From 501904a912258a40c0e4b3f10ec69e21f6ea6cdd Mon Sep 17 00:00:00 2001 From: Kamal Bennani Date: Mon, 20 Nov 2023 10:54:50 +0100 Subject: [PATCH 01/15] feat: expose a way to switch from one cluster/app to the other --- package-lock.json | 4 ++-- src/core/connection/connection_manager.ts | 9 +++++++++ src/core/options.ts | 5 +++++ src/core/pusher.ts | 20 ++++++++++++++----- .../core/connection/connection_manager.d.ts | 1 + types/src/core/options.d.ts | 4 ++++ types/src/core/pusher.d.ts | 4 +++- 7 files changed, 39 insertions(+), 8 deletions(-) diff --git a/package-lock.json b/package-lock.json index 0e9f6a439..b7ea0c54c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "pusher-js", - "version": "8.2.0", + "version": "8.3.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "pusher-js", - "version": "8.2.0", + "version": "8.3.0", "license": "MIT", "dependencies": { "tweetnacl": "^1.0.3" diff --git a/src/core/connection/connection_manager.ts b/src/core/connection/connection_manager.ts index f913da446..333abcde5 100644 --- a/src/core/connection/connection_manager.ts +++ b/src/core/connection/connection_manager.ts @@ -96,6 +96,15 @@ export default class ConnectionManager extends EventsDispatcher { this.updateStrategy(); } + switchCluster(key: string) { + this.key = key; + // This ensures that the new config coming from + // pusher instance are taken into account + // such as appKey and cluster + this.updateStrategy(); + this.retryIn(0); + } + /** Establishes a connection to Pusher. * * Does nothing when connection is already established. See top-level doc diff --git a/src/core/options.ts b/src/core/options.ts index baf974eee..b748a02a3 100644 --- a/src/core/options.ts +++ b/src/core/options.ts @@ -44,6 +44,11 @@ export interface Options { wssPort?: number; } +export interface ClusterOptions { + appKey: string; + cluster: string; +} + export function validateOptions(options) { if (options == null) { throw 'You must pass an options object'; diff --git a/src/core/pusher.ts b/src/core/pusher.ts index 0d9616094..b1ffc8ed1 100644 --- a/src/core/pusher.ts +++ b/src/core/pusher.ts @@ -1,6 +1,5 @@ import AbstractRuntime from '../runtimes/interface'; import Runtime from 'runtime'; -import Util from './util'; import * as Collections from './utils/collections'; import Channels from './channels/channels'; import Channel from './channels/channel'; @@ -10,14 +9,11 @@ import TimelineSender from './timeline/timeline_sender'; import TimelineLevel from './timeline/level'; import { defineTransport } from './strategies/strategy_builder'; import ConnectionManager from './connection/connection_manager'; -import ConnectionManagerOptions from './connection/connection_manager_options'; import { PeriodicTimer } from './utils/timers'; import Defaults from './defaults'; -import * as DefaultConfig from './config'; import Logger from './logger'; import Factory from './utils/factory'; -import UrlStore from 'core/utils/url_store'; -import { Options, validateOptions } from './options'; +import { Options, ClusterOptions, validateOptions } from './options'; import { Config, getConfig } from './config'; import StrategyOptions from './strategies/strategy_options'; import UserFacade from './user'; @@ -53,6 +49,7 @@ export default class Pusher { /* INSTANCE PROPERTIES */ key: string; + options: Options; config: Config; channels: Channels; global_emitter: EventsDispatcher; @@ -141,6 +138,19 @@ export default class Pusher { } } + /** + * Allows you to switch Pusher cluster without + * losing all the channels/subscription binding + * as this is internally managed by the SDK. + */ + switchCluster(options: ClusterOptions) { + const { appKey, cluster } = options; + this.key = appKey; + this.options = { ...this.options, cluster }; + this.config = getConfig(this.options, this); + this.connection.switchCluster(this.key); + } + channel(name: string): Channel { return this.channels.find(name); } diff --git a/types/src/core/connection/connection_manager.d.ts b/types/src/core/connection/connection_manager.d.ts index e63fea71f..53dc9110f 100644 --- a/types/src/core/connection/connection_manager.d.ts +++ b/types/src/core/connection/connection_manager.d.ts @@ -24,6 +24,7 @@ export default class ConnectionManager extends EventsDispatcher { handshakeCallbacks: HandshakeCallbacks; connectionCallbacks: ConnectionCallbacks; constructor(key: string, options: ConnectionManagerOptions); + switchCluster(key: string): void; connect(): void; send(data: any): boolean; send_event(name: string, data: any, channel?: string): boolean; diff --git a/types/src/core/options.d.ts b/types/src/core/options.d.ts index 64c47f625..ee8ce2b3e 100644 --- a/types/src/core/options.d.ts +++ b/types/src/core/options.d.ts @@ -31,4 +31,8 @@ export interface Options { wsPort?: number; wssPort?: number; } +export interface ClusterOptions { + appKey: string; + cluster: string; +} export declare function validateOptions(options: any): void; diff --git a/types/src/core/pusher.d.ts b/types/src/core/pusher.d.ts index 9d0f652d7..a3708fc0e 100644 --- a/types/src/core/pusher.d.ts +++ b/types/src/core/pusher.d.ts @@ -6,7 +6,7 @@ import Timeline from './timeline/timeline'; import TimelineSender from './timeline/timeline_sender'; import ConnectionManager from './connection/connection_manager'; import { PeriodicTimer } from './utils/timers'; -import { Options } from './options'; +import { Options, ClusterOptions } from './options'; import { Config } from './config'; import UserFacade from './user'; export default class Pusher { @@ -21,6 +21,7 @@ export default class Pusher { static log: (message: any) => void; private static getClientFeatures; key: string; + options: Options; config: Config; channels: Channels; global_emitter: EventsDispatcher; @@ -31,6 +32,7 @@ export default class Pusher { timelineSenderTimer: PeriodicTimer; user: UserFacade; constructor(app_key: string, options: Options); + switchCluster(options: ClusterOptions): void; channel(name: string): Channel; allChannels(): Channel[]; connect(): void; From 83f4db8ac42c37518739249a70252f3ca3759e74 Mon Sep 17 00:00:00 2001 From: Kamal Bennani Date: Mon, 20 Nov 2023 12:06:57 +0100 Subject: [PATCH 02/15] test: cover the new logic with unit tests --- spec/javascripts/helpers/mocks.js | 1 + .../connection/connection_manager_spec.js | 43 +++++++++++++++++++ spec/javascripts/unit/core/pusher_spec.js | 41 ++++++++++++++++++ 3 files changed, 85 insertions(+) diff --git a/spec/javascripts/helpers/mocks.js b/spec/javascripts/helpers/mocks.js index 0e11d7c13..400affbf9 100644 --- a/spec/javascripts/helpers/mocks.js +++ b/spec/javascripts/helpers/mocks.js @@ -245,6 +245,7 @@ var Mocks = { manager.disconnect = jasmine.createSpy("disconnect"); manager.send_event = jasmine.createSpy("send_event"); manager.isUsingTLS = jasmine.createSpy("isUsingTLS").and.returnValue(false); + manager.switchCluster = jasmine.createSpy("switchCluster"); return manager; }, diff --git a/spec/javascripts/unit/core/connection/connection_manager_spec.js b/spec/javascripts/unit/core/connection/connection_manager_spec.js index 412577cc1..db0a7c83d 100644 --- a/spec/javascripts/unit/core/connection/connection_manager_spec.js +++ b/spec/javascripts/unit/core/connection/connection_manager_spec.js @@ -116,6 +116,49 @@ describe("ConnectionManager", function() { }); }); + describe("#switchCluster", function() { + it("should update cluster key", function() { + expect(manager.key).toEqual("foo"); + manager.switchCluster("bar"); + expect(manager.key).toEqual("bar"); + }); + + it("should re-build the strategy", function() { + expect(managerOptions.getStrategy.calls.count()).toEqual(1); + manager.switchCluster("bar"); + expect(managerOptions.getStrategy.calls.count()).toEqual(2); + expect(managerOptions.getStrategy).toHaveBeenCalledWith({ + key: "bar", + useTLS: false, + timeline: timeline + }); + }); + + it("should try to connect using the strategy", function() { + manager.switchCluster("bar"); + // connection is retried with a zero delay + jasmine.clock().tick(0); + expect(strategy.connect).toHaveBeenCalled(); + }); + + it("should transition to connecting", function() { + var onConnecting = jasmine.createSpy("onConnecting"); + var onStateChange = jasmine.createSpy("onStateChange"); + manager.bind("connecting", onConnecting); + manager.bind("state_change", onStateChange); + + manager.switchCluster("bar");// connection is retried with a zero delay + jasmine.clock().tick(0); + + expect(manager.state).toEqual("connecting"); + expect(onConnecting).toHaveBeenCalled(); + expect(onStateChange).toHaveBeenCalledWith({ + previous: "initialized", + current: "connecting" + }); + }); + }); + describe("before establishing a connection", function() { beforeEach(function() { manager.connect(); diff --git a/spec/javascripts/unit/core/pusher_spec.js b/spec/javascripts/unit/core/pusher_spec.js index 250b420ea..28cfd73f9 100644 --- a/spec/javascripts/unit/core/pusher_spec.js +++ b/spec/javascripts/unit/core/pusher_spec.js @@ -307,6 +307,47 @@ describe("Pusher", function() { }); }); + describe("switch cluster", function() { + var pusher; + var subscribedChannels + + beforeEach(function() { + pusher = new Pusher("foo", {cluster: "mt1"}); + + subscribedChannels = { + channel1: pusher.subscribe("channel1"), + channel2: pusher.subscribe("channel2") + }; + + pusher.connect(); + pusher.connection.state = "connected"; + pusher.connection.emit("connected"); + }); + + it("should resubscribe to all channels", function() { + expect(subscribedChannels.channel1.subscribe).toHaveBeenCalledTimes(1); + expect(subscribedChannels.channel2.subscribe).toHaveBeenCalledTimes(1); + + pusher.switchCluster({ appKey: 'bar', cluster: 'us3' }); + pusher.connect(); + pusher.connection.state = 'connected'; + pusher.connection.emit('connected'); + + expect(subscribedChannels.channel1.subscribe).toHaveBeenCalledTimes(2); + expect(subscribedChannels.channel2.subscribe).toHaveBeenCalledTimes(2); + }); + + it("should send events via the connection manager", function() { + pusher.switchCluster({ appKey: 'bar', cluster: 'us3' }); + pusher.send_event("event", { key: "value" }, "channel"); + expect(pusher.connection.send_event).toHaveBeenCalledWith( + "event", + { key: "value" }, + "channel" + ); + }); + }) + describe("#unsubscribe", function() { it("should unsubscribe the channel if subscription is not pending", function() { var channel = pusher.subscribe("yyy"); From d4a5e592f6ea81ec1d112b7fba54af5880cfb259 Mon Sep 17 00:00:00 2001 From: Pusher CI Date: Wed, 29 Nov 2023 08:16:01 +0000 Subject: [PATCH 03/15] Bump to version 8.4.0 --- CHANGELOG.md | 4 ++++ dist/node/pusher.js | 16 ++++++++++++++-- dist/node/pusher.js.map | 2 +- dist/react-native/pusher.js | 4 ++-- dist/react-native/pusher.js.map | 2 +- dist/web/pusher-with-encryption.js | 16 ++++++++++++++-- dist/web/pusher-with-encryption.js.map | 2 +- dist/web/pusher-with-encryption.min.js | 4 ++-- dist/web/pusher-with-encryption.min.js.map | 2 +- dist/web/pusher.js | 16 ++++++++++++++-- dist/web/pusher.js.map | 2 +- dist/web/pusher.min.js | 4 ++-- dist/web/pusher.min.js.map | 2 +- dist/worker/pusher-with-encryption.worker.js | 16 ++++++++++++++-- dist/worker/pusher-with-encryption.worker.js.map | 2 +- dist/worker/pusher-with-encryption.worker.min.js | 4 ++-- .../pusher-with-encryption.worker.min.js.map | 2 +- dist/worker/pusher.worker.js | 16 ++++++++++++++-- dist/worker/pusher.worker.js.map | 2 +- dist/worker/pusher.worker.min.js | 4 ++-- dist/worker/pusher.worker.min.js.map | 2 +- package.json | 2 +- 22 files changed, 95 insertions(+), 31 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fbe365717..c9058fa85 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## 8.4.0 + +- [Added] Introduce a new method to switch the Pusher client to a different cluster and re-establish all existing subscriptions and channel bindings. + ## 8.3.0 - [CHANGED] Update cached re-connect strategy to prioritize WebSocket diff --git a/dist/node/pusher.js b/dist/node/pusher.js index 4852ffd9b..1e84cb8a6 100644 --- a/dist/node/pusher.js +++ b/dist/node/pusher.js @@ -1,5 +1,5 @@ /*! - * Pusher JavaScript Library v8.3.0 + * Pusher JavaScript Library v8.4.0 * https://pusher.com/ * * Copyright 2020, Pusher @@ -7499,7 +7499,7 @@ function safeJSONStringify(source) { // CONCATENATED MODULE: ./src/core/defaults.ts var Defaults = { - VERSION: "8.3.0", + VERSION: "8.4.0", PROTOCOL: 7, wsPort: 80, wssPort: 443, @@ -8741,6 +8741,11 @@ class connection_manager_ConnectionManager extends dispatcher_Dispatcher { }); this.updateStrategy(); } + switchCluster(key) { + this.key = key; + this.updateStrategy(); + this.retryIn(0); + } connect() { if (this.connection || this.runner) { return; @@ -10746,6 +10751,13 @@ class pusher_Pusher { this.connect(); } } + switchCluster(options) { + const { appKey, cluster } = options; + this.key = appKey; + this.options = Object.assign(Object.assign({}, this.options), { cluster }); + this.config = getConfig(this.options, this); + this.connection.switchCluster(this.key); + } channel(name) { return this.channels.find(name); } diff --git a/dist/node/pusher.js.map b/dist/node/pusher.js.map index addc29aa2..215373adb 100644 --- a/dist/node/pusher.js.map +++ b/dist/node/pusher.js.map @@ -1 +1 @@ -{"version":3,"sources":["webpack://Pusher/webpack/bootstrap","webpack://Pusher/external \"util\"","webpack://Pusher/./node_modules/safe-buffer/index.js","webpack://Pusher/./node_modules/websocket-driver/lib/websocket/driver/base.js","webpack://Pusher/external \"crypto\"","webpack://Pusher/./node_modules/websocket-driver/lib/websocket/driver.js","webpack://Pusher/external \"stream\"","webpack://Pusher/external \"url\"","webpack://Pusher/./node_modules/faye-websocket/lib/faye/websocket/api/event.js","webpack://Pusher/./node_modules/@stablelib/base64/base64.ts","webpack://Pusher/./node_modules/websocket-driver/lib/websocket/driver/headers.js","webpack://Pusher/./node_modules/websocket-driver/lib/websocket/http_parser.js","webpack://Pusher/./node_modules/faye-websocket/lib/faye/websocket/api.js","webpack://Pusher/./node_modules/websocket-driver/lib/websocket/driver/hybi.js","webpack://Pusher/./node_modules/websocket-extensions/lib/pipeline/ring_buffer.js","webpack://Pusher/./node_modules/websocket-extensions/lib/pipeline/pledge.js","webpack://Pusher/./node_modules/websocket-driver/lib/websocket/driver/draft75.js","webpack://Pusher/./node_modules/faye-websocket/lib/faye/websocket/api/event_target.js","webpack://Pusher/./node_modules/@stablelib/utf8/utf8.ts","webpack://Pusher/./node_modules/faye-websocket/lib/faye/websocket.js","webpack://Pusher/./node_modules/xmlhttprequest/lib/XMLHttpRequest.js","webpack://Pusher/./node_modules/tweetnacl/nacl-fast.js","webpack://Pusher/./src/core/pusher-with-encryption.js","webpack://Pusher/external \"buffer\"","webpack://Pusher/external \"events\"","webpack://Pusher/./node_modules/websocket-driver/lib/websocket/streams.js","webpack://Pusher/./node_modules/websocket-driver/lib/websocket/driver/stream_reader.js","webpack://Pusher/./node_modules/websocket-driver/lib/websocket/driver/client.js","webpack://Pusher/./node_modules/http-parser-js/http-parser.js","webpack://Pusher/external \"assert\"","webpack://Pusher/./node_modules/websocket-extensions/lib/websocket_extensions.js","webpack://Pusher/./node_modules/websocket-extensions/lib/parser.js","webpack://Pusher/./node_modules/websocket-extensions/lib/pipeline/index.js","webpack://Pusher/./node_modules/websocket-extensions/lib/pipeline/cell.js","webpack://Pusher/./node_modules/websocket-extensions/lib/pipeline/functor.js","webpack://Pusher/./node_modules/websocket-driver/lib/websocket/driver/hybi/frame.js","webpack://Pusher/./node_modules/websocket-driver/lib/websocket/driver/hybi/message.js","webpack://Pusher/./node_modules/websocket-driver/lib/websocket/driver/proxy.js","webpack://Pusher/./node_modules/websocket-driver/lib/websocket/driver/server.js","webpack://Pusher/./node_modules/websocket-driver/lib/websocket/driver/draft76.js","webpack://Pusher/./node_modules/faye-websocket/lib/faye/websocket/client.js","webpack://Pusher/external \"net\"","webpack://Pusher/external \"tls\"","webpack://Pusher/./node_modules/faye-websocket/lib/faye/eventsource.js","webpack://Pusher/external \"child_process\"","webpack://Pusher/external \"fs\"","webpack://Pusher/external \"http\"","webpack://Pusher/external \"https\"","webpack://Pusher/./src/core/base64.ts","webpack://Pusher/./src/core/utils/timers/abstract_timer.ts","webpack://Pusher/./src/core/utils/timers/index.ts","webpack://Pusher/./src/core/util.ts","webpack://Pusher/./src/core/utils/collections.ts","webpack://Pusher/./src/core/defaults.ts","webpack://Pusher/./src/core/transports/url_schemes.ts","webpack://Pusher/./src/core/events/callback_registry.ts","webpack://Pusher/./src/core/events/dispatcher.ts","webpack://Pusher/./src/core/logger.ts","webpack://Pusher/./src/core/transports/transport_connection.ts","webpack://Pusher/./src/core/transports/transport.ts","webpack://Pusher/./src/runtimes/isomorphic/transports/transports.ts","webpack://Pusher/./src/core/transports/assistant_to_the_transport_manager.ts","webpack://Pusher/./src/core/connection/protocol/protocol.ts","webpack://Pusher/./src/core/connection/connection.ts","webpack://Pusher/./src/core/connection/handshake/index.ts","webpack://Pusher/./src/core/timeline/timeline_sender.ts","webpack://Pusher/./src/core/errors.ts","webpack://Pusher/./src/core/utils/url_store.ts","webpack://Pusher/./src/core/channels/channel.ts","webpack://Pusher/./src/core/channels/private_channel.ts","webpack://Pusher/./src/core/channels/members.ts","webpack://Pusher/./src/core/channels/presence_channel.ts","webpack://Pusher/./src/core/channels/encrypted_channel.ts","webpack://Pusher/./src/core/connection/connection_manager.ts","webpack://Pusher/./src/core/channels/channels.ts","webpack://Pusher/./src/core/utils/factory.ts","webpack://Pusher/./src/core/transports/transport_manager.ts","webpack://Pusher/./src/core/strategies/sequential_strategy.ts","webpack://Pusher/./src/core/strategies/best_connected_ever_strategy.ts","webpack://Pusher/./src/core/strategies/websocket_prioritized_cached_strategy.ts","webpack://Pusher/./src/core/strategies/delayed_strategy.ts","webpack://Pusher/./src/core/strategies/if_strategy.ts","webpack://Pusher/./src/core/strategies/first_connected_strategy.ts","webpack://Pusher/./src/runtimes/isomorphic/default_strategy.ts","webpack://Pusher/./src/runtimes/isomorphic/transports/transport_connection_initializer.ts","webpack://Pusher/./src/core/http/http_request.ts","webpack://Pusher/./src/core/http/state.ts","webpack://Pusher/./src/core/http/http_socket.ts","webpack://Pusher/./src/core/http/http_streaming_socket.ts","webpack://Pusher/./src/core/http/http_polling_socket.ts","webpack://Pusher/./src/runtimes/isomorphic/http/http_xhr_request.ts","webpack://Pusher/./src/runtimes/isomorphic/http/http.ts","webpack://Pusher/./src/runtimes/isomorphic/runtime.ts","webpack://Pusher/./src/runtimes/node/net_info.ts","webpack://Pusher/./src/core/auth/options.ts","webpack://Pusher/./src/runtimes/isomorphic/auth/xhr_auth.ts","webpack://Pusher/./src/runtimes/isomorphic/timeline/xhr_timeline.ts","webpack://Pusher/./src/runtimes/node/runtime.ts","webpack://Pusher/./src/core/timeline/level.ts","webpack://Pusher/./src/core/timeline/timeline.ts","webpack://Pusher/./src/core/strategies/transport_strategy.ts","webpack://Pusher/./src/core/strategies/strategy_builder.ts","webpack://Pusher/./src/core/options.ts","webpack://Pusher/./src/core/auth/user_authenticator.ts","webpack://Pusher/./src/core/auth/channel_authorizer.ts","webpack://Pusher/./src/core/auth/deprecated_channel_authorizer.ts","webpack://Pusher/./src/core/config.ts","webpack://Pusher/./src/core/watchlist.ts","webpack://Pusher/./src/core/utils/flat_promise.ts","webpack://Pusher/./src/core/user.ts","webpack://Pusher/./src/core/pusher.ts","webpack://Pusher/./src/core/pusher-with-encryption.ts"],"names":[],"mappings":";;;;;;;;;;QAAA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;;QAEA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;;;QAGA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;QACA,0CAA0C,gCAAgC;QAC1E;QACA;;QAEA;QACA;QACA;QACA,wDAAwD,kBAAkB;QAC1E;QACA,iDAAiD,cAAc;QAC/D;;QAEA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA,yCAAyC,iCAAiC;QAC1E,gHAAgH,mBAAmB,EAAE;QACrI;QACA;;QAEA;QACA;QACA;QACA,2BAA2B,0BAA0B,EAAE;QACvD,iCAAiC,eAAe;QAChD;QACA;QACA;;QAEA;QACA,sDAAsD,+DAA+D;;QAErH;QACA;;;QAGA;QACA;;;;;;;AClFA,iC;;;;;;ACAA;AACA,aAAa,mBAAO,CAAC,EAAQ;AAC7B;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AACD;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;;;;;;;AC7Da;;AAEb,cAAc,mBAAO,CAAC,CAAa;AACnC,cAAc,mBAAO,CAAC,EAAQ;AAC9B,cAAc,mBAAO,CAAC,CAAM;AAC5B,cAAc,mBAAO,CAAC,EAAY;AAClC,cAAc,mBAAO,CAAC,CAAW;AACjC,cAAc,mBAAO,CAAC,EAAiB;;AAEvC;AACA;AACA,oCAAoC;;AAEpC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA,2CAA2C;;AAE3C;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA,KAAK;AACL,GAAG;;AAEH;AACA;AACA,GAAG;;AAEH;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA;AACA,GAAG;;AAEH;AACA;;AAEA;AACA;;AAEA;;AAEA;AACA;AACA,KAAK;AACL;AACA;;AAEA;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA,GAAG;;AAEH;AACA;AACA,GAAG;;AAEH;AACA;AACA,GAAG;;AAEH;AACA;AACA,GAAG;;AAEH;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA,yCAAyC,+BAA+B;AACxE;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;;AAGA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;;;;;;;AChMA,mC;;;;;;;ACAa;;AAEb;AACA;AACA;AACA;AACA;;AAEA,aAAa,mBAAO,CAAC,CAAe;AACpC,aAAa,mBAAO,CAAC,EAAiB;AACtC,aAAa,mBAAO,CAAC,EAAiB;;AAEtC;AACA;AACA;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA,GAAG;;AAEH;AACA;AACA,GAAG;;AAEH;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA;;AAEA;;;;;;;AC1CA,mC;;;;;;ACAA,gC;;;;;;;ACAa;;AAEb;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;;;;;;;;;ACrBA,sCAAsC;AACtC,6CAA6C;;;;;;;;;;;;;;;AAE7C;;GAEG;AAEH,iDAAiD;AACjD,kDAAkD;AAClD,kCAAkC;AAClC,IAA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AEtB,wBAAgB,GAAG,UAAC,MAAc;IAC3C,eAAQ,CAAC,gBAAgB,CAAC,MAAM,CAAC;AAAjC,CAAiC,CAAC;AAEzB,qBAAa,GAAG,UAAC,CAAS;IACnC,eAAQ,CAAC,aAAa,CAAC,CAAC,CAAC;AAAzB,CAAyB,CAAC;;;;;;;;AC1RjB;;AAEb;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;;;;;;;;AClCa;;AAEb,qBAAqB,mBAAO,CAAC,EAAgB;AAC7C,qBAAqB,mBAAO,CAAC,CAAa;;AAE1C;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;;AAEA,mDAAmD,OAAO;AAC1D;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,sDAAsD,yBAAyB;AAC/E;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;;;;;;;;ACtIa;;AAEb,kBAAkB,mBAAO,CAAC,CAAQ;AAClC,kBAAkB,mBAAO,CAAC,CAAM;AAChC,kBAAkB,mBAAO,CAAC,CAAkB;AAC5C,kBAAkB,mBAAO,CAAC,EAAoB;AAC9C,kBAAkB,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iB,mBAAO,CAAC,CAAQ;AACjC,iBAAiB,mBAAO,CAAC,EAAc;AACvC,iBAAiB,mBAAO,CAAC,EAAgB;;AAEzC;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA;AACA,+CAA+C,mCAAmC;AAClF;;AAEA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;;AAEA,8CAA8C,OAAO;AACrD;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA;;AAEA;AACA,8GAA8G,EAAE,uDAAuD,EAAE,wBAAwB,EAAE,4BAA4B,EAAE;;AAEjO;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA,yCAAyC,oCAAoC;AAC7E;AACA,KAAK;AACL;AACA;AACA,GAAG;;AAEH;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;;AAEA;AACA,GAAG;;AAEH;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,KAAK;AACL;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;AACA,GAAG;;AAEH;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA,GAAG;;AAEH;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL,GAAG;;AAEH;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA,KAAK;;AAEL;;AAEA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;;AAEA;AACA;AACA,GAAG;;AAEH;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA,GAAG;;AAEH;AACA;;AAEA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA,GAAG;;AAEH;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA,KAAK;AACL,GAAG;;AAEH;AACA;AACA;AACA;AACA,KAAK;AACL;AACA,GAAG;;AAEH;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;;;;;;;;AClea;;AAEb;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA,GAAG;AACH;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;;AAEA;;;;;;;;ACjEa;;AAEb,iBAAiB,mBAAO,CAAC,EAAe;;AAExC;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA,GAAG;AACH;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;;;;;;;;ACpCa;;AAEb,aAAa,mBAAO,CAAC,CAAa;AAClC,aAAa,mBAAO,CAAC,CAAQ;AAC7B,aAAa,mBAAO,CAAC,CAAM;;AAE3B;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;;AAEH;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa;AACb;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL,GAAG;;AAEH;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA,GAAG;;AAEH;AACA;AACA;;AAEA;AACA,GAAG;;AAEH;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;;;;;;;;AC1Ha;;AAEb,YAAY,mBAAO,CAAC,CAAS;;AAE7B;AACA;AACA;AACA;AACA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AACA;AACA;AACA,aAAa,mBAAO,CAAC,EAAM;AAC3B,cAAc,mBAAO,CAAC,EAAO;;AAE7B;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,WAAW;AACX;AACA;AACA;AACA;AACA,SAAS;AACT,OAAO;AACP;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,KAAK;AACL;;AAEA;AACA,8CAA8C;AAC9C;AACA,KAAK;AACL;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;;AAET;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;;AAET;AACA;AACA,SAAS;AACT;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;;AAEA;AACA,KAAK,OAAO;AACZ;AACA;AACA;AACA;AACA;AACA,iGAAiG;AACjG,gEAAgE;AAChE,yDAAyD;AACzD,iCAAiC;AACjC,4DAA4D;AAC5D,wCAAwC;AACxC,gDAAgD;AAChD,mCAAmC;AACnC,YAAY,EAAE;AACd,0CAA0C;AAC1C,mEAAmE,kBAAkB,gFAAgF,WAAW;AAChL,6CAA6C;AAC7C,YAAY,EAAE;AACd,iDAAiD;AACjD,mEAAmE,WAAW,WAAW;AACzF,6CAA6C;AAC7C,YAAY,EAAE;AACd,YAAY,+BAA+B;AAC3C,mEAAmE,WAAW,WAAW;AACzF,6CAA6C;AAC7C,YAAY,EAAE;AACd,8FAA8F;AAC9F,qBAAqB;AACrB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,OAAO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,oDAAoD,SAAS;AAC7D;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;AC3mBA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,uBAAuB,iBAAiB;AACxC;AACA;;AAEA;AACA,wCAAwC,4BAA4B;;AAEpE;AACA,4BAA4B;;AAE5B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa,OAAO;AACpB;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,aAAa,QAAQ;AACrB,aAAa,OAAO;AACpB;AACA;AACA,eAAe,QAAQ;AACvB;AACA,eAAe,QAAQ;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB;AACA;AACA;;AAEA;AACA;AACA;AACA,aAAa,QAAQ;AACrB,aAAa,OAAO;AACpB;AACA;AACA,eAAe,QAAQ;AACvB;AACA,eAAe,QAAQ;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,iBAAiB,OAAO;AACxB;AACA;;AAEA;AACA;AACA;AACA;AACA,iBAAiB,OAAO;AACxB;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA,8CAA8C;AAC9C,8CAA8C;AAC9C,8CAA8C;AAC9C,8CAA8C;AAC9C,8CAA8C;AAC9C;AACA,8CAA8C;AAC9C,8CAA8C;AAC9C,8CAA8C;AAC9C;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,sDAAsD;AACtD,sDAAsD;AACtD,sDAAsD;AACtD,sDAAsD;AACtD,sDAAsD;AACtD;AACA,sDAAsD;AACtD,sDAAsD;AACtD,sDAAsD;AACtD;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA,qBAAqB;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA,qBAAqB;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA,qBAAqB;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA,qBAAqB;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA,qBAAqB;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA,qBAAqB;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA,qBAAqB;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA,qBAAqB;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA,qBAAqB;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA,qBAAqB;;AAErB;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA,UAAU,QAAQ;AAClB;AACA;AACA;;AAEA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA;AACA;;AAEA;AACA,aAAa,QAAQ;AACrB;AACA,aAAa,QAAQ;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa,OAAO;AACpB;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,UAAU;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,eAAe,WAAW;AAC1B;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;;AAEA;AACA;AACA,aAAa,QAAQ;AACrB;;AAEA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA,aAAa,OAAO;AACpB;AACA,eAAe,QAAQ;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;;AAEA;AACA,iBAAiB,QAAQ;AACzB;;AAEA;AACA,iBAAiB,QAAQ;AACzB;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD;;AAEA;AACA;AACA,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA,aAAa,QAAQ;AACrB,eAAe,QAAQ;AACvB;AACA;AACA;AACA,aAAa,QAAQ;AACrB;;AAEA;AACA;AACA;AACA,aAAa,QAAQ;AACrB,eAAe,QAAQ;AACvB;AACA;AACA;AACA,aAAa,QAAQ;AACrB;;AAEA;AACA;AACA;AACA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA;AACA,aAAa,MAAM;AACnB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,eAAe,QAAQ;AACvB;AACA;AACA;AACA;AACA,eAAe,QAAQ;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA,qBAAqB;AACrB,qBAAqB;;AAErB;AACA;AACA;;AAEA,sBAAsB;AACtB,sBAAsB;;AAEtB;AACA;AACA;;AAEA,sBAAsB;AACtB,sBAAsB;;AAEtB;AACA;AACA;;AAEA,sBAAsB;AACtB,sBAAsB;;AAEtB;AACA;AACA;;AAEA,sBAAsB;AACtB,sBAAsB;;AAEtB;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA,qBAAqB;AACrB,qBAAqB;;AAErB;AACA;AACA;;AAEA,sBAAsB;AACtB,sBAAsB;;AAEtB;AACA;AACA;;AAEA,sBAAsB;AACtB,sBAAsB;;AAEtB;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA,qBAAqB;AACrB,qBAAqB;;AAErB;AACA;;AAEA,sBAAsB;AACtB,sBAAsB;;AAEtB;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;A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;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA,aAAa,OAAO;AACpB;;AAEA;AACA;AACA;AACA;;AAEA,aAAa,OAAO;;AAEpB;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa,OAAO;AACpB;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,QAAQ;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA,aAAa,QAAQ;AACrB;AACA;;AAEA;;AAEA;AACA;AACA,cAAc,SAAS;AACvB;AACA,gCAAgC,OAAO;AACvC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA;AACA,aAAa,QAAQ;AACrB,aAAa,QAAQ;AACrB;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa,QAAQ;AACrB,aAAa,QAAQ;AACrB;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA,aAAa,OAAO;AACpB,aAAa,QAAQ;;AAErB;AACA;AACA;AACA;;AAEA,cAAc,QAAQ;AACtB;AACA;;AAEA,aAAa,QAAQ;AACrB,aAAa,QAAQ;AACrB,aAAa,QAAQ;AACrB,eAAe,QAAQ;AACvB;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;;AAEA,aAAa,OAAO;AACpB,aAAa,QAAQ;AACrB;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA,eAAe,OAAO;AACtB;AACA;;AAEA,aAAa,OAAO;AACpB;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA,iBAAiB,sBAAsB;AACvC;AACA;AACA;AACA;;AAEA;AACA,iBAAiB,gBAAgB;AACjC;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,iBAAiB,gBAAgB;AACjC;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,iBAAiB,gBAAgB;AACjC;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA,UAAU;AACV;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,UAAU;AACV;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAiB,cAAc;AAC/B;AACA;;AAEA;AACA;AACA;AACA,iBAAiB,gBAAgB;AACjC;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa,uBAAuB;AACpC,aAAa,gBAAgB;AAC7B;AACA;;AAEA;AACA;AACA;AACA;AACA,UAAU;AACV;;AAEA;AACA;AACA;AACA;AACA;AACA,iBAAiB,eAAe;AAChC,UAAU;AACV;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAiB,QAAQ;AACzB;AACA,UAAU;AACV;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAiB,OAAO;AACxB;AACA;AACA,iBAAiB,OAAO;AACxB;AACA,KAAK;AACL,GAAG,UAAU,IAA8B;AAC3C;AACA,aAAa,mBAAO,CAAC,CAAQ;AAC7B;AACA;AACA;AACA,mBAAmB,OAAO;AAC1B;AACA,OAAO;AACP;AACA;AACA,CAAC;;AAED,CAAC,EAAE,KAA6B,kEAAkE;;;;;;;ACt1ElG,iBAAiB,mBAAO,CAAC,EAA0B;;;;;;;ACAnD,mC;;;;;;ACAA,mC;;;;;;;ACAa;;AAEb;;AAEA;AACA;;AAEA;AACA;;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AAGA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;;AAGA,aAAa,mBAAO,CAAC,CAAQ;AAC7B,aAAa,mBAAO,CAAC,CAAM;;;AAG3B;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;;AAGA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;;AAGA;AACA;;;;;;;;ACjJa;;AAEb,aAAa,mBAAO,CAAC,CAAa;;AAElC;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;;AAEA,mCAAmC,OAAO;AAC1C;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;;;;;;;ACpEa;;AAEb,iBAAiB,mBAAO,CAAC,CAAa;AACtC,iBAAiB,mBAAO,CAAC,CAAQ;AACjC,iBAAiB,mBAAO,CAAC,CAAK;AAC9B,iBAAiB,mBAAO,CAAC,CAAM;AAC/B,iBAAiB,mBAAO,CAAC,EAAgB;AACzC,iBAAiB,mBAAO,CAAC,CAAQ;AACjC,iBAAiB,mBAAO,CAAC,EAAQ;AACjC,iBAAiB,mBAAO,CAAC,EAAS;;AAElC;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA,GAAG;;AAEH;AACA;AACA;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;;AAEA;AACA;;AAEA;;;;;;;AC7IA;;AAEA,aAAa,mBAAO,CAAC,EAAQ;;AAE7B;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,sBAAsB;AACtB;AACA;AACA;AACA;;AAEA;AACA,qCAAqC;AACrC;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,8CAA8C,UAAU;;AAExD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,2BAA2B,SAAS;AACpC,4BAA4B;AAC5B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,UAAU;AACV;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,yCAAyC,EAAE;AAC3C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA,mDAAmD;AACnD;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA,mBAAmB,oBAAoB;AACvC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW;AACX;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA,KAAK;AACL;AACA;AACA,kCAAkC;AAClC;AACA,KAAK;AACL;AACA,KAAK;AACL;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH,CAAC;;AAED;AACA;AACA;AACA;AACA;;;;;;;AC9cA,mC;;;;;;;ACAa;;AAEb,eAAe,mBAAO,CAAC,EAAU;AACjC,eAAe,mBAAO,CAAC,EAAY;;AAEnC;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA,OAAO;AACP,KAAK;;AAEL;AACA;;AAEA;AACA,GAAG;;AAEH;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA,KAAK;;AAEL;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,KAAK;;AAEL;AACA;;AAEA;AACA,GAAG;;AAEH;AACA,mBAAmB,wCAAwC;AAC3D;;AAEA;AACA,gDAAgD,OAAO;AACvD;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA,GAAG;;AAEH;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;;;;;;;;ACjKa;;AAEb;AACA;AACA;AACA;AACA,gDAAgD;AAChD;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA,SAAS;AACT;AACA,SAAS;AACT;AACA;AACA;;AAEA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA,OAAO;AACP;AACA,KAAK;;AAEL;AACA,GAAG;;AAEH;AACA;;AAEA;AACA;AACA,mCAAmC,gBAAgB;AACnD,OAAO;AACP;AACA,OAAO;AACP;AACA,OAAO;AACP;AACA,OAAO;AACP;AACA;AACA;;AAEA;;AAEA,wCAAwC;AACxC;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA,sBAAsB,6BAA6B;AACnD;;AAEA;AACA;AACA,kCAAkC,OAAO;AACzC;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;;;;;;;;ACtGa;;AAEb,aAAa,mBAAO,CAAC,EAAQ;AAC7B,aAAa,mBAAO,CAAC,EAAU;;AAE/B;AACA,kDAAkD,2BAA2B;AAC7E,mBAAmB;AACnB;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA,mBAAmB;;AAEnB,4CAA4C,mBAAmB;AAC/D;AACA,wCAAwC,yBAAyB;AACjE;;AAEA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;;AAEA;;;;;;;;AC9Ca;;AAEb,cAAc,mBAAO,CAAC,EAAW;AACjC,cAAc,mBAAO,CAAC,EAAU;;AAEhC;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;;;;;;;;ACpDa;;AAEb,iBAAiB,mBAAO,CAAC,EAAe;;AAExC;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA,gBAAgB,oFAAoF;AACpG;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA,GAAG;AACH;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;;AAEA;;;;;;;;ACvEa;;AAEb;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;;;;;;;;ACpBa;;AAEb,aAAa,mBAAO,CAAC,CAAa;;AAElC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;;;;;;;;ACjCa;;AAEb,iBAAiB,mBAAO,CAAC,CAAa;AACtC,iBAAiB,mBAAO,CAAC,CAAQ;AACjC,iBAAiB,mBAAO,CAAC,CAAK;AAC9B,iBAAiB,mBAAO,CAAC,CAAM;AAC/B,iBAAiB,mBAAO,CAAC,CAAQ;AACjC,iBAAiB,mBAAO,CAAC,CAAW;AACpC,iBAAiB,mBAAO,CAAC,EAAgB;;AAEzC,aAAa;;AAEb;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;;AAEA;AACA;AACA;;AAEA;;AAEA;AACA;AACA,GAAG;;AAEH;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA,GAAG;;AAEH;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA;;AAEA;AACA;;AAEA;;;;;;;;AClGa;;AAEb,iBAAiB,mBAAO,CAAC,CAAM;AAC/B,iBAAiB,mBAAO,CAAC,EAAgB;AACzC,iBAAiB,mBAAO,CAAC,CAAQ;AACjC,iBAAiB,mBAAO,CAAC,EAAW;AACpC,iBAAiB,mBAAO,CAAC,EAAW;AACpC,iBAAiB,mBAAO,CAAC,EAAQ;;AAEjC;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA,2CAA2C;AAC3C,kCAAkC;AAClC,GAAG;;AAEH;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA,4CAA4C,sBAAsB;AAClE,KAAK;;AAEL;AACA;;AAEA;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA,CAAC;;AAED;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;;;;;;;AC/Ga;;AAEb,cAAc,mBAAO,CAAC,CAAa;AACnC,cAAc,mBAAO,CAAC,CAAQ;AAC9B,cAAc,mBAAO,CAAC,EAAW;AACjC,cAAc,mBAAO,CAAC,CAAQ;AAC9B,cAAc,mBAAO,CAAC,CAAM;;;AAG5B;AACA;AACA;;AAEA;AACA;AACA;;;AAGA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA;AACA;AACA;AACA,GAAG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YAAY,GAAG,2CAAoB,CAAC,YAAY,CAAC;QACxD,WAAM,CAAC,GAAG,GAAG,2CAAoB,CAAC,GAAG,CAAC;QAEtC,eAAe,CAAC,OAAO,CAAC,CAAC;QACzB,OAAO,CAAC,IAAI,GAAG,SAAI,CAAC;QACpB,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAC1B,CAAC;CACF","file":"pusher.js","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 21);\n","module.exports = require(\"util\");","/* eslint-disable node/no-deprecated-api */\nvar buffer = require('buffer')\nvar Buffer = buffer.Buffer\n\n// alternative to using Object.keys for old browsers\nfunction copyProps (src, dst) {\n for (var key in src) {\n dst[key] = src[key]\n }\n}\nif (Buffer.from && Buffer.alloc && Buffer.allocUnsafe && Buffer.allocUnsafeSlow) {\n module.exports = buffer\n} else {\n // Copy properties from require('buffer')\n copyProps(buffer, exports)\n exports.Buffer = SafeBuffer\n}\n\nfunction SafeBuffer (arg, encodingOrOffset, length) {\n return Buffer(arg, encodingOrOffset, length)\n}\n\n// Copy static methods from Buffer\ncopyProps(Buffer, SafeBuffer)\n\nSafeBuffer.from = function (arg, encodingOrOffset, length) {\n if (typeof arg === 'number') {\n throw new TypeError('Argument must not be a number')\n }\n return Buffer(arg, encodingOrOffset, length)\n}\n\nSafeBuffer.alloc = function (size, fill, encoding) {\n if (typeof size !== 'number') {\n throw new TypeError('Argument must be a number')\n }\n var buf = Buffer(size)\n if (fill !== undefined) {\n if (typeof encoding === 'string') {\n buf.fill(fill, encoding)\n } else {\n buf.fill(fill)\n }\n } else {\n buf.fill(0)\n }\n return buf\n}\n\nSafeBuffer.allocUnsafe = function (size) {\n if (typeof size !== 'number') {\n throw new TypeError('Argument must be a number')\n }\n return Buffer(size)\n}\n\nSafeBuffer.allocUnsafeSlow = function (size) {\n if (typeof size !== 'number') {\n throw new TypeError('Argument must be a number')\n }\n return buffer.SlowBuffer(size)\n}\n","'use strict';\n\nvar Buffer = require('safe-buffer').Buffer,\n Emitter = require('events').EventEmitter,\n util = require('util'),\n streams = require('../streams'),\n Headers = require('./headers'),\n Reader = require('./stream_reader');\n\nvar Base = function(request, url, options) {\n Emitter.call(this);\n Base.validateOptions(options || {}, ['maxLength', 'masking', 'requireMasking', 'protocols']);\n\n this._request = request;\n this._reader = new Reader();\n this._options = options || {};\n this._maxLength = this._options.maxLength || this.MAX_LENGTH;\n this._headers = new Headers();\n this.__queue = [];\n this.readyState = 0;\n this.url = url;\n\n this.io = new streams.IO(this);\n this.messages = new streams.Messages(this);\n this._bindEventListeners();\n};\nutil.inherits(Base, Emitter);\n\nBase.isWebSocket = function(request) {\n var connection = request.headers.connection || '',\n upgrade = request.headers.upgrade || '';\n\n return request.method === 'GET' &&\n connection.toLowerCase().split(/ *, */).indexOf('upgrade') >= 0 &&\n upgrade.toLowerCase() === 'websocket';\n};\n\nBase.validateOptions = function(options, validKeys) {\n for (var key in options) {\n if (validKeys.indexOf(key) < 0)\n throw new Error('Unrecognized option: ' + key);\n }\n};\n\nvar instance = {\n // This is 64MB, small enough for an average VPS to handle without\n // crashing from process out of memory\n MAX_LENGTH: 0x3ffffff,\n\n STATES: ['connecting', 'open', 'closing', 'closed'],\n\n _bindEventListeners: function() {\n var self = this;\n\n // Protocol errors are informational and do not have to be handled\n this.messages.on('error', function() {});\n\n this.on('message', function(event) {\n var messages = self.messages;\n if (messages.readable) messages.emit('data', event.data);\n });\n\n this.on('error', function(error) {\n var messages = self.messages;\n if (messages.readable) messages.emit('error', error);\n });\n\n this.on('close', function() {\n var messages = self.messages;\n if (!messages.readable) return;\n messages.readable = messages.writable = false;\n messages.emit('end');\n });\n },\n\n getState: function() {\n return this.STATES[this.readyState] || null;\n },\n\n addExtension: function(extension) {\n return false;\n },\n\n setHeader: function(name, value) {\n if (this.readyState > 0) return false;\n this._headers.set(name, value);\n return true;\n },\n\n start: function() {\n if (this.readyState !== 0) return false;\n\n if (!Base.isWebSocket(this._request))\n return this._failHandshake(new Error('Not a WebSocket request'));\n\n var response;\n\n try {\n response = this._handshakeResponse();\n } catch (error) {\n return this._failHandshake(error);\n }\n\n this._write(response);\n if (this._stage !== -1) this._open();\n return true;\n },\n\n _failHandshake: function(error) {\n var headers = new Headers();\n headers.set('Content-Type', 'text/plain');\n headers.set('Content-Length', Buffer.byteLength(error.message, 'utf8'));\n\n headers = ['HTTP/1.1 400 Bad Request', headers.toString(), error.message];\n this._write(Buffer.from(headers.join('\\r\\n'), 'utf8'));\n this._fail('protocol_error', error.message);\n\n return false;\n },\n\n text: function(message) {\n return this.frame(message);\n },\n\n binary: function(message) {\n return false;\n },\n\n ping: function() {\n return false;\n },\n\n pong: function() {\n return false;\n },\n\n close: function(reason, code) {\n if (this.readyState !== 1) return false;\n this.readyState = 3;\n this.emit('close', new Base.CloseEvent(null, null));\n return true;\n },\n\n _open: function() {\n this.readyState = 1;\n this.__queue.forEach(function(args) { this.frame.apply(this, args) }, this);\n this.__queue = [];\n this.emit('open', new Base.OpenEvent());\n },\n\n _queue: function(message) {\n this.__queue.push(message);\n return true;\n },\n\n _write: function(chunk) {\n var io = this.io;\n if (io.readable) io.emit('data', chunk);\n },\n\n _fail: function(type, message) {\n this.readyState = 2;\n this.emit('error', new Error(message));\n this.close();\n }\n};\n\nfor (var key in instance)\n Base.prototype[key] = instance[key];\n\n\nBase.ConnectEvent = function() {};\n\nBase.OpenEvent = function() {};\n\nBase.CloseEvent = function(code, reason) {\n this.code = code;\n this.reason = reason;\n};\n\nBase.MessageEvent = function(data) {\n this.data = data;\n};\n\nBase.PingEvent = function(data) {\n this.data = data;\n};\n\nBase.PongEvent = function(data) {\n this.data = data;\n};\n\nmodule.exports = Base;\n","module.exports = require(\"crypto\");","'use strict';\n\n// Protocol references:\n//\n// * http://tools.ietf.org/html/draft-hixie-thewebsocketprotocol-75\n// * http://tools.ietf.org/html/draft-hixie-thewebsocketprotocol-76\n// * http://tools.ietf.org/html/draft-ietf-hybi-thewebsocketprotocol-17\n\nvar Base = require('./driver/base'),\n Client = require('./driver/client'),\n Server = require('./driver/server');\n\nvar Driver = {\n client: function(url, options) {\n options = options || {};\n if (options.masking === undefined) options.masking = true;\n return new Client(url, options);\n },\n\n server: function(options) {\n options = options || {};\n if (options.requireMasking === undefined) options.requireMasking = true;\n return new Server(options);\n },\n\n http: function() {\n return Server.http.apply(Server, arguments);\n },\n\n isSecureRequest: function(request) {\n return Server.isSecureRequest(request);\n },\n\n isWebSocket: function(request) {\n return Base.isWebSocket(request);\n },\n\n validateOptions: function(options, validKeys) {\n Base.validateOptions(options, validKeys);\n }\n};\n\nmodule.exports = Driver;\n","module.exports = require(\"stream\");","module.exports = require(\"url\");","'use strict';\n\nvar Event = function(eventType, options) {\n this.type = eventType;\n for (var key in options)\n this[key] = options[key];\n};\n\nEvent.prototype.initEvent = function(eventType, canBubble, cancelable) {\n this.type = eventType;\n this.bubbles = canBubble;\n this.cancelable = cancelable;\n};\n\nEvent.prototype.stopPropagation = function() {};\nEvent.prototype.preventDefault = function() {};\n\nEvent.CAPTURING_PHASE = 1;\nEvent.AT_TARGET = 2;\nEvent.BUBBLING_PHASE = 3;\n\nmodule.exports = Event;\n","// Copyright (C) 2016 Dmitry Chestnykh\n// MIT License. See LICENSE file for details.\n\n/**\n * Package base64 implements Base64 encoding and decoding.\n */\n\n// Invalid character used in decoding to indicate\n// that the character to decode is out of range of\n// alphabet and cannot be decoded.\nconst INVALID_BYTE = 256;\n\n/**\n * Implements standard Base64 encoding.\n *\n * Operates in constant time.\n */\nexport class Coder {\n // TODO(dchest): methods to encode chunk-by-chunk.\n\n constructor(private _paddingCharacter = \"=\") { }\n\n encodedLength(length: number): number {\n if (!this._paddingCharacter) {\n return (length * 8 + 5) / 6 | 0;\n }\n return (length + 2) / 3 * 4 | 0;\n }\n\n encode(data: Uint8Array): string {\n let out = \"\";\n\n let i = 0;\n for (; i < data.length - 2; i += 3) {\n let c = (data[i] << 16) | (data[i + 1] << 8) | (data[i + 2]);\n out += this._encodeByte((c >>> 3 * 6) & 63);\n out += this._encodeByte((c >>> 2 * 6) & 63);\n out += this._encodeByte((c >>> 1 * 6) & 63);\n out += this._encodeByte((c >>> 0 * 6) & 63);\n }\n\n const left = data.length - i;\n if (left > 0) {\n let c = (data[i] << 16) | (left === 2 ? data[i + 1] << 8 : 0);\n out += this._encodeByte((c >>> 3 * 6) & 63);\n out += this._encodeByte((c >>> 2 * 6) & 63);\n if (left === 2) {\n out += this._encodeByte((c >>> 1 * 6) & 63);\n } else {\n out += this._paddingCharacter || \"\";\n }\n out += this._paddingCharacter || \"\";\n }\n\n return out;\n }\n\n maxDecodedLength(length: number): number {\n if (!this._paddingCharacter) {\n return (length * 6 + 7) / 8 | 0;\n }\n return length / 4 * 3 | 0;\n }\n\n decodedLength(s: string): number {\n return this.maxDecodedLength(s.length - this._getPaddingLength(s));\n }\n\n decode(s: string): Uint8Array {\n if (s.length === 0) {\n return new Uint8Array(0);\n }\n const paddingLength = this._getPaddingLength(s);\n const length = s.length - paddingLength;\n const out = new Uint8Array(this.maxDecodedLength(length));\n let op = 0;\n let i = 0;\n let haveBad = 0;\n let v0 = 0, v1 = 0, v2 = 0, v3 = 0;\n for (; i < length - 4; i += 4) {\n v0 = this._decodeChar(s.charCodeAt(i + 0));\n v1 = this._decodeChar(s.charCodeAt(i + 1));\n v2 = this._decodeChar(s.charCodeAt(i + 2));\n v3 = this._decodeChar(s.charCodeAt(i + 3));\n out[op++] = (v0 << 2) | (v1 >>> 4);\n out[op++] = (v1 << 4) | (v2 >>> 2);\n out[op++] = (v2 << 6) | v3;\n haveBad |= v0 & INVALID_BYTE;\n haveBad |= v1 & INVALID_BYTE;\n haveBad |= v2 & INVALID_BYTE;\n haveBad |= v3 & INVALID_BYTE;\n }\n if (i < length - 1) {\n v0 = this._decodeChar(s.charCodeAt(i));\n v1 = this._decodeChar(s.charCodeAt(i + 1));\n out[op++] = (v0 << 2) | (v1 >>> 4);\n haveBad |= v0 & INVALID_BYTE;\n haveBad |= v1 & INVALID_BYTE;\n }\n if (i < length - 2) {\n v2 = this._decodeChar(s.charCodeAt(i + 2));\n out[op++] = (v1 << 4) | (v2 >>> 2);\n haveBad |= v2 & INVALID_BYTE;\n }\n if (i < length - 3) {\n v3 = this._decodeChar(s.charCodeAt(i + 3));\n out[op++] = (v2 << 6) | v3;\n haveBad |= v3 & INVALID_BYTE;\n }\n if (haveBad !== 0) {\n throw new Error(\"Base64Coder: incorrect characters for decoding\");\n }\n return out;\n }\n\n // Standard encoding have the following encoded/decoded ranges,\n // which we need to convert between.\n //\n // ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 0123456789 + /\n // Index: 0 - 25 26 - 51 52 - 61 62 63\n // ASCII: 65 - 90 97 - 122 48 - 57 43 47\n //\n\n // Encode 6 bits in b into a new character.\n protected _encodeByte(b: number): string {\n // Encoding uses constant time operations as follows:\n //\n // 1. Define comparison of A with B using (A - B) >>> 8:\n // if A > B, then result is positive integer\n // if A <= B, then result is 0\n //\n // 2. Define selection of C or 0 using bitwise AND: X & C:\n // if X == 0, then result is 0\n // if X != 0, then result is C\n //\n // 3. Start with the smallest comparison (b >= 0), which is always\n // true, so set the result to the starting ASCII value (65).\n //\n // 4. Continue comparing b to higher ASCII values, and selecting\n // zero if comparison isn't true, otherwise selecting a value\n // to add to result, which:\n //\n // a) undoes the previous addition\n // b) provides new value to add\n //\n let result = b;\n // b >= 0\n result += 65;\n // b > 25\n result += ((25 - b) >>> 8) & ((0 - 65) - 26 + 97);\n // b > 51\n result += ((51 - b) >>> 8) & ((26 - 97) - 52 + 48);\n // b > 61\n result += ((61 - b) >>> 8) & ((52 - 48) - 62 + 43);\n // b > 62\n result += ((62 - b) >>> 8) & ((62 - 43) - 63 + 47);\n\n return String.fromCharCode(result);\n }\n\n // Decode a character code into a byte.\n // Must return 256 if character is out of alphabet range.\n protected _decodeChar(c: number): number {\n // Decoding works similar to encoding: using the same comparison\n // function, but now it works on ranges: result is always incremented\n // by value, but this value becomes zero if the range is not\n // satisfied.\n //\n // Decoding starts with invalid value, 256, which is then\n // subtracted when the range is satisfied. If none of the ranges\n // apply, the function returns 256, which is then checked by\n // the caller to throw error.\n let result = INVALID_BYTE; // start with invalid character\n\n // c == 43 (c > 42 and c < 44)\n result += (((42 - c) & (c - 44)) >>> 8) & (-INVALID_BYTE + c - 43 + 62);\n // c == 47 (c > 46 and c < 48)\n result += (((46 - c) & (c - 48)) >>> 8) & (-INVALID_BYTE + c - 47 + 63);\n // c > 47 and c < 58\n result += (((47 - c) & (c - 58)) >>> 8) & (-INVALID_BYTE + c - 48 + 52);\n // c > 64 and c < 91\n result += (((64 - c) & (c - 91)) >>> 8) & (-INVALID_BYTE + c - 65 + 0);\n // c > 96 and c < 123\n result += (((96 - c) & (c - 123)) >>> 8) & (-INVALID_BYTE + c - 97 + 26);\n\n return result;\n }\n\n private _getPaddingLength(s: string): number {\n let paddingLength = 0;\n if (this._paddingCharacter) {\n for (let i = s.length - 1; i >= 0; i--) {\n if (s[i] !== this._paddingCharacter) {\n break;\n }\n paddingLength++;\n }\n if (s.length < 4 || paddingLength > 2) {\n throw new Error(\"Base64Coder: incorrect padding\");\n }\n }\n return paddingLength;\n }\n\n}\n\nconst stdCoder = new Coder();\n\nexport function encode(data: Uint8Array): string {\n return stdCoder.encode(data);\n}\n\nexport function decode(s: string): Uint8Array {\n return stdCoder.decode(s);\n}\n\n/**\n * Implements URL-safe Base64 encoding.\n * (Same as Base64, but '+' is replaced with '-', and '/' with '_').\n *\n * Operates in constant time.\n */\nexport class URLSafeCoder extends Coder {\n // URL-safe encoding have the following encoded/decoded ranges:\n //\n // ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 0123456789 - _\n // Index: 0 - 25 26 - 51 52 - 61 62 63\n // ASCII: 65 - 90 97 - 122 48 - 57 45 95\n //\n\n protected _encodeByte(b: number): string {\n let result = b;\n // b >= 0\n result += 65;\n // b > 25\n result += ((25 - b) >>> 8) & ((0 - 65) - 26 + 97);\n // b > 51\n result += ((51 - b) >>> 8) & ((26 - 97) - 52 + 48);\n // b > 61\n result += ((61 - b) >>> 8) & ((52 - 48) - 62 + 45);\n // b > 62\n result += ((62 - b) >>> 8) & ((62 - 45) - 63 + 95);\n\n return String.fromCharCode(result);\n }\n\n protected _decodeChar(c: number): number {\n let result = INVALID_BYTE;\n\n // c == 45 (c > 44 and c < 46)\n result += (((44 - c) & (c - 46)) >>> 8) & (-INVALID_BYTE + c - 45 + 62);\n // c == 95 (c > 94 and c < 96)\n result += (((94 - c) & (c - 96)) >>> 8) & (-INVALID_BYTE + c - 95 + 63);\n // c > 47 and c < 58\n result += (((47 - c) & (c - 58)) >>> 8) & (-INVALID_BYTE + c - 48 + 52);\n // c > 64 and c < 91\n result += (((64 - c) & (c - 91)) >>> 8) & (-INVALID_BYTE + c - 65 + 0);\n // c > 96 and c < 123\n result += (((96 - c) & (c - 123)) >>> 8) & (-INVALID_BYTE + c - 97 + 26);\n\n return result;\n }\n}\n\nconst urlSafeCoder = new URLSafeCoder();\n\nexport function encodeURLSafe(data: Uint8Array): string {\n return urlSafeCoder.encode(data);\n}\n\nexport function decodeURLSafe(s: string): Uint8Array {\n return urlSafeCoder.decode(s);\n}\n\n\nexport const encodedLength = (length: number) =>\n stdCoder.encodedLength(length);\n\nexport const maxDecodedLength = (length: number) =>\n stdCoder.maxDecodedLength(length);\n\nexport const decodedLength = (s: string) =>\n stdCoder.decodedLength(s);\n","'use strict';\n\nvar Headers = function() {\n this.clear();\n};\n\nHeaders.prototype.ALLOWED_DUPLICATES = ['set-cookie', 'set-cookie2', 'warning', 'www-authenticate'];\n\nHeaders.prototype.clear = function() {\n this._sent = {};\n this._lines = [];\n};\n\nHeaders.prototype.set = function(name, value) {\n if (value === undefined) return;\n\n name = this._strip(name);\n value = this._strip(value);\n\n var key = name.toLowerCase();\n if (!this._sent.hasOwnProperty(key) || this.ALLOWED_DUPLICATES.indexOf(key) >= 0) {\n this._sent[key] = true;\n this._lines.push(name + ': ' + value + '\\r\\n');\n }\n};\n\nHeaders.prototype.toString = function() {\n return this._lines.join('');\n};\n\nHeaders.prototype._strip = function(string) {\n return string.toString().replace(/^ */, '').replace(/ *$/, '');\n};\n\nmodule.exports = Headers;\n","'use strict';\n\nvar NodeHTTPParser = require('http-parser-js').HTTPParser,\n Buffer = require('safe-buffer').Buffer;\n\nvar TYPES = {\n request: NodeHTTPParser.REQUEST || 'request',\n response: NodeHTTPParser.RESPONSE || 'response'\n};\n\nvar HttpParser = function(type) {\n this._type = type;\n this._parser = new NodeHTTPParser(TYPES[type]);\n this._complete = false;\n this.headers = {};\n\n var current = null,\n self = this;\n\n this._parser.onHeaderField = function(b, start, length) {\n current = b.toString('utf8', start, start + length).toLowerCase();\n };\n\n this._parser.onHeaderValue = function(b, start, length) {\n var value = b.toString('utf8', start, start + length);\n\n if (self.headers.hasOwnProperty(current))\n self.headers[current] += ', ' + value;\n else\n self.headers[current] = value;\n };\n\n this._parser.onHeadersComplete = this._parser[NodeHTTPParser.kOnHeadersComplete] =\n function(majorVersion, minorVersion, headers, method, pathname, statusCode) {\n var info = arguments[0];\n\n if (typeof info === 'object') {\n method = info.method;\n pathname = info.url;\n statusCode = info.statusCode;\n headers = info.headers;\n }\n\n self.method = (typeof method === 'number') ? HttpParser.METHODS[method] : method;\n self.statusCode = statusCode;\n self.url = pathname;\n\n if (!headers) return;\n\n for (var i = 0, n = headers.length, key, value; i < n; i += 2) {\n key = headers[i].toLowerCase();\n value = headers[i+1];\n if (self.headers.hasOwnProperty(key))\n self.headers[key] += ', ' + value;\n else\n self.headers[key] = value;\n }\n\n self._complete = true;\n };\n};\n\nHttpParser.METHODS = {\n 0: 'DELETE',\n 1: 'GET',\n 2: 'HEAD',\n 3: 'POST',\n 4: 'PUT',\n 5: 'CONNECT',\n 6: 'OPTIONS',\n 7: 'TRACE',\n 8: 'COPY',\n 9: 'LOCK',\n 10: 'MKCOL',\n 11: 'MOVE',\n 12: 'PROPFIND',\n 13: 'PROPPATCH',\n 14: 'SEARCH',\n 15: 'UNLOCK',\n 16: 'BIND',\n 17: 'REBIND',\n 18: 'UNBIND',\n 19: 'ACL',\n 20: 'REPORT',\n 21: 'MKACTIVITY',\n 22: 'CHECKOUT',\n 23: 'MERGE',\n 24: 'M-SEARCH',\n 25: 'NOTIFY',\n 26: 'SUBSCRIBE',\n 27: 'UNSUBSCRIBE',\n 28: 'PATCH',\n 29: 'PURGE',\n 30: 'MKCALENDAR',\n 31: 'LINK',\n 32: 'UNLINK'\n};\n\nvar VERSION = process.version\n ? process.version.match(/[0-9]+/g).map(function(n) { return parseInt(n, 10) })\n : [];\n\nif (VERSION[0] === 0 && VERSION[1] === 12) {\n HttpParser.METHODS[16] = 'REPORT';\n HttpParser.METHODS[17] = 'MKACTIVITY';\n HttpParser.METHODS[18] = 'CHECKOUT';\n HttpParser.METHODS[19] = 'MERGE';\n HttpParser.METHODS[20] = 'M-SEARCH';\n HttpParser.METHODS[21] = 'NOTIFY';\n HttpParser.METHODS[22] = 'SUBSCRIBE';\n HttpParser.METHODS[23] = 'UNSUBSCRIBE';\n HttpParser.METHODS[24] = 'PATCH';\n HttpParser.METHODS[25] = 'PURGE';\n}\n\nHttpParser.prototype.isComplete = function() {\n return this._complete;\n};\n\nHttpParser.prototype.parse = function(chunk) {\n var consumed = this._parser.execute(chunk, 0, chunk.length);\n\n if (typeof consumed !== 'number') {\n this.error = consumed;\n this._complete = true;\n return;\n }\n\n if (this._complete)\n this.body = (consumed < chunk.length)\n ? chunk.slice(consumed)\n : Buffer.alloc(0);\n};\n\nmodule.exports = HttpParser;\n","'use strict';\n\nvar Stream = require('stream').Stream,\n util = require('util'),\n driver = require('websocket-driver'),\n EventTarget = require('./api/event_target'),\n Event = require('./api/event');\n\nvar API = function(options) {\n options = options || {};\n driver.validateOptions(options, ['headers', 'extensions', 'maxLength', 'ping', 'proxy', 'tls', 'ca']);\n\n this.readable = this.writable = true;\n\n var headers = options.headers;\n if (headers) {\n for (var name in headers) this._driver.setHeader(name, headers[name]);\n }\n\n var extensions = options.extensions;\n if (extensions) {\n [].concat(extensions).forEach(this._driver.addExtension, this._driver);\n }\n\n this._ping = options.ping;\n this._pingId = 0;\n this.readyState = API.CONNECTING;\n this.bufferedAmount = 0;\n this.protocol = '';\n this.url = this._driver.url;\n this.version = this._driver.version;\n\n var self = this;\n\n this._driver.on('open', function(e) { self._open() });\n this._driver.on('message', function(e) { self._receiveMessage(e.data) });\n this._driver.on('close', function(e) { self._beginClose(e.reason, e.code) });\n\n this._driver.on('error', function(error) {\n self._emitError(error.message);\n });\n this.on('error', function() {});\n\n this._driver.messages.on('drain', function() {\n self.emit('drain');\n });\n\n if (this._ping)\n this._pingTimer = setInterval(function() {\n self._pingId += 1;\n self.ping(self._pingId.toString());\n }, this._ping * 1000);\n\n this._configureStream();\n\n if (!this._proxy) {\n this._stream.pipe(this._driver.io);\n this._driver.io.pipe(this._stream);\n }\n};\nutil.inherits(API, Stream);\n\nAPI.CONNECTING = 0;\nAPI.OPEN = 1;\nAPI.CLOSING = 2;\nAPI.CLOSED = 3;\n\nAPI.CLOSE_TIMEOUT = 30000;\n\nvar instance = {\n write: function(data) {\n return this.send(data);\n },\n\n end: function(data) {\n if (data !== undefined) this.send(data);\n this.close();\n },\n\n pause: function() {\n return this._driver.messages.pause();\n },\n\n resume: function() {\n return this._driver.messages.resume();\n },\n\n send: function(data) {\n if (this.readyState > API.OPEN) return false;\n if (!(data instanceof Buffer)) data = String(data);\n return this._driver.messages.write(data);\n },\n\n ping: function(message, callback) {\n if (this.readyState > API.OPEN) return false;\n return this._driver.ping(message, callback);\n },\n\n close: function(code, reason) {\n if (code === undefined) code = 1000;\n if (reason === undefined) reason = '';\n\n if (code !== 1000 && (code < 3000 || code > 4999))\n throw new Error(\"Failed to execute 'close' on WebSocket: \" +\n \"The code must be either 1000, or between 3000 and 4999. \" +\n code + \" is neither.\");\n\n if (this.readyState !== API.CLOSED) this.readyState = API.CLOSING;\n var self = this;\n\n this._closeTimer = setTimeout(function() {\n self._beginClose('', 1006);\n }, API.CLOSE_TIMEOUT);\n\n this._driver.close(reason, code);\n },\n\n _configureStream: function() {\n var self = this;\n\n this._stream.setTimeout(0);\n this._stream.setNoDelay(true);\n\n ['close', 'end'].forEach(function(event) {\n this._stream.on(event, function() { self._finalizeClose() });\n }, this);\n\n this._stream.on('error', function(error) {\n self._emitError('Network error: ' + self.url + ': ' + error.message);\n self._finalizeClose();\n });\n },\n\n _open: function() {\n if (this.readyState !== API.CONNECTING) return;\n\n this.readyState = API.OPEN;\n this.protocol = this._driver.protocol || '';\n\n var event = new Event('open');\n event.initEvent('open', false, false);\n this.dispatchEvent(event);\n },\n\n _receiveMessage: function(data) {\n if (this.readyState > API.OPEN) return false;\n\n if (this.readable) this.emit('data', data);\n\n var event = new Event('message', {data: data});\n event.initEvent('message', false, false);\n this.dispatchEvent(event);\n },\n\n _emitError: function(message) {\n if (this.readyState >= API.CLOSING) return;\n\n var event = new Event('error', {message: message});\n event.initEvent('error', false, false);\n this.dispatchEvent(event);\n },\n\n _beginClose: function(reason, code) {\n if (this.readyState === API.CLOSED) return;\n this.readyState = API.CLOSING;\n this._closeParams = [reason, code];\n\n if (this._stream) {\n this._stream.destroy();\n if (!this._stream.readable) this._finalizeClose();\n }\n },\n\n _finalizeClose: function() {\n if (this.readyState === API.CLOSED) return;\n this.readyState = API.CLOSED;\n\n if (this._closeTimer) clearTimeout(this._closeTimer);\n if (this._pingTimer) clearInterval(this._pingTimer);\n if (this._stream) this._stream.end();\n\n if (this.readable) this.emit('end');\n this.readable = this.writable = false;\n\n var reason = this._closeParams ? this._closeParams[0] : '',\n code = this._closeParams ? this._closeParams[1] : 1006;\n\n var event = new Event('close', {code: code, reason: reason});\n event.initEvent('close', false, false);\n this.dispatchEvent(event);\n }\n};\n\nfor (var method in instance) API.prototype[method] = instance[method];\nfor (var key in EventTarget) API.prototype[key] = EventTarget[key];\n\nmodule.exports = API;\n","'use strict';\n\nvar Buffer = require('safe-buffer').Buffer,\n crypto = require('crypto'),\n util = require('util'),\n Extensions = require('websocket-extensions'),\n Base = require('./base'),\n Frame = require('./hybi/frame'),\n Message = require('./hybi/message');\n\nvar Hybi = function(request, url, options) {\n Base.apply(this, arguments);\n\n this._extensions = new Extensions();\n this._stage = 0;\n this._masking = this._options.masking;\n this._protocols = this._options.protocols || [];\n this._requireMasking = this._options.requireMasking;\n this._pingCallbacks = {};\n\n if (typeof this._protocols === 'string')\n this._protocols = this._protocols.split(/ *, */);\n\n if (!this._request) return;\n\n var protos = this._request.headers['sec-websocket-protocol'],\n supported = this._protocols;\n\n if (protos !== undefined) {\n if (typeof protos === 'string') protos = protos.split(/ *, */);\n this.protocol = protos.filter(function(p) { return supported.indexOf(p) >= 0 })[0];\n }\n\n this.version = 'hybi-' + Hybi.VERSION;\n};\nutil.inherits(Hybi, Base);\n\nHybi.VERSION = '13';\n\nHybi.mask = function(payload, mask, offset) {\n if (!mask || mask.length === 0) return payload;\n offset = offset || 0;\n\n for (var i = 0, n = payload.length - offset; i < n; i++) {\n payload[offset + i] = payload[offset + i] ^ mask[i % 4];\n }\n return payload;\n};\n\nHybi.generateAccept = function(key) {\n var sha1 = crypto.createHash('sha1');\n sha1.update(key + Hybi.GUID);\n return sha1.digest('base64');\n};\n\nHybi.GUID = '258EAFA5-E914-47DA-95CA-C5AB0DC85B11';\n\nvar instance = {\n FIN: 0x80,\n MASK: 0x80,\n RSV1: 0x40,\n RSV2: 0x20,\n RSV3: 0x10,\n OPCODE: 0x0F,\n LENGTH: 0x7F,\n\n OPCODES: {\n continuation: 0,\n text: 1,\n binary: 2,\n close: 8,\n ping: 9,\n pong: 10\n },\n\n OPCODE_CODES: [0, 1, 2, 8, 9, 10],\n MESSAGE_OPCODES: [0, 1, 2],\n OPENING_OPCODES: [1, 2],\n\n ERRORS: {\n normal_closure: 1000,\n going_away: 1001,\n protocol_error: 1002,\n unacceptable: 1003,\n encoding_error: 1007,\n policy_violation: 1008,\n too_large: 1009,\n extension_error: 1010,\n unexpected_condition: 1011\n },\n\n ERROR_CODES: [1000, 1001, 1002, 1003, 1007, 1008, 1009, 1010, 1011],\n DEFAULT_ERROR_CODE: 1000,\n MIN_RESERVED_ERROR: 3000,\n MAX_RESERVED_ERROR: 4999,\n\n // http://www.w3.org/International/questions/qa-forms-utf-8.en.php\n UTF8_MATCH: /^([\\x00-\\x7F]|[\\xC2-\\xDF][\\x80-\\xBF]|\\xE0[\\xA0-\\xBF][\\x80-\\xBF]|[\\xE1-\\xEC\\xEE\\xEF][\\x80-\\xBF]{2}|\\xED[\\x80-\\x9F][\\x80-\\xBF]|\\xF0[\\x90-\\xBF][\\x80-\\xBF]{2}|[\\xF1-\\xF3][\\x80-\\xBF]{3}|\\xF4[\\x80-\\x8F][\\x80-\\xBF]{2})*$/,\n\n addExtension: function(extension) {\n this._extensions.add(extension);\n return true;\n },\n\n parse: function(chunk) {\n this._reader.put(chunk);\n var buffer = true;\n while (buffer) {\n switch (this._stage) {\n case 0:\n buffer = this._reader.read(1);\n if (buffer) this._parseOpcode(buffer[0]);\n break;\n\n case 1:\n buffer = this._reader.read(1);\n if (buffer) this._parseLength(buffer[0]);\n break;\n\n case 2:\n buffer = this._reader.read(this._frame.lengthBytes);\n if (buffer) this._parseExtendedLength(buffer);\n break;\n\n case 3:\n buffer = this._reader.read(4);\n if (buffer) {\n this._stage = 4;\n this._frame.maskingKey = buffer;\n }\n break;\n\n case 4:\n buffer = this._reader.read(this._frame.length);\n if (buffer) {\n this._stage = 0;\n this._emitFrame(buffer);\n }\n break;\n\n default:\n buffer = null;\n }\n }\n },\n\n text: function(message) {\n if (this.readyState > 1) return false;\n return this.frame(message, 'text');\n },\n\n binary: function(message) {\n if (this.readyState > 1) return false;\n return this.frame(message, 'binary');\n },\n\n ping: function(message, callback) {\n if (this.readyState > 1) return false;\n message = message || '';\n if (callback) this._pingCallbacks[message] = callback;\n return this.frame(message, 'ping');\n },\n\n pong: function(message) {\n if (this.readyState > 1) return false;\n message = message ||'';\n return this.frame(message, 'pong');\n },\n\n close: function(reason, code) {\n reason = reason || '';\n code = code || this.ERRORS.normal_closure;\n\n if (this.readyState <= 0) {\n this.readyState = 3;\n this.emit('close', new Base.CloseEvent(code, reason));\n return true;\n } else if (this.readyState === 1) {\n this.readyState = 2;\n this._extensions.close(function() { this.frame(reason, 'close', code) }, this);\n return true;\n } else {\n return false;\n }\n },\n\n frame: function(buffer, type, code) {\n if (this.readyState <= 0) return this._queue([buffer, type, code]);\n if (this.readyState > 2) return false;\n\n if (buffer instanceof Array) buffer = Buffer.from(buffer);\n if (typeof buffer === 'number') buffer = buffer.toString();\n\n var message = new Message(),\n isText = (typeof buffer === 'string'),\n payload, copy;\n\n message.rsv1 = message.rsv2 = message.rsv3 = false;\n message.opcode = this.OPCODES[type || (isText ? 'text' : 'binary')];\n\n payload = isText ? Buffer.from(buffer, 'utf8') : buffer;\n\n if (code) {\n copy = payload;\n payload = Buffer.allocUnsafe(2 + copy.length);\n payload.writeUInt16BE(code, 0);\n copy.copy(payload, 2);\n }\n message.data = payload;\n\n var onMessageReady = function(message) {\n var frame = new Frame();\n\n frame.final = true;\n frame.rsv1 = message.rsv1;\n frame.rsv2 = message.rsv2;\n frame.rsv3 = message.rsv3;\n frame.opcode = message.opcode;\n frame.masked = !!this._masking;\n frame.length = message.data.length;\n frame.payload = message.data;\n\n if (frame.masked) frame.maskingKey = crypto.randomBytes(4);\n\n this._sendFrame(frame);\n };\n\n if (this.MESSAGE_OPCODES.indexOf(message.opcode) >= 0)\n this._extensions.processOutgoingMessage(message, function(error, message) {\n if (error) return this._fail('extension_error', error.message);\n onMessageReady.call(this, message);\n }, this);\n else\n onMessageReady.call(this, message);\n\n return true;\n },\n\n _sendFrame: function(frame) {\n var length = frame.length,\n header = (length <= 125) ? 2 : (length <= 65535 ? 4 : 10),\n offset = header + (frame.masked ? 4 : 0),\n buffer = Buffer.allocUnsafe(offset + length),\n masked = frame.masked ? this.MASK : 0;\n\n buffer[0] = (frame.final ? this.FIN : 0) |\n (frame.rsv1 ? this.RSV1 : 0) |\n (frame.rsv2 ? this.RSV2 : 0) |\n (frame.rsv3 ? this.RSV3 : 0) |\n frame.opcode;\n\n if (length <= 125) {\n buffer[1] = masked | length;\n } else if (length <= 65535) {\n buffer[1] = masked | 126;\n buffer.writeUInt16BE(length, 2);\n } else {\n buffer[1] = masked | 127;\n buffer.writeUInt32BE(Math.floor(length / 0x100000000), 2);\n buffer.writeUInt32BE(length % 0x100000000, 6);\n }\n\n frame.payload.copy(buffer, offset);\n\n if (frame.masked) {\n frame.maskingKey.copy(buffer, header);\n Hybi.mask(buffer, frame.maskingKey, offset);\n }\n\n this._write(buffer);\n },\n\n _handshakeResponse: function() {\n var secKey = this._request.headers['sec-websocket-key'],\n version = this._request.headers['sec-websocket-version'];\n\n if (version !== Hybi.VERSION)\n throw new Error('Unsupported WebSocket version: ' + version);\n\n if (typeof secKey !== 'string')\n throw new Error('Missing handshake request header: Sec-WebSocket-Key');\n\n this._headers.set('Upgrade', 'websocket');\n this._headers.set('Connection', 'Upgrade');\n this._headers.set('Sec-WebSocket-Accept', Hybi.generateAccept(secKey));\n\n if (this.protocol) this._headers.set('Sec-WebSocket-Protocol', this.protocol);\n\n var extensions = this._extensions.generateResponse(this._request.headers['sec-websocket-extensions']);\n if (extensions) this._headers.set('Sec-WebSocket-Extensions', extensions);\n\n var start = 'HTTP/1.1 101 Switching Protocols',\n headers = [start, this._headers.toString(), ''];\n\n return Buffer.from(headers.join('\\r\\n'), 'utf8');\n },\n\n _shutdown: function(code, reason, error) {\n delete this._frame;\n delete this._message;\n this._stage = 5;\n\n var sendCloseFrame = (this.readyState === 1);\n this.readyState = 2;\n\n this._extensions.close(function() {\n if (sendCloseFrame) this.frame(reason, 'close', code);\n this.readyState = 3;\n if (error) this.emit('error', new Error(reason));\n this.emit('close', new Base.CloseEvent(code, reason));\n }, this);\n },\n\n _fail: function(type, message) {\n if (this.readyState > 1) return;\n this._shutdown(this.ERRORS[type], message, true);\n },\n\n _parseOpcode: function(octet) {\n var rsvs = [this.RSV1, this.RSV2, this.RSV3].map(function(rsv) {\n return (octet & rsv) === rsv;\n });\n\n var frame = this._frame = new Frame();\n\n frame.final = (octet & this.FIN) === this.FIN;\n frame.rsv1 = rsvs[0];\n frame.rsv2 = rsvs[1];\n frame.rsv3 = rsvs[2];\n frame.opcode = (octet & this.OPCODE);\n\n this._stage = 1;\n\n if (!this._extensions.validFrameRsv(frame))\n return this._fail('protocol_error',\n 'One or more reserved bits are on: reserved1 = ' + (frame.rsv1 ? 1 : 0) +\n ', reserved2 = ' + (frame.rsv2 ? 1 : 0) +\n ', reserved3 = ' + (frame.rsv3 ? 1 : 0));\n\n if (this.OPCODE_CODES.indexOf(frame.opcode) < 0)\n return this._fail('protocol_error', 'Unrecognized frame opcode: ' + frame.opcode);\n\n if (this.MESSAGE_OPCODES.indexOf(frame.opcode) < 0 && !frame.final)\n return this._fail('protocol_error', 'Received fragmented control frame: opcode = ' + frame.opcode);\n\n if (this._message && this.OPENING_OPCODES.indexOf(frame.opcode) >= 0)\n return this._fail('protocol_error', 'Received new data frame but previous continuous frame is unfinished');\n },\n\n _parseLength: function(octet) {\n var frame = this._frame;\n frame.masked = (octet & this.MASK) === this.MASK;\n frame.length = (octet & this.LENGTH);\n\n if (frame.length >= 0 && frame.length <= 125) {\n this._stage = frame.masked ? 3 : 4;\n if (!this._checkFrameLength()) return;\n } else {\n this._stage = 2;\n frame.lengthBytes = (frame.length === 126 ? 2 : 8);\n }\n\n if (this._requireMasking && !frame.masked)\n return this._fail('unacceptable', 'Received unmasked frame but masking is required');\n },\n\n _parseExtendedLength: function(buffer) {\n var frame = this._frame;\n frame.length = this._readUInt(buffer);\n\n this._stage = frame.masked ? 3 : 4;\n\n if (this.MESSAGE_OPCODES.indexOf(frame.opcode) < 0 && frame.length > 125)\n return this._fail('protocol_error', 'Received control frame having too long payload: ' + frame.length);\n\n if (!this._checkFrameLength()) return;\n },\n\n _checkFrameLength: function() {\n var length = this._message ? this._message.length : 0;\n\n if (length + this._frame.length > this._maxLength) {\n this._fail('too_large', 'WebSocket frame length too large');\n return false;\n } else {\n return true;\n }\n },\n\n _emitFrame: function(buffer) {\n var frame = this._frame,\n payload = frame.payload = Hybi.mask(buffer, frame.maskingKey),\n opcode = frame.opcode,\n message,\n code, reason,\n callbacks, callback;\n\n delete this._frame;\n\n if (opcode === this.OPCODES.continuation) {\n if (!this._message) return this._fail('protocol_error', 'Received unexpected continuation frame');\n this._message.pushFrame(frame);\n }\n\n if (opcode === this.OPCODES.text || opcode === this.OPCODES.binary) {\n this._message = new Message();\n this._message.pushFrame(frame);\n }\n\n if (frame.final && this.MESSAGE_OPCODES.indexOf(opcode) >= 0)\n return this._emitMessage(this._message);\n\n if (opcode === this.OPCODES.close) {\n code = (payload.length >= 2) ? payload.readUInt16BE(0) : null;\n reason = (payload.length > 2) ? this._encode(payload.slice(2)) : null;\n\n if (!(payload.length === 0) &&\n !(code !== null && code >= this.MIN_RESERVED_ERROR && code <= this.MAX_RESERVED_ERROR) &&\n this.ERROR_CODES.indexOf(code) < 0)\n code = this.ERRORS.protocol_error;\n\n if (payload.length > 125 || (payload.length > 2 && !reason))\n code = this.ERRORS.protocol_error;\n\n this._shutdown(code || this.DEFAULT_ERROR_CODE, reason || '');\n }\n\n if (opcode === this.OPCODES.ping) {\n this.frame(payload, 'pong');\n this.emit('ping', new Base.PingEvent(payload.toString()))\n }\n\n if (opcode === this.OPCODES.pong) {\n callbacks = this._pingCallbacks;\n message = this._encode(payload);\n callback = callbacks[message];\n\n delete callbacks[message];\n if (callback) callback()\n\n this.emit('pong', new Base.PongEvent(payload.toString()))\n }\n },\n\n _emitMessage: function(message) {\n var message = this._message;\n message.read();\n\n delete this._message;\n\n this._extensions.processIncomingMessage(message, function(error, message) {\n if (error) return this._fail('extension_error', error.message);\n\n var payload = message.data;\n if (message.opcode === this.OPCODES.text) payload = this._encode(payload);\n\n if (payload === null)\n return this._fail('encoding_error', 'Could not decode a text frame as UTF-8');\n else\n this.emit('message', new Base.MessageEvent(payload));\n }, this);\n },\n\n _encode: function(buffer) {\n try {\n var string = buffer.toString('binary', 0, buffer.length);\n if (!this.UTF8_MATCH.test(string)) return null;\n } catch (e) {}\n return buffer.toString('utf8', 0, buffer.length);\n },\n\n _readUInt: function(buffer) {\n if (buffer.length === 2) return buffer.readUInt16BE(0);\n\n return buffer.readUInt32BE(0) * 0x100000000 +\n buffer.readUInt32BE(4);\n }\n};\n\nfor (var key in instance)\n Hybi.prototype[key] = instance[key];\n\nmodule.exports = Hybi;\n","'use strict';\n\nvar RingBuffer = function(bufferSize) {\n this._bufferSize = bufferSize;\n this.clear();\n};\n\nRingBuffer.prototype.clear = function() {\n this._buffer = new Array(this._bufferSize);\n this._ringOffset = 0;\n this._ringSize = this._bufferSize;\n this._head = 0;\n this._tail = 0;\n this.length = 0;\n};\n\nRingBuffer.prototype.push = function(value) {\n var expandBuffer = false,\n expandRing = false;\n\n if (this._ringSize < this._bufferSize) {\n expandBuffer = (this._tail === 0);\n } else if (this._ringOffset === this._ringSize) {\n expandBuffer = true;\n expandRing = (this._tail === 0);\n }\n\n if (expandBuffer) {\n this._tail = this._bufferSize;\n this._buffer = this._buffer.concat(new Array(this._bufferSize));\n this._bufferSize = this._buffer.length;\n\n if (expandRing)\n this._ringSize = this._bufferSize;\n }\n\n this._buffer[this._tail] = value;\n this.length += 1;\n if (this._tail < this._ringSize) this._ringOffset += 1;\n this._tail = (this._tail + 1) % this._bufferSize;\n};\n\nRingBuffer.prototype.peek = function() {\n if (this.length === 0) return void 0;\n return this._buffer[this._head];\n};\n\nRingBuffer.prototype.shift = function() {\n if (this.length === 0) return void 0;\n\n var value = this._buffer[this._head];\n this._buffer[this._head] = void 0;\n this.length -= 1;\n this._ringOffset -= 1;\n\n if (this._ringOffset === 0 && this.length > 0) {\n this._head = this._ringSize;\n this._ringOffset = this.length;\n this._ringSize = this._bufferSize;\n } else {\n this._head = (this._head + 1) % this._ringSize;\n }\n return value;\n};\n\nmodule.exports = RingBuffer;\n","'use strict';\n\nvar RingBuffer = require('./ring_buffer');\n\nvar Pledge = function() {\n this._complete = false;\n this._callbacks = new RingBuffer(Pledge.QUEUE_SIZE);\n};\n\nPledge.QUEUE_SIZE = 4;\n\nPledge.all = function(list) {\n var pledge = new Pledge(),\n pending = list.length,\n n = pending;\n\n if (pending === 0) pledge.done();\n\n while (n--) list[n].then(function() {\n pending -= 1;\n if (pending === 0) pledge.done();\n });\n return pledge;\n};\n\nPledge.prototype.then = function(callback) {\n if (this._complete) callback();\n else this._callbacks.push(callback);\n};\n\nPledge.prototype.done = function() {\n this._complete = true;\n var callbacks = this._callbacks, callback;\n while (callback = callbacks.shift()) callback();\n};\n\nmodule.exports = Pledge;\n","'use strict';\n\nvar Buffer = require('safe-buffer').Buffer,\n Base = require('./base'),\n util = require('util');\n\nvar Draft75 = function(request, url, options) {\n Base.apply(this, arguments);\n this._stage = 0;\n this.version = 'hixie-75';\n\n this._headers.set('Upgrade', 'WebSocket');\n this._headers.set('Connection', 'Upgrade');\n this._headers.set('WebSocket-Origin', this._request.headers.origin);\n this._headers.set('WebSocket-Location', this.url);\n};\nutil.inherits(Draft75, Base);\n\nvar instance = {\n close: function() {\n if (this.readyState === 3) return false;\n this.readyState = 3;\n this.emit('close', new Base.CloseEvent(null, null));\n return true;\n },\n\n parse: function(chunk) {\n if (this.readyState > 1) return;\n\n this._reader.put(chunk);\n\n this._reader.eachByte(function(octet) {\n var message;\n\n switch (this._stage) {\n case -1:\n this._body.push(octet);\n this._sendHandshakeBody();\n break;\n\n case 0:\n this._parseLeadingByte(octet);\n break;\n\n case 1:\n this._length = (octet & 0x7F) + 128 * this._length;\n\n if (this._closing && this._length === 0) {\n return this.close();\n }\n else if ((octet & 0x80) !== 0x80) {\n if (this._length === 0) {\n this._stage = 0;\n }\n else {\n this._skipped = 0;\n this._stage = 2;\n }\n }\n break;\n\n case 2:\n if (octet === 0xFF) {\n this._stage = 0;\n message = Buffer.from(this._buffer).toString('utf8', 0, this._buffer.length);\n this.emit('message', new Base.MessageEvent(message));\n }\n else {\n if (this._length) {\n this._skipped += 1;\n if (this._skipped === this._length)\n this._stage = 0;\n } else {\n this._buffer.push(octet);\n if (this._buffer.length > this._maxLength) return this.close();\n }\n }\n break;\n }\n }, this);\n },\n\n frame: function(buffer) {\n if (this.readyState === 0) return this._queue([buffer]);\n if (this.readyState > 1) return false;\n\n if (typeof buffer !== 'string') buffer = buffer.toString();\n\n var length = Buffer.byteLength(buffer),\n frame = Buffer.allocUnsafe(length + 2);\n\n frame[0] = 0x00;\n frame.write(buffer, 1);\n frame[frame.length - 1] = 0xFF;\n\n this._write(frame);\n return true;\n },\n\n _handshakeResponse: function() {\n var start = 'HTTP/1.1 101 Web Socket Protocol Handshake',\n headers = [start, this._headers.toString(), ''];\n\n return Buffer.from(headers.join('\\r\\n'), 'utf8');\n },\n\n _parseLeadingByte: function(octet) {\n if ((octet & 0x80) === 0x80) {\n this._length = 0;\n this._stage = 1;\n } else {\n delete this._length;\n delete this._skipped;\n this._buffer = [];\n this._stage = 2;\n }\n }\n};\n\nfor (var key in instance)\n Draft75.prototype[key] = instance[key];\n\nmodule.exports = Draft75;\n","'use strict';\n\nvar Event = require('./event');\n\nvar EventTarget = {\n onopen: null,\n onmessage: null,\n onerror: null,\n onclose: null,\n\n addEventListener: function(eventType, listener, useCapture) {\n this.on(eventType, listener);\n },\n\n removeEventListener: function(eventType, listener, useCapture) {\n this.removeListener(eventType, listener);\n },\n\n dispatchEvent: function(event) {\n event.target = event.currentTarget = this;\n event.eventPhase = Event.AT_TARGET;\n\n if (this['on' + event.type])\n this['on' + event.type](event);\n\n this.emit(event.type, event);\n }\n};\n\nmodule.exports = EventTarget;\n","// Copyright (C) 2016 Dmitry Chestnykh\n// MIT License. See LICENSE file for details.\n\n/**\n * Package utf8 implements UTF-8 encoding and decoding.\n */\n\nconst INVALID_UTF16 = \"utf8: invalid string\";\nconst INVALID_UTF8 = \"utf8: invalid source encoding\";\n\n/**\n * Encodes the given string into UTF-8 byte array.\n * Throws if the source string has invalid UTF-16 encoding.\n */\nexport function encode(s: string): Uint8Array {\n // Calculate result length and allocate output array.\n // encodedLength() also validates string and throws errors,\n // so we don't need repeat validation here.\n const arr = new Uint8Array(encodedLength(s));\n\n let pos = 0;\n for (let i = 0; i < s.length; i++) {\n let c = s.charCodeAt(i);\n if (c < 0x80) {\n arr[pos++] = c;\n } else if (c < 0x800) {\n arr[pos++] = 0xc0 | c >> 6;\n arr[pos++] = 0x80 | c & 0x3f;\n } else if (c < 0xd800) {\n arr[pos++] = 0xe0 | c >> 12;\n arr[pos++] = 0x80 | (c >> 6) & 0x3f;\n arr[pos++] = 0x80 | c & 0x3f;\n } else {\n i++; // get one more character\n c = (c & 0x3ff) << 10;\n c |= s.charCodeAt(i) & 0x3ff;\n c += 0x10000;\n\n arr[pos++] = 0xf0 | c >> 18;\n arr[pos++] = 0x80 | (c >> 12) & 0x3f;\n arr[pos++] = 0x80 | (c >> 6) & 0x3f;\n arr[pos++] = 0x80 | c & 0x3f;\n }\n }\n return arr;\n}\n\n/**\n * Returns the number of bytes required to encode the given string into UTF-8.\n * Throws if the source string has invalid UTF-16 encoding.\n */\nexport function encodedLength(s: string): number {\n let result = 0;\n for (let i = 0; i < s.length; i++) {\n const c = s.charCodeAt(i);\n if (c < 0x80) {\n result += 1;\n } else if (c < 0x800) {\n result += 2;\n } else if (c < 0xd800) {\n result += 3;\n } else if (c <= 0xdfff) {\n if (i >= s.length - 1) {\n throw new Error(INVALID_UTF16);\n }\n i++; // \"eat\" next character\n result += 4;\n } else {\n throw new Error(INVALID_UTF16);\n }\n }\n return result;\n}\n\n/**\n * Decodes the given byte array from UTF-8 into a string.\n * Throws if encoding is invalid.\n */\nexport function decode(arr: Uint8Array): string {\n const chars: string[] = [];\n for (let i = 0; i < arr.length; i++) {\n let b = arr[i];\n\n if (b & 0x80) {\n let min;\n if (b < 0xe0) {\n // Need 1 more byte.\n if (i >= arr.length) {\n throw new Error(INVALID_UTF8);\n }\n const n1 = arr[++i];\n if ((n1 & 0xc0) !== 0x80) {\n throw new Error(INVALID_UTF8);\n }\n b = (b & 0x1f) << 6 | (n1 & 0x3f);\n min = 0x80;\n } else if (b < 0xf0) {\n // Need 2 more bytes.\n if (i >= arr.length - 1) {\n throw new Error(INVALID_UTF8);\n }\n const n1 = arr[++i];\n const n2 = arr[++i];\n if ((n1 & 0xc0) !== 0x80 || (n2 & 0xc0) !== 0x80) {\n throw new Error(INVALID_UTF8);\n }\n b = (b & 0x0f) << 12 | (n1 & 0x3f) << 6 | (n2 & 0x3f);\n min = 0x800;\n } else if (b < 0xf8) {\n // Need 3 more bytes.\n if (i >= arr.length - 2) {\n throw new Error(INVALID_UTF8);\n }\n const n1 = arr[++i];\n const n2 = arr[++i];\n const n3 = arr[++i];\n if ((n1 & 0xc0) !== 0x80 || (n2 & 0xc0) !== 0x80 || (n3 & 0xc0) !== 0x80) {\n throw new Error(INVALID_UTF8);\n }\n b = (b & 0x0f) << 18 | (n1 & 0x3f) << 12 | (n2 & 0x3f) << 6 | (n3 & 0x3f);\n min = 0x10000;\n } else {\n throw new Error(INVALID_UTF8);\n }\n\n if (b < min || (b >= 0xd800 && b <= 0xdfff)) {\n throw new Error(INVALID_UTF8);\n }\n\n if (b >= 0x10000) {\n // Surrogate pair.\n if (b > 0x10ffff) {\n throw new Error(INVALID_UTF8);\n }\n b -= 0x10000;\n chars.push(String.fromCharCode(0xd800 | (b >> 10)));\n b = 0xdc00 | (b & 0x3ff);\n }\n }\n\n chars.push(String.fromCharCode(b));\n }\n return chars.join(\"\");\n}\n","// API references:\n//\n// * https://html.spec.whatwg.org/multipage/comms.html#network\n// * https://dom.spec.whatwg.org/#interface-eventtarget\n// * https://dom.spec.whatwg.org/#interface-event\n\n'use strict';\n\nvar util = require('util'),\n driver = require('websocket-driver'),\n API = require('./websocket/api');\n\nvar WebSocket = function(request, socket, body, protocols, options) {\n options = options || {};\n\n this._stream = socket;\n this._driver = driver.http(request, {maxLength: options.maxLength, protocols: protocols});\n\n var self = this;\n if (!this._stream || !this._stream.writable) return;\n if (!this._stream.readable) return this._stream.end();\n\n var catchup = function() { self._stream.removeListener('data', catchup) };\n this._stream.on('data', catchup);\n\n API.call(this, options);\n\n process.nextTick(function() {\n self._driver.start();\n self._driver.io.write(body);\n });\n};\nutil.inherits(WebSocket, API);\n\nWebSocket.isWebSocket = function(request) {\n return driver.isWebSocket(request);\n};\n\nWebSocket.validateOptions = function(options, validKeys) {\n driver.validateOptions(options, validKeys);\n};\n\nWebSocket.WebSocket = WebSocket;\nWebSocket.Client = require('./websocket/client');\nWebSocket.EventSource = require('./eventsource');\n\nmodule.exports = WebSocket;\n","/**\n * Wrapper for built-in http.js to emulate the browser XMLHttpRequest object.\n *\n * This can be used with JS designed for browsers to improve reuse of code and\n * allow the use of existing libraries.\n *\n * Usage: include(\"XMLHttpRequest.js\") and use XMLHttpRequest per W3C specs.\n *\n * @author Dan DeFelippi \n * @contributor David Ellis \n * @license MIT\n */\n\nvar Url = require(\"url\");\nvar spawn = require(\"child_process\").spawn;\nvar fs = require(\"fs\");\n\nexports.XMLHttpRequest = function() {\n \"use strict\";\n\n /**\n * Private variables\n */\n var self = this;\n var http = require(\"http\");\n var https = require(\"https\");\n\n // Holds http.js objects\n var request;\n var response;\n\n // Request settings\n var settings = {};\n\n // Disable header blacklist.\n // Not part of XHR specs.\n var disableHeaderCheck = false;\n\n // Set some default headers\n var defaultHeaders = {\n \"User-Agent\": \"node-XMLHttpRequest\",\n \"Accept\": \"*/*\",\n };\n\n var headers = {};\n var headersCase = {};\n\n // These headers are not user setable.\n // The following are allowed but banned in the spec:\n // * user-agent\n var forbiddenRequestHeaders = [\n \"accept-charset\",\n \"accept-encoding\",\n \"access-control-request-headers\",\n \"access-control-request-method\",\n \"connection\",\n \"content-length\",\n \"content-transfer-encoding\",\n \"cookie\",\n \"cookie2\",\n \"date\",\n \"expect\",\n \"host\",\n \"keep-alive\",\n \"origin\",\n \"referer\",\n \"te\",\n \"trailer\",\n \"transfer-encoding\",\n \"upgrade\",\n \"via\"\n ];\n\n // These request methods are not allowed\n var forbiddenRequestMethods = [\n \"TRACE\",\n \"TRACK\",\n \"CONNECT\"\n ];\n\n // Send flag\n var sendFlag = false;\n // Error flag, used when errors occur or abort is called\n var errorFlag = false;\n\n // Event listeners\n var listeners = {};\n\n /**\n * Constants\n */\n\n this.UNSENT = 0;\n this.OPENED = 1;\n this.HEADERS_RECEIVED = 2;\n this.LOADING = 3;\n this.DONE = 4;\n\n /**\n * Public vars\n */\n\n // Current state\n this.readyState = this.UNSENT;\n\n // default ready state change handler in case one is not set or is set late\n this.onreadystatechange = null;\n\n // Result & response\n this.responseText = \"\";\n this.responseXML = \"\";\n this.status = null;\n this.statusText = null;\n \n // Whether cross-site Access-Control requests should be made using\n // credentials such as cookies or authorization headers\n this.withCredentials = false;\n\n /**\n * Private methods\n */\n\n /**\n * Check if the specified header is allowed.\n *\n * @param string header Header to validate\n * @return boolean False if not allowed, otherwise true\n */\n var isAllowedHttpHeader = function(header) {\n return disableHeaderCheck || (header && forbiddenRequestHeaders.indexOf(header.toLowerCase()) === -1);\n };\n\n /**\n * Check if the specified method is allowed.\n *\n * @param string method Request method to validate\n * @return boolean False if not allowed, otherwise true\n */\n var isAllowedHttpMethod = function(method) {\n return (method && forbiddenRequestMethods.indexOf(method) === -1);\n };\n\n /**\n * Public methods\n */\n\n /**\n * Open the connection. Currently supports local server requests.\n *\n * @param string method Connection method (eg GET, POST)\n * @param string url URL for the connection.\n * @param boolean async Asynchronous connection. Default is true.\n * @param string user Username for basic authentication (optional)\n * @param string password Password for basic authentication (optional)\n */\n this.open = function(method, url, async, user, password) {\n this.abort();\n errorFlag = false;\n\n // Check for valid request method\n if (!isAllowedHttpMethod(method)) {\n throw new Error(\"SecurityError: Request method not allowed\");\n }\n\n settings = {\n \"method\": method,\n \"url\": url.toString(),\n \"async\": (typeof async !== \"boolean\" ? true : async),\n \"user\": user || null,\n \"password\": password || null\n };\n\n setState(this.OPENED);\n };\n\n /**\n * Disables or enables isAllowedHttpHeader() check the request. Enabled by default.\n * This does not conform to the W3C spec.\n *\n * @param boolean state Enable or disable header checking.\n */\n this.setDisableHeaderCheck = function(state) {\n disableHeaderCheck = state;\n };\n\n /**\n * Sets a header for the request or appends the value if one is already set.\n *\n * @param string header Header name\n * @param string value Header value\n */\n this.setRequestHeader = function(header, value) {\n if (this.readyState !== this.OPENED) {\n throw new Error(\"INVALID_STATE_ERR: setRequestHeader can only be called when state is OPEN\");\n }\n if (!isAllowedHttpHeader(header)) {\n console.warn(\"Refused to set unsafe header \\\"\" + header + \"\\\"\");\n return;\n }\n if (sendFlag) {\n throw new Error(\"INVALID_STATE_ERR: send flag is true\");\n }\n header = headersCase[header.toLowerCase()] || header;\n headersCase[header.toLowerCase()] = header;\n headers[header] = headers[header] ? headers[header] + ', ' + value : value;\n };\n\n /**\n * Gets a header from the server response.\n *\n * @param string header Name of header to get.\n * @return string Text of the header or null if it doesn't exist.\n */\n this.getResponseHeader = function(header) {\n if (typeof header === \"string\"\n && this.readyState > this.OPENED\n && response\n && response.headers\n && response.headers[header.toLowerCase()]\n && !errorFlag\n ) {\n return response.headers[header.toLowerCase()];\n }\n\n return null;\n };\n\n /**\n * Gets all the response headers.\n *\n * @return string A string with all response headers separated by CR+LF\n */\n this.getAllResponseHeaders = function() {\n if (this.readyState < this.HEADERS_RECEIVED || errorFlag) {\n return \"\";\n }\n var result = \"\";\n\n for (var i in response.headers) {\n // Cookie headers are excluded\n if (i !== \"set-cookie\" && i !== \"set-cookie2\") {\n result += i + \": \" + response.headers[i] + \"\\r\\n\";\n }\n }\n return result.substr(0, result.length - 2);\n };\n\n /**\n * Gets a request header\n *\n * @param string name Name of header to get\n * @return string Returns the request header or empty string if not set\n */\n this.getRequestHeader = function(name) {\n if (typeof name === \"string\" && headersCase[name.toLowerCase()]) {\n return headers[headersCase[name.toLowerCase()]];\n }\n\n return \"\";\n };\n\n /**\n * Sends the request to the server.\n *\n * @param string data Optional data to send as request body.\n */\n this.send = function(data) {\n if (this.readyState !== this.OPENED) {\n throw new Error(\"INVALID_STATE_ERR: connection must be opened before send() is called\");\n }\n\n if (sendFlag) {\n throw new Error(\"INVALID_STATE_ERR: send has already been called\");\n }\n\n var ssl = false, local = false;\n var url = Url.parse(settings.url);\n var host;\n // Determine the server\n switch (url.protocol) {\n case \"https:\":\n ssl = true;\n // SSL & non-SSL both need host, no break here.\n case \"http:\":\n host = url.hostname;\n break;\n\n case \"file:\":\n local = true;\n break;\n\n case undefined:\n case null:\n case \"\":\n host = \"localhost\";\n break;\n\n default:\n throw new Error(\"Protocol not supported.\");\n }\n\n // Load files off the local filesystem (file://)\n if (local) {\n if (settings.method !== \"GET\") {\n throw new Error(\"XMLHttpRequest: Only GET method is supported\");\n }\n\n if (settings.async) {\n fs.readFile(url.pathname, \"utf8\", function(error, data) {\n if (error) {\n self.handleError(error);\n } else {\n self.status = 200;\n self.responseText = data;\n setState(self.DONE);\n }\n });\n } else {\n try {\n this.responseText = fs.readFileSync(url.pathname, \"utf8\");\n this.status = 200;\n setState(self.DONE);\n } catch(e) {\n this.handleError(e);\n }\n }\n\n return;\n }\n\n // Default to port 80. If accessing localhost on another port be sure\n // to use http://localhost:port/path\n var port = url.port || (ssl ? 443 : 80);\n // Add query string if one is used\n var uri = url.pathname + (url.search ? url.search : \"\");\n\n // Set the defaults if they haven't been set\n for (var name in defaultHeaders) {\n if (!headersCase[name.toLowerCase()]) {\n headers[name] = defaultHeaders[name];\n }\n }\n\n // Set the Host header or the server may reject the request\n headers.Host = host;\n if (!((ssl && port === 443) || port === 80)) {\n headers.Host += \":\" + url.port;\n }\n\n // Set Basic Auth if necessary\n if (settings.user) {\n if (typeof settings.password === \"undefined\") {\n settings.password = \"\";\n }\n var authBuf = new Buffer(settings.user + \":\" + settings.password);\n headers.Authorization = \"Basic \" + authBuf.toString(\"base64\");\n }\n\n // Set content length header\n if (settings.method === \"GET\" || settings.method === \"HEAD\") {\n data = null;\n } else if (data) {\n headers[\"Content-Length\"] = Buffer.isBuffer(data) ? data.length : Buffer.byteLength(data);\n\n if (!headers[\"Content-Type\"]) {\n headers[\"Content-Type\"] = \"text/plain;charset=UTF-8\";\n }\n } else if (settings.method === \"POST\") {\n // For a post with no data set Content-Length: 0.\n // This is required by buggy servers that don't meet the specs.\n headers[\"Content-Length\"] = 0;\n }\n\n var options = {\n host: host,\n port: port,\n path: uri,\n method: settings.method,\n headers: headers,\n agent: false,\n withCredentials: self.withCredentials\n };\n\n // Reset error flag\n errorFlag = false;\n\n // Handle async requests\n if (settings.async) {\n // Use the proper protocol\n var doRequest = ssl ? https.request : http.request;\n\n // Request is being sent, set send flag\n sendFlag = true;\n\n // As per spec, this is called here for historical reasons.\n self.dispatchEvent(\"readystatechange\");\n\n // Handler for the response\n var responseHandler = function responseHandler(resp) {\n // Set response var to the response we got back\n // This is so it remains accessable outside this scope\n response = resp;\n // Check for redirect\n // @TODO Prevent looped redirects\n if (response.statusCode === 301 || response.statusCode === 302 || response.statusCode === 303 || response.statusCode === 307) {\n // Change URL to the redirect location\n settings.url = response.headers.location;\n var url = Url.parse(settings.url);\n // Set host var in case it's used later\n host = url.hostname;\n // Options for the new request\n var newOptions = {\n hostname: url.hostname,\n port: url.port,\n path: url.path,\n method: response.statusCode === 303 ? \"GET\" : settings.method,\n headers: headers,\n withCredentials: self.withCredentials\n };\n\n // Issue the new request\n request = doRequest(newOptions, responseHandler).on(\"error\", errorHandler);\n request.end();\n // @TODO Check if an XHR event needs to be fired here\n return;\n }\n\n response.setEncoding(\"utf8\");\n\n setState(self.HEADERS_RECEIVED);\n self.status = response.statusCode;\n\n response.on(\"data\", function(chunk) {\n // Make sure there's some data\n if (chunk) {\n self.responseText += chunk;\n }\n // Don't emit state changes if the connection has been aborted.\n if (sendFlag) {\n setState(self.LOADING);\n }\n });\n\n response.on(\"end\", function() {\n if (sendFlag) {\n // Discard the end event if the connection has been aborted\n setState(self.DONE);\n sendFlag = false;\n }\n });\n\n response.on(\"error\", function(error) {\n self.handleError(error);\n });\n };\n\n // Error handler for the request\n var errorHandler = function errorHandler(error) {\n self.handleError(error);\n };\n\n // Create the request\n request = doRequest(options, responseHandler).on(\"error\", errorHandler);\n\n // Node 0.4 and later won't accept empty data. Make sure it's needed.\n if (data) {\n request.write(data);\n }\n\n request.end();\n\n self.dispatchEvent(\"loadstart\");\n } else { // Synchronous\n // Create a temporary file for communication with the other Node process\n var contentFile = \".node-xmlhttprequest-content-\" + process.pid;\n var syncFile = \".node-xmlhttprequest-sync-\" + process.pid;\n fs.writeFileSync(syncFile, \"\", \"utf8\");\n // The async request the other Node process executes\n var execString = \"var http = require('http'), https = require('https'), fs = require('fs');\"\n + \"var doRequest = http\" + (ssl ? \"s\" : \"\") + \".request;\"\n + \"var options = \" + JSON.stringify(options) + \";\"\n + \"var responseText = '';\"\n + \"var req = doRequest(options, function(response) {\"\n + \"response.setEncoding('utf8');\"\n + \"response.on('data', function(chunk) {\"\n + \" responseText += chunk;\"\n + \"});\"\n + \"response.on('end', function() {\"\n + \"fs.writeFileSync('\" + contentFile + \"', JSON.stringify({err: null, data: {statusCode: response.statusCode, headers: response.headers, text: responseText}}), 'utf8');\"\n + \"fs.unlinkSync('\" + syncFile + \"');\"\n + \"});\"\n + \"response.on('error', function(error) {\"\n + \"fs.writeFileSync('\" + contentFile + \"', JSON.stringify({err: error}), 'utf8');\"\n + \"fs.unlinkSync('\" + syncFile + \"');\"\n + \"});\"\n + \"}).on('error', function(error) {\"\n + \"fs.writeFileSync('\" + contentFile + \"', JSON.stringify({err: error}), 'utf8');\"\n + \"fs.unlinkSync('\" + syncFile + \"');\"\n + \"});\"\n + (data ? \"req.write('\" + JSON.stringify(data).slice(1,-1).replace(/'/g, \"\\\\'\") + \"');\":\"\")\n + \"req.end();\";\n // Start the other Node Process, executing this string\n var syncProc = spawn(process.argv[0], [\"-e\", execString]);\n while(fs.existsSync(syncFile)) {\n // Wait while the sync file is empty\n }\n var resp = JSON.parse(fs.readFileSync(contentFile, 'utf8'));\n // Kill the child process once the file has data\n syncProc.stdin.end();\n // Remove the temporary file\n fs.unlinkSync(contentFile);\n\n if (resp.err) {\n self.handleError(resp.err);\n } else {\n response = resp.data;\n self.status = resp.data.statusCode;\n self.responseText = resp.data.text;\n setState(self.DONE);\n }\n }\n };\n\n /**\n * Called when an error is encountered to deal with it.\n */\n this.handleError = function(error) {\n this.status = 0;\n this.statusText = error;\n this.responseText = error.stack;\n errorFlag = true;\n setState(this.DONE);\n this.dispatchEvent('error');\n };\n\n /**\n * Aborts a request.\n */\n this.abort = function() {\n if (request) {\n request.abort();\n request = null;\n }\n\n headers = defaultHeaders;\n this.status = 0;\n this.responseText = \"\";\n this.responseXML = \"\";\n\n errorFlag = true;\n\n if (this.readyState !== this.UNSENT\n && (this.readyState !== this.OPENED || sendFlag)\n && this.readyState !== this.DONE) {\n sendFlag = false;\n setState(this.DONE);\n }\n this.readyState = this.UNSENT;\n this.dispatchEvent('abort');\n };\n\n /**\n * Adds an event listener. Preferred method of binding to events.\n */\n this.addEventListener = function(event, callback) {\n if (!(event in listeners)) {\n listeners[event] = [];\n }\n // Currently allows duplicate callbacks. Should it?\n listeners[event].push(callback);\n };\n\n /**\n * Remove an event callback that has already been bound.\n * Only works on the matching funciton, cannot be a copy.\n */\n this.removeEventListener = function(event, callback) {\n if (event in listeners) {\n // Filter will return a new array with the callback removed\n listeners[event] = listeners[event].filter(function(ev) {\n return ev !== callback;\n });\n }\n };\n\n /**\n * Dispatch any events, including both \"on\" methods and events attached using addEventListener.\n */\n this.dispatchEvent = function(event) {\n if (typeof self[\"on\" + event] === \"function\") {\n self[\"on\" + event]();\n }\n if (event in listeners) {\n for (var i = 0, len = listeners[event].length; i < len; i++) {\n listeners[event][i].call(self);\n }\n }\n };\n\n /**\n * Changes readyState and calls onreadystatechange.\n *\n * @param int state New state\n */\n var setState = function(state) {\n if (state == self.LOADING || self.readyState !== state) {\n self.readyState = state;\n\n if (settings.async || self.readyState < self.OPENED || self.readyState === self.DONE) {\n self.dispatchEvent(\"readystatechange\");\n }\n\n if (self.readyState === self.DONE && !errorFlag) {\n self.dispatchEvent(\"load\");\n // @TODO figure out InspectorInstrumentation::didLoadXHR(cookie)\n self.dispatchEvent(\"loadend\");\n }\n }\n };\n};\n","(function(nacl) {\n'use strict';\n\n// Ported in 2014 by Dmitry Chestnykh and Devi Mandiri.\n// Public domain.\n//\n// Implementation derived from TweetNaCl version 20140427.\n// See for details: http://tweetnacl.cr.yp.to/\n\nvar gf = function(init) {\n var i, r = new Float64Array(16);\n if (init) for (i = 0; i < init.length; i++) r[i] = init[i];\n return r;\n};\n\n// Pluggable, initialized in high-level API below.\nvar randombytes = function(/* x, n */) { throw new Error('no PRNG'); };\n\nvar _0 = new Uint8Array(16);\nvar _9 = new Uint8Array(32); _9[0] = 9;\n\nvar gf0 = gf(),\n gf1 = gf([1]),\n _121665 = gf([0xdb41, 1]),\n D = gf([0x78a3, 0x1359, 0x4dca, 0x75eb, 0xd8ab, 0x4141, 0x0a4d, 0x0070, 0xe898, 0x7779, 0x4079, 0x8cc7, 0xfe73, 0x2b6f, 0x6cee, 0x5203]),\n D2 = gf([0xf159, 0x26b2, 0x9b94, 0xebd6, 0xb156, 0x8283, 0x149a, 0x00e0, 0xd130, 0xeef3, 0x80f2, 0x198e, 0xfce7, 0x56df, 0xd9dc, 0x2406]),\n X = gf([0xd51a, 0x8f25, 0x2d60, 0xc956, 0xa7b2, 0x9525, 0xc760, 0x692c, 0xdc5c, 0xfdd6, 0xe231, 0xc0a4, 0x53fe, 0xcd6e, 0x36d3, 0x2169]),\n Y = gf([0x6658, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666]),\n I = gf([0xa0b0, 0x4a0e, 0x1b27, 0xc4ee, 0xe478, 0xad2f, 0x1806, 0x2f43, 0xd7a7, 0x3dfb, 0x0099, 0x2b4d, 0xdf0b, 0x4fc1, 0x2480, 0x2b83]);\n\nfunction ts64(x, i, h, l) {\n x[i] = (h >> 24) & 0xff;\n x[i+1] = (h >> 16) & 0xff;\n x[i+2] = (h >> 8) & 0xff;\n x[i+3] = h & 0xff;\n x[i+4] = (l >> 24) & 0xff;\n x[i+5] = (l >> 16) & 0xff;\n x[i+6] = (l >> 8) & 0xff;\n x[i+7] = l & 0xff;\n}\n\nfunction vn(x, xi, y, yi, n) {\n var i,d = 0;\n for (i = 0; i < n; i++) d |= x[xi+i]^y[yi+i];\n return (1 & ((d - 1) >>> 8)) - 1;\n}\n\nfunction crypto_verify_16(x, xi, y, yi) {\n return vn(x,xi,y,yi,16);\n}\n\nfunction crypto_verify_32(x, xi, y, yi) {\n return vn(x,xi,y,yi,32);\n}\n\nfunction core_salsa20(o, p, k, c) {\n var j0 = c[ 0] & 0xff | (c[ 1] & 0xff)<<8 | (c[ 2] & 0xff)<<16 | (c[ 3] & 0xff)<<24,\n j1 = k[ 0] & 0xff | (k[ 1] & 0xff)<<8 | (k[ 2] & 0xff)<<16 | (k[ 3] & 0xff)<<24,\n j2 = k[ 4] & 0xff | (k[ 5] & 0xff)<<8 | (k[ 6] & 0xff)<<16 | (k[ 7] & 0xff)<<24,\n j3 = k[ 8] & 0xff | (k[ 9] & 0xff)<<8 | (k[10] & 0xff)<<16 | (k[11] & 0xff)<<24,\n j4 = k[12] & 0xff | (k[13] & 0xff)<<8 | (k[14] & 0xff)<<16 | (k[15] & 0xff)<<24,\n j5 = c[ 4] & 0xff | (c[ 5] & 0xff)<<8 | (c[ 6] & 0xff)<<16 | (c[ 7] & 0xff)<<24,\n j6 = p[ 0] & 0xff | (p[ 1] & 0xff)<<8 | (p[ 2] & 0xff)<<16 | (p[ 3] & 0xff)<<24,\n j7 = p[ 4] & 0xff | (p[ 5] & 0xff)<<8 | (p[ 6] & 0xff)<<16 | (p[ 7] & 0xff)<<24,\n j8 = p[ 8] & 0xff | (p[ 9] & 0xff)<<8 | (p[10] & 0xff)<<16 | (p[11] & 0xff)<<24,\n j9 = p[12] & 0xff | (p[13] & 0xff)<<8 | (p[14] & 0xff)<<16 | (p[15] & 0xff)<<24,\n j10 = c[ 8] & 0xff | (c[ 9] & 0xff)<<8 | (c[10] & 0xff)<<16 | (c[11] & 0xff)<<24,\n j11 = k[16] & 0xff | (k[17] & 0xff)<<8 | (k[18] & 0xff)<<16 | (k[19] & 0xff)<<24,\n j12 = k[20] & 0xff | (k[21] & 0xff)<<8 | (k[22] & 0xff)<<16 | (k[23] & 0xff)<<24,\n j13 = k[24] & 0xff | (k[25] & 0xff)<<8 | (k[26] & 0xff)<<16 | (k[27] & 0xff)<<24,\n j14 = k[28] & 0xff | (k[29] & 0xff)<<8 | (k[30] & 0xff)<<16 | (k[31] & 0xff)<<24,\n j15 = c[12] & 0xff | (c[13] & 0xff)<<8 | (c[14] & 0xff)<<16 | (c[15] & 0xff)<<24;\n\n var x0 = j0, x1 = j1, x2 = j2, x3 = j3, x4 = j4, x5 = j5, x6 = j6, x7 = j7,\n x8 = j8, x9 = j9, x10 = j10, x11 = j11, x12 = j12, x13 = j13, x14 = j14,\n x15 = j15, u;\n\n for (var i = 0; i < 20; i += 2) {\n u = x0 + x12 | 0;\n x4 ^= u<<7 | u>>>(32-7);\n u = x4 + x0 | 0;\n x8 ^= u<<9 | u>>>(32-9);\n u = x8 + x4 | 0;\n x12 ^= u<<13 | u>>>(32-13);\n u = x12 + x8 | 0;\n x0 ^= u<<18 | u>>>(32-18);\n\n u = x5 + x1 | 0;\n x9 ^= u<<7 | u>>>(32-7);\n u = x9 + x5 | 0;\n x13 ^= u<<9 | u>>>(32-9);\n u = x13 + x9 | 0;\n x1 ^= u<<13 | u>>>(32-13);\n u = x1 + x13 | 0;\n x5 ^= u<<18 | u>>>(32-18);\n\n u = x10 + x6 | 0;\n x14 ^= u<<7 | u>>>(32-7);\n u = x14 + x10 | 0;\n x2 ^= u<<9 | u>>>(32-9);\n u = x2 + x14 | 0;\n x6 ^= u<<13 | u>>>(32-13);\n u = x6 + x2 | 0;\n x10 ^= u<<18 | u>>>(32-18);\n\n u = x15 + x11 | 0;\n x3 ^= u<<7 | u>>>(32-7);\n u = x3 + x15 | 0;\n x7 ^= u<<9 | u>>>(32-9);\n u = x7 + x3 | 0;\n x11 ^= u<<13 | u>>>(32-13);\n u = x11 + x7 | 0;\n x15 ^= u<<18 | u>>>(32-18);\n\n u = x0 + x3 | 0;\n x1 ^= u<<7 | u>>>(32-7);\n u = x1 + x0 | 0;\n x2 ^= u<<9 | u>>>(32-9);\n u = x2 + x1 | 0;\n x3 ^= u<<13 | u>>>(32-13);\n u = x3 + x2 | 0;\n x0 ^= u<<18 | u>>>(32-18);\n\n u = x5 + x4 | 0;\n x6 ^= u<<7 | u>>>(32-7);\n u = x6 + x5 | 0;\n x7 ^= u<<9 | u>>>(32-9);\n u = x7 + x6 | 0;\n x4 ^= u<<13 | u>>>(32-13);\n u = x4 + x7 | 0;\n x5 ^= u<<18 | u>>>(32-18);\n\n u = x10 + x9 | 0;\n x11 ^= u<<7 | u>>>(32-7);\n u = x11 + x10 | 0;\n x8 ^= u<<9 | u>>>(32-9);\n u = x8 + x11 | 0;\n x9 ^= u<<13 | u>>>(32-13);\n u = x9 + x8 | 0;\n x10 ^= u<<18 | u>>>(32-18);\n\n u = x15 + x14 | 0;\n x12 ^= u<<7 | u>>>(32-7);\n u = x12 + x15 | 0;\n x13 ^= u<<9 | u>>>(32-9);\n u = x13 + x12 | 0;\n x14 ^= u<<13 | u>>>(32-13);\n u = x14 + x13 | 0;\n x15 ^= u<<18 | u>>>(32-18);\n }\n x0 = x0 + j0 | 0;\n x1 = x1 + j1 | 0;\n x2 = x2 + j2 | 0;\n x3 = x3 + j3 | 0;\n x4 = x4 + j4 | 0;\n x5 = x5 + j5 | 0;\n x6 = x6 + j6 | 0;\n x7 = x7 + j7 | 0;\n x8 = x8 + j8 | 0;\n x9 = x9 + j9 | 0;\n x10 = x10 + j10 | 0;\n x11 = x11 + j11 | 0;\n x12 = x12 + j12 | 0;\n x13 = x13 + j13 | 0;\n x14 = x14 + j14 | 0;\n x15 = x15 + j15 | 0;\n\n o[ 0] = x0 >>> 0 & 0xff;\n o[ 1] = x0 >>> 8 & 0xff;\n o[ 2] = x0 >>> 16 & 0xff;\n o[ 3] = x0 >>> 24 & 0xff;\n\n o[ 4] = x1 >>> 0 & 0xff;\n o[ 5] = x1 >>> 8 & 0xff;\n o[ 6] = x1 >>> 16 & 0xff;\n o[ 7] = x1 >>> 24 & 0xff;\n\n o[ 8] = x2 >>> 0 & 0xff;\n o[ 9] = x2 >>> 8 & 0xff;\n o[10] = x2 >>> 16 & 0xff;\n o[11] = x2 >>> 24 & 0xff;\n\n o[12] = x3 >>> 0 & 0xff;\n o[13] = x3 >>> 8 & 0xff;\n o[14] = x3 >>> 16 & 0xff;\n o[15] = x3 >>> 24 & 0xff;\n\n o[16] = x4 >>> 0 & 0xff;\n o[17] = x4 >>> 8 & 0xff;\n o[18] = x4 >>> 16 & 0xff;\n o[19] = x4 >>> 24 & 0xff;\n\n o[20] = x5 >>> 0 & 0xff;\n o[21] = x5 >>> 8 & 0xff;\n o[22] = x5 >>> 16 & 0xff;\n o[23] = x5 >>> 24 & 0xff;\n\n o[24] = x6 >>> 0 & 0xff;\n o[25] = x6 >>> 8 & 0xff;\n o[26] = x6 >>> 16 & 0xff;\n o[27] = x6 >>> 24 & 0xff;\n\n o[28] = x7 >>> 0 & 0xff;\n o[29] = x7 >>> 8 & 0xff;\n o[30] = x7 >>> 16 & 0xff;\n o[31] = x7 >>> 24 & 0xff;\n\n o[32] = x8 >>> 0 & 0xff;\n o[33] = x8 >>> 8 & 0xff;\n o[34] = x8 >>> 16 & 0xff;\n o[35] = x8 >>> 24 & 0xff;\n\n o[36] = x9 >>> 0 & 0xff;\n o[37] = x9 >>> 8 & 0xff;\n o[38] = x9 >>> 16 & 0xff;\n o[39] = x9 >>> 24 & 0xff;\n\n o[40] = x10 >>> 0 & 0xff;\n o[41] = x10 >>> 8 & 0xff;\n o[42] = x10 >>> 16 & 0xff;\n o[43] = x10 >>> 24 & 0xff;\n\n o[44] = x11 >>> 0 & 0xff;\n o[45] = x11 >>> 8 & 0xff;\n o[46] = x11 >>> 16 & 0xff;\n o[47] = x11 >>> 24 & 0xff;\n\n o[48] = x12 >>> 0 & 0xff;\n o[49] = x12 >>> 8 & 0xff;\n o[50] = x12 >>> 16 & 0xff;\n o[51] = x12 >>> 24 & 0xff;\n\n o[52] = x13 >>> 0 & 0xff;\n o[53] = x13 >>> 8 & 0xff;\n o[54] = x13 >>> 16 & 0xff;\n o[55] = x13 >>> 24 & 0xff;\n\n o[56] = x14 >>> 0 & 0xff;\n o[57] = x14 >>> 8 & 0xff;\n o[58] = x14 >>> 16 & 0xff;\n o[59] = x14 >>> 24 & 0xff;\n\n o[60] = x15 >>> 0 & 0xff;\n o[61] = x15 >>> 8 & 0xff;\n o[62] = x15 >>> 16 & 0xff;\n o[63] = x15 >>> 24 & 0xff;\n}\n\nfunction core_hsalsa20(o,p,k,c) {\n var j0 = c[ 0] & 0xff | (c[ 1] & 0xff)<<8 | (c[ 2] & 0xff)<<16 | (c[ 3] & 0xff)<<24,\n j1 = k[ 0] & 0xff | (k[ 1] & 0xff)<<8 | (k[ 2] & 0xff)<<16 | (k[ 3] & 0xff)<<24,\n j2 = k[ 4] & 0xff | (k[ 5] & 0xff)<<8 | (k[ 6] & 0xff)<<16 | (k[ 7] & 0xff)<<24,\n j3 = k[ 8] & 0xff | (k[ 9] & 0xff)<<8 | (k[10] & 0xff)<<16 | (k[11] & 0xff)<<24,\n j4 = k[12] & 0xff | (k[13] & 0xff)<<8 | (k[14] & 0xff)<<16 | (k[15] & 0xff)<<24,\n j5 = c[ 4] & 0xff | (c[ 5] & 0xff)<<8 | (c[ 6] & 0xff)<<16 | (c[ 7] & 0xff)<<24,\n j6 = p[ 0] & 0xff | (p[ 1] & 0xff)<<8 | (p[ 2] & 0xff)<<16 | (p[ 3] & 0xff)<<24,\n j7 = p[ 4] & 0xff | (p[ 5] & 0xff)<<8 | (p[ 6] & 0xff)<<16 | (p[ 7] & 0xff)<<24,\n j8 = p[ 8] & 0xff | (p[ 9] & 0xff)<<8 | (p[10] & 0xff)<<16 | (p[11] & 0xff)<<24,\n j9 = p[12] & 0xff | (p[13] & 0xff)<<8 | (p[14] & 0xff)<<16 | (p[15] & 0xff)<<24,\n j10 = c[ 8] & 0xff | (c[ 9] & 0xff)<<8 | (c[10] & 0xff)<<16 | (c[11] & 0xff)<<24,\n j11 = k[16] & 0xff | (k[17] & 0xff)<<8 | (k[18] & 0xff)<<16 | (k[19] & 0xff)<<24,\n j12 = k[20] & 0xff | (k[21] & 0xff)<<8 | (k[22] & 0xff)<<16 | (k[23] & 0xff)<<24,\n j13 = k[24] & 0xff | (k[25] & 0xff)<<8 | (k[26] & 0xff)<<16 | (k[27] & 0xff)<<24,\n j14 = k[28] & 0xff | (k[29] & 0xff)<<8 | (k[30] & 0xff)<<16 | (k[31] & 0xff)<<24,\n j15 = c[12] & 0xff | (c[13] & 0xff)<<8 | (c[14] & 0xff)<<16 | (c[15] & 0xff)<<24;\n\n var x0 = j0, x1 = j1, x2 = j2, x3 = j3, x4 = j4, x5 = j5, x6 = j6, x7 = j7,\n x8 = j8, x9 = j9, x10 = j10, x11 = j11, x12 = j12, x13 = j13, x14 = j14,\n x15 = j15, u;\n\n for (var i = 0; i < 20; i += 2) {\n u = x0 + x12 | 0;\n x4 ^= u<<7 | u>>>(32-7);\n u = x4 + x0 | 0;\n x8 ^= u<<9 | u>>>(32-9);\n u = x8 + x4 | 0;\n x12 ^= u<<13 | u>>>(32-13);\n u = x12 + x8 | 0;\n x0 ^= u<<18 | u>>>(32-18);\n\n u = x5 + x1 | 0;\n x9 ^= u<<7 | u>>>(32-7);\n u = x9 + x5 | 0;\n x13 ^= u<<9 | u>>>(32-9);\n u = x13 + x9 | 0;\n x1 ^= u<<13 | u>>>(32-13);\n u = x1 + x13 | 0;\n x5 ^= u<<18 | u>>>(32-18);\n\n u = x10 + x6 | 0;\n x14 ^= u<<7 | u>>>(32-7);\n u = x14 + x10 | 0;\n x2 ^= u<<9 | u>>>(32-9);\n u = x2 + x14 | 0;\n x6 ^= u<<13 | u>>>(32-13);\n u = x6 + x2 | 0;\n x10 ^= u<<18 | u>>>(32-18);\n\n u = x15 + x11 | 0;\n x3 ^= u<<7 | u>>>(32-7);\n u = x3 + x15 | 0;\n x7 ^= u<<9 | u>>>(32-9);\n u = x7 + x3 | 0;\n x11 ^= u<<13 | u>>>(32-13);\n u = x11 + x7 | 0;\n x15 ^= u<<18 | u>>>(32-18);\n\n u = x0 + x3 | 0;\n x1 ^= u<<7 | u>>>(32-7);\n u = x1 + x0 | 0;\n x2 ^= u<<9 | u>>>(32-9);\n u = x2 + x1 | 0;\n x3 ^= u<<13 | u>>>(32-13);\n u = x3 + x2 | 0;\n x0 ^= u<<18 | u>>>(32-18);\n\n u = x5 + x4 | 0;\n x6 ^= u<<7 | u>>>(32-7);\n u = x6 + x5 | 0;\n x7 ^= u<<9 | u>>>(32-9);\n u = x7 + x6 | 0;\n x4 ^= u<<13 | u>>>(32-13);\n u = x4 + x7 | 0;\n x5 ^= u<<18 | u>>>(32-18);\n\n u = x10 + x9 | 0;\n x11 ^= u<<7 | u>>>(32-7);\n u = x11 + x10 | 0;\n x8 ^= u<<9 | u>>>(32-9);\n u = x8 + x11 | 0;\n x9 ^= u<<13 | u>>>(32-13);\n u = x9 + x8 | 0;\n x10 ^= u<<18 | u>>>(32-18);\n\n u = x15 + x14 | 0;\n x12 ^= u<<7 | u>>>(32-7);\n u = x12 + x15 | 0;\n x13 ^= u<<9 | u>>>(32-9);\n u = x13 + x12 | 0;\n x14 ^= u<<13 | u>>>(32-13);\n u = x14 + x13 | 0;\n x15 ^= u<<18 | u>>>(32-18);\n }\n\n o[ 0] = x0 >>> 0 & 0xff;\n o[ 1] = x0 >>> 8 & 0xff;\n o[ 2] = x0 >>> 16 & 0xff;\n o[ 3] = x0 >>> 24 & 0xff;\n\n o[ 4] = x5 >>> 0 & 0xff;\n o[ 5] = x5 >>> 8 & 0xff;\n o[ 6] = x5 >>> 16 & 0xff;\n o[ 7] = x5 >>> 24 & 0xff;\n\n o[ 8] = x10 >>> 0 & 0xff;\n o[ 9] = x10 >>> 8 & 0xff;\n o[10] = x10 >>> 16 & 0xff;\n o[11] = x10 >>> 24 & 0xff;\n\n o[12] = x15 >>> 0 & 0xff;\n o[13] = x15 >>> 8 & 0xff;\n o[14] = x15 >>> 16 & 0xff;\n o[15] = x15 >>> 24 & 0xff;\n\n o[16] = x6 >>> 0 & 0xff;\n o[17] = x6 >>> 8 & 0xff;\n o[18] = x6 >>> 16 & 0xff;\n o[19] = x6 >>> 24 & 0xff;\n\n o[20] = x7 >>> 0 & 0xff;\n o[21] = x7 >>> 8 & 0xff;\n o[22] = x7 >>> 16 & 0xff;\n o[23] = x7 >>> 24 & 0xff;\n\n o[24] = x8 >>> 0 & 0xff;\n o[25] = x8 >>> 8 & 0xff;\n o[26] = x8 >>> 16 & 0xff;\n o[27] = x8 >>> 24 & 0xff;\n\n o[28] = x9 >>> 0 & 0xff;\n o[29] = x9 >>> 8 & 0xff;\n o[30] = x9 >>> 16 & 0xff;\n o[31] = x9 >>> 24 & 0xff;\n}\n\nfunction crypto_core_salsa20(out,inp,k,c) {\n core_salsa20(out,inp,k,c);\n}\n\nfunction crypto_core_hsalsa20(out,inp,k,c) {\n core_hsalsa20(out,inp,k,c);\n}\n\nvar sigma = new Uint8Array([101, 120, 112, 97, 110, 100, 32, 51, 50, 45, 98, 121, 116, 101, 32, 107]);\n // \"expand 32-byte k\"\n\nfunction crypto_stream_salsa20_xor(c,cpos,m,mpos,b,n,k) {\n var z = new Uint8Array(16), x = new Uint8Array(64);\n var u, i;\n for (i = 0; i < 16; i++) z[i] = 0;\n for (i = 0; i < 8; i++) z[i] = n[i];\n while (b >= 64) {\n crypto_core_salsa20(x,z,k,sigma);\n for (i = 0; i < 64; i++) c[cpos+i] = m[mpos+i] ^ x[i];\n u = 1;\n for (i = 8; i < 16; i++) {\n u = u + (z[i] & 0xff) | 0;\n z[i] = u & 0xff;\n u >>>= 8;\n }\n b -= 64;\n cpos += 64;\n mpos += 64;\n }\n if (b > 0) {\n crypto_core_salsa20(x,z,k,sigma);\n for (i = 0; i < b; i++) c[cpos+i] = m[mpos+i] ^ x[i];\n }\n return 0;\n}\n\nfunction crypto_stream_salsa20(c,cpos,b,n,k) {\n var z = new Uint8Array(16), x = new Uint8Array(64);\n var u, i;\n for (i = 0; i < 16; i++) z[i] = 0;\n for (i = 0; i < 8; i++) z[i] = n[i];\n while (b >= 64) {\n crypto_core_salsa20(x,z,k,sigma);\n for (i = 0; i < 64; i++) c[cpos+i] = x[i];\n u = 1;\n for (i = 8; i < 16; i++) {\n u = u + (z[i] & 0xff) | 0;\n z[i] = u & 0xff;\n u >>>= 8;\n }\n b -= 64;\n cpos += 64;\n }\n if (b > 0) {\n crypto_core_salsa20(x,z,k,sigma);\n for (i = 0; i < b; i++) c[cpos+i] = x[i];\n }\n return 0;\n}\n\nfunction crypto_stream(c,cpos,d,n,k) {\n var s = new Uint8Array(32);\n crypto_core_hsalsa20(s,n,k,sigma);\n var sn = new Uint8Array(8);\n for (var i = 0; i < 8; i++) sn[i] = n[i+16];\n return crypto_stream_salsa20(c,cpos,d,sn,s);\n}\n\nfunction crypto_stream_xor(c,cpos,m,mpos,d,n,k) {\n var s = new Uint8Array(32);\n crypto_core_hsalsa20(s,n,k,sigma);\n var sn = new Uint8Array(8);\n for (var i = 0; i < 8; i++) sn[i] = n[i+16];\n return crypto_stream_salsa20_xor(c,cpos,m,mpos,d,sn,s);\n}\n\n/*\n* Port of Andrew Moon's Poly1305-donna-16. Public domain.\n* https://github.com/floodyberry/poly1305-donna\n*/\n\nvar poly1305 = function(key) {\n this.buffer = new Uint8Array(16);\n this.r = new Uint16Array(10);\n this.h = new Uint16Array(10);\n this.pad = new Uint16Array(8);\n this.leftover = 0;\n this.fin = 0;\n\n var t0, t1, t2, t3, t4, t5, t6, t7;\n\n t0 = key[ 0] & 0xff | (key[ 1] & 0xff) << 8; this.r[0] = ( t0 ) & 0x1fff;\n t1 = key[ 2] & 0xff | (key[ 3] & 0xff) << 8; this.r[1] = ((t0 >>> 13) | (t1 << 3)) & 0x1fff;\n t2 = key[ 4] & 0xff | (key[ 5] & 0xff) << 8; this.r[2] = ((t1 >>> 10) | (t2 << 6)) & 0x1f03;\n t3 = key[ 6] & 0xff | (key[ 7] & 0xff) << 8; this.r[3] = ((t2 >>> 7) | (t3 << 9)) & 0x1fff;\n t4 = key[ 8] & 0xff | (key[ 9] & 0xff) << 8; this.r[4] = ((t3 >>> 4) | (t4 << 12)) & 0x00ff;\n this.r[5] = ((t4 >>> 1)) & 0x1ffe;\n t5 = key[10] & 0xff | (key[11] & 0xff) << 8; this.r[6] = ((t4 >>> 14) | (t5 << 2)) & 0x1fff;\n t6 = key[12] & 0xff | (key[13] & 0xff) << 8; this.r[7] = ((t5 >>> 11) | (t6 << 5)) & 0x1f81;\n t7 = key[14] & 0xff | (key[15] & 0xff) << 8; this.r[8] = ((t6 >>> 8) | (t7 << 8)) & 0x1fff;\n this.r[9] = ((t7 >>> 5)) & 0x007f;\n\n this.pad[0] = key[16] & 0xff | (key[17] & 0xff) << 8;\n this.pad[1] = key[18] & 0xff | (key[19] & 0xff) << 8;\n this.pad[2] = key[20] & 0xff | (key[21] & 0xff) << 8;\n this.pad[3] = key[22] & 0xff | (key[23] & 0xff) << 8;\n this.pad[4] = key[24] & 0xff | (key[25] & 0xff) << 8;\n this.pad[5] = key[26] & 0xff | (key[27] & 0xff) << 8;\n this.pad[6] = key[28] & 0xff | (key[29] & 0xff) << 8;\n this.pad[7] = key[30] & 0xff | (key[31] & 0xff) << 8;\n};\n\npoly1305.prototype.blocks = function(m, mpos, bytes) {\n var hibit = this.fin ? 0 : (1 << 11);\n var t0, t1, t2, t3, t4, t5, t6, t7, c;\n var d0, d1, d2, d3, d4, d5, d6, d7, d8, d9;\n\n var h0 = this.h[0],\n h1 = this.h[1],\n h2 = this.h[2],\n h3 = this.h[3],\n h4 = this.h[4],\n h5 = this.h[5],\n h6 = this.h[6],\n h7 = this.h[7],\n h8 = this.h[8],\n h9 = this.h[9];\n\n var r0 = this.r[0],\n r1 = this.r[1],\n r2 = this.r[2],\n r3 = this.r[3],\n r4 = this.r[4],\n r5 = this.r[5],\n r6 = this.r[6],\n r7 = this.r[7],\n r8 = this.r[8],\n r9 = this.r[9];\n\n while (bytes >= 16) {\n t0 = m[mpos+ 0] & 0xff | (m[mpos+ 1] & 0xff) << 8; h0 += ( t0 ) & 0x1fff;\n t1 = m[mpos+ 2] & 0xff | (m[mpos+ 3] & 0xff) << 8; h1 += ((t0 >>> 13) | (t1 << 3)) & 0x1fff;\n t2 = m[mpos+ 4] & 0xff | (m[mpos+ 5] & 0xff) << 8; h2 += ((t1 >>> 10) | (t2 << 6)) & 0x1fff;\n t3 = m[mpos+ 6] & 0xff | (m[mpos+ 7] & 0xff) << 8; h3 += ((t2 >>> 7) | (t3 << 9)) & 0x1fff;\n t4 = m[mpos+ 8] & 0xff | (m[mpos+ 9] & 0xff) << 8; h4 += ((t3 >>> 4) | (t4 << 12)) & 0x1fff;\n h5 += ((t4 >>> 1)) & 0x1fff;\n t5 = m[mpos+10] & 0xff | (m[mpos+11] & 0xff) << 8; h6 += ((t4 >>> 14) | (t5 << 2)) & 0x1fff;\n t6 = m[mpos+12] & 0xff | (m[mpos+13] & 0xff) << 8; h7 += ((t5 >>> 11) | (t6 << 5)) & 0x1fff;\n t7 = m[mpos+14] & 0xff | (m[mpos+15] & 0xff) << 8; h8 += ((t6 >>> 8) | (t7 << 8)) & 0x1fff;\n h9 += ((t7 >>> 5)) | hibit;\n\n c = 0;\n\n d0 = c;\n d0 += h0 * r0;\n d0 += h1 * (5 * r9);\n d0 += h2 * (5 * r8);\n d0 += h3 * (5 * r7);\n d0 += h4 * (5 * r6);\n c = (d0 >>> 13); d0 &= 0x1fff;\n d0 += h5 * (5 * r5);\n d0 += h6 * (5 * r4);\n d0 += h7 * (5 * r3);\n d0 += h8 * (5 * r2);\n d0 += h9 * (5 * r1);\n c += (d0 >>> 13); d0 &= 0x1fff;\n\n d1 = c;\n d1 += h0 * r1;\n d1 += h1 * r0;\n d1 += h2 * (5 * r9);\n d1 += h3 * (5 * r8);\n d1 += h4 * (5 * r7);\n c = (d1 >>> 13); d1 &= 0x1fff;\n d1 += h5 * (5 * r6);\n d1 += h6 * (5 * r5);\n d1 += h7 * (5 * r4);\n d1 += h8 * (5 * r3);\n d1 += h9 * (5 * r2);\n c += (d1 >>> 13); d1 &= 0x1fff;\n\n d2 = c;\n d2 += h0 * r2;\n d2 += h1 * r1;\n d2 += h2 * r0;\n d2 += h3 * (5 * r9);\n d2 += h4 * (5 * r8);\n c = (d2 >>> 13); d2 &= 0x1fff;\n d2 += h5 * (5 * r7);\n d2 += h6 * (5 * r6);\n d2 += h7 * (5 * r5);\n d2 += h8 * (5 * r4);\n d2 += h9 * (5 * r3);\n c += (d2 >>> 13); d2 &= 0x1fff;\n\n d3 = c;\n d3 += h0 * r3;\n d3 += h1 * r2;\n d3 += h2 * r1;\n d3 += h3 * r0;\n d3 += h4 * (5 * r9);\n c = (d3 >>> 13); d3 &= 0x1fff;\n d3 += h5 * (5 * r8);\n d3 += h6 * (5 * r7);\n d3 += h7 * (5 * r6);\n d3 += h8 * (5 * r5);\n d3 += h9 * (5 * r4);\n c += (d3 >>> 13); d3 &= 0x1fff;\n\n d4 = c;\n d4 += h0 * r4;\n d4 += h1 * r3;\n d4 += h2 * r2;\n d4 += h3 * r1;\n d4 += h4 * r0;\n c = (d4 >>> 13); d4 &= 0x1fff;\n d4 += h5 * (5 * r9);\n d4 += h6 * (5 * r8);\n d4 += h7 * (5 * r7);\n d4 += h8 * (5 * r6);\n d4 += h9 * (5 * r5);\n c += (d4 >>> 13); d4 &= 0x1fff;\n\n d5 = c;\n d5 += h0 * r5;\n d5 += h1 * r4;\n d5 += h2 * r3;\n d5 += h3 * r2;\n d5 += h4 * r1;\n c = (d5 >>> 13); d5 &= 0x1fff;\n d5 += h5 * r0;\n d5 += h6 * (5 * r9);\n d5 += h7 * (5 * r8);\n d5 += h8 * (5 * r7);\n d5 += h9 * (5 * r6);\n c += (d5 >>> 13); d5 &= 0x1fff;\n\n d6 = c;\n d6 += h0 * r6;\n d6 += h1 * r5;\n d6 += h2 * r4;\n d6 += h3 * r3;\n d6 += h4 * r2;\n c = (d6 >>> 13); d6 &= 0x1fff;\n d6 += h5 * r1;\n d6 += h6 * r0;\n d6 += h7 * (5 * r9);\n d6 += h8 * (5 * r8);\n d6 += h9 * (5 * r7);\n c += (d6 >>> 13); d6 &= 0x1fff;\n\n d7 = c;\n d7 += h0 * r7;\n d7 += h1 * r6;\n d7 += h2 * r5;\n d7 += h3 * r4;\n d7 += h4 * r3;\n c = (d7 >>> 13); d7 &= 0x1fff;\n d7 += h5 * r2;\n d7 += h6 * r1;\n d7 += h7 * r0;\n d7 += h8 * (5 * r9);\n d7 += h9 * (5 * r8);\n c += (d7 >>> 13); d7 &= 0x1fff;\n\n d8 = c;\n d8 += h0 * r8;\n d8 += h1 * r7;\n d8 += h2 * r6;\n d8 += h3 * r5;\n d8 += h4 * r4;\n c = (d8 >>> 13); d8 &= 0x1fff;\n d8 += h5 * r3;\n d8 += h6 * r2;\n d8 += h7 * r1;\n d8 += h8 * r0;\n d8 += h9 * (5 * r9);\n c += (d8 >>> 13); d8 &= 0x1fff;\n\n d9 = c;\n d9 += h0 * r9;\n d9 += h1 * r8;\n d9 += h2 * r7;\n d9 += h3 * r6;\n d9 += h4 * r5;\n c = (d9 >>> 13); d9 &= 0x1fff;\n d9 += h5 * r4;\n d9 += h6 * r3;\n d9 += h7 * r2;\n d9 += h8 * r1;\n d9 += h9 * r0;\n c += (d9 >>> 13); d9 &= 0x1fff;\n\n c = (((c << 2) + c)) | 0;\n c = (c + d0) | 0;\n d0 = c & 0x1fff;\n c = (c >>> 13);\n d1 += c;\n\n h0 = d0;\n h1 = d1;\n h2 = d2;\n h3 = d3;\n h4 = d4;\n h5 = d5;\n h6 = d6;\n h7 = d7;\n h8 = d8;\n h9 = d9;\n\n mpos += 16;\n bytes -= 16;\n }\n this.h[0] = h0;\n this.h[1] = h1;\n this.h[2] = h2;\n this.h[3] = h3;\n this.h[4] = h4;\n this.h[5] = h5;\n this.h[6] = h6;\n this.h[7] = h7;\n this.h[8] = h8;\n this.h[9] = h9;\n};\n\npoly1305.prototype.finish = function(mac, macpos) {\n var g = new Uint16Array(10);\n var c, mask, f, i;\n\n if (this.leftover) {\n i = this.leftover;\n this.buffer[i++] = 1;\n for (; i < 16; i++) this.buffer[i] = 0;\n this.fin = 1;\n this.blocks(this.buffer, 0, 16);\n }\n\n c = this.h[1] >>> 13;\n this.h[1] &= 0x1fff;\n for (i = 2; i < 10; i++) {\n this.h[i] += c;\n c = this.h[i] >>> 13;\n this.h[i] &= 0x1fff;\n }\n this.h[0] += (c * 5);\n c = this.h[0] >>> 13;\n this.h[0] &= 0x1fff;\n this.h[1] += c;\n c = this.h[1] >>> 13;\n this.h[1] &= 0x1fff;\n this.h[2] += c;\n\n g[0] = this.h[0] + 5;\n c = g[0] >>> 13;\n g[0] &= 0x1fff;\n for (i = 1; i < 10; i++) {\n g[i] = this.h[i] + c;\n c = g[i] >>> 13;\n g[i] &= 0x1fff;\n }\n g[9] -= (1 << 13);\n\n mask = (c ^ 1) - 1;\n for (i = 0; i < 10; i++) g[i] &= mask;\n mask = ~mask;\n for (i = 0; i < 10; i++) this.h[i] = (this.h[i] & mask) | g[i];\n\n this.h[0] = ((this.h[0] ) | (this.h[1] << 13) ) & 0xffff;\n this.h[1] = ((this.h[1] >>> 3) | (this.h[2] << 10) ) & 0xffff;\n this.h[2] = ((this.h[2] >>> 6) | (this.h[3] << 7) ) & 0xffff;\n this.h[3] = ((this.h[3] >>> 9) | (this.h[4] << 4) ) & 0xffff;\n this.h[4] = ((this.h[4] >>> 12) | (this.h[5] << 1) | (this.h[6] << 14)) & 0xffff;\n this.h[5] = ((this.h[6] >>> 2) | (this.h[7] << 11) ) & 0xffff;\n this.h[6] = ((this.h[7] >>> 5) | (this.h[8] << 8) ) & 0xffff;\n this.h[7] = ((this.h[8] >>> 8) | (this.h[9] << 5) ) & 0xffff;\n\n f = this.h[0] + this.pad[0];\n this.h[0] = f & 0xffff;\n for (i = 1; i < 8; i++) {\n f = (((this.h[i] + this.pad[i]) | 0) + (f >>> 16)) | 0;\n this.h[i] = f & 0xffff;\n }\n\n mac[macpos+ 0] = (this.h[0] >>> 0) & 0xff;\n mac[macpos+ 1] = (this.h[0] >>> 8) & 0xff;\n mac[macpos+ 2] = (this.h[1] >>> 0) & 0xff;\n mac[macpos+ 3] = (this.h[1] >>> 8) & 0xff;\n mac[macpos+ 4] = (this.h[2] >>> 0) & 0xff;\n mac[macpos+ 5] = (this.h[2] >>> 8) & 0xff;\n mac[macpos+ 6] = (this.h[3] >>> 0) & 0xff;\n mac[macpos+ 7] = (this.h[3] >>> 8) & 0xff;\n mac[macpos+ 8] = (this.h[4] >>> 0) & 0xff;\n mac[macpos+ 9] = (this.h[4] >>> 8) & 0xff;\n mac[macpos+10] = (this.h[5] >>> 0) & 0xff;\n mac[macpos+11] = (this.h[5] >>> 8) & 0xff;\n mac[macpos+12] = (this.h[6] >>> 0) & 0xff;\n mac[macpos+13] = (this.h[6] >>> 8) & 0xff;\n mac[macpos+14] = (this.h[7] >>> 0) & 0xff;\n mac[macpos+15] = (this.h[7] >>> 8) & 0xff;\n};\n\npoly1305.prototype.update = function(m, mpos, bytes) {\n var i, want;\n\n if (this.leftover) {\n want = (16 - this.leftover);\n if (want > bytes)\n want = bytes;\n for (i = 0; i < want; i++)\n this.buffer[this.leftover + i] = m[mpos+i];\n bytes -= want;\n mpos += want;\n this.leftover += want;\n if (this.leftover < 16)\n return;\n this.blocks(this.buffer, 0, 16);\n this.leftover = 0;\n }\n\n if (bytes >= 16) {\n want = bytes - (bytes % 16);\n this.blocks(m, mpos, want);\n mpos += want;\n bytes -= want;\n }\n\n if (bytes) {\n for (i = 0; i < bytes; i++)\n this.buffer[this.leftover + i] = m[mpos+i];\n this.leftover += bytes;\n }\n};\n\nfunction crypto_onetimeauth(out, outpos, m, mpos, n, k) {\n var s = new poly1305(k);\n s.update(m, mpos, n);\n s.finish(out, outpos);\n return 0;\n}\n\nfunction crypto_onetimeauth_verify(h, hpos, m, mpos, n, k) {\n var x = new Uint8Array(16);\n crypto_onetimeauth(x,0,m,mpos,n,k);\n return crypto_verify_16(h,hpos,x,0);\n}\n\nfunction crypto_secretbox(c,m,d,n,k) {\n var i;\n if (d < 32) return -1;\n crypto_stream_xor(c,0,m,0,d,n,k);\n crypto_onetimeauth(c, 16, c, 32, d - 32, c);\n for (i = 0; i < 16; i++) c[i] = 0;\n return 0;\n}\n\nfunction crypto_secretbox_open(m,c,d,n,k) {\n var i;\n var x = new Uint8Array(32);\n if (d < 32) return -1;\n crypto_stream(x,0,32,n,k);\n if (crypto_onetimeauth_verify(c, 16,c, 32,d - 32,x) !== 0) return -1;\n crypto_stream_xor(m,0,c,0,d,n,k);\n for (i = 0; i < 32; i++) m[i] = 0;\n return 0;\n}\n\nfunction set25519(r, a) {\n var i;\n for (i = 0; i < 16; i++) r[i] = a[i]|0;\n}\n\nfunction car25519(o) {\n var i, v, c = 1;\n for (i = 0; i < 16; i++) {\n v = o[i] + c + 65535;\n c = Math.floor(v / 65536);\n o[i] = v - c * 65536;\n }\n o[0] += c-1 + 37 * (c-1);\n}\n\nfunction sel25519(p, q, b) {\n var t, c = ~(b-1);\n for (var i = 0; i < 16; i++) {\n t = c & (p[i] ^ q[i]);\n p[i] ^= t;\n q[i] ^= t;\n }\n}\n\nfunction pack25519(o, n) {\n var i, j, b;\n var m = gf(), t = gf();\n for (i = 0; i < 16; i++) t[i] = n[i];\n car25519(t);\n car25519(t);\n car25519(t);\n for (j = 0; j < 2; j++) {\n m[0] = t[0] - 0xffed;\n for (i = 1; i < 15; i++) {\n m[i] = t[i] - 0xffff - ((m[i-1]>>16) & 1);\n m[i-1] &= 0xffff;\n }\n m[15] = t[15] - 0x7fff - ((m[14]>>16) & 1);\n b = (m[15]>>16) & 1;\n m[14] &= 0xffff;\n sel25519(t, m, 1-b);\n }\n for (i = 0; i < 16; i++) {\n o[2*i] = t[i] & 0xff;\n o[2*i+1] = t[i]>>8;\n }\n}\n\nfunction neq25519(a, b) {\n var c = new Uint8Array(32), d = new Uint8Array(32);\n pack25519(c, a);\n pack25519(d, b);\n return crypto_verify_32(c, 0, d, 0);\n}\n\nfunction par25519(a) {\n var d = new Uint8Array(32);\n pack25519(d, a);\n return d[0] & 1;\n}\n\nfunction unpack25519(o, n) {\n var i;\n for (i = 0; i < 16; i++) o[i] = n[2*i] + (n[2*i+1] << 8);\n o[15] &= 0x7fff;\n}\n\nfunction A(o, a, b) {\n for (var i = 0; i < 16; i++) o[i] = a[i] + b[i];\n}\n\nfunction Z(o, a, b) {\n for (var i = 0; i < 16; i++) o[i] = a[i] - b[i];\n}\n\nfunction M(o, a, b) {\n var v, c,\n t0 = 0, t1 = 0, t2 = 0, t3 = 0, t4 = 0, t5 = 0, t6 = 0, t7 = 0,\n t8 = 0, t9 = 0, t10 = 0, t11 = 0, t12 = 0, t13 = 0, t14 = 0, t15 = 0,\n t16 = 0, t17 = 0, t18 = 0, t19 = 0, t20 = 0, t21 = 0, t22 = 0, t23 = 0,\n t24 = 0, t25 = 0, t26 = 0, t27 = 0, t28 = 0, t29 = 0, t30 = 0,\n b0 = b[0],\n b1 = b[1],\n b2 = b[2],\n b3 = b[3],\n b4 = b[4],\n b5 = b[5],\n b6 = b[6],\n b7 = b[7],\n b8 = b[8],\n b9 = b[9],\n b10 = b[10],\n b11 = b[11],\n b12 = b[12],\n b13 = b[13],\n b14 = b[14],\n b15 = b[15];\n\n v = a[0];\n t0 += v * b0;\n t1 += v * b1;\n t2 += v * b2;\n t3 += v * b3;\n t4 += v * b4;\n t5 += v * b5;\n t6 += v * b6;\n t7 += v * b7;\n t8 += v * b8;\n t9 += v * b9;\n t10 += v * b10;\n t11 += v * b11;\n t12 += v * b12;\n t13 += v * b13;\n t14 += v * b14;\n t15 += v * b15;\n v = a[1];\n t1 += v * b0;\n t2 += v * b1;\n t3 += v * b2;\n t4 += v * b3;\n t5 += v * b4;\n t6 += v * b5;\n t7 += v * b6;\n t8 += v * b7;\n t9 += v * b8;\n t10 += v * b9;\n t11 += v * b10;\n t12 += v * b11;\n t13 += v * b12;\n t14 += v * b13;\n t15 += v * b14;\n t16 += v * b15;\n v = a[2];\n t2 += v * b0;\n t3 += v * b1;\n t4 += v * b2;\n t5 += v * b3;\n t6 += v * b4;\n t7 += v * b5;\n t8 += v * b6;\n t9 += v * b7;\n t10 += v * b8;\n t11 += v * b9;\n t12 += v * b10;\n t13 += v * b11;\n t14 += v * b12;\n t15 += v * b13;\n t16 += v * b14;\n t17 += v * b15;\n v = a[3];\n t3 += v * b0;\n t4 += v * b1;\n t5 += v * b2;\n t6 += v * b3;\n t7 += v * b4;\n t8 += v * b5;\n t9 += v * b6;\n t10 += v * b7;\n t11 += v * b8;\n t12 += v * b9;\n t13 += v * b10;\n t14 += v * b11;\n t15 += v * b12;\n t16 += v * b13;\n t17 += v * b14;\n t18 += v * b15;\n v = a[4];\n t4 += v * b0;\n t5 += v * b1;\n t6 += v * b2;\n t7 += v * b3;\n t8 += v * b4;\n t9 += v * b5;\n t10 += v * b6;\n t11 += v * b7;\n t12 += v * b8;\n t13 += v * b9;\n t14 += v * b10;\n t15 += v * b11;\n t16 += v * b12;\n t17 += v * b13;\n t18 += v * b14;\n t19 += v * b15;\n v = a[5];\n t5 += v * b0;\n t6 += v * b1;\n t7 += v * b2;\n t8 += v * b3;\n t9 += v * b4;\n t10 += v * b5;\n t11 += v * b6;\n t12 += v * b7;\n t13 += v * b8;\n t14 += v * b9;\n t15 += v * b10;\n t16 += v * b11;\n t17 += v * b12;\n t18 += v * b13;\n t19 += v * b14;\n t20 += v * b15;\n v = a[6];\n t6 += v * b0;\n t7 += v * b1;\n t8 += v * b2;\n t9 += v * b3;\n t10 += v * b4;\n t11 += v * b5;\n t12 += v * b6;\n t13 += v * b7;\n t14 += v * b8;\n t15 += v * b9;\n t16 += v * b10;\n t17 += v * b11;\n t18 += v * b12;\n t19 += v * b13;\n t20 += v * b14;\n t21 += v * b15;\n v = a[7];\n t7 += v * b0;\n t8 += v * b1;\n t9 += v * b2;\n t10 += v * b3;\n t11 += v * b4;\n t12 += v * b5;\n t13 += v * b6;\n t14 += v * b7;\n t15 += v * b8;\n t16 += v * b9;\n t17 += v * b10;\n t18 += v * b11;\n t19 += v * b12;\n t20 += v * b13;\n t21 += v * b14;\n t22 += v * b15;\n v = a[8];\n t8 += v * b0;\n t9 += v * b1;\n t10 += v * b2;\n t11 += v * b3;\n t12 += v * b4;\n t13 += v * b5;\n t14 += v * b6;\n t15 += v * b7;\n t16 += v * b8;\n t17 += v * b9;\n t18 += v * b10;\n t19 += v * b11;\n t20 += v * b12;\n t21 += v * b13;\n t22 += v * b14;\n t23 += v * b15;\n v = a[9];\n t9 += v * b0;\n t10 += v * b1;\n t11 += v * b2;\n t12 += v * b3;\n t13 += v * b4;\n t14 += v * b5;\n t15 += v * b6;\n t16 += v * b7;\n t17 += v * b8;\n t18 += v * b9;\n t19 += v * b10;\n t20 += v * b11;\n t21 += v * b12;\n t22 += v * b13;\n t23 += v * b14;\n t24 += v * b15;\n v = a[10];\n t10 += v * b0;\n t11 += v * b1;\n t12 += v * b2;\n t13 += v * b3;\n t14 += v * b4;\n t15 += v * b5;\n t16 += v * b6;\n t17 += v * b7;\n t18 += v * b8;\n t19 += v * b9;\n t20 += v * b10;\n t21 += v * b11;\n t22 += v * b12;\n t23 += v * b13;\n t24 += v * b14;\n t25 += v * b15;\n v = a[11];\n t11 += v * b0;\n t12 += v * b1;\n t13 += v * b2;\n t14 += v * b3;\n t15 += v * b4;\n t16 += v * b5;\n t17 += v * b6;\n t18 += v * b7;\n t19 += v * b8;\n t20 += v * b9;\n t21 += v * b10;\n t22 += v * b11;\n t23 += v * b12;\n t24 += v * b13;\n t25 += v * b14;\n t26 += v * b15;\n v = a[12];\n t12 += v * b0;\n t13 += v * b1;\n t14 += v * b2;\n t15 += v * b3;\n t16 += v * b4;\n t17 += v * b5;\n t18 += v * b6;\n t19 += v * b7;\n t20 += v * b8;\n t21 += v * b9;\n t22 += v * b10;\n t23 += v * b11;\n t24 += v * b12;\n t25 += v * b13;\n t26 += v * b14;\n t27 += v * b15;\n v = a[13];\n t13 += v * b0;\n t14 += v * b1;\n t15 += v * b2;\n t16 += v * b3;\n t17 += v * b4;\n t18 += v * b5;\n t19 += v * b6;\n t20 += v * b7;\n t21 += v * b8;\n t22 += v * b9;\n t23 += v * b10;\n t24 += v * b11;\n t25 += v * b12;\n t26 += v * b13;\n t27 += v * b14;\n t28 += v * b15;\n v = a[14];\n t14 += v * b0;\n t15 += v * b1;\n t16 += v * b2;\n t17 += v * b3;\n t18 += v * b4;\n t19 += v * b5;\n t20 += v * b6;\n t21 += v * b7;\n t22 += v * b8;\n t23 += v * b9;\n t24 += v * b10;\n t25 += v * b11;\n t26 += v * b12;\n t27 += v * b13;\n t28 += v * b14;\n t29 += v * b15;\n v = a[15];\n t15 += v * b0;\n t16 += v * b1;\n t17 += v * b2;\n t18 += v * b3;\n t19 += v * b4;\n t20 += v * b5;\n t21 += v * b6;\n t22 += v * b7;\n t23 += v * b8;\n t24 += v * b9;\n t25 += v * b10;\n t26 += v * b11;\n t27 += v * b12;\n t28 += v * b13;\n t29 += v * b14;\n t30 += v * b15;\n\n t0 += 38 * t16;\n t1 += 38 * t17;\n t2 += 38 * t18;\n t3 += 38 * t19;\n t4 += 38 * t20;\n t5 += 38 * t21;\n t6 += 38 * t22;\n t7 += 38 * t23;\n t8 += 38 * t24;\n t9 += 38 * t25;\n t10 += 38 * t26;\n t11 += 38 * t27;\n t12 += 38 * t28;\n t13 += 38 * t29;\n t14 += 38 * t30;\n // t15 left as is\n\n // first car\n c = 1;\n v = t0 + c + 65535; c = Math.floor(v / 65536); t0 = v - c * 65536;\n v = t1 + c + 65535; c = Math.floor(v / 65536); t1 = v - c * 65536;\n v = t2 + c + 65535; c = Math.floor(v / 65536); t2 = v - c * 65536;\n v = t3 + c + 65535; c = Math.floor(v / 65536); t3 = v - c * 65536;\n v = t4 + c + 65535; c = Math.floor(v / 65536); t4 = v - c * 65536;\n v = t5 + c + 65535; c = Math.floor(v / 65536); t5 = v - c * 65536;\n v = t6 + c + 65535; c = Math.floor(v / 65536); t6 = v - c * 65536;\n v = t7 + c + 65535; c = Math.floor(v / 65536); t7 = v - c * 65536;\n v = t8 + c + 65535; c = Math.floor(v / 65536); t8 = v - c * 65536;\n v = t9 + c + 65535; c = Math.floor(v / 65536); t9 = v - c * 65536;\n v = t10 + c + 65535; c = Math.floor(v / 65536); t10 = v - c * 65536;\n v = t11 + c + 65535; c = Math.floor(v / 65536); t11 = v - c * 65536;\n v = t12 + c + 65535; c = Math.floor(v / 65536); t12 = v - c * 65536;\n v = t13 + c + 65535; c = Math.floor(v / 65536); t13 = v - c * 65536;\n v = t14 + c + 65535; c = Math.floor(v / 65536); t14 = v - c * 65536;\n v = t15 + c + 65535; c = Math.floor(v / 65536); t15 = v - c * 65536;\n t0 += c-1 + 37 * (c-1);\n\n // second car\n c = 1;\n v = t0 + c + 65535; c = Math.floor(v / 65536); t0 = v - c * 65536;\n v = t1 + c + 65535; c = Math.floor(v / 65536); t1 = v - c * 65536;\n v = t2 + c + 65535; c = Math.floor(v / 65536); t2 = v - c * 65536;\n v = t3 + c + 65535; c = Math.floor(v / 65536); t3 = v - c * 65536;\n v = t4 + c + 65535; c = Math.floor(v / 65536); t4 = v - c * 65536;\n v = t5 + c + 65535; c = Math.floor(v / 65536); t5 = v - c * 65536;\n v = t6 + c + 65535; c = Math.floor(v / 65536); t6 = v - c * 65536;\n v = t7 + c + 65535; c = Math.floor(v / 65536); t7 = v - c * 65536;\n v = t8 + c + 65535; c = Math.floor(v / 65536); t8 = v - c * 65536;\n v = t9 + c + 65535; c = Math.floor(v / 65536); t9 = v - c * 65536;\n v = t10 + c + 65535; c = Math.floor(v / 65536); t10 = v - c * 65536;\n v = t11 + c + 65535; c = Math.floor(v / 65536); t11 = v - c * 65536;\n v = t12 + c + 65535; c = Math.floor(v / 65536); t12 = v - c * 65536;\n v = t13 + c + 65535; c = Math.floor(v / 65536); t13 = v - c * 65536;\n v = t14 + c + 65535; c = Math.floor(v / 65536); t14 = v - c * 65536;\n v = t15 + c + 65535; c = Math.floor(v / 65536); t15 = v - c * 65536;\n t0 += c-1 + 37 * (c-1);\n\n o[ 0] = t0;\n o[ 1] = t1;\n o[ 2] = t2;\n o[ 3] = t3;\n o[ 4] = t4;\n o[ 5] = t5;\n o[ 6] = t6;\n o[ 7] = t7;\n o[ 8] = t8;\n o[ 9] = t9;\n o[10] = t10;\n o[11] = t11;\n o[12] = t12;\n o[13] = t13;\n o[14] = t14;\n o[15] = t15;\n}\n\nfunction S(o, a) {\n M(o, a, a);\n}\n\nfunction inv25519(o, i) {\n var c = gf();\n var a;\n for (a = 0; a < 16; a++) c[a] = i[a];\n for (a = 253; a >= 0; a--) {\n S(c, c);\n if(a !== 2 && a !== 4) M(c, c, i);\n }\n for (a = 0; a < 16; a++) o[a] = c[a];\n}\n\nfunction pow2523(o, i) {\n var c = gf();\n var a;\n for (a = 0; a < 16; a++) c[a] = i[a];\n for (a = 250; a >= 0; a--) {\n S(c, c);\n if(a !== 1) M(c, c, i);\n }\n for (a = 0; a < 16; a++) o[a] = c[a];\n}\n\nfunction crypto_scalarmult(q, n, p) {\n var z = new Uint8Array(32);\n var x = new Float64Array(80), r, i;\n var a = gf(), b = gf(), c = gf(),\n d = gf(), e = gf(), f = gf();\n for (i = 0; i < 31; i++) z[i] = n[i];\n z[31]=(n[31]&127)|64;\n z[0]&=248;\n unpack25519(x,p);\n for (i = 0; i < 16; i++) {\n b[i]=x[i];\n d[i]=a[i]=c[i]=0;\n }\n a[0]=d[0]=1;\n for (i=254; i>=0; --i) {\n r=(z[i>>>3]>>>(i&7))&1;\n sel25519(a,b,r);\n sel25519(c,d,r);\n A(e,a,c);\n Z(a,a,c);\n A(c,b,d);\n Z(b,b,d);\n S(d,e);\n S(f,a);\n M(a,c,a);\n M(c,b,e);\n A(e,a,c);\n Z(a,a,c);\n S(b,a);\n Z(c,d,f);\n M(a,c,_121665);\n A(a,a,d);\n M(c,c,a);\n M(a,d,f);\n M(d,b,x);\n S(b,e);\n sel25519(a,b,r);\n sel25519(c,d,r);\n }\n for (i = 0; i < 16; i++) {\n x[i+16]=a[i];\n x[i+32]=c[i];\n x[i+48]=b[i];\n x[i+64]=d[i];\n }\n var x32 = x.subarray(32);\n var x16 = x.subarray(16);\n inv25519(x32,x32);\n M(x16,x16,x32);\n pack25519(q,x16);\n return 0;\n}\n\nfunction crypto_scalarmult_base(q, n) {\n return crypto_scalarmult(q, n, _9);\n}\n\nfunction crypto_box_keypair(y, x) {\n randombytes(x, 32);\n return crypto_scalarmult_base(y, x);\n}\n\nfunction crypto_box_beforenm(k, y, x) {\n var s = new Uint8Array(32);\n crypto_scalarmult(s, x, y);\n return crypto_core_hsalsa20(k, _0, s, sigma);\n}\n\nvar crypto_box_afternm = crypto_secretbox;\nvar crypto_box_open_afternm = crypto_secretbox_open;\n\nfunction crypto_box(c, m, d, n, y, x) {\n var k = new Uint8Array(32);\n crypto_box_beforenm(k, y, x);\n return crypto_box_afternm(c, m, d, n, k);\n}\n\nfunction crypto_box_open(m, c, d, n, y, x) {\n var k = new Uint8Array(32);\n crypto_box_beforenm(k, y, x);\n return crypto_box_open_afternm(m, c, d, n, k);\n}\n\nvar K = [\n 0x428a2f98, 0xd728ae22, 0x71374491, 0x23ef65cd,\n 0xb5c0fbcf, 0xec4d3b2f, 0xe9b5dba5, 0x8189dbbc,\n 0x3956c25b, 0xf348b538, 0x59f111f1, 0xb605d019,\n 0x923f82a4, 0xaf194f9b, 0xab1c5ed5, 0xda6d8118,\n 0xd807aa98, 0xa3030242, 0x12835b01, 0x45706fbe,\n 0x243185be, 0x4ee4b28c, 0x550c7dc3, 0xd5ffb4e2,\n 0x72be5d74, 0xf27b896f, 0x80deb1fe, 0x3b1696b1,\n 0x9bdc06a7, 0x25c71235, 0xc19bf174, 0xcf692694,\n 0xe49b69c1, 0x9ef14ad2, 0xefbe4786, 0x384f25e3,\n 0x0fc19dc6, 0x8b8cd5b5, 0x240ca1cc, 0x77ac9c65,\n 0x2de92c6f, 0x592b0275, 0x4a7484aa, 0x6ea6e483,\n 0x5cb0a9dc, 0xbd41fbd4, 0x76f988da, 0x831153b5,\n 0x983e5152, 0xee66dfab, 0xa831c66d, 0x2db43210,\n 0xb00327c8, 0x98fb213f, 0xbf597fc7, 0xbeef0ee4,\n 0xc6e00bf3, 0x3da88fc2, 0xd5a79147, 0x930aa725,\n 0x06ca6351, 0xe003826f, 0x14292967, 0x0a0e6e70,\n 0x27b70a85, 0x46d22ffc, 0x2e1b2138, 0x5c26c926,\n 0x4d2c6dfc, 0x5ac42aed, 0x53380d13, 0x9d95b3df,\n 0x650a7354, 0x8baf63de, 0x766a0abb, 0x3c77b2a8,\n 0x81c2c92e, 0x47edaee6, 0x92722c85, 0x1482353b,\n 0xa2bfe8a1, 0x4cf10364, 0xa81a664b, 0xbc423001,\n 0xc24b8b70, 0xd0f89791, 0xc76c51a3, 0x0654be30,\n 0xd192e819, 0xd6ef5218, 0xd6990624, 0x5565a910,\n 0xf40e3585, 0x5771202a, 0x106aa070, 0x32bbd1b8,\n 0x19a4c116, 0xb8d2d0c8, 0x1e376c08, 0x5141ab53,\n 0x2748774c, 0xdf8eeb99, 0x34b0bcb5, 0xe19b48a8,\n 0x391c0cb3, 0xc5c95a63, 0x4ed8aa4a, 0xe3418acb,\n 0x5b9cca4f, 0x7763e373, 0x682e6ff3, 0xd6b2b8a3,\n 0x748f82ee, 0x5defb2fc, 0x78a5636f, 0x43172f60,\n 0x84c87814, 0xa1f0ab72, 0x8cc70208, 0x1a6439ec,\n 0x90befffa, 0x23631e28, 0xa4506ceb, 0xde82bde9,\n 0xbef9a3f7, 0xb2c67915, 0xc67178f2, 0xe372532b,\n 0xca273ece, 0xea26619c, 0xd186b8c7, 0x21c0c207,\n 0xeada7dd6, 0xcde0eb1e, 0xf57d4f7f, 0xee6ed178,\n 0x06f067aa, 0x72176fba, 0x0a637dc5, 0xa2c898a6,\n 0x113f9804, 0xbef90dae, 0x1b710b35, 0x131c471b,\n 0x28db77f5, 0x23047d84, 0x32caab7b, 0x40c72493,\n 0x3c9ebe0a, 0x15c9bebc, 0x431d67c4, 0x9c100d4c,\n 0x4cc5d4be, 0xcb3e42b6, 0x597f299c, 0xfc657e2a,\n 0x5fcb6fab, 0x3ad6faec, 0x6c44198c, 0x4a475817\n];\n\nfunction crypto_hashblocks_hl(hh, hl, m, n) {\n var wh = new Int32Array(16), wl = new Int32Array(16),\n bh0, bh1, bh2, bh3, bh4, bh5, bh6, bh7,\n bl0, bl1, bl2, bl3, bl4, bl5, bl6, bl7,\n th, tl, i, j, h, l, a, b, c, d;\n\n var ah0 = hh[0],\n ah1 = hh[1],\n ah2 = hh[2],\n ah3 = hh[3],\n ah4 = hh[4],\n ah5 = hh[5],\n ah6 = hh[6],\n ah7 = hh[7],\n\n al0 = hl[0],\n al1 = hl[1],\n al2 = hl[2],\n al3 = hl[3],\n al4 = hl[4],\n al5 = hl[5],\n al6 = hl[6],\n al7 = hl[7];\n\n var pos = 0;\n while (n >= 128) {\n for (i = 0; i < 16; i++) {\n j = 8 * i + pos;\n wh[i] = (m[j+0] << 24) | (m[j+1] << 16) | (m[j+2] << 8) | m[j+3];\n wl[i] = (m[j+4] << 24) | (m[j+5] << 16) | (m[j+6] << 8) | m[j+7];\n }\n for (i = 0; i < 80; i++) {\n bh0 = ah0;\n bh1 = ah1;\n bh2 = ah2;\n bh3 = ah3;\n bh4 = ah4;\n bh5 = ah5;\n bh6 = ah6;\n bh7 = ah7;\n\n bl0 = al0;\n bl1 = al1;\n bl2 = al2;\n bl3 = al3;\n bl4 = al4;\n bl5 = al5;\n bl6 = al6;\n bl7 = al7;\n\n // add\n h = ah7;\n l = al7;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n // Sigma1\n h = ((ah4 >>> 14) | (al4 << (32-14))) ^ ((ah4 >>> 18) | (al4 << (32-18))) ^ ((al4 >>> (41-32)) | (ah4 << (32-(41-32))));\n l = ((al4 >>> 14) | (ah4 << (32-14))) ^ ((al4 >>> 18) | (ah4 << (32-18))) ^ ((ah4 >>> (41-32)) | (al4 << (32-(41-32))));\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // Ch\n h = (ah4 & ah5) ^ (~ah4 & ah6);\n l = (al4 & al5) ^ (~al4 & al6);\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // K\n h = K[i*2];\n l = K[i*2+1];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // w\n h = wh[i%16];\n l = wl[i%16];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n th = c & 0xffff | d << 16;\n tl = a & 0xffff | b << 16;\n\n // add\n h = th;\n l = tl;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n // Sigma0\n h = ((ah0 >>> 28) | (al0 << (32-28))) ^ ((al0 >>> (34-32)) | (ah0 << (32-(34-32)))) ^ ((al0 >>> (39-32)) | (ah0 << (32-(39-32))));\n l = ((al0 >>> 28) | (ah0 << (32-28))) ^ ((ah0 >>> (34-32)) | (al0 << (32-(34-32)))) ^ ((ah0 >>> (39-32)) | (al0 << (32-(39-32))));\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // Maj\n h = (ah0 & ah1) ^ (ah0 & ah2) ^ (ah1 & ah2);\n l = (al0 & al1) ^ (al0 & al2) ^ (al1 & al2);\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n bh7 = (c & 0xffff) | (d << 16);\n bl7 = (a & 0xffff) | (b << 16);\n\n // add\n h = bh3;\n l = bl3;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = th;\n l = tl;\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n bh3 = (c & 0xffff) | (d << 16);\n bl3 = (a & 0xffff) | (b << 16);\n\n ah1 = bh0;\n ah2 = bh1;\n ah3 = bh2;\n ah4 = bh3;\n ah5 = bh4;\n ah6 = bh5;\n ah7 = bh6;\n ah0 = bh7;\n\n al1 = bl0;\n al2 = bl1;\n al3 = bl2;\n al4 = bl3;\n al5 = bl4;\n al6 = bl5;\n al7 = bl6;\n al0 = bl7;\n\n if (i%16 === 15) {\n for (j = 0; j < 16; j++) {\n // add\n h = wh[j];\n l = wl[j];\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = wh[(j+9)%16];\n l = wl[(j+9)%16];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // sigma0\n th = wh[(j+1)%16];\n tl = wl[(j+1)%16];\n h = ((th >>> 1) | (tl << (32-1))) ^ ((th >>> 8) | (tl << (32-8))) ^ (th >>> 7);\n l = ((tl >>> 1) | (th << (32-1))) ^ ((tl >>> 8) | (th << (32-8))) ^ ((tl >>> 7) | (th << (32-7)));\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // sigma1\n th = wh[(j+14)%16];\n tl = wl[(j+14)%16];\n h = ((th >>> 19) | (tl << (32-19))) ^ ((tl >>> (61-32)) | (th << (32-(61-32)))) ^ (th >>> 6);\n l = ((tl >>> 19) | (th << (32-19))) ^ ((th >>> (61-32)) | (tl << (32-(61-32)))) ^ ((tl >>> 6) | (th << (32-6)));\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n wh[j] = (c & 0xffff) | (d << 16);\n wl[j] = (a & 0xffff) | (b << 16);\n }\n }\n }\n\n // add\n h = ah0;\n l = al0;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[0];\n l = hl[0];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[0] = ah0 = (c & 0xffff) | (d << 16);\n hl[0] = al0 = (a & 0xffff) | (b << 16);\n\n h = ah1;\n l = al1;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[1];\n l = hl[1];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[1] = ah1 = (c & 0xffff) | (d << 16);\n hl[1] = al1 = (a & 0xffff) | (b << 16);\n\n h = ah2;\n l = al2;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[2];\n l = hl[2];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[2] = ah2 = (c & 0xffff) | (d << 16);\n hl[2] = al2 = (a & 0xffff) | (b << 16);\n\n h = ah3;\n l = al3;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[3];\n l = hl[3];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[3] = ah3 = (c & 0xffff) | (d << 16);\n hl[3] = al3 = (a & 0xffff) | (b << 16);\n\n h = ah4;\n l = al4;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[4];\n l = hl[4];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[4] = ah4 = (c & 0xffff) | (d << 16);\n hl[4] = al4 = (a & 0xffff) | (b << 16);\n\n h = ah5;\n l = al5;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[5];\n l = hl[5];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[5] = ah5 = (c & 0xffff) | (d << 16);\n hl[5] = al5 = (a & 0xffff) | (b << 16);\n\n h = ah6;\n l = al6;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[6];\n l = hl[6];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[6] = ah6 = (c & 0xffff) | (d << 16);\n hl[6] = al6 = (a & 0xffff) | (b << 16);\n\n h = ah7;\n l = al7;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[7];\n l = hl[7];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[7] = ah7 = (c & 0xffff) | (d << 16);\n hl[7] = al7 = (a & 0xffff) | (b << 16);\n\n pos += 128;\n n -= 128;\n }\n\n return n;\n}\n\nfunction crypto_hash(out, m, n) {\n var hh = new Int32Array(8),\n hl = new Int32Array(8),\n x = new Uint8Array(256),\n i, b = n;\n\n hh[0] = 0x6a09e667;\n hh[1] = 0xbb67ae85;\n hh[2] = 0x3c6ef372;\n hh[3] = 0xa54ff53a;\n hh[4] = 0x510e527f;\n hh[5] = 0x9b05688c;\n hh[6] = 0x1f83d9ab;\n hh[7] = 0x5be0cd19;\n\n hl[0] = 0xf3bcc908;\n hl[1] = 0x84caa73b;\n hl[2] = 0xfe94f82b;\n hl[3] = 0x5f1d36f1;\n hl[4] = 0xade682d1;\n hl[5] = 0x2b3e6c1f;\n hl[6] = 0xfb41bd6b;\n hl[7] = 0x137e2179;\n\n crypto_hashblocks_hl(hh, hl, m, n);\n n %= 128;\n\n for (i = 0; i < n; i++) x[i] = m[b-n+i];\n x[n] = 128;\n\n n = 256-128*(n<112?1:0);\n x[n-9] = 0;\n ts64(x, n-8, (b / 0x20000000) | 0, b << 3);\n crypto_hashblocks_hl(hh, hl, x, n);\n\n for (i = 0; i < 8; i++) ts64(out, 8*i, hh[i], hl[i]);\n\n return 0;\n}\n\nfunction add(p, q) {\n var a = gf(), b = gf(), c = gf(),\n d = gf(), e = gf(), f = gf(),\n g = gf(), h = gf(), t = gf();\n\n Z(a, p[1], p[0]);\n Z(t, q[1], q[0]);\n M(a, a, t);\n A(b, p[0], p[1]);\n A(t, q[0], q[1]);\n M(b, b, t);\n M(c, p[3], q[3]);\n M(c, c, D2);\n M(d, p[2], q[2]);\n A(d, d, d);\n Z(e, b, a);\n Z(f, d, c);\n A(g, d, c);\n A(h, b, a);\n\n M(p[0], e, f);\n M(p[1], h, g);\n M(p[2], g, f);\n M(p[3], e, h);\n}\n\nfunction cswap(p, q, b) {\n var i;\n for (i = 0; i < 4; i++) {\n sel25519(p[i], q[i], b);\n }\n}\n\nfunction pack(r, p) {\n var tx = gf(), ty = gf(), zi = gf();\n inv25519(zi, p[2]);\n M(tx, p[0], zi);\n M(ty, p[1], zi);\n pack25519(r, ty);\n r[31] ^= par25519(tx) << 7;\n}\n\nfunction scalarmult(p, q, s) {\n var b, i;\n set25519(p[0], gf0);\n set25519(p[1], gf1);\n set25519(p[2], gf1);\n set25519(p[3], gf0);\n for (i = 255; i >= 0; --i) {\n b = (s[(i/8)|0] >> (i&7)) & 1;\n cswap(p, q, b);\n add(q, p);\n add(p, p);\n cswap(p, q, b);\n }\n}\n\nfunction scalarbase(p, s) {\n var q = [gf(), gf(), gf(), gf()];\n set25519(q[0], X);\n set25519(q[1], Y);\n set25519(q[2], gf1);\n M(q[3], X, Y);\n scalarmult(p, q, s);\n}\n\nfunction crypto_sign_keypair(pk, sk, seeded) {\n var d = new Uint8Array(64);\n var p = [gf(), gf(), gf(), gf()];\n var i;\n\n if (!seeded) randombytes(sk, 32);\n crypto_hash(d, sk, 32);\n d[0] &= 248;\n d[31] &= 127;\n d[31] |= 64;\n\n scalarbase(p, d);\n pack(pk, p);\n\n for (i = 0; i < 32; i++) sk[i+32] = pk[i];\n return 0;\n}\n\nvar L = new Float64Array([0xed, 0xd3, 0xf5, 0x5c, 0x1a, 0x63, 0x12, 0x58, 0xd6, 0x9c, 0xf7, 0xa2, 0xde, 0xf9, 0xde, 0x14, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x10]);\n\nfunction modL(r, x) {\n var carry, i, j, k;\n for (i = 63; i >= 32; --i) {\n carry = 0;\n for (j = i - 32, k = i - 12; j < k; ++j) {\n x[j] += carry - 16 * x[i] * L[j - (i - 32)];\n carry = Math.floor((x[j] + 128) / 256);\n x[j] -= carry * 256;\n }\n x[j] += carry;\n x[i] = 0;\n }\n carry = 0;\n for (j = 0; j < 32; j++) {\n x[j] += carry - (x[31] >> 4) * L[j];\n carry = x[j] >> 8;\n x[j] &= 255;\n }\n for (j = 0; j < 32; j++) x[j] -= carry * L[j];\n for (i = 0; i < 32; i++) {\n x[i+1] += x[i] >> 8;\n r[i] = x[i] & 255;\n }\n}\n\nfunction reduce(r) {\n var x = new Float64Array(64), i;\n for (i = 0; i < 64; i++) x[i] = r[i];\n for (i = 0; i < 64; i++) r[i] = 0;\n modL(r, x);\n}\n\n// Note: difference from C - smlen returned, not passed as argument.\nfunction crypto_sign(sm, m, n, sk) {\n var d = new Uint8Array(64), h = new Uint8Array(64), r = new Uint8Array(64);\n var i, j, x = new Float64Array(64);\n var p = [gf(), gf(), gf(), gf()];\n\n crypto_hash(d, sk, 32);\n d[0] &= 248;\n d[31] &= 127;\n d[31] |= 64;\n\n var smlen = n + 64;\n for (i = 0; i < n; i++) sm[64 + i] = m[i];\n for (i = 0; i < 32; i++) sm[32 + i] = d[32 + i];\n\n crypto_hash(r, sm.subarray(32), n+32);\n reduce(r);\n scalarbase(p, r);\n pack(sm, p);\n\n for (i = 32; i < 64; i++) sm[i] = sk[i];\n crypto_hash(h, sm, n + 64);\n reduce(h);\n\n for (i = 0; i < 64; i++) x[i] = 0;\n for (i = 0; i < 32; i++) x[i] = r[i];\n for (i = 0; i < 32; i++) {\n for (j = 0; j < 32; j++) {\n x[i+j] += h[i] * d[j];\n }\n }\n\n modL(sm.subarray(32), x);\n return smlen;\n}\n\nfunction unpackneg(r, p) {\n var t = gf(), chk = gf(), num = gf(),\n den = gf(), den2 = gf(), den4 = gf(),\n den6 = gf();\n\n set25519(r[2], gf1);\n unpack25519(r[1], p);\n S(num, r[1]);\n M(den, num, D);\n Z(num, num, r[2]);\n A(den, r[2], den);\n\n S(den2, den);\n S(den4, den2);\n M(den6, den4, den2);\n M(t, den6, num);\n M(t, t, den);\n\n pow2523(t, t);\n M(t, t, num);\n M(t, t, den);\n M(t, t, den);\n M(r[0], t, den);\n\n S(chk, r[0]);\n M(chk, chk, den);\n if (neq25519(chk, num)) M(r[0], r[0], I);\n\n S(chk, r[0]);\n M(chk, chk, den);\n if (neq25519(chk, num)) return -1;\n\n if (par25519(r[0]) === (p[31]>>7)) Z(r[0], gf0, r[0]);\n\n M(r[3], r[0], r[1]);\n return 0;\n}\n\nfunction crypto_sign_open(m, sm, n, pk) {\n var i;\n var t = new Uint8Array(32), h = new Uint8Array(64);\n var p = [gf(), gf(), gf(), gf()],\n q = [gf(), gf(), gf(), gf()];\n\n if (n < 64) return -1;\n\n if (unpackneg(q, pk)) return -1;\n\n for (i = 0; i < n; i++) m[i] = sm[i];\n for (i = 0; i < 32; i++) m[i+32] = pk[i];\n crypto_hash(h, m, n);\n reduce(h);\n scalarmult(p, q, h);\n\n scalarbase(q, sm.subarray(32));\n add(p, q);\n pack(t, p);\n\n n -= 64;\n if (crypto_verify_32(sm, 0, t, 0)) {\n for (i = 0; i < n; i++) m[i] = 0;\n return -1;\n }\n\n for (i = 0; i < n; i++) m[i] = sm[i + 64];\n return n;\n}\n\nvar crypto_secretbox_KEYBYTES = 32,\n crypto_secretbox_NONCEBYTES = 24,\n crypto_secretbox_ZEROBYTES = 32,\n crypto_secretbox_BOXZEROBYTES = 16,\n crypto_scalarmult_BYTES = 32,\n crypto_scalarmult_SCALARBYTES = 32,\n crypto_box_PUBLICKEYBYTES = 32,\n crypto_box_SECRETKEYBYTES = 32,\n crypto_box_BEFORENMBYTES = 32,\n crypto_box_NONCEBYTES = crypto_secretbox_NONCEBYTES,\n crypto_box_ZEROBYTES = crypto_secretbox_ZEROBYTES,\n crypto_box_BOXZEROBYTES = crypto_secretbox_BOXZEROBYTES,\n crypto_sign_BYTES = 64,\n crypto_sign_PUBLICKEYBYTES = 32,\n crypto_sign_SECRETKEYBYTES = 64,\n crypto_sign_SEEDBYTES = 32,\n crypto_hash_BYTES = 64;\n\nnacl.lowlevel = {\n crypto_core_hsalsa20: crypto_core_hsalsa20,\n crypto_stream_xor: crypto_stream_xor,\n crypto_stream: crypto_stream,\n crypto_stream_salsa20_xor: crypto_stream_salsa20_xor,\n crypto_stream_salsa20: crypto_stream_salsa20,\n crypto_onetimeauth: crypto_onetimeauth,\n crypto_onetimeauth_verify: crypto_onetimeauth_verify,\n crypto_verify_16: crypto_verify_16,\n crypto_verify_32: crypto_verify_32,\n crypto_secretbox: crypto_secretbox,\n crypto_secretbox_open: crypto_secretbox_open,\n crypto_scalarmult: crypto_scalarmult,\n crypto_scalarmult_base: crypto_scalarmult_base,\n crypto_box_beforenm: crypto_box_beforenm,\n crypto_box_afternm: crypto_box_afternm,\n crypto_box: crypto_box,\n crypto_box_open: crypto_box_open,\n crypto_box_keypair: crypto_box_keypair,\n crypto_hash: crypto_hash,\n crypto_sign: crypto_sign,\n crypto_sign_keypair: crypto_sign_keypair,\n crypto_sign_open: crypto_sign_open,\n\n crypto_secretbox_KEYBYTES: crypto_secretbox_KEYBYTES,\n crypto_secretbox_NONCEBYTES: crypto_secretbox_NONCEBYTES,\n crypto_secretbox_ZEROBYTES: crypto_secretbox_ZEROBYTES,\n crypto_secretbox_BOXZEROBYTES: crypto_secretbox_BOXZEROBYTES,\n crypto_scalarmult_BYTES: crypto_scalarmult_BYTES,\n crypto_scalarmult_SCALARBYTES: crypto_scalarmult_SCALARBYTES,\n crypto_box_PUBLICKEYBYTES: crypto_box_PUBLICKEYBYTES,\n crypto_box_SECRETKEYBYTES: crypto_box_SECRETKEYBYTES,\n crypto_box_BEFORENMBYTES: crypto_box_BEFORENMBYTES,\n crypto_box_NONCEBYTES: crypto_box_NONCEBYTES,\n crypto_box_ZEROBYTES: crypto_box_ZEROBYTES,\n crypto_box_BOXZEROBYTES: crypto_box_BOXZEROBYTES,\n crypto_sign_BYTES: crypto_sign_BYTES,\n crypto_sign_PUBLICKEYBYTES: crypto_sign_PUBLICKEYBYTES,\n crypto_sign_SECRETKEYBYTES: crypto_sign_SECRETKEYBYTES,\n crypto_sign_SEEDBYTES: crypto_sign_SEEDBYTES,\n crypto_hash_BYTES: crypto_hash_BYTES,\n\n gf: gf,\n D: D,\n L: L,\n pack25519: pack25519,\n unpack25519: unpack25519,\n M: M,\n A: A,\n S: S,\n Z: Z,\n pow2523: pow2523,\n add: add,\n set25519: set25519,\n modL: modL,\n scalarmult: scalarmult,\n scalarbase: scalarbase,\n};\n\n/* High-level API */\n\nfunction checkLengths(k, n) {\n if (k.length !== crypto_secretbox_KEYBYTES) throw new Error('bad key size');\n if (n.length !== crypto_secretbox_NONCEBYTES) throw new Error('bad nonce size');\n}\n\nfunction checkBoxLengths(pk, sk) {\n if (pk.length !== crypto_box_PUBLICKEYBYTES) throw new Error('bad public key size');\n if (sk.length !== crypto_box_SECRETKEYBYTES) throw new Error('bad secret key size');\n}\n\nfunction checkArrayTypes() {\n for (var i = 0; i < arguments.length; i++) {\n if (!(arguments[i] instanceof Uint8Array))\n throw new TypeError('unexpected type, use Uint8Array');\n }\n}\n\nfunction cleanup(arr) {\n for (var i = 0; i < arr.length; i++) arr[i] = 0;\n}\n\nnacl.randomBytes = function(n) {\n var b = new Uint8Array(n);\n randombytes(b, n);\n return b;\n};\n\nnacl.secretbox = function(msg, nonce, key) {\n checkArrayTypes(msg, nonce, key);\n checkLengths(key, nonce);\n var m = new Uint8Array(crypto_secretbox_ZEROBYTES + msg.length);\n var c = new Uint8Array(m.length);\n for (var i = 0; i < msg.length; i++) m[i+crypto_secretbox_ZEROBYTES] = msg[i];\n crypto_secretbox(c, m, m.length, nonce, key);\n return c.subarray(crypto_secretbox_BOXZEROBYTES);\n};\n\nnacl.secretbox.open = function(box, nonce, key) {\n checkArrayTypes(box, nonce, key);\n checkLengths(key, nonce);\n var c = new Uint8Array(crypto_secretbox_BOXZEROBYTES + box.length);\n var m = new Uint8Array(c.length);\n for (var i = 0; i < box.length; i++) c[i+crypto_secretbox_BOXZEROBYTES] = box[i];\n if (c.length < 32) return null;\n if (crypto_secretbox_open(m, c, c.length, nonce, key) !== 0) return null;\n return m.subarray(crypto_secretbox_ZEROBYTES);\n};\n\nnacl.secretbox.keyLength = crypto_secretbox_KEYBYTES;\nnacl.secretbox.nonceLength = crypto_secretbox_NONCEBYTES;\nnacl.secretbox.overheadLength = crypto_secretbox_BOXZEROBYTES;\n\nnacl.scalarMult = function(n, p) {\n checkArrayTypes(n, p);\n if (n.length !== crypto_scalarmult_SCALARBYTES) throw new Error('bad n size');\n if (p.length !== crypto_scalarmult_BYTES) throw new Error('bad p size');\n var q = new Uint8Array(crypto_scalarmult_BYTES);\n crypto_scalarmult(q, n, p);\n return q;\n};\n\nnacl.scalarMult.base = function(n) {\n checkArrayTypes(n);\n if (n.length !== crypto_scalarmult_SCALARBYTES) throw new Error('bad n size');\n var q = new Uint8Array(crypto_scalarmult_BYTES);\n crypto_scalarmult_base(q, n);\n return q;\n};\n\nnacl.scalarMult.scalarLength = crypto_scalarmult_SCALARBYTES;\nnacl.scalarMult.groupElementLength = crypto_scalarmult_BYTES;\n\nnacl.box = function(msg, nonce, publicKey, secretKey) {\n var k = nacl.box.before(publicKey, secretKey);\n return nacl.secretbox(msg, nonce, k);\n};\n\nnacl.box.before = function(publicKey, secretKey) {\n checkArrayTypes(publicKey, secretKey);\n checkBoxLengths(publicKey, secretKey);\n var k = new Uint8Array(crypto_box_BEFORENMBYTES);\n crypto_box_beforenm(k, publicKey, secretKey);\n return k;\n};\n\nnacl.box.after = nacl.secretbox;\n\nnacl.box.open = function(msg, nonce, publicKey, secretKey) {\n var k = nacl.box.before(publicKey, secretKey);\n return nacl.secretbox.open(msg, nonce, k);\n};\n\nnacl.box.open.after = nacl.secretbox.open;\n\nnacl.box.keyPair = function() {\n var pk = new Uint8Array(crypto_box_PUBLICKEYBYTES);\n var sk = new Uint8Array(crypto_box_SECRETKEYBYTES);\n crypto_box_keypair(pk, sk);\n return {publicKey: pk, secretKey: sk};\n};\n\nnacl.box.keyPair.fromSecretKey = function(secretKey) {\n checkArrayTypes(secretKey);\n if (secretKey.length !== crypto_box_SECRETKEYBYTES)\n throw new Error('bad secret key size');\n var pk = new Uint8Array(crypto_box_PUBLICKEYBYTES);\n crypto_scalarmult_base(pk, secretKey);\n return {publicKey: pk, secretKey: new Uint8Array(secretKey)};\n};\n\nnacl.box.publicKeyLength = crypto_box_PUBLICKEYBYTES;\nnacl.box.secretKeyLength = crypto_box_SECRETKEYBYTES;\nnacl.box.sharedKeyLength = crypto_box_BEFORENMBYTES;\nnacl.box.nonceLength = crypto_box_NONCEBYTES;\nnacl.box.overheadLength = nacl.secretbox.overheadLength;\n\nnacl.sign = function(msg, secretKey) {\n checkArrayTypes(msg, secretKey);\n if (secretKey.length !== crypto_sign_SECRETKEYBYTES)\n throw new Error('bad secret key size');\n var signedMsg = new Uint8Array(crypto_sign_BYTES+msg.length);\n crypto_sign(signedMsg, msg, msg.length, secretKey);\n return signedMsg;\n};\n\nnacl.sign.open = function(signedMsg, publicKey) {\n checkArrayTypes(signedMsg, publicKey);\n if (publicKey.length !== crypto_sign_PUBLICKEYBYTES)\n throw new Error('bad public key size');\n var tmp = new Uint8Array(signedMsg.length);\n var mlen = crypto_sign_open(tmp, signedMsg, signedMsg.length, publicKey);\n if (mlen < 0) return null;\n var m = new Uint8Array(mlen);\n for (var i = 0; i < m.length; i++) m[i] = tmp[i];\n return m;\n};\n\nnacl.sign.detached = function(msg, secretKey) {\n var signedMsg = nacl.sign(msg, secretKey);\n var sig = new Uint8Array(crypto_sign_BYTES);\n for (var i = 0; i < sig.length; i++) sig[i] = signedMsg[i];\n return sig;\n};\n\nnacl.sign.detached.verify = function(msg, sig, publicKey) {\n checkArrayTypes(msg, sig, publicKey);\n if (sig.length !== crypto_sign_BYTES)\n throw new Error('bad signature size');\n if (publicKey.length !== crypto_sign_PUBLICKEYBYTES)\n throw new Error('bad public key size');\n var sm = new Uint8Array(crypto_sign_BYTES + msg.length);\n var m = new Uint8Array(crypto_sign_BYTES + msg.length);\n var i;\n for (i = 0; i < crypto_sign_BYTES; i++) sm[i] = sig[i];\n for (i = 0; i < msg.length; i++) sm[i+crypto_sign_BYTES] = msg[i];\n return (crypto_sign_open(m, sm, sm.length, publicKey) >= 0);\n};\n\nnacl.sign.keyPair = function() {\n var pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);\n var sk = new Uint8Array(crypto_sign_SECRETKEYBYTES);\n crypto_sign_keypair(pk, sk);\n return {publicKey: pk, secretKey: sk};\n};\n\nnacl.sign.keyPair.fromSecretKey = function(secretKey) {\n checkArrayTypes(secretKey);\n if (secretKey.length !== crypto_sign_SECRETKEYBYTES)\n throw new Error('bad secret key size');\n var pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);\n for (var i = 0; i < pk.length; i++) pk[i] = secretKey[32+i];\n return {publicKey: pk, secretKey: new Uint8Array(secretKey)};\n};\n\nnacl.sign.keyPair.fromSeed = function(seed) {\n checkArrayTypes(seed);\n if (seed.length !== crypto_sign_SEEDBYTES)\n throw new Error('bad seed size');\n var pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);\n var sk = new Uint8Array(crypto_sign_SECRETKEYBYTES);\n for (var i = 0; i < 32; i++) sk[i] = seed[i];\n crypto_sign_keypair(pk, sk, true);\n return {publicKey: pk, secretKey: sk};\n};\n\nnacl.sign.publicKeyLength = crypto_sign_PUBLICKEYBYTES;\nnacl.sign.secretKeyLength = crypto_sign_SECRETKEYBYTES;\nnacl.sign.seedLength = crypto_sign_SEEDBYTES;\nnacl.sign.signatureLength = crypto_sign_BYTES;\n\nnacl.hash = function(msg) {\n checkArrayTypes(msg);\n var h = new Uint8Array(crypto_hash_BYTES);\n crypto_hash(h, msg, msg.length);\n return h;\n};\n\nnacl.hash.hashLength = crypto_hash_BYTES;\n\nnacl.verify = function(x, y) {\n checkArrayTypes(x, y);\n // Zero length arguments are considered not equal.\n if (x.length === 0 || y.length === 0) return false;\n if (x.length !== y.length) return false;\n return (vn(x, 0, y, 0, x.length) === 0) ? true : false;\n};\n\nnacl.setPRNG = function(fn) {\n randombytes = fn;\n};\n\n(function() {\n // Initialize PRNG if environment provides CSPRNG.\n // If not, methods calling randombytes will throw.\n var crypto = typeof self !== 'undefined' ? (self.crypto || self.msCrypto) : null;\n if (crypto && crypto.getRandomValues) {\n // Browsers.\n var QUOTA = 65536;\n nacl.setPRNG(function(x, n) {\n var i, v = new Uint8Array(n);\n for (i = 0; i < n; i += QUOTA) {\n crypto.getRandomValues(v.subarray(i, i + Math.min(n - i, QUOTA)));\n }\n for (i = 0; i < n; i++) x[i] = v[i];\n cleanup(v);\n });\n } else if (typeof require !== 'undefined') {\n // Node.js.\n crypto = require('crypto');\n if (crypto && crypto.randomBytes) {\n nacl.setPRNG(function(x, n) {\n var i, v = crypto.randomBytes(n);\n for (i = 0; i < n; i++) x[i] = v[i];\n cleanup(v);\n });\n }\n }\n})();\n\n})(typeof module !== 'undefined' && module.exports ? module.exports : (self.nacl = self.nacl || {}));\n","module.exports = require('./pusher-with-encryption').default;\n","module.exports = require(\"buffer\");","module.exports = require(\"events\");","'use strict';\n\n/**\n\nStreams in a WebSocket connection\n---------------------------------\n\nWe model a WebSocket as two duplex streams: one stream is for the wire protocol\nover an I/O socket, and the other is for incoming/outgoing messages.\n\n\n +----------+ +---------+ +----------+\n [1] write(chunk) -->| ~~~~~~~~ +----->| parse() +----->| ~~~~~~~~ +--> emit('data') [2]\n | | +----+----+ | |\n | | | | |\n | IO | | [5] | Messages |\n | | V | |\n | | +---------+ | |\n [4] emit('data') <--+ ~~~~~~~~ |<-----+ frame() |<-----+ ~~~~~~~~ |<-- write(chunk) [3]\n +----------+ +---------+ +----------+\n\n\nMessage transfer in each direction is simple: IO receives a byte stream [1] and\nsends this stream for parsing. The parser will periodically emit a complete\nmessage text on the Messages stream [2]. Similarly, when messages are written\nto the Messages stream [3], they are framed using the WebSocket wire format and\nemitted via IO [4].\n\nThere is a feedback loop via [5] since some input from [1] will be things like\nping, pong and close frames. In these cases the protocol responds by emitting\nresponses directly back to [4] rather than emitting messages via [2].\n\nFor the purposes of flow control, we consider the sources of each Readable\nstream to be as follows:\n\n* [2] receives input from [1]\n* [4] receives input from [1] and [3]\n\nThe classes below express the relationships described above without prescribing\nanything about how parse() and frame() work, other than assuming they emit\n'data' events to the IO and Messages streams. They will work with any protocol\ndriver having these two methods.\n**/\n\n\nvar Stream = require('stream').Stream,\n util = require('util');\n\n\nvar IO = function(driver) {\n this.readable = this.writable = true;\n this._paused = false;\n this._driver = driver;\n};\nutil.inherits(IO, Stream);\n\n// The IO pause() and resume() methods will be called when the socket we are\n// piping to gets backed up and drains. Since IO output [4] comes from IO input\n// [1] and Messages input [3], we need to tell both of those to return false\n// from write() when this stream is paused.\n\nIO.prototype.pause = function() {\n this._paused = true;\n this._driver.messages._paused = true;\n};\n\nIO.prototype.resume = function() {\n this._paused = false;\n this.emit('drain');\n\n var messages = this._driver.messages;\n messages._paused = false;\n messages.emit('drain');\n};\n\n// When we receive input from a socket, send it to the parser and tell the\n// source whether to back off.\nIO.prototype.write = function(chunk) {\n if (!this.writable) return false;\n this._driver.parse(chunk);\n return !this._paused;\n};\n\n// The IO end() method will be called when the socket piping into it emits\n// 'close' or 'end', i.e. the socket is closed. In this situation the Messages\n// stream will not emit any more data so we emit 'end'.\nIO.prototype.end = function(chunk) {\n if (!this.writable) return;\n if (chunk !== undefined) this.write(chunk);\n this.writable = false;\n\n var messages = this._driver.messages;\n if (messages.readable) {\n messages.readable = messages.writable = false;\n messages.emit('end');\n }\n};\n\nIO.prototype.destroy = function() {\n this.end();\n};\n\n\nvar Messages = function(driver) {\n this.readable = this.writable = true;\n this._paused = false;\n this._driver = driver;\n};\nutil.inherits(Messages, Stream);\n\n// The Messages pause() and resume() methods will be called when the app that's\n// processing the messages gets backed up and drains. If we're emitting\n// messages too fast we should tell the source to slow down. Message output [2]\n// comes from IO input [1].\n\nMessages.prototype.pause = function() {\n this._driver.io._paused = true;\n};\n\nMessages.prototype.resume = function() {\n this._driver.io._paused = false;\n this._driver.io.emit('drain');\n};\n\n// When we receive messages from the user, send them to the formatter and tell\n// the source whether to back off.\nMessages.prototype.write = function(message) {\n if (!this.writable) return false;\n if (typeof message === 'string') this._driver.text(message);\n else this._driver.binary(message);\n return !this._paused;\n};\n\n// The Messages end() method will be called when a stream piping into it emits\n// 'end'. Many streams may be piped into the WebSocket and one of them ending\n// does not mean the whole socket is done, so just process the input and move\n// on leaving the socket open.\nMessages.prototype.end = function(message) {\n if (message !== undefined) this.write(message);\n};\n\nMessages.prototype.destroy = function() {};\n\n\nexports.IO = IO;\nexports.Messages = Messages;\n","'use strict';\n\nvar Buffer = require('safe-buffer').Buffer;\n\nvar StreamReader = function() {\n this._queue = [];\n this._queueSize = 0;\n this._offset = 0;\n};\n\nStreamReader.prototype.put = function(buffer) {\n if (!buffer || buffer.length === 0) return;\n if (!Buffer.isBuffer(buffer)) buffer = Buffer.from(buffer);\n this._queue.push(buffer);\n this._queueSize += buffer.length;\n};\n\nStreamReader.prototype.read = function(length) {\n if (length > this._queueSize) return null;\n if (length === 0) return Buffer.alloc(0);\n\n this._queueSize -= length;\n\n var queue = this._queue,\n remain = length,\n first = queue[0],\n buffers, buffer;\n\n if (first.length >= length) {\n if (first.length === length) {\n return queue.shift();\n } else {\n buffer = first.slice(0, length);\n queue[0] = first.slice(length);\n return buffer;\n }\n }\n\n for (var i = 0, n = queue.length; i < n; i++) {\n if (remain < queue[i].length) break;\n remain -= queue[i].length;\n }\n buffers = queue.splice(0, i);\n\n if (remain > 0 && queue.length > 0) {\n buffers.push(queue[0].slice(0, remain));\n queue[0] = queue[0].slice(remain);\n }\n return Buffer.concat(buffers, length);\n};\n\nStreamReader.prototype.eachByte = function(callback, context) {\n var buffer, n, index;\n\n while (this._queue.length > 0) {\n buffer = this._queue[0];\n n = buffer.length;\n\n while (this._offset < n) {\n index = this._offset;\n this._offset += 1;\n callback.call(context, buffer[index]);\n }\n this._offset = 0;\n this._queue.shift();\n }\n};\n\nmodule.exports = StreamReader;\n","'use strict';\n\nvar Buffer = require('safe-buffer').Buffer,\n crypto = require('crypto'),\n url = require('url'),\n util = require('util'),\n HttpParser = require('../http_parser'),\n Base = require('./base'),\n Hybi = require('./hybi'),\n Proxy = require('./proxy');\n\nvar Client = function(_url, options) {\n this.version = 'hybi-' + Hybi.VERSION;\n Hybi.call(this, null, _url, options);\n\n this.readyState = -1;\n this._key = Client.generateKey();\n this._accept = Hybi.generateAccept(this._key);\n this._http = new HttpParser('response');\n\n var uri = url.parse(this.url),\n auth = uri.auth && Buffer.from(uri.auth, 'utf8').toString('base64');\n\n if (this.VALID_PROTOCOLS.indexOf(uri.protocol) < 0)\n throw new Error(this.url + ' is not a valid WebSocket URL');\n\n this._pathname = (uri.pathname || '/') + (uri.search || '');\n\n this._headers.set('Host', uri.host);\n this._headers.set('Upgrade', 'websocket');\n this._headers.set('Connection', 'Upgrade');\n this._headers.set('Sec-WebSocket-Key', this._key);\n this._headers.set('Sec-WebSocket-Version', Hybi.VERSION);\n\n if (this._protocols.length > 0)\n this._headers.set('Sec-WebSocket-Protocol', this._protocols.join(', '));\n\n if (auth)\n this._headers.set('Authorization', 'Basic ' + auth);\n};\nutil.inherits(Client, Hybi);\n\nClient.generateKey = function() {\n return crypto.randomBytes(16).toString('base64');\n};\n\nvar instance = {\n VALID_PROTOCOLS: ['ws:', 'wss:'],\n\n proxy: function(origin, options) {\n return new Proxy(this, origin, options);\n },\n\n start: function() {\n if (this.readyState !== -1) return false;\n this._write(this._handshakeRequest());\n this.readyState = 0;\n return true;\n },\n\n parse: function(chunk) {\n if (this.readyState === 3) return;\n if (this.readyState > 0) return Hybi.prototype.parse.call(this, chunk);\n\n this._http.parse(chunk);\n if (!this._http.isComplete()) return;\n\n this._validateHandshake();\n if (this.readyState === 3) return;\n\n this._open();\n this.parse(this._http.body);\n },\n\n _handshakeRequest: function() {\n var extensions = this._extensions.generateOffer();\n if (extensions)\n this._headers.set('Sec-WebSocket-Extensions', extensions);\n\n var start = 'GET ' + this._pathname + ' HTTP/1.1',\n headers = [start, this._headers.toString(), ''];\n\n return Buffer.from(headers.join('\\r\\n'), 'utf8');\n },\n\n _failHandshake: function(message) {\n message = 'Error during WebSocket handshake: ' + message;\n this.readyState = 3;\n this.emit('error', new Error(message));\n this.emit('close', new Base.CloseEvent(this.ERRORS.protocol_error, message));\n },\n\n _validateHandshake: function() {\n this.statusCode = this._http.statusCode;\n this.headers = this._http.headers;\n\n if (this._http.error)\n return this._failHandshake(this._http.error.message);\n\n if (this._http.statusCode !== 101)\n return this._failHandshake('Unexpected response code: ' + this._http.statusCode);\n\n var headers = this._http.headers,\n upgrade = headers['upgrade'] || '',\n connection = headers['connection'] || '',\n accept = headers['sec-websocket-accept'] || '',\n protocol = headers['sec-websocket-protocol'] || '';\n\n if (upgrade === '')\n return this._failHandshake(\"'Upgrade' header is missing\");\n if (upgrade.toLowerCase() !== 'websocket')\n return this._failHandshake(\"'Upgrade' header value is not 'WebSocket'\");\n\n if (connection === '')\n return this._failHandshake(\"'Connection' header is missing\");\n if (connection.toLowerCase() !== 'upgrade')\n return this._failHandshake(\"'Connection' header value is not 'Upgrade'\");\n\n if (accept !== this._accept)\n return this._failHandshake('Sec-WebSocket-Accept mismatch');\n\n this.protocol = null;\n\n if (protocol !== '') {\n if (this._protocols.indexOf(protocol) < 0)\n return this._failHandshake('Sec-WebSocket-Protocol mismatch');\n else\n this.protocol = protocol;\n }\n\n try {\n this._extensions.activate(this.headers['sec-websocket-extensions']);\n } catch (e) {\n return this._failHandshake(e.message);\n }\n }\n};\n\nfor (var key in instance)\n Client.prototype[key] = instance[key];\n\nmodule.exports = Client;\n","/*jshint node:true */\n\nvar assert = require('assert');\n\nexports.HTTPParser = HTTPParser;\nfunction HTTPParser(type) {\n assert.ok(type === HTTPParser.REQUEST || type === HTTPParser.RESPONSE || type === undefined);\n if (type === undefined) {\n // Node v12+\n } else {\n this.initialize(type);\n }\n this.maxHeaderSize=HTTPParser.maxHeaderSize\n}\nHTTPParser.prototype.initialize = function (type, async_resource) {\n assert.ok(type === HTTPParser.REQUEST || type === HTTPParser.RESPONSE);\n this.type = type;\n this.state = type + '_LINE';\n this.info = {\n headers: [],\n upgrade: false\n };\n this.trailers = [];\n this.line = '';\n this.isChunked = false;\n this.connection = '';\n this.headerSize = 0; // for preventing too big headers\n this.body_bytes = null;\n this.isUserCall = false;\n this.hadError = false;\n};\n\nHTTPParser.encoding = 'ascii';\nHTTPParser.maxHeaderSize = 80 * 1024; // maxHeaderSize (in bytes) is configurable, but 80kb by default;\nHTTPParser.REQUEST = 'REQUEST';\nHTTPParser.RESPONSE = 'RESPONSE';\n\n// Note: *not* starting with kOnHeaders=0 line the Node parser, because any\n// newly added constants (kOnTimeout in Node v12.19.0) will overwrite 0!\nvar kOnHeaders = HTTPParser.kOnHeaders = 1;\nvar kOnHeadersComplete = HTTPParser.kOnHeadersComplete = 2;\nvar kOnBody = HTTPParser.kOnBody = 3;\nvar kOnMessageComplete = HTTPParser.kOnMessageComplete = 4;\n\n// Some handler stubs, needed for compatibility\nHTTPParser.prototype[kOnHeaders] =\nHTTPParser.prototype[kOnHeadersComplete] =\nHTTPParser.prototype[kOnBody] =\nHTTPParser.prototype[kOnMessageComplete] = function () {};\n\nvar compatMode0_12 = true;\nObject.defineProperty(HTTPParser, 'kOnExecute', {\n get: function () {\n // hack for backward compatibility\n compatMode0_12 = false;\n return 99;\n }\n });\n\nvar methods = exports.methods = HTTPParser.methods = [\n 'DELETE',\n 'GET',\n 'HEAD',\n 'POST',\n 'PUT',\n 'CONNECT',\n 'OPTIONS',\n 'TRACE',\n 'COPY',\n 'LOCK',\n 'MKCOL',\n 'MOVE',\n 'PROPFIND',\n 'PROPPATCH',\n 'SEARCH',\n 'UNLOCK',\n 'BIND',\n 'REBIND',\n 'UNBIND',\n 'ACL',\n 'REPORT',\n 'MKACTIVITY',\n 'CHECKOUT',\n 'MERGE',\n 'M-SEARCH',\n 'NOTIFY',\n 'SUBSCRIBE',\n 'UNSUBSCRIBE',\n 'PATCH',\n 'PURGE',\n 'MKCALENDAR',\n 'LINK',\n 'UNLINK',\n 'SOURCE',\n];\nvar method_connect = methods.indexOf('CONNECT');\nHTTPParser.prototype.reinitialize = HTTPParser;\nHTTPParser.prototype.close =\nHTTPParser.prototype.pause =\nHTTPParser.prototype.resume =\nHTTPParser.prototype.free = function () {};\nHTTPParser.prototype._compatMode0_11 = false;\nHTTPParser.prototype.getAsyncId = function() { return 0; };\n\nvar headerState = {\n REQUEST_LINE: true,\n RESPONSE_LINE: true,\n HEADER: true\n};\nHTTPParser.prototype.execute = function (chunk, start, length) {\n if (!(this instanceof HTTPParser)) {\n throw new TypeError('not a HTTPParser');\n }\n\n // backward compat to node < 0.11.4\n // Note: the start and length params were removed in newer version\n start = start || 0;\n length = typeof length === 'number' ? length : chunk.length;\n\n this.chunk = chunk;\n this.offset = start;\n var end = this.end = start + length;\n try {\n while (this.offset < end) {\n if (this[this.state]()) {\n break;\n }\n }\n } catch (err) {\n if (this.isUserCall) {\n throw err;\n }\n this.hadError = true;\n return err;\n }\n this.chunk = null;\n length = this.offset - start;\n if (headerState[this.state]) {\n this.headerSize += length;\n if (this.headerSize > (this.maxHeaderSize||HTTPParser.maxHeaderSize)) {\n return new Error('max header size exceeded');\n }\n }\n return length;\n};\n\nvar stateFinishAllowed = {\n REQUEST_LINE: true,\n RESPONSE_LINE: true,\n BODY_RAW: true\n};\nHTTPParser.prototype.finish = function () {\n if (this.hadError) {\n return;\n }\n if (!stateFinishAllowed[this.state]) {\n return new Error('invalid state for EOF');\n }\n if (this.state === 'BODY_RAW') {\n this.userCall()(this[kOnMessageComplete]());\n }\n};\n\n// These three methods are used for an internal speed optimization, and it also\n// works if theses are noops. Basically consume() asks us to read the bytes\n// ourselves, but if we don't do it we get them through execute().\nHTTPParser.prototype.consume =\nHTTPParser.prototype.unconsume =\nHTTPParser.prototype.getCurrentBuffer = function () {};\n\n//For correct error handling - see HTTPParser#execute\n//Usage: this.userCall()(userFunction('arg'));\nHTTPParser.prototype.userCall = function () {\n this.isUserCall = true;\n var self = this;\n return function (ret) {\n self.isUserCall = false;\n return ret;\n };\n};\n\nHTTPParser.prototype.nextRequest = function () {\n this.userCall()(this[kOnMessageComplete]());\n this.reinitialize(this.type);\n};\n\nHTTPParser.prototype.consumeLine = function () {\n var end = this.end,\n chunk = this.chunk;\n for (var i = this.offset; i < end; i++) {\n if (chunk[i] === 0x0a) { // \\n\n var line = this.line + chunk.toString(HTTPParser.encoding, this.offset, i);\n if (line.charAt(line.length - 1) === '\\r') {\n line = line.substr(0, line.length - 1);\n }\n this.line = '';\n this.offset = i + 1;\n return line;\n }\n }\n //line split over multiple chunks\n this.line += chunk.toString(HTTPParser.encoding, this.offset, this.end);\n this.offset = this.end;\n};\n\nvar headerExp = /^([^: \\t]+):[ \\t]*((?:.*[^ \\t])|)/;\nvar headerContinueExp = /^[ \\t]+(.*[^ \\t])/;\nHTTPParser.prototype.parseHeader = function (line, headers) {\n if (line.indexOf('\\r') !== -1) {\n throw parseErrorCode('HPE_LF_EXPECTED');\n }\n\n var match = headerExp.exec(line);\n var k = match && match[1];\n if (k) { // skip empty string (malformed header)\n headers.push(k);\n headers.push(match[2]);\n } else {\n var matchContinue = headerContinueExp.exec(line);\n if (matchContinue && headers.length) {\n if (headers[headers.length - 1]) {\n headers[headers.length - 1] += ' ';\n }\n headers[headers.length - 1] += matchContinue[1];\n }\n }\n};\n\nvar requestExp = /^([A-Z-]+) ([^ ]+) HTTP\\/(\\d)\\.(\\d)$/;\nHTTPParser.prototype.REQUEST_LINE = function () {\n var line = this.consumeLine();\n if (!line) {\n return;\n }\n var match = requestExp.exec(line);\n if (match === null) {\n throw parseErrorCode('HPE_INVALID_CONSTANT');\n }\n this.info.method = this._compatMode0_11 ? match[1] : methods.indexOf(match[1]);\n if (this.info.method === -1) {\n throw new Error('invalid request method');\n }\n this.info.url = match[2];\n this.info.versionMajor = +match[3];\n this.info.versionMinor = +match[4];\n this.body_bytes = 0;\n this.state = 'HEADER';\n};\n\nvar responseExp = /^HTTP\\/(\\d)\\.(\\d) (\\d{3}) ?(.*)$/;\nHTTPParser.prototype.RESPONSE_LINE = function () {\n var line = this.consumeLine();\n if (!line) {\n return;\n }\n var match = responseExp.exec(line);\n if (match === null) {\n throw parseErrorCode('HPE_INVALID_CONSTANT');\n }\n this.info.versionMajor = +match[1];\n this.info.versionMinor = +match[2];\n var statusCode = this.info.statusCode = +match[3];\n this.info.statusMessage = match[4];\n // Implied zero length.\n if ((statusCode / 100 | 0) === 1 || statusCode === 204 || statusCode === 304) {\n this.body_bytes = 0;\n }\n this.state = 'HEADER';\n};\n\nHTTPParser.prototype.shouldKeepAlive = function () {\n if (this.info.versionMajor > 0 && this.info.versionMinor > 0) {\n if (this.connection.indexOf('close') !== -1) {\n return false;\n }\n } else if (this.connection.indexOf('keep-alive') === -1) {\n return false;\n }\n if (this.body_bytes !== null || this.isChunked) { // || skipBody\n return true;\n }\n return false;\n};\n\nHTTPParser.prototype.HEADER = function () {\n var line = this.consumeLine();\n if (line === undefined) {\n return;\n }\n var info = this.info;\n if (line) {\n this.parseHeader(line, info.headers);\n } else {\n var headers = info.headers;\n var hasContentLength = false;\n var currentContentLengthValue;\n var hasUpgradeHeader = false;\n for (var i = 0; i < headers.length; i += 2) {\n switch (headers[i].toLowerCase()) {\n case 'transfer-encoding':\n this.isChunked = headers[i + 1].toLowerCase() === 'chunked';\n break;\n case 'content-length':\n currentContentLengthValue = +headers[i + 1];\n if (hasContentLength) {\n // Fix duplicate Content-Length header with same values.\n // Throw error only if values are different.\n // Known issues:\n // https://github.com/request/request/issues/2091#issuecomment-328715113\n // https://github.com/nodejs/node/issues/6517#issuecomment-216263771\n if (currentContentLengthValue !== this.body_bytes) {\n throw parseErrorCode('HPE_UNEXPECTED_CONTENT_LENGTH');\n }\n } else {\n hasContentLength = true;\n this.body_bytes = currentContentLengthValue;\n }\n break;\n case 'connection':\n this.connection += headers[i + 1].toLowerCase();\n break;\n case 'upgrade':\n hasUpgradeHeader = true;\n break;\n }\n }\n\n // if both isChunked and hasContentLength, isChunked wins\n // This is required so the body is parsed using the chunked method, and matches\n // Chrome's behavior. We could, maybe, ignore them both (would get chunked\n // encoding into the body), and/or disable shouldKeepAlive to be more\n // resilient.\n if (this.isChunked && hasContentLength) {\n hasContentLength = false;\n this.body_bytes = null;\n }\n\n // Logic from https://github.com/nodejs/http-parser/blob/921d5585515a153fa00e411cf144280c59b41f90/http_parser.c#L1727-L1737\n // \"For responses, \"Upgrade: foo\" and \"Connection: upgrade\" are\n // mandatory only when it is a 101 Switching Protocols response,\n // otherwise it is purely informational, to announce support.\n if (hasUpgradeHeader && this.connection.indexOf('upgrade') != -1) {\n info.upgrade = this.type === HTTPParser.REQUEST || info.statusCode === 101;\n } else {\n info.upgrade = info.method === method_connect;\n }\n\n if (this.isChunked && info.upgrade) {\n this.isChunked = false;\n }\n\n info.shouldKeepAlive = this.shouldKeepAlive();\n //problem which also exists in original node: we should know skipBody before calling onHeadersComplete\n var skipBody;\n if (compatMode0_12) {\n skipBody = this.userCall()(this[kOnHeadersComplete](info));\n } else {\n skipBody = this.userCall()(this[kOnHeadersComplete](info.versionMajor,\n info.versionMinor, info.headers, info.method, info.url, info.statusCode,\n info.statusMessage, info.upgrade, info.shouldKeepAlive));\n }\n if (skipBody === 2) {\n this.nextRequest();\n return true;\n } else if (this.isChunked && !skipBody) {\n this.state = 'BODY_CHUNKHEAD';\n } else if (skipBody || this.body_bytes === 0) {\n this.nextRequest();\n // For older versions of node (v6.x and older?), that return skipBody=1 or skipBody=true,\n // need this \"return true;\" if it's an upgrade request.\n return info.upgrade;\n } else if (this.body_bytes === null) {\n this.state = 'BODY_RAW';\n } else {\n this.state = 'BODY_SIZED';\n }\n }\n};\n\nHTTPParser.prototype.BODY_CHUNKHEAD = function () {\n var line = this.consumeLine();\n if (line === undefined) {\n return;\n }\n this.body_bytes = parseInt(line, 16);\n if (!this.body_bytes) {\n this.state = 'BODY_CHUNKTRAILERS';\n } else {\n this.state = 'BODY_CHUNK';\n }\n};\n\nHTTPParser.prototype.BODY_CHUNK = function () {\n var length = Math.min(this.end - this.offset, this.body_bytes);\n this.userCall()(this[kOnBody](this.chunk, this.offset, length));\n this.offset += length;\n this.body_bytes -= length;\n if (!this.body_bytes) {\n this.state = 'BODY_CHUNKEMPTYLINE';\n }\n};\n\nHTTPParser.prototype.BODY_CHUNKEMPTYLINE = function () {\n var line = this.consumeLine();\n if (line === undefined) {\n return;\n }\n assert.equal(line, '');\n this.state = 'BODY_CHUNKHEAD';\n};\n\nHTTPParser.prototype.BODY_CHUNKTRAILERS = function () {\n var line = this.consumeLine();\n if (line === undefined) {\n return;\n }\n if (line) {\n this.parseHeader(line, this.trailers);\n } else {\n if (this.trailers.length) {\n this.userCall()(this[kOnHeaders](this.trailers, ''));\n }\n this.nextRequest();\n }\n};\n\nHTTPParser.prototype.BODY_RAW = function () {\n var length = this.end - this.offset;\n this.userCall()(this[kOnBody](this.chunk, this.offset, length));\n this.offset = this.end;\n};\n\nHTTPParser.prototype.BODY_SIZED = function () {\n var length = Math.min(this.end - this.offset, this.body_bytes);\n this.userCall()(this[kOnBody](this.chunk, this.offset, length));\n this.offset += length;\n this.body_bytes -= length;\n if (!this.body_bytes) {\n this.nextRequest();\n }\n};\n\n// backward compat to node < 0.11.6\n['Headers', 'HeadersComplete', 'Body', 'MessageComplete'].forEach(function (name) {\n var k = HTTPParser['kOn' + name];\n Object.defineProperty(HTTPParser.prototype, 'on' + name, {\n get: function () {\n return this[k];\n },\n set: function (to) {\n // hack for backward compatibility\n this._compatMode0_11 = true;\n method_connect = 'CONNECT';\n return (this[k] = to);\n }\n });\n});\n\nfunction parseErrorCode(code) {\n var err = new Error('Parse Error');\n err.code = code;\n return err;\n}\n","module.exports = require(\"assert\");","'use strict';\n\nvar Parser = require('./parser'),\n Pipeline = require('./pipeline');\n\nvar Extensions = function() {\n this._rsv1 = this._rsv2 = this._rsv3 = null;\n\n this._byName = {};\n this._inOrder = [];\n this._sessions = [];\n this._index = {};\n};\n\nExtensions.MESSAGE_OPCODES = [1, 2];\n\nvar instance = {\n add: function(ext) {\n if (typeof ext.name !== 'string') throw new TypeError('extension.name must be a string');\n if (ext.type !== 'permessage') throw new TypeError('extension.type must be \"permessage\"');\n\n if (typeof ext.rsv1 !== 'boolean') throw new TypeError('extension.rsv1 must be true or false');\n if (typeof ext.rsv2 !== 'boolean') throw new TypeError('extension.rsv2 must be true or false');\n if (typeof ext.rsv3 !== 'boolean') throw new TypeError('extension.rsv3 must be true or false');\n\n if (this._byName.hasOwnProperty(ext.name))\n throw new TypeError('An extension with name \"' + ext.name + '\" is already registered');\n\n this._byName[ext.name] = ext;\n this._inOrder.push(ext);\n },\n\n generateOffer: function() {\n var sessions = [],\n offer = [],\n index = {};\n\n this._inOrder.forEach(function(ext) {\n var session = ext.createClientSession();\n if (!session) return;\n\n var record = [ext, session];\n sessions.push(record);\n index[ext.name] = record;\n\n var offers = session.generateOffer();\n offers = offers ? [].concat(offers) : [];\n\n offers.forEach(function(off) {\n offer.push(Parser.serializeParams(ext.name, off));\n }, this);\n }, this);\n\n this._sessions = sessions;\n this._index = index;\n\n return offer.length > 0 ? offer.join(', ') : null;\n },\n\n activate: function(header) {\n var responses = Parser.parseHeader(header),\n sessions = [];\n\n responses.eachOffer(function(name, params) {\n var record = this._index[name];\n\n if (!record)\n throw new Error('Server sent an extension response for unknown extension \"' + name + '\"');\n\n var ext = record[0],\n session = record[1],\n reserved = this._reserved(ext);\n\n if (reserved)\n throw new Error('Server sent two extension responses that use the RSV' +\n reserved[0] + ' bit: \"' +\n reserved[1] + '\" and \"' + ext.name + '\"');\n\n if (session.activate(params) !== true)\n throw new Error('Server sent unacceptable extension parameters: ' +\n Parser.serializeParams(name, params));\n\n this._reserve(ext);\n sessions.push(record);\n }, this);\n\n this._sessions = sessions;\n this._pipeline = new Pipeline(sessions);\n },\n\n generateResponse: function(header) {\n var sessions = [],\n response = [],\n offers = Parser.parseHeader(header);\n\n this._inOrder.forEach(function(ext) {\n var offer = offers.byName(ext.name);\n if (offer.length === 0 || this._reserved(ext)) return;\n\n var session = ext.createServerSession(offer);\n if (!session) return;\n\n this._reserve(ext);\n sessions.push([ext, session]);\n response.push(Parser.serializeParams(ext.name, session.generateResponse()));\n }, this);\n\n this._sessions = sessions;\n this._pipeline = new Pipeline(sessions);\n\n return response.length > 0 ? response.join(', ') : null;\n },\n\n validFrameRsv: function(frame) {\n var allowed = { rsv1: false, rsv2: false, rsv3: false },\n ext;\n\n if (Extensions.MESSAGE_OPCODES.indexOf(frame.opcode) >= 0) {\n for (var i = 0, n = this._sessions.length; i < n; i++) {\n ext = this._sessions[i][0];\n allowed.rsv1 = allowed.rsv1 || ext.rsv1;\n allowed.rsv2 = allowed.rsv2 || ext.rsv2;\n allowed.rsv3 = allowed.rsv3 || ext.rsv3;\n }\n }\n\n return (allowed.rsv1 || !frame.rsv1) &&\n (allowed.rsv2 || !frame.rsv2) &&\n (allowed.rsv3 || !frame.rsv3);\n },\n\n processIncomingMessage: function(message, callback, context) {\n this._pipeline.processIncomingMessage(message, callback, context);\n },\n\n processOutgoingMessage: function(message, callback, context) {\n this._pipeline.processOutgoingMessage(message, callback, context);\n },\n\n close: function(callback, context) {\n if (!this._pipeline) return callback.call(context);\n this._pipeline.close(callback, context);\n },\n\n _reserve: function(ext) {\n this._rsv1 = this._rsv1 || (ext.rsv1 && ext.name);\n this._rsv2 = this._rsv2 || (ext.rsv2 && ext.name);\n this._rsv3 = this._rsv3 || (ext.rsv3 && ext.name);\n },\n\n _reserved: function(ext) {\n if (this._rsv1 && ext.rsv1) return [1, this._rsv1];\n if (this._rsv2 && ext.rsv2) return [2, this._rsv2];\n if (this._rsv3 && ext.rsv3) return [3, this._rsv3];\n return false;\n }\n};\n\nfor (var key in instance)\n Extensions.prototype[key] = instance[key];\n\nmodule.exports = Extensions;\n","'use strict';\n\nvar TOKEN = /([!#\\$%&'\\*\\+\\-\\.\\^_`\\|~0-9A-Za-z]+)/,\n NOTOKEN = /([^!#\\$%&'\\*\\+\\-\\.\\^_`\\|~0-9A-Za-z])/g,\n QUOTED = /\"((?:\\\\[\\x00-\\x7f]|[^\\x00-\\x08\\x0a-\\x1f\\x7f\"\\\\])*)\"/,\n PARAM = new RegExp(TOKEN.source + '(?:=(?:' + TOKEN.source + '|' + QUOTED.source + '))?'),\n EXT = new RegExp(TOKEN.source + '(?: *; *' + PARAM.source + ')*', 'g'),\n EXT_LIST = new RegExp('^' + EXT.source + '(?: *, *' + EXT.source + ')*$'),\n NUMBER = /^-?(0|[1-9][0-9]*)(\\.[0-9]+)?$/;\n\nvar hasOwnProperty = Object.prototype.hasOwnProperty;\n\nvar Parser = {\n parseHeader: function(header) {\n var offers = new Offers();\n if (header === '' || header === undefined) return offers;\n\n if (!EXT_LIST.test(header))\n throw new SyntaxError('Invalid Sec-WebSocket-Extensions header: ' + header);\n\n var values = header.match(EXT);\n\n values.forEach(function(value) {\n var params = value.match(new RegExp(PARAM.source, 'g')),\n name = params.shift(),\n offer = {};\n\n params.forEach(function(param) {\n var args = param.match(PARAM), key = args[1], data;\n\n if (args[2] !== undefined) {\n data = args[2];\n } else if (args[3] !== undefined) {\n data = args[3].replace(/\\\\/g, '');\n } else {\n data = true;\n }\n if (NUMBER.test(data)) data = parseFloat(data);\n\n if (hasOwnProperty.call(offer, key)) {\n offer[key] = [].concat(offer[key]);\n offer[key].push(data);\n } else {\n offer[key] = data;\n }\n }, this);\n offers.push(name, offer);\n }, this);\n\n return offers;\n },\n\n serializeParams: function(name, params) {\n var values = [];\n\n var print = function(key, value) {\n if (value instanceof Array) {\n value.forEach(function(v) { print(key, v) });\n } else if (value === true) {\n values.push(key);\n } else if (typeof value === 'number') {\n values.push(key + '=' + value);\n } else if (NOTOKEN.test(value)) {\n values.push(key + '=\"' + value.replace(/\"/g, '\\\\\"') + '\"');\n } else {\n values.push(key + '=' + value);\n }\n };\n\n for (var key in params) print(key, params[key]);\n\n return [name].concat(values).join('; ');\n }\n};\n\nvar Offers = function() {\n this._byName = {};\n this._inOrder = [];\n};\n\nOffers.prototype.push = function(name, params) {\n if (!hasOwnProperty.call(this._byName, name))\n this._byName[name] = [];\n\n this._byName[name].push(params);\n this._inOrder.push({ name: name, params: params });\n};\n\nOffers.prototype.eachOffer = function(callback, context) {\n var list = this._inOrder;\n for (var i = 0, n = list.length; i < n; i++)\n callback.call(context, list[i].name, list[i].params);\n};\n\nOffers.prototype.byName = function(name) {\n return this._byName[name] || [];\n};\n\nOffers.prototype.toArray = function() {\n return this._inOrder.slice();\n};\n\nmodule.exports = Parser;\n","'use strict';\n\nvar Cell = require('./cell'),\n Pledge = require('./pledge');\n\nvar Pipeline = function(sessions) {\n this._cells = sessions.map(function(session) { return new Cell(session) });\n this._stopped = { incoming: false, outgoing: false };\n};\n\nPipeline.prototype.processIncomingMessage = function(message, callback, context) {\n if (this._stopped.incoming) return;\n this._loop('incoming', this._cells.length - 1, -1, -1, message, callback, context);\n};\n\nPipeline.prototype.processOutgoingMessage = function(message, callback, context) {\n if (this._stopped.outgoing) return;\n this._loop('outgoing', 0, this._cells.length, 1, message, callback, context);\n};\n\nPipeline.prototype.close = function(callback, context) {\n this._stopped = { incoming: true, outgoing: true };\n\n var closed = this._cells.map(function(a) { return a.close() });\n if (callback)\n Pledge.all(closed).then(function() { callback.call(context) });\n};\n\nPipeline.prototype._loop = function(direction, start, end, step, message, callback, context) {\n var cells = this._cells,\n n = cells.length,\n self = this;\n\n while (n--) cells[n].pending(direction);\n\n var pipe = function(index, error, msg) {\n if (index === end) return callback.call(context, error, msg);\n\n cells[index][direction](error, msg, function(err, m) {\n if (err) self._stopped[direction] = true;\n pipe(index + step, err, m);\n });\n };\n pipe(start, null, message);\n};\n\nmodule.exports = Pipeline;\n","'use strict';\n\nvar Functor = require('./functor'),\n Pledge = require('./pledge');\n\nvar Cell = function(tuple) {\n this._ext = tuple[0];\n this._session = tuple[1];\n\n this._functors = {\n incoming: new Functor(this._session, 'processIncomingMessage'),\n outgoing: new Functor(this._session, 'processOutgoingMessage')\n };\n};\n\nCell.prototype.pending = function(direction) {\n var functor = this._functors[direction];\n if (!functor._stopped) functor.pending += 1;\n};\n\nCell.prototype.incoming = function(error, message, callback, context) {\n this._exec('incoming', error, message, callback, context);\n};\n\nCell.prototype.outgoing = function(error, message, callback, context) {\n this._exec('outgoing', error, message, callback, context);\n};\n\nCell.prototype.close = function() {\n this._closed = this._closed || new Pledge();\n this._doClose();\n return this._closed;\n};\n\nCell.prototype._exec = function(direction, error, message, callback, context) {\n this._functors[direction].call(error, message, function(err, msg) {\n if (err) err.message = this._ext.name + ': ' + err.message;\n callback.call(context, err, msg);\n this._doClose();\n }, this);\n};\n\nCell.prototype._doClose = function() {\n var fin = this._functors.incoming,\n fout = this._functors.outgoing;\n\n if (!this._closed || fin.pending + fout.pending !== 0) return;\n if (this._session) this._session.close();\n this._session = null;\n this._closed.done();\n};\n\nmodule.exports = Cell;\n","'use strict';\n\nvar RingBuffer = require('./ring_buffer');\n\nvar Functor = function(session, method) {\n this._session = session;\n this._method = method;\n this._queue = new RingBuffer(Functor.QUEUE_SIZE);\n this._stopped = false;\n this.pending = 0;\n};\n\nFunctor.QUEUE_SIZE = 8;\n\nFunctor.prototype.call = function(error, message, callback, context) {\n if (this._stopped) return;\n\n var record = { error: error, message: message, callback: callback, context: context, done: false },\n called = false,\n self = this;\n\n this._queue.push(record);\n\n if (record.error) {\n record.done = true;\n this._stop();\n return this._flushQueue();\n }\n\n var handler = function(err, msg) {\n if (!(called ^ (called = true))) return;\n\n if (err) {\n self._stop();\n record.error = err;\n record.message = null;\n } else {\n record.message = msg;\n }\n\n record.done = true;\n self._flushQueue();\n };\n\n try {\n this._session[this._method](message, handler);\n } catch (err) {\n handler(err);\n }\n};\n\nFunctor.prototype._stop = function() {\n this.pending = this._queue.length;\n this._stopped = true;\n};\n\nFunctor.prototype._flushQueue = function() {\n var queue = this._queue, record;\n\n while (queue.length > 0 && queue.peek().done) {\n record = queue.shift();\n if (record.error) {\n this.pending = 0;\n queue.clear();\n } else {\n this.pending -= 1;\n }\n record.callback.call(record.context, record.error, record.message);\n }\n};\n\nmodule.exports = Functor;\n","'use strict';\n\nvar Frame = function() {};\n\nvar instance = {\n final: false,\n rsv1: false,\n rsv2: false,\n rsv3: false,\n opcode: null,\n masked: false,\n maskingKey: null,\n lengthBytes: 1,\n length: 0,\n payload: null\n};\n\nfor (var key in instance)\n Frame.prototype[key] = instance[key];\n\nmodule.exports = Frame;\n","'use strict';\n\nvar Buffer = require('safe-buffer').Buffer;\n\nvar Message = function() {\n this.rsv1 = false;\n this.rsv2 = false;\n this.rsv3 = false;\n this.opcode = null;\n this.length = 0;\n this._chunks = [];\n};\n\nvar instance = {\n read: function() {\n return this.data = this.data || Buffer.concat(this._chunks, this.length);\n },\n\n pushFrame: function(frame) {\n this.rsv1 = this.rsv1 || frame.rsv1;\n this.rsv2 = this.rsv2 || frame.rsv2;\n this.rsv3 = this.rsv3 || frame.rsv3;\n\n if (this.opcode === null) this.opcode = frame.opcode;\n\n this._chunks.push(frame.payload);\n this.length += frame.length;\n }\n};\n\nfor (var key in instance)\n Message.prototype[key] = instance[key];\n\nmodule.exports = Message;\n","'use strict';\n\nvar Buffer = require('safe-buffer').Buffer,\n Stream = require('stream').Stream,\n url = require('url'),\n util = require('util'),\n Base = require('./base'),\n Headers = require('./headers'),\n HttpParser = require('../http_parser');\n\nvar PORTS = { 'ws:': 80, 'wss:': 443 };\n\nvar Proxy = function(client, origin, options) {\n this._client = client;\n this._http = new HttpParser('response');\n this._origin = (typeof client.url === 'object') ? client.url : url.parse(client.url);\n this._url = (typeof origin === 'object') ? origin : url.parse(origin);\n this._options = options || {};\n this._state = 0;\n\n this.readable = this.writable = true;\n this._paused = false;\n\n this._headers = new Headers();\n this._headers.set('Host', this._origin.host);\n this._headers.set('Connection', 'keep-alive');\n this._headers.set('Proxy-Connection', 'keep-alive');\n\n var auth = this._url.auth && Buffer.from(this._url.auth, 'utf8').toString('base64');\n if (auth) this._headers.set('Proxy-Authorization', 'Basic ' + auth);\n};\nutil.inherits(Proxy, Stream);\n\nvar instance = {\n setHeader: function(name, value) {\n if (this._state !== 0) return false;\n this._headers.set(name, value);\n return true;\n },\n\n start: function() {\n if (this._state !== 0) return false;\n this._state = 1;\n\n var origin = this._origin,\n port = origin.port || PORTS[origin.protocol],\n start = 'CONNECT ' + origin.hostname + ':' + port + ' HTTP/1.1';\n\n var headers = [start, this._headers.toString(), ''];\n\n this.emit('data', Buffer.from(headers.join('\\r\\n'), 'utf8'));\n return true;\n },\n\n pause: function() {\n this._paused = true;\n },\n\n resume: function() {\n this._paused = false;\n this.emit('drain');\n },\n\n write: function(chunk) {\n if (!this.writable) return false;\n\n this._http.parse(chunk);\n if (!this._http.isComplete()) return !this._paused;\n\n this.statusCode = this._http.statusCode;\n this.headers = this._http.headers;\n\n if (this.statusCode === 200) {\n this.emit('connect', new Base.ConnectEvent());\n } else {\n var message = \"Can't establish a connection to the server at \" + this._origin.href;\n this.emit('error', new Error(message));\n }\n this.end();\n return !this._paused;\n },\n\n end: function(chunk) {\n if (!this.writable) return;\n if (chunk !== undefined) this.write(chunk);\n this.readable = this.writable = false;\n this.emit('close');\n this.emit('end');\n },\n\n destroy: function() {\n this.end();\n }\n};\n\nfor (var key in instance)\n Proxy.prototype[key] = instance[key];\n\nmodule.exports = Proxy;\n","'use strict';\n\nvar util = require('util'),\n HttpParser = require('../http_parser'),\n Base = require('./base'),\n Draft75 = require('./draft75'),\n Draft76 = require('./draft76'),\n Hybi = require('./hybi');\n\nvar Server = function(options) {\n Base.call(this, null, null, options);\n this._http = new HttpParser('request');\n};\nutil.inherits(Server, Base);\n\nvar instance = {\n EVENTS: ['open', 'message', 'error', 'close', 'ping', 'pong'],\n\n _bindEventListeners: function() {\n this.messages.on('error', function() {});\n this.on('error', function() {});\n },\n\n parse: function(chunk) {\n if (this._delegate) return this._delegate.parse(chunk);\n\n this._http.parse(chunk);\n if (!this._http.isComplete()) return;\n\n this.method = this._http.method;\n this.url = this._http.url;\n this.headers = this._http.headers;\n this.body = this._http.body;\n\n var self = this;\n this._delegate = Server.http(this, this._options);\n this._delegate.messages = this.messages;\n this._delegate.io = this.io;\n this._open();\n\n this.EVENTS.forEach(function(event) {\n this._delegate.on(event, function(e) { self.emit(event, e) });\n }, this);\n\n this.protocol = this._delegate.protocol;\n this.version = this._delegate.version;\n\n this.parse(this._http.body);\n this.emit('connect', new Base.ConnectEvent());\n },\n\n _open: function() {\n this.__queue.forEach(function(msg) {\n this._delegate[msg[0]].apply(this._delegate, msg[1]);\n }, this);\n this.__queue = [];\n }\n};\n\n['addExtension', 'setHeader', 'start', 'frame', 'text', 'binary', 'ping', 'close'].forEach(function(method) {\n instance[method] = function() {\n if (this._delegate) {\n return this._delegate[method].apply(this._delegate, arguments);\n } else {\n this.__queue.push([method, arguments]);\n return true;\n }\n };\n});\n\nfor (var key in instance)\n Server.prototype[key] = instance[key];\n\nServer.isSecureRequest = function(request) {\n if (request.connection && request.connection.authorized !== undefined) return true;\n if (request.socket && request.socket.secure) return true;\n\n var headers = request.headers;\n if (!headers) return false;\n if (headers['https'] === 'on') return true;\n if (headers['x-forwarded-ssl'] === 'on') return true;\n if (headers['x-forwarded-scheme'] === 'https') return true;\n if (headers['x-forwarded-proto'] === 'https') return true;\n\n return false;\n};\n\nServer.determineUrl = function(request) {\n var scheme = this.isSecureRequest(request) ? 'wss:' : 'ws:';\n return scheme + '//' + request.headers.host + request.url;\n};\n\nServer.http = function(request, options) {\n options = options || {};\n if (options.requireMasking === undefined) options.requireMasking = true;\n\n var headers = request.headers,\n version = headers['sec-websocket-version'],\n key = headers['sec-websocket-key'],\n key1 = headers['sec-websocket-key1'],\n key2 = headers['sec-websocket-key2'],\n url = this.determineUrl(request);\n\n if (version || key)\n return new Hybi(request, url, options);\n else if (key1 || key2)\n return new Draft76(request, url, options);\n else\n return new Draft75(request, url, options);\n};\n\nmodule.exports = Server;\n","'use strict';\n\nvar Buffer = require('safe-buffer').Buffer,\n Base = require('./base'),\n Draft75 = require('./draft75'),\n crypto = require('crypto'),\n util = require('util');\n\n\nvar numberFromKey = function(key) {\n return parseInt((key.match(/[0-9]/g) || []).join(''), 10);\n};\n\nvar spacesInKey = function(key) {\n return (key.match(/ /g) || []).length;\n};\n\n\nvar Draft76 = function(request, url, options) {\n Draft75.apply(this, arguments);\n this._stage = -1;\n this._body = [];\n this.version = 'hixie-76';\n\n this._headers.clear();\n\n this._headers.set('Upgrade', 'WebSocket');\n this._headers.set('Connection', 'Upgrade');\n this._headers.set('Sec-WebSocket-Origin', this._request.headers.origin);\n this._headers.set('Sec-WebSocket-Location', this.url);\n};\nutil.inherits(Draft76, Draft75);\n\nvar instance = {\n BODY_SIZE: 8,\n\n start: function() {\n if (!Draft75.prototype.start.call(this)) return false;\n this._started = true;\n this._sendHandshakeBody();\n return true;\n },\n\n close: function() {\n if (this.readyState === 3) return false;\n if (this.readyState === 1) this._write(Buffer.from([0xFF, 0x00]));\n this.readyState = 3;\n this.emit('close', new Base.CloseEvent(null, null));\n return true;\n },\n\n _handshakeResponse: function() {\n var headers = this._request.headers,\n key1 = headers['sec-websocket-key1'],\n key2 = headers['sec-websocket-key2'];\n\n if (!key1) throw new Error('Missing required header: Sec-WebSocket-Key1');\n if (!key2) throw new Error('Missing required header: Sec-WebSocket-Key2');\n\n var number1 = numberFromKey(key1),\n spaces1 = spacesInKey(key1),\n\n number2 = numberFromKey(key2),\n spaces2 = spacesInKey(key2);\n\n if (number1 % spaces1 !== 0 || number2 % spaces2 !== 0)\n throw new Error('Client sent invalid Sec-WebSocket-Key headers');\n\n this._keyValues = [number1 / spaces1, number2 / spaces2];\n\n var start = 'HTTP/1.1 101 WebSocket Protocol Handshake',\n headers = [start, this._headers.toString(), ''];\n\n return Buffer.from(headers.join('\\r\\n'), 'binary');\n },\n\n _handshakeSignature: function() {\n if (this._body.length < this.BODY_SIZE) return null;\n\n var md5 = crypto.createHash('md5'),\n buffer = Buffer.allocUnsafe(8 + this.BODY_SIZE);\n\n buffer.writeUInt32BE(this._keyValues[0], 0);\n buffer.writeUInt32BE(this._keyValues[1], 4);\n Buffer.from(this._body).copy(buffer, 8, 0, this.BODY_SIZE);\n\n md5.update(buffer);\n return Buffer.from(md5.digest('binary'), 'binary');\n },\n\n _sendHandshakeBody: function() {\n if (!this._started) return;\n var signature = this._handshakeSignature();\n if (!signature) return;\n\n this._write(signature);\n this._stage = 0;\n this._open();\n\n if (this._body.length > this.BODY_SIZE)\n this.parse(this._body.slice(this.BODY_SIZE));\n },\n\n _parseLeadingByte: function(octet) {\n if (octet !== 0xFF)\n return Draft75.prototype._parseLeadingByte.call(this, octet);\n\n this._closing = true;\n this._length = 0;\n this._stage = 1;\n }\n};\n\nfor (var key in instance)\n Draft76.prototype[key] = instance[key];\n\nmodule.exports = Draft76;\n","'use strict';\n\nvar util = require('util'),\n net = require('net'),\n tls = require('tls'),\n url = require('url'),\n driver = require('websocket-driver'),\n API = require('./api'),\n Event = require('./api/event');\n\nvar DEFAULT_PORTS = {'http:': 80, 'https:': 443, 'ws:':80, 'wss:': 443},\n SECURE_PROTOCOLS = ['https:', 'wss:'];\n\nvar Client = function(_url, protocols, options) {\n options = options || {};\n\n this.url = _url;\n this._driver = driver.client(this.url, {maxLength: options.maxLength, protocols: protocols});\n\n ['open', 'error'].forEach(function(event) {\n this._driver.on(event, function() {\n self.headers = self._driver.headers;\n self.statusCode = self._driver.statusCode;\n });\n }, this);\n\n var proxy = options.proxy || {},\n endpoint = url.parse(proxy.origin || this.url),\n port = endpoint.port || DEFAULT_PORTS[endpoint.protocol],\n secure = SECURE_PROTOCOLS.indexOf(endpoint.protocol) >= 0,\n onConnect = function() { self._onConnect() },\n netOptions = options.net || {},\n originTLS = options.tls || {},\n socketTLS = proxy.origin ? (proxy.tls || {}) : originTLS,\n self = this;\n\n netOptions.host = socketTLS.host = endpoint.hostname;\n netOptions.port = socketTLS.port = port;\n\n originTLS.ca = originTLS.ca || options.ca;\n socketTLS.servername = socketTLS.servername || endpoint.hostname;\n\n this._stream = secure\n ? tls.connect(socketTLS, onConnect)\n : net.connect(netOptions, onConnect);\n\n if (proxy.origin) this._configureProxy(proxy, originTLS);\n\n API.call(this, options);\n};\nutil.inherits(Client, API);\n\nClient.prototype._onConnect = function() {\n var worker = this._proxy || this._driver;\n worker.start();\n};\n\nClient.prototype._configureProxy = function(proxy, originTLS) {\n var uri = url.parse(this.url),\n secure = SECURE_PROTOCOLS.indexOf(uri.protocol) >= 0,\n self = this,\n name;\n\n this._proxy = this._driver.proxy(proxy.origin);\n\n if (proxy.headers) {\n for (name in proxy.headers) this._proxy.setHeader(name, proxy.headers[name]);\n }\n\n this._proxy.pipe(this._stream, {end: false});\n this._stream.pipe(this._proxy);\n\n this._proxy.on('connect', function() {\n if (secure) {\n var options = {socket: self._stream, servername: uri.hostname};\n for (name in originTLS) options[name] = originTLS[name];\n self._stream = tls.connect(options);\n self._configureStream();\n }\n self._driver.io.pipe(self._stream);\n self._stream.pipe(self._driver.io);\n self._driver.start();\n });\n\n this._proxy.on('error', function(error) {\n self._driver.emit('error', error);\n });\n};\n\nmodule.exports = Client;\n","module.exports = require(\"net\");","module.exports = require(\"tls\");","'use strict';\n\nvar Stream = require('stream').Stream,\n util = require('util'),\n driver = require('websocket-driver'),\n Headers = require('websocket-driver/lib/websocket/driver/headers'),\n API = require('./websocket/api'),\n EventTarget = require('./websocket/api/event_target'),\n Event = require('./websocket/api/event');\n\nvar EventSource = function(request, response, options) {\n this.writable = true;\n options = options || {};\n\n this._stream = response.socket;\n this._ping = options.ping || this.DEFAULT_PING;\n this._retry = options.retry || this.DEFAULT_RETRY;\n\n var scheme = driver.isSecureRequest(request) ? 'https:' : 'http:';\n this.url = scheme + '//' + request.headers.host + request.url;\n this.lastEventId = request.headers['last-event-id'] || '';\n this.readyState = API.CONNECTING;\n\n var headers = new Headers(),\n self = this;\n\n if (options.headers) {\n for (var key in options.headers) headers.set(key, options.headers[key]);\n }\n\n if (!this._stream || !this._stream.writable) return;\n process.nextTick(function() { self._open() });\n\n this._stream.setTimeout(0);\n this._stream.setNoDelay(true);\n\n var handshake = 'HTTP/1.1 200 OK\\r\\n' +\n 'Content-Type: text/event-stream\\r\\n' +\n 'Cache-Control: no-cache, no-store\\r\\n' +\n 'Connection: close\\r\\n' +\n headers.toString() +\n '\\r\\n' +\n 'retry: ' + Math.floor(this._retry * 1000) + '\\r\\n\\r\\n';\n\n this._write(handshake);\n\n this._stream.on('drain', function() { self.emit('drain') });\n\n if (this._ping)\n this._pingTimer = setInterval(function() { self.ping() }, this._ping * 1000);\n\n ['error', 'end'].forEach(function(event) {\n self._stream.on(event, function() { self.close() });\n });\n};\nutil.inherits(EventSource, Stream);\n\nEventSource.isEventSource = function(request) {\n if (request.method !== 'GET') return false;\n var accept = (request.headers.accept || '').split(/\\s*,\\s*/);\n return accept.indexOf('text/event-stream') >= 0;\n};\n\nvar instance = {\n DEFAULT_PING: 10,\n DEFAULT_RETRY: 5,\n\n _write: function(chunk) {\n if (!this.writable) return false;\n try {\n return this._stream.write(chunk, 'utf8');\n } catch (e) {\n return false;\n }\n },\n\n _open: function() {\n if (this.readyState !== API.CONNECTING) return;\n\n this.readyState = API.OPEN;\n\n var event = new Event('open');\n event.initEvent('open', false, false);\n this.dispatchEvent(event);\n },\n\n write: function(message) {\n return this.send(message);\n },\n\n end: function(message) {\n if (message !== undefined) this.write(message);\n this.close();\n },\n\n send: function(message, options) {\n if (this.readyState > API.OPEN) return false;\n\n message = String(message).replace(/(\\r\\n|\\r|\\n)/g, '$1data: ');\n options = options || {};\n\n var frame = '';\n if (options.event) frame += 'event: ' + options.event + '\\r\\n';\n if (options.id) frame += 'id: ' + options.id + '\\r\\n';\n frame += 'data: ' + message + '\\r\\n\\r\\n';\n\n return this._write(frame);\n },\n\n ping: function() {\n return this._write(':\\r\\n\\r\\n');\n },\n\n close: function() {\n if (this.readyState > API.OPEN) return false;\n\n this.readyState = API.CLOSED;\n this.writable = false;\n if (this._pingTimer) clearInterval(this._pingTimer);\n if (this._stream) this._stream.end();\n\n var event = new Event('close');\n event.initEvent('close', false, false);\n this.dispatchEvent(event);\n\n return true;\n }\n};\n\nfor (var method in instance) EventSource.prototype[method] = instance[method];\nfor (var key in EventTarget) EventSource.prototype[key] = EventTarget[key];\n\nmodule.exports = EventSource;\n","module.exports = require(\"child_process\");","module.exports = require(\"fs\");","module.exports = require(\"http\");","module.exports = require(\"https\");","export default function encode(s: any): string {\n return btoa(utob(s));\n}\n\nvar fromCharCode = String.fromCharCode;\n\nvar b64chars =\n 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';\nvar b64tab = {};\n\nfor (var i = 0, l = b64chars.length; i < l; i++) {\n b64tab[b64chars.charAt(i)] = i;\n}\n\nvar cb_utob = function(c) {\n var cc = c.charCodeAt(0);\n return cc < 0x80\n ? c\n : cc < 0x800\n ? fromCharCode(0xc0 | (cc >>> 6)) + fromCharCode(0x80 | (cc & 0x3f))\n : fromCharCode(0xe0 | ((cc >>> 12) & 0x0f)) +\n fromCharCode(0x80 | ((cc >>> 6) & 0x3f)) +\n fromCharCode(0x80 | (cc & 0x3f));\n};\n\nvar utob = function(u) {\n return u.replace(/[^\\x00-\\x7F]/g, cb_utob);\n};\n\nvar cb_encode = function(ccc) {\n var padlen = [0, 2, 1][ccc.length % 3];\n var ord =\n (ccc.charCodeAt(0) << 16) |\n ((ccc.length > 1 ? ccc.charCodeAt(1) : 0) << 8) |\n (ccc.length > 2 ? ccc.charCodeAt(2) : 0);\n var chars = [\n b64chars.charAt(ord >>> 18),\n b64chars.charAt((ord >>> 12) & 63),\n padlen >= 2 ? '=' : b64chars.charAt((ord >>> 6) & 63),\n padlen >= 1 ? '=' : b64chars.charAt(ord & 63)\n ];\n return chars.join('');\n};\n\nvar btoa =\n global.btoa ||\n function(b) {\n return b.replace(/[\\s\\S]{1,3}/g, cb_encode);\n };\n","import TimedCallback from './timed_callback';\nimport { Delay, Scheduler, Canceller } from './scheduling';\n\nabstract class Timer {\n protected clear: Canceller;\n protected timer: number | void;\n\n constructor(\n set: Scheduler,\n clear: Canceller,\n delay: Delay,\n callback: TimedCallback\n ) {\n this.clear = clear;\n this.timer = set(() => {\n if (this.timer) {\n this.timer = callback(this.timer);\n }\n }, delay);\n }\n\n /** Returns whether the timer is still running.\n *\n * @return {Boolean}\n */\n isRunning(): boolean {\n return this.timer !== null;\n }\n\n /** Aborts a timer when it's running. */\n ensureAborted() {\n if (this.timer) {\n this.clear(this.timer);\n this.timer = null;\n }\n }\n}\n\nexport default Timer;\n","import Timer from './abstract_timer';\nimport TimedCallback from './timed_callback';\nimport { Delay } from './scheduling';\n\n// We need to bind clear functions this way to avoid exceptions on IE8\nfunction clearTimeout(timer) {\n global.clearTimeout(timer);\n}\nfunction clearInterval(timer) {\n global.clearInterval(timer);\n}\n\n/** Cross-browser compatible one-off timer abstraction.\n *\n * @param {Number} delay\n * @param {Function} callback\n */\nexport class OneOffTimer extends Timer {\n constructor(delay: Delay, callback: TimedCallback) {\n super(setTimeout, clearTimeout, delay, function(timer) {\n callback();\n return null;\n });\n }\n}\n\n/** Cross-browser compatible periodic timer abstraction.\n *\n * @param {Number} delay\n * @param {Function} callback\n */\nexport class PeriodicTimer extends Timer {\n constructor(delay: Delay, callback: TimedCallback) {\n super(setInterval, clearInterval, delay, function(timer) {\n callback();\n return timer;\n });\n }\n}\n","import * as Collections from './utils/collections';\nimport TimedCallback from './utils/timers/timed_callback';\nimport { OneOffTimer, PeriodicTimer } from './utils/timers';\n\nvar Util = {\n now(): number {\n if (Date.now) {\n return Date.now();\n } else {\n return new Date().valueOf();\n }\n },\n\n defer(callback: TimedCallback): OneOffTimer {\n return new OneOffTimer(0, callback);\n },\n\n /** Builds a function that will proxy a method call to its first argument.\n *\n * Allows partial application of arguments, so additional arguments are\n * prepended to the argument list.\n *\n * @param {String} name method name\n * @return {Function} proxy function\n */\n method(name: string, ...args: any[]): Function {\n var boundArguments = Array.prototype.slice.call(arguments, 1);\n return function(object) {\n return object[name].apply(object, boundArguments.concat(arguments));\n };\n }\n};\n\nexport default Util;\n","import base64encode from '../base64';\nimport Util from '../util';\n\n/** Merges multiple objects into the target argument.\n *\n * For properties that are plain Objects, performs a deep-merge. For the\n * rest it just copies the value of the property.\n *\n * To extend prototypes use it as following:\n * Pusher.Util.extend(Target.prototype, Base.prototype)\n *\n * You can also use it to merge objects without altering them:\n * Pusher.Util.extend({}, object1, object2)\n *\n * @param {Object} target\n * @return {Object} the target argument\n */\nexport function extend(target: any, ...sources: any[]): T {\n for (var i = 0; i < sources.length; i++) {\n var extensions = sources[i];\n for (var property in extensions) {\n if (\n extensions[property] &&\n extensions[property].constructor &&\n extensions[property].constructor === Object\n ) {\n target[property] = extend(target[property] || {}, extensions[property]);\n } else {\n target[property] = extensions[property];\n }\n }\n }\n return target;\n}\n\nexport function stringify(): string {\n var m = ['Pusher'];\n for (var i = 0; i < arguments.length; i++) {\n if (typeof arguments[i] === 'string') {\n m.push(arguments[i]);\n } else {\n m.push(safeJSONStringify(arguments[i]));\n }\n }\n return m.join(' : ');\n}\n\nexport function arrayIndexOf(array: any[], item: any): number {\n // MSIE doesn't have array.indexOf\n var nativeIndexOf = Array.prototype.indexOf;\n if (array === null) {\n return -1;\n }\n if (nativeIndexOf && array.indexOf === nativeIndexOf) {\n return array.indexOf(item);\n }\n for (var i = 0, l = array.length; i < l; i++) {\n if (array[i] === item) {\n return i;\n }\n }\n return -1;\n}\n\n/** Applies a function f to all properties of an object.\n *\n * Function f gets 3 arguments passed:\n * - element from the object\n * - key of the element\n * - reference to the object\n *\n * @param {Object} object\n * @param {Function} f\n */\nexport function objectApply(object: any, f: Function) {\n for (var key in object) {\n if (Object.prototype.hasOwnProperty.call(object, key)) {\n f(object[key], key, object);\n }\n }\n}\n\n/** Return a list of objects own proerty keys\n *\n * @param {Object} object\n * @returns {Array}\n */\nexport function keys(object: any): string[] {\n var keys = [];\n objectApply(object, function(_, key) {\n keys.push(key);\n });\n return keys;\n}\n\n/** Return a list of object's own property values\n *\n * @param {Object} object\n * @returns {Array}\n */\nexport function values(object: any): any[] {\n var values = [];\n objectApply(object, function(value) {\n values.push(value);\n });\n return values;\n}\n\n/** Applies a function f to all elements of an array.\n *\n * Function f gets 3 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function apply(array: any[], f: Function, context?: any) {\n for (var i = 0; i < array.length; i++) {\n f.call(context || global, array[i], i, array);\n }\n}\n\n/** Maps all elements of the array and returns the result.\n *\n * Function f gets 4 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n * - reference to the destination array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function map(array: any[], f: Function): any[] {\n var result = [];\n for (var i = 0; i < array.length; i++) {\n result.push(f(array[i], i, array, result));\n }\n return result;\n}\n\n/** Maps all elements of the object and returns the result.\n *\n * Function f gets 4 arguments passed:\n * - element from the object\n * - key of the element\n * - reference to the source object\n * - reference to the destination object\n *\n * @param {Object} object\n * @param {Function} f\n */\nexport function mapObject(object: any, f: Function): any {\n var result = {};\n objectApply(object, function(value, key) {\n result[key] = f(value);\n });\n return result;\n}\n\n/** Filters elements of the array using a test function.\n *\n * Function test gets 4 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n * - reference to the destination array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function filter(array: any[], test: Function): any[] {\n test =\n test ||\n function(value) {\n return !!value;\n };\n\n var result = [];\n for (var i = 0; i < array.length; i++) {\n if (test(array[i], i, array, result)) {\n result.push(array[i]);\n }\n }\n return result;\n}\n\n/** Filters properties of the object using a test function.\n *\n * Function test gets 4 arguments passed:\n * - element from the object\n * - key of the element\n * - reference to the source object\n * - reference to the destination object\n *\n * @param {Object} object\n * @param {Function} f\n */\nexport function filterObject(object: Object, test: Function) {\n var result = {};\n objectApply(object, function(value, key) {\n if ((test && test(value, key, object, result)) || Boolean(value)) {\n result[key] = value;\n }\n });\n return result;\n}\n\n/** Flattens an object into a two-dimensional array.\n *\n * @param {Object} object\n * @return {Array} resulting array of [key, value] pairs\n */\nexport function flatten(object: Object): any[] {\n var result = [];\n objectApply(object, function(value, key) {\n result.push([key, value]);\n });\n return result;\n}\n\n/** Checks whether any element of the array passes the test.\n *\n * Function test gets 3 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function any(array: any[], test: Function): boolean {\n for (var i = 0; i < array.length; i++) {\n if (test(array[i], i, array)) {\n return true;\n }\n }\n return false;\n}\n\n/** Checks whether all elements of the array pass the test.\n *\n * Function test gets 3 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function all(array: any[], test: Function): boolean {\n for (var i = 0; i < array.length; i++) {\n if (!test(array[i], i, array)) {\n return false;\n }\n }\n return true;\n}\n\nexport function encodeParamsObject(data): string {\n return mapObject(data, function(value) {\n if (typeof value === 'object') {\n value = safeJSONStringify(value);\n }\n return encodeURIComponent(base64encode(value.toString()));\n });\n}\n\nexport function buildQueryString(data: any): string {\n var params = filterObject(data, function(value) {\n return value !== undefined;\n });\n\n var query = map(\n flatten(encodeParamsObject(params)),\n Util.method('join', '=')\n ).join('&');\n\n return query;\n}\n\n/**\n * See https://github.com/douglascrockford/JSON-js/blob/master/cycle.js\n *\n * Remove circular references from an object. Required for JSON.stringify in\n * React Native, which tends to blow up a lot.\n *\n * @param {any} object\n * @return {any} Decycled object\n */\nexport function decycleObject(object: any): any {\n var objects = [],\n paths = [];\n\n return (function derez(value, path) {\n var i, name, nu;\n\n switch (typeof value) {\n case 'object':\n if (!value) {\n return null;\n }\n for (i = 0; i < objects.length; i += 1) {\n if (objects[i] === value) {\n return { $ref: paths[i] };\n }\n }\n\n objects.push(value);\n paths.push(path);\n\n if (Object.prototype.toString.apply(value) === '[object Array]') {\n nu = [];\n for (i = 0; i < value.length; i += 1) {\n nu[i] = derez(value[i], path + '[' + i + ']');\n }\n } else {\n nu = {};\n for (name in value) {\n if (Object.prototype.hasOwnProperty.call(value, name)) {\n nu[name] = derez(\n value[name],\n path + '[' + JSON.stringify(name) + ']'\n );\n }\n }\n }\n return nu;\n case 'number':\n case 'string':\n case 'boolean':\n return value;\n }\n })(object, '$');\n}\n\n/**\n * Provides a cross-browser and cross-platform way to safely stringify objects\n * into JSON. This is particularly necessary for ReactNative, where circular JSON\n * structures throw an exception.\n *\n * @param {any} source The object to stringify\n * @return {string} The serialized output.\n */\nexport function safeJSONStringify(source: any): string {\n try {\n return JSON.stringify(source);\n } catch (e) {\n return JSON.stringify(decycleObject(source));\n }\n}\n","import {\n ChannelAuthorizationOptions,\n UserAuthenticationOptions\n} from './auth/options';\nimport { AuthTransport } from './config';\n\nexport interface DefaultConfig {\n VERSION: string;\n PROTOCOL: number;\n wsPort: number;\n wssPort: number;\n wsPath: string;\n httpHost: string;\n httpPort: number;\n httpsPort: number;\n httpPath: string;\n stats_host: string;\n authEndpoint: string;\n authTransport: AuthTransport;\n activityTimeout: number;\n pongTimeout: number;\n unavailableTimeout: number;\n userAuthentication: UserAuthenticationOptions;\n channelAuthorization: ChannelAuthorizationOptions;\n\n cdn_http?: string;\n cdn_https?: string;\n dependency_suffix?: string;\n}\n\nvar Defaults: DefaultConfig = {\n VERSION: VERSION,\n PROTOCOL: 7,\n\n wsPort: 80,\n wssPort: 443,\n wsPath: '',\n // DEPRECATED: SockJS fallback parameters\n httpHost: 'sockjs.pusher.com',\n httpPort: 80,\n httpsPort: 443,\n httpPath: '/pusher',\n // DEPRECATED: Stats\n stats_host: 'stats.pusher.com',\n // DEPRECATED: Other settings\n authEndpoint: '/pusher/auth',\n authTransport: 'ajax',\n activityTimeout: 120000,\n pongTimeout: 30000,\n unavailableTimeout: 10000,\n userAuthentication: {\n endpoint: '/pusher/user-auth',\n transport: 'ajax'\n },\n channelAuthorization: {\n endpoint: '/pusher/auth',\n transport: 'ajax'\n },\n\n // CDN configuration\n cdn_http: CDN_HTTP,\n cdn_https: CDN_HTTPS,\n dependency_suffix: DEPENDENCY_SUFFIX\n};\n\nexport default Defaults;\n","import Defaults from '../defaults';\nimport { default as URLScheme, URLSchemeParams } from './url_scheme';\n\nfunction getGenericURL(\n baseScheme: string,\n params: URLSchemeParams,\n path: string\n): string {\n var scheme = baseScheme + (params.useTLS ? 's' : '');\n var host = params.useTLS ? params.hostTLS : params.hostNonTLS;\n return scheme + '://' + host + path;\n}\n\nfunction getGenericPath(key: string, queryString?: string): string {\n var path = '/app/' + key;\n var query =\n '?protocol=' +\n Defaults.PROTOCOL +\n '&client=js' +\n '&version=' +\n Defaults.VERSION +\n (queryString ? '&' + queryString : '');\n return path + query;\n}\n\nexport var ws: URLScheme = {\n getInitial: function(key: string, params: URLSchemeParams): string {\n var path = (params.httpPath || '') + getGenericPath(key, 'flash=false');\n return getGenericURL('ws', params, path);\n }\n};\n\nexport var http: URLScheme = {\n getInitial: function(key: string, params: URLSchemeParams): string {\n var path = (params.httpPath || '/pusher') + getGenericPath(key);\n return getGenericURL('http', params, path);\n }\n};\n\nexport var sockjs: URLScheme = {\n getInitial: function(key: string, params: URLSchemeParams): string {\n return getGenericURL('http', params, params.httpPath || '/pusher');\n },\n getPath: function(key: string, params: URLSchemeParams): string {\n return getGenericPath(key);\n }\n};\n","import Callback from './callback';\nimport * as Collections from '../utils/collections';\nimport CallbackTable from './callback_table';\n\nexport default class CallbackRegistry {\n _callbacks: CallbackTable;\n\n constructor() {\n this._callbacks = {};\n }\n\n get(name: string): Callback[] {\n return this._callbacks[prefix(name)];\n }\n\n add(name: string, callback: Function, context: any) {\n var prefixedEventName = prefix(name);\n this._callbacks[prefixedEventName] =\n this._callbacks[prefixedEventName] || [];\n this._callbacks[prefixedEventName].push({\n fn: callback,\n context: context\n });\n }\n\n remove(name?: string, callback?: Function, context?: any) {\n if (!name && !callback && !context) {\n this._callbacks = {};\n return;\n }\n\n var names = name ? [prefix(name)] : Collections.keys(this._callbacks);\n\n if (callback || context) {\n this.removeCallback(names, callback, context);\n } else {\n this.removeAllCallbacks(names);\n }\n }\n\n private removeCallback(names: string[], callback: Function, context: any) {\n Collections.apply(\n names,\n function(name) {\n this._callbacks[name] = Collections.filter(\n this._callbacks[name] || [],\n function(binding) {\n return (\n (callback && callback !== binding.fn) ||\n (context && context !== binding.context)\n );\n }\n );\n if (this._callbacks[name].length === 0) {\n delete this._callbacks[name];\n }\n },\n this\n );\n }\n\n private removeAllCallbacks(names: string[]) {\n Collections.apply(\n names,\n function(name) {\n delete this._callbacks[name];\n },\n this\n );\n }\n}\n\nfunction prefix(name: string): string {\n return '_' + name;\n}\n","import * as Collections from '../utils/collections';\nimport Callback from './callback';\nimport Metadata from '../channels/metadata';\nimport CallbackRegistry from './callback_registry';\n\n/** Manages callback bindings and event emitting.\n *\n * @param Function failThrough called when no listeners are bound to an event\n */\nexport default class Dispatcher {\n callbacks: CallbackRegistry;\n global_callbacks: Function[];\n failThrough: Function;\n\n constructor(failThrough?: Function) {\n this.callbacks = new CallbackRegistry();\n this.global_callbacks = [];\n this.failThrough = failThrough;\n }\n\n bind(eventName: string, callback: Function, context?: any) {\n this.callbacks.add(eventName, callback, context);\n return this;\n }\n\n bind_global(callback: Function) {\n this.global_callbacks.push(callback);\n return this;\n }\n\n unbind(eventName?: string, callback?: Function, context?: any) {\n this.callbacks.remove(eventName, callback, context);\n return this;\n }\n\n unbind_global(callback?: Function) {\n if (!callback) {\n this.global_callbacks = [];\n return this;\n }\n\n this.global_callbacks = Collections.filter(\n this.global_callbacks || [],\n c => c !== callback\n );\n\n return this;\n }\n\n unbind_all() {\n this.unbind();\n this.unbind_global();\n return this;\n }\n\n emit(eventName: string, data?: any, metadata?: Metadata): Dispatcher {\n for (var i = 0; i < this.global_callbacks.length; i++) {\n this.global_callbacks[i](eventName, data);\n }\n\n var callbacks = this.callbacks.get(eventName);\n var args = [];\n\n if (metadata) {\n // if there's a metadata argument, we need to call the callback with both\n // data and metadata regardless of whether data is undefined\n args.push(data, metadata);\n } else if (data) {\n // metadata is undefined, so we only need to call the callback with data\n // if data exists\n args.push(data);\n }\n\n if (callbacks && callbacks.length > 0) {\n for (var i = 0; i < callbacks.length; i++) {\n callbacks[i].fn.apply(callbacks[i].context || global, args);\n }\n } else if (this.failThrough) {\n this.failThrough(eventName, data);\n }\n\n return this;\n }\n}\n","import { stringify } from './utils/collections';\nimport Pusher from './pusher';\n\nclass Logger {\n debug(...args: any[]) {\n this.log(this.globalLog, args);\n }\n\n warn(...args: any[]) {\n this.log(this.globalLogWarn, args);\n }\n\n error(...args: any[]) {\n this.log(this.globalLogError, args);\n }\n\n private globalLog = (message: string) => {\n if (global.console && global.console.log) {\n global.console.log(message);\n }\n };\n\n private globalLogWarn(message: string) {\n if (global.console && global.console.warn) {\n global.console.warn(message);\n } else {\n this.globalLog(message);\n }\n }\n\n private globalLogError(message: string) {\n if (global.console && global.console.error) {\n global.console.error(message);\n } else {\n this.globalLogWarn(message);\n }\n }\n\n private log(\n defaultLoggingFunction: (message: string) => void,\n ...args: any[]\n ) {\n var message = stringify.apply(this, arguments);\n if (Pusher.log) {\n Pusher.log(message);\n } else if (Pusher.logToConsole) {\n const log = defaultLoggingFunction.bind(this);\n log(message);\n }\n }\n}\n\nexport default new Logger();\n","import Util from '../util';\nimport * as Collections from '../utils/collections';\nimport { default as EventsDispatcher } from '../events/dispatcher';\nimport Logger from '../logger';\nimport TransportHooks from './transport_hooks';\nimport Socket from '../socket';\nimport Runtime from 'runtime';\nimport Timeline from '../timeline/timeline';\nimport TransportConnectionOptions from './transport_connection_options';\n\n/** Provides universal API for transport connections.\n *\n * Transport connection is a low-level object that wraps a connection method\n * and exposes a simple evented interface for the connection state and\n * messaging. It does not implement Pusher-specific WebSocket protocol.\n *\n * Additionally, it fetches resources needed for transport to work and exposes\n * an interface for querying transport features.\n *\n * States:\n * - new - initial state after constructing the object\n * - initializing - during initialization phase, usually fetching resources\n * - intialized - ready to establish a connection\n * - connection - when connection is being established\n * - open - when connection ready to be used\n * - closed - after connection was closed be either side\n *\n * Emits:\n * - error - after the connection raised an error\n *\n * Options:\n * - useTLS - whether connection should be over TLS\n * - hostTLS - host to connect to when connection is over TLS\n * - hostNonTLS - host to connect to when connection is over TLS\n *\n * @param {String} key application key\n * @param {Object} options\n */\nexport default class TransportConnection extends EventsDispatcher {\n hooks: TransportHooks;\n name: string;\n priority: number;\n key: string;\n options: TransportConnectionOptions;\n state: string;\n timeline: Timeline;\n activityTimeout: number;\n id: number;\n socket: Socket;\n beforeOpen: Function;\n initialize: Function;\n\n constructor(\n hooks: TransportHooks,\n name: string,\n priority: number,\n key: string,\n options: TransportConnectionOptions\n ) {\n super();\n this.initialize = Runtime.transportConnectionInitializer;\n this.hooks = hooks;\n this.name = name;\n this.priority = priority;\n this.key = key;\n this.options = options;\n\n this.state = 'new';\n this.timeline = options.timeline;\n this.activityTimeout = options.activityTimeout;\n this.id = this.timeline.generateUniqueID();\n }\n\n /** Checks whether the transport handles activity checks by itself.\n *\n * @return {Boolean}\n */\n handlesActivityChecks(): boolean {\n return Boolean(this.hooks.handlesActivityChecks);\n }\n\n /** Checks whether the transport supports the ping/pong API.\n *\n * @return {Boolean}\n */\n supportsPing(): boolean {\n return Boolean(this.hooks.supportsPing);\n }\n\n /** Tries to establish a connection.\n *\n * @returns {Boolean} false if transport is in invalid state\n */\n connect(): boolean {\n if (this.socket || this.state !== 'initialized') {\n return false;\n }\n\n var url = this.hooks.urls.getInitial(this.key, this.options);\n try {\n this.socket = this.hooks.getSocket(url, this.options);\n } catch (e) {\n Util.defer(() => {\n this.onError(e);\n this.changeState('closed');\n });\n return false;\n }\n\n this.bindListeners();\n\n Logger.debug('Connecting', { transport: this.name, url });\n this.changeState('connecting');\n return true;\n }\n\n /** Closes the connection.\n *\n * @return {Boolean} true if there was a connection to close\n */\n close(): boolean {\n if (this.socket) {\n this.socket.close();\n return true;\n } else {\n return false;\n }\n }\n\n /** Sends data over the open connection.\n *\n * @param {String} data\n * @return {Boolean} true only when in the \"open\" state\n */\n send(data: any): boolean {\n if (this.state === 'open') {\n // Workaround for MobileSafari bug (see https://gist.github.com/2052006)\n Util.defer(() => {\n if (this.socket) {\n this.socket.send(data);\n }\n });\n return true;\n } else {\n return false;\n }\n }\n\n /** Sends a ping if the connection is open and transport supports it. */\n ping() {\n if (this.state === 'open' && this.supportsPing()) {\n this.socket.ping();\n }\n }\n\n private onOpen() {\n if (this.hooks.beforeOpen) {\n this.hooks.beforeOpen(\n this.socket,\n this.hooks.urls.getPath(this.key, this.options)\n );\n }\n this.changeState('open');\n this.socket.onopen = undefined;\n }\n\n private onError(error) {\n this.emit('error', { type: 'WebSocketError', error: error });\n this.timeline.error(this.buildTimelineMessage({ error: error.toString() }));\n }\n\n private onClose(closeEvent?: any) {\n if (closeEvent) {\n this.changeState('closed', {\n code: closeEvent.code,\n reason: closeEvent.reason,\n wasClean: closeEvent.wasClean\n });\n } else {\n this.changeState('closed');\n }\n this.unbindListeners();\n this.socket = undefined;\n }\n\n private onMessage(message) {\n this.emit('message', message);\n }\n\n private onActivity() {\n this.emit('activity');\n }\n\n private bindListeners() {\n this.socket.onopen = () => {\n this.onOpen();\n };\n this.socket.onerror = error => {\n this.onError(error);\n };\n this.socket.onclose = closeEvent => {\n this.onClose(closeEvent);\n };\n this.socket.onmessage = message => {\n this.onMessage(message);\n };\n\n if (this.supportsPing()) {\n this.socket.onactivity = () => {\n this.onActivity();\n };\n }\n }\n\n private unbindListeners() {\n if (this.socket) {\n this.socket.onopen = undefined;\n this.socket.onerror = undefined;\n this.socket.onclose = undefined;\n this.socket.onmessage = undefined;\n if (this.supportsPing()) {\n this.socket.onactivity = undefined;\n }\n }\n }\n\n private changeState(state: string, params?: any) {\n this.state = state;\n this.timeline.info(\n this.buildTimelineMessage({\n state: state,\n params: params\n })\n );\n this.emit(state, params);\n }\n\n buildTimelineMessage(message): any {\n return Collections.extend({ cid: this.id }, message);\n }\n}\n","import Factory from '../utils/factory';\nimport TransportHooks from './transport_hooks';\nimport TransportConnection from './transport_connection';\nimport TransportConnectionOptions from './transport_connection_options';\n\n/** Provides interface for transport connection instantiation.\n *\n * Takes transport-specific hooks as the only argument, which allow checking\n * for transport support and creating its connections.\n *\n * Supported hooks: * - file - the name of the file to be fetched during initialization\n * - urls - URL scheme to be used by transport\n * - handlesActivityCheck - true when the transport handles activity checks\n * - supportsPing - true when the transport has a ping/activity API\n * - isSupported - tells whether the transport is supported in the environment\n * - getSocket - creates a WebSocket-compatible transport socket\n *\n * See transports.js for specific implementations.\n *\n * @param {Object} hooks object containing all needed transport hooks\n */\nexport default class Transport {\n hooks: TransportHooks;\n\n constructor(hooks: TransportHooks) {\n this.hooks = hooks;\n }\n\n /** Returns whether the transport is supported in the environment.\n *\n * @param {Object} envronment te environment details (encryption, settings)\n * @returns {Boolean} true when the transport is supported\n */\n isSupported(environment: any): boolean {\n return this.hooks.isSupported(environment);\n }\n\n /** Creates a transport connection.\n *\n * @param {String} name\n * @param {Number} priority\n * @param {String} key the application key\n * @param {Object} options\n * @returns {TransportConnection}\n */\n createConnection(\n name: string,\n priority: number,\n key: string,\n options: any\n ): TransportConnection {\n return new TransportConnection(this.hooks, name, priority, key, options);\n }\n}\n","import * as URLSchemes from 'core/transports/url_schemes';\nimport URLScheme from 'core/transports/url_scheme';\nimport Transport from 'core/transports/transport';\nimport Util from 'core/util';\nimport * as Collections from 'core/utils/collections';\nimport TransportHooks from 'core/transports/transport_hooks';\nimport TransportsTable from 'core/transports/transports_table';\nimport Runtime from 'runtime';\n\n/** WebSocket transport.\n *\n * Uses native WebSocket implementation, including MozWebSocket supported by\n * earlier Firefox versions.\n */\nvar WSTransport = new Transport({\n urls: URLSchemes.ws,\n handlesActivityChecks: false,\n supportsPing: false,\n\n isInitialized: function() {\n return Boolean(Runtime.getWebSocketAPI());\n },\n isSupported: function(): boolean {\n return Boolean(Runtime.getWebSocketAPI());\n },\n getSocket: function(url) {\n return Runtime.createWebSocket(url);\n }\n});\n\nvar httpConfiguration = {\n urls: URLSchemes.http,\n handlesActivityChecks: false,\n supportsPing: true,\n isInitialized: function() {\n return true;\n }\n};\n\nexport var streamingConfiguration = Collections.extend(\n {\n getSocket: function(url) {\n return Runtime.HTTPFactory.createStreamingSocket(url);\n }\n },\n httpConfiguration\n);\nexport var pollingConfiguration = Collections.extend(\n {\n getSocket: function(url) {\n return Runtime.HTTPFactory.createPollingSocket(url);\n }\n },\n httpConfiguration\n);\n\nvar xhrConfiguration = {\n isSupported: function(): boolean {\n return Runtime.isXHRSupported();\n }\n};\n\n/** HTTP streaming transport using CORS-enabled XMLHttpRequest. */\nvar XHRStreamingTransport = new Transport(\n (\n Collections.extend({}, streamingConfiguration, xhrConfiguration)\n )\n);\n\n/** HTTP long-polling transport using CORS-enabled XMLHttpRequest. */\nvar XHRPollingTransport = new Transport(\n Collections.extend({}, pollingConfiguration, xhrConfiguration)\n);\n\nvar Transports: TransportsTable = {\n ws: WSTransport,\n xhr_streaming: XHRStreamingTransport,\n xhr_polling: XHRPollingTransport\n};\n\nexport default Transports;\n","import Util from '../util';\nimport * as Collections from '../utils/collections';\nimport TransportManager from './transport_manager';\nimport TransportConnection from './transport_connection';\nimport Transport from './transport';\nimport PingDelayOptions from './ping_delay_options';\n\n/** Creates transport connections monitored by a transport manager.\n *\n * When a transport is closed, it might mean the environment does not support\n * it. It's possible that messages get stuck in an intermediate buffer or\n * proxies terminate inactive connections. To combat these problems,\n * assistants monitor the connection lifetime, report unclean exits and\n * adjust ping timeouts to keep the connection active. The decision to disable\n * a transport is the manager's responsibility.\n *\n * @param {TransportManager} manager\n * @param {TransportConnection} transport\n * @param {Object} options\n */\nexport default class AssistantToTheTransportManager {\n manager: TransportManager;\n transport: Transport;\n minPingDelay: number;\n maxPingDelay: number;\n pingDelay: number;\n\n constructor(\n manager: TransportManager,\n transport: Transport,\n options: PingDelayOptions\n ) {\n this.manager = manager;\n this.transport = transport;\n this.minPingDelay = options.minPingDelay;\n this.maxPingDelay = options.maxPingDelay;\n this.pingDelay = undefined;\n }\n\n /** Creates a transport connection.\n *\n * This function has the same API as Transport#createConnection.\n *\n * @param {String} name\n * @param {Number} priority\n * @param {String} key the application key\n * @param {Object} options\n * @returns {TransportConnection}\n */\n createConnection(\n name: string,\n priority: number,\n key: string,\n options: Object\n ): TransportConnection {\n options = Collections.extend({}, options, {\n activityTimeout: this.pingDelay\n });\n var connection = this.transport.createConnection(\n name,\n priority,\n key,\n options\n );\n\n var openTimestamp = null;\n\n var onOpen = function() {\n connection.unbind('open', onOpen);\n connection.bind('closed', onClosed);\n openTimestamp = Util.now();\n };\n var onClosed = closeEvent => {\n connection.unbind('closed', onClosed);\n\n if (closeEvent.code === 1002 || closeEvent.code === 1003) {\n // we don't want to use transports not obeying the protocol\n this.manager.reportDeath();\n } else if (!closeEvent.wasClean && openTimestamp) {\n // report deaths only for short-living transport\n var lifespan = Util.now() - openTimestamp;\n if (lifespan < 2 * this.maxPingDelay) {\n this.manager.reportDeath();\n this.pingDelay = Math.max(lifespan / 2, this.minPingDelay);\n }\n }\n };\n\n connection.bind('open', onOpen);\n return connection;\n }\n\n /** Returns whether the transport is supported in the environment.\n *\n * This function has the same API as Transport#isSupported. Might return false\n * when the manager decides to kill the transport.\n *\n * @param {Object} environment the environment details (encryption, settings)\n * @returns {Boolean} true when the transport is supported\n */\n isSupported(environment: string): boolean {\n return this.manager.isAlive() && this.transport.isSupported(environment);\n }\n}\n","import Action from './action';\nimport { PusherEvent } from './message-types';\n/**\n * Provides functions for handling Pusher protocol-specific messages.\n */\n\nconst Protocol = {\n /**\n * Decodes a message in a Pusher format.\n *\n * The MessageEvent we receive from the transport should contain a pusher event\n * (https://pusher.com/docs/pusher_protocol#events) serialized as JSON in the\n * data field\n *\n * The pusher event may contain a data field too, and it may also be\n * serialised as JSON\n *\n * Throws errors when messages are not parse'able.\n *\n * @param {MessageEvent} messageEvent\n * @return {PusherEvent}\n */\n decodeMessage: function(messageEvent: MessageEvent): PusherEvent {\n try {\n var messageData = JSON.parse(messageEvent.data);\n var pusherEventData = messageData.data;\n if (typeof pusherEventData === 'string') {\n try {\n pusherEventData = JSON.parse(messageData.data);\n } catch (e) {}\n }\n var pusherEvent: PusherEvent = {\n event: messageData.event,\n channel: messageData.channel,\n data: pusherEventData\n };\n if (messageData.user_id) {\n pusherEvent.user_id = messageData.user_id;\n }\n return pusherEvent;\n } catch (e) {\n throw { type: 'MessageParseError', error: e, data: messageEvent.data };\n }\n },\n\n /**\n * Encodes a message to be sent.\n *\n * @param {PusherEvent} event\n * @return {String}\n */\n encodeMessage: function(event: PusherEvent): string {\n return JSON.stringify(event);\n },\n\n /**\n * Processes a handshake message and returns appropriate actions.\n *\n * Returns an object with an 'action' and other action-specific properties.\n *\n * There are three outcomes when calling this function. First is a successful\n * connection attempt, when pusher:connection_established is received, which\n * results in a 'connected' action with an 'id' property. When passed a\n * pusher:error event, it returns a result with action appropriate to the\n * close code and an error. Otherwise, it raises an exception.\n *\n * @param {String} message\n * @result Object\n */\n processHandshake: function(messageEvent: MessageEvent): Action {\n var message = Protocol.decodeMessage(messageEvent);\n\n if (message.event === 'pusher:connection_established') {\n if (!message.data.activity_timeout) {\n throw 'No activity timeout specified in handshake';\n }\n return {\n action: 'connected',\n id: message.data.socket_id,\n activityTimeout: message.data.activity_timeout * 1000\n };\n } else if (message.event === 'pusher:error') {\n // From protocol 6 close codes are sent only once, so this only\n // happens when connection does not support close codes\n return {\n action: this.getCloseAction(message.data),\n error: this.getCloseError(message.data)\n };\n } else {\n throw 'Invalid handshake';\n }\n },\n\n /**\n * Dispatches the close event and returns an appropriate action name.\n *\n * See:\n * 1. https://developer.mozilla.org/en-US/docs/WebSockets/WebSockets_reference/CloseEvent\n * 2. http://pusher.com/docs/pusher_protocol\n *\n * @param {CloseEvent} closeEvent\n * @return {String} close action name\n */\n getCloseAction: function(closeEvent): string {\n if (closeEvent.code < 4000) {\n // ignore 1000 CLOSE_NORMAL, 1001 CLOSE_GOING_AWAY,\n // 1005 CLOSE_NO_STATUS, 1006 CLOSE_ABNORMAL\n // ignore 1007...3999\n // handle 1002 CLOSE_PROTOCOL_ERROR, 1003 CLOSE_UNSUPPORTED,\n // 1004 CLOSE_TOO_LARGE\n if (closeEvent.code >= 1002 && closeEvent.code <= 1004) {\n return 'backoff';\n } else {\n return null;\n }\n } else if (closeEvent.code === 4000) {\n return 'tls_only';\n } else if (closeEvent.code < 4100) {\n return 'refused';\n } else if (closeEvent.code < 4200) {\n return 'backoff';\n } else if (closeEvent.code < 4300) {\n return 'retry';\n } else {\n // unknown error\n return 'refused';\n }\n },\n\n /**\n * Returns an error or null basing on the close event.\n *\n * Null is returned when connection was closed cleanly. Otherwise, an object\n * with error details is returned.\n *\n * @param {CloseEvent} closeEvent\n * @return {Object} error object\n */\n getCloseError: function(closeEvent): any {\n if (closeEvent.code !== 1000 && closeEvent.code !== 1001) {\n return {\n type: 'PusherError',\n data: {\n code: closeEvent.code,\n message: closeEvent.reason || closeEvent.message\n }\n };\n } else {\n return null;\n }\n }\n};\n\nexport default Protocol;\n","import * as Collections from '../utils/collections';\nimport { default as EventsDispatcher } from '../events/dispatcher';\nimport Protocol from './protocol/protocol';\nimport { PusherEvent } from './protocol/message-types';\nimport Logger from '../logger';\nimport TransportConnection from '../transports/transport_connection';\nimport Socket from '../socket';\n/**\n * Provides Pusher protocol interface for transports.\n *\n * Emits following events:\n * - message - on received messages\n * - ping - on ping requests\n * - pong - on pong responses\n * - error - when the transport emits an error\n * - closed - after closing the transport\n *\n * It also emits more events when connection closes with a code.\n * See Protocol.getCloseAction to get more details.\n *\n * @param {Number} id\n * @param {AbstractTransport} transport\n */\nexport default class Connection extends EventsDispatcher implements Socket {\n id: string;\n transport: TransportConnection;\n activityTimeout: number;\n\n constructor(id: string, transport: TransportConnection) {\n super();\n this.id = id;\n this.transport = transport;\n this.activityTimeout = transport.activityTimeout;\n this.bindListeners();\n }\n\n /** Returns whether used transport handles activity checks by itself\n *\n * @returns {Boolean} true if activity checks are handled by the transport\n */\n handlesActivityChecks() {\n return this.transport.handlesActivityChecks();\n }\n\n /** Sends raw data.\n *\n * @param {String} data\n */\n send(data: any): boolean {\n return this.transport.send(data);\n }\n\n /** Sends an event.\n *\n * @param {String} name\n * @param {String} data\n * @param {String} [channel]\n * @returns {Boolean} whether message was sent or not\n */\n send_event(name: string, data: any, channel?: string): boolean {\n var event: PusherEvent = { event: name, data: data };\n if (channel) {\n event.channel = channel;\n }\n Logger.debug('Event sent', event);\n return this.send(Protocol.encodeMessage(event));\n }\n\n /** Sends a ping message to the server.\n *\n * Basing on the underlying transport, it might send either transport's\n * protocol-specific ping or pusher:ping event.\n */\n ping() {\n if (this.transport.supportsPing()) {\n this.transport.ping();\n } else {\n this.send_event('pusher:ping', {});\n }\n }\n\n /** Closes the connection. */\n close() {\n this.transport.close();\n }\n\n private bindListeners() {\n var listeners = {\n message: (messageEvent: MessageEvent) => {\n var pusherEvent;\n try {\n pusherEvent = Protocol.decodeMessage(messageEvent);\n } catch (e) {\n this.emit('error', {\n type: 'MessageParseError',\n error: e,\n data: messageEvent.data\n });\n }\n\n if (pusherEvent !== undefined) {\n Logger.debug('Event recd', pusherEvent);\n\n switch (pusherEvent.event) {\n case 'pusher:error':\n this.emit('error', {\n type: 'PusherError',\n data: pusherEvent.data\n });\n break;\n case 'pusher:ping':\n this.emit('ping');\n break;\n case 'pusher:pong':\n this.emit('pong');\n break;\n }\n this.emit('message', pusherEvent);\n }\n },\n activity: () => {\n this.emit('activity');\n },\n error: error => {\n this.emit('error', error);\n },\n closed: closeEvent => {\n unbindListeners();\n\n if (closeEvent && closeEvent.code) {\n this.handleCloseEvent(closeEvent);\n }\n\n this.transport = null;\n this.emit('closed');\n }\n };\n\n var unbindListeners = () => {\n Collections.objectApply(listeners, (listener, event) => {\n this.transport.unbind(event, listener);\n });\n };\n\n Collections.objectApply(listeners, (listener, event) => {\n this.transport.bind(event, listener);\n });\n }\n\n private handleCloseEvent(closeEvent: any) {\n var action = Protocol.getCloseAction(closeEvent);\n var error = Protocol.getCloseError(closeEvent);\n if (error) {\n this.emit('error', error);\n }\n if (action) {\n this.emit(action, { action: action, error: error });\n }\n }\n}\n","import Util from '../../util';\nimport * as Collections from '../../utils/collections';\nimport Protocol from '../protocol/protocol';\nimport Connection from '../connection';\nimport TransportConnection from '../../transports/transport_connection';\nimport HandshakePayload from './handshake_payload';\n\n/**\n * Handles Pusher protocol handshakes for transports.\n *\n * Calls back with a result object after handshake is completed. Results\n * always have two fields:\n * - action - string describing action to be taken after the handshake\n * - transport - the transport object passed to the constructor\n *\n * Different actions can set different additional properties on the result.\n * In the case of 'connected' action, there will be a 'connection' property\n * containing a Connection object for the transport. Other actions should\n * carry an 'error' property.\n *\n * @param {AbstractTransport} transport\n * @param {Function} callback\n */\nexport default class Handshake {\n transport: TransportConnection;\n callback: (HandshakePayload) => void;\n onMessage: Function;\n onClosed: Function;\n\n constructor(\n transport: TransportConnection,\n callback: (HandshakePayload) => void\n ) {\n this.transport = transport;\n this.callback = callback;\n this.bindListeners();\n }\n\n close() {\n this.unbindListeners();\n this.transport.close();\n }\n\n private bindListeners() {\n this.onMessage = m => {\n this.unbindListeners();\n\n var result;\n try {\n result = Protocol.processHandshake(m);\n } catch (e) {\n this.finish('error', { error: e });\n this.transport.close();\n return;\n }\n\n if (result.action === 'connected') {\n this.finish('connected', {\n connection: new Connection(result.id, this.transport),\n activityTimeout: result.activityTimeout\n });\n } else {\n this.finish(result.action, { error: result.error });\n this.transport.close();\n }\n };\n\n this.onClosed = closeEvent => {\n this.unbindListeners();\n\n var action = Protocol.getCloseAction(closeEvent) || 'backoff';\n var error = Protocol.getCloseError(closeEvent);\n this.finish(action, { error: error });\n };\n\n this.transport.bind('message', this.onMessage);\n this.transport.bind('closed', this.onClosed);\n }\n\n private unbindListeners() {\n this.transport.unbind('message', this.onMessage);\n this.transport.unbind('closed', this.onClosed);\n }\n\n private finish(action: string, params: any) {\n this.callback(\n Collections.extend({ transport: this.transport, action: action }, params)\n );\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport base64encode from '../base64';\nimport Timeline from './timeline';\nimport Runtime from 'runtime';\n\nexport interface TimelineSenderOptions {\n host?: string;\n port?: number;\n path?: string;\n}\n\nexport default class TimelineSender {\n timeline: Timeline;\n options: TimelineSenderOptions;\n host: string;\n\n constructor(timeline: Timeline, options: TimelineSenderOptions) {\n this.timeline = timeline;\n this.options = options || {};\n }\n\n send(useTLS: boolean, callback?: Function) {\n if (this.timeline.isEmpty()) {\n return;\n }\n\n this.timeline.send(\n Runtime.TimelineTransport.getAgent(this, useTLS),\n callback\n );\n }\n}\n","/** Error classes used throughout the library. */\n// https://github.com/Microsoft/TypeScript-wiki/blob/master/Breaking-Changes.md#extending-built-ins-like-error-array-and-map-may-no-longer-work\nexport class BadEventName extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\nexport class BadChannelName extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\nexport class RequestTimedOut extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class TransportPriorityTooLow extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class TransportClosed extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class UnsupportedFeature extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class UnsupportedTransport extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class UnsupportedStrategy extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class HTTPAuthError extends Error {\n status: number;\n constructor(status: number, msg?: string) {\n super(msg);\n this.status = status;\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n","/**\n * A place to store help URLs for error messages etc\n */\n\nconst urlStore = {\n baseUrl: 'https://pusher.com',\n urls: {\n authenticationEndpoint: {\n path: '/docs/channels/server_api/authenticating_users'\n },\n authorizationEndpoint: {\n path: '/docs/channels/server_api/authorizing-users/'\n },\n javascriptQuickStart: {\n path: '/docs/javascript_quick_start'\n },\n triggeringClientEvents: {\n path: '/docs/client_api_guide/client_events#trigger-events'\n },\n encryptedChannelSupport: {\n fullUrl:\n 'https://github.com/pusher/pusher-js/tree/cc491015371a4bde5743d1c87a0fbac0feb53195#encrypted-channel-support'\n }\n }\n};\n\n/** Builds a consistent string with links to pusher documentation\n *\n * @param {string} key - relevant key in the url_store.urls object\n * @return {string} suffix string to append to log message\n */\nconst buildLogSuffix = function(key: string): string {\n const urlPrefix = 'See:';\n const urlObj = urlStore.urls[key];\n if (!urlObj) return '';\n\n let url;\n if (urlObj.fullUrl) {\n url = urlObj.fullUrl;\n } else if (urlObj.path) {\n url = urlStore.baseUrl + urlObj.path;\n }\n\n if (!url) return '';\n return `${urlPrefix} ${url}`;\n};\n\nexport default { buildLogSuffix };\n","import { default as EventsDispatcher } from '../events/dispatcher';\nimport * as Errors from '../errors';\nimport Logger from '../logger';\nimport Pusher from '../pusher';\nimport { PusherEvent } from '../connection/protocol/message-types';\nimport Metadata from './metadata';\nimport UrlStore from '../utils/url_store';\nimport {\n ChannelAuthorizationData,\n ChannelAuthorizationCallback\n} from '../auth/options';\nimport { HTTPAuthError } from '../errors';\n\n/** Provides base public channel interface with an event emitter.\n *\n * Emits:\n * - pusher:subscription_succeeded - after subscribing successfully\n * - other non-internal events\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\nexport default class Channel extends EventsDispatcher {\n name: string;\n pusher: Pusher;\n subscribed: boolean;\n subscriptionPending: boolean;\n subscriptionCancelled: boolean;\n subscriptionCount: null;\n\n constructor(name: string, pusher: Pusher) {\n super(function(event, data) {\n Logger.debug('No callbacks on ' + name + ' for ' + event);\n });\n\n this.name = name;\n this.pusher = pusher;\n this.subscribed = false;\n this.subscriptionPending = false;\n this.subscriptionCancelled = false;\n }\n\n /** Skips authorization, since public channels don't require it.\n *\n * @param {Function} callback\n */\n authorize(socketId: string, callback: ChannelAuthorizationCallback) {\n return callback(null, { auth: '' });\n }\n\n /** Triggers an event */\n trigger(event: string, data: any) {\n if (event.indexOf('client-') !== 0) {\n throw new Errors.BadEventName(\n \"Event '\" + event + \"' does not start with 'client-'\"\n );\n }\n if (!this.subscribed) {\n var suffix = UrlStore.buildLogSuffix('triggeringClientEvents');\n Logger.warn(\n `Client event triggered before channel 'subscription_succeeded' event . ${suffix}`\n );\n }\n return this.pusher.send_event(event, data, this.name);\n }\n\n /** Signals disconnection to the channel. For internal use only. */\n disconnect() {\n this.subscribed = false;\n this.subscriptionPending = false;\n }\n\n /** Handles a PusherEvent. For internal use only.\n *\n * @param {PusherEvent} event\n */\n handleEvent(event: PusherEvent) {\n var eventName = event.event;\n var data = event.data;\n if (eventName === 'pusher_internal:subscription_succeeded') {\n this.handleSubscriptionSucceededEvent(event);\n } else if (eventName === 'pusher_internal:subscription_count') {\n this.handleSubscriptionCountEvent(event);\n } else if (eventName.indexOf('pusher_internal:') !== 0) {\n var metadata: Metadata = {};\n this.emit(eventName, data, metadata);\n }\n }\n\n handleSubscriptionSucceededEvent(event: PusherEvent) {\n this.subscriptionPending = false;\n this.subscribed = true;\n if (this.subscriptionCancelled) {\n this.pusher.unsubscribe(this.name);\n } else {\n this.emit('pusher:subscription_succeeded', event.data);\n }\n }\n\n handleSubscriptionCountEvent(event: PusherEvent) {\n if (event.data.subscription_count) {\n this.subscriptionCount = event.data.subscription_count;\n }\n\n this.emit('pusher:subscription_count', event.data);\n }\n\n /** Sends a subscription request. For internal use only. */\n subscribe() {\n if (this.subscribed) {\n return;\n }\n this.subscriptionPending = true;\n this.subscriptionCancelled = false;\n this.authorize(\n this.pusher.connection.socket_id,\n (error: Error | null, data: ChannelAuthorizationData) => {\n if (error) {\n this.subscriptionPending = false;\n // Why not bind to 'pusher:subscription_error' a level up, and log there?\n // Binding to this event would cause the warning about no callbacks being\n // bound (see constructor) to be suppressed, that's not what we want.\n Logger.error(error.toString());\n this.emit(\n 'pusher:subscription_error',\n Object.assign(\n {},\n {\n type: 'AuthError',\n error: error.message\n },\n error instanceof HTTPAuthError ? { status: error.status } : {}\n )\n );\n } else {\n this.pusher.send_event('pusher:subscribe', {\n auth: data.auth,\n channel_data: data.channel_data,\n channel: this.name\n });\n }\n }\n );\n }\n\n /** Sends an unsubscription request. For internal use only. */\n unsubscribe() {\n this.subscribed = false;\n this.pusher.send_event('pusher:unsubscribe', {\n channel: this.name\n });\n }\n\n /** Cancels an in progress subscription. For internal use only. */\n cancelSubscription() {\n this.subscriptionCancelled = true;\n }\n\n /** Reinstates an in progress subscripiton. For internal use only. */\n reinstateSubscription() {\n this.subscriptionCancelled = false;\n }\n}\n","import Factory from '../utils/factory';\nimport Channel from './channel';\nimport { ChannelAuthorizationCallback } from '../auth/options';\n\n/** Extends public channels to provide private channel interface.\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\nexport default class PrivateChannel extends Channel {\n /** Authorizes the connection to use the channel.\n *\n * @param {String} socketId\n * @param {Function} callback\n */\n authorize(socketId: string, callback: ChannelAuthorizationCallback) {\n return this.pusher.config.channelAuthorizer(\n {\n channelName: this.name,\n socketId: socketId\n },\n callback\n );\n }\n}\n","import * as Collections from '../utils/collections';\n\n/** Represents a collection of members of a presence channel. */\nexport default class Members {\n members: any;\n count: number;\n myID: any;\n me: any;\n\n constructor() {\n this.reset();\n }\n\n /** Returns member's info for given id.\n *\n * Resulting object containts two fields - id and info.\n *\n * @param {Number} id\n * @return {Object} member's info or null\n */\n get(id: string): any {\n if (Object.prototype.hasOwnProperty.call(this.members, id)) {\n return {\n id: id,\n info: this.members[id]\n };\n } else {\n return null;\n }\n }\n\n /** Calls back for each member in unspecified order.\n *\n * @param {Function} callback\n */\n each(callback: Function) {\n Collections.objectApply(this.members, (member, id) => {\n callback(this.get(id));\n });\n }\n\n /** Updates the id for connected member. For internal use only. */\n setMyID(id: string) {\n this.myID = id;\n }\n\n /** Handles subscription data. For internal use only. */\n onSubscription(subscriptionData: any) {\n this.members = subscriptionData.presence.hash;\n this.count = subscriptionData.presence.count;\n this.me = this.get(this.myID);\n }\n\n /** Adds a new member to the collection. For internal use only. */\n addMember(memberData: any) {\n if (this.get(memberData.user_id) === null) {\n this.count++;\n }\n this.members[memberData.user_id] = memberData.user_info;\n return this.get(memberData.user_id);\n }\n\n /** Adds a member from the collection. For internal use only. */\n removeMember(memberData: any) {\n var member = this.get(memberData.user_id);\n if (member) {\n delete this.members[memberData.user_id];\n this.count--;\n }\n return member;\n }\n\n /** Resets the collection to the initial state. For internal use only. */\n reset() {\n this.members = {};\n this.count = 0;\n this.myID = null;\n this.me = null;\n }\n}\n","import PrivateChannel from './private_channel';\nimport Logger from '../logger';\nimport Members from './members';\nimport Pusher from '../pusher';\nimport UrlStore from 'core/utils/url_store';\nimport { PusherEvent } from '../connection/protocol/message-types';\nimport Metadata from './metadata';\nimport { ChannelAuthorizationData } from '../auth/options';\n\nexport default class PresenceChannel extends PrivateChannel {\n members: Members;\n\n /** Adds presence channel functionality to private channels.\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\n constructor(name: string, pusher: Pusher) {\n super(name, pusher);\n this.members = new Members();\n }\n\n /** Authorizes the connection as a member of the channel.\n *\n * @param {String} socketId\n * @param {Function} callback\n */\n authorize(socketId: string, callback: Function) {\n super.authorize(socketId, async (error, authData) => {\n if (!error) {\n authData = authData as ChannelAuthorizationData;\n if (authData.channel_data != null) {\n var channelData = JSON.parse(authData.channel_data);\n this.members.setMyID(channelData.user_id);\n } else {\n await this.pusher.user.signinDonePromise;\n if (this.pusher.user.user_data != null) {\n // If the user is signed in, get the id of the authenticated user\n // and allow the presence authorization to continue.\n this.members.setMyID(this.pusher.user.user_data.id);\n } else {\n let suffix = UrlStore.buildLogSuffix('authorizationEndpoint');\n Logger.error(\n `Invalid auth response for channel '${this.name}', ` +\n `expected 'channel_data' field. ${suffix}, ` +\n `or the user should be signed in.`\n );\n callback('Invalid auth response');\n return;\n }\n }\n }\n callback(error, authData);\n });\n }\n\n /** Handles presence and subscription events. For internal use only.\n *\n * @param {PusherEvent} event\n */\n handleEvent(event: PusherEvent) {\n var eventName = event.event;\n if (eventName.indexOf('pusher_internal:') === 0) {\n this.handleInternalEvent(event);\n } else {\n var data = event.data;\n var metadata: Metadata = {};\n if (event.user_id) {\n metadata.user_id = event.user_id;\n }\n this.emit(eventName, data, metadata);\n }\n }\n handleInternalEvent(event: PusherEvent) {\n var eventName = event.event;\n var data = event.data;\n switch (eventName) {\n case 'pusher_internal:subscription_succeeded':\n this.handleSubscriptionSucceededEvent(event);\n break;\n case 'pusher_internal:subscription_count':\n this.handleSubscriptionCountEvent(event);\n break;\n case 'pusher_internal:member_added':\n var addedMember = this.members.addMember(data);\n this.emit('pusher:member_added', addedMember);\n break;\n case 'pusher_internal:member_removed':\n var removedMember = this.members.removeMember(data);\n if (removedMember) {\n this.emit('pusher:member_removed', removedMember);\n }\n break;\n }\n }\n\n handleSubscriptionSucceededEvent(event: PusherEvent) {\n this.subscriptionPending = false;\n this.subscribed = true;\n if (this.subscriptionCancelled) {\n this.pusher.unsubscribe(this.name);\n } else {\n this.members.onSubscription(event.data);\n this.emit('pusher:subscription_succeeded', this.members);\n }\n }\n\n /** Resets the channel state, including members map. For internal use only. */\n disconnect() {\n this.members.reset();\n super.disconnect();\n }\n}\n","import PrivateChannel from './private_channel';\nimport * as Errors from '../errors';\nimport Logger from '../logger';\nimport Pusher from '../pusher';\nimport { decode as encodeUTF8 } from '@stablelib/utf8';\nimport { decode as decodeBase64 } from '@stablelib/base64';\nimport Dispatcher from '../events/dispatcher';\nimport { PusherEvent } from '../connection/protocol/message-types';\nimport {\n ChannelAuthorizationData,\n ChannelAuthorizationCallback\n} from '../auth/options';\nimport * as nacl from 'tweetnacl';\n\n/** Extends private channels to provide encrypted channel interface.\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\nexport default class EncryptedChannel extends PrivateChannel {\n key: Uint8Array = null;\n nacl: nacl;\n\n constructor(name: string, pusher: Pusher, nacl: nacl) {\n super(name, pusher);\n this.nacl = nacl;\n }\n\n /** Authorizes the connection to use the channel.\n *\n * @param {String} socketId\n * @param {Function} callback\n */\n authorize(socketId: string, callback: ChannelAuthorizationCallback) {\n super.authorize(\n socketId,\n (error: Error | null, authData: ChannelAuthorizationData) => {\n if (error) {\n callback(error, authData);\n return;\n }\n let sharedSecret = authData['shared_secret'];\n if (!sharedSecret) {\n callback(\n new Error(\n `No shared_secret key in auth payload for encrypted channel: ${this.name}`\n ),\n null\n );\n return;\n }\n this.key = decodeBase64(sharedSecret);\n delete authData['shared_secret'];\n callback(null, authData);\n }\n );\n }\n\n trigger(event: string, data: any): boolean {\n throw new Errors.UnsupportedFeature(\n 'Client events are not currently supported for encrypted channels'\n );\n }\n\n /** Handles an event. For internal use only.\n *\n * @param {PusherEvent} event\n */\n handleEvent(event: PusherEvent) {\n var eventName = event.event;\n var data = event.data;\n if (\n eventName.indexOf('pusher_internal:') === 0 ||\n eventName.indexOf('pusher:') === 0\n ) {\n super.handleEvent(event);\n return;\n }\n this.handleEncryptedEvent(eventName, data);\n }\n\n private handleEncryptedEvent(event: string, data: any): void {\n if (!this.key) {\n Logger.debug(\n 'Received encrypted event before key has been retrieved from the authEndpoint'\n );\n return;\n }\n if (!data.ciphertext || !data.nonce) {\n Logger.error(\n 'Unexpected format for encrypted event, expected object with `ciphertext` and `nonce` fields, got: ' +\n data\n );\n return;\n }\n let cipherText = decodeBase64(data.ciphertext);\n if (cipherText.length < this.nacl.secretbox.overheadLength) {\n Logger.error(\n `Expected encrypted event ciphertext length to be ${this.nacl.secretbox.overheadLength}, got: ${cipherText.length}`\n );\n return;\n }\n let nonce = decodeBase64(data.nonce);\n if (nonce.length < this.nacl.secretbox.nonceLength) {\n Logger.error(\n `Expected encrypted event nonce length to be ${this.nacl.secretbox.nonceLength}, got: ${nonce.length}`\n );\n return;\n }\n\n let bytes = this.nacl.secretbox.open(cipherText, nonce, this.key);\n if (bytes === null) {\n Logger.debug(\n 'Failed to decrypt an event, probably because it was encrypted with a different key. Fetching a new key from the authEndpoint...'\n );\n // Try a single time to retrieve a new auth key and decrypt the event with it\n // If this fails, a new key will be requested when a new message is received\n this.authorize(this.pusher.connection.socket_id, (error, authData) => {\n if (error) {\n Logger.error(\n `Failed to make a request to the authEndpoint: ${authData}. Unable to fetch new key, so dropping encrypted event`\n );\n return;\n }\n bytes = this.nacl.secretbox.open(cipherText, nonce, this.key);\n if (bytes === null) {\n Logger.error(\n `Failed to decrypt event with new key. Dropping encrypted event`\n );\n return;\n }\n this.emit(event, this.getDataToEmit(bytes));\n return;\n });\n return;\n }\n this.emit(event, this.getDataToEmit(bytes));\n }\n\n // Try and parse the decrypted bytes as JSON. If we can't parse it, just\n // return the utf-8 string\n getDataToEmit(bytes: Uint8Array): string {\n let raw = encodeUTF8(bytes);\n try {\n return JSON.parse(raw);\n } catch {\n return raw;\n }\n }\n}\n","import { default as EventsDispatcher } from '../events/dispatcher';\nimport { OneOffTimer as Timer } from '../utils/timers';\nimport { Config } from '../config';\nimport Logger from '../logger';\nimport HandshakePayload from './handshake/handshake_payload';\nimport Connection from './connection';\nimport Strategy from '../strategies/strategy';\nimport StrategyRunner from '../strategies/strategy_runner';\nimport * as Collections from '../utils/collections';\nimport Timeline from '../timeline/timeline';\nimport ConnectionManagerOptions from './connection_manager_options';\nimport Runtime from 'runtime';\n\nimport {\n ErrorCallbacks,\n HandshakeCallbacks,\n ConnectionCallbacks\n} from './callbacks';\nimport Action from './protocol/action';\n\n/** Manages connection to Pusher.\n *\n * Uses a strategy (currently only default), timers and network availability\n * info to establish a connection and export its state. In case of failures,\n * manages reconnection attempts.\n *\n * Exports state changes as following events:\n * - \"state_change\", { previous: p, current: state }\n * - state\n *\n * States:\n * - initialized - initial state, never transitioned to\n * - connecting - connection is being established\n * - connected - connection has been fully established\n * - disconnected - on requested disconnection\n * - unavailable - after connection timeout or when there's no network\n * - failed - when the connection strategy is not supported\n *\n * Options:\n * - unavailableTimeout - time to transition to unavailable state\n * - activityTimeout - time after which ping message should be sent\n * - pongTimeout - time for Pusher to respond with pong before reconnecting\n *\n * @param {String} key application key\n * @param {Object} options\n */\nexport default class ConnectionManager extends EventsDispatcher {\n key: string;\n options: ConnectionManagerOptions;\n state: string;\n connection: Connection;\n usingTLS: boolean;\n timeline: Timeline;\n socket_id: string;\n unavailableTimer: Timer;\n activityTimer: Timer;\n retryTimer: Timer;\n activityTimeout: number;\n strategy: Strategy;\n runner: StrategyRunner;\n errorCallbacks: ErrorCallbacks;\n handshakeCallbacks: HandshakeCallbacks;\n connectionCallbacks: ConnectionCallbacks;\n\n constructor(key: string, options: ConnectionManagerOptions) {\n super();\n this.state = 'initialized';\n this.connection = null;\n\n this.key = key;\n this.options = options;\n this.timeline = this.options.timeline;\n this.usingTLS = this.options.useTLS;\n\n this.errorCallbacks = this.buildErrorCallbacks();\n this.connectionCallbacks = this.buildConnectionCallbacks(\n this.errorCallbacks\n );\n this.handshakeCallbacks = this.buildHandshakeCallbacks(this.errorCallbacks);\n\n var Network = Runtime.getNetwork();\n\n Network.bind('online', () => {\n this.timeline.info({ netinfo: 'online' });\n if (this.state === 'connecting' || this.state === 'unavailable') {\n this.retryIn(0);\n }\n });\n Network.bind('offline', () => {\n this.timeline.info({ netinfo: 'offline' });\n if (this.connection) {\n this.sendActivityCheck();\n }\n });\n\n this.updateStrategy();\n }\n\n /** Establishes a connection to Pusher.\n *\n * Does nothing when connection is already established. See top-level doc\n * to find events emitted on connection attempts.\n */\n connect() {\n if (this.connection || this.runner) {\n return;\n }\n if (!this.strategy.isSupported()) {\n this.updateState('failed');\n return;\n }\n this.updateState('connecting');\n this.startConnecting();\n this.setUnavailableTimer();\n }\n\n /** Sends raw data.\n *\n * @param {String} data\n */\n send(data) {\n if (this.connection) {\n return this.connection.send(data);\n } else {\n return false;\n }\n }\n\n /** Sends an event.\n *\n * @param {String} name\n * @param {String} data\n * @param {String} [channel]\n * @returns {Boolean} whether message was sent or not\n */\n send_event(name: string, data: any, channel?: string) {\n if (this.connection) {\n return this.connection.send_event(name, data, channel);\n } else {\n return false;\n }\n }\n\n /** Closes the connection. */\n disconnect() {\n this.disconnectInternally();\n this.updateState('disconnected');\n }\n\n isUsingTLS() {\n return this.usingTLS;\n }\n\n private startConnecting() {\n var callback = (error, handshake) => {\n if (error) {\n this.runner = this.strategy.connect(0, callback);\n } else {\n if (handshake.action === 'error') {\n this.emit('error', {\n type: 'HandshakeError',\n error: handshake.error\n });\n this.timeline.error({ handshakeError: handshake.error });\n } else {\n this.abortConnecting(); // we don't support switching connections yet\n this.handshakeCallbacks[handshake.action](handshake);\n }\n }\n };\n this.runner = this.strategy.connect(0, callback);\n }\n\n private abortConnecting() {\n if (this.runner) {\n this.runner.abort();\n this.runner = null;\n }\n }\n\n private disconnectInternally() {\n this.abortConnecting();\n this.clearRetryTimer();\n this.clearUnavailableTimer();\n if (this.connection) {\n var connection = this.abandonConnection();\n connection.close();\n }\n }\n\n private updateStrategy() {\n this.strategy = this.options.getStrategy({\n key: this.key,\n timeline: this.timeline,\n useTLS: this.usingTLS\n });\n }\n\n private retryIn(delay) {\n this.timeline.info({ action: 'retry', delay: delay });\n if (delay > 0) {\n this.emit('connecting_in', Math.round(delay / 1000));\n }\n this.retryTimer = new Timer(delay || 0, () => {\n this.disconnectInternally();\n this.connect();\n });\n }\n\n private clearRetryTimer() {\n if (this.retryTimer) {\n this.retryTimer.ensureAborted();\n this.retryTimer = null;\n }\n }\n\n private setUnavailableTimer() {\n this.unavailableTimer = new Timer(this.options.unavailableTimeout, () => {\n this.updateState('unavailable');\n });\n }\n\n private clearUnavailableTimer() {\n if (this.unavailableTimer) {\n this.unavailableTimer.ensureAborted();\n }\n }\n\n private sendActivityCheck() {\n this.stopActivityCheck();\n this.connection.ping();\n // wait for pong response\n this.activityTimer = new Timer(this.options.pongTimeout, () => {\n this.timeline.error({ pong_timed_out: this.options.pongTimeout });\n this.retryIn(0);\n });\n }\n\n private resetActivityCheck() {\n this.stopActivityCheck();\n // send ping after inactivity\n if (this.connection && !this.connection.handlesActivityChecks()) {\n this.activityTimer = new Timer(this.activityTimeout, () => {\n this.sendActivityCheck();\n });\n }\n }\n\n private stopActivityCheck() {\n if (this.activityTimer) {\n this.activityTimer.ensureAborted();\n }\n }\n\n private buildConnectionCallbacks(\n errorCallbacks: ErrorCallbacks\n ): ConnectionCallbacks {\n return Collections.extend({}, errorCallbacks, {\n message: message => {\n // includes pong messages from server\n this.resetActivityCheck();\n this.emit('message', message);\n },\n ping: () => {\n this.send_event('pusher:pong', {});\n },\n activity: () => {\n this.resetActivityCheck();\n },\n error: error => {\n // just emit error to user - socket will already be closed by browser\n this.emit('error', error);\n },\n closed: () => {\n this.abandonConnection();\n if (this.shouldRetry()) {\n this.retryIn(1000);\n }\n }\n });\n }\n\n private buildHandshakeCallbacks(\n errorCallbacks: ErrorCallbacks\n ): HandshakeCallbacks {\n return Collections.extend({}, errorCallbacks, {\n connected: (handshake: HandshakePayload) => {\n this.activityTimeout = Math.min(\n this.options.activityTimeout,\n handshake.activityTimeout,\n handshake.connection.activityTimeout || Infinity\n );\n this.clearUnavailableTimer();\n this.setConnection(handshake.connection);\n this.socket_id = this.connection.id;\n this.updateState('connected', { socket_id: this.socket_id });\n }\n });\n }\n\n private buildErrorCallbacks(): ErrorCallbacks {\n let withErrorEmitted = callback => {\n return (result: Action | HandshakePayload) => {\n if (result.error) {\n this.emit('error', { type: 'WebSocketError', error: result.error });\n }\n callback(result);\n };\n };\n\n return {\n tls_only: withErrorEmitted(() => {\n this.usingTLS = true;\n this.updateStrategy();\n this.retryIn(0);\n }),\n refused: withErrorEmitted(() => {\n this.disconnect();\n }),\n backoff: withErrorEmitted(() => {\n this.retryIn(1000);\n }),\n retry: withErrorEmitted(() => {\n this.retryIn(0);\n })\n };\n }\n\n private setConnection(connection) {\n this.connection = connection;\n for (var event in this.connectionCallbacks) {\n this.connection.bind(event, this.connectionCallbacks[event]);\n }\n this.resetActivityCheck();\n }\n\n private abandonConnection() {\n if (!this.connection) {\n return;\n }\n this.stopActivityCheck();\n for (var event in this.connectionCallbacks) {\n this.connection.unbind(event, this.connectionCallbacks[event]);\n }\n var connection = this.connection;\n this.connection = null;\n return connection;\n }\n\n private updateState(newState: string, data?: any) {\n var previousState = this.state;\n this.state = newState;\n if (previousState !== newState) {\n var newStateDescription = newState;\n if (newStateDescription === 'connected') {\n newStateDescription += ' with new socket ID ' + data.socket_id;\n }\n Logger.debug(\n 'State changed',\n previousState + ' -> ' + newStateDescription\n );\n this.timeline.info({ state: newState, params: data });\n this.emit('state_change', { previous: previousState, current: newState });\n this.emit(newState, data);\n }\n }\n\n private shouldRetry(): boolean {\n return this.state === 'connecting' || this.state === 'connected';\n }\n}\n","import Channel from './channel';\nimport * as Collections from '../utils/collections';\nimport ChannelTable from './channel_table';\nimport Factory from '../utils/factory';\nimport Pusher from '../pusher';\nimport Logger from '../logger';\nimport * as Errors from '../errors';\nimport urlStore from '../utils/url_store';\n\n/** Handles a channel map. */\nexport default class Channels {\n channels: ChannelTable;\n\n constructor() {\n this.channels = {};\n }\n\n /** Creates or retrieves an existing channel by its name.\n *\n * @param {String} name\n * @param {Pusher} pusher\n * @return {Channel}\n */\n add(name: string, pusher: Pusher) {\n if (!this.channels[name]) {\n this.channels[name] = createChannel(name, pusher);\n }\n return this.channels[name];\n }\n\n /** Returns a list of all channels\n *\n * @return {Array}\n */\n all(): Channel[] {\n return Collections.values(this.channels);\n }\n\n /** Finds a channel by its name.\n *\n * @param {String} name\n * @return {Channel} channel or null if it doesn't exist\n */\n find(name: string) {\n return this.channels[name];\n }\n\n /** Removes a channel from the map.\n *\n * @param {String} name\n */\n remove(name: string) {\n var channel = this.channels[name];\n delete this.channels[name];\n return channel;\n }\n\n /** Proxies disconnection signal to all channels. */\n disconnect() {\n Collections.objectApply(this.channels, function(channel) {\n channel.disconnect();\n });\n }\n}\n\nfunction createChannel(name: string, pusher: Pusher): Channel {\n if (name.indexOf('private-encrypted-') === 0) {\n if (pusher.config.nacl) {\n return Factory.createEncryptedChannel(name, pusher, pusher.config.nacl);\n }\n let errMsg =\n 'Tried to subscribe to a private-encrypted- channel but no nacl implementation available';\n let suffix = urlStore.buildLogSuffix('encryptedChannelSupport');\n throw new Errors.UnsupportedFeature(`${errMsg}. ${suffix}`);\n } else if (name.indexOf('private-') === 0) {\n return Factory.createPrivateChannel(name, pusher);\n } else if (name.indexOf('presence-') === 0) {\n return Factory.createPresenceChannel(name, pusher);\n } else if (name.indexOf('#') === 0) {\n throw new Errors.BadChannelName(\n 'Cannot create a channel with name \"' + name + '\".'\n );\n } else {\n return Factory.createChannel(name, pusher);\n }\n}\n","import AssistantToTheTransportManager from '../transports/assistant_to_the_transport_manager';\nimport PingDelayOptions from '../transports/ping_delay_options';\nimport Transport from '../transports/transport';\nimport TransportManager from '../transports/transport_manager';\nimport Handshake from '../connection/handshake';\nimport TransportConnection from '../transports/transport_connection';\nimport SocketHooks from '../http/socket_hooks';\nimport HTTPSocket from '../http/http_socket';\n\nimport Timeline from '../timeline/timeline';\nimport {\n default as TimelineSender,\n TimelineSenderOptions\n} from '../timeline/timeline_sender';\nimport PresenceChannel from '../channels/presence_channel';\nimport PrivateChannel from '../channels/private_channel';\nimport EncryptedChannel from '../channels/encrypted_channel';\nimport Channel from '../channels/channel';\nimport ConnectionManager from '../connection/connection_manager';\nimport ConnectionManagerOptions from '../connection/connection_manager_options';\nimport Ajax from '../http/ajax';\nimport Channels from '../channels/channels';\nimport Pusher from '../pusher';\nimport { Config } from '../config';\nimport * as nacl from 'tweetnacl';\n\nvar Factory = {\n createChannels(): Channels {\n return new Channels();\n },\n\n createConnectionManager(\n key: string,\n options: ConnectionManagerOptions\n ): ConnectionManager {\n return new ConnectionManager(key, options);\n },\n\n createChannel(name: string, pusher: Pusher): Channel {\n return new Channel(name, pusher);\n },\n\n createPrivateChannel(name: string, pusher: Pusher): PrivateChannel {\n return new PrivateChannel(name, pusher);\n },\n\n createPresenceChannel(name: string, pusher: Pusher): PresenceChannel {\n return new PresenceChannel(name, pusher);\n },\n\n createEncryptedChannel(\n name: string,\n pusher: Pusher,\n nacl: nacl\n ): EncryptedChannel {\n return new EncryptedChannel(name, pusher, nacl);\n },\n\n createTimelineSender(timeline: Timeline, options: TimelineSenderOptions) {\n return new TimelineSender(timeline, options);\n },\n\n createHandshake(\n transport: TransportConnection,\n callback: (HandshakePayload) => void\n ): Handshake {\n return new Handshake(transport, callback);\n },\n\n createAssistantToTheTransportManager(\n manager: TransportManager,\n transport: Transport,\n options: PingDelayOptions\n ): AssistantToTheTransportManager {\n return new AssistantToTheTransportManager(manager, transport, options);\n }\n};\n\nexport default Factory;\n","import AssistantToTheTransportManager from './assistant_to_the_transport_manager';\nimport Transport from './transport';\nimport PingDelayOptions from './ping_delay_options';\nimport Factory from '../utils/factory';\n\nexport interface TransportManagerOptions extends PingDelayOptions {\n lives?: number;\n}\n\n/** Keeps track of the number of lives left for a transport.\n *\n * In the beginning of a session, transports may be assigned a number of\n * lives. When an AssistantToTheTransportManager instance reports a transport\n * connection closed uncleanly, the transport loses a life. When the number\n * of lives drops to zero, the transport gets disabled by its manager.\n *\n * @param {Object} options\n */\nexport default class TransportManager {\n options: TransportManagerOptions;\n livesLeft: number;\n\n constructor(options: TransportManagerOptions) {\n this.options = options || {};\n this.livesLeft = this.options.lives || Infinity;\n }\n\n /** Creates a assistant for the transport.\n *\n * @param {Transport} transport\n * @returns {AssistantToTheTransportManager}\n */\n getAssistant(transport: Transport): AssistantToTheTransportManager {\n return Factory.createAssistantToTheTransportManager(this, transport, {\n minPingDelay: this.options.minPingDelay,\n maxPingDelay: this.options.maxPingDelay\n });\n }\n\n /** Returns whether the transport has any lives left.\n *\n * @returns {Boolean}\n */\n isAlive(): boolean {\n return this.livesLeft > 0;\n }\n\n /** Takes one life from the transport. */\n reportDeath() {\n this.livesLeft -= 1;\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport { OneOffTimer as Timer } from '../utils/timers';\nimport Strategy from './strategy';\nimport StrategyOptions from './strategy_options';\n\n/** Loops through strategies with optional timeouts.\n *\n * Options:\n * - loop - whether it should loop through the substrategy list\n * - timeout - initial timeout for a single substrategy\n * - timeoutLimit - maximum timeout\n *\n * @param {Strategy[]} strategies\n * @param {Object} options\n */\nexport default class SequentialStrategy implements Strategy {\n strategies: Strategy[];\n loop: boolean;\n failFast: boolean;\n timeout: number;\n timeoutLimit: number;\n\n constructor(strategies: Strategy[], options: StrategyOptions) {\n this.strategies = strategies;\n this.loop = Boolean(options.loop);\n this.failFast = Boolean(options.failFast);\n this.timeout = options.timeout;\n this.timeoutLimit = options.timeoutLimit;\n }\n\n isSupported(): boolean {\n return Collections.any(this.strategies, Util.method('isSupported'));\n }\n\n connect(minPriority: number, callback: Function) {\n var strategies = this.strategies;\n var current = 0;\n var timeout = this.timeout;\n var runner = null;\n\n var tryNextStrategy = (error, handshake) => {\n if (handshake) {\n callback(null, handshake);\n } else {\n current = current + 1;\n if (this.loop) {\n current = current % strategies.length;\n }\n\n if (current < strategies.length) {\n if (timeout) {\n timeout = timeout * 2;\n if (this.timeoutLimit) {\n timeout = Math.min(timeout, this.timeoutLimit);\n }\n }\n runner = this.tryStrategy(\n strategies[current],\n minPriority,\n { timeout, failFast: this.failFast },\n tryNextStrategy\n );\n } else {\n callback(true);\n }\n }\n };\n\n runner = this.tryStrategy(\n strategies[current],\n minPriority,\n { timeout: timeout, failFast: this.failFast },\n tryNextStrategy\n );\n\n return {\n abort: function() {\n runner.abort();\n },\n forceMinPriority: function(p) {\n minPriority = p;\n if (runner) {\n runner.forceMinPriority(p);\n }\n }\n };\n }\n\n private tryStrategy(\n strategy: Strategy,\n minPriority: number,\n options: StrategyOptions,\n callback: Function\n ) {\n var timer = null;\n var runner = null;\n\n if (options.timeout > 0) {\n timer = new Timer(options.timeout, function() {\n runner.abort();\n callback(true);\n });\n }\n\n runner = strategy.connect(minPriority, function(error, handshake) {\n if (error && timer && timer.isRunning() && !options.failFast) {\n // advance to the next strategy after the timeout\n return;\n }\n if (timer) {\n timer.ensureAborted();\n }\n callback(error, handshake);\n });\n\n return {\n abort: function() {\n if (timer) {\n timer.ensureAborted();\n }\n runner.abort();\n },\n forceMinPriority: function(p) {\n runner.forceMinPriority(p);\n }\n };\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport Strategy from './strategy';\n\n/** Launches all substrategies and emits prioritized connected transports.\n *\n * @param {Array} strategies\n */\nexport default class BestConnectedEverStrategy implements Strategy {\n strategies: Strategy[];\n\n constructor(strategies: Strategy[]) {\n this.strategies = strategies;\n }\n\n isSupported(): boolean {\n return Collections.any(this.strategies, Util.method('isSupported'));\n }\n\n connect(minPriority: number, callback: Function) {\n return connect(this.strategies, minPriority, function(i, runners) {\n return function(error, handshake) {\n runners[i].error = error;\n if (error) {\n if (allRunnersFailed(runners)) {\n callback(true);\n }\n return;\n }\n Collections.apply(runners, function(runner) {\n runner.forceMinPriority(handshake.transport.priority);\n });\n callback(null, handshake);\n };\n });\n }\n}\n\n/** Connects to all strategies in parallel.\n *\n * Callback builder should be a function that takes two arguments: index\n * and a list of runners. It should return another function that will be\n * passed to the substrategy with given index. Runners can be aborted using\n * abortRunner(s) functions from this class.\n *\n * @param {Array} strategies\n * @param {Function} callbackBuilder\n * @return {Object} strategy runner\n */\nfunction connect(\n strategies: Strategy[],\n minPriority: number,\n callbackBuilder: Function\n) {\n var runners = Collections.map(strategies, function(strategy, i, _, rs) {\n return strategy.connect(minPriority, callbackBuilder(i, rs));\n });\n return {\n abort: function() {\n Collections.apply(runners, abortRunner);\n },\n forceMinPriority: function(p) {\n Collections.apply(runners, function(runner) {\n runner.forceMinPriority(p);\n });\n }\n };\n}\n\nfunction allRunnersFailed(runners): boolean {\n return Collections.all(runners, function(runner) {\n return Boolean(runner.error);\n });\n}\n\nfunction abortRunner(runner) {\n if (!runner.error && !runner.aborted) {\n runner.abort();\n runner.aborted = true;\n }\n}\n","import Util from '../util';\nimport Runtime from 'runtime';\nimport Strategy from './strategy';\nimport SequentialStrategy from './sequential_strategy';\nimport StrategyOptions from './strategy_options';\nimport TransportStrategy from './transport_strategy';\nimport Timeline from '../timeline/timeline';\nimport * as Collections from '../utils/collections';\n\nexport interface TransportStrategyDictionary {\n [key: string]: TransportStrategy;\n}\n\n/** Caches the last successful transport and, after the first few attempts,\n * uses the cached transport for subsequent attempts.\n *\n * @param {Strategy} strategy\n * @param {Object} transports\n * @param {Object} options\n */\nexport default class WebSocketPrioritizedCachedStrategy implements Strategy {\n strategy: Strategy;\n transports: TransportStrategyDictionary;\n ttl: number;\n usingTLS: boolean;\n timeline: Timeline;\n\n constructor(\n strategy: Strategy,\n transports: TransportStrategyDictionary,\n options: StrategyOptions\n ) {\n this.strategy = strategy;\n this.transports = transports;\n this.ttl = options.ttl || 1800 * 1000;\n this.usingTLS = options.useTLS;\n this.timeline = options.timeline;\n }\n\n isSupported(): boolean {\n return this.strategy.isSupported();\n }\n\n connect(minPriority: number, callback: Function) {\n var usingTLS = this.usingTLS;\n var info = fetchTransportCache(usingTLS);\n var cacheSkipCount = info && info.cacheSkipCount ? info.cacheSkipCount : 0;\n\n var strategies = [this.strategy];\n if (info && info.timestamp + this.ttl >= Util.now()) {\n var transport = this.transports[info.transport];\n if (transport) {\n if (['ws', 'wss'].includes(info.transport) || cacheSkipCount > 3) {\n this.timeline.info({\n cached: true,\n transport: info.transport,\n latency: info.latency\n });\n strategies.push(\n new SequentialStrategy([transport], {\n timeout: info.latency * 2 + 1000,\n failFast: true\n })\n );\n } else {\n cacheSkipCount++;\n }\n }\n }\n\n var startTimestamp = Util.now();\n var runner = strategies\n .pop()\n .connect(minPriority, function cb(error, handshake) {\n if (error) {\n flushTransportCache(usingTLS);\n if (strategies.length > 0) {\n startTimestamp = Util.now();\n runner = strategies.pop().connect(minPriority, cb);\n } else {\n callback(error);\n }\n } else {\n storeTransportCache(\n usingTLS,\n handshake.transport.name,\n Util.now() - startTimestamp,\n cacheSkipCount\n );\n callback(null, handshake);\n }\n });\n\n return {\n abort: function() {\n runner.abort();\n },\n forceMinPriority: function(p) {\n minPriority = p;\n if (runner) {\n runner.forceMinPriority(p);\n }\n }\n };\n }\n}\n\nfunction getTransportCacheKey(usingTLS: boolean): string {\n return 'pusherTransport' + (usingTLS ? 'TLS' : 'NonTLS');\n}\n\nfunction fetchTransportCache(usingTLS: boolean): any {\n var storage = Runtime.getLocalStorage();\n if (storage) {\n try {\n var serializedCache = storage[getTransportCacheKey(usingTLS)];\n if (serializedCache) {\n return JSON.parse(serializedCache);\n }\n } catch (e) {\n flushTransportCache(usingTLS);\n }\n }\n return null;\n}\n\nfunction storeTransportCache(\n usingTLS: boolean,\n transport: TransportStrategy,\n latency: number,\n cacheSkipCount: number\n) {\n var storage = Runtime.getLocalStorage();\n if (storage) {\n try {\n storage[getTransportCacheKey(usingTLS)] = Collections.safeJSONStringify({\n timestamp: Util.now(),\n transport: transport,\n latency: latency,\n cacheSkipCount: cacheSkipCount\n });\n } catch (e) {\n // catch over quota exceptions raised by localStorage\n }\n }\n}\n\nfunction flushTransportCache(usingTLS: boolean) {\n var storage = Runtime.getLocalStorage();\n if (storage) {\n try {\n delete storage[getTransportCacheKey(usingTLS)];\n } catch (e) {\n // catch exceptions raised by localStorage\n }\n }\n}\n","import { OneOffTimer as Timer } from '../utils/timers';\nimport Strategy from './strategy';\nimport StrategyOptions from './strategy_options';\n\n/** Runs substrategy after specified delay.\n *\n * Options:\n * - delay - time in miliseconds to delay the substrategy attempt\n *\n * @param {Strategy} strategy\n * @param {Object} options\n */\nexport default class DelayedStrategy implements Strategy {\n strategy: Strategy;\n options: { delay: number };\n\n constructor(strategy: Strategy, { delay: number }) {\n this.strategy = strategy;\n this.options = { delay: number };\n }\n\n isSupported(): boolean {\n return this.strategy.isSupported();\n }\n\n connect(minPriority: number, callback: Function) {\n var strategy = this.strategy;\n var runner;\n var timer = new Timer(this.options.delay, function() {\n runner = strategy.connect(minPriority, callback);\n });\n\n return {\n abort: function() {\n timer.ensureAborted();\n if (runner) {\n runner.abort();\n }\n },\n forceMinPriority: function(p) {\n minPriority = p;\n if (runner) {\n runner.forceMinPriority(p);\n }\n }\n };\n }\n}\n","import Strategy from './strategy';\nimport StrategyRunner from './strategy_runner';\n\n/** Proxies method calls to one of substrategies basing on the test function.\n *\n * @param {Function} test\n * @param {Strategy} trueBranch strategy used when test returns true\n * @param {Strategy} falseBranch strategy used when test returns false\n */\nexport default class IfStrategy implements Strategy {\n test: () => boolean;\n trueBranch: Strategy;\n falseBranch: Strategy;\n\n constructor(\n test: () => boolean,\n trueBranch: Strategy,\n falseBranch: Strategy\n ) {\n this.test = test;\n this.trueBranch = trueBranch;\n this.falseBranch = falseBranch;\n }\n\n isSupported(): boolean {\n var branch = this.test() ? this.trueBranch : this.falseBranch;\n return branch.isSupported();\n }\n\n connect(minPriority: number, callback: Function): StrategyRunner {\n var branch = this.test() ? this.trueBranch : this.falseBranch;\n return branch.connect(minPriority, callback);\n }\n}\n","import Strategy from './strategy';\nimport StrategyRunner from './strategy_runner';\n\n/** Launches the substrategy and terminates on the first open connection.\n *\n * @param {Strategy} strategy\n */\nexport default class FirstConnectedStrategy implements Strategy {\n strategy: Strategy;\n\n constructor(strategy: Strategy) {\n this.strategy = strategy;\n }\n\n isSupported(): boolean {\n return this.strategy.isSupported();\n }\n\n connect(minPriority: number, callback: Function): StrategyRunner {\n var runner = this.strategy.connect(minPriority, function(error, handshake) {\n if (handshake) {\n runner.abort();\n }\n callback(error, handshake);\n });\n return runner;\n }\n}\n","import * as Collections from 'core/utils/collections';\nimport TransportManager from 'core/transports/transport_manager';\nimport Strategy from 'core/strategies/strategy';\nimport SequentialStrategy from 'core/strategies/sequential_strategy';\nimport BestConnectedEverStrategy from 'core/strategies/best_connected_ever_strategy';\nimport WebSocketPrioritizedCachedStrategy, {\n TransportStrategyDictionary\n} from 'core/strategies/websocket_prioritized_cached_strategy';\nimport DelayedStrategy from 'core/strategies/delayed_strategy';\nimport IfStrategy from 'core/strategies/if_strategy';\nimport FirstConnectedStrategy from 'core/strategies/first_connected_strategy';\nimport { Config } from 'core/config';\nimport StrategyOptions from 'core/strategies/strategy_options';\n\nfunction testSupportsStrategy(strategy: Strategy) {\n return function() {\n return strategy.isSupported();\n };\n}\n\nvar getDefaultStrategy = function(\n config: Config,\n baseOptions: StrategyOptions,\n defineTransport: Function\n): Strategy {\n var definedTransports = {};\n\n function defineTransportStrategy(\n name: string,\n type: string,\n priority: number,\n options: StrategyOptions,\n manager?: TransportManager\n ) {\n var transport = defineTransport(\n config,\n name,\n type,\n priority,\n options,\n manager\n );\n\n definedTransports[name] = transport;\n\n return transport;\n }\n\n var ws_options: StrategyOptions = Object.assign({}, baseOptions, {\n hostNonTLS: config.wsHost + ':' + config.wsPort,\n hostTLS: config.wsHost + ':' + config.wssPort,\n httpPath: config.wsPath\n });\n var wss_options: StrategyOptions = Collections.extend({}, ws_options, {\n useTLS: true\n });\n var http_options: StrategyOptions = Object.assign({}, baseOptions, {\n hostNonTLS: config.httpHost + ':' + config.httpPort,\n hostTLS: config.httpHost + ':' + config.httpsPort,\n httpPath: config.httpPath\n });\n var timeouts = {\n loop: true,\n timeout: 15000,\n timeoutLimit: 60000\n };\n\n var ws_manager = new TransportManager({\n minPingDelay: 10000,\n maxPingDelay: config.activityTimeout\n });\n var streaming_manager = new TransportManager({\n lives: 2,\n minPingDelay: 10000,\n maxPingDelay: config.activityTimeout\n });\n\n var ws_transport = defineTransportStrategy(\n 'ws',\n 'ws',\n 3,\n ws_options,\n ws_manager\n );\n var wss_transport = defineTransportStrategy(\n 'wss',\n 'ws',\n 3,\n wss_options,\n ws_manager\n );\n var xhr_streaming_transport = defineTransportStrategy(\n 'xhr_streaming',\n 'xhr_streaming',\n 1,\n http_options,\n streaming_manager\n );\n var xhr_polling_transport = defineTransportStrategy(\n 'xhr_polling',\n 'xhr_polling',\n 1,\n http_options\n );\n\n var ws_loop = new SequentialStrategy([ws_transport], timeouts);\n var wss_loop = new SequentialStrategy([wss_transport], timeouts);\n var streaming_loop = new SequentialStrategy(\n [xhr_streaming_transport],\n timeouts\n );\n var polling_loop = new SequentialStrategy([xhr_polling_transport], timeouts);\n\n var http_loop = new SequentialStrategy(\n [\n new IfStrategy(\n testSupportsStrategy(streaming_loop),\n new BestConnectedEverStrategy([\n streaming_loop,\n new DelayedStrategy(polling_loop, { delay: 4000 })\n ]),\n polling_loop\n )\n ],\n timeouts\n );\n\n var wsStrategy;\n if (baseOptions.useTLS) {\n wsStrategy = new BestConnectedEverStrategy([\n ws_loop,\n new DelayedStrategy(http_loop, { delay: 2000 })\n ]);\n } else {\n wsStrategy = new BestConnectedEverStrategy([\n ws_loop,\n new DelayedStrategy(wss_loop, { delay: 2000 }),\n new DelayedStrategy(http_loop, { delay: 5000 })\n ]);\n }\n\n return new WebSocketPrioritizedCachedStrategy(\n new FirstConnectedStrategy(\n new IfStrategy(testSupportsStrategy(ws_transport), wsStrategy, http_loop)\n ),\n definedTransports,\n {\n ttl: 1800000,\n timeline: baseOptions.timeline,\n useTLS: baseOptions.useTLS\n }\n );\n};\n\nexport default getDefaultStrategy;\n","/** Initializes the transport.\n *\n * Fetches resources if needed and then transitions to initialized.\n */\nexport default function() {\n var self = this;\n\n self.timeline.info(\n self.buildTimelineMessage({\n transport: self.name + (self.options.useTLS ? 's' : '')\n })\n );\n\n if (self.hooks.isInitialized()) {\n self.changeState('initialized');\n } else {\n self.onClose();\n }\n}\n","import Runtime from 'runtime';\nimport RequestHooks from './request_hooks';\nimport Ajax from './ajax';\nimport { default as EventsDispatcher } from '../events/dispatcher';\n\nconst MAX_BUFFER_LENGTH = 256 * 1024;\n\nexport default class HTTPRequest extends EventsDispatcher {\n hooks: RequestHooks;\n method: string;\n url: string;\n position: number;\n xhr: Ajax;\n unloader: Function;\n\n constructor(hooks: RequestHooks, method: string, url: string) {\n super();\n this.hooks = hooks;\n this.method = method;\n this.url = url;\n }\n\n start(payload?: any) {\n this.position = 0;\n this.xhr = this.hooks.getRequest(this);\n\n this.unloader = () => {\n this.close();\n };\n Runtime.addUnloadListener(this.unloader);\n\n this.xhr.open(this.method, this.url, true);\n\n if (this.xhr.setRequestHeader) {\n this.xhr.setRequestHeader('Content-Type', 'application/json'); // ReactNative doesn't set this header by default.\n }\n this.xhr.send(payload);\n }\n\n close() {\n if (this.unloader) {\n Runtime.removeUnloadListener(this.unloader);\n this.unloader = null;\n }\n if (this.xhr) {\n this.hooks.abortRequest(this.xhr);\n this.xhr = null;\n }\n }\n\n onChunk(status: number, data: any) {\n while (true) {\n var chunk = this.advanceBuffer(data);\n if (chunk) {\n this.emit('chunk', { status: status, data: chunk });\n } else {\n break;\n }\n }\n if (this.isBufferTooLong(data)) {\n this.emit('buffer_too_long');\n }\n }\n\n private advanceBuffer(buffer: any[]): any {\n var unreadData = buffer.slice(this.position);\n var endOfLinePosition = unreadData.indexOf('\\n');\n\n if (endOfLinePosition !== -1) {\n this.position += endOfLinePosition + 1;\n return unreadData.slice(0, endOfLinePosition);\n } else {\n // chunk is not finished yet, don't move the buffer pointer\n return null;\n }\n }\n\n private isBufferTooLong(buffer: any): boolean {\n return this.position === buffer.length && buffer.length > MAX_BUFFER_LENGTH;\n }\n}\n","enum State {\n CONNECTING = 0,\n OPEN = 1,\n CLOSED = 3\n}\n\nexport default State;\n","import URLLocation from './url_location';\nimport State from './state';\nimport Socket from '../socket';\nimport SocketHooks from './socket_hooks';\nimport Util from '../util';\nimport Ajax from './ajax';\nimport HTTPRequest from './http_request';\nimport Runtime from 'runtime';\n\nvar autoIncrement = 1;\n\nclass HTTPSocket implements Socket {\n hooks: SocketHooks;\n session: string;\n location: URLLocation;\n readyState: State;\n stream: HTTPRequest;\n\n onopen: () => void;\n onerror: (error: any) => void;\n onclose: (closeEvent: any) => void;\n onmessage: (message: any) => void;\n onactivity: () => void;\n\n constructor(hooks: SocketHooks, url: string) {\n this.hooks = hooks;\n this.session = randomNumber(1000) + '/' + randomString(8);\n this.location = getLocation(url);\n this.readyState = State.CONNECTING;\n this.openStream();\n }\n\n send(payload: any) {\n return this.sendRaw(JSON.stringify([payload]));\n }\n\n ping() {\n this.hooks.sendHeartbeat(this);\n }\n\n close(code: any, reason: any) {\n this.onClose(code, reason, true);\n }\n\n /** For internal use only */\n sendRaw(payload: any): boolean {\n if (this.readyState === State.OPEN) {\n try {\n Runtime.createSocketRequest(\n 'POST',\n getUniqueURL(getSendURL(this.location, this.session))\n ).start(payload);\n return true;\n } catch (e) {\n return false;\n }\n } else {\n return false;\n }\n }\n\n /** For internal use only */\n reconnect() {\n this.closeStream();\n this.openStream();\n }\n\n /** For internal use only */\n onClose(code, reason, wasClean) {\n this.closeStream();\n this.readyState = State.CLOSED;\n if (this.onclose) {\n this.onclose({\n code: code,\n reason: reason,\n wasClean: wasClean\n });\n }\n }\n\n private onChunk(chunk) {\n if (chunk.status !== 200) {\n return;\n }\n if (this.readyState === State.OPEN) {\n this.onActivity();\n }\n\n var payload;\n var type = chunk.data.slice(0, 1);\n switch (type) {\n case 'o':\n payload = JSON.parse(chunk.data.slice(1) || '{}');\n this.onOpen(payload);\n break;\n case 'a':\n payload = JSON.parse(chunk.data.slice(1) || '[]');\n for (var i = 0; i < payload.length; i++) {\n this.onEvent(payload[i]);\n }\n break;\n case 'm':\n payload = JSON.parse(chunk.data.slice(1) || 'null');\n this.onEvent(payload);\n break;\n case 'h':\n this.hooks.onHeartbeat(this);\n break;\n case 'c':\n payload = JSON.parse(chunk.data.slice(1) || '[]');\n this.onClose(payload[0], payload[1], true);\n break;\n }\n }\n\n private onOpen(options) {\n if (this.readyState === State.CONNECTING) {\n if (options && options.hostname) {\n this.location.base = replaceHost(this.location.base, options.hostname);\n }\n this.readyState = State.OPEN;\n\n if (this.onopen) {\n this.onopen();\n }\n } else {\n this.onClose(1006, 'Server lost session', true);\n }\n }\n\n private onEvent(event) {\n if (this.readyState === State.OPEN && this.onmessage) {\n this.onmessage({ data: event });\n }\n }\n\n private onActivity() {\n if (this.onactivity) {\n this.onactivity();\n }\n }\n\n private onError(error) {\n if (this.onerror) {\n this.onerror(error);\n }\n }\n\n private openStream() {\n this.stream = Runtime.createSocketRequest(\n 'POST',\n getUniqueURL(this.hooks.getReceiveURL(this.location, this.session))\n );\n\n this.stream.bind('chunk', chunk => {\n this.onChunk(chunk);\n });\n this.stream.bind('finished', status => {\n this.hooks.onFinished(this, status);\n });\n this.stream.bind('buffer_too_long', () => {\n this.reconnect();\n });\n\n try {\n this.stream.start();\n } catch (error) {\n Util.defer(() => {\n this.onError(error);\n this.onClose(1006, 'Could not start streaming', false);\n });\n }\n }\n\n private closeStream() {\n if (this.stream) {\n this.stream.unbind_all();\n this.stream.close();\n this.stream = null;\n }\n }\n}\n\nfunction getLocation(url): URLLocation {\n var parts = /([^\\?]*)\\/*(\\??.*)/.exec(url);\n return {\n base: parts[1],\n queryString: parts[2]\n };\n}\n\nfunction getSendURL(url: URLLocation, session: string): string {\n return url.base + '/' + session + '/xhr_send';\n}\n\nfunction getUniqueURL(url: string): string {\n var separator = url.indexOf('?') === -1 ? '?' : '&';\n return url + separator + 't=' + +new Date() + '&n=' + autoIncrement++;\n}\n\nfunction replaceHost(url: string, hostname: string): string {\n var urlParts = /(https?:\\/\\/)([^\\/:]+)((\\/|:)?.*)/.exec(url);\n return urlParts[1] + hostname + urlParts[3];\n}\n\nfunction randomNumber(max: number): number {\n return Runtime.randomInt(max);\n}\n\nfunction randomString(length: number): string {\n var result = [];\n\n for (var i = 0; i < length; i++) {\n result.push(randomNumber(32).toString(32));\n }\n\n return result.join('');\n}\n\nexport default HTTPSocket;\n","import SocketHooks from './socket_hooks';\nimport HTTPSocket from './http_socket';\n\nvar hooks: SocketHooks = {\n getReceiveURL: function(url, session) {\n return url.base + '/' + session + '/xhr_streaming' + url.queryString;\n },\n onHeartbeat: function(socket) {\n socket.sendRaw('[]');\n },\n sendHeartbeat: function(socket) {\n socket.sendRaw('[]');\n },\n onFinished: function(socket, status) {\n socket.onClose(1006, 'Connection interrupted (' + status + ')', false);\n }\n};\n\nexport default hooks;\n","import SocketHooks from './socket_hooks';\nimport URLLocation from './url_location';\nimport HTTPSocket from './http_socket';\n\nvar hooks: SocketHooks = {\n getReceiveURL: function(url: URLLocation, session: string): string {\n return url.base + '/' + session + '/xhr' + url.queryString;\n },\n onHeartbeat: function() {\n // next HTTP request will reset server's activity timer\n },\n sendHeartbeat: function(socket) {\n socket.sendRaw('[]');\n },\n onFinished: function(socket, status) {\n if (status === 200) {\n socket.reconnect();\n } else {\n socket.onClose(1006, 'Connection interrupted (' + status + ')', false);\n }\n }\n};\n\nexport default hooks;\n","import HTTPRequest from 'core/http/http_request';\nimport RequestHooks from 'core/http/request_hooks';\nimport Ajax from 'core/http/ajax';\nimport Runtime from 'runtime';\n\nvar hooks: RequestHooks = {\n getRequest: function(socket: HTTPRequest): Ajax {\n var Constructor = Runtime.getXHRAPI();\n var xhr = new Constructor();\n xhr.onreadystatechange = xhr.onprogress = function() {\n switch (xhr.readyState) {\n case 3:\n if (xhr.responseText && xhr.responseText.length > 0) {\n socket.onChunk(xhr.status, xhr.responseText);\n }\n break;\n case 4:\n // this happens only on errors, never after calling close\n if (xhr.responseText && xhr.responseText.length > 0) {\n socket.onChunk(xhr.status, xhr.responseText);\n }\n socket.emit('finished', xhr.status);\n socket.close();\n break;\n }\n };\n return xhr;\n },\n abortRequest: function(xhr: Ajax) {\n xhr.onreadystatechange = null;\n xhr.abort();\n }\n};\n\nexport default hooks;\n","import HTTPRequest from 'core/http/http_request';\nimport HTTPSocket from 'core/http/http_socket';\nimport SocketHooks from 'core/http/socket_hooks';\nimport RequestHooks from 'core/http/request_hooks';\nimport streamingHooks from 'core/http/http_streaming_socket';\nimport pollingHooks from 'core/http/http_polling_socket';\nimport xhrHooks from './http_xhr_request';\nimport HTTPFactory from 'core/http/http_factory';\n\nvar HTTP: HTTPFactory = {\n createStreamingSocket(url: string): HTTPSocket {\n return this.createSocket(streamingHooks, url);\n },\n\n createPollingSocket(url: string): HTTPSocket {\n return this.createSocket(pollingHooks, url);\n },\n\n createSocket(hooks: SocketHooks, url: string): HTTPSocket {\n return new HTTPSocket(hooks, url);\n },\n\n createXHR(method: string, url: string): HTTPRequest {\n return this.createRequest(xhrHooks, method, url);\n },\n\n createRequest(hooks: RequestHooks, method: string, url: string): HTTPRequest {\n return new HTTPRequest(hooks, method, url);\n }\n};\n\nexport default HTTP;\n","import * as Collections from 'core/utils/collections';\nimport Transports from 'isomorphic/transports/transports';\nimport TimelineSender from 'core/timeline/timeline_sender';\nimport Ajax from 'core/http/ajax';\nimport getDefaultStrategy from './default_strategy';\nimport TransportsTable from 'core/transports/transports_table';\nimport transportConnectionInitializer from './transports/transport_connection_initializer';\nimport HTTPFactory from './http/http';\n\nvar Isomorphic: any = {\n getDefaultStrategy,\n Transports: Transports,\n transportConnectionInitializer,\n HTTPFactory,\n\n setup(PusherClass): void {\n PusherClass.ready();\n },\n\n getLocalStorage(): any {\n return undefined;\n },\n\n getClientFeatures(): any[] {\n return Collections.keys(\n Collections.filterObject({ ws: Transports.ws }, function(t) {\n return t.isSupported({});\n })\n );\n },\n\n getProtocol(): string {\n return 'http:';\n },\n\n isXHRSupported(): boolean {\n return true;\n },\n\n createSocketRequest(method: string, url: string) {\n if (this.isXHRSupported()) {\n return this.HTTPFactory.createXHR(method, url);\n } else {\n throw 'Cross-origin HTTP requests are not supported';\n }\n },\n\n createXHR(): Ajax {\n var Constructor = this.getXHRAPI();\n return new Constructor();\n },\n\n createWebSocket(url: string): any {\n var Constructor = this.getWebSocketAPI();\n return new Constructor(url);\n },\n\n addUnloadListener(listener: any) {},\n removeUnloadListener(listener: any) {}\n};\n\nexport default Isomorphic;\n","import { default as EventsDispatcher } from 'core/events/dispatcher';\nimport Reachability from 'core/reachability';\n\nexport class NetInfo extends EventsDispatcher implements Reachability {\n isOnline(): boolean {\n return true;\n }\n}\n\nexport var Network = new NetInfo();\n","export enum AuthRequestType {\n UserAuthentication = 'user-authentication',\n ChannelAuthorization = 'channel-authorization'\n}\n\nexport interface ChannelAuthorizationData {\n auth: string;\n channel_data?: string;\n shared_secret?: string;\n}\n\nexport type ChannelAuthorizationCallback = (\n error: Error | null,\n authData: ChannelAuthorizationData | null\n) => void;\n\nexport interface ChannelAuthorizationRequestParams {\n socketId: string;\n channelName: string;\n}\n\nexport interface ChannelAuthorizationHandler {\n (\n params: ChannelAuthorizationRequestParams,\n callback: ChannelAuthorizationCallback\n ): void;\n}\n\nexport interface UserAuthenticationData {\n auth: string;\n user_data: string;\n}\n\nexport type UserAuthenticationCallback = (\n error: Error | null,\n authData: UserAuthenticationData | null\n) => void;\n\nexport interface UserAuthenticationRequestParams {\n socketId: string;\n}\n\nexport interface UserAuthenticationHandler {\n (\n params: UserAuthenticationRequestParams,\n callback: UserAuthenticationCallback\n ): void;\n}\n\nexport type AuthTransportCallback =\n | ChannelAuthorizationCallback\n | UserAuthenticationCallback;\n\nexport interface AuthOptionsT {\n transport: 'ajax' | 'jsonp';\n endpoint: string;\n params?: any;\n headers?: any;\n paramsProvider?: () => any;\n headersProvider?: () => any;\n customHandler?: AuthHandler;\n}\n\nexport declare type UserAuthenticationOptions = AuthOptionsT<\n UserAuthenticationHandler\n>;\nexport declare type ChannelAuthorizationOptions = AuthOptionsT<\n ChannelAuthorizationHandler\n>;\n\nexport interface InternalAuthOptions {\n transport: 'ajax' | 'jsonp';\n endpoint: string;\n params?: any;\n headers?: any;\n paramsProvider?: () => any;\n headersProvider?: () => any;\n}\n","import TimelineSender from 'core/timeline/timeline_sender';\nimport * as Collections from 'core/utils/collections';\nimport Util from 'core/util';\nimport Runtime from 'runtime';\nimport { AuthTransport } from 'core/auth/auth_transports';\nimport AbstractRuntime from 'runtimes/interface';\nimport UrlStore from 'core/utils/url_store';\nimport {\n AuthRequestType,\n AuthTransportCallback,\n InternalAuthOptions\n} from 'core/auth/options';\nimport { HTTPAuthError } from 'core/errors';\n\nconst ajax: AuthTransport = function(\n context: AbstractRuntime,\n query: string,\n authOptions: InternalAuthOptions,\n authRequestType: AuthRequestType,\n callback: AuthTransportCallback\n) {\n const xhr = Runtime.createXHR();\n xhr.open('POST', authOptions.endpoint, true);\n\n // add request headers\n xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');\n for (var headerName in authOptions.headers) {\n xhr.setRequestHeader(headerName, authOptions.headers[headerName]);\n }\n if (authOptions.headersProvider != null) {\n let dynamicHeaders = authOptions.headersProvider();\n for (var headerName in dynamicHeaders) {\n xhr.setRequestHeader(headerName, dynamicHeaders[headerName]);\n }\n }\n\n xhr.onreadystatechange = function() {\n if (xhr.readyState === 4) {\n if (xhr.status === 200) {\n let data;\n let parsed = false;\n\n try {\n data = JSON.parse(xhr.responseText);\n parsed = true;\n } catch (e) {\n callback(\n new HTTPAuthError(\n 200,\n `JSON returned from ${authRequestType.toString()} endpoint was invalid, yet status code was 200. Data was: ${\n xhr.responseText\n }`\n ),\n null\n );\n }\n\n if (parsed) {\n // prevents double execution.\n callback(null, data);\n }\n } else {\n let suffix = '';\n switch (authRequestType) {\n case AuthRequestType.UserAuthentication:\n suffix = UrlStore.buildLogSuffix('authenticationEndpoint');\n break;\n case AuthRequestType.ChannelAuthorization:\n suffix = `Clients must be authorized to join private or presence channels. ${UrlStore.buildLogSuffix(\n 'authorizationEndpoint'\n )}`;\n break;\n }\n callback(\n new HTTPAuthError(\n xhr.status,\n `Unable to retrieve auth string from ${authRequestType.toString()} endpoint - ` +\n `received status: ${xhr.status} from ${authOptions.endpoint}. ${suffix}`\n ),\n null\n );\n }\n }\n };\n\n xhr.send(query);\n return xhr;\n};\n\nexport default ajax;\n","import Logger from 'core/logger';\nimport TimelineSender from 'core/timeline/timeline_sender';\nimport * as Collections from 'core/utils/collections';\nimport Util from 'core/util';\nimport Runtime from 'runtime';\nimport TimelineTransport from 'core/timeline/timeline_transport';\n\nvar getAgent = function(sender: TimelineSender, useTLS: boolean) {\n return function(data: any, callback: Function) {\n var scheme = 'http' + (useTLS ? 's' : '') + '://';\n var url =\n scheme + (sender.host || sender.options.host) + sender.options.path;\n var query = Collections.buildQueryString(data);\n\n url += '/' + 2 + '?' + query;\n\n var xhr = Runtime.createXHR();\n xhr.open('GET', url, true);\n\n xhr.onreadystatechange = function() {\n if (xhr.readyState === 4) {\n let { status, responseText } = xhr;\n if (status !== 200) {\n Logger.debug(\n `TimelineSender Error: received ${status} from stats.pusher.com`\n );\n return;\n }\n\n try {\n var { host } = JSON.parse(responseText);\n } catch (e) {\n Logger.debug(`TimelineSenderError: invalid response ${responseText}`);\n }\n if (host) {\n sender.host = host;\n }\n }\n };\n\n xhr.send();\n };\n};\n\nvar xhr = {\n name: 'xhr',\n getAgent\n};\n\nexport default xhr;\n","import Isomorphic from 'isomorphic/runtime';\nimport { Client as WebSocket } from 'faye-websocket';\nimport { XMLHttpRequest } from 'xmlhttprequest';\nimport Runtime from '../interface';\nimport { Network } from './net_info';\nimport xhrAuth from 'isomorphic/auth/xhr_auth';\nimport { AuthTransports } from 'core/auth/auth_transports';\nimport xhrTimeline from 'isomorphic/timeline/xhr_timeline';\nimport { randomInt } from 'crypto';\n\n// Very verbose but until unavoidable until\n// TypeScript 2.1, when spread attributes will be\n// supported\nconst {\n getDefaultStrategy,\n Transports,\n setup,\n getProtocol,\n isXHRSupported,\n getLocalStorage,\n createXHR,\n createWebSocket,\n addUnloadListener,\n removeUnloadListener,\n transportConnectionInitializer,\n createSocketRequest,\n HTTPFactory\n} = Isomorphic;\n\nconst NodeJS: Runtime = {\n getDefaultStrategy,\n Transports,\n setup,\n getProtocol,\n isXHRSupported,\n createSocketRequest,\n getLocalStorage,\n createXHR,\n createWebSocket,\n addUnloadListener,\n removeUnloadListener,\n transportConnectionInitializer,\n HTTPFactory,\n\n TimelineTransport: xhrTimeline,\n\n getAuthorizers(): AuthTransports {\n return { ajax: xhrAuth };\n },\n\n getWebSocketAPI() {\n return WebSocket;\n },\n\n getXHRAPI() {\n return XMLHttpRequest;\n },\n\n getNetwork() {\n return Network;\n },\n\n randomInt(max: number): number {\n return randomInt(max);\n }\n};\n\nexport default NodeJS;\n","enum TimelineLevel {\n ERROR = 3,\n INFO = 6,\n DEBUG = 7\n}\n\nexport default TimelineLevel;\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport { default as Level } from './level';\n\nexport interface TimelineOptions {\n level?: Level;\n limit?: number;\n version?: string;\n cluster?: string;\n features?: string[];\n params?: any;\n}\n\nexport default class Timeline {\n key: string;\n session: number;\n events: any[];\n options: TimelineOptions;\n sent: number;\n uniqueID: number;\n\n constructor(key: string, session: number, options: TimelineOptions) {\n this.key = key;\n this.session = session;\n this.events = [];\n this.options = options || {};\n this.sent = 0;\n this.uniqueID = 0;\n }\n\n log(level, event) {\n if (level <= this.options.level) {\n this.events.push(\n Collections.extend({}, event, { timestamp: Util.now() })\n );\n if (this.options.limit && this.events.length > this.options.limit) {\n this.events.shift();\n }\n }\n }\n\n error(event) {\n this.log(Level.ERROR, event);\n }\n\n info(event) {\n this.log(Level.INFO, event);\n }\n\n debug(event) {\n this.log(Level.DEBUG, event);\n }\n\n isEmpty() {\n return this.events.length === 0;\n }\n\n send(sendfn, callback) {\n var data = Collections.extend(\n {\n session: this.session,\n bundle: this.sent + 1,\n key: this.key,\n lib: 'js',\n version: this.options.version,\n cluster: this.options.cluster,\n features: this.options.features,\n timeline: this.events\n },\n this.options.params\n );\n\n this.events = [];\n sendfn(data, (error, result) => {\n if (!error) {\n this.sent++;\n }\n if (callback) {\n callback(error, result);\n }\n });\n\n return true;\n }\n\n generateUniqueID(): number {\n this.uniqueID++;\n return this.uniqueID;\n }\n}\n","import Factory from '../utils/factory';\nimport Util from '../util';\nimport * as Errors from '../errors';\nimport * as Collections from '../utils/collections';\nimport Strategy from './strategy';\nimport Transport from '../transports/transport';\nimport StrategyOptions from './strategy_options';\nimport Handshake from '../connection/handshake';\n\n/** Provides a strategy interface for transports.\n *\n * @param {String} name\n * @param {Number} priority\n * @param {Class} transport\n * @param {Object} options\n */\nexport default class TransportStrategy implements Strategy {\n name: string;\n priority: number;\n transport: Transport;\n options: StrategyOptions;\n\n constructor(\n name: string,\n priority: number,\n transport: Transport,\n options: StrategyOptions\n ) {\n this.name = name;\n this.priority = priority;\n this.transport = transport;\n this.options = options || {};\n }\n\n /** Returns whether the transport is supported in the browser.\n *\n * @returns {Boolean}\n */\n isSupported(): boolean {\n return this.transport.isSupported({\n useTLS: this.options.useTLS\n });\n }\n\n /** Launches a connection attempt and returns a strategy runner.\n *\n * @param {Function} callback\n * @return {Object} strategy runner\n */\n connect(minPriority: number, callback: Function) {\n if (!this.isSupported()) {\n return failAttempt(new Errors.UnsupportedStrategy(), callback);\n } else if (this.priority < minPriority) {\n return failAttempt(new Errors.TransportPriorityTooLow(), callback);\n }\n\n var connected = false;\n var transport = this.transport.createConnection(\n this.name,\n this.priority,\n this.options.key,\n this.options\n );\n var handshake = null;\n\n var onInitialized = function() {\n transport.unbind('initialized', onInitialized);\n transport.connect();\n };\n var onOpen = function() {\n handshake = Factory.createHandshake(transport, function(result) {\n connected = true;\n unbindListeners();\n callback(null, result);\n });\n };\n var onError = function(error) {\n unbindListeners();\n callback(error);\n };\n var onClosed = function() {\n unbindListeners();\n var serializedTransport;\n\n // The reason for this try/catch block is that on React Native\n // the WebSocket object is circular. Therefore transport.socket will\n // throw errors upon stringification. Collections.safeJSONStringify\n // discards circular references when serializing.\n serializedTransport = Collections.safeJSONStringify(transport);\n callback(new Errors.TransportClosed(serializedTransport));\n };\n\n var unbindListeners = function() {\n transport.unbind('initialized', onInitialized);\n transport.unbind('open', onOpen);\n transport.unbind('error', onError);\n transport.unbind('closed', onClosed);\n };\n\n transport.bind('initialized', onInitialized);\n transport.bind('open', onOpen);\n transport.bind('error', onError);\n transport.bind('closed', onClosed);\n\n // connect will be called automatically after initialization\n transport.initialize();\n\n return {\n abort: () => {\n if (connected) {\n return;\n }\n unbindListeners();\n if (handshake) {\n handshake.close();\n } else {\n transport.close();\n }\n },\n forceMinPriority: p => {\n if (connected) {\n return;\n }\n if (this.priority < p) {\n if (handshake) {\n handshake.close();\n } else {\n transport.close();\n }\n }\n }\n };\n }\n}\n\nfunction failAttempt(error: Error, callback: Function) {\n Util.defer(function() {\n callback(error);\n });\n return {\n abort: function() {},\n forceMinPriority: function() {}\n };\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport TransportManager from '../transports/transport_manager';\nimport * as Errors from '../errors';\nimport Strategy from './strategy';\nimport TransportStrategy from './transport_strategy';\nimport StrategyOptions from '../strategies/strategy_options';\nimport { Config } from '../config';\nimport Runtime from 'runtime';\n\nconst { Transports } = Runtime;\n\nexport var defineTransport = function(\n config: Config,\n name: string,\n type: string,\n priority: number,\n options: StrategyOptions,\n manager?: TransportManager\n): Strategy {\n var transportClass = Transports[type];\n if (!transportClass) {\n throw new Errors.UnsupportedTransport(type);\n }\n\n var enabled =\n (!config.enabledTransports ||\n Collections.arrayIndexOf(config.enabledTransports, name) !== -1) &&\n (!config.disabledTransports ||\n Collections.arrayIndexOf(config.disabledTransports, name) === -1);\n\n var transport;\n if (enabled) {\n options = Object.assign(\n { ignoreNullOrigin: config.ignoreNullOrigin },\n options\n );\n\n transport = new TransportStrategy(\n name,\n priority,\n manager ? manager.getAssistant(transportClass) : transportClass,\n options\n );\n } else {\n transport = UnsupportedStrategy;\n }\n\n return transport;\n};\n\nvar UnsupportedStrategy: Strategy = {\n isSupported: function() {\n return false;\n },\n connect: function(_, callback) {\n var deferred = Util.defer(function() {\n callback(new Errors.UnsupportedStrategy());\n });\n return {\n abort: function() {\n deferred.ensureAborted();\n },\n forceMinPriority: function() {}\n };\n }\n};\n","import ConnectionManager from './connection/connection_manager';\nimport {\n ChannelAuthorizationOptions,\n UserAuthenticationOptions\n} from './auth/options';\nimport {\n ChannelAuthorizerGenerator,\n DeprecatedAuthOptions\n} from './auth/deprecated_channel_authorizer';\nimport { AuthTransport, Transport } from './config';\nimport * as nacl from 'tweetnacl';\nimport Logger from './logger';\n\nexport interface Options {\n activityTimeout?: number;\n\n auth?: DeprecatedAuthOptions; // DEPRECATED use channelAuthorization instead\n authEndpoint?: string; // DEPRECATED use channelAuthorization instead\n authTransport?: AuthTransport; // DEPRECATED use channelAuthorization instead\n authorizer?: ChannelAuthorizerGenerator; // DEPRECATED use channelAuthorization instead\n\n channelAuthorization?: ChannelAuthorizationOptions;\n userAuthentication?: UserAuthenticationOptions;\n\n cluster: string;\n enableStats?: boolean;\n disableStats?: boolean;\n disabledTransports?: Transport[];\n enabledTransports?: Transport[];\n forceTLS?: boolean;\n httpHost?: string;\n httpPath?: string;\n httpPort?: number;\n httpsPort?: number;\n ignoreNullOrigin?: boolean;\n nacl?: nacl;\n pongTimeout?: number;\n statsHost?: string;\n timelineParams?: any;\n unavailableTimeout?: number;\n wsHost?: string;\n wsPath?: string;\n wsPort?: number;\n wssPort?: number;\n}\n\nexport function validateOptions(options) {\n if (options == null) {\n throw 'You must pass an options object';\n }\n if (options.cluster == null) {\n throw 'Options object must provide a cluster';\n }\n if ('disableStats' in options) {\n Logger.warn(\n 'The disableStats option is deprecated in favor of enableStats'\n );\n }\n}\n","import {\n UserAuthenticationCallback,\n InternalAuthOptions,\n UserAuthenticationHandler,\n UserAuthenticationRequestParams,\n AuthRequestType\n} from './options';\n\nimport Runtime from 'runtime';\n\nconst composeChannelQuery = (\n params: UserAuthenticationRequestParams,\n authOptions: InternalAuthOptions\n) => {\n var query = 'socket_id=' + encodeURIComponent(params.socketId);\n\n for (var key in authOptions.params) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(authOptions.params[key]);\n }\n\n if (authOptions.paramsProvider != null) {\n let dynamicParams = authOptions.paramsProvider();\n for (var key in dynamicParams) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(dynamicParams[key]);\n }\n }\n\n return query;\n};\n\nconst UserAuthenticator = (\n authOptions: InternalAuthOptions\n): UserAuthenticationHandler => {\n if (typeof Runtime.getAuthorizers()[authOptions.transport] === 'undefined') {\n throw `'${authOptions.transport}' is not a recognized auth transport`;\n }\n\n return (\n params: UserAuthenticationRequestParams,\n callback: UserAuthenticationCallback\n ) => {\n const query = composeChannelQuery(params, authOptions);\n\n Runtime.getAuthorizers()[authOptions.transport](\n Runtime,\n query,\n authOptions,\n AuthRequestType.UserAuthentication,\n callback\n );\n };\n};\n\nexport default UserAuthenticator;\n","import {\n AuthRequestType,\n InternalAuthOptions,\n ChannelAuthorizationHandler,\n ChannelAuthorizationRequestParams,\n ChannelAuthorizationCallback\n} from './options';\n\nimport Runtime from 'runtime';\n\nconst composeChannelQuery = (\n params: ChannelAuthorizationRequestParams,\n authOptions: InternalAuthOptions\n) => {\n var query = 'socket_id=' + encodeURIComponent(params.socketId);\n\n query += '&channel_name=' + encodeURIComponent(params.channelName);\n\n for (var key in authOptions.params) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(authOptions.params[key]);\n }\n\n if (authOptions.paramsProvider != null) {\n let dynamicParams = authOptions.paramsProvider();\n for (var key in dynamicParams) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(dynamicParams[key]);\n }\n }\n\n return query;\n};\n\nconst ChannelAuthorizer = (\n authOptions: InternalAuthOptions\n): ChannelAuthorizationHandler => {\n if (typeof Runtime.getAuthorizers()[authOptions.transport] === 'undefined') {\n throw `'${authOptions.transport}' is not a recognized auth transport`;\n }\n\n return (\n params: ChannelAuthorizationRequestParams,\n callback: ChannelAuthorizationCallback\n ) => {\n const query = composeChannelQuery(params, authOptions);\n\n Runtime.getAuthorizers()[authOptions.transport](\n Runtime,\n query,\n authOptions,\n AuthRequestType.ChannelAuthorization,\n callback\n );\n };\n};\n\nexport default ChannelAuthorizer;\n","import Channel from '../channels/channel';\nimport {\n ChannelAuthorizationCallback,\n ChannelAuthorizationHandler,\n ChannelAuthorizationRequestParams,\n InternalAuthOptions\n} from './options';\n\nexport interface DeprecatedChannelAuthorizer {\n authorize(socketId: string, callback: ChannelAuthorizationCallback): void;\n}\n\nexport interface ChannelAuthorizerGenerator {\n (\n channel: Channel,\n options: DeprecatedAuthorizerOptions\n ): DeprecatedChannelAuthorizer;\n}\n\nexport interface DeprecatedAuthOptions {\n params?: any;\n headers?: any;\n}\n\nexport interface DeprecatedAuthorizerOptions {\n authTransport: 'ajax' | 'jsonp';\n authEndpoint: string;\n auth?: DeprecatedAuthOptions;\n}\n\nexport const ChannelAuthorizerProxy = (\n pusher,\n authOptions: InternalAuthOptions,\n channelAuthorizerGenerator: ChannelAuthorizerGenerator\n): ChannelAuthorizationHandler => {\n const deprecatedAuthorizerOptions: DeprecatedAuthorizerOptions = {\n authTransport: authOptions.transport,\n authEndpoint: authOptions.endpoint,\n auth: {\n params: authOptions.params,\n headers: authOptions.headers\n }\n };\n return (\n params: ChannelAuthorizationRequestParams,\n callback: ChannelAuthorizationCallback\n ) => {\n const channel = pusher.channel(params.channelName);\n // This line creates a new channel authorizer every time.\n // In the past, this was only done once per channel and reused.\n // We can do that again if we want to keep this behavior intact.\n const channelAuthorizer: DeprecatedChannelAuthorizer = channelAuthorizerGenerator(\n channel,\n deprecatedAuthorizerOptions\n );\n channelAuthorizer.authorize(params.socketId, callback);\n };\n};\n","import { Options } from './options';\nimport Defaults from './defaults';\nimport {\n ChannelAuthorizationHandler,\n UserAuthenticationHandler,\n ChannelAuthorizationOptions\n} from './auth/options';\nimport UserAuthenticator from './auth/user_authenticator';\nimport ChannelAuthorizer from './auth/channel_authorizer';\nimport { ChannelAuthorizerProxy } from './auth/deprecated_channel_authorizer';\nimport Runtime from 'runtime';\nimport * as nacl from 'tweetnacl';\n\nexport type AuthTransport = 'ajax' | 'jsonp';\nexport type Transport =\n | 'ws'\n | 'wss'\n | 'xhr_streaming'\n | 'xhr_polling'\n | 'sockjs';\n\nexport interface Config {\n // these are all 'required' config parameters, it's not necessary for the user\n // to set them, but they have configured defaults.\n activityTimeout: number;\n enableStats: boolean;\n httpHost: string;\n httpPath: string;\n httpPort: number;\n httpsPort: number;\n pongTimeout: number;\n statsHost: string;\n unavailableTimeout: number;\n useTLS: boolean;\n wsHost: string;\n wsPath: string;\n wsPort: number;\n wssPort: number;\n userAuthenticator: UserAuthenticationHandler;\n channelAuthorizer: ChannelAuthorizationHandler;\n\n // these are all optional parameters or overrrides. The customer can set these\n // but it's not strictly necessary\n forceTLS?: boolean;\n cluster?: string;\n disabledTransports?: Transport[];\n enabledTransports?: Transport[];\n ignoreNullOrigin?: boolean;\n nacl?: nacl;\n timelineParams?: any;\n}\n\n// getConfig mainly sets the defaults for the options that are not provided\nexport function getConfig(opts: Options, pusher): Config {\n let config: Config = {\n activityTimeout: opts.activityTimeout || Defaults.activityTimeout,\n cluster: opts.cluster,\n httpPath: opts.httpPath || Defaults.httpPath,\n httpPort: opts.httpPort || Defaults.httpPort,\n httpsPort: opts.httpsPort || Defaults.httpsPort,\n pongTimeout: opts.pongTimeout || Defaults.pongTimeout,\n statsHost: opts.statsHost || Defaults.stats_host,\n unavailableTimeout: opts.unavailableTimeout || Defaults.unavailableTimeout,\n wsPath: opts.wsPath || Defaults.wsPath,\n wsPort: opts.wsPort || Defaults.wsPort,\n wssPort: opts.wssPort || Defaults.wssPort,\n\n enableStats: getEnableStatsConfig(opts),\n httpHost: getHttpHost(opts),\n useTLS: shouldUseTLS(opts),\n wsHost: getWebsocketHost(opts),\n\n userAuthenticator: buildUserAuthenticator(opts),\n channelAuthorizer: buildChannelAuthorizer(opts, pusher)\n };\n\n if ('disabledTransports' in opts)\n config.disabledTransports = opts.disabledTransports;\n if ('enabledTransports' in opts)\n config.enabledTransports = opts.enabledTransports;\n if ('ignoreNullOrigin' in opts)\n config.ignoreNullOrigin = opts.ignoreNullOrigin;\n if ('timelineParams' in opts) config.timelineParams = opts.timelineParams;\n if ('nacl' in opts) {\n config.nacl = opts.nacl;\n }\n\n return config;\n}\n\nfunction getHttpHost(opts: Options): string {\n if (opts.httpHost) {\n return opts.httpHost;\n }\n if (opts.cluster) {\n return `sockjs-${opts.cluster}.pusher.com`;\n }\n return Defaults.httpHost;\n}\n\nfunction getWebsocketHost(opts: Options): string {\n if (opts.wsHost) {\n return opts.wsHost;\n }\n return getWebsocketHostFromCluster(opts.cluster);\n}\n\nfunction getWebsocketHostFromCluster(cluster: string): string {\n return `ws-${cluster}.pusher.com`;\n}\n\nfunction shouldUseTLS(opts: Options): boolean {\n if (Runtime.getProtocol() === 'https:') {\n return true;\n } else if (opts.forceTLS === false) {\n return false;\n }\n return true;\n}\n\n// if enableStats is set take the value\n// if disableStats is set take the inverse\n// otherwise default to false\nfunction getEnableStatsConfig(opts: Options): boolean {\n if ('enableStats' in opts) {\n return opts.enableStats;\n }\n if ('disableStats' in opts) {\n return !opts.disableStats;\n }\n return false;\n}\n\nfunction buildUserAuthenticator(opts: Options): UserAuthenticationHandler {\n const userAuthentication = {\n ...Defaults.userAuthentication,\n ...opts.userAuthentication\n };\n if (\n 'customHandler' in userAuthentication &&\n userAuthentication['customHandler'] != null\n ) {\n return userAuthentication['customHandler'];\n }\n\n return UserAuthenticator(userAuthentication);\n}\n\nfunction buildChannelAuth(opts: Options, pusher): ChannelAuthorizationOptions {\n let channelAuthorization: ChannelAuthorizationOptions;\n if ('channelAuthorization' in opts) {\n channelAuthorization = {\n ...Defaults.channelAuthorization,\n ...opts.channelAuthorization\n };\n } else {\n channelAuthorization = {\n transport: opts.authTransport || Defaults.authTransport,\n endpoint: opts.authEndpoint || Defaults.authEndpoint\n };\n if ('auth' in opts) {\n if ('params' in opts.auth) channelAuthorization.params = opts.auth.params;\n if ('headers' in opts.auth)\n channelAuthorization.headers = opts.auth.headers;\n }\n if ('authorizer' in opts)\n channelAuthorization.customHandler = ChannelAuthorizerProxy(\n pusher,\n channelAuthorization,\n opts.authorizer\n );\n }\n return channelAuthorization;\n}\n\nfunction buildChannelAuthorizer(\n opts: Options,\n pusher\n): ChannelAuthorizationHandler {\n const channelAuthorization = buildChannelAuth(opts, pusher);\n if (\n 'customHandler' in channelAuthorization &&\n channelAuthorization['customHandler'] != null\n ) {\n return channelAuthorization['customHandler'];\n }\n\n return ChannelAuthorizer(channelAuthorization);\n}\n","import Logger from './logger';\nimport Pusher from './pusher';\nimport EventsDispatcher from './events/dispatcher';\n\nexport default class WatchlistFacade extends EventsDispatcher {\n private pusher: Pusher;\n\n public constructor(pusher: Pusher) {\n super(function(eventName, data) {\n Logger.debug(`No callbacks on watchlist events for ${eventName}`);\n });\n\n this.pusher = pusher;\n this.bindWatchlistInternalEvent();\n }\n\n handleEvent(pusherEvent) {\n pusherEvent.data.events.forEach(watchlistEvent => {\n this.emit(watchlistEvent.name, watchlistEvent);\n });\n }\n\n private bindWatchlistInternalEvent() {\n this.pusher.connection.bind('message', pusherEvent => {\n var eventName = pusherEvent.event;\n if (eventName === 'pusher_internal:watchlist_events') {\n this.handleEvent(pusherEvent);\n }\n });\n }\n}\n","function flatPromise() {\n let resolve, reject;\n const promise = new Promise((res, rej) => {\n resolve = res;\n reject = rej;\n });\n return { promise, resolve, reject };\n}\n\nexport default flatPromise;\n","import Pusher from './pusher';\nimport Logger from './logger';\nimport {\n UserAuthenticationData,\n UserAuthenticationCallback\n} from './auth/options';\nimport Channel from './channels/channel';\nimport WatchlistFacade from './watchlist';\nimport EventsDispatcher from './events/dispatcher';\nimport flatPromise from './utils/flat_promise';\n\nexport default class UserFacade extends EventsDispatcher {\n pusher: Pusher;\n signin_requested: boolean = false;\n user_data: any = null;\n serverToUserChannel: Channel = null;\n signinDonePromise: Promise = null;\n watchlist: WatchlistFacade;\n private _signinDoneResolve: Function = null;\n\n public constructor(pusher: Pusher) {\n super(function(eventName, data) {\n Logger.debug('No callbacks on user for ' + eventName);\n });\n this.pusher = pusher;\n this.pusher.connection.bind('state_change', ({ previous, current }) => {\n if (previous !== 'connected' && current === 'connected') {\n this._signin();\n }\n if (previous === 'connected' && current !== 'connected') {\n this._cleanup();\n this._newSigninPromiseIfNeeded();\n }\n });\n\n this.watchlist = new WatchlistFacade(pusher);\n\n this.pusher.connection.bind('message', event => {\n var eventName = event.event;\n if (eventName === 'pusher:signin_success') {\n this._onSigninSuccess(event.data);\n }\n if (\n this.serverToUserChannel &&\n this.serverToUserChannel.name === event.channel\n ) {\n this.serverToUserChannel.handleEvent(event);\n }\n });\n }\n\n public signin() {\n if (this.signin_requested) {\n return;\n }\n\n this.signin_requested = true;\n this._signin();\n }\n\n private _signin() {\n if (!this.signin_requested) {\n return;\n }\n\n this._newSigninPromiseIfNeeded();\n\n if (this.pusher.connection.state !== 'connected') {\n // Signin will be attempted when the connection is connected\n return;\n }\n\n this.pusher.config.userAuthenticator(\n {\n socketId: this.pusher.connection.socket_id\n },\n this._onAuthorize\n );\n }\n\n private _onAuthorize: UserAuthenticationCallback = (\n err,\n authData: UserAuthenticationData\n ) => {\n if (err) {\n Logger.warn(`Error during signin: ${err}`);\n this._cleanup();\n return;\n }\n\n this.pusher.send_event('pusher:signin', {\n auth: authData.auth,\n user_data: authData.user_data\n });\n\n // Later when we get pusher:singin_success event, the user will be marked as signed in\n };\n\n private _onSigninSuccess(data: any) {\n try {\n this.user_data = JSON.parse(data.user_data);\n } catch (e) {\n Logger.error(`Failed parsing user data after signin: ${data.user_data}`);\n this._cleanup();\n return;\n }\n\n if (typeof this.user_data.id !== 'string' || this.user_data.id === '') {\n Logger.error(\n `user_data doesn't contain an id. user_data: ${this.user_data}`\n );\n this._cleanup();\n return;\n }\n\n // Signin succeeded\n this._signinDoneResolve();\n this._subscribeChannels();\n }\n\n private _subscribeChannels() {\n const ensure_subscribed = channel => {\n if (channel.subscriptionPending && channel.subscriptionCancelled) {\n channel.reinstateSubscription();\n } else if (\n !channel.subscriptionPending &&\n this.pusher.connection.state === 'connected'\n ) {\n channel.subscribe();\n }\n };\n\n this.serverToUserChannel = new Channel(\n `#server-to-user-${this.user_data.id}`,\n this.pusher\n );\n this.serverToUserChannel.bind_global((eventName, data) => {\n if (\n eventName.indexOf('pusher_internal:') === 0 ||\n eventName.indexOf('pusher:') === 0\n ) {\n // ignore internal events\n return;\n }\n this.emit(eventName, data);\n });\n ensure_subscribed(this.serverToUserChannel);\n }\n\n private _cleanup() {\n this.user_data = null;\n if (this.serverToUserChannel) {\n this.serverToUserChannel.unbind_all();\n this.serverToUserChannel.disconnect();\n this.serverToUserChannel = null;\n }\n\n if (this.signin_requested) {\n // If signin is in progress and cleanup is called,\n // Mark the current signin process as done.\n this._signinDoneResolve();\n }\n }\n\n private _newSigninPromiseIfNeeded() {\n if (!this.signin_requested) {\n return;\n }\n\n // If there is a promise and it is not resolved, return without creating a new one.\n if (this.signinDonePromise && !(this.signinDonePromise as any).done) {\n return;\n }\n\n // This promise is never rejected.\n // It gets resolved when the signin process is done whether it failed or succeeded\n const { promise, resolve, reject: _ } = flatPromise();\n (promise as any).done = false;\n const setDone = () => {\n (promise as any).done = true;\n };\n promise.then(setDone).catch(setDone);\n this.signinDonePromise = promise;\n this._signinDoneResolve = resolve;\n }\n}\n","import AbstractRuntime from '../runtimes/interface';\nimport Runtime from 'runtime';\nimport Util from './util';\nimport * as Collections from './utils/collections';\nimport Channels from './channels/channels';\nimport Channel from './channels/channel';\nimport { default as EventsDispatcher } from './events/dispatcher';\nimport Timeline from './timeline/timeline';\nimport TimelineSender from './timeline/timeline_sender';\nimport TimelineLevel from './timeline/level';\nimport { defineTransport } from './strategies/strategy_builder';\nimport ConnectionManager from './connection/connection_manager';\nimport ConnectionManagerOptions from './connection/connection_manager_options';\nimport { PeriodicTimer } from './utils/timers';\nimport Defaults from './defaults';\nimport * as DefaultConfig from './config';\nimport Logger from './logger';\nimport Factory from './utils/factory';\nimport UrlStore from 'core/utils/url_store';\nimport { Options, validateOptions } from './options';\nimport { Config, getConfig } from './config';\nimport StrategyOptions from './strategies/strategy_options';\nimport UserFacade from './user';\n\nexport default class Pusher {\n /* STATIC PROPERTIES */\n static instances: Pusher[] = [];\n static isReady: boolean = false;\n static logToConsole: boolean = false;\n\n // for jsonp\n static Runtime: AbstractRuntime = Runtime;\n static ScriptReceivers: any = (Runtime).ScriptReceivers;\n static DependenciesReceivers: any = (Runtime).DependenciesReceivers;\n static auth_callbacks: any = (Runtime).auth_callbacks;\n\n static ready() {\n Pusher.isReady = true;\n for (var i = 0, l = Pusher.instances.length; i < l; i++) {\n Pusher.instances[i].connect();\n }\n }\n\n static log: (message: any) => void;\n\n private static getClientFeatures(): string[] {\n return Collections.keys(\n Collections.filterObject({ ws: Runtime.Transports.ws }, function(t) {\n return t.isSupported({});\n })\n );\n }\n\n /* INSTANCE PROPERTIES */\n key: string;\n config: Config;\n channels: Channels;\n global_emitter: EventsDispatcher;\n sessionID: number;\n timeline: Timeline;\n timelineSender: TimelineSender;\n connection: ConnectionManager;\n timelineSenderTimer: PeriodicTimer;\n user: UserFacade;\n constructor(app_key: string, options: Options) {\n checkAppKey(app_key);\n validateOptions(options);\n this.key = app_key;\n this.config = getConfig(options, this);\n\n this.channels = Factory.createChannels();\n this.global_emitter = new EventsDispatcher();\n this.sessionID = Runtime.randomInt(1000000000);\n\n this.timeline = new Timeline(this.key, this.sessionID, {\n cluster: this.config.cluster,\n features: Pusher.getClientFeatures(),\n params: this.config.timelineParams || {},\n limit: 50,\n level: TimelineLevel.INFO,\n version: Defaults.VERSION\n });\n if (this.config.enableStats) {\n this.timelineSender = Factory.createTimelineSender(this.timeline, {\n host: this.config.statsHost,\n path: '/timeline/v2/' + Runtime.TimelineTransport.name\n });\n }\n\n var getStrategy = (options: StrategyOptions) => {\n return Runtime.getDefaultStrategy(this.config, options, defineTransport);\n };\n\n this.connection = Factory.createConnectionManager(this.key, {\n getStrategy: getStrategy,\n timeline: this.timeline,\n activityTimeout: this.config.activityTimeout,\n pongTimeout: this.config.pongTimeout,\n unavailableTimeout: this.config.unavailableTimeout,\n useTLS: Boolean(this.config.useTLS)\n });\n\n this.connection.bind('connected', () => {\n this.subscribeAll();\n if (this.timelineSender) {\n this.timelineSender.send(this.connection.isUsingTLS());\n }\n });\n\n this.connection.bind('message', event => {\n var eventName = event.event;\n var internal = eventName.indexOf('pusher_internal:') === 0;\n if (event.channel) {\n var channel = this.channel(event.channel);\n if (channel) {\n channel.handleEvent(event);\n }\n }\n // Emit globally [deprecated]\n if (!internal) {\n this.global_emitter.emit(event.event, event.data);\n }\n });\n this.connection.bind('connecting', () => {\n this.channels.disconnect();\n });\n this.connection.bind('disconnected', () => {\n this.channels.disconnect();\n });\n this.connection.bind('error', err => {\n Logger.warn(err);\n });\n\n Pusher.instances.push(this);\n this.timeline.info({ instances: Pusher.instances.length });\n\n this.user = new UserFacade(this);\n\n if (Pusher.isReady) {\n this.connect();\n }\n }\n\n channel(name: string): Channel {\n return this.channels.find(name);\n }\n\n allChannels(): Channel[] {\n return this.channels.all();\n }\n\n connect() {\n this.connection.connect();\n\n if (this.timelineSender) {\n if (!this.timelineSenderTimer) {\n var usingTLS = this.connection.isUsingTLS();\n var timelineSender = this.timelineSender;\n this.timelineSenderTimer = new PeriodicTimer(60000, function() {\n timelineSender.send(usingTLS);\n });\n }\n }\n }\n\n disconnect() {\n this.connection.disconnect();\n\n if (this.timelineSenderTimer) {\n this.timelineSenderTimer.ensureAborted();\n this.timelineSenderTimer = null;\n }\n }\n\n bind(event_name: string, callback: Function, context?: any): Pusher {\n this.global_emitter.bind(event_name, callback, context);\n return this;\n }\n\n unbind(event_name?: string, callback?: Function, context?: any): Pusher {\n this.global_emitter.unbind(event_name, callback, context);\n return this;\n }\n\n bind_global(callback: Function): Pusher {\n this.global_emitter.bind_global(callback);\n return this;\n }\n\n unbind_global(callback?: Function): Pusher {\n this.global_emitter.unbind_global(callback);\n return this;\n }\n\n unbind_all(callback?: Function): Pusher {\n this.global_emitter.unbind_all();\n return this;\n }\n\n subscribeAll() {\n var channelName;\n for (channelName in this.channels.channels) {\n if (this.channels.channels.hasOwnProperty(channelName)) {\n this.subscribe(channelName);\n }\n }\n }\n\n subscribe(channel_name: string) {\n var channel = this.channels.add(channel_name, this);\n if (channel.subscriptionPending && channel.subscriptionCancelled) {\n channel.reinstateSubscription();\n } else if (\n !channel.subscriptionPending &&\n this.connection.state === 'connected'\n ) {\n channel.subscribe();\n }\n return channel;\n }\n\n unsubscribe(channel_name: string) {\n var channel = this.channels.find(channel_name);\n if (channel && channel.subscriptionPending) {\n channel.cancelSubscription();\n } else {\n channel = this.channels.remove(channel_name);\n if (channel && channel.subscribed) {\n channel.unsubscribe();\n }\n }\n }\n\n send_event(event_name: string, data: any, channel?: string) {\n return this.connection.send_event(event_name, data, channel);\n }\n\n shouldUseTLS(): boolean {\n return this.config.useTLS;\n }\n\n signin() {\n this.user.signin();\n }\n}\n\nfunction checkAppKey(key) {\n if (key === null || key === undefined) {\n throw 'You must pass your app key when you instantiate Pusher.';\n }\n}\n\nRuntime.setup(Pusher);\n","import Pusher from './pusher';\nimport { Options, validateOptions } from './options';\nimport * as nacl from 'tweetnacl';\n\nexport default class PusherWithEncryption extends Pusher {\n constructor(app_key: string, options: Options) {\n Pusher.logToConsole = PusherWithEncryption.logToConsole;\n Pusher.log = PusherWithEncryption.log;\n\n validateOptions(options);\n options.nacl = nacl;\n super(app_key, options);\n }\n}\n"],"sourceRoot":""} \ No newline at end of file +{"version":3,"sources":["webpack://Pusher/webpack/bootstrap","webpack://Pusher/external \"util\"","webpack://Pusher/./node_modules/safe-buffer/index.js","webpack://Pusher/./node_modules/websocket-driver/lib/websocket/driver/base.js","webpack://Pusher/external \"crypto\"","webpack://Pusher/./node_modules/websocket-driver/lib/websocket/driver.js","webpack://Pusher/external \"stream\"","webpack://Pusher/external \"url\"","webpack://Pusher/./node_modules/faye-websocket/lib/faye/websocket/api/event.js","webpack://Pusher/./node_modules/@stablelib/base64/base64.ts","webpack://Pusher/./node_modules/websocket-driver/lib/websocket/driver/headers.js","webpack://Pusher/./node_modules/websocket-driver/lib/websocket/http_parser.js","webpack://Pusher/./node_modules/faye-websocket/lib/faye/websocket/api.js","webpack://Pusher/./node_modules/websocket-driver/lib/websocket/driver/hybi.js","webpack://Pusher/./node_modules/websocket-extensions/lib/pipeline/ring_buffer.js","webpack://Pusher/./node_modules/websocket-extensions/lib/pipeline/pledge.js","webpack://Pusher/./node_modules/websocket-driver/lib/websocket/driver/draft75.js","webpack://Pusher/./node_modules/faye-websocket/lib/faye/websocket/api/event_target.js","webpack://Pusher/./node_modules/@stablelib/utf8/utf8.ts","webpack://Pusher/./node_modules/faye-websocket/lib/faye/websocket.js","webpack://Pusher/./node_modules/xmlhttprequest/lib/XMLHttpRequest.js","webpack://Pusher/./node_modules/tweetnacl/nacl-fast.js","webpack://Pusher/./src/core/pusher-with-encryption.js","webpack://Pusher/external \"buffer\"","webpack://Pusher/external \"events\"","webpack://Pusher/./node_modules/websocket-driver/lib/websocket/streams.js","webpack://Pusher/./node_modules/websocket-driver/lib/websocket/driver/stream_reader.js","webpack://Pusher/./node_modules/websocket-driver/lib/websocket/driver/client.js","webpack://Pusher/./node_modules/http-parser-js/http-parser.js","webpack://Pusher/external \"assert\"","webpack://Pusher/./node_modules/websocket-extensions/lib/websocket_extensions.js","webpack://Pusher/./node_modules/websocket-extensions/lib/parser.js","webpack://Pusher/./node_modules/websocket-extensions/lib/pipeline/index.js","webpack://Pusher/./node_modules/websocket-extensions/lib/pipeline/cell.js","webpack://Pusher/./node_modules/websocket-extensions/lib/pipeline/functor.js","webpack://Pusher/./node_modules/websocket-driver/lib/websocket/driver/hybi/frame.js","webpack://Pusher/./node_modules/websocket-driver/lib/websocket/driver/hybi/message.js","webpack://Pusher/./node_modules/websocket-driver/lib/websocket/driver/proxy.js","webpack://Pusher/./node_modules/websocket-driver/lib/websocket/driver/server.js","webpack://Pusher/./node_modules/websocket-driver/lib/websocket/driver/draft76.js","webpack://Pusher/./node_modules/faye-websocket/lib/faye/websocket/client.js","webpack://Pusher/external \"net\"","webpack://Pusher/external \"tls\"","webpack://Pusher/./node_modules/faye-websocket/lib/faye/eventsource.js","webpack://Pusher/external \"child_process\"","webpack://Pusher/external \"fs\"","webpack://Pusher/external \"http\"","webpack://Pusher/external \"https\"","webpack://Pusher/./src/core/base64.ts","webpack://Pusher/./src/core/utils/timers/abstract_timer.ts","webpack://Pusher/./src/core/utils/timers/index.ts","webpack://Pusher/./src/core/util.ts","webpack://Pusher/./src/core/utils/collections.ts","webpack://Pusher/./src/core/defaults.ts","webpack://Pusher/./src/core/transports/url_schemes.ts","webpack://Pusher/./src/core/events/callback_registry.ts","webpack://Pusher/./src/core/events/dispatcher.ts","webpack://Pusher/./src/core/logger.ts","webpack://Pusher/./src/core/transports/transport_connection.ts","webpack://Pusher/./src/core/transports/transport.ts","webpack://Pusher/./src/runtimes/isomorphic/transports/transports.ts","webpack://Pusher/./src/core/transports/assistant_to_the_transport_manager.ts","webpack://Pusher/./src/core/connection/protocol/protocol.ts","webpack://Pusher/./src/core/connection/connection.ts","webpack://Pusher/./src/core/connection/handshake/index.ts","webpack://Pusher/./src/core/timeline/timeline_sender.ts","webpack://Pusher/./src/core/errors.ts","webpack://Pusher/./src/core/utils/url_store.ts","webpack://Pusher/./src/core/channels/channel.ts","webpack://Pusher/./src/core/channels/private_channel.ts","webpack://Pusher/./src/core/channels/members.ts","webpack://Pusher/./src/core/channels/presence_channel.ts","webpack://Pusher/./src/core/channels/encrypted_channel.ts","webpack://Pusher/./src/core/connection/connection_manager.ts","webpack://Pusher/./src/core/channels/channels.ts","webpack://Pusher/./src/core/utils/factory.ts","webpack://Pusher/./src/core/transports/transport_manager.ts","webpack://Pusher/./src/core/strategies/sequential_strategy.ts","webpack://Pusher/./src/core/strategies/best_connected_ever_strategy.ts","webpack://Pusher/./src/core/strategies/websocket_prioritized_cached_strategy.ts","webpack://Pusher/./src/core/strategies/delayed_strategy.ts","webpack://Pusher/./src/core/strategies/if_strategy.ts","webpack://Pusher/./src/core/strategies/first_connected_strategy.ts","webpack://Pusher/./src/runtimes/isomorphic/default_strategy.ts","webpack://Pusher/./src/runtimes/isomorphic/transports/transport_connection_initializer.ts","webpack://Pusher/./src/core/http/http_request.ts","webpack://Pusher/./src/core/http/state.ts","webpack://Pusher/./src/core/http/http_socket.ts","webpack://Pusher/./src/core/http/http_streaming_socket.ts","webpack://Pusher/./src/core/http/http_polling_socket.ts","webpack://Pusher/./src/runtimes/isomorphic/http/http_xhr_request.ts","webpack://Pusher/./src/runtimes/isomorphic/http/http.ts","webpack://Pusher/./src/runtimes/isomorphic/runtime.ts","webpack://Pusher/./src/runtimes/node/net_info.ts","webpack://Pusher/./src/core/auth/options.ts","webpack://Pusher/./src/runtimes/isomorphic/auth/xhr_auth.ts","webpack://Pusher/./src/runtimes/isomorphic/timeline/xhr_timeline.ts","webpack://Pusher/./src/runtimes/node/runtime.ts","webpack://Pusher/./src/core/timeline/level.ts","webpack://Pusher/./src/core/timeline/timeline.ts","webpack://Pusher/./src/core/strategies/transport_strategy.ts","webpack://Pusher/./src/core/strategies/strategy_builder.ts","webpack://Pusher/./src/core/options.ts","webpack://Pusher/./src/core/auth/user_authenticator.ts","webpack://Pusher/./src/core/auth/channel_authorizer.ts","webpack://Pusher/./src/core/auth/deprecated_channel_authorizer.ts","webpack://Pusher/./src/core/config.ts","webpack://Pusher/./src/core/watchlist.ts","webpack://Pusher/./src/core/utils/flat_promise.ts","webpack://Pusher/./src/core/user.ts","webpack://Pusher/./src/core/pusher.ts","webpack://Pusher/./src/core/pusher-with-encryption.ts"],"names":[],"mappings":";;;;;;;;;;QAAA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;;QAEA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;;;QAGA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;QACA,0CAA0C,gCAAgC;QAC1E;QACA;;QAEA;QACA;QACA;QACA,wDAAwD,kBAAkB;QAC1E;QACA,iDAAiD,cAAc;QAC/D;;QAEA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA,yCAAyC,iCAAiC;QAC1E,gHAAgH,mBAAmB,EAAE;QACrI;QACA;;QAEA;QACA;QACA;QACA,2BAA2B,0BAA0B,EAAE;QACvD,iCAAiC,eAAe;QAChD;QACA;QACA;;QAEA;QACA,sDAAsD,+DAA+D;;QAErH;QACA;;;QAGA;QACA;;;;;;;AClFA,iC;;;;;;ACAA;AACA,aAAa,mBAAO,CAAC,EAAQ;AAC7B;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AACD;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;;;;;;;AC7Da;;AAEb,cAAc,mBAAO,CAAC,CAAa;AACnC,cAAc,mBAAO,CAAC,EAAQ;AAC9B,cAAc,mBAAO,CAAC,CAAM;AAC5B,cAAc,mBAAO,CAAC,EAAY;AAClC,cAAc,mBAAO,CAAC,CAAW;AACjC,cAAc,mBAAO,CAAC,EAAiB;;AAEvC;AACA;AACA,oCAAoC;;AAEpC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA,2CAA2C;;AAE3C;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA,KAAK;AACL,GAAG;;AAEH;AACA;AACA,GAAG;;AAEH;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA;AACA,GAAG;;AAEH;AACA;;AAEA;AACA;;AAEA;;AAEA;AACA;AACA,KAAK;AACL;AACA;;AAEA;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA,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AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;;;;;;;;AClCa;;AAEb,qBAAqB,mBAAO,CAAC,EAAgB;AAC7C,qBAAqB,mBAAO,CAAC,CAAa;;AAE1C;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;;AAEA,mDAAmD,OAAO;AAC1D;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,sDAAsD,yBAAyB;AAC/E;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;;;;;;;;ACtIa;;AAEb,kBAAkB,mBAAO,CAAC,CAAQ;AAClC,kBAAkB,mBAAO,CAAC,CAAM;AAChC,kBAAkB,mBAAO,CAAC,CAAkB;AAC5C,kBAAkB,mBAAO,CAAC,EAAoB;AAC9C,kBAAkB,mBAAO,CAAC,CAAa;;AAEvC;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA,0CAA0C,eAAe;AACzD,0CAA0C,+BAA+B;AACzE,0CAA0C,qCAAqC;;AAE/E;AACA;AACA,GAAG;AACH,gCAAgC;;AAEhC;AACA;AACA,GAAG;;AAEH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AAO;AACrD;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA;;AAEA;AACA,8GAA8G,EAAE,uDAAuD,EAAE,wBAAwB,EAAE,4BAA4B,EAAE;;AAEjO;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA,yCAAyC,oCAAoC;AAC7E;AACA,KAAK;AACL;AACA;AACA,GAAG;;AAEH;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;;AAEA;AACA,GAAG;;AAEH;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,KAAK;AACL;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;AACA,GAAG;;AAEH;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA,GAAG;;AAEH;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL,GAAG;;AAEH;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA,KAAK;;AAEL;;AAEA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;;AAEA;AACA;AACA,GAAG;;AAEH;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA,GAAG;;AAEH;AACA;;AAEA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA,GAAG;;AAEH;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA,KAAK;AACL,GAAG;;AAEH;AACA;AACA;AACA;AACA,KAAK;AACL;AACA,GAAG;;AAEH;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;;;;;;;;AClea;;AAEb;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA,GAAG;AACH;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;;AAEA;;;;;;;;ACjEa;;AAEb,iBAAiB,mBAAO,CAAC,EAAe;;AAExC;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA,GAAG;AACH;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;;;;;;;;ACpCa;;AAEb,aAAa,mBAAO,CAAC,CAAa;AAClC,aAAa,mBAAO,CAAC,CAAQ;AAC7B,aAAa,mBAAO,CAAC,CAAM;;AAE3B;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;;AAEH;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa;AACb;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL,GAAG;;AAEH;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA,GAAG;;AAEH;AACA;AACA;;AAEA;AACA,GAAG;;AAEH;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;;;;;;;;AC1Ha;;AAEb,YAAY,mBAAO,CAAC,CAAS;;AAE7B;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,GAAG;;AAEH;AACA;AACA,GAAG;;AAEH;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;;;;;;;;;AC7BA,sCAAsC;AACtC,6CAA6C;;AAE7C;;GAEG;AAEH,IAAM,aAAa,GAAG,sBAAsB,CAAC;AAC7C,IAAM,YAAY,GAAG,+BAA+B,CAAC;AAErD;;;GAGG;AACH,SAAgB,MAAM,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AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,WAAW;AACX;AACA;AACA;AACA;AACA,SAAS;AACT,OAAO;AACP;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,KAAK;AACL;;AAEA;AACA,8CAA8C;AAC9C;AACA,KAAK;AACL;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;;AAET;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;;AAET;AACA;AACA,SAAS;AACT;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;;AAEA;AACA,KAAK,OAAO;AACZ;AACA;AACA;AACA;AACA;AACA,iGAAiG;AACjG,gEAAgE;AAChE,yDAAyD;AACzD,iCAAiC;AACjC,4DAA4D;AAC5D,wCAAwC;AACxC,gDAAgD;AAChD,mCAAmC;AACnC,YAAY,EAAE;AACd,0CAA0C;AAC1C,mEAAmE,kBAAkB,gFAAgF,WAAW;AAChL,6CAA6C;AAC7C,YAAY,EAAE;AACd,iDAAiD;AACjD,mEAAmE,WAAW,WAAW;AACzF,6CAA6C;AAC7C,YAAY,EAAE;AACd,YAAY,+BAA+B;AAC3C,mEAAmE,WAAW,WAAW;AACzF,6CAA6C;AAC7C,YAAY,EAAE;AACd,8FAA8F;AAC9F,qBAAqB;AACrB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,OAAO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,oDAAoD,SAAS;AAC7D;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;AC3mBA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,uBAAuB,iBAAiB;AACxC;AACA;;AAEA;AACA,wCAAwC,4BAA4B;;AAEpE;AACA,4BAA4B;;AAE5B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa,OAAO;AACpB;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,aAAa,QAAQ;AACrB,aAAa,OAAO;AACpB;AACA;AACA,eAAe,QAAQ;AACvB;AACA,eAAe,QAAQ;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB;AACA;AACA;;AAEA;AACA;AACA;AACA,aAAa,QAAQ;AACrB,aAAa,OAAO;AACpB;AACA;AACA,eAAe,QAAQ;AACvB;AACA,eAAe,QAAQ;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,iBAAiB,OAAO;AACxB;AACA;;AAEA;AACA;AACA;AACA;AACA,iBAAiB,OAAO;AACxB;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA,8CAA8C;AAC9C,8CAA8C;AAC9C,8CAA8C;AAC9C,8CAA8C;AAC9C,8CAA8C;AAC9C;AACA,8CAA8C;AAC9C,8CAA8C;AAC9C,8CAA8C;AAC9C;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,sDAAsD;AACtD,sDAAsD;AACtD,sDAAsD;AACtD,sDAAsD;AACtD,sDAAsD;AACtD;AACA,sDAAsD;AACtD,sDAAsD;AACtD,sDAAsD;AACtD;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA,qBAAqB;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA,qBAAqB;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA,qBAAqB;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA,qBAAqB;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA,qBAAqB;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA,qBAAqB;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA,qBAAqB;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA,qBAAqB;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA,qBAAqB;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA,qBAAqB;;AAErB;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA,UAAU,QAAQ;AAClB;AACA;AACA;;AAEA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA;AACA;;AAEA;AACA,aAAa,QAAQ;AACrB;AACA,aAAa,QAAQ;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa,OAAO;AACpB;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,UAAU;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,eAAe,WAAW;AAC1B;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;;AAEA;AACA;AACA,aAAa,QAAQ;AACrB;;AAEA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA,aAAa,OAAO;AACpB;AACA,eAAe,QAAQ;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;;AAEA;AACA,iBAAiB,QAAQ;AACzB;;AAEA;AACA,iBAAiB,QAAQ;AACzB;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD;;AAEA;AACA;AACA,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA,aAAa,QAAQ;AACrB,eAAe,QAAQ;AACvB;AACA;AACA;AACA,aAAa,QAAQ;AACrB;;AAEA;AACA;AACA;AACA,aAAa,QAAQ;AACrB,eAAe,QAAQ;AACvB;AACA;AACA;AACA,aAAa,QAAQ;AACrB;;AAEA;AACA;AACA;AACA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA;AACA,aAAa,MAAM;AACnB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,eAAe,QAAQ;AACvB;AACA;AACA;AACA;AACA,eAAe,QAAQ;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA,qBAAqB;AACrB,qBAAqB;;AAErB;AACA;AACA;;AAEA,sBAAsB;AACtB,sBAAsB;;AAEtB;AACA;AACA;;AAEA,sBAAsB;AACtB,sBAAsB;;AAEtB;AACA;AACA;;AAEA,sBAAsB;AACtB,sBAAsB;;AAEtB;AACA;AACA;;AAEA,sBAAsB;AACtB,sBAAsB;;AAEtB;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA,qBAAqB;AACrB,qBAAqB;;AAErB;AACA;AACA;;AAEA,sBAAsB;AACtB,sBAAsB;;AAEtB;AACA;AACA;;AAEA,sBAAsB;AACtB,sBAAsB;;AAEtB;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA,qBAAqB;AACrB,qBAAqB;;AAErB;AACA;;AAEA,sBAAsB;AACtB,sBAAsB;;AAEtB;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,mBAAmB,QAAQ;AAC3B;AACA;AACA;;AAEA,yBAAyB;AACzB,yBAAyB;;AAEzB;AACA;;AAEA,0BAA0B;AAC1B,0BAA0B;;AAE1B;AACA;AACA;AACA;AACA;;AAEA,0BAA0B;AAC1B,0BAA0B;;AAE1B;AACA;AACA;AACA;AACA;;AAEA,0BAA0B;AAC1B,0BAA0B;;AAE1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A;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa,OAAO;AACpB;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,QAAQ;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA,aAAa,QAAQ;AACrB;AACA;;AAEA;;AAEA;AACA;AACA,cAAc,SAAS;AACvB;AACA,gCAAgC,OAAO;AACvC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA;AACA,aAAa,QAAQ;AACrB,aAAa,QAAQ;AACrB;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa,QAAQ;AACrB,aAAa,QAAQ;AACrB;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA,aAAa,OAAO;AACpB,aAAa,QAAQ;;AAErB;AACA;AACA;AACA;;AAEA,cAAc,QAAQ;AACtB;AACA;;AAEA,aAAa,QAAQ;AACrB,aAAa,QAAQ;AACrB,aAAa,QAAQ;AACrB,eAAe,QAAQ;AACvB;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;;AAEA,aAAa,OAAO;AACpB,aAAa,QAAQ;AACrB;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA,eAAe,OAAO;AACtB;AACA;;AAEA,aAAa,OAAO;AACpB;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA,iBAAiB,sBAAsB;AACvC;AACA;AACA;AACA;;AAEA;AACA,iBAAiB,gBAAgB;AACjC;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,iBAAiB,gBAAgB;AACjC;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,iBAAiB,gBAAgB;AACjC;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA,UAAU;AACV;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,UAAU;AACV;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAiB,cAAc;AAC/B;AACA;;AAEA;AACA;AACA;AACA,iBAAiB,gBAAgB;AACjC;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa,uBAAuB;AACpC,aAAa,gBAAgB;AAC7B;AACA;;AAEA;AACA;AACA;AACA;AACA,UAAU;AACV;;AAEA;AACA;AACA;AACA;AACA;AACA,iBAAiB,eAAe;AAChC,UAAU;AACV;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAiB,QAAQ;AACzB;AACA,UAAU;AACV;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAiB,OAAO;AACxB;AACA;AACA,iBAAiB,OAAO;AACxB;AACA,KAAK;AACL,GAAG,UAAU,IAA8B;AAC3C;AACA,aAAa,mBAAO,CAAC,CAAQ;AAC7B;AACA;AACA;AACA,mBAAmB,OAAO;AAC1B;AACA,OAAO;AACP;AACA;AACA,CAAC;;AAED,CAAC,EAAE,KAA6B,kEAAkE;;;;;;;ACt1ElG,iBAAiB,mBAAO,CAAC,EAA0B;;;;;;;ACAnD,mC;;;;;;ACAA,mC;;;;;;;ACAa;;AAEb;;AAEA;AACA;;AAEA;AACA;;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AAGA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;;AAGA,aAAa,mBAAO,CAAC,CAAQ;AAC7B,aAAa,mBAAO,CAAC,CAAM;;;AAG3B;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;;AAGA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;;AAGA;AACA;;;;;;;;ACjJa;;AAEb,aAAa,mBAAO,CAAC,CAAa;;AAElC;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;;AAEA,mCAAmC,OAAO;AAC1C;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;;;;;;;ACpEa;;AAEb,iBAAiB,mBAAO,CAAC,CAAa;AACtC,iBAAiB,mBAAO,CAAC,CAAQ;AACjC,iBAAiB,mBAAO,CAAC,CAAK;AAC9B,iBAAiB,mBAAO,CAAC,CAAM;AAC/B,iBAAiB,mBAAO,CAAC,EAAgB;AACzC,iBAAiB,mBAAO,CAAC,CAAQ;AACjC,iBAAiB,mBAAO,CAAC,EAAQ;AACjC,iBAAiB,mBAAO,CAAC,EAAS;;AAElC;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA,GAAG;;AAEH;AACA;AACA;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;;AAEA;AACA;;AAEA;;;;;;;AC7IA;;AAEA,aAAa,mBAAO,CAAC,EAAQ;;AAE7B;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,sBAAsB;AACtB;AACA;AACA;AACA;;AAEA;AACA,qCAAqC;AACrC;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,8CAA8C,UAAU;;AAExD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,2BAA2B,SAAS;AACpC,4BAA4B;AAC5B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,UAAU;AACV;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,yCAAyC,EAAE;AAC3C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA,mDAAmD;AACnD;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA,mBAAmB,oBAAoB;AACvC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW;AACX;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA,KAAK;AACL;AACA;AACA,kCAAkC;AAClC;AACA,KAAK;AACL;AACA,KAAK;AACL;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH,CAAC;;AAED;AACA;AACA;AACA;AACA;;;;;;;AC9cA,mC;;;;;;;ACAa;;AAEb,eAAe,mBAAO,CAAC,EAAU;AACjC,eAAe,mBAAO,CAAC,EAAY;;AAEnC;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA,OAAO;AACP,KAAK;;AAEL;AACA;;AAEA;AACA,GAAG;;AAEH;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA,KAAK;;AAEL;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,KAAK;;AAEL;AACA;;AAEA;AACA,GAAG;;AAEH;AACA,mBAAmB,wCAAwC;AAC3D;;AAEA;AACA,gDAAgD,OAAO;AACvD;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA,GAAG;;AAEH;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;;;;;;;;ACjKa;;AAEb;AACA;AACA;AACA;AACA,gDAAgD;AAChD;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA,SAAS;AACT;AACA,SAAS;AACT;AACA;AACA;;AAEA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA,OAAO;AACP;AACA,KAAK;;AAEL;AACA,GAAG;;AAEH;AACA;;AAEA;AACA;AACA,mCAAmC,gBAAgB;AACnD,OAAO;AACP;AACA,OAAO;AACP;AACA,OAAO;AACP;AACA,OAAO;AACP;AACA;AACA;;AAEA;;AAEA,wCAAwC;AACxC;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA,sBAAsB,6BAA6B;AACnD;;AAEA;AACA;AACA,kCAAkC,OAAO;AACzC;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;;;;;;;;ACtGa;;AAEb,aAAa,mBAAO,CAAC,EAAQ;AAC7B,aAAa,mBAAO,CAAC,EAAU;;AAE/B;AACA,kDAAkD,2BAA2B;AAC7E,mBAAmB;AACnB;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA,mBAAmB;;AAEnB,4CAA4C,mBAAmB;AAC/D;AACA,wCAAwC,yBAAyB;AACjE;;AAEA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;;AAEA;;;;;;;;AC9Ca;;AAEb,cAAc,mBAAO,CAAC,EAAW;AACjC,cAAc,mBAAO,CAAC,EAAU;;AAEhC;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;;;;;;;;ACpDa;;AAEb,iBAAiB,mBAAO,CAAC,EAAe;;AAExC;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA,gBAAgB,oFAAoF;AACpG;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA,GAAG;AACH;AACA;AACA;;AAE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;AACpC,iBAAiB,mBAAO,CAAC,EAAW;AACpC,iBAAiB,mBAAO,CAAC,EAAQ;;AAEjC;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA,2CAA2C;AAC3C,kCAAkC;AAClC,GAAG;;AAEH;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA,4CAA4C,sBAAsB;AAClE,KAAK;;AAEL;AACA;;AAEA;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA,CAAC;;AAED;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;;;;;;;AC/Ga;;AAEb,cAAc,mBAAO,CAAC,CAAa;AACnC,cAAc,mBAAO,CAAC,CAAQ;AAC9B,cAAc,mBAAO,CAAC,EAAW;AACjC,cAAc,mBAAO,CAAC,CAAQ;AAC9B,cAAc,mBAAO,CAAC,CAAM;;;AAG5B;AACA;AACA;;AAEA;AACA;AACA;;;AAGA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA,GAAG;;AAEH;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA,GAAG;;AAEH;AACA;AACA;;AAEA;AACA;AACA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,GAAG;IACtB,IAAI,GAAG,KAAK,IAAI,IAAI,GAAG,KAAK,SAAS,EAAE;QACrC,MAAM,yDAAyD,CAAC;KACjE;AACH,CAAC;AAED,YAAO,CAAC,KAAK,CAAC,aAAM,CAAC,CAAC;;;;;;ACtQQ;AACuB;AACnB;AAEnB,MAAM,2CAAqB,SAAQ,WAAM;IACtD,YAAY,OAAe,EAAE,OAAgB;QAC3C,WAAM,CAAC,YAAY,GAAG,2CAAoB,CAAC,YAAY,CAAC;QACxD,WAAM,CAAC,GAAG,GAAG,2CAAoB,CAAC,GAAG,CAAC;QAEtC,eAAe,CAAC,OAAO,CAAC,CAAC;QACzB,OAAO,CAAC,IAAI,GAAG,SAAI,CAAC;QACpB,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAC1B,CAAC;CACF","file":"pusher.js","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 21);\n","module.exports = require(\"util\");","/* eslint-disable node/no-deprecated-api */\nvar buffer = require('buffer')\nvar Buffer = buffer.Buffer\n\n// alternative to using Object.keys for old browsers\nfunction copyProps (src, dst) {\n for (var key in src) {\n dst[key] = src[key]\n }\n}\nif (Buffer.from && Buffer.alloc && Buffer.allocUnsafe && Buffer.allocUnsafeSlow) {\n module.exports = buffer\n} else {\n // Copy properties from require('buffer')\n copyProps(buffer, exports)\n exports.Buffer = SafeBuffer\n}\n\nfunction SafeBuffer (arg, encodingOrOffset, length) {\n return Buffer(arg, encodingOrOffset, length)\n}\n\n// Copy static methods from Buffer\ncopyProps(Buffer, SafeBuffer)\n\nSafeBuffer.from = function (arg, encodingOrOffset, length) {\n if (typeof arg === 'number') {\n throw new TypeError('Argument must not be a number')\n }\n return Buffer(arg, encodingOrOffset, length)\n}\n\nSafeBuffer.alloc = function (size, fill, encoding) {\n if (typeof size !== 'number') {\n throw new TypeError('Argument must be a number')\n }\n var buf = Buffer(size)\n if (fill !== undefined) {\n if (typeof encoding === 'string') {\n buf.fill(fill, encoding)\n } else {\n buf.fill(fill)\n }\n } else {\n buf.fill(0)\n }\n return buf\n}\n\nSafeBuffer.allocUnsafe = function (size) {\n if (typeof size !== 'number') {\n throw new TypeError('Argument must be a number')\n }\n return Buffer(size)\n}\n\nSafeBuffer.allocUnsafeSlow = function (size) {\n if (typeof size !== 'number') {\n throw new TypeError('Argument must be a number')\n }\n return buffer.SlowBuffer(size)\n}\n","'use strict';\n\nvar Buffer = require('safe-buffer').Buffer,\n Emitter = require('events').EventEmitter,\n util = require('util'),\n streams = require('../streams'),\n Headers = require('./headers'),\n Reader = require('./stream_reader');\n\nvar Base = function(request, url, options) {\n Emitter.call(this);\n Base.validateOptions(options || {}, ['maxLength', 'masking', 'requireMasking', 'protocols']);\n\n this._request = request;\n this._reader = new Reader();\n this._options = options || {};\n this._maxLength = this._options.maxLength || this.MAX_LENGTH;\n this._headers = new Headers();\n this.__queue = [];\n this.readyState = 0;\n this.url = url;\n\n this.io = new streams.IO(this);\n this.messages = new streams.Messages(this);\n this._bindEventListeners();\n};\nutil.inherits(Base, Emitter);\n\nBase.isWebSocket = function(request) {\n var connection = request.headers.connection || '',\n upgrade = request.headers.upgrade || '';\n\n return request.method === 'GET' &&\n connection.toLowerCase().split(/ *, */).indexOf('upgrade') >= 0 &&\n upgrade.toLowerCase() === 'websocket';\n};\n\nBase.validateOptions = function(options, validKeys) {\n for (var key in options) {\n if (validKeys.indexOf(key) < 0)\n throw new Error('Unrecognized option: ' + key);\n }\n};\n\nvar instance = {\n // This is 64MB, small enough for an average VPS to handle without\n // crashing from process out of memory\n MAX_LENGTH: 0x3ffffff,\n\n STATES: ['connecting', 'open', 'closing', 'closed'],\n\n _bindEventListeners: function() {\n var self = this;\n\n // Protocol errors are informational and do not have to be handled\n this.messages.on('error', function() {});\n\n this.on('message', function(event) {\n var messages = self.messages;\n if (messages.readable) messages.emit('data', event.data);\n });\n\n this.on('error', function(error) {\n var messages = self.messages;\n if (messages.readable) messages.emit('error', error);\n });\n\n this.on('close', function() {\n var messages = self.messages;\n if (!messages.readable) return;\n messages.readable = messages.writable = false;\n messages.emit('end');\n });\n },\n\n getState: function() {\n return this.STATES[this.readyState] || null;\n },\n\n addExtension: function(extension) {\n return false;\n },\n\n setHeader: function(name, value) {\n if (this.readyState > 0) return false;\n this._headers.set(name, value);\n return true;\n },\n\n start: function() {\n if (this.readyState !== 0) return false;\n\n if (!Base.isWebSocket(this._request))\n return this._failHandshake(new Error('Not a WebSocket request'));\n\n var response;\n\n try {\n response = this._handshakeResponse();\n } catch (error) {\n return this._failHandshake(error);\n }\n\n this._write(response);\n if (this._stage !== -1) this._open();\n return true;\n },\n\n _failHandshake: function(error) {\n var headers = new Headers();\n headers.set('Content-Type', 'text/plain');\n headers.set('Content-Length', Buffer.byteLength(error.message, 'utf8'));\n\n headers = ['HTTP/1.1 400 Bad Request', headers.toString(), error.message];\n this._write(Buffer.from(headers.join('\\r\\n'), 'utf8'));\n this._fail('protocol_error', error.message);\n\n return false;\n },\n\n text: function(message) {\n return this.frame(message);\n },\n\n binary: function(message) {\n return false;\n },\n\n ping: function() {\n return false;\n },\n\n pong: function() {\n return false;\n },\n\n close: function(reason, code) {\n if (this.readyState !== 1) return false;\n this.readyState = 3;\n this.emit('close', new Base.CloseEvent(null, null));\n return true;\n },\n\n _open: function() {\n this.readyState = 1;\n this.__queue.forEach(function(args) { this.frame.apply(this, args) }, this);\n this.__queue = [];\n this.emit('open', new Base.OpenEvent());\n },\n\n _queue: function(message) {\n this.__queue.push(message);\n return true;\n },\n\n _write: function(chunk) {\n var io = this.io;\n if (io.readable) io.emit('data', chunk);\n },\n\n _fail: function(type, message) {\n this.readyState = 2;\n this.emit('error', new Error(message));\n this.close();\n }\n};\n\nfor (var key in instance)\n Base.prototype[key] = instance[key];\n\n\nBase.ConnectEvent = function() {};\n\nBase.OpenEvent = function() {};\n\nBase.CloseEvent = function(code, reason) {\n this.code = code;\n this.reason = reason;\n};\n\nBase.MessageEvent = function(data) {\n this.data = data;\n};\n\nBase.PingEvent = function(data) {\n this.data = data;\n};\n\nBase.PongEvent = function(data) {\n this.data = data;\n};\n\nmodule.exports = Base;\n","module.exports = require(\"crypto\");","'use strict';\n\n// Protocol references:\n//\n// * http://tools.ietf.org/html/draft-hixie-thewebsocketprotocol-75\n// * http://tools.ietf.org/html/draft-hixie-thewebsocketprotocol-76\n// * http://tools.ietf.org/html/draft-ietf-hybi-thewebsocketprotocol-17\n\nvar Base = require('./driver/base'),\n Client = require('./driver/client'),\n Server = require('./driver/server');\n\nvar Driver = {\n client: function(url, options) {\n options = options || {};\n if (options.masking === undefined) options.masking = true;\n return new Client(url, options);\n },\n\n server: function(options) {\n options = options || {};\n if (options.requireMasking === undefined) options.requireMasking = true;\n return new Server(options);\n },\n\n http: function() {\n return Server.http.apply(Server, arguments);\n },\n\n isSecureRequest: function(request) {\n return Server.isSecureRequest(request);\n },\n\n isWebSocket: function(request) {\n return Base.isWebSocket(request);\n },\n\n validateOptions: function(options, validKeys) {\n Base.validateOptions(options, validKeys);\n }\n};\n\nmodule.exports = Driver;\n","module.exports = require(\"stream\");","module.exports = require(\"url\");","'use strict';\n\nvar Event = function(eventType, options) {\n this.type = eventType;\n for (var key in options)\n this[key] = options[key];\n};\n\nEvent.prototype.initEvent = function(eventType, canBubble, cancelable) {\n this.type = eventType;\n this.bubbles = canBubble;\n this.cancelable = cancelable;\n};\n\nEvent.prototype.stopPropagation = function() {};\nEvent.prototype.preventDefault = function() {};\n\nEvent.CAPTURING_PHASE = 1;\nEvent.AT_TARGET = 2;\nEvent.BUBBLING_PHASE = 3;\n\nmodule.exports = Event;\n","// Copyright (C) 2016 Dmitry Chestnykh\n// MIT License. See LICENSE file for details.\n\n/**\n * Package base64 implements Base64 encoding and decoding.\n */\n\n// Invalid character used in decoding to indicate\n// that the character to decode is out of range of\n// alphabet and cannot be decoded.\nconst INVALID_BYTE = 256;\n\n/**\n * Implements standard Base64 encoding.\n *\n * Operates in constant time.\n */\nexport class Coder {\n // TODO(dchest): methods to encode chunk-by-chunk.\n\n constructor(private _paddingCharacter = \"=\") { }\n\n encodedLength(length: number): number {\n if (!this._paddingCharacter) {\n return (length * 8 + 5) / 6 | 0;\n }\n return (length + 2) / 3 * 4 | 0;\n }\n\n encode(data: Uint8Array): string {\n let out = \"\";\n\n let i = 0;\n for (; i < data.length - 2; i += 3) {\n let c = (data[i] << 16) | (data[i + 1] << 8) | (data[i + 2]);\n out += this._encodeByte((c >>> 3 * 6) & 63);\n out += this._encodeByte((c >>> 2 * 6) & 63);\n out += this._encodeByte((c >>> 1 * 6) & 63);\n out += this._encodeByte((c >>> 0 * 6) & 63);\n }\n\n const left = data.length - i;\n if (left > 0) {\n let c = (data[i] << 16) | (left === 2 ? data[i + 1] << 8 : 0);\n out += this._encodeByte((c >>> 3 * 6) & 63);\n out += this._encodeByte((c >>> 2 * 6) & 63);\n if (left === 2) {\n out += this._encodeByte((c >>> 1 * 6) & 63);\n } else {\n out += this._paddingCharacter || \"\";\n }\n out += this._paddingCharacter || \"\";\n }\n\n return out;\n }\n\n maxDecodedLength(length: number): number {\n if (!this._paddingCharacter) {\n return (length * 6 + 7) / 8 | 0;\n }\n return length / 4 * 3 | 0;\n }\n\n decodedLength(s: string): number {\n return this.maxDecodedLength(s.length - this._getPaddingLength(s));\n }\n\n decode(s: string): Uint8Array {\n if (s.length === 0) {\n return new Uint8Array(0);\n }\n const paddingLength = this._getPaddingLength(s);\n const length = s.length - paddingLength;\n const out = new Uint8Array(this.maxDecodedLength(length));\n let op = 0;\n let i = 0;\n let haveBad = 0;\n let v0 = 0, v1 = 0, v2 = 0, v3 = 0;\n for (; i < length - 4; i += 4) {\n v0 = this._decodeChar(s.charCodeAt(i + 0));\n v1 = this._decodeChar(s.charCodeAt(i + 1));\n v2 = this._decodeChar(s.charCodeAt(i + 2));\n v3 = this._decodeChar(s.charCodeAt(i + 3));\n out[op++] = (v0 << 2) | (v1 >>> 4);\n out[op++] = (v1 << 4) | (v2 >>> 2);\n out[op++] = (v2 << 6) | v3;\n haveBad |= v0 & INVALID_BYTE;\n haveBad |= v1 & INVALID_BYTE;\n haveBad |= v2 & INVALID_BYTE;\n haveBad |= v3 & INVALID_BYTE;\n }\n if (i < length - 1) {\n v0 = this._decodeChar(s.charCodeAt(i));\n v1 = this._decodeChar(s.charCodeAt(i + 1));\n out[op++] = (v0 << 2) | (v1 >>> 4);\n haveBad |= v0 & INVALID_BYTE;\n haveBad |= v1 & INVALID_BYTE;\n }\n if (i < length - 2) {\n v2 = this._decodeChar(s.charCodeAt(i + 2));\n out[op++] = (v1 << 4) | (v2 >>> 2);\n haveBad |= v2 & INVALID_BYTE;\n }\n if (i < length - 3) {\n v3 = this._decodeChar(s.charCodeAt(i + 3));\n out[op++] = (v2 << 6) | v3;\n haveBad |= v3 & INVALID_BYTE;\n }\n if (haveBad !== 0) {\n throw new Error(\"Base64Coder: incorrect characters for decoding\");\n }\n return out;\n }\n\n // Standard encoding have the following encoded/decoded ranges,\n // which we need to convert between.\n //\n // ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 0123456789 + /\n // Index: 0 - 25 26 - 51 52 - 61 62 63\n // ASCII: 65 - 90 97 - 122 48 - 57 43 47\n //\n\n // Encode 6 bits in b into a new character.\n protected _encodeByte(b: number): string {\n // Encoding uses constant time operations as follows:\n //\n // 1. Define comparison of A with B using (A - B) >>> 8:\n // if A > B, then result is positive integer\n // if A <= B, then result is 0\n //\n // 2. Define selection of C or 0 using bitwise AND: X & C:\n // if X == 0, then result is 0\n // if X != 0, then result is C\n //\n // 3. Start with the smallest comparison (b >= 0), which is always\n // true, so set the result to the starting ASCII value (65).\n //\n // 4. Continue comparing b to higher ASCII values, and selecting\n // zero if comparison isn't true, otherwise selecting a value\n // to add to result, which:\n //\n // a) undoes the previous addition\n // b) provides new value to add\n //\n let result = b;\n // b >= 0\n result += 65;\n // b > 25\n result += ((25 - b) >>> 8) & ((0 - 65) - 26 + 97);\n // b > 51\n result += ((51 - b) >>> 8) & ((26 - 97) - 52 + 48);\n // b > 61\n result += ((61 - b) >>> 8) & ((52 - 48) - 62 + 43);\n // b > 62\n result += ((62 - b) >>> 8) & ((62 - 43) - 63 + 47);\n\n return String.fromCharCode(result);\n }\n\n // Decode a character code into a byte.\n // Must return 256 if character is out of alphabet range.\n protected _decodeChar(c: number): number {\n // Decoding works similar to encoding: using the same comparison\n // function, but now it works on ranges: result is always incremented\n // by value, but this value becomes zero if the range is not\n // satisfied.\n //\n // Decoding starts with invalid value, 256, which is then\n // subtracted when the range is satisfied. If none of the ranges\n // apply, the function returns 256, which is then checked by\n // the caller to throw error.\n let result = INVALID_BYTE; // start with invalid character\n\n // c == 43 (c > 42 and c < 44)\n result += (((42 - c) & (c - 44)) >>> 8) & (-INVALID_BYTE + c - 43 + 62);\n // c == 47 (c > 46 and c < 48)\n result += (((46 - c) & (c - 48)) >>> 8) & (-INVALID_BYTE + c - 47 + 63);\n // c > 47 and c < 58\n result += (((47 - c) & (c - 58)) >>> 8) & (-INVALID_BYTE + c - 48 + 52);\n // c > 64 and c < 91\n result += (((64 - c) & (c - 91)) >>> 8) & (-INVALID_BYTE + c - 65 + 0);\n // c > 96 and c < 123\n result += (((96 - c) & (c - 123)) >>> 8) & (-INVALID_BYTE + c - 97 + 26);\n\n return result;\n }\n\n private _getPaddingLength(s: string): number {\n let paddingLength = 0;\n if (this._paddingCharacter) {\n for (let i = s.length - 1; i >= 0; i--) {\n if (s[i] !== this._paddingCharacter) {\n break;\n }\n paddingLength++;\n }\n if (s.length < 4 || paddingLength > 2) {\n throw new Error(\"Base64Coder: incorrect padding\");\n }\n }\n return paddingLength;\n }\n\n}\n\nconst stdCoder = new Coder();\n\nexport function encode(data: Uint8Array): string {\n return stdCoder.encode(data);\n}\n\nexport function decode(s: string): Uint8Array {\n return stdCoder.decode(s);\n}\n\n/**\n * Implements URL-safe Base64 encoding.\n * (Same as Base64, but '+' is replaced with '-', and '/' with '_').\n *\n * Operates in constant time.\n */\nexport class URLSafeCoder extends Coder {\n // URL-safe encoding have the following encoded/decoded ranges:\n //\n // ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 0123456789 - _\n // Index: 0 - 25 26 - 51 52 - 61 62 63\n // ASCII: 65 - 90 97 - 122 48 - 57 45 95\n //\n\n protected _encodeByte(b: number): string {\n let result = b;\n // b >= 0\n result += 65;\n // b > 25\n result += ((25 - b) >>> 8) & ((0 - 65) - 26 + 97);\n // b > 51\n result += ((51 - b) >>> 8) & ((26 - 97) - 52 + 48);\n // b > 61\n result += ((61 - b) >>> 8) & ((52 - 48) - 62 + 45);\n // b > 62\n result += ((62 - b) >>> 8) & ((62 - 45) - 63 + 95);\n\n return String.fromCharCode(result);\n }\n\n protected _decodeChar(c: number): number {\n let result = INVALID_BYTE;\n\n // c == 45 (c > 44 and c < 46)\n result += (((44 - c) & (c - 46)) >>> 8) & (-INVALID_BYTE + c - 45 + 62);\n // c == 95 (c > 94 and c < 96)\n result += (((94 - c) & (c - 96)) >>> 8) & (-INVALID_BYTE + c - 95 + 63);\n // c > 47 and c < 58\n result += (((47 - c) & (c - 58)) >>> 8) & (-INVALID_BYTE + c - 48 + 52);\n // c > 64 and c < 91\n result += (((64 - c) & (c - 91)) >>> 8) & (-INVALID_BYTE + c - 65 + 0);\n // c > 96 and c < 123\n result += (((96 - c) & (c - 123)) >>> 8) & (-INVALID_BYTE + c - 97 + 26);\n\n return result;\n }\n}\n\nconst urlSafeCoder = new URLSafeCoder();\n\nexport function encodeURLSafe(data: Uint8Array): string {\n return urlSafeCoder.encode(data);\n}\n\nexport function decodeURLSafe(s: string): Uint8Array {\n return urlSafeCoder.decode(s);\n}\n\n\nexport const encodedLength = (length: number) =>\n stdCoder.encodedLength(length);\n\nexport const maxDecodedLength = (length: number) =>\n stdCoder.maxDecodedLength(length);\n\nexport const decodedLength = (s: string) =>\n stdCoder.decodedLength(s);\n","'use strict';\n\nvar Headers = function() {\n this.clear();\n};\n\nHeaders.prototype.ALLOWED_DUPLICATES = ['set-cookie', 'set-cookie2', 'warning', 'www-authenticate'];\n\nHeaders.prototype.clear = function() {\n this._sent = {};\n this._lines = [];\n};\n\nHeaders.prototype.set = function(name, value) {\n if (value === undefined) return;\n\n name = this._strip(name);\n value = this._strip(value);\n\n var key = name.toLowerCase();\n if (!this._sent.hasOwnProperty(key) || this.ALLOWED_DUPLICATES.indexOf(key) >= 0) {\n this._sent[key] = true;\n this._lines.push(name + ': ' + value + '\\r\\n');\n }\n};\n\nHeaders.prototype.toString = function() {\n return this._lines.join('');\n};\n\nHeaders.prototype._strip = function(string) {\n return string.toString().replace(/^ */, '').replace(/ *$/, '');\n};\n\nmodule.exports = Headers;\n","'use strict';\n\nvar NodeHTTPParser = require('http-parser-js').HTTPParser,\n Buffer = require('safe-buffer').Buffer;\n\nvar TYPES = {\n request: NodeHTTPParser.REQUEST || 'request',\n response: NodeHTTPParser.RESPONSE || 'response'\n};\n\nvar HttpParser = function(type) {\n this._type = type;\n this._parser = new NodeHTTPParser(TYPES[type]);\n this._complete = false;\n this.headers = {};\n\n var current = null,\n self = this;\n\n this._parser.onHeaderField = function(b, start, length) {\n current = b.toString('utf8', start, start + length).toLowerCase();\n };\n\n this._parser.onHeaderValue = function(b, start, length) {\n var value = b.toString('utf8', start, start + length);\n\n if (self.headers.hasOwnProperty(current))\n self.headers[current] += ', ' + value;\n else\n self.headers[current] = value;\n };\n\n this._parser.onHeadersComplete = this._parser[NodeHTTPParser.kOnHeadersComplete] =\n function(majorVersion, minorVersion, headers, method, pathname, statusCode) {\n var info = arguments[0];\n\n if (typeof info === 'object') {\n method = info.method;\n pathname = info.url;\n statusCode = info.statusCode;\n headers = info.headers;\n }\n\n self.method = (typeof method === 'number') ? HttpParser.METHODS[method] : method;\n self.statusCode = statusCode;\n self.url = pathname;\n\n if (!headers) return;\n\n for (var i = 0, n = headers.length, key, value; i < n; i += 2) {\n key = headers[i].toLowerCase();\n value = headers[i+1];\n if (self.headers.hasOwnProperty(key))\n self.headers[key] += ', ' + value;\n else\n self.headers[key] = value;\n }\n\n self._complete = true;\n };\n};\n\nHttpParser.METHODS = {\n 0: 'DELETE',\n 1: 'GET',\n 2: 'HEAD',\n 3: 'POST',\n 4: 'PUT',\n 5: 'CONNECT',\n 6: 'OPTIONS',\n 7: 'TRACE',\n 8: 'COPY',\n 9: 'LOCK',\n 10: 'MKCOL',\n 11: 'MOVE',\n 12: 'PROPFIND',\n 13: 'PROPPATCH',\n 14: 'SEARCH',\n 15: 'UNLOCK',\n 16: 'BIND',\n 17: 'REBIND',\n 18: 'UNBIND',\n 19: 'ACL',\n 20: 'REPORT',\n 21: 'MKACTIVITY',\n 22: 'CHECKOUT',\n 23: 'MERGE',\n 24: 'M-SEARCH',\n 25: 'NOTIFY',\n 26: 'SUBSCRIBE',\n 27: 'UNSUBSCRIBE',\n 28: 'PATCH',\n 29: 'PURGE',\n 30: 'MKCALENDAR',\n 31: 'LINK',\n 32: 'UNLINK'\n};\n\nvar VERSION = process.version\n ? process.version.match(/[0-9]+/g).map(function(n) { return parseInt(n, 10) })\n : [];\n\nif (VERSION[0] === 0 && VERSION[1] === 12) {\n HttpParser.METHODS[16] = 'REPORT';\n HttpParser.METHODS[17] = 'MKACTIVITY';\n HttpParser.METHODS[18] = 'CHECKOUT';\n HttpParser.METHODS[19] = 'MERGE';\n HttpParser.METHODS[20] = 'M-SEARCH';\n HttpParser.METHODS[21] = 'NOTIFY';\n HttpParser.METHODS[22] = 'SUBSCRIBE';\n HttpParser.METHODS[23] = 'UNSUBSCRIBE';\n HttpParser.METHODS[24] = 'PATCH';\n HttpParser.METHODS[25] = 'PURGE';\n}\n\nHttpParser.prototype.isComplete = function() {\n return this._complete;\n};\n\nHttpParser.prototype.parse = function(chunk) {\n var consumed = this._parser.execute(chunk, 0, chunk.length);\n\n if (typeof consumed !== 'number') {\n this.error = consumed;\n this._complete = true;\n return;\n }\n\n if (this._complete)\n this.body = (consumed < chunk.length)\n ? chunk.slice(consumed)\n : Buffer.alloc(0);\n};\n\nmodule.exports = HttpParser;\n","'use strict';\n\nvar Stream = require('stream').Stream,\n util = require('util'),\n driver = require('websocket-driver'),\n EventTarget = require('./api/event_target'),\n Event = require('./api/event');\n\nvar API = function(options) {\n options = options || {};\n driver.validateOptions(options, ['headers', 'extensions', 'maxLength', 'ping', 'proxy', 'tls', 'ca']);\n\n this.readable = this.writable = true;\n\n var headers = options.headers;\n if (headers) {\n for (var name in headers) this._driver.setHeader(name, headers[name]);\n }\n\n var extensions = options.extensions;\n if (extensions) {\n [].concat(extensions).forEach(this._driver.addExtension, this._driver);\n }\n\n this._ping = options.ping;\n this._pingId = 0;\n this.readyState = API.CONNECTING;\n this.bufferedAmount = 0;\n this.protocol = '';\n this.url = this._driver.url;\n this.version = this._driver.version;\n\n var self = this;\n\n this._driver.on('open', function(e) { self._open() });\n this._driver.on('message', function(e) { self._receiveMessage(e.data) });\n this._driver.on('close', function(e) { self._beginClose(e.reason, e.code) });\n\n this._driver.on('error', function(error) {\n self._emitError(error.message);\n });\n this.on('error', function() {});\n\n this._driver.messages.on('drain', function() {\n self.emit('drain');\n });\n\n if (this._ping)\n this._pingTimer = setInterval(function() {\n self._pingId += 1;\n self.ping(self._pingId.toString());\n }, this._ping * 1000);\n\n this._configureStream();\n\n if (!this._proxy) {\n this._stream.pipe(this._driver.io);\n this._driver.io.pipe(this._stream);\n }\n};\nutil.inherits(API, Stream);\n\nAPI.CONNECTING = 0;\nAPI.OPEN = 1;\nAPI.CLOSING = 2;\nAPI.CLOSED = 3;\n\nAPI.CLOSE_TIMEOUT = 30000;\n\nvar instance = {\n write: function(data) {\n return this.send(data);\n },\n\n end: function(data) {\n if (data !== undefined) this.send(data);\n this.close();\n },\n\n pause: function() {\n return this._driver.messages.pause();\n },\n\n resume: function() {\n return this._driver.messages.resume();\n },\n\n send: function(data) {\n if (this.readyState > API.OPEN) return false;\n if (!(data instanceof Buffer)) data = String(data);\n return this._driver.messages.write(data);\n },\n\n ping: function(message, callback) {\n if (this.readyState > API.OPEN) return false;\n return this._driver.ping(message, callback);\n },\n\n close: function(code, reason) {\n if (code === undefined) code = 1000;\n if (reason === undefined) reason = '';\n\n if (code !== 1000 && (code < 3000 || code > 4999))\n throw new Error(\"Failed to execute 'close' on WebSocket: \" +\n \"The code must be either 1000, or between 3000 and 4999. \" +\n code + \" is neither.\");\n\n if (this.readyState !== API.CLOSED) this.readyState = API.CLOSING;\n var self = this;\n\n this._closeTimer = setTimeout(function() {\n self._beginClose('', 1006);\n }, API.CLOSE_TIMEOUT);\n\n this._driver.close(reason, code);\n },\n\n _configureStream: function() {\n var self = this;\n\n this._stream.setTimeout(0);\n this._stream.setNoDelay(true);\n\n ['close', 'end'].forEach(function(event) {\n this._stream.on(event, function() { self._finalizeClose() });\n }, this);\n\n this._stream.on('error', function(error) {\n self._emitError('Network error: ' + self.url + ': ' + error.message);\n self._finalizeClose();\n });\n },\n\n _open: function() {\n if (this.readyState !== API.CONNECTING) return;\n\n this.readyState = API.OPEN;\n this.protocol = this._driver.protocol || '';\n\n var event = new Event('open');\n event.initEvent('open', false, false);\n this.dispatchEvent(event);\n },\n\n _receiveMessage: function(data) {\n if (this.readyState > API.OPEN) return false;\n\n if (this.readable) this.emit('data', data);\n\n var event = new Event('message', {data: data});\n event.initEvent('message', false, false);\n this.dispatchEvent(event);\n },\n\n _emitError: function(message) {\n if (this.readyState >= API.CLOSING) return;\n\n var event = new Event('error', {message: message});\n event.initEvent('error', false, false);\n this.dispatchEvent(event);\n },\n\n _beginClose: function(reason, code) {\n if (this.readyState === API.CLOSED) return;\n this.readyState = API.CLOSING;\n this._closeParams = [reason, code];\n\n if (this._stream) {\n this._stream.destroy();\n if (!this._stream.readable) this._finalizeClose();\n }\n },\n\n _finalizeClose: function() {\n if (this.readyState === API.CLOSED) return;\n this.readyState = API.CLOSED;\n\n if (this._closeTimer) clearTimeout(this._closeTimer);\n if (this._pingTimer) clearInterval(this._pingTimer);\n if (this._stream) this._stream.end();\n\n if (this.readable) this.emit('end');\n this.readable = this.writable = false;\n\n var reason = this._closeParams ? this._closeParams[0] : '',\n code = this._closeParams ? this._closeParams[1] : 1006;\n\n var event = new Event('close', {code: code, reason: reason});\n event.initEvent('close', false, false);\n this.dispatchEvent(event);\n }\n};\n\nfor (var method in instance) API.prototype[method] = instance[method];\nfor (var key in EventTarget) API.prototype[key] = EventTarget[key];\n\nmodule.exports = API;\n","'use strict';\n\nvar Buffer = require('safe-buffer').Buffer,\n crypto = require('crypto'),\n util = require('util'),\n Extensions = require('websocket-extensions'),\n Base = require('./base'),\n Frame = require('./hybi/frame'),\n Message = require('./hybi/message');\n\nvar Hybi = function(request, url, options) {\n Base.apply(this, arguments);\n\n this._extensions = new Extensions();\n this._stage = 0;\n this._masking = this._options.masking;\n this._protocols = this._options.protocols || [];\n this._requireMasking = this._options.requireMasking;\n this._pingCallbacks = {};\n\n if (typeof this._protocols === 'string')\n this._protocols = this._protocols.split(/ *, */);\n\n if (!this._request) return;\n\n var protos = this._request.headers['sec-websocket-protocol'],\n supported = this._protocols;\n\n if (protos !== undefined) {\n if (typeof protos === 'string') protos = protos.split(/ *, */);\n this.protocol = protos.filter(function(p) { return supported.indexOf(p) >= 0 })[0];\n }\n\n this.version = 'hybi-' + Hybi.VERSION;\n};\nutil.inherits(Hybi, Base);\n\nHybi.VERSION = '13';\n\nHybi.mask = function(payload, mask, offset) {\n if (!mask || mask.length === 0) return payload;\n offset = offset || 0;\n\n for (var i = 0, n = payload.length - offset; i < n; i++) {\n payload[offset + i] = payload[offset + i] ^ mask[i % 4];\n }\n return payload;\n};\n\nHybi.generateAccept = function(key) {\n var sha1 = crypto.createHash('sha1');\n sha1.update(key + Hybi.GUID);\n return sha1.digest('base64');\n};\n\nHybi.GUID = '258EAFA5-E914-47DA-95CA-C5AB0DC85B11';\n\nvar instance = {\n FIN: 0x80,\n MASK: 0x80,\n RSV1: 0x40,\n RSV2: 0x20,\n RSV3: 0x10,\n OPCODE: 0x0F,\n LENGTH: 0x7F,\n\n OPCODES: {\n continuation: 0,\n text: 1,\n binary: 2,\n close: 8,\n ping: 9,\n pong: 10\n },\n\n OPCODE_CODES: [0, 1, 2, 8, 9, 10],\n MESSAGE_OPCODES: [0, 1, 2],\n OPENING_OPCODES: [1, 2],\n\n ERRORS: {\n normal_closure: 1000,\n going_away: 1001,\n protocol_error: 1002,\n unacceptable: 1003,\n encoding_error: 1007,\n policy_violation: 1008,\n too_large: 1009,\n extension_error: 1010,\n unexpected_condition: 1011\n },\n\n ERROR_CODES: [1000, 1001, 1002, 1003, 1007, 1008, 1009, 1010, 1011],\n DEFAULT_ERROR_CODE: 1000,\n MIN_RESERVED_ERROR: 3000,\n MAX_RESERVED_ERROR: 4999,\n\n // http://www.w3.org/International/questions/qa-forms-utf-8.en.php\n UTF8_MATCH: /^([\\x00-\\x7F]|[\\xC2-\\xDF][\\x80-\\xBF]|\\xE0[\\xA0-\\xBF][\\x80-\\xBF]|[\\xE1-\\xEC\\xEE\\xEF][\\x80-\\xBF]{2}|\\xED[\\x80-\\x9F][\\x80-\\xBF]|\\xF0[\\x90-\\xBF][\\x80-\\xBF]{2}|[\\xF1-\\xF3][\\x80-\\xBF]{3}|\\xF4[\\x80-\\x8F][\\x80-\\xBF]{2})*$/,\n\n addExtension: function(extension) {\n this._extensions.add(extension);\n return true;\n },\n\n parse: function(chunk) {\n this._reader.put(chunk);\n var buffer = true;\n while (buffer) {\n switch (this._stage) {\n case 0:\n buffer = this._reader.read(1);\n if (buffer) this._parseOpcode(buffer[0]);\n break;\n\n case 1:\n buffer = this._reader.read(1);\n if (buffer) this._parseLength(buffer[0]);\n break;\n\n case 2:\n buffer = this._reader.read(this._frame.lengthBytes);\n if (buffer) this._parseExtendedLength(buffer);\n break;\n\n case 3:\n buffer = this._reader.read(4);\n if (buffer) {\n this._stage = 4;\n this._frame.maskingKey = buffer;\n }\n break;\n\n case 4:\n buffer = this._reader.read(this._frame.length);\n if (buffer) {\n this._stage = 0;\n this._emitFrame(buffer);\n }\n break;\n\n default:\n buffer = null;\n }\n }\n },\n\n text: function(message) {\n if (this.readyState > 1) return false;\n return this.frame(message, 'text');\n },\n\n binary: function(message) {\n if (this.readyState > 1) return false;\n return this.frame(message, 'binary');\n },\n\n ping: function(message, callback) {\n if (this.readyState > 1) return false;\n message = message || '';\n if (callback) this._pingCallbacks[message] = callback;\n return this.frame(message, 'ping');\n },\n\n pong: function(message) {\n if (this.readyState > 1) return false;\n message = message ||'';\n return this.frame(message, 'pong');\n },\n\n close: function(reason, code) {\n reason = reason || '';\n code = code || this.ERRORS.normal_closure;\n\n if (this.readyState <= 0) {\n this.readyState = 3;\n this.emit('close', new Base.CloseEvent(code, reason));\n return true;\n } else if (this.readyState === 1) {\n this.readyState = 2;\n this._extensions.close(function() { this.frame(reason, 'close', code) }, this);\n return true;\n } else {\n return false;\n }\n },\n\n frame: function(buffer, type, code) {\n if (this.readyState <= 0) return this._queue([buffer, type, code]);\n if (this.readyState > 2) return false;\n\n if (buffer instanceof Array) buffer = Buffer.from(buffer);\n if (typeof buffer === 'number') buffer = buffer.toString();\n\n var message = new Message(),\n isText = (typeof buffer === 'string'),\n payload, copy;\n\n message.rsv1 = message.rsv2 = message.rsv3 = false;\n message.opcode = this.OPCODES[type || (isText ? 'text' : 'binary')];\n\n payload = isText ? Buffer.from(buffer, 'utf8') : buffer;\n\n if (code) {\n copy = payload;\n payload = Buffer.allocUnsafe(2 + copy.length);\n payload.writeUInt16BE(code, 0);\n copy.copy(payload, 2);\n }\n message.data = payload;\n\n var onMessageReady = function(message) {\n var frame = new Frame();\n\n frame.final = true;\n frame.rsv1 = message.rsv1;\n frame.rsv2 = message.rsv2;\n frame.rsv3 = message.rsv3;\n frame.opcode = message.opcode;\n frame.masked = !!this._masking;\n frame.length = message.data.length;\n frame.payload = message.data;\n\n if (frame.masked) frame.maskingKey = crypto.randomBytes(4);\n\n this._sendFrame(frame);\n };\n\n if (this.MESSAGE_OPCODES.indexOf(message.opcode) >= 0)\n this._extensions.processOutgoingMessage(message, function(error, message) {\n if (error) return this._fail('extension_error', error.message);\n onMessageReady.call(this, message);\n }, this);\n else\n onMessageReady.call(this, message);\n\n return true;\n },\n\n _sendFrame: function(frame) {\n var length = frame.length,\n header = (length <= 125) ? 2 : (length <= 65535 ? 4 : 10),\n offset = header + (frame.masked ? 4 : 0),\n buffer = Buffer.allocUnsafe(offset + length),\n masked = frame.masked ? this.MASK : 0;\n\n buffer[0] = (frame.final ? this.FIN : 0) |\n (frame.rsv1 ? this.RSV1 : 0) |\n (frame.rsv2 ? this.RSV2 : 0) |\n (frame.rsv3 ? this.RSV3 : 0) |\n frame.opcode;\n\n if (length <= 125) {\n buffer[1] = masked | length;\n } else if (length <= 65535) {\n buffer[1] = masked | 126;\n buffer.writeUInt16BE(length, 2);\n } else {\n buffer[1] = masked | 127;\n buffer.writeUInt32BE(Math.floor(length / 0x100000000), 2);\n buffer.writeUInt32BE(length % 0x100000000, 6);\n }\n\n frame.payload.copy(buffer, offset);\n\n if (frame.masked) {\n frame.maskingKey.copy(buffer, header);\n Hybi.mask(buffer, frame.maskingKey, offset);\n }\n\n this._write(buffer);\n },\n\n _handshakeResponse: function() {\n var secKey = this._request.headers['sec-websocket-key'],\n version = this._request.headers['sec-websocket-version'];\n\n if (version !== Hybi.VERSION)\n throw new Error('Unsupported WebSocket version: ' + version);\n\n if (typeof secKey !== 'string')\n throw new Error('Missing handshake request header: Sec-WebSocket-Key');\n\n this._headers.set('Upgrade', 'websocket');\n this._headers.set('Connection', 'Upgrade');\n this._headers.set('Sec-WebSocket-Accept', Hybi.generateAccept(secKey));\n\n if (this.protocol) this._headers.set('Sec-WebSocket-Protocol', this.protocol);\n\n var extensions = this._extensions.generateResponse(this._request.headers['sec-websocket-extensions']);\n if (extensions) this._headers.set('Sec-WebSocket-Extensions', extensions);\n\n var start = 'HTTP/1.1 101 Switching Protocols',\n headers = [start, this._headers.toString(), ''];\n\n return Buffer.from(headers.join('\\r\\n'), 'utf8');\n },\n\n _shutdown: function(code, reason, error) {\n delete this._frame;\n delete this._message;\n this._stage = 5;\n\n var sendCloseFrame = (this.readyState === 1);\n this.readyState = 2;\n\n this._extensions.close(function() {\n if (sendCloseFrame) this.frame(reason, 'close', code);\n this.readyState = 3;\n if (error) this.emit('error', new Error(reason));\n this.emit('close', new Base.CloseEvent(code, reason));\n }, this);\n },\n\n _fail: function(type, message) {\n if (this.readyState > 1) return;\n this._shutdown(this.ERRORS[type], message, true);\n },\n\n _parseOpcode: function(octet) {\n var rsvs = [this.RSV1, this.RSV2, this.RSV3].map(function(rsv) {\n return (octet & rsv) === rsv;\n });\n\n var frame = this._frame = new Frame();\n\n frame.final = (octet & this.FIN) === this.FIN;\n frame.rsv1 = rsvs[0];\n frame.rsv2 = rsvs[1];\n frame.rsv3 = rsvs[2];\n frame.opcode = (octet & this.OPCODE);\n\n this._stage = 1;\n\n if (!this._extensions.validFrameRsv(frame))\n return this._fail('protocol_error',\n 'One or more reserved bits are on: reserved1 = ' + (frame.rsv1 ? 1 : 0) +\n ', reserved2 = ' + (frame.rsv2 ? 1 : 0) +\n ', reserved3 = ' + (frame.rsv3 ? 1 : 0));\n\n if (this.OPCODE_CODES.indexOf(frame.opcode) < 0)\n return this._fail('protocol_error', 'Unrecognized frame opcode: ' + frame.opcode);\n\n if (this.MESSAGE_OPCODES.indexOf(frame.opcode) < 0 && !frame.final)\n return this._fail('protocol_error', 'Received fragmented control frame: opcode = ' + frame.opcode);\n\n if (this._message && this.OPENING_OPCODES.indexOf(frame.opcode) >= 0)\n return this._fail('protocol_error', 'Received new data frame but previous continuous frame is unfinished');\n },\n\n _parseLength: function(octet) {\n var frame = this._frame;\n frame.masked = (octet & this.MASK) === this.MASK;\n frame.length = (octet & this.LENGTH);\n\n if (frame.length >= 0 && frame.length <= 125) {\n this._stage = frame.masked ? 3 : 4;\n if (!this._checkFrameLength()) return;\n } else {\n this._stage = 2;\n frame.lengthBytes = (frame.length === 126 ? 2 : 8);\n }\n\n if (this._requireMasking && !frame.masked)\n return this._fail('unacceptable', 'Received unmasked frame but masking is required');\n },\n\n _parseExtendedLength: function(buffer) {\n var frame = this._frame;\n frame.length = this._readUInt(buffer);\n\n this._stage = frame.masked ? 3 : 4;\n\n if (this.MESSAGE_OPCODES.indexOf(frame.opcode) < 0 && frame.length > 125)\n return this._fail('protocol_error', 'Received control frame having too long payload: ' + frame.length);\n\n if (!this._checkFrameLength()) return;\n },\n\n _checkFrameLength: function() {\n var length = this._message ? this._message.length : 0;\n\n if (length + this._frame.length > this._maxLength) {\n this._fail('too_large', 'WebSocket frame length too large');\n return false;\n } else {\n return true;\n }\n },\n\n _emitFrame: function(buffer) {\n var frame = this._frame,\n payload = frame.payload = Hybi.mask(buffer, frame.maskingKey),\n opcode = frame.opcode,\n message,\n code, reason,\n callbacks, callback;\n\n delete this._frame;\n\n if (opcode === this.OPCODES.continuation) {\n if (!this._message) return this._fail('protocol_error', 'Received unexpected continuation frame');\n this._message.pushFrame(frame);\n }\n\n if (opcode === this.OPCODES.text || opcode === this.OPCODES.binary) {\n this._message = new Message();\n this._message.pushFrame(frame);\n }\n\n if (frame.final && this.MESSAGE_OPCODES.indexOf(opcode) >= 0)\n return this._emitMessage(this._message);\n\n if (opcode === this.OPCODES.close) {\n code = (payload.length >= 2) ? payload.readUInt16BE(0) : null;\n reason = (payload.length > 2) ? this._encode(payload.slice(2)) : null;\n\n if (!(payload.length === 0) &&\n !(code !== null && code >= this.MIN_RESERVED_ERROR && code <= this.MAX_RESERVED_ERROR) &&\n this.ERROR_CODES.indexOf(code) < 0)\n code = this.ERRORS.protocol_error;\n\n if (payload.length > 125 || (payload.length > 2 && !reason))\n code = this.ERRORS.protocol_error;\n\n this._shutdown(code || this.DEFAULT_ERROR_CODE, reason || '');\n }\n\n if (opcode === this.OPCODES.ping) {\n this.frame(payload, 'pong');\n this.emit('ping', new Base.PingEvent(payload.toString()))\n }\n\n if (opcode === this.OPCODES.pong) {\n callbacks = this._pingCallbacks;\n message = this._encode(payload);\n callback = callbacks[message];\n\n delete callbacks[message];\n if (callback) callback()\n\n this.emit('pong', new Base.PongEvent(payload.toString()))\n }\n },\n\n _emitMessage: function(message) {\n var message = this._message;\n message.read();\n\n delete this._message;\n\n this._extensions.processIncomingMessage(message, function(error, message) {\n if (error) return this._fail('extension_error', error.message);\n\n var payload = message.data;\n if (message.opcode === this.OPCODES.text) payload = this._encode(payload);\n\n if (payload === null)\n return this._fail('encoding_error', 'Could not decode a text frame as UTF-8');\n else\n this.emit('message', new Base.MessageEvent(payload));\n }, this);\n },\n\n _encode: function(buffer) {\n try {\n var string = buffer.toString('binary', 0, buffer.length);\n if (!this.UTF8_MATCH.test(string)) return null;\n } catch (e) {}\n return buffer.toString('utf8', 0, buffer.length);\n },\n\n _readUInt: function(buffer) {\n if (buffer.length === 2) return buffer.readUInt16BE(0);\n\n return buffer.readUInt32BE(0) * 0x100000000 +\n buffer.readUInt32BE(4);\n }\n};\n\nfor (var key in instance)\n Hybi.prototype[key] = instance[key];\n\nmodule.exports = Hybi;\n","'use strict';\n\nvar RingBuffer = function(bufferSize) {\n this._bufferSize = bufferSize;\n this.clear();\n};\n\nRingBuffer.prototype.clear = function() {\n this._buffer = new Array(this._bufferSize);\n this._ringOffset = 0;\n this._ringSize = this._bufferSize;\n this._head = 0;\n this._tail = 0;\n this.length = 0;\n};\n\nRingBuffer.prototype.push = function(value) {\n var expandBuffer = false,\n expandRing = false;\n\n if (this._ringSize < this._bufferSize) {\n expandBuffer = (this._tail === 0);\n } else if (this._ringOffset === this._ringSize) {\n expandBuffer = true;\n expandRing = (this._tail === 0);\n }\n\n if (expandBuffer) {\n this._tail = this._bufferSize;\n this._buffer = this._buffer.concat(new Array(this._bufferSize));\n this._bufferSize = this._buffer.length;\n\n if (expandRing)\n this._ringSize = this._bufferSize;\n }\n\n this._buffer[this._tail] = value;\n this.length += 1;\n if (this._tail < this._ringSize) this._ringOffset += 1;\n this._tail = (this._tail + 1) % this._bufferSize;\n};\n\nRingBuffer.prototype.peek = function() {\n if (this.length === 0) return void 0;\n return this._buffer[this._head];\n};\n\nRingBuffer.prototype.shift = function() {\n if (this.length === 0) return void 0;\n\n var value = this._buffer[this._head];\n this._buffer[this._head] = void 0;\n this.length -= 1;\n this._ringOffset -= 1;\n\n if (this._ringOffset === 0 && this.length > 0) {\n this._head = this._ringSize;\n this._ringOffset = this.length;\n this._ringSize = this._bufferSize;\n } else {\n this._head = (this._head + 1) % this._ringSize;\n }\n return value;\n};\n\nmodule.exports = RingBuffer;\n","'use strict';\n\nvar RingBuffer = require('./ring_buffer');\n\nvar Pledge = function() {\n this._complete = false;\n this._callbacks = new RingBuffer(Pledge.QUEUE_SIZE);\n};\n\nPledge.QUEUE_SIZE = 4;\n\nPledge.all = function(list) {\n var pledge = new Pledge(),\n pending = list.length,\n n = pending;\n\n if (pending === 0) pledge.done();\n\n while (n--) list[n].then(function() {\n pending -= 1;\n if (pending === 0) pledge.done();\n });\n return pledge;\n};\n\nPledge.prototype.then = function(callback) {\n if (this._complete) callback();\n else this._callbacks.push(callback);\n};\n\nPledge.prototype.done = function() {\n this._complete = true;\n var callbacks = this._callbacks, callback;\n while (callback = callbacks.shift()) callback();\n};\n\nmodule.exports = Pledge;\n","'use strict';\n\nvar Buffer = require('safe-buffer').Buffer,\n Base = require('./base'),\n util = require('util');\n\nvar Draft75 = function(request, url, options) {\n Base.apply(this, arguments);\n this._stage = 0;\n this.version = 'hixie-75';\n\n this._headers.set('Upgrade', 'WebSocket');\n this._headers.set('Connection', 'Upgrade');\n this._headers.set('WebSocket-Origin', this._request.headers.origin);\n this._headers.set('WebSocket-Location', this.url);\n};\nutil.inherits(Draft75, Base);\n\nvar instance = {\n close: function() {\n if (this.readyState === 3) return false;\n this.readyState = 3;\n this.emit('close', new Base.CloseEvent(null, null));\n return true;\n },\n\n parse: function(chunk) {\n if (this.readyState > 1) return;\n\n this._reader.put(chunk);\n\n this._reader.eachByte(function(octet) {\n var message;\n\n switch (this._stage) {\n case -1:\n this._body.push(octet);\n this._sendHandshakeBody();\n break;\n\n case 0:\n this._parseLeadingByte(octet);\n break;\n\n case 1:\n this._length = (octet & 0x7F) + 128 * this._length;\n\n if (this._closing && this._length === 0) {\n return this.close();\n }\n else if ((octet & 0x80) !== 0x80) {\n if (this._length === 0) {\n this._stage = 0;\n }\n else {\n this._skipped = 0;\n this._stage = 2;\n }\n }\n break;\n\n case 2:\n if (octet === 0xFF) {\n this._stage = 0;\n message = Buffer.from(this._buffer).toString('utf8', 0, this._buffer.length);\n this.emit('message', new Base.MessageEvent(message));\n }\n else {\n if (this._length) {\n this._skipped += 1;\n if (this._skipped === this._length)\n this._stage = 0;\n } else {\n this._buffer.push(octet);\n if (this._buffer.length > this._maxLength) return this.close();\n }\n }\n break;\n }\n }, this);\n },\n\n frame: function(buffer) {\n if (this.readyState === 0) return this._queue([buffer]);\n if (this.readyState > 1) return false;\n\n if (typeof buffer !== 'string') buffer = buffer.toString();\n\n var length = Buffer.byteLength(buffer),\n frame = Buffer.allocUnsafe(length + 2);\n\n frame[0] = 0x00;\n frame.write(buffer, 1);\n frame[frame.length - 1] = 0xFF;\n\n this._write(frame);\n return true;\n },\n\n _handshakeResponse: function() {\n var start = 'HTTP/1.1 101 Web Socket Protocol Handshake',\n headers = [start, this._headers.toString(), ''];\n\n return Buffer.from(headers.join('\\r\\n'), 'utf8');\n },\n\n _parseLeadingByte: function(octet) {\n if ((octet & 0x80) === 0x80) {\n this._length = 0;\n this._stage = 1;\n } else {\n delete this._length;\n delete this._skipped;\n this._buffer = [];\n this._stage = 2;\n }\n }\n};\n\nfor (var key in instance)\n Draft75.prototype[key] = instance[key];\n\nmodule.exports = Draft75;\n","'use strict';\n\nvar Event = require('./event');\n\nvar EventTarget = {\n onopen: null,\n onmessage: null,\n onerror: null,\n onclose: null,\n\n addEventListener: function(eventType, listener, useCapture) {\n this.on(eventType, listener);\n },\n\n removeEventListener: function(eventType, listener, useCapture) {\n this.removeListener(eventType, listener);\n },\n\n dispatchEvent: function(event) {\n event.target = event.currentTarget = this;\n event.eventPhase = Event.AT_TARGET;\n\n if (this['on' + event.type])\n this['on' + event.type](event);\n\n this.emit(event.type, event);\n }\n};\n\nmodule.exports = EventTarget;\n","// Copyright (C) 2016 Dmitry Chestnykh\n// MIT License. See LICENSE file for details.\n\n/**\n * Package utf8 implements UTF-8 encoding and decoding.\n */\n\nconst INVALID_UTF16 = \"utf8: invalid string\";\nconst INVALID_UTF8 = \"utf8: invalid source encoding\";\n\n/**\n * Encodes the given string into UTF-8 byte array.\n * Throws if the source string has invalid UTF-16 encoding.\n */\nexport function encode(s: string): Uint8Array {\n // Calculate result length and allocate output array.\n // encodedLength() also validates string and throws errors,\n // so we don't need repeat validation here.\n const arr = new Uint8Array(encodedLength(s));\n\n let pos = 0;\n for (let i = 0; i < s.length; i++) {\n let c = s.charCodeAt(i);\n if (c < 0x80) {\n arr[pos++] = c;\n } else if (c < 0x800) {\n arr[pos++] = 0xc0 | c >> 6;\n arr[pos++] = 0x80 | c & 0x3f;\n } else if (c < 0xd800) {\n arr[pos++] = 0xe0 | c >> 12;\n arr[pos++] = 0x80 | (c >> 6) & 0x3f;\n arr[pos++] = 0x80 | c & 0x3f;\n } else {\n i++; // get one more character\n c = (c & 0x3ff) << 10;\n c |= s.charCodeAt(i) & 0x3ff;\n c += 0x10000;\n\n arr[pos++] = 0xf0 | c >> 18;\n arr[pos++] = 0x80 | (c >> 12) & 0x3f;\n arr[pos++] = 0x80 | (c >> 6) & 0x3f;\n arr[pos++] = 0x80 | c & 0x3f;\n }\n }\n return arr;\n}\n\n/**\n * Returns the number of bytes required to encode the given string into UTF-8.\n * Throws if the source string has invalid UTF-16 encoding.\n */\nexport function encodedLength(s: string): number {\n let result = 0;\n for (let i = 0; i < s.length; i++) {\n const c = s.charCodeAt(i);\n if (c < 0x80) {\n result += 1;\n } else if (c < 0x800) {\n result += 2;\n } else if (c < 0xd800) {\n result += 3;\n } else if (c <= 0xdfff) {\n if (i >= s.length - 1) {\n throw new Error(INVALID_UTF16);\n }\n i++; // \"eat\" next character\n result += 4;\n } else {\n throw new Error(INVALID_UTF16);\n }\n }\n return result;\n}\n\n/**\n * Decodes the given byte array from UTF-8 into a string.\n * Throws if encoding is invalid.\n */\nexport function decode(arr: Uint8Array): string {\n const chars: string[] = [];\n for (let i = 0; i < arr.length; i++) {\n let b = arr[i];\n\n if (b & 0x80) {\n let min;\n if (b < 0xe0) {\n // Need 1 more byte.\n if (i >= arr.length) {\n throw new Error(INVALID_UTF8);\n }\n const n1 = arr[++i];\n if ((n1 & 0xc0) !== 0x80) {\n throw new Error(INVALID_UTF8);\n }\n b = (b & 0x1f) << 6 | (n1 & 0x3f);\n min = 0x80;\n } else if (b < 0xf0) {\n // Need 2 more bytes.\n if (i >= arr.length - 1) {\n throw new Error(INVALID_UTF8);\n }\n const n1 = arr[++i];\n const n2 = arr[++i];\n if ((n1 & 0xc0) !== 0x80 || (n2 & 0xc0) !== 0x80) {\n throw new Error(INVALID_UTF8);\n }\n b = (b & 0x0f) << 12 | (n1 & 0x3f) << 6 | (n2 & 0x3f);\n min = 0x800;\n } else if (b < 0xf8) {\n // Need 3 more bytes.\n if (i >= arr.length - 2) {\n throw new Error(INVALID_UTF8);\n }\n const n1 = arr[++i];\n const n2 = arr[++i];\n const n3 = arr[++i];\n if ((n1 & 0xc0) !== 0x80 || (n2 & 0xc0) !== 0x80 || (n3 & 0xc0) !== 0x80) {\n throw new Error(INVALID_UTF8);\n }\n b = (b & 0x0f) << 18 | (n1 & 0x3f) << 12 | (n2 & 0x3f) << 6 | (n3 & 0x3f);\n min = 0x10000;\n } else {\n throw new Error(INVALID_UTF8);\n }\n\n if (b < min || (b >= 0xd800 && b <= 0xdfff)) {\n throw new Error(INVALID_UTF8);\n }\n\n if (b >= 0x10000) {\n // Surrogate pair.\n if (b > 0x10ffff) {\n throw new Error(INVALID_UTF8);\n }\n b -= 0x10000;\n chars.push(String.fromCharCode(0xd800 | (b >> 10)));\n b = 0xdc00 | (b & 0x3ff);\n }\n }\n\n chars.push(String.fromCharCode(b));\n }\n return chars.join(\"\");\n}\n","// API references:\n//\n// * https://html.spec.whatwg.org/multipage/comms.html#network\n// * https://dom.spec.whatwg.org/#interface-eventtarget\n// * https://dom.spec.whatwg.org/#interface-event\n\n'use strict';\n\nvar util = require('util'),\n driver = require('websocket-driver'),\n API = require('./websocket/api');\n\nvar WebSocket = function(request, socket, body, protocols, options) {\n options = options || {};\n\n this._stream = socket;\n this._driver = driver.http(request, {maxLength: options.maxLength, protocols: protocols});\n\n var self = this;\n if (!this._stream || !this._stream.writable) return;\n if (!this._stream.readable) return this._stream.end();\n\n var catchup = function() { self._stream.removeListener('data', catchup) };\n this._stream.on('data', catchup);\n\n API.call(this, options);\n\n process.nextTick(function() {\n self._driver.start();\n self._driver.io.write(body);\n });\n};\nutil.inherits(WebSocket, API);\n\nWebSocket.isWebSocket = function(request) {\n return driver.isWebSocket(request);\n};\n\nWebSocket.validateOptions = function(options, validKeys) {\n driver.validateOptions(options, validKeys);\n};\n\nWebSocket.WebSocket = WebSocket;\nWebSocket.Client = require('./websocket/client');\nWebSocket.EventSource = require('./eventsource');\n\nmodule.exports = WebSocket;\n","/**\n * Wrapper for built-in http.js to emulate the browser XMLHttpRequest object.\n *\n * This can be used with JS designed for browsers to improve reuse of code and\n * allow the use of existing libraries.\n *\n * Usage: include(\"XMLHttpRequest.js\") and use XMLHttpRequest per W3C specs.\n *\n * @author Dan DeFelippi \n * @contributor David Ellis \n * @license MIT\n */\n\nvar Url = require(\"url\");\nvar spawn = require(\"child_process\").spawn;\nvar fs = require(\"fs\");\n\nexports.XMLHttpRequest = function() {\n \"use strict\";\n\n /**\n * Private variables\n */\n var self = this;\n var http = require(\"http\");\n var https = require(\"https\");\n\n // Holds http.js objects\n var request;\n var response;\n\n // Request settings\n var settings = {};\n\n // Disable header blacklist.\n // Not part of XHR specs.\n var disableHeaderCheck = false;\n\n // Set some default headers\n var defaultHeaders = {\n \"User-Agent\": \"node-XMLHttpRequest\",\n \"Accept\": \"*/*\",\n };\n\n var headers = {};\n var headersCase = {};\n\n // These headers are not user setable.\n // The following are allowed but banned in the spec:\n // * user-agent\n var forbiddenRequestHeaders = [\n \"accept-charset\",\n \"accept-encoding\",\n \"access-control-request-headers\",\n \"access-control-request-method\",\n \"connection\",\n \"content-length\",\n \"content-transfer-encoding\",\n \"cookie\",\n \"cookie2\",\n \"date\",\n \"expect\",\n \"host\",\n \"keep-alive\",\n \"origin\",\n \"referer\",\n \"te\",\n \"trailer\",\n \"transfer-encoding\",\n \"upgrade\",\n \"via\"\n ];\n\n // These request methods are not allowed\n var forbiddenRequestMethods = [\n \"TRACE\",\n \"TRACK\",\n \"CONNECT\"\n ];\n\n // Send flag\n var sendFlag = false;\n // Error flag, used when errors occur or abort is called\n var errorFlag = false;\n\n // Event listeners\n var listeners = {};\n\n /**\n * Constants\n */\n\n this.UNSENT = 0;\n this.OPENED = 1;\n this.HEADERS_RECEIVED = 2;\n this.LOADING = 3;\n this.DONE = 4;\n\n /**\n * Public vars\n */\n\n // Current state\n this.readyState = this.UNSENT;\n\n // default ready state change handler in case one is not set or is set late\n this.onreadystatechange = null;\n\n // Result & response\n this.responseText = \"\";\n this.responseXML = \"\";\n this.status = null;\n this.statusText = null;\n \n // Whether cross-site Access-Control requests should be made using\n // credentials such as cookies or authorization headers\n this.withCredentials = false;\n\n /**\n * Private methods\n */\n\n /**\n * Check if the specified header is allowed.\n *\n * @param string header Header to validate\n * @return boolean False if not allowed, otherwise true\n */\n var isAllowedHttpHeader = function(header) {\n return disableHeaderCheck || (header && forbiddenRequestHeaders.indexOf(header.toLowerCase()) === -1);\n };\n\n /**\n * Check if the specified method is allowed.\n *\n * @param string method Request method to validate\n * @return boolean False if not allowed, otherwise true\n */\n var isAllowedHttpMethod = function(method) {\n return (method && forbiddenRequestMethods.indexOf(method) === -1);\n };\n\n /**\n * Public methods\n */\n\n /**\n * Open the connection. Currently supports local server requests.\n *\n * @param string method Connection method (eg GET, POST)\n * @param string url URL for the connection.\n * @param boolean async Asynchronous connection. Default is true.\n * @param string user Username for basic authentication (optional)\n * @param string password Password for basic authentication (optional)\n */\n this.open = function(method, url, async, user, password) {\n this.abort();\n errorFlag = false;\n\n // Check for valid request method\n if (!isAllowedHttpMethod(method)) {\n throw new Error(\"SecurityError: Request method not allowed\");\n }\n\n settings = {\n \"method\": method,\n \"url\": url.toString(),\n \"async\": (typeof async !== \"boolean\" ? true : async),\n \"user\": user || null,\n \"password\": password || null\n };\n\n setState(this.OPENED);\n };\n\n /**\n * Disables or enables isAllowedHttpHeader() check the request. Enabled by default.\n * This does not conform to the W3C spec.\n *\n * @param boolean state Enable or disable header checking.\n */\n this.setDisableHeaderCheck = function(state) {\n disableHeaderCheck = state;\n };\n\n /**\n * Sets a header for the request or appends the value if one is already set.\n *\n * @param string header Header name\n * @param string value Header value\n */\n this.setRequestHeader = function(header, value) {\n if (this.readyState !== this.OPENED) {\n throw new Error(\"INVALID_STATE_ERR: setRequestHeader can only be called when state is OPEN\");\n }\n if (!isAllowedHttpHeader(header)) {\n console.warn(\"Refused to set unsafe header \\\"\" + header + \"\\\"\");\n return;\n }\n if (sendFlag) {\n throw new Error(\"INVALID_STATE_ERR: send flag is true\");\n }\n header = headersCase[header.toLowerCase()] || header;\n headersCase[header.toLowerCase()] = header;\n headers[header] = headers[header] ? headers[header] + ', ' + value : value;\n };\n\n /**\n * Gets a header from the server response.\n *\n * @param string header Name of header to get.\n * @return string Text of the header or null if it doesn't exist.\n */\n this.getResponseHeader = function(header) {\n if (typeof header === \"string\"\n && this.readyState > this.OPENED\n && response\n && response.headers\n && response.headers[header.toLowerCase()]\n && !errorFlag\n ) {\n return response.headers[header.toLowerCase()];\n }\n\n return null;\n };\n\n /**\n * Gets all the response headers.\n *\n * @return string A string with all response headers separated by CR+LF\n */\n this.getAllResponseHeaders = function() {\n if (this.readyState < this.HEADERS_RECEIVED || errorFlag) {\n return \"\";\n }\n var result = \"\";\n\n for (var i in response.headers) {\n // Cookie headers are excluded\n if (i !== \"set-cookie\" && i !== \"set-cookie2\") {\n result += i + \": \" + response.headers[i] + \"\\r\\n\";\n }\n }\n return result.substr(0, result.length - 2);\n };\n\n /**\n * Gets a request header\n *\n * @param string name Name of header to get\n * @return string Returns the request header or empty string if not set\n */\n this.getRequestHeader = function(name) {\n if (typeof name === \"string\" && headersCase[name.toLowerCase()]) {\n return headers[headersCase[name.toLowerCase()]];\n }\n\n return \"\";\n };\n\n /**\n * Sends the request to the server.\n *\n * @param string data Optional data to send as request body.\n */\n this.send = function(data) {\n if (this.readyState !== this.OPENED) {\n throw new Error(\"INVALID_STATE_ERR: connection must be opened before send() is called\");\n }\n\n if (sendFlag) {\n throw new Error(\"INVALID_STATE_ERR: send has already been called\");\n }\n\n var ssl = false, local = false;\n var url = Url.parse(settings.url);\n var host;\n // Determine the server\n switch (url.protocol) {\n case \"https:\":\n ssl = true;\n // SSL & non-SSL both need host, no break here.\n case \"http:\":\n host = url.hostname;\n break;\n\n case \"file:\":\n local = true;\n break;\n\n case undefined:\n case null:\n case \"\":\n host = \"localhost\";\n break;\n\n default:\n throw new Error(\"Protocol not supported.\");\n }\n\n // Load files off the local filesystem (file://)\n if (local) {\n if (settings.method !== \"GET\") {\n throw new Error(\"XMLHttpRequest: Only GET method is supported\");\n }\n\n if (settings.async) {\n fs.readFile(url.pathname, \"utf8\", function(error, data) {\n if (error) {\n self.handleError(error);\n } else {\n self.status = 200;\n self.responseText = data;\n setState(self.DONE);\n }\n });\n } else {\n try {\n this.responseText = fs.readFileSync(url.pathname, \"utf8\");\n this.status = 200;\n setState(self.DONE);\n } catch(e) {\n this.handleError(e);\n }\n }\n\n return;\n }\n\n // Default to port 80. If accessing localhost on another port be sure\n // to use http://localhost:port/path\n var port = url.port || (ssl ? 443 : 80);\n // Add query string if one is used\n var uri = url.pathname + (url.search ? url.search : \"\");\n\n // Set the defaults if they haven't been set\n for (var name in defaultHeaders) {\n if (!headersCase[name.toLowerCase()]) {\n headers[name] = defaultHeaders[name];\n }\n }\n\n // Set the Host header or the server may reject the request\n headers.Host = host;\n if (!((ssl && port === 443) || port === 80)) {\n headers.Host += \":\" + url.port;\n }\n\n // Set Basic Auth if necessary\n if (settings.user) {\n if (typeof settings.password === \"undefined\") {\n settings.password = \"\";\n }\n var authBuf = new Buffer(settings.user + \":\" + settings.password);\n headers.Authorization = \"Basic \" + authBuf.toString(\"base64\");\n }\n\n // Set content length header\n if (settings.method === \"GET\" || settings.method === \"HEAD\") {\n data = null;\n } else if (data) {\n headers[\"Content-Length\"] = Buffer.isBuffer(data) ? data.length : Buffer.byteLength(data);\n\n if (!headers[\"Content-Type\"]) {\n headers[\"Content-Type\"] = \"text/plain;charset=UTF-8\";\n }\n } else if (settings.method === \"POST\") {\n // For a post with no data set Content-Length: 0.\n // This is required by buggy servers that don't meet the specs.\n headers[\"Content-Length\"] = 0;\n }\n\n var options = {\n host: host,\n port: port,\n path: uri,\n method: settings.method,\n headers: headers,\n agent: false,\n withCredentials: self.withCredentials\n };\n\n // Reset error flag\n errorFlag = false;\n\n // Handle async requests\n if (settings.async) {\n // Use the proper protocol\n var doRequest = ssl ? https.request : http.request;\n\n // Request is being sent, set send flag\n sendFlag = true;\n\n // As per spec, this is called here for historical reasons.\n self.dispatchEvent(\"readystatechange\");\n\n // Handler for the response\n var responseHandler = function responseHandler(resp) {\n // Set response var to the response we got back\n // This is so it remains accessable outside this scope\n response = resp;\n // Check for redirect\n // @TODO Prevent looped redirects\n if (response.statusCode === 301 || response.statusCode === 302 || response.statusCode === 303 || response.statusCode === 307) {\n // Change URL to the redirect location\n settings.url = response.headers.location;\n var url = Url.parse(settings.url);\n // Set host var in case it's used later\n host = url.hostname;\n // Options for the new request\n var newOptions = {\n hostname: url.hostname,\n port: url.port,\n path: url.path,\n method: response.statusCode === 303 ? \"GET\" : settings.method,\n headers: headers,\n withCredentials: self.withCredentials\n };\n\n // Issue the new request\n request = doRequest(newOptions, responseHandler).on(\"error\", errorHandler);\n request.end();\n // @TODO Check if an XHR event needs to be fired here\n return;\n }\n\n response.setEncoding(\"utf8\");\n\n setState(self.HEADERS_RECEIVED);\n self.status = response.statusCode;\n\n response.on(\"data\", function(chunk) {\n // Make sure there's some data\n if (chunk) {\n self.responseText += chunk;\n }\n // Don't emit state changes if the connection has been aborted.\n if (sendFlag) {\n setState(self.LOADING);\n }\n });\n\n response.on(\"end\", function() {\n if (sendFlag) {\n // Discard the end event if the connection has been aborted\n setState(self.DONE);\n sendFlag = false;\n }\n });\n\n response.on(\"error\", function(error) {\n self.handleError(error);\n });\n };\n\n // Error handler for the request\n var errorHandler = function errorHandler(error) {\n self.handleError(error);\n };\n\n // Create the request\n request = doRequest(options, responseHandler).on(\"error\", errorHandler);\n\n // Node 0.4 and later won't accept empty data. Make sure it's needed.\n if (data) {\n request.write(data);\n }\n\n request.end();\n\n self.dispatchEvent(\"loadstart\");\n } else { // Synchronous\n // Create a temporary file for communication with the other Node process\n var contentFile = \".node-xmlhttprequest-content-\" + process.pid;\n var syncFile = \".node-xmlhttprequest-sync-\" + process.pid;\n fs.writeFileSync(syncFile, \"\", \"utf8\");\n // The async request the other Node process executes\n var execString = \"var http = require('http'), https = require('https'), fs = require('fs');\"\n + \"var doRequest = http\" + (ssl ? \"s\" : \"\") + \".request;\"\n + \"var options = \" + JSON.stringify(options) + \";\"\n + \"var responseText = '';\"\n + \"var req = doRequest(options, function(response) {\"\n + \"response.setEncoding('utf8');\"\n + \"response.on('data', function(chunk) {\"\n + \" responseText += chunk;\"\n + \"});\"\n + \"response.on('end', function() {\"\n + \"fs.writeFileSync('\" + contentFile + \"', JSON.stringify({err: null, data: {statusCode: response.statusCode, headers: response.headers, text: responseText}}), 'utf8');\"\n + \"fs.unlinkSync('\" + syncFile + \"');\"\n + \"});\"\n + \"response.on('error', function(error) {\"\n + \"fs.writeFileSync('\" + contentFile + \"', JSON.stringify({err: error}), 'utf8');\"\n + \"fs.unlinkSync('\" + syncFile + \"');\"\n + \"});\"\n + \"}).on('error', function(error) {\"\n + \"fs.writeFileSync('\" + contentFile + \"', JSON.stringify({err: error}), 'utf8');\"\n + \"fs.unlinkSync('\" + syncFile + \"');\"\n + \"});\"\n + (data ? \"req.write('\" + JSON.stringify(data).slice(1,-1).replace(/'/g, \"\\\\'\") + \"');\":\"\")\n + \"req.end();\";\n // Start the other Node Process, executing this string\n var syncProc = spawn(process.argv[0], [\"-e\", execString]);\n while(fs.existsSync(syncFile)) {\n // Wait while the sync file is empty\n }\n var resp = JSON.parse(fs.readFileSync(contentFile, 'utf8'));\n // Kill the child process once the file has data\n syncProc.stdin.end();\n // Remove the temporary file\n fs.unlinkSync(contentFile);\n\n if (resp.err) {\n self.handleError(resp.err);\n } else {\n response = resp.data;\n self.status = resp.data.statusCode;\n self.responseText = resp.data.text;\n setState(self.DONE);\n }\n }\n };\n\n /**\n * Called when an error is encountered to deal with it.\n */\n this.handleError = function(error) {\n this.status = 0;\n this.statusText = error;\n this.responseText = error.stack;\n errorFlag = true;\n setState(this.DONE);\n this.dispatchEvent('error');\n };\n\n /**\n * Aborts a request.\n */\n this.abort = function() {\n if (request) {\n request.abort();\n request = null;\n }\n\n headers = defaultHeaders;\n this.status = 0;\n this.responseText = \"\";\n this.responseXML = \"\";\n\n errorFlag = true;\n\n if (this.readyState !== this.UNSENT\n && (this.readyState !== this.OPENED || sendFlag)\n && this.readyState !== this.DONE) {\n sendFlag = false;\n setState(this.DONE);\n }\n this.readyState = this.UNSENT;\n this.dispatchEvent('abort');\n };\n\n /**\n * Adds an event listener. Preferred method of binding to events.\n */\n this.addEventListener = function(event, callback) {\n if (!(event in listeners)) {\n listeners[event] = [];\n }\n // Currently allows duplicate callbacks. Should it?\n listeners[event].push(callback);\n };\n\n /**\n * Remove an event callback that has already been bound.\n * Only works on the matching funciton, cannot be a copy.\n */\n this.removeEventListener = function(event, callback) {\n if (event in listeners) {\n // Filter will return a new array with the callback removed\n listeners[event] = listeners[event].filter(function(ev) {\n return ev !== callback;\n });\n }\n };\n\n /**\n * Dispatch any events, including both \"on\" methods and events attached using addEventListener.\n */\n this.dispatchEvent = function(event) {\n if (typeof self[\"on\" + event] === \"function\") {\n self[\"on\" + event]();\n }\n if (event in listeners) {\n for (var i = 0, len = listeners[event].length; i < len; i++) {\n listeners[event][i].call(self);\n }\n }\n };\n\n /**\n * Changes readyState and calls onreadystatechange.\n *\n * @param int state New state\n */\n var setState = function(state) {\n if (state == self.LOADING || self.readyState !== state) {\n self.readyState = state;\n\n if (settings.async || self.readyState < self.OPENED || self.readyState === self.DONE) {\n self.dispatchEvent(\"readystatechange\");\n }\n\n if (self.readyState === self.DONE && !errorFlag) {\n self.dispatchEvent(\"load\");\n // @TODO figure out InspectorInstrumentation::didLoadXHR(cookie)\n self.dispatchEvent(\"loadend\");\n }\n }\n };\n};\n","(function(nacl) {\n'use strict';\n\n// Ported in 2014 by Dmitry Chestnykh and Devi Mandiri.\n// Public domain.\n//\n// Implementation derived from TweetNaCl version 20140427.\n// See for details: http://tweetnacl.cr.yp.to/\n\nvar gf = function(init) {\n var i, r = new Float64Array(16);\n if (init) for (i = 0; i < init.length; i++) r[i] = init[i];\n return r;\n};\n\n// Pluggable, initialized in high-level API below.\nvar randombytes = function(/* x, n */) { throw new Error('no PRNG'); };\n\nvar _0 = new Uint8Array(16);\nvar _9 = new Uint8Array(32); _9[0] = 9;\n\nvar gf0 = gf(),\n gf1 = gf([1]),\n _121665 = gf([0xdb41, 1]),\n D = gf([0x78a3, 0x1359, 0x4dca, 0x75eb, 0xd8ab, 0x4141, 0x0a4d, 0x0070, 0xe898, 0x7779, 0x4079, 0x8cc7, 0xfe73, 0x2b6f, 0x6cee, 0x5203]),\n D2 = gf([0xf159, 0x26b2, 0x9b94, 0xebd6, 0xb156, 0x8283, 0x149a, 0x00e0, 0xd130, 0xeef3, 0x80f2, 0x198e, 0xfce7, 0x56df, 0xd9dc, 0x2406]),\n X = gf([0xd51a, 0x8f25, 0x2d60, 0xc956, 0xa7b2, 0x9525, 0xc760, 0x692c, 0xdc5c, 0xfdd6, 0xe231, 0xc0a4, 0x53fe, 0xcd6e, 0x36d3, 0x2169]),\n Y = gf([0x6658, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666]),\n I = gf([0xa0b0, 0x4a0e, 0x1b27, 0xc4ee, 0xe478, 0xad2f, 0x1806, 0x2f43, 0xd7a7, 0x3dfb, 0x0099, 0x2b4d, 0xdf0b, 0x4fc1, 0x2480, 0x2b83]);\n\nfunction ts64(x, i, h, l) {\n x[i] = (h >> 24) & 0xff;\n x[i+1] = (h >> 16) & 0xff;\n x[i+2] = (h >> 8) & 0xff;\n x[i+3] = h & 0xff;\n x[i+4] = (l >> 24) & 0xff;\n x[i+5] = (l >> 16) & 0xff;\n x[i+6] = (l >> 8) & 0xff;\n x[i+7] = l & 0xff;\n}\n\nfunction vn(x, xi, y, yi, n) {\n var i,d = 0;\n for (i = 0; i < n; i++) d |= x[xi+i]^y[yi+i];\n return (1 & ((d - 1) >>> 8)) - 1;\n}\n\nfunction crypto_verify_16(x, xi, y, yi) {\n return vn(x,xi,y,yi,16);\n}\n\nfunction crypto_verify_32(x, xi, y, yi) {\n return vn(x,xi,y,yi,32);\n}\n\nfunction core_salsa20(o, p, k, c) {\n var j0 = c[ 0] & 0xff | (c[ 1] & 0xff)<<8 | (c[ 2] & 0xff)<<16 | (c[ 3] & 0xff)<<24,\n j1 = k[ 0] & 0xff | (k[ 1] & 0xff)<<8 | (k[ 2] & 0xff)<<16 | (k[ 3] & 0xff)<<24,\n j2 = k[ 4] & 0xff | (k[ 5] & 0xff)<<8 | (k[ 6] & 0xff)<<16 | (k[ 7] & 0xff)<<24,\n j3 = k[ 8] & 0xff | (k[ 9] & 0xff)<<8 | (k[10] & 0xff)<<16 | (k[11] & 0xff)<<24,\n j4 = k[12] & 0xff | (k[13] & 0xff)<<8 | (k[14] & 0xff)<<16 | (k[15] & 0xff)<<24,\n j5 = c[ 4] & 0xff | (c[ 5] & 0xff)<<8 | (c[ 6] & 0xff)<<16 | (c[ 7] & 0xff)<<24,\n j6 = p[ 0] & 0xff | (p[ 1] & 0xff)<<8 | (p[ 2] & 0xff)<<16 | (p[ 3] & 0xff)<<24,\n j7 = p[ 4] & 0xff | (p[ 5] & 0xff)<<8 | (p[ 6] & 0xff)<<16 | (p[ 7] & 0xff)<<24,\n j8 = p[ 8] & 0xff | (p[ 9] & 0xff)<<8 | (p[10] & 0xff)<<16 | (p[11] & 0xff)<<24,\n j9 = p[12] & 0xff | (p[13] & 0xff)<<8 | (p[14] & 0xff)<<16 | (p[15] & 0xff)<<24,\n j10 = c[ 8] & 0xff | (c[ 9] & 0xff)<<8 | (c[10] & 0xff)<<16 | (c[11] & 0xff)<<24,\n j11 = k[16] & 0xff | (k[17] & 0xff)<<8 | (k[18] & 0xff)<<16 | (k[19] & 0xff)<<24,\n j12 = k[20] & 0xff | (k[21] & 0xff)<<8 | (k[22] & 0xff)<<16 | (k[23] & 0xff)<<24,\n j13 = k[24] & 0xff | (k[25] & 0xff)<<8 | (k[26] & 0xff)<<16 | (k[27] & 0xff)<<24,\n j14 = k[28] & 0xff | (k[29] & 0xff)<<8 | (k[30] & 0xff)<<16 | (k[31] & 0xff)<<24,\n j15 = c[12] & 0xff | (c[13] & 0xff)<<8 | (c[14] & 0xff)<<16 | (c[15] & 0xff)<<24;\n\n var x0 = j0, x1 = j1, x2 = j2, x3 = j3, x4 = j4, x5 = j5, x6 = j6, x7 = j7,\n x8 = j8, x9 = j9, x10 = j10, x11 = j11, x12 = j12, x13 = j13, x14 = j14,\n x15 = j15, u;\n\n for (var i = 0; i < 20; i += 2) {\n u = x0 + x12 | 0;\n x4 ^= u<<7 | u>>>(32-7);\n u = x4 + x0 | 0;\n x8 ^= u<<9 | u>>>(32-9);\n u = x8 + x4 | 0;\n x12 ^= u<<13 | u>>>(32-13);\n u = x12 + x8 | 0;\n x0 ^= u<<18 | u>>>(32-18);\n\n u = x5 + x1 | 0;\n x9 ^= u<<7 | u>>>(32-7);\n u = x9 + x5 | 0;\n x13 ^= u<<9 | u>>>(32-9);\n u = x13 + x9 | 0;\n x1 ^= u<<13 | u>>>(32-13);\n u = x1 + x13 | 0;\n x5 ^= u<<18 | u>>>(32-18);\n\n u = x10 + x6 | 0;\n x14 ^= u<<7 | u>>>(32-7);\n u = x14 + x10 | 0;\n x2 ^= u<<9 | u>>>(32-9);\n u = x2 + x14 | 0;\n x6 ^= u<<13 | u>>>(32-13);\n u = x6 + x2 | 0;\n x10 ^= u<<18 | u>>>(32-18);\n\n u = x15 + x11 | 0;\n x3 ^= u<<7 | u>>>(32-7);\n u = x3 + x15 | 0;\n x7 ^= u<<9 | u>>>(32-9);\n u = x7 + x3 | 0;\n x11 ^= u<<13 | u>>>(32-13);\n u = x11 + x7 | 0;\n x15 ^= u<<18 | u>>>(32-18);\n\n u = x0 + x3 | 0;\n x1 ^= u<<7 | u>>>(32-7);\n u = x1 + x0 | 0;\n x2 ^= u<<9 | u>>>(32-9);\n u = x2 + x1 | 0;\n x3 ^= u<<13 | u>>>(32-13);\n u = x3 + x2 | 0;\n x0 ^= u<<18 | u>>>(32-18);\n\n u = x5 + x4 | 0;\n x6 ^= u<<7 | u>>>(32-7);\n u = x6 + x5 | 0;\n x7 ^= u<<9 | u>>>(32-9);\n u = x7 + x6 | 0;\n x4 ^= u<<13 | u>>>(32-13);\n u = x4 + x7 | 0;\n x5 ^= u<<18 | u>>>(32-18);\n\n u = x10 + x9 | 0;\n x11 ^= u<<7 | u>>>(32-7);\n u = x11 + x10 | 0;\n x8 ^= u<<9 | u>>>(32-9);\n u = x8 + x11 | 0;\n x9 ^= u<<13 | u>>>(32-13);\n u = x9 + x8 | 0;\n x10 ^= u<<18 | u>>>(32-18);\n\n u = x15 + x14 | 0;\n x12 ^= u<<7 | u>>>(32-7);\n u = x12 + x15 | 0;\n x13 ^= u<<9 | u>>>(32-9);\n u = x13 + x12 | 0;\n x14 ^= u<<13 | u>>>(32-13);\n u = x14 + x13 | 0;\n x15 ^= u<<18 | u>>>(32-18);\n }\n x0 = x0 + j0 | 0;\n x1 = x1 + j1 | 0;\n x2 = x2 + j2 | 0;\n x3 = x3 + j3 | 0;\n x4 = x4 + j4 | 0;\n x5 = x5 + j5 | 0;\n x6 = x6 + j6 | 0;\n x7 = x7 + j7 | 0;\n x8 = x8 + j8 | 0;\n x9 = x9 + j9 | 0;\n x10 = x10 + j10 | 0;\n x11 = x11 + j11 | 0;\n x12 = x12 + j12 | 0;\n x13 = x13 + j13 | 0;\n x14 = x14 + j14 | 0;\n x15 = x15 + j15 | 0;\n\n o[ 0] = x0 >>> 0 & 0xff;\n o[ 1] = x0 >>> 8 & 0xff;\n o[ 2] = x0 >>> 16 & 0xff;\n o[ 3] = x0 >>> 24 & 0xff;\n\n o[ 4] = x1 >>> 0 & 0xff;\n o[ 5] = x1 >>> 8 & 0xff;\n o[ 6] = x1 >>> 16 & 0xff;\n o[ 7] = x1 >>> 24 & 0xff;\n\n o[ 8] = x2 >>> 0 & 0xff;\n o[ 9] = x2 >>> 8 & 0xff;\n o[10] = x2 >>> 16 & 0xff;\n o[11] = x2 >>> 24 & 0xff;\n\n o[12] = x3 >>> 0 & 0xff;\n o[13] = x3 >>> 8 & 0xff;\n o[14] = x3 >>> 16 & 0xff;\n o[15] = x3 >>> 24 & 0xff;\n\n o[16] = x4 >>> 0 & 0xff;\n o[17] = x4 >>> 8 & 0xff;\n o[18] = x4 >>> 16 & 0xff;\n o[19] = x4 >>> 24 & 0xff;\n\n o[20] = x5 >>> 0 & 0xff;\n o[21] = x5 >>> 8 & 0xff;\n o[22] = x5 >>> 16 & 0xff;\n o[23] = x5 >>> 24 & 0xff;\n\n o[24] = x6 >>> 0 & 0xff;\n o[25] = x6 >>> 8 & 0xff;\n o[26] = x6 >>> 16 & 0xff;\n o[27] = x6 >>> 24 & 0xff;\n\n o[28] = x7 >>> 0 & 0xff;\n o[29] = x7 >>> 8 & 0xff;\n o[30] = x7 >>> 16 & 0xff;\n o[31] = x7 >>> 24 & 0xff;\n\n o[32] = x8 >>> 0 & 0xff;\n o[33] = x8 >>> 8 & 0xff;\n o[34] = x8 >>> 16 & 0xff;\n o[35] = x8 >>> 24 & 0xff;\n\n o[36] = x9 >>> 0 & 0xff;\n o[37] = x9 >>> 8 & 0xff;\n o[38] = x9 >>> 16 & 0xff;\n o[39] = x9 >>> 24 & 0xff;\n\n o[40] = x10 >>> 0 & 0xff;\n o[41] = x10 >>> 8 & 0xff;\n o[42] = x10 >>> 16 & 0xff;\n o[43] = x10 >>> 24 & 0xff;\n\n o[44] = x11 >>> 0 & 0xff;\n o[45] = x11 >>> 8 & 0xff;\n o[46] = x11 >>> 16 & 0xff;\n o[47] = x11 >>> 24 & 0xff;\n\n o[48] = x12 >>> 0 & 0xff;\n o[49] = x12 >>> 8 & 0xff;\n o[50] = x12 >>> 16 & 0xff;\n o[51] = x12 >>> 24 & 0xff;\n\n o[52] = x13 >>> 0 & 0xff;\n o[53] = x13 >>> 8 & 0xff;\n o[54] = x13 >>> 16 & 0xff;\n o[55] = x13 >>> 24 & 0xff;\n\n o[56] = x14 >>> 0 & 0xff;\n o[57] = x14 >>> 8 & 0xff;\n o[58] = x14 >>> 16 & 0xff;\n o[59] = x14 >>> 24 & 0xff;\n\n o[60] = x15 >>> 0 & 0xff;\n o[61] = x15 >>> 8 & 0xff;\n o[62] = x15 >>> 16 & 0xff;\n o[63] = x15 >>> 24 & 0xff;\n}\n\nfunction core_hsalsa20(o,p,k,c) {\n var j0 = c[ 0] & 0xff | (c[ 1] & 0xff)<<8 | (c[ 2] & 0xff)<<16 | (c[ 3] & 0xff)<<24,\n j1 = k[ 0] & 0xff | (k[ 1] & 0xff)<<8 | (k[ 2] & 0xff)<<16 | (k[ 3] & 0xff)<<24,\n j2 = k[ 4] & 0xff | (k[ 5] & 0xff)<<8 | (k[ 6] & 0xff)<<16 | (k[ 7] & 0xff)<<24,\n j3 = k[ 8] & 0xff | (k[ 9] & 0xff)<<8 | (k[10] & 0xff)<<16 | (k[11] & 0xff)<<24,\n j4 = k[12] & 0xff | (k[13] & 0xff)<<8 | (k[14] & 0xff)<<16 | (k[15] & 0xff)<<24,\n j5 = c[ 4] & 0xff | (c[ 5] & 0xff)<<8 | (c[ 6] & 0xff)<<16 | (c[ 7] & 0xff)<<24,\n j6 = p[ 0] & 0xff | (p[ 1] & 0xff)<<8 | (p[ 2] & 0xff)<<16 | (p[ 3] & 0xff)<<24,\n j7 = p[ 4] & 0xff | (p[ 5] & 0xff)<<8 | (p[ 6] & 0xff)<<16 | (p[ 7] & 0xff)<<24,\n j8 = p[ 8] & 0xff | (p[ 9] & 0xff)<<8 | (p[10] & 0xff)<<16 | (p[11] & 0xff)<<24,\n j9 = p[12] & 0xff | (p[13] & 0xff)<<8 | (p[14] & 0xff)<<16 | (p[15] & 0xff)<<24,\n j10 = c[ 8] & 0xff | (c[ 9] & 0xff)<<8 | (c[10] & 0xff)<<16 | (c[11] & 0xff)<<24,\n j11 = k[16] & 0xff | (k[17] & 0xff)<<8 | (k[18] & 0xff)<<16 | (k[19] & 0xff)<<24,\n j12 = k[20] & 0xff | (k[21] & 0xff)<<8 | (k[22] & 0xff)<<16 | (k[23] & 0xff)<<24,\n j13 = k[24] & 0xff | (k[25] & 0xff)<<8 | (k[26] & 0xff)<<16 | (k[27] & 0xff)<<24,\n j14 = k[28] & 0xff | (k[29] & 0xff)<<8 | (k[30] & 0xff)<<16 | (k[31] & 0xff)<<24,\n j15 = c[12] & 0xff | (c[13] & 0xff)<<8 | (c[14] & 0xff)<<16 | (c[15] & 0xff)<<24;\n\n var x0 = j0, x1 = j1, x2 = j2, x3 = j3, x4 = j4, x5 = j5, x6 = j6, x7 = j7,\n x8 = j8, x9 = j9, x10 = j10, x11 = j11, x12 = j12, x13 = j13, x14 = j14,\n x15 = j15, u;\n\n for (var i = 0; i < 20; i += 2) {\n u = x0 + x12 | 0;\n x4 ^= u<<7 | u>>>(32-7);\n u = x4 + x0 | 0;\n x8 ^= u<<9 | u>>>(32-9);\n u = x8 + x4 | 0;\n x12 ^= u<<13 | u>>>(32-13);\n u = x12 + x8 | 0;\n x0 ^= u<<18 | u>>>(32-18);\n\n u = x5 + x1 | 0;\n x9 ^= u<<7 | u>>>(32-7);\n u = x9 + x5 | 0;\n x13 ^= u<<9 | u>>>(32-9);\n u = x13 + x9 | 0;\n x1 ^= u<<13 | u>>>(32-13);\n u = x1 + x13 | 0;\n x5 ^= u<<18 | u>>>(32-18);\n\n u = x10 + x6 | 0;\n x14 ^= u<<7 | u>>>(32-7);\n u = x14 + x10 | 0;\n x2 ^= u<<9 | u>>>(32-9);\n u = x2 + x14 | 0;\n x6 ^= u<<13 | u>>>(32-13);\n u = x6 + x2 | 0;\n x10 ^= u<<18 | u>>>(32-18);\n\n u = x15 + x11 | 0;\n x3 ^= u<<7 | u>>>(32-7);\n u = x3 + x15 | 0;\n x7 ^= u<<9 | u>>>(32-9);\n u = x7 + x3 | 0;\n x11 ^= u<<13 | u>>>(32-13);\n u = x11 + x7 | 0;\n x15 ^= u<<18 | u>>>(32-18);\n\n u = x0 + x3 | 0;\n x1 ^= u<<7 | u>>>(32-7);\n u = x1 + x0 | 0;\n x2 ^= u<<9 | u>>>(32-9);\n u = x2 + x1 | 0;\n x3 ^= u<<13 | u>>>(32-13);\n u = x3 + x2 | 0;\n x0 ^= u<<18 | u>>>(32-18);\n\n u = x5 + x4 | 0;\n x6 ^= u<<7 | u>>>(32-7);\n u = x6 + x5 | 0;\n x7 ^= u<<9 | u>>>(32-9);\n u = x7 + x6 | 0;\n x4 ^= u<<13 | u>>>(32-13);\n u = x4 + x7 | 0;\n x5 ^= u<<18 | u>>>(32-18);\n\n u = x10 + x9 | 0;\n x11 ^= u<<7 | u>>>(32-7);\n u = x11 + x10 | 0;\n x8 ^= u<<9 | u>>>(32-9);\n u = x8 + x11 | 0;\n x9 ^= u<<13 | u>>>(32-13);\n u = x9 + x8 | 0;\n x10 ^= u<<18 | u>>>(32-18);\n\n u = x15 + x14 | 0;\n x12 ^= u<<7 | u>>>(32-7);\n u = x12 + x15 | 0;\n x13 ^= u<<9 | u>>>(32-9);\n u = x13 + x12 | 0;\n x14 ^= u<<13 | u>>>(32-13);\n u = x14 + x13 | 0;\n x15 ^= u<<18 | u>>>(32-18);\n }\n\n o[ 0] = x0 >>> 0 & 0xff;\n o[ 1] = x0 >>> 8 & 0xff;\n o[ 2] = x0 >>> 16 & 0xff;\n o[ 3] = x0 >>> 24 & 0xff;\n\n o[ 4] = x5 >>> 0 & 0xff;\n o[ 5] = x5 >>> 8 & 0xff;\n o[ 6] = x5 >>> 16 & 0xff;\n o[ 7] = x5 >>> 24 & 0xff;\n\n o[ 8] = x10 >>> 0 & 0xff;\n o[ 9] = x10 >>> 8 & 0xff;\n o[10] = x10 >>> 16 & 0xff;\n o[11] = x10 >>> 24 & 0xff;\n\n o[12] = x15 >>> 0 & 0xff;\n o[13] = x15 >>> 8 & 0xff;\n o[14] = x15 >>> 16 & 0xff;\n o[15] = x15 >>> 24 & 0xff;\n\n o[16] = x6 >>> 0 & 0xff;\n o[17] = x6 >>> 8 & 0xff;\n o[18] = x6 >>> 16 & 0xff;\n o[19] = x6 >>> 24 & 0xff;\n\n o[20] = x7 >>> 0 & 0xff;\n o[21] = x7 >>> 8 & 0xff;\n o[22] = x7 >>> 16 & 0xff;\n o[23] = x7 >>> 24 & 0xff;\n\n o[24] = x8 >>> 0 & 0xff;\n o[25] = x8 >>> 8 & 0xff;\n o[26] = x8 >>> 16 & 0xff;\n o[27] = x8 >>> 24 & 0xff;\n\n o[28] = x9 >>> 0 & 0xff;\n o[29] = x9 >>> 8 & 0xff;\n o[30] = x9 >>> 16 & 0xff;\n o[31] = x9 >>> 24 & 0xff;\n}\n\nfunction crypto_core_salsa20(out,inp,k,c) {\n core_salsa20(out,inp,k,c);\n}\n\nfunction crypto_core_hsalsa20(out,inp,k,c) {\n core_hsalsa20(out,inp,k,c);\n}\n\nvar sigma = new Uint8Array([101, 120, 112, 97, 110, 100, 32, 51, 50, 45, 98, 121, 116, 101, 32, 107]);\n // \"expand 32-byte k\"\n\nfunction crypto_stream_salsa20_xor(c,cpos,m,mpos,b,n,k) {\n var z = new Uint8Array(16), x = new Uint8Array(64);\n var u, i;\n for (i = 0; i < 16; i++) z[i] = 0;\n for (i = 0; i < 8; i++) z[i] = n[i];\n while (b >= 64) {\n crypto_core_salsa20(x,z,k,sigma);\n for (i = 0; i < 64; i++) c[cpos+i] = m[mpos+i] ^ x[i];\n u = 1;\n for (i = 8; i < 16; i++) {\n u = u + (z[i] & 0xff) | 0;\n z[i] = u & 0xff;\n u >>>= 8;\n }\n b -= 64;\n cpos += 64;\n mpos += 64;\n }\n if (b > 0) {\n crypto_core_salsa20(x,z,k,sigma);\n for (i = 0; i < b; i++) c[cpos+i] = m[mpos+i] ^ x[i];\n }\n return 0;\n}\n\nfunction crypto_stream_salsa20(c,cpos,b,n,k) {\n var z = new Uint8Array(16), x = new Uint8Array(64);\n var u, i;\n for (i = 0; i < 16; i++) z[i] = 0;\n for (i = 0; i < 8; i++) z[i] = n[i];\n while (b >= 64) {\n crypto_core_salsa20(x,z,k,sigma);\n for (i = 0; i < 64; i++) c[cpos+i] = x[i];\n u = 1;\n for (i = 8; i < 16; i++) {\n u = u + (z[i] & 0xff) | 0;\n z[i] = u & 0xff;\n u >>>= 8;\n }\n b -= 64;\n cpos += 64;\n }\n if (b > 0) {\n crypto_core_salsa20(x,z,k,sigma);\n for (i = 0; i < b; i++) c[cpos+i] = x[i];\n }\n return 0;\n}\n\nfunction crypto_stream(c,cpos,d,n,k) {\n var s = new Uint8Array(32);\n crypto_core_hsalsa20(s,n,k,sigma);\n var sn = new Uint8Array(8);\n for (var i = 0; i < 8; i++) sn[i] = n[i+16];\n return crypto_stream_salsa20(c,cpos,d,sn,s);\n}\n\nfunction crypto_stream_xor(c,cpos,m,mpos,d,n,k) {\n var s = new Uint8Array(32);\n crypto_core_hsalsa20(s,n,k,sigma);\n var sn = new Uint8Array(8);\n for (var i = 0; i < 8; i++) sn[i] = n[i+16];\n return crypto_stream_salsa20_xor(c,cpos,m,mpos,d,sn,s);\n}\n\n/*\n* Port of Andrew Moon's Poly1305-donna-16. Public domain.\n* https://github.com/floodyberry/poly1305-donna\n*/\n\nvar poly1305 = function(key) {\n this.buffer = new Uint8Array(16);\n this.r = new Uint16Array(10);\n this.h = new Uint16Array(10);\n this.pad = new Uint16Array(8);\n this.leftover = 0;\n this.fin = 0;\n\n var t0, t1, t2, t3, t4, t5, t6, t7;\n\n t0 = key[ 0] & 0xff | (key[ 1] & 0xff) << 8; this.r[0] = ( t0 ) & 0x1fff;\n t1 = key[ 2] & 0xff | (key[ 3] & 0xff) << 8; this.r[1] = ((t0 >>> 13) | (t1 << 3)) & 0x1fff;\n t2 = key[ 4] & 0xff | (key[ 5] & 0xff) << 8; this.r[2] = ((t1 >>> 10) | (t2 << 6)) & 0x1f03;\n t3 = key[ 6] & 0xff | (key[ 7] & 0xff) << 8; this.r[3] = ((t2 >>> 7) | (t3 << 9)) & 0x1fff;\n t4 = key[ 8] & 0xff | (key[ 9] & 0xff) << 8; this.r[4] = ((t3 >>> 4) | (t4 << 12)) & 0x00ff;\n this.r[5] = ((t4 >>> 1)) & 0x1ffe;\n t5 = key[10] & 0xff | (key[11] & 0xff) << 8; this.r[6] = ((t4 >>> 14) | (t5 << 2)) & 0x1fff;\n t6 = key[12] & 0xff | (key[13] & 0xff) << 8; this.r[7] = ((t5 >>> 11) | (t6 << 5)) & 0x1f81;\n t7 = key[14] & 0xff | (key[15] & 0xff) << 8; this.r[8] = ((t6 >>> 8) | (t7 << 8)) & 0x1fff;\n this.r[9] = ((t7 >>> 5)) & 0x007f;\n\n this.pad[0] = key[16] & 0xff | (key[17] & 0xff) << 8;\n this.pad[1] = key[18] & 0xff | (key[19] & 0xff) << 8;\n this.pad[2] = key[20] & 0xff | (key[21] & 0xff) << 8;\n this.pad[3] = key[22] & 0xff | (key[23] & 0xff) << 8;\n this.pad[4] = key[24] & 0xff | (key[25] & 0xff) << 8;\n this.pad[5] = key[26] & 0xff | (key[27] & 0xff) << 8;\n this.pad[6] = key[28] & 0xff | (key[29] & 0xff) << 8;\n this.pad[7] = key[30] & 0xff | (key[31] & 0xff) << 8;\n};\n\npoly1305.prototype.blocks = function(m, mpos, bytes) {\n var hibit = this.fin ? 0 : (1 << 11);\n var t0, t1, t2, t3, t4, t5, t6, t7, c;\n var d0, d1, d2, d3, d4, d5, d6, d7, d8, d9;\n\n var h0 = this.h[0],\n h1 = this.h[1],\n h2 = this.h[2],\n h3 = this.h[3],\n h4 = this.h[4],\n h5 = this.h[5],\n h6 = this.h[6],\n h7 = this.h[7],\n h8 = this.h[8],\n h9 = this.h[9];\n\n var r0 = this.r[0],\n r1 = this.r[1],\n r2 = this.r[2],\n r3 = this.r[3],\n r4 = this.r[4],\n r5 = this.r[5],\n r6 = this.r[6],\n r7 = this.r[7],\n r8 = this.r[8],\n r9 = this.r[9];\n\n while (bytes >= 16) {\n t0 = m[mpos+ 0] & 0xff | (m[mpos+ 1] & 0xff) << 8; h0 += ( t0 ) & 0x1fff;\n t1 = m[mpos+ 2] & 0xff | (m[mpos+ 3] & 0xff) << 8; h1 += ((t0 >>> 13) | (t1 << 3)) & 0x1fff;\n t2 = m[mpos+ 4] & 0xff | (m[mpos+ 5] & 0xff) << 8; h2 += ((t1 >>> 10) | (t2 << 6)) & 0x1fff;\n t3 = m[mpos+ 6] & 0xff | (m[mpos+ 7] & 0xff) << 8; h3 += ((t2 >>> 7) | (t3 << 9)) & 0x1fff;\n t4 = m[mpos+ 8] & 0xff | (m[mpos+ 9] & 0xff) << 8; h4 += ((t3 >>> 4) | (t4 << 12)) & 0x1fff;\n h5 += ((t4 >>> 1)) & 0x1fff;\n t5 = m[mpos+10] & 0xff | (m[mpos+11] & 0xff) << 8; h6 += ((t4 >>> 14) | (t5 << 2)) & 0x1fff;\n t6 = m[mpos+12] & 0xff | (m[mpos+13] & 0xff) << 8; h7 += ((t5 >>> 11) | (t6 << 5)) & 0x1fff;\n t7 = m[mpos+14] & 0xff | (m[mpos+15] & 0xff) << 8; h8 += ((t6 >>> 8) | (t7 << 8)) & 0x1fff;\n h9 += ((t7 >>> 5)) | hibit;\n\n c = 0;\n\n d0 = c;\n d0 += h0 * r0;\n d0 += h1 * (5 * r9);\n d0 += h2 * (5 * r8);\n d0 += h3 * (5 * r7);\n d0 += h4 * (5 * r6);\n c = (d0 >>> 13); d0 &= 0x1fff;\n d0 += h5 * (5 * r5);\n d0 += h6 * (5 * r4);\n d0 += h7 * (5 * r3);\n d0 += h8 * (5 * r2);\n d0 += h9 * (5 * r1);\n c += (d0 >>> 13); d0 &= 0x1fff;\n\n d1 = c;\n d1 += h0 * r1;\n d1 += h1 * r0;\n d1 += h2 * (5 * r9);\n d1 += h3 * (5 * r8);\n d1 += h4 * (5 * r7);\n c = (d1 >>> 13); d1 &= 0x1fff;\n d1 += h5 * (5 * r6);\n d1 += h6 * (5 * r5);\n d1 += h7 * (5 * r4);\n d1 += h8 * (5 * r3);\n d1 += h9 * (5 * r2);\n c += (d1 >>> 13); d1 &= 0x1fff;\n\n d2 = c;\n d2 += h0 * r2;\n d2 += h1 * r1;\n d2 += h2 * r0;\n d2 += h3 * (5 * r9);\n d2 += h4 * (5 * r8);\n c = (d2 >>> 13); d2 &= 0x1fff;\n d2 += h5 * (5 * r7);\n d2 += h6 * (5 * r6);\n d2 += h7 * (5 * r5);\n d2 += h8 * (5 * r4);\n d2 += h9 * (5 * r3);\n c += (d2 >>> 13); d2 &= 0x1fff;\n\n d3 = c;\n d3 += h0 * r3;\n d3 += h1 * r2;\n d3 += h2 * r1;\n d3 += h3 * r0;\n d3 += h4 * (5 * r9);\n c = (d3 >>> 13); d3 &= 0x1fff;\n d3 += h5 * (5 * r8);\n d3 += h6 * (5 * r7);\n d3 += h7 * (5 * r6);\n d3 += h8 * (5 * r5);\n d3 += h9 * (5 * r4);\n c += (d3 >>> 13); d3 &= 0x1fff;\n\n d4 = c;\n d4 += h0 * r4;\n d4 += h1 * r3;\n d4 += h2 * r2;\n d4 += h3 * r1;\n d4 += h4 * r0;\n c = (d4 >>> 13); d4 &= 0x1fff;\n d4 += h5 * (5 * r9);\n d4 += h6 * (5 * r8);\n d4 += h7 * (5 * r7);\n d4 += h8 * (5 * r6);\n d4 += h9 * (5 * r5);\n c += (d4 >>> 13); d4 &= 0x1fff;\n\n d5 = c;\n d5 += h0 * r5;\n d5 += h1 * r4;\n d5 += h2 * r3;\n d5 += h3 * r2;\n d5 += h4 * r1;\n c = (d5 >>> 13); d5 &= 0x1fff;\n d5 += h5 * r0;\n d5 += h6 * (5 * r9);\n d5 += h7 * (5 * r8);\n d5 += h8 * (5 * r7);\n d5 += h9 * (5 * r6);\n c += (d5 >>> 13); d5 &= 0x1fff;\n\n d6 = c;\n d6 += h0 * r6;\n d6 += h1 * r5;\n d6 += h2 * r4;\n d6 += h3 * r3;\n d6 += h4 * r2;\n c = (d6 >>> 13); d6 &= 0x1fff;\n d6 += h5 * r1;\n d6 += h6 * r0;\n d6 += h7 * (5 * r9);\n d6 += h8 * (5 * r8);\n d6 += h9 * (5 * r7);\n c += (d6 >>> 13); d6 &= 0x1fff;\n\n d7 = c;\n d7 += h0 * r7;\n d7 += h1 * r6;\n d7 += h2 * r5;\n d7 += h3 * r4;\n d7 += h4 * r3;\n c = (d7 >>> 13); d7 &= 0x1fff;\n d7 += h5 * r2;\n d7 += h6 * r1;\n d7 += h7 * r0;\n d7 += h8 * (5 * r9);\n d7 += h9 * (5 * r8);\n c += (d7 >>> 13); d7 &= 0x1fff;\n\n d8 = c;\n d8 += h0 * r8;\n d8 += h1 * r7;\n d8 += h2 * r6;\n d8 += h3 * r5;\n d8 += h4 * r4;\n c = (d8 >>> 13); d8 &= 0x1fff;\n d8 += h5 * r3;\n d8 += h6 * r2;\n d8 += h7 * r1;\n d8 += h8 * r0;\n d8 += h9 * (5 * r9);\n c += (d8 >>> 13); d8 &= 0x1fff;\n\n d9 = c;\n d9 += h0 * r9;\n d9 += h1 * r8;\n d9 += h2 * r7;\n d9 += h3 * r6;\n d9 += h4 * r5;\n c = (d9 >>> 13); d9 &= 0x1fff;\n d9 += h5 * r4;\n d9 += h6 * r3;\n d9 += h7 * r2;\n d9 += h8 * r1;\n d9 += h9 * r0;\n c += (d9 >>> 13); d9 &= 0x1fff;\n\n c = (((c << 2) + c)) | 0;\n c = (c + d0) | 0;\n d0 = c & 0x1fff;\n c = (c >>> 13);\n d1 += c;\n\n h0 = d0;\n h1 = d1;\n h2 = d2;\n h3 = d3;\n h4 = d4;\n h5 = d5;\n h6 = d6;\n h7 = d7;\n h8 = d8;\n h9 = d9;\n\n mpos += 16;\n bytes -= 16;\n }\n this.h[0] = h0;\n this.h[1] = h1;\n this.h[2] = h2;\n this.h[3] = h3;\n this.h[4] = h4;\n this.h[5] = h5;\n this.h[6] = h6;\n this.h[7] = h7;\n this.h[8] = h8;\n this.h[9] = h9;\n};\n\npoly1305.prototype.finish = function(mac, macpos) {\n var g = new Uint16Array(10);\n var c, mask, f, i;\n\n if (this.leftover) {\n i = this.leftover;\n this.buffer[i++] = 1;\n for (; i < 16; i++) this.buffer[i] = 0;\n this.fin = 1;\n this.blocks(this.buffer, 0, 16);\n }\n\n c = this.h[1] >>> 13;\n this.h[1] &= 0x1fff;\n for (i = 2; i < 10; i++) {\n this.h[i] += c;\n c = this.h[i] >>> 13;\n this.h[i] &= 0x1fff;\n }\n this.h[0] += (c * 5);\n c = this.h[0] >>> 13;\n this.h[0] &= 0x1fff;\n this.h[1] += c;\n c = this.h[1] >>> 13;\n this.h[1] &= 0x1fff;\n this.h[2] += c;\n\n g[0] = this.h[0] + 5;\n c = g[0] >>> 13;\n g[0] &= 0x1fff;\n for (i = 1; i < 10; i++) {\n g[i] = this.h[i] + c;\n c = g[i] >>> 13;\n g[i] &= 0x1fff;\n }\n g[9] -= (1 << 13);\n\n mask = (c ^ 1) - 1;\n for (i = 0; i < 10; i++) g[i] &= mask;\n mask = ~mask;\n for (i = 0; i < 10; i++) this.h[i] = (this.h[i] & mask) | g[i];\n\n this.h[0] = ((this.h[0] ) | (this.h[1] << 13) ) & 0xffff;\n this.h[1] = ((this.h[1] >>> 3) | (this.h[2] << 10) ) & 0xffff;\n this.h[2] = ((this.h[2] >>> 6) | (this.h[3] << 7) ) & 0xffff;\n this.h[3] = ((this.h[3] >>> 9) | (this.h[4] << 4) ) & 0xffff;\n this.h[4] = ((this.h[4] >>> 12) | (this.h[5] << 1) | (this.h[6] << 14)) & 0xffff;\n this.h[5] = ((this.h[6] >>> 2) | (this.h[7] << 11) ) & 0xffff;\n this.h[6] = ((this.h[7] >>> 5) | (this.h[8] << 8) ) & 0xffff;\n this.h[7] = ((this.h[8] >>> 8) | (this.h[9] << 5) ) & 0xffff;\n\n f = this.h[0] + this.pad[0];\n this.h[0] = f & 0xffff;\n for (i = 1; i < 8; i++) {\n f = (((this.h[i] + this.pad[i]) | 0) + (f >>> 16)) | 0;\n this.h[i] = f & 0xffff;\n }\n\n mac[macpos+ 0] = (this.h[0] >>> 0) & 0xff;\n mac[macpos+ 1] = (this.h[0] >>> 8) & 0xff;\n mac[macpos+ 2] = (this.h[1] >>> 0) & 0xff;\n mac[macpos+ 3] = (this.h[1] >>> 8) & 0xff;\n mac[macpos+ 4] = (this.h[2] >>> 0) & 0xff;\n mac[macpos+ 5] = (this.h[2] >>> 8) & 0xff;\n mac[macpos+ 6] = (this.h[3] >>> 0) & 0xff;\n mac[macpos+ 7] = (this.h[3] >>> 8) & 0xff;\n mac[macpos+ 8] = (this.h[4] >>> 0) & 0xff;\n mac[macpos+ 9] = (this.h[4] >>> 8) & 0xff;\n mac[macpos+10] = (this.h[5] >>> 0) & 0xff;\n mac[macpos+11] = (this.h[5] >>> 8) & 0xff;\n mac[macpos+12] = (this.h[6] >>> 0) & 0xff;\n mac[macpos+13] = (this.h[6] >>> 8) & 0xff;\n mac[macpos+14] = (this.h[7] >>> 0) & 0xff;\n mac[macpos+15] = (this.h[7] >>> 8) & 0xff;\n};\n\npoly1305.prototype.update = function(m, mpos, bytes) {\n var i, want;\n\n if (this.leftover) {\n want = (16 - this.leftover);\n if (want > bytes)\n want = bytes;\n for (i = 0; i < want; i++)\n this.buffer[this.leftover + i] = m[mpos+i];\n bytes -= want;\n mpos += want;\n this.leftover += want;\n if (this.leftover < 16)\n return;\n this.blocks(this.buffer, 0, 16);\n this.leftover = 0;\n }\n\n if (bytes >= 16) {\n want = bytes - (bytes % 16);\n this.blocks(m, mpos, want);\n mpos += want;\n bytes -= want;\n }\n\n if (bytes) {\n for (i = 0; i < bytes; i++)\n this.buffer[this.leftover + i] = m[mpos+i];\n this.leftover += bytes;\n }\n};\n\nfunction crypto_onetimeauth(out, outpos, m, mpos, n, k) {\n var s = new poly1305(k);\n s.update(m, mpos, n);\n s.finish(out, outpos);\n return 0;\n}\n\nfunction crypto_onetimeauth_verify(h, hpos, m, mpos, n, k) {\n var x = new Uint8Array(16);\n crypto_onetimeauth(x,0,m,mpos,n,k);\n return crypto_verify_16(h,hpos,x,0);\n}\n\nfunction crypto_secretbox(c,m,d,n,k) {\n var i;\n if (d < 32) return -1;\n crypto_stream_xor(c,0,m,0,d,n,k);\n crypto_onetimeauth(c, 16, c, 32, d - 32, c);\n for (i = 0; i < 16; i++) c[i] = 0;\n return 0;\n}\n\nfunction crypto_secretbox_open(m,c,d,n,k) {\n var i;\n var x = new Uint8Array(32);\n if (d < 32) return -1;\n crypto_stream(x,0,32,n,k);\n if (crypto_onetimeauth_verify(c, 16,c, 32,d - 32,x) !== 0) return -1;\n crypto_stream_xor(m,0,c,0,d,n,k);\n for (i = 0; i < 32; i++) m[i] = 0;\n return 0;\n}\n\nfunction set25519(r, a) {\n var i;\n for (i = 0; i < 16; i++) r[i] = a[i]|0;\n}\n\nfunction car25519(o) {\n var i, v, c = 1;\n for (i = 0; i < 16; i++) {\n v = o[i] + c + 65535;\n c = Math.floor(v / 65536);\n o[i] = v - c * 65536;\n }\n o[0] += c-1 + 37 * (c-1);\n}\n\nfunction sel25519(p, q, b) {\n var t, c = ~(b-1);\n for (var i = 0; i < 16; i++) {\n t = c & (p[i] ^ q[i]);\n p[i] ^= t;\n q[i] ^= t;\n }\n}\n\nfunction pack25519(o, n) {\n var i, j, b;\n var m = gf(), t = gf();\n for (i = 0; i < 16; i++) t[i] = n[i];\n car25519(t);\n car25519(t);\n car25519(t);\n for (j = 0; j < 2; j++) {\n m[0] = t[0] - 0xffed;\n for (i = 1; i < 15; i++) {\n m[i] = t[i] - 0xffff - ((m[i-1]>>16) & 1);\n m[i-1] &= 0xffff;\n }\n m[15] = t[15] - 0x7fff - ((m[14]>>16) & 1);\n b = (m[15]>>16) & 1;\n m[14] &= 0xffff;\n sel25519(t, m, 1-b);\n }\n for (i = 0; i < 16; i++) {\n o[2*i] = t[i] & 0xff;\n o[2*i+1] = t[i]>>8;\n }\n}\n\nfunction neq25519(a, b) {\n var c = new Uint8Array(32), d = new Uint8Array(32);\n pack25519(c, a);\n pack25519(d, b);\n return crypto_verify_32(c, 0, d, 0);\n}\n\nfunction par25519(a) {\n var d = new Uint8Array(32);\n pack25519(d, a);\n return d[0] & 1;\n}\n\nfunction unpack25519(o, n) {\n var i;\n for (i = 0; i < 16; i++) o[i] = n[2*i] + (n[2*i+1] << 8);\n o[15] &= 0x7fff;\n}\n\nfunction A(o, a, b) {\n for (var i = 0; i < 16; i++) o[i] = a[i] + b[i];\n}\n\nfunction Z(o, a, b) {\n for (var i = 0; i < 16; i++) o[i] = a[i] - b[i];\n}\n\nfunction M(o, a, b) {\n var v, c,\n t0 = 0, t1 = 0, t2 = 0, t3 = 0, t4 = 0, t5 = 0, t6 = 0, t7 = 0,\n t8 = 0, t9 = 0, t10 = 0, t11 = 0, t12 = 0, t13 = 0, t14 = 0, t15 = 0,\n t16 = 0, t17 = 0, t18 = 0, t19 = 0, t20 = 0, t21 = 0, t22 = 0, t23 = 0,\n t24 = 0, t25 = 0, t26 = 0, t27 = 0, t28 = 0, t29 = 0, t30 = 0,\n b0 = b[0],\n b1 = b[1],\n b2 = b[2],\n b3 = b[3],\n b4 = b[4],\n b5 = b[5],\n b6 = b[6],\n b7 = b[7],\n b8 = b[8],\n b9 = b[9],\n b10 = b[10],\n b11 = b[11],\n b12 = b[12],\n b13 = b[13],\n b14 = b[14],\n b15 = b[15];\n\n v = a[0];\n t0 += v * b0;\n t1 += v * b1;\n t2 += v * b2;\n t3 += v * b3;\n t4 += v * b4;\n t5 += v * b5;\n t6 += v * b6;\n t7 += v * b7;\n t8 += v * b8;\n t9 += v * b9;\n t10 += v * b10;\n t11 += v * b11;\n t12 += v * b12;\n t13 += v * b13;\n t14 += v * b14;\n t15 += v * b15;\n v = a[1];\n t1 += v * b0;\n t2 += v * b1;\n t3 += v * b2;\n t4 += v * b3;\n t5 += v * b4;\n t6 += v * b5;\n t7 += v * b6;\n t8 += v * b7;\n t9 += v * b8;\n t10 += v * b9;\n t11 += v * b10;\n t12 += v * b11;\n t13 += v * b12;\n t14 += v * b13;\n t15 += v * b14;\n t16 += v * b15;\n v = a[2];\n t2 += v * b0;\n t3 += v * b1;\n t4 += v * b2;\n t5 += v * b3;\n t6 += v * b4;\n t7 += v * b5;\n t8 += v * b6;\n t9 += v * b7;\n t10 += v * b8;\n t11 += v * b9;\n t12 += v * b10;\n t13 += v * b11;\n t14 += v * b12;\n t15 += v * b13;\n t16 += v * b14;\n t17 += v * b15;\n v = a[3];\n t3 += v * b0;\n t4 += v * b1;\n t5 += v * b2;\n t6 += v * b3;\n t7 += v * b4;\n t8 += v * b5;\n t9 += v * b6;\n t10 += v * b7;\n t11 += v * b8;\n t12 += v * b9;\n t13 += v * b10;\n t14 += v * b11;\n t15 += v * b12;\n t16 += v * b13;\n t17 += v * b14;\n t18 += v * b15;\n v = a[4];\n t4 += v * b0;\n t5 += v * b1;\n t6 += v * b2;\n t7 += v * b3;\n t8 += v * b4;\n t9 += v * b5;\n t10 += v * b6;\n t11 += v * b7;\n t12 += v * b8;\n t13 += v * b9;\n t14 += v * b10;\n t15 += v * b11;\n t16 += v * b12;\n t17 += v * b13;\n t18 += v * b14;\n t19 += v * b15;\n v = a[5];\n t5 += v * b0;\n t6 += v * b1;\n t7 += v * b2;\n t8 += v * b3;\n t9 += v * b4;\n t10 += v * b5;\n t11 += v * b6;\n t12 += v * b7;\n t13 += v * b8;\n t14 += v * b9;\n t15 += v * b10;\n t16 += v * b11;\n t17 += v * b12;\n t18 += v * b13;\n t19 += v * b14;\n t20 += v * b15;\n v = a[6];\n t6 += v * b0;\n t7 += v * b1;\n t8 += v * b2;\n t9 += v * b3;\n t10 += v * b4;\n t11 += v * b5;\n t12 += v * b6;\n t13 += v * b7;\n t14 += v * b8;\n t15 += v * b9;\n t16 += v * b10;\n t17 += v * b11;\n t18 += v * b12;\n t19 += v * b13;\n t20 += v * b14;\n t21 += v * b15;\n v = a[7];\n t7 += v * b0;\n t8 += v * b1;\n t9 += v * b2;\n t10 += v * b3;\n t11 += v * b4;\n t12 += v * b5;\n t13 += v * b6;\n t14 += v * b7;\n t15 += v * b8;\n t16 += v * b9;\n t17 += v * b10;\n t18 += v * b11;\n t19 += v * b12;\n t20 += v * b13;\n t21 += v * b14;\n t22 += v * b15;\n v = a[8];\n t8 += v * b0;\n t9 += v * b1;\n t10 += v * b2;\n t11 += v * b3;\n t12 += v * b4;\n t13 += v * b5;\n t14 += v * b6;\n t15 += v * b7;\n t16 += v * b8;\n t17 += v * b9;\n t18 += v * b10;\n t19 += v * b11;\n t20 += v * b12;\n t21 += v * b13;\n t22 += v * b14;\n t23 += v * b15;\n v = a[9];\n t9 += v * b0;\n t10 += v * b1;\n t11 += v * b2;\n t12 += v * b3;\n t13 += v * b4;\n t14 += v * b5;\n t15 += v * b6;\n t16 += v * b7;\n t17 += v * b8;\n t18 += v * b9;\n t19 += v * b10;\n t20 += v * b11;\n t21 += v * b12;\n t22 += v * b13;\n t23 += v * b14;\n t24 += v * b15;\n v = a[10];\n t10 += v * b0;\n t11 += v * b1;\n t12 += v * b2;\n t13 += v * b3;\n t14 += v * b4;\n t15 += v * b5;\n t16 += v * b6;\n t17 += v * b7;\n t18 += v * b8;\n t19 += v * b9;\n t20 += v * b10;\n t21 += v * b11;\n t22 += v * b12;\n t23 += v * b13;\n t24 += v * b14;\n t25 += v * b15;\n v = a[11];\n t11 += v * b0;\n t12 += v * b1;\n t13 += v * b2;\n t14 += v * b3;\n t15 += v * b4;\n t16 += v * b5;\n t17 += v * b6;\n t18 += v * b7;\n t19 += v * b8;\n t20 += v * b9;\n t21 += v * b10;\n t22 += v * b11;\n t23 += v * b12;\n t24 += v * b13;\n t25 += v * b14;\n t26 += v * b15;\n v = a[12];\n t12 += v * b0;\n t13 += v * b1;\n t14 += v * b2;\n t15 += v * b3;\n t16 += v * b4;\n t17 += v * b5;\n t18 += v * b6;\n t19 += v * b7;\n t20 += v * b8;\n t21 += v * b9;\n t22 += v * b10;\n t23 += v * b11;\n t24 += v * b12;\n t25 += v * b13;\n t26 += v * b14;\n t27 += v * b15;\n v = a[13];\n t13 += v * b0;\n t14 += v * b1;\n t15 += v * b2;\n t16 += v * b3;\n t17 += v * b4;\n t18 += v * b5;\n t19 += v * b6;\n t20 += v * b7;\n t21 += v * b8;\n t22 += v * b9;\n t23 += v * b10;\n t24 += v * b11;\n t25 += v * b12;\n t26 += v * b13;\n t27 += v * b14;\n t28 += v * b15;\n v = a[14];\n t14 += v * b0;\n t15 += v * b1;\n t16 += v * b2;\n t17 += v * b3;\n t18 += v * b4;\n t19 += v * b5;\n t20 += v * b6;\n t21 += v * b7;\n t22 += v * b8;\n t23 += v * b9;\n t24 += v * b10;\n t25 += v * b11;\n t26 += v * b12;\n t27 += v * b13;\n t28 += v * b14;\n t29 += v * b15;\n v = a[15];\n t15 += v * b0;\n t16 += v * b1;\n t17 += v * b2;\n t18 += v * b3;\n t19 += v * b4;\n t20 += v * b5;\n t21 += v * b6;\n t22 += v * b7;\n t23 += v * b8;\n t24 += v * b9;\n t25 += v * b10;\n t26 += v * b11;\n t27 += v * b12;\n t28 += v * b13;\n t29 += v * b14;\n t30 += v * b15;\n\n t0 += 38 * t16;\n t1 += 38 * t17;\n t2 += 38 * t18;\n t3 += 38 * t19;\n t4 += 38 * t20;\n t5 += 38 * t21;\n t6 += 38 * t22;\n t7 += 38 * t23;\n t8 += 38 * t24;\n t9 += 38 * t25;\n t10 += 38 * t26;\n t11 += 38 * t27;\n t12 += 38 * t28;\n t13 += 38 * t29;\n t14 += 38 * t30;\n // t15 left as is\n\n // first car\n c = 1;\n v = t0 + c + 65535; c = Math.floor(v / 65536); t0 = v - c * 65536;\n v = t1 + c + 65535; c = Math.floor(v / 65536); t1 = v - c * 65536;\n v = t2 + c + 65535; c = Math.floor(v / 65536); t2 = v - c * 65536;\n v = t3 + c + 65535; c = Math.floor(v / 65536); t3 = v - c * 65536;\n v = t4 + c + 65535; c = Math.floor(v / 65536); t4 = v - c * 65536;\n v = t5 + c + 65535; c = Math.floor(v / 65536); t5 = v - c * 65536;\n v = t6 + c + 65535; c = Math.floor(v / 65536); t6 = v - c * 65536;\n v = t7 + c + 65535; c = Math.floor(v / 65536); t7 = v - c * 65536;\n v = t8 + c + 65535; c = Math.floor(v / 65536); t8 = v - c * 65536;\n v = t9 + c + 65535; c = Math.floor(v / 65536); t9 = v - c * 65536;\n v = t10 + c + 65535; c = Math.floor(v / 65536); t10 = v - c * 65536;\n v = t11 + c + 65535; c = Math.floor(v / 65536); t11 = v - c * 65536;\n v = t12 + c + 65535; c = Math.floor(v / 65536); t12 = v - c * 65536;\n v = t13 + c + 65535; c = Math.floor(v / 65536); t13 = v - c * 65536;\n v = t14 + c + 65535; c = Math.floor(v / 65536); t14 = v - c * 65536;\n v = t15 + c + 65535; c = Math.floor(v / 65536); t15 = v - c * 65536;\n t0 += c-1 + 37 * (c-1);\n\n // second car\n c = 1;\n v = t0 + c + 65535; c = Math.floor(v / 65536); t0 = v - c * 65536;\n v = t1 + c + 65535; c = Math.floor(v / 65536); t1 = v - c * 65536;\n v = t2 + c + 65535; c = Math.floor(v / 65536); t2 = v - c * 65536;\n v = t3 + c + 65535; c = Math.floor(v / 65536); t3 = v - c * 65536;\n v = t4 + c + 65535; c = Math.floor(v / 65536); t4 = v - c * 65536;\n v = t5 + c + 65535; c = Math.floor(v / 65536); t5 = v - c * 65536;\n v = t6 + c + 65535; c = Math.floor(v / 65536); t6 = v - c * 65536;\n v = t7 + c + 65535; c = Math.floor(v / 65536); t7 = v - c * 65536;\n v = t8 + c + 65535; c = Math.floor(v / 65536); t8 = v - c * 65536;\n v = t9 + c + 65535; c = Math.floor(v / 65536); t9 = v - c * 65536;\n v = t10 + c + 65535; c = Math.floor(v / 65536); t10 = v - c * 65536;\n v = t11 + c + 65535; c = Math.floor(v / 65536); t11 = v - c * 65536;\n v = t12 + c + 65535; c = Math.floor(v / 65536); t12 = v - c * 65536;\n v = t13 + c + 65535; c = Math.floor(v / 65536); t13 = v - c * 65536;\n v = t14 + c + 65535; c = Math.floor(v / 65536); t14 = v - c * 65536;\n v = t15 + c + 65535; c = Math.floor(v / 65536); t15 = v - c * 65536;\n t0 += c-1 + 37 * (c-1);\n\n o[ 0] = t0;\n o[ 1] = t1;\n o[ 2] = t2;\n o[ 3] = t3;\n o[ 4] = t4;\n o[ 5] = t5;\n o[ 6] = t6;\n o[ 7] = t7;\n o[ 8] = t8;\n o[ 9] = t9;\n o[10] = t10;\n o[11] = t11;\n o[12] = t12;\n o[13] = t13;\n o[14] = t14;\n o[15] = t15;\n}\n\nfunction S(o, a) {\n M(o, a, a);\n}\n\nfunction inv25519(o, i) {\n var c = gf();\n var a;\n for (a = 0; a < 16; a++) c[a] = i[a];\n for (a = 253; a >= 0; a--) {\n S(c, c);\n if(a !== 2 && a !== 4) M(c, c, i);\n }\n for (a = 0; a < 16; a++) o[a] = c[a];\n}\n\nfunction pow2523(o, i) {\n var c = gf();\n var a;\n for (a = 0; a < 16; a++) c[a] = i[a];\n for (a = 250; a >= 0; a--) {\n S(c, c);\n if(a !== 1) M(c, c, i);\n }\n for (a = 0; a < 16; a++) o[a] = c[a];\n}\n\nfunction crypto_scalarmult(q, n, p) {\n var z = new Uint8Array(32);\n var x = new Float64Array(80), r, i;\n var a = gf(), b = gf(), c = gf(),\n d = gf(), e = gf(), f = gf();\n for (i = 0; i < 31; i++) z[i] = n[i];\n z[31]=(n[31]&127)|64;\n z[0]&=248;\n unpack25519(x,p);\n for (i = 0; i < 16; i++) {\n b[i]=x[i];\n d[i]=a[i]=c[i]=0;\n }\n a[0]=d[0]=1;\n for (i=254; i>=0; --i) {\n r=(z[i>>>3]>>>(i&7))&1;\n sel25519(a,b,r);\n sel25519(c,d,r);\n A(e,a,c);\n Z(a,a,c);\n A(c,b,d);\n Z(b,b,d);\n S(d,e);\n S(f,a);\n M(a,c,a);\n M(c,b,e);\n A(e,a,c);\n Z(a,a,c);\n S(b,a);\n Z(c,d,f);\n M(a,c,_121665);\n A(a,a,d);\n M(c,c,a);\n M(a,d,f);\n M(d,b,x);\n S(b,e);\n sel25519(a,b,r);\n sel25519(c,d,r);\n }\n for (i = 0; i < 16; i++) {\n x[i+16]=a[i];\n x[i+32]=c[i];\n x[i+48]=b[i];\n x[i+64]=d[i];\n }\n var x32 = x.subarray(32);\n var x16 = x.subarray(16);\n inv25519(x32,x32);\n M(x16,x16,x32);\n pack25519(q,x16);\n return 0;\n}\n\nfunction crypto_scalarmult_base(q, n) {\n return crypto_scalarmult(q, n, _9);\n}\n\nfunction crypto_box_keypair(y, x) {\n randombytes(x, 32);\n return crypto_scalarmult_base(y, x);\n}\n\nfunction crypto_box_beforenm(k, y, x) {\n var s = new Uint8Array(32);\n crypto_scalarmult(s, x, y);\n return crypto_core_hsalsa20(k, _0, s, sigma);\n}\n\nvar crypto_box_afternm = crypto_secretbox;\nvar crypto_box_open_afternm = crypto_secretbox_open;\n\nfunction crypto_box(c, m, d, n, y, x) {\n var k = new Uint8Array(32);\n crypto_box_beforenm(k, y, x);\n return crypto_box_afternm(c, m, d, n, k);\n}\n\nfunction crypto_box_open(m, c, d, n, y, x) {\n var k = new Uint8Array(32);\n crypto_box_beforenm(k, y, x);\n return crypto_box_open_afternm(m, c, d, n, k);\n}\n\nvar K = [\n 0x428a2f98, 0xd728ae22, 0x71374491, 0x23ef65cd,\n 0xb5c0fbcf, 0xec4d3b2f, 0xe9b5dba5, 0x8189dbbc,\n 0x3956c25b, 0xf348b538, 0x59f111f1, 0xb605d019,\n 0x923f82a4, 0xaf194f9b, 0xab1c5ed5, 0xda6d8118,\n 0xd807aa98, 0xa3030242, 0x12835b01, 0x45706fbe,\n 0x243185be, 0x4ee4b28c, 0x550c7dc3, 0xd5ffb4e2,\n 0x72be5d74, 0xf27b896f, 0x80deb1fe, 0x3b1696b1,\n 0x9bdc06a7, 0x25c71235, 0xc19bf174, 0xcf692694,\n 0xe49b69c1, 0x9ef14ad2, 0xefbe4786, 0x384f25e3,\n 0x0fc19dc6, 0x8b8cd5b5, 0x240ca1cc, 0x77ac9c65,\n 0x2de92c6f, 0x592b0275, 0x4a7484aa, 0x6ea6e483,\n 0x5cb0a9dc, 0xbd41fbd4, 0x76f988da, 0x831153b5,\n 0x983e5152, 0xee66dfab, 0xa831c66d, 0x2db43210,\n 0xb00327c8, 0x98fb213f, 0xbf597fc7, 0xbeef0ee4,\n 0xc6e00bf3, 0x3da88fc2, 0xd5a79147, 0x930aa725,\n 0x06ca6351, 0xe003826f, 0x14292967, 0x0a0e6e70,\n 0x27b70a85, 0x46d22ffc, 0x2e1b2138, 0x5c26c926,\n 0x4d2c6dfc, 0x5ac42aed, 0x53380d13, 0x9d95b3df,\n 0x650a7354, 0x8baf63de, 0x766a0abb, 0x3c77b2a8,\n 0x81c2c92e, 0x47edaee6, 0x92722c85, 0x1482353b,\n 0xa2bfe8a1, 0x4cf10364, 0xa81a664b, 0xbc423001,\n 0xc24b8b70, 0xd0f89791, 0xc76c51a3, 0x0654be30,\n 0xd192e819, 0xd6ef5218, 0xd6990624, 0x5565a910,\n 0xf40e3585, 0x5771202a, 0x106aa070, 0x32bbd1b8,\n 0x19a4c116, 0xb8d2d0c8, 0x1e376c08, 0x5141ab53,\n 0x2748774c, 0xdf8eeb99, 0x34b0bcb5, 0xe19b48a8,\n 0x391c0cb3, 0xc5c95a63, 0x4ed8aa4a, 0xe3418acb,\n 0x5b9cca4f, 0x7763e373, 0x682e6ff3, 0xd6b2b8a3,\n 0x748f82ee, 0x5defb2fc, 0x78a5636f, 0x43172f60,\n 0x84c87814, 0xa1f0ab72, 0x8cc70208, 0x1a6439ec,\n 0x90befffa, 0x23631e28, 0xa4506ceb, 0xde82bde9,\n 0xbef9a3f7, 0xb2c67915, 0xc67178f2, 0xe372532b,\n 0xca273ece, 0xea26619c, 0xd186b8c7, 0x21c0c207,\n 0xeada7dd6, 0xcde0eb1e, 0xf57d4f7f, 0xee6ed178,\n 0x06f067aa, 0x72176fba, 0x0a637dc5, 0xa2c898a6,\n 0x113f9804, 0xbef90dae, 0x1b710b35, 0x131c471b,\n 0x28db77f5, 0x23047d84, 0x32caab7b, 0x40c72493,\n 0x3c9ebe0a, 0x15c9bebc, 0x431d67c4, 0x9c100d4c,\n 0x4cc5d4be, 0xcb3e42b6, 0x597f299c, 0xfc657e2a,\n 0x5fcb6fab, 0x3ad6faec, 0x6c44198c, 0x4a475817\n];\n\nfunction crypto_hashblocks_hl(hh, hl, m, n) {\n var wh = new Int32Array(16), wl = new Int32Array(16),\n bh0, bh1, bh2, bh3, bh4, bh5, bh6, bh7,\n bl0, bl1, bl2, bl3, bl4, bl5, bl6, bl7,\n th, tl, i, j, h, l, a, b, c, d;\n\n var ah0 = hh[0],\n ah1 = hh[1],\n ah2 = hh[2],\n ah3 = hh[3],\n ah4 = hh[4],\n ah5 = hh[5],\n ah6 = hh[6],\n ah7 = hh[7],\n\n al0 = hl[0],\n al1 = hl[1],\n al2 = hl[2],\n al3 = hl[3],\n al4 = hl[4],\n al5 = hl[5],\n al6 = hl[6],\n al7 = hl[7];\n\n var pos = 0;\n while (n >= 128) {\n for (i = 0; i < 16; i++) {\n j = 8 * i + pos;\n wh[i] = (m[j+0] << 24) | (m[j+1] << 16) | (m[j+2] << 8) | m[j+3];\n wl[i] = (m[j+4] << 24) | (m[j+5] << 16) | (m[j+6] << 8) | m[j+7];\n }\n for (i = 0; i < 80; i++) {\n bh0 = ah0;\n bh1 = ah1;\n bh2 = ah2;\n bh3 = ah3;\n bh4 = ah4;\n bh5 = ah5;\n bh6 = ah6;\n bh7 = ah7;\n\n bl0 = al0;\n bl1 = al1;\n bl2 = al2;\n bl3 = al3;\n bl4 = al4;\n bl5 = al5;\n bl6 = al6;\n bl7 = al7;\n\n // add\n h = ah7;\n l = al7;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n // Sigma1\n h = ((ah4 >>> 14) | (al4 << (32-14))) ^ ((ah4 >>> 18) | (al4 << (32-18))) ^ ((al4 >>> (41-32)) | (ah4 << (32-(41-32))));\n l = ((al4 >>> 14) | (ah4 << (32-14))) ^ ((al4 >>> 18) | (ah4 << (32-18))) ^ ((ah4 >>> (41-32)) | (al4 << (32-(41-32))));\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // Ch\n h = (ah4 & ah5) ^ (~ah4 & ah6);\n l = (al4 & al5) ^ (~al4 & al6);\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // K\n h = K[i*2];\n l = K[i*2+1];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // w\n h = wh[i%16];\n l = wl[i%16];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n th = c & 0xffff | d << 16;\n tl = a & 0xffff | b << 16;\n\n // add\n h = th;\n l = tl;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n // Sigma0\n h = ((ah0 >>> 28) | (al0 << (32-28))) ^ ((al0 >>> (34-32)) | (ah0 << (32-(34-32)))) ^ ((al0 >>> (39-32)) | (ah0 << (32-(39-32))));\n l = ((al0 >>> 28) | (ah0 << (32-28))) ^ ((ah0 >>> (34-32)) | (al0 << (32-(34-32)))) ^ ((ah0 >>> (39-32)) | (al0 << (32-(39-32))));\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // Maj\n h = (ah0 & ah1) ^ (ah0 & ah2) ^ (ah1 & ah2);\n l = (al0 & al1) ^ (al0 & al2) ^ (al1 & al2);\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n bh7 = (c & 0xffff) | (d << 16);\n bl7 = (a & 0xffff) | (b << 16);\n\n // add\n h = bh3;\n l = bl3;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = th;\n l = tl;\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n bh3 = (c & 0xffff) | (d << 16);\n bl3 = (a & 0xffff) | (b << 16);\n\n ah1 = bh0;\n ah2 = bh1;\n ah3 = bh2;\n ah4 = bh3;\n ah5 = bh4;\n ah6 = bh5;\n ah7 = bh6;\n ah0 = bh7;\n\n al1 = bl0;\n al2 = bl1;\n al3 = bl2;\n al4 = bl3;\n al5 = bl4;\n al6 = bl5;\n al7 = bl6;\n al0 = bl7;\n\n if (i%16 === 15) {\n for (j = 0; j < 16; j++) {\n // add\n h = wh[j];\n l = wl[j];\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = wh[(j+9)%16];\n l = wl[(j+9)%16];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // sigma0\n th = wh[(j+1)%16];\n tl = wl[(j+1)%16];\n h = ((th >>> 1) | (tl << (32-1))) ^ ((th >>> 8) | (tl << (32-8))) ^ (th >>> 7);\n l = ((tl >>> 1) | (th << (32-1))) ^ ((tl >>> 8) | (th << (32-8))) ^ ((tl >>> 7) | (th << (32-7)));\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // sigma1\n th = wh[(j+14)%16];\n tl = wl[(j+14)%16];\n h = ((th >>> 19) | (tl << (32-19))) ^ ((tl >>> (61-32)) | (th << (32-(61-32)))) ^ (th >>> 6);\n l = ((tl >>> 19) | (th << (32-19))) ^ ((th >>> (61-32)) | (tl << (32-(61-32)))) ^ ((tl >>> 6) | (th << (32-6)));\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n wh[j] = (c & 0xffff) | (d << 16);\n wl[j] = (a & 0xffff) | (b << 16);\n }\n }\n }\n\n // add\n h = ah0;\n l = al0;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[0];\n l = hl[0];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[0] = ah0 = (c & 0xffff) | (d << 16);\n hl[0] = al0 = (a & 0xffff) | (b << 16);\n\n h = ah1;\n l = al1;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[1];\n l = hl[1];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[1] = ah1 = (c & 0xffff) | (d << 16);\n hl[1] = al1 = (a & 0xffff) | (b << 16);\n\n h = ah2;\n l = al2;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[2];\n l = hl[2];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[2] = ah2 = (c & 0xffff) | (d << 16);\n hl[2] = al2 = (a & 0xffff) | (b << 16);\n\n h = ah3;\n l = al3;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[3];\n l = hl[3];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[3] = ah3 = (c & 0xffff) | (d << 16);\n hl[3] = al3 = (a & 0xffff) | (b << 16);\n\n h = ah4;\n l = al4;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[4];\n l = hl[4];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[4] = ah4 = (c & 0xffff) | (d << 16);\n hl[4] = al4 = (a & 0xffff) | (b << 16);\n\n h = ah5;\n l = al5;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[5];\n l = hl[5];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[5] = ah5 = (c & 0xffff) | (d << 16);\n hl[5] = al5 = (a & 0xffff) | (b << 16);\n\n h = ah6;\n l = al6;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[6];\n l = hl[6];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[6] = ah6 = (c & 0xffff) | (d << 16);\n hl[6] = al6 = (a & 0xffff) | (b << 16);\n\n h = ah7;\n l = al7;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[7];\n l = hl[7];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[7] = ah7 = (c & 0xffff) | (d << 16);\n hl[7] = al7 = (a & 0xffff) | (b << 16);\n\n pos += 128;\n n -= 128;\n }\n\n return n;\n}\n\nfunction crypto_hash(out, m, n) {\n var hh = new Int32Array(8),\n hl = new Int32Array(8),\n x = new Uint8Array(256),\n i, b = n;\n\n hh[0] = 0x6a09e667;\n hh[1] = 0xbb67ae85;\n hh[2] = 0x3c6ef372;\n hh[3] = 0xa54ff53a;\n hh[4] = 0x510e527f;\n hh[5] = 0x9b05688c;\n hh[6] = 0x1f83d9ab;\n hh[7] = 0x5be0cd19;\n\n hl[0] = 0xf3bcc908;\n hl[1] = 0x84caa73b;\n hl[2] = 0xfe94f82b;\n hl[3] = 0x5f1d36f1;\n hl[4] = 0xade682d1;\n hl[5] = 0x2b3e6c1f;\n hl[6] = 0xfb41bd6b;\n hl[7] = 0x137e2179;\n\n crypto_hashblocks_hl(hh, hl, m, n);\n n %= 128;\n\n for (i = 0; i < n; i++) x[i] = m[b-n+i];\n x[n] = 128;\n\n n = 256-128*(n<112?1:0);\n x[n-9] = 0;\n ts64(x, n-8, (b / 0x20000000) | 0, b << 3);\n crypto_hashblocks_hl(hh, hl, x, n);\n\n for (i = 0; i < 8; i++) ts64(out, 8*i, hh[i], hl[i]);\n\n return 0;\n}\n\nfunction add(p, q) {\n var a = gf(), b = gf(), c = gf(),\n d = gf(), e = gf(), f = gf(),\n g = gf(), h = gf(), t = gf();\n\n Z(a, p[1], p[0]);\n Z(t, q[1], q[0]);\n M(a, a, t);\n A(b, p[0], p[1]);\n A(t, q[0], q[1]);\n M(b, b, t);\n M(c, p[3], q[3]);\n M(c, c, D2);\n M(d, p[2], q[2]);\n A(d, d, d);\n Z(e, b, a);\n Z(f, d, c);\n A(g, d, c);\n A(h, b, a);\n\n M(p[0], e, f);\n M(p[1], h, g);\n M(p[2], g, f);\n M(p[3], e, h);\n}\n\nfunction cswap(p, q, b) {\n var i;\n for (i = 0; i < 4; i++) {\n sel25519(p[i], q[i], b);\n }\n}\n\nfunction pack(r, p) {\n var tx = gf(), ty = gf(), zi = gf();\n inv25519(zi, p[2]);\n M(tx, p[0], zi);\n M(ty, p[1], zi);\n pack25519(r, ty);\n r[31] ^= par25519(tx) << 7;\n}\n\nfunction scalarmult(p, q, s) {\n var b, i;\n set25519(p[0], gf0);\n set25519(p[1], gf1);\n set25519(p[2], gf1);\n set25519(p[3], gf0);\n for (i = 255; i >= 0; --i) {\n b = (s[(i/8)|0] >> (i&7)) & 1;\n cswap(p, q, b);\n add(q, p);\n add(p, p);\n cswap(p, q, b);\n }\n}\n\nfunction scalarbase(p, s) {\n var q = [gf(), gf(), gf(), gf()];\n set25519(q[0], X);\n set25519(q[1], Y);\n set25519(q[2], gf1);\n M(q[3], X, Y);\n scalarmult(p, q, s);\n}\n\nfunction crypto_sign_keypair(pk, sk, seeded) {\n var d = new Uint8Array(64);\n var p = [gf(), gf(), gf(), gf()];\n var i;\n\n if (!seeded) randombytes(sk, 32);\n crypto_hash(d, sk, 32);\n d[0] &= 248;\n d[31] &= 127;\n d[31] |= 64;\n\n scalarbase(p, d);\n pack(pk, p);\n\n for (i = 0; i < 32; i++) sk[i+32] = pk[i];\n return 0;\n}\n\nvar L = new Float64Array([0xed, 0xd3, 0xf5, 0x5c, 0x1a, 0x63, 0x12, 0x58, 0xd6, 0x9c, 0xf7, 0xa2, 0xde, 0xf9, 0xde, 0x14, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x10]);\n\nfunction modL(r, x) {\n var carry, i, j, k;\n for (i = 63; i >= 32; --i) {\n carry = 0;\n for (j = i - 32, k = i - 12; j < k; ++j) {\n x[j] += carry - 16 * x[i] * L[j - (i - 32)];\n carry = Math.floor((x[j] + 128) / 256);\n x[j] -= carry * 256;\n }\n x[j] += carry;\n x[i] = 0;\n }\n carry = 0;\n for (j = 0; j < 32; j++) {\n x[j] += carry - (x[31] >> 4) * L[j];\n carry = x[j] >> 8;\n x[j] &= 255;\n }\n for (j = 0; j < 32; j++) x[j] -= carry * L[j];\n for (i = 0; i < 32; i++) {\n x[i+1] += x[i] >> 8;\n r[i] = x[i] & 255;\n }\n}\n\nfunction reduce(r) {\n var x = new Float64Array(64), i;\n for (i = 0; i < 64; i++) x[i] = r[i];\n for (i = 0; i < 64; i++) r[i] = 0;\n modL(r, x);\n}\n\n// Note: difference from C - smlen returned, not passed as argument.\nfunction crypto_sign(sm, m, n, sk) {\n var d = new Uint8Array(64), h = new Uint8Array(64), r = new Uint8Array(64);\n var i, j, x = new Float64Array(64);\n var p = [gf(), gf(), gf(), gf()];\n\n crypto_hash(d, sk, 32);\n d[0] &= 248;\n d[31] &= 127;\n d[31] |= 64;\n\n var smlen = n + 64;\n for (i = 0; i < n; i++) sm[64 + i] = m[i];\n for (i = 0; i < 32; i++) sm[32 + i] = d[32 + i];\n\n crypto_hash(r, sm.subarray(32), n+32);\n reduce(r);\n scalarbase(p, r);\n pack(sm, p);\n\n for (i = 32; i < 64; i++) sm[i] = sk[i];\n crypto_hash(h, sm, n + 64);\n reduce(h);\n\n for (i = 0; i < 64; i++) x[i] = 0;\n for (i = 0; i < 32; i++) x[i] = r[i];\n for (i = 0; i < 32; i++) {\n for (j = 0; j < 32; j++) {\n x[i+j] += h[i] * d[j];\n }\n }\n\n modL(sm.subarray(32), x);\n return smlen;\n}\n\nfunction unpackneg(r, p) {\n var t = gf(), chk = gf(), num = gf(),\n den = gf(), den2 = gf(), den4 = gf(),\n den6 = gf();\n\n set25519(r[2], gf1);\n unpack25519(r[1], p);\n S(num, r[1]);\n M(den, num, D);\n Z(num, num, r[2]);\n A(den, r[2], den);\n\n S(den2, den);\n S(den4, den2);\n M(den6, den4, den2);\n M(t, den6, num);\n M(t, t, den);\n\n pow2523(t, t);\n M(t, t, num);\n M(t, t, den);\n M(t, t, den);\n M(r[0], t, den);\n\n S(chk, r[0]);\n M(chk, chk, den);\n if (neq25519(chk, num)) M(r[0], r[0], I);\n\n S(chk, r[0]);\n M(chk, chk, den);\n if (neq25519(chk, num)) return -1;\n\n if (par25519(r[0]) === (p[31]>>7)) Z(r[0], gf0, r[0]);\n\n M(r[3], r[0], r[1]);\n return 0;\n}\n\nfunction crypto_sign_open(m, sm, n, pk) {\n var i;\n var t = new Uint8Array(32), h = new Uint8Array(64);\n var p = [gf(), gf(), gf(), gf()],\n q = [gf(), gf(), gf(), gf()];\n\n if (n < 64) return -1;\n\n if (unpackneg(q, pk)) return -1;\n\n for (i = 0; i < n; i++) m[i] = sm[i];\n for (i = 0; i < 32; i++) m[i+32] = pk[i];\n crypto_hash(h, m, n);\n reduce(h);\n scalarmult(p, q, h);\n\n scalarbase(q, sm.subarray(32));\n add(p, q);\n pack(t, p);\n\n n -= 64;\n if (crypto_verify_32(sm, 0, t, 0)) {\n for (i = 0; i < n; i++) m[i] = 0;\n return -1;\n }\n\n for (i = 0; i < n; i++) m[i] = sm[i + 64];\n return n;\n}\n\nvar crypto_secretbox_KEYBYTES = 32,\n crypto_secretbox_NONCEBYTES = 24,\n crypto_secretbox_ZEROBYTES = 32,\n crypto_secretbox_BOXZEROBYTES = 16,\n crypto_scalarmult_BYTES = 32,\n crypto_scalarmult_SCALARBYTES = 32,\n crypto_box_PUBLICKEYBYTES = 32,\n crypto_box_SECRETKEYBYTES = 32,\n crypto_box_BEFORENMBYTES = 32,\n crypto_box_NONCEBYTES = crypto_secretbox_NONCEBYTES,\n crypto_box_ZEROBYTES = crypto_secretbox_ZEROBYTES,\n crypto_box_BOXZEROBYTES = crypto_secretbox_BOXZEROBYTES,\n crypto_sign_BYTES = 64,\n crypto_sign_PUBLICKEYBYTES = 32,\n crypto_sign_SECRETKEYBYTES = 64,\n crypto_sign_SEEDBYTES = 32,\n crypto_hash_BYTES = 64;\n\nnacl.lowlevel = {\n crypto_core_hsalsa20: crypto_core_hsalsa20,\n crypto_stream_xor: crypto_stream_xor,\n crypto_stream: crypto_stream,\n crypto_stream_salsa20_xor: crypto_stream_salsa20_xor,\n crypto_stream_salsa20: crypto_stream_salsa20,\n crypto_onetimeauth: crypto_onetimeauth,\n crypto_onetimeauth_verify: crypto_onetimeauth_verify,\n crypto_verify_16: crypto_verify_16,\n crypto_verify_32: crypto_verify_32,\n crypto_secretbox: crypto_secretbox,\n crypto_secretbox_open: crypto_secretbox_open,\n crypto_scalarmult: crypto_scalarmult,\n crypto_scalarmult_base: crypto_scalarmult_base,\n crypto_box_beforenm: crypto_box_beforenm,\n crypto_box_afternm: crypto_box_afternm,\n crypto_box: crypto_box,\n crypto_box_open: crypto_box_open,\n crypto_box_keypair: crypto_box_keypair,\n crypto_hash: crypto_hash,\n crypto_sign: crypto_sign,\n crypto_sign_keypair: crypto_sign_keypair,\n crypto_sign_open: crypto_sign_open,\n\n crypto_secretbox_KEYBYTES: crypto_secretbox_KEYBYTES,\n crypto_secretbox_NONCEBYTES: crypto_secretbox_NONCEBYTES,\n crypto_secretbox_ZEROBYTES: crypto_secretbox_ZEROBYTES,\n crypto_secretbox_BOXZEROBYTES: crypto_secretbox_BOXZEROBYTES,\n crypto_scalarmult_BYTES: crypto_scalarmult_BYTES,\n crypto_scalarmult_SCALARBYTES: crypto_scalarmult_SCALARBYTES,\n crypto_box_PUBLICKEYBYTES: crypto_box_PUBLICKEYBYTES,\n crypto_box_SECRETKEYBYTES: crypto_box_SECRETKEYBYTES,\n crypto_box_BEFORENMBYTES: crypto_box_BEFORENMBYTES,\n crypto_box_NONCEBYTES: crypto_box_NONCEBYTES,\n crypto_box_ZEROBYTES: crypto_box_ZEROBYTES,\n crypto_box_BOXZEROBYTES: crypto_box_BOXZEROBYTES,\n crypto_sign_BYTES: crypto_sign_BYTES,\n crypto_sign_PUBLICKEYBYTES: crypto_sign_PUBLICKEYBYTES,\n crypto_sign_SECRETKEYBYTES: crypto_sign_SECRETKEYBYTES,\n crypto_sign_SEEDBYTES: crypto_sign_SEEDBYTES,\n crypto_hash_BYTES: crypto_hash_BYTES,\n\n gf: gf,\n D: D,\n L: L,\n pack25519: pack25519,\n unpack25519: unpack25519,\n M: M,\n A: A,\n S: S,\n Z: Z,\n pow2523: pow2523,\n add: add,\n set25519: set25519,\n modL: modL,\n scalarmult: scalarmult,\n scalarbase: scalarbase,\n};\n\n/* High-level API */\n\nfunction checkLengths(k, n) {\n if (k.length !== crypto_secretbox_KEYBYTES) throw new Error('bad key size');\n if (n.length !== crypto_secretbox_NONCEBYTES) throw new Error('bad nonce size');\n}\n\nfunction checkBoxLengths(pk, sk) {\n if (pk.length !== crypto_box_PUBLICKEYBYTES) throw new Error('bad public key size');\n if (sk.length !== crypto_box_SECRETKEYBYTES) throw new Error('bad secret key size');\n}\n\nfunction checkArrayTypes() {\n for (var i = 0; i < arguments.length; i++) {\n if (!(arguments[i] instanceof Uint8Array))\n throw new TypeError('unexpected type, use Uint8Array');\n }\n}\n\nfunction cleanup(arr) {\n for (var i = 0; i < arr.length; i++) arr[i] = 0;\n}\n\nnacl.randomBytes = function(n) {\n var b = new Uint8Array(n);\n randombytes(b, n);\n return b;\n};\n\nnacl.secretbox = function(msg, nonce, key) {\n checkArrayTypes(msg, nonce, key);\n checkLengths(key, nonce);\n var m = new Uint8Array(crypto_secretbox_ZEROBYTES + msg.length);\n var c = new Uint8Array(m.length);\n for (var i = 0; i < msg.length; i++) m[i+crypto_secretbox_ZEROBYTES] = msg[i];\n crypto_secretbox(c, m, m.length, nonce, key);\n return c.subarray(crypto_secretbox_BOXZEROBYTES);\n};\n\nnacl.secretbox.open = function(box, nonce, key) {\n checkArrayTypes(box, nonce, key);\n checkLengths(key, nonce);\n var c = new Uint8Array(crypto_secretbox_BOXZEROBYTES + box.length);\n var m = new Uint8Array(c.length);\n for (var i = 0; i < box.length; i++) c[i+crypto_secretbox_BOXZEROBYTES] = box[i];\n if (c.length < 32) return null;\n if (crypto_secretbox_open(m, c, c.length, nonce, key) !== 0) return null;\n return m.subarray(crypto_secretbox_ZEROBYTES);\n};\n\nnacl.secretbox.keyLength = crypto_secretbox_KEYBYTES;\nnacl.secretbox.nonceLength = crypto_secretbox_NONCEBYTES;\nnacl.secretbox.overheadLength = crypto_secretbox_BOXZEROBYTES;\n\nnacl.scalarMult = function(n, p) {\n checkArrayTypes(n, p);\n if (n.length !== crypto_scalarmult_SCALARBYTES) throw new Error('bad n size');\n if (p.length !== crypto_scalarmult_BYTES) throw new Error('bad p size');\n var q = new Uint8Array(crypto_scalarmult_BYTES);\n crypto_scalarmult(q, n, p);\n return q;\n};\n\nnacl.scalarMult.base = function(n) {\n checkArrayTypes(n);\n if (n.length !== crypto_scalarmult_SCALARBYTES) throw new Error('bad n size');\n var q = new Uint8Array(crypto_scalarmult_BYTES);\n crypto_scalarmult_base(q, n);\n return q;\n};\n\nnacl.scalarMult.scalarLength = crypto_scalarmult_SCALARBYTES;\nnacl.scalarMult.groupElementLength = crypto_scalarmult_BYTES;\n\nnacl.box = function(msg, nonce, publicKey, secretKey) {\n var k = nacl.box.before(publicKey, secretKey);\n return nacl.secretbox(msg, nonce, k);\n};\n\nnacl.box.before = function(publicKey, secretKey) {\n checkArrayTypes(publicKey, secretKey);\n checkBoxLengths(publicKey, secretKey);\n var k = new Uint8Array(crypto_box_BEFORENMBYTES);\n crypto_box_beforenm(k, publicKey, secretKey);\n return k;\n};\n\nnacl.box.after = nacl.secretbox;\n\nnacl.box.open = function(msg, nonce, publicKey, secretKey) {\n var k = nacl.box.before(publicKey, secretKey);\n return nacl.secretbox.open(msg, nonce, k);\n};\n\nnacl.box.open.after = nacl.secretbox.open;\n\nnacl.box.keyPair = function() {\n var pk = new Uint8Array(crypto_box_PUBLICKEYBYTES);\n var sk = new Uint8Array(crypto_box_SECRETKEYBYTES);\n crypto_box_keypair(pk, sk);\n return {publicKey: pk, secretKey: sk};\n};\n\nnacl.box.keyPair.fromSecretKey = function(secretKey) {\n checkArrayTypes(secretKey);\n if (secretKey.length !== crypto_box_SECRETKEYBYTES)\n throw new Error('bad secret key size');\n var pk = new Uint8Array(crypto_box_PUBLICKEYBYTES);\n crypto_scalarmult_base(pk, secretKey);\n return {publicKey: pk, secretKey: new Uint8Array(secretKey)};\n};\n\nnacl.box.publicKeyLength = crypto_box_PUBLICKEYBYTES;\nnacl.box.secretKeyLength = crypto_box_SECRETKEYBYTES;\nnacl.box.sharedKeyLength = crypto_box_BEFORENMBYTES;\nnacl.box.nonceLength = crypto_box_NONCEBYTES;\nnacl.box.overheadLength = nacl.secretbox.overheadLength;\n\nnacl.sign = function(msg, secretKey) {\n checkArrayTypes(msg, secretKey);\n if (secretKey.length !== crypto_sign_SECRETKEYBYTES)\n throw new Error('bad secret key size');\n var signedMsg = new Uint8Array(crypto_sign_BYTES+msg.length);\n crypto_sign(signedMsg, msg, msg.length, secretKey);\n return signedMsg;\n};\n\nnacl.sign.open = function(signedMsg, publicKey) {\n checkArrayTypes(signedMsg, publicKey);\n if (publicKey.length !== crypto_sign_PUBLICKEYBYTES)\n throw new Error('bad public key size');\n var tmp = new Uint8Array(signedMsg.length);\n var mlen = crypto_sign_open(tmp, signedMsg, signedMsg.length, publicKey);\n if (mlen < 0) return null;\n var m = new Uint8Array(mlen);\n for (var i = 0; i < m.length; i++) m[i] = tmp[i];\n return m;\n};\n\nnacl.sign.detached = function(msg, secretKey) {\n var signedMsg = nacl.sign(msg, secretKey);\n var sig = new Uint8Array(crypto_sign_BYTES);\n for (var i = 0; i < sig.length; i++) sig[i] = signedMsg[i];\n return sig;\n};\n\nnacl.sign.detached.verify = function(msg, sig, publicKey) {\n checkArrayTypes(msg, sig, publicKey);\n if (sig.length !== crypto_sign_BYTES)\n throw new Error('bad signature size');\n if (publicKey.length !== crypto_sign_PUBLICKEYBYTES)\n throw new Error('bad public key size');\n var sm = new Uint8Array(crypto_sign_BYTES + msg.length);\n var m = new Uint8Array(crypto_sign_BYTES + msg.length);\n var i;\n for (i = 0; i < crypto_sign_BYTES; i++) sm[i] = sig[i];\n for (i = 0; i < msg.length; i++) sm[i+crypto_sign_BYTES] = msg[i];\n return (crypto_sign_open(m, sm, sm.length, publicKey) >= 0);\n};\n\nnacl.sign.keyPair = function() {\n var pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);\n var sk = new Uint8Array(crypto_sign_SECRETKEYBYTES);\n crypto_sign_keypair(pk, sk);\n return {publicKey: pk, secretKey: sk};\n};\n\nnacl.sign.keyPair.fromSecretKey = function(secretKey) {\n checkArrayTypes(secretKey);\n if (secretKey.length !== crypto_sign_SECRETKEYBYTES)\n throw new Error('bad secret key size');\n var pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);\n for (var i = 0; i < pk.length; i++) pk[i] = secretKey[32+i];\n return {publicKey: pk, secretKey: new Uint8Array(secretKey)};\n};\n\nnacl.sign.keyPair.fromSeed = function(seed) {\n checkArrayTypes(seed);\n if (seed.length !== crypto_sign_SEEDBYTES)\n throw new Error('bad seed size');\n var pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);\n var sk = new Uint8Array(crypto_sign_SECRETKEYBYTES);\n for (var i = 0; i < 32; i++) sk[i] = seed[i];\n crypto_sign_keypair(pk, sk, true);\n return {publicKey: pk, secretKey: sk};\n};\n\nnacl.sign.publicKeyLength = crypto_sign_PUBLICKEYBYTES;\nnacl.sign.secretKeyLength = crypto_sign_SECRETKEYBYTES;\nnacl.sign.seedLength = crypto_sign_SEEDBYTES;\nnacl.sign.signatureLength = crypto_sign_BYTES;\n\nnacl.hash = function(msg) {\n checkArrayTypes(msg);\n var h = new Uint8Array(crypto_hash_BYTES);\n crypto_hash(h, msg, msg.length);\n return h;\n};\n\nnacl.hash.hashLength = crypto_hash_BYTES;\n\nnacl.verify = function(x, y) {\n checkArrayTypes(x, y);\n // Zero length arguments are considered not equal.\n if (x.length === 0 || y.length === 0) return false;\n if (x.length !== y.length) return false;\n return (vn(x, 0, y, 0, x.length) === 0) ? true : false;\n};\n\nnacl.setPRNG = function(fn) {\n randombytes = fn;\n};\n\n(function() {\n // Initialize PRNG if environment provides CSPRNG.\n // If not, methods calling randombytes will throw.\n var crypto = typeof self !== 'undefined' ? (self.crypto || self.msCrypto) : null;\n if (crypto && crypto.getRandomValues) {\n // Browsers.\n var QUOTA = 65536;\n nacl.setPRNG(function(x, n) {\n var i, v = new Uint8Array(n);\n for (i = 0; i < n; i += QUOTA) {\n crypto.getRandomValues(v.subarray(i, i + Math.min(n - i, QUOTA)));\n }\n for (i = 0; i < n; i++) x[i] = v[i];\n cleanup(v);\n });\n } else if (typeof require !== 'undefined') {\n // Node.js.\n crypto = require('crypto');\n if (crypto && crypto.randomBytes) {\n nacl.setPRNG(function(x, n) {\n var i, v = crypto.randomBytes(n);\n for (i = 0; i < n; i++) x[i] = v[i];\n cleanup(v);\n });\n }\n }\n})();\n\n})(typeof module !== 'undefined' && module.exports ? module.exports : (self.nacl = self.nacl || {}));\n","module.exports = require('./pusher-with-encryption').default;\n","module.exports = require(\"buffer\");","module.exports = require(\"events\");","'use strict';\n\n/**\n\nStreams in a WebSocket connection\n---------------------------------\n\nWe model a WebSocket as two duplex streams: one stream is for the wire protocol\nover an I/O socket, and the other is for incoming/outgoing messages.\n\n\n +----------+ +---------+ +----------+\n [1] write(chunk) -->| ~~~~~~~~ +----->| parse() +----->| ~~~~~~~~ +--> emit('data') [2]\n | | +----+----+ | |\n | | | | |\n | IO | | [5] | Messages |\n | | V | |\n | | +---------+ | |\n [4] emit('data') <--+ ~~~~~~~~ |<-----+ frame() |<-----+ ~~~~~~~~ |<-- write(chunk) [3]\n +----------+ +---------+ +----------+\n\n\nMessage transfer in each direction is simple: IO receives a byte stream [1] and\nsends this stream for parsing. The parser will periodically emit a complete\nmessage text on the Messages stream [2]. Similarly, when messages are written\nto the Messages stream [3], they are framed using the WebSocket wire format and\nemitted via IO [4].\n\nThere is a feedback loop via [5] since some input from [1] will be things like\nping, pong and close frames. In these cases the protocol responds by emitting\nresponses directly back to [4] rather than emitting messages via [2].\n\nFor the purposes of flow control, we consider the sources of each Readable\nstream to be as follows:\n\n* [2] receives input from [1]\n* [4] receives input from [1] and [3]\n\nThe classes below express the relationships described above without prescribing\nanything about how parse() and frame() work, other than assuming they emit\n'data' events to the IO and Messages streams. They will work with any protocol\ndriver having these two methods.\n**/\n\n\nvar Stream = require('stream').Stream,\n util = require('util');\n\n\nvar IO = function(driver) {\n this.readable = this.writable = true;\n this._paused = false;\n this._driver = driver;\n};\nutil.inherits(IO, Stream);\n\n// The IO pause() and resume() methods will be called when the socket we are\n// piping to gets backed up and drains. Since IO output [4] comes from IO input\n// [1] and Messages input [3], we need to tell both of those to return false\n// from write() when this stream is paused.\n\nIO.prototype.pause = function() {\n this._paused = true;\n this._driver.messages._paused = true;\n};\n\nIO.prototype.resume = function() {\n this._paused = false;\n this.emit('drain');\n\n var messages = this._driver.messages;\n messages._paused = false;\n messages.emit('drain');\n};\n\n// When we receive input from a socket, send it to the parser and tell the\n// source whether to back off.\nIO.prototype.write = function(chunk) {\n if (!this.writable) return false;\n this._driver.parse(chunk);\n return !this._paused;\n};\n\n// The IO end() method will be called when the socket piping into it emits\n// 'close' or 'end', i.e. the socket is closed. In this situation the Messages\n// stream will not emit any more data so we emit 'end'.\nIO.prototype.end = function(chunk) {\n if (!this.writable) return;\n if (chunk !== undefined) this.write(chunk);\n this.writable = false;\n\n var messages = this._driver.messages;\n if (messages.readable) {\n messages.readable = messages.writable = false;\n messages.emit('end');\n }\n};\n\nIO.prototype.destroy = function() {\n this.end();\n};\n\n\nvar Messages = function(driver) {\n this.readable = this.writable = true;\n this._paused = false;\n this._driver = driver;\n};\nutil.inherits(Messages, Stream);\n\n// The Messages pause() and resume() methods will be called when the app that's\n// processing the messages gets backed up and drains. If we're emitting\n// messages too fast we should tell the source to slow down. Message output [2]\n// comes from IO input [1].\n\nMessages.prototype.pause = function() {\n this._driver.io._paused = true;\n};\n\nMessages.prototype.resume = function() {\n this._driver.io._paused = false;\n this._driver.io.emit('drain');\n};\n\n// When we receive messages from the user, send them to the formatter and tell\n// the source whether to back off.\nMessages.prototype.write = function(message) {\n if (!this.writable) return false;\n if (typeof message === 'string') this._driver.text(message);\n else this._driver.binary(message);\n return !this._paused;\n};\n\n// The Messages end() method will be called when a stream piping into it emits\n// 'end'. Many streams may be piped into the WebSocket and one of them ending\n// does not mean the whole socket is done, so just process the input and move\n// on leaving the socket open.\nMessages.prototype.end = function(message) {\n if (message !== undefined) this.write(message);\n};\n\nMessages.prototype.destroy = function() {};\n\n\nexports.IO = IO;\nexports.Messages = Messages;\n","'use strict';\n\nvar Buffer = require('safe-buffer').Buffer;\n\nvar StreamReader = function() {\n this._queue = [];\n this._queueSize = 0;\n this._offset = 0;\n};\n\nStreamReader.prototype.put = function(buffer) {\n if (!buffer || buffer.length === 0) return;\n if (!Buffer.isBuffer(buffer)) buffer = Buffer.from(buffer);\n this._queue.push(buffer);\n this._queueSize += buffer.length;\n};\n\nStreamReader.prototype.read = function(length) {\n if (length > this._queueSize) return null;\n if (length === 0) return Buffer.alloc(0);\n\n this._queueSize -= length;\n\n var queue = this._queue,\n remain = length,\n first = queue[0],\n buffers, buffer;\n\n if (first.length >= length) {\n if (first.length === length) {\n return queue.shift();\n } else {\n buffer = first.slice(0, length);\n queue[0] = first.slice(length);\n return buffer;\n }\n }\n\n for (var i = 0, n = queue.length; i < n; i++) {\n if (remain < queue[i].length) break;\n remain -= queue[i].length;\n }\n buffers = queue.splice(0, i);\n\n if (remain > 0 && queue.length > 0) {\n buffers.push(queue[0].slice(0, remain));\n queue[0] = queue[0].slice(remain);\n }\n return Buffer.concat(buffers, length);\n};\n\nStreamReader.prototype.eachByte = function(callback, context) {\n var buffer, n, index;\n\n while (this._queue.length > 0) {\n buffer = this._queue[0];\n n = buffer.length;\n\n while (this._offset < n) {\n index = this._offset;\n this._offset += 1;\n callback.call(context, buffer[index]);\n }\n this._offset = 0;\n this._queue.shift();\n }\n};\n\nmodule.exports = StreamReader;\n","'use strict';\n\nvar Buffer = require('safe-buffer').Buffer,\n crypto = require('crypto'),\n url = require('url'),\n util = require('util'),\n HttpParser = require('../http_parser'),\n Base = require('./base'),\n Hybi = require('./hybi'),\n Proxy = require('./proxy');\n\nvar Client = function(_url, options) {\n this.version = 'hybi-' + Hybi.VERSION;\n Hybi.call(this, null, _url, options);\n\n this.readyState = -1;\n this._key = Client.generateKey();\n this._accept = Hybi.generateAccept(this._key);\n this._http = new HttpParser('response');\n\n var uri = url.parse(this.url),\n auth = uri.auth && Buffer.from(uri.auth, 'utf8').toString('base64');\n\n if (this.VALID_PROTOCOLS.indexOf(uri.protocol) < 0)\n throw new Error(this.url + ' is not a valid WebSocket URL');\n\n this._pathname = (uri.pathname || '/') + (uri.search || '');\n\n this._headers.set('Host', uri.host);\n this._headers.set('Upgrade', 'websocket');\n this._headers.set('Connection', 'Upgrade');\n this._headers.set('Sec-WebSocket-Key', this._key);\n this._headers.set('Sec-WebSocket-Version', Hybi.VERSION);\n\n if (this._protocols.length > 0)\n this._headers.set('Sec-WebSocket-Protocol', this._protocols.join(', '));\n\n if (auth)\n this._headers.set('Authorization', 'Basic ' + auth);\n};\nutil.inherits(Client, Hybi);\n\nClient.generateKey = function() {\n return crypto.randomBytes(16).toString('base64');\n};\n\nvar instance = {\n VALID_PROTOCOLS: ['ws:', 'wss:'],\n\n proxy: function(origin, options) {\n return new Proxy(this, origin, options);\n },\n\n start: function() {\n if (this.readyState !== -1) return false;\n this._write(this._handshakeRequest());\n this.readyState = 0;\n return true;\n },\n\n parse: function(chunk) {\n if (this.readyState === 3) return;\n if (this.readyState > 0) return Hybi.prototype.parse.call(this, chunk);\n\n this._http.parse(chunk);\n if (!this._http.isComplete()) return;\n\n this._validateHandshake();\n if (this.readyState === 3) return;\n\n this._open();\n this.parse(this._http.body);\n },\n\n _handshakeRequest: function() {\n var extensions = this._extensions.generateOffer();\n if (extensions)\n this._headers.set('Sec-WebSocket-Extensions', extensions);\n\n var start = 'GET ' + this._pathname + ' HTTP/1.1',\n headers = [start, this._headers.toString(), ''];\n\n return Buffer.from(headers.join('\\r\\n'), 'utf8');\n },\n\n _failHandshake: function(message) {\n message = 'Error during WebSocket handshake: ' + message;\n this.readyState = 3;\n this.emit('error', new Error(message));\n this.emit('close', new Base.CloseEvent(this.ERRORS.protocol_error, message));\n },\n\n _validateHandshake: function() {\n this.statusCode = this._http.statusCode;\n this.headers = this._http.headers;\n\n if (this._http.error)\n return this._failHandshake(this._http.error.message);\n\n if (this._http.statusCode !== 101)\n return this._failHandshake('Unexpected response code: ' + this._http.statusCode);\n\n var headers = this._http.headers,\n upgrade = headers['upgrade'] || '',\n connection = headers['connection'] || '',\n accept = headers['sec-websocket-accept'] || '',\n protocol = headers['sec-websocket-protocol'] || '';\n\n if (upgrade === '')\n return this._failHandshake(\"'Upgrade' header is missing\");\n if (upgrade.toLowerCase() !== 'websocket')\n return this._failHandshake(\"'Upgrade' header value is not 'WebSocket'\");\n\n if (connection === '')\n return this._failHandshake(\"'Connection' header is missing\");\n if (connection.toLowerCase() !== 'upgrade')\n return this._failHandshake(\"'Connection' header value is not 'Upgrade'\");\n\n if (accept !== this._accept)\n return this._failHandshake('Sec-WebSocket-Accept mismatch');\n\n this.protocol = null;\n\n if (protocol !== '') {\n if (this._protocols.indexOf(protocol) < 0)\n return this._failHandshake('Sec-WebSocket-Protocol mismatch');\n else\n this.protocol = protocol;\n }\n\n try {\n this._extensions.activate(this.headers['sec-websocket-extensions']);\n } catch (e) {\n return this._failHandshake(e.message);\n }\n }\n};\n\nfor (var key in instance)\n Client.prototype[key] = instance[key];\n\nmodule.exports = Client;\n","/*jshint node:true */\n\nvar assert = require('assert');\n\nexports.HTTPParser = HTTPParser;\nfunction HTTPParser(type) {\n assert.ok(type === HTTPParser.REQUEST || type === HTTPParser.RESPONSE || type === undefined);\n if (type === undefined) {\n // Node v12+\n } else {\n this.initialize(type);\n }\n this.maxHeaderSize=HTTPParser.maxHeaderSize\n}\nHTTPParser.prototype.initialize = function (type, async_resource) {\n assert.ok(type === HTTPParser.REQUEST || type === HTTPParser.RESPONSE);\n this.type = type;\n this.state = type + '_LINE';\n this.info = {\n headers: [],\n upgrade: false\n };\n this.trailers = [];\n this.line = '';\n this.isChunked = false;\n this.connection = '';\n this.headerSize = 0; // for preventing too big headers\n this.body_bytes = null;\n this.isUserCall = false;\n this.hadError = false;\n};\n\nHTTPParser.encoding = 'ascii';\nHTTPParser.maxHeaderSize = 80 * 1024; // maxHeaderSize (in bytes) is configurable, but 80kb by default;\nHTTPParser.REQUEST = 'REQUEST';\nHTTPParser.RESPONSE = 'RESPONSE';\n\n// Note: *not* starting with kOnHeaders=0 line the Node parser, because any\n// newly added constants (kOnTimeout in Node v12.19.0) will overwrite 0!\nvar kOnHeaders = HTTPParser.kOnHeaders = 1;\nvar kOnHeadersComplete = HTTPParser.kOnHeadersComplete = 2;\nvar kOnBody = HTTPParser.kOnBody = 3;\nvar kOnMessageComplete = HTTPParser.kOnMessageComplete = 4;\n\n// Some handler stubs, needed for compatibility\nHTTPParser.prototype[kOnHeaders] =\nHTTPParser.prototype[kOnHeadersComplete] =\nHTTPParser.prototype[kOnBody] =\nHTTPParser.prototype[kOnMessageComplete] = function () {};\n\nvar compatMode0_12 = true;\nObject.defineProperty(HTTPParser, 'kOnExecute', {\n get: function () {\n // hack for backward compatibility\n compatMode0_12 = false;\n return 99;\n }\n });\n\nvar methods = exports.methods = HTTPParser.methods = [\n 'DELETE',\n 'GET',\n 'HEAD',\n 'POST',\n 'PUT',\n 'CONNECT',\n 'OPTIONS',\n 'TRACE',\n 'COPY',\n 'LOCK',\n 'MKCOL',\n 'MOVE',\n 'PROPFIND',\n 'PROPPATCH',\n 'SEARCH',\n 'UNLOCK',\n 'BIND',\n 'REBIND',\n 'UNBIND',\n 'ACL',\n 'REPORT',\n 'MKACTIVITY',\n 'CHECKOUT',\n 'MERGE',\n 'M-SEARCH',\n 'NOTIFY',\n 'SUBSCRIBE',\n 'UNSUBSCRIBE',\n 'PATCH',\n 'PURGE',\n 'MKCALENDAR',\n 'LINK',\n 'UNLINK',\n 'SOURCE',\n];\nvar method_connect = methods.indexOf('CONNECT');\nHTTPParser.prototype.reinitialize = HTTPParser;\nHTTPParser.prototype.close =\nHTTPParser.prototype.pause =\nHTTPParser.prototype.resume =\nHTTPParser.prototype.free = function () {};\nHTTPParser.prototype._compatMode0_11 = false;\nHTTPParser.prototype.getAsyncId = function() { return 0; };\n\nvar headerState = {\n REQUEST_LINE: true,\n RESPONSE_LINE: true,\n HEADER: true\n};\nHTTPParser.prototype.execute = function (chunk, start, length) {\n if (!(this instanceof HTTPParser)) {\n throw new TypeError('not a HTTPParser');\n }\n\n // backward compat to node < 0.11.4\n // Note: the start and length params were removed in newer version\n start = start || 0;\n length = typeof length === 'number' ? length : chunk.length;\n\n this.chunk = chunk;\n this.offset = start;\n var end = this.end = start + length;\n try {\n while (this.offset < end) {\n if (this[this.state]()) {\n break;\n }\n }\n } catch (err) {\n if (this.isUserCall) {\n throw err;\n }\n this.hadError = true;\n return err;\n }\n this.chunk = null;\n length = this.offset - start;\n if (headerState[this.state]) {\n this.headerSize += length;\n if (this.headerSize > (this.maxHeaderSize||HTTPParser.maxHeaderSize)) {\n return new Error('max header size exceeded');\n }\n }\n return length;\n};\n\nvar stateFinishAllowed = {\n REQUEST_LINE: true,\n RESPONSE_LINE: true,\n BODY_RAW: true\n};\nHTTPParser.prototype.finish = function () {\n if (this.hadError) {\n return;\n }\n if (!stateFinishAllowed[this.state]) {\n return new Error('invalid state for EOF');\n }\n if (this.state === 'BODY_RAW') {\n this.userCall()(this[kOnMessageComplete]());\n }\n};\n\n// These three methods are used for an internal speed optimization, and it also\n// works if theses are noops. Basically consume() asks us to read the bytes\n// ourselves, but if we don't do it we get them through execute().\nHTTPParser.prototype.consume =\nHTTPParser.prototype.unconsume =\nHTTPParser.prototype.getCurrentBuffer = function () {};\n\n//For correct error handling - see HTTPParser#execute\n//Usage: this.userCall()(userFunction('arg'));\nHTTPParser.prototype.userCall = function () {\n this.isUserCall = true;\n var self = this;\n return function (ret) {\n self.isUserCall = false;\n return ret;\n };\n};\n\nHTTPParser.prototype.nextRequest = function () {\n this.userCall()(this[kOnMessageComplete]());\n this.reinitialize(this.type);\n};\n\nHTTPParser.prototype.consumeLine = function () {\n var end = this.end,\n chunk = this.chunk;\n for (var i = this.offset; i < end; i++) {\n if (chunk[i] === 0x0a) { // \\n\n var line = this.line + chunk.toString(HTTPParser.encoding, this.offset, i);\n if (line.charAt(line.length - 1) === '\\r') {\n line = line.substr(0, line.length - 1);\n }\n this.line = '';\n this.offset = i + 1;\n return line;\n }\n }\n //line split over multiple chunks\n this.line += chunk.toString(HTTPParser.encoding, this.offset, this.end);\n this.offset = this.end;\n};\n\nvar headerExp = /^([^: \\t]+):[ \\t]*((?:.*[^ \\t])|)/;\nvar headerContinueExp = /^[ \\t]+(.*[^ \\t])/;\nHTTPParser.prototype.parseHeader = function (line, headers) {\n if (line.indexOf('\\r') !== -1) {\n throw parseErrorCode('HPE_LF_EXPECTED');\n }\n\n var match = headerExp.exec(line);\n var k = match && match[1];\n if (k) { // skip empty string (malformed header)\n headers.push(k);\n headers.push(match[2]);\n } else {\n var matchContinue = headerContinueExp.exec(line);\n if (matchContinue && headers.length) {\n if (headers[headers.length - 1]) {\n headers[headers.length - 1] += ' ';\n }\n headers[headers.length - 1] += matchContinue[1];\n }\n }\n};\n\nvar requestExp = /^([A-Z-]+) ([^ ]+) HTTP\\/(\\d)\\.(\\d)$/;\nHTTPParser.prototype.REQUEST_LINE = function () {\n var line = this.consumeLine();\n if (!line) {\n return;\n }\n var match = requestExp.exec(line);\n if (match === null) {\n throw parseErrorCode('HPE_INVALID_CONSTANT');\n }\n this.info.method = this._compatMode0_11 ? match[1] : methods.indexOf(match[1]);\n if (this.info.method === -1) {\n throw new Error('invalid request method');\n }\n this.info.url = match[2];\n this.info.versionMajor = +match[3];\n this.info.versionMinor = +match[4];\n this.body_bytes = 0;\n this.state = 'HEADER';\n};\n\nvar responseExp = /^HTTP\\/(\\d)\\.(\\d) (\\d{3}) ?(.*)$/;\nHTTPParser.prototype.RESPONSE_LINE = function () {\n var line = this.consumeLine();\n if (!line) {\n return;\n }\n var match = responseExp.exec(line);\n if (match === null) {\n throw parseErrorCode('HPE_INVALID_CONSTANT');\n }\n this.info.versionMajor = +match[1];\n this.info.versionMinor = +match[2];\n var statusCode = this.info.statusCode = +match[3];\n this.info.statusMessage = match[4];\n // Implied zero length.\n if ((statusCode / 100 | 0) === 1 || statusCode === 204 || statusCode === 304) {\n this.body_bytes = 0;\n }\n this.state = 'HEADER';\n};\n\nHTTPParser.prototype.shouldKeepAlive = function () {\n if (this.info.versionMajor > 0 && this.info.versionMinor > 0) {\n if (this.connection.indexOf('close') !== -1) {\n return false;\n }\n } else if (this.connection.indexOf('keep-alive') === -1) {\n return false;\n }\n if (this.body_bytes !== null || this.isChunked) { // || skipBody\n return true;\n }\n return false;\n};\n\nHTTPParser.prototype.HEADER = function () {\n var line = this.consumeLine();\n if (line === undefined) {\n return;\n }\n var info = this.info;\n if (line) {\n this.parseHeader(line, info.headers);\n } else {\n var headers = info.headers;\n var hasContentLength = false;\n var currentContentLengthValue;\n var hasUpgradeHeader = false;\n for (var i = 0; i < headers.length; i += 2) {\n switch (headers[i].toLowerCase()) {\n case 'transfer-encoding':\n this.isChunked = headers[i + 1].toLowerCase() === 'chunked';\n break;\n case 'content-length':\n currentContentLengthValue = +headers[i + 1];\n if (hasContentLength) {\n // Fix duplicate Content-Length header with same values.\n // Throw error only if values are different.\n // Known issues:\n // https://github.com/request/request/issues/2091#issuecomment-328715113\n // https://github.com/nodejs/node/issues/6517#issuecomment-216263771\n if (currentContentLengthValue !== this.body_bytes) {\n throw parseErrorCode('HPE_UNEXPECTED_CONTENT_LENGTH');\n }\n } else {\n hasContentLength = true;\n this.body_bytes = currentContentLengthValue;\n }\n break;\n case 'connection':\n this.connection += headers[i + 1].toLowerCase();\n break;\n case 'upgrade':\n hasUpgradeHeader = true;\n break;\n }\n }\n\n // if both isChunked and hasContentLength, isChunked wins\n // This is required so the body is parsed using the chunked method, and matches\n // Chrome's behavior. We could, maybe, ignore them both (would get chunked\n // encoding into the body), and/or disable shouldKeepAlive to be more\n // resilient.\n if (this.isChunked && hasContentLength) {\n hasContentLength = false;\n this.body_bytes = null;\n }\n\n // Logic from https://github.com/nodejs/http-parser/blob/921d5585515a153fa00e411cf144280c59b41f90/http_parser.c#L1727-L1737\n // \"For responses, \"Upgrade: foo\" and \"Connection: upgrade\" are\n // mandatory only when it is a 101 Switching Protocols response,\n // otherwise it is purely informational, to announce support.\n if (hasUpgradeHeader && this.connection.indexOf('upgrade') != -1) {\n info.upgrade = this.type === HTTPParser.REQUEST || info.statusCode === 101;\n } else {\n info.upgrade = info.method === method_connect;\n }\n\n if (this.isChunked && info.upgrade) {\n this.isChunked = false;\n }\n\n info.shouldKeepAlive = this.shouldKeepAlive();\n //problem which also exists in original node: we should know skipBody before calling onHeadersComplete\n var skipBody;\n if (compatMode0_12) {\n skipBody = this.userCall()(this[kOnHeadersComplete](info));\n } else {\n skipBody = this.userCall()(this[kOnHeadersComplete](info.versionMajor,\n info.versionMinor, info.headers, info.method, info.url, info.statusCode,\n info.statusMessage, info.upgrade, info.shouldKeepAlive));\n }\n if (skipBody === 2) {\n this.nextRequest();\n return true;\n } else if (this.isChunked && !skipBody) {\n this.state = 'BODY_CHUNKHEAD';\n } else if (skipBody || this.body_bytes === 0) {\n this.nextRequest();\n // For older versions of node (v6.x and older?), that return skipBody=1 or skipBody=true,\n // need this \"return true;\" if it's an upgrade request.\n return info.upgrade;\n } else if (this.body_bytes === null) {\n this.state = 'BODY_RAW';\n } else {\n this.state = 'BODY_SIZED';\n }\n }\n};\n\nHTTPParser.prototype.BODY_CHUNKHEAD = function () {\n var line = this.consumeLine();\n if (line === undefined) {\n return;\n }\n this.body_bytes = parseInt(line, 16);\n if (!this.body_bytes) {\n this.state = 'BODY_CHUNKTRAILERS';\n } else {\n this.state = 'BODY_CHUNK';\n }\n};\n\nHTTPParser.prototype.BODY_CHUNK = function () {\n var length = Math.min(this.end - this.offset, this.body_bytes);\n this.userCall()(this[kOnBody](this.chunk, this.offset, length));\n this.offset += length;\n this.body_bytes -= length;\n if (!this.body_bytes) {\n this.state = 'BODY_CHUNKEMPTYLINE';\n }\n};\n\nHTTPParser.prototype.BODY_CHUNKEMPTYLINE = function () {\n var line = this.consumeLine();\n if (line === undefined) {\n return;\n }\n assert.equal(line, '');\n this.state = 'BODY_CHUNKHEAD';\n};\n\nHTTPParser.prototype.BODY_CHUNKTRAILERS = function () {\n var line = this.consumeLine();\n if (line === undefined) {\n return;\n }\n if (line) {\n this.parseHeader(line, this.trailers);\n } else {\n if (this.trailers.length) {\n this.userCall()(this[kOnHeaders](this.trailers, ''));\n }\n this.nextRequest();\n }\n};\n\nHTTPParser.prototype.BODY_RAW = function () {\n var length = this.end - this.offset;\n this.userCall()(this[kOnBody](this.chunk, this.offset, length));\n this.offset = this.end;\n};\n\nHTTPParser.prototype.BODY_SIZED = function () {\n var length = Math.min(this.end - this.offset, this.body_bytes);\n this.userCall()(this[kOnBody](this.chunk, this.offset, length));\n this.offset += length;\n this.body_bytes -= length;\n if (!this.body_bytes) {\n this.nextRequest();\n }\n};\n\n// backward compat to node < 0.11.6\n['Headers', 'HeadersComplete', 'Body', 'MessageComplete'].forEach(function (name) {\n var k = HTTPParser['kOn' + name];\n Object.defineProperty(HTTPParser.prototype, 'on' + name, {\n get: function () {\n return this[k];\n },\n set: function (to) {\n // hack for backward compatibility\n this._compatMode0_11 = true;\n method_connect = 'CONNECT';\n return (this[k] = to);\n }\n });\n});\n\nfunction parseErrorCode(code) {\n var err = new Error('Parse Error');\n err.code = code;\n return err;\n}\n","module.exports = require(\"assert\");","'use strict';\n\nvar Parser = require('./parser'),\n Pipeline = require('./pipeline');\n\nvar Extensions = function() {\n this._rsv1 = this._rsv2 = this._rsv3 = null;\n\n this._byName = {};\n this._inOrder = [];\n this._sessions = [];\n this._index = {};\n};\n\nExtensions.MESSAGE_OPCODES = [1, 2];\n\nvar instance = {\n add: function(ext) {\n if (typeof ext.name !== 'string') throw new TypeError('extension.name must be a string');\n if (ext.type !== 'permessage') throw new TypeError('extension.type must be \"permessage\"');\n\n if (typeof ext.rsv1 !== 'boolean') throw new TypeError('extension.rsv1 must be true or false');\n if (typeof ext.rsv2 !== 'boolean') throw new TypeError('extension.rsv2 must be true or false');\n if (typeof ext.rsv3 !== 'boolean') throw new TypeError('extension.rsv3 must be true or false');\n\n if (this._byName.hasOwnProperty(ext.name))\n throw new TypeError('An extension with name \"' + ext.name + '\" is already registered');\n\n this._byName[ext.name] = ext;\n this._inOrder.push(ext);\n },\n\n generateOffer: function() {\n var sessions = [],\n offer = [],\n index = {};\n\n this._inOrder.forEach(function(ext) {\n var session = ext.createClientSession();\n if (!session) return;\n\n var record = [ext, session];\n sessions.push(record);\n index[ext.name] = record;\n\n var offers = session.generateOffer();\n offers = offers ? [].concat(offers) : [];\n\n offers.forEach(function(off) {\n offer.push(Parser.serializeParams(ext.name, off));\n }, this);\n }, this);\n\n this._sessions = sessions;\n this._index = index;\n\n return offer.length > 0 ? offer.join(', ') : null;\n },\n\n activate: function(header) {\n var responses = Parser.parseHeader(header),\n sessions = [];\n\n responses.eachOffer(function(name, params) {\n var record = this._index[name];\n\n if (!record)\n throw new Error('Server sent an extension response for unknown extension \"' + name + '\"');\n\n var ext = record[0],\n session = record[1],\n reserved = this._reserved(ext);\n\n if (reserved)\n throw new Error('Server sent two extension responses that use the RSV' +\n reserved[0] + ' bit: \"' +\n reserved[1] + '\" and \"' + ext.name + '\"');\n\n if (session.activate(params) !== true)\n throw new Error('Server sent unacceptable extension parameters: ' +\n Parser.serializeParams(name, params));\n\n this._reserve(ext);\n sessions.push(record);\n }, this);\n\n this._sessions = sessions;\n this._pipeline = new Pipeline(sessions);\n },\n\n generateResponse: function(header) {\n var sessions = [],\n response = [],\n offers = Parser.parseHeader(header);\n\n this._inOrder.forEach(function(ext) {\n var offer = offers.byName(ext.name);\n if (offer.length === 0 || this._reserved(ext)) return;\n\n var session = ext.createServerSession(offer);\n if (!session) return;\n\n this._reserve(ext);\n sessions.push([ext, session]);\n response.push(Parser.serializeParams(ext.name, session.generateResponse()));\n }, this);\n\n this._sessions = sessions;\n this._pipeline = new Pipeline(sessions);\n\n return response.length > 0 ? response.join(', ') : null;\n },\n\n validFrameRsv: function(frame) {\n var allowed = { rsv1: false, rsv2: false, rsv3: false },\n ext;\n\n if (Extensions.MESSAGE_OPCODES.indexOf(frame.opcode) >= 0) {\n for (var i = 0, n = this._sessions.length; i < n; i++) {\n ext = this._sessions[i][0];\n allowed.rsv1 = allowed.rsv1 || ext.rsv1;\n allowed.rsv2 = allowed.rsv2 || ext.rsv2;\n allowed.rsv3 = allowed.rsv3 || ext.rsv3;\n }\n }\n\n return (allowed.rsv1 || !frame.rsv1) &&\n (allowed.rsv2 || !frame.rsv2) &&\n (allowed.rsv3 || !frame.rsv3);\n },\n\n processIncomingMessage: function(message, callback, context) {\n this._pipeline.processIncomingMessage(message, callback, context);\n },\n\n processOutgoingMessage: function(message, callback, context) {\n this._pipeline.processOutgoingMessage(message, callback, context);\n },\n\n close: function(callback, context) {\n if (!this._pipeline) return callback.call(context);\n this._pipeline.close(callback, context);\n },\n\n _reserve: function(ext) {\n this._rsv1 = this._rsv1 || (ext.rsv1 && ext.name);\n this._rsv2 = this._rsv2 || (ext.rsv2 && ext.name);\n this._rsv3 = this._rsv3 || (ext.rsv3 && ext.name);\n },\n\n _reserved: function(ext) {\n if (this._rsv1 && ext.rsv1) return [1, this._rsv1];\n if (this._rsv2 && ext.rsv2) return [2, this._rsv2];\n if (this._rsv3 && ext.rsv3) return [3, this._rsv3];\n return false;\n }\n};\n\nfor (var key in instance)\n Extensions.prototype[key] = instance[key];\n\nmodule.exports = Extensions;\n","'use strict';\n\nvar TOKEN = /([!#\\$%&'\\*\\+\\-\\.\\^_`\\|~0-9A-Za-z]+)/,\n NOTOKEN = /([^!#\\$%&'\\*\\+\\-\\.\\^_`\\|~0-9A-Za-z])/g,\n QUOTED = /\"((?:\\\\[\\x00-\\x7f]|[^\\x00-\\x08\\x0a-\\x1f\\x7f\"\\\\])*)\"/,\n PARAM = new RegExp(TOKEN.source + '(?:=(?:' + TOKEN.source + '|' + QUOTED.source + '))?'),\n EXT = new RegExp(TOKEN.source + '(?: *; *' + PARAM.source + ')*', 'g'),\n EXT_LIST = new RegExp('^' + EXT.source + '(?: *, *' + EXT.source + ')*$'),\n NUMBER = /^-?(0|[1-9][0-9]*)(\\.[0-9]+)?$/;\n\nvar hasOwnProperty = Object.prototype.hasOwnProperty;\n\nvar Parser = {\n parseHeader: function(header) {\n var offers = new Offers();\n if (header === '' || header === undefined) return offers;\n\n if (!EXT_LIST.test(header))\n throw new SyntaxError('Invalid Sec-WebSocket-Extensions header: ' + header);\n\n var values = header.match(EXT);\n\n values.forEach(function(value) {\n var params = value.match(new RegExp(PARAM.source, 'g')),\n name = params.shift(),\n offer = {};\n\n params.forEach(function(param) {\n var args = param.match(PARAM), key = args[1], data;\n\n if (args[2] !== undefined) {\n data = args[2];\n } else if (args[3] !== undefined) {\n data = args[3].replace(/\\\\/g, '');\n } else {\n data = true;\n }\n if (NUMBER.test(data)) data = parseFloat(data);\n\n if (hasOwnProperty.call(offer, key)) {\n offer[key] = [].concat(offer[key]);\n offer[key].push(data);\n } else {\n offer[key] = data;\n }\n }, this);\n offers.push(name, offer);\n }, this);\n\n return offers;\n },\n\n serializeParams: function(name, params) {\n var values = [];\n\n var print = function(key, value) {\n if (value instanceof Array) {\n value.forEach(function(v) { print(key, v) });\n } else if (value === true) {\n values.push(key);\n } else if (typeof value === 'number') {\n values.push(key + '=' + value);\n } else if (NOTOKEN.test(value)) {\n values.push(key + '=\"' + value.replace(/\"/g, '\\\\\"') + '\"');\n } else {\n values.push(key + '=' + value);\n }\n };\n\n for (var key in params) print(key, params[key]);\n\n return [name].concat(values).join('; ');\n }\n};\n\nvar Offers = function() {\n this._byName = {};\n this._inOrder = [];\n};\n\nOffers.prototype.push = function(name, params) {\n if (!hasOwnProperty.call(this._byName, name))\n this._byName[name] = [];\n\n this._byName[name].push(params);\n this._inOrder.push({ name: name, params: params });\n};\n\nOffers.prototype.eachOffer = function(callback, context) {\n var list = this._inOrder;\n for (var i = 0, n = list.length; i < n; i++)\n callback.call(context, list[i].name, list[i].params);\n};\n\nOffers.prototype.byName = function(name) {\n return this._byName[name] || [];\n};\n\nOffers.prototype.toArray = function() {\n return this._inOrder.slice();\n};\n\nmodule.exports = Parser;\n","'use strict';\n\nvar Cell = require('./cell'),\n Pledge = require('./pledge');\n\nvar Pipeline = function(sessions) {\n this._cells = sessions.map(function(session) { return new Cell(session) });\n this._stopped = { incoming: false, outgoing: false };\n};\n\nPipeline.prototype.processIncomingMessage = function(message, callback, context) {\n if (this._stopped.incoming) return;\n this._loop('incoming', this._cells.length - 1, -1, -1, message, callback, context);\n};\n\nPipeline.prototype.processOutgoingMessage = function(message, callback, context) {\n if (this._stopped.outgoing) return;\n this._loop('outgoing', 0, this._cells.length, 1, message, callback, context);\n};\n\nPipeline.prototype.close = function(callback, context) {\n this._stopped = { incoming: true, outgoing: true };\n\n var closed = this._cells.map(function(a) { return a.close() });\n if (callback)\n Pledge.all(closed).then(function() { callback.call(context) });\n};\n\nPipeline.prototype._loop = function(direction, start, end, step, message, callback, context) {\n var cells = this._cells,\n n = cells.length,\n self = this;\n\n while (n--) cells[n].pending(direction);\n\n var pipe = function(index, error, msg) {\n if (index === end) return callback.call(context, error, msg);\n\n cells[index][direction](error, msg, function(err, m) {\n if (err) self._stopped[direction] = true;\n pipe(index + step, err, m);\n });\n };\n pipe(start, null, message);\n};\n\nmodule.exports = Pipeline;\n","'use strict';\n\nvar Functor = require('./functor'),\n Pledge = require('./pledge');\n\nvar Cell = function(tuple) {\n this._ext = tuple[0];\n this._session = tuple[1];\n\n this._functors = {\n incoming: new Functor(this._session, 'processIncomingMessage'),\n outgoing: new Functor(this._session, 'processOutgoingMessage')\n };\n};\n\nCell.prototype.pending = function(direction) {\n var functor = this._functors[direction];\n if (!functor._stopped) functor.pending += 1;\n};\n\nCell.prototype.incoming = function(error, message, callback, context) {\n this._exec('incoming', error, message, callback, context);\n};\n\nCell.prototype.outgoing = function(error, message, callback, context) {\n this._exec('outgoing', error, message, callback, context);\n};\n\nCell.prototype.close = function() {\n this._closed = this._closed || new Pledge();\n this._doClose();\n return this._closed;\n};\n\nCell.prototype._exec = function(direction, error, message, callback, context) {\n this._functors[direction].call(error, message, function(err, msg) {\n if (err) err.message = this._ext.name + ': ' + err.message;\n callback.call(context, err, msg);\n this._doClose();\n }, this);\n};\n\nCell.prototype._doClose = function() {\n var fin = this._functors.incoming,\n fout = this._functors.outgoing;\n\n if (!this._closed || fin.pending + fout.pending !== 0) return;\n if (this._session) this._session.close();\n this._session = null;\n this._closed.done();\n};\n\nmodule.exports = Cell;\n","'use strict';\n\nvar RingBuffer = require('./ring_buffer');\n\nvar Functor = function(session, method) {\n this._session = session;\n this._method = method;\n this._queue = new RingBuffer(Functor.QUEUE_SIZE);\n this._stopped = false;\n this.pending = 0;\n};\n\nFunctor.QUEUE_SIZE = 8;\n\nFunctor.prototype.call = function(error, message, callback, context) {\n if (this._stopped) return;\n\n var record = { error: error, message: message, callback: callback, context: context, done: false },\n called = false,\n self = this;\n\n this._queue.push(record);\n\n if (record.error) {\n record.done = true;\n this._stop();\n return this._flushQueue();\n }\n\n var handler = function(err, msg) {\n if (!(called ^ (called = true))) return;\n\n if (err) {\n self._stop();\n record.error = err;\n record.message = null;\n } else {\n record.message = msg;\n }\n\n record.done = true;\n self._flushQueue();\n };\n\n try {\n this._session[this._method](message, handler);\n } catch (err) {\n handler(err);\n }\n};\n\nFunctor.prototype._stop = function() {\n this.pending = this._queue.length;\n this._stopped = true;\n};\n\nFunctor.prototype._flushQueue = function() {\n var queue = this._queue, record;\n\n while (queue.length > 0 && queue.peek().done) {\n record = queue.shift();\n if (record.error) {\n this.pending = 0;\n queue.clear();\n } else {\n this.pending -= 1;\n }\n record.callback.call(record.context, record.error, record.message);\n }\n};\n\nmodule.exports = Functor;\n","'use strict';\n\nvar Frame = function() {};\n\nvar instance = {\n final: false,\n rsv1: false,\n rsv2: false,\n rsv3: false,\n opcode: null,\n masked: false,\n maskingKey: null,\n lengthBytes: 1,\n length: 0,\n payload: null\n};\n\nfor (var key in instance)\n Frame.prototype[key] = instance[key];\n\nmodule.exports = Frame;\n","'use strict';\n\nvar Buffer = require('safe-buffer').Buffer;\n\nvar Message = function() {\n this.rsv1 = false;\n this.rsv2 = false;\n this.rsv3 = false;\n this.opcode = null;\n this.length = 0;\n this._chunks = [];\n};\n\nvar instance = {\n read: function() {\n return this.data = this.data || Buffer.concat(this._chunks, this.length);\n },\n\n pushFrame: function(frame) {\n this.rsv1 = this.rsv1 || frame.rsv1;\n this.rsv2 = this.rsv2 || frame.rsv2;\n this.rsv3 = this.rsv3 || frame.rsv3;\n\n if (this.opcode === null) this.opcode = frame.opcode;\n\n this._chunks.push(frame.payload);\n this.length += frame.length;\n }\n};\n\nfor (var key in instance)\n Message.prototype[key] = instance[key];\n\nmodule.exports = Message;\n","'use strict';\n\nvar Buffer = require('safe-buffer').Buffer,\n Stream = require('stream').Stream,\n url = require('url'),\n util = require('util'),\n Base = require('./base'),\n Headers = require('./headers'),\n HttpParser = require('../http_parser');\n\nvar PORTS = { 'ws:': 80, 'wss:': 443 };\n\nvar Proxy = function(client, origin, options) {\n this._client = client;\n this._http = new HttpParser('response');\n this._origin = (typeof client.url === 'object') ? client.url : url.parse(client.url);\n this._url = (typeof origin === 'object') ? origin : url.parse(origin);\n this._options = options || {};\n this._state = 0;\n\n this.readable = this.writable = true;\n this._paused = false;\n\n this._headers = new Headers();\n this._headers.set('Host', this._origin.host);\n this._headers.set('Connection', 'keep-alive');\n this._headers.set('Proxy-Connection', 'keep-alive');\n\n var auth = this._url.auth && Buffer.from(this._url.auth, 'utf8').toString('base64');\n if (auth) this._headers.set('Proxy-Authorization', 'Basic ' + auth);\n};\nutil.inherits(Proxy, Stream);\n\nvar instance = {\n setHeader: function(name, value) {\n if (this._state !== 0) return false;\n this._headers.set(name, value);\n return true;\n },\n\n start: function() {\n if (this._state !== 0) return false;\n this._state = 1;\n\n var origin = this._origin,\n port = origin.port || PORTS[origin.protocol],\n start = 'CONNECT ' + origin.hostname + ':' + port + ' HTTP/1.1';\n\n var headers = [start, this._headers.toString(), ''];\n\n this.emit('data', Buffer.from(headers.join('\\r\\n'), 'utf8'));\n return true;\n },\n\n pause: function() {\n this._paused = true;\n },\n\n resume: function() {\n this._paused = false;\n this.emit('drain');\n },\n\n write: function(chunk) {\n if (!this.writable) return false;\n\n this._http.parse(chunk);\n if (!this._http.isComplete()) return !this._paused;\n\n this.statusCode = this._http.statusCode;\n this.headers = this._http.headers;\n\n if (this.statusCode === 200) {\n this.emit('connect', new Base.ConnectEvent());\n } else {\n var message = \"Can't establish a connection to the server at \" + this._origin.href;\n this.emit('error', new Error(message));\n }\n this.end();\n return !this._paused;\n },\n\n end: function(chunk) {\n if (!this.writable) return;\n if (chunk !== undefined) this.write(chunk);\n this.readable = this.writable = false;\n this.emit('close');\n this.emit('end');\n },\n\n destroy: function() {\n this.end();\n }\n};\n\nfor (var key in instance)\n Proxy.prototype[key] = instance[key];\n\nmodule.exports = Proxy;\n","'use strict';\n\nvar util = require('util'),\n HttpParser = require('../http_parser'),\n Base = require('./base'),\n Draft75 = require('./draft75'),\n Draft76 = require('./draft76'),\n Hybi = require('./hybi');\n\nvar Server = function(options) {\n Base.call(this, null, null, options);\n this._http = new HttpParser('request');\n};\nutil.inherits(Server, Base);\n\nvar instance = {\n EVENTS: ['open', 'message', 'error', 'close', 'ping', 'pong'],\n\n _bindEventListeners: function() {\n this.messages.on('error', function() {});\n this.on('error', function() {});\n },\n\n parse: function(chunk) {\n if (this._delegate) return this._delegate.parse(chunk);\n\n this._http.parse(chunk);\n if (!this._http.isComplete()) return;\n\n this.method = this._http.method;\n this.url = this._http.url;\n this.headers = this._http.headers;\n this.body = this._http.body;\n\n var self = this;\n this._delegate = Server.http(this, this._options);\n this._delegate.messages = this.messages;\n this._delegate.io = this.io;\n this._open();\n\n this.EVENTS.forEach(function(event) {\n this._delegate.on(event, function(e) { self.emit(event, e) });\n }, this);\n\n this.protocol = this._delegate.protocol;\n this.version = this._delegate.version;\n\n this.parse(this._http.body);\n this.emit('connect', new Base.ConnectEvent());\n },\n\n _open: function() {\n this.__queue.forEach(function(msg) {\n this._delegate[msg[0]].apply(this._delegate, msg[1]);\n }, this);\n this.__queue = [];\n }\n};\n\n['addExtension', 'setHeader', 'start', 'frame', 'text', 'binary', 'ping', 'close'].forEach(function(method) {\n instance[method] = function() {\n if (this._delegate) {\n return this._delegate[method].apply(this._delegate, arguments);\n } else {\n this.__queue.push([method, arguments]);\n return true;\n }\n };\n});\n\nfor (var key in instance)\n Server.prototype[key] = instance[key];\n\nServer.isSecureRequest = function(request) {\n if (request.connection && request.connection.authorized !== undefined) return true;\n if (request.socket && request.socket.secure) return true;\n\n var headers = request.headers;\n if (!headers) return false;\n if (headers['https'] === 'on') return true;\n if (headers['x-forwarded-ssl'] === 'on') return true;\n if (headers['x-forwarded-scheme'] === 'https') return true;\n if (headers['x-forwarded-proto'] === 'https') return true;\n\n return false;\n};\n\nServer.determineUrl = function(request) {\n var scheme = this.isSecureRequest(request) ? 'wss:' : 'ws:';\n return scheme + '//' + request.headers.host + request.url;\n};\n\nServer.http = function(request, options) {\n options = options || {};\n if (options.requireMasking === undefined) options.requireMasking = true;\n\n var headers = request.headers,\n version = headers['sec-websocket-version'],\n key = headers['sec-websocket-key'],\n key1 = headers['sec-websocket-key1'],\n key2 = headers['sec-websocket-key2'],\n url = this.determineUrl(request);\n\n if (version || key)\n return new Hybi(request, url, options);\n else if (key1 || key2)\n return new Draft76(request, url, options);\n else\n return new Draft75(request, url, options);\n};\n\nmodule.exports = Server;\n","'use strict';\n\nvar Buffer = require('safe-buffer').Buffer,\n Base = require('./base'),\n Draft75 = require('./draft75'),\n crypto = require('crypto'),\n util = require('util');\n\n\nvar numberFromKey = function(key) {\n return parseInt((key.match(/[0-9]/g) || []).join(''), 10);\n};\n\nvar spacesInKey = function(key) {\n return (key.match(/ /g) || []).length;\n};\n\n\nvar Draft76 = function(request, url, options) {\n Draft75.apply(this, arguments);\n this._stage = -1;\n this._body = [];\n this.version = 'hixie-76';\n\n this._headers.clear();\n\n this._headers.set('Upgrade', 'WebSocket');\n this._headers.set('Connection', 'Upgrade');\n this._headers.set('Sec-WebSocket-Origin', this._request.headers.origin);\n this._headers.set('Sec-WebSocket-Location', this.url);\n};\nutil.inherits(Draft76, Draft75);\n\nvar instance = {\n BODY_SIZE: 8,\n\n start: function() {\n if (!Draft75.prototype.start.call(this)) return false;\n this._started = true;\n this._sendHandshakeBody();\n return true;\n },\n\n close: function() {\n if (this.readyState === 3) return false;\n if (this.readyState === 1) this._write(Buffer.from([0xFF, 0x00]));\n this.readyState = 3;\n this.emit('close', new Base.CloseEvent(null, null));\n return true;\n },\n\n _handshakeResponse: function() {\n var headers = this._request.headers,\n key1 = headers['sec-websocket-key1'],\n key2 = headers['sec-websocket-key2'];\n\n if (!key1) throw new Error('Missing required header: Sec-WebSocket-Key1');\n if (!key2) throw new Error('Missing required header: Sec-WebSocket-Key2');\n\n var number1 = numberFromKey(key1),\n spaces1 = spacesInKey(key1),\n\n number2 = numberFromKey(key2),\n spaces2 = spacesInKey(key2);\n\n if (number1 % spaces1 !== 0 || number2 % spaces2 !== 0)\n throw new Error('Client sent invalid Sec-WebSocket-Key headers');\n\n this._keyValues = [number1 / spaces1, number2 / spaces2];\n\n var start = 'HTTP/1.1 101 WebSocket Protocol Handshake',\n headers = [start, this._headers.toString(), ''];\n\n return Buffer.from(headers.join('\\r\\n'), 'binary');\n },\n\n _handshakeSignature: function() {\n if (this._body.length < this.BODY_SIZE) return null;\n\n var md5 = crypto.createHash('md5'),\n buffer = Buffer.allocUnsafe(8 + this.BODY_SIZE);\n\n buffer.writeUInt32BE(this._keyValues[0], 0);\n buffer.writeUInt32BE(this._keyValues[1], 4);\n Buffer.from(this._body).copy(buffer, 8, 0, this.BODY_SIZE);\n\n md5.update(buffer);\n return Buffer.from(md5.digest('binary'), 'binary');\n },\n\n _sendHandshakeBody: function() {\n if (!this._started) return;\n var signature = this._handshakeSignature();\n if (!signature) return;\n\n this._write(signature);\n this._stage = 0;\n this._open();\n\n if (this._body.length > this.BODY_SIZE)\n this.parse(this._body.slice(this.BODY_SIZE));\n },\n\n _parseLeadingByte: function(octet) {\n if (octet !== 0xFF)\n return Draft75.prototype._parseLeadingByte.call(this, octet);\n\n this._closing = true;\n this._length = 0;\n this._stage = 1;\n }\n};\n\nfor (var key in instance)\n Draft76.prototype[key] = instance[key];\n\nmodule.exports = Draft76;\n","'use strict';\n\nvar util = require('util'),\n net = require('net'),\n tls = require('tls'),\n url = require('url'),\n driver = require('websocket-driver'),\n API = require('./api'),\n Event = require('./api/event');\n\nvar DEFAULT_PORTS = {'http:': 80, 'https:': 443, 'ws:':80, 'wss:': 443},\n SECURE_PROTOCOLS = ['https:', 'wss:'];\n\nvar Client = function(_url, protocols, options) {\n options = options || {};\n\n this.url = _url;\n this._driver = driver.client(this.url, {maxLength: options.maxLength, protocols: protocols});\n\n ['open', 'error'].forEach(function(event) {\n this._driver.on(event, function() {\n self.headers = self._driver.headers;\n self.statusCode = self._driver.statusCode;\n });\n }, this);\n\n var proxy = options.proxy || {},\n endpoint = url.parse(proxy.origin || this.url),\n port = endpoint.port || DEFAULT_PORTS[endpoint.protocol],\n secure = SECURE_PROTOCOLS.indexOf(endpoint.protocol) >= 0,\n onConnect = function() { self._onConnect() },\n netOptions = options.net || {},\n originTLS = options.tls || {},\n socketTLS = proxy.origin ? (proxy.tls || {}) : originTLS,\n self = this;\n\n netOptions.host = socketTLS.host = endpoint.hostname;\n netOptions.port = socketTLS.port = port;\n\n originTLS.ca = originTLS.ca || options.ca;\n socketTLS.servername = socketTLS.servername || endpoint.hostname;\n\n this._stream = secure\n ? tls.connect(socketTLS, onConnect)\n : net.connect(netOptions, onConnect);\n\n if (proxy.origin) this._configureProxy(proxy, originTLS);\n\n API.call(this, options);\n};\nutil.inherits(Client, API);\n\nClient.prototype._onConnect = function() {\n var worker = this._proxy || this._driver;\n worker.start();\n};\n\nClient.prototype._configureProxy = function(proxy, originTLS) {\n var uri = url.parse(this.url),\n secure = SECURE_PROTOCOLS.indexOf(uri.protocol) >= 0,\n self = this,\n name;\n\n this._proxy = this._driver.proxy(proxy.origin);\n\n if (proxy.headers) {\n for (name in proxy.headers) this._proxy.setHeader(name, proxy.headers[name]);\n }\n\n this._proxy.pipe(this._stream, {end: false});\n this._stream.pipe(this._proxy);\n\n this._proxy.on('connect', function() {\n if (secure) {\n var options = {socket: self._stream, servername: uri.hostname};\n for (name in originTLS) options[name] = originTLS[name];\n self._stream = tls.connect(options);\n self._configureStream();\n }\n self._driver.io.pipe(self._stream);\n self._stream.pipe(self._driver.io);\n self._driver.start();\n });\n\n this._proxy.on('error', function(error) {\n self._driver.emit('error', error);\n });\n};\n\nmodule.exports = Client;\n","module.exports = require(\"net\");","module.exports = require(\"tls\");","'use strict';\n\nvar Stream = require('stream').Stream,\n util = require('util'),\n driver = require('websocket-driver'),\n Headers = require('websocket-driver/lib/websocket/driver/headers'),\n API = require('./websocket/api'),\n EventTarget = require('./websocket/api/event_target'),\n Event = require('./websocket/api/event');\n\nvar EventSource = function(request, response, options) {\n this.writable = true;\n options = options || {};\n\n this._stream = response.socket;\n this._ping = options.ping || this.DEFAULT_PING;\n this._retry = options.retry || this.DEFAULT_RETRY;\n\n var scheme = driver.isSecureRequest(request) ? 'https:' : 'http:';\n this.url = scheme + '//' + request.headers.host + request.url;\n this.lastEventId = request.headers['last-event-id'] || '';\n this.readyState = API.CONNECTING;\n\n var headers = new Headers(),\n self = this;\n\n if (options.headers) {\n for (var key in options.headers) headers.set(key, options.headers[key]);\n }\n\n if (!this._stream || !this._stream.writable) return;\n process.nextTick(function() { self._open() });\n\n this._stream.setTimeout(0);\n this._stream.setNoDelay(true);\n\n var handshake = 'HTTP/1.1 200 OK\\r\\n' +\n 'Content-Type: text/event-stream\\r\\n' +\n 'Cache-Control: no-cache, no-store\\r\\n' +\n 'Connection: close\\r\\n' +\n headers.toString() +\n '\\r\\n' +\n 'retry: ' + Math.floor(this._retry * 1000) + '\\r\\n\\r\\n';\n\n this._write(handshake);\n\n this._stream.on('drain', function() { self.emit('drain') });\n\n if (this._ping)\n this._pingTimer = setInterval(function() { self.ping() }, this._ping * 1000);\n\n ['error', 'end'].forEach(function(event) {\n self._stream.on(event, function() { self.close() });\n });\n};\nutil.inherits(EventSource, Stream);\n\nEventSource.isEventSource = function(request) {\n if (request.method !== 'GET') return false;\n var accept = (request.headers.accept || '').split(/\\s*,\\s*/);\n return accept.indexOf('text/event-stream') >= 0;\n};\n\nvar instance = {\n DEFAULT_PING: 10,\n DEFAULT_RETRY: 5,\n\n _write: function(chunk) {\n if (!this.writable) return false;\n try {\n return this._stream.write(chunk, 'utf8');\n } catch (e) {\n return false;\n }\n },\n\n _open: function() {\n if (this.readyState !== API.CONNECTING) return;\n\n this.readyState = API.OPEN;\n\n var event = new Event('open');\n event.initEvent('open', false, false);\n this.dispatchEvent(event);\n },\n\n write: function(message) {\n return this.send(message);\n },\n\n end: function(message) {\n if (message !== undefined) this.write(message);\n this.close();\n },\n\n send: function(message, options) {\n if (this.readyState > API.OPEN) return false;\n\n message = String(message).replace(/(\\r\\n|\\r|\\n)/g, '$1data: ');\n options = options || {};\n\n var frame = '';\n if (options.event) frame += 'event: ' + options.event + '\\r\\n';\n if (options.id) frame += 'id: ' + options.id + '\\r\\n';\n frame += 'data: ' + message + '\\r\\n\\r\\n';\n\n return this._write(frame);\n },\n\n ping: function() {\n return this._write(':\\r\\n\\r\\n');\n },\n\n close: function() {\n if (this.readyState > API.OPEN) return false;\n\n this.readyState = API.CLOSED;\n this.writable = false;\n if (this._pingTimer) clearInterval(this._pingTimer);\n if (this._stream) this._stream.end();\n\n var event = new Event('close');\n event.initEvent('close', false, false);\n this.dispatchEvent(event);\n\n return true;\n }\n};\n\nfor (var method in instance) EventSource.prototype[method] = instance[method];\nfor (var key in EventTarget) EventSource.prototype[key] = EventTarget[key];\n\nmodule.exports = EventSource;\n","module.exports = require(\"child_process\");","module.exports = require(\"fs\");","module.exports = require(\"http\");","module.exports = require(\"https\");","export default function encode(s: any): string {\n return btoa(utob(s));\n}\n\nvar fromCharCode = String.fromCharCode;\n\nvar b64chars =\n 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';\nvar b64tab = {};\n\nfor (var i = 0, l = b64chars.length; i < l; i++) {\n b64tab[b64chars.charAt(i)] = i;\n}\n\nvar cb_utob = function(c) {\n var cc = c.charCodeAt(0);\n return cc < 0x80\n ? c\n : cc < 0x800\n ? fromCharCode(0xc0 | (cc >>> 6)) + fromCharCode(0x80 | (cc & 0x3f))\n : fromCharCode(0xe0 | ((cc >>> 12) & 0x0f)) +\n fromCharCode(0x80 | ((cc >>> 6) & 0x3f)) +\n fromCharCode(0x80 | (cc & 0x3f));\n};\n\nvar utob = function(u) {\n return u.replace(/[^\\x00-\\x7F]/g, cb_utob);\n};\n\nvar cb_encode = function(ccc) {\n var padlen = [0, 2, 1][ccc.length % 3];\n var ord =\n (ccc.charCodeAt(0) << 16) |\n ((ccc.length > 1 ? ccc.charCodeAt(1) : 0) << 8) |\n (ccc.length > 2 ? ccc.charCodeAt(2) : 0);\n var chars = [\n b64chars.charAt(ord >>> 18),\n b64chars.charAt((ord >>> 12) & 63),\n padlen >= 2 ? '=' : b64chars.charAt((ord >>> 6) & 63),\n padlen >= 1 ? '=' : b64chars.charAt(ord & 63)\n ];\n return chars.join('');\n};\n\nvar btoa =\n global.btoa ||\n function(b) {\n return b.replace(/[\\s\\S]{1,3}/g, cb_encode);\n };\n","import TimedCallback from './timed_callback';\nimport { Delay, Scheduler, Canceller } from './scheduling';\n\nabstract class Timer {\n protected clear: Canceller;\n protected timer: number | void;\n\n constructor(\n set: Scheduler,\n clear: Canceller,\n delay: Delay,\n callback: TimedCallback\n ) {\n this.clear = clear;\n this.timer = set(() => {\n if (this.timer) {\n this.timer = callback(this.timer);\n }\n }, delay);\n }\n\n /** Returns whether the timer is still running.\n *\n * @return {Boolean}\n */\n isRunning(): boolean {\n return this.timer !== null;\n }\n\n /** Aborts a timer when it's running. */\n ensureAborted() {\n if (this.timer) {\n this.clear(this.timer);\n this.timer = null;\n }\n }\n}\n\nexport default Timer;\n","import Timer from './abstract_timer';\nimport TimedCallback from './timed_callback';\nimport { Delay } from './scheduling';\n\n// We need to bind clear functions this way to avoid exceptions on IE8\nfunction clearTimeout(timer) {\n global.clearTimeout(timer);\n}\nfunction clearInterval(timer) {\n global.clearInterval(timer);\n}\n\n/** Cross-browser compatible one-off timer abstraction.\n *\n * @param {Number} delay\n * @param {Function} callback\n */\nexport class OneOffTimer extends Timer {\n constructor(delay: Delay, callback: TimedCallback) {\n super(setTimeout, clearTimeout, delay, function(timer) {\n callback();\n return null;\n });\n }\n}\n\n/** Cross-browser compatible periodic timer abstraction.\n *\n * @param {Number} delay\n * @param {Function} callback\n */\nexport class PeriodicTimer extends Timer {\n constructor(delay: Delay, callback: TimedCallback) {\n super(setInterval, clearInterval, delay, function(timer) {\n callback();\n return timer;\n });\n }\n}\n","import * as Collections from './utils/collections';\nimport TimedCallback from './utils/timers/timed_callback';\nimport { OneOffTimer, PeriodicTimer } from './utils/timers';\n\nvar Util = {\n now(): number {\n if (Date.now) {\n return Date.now();\n } else {\n return new Date().valueOf();\n }\n },\n\n defer(callback: TimedCallback): OneOffTimer {\n return new OneOffTimer(0, callback);\n },\n\n /** Builds a function that will proxy a method call to its first argument.\n *\n * Allows partial application of arguments, so additional arguments are\n * prepended to the argument list.\n *\n * @param {String} name method name\n * @return {Function} proxy function\n */\n method(name: string, ...args: any[]): Function {\n var boundArguments = Array.prototype.slice.call(arguments, 1);\n return function(object) {\n return object[name].apply(object, boundArguments.concat(arguments));\n };\n }\n};\n\nexport default Util;\n","import base64encode from '../base64';\nimport Util from '../util';\n\n/** Merges multiple objects into the target argument.\n *\n * For properties that are plain Objects, performs a deep-merge. For the\n * rest it just copies the value of the property.\n *\n * To extend prototypes use it as following:\n * Pusher.Util.extend(Target.prototype, Base.prototype)\n *\n * You can also use it to merge objects without altering them:\n * Pusher.Util.extend({}, object1, object2)\n *\n * @param {Object} target\n * @return {Object} the target argument\n */\nexport function extend(target: any, ...sources: any[]): T {\n for (var i = 0; i < sources.length; i++) {\n var extensions = sources[i];\n for (var property in extensions) {\n if (\n extensions[property] &&\n extensions[property].constructor &&\n extensions[property].constructor === Object\n ) {\n target[property] = extend(target[property] || {}, extensions[property]);\n } else {\n target[property] = extensions[property];\n }\n }\n }\n return target;\n}\n\nexport function stringify(): string {\n var m = ['Pusher'];\n for (var i = 0; i < arguments.length; i++) {\n if (typeof arguments[i] === 'string') {\n m.push(arguments[i]);\n } else {\n m.push(safeJSONStringify(arguments[i]));\n }\n }\n return m.join(' : ');\n}\n\nexport function arrayIndexOf(array: any[], item: any): number {\n // MSIE doesn't have array.indexOf\n var nativeIndexOf = Array.prototype.indexOf;\n if (array === null) {\n return -1;\n }\n if (nativeIndexOf && array.indexOf === nativeIndexOf) {\n return array.indexOf(item);\n }\n for (var i = 0, l = array.length; i < l; i++) {\n if (array[i] === item) {\n return i;\n }\n }\n return -1;\n}\n\n/** Applies a function f to all properties of an object.\n *\n * Function f gets 3 arguments passed:\n * - element from the object\n * - key of the element\n * - reference to the object\n *\n * @param {Object} object\n * @param {Function} f\n */\nexport function objectApply(object: any, f: Function) {\n for (var key in object) {\n if (Object.prototype.hasOwnProperty.call(object, key)) {\n f(object[key], key, object);\n }\n }\n}\n\n/** Return a list of objects own proerty keys\n *\n * @param {Object} object\n * @returns {Array}\n */\nexport function keys(object: any): string[] {\n var keys = [];\n objectApply(object, function(_, key) {\n keys.push(key);\n });\n return keys;\n}\n\n/** Return a list of object's own property values\n *\n * @param {Object} object\n * @returns {Array}\n */\nexport function values(object: any): any[] {\n var values = [];\n objectApply(object, function(value) {\n values.push(value);\n });\n return values;\n}\n\n/** Applies a function f to all elements of an array.\n *\n * Function f gets 3 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function apply(array: any[], f: Function, context?: any) {\n for (var i = 0; i < array.length; i++) {\n f.call(context || global, array[i], i, array);\n }\n}\n\n/** Maps all elements of the array and returns the result.\n *\n * Function f gets 4 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n * - reference to the destination array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function map(array: any[], f: Function): any[] {\n var result = [];\n for (var i = 0; i < array.length; i++) {\n result.push(f(array[i], i, array, result));\n }\n return result;\n}\n\n/** Maps all elements of the object and returns the result.\n *\n * Function f gets 4 arguments passed:\n * - element from the object\n * - key of the element\n * - reference to the source object\n * - reference to the destination object\n *\n * @param {Object} object\n * @param {Function} f\n */\nexport function mapObject(object: any, f: Function): any {\n var result = {};\n objectApply(object, function(value, key) {\n result[key] = f(value);\n });\n return result;\n}\n\n/** Filters elements of the array using a test function.\n *\n * Function test gets 4 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n * - reference to the destination array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function filter(array: any[], test: Function): any[] {\n test =\n test ||\n function(value) {\n return !!value;\n };\n\n var result = [];\n for (var i = 0; i < array.length; i++) {\n if (test(array[i], i, array, result)) {\n result.push(array[i]);\n }\n }\n return result;\n}\n\n/** Filters properties of the object using a test function.\n *\n * Function test gets 4 arguments passed:\n * - element from the object\n * - key of the element\n * - reference to the source object\n * - reference to the destination object\n *\n * @param {Object} object\n * @param {Function} f\n */\nexport function filterObject(object: Object, test: Function) {\n var result = {};\n objectApply(object, function(value, key) {\n if ((test && test(value, key, object, result)) || Boolean(value)) {\n result[key] = value;\n }\n });\n return result;\n}\n\n/** Flattens an object into a two-dimensional array.\n *\n * @param {Object} object\n * @return {Array} resulting array of [key, value] pairs\n */\nexport function flatten(object: Object): any[] {\n var result = [];\n objectApply(object, function(value, key) {\n result.push([key, value]);\n });\n return result;\n}\n\n/** Checks whether any element of the array passes the test.\n *\n * Function test gets 3 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function any(array: any[], test: Function): boolean {\n for (var i = 0; i < array.length; i++) {\n if (test(array[i], i, array)) {\n return true;\n }\n }\n return false;\n}\n\n/** Checks whether all elements of the array pass the test.\n *\n * Function test gets 3 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function all(array: any[], test: Function): boolean {\n for (var i = 0; i < array.length; i++) {\n if (!test(array[i], i, array)) {\n return false;\n }\n }\n return true;\n}\n\nexport function encodeParamsObject(data): string {\n return mapObject(data, function(value) {\n if (typeof value === 'object') {\n value = safeJSONStringify(value);\n }\n return encodeURIComponent(base64encode(value.toString()));\n });\n}\n\nexport function buildQueryString(data: any): string {\n var params = filterObject(data, function(value) {\n return value !== undefined;\n });\n\n var query = map(\n flatten(encodeParamsObject(params)),\n Util.method('join', '=')\n ).join('&');\n\n return query;\n}\n\n/**\n * See https://github.com/douglascrockford/JSON-js/blob/master/cycle.js\n *\n * Remove circular references from an object. Required for JSON.stringify in\n * React Native, which tends to blow up a lot.\n *\n * @param {any} object\n * @return {any} Decycled object\n */\nexport function decycleObject(object: any): any {\n var objects = [],\n paths = [];\n\n return (function derez(value, path) {\n var i, name, nu;\n\n switch (typeof value) {\n case 'object':\n if (!value) {\n return null;\n }\n for (i = 0; i < objects.length; i += 1) {\n if (objects[i] === value) {\n return { $ref: paths[i] };\n }\n }\n\n objects.push(value);\n paths.push(path);\n\n if (Object.prototype.toString.apply(value) === '[object Array]') {\n nu = [];\n for (i = 0; i < value.length; i += 1) {\n nu[i] = derez(value[i], path + '[' + i + ']');\n }\n } else {\n nu = {};\n for (name in value) {\n if (Object.prototype.hasOwnProperty.call(value, name)) {\n nu[name] = derez(\n value[name],\n path + '[' + JSON.stringify(name) + ']'\n );\n }\n }\n }\n return nu;\n case 'number':\n case 'string':\n case 'boolean':\n return value;\n }\n })(object, '$');\n}\n\n/**\n * Provides a cross-browser and cross-platform way to safely stringify objects\n * into JSON. This is particularly necessary for ReactNative, where circular JSON\n * structures throw an exception.\n *\n * @param {any} source The object to stringify\n * @return {string} The serialized output.\n */\nexport function safeJSONStringify(source: any): string {\n try {\n return JSON.stringify(source);\n } catch (e) {\n return JSON.stringify(decycleObject(source));\n }\n}\n","import {\n ChannelAuthorizationOptions,\n UserAuthenticationOptions\n} from './auth/options';\nimport { AuthTransport } from './config';\n\nexport interface DefaultConfig {\n VERSION: string;\n PROTOCOL: number;\n wsPort: number;\n wssPort: number;\n wsPath: string;\n httpHost: string;\n httpPort: number;\n httpsPort: number;\n httpPath: string;\n stats_host: string;\n authEndpoint: string;\n authTransport: AuthTransport;\n activityTimeout: number;\n pongTimeout: number;\n unavailableTimeout: number;\n userAuthentication: UserAuthenticationOptions;\n channelAuthorization: ChannelAuthorizationOptions;\n\n cdn_http?: string;\n cdn_https?: string;\n dependency_suffix?: string;\n}\n\nvar Defaults: DefaultConfig = {\n VERSION: VERSION,\n PROTOCOL: 7,\n\n wsPort: 80,\n wssPort: 443,\n wsPath: '',\n // DEPRECATED: SockJS fallback parameters\n httpHost: 'sockjs.pusher.com',\n httpPort: 80,\n httpsPort: 443,\n httpPath: '/pusher',\n // DEPRECATED: Stats\n stats_host: 'stats.pusher.com',\n // DEPRECATED: Other settings\n authEndpoint: '/pusher/auth',\n authTransport: 'ajax',\n activityTimeout: 120000,\n pongTimeout: 30000,\n unavailableTimeout: 10000,\n userAuthentication: {\n endpoint: '/pusher/user-auth',\n transport: 'ajax'\n },\n channelAuthorization: {\n endpoint: '/pusher/auth',\n transport: 'ajax'\n },\n\n // CDN configuration\n cdn_http: CDN_HTTP,\n cdn_https: CDN_HTTPS,\n dependency_suffix: DEPENDENCY_SUFFIX\n};\n\nexport default Defaults;\n","import Defaults from '../defaults';\nimport { default as URLScheme, URLSchemeParams } from './url_scheme';\n\nfunction getGenericURL(\n baseScheme: string,\n params: URLSchemeParams,\n path: string\n): string {\n var scheme = baseScheme + (params.useTLS ? 's' : '');\n var host = params.useTLS ? params.hostTLS : params.hostNonTLS;\n return scheme + '://' + host + path;\n}\n\nfunction getGenericPath(key: string, queryString?: string): string {\n var path = '/app/' + key;\n var query =\n '?protocol=' +\n Defaults.PROTOCOL +\n '&client=js' +\n '&version=' +\n Defaults.VERSION +\n (queryString ? '&' + queryString : '');\n return path + query;\n}\n\nexport var ws: URLScheme = {\n getInitial: function(key: string, params: URLSchemeParams): string {\n var path = (params.httpPath || '') + getGenericPath(key, 'flash=false');\n return getGenericURL('ws', params, path);\n }\n};\n\nexport var http: URLScheme = {\n getInitial: function(key: string, params: URLSchemeParams): string {\n var path = (params.httpPath || '/pusher') + getGenericPath(key);\n return getGenericURL('http', params, path);\n }\n};\n\nexport var sockjs: URLScheme = {\n getInitial: function(key: string, params: URLSchemeParams): string {\n return getGenericURL('http', params, params.httpPath || '/pusher');\n },\n getPath: function(key: string, params: URLSchemeParams): string {\n return getGenericPath(key);\n }\n};\n","import Callback from './callback';\nimport * as Collections from '../utils/collections';\nimport CallbackTable from './callback_table';\n\nexport default class CallbackRegistry {\n _callbacks: CallbackTable;\n\n constructor() {\n this._callbacks = {};\n }\n\n get(name: string): Callback[] {\n return this._callbacks[prefix(name)];\n }\n\n add(name: string, callback: Function, context: any) {\n var prefixedEventName = prefix(name);\n this._callbacks[prefixedEventName] =\n this._callbacks[prefixedEventName] || [];\n this._callbacks[prefixedEventName].push({\n fn: callback,\n context: context\n });\n }\n\n remove(name?: string, callback?: Function, context?: any) {\n if (!name && !callback && !context) {\n this._callbacks = {};\n return;\n }\n\n var names = name ? [prefix(name)] : Collections.keys(this._callbacks);\n\n if (callback || context) {\n this.removeCallback(names, callback, context);\n } else {\n this.removeAllCallbacks(names);\n }\n }\n\n private removeCallback(names: string[], callback: Function, context: any) {\n Collections.apply(\n names,\n function(name) {\n this._callbacks[name] = Collections.filter(\n this._callbacks[name] || [],\n function(binding) {\n return (\n (callback && callback !== binding.fn) ||\n (context && context !== binding.context)\n );\n }\n );\n if (this._callbacks[name].length === 0) {\n delete this._callbacks[name];\n }\n },\n this\n );\n }\n\n private removeAllCallbacks(names: string[]) {\n Collections.apply(\n names,\n function(name) {\n delete this._callbacks[name];\n },\n this\n );\n }\n}\n\nfunction prefix(name: string): string {\n return '_' + name;\n}\n","import * as Collections from '../utils/collections';\nimport Callback from './callback';\nimport Metadata from '../channels/metadata';\nimport CallbackRegistry from './callback_registry';\n\n/** Manages callback bindings and event emitting.\n *\n * @param Function failThrough called when no listeners are bound to an event\n */\nexport default class Dispatcher {\n callbacks: CallbackRegistry;\n global_callbacks: Function[];\n failThrough: Function;\n\n constructor(failThrough?: Function) {\n this.callbacks = new CallbackRegistry();\n this.global_callbacks = [];\n this.failThrough = failThrough;\n }\n\n bind(eventName: string, callback: Function, context?: any) {\n this.callbacks.add(eventName, callback, context);\n return this;\n }\n\n bind_global(callback: Function) {\n this.global_callbacks.push(callback);\n return this;\n }\n\n unbind(eventName?: string, callback?: Function, context?: any) {\n this.callbacks.remove(eventName, callback, context);\n return this;\n }\n\n unbind_global(callback?: Function) {\n if (!callback) {\n this.global_callbacks = [];\n return this;\n }\n\n this.global_callbacks = Collections.filter(\n this.global_callbacks || [],\n c => c !== callback\n );\n\n return this;\n }\n\n unbind_all() {\n this.unbind();\n this.unbind_global();\n return this;\n }\n\n emit(eventName: string, data?: any, metadata?: Metadata): Dispatcher {\n for (var i = 0; i < this.global_callbacks.length; i++) {\n this.global_callbacks[i](eventName, data);\n }\n\n var callbacks = this.callbacks.get(eventName);\n var args = [];\n\n if (metadata) {\n // if there's a metadata argument, we need to call the callback with both\n // data and metadata regardless of whether data is undefined\n args.push(data, metadata);\n } else if (data) {\n // metadata is undefined, so we only need to call the callback with data\n // if data exists\n args.push(data);\n }\n\n if (callbacks && callbacks.length > 0) {\n for (var i = 0; i < callbacks.length; i++) {\n callbacks[i].fn.apply(callbacks[i].context || global, args);\n }\n } else if (this.failThrough) {\n this.failThrough(eventName, data);\n }\n\n return this;\n }\n}\n","import { stringify } from './utils/collections';\nimport Pusher from './pusher';\n\nclass Logger {\n debug(...args: any[]) {\n this.log(this.globalLog, args);\n }\n\n warn(...args: any[]) {\n this.log(this.globalLogWarn, args);\n }\n\n error(...args: any[]) {\n this.log(this.globalLogError, args);\n }\n\n private globalLog = (message: string) => {\n if (global.console && global.console.log) {\n global.console.log(message);\n }\n };\n\n private globalLogWarn(message: string) {\n if (global.console && global.console.warn) {\n global.console.warn(message);\n } else {\n this.globalLog(message);\n }\n }\n\n private globalLogError(message: string) {\n if (global.console && global.console.error) {\n global.console.error(message);\n } else {\n this.globalLogWarn(message);\n }\n }\n\n private log(\n defaultLoggingFunction: (message: string) => void,\n ...args: any[]\n ) {\n var message = stringify.apply(this, arguments);\n if (Pusher.log) {\n Pusher.log(message);\n } else if (Pusher.logToConsole) {\n const log = defaultLoggingFunction.bind(this);\n log(message);\n }\n }\n}\n\nexport default new Logger();\n","import Util from '../util';\nimport * as Collections from '../utils/collections';\nimport { default as EventsDispatcher } from '../events/dispatcher';\nimport Logger from '../logger';\nimport TransportHooks from './transport_hooks';\nimport Socket from '../socket';\nimport Runtime from 'runtime';\nimport Timeline from '../timeline/timeline';\nimport TransportConnectionOptions from './transport_connection_options';\n\n/** Provides universal API for transport connections.\n *\n * Transport connection is a low-level object that wraps a connection method\n * and exposes a simple evented interface for the connection state and\n * messaging. It does not implement Pusher-specific WebSocket protocol.\n *\n * Additionally, it fetches resources needed for transport to work and exposes\n * an interface for querying transport features.\n *\n * States:\n * - new - initial state after constructing the object\n * - initializing - during initialization phase, usually fetching resources\n * - intialized - ready to establish a connection\n * - connection - when connection is being established\n * - open - when connection ready to be used\n * - closed - after connection was closed be either side\n *\n * Emits:\n * - error - after the connection raised an error\n *\n * Options:\n * - useTLS - whether connection should be over TLS\n * - hostTLS - host to connect to when connection is over TLS\n * - hostNonTLS - host to connect to when connection is over TLS\n *\n * @param {String} key application key\n * @param {Object} options\n */\nexport default class TransportConnection extends EventsDispatcher {\n hooks: TransportHooks;\n name: string;\n priority: number;\n key: string;\n options: TransportConnectionOptions;\n state: string;\n timeline: Timeline;\n activityTimeout: number;\n id: number;\n socket: Socket;\n beforeOpen: Function;\n initialize: Function;\n\n constructor(\n hooks: TransportHooks,\n name: string,\n priority: number,\n key: string,\n options: TransportConnectionOptions\n ) {\n super();\n this.initialize = Runtime.transportConnectionInitializer;\n this.hooks = hooks;\n this.name = name;\n this.priority = priority;\n this.key = key;\n this.options = options;\n\n this.state = 'new';\n this.timeline = options.timeline;\n this.activityTimeout = options.activityTimeout;\n this.id = this.timeline.generateUniqueID();\n }\n\n /** Checks whether the transport handles activity checks by itself.\n *\n * @return {Boolean}\n */\n handlesActivityChecks(): boolean {\n return Boolean(this.hooks.handlesActivityChecks);\n }\n\n /** Checks whether the transport supports the ping/pong API.\n *\n * @return {Boolean}\n */\n supportsPing(): boolean {\n return Boolean(this.hooks.supportsPing);\n }\n\n /** Tries to establish a connection.\n *\n * @returns {Boolean} false if transport is in invalid state\n */\n connect(): boolean {\n if (this.socket || this.state !== 'initialized') {\n return false;\n }\n\n var url = this.hooks.urls.getInitial(this.key, this.options);\n try {\n this.socket = this.hooks.getSocket(url, this.options);\n } catch (e) {\n Util.defer(() => {\n this.onError(e);\n this.changeState('closed');\n });\n return false;\n }\n\n this.bindListeners();\n\n Logger.debug('Connecting', { transport: this.name, url });\n this.changeState('connecting');\n return true;\n }\n\n /** Closes the connection.\n *\n * @return {Boolean} true if there was a connection to close\n */\n close(): boolean {\n if (this.socket) {\n this.socket.close();\n return true;\n } else {\n return false;\n }\n }\n\n /** Sends data over the open connection.\n *\n * @param {String} data\n * @return {Boolean} true only when in the \"open\" state\n */\n send(data: any): boolean {\n if (this.state === 'open') {\n // Workaround for MobileSafari bug (see https://gist.github.com/2052006)\n Util.defer(() => {\n if (this.socket) {\n this.socket.send(data);\n }\n });\n return true;\n } else {\n return false;\n }\n }\n\n /** Sends a ping if the connection is open and transport supports it. */\n ping() {\n if (this.state === 'open' && this.supportsPing()) {\n this.socket.ping();\n }\n }\n\n private onOpen() {\n if (this.hooks.beforeOpen) {\n this.hooks.beforeOpen(\n this.socket,\n this.hooks.urls.getPath(this.key, this.options)\n );\n }\n this.changeState('open');\n this.socket.onopen = undefined;\n }\n\n private onError(error) {\n this.emit('error', { type: 'WebSocketError', error: error });\n this.timeline.error(this.buildTimelineMessage({ error: error.toString() }));\n }\n\n private onClose(closeEvent?: any) {\n if (closeEvent) {\n this.changeState('closed', {\n code: closeEvent.code,\n reason: closeEvent.reason,\n wasClean: closeEvent.wasClean\n });\n } else {\n this.changeState('closed');\n }\n this.unbindListeners();\n this.socket = undefined;\n }\n\n private onMessage(message) {\n this.emit('message', message);\n }\n\n private onActivity() {\n this.emit('activity');\n }\n\n private bindListeners() {\n this.socket.onopen = () => {\n this.onOpen();\n };\n this.socket.onerror = error => {\n this.onError(error);\n };\n this.socket.onclose = closeEvent => {\n this.onClose(closeEvent);\n };\n this.socket.onmessage = message => {\n this.onMessage(message);\n };\n\n if (this.supportsPing()) {\n this.socket.onactivity = () => {\n this.onActivity();\n };\n }\n }\n\n private unbindListeners() {\n if (this.socket) {\n this.socket.onopen = undefined;\n this.socket.onerror = undefined;\n this.socket.onclose = undefined;\n this.socket.onmessage = undefined;\n if (this.supportsPing()) {\n this.socket.onactivity = undefined;\n }\n }\n }\n\n private changeState(state: string, params?: any) {\n this.state = state;\n this.timeline.info(\n this.buildTimelineMessage({\n state: state,\n params: params\n })\n );\n this.emit(state, params);\n }\n\n buildTimelineMessage(message): any {\n return Collections.extend({ cid: this.id }, message);\n }\n}\n","import Factory from '../utils/factory';\nimport TransportHooks from './transport_hooks';\nimport TransportConnection from './transport_connection';\nimport TransportConnectionOptions from './transport_connection_options';\n\n/** Provides interface for transport connection instantiation.\n *\n * Takes transport-specific hooks as the only argument, which allow checking\n * for transport support and creating its connections.\n *\n * Supported hooks: * - file - the name of the file to be fetched during initialization\n * - urls - URL scheme to be used by transport\n * - handlesActivityCheck - true when the transport handles activity checks\n * - supportsPing - true when the transport has a ping/activity API\n * - isSupported - tells whether the transport is supported in the environment\n * - getSocket - creates a WebSocket-compatible transport socket\n *\n * See transports.js for specific implementations.\n *\n * @param {Object} hooks object containing all needed transport hooks\n */\nexport default class Transport {\n hooks: TransportHooks;\n\n constructor(hooks: TransportHooks) {\n this.hooks = hooks;\n }\n\n /** Returns whether the transport is supported in the environment.\n *\n * @param {Object} envronment te environment details (encryption, settings)\n * @returns {Boolean} true when the transport is supported\n */\n isSupported(environment: any): boolean {\n return this.hooks.isSupported(environment);\n }\n\n /** Creates a transport connection.\n *\n * @param {String} name\n * @param {Number} priority\n * @param {String} key the application key\n * @param {Object} options\n * @returns {TransportConnection}\n */\n createConnection(\n name: string,\n priority: number,\n key: string,\n options: any\n ): TransportConnection {\n return new TransportConnection(this.hooks, name, priority, key, options);\n }\n}\n","import * as URLSchemes from 'core/transports/url_schemes';\nimport URLScheme from 'core/transports/url_scheme';\nimport Transport from 'core/transports/transport';\nimport Util from 'core/util';\nimport * as Collections from 'core/utils/collections';\nimport TransportHooks from 'core/transports/transport_hooks';\nimport TransportsTable from 'core/transports/transports_table';\nimport Runtime from 'runtime';\n\n/** WebSocket transport.\n *\n * Uses native WebSocket implementation, including MozWebSocket supported by\n * earlier Firefox versions.\n */\nvar WSTransport = new Transport({\n urls: URLSchemes.ws,\n handlesActivityChecks: false,\n supportsPing: false,\n\n isInitialized: function() {\n return Boolean(Runtime.getWebSocketAPI());\n },\n isSupported: function(): boolean {\n return Boolean(Runtime.getWebSocketAPI());\n },\n getSocket: function(url) {\n return Runtime.createWebSocket(url);\n }\n});\n\nvar httpConfiguration = {\n urls: URLSchemes.http,\n handlesActivityChecks: false,\n supportsPing: true,\n isInitialized: function() {\n return true;\n }\n};\n\nexport var streamingConfiguration = Collections.extend(\n {\n getSocket: function(url) {\n return Runtime.HTTPFactory.createStreamingSocket(url);\n }\n },\n httpConfiguration\n);\nexport var pollingConfiguration = Collections.extend(\n {\n getSocket: function(url) {\n return Runtime.HTTPFactory.createPollingSocket(url);\n }\n },\n httpConfiguration\n);\n\nvar xhrConfiguration = {\n isSupported: function(): boolean {\n return Runtime.isXHRSupported();\n }\n};\n\n/** HTTP streaming transport using CORS-enabled XMLHttpRequest. */\nvar XHRStreamingTransport = new Transport(\n (\n Collections.extend({}, streamingConfiguration, xhrConfiguration)\n )\n);\n\n/** HTTP long-polling transport using CORS-enabled XMLHttpRequest. */\nvar XHRPollingTransport = new Transport(\n Collections.extend({}, pollingConfiguration, xhrConfiguration)\n);\n\nvar Transports: TransportsTable = {\n ws: WSTransport,\n xhr_streaming: XHRStreamingTransport,\n xhr_polling: XHRPollingTransport\n};\n\nexport default Transports;\n","import Util from '../util';\nimport * as Collections from '../utils/collections';\nimport TransportManager from './transport_manager';\nimport TransportConnection from './transport_connection';\nimport Transport from './transport';\nimport PingDelayOptions from './ping_delay_options';\n\n/** Creates transport connections monitored by a transport manager.\n *\n * When a transport is closed, it might mean the environment does not support\n * it. It's possible that messages get stuck in an intermediate buffer or\n * proxies terminate inactive connections. To combat these problems,\n * assistants monitor the connection lifetime, report unclean exits and\n * adjust ping timeouts to keep the connection active. The decision to disable\n * a transport is the manager's responsibility.\n *\n * @param {TransportManager} manager\n * @param {TransportConnection} transport\n * @param {Object} options\n */\nexport default class AssistantToTheTransportManager {\n manager: TransportManager;\n transport: Transport;\n minPingDelay: number;\n maxPingDelay: number;\n pingDelay: number;\n\n constructor(\n manager: TransportManager,\n transport: Transport,\n options: PingDelayOptions\n ) {\n this.manager = manager;\n this.transport = transport;\n this.minPingDelay = options.minPingDelay;\n this.maxPingDelay = options.maxPingDelay;\n this.pingDelay = undefined;\n }\n\n /** Creates a transport connection.\n *\n * This function has the same API as Transport#createConnection.\n *\n * @param {String} name\n * @param {Number} priority\n * @param {String} key the application key\n * @param {Object} options\n * @returns {TransportConnection}\n */\n createConnection(\n name: string,\n priority: number,\n key: string,\n options: Object\n ): TransportConnection {\n options = Collections.extend({}, options, {\n activityTimeout: this.pingDelay\n });\n var connection = this.transport.createConnection(\n name,\n priority,\n key,\n options\n );\n\n var openTimestamp = null;\n\n var onOpen = function() {\n connection.unbind('open', onOpen);\n connection.bind('closed', onClosed);\n openTimestamp = Util.now();\n };\n var onClosed = closeEvent => {\n connection.unbind('closed', onClosed);\n\n if (closeEvent.code === 1002 || closeEvent.code === 1003) {\n // we don't want to use transports not obeying the protocol\n this.manager.reportDeath();\n } else if (!closeEvent.wasClean && openTimestamp) {\n // report deaths only for short-living transport\n var lifespan = Util.now() - openTimestamp;\n if (lifespan < 2 * this.maxPingDelay) {\n this.manager.reportDeath();\n this.pingDelay = Math.max(lifespan / 2, this.minPingDelay);\n }\n }\n };\n\n connection.bind('open', onOpen);\n return connection;\n }\n\n /** Returns whether the transport is supported in the environment.\n *\n * This function has the same API as Transport#isSupported. Might return false\n * when the manager decides to kill the transport.\n *\n * @param {Object} environment the environment details (encryption, settings)\n * @returns {Boolean} true when the transport is supported\n */\n isSupported(environment: string): boolean {\n return this.manager.isAlive() && this.transport.isSupported(environment);\n }\n}\n","import Action from './action';\nimport { PusherEvent } from './message-types';\n/**\n * Provides functions for handling Pusher protocol-specific messages.\n */\n\nconst Protocol = {\n /**\n * Decodes a message in a Pusher format.\n *\n * The MessageEvent we receive from the transport should contain a pusher event\n * (https://pusher.com/docs/pusher_protocol#events) serialized as JSON in the\n * data field\n *\n * The pusher event may contain a data field too, and it may also be\n * serialised as JSON\n *\n * Throws errors when messages are not parse'able.\n *\n * @param {MessageEvent} messageEvent\n * @return {PusherEvent}\n */\n decodeMessage: function(messageEvent: MessageEvent): PusherEvent {\n try {\n var messageData = JSON.parse(messageEvent.data);\n var pusherEventData = messageData.data;\n if (typeof pusherEventData === 'string') {\n try {\n pusherEventData = JSON.parse(messageData.data);\n } catch (e) {}\n }\n var pusherEvent: PusherEvent = {\n event: messageData.event,\n channel: messageData.channel,\n data: pusherEventData\n };\n if (messageData.user_id) {\n pusherEvent.user_id = messageData.user_id;\n }\n return pusherEvent;\n } catch (e) {\n throw { type: 'MessageParseError', error: e, data: messageEvent.data };\n }\n },\n\n /**\n * Encodes a message to be sent.\n *\n * @param {PusherEvent} event\n * @return {String}\n */\n encodeMessage: function(event: PusherEvent): string {\n return JSON.stringify(event);\n },\n\n /**\n * Processes a handshake message and returns appropriate actions.\n *\n * Returns an object with an 'action' and other action-specific properties.\n *\n * There are three outcomes when calling this function. First is a successful\n * connection attempt, when pusher:connection_established is received, which\n * results in a 'connected' action with an 'id' property. When passed a\n * pusher:error event, it returns a result with action appropriate to the\n * close code and an error. Otherwise, it raises an exception.\n *\n * @param {String} message\n * @result Object\n */\n processHandshake: function(messageEvent: MessageEvent): Action {\n var message = Protocol.decodeMessage(messageEvent);\n\n if (message.event === 'pusher:connection_established') {\n if (!message.data.activity_timeout) {\n throw 'No activity timeout specified in handshake';\n }\n return {\n action: 'connected',\n id: message.data.socket_id,\n activityTimeout: message.data.activity_timeout * 1000\n };\n } else if (message.event === 'pusher:error') {\n // From protocol 6 close codes are sent only once, so this only\n // happens when connection does not support close codes\n return {\n action: this.getCloseAction(message.data),\n error: this.getCloseError(message.data)\n };\n } else {\n throw 'Invalid handshake';\n }\n },\n\n /**\n * Dispatches the close event and returns an appropriate action name.\n *\n * See:\n * 1. https://developer.mozilla.org/en-US/docs/WebSockets/WebSockets_reference/CloseEvent\n * 2. http://pusher.com/docs/pusher_protocol\n *\n * @param {CloseEvent} closeEvent\n * @return {String} close action name\n */\n getCloseAction: function(closeEvent): string {\n if (closeEvent.code < 4000) {\n // ignore 1000 CLOSE_NORMAL, 1001 CLOSE_GOING_AWAY,\n // 1005 CLOSE_NO_STATUS, 1006 CLOSE_ABNORMAL\n // ignore 1007...3999\n // handle 1002 CLOSE_PROTOCOL_ERROR, 1003 CLOSE_UNSUPPORTED,\n // 1004 CLOSE_TOO_LARGE\n if (closeEvent.code >= 1002 && closeEvent.code <= 1004) {\n return 'backoff';\n } else {\n return null;\n }\n } else if (closeEvent.code === 4000) {\n return 'tls_only';\n } else if (closeEvent.code < 4100) {\n return 'refused';\n } else if (closeEvent.code < 4200) {\n return 'backoff';\n } else if (closeEvent.code < 4300) {\n return 'retry';\n } else {\n // unknown error\n return 'refused';\n }\n },\n\n /**\n * Returns an error or null basing on the close event.\n *\n * Null is returned when connection was closed cleanly. Otherwise, an object\n * with error details is returned.\n *\n * @param {CloseEvent} closeEvent\n * @return {Object} error object\n */\n getCloseError: function(closeEvent): any {\n if (closeEvent.code !== 1000 && closeEvent.code !== 1001) {\n return {\n type: 'PusherError',\n data: {\n code: closeEvent.code,\n message: closeEvent.reason || closeEvent.message\n }\n };\n } else {\n return null;\n }\n }\n};\n\nexport default Protocol;\n","import * as Collections from '../utils/collections';\nimport { default as EventsDispatcher } from '../events/dispatcher';\nimport Protocol from './protocol/protocol';\nimport { PusherEvent } from './protocol/message-types';\nimport Logger from '../logger';\nimport TransportConnection from '../transports/transport_connection';\nimport Socket from '../socket';\n/**\n * Provides Pusher protocol interface for transports.\n *\n * Emits following events:\n * - message - on received messages\n * - ping - on ping requests\n * - pong - on pong responses\n * - error - when the transport emits an error\n * - closed - after closing the transport\n *\n * It also emits more events when connection closes with a code.\n * See Protocol.getCloseAction to get more details.\n *\n * @param {Number} id\n * @param {AbstractTransport} transport\n */\nexport default class Connection extends EventsDispatcher implements Socket {\n id: string;\n transport: TransportConnection;\n activityTimeout: number;\n\n constructor(id: string, transport: TransportConnection) {\n super();\n this.id = id;\n this.transport = transport;\n this.activityTimeout = transport.activityTimeout;\n this.bindListeners();\n }\n\n /** Returns whether used transport handles activity checks by itself\n *\n * @returns {Boolean} true if activity checks are handled by the transport\n */\n handlesActivityChecks() {\n return this.transport.handlesActivityChecks();\n }\n\n /** Sends raw data.\n *\n * @param {String} data\n */\n send(data: any): boolean {\n return this.transport.send(data);\n }\n\n /** Sends an event.\n *\n * @param {String} name\n * @param {String} data\n * @param {String} [channel]\n * @returns {Boolean} whether message was sent or not\n */\n send_event(name: string, data: any, channel?: string): boolean {\n var event: PusherEvent = { event: name, data: data };\n if (channel) {\n event.channel = channel;\n }\n Logger.debug('Event sent', event);\n return this.send(Protocol.encodeMessage(event));\n }\n\n /** Sends a ping message to the server.\n *\n * Basing on the underlying transport, it might send either transport's\n * protocol-specific ping or pusher:ping event.\n */\n ping() {\n if (this.transport.supportsPing()) {\n this.transport.ping();\n } else {\n this.send_event('pusher:ping', {});\n }\n }\n\n /** Closes the connection. */\n close() {\n this.transport.close();\n }\n\n private bindListeners() {\n var listeners = {\n message: (messageEvent: MessageEvent) => {\n var pusherEvent;\n try {\n pusherEvent = Protocol.decodeMessage(messageEvent);\n } catch (e) {\n this.emit('error', {\n type: 'MessageParseError',\n error: e,\n data: messageEvent.data\n });\n }\n\n if (pusherEvent !== undefined) {\n Logger.debug('Event recd', pusherEvent);\n\n switch (pusherEvent.event) {\n case 'pusher:error':\n this.emit('error', {\n type: 'PusherError',\n data: pusherEvent.data\n });\n break;\n case 'pusher:ping':\n this.emit('ping');\n break;\n case 'pusher:pong':\n this.emit('pong');\n break;\n }\n this.emit('message', pusherEvent);\n }\n },\n activity: () => {\n this.emit('activity');\n },\n error: error => {\n this.emit('error', error);\n },\n closed: closeEvent => {\n unbindListeners();\n\n if (closeEvent && closeEvent.code) {\n this.handleCloseEvent(closeEvent);\n }\n\n this.transport = null;\n this.emit('closed');\n }\n };\n\n var unbindListeners = () => {\n Collections.objectApply(listeners, (listener, event) => {\n this.transport.unbind(event, listener);\n });\n };\n\n Collections.objectApply(listeners, (listener, event) => {\n this.transport.bind(event, listener);\n });\n }\n\n private handleCloseEvent(closeEvent: any) {\n var action = Protocol.getCloseAction(closeEvent);\n var error = Protocol.getCloseError(closeEvent);\n if (error) {\n this.emit('error', error);\n }\n if (action) {\n this.emit(action, { action: action, error: error });\n }\n }\n}\n","import Util from '../../util';\nimport * as Collections from '../../utils/collections';\nimport Protocol from '../protocol/protocol';\nimport Connection from '../connection';\nimport TransportConnection from '../../transports/transport_connection';\nimport HandshakePayload from './handshake_payload';\n\n/**\n * Handles Pusher protocol handshakes for transports.\n *\n * Calls back with a result object after handshake is completed. Results\n * always have two fields:\n * - action - string describing action to be taken after the handshake\n * - transport - the transport object passed to the constructor\n *\n * Different actions can set different additional properties on the result.\n * In the case of 'connected' action, there will be a 'connection' property\n * containing a Connection object for the transport. Other actions should\n * carry an 'error' property.\n *\n * @param {AbstractTransport} transport\n * @param {Function} callback\n */\nexport default class Handshake {\n transport: TransportConnection;\n callback: (HandshakePayload) => void;\n onMessage: Function;\n onClosed: Function;\n\n constructor(\n transport: TransportConnection,\n callback: (HandshakePayload) => void\n ) {\n this.transport = transport;\n this.callback = callback;\n this.bindListeners();\n }\n\n close() {\n this.unbindListeners();\n this.transport.close();\n }\n\n private bindListeners() {\n this.onMessage = m => {\n this.unbindListeners();\n\n var result;\n try {\n result = Protocol.processHandshake(m);\n } catch (e) {\n this.finish('error', { error: e });\n this.transport.close();\n return;\n }\n\n if (result.action === 'connected') {\n this.finish('connected', {\n connection: new Connection(result.id, this.transport),\n activityTimeout: result.activityTimeout\n });\n } else {\n this.finish(result.action, { error: result.error });\n this.transport.close();\n }\n };\n\n this.onClosed = closeEvent => {\n this.unbindListeners();\n\n var action = Protocol.getCloseAction(closeEvent) || 'backoff';\n var error = Protocol.getCloseError(closeEvent);\n this.finish(action, { error: error });\n };\n\n this.transport.bind('message', this.onMessage);\n this.transport.bind('closed', this.onClosed);\n }\n\n private unbindListeners() {\n this.transport.unbind('message', this.onMessage);\n this.transport.unbind('closed', this.onClosed);\n }\n\n private finish(action: string, params: any) {\n this.callback(\n Collections.extend({ transport: this.transport, action: action }, params)\n );\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport base64encode from '../base64';\nimport Timeline from './timeline';\nimport Runtime from 'runtime';\n\nexport interface TimelineSenderOptions {\n host?: string;\n port?: number;\n path?: string;\n}\n\nexport default class TimelineSender {\n timeline: Timeline;\n options: TimelineSenderOptions;\n host: string;\n\n constructor(timeline: Timeline, options: TimelineSenderOptions) {\n this.timeline = timeline;\n this.options = options || {};\n }\n\n send(useTLS: boolean, callback?: Function) {\n if (this.timeline.isEmpty()) {\n return;\n }\n\n this.timeline.send(\n Runtime.TimelineTransport.getAgent(this, useTLS),\n callback\n );\n }\n}\n","/** Error classes used throughout the library. */\n// https://github.com/Microsoft/TypeScript-wiki/blob/master/Breaking-Changes.md#extending-built-ins-like-error-array-and-map-may-no-longer-work\nexport class BadEventName extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\nexport class BadChannelName extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\nexport class RequestTimedOut extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class TransportPriorityTooLow extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class TransportClosed extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class UnsupportedFeature extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class UnsupportedTransport extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class UnsupportedStrategy extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class HTTPAuthError extends Error {\n status: number;\n constructor(status: number, msg?: string) {\n super(msg);\n this.status = status;\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n","/**\n * A place to store help URLs for error messages etc\n */\n\nconst urlStore = {\n baseUrl: 'https://pusher.com',\n urls: {\n authenticationEndpoint: {\n path: '/docs/channels/server_api/authenticating_users'\n },\n authorizationEndpoint: {\n path: '/docs/channels/server_api/authorizing-users/'\n },\n javascriptQuickStart: {\n path: '/docs/javascript_quick_start'\n },\n triggeringClientEvents: {\n path: '/docs/client_api_guide/client_events#trigger-events'\n },\n encryptedChannelSupport: {\n fullUrl:\n 'https://github.com/pusher/pusher-js/tree/cc491015371a4bde5743d1c87a0fbac0feb53195#encrypted-channel-support'\n }\n }\n};\n\n/** Builds a consistent string with links to pusher documentation\n *\n * @param {string} key - relevant key in the url_store.urls object\n * @return {string} suffix string to append to log message\n */\nconst buildLogSuffix = function(key: string): string {\n const urlPrefix = 'See:';\n const urlObj = urlStore.urls[key];\n if (!urlObj) return '';\n\n let url;\n if (urlObj.fullUrl) {\n url = urlObj.fullUrl;\n } else if (urlObj.path) {\n url = urlStore.baseUrl + urlObj.path;\n }\n\n if (!url) return '';\n return `${urlPrefix} ${url}`;\n};\n\nexport default { buildLogSuffix };\n","import { default as EventsDispatcher } from '../events/dispatcher';\nimport * as Errors from '../errors';\nimport Logger from '../logger';\nimport Pusher from '../pusher';\nimport { PusherEvent } from '../connection/protocol/message-types';\nimport Metadata from './metadata';\nimport UrlStore from '../utils/url_store';\nimport {\n ChannelAuthorizationData,\n ChannelAuthorizationCallback\n} from '../auth/options';\nimport { HTTPAuthError } from '../errors';\n\n/** Provides base public channel interface with an event emitter.\n *\n * Emits:\n * - pusher:subscription_succeeded - after subscribing successfully\n * - other non-internal events\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\nexport default class Channel extends EventsDispatcher {\n name: string;\n pusher: Pusher;\n subscribed: boolean;\n subscriptionPending: boolean;\n subscriptionCancelled: boolean;\n subscriptionCount: null;\n\n constructor(name: string, pusher: Pusher) {\n super(function(event, data) {\n Logger.debug('No callbacks on ' + name + ' for ' + event);\n });\n\n this.name = name;\n this.pusher = pusher;\n this.subscribed = false;\n this.subscriptionPending = false;\n this.subscriptionCancelled = false;\n }\n\n /** Skips authorization, since public channels don't require it.\n *\n * @param {Function} callback\n */\n authorize(socketId: string, callback: ChannelAuthorizationCallback) {\n return callback(null, { auth: '' });\n }\n\n /** Triggers an event */\n trigger(event: string, data: any) {\n if (event.indexOf('client-') !== 0) {\n throw new Errors.BadEventName(\n \"Event '\" + event + \"' does not start with 'client-'\"\n );\n }\n if (!this.subscribed) {\n var suffix = UrlStore.buildLogSuffix('triggeringClientEvents');\n Logger.warn(\n `Client event triggered before channel 'subscription_succeeded' event . ${suffix}`\n );\n }\n return this.pusher.send_event(event, data, this.name);\n }\n\n /** Signals disconnection to the channel. For internal use only. */\n disconnect() {\n this.subscribed = false;\n this.subscriptionPending = false;\n }\n\n /** Handles a PusherEvent. For internal use only.\n *\n * @param {PusherEvent} event\n */\n handleEvent(event: PusherEvent) {\n var eventName = event.event;\n var data = event.data;\n if (eventName === 'pusher_internal:subscription_succeeded') {\n this.handleSubscriptionSucceededEvent(event);\n } else if (eventName === 'pusher_internal:subscription_count') {\n this.handleSubscriptionCountEvent(event);\n } else if (eventName.indexOf('pusher_internal:') !== 0) {\n var metadata: Metadata = {};\n this.emit(eventName, data, metadata);\n }\n }\n\n handleSubscriptionSucceededEvent(event: PusherEvent) {\n this.subscriptionPending = false;\n this.subscribed = true;\n if (this.subscriptionCancelled) {\n this.pusher.unsubscribe(this.name);\n } else {\n this.emit('pusher:subscription_succeeded', event.data);\n }\n }\n\n handleSubscriptionCountEvent(event: PusherEvent) {\n if (event.data.subscription_count) {\n this.subscriptionCount = event.data.subscription_count;\n }\n\n this.emit('pusher:subscription_count', event.data);\n }\n\n /** Sends a subscription request. For internal use only. */\n subscribe() {\n if (this.subscribed) {\n return;\n }\n this.subscriptionPending = true;\n this.subscriptionCancelled = false;\n this.authorize(\n this.pusher.connection.socket_id,\n (error: Error | null, data: ChannelAuthorizationData) => {\n if (error) {\n this.subscriptionPending = false;\n // Why not bind to 'pusher:subscription_error' a level up, and log there?\n // Binding to this event would cause the warning about no callbacks being\n // bound (see constructor) to be suppressed, that's not what we want.\n Logger.error(error.toString());\n this.emit(\n 'pusher:subscription_error',\n Object.assign(\n {},\n {\n type: 'AuthError',\n error: error.message\n },\n error instanceof HTTPAuthError ? { status: error.status } : {}\n )\n );\n } else {\n this.pusher.send_event('pusher:subscribe', {\n auth: data.auth,\n channel_data: data.channel_data,\n channel: this.name\n });\n }\n }\n );\n }\n\n /** Sends an unsubscription request. For internal use only. */\n unsubscribe() {\n this.subscribed = false;\n this.pusher.send_event('pusher:unsubscribe', {\n channel: this.name\n });\n }\n\n /** Cancels an in progress subscription. For internal use only. */\n cancelSubscription() {\n this.subscriptionCancelled = true;\n }\n\n /** Reinstates an in progress subscripiton. For internal use only. */\n reinstateSubscription() {\n this.subscriptionCancelled = false;\n }\n}\n","import Factory from '../utils/factory';\nimport Channel from './channel';\nimport { ChannelAuthorizationCallback } from '../auth/options';\n\n/** Extends public channels to provide private channel interface.\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\nexport default class PrivateChannel extends Channel {\n /** Authorizes the connection to use the channel.\n *\n * @param {String} socketId\n * @param {Function} callback\n */\n authorize(socketId: string, callback: ChannelAuthorizationCallback) {\n return this.pusher.config.channelAuthorizer(\n {\n channelName: this.name,\n socketId: socketId\n },\n callback\n );\n }\n}\n","import * as Collections from '../utils/collections';\n\n/** Represents a collection of members of a presence channel. */\nexport default class Members {\n members: any;\n count: number;\n myID: any;\n me: any;\n\n constructor() {\n this.reset();\n }\n\n /** Returns member's info for given id.\n *\n * Resulting object containts two fields - id and info.\n *\n * @param {Number} id\n * @return {Object} member's info or null\n */\n get(id: string): any {\n if (Object.prototype.hasOwnProperty.call(this.members, id)) {\n return {\n id: id,\n info: this.members[id]\n };\n } else {\n return null;\n }\n }\n\n /** Calls back for each member in unspecified order.\n *\n * @param {Function} callback\n */\n each(callback: Function) {\n Collections.objectApply(this.members, (member, id) => {\n callback(this.get(id));\n });\n }\n\n /** Updates the id for connected member. For internal use only. */\n setMyID(id: string) {\n this.myID = id;\n }\n\n /** Handles subscription data. For internal use only. */\n onSubscription(subscriptionData: any) {\n this.members = subscriptionData.presence.hash;\n this.count = subscriptionData.presence.count;\n this.me = this.get(this.myID);\n }\n\n /** Adds a new member to the collection. For internal use only. */\n addMember(memberData: any) {\n if (this.get(memberData.user_id) === null) {\n this.count++;\n }\n this.members[memberData.user_id] = memberData.user_info;\n return this.get(memberData.user_id);\n }\n\n /** Adds a member from the collection. For internal use only. */\n removeMember(memberData: any) {\n var member = this.get(memberData.user_id);\n if (member) {\n delete this.members[memberData.user_id];\n this.count--;\n }\n return member;\n }\n\n /** Resets the collection to the initial state. For internal use only. */\n reset() {\n this.members = {};\n this.count = 0;\n this.myID = null;\n this.me = null;\n }\n}\n","import PrivateChannel from './private_channel';\nimport Logger from '../logger';\nimport Members from './members';\nimport Pusher from '../pusher';\nimport UrlStore from 'core/utils/url_store';\nimport { PusherEvent } from '../connection/protocol/message-types';\nimport Metadata from './metadata';\nimport { ChannelAuthorizationData } from '../auth/options';\n\nexport default class PresenceChannel extends PrivateChannel {\n members: Members;\n\n /** Adds presence channel functionality to private channels.\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\n constructor(name: string, pusher: Pusher) {\n super(name, pusher);\n this.members = new Members();\n }\n\n /** Authorizes the connection as a member of the channel.\n *\n * @param {String} socketId\n * @param {Function} callback\n */\n authorize(socketId: string, callback: Function) {\n super.authorize(socketId, async (error, authData) => {\n if (!error) {\n authData = authData as ChannelAuthorizationData;\n if (authData.channel_data != null) {\n var channelData = JSON.parse(authData.channel_data);\n this.members.setMyID(channelData.user_id);\n } else {\n await this.pusher.user.signinDonePromise;\n if (this.pusher.user.user_data != null) {\n // If the user is signed in, get the id of the authenticated user\n // and allow the presence authorization to continue.\n this.members.setMyID(this.pusher.user.user_data.id);\n } else {\n let suffix = UrlStore.buildLogSuffix('authorizationEndpoint');\n Logger.error(\n `Invalid auth response for channel '${this.name}', ` +\n `expected 'channel_data' field. ${suffix}, ` +\n `or the user should be signed in.`\n );\n callback('Invalid auth response');\n return;\n }\n }\n }\n callback(error, authData);\n });\n }\n\n /** Handles presence and subscription events. For internal use only.\n *\n * @param {PusherEvent} event\n */\n handleEvent(event: PusherEvent) {\n var eventName = event.event;\n if (eventName.indexOf('pusher_internal:') === 0) {\n this.handleInternalEvent(event);\n } else {\n var data = event.data;\n var metadata: Metadata = {};\n if (event.user_id) {\n metadata.user_id = event.user_id;\n }\n this.emit(eventName, data, metadata);\n }\n }\n handleInternalEvent(event: PusherEvent) {\n var eventName = event.event;\n var data = event.data;\n switch (eventName) {\n case 'pusher_internal:subscription_succeeded':\n this.handleSubscriptionSucceededEvent(event);\n break;\n case 'pusher_internal:subscription_count':\n this.handleSubscriptionCountEvent(event);\n break;\n case 'pusher_internal:member_added':\n var addedMember = this.members.addMember(data);\n this.emit('pusher:member_added', addedMember);\n break;\n case 'pusher_internal:member_removed':\n var removedMember = this.members.removeMember(data);\n if (removedMember) {\n this.emit('pusher:member_removed', removedMember);\n }\n break;\n }\n }\n\n handleSubscriptionSucceededEvent(event: PusherEvent) {\n this.subscriptionPending = false;\n this.subscribed = true;\n if (this.subscriptionCancelled) {\n this.pusher.unsubscribe(this.name);\n } else {\n this.members.onSubscription(event.data);\n this.emit('pusher:subscription_succeeded', this.members);\n }\n }\n\n /** Resets the channel state, including members map. For internal use only. */\n disconnect() {\n this.members.reset();\n super.disconnect();\n }\n}\n","import PrivateChannel from './private_channel';\nimport * as Errors from '../errors';\nimport Logger from '../logger';\nimport Pusher from '../pusher';\nimport { decode as encodeUTF8 } from '@stablelib/utf8';\nimport { decode as decodeBase64 } from '@stablelib/base64';\nimport Dispatcher from '../events/dispatcher';\nimport { PusherEvent } from '../connection/protocol/message-types';\nimport {\n ChannelAuthorizationData,\n ChannelAuthorizationCallback\n} from '../auth/options';\nimport * as nacl from 'tweetnacl';\n\n/** Extends private channels to provide encrypted channel interface.\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\nexport default class EncryptedChannel extends PrivateChannel {\n key: Uint8Array = null;\n nacl: nacl;\n\n constructor(name: string, pusher: Pusher, nacl: nacl) {\n super(name, pusher);\n this.nacl = nacl;\n }\n\n /** Authorizes the connection to use the channel.\n *\n * @param {String} socketId\n * @param {Function} callback\n */\n authorize(socketId: string, callback: ChannelAuthorizationCallback) {\n super.authorize(\n socketId,\n (error: Error | null, authData: ChannelAuthorizationData) => {\n if (error) {\n callback(error, authData);\n return;\n }\n let sharedSecret = authData['shared_secret'];\n if (!sharedSecret) {\n callback(\n new Error(\n `No shared_secret key in auth payload for encrypted channel: ${this.name}`\n ),\n null\n );\n return;\n }\n this.key = decodeBase64(sharedSecret);\n delete authData['shared_secret'];\n callback(null, authData);\n }\n );\n }\n\n trigger(event: string, data: any): boolean {\n throw new Errors.UnsupportedFeature(\n 'Client events are not currently supported for encrypted channels'\n );\n }\n\n /** Handles an event. For internal use only.\n *\n * @param {PusherEvent} event\n */\n handleEvent(event: PusherEvent) {\n var eventName = event.event;\n var data = event.data;\n if (\n eventName.indexOf('pusher_internal:') === 0 ||\n eventName.indexOf('pusher:') === 0\n ) {\n super.handleEvent(event);\n return;\n }\n this.handleEncryptedEvent(eventName, data);\n }\n\n private handleEncryptedEvent(event: string, data: any): void {\n if (!this.key) {\n Logger.debug(\n 'Received encrypted event before key has been retrieved from the authEndpoint'\n );\n return;\n }\n if (!data.ciphertext || !data.nonce) {\n Logger.error(\n 'Unexpected format for encrypted event, expected object with `ciphertext` and `nonce` fields, got: ' +\n data\n );\n return;\n }\n let cipherText = decodeBase64(data.ciphertext);\n if (cipherText.length < this.nacl.secretbox.overheadLength) {\n Logger.error(\n `Expected encrypted event ciphertext length to be ${this.nacl.secretbox.overheadLength}, got: ${cipherText.length}`\n );\n return;\n }\n let nonce = decodeBase64(data.nonce);\n if (nonce.length < this.nacl.secretbox.nonceLength) {\n Logger.error(\n `Expected encrypted event nonce length to be ${this.nacl.secretbox.nonceLength}, got: ${nonce.length}`\n );\n return;\n }\n\n let bytes = this.nacl.secretbox.open(cipherText, nonce, this.key);\n if (bytes === null) {\n Logger.debug(\n 'Failed to decrypt an event, probably because it was encrypted with a different key. Fetching a new key from the authEndpoint...'\n );\n // Try a single time to retrieve a new auth key and decrypt the event with it\n // If this fails, a new key will be requested when a new message is received\n this.authorize(this.pusher.connection.socket_id, (error, authData) => {\n if (error) {\n Logger.error(\n `Failed to make a request to the authEndpoint: ${authData}. Unable to fetch new key, so dropping encrypted event`\n );\n return;\n }\n bytes = this.nacl.secretbox.open(cipherText, nonce, this.key);\n if (bytes === null) {\n Logger.error(\n `Failed to decrypt event with new key. Dropping encrypted event`\n );\n return;\n }\n this.emit(event, this.getDataToEmit(bytes));\n return;\n });\n return;\n }\n this.emit(event, this.getDataToEmit(bytes));\n }\n\n // Try and parse the decrypted bytes as JSON. If we can't parse it, just\n // return the utf-8 string\n getDataToEmit(bytes: Uint8Array): string {\n let raw = encodeUTF8(bytes);\n try {\n return JSON.parse(raw);\n } catch {\n return raw;\n }\n }\n}\n","import { default as EventsDispatcher } from '../events/dispatcher';\nimport { OneOffTimer as Timer } from '../utils/timers';\nimport { Config } from '../config';\nimport Logger from '../logger';\nimport HandshakePayload from './handshake/handshake_payload';\nimport Connection from './connection';\nimport Strategy from '../strategies/strategy';\nimport StrategyRunner from '../strategies/strategy_runner';\nimport * as Collections from '../utils/collections';\nimport Timeline from '../timeline/timeline';\nimport ConnectionManagerOptions from './connection_manager_options';\nimport Runtime from 'runtime';\n\nimport {\n ErrorCallbacks,\n HandshakeCallbacks,\n ConnectionCallbacks\n} from './callbacks';\nimport Action from './protocol/action';\n\n/** Manages connection to Pusher.\n *\n * Uses a strategy (currently only default), timers and network availability\n * info to establish a connection and export its state. In case of failures,\n * manages reconnection attempts.\n *\n * Exports state changes as following events:\n * - \"state_change\", { previous: p, current: state }\n * - state\n *\n * States:\n * - initialized - initial state, never transitioned to\n * - connecting - connection is being established\n * - connected - connection has been fully established\n * - disconnected - on requested disconnection\n * - unavailable - after connection timeout or when there's no network\n * - failed - when the connection strategy is not supported\n *\n * Options:\n * - unavailableTimeout - time to transition to unavailable state\n * - activityTimeout - time after which ping message should be sent\n * - pongTimeout - time for Pusher to respond with pong before reconnecting\n *\n * @param {String} key application key\n * @param {Object} options\n */\nexport default class ConnectionManager extends EventsDispatcher {\n key: string;\n options: ConnectionManagerOptions;\n state: string;\n connection: Connection;\n usingTLS: boolean;\n timeline: Timeline;\n socket_id: string;\n unavailableTimer: Timer;\n activityTimer: Timer;\n retryTimer: Timer;\n activityTimeout: number;\n strategy: Strategy;\n runner: StrategyRunner;\n errorCallbacks: ErrorCallbacks;\n handshakeCallbacks: HandshakeCallbacks;\n connectionCallbacks: ConnectionCallbacks;\n\n constructor(key: string, options: ConnectionManagerOptions) {\n super();\n this.state = 'initialized';\n this.connection = null;\n\n this.key = key;\n this.options = options;\n this.timeline = this.options.timeline;\n this.usingTLS = this.options.useTLS;\n\n this.errorCallbacks = this.buildErrorCallbacks();\n this.connectionCallbacks = this.buildConnectionCallbacks(\n this.errorCallbacks\n );\n this.handshakeCallbacks = this.buildHandshakeCallbacks(this.errorCallbacks);\n\n var Network = Runtime.getNetwork();\n\n Network.bind('online', () => {\n this.timeline.info({ netinfo: 'online' });\n if (this.state === 'connecting' || this.state === 'unavailable') {\n this.retryIn(0);\n }\n });\n Network.bind('offline', () => {\n this.timeline.info({ netinfo: 'offline' });\n if (this.connection) {\n this.sendActivityCheck();\n }\n });\n\n this.updateStrategy();\n }\n\n switchCluster(key: string) {\n this.key = key;\n // This ensures that the new config coming from\n // pusher instance are taken into account\n // such as appKey and cluster\n this.updateStrategy();\n this.retryIn(0);\n }\n\n /** Establishes a connection to Pusher.\n *\n * Does nothing when connection is already established. See top-level doc\n * to find events emitted on connection attempts.\n */\n connect() {\n if (this.connection || this.runner) {\n return;\n }\n if (!this.strategy.isSupported()) {\n this.updateState('failed');\n return;\n }\n this.updateState('connecting');\n this.startConnecting();\n this.setUnavailableTimer();\n }\n\n /** Sends raw data.\n *\n * @param {String} data\n */\n send(data) {\n if (this.connection) {\n return this.connection.send(data);\n } else {\n return false;\n }\n }\n\n /** Sends an event.\n *\n * @param {String} name\n * @param {String} data\n * @param {String} [channel]\n * @returns {Boolean} whether message was sent or not\n */\n send_event(name: string, data: any, channel?: string) {\n if (this.connection) {\n return this.connection.send_event(name, data, channel);\n } else {\n return false;\n }\n }\n\n /** Closes the connection. */\n disconnect() {\n this.disconnectInternally();\n this.updateState('disconnected');\n }\n\n isUsingTLS() {\n return this.usingTLS;\n }\n\n private startConnecting() {\n var callback = (error, handshake) => {\n if (error) {\n this.runner = this.strategy.connect(0, callback);\n } else {\n if (handshake.action === 'error') {\n this.emit('error', {\n type: 'HandshakeError',\n error: handshake.error\n });\n this.timeline.error({ handshakeError: handshake.error });\n } else {\n this.abortConnecting(); // we don't support switching connections yet\n this.handshakeCallbacks[handshake.action](handshake);\n }\n }\n };\n this.runner = this.strategy.connect(0, callback);\n }\n\n private abortConnecting() {\n if (this.runner) {\n this.runner.abort();\n this.runner = null;\n }\n }\n\n private disconnectInternally() {\n this.abortConnecting();\n this.clearRetryTimer();\n this.clearUnavailableTimer();\n if (this.connection) {\n var connection = this.abandonConnection();\n connection.close();\n }\n }\n\n private updateStrategy() {\n this.strategy = this.options.getStrategy({\n key: this.key,\n timeline: this.timeline,\n useTLS: this.usingTLS\n });\n }\n\n private retryIn(delay) {\n this.timeline.info({ action: 'retry', delay: delay });\n if (delay > 0) {\n this.emit('connecting_in', Math.round(delay / 1000));\n }\n this.retryTimer = new Timer(delay || 0, () => {\n this.disconnectInternally();\n this.connect();\n });\n }\n\n private clearRetryTimer() {\n if (this.retryTimer) {\n this.retryTimer.ensureAborted();\n this.retryTimer = null;\n }\n }\n\n private setUnavailableTimer() {\n this.unavailableTimer = new Timer(this.options.unavailableTimeout, () => {\n this.updateState('unavailable');\n });\n }\n\n private clearUnavailableTimer() {\n if (this.unavailableTimer) {\n this.unavailableTimer.ensureAborted();\n }\n }\n\n private sendActivityCheck() {\n this.stopActivityCheck();\n this.connection.ping();\n // wait for pong response\n this.activityTimer = new Timer(this.options.pongTimeout, () => {\n this.timeline.error({ pong_timed_out: this.options.pongTimeout });\n this.retryIn(0);\n });\n }\n\n private resetActivityCheck() {\n this.stopActivityCheck();\n // send ping after inactivity\n if (this.connection && !this.connection.handlesActivityChecks()) {\n this.activityTimer = new Timer(this.activityTimeout, () => {\n this.sendActivityCheck();\n });\n }\n }\n\n private stopActivityCheck() {\n if (this.activityTimer) {\n this.activityTimer.ensureAborted();\n }\n }\n\n private buildConnectionCallbacks(\n errorCallbacks: ErrorCallbacks\n ): ConnectionCallbacks {\n return Collections.extend({}, errorCallbacks, {\n message: message => {\n // includes pong messages from server\n this.resetActivityCheck();\n this.emit('message', message);\n },\n ping: () => {\n this.send_event('pusher:pong', {});\n },\n activity: () => {\n this.resetActivityCheck();\n },\n error: error => {\n // just emit error to user - socket will already be closed by browser\n this.emit('error', error);\n },\n closed: () => {\n this.abandonConnection();\n if (this.shouldRetry()) {\n this.retryIn(1000);\n }\n }\n });\n }\n\n private buildHandshakeCallbacks(\n errorCallbacks: ErrorCallbacks\n ): HandshakeCallbacks {\n return Collections.extend({}, errorCallbacks, {\n connected: (handshake: HandshakePayload) => {\n this.activityTimeout = Math.min(\n this.options.activityTimeout,\n handshake.activityTimeout,\n handshake.connection.activityTimeout || Infinity\n );\n this.clearUnavailableTimer();\n this.setConnection(handshake.connection);\n this.socket_id = this.connection.id;\n this.updateState('connected', { socket_id: this.socket_id });\n }\n });\n }\n\n private buildErrorCallbacks(): ErrorCallbacks {\n let withErrorEmitted = callback => {\n return (result: Action | HandshakePayload) => {\n if (result.error) {\n this.emit('error', { type: 'WebSocketError', error: result.error });\n }\n callback(result);\n };\n };\n\n return {\n tls_only: withErrorEmitted(() => {\n this.usingTLS = true;\n this.updateStrategy();\n this.retryIn(0);\n }),\n refused: withErrorEmitted(() => {\n this.disconnect();\n }),\n backoff: withErrorEmitted(() => {\n this.retryIn(1000);\n }),\n retry: withErrorEmitted(() => {\n this.retryIn(0);\n })\n };\n }\n\n private setConnection(connection) {\n this.connection = connection;\n for (var event in this.connectionCallbacks) {\n this.connection.bind(event, this.connectionCallbacks[event]);\n }\n this.resetActivityCheck();\n }\n\n private abandonConnection() {\n if (!this.connection) {\n return;\n }\n this.stopActivityCheck();\n for (var event in this.connectionCallbacks) {\n this.connection.unbind(event, this.connectionCallbacks[event]);\n }\n var connection = this.connection;\n this.connection = null;\n return connection;\n }\n\n private updateState(newState: string, data?: any) {\n var previousState = this.state;\n this.state = newState;\n if (previousState !== newState) {\n var newStateDescription = newState;\n if (newStateDescription === 'connected') {\n newStateDescription += ' with new socket ID ' + data.socket_id;\n }\n Logger.debug(\n 'State changed',\n previousState + ' -> ' + newStateDescription\n );\n this.timeline.info({ state: newState, params: data });\n this.emit('state_change', { previous: previousState, current: newState });\n this.emit(newState, data);\n }\n }\n\n private shouldRetry(): boolean {\n return this.state === 'connecting' || this.state === 'connected';\n }\n}\n","import Channel from './channel';\nimport * as Collections from '../utils/collections';\nimport ChannelTable from './channel_table';\nimport Factory from '../utils/factory';\nimport Pusher from '../pusher';\nimport Logger from '../logger';\nimport * as Errors from '../errors';\nimport urlStore from '../utils/url_store';\n\n/** Handles a channel map. */\nexport default class Channels {\n channels: ChannelTable;\n\n constructor() {\n this.channels = {};\n }\n\n /** Creates or retrieves an existing channel by its name.\n *\n * @param {String} name\n * @param {Pusher} pusher\n * @return {Channel}\n */\n add(name: string, pusher: Pusher) {\n if (!this.channels[name]) {\n this.channels[name] = createChannel(name, pusher);\n }\n return this.channels[name];\n }\n\n /** Returns a list of all channels\n *\n * @return {Array}\n */\n all(): Channel[] {\n return Collections.values(this.channels);\n }\n\n /** Finds a channel by its name.\n *\n * @param {String} name\n * @return {Channel} channel or null if it doesn't exist\n */\n find(name: string) {\n return this.channels[name];\n }\n\n /** Removes a channel from the map.\n *\n * @param {String} name\n */\n remove(name: string) {\n var channel = this.channels[name];\n delete this.channels[name];\n return channel;\n }\n\n /** Proxies disconnection signal to all channels. */\n disconnect() {\n Collections.objectApply(this.channels, function(channel) {\n channel.disconnect();\n });\n }\n}\n\nfunction createChannel(name: string, pusher: Pusher): Channel {\n if (name.indexOf('private-encrypted-') === 0) {\n if (pusher.config.nacl) {\n return Factory.createEncryptedChannel(name, pusher, pusher.config.nacl);\n }\n let errMsg =\n 'Tried to subscribe to a private-encrypted- channel but no nacl implementation available';\n let suffix = urlStore.buildLogSuffix('encryptedChannelSupport');\n throw new Errors.UnsupportedFeature(`${errMsg}. ${suffix}`);\n } else if (name.indexOf('private-') === 0) {\n return Factory.createPrivateChannel(name, pusher);\n } else if (name.indexOf('presence-') === 0) {\n return Factory.createPresenceChannel(name, pusher);\n } else if (name.indexOf('#') === 0) {\n throw new Errors.BadChannelName(\n 'Cannot create a channel with name \"' + name + '\".'\n );\n } else {\n return Factory.createChannel(name, pusher);\n }\n}\n","import AssistantToTheTransportManager from '../transports/assistant_to_the_transport_manager';\nimport PingDelayOptions from '../transports/ping_delay_options';\nimport Transport from '../transports/transport';\nimport TransportManager from '../transports/transport_manager';\nimport Handshake from '../connection/handshake';\nimport TransportConnection from '../transports/transport_connection';\nimport SocketHooks from '../http/socket_hooks';\nimport HTTPSocket from '../http/http_socket';\n\nimport Timeline from '../timeline/timeline';\nimport {\n default as TimelineSender,\n TimelineSenderOptions\n} from '../timeline/timeline_sender';\nimport PresenceChannel from '../channels/presence_channel';\nimport PrivateChannel from '../channels/private_channel';\nimport EncryptedChannel from '../channels/encrypted_channel';\nimport Channel from '../channels/channel';\nimport ConnectionManager from '../connection/connection_manager';\nimport ConnectionManagerOptions from '../connection/connection_manager_options';\nimport Ajax from '../http/ajax';\nimport Channels from '../channels/channels';\nimport Pusher from '../pusher';\nimport { Config } from '../config';\nimport * as nacl from 'tweetnacl';\n\nvar Factory = {\n createChannels(): Channels {\n return new Channels();\n },\n\n createConnectionManager(\n key: string,\n options: ConnectionManagerOptions\n ): ConnectionManager {\n return new ConnectionManager(key, options);\n },\n\n createChannel(name: string, pusher: Pusher): Channel {\n return new Channel(name, pusher);\n },\n\n createPrivateChannel(name: string, pusher: Pusher): PrivateChannel {\n return new PrivateChannel(name, pusher);\n },\n\n createPresenceChannel(name: string, pusher: Pusher): PresenceChannel {\n return new PresenceChannel(name, pusher);\n },\n\n createEncryptedChannel(\n name: string,\n pusher: Pusher,\n nacl: nacl\n ): EncryptedChannel {\n return new EncryptedChannel(name, pusher, nacl);\n },\n\n createTimelineSender(timeline: Timeline, options: TimelineSenderOptions) {\n return new TimelineSender(timeline, options);\n },\n\n createHandshake(\n transport: TransportConnection,\n callback: (HandshakePayload) => void\n ): Handshake {\n return new Handshake(transport, callback);\n },\n\n createAssistantToTheTransportManager(\n manager: TransportManager,\n transport: Transport,\n options: PingDelayOptions\n ): AssistantToTheTransportManager {\n return new AssistantToTheTransportManager(manager, transport, options);\n }\n};\n\nexport default Factory;\n","import AssistantToTheTransportManager from './assistant_to_the_transport_manager';\nimport Transport from './transport';\nimport PingDelayOptions from './ping_delay_options';\nimport Factory from '../utils/factory';\n\nexport interface TransportManagerOptions extends PingDelayOptions {\n lives?: number;\n}\n\n/** Keeps track of the number of lives left for a transport.\n *\n * In the beginning of a session, transports may be assigned a number of\n * lives. When an AssistantToTheTransportManager instance reports a transport\n * connection closed uncleanly, the transport loses a life. When the number\n * of lives drops to zero, the transport gets disabled by its manager.\n *\n * @param {Object} options\n */\nexport default class TransportManager {\n options: TransportManagerOptions;\n livesLeft: number;\n\n constructor(options: TransportManagerOptions) {\n this.options = options || {};\n this.livesLeft = this.options.lives || Infinity;\n }\n\n /** Creates a assistant for the transport.\n *\n * @param {Transport} transport\n * @returns {AssistantToTheTransportManager}\n */\n getAssistant(transport: Transport): AssistantToTheTransportManager {\n return Factory.createAssistantToTheTransportManager(this, transport, {\n minPingDelay: this.options.minPingDelay,\n maxPingDelay: this.options.maxPingDelay\n });\n }\n\n /** Returns whether the transport has any lives left.\n *\n * @returns {Boolean}\n */\n isAlive(): boolean {\n return this.livesLeft > 0;\n }\n\n /** Takes one life from the transport. */\n reportDeath() {\n this.livesLeft -= 1;\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport { OneOffTimer as Timer } from '../utils/timers';\nimport Strategy from './strategy';\nimport StrategyOptions from './strategy_options';\n\n/** Loops through strategies with optional timeouts.\n *\n * Options:\n * - loop - whether it should loop through the substrategy list\n * - timeout - initial timeout for a single substrategy\n * - timeoutLimit - maximum timeout\n *\n * @param {Strategy[]} strategies\n * @param {Object} options\n */\nexport default class SequentialStrategy implements Strategy {\n strategies: Strategy[];\n loop: boolean;\n failFast: boolean;\n timeout: number;\n timeoutLimit: number;\n\n constructor(strategies: Strategy[], options: StrategyOptions) {\n this.strategies = strategies;\n this.loop = Boolean(options.loop);\n this.failFast = Boolean(options.failFast);\n this.timeout = options.timeout;\n this.timeoutLimit = options.timeoutLimit;\n }\n\n isSupported(): boolean {\n return Collections.any(this.strategies, Util.method('isSupported'));\n }\n\n connect(minPriority: number, callback: Function) {\n var strategies = this.strategies;\n var current = 0;\n var timeout = this.timeout;\n var runner = null;\n\n var tryNextStrategy = (error, handshake) => {\n if (handshake) {\n callback(null, handshake);\n } else {\n current = current + 1;\n if (this.loop) {\n current = current % strategies.length;\n }\n\n if (current < strategies.length) {\n if (timeout) {\n timeout = timeout * 2;\n if (this.timeoutLimit) {\n timeout = Math.min(timeout, this.timeoutLimit);\n }\n }\n runner = this.tryStrategy(\n strategies[current],\n minPriority,\n { timeout, failFast: this.failFast },\n tryNextStrategy\n );\n } else {\n callback(true);\n }\n }\n };\n\n runner = this.tryStrategy(\n strategies[current],\n minPriority,\n { timeout: timeout, failFast: this.failFast },\n tryNextStrategy\n );\n\n return {\n abort: function() {\n runner.abort();\n },\n forceMinPriority: function(p) {\n minPriority = p;\n if (runner) {\n runner.forceMinPriority(p);\n }\n }\n };\n }\n\n private tryStrategy(\n strategy: Strategy,\n minPriority: number,\n options: StrategyOptions,\n callback: Function\n ) {\n var timer = null;\n var runner = null;\n\n if (options.timeout > 0) {\n timer = new Timer(options.timeout, function() {\n runner.abort();\n callback(true);\n });\n }\n\n runner = strategy.connect(minPriority, function(error, handshake) {\n if (error && timer && timer.isRunning() && !options.failFast) {\n // advance to the next strategy after the timeout\n return;\n }\n if (timer) {\n timer.ensureAborted();\n }\n callback(error, handshake);\n });\n\n return {\n abort: function() {\n if (timer) {\n timer.ensureAborted();\n }\n runner.abort();\n },\n forceMinPriority: function(p) {\n runner.forceMinPriority(p);\n }\n };\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport Strategy from './strategy';\n\n/** Launches all substrategies and emits prioritized connected transports.\n *\n * @param {Array} strategies\n */\nexport default class BestConnectedEverStrategy implements Strategy {\n strategies: Strategy[];\n\n constructor(strategies: Strategy[]) {\n this.strategies = strategies;\n }\n\n isSupported(): boolean {\n return Collections.any(this.strategies, Util.method('isSupported'));\n }\n\n connect(minPriority: number, callback: Function) {\n return connect(this.strategies, minPriority, function(i, runners) {\n return function(error, handshake) {\n runners[i].error = error;\n if (error) {\n if (allRunnersFailed(runners)) {\n callback(true);\n }\n return;\n }\n Collections.apply(runners, function(runner) {\n runner.forceMinPriority(handshake.transport.priority);\n });\n callback(null, handshake);\n };\n });\n }\n}\n\n/** Connects to all strategies in parallel.\n *\n * Callback builder should be a function that takes two arguments: index\n * and a list of runners. It should return another function that will be\n * passed to the substrategy with given index. Runners can be aborted using\n * abortRunner(s) functions from this class.\n *\n * @param {Array} strategies\n * @param {Function} callbackBuilder\n * @return {Object} strategy runner\n */\nfunction connect(\n strategies: Strategy[],\n minPriority: number,\n callbackBuilder: Function\n) {\n var runners = Collections.map(strategies, function(strategy, i, _, rs) {\n return strategy.connect(minPriority, callbackBuilder(i, rs));\n });\n return {\n abort: function() {\n Collections.apply(runners, abortRunner);\n },\n forceMinPriority: function(p) {\n Collections.apply(runners, function(runner) {\n runner.forceMinPriority(p);\n });\n }\n };\n}\n\nfunction allRunnersFailed(runners): boolean {\n return Collections.all(runners, function(runner) {\n return Boolean(runner.error);\n });\n}\n\nfunction abortRunner(runner) {\n if (!runner.error && !runner.aborted) {\n runner.abort();\n runner.aborted = true;\n }\n}\n","import Util from '../util';\nimport Runtime from 'runtime';\nimport Strategy from './strategy';\nimport SequentialStrategy from './sequential_strategy';\nimport StrategyOptions from './strategy_options';\nimport TransportStrategy from './transport_strategy';\nimport Timeline from '../timeline/timeline';\nimport * as Collections from '../utils/collections';\n\nexport interface TransportStrategyDictionary {\n [key: string]: TransportStrategy;\n}\n\n/** Caches the last successful transport and, after the first few attempts,\n * uses the cached transport for subsequent attempts.\n *\n * @param {Strategy} strategy\n * @param {Object} transports\n * @param {Object} options\n */\nexport default class WebSocketPrioritizedCachedStrategy implements Strategy {\n strategy: Strategy;\n transports: TransportStrategyDictionary;\n ttl: number;\n usingTLS: boolean;\n timeline: Timeline;\n\n constructor(\n strategy: Strategy,\n transports: TransportStrategyDictionary,\n options: StrategyOptions\n ) {\n this.strategy = strategy;\n this.transports = transports;\n this.ttl = options.ttl || 1800 * 1000;\n this.usingTLS = options.useTLS;\n this.timeline = options.timeline;\n }\n\n isSupported(): boolean {\n return this.strategy.isSupported();\n }\n\n connect(minPriority: number, callback: Function) {\n var usingTLS = this.usingTLS;\n var info = fetchTransportCache(usingTLS);\n var cacheSkipCount = info && info.cacheSkipCount ? info.cacheSkipCount : 0;\n\n var strategies = [this.strategy];\n if (info && info.timestamp + this.ttl >= Util.now()) {\n var transport = this.transports[info.transport];\n if (transport) {\n if (['ws', 'wss'].includes(info.transport) || cacheSkipCount > 3) {\n this.timeline.info({\n cached: true,\n transport: info.transport,\n latency: info.latency\n });\n strategies.push(\n new SequentialStrategy([transport], {\n timeout: info.latency * 2 + 1000,\n failFast: true\n })\n );\n } else {\n cacheSkipCount++;\n }\n }\n }\n\n var startTimestamp = Util.now();\n var runner = strategies\n .pop()\n .connect(minPriority, function cb(error, handshake) {\n if (error) {\n flushTransportCache(usingTLS);\n if (strategies.length > 0) {\n startTimestamp = Util.now();\n runner = strategies.pop().connect(minPriority, cb);\n } else {\n callback(error);\n }\n } else {\n storeTransportCache(\n usingTLS,\n handshake.transport.name,\n Util.now() - startTimestamp,\n cacheSkipCount\n );\n callback(null, handshake);\n }\n });\n\n return {\n abort: function() {\n runner.abort();\n },\n forceMinPriority: function(p) {\n minPriority = p;\n if (runner) {\n runner.forceMinPriority(p);\n }\n }\n };\n }\n}\n\nfunction getTransportCacheKey(usingTLS: boolean): string {\n return 'pusherTransport' + (usingTLS ? 'TLS' : 'NonTLS');\n}\n\nfunction fetchTransportCache(usingTLS: boolean): any {\n var storage = Runtime.getLocalStorage();\n if (storage) {\n try {\n var serializedCache = storage[getTransportCacheKey(usingTLS)];\n if (serializedCache) {\n return JSON.parse(serializedCache);\n }\n } catch (e) {\n flushTransportCache(usingTLS);\n }\n }\n return null;\n}\n\nfunction storeTransportCache(\n usingTLS: boolean,\n transport: TransportStrategy,\n latency: number,\n cacheSkipCount: number\n) {\n var storage = Runtime.getLocalStorage();\n if (storage) {\n try {\n storage[getTransportCacheKey(usingTLS)] = Collections.safeJSONStringify({\n timestamp: Util.now(),\n transport: transport,\n latency: latency,\n cacheSkipCount: cacheSkipCount\n });\n } catch (e) {\n // catch over quota exceptions raised by localStorage\n }\n }\n}\n\nfunction flushTransportCache(usingTLS: boolean) {\n var storage = Runtime.getLocalStorage();\n if (storage) {\n try {\n delete storage[getTransportCacheKey(usingTLS)];\n } catch (e) {\n // catch exceptions raised by localStorage\n }\n }\n}\n","import { OneOffTimer as Timer } from '../utils/timers';\nimport Strategy from './strategy';\nimport StrategyOptions from './strategy_options';\n\n/** Runs substrategy after specified delay.\n *\n * Options:\n * - delay - time in miliseconds to delay the substrategy attempt\n *\n * @param {Strategy} strategy\n * @param {Object} options\n */\nexport default class DelayedStrategy implements Strategy {\n strategy: Strategy;\n options: { delay: number };\n\n constructor(strategy: Strategy, { delay: number }) {\n this.strategy = strategy;\n this.options = { delay: number };\n }\n\n isSupported(): boolean {\n return this.strategy.isSupported();\n }\n\n connect(minPriority: number, callback: Function) {\n var strategy = this.strategy;\n var runner;\n var timer = new Timer(this.options.delay, function() {\n runner = strategy.connect(minPriority, callback);\n });\n\n return {\n abort: function() {\n timer.ensureAborted();\n if (runner) {\n runner.abort();\n }\n },\n forceMinPriority: function(p) {\n minPriority = p;\n if (runner) {\n runner.forceMinPriority(p);\n }\n }\n };\n }\n}\n","import Strategy from './strategy';\nimport StrategyRunner from './strategy_runner';\n\n/** Proxies method calls to one of substrategies basing on the test function.\n *\n * @param {Function} test\n * @param {Strategy} trueBranch strategy used when test returns true\n * @param {Strategy} falseBranch strategy used when test returns false\n */\nexport default class IfStrategy implements Strategy {\n test: () => boolean;\n trueBranch: Strategy;\n falseBranch: Strategy;\n\n constructor(\n test: () => boolean,\n trueBranch: Strategy,\n falseBranch: Strategy\n ) {\n this.test = test;\n this.trueBranch = trueBranch;\n this.falseBranch = falseBranch;\n }\n\n isSupported(): boolean {\n var branch = this.test() ? this.trueBranch : this.falseBranch;\n return branch.isSupported();\n }\n\n connect(minPriority: number, callback: Function): StrategyRunner {\n var branch = this.test() ? this.trueBranch : this.falseBranch;\n return branch.connect(minPriority, callback);\n }\n}\n","import Strategy from './strategy';\nimport StrategyRunner from './strategy_runner';\n\n/** Launches the substrategy and terminates on the first open connection.\n *\n * @param {Strategy} strategy\n */\nexport default class FirstConnectedStrategy implements Strategy {\n strategy: Strategy;\n\n constructor(strategy: Strategy) {\n this.strategy = strategy;\n }\n\n isSupported(): boolean {\n return this.strategy.isSupported();\n }\n\n connect(minPriority: number, callback: Function): StrategyRunner {\n var runner = this.strategy.connect(minPriority, function(error, handshake) {\n if (handshake) {\n runner.abort();\n }\n callback(error, handshake);\n });\n return runner;\n }\n}\n","import * as Collections from 'core/utils/collections';\nimport TransportManager from 'core/transports/transport_manager';\nimport Strategy from 'core/strategies/strategy';\nimport SequentialStrategy from 'core/strategies/sequential_strategy';\nimport BestConnectedEverStrategy from 'core/strategies/best_connected_ever_strategy';\nimport WebSocketPrioritizedCachedStrategy, {\n TransportStrategyDictionary\n} from 'core/strategies/websocket_prioritized_cached_strategy';\nimport DelayedStrategy from 'core/strategies/delayed_strategy';\nimport IfStrategy from 'core/strategies/if_strategy';\nimport FirstConnectedStrategy from 'core/strategies/first_connected_strategy';\nimport { Config } from 'core/config';\nimport StrategyOptions from 'core/strategies/strategy_options';\n\nfunction testSupportsStrategy(strategy: Strategy) {\n return function() {\n return strategy.isSupported();\n };\n}\n\nvar getDefaultStrategy = function(\n config: Config,\n baseOptions: StrategyOptions,\n defineTransport: Function\n): Strategy {\n var definedTransports = {};\n\n function defineTransportStrategy(\n name: string,\n type: string,\n priority: number,\n options: StrategyOptions,\n manager?: TransportManager\n ) {\n var transport = defineTransport(\n config,\n name,\n type,\n priority,\n options,\n manager\n );\n\n definedTransports[name] = transport;\n\n return transport;\n }\n\n var ws_options: StrategyOptions = Object.assign({}, baseOptions, {\n hostNonTLS: config.wsHost + ':' + config.wsPort,\n hostTLS: config.wsHost + ':' + config.wssPort,\n httpPath: config.wsPath\n });\n var wss_options: StrategyOptions = Collections.extend({}, ws_options, {\n useTLS: true\n });\n var http_options: StrategyOptions = Object.assign({}, baseOptions, {\n hostNonTLS: config.httpHost + ':' + config.httpPort,\n hostTLS: config.httpHost + ':' + config.httpsPort,\n httpPath: config.httpPath\n });\n var timeouts = {\n loop: true,\n timeout: 15000,\n timeoutLimit: 60000\n };\n\n var ws_manager = new TransportManager({\n minPingDelay: 10000,\n maxPingDelay: config.activityTimeout\n });\n var streaming_manager = new TransportManager({\n lives: 2,\n minPingDelay: 10000,\n maxPingDelay: config.activityTimeout\n });\n\n var ws_transport = defineTransportStrategy(\n 'ws',\n 'ws',\n 3,\n ws_options,\n ws_manager\n );\n var wss_transport = defineTransportStrategy(\n 'wss',\n 'ws',\n 3,\n wss_options,\n ws_manager\n );\n var xhr_streaming_transport = defineTransportStrategy(\n 'xhr_streaming',\n 'xhr_streaming',\n 1,\n http_options,\n streaming_manager\n );\n var xhr_polling_transport = defineTransportStrategy(\n 'xhr_polling',\n 'xhr_polling',\n 1,\n http_options\n );\n\n var ws_loop = new SequentialStrategy([ws_transport], timeouts);\n var wss_loop = new SequentialStrategy([wss_transport], timeouts);\n var streaming_loop = new SequentialStrategy(\n [xhr_streaming_transport],\n timeouts\n );\n var polling_loop = new SequentialStrategy([xhr_polling_transport], timeouts);\n\n var http_loop = new SequentialStrategy(\n [\n new IfStrategy(\n testSupportsStrategy(streaming_loop),\n new BestConnectedEverStrategy([\n streaming_loop,\n new DelayedStrategy(polling_loop, { delay: 4000 })\n ]),\n polling_loop\n )\n ],\n timeouts\n );\n\n var wsStrategy;\n if (baseOptions.useTLS) {\n wsStrategy = new BestConnectedEverStrategy([\n ws_loop,\n new DelayedStrategy(http_loop, { delay: 2000 })\n ]);\n } else {\n wsStrategy = new BestConnectedEverStrategy([\n ws_loop,\n new DelayedStrategy(wss_loop, { delay: 2000 }),\n new DelayedStrategy(http_loop, { delay: 5000 })\n ]);\n }\n\n return new WebSocketPrioritizedCachedStrategy(\n new FirstConnectedStrategy(\n new IfStrategy(testSupportsStrategy(ws_transport), wsStrategy, http_loop)\n ),\n definedTransports,\n {\n ttl: 1800000,\n timeline: baseOptions.timeline,\n useTLS: baseOptions.useTLS\n }\n );\n};\n\nexport default getDefaultStrategy;\n","/** Initializes the transport.\n *\n * Fetches resources if needed and then transitions to initialized.\n */\nexport default function() {\n var self = this;\n\n self.timeline.info(\n self.buildTimelineMessage({\n transport: self.name + (self.options.useTLS ? 's' : '')\n })\n );\n\n if (self.hooks.isInitialized()) {\n self.changeState('initialized');\n } else {\n self.onClose();\n }\n}\n","import Runtime from 'runtime';\nimport RequestHooks from './request_hooks';\nimport Ajax from './ajax';\nimport { default as EventsDispatcher } from '../events/dispatcher';\n\nconst MAX_BUFFER_LENGTH = 256 * 1024;\n\nexport default class HTTPRequest extends EventsDispatcher {\n hooks: RequestHooks;\n method: string;\n url: string;\n position: number;\n xhr: Ajax;\n unloader: Function;\n\n constructor(hooks: RequestHooks, method: string, url: string) {\n super();\n this.hooks = hooks;\n this.method = method;\n this.url = url;\n }\n\n start(payload?: any) {\n this.position = 0;\n this.xhr = this.hooks.getRequest(this);\n\n this.unloader = () => {\n this.close();\n };\n Runtime.addUnloadListener(this.unloader);\n\n this.xhr.open(this.method, this.url, true);\n\n if (this.xhr.setRequestHeader) {\n this.xhr.setRequestHeader('Content-Type', 'application/json'); // ReactNative doesn't set this header by default.\n }\n this.xhr.send(payload);\n }\n\n close() {\n if (this.unloader) {\n Runtime.removeUnloadListener(this.unloader);\n this.unloader = null;\n }\n if (this.xhr) {\n this.hooks.abortRequest(this.xhr);\n this.xhr = null;\n }\n }\n\n onChunk(status: number, data: any) {\n while (true) {\n var chunk = this.advanceBuffer(data);\n if (chunk) {\n this.emit('chunk', { status: status, data: chunk });\n } else {\n break;\n }\n }\n if (this.isBufferTooLong(data)) {\n this.emit('buffer_too_long');\n }\n }\n\n private advanceBuffer(buffer: any[]): any {\n var unreadData = buffer.slice(this.position);\n var endOfLinePosition = unreadData.indexOf('\\n');\n\n if (endOfLinePosition !== -1) {\n this.position += endOfLinePosition + 1;\n return unreadData.slice(0, endOfLinePosition);\n } else {\n // chunk is not finished yet, don't move the buffer pointer\n return null;\n }\n }\n\n private isBufferTooLong(buffer: any): boolean {\n return this.position === buffer.length && buffer.length > MAX_BUFFER_LENGTH;\n }\n}\n","enum State {\n CONNECTING = 0,\n OPEN = 1,\n CLOSED = 3\n}\n\nexport default State;\n","import URLLocation from './url_location';\nimport State from './state';\nimport Socket from '../socket';\nimport SocketHooks from './socket_hooks';\nimport Util from '../util';\nimport Ajax from './ajax';\nimport HTTPRequest from './http_request';\nimport Runtime from 'runtime';\n\nvar autoIncrement = 1;\n\nclass HTTPSocket implements Socket {\n hooks: SocketHooks;\n session: string;\n location: URLLocation;\n readyState: State;\n stream: HTTPRequest;\n\n onopen: () => void;\n onerror: (error: any) => void;\n onclose: (closeEvent: any) => void;\n onmessage: (message: any) => void;\n onactivity: () => void;\n\n constructor(hooks: SocketHooks, url: string) {\n this.hooks = hooks;\n this.session = randomNumber(1000) + '/' + randomString(8);\n this.location = getLocation(url);\n this.readyState = State.CONNECTING;\n this.openStream();\n }\n\n send(payload: any) {\n return this.sendRaw(JSON.stringify([payload]));\n }\n\n ping() {\n this.hooks.sendHeartbeat(this);\n }\n\n close(code: any, reason: any) {\n this.onClose(code, reason, true);\n }\n\n /** For internal use only */\n sendRaw(payload: any): boolean {\n if (this.readyState === State.OPEN) {\n try {\n Runtime.createSocketRequest(\n 'POST',\n getUniqueURL(getSendURL(this.location, this.session))\n ).start(payload);\n return true;\n } catch (e) {\n return false;\n }\n } else {\n return false;\n }\n }\n\n /** For internal use only */\n reconnect() {\n this.closeStream();\n this.openStream();\n }\n\n /** For internal use only */\n onClose(code, reason, wasClean) {\n this.closeStream();\n this.readyState = State.CLOSED;\n if (this.onclose) {\n this.onclose({\n code: code,\n reason: reason,\n wasClean: wasClean\n });\n }\n }\n\n private onChunk(chunk) {\n if (chunk.status !== 200) {\n return;\n }\n if (this.readyState === State.OPEN) {\n this.onActivity();\n }\n\n var payload;\n var type = chunk.data.slice(0, 1);\n switch (type) {\n case 'o':\n payload = JSON.parse(chunk.data.slice(1) || '{}');\n this.onOpen(payload);\n break;\n case 'a':\n payload = JSON.parse(chunk.data.slice(1) || '[]');\n for (var i = 0; i < payload.length; i++) {\n this.onEvent(payload[i]);\n }\n break;\n case 'm':\n payload = JSON.parse(chunk.data.slice(1) || 'null');\n this.onEvent(payload);\n break;\n case 'h':\n this.hooks.onHeartbeat(this);\n break;\n case 'c':\n payload = JSON.parse(chunk.data.slice(1) || '[]');\n this.onClose(payload[0], payload[1], true);\n break;\n }\n }\n\n private onOpen(options) {\n if (this.readyState === State.CONNECTING) {\n if (options && options.hostname) {\n this.location.base = replaceHost(this.location.base, options.hostname);\n }\n this.readyState = State.OPEN;\n\n if (this.onopen) {\n this.onopen();\n }\n } else {\n this.onClose(1006, 'Server lost session', true);\n }\n }\n\n private onEvent(event) {\n if (this.readyState === State.OPEN && this.onmessage) {\n this.onmessage({ data: event });\n }\n }\n\n private onActivity() {\n if (this.onactivity) {\n this.onactivity();\n }\n }\n\n private onError(error) {\n if (this.onerror) {\n this.onerror(error);\n }\n }\n\n private openStream() {\n this.stream = Runtime.createSocketRequest(\n 'POST',\n getUniqueURL(this.hooks.getReceiveURL(this.location, this.session))\n );\n\n this.stream.bind('chunk', chunk => {\n this.onChunk(chunk);\n });\n this.stream.bind('finished', status => {\n this.hooks.onFinished(this, status);\n });\n this.stream.bind('buffer_too_long', () => {\n this.reconnect();\n });\n\n try {\n this.stream.start();\n } catch (error) {\n Util.defer(() => {\n this.onError(error);\n this.onClose(1006, 'Could not start streaming', false);\n });\n }\n }\n\n private closeStream() {\n if (this.stream) {\n this.stream.unbind_all();\n this.stream.close();\n this.stream = null;\n }\n }\n}\n\nfunction getLocation(url): URLLocation {\n var parts = /([^\\?]*)\\/*(\\??.*)/.exec(url);\n return {\n base: parts[1],\n queryString: parts[2]\n };\n}\n\nfunction getSendURL(url: URLLocation, session: string): string {\n return url.base + '/' + session + '/xhr_send';\n}\n\nfunction getUniqueURL(url: string): string {\n var separator = url.indexOf('?') === -1 ? '?' : '&';\n return url + separator + 't=' + +new Date() + '&n=' + autoIncrement++;\n}\n\nfunction replaceHost(url: string, hostname: string): string {\n var urlParts = /(https?:\\/\\/)([^\\/:]+)((\\/|:)?.*)/.exec(url);\n return urlParts[1] + hostname + urlParts[3];\n}\n\nfunction randomNumber(max: number): number {\n return Runtime.randomInt(max);\n}\n\nfunction randomString(length: number): string {\n var result = [];\n\n for (var i = 0; i < length; i++) {\n result.push(randomNumber(32).toString(32));\n }\n\n return result.join('');\n}\n\nexport default HTTPSocket;\n","import SocketHooks from './socket_hooks';\nimport HTTPSocket from './http_socket';\n\nvar hooks: SocketHooks = {\n getReceiveURL: function(url, session) {\n return url.base + '/' + session + '/xhr_streaming' + url.queryString;\n },\n onHeartbeat: function(socket) {\n socket.sendRaw('[]');\n },\n sendHeartbeat: function(socket) {\n socket.sendRaw('[]');\n },\n onFinished: function(socket, status) {\n socket.onClose(1006, 'Connection interrupted (' + status + ')', false);\n }\n};\n\nexport default hooks;\n","import SocketHooks from './socket_hooks';\nimport URLLocation from './url_location';\nimport HTTPSocket from './http_socket';\n\nvar hooks: SocketHooks = {\n getReceiveURL: function(url: URLLocation, session: string): string {\n return url.base + '/' + session + '/xhr' + url.queryString;\n },\n onHeartbeat: function() {\n // next HTTP request will reset server's activity timer\n },\n sendHeartbeat: function(socket) {\n socket.sendRaw('[]');\n },\n onFinished: function(socket, status) {\n if (status === 200) {\n socket.reconnect();\n } else {\n socket.onClose(1006, 'Connection interrupted (' + status + ')', false);\n }\n }\n};\n\nexport default hooks;\n","import HTTPRequest from 'core/http/http_request';\nimport RequestHooks from 'core/http/request_hooks';\nimport Ajax from 'core/http/ajax';\nimport Runtime from 'runtime';\n\nvar hooks: RequestHooks = {\n getRequest: function(socket: HTTPRequest): Ajax {\n var Constructor = Runtime.getXHRAPI();\n var xhr = new Constructor();\n xhr.onreadystatechange = xhr.onprogress = function() {\n switch (xhr.readyState) {\n case 3:\n if (xhr.responseText && xhr.responseText.length > 0) {\n socket.onChunk(xhr.status, xhr.responseText);\n }\n break;\n case 4:\n // this happens only on errors, never after calling close\n if (xhr.responseText && xhr.responseText.length > 0) {\n socket.onChunk(xhr.status, xhr.responseText);\n }\n socket.emit('finished', xhr.status);\n socket.close();\n break;\n }\n };\n return xhr;\n },\n abortRequest: function(xhr: Ajax) {\n xhr.onreadystatechange = null;\n xhr.abort();\n }\n};\n\nexport default hooks;\n","import HTTPRequest from 'core/http/http_request';\nimport HTTPSocket from 'core/http/http_socket';\nimport SocketHooks from 'core/http/socket_hooks';\nimport RequestHooks from 'core/http/request_hooks';\nimport streamingHooks from 'core/http/http_streaming_socket';\nimport pollingHooks from 'core/http/http_polling_socket';\nimport xhrHooks from './http_xhr_request';\nimport HTTPFactory from 'core/http/http_factory';\n\nvar HTTP: HTTPFactory = {\n createStreamingSocket(url: string): HTTPSocket {\n return this.createSocket(streamingHooks, url);\n },\n\n createPollingSocket(url: string): HTTPSocket {\n return this.createSocket(pollingHooks, url);\n },\n\n createSocket(hooks: SocketHooks, url: string): HTTPSocket {\n return new HTTPSocket(hooks, url);\n },\n\n createXHR(method: string, url: string): HTTPRequest {\n return this.createRequest(xhrHooks, method, url);\n },\n\n createRequest(hooks: RequestHooks, method: string, url: string): HTTPRequest {\n return new HTTPRequest(hooks, method, url);\n }\n};\n\nexport default HTTP;\n","import * as Collections from 'core/utils/collections';\nimport Transports from 'isomorphic/transports/transports';\nimport TimelineSender from 'core/timeline/timeline_sender';\nimport Ajax from 'core/http/ajax';\nimport getDefaultStrategy from './default_strategy';\nimport TransportsTable from 'core/transports/transports_table';\nimport transportConnectionInitializer from './transports/transport_connection_initializer';\nimport HTTPFactory from './http/http';\n\nvar Isomorphic: any = {\n getDefaultStrategy,\n Transports: Transports,\n transportConnectionInitializer,\n HTTPFactory,\n\n setup(PusherClass): void {\n PusherClass.ready();\n },\n\n getLocalStorage(): any {\n return undefined;\n },\n\n getClientFeatures(): any[] {\n return Collections.keys(\n Collections.filterObject({ ws: Transports.ws }, function(t) {\n return t.isSupported({});\n })\n );\n },\n\n getProtocol(): string {\n return 'http:';\n },\n\n isXHRSupported(): boolean {\n return true;\n },\n\n createSocketRequest(method: string, url: string) {\n if (this.isXHRSupported()) {\n return this.HTTPFactory.createXHR(method, url);\n } else {\n throw 'Cross-origin HTTP requests are not supported';\n }\n },\n\n createXHR(): Ajax {\n var Constructor = this.getXHRAPI();\n return new Constructor();\n },\n\n createWebSocket(url: string): any {\n var Constructor = this.getWebSocketAPI();\n return new Constructor(url);\n },\n\n addUnloadListener(listener: any) {},\n removeUnloadListener(listener: any) {}\n};\n\nexport default Isomorphic;\n","import { default as EventsDispatcher } from 'core/events/dispatcher';\nimport Reachability from 'core/reachability';\n\nexport class NetInfo extends EventsDispatcher implements Reachability {\n isOnline(): boolean {\n return true;\n }\n}\n\nexport var Network = new NetInfo();\n","export enum AuthRequestType {\n UserAuthentication = 'user-authentication',\n ChannelAuthorization = 'channel-authorization'\n}\n\nexport interface ChannelAuthorizationData {\n auth: string;\n channel_data?: string;\n shared_secret?: string;\n}\n\nexport type ChannelAuthorizationCallback = (\n error: Error | null,\n authData: ChannelAuthorizationData | null\n) => void;\n\nexport interface ChannelAuthorizationRequestParams {\n socketId: string;\n channelName: string;\n}\n\nexport interface ChannelAuthorizationHandler {\n (\n params: ChannelAuthorizationRequestParams,\n callback: ChannelAuthorizationCallback\n ): void;\n}\n\nexport interface UserAuthenticationData {\n auth: string;\n user_data: string;\n}\n\nexport type UserAuthenticationCallback = (\n error: Error | null,\n authData: UserAuthenticationData | null\n) => void;\n\nexport interface UserAuthenticationRequestParams {\n socketId: string;\n}\n\nexport interface UserAuthenticationHandler {\n (\n params: UserAuthenticationRequestParams,\n callback: UserAuthenticationCallback\n ): void;\n}\n\nexport type AuthTransportCallback =\n | ChannelAuthorizationCallback\n | UserAuthenticationCallback;\n\nexport interface AuthOptionsT {\n transport: 'ajax' | 'jsonp';\n endpoint: string;\n params?: any;\n headers?: any;\n paramsProvider?: () => any;\n headersProvider?: () => any;\n customHandler?: AuthHandler;\n}\n\nexport declare type UserAuthenticationOptions = AuthOptionsT<\n UserAuthenticationHandler\n>;\nexport declare type ChannelAuthorizationOptions = AuthOptionsT<\n ChannelAuthorizationHandler\n>;\n\nexport interface InternalAuthOptions {\n transport: 'ajax' | 'jsonp';\n endpoint: string;\n params?: any;\n headers?: any;\n paramsProvider?: () => any;\n headersProvider?: () => any;\n}\n","import TimelineSender from 'core/timeline/timeline_sender';\nimport * as Collections from 'core/utils/collections';\nimport Util from 'core/util';\nimport Runtime from 'runtime';\nimport { AuthTransport } from 'core/auth/auth_transports';\nimport AbstractRuntime from 'runtimes/interface';\nimport UrlStore from 'core/utils/url_store';\nimport {\n AuthRequestType,\n AuthTransportCallback,\n InternalAuthOptions\n} from 'core/auth/options';\nimport { HTTPAuthError } from 'core/errors';\n\nconst ajax: AuthTransport = function(\n context: AbstractRuntime,\n query: string,\n authOptions: InternalAuthOptions,\n authRequestType: AuthRequestType,\n callback: AuthTransportCallback\n) {\n const xhr = Runtime.createXHR();\n xhr.open('POST', authOptions.endpoint, true);\n\n // add request headers\n xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');\n for (var headerName in authOptions.headers) {\n xhr.setRequestHeader(headerName, authOptions.headers[headerName]);\n }\n if (authOptions.headersProvider != null) {\n let dynamicHeaders = authOptions.headersProvider();\n for (var headerName in dynamicHeaders) {\n xhr.setRequestHeader(headerName, dynamicHeaders[headerName]);\n }\n }\n\n xhr.onreadystatechange = function() {\n if (xhr.readyState === 4) {\n if (xhr.status === 200) {\n let data;\n let parsed = false;\n\n try {\n data = JSON.parse(xhr.responseText);\n parsed = true;\n } catch (e) {\n callback(\n new HTTPAuthError(\n 200,\n `JSON returned from ${authRequestType.toString()} endpoint was invalid, yet status code was 200. Data was: ${\n xhr.responseText\n }`\n ),\n null\n );\n }\n\n if (parsed) {\n // prevents double execution.\n callback(null, data);\n }\n } else {\n let suffix = '';\n switch (authRequestType) {\n case AuthRequestType.UserAuthentication:\n suffix = UrlStore.buildLogSuffix('authenticationEndpoint');\n break;\n case AuthRequestType.ChannelAuthorization:\n suffix = `Clients must be authorized to join private or presence channels. ${UrlStore.buildLogSuffix(\n 'authorizationEndpoint'\n )}`;\n break;\n }\n callback(\n new HTTPAuthError(\n xhr.status,\n `Unable to retrieve auth string from ${authRequestType.toString()} endpoint - ` +\n `received status: ${xhr.status} from ${authOptions.endpoint}. ${suffix}`\n ),\n null\n );\n }\n }\n };\n\n xhr.send(query);\n return xhr;\n};\n\nexport default ajax;\n","import Logger from 'core/logger';\nimport TimelineSender from 'core/timeline/timeline_sender';\nimport * as Collections from 'core/utils/collections';\nimport Util from 'core/util';\nimport Runtime from 'runtime';\nimport TimelineTransport from 'core/timeline/timeline_transport';\n\nvar getAgent = function(sender: TimelineSender, useTLS: boolean) {\n return function(data: any, callback: Function) {\n var scheme = 'http' + (useTLS ? 's' : '') + '://';\n var url =\n scheme + (sender.host || sender.options.host) + sender.options.path;\n var query = Collections.buildQueryString(data);\n\n url += '/' + 2 + '?' + query;\n\n var xhr = Runtime.createXHR();\n xhr.open('GET', url, true);\n\n xhr.onreadystatechange = function() {\n if (xhr.readyState === 4) {\n let { status, responseText } = xhr;\n if (status !== 200) {\n Logger.debug(\n `TimelineSender Error: received ${status} from stats.pusher.com`\n );\n return;\n }\n\n try {\n var { host } = JSON.parse(responseText);\n } catch (e) {\n Logger.debug(`TimelineSenderError: invalid response ${responseText}`);\n }\n if (host) {\n sender.host = host;\n }\n }\n };\n\n xhr.send();\n };\n};\n\nvar xhr = {\n name: 'xhr',\n getAgent\n};\n\nexport default xhr;\n","import Isomorphic from 'isomorphic/runtime';\nimport { Client as WebSocket } from 'faye-websocket';\nimport { XMLHttpRequest } from 'xmlhttprequest';\nimport Runtime from '../interface';\nimport { Network } from './net_info';\nimport xhrAuth from 'isomorphic/auth/xhr_auth';\nimport { AuthTransports } from 'core/auth/auth_transports';\nimport xhrTimeline from 'isomorphic/timeline/xhr_timeline';\nimport { randomInt } from 'crypto';\n\n// Very verbose but until unavoidable until\n// TypeScript 2.1, when spread attributes will be\n// supported\nconst {\n getDefaultStrategy,\n Transports,\n setup,\n getProtocol,\n isXHRSupported,\n getLocalStorage,\n createXHR,\n createWebSocket,\n addUnloadListener,\n removeUnloadListener,\n transportConnectionInitializer,\n createSocketRequest,\n HTTPFactory\n} = Isomorphic;\n\nconst NodeJS: Runtime = {\n getDefaultStrategy,\n Transports,\n setup,\n getProtocol,\n isXHRSupported,\n createSocketRequest,\n getLocalStorage,\n createXHR,\n createWebSocket,\n addUnloadListener,\n removeUnloadListener,\n transportConnectionInitializer,\n HTTPFactory,\n\n TimelineTransport: xhrTimeline,\n\n getAuthorizers(): AuthTransports {\n return { ajax: xhrAuth };\n },\n\n getWebSocketAPI() {\n return WebSocket;\n },\n\n getXHRAPI() {\n return XMLHttpRequest;\n },\n\n getNetwork() {\n return Network;\n },\n\n randomInt(max: number): number {\n return randomInt(max);\n }\n};\n\nexport default NodeJS;\n","enum TimelineLevel {\n ERROR = 3,\n INFO = 6,\n DEBUG = 7\n}\n\nexport default TimelineLevel;\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport { default as Level } from './level';\n\nexport interface TimelineOptions {\n level?: Level;\n limit?: number;\n version?: string;\n cluster?: string;\n features?: string[];\n params?: any;\n}\n\nexport default class Timeline {\n key: string;\n session: number;\n events: any[];\n options: TimelineOptions;\n sent: number;\n uniqueID: number;\n\n constructor(key: string, session: number, options: TimelineOptions) {\n this.key = key;\n this.session = session;\n this.events = [];\n this.options = options || {};\n this.sent = 0;\n this.uniqueID = 0;\n }\n\n log(level, event) {\n if (level <= this.options.level) {\n this.events.push(\n Collections.extend({}, event, { timestamp: Util.now() })\n );\n if (this.options.limit && this.events.length > this.options.limit) {\n this.events.shift();\n }\n }\n }\n\n error(event) {\n this.log(Level.ERROR, event);\n }\n\n info(event) {\n this.log(Level.INFO, event);\n }\n\n debug(event) {\n this.log(Level.DEBUG, event);\n }\n\n isEmpty() {\n return this.events.length === 0;\n }\n\n send(sendfn, callback) {\n var data = Collections.extend(\n {\n session: this.session,\n bundle: this.sent + 1,\n key: this.key,\n lib: 'js',\n version: this.options.version,\n cluster: this.options.cluster,\n features: this.options.features,\n timeline: this.events\n },\n this.options.params\n );\n\n this.events = [];\n sendfn(data, (error, result) => {\n if (!error) {\n this.sent++;\n }\n if (callback) {\n callback(error, result);\n }\n });\n\n return true;\n }\n\n generateUniqueID(): number {\n this.uniqueID++;\n return this.uniqueID;\n }\n}\n","import Factory from '../utils/factory';\nimport Util from '../util';\nimport * as Errors from '../errors';\nimport * as Collections from '../utils/collections';\nimport Strategy from './strategy';\nimport Transport from '../transports/transport';\nimport StrategyOptions from './strategy_options';\nimport Handshake from '../connection/handshake';\n\n/** Provides a strategy interface for transports.\n *\n * @param {String} name\n * @param {Number} priority\n * @param {Class} transport\n * @param {Object} options\n */\nexport default class TransportStrategy implements Strategy {\n name: string;\n priority: number;\n transport: Transport;\n options: StrategyOptions;\n\n constructor(\n name: string,\n priority: number,\n transport: Transport,\n options: StrategyOptions\n ) {\n this.name = name;\n this.priority = priority;\n this.transport = transport;\n this.options = options || {};\n }\n\n /** Returns whether the transport is supported in the browser.\n *\n * @returns {Boolean}\n */\n isSupported(): boolean {\n return this.transport.isSupported({\n useTLS: this.options.useTLS\n });\n }\n\n /** Launches a connection attempt and returns a strategy runner.\n *\n * @param {Function} callback\n * @return {Object} strategy runner\n */\n connect(minPriority: number, callback: Function) {\n if (!this.isSupported()) {\n return failAttempt(new Errors.UnsupportedStrategy(), callback);\n } else if (this.priority < minPriority) {\n return failAttempt(new Errors.TransportPriorityTooLow(), callback);\n }\n\n var connected = false;\n var transport = this.transport.createConnection(\n this.name,\n this.priority,\n this.options.key,\n this.options\n );\n var handshake = null;\n\n var onInitialized = function() {\n transport.unbind('initialized', onInitialized);\n transport.connect();\n };\n var onOpen = function() {\n handshake = Factory.createHandshake(transport, function(result) {\n connected = true;\n unbindListeners();\n callback(null, result);\n });\n };\n var onError = function(error) {\n unbindListeners();\n callback(error);\n };\n var onClosed = function() {\n unbindListeners();\n var serializedTransport;\n\n // The reason for this try/catch block is that on React Native\n // the WebSocket object is circular. Therefore transport.socket will\n // throw errors upon stringification. Collections.safeJSONStringify\n // discards circular references when serializing.\n serializedTransport = Collections.safeJSONStringify(transport);\n callback(new Errors.TransportClosed(serializedTransport));\n };\n\n var unbindListeners = function() {\n transport.unbind('initialized', onInitialized);\n transport.unbind('open', onOpen);\n transport.unbind('error', onError);\n transport.unbind('closed', onClosed);\n };\n\n transport.bind('initialized', onInitialized);\n transport.bind('open', onOpen);\n transport.bind('error', onError);\n transport.bind('closed', onClosed);\n\n // connect will be called automatically after initialization\n transport.initialize();\n\n return {\n abort: () => {\n if (connected) {\n return;\n }\n unbindListeners();\n if (handshake) {\n handshake.close();\n } else {\n transport.close();\n }\n },\n forceMinPriority: p => {\n if (connected) {\n return;\n }\n if (this.priority < p) {\n if (handshake) {\n handshake.close();\n } else {\n transport.close();\n }\n }\n }\n };\n }\n}\n\nfunction failAttempt(error: Error, callback: Function) {\n Util.defer(function() {\n callback(error);\n });\n return {\n abort: function() {},\n forceMinPriority: function() {}\n };\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport TransportManager from '../transports/transport_manager';\nimport * as Errors from '../errors';\nimport Strategy from './strategy';\nimport TransportStrategy from './transport_strategy';\nimport StrategyOptions from '../strategies/strategy_options';\nimport { Config } from '../config';\nimport Runtime from 'runtime';\n\nconst { Transports } = Runtime;\n\nexport var defineTransport = function(\n config: Config,\n name: string,\n type: string,\n priority: number,\n options: StrategyOptions,\n manager?: TransportManager\n): Strategy {\n var transportClass = Transports[type];\n if (!transportClass) {\n throw new Errors.UnsupportedTransport(type);\n }\n\n var enabled =\n (!config.enabledTransports ||\n Collections.arrayIndexOf(config.enabledTransports, name) !== -1) &&\n (!config.disabledTransports ||\n Collections.arrayIndexOf(config.disabledTransports, name) === -1);\n\n var transport;\n if (enabled) {\n options = Object.assign(\n { ignoreNullOrigin: config.ignoreNullOrigin },\n options\n );\n\n transport = new TransportStrategy(\n name,\n priority,\n manager ? manager.getAssistant(transportClass) : transportClass,\n options\n );\n } else {\n transport = UnsupportedStrategy;\n }\n\n return transport;\n};\n\nvar UnsupportedStrategy: Strategy = {\n isSupported: function() {\n return false;\n },\n connect: function(_, callback) {\n var deferred = Util.defer(function() {\n callback(new Errors.UnsupportedStrategy());\n });\n return {\n abort: function() {\n deferred.ensureAborted();\n },\n forceMinPriority: function() {}\n };\n }\n};\n","import ConnectionManager from './connection/connection_manager';\nimport {\n ChannelAuthorizationOptions,\n UserAuthenticationOptions\n} from './auth/options';\nimport {\n ChannelAuthorizerGenerator,\n DeprecatedAuthOptions\n} from './auth/deprecated_channel_authorizer';\nimport { AuthTransport, Transport } from './config';\nimport * as nacl from 'tweetnacl';\nimport Logger from './logger';\n\nexport interface Options {\n activityTimeout?: number;\n\n auth?: DeprecatedAuthOptions; // DEPRECATED use channelAuthorization instead\n authEndpoint?: string; // DEPRECATED use channelAuthorization instead\n authTransport?: AuthTransport; // DEPRECATED use channelAuthorization instead\n authorizer?: ChannelAuthorizerGenerator; // DEPRECATED use channelAuthorization instead\n\n channelAuthorization?: ChannelAuthorizationOptions;\n userAuthentication?: UserAuthenticationOptions;\n\n cluster: string;\n enableStats?: boolean;\n disableStats?: boolean;\n disabledTransports?: Transport[];\n enabledTransports?: Transport[];\n forceTLS?: boolean;\n httpHost?: string;\n httpPath?: string;\n httpPort?: number;\n httpsPort?: number;\n ignoreNullOrigin?: boolean;\n nacl?: nacl;\n pongTimeout?: number;\n statsHost?: string;\n timelineParams?: any;\n unavailableTimeout?: number;\n wsHost?: string;\n wsPath?: string;\n wsPort?: number;\n wssPort?: number;\n}\n\nexport interface ClusterOptions {\n appKey: string;\n cluster: string;\n}\n\nexport function validateOptions(options) {\n if (options == null) {\n throw 'You must pass an options object';\n }\n if (options.cluster == null) {\n throw 'Options object must provide a cluster';\n }\n if ('disableStats' in options) {\n Logger.warn(\n 'The disableStats option is deprecated in favor of enableStats'\n );\n }\n}\n","import {\n UserAuthenticationCallback,\n InternalAuthOptions,\n UserAuthenticationHandler,\n UserAuthenticationRequestParams,\n AuthRequestType\n} from './options';\n\nimport Runtime from 'runtime';\n\nconst composeChannelQuery = (\n params: UserAuthenticationRequestParams,\n authOptions: InternalAuthOptions\n) => {\n var query = 'socket_id=' + encodeURIComponent(params.socketId);\n\n for (var key in authOptions.params) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(authOptions.params[key]);\n }\n\n if (authOptions.paramsProvider != null) {\n let dynamicParams = authOptions.paramsProvider();\n for (var key in dynamicParams) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(dynamicParams[key]);\n }\n }\n\n return query;\n};\n\nconst UserAuthenticator = (\n authOptions: InternalAuthOptions\n): UserAuthenticationHandler => {\n if (typeof Runtime.getAuthorizers()[authOptions.transport] === 'undefined') {\n throw `'${authOptions.transport}' is not a recognized auth transport`;\n }\n\n return (\n params: UserAuthenticationRequestParams,\n callback: UserAuthenticationCallback\n ) => {\n const query = composeChannelQuery(params, authOptions);\n\n Runtime.getAuthorizers()[authOptions.transport](\n Runtime,\n query,\n authOptions,\n AuthRequestType.UserAuthentication,\n callback\n );\n };\n};\n\nexport default UserAuthenticator;\n","import {\n AuthRequestType,\n InternalAuthOptions,\n ChannelAuthorizationHandler,\n ChannelAuthorizationRequestParams,\n ChannelAuthorizationCallback\n} from './options';\n\nimport Runtime from 'runtime';\n\nconst composeChannelQuery = (\n params: ChannelAuthorizationRequestParams,\n authOptions: InternalAuthOptions\n) => {\n var query = 'socket_id=' + encodeURIComponent(params.socketId);\n\n query += '&channel_name=' + encodeURIComponent(params.channelName);\n\n for (var key in authOptions.params) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(authOptions.params[key]);\n }\n\n if (authOptions.paramsProvider != null) {\n let dynamicParams = authOptions.paramsProvider();\n for (var key in dynamicParams) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(dynamicParams[key]);\n }\n }\n\n return query;\n};\n\nconst ChannelAuthorizer = (\n authOptions: InternalAuthOptions\n): ChannelAuthorizationHandler => {\n if (typeof Runtime.getAuthorizers()[authOptions.transport] === 'undefined') {\n throw `'${authOptions.transport}' is not a recognized auth transport`;\n }\n\n return (\n params: ChannelAuthorizationRequestParams,\n callback: ChannelAuthorizationCallback\n ) => {\n const query = composeChannelQuery(params, authOptions);\n\n Runtime.getAuthorizers()[authOptions.transport](\n Runtime,\n query,\n authOptions,\n AuthRequestType.ChannelAuthorization,\n callback\n );\n };\n};\n\nexport default ChannelAuthorizer;\n","import Channel from '../channels/channel';\nimport {\n ChannelAuthorizationCallback,\n ChannelAuthorizationHandler,\n ChannelAuthorizationRequestParams,\n InternalAuthOptions\n} from './options';\n\nexport interface DeprecatedChannelAuthorizer {\n authorize(socketId: string, callback: ChannelAuthorizationCallback): void;\n}\n\nexport interface ChannelAuthorizerGenerator {\n (\n channel: Channel,\n options: DeprecatedAuthorizerOptions\n ): DeprecatedChannelAuthorizer;\n}\n\nexport interface DeprecatedAuthOptions {\n params?: any;\n headers?: any;\n}\n\nexport interface DeprecatedAuthorizerOptions {\n authTransport: 'ajax' | 'jsonp';\n authEndpoint: string;\n auth?: DeprecatedAuthOptions;\n}\n\nexport const ChannelAuthorizerProxy = (\n pusher,\n authOptions: InternalAuthOptions,\n channelAuthorizerGenerator: ChannelAuthorizerGenerator\n): ChannelAuthorizationHandler => {\n const deprecatedAuthorizerOptions: DeprecatedAuthorizerOptions = {\n authTransport: authOptions.transport,\n authEndpoint: authOptions.endpoint,\n auth: {\n params: authOptions.params,\n headers: authOptions.headers\n }\n };\n return (\n params: ChannelAuthorizationRequestParams,\n callback: ChannelAuthorizationCallback\n ) => {\n const channel = pusher.channel(params.channelName);\n // This line creates a new channel authorizer every time.\n // In the past, this was only done once per channel and reused.\n // We can do that again if we want to keep this behavior intact.\n const channelAuthorizer: DeprecatedChannelAuthorizer = channelAuthorizerGenerator(\n channel,\n deprecatedAuthorizerOptions\n );\n channelAuthorizer.authorize(params.socketId, callback);\n };\n};\n","import { Options } from './options';\nimport Defaults from './defaults';\nimport {\n ChannelAuthorizationHandler,\n UserAuthenticationHandler,\n ChannelAuthorizationOptions\n} from './auth/options';\nimport UserAuthenticator from './auth/user_authenticator';\nimport ChannelAuthorizer from './auth/channel_authorizer';\nimport { ChannelAuthorizerProxy } from './auth/deprecated_channel_authorizer';\nimport Runtime from 'runtime';\nimport * as nacl from 'tweetnacl';\n\nexport type AuthTransport = 'ajax' | 'jsonp';\nexport type Transport =\n | 'ws'\n | 'wss'\n | 'xhr_streaming'\n | 'xhr_polling'\n | 'sockjs';\n\nexport interface Config {\n // these are all 'required' config parameters, it's not necessary for the user\n // to set them, but they have configured defaults.\n activityTimeout: number;\n enableStats: boolean;\n httpHost: string;\n httpPath: string;\n httpPort: number;\n httpsPort: number;\n pongTimeout: number;\n statsHost: string;\n unavailableTimeout: number;\n useTLS: boolean;\n wsHost: string;\n wsPath: string;\n wsPort: number;\n wssPort: number;\n userAuthenticator: UserAuthenticationHandler;\n channelAuthorizer: ChannelAuthorizationHandler;\n\n // these are all optional parameters or overrrides. The customer can set these\n // but it's not strictly necessary\n forceTLS?: boolean;\n cluster?: string;\n disabledTransports?: Transport[];\n enabledTransports?: Transport[];\n ignoreNullOrigin?: boolean;\n nacl?: nacl;\n timelineParams?: any;\n}\n\n// getConfig mainly sets the defaults for the options that are not provided\nexport function getConfig(opts: Options, pusher): Config {\n let config: Config = {\n activityTimeout: opts.activityTimeout || Defaults.activityTimeout,\n cluster: opts.cluster,\n httpPath: opts.httpPath || Defaults.httpPath,\n httpPort: opts.httpPort || Defaults.httpPort,\n httpsPort: opts.httpsPort || Defaults.httpsPort,\n pongTimeout: opts.pongTimeout || Defaults.pongTimeout,\n statsHost: opts.statsHost || Defaults.stats_host,\n unavailableTimeout: opts.unavailableTimeout || Defaults.unavailableTimeout,\n wsPath: opts.wsPath || Defaults.wsPath,\n wsPort: opts.wsPort || Defaults.wsPort,\n wssPort: opts.wssPort || Defaults.wssPort,\n\n enableStats: getEnableStatsConfig(opts),\n httpHost: getHttpHost(opts),\n useTLS: shouldUseTLS(opts),\n wsHost: getWebsocketHost(opts),\n\n userAuthenticator: buildUserAuthenticator(opts),\n channelAuthorizer: buildChannelAuthorizer(opts, pusher)\n };\n\n if ('disabledTransports' in opts)\n config.disabledTransports = opts.disabledTransports;\n if ('enabledTransports' in opts)\n config.enabledTransports = opts.enabledTransports;\n if ('ignoreNullOrigin' in opts)\n config.ignoreNullOrigin = opts.ignoreNullOrigin;\n if ('timelineParams' in opts) config.timelineParams = opts.timelineParams;\n if ('nacl' in opts) {\n config.nacl = opts.nacl;\n }\n\n return config;\n}\n\nfunction getHttpHost(opts: Options): string {\n if (opts.httpHost) {\n return opts.httpHost;\n }\n if (opts.cluster) {\n return `sockjs-${opts.cluster}.pusher.com`;\n }\n return Defaults.httpHost;\n}\n\nfunction getWebsocketHost(opts: Options): string {\n if (opts.wsHost) {\n return opts.wsHost;\n }\n return getWebsocketHostFromCluster(opts.cluster);\n}\n\nfunction getWebsocketHostFromCluster(cluster: string): string {\n return `ws-${cluster}.pusher.com`;\n}\n\nfunction shouldUseTLS(opts: Options): boolean {\n if (Runtime.getProtocol() === 'https:') {\n return true;\n } else if (opts.forceTLS === false) {\n return false;\n }\n return true;\n}\n\n// if enableStats is set take the value\n// if disableStats is set take the inverse\n// otherwise default to false\nfunction getEnableStatsConfig(opts: Options): boolean {\n if ('enableStats' in opts) {\n return opts.enableStats;\n }\n if ('disableStats' in opts) {\n return !opts.disableStats;\n }\n return false;\n}\n\nfunction buildUserAuthenticator(opts: Options): UserAuthenticationHandler {\n const userAuthentication = {\n ...Defaults.userAuthentication,\n ...opts.userAuthentication\n };\n if (\n 'customHandler' in userAuthentication &&\n userAuthentication['customHandler'] != null\n ) {\n return userAuthentication['customHandler'];\n }\n\n return UserAuthenticator(userAuthentication);\n}\n\nfunction buildChannelAuth(opts: Options, pusher): ChannelAuthorizationOptions {\n let channelAuthorization: ChannelAuthorizationOptions;\n if ('channelAuthorization' in opts) {\n channelAuthorization = {\n ...Defaults.channelAuthorization,\n ...opts.channelAuthorization\n };\n } else {\n channelAuthorization = {\n transport: opts.authTransport || Defaults.authTransport,\n endpoint: opts.authEndpoint || Defaults.authEndpoint\n };\n if ('auth' in opts) {\n if ('params' in opts.auth) channelAuthorization.params = opts.auth.params;\n if ('headers' in opts.auth)\n channelAuthorization.headers = opts.auth.headers;\n }\n if ('authorizer' in opts)\n channelAuthorization.customHandler = ChannelAuthorizerProxy(\n pusher,\n channelAuthorization,\n opts.authorizer\n );\n }\n return channelAuthorization;\n}\n\nfunction buildChannelAuthorizer(\n opts: Options,\n pusher\n): ChannelAuthorizationHandler {\n const channelAuthorization = buildChannelAuth(opts, pusher);\n if (\n 'customHandler' in channelAuthorization &&\n channelAuthorization['customHandler'] != null\n ) {\n return channelAuthorization['customHandler'];\n }\n\n return ChannelAuthorizer(channelAuthorization);\n}\n","import Logger from './logger';\nimport Pusher from './pusher';\nimport EventsDispatcher from './events/dispatcher';\n\nexport default class WatchlistFacade extends EventsDispatcher {\n private pusher: Pusher;\n\n public constructor(pusher: Pusher) {\n super(function(eventName, data) {\n Logger.debug(`No callbacks on watchlist events for ${eventName}`);\n });\n\n this.pusher = pusher;\n this.bindWatchlistInternalEvent();\n }\n\n handleEvent(pusherEvent) {\n pusherEvent.data.events.forEach(watchlistEvent => {\n this.emit(watchlistEvent.name, watchlistEvent);\n });\n }\n\n private bindWatchlistInternalEvent() {\n this.pusher.connection.bind('message', pusherEvent => {\n var eventName = pusherEvent.event;\n if (eventName === 'pusher_internal:watchlist_events') {\n this.handleEvent(pusherEvent);\n }\n });\n }\n}\n","function flatPromise() {\n let resolve, reject;\n const promise = new Promise((res, rej) => {\n resolve = res;\n reject = rej;\n });\n return { promise, resolve, reject };\n}\n\nexport default flatPromise;\n","import Pusher from './pusher';\nimport Logger from './logger';\nimport {\n UserAuthenticationData,\n UserAuthenticationCallback\n} from './auth/options';\nimport Channel from './channels/channel';\nimport WatchlistFacade from './watchlist';\nimport EventsDispatcher from './events/dispatcher';\nimport flatPromise from './utils/flat_promise';\n\nexport default class UserFacade extends EventsDispatcher {\n pusher: Pusher;\n signin_requested: boolean = false;\n user_data: any = null;\n serverToUserChannel: Channel = null;\n signinDonePromise: Promise = null;\n watchlist: WatchlistFacade;\n private _signinDoneResolve: Function = null;\n\n public constructor(pusher: Pusher) {\n super(function(eventName, data) {\n Logger.debug('No callbacks on user for ' + eventName);\n });\n this.pusher = pusher;\n this.pusher.connection.bind('state_change', ({ previous, current }) => {\n if (previous !== 'connected' && current === 'connected') {\n this._signin();\n }\n if (previous === 'connected' && current !== 'connected') {\n this._cleanup();\n this._newSigninPromiseIfNeeded();\n }\n });\n\n this.watchlist = new WatchlistFacade(pusher);\n\n this.pusher.connection.bind('message', event => {\n var eventName = event.event;\n if (eventName === 'pusher:signin_success') {\n this._onSigninSuccess(event.data);\n }\n if (\n this.serverToUserChannel &&\n this.serverToUserChannel.name === event.channel\n ) {\n this.serverToUserChannel.handleEvent(event);\n }\n });\n }\n\n public signin() {\n if (this.signin_requested) {\n return;\n }\n\n this.signin_requested = true;\n this._signin();\n }\n\n private _signin() {\n if (!this.signin_requested) {\n return;\n }\n\n this._newSigninPromiseIfNeeded();\n\n if (this.pusher.connection.state !== 'connected') {\n // Signin will be attempted when the connection is connected\n return;\n }\n\n this.pusher.config.userAuthenticator(\n {\n socketId: this.pusher.connection.socket_id\n },\n this._onAuthorize\n );\n }\n\n private _onAuthorize: UserAuthenticationCallback = (\n err,\n authData: UserAuthenticationData\n ) => {\n if (err) {\n Logger.warn(`Error during signin: ${err}`);\n this._cleanup();\n return;\n }\n\n this.pusher.send_event('pusher:signin', {\n auth: authData.auth,\n user_data: authData.user_data\n });\n\n // Later when we get pusher:singin_success event, the user will be marked as signed in\n };\n\n private _onSigninSuccess(data: any) {\n try {\n this.user_data = JSON.parse(data.user_data);\n } catch (e) {\n Logger.error(`Failed parsing user data after signin: ${data.user_data}`);\n this._cleanup();\n return;\n }\n\n if (typeof this.user_data.id !== 'string' || this.user_data.id === '') {\n Logger.error(\n `user_data doesn't contain an id. user_data: ${this.user_data}`\n );\n this._cleanup();\n return;\n }\n\n // Signin succeeded\n this._signinDoneResolve();\n this._subscribeChannels();\n }\n\n private _subscribeChannels() {\n const ensure_subscribed = channel => {\n if (channel.subscriptionPending && channel.subscriptionCancelled) {\n channel.reinstateSubscription();\n } else if (\n !channel.subscriptionPending &&\n this.pusher.connection.state === 'connected'\n ) {\n channel.subscribe();\n }\n };\n\n this.serverToUserChannel = new Channel(\n `#server-to-user-${this.user_data.id}`,\n this.pusher\n );\n this.serverToUserChannel.bind_global((eventName, data) => {\n if (\n eventName.indexOf('pusher_internal:') === 0 ||\n eventName.indexOf('pusher:') === 0\n ) {\n // ignore internal events\n return;\n }\n this.emit(eventName, data);\n });\n ensure_subscribed(this.serverToUserChannel);\n }\n\n private _cleanup() {\n this.user_data = null;\n if (this.serverToUserChannel) {\n this.serverToUserChannel.unbind_all();\n this.serverToUserChannel.disconnect();\n this.serverToUserChannel = null;\n }\n\n if (this.signin_requested) {\n // If signin is in progress and cleanup is called,\n // Mark the current signin process as done.\n this._signinDoneResolve();\n }\n }\n\n private _newSigninPromiseIfNeeded() {\n if (!this.signin_requested) {\n return;\n }\n\n // If there is a promise and it is not resolved, return without creating a new one.\n if (this.signinDonePromise && !(this.signinDonePromise as any).done) {\n return;\n }\n\n // This promise is never rejected.\n // It gets resolved when the signin process is done whether it failed or succeeded\n const { promise, resolve, reject: _ } = flatPromise();\n (promise as any).done = false;\n const setDone = () => {\n (promise as any).done = true;\n };\n promise.then(setDone).catch(setDone);\n this.signinDonePromise = promise;\n this._signinDoneResolve = resolve;\n }\n}\n","import AbstractRuntime from '../runtimes/interface';\nimport Runtime from 'runtime';\nimport * as Collections from './utils/collections';\nimport Channels from './channels/channels';\nimport Channel from './channels/channel';\nimport { default as EventsDispatcher } from './events/dispatcher';\nimport Timeline from './timeline/timeline';\nimport TimelineSender from './timeline/timeline_sender';\nimport TimelineLevel from './timeline/level';\nimport { defineTransport } from './strategies/strategy_builder';\nimport ConnectionManager from './connection/connection_manager';\nimport { PeriodicTimer } from './utils/timers';\nimport Defaults from './defaults';\nimport Logger from './logger';\nimport Factory from './utils/factory';\nimport { Options, ClusterOptions, validateOptions } from './options';\nimport { Config, getConfig } from './config';\nimport StrategyOptions from './strategies/strategy_options';\nimport UserFacade from './user';\n\nexport default class Pusher {\n /* STATIC PROPERTIES */\n static instances: Pusher[] = [];\n static isReady: boolean = false;\n static logToConsole: boolean = false;\n\n // for jsonp\n static Runtime: AbstractRuntime = Runtime;\n static ScriptReceivers: any = (Runtime).ScriptReceivers;\n static DependenciesReceivers: any = (Runtime).DependenciesReceivers;\n static auth_callbacks: any = (Runtime).auth_callbacks;\n\n static ready() {\n Pusher.isReady = true;\n for (var i = 0, l = Pusher.instances.length; i < l; i++) {\n Pusher.instances[i].connect();\n }\n }\n\n static log: (message: any) => void;\n\n private static getClientFeatures(): string[] {\n return Collections.keys(\n Collections.filterObject({ ws: Runtime.Transports.ws }, function(t) {\n return t.isSupported({});\n })\n );\n }\n\n /* INSTANCE PROPERTIES */\n key: string;\n options: Options;\n config: Config;\n channels: Channels;\n global_emitter: EventsDispatcher;\n sessionID: number;\n timeline: Timeline;\n timelineSender: TimelineSender;\n connection: ConnectionManager;\n timelineSenderTimer: PeriodicTimer;\n user: UserFacade;\n constructor(app_key: string, options: Options) {\n checkAppKey(app_key);\n validateOptions(options);\n this.key = app_key;\n this.config = getConfig(options, this);\n\n this.channels = Factory.createChannels();\n this.global_emitter = new EventsDispatcher();\n this.sessionID = Runtime.randomInt(1000000000);\n\n this.timeline = new Timeline(this.key, this.sessionID, {\n cluster: this.config.cluster,\n features: Pusher.getClientFeatures(),\n params: this.config.timelineParams || {},\n limit: 50,\n level: TimelineLevel.INFO,\n version: Defaults.VERSION\n });\n if (this.config.enableStats) {\n this.timelineSender = Factory.createTimelineSender(this.timeline, {\n host: this.config.statsHost,\n path: '/timeline/v2/' + Runtime.TimelineTransport.name\n });\n }\n\n var getStrategy = (options: StrategyOptions) => {\n return Runtime.getDefaultStrategy(this.config, options, defineTransport);\n };\n\n this.connection = Factory.createConnectionManager(this.key, {\n getStrategy: getStrategy,\n timeline: this.timeline,\n activityTimeout: this.config.activityTimeout,\n pongTimeout: this.config.pongTimeout,\n unavailableTimeout: this.config.unavailableTimeout,\n useTLS: Boolean(this.config.useTLS)\n });\n\n this.connection.bind('connected', () => {\n this.subscribeAll();\n if (this.timelineSender) {\n this.timelineSender.send(this.connection.isUsingTLS());\n }\n });\n\n this.connection.bind('message', event => {\n var eventName = event.event;\n var internal = eventName.indexOf('pusher_internal:') === 0;\n if (event.channel) {\n var channel = this.channel(event.channel);\n if (channel) {\n channel.handleEvent(event);\n }\n }\n // Emit globally [deprecated]\n if (!internal) {\n this.global_emitter.emit(event.event, event.data);\n }\n });\n this.connection.bind('connecting', () => {\n this.channels.disconnect();\n });\n this.connection.bind('disconnected', () => {\n this.channels.disconnect();\n });\n this.connection.bind('error', err => {\n Logger.warn(err);\n });\n\n Pusher.instances.push(this);\n this.timeline.info({ instances: Pusher.instances.length });\n\n this.user = new UserFacade(this);\n\n if (Pusher.isReady) {\n this.connect();\n }\n }\n\n /**\n * Allows you to switch Pusher cluster without\n * losing all the channels/subscription binding\n * as this is internally managed by the SDK.\n */\n switchCluster(options: ClusterOptions) {\n const { appKey, cluster } = options;\n this.key = appKey;\n this.options = { ...this.options, cluster };\n this.config = getConfig(this.options, this);\n this.connection.switchCluster(this.key);\n }\n\n channel(name: string): Channel {\n return this.channels.find(name);\n }\n\n allChannels(): Channel[] {\n return this.channels.all();\n }\n\n connect() {\n this.connection.connect();\n\n if (this.timelineSender) {\n if (!this.timelineSenderTimer) {\n var usingTLS = this.connection.isUsingTLS();\n var timelineSender = this.timelineSender;\n this.timelineSenderTimer = new PeriodicTimer(60000, function() {\n timelineSender.send(usingTLS);\n });\n }\n }\n }\n\n disconnect() {\n this.connection.disconnect();\n\n if (this.timelineSenderTimer) {\n this.timelineSenderTimer.ensureAborted();\n this.timelineSenderTimer = null;\n }\n }\n\n bind(event_name: string, callback: Function, context?: any): Pusher {\n this.global_emitter.bind(event_name, callback, context);\n return this;\n }\n\n unbind(event_name?: string, callback?: Function, context?: any): Pusher {\n this.global_emitter.unbind(event_name, callback, context);\n return this;\n }\n\n bind_global(callback: Function): Pusher {\n this.global_emitter.bind_global(callback);\n return this;\n }\n\n unbind_global(callback?: Function): Pusher {\n this.global_emitter.unbind_global(callback);\n return this;\n }\n\n unbind_all(callback?: Function): Pusher {\n this.global_emitter.unbind_all();\n return this;\n }\n\n subscribeAll() {\n var channelName;\n for (channelName in this.channels.channels) {\n if (this.channels.channels.hasOwnProperty(channelName)) {\n this.subscribe(channelName);\n }\n }\n }\n\n subscribe(channel_name: string) {\n var channel = this.channels.add(channel_name, this);\n if (channel.subscriptionPending && channel.subscriptionCancelled) {\n channel.reinstateSubscription();\n } else if (\n !channel.subscriptionPending &&\n this.connection.state === 'connected'\n ) {\n channel.subscribe();\n }\n return channel;\n }\n\n unsubscribe(channel_name: string) {\n var channel = this.channels.find(channel_name);\n if (channel && channel.subscriptionPending) {\n channel.cancelSubscription();\n } else {\n channel = this.channels.remove(channel_name);\n if (channel && channel.subscribed) {\n channel.unsubscribe();\n }\n }\n }\n\n send_event(event_name: string, data: any, channel?: string) {\n return this.connection.send_event(event_name, data, channel);\n }\n\n shouldUseTLS(): boolean {\n return this.config.useTLS;\n }\n\n signin() {\n this.user.signin();\n }\n}\n\nfunction checkAppKey(key) {\n if (key === null || key === undefined) {\n throw 'You must pass your app key when you instantiate Pusher.';\n }\n}\n\nRuntime.setup(Pusher);\n","import Pusher from './pusher';\nimport { Options, validateOptions } from './options';\nimport * as nacl from 'tweetnacl';\n\nexport default class PusherWithEncryption extends Pusher {\n constructor(app_key: string, options: Options) {\n Pusher.logToConsole = PusherWithEncryption.logToConsole;\n Pusher.log = PusherWithEncryption.log;\n\n validateOptions(options);\n options.nacl = nacl;\n super(app_key, options);\n }\n}\n"],"sourceRoot":""} \ No newline at end of file diff --git a/dist/react-native/pusher.js b/dist/react-native/pusher.js index 002b85796..a2bef6c82 100644 --- a/dist/react-native/pusher.js +++ b/dist/react-native/pusher.js @@ -1,9 +1,9 @@ /*! - * Pusher JavaScript Library v8.3.0 + * Pusher JavaScript Library v8.4.0 * https://pusher.com/ * * Copyright 2020, Pusher * Released under the MIT licence. */ -module.exports=function(t){var e={};function n(r){if(e[r])return e[r].exports;var i=e[r]={i:r,l:!1,exports:{}};return t[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)n.d(r,i,function(e){return t[e]}.bind(null,i));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=15)}([function(t,e,n){"use strict";(function(t){n.d(e,"f",(function(){return s})),n.d(e,"m",(function(){return o})),n.d(e,"d",(function(){return a})),n.d(e,"k",(function(){return h})),n.d(e,"i",(function(){return c})),n.d(e,"n",(function(){return u})),n.d(e,"c",(function(){return l})),n.d(e,"j",(function(){return d})),n.d(e,"g",(function(){return f})),n.d(e,"h",(function(){return p})),n.d(e,"b",(function(){return g})),n.d(e,"a",(function(){return b})),n.d(e,"e",(function(){return y})),n.d(e,"l",(function(){return m}));var r=n(11),i=n(2);function s(t,...e){for(var n=0;n{t.console&&t.console.log&&t.console.log(e)}}debug(...t){this.log(this.globalLog,t)}warn(...t){this.log(this.globalLogWarn,t)}error(...t){this.log(this.globalLogError,t)}globalLogWarn(e){t.console&&t.console.warn?t.console.warn(e):this.globalLog(e)}globalLogError(e){t.console&&t.console.error?t.console.error(e):this.globalLogWarn(e)}log(t,...e){var n=r.m.apply(this,arguments);if(i.a.log)i.a.log(n);else if(i.a.logToConsole){t.bind(this)(n)}}}}).call(this,n(6))},function(t,e,n){"use strict";var r=n(4),i={now:()=>Date.now?Date.now():(new Date).valueOf(),defer:t=>new r.a(0,t),method(t,...e){var n=Array.prototype.slice.call(arguments,1);return function(e){return e[t].apply(e,n.concat(arguments))}}};e.a=i},function(t,e,n){"use strict";(function(t){n.d(e,"a",(function(){return s}));var r=n(0),i=n(12);class s{constructor(t){this.callbacks=new i.a,this.global_callbacks=[],this.failThrough=t}bind(t,e,n){return this.callbacks.add(t,e,n),this}bind_global(t){return this.global_callbacks.push(t),this}unbind(t,e,n){return this.callbacks.remove(t,e,n),this}unbind_global(t){return t?(this.global_callbacks=r.g(this.global_callbacks||[],e=>e!==t),this):(this.global_callbacks=[],this)}unbind_all(){return this.unbind(),this.unbind_global(),this}emit(e,n,r){for(var i=0;i0)for(i=0;i{this.onError(t),this.changeState("closed")}),!1}return this.bindListeners(),l.a.debug("Connecting",{transport:this.name,url:t}),this.changeState("connecting"),!0}close(){return!!this.socket&&(this.socket.close(),!0)}send(t){return"open"===this.state&&(c.a.defer(()=>{this.socket&&this.socket.send(t)}),!0)}ping(){"open"===this.state&&this.supportsPing()&&this.socket.ping()}onOpen(){this.hooks.beforeOpen&&this.hooks.beforeOpen(this.socket,this.hooks.urls.getPath(this.key,this.options)),this.changeState("open"),this.socket.onopen=void 0}onError(t){this.emit("error",{type:"WebSocketError",error:t}),this.timeline.error(this.buildTimelineMessage({error:t.toString()}))}onClose(t){t?this.changeState("closed",{code:t.code,reason:t.reason,wasClean:t.wasClean}):this.changeState("closed"),this.unbindListeners(),this.socket=void 0}onMessage(t){this.emit("message",t)}onActivity(){this.emit("activity")}bindListeners(){this.socket.onopen=()=>{this.onOpen()},this.socket.onerror=t=>{this.onError(t)},this.socket.onclose=t=>{this.onClose(t)},this.socket.onmessage=t=>{this.onMessage(t)},this.supportsPing()&&(this.socket.onactivity=()=>{this.onActivity()})}unbindListeners(){this.socket&&(this.socket.onopen=void 0,this.socket.onerror=void 0,this.socket.onclose=void 0,this.socket.onmessage=void 0,this.supportsPing()&&(this.socket.onactivity=void 0))}changeState(t,e){this.state=t,this.timeline.info(this.buildTimelineMessage({state:t,params:e})),this.emit(t,e)}buildTimelineMessage(t){return r.f({cid:this.id},t)}}class f{constructor(t){this.hooks=t}isSupported(t){return this.hooks.isSupported(t)}createConnection(t,e,n,r){return new d(this.hooks,t,e,n,r)}}var p=new f({urls:a,handlesActivityChecks:!1,supportsPing:!1,isInitialized:function(){return Boolean(zt.getWebSocketAPI())},isSupported:function(){return Boolean(zt.getWebSocketAPI())},getSocket:function(t){return zt.createWebSocket(t)}}),g={urls:h,handlesActivityChecks:!1,supportsPing:!0,isInitialized:function(){return!0}},b=r.f({getSocket:function(t){return zt.HTTPFactory.createStreamingSocket(t)}},g),v=r.f({getSocket:function(t){return zt.HTTPFactory.createPollingSocket(t)}},g),y={isSupported:function(){return zt.isXHRSupported()}},m={ws:p,xhr_streaming:new f(r.f({},b,y)),xhr_polling:new f(r.f({},v,y))};class w{constructor(t,e,n){this.manager=t,this.transport=e,this.minPingDelay=n.minPingDelay,this.maxPingDelay=n.maxPingDelay,this.pingDelay=void 0}createConnection(t,e,n,i){i=r.f({},i,{activityTimeout:this.pingDelay});var s=this.transport.createConnection(t,e,n,i),o=null,a=function(){s.unbind("open",a),s.bind("closed",h),o=c.a.now()},h=t=>{if(s.unbind("closed",h),1002===t.code||1003===t.code)this.manager.reportDeath();else if(!t.wasClean&&o){var e=c.a.now()-o;e<2*this.maxPingDelay&&(this.manager.reportDeath(),this.pingDelay=Math.max(e/2,this.minPingDelay))}};return s.bind("open",a),s}isSupported(t){return this.manager.isAlive()&&this.transport.isSupported(t)}}const _={decodeMessage:function(t){try{var e=JSON.parse(t.data),n=e.data;if("string"==typeof n)try{n=JSON.parse(e.data)}catch(t){}var r={event:e.event,channel:e.channel,data:n};return e.user_id&&(r.user_id=e.user_id),r}catch(e){throw{type:"MessageParseError",error:e,data:t.data}}},encodeMessage:function(t){return JSON.stringify(t)},processHandshake:function(t){var e=_.decodeMessage(t);if("pusher:connection_established"===e.event){if(!e.data.activity_timeout)throw"No activity timeout specified in handshake";return{action:"connected",id:e.data.socket_id,activityTimeout:1e3*e.data.activity_timeout}}if("pusher:error"===e.event)return{action:this.getCloseAction(e.data),error:this.getCloseError(e.data)};throw"Invalid handshake"},getCloseAction:function(t){return t.code<4e3?t.code>=1002&&t.code<=1004?"backoff":null:4e3===t.code?"tls_only":t.code<4100?"refused":t.code<4200?"backoff":t.code<4300?"retry":"refused"},getCloseError:function(t){return 1e3!==t.code&&1001!==t.code?{type:"PusherError",data:{code:t.code,message:t.reason||t.message}}:null}};var S=_;class k extends u.a{constructor(t,e){super(),this.id=t,this.transport=e,this.activityTimeout=e.activityTimeout,this.bindListeners()}handlesActivityChecks(){return this.transport.handlesActivityChecks()}send(t){return this.transport.send(t)}send_event(t,e,n){var r={event:t,data:e};return n&&(r.channel=n),l.a.debug("Event sent",r),this.send(S.encodeMessage(r))}ping(){this.transport.supportsPing()?this.transport.ping():this.send_event("pusher:ping",{})}close(){this.transport.close()}bindListeners(){var t={message:t=>{var e;try{e=S.decodeMessage(t)}catch(e){this.emit("error",{type:"MessageParseError",error:e,data:t.data})}if(void 0!==e){switch(l.a.debug("Event recd",e),e.event){case"pusher:error":this.emit("error",{type:"PusherError",data:e.data});break;case"pusher:ping":this.emit("ping");break;case"pusher:pong":this.emit("pong")}this.emit("message",e)}},activity:()=>{this.emit("activity")},error:t=>{this.emit("error",t)},closed:t=>{e(),t&&t.code&&this.handleCloseEvent(t),this.transport=null,this.emit("closed")}},e=()=>{r.k(t,(t,e)=>{this.transport.unbind(e,t)})};r.k(t,(t,e)=>{this.transport.bind(e,t)})}handleCloseEvent(t){var e=S.getCloseAction(t),n=S.getCloseError(t);n&&this.emit("error",n),e&&this.emit(e,{action:e,error:n})}}class C{constructor(t,e){this.transport=t,this.callback=e,this.bindListeners()}close(){this.unbindListeners(),this.transport.close()}bindListeners(){this.onMessage=t=>{var e;this.unbindListeners();try{e=S.processHandshake(t)}catch(t){return this.finish("error",{error:t}),void this.transport.close()}"connected"===e.action?this.finish("connected",{connection:new k(e.id,this.transport),activityTimeout:e.activityTimeout}):(this.finish(e.action,{error:e.error}),this.transport.close())},this.onClosed=t=>{this.unbindListeners();var e=S.getCloseAction(t)||"backoff",n=S.getCloseError(t);this.finish(e,{error:n})},this.transport.bind("message",this.onMessage),this.transport.bind("closed",this.onClosed)}unbindListeners(){this.transport.unbind("message",this.onMessage),this.transport.unbind("closed",this.onClosed)}finish(t,e){this.callback(r.f({transport:this.transport,action:t},e))}}class T{constructor(t,e){this.timeline=t,this.options=e||{}}send(t,e){this.timeline.isEmpty()||this.timeline.send(zt.TimelineTransport.getAgent(this,t),e)}}class E extends Error{constructor(t){super(t),Object.setPrototypeOf(this,new.target.prototype)}}class A extends Error{constructor(t){super(t),Object.setPrototypeOf(this,new.target.prototype)}}Error;class P extends Error{constructor(t){super(t),Object.setPrototypeOf(this,new.target.prototype)}}class x extends Error{constructor(t){super(t),Object.setPrototypeOf(this,new.target.prototype)}}class O extends Error{constructor(t){super(t),Object.setPrototypeOf(this,new.target.prototype)}}class L extends Error{constructor(t){super(t),Object.setPrototypeOf(this,new.target.prototype)}}class U extends Error{constructor(t){super(t),Object.setPrototypeOf(this,new.target.prototype)}}class R extends Error{constructor(t,e){super(e),this.status=t,Object.setPrototypeOf(this,new.target.prototype)}}const M={baseUrl:"https://pusher.com",urls:{authenticationEndpoint:{path:"/docs/channels/server_api/authenticating_users"},authorizationEndpoint:{path:"/docs/channels/server_api/authorizing-users/"},javascriptQuickStart:{path:"/docs/javascript_quick_start"},triggeringClientEvents:{path:"/docs/client_api_guide/client_events#trigger-events"},encryptedChannelSupport:{fullUrl:"https://github.com/pusher/pusher-js/tree/cc491015371a4bde5743d1c87a0fbac0feb53195#encrypted-channel-support"}}};var I=function(t){const e=M.urls[t];if(!e)return"";let n;return e.fullUrl?n=e.fullUrl:e.path&&(n=M.baseUrl+e.path),n?"See: "+n:""};class N extends u.a{constructor(t,e){super((function(e,n){l.a.debug("No callbacks on "+t+" for "+e)})),this.name=t,this.pusher=e,this.subscribed=!1,this.subscriptionPending=!1,this.subscriptionCancelled=!1}authorize(t,e){return e(null,{auth:""})}trigger(t,e){if(0!==t.indexOf("client-"))throw new E("Event '"+t+"' does not start with 'client-'");if(!this.subscribed){var n=I("triggeringClientEvents");l.a.warn("Client event triggered before channel 'subscription_succeeded' event . "+n)}return this.pusher.send_event(t,e,this.name)}disconnect(){this.subscribed=!1,this.subscriptionPending=!1}handleEvent(t){var e=t.event,n=t.data;if("pusher_internal:subscription_succeeded"===e)this.handleSubscriptionSucceededEvent(t);else if("pusher_internal:subscription_count"===e)this.handleSubscriptionCountEvent(t);else if(0!==e.indexOf("pusher_internal:")){this.emit(e,n,{})}}handleSubscriptionSucceededEvent(t){this.subscriptionPending=!1,this.subscribed=!0,this.subscriptionCancelled?this.pusher.unsubscribe(this.name):this.emit("pusher:subscription_succeeded",t.data)}handleSubscriptionCountEvent(t){t.data.subscription_count&&(this.subscriptionCount=t.data.subscription_count),this.emit("pusher:subscription_count",t.data)}subscribe(){this.subscribed||(this.subscriptionPending=!0,this.subscriptionCancelled=!1,this.authorize(this.pusher.connection.socket_id,(t,e)=>{t?(this.subscriptionPending=!1,l.a.error(t.toString()),this.emit("pusher:subscription_error",Object.assign({},{type:"AuthError",error:t.message},t instanceof R?{status:t.status}:{}))):this.pusher.send_event("pusher:subscribe",{auth:e.auth,channel_data:e.channel_data,channel:this.name})}))}unsubscribe(){this.subscribed=!1,this.pusher.send_event("pusher:unsubscribe",{channel:this.name})}cancelSubscription(){this.subscriptionCancelled=!0}reinstateSubscription(){this.subscriptionCancelled=!1}}class j extends N{authorize(t,e){return this.pusher.config.channelAuthorizer({channelName:this.name,socketId:t},e)}}class D{constructor(){this.reset()}get(t){return Object.prototype.hasOwnProperty.call(this.members,t)?{id:t,info:this.members[t]}:null}each(t){r.k(this.members,(e,n)=>{t(this.get(n))})}setMyID(t){this.myID=t}onSubscription(t){this.members=t.presence.hash,this.count=t.presence.count,this.me=this.get(this.myID)}addMember(t){return null===this.get(t.user_id)&&this.count++,this.members[t.user_id]=t.user_info,this.get(t.user_id)}removeMember(t){var e=this.get(t.user_id);return e&&(delete this.members[t.user_id],this.count--),e}reset(){this.members={},this.count=0,this.myID=null,this.me=null}}var z=function(t,e,n,r){return new(n||(n=Promise))((function(i,s){function o(t){try{h(r.next(t))}catch(t){s(t)}}function a(t){try{h(r.throw(t))}catch(t){s(t)}}function h(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(o,a)}h((r=r.apply(t,e||[])).next())}))};class H extends j{constructor(t,e){super(t,e),this.members=new D}authorize(t,e){super.authorize(t,(t,n)=>z(this,void 0,void 0,(function*(){if(!t)if(null!=(n=n).channel_data){var r=JSON.parse(n.channel_data);this.members.setMyID(r.user_id)}else{if(yield this.pusher.user.signinDonePromise,null==this.pusher.user.user_data){let t=I("authorizationEndpoint");return l.a.error(`Invalid auth response for channel '${this.name}', expected 'channel_data' field. ${t}, or the user should be signed in.`),void e("Invalid auth response")}this.members.setMyID(this.pusher.user.user_data.id)}e(t,n)})))}handleEvent(t){var e=t.event;if(0===e.indexOf("pusher_internal:"))this.handleInternalEvent(t);else{var n=t.data,r={};t.user_id&&(r.user_id=t.user_id),this.emit(e,n,r)}}handleInternalEvent(t){var e=t.event,n=t.data;switch(e){case"pusher_internal:subscription_succeeded":this.handleSubscriptionSucceededEvent(t);break;case"pusher_internal:subscription_count":this.handleSubscriptionCountEvent(t);break;case"pusher_internal:member_added":var r=this.members.addMember(n);this.emit("pusher:member_added",r);break;case"pusher_internal:member_removed":var i=this.members.removeMember(n);i&&this.emit("pusher:member_removed",i)}}handleSubscriptionSucceededEvent(t){this.subscriptionPending=!1,this.subscribed=!0,this.subscriptionCancelled?this.pusher.unsubscribe(this.name):(this.members.onSubscription(t.data),this.emit("pusher:subscription_succeeded",this.members))}disconnect(){this.members.reset(),super.disconnect()}}var B=n(13),F=n(8);class q extends j{constructor(t,e,n){super(t,e),this.key=null,this.nacl=n}authorize(t,e){super.authorize(t,(t,n)=>{if(t)return void e(t,n);let r=n.shared_secret;r?(this.key=Object(F.decode)(r),delete n.shared_secret,e(null,n)):e(new Error("No shared_secret key in auth payload for encrypted channel: "+this.name),null)})}trigger(t,e){throw new O("Client events are not currently supported for encrypted channels")}handleEvent(t){var e=t.event,n=t.data;0!==e.indexOf("pusher_internal:")&&0!==e.indexOf("pusher:")?this.handleEncryptedEvent(e,n):super.handleEvent(t)}handleEncryptedEvent(t,e){if(!this.key)return void l.a.debug("Received encrypted event before key has been retrieved from the authEndpoint");if(!e.ciphertext||!e.nonce)return void l.a.error("Unexpected format for encrypted event, expected object with `ciphertext` and `nonce` fields, got: "+e);let n=Object(F.decode)(e.ciphertext);if(n.length{e?l.a.error(`Failed to make a request to the authEndpoint: ${s}. Unable to fetch new key, so dropping encrypted event`):(i=this.nacl.secretbox.open(n,r,this.key),null!==i?this.emit(t,this.getDataToEmit(i)):l.a.error("Failed to decrypt event with new key. Dropping encrypted event"))});this.emit(t,this.getDataToEmit(i))}getDataToEmit(t){let e=Object(B.decode)(t);try{return JSON.parse(e)}catch(t){return e}}}var Y=n(4);class K extends u.a{constructor(t,e){super(),this.state="initialized",this.connection=null,this.key=t,this.options=e,this.timeline=this.options.timeline,this.usingTLS=this.options.useTLS,this.errorCallbacks=this.buildErrorCallbacks(),this.connectionCallbacks=this.buildConnectionCallbacks(this.errorCallbacks),this.handshakeCallbacks=this.buildHandshakeCallbacks(this.errorCallbacks);var n=zt.getNetwork();n.bind("online",()=>{this.timeline.info({netinfo:"online"}),"connecting"!==this.state&&"unavailable"!==this.state||this.retryIn(0)}),n.bind("offline",()=>{this.timeline.info({netinfo:"offline"}),this.connection&&this.sendActivityCheck()}),this.updateStrategy()}connect(){this.connection||this.runner||(this.strategy.isSupported()?(this.updateState("connecting"),this.startConnecting(),this.setUnavailableTimer()):this.updateState("failed"))}send(t){return!!this.connection&&this.connection.send(t)}send_event(t,e,n){return!!this.connection&&this.connection.send_event(t,e,n)}disconnect(){this.disconnectInternally(),this.updateState("disconnected")}isUsingTLS(){return this.usingTLS}startConnecting(){var t=(e,n)=>{e?this.runner=this.strategy.connect(0,t):"error"===n.action?(this.emit("error",{type:"HandshakeError",error:n.error}),this.timeline.error({handshakeError:n.error})):(this.abortConnecting(),this.handshakeCallbacks[n.action](n))};this.runner=this.strategy.connect(0,t)}abortConnecting(){this.runner&&(this.runner.abort(),this.runner=null)}disconnectInternally(){(this.abortConnecting(),this.clearRetryTimer(),this.clearUnavailableTimer(),this.connection)&&this.abandonConnection().close()}updateStrategy(){this.strategy=this.options.getStrategy({key:this.key,timeline:this.timeline,useTLS:this.usingTLS})}retryIn(t){this.timeline.info({action:"retry",delay:t}),t>0&&this.emit("connecting_in",Math.round(t/1e3)),this.retryTimer=new Y.a(t||0,()=>{this.disconnectInternally(),this.connect()})}clearRetryTimer(){this.retryTimer&&(this.retryTimer.ensureAborted(),this.retryTimer=null)}setUnavailableTimer(){this.unavailableTimer=new Y.a(this.options.unavailableTimeout,()=>{this.updateState("unavailable")})}clearUnavailableTimer(){this.unavailableTimer&&this.unavailableTimer.ensureAborted()}sendActivityCheck(){this.stopActivityCheck(),this.connection.ping(),this.activityTimer=new Y.a(this.options.pongTimeout,()=>{this.timeline.error({pong_timed_out:this.options.pongTimeout}),this.retryIn(0)})}resetActivityCheck(){this.stopActivityCheck(),this.connection&&!this.connection.handlesActivityChecks()&&(this.activityTimer=new Y.a(this.activityTimeout,()=>{this.sendActivityCheck()}))}stopActivityCheck(){this.activityTimer&&this.activityTimer.ensureAborted()}buildConnectionCallbacks(t){return r.f({},t,{message:t=>{this.resetActivityCheck(),this.emit("message",t)},ping:()=>{this.send_event("pusher:pong",{})},activity:()=>{this.resetActivityCheck()},error:t=>{this.emit("error",t)},closed:()=>{this.abandonConnection(),this.shouldRetry()&&this.retryIn(1e3)}})}buildHandshakeCallbacks(t){return r.f({},t,{connected:t=>{this.activityTimeout=Math.min(this.options.activityTimeout,t.activityTimeout,t.connection.activityTimeout||1/0),this.clearUnavailableTimer(),this.setConnection(t.connection),this.socket_id=this.connection.id,this.updateState("connected",{socket_id:this.socket_id})}})}buildErrorCallbacks(){let t=t=>e=>{e.error&&this.emit("error",{type:"WebSocketError",error:e.error}),t(e)};return{tls_only:t(()=>{this.usingTLS=!0,this.updateStrategy(),this.retryIn(0)}),refused:t(()=>{this.disconnect()}),backoff:t(()=>{this.retryIn(1e3)}),retry:t(()=>{this.retryIn(0)})}}setConnection(t){for(var e in this.connection=t,this.connectionCallbacks)this.connection.bind(e,this.connectionCallbacks[e]);this.resetActivityCheck()}abandonConnection(){if(this.connection){for(var t in this.stopActivityCheck(),this.connectionCallbacks)this.connection.unbind(t,this.connectionCallbacks[t]);var e=this.connection;return this.connection=null,e}}updateState(t,e){var n=this.state;if(this.state=t,n!==t){var r=t;"connected"===r&&(r+=" with new socket ID "+e.socket_id),l.a.debug("State changed",n+" -> "+r),this.timeline.info({state:t,params:e}),this.emit("state_change",{previous:n,current:t}),this.emit(t,e)}}shouldRetry(){return"connecting"===this.state||"connected"===this.state}}class ${constructor(){this.channels={}}add(t,e){return this.channels[t]||(this.channels[t]=function(t,e){if(0===t.indexOf("private-encrypted-")){if(e.config.nacl)return J.createEncryptedChannel(t,e,e.config.nacl);let n="Tried to subscribe to a private-encrypted- channel but no nacl implementation available",r=I("encryptedChannelSupport");throw new O(`${n}. ${r}`)}if(0===t.indexOf("private-"))return J.createPrivateChannel(t,e);if(0===t.indexOf("presence-"))return J.createPresenceChannel(t,e);if(0===t.indexOf("#"))throw new A('Cannot create a channel with name "'+t+'".');return J.createChannel(t,e)}(t,e)),this.channels[t]}all(){return r.n(this.channels)}find(t){return this.channels[t]}remove(t){var e=this.channels[t];return delete this.channels[t],e}disconnect(){r.k(this.channels,(function(t){t.disconnect()}))}}var J={createChannels:()=>new $,createConnectionManager:(t,e)=>new K(t,e),createChannel:(t,e)=>new N(t,e),createPrivateChannel:(t,e)=>new j(t,e),createPresenceChannel:(t,e)=>new H(t,e),createEncryptedChannel:(t,e,n)=>new q(t,e,n),createTimelineSender:(t,e)=>new T(t,e),createHandshake:(t,e)=>new C(t,e),createAssistantToTheTransportManager:(t,e,n)=>new w(t,e,n)};class X{constructor(t){this.options=t||{},this.livesLeft=this.options.lives||1/0}getAssistant(t){return J.createAssistantToTheTransportManager(this,t,{minPingDelay:this.options.minPingDelay,maxPingDelay:this.options.maxPingDelay})}isAlive(){return this.livesLeft>0}reportDeath(){this.livesLeft-=1}}class W{constructor(t,e){this.strategies=t,this.loop=Boolean(e.loop),this.failFast=Boolean(e.failFast),this.timeout=e.timeout,this.timeoutLimit=e.timeoutLimit}isSupported(){return r.b(this.strategies,c.a.method("isSupported"))}connect(t,e){var n=this.strategies,r=0,i=this.timeout,s=null,o=(a,h)=>{h?e(null,h):(r+=1,this.loop&&(r%=n.length),r0&&(i=new Y.a(n.timeout,(function(){s.abort(),r(!0)}))),s=t.connect(e,(function(t,e){t&&i&&i.isRunning()&&!n.failFast||(i&&i.ensureAborted(),r(t,e))})),{abort:function(){i&&i.ensureAborted(),s.abort()},forceMinPriority:function(t){s.forceMinPriority(t)}}}}class G{constructor(t){this.strategies=t}isSupported(){return r.b(this.strategies,c.a.method("isSupported"))}connect(t,e){return function(t,e,n){var i=r.j(t,(function(t,r,i,s){return t.connect(e,n(r,s))}));return{abort:function(){r.c(i,V)},forceMinPriority:function(t){r.c(i,(function(e){e.forceMinPriority(t)}))}}}(this.strategies,t,(function(t,n){return function(i,s){n[t].error=i,i?function(t){return r.a(t,(function(t){return Boolean(t.error)}))}(n)&&e(!0):(r.c(n,(function(t){t.forceMinPriority(s.transport.priority)})),e(null,s))}}))}}function V(t){t.error||t.aborted||(t.abort(),t.aborted=!0)}class Z{constructor(t,e,n){this.strategy=t,this.transports=e,this.ttl=n.ttl||18e5,this.usingTLS=n.useTLS,this.timeline=n.timeline}isSupported(){return this.strategy.isSupported()}connect(t,e){var n=this.usingTLS,i=function(t){var e=zt.getLocalStorage();if(e)try{var n=e[Q(t)];if(n)return JSON.parse(n)}catch(e){tt(t)}return null}(n),s=i&&i.cacheSkipCount?i.cacheSkipCount:0,o=[this.strategy];if(i&&i.timestamp+this.ttl>=c.a.now()){var a=this.transports[i.transport];a&&(["ws","wss"].includes(i.transport)||s>3?(this.timeline.info({cached:!0,transport:i.transport,latency:i.latency}),o.push(new W([a],{timeout:2*i.latency+1e3,failFast:!0}))):s++)}var h=c.a.now(),u=o.pop().connect(t,(function i(a,l){a?(tt(n),o.length>0?(h=c.a.now(),u=o.pop().connect(t,i)):e(a)):(!function(t,e,n,i){var s=zt.getLocalStorage();if(s)try{s[Q(t)]=r.l({timestamp:c.a.now(),transport:e,latency:n,cacheSkipCount:i})}catch(t){}}(n,l.transport.name,c.a.now()-h,s),e(null,l))}));return{abort:function(){u.abort()},forceMinPriority:function(e){t=e,u&&u.forceMinPriority(e)}}}}function Q(t){return"pusherTransport"+(t?"TLS":"NonTLS")}function tt(t){var e=zt.getLocalStorage();if(e)try{delete e[Q(t)]}catch(t){}}class et{constructor(t,{delay:e}){this.strategy=t,this.options={delay:e}}isSupported(){return this.strategy.isSupported()}connect(t,e){var n,r=this.strategy,i=new Y.a(this.options.delay,(function(){n=r.connect(t,e)}));return{abort:function(){i.ensureAborted(),n&&n.abort()},forceMinPriority:function(e){t=e,n&&n.forceMinPriority(e)}}}}class nt{constructor(t,e,n){this.test=t,this.trueBranch=e,this.falseBranch=n}isSupported(){return(this.test()?this.trueBranch:this.falseBranch).isSupported()}connect(t,e){return(this.test()?this.trueBranch:this.falseBranch).connect(t,e)}}class rt{constructor(t){this.strategy=t}isSupported(){return this.strategy.isSupported()}connect(t,e){var n=this.strategy.connect(t,(function(t,r){r&&n.abort(),e(t,r)}));return n}}function it(t){return function(){return t.isSupported()}}var st=function(t,e,n){var i={};function s(e,r,s,o,a){var h=n(t,e,r,s,o,a);return i[e]=h,h}var o,a=Object.assign({},e,{hostNonTLS:t.wsHost+":"+t.wsPort,hostTLS:t.wsHost+":"+t.wssPort,httpPath:t.wsPath}),h=r.f({},a,{useTLS:!0}),c=Object.assign({},e,{hostNonTLS:t.httpHost+":"+t.httpPort,hostTLS:t.httpHost+":"+t.httpsPort,httpPath:t.httpPath}),u={loop:!0,timeout:15e3,timeoutLimit:6e4},l=new X({minPingDelay:1e4,maxPingDelay:t.activityTimeout}),d=new X({lives:2,minPingDelay:1e4,maxPingDelay:t.activityTimeout}),f=s("ws","ws",3,a,l),p=s("wss","ws",3,h,l),g=s("xhr_streaming","xhr_streaming",1,c,d),b=s("xhr_polling","xhr_polling",1,c),v=new W([f],u),y=new W([p],u),m=new W([g],u),w=new W([b],u),_=new W([new nt(it(m),new G([m,new et(w,{delay:4e3})]),w)],u);return o=e.useTLS?new G([v,new et(_,{delay:2e3})]):new G([v,new et(y,{delay:2e3}),new et(_,{delay:5e3})]),new Z(new rt(new nt(it(f),o,_)),i,{ttl:18e5,timeline:e.timeline,useTLS:e.useTLS})};class ot extends u.a{constructor(t,e,n){super(),this.hooks=t,this.method=e,this.url=n}start(t){this.position=0,this.xhr=this.hooks.getRequest(this),this.unloader=()=>{this.close()},zt.addUnloadListener(this.unloader),this.xhr.open(this.method,this.url,!0),this.xhr.setRequestHeader&&this.xhr.setRequestHeader("Content-Type","application/json"),this.xhr.send(t)}close(){this.unloader&&(zt.removeUnloadListener(this.unloader),this.unloader=null),this.xhr&&(this.hooks.abortRequest(this.xhr),this.xhr=null)}onChunk(t,e){for(;;){var n=this.advanceBuffer(e);if(!n)break;this.emit("chunk",{status:t,data:n})}this.isBufferTooLong(e)&&this.emit("buffer_too_long")}advanceBuffer(t){var e=t.slice(this.position),n=e.indexOf("\n");return-1!==n?(this.position+=n+1,e.slice(0,n)):null}isBufferTooLong(t){return this.position===t.length&&t.length>262144}}var at;!function(t){t[t.CONNECTING=0]="CONNECTING",t[t.OPEN=1]="OPEN",t[t.CLOSED=3]="CLOSED"}(at||(at={}));var ht=at,ct=1;function ut(t){var e=-1===t.indexOf("?")?"?":"&";return t+e+"t="+ +new Date+"&n="+ct++}function lt(t){return zt.randomInt(t)}var dt=class{constructor(t,e){this.hooks=t,this.session=lt(1e3)+"/"+function(t){for(var e=[],n=0;n{this.onChunk(t)}),this.stream.bind("finished",t=>{this.hooks.onFinished(this,t)}),this.stream.bind("buffer_too_long",()=>{this.reconnect()});try{this.stream.start()}catch(t){c.a.defer(()=>{this.onError(t),this.onClose(1006,"Could not start streaming",!1)})}}closeStream(){this.stream&&(this.stream.unbind_all(),this.stream.close(),this.stream=null)}},ft={getReceiveURL:function(t,e){return t.base+"/"+e+"/xhr_streaming"+t.queryString},onHeartbeat:function(t){t.sendRaw("[]")},sendHeartbeat:function(t){t.sendRaw("[]")},onFinished:function(t,e){t.onClose(1006,"Connection interrupted ("+e+")",!1)}},pt={getReceiveURL:function(t,e){return t.base+"/"+e+"/xhr"+t.queryString},onHeartbeat:function(){},sendHeartbeat:function(t){t.sendRaw("[]")},onFinished:function(t,e){200===e?t.reconnect():t.onClose(1006,"Connection interrupted ("+e+")",!1)}},gt={getRequest:function(t){var e=new(zt.getXHRAPI());return e.onreadystatechange=e.onprogress=function(){switch(e.readyState){case 3:e.responseText&&e.responseText.length>0&&t.onChunk(e.status,e.responseText);break;case 4:e.responseText&&e.responseText.length>0&&t.onChunk(e.status,e.responseText),t.emit("finished",e.status),t.close()}},e},abortRequest:function(t){t.onreadystatechange=null,t.abort()}},bt={getDefaultStrategy:st,Transports:m,transportConnectionInitializer:function(){this.timeline.info(this.buildTimelineMessage({transport:this.name+(this.options.useTLS?"s":"")})),this.hooks.isInitialized()?this.changeState("initialized"):this.onClose()},HTTPFactory:{createStreamingSocket(t){return this.createSocket(ft,t)},createPollingSocket(t){return this.createSocket(pt,t)},createSocket:(t,e)=>new dt(t,e),createXHR(t,e){return this.createRequest(gt,t,e)},createRequest:(t,e,n)=>new ot(t,e,n)},setup(t){t.ready()},getLocalStorage(){},getClientFeatures:()=>r.i(r.h({ws:m.ws},(function(t){return t.isSupported({})}))),getProtocol:()=>"http:",isXHRSupported:()=>!0,createSocketRequest(t,e){if(this.isXHRSupported())return this.HTTPFactory.createXHR(t,e);throw"Cross-origin HTTP requests are not supported"},createXHR(){return new(this.getXHRAPI())},createWebSocket(t){return new(this.getWebSocketAPI())(t)},addUnloadListener(t){},removeUnloadListener(t){}},vt=n(10),yt=n.n(vt);function mt(t){return"none"!==t.type.toLowerCase()}class wt extends u.a{constructor(){super(),this.online=!0,yt.a.fetch().then(t=>{this.online=mt(t)}),yt.a.addEventListener(t=>{var e=mt(t);this.online!==e&&(this.online=e,this.online?this.emit("online"):this.emit("offline"))})}isOnline(){return this.online}}var _t,St=new wt;!function(t){t.UserAuthentication="user-authentication",t.ChannelAuthorization="channel-authorization"}(_t||(_t={}));var kt=function(t,e,n,r,i){const s=zt.createXHR();for(var o in s.open("POST",n.endpoint,!0),s.setRequestHeader("Content-Type","application/x-www-form-urlencoded"),n.headers)s.setRequestHeader(o,n.headers[o]);if(null!=n.headersProvider){let t=n.headersProvider();for(var o in t)s.setRequestHeader(o,t[o])}return s.onreadystatechange=function(){if(4===s.readyState)if(200===s.status){let t,e=!1;try{t=JSON.parse(s.responseText),e=!0}catch(t){i(new R(200,`JSON returned from ${r.toString()} endpoint was invalid, yet status code was 200. Data was: ${s.responseText}`),null)}e&&i(null,t)}else{let t="";switch(r){case _t.UserAuthentication:t=I("authenticationEndpoint");break;case _t.ChannelAuthorization:t="Clients must be authorized to join private or presence channels. "+I("authorizationEndpoint")}i(new R(s.status,`Unable to retrieve auth string from ${r.toString()} endpoint - received status: ${s.status} from ${n.endpoint}. ${t}`),null)}},s.send(e),s},Ct={name:"xhr",getAgent:function(t,e){return function(n,i){var s="http"+(e?"s":"")+"://"+(t.host||t.options.host)+t.options.path;s+="/2?"+r.e(n);var o=zt.createXHR();o.open("GET",s,!0),o.onreadystatechange=function(){if(4===o.readyState){let{status:n,responseText:r}=o;if(200!==n)return void l.a.debug(`TimelineSender Error: received ${n} from stats.pusher.com`);try{var{host:e}=JSON.parse(r)}catch(t){l.a.debug("TimelineSenderError: invalid response "+r)}e&&(t.host=e)}},o.send()}}};const{getDefaultStrategy:Tt,Transports:Et,setup:At,getProtocol:Pt,isXHRSupported:xt,getLocalStorage:Ot,createXHR:Lt,createWebSocket:Ut,addUnloadListener:Rt,removeUnloadListener:Mt,transportConnectionInitializer:It,createSocketRequest:Nt,HTTPFactory:jt}=bt;var Dt,zt={getDefaultStrategy:Tt,Transports:Et,setup:At,getProtocol:Pt,isXHRSupported:xt,getLocalStorage:Ot,createXHR:Lt,createWebSocket:Ut,addUnloadListener:Rt,removeUnloadListener:Mt,transportConnectionInitializer:It,createSocketRequest:Nt,HTTPFactory:jt,TimelineTransport:Ct,getAuthorizers:()=>({ajax:kt}),getWebSocketAPI:()=>WebSocket,getXHRAPI:()=>XMLHttpRequest,getNetwork:()=>St,randomInt:t=>Math.floor(Math.random()*t)};!function(t){t[t.ERROR=3]="ERROR",t[t.INFO=6]="INFO",t[t.DEBUG=7]="DEBUG"}(Dt||(Dt={}));var Ht=Dt;class Bt{constructor(t,e,n){this.key=t,this.session=e,this.events=[],this.options=n||{},this.sent=0,this.uniqueID=0}log(t,e){t<=this.options.level&&(this.events.push(r.f({},e,{timestamp:c.a.now()})),this.options.limit&&this.events.length>this.options.limit&&this.events.shift())}error(t){this.log(Ht.ERROR,t)}info(t){this.log(Ht.INFO,t)}debug(t){this.log(Ht.DEBUG,t)}isEmpty(){return 0===this.events.length}send(t,e){var n=r.f({session:this.session,bundle:this.sent+1,key:this.key,lib:"js",version:this.options.version,cluster:this.options.cluster,features:this.options.features,timeline:this.events},this.options.params);return this.events=[],t(n,(t,n)=>{t||this.sent++,e&&e(t,n)}),!0}generateUniqueID(){return this.uniqueID++,this.uniqueID}}class Ft{constructor(t,e,n,r){this.name=t,this.priority=e,this.transport=n,this.options=r||{}}isSupported(){return this.transport.isSupported({useTLS:this.options.useTLS})}connect(t,e){if(!this.isSupported())return qt(new U,e);if(this.priority{n||(u(),s?s.close():i.close())},forceMinPriority:t=>{n||this.priority{if(void 0===zt.getAuthorizers()[t.transport])throw`'${t.transport}' is not a recognized auth transport`;return(e,n)=>{const r=((t,e)=>{var n="socket_id="+encodeURIComponent(t.socketId);for(var r in e.params)n+="&"+encodeURIComponent(r)+"="+encodeURIComponent(e.params[r]);if(null!=e.paramsProvider){let t=e.paramsProvider();for(var r in t)n+="&"+encodeURIComponent(r)+"="+encodeURIComponent(t[r])}return n})(e,t);zt.getAuthorizers()[t.transport](zt,r,t,_t.UserAuthentication,n)}};var Wt=t=>{if(void 0===zt.getAuthorizers()[t.transport])throw`'${t.transport}' is not a recognized auth transport`;return(e,n)=>{const r=((t,e)=>{var n="socket_id="+encodeURIComponent(t.socketId);for(var r in n+="&channel_name="+encodeURIComponent(t.channelName),e.params)n+="&"+encodeURIComponent(r)+"="+encodeURIComponent(e.params[r]);if(null!=e.paramsProvider){let t=e.paramsProvider();for(var r in t)n+="&"+encodeURIComponent(r)+"="+encodeURIComponent(t[r])}return n})(e,t);zt.getAuthorizers()[t.transport](zt,r,t,_t.ChannelAuthorization,n)}};function Gt(t){return t.httpHost?t.httpHost:t.cluster?`sockjs-${t.cluster}.pusher.com`:i.httpHost}function Vt(t){return t.wsHost?t.wsHost:`ws-${t.cluster}.pusher.com`}function Zt(t){return"https:"===zt.getProtocol()||!1!==t.forceTLS}function Qt(t){return"enableStats"in t?t.enableStats:"disableStats"in t&&!t.disableStats}function te(t){const e=Object.assign(Object.assign({},i.userAuthentication),t.userAuthentication);return"customHandler"in e&&null!=e.customHandler?e.customHandler:Xt(e)}function ee(t,e){const n=function(t,e){let n;return"channelAuthorization"in t?n=Object.assign(Object.assign({},i.channelAuthorization),t.channelAuthorization):(n={transport:t.authTransport||i.authTransport,endpoint:t.authEndpoint||i.authEndpoint},"auth"in t&&("params"in t.auth&&(n.params=t.auth.params),"headers"in t.auth&&(n.headers=t.auth.headers)),"authorizer"in t&&(n.customHandler=((t,e,n)=>{const r={authTransport:e.transport,authEndpoint:e.endpoint,auth:{params:e.params,headers:e.headers}};return(e,i)=>{const s=t.channel(e.channelName);n(s,r).authorize(e.socketId,i)}})(e,n,t.authorizer))),n}(t,e);return"customHandler"in n&&null!=n.customHandler?n.customHandler:Wt(n)}class ne extends u.a{constructor(t){super((function(t,e){l.a.debug("No callbacks on watchlist events for "+t)})),this.pusher=t,this.bindWatchlistInternalEvent()}handleEvent(t){t.data.events.forEach(t=>{this.emit(t.name,t)})}bindWatchlistInternalEvent(){this.pusher.connection.bind("message",t=>{"pusher_internal:watchlist_events"===t.event&&this.handleEvent(t)})}}var re=function(){let t,e;return{promise:new Promise((n,r)=>{t=n,e=r}),resolve:t,reject:e}};class ie extends u.a{constructor(t){super((function(t,e){l.a.debug("No callbacks on user for "+t)})),this.signin_requested=!1,this.user_data=null,this.serverToUserChannel=null,this.signinDonePromise=null,this._signinDoneResolve=null,this._onAuthorize=(t,e)=>{if(t)return l.a.warn("Error during signin: "+t),void this._cleanup();this.pusher.send_event("pusher:signin",{auth:e.auth,user_data:e.user_data})},this.pusher=t,this.pusher.connection.bind("state_change",({previous:t,current:e})=>{"connected"!==t&&"connected"===e&&this._signin(),"connected"===t&&"connected"!==e&&(this._cleanup(),this._newSigninPromiseIfNeeded())}),this.watchlist=new ne(t),this.pusher.connection.bind("message",t=>{"pusher:signin_success"===t.event&&this._onSigninSuccess(t.data),this.serverToUserChannel&&this.serverToUserChannel.name===t.channel&&this.serverToUserChannel.handleEvent(t)})}signin(){this.signin_requested||(this.signin_requested=!0,this._signin())}_signin(){this.signin_requested&&(this._newSigninPromiseIfNeeded(),"connected"===this.pusher.connection.state&&this.pusher.config.userAuthenticator({socketId:this.pusher.connection.socket_id},this._onAuthorize))}_onSigninSuccess(t){try{this.user_data=JSON.parse(t.user_data)}catch(e){return l.a.error("Failed parsing user data after signin: "+t.user_data),void this._cleanup()}if("string"!=typeof this.user_data.id||""===this.user_data.id)return l.a.error("user_data doesn't contain an id. user_data: "+this.user_data),void this._cleanup();this._signinDoneResolve(),this._subscribeChannels()}_subscribeChannels(){this.serverToUserChannel=new N("#server-to-user-"+this.user_data.id,this.pusher),this.serverToUserChannel.bind_global((t,e)=>{0!==t.indexOf("pusher_internal:")&&0!==t.indexOf("pusher:")&&this.emit(t,e)}),(t=>{t.subscriptionPending&&t.subscriptionCancelled?t.reinstateSubscription():t.subscriptionPending||"connected"!==this.pusher.connection.state||t.subscribe()})(this.serverToUserChannel)}_cleanup(){this.user_data=null,this.serverToUserChannel&&(this.serverToUserChannel.unbind_all(),this.serverToUserChannel.disconnect(),this.serverToUserChannel=null),this.signin_requested&&this._signinDoneResolve()}_newSigninPromiseIfNeeded(){if(!this.signin_requested)return;if(this.signinDonePromise&&!this.signinDonePromise.done)return;const{promise:t,resolve:e,reject:n}=re();t.done=!1;const r=()=>{t.done=!0};t.then(r).catch(r),this.signinDonePromise=t,this._signinDoneResolve=e}}class se{static ready(){se.isReady=!0;for(var t=0,e=se.instances.length;tzt.getDefaultStrategy(this.config,t,Kt),timeline:this.timeline,activityTimeout:this.config.activityTimeout,pongTimeout:this.config.pongTimeout,unavailableTimeout:this.config.unavailableTimeout,useTLS:Boolean(this.config.useTLS)}),this.connection.bind("connected",()=>{this.subscribeAll(),this.timelineSender&&this.timelineSender.send(this.connection.isUsingTLS())}),this.connection.bind("message",t=>{var e=0===t.event.indexOf("pusher_internal:");if(t.channel){var n=this.channel(t.channel);n&&n.handleEvent(t)}e||this.global_emitter.emit(t.event,t.data)}),this.connection.bind("connecting",()=>{this.channels.disconnect()}),this.connection.bind("disconnected",()=>{this.channels.disconnect()}),this.connection.bind("error",t=>{l.a.warn(t)}),se.instances.push(this),this.timeline.info({instances:se.instances.length}),this.user=new ie(this),se.isReady&&this.connect()}channel(t){return this.channels.find(t)}allChannels(){return this.channels.all()}connect(){if(this.connection.connect(),this.timelineSender&&!this.timelineSenderTimer){var t=this.connection.isUsingTLS(),e=this.timelineSender;this.timelineSenderTimer=new Y.b(6e4,(function(){e.send(t)}))}}disconnect(){this.connection.disconnect(),this.timelineSenderTimer&&(this.timelineSenderTimer.ensureAborted(),this.timelineSenderTimer=null)}bind(t,e,n){return this.global_emitter.bind(t,e,n),this}unbind(t,e,n){return this.global_emitter.unbind(t,e,n),this}bind_global(t){return this.global_emitter.bind_global(t),this}unbind_global(t){return this.global_emitter.unbind_global(t),this}unbind_all(t){return this.global_emitter.unbind_all(),this}subscribeAll(){var t;for(t in this.channels.channels)this.channels.channels.hasOwnProperty(t)&&this.subscribe(t)}subscribe(t){var e=this.channels.add(t,this);return e.subscriptionPending&&e.subscriptionCancelled?e.reinstateSubscription():e.subscriptionPending||"connected"!==this.connection.state||e.subscribe(),e}unsubscribe(t){var e=this.channels.find(t);e&&e.subscriptionPending?e.cancelSubscription():(e=this.channels.remove(t))&&e.subscribed&&e.unsubscribe()}send_event(t,e,n){return this.connection.send_event(t,e,n)}shouldUseTLS(){return this.config.useTLS}signin(){this.user.signin()}}se.instances=[],se.isReady=!1,se.logToConsole=!1,se.Runtime=zt,se.ScriptReceivers=zt.ScriptReceivers,se.DependenciesReceivers=zt.DependenciesReceivers,se.auth_callbacks=zt.auth_callbacks;e.a=se;zt.setup(se)},function(t,e){var n;n=function(){return this}();try{n=n||new Function("return this")()}catch(t){"object"==typeof window&&(n=window)}t.exports=n},function(t,e,n){"use strict";n.d(e,"a",(function(){return i}));var r=n(1);function i(t){if(null==t)throw"You must pass an options object";if(null==t.cluster)throw"Options object must provide a cluster";"disableStats"in t&&r.a.warn("The disableStats option is deprecated in favor of enableStats")}},function(t,e,n){"use strict";var r,i=this&&this.__extends||(r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)},function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)});Object.defineProperty(e,"__esModule",{value:!0});var s=function(){function t(t){void 0===t&&(t="="),this._paddingCharacter=t}return t.prototype.encodedLength=function(t){return this._paddingCharacter?(t+2)/3*4|0:(8*t+5)/6|0},t.prototype.encode=function(t){for(var e="",n=0;n>>18&63),e+=this._encodeByte(r>>>12&63),e+=this._encodeByte(r>>>6&63),e+=this._encodeByte(r>>>0&63)}var i=t.length-n;if(i>0){r=t[n]<<16|(2===i?t[n+1]<<8:0);e+=this._encodeByte(r>>>18&63),e+=this._encodeByte(r>>>12&63),e+=2===i?this._encodeByte(r>>>6&63):this._paddingCharacter||"",e+=this._paddingCharacter||""}return e},t.prototype.maxDecodedLength=function(t){return this._paddingCharacter?t/4*3|0:(6*t+7)/8|0},t.prototype.decodedLength=function(t){return this.maxDecodedLength(t.length-this._getPaddingLength(t))},t.prototype.decode=function(t){if(0===t.length)return new Uint8Array(0);for(var e=this._getPaddingLength(t),n=t.length-e,r=new Uint8Array(this.maxDecodedLength(n)),i=0,s=0,o=0,a=0,h=0,c=0,u=0;s>>4,r[i++]=h<<4|c>>>2,r[i++]=c<<6|u,o|=256&a,o|=256&h,o|=256&c,o|=256&u;if(s>>4,o|=256&a,o|=256&h),s>>2,o|=256&c),s>>8&6,e+=51-t>>>8&-75,e+=61-t>>>8&-15,e+=62-t>>>8&3,String.fromCharCode(e)},t.prototype._decodeChar=function(t){var e=256;return e+=(42-t&t-44)>>>8&-256+t-43+62,e+=(46-t&t-48)>>>8&-256+t-47+63,e+=(47-t&t-58)>>>8&-256+t-48+52,e+=(64-t&t-91)>>>8&-256+t-65+0,e+=(96-t&t-123)>>>8&-256+t-97+26},t.prototype._getPaddingLength=function(t){var e=0;if(this._paddingCharacter){for(var n=t.length-1;n>=0&&t[n]===this._paddingCharacter;n--)e++;if(t.length<4||e>2)throw new Error("Base64Coder: incorrect padding")}return e},t}();e.Coder=s;var o=new s;e.encode=function(t){return o.encode(t)},e.decode=function(t){return o.decode(t)};var a=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return i(e,t),e.prototype._encodeByte=function(t){var e=t;return e+=65,e+=25-t>>>8&6,e+=51-t>>>8&-75,e+=61-t>>>8&-13,e+=62-t>>>8&49,String.fromCharCode(e)},e.prototype._decodeChar=function(t){var e=256;return e+=(44-t&t-46)>>>8&-256+t-45+62,e+=(94-t&t-96)>>>8&-256+t-95+63,e+=(47-t&t-58)>>>8&-256+t-48+52,e+=(64-t&t-91)>>>8&-256+t-65+0,e+=(96-t&t-123)>>>8&-256+t-97+26},e}(s);e.URLSafeCoder=a;var h=new a;e.encodeURLSafe=function(t){return h.encode(t)},e.decodeURLSafe=function(t){return h.decode(t)},e.encodedLength=function(t){return o.encodedLength(t)},e.maxDecodedLength=function(t){return o.maxDecodedLength(t)},e.decodedLength=function(t){return o.decodedLength(t)}},function(t,e,n){"use strict";e.a=class{constructor(t,e,n,r){this.clear=e,this.timer=t(()=>{this.timer&&(this.timer=r(this.timer))},n)}isRunning(){return null!==this.timer}ensureAborted(){this.timer&&(this.clear(this.timer),this.timer=null)}}},function(t,e){t.exports=require("@react-native-community/netinfo")},function(t,e,n){"use strict";(function(t){function r(t){return d(u(t))}n.d(e,"a",(function(){return r}));for(var i=String.fromCharCode,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",o={},a=0,h=s.length;a>>6)+i(128|63&e):i(224|e>>>12&15)+i(128|e>>>6&63)+i(128|63&e)},u=function(t){return t.replace(/[^\x00-\x7F]/g,c)},l=function(t){var e=[0,2,1][t.length%3],n=t.charCodeAt(0)<<16|(t.length>1?t.charCodeAt(1):0)<<8|(t.length>2?t.charCodeAt(2):0);return[s.charAt(n>>>18),s.charAt(n>>>12&63),e>=2?"=":s.charAt(n>>>6&63),e>=1?"=":s.charAt(63&n)].join("")},d=t.btoa||function(t){return t.replace(/[\s\S]{1,3}/g,l)}}).call(this,n(6))},function(t,e,n){"use strict";n.d(e,"a",(function(){return i}));var r=n(0);class i{constructor(){this._callbacks={}}get(t){return this._callbacks[s(t)]}add(t,e,n){var r=s(t);this._callbacks[r]=this._callbacks[r]||[],this._callbacks[r].push({fn:e,context:n})}remove(t,e,n){if(t||e||n){var i=t?[s(t)]:r.i(this._callbacks);e||n?this.removeCallback(i,e,n):this.removeAllCallbacks(i)}else this._callbacks={}}removeCallback(t,e,n){r.c(t,(function(t){this._callbacks[t]=r.g(this._callbacks[t]||[],(function(t){return e&&e!==t.fn||n&&n!==t.context})),0===this._callbacks[t].length&&delete this._callbacks[t]}),this)}removeAllCallbacks(t){r.c(t,(function(t){delete this._callbacks[t]}),this)}}function s(t){return"_"+t}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r="utf8: invalid source encoding";function i(t){for(var e=0,n=0;n=t.length-1)throw new Error("utf8: invalid string");n++,e+=4}}return e}e.encode=function(t){for(var e=new Uint8Array(i(t)),n=0,r=0;r>6,e[n++]=128|63&s):s<55296?(e[n++]=224|s>>12,e[n++]=128|s>>6&63,e[n++]=128|63&s):(r++,s=(1023&s)<<10,s|=1023&t.charCodeAt(r),s+=65536,e[n++]=240|s>>18,e[n++]=128|s>>12&63,e[n++]=128|s>>6&63,e[n++]=128|63&s)}return e},e.encodedLength=i,e.decode=function(t){for(var e=[],n=0;n=t.length)throw new Error(r);if(128!=(192&(o=t[++n])))throw new Error(r);i=(31&i)<<6|63&o,s=128}else if(i<240){if(n>=t.length-1)throw new Error(r);var o=t[++n],a=t[++n];if(128!=(192&o)||128!=(192&a))throw new Error(r);i=(15&i)<<12|(63&o)<<6|63&a,s=2048}else{if(!(i<248))throw new Error(r);if(n>=t.length-2)throw new Error(r);o=t[++n],a=t[++n];var h=t[++n];if(128!=(192&o)||128!=(192&a)||128!=(192&h))throw new Error(r);i=(15&i)<<18|(63&o)<<12|(63&a)<<6|63&h,s=65536}if(i=55296&&i<=57343)throw new Error(r);if(i>=65536){if(i>1114111)throw new Error(r);i-=65536,e.push(String.fromCharCode(55296|i>>10)),i=56320|1023&i}}e.push(String.fromCharCode(i))}return e.join("")}},function(t,e,n){!function(t){"use strict";var e=function(t){var e,n=new Float64Array(16);if(t)for(e=0;e>24&255,t[e+1]=n>>16&255,t[e+2]=n>>8&255,t[e+3]=255&n,t[e+4]=r>>24&255,t[e+5]=r>>16&255,t[e+6]=r>>8&255,t[e+7]=255&r}function g(t,e,n,r,i){var s,o=0;for(s=0;s>>8)-1}function b(t,e,n,r){return g(t,e,n,r,16)}function v(t,e,n,r){return g(t,e,n,r,32)}function y(t,e,n,r){!function(t,e,n,r){for(var i,s=255&r[0]|(255&r[1])<<8|(255&r[2])<<16|(255&r[3])<<24,o=255&n[0]|(255&n[1])<<8|(255&n[2])<<16|(255&n[3])<<24,a=255&n[4]|(255&n[5])<<8|(255&n[6])<<16|(255&n[7])<<24,h=255&n[8]|(255&n[9])<<8|(255&n[10])<<16|(255&n[11])<<24,c=255&n[12]|(255&n[13])<<8|(255&n[14])<<16|(255&n[15])<<24,u=255&r[4]|(255&r[5])<<8|(255&r[6])<<16|(255&r[7])<<24,l=255&e[0]|(255&e[1])<<8|(255&e[2])<<16|(255&e[3])<<24,d=255&e[4]|(255&e[5])<<8|(255&e[6])<<16|(255&e[7])<<24,f=255&e[8]|(255&e[9])<<8|(255&e[10])<<16|(255&e[11])<<24,p=255&e[12]|(255&e[13])<<8|(255&e[14])<<16|(255&e[15])<<24,g=255&r[8]|(255&r[9])<<8|(255&r[10])<<16|(255&r[11])<<24,b=255&n[16]|(255&n[17])<<8|(255&n[18])<<16|(255&n[19])<<24,v=255&n[20]|(255&n[21])<<8|(255&n[22])<<16|(255&n[23])<<24,y=255&n[24]|(255&n[25])<<8|(255&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,t[1]=_>>>8&255,t[2]=_>>>16&255,t[3]=_>>>24&255,t[4]=S>>>0&255,t[5]=S>>>8&255,t[6]=S>>>16&255,t[7]=S>>>24&255,t[8]=k>>>0&255,t[9]=k>>>8&255,t[10]=k>>>16&255,t[11]=k>>>24&255,t[12]=C>>>0&255,t[13]=C>>>8&255,t[14]=C>>>16&255,t[15]=C>>>24&255,t[16]=T>>>0&255,t[17]=T>>>8&255,t[18]=T>>>16&255,t[19]=T>>>24&255,t[20]=E>>>0&255,t[21]=E>>>8&255,t[22]=E>>>16&255,t[23]=E>>>24&255,t[24]=A>>>0&255,t[25]=A>>>8&255,t[26]=A>>>16&255,t[27]=A>>>24&255,t[28]=P>>>0&255,t[29]=P>>>8&255,t[30]=P>>>16&255,t[31]=P>>>24&255,t[32]=x>>>0&255,t[33]=x>>>8&255,t[34]=x>>>16&255,t[35]=x>>>24&255,t[36]=O>>>0&255,t[37]=O>>>8&255,t[38]=O>>>16&255,t[39]=O>>>24&255,t[40]=L>>>0&255,t[41]=L>>>8&255,t[42]=L>>>16&255,t[43]=L>>>24&255,t[44]=U>>>0&255,t[45]=U>>>8&255,t[46]=U>>>16&255,t[47]=U>>>24&255,t[48]=R>>>0&255,t[49]=R>>>8&255,t[50]=R>>>16&255,t[51]=R>>>24&255,t[52]=M>>>0&255,t[53]=M>>>8&255,t[54]=M>>>16&255,t[55]=M>>>24&255,t[56]=I>>>0&255,t[57]=I>>>8&255,t[58]=I>>>16&255,t[59]=I>>>24&255,t[60]=N>>>0&255,t[61]=N>>>8&255,t[62]=N>>>16&255,t[63]=N>>>24&255}(t,e,n,r)}function m(t,e,n,r){!function(t,e,n,r){for(var i,s=255&r[0]|(255&r[1])<<8|(255&r[2])<<16|(255&r[3])<<24,o=255&n[0]|(255&n[1])<<8|(255&n[2])<<16|(255&n[3])<<24,a=255&n[4]|(255&n[5])<<8|(255&n[6])<<16|(255&n[7])<<24,h=255&n[8]|(255&n[9])<<8|(255&n[10])<<16|(255&n[11])<<24,c=255&n[12]|(255&n[13])<<8|(255&n[14])<<16|(255&n[15])<<24,u=255&r[4]|(255&r[5])<<8|(255&r[6])<<16|(255&r[7])<<24,l=255&e[0]|(255&e[1])<<8|(255&e[2])<<16|(255&e[3])<<24,d=255&e[4]|(255&e[5])<<8|(255&e[6])<<16|(255&e[7])<<24,f=255&e[8]|(255&e[9])<<8|(255&e[10])<<16|(255&e[11])<<24,p=255&e[12]|(255&e[13])<<8|(255&e[14])<<16|(255&e[15])<<24,g=255&r[8]|(255&r[9])<<8|(255&r[10])<<16|(255&r[11])<<24,b=255&n[16]|(255&n[17])<<8|(255&n[18])<<16|(255&n[19])<<24,v=255&n[20]|(255&n[21])<<8|(255&n[22])<<16|(255&n[23])<<24,y=255&n[24]|(255&n[25])<<8|(255&n[26])<<16|(255&n[27])<<24,m=255&n[28]|(255&n[29])<<8|(255&n[30])<<16|(255&n[31])<<24,w=255&r[12]|(255&r[13])<<8|(255&r[14])<<16|(255&r[15])<<24,_=0;_<20;_+=2)s^=(i=(v^=(i=(f^=(i=(c^=(i=s+v|0)<<7|i>>>25)+s|0)<<9|i>>>23)+c|0)<<13|i>>>19)+f|0)<<18|i>>>14,u^=(i=(o^=(i=(y^=(i=(p^=(i=u+o|0)<<7|i>>>25)+u|0)<<9|i>>>23)+p|0)<<13|i>>>19)+y|0)<<18|i>>>14,g^=(i=(l^=(i=(a^=(i=(m^=(i=g+l|0)<<7|i>>>25)+g|0)<<9|i>>>23)+m|0)<<13|i>>>19)+a|0)<<18|i>>>14,w^=(i=(b^=(i=(d^=(i=(h^=(i=w+b|0)<<7|i>>>25)+w|0)<<9|i>>>23)+h|0)<<13|i>>>19)+d|0)<<18|i>>>14,s^=(i=(h^=(i=(a^=(i=(o^=(i=s+h|0)<<7|i>>>25)+s|0)<<9|i>>>23)+o|0)<<13|i>>>19)+a|0)<<18|i>>>14,u^=(i=(c^=(i=(d^=(i=(l^=(i=u+c|0)<<7|i>>>25)+u|0)<<9|i>>>23)+l|0)<<13|i>>>19)+d|0)<<18|i>>>14,g^=(i=(p^=(i=(f^=(i=(b^=(i=g+p|0)<<7|i>>>25)+g|0)<<9|i>>>23)+b|0)<<13|i>>>19)+f|0)<<18|i>>>14,w^=(i=(m^=(i=(y^=(i=(v^=(i=w+m|0)<<7|i>>>25)+w|0)<<9|i>>>23)+v|0)<<13|i>>>19)+y|0)<<18|i>>>14;t[0]=s>>>0&255,t[1]=s>>>8&255,t[2]=s>>>16&255,t[3]=s>>>24&255,t[4]=u>>>0&255,t[5]=u>>>8&255,t[6]=u>>>16&255,t[7]=u>>>24&255,t[8]=g>>>0&255,t[9]=g>>>8&255,t[10]=g>>>16&255,t[11]=g>>>24&255,t[12]=w>>>0&255,t[13]=w>>>8&255,t[14]=w>>>16&255,t[15]=w>>>24&255,t[16]=l>>>0&255,t[17]=l>>>8&255,t[18]=l>>>16&255,t[19]=l>>>24&255,t[20]=d>>>0&255,t[21]=d>>>8&255,t[22]=d>>>16&255,t[23]=d>>>24&255,t[24]=f>>>0&255,t[25]=f>>>8&255,t[26]=f>>>16&255,t[27]=f>>>24&255,t[28]=p>>>0&255,t[29]=p>>>8&255,t[30]=p>>>16&255,t[31]=p>>>24&255}(t,e,n,r)}var w=new Uint8Array([101,120,112,97,110,100,32,51,50,45,98,121,116,101,32,107]);function _(t,e,n,r,i,s,o){var a,h,c=new Uint8Array(16),u=new Uint8Array(64);for(h=0;h<16;h++)c[h]=0;for(h=0;h<8;h++)c[h]=s[h];for(;i>=64;){for(y(u,c,o,w),h=0;h<64;h++)t[e+h]=n[r+h]^u[h];for(a=1,h=8;h<16;h++)a=a+(255&c[h])|0,c[h]=255&a,a>>>=8;i-=64,e+=64,r+=64}if(i>0)for(y(u,c,o,w),h=0;h=64;){for(y(h,a,i,w),o=0;o<64;o++)t[e+o]=h[o];for(s=1,o=8;o<16;o++)s=s+(255&a[o])|0,a[o]=255&s,s>>>=8;n-=64,e+=64}if(n>0)for(y(h,a,i,w),o=0;o>>13|n<<3),r=255&t[4]|(255&t[5])<<8,this.r[2]=7939&(n>>>10|r<<6),i=255&t[6]|(255&t[7])<<8,this.r[3]=8191&(r>>>7|i<<9),s=255&t[8]|(255&t[9])<<8,this.r[4]=255&(i>>>4|s<<12),this.r[5]=s>>>1&8190,o=255&t[10]|(255&t[11])<<8,this.r[6]=8191&(s>>>14|o<<2),a=255&t[12]|(255&t[13])<<8,this.r[7]=8065&(o>>>11|a<<5),h=255&t[14]|(255&t[15])<<8,this.r[8]=8191&(a>>>8|h<<8),this.r[9]=h>>>5&127,this.pad[0]=255&t[16]|(255&t[17])<<8,this.pad[1]=255&t[18]|(255&t[19])<<8,this.pad[2]=255&t[20]|(255&t[21])<<8,this.pad[3]=255&t[22]|(255&t[23])<<8,this.pad[4]=255&t[24]|(255&t[25])<<8,this.pad[5]=255&t[26]|(255&t[27])<<8,this.pad[6]=255&t[28]|(255&t[29])<<8,this.pad[7]=255&t[30]|(255&t[31])<<8};function E(t,e,n,r,i,s){var o=new T(s);return o.update(n,r,i),o.finish(t,e),0}function A(t,e,n,r,i,s){var o=new Uint8Array(16);return E(o,0,n,r,i,s),b(t,e,o,0)}function P(t,e,n,r,i){var s;if(n<32)return-1;for(C(t,0,e,0,n,r,i),E(t,16,t,32,n-32,t),s=0;s<16;s++)t[s]=0;return 0}function x(t,e,n,r,i){var s,o=new Uint8Array(32);if(n<32)return-1;if(k(o,0,32,r,i),0!==A(e,16,e,32,n-32,o))return-1;for(C(t,0,e,0,n,r,i),s=0;s<32;s++)t[s]=0;return 0}function O(t,e){var n;for(n=0;n<16;n++)t[n]=0|e[n]}function L(t){var e,n,r=1;for(e=0;e<16;e++)n=t[e]+r+65535,r=Math.floor(n/65536),t[e]=n-65536*r;t[0]+=r-1+37*(r-1)}function U(t,e,n){for(var r,i=~(n-1),s=0;s<16;s++)r=i&(t[s]^e[s]),t[s]^=r,e[s]^=r}function R(t,n){var r,i,s,o=e(),a=e();for(r=0;r<16;r++)a[r]=n[r];for(L(a),L(a),L(a),i=0;i<2;i++){for(o[0]=a[0]-65517,r=1;r<15;r++)o[r]=a[r]-65535-(o[r-1]>>16&1),o[r-1]&=65535;o[15]=a[15]-32767-(o[14]>>16&1),s=o[15]>>16&1,o[14]&=65535,U(a,o,1-s)}for(r=0;r<16;r++)t[2*r]=255&a[r],t[2*r+1]=a[r]>>8}function M(t,e){var n=new Uint8Array(32),r=new Uint8Array(32);return R(n,t),R(r,e),v(n,0,r,0)}function I(t){var e=new Uint8Array(32);return R(e,t),1&e[0]}function N(t,e){var n;for(n=0;n<16;n++)t[n]=e[2*n]+(e[2*n+1]<<8);t[15]&=32767}function j(t,e,n){for(var r=0;r<16;r++)t[r]=e[r]+n[r]}function D(t,e,n){for(var r=0;r<16;r++)t[r]=e[r]-n[r]}function z(t,e,n){var r,i,s=0,o=0,a=0,h=0,c=0,u=0,l=0,d=0,f=0,p=0,g=0,b=0,v=0,y=0,m=0,w=0,_=0,S=0,k=0,C=0,T=0,E=0,A=0,P=0,x=0,O=0,L=0,U=0,R=0,M=0,I=0,N=n[0],j=n[1],D=n[2],z=n[3],H=n[4],B=n[5],F=n[6],q=n[7],Y=n[8],K=n[9],$=n[10],J=n[11],X=n[12],W=n[13],G=n[14],V=n[15];s+=(r=e[0])*N,o+=r*j,a+=r*D,h+=r*z,c+=r*H,u+=r*B,l+=r*F,d+=r*q,f+=r*Y,p+=r*K,g+=r*$,b+=r*J,v+=r*X,y+=r*W,m+=r*G,w+=r*V,o+=(r=e[1])*N,a+=r*j,h+=r*D,c+=r*z,u+=r*H,l+=r*B,d+=r*F,f+=r*q,p+=r*Y,g+=r*K,b+=r*$,v+=r*J,y+=r*X,m+=r*W,w+=r*G,_+=r*V,a+=(r=e[2])*N,h+=r*j,c+=r*D,u+=r*z,l+=r*H,d+=r*B,f+=r*F,p+=r*q,g+=r*Y,b+=r*K,v+=r*$,y+=r*J,m+=r*X,w+=r*W,_+=r*G,S+=r*V,h+=(r=e[3])*N,c+=r*j,u+=r*D,l+=r*z,d+=r*H,f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=r*V,v+=(r=e[12])*N,y+=r*j,m+=r*D,w+=r*z,_+=r*H,S+=r*B,k+=r*F,C+=r*q,T+=r*Y,E+=r*K,A+=r*$,P+=r*J,x+=r*X,O+=r*W,L+=r*G,U+=r*V,y+=(r=e[13])*N,m+=r*j,w+=r*D,_+=r*z,S+=r*H,k+=r*B,C+=r*F,T+=r*q,E+=r*Y,A+=r*K,P+=r*$,x+=r*J,O+=r*X,L+=r*W,U+=r*G,R+=r*V,m+=(r=e[14])*N,w+=r*j,_+=r*D,S+=r*z,k+=r*H,C+=r*B,T+=r*F,E+=r*q,A+=r*Y,P+=r*K,x+=r*$,O+=r*J,L+=r*X,U+=r*W,R+=r*G,M+=r*V,w+=(r=e[15])*N,o+=38*(S+=r*D),a+=38*(k+=r*z),h+=38*(C+=r*H),c+=38*(T+=r*B),u+=38*(E+=r*F),l+=38*(A+=r*q),d+=38*(P+=r*Y),f+=38*(x+=r*K),p+=38*(O+=r*$),g+=38*(L+=r*J),b+=38*(U+=r*X),v+=38*(R+=r*W),y+=38*(M+=r*G),m+=38*(I+=r*V),s=(r=(s+=38*(_+=r*j))+(i=1)+65535)-65536*(i=Math.floor(r/65536)),o=(r=o+i+65535)-65536*(i=Math.floor(r/65536)),a=(r=a+i+65535)-65536*(i=Math.floor(r/65536)),h=(r=h+i+65535)-65536*(i=Math.floor(r/65536)),c=(r=c+i+65535)-65536*(i=Math.floor(r/65536)),u=(r=u+i+65535)-65536*(i=Math.floor(r/65536)),l=(r=l+i+65535)-65536*(i=Math.floor(r/65536)),d=(r=d+i+65535)-65536*(i=Math.floor(r/65536)),f=(r=f+i+65535)-65536*(i=Math.floor(r/65536)),p=(r=p+i+65535)-65536*(i=Math.floor(r/65536)),g=(r=g+i+65535)-65536*(i=Math.floor(r/65536)),b=(r=b+i+65535)-65536*(i=Math.floor(r/65536)),v=(r=v+i+65535)-65536*(i=Math.floor(r/65536)),y=(r=y+i+65535)-65536*(i=Math.floor(r/65536)),m=(r=m+i+65535)-65536*(i=Math.floor(r/65536)),w=(r=w+i+65535)-65536*(i=Math.floor(r/65536)),s=(r=(s+=i-1+37*(i-1))+(i=1)+65535)-65536*(i=Math.floor(r/65536)),o=(r=o+i+65535)-65536*(i=Math.floor(r/65536)),a=(r=a+i+65535)-65536*(i=Math.floor(r/65536)),h=(r=h+i+65535)-65536*(i=Math.floor(r/65536)),c=(r=c+i+65535)-65536*(i=Math.floor(r/65536)),u=(r=u+i+65535)-65536*(i=Math.floor(r/65536)),l=(r=l+i+65535)-65536*(i=Math.floor(r/65536)),d=(r=d+i+65535)-65536*(i=Math.floor(r/65536)),f=(r=f+i+65535)-65536*(i=Math.floor(r/65536)),p=(r=p+i+65535)-65536*(i=Math.floor(r/65536)),g=(r=g+i+65535)-65536*(i=Math.floor(r/65536)),b=(r=b+i+65535)-65536*(i=Math.floor(r/65536)),v=(r=v+i+65535)-65536*(i=Math.floor(r/65536)),y=(r=y+i+65535)-65536*(i=Math.floor(r/65536)),m=(r=m+i+65535)-65536*(i=Math.floor(r/65536)),w=(r=w+i+65535)-65536*(i=Math.floor(r/65536)),s+=i-1+37*(i-1),t[0]=s,t[1]=o,t[2]=a,t[3]=h,t[4]=c,t[5]=u,t[6]=l,t[7]=d,t[8]=f,t[9]=p,t[10]=g,t[11]=b,t[12]=v,t[13]=y,t[14]=m,t[15]=w}function H(t,e){z(t,e,e)}function B(t,n){var r,i=e();for(r=0;r<16;r++)i[r]=n[r];for(r=253;r>=0;r--)H(i,i),2!==r&&4!==r&&z(i,i,n);for(r=0;r<16;r++)t[r]=i[r]}function F(t,n){var r,i=e();for(r=0;r<16;r++)i[r]=n[r];for(r=250;r>=0;r--)H(i,i),1!==r&&z(i,i,n);for(r=0;r<16;r++)t[r]=i[r]}function q(t,n,r){var i,s,o=new Uint8Array(32),a=new Float64Array(80),c=e(),u=e(),l=e(),d=e(),f=e(),p=e();for(s=0;s<31;s++)o[s]=n[s];for(o[31]=127&n[31]|64,o[0]&=248,N(a,r),s=0;s<16;s++)u[s]=a[s],d[s]=c[s]=l[s]=0;for(c[0]=d[0]=1,s=254;s>=0;--s)U(c,u,i=o[s>>>3]>>>(7&s)&1),U(l,d,i),j(f,c,l),D(c,c,l),j(l,u,d),D(u,u,d),H(d,f),H(p,c),z(c,l,c),z(l,u,f),j(f,c,l),D(c,c,l),H(u,c),D(l,d,p),z(c,l,h),j(c,c,d),z(l,l,c),z(c,d,p),z(d,u,a),H(u,f),U(c,u,i),U(l,d,i);for(s=0;s<16;s++)a[s+16]=c[s],a[s+32]=l[s],a[s+48]=u[s],a[s+64]=d[s];var g=a.subarray(32),b=a.subarray(16);return B(g,g),z(b,b,g),R(t,b),0}function Y(t,e){return q(t,e,s)}function K(t,e){return r(e,32),Y(t,e)}function $(t,e,n){var r=new Uint8Array(32);return q(r,n,e),m(t,i,r,w)}T.prototype.blocks=function(t,e,n){for(var r,i,s,o,a,h,c,u,l,d,f,p,g,b,v,y,m,w,_,S=this.fin?0:2048,k=this.h[0],C=this.h[1],T=this.h[2],E=this.h[3],A=this.h[4],P=this.h[5],x=this.h[6],O=this.h[7],L=this.h[8],U=this.h[9],R=this.r[0],M=this.r[1],I=this.r[2],N=this.r[3],j=this.r[4],D=this.r[5],z=this.r[6],H=this.r[7],B=this.r[8],F=this.r[9];n>=16;)d=l=0,d+=(k+=8191&(r=255&t[e+0]|(255&t[e+1])<<8))*R,d+=(C+=8191&(r>>>13|(i=255&t[e+2]|(255&t[e+3])<<8)<<3))*(5*F),d+=(T+=8191&(i>>>10|(s=255&t[e+4]|(255&t[e+5])<<8)<<6))*(5*B),d+=(E+=8191&(s>>>7|(o=255&t[e+6]|(255&t[e+7])<<8)<<9))*(5*H),l=(d+=(A+=8191&(o>>>4|(a=255&t[e+8]|(255&t[e+9])<<8)<<12))*(5*z))>>>13,d&=8191,d+=(P+=a>>>1&8191)*(5*D),d+=(x+=8191&(a>>>14|(h=255&t[e+10]|(255&t[e+11])<<8)<<2))*(5*j),d+=(O+=8191&(h>>>11|(c=255&t[e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)>>>13,_&=8191,_+=P*j,_+=x*N,_+=O*I,_+=L*M,k=d=8191&(l=(l=((l+=(_+=U*R)>>>13)<<2)+l|0)+(d&=8191)|0),C=f+=l>>>=13,T=p&=8191,E=g&=8191,A=b&=8191,P=v&=8191,x=y&=8191,O=m&=8191,L=w&=8191,U=_&=8191,e+=16,n-=16;this.h[0]=k,this.h[1]=C,this.h[2]=T,this.h[3]=E,this.h[4]=A,this.h[5]=P,this.h[6]=x,this.h[7]=O,this.h[8]=L,this.h[9]=U},T.prototype.finish=function(t,e){var n,r,i,s,o=new Uint16Array(10);if(this.leftover){for(s=this.leftover,this.buffer[s++]=1;s<16;s++)this.buffer[s]=0;this.fin=1,this.blocks(this.buffer,0,16)}for(n=this.h[1]>>>13,this.h[1]&=8191,s=2;s<10;s++)this.h[s]+=n,n=this.h[s]>>>13,this.h[s]&=8191;for(this.h[0]+=5*n,n=this.h[0]>>>13,this.h[0]&=8191,this.h[1]+=n,n=this.h[1]>>>13,this.h[1]&=8191,this.h[2]+=n,o[0]=this.h[0]+5,n=o[0]>>>13,o[0]&=8191,s=1;s<10;s++)o[s]=this.h[s]+n,n=o[s]>>>13,o[s]&=8191;for(o[9]-=8192,r=(1^n)-1,s=0;s<10;s++)o[s]&=r;for(r=~r,s=0;s<10;s++)this.h[s]=this.h[s]&r|o[s];for(this.h[0]=65535&(this.h[0]|this.h[1]<<13),this.h[1]=65535&(this.h[1]>>>3|this.h[2]<<10),this.h[2]=65535&(this.h[2]>>>6|this.h[3]<<7),this.h[3]=65535&(this.h[3]>>>9|this.h[4]<<4),this.h[4]=65535&(this.h[4]>>>12|this.h[5]<<1|this.h[6]<<14),this.h[5]=65535&(this.h[6]>>>2|this.h[7]<<11),this.h[6]=65535&(this.h[7]>>>5|this.h[8]<<8),this.h[7]=65535&(this.h[8]>>>8|this.h[9]<<5),i=this.h[0]+this.pad[0],this.h[0]=65535&i,s=1;s<8;s++)i=(this.h[s]+this.pad[s]|0)+(i>>>16)|0,this.h[s]=65535&i;t[e+0]=this.h[0]>>>0&255,t[e+1]=this.h[0]>>>8&255,t[e+2]=this.h[1]>>>0&255,t[e+3]=this.h[1]>>>8&255,t[e+4]=this.h[2]>>>0&255,t[e+5]=this.h[2]>>>8&255,t[e+6]=this.h[3]>>>0&255,t[e+7]=this.h[3]>>>8&255,t[e+8]=this.h[4]>>>0&255,t[e+9]=this.h[4]>>>8&255,t[e+10]=this.h[5]>>>0&255,t[e+11]=this.h[5]>>>8&255,t[e+12]=this.h[6]>>>0&255,t[e+13]=this.h[6]>>>8&255,t[e+14]=this.h[7]>>>0&255,t[e+15]=this.h[7]>>>8&255},T.prototype.update=function(t,e,n){var r,i;if(this.leftover){for((i=16-this.leftover)>n&&(i=n),r=0;r=16&&(i=n-n%16,this.blocks(t,e,i),e+=i,n-=i),n){for(r=0;r=128;){for(S=0;S<16;S++)k=8*S+X,O[S]=n[k+0]<<24|n[k+1]<<16|n[k+2]<<8|n[k+3],L[S]=n[k+4]<<24|n[k+5]<<16|n[k+6]<<8|n[k+7];for(S=0;S<80;S++)if(i=U,s=R,o=M,a=I,h=N,c=j,u=D,z,d=H,f=B,p=F,g=q,b=Y,v=K,y=$,J,E=65535&(T=J),A=T>>>16,P=65535&(C=z),x=C>>>16,E+=65535&(T=(Y>>>14|N<<18)^(Y>>>18|N<<14)^(N>>>9|Y<<23)),A+=T>>>16,P+=65535&(C=(N>>>14|Y<<18)^(N>>>18|Y<<14)^(Y>>>9|N<<23)),x+=C>>>16,E+=65535&(T=Y&K^~Y&$),A+=T>>>16,P+=65535&(C=N&j^~N&D),x+=C>>>16,E+=65535&(T=W[2*S+1]),A+=T>>>16,P+=65535&(C=W[2*S]),x+=C>>>16,C=O[S%16],A+=(T=L[S%16])>>>16,P+=65535&C,x+=C>>>16,P+=(A+=(E+=65535&T)>>>16)>>>16,E=65535&(T=_=65535&E|A<<16),A=T>>>16,P=65535&(C=w=65535&P|(x+=P>>>16)<<16),x=C>>>16,E+=65535&(T=(H>>>28|U<<4)^(U>>>2|H<<30)^(U>>>7|H<<25)),A+=T>>>16,P+=65535&(C=(U>>>28|H<<4)^(H>>>2|U<<30)^(H>>>7|U<<25)),x+=C>>>16,A+=(T=H&B^H&F^B&F)>>>16,P+=65535&(C=U&R^U&M^R&M),x+=C>>>16,l=65535&(P+=(A+=(E+=65535&T)>>>16)>>>16)|(x+=P>>>16)<<16,m=65535&E|A<<16,E=65535&(T=g),A=T>>>16,P=65535&(C=a),x=C>>>16,A+=(T=_)>>>16,P+=65535&(C=w),x+=C>>>16,R=i,M=s,I=o,N=a=65535&(P+=(A+=(E+=65535&T)>>>16)>>>16)|(x+=P>>>16)<<16,j=h,D=c,z=u,U=l,B=d,F=f,q=p,Y=g=65535&E|A<<16,K=b,$=v,J=y,H=m,S%16==15)for(k=0;k<16;k++)C=O[k],E=65535&(T=L[k]),A=T>>>16,P=65535&C,x=C>>>16,C=O[(k+9)%16],E+=65535&(T=L[(k+9)%16]),A+=T>>>16,P+=65535&C,x+=C>>>16,w=O[(k+1)%16],E+=65535&(T=((_=L[(k+1)%16])>>>1|w<<31)^(_>>>8|w<<24)^(_>>>7|w<<25)),A+=T>>>16,P+=65535&(C=(w>>>1|_<<31)^(w>>>8|_<<24)^w>>>7),x+=C>>>16,w=O[(k+14)%16],A+=(T=((_=L[(k+14)%16])>>>19|w<<13)^(w>>>29|_<<3)^(_>>>6|w<<26))>>>16,P+=65535&(C=(w>>>19|_<<13)^(_>>>29|w<<3)^w>>>6),x+=C>>>16,x+=(P+=(A+=(E+=65535&T)>>>16)>>>16)>>>16,O[k]=65535&P|x<<16,L[k]=65535&E|A<<16;E=65535&(T=H),A=T>>>16,P=65535&(C=U),x=C>>>16,C=t[0],A+=(T=e[0])>>>16,P+=65535&C,x+=C>>>16,x+=(P+=(A+=(E+=65535&T)>>>16)>>>16)>>>16,t[0]=U=65535&P|x<<16,e[0]=H=65535&E|A<<16,E=65535&(T=B),A=T>>>16,P=65535&(C=R),x=C>>>16,C=t[1],A+=(T=e[1])>>>16,P+=65535&C,x+=C>>>16,x+=(P+=(A+=(E+=65535&T)>>>16)>>>16)>>>16,t[1]=R=65535&P|x<<16,e[1]=B=65535&E|A<<16,E=65535&(T=F),A=T>>>16,P=65535&(C=M),x=C>>>16,C=t[2],A+=(T=e[2])>>>16,P+=65535&C,x+=C>>>16,x+=(P+=(A+=(E+=65535&T)>>>16)>>>16)>>>16,t[2]=M=65535&P|x<<16,e[2]=F=65535&E|A<<16,E=65535&(T=q),A=T>>>16,P=65535&(C=I),x=C>>>16,C=t[3],A+=(T=e[3])>>>16,P+=65535&C,x+=C>>>16,x+=(P+=(A+=(E+=65535&T)>>>16)>>>16)>>>16,t[3]=I=65535&P|x<<16,e[3]=q=65535&E|A<<16,E=65535&(T=Y),A=T>>>16,P=65535&(C=N),x=C>>>16,C=t[4],A+=(T=e[4])>>>16,P+=65535&C,x+=C>>>16,x+=(P+=(A+=(E+=65535&T)>>>16)>>>16)>>>16,t[4]=N=65535&P|x<<16,e[4]=Y=65535&E|A<<16,E=65535&(T=K),A=T>>>16,P=65535&(C=j),x=C>>>16,C=t[5],A+=(T=e[5])>>>16,P+=65535&C,x+=C>>>16,x+=(P+=(A+=(E+=65535&T)>>>16)>>>16)>>>16,t[5]=j=65535&P|x<<16,e[5]=K=65535&E|A<<16,E=65535&(T=$),A=T>>>16,P=65535&(C=D),x=C>>>16,C=t[6],A+=(T=e[6])>>>16,P+=65535&C,x+=C>>>16,x+=(P+=(A+=(E+=65535&T)>>>16)>>>16)>>>16,t[6]=D=65535&P|x<<16,e[6]=$=65535&E|A<<16,E=65535&(T=J),A=T>>>16,P=65535&(C=z),x=C>>>16,C=t[7],A+=(T=e[7])>>>16,P+=65535&C,x+=C>>>16,x+=(P+=(A+=(E+=65535&T)>>>16)>>>16)>>>16,t[7]=z=65535&P|x<<16,e[7]=J=65535&E|A<<16,X+=128,r-=128}return r}function V(t,e,n){var r,i=new Int32Array(8),s=new Int32Array(8),o=new Uint8Array(256),a=n;for(i[0]=1779033703,i[1]=3144134277,i[2]=1013904242,i[3]=2773480762,i[4]=1359893119,i[5]=2600822924,i[6]=528734635,i[7]=1541459225,s[0]=4089235720,s[1]=2227873595,s[2]=4271175723,s[3]=1595750129,s[4]=2917565137,s[5]=725511199,s[6]=4215389547,s[7]=327033209,G(i,s,e,n),n%=128,r=0;r=0;--i)Q(t,e,r=n[i/8|0]>>(7&i)&1),Z(e,t),Z(t,t),Q(t,e,r)}function nt(t,n){var r=[e(),e(),e(),e()];O(r[0],l),O(r[1],d),O(r[2],a),z(r[3],l,d),et(t,r,n)}function rt(t,n,i){var s,o=new Uint8Array(64),a=[e(),e(),e(),e()];for(i||r(n,32),V(o,n,32),o[0]&=248,o[31]&=127,o[31]|=64,nt(a,o),tt(t,a),s=0;s<32;s++)n[s+32]=t[s];return 0}var it=new Float64Array([237,211,245,92,26,99,18,88,214,156,247,162,222,249,222,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16]);function st(t,e){var n,r,i,s;for(r=63;r>=32;--r){for(n=0,i=r-32,s=r-12;i>4)*it[i],n=e[i]>>8,e[i]&=255;for(i=0;i<32;i++)e[i]-=n*it[i];for(r=0;r<32;r++)e[r+1]+=e[r]>>8,t[r]=255&e[r]}function ot(t){var e,n=new Float64Array(64);for(e=0;e<64;e++)n[e]=t[e];for(e=0;e<64;e++)t[e]=0;st(t,n)}function at(t,n,r,i){var s,o,a=new Uint8Array(64),h=new Uint8Array(64),c=new Uint8Array(64),u=new Float64Array(64),l=[e(),e(),e(),e()];V(a,i,32),a[0]&=248,a[31]&=127,a[31]|=64;var d=r+64;for(s=0;s>7&&D(t[0],o,t[0]),z(t[3],t[0],t[1]),0)}(d,i))return-1;for(s=0;s=0},t.sign.keyPair=function(){var t=new Uint8Array(32),e=new Uint8Array(64);return rt(t,e),{publicKey:t,secretKey:e}},t.sign.keyPair.fromSecretKey=function(t){if(ut(t),64!==t.length)throw new Error("bad secret key size");for(var e=new Uint8Array(32),n=0;n{t.console&&t.console.log&&t.console.log(e)}}debug(...t){this.log(this.globalLog,t)}warn(...t){this.log(this.globalLogWarn,t)}error(...t){this.log(this.globalLogError,t)}globalLogWarn(e){t.console&&t.console.warn?t.console.warn(e):this.globalLog(e)}globalLogError(e){t.console&&t.console.error?t.console.error(e):this.globalLogWarn(e)}log(t,...e){var n=r.m.apply(this,arguments);if(i.a.log)i.a.log(n);else if(i.a.logToConsole){t.bind(this)(n)}}}}).call(this,n(6))},function(t,e,n){"use strict";var r=n(4),i={now:()=>Date.now?Date.now():(new Date).valueOf(),defer:t=>new r.a(0,t),method(t,...e){var n=Array.prototype.slice.call(arguments,1);return function(e){return e[t].apply(e,n.concat(arguments))}}};e.a=i},function(t,e,n){"use strict";(function(t){n.d(e,"a",(function(){return s}));var r=n(0),i=n(12);class s{constructor(t){this.callbacks=new i.a,this.global_callbacks=[],this.failThrough=t}bind(t,e,n){return this.callbacks.add(t,e,n),this}bind_global(t){return this.global_callbacks.push(t),this}unbind(t,e,n){return this.callbacks.remove(t,e,n),this}unbind_global(t){return t?(this.global_callbacks=r.g(this.global_callbacks||[],e=>e!==t),this):(this.global_callbacks=[],this)}unbind_all(){return this.unbind(),this.unbind_global(),this}emit(e,n,r){for(var i=0;i0)for(i=0;i{this.onError(t),this.changeState("closed")}),!1}return this.bindListeners(),l.a.debug("Connecting",{transport:this.name,url:t}),this.changeState("connecting"),!0}close(){return!!this.socket&&(this.socket.close(),!0)}send(t){return"open"===this.state&&(c.a.defer(()=>{this.socket&&this.socket.send(t)}),!0)}ping(){"open"===this.state&&this.supportsPing()&&this.socket.ping()}onOpen(){this.hooks.beforeOpen&&this.hooks.beforeOpen(this.socket,this.hooks.urls.getPath(this.key,this.options)),this.changeState("open"),this.socket.onopen=void 0}onError(t){this.emit("error",{type:"WebSocketError",error:t}),this.timeline.error(this.buildTimelineMessage({error:t.toString()}))}onClose(t){t?this.changeState("closed",{code:t.code,reason:t.reason,wasClean:t.wasClean}):this.changeState("closed"),this.unbindListeners(),this.socket=void 0}onMessage(t){this.emit("message",t)}onActivity(){this.emit("activity")}bindListeners(){this.socket.onopen=()=>{this.onOpen()},this.socket.onerror=t=>{this.onError(t)},this.socket.onclose=t=>{this.onClose(t)},this.socket.onmessage=t=>{this.onMessage(t)},this.supportsPing()&&(this.socket.onactivity=()=>{this.onActivity()})}unbindListeners(){this.socket&&(this.socket.onopen=void 0,this.socket.onerror=void 0,this.socket.onclose=void 0,this.socket.onmessage=void 0,this.supportsPing()&&(this.socket.onactivity=void 0))}changeState(t,e){this.state=t,this.timeline.info(this.buildTimelineMessage({state:t,params:e})),this.emit(t,e)}buildTimelineMessage(t){return r.f({cid:this.id},t)}}class f{constructor(t){this.hooks=t}isSupported(t){return this.hooks.isSupported(t)}createConnection(t,e,n,r){return new d(this.hooks,t,e,n,r)}}var p=new f({urls:a,handlesActivityChecks:!1,supportsPing:!1,isInitialized:function(){return Boolean(zt.getWebSocketAPI())},isSupported:function(){return Boolean(zt.getWebSocketAPI())},getSocket:function(t){return zt.createWebSocket(t)}}),g={urls:h,handlesActivityChecks:!1,supportsPing:!0,isInitialized:function(){return!0}},b=r.f({getSocket:function(t){return zt.HTTPFactory.createStreamingSocket(t)}},g),v=r.f({getSocket:function(t){return zt.HTTPFactory.createPollingSocket(t)}},g),y={isSupported:function(){return zt.isXHRSupported()}},m={ws:p,xhr_streaming:new f(r.f({},b,y)),xhr_polling:new f(r.f({},v,y))};class w{constructor(t,e,n){this.manager=t,this.transport=e,this.minPingDelay=n.minPingDelay,this.maxPingDelay=n.maxPingDelay,this.pingDelay=void 0}createConnection(t,e,n,i){i=r.f({},i,{activityTimeout:this.pingDelay});var s=this.transport.createConnection(t,e,n,i),o=null,a=function(){s.unbind("open",a),s.bind("closed",h),o=c.a.now()},h=t=>{if(s.unbind("closed",h),1002===t.code||1003===t.code)this.manager.reportDeath();else if(!t.wasClean&&o){var e=c.a.now()-o;e<2*this.maxPingDelay&&(this.manager.reportDeath(),this.pingDelay=Math.max(e/2,this.minPingDelay))}};return s.bind("open",a),s}isSupported(t){return this.manager.isAlive()&&this.transport.isSupported(t)}}const _={decodeMessage:function(t){try{var e=JSON.parse(t.data),n=e.data;if("string"==typeof n)try{n=JSON.parse(e.data)}catch(t){}var r={event:e.event,channel:e.channel,data:n};return e.user_id&&(r.user_id=e.user_id),r}catch(e){throw{type:"MessageParseError",error:e,data:t.data}}},encodeMessage:function(t){return JSON.stringify(t)},processHandshake:function(t){var e=_.decodeMessage(t);if("pusher:connection_established"===e.event){if(!e.data.activity_timeout)throw"No activity timeout specified in handshake";return{action:"connected",id:e.data.socket_id,activityTimeout:1e3*e.data.activity_timeout}}if("pusher:error"===e.event)return{action:this.getCloseAction(e.data),error:this.getCloseError(e.data)};throw"Invalid handshake"},getCloseAction:function(t){return t.code<4e3?t.code>=1002&&t.code<=1004?"backoff":null:4e3===t.code?"tls_only":t.code<4100?"refused":t.code<4200?"backoff":t.code<4300?"retry":"refused"},getCloseError:function(t){return 1e3!==t.code&&1001!==t.code?{type:"PusherError",data:{code:t.code,message:t.reason||t.message}}:null}};var S=_;class k extends u.a{constructor(t,e){super(),this.id=t,this.transport=e,this.activityTimeout=e.activityTimeout,this.bindListeners()}handlesActivityChecks(){return this.transport.handlesActivityChecks()}send(t){return this.transport.send(t)}send_event(t,e,n){var r={event:t,data:e};return n&&(r.channel=n),l.a.debug("Event sent",r),this.send(S.encodeMessage(r))}ping(){this.transport.supportsPing()?this.transport.ping():this.send_event("pusher:ping",{})}close(){this.transport.close()}bindListeners(){var t={message:t=>{var e;try{e=S.decodeMessage(t)}catch(e){this.emit("error",{type:"MessageParseError",error:e,data:t.data})}if(void 0!==e){switch(l.a.debug("Event recd",e),e.event){case"pusher:error":this.emit("error",{type:"PusherError",data:e.data});break;case"pusher:ping":this.emit("ping");break;case"pusher:pong":this.emit("pong")}this.emit("message",e)}},activity:()=>{this.emit("activity")},error:t=>{this.emit("error",t)},closed:t=>{e(),t&&t.code&&this.handleCloseEvent(t),this.transport=null,this.emit("closed")}},e=()=>{r.k(t,(t,e)=>{this.transport.unbind(e,t)})};r.k(t,(t,e)=>{this.transport.bind(e,t)})}handleCloseEvent(t){var e=S.getCloseAction(t),n=S.getCloseError(t);n&&this.emit("error",n),e&&this.emit(e,{action:e,error:n})}}class C{constructor(t,e){this.transport=t,this.callback=e,this.bindListeners()}close(){this.unbindListeners(),this.transport.close()}bindListeners(){this.onMessage=t=>{var e;this.unbindListeners();try{e=S.processHandshake(t)}catch(t){return this.finish("error",{error:t}),void this.transport.close()}"connected"===e.action?this.finish("connected",{connection:new k(e.id,this.transport),activityTimeout:e.activityTimeout}):(this.finish(e.action,{error:e.error}),this.transport.close())},this.onClosed=t=>{this.unbindListeners();var e=S.getCloseAction(t)||"backoff",n=S.getCloseError(t);this.finish(e,{error:n})},this.transport.bind("message",this.onMessage),this.transport.bind("closed",this.onClosed)}unbindListeners(){this.transport.unbind("message",this.onMessage),this.transport.unbind("closed",this.onClosed)}finish(t,e){this.callback(r.f({transport:this.transport,action:t},e))}}class T{constructor(t,e){this.timeline=t,this.options=e||{}}send(t,e){this.timeline.isEmpty()||this.timeline.send(zt.TimelineTransport.getAgent(this,t),e)}}class E extends Error{constructor(t){super(t),Object.setPrototypeOf(this,new.target.prototype)}}class A extends Error{constructor(t){super(t),Object.setPrototypeOf(this,new.target.prototype)}}Error;class P extends Error{constructor(t){super(t),Object.setPrototypeOf(this,new.target.prototype)}}class x extends Error{constructor(t){super(t),Object.setPrototypeOf(this,new.target.prototype)}}class O extends Error{constructor(t){super(t),Object.setPrototypeOf(this,new.target.prototype)}}class L extends Error{constructor(t){super(t),Object.setPrototypeOf(this,new.target.prototype)}}class U extends Error{constructor(t){super(t),Object.setPrototypeOf(this,new.target.prototype)}}class R extends Error{constructor(t,e){super(e),this.status=t,Object.setPrototypeOf(this,new.target.prototype)}}const M={baseUrl:"https://pusher.com",urls:{authenticationEndpoint:{path:"/docs/channels/server_api/authenticating_users"},authorizationEndpoint:{path:"/docs/channels/server_api/authorizing-users/"},javascriptQuickStart:{path:"/docs/javascript_quick_start"},triggeringClientEvents:{path:"/docs/client_api_guide/client_events#trigger-events"},encryptedChannelSupport:{fullUrl:"https://github.com/pusher/pusher-js/tree/cc491015371a4bde5743d1c87a0fbac0feb53195#encrypted-channel-support"}}};var I=function(t){const e=M.urls[t];if(!e)return"";let n;return e.fullUrl?n=e.fullUrl:e.path&&(n=M.baseUrl+e.path),n?"See: "+n:""};class N extends u.a{constructor(t,e){super((function(e,n){l.a.debug("No callbacks on "+t+" for "+e)})),this.name=t,this.pusher=e,this.subscribed=!1,this.subscriptionPending=!1,this.subscriptionCancelled=!1}authorize(t,e){return e(null,{auth:""})}trigger(t,e){if(0!==t.indexOf("client-"))throw new E("Event '"+t+"' does not start with 'client-'");if(!this.subscribed){var n=I("triggeringClientEvents");l.a.warn("Client event triggered before channel 'subscription_succeeded' event . "+n)}return this.pusher.send_event(t,e,this.name)}disconnect(){this.subscribed=!1,this.subscriptionPending=!1}handleEvent(t){var e=t.event,n=t.data;if("pusher_internal:subscription_succeeded"===e)this.handleSubscriptionSucceededEvent(t);else if("pusher_internal:subscription_count"===e)this.handleSubscriptionCountEvent(t);else if(0!==e.indexOf("pusher_internal:")){this.emit(e,n,{})}}handleSubscriptionSucceededEvent(t){this.subscriptionPending=!1,this.subscribed=!0,this.subscriptionCancelled?this.pusher.unsubscribe(this.name):this.emit("pusher:subscription_succeeded",t.data)}handleSubscriptionCountEvent(t){t.data.subscription_count&&(this.subscriptionCount=t.data.subscription_count),this.emit("pusher:subscription_count",t.data)}subscribe(){this.subscribed||(this.subscriptionPending=!0,this.subscriptionCancelled=!1,this.authorize(this.pusher.connection.socket_id,(t,e)=>{t?(this.subscriptionPending=!1,l.a.error(t.toString()),this.emit("pusher:subscription_error",Object.assign({},{type:"AuthError",error:t.message},t instanceof R?{status:t.status}:{}))):this.pusher.send_event("pusher:subscribe",{auth:e.auth,channel_data:e.channel_data,channel:this.name})}))}unsubscribe(){this.subscribed=!1,this.pusher.send_event("pusher:unsubscribe",{channel:this.name})}cancelSubscription(){this.subscriptionCancelled=!0}reinstateSubscription(){this.subscriptionCancelled=!1}}class j extends N{authorize(t,e){return this.pusher.config.channelAuthorizer({channelName:this.name,socketId:t},e)}}class D{constructor(){this.reset()}get(t){return Object.prototype.hasOwnProperty.call(this.members,t)?{id:t,info:this.members[t]}:null}each(t){r.k(this.members,(e,n)=>{t(this.get(n))})}setMyID(t){this.myID=t}onSubscription(t){this.members=t.presence.hash,this.count=t.presence.count,this.me=this.get(this.myID)}addMember(t){return null===this.get(t.user_id)&&this.count++,this.members[t.user_id]=t.user_info,this.get(t.user_id)}removeMember(t){var e=this.get(t.user_id);return e&&(delete this.members[t.user_id],this.count--),e}reset(){this.members={},this.count=0,this.myID=null,this.me=null}}var z=function(t,e,n,r){return new(n||(n=Promise))((function(i,s){function o(t){try{h(r.next(t))}catch(t){s(t)}}function a(t){try{h(r.throw(t))}catch(t){s(t)}}function h(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(o,a)}h((r=r.apply(t,e||[])).next())}))};class H extends j{constructor(t,e){super(t,e),this.members=new D}authorize(t,e){super.authorize(t,(t,n)=>z(this,void 0,void 0,(function*(){if(!t)if(null!=(n=n).channel_data){var r=JSON.parse(n.channel_data);this.members.setMyID(r.user_id)}else{if(yield this.pusher.user.signinDonePromise,null==this.pusher.user.user_data){let t=I("authorizationEndpoint");return l.a.error(`Invalid auth response for channel '${this.name}', expected 'channel_data' field. ${t}, or the user should be signed in.`),void e("Invalid auth response")}this.members.setMyID(this.pusher.user.user_data.id)}e(t,n)})))}handleEvent(t){var e=t.event;if(0===e.indexOf("pusher_internal:"))this.handleInternalEvent(t);else{var n=t.data,r={};t.user_id&&(r.user_id=t.user_id),this.emit(e,n,r)}}handleInternalEvent(t){var e=t.event,n=t.data;switch(e){case"pusher_internal:subscription_succeeded":this.handleSubscriptionSucceededEvent(t);break;case"pusher_internal:subscription_count":this.handleSubscriptionCountEvent(t);break;case"pusher_internal:member_added":var r=this.members.addMember(n);this.emit("pusher:member_added",r);break;case"pusher_internal:member_removed":var i=this.members.removeMember(n);i&&this.emit("pusher:member_removed",i)}}handleSubscriptionSucceededEvent(t){this.subscriptionPending=!1,this.subscribed=!0,this.subscriptionCancelled?this.pusher.unsubscribe(this.name):(this.members.onSubscription(t.data),this.emit("pusher:subscription_succeeded",this.members))}disconnect(){this.members.reset(),super.disconnect()}}var B=n(13),F=n(8);class q extends j{constructor(t,e,n){super(t,e),this.key=null,this.nacl=n}authorize(t,e){super.authorize(t,(t,n)=>{if(t)return void e(t,n);let r=n.shared_secret;r?(this.key=Object(F.decode)(r),delete n.shared_secret,e(null,n)):e(new Error("No shared_secret key in auth payload for encrypted channel: "+this.name),null)})}trigger(t,e){throw new O("Client events are not currently supported for encrypted channels")}handleEvent(t){var e=t.event,n=t.data;0!==e.indexOf("pusher_internal:")&&0!==e.indexOf("pusher:")?this.handleEncryptedEvent(e,n):super.handleEvent(t)}handleEncryptedEvent(t,e){if(!this.key)return void l.a.debug("Received encrypted event before key has been retrieved from the authEndpoint");if(!e.ciphertext||!e.nonce)return void l.a.error("Unexpected format for encrypted event, expected object with `ciphertext` and `nonce` fields, got: "+e);let n=Object(F.decode)(e.ciphertext);if(n.length{e?l.a.error(`Failed to make a request to the authEndpoint: ${s}. Unable to fetch new key, so dropping encrypted event`):(i=this.nacl.secretbox.open(n,r,this.key),null!==i?this.emit(t,this.getDataToEmit(i)):l.a.error("Failed to decrypt event with new key. Dropping encrypted event"))});this.emit(t,this.getDataToEmit(i))}getDataToEmit(t){let e=Object(B.decode)(t);try{return JSON.parse(e)}catch(t){return e}}}var Y=n(4);class K extends u.a{constructor(t,e){super(),this.state="initialized",this.connection=null,this.key=t,this.options=e,this.timeline=this.options.timeline,this.usingTLS=this.options.useTLS,this.errorCallbacks=this.buildErrorCallbacks(),this.connectionCallbacks=this.buildConnectionCallbacks(this.errorCallbacks),this.handshakeCallbacks=this.buildHandshakeCallbacks(this.errorCallbacks);var n=zt.getNetwork();n.bind("online",()=>{this.timeline.info({netinfo:"online"}),"connecting"!==this.state&&"unavailable"!==this.state||this.retryIn(0)}),n.bind("offline",()=>{this.timeline.info({netinfo:"offline"}),this.connection&&this.sendActivityCheck()}),this.updateStrategy()}switchCluster(t){this.key=t,this.updateStrategy(),this.retryIn(0)}connect(){this.connection||this.runner||(this.strategy.isSupported()?(this.updateState("connecting"),this.startConnecting(),this.setUnavailableTimer()):this.updateState("failed"))}send(t){return!!this.connection&&this.connection.send(t)}send_event(t,e,n){return!!this.connection&&this.connection.send_event(t,e,n)}disconnect(){this.disconnectInternally(),this.updateState("disconnected")}isUsingTLS(){return this.usingTLS}startConnecting(){var t=(e,n)=>{e?this.runner=this.strategy.connect(0,t):"error"===n.action?(this.emit("error",{type:"HandshakeError",error:n.error}),this.timeline.error({handshakeError:n.error})):(this.abortConnecting(),this.handshakeCallbacks[n.action](n))};this.runner=this.strategy.connect(0,t)}abortConnecting(){this.runner&&(this.runner.abort(),this.runner=null)}disconnectInternally(){(this.abortConnecting(),this.clearRetryTimer(),this.clearUnavailableTimer(),this.connection)&&this.abandonConnection().close()}updateStrategy(){this.strategy=this.options.getStrategy({key:this.key,timeline:this.timeline,useTLS:this.usingTLS})}retryIn(t){this.timeline.info({action:"retry",delay:t}),t>0&&this.emit("connecting_in",Math.round(t/1e3)),this.retryTimer=new Y.a(t||0,()=>{this.disconnectInternally(),this.connect()})}clearRetryTimer(){this.retryTimer&&(this.retryTimer.ensureAborted(),this.retryTimer=null)}setUnavailableTimer(){this.unavailableTimer=new Y.a(this.options.unavailableTimeout,()=>{this.updateState("unavailable")})}clearUnavailableTimer(){this.unavailableTimer&&this.unavailableTimer.ensureAborted()}sendActivityCheck(){this.stopActivityCheck(),this.connection.ping(),this.activityTimer=new Y.a(this.options.pongTimeout,()=>{this.timeline.error({pong_timed_out:this.options.pongTimeout}),this.retryIn(0)})}resetActivityCheck(){this.stopActivityCheck(),this.connection&&!this.connection.handlesActivityChecks()&&(this.activityTimer=new Y.a(this.activityTimeout,()=>{this.sendActivityCheck()}))}stopActivityCheck(){this.activityTimer&&this.activityTimer.ensureAborted()}buildConnectionCallbacks(t){return r.f({},t,{message:t=>{this.resetActivityCheck(),this.emit("message",t)},ping:()=>{this.send_event("pusher:pong",{})},activity:()=>{this.resetActivityCheck()},error:t=>{this.emit("error",t)},closed:()=>{this.abandonConnection(),this.shouldRetry()&&this.retryIn(1e3)}})}buildHandshakeCallbacks(t){return r.f({},t,{connected:t=>{this.activityTimeout=Math.min(this.options.activityTimeout,t.activityTimeout,t.connection.activityTimeout||1/0),this.clearUnavailableTimer(),this.setConnection(t.connection),this.socket_id=this.connection.id,this.updateState("connected",{socket_id:this.socket_id})}})}buildErrorCallbacks(){let t=t=>e=>{e.error&&this.emit("error",{type:"WebSocketError",error:e.error}),t(e)};return{tls_only:t(()=>{this.usingTLS=!0,this.updateStrategy(),this.retryIn(0)}),refused:t(()=>{this.disconnect()}),backoff:t(()=>{this.retryIn(1e3)}),retry:t(()=>{this.retryIn(0)})}}setConnection(t){for(var e in this.connection=t,this.connectionCallbacks)this.connection.bind(e,this.connectionCallbacks[e]);this.resetActivityCheck()}abandonConnection(){if(this.connection){for(var t in this.stopActivityCheck(),this.connectionCallbacks)this.connection.unbind(t,this.connectionCallbacks[t]);var e=this.connection;return this.connection=null,e}}updateState(t,e){var n=this.state;if(this.state=t,n!==t){var r=t;"connected"===r&&(r+=" with new socket ID "+e.socket_id),l.a.debug("State changed",n+" -> "+r),this.timeline.info({state:t,params:e}),this.emit("state_change",{previous:n,current:t}),this.emit(t,e)}}shouldRetry(){return"connecting"===this.state||"connected"===this.state}}class ${constructor(){this.channels={}}add(t,e){return this.channels[t]||(this.channels[t]=function(t,e){if(0===t.indexOf("private-encrypted-")){if(e.config.nacl)return J.createEncryptedChannel(t,e,e.config.nacl);let n="Tried to subscribe to a private-encrypted- channel but no nacl implementation available",r=I("encryptedChannelSupport");throw new O(`${n}. ${r}`)}if(0===t.indexOf("private-"))return J.createPrivateChannel(t,e);if(0===t.indexOf("presence-"))return J.createPresenceChannel(t,e);if(0===t.indexOf("#"))throw new A('Cannot create a channel with name "'+t+'".');return J.createChannel(t,e)}(t,e)),this.channels[t]}all(){return r.n(this.channels)}find(t){return this.channels[t]}remove(t){var e=this.channels[t];return delete this.channels[t],e}disconnect(){r.k(this.channels,(function(t){t.disconnect()}))}}var J={createChannels:()=>new $,createConnectionManager:(t,e)=>new K(t,e),createChannel:(t,e)=>new N(t,e),createPrivateChannel:(t,e)=>new j(t,e),createPresenceChannel:(t,e)=>new H(t,e),createEncryptedChannel:(t,e,n)=>new q(t,e,n),createTimelineSender:(t,e)=>new T(t,e),createHandshake:(t,e)=>new C(t,e),createAssistantToTheTransportManager:(t,e,n)=>new w(t,e,n)};class X{constructor(t){this.options=t||{},this.livesLeft=this.options.lives||1/0}getAssistant(t){return J.createAssistantToTheTransportManager(this,t,{minPingDelay:this.options.minPingDelay,maxPingDelay:this.options.maxPingDelay})}isAlive(){return this.livesLeft>0}reportDeath(){this.livesLeft-=1}}class W{constructor(t,e){this.strategies=t,this.loop=Boolean(e.loop),this.failFast=Boolean(e.failFast),this.timeout=e.timeout,this.timeoutLimit=e.timeoutLimit}isSupported(){return r.b(this.strategies,c.a.method("isSupported"))}connect(t,e){var n=this.strategies,r=0,i=this.timeout,s=null,o=(a,h)=>{h?e(null,h):(r+=1,this.loop&&(r%=n.length),r0&&(i=new Y.a(n.timeout,(function(){s.abort(),r(!0)}))),s=t.connect(e,(function(t,e){t&&i&&i.isRunning()&&!n.failFast||(i&&i.ensureAborted(),r(t,e))})),{abort:function(){i&&i.ensureAborted(),s.abort()},forceMinPriority:function(t){s.forceMinPriority(t)}}}}class G{constructor(t){this.strategies=t}isSupported(){return r.b(this.strategies,c.a.method("isSupported"))}connect(t,e){return function(t,e,n){var i=r.j(t,(function(t,r,i,s){return t.connect(e,n(r,s))}));return{abort:function(){r.c(i,V)},forceMinPriority:function(t){r.c(i,(function(e){e.forceMinPriority(t)}))}}}(this.strategies,t,(function(t,n){return function(i,s){n[t].error=i,i?function(t){return r.a(t,(function(t){return Boolean(t.error)}))}(n)&&e(!0):(r.c(n,(function(t){t.forceMinPriority(s.transport.priority)})),e(null,s))}}))}}function V(t){t.error||t.aborted||(t.abort(),t.aborted=!0)}class Z{constructor(t,e,n){this.strategy=t,this.transports=e,this.ttl=n.ttl||18e5,this.usingTLS=n.useTLS,this.timeline=n.timeline}isSupported(){return this.strategy.isSupported()}connect(t,e){var n=this.usingTLS,i=function(t){var e=zt.getLocalStorage();if(e)try{var n=e[Q(t)];if(n)return JSON.parse(n)}catch(e){tt(t)}return null}(n),s=i&&i.cacheSkipCount?i.cacheSkipCount:0,o=[this.strategy];if(i&&i.timestamp+this.ttl>=c.a.now()){var a=this.transports[i.transport];a&&(["ws","wss"].includes(i.transport)||s>3?(this.timeline.info({cached:!0,transport:i.transport,latency:i.latency}),o.push(new W([a],{timeout:2*i.latency+1e3,failFast:!0}))):s++)}var h=c.a.now(),u=o.pop().connect(t,(function i(a,l){a?(tt(n),o.length>0?(h=c.a.now(),u=o.pop().connect(t,i)):e(a)):(!function(t,e,n,i){var s=zt.getLocalStorage();if(s)try{s[Q(t)]=r.l({timestamp:c.a.now(),transport:e,latency:n,cacheSkipCount:i})}catch(t){}}(n,l.transport.name,c.a.now()-h,s),e(null,l))}));return{abort:function(){u.abort()},forceMinPriority:function(e){t=e,u&&u.forceMinPriority(e)}}}}function Q(t){return"pusherTransport"+(t?"TLS":"NonTLS")}function tt(t){var e=zt.getLocalStorage();if(e)try{delete e[Q(t)]}catch(t){}}class et{constructor(t,{delay:e}){this.strategy=t,this.options={delay:e}}isSupported(){return this.strategy.isSupported()}connect(t,e){var n,r=this.strategy,i=new Y.a(this.options.delay,(function(){n=r.connect(t,e)}));return{abort:function(){i.ensureAborted(),n&&n.abort()},forceMinPriority:function(e){t=e,n&&n.forceMinPriority(e)}}}}class nt{constructor(t,e,n){this.test=t,this.trueBranch=e,this.falseBranch=n}isSupported(){return(this.test()?this.trueBranch:this.falseBranch).isSupported()}connect(t,e){return(this.test()?this.trueBranch:this.falseBranch).connect(t,e)}}class rt{constructor(t){this.strategy=t}isSupported(){return this.strategy.isSupported()}connect(t,e){var n=this.strategy.connect(t,(function(t,r){r&&n.abort(),e(t,r)}));return n}}function it(t){return function(){return t.isSupported()}}var st=function(t,e,n){var i={};function s(e,r,s,o,a){var h=n(t,e,r,s,o,a);return i[e]=h,h}var o,a=Object.assign({},e,{hostNonTLS:t.wsHost+":"+t.wsPort,hostTLS:t.wsHost+":"+t.wssPort,httpPath:t.wsPath}),h=r.f({},a,{useTLS:!0}),c=Object.assign({},e,{hostNonTLS:t.httpHost+":"+t.httpPort,hostTLS:t.httpHost+":"+t.httpsPort,httpPath:t.httpPath}),u={loop:!0,timeout:15e3,timeoutLimit:6e4},l=new X({minPingDelay:1e4,maxPingDelay:t.activityTimeout}),d=new X({lives:2,minPingDelay:1e4,maxPingDelay:t.activityTimeout}),f=s("ws","ws",3,a,l),p=s("wss","ws",3,h,l),g=s("xhr_streaming","xhr_streaming",1,c,d),b=s("xhr_polling","xhr_polling",1,c),v=new W([f],u),y=new W([p],u),m=new W([g],u),w=new W([b],u),_=new W([new nt(it(m),new G([m,new et(w,{delay:4e3})]),w)],u);return o=e.useTLS?new G([v,new et(_,{delay:2e3})]):new G([v,new et(y,{delay:2e3}),new et(_,{delay:5e3})]),new Z(new rt(new nt(it(f),o,_)),i,{ttl:18e5,timeline:e.timeline,useTLS:e.useTLS})};class ot extends u.a{constructor(t,e,n){super(),this.hooks=t,this.method=e,this.url=n}start(t){this.position=0,this.xhr=this.hooks.getRequest(this),this.unloader=()=>{this.close()},zt.addUnloadListener(this.unloader),this.xhr.open(this.method,this.url,!0),this.xhr.setRequestHeader&&this.xhr.setRequestHeader("Content-Type","application/json"),this.xhr.send(t)}close(){this.unloader&&(zt.removeUnloadListener(this.unloader),this.unloader=null),this.xhr&&(this.hooks.abortRequest(this.xhr),this.xhr=null)}onChunk(t,e){for(;;){var n=this.advanceBuffer(e);if(!n)break;this.emit("chunk",{status:t,data:n})}this.isBufferTooLong(e)&&this.emit("buffer_too_long")}advanceBuffer(t){var e=t.slice(this.position),n=e.indexOf("\n");return-1!==n?(this.position+=n+1,e.slice(0,n)):null}isBufferTooLong(t){return this.position===t.length&&t.length>262144}}var at;!function(t){t[t.CONNECTING=0]="CONNECTING",t[t.OPEN=1]="OPEN",t[t.CLOSED=3]="CLOSED"}(at||(at={}));var ht=at,ct=1;function ut(t){var e=-1===t.indexOf("?")?"?":"&";return t+e+"t="+ +new Date+"&n="+ct++}function lt(t){return zt.randomInt(t)}var dt=class{constructor(t,e){this.hooks=t,this.session=lt(1e3)+"/"+function(t){for(var e=[],n=0;n{this.onChunk(t)}),this.stream.bind("finished",t=>{this.hooks.onFinished(this,t)}),this.stream.bind("buffer_too_long",()=>{this.reconnect()});try{this.stream.start()}catch(t){c.a.defer(()=>{this.onError(t),this.onClose(1006,"Could not start streaming",!1)})}}closeStream(){this.stream&&(this.stream.unbind_all(),this.stream.close(),this.stream=null)}},ft={getReceiveURL:function(t,e){return t.base+"/"+e+"/xhr_streaming"+t.queryString},onHeartbeat:function(t){t.sendRaw("[]")},sendHeartbeat:function(t){t.sendRaw("[]")},onFinished:function(t,e){t.onClose(1006,"Connection interrupted ("+e+")",!1)}},pt={getReceiveURL:function(t,e){return t.base+"/"+e+"/xhr"+t.queryString},onHeartbeat:function(){},sendHeartbeat:function(t){t.sendRaw("[]")},onFinished:function(t,e){200===e?t.reconnect():t.onClose(1006,"Connection interrupted ("+e+")",!1)}},gt={getRequest:function(t){var e=new(zt.getXHRAPI());return e.onreadystatechange=e.onprogress=function(){switch(e.readyState){case 3:e.responseText&&e.responseText.length>0&&t.onChunk(e.status,e.responseText);break;case 4:e.responseText&&e.responseText.length>0&&t.onChunk(e.status,e.responseText),t.emit("finished",e.status),t.close()}},e},abortRequest:function(t){t.onreadystatechange=null,t.abort()}},bt={getDefaultStrategy:st,Transports:m,transportConnectionInitializer:function(){this.timeline.info(this.buildTimelineMessage({transport:this.name+(this.options.useTLS?"s":"")})),this.hooks.isInitialized()?this.changeState("initialized"):this.onClose()},HTTPFactory:{createStreamingSocket(t){return this.createSocket(ft,t)},createPollingSocket(t){return this.createSocket(pt,t)},createSocket:(t,e)=>new dt(t,e),createXHR(t,e){return this.createRequest(gt,t,e)},createRequest:(t,e,n)=>new ot(t,e,n)},setup(t){t.ready()},getLocalStorage(){},getClientFeatures:()=>r.i(r.h({ws:m.ws},(function(t){return t.isSupported({})}))),getProtocol:()=>"http:",isXHRSupported:()=>!0,createSocketRequest(t,e){if(this.isXHRSupported())return this.HTTPFactory.createXHR(t,e);throw"Cross-origin HTTP requests are not supported"},createXHR(){return new(this.getXHRAPI())},createWebSocket(t){return new(this.getWebSocketAPI())(t)},addUnloadListener(t){},removeUnloadListener(t){}},vt=n(10),yt=n.n(vt);function mt(t){return"none"!==t.type.toLowerCase()}class wt extends u.a{constructor(){super(),this.online=!0,yt.a.fetch().then(t=>{this.online=mt(t)}),yt.a.addEventListener(t=>{var e=mt(t);this.online!==e&&(this.online=e,this.online?this.emit("online"):this.emit("offline"))})}isOnline(){return this.online}}var _t,St=new wt;!function(t){t.UserAuthentication="user-authentication",t.ChannelAuthorization="channel-authorization"}(_t||(_t={}));var kt=function(t,e,n,r,i){const s=zt.createXHR();for(var o in s.open("POST",n.endpoint,!0),s.setRequestHeader("Content-Type","application/x-www-form-urlencoded"),n.headers)s.setRequestHeader(o,n.headers[o]);if(null!=n.headersProvider){let t=n.headersProvider();for(var o in t)s.setRequestHeader(o,t[o])}return s.onreadystatechange=function(){if(4===s.readyState)if(200===s.status){let t,e=!1;try{t=JSON.parse(s.responseText),e=!0}catch(t){i(new R(200,`JSON returned from ${r.toString()} endpoint was invalid, yet status code was 200. Data was: ${s.responseText}`),null)}e&&i(null,t)}else{let t="";switch(r){case _t.UserAuthentication:t=I("authenticationEndpoint");break;case _t.ChannelAuthorization:t="Clients must be authorized to join private or presence channels. "+I("authorizationEndpoint")}i(new R(s.status,`Unable to retrieve auth string from ${r.toString()} endpoint - received status: ${s.status} from ${n.endpoint}. ${t}`),null)}},s.send(e),s},Ct={name:"xhr",getAgent:function(t,e){return function(n,i){var s="http"+(e?"s":"")+"://"+(t.host||t.options.host)+t.options.path;s+="/2?"+r.e(n);var o=zt.createXHR();o.open("GET",s,!0),o.onreadystatechange=function(){if(4===o.readyState){let{status:n,responseText:r}=o;if(200!==n)return void l.a.debug(`TimelineSender Error: received ${n} from stats.pusher.com`);try{var{host:e}=JSON.parse(r)}catch(t){l.a.debug("TimelineSenderError: invalid response "+r)}e&&(t.host=e)}},o.send()}}};const{getDefaultStrategy:Tt,Transports:Et,setup:At,getProtocol:Pt,isXHRSupported:xt,getLocalStorage:Ot,createXHR:Lt,createWebSocket:Ut,addUnloadListener:Rt,removeUnloadListener:Mt,transportConnectionInitializer:It,createSocketRequest:Nt,HTTPFactory:jt}=bt;var Dt,zt={getDefaultStrategy:Tt,Transports:Et,setup:At,getProtocol:Pt,isXHRSupported:xt,getLocalStorage:Ot,createXHR:Lt,createWebSocket:Ut,addUnloadListener:Rt,removeUnloadListener:Mt,transportConnectionInitializer:It,createSocketRequest:Nt,HTTPFactory:jt,TimelineTransport:Ct,getAuthorizers:()=>({ajax:kt}),getWebSocketAPI:()=>WebSocket,getXHRAPI:()=>XMLHttpRequest,getNetwork:()=>St,randomInt:t=>Math.floor(Math.random()*t)};!function(t){t[t.ERROR=3]="ERROR",t[t.INFO=6]="INFO",t[t.DEBUG=7]="DEBUG"}(Dt||(Dt={}));var Ht=Dt;class Bt{constructor(t,e,n){this.key=t,this.session=e,this.events=[],this.options=n||{},this.sent=0,this.uniqueID=0}log(t,e){t<=this.options.level&&(this.events.push(r.f({},e,{timestamp:c.a.now()})),this.options.limit&&this.events.length>this.options.limit&&this.events.shift())}error(t){this.log(Ht.ERROR,t)}info(t){this.log(Ht.INFO,t)}debug(t){this.log(Ht.DEBUG,t)}isEmpty(){return 0===this.events.length}send(t,e){var n=r.f({session:this.session,bundle:this.sent+1,key:this.key,lib:"js",version:this.options.version,cluster:this.options.cluster,features:this.options.features,timeline:this.events},this.options.params);return this.events=[],t(n,(t,n)=>{t||this.sent++,e&&e(t,n)}),!0}generateUniqueID(){return this.uniqueID++,this.uniqueID}}class Ft{constructor(t,e,n,r){this.name=t,this.priority=e,this.transport=n,this.options=r||{}}isSupported(){return this.transport.isSupported({useTLS:this.options.useTLS})}connect(t,e){if(!this.isSupported())return qt(new U,e);if(this.priority{n||(u(),s?s.close():i.close())},forceMinPriority:t=>{n||this.priority{if(void 0===zt.getAuthorizers()[t.transport])throw`'${t.transport}' is not a recognized auth transport`;return(e,n)=>{const r=((t,e)=>{var n="socket_id="+encodeURIComponent(t.socketId);for(var r in e.params)n+="&"+encodeURIComponent(r)+"="+encodeURIComponent(e.params[r]);if(null!=e.paramsProvider){let t=e.paramsProvider();for(var r in t)n+="&"+encodeURIComponent(r)+"="+encodeURIComponent(t[r])}return n})(e,t);zt.getAuthorizers()[t.transport](zt,r,t,_t.UserAuthentication,n)}};var Wt=t=>{if(void 0===zt.getAuthorizers()[t.transport])throw`'${t.transport}' is not a recognized auth transport`;return(e,n)=>{const r=((t,e)=>{var n="socket_id="+encodeURIComponent(t.socketId);for(var r in n+="&channel_name="+encodeURIComponent(t.channelName),e.params)n+="&"+encodeURIComponent(r)+"="+encodeURIComponent(e.params[r]);if(null!=e.paramsProvider){let t=e.paramsProvider();for(var r in t)n+="&"+encodeURIComponent(r)+"="+encodeURIComponent(t[r])}return n})(e,t);zt.getAuthorizers()[t.transport](zt,r,t,_t.ChannelAuthorization,n)}};function Gt(t,e){let n={activityTimeout:t.activityTimeout||i.activityTimeout,cluster:t.cluster,httpPath:t.httpPath||i.httpPath,httpPort:t.httpPort||i.httpPort,httpsPort:t.httpsPort||i.httpsPort,pongTimeout:t.pongTimeout||i.pongTimeout,statsHost:t.statsHost||i.stats_host,unavailableTimeout:t.unavailableTimeout||i.unavailableTimeout,wsPath:t.wsPath||i.wsPath,wsPort:t.wsPort||i.wsPort,wssPort:t.wssPort||i.wssPort,enableStats:te(t),httpHost:Vt(t),useTLS:Qt(t),wsHost:Zt(t),userAuthenticator:ee(t),channelAuthorizer:ne(t,e)};return"disabledTransports"in t&&(n.disabledTransports=t.disabledTransports),"enabledTransports"in t&&(n.enabledTransports=t.enabledTransports),"ignoreNullOrigin"in t&&(n.ignoreNullOrigin=t.ignoreNullOrigin),"timelineParams"in t&&(n.timelineParams=t.timelineParams),"nacl"in t&&(n.nacl=t.nacl),n}function Vt(t){return t.httpHost?t.httpHost:t.cluster?`sockjs-${t.cluster}.pusher.com`:i.httpHost}function Zt(t){return t.wsHost?t.wsHost:`ws-${t.cluster}.pusher.com`}function Qt(t){return"https:"===zt.getProtocol()||!1!==t.forceTLS}function te(t){return"enableStats"in t?t.enableStats:"disableStats"in t&&!t.disableStats}function ee(t){const e=Object.assign(Object.assign({},i.userAuthentication),t.userAuthentication);return"customHandler"in e&&null!=e.customHandler?e.customHandler:Xt(e)}function ne(t,e){const n=function(t,e){let n;return"channelAuthorization"in t?n=Object.assign(Object.assign({},i.channelAuthorization),t.channelAuthorization):(n={transport:t.authTransport||i.authTransport,endpoint:t.authEndpoint||i.authEndpoint},"auth"in t&&("params"in t.auth&&(n.params=t.auth.params),"headers"in t.auth&&(n.headers=t.auth.headers)),"authorizer"in t&&(n.customHandler=((t,e,n)=>{const r={authTransport:e.transport,authEndpoint:e.endpoint,auth:{params:e.params,headers:e.headers}};return(e,i)=>{const s=t.channel(e.channelName);n(s,r).authorize(e.socketId,i)}})(e,n,t.authorizer))),n}(t,e);return"customHandler"in n&&null!=n.customHandler?n.customHandler:Wt(n)}class re extends u.a{constructor(t){super((function(t,e){l.a.debug("No callbacks on watchlist events for "+t)})),this.pusher=t,this.bindWatchlistInternalEvent()}handleEvent(t){t.data.events.forEach(t=>{this.emit(t.name,t)})}bindWatchlistInternalEvent(){this.pusher.connection.bind("message",t=>{"pusher_internal:watchlist_events"===t.event&&this.handleEvent(t)})}}var ie=function(){let t,e;return{promise:new Promise((n,r)=>{t=n,e=r}),resolve:t,reject:e}};class se extends u.a{constructor(t){super((function(t,e){l.a.debug("No callbacks on user for "+t)})),this.signin_requested=!1,this.user_data=null,this.serverToUserChannel=null,this.signinDonePromise=null,this._signinDoneResolve=null,this._onAuthorize=(t,e)=>{if(t)return l.a.warn("Error during signin: "+t),void this._cleanup();this.pusher.send_event("pusher:signin",{auth:e.auth,user_data:e.user_data})},this.pusher=t,this.pusher.connection.bind("state_change",({previous:t,current:e})=>{"connected"!==t&&"connected"===e&&this._signin(),"connected"===t&&"connected"!==e&&(this._cleanup(),this._newSigninPromiseIfNeeded())}),this.watchlist=new re(t),this.pusher.connection.bind("message",t=>{"pusher:signin_success"===t.event&&this._onSigninSuccess(t.data),this.serverToUserChannel&&this.serverToUserChannel.name===t.channel&&this.serverToUserChannel.handleEvent(t)})}signin(){this.signin_requested||(this.signin_requested=!0,this._signin())}_signin(){this.signin_requested&&(this._newSigninPromiseIfNeeded(),"connected"===this.pusher.connection.state&&this.pusher.config.userAuthenticator({socketId:this.pusher.connection.socket_id},this._onAuthorize))}_onSigninSuccess(t){try{this.user_data=JSON.parse(t.user_data)}catch(e){return l.a.error("Failed parsing user data after signin: "+t.user_data),void this._cleanup()}if("string"!=typeof this.user_data.id||""===this.user_data.id)return l.a.error("user_data doesn't contain an id. user_data: "+this.user_data),void this._cleanup();this._signinDoneResolve(),this._subscribeChannels()}_subscribeChannels(){this.serverToUserChannel=new N("#server-to-user-"+this.user_data.id,this.pusher),this.serverToUserChannel.bind_global((t,e)=>{0!==t.indexOf("pusher_internal:")&&0!==t.indexOf("pusher:")&&this.emit(t,e)}),(t=>{t.subscriptionPending&&t.subscriptionCancelled?t.reinstateSubscription():t.subscriptionPending||"connected"!==this.pusher.connection.state||t.subscribe()})(this.serverToUserChannel)}_cleanup(){this.user_data=null,this.serverToUserChannel&&(this.serverToUserChannel.unbind_all(),this.serverToUserChannel.disconnect(),this.serverToUserChannel=null),this.signin_requested&&this._signinDoneResolve()}_newSigninPromiseIfNeeded(){if(!this.signin_requested)return;if(this.signinDonePromise&&!this.signinDonePromise.done)return;const{promise:t,resolve:e,reject:n}=ie();t.done=!1;const r=()=>{t.done=!0};t.then(r).catch(r),this.signinDonePromise=t,this._signinDoneResolve=e}}class oe{static ready(){oe.isReady=!0;for(var t=0,e=oe.instances.length;tzt.getDefaultStrategy(this.config,t,Kt),timeline:this.timeline,activityTimeout:this.config.activityTimeout,pongTimeout:this.config.pongTimeout,unavailableTimeout:this.config.unavailableTimeout,useTLS:Boolean(this.config.useTLS)}),this.connection.bind("connected",()=>{this.subscribeAll(),this.timelineSender&&this.timelineSender.send(this.connection.isUsingTLS())}),this.connection.bind("message",t=>{var e=0===t.event.indexOf("pusher_internal:");if(t.channel){var n=this.channel(t.channel);n&&n.handleEvent(t)}e||this.global_emitter.emit(t.event,t.data)}),this.connection.bind("connecting",()=>{this.channels.disconnect()}),this.connection.bind("disconnected",()=>{this.channels.disconnect()}),this.connection.bind("error",t=>{l.a.warn(t)}),oe.instances.push(this),this.timeline.info({instances:oe.instances.length}),this.user=new se(this),oe.isReady&&this.connect()}switchCluster(t){const{appKey:e,cluster:n}=t;this.key=e,this.options=Object.assign(Object.assign({},this.options),{cluster:n}),this.config=Gt(this.options,this),this.connection.switchCluster(this.key)}channel(t){return this.channels.find(t)}allChannels(){return this.channels.all()}connect(){if(this.connection.connect(),this.timelineSender&&!this.timelineSenderTimer){var t=this.connection.isUsingTLS(),e=this.timelineSender;this.timelineSenderTimer=new Y.b(6e4,(function(){e.send(t)}))}}disconnect(){this.connection.disconnect(),this.timelineSenderTimer&&(this.timelineSenderTimer.ensureAborted(),this.timelineSenderTimer=null)}bind(t,e,n){return this.global_emitter.bind(t,e,n),this}unbind(t,e,n){return this.global_emitter.unbind(t,e,n),this}bind_global(t){return this.global_emitter.bind_global(t),this}unbind_global(t){return this.global_emitter.unbind_global(t),this}unbind_all(t){return this.global_emitter.unbind_all(),this}subscribeAll(){var t;for(t in this.channels.channels)this.channels.channels.hasOwnProperty(t)&&this.subscribe(t)}subscribe(t){var e=this.channels.add(t,this);return e.subscriptionPending&&e.subscriptionCancelled?e.reinstateSubscription():e.subscriptionPending||"connected"!==this.connection.state||e.subscribe(),e}unsubscribe(t){var e=this.channels.find(t);e&&e.subscriptionPending?e.cancelSubscription():(e=this.channels.remove(t))&&e.subscribed&&e.unsubscribe()}send_event(t,e,n){return this.connection.send_event(t,e,n)}shouldUseTLS(){return this.config.useTLS}signin(){this.user.signin()}}oe.instances=[],oe.isReady=!1,oe.logToConsole=!1,oe.Runtime=zt,oe.ScriptReceivers=zt.ScriptReceivers,oe.DependenciesReceivers=zt.DependenciesReceivers,oe.auth_callbacks=zt.auth_callbacks;e.a=oe;zt.setup(oe)},function(t,e){var n;n=function(){return this}();try{n=n||new Function("return this")()}catch(t){"object"==typeof window&&(n=window)}t.exports=n},function(t,e,n){"use strict";n.d(e,"a",(function(){return i}));var r=n(1);function i(t){if(null==t)throw"You must pass an options object";if(null==t.cluster)throw"Options object must provide a cluster";"disableStats"in t&&r.a.warn("The disableStats option is deprecated in favor of enableStats")}},function(t,e,n){"use strict";var r,i=this&&this.__extends||(r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)},function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)});Object.defineProperty(e,"__esModule",{value:!0});var s=function(){function t(t){void 0===t&&(t="="),this._paddingCharacter=t}return t.prototype.encodedLength=function(t){return this._paddingCharacter?(t+2)/3*4|0:(8*t+5)/6|0},t.prototype.encode=function(t){for(var e="",n=0;n>>18&63),e+=this._encodeByte(r>>>12&63),e+=this._encodeByte(r>>>6&63),e+=this._encodeByte(r>>>0&63)}var i=t.length-n;if(i>0){r=t[n]<<16|(2===i?t[n+1]<<8:0);e+=this._encodeByte(r>>>18&63),e+=this._encodeByte(r>>>12&63),e+=2===i?this._encodeByte(r>>>6&63):this._paddingCharacter||"",e+=this._paddingCharacter||""}return e},t.prototype.maxDecodedLength=function(t){return this._paddingCharacter?t/4*3|0:(6*t+7)/8|0},t.prototype.decodedLength=function(t){return this.maxDecodedLength(t.length-this._getPaddingLength(t))},t.prototype.decode=function(t){if(0===t.length)return new Uint8Array(0);for(var e=this._getPaddingLength(t),n=t.length-e,r=new Uint8Array(this.maxDecodedLength(n)),i=0,s=0,o=0,a=0,h=0,c=0,u=0;s>>4,r[i++]=h<<4|c>>>2,r[i++]=c<<6|u,o|=256&a,o|=256&h,o|=256&c,o|=256&u;if(s>>4,o|=256&a,o|=256&h),s>>2,o|=256&c),s>>8&6,e+=51-t>>>8&-75,e+=61-t>>>8&-15,e+=62-t>>>8&3,String.fromCharCode(e)},t.prototype._decodeChar=function(t){var e=256;return e+=(42-t&t-44)>>>8&-256+t-43+62,e+=(46-t&t-48)>>>8&-256+t-47+63,e+=(47-t&t-58)>>>8&-256+t-48+52,e+=(64-t&t-91)>>>8&-256+t-65+0,e+=(96-t&t-123)>>>8&-256+t-97+26},t.prototype._getPaddingLength=function(t){var e=0;if(this._paddingCharacter){for(var n=t.length-1;n>=0&&t[n]===this._paddingCharacter;n--)e++;if(t.length<4||e>2)throw new Error("Base64Coder: incorrect padding")}return e},t}();e.Coder=s;var o=new s;e.encode=function(t){return o.encode(t)},e.decode=function(t){return o.decode(t)};var a=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return i(e,t),e.prototype._encodeByte=function(t){var e=t;return e+=65,e+=25-t>>>8&6,e+=51-t>>>8&-75,e+=61-t>>>8&-13,e+=62-t>>>8&49,String.fromCharCode(e)},e.prototype._decodeChar=function(t){var e=256;return e+=(44-t&t-46)>>>8&-256+t-45+62,e+=(94-t&t-96)>>>8&-256+t-95+63,e+=(47-t&t-58)>>>8&-256+t-48+52,e+=(64-t&t-91)>>>8&-256+t-65+0,e+=(96-t&t-123)>>>8&-256+t-97+26},e}(s);e.URLSafeCoder=a;var h=new a;e.encodeURLSafe=function(t){return h.encode(t)},e.decodeURLSafe=function(t){return h.decode(t)},e.encodedLength=function(t){return o.encodedLength(t)},e.maxDecodedLength=function(t){return o.maxDecodedLength(t)},e.decodedLength=function(t){return o.decodedLength(t)}},function(t,e,n){"use strict";e.a=class{constructor(t,e,n,r){this.clear=e,this.timer=t(()=>{this.timer&&(this.timer=r(this.timer))},n)}isRunning(){return null!==this.timer}ensureAborted(){this.timer&&(this.clear(this.timer),this.timer=null)}}},function(t,e){t.exports=require("@react-native-community/netinfo")},function(t,e,n){"use strict";(function(t){function r(t){return d(u(t))}n.d(e,"a",(function(){return r}));for(var i=String.fromCharCode,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",o={},a=0,h=s.length;a>>6)+i(128|63&e):i(224|e>>>12&15)+i(128|e>>>6&63)+i(128|63&e)},u=function(t){return t.replace(/[^\x00-\x7F]/g,c)},l=function(t){var e=[0,2,1][t.length%3],n=t.charCodeAt(0)<<16|(t.length>1?t.charCodeAt(1):0)<<8|(t.length>2?t.charCodeAt(2):0);return[s.charAt(n>>>18),s.charAt(n>>>12&63),e>=2?"=":s.charAt(n>>>6&63),e>=1?"=":s.charAt(63&n)].join("")},d=t.btoa||function(t){return t.replace(/[\s\S]{1,3}/g,l)}}).call(this,n(6))},function(t,e,n){"use strict";n.d(e,"a",(function(){return i}));var r=n(0);class i{constructor(){this._callbacks={}}get(t){return this._callbacks[s(t)]}add(t,e,n){var r=s(t);this._callbacks[r]=this._callbacks[r]||[],this._callbacks[r].push({fn:e,context:n})}remove(t,e,n){if(t||e||n){var i=t?[s(t)]:r.i(this._callbacks);e||n?this.removeCallback(i,e,n):this.removeAllCallbacks(i)}else this._callbacks={}}removeCallback(t,e,n){r.c(t,(function(t){this._callbacks[t]=r.g(this._callbacks[t]||[],(function(t){return e&&e!==t.fn||n&&n!==t.context})),0===this._callbacks[t].length&&delete this._callbacks[t]}),this)}removeAllCallbacks(t){r.c(t,(function(t){delete this._callbacks[t]}),this)}}function s(t){return"_"+t}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r="utf8: invalid source encoding";function i(t){for(var e=0,n=0;n=t.length-1)throw new Error("utf8: invalid string");n++,e+=4}}return e}e.encode=function(t){for(var e=new Uint8Array(i(t)),n=0,r=0;r>6,e[n++]=128|63&s):s<55296?(e[n++]=224|s>>12,e[n++]=128|s>>6&63,e[n++]=128|63&s):(r++,s=(1023&s)<<10,s|=1023&t.charCodeAt(r),s+=65536,e[n++]=240|s>>18,e[n++]=128|s>>12&63,e[n++]=128|s>>6&63,e[n++]=128|63&s)}return e},e.encodedLength=i,e.decode=function(t){for(var e=[],n=0;n=t.length)throw new Error(r);if(128!=(192&(o=t[++n])))throw new Error(r);i=(31&i)<<6|63&o,s=128}else if(i<240){if(n>=t.length-1)throw new Error(r);var o=t[++n],a=t[++n];if(128!=(192&o)||128!=(192&a))throw new Error(r);i=(15&i)<<12|(63&o)<<6|63&a,s=2048}else{if(!(i<248))throw new Error(r);if(n>=t.length-2)throw new Error(r);o=t[++n],a=t[++n];var h=t[++n];if(128!=(192&o)||128!=(192&a)||128!=(192&h))throw new Error(r);i=(15&i)<<18|(63&o)<<12|(63&a)<<6|63&h,s=65536}if(i=55296&&i<=57343)throw new Error(r);if(i>=65536){if(i>1114111)throw new Error(r);i-=65536,e.push(String.fromCharCode(55296|i>>10)),i=56320|1023&i}}e.push(String.fromCharCode(i))}return e.join("")}},function(t,e,n){!function(t){"use strict";var e=function(t){var e,n=new Float64Array(16);if(t)for(e=0;e>24&255,t[e+1]=n>>16&255,t[e+2]=n>>8&255,t[e+3]=255&n,t[e+4]=r>>24&255,t[e+5]=r>>16&255,t[e+6]=r>>8&255,t[e+7]=255&r}function g(t,e,n,r,i){var s,o=0;for(s=0;s>>8)-1}function b(t,e,n,r){return g(t,e,n,r,16)}function v(t,e,n,r){return g(t,e,n,r,32)}function y(t,e,n,r){!function(t,e,n,r){for(var i,s=255&r[0]|(255&r[1])<<8|(255&r[2])<<16|(255&r[3])<<24,o=255&n[0]|(255&n[1])<<8|(255&n[2])<<16|(255&n[3])<<24,a=255&n[4]|(255&n[5])<<8|(255&n[6])<<16|(255&n[7])<<24,h=255&n[8]|(255&n[9])<<8|(255&n[10])<<16|(255&n[11])<<24,c=255&n[12]|(255&n[13])<<8|(255&n[14])<<16|(255&n[15])<<24,u=255&r[4]|(255&r[5])<<8|(255&r[6])<<16|(255&r[7])<<24,l=255&e[0]|(255&e[1])<<8|(255&e[2])<<16|(255&e[3])<<24,d=255&e[4]|(255&e[5])<<8|(255&e[6])<<16|(255&e[7])<<24,f=255&e[8]|(255&e[9])<<8|(255&e[10])<<16|(255&e[11])<<24,p=255&e[12]|(255&e[13])<<8|(255&e[14])<<16|(255&e[15])<<24,g=255&r[8]|(255&r[9])<<8|(255&r[10])<<16|(255&r[11])<<24,b=255&n[16]|(255&n[17])<<8|(255&n[18])<<16|(255&n[19])<<24,v=255&n[20]|(255&n[21])<<8|(255&n[22])<<16|(255&n[23])<<24,y=255&n[24]|(255&n[25])<<8|(255&n[26])<<16|(255&n[27])<<24,m=255&n[28]|(255&n[29])<<8|(255&n[30])<<16|(255&n[31])<<24,w=255&r[12]|(255&r[13])<<8|(255&r[14])<<16|(255&r[15])<<24,_=s,S=o,k=a,C=h,T=c,E=u,A=l,P=d,x=f,O=p,L=g,U=b,R=v,M=y,I=m,N=w,j=0;j<20;j+=2)_^=(i=(R^=(i=(x^=(i=(T^=(i=_+R|0)<<7|i>>>25)+_|0)<<9|i>>>23)+T|0)<<13|i>>>19)+x|0)<<18|i>>>14,E^=(i=(S^=(i=(M^=(i=(O^=(i=E+S|0)<<7|i>>>25)+E|0)<<9|i>>>23)+O|0)<<13|i>>>19)+M|0)<<18|i>>>14,L^=(i=(A^=(i=(k^=(i=(I^=(i=L+A|0)<<7|i>>>25)+L|0)<<9|i>>>23)+I|0)<<13|i>>>19)+k|0)<<18|i>>>14,N^=(i=(U^=(i=(P^=(i=(C^=(i=N+U|0)<<7|i>>>25)+N|0)<<9|i>>>23)+C|0)<<13|i>>>19)+P|0)<<18|i>>>14,_^=(i=(C^=(i=(k^=(i=(S^=(i=_+C|0)<<7|i>>>25)+_|0)<<9|i>>>23)+S|0)<<13|i>>>19)+k|0)<<18|i>>>14,E^=(i=(T^=(i=(P^=(i=(A^=(i=E+T|0)<<7|i>>>25)+E|0)<<9|i>>>23)+A|0)<<13|i>>>19)+P|0)<<18|i>>>14,L^=(i=(O^=(i=(x^=(i=(U^=(i=L+O|0)<<7|i>>>25)+L|0)<<9|i>>>23)+U|0)<<13|i>>>19)+x|0)<<18|i>>>14,N^=(i=(I^=(i=(M^=(i=(R^=(i=N+I|0)<<7|i>>>25)+N|0)<<9|i>>>23)+R|0)<<13|i>>>19)+M|0)<<18|i>>>14;_=_+s|0,S=S+o|0,k=k+a|0,C=C+h|0,T=T+c|0,E=E+u|0,A=A+l|0,P=P+d|0,x=x+f|0,O=O+p|0,L=L+g|0,U=U+b|0,R=R+v|0,M=M+y|0,I=I+m|0,N=N+w|0,t[0]=_>>>0&255,t[1]=_>>>8&255,t[2]=_>>>16&255,t[3]=_>>>24&255,t[4]=S>>>0&255,t[5]=S>>>8&255,t[6]=S>>>16&255,t[7]=S>>>24&255,t[8]=k>>>0&255,t[9]=k>>>8&255,t[10]=k>>>16&255,t[11]=k>>>24&255,t[12]=C>>>0&255,t[13]=C>>>8&255,t[14]=C>>>16&255,t[15]=C>>>24&255,t[16]=T>>>0&255,t[17]=T>>>8&255,t[18]=T>>>16&255,t[19]=T>>>24&255,t[20]=E>>>0&255,t[21]=E>>>8&255,t[22]=E>>>16&255,t[23]=E>>>24&255,t[24]=A>>>0&255,t[25]=A>>>8&255,t[26]=A>>>16&255,t[27]=A>>>24&255,t[28]=P>>>0&255,t[29]=P>>>8&255,t[30]=P>>>16&255,t[31]=P>>>24&255,t[32]=x>>>0&255,t[33]=x>>>8&255,t[34]=x>>>16&255,t[35]=x>>>24&255,t[36]=O>>>0&255,t[37]=O>>>8&255,t[38]=O>>>16&255,t[39]=O>>>24&255,t[40]=L>>>0&255,t[41]=L>>>8&255,t[42]=L>>>16&255,t[43]=L>>>24&255,t[44]=U>>>0&255,t[45]=U>>>8&255,t[46]=U>>>16&255,t[47]=U>>>24&255,t[48]=R>>>0&255,t[49]=R>>>8&255,t[50]=R>>>16&255,t[51]=R>>>24&255,t[52]=M>>>0&255,t[53]=M>>>8&255,t[54]=M>>>16&255,t[55]=M>>>24&255,t[56]=I>>>0&255,t[57]=I>>>8&255,t[58]=I>>>16&255,t[59]=I>>>24&255,t[60]=N>>>0&255,t[61]=N>>>8&255,t[62]=N>>>16&255,t[63]=N>>>24&255}(t,e,n,r)}function m(t,e,n,r){!function(t,e,n,r){for(var i,s=255&r[0]|(255&r[1])<<8|(255&r[2])<<16|(255&r[3])<<24,o=255&n[0]|(255&n[1])<<8|(255&n[2])<<16|(255&n[3])<<24,a=255&n[4]|(255&n[5])<<8|(255&n[6])<<16|(255&n[7])<<24,h=255&n[8]|(255&n[9])<<8|(255&n[10])<<16|(255&n[11])<<24,c=255&n[12]|(255&n[13])<<8|(255&n[14])<<16|(255&n[15])<<24,u=255&r[4]|(255&r[5])<<8|(255&r[6])<<16|(255&r[7])<<24,l=255&e[0]|(255&e[1])<<8|(255&e[2])<<16|(255&e[3])<<24,d=255&e[4]|(255&e[5])<<8|(255&e[6])<<16|(255&e[7])<<24,f=255&e[8]|(255&e[9])<<8|(255&e[10])<<16|(255&e[11])<<24,p=255&e[12]|(255&e[13])<<8|(255&e[14])<<16|(255&e[15])<<24,g=255&r[8]|(255&r[9])<<8|(255&r[10])<<16|(255&r[11])<<24,b=255&n[16]|(255&n[17])<<8|(255&n[18])<<16|(255&n[19])<<24,v=255&n[20]|(255&n[21])<<8|(255&n[22])<<16|(255&n[23])<<24,y=255&n[24]|(255&n[25])<<8|(255&n[26])<<16|(255&n[27])<<24,m=255&n[28]|(255&n[29])<<8|(255&n[30])<<16|(255&n[31])<<24,w=255&r[12]|(255&r[13])<<8|(255&r[14])<<16|(255&r[15])<<24,_=0;_<20;_+=2)s^=(i=(v^=(i=(f^=(i=(c^=(i=s+v|0)<<7|i>>>25)+s|0)<<9|i>>>23)+c|0)<<13|i>>>19)+f|0)<<18|i>>>14,u^=(i=(o^=(i=(y^=(i=(p^=(i=u+o|0)<<7|i>>>25)+u|0)<<9|i>>>23)+p|0)<<13|i>>>19)+y|0)<<18|i>>>14,g^=(i=(l^=(i=(a^=(i=(m^=(i=g+l|0)<<7|i>>>25)+g|0)<<9|i>>>23)+m|0)<<13|i>>>19)+a|0)<<18|i>>>14,w^=(i=(b^=(i=(d^=(i=(h^=(i=w+b|0)<<7|i>>>25)+w|0)<<9|i>>>23)+h|0)<<13|i>>>19)+d|0)<<18|i>>>14,s^=(i=(h^=(i=(a^=(i=(o^=(i=s+h|0)<<7|i>>>25)+s|0)<<9|i>>>23)+o|0)<<13|i>>>19)+a|0)<<18|i>>>14,u^=(i=(c^=(i=(d^=(i=(l^=(i=u+c|0)<<7|i>>>25)+u|0)<<9|i>>>23)+l|0)<<13|i>>>19)+d|0)<<18|i>>>14,g^=(i=(p^=(i=(f^=(i=(b^=(i=g+p|0)<<7|i>>>25)+g|0)<<9|i>>>23)+b|0)<<13|i>>>19)+f|0)<<18|i>>>14,w^=(i=(m^=(i=(y^=(i=(v^=(i=w+m|0)<<7|i>>>25)+w|0)<<9|i>>>23)+v|0)<<13|i>>>19)+y|0)<<18|i>>>14;t[0]=s>>>0&255,t[1]=s>>>8&255,t[2]=s>>>16&255,t[3]=s>>>24&255,t[4]=u>>>0&255,t[5]=u>>>8&255,t[6]=u>>>16&255,t[7]=u>>>24&255,t[8]=g>>>0&255,t[9]=g>>>8&255,t[10]=g>>>16&255,t[11]=g>>>24&255,t[12]=w>>>0&255,t[13]=w>>>8&255,t[14]=w>>>16&255,t[15]=w>>>24&255,t[16]=l>>>0&255,t[17]=l>>>8&255,t[18]=l>>>16&255,t[19]=l>>>24&255,t[20]=d>>>0&255,t[21]=d>>>8&255,t[22]=d>>>16&255,t[23]=d>>>24&255,t[24]=f>>>0&255,t[25]=f>>>8&255,t[26]=f>>>16&255,t[27]=f>>>24&255,t[28]=p>>>0&255,t[29]=p>>>8&255,t[30]=p>>>16&255,t[31]=p>>>24&255}(t,e,n,r)}var w=new Uint8Array([101,120,112,97,110,100,32,51,50,45,98,121,116,101,32,107]);function _(t,e,n,r,i,s,o){var a,h,c=new Uint8Array(16),u=new Uint8Array(64);for(h=0;h<16;h++)c[h]=0;for(h=0;h<8;h++)c[h]=s[h];for(;i>=64;){for(y(u,c,o,w),h=0;h<64;h++)t[e+h]=n[r+h]^u[h];for(a=1,h=8;h<16;h++)a=a+(255&c[h])|0,c[h]=255&a,a>>>=8;i-=64,e+=64,r+=64}if(i>0)for(y(u,c,o,w),h=0;h=64;){for(y(h,a,i,w),o=0;o<64;o++)t[e+o]=h[o];for(s=1,o=8;o<16;o++)s=s+(255&a[o])|0,a[o]=255&s,s>>>=8;n-=64,e+=64}if(n>0)for(y(h,a,i,w),o=0;o>>13|n<<3),r=255&t[4]|(255&t[5])<<8,this.r[2]=7939&(n>>>10|r<<6),i=255&t[6]|(255&t[7])<<8,this.r[3]=8191&(r>>>7|i<<9),s=255&t[8]|(255&t[9])<<8,this.r[4]=255&(i>>>4|s<<12),this.r[5]=s>>>1&8190,o=255&t[10]|(255&t[11])<<8,this.r[6]=8191&(s>>>14|o<<2),a=255&t[12]|(255&t[13])<<8,this.r[7]=8065&(o>>>11|a<<5),h=255&t[14]|(255&t[15])<<8,this.r[8]=8191&(a>>>8|h<<8),this.r[9]=h>>>5&127,this.pad[0]=255&t[16]|(255&t[17])<<8,this.pad[1]=255&t[18]|(255&t[19])<<8,this.pad[2]=255&t[20]|(255&t[21])<<8,this.pad[3]=255&t[22]|(255&t[23])<<8,this.pad[4]=255&t[24]|(255&t[25])<<8,this.pad[5]=255&t[26]|(255&t[27])<<8,this.pad[6]=255&t[28]|(255&t[29])<<8,this.pad[7]=255&t[30]|(255&t[31])<<8};function E(t,e,n,r,i,s){var o=new T(s);return o.update(n,r,i),o.finish(t,e),0}function A(t,e,n,r,i,s){var o=new Uint8Array(16);return E(o,0,n,r,i,s),b(t,e,o,0)}function P(t,e,n,r,i){var s;if(n<32)return-1;for(C(t,0,e,0,n,r,i),E(t,16,t,32,n-32,t),s=0;s<16;s++)t[s]=0;return 0}function x(t,e,n,r,i){var s,o=new Uint8Array(32);if(n<32)return-1;if(k(o,0,32,r,i),0!==A(e,16,e,32,n-32,o))return-1;for(C(t,0,e,0,n,r,i),s=0;s<32;s++)t[s]=0;return 0}function O(t,e){var n;for(n=0;n<16;n++)t[n]=0|e[n]}function L(t){var e,n,r=1;for(e=0;e<16;e++)n=t[e]+r+65535,r=Math.floor(n/65536),t[e]=n-65536*r;t[0]+=r-1+37*(r-1)}function U(t,e,n){for(var r,i=~(n-1),s=0;s<16;s++)r=i&(t[s]^e[s]),t[s]^=r,e[s]^=r}function R(t,n){var r,i,s,o=e(),a=e();for(r=0;r<16;r++)a[r]=n[r];for(L(a),L(a),L(a),i=0;i<2;i++){for(o[0]=a[0]-65517,r=1;r<15;r++)o[r]=a[r]-65535-(o[r-1]>>16&1),o[r-1]&=65535;o[15]=a[15]-32767-(o[14]>>16&1),s=o[15]>>16&1,o[14]&=65535,U(a,o,1-s)}for(r=0;r<16;r++)t[2*r]=255&a[r],t[2*r+1]=a[r]>>8}function M(t,e){var n=new Uint8Array(32),r=new Uint8Array(32);return R(n,t),R(r,e),v(n,0,r,0)}function I(t){var e=new Uint8Array(32);return R(e,t),1&e[0]}function N(t,e){var n;for(n=0;n<16;n++)t[n]=e[2*n]+(e[2*n+1]<<8);t[15]&=32767}function j(t,e,n){for(var r=0;r<16;r++)t[r]=e[r]+n[r]}function D(t,e,n){for(var r=0;r<16;r++)t[r]=e[r]-n[r]}function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38*(k+=r*z),h+=38*(C+=r*H),c+=38*(T+=r*B),u+=38*(E+=r*F),l+=38*(A+=r*q),d+=38*(P+=r*Y),f+=38*(x+=r*K),p+=38*(O+=r*$),g+=38*(L+=r*J),b+=38*(U+=r*X),v+=38*(R+=r*W),y+=38*(M+=r*G),m+=38*(I+=r*V),s=(r=(s+=38*(_+=r*j))+(i=1)+65535)-65536*(i=Math.floor(r/65536)),o=(r=o+i+65535)-65536*(i=Math.floor(r/65536)),a=(r=a+i+65535)-65536*(i=Math.floor(r/65536)),h=(r=h+i+65535)-65536*(i=Math.floor(r/65536)),c=(r=c+i+65535)-65536*(i=Math.floor(r/65536)),u=(r=u+i+65535)-65536*(i=Math.floor(r/65536)),l=(r=l+i+65535)-65536*(i=Math.floor(r/65536)),d=(r=d+i+65535)-65536*(i=Math.floor(r/65536)),f=(r=f+i+65535)-65536*(i=Math.floor(r/65536)),p=(r=p+i+65535)-65536*(i=Math.floor(r/65536)),g=(r=g+i+65535)-65536*(i=Math.floor(r/65536)),b=(r=b+i+65535)-65536*(i=Math.floor(r/65536)),v=(r=v+i+65535)-65536*(i=Math.floor(r/65536)),y=(r=y+i+65535)-65536*(i=Math.floor(r/65536)),m=(r=m+i+65535)-65536*(i=Math.floor(r/65536)),w=(r=w+i+65535)-65536*(i=Math.floor(r/65536)),s=(r=(s+=i-1+37*(i-1))+(i=1)+65535)-65536*(i=Math.floor(r/65536)),o=(r=o+i+65535)-65536*(i=Math.floor(r/65536)),a=(r=a+i+65535)-65536*(i=Math.floor(r/65536)),h=(r=h+i+65535)-65536*(i=Math.floor(r/65536)),c=(r=c+i+65535)-65536*(i=Math.floor(r/65536)),u=(r=u+i+65535)-65536*(i=Math.floor(r/65536)),l=(r=l+i+65535)-65536*(i=Math.floor(r/65536)),d=(r=d+i+65535)-65536*(i=Math.floor(r/65536)),f=(r=f+i+65535)-65536*(i=Math.floor(r/65536)),p=(r=p+i+65535)-65536*(i=Math.floor(r/65536)),g=(r=g+i+65535)-65536*(i=Math.floor(r/65536)),b=(r=b+i+65535)-65536*(i=Math.floor(r/65536)),v=(r=v+i+65535)-65536*(i=Math.floor(r/65536)),y=(r=y+i+65535)-65536*(i=Math.floor(r/65536)),m=(r=m+i+65535)-65536*(i=Math.floor(r/65536)),w=(r=w+i+65535)-65536*(i=Math.floor(r/65536)),s+=i-1+37*(i-1),t[0]=s,t[1]=o,t[2]=a,t[3]=h,t[4]=c,t[5]=u,t[6]=l,t[7]=d,t[8]=f,t[9]=p,t[10]=g,t[11]=b,t[12]=v,t[13]=y,t[14]=m,t[15]=w}function H(t,e){z(t,e,e)}function B(t,n){var r,i=e();for(r=0;r<16;r++)i[r]=n[r];for(r=253;r>=0;r--)H(i,i),2!==r&&4!==r&&z(i,i,n);for(r=0;r<16;r++)t[r]=i[r]}function F(t,n){var r,i=e();for(r=0;r<16;r++)i[r]=n[r];for(r=250;r>=0;r--)H(i,i),1!==r&&z(i,i,n);for(r=0;r<16;r++)t[r]=i[r]}function q(t,n,r){var i,s,o=new Uint8Array(32),a=new Float64Array(80),c=e(),u=e(),l=e(),d=e(),f=e(),p=e();for(s=0;s<31;s++)o[s]=n[s];for(o[31]=127&n[31]|64,o[0]&=248,N(a,r),s=0;s<16;s++)u[s]=a[s],d[s]=c[s]=l[s]=0;for(c[0]=d[0]=1,s=254;s>=0;--s)U(c,u,i=o[s>>>3]>>>(7&s)&1),U(l,d,i),j(f,c,l),D(c,c,l),j(l,u,d),D(u,u,d),H(d,f),H(p,c),z(c,l,c),z(l,u,f),j(f,c,l),D(c,c,l),H(u,c),D(l,d,p),z(c,l,h),j(c,c,d),z(l,l,c),z(c,d,p),z(d,u,a),H(u,f),U(c,u,i),U(l,d,i);for(s=0;s<16;s++)a[s+16]=c[s],a[s+32]=l[s],a[s+48]=u[s],a[s+64]=d[s];var g=a.subarray(32),b=a.subarray(16);return B(g,g),z(b,b,g),R(t,b),0}function Y(t,e){return q(t,e,s)}function K(t,e){return r(e,32),Y(t,e)}function $(t,e,n){var r=new Uint8Array(32);return q(r,n,e),m(t,i,r,w)}T.prototype.blocks=function(t,e,n){for(var r,i,s,o,a,h,c,u,l,d,f,p,g,b,v,y,m,w,_,S=this.fin?0:2048,k=this.h[0],C=this.h[1],T=this.h[2],E=this.h[3],A=this.h[4],P=this.h[5],x=this.h[6],O=this.h[7],L=this.h[8],U=this.h[9],R=this.r[0],M=this.r[1],I=this.r[2],N=this.r[3],j=this.r[4],D=this.r[5],z=this.r[6],H=this.r[7],B=this.r[8],F=this.r[9];n>=16;)d=l=0,d+=(k+=8191&(r=255&t[e+0]|(255&t[e+1])<<8))*R,d+=(C+=8191&(r>>>13|(i=255&t[e+2]|(255&t[e+3])<<8)<<3))*(5*F),d+=(T+=8191&(i>>>10|(s=255&t[e+4]|(255&t[e+5])<<8)<<6))*(5*B),d+=(E+=8191&(s>>>7|(o=255&t[e+6]|(255&t[e+7])<<8)<<9))*(5*H),l=(d+=(A+=8191&(o>>>4|(a=255&t[e+8]|(255&t[e+9])<<8)<<12))*(5*z))>>>13,d&=8191,d+=(P+=a>>>1&8191)*(5*D),d+=(x+=8191&(a>>>14|(h=255&t[e+10]|(255&t[e+11])<<8)<<2))*(5*j),d+=(O+=8191&(h>>>11|(c=255&t[e+12]|(255&t[e+13])<<8)<<5))*(5*N),d+=(L+=8191&(c>>>8|(u=255&t[e+14]|(255&t[e+15])<<8)<<8))*(5*I),f=l+=(d+=(U+=u>>>5|S)*(5*M))>>>13,f+=k*M,f+=C*R,f+=T*(5*F),f+=E*(5*B),l=(f+=A*(5*H))>>>13,f&=8191,f+=P*(5*z),f+=x*(5*D),f+=O*(5*j),f+=L*(5*N),l+=(f+=U*(5*I))>>>13,f&=8191,p=l,p+=k*I,p+=C*M,p+=T*R,p+=E*(5*F),l=(p+=A*(5*B))>>>13,p&=8191,p+=P*(5*H),p+=x*(5*z),p+=O*(5*D),p+=L*(5*j),g=l+=(p+=U*(5*N))>>>13,g+=k*N,g+=C*I,g+=T*M,g+=E*R,l=(g+=A*(5*F))>>>13,g&=8191,g+=P*(5*B),g+=x*(5*H),g+=O*(5*z),g+=L*(5*D),b=l+=(g+=U*(5*j))>>>13,b+=k*j,b+=C*N,b+=T*I,b+=E*M,l=(b+=A*R)>>>13,b&=8191,b+=P*(5*F),b+=x*(5*B),b+=O*(5*H),b+=L*(5*z),v=l+=(b+=U*(5*D))>>>13,v+=k*D,v+=C*j,v+=T*N,v+=E*I,l=(v+=A*M)>>>13,v&=8191,v+=P*R,v+=x*(5*F),v+=O*(5*B),v+=L*(5*H),y=l+=(v+=U*(5*z))>>>13,y+=k*z,y+=C*D,y+=T*j,y+=E*N,l=(y+=A*I)>>>13,y&=8191,y+=P*M,y+=x*R,y+=O*(5*F),y+=L*(5*B),m=l+=(y+=U*(5*H))>>>13,m+=k*H,m+=C*z,m+=T*D,m+=E*j,l=(m+=A*N)>>>13,m&=8191,m+=P*I,m+=x*M,m+=O*R,m+=L*(5*F),w=l+=(m+=U*(5*B))>>>13,w+=k*B,w+=C*H,w+=T*z,w+=E*D,l=(w+=A*j)>>>13,w&=8191,w+=P*N,w+=x*I,w+=O*M,w+=L*R,_=l+=(w+=U*(5*F))>>>13,_+=k*F,_+=C*B,_+=T*H,_+=E*z,l=(_+=A*D)>>>13,_&=8191,_+=P*j,_+=x*N,_+=O*I,_+=L*M,k=d=8191&(l=(l=((l+=(_+=U*R)>>>13)<<2)+l|0)+(d&=8191)|0),C=f+=l>>>=13,T=p&=8191,E=g&=8191,A=b&=8191,P=v&=8191,x=y&=8191,O=m&=8191,L=w&=8191,U=_&=8191,e+=16,n-=16;this.h[0]=k,this.h[1]=C,this.h[2]=T,this.h[3]=E,this.h[4]=A,this.h[5]=P,this.h[6]=x,this.h[7]=O,this.h[8]=L,this.h[9]=U},T.prototype.finish=function(t,e){var n,r,i,s,o=new Uint16Array(10);if(this.leftover){for(s=this.leftover,this.buffer[s++]=1;s<16;s++)this.buffer[s]=0;this.fin=1,this.blocks(this.buffer,0,16)}for(n=this.h[1]>>>13,this.h[1]&=8191,s=2;s<10;s++)this.h[s]+=n,n=this.h[s]>>>13,this.h[s]&=8191;for(this.h[0]+=5*n,n=this.h[0]>>>13,this.h[0]&=8191,this.h[1]+=n,n=this.h[1]>>>13,this.h[1]&=8191,this.h[2]+=n,o[0]=this.h[0]+5,n=o[0]>>>13,o[0]&=8191,s=1;s<10;s++)o[s]=this.h[s]+n,n=o[s]>>>13,o[s]&=8191;for(o[9]-=8192,r=(1^n)-1,s=0;s<10;s++)o[s]&=r;for(r=~r,s=0;s<10;s++)this.h[s]=this.h[s]&r|o[s];for(this.h[0]=65535&(this.h[0]|this.h[1]<<13),this.h[1]=65535&(this.h[1]>>>3|this.h[2]<<10),this.h[2]=65535&(this.h[2]>>>6|this.h[3]<<7),this.h[3]=65535&(this.h[3]>>>9|this.h[4]<<4),this.h[4]=65535&(this.h[4]>>>12|this.h[5]<<1|this.h[6]<<14),this.h[5]=65535&(this.h[6]>>>2|this.h[7]<<11),this.h[6]=65535&(this.h[7]>>>5|this.h[8]<<8),this.h[7]=65535&(this.h[8]>>>8|this.h[9]<<5),i=this.h[0]+this.pad[0],this.h[0]=65535&i,s=1;s<8;s++)i=(this.h[s]+this.pad[s]|0)+(i>>>16)|0,this.h[s]=65535&i;t[e+0]=this.h[0]>>>0&255,t[e+1]=this.h[0]>>>8&255,t[e+2]=this.h[1]>>>0&255,t[e+3]=this.h[1]>>>8&255,t[e+4]=this.h[2]>>>0&255,t[e+5]=this.h[2]>>>8&255,t[e+6]=this.h[3]>>>0&255,t[e+7]=this.h[3]>>>8&255,t[e+8]=this.h[4]>>>0&255,t[e+9]=this.h[4]>>>8&255,t[e+10]=this.h[5]>>>0&255,t[e+11]=this.h[5]>>>8&255,t[e+12]=this.h[6]>>>0&255,t[e+13]=this.h[6]>>>8&255,t[e+14]=this.h[7]>>>0&255,t[e+15]=this.h[7]>>>8&255},T.prototype.update=function(t,e,n){var r,i;if(this.leftover){for((i=16-this.leftover)>n&&(i=n),r=0;r=16&&(i=n-n%16,this.blocks(t,e,i),e+=i,n-=i),n){for(r=0;r=128;){for(S=0;S<16;S++)k=8*S+X,O[S]=n[k+0]<<24|n[k+1]<<16|n[k+2]<<8|n[k+3],L[S]=n[k+4]<<24|n[k+5]<<16|n[k+6]<<8|n[k+7];for(S=0;S<80;S++)if(i=U,s=R,o=M,a=I,h=N,c=j,u=D,z,d=H,f=B,p=F,g=q,b=Y,v=K,y=$,J,E=65535&(T=J),A=T>>>16,P=65535&(C=z),x=C>>>16,E+=65535&(T=(Y>>>14|N<<18)^(Y>>>18|N<<14)^(N>>>9|Y<<23)),A+=T>>>16,P+=65535&(C=(N>>>14|Y<<18)^(N>>>18|Y<<14)^(Y>>>9|N<<23)),x+=C>>>16,E+=65535&(T=Y&K^~Y&$),A+=T>>>16,P+=65535&(C=N&j^~N&D),x+=C>>>16,E+=65535&(T=W[2*S+1]),A+=T>>>16,P+=65535&(C=W[2*S]),x+=C>>>16,C=O[S%16],A+=(T=L[S%16])>>>16,P+=65535&C,x+=C>>>16,P+=(A+=(E+=65535&T)>>>16)>>>16,E=65535&(T=_=65535&E|A<<16),A=T>>>16,P=65535&(C=w=65535&P|(x+=P>>>16)<<16),x=C>>>16,E+=65535&(T=(H>>>28|U<<4)^(U>>>2|H<<30)^(U>>>7|H<<25)),A+=T>>>16,P+=65535&(C=(U>>>28|H<<4)^(H>>>2|U<<30)^(H>>>7|U<<25)),x+=C>>>16,A+=(T=H&B^H&F^B&F)>>>16,P+=65535&(C=U&R^U&M^R&M),x+=C>>>16,l=65535&(P+=(A+=(E+=65535&T)>>>16)>>>16)|(x+=P>>>16)<<16,m=65535&E|A<<16,E=65535&(T=g),A=T>>>16,P=65535&(C=a),x=C>>>16,A+=(T=_)>>>16,P+=65535&(C=w),x+=C>>>16,R=i,M=s,I=o,N=a=65535&(P+=(A+=(E+=65535&T)>>>16)>>>16)|(x+=P>>>16)<<16,j=h,D=c,z=u,U=l,B=d,F=f,q=p,Y=g=65535&E|A<<16,K=b,$=v,J=y,H=m,S%16==15)for(k=0;k<16;k++)C=O[k],E=65535&(T=L[k]),A=T>>>16,P=65535&C,x=C>>>16,C=O[(k+9)%16],E+=65535&(T=L[(k+9)%16]),A+=T>>>16,P+=65535&C,x+=C>>>16,w=O[(k+1)%16],E+=65535&(T=((_=L[(k+1)%16])>>>1|w<<31)^(_>>>8|w<<24)^(_>>>7|w<<25)),A+=T>>>16,P+=65535&(C=(w>>>1|_<<31)^(w>>>8|_<<24)^w>>>7),x+=C>>>16,w=O[(k+14)%16],A+=(T=((_=L[(k+14)%16])>>>19|w<<13)^(w>>>29|_<<3)^(_>>>6|w<<26))>>>16,P+=65535&(C=(w>>>19|_<<13)^(_>>>29|w<<3)^w>>>6),x+=C>>>16,x+=(P+=(A+=(E+=65535&T)>>>16)>>>16)>>>16,O[k]=65535&P|x<<16,L[k]=65535&E|A<<16;E=65535&(T=H),A=T>>>16,P=65535&(C=U),x=C>>>16,C=t[0],A+=(T=e[0])>>>16,P+=65535&C,x+=C>>>16,x+=(P+=(A+=(E+=65535&T)>>>16)>>>16)>>>16,t[0]=U=65535&P|x<<16,e[0]=H=65535&E|A<<16,E=65535&(T=B),A=T>>>16,P=65535&(C=R),x=C>>>16,C=t[1],A+=(T=e[1])>>>16,P+=65535&C,x+=C>>>16,x+=(P+=(A+=(E+=65535&T)>>>16)>>>16)>>>16,t[1]=R=65535&P|x<<16,e[1]=B=65535&E|A<<16,E=65535&(T=F),A=T>>>16,P=65535&(C=M),x=C>>>16,C=t[2],A+=(T=e[2])>>>16,P+=65535&C,x+=C>>>16,x+=(P+=(A+=(E+=65535&T)>>>16)>>>16)>>>16,t[2]=M=65535&P|x<<16,e[2]=F=65535&E|A<<16,E=65535&(T=q),A=T>>>16,P=65535&(C=I),x=C>>>16,C=t[3],A+=(T=e[3])>>>16,P+=65535&C,x+=C>>>16,x+=(P+=(A+=(E+=65535&T)>>>16)>>>16)>>>16,t[3]=I=65535&P|x<<16,e[3]=q=65535&E|A<<16,E=65535&(T=Y),A=T>>>16,P=65535&(C=N),x=C>>>16,C=t[4],A+=(T=e[4])>>>16,P+=65535&C,x+=C>>>16,x+=(P+=(A+=(E+=65535&T)>>>16)>>>16)>>>16,t[4]=N=65535&P|x<<16,e[4]=Y=65535&E|A<<16,E=65535&(T=K),A=T>>>16,P=65535&(C=j),x=C>>>16,C=t[5],A+=(T=e[5])>>>16,P+=65535&C,x+=C>>>16,x+=(P+=(A+=(E+=65535&T)>>>16)>>>16)>>>16,t[5]=j=65535&P|x<<16,e[5]=K=65535&E|A<<16,E=65535&(T=$),A=T>>>16,P=65535&(C=D),x=C>>>16,C=t[6],A+=(T=e[6])>>>16,P+=65535&C,x+=C>>>16,x+=(P+=(A+=(E+=65535&T)>>>16)>>>16)>>>16,t[6]=D=65535&P|x<<16,e[6]=$=65535&E|A<<16,E=65535&(T=J),A=T>>>16,P=65535&(C=z),x=C>>>16,C=t[7],A+=(T=e[7])>>>16,P+=65535&C,x+=C>>>16,x+=(P+=(A+=(E+=65535&T)>>>16)>>>16)>>>16,t[7]=z=65535&P|x<<16,e[7]=J=65535&E|A<<16,X+=128,r-=128}return r}function V(t,e,n){var r,i=new Int32Array(8),s=new Int32Array(8),o=new Uint8Array(256),a=n;for(i[0]=1779033703,i[1]=3144134277,i[2]=1013904242,i[3]=2773480762,i[4]=1359893119,i[5]=2600822924,i[6]=528734635,i[7]=1541459225,s[0]=4089235720,s[1]=2227873595,s[2]=4271175723,s[3]=1595750129,s[4]=2917565137,s[5]=725511199,s[6]=4215389547,s[7]=327033209,G(i,s,e,n),n%=128,r=0;r=0;--i)Q(t,e,r=n[i/8|0]>>(7&i)&1),Z(e,t),Z(t,t),Q(t,e,r)}function nt(t,n){var r=[e(),e(),e(),e()];O(r[0],l),O(r[1],d),O(r[2],a),z(r[3],l,d),et(t,r,n)}function rt(t,n,i){var s,o=new Uint8Array(64),a=[e(),e(),e(),e()];for(i||r(n,32),V(o,n,32),o[0]&=248,o[31]&=127,o[31]|=64,nt(a,o),tt(t,a),s=0;s<32;s++)n[s+32]=t[s];return 0}var it=new Float64Array([237,211,245,92,26,99,18,88,214,156,247,162,222,249,222,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16]);function st(t,e){var n,r,i,s;for(r=63;r>=32;--r){for(n=0,i=r-32,s=r-12;i>4)*it[i],n=e[i]>>8,e[i]&=255;for(i=0;i<32;i++)e[i]-=n*it[i];for(r=0;r<32;r++)e[r+1]+=e[r]>>8,t[r]=255&e[r]}function ot(t){var e,n=new Float64Array(64);for(e=0;e<64;e++)n[e]=t[e];for(e=0;e<64;e++)t[e]=0;st(t,n)}function at(t,n,r,i){var s,o,a=new Uint8Array(64),h=new Uint8Array(64),c=new Uint8Array(64),u=new Float64Array(64),l=[e(),e(),e(),e()];V(a,i,32),a[0]&=248,a[31]&=127,a[31]|=64;var d=r+64;for(s=0;s>7&&D(t[0],o,t[0]),z(t[3],t[0],t[1]),0)}(d,i))return-1;for(s=0;s=0},t.sign.keyPair=function(){var t=new Uint8Array(32),e=new Uint8Array(64);return rt(t,e),{publicKey:t,secretKey:e}},t.sign.keyPair.fromSecretKey=function(t){if(ut(t),64!==t.length)throw new Error("bad secret key size");for(var e=new Uint8Array(32),n=0;n(target: any, ...sources: any[]): T {\n for (var i = 0; i < sources.length; i++) {\n var extensions = sources[i];\n for (var property in extensions) {\n if (\n extensions[property] &&\n extensions[property].constructor &&\n extensions[property].constructor === Object\n ) {\n target[property] = extend(target[property] || {}, extensions[property]);\n } else {\n target[property] = extensions[property];\n }\n }\n }\n return target;\n}\n\nexport function stringify(): string {\n var m = ['Pusher'];\n for (var i = 0; i < arguments.length; i++) {\n if (typeof arguments[i] === 'string') {\n m.push(arguments[i]);\n } else {\n m.push(safeJSONStringify(arguments[i]));\n }\n }\n return m.join(' : ');\n}\n\nexport function arrayIndexOf(array: any[], item: any): number {\n // MSIE doesn't have array.indexOf\n var nativeIndexOf = Array.prototype.indexOf;\n if (array === null) {\n return -1;\n }\n if (nativeIndexOf && array.indexOf === nativeIndexOf) {\n return array.indexOf(item);\n }\n for (var i = 0, l = array.length; i < l; i++) {\n if (array[i] === item) {\n return i;\n }\n }\n return -1;\n}\n\n/** Applies a function f to all properties of an object.\n *\n * Function f gets 3 arguments passed:\n * - element from the object\n * - key of the element\n * - reference to the object\n *\n * @param {Object} object\n * @param {Function} f\n */\nexport function objectApply(object: any, f: Function) {\n for (var key in object) {\n if (Object.prototype.hasOwnProperty.call(object, key)) {\n f(object[key], key, object);\n }\n }\n}\n\n/** Return a list of objects own proerty keys\n *\n * @param {Object} object\n * @returns {Array}\n */\nexport function keys(object: any): string[] {\n var keys = [];\n objectApply(object, function(_, key) {\n keys.push(key);\n });\n return keys;\n}\n\n/** Return a list of object's own property values\n *\n * @param {Object} object\n * @returns {Array}\n */\nexport function values(object: any): any[] {\n var values = [];\n objectApply(object, function(value) {\n values.push(value);\n });\n return values;\n}\n\n/** Applies a function f to all elements of an array.\n *\n * Function f gets 3 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function apply(array: any[], f: Function, context?: any) {\n for (var i = 0; i < array.length; i++) {\n f.call(context || global, array[i], i, array);\n }\n}\n\n/** Maps all elements of the array and returns the result.\n *\n * Function f gets 4 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n * - reference to the destination array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function map(array: any[], f: Function): any[] {\n var result = [];\n for (var i = 0; i < array.length; i++) {\n result.push(f(array[i], i, array, result));\n }\n return result;\n}\n\n/** Maps all elements of the object and returns the result.\n *\n * Function f gets 4 arguments passed:\n * - element from the object\n * - key of the element\n * - reference to the source object\n * - reference to the destination object\n *\n * @param {Object} object\n * @param {Function} f\n */\nexport function mapObject(object: any, f: Function): any {\n var result = {};\n objectApply(object, function(value, key) {\n result[key] = f(value);\n });\n return result;\n}\n\n/** Filters elements of the array using a test function.\n *\n * Function test gets 4 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n * - reference to the destination array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function filter(array: any[], test: Function): any[] {\n test =\n test ||\n function(value) {\n return !!value;\n };\n\n var result = [];\n for (var i = 0; i < array.length; i++) {\n if (test(array[i], i, array, result)) {\n result.push(array[i]);\n }\n }\n return result;\n}\n\n/** Filters properties of the object using a test function.\n *\n * Function test gets 4 arguments passed:\n * - element from the object\n * - key of the element\n * - reference to the source object\n * - reference to the destination object\n *\n * @param {Object} object\n * @param {Function} f\n */\nexport function filterObject(object: Object, test: Function) {\n var result = {};\n objectApply(object, function(value, key) {\n if ((test && test(value, key, object, result)) || Boolean(value)) {\n result[key] = value;\n }\n });\n return result;\n}\n\n/** Flattens an object into a two-dimensional array.\n *\n * @param {Object} object\n * @return {Array} resulting array of [key, value] pairs\n */\nexport function flatten(object: Object): any[] {\n var result = [];\n objectApply(object, function(value, key) {\n result.push([key, value]);\n });\n return result;\n}\n\n/** Checks whether any element of the array passes the test.\n *\n * Function test gets 3 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function any(array: any[], test: Function): boolean {\n for (var i = 0; i < array.length; i++) {\n if (test(array[i], i, array)) {\n return true;\n }\n }\n return false;\n}\n\n/** Checks whether all elements of the array pass the test.\n *\n * Function test gets 3 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function all(array: any[], test: Function): boolean {\n for (var i = 0; i < array.length; i++) {\n if (!test(array[i], i, array)) {\n return false;\n }\n }\n return true;\n}\n\nexport function encodeParamsObject(data): string {\n return mapObject(data, function(value) {\n if (typeof value === 'object') {\n value = safeJSONStringify(value);\n }\n return encodeURIComponent(base64encode(value.toString()));\n });\n}\n\nexport function buildQueryString(data: any): string {\n var params = filterObject(data, function(value) {\n return value !== undefined;\n });\n\n var query = map(\n flatten(encodeParamsObject(params)),\n Util.method('join', '=')\n ).join('&');\n\n return query;\n}\n\n/**\n * See https://github.com/douglascrockford/JSON-js/blob/master/cycle.js\n *\n * Remove circular references from an object. Required for JSON.stringify in\n * React Native, which tends to blow up a lot.\n *\n * @param {any} object\n * @return {any} Decycled object\n */\nexport function decycleObject(object: any): any {\n var objects = [],\n paths = [];\n\n return (function derez(value, path) {\n var i, name, nu;\n\n switch (typeof value) {\n case 'object':\n if (!value) {\n return null;\n }\n for (i = 0; i < objects.length; i += 1) {\n if (objects[i] === value) {\n return { $ref: paths[i] };\n }\n }\n\n objects.push(value);\n paths.push(path);\n\n if (Object.prototype.toString.apply(value) === '[object Array]') {\n nu = [];\n for (i = 0; i < value.length; i += 1) {\n nu[i] = derez(value[i], path + '[' + i + ']');\n }\n } else {\n nu = {};\n for (name in value) {\n if (Object.prototype.hasOwnProperty.call(value, name)) {\n nu[name] = derez(\n value[name],\n path + '[' + JSON.stringify(name) + ']'\n );\n }\n }\n }\n return nu;\n case 'number':\n case 'string':\n case 'boolean':\n return value;\n }\n })(object, '$');\n}\n\n/**\n * Provides a cross-browser and cross-platform way to safely stringify objects\n * into JSON. This is particularly necessary for ReactNative, where circular JSON\n * structures throw an exception.\n *\n * @param {any} source The object to stringify\n * @return {string} The serialized output.\n */\nexport function safeJSONStringify(source: any): string {\n try {\n return JSON.stringify(source);\n } catch (e) {\n return JSON.stringify(decycleObject(source));\n }\n}\n","import { stringify } from './utils/collections';\nimport Pusher from './pusher';\n\nclass Logger {\n debug(...args: any[]) {\n this.log(this.globalLog, args);\n }\n\n warn(...args: any[]) {\n this.log(this.globalLogWarn, args);\n }\n\n error(...args: any[]) {\n this.log(this.globalLogError, args);\n }\n\n private globalLog = (message: string) => {\n if (global.console && global.console.log) {\n global.console.log(message);\n }\n };\n\n private globalLogWarn(message: string) {\n if (global.console && global.console.warn) {\n global.console.warn(message);\n } else {\n this.globalLog(message);\n }\n }\n\n private globalLogError(message: string) {\n if (global.console && global.console.error) {\n global.console.error(message);\n } else {\n this.globalLogWarn(message);\n }\n }\n\n private log(\n defaultLoggingFunction: (message: string) => void,\n ...args: any[]\n ) {\n var message = stringify.apply(this, arguments);\n if (Pusher.log) {\n Pusher.log(message);\n } else if (Pusher.logToConsole) {\n const log = defaultLoggingFunction.bind(this);\n log(message);\n }\n }\n}\n\nexport default new Logger();\n","import * as Collections from './utils/collections';\nimport TimedCallback from './utils/timers/timed_callback';\nimport { OneOffTimer, PeriodicTimer } from './utils/timers';\n\nvar Util = {\n now(): number {\n if (Date.now) {\n return Date.now();\n } else {\n return new Date().valueOf();\n }\n },\n\n defer(callback: TimedCallback): OneOffTimer {\n return new OneOffTimer(0, callback);\n },\n\n /** Builds a function that will proxy a method call to its first argument.\n *\n * Allows partial application of arguments, so additional arguments are\n * prepended to the argument list.\n *\n * @param {String} name method name\n * @return {Function} proxy function\n */\n method(name: string, ...args: any[]): Function {\n var boundArguments = Array.prototype.slice.call(arguments, 1);\n return function(object) {\n return object[name].apply(object, boundArguments.concat(arguments));\n };\n }\n};\n\nexport default Util;\n","import * as Collections from '../utils/collections';\nimport Callback from './callback';\nimport Metadata from '../channels/metadata';\nimport CallbackRegistry from './callback_registry';\n\n/** Manages callback bindings and event emitting.\n *\n * @param Function failThrough called when no listeners are bound to an event\n */\nexport default class Dispatcher {\n callbacks: CallbackRegistry;\n global_callbacks: Function[];\n failThrough: Function;\n\n constructor(failThrough?: Function) {\n this.callbacks = new CallbackRegistry();\n this.global_callbacks = [];\n this.failThrough = failThrough;\n }\n\n bind(eventName: string, callback: Function, context?: any) {\n this.callbacks.add(eventName, callback, context);\n return this;\n }\n\n bind_global(callback: Function) {\n this.global_callbacks.push(callback);\n return this;\n }\n\n unbind(eventName?: string, callback?: Function, context?: any) {\n this.callbacks.remove(eventName, callback, context);\n return this;\n }\n\n unbind_global(callback?: Function) {\n if (!callback) {\n this.global_callbacks = [];\n return this;\n }\n\n this.global_callbacks = Collections.filter(\n this.global_callbacks || [],\n c => c !== callback\n );\n\n return this;\n }\n\n unbind_all() {\n this.unbind();\n this.unbind_global();\n return this;\n }\n\n emit(eventName: string, data?: any, metadata?: Metadata): Dispatcher {\n for (var i = 0; i < this.global_callbacks.length; i++) {\n this.global_callbacks[i](eventName, data);\n }\n\n var callbacks = this.callbacks.get(eventName);\n var args = [];\n\n if (metadata) {\n // if there's a metadata argument, we need to call the callback with both\n // data and metadata regardless of whether data is undefined\n args.push(data, metadata);\n } else if (data) {\n // metadata is undefined, so we only need to call the callback with data\n // if data exists\n args.push(data);\n }\n\n if (callbacks && callbacks.length > 0) {\n for (var i = 0; i < callbacks.length; i++) {\n callbacks[i].fn.apply(callbacks[i].context || global, args);\n }\n } else if (this.failThrough) {\n this.failThrough(eventName, data);\n }\n\n return this;\n }\n}\n","import Timer from './abstract_timer';\nimport TimedCallback from './timed_callback';\nimport { Delay } from './scheduling';\n\n// We need to bind clear functions this way to avoid exceptions on IE8\nfunction clearTimeout(timer) {\n global.clearTimeout(timer);\n}\nfunction clearInterval(timer) {\n global.clearInterval(timer);\n}\n\n/** Cross-browser compatible one-off timer abstraction.\n *\n * @param {Number} delay\n * @param {Function} callback\n */\nexport class OneOffTimer extends Timer {\n constructor(delay: Delay, callback: TimedCallback) {\n super(setTimeout, clearTimeout, delay, function(timer) {\n callback();\n return null;\n });\n }\n}\n\n/** Cross-browser compatible periodic timer abstraction.\n *\n * @param {Number} delay\n * @param {Function} callback\n */\nexport class PeriodicTimer extends Timer {\n constructor(delay: Delay, callback: TimedCallback) {\n super(setInterval, clearInterval, delay, function(timer) {\n callback();\n return timer;\n });\n }\n}\n","import {\n ChannelAuthorizationOptions,\n UserAuthenticationOptions\n} from './auth/options';\nimport { AuthTransport } from './config';\n\nexport interface DefaultConfig {\n VERSION: string;\n PROTOCOL: number;\n wsPort: number;\n wssPort: number;\n wsPath: string;\n httpHost: string;\n httpPort: number;\n httpsPort: number;\n httpPath: string;\n stats_host: string;\n authEndpoint: string;\n authTransport: AuthTransport;\n activityTimeout: number;\n pongTimeout: number;\n unavailableTimeout: number;\n userAuthentication: UserAuthenticationOptions;\n channelAuthorization: ChannelAuthorizationOptions;\n\n cdn_http?: string;\n cdn_https?: string;\n dependency_suffix?: string;\n}\n\nvar Defaults: DefaultConfig = {\n VERSION: VERSION,\n PROTOCOL: 7,\n\n wsPort: 80,\n wssPort: 443,\n wsPath: '',\n // DEPRECATED: SockJS fallback parameters\n httpHost: 'sockjs.pusher.com',\n httpPort: 80,\n httpsPort: 443,\n httpPath: '/pusher',\n // DEPRECATED: Stats\n stats_host: 'stats.pusher.com',\n // DEPRECATED: Other settings\n authEndpoint: '/pusher/auth',\n authTransport: 'ajax',\n activityTimeout: 120000,\n pongTimeout: 30000,\n unavailableTimeout: 10000,\n userAuthentication: {\n endpoint: '/pusher/user-auth',\n transport: 'ajax'\n },\n channelAuthorization: {\n endpoint: '/pusher/auth',\n transport: 'ajax'\n },\n\n // CDN configuration\n cdn_http: CDN_HTTP,\n cdn_https: CDN_HTTPS,\n dependency_suffix: DEPENDENCY_SUFFIX\n};\n\nexport default Defaults;\n","import Defaults from '../defaults';\nimport { default as URLScheme, URLSchemeParams } from './url_scheme';\n\nfunction getGenericURL(\n baseScheme: string,\n params: URLSchemeParams,\n path: string\n): string {\n var scheme = baseScheme + (params.useTLS ? 's' : '');\n var host = params.useTLS ? params.hostTLS : params.hostNonTLS;\n return scheme + '://' + host + path;\n}\n\nfunction getGenericPath(key: string, queryString?: string): string {\n var path = '/app/' + key;\n var query =\n '?protocol=' +\n Defaults.PROTOCOL +\n '&client=js' +\n '&version=' +\n Defaults.VERSION +\n (queryString ? '&' + queryString : '');\n return path + query;\n}\n\nexport var ws: URLScheme = {\n getInitial: function(key: string, params: URLSchemeParams): string {\n var path = (params.httpPath || '') + getGenericPath(key, 'flash=false');\n return getGenericURL('ws', params, path);\n }\n};\n\nexport var http: URLScheme = {\n getInitial: function(key: string, params: URLSchemeParams): string {\n var path = (params.httpPath || '/pusher') + getGenericPath(key);\n return getGenericURL('http', params, path);\n }\n};\n\nexport var sockjs: URLScheme = {\n getInitial: function(key: string, params: URLSchemeParams): string {\n return getGenericURL('http', params, params.httpPath || '/pusher');\n },\n getPath: function(key: string, params: URLSchemeParams): string {\n return getGenericPath(key);\n }\n};\n","import Util from '../util';\nimport * as Collections from '../utils/collections';\nimport { default as EventsDispatcher } from '../events/dispatcher';\nimport Logger from '../logger';\nimport TransportHooks from './transport_hooks';\nimport Socket from '../socket';\nimport Runtime from 'runtime';\nimport Timeline from '../timeline/timeline';\nimport TransportConnectionOptions from './transport_connection_options';\n\n/** Provides universal API for transport connections.\n *\n * Transport connection is a low-level object that wraps a connection method\n * and exposes a simple evented interface for the connection state and\n * messaging. It does not implement Pusher-specific WebSocket protocol.\n *\n * Additionally, it fetches resources needed for transport to work and exposes\n * an interface for querying transport features.\n *\n * States:\n * - new - initial state after constructing the object\n * - initializing - during initialization phase, usually fetching resources\n * - intialized - ready to establish a connection\n * - connection - when connection is being established\n * - open - when connection ready to be used\n * - closed - after connection was closed be either side\n *\n * Emits:\n * - error - after the connection raised an error\n *\n * Options:\n * - useTLS - whether connection should be over TLS\n * - hostTLS - host to connect to when connection is over TLS\n * - hostNonTLS - host to connect to when connection is over TLS\n *\n * @param {String} key application key\n * @param {Object} options\n */\nexport default class TransportConnection extends EventsDispatcher {\n hooks: TransportHooks;\n name: string;\n priority: number;\n key: string;\n options: TransportConnectionOptions;\n state: string;\n timeline: Timeline;\n activityTimeout: number;\n id: number;\n socket: Socket;\n beforeOpen: Function;\n initialize: Function;\n\n constructor(\n hooks: TransportHooks,\n name: string,\n priority: number,\n key: string,\n options: TransportConnectionOptions\n ) {\n super();\n this.initialize = Runtime.transportConnectionInitializer;\n this.hooks = hooks;\n this.name = name;\n this.priority = priority;\n this.key = key;\n this.options = options;\n\n this.state = 'new';\n this.timeline = options.timeline;\n this.activityTimeout = options.activityTimeout;\n this.id = this.timeline.generateUniqueID();\n }\n\n /** Checks whether the transport handles activity checks by itself.\n *\n * @return {Boolean}\n */\n handlesActivityChecks(): boolean {\n return Boolean(this.hooks.handlesActivityChecks);\n }\n\n /** Checks whether the transport supports the ping/pong API.\n *\n * @return {Boolean}\n */\n supportsPing(): boolean {\n return Boolean(this.hooks.supportsPing);\n }\n\n /** Tries to establish a connection.\n *\n * @returns {Boolean} false if transport is in invalid state\n */\n connect(): boolean {\n if (this.socket || this.state !== 'initialized') {\n return false;\n }\n\n var url = this.hooks.urls.getInitial(this.key, this.options);\n try {\n this.socket = this.hooks.getSocket(url, this.options);\n } catch (e) {\n Util.defer(() => {\n this.onError(e);\n this.changeState('closed');\n });\n return false;\n }\n\n this.bindListeners();\n\n Logger.debug('Connecting', { transport: this.name, url });\n this.changeState('connecting');\n return true;\n }\n\n /** Closes the connection.\n *\n * @return {Boolean} true if there was a connection to close\n */\n close(): boolean {\n if (this.socket) {\n this.socket.close();\n return true;\n } else {\n return false;\n }\n }\n\n /** Sends data over the open connection.\n *\n * @param {String} data\n * @return {Boolean} true only when in the \"open\" state\n */\n send(data: any): boolean {\n if (this.state === 'open') {\n // Workaround for MobileSafari bug (see https://gist.github.com/2052006)\n Util.defer(() => {\n if (this.socket) {\n this.socket.send(data);\n }\n });\n return true;\n } else {\n return false;\n }\n }\n\n /** Sends a ping if the connection is open and transport supports it. */\n ping() {\n if (this.state === 'open' && this.supportsPing()) {\n this.socket.ping();\n }\n }\n\n private onOpen() {\n if (this.hooks.beforeOpen) {\n this.hooks.beforeOpen(\n this.socket,\n this.hooks.urls.getPath(this.key, this.options)\n );\n }\n this.changeState('open');\n this.socket.onopen = undefined;\n }\n\n private onError(error) {\n this.emit('error', { type: 'WebSocketError', error: error });\n this.timeline.error(this.buildTimelineMessage({ error: error.toString() }));\n }\n\n private onClose(closeEvent?: any) {\n if (closeEvent) {\n this.changeState('closed', {\n code: closeEvent.code,\n reason: closeEvent.reason,\n wasClean: closeEvent.wasClean\n });\n } else {\n this.changeState('closed');\n }\n this.unbindListeners();\n this.socket = undefined;\n }\n\n private onMessage(message) {\n this.emit('message', message);\n }\n\n private onActivity() {\n this.emit('activity');\n }\n\n private bindListeners() {\n this.socket.onopen = () => {\n this.onOpen();\n };\n this.socket.onerror = error => {\n this.onError(error);\n };\n this.socket.onclose = closeEvent => {\n this.onClose(closeEvent);\n };\n this.socket.onmessage = message => {\n this.onMessage(message);\n };\n\n if (this.supportsPing()) {\n this.socket.onactivity = () => {\n this.onActivity();\n };\n }\n }\n\n private unbindListeners() {\n if (this.socket) {\n this.socket.onopen = undefined;\n this.socket.onerror = undefined;\n this.socket.onclose = undefined;\n this.socket.onmessage = undefined;\n if (this.supportsPing()) {\n this.socket.onactivity = undefined;\n }\n }\n }\n\n private changeState(state: string, params?: any) {\n this.state = state;\n this.timeline.info(\n this.buildTimelineMessage({\n state: state,\n params: params\n })\n );\n this.emit(state, params);\n }\n\n buildTimelineMessage(message): any {\n return Collections.extend({ cid: this.id }, message);\n }\n}\n","import Factory from '../utils/factory';\nimport TransportHooks from './transport_hooks';\nimport TransportConnection from './transport_connection';\nimport TransportConnectionOptions from './transport_connection_options';\n\n/** Provides interface for transport connection instantiation.\n *\n * Takes transport-specific hooks as the only argument, which allow checking\n * for transport support and creating its connections.\n *\n * Supported hooks: * - file - the name of the file to be fetched during initialization\n * - urls - URL scheme to be used by transport\n * - handlesActivityCheck - true when the transport handles activity checks\n * - supportsPing - true when the transport has a ping/activity API\n * - isSupported - tells whether the transport is supported in the environment\n * - getSocket - creates a WebSocket-compatible transport socket\n *\n * See transports.js for specific implementations.\n *\n * @param {Object} hooks object containing all needed transport hooks\n */\nexport default class Transport {\n hooks: TransportHooks;\n\n constructor(hooks: TransportHooks) {\n this.hooks = hooks;\n }\n\n /** Returns whether the transport is supported in the environment.\n *\n * @param {Object} envronment te environment details (encryption, settings)\n * @returns {Boolean} true when the transport is supported\n */\n isSupported(environment: any): boolean {\n return this.hooks.isSupported(environment);\n }\n\n /** Creates a transport connection.\n *\n * @param {String} name\n * @param {Number} priority\n * @param {String} key the application key\n * @param {Object} options\n * @returns {TransportConnection}\n */\n createConnection(\n name: string,\n priority: number,\n key: string,\n options: any\n ): TransportConnection {\n return new TransportConnection(this.hooks, name, priority, key, options);\n }\n}\n","import * as URLSchemes from 'core/transports/url_schemes';\nimport URLScheme from 'core/transports/url_scheme';\nimport Transport from 'core/transports/transport';\nimport Util from 'core/util';\nimport * as Collections from 'core/utils/collections';\nimport TransportHooks from 'core/transports/transport_hooks';\nimport TransportsTable from 'core/transports/transports_table';\nimport Runtime from 'runtime';\n\n/** WebSocket transport.\n *\n * Uses native WebSocket implementation, including MozWebSocket supported by\n * earlier Firefox versions.\n */\nvar WSTransport = new Transport({\n urls: URLSchemes.ws,\n handlesActivityChecks: false,\n supportsPing: false,\n\n isInitialized: function() {\n return Boolean(Runtime.getWebSocketAPI());\n },\n isSupported: function(): boolean {\n return Boolean(Runtime.getWebSocketAPI());\n },\n getSocket: function(url) {\n return Runtime.createWebSocket(url);\n }\n});\n\nvar httpConfiguration = {\n urls: URLSchemes.http,\n handlesActivityChecks: false,\n supportsPing: true,\n isInitialized: function() {\n return true;\n }\n};\n\nexport var streamingConfiguration = Collections.extend(\n {\n getSocket: function(url) {\n return Runtime.HTTPFactory.createStreamingSocket(url);\n }\n },\n httpConfiguration\n);\nexport var pollingConfiguration = Collections.extend(\n {\n getSocket: function(url) {\n return Runtime.HTTPFactory.createPollingSocket(url);\n }\n },\n httpConfiguration\n);\n\nvar xhrConfiguration = {\n isSupported: function(): boolean {\n return Runtime.isXHRSupported();\n }\n};\n\n/** HTTP streaming transport using CORS-enabled XMLHttpRequest. */\nvar XHRStreamingTransport = new Transport(\n (\n Collections.extend({}, streamingConfiguration, xhrConfiguration)\n )\n);\n\n/** HTTP long-polling transport using CORS-enabled XMLHttpRequest. */\nvar XHRPollingTransport = new Transport(\n Collections.extend({}, pollingConfiguration, xhrConfiguration)\n);\n\nvar Transports: TransportsTable = {\n ws: WSTransport,\n xhr_streaming: XHRStreamingTransport,\n xhr_polling: XHRPollingTransport\n};\n\nexport default Transports;\n","import Util from '../util';\nimport * as Collections from '../utils/collections';\nimport TransportManager from './transport_manager';\nimport TransportConnection from './transport_connection';\nimport Transport from './transport';\nimport PingDelayOptions from './ping_delay_options';\n\n/** Creates transport connections monitored by a transport manager.\n *\n * When a transport is closed, it might mean the environment does not support\n * it. It's possible that messages get stuck in an intermediate buffer or\n * proxies terminate inactive connections. To combat these problems,\n * assistants monitor the connection lifetime, report unclean exits and\n * adjust ping timeouts to keep the connection active. The decision to disable\n * a transport is the manager's responsibility.\n *\n * @param {TransportManager} manager\n * @param {TransportConnection} transport\n * @param {Object} options\n */\nexport default class AssistantToTheTransportManager {\n manager: TransportManager;\n transport: Transport;\n minPingDelay: number;\n maxPingDelay: number;\n pingDelay: number;\n\n constructor(\n manager: TransportManager,\n transport: Transport,\n options: PingDelayOptions\n ) {\n this.manager = manager;\n this.transport = transport;\n this.minPingDelay = options.minPingDelay;\n this.maxPingDelay = options.maxPingDelay;\n this.pingDelay = undefined;\n }\n\n /** Creates a transport connection.\n *\n * This function has the same API as Transport#createConnection.\n *\n * @param {String} name\n * @param {Number} priority\n * @param {String} key the application key\n * @param {Object} options\n * @returns {TransportConnection}\n */\n createConnection(\n name: string,\n priority: number,\n key: string,\n options: Object\n ): TransportConnection {\n options = Collections.extend({}, options, {\n activityTimeout: this.pingDelay\n });\n var connection = this.transport.createConnection(\n name,\n priority,\n key,\n options\n );\n\n var openTimestamp = null;\n\n var onOpen = function() {\n connection.unbind('open', onOpen);\n connection.bind('closed', onClosed);\n openTimestamp = Util.now();\n };\n var onClosed = closeEvent => {\n connection.unbind('closed', onClosed);\n\n if (closeEvent.code === 1002 || closeEvent.code === 1003) {\n // we don't want to use transports not obeying the protocol\n this.manager.reportDeath();\n } else if (!closeEvent.wasClean && openTimestamp) {\n // report deaths only for short-living transport\n var lifespan = Util.now() - openTimestamp;\n if (lifespan < 2 * this.maxPingDelay) {\n this.manager.reportDeath();\n this.pingDelay = Math.max(lifespan / 2, this.minPingDelay);\n }\n }\n };\n\n connection.bind('open', onOpen);\n return connection;\n }\n\n /** Returns whether the transport is supported in the environment.\n *\n * This function has the same API as Transport#isSupported. Might return false\n * when the manager decides to kill the transport.\n *\n * @param {Object} environment the environment details (encryption, settings)\n * @returns {Boolean} true when the transport is supported\n */\n isSupported(environment: string): boolean {\n return this.manager.isAlive() && this.transport.isSupported(environment);\n }\n}\n","import Action from './action';\nimport { PusherEvent } from './message-types';\n/**\n * Provides functions for handling Pusher protocol-specific messages.\n */\n\nconst Protocol = {\n /**\n * Decodes a message in a Pusher format.\n *\n * The MessageEvent we receive from the transport should contain a pusher event\n * (https://pusher.com/docs/pusher_protocol#events) serialized as JSON in the\n * data field\n *\n * The pusher event may contain a data field too, and it may also be\n * serialised as JSON\n *\n * Throws errors when messages are not parse'able.\n *\n * @param {MessageEvent} messageEvent\n * @return {PusherEvent}\n */\n decodeMessage: function(messageEvent: MessageEvent): PusherEvent {\n try {\n var messageData = JSON.parse(messageEvent.data);\n var pusherEventData = messageData.data;\n if (typeof pusherEventData === 'string') {\n try {\n pusherEventData = JSON.parse(messageData.data);\n } catch (e) {}\n }\n var pusherEvent: PusherEvent = {\n event: messageData.event,\n channel: messageData.channel,\n data: pusherEventData\n };\n if (messageData.user_id) {\n pusherEvent.user_id = messageData.user_id;\n }\n return pusherEvent;\n } catch (e) {\n throw { type: 'MessageParseError', error: e, data: messageEvent.data };\n }\n },\n\n /**\n * Encodes a message to be sent.\n *\n * @param {PusherEvent} event\n * @return {String}\n */\n encodeMessage: function(event: PusherEvent): string {\n return JSON.stringify(event);\n },\n\n /**\n * Processes a handshake message and returns appropriate actions.\n *\n * Returns an object with an 'action' and other action-specific properties.\n *\n * There are three outcomes when calling this function. First is a successful\n * connection attempt, when pusher:connection_established is received, which\n * results in a 'connected' action with an 'id' property. When passed a\n * pusher:error event, it returns a result with action appropriate to the\n * close code and an error. Otherwise, it raises an exception.\n *\n * @param {String} message\n * @result Object\n */\n processHandshake: function(messageEvent: MessageEvent): Action {\n var message = Protocol.decodeMessage(messageEvent);\n\n if (message.event === 'pusher:connection_established') {\n if (!message.data.activity_timeout) {\n throw 'No activity timeout specified in handshake';\n }\n return {\n action: 'connected',\n id: message.data.socket_id,\n activityTimeout: message.data.activity_timeout * 1000\n };\n } else if (message.event === 'pusher:error') {\n // From protocol 6 close codes are sent only once, so this only\n // happens when connection does not support close codes\n return {\n action: this.getCloseAction(message.data),\n error: this.getCloseError(message.data)\n };\n } else {\n throw 'Invalid handshake';\n }\n },\n\n /**\n * Dispatches the close event and returns an appropriate action name.\n *\n * See:\n * 1. https://developer.mozilla.org/en-US/docs/WebSockets/WebSockets_reference/CloseEvent\n * 2. http://pusher.com/docs/pusher_protocol\n *\n * @param {CloseEvent} closeEvent\n * @return {String} close action name\n */\n getCloseAction: function(closeEvent): string {\n if (closeEvent.code < 4000) {\n // ignore 1000 CLOSE_NORMAL, 1001 CLOSE_GOING_AWAY,\n // 1005 CLOSE_NO_STATUS, 1006 CLOSE_ABNORMAL\n // ignore 1007...3999\n // handle 1002 CLOSE_PROTOCOL_ERROR, 1003 CLOSE_UNSUPPORTED,\n // 1004 CLOSE_TOO_LARGE\n if (closeEvent.code >= 1002 && closeEvent.code <= 1004) {\n return 'backoff';\n } else {\n return null;\n }\n } else if (closeEvent.code === 4000) {\n return 'tls_only';\n } else if (closeEvent.code < 4100) {\n return 'refused';\n } else if (closeEvent.code < 4200) {\n return 'backoff';\n } else if (closeEvent.code < 4300) {\n return 'retry';\n } else {\n // unknown error\n return 'refused';\n }\n },\n\n /**\n * Returns an error or null basing on the close event.\n *\n * Null is returned when connection was closed cleanly. Otherwise, an object\n * with error details is returned.\n *\n * @param {CloseEvent} closeEvent\n * @return {Object} error object\n */\n getCloseError: function(closeEvent): any {\n if (closeEvent.code !== 1000 && closeEvent.code !== 1001) {\n return {\n type: 'PusherError',\n data: {\n code: closeEvent.code,\n message: closeEvent.reason || closeEvent.message\n }\n };\n } else {\n return null;\n }\n }\n};\n\nexport default Protocol;\n","import * as Collections from '../utils/collections';\nimport { default as EventsDispatcher } from '../events/dispatcher';\nimport Protocol from './protocol/protocol';\nimport { PusherEvent } from './protocol/message-types';\nimport Logger from '../logger';\nimport TransportConnection from '../transports/transport_connection';\nimport Socket from '../socket';\n/**\n * Provides Pusher protocol interface for transports.\n *\n * Emits following events:\n * - message - on received messages\n * - ping - on ping requests\n * - pong - on pong responses\n * - error - when the transport emits an error\n * - closed - after closing the transport\n *\n * It also emits more events when connection closes with a code.\n * See Protocol.getCloseAction to get more details.\n *\n * @param {Number} id\n * @param {AbstractTransport} transport\n */\nexport default class Connection extends EventsDispatcher implements Socket {\n id: string;\n transport: TransportConnection;\n activityTimeout: number;\n\n constructor(id: string, transport: TransportConnection) {\n super();\n this.id = id;\n this.transport = transport;\n this.activityTimeout = transport.activityTimeout;\n this.bindListeners();\n }\n\n /** Returns whether used transport handles activity checks by itself\n *\n * @returns {Boolean} true if activity checks are handled by the transport\n */\n handlesActivityChecks() {\n return this.transport.handlesActivityChecks();\n }\n\n /** Sends raw data.\n *\n * @param {String} data\n */\n send(data: any): boolean {\n return this.transport.send(data);\n }\n\n /** Sends an event.\n *\n * @param {String} name\n * @param {String} data\n * @param {String} [channel]\n * @returns {Boolean} whether message was sent or not\n */\n send_event(name: string, data: any, channel?: string): boolean {\n var event: PusherEvent = { event: name, data: data };\n if (channel) {\n event.channel = channel;\n }\n Logger.debug('Event sent', event);\n return this.send(Protocol.encodeMessage(event));\n }\n\n /** Sends a ping message to the server.\n *\n * Basing on the underlying transport, it might send either transport's\n * protocol-specific ping or pusher:ping event.\n */\n ping() {\n if (this.transport.supportsPing()) {\n this.transport.ping();\n } else {\n this.send_event('pusher:ping', {});\n }\n }\n\n /** Closes the connection. */\n close() {\n this.transport.close();\n }\n\n private bindListeners() {\n var listeners = {\n message: (messageEvent: MessageEvent) => {\n var pusherEvent;\n try {\n pusherEvent = Protocol.decodeMessage(messageEvent);\n } catch (e) {\n this.emit('error', {\n type: 'MessageParseError',\n error: e,\n data: messageEvent.data\n });\n }\n\n if (pusherEvent !== undefined) {\n Logger.debug('Event recd', pusherEvent);\n\n switch (pusherEvent.event) {\n case 'pusher:error':\n this.emit('error', {\n type: 'PusherError',\n data: pusherEvent.data\n });\n break;\n case 'pusher:ping':\n this.emit('ping');\n break;\n case 'pusher:pong':\n this.emit('pong');\n break;\n }\n this.emit('message', pusherEvent);\n }\n },\n activity: () => {\n this.emit('activity');\n },\n error: error => {\n this.emit('error', error);\n },\n closed: closeEvent => {\n unbindListeners();\n\n if (closeEvent && closeEvent.code) {\n this.handleCloseEvent(closeEvent);\n }\n\n this.transport = null;\n this.emit('closed');\n }\n };\n\n var unbindListeners = () => {\n Collections.objectApply(listeners, (listener, event) => {\n this.transport.unbind(event, listener);\n });\n };\n\n Collections.objectApply(listeners, (listener, event) => {\n this.transport.bind(event, listener);\n });\n }\n\n private handleCloseEvent(closeEvent: any) {\n var action = Protocol.getCloseAction(closeEvent);\n var error = Protocol.getCloseError(closeEvent);\n if (error) {\n this.emit('error', error);\n }\n if (action) {\n this.emit(action, { action: action, error: error });\n }\n }\n}\n","import Util from '../../util';\nimport * as Collections from '../../utils/collections';\nimport Protocol from '../protocol/protocol';\nimport Connection from '../connection';\nimport TransportConnection from '../../transports/transport_connection';\nimport HandshakePayload from './handshake_payload';\n\n/**\n * Handles Pusher protocol handshakes for transports.\n *\n * Calls back with a result object after handshake is completed. Results\n * always have two fields:\n * - action - string describing action to be taken after the handshake\n * - transport - the transport object passed to the constructor\n *\n * Different actions can set different additional properties on the result.\n * In the case of 'connected' action, there will be a 'connection' property\n * containing a Connection object for the transport. Other actions should\n * carry an 'error' property.\n *\n * @param {AbstractTransport} transport\n * @param {Function} callback\n */\nexport default class Handshake {\n transport: TransportConnection;\n callback: (HandshakePayload) => void;\n onMessage: Function;\n onClosed: Function;\n\n constructor(\n transport: TransportConnection,\n callback: (HandshakePayload) => void\n ) {\n this.transport = transport;\n this.callback = callback;\n this.bindListeners();\n }\n\n close() {\n this.unbindListeners();\n this.transport.close();\n }\n\n private bindListeners() {\n this.onMessage = m => {\n this.unbindListeners();\n\n var result;\n try {\n result = Protocol.processHandshake(m);\n } catch (e) {\n this.finish('error', { error: e });\n this.transport.close();\n return;\n }\n\n if (result.action === 'connected') {\n this.finish('connected', {\n connection: new Connection(result.id, this.transport),\n activityTimeout: result.activityTimeout\n });\n } else {\n this.finish(result.action, { error: result.error });\n this.transport.close();\n }\n };\n\n this.onClosed = closeEvent => {\n this.unbindListeners();\n\n var action = Protocol.getCloseAction(closeEvent) || 'backoff';\n var error = Protocol.getCloseError(closeEvent);\n this.finish(action, { error: error });\n };\n\n this.transport.bind('message', this.onMessage);\n this.transport.bind('closed', this.onClosed);\n }\n\n private unbindListeners() {\n this.transport.unbind('message', this.onMessage);\n this.transport.unbind('closed', this.onClosed);\n }\n\n private finish(action: string, params: any) {\n this.callback(\n Collections.extend({ transport: this.transport, action: action }, params)\n );\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport base64encode from '../base64';\nimport Timeline from './timeline';\nimport Runtime from 'runtime';\n\nexport interface TimelineSenderOptions {\n host?: string;\n port?: number;\n path?: string;\n}\n\nexport default class TimelineSender {\n timeline: Timeline;\n options: TimelineSenderOptions;\n host: string;\n\n constructor(timeline: Timeline, options: TimelineSenderOptions) {\n this.timeline = timeline;\n this.options = options || {};\n }\n\n send(useTLS: boolean, callback?: Function) {\n if (this.timeline.isEmpty()) {\n return;\n }\n\n this.timeline.send(\n Runtime.TimelineTransport.getAgent(this, useTLS),\n callback\n );\n }\n}\n","/** Error classes used throughout the library. */\n// https://github.com/Microsoft/TypeScript-wiki/blob/master/Breaking-Changes.md#extending-built-ins-like-error-array-and-map-may-no-longer-work\nexport class BadEventName extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\nexport class BadChannelName extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\nexport class RequestTimedOut extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class TransportPriorityTooLow extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class TransportClosed extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class UnsupportedFeature extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class UnsupportedTransport extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class UnsupportedStrategy extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class HTTPAuthError extends Error {\n status: number;\n constructor(status: number, msg?: string) {\n super(msg);\n this.status = status;\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n","/**\n * A place to store help URLs for error messages etc\n */\n\nconst urlStore = {\n baseUrl: 'https://pusher.com',\n urls: {\n authenticationEndpoint: {\n path: '/docs/channels/server_api/authenticating_users'\n },\n authorizationEndpoint: {\n path: '/docs/channels/server_api/authorizing-users/'\n },\n javascriptQuickStart: {\n path: '/docs/javascript_quick_start'\n },\n triggeringClientEvents: {\n path: '/docs/client_api_guide/client_events#trigger-events'\n },\n encryptedChannelSupport: {\n fullUrl:\n 'https://github.com/pusher/pusher-js/tree/cc491015371a4bde5743d1c87a0fbac0feb53195#encrypted-channel-support'\n }\n }\n};\n\n/** Builds a consistent string with links to pusher documentation\n *\n * @param {string} key - relevant key in the url_store.urls object\n * @return {string} suffix string to append to log message\n */\nconst buildLogSuffix = function(key: string): string {\n const urlPrefix = 'See:';\n const urlObj = urlStore.urls[key];\n if (!urlObj) return '';\n\n let url;\n if (urlObj.fullUrl) {\n url = urlObj.fullUrl;\n } else if (urlObj.path) {\n url = urlStore.baseUrl + urlObj.path;\n }\n\n if (!url) return '';\n return `${urlPrefix} ${url}`;\n};\n\nexport default { buildLogSuffix };\n","import { default as EventsDispatcher } from '../events/dispatcher';\nimport * as Errors from '../errors';\nimport Logger from '../logger';\nimport Pusher from '../pusher';\nimport { PusherEvent } from '../connection/protocol/message-types';\nimport Metadata from './metadata';\nimport UrlStore from '../utils/url_store';\nimport {\n ChannelAuthorizationData,\n ChannelAuthorizationCallback\n} from '../auth/options';\nimport { HTTPAuthError } from '../errors';\n\n/** Provides base public channel interface with an event emitter.\n *\n * Emits:\n * - pusher:subscription_succeeded - after subscribing successfully\n * - other non-internal events\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\nexport default class Channel extends EventsDispatcher {\n name: string;\n pusher: Pusher;\n subscribed: boolean;\n subscriptionPending: boolean;\n subscriptionCancelled: boolean;\n subscriptionCount: null;\n\n constructor(name: string, pusher: Pusher) {\n super(function(event, data) {\n Logger.debug('No callbacks on ' + name + ' for ' + event);\n });\n\n this.name = name;\n this.pusher = pusher;\n this.subscribed = false;\n this.subscriptionPending = false;\n this.subscriptionCancelled = false;\n }\n\n /** Skips authorization, since public channels don't require it.\n *\n * @param {Function} callback\n */\n authorize(socketId: string, callback: ChannelAuthorizationCallback) {\n return callback(null, { auth: '' });\n }\n\n /** Triggers an event */\n trigger(event: string, data: any) {\n if (event.indexOf('client-') !== 0) {\n throw new Errors.BadEventName(\n \"Event '\" + event + \"' does not start with 'client-'\"\n );\n }\n if (!this.subscribed) {\n var suffix = UrlStore.buildLogSuffix('triggeringClientEvents');\n Logger.warn(\n `Client event triggered before channel 'subscription_succeeded' event . ${suffix}`\n );\n }\n return this.pusher.send_event(event, data, this.name);\n }\n\n /** Signals disconnection to the channel. For internal use only. */\n disconnect() {\n this.subscribed = false;\n this.subscriptionPending = false;\n }\n\n /** Handles a PusherEvent. For internal use only.\n *\n * @param {PusherEvent} event\n */\n handleEvent(event: PusherEvent) {\n var eventName = event.event;\n var data = event.data;\n if (eventName === 'pusher_internal:subscription_succeeded') {\n this.handleSubscriptionSucceededEvent(event);\n } else if (eventName === 'pusher_internal:subscription_count') {\n this.handleSubscriptionCountEvent(event);\n } else if (eventName.indexOf('pusher_internal:') !== 0) {\n var metadata: Metadata = {};\n this.emit(eventName, data, metadata);\n }\n }\n\n handleSubscriptionSucceededEvent(event: PusherEvent) {\n this.subscriptionPending = false;\n this.subscribed = true;\n if (this.subscriptionCancelled) {\n this.pusher.unsubscribe(this.name);\n } else {\n this.emit('pusher:subscription_succeeded', event.data);\n }\n }\n\n handleSubscriptionCountEvent(event: PusherEvent) {\n if (event.data.subscription_count) {\n this.subscriptionCount = event.data.subscription_count;\n }\n\n this.emit('pusher:subscription_count', event.data);\n }\n\n /** Sends a subscription request. For internal use only. */\n subscribe() {\n if (this.subscribed) {\n return;\n }\n this.subscriptionPending = true;\n this.subscriptionCancelled = false;\n this.authorize(\n this.pusher.connection.socket_id,\n (error: Error | null, data: ChannelAuthorizationData) => {\n if (error) {\n this.subscriptionPending = false;\n // Why not bind to 'pusher:subscription_error' a level up, and log there?\n // Binding to this event would cause the warning about no callbacks being\n // bound (see constructor) to be suppressed, that's not what we want.\n Logger.error(error.toString());\n this.emit(\n 'pusher:subscription_error',\n Object.assign(\n {},\n {\n type: 'AuthError',\n error: error.message\n },\n error instanceof HTTPAuthError ? { status: error.status } : {}\n )\n );\n } else {\n this.pusher.send_event('pusher:subscribe', {\n auth: data.auth,\n channel_data: data.channel_data,\n channel: this.name\n });\n }\n }\n );\n }\n\n /** Sends an unsubscription request. For internal use only. */\n unsubscribe() {\n this.subscribed = false;\n this.pusher.send_event('pusher:unsubscribe', {\n channel: this.name\n });\n }\n\n /** Cancels an in progress subscription. For internal use only. */\n cancelSubscription() {\n this.subscriptionCancelled = true;\n }\n\n /** Reinstates an in progress subscripiton. For internal use only. */\n reinstateSubscription() {\n this.subscriptionCancelled = false;\n }\n}\n","import Factory from '../utils/factory';\nimport Channel from './channel';\nimport { ChannelAuthorizationCallback } from '../auth/options';\n\n/** Extends public channels to provide private channel interface.\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\nexport default class PrivateChannel extends Channel {\n /** Authorizes the connection to use the channel.\n *\n * @param {String} socketId\n * @param {Function} callback\n */\n authorize(socketId: string, callback: ChannelAuthorizationCallback) {\n return this.pusher.config.channelAuthorizer(\n {\n channelName: this.name,\n socketId: socketId\n },\n callback\n );\n }\n}\n","import * as Collections from '../utils/collections';\n\n/** Represents a collection of members of a presence channel. */\nexport default class Members {\n members: any;\n count: number;\n myID: any;\n me: any;\n\n constructor() {\n this.reset();\n }\n\n /** Returns member's info for given id.\n *\n * Resulting object containts two fields - id and info.\n *\n * @param {Number} id\n * @return {Object} member's info or null\n */\n get(id: string): any {\n if (Object.prototype.hasOwnProperty.call(this.members, id)) {\n return {\n id: id,\n info: this.members[id]\n };\n } else {\n return null;\n }\n }\n\n /** Calls back for each member in unspecified order.\n *\n * @param {Function} callback\n */\n each(callback: Function) {\n Collections.objectApply(this.members, (member, id) => {\n callback(this.get(id));\n });\n }\n\n /** Updates the id for connected member. For internal use only. */\n setMyID(id: string) {\n this.myID = id;\n }\n\n /** Handles subscription data. For internal use only. */\n onSubscription(subscriptionData: any) {\n this.members = subscriptionData.presence.hash;\n this.count = subscriptionData.presence.count;\n this.me = this.get(this.myID);\n }\n\n /** Adds a new member to the collection. For internal use only. */\n addMember(memberData: any) {\n if (this.get(memberData.user_id) === null) {\n this.count++;\n }\n this.members[memberData.user_id] = memberData.user_info;\n return this.get(memberData.user_id);\n }\n\n /** Adds a member from the collection. For internal use only. */\n removeMember(memberData: any) {\n var member = this.get(memberData.user_id);\n if (member) {\n delete this.members[memberData.user_id];\n this.count--;\n }\n return member;\n }\n\n /** Resets the collection to the initial state. For internal use only. */\n reset() {\n this.members = {};\n this.count = 0;\n this.myID = null;\n this.me = null;\n }\n}\n","import PrivateChannel from './private_channel';\nimport Logger from '../logger';\nimport Members from './members';\nimport Pusher from '../pusher';\nimport UrlStore from 'core/utils/url_store';\nimport { PusherEvent } from '../connection/protocol/message-types';\nimport Metadata from './metadata';\nimport { ChannelAuthorizationData } from '../auth/options';\n\nexport default class PresenceChannel extends PrivateChannel {\n members: Members;\n\n /** Adds presence channel functionality to private channels.\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\n constructor(name: string, pusher: Pusher) {\n super(name, pusher);\n this.members = new Members();\n }\n\n /** Authorizes the connection as a member of the channel.\n *\n * @param {String} socketId\n * @param {Function} callback\n */\n authorize(socketId: string, callback: Function) {\n super.authorize(socketId, async (error, authData) => {\n if (!error) {\n authData = authData as ChannelAuthorizationData;\n if (authData.channel_data != null) {\n var channelData = JSON.parse(authData.channel_data);\n this.members.setMyID(channelData.user_id);\n } else {\n await this.pusher.user.signinDonePromise;\n if (this.pusher.user.user_data != null) {\n // If the user is signed in, get the id of the authenticated user\n // and allow the presence authorization to continue.\n this.members.setMyID(this.pusher.user.user_data.id);\n } else {\n let suffix = UrlStore.buildLogSuffix('authorizationEndpoint');\n Logger.error(\n `Invalid auth response for channel '${this.name}', ` +\n `expected 'channel_data' field. ${suffix}, ` +\n `or the user should be signed in.`\n );\n callback('Invalid auth response');\n return;\n }\n }\n }\n callback(error, authData);\n });\n }\n\n /** Handles presence and subscription events. For internal use only.\n *\n * @param {PusherEvent} event\n */\n handleEvent(event: PusherEvent) {\n var eventName = event.event;\n if (eventName.indexOf('pusher_internal:') === 0) {\n this.handleInternalEvent(event);\n } else {\n var data = event.data;\n var metadata: Metadata = {};\n if (event.user_id) {\n metadata.user_id = event.user_id;\n }\n this.emit(eventName, data, metadata);\n }\n }\n handleInternalEvent(event: PusherEvent) {\n var eventName = event.event;\n var data = event.data;\n switch (eventName) {\n case 'pusher_internal:subscription_succeeded':\n this.handleSubscriptionSucceededEvent(event);\n break;\n case 'pusher_internal:subscription_count':\n this.handleSubscriptionCountEvent(event);\n break;\n case 'pusher_internal:member_added':\n var addedMember = this.members.addMember(data);\n this.emit('pusher:member_added', addedMember);\n break;\n case 'pusher_internal:member_removed':\n var removedMember = this.members.removeMember(data);\n if (removedMember) {\n this.emit('pusher:member_removed', removedMember);\n }\n break;\n }\n }\n\n handleSubscriptionSucceededEvent(event: PusherEvent) {\n this.subscriptionPending = false;\n this.subscribed = true;\n if (this.subscriptionCancelled) {\n this.pusher.unsubscribe(this.name);\n } else {\n this.members.onSubscription(event.data);\n this.emit('pusher:subscription_succeeded', this.members);\n }\n }\n\n /** Resets the channel state, including members map. For internal use only. */\n disconnect() {\n this.members.reset();\n super.disconnect();\n }\n}\n","import PrivateChannel from './private_channel';\nimport * as Errors from '../errors';\nimport Logger from '../logger';\nimport Pusher from '../pusher';\nimport { decode as encodeUTF8 } from '@stablelib/utf8';\nimport { decode as decodeBase64 } from '@stablelib/base64';\nimport Dispatcher from '../events/dispatcher';\nimport { PusherEvent } from '../connection/protocol/message-types';\nimport {\n ChannelAuthorizationData,\n ChannelAuthorizationCallback\n} from '../auth/options';\nimport * as nacl from 'tweetnacl';\n\n/** Extends private channels to provide encrypted channel interface.\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\nexport default class EncryptedChannel extends PrivateChannel {\n key: Uint8Array = null;\n nacl: nacl;\n\n constructor(name: string, pusher: Pusher, nacl: nacl) {\n super(name, pusher);\n this.nacl = nacl;\n }\n\n /** Authorizes the connection to use the channel.\n *\n * @param {String} socketId\n * @param {Function} callback\n */\n authorize(socketId: string, callback: ChannelAuthorizationCallback) {\n super.authorize(\n socketId,\n (error: Error | null, authData: ChannelAuthorizationData) => {\n if (error) {\n callback(error, authData);\n return;\n }\n let sharedSecret = authData['shared_secret'];\n if (!sharedSecret) {\n callback(\n new Error(\n `No shared_secret key in auth payload for encrypted channel: ${this.name}`\n ),\n null\n );\n return;\n }\n this.key = decodeBase64(sharedSecret);\n delete authData['shared_secret'];\n callback(null, authData);\n }\n );\n }\n\n trigger(event: string, data: any): boolean {\n throw new Errors.UnsupportedFeature(\n 'Client events are not currently supported for encrypted channels'\n );\n }\n\n /** Handles an event. For internal use only.\n *\n * @param {PusherEvent} event\n */\n handleEvent(event: PusherEvent) {\n var eventName = event.event;\n var data = event.data;\n if (\n eventName.indexOf('pusher_internal:') === 0 ||\n eventName.indexOf('pusher:') === 0\n ) {\n super.handleEvent(event);\n return;\n }\n this.handleEncryptedEvent(eventName, data);\n }\n\n private handleEncryptedEvent(event: string, data: any): void {\n if (!this.key) {\n Logger.debug(\n 'Received encrypted event before key has been retrieved from the authEndpoint'\n );\n return;\n }\n if (!data.ciphertext || !data.nonce) {\n Logger.error(\n 'Unexpected format for encrypted event, expected object with `ciphertext` and `nonce` fields, got: ' +\n data\n );\n return;\n }\n let cipherText = decodeBase64(data.ciphertext);\n if (cipherText.length < this.nacl.secretbox.overheadLength) {\n Logger.error(\n `Expected encrypted event ciphertext length to be ${this.nacl.secretbox.overheadLength}, got: ${cipherText.length}`\n );\n return;\n }\n let nonce = decodeBase64(data.nonce);\n if (nonce.length < this.nacl.secretbox.nonceLength) {\n Logger.error(\n `Expected encrypted event nonce length to be ${this.nacl.secretbox.nonceLength}, got: ${nonce.length}`\n );\n return;\n }\n\n let bytes = this.nacl.secretbox.open(cipherText, nonce, this.key);\n if (bytes === null) {\n Logger.debug(\n 'Failed to decrypt an event, probably because it was encrypted with a different key. Fetching a new key from the authEndpoint...'\n );\n // Try a single time to retrieve a new auth key and decrypt the event with it\n // If this fails, a new key will be requested when a new message is received\n this.authorize(this.pusher.connection.socket_id, (error, authData) => {\n if (error) {\n Logger.error(\n `Failed to make a request to the authEndpoint: ${authData}. Unable to fetch new key, so dropping encrypted event`\n );\n return;\n }\n bytes = this.nacl.secretbox.open(cipherText, nonce, this.key);\n if (bytes === null) {\n Logger.error(\n `Failed to decrypt event with new key. Dropping encrypted event`\n );\n return;\n }\n this.emit(event, this.getDataToEmit(bytes));\n return;\n });\n return;\n }\n this.emit(event, this.getDataToEmit(bytes));\n }\n\n // Try and parse the decrypted bytes as JSON. If we can't parse it, just\n // return the utf-8 string\n getDataToEmit(bytes: Uint8Array): string {\n let raw = encodeUTF8(bytes);\n try {\n return JSON.parse(raw);\n } catch {\n return raw;\n }\n }\n}\n","import { default as EventsDispatcher } from '../events/dispatcher';\nimport { OneOffTimer as Timer } from '../utils/timers';\nimport { Config } from '../config';\nimport Logger from '../logger';\nimport HandshakePayload from './handshake/handshake_payload';\nimport Connection from './connection';\nimport Strategy from '../strategies/strategy';\nimport StrategyRunner from '../strategies/strategy_runner';\nimport * as Collections from '../utils/collections';\nimport Timeline from '../timeline/timeline';\nimport ConnectionManagerOptions from './connection_manager_options';\nimport Runtime from 'runtime';\n\nimport {\n ErrorCallbacks,\n HandshakeCallbacks,\n ConnectionCallbacks\n} from './callbacks';\nimport Action from './protocol/action';\n\n/** Manages connection to Pusher.\n *\n * Uses a strategy (currently only default), timers and network availability\n * info to establish a connection and export its state. In case of failures,\n * manages reconnection attempts.\n *\n * Exports state changes as following events:\n * - \"state_change\", { previous: p, current: state }\n * - state\n *\n * States:\n * - initialized - initial state, never transitioned to\n * - connecting - connection is being established\n * - connected - connection has been fully established\n * - disconnected - on requested disconnection\n * - unavailable - after connection timeout or when there's no network\n * - failed - when the connection strategy is not supported\n *\n * Options:\n * - unavailableTimeout - time to transition to unavailable state\n * - activityTimeout - time after which ping message should be sent\n * - pongTimeout - time for Pusher to respond with pong before reconnecting\n *\n * @param {String} key application key\n * @param {Object} options\n */\nexport default class ConnectionManager extends EventsDispatcher {\n key: string;\n options: ConnectionManagerOptions;\n state: string;\n connection: Connection;\n usingTLS: boolean;\n timeline: Timeline;\n socket_id: string;\n unavailableTimer: Timer;\n activityTimer: Timer;\n retryTimer: Timer;\n activityTimeout: number;\n strategy: Strategy;\n runner: StrategyRunner;\n errorCallbacks: ErrorCallbacks;\n handshakeCallbacks: HandshakeCallbacks;\n connectionCallbacks: ConnectionCallbacks;\n\n constructor(key: string, options: ConnectionManagerOptions) {\n super();\n this.state = 'initialized';\n this.connection = null;\n\n this.key = key;\n this.options = options;\n this.timeline = this.options.timeline;\n this.usingTLS = this.options.useTLS;\n\n this.errorCallbacks = this.buildErrorCallbacks();\n this.connectionCallbacks = this.buildConnectionCallbacks(\n this.errorCallbacks\n );\n this.handshakeCallbacks = this.buildHandshakeCallbacks(this.errorCallbacks);\n\n var Network = Runtime.getNetwork();\n\n Network.bind('online', () => {\n this.timeline.info({ netinfo: 'online' });\n if (this.state === 'connecting' || this.state === 'unavailable') {\n this.retryIn(0);\n }\n });\n Network.bind('offline', () => {\n this.timeline.info({ netinfo: 'offline' });\n if (this.connection) {\n this.sendActivityCheck();\n }\n });\n\n this.updateStrategy();\n }\n\n /** Establishes a connection to Pusher.\n *\n * Does nothing when connection is already established. See top-level doc\n * to find events emitted on connection attempts.\n */\n connect() {\n if (this.connection || this.runner) {\n return;\n }\n if (!this.strategy.isSupported()) {\n this.updateState('failed');\n return;\n }\n this.updateState('connecting');\n this.startConnecting();\n this.setUnavailableTimer();\n }\n\n /** Sends raw data.\n *\n * @param {String} data\n */\n send(data) {\n if (this.connection) {\n return this.connection.send(data);\n } else {\n return false;\n }\n }\n\n /** Sends an event.\n *\n * @param {String} name\n * @param {String} data\n * @param {String} [channel]\n * @returns {Boolean} whether message was sent or not\n */\n send_event(name: string, data: any, channel?: string) {\n if (this.connection) {\n return this.connection.send_event(name, data, channel);\n } else {\n return false;\n }\n }\n\n /** Closes the connection. */\n disconnect() {\n this.disconnectInternally();\n this.updateState('disconnected');\n }\n\n isUsingTLS() {\n return this.usingTLS;\n }\n\n private startConnecting() {\n var callback = (error, handshake) => {\n if (error) {\n this.runner = this.strategy.connect(0, callback);\n } else {\n if (handshake.action === 'error') {\n this.emit('error', {\n type: 'HandshakeError',\n error: handshake.error\n });\n this.timeline.error({ handshakeError: handshake.error });\n } else {\n this.abortConnecting(); // we don't support switching connections yet\n this.handshakeCallbacks[handshake.action](handshake);\n }\n }\n };\n this.runner = this.strategy.connect(0, callback);\n }\n\n private abortConnecting() {\n if (this.runner) {\n this.runner.abort();\n this.runner = null;\n }\n }\n\n private disconnectInternally() {\n this.abortConnecting();\n this.clearRetryTimer();\n this.clearUnavailableTimer();\n if (this.connection) {\n var connection = this.abandonConnection();\n connection.close();\n }\n }\n\n private updateStrategy() {\n this.strategy = this.options.getStrategy({\n key: this.key,\n timeline: this.timeline,\n useTLS: this.usingTLS\n });\n }\n\n private retryIn(delay) {\n this.timeline.info({ action: 'retry', delay: delay });\n if (delay > 0) {\n this.emit('connecting_in', Math.round(delay / 1000));\n }\n this.retryTimer = new Timer(delay || 0, () => {\n this.disconnectInternally();\n this.connect();\n });\n }\n\n private clearRetryTimer() {\n if (this.retryTimer) {\n this.retryTimer.ensureAborted();\n this.retryTimer = null;\n }\n }\n\n private setUnavailableTimer() {\n this.unavailableTimer = new Timer(this.options.unavailableTimeout, () => {\n this.updateState('unavailable');\n });\n }\n\n private clearUnavailableTimer() {\n if (this.unavailableTimer) {\n this.unavailableTimer.ensureAborted();\n }\n }\n\n private sendActivityCheck() {\n this.stopActivityCheck();\n this.connection.ping();\n // wait for pong response\n this.activityTimer = new Timer(this.options.pongTimeout, () => {\n this.timeline.error({ pong_timed_out: this.options.pongTimeout });\n this.retryIn(0);\n });\n }\n\n private resetActivityCheck() {\n this.stopActivityCheck();\n // send ping after inactivity\n if (this.connection && !this.connection.handlesActivityChecks()) {\n this.activityTimer = new Timer(this.activityTimeout, () => {\n this.sendActivityCheck();\n });\n }\n }\n\n private stopActivityCheck() {\n if (this.activityTimer) {\n this.activityTimer.ensureAborted();\n }\n }\n\n private buildConnectionCallbacks(\n errorCallbacks: ErrorCallbacks\n ): ConnectionCallbacks {\n return Collections.extend({}, errorCallbacks, {\n message: message => {\n // includes pong messages from server\n this.resetActivityCheck();\n this.emit('message', message);\n },\n ping: () => {\n this.send_event('pusher:pong', {});\n },\n activity: () => {\n this.resetActivityCheck();\n },\n error: error => {\n // just emit error to user - socket will already be closed by browser\n this.emit('error', error);\n },\n closed: () => {\n this.abandonConnection();\n if (this.shouldRetry()) {\n this.retryIn(1000);\n }\n }\n });\n }\n\n private buildHandshakeCallbacks(\n errorCallbacks: ErrorCallbacks\n ): HandshakeCallbacks {\n return Collections.extend({}, errorCallbacks, {\n connected: (handshake: HandshakePayload) => {\n this.activityTimeout = Math.min(\n this.options.activityTimeout,\n handshake.activityTimeout,\n handshake.connection.activityTimeout || Infinity\n );\n this.clearUnavailableTimer();\n this.setConnection(handshake.connection);\n this.socket_id = this.connection.id;\n this.updateState('connected', { socket_id: this.socket_id });\n }\n });\n }\n\n private buildErrorCallbacks(): ErrorCallbacks {\n let withErrorEmitted = callback => {\n return (result: Action | HandshakePayload) => {\n if (result.error) {\n this.emit('error', { type: 'WebSocketError', error: result.error });\n }\n callback(result);\n };\n };\n\n return {\n tls_only: withErrorEmitted(() => {\n this.usingTLS = true;\n this.updateStrategy();\n this.retryIn(0);\n }),\n refused: withErrorEmitted(() => {\n this.disconnect();\n }),\n backoff: withErrorEmitted(() => {\n this.retryIn(1000);\n }),\n retry: withErrorEmitted(() => {\n this.retryIn(0);\n })\n };\n }\n\n private setConnection(connection) {\n this.connection = connection;\n for (var event in this.connectionCallbacks) {\n this.connection.bind(event, this.connectionCallbacks[event]);\n }\n this.resetActivityCheck();\n }\n\n private abandonConnection() {\n if (!this.connection) {\n return;\n }\n this.stopActivityCheck();\n for (var event in this.connectionCallbacks) {\n this.connection.unbind(event, this.connectionCallbacks[event]);\n }\n var connection = this.connection;\n this.connection = null;\n return connection;\n }\n\n private updateState(newState: string, data?: any) {\n var previousState = this.state;\n this.state = newState;\n if (previousState !== newState) {\n var newStateDescription = newState;\n if (newStateDescription === 'connected') {\n newStateDescription += ' with new socket ID ' + data.socket_id;\n }\n Logger.debug(\n 'State changed',\n previousState + ' -> ' + newStateDescription\n );\n this.timeline.info({ state: newState, params: data });\n this.emit('state_change', { previous: previousState, current: newState });\n this.emit(newState, data);\n }\n }\n\n private shouldRetry(): boolean {\n return this.state === 'connecting' || this.state === 'connected';\n }\n}\n","import Channel from './channel';\nimport * as Collections from '../utils/collections';\nimport ChannelTable from './channel_table';\nimport Factory from '../utils/factory';\nimport Pusher from '../pusher';\nimport Logger from '../logger';\nimport * as Errors from '../errors';\nimport urlStore from '../utils/url_store';\n\n/** Handles a channel map. */\nexport default class Channels {\n channels: ChannelTable;\n\n constructor() {\n this.channels = {};\n }\n\n /** Creates or retrieves an existing channel by its name.\n *\n * @param {String} name\n * @param {Pusher} pusher\n * @return {Channel}\n */\n add(name: string, pusher: Pusher) {\n if (!this.channels[name]) {\n this.channels[name] = createChannel(name, pusher);\n }\n return this.channels[name];\n }\n\n /** Returns a list of all channels\n *\n * @return {Array}\n */\n all(): Channel[] {\n return Collections.values(this.channels);\n }\n\n /** Finds a channel by its name.\n *\n * @param {String} name\n * @return {Channel} channel or null if it doesn't exist\n */\n find(name: string) {\n return this.channels[name];\n }\n\n /** Removes a channel from the map.\n *\n * @param {String} name\n */\n remove(name: string) {\n var channel = this.channels[name];\n delete this.channels[name];\n return channel;\n }\n\n /** Proxies disconnection signal to all channels. */\n disconnect() {\n Collections.objectApply(this.channels, function(channel) {\n channel.disconnect();\n });\n }\n}\n\nfunction createChannel(name: string, pusher: Pusher): Channel {\n if (name.indexOf('private-encrypted-') === 0) {\n if (pusher.config.nacl) {\n return Factory.createEncryptedChannel(name, pusher, pusher.config.nacl);\n }\n let errMsg =\n 'Tried to subscribe to a private-encrypted- channel but no nacl implementation available';\n let suffix = urlStore.buildLogSuffix('encryptedChannelSupport');\n throw new Errors.UnsupportedFeature(`${errMsg}. ${suffix}`);\n } else if (name.indexOf('private-') === 0) {\n return Factory.createPrivateChannel(name, pusher);\n } else if (name.indexOf('presence-') === 0) {\n return Factory.createPresenceChannel(name, pusher);\n } else if (name.indexOf('#') === 0) {\n throw new Errors.BadChannelName(\n 'Cannot create a channel with name \"' + name + '\".'\n );\n } else {\n return Factory.createChannel(name, pusher);\n }\n}\n","import AssistantToTheTransportManager from '../transports/assistant_to_the_transport_manager';\nimport PingDelayOptions from '../transports/ping_delay_options';\nimport Transport from '../transports/transport';\nimport TransportManager from '../transports/transport_manager';\nimport Handshake from '../connection/handshake';\nimport TransportConnection from '../transports/transport_connection';\nimport SocketHooks from '../http/socket_hooks';\nimport HTTPSocket from '../http/http_socket';\n\nimport Timeline from '../timeline/timeline';\nimport {\n default as TimelineSender,\n TimelineSenderOptions\n} from '../timeline/timeline_sender';\nimport PresenceChannel from '../channels/presence_channel';\nimport PrivateChannel from '../channels/private_channel';\nimport EncryptedChannel from '../channels/encrypted_channel';\nimport Channel from '../channels/channel';\nimport ConnectionManager from '../connection/connection_manager';\nimport ConnectionManagerOptions from '../connection/connection_manager_options';\nimport Ajax from '../http/ajax';\nimport Channels from '../channels/channels';\nimport Pusher from '../pusher';\nimport { Config } from '../config';\nimport * as nacl from 'tweetnacl';\n\nvar Factory = {\n createChannels(): Channels {\n return new Channels();\n },\n\n createConnectionManager(\n key: string,\n options: ConnectionManagerOptions\n ): ConnectionManager {\n return new ConnectionManager(key, options);\n },\n\n createChannel(name: string, pusher: Pusher): Channel {\n return new Channel(name, pusher);\n },\n\n createPrivateChannel(name: string, pusher: Pusher): PrivateChannel {\n return new PrivateChannel(name, pusher);\n },\n\n createPresenceChannel(name: string, pusher: Pusher): PresenceChannel {\n return new PresenceChannel(name, pusher);\n },\n\n createEncryptedChannel(\n name: string,\n pusher: Pusher,\n nacl: nacl\n ): EncryptedChannel {\n return new EncryptedChannel(name, pusher, nacl);\n },\n\n createTimelineSender(timeline: Timeline, options: TimelineSenderOptions) {\n return new TimelineSender(timeline, options);\n },\n\n createHandshake(\n transport: TransportConnection,\n callback: (HandshakePayload) => void\n ): Handshake {\n return new Handshake(transport, callback);\n },\n\n createAssistantToTheTransportManager(\n manager: TransportManager,\n transport: Transport,\n options: PingDelayOptions\n ): AssistantToTheTransportManager {\n return new AssistantToTheTransportManager(manager, transport, options);\n }\n};\n\nexport default Factory;\n","import AssistantToTheTransportManager from './assistant_to_the_transport_manager';\nimport Transport from './transport';\nimport PingDelayOptions from './ping_delay_options';\nimport Factory from '../utils/factory';\n\nexport interface TransportManagerOptions extends PingDelayOptions {\n lives?: number;\n}\n\n/** Keeps track of the number of lives left for a transport.\n *\n * In the beginning of a session, transports may be assigned a number of\n * lives. When an AssistantToTheTransportManager instance reports a transport\n * connection closed uncleanly, the transport loses a life. When the number\n * of lives drops to zero, the transport gets disabled by its manager.\n *\n * @param {Object} options\n */\nexport default class TransportManager {\n options: TransportManagerOptions;\n livesLeft: number;\n\n constructor(options: TransportManagerOptions) {\n this.options = options || {};\n this.livesLeft = this.options.lives || Infinity;\n }\n\n /** Creates a assistant for the transport.\n *\n * @param {Transport} transport\n * @returns {AssistantToTheTransportManager}\n */\n getAssistant(transport: Transport): AssistantToTheTransportManager {\n return Factory.createAssistantToTheTransportManager(this, transport, {\n minPingDelay: this.options.minPingDelay,\n maxPingDelay: this.options.maxPingDelay\n });\n }\n\n /** Returns whether the transport has any lives left.\n *\n * @returns {Boolean}\n */\n isAlive(): boolean {\n return this.livesLeft > 0;\n }\n\n /** Takes one life from the transport. */\n reportDeath() {\n this.livesLeft -= 1;\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport { OneOffTimer as Timer } from '../utils/timers';\nimport Strategy from './strategy';\nimport StrategyOptions from './strategy_options';\n\n/** Loops through strategies with optional timeouts.\n *\n * Options:\n * - loop - whether it should loop through the substrategy list\n * - timeout - initial timeout for a single substrategy\n * - timeoutLimit - maximum timeout\n *\n * @param {Strategy[]} strategies\n * @param {Object} options\n */\nexport default class SequentialStrategy implements Strategy {\n strategies: Strategy[];\n loop: boolean;\n failFast: boolean;\n timeout: number;\n timeoutLimit: number;\n\n constructor(strategies: Strategy[], options: StrategyOptions) {\n this.strategies = strategies;\n this.loop = Boolean(options.loop);\n this.failFast = Boolean(options.failFast);\n this.timeout = options.timeout;\n this.timeoutLimit = options.timeoutLimit;\n }\n\n isSupported(): boolean {\n return Collections.any(this.strategies, Util.method('isSupported'));\n }\n\n connect(minPriority: number, callback: Function) {\n var strategies = this.strategies;\n var current = 0;\n var timeout = this.timeout;\n var runner = null;\n\n var tryNextStrategy = (error, handshake) => {\n if (handshake) {\n callback(null, handshake);\n } else {\n current = current + 1;\n if (this.loop) {\n current = current % strategies.length;\n }\n\n if (current < strategies.length) {\n if (timeout) {\n timeout = timeout * 2;\n if (this.timeoutLimit) {\n timeout = Math.min(timeout, this.timeoutLimit);\n }\n }\n runner = this.tryStrategy(\n strategies[current],\n minPriority,\n { timeout, failFast: this.failFast },\n tryNextStrategy\n );\n } else {\n callback(true);\n }\n }\n };\n\n runner = this.tryStrategy(\n strategies[current],\n minPriority,\n { timeout: timeout, failFast: this.failFast },\n tryNextStrategy\n );\n\n return {\n abort: function() {\n runner.abort();\n },\n forceMinPriority: function(p) {\n minPriority = p;\n if (runner) {\n runner.forceMinPriority(p);\n }\n }\n };\n }\n\n private tryStrategy(\n strategy: Strategy,\n minPriority: number,\n options: StrategyOptions,\n callback: Function\n ) {\n var timer = null;\n var runner = null;\n\n if (options.timeout > 0) {\n timer = new Timer(options.timeout, function() {\n runner.abort();\n callback(true);\n });\n }\n\n runner = strategy.connect(minPriority, function(error, handshake) {\n if (error && timer && timer.isRunning() && !options.failFast) {\n // advance to the next strategy after the timeout\n return;\n }\n if (timer) {\n timer.ensureAborted();\n }\n callback(error, handshake);\n });\n\n return {\n abort: function() {\n if (timer) {\n timer.ensureAborted();\n }\n runner.abort();\n },\n forceMinPriority: function(p) {\n runner.forceMinPriority(p);\n }\n };\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport Strategy from './strategy';\n\n/** Launches all substrategies and emits prioritized connected transports.\n *\n * @param {Array} strategies\n */\nexport default class BestConnectedEverStrategy implements Strategy {\n strategies: Strategy[];\n\n constructor(strategies: Strategy[]) {\n this.strategies = strategies;\n }\n\n isSupported(): boolean {\n return Collections.any(this.strategies, Util.method('isSupported'));\n }\n\n connect(minPriority: number, callback: Function) {\n return connect(this.strategies, minPriority, function(i, runners) {\n return function(error, handshake) {\n runners[i].error = error;\n if (error) {\n if (allRunnersFailed(runners)) {\n callback(true);\n }\n return;\n }\n Collections.apply(runners, function(runner) {\n runner.forceMinPriority(handshake.transport.priority);\n });\n callback(null, handshake);\n };\n });\n }\n}\n\n/** Connects to all strategies in parallel.\n *\n * Callback builder should be a function that takes two arguments: index\n * and a list of runners. It should return another function that will be\n * passed to the substrategy with given index. Runners can be aborted using\n * abortRunner(s) functions from this class.\n *\n * @param {Array} strategies\n * @param {Function} callbackBuilder\n * @return {Object} strategy runner\n */\nfunction connect(\n strategies: Strategy[],\n minPriority: number,\n callbackBuilder: Function\n) {\n var runners = Collections.map(strategies, function(strategy, i, _, rs) {\n return strategy.connect(minPriority, callbackBuilder(i, rs));\n });\n return {\n abort: function() {\n Collections.apply(runners, abortRunner);\n },\n forceMinPriority: function(p) {\n Collections.apply(runners, function(runner) {\n runner.forceMinPriority(p);\n });\n }\n };\n}\n\nfunction allRunnersFailed(runners): boolean {\n return Collections.all(runners, function(runner) {\n return Boolean(runner.error);\n });\n}\n\nfunction abortRunner(runner) {\n if (!runner.error && !runner.aborted) {\n runner.abort();\n runner.aborted = true;\n }\n}\n","import Util from '../util';\nimport Runtime from 'runtime';\nimport Strategy from './strategy';\nimport SequentialStrategy from './sequential_strategy';\nimport StrategyOptions from './strategy_options';\nimport TransportStrategy from './transport_strategy';\nimport Timeline from '../timeline/timeline';\nimport * as Collections from '../utils/collections';\n\nexport interface TransportStrategyDictionary {\n [key: string]: TransportStrategy;\n}\n\n/** Caches the last successful transport and, after the first few attempts,\n * uses the cached transport for subsequent attempts.\n *\n * @param {Strategy} strategy\n * @param {Object} transports\n * @param {Object} options\n */\nexport default class WebSocketPrioritizedCachedStrategy implements Strategy {\n strategy: Strategy;\n transports: TransportStrategyDictionary;\n ttl: number;\n usingTLS: boolean;\n timeline: Timeline;\n\n constructor(\n strategy: Strategy,\n transports: TransportStrategyDictionary,\n options: StrategyOptions\n ) {\n this.strategy = strategy;\n this.transports = transports;\n this.ttl = options.ttl || 1800 * 1000;\n this.usingTLS = options.useTLS;\n this.timeline = options.timeline;\n }\n\n isSupported(): boolean {\n return this.strategy.isSupported();\n }\n\n connect(minPriority: number, callback: Function) {\n var usingTLS = this.usingTLS;\n var info = fetchTransportCache(usingTLS);\n var cacheSkipCount = info && info.cacheSkipCount ? info.cacheSkipCount : 0;\n\n var strategies = [this.strategy];\n if (info && info.timestamp + this.ttl >= Util.now()) {\n var transport = this.transports[info.transport];\n if (transport) {\n if (['ws', 'wss'].includes(info.transport) || cacheSkipCount > 3) {\n this.timeline.info({\n cached: true,\n transport: info.transport,\n latency: info.latency\n });\n strategies.push(\n new SequentialStrategy([transport], {\n timeout: info.latency * 2 + 1000,\n failFast: true\n })\n );\n } else {\n cacheSkipCount++;\n }\n }\n }\n\n var startTimestamp = Util.now();\n var runner = strategies\n .pop()\n .connect(minPriority, function cb(error, handshake) {\n if (error) {\n flushTransportCache(usingTLS);\n if (strategies.length > 0) {\n startTimestamp = Util.now();\n runner = strategies.pop().connect(minPriority, cb);\n } else {\n callback(error);\n }\n } else {\n storeTransportCache(\n usingTLS,\n handshake.transport.name,\n Util.now() - startTimestamp,\n cacheSkipCount\n );\n callback(null, handshake);\n }\n });\n\n return {\n abort: function() {\n runner.abort();\n },\n forceMinPriority: function(p) {\n minPriority = p;\n if (runner) {\n runner.forceMinPriority(p);\n }\n }\n };\n }\n}\n\nfunction getTransportCacheKey(usingTLS: boolean): string {\n return 'pusherTransport' + (usingTLS ? 'TLS' : 'NonTLS');\n}\n\nfunction fetchTransportCache(usingTLS: boolean): any {\n var storage = Runtime.getLocalStorage();\n if (storage) {\n try {\n var serializedCache = storage[getTransportCacheKey(usingTLS)];\n if (serializedCache) {\n return JSON.parse(serializedCache);\n }\n } catch (e) {\n flushTransportCache(usingTLS);\n }\n }\n return null;\n}\n\nfunction storeTransportCache(\n usingTLS: boolean,\n transport: TransportStrategy,\n latency: number,\n cacheSkipCount: number\n) {\n var storage = Runtime.getLocalStorage();\n if (storage) {\n try {\n storage[getTransportCacheKey(usingTLS)] = Collections.safeJSONStringify({\n timestamp: Util.now(),\n transport: transport,\n latency: latency,\n cacheSkipCount: cacheSkipCount\n });\n } catch (e) {\n // catch over quota exceptions raised by localStorage\n }\n }\n}\n\nfunction flushTransportCache(usingTLS: boolean) {\n var storage = Runtime.getLocalStorage();\n if (storage) {\n try {\n delete storage[getTransportCacheKey(usingTLS)];\n } catch (e) {\n // catch exceptions raised by localStorage\n }\n }\n}\n","import { OneOffTimer as Timer } from '../utils/timers';\nimport Strategy from './strategy';\nimport StrategyOptions from './strategy_options';\n\n/** Runs substrategy after specified delay.\n *\n * Options:\n * - delay - time in miliseconds to delay the substrategy attempt\n *\n * @param {Strategy} strategy\n * @param {Object} options\n */\nexport default class DelayedStrategy implements Strategy {\n strategy: Strategy;\n options: { delay: number };\n\n constructor(strategy: Strategy, { delay: number }) {\n this.strategy = strategy;\n this.options = { delay: number };\n }\n\n isSupported(): boolean {\n return this.strategy.isSupported();\n }\n\n connect(minPriority: number, callback: Function) {\n var strategy = this.strategy;\n var runner;\n var timer = new Timer(this.options.delay, function() {\n runner = strategy.connect(minPriority, callback);\n });\n\n return {\n abort: function() {\n timer.ensureAborted();\n if (runner) {\n runner.abort();\n }\n },\n forceMinPriority: function(p) {\n minPriority = p;\n if (runner) {\n runner.forceMinPriority(p);\n }\n }\n };\n }\n}\n","import Strategy from './strategy';\nimport StrategyRunner from './strategy_runner';\n\n/** Proxies method calls to one of substrategies basing on the test function.\n *\n * @param {Function} test\n * @param {Strategy} trueBranch strategy used when test returns true\n * @param {Strategy} falseBranch strategy used when test returns false\n */\nexport default class IfStrategy implements Strategy {\n test: () => boolean;\n trueBranch: Strategy;\n falseBranch: Strategy;\n\n constructor(\n test: () => boolean,\n trueBranch: Strategy,\n falseBranch: Strategy\n ) {\n this.test = test;\n this.trueBranch = trueBranch;\n this.falseBranch = falseBranch;\n }\n\n isSupported(): boolean {\n var branch = this.test() ? this.trueBranch : this.falseBranch;\n return branch.isSupported();\n }\n\n connect(minPriority: number, callback: Function): StrategyRunner {\n var branch = this.test() ? this.trueBranch : this.falseBranch;\n return branch.connect(minPriority, callback);\n }\n}\n","import Strategy from './strategy';\nimport StrategyRunner from './strategy_runner';\n\n/** Launches the substrategy and terminates on the first open connection.\n *\n * @param {Strategy} strategy\n */\nexport default class FirstConnectedStrategy implements Strategy {\n strategy: Strategy;\n\n constructor(strategy: Strategy) {\n this.strategy = strategy;\n }\n\n isSupported(): boolean {\n return this.strategy.isSupported();\n }\n\n connect(minPriority: number, callback: Function): StrategyRunner {\n var runner = this.strategy.connect(minPriority, function(error, handshake) {\n if (handshake) {\n runner.abort();\n }\n callback(error, handshake);\n });\n return runner;\n }\n}\n","import * as Collections from 'core/utils/collections';\nimport TransportManager from 'core/transports/transport_manager';\nimport Strategy from 'core/strategies/strategy';\nimport SequentialStrategy from 'core/strategies/sequential_strategy';\nimport BestConnectedEverStrategy from 'core/strategies/best_connected_ever_strategy';\nimport WebSocketPrioritizedCachedStrategy, {\n TransportStrategyDictionary\n} from 'core/strategies/websocket_prioritized_cached_strategy';\nimport DelayedStrategy from 'core/strategies/delayed_strategy';\nimport IfStrategy from 'core/strategies/if_strategy';\nimport FirstConnectedStrategy from 'core/strategies/first_connected_strategy';\nimport { Config } from 'core/config';\nimport StrategyOptions from 'core/strategies/strategy_options';\n\nfunction testSupportsStrategy(strategy: Strategy) {\n return function() {\n return strategy.isSupported();\n };\n}\n\nvar getDefaultStrategy = function(\n config: Config,\n baseOptions: StrategyOptions,\n defineTransport: Function\n): Strategy {\n var definedTransports = {};\n\n function defineTransportStrategy(\n name: string,\n type: string,\n priority: number,\n options: StrategyOptions,\n manager?: TransportManager\n ) {\n var transport = defineTransport(\n config,\n name,\n type,\n priority,\n options,\n manager\n );\n\n definedTransports[name] = transport;\n\n return transport;\n }\n\n var ws_options: StrategyOptions = Object.assign({}, baseOptions, {\n hostNonTLS: config.wsHost + ':' + config.wsPort,\n hostTLS: config.wsHost + ':' + config.wssPort,\n httpPath: config.wsPath\n });\n var wss_options: StrategyOptions = Collections.extend({}, ws_options, {\n useTLS: true\n });\n var http_options: StrategyOptions = Object.assign({}, baseOptions, {\n hostNonTLS: config.httpHost + ':' + config.httpPort,\n hostTLS: config.httpHost + ':' + config.httpsPort,\n httpPath: config.httpPath\n });\n var timeouts = {\n loop: true,\n timeout: 15000,\n timeoutLimit: 60000\n };\n\n var ws_manager = new TransportManager({\n minPingDelay: 10000,\n maxPingDelay: config.activityTimeout\n });\n var streaming_manager = new TransportManager({\n lives: 2,\n minPingDelay: 10000,\n maxPingDelay: config.activityTimeout\n });\n\n var ws_transport = defineTransportStrategy(\n 'ws',\n 'ws',\n 3,\n ws_options,\n ws_manager\n );\n var wss_transport = defineTransportStrategy(\n 'wss',\n 'ws',\n 3,\n wss_options,\n ws_manager\n );\n var xhr_streaming_transport = defineTransportStrategy(\n 'xhr_streaming',\n 'xhr_streaming',\n 1,\n http_options,\n streaming_manager\n );\n var xhr_polling_transport = defineTransportStrategy(\n 'xhr_polling',\n 'xhr_polling',\n 1,\n http_options\n );\n\n var ws_loop = new SequentialStrategy([ws_transport], timeouts);\n var wss_loop = new SequentialStrategy([wss_transport], timeouts);\n var streaming_loop = new SequentialStrategy(\n [xhr_streaming_transport],\n timeouts\n );\n var polling_loop = new SequentialStrategy([xhr_polling_transport], timeouts);\n\n var http_loop = new SequentialStrategy(\n [\n new IfStrategy(\n testSupportsStrategy(streaming_loop),\n new BestConnectedEverStrategy([\n streaming_loop,\n new DelayedStrategy(polling_loop, { delay: 4000 })\n ]),\n polling_loop\n )\n ],\n timeouts\n );\n\n var wsStrategy;\n if (baseOptions.useTLS) {\n wsStrategy = new BestConnectedEverStrategy([\n ws_loop,\n new DelayedStrategy(http_loop, { delay: 2000 })\n ]);\n } else {\n wsStrategy = new BestConnectedEverStrategy([\n ws_loop,\n new DelayedStrategy(wss_loop, { delay: 2000 }),\n new DelayedStrategy(http_loop, { delay: 5000 })\n ]);\n }\n\n return new WebSocketPrioritizedCachedStrategy(\n new FirstConnectedStrategy(\n new IfStrategy(testSupportsStrategy(ws_transport), wsStrategy, http_loop)\n ),\n definedTransports,\n {\n ttl: 1800000,\n timeline: baseOptions.timeline,\n useTLS: baseOptions.useTLS\n }\n );\n};\n\nexport default getDefaultStrategy;\n","import Runtime from 'runtime';\nimport RequestHooks from './request_hooks';\nimport Ajax from './ajax';\nimport { default as EventsDispatcher } from '../events/dispatcher';\n\nconst MAX_BUFFER_LENGTH = 256 * 1024;\n\nexport default class HTTPRequest extends EventsDispatcher {\n hooks: RequestHooks;\n method: string;\n url: string;\n position: number;\n xhr: Ajax;\n unloader: Function;\n\n constructor(hooks: RequestHooks, method: string, url: string) {\n super();\n this.hooks = hooks;\n this.method = method;\n this.url = url;\n }\n\n start(payload?: any) {\n this.position = 0;\n this.xhr = this.hooks.getRequest(this);\n\n this.unloader = () => {\n this.close();\n };\n Runtime.addUnloadListener(this.unloader);\n\n this.xhr.open(this.method, this.url, true);\n\n if (this.xhr.setRequestHeader) {\n this.xhr.setRequestHeader('Content-Type', 'application/json'); // ReactNative doesn't set this header by default.\n }\n this.xhr.send(payload);\n }\n\n close() {\n if (this.unloader) {\n Runtime.removeUnloadListener(this.unloader);\n this.unloader = null;\n }\n if (this.xhr) {\n this.hooks.abortRequest(this.xhr);\n this.xhr = null;\n }\n }\n\n onChunk(status: number, data: any) {\n while (true) {\n var chunk = this.advanceBuffer(data);\n if (chunk) {\n this.emit('chunk', { status: status, data: chunk });\n } else {\n break;\n }\n }\n if (this.isBufferTooLong(data)) {\n this.emit('buffer_too_long');\n }\n }\n\n private advanceBuffer(buffer: any[]): any {\n var unreadData = buffer.slice(this.position);\n var endOfLinePosition = unreadData.indexOf('\\n');\n\n if (endOfLinePosition !== -1) {\n this.position += endOfLinePosition + 1;\n return unreadData.slice(0, endOfLinePosition);\n } else {\n // chunk is not finished yet, don't move the buffer pointer\n return null;\n }\n }\n\n private isBufferTooLong(buffer: any): boolean {\n return this.position === buffer.length && buffer.length > MAX_BUFFER_LENGTH;\n }\n}\n","enum State {\n CONNECTING = 0,\n OPEN = 1,\n CLOSED = 3\n}\n\nexport default State;\n","import URLLocation from './url_location';\nimport State from './state';\nimport Socket from '../socket';\nimport SocketHooks from './socket_hooks';\nimport Util from '../util';\nimport Ajax from './ajax';\nimport HTTPRequest from './http_request';\nimport Runtime from 'runtime';\n\nvar autoIncrement = 1;\n\nclass HTTPSocket implements Socket {\n hooks: SocketHooks;\n session: string;\n location: URLLocation;\n readyState: State;\n stream: HTTPRequest;\n\n onopen: () => void;\n onerror: (error: any) => void;\n onclose: (closeEvent: any) => void;\n onmessage: (message: any) => void;\n onactivity: () => void;\n\n constructor(hooks: SocketHooks, url: string) {\n this.hooks = hooks;\n this.session = randomNumber(1000) + '/' + randomString(8);\n this.location = getLocation(url);\n this.readyState = State.CONNECTING;\n this.openStream();\n }\n\n send(payload: any) {\n return this.sendRaw(JSON.stringify([payload]));\n }\n\n ping() {\n this.hooks.sendHeartbeat(this);\n }\n\n close(code: any, reason: any) {\n this.onClose(code, reason, true);\n }\n\n /** For internal use only */\n sendRaw(payload: any): boolean {\n if (this.readyState === State.OPEN) {\n try {\n Runtime.createSocketRequest(\n 'POST',\n getUniqueURL(getSendURL(this.location, this.session))\n ).start(payload);\n return true;\n } catch (e) {\n return false;\n }\n } else {\n return false;\n }\n }\n\n /** For internal use only */\n reconnect() {\n this.closeStream();\n this.openStream();\n }\n\n /** For internal use only */\n onClose(code, reason, wasClean) {\n this.closeStream();\n this.readyState = State.CLOSED;\n if (this.onclose) {\n this.onclose({\n code: code,\n reason: reason,\n wasClean: wasClean\n });\n }\n }\n\n private onChunk(chunk) {\n if (chunk.status !== 200) {\n return;\n }\n if (this.readyState === State.OPEN) {\n this.onActivity();\n }\n\n var payload;\n var type = chunk.data.slice(0, 1);\n switch (type) {\n case 'o':\n payload = JSON.parse(chunk.data.slice(1) || '{}');\n this.onOpen(payload);\n break;\n case 'a':\n payload = JSON.parse(chunk.data.slice(1) || '[]');\n for (var i = 0; i < payload.length; i++) {\n this.onEvent(payload[i]);\n }\n break;\n case 'm':\n payload = JSON.parse(chunk.data.slice(1) || 'null');\n this.onEvent(payload);\n break;\n case 'h':\n this.hooks.onHeartbeat(this);\n break;\n case 'c':\n payload = JSON.parse(chunk.data.slice(1) || '[]');\n this.onClose(payload[0], payload[1], true);\n break;\n }\n }\n\n private onOpen(options) {\n if (this.readyState === State.CONNECTING) {\n if (options && options.hostname) {\n this.location.base = replaceHost(this.location.base, options.hostname);\n }\n this.readyState = State.OPEN;\n\n if (this.onopen) {\n this.onopen();\n }\n } else {\n this.onClose(1006, 'Server lost session', true);\n }\n }\n\n private onEvent(event) {\n if (this.readyState === State.OPEN && this.onmessage) {\n this.onmessage({ data: event });\n }\n }\n\n private onActivity() {\n if (this.onactivity) {\n this.onactivity();\n }\n }\n\n private onError(error) {\n if (this.onerror) {\n this.onerror(error);\n }\n }\n\n private openStream() {\n this.stream = Runtime.createSocketRequest(\n 'POST',\n getUniqueURL(this.hooks.getReceiveURL(this.location, this.session))\n );\n\n this.stream.bind('chunk', chunk => {\n this.onChunk(chunk);\n });\n this.stream.bind('finished', status => {\n this.hooks.onFinished(this, status);\n });\n this.stream.bind('buffer_too_long', () => {\n this.reconnect();\n });\n\n try {\n this.stream.start();\n } catch (error) {\n Util.defer(() => {\n this.onError(error);\n this.onClose(1006, 'Could not start streaming', false);\n });\n }\n }\n\n private closeStream() {\n if (this.stream) {\n this.stream.unbind_all();\n this.stream.close();\n this.stream = null;\n }\n }\n}\n\nfunction getLocation(url): URLLocation {\n var parts = /([^\\?]*)\\/*(\\??.*)/.exec(url);\n return {\n base: parts[1],\n queryString: parts[2]\n };\n}\n\nfunction getSendURL(url: URLLocation, session: string): string {\n return url.base + '/' + session + '/xhr_send';\n}\n\nfunction getUniqueURL(url: string): string {\n var separator = url.indexOf('?') === -1 ? '?' : '&';\n return url + separator + 't=' + +new Date() + '&n=' + autoIncrement++;\n}\n\nfunction replaceHost(url: string, hostname: string): string {\n var urlParts = /(https?:\\/\\/)([^\\/:]+)((\\/|:)?.*)/.exec(url);\n return urlParts[1] + hostname + urlParts[3];\n}\n\nfunction randomNumber(max: number): number {\n return Runtime.randomInt(max);\n}\n\nfunction randomString(length: number): string {\n var result = [];\n\n for (var i = 0; i < length; i++) {\n result.push(randomNumber(32).toString(32));\n }\n\n return result.join('');\n}\n\nexport default HTTPSocket;\n","import SocketHooks from './socket_hooks';\nimport HTTPSocket from './http_socket';\n\nvar hooks: SocketHooks = {\n getReceiveURL: function(url, session) {\n return url.base + '/' + session + '/xhr_streaming' + url.queryString;\n },\n onHeartbeat: function(socket) {\n socket.sendRaw('[]');\n },\n sendHeartbeat: function(socket) {\n socket.sendRaw('[]');\n },\n onFinished: function(socket, status) {\n socket.onClose(1006, 'Connection interrupted (' + status + ')', false);\n }\n};\n\nexport default hooks;\n","import SocketHooks from './socket_hooks';\nimport URLLocation from './url_location';\nimport HTTPSocket from './http_socket';\n\nvar hooks: SocketHooks = {\n getReceiveURL: function(url: URLLocation, session: string): string {\n return url.base + '/' + session + '/xhr' + url.queryString;\n },\n onHeartbeat: function() {\n // next HTTP request will reset server's activity timer\n },\n sendHeartbeat: function(socket) {\n socket.sendRaw('[]');\n },\n onFinished: function(socket, status) {\n if (status === 200) {\n socket.reconnect();\n } else {\n socket.onClose(1006, 'Connection interrupted (' + status + ')', false);\n }\n }\n};\n\nexport default hooks;\n","import HTTPRequest from 'core/http/http_request';\nimport RequestHooks from 'core/http/request_hooks';\nimport Ajax from 'core/http/ajax';\nimport Runtime from 'runtime';\n\nvar hooks: RequestHooks = {\n getRequest: function(socket: HTTPRequest): Ajax {\n var Constructor = Runtime.getXHRAPI();\n var xhr = new Constructor();\n xhr.onreadystatechange = xhr.onprogress = function() {\n switch (xhr.readyState) {\n case 3:\n if (xhr.responseText && xhr.responseText.length > 0) {\n socket.onChunk(xhr.status, xhr.responseText);\n }\n break;\n case 4:\n // this happens only on errors, never after calling close\n if (xhr.responseText && xhr.responseText.length > 0) {\n socket.onChunk(xhr.status, xhr.responseText);\n }\n socket.emit('finished', xhr.status);\n socket.close();\n break;\n }\n };\n return xhr;\n },\n abortRequest: function(xhr: Ajax) {\n xhr.onreadystatechange = null;\n xhr.abort();\n }\n};\n\nexport default hooks;\n","import * as Collections from 'core/utils/collections';\nimport Transports from 'isomorphic/transports/transports';\nimport TimelineSender from 'core/timeline/timeline_sender';\nimport Ajax from 'core/http/ajax';\nimport getDefaultStrategy from './default_strategy';\nimport TransportsTable from 'core/transports/transports_table';\nimport transportConnectionInitializer from './transports/transport_connection_initializer';\nimport HTTPFactory from './http/http';\n\nvar Isomorphic: any = {\n getDefaultStrategy,\n Transports: Transports,\n transportConnectionInitializer,\n HTTPFactory,\n\n setup(PusherClass): void {\n PusherClass.ready();\n },\n\n getLocalStorage(): any {\n return undefined;\n },\n\n getClientFeatures(): any[] {\n return Collections.keys(\n Collections.filterObject({ ws: Transports.ws }, function(t) {\n return t.isSupported({});\n })\n );\n },\n\n getProtocol(): string {\n return 'http:';\n },\n\n isXHRSupported(): boolean {\n return true;\n },\n\n createSocketRequest(method: string, url: string) {\n if (this.isXHRSupported()) {\n return this.HTTPFactory.createXHR(method, url);\n } else {\n throw 'Cross-origin HTTP requests are not supported';\n }\n },\n\n createXHR(): Ajax {\n var Constructor = this.getXHRAPI();\n return new Constructor();\n },\n\n createWebSocket(url: string): any {\n var Constructor = this.getWebSocketAPI();\n return new Constructor(url);\n },\n\n addUnloadListener(listener: any) {},\n removeUnloadListener(listener: any) {}\n};\n\nexport default Isomorphic;\n","/** Initializes the transport.\n *\n * Fetches resources if needed and then transitions to initialized.\n */\nexport default function() {\n var self = this;\n\n self.timeline.info(\n self.buildTimelineMessage({\n transport: self.name + (self.options.useTLS ? 's' : '')\n })\n );\n\n if (self.hooks.isInitialized()) {\n self.changeState('initialized');\n } else {\n self.onClose();\n }\n}\n","import HTTPRequest from 'core/http/http_request';\nimport HTTPSocket from 'core/http/http_socket';\nimport SocketHooks from 'core/http/socket_hooks';\nimport RequestHooks from 'core/http/request_hooks';\nimport streamingHooks from 'core/http/http_streaming_socket';\nimport pollingHooks from 'core/http/http_polling_socket';\nimport xhrHooks from './http_xhr_request';\nimport HTTPFactory from 'core/http/http_factory';\n\nvar HTTP: HTTPFactory = {\n createStreamingSocket(url: string): HTTPSocket {\n return this.createSocket(streamingHooks, url);\n },\n\n createPollingSocket(url: string): HTTPSocket {\n return this.createSocket(pollingHooks, url);\n },\n\n createSocket(hooks: SocketHooks, url: string): HTTPSocket {\n return new HTTPSocket(hooks, url);\n },\n\n createXHR(method: string, url: string): HTTPRequest {\n return this.createRequest(xhrHooks, method, url);\n },\n\n createRequest(hooks: RequestHooks, method: string, url: string): HTTPRequest {\n return new HTTPRequest(hooks, method, url);\n }\n};\n\nexport default HTTP;\n","import { default as NativeNetInfo } from '@react-native-community/netinfo';\nimport EventsDispatcher from 'core/events/dispatcher';\nimport Util from 'core/util';\nimport Reachability from 'core/reachability';\n\nfunction hasOnlineConnectionState(connectionState): boolean {\n return connectionState.type.toLowerCase() !== 'none';\n}\n\nexport class NetInfo extends EventsDispatcher implements Reachability {\n online: boolean;\n\n constructor() {\n super();\n this.online = true;\n\n NativeNetInfo.fetch().then(connectionState => {\n this.online = hasOnlineConnectionState(connectionState);\n });\n\n NativeNetInfo.addEventListener(connectionState => {\n var isNowOnline = hasOnlineConnectionState(connectionState);\n\n // React Native counts the switch from Wi-Fi to Cellular\n // as a state change. Return if current and previous states\n // are both online/offline\n if (this.online === isNowOnline) return;\n this.online = isNowOnline;\n if (this.online) {\n this.emit('online');\n } else {\n this.emit('offline');\n }\n });\n }\n\n isOnline(): boolean {\n return this.online;\n }\n}\n\nexport var Network = new NetInfo();\n","export enum AuthRequestType {\n UserAuthentication = 'user-authentication',\n ChannelAuthorization = 'channel-authorization'\n}\n\nexport interface ChannelAuthorizationData {\n auth: string;\n channel_data?: string;\n shared_secret?: string;\n}\n\nexport type ChannelAuthorizationCallback = (\n error: Error | null,\n authData: ChannelAuthorizationData | null\n) => void;\n\nexport interface ChannelAuthorizationRequestParams {\n socketId: string;\n channelName: string;\n}\n\nexport interface ChannelAuthorizationHandler {\n (\n params: ChannelAuthorizationRequestParams,\n callback: ChannelAuthorizationCallback\n ): void;\n}\n\nexport interface UserAuthenticationData {\n auth: string;\n user_data: string;\n}\n\nexport type UserAuthenticationCallback = (\n error: Error | null,\n authData: UserAuthenticationData | null\n) => void;\n\nexport interface UserAuthenticationRequestParams {\n socketId: string;\n}\n\nexport interface UserAuthenticationHandler {\n (\n params: UserAuthenticationRequestParams,\n callback: UserAuthenticationCallback\n ): void;\n}\n\nexport type AuthTransportCallback =\n | ChannelAuthorizationCallback\n | UserAuthenticationCallback;\n\nexport interface AuthOptionsT {\n transport: 'ajax' | 'jsonp';\n endpoint: string;\n params?: any;\n headers?: any;\n paramsProvider?: () => any;\n headersProvider?: () => any;\n customHandler?: AuthHandler;\n}\n\nexport declare type UserAuthenticationOptions = AuthOptionsT<\n UserAuthenticationHandler\n>;\nexport declare type ChannelAuthorizationOptions = AuthOptionsT<\n ChannelAuthorizationHandler\n>;\n\nexport interface InternalAuthOptions {\n transport: 'ajax' | 'jsonp';\n endpoint: string;\n params?: any;\n headers?: any;\n paramsProvider?: () => any;\n headersProvider?: () => any;\n}\n","import TimelineSender from 'core/timeline/timeline_sender';\nimport * as Collections from 'core/utils/collections';\nimport Util from 'core/util';\nimport Runtime from 'runtime';\nimport { AuthTransport } from 'core/auth/auth_transports';\nimport AbstractRuntime from 'runtimes/interface';\nimport UrlStore from 'core/utils/url_store';\nimport {\n AuthRequestType,\n AuthTransportCallback,\n InternalAuthOptions\n} from 'core/auth/options';\nimport { HTTPAuthError } from 'core/errors';\n\nconst ajax: AuthTransport = function(\n context: AbstractRuntime,\n query: string,\n authOptions: InternalAuthOptions,\n authRequestType: AuthRequestType,\n callback: AuthTransportCallback\n) {\n const xhr = Runtime.createXHR();\n xhr.open('POST', authOptions.endpoint, true);\n\n // add request headers\n xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');\n for (var headerName in authOptions.headers) {\n xhr.setRequestHeader(headerName, authOptions.headers[headerName]);\n }\n if (authOptions.headersProvider != null) {\n let dynamicHeaders = authOptions.headersProvider();\n for (var headerName in dynamicHeaders) {\n xhr.setRequestHeader(headerName, dynamicHeaders[headerName]);\n }\n }\n\n xhr.onreadystatechange = function() {\n if (xhr.readyState === 4) {\n if (xhr.status === 200) {\n let data;\n let parsed = false;\n\n try {\n data = JSON.parse(xhr.responseText);\n parsed = true;\n } catch (e) {\n callback(\n new HTTPAuthError(\n 200,\n `JSON returned from ${authRequestType.toString()} endpoint was invalid, yet status code was 200. Data was: ${\n xhr.responseText\n }`\n ),\n null\n );\n }\n\n if (parsed) {\n // prevents double execution.\n callback(null, data);\n }\n } else {\n let suffix = '';\n switch (authRequestType) {\n case AuthRequestType.UserAuthentication:\n suffix = UrlStore.buildLogSuffix('authenticationEndpoint');\n break;\n case AuthRequestType.ChannelAuthorization:\n suffix = `Clients must be authorized to join private or presence channels. ${UrlStore.buildLogSuffix(\n 'authorizationEndpoint'\n )}`;\n break;\n }\n callback(\n new HTTPAuthError(\n xhr.status,\n `Unable to retrieve auth string from ${authRequestType.toString()} endpoint - ` +\n `received status: ${xhr.status} from ${authOptions.endpoint}. ${suffix}`\n ),\n null\n );\n }\n }\n };\n\n xhr.send(query);\n return xhr;\n};\n\nexport default ajax;\n","import Logger from 'core/logger';\nimport TimelineSender from 'core/timeline/timeline_sender';\nimport * as Collections from 'core/utils/collections';\nimport Util from 'core/util';\nimport Runtime from 'runtime';\nimport TimelineTransport from 'core/timeline/timeline_transport';\n\nvar getAgent = function(sender: TimelineSender, useTLS: boolean) {\n return function(data: any, callback: Function) {\n var scheme = 'http' + (useTLS ? 's' : '') + '://';\n var url =\n scheme + (sender.host || sender.options.host) + sender.options.path;\n var query = Collections.buildQueryString(data);\n\n url += '/' + 2 + '?' + query;\n\n var xhr = Runtime.createXHR();\n xhr.open('GET', url, true);\n\n xhr.onreadystatechange = function() {\n if (xhr.readyState === 4) {\n let { status, responseText } = xhr;\n if (status !== 200) {\n Logger.debug(\n `TimelineSender Error: received ${status} from stats.pusher.com`\n );\n return;\n }\n\n try {\n var { host } = JSON.parse(responseText);\n } catch (e) {\n Logger.debug(`TimelineSenderError: invalid response ${responseText}`);\n }\n if (host) {\n sender.host = host;\n }\n }\n };\n\n xhr.send();\n };\n};\n\nvar xhr = {\n name: 'xhr',\n getAgent\n};\n\nexport default xhr;\n","import Isomorphic from 'isomorphic/runtime';\nimport Runtime from '../interface';\nimport { Network } from './net_info';\nimport xhrAuth from 'isomorphic/auth/xhr_auth';\nimport { AuthTransports } from 'core/auth/auth_transports';\nimport xhrTimeline from 'isomorphic/timeline/xhr_timeline';\n\n// Very verbose but until unavoidable until\n// TypeScript 2.1, when spread attributes will be\n// supported\nconst {\n getDefaultStrategy,\n Transports,\n setup,\n getProtocol,\n isXHRSupported,\n getLocalStorage,\n createXHR,\n createWebSocket,\n addUnloadListener,\n removeUnloadListener,\n transportConnectionInitializer,\n createSocketRequest,\n HTTPFactory\n} = Isomorphic;\n\nconst ReactNative: Runtime = {\n getDefaultStrategy,\n Transports,\n setup,\n getProtocol,\n isXHRSupported,\n getLocalStorage,\n createXHR,\n createWebSocket,\n addUnloadListener,\n removeUnloadListener,\n transportConnectionInitializer,\n createSocketRequest,\n HTTPFactory,\n\n TimelineTransport: xhrTimeline,\n\n getAuthorizers(): AuthTransports {\n return { ajax: xhrAuth };\n },\n\n getWebSocketAPI() {\n return WebSocket;\n },\n\n getXHRAPI() {\n return XMLHttpRequest;\n },\n\n getNetwork() {\n return Network;\n },\n\n randomInt(max: number): number {\n return Math.floor(Math.random() * max);\n }\n};\n\nexport default ReactNative;\n","enum TimelineLevel {\n ERROR = 3,\n INFO = 6,\n DEBUG = 7\n}\n\nexport default TimelineLevel;\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport { default as Level } from './level';\n\nexport interface TimelineOptions {\n level?: Level;\n limit?: number;\n version?: string;\n cluster?: string;\n features?: string[];\n params?: any;\n}\n\nexport default class Timeline {\n key: string;\n session: number;\n events: any[];\n options: TimelineOptions;\n sent: number;\n uniqueID: number;\n\n constructor(key: string, session: number, options: TimelineOptions) {\n this.key = key;\n this.session = session;\n this.events = [];\n this.options = options || {};\n this.sent = 0;\n this.uniqueID = 0;\n }\n\n log(level, event) {\n if (level <= this.options.level) {\n this.events.push(\n Collections.extend({}, event, { timestamp: Util.now() })\n );\n if (this.options.limit && this.events.length > this.options.limit) {\n this.events.shift();\n }\n }\n }\n\n error(event) {\n this.log(Level.ERROR, event);\n }\n\n info(event) {\n this.log(Level.INFO, event);\n }\n\n debug(event) {\n this.log(Level.DEBUG, event);\n }\n\n isEmpty() {\n return this.events.length === 0;\n }\n\n send(sendfn, callback) {\n var data = Collections.extend(\n {\n session: this.session,\n bundle: this.sent + 1,\n key: this.key,\n lib: 'js',\n version: this.options.version,\n cluster: this.options.cluster,\n features: this.options.features,\n timeline: this.events\n },\n this.options.params\n );\n\n this.events = [];\n sendfn(data, (error, result) => {\n if (!error) {\n this.sent++;\n }\n if (callback) {\n callback(error, result);\n }\n });\n\n return true;\n }\n\n generateUniqueID(): number {\n this.uniqueID++;\n return this.uniqueID;\n }\n}\n","import Factory from '../utils/factory';\nimport Util from '../util';\nimport * as Errors from '../errors';\nimport * as Collections from '../utils/collections';\nimport Strategy from './strategy';\nimport Transport from '../transports/transport';\nimport StrategyOptions from './strategy_options';\nimport Handshake from '../connection/handshake';\n\n/** Provides a strategy interface for transports.\n *\n * @param {String} name\n * @param {Number} priority\n * @param {Class} transport\n * @param {Object} options\n */\nexport default class TransportStrategy implements Strategy {\n name: string;\n priority: number;\n transport: Transport;\n options: StrategyOptions;\n\n constructor(\n name: string,\n priority: number,\n transport: Transport,\n options: StrategyOptions\n ) {\n this.name = name;\n this.priority = priority;\n this.transport = transport;\n this.options = options || {};\n }\n\n /** Returns whether the transport is supported in the browser.\n *\n * @returns {Boolean}\n */\n isSupported(): boolean {\n return this.transport.isSupported({\n useTLS: this.options.useTLS\n });\n }\n\n /** Launches a connection attempt and returns a strategy runner.\n *\n * @param {Function} callback\n * @return {Object} strategy runner\n */\n connect(minPriority: number, callback: Function) {\n if (!this.isSupported()) {\n return failAttempt(new Errors.UnsupportedStrategy(), callback);\n } else if (this.priority < minPriority) {\n return failAttempt(new Errors.TransportPriorityTooLow(), callback);\n }\n\n var connected = false;\n var transport = this.transport.createConnection(\n this.name,\n this.priority,\n this.options.key,\n this.options\n );\n var handshake = null;\n\n var onInitialized = function() {\n transport.unbind('initialized', onInitialized);\n transport.connect();\n };\n var onOpen = function() {\n handshake = Factory.createHandshake(transport, function(result) {\n connected = true;\n unbindListeners();\n callback(null, result);\n });\n };\n var onError = function(error) {\n unbindListeners();\n callback(error);\n };\n var onClosed = function() {\n unbindListeners();\n var serializedTransport;\n\n // The reason for this try/catch block is that on React Native\n // the WebSocket object is circular. Therefore transport.socket will\n // throw errors upon stringification. Collections.safeJSONStringify\n // discards circular references when serializing.\n serializedTransport = Collections.safeJSONStringify(transport);\n callback(new Errors.TransportClosed(serializedTransport));\n };\n\n var unbindListeners = function() {\n transport.unbind('initialized', onInitialized);\n transport.unbind('open', onOpen);\n transport.unbind('error', onError);\n transport.unbind('closed', onClosed);\n };\n\n transport.bind('initialized', onInitialized);\n transport.bind('open', onOpen);\n transport.bind('error', onError);\n transport.bind('closed', onClosed);\n\n // connect will be called automatically after initialization\n transport.initialize();\n\n return {\n abort: () => {\n if (connected) {\n return;\n }\n unbindListeners();\n if (handshake) {\n handshake.close();\n } else {\n transport.close();\n }\n },\n forceMinPriority: p => {\n if (connected) {\n return;\n }\n if (this.priority < p) {\n if (handshake) {\n handshake.close();\n } else {\n transport.close();\n }\n }\n }\n };\n }\n}\n\nfunction failAttempt(error: Error, callback: Function) {\n Util.defer(function() {\n callback(error);\n });\n return {\n abort: function() {},\n forceMinPriority: function() {}\n };\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport TransportManager from '../transports/transport_manager';\nimport * as Errors from '../errors';\nimport Strategy from './strategy';\nimport TransportStrategy from './transport_strategy';\nimport StrategyOptions from '../strategies/strategy_options';\nimport { Config } from '../config';\nimport Runtime from 'runtime';\n\nconst { Transports } = Runtime;\n\nexport var defineTransport = function(\n config: Config,\n name: string,\n type: string,\n priority: number,\n options: StrategyOptions,\n manager?: TransportManager\n): Strategy {\n var transportClass = Transports[type];\n if (!transportClass) {\n throw new Errors.UnsupportedTransport(type);\n }\n\n var enabled =\n (!config.enabledTransports ||\n Collections.arrayIndexOf(config.enabledTransports, name) !== -1) &&\n (!config.disabledTransports ||\n Collections.arrayIndexOf(config.disabledTransports, name) === -1);\n\n var transport;\n if (enabled) {\n options = Object.assign(\n { ignoreNullOrigin: config.ignoreNullOrigin },\n options\n );\n\n transport = new TransportStrategy(\n name,\n priority,\n manager ? manager.getAssistant(transportClass) : transportClass,\n options\n );\n } else {\n transport = UnsupportedStrategy;\n }\n\n return transport;\n};\n\nvar UnsupportedStrategy: Strategy = {\n isSupported: function() {\n return false;\n },\n connect: function(_, callback) {\n var deferred = Util.defer(function() {\n callback(new Errors.UnsupportedStrategy());\n });\n return {\n abort: function() {\n deferred.ensureAborted();\n },\n forceMinPriority: function() {}\n };\n }\n};\n","import {\n UserAuthenticationCallback,\n InternalAuthOptions,\n UserAuthenticationHandler,\n UserAuthenticationRequestParams,\n AuthRequestType\n} from './options';\n\nimport Runtime from 'runtime';\n\nconst composeChannelQuery = (\n params: UserAuthenticationRequestParams,\n authOptions: InternalAuthOptions\n) => {\n var query = 'socket_id=' + encodeURIComponent(params.socketId);\n\n for (var key in authOptions.params) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(authOptions.params[key]);\n }\n\n if (authOptions.paramsProvider != null) {\n let dynamicParams = authOptions.paramsProvider();\n for (var key in dynamicParams) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(dynamicParams[key]);\n }\n }\n\n return query;\n};\n\nconst UserAuthenticator = (\n authOptions: InternalAuthOptions\n): UserAuthenticationHandler => {\n if (typeof Runtime.getAuthorizers()[authOptions.transport] === 'undefined') {\n throw `'${authOptions.transport}' is not a recognized auth transport`;\n }\n\n return (\n params: UserAuthenticationRequestParams,\n callback: UserAuthenticationCallback\n ) => {\n const query = composeChannelQuery(params, authOptions);\n\n Runtime.getAuthorizers()[authOptions.transport](\n Runtime,\n query,\n authOptions,\n AuthRequestType.UserAuthentication,\n callback\n );\n };\n};\n\nexport default UserAuthenticator;\n","import {\n AuthRequestType,\n InternalAuthOptions,\n ChannelAuthorizationHandler,\n ChannelAuthorizationRequestParams,\n ChannelAuthorizationCallback\n} from './options';\n\nimport Runtime from 'runtime';\n\nconst composeChannelQuery = (\n params: ChannelAuthorizationRequestParams,\n authOptions: InternalAuthOptions\n) => {\n var query = 'socket_id=' + encodeURIComponent(params.socketId);\n\n query += '&channel_name=' + encodeURIComponent(params.channelName);\n\n for (var key in authOptions.params) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(authOptions.params[key]);\n }\n\n if (authOptions.paramsProvider != null) {\n let dynamicParams = authOptions.paramsProvider();\n for (var key in dynamicParams) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(dynamicParams[key]);\n }\n }\n\n return query;\n};\n\nconst ChannelAuthorizer = (\n authOptions: InternalAuthOptions\n): ChannelAuthorizationHandler => {\n if (typeof Runtime.getAuthorizers()[authOptions.transport] === 'undefined') {\n throw `'${authOptions.transport}' is not a recognized auth transport`;\n }\n\n return (\n params: ChannelAuthorizationRequestParams,\n callback: ChannelAuthorizationCallback\n ) => {\n const query = composeChannelQuery(params, authOptions);\n\n Runtime.getAuthorizers()[authOptions.transport](\n Runtime,\n query,\n authOptions,\n AuthRequestType.ChannelAuthorization,\n callback\n );\n };\n};\n\nexport default ChannelAuthorizer;\n","import { Options } from './options';\nimport Defaults from './defaults';\nimport {\n ChannelAuthorizationHandler,\n UserAuthenticationHandler,\n ChannelAuthorizationOptions\n} from './auth/options';\nimport UserAuthenticator from './auth/user_authenticator';\nimport ChannelAuthorizer from './auth/channel_authorizer';\nimport { ChannelAuthorizerProxy } from './auth/deprecated_channel_authorizer';\nimport Runtime from 'runtime';\nimport * as nacl from 'tweetnacl';\n\nexport type AuthTransport = 'ajax' | 'jsonp';\nexport type Transport =\n | 'ws'\n | 'wss'\n | 'xhr_streaming'\n | 'xhr_polling'\n | 'sockjs';\n\nexport interface Config {\n // these are all 'required' config parameters, it's not necessary for the user\n // to set them, but they have configured defaults.\n activityTimeout: number;\n enableStats: boolean;\n httpHost: string;\n httpPath: string;\n httpPort: number;\n httpsPort: number;\n pongTimeout: number;\n statsHost: string;\n unavailableTimeout: number;\n useTLS: boolean;\n wsHost: string;\n wsPath: string;\n wsPort: number;\n wssPort: number;\n userAuthenticator: UserAuthenticationHandler;\n channelAuthorizer: ChannelAuthorizationHandler;\n\n // these are all optional parameters or overrrides. The customer can set these\n // but it's not strictly necessary\n forceTLS?: boolean;\n cluster?: string;\n disabledTransports?: Transport[];\n enabledTransports?: Transport[];\n ignoreNullOrigin?: boolean;\n nacl?: nacl;\n timelineParams?: any;\n}\n\n// getConfig mainly sets the defaults for the options that are not provided\nexport function getConfig(opts: Options, pusher): Config {\n let config: Config = {\n activityTimeout: opts.activityTimeout || Defaults.activityTimeout,\n cluster: opts.cluster,\n httpPath: opts.httpPath || Defaults.httpPath,\n httpPort: opts.httpPort || Defaults.httpPort,\n httpsPort: opts.httpsPort || Defaults.httpsPort,\n pongTimeout: opts.pongTimeout || Defaults.pongTimeout,\n statsHost: opts.statsHost || Defaults.stats_host,\n unavailableTimeout: opts.unavailableTimeout || Defaults.unavailableTimeout,\n wsPath: opts.wsPath || Defaults.wsPath,\n wsPort: opts.wsPort || Defaults.wsPort,\n wssPort: opts.wssPort || Defaults.wssPort,\n\n enableStats: getEnableStatsConfig(opts),\n httpHost: getHttpHost(opts),\n useTLS: shouldUseTLS(opts),\n wsHost: getWebsocketHost(opts),\n\n userAuthenticator: buildUserAuthenticator(opts),\n channelAuthorizer: buildChannelAuthorizer(opts, pusher)\n };\n\n if ('disabledTransports' in opts)\n config.disabledTransports = opts.disabledTransports;\n if ('enabledTransports' in opts)\n config.enabledTransports = opts.enabledTransports;\n if ('ignoreNullOrigin' in opts)\n config.ignoreNullOrigin = opts.ignoreNullOrigin;\n if ('timelineParams' in opts) config.timelineParams = opts.timelineParams;\n if ('nacl' in opts) {\n config.nacl = opts.nacl;\n }\n\n return config;\n}\n\nfunction getHttpHost(opts: Options): string {\n if (opts.httpHost) {\n return opts.httpHost;\n }\n if (opts.cluster) {\n return `sockjs-${opts.cluster}.pusher.com`;\n }\n return Defaults.httpHost;\n}\n\nfunction getWebsocketHost(opts: Options): string {\n if (opts.wsHost) {\n return opts.wsHost;\n }\n return getWebsocketHostFromCluster(opts.cluster);\n}\n\nfunction getWebsocketHostFromCluster(cluster: string): string {\n return `ws-${cluster}.pusher.com`;\n}\n\nfunction shouldUseTLS(opts: Options): boolean {\n if (Runtime.getProtocol() === 'https:') {\n return true;\n } else if (opts.forceTLS === false) {\n return false;\n }\n return true;\n}\n\n// if enableStats is set take the value\n// if disableStats is set take the inverse\n// otherwise default to false\nfunction getEnableStatsConfig(opts: Options): boolean {\n if ('enableStats' in opts) {\n return opts.enableStats;\n }\n if ('disableStats' in opts) {\n return !opts.disableStats;\n }\n return false;\n}\n\nfunction buildUserAuthenticator(opts: Options): UserAuthenticationHandler {\n const userAuthentication = {\n ...Defaults.userAuthentication,\n ...opts.userAuthentication\n };\n if (\n 'customHandler' in userAuthentication &&\n userAuthentication['customHandler'] != null\n ) {\n return userAuthentication['customHandler'];\n }\n\n return UserAuthenticator(userAuthentication);\n}\n\nfunction buildChannelAuth(opts: Options, pusher): ChannelAuthorizationOptions {\n let channelAuthorization: ChannelAuthorizationOptions;\n if ('channelAuthorization' in opts) {\n channelAuthorization = {\n ...Defaults.channelAuthorization,\n ...opts.channelAuthorization\n };\n } else {\n channelAuthorization = {\n transport: opts.authTransport || Defaults.authTransport,\n endpoint: opts.authEndpoint || Defaults.authEndpoint\n };\n if ('auth' in opts) {\n if ('params' in opts.auth) channelAuthorization.params = opts.auth.params;\n if ('headers' in opts.auth)\n channelAuthorization.headers = opts.auth.headers;\n }\n if ('authorizer' in opts)\n channelAuthorization.customHandler = ChannelAuthorizerProxy(\n pusher,\n channelAuthorization,\n opts.authorizer\n );\n }\n return channelAuthorization;\n}\n\nfunction buildChannelAuthorizer(\n opts: Options,\n pusher\n): ChannelAuthorizationHandler {\n const channelAuthorization = buildChannelAuth(opts, pusher);\n if (\n 'customHandler' in channelAuthorization &&\n channelAuthorization['customHandler'] != null\n ) {\n return channelAuthorization['customHandler'];\n }\n\n return ChannelAuthorizer(channelAuthorization);\n}\n","import Channel from '../channels/channel';\nimport {\n ChannelAuthorizationCallback,\n ChannelAuthorizationHandler,\n ChannelAuthorizationRequestParams,\n InternalAuthOptions\n} from './options';\n\nexport interface DeprecatedChannelAuthorizer {\n authorize(socketId: string, callback: ChannelAuthorizationCallback): void;\n}\n\nexport interface ChannelAuthorizerGenerator {\n (\n channel: Channel,\n options: DeprecatedAuthorizerOptions\n ): DeprecatedChannelAuthorizer;\n}\n\nexport interface DeprecatedAuthOptions {\n params?: any;\n headers?: any;\n}\n\nexport interface DeprecatedAuthorizerOptions {\n authTransport: 'ajax' | 'jsonp';\n authEndpoint: string;\n auth?: DeprecatedAuthOptions;\n}\n\nexport const ChannelAuthorizerProxy = (\n pusher,\n authOptions: InternalAuthOptions,\n channelAuthorizerGenerator: ChannelAuthorizerGenerator\n): ChannelAuthorizationHandler => {\n const deprecatedAuthorizerOptions: DeprecatedAuthorizerOptions = {\n authTransport: authOptions.transport,\n authEndpoint: authOptions.endpoint,\n auth: {\n params: authOptions.params,\n headers: authOptions.headers\n }\n };\n return (\n params: ChannelAuthorizationRequestParams,\n callback: ChannelAuthorizationCallback\n ) => {\n const channel = pusher.channel(params.channelName);\n // This line creates a new channel authorizer every time.\n // In the past, this was only done once per channel and reused.\n // We can do that again if we want to keep this behavior intact.\n const channelAuthorizer: DeprecatedChannelAuthorizer = channelAuthorizerGenerator(\n channel,\n deprecatedAuthorizerOptions\n );\n channelAuthorizer.authorize(params.socketId, callback);\n };\n};\n","import Logger from './logger';\nimport Pusher from './pusher';\nimport EventsDispatcher from './events/dispatcher';\n\nexport default class WatchlistFacade extends EventsDispatcher {\n private pusher: Pusher;\n\n public constructor(pusher: Pusher) {\n super(function(eventName, data) {\n Logger.debug(`No callbacks on watchlist events for ${eventName}`);\n });\n\n this.pusher = pusher;\n this.bindWatchlistInternalEvent();\n }\n\n handleEvent(pusherEvent) {\n pusherEvent.data.events.forEach(watchlistEvent => {\n this.emit(watchlistEvent.name, watchlistEvent);\n });\n }\n\n private bindWatchlistInternalEvent() {\n this.pusher.connection.bind('message', pusherEvent => {\n var eventName = pusherEvent.event;\n if (eventName === 'pusher_internal:watchlist_events') {\n this.handleEvent(pusherEvent);\n }\n });\n }\n}\n","function flatPromise() {\n let resolve, reject;\n const promise = new Promise((res, rej) => {\n resolve = res;\n reject = rej;\n });\n return { promise, resolve, reject };\n}\n\nexport default flatPromise;\n","import Pusher from './pusher';\nimport Logger from './logger';\nimport {\n UserAuthenticationData,\n UserAuthenticationCallback\n} from './auth/options';\nimport Channel from './channels/channel';\nimport WatchlistFacade from './watchlist';\nimport EventsDispatcher from './events/dispatcher';\nimport flatPromise from './utils/flat_promise';\n\nexport default class UserFacade extends EventsDispatcher {\n pusher: Pusher;\n signin_requested: boolean = false;\n user_data: any = null;\n serverToUserChannel: Channel = null;\n signinDonePromise: Promise = null;\n watchlist: WatchlistFacade;\n private _signinDoneResolve: Function = null;\n\n public constructor(pusher: Pusher) {\n super(function(eventName, data) {\n Logger.debug('No callbacks on user for ' + eventName);\n });\n this.pusher = pusher;\n this.pusher.connection.bind('state_change', ({ previous, current }) => {\n if (previous !== 'connected' && current === 'connected') {\n this._signin();\n }\n if (previous === 'connected' && current !== 'connected') {\n this._cleanup();\n this._newSigninPromiseIfNeeded();\n }\n });\n\n this.watchlist = new WatchlistFacade(pusher);\n\n this.pusher.connection.bind('message', event => {\n var eventName = event.event;\n if (eventName === 'pusher:signin_success') {\n this._onSigninSuccess(event.data);\n }\n if (\n this.serverToUserChannel &&\n this.serverToUserChannel.name === event.channel\n ) {\n this.serverToUserChannel.handleEvent(event);\n }\n });\n }\n\n public signin() {\n if (this.signin_requested) {\n return;\n }\n\n this.signin_requested = true;\n this._signin();\n }\n\n private _signin() {\n if (!this.signin_requested) {\n return;\n }\n\n this._newSigninPromiseIfNeeded();\n\n if (this.pusher.connection.state !== 'connected') {\n // Signin will be attempted when the connection is connected\n return;\n }\n\n this.pusher.config.userAuthenticator(\n {\n socketId: this.pusher.connection.socket_id\n },\n this._onAuthorize\n );\n }\n\n private _onAuthorize: UserAuthenticationCallback = (\n err,\n authData: UserAuthenticationData\n ) => {\n if (err) {\n Logger.warn(`Error during signin: ${err}`);\n this._cleanup();\n return;\n }\n\n this.pusher.send_event('pusher:signin', {\n auth: authData.auth,\n user_data: authData.user_data\n });\n\n // Later when we get pusher:singin_success event, the user will be marked as signed in\n };\n\n private _onSigninSuccess(data: any) {\n try {\n this.user_data = JSON.parse(data.user_data);\n } catch (e) {\n Logger.error(`Failed parsing user data after signin: ${data.user_data}`);\n this._cleanup();\n return;\n }\n\n if (typeof this.user_data.id !== 'string' || this.user_data.id === '') {\n Logger.error(\n `user_data doesn't contain an id. user_data: ${this.user_data}`\n );\n this._cleanup();\n return;\n }\n\n // Signin succeeded\n this._signinDoneResolve();\n this._subscribeChannels();\n }\n\n private _subscribeChannels() {\n const ensure_subscribed = channel => {\n if (channel.subscriptionPending && channel.subscriptionCancelled) {\n channel.reinstateSubscription();\n } else if (\n !channel.subscriptionPending &&\n this.pusher.connection.state === 'connected'\n ) {\n channel.subscribe();\n }\n };\n\n this.serverToUserChannel = new Channel(\n `#server-to-user-${this.user_data.id}`,\n this.pusher\n );\n this.serverToUserChannel.bind_global((eventName, data) => {\n if (\n eventName.indexOf('pusher_internal:') === 0 ||\n eventName.indexOf('pusher:') === 0\n ) {\n // ignore internal events\n return;\n }\n this.emit(eventName, data);\n });\n ensure_subscribed(this.serverToUserChannel);\n }\n\n private _cleanup() {\n this.user_data = null;\n if (this.serverToUserChannel) {\n this.serverToUserChannel.unbind_all();\n this.serverToUserChannel.disconnect();\n this.serverToUserChannel = null;\n }\n\n if (this.signin_requested) {\n // If signin is in progress and cleanup is called,\n // Mark the current signin process as done.\n this._signinDoneResolve();\n }\n }\n\n private _newSigninPromiseIfNeeded() {\n if (!this.signin_requested) {\n return;\n }\n\n // If there is a promise and it is not resolved, return without creating a new one.\n if (this.signinDonePromise && !(this.signinDonePromise as any).done) {\n return;\n }\n\n // This promise is never rejected.\n // It gets resolved when the signin process is done whether it failed or succeeded\n const { promise, resolve, reject: _ } = flatPromise();\n (promise as any).done = false;\n const setDone = () => {\n (promise as any).done = true;\n };\n promise.then(setDone).catch(setDone);\n this.signinDonePromise = promise;\n this._signinDoneResolve = resolve;\n }\n}\n","import AbstractRuntime from '../runtimes/interface';\nimport Runtime from 'runtime';\nimport Util from './util';\nimport * as Collections from './utils/collections';\nimport Channels from './channels/channels';\nimport Channel from './channels/channel';\nimport { default as EventsDispatcher } from './events/dispatcher';\nimport Timeline from './timeline/timeline';\nimport TimelineSender from './timeline/timeline_sender';\nimport TimelineLevel from './timeline/level';\nimport { defineTransport } from './strategies/strategy_builder';\nimport ConnectionManager from './connection/connection_manager';\nimport ConnectionManagerOptions from './connection/connection_manager_options';\nimport { PeriodicTimer } from './utils/timers';\nimport Defaults from './defaults';\nimport * as DefaultConfig from './config';\nimport Logger from './logger';\nimport Factory from './utils/factory';\nimport UrlStore from 'core/utils/url_store';\nimport { Options, validateOptions } from './options';\nimport { Config, getConfig } from './config';\nimport StrategyOptions from './strategies/strategy_options';\nimport UserFacade from './user';\n\nexport default class Pusher {\n /* STATIC PROPERTIES */\n static instances: Pusher[] = [];\n static isReady: boolean = false;\n static logToConsole: boolean = false;\n\n // for jsonp\n static Runtime: AbstractRuntime = Runtime;\n static ScriptReceivers: any = (Runtime).ScriptReceivers;\n static DependenciesReceivers: any = (Runtime).DependenciesReceivers;\n static auth_callbacks: any = (Runtime).auth_callbacks;\n\n static ready() {\n Pusher.isReady = true;\n for (var i = 0, l = Pusher.instances.length; i < l; i++) {\n Pusher.instances[i].connect();\n }\n }\n\n static log: (message: any) => void;\n\n private static getClientFeatures(): string[] {\n return Collections.keys(\n Collections.filterObject({ ws: Runtime.Transports.ws }, function(t) {\n return t.isSupported({});\n })\n );\n }\n\n /* INSTANCE PROPERTIES */\n key: string;\n config: Config;\n channels: Channels;\n global_emitter: EventsDispatcher;\n sessionID: number;\n timeline: Timeline;\n timelineSender: TimelineSender;\n connection: ConnectionManager;\n timelineSenderTimer: PeriodicTimer;\n user: UserFacade;\n constructor(app_key: string, options: Options) {\n checkAppKey(app_key);\n validateOptions(options);\n this.key = app_key;\n this.config = getConfig(options, this);\n\n this.channels = Factory.createChannels();\n this.global_emitter = new EventsDispatcher();\n this.sessionID = Runtime.randomInt(1000000000);\n\n this.timeline = new Timeline(this.key, this.sessionID, {\n cluster: this.config.cluster,\n features: Pusher.getClientFeatures(),\n params: this.config.timelineParams || {},\n limit: 50,\n level: TimelineLevel.INFO,\n version: Defaults.VERSION\n });\n if (this.config.enableStats) {\n this.timelineSender = Factory.createTimelineSender(this.timeline, {\n host: this.config.statsHost,\n path: '/timeline/v2/' + Runtime.TimelineTransport.name\n });\n }\n\n var getStrategy = (options: StrategyOptions) => {\n return Runtime.getDefaultStrategy(this.config, options, defineTransport);\n };\n\n this.connection = Factory.createConnectionManager(this.key, {\n getStrategy: getStrategy,\n timeline: this.timeline,\n activityTimeout: this.config.activityTimeout,\n pongTimeout: this.config.pongTimeout,\n unavailableTimeout: this.config.unavailableTimeout,\n useTLS: Boolean(this.config.useTLS)\n });\n\n this.connection.bind('connected', () => {\n this.subscribeAll();\n if (this.timelineSender) {\n this.timelineSender.send(this.connection.isUsingTLS());\n }\n });\n\n this.connection.bind('message', event => {\n var eventName = event.event;\n var internal = eventName.indexOf('pusher_internal:') === 0;\n if (event.channel) {\n var channel = this.channel(event.channel);\n if (channel) {\n channel.handleEvent(event);\n }\n }\n // Emit globally [deprecated]\n if (!internal) {\n this.global_emitter.emit(event.event, event.data);\n }\n });\n this.connection.bind('connecting', () => {\n this.channels.disconnect();\n });\n this.connection.bind('disconnected', () => {\n this.channels.disconnect();\n });\n this.connection.bind('error', err => {\n Logger.warn(err);\n });\n\n Pusher.instances.push(this);\n this.timeline.info({ instances: Pusher.instances.length });\n\n this.user = new UserFacade(this);\n\n if (Pusher.isReady) {\n this.connect();\n }\n }\n\n channel(name: string): Channel {\n return this.channels.find(name);\n }\n\n allChannels(): Channel[] {\n return this.channels.all();\n }\n\n connect() {\n this.connection.connect();\n\n if (this.timelineSender) {\n if (!this.timelineSenderTimer) {\n var usingTLS = this.connection.isUsingTLS();\n var timelineSender = this.timelineSender;\n this.timelineSenderTimer = new PeriodicTimer(60000, function() {\n timelineSender.send(usingTLS);\n });\n }\n }\n }\n\n disconnect() {\n this.connection.disconnect();\n\n if (this.timelineSenderTimer) {\n this.timelineSenderTimer.ensureAborted();\n this.timelineSenderTimer = null;\n }\n }\n\n bind(event_name: string, callback: Function, context?: any): Pusher {\n this.global_emitter.bind(event_name, callback, context);\n return this;\n }\n\n unbind(event_name?: string, callback?: Function, context?: any): Pusher {\n this.global_emitter.unbind(event_name, callback, context);\n return this;\n }\n\n bind_global(callback: Function): Pusher {\n this.global_emitter.bind_global(callback);\n return this;\n }\n\n unbind_global(callback?: Function): Pusher {\n this.global_emitter.unbind_global(callback);\n return this;\n }\n\n unbind_all(callback?: Function): Pusher {\n this.global_emitter.unbind_all();\n return this;\n }\n\n subscribeAll() {\n var channelName;\n for (channelName in this.channels.channels) {\n if (this.channels.channels.hasOwnProperty(channelName)) {\n this.subscribe(channelName);\n }\n }\n }\n\n subscribe(channel_name: string) {\n var channel = this.channels.add(channel_name, this);\n if (channel.subscriptionPending && channel.subscriptionCancelled) {\n channel.reinstateSubscription();\n } else if (\n !channel.subscriptionPending &&\n this.connection.state === 'connected'\n ) {\n channel.subscribe();\n }\n return channel;\n }\n\n unsubscribe(channel_name: string) {\n var channel = this.channels.find(channel_name);\n if (channel && channel.subscriptionPending) {\n channel.cancelSubscription();\n } else {\n channel = this.channels.remove(channel_name);\n if (channel && channel.subscribed) {\n channel.unsubscribe();\n }\n }\n }\n\n send_event(event_name: string, data: any, channel?: string) {\n return this.connection.send_event(event_name, data, channel);\n }\n\n shouldUseTLS(): boolean {\n return this.config.useTLS;\n }\n\n signin() {\n this.user.signin();\n }\n}\n\nfunction checkAppKey(key) {\n if (key === null || key === undefined) {\n throw 'You must pass your app key when you instantiate Pusher.';\n }\n}\n\nRuntime.setup(Pusher);\n","var g;\n\n// This works in non-strict mode\ng = (function() {\n\treturn this;\n})();\n\ntry {\n\t// This works if eval is allowed (see CSP)\n\tg = g || new Function(\"return this\")();\n} catch (e) {\n\t// This works if the window reference is available\n\tif (typeof window === \"object\") g = window;\n}\n\n// g can still be undefined, but nothing to do about it...\n// We return undefined, instead of nothing here, so it's\n// easier to handle this case. if(!global) { ...}\n\nmodule.exports = g;\n","import ConnectionManager from './connection/connection_manager';\nimport {\n ChannelAuthorizationOptions,\n UserAuthenticationOptions\n} from './auth/options';\nimport {\n ChannelAuthorizerGenerator,\n DeprecatedAuthOptions\n} from './auth/deprecated_channel_authorizer';\nimport { AuthTransport, Transport } from './config';\nimport * as nacl from 'tweetnacl';\nimport Logger from './logger';\n\nexport interface Options {\n activityTimeout?: number;\n\n auth?: DeprecatedAuthOptions; // DEPRECATED use channelAuthorization instead\n authEndpoint?: string; // DEPRECATED use channelAuthorization instead\n authTransport?: AuthTransport; // DEPRECATED use channelAuthorization instead\n authorizer?: ChannelAuthorizerGenerator; // DEPRECATED use channelAuthorization instead\n\n channelAuthorization?: ChannelAuthorizationOptions;\n userAuthentication?: UserAuthenticationOptions;\n\n cluster: string;\n enableStats?: boolean;\n disableStats?: boolean;\n disabledTransports?: Transport[];\n enabledTransports?: Transport[];\n forceTLS?: boolean;\n httpHost?: string;\n httpPath?: string;\n httpPort?: number;\n httpsPort?: number;\n ignoreNullOrigin?: boolean;\n nacl?: nacl;\n pongTimeout?: number;\n statsHost?: string;\n timelineParams?: any;\n unavailableTimeout?: number;\n wsHost?: string;\n wsPath?: string;\n wsPort?: number;\n wssPort?: number;\n}\n\nexport function validateOptions(options) {\n if (options == null) {\n throw 'You must pass an options object';\n }\n if (options.cluster == null) {\n throw 'Options object must provide a cluster';\n }\n if ('disableStats' in options) {\n Logger.warn(\n 'The disableStats option is deprecated in favor of enableStats'\n );\n }\n}\n","// Copyright (C) 2016 Dmitry Chestnykh\n// MIT License. See LICENSE file for details.\n\n/**\n * Package base64 implements Base64 encoding and decoding.\n */\n\n// Invalid character used in decoding to indicate\n// that the character to decode is out of range of\n// alphabet and cannot be decoded.\nconst INVALID_BYTE = 256;\n\n/**\n * Implements standard Base64 encoding.\n *\n * Operates in constant time.\n */\nexport class Coder {\n // TODO(dchest): methods to encode chunk-by-chunk.\n\n constructor(private _paddingCharacter = \"=\") { }\n\n encodedLength(length: number): number {\n if (!this._paddingCharacter) {\n return (length * 8 + 5) / 6 | 0;\n }\n return (length + 2) / 3 * 4 | 0;\n }\n\n encode(data: Uint8Array): string {\n let out = \"\";\n\n let i = 0;\n for (; i < data.length - 2; i += 3) {\n let c = (data[i] << 16) | (data[i + 1] << 8) | (data[i + 2]);\n out += this._encodeByte((c >>> 3 * 6) & 63);\n out += this._encodeByte((c >>> 2 * 6) & 63);\n out += this._encodeByte((c >>> 1 * 6) & 63);\n out += this._encodeByte((c >>> 0 * 6) & 63);\n }\n\n const left = data.length - i;\n if (left > 0) {\n let c = (data[i] << 16) | (left === 2 ? data[i + 1] << 8 : 0);\n out += this._encodeByte((c >>> 3 * 6) & 63);\n out += this._encodeByte((c >>> 2 * 6) & 63);\n if (left === 2) {\n out += this._encodeByte((c >>> 1 * 6) & 63);\n } else {\n out += this._paddingCharacter || \"\";\n }\n out += this._paddingCharacter || \"\";\n }\n\n return out;\n }\n\n maxDecodedLength(length: number): number {\n if (!this._paddingCharacter) {\n return (length * 6 + 7) / 8 | 0;\n }\n return length / 4 * 3 | 0;\n }\n\n decodedLength(s: string): number {\n return this.maxDecodedLength(s.length - this._getPaddingLength(s));\n }\n\n decode(s: string): Uint8Array {\n if (s.length === 0) {\n return new Uint8Array(0);\n }\n const paddingLength = this._getPaddingLength(s);\n const length = s.length - paddingLength;\n const out = new Uint8Array(this.maxDecodedLength(length));\n let op = 0;\n let i = 0;\n let haveBad = 0;\n let v0 = 0, v1 = 0, v2 = 0, v3 = 0;\n for (; i < length - 4; i += 4) {\n v0 = this._decodeChar(s.charCodeAt(i + 0));\n v1 = this._decodeChar(s.charCodeAt(i + 1));\n v2 = this._decodeChar(s.charCodeAt(i + 2));\n v3 = this._decodeChar(s.charCodeAt(i + 3));\n out[op++] = (v0 << 2) | (v1 >>> 4);\n out[op++] = (v1 << 4) | (v2 >>> 2);\n out[op++] = (v2 << 6) | v3;\n haveBad |= v0 & INVALID_BYTE;\n haveBad |= v1 & INVALID_BYTE;\n haveBad |= v2 & INVALID_BYTE;\n haveBad |= v3 & INVALID_BYTE;\n }\n if (i < length - 1) {\n v0 = this._decodeChar(s.charCodeAt(i));\n v1 = this._decodeChar(s.charCodeAt(i + 1));\n out[op++] = (v0 << 2) | (v1 >>> 4);\n haveBad |= v0 & INVALID_BYTE;\n haveBad |= v1 & INVALID_BYTE;\n }\n if (i < length - 2) {\n v2 = this._decodeChar(s.charCodeAt(i + 2));\n out[op++] = (v1 << 4) | (v2 >>> 2);\n haveBad |= v2 & INVALID_BYTE;\n }\n if (i < length - 3) {\n v3 = this._decodeChar(s.charCodeAt(i + 3));\n out[op++] = (v2 << 6) | v3;\n haveBad |= v3 & INVALID_BYTE;\n }\n if (haveBad !== 0) {\n throw new Error(\"Base64Coder: incorrect characters for decoding\");\n }\n return out;\n }\n\n // Standard encoding have the following encoded/decoded ranges,\n // which we need to convert between.\n //\n // ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 0123456789 + /\n // Index: 0 - 25 26 - 51 52 - 61 62 63\n // ASCII: 65 - 90 97 - 122 48 - 57 43 47\n //\n\n // Encode 6 bits in b into a new character.\n protected _encodeByte(b: number): string {\n // Encoding uses constant time operations as follows:\n //\n // 1. Define comparison of A with B using (A - B) >>> 8:\n // if A > B, then result is positive integer\n // if A <= B, then result is 0\n //\n // 2. Define selection of C or 0 using bitwise AND: X & C:\n // if X == 0, then result is 0\n // if X != 0, then result is C\n //\n // 3. Start with the smallest comparison (b >= 0), which is always\n // true, so set the result to the starting ASCII value (65).\n //\n // 4. Continue comparing b to higher ASCII values, and selecting\n // zero if comparison isn't true, otherwise selecting a value\n // to add to result, which:\n //\n // a) undoes the previous addition\n // b) provides new value to add\n //\n let result = b;\n // b >= 0\n result += 65;\n // b > 25\n result += ((25 - b) >>> 8) & ((0 - 65) - 26 + 97);\n // b > 51\n result += ((51 - b) >>> 8) & ((26 - 97) - 52 + 48);\n // b > 61\n result += ((61 - b) >>> 8) & ((52 - 48) - 62 + 43);\n // b > 62\n result += ((62 - b) >>> 8) & ((62 - 43) - 63 + 47);\n\n return String.fromCharCode(result);\n }\n\n // Decode a character code into a byte.\n // Must return 256 if character is out of alphabet range.\n protected _decodeChar(c: number): number {\n // Decoding works similar to encoding: using the same comparison\n // function, but now it works on ranges: result is always incremented\n // by value, but this value becomes zero if the range is not\n // satisfied.\n //\n // Decoding starts with invalid value, 256, which is then\n // subtracted when the range is satisfied. If none of the ranges\n // apply, the function returns 256, which is then checked by\n // the caller to throw error.\n let result = INVALID_BYTE; // start with invalid character\n\n // c == 43 (c > 42 and c < 44)\n result += (((42 - c) & (c - 44)) >>> 8) & (-INVALID_BYTE + c - 43 + 62);\n // c == 47 (c > 46 and c < 48)\n result += (((46 - c) & (c - 48)) >>> 8) & (-INVALID_BYTE + c - 47 + 63);\n // c > 47 and c < 58\n result += (((47 - c) & (c - 58)) >>> 8) & (-INVALID_BYTE + c - 48 + 52);\n // c > 64 and c < 91\n result += (((64 - c) & (c - 91)) >>> 8) & (-INVALID_BYTE + c - 65 + 0);\n // c > 96 and c < 123\n result += (((96 - c) & (c - 123)) >>> 8) & (-INVALID_BYTE + c - 97 + 26);\n\n return result;\n }\n\n private _getPaddingLength(s: string): number {\n let paddingLength = 0;\n if (this._paddingCharacter) {\n for (let i = s.length - 1; i >= 0; i--) {\n if (s[i] !== this._paddingCharacter) {\n break;\n }\n paddingLength++;\n }\n if (s.length < 4 || paddingLength > 2) {\n throw new Error(\"Base64Coder: incorrect padding\");\n }\n }\n return paddingLength;\n }\n\n}\n\nconst stdCoder = new Coder();\n\nexport function encode(data: Uint8Array): string {\n return stdCoder.encode(data);\n}\n\nexport function decode(s: string): Uint8Array {\n return stdCoder.decode(s);\n}\n\n/**\n * Implements URL-safe Base64 encoding.\n * (Same as Base64, but '+' is replaced with '-', and '/' with '_').\n *\n * Operates in constant time.\n */\nexport class URLSafeCoder extends Coder {\n // URL-safe encoding have the following encoded/decoded ranges:\n //\n // ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 0123456789 - _\n // Index: 0 - 25 26 - 51 52 - 61 62 63\n // ASCII: 65 - 90 97 - 122 48 - 57 45 95\n //\n\n protected _encodeByte(b: number): string {\n let result = b;\n // b >= 0\n result += 65;\n // b > 25\n result += ((25 - b) >>> 8) & ((0 - 65) - 26 + 97);\n // b > 51\n result += ((51 - b) >>> 8) & ((26 - 97) - 52 + 48);\n // b > 61\n result += ((61 - b) >>> 8) & ((52 - 48) - 62 + 45);\n // b > 62\n result += ((62 - b) >>> 8) & ((62 - 45) - 63 + 95);\n\n return String.fromCharCode(result);\n }\n\n protected _decodeChar(c: number): number {\n let result = INVALID_BYTE;\n\n // c == 45 (c > 44 and c < 46)\n result += (((44 - c) & (c - 46)) >>> 8) & (-INVALID_BYTE + c - 45 + 62);\n // c == 95 (c > 94 and c < 96)\n result += (((94 - c) & (c - 96)) >>> 8) & (-INVALID_BYTE + c - 95 + 63);\n // c > 47 and c < 58\n result += (((47 - c) & (c - 58)) >>> 8) & (-INVALID_BYTE + c - 48 + 52);\n // c > 64 and c < 91\n result += (((64 - c) & (c - 91)) >>> 8) & (-INVALID_BYTE + c - 65 + 0);\n // c > 96 and c < 123\n result += (((96 - c) & (c - 123)) >>> 8) & (-INVALID_BYTE + c - 97 + 26);\n\n return result;\n }\n}\n\nconst urlSafeCoder = new URLSafeCoder();\n\nexport function encodeURLSafe(data: Uint8Array): string {\n return urlSafeCoder.encode(data);\n}\n\nexport function decodeURLSafe(s: string): Uint8Array {\n return urlSafeCoder.decode(s);\n}\n\n\nexport const encodedLength = (length: number) =>\n stdCoder.encodedLength(length);\n\nexport const maxDecodedLength = (length: number) =>\n stdCoder.maxDecodedLength(length);\n\nexport const decodedLength = (s: string) =>\n stdCoder.decodedLength(s);\n","import TimedCallback from './timed_callback';\nimport { Delay, Scheduler, Canceller } from './scheduling';\n\nabstract class Timer {\n protected clear: Canceller;\n protected timer: number | void;\n\n constructor(\n set: Scheduler,\n clear: Canceller,\n delay: Delay,\n callback: TimedCallback\n ) {\n this.clear = clear;\n this.timer = set(() => {\n if (this.timer) {\n this.timer = callback(this.timer);\n }\n }, delay);\n }\n\n /** Returns whether the timer is still running.\n *\n * @return {Boolean}\n */\n isRunning(): boolean {\n return this.timer !== null;\n }\n\n /** Aborts a timer when it's running. */\n ensureAborted() {\n if (this.timer) {\n this.clear(this.timer);\n this.timer = null;\n }\n }\n}\n\nexport default Timer;\n","module.exports = require(\"@react-native-community/netinfo\");","export default function encode(s: any): string {\n return btoa(utob(s));\n}\n\nvar fromCharCode = String.fromCharCode;\n\nvar b64chars =\n 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';\nvar b64tab = {};\n\nfor (var i = 0, l = b64chars.length; i < l; i++) {\n b64tab[b64chars.charAt(i)] = i;\n}\n\nvar cb_utob = function(c) {\n var cc = c.charCodeAt(0);\n return cc < 0x80\n ? c\n : cc < 0x800\n ? fromCharCode(0xc0 | (cc >>> 6)) + fromCharCode(0x80 | (cc & 0x3f))\n : fromCharCode(0xe0 | ((cc >>> 12) & 0x0f)) +\n fromCharCode(0x80 | ((cc >>> 6) & 0x3f)) +\n fromCharCode(0x80 | (cc & 0x3f));\n};\n\nvar utob = function(u) {\n return u.replace(/[^\\x00-\\x7F]/g, cb_utob);\n};\n\nvar cb_encode = function(ccc) {\n var padlen = [0, 2, 1][ccc.length % 3];\n var ord =\n (ccc.charCodeAt(0) << 16) |\n ((ccc.length > 1 ? ccc.charCodeAt(1) : 0) << 8) |\n (ccc.length > 2 ? ccc.charCodeAt(2) : 0);\n var chars = [\n b64chars.charAt(ord >>> 18),\n b64chars.charAt((ord >>> 12) & 63),\n padlen >= 2 ? '=' : b64chars.charAt((ord >>> 6) & 63),\n padlen >= 1 ? '=' : b64chars.charAt(ord & 63)\n ];\n return chars.join('');\n};\n\nvar btoa =\n global.btoa ||\n function(b) {\n return b.replace(/[\\s\\S]{1,3}/g, cb_encode);\n };\n","import Callback from './callback';\nimport * as Collections from '../utils/collections';\nimport CallbackTable from './callback_table';\n\nexport default class CallbackRegistry {\n _callbacks: CallbackTable;\n\n constructor() {\n this._callbacks = {};\n }\n\n get(name: string): Callback[] {\n return this._callbacks[prefix(name)];\n }\n\n add(name: string, callback: Function, context: any) {\n var prefixedEventName = prefix(name);\n this._callbacks[prefixedEventName] =\n this._callbacks[prefixedEventName] || [];\n this._callbacks[prefixedEventName].push({\n fn: callback,\n context: context\n });\n }\n\n remove(name?: string, callback?: Function, context?: any) {\n if (!name && !callback && !context) {\n this._callbacks = {};\n return;\n }\n\n var names = name ? [prefix(name)] : Collections.keys(this._callbacks);\n\n if (callback || context) {\n this.removeCallback(names, callback, context);\n } else {\n this.removeAllCallbacks(names);\n }\n }\n\n private removeCallback(names: string[], callback: Function, context: any) {\n Collections.apply(\n names,\n function(name) {\n this._callbacks[name] = Collections.filter(\n this._callbacks[name] || [],\n function(binding) {\n return (\n (callback && callback !== binding.fn) ||\n (context && context !== binding.context)\n );\n }\n );\n if (this._callbacks[name].length === 0) {\n delete this._callbacks[name];\n }\n },\n this\n );\n }\n\n private removeAllCallbacks(names: string[]) {\n Collections.apply(\n names,\n function(name) {\n delete this._callbacks[name];\n },\n this\n );\n }\n}\n\nfunction prefix(name: string): string {\n return '_' + name;\n}\n","// Copyright (C) 2016 Dmitry Chestnykh\n// MIT License. See LICENSE file for details.\n\n/**\n * Package utf8 implements UTF-8 encoding and decoding.\n */\n\nconst INVALID_UTF16 = \"utf8: invalid string\";\nconst INVALID_UTF8 = \"utf8: invalid source encoding\";\n\n/**\n * Encodes the given string into UTF-8 byte array.\n * Throws if the source string has invalid UTF-16 encoding.\n */\nexport function encode(s: string): Uint8Array {\n // Calculate result length and allocate output array.\n // encodedLength() also validates string and throws errors,\n // so we don't need repeat validation here.\n const arr = new Uint8Array(encodedLength(s));\n\n let pos = 0;\n for (let i = 0; i < s.length; i++) {\n let c = s.charCodeAt(i);\n if (c < 0x80) {\n arr[pos++] = c;\n } else if (c < 0x800) {\n arr[pos++] = 0xc0 | c >> 6;\n arr[pos++] = 0x80 | c & 0x3f;\n } else if (c < 0xd800) {\n arr[pos++] = 0xe0 | c >> 12;\n arr[pos++] = 0x80 | (c >> 6) & 0x3f;\n arr[pos++] = 0x80 | c & 0x3f;\n } else {\n i++; // get one more character\n c = (c & 0x3ff) << 10;\n c |= s.charCodeAt(i) & 0x3ff;\n c += 0x10000;\n\n arr[pos++] = 0xf0 | c >> 18;\n arr[pos++] = 0x80 | (c >> 12) & 0x3f;\n arr[pos++] = 0x80 | (c >> 6) & 0x3f;\n arr[pos++] = 0x80 | c & 0x3f;\n }\n }\n return arr;\n}\n\n/**\n * Returns the number of bytes required to encode the given string into UTF-8.\n * Throws if the source string has invalid UTF-16 encoding.\n */\nexport function encodedLength(s: string): number {\n let result = 0;\n for (let i = 0; i < s.length; i++) {\n const c = s.charCodeAt(i);\n if (c < 0x80) {\n result += 1;\n } else if (c < 0x800) {\n result += 2;\n } else if (c < 0xd800) {\n result += 3;\n } else if (c <= 0xdfff) {\n if (i >= s.length - 1) {\n throw new Error(INVALID_UTF16);\n }\n i++; // \"eat\" next character\n result += 4;\n } else {\n throw new Error(INVALID_UTF16);\n }\n }\n return result;\n}\n\n/**\n * Decodes the given byte array from UTF-8 into a string.\n * Throws if encoding is invalid.\n */\nexport function decode(arr: Uint8Array): string {\n const chars: string[] = [];\n for (let i = 0; i < arr.length; i++) {\n let b = arr[i];\n\n if (b & 0x80) {\n let min;\n if (b < 0xe0) {\n // Need 1 more byte.\n if (i >= arr.length) {\n throw new Error(INVALID_UTF8);\n }\n const n1 = arr[++i];\n if ((n1 & 0xc0) !== 0x80) {\n throw new Error(INVALID_UTF8);\n }\n b = (b & 0x1f) << 6 | (n1 & 0x3f);\n min = 0x80;\n } else if (b < 0xf0) {\n // Need 2 more bytes.\n if (i >= arr.length - 1) {\n throw new Error(INVALID_UTF8);\n }\n const n1 = arr[++i];\n const n2 = arr[++i];\n if ((n1 & 0xc0) !== 0x80 || (n2 & 0xc0) !== 0x80) {\n throw new Error(INVALID_UTF8);\n }\n b = (b & 0x0f) << 12 | (n1 & 0x3f) << 6 | (n2 & 0x3f);\n min = 0x800;\n } else if (b < 0xf8) {\n // Need 3 more bytes.\n if (i >= arr.length - 2) {\n throw new Error(INVALID_UTF8);\n }\n const n1 = arr[++i];\n const n2 = arr[++i];\n const n3 = arr[++i];\n if ((n1 & 0xc0) !== 0x80 || (n2 & 0xc0) !== 0x80 || (n3 & 0xc0) !== 0x80) {\n throw new Error(INVALID_UTF8);\n }\n b = (b & 0x0f) << 18 | (n1 & 0x3f) << 12 | (n2 & 0x3f) << 6 | (n3 & 0x3f);\n min = 0x10000;\n } else {\n throw new Error(INVALID_UTF8);\n }\n\n if (b < min || (b >= 0xd800 && b <= 0xdfff)) {\n throw new Error(INVALID_UTF8);\n }\n\n if (b >= 0x10000) {\n // Surrogate pair.\n if (b > 0x10ffff) {\n throw new Error(INVALID_UTF8);\n }\n b -= 0x10000;\n chars.push(String.fromCharCode(0xd800 | (b >> 10)));\n b = 0xdc00 | (b & 0x3ff);\n }\n }\n\n chars.push(String.fromCharCode(b));\n }\n return chars.join(\"\");\n}\n","(function(nacl) {\n'use strict';\n\n// Ported in 2014 by Dmitry Chestnykh and Devi Mandiri.\n// Public domain.\n//\n// Implementation derived from TweetNaCl version 20140427.\n// See for details: http://tweetnacl.cr.yp.to/\n\nvar gf = function(init) {\n var i, r = new Float64Array(16);\n if (init) for (i = 0; i < init.length; i++) r[i] = init[i];\n return r;\n};\n\n// Pluggable, initialized in high-level API below.\nvar randombytes = function(/* x, n */) { throw new Error('no PRNG'); };\n\nvar _0 = new Uint8Array(16);\nvar _9 = new Uint8Array(32); _9[0] = 9;\n\nvar gf0 = gf(),\n gf1 = gf([1]),\n _121665 = gf([0xdb41, 1]),\n D = gf([0x78a3, 0x1359, 0x4dca, 0x75eb, 0xd8ab, 0x4141, 0x0a4d, 0x0070, 0xe898, 0x7779, 0x4079, 0x8cc7, 0xfe73, 0x2b6f, 0x6cee, 0x5203]),\n D2 = gf([0xf159, 0x26b2, 0x9b94, 0xebd6, 0xb156, 0x8283, 0x149a, 0x00e0, 0xd130, 0xeef3, 0x80f2, 0x198e, 0xfce7, 0x56df, 0xd9dc, 0x2406]),\n X = gf([0xd51a, 0x8f25, 0x2d60, 0xc956, 0xa7b2, 0x9525, 0xc760, 0x692c, 0xdc5c, 0xfdd6, 0xe231, 0xc0a4, 0x53fe, 0xcd6e, 0x36d3, 0x2169]),\n Y = gf([0x6658, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666]),\n I = gf([0xa0b0, 0x4a0e, 0x1b27, 0xc4ee, 0xe478, 0xad2f, 0x1806, 0x2f43, 0xd7a7, 0x3dfb, 0x0099, 0x2b4d, 0xdf0b, 0x4fc1, 0x2480, 0x2b83]);\n\nfunction ts64(x, i, h, l) {\n x[i] = (h >> 24) & 0xff;\n x[i+1] = (h >> 16) & 0xff;\n x[i+2] = (h >> 8) & 0xff;\n x[i+3] = h & 0xff;\n x[i+4] = (l >> 24) & 0xff;\n x[i+5] = (l >> 16) & 0xff;\n x[i+6] = (l >> 8) & 0xff;\n x[i+7] = l & 0xff;\n}\n\nfunction vn(x, xi, y, yi, n) {\n var i,d = 0;\n for (i = 0; i < n; i++) d |= x[xi+i]^y[yi+i];\n return (1 & ((d - 1) >>> 8)) - 1;\n}\n\nfunction crypto_verify_16(x, xi, y, yi) {\n return vn(x,xi,y,yi,16);\n}\n\nfunction crypto_verify_32(x, xi, y, yi) {\n return vn(x,xi,y,yi,32);\n}\n\nfunction core_salsa20(o, p, k, c) {\n var j0 = c[ 0] & 0xff | (c[ 1] & 0xff)<<8 | (c[ 2] & 0xff)<<16 | (c[ 3] & 0xff)<<24,\n j1 = k[ 0] & 0xff | (k[ 1] & 0xff)<<8 | (k[ 2] & 0xff)<<16 | (k[ 3] & 0xff)<<24,\n j2 = k[ 4] & 0xff | (k[ 5] & 0xff)<<8 | (k[ 6] & 0xff)<<16 | (k[ 7] & 0xff)<<24,\n j3 = k[ 8] & 0xff | (k[ 9] & 0xff)<<8 | (k[10] & 0xff)<<16 | (k[11] & 0xff)<<24,\n j4 = k[12] & 0xff | (k[13] & 0xff)<<8 | (k[14] & 0xff)<<16 | (k[15] & 0xff)<<24,\n j5 = c[ 4] & 0xff | (c[ 5] & 0xff)<<8 | (c[ 6] & 0xff)<<16 | (c[ 7] & 0xff)<<24,\n j6 = p[ 0] & 0xff | (p[ 1] & 0xff)<<8 | (p[ 2] & 0xff)<<16 | (p[ 3] & 0xff)<<24,\n j7 = p[ 4] & 0xff | (p[ 5] & 0xff)<<8 | (p[ 6] & 0xff)<<16 | (p[ 7] & 0xff)<<24,\n j8 = p[ 8] & 0xff | (p[ 9] & 0xff)<<8 | (p[10] & 0xff)<<16 | (p[11] & 0xff)<<24,\n j9 = p[12] & 0xff | (p[13] & 0xff)<<8 | (p[14] & 0xff)<<16 | (p[15] & 0xff)<<24,\n j10 = c[ 8] & 0xff | (c[ 9] & 0xff)<<8 | (c[10] & 0xff)<<16 | (c[11] & 0xff)<<24,\n j11 = k[16] & 0xff | (k[17] & 0xff)<<8 | (k[18] & 0xff)<<16 | (k[19] & 0xff)<<24,\n j12 = k[20] & 0xff | (k[21] & 0xff)<<8 | (k[22] & 0xff)<<16 | (k[23] & 0xff)<<24,\n j13 = k[24] & 0xff | (k[25] & 0xff)<<8 | (k[26] & 0xff)<<16 | (k[27] & 0xff)<<24,\n j14 = k[28] & 0xff | (k[29] & 0xff)<<8 | (k[30] & 0xff)<<16 | (k[31] & 0xff)<<24,\n j15 = c[12] & 0xff | (c[13] & 0xff)<<8 | (c[14] & 0xff)<<16 | (c[15] & 0xff)<<24;\n\n var x0 = j0, x1 = j1, x2 = j2, x3 = j3, x4 = j4, x5 = j5, x6 = j6, x7 = j7,\n x8 = j8, x9 = j9, x10 = j10, x11 = j11, x12 = j12, x13 = j13, x14 = j14,\n x15 = j15, u;\n\n for (var i = 0; i < 20; i += 2) {\n u = x0 + x12 | 0;\n x4 ^= u<<7 | u>>>(32-7);\n u = x4 + x0 | 0;\n x8 ^= u<<9 | u>>>(32-9);\n u = x8 + x4 | 0;\n x12 ^= u<<13 | u>>>(32-13);\n u = x12 + x8 | 0;\n x0 ^= u<<18 | u>>>(32-18);\n\n u = x5 + x1 | 0;\n x9 ^= u<<7 | u>>>(32-7);\n u = x9 + x5 | 0;\n x13 ^= u<<9 | u>>>(32-9);\n u = x13 + x9 | 0;\n x1 ^= u<<13 | u>>>(32-13);\n u = x1 + x13 | 0;\n x5 ^= u<<18 | u>>>(32-18);\n\n u = x10 + x6 | 0;\n x14 ^= u<<7 | u>>>(32-7);\n u = x14 + x10 | 0;\n x2 ^= u<<9 | u>>>(32-9);\n u = x2 + x14 | 0;\n x6 ^= u<<13 | u>>>(32-13);\n u = x6 + x2 | 0;\n x10 ^= u<<18 | u>>>(32-18);\n\n u = x15 + x11 | 0;\n x3 ^= u<<7 | u>>>(32-7);\n u = x3 + x15 | 0;\n x7 ^= u<<9 | u>>>(32-9);\n u = x7 + x3 | 0;\n x11 ^= u<<13 | u>>>(32-13);\n u = x11 + x7 | 0;\n x15 ^= u<<18 | u>>>(32-18);\n\n u = x0 + x3 | 0;\n x1 ^= u<<7 | u>>>(32-7);\n u = x1 + x0 | 0;\n x2 ^= u<<9 | u>>>(32-9);\n u = x2 + x1 | 0;\n x3 ^= u<<13 | u>>>(32-13);\n u = x3 + x2 | 0;\n x0 ^= u<<18 | u>>>(32-18);\n\n u = x5 + x4 | 0;\n x6 ^= u<<7 | u>>>(32-7);\n u = x6 + x5 | 0;\n x7 ^= u<<9 | u>>>(32-9);\n u = x7 + x6 | 0;\n x4 ^= u<<13 | u>>>(32-13);\n u = x4 + x7 | 0;\n x5 ^= u<<18 | u>>>(32-18);\n\n u = x10 + x9 | 0;\n x11 ^= u<<7 | u>>>(32-7);\n u = x11 + x10 | 0;\n x8 ^= u<<9 | u>>>(32-9);\n u = x8 + x11 | 0;\n x9 ^= u<<13 | u>>>(32-13);\n u = x9 + x8 | 0;\n x10 ^= u<<18 | u>>>(32-18);\n\n u = x15 + x14 | 0;\n x12 ^= u<<7 | u>>>(32-7);\n u = x12 + x15 | 0;\n x13 ^= u<<9 | u>>>(32-9);\n u = x13 + x12 | 0;\n x14 ^= u<<13 | u>>>(32-13);\n u = x14 + x13 | 0;\n x15 ^= u<<18 | u>>>(32-18);\n }\n x0 = x0 + j0 | 0;\n x1 = x1 + j1 | 0;\n x2 = x2 + j2 | 0;\n x3 = x3 + j3 | 0;\n x4 = x4 + j4 | 0;\n x5 = x5 + j5 | 0;\n x6 = x6 + j6 | 0;\n x7 = x7 + j7 | 0;\n x8 = x8 + j8 | 0;\n x9 = x9 + j9 | 0;\n x10 = x10 + j10 | 0;\n x11 = x11 + j11 | 0;\n x12 = x12 + j12 | 0;\n x13 = x13 + j13 | 0;\n x14 = x14 + j14 | 0;\n x15 = x15 + j15 | 0;\n\n o[ 0] = x0 >>> 0 & 0xff;\n o[ 1] = x0 >>> 8 & 0xff;\n o[ 2] = x0 >>> 16 & 0xff;\n o[ 3] = x0 >>> 24 & 0xff;\n\n o[ 4] = x1 >>> 0 & 0xff;\n o[ 5] = x1 >>> 8 & 0xff;\n o[ 6] = x1 >>> 16 & 0xff;\n o[ 7] = x1 >>> 24 & 0xff;\n\n o[ 8] = x2 >>> 0 & 0xff;\n o[ 9] = x2 >>> 8 & 0xff;\n o[10] = x2 >>> 16 & 0xff;\n o[11] = x2 >>> 24 & 0xff;\n\n o[12] = x3 >>> 0 & 0xff;\n o[13] = x3 >>> 8 & 0xff;\n o[14] = x3 >>> 16 & 0xff;\n o[15] = x3 >>> 24 & 0xff;\n\n o[16] = x4 >>> 0 & 0xff;\n o[17] = x4 >>> 8 & 0xff;\n o[18] = x4 >>> 16 & 0xff;\n o[19] = x4 >>> 24 & 0xff;\n\n o[20] = x5 >>> 0 & 0xff;\n o[21] = x5 >>> 8 & 0xff;\n o[22] = x5 >>> 16 & 0xff;\n o[23] = x5 >>> 24 & 0xff;\n\n o[24] = x6 >>> 0 & 0xff;\n o[25] = x6 >>> 8 & 0xff;\n o[26] = x6 >>> 16 & 0xff;\n o[27] = x6 >>> 24 & 0xff;\n\n o[28] = x7 >>> 0 & 0xff;\n o[29] = x7 >>> 8 & 0xff;\n o[30] = x7 >>> 16 & 0xff;\n o[31] = x7 >>> 24 & 0xff;\n\n o[32] = x8 >>> 0 & 0xff;\n o[33] = x8 >>> 8 & 0xff;\n o[34] = x8 >>> 16 & 0xff;\n o[35] = x8 >>> 24 & 0xff;\n\n o[36] = x9 >>> 0 & 0xff;\n o[37] = x9 >>> 8 & 0xff;\n o[38] = x9 >>> 16 & 0xff;\n o[39] = x9 >>> 24 & 0xff;\n\n o[40] = x10 >>> 0 & 0xff;\n o[41] = x10 >>> 8 & 0xff;\n o[42] = x10 >>> 16 & 0xff;\n o[43] = x10 >>> 24 & 0xff;\n\n o[44] = x11 >>> 0 & 0xff;\n o[45] = x11 >>> 8 & 0xff;\n o[46] = x11 >>> 16 & 0xff;\n o[47] = x11 >>> 24 & 0xff;\n\n o[48] = x12 >>> 0 & 0xff;\n o[49] = x12 >>> 8 & 0xff;\n o[50] = x12 >>> 16 & 0xff;\n o[51] = x12 >>> 24 & 0xff;\n\n o[52] = x13 >>> 0 & 0xff;\n o[53] = x13 >>> 8 & 0xff;\n o[54] = x13 >>> 16 & 0xff;\n o[55] = x13 >>> 24 & 0xff;\n\n o[56] = x14 >>> 0 & 0xff;\n o[57] = x14 >>> 8 & 0xff;\n o[58] = x14 >>> 16 & 0xff;\n o[59] = x14 >>> 24 & 0xff;\n\n o[60] = x15 >>> 0 & 0xff;\n o[61] = x15 >>> 8 & 0xff;\n o[62] = x15 >>> 16 & 0xff;\n o[63] = x15 >>> 24 & 0xff;\n}\n\nfunction core_hsalsa20(o,p,k,c) {\n var j0 = c[ 0] & 0xff | (c[ 1] & 0xff)<<8 | (c[ 2] & 0xff)<<16 | (c[ 3] & 0xff)<<24,\n j1 = k[ 0] & 0xff | (k[ 1] & 0xff)<<8 | (k[ 2] & 0xff)<<16 | (k[ 3] & 0xff)<<24,\n j2 = k[ 4] & 0xff | (k[ 5] & 0xff)<<8 | (k[ 6] & 0xff)<<16 | (k[ 7] & 0xff)<<24,\n j3 = k[ 8] & 0xff | (k[ 9] & 0xff)<<8 | (k[10] & 0xff)<<16 | (k[11] & 0xff)<<24,\n j4 = k[12] & 0xff | (k[13] & 0xff)<<8 | (k[14] & 0xff)<<16 | (k[15] & 0xff)<<24,\n j5 = c[ 4] & 0xff | (c[ 5] & 0xff)<<8 | (c[ 6] & 0xff)<<16 | (c[ 7] & 0xff)<<24,\n j6 = p[ 0] & 0xff | (p[ 1] & 0xff)<<8 | (p[ 2] & 0xff)<<16 | (p[ 3] & 0xff)<<24,\n j7 = p[ 4] & 0xff | (p[ 5] & 0xff)<<8 | (p[ 6] & 0xff)<<16 | (p[ 7] & 0xff)<<24,\n j8 = p[ 8] & 0xff | (p[ 9] & 0xff)<<8 | (p[10] & 0xff)<<16 | (p[11] & 0xff)<<24,\n j9 = p[12] & 0xff | (p[13] & 0xff)<<8 | (p[14] & 0xff)<<16 | (p[15] & 0xff)<<24,\n j10 = c[ 8] & 0xff | (c[ 9] & 0xff)<<8 | (c[10] & 0xff)<<16 | (c[11] & 0xff)<<24,\n j11 = k[16] & 0xff | (k[17] & 0xff)<<8 | (k[18] & 0xff)<<16 | (k[19] & 0xff)<<24,\n j12 = k[20] & 0xff | (k[21] & 0xff)<<8 | (k[22] & 0xff)<<16 | (k[23] & 0xff)<<24,\n j13 = k[24] & 0xff | (k[25] & 0xff)<<8 | (k[26] & 0xff)<<16 | (k[27] & 0xff)<<24,\n j14 = k[28] & 0xff | (k[29] & 0xff)<<8 | (k[30] & 0xff)<<16 | (k[31] & 0xff)<<24,\n j15 = c[12] & 0xff | (c[13] & 0xff)<<8 | (c[14] & 0xff)<<16 | (c[15] & 0xff)<<24;\n\n var x0 = j0, x1 = j1, x2 = j2, x3 = j3, x4 = j4, x5 = j5, x6 = j6, x7 = j7,\n x8 = j8, x9 = j9, x10 = j10, x11 = j11, x12 = j12, x13 = j13, x14 = j14,\n x15 = j15, u;\n\n for (var i = 0; i < 20; i += 2) {\n u = x0 + x12 | 0;\n x4 ^= u<<7 | u>>>(32-7);\n u = x4 + x0 | 0;\n x8 ^= u<<9 | u>>>(32-9);\n u = x8 + x4 | 0;\n x12 ^= u<<13 | u>>>(32-13);\n u = x12 + x8 | 0;\n x0 ^= u<<18 | u>>>(32-18);\n\n u = x5 + x1 | 0;\n x9 ^= u<<7 | u>>>(32-7);\n u = x9 + x5 | 0;\n x13 ^= u<<9 | u>>>(32-9);\n u = x13 + x9 | 0;\n x1 ^= u<<13 | u>>>(32-13);\n u = x1 + x13 | 0;\n x5 ^= u<<18 | u>>>(32-18);\n\n u = x10 + x6 | 0;\n x14 ^= u<<7 | u>>>(32-7);\n u = x14 + x10 | 0;\n x2 ^= u<<9 | u>>>(32-9);\n u = x2 + x14 | 0;\n x6 ^= u<<13 | u>>>(32-13);\n u = x6 + x2 | 0;\n x10 ^= u<<18 | u>>>(32-18);\n\n u = x15 + x11 | 0;\n x3 ^= u<<7 | u>>>(32-7);\n u = x3 + x15 | 0;\n x7 ^= u<<9 | u>>>(32-9);\n u = x7 + x3 | 0;\n x11 ^= u<<13 | u>>>(32-13);\n u = x11 + x7 | 0;\n x15 ^= u<<18 | u>>>(32-18);\n\n u = x0 + x3 | 0;\n x1 ^= u<<7 | u>>>(32-7);\n u = x1 + x0 | 0;\n x2 ^= u<<9 | u>>>(32-9);\n u = x2 + x1 | 0;\n x3 ^= u<<13 | u>>>(32-13);\n u = x3 + x2 | 0;\n x0 ^= u<<18 | u>>>(32-18);\n\n u = x5 + x4 | 0;\n x6 ^= u<<7 | u>>>(32-7);\n u = x6 + x5 | 0;\n x7 ^= u<<9 | u>>>(32-9);\n u = x7 + x6 | 0;\n x4 ^= u<<13 | u>>>(32-13);\n u = x4 + x7 | 0;\n x5 ^= u<<18 | u>>>(32-18);\n\n u = x10 + x9 | 0;\n x11 ^= u<<7 | u>>>(32-7);\n u = x11 + x10 | 0;\n x8 ^= u<<9 | u>>>(32-9);\n u = x8 + x11 | 0;\n x9 ^= u<<13 | u>>>(32-13);\n u = x9 + x8 | 0;\n x10 ^= u<<18 | u>>>(32-18);\n\n u = x15 + x14 | 0;\n x12 ^= u<<7 | u>>>(32-7);\n u = x12 + x15 | 0;\n x13 ^= u<<9 | u>>>(32-9);\n u = x13 + x12 | 0;\n x14 ^= u<<13 | u>>>(32-13);\n u = x14 + x13 | 0;\n x15 ^= u<<18 | u>>>(32-18);\n }\n\n o[ 0] = x0 >>> 0 & 0xff;\n o[ 1] = x0 >>> 8 & 0xff;\n o[ 2] = x0 >>> 16 & 0xff;\n o[ 3] = x0 >>> 24 & 0xff;\n\n o[ 4] = x5 >>> 0 & 0xff;\n o[ 5] = x5 >>> 8 & 0xff;\n o[ 6] = x5 >>> 16 & 0xff;\n o[ 7] = x5 >>> 24 & 0xff;\n\n o[ 8] = x10 >>> 0 & 0xff;\n o[ 9] = x10 >>> 8 & 0xff;\n o[10] = x10 >>> 16 & 0xff;\n o[11] = x10 >>> 24 & 0xff;\n\n o[12] = x15 >>> 0 & 0xff;\n o[13] = x15 >>> 8 & 0xff;\n o[14] = x15 >>> 16 & 0xff;\n o[15] = x15 >>> 24 & 0xff;\n\n o[16] = x6 >>> 0 & 0xff;\n o[17] = x6 >>> 8 & 0xff;\n o[18] = x6 >>> 16 & 0xff;\n o[19] = x6 >>> 24 & 0xff;\n\n o[20] = x7 >>> 0 & 0xff;\n o[21] = x7 >>> 8 & 0xff;\n o[22] = x7 >>> 16 & 0xff;\n o[23] = x7 >>> 24 & 0xff;\n\n o[24] = x8 >>> 0 & 0xff;\n o[25] = x8 >>> 8 & 0xff;\n o[26] = x8 >>> 16 & 0xff;\n o[27] = x8 >>> 24 & 0xff;\n\n o[28] = x9 >>> 0 & 0xff;\n o[29] = x9 >>> 8 & 0xff;\n o[30] = x9 >>> 16 & 0xff;\n o[31] = x9 >>> 24 & 0xff;\n}\n\nfunction crypto_core_salsa20(out,inp,k,c) {\n core_salsa20(out,inp,k,c);\n}\n\nfunction crypto_core_hsalsa20(out,inp,k,c) {\n core_hsalsa20(out,inp,k,c);\n}\n\nvar sigma = new Uint8Array([101, 120, 112, 97, 110, 100, 32, 51, 50, 45, 98, 121, 116, 101, 32, 107]);\n // \"expand 32-byte k\"\n\nfunction crypto_stream_salsa20_xor(c,cpos,m,mpos,b,n,k) {\n var z = new Uint8Array(16), x = new Uint8Array(64);\n var u, i;\n for (i = 0; i < 16; i++) z[i] = 0;\n for (i = 0; i < 8; i++) z[i] = n[i];\n while (b >= 64) {\n crypto_core_salsa20(x,z,k,sigma);\n for (i = 0; i < 64; i++) c[cpos+i] = m[mpos+i] ^ x[i];\n u = 1;\n for (i = 8; i < 16; i++) {\n u = u + (z[i] & 0xff) | 0;\n z[i] = u & 0xff;\n u >>>= 8;\n }\n b -= 64;\n cpos += 64;\n mpos += 64;\n }\n if (b > 0) {\n crypto_core_salsa20(x,z,k,sigma);\n for (i = 0; i < b; i++) c[cpos+i] = m[mpos+i] ^ x[i];\n }\n return 0;\n}\n\nfunction crypto_stream_salsa20(c,cpos,b,n,k) {\n var z = new Uint8Array(16), x = new Uint8Array(64);\n var u, i;\n for (i = 0; i < 16; i++) z[i] = 0;\n for (i = 0; i < 8; i++) z[i] = n[i];\n while (b >= 64) {\n crypto_core_salsa20(x,z,k,sigma);\n for (i = 0; i < 64; i++) c[cpos+i] = x[i];\n u = 1;\n for (i = 8; i < 16; i++) {\n u = u + (z[i] & 0xff) | 0;\n z[i] = u & 0xff;\n u >>>= 8;\n }\n b -= 64;\n cpos += 64;\n }\n if (b > 0) {\n crypto_core_salsa20(x,z,k,sigma);\n for (i = 0; i < b; i++) c[cpos+i] = x[i];\n }\n return 0;\n}\n\nfunction crypto_stream(c,cpos,d,n,k) {\n var s = new Uint8Array(32);\n crypto_core_hsalsa20(s,n,k,sigma);\n var sn = new Uint8Array(8);\n for (var i = 0; i < 8; i++) sn[i] = n[i+16];\n return crypto_stream_salsa20(c,cpos,d,sn,s);\n}\n\nfunction crypto_stream_xor(c,cpos,m,mpos,d,n,k) {\n var s = new Uint8Array(32);\n crypto_core_hsalsa20(s,n,k,sigma);\n var sn = new Uint8Array(8);\n for (var i = 0; i < 8; i++) sn[i] = n[i+16];\n return crypto_stream_salsa20_xor(c,cpos,m,mpos,d,sn,s);\n}\n\n/*\n* Port of Andrew Moon's Poly1305-donna-16. Public domain.\n* https://github.com/floodyberry/poly1305-donna\n*/\n\nvar poly1305 = function(key) {\n this.buffer = new Uint8Array(16);\n this.r = new Uint16Array(10);\n this.h = new Uint16Array(10);\n this.pad = new Uint16Array(8);\n this.leftover = 0;\n this.fin = 0;\n\n var t0, t1, t2, t3, t4, t5, t6, t7;\n\n t0 = key[ 0] & 0xff | (key[ 1] & 0xff) << 8; this.r[0] = ( t0 ) & 0x1fff;\n t1 = key[ 2] & 0xff | (key[ 3] & 0xff) << 8; this.r[1] = ((t0 >>> 13) | (t1 << 3)) & 0x1fff;\n t2 = key[ 4] & 0xff | (key[ 5] & 0xff) << 8; this.r[2] = ((t1 >>> 10) | (t2 << 6)) & 0x1f03;\n t3 = key[ 6] & 0xff | (key[ 7] & 0xff) << 8; this.r[3] = ((t2 >>> 7) | (t3 << 9)) & 0x1fff;\n t4 = key[ 8] & 0xff | (key[ 9] & 0xff) << 8; this.r[4] = ((t3 >>> 4) | (t4 << 12)) & 0x00ff;\n this.r[5] = ((t4 >>> 1)) & 0x1ffe;\n t5 = key[10] & 0xff | (key[11] & 0xff) << 8; this.r[6] = ((t4 >>> 14) | (t5 << 2)) & 0x1fff;\n t6 = key[12] & 0xff | (key[13] & 0xff) << 8; this.r[7] = ((t5 >>> 11) | (t6 << 5)) & 0x1f81;\n t7 = key[14] & 0xff | (key[15] & 0xff) << 8; this.r[8] = ((t6 >>> 8) | (t7 << 8)) & 0x1fff;\n this.r[9] = ((t7 >>> 5)) & 0x007f;\n\n this.pad[0] = key[16] & 0xff | (key[17] & 0xff) << 8;\n this.pad[1] = key[18] & 0xff | (key[19] & 0xff) << 8;\n this.pad[2] = key[20] & 0xff | (key[21] & 0xff) << 8;\n this.pad[3] = key[22] & 0xff | (key[23] & 0xff) << 8;\n this.pad[4] = key[24] & 0xff | (key[25] & 0xff) << 8;\n this.pad[5] = key[26] & 0xff | (key[27] & 0xff) << 8;\n this.pad[6] = key[28] & 0xff | (key[29] & 0xff) << 8;\n this.pad[7] = key[30] & 0xff | (key[31] & 0xff) << 8;\n};\n\npoly1305.prototype.blocks = function(m, mpos, bytes) {\n var hibit = this.fin ? 0 : (1 << 11);\n var t0, t1, t2, t3, t4, t5, t6, t7, c;\n var d0, d1, d2, d3, d4, d5, d6, d7, d8, d9;\n\n var h0 = this.h[0],\n h1 = this.h[1],\n h2 = this.h[2],\n h3 = this.h[3],\n h4 = this.h[4],\n h5 = this.h[5],\n h6 = this.h[6],\n h7 = this.h[7],\n h8 = this.h[8],\n h9 = this.h[9];\n\n var r0 = this.r[0],\n r1 = this.r[1],\n r2 = this.r[2],\n r3 = this.r[3],\n r4 = this.r[4],\n r5 = this.r[5],\n r6 = this.r[6],\n r7 = this.r[7],\n r8 = this.r[8],\n r9 = this.r[9];\n\n while (bytes >= 16) {\n t0 = m[mpos+ 0] & 0xff | (m[mpos+ 1] & 0xff) << 8; h0 += ( t0 ) & 0x1fff;\n t1 = m[mpos+ 2] & 0xff | (m[mpos+ 3] & 0xff) << 8; h1 += ((t0 >>> 13) | (t1 << 3)) & 0x1fff;\n t2 = m[mpos+ 4] & 0xff | (m[mpos+ 5] & 0xff) << 8; h2 += ((t1 >>> 10) | (t2 << 6)) & 0x1fff;\n t3 = m[mpos+ 6] & 0xff | (m[mpos+ 7] & 0xff) << 8; h3 += ((t2 >>> 7) | (t3 << 9)) & 0x1fff;\n t4 = m[mpos+ 8] & 0xff | (m[mpos+ 9] & 0xff) << 8; h4 += ((t3 >>> 4) | (t4 << 12)) & 0x1fff;\n h5 += ((t4 >>> 1)) & 0x1fff;\n t5 = m[mpos+10] & 0xff | (m[mpos+11] & 0xff) << 8; h6 += ((t4 >>> 14) | (t5 << 2)) & 0x1fff;\n t6 = m[mpos+12] & 0xff | (m[mpos+13] & 0xff) << 8; h7 += ((t5 >>> 11) | (t6 << 5)) & 0x1fff;\n t7 = m[mpos+14] & 0xff | (m[mpos+15] & 0xff) << 8; h8 += ((t6 >>> 8) | (t7 << 8)) & 0x1fff;\n h9 += ((t7 >>> 5)) | hibit;\n\n c = 0;\n\n d0 = c;\n d0 += h0 * r0;\n d0 += h1 * (5 * r9);\n d0 += h2 * (5 * r8);\n d0 += h3 * (5 * r7);\n d0 += h4 * (5 * r6);\n c = (d0 >>> 13); d0 &= 0x1fff;\n d0 += h5 * (5 * r5);\n d0 += h6 * (5 * r4);\n d0 += h7 * (5 * r3);\n d0 += h8 * (5 * r2);\n d0 += h9 * (5 * r1);\n c += (d0 >>> 13); d0 &= 0x1fff;\n\n d1 = c;\n d1 += h0 * r1;\n d1 += h1 * r0;\n d1 += h2 * (5 * r9);\n d1 += h3 * (5 * r8);\n d1 += h4 * (5 * r7);\n c = (d1 >>> 13); d1 &= 0x1fff;\n d1 += h5 * (5 * r6);\n d1 += h6 * (5 * r5);\n d1 += h7 * (5 * r4);\n d1 += h8 * (5 * r3);\n d1 += h9 * (5 * r2);\n c += (d1 >>> 13); d1 &= 0x1fff;\n\n d2 = c;\n d2 += h0 * r2;\n d2 += h1 * r1;\n d2 += h2 * r0;\n d2 += h3 * (5 * r9);\n d2 += h4 * (5 * r8);\n c = (d2 >>> 13); d2 &= 0x1fff;\n d2 += h5 * (5 * r7);\n d2 += h6 * (5 * r6);\n d2 += h7 * (5 * r5);\n d2 += h8 * (5 * r4);\n d2 += h9 * (5 * r3);\n c += (d2 >>> 13); d2 &= 0x1fff;\n\n d3 = c;\n d3 += h0 * r3;\n d3 += h1 * r2;\n d3 += h2 * r1;\n d3 += h3 * r0;\n d3 += h4 * (5 * r9);\n c = (d3 >>> 13); d3 &= 0x1fff;\n d3 += h5 * (5 * r8);\n d3 += h6 * (5 * r7);\n d3 += h7 * (5 * r6);\n d3 += h8 * (5 * r5);\n d3 += h9 * (5 * r4);\n c += (d3 >>> 13); d3 &= 0x1fff;\n\n d4 = c;\n d4 += h0 * r4;\n d4 += h1 * r3;\n d4 += h2 * r2;\n d4 += h3 * r1;\n d4 += h4 * r0;\n c = (d4 >>> 13); d4 &= 0x1fff;\n d4 += h5 * (5 * r9);\n d4 += h6 * (5 * r8);\n d4 += h7 * (5 * r7);\n d4 += h8 * (5 * r6);\n d4 += h9 * (5 * r5);\n c += (d4 >>> 13); d4 &= 0x1fff;\n\n d5 = c;\n d5 += h0 * r5;\n d5 += h1 * r4;\n d5 += h2 * r3;\n d5 += h3 * r2;\n d5 += h4 * r1;\n c = (d5 >>> 13); d5 &= 0x1fff;\n d5 += h5 * r0;\n d5 += h6 * (5 * r9);\n d5 += h7 * (5 * r8);\n d5 += h8 * (5 * r7);\n d5 += h9 * (5 * r6);\n c += (d5 >>> 13); d5 &= 0x1fff;\n\n d6 = c;\n d6 += h0 * r6;\n d6 += h1 * r5;\n d6 += h2 * r4;\n d6 += h3 * r3;\n d6 += h4 * r2;\n c = (d6 >>> 13); d6 &= 0x1fff;\n d6 += h5 * r1;\n d6 += h6 * r0;\n d6 += h7 * (5 * r9);\n d6 += h8 * (5 * r8);\n d6 += h9 * (5 * r7);\n c += (d6 >>> 13); d6 &= 0x1fff;\n\n d7 = c;\n d7 += h0 * r7;\n d7 += h1 * r6;\n d7 += h2 * r5;\n d7 += h3 * r4;\n d7 += h4 * r3;\n c = (d7 >>> 13); d7 &= 0x1fff;\n d7 += h5 * r2;\n d7 += h6 * r1;\n d7 += h7 * r0;\n d7 += h8 * (5 * r9);\n d7 += h9 * (5 * r8);\n c += (d7 >>> 13); d7 &= 0x1fff;\n\n d8 = c;\n d8 += h0 * r8;\n d8 += h1 * r7;\n d8 += h2 * r6;\n d8 += h3 * r5;\n d8 += h4 * r4;\n c = (d8 >>> 13); d8 &= 0x1fff;\n d8 += h5 * r3;\n d8 += h6 * r2;\n d8 += h7 * r1;\n d8 += h8 * r0;\n d8 += h9 * (5 * r9);\n c += (d8 >>> 13); d8 &= 0x1fff;\n\n d9 = c;\n d9 += h0 * r9;\n d9 += h1 * r8;\n d9 += h2 * r7;\n d9 += h3 * r6;\n d9 += h4 * r5;\n c = (d9 >>> 13); d9 &= 0x1fff;\n d9 += h5 * r4;\n d9 += h6 * r3;\n d9 += h7 * r2;\n d9 += h8 * r1;\n d9 += h9 * r0;\n c += (d9 >>> 13); d9 &= 0x1fff;\n\n c = (((c << 2) + c)) | 0;\n c = (c + d0) | 0;\n d0 = c & 0x1fff;\n c = (c >>> 13);\n d1 += c;\n\n h0 = d0;\n h1 = d1;\n h2 = d2;\n h3 = d3;\n h4 = d4;\n h5 = d5;\n h6 = d6;\n h7 = d7;\n h8 = d8;\n h9 = d9;\n\n mpos += 16;\n bytes -= 16;\n }\n this.h[0] = h0;\n this.h[1] = h1;\n this.h[2] = h2;\n this.h[3] = h3;\n this.h[4] = h4;\n this.h[5] = h5;\n this.h[6] = h6;\n this.h[7] = h7;\n this.h[8] = h8;\n this.h[9] = h9;\n};\n\npoly1305.prototype.finish = function(mac, macpos) {\n var g = new Uint16Array(10);\n var c, mask, f, i;\n\n if (this.leftover) {\n i = this.leftover;\n this.buffer[i++] = 1;\n for (; i < 16; i++) this.buffer[i] = 0;\n this.fin = 1;\n this.blocks(this.buffer, 0, 16);\n }\n\n c = this.h[1] >>> 13;\n this.h[1] &= 0x1fff;\n for (i = 2; i < 10; i++) {\n this.h[i] += c;\n c = this.h[i] >>> 13;\n this.h[i] &= 0x1fff;\n }\n this.h[0] += (c * 5);\n c = this.h[0] >>> 13;\n this.h[0] &= 0x1fff;\n this.h[1] += c;\n c = this.h[1] >>> 13;\n this.h[1] &= 0x1fff;\n this.h[2] += c;\n\n g[0] = this.h[0] + 5;\n c = g[0] >>> 13;\n g[0] &= 0x1fff;\n for (i = 1; i < 10; i++) {\n g[i] = this.h[i] + c;\n c = g[i] >>> 13;\n g[i] &= 0x1fff;\n }\n g[9] -= (1 << 13);\n\n mask = (c ^ 1) - 1;\n for (i = 0; i < 10; i++) g[i] &= mask;\n mask = ~mask;\n for (i = 0; i < 10; i++) this.h[i] = (this.h[i] & mask) | g[i];\n\n this.h[0] = ((this.h[0] ) | (this.h[1] << 13) ) & 0xffff;\n this.h[1] = ((this.h[1] >>> 3) | (this.h[2] << 10) ) & 0xffff;\n this.h[2] = ((this.h[2] >>> 6) | (this.h[3] << 7) ) & 0xffff;\n this.h[3] = ((this.h[3] >>> 9) | (this.h[4] << 4) ) & 0xffff;\n this.h[4] = ((this.h[4] >>> 12) | (this.h[5] << 1) | (this.h[6] << 14)) & 0xffff;\n this.h[5] = ((this.h[6] >>> 2) | (this.h[7] << 11) ) & 0xffff;\n this.h[6] = ((this.h[7] >>> 5) | (this.h[8] << 8) ) & 0xffff;\n this.h[7] = ((this.h[8] >>> 8) | (this.h[9] << 5) ) & 0xffff;\n\n f = this.h[0] + this.pad[0];\n this.h[0] = f & 0xffff;\n for (i = 1; i < 8; i++) {\n f = (((this.h[i] + this.pad[i]) | 0) + (f >>> 16)) | 0;\n this.h[i] = f & 0xffff;\n }\n\n mac[macpos+ 0] = (this.h[0] >>> 0) & 0xff;\n mac[macpos+ 1] = (this.h[0] >>> 8) & 0xff;\n mac[macpos+ 2] = (this.h[1] >>> 0) & 0xff;\n mac[macpos+ 3] = (this.h[1] >>> 8) & 0xff;\n mac[macpos+ 4] = (this.h[2] >>> 0) & 0xff;\n mac[macpos+ 5] = (this.h[2] >>> 8) & 0xff;\n mac[macpos+ 6] = (this.h[3] >>> 0) & 0xff;\n mac[macpos+ 7] = (this.h[3] >>> 8) & 0xff;\n mac[macpos+ 8] = (this.h[4] >>> 0) & 0xff;\n mac[macpos+ 9] = (this.h[4] >>> 8) & 0xff;\n mac[macpos+10] = (this.h[5] >>> 0) & 0xff;\n mac[macpos+11] = (this.h[5] >>> 8) & 0xff;\n mac[macpos+12] = (this.h[6] >>> 0) & 0xff;\n mac[macpos+13] = (this.h[6] >>> 8) & 0xff;\n mac[macpos+14] = (this.h[7] >>> 0) & 0xff;\n mac[macpos+15] = (this.h[7] >>> 8) & 0xff;\n};\n\npoly1305.prototype.update = function(m, mpos, bytes) {\n var i, want;\n\n if (this.leftover) {\n want = (16 - this.leftover);\n if (want > bytes)\n want = bytes;\n for (i = 0; i < want; i++)\n this.buffer[this.leftover + i] = m[mpos+i];\n bytes -= want;\n mpos += want;\n this.leftover += want;\n if (this.leftover < 16)\n return;\n this.blocks(this.buffer, 0, 16);\n this.leftover = 0;\n }\n\n if (bytes >= 16) {\n want = bytes - (bytes % 16);\n this.blocks(m, mpos, want);\n mpos += want;\n bytes -= want;\n }\n\n if (bytes) {\n for (i = 0; i < bytes; i++)\n this.buffer[this.leftover + i] = m[mpos+i];\n this.leftover += bytes;\n }\n};\n\nfunction crypto_onetimeauth(out, outpos, m, mpos, n, k) {\n var s = new poly1305(k);\n s.update(m, mpos, n);\n s.finish(out, outpos);\n return 0;\n}\n\nfunction crypto_onetimeauth_verify(h, hpos, m, mpos, n, k) {\n var x = new Uint8Array(16);\n crypto_onetimeauth(x,0,m,mpos,n,k);\n return crypto_verify_16(h,hpos,x,0);\n}\n\nfunction crypto_secretbox(c,m,d,n,k) {\n var i;\n if (d < 32) return -1;\n crypto_stream_xor(c,0,m,0,d,n,k);\n crypto_onetimeauth(c, 16, c, 32, d - 32, c);\n for (i = 0; i < 16; i++) c[i] = 0;\n return 0;\n}\n\nfunction crypto_secretbox_open(m,c,d,n,k) {\n var i;\n var x = new Uint8Array(32);\n if (d < 32) return -1;\n crypto_stream(x,0,32,n,k);\n if (crypto_onetimeauth_verify(c, 16,c, 32,d - 32,x) !== 0) return -1;\n crypto_stream_xor(m,0,c,0,d,n,k);\n for (i = 0; i < 32; i++) m[i] = 0;\n return 0;\n}\n\nfunction set25519(r, a) {\n var i;\n for (i = 0; i < 16; i++) r[i] = a[i]|0;\n}\n\nfunction car25519(o) {\n var i, v, c = 1;\n for (i = 0; i < 16; i++) {\n v = o[i] + c + 65535;\n c = Math.floor(v / 65536);\n o[i] = v - c * 65536;\n }\n o[0] += c-1 + 37 * (c-1);\n}\n\nfunction sel25519(p, q, b) {\n var t, c = ~(b-1);\n for (var i = 0; i < 16; i++) {\n t = c & (p[i] ^ q[i]);\n p[i] ^= t;\n q[i] ^= t;\n }\n}\n\nfunction pack25519(o, n) {\n var i, j, b;\n var m = gf(), t = gf();\n for (i = 0; i < 16; i++) t[i] = n[i];\n car25519(t);\n car25519(t);\n car25519(t);\n for (j = 0; j < 2; j++) {\n m[0] = t[0] - 0xffed;\n for (i = 1; i < 15; i++) {\n m[i] = t[i] - 0xffff - ((m[i-1]>>16) & 1);\n m[i-1] &= 0xffff;\n }\n m[15] = t[15] - 0x7fff - ((m[14]>>16) & 1);\n b = (m[15]>>16) & 1;\n m[14] &= 0xffff;\n sel25519(t, m, 1-b);\n }\n for (i = 0; i < 16; i++) {\n o[2*i] = t[i] & 0xff;\n o[2*i+1] = t[i]>>8;\n }\n}\n\nfunction neq25519(a, b) {\n var c = new Uint8Array(32), d = new Uint8Array(32);\n pack25519(c, a);\n pack25519(d, b);\n return crypto_verify_32(c, 0, d, 0);\n}\n\nfunction par25519(a) {\n var d = new Uint8Array(32);\n pack25519(d, a);\n return d[0] & 1;\n}\n\nfunction unpack25519(o, n) {\n var i;\n for (i = 0; i < 16; i++) o[i] = n[2*i] + (n[2*i+1] << 8);\n o[15] &= 0x7fff;\n}\n\nfunction A(o, a, b) {\n for (var i = 0; i < 16; i++) o[i] = a[i] + b[i];\n}\n\nfunction Z(o, a, b) {\n for (var i = 0; i < 16; i++) o[i] = a[i] - b[i];\n}\n\nfunction M(o, a, b) {\n var v, c,\n t0 = 0, t1 = 0, t2 = 0, t3 = 0, t4 = 0, t5 = 0, t6 = 0, t7 = 0,\n t8 = 0, t9 = 0, t10 = 0, t11 = 0, t12 = 0, t13 = 0, t14 = 0, t15 = 0,\n t16 = 0, t17 = 0, t18 = 0, t19 = 0, t20 = 0, t21 = 0, t22 = 0, t23 = 0,\n t24 = 0, t25 = 0, t26 = 0, t27 = 0, t28 = 0, t29 = 0, t30 = 0,\n b0 = b[0],\n b1 = b[1],\n b2 = b[2],\n b3 = b[3],\n b4 = b[4],\n b5 = b[5],\n b6 = b[6],\n b7 = b[7],\n b8 = b[8],\n b9 = b[9],\n b10 = b[10],\n b11 = b[11],\n b12 = b[12],\n b13 = b[13],\n b14 = b[14],\n b15 = b[15];\n\n v = a[0];\n t0 += v * b0;\n t1 += v * b1;\n t2 += v * b2;\n t3 += v * b3;\n t4 += v * b4;\n t5 += v * b5;\n t6 += v * b6;\n t7 += v * b7;\n t8 += v * b8;\n t9 += v * b9;\n t10 += v * b10;\n t11 += v * b11;\n t12 += v * b12;\n t13 += v * b13;\n t14 += v * b14;\n t15 += v * b15;\n v = a[1];\n t1 += v * b0;\n t2 += v * b1;\n t3 += v * b2;\n t4 += v * b3;\n t5 += v * b4;\n t6 += v * b5;\n t7 += v * b6;\n t8 += v * b7;\n t9 += v * b8;\n t10 += v * b9;\n t11 += v * b10;\n t12 += v * b11;\n t13 += v * b12;\n t14 += v * b13;\n t15 += v * b14;\n t16 += v * b15;\n v = a[2];\n t2 += v * b0;\n t3 += v * b1;\n t4 += v * b2;\n t5 += v * b3;\n t6 += v * b4;\n t7 += v * b5;\n t8 += v * b6;\n t9 += v * b7;\n t10 += v * b8;\n t11 += v * b9;\n t12 += v * b10;\n t13 += v * b11;\n t14 += v * b12;\n t15 += v * b13;\n t16 += v * b14;\n t17 += v * b15;\n v = a[3];\n t3 += v * b0;\n t4 += v * b1;\n t5 += v * b2;\n t6 += v * b3;\n t7 += v * b4;\n t8 += v * b5;\n t9 += v * b6;\n t10 += v * b7;\n t11 += v * b8;\n t12 += v * b9;\n t13 += v * b10;\n t14 += v * b11;\n t15 += v * b12;\n t16 += v * b13;\n t17 += v * b14;\n t18 += v * b15;\n v = a[4];\n t4 += v * b0;\n t5 += v * b1;\n t6 += v * b2;\n t7 += v * b3;\n t8 += v * b4;\n t9 += v * b5;\n t10 += v * b6;\n t11 += v * b7;\n t12 += v * b8;\n t13 += v * b9;\n t14 += v * b10;\n t15 += v * b11;\n t16 += v * b12;\n t17 += v * b13;\n t18 += v * b14;\n t19 += v * b15;\n v = a[5];\n t5 += v * b0;\n t6 += v * b1;\n t7 += v * b2;\n t8 += v * b3;\n t9 += v * b4;\n t10 += v * b5;\n t11 += v * b6;\n t12 += v * b7;\n t13 += v * b8;\n t14 += v * b9;\n t15 += v * b10;\n t16 += v * b11;\n t17 += v * b12;\n t18 += v * b13;\n t19 += v * b14;\n t20 += v * b15;\n v = a[6];\n t6 += v * b0;\n t7 += v * b1;\n t8 += v * b2;\n t9 += v * b3;\n t10 += v * b4;\n t11 += v * b5;\n t12 += v * b6;\n t13 += v * b7;\n t14 += v * b8;\n t15 += v * b9;\n t16 += v * b10;\n t17 += v * b11;\n t18 += v * b12;\n t19 += v * b13;\n t20 += v * b14;\n t21 += v * b15;\n v = a[7];\n t7 += v * b0;\n t8 += v * b1;\n t9 += v * b2;\n t10 += v * b3;\n t11 += v * b4;\n t12 += v * b5;\n t13 += v * b6;\n t14 += v * b7;\n t15 += v * b8;\n t16 += v * b9;\n t17 += v * b10;\n t18 += v * b11;\n t19 += v * b12;\n t20 += v * b13;\n t21 += v * b14;\n t22 += v * b15;\n v = a[8];\n t8 += v * b0;\n t9 += v * b1;\n t10 += v * b2;\n t11 += v * b3;\n t12 += v * b4;\n t13 += v * b5;\n t14 += v * b6;\n t15 += v * b7;\n t16 += v * b8;\n t17 += v * b9;\n t18 += v * b10;\n t19 += v * b11;\n t20 += v * b12;\n t21 += v * b13;\n t22 += v * b14;\n t23 += v * b15;\n v = a[9];\n t9 += v * b0;\n t10 += v * b1;\n t11 += v * b2;\n t12 += v * b3;\n t13 += v * b4;\n t14 += v * b5;\n t15 += v * b6;\n t16 += v * b7;\n t17 += v * b8;\n t18 += v * b9;\n t19 += v * b10;\n t20 += v * b11;\n t21 += v * b12;\n t22 += v * b13;\n t23 += v * b14;\n t24 += v * b15;\n v = a[10];\n t10 += v * b0;\n t11 += v * b1;\n t12 += v * b2;\n t13 += v * b3;\n t14 += v * b4;\n t15 += v * b5;\n t16 += v * b6;\n t17 += v * b7;\n t18 += v * b8;\n t19 += v * b9;\n t20 += v * b10;\n t21 += v * b11;\n t22 += v * b12;\n t23 += v * b13;\n t24 += v * b14;\n t25 += v * b15;\n v = a[11];\n t11 += v * b0;\n t12 += v * b1;\n t13 += v * b2;\n t14 += v * b3;\n t15 += v * b4;\n t16 += v * b5;\n t17 += v * b6;\n t18 += v * b7;\n t19 += v * b8;\n t20 += v * b9;\n t21 += v * b10;\n t22 += v * b11;\n t23 += v * b12;\n t24 += v * b13;\n t25 += v * b14;\n t26 += v * b15;\n v = a[12];\n t12 += v * b0;\n t13 += v * b1;\n t14 += v * b2;\n t15 += v * b3;\n t16 += v * b4;\n t17 += v * b5;\n t18 += v * b6;\n t19 += v * b7;\n t20 += v * b8;\n t21 += v * b9;\n t22 += v * b10;\n t23 += v * b11;\n t24 += v * b12;\n t25 += v * b13;\n t26 += v * b14;\n t27 += v * b15;\n v = a[13];\n t13 += v * b0;\n t14 += v * b1;\n t15 += v * b2;\n t16 += v * b3;\n t17 += v * b4;\n t18 += v * b5;\n t19 += v * b6;\n t20 += v * b7;\n t21 += v * b8;\n t22 += v * b9;\n t23 += v * b10;\n t24 += v * b11;\n t25 += v * b12;\n t26 += v * b13;\n t27 += v * b14;\n t28 += v * b15;\n v = a[14];\n t14 += v * b0;\n t15 += v * b1;\n t16 += v * b2;\n t17 += v * b3;\n t18 += v * b4;\n t19 += v * b5;\n t20 += v * b6;\n t21 += v * b7;\n t22 += v * b8;\n t23 += v * b9;\n t24 += v * b10;\n t25 += v * b11;\n t26 += v * b12;\n t27 += v * b13;\n t28 += v * b14;\n t29 += v * b15;\n v = a[15];\n t15 += v * b0;\n t16 += v * b1;\n t17 += v * b2;\n t18 += v * b3;\n t19 += v * b4;\n t20 += v * b5;\n t21 += v * b6;\n t22 += v * b7;\n t23 += v * b8;\n t24 += v * b9;\n t25 += v * b10;\n t26 += v * b11;\n t27 += v * b12;\n t28 += v * b13;\n t29 += v * b14;\n t30 += v * b15;\n\n t0 += 38 * t16;\n t1 += 38 * t17;\n t2 += 38 * t18;\n t3 += 38 * t19;\n t4 += 38 * t20;\n t5 += 38 * t21;\n t6 += 38 * t22;\n t7 += 38 * t23;\n t8 += 38 * t24;\n t9 += 38 * t25;\n t10 += 38 * t26;\n t11 += 38 * t27;\n t12 += 38 * t28;\n t13 += 38 * t29;\n t14 += 38 * t30;\n // t15 left as is\n\n // first car\n c = 1;\n v = t0 + c + 65535; c = Math.floor(v / 65536); t0 = v - c * 65536;\n v = t1 + c + 65535; c = Math.floor(v / 65536); t1 = v - c * 65536;\n v = t2 + c + 65535; c = Math.floor(v / 65536); t2 = v - c * 65536;\n v = t3 + c + 65535; c = Math.floor(v / 65536); t3 = v - c * 65536;\n v = t4 + c + 65535; c = Math.floor(v / 65536); t4 = v - c * 65536;\n v = t5 + c + 65535; c = Math.floor(v / 65536); t5 = v - c * 65536;\n v = t6 + c + 65535; c = Math.floor(v / 65536); t6 = v - c * 65536;\n v = t7 + c + 65535; c = Math.floor(v / 65536); t7 = v - c * 65536;\n v = t8 + c + 65535; c = Math.floor(v / 65536); t8 = v - c * 65536;\n v = t9 + c + 65535; c = Math.floor(v / 65536); t9 = v - c * 65536;\n v = t10 + c + 65535; c = Math.floor(v / 65536); t10 = v - c * 65536;\n v = t11 + c + 65535; c = Math.floor(v / 65536); t11 = v - c * 65536;\n v = t12 + c + 65535; c = Math.floor(v / 65536); t12 = v - c * 65536;\n v = t13 + c + 65535; c = Math.floor(v / 65536); t13 = v - c * 65536;\n v = t14 + c + 65535; c = Math.floor(v / 65536); t14 = v - c * 65536;\n v = t15 + c + 65535; c = Math.floor(v / 65536); t15 = v - c * 65536;\n t0 += c-1 + 37 * (c-1);\n\n // second car\n c = 1;\n v = t0 + c + 65535; c = Math.floor(v / 65536); t0 = v - c * 65536;\n v = t1 + c + 65535; c = Math.floor(v / 65536); t1 = v - c * 65536;\n v = t2 + c + 65535; c = Math.floor(v / 65536); t2 = v - c * 65536;\n v = t3 + c + 65535; c = Math.floor(v / 65536); t3 = v - c * 65536;\n v = t4 + c + 65535; c = Math.floor(v / 65536); t4 = v - c * 65536;\n v = t5 + c + 65535; c = Math.floor(v / 65536); t5 = v - c * 65536;\n v = t6 + c + 65535; c = Math.floor(v / 65536); t6 = v - c * 65536;\n v = t7 + c + 65535; c = Math.floor(v / 65536); t7 = v - c * 65536;\n v = t8 + c + 65535; c = Math.floor(v / 65536); t8 = v - c * 65536;\n v = t9 + c + 65535; c = Math.floor(v / 65536); t9 = v - c * 65536;\n v = t10 + c + 65535; c = Math.floor(v / 65536); t10 = v - c * 65536;\n v = t11 + c + 65535; c = Math.floor(v / 65536); t11 = v - c * 65536;\n v = t12 + c + 65535; c = Math.floor(v / 65536); t12 = v - c * 65536;\n v = t13 + c + 65535; c = Math.floor(v / 65536); t13 = v - c * 65536;\n v = t14 + c + 65535; c = Math.floor(v / 65536); t14 = v - c * 65536;\n v = t15 + c + 65535; c = Math.floor(v / 65536); t15 = v - c * 65536;\n t0 += c-1 + 37 * (c-1);\n\n o[ 0] = t0;\n o[ 1] = t1;\n o[ 2] = t2;\n o[ 3] = t3;\n o[ 4] = t4;\n o[ 5] = t5;\n o[ 6] = t6;\n o[ 7] = t7;\n o[ 8] = t8;\n o[ 9] = t9;\n o[10] = t10;\n o[11] = t11;\n o[12] = t12;\n o[13] = t13;\n o[14] = t14;\n o[15] = t15;\n}\n\nfunction S(o, a) {\n M(o, a, a);\n}\n\nfunction inv25519(o, i) {\n var c = gf();\n var a;\n for (a = 0; a < 16; a++) c[a] = i[a];\n for (a = 253; a >= 0; a--) {\n S(c, c);\n if(a !== 2 && a !== 4) M(c, c, i);\n }\n for (a = 0; a < 16; a++) o[a] = c[a];\n}\n\nfunction pow2523(o, i) {\n var c = gf();\n var a;\n for (a = 0; a < 16; a++) c[a] = i[a];\n for (a = 250; a >= 0; a--) {\n S(c, c);\n if(a !== 1) M(c, c, i);\n }\n for (a = 0; a < 16; a++) o[a] = c[a];\n}\n\nfunction crypto_scalarmult(q, n, p) {\n var z = new Uint8Array(32);\n var x = new Float64Array(80), r, i;\n var a = gf(), b = gf(), c = gf(),\n d = gf(), e = gf(), f = gf();\n for (i = 0; i < 31; i++) z[i] = n[i];\n z[31]=(n[31]&127)|64;\n z[0]&=248;\n unpack25519(x,p);\n for (i = 0; i < 16; i++) {\n b[i]=x[i];\n d[i]=a[i]=c[i]=0;\n }\n a[0]=d[0]=1;\n for (i=254; i>=0; --i) {\n r=(z[i>>>3]>>>(i&7))&1;\n sel25519(a,b,r);\n sel25519(c,d,r);\n A(e,a,c);\n Z(a,a,c);\n A(c,b,d);\n Z(b,b,d);\n S(d,e);\n S(f,a);\n M(a,c,a);\n M(c,b,e);\n A(e,a,c);\n Z(a,a,c);\n S(b,a);\n Z(c,d,f);\n M(a,c,_121665);\n A(a,a,d);\n M(c,c,a);\n M(a,d,f);\n M(d,b,x);\n S(b,e);\n sel25519(a,b,r);\n sel25519(c,d,r);\n }\n for (i = 0; i < 16; i++) {\n x[i+16]=a[i];\n x[i+32]=c[i];\n x[i+48]=b[i];\n x[i+64]=d[i];\n }\n var x32 = x.subarray(32);\n var x16 = x.subarray(16);\n inv25519(x32,x32);\n M(x16,x16,x32);\n pack25519(q,x16);\n return 0;\n}\n\nfunction crypto_scalarmult_base(q, n) {\n return crypto_scalarmult(q, n, _9);\n}\n\nfunction crypto_box_keypair(y, x) {\n randombytes(x, 32);\n return crypto_scalarmult_base(y, x);\n}\n\nfunction crypto_box_beforenm(k, y, x) {\n var s = new Uint8Array(32);\n crypto_scalarmult(s, x, y);\n return crypto_core_hsalsa20(k, _0, s, sigma);\n}\n\nvar crypto_box_afternm = crypto_secretbox;\nvar crypto_box_open_afternm = crypto_secretbox_open;\n\nfunction crypto_box(c, m, d, n, y, x) {\n var k = new Uint8Array(32);\n crypto_box_beforenm(k, y, x);\n return crypto_box_afternm(c, m, d, n, k);\n}\n\nfunction crypto_box_open(m, c, d, n, y, x) {\n var k = new Uint8Array(32);\n crypto_box_beforenm(k, y, x);\n return crypto_box_open_afternm(m, c, d, n, k);\n}\n\nvar K = [\n 0x428a2f98, 0xd728ae22, 0x71374491, 0x23ef65cd,\n 0xb5c0fbcf, 0xec4d3b2f, 0xe9b5dba5, 0x8189dbbc,\n 0x3956c25b, 0xf348b538, 0x59f111f1, 0xb605d019,\n 0x923f82a4, 0xaf194f9b, 0xab1c5ed5, 0xda6d8118,\n 0xd807aa98, 0xa3030242, 0x12835b01, 0x45706fbe,\n 0x243185be, 0x4ee4b28c, 0x550c7dc3, 0xd5ffb4e2,\n 0x72be5d74, 0xf27b896f, 0x80deb1fe, 0x3b1696b1,\n 0x9bdc06a7, 0x25c71235, 0xc19bf174, 0xcf692694,\n 0xe49b69c1, 0x9ef14ad2, 0xefbe4786, 0x384f25e3,\n 0x0fc19dc6, 0x8b8cd5b5, 0x240ca1cc, 0x77ac9c65,\n 0x2de92c6f, 0x592b0275, 0x4a7484aa, 0x6ea6e483,\n 0x5cb0a9dc, 0xbd41fbd4, 0x76f988da, 0x831153b5,\n 0x983e5152, 0xee66dfab, 0xa831c66d, 0x2db43210,\n 0xb00327c8, 0x98fb213f, 0xbf597fc7, 0xbeef0ee4,\n 0xc6e00bf3, 0x3da88fc2, 0xd5a79147, 0x930aa725,\n 0x06ca6351, 0xe003826f, 0x14292967, 0x0a0e6e70,\n 0x27b70a85, 0x46d22ffc, 0x2e1b2138, 0x5c26c926,\n 0x4d2c6dfc, 0x5ac42aed, 0x53380d13, 0x9d95b3df,\n 0x650a7354, 0x8baf63de, 0x766a0abb, 0x3c77b2a8,\n 0x81c2c92e, 0x47edaee6, 0x92722c85, 0x1482353b,\n 0xa2bfe8a1, 0x4cf10364, 0xa81a664b, 0xbc423001,\n 0xc24b8b70, 0xd0f89791, 0xc76c51a3, 0x0654be30,\n 0xd192e819, 0xd6ef5218, 0xd6990624, 0x5565a910,\n 0xf40e3585, 0x5771202a, 0x106aa070, 0x32bbd1b8,\n 0x19a4c116, 0xb8d2d0c8, 0x1e376c08, 0x5141ab53,\n 0x2748774c, 0xdf8eeb99, 0x34b0bcb5, 0xe19b48a8,\n 0x391c0cb3, 0xc5c95a63, 0x4ed8aa4a, 0xe3418acb,\n 0x5b9cca4f, 0x7763e373, 0x682e6ff3, 0xd6b2b8a3,\n 0x748f82ee, 0x5defb2fc, 0x78a5636f, 0x43172f60,\n 0x84c87814, 0xa1f0ab72, 0x8cc70208, 0x1a6439ec,\n 0x90befffa, 0x23631e28, 0xa4506ceb, 0xde82bde9,\n 0xbef9a3f7, 0xb2c67915, 0xc67178f2, 0xe372532b,\n 0xca273ece, 0xea26619c, 0xd186b8c7, 0x21c0c207,\n 0xeada7dd6, 0xcde0eb1e, 0xf57d4f7f, 0xee6ed178,\n 0x06f067aa, 0x72176fba, 0x0a637dc5, 0xa2c898a6,\n 0x113f9804, 0xbef90dae, 0x1b710b35, 0x131c471b,\n 0x28db77f5, 0x23047d84, 0x32caab7b, 0x40c72493,\n 0x3c9ebe0a, 0x15c9bebc, 0x431d67c4, 0x9c100d4c,\n 0x4cc5d4be, 0xcb3e42b6, 0x597f299c, 0xfc657e2a,\n 0x5fcb6fab, 0x3ad6faec, 0x6c44198c, 0x4a475817\n];\n\nfunction crypto_hashblocks_hl(hh, hl, m, n) {\n var wh = new Int32Array(16), wl = new Int32Array(16),\n bh0, bh1, bh2, bh3, bh4, bh5, bh6, bh7,\n bl0, bl1, bl2, bl3, bl4, bl5, bl6, bl7,\n th, tl, i, j, h, l, a, b, c, d;\n\n var ah0 = hh[0],\n ah1 = hh[1],\n ah2 = hh[2],\n ah3 = hh[3],\n ah4 = hh[4],\n ah5 = hh[5],\n ah6 = hh[6],\n ah7 = hh[7],\n\n al0 = hl[0],\n al1 = hl[1],\n al2 = hl[2],\n al3 = hl[3],\n al4 = hl[4],\n al5 = hl[5],\n al6 = hl[6],\n al7 = hl[7];\n\n var pos = 0;\n while (n >= 128) {\n for (i = 0; i < 16; i++) {\n j = 8 * i + pos;\n wh[i] = (m[j+0] << 24) | (m[j+1] << 16) | (m[j+2] << 8) | m[j+3];\n wl[i] = (m[j+4] << 24) | (m[j+5] << 16) | (m[j+6] << 8) | m[j+7];\n }\n for (i = 0; i < 80; i++) {\n bh0 = ah0;\n bh1 = ah1;\n bh2 = ah2;\n bh3 = ah3;\n bh4 = ah4;\n bh5 = ah5;\n bh6 = ah6;\n bh7 = ah7;\n\n bl0 = al0;\n bl1 = al1;\n bl2 = al2;\n bl3 = al3;\n bl4 = al4;\n bl5 = al5;\n bl6 = al6;\n bl7 = al7;\n\n // add\n h = ah7;\n l = al7;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n // Sigma1\n h = ((ah4 >>> 14) | (al4 << (32-14))) ^ ((ah4 >>> 18) | (al4 << (32-18))) ^ ((al4 >>> (41-32)) | (ah4 << (32-(41-32))));\n l = ((al4 >>> 14) | (ah4 << (32-14))) ^ ((al4 >>> 18) | (ah4 << (32-18))) ^ ((ah4 >>> (41-32)) | (al4 << (32-(41-32))));\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // Ch\n h = (ah4 & ah5) ^ (~ah4 & ah6);\n l = (al4 & al5) ^ (~al4 & al6);\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // K\n h = K[i*2];\n l = K[i*2+1];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // w\n h = wh[i%16];\n l = wl[i%16];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n th = c & 0xffff | d << 16;\n tl = a & 0xffff | b << 16;\n\n // add\n h = th;\n l = tl;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n // Sigma0\n h = ((ah0 >>> 28) | (al0 << (32-28))) ^ ((al0 >>> (34-32)) | (ah0 << (32-(34-32)))) ^ ((al0 >>> (39-32)) | (ah0 << (32-(39-32))));\n l = ((al0 >>> 28) | (ah0 << (32-28))) ^ ((ah0 >>> (34-32)) | (al0 << (32-(34-32)))) ^ ((ah0 >>> (39-32)) | (al0 << (32-(39-32))));\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // Maj\n h = (ah0 & ah1) ^ (ah0 & ah2) ^ (ah1 & ah2);\n l = (al0 & al1) ^ (al0 & al2) ^ (al1 & al2);\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n bh7 = (c & 0xffff) | (d << 16);\n bl7 = (a & 0xffff) | (b << 16);\n\n // add\n h = bh3;\n l = bl3;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = th;\n l = tl;\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n bh3 = (c & 0xffff) | (d << 16);\n bl3 = (a & 0xffff) | (b << 16);\n\n ah1 = bh0;\n ah2 = bh1;\n ah3 = bh2;\n ah4 = bh3;\n ah5 = bh4;\n ah6 = bh5;\n ah7 = bh6;\n ah0 = bh7;\n\n al1 = bl0;\n al2 = bl1;\n al3 = bl2;\n al4 = bl3;\n al5 = bl4;\n al6 = bl5;\n al7 = bl6;\n al0 = bl7;\n\n if (i%16 === 15) {\n for (j = 0; j < 16; j++) {\n // add\n h = wh[j];\n l = wl[j];\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = wh[(j+9)%16];\n l = wl[(j+9)%16];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // sigma0\n th = wh[(j+1)%16];\n tl = wl[(j+1)%16];\n h = ((th >>> 1) | (tl << (32-1))) ^ ((th >>> 8) | (tl << (32-8))) ^ (th >>> 7);\n l = ((tl >>> 1) | (th << (32-1))) ^ ((tl >>> 8) | (th << (32-8))) ^ ((tl >>> 7) | (th << (32-7)));\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // sigma1\n th = wh[(j+14)%16];\n tl = wl[(j+14)%16];\n h = ((th >>> 19) | (tl << (32-19))) ^ ((tl >>> (61-32)) | (th << (32-(61-32)))) ^ (th >>> 6);\n l = ((tl >>> 19) | (th << (32-19))) ^ ((th >>> (61-32)) | (tl << (32-(61-32)))) ^ ((tl >>> 6) | (th << (32-6)));\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n wh[j] = (c & 0xffff) | (d << 16);\n wl[j] = (a & 0xffff) | (b << 16);\n }\n }\n }\n\n // add\n h = ah0;\n l = al0;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[0];\n l = hl[0];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[0] = ah0 = (c & 0xffff) | (d << 16);\n hl[0] = al0 = (a & 0xffff) | (b << 16);\n\n h = ah1;\n l = al1;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[1];\n l = hl[1];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[1] = ah1 = (c & 0xffff) | (d << 16);\n hl[1] = al1 = (a & 0xffff) | (b << 16);\n\n h = ah2;\n l = al2;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[2];\n l = hl[2];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[2] = ah2 = (c & 0xffff) | (d << 16);\n hl[2] = al2 = (a & 0xffff) | (b << 16);\n\n h = ah3;\n l = al3;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[3];\n l = hl[3];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[3] = ah3 = (c & 0xffff) | (d << 16);\n hl[3] = al3 = (a & 0xffff) | (b << 16);\n\n h = ah4;\n l = al4;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[4];\n l = hl[4];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[4] = ah4 = (c & 0xffff) | (d << 16);\n hl[4] = al4 = (a & 0xffff) | (b << 16);\n\n h = ah5;\n l = al5;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[5];\n l = hl[5];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[5] = ah5 = (c & 0xffff) | (d << 16);\n hl[5] = al5 = (a & 0xffff) | (b << 16);\n\n h = ah6;\n l = al6;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[6];\n l = hl[6];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[6] = ah6 = (c & 0xffff) | (d << 16);\n hl[6] = al6 = (a & 0xffff) | (b << 16);\n\n h = ah7;\n l = al7;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[7];\n l = hl[7];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[7] = ah7 = (c & 0xffff) | (d << 16);\n hl[7] = al7 = (a & 0xffff) | (b << 16);\n\n pos += 128;\n n -= 128;\n }\n\n return n;\n}\n\nfunction crypto_hash(out, m, n) {\n var hh = new Int32Array(8),\n hl = new Int32Array(8),\n x = new Uint8Array(256),\n i, b = n;\n\n hh[0] = 0x6a09e667;\n hh[1] = 0xbb67ae85;\n hh[2] = 0x3c6ef372;\n hh[3] = 0xa54ff53a;\n hh[4] = 0x510e527f;\n hh[5] = 0x9b05688c;\n hh[6] = 0x1f83d9ab;\n hh[7] = 0x5be0cd19;\n\n hl[0] = 0xf3bcc908;\n hl[1] = 0x84caa73b;\n hl[2] = 0xfe94f82b;\n hl[3] = 0x5f1d36f1;\n hl[4] = 0xade682d1;\n hl[5] = 0x2b3e6c1f;\n hl[6] = 0xfb41bd6b;\n hl[7] = 0x137e2179;\n\n crypto_hashblocks_hl(hh, hl, m, n);\n n %= 128;\n\n for (i = 0; i < n; i++) x[i] = m[b-n+i];\n x[n] = 128;\n\n n = 256-128*(n<112?1:0);\n x[n-9] = 0;\n ts64(x, n-8, (b / 0x20000000) | 0, b << 3);\n crypto_hashblocks_hl(hh, hl, x, n);\n\n for (i = 0; i < 8; i++) ts64(out, 8*i, hh[i], hl[i]);\n\n return 0;\n}\n\nfunction add(p, q) {\n var a = gf(), b = gf(), c = gf(),\n d = gf(), e = gf(), f = gf(),\n g = gf(), h = gf(), t = gf();\n\n Z(a, p[1], p[0]);\n Z(t, q[1], q[0]);\n M(a, a, t);\n A(b, p[0], p[1]);\n A(t, q[0], q[1]);\n M(b, b, t);\n M(c, p[3], q[3]);\n M(c, c, D2);\n M(d, p[2], q[2]);\n A(d, d, d);\n Z(e, b, a);\n Z(f, d, c);\n A(g, d, c);\n A(h, b, a);\n\n M(p[0], e, f);\n M(p[1], h, g);\n M(p[2], g, f);\n M(p[3], e, h);\n}\n\nfunction cswap(p, q, b) {\n var i;\n for (i = 0; i < 4; i++) {\n sel25519(p[i], q[i], b);\n }\n}\n\nfunction pack(r, p) {\n var tx = gf(), ty = gf(), zi = gf();\n inv25519(zi, p[2]);\n M(tx, p[0], zi);\n M(ty, p[1], zi);\n pack25519(r, ty);\n r[31] ^= par25519(tx) << 7;\n}\n\nfunction scalarmult(p, q, s) {\n var b, i;\n set25519(p[0], gf0);\n set25519(p[1], gf1);\n set25519(p[2], gf1);\n set25519(p[3], gf0);\n for (i = 255; i >= 0; --i) {\n b = (s[(i/8)|0] >> (i&7)) & 1;\n cswap(p, q, b);\n add(q, p);\n add(p, p);\n cswap(p, q, b);\n }\n}\n\nfunction scalarbase(p, s) {\n var q = [gf(), gf(), gf(), gf()];\n set25519(q[0], X);\n set25519(q[1], Y);\n set25519(q[2], gf1);\n M(q[3], X, Y);\n scalarmult(p, q, s);\n}\n\nfunction crypto_sign_keypair(pk, sk, seeded) {\n var d = new Uint8Array(64);\n var p = [gf(), gf(), gf(), gf()];\n var i;\n\n if (!seeded) randombytes(sk, 32);\n crypto_hash(d, sk, 32);\n d[0] &= 248;\n d[31] &= 127;\n d[31] |= 64;\n\n scalarbase(p, d);\n pack(pk, p);\n\n for (i = 0; i < 32; i++) sk[i+32] = pk[i];\n return 0;\n}\n\nvar L = new Float64Array([0xed, 0xd3, 0xf5, 0x5c, 0x1a, 0x63, 0x12, 0x58, 0xd6, 0x9c, 0xf7, 0xa2, 0xde, 0xf9, 0xde, 0x14, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x10]);\n\nfunction modL(r, x) {\n var carry, i, j, k;\n for (i = 63; i >= 32; --i) {\n carry = 0;\n for (j = i - 32, k = i - 12; j < k; ++j) {\n x[j] += carry - 16 * x[i] * L[j - (i - 32)];\n carry = Math.floor((x[j] + 128) / 256);\n x[j] -= carry * 256;\n }\n x[j] += carry;\n x[i] = 0;\n }\n carry = 0;\n for (j = 0; j < 32; j++) {\n x[j] += carry - (x[31] >> 4) * L[j];\n carry = x[j] >> 8;\n x[j] &= 255;\n }\n for (j = 0; j < 32; j++) x[j] -= carry * L[j];\n for (i = 0; i < 32; i++) {\n x[i+1] += x[i] >> 8;\n r[i] = x[i] & 255;\n }\n}\n\nfunction reduce(r) {\n var x = new Float64Array(64), i;\n for (i = 0; i < 64; i++) x[i] = r[i];\n for (i = 0; i < 64; i++) r[i] = 0;\n modL(r, x);\n}\n\n// Note: difference from C - smlen returned, not passed as argument.\nfunction crypto_sign(sm, m, n, sk) {\n var d = new Uint8Array(64), h = new Uint8Array(64), r = new Uint8Array(64);\n var i, j, x = new Float64Array(64);\n var p = [gf(), gf(), gf(), gf()];\n\n crypto_hash(d, sk, 32);\n d[0] &= 248;\n d[31] &= 127;\n d[31] |= 64;\n\n var smlen = n + 64;\n for (i = 0; i < n; i++) sm[64 + i] = m[i];\n for (i = 0; i < 32; i++) sm[32 + i] = d[32 + i];\n\n crypto_hash(r, sm.subarray(32), n+32);\n reduce(r);\n scalarbase(p, r);\n pack(sm, p);\n\n for (i = 32; i < 64; i++) sm[i] = sk[i];\n crypto_hash(h, sm, n + 64);\n reduce(h);\n\n for (i = 0; i < 64; i++) x[i] = 0;\n for (i = 0; i < 32; i++) x[i] = r[i];\n for (i = 0; i < 32; i++) {\n for (j = 0; j < 32; j++) {\n x[i+j] += h[i] * d[j];\n }\n }\n\n modL(sm.subarray(32), x);\n return smlen;\n}\n\nfunction unpackneg(r, p) {\n var t = gf(), chk = gf(), num = gf(),\n den = gf(), den2 = gf(), den4 = gf(),\n den6 = gf();\n\n set25519(r[2], gf1);\n unpack25519(r[1], p);\n S(num, r[1]);\n M(den, num, D);\n Z(num, num, r[2]);\n A(den, r[2], den);\n\n S(den2, den);\n S(den4, den2);\n M(den6, den4, den2);\n M(t, den6, num);\n M(t, t, den);\n\n pow2523(t, t);\n M(t, t, num);\n M(t, t, den);\n M(t, t, den);\n M(r[0], t, den);\n\n S(chk, r[0]);\n M(chk, chk, den);\n if (neq25519(chk, num)) M(r[0], r[0], I);\n\n S(chk, r[0]);\n M(chk, chk, den);\n if (neq25519(chk, num)) return -1;\n\n if (par25519(r[0]) === (p[31]>>7)) Z(r[0], gf0, r[0]);\n\n M(r[3], r[0], r[1]);\n return 0;\n}\n\nfunction crypto_sign_open(m, sm, n, pk) {\n var i;\n var t = new Uint8Array(32), h = new Uint8Array(64);\n var p = [gf(), gf(), gf(), gf()],\n q = [gf(), gf(), gf(), gf()];\n\n if (n < 64) return -1;\n\n if (unpackneg(q, pk)) return -1;\n\n for (i = 0; i < n; i++) m[i] = sm[i];\n for (i = 0; i < 32; i++) m[i+32] = pk[i];\n crypto_hash(h, m, n);\n reduce(h);\n scalarmult(p, q, h);\n\n scalarbase(q, sm.subarray(32));\n add(p, q);\n pack(t, p);\n\n n -= 64;\n if (crypto_verify_32(sm, 0, t, 0)) {\n for (i = 0; i < n; i++) m[i] = 0;\n return -1;\n }\n\n for (i = 0; i < n; i++) m[i] = sm[i + 64];\n return n;\n}\n\nvar crypto_secretbox_KEYBYTES = 32,\n crypto_secretbox_NONCEBYTES = 24,\n crypto_secretbox_ZEROBYTES = 32,\n crypto_secretbox_BOXZEROBYTES = 16,\n crypto_scalarmult_BYTES = 32,\n crypto_scalarmult_SCALARBYTES = 32,\n crypto_box_PUBLICKEYBYTES = 32,\n crypto_box_SECRETKEYBYTES = 32,\n crypto_box_BEFORENMBYTES = 32,\n crypto_box_NONCEBYTES = crypto_secretbox_NONCEBYTES,\n crypto_box_ZEROBYTES = crypto_secretbox_ZEROBYTES,\n crypto_box_BOXZEROBYTES = crypto_secretbox_BOXZEROBYTES,\n crypto_sign_BYTES = 64,\n crypto_sign_PUBLICKEYBYTES = 32,\n crypto_sign_SECRETKEYBYTES = 64,\n crypto_sign_SEEDBYTES = 32,\n crypto_hash_BYTES = 64;\n\nnacl.lowlevel = {\n crypto_core_hsalsa20: crypto_core_hsalsa20,\n crypto_stream_xor: crypto_stream_xor,\n crypto_stream: crypto_stream,\n crypto_stream_salsa20_xor: crypto_stream_salsa20_xor,\n crypto_stream_salsa20: crypto_stream_salsa20,\n crypto_onetimeauth: crypto_onetimeauth,\n crypto_onetimeauth_verify: crypto_onetimeauth_verify,\n crypto_verify_16: crypto_verify_16,\n crypto_verify_32: crypto_verify_32,\n crypto_secretbox: crypto_secretbox,\n crypto_secretbox_open: crypto_secretbox_open,\n crypto_scalarmult: crypto_scalarmult,\n crypto_scalarmult_base: crypto_scalarmult_base,\n crypto_box_beforenm: crypto_box_beforenm,\n crypto_box_afternm: crypto_box_afternm,\n crypto_box: crypto_box,\n crypto_box_open: crypto_box_open,\n crypto_box_keypair: crypto_box_keypair,\n crypto_hash: crypto_hash,\n crypto_sign: crypto_sign,\n crypto_sign_keypair: crypto_sign_keypair,\n crypto_sign_open: crypto_sign_open,\n\n crypto_secretbox_KEYBYTES: crypto_secretbox_KEYBYTES,\n crypto_secretbox_NONCEBYTES: crypto_secretbox_NONCEBYTES,\n crypto_secretbox_ZEROBYTES: crypto_secretbox_ZEROBYTES,\n crypto_secretbox_BOXZEROBYTES: crypto_secretbox_BOXZEROBYTES,\n crypto_scalarmult_BYTES: crypto_scalarmult_BYTES,\n crypto_scalarmult_SCALARBYTES: crypto_scalarmult_SCALARBYTES,\n crypto_box_PUBLICKEYBYTES: crypto_box_PUBLICKEYBYTES,\n crypto_box_SECRETKEYBYTES: crypto_box_SECRETKEYBYTES,\n crypto_box_BEFORENMBYTES: crypto_box_BEFORENMBYTES,\n crypto_box_NONCEBYTES: crypto_box_NONCEBYTES,\n crypto_box_ZEROBYTES: crypto_box_ZEROBYTES,\n crypto_box_BOXZEROBYTES: crypto_box_BOXZEROBYTES,\n crypto_sign_BYTES: crypto_sign_BYTES,\n crypto_sign_PUBLICKEYBYTES: crypto_sign_PUBLICKEYBYTES,\n crypto_sign_SECRETKEYBYTES: crypto_sign_SECRETKEYBYTES,\n crypto_sign_SEEDBYTES: crypto_sign_SEEDBYTES,\n crypto_hash_BYTES: crypto_hash_BYTES,\n\n gf: gf,\n D: D,\n L: L,\n pack25519: pack25519,\n unpack25519: unpack25519,\n M: M,\n A: A,\n S: S,\n Z: Z,\n pow2523: pow2523,\n add: add,\n set25519: set25519,\n modL: modL,\n scalarmult: scalarmult,\n scalarbase: scalarbase,\n};\n\n/* High-level API */\n\nfunction checkLengths(k, n) {\n if (k.length !== crypto_secretbox_KEYBYTES) throw new Error('bad key size');\n if (n.length !== crypto_secretbox_NONCEBYTES) throw new Error('bad nonce size');\n}\n\nfunction checkBoxLengths(pk, sk) {\n if (pk.length !== crypto_box_PUBLICKEYBYTES) throw new Error('bad public key size');\n if (sk.length !== crypto_box_SECRETKEYBYTES) throw new Error('bad secret key size');\n}\n\nfunction checkArrayTypes() {\n for (var i = 0; i < arguments.length; i++) {\n if (!(arguments[i] instanceof Uint8Array))\n throw new TypeError('unexpected type, use Uint8Array');\n }\n}\n\nfunction cleanup(arr) {\n for (var i = 0; i < arr.length; i++) arr[i] = 0;\n}\n\nnacl.randomBytes = function(n) {\n var b = new Uint8Array(n);\n randombytes(b, n);\n return b;\n};\n\nnacl.secretbox = function(msg, nonce, key) {\n checkArrayTypes(msg, nonce, key);\n checkLengths(key, nonce);\n var m = new Uint8Array(crypto_secretbox_ZEROBYTES + msg.length);\n var c = new Uint8Array(m.length);\n for (var i = 0; i < msg.length; i++) m[i+crypto_secretbox_ZEROBYTES] = msg[i];\n crypto_secretbox(c, m, m.length, nonce, key);\n return c.subarray(crypto_secretbox_BOXZEROBYTES);\n};\n\nnacl.secretbox.open = function(box, nonce, key) {\n checkArrayTypes(box, nonce, key);\n checkLengths(key, nonce);\n var c = new Uint8Array(crypto_secretbox_BOXZEROBYTES + box.length);\n var m = new Uint8Array(c.length);\n for (var i = 0; i < box.length; i++) c[i+crypto_secretbox_BOXZEROBYTES] = box[i];\n if (c.length < 32) return null;\n if (crypto_secretbox_open(m, c, c.length, nonce, key) !== 0) return null;\n return m.subarray(crypto_secretbox_ZEROBYTES);\n};\n\nnacl.secretbox.keyLength = crypto_secretbox_KEYBYTES;\nnacl.secretbox.nonceLength = crypto_secretbox_NONCEBYTES;\nnacl.secretbox.overheadLength = crypto_secretbox_BOXZEROBYTES;\n\nnacl.scalarMult = function(n, p) {\n checkArrayTypes(n, p);\n if (n.length !== crypto_scalarmult_SCALARBYTES) throw new Error('bad n size');\n if (p.length !== crypto_scalarmult_BYTES) throw new Error('bad p size');\n var q = new Uint8Array(crypto_scalarmult_BYTES);\n crypto_scalarmult(q, n, p);\n return q;\n};\n\nnacl.scalarMult.base = function(n) {\n checkArrayTypes(n);\n if (n.length !== crypto_scalarmult_SCALARBYTES) throw new Error('bad n size');\n var q = new Uint8Array(crypto_scalarmult_BYTES);\n crypto_scalarmult_base(q, n);\n return q;\n};\n\nnacl.scalarMult.scalarLength = crypto_scalarmult_SCALARBYTES;\nnacl.scalarMult.groupElementLength = crypto_scalarmult_BYTES;\n\nnacl.box = function(msg, nonce, publicKey, secretKey) {\n var k = nacl.box.before(publicKey, secretKey);\n return nacl.secretbox(msg, nonce, k);\n};\n\nnacl.box.before = function(publicKey, secretKey) {\n checkArrayTypes(publicKey, secretKey);\n checkBoxLengths(publicKey, secretKey);\n var k = new Uint8Array(crypto_box_BEFORENMBYTES);\n crypto_box_beforenm(k, publicKey, secretKey);\n return k;\n};\n\nnacl.box.after = nacl.secretbox;\n\nnacl.box.open = function(msg, nonce, publicKey, secretKey) {\n var k = nacl.box.before(publicKey, secretKey);\n return nacl.secretbox.open(msg, nonce, k);\n};\n\nnacl.box.open.after = nacl.secretbox.open;\n\nnacl.box.keyPair = function() {\n var pk = new Uint8Array(crypto_box_PUBLICKEYBYTES);\n var sk = new Uint8Array(crypto_box_SECRETKEYBYTES);\n crypto_box_keypair(pk, sk);\n return {publicKey: pk, secretKey: sk};\n};\n\nnacl.box.keyPair.fromSecretKey = function(secretKey) {\n checkArrayTypes(secretKey);\n if (secretKey.length !== crypto_box_SECRETKEYBYTES)\n throw new Error('bad secret key size');\n var pk = new Uint8Array(crypto_box_PUBLICKEYBYTES);\n crypto_scalarmult_base(pk, secretKey);\n return {publicKey: pk, secretKey: new Uint8Array(secretKey)};\n};\n\nnacl.box.publicKeyLength = crypto_box_PUBLICKEYBYTES;\nnacl.box.secretKeyLength = crypto_box_SECRETKEYBYTES;\nnacl.box.sharedKeyLength = crypto_box_BEFORENMBYTES;\nnacl.box.nonceLength = crypto_box_NONCEBYTES;\nnacl.box.overheadLength = nacl.secretbox.overheadLength;\n\nnacl.sign = function(msg, secretKey) {\n checkArrayTypes(msg, secretKey);\n if (secretKey.length !== crypto_sign_SECRETKEYBYTES)\n throw new Error('bad secret key size');\n var signedMsg = new Uint8Array(crypto_sign_BYTES+msg.length);\n crypto_sign(signedMsg, msg, msg.length, secretKey);\n return signedMsg;\n};\n\nnacl.sign.open = function(signedMsg, publicKey) {\n checkArrayTypes(signedMsg, publicKey);\n if (publicKey.length !== crypto_sign_PUBLICKEYBYTES)\n throw new Error('bad public key size');\n var tmp = new Uint8Array(signedMsg.length);\n var mlen = crypto_sign_open(tmp, signedMsg, signedMsg.length, publicKey);\n if (mlen < 0) return null;\n var m = new Uint8Array(mlen);\n for (var i = 0; i < m.length; i++) m[i] = tmp[i];\n return m;\n};\n\nnacl.sign.detached = function(msg, secretKey) {\n var signedMsg = nacl.sign(msg, secretKey);\n var sig = new Uint8Array(crypto_sign_BYTES);\n for (var i = 0; i < sig.length; i++) sig[i] = signedMsg[i];\n return sig;\n};\n\nnacl.sign.detached.verify = function(msg, sig, publicKey) {\n checkArrayTypes(msg, sig, publicKey);\n if (sig.length !== crypto_sign_BYTES)\n throw new Error('bad signature size');\n if (publicKey.length !== crypto_sign_PUBLICKEYBYTES)\n throw new Error('bad public key size');\n var sm = new Uint8Array(crypto_sign_BYTES + msg.length);\n var m = new Uint8Array(crypto_sign_BYTES + msg.length);\n var i;\n for (i = 0; i < crypto_sign_BYTES; i++) sm[i] = sig[i];\n for (i = 0; i < msg.length; i++) sm[i+crypto_sign_BYTES] = msg[i];\n return (crypto_sign_open(m, sm, sm.length, publicKey) >= 0);\n};\n\nnacl.sign.keyPair = function() {\n var pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);\n var sk = new Uint8Array(crypto_sign_SECRETKEYBYTES);\n crypto_sign_keypair(pk, sk);\n return {publicKey: pk, secretKey: sk};\n};\n\nnacl.sign.keyPair.fromSecretKey = function(secretKey) {\n checkArrayTypes(secretKey);\n if (secretKey.length !== crypto_sign_SECRETKEYBYTES)\n throw new Error('bad secret key size');\n var pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);\n for (var i = 0; i < pk.length; i++) pk[i] = secretKey[32+i];\n return {publicKey: pk, secretKey: new Uint8Array(secretKey)};\n};\n\nnacl.sign.keyPair.fromSeed = function(seed) {\n checkArrayTypes(seed);\n if (seed.length !== crypto_sign_SEEDBYTES)\n throw new Error('bad seed size');\n var pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);\n var sk = new Uint8Array(crypto_sign_SECRETKEYBYTES);\n for (var i = 0; i < 32; i++) sk[i] = seed[i];\n crypto_sign_keypair(pk, sk, true);\n return {publicKey: pk, secretKey: sk};\n};\n\nnacl.sign.publicKeyLength = crypto_sign_PUBLICKEYBYTES;\nnacl.sign.secretKeyLength = crypto_sign_SECRETKEYBYTES;\nnacl.sign.seedLength = crypto_sign_SEEDBYTES;\nnacl.sign.signatureLength = crypto_sign_BYTES;\n\nnacl.hash = function(msg) {\n checkArrayTypes(msg);\n var h = new Uint8Array(crypto_hash_BYTES);\n crypto_hash(h, msg, msg.length);\n return h;\n};\n\nnacl.hash.hashLength = crypto_hash_BYTES;\n\nnacl.verify = function(x, y) {\n checkArrayTypes(x, y);\n // Zero length arguments are considered not equal.\n if (x.length === 0 || y.length === 0) return false;\n if (x.length !== y.length) return false;\n return (vn(x, 0, y, 0, x.length) === 0) ? true : false;\n};\n\nnacl.setPRNG = function(fn) {\n randombytes = fn;\n};\n\n(function() {\n // Initialize PRNG if environment provides CSPRNG.\n // If not, methods calling randombytes will throw.\n var crypto = typeof self !== 'undefined' ? (self.crypto || self.msCrypto) : null;\n if (crypto && crypto.getRandomValues) {\n // Browsers.\n var QUOTA = 65536;\n nacl.setPRNG(function(x, n) {\n var i, v = new Uint8Array(n);\n for (i = 0; i < n; i += QUOTA) {\n crypto.getRandomValues(v.subarray(i, i + Math.min(n - i, QUOTA)));\n }\n for (i = 0; i < n; i++) x[i] = v[i];\n cleanup(v);\n });\n } else if (typeof require !== 'undefined') {\n // Node.js.\n crypto = require('crypto');\n if (crypto && crypto.randomBytes) {\n nacl.setPRNG(function(x, n) {\n var i, v = crypto.randomBytes(n);\n for (i = 0; i < n; i++) x[i] = v[i];\n cleanup(v);\n });\n }\n }\n})();\n\n})(typeof module !== 'undefined' && module.exports ? module.exports : (self.nacl = self.nacl || {}));\n","module.exports = require('./pusher-with-encryption').default;\n","import Pusher from './pusher';\nimport { Options, validateOptions } from './options';\nimport * as nacl from 'tweetnacl';\n\nexport default class PusherWithEncryption extends Pusher {\n constructor(app_key: string, options: Options) {\n Pusher.logToConsole = PusherWithEncryption.logToConsole;\n Pusher.log = PusherWithEncryption.log;\n\n validateOptions(options);\n options.nacl = nacl;\n super(app_key, options);\n }\n}\n"],"sourceRoot":""} \ No newline at end of file +{"version":3,"sources":["webpack://Pusher/webpack/bootstrap","webpack://Pusher/./src/core/utils/collections.ts","webpack://Pusher/./src/core/logger.ts","webpack://Pusher/./src/core/util.ts","webpack://Pusher/./src/core/events/dispatcher.ts","webpack://Pusher/./src/core/utils/timers/index.ts","webpack://Pusher/./src/core/defaults.ts","webpack://Pusher/./src/core/transports/url_schemes.ts","webpack://Pusher/./src/core/transports/transport_connection.ts","webpack://Pusher/./src/core/transports/transport.ts","webpack://Pusher/./src/runtimes/isomorphic/transports/transports.ts","webpack://Pusher/./src/core/transports/assistant_to_the_transport_manager.ts","webpack://Pusher/./src/core/connection/protocol/protocol.ts","webpack://Pusher/./src/core/connection/connection.ts","webpack://Pusher/./src/core/connection/handshake/index.ts","webpack://Pusher/./src/core/timeline/timeline_sender.ts","webpack://Pusher/./src/core/errors.ts","webpack://Pusher/./src/core/utils/url_store.ts","webpack://Pusher/./src/core/channels/channel.ts","webpack://Pusher/./src/core/channels/private_channel.ts","webpack://Pusher/./src/core/channels/members.ts","webpack://Pusher/./src/core/channels/presence_channel.ts","webpack://Pusher/./src/core/channels/encrypted_channel.ts","webpack://Pusher/./src/core/connection/connection_manager.ts","webpack://Pusher/./src/core/channels/channels.ts","webpack://Pusher/./src/core/utils/factory.ts","webpack://Pusher/./src/core/transports/transport_manager.ts","webpack://Pusher/./src/core/strategies/sequential_strategy.ts","webpack://Pusher/./src/core/strategies/best_connected_ever_strategy.ts","webpack://Pusher/./src/core/strategies/websocket_prioritized_cached_strategy.ts","webpack://Pusher/./src/core/strategies/delayed_strategy.ts","webpack://Pusher/./src/core/strategies/if_strategy.ts","webpack://Pusher/./src/core/strategies/first_connected_strategy.ts","webpack://Pusher/./src/runtimes/isomorphic/default_strategy.ts","webpack://Pusher/./src/core/http/http_request.ts","webpack://Pusher/./src/core/http/state.ts","webpack://Pusher/./src/core/http/http_socket.ts","webpack://Pusher/./src/core/http/http_streaming_socket.ts","webpack://Pusher/./src/core/http/http_polling_socket.ts","webpack://Pusher/./src/runtimes/isomorphic/http/http_xhr_request.ts","webpack://Pusher/./src/runtimes/isomorphic/runtime.ts","webpack://Pusher/./src/runtimes/isomorphic/transports/transport_connection_initializer.ts","webpack://Pusher/./src/runtimes/isomorphic/http/http.ts","webpack://Pusher/./src/runtimes/react-native/net_info.ts","webpack://Pusher/./src/core/auth/options.ts","webpack://Pusher/./src/runtimes/isomorphic/auth/xhr_auth.ts","webpack://Pusher/./src/runtimes/isomorphic/timeline/xhr_timeline.ts","webpack://Pusher/./src/runtimes/react-native/runtime.ts","webpack://Pusher/./src/core/timeline/level.ts","webpack://Pusher/./src/core/timeline/timeline.ts","webpack://Pusher/./src/core/strategies/transport_strategy.ts","webpack://Pusher/./src/core/strategies/strategy_builder.ts","webpack://Pusher/./src/core/auth/user_authenticator.ts","webpack://Pusher/./src/core/auth/channel_authorizer.ts","webpack://Pusher/./src/core/config.ts","webpack://Pusher/./src/core/auth/deprecated_channel_authorizer.ts","webpack://Pusher/./src/core/watchlist.ts","webpack://Pusher/./src/core/utils/flat_promise.ts","webpack://Pusher/./src/core/user.ts","webpack://Pusher/./src/core/pusher.ts","webpack://Pusher/(webpack)/buildin/global.js","webpack://Pusher/./src/core/options.ts","webpack://Pusher/./node_modules/@stablelib/base64/base64.ts","webpack://Pusher/./src/core/utils/timers/abstract_timer.ts","webpack://Pusher/external \"@react-native-community/netinfo\"","webpack://Pusher/./src/core/base64.ts","webpack://Pusher/./src/core/events/callback_registry.ts","webpack://Pusher/./node_modules/@stablelib/utf8/utf8.ts","webpack://Pusher/./node_modules/tweetnacl/nacl-fast.js","webpack://Pusher/./src/core/pusher-with-encryption.js","webpack://Pusher/./src/core/pusher-with-encryption.ts"],"names":["installedModules","__webpack_require__","moduleId","exports","module","i","l","modules","call","m","c","d","name","getter","o","Object","defineProperty","enumerable","get","r","Symbol","toStringTag","value","t","mode","__esModule","ns","create","key","bind","n","object","property","prototype","hasOwnProperty","p","s","extend","target","sources","length","extensions","constructor","stringify","arguments","push","safeJSONStringify","join","arrayIndexOf","array","item","nativeIndexOf","Array","indexOf","objectApply","f","keys","_","values","apply","context","global","map","result","filter","test","filterObject","Boolean","any","all","encodeParamsObject","data","encodeURIComponent","toString","buildQueryString","params","undefined","method","source","JSON","e","objects","paths","derez","path","nu","$ref","globalLog","message","console","log","args","this","globalLogWarn","globalLogError","warn","error","defaultLoggingFunction","logToConsole","Util","now","Date","valueOf","defer","callback","boundArguments","slice","concat","Dispatcher","failThrough","callbacks","global_callbacks","eventName","add","remove","unbind","unbind_global","metadata","fn","clearTimeout","timer","clearInterval","OneOffTimer","delay","super","setTimeout","PeriodicTimer","setInterval","VERSION","PROTOCOL","wsPort","wssPort","wsPath","httpHost","httpPort","httpsPort","httpPath","stats_host","authEndpoint","authTransport","activityTimeout","pongTimeout","unavailableTimeout","userAuthentication","endpoint","transport","channelAuthorization","cdn_http","cdn_https","dependency_suffix","getGenericURL","baseScheme","useTLS","hostTLS","hostNonTLS","getGenericPath","queryString","ws","getInitial","http","hooks","priority","options","initialize","transportConnectionInitializer","state","timeline","id","generateUniqueID","handlesActivityChecks","supportsPing","socket","url","urls","getSocket","onError","changeState","bindListeners","debug","close","send","ping","beforeOpen","getPath","onopen","emit","type","buildTimelineMessage","closeEvent","code","reason","wasClean","unbindListeners","onOpen","onerror","onclose","onClose","onmessage","onMessage","onactivity","onActivity","info","cid","environment","isSupported","WSTransport","isInitialized","getWebSocketAPI","createWebSocket","httpConfiguration","streamingConfiguration","HTTPFactory","createStreamingSocket","pollingConfiguration","createPollingSocket","xhrConfiguration","isXHRSupported","xhr_streaming","xhr_polling","manager","minPingDelay","maxPingDelay","pingDelay","connection","createConnection","openTimestamp","onClosed","reportDeath","lifespan","Math","max","isAlive","Protocol","decodeMessage","messageEvent","messageData","parse","pusherEventData","pusherEvent","event","channel","user_id","encodeMessage","processHandshake","activity_timeout","action","socket_id","getCloseAction","getCloseError","send_event","listeners","activity","closed","handleCloseEvent","listener","finish","isEmpty","TimelineTransport","getAgent","BadEventName","Error","msg","setPrototypeOf","BadChannelName","TransportPriorityTooLow","TransportClosed","UnsupportedFeature","UnsupportedTransport","UnsupportedStrategy","HTTPAuthError","status","urlStore","baseUrl","authenticationEndpoint","authorizationEndpoint","javascriptQuickStart","triggeringClientEvents","encryptedChannelSupport","fullUrl","urlObj","pusher","subscribed","subscriptionPending","subscriptionCancelled","socketId","auth","suffix","handleSubscriptionSucceededEvent","handleSubscriptionCountEvent","unsubscribe","subscription_count","subscriptionCount","authorize","assign","channel_data","config","channelAuthorizer","channelName","reset","members","member","myID","subscriptionData","presence","hash","count","me","memberData","user_info","authData","channelData","setMyID","user","signinDonePromise","user_data","handleInternalEvent","addedMember","addMember","removedMember","removeMember","onSubscription","disconnect","nacl","sharedSecret","handleEncryptedEvent","handleEvent","ciphertext","nonce","cipherText","secretbox","overheadLength","nonceLength","bytes","open","getDataToEmit","raw","usingTLS","errorCallbacks","buildErrorCallbacks","connectionCallbacks","buildConnectionCallbacks","handshakeCallbacks","buildHandshakeCallbacks","Network","getNetwork","netinfo","retryIn","sendActivityCheck","updateStrategy","runner","strategy","updateState","startConnecting","setUnavailableTimer","disconnectInternally","handshake","connect","handshakeError","abortConnecting","abort","clearRetryTimer","clearUnavailableTimer","abandonConnection","getStrategy","round","retryTimer","ensureAborted","unavailableTimer","stopActivityCheck","activityTimer","pong_timed_out","resetActivityCheck","shouldRetry","connected","min","Infinity","setConnection","withErrorEmitted","tls_only","refused","backoff","retry","newState","previousState","newStateDescription","previous","current","channels","createEncryptedChannel","errMsg","createPrivateChannel","createPresenceChannel","createChannel","createChannels","createConnectionManager","createTimelineSender","createHandshake","createAssistantToTheTransportManager","livesLeft","lives","strategies","loop","failFast","timeout","timeoutLimit","minPriority","tryNextStrategy","tryStrategy","forceMinPriority","isRunning","callbackBuilder","runners","rs","abortRunner","allRunnersFailed","aborted","transports","ttl","storage","getLocalStorage","serializedCache","getTransportCacheKey","flushTransportCache","fetchTransportCache","cacheSkipCount","timestamp","includes","cached","latency","startTimestamp","pop","cb","storeTransportCache","number","IfStrategy","trueBranch","falseBranch","FirstConnectedStrategy","testSupportsStrategy","baseOptions","defineTransport","definedTransports","defineTransportStrategy","wsStrategy","ws_options","wsHost","wss_options","http_options","timeouts","ws_manager","streaming_manager","ws_transport","wss_transport","xhr_streaming_transport","xhr_polling_transport","ws_loop","wss_loop","streaming_loop","polling_loop","http_loop","payload","position","xhr","getRequest","unloader","addUnloadListener","setRequestHeader","removeUnloadListener","abortRequest","chunk","advanceBuffer","isBufferTooLong","buffer","unreadData","endOfLinePosition","State","autoIncrement","getUniqueURL","separator","randomNumber","randomInt","session","randomString","location","parts","exec","base","getLocation","readyState","CONNECTING","openStream","sendRaw","sendHeartbeat","OPEN","createSocketRequest","start","closeStream","CLOSED","onEvent","onHeartbeat","hostname","urlParts","stream","getReceiveURL","onChunk","onFinished","reconnect","unbind_all","getXHRAPI","onreadystatechange","onprogress","responseText","getDefaultStrategy","Transports","createSocket","createRequest","PusherClass","ready","getClientFeatures","getProtocol","createXHR","hasOnlineConnectionState","connectionState","toLowerCase","online","fetch","then","addEventListener","isNowOnline","AuthRequestType","query","authOptions","authRequestType","headerName","headers","headersProvider","dynamicHeaders","parsed","UserAuthentication","ChannelAuthorization","sender","host","setup","TimelineLevel","getAuthorizers","ajax","WebSocket","XMLHttpRequest","floor","random","events","sent","uniqueID","level","limit","shift","ERROR","INFO","DEBUG","sendfn","bundle","lib","version","cluster","features","failAttempt","onInitialized","serializedTransport","transportClass","enabledTransports","disabledTransports","ignoreNullOrigin","getAssistant","deferred","paramsProvider","dynamicParams","composeChannelQuery","getConfig","opts","statsHost","enableStats","getEnableStatsConfig","getHttpHost","shouldUseTLS","getWebsocketHost","userAuthenticator","buildUserAuthenticator","buildChannelAuthorizer","timelineParams","forceTLS","disableStats","customHandler","channelAuthorizerGenerator","deprecatedAuthorizerOptions","ChannelAuthorizerProxy","authorizer","buildChannelAuth","bindWatchlistInternalEvent","forEach","watchlistEvent","resolve","reject","promise","Promise","res","rej","signin_requested","serverToUserChannel","_signinDoneResolve","_onAuthorize","err","_cleanup","_signin","_newSigninPromiseIfNeeded","watchlist","_onSigninSuccess","_subscribeChannels","bind_global","reinstateSubscription","subscribe","ensure_subscribed","done","setDone","catch","isReady","instances","app_key","checkAppKey","global_emitter","sessionID","timelineSender","subscribeAll","isUsingTLS","internal","appKey","switchCluster","find","timelineSenderTimer","event_name","channel_name","cancelSubscription","signin","Runtime","ScriptReceivers","DependenciesReceivers","auth_callbacks","g","Function","window","validateOptions","_paddingCharacter","encodedLength","encode","out","_encodeByte","left","maxDecodedLength","decodedLength","_getPaddingLength","decode","Uint8Array","paddingLength","op","haveBad","v0","v1","v2","v3","_decodeChar","charCodeAt","b","String","fromCharCode","Coder","stdCoder","URLSafeCoder","urlSafeCoder","set","clear","require","btoa","utob","b64chars","b64tab","charAt","cb_utob","cc","u","replace","cb_encode","ccc","padlen","ord","CallbackRegistry","_callbacks","prefix","prefixedEventName","names","removeCallback","removeAllCallbacks","binding","INVALID_UTF8","arr","pos","chars","n1","n2","n3","gf","init","Float64Array","randombytes","_0","_9","gf0","gf1","_121665","D","D2","X","Y","I","ts64","x","h","vn","xi","y","yi","crypto_verify_16","crypto_verify_32","crypto_core_salsa20","inp","k","j0","j1","j2","j3","j4","j5","j6","j7","j8","j9","j10","j11","j12","j13","j14","j15","x0","x1","x2","x3","x4","x5","x6","x7","x8","x9","x10","x11","x12","x13","x14","x15","core_salsa20","crypto_core_hsalsa20","core_hsalsa20","sigma","crypto_stream_salsa20_xor","cpos","mpos","z","crypto_stream_salsa20","crypto_stream","sn","crypto_stream_xor","poly1305","t0","t1","t2","t3","t4","t5","t6","t7","Uint16Array","pad","leftover","fin","crypto_onetimeauth","outpos","update","crypto_onetimeauth_verify","hpos","crypto_secretbox","crypto_secretbox_open","set25519","a","car25519","v","sel25519","q","pack25519","j","neq25519","par25519","unpack25519","A","Z","M","t8","t9","t10","t11","t12","t13","t14","t15","t16","t17","t18","t19","t20","t21","t22","t23","t24","t25","t26","t27","t28","t29","t30","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","b10","b11","b12","b13","b14","b15","S","inv25519","pow2523","crypto_scalarmult","x32","subarray","x16","crypto_scalarmult_base","crypto_box_keypair","crypto_box_beforenm","blocks","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","hibit","h0","h1","h2","h3","h4","h5","h6","h7","h8","h9","r0","r1","r2","r3","r4","r5","r6","r7","r8","r9","mac","macpos","mask","want","crypto_box_afternm","crypto_box_open_afternm","K","crypto_hashblocks_hl","hh","hl","bh0","bh1","bh2","bh3","bh4","bh5","bh6","bh7","bl0","bl1","bl2","bl3","bl4","bl5","bl6","bl7","th","tl","wh","Int32Array","wl","ah0","ah1","ah2","ah3","ah4","ah5","ah6","ah7","al0","al1","al2","al3","al4","al5","al6","al7","crypto_hash","cswap","pack","tx","ty","zi","scalarmult","scalarbase","crypto_sign_keypair","pk","sk","seeded","L","modL","carry","reduce","crypto_sign","sm","smlen","crypto_sign_open","chk","num","den","den2","den4","den6","unpackneg","checkLengths","checkArrayTypes","TypeError","cleanup","lowlevel","crypto_box","crypto_box_open","crypto_secretbox_KEYBYTES","crypto_secretbox_NONCEBYTES","crypto_secretbox_ZEROBYTES","crypto_secretbox_BOXZEROBYTES","crypto_scalarmult_BYTES","crypto_scalarmult_SCALARBYTES","crypto_box_PUBLICKEYBYTES","crypto_box_SECRETKEYBYTES","crypto_box_BEFORENMBYTES","crypto_box_NONCEBYTES","crypto_box_ZEROBYTES","crypto_box_BOXZEROBYTES","crypto_sign_BYTES","crypto_sign_PUBLICKEYBYTES","crypto_sign_SECRETKEYBYTES","crypto_sign_SEEDBYTES","crypto_hash_BYTES","randomBytes","box","keyLength","scalarMult","scalarLength","groupElementLength","publicKey","secretKey","before","checkBoxLengths","after","keyPair","fromSecretKey","publicKeyLength","secretKeyLength","sharedKeyLength","sign","signedMsg","tmp","mlen","detached","sig","verify","fromSeed","seed","seedLength","signatureLength","hashLength","setPRNG","crypto","self","msCrypto","getRandomValues","default","PusherWithEncryption"],"mappings":";;;;;;;2BACE,IAAIA,EAAmB,GAGvB,SAASC,EAAoBC,GAG5B,GAAGF,EAAiBE,GACnB,OAAOF,EAAiBE,GAAUC,QAGnC,IAAIC,EAASJ,EAAiBE,GAAY,CACzCG,EAAGH,EACHI,GAAG,EACHH,QAAS,IAUV,OANAI,EAAQL,GAAUM,KAAKJ,EAAOD,QAASC,EAAQA,EAAOD,QAASF,GAG/DG,EAAOE,GAAI,EAGJF,EAAOD,QA0Df,OArDAF,EAAoBQ,EAAIF,EAGxBN,EAAoBS,EAAIV,EAGxBC,EAAoBU,EAAI,SAASR,EAASS,EAAMC,GAC3CZ,EAAoBa,EAAEX,EAASS,IAClCG,OAAOC,eAAeb,EAASS,EAAM,CAAEK,YAAY,EAAMC,IAAKL,KAKhEZ,EAAoBkB,EAAI,SAAShB,GACX,oBAAXiB,QAA0BA,OAAOC,aAC1CN,OAAOC,eAAeb,EAASiB,OAAOC,YAAa,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EAAcjlB,GAGhB,WAGE,IAAIs4B,EAAyB,oBAATC,KAAwBA,KAAKD,QAAUC,KAAKC,SAAY,KAC5E,GAAIF,GAAUA,EAAOG,gBAAiB,CAGpC7rB,EAAKyrB,SAAQ,SAASxS,EAAGrrB,GACvB,IAAIzB,EAAG4xB,EAAI,IAAI7I,WAAWtnB,GAC1B,IAAKzB,EAAI,EAAGA,EAAIyB,EAAGzB,GAHT,MAIRu/B,EAAOG,gBAAgB9N,EAAEuD,SAASn1B,EAAGA,EAAIgO,KAAKiJ,IAAIxV,EAAIzB,EAJ9C,SAMV,IAAKA,EAAI,EAAGA,EAAIyB,EAAGzB,IAAK8sB,EAAE9sB,GAAK4xB,EAAE5xB,GACjCq8B,GAAQzK,WAIV2N,EAAS,EAAQ,MACHA,EAAO7B,aACnB7pB,EAAKyrB,SAAQ,SAASxS,EAAGrrB,GACvB,IAAIzB,EAAG4xB,EAAI2N,EAAO7B,YAAYj8B,GAC9B,IAAKzB,EAAI,EAAGA,EAAIyB,EAAGzB,IAAK8sB,EAAE9sB,GAAK4xB,EAAE5xB,GACjCq8B,GAAQzK,MAtBhB,GA1zEA,CAs1EoC7xB,EAAOD,QAAUC,EAAOD,QAAW0/B,KAAK3rB,KAAO2rB,KAAK3rB,MAAQ,K,gBCt1EhG9T,EAAOD,QAAU,EAAQ,IAA4B6/B,S,6BCArD,yEAIe,MAAMC,UAA6B,IAChD,YAAY/Y,EAAiBhd,GAC3B,IAAOhE,aAAe+5B,EAAqB/5B,aAC3C,IAAOR,IAAMu6B,EAAqBv6B,IAElC,YAAgBwE,GAChBA,EAAQgK,KAAO,EACftM,MAAMsf,EAAShd,M","file":"pusher.js","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 15);\n","import base64encode from '../base64';\nimport Util from '../util';\n\n/** Merges multiple objects into the target argument.\n *\n * For properties that are plain Objects, performs a deep-merge. For the\n * rest it just copies the value of the property.\n *\n * To extend prototypes use it as following:\n * Pusher.Util.extend(Target.prototype, Base.prototype)\n *\n * You can also use it to merge objects without altering them:\n * Pusher.Util.extend({}, object1, object2)\n *\n * @param {Object} target\n * @return {Object} the target argument\n */\nexport function extend(target: any, ...sources: any[]): T {\n for (var i = 0; i < sources.length; i++) {\n var extensions = sources[i];\n for (var property in extensions) {\n if (\n extensions[property] &&\n extensions[property].constructor &&\n extensions[property].constructor === Object\n ) {\n target[property] = extend(target[property] || {}, extensions[property]);\n } else {\n target[property] = extensions[property];\n }\n }\n }\n return target;\n}\n\nexport function stringify(): string {\n var m = ['Pusher'];\n for (var i = 0; i < arguments.length; i++) {\n if (typeof arguments[i] === 'string') {\n m.push(arguments[i]);\n } else {\n m.push(safeJSONStringify(arguments[i]));\n }\n }\n return m.join(' : ');\n}\n\nexport function arrayIndexOf(array: any[], item: any): number {\n // MSIE doesn't have array.indexOf\n var nativeIndexOf = Array.prototype.indexOf;\n if (array === null) {\n return -1;\n }\n if (nativeIndexOf && array.indexOf === nativeIndexOf) {\n return array.indexOf(item);\n }\n for (var i = 0, l = array.length; i < l; i++) {\n if (array[i] === item) {\n return i;\n }\n }\n return -1;\n}\n\n/** Applies a function f to all properties of an object.\n *\n * Function f gets 3 arguments passed:\n * - element from the object\n * - key of the element\n * - reference to the object\n *\n * @param {Object} object\n * @param {Function} f\n */\nexport function objectApply(object: any, f: Function) {\n for (var key in object) {\n if (Object.prototype.hasOwnProperty.call(object, key)) {\n f(object[key], key, object);\n }\n }\n}\n\n/** Return a list of objects own proerty keys\n *\n * @param {Object} object\n * @returns {Array}\n */\nexport function keys(object: any): string[] {\n var keys = [];\n objectApply(object, function(_, key) {\n keys.push(key);\n });\n return keys;\n}\n\n/** Return a list of object's own property values\n *\n * @param {Object} object\n * @returns {Array}\n */\nexport function values(object: any): any[] {\n var values = [];\n objectApply(object, function(value) {\n values.push(value);\n });\n return values;\n}\n\n/** Applies a function f to all elements of an array.\n *\n * Function f gets 3 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function apply(array: any[], f: Function, context?: any) {\n for (var i = 0; i < array.length; i++) {\n f.call(context || global, array[i], i, array);\n }\n}\n\n/** Maps all elements of the array and returns the result.\n *\n * Function f gets 4 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n * - reference to the destination array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function map(array: any[], f: Function): any[] {\n var result = [];\n for (var i = 0; i < array.length; i++) {\n result.push(f(array[i], i, array, result));\n }\n return result;\n}\n\n/** Maps all elements of the object and returns the result.\n *\n * Function f gets 4 arguments passed:\n * - element from the object\n * - key of the element\n * - reference to the source object\n * - reference to the destination object\n *\n * @param {Object} object\n * @param {Function} f\n */\nexport function mapObject(object: any, f: Function): any {\n var result = {};\n objectApply(object, function(value, key) {\n result[key] = f(value);\n });\n return result;\n}\n\n/** Filters elements of the array using a test function.\n *\n * Function test gets 4 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n * - reference to the destination array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function filter(array: any[], test: Function): any[] {\n test =\n test ||\n function(value) {\n return !!value;\n };\n\n var result = [];\n for (var i = 0; i < array.length; i++) {\n if (test(array[i], i, array, result)) {\n result.push(array[i]);\n }\n }\n return result;\n}\n\n/** Filters properties of the object using a test function.\n *\n * Function test gets 4 arguments passed:\n * - element from the object\n * - key of the element\n * - reference to the source object\n * - reference to the destination object\n *\n * @param {Object} object\n * @param {Function} f\n */\nexport function filterObject(object: Object, test: Function) {\n var result = {};\n objectApply(object, function(value, key) {\n if ((test && test(value, key, object, result)) || Boolean(value)) {\n result[key] = value;\n }\n });\n return result;\n}\n\n/** Flattens an object into a two-dimensional array.\n *\n * @param {Object} object\n * @return {Array} resulting array of [key, value] pairs\n */\nexport function flatten(object: Object): any[] {\n var result = [];\n objectApply(object, function(value, key) {\n result.push([key, value]);\n });\n return result;\n}\n\n/** Checks whether any element of the array passes the test.\n *\n * Function test gets 3 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function any(array: any[], test: Function): boolean {\n for (var i = 0; i < array.length; i++) {\n if (test(array[i], i, array)) {\n return true;\n }\n }\n return false;\n}\n\n/** Checks whether all elements of the array pass the test.\n *\n * Function test gets 3 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function all(array: any[], test: Function): boolean {\n for (var i = 0; i < array.length; i++) {\n if (!test(array[i], i, array)) {\n return false;\n }\n }\n return true;\n}\n\nexport function encodeParamsObject(data): string {\n return mapObject(data, function(value) {\n if (typeof value === 'object') {\n value = safeJSONStringify(value);\n }\n return encodeURIComponent(base64encode(value.toString()));\n });\n}\n\nexport function buildQueryString(data: any): string {\n var params = filterObject(data, function(value) {\n return value !== undefined;\n });\n\n var query = map(\n flatten(encodeParamsObject(params)),\n Util.method('join', '=')\n ).join('&');\n\n return query;\n}\n\n/**\n * See https://github.com/douglascrockford/JSON-js/blob/master/cycle.js\n *\n * Remove circular references from an object. Required for JSON.stringify in\n * React Native, which tends to blow up a lot.\n *\n * @param {any} object\n * @return {any} Decycled object\n */\nexport function decycleObject(object: any): any {\n var objects = [],\n paths = [];\n\n return (function derez(value, path) {\n var i, name, nu;\n\n switch (typeof value) {\n case 'object':\n if (!value) {\n return null;\n }\n for (i = 0; i < objects.length; i += 1) {\n if (objects[i] === value) {\n return { $ref: paths[i] };\n }\n }\n\n objects.push(value);\n paths.push(path);\n\n if (Object.prototype.toString.apply(value) === '[object Array]') {\n nu = [];\n for (i = 0; i < value.length; i += 1) {\n nu[i] = derez(value[i], path + '[' + i + ']');\n }\n } else {\n nu = {};\n for (name in value) {\n if (Object.prototype.hasOwnProperty.call(value, name)) {\n nu[name] = derez(\n value[name],\n path + '[' + JSON.stringify(name) + ']'\n );\n }\n }\n }\n return nu;\n case 'number':\n case 'string':\n case 'boolean':\n return value;\n }\n })(object, '$');\n}\n\n/**\n * Provides a cross-browser and cross-platform way to safely stringify objects\n * into JSON. This is particularly necessary for ReactNative, where circular JSON\n * structures throw an exception.\n *\n * @param {any} source The object to stringify\n * @return {string} The serialized output.\n */\nexport function safeJSONStringify(source: any): string {\n try {\n return JSON.stringify(source);\n } catch (e) {\n return JSON.stringify(decycleObject(source));\n }\n}\n","import { stringify } from './utils/collections';\nimport Pusher from './pusher';\n\nclass Logger {\n debug(...args: any[]) {\n this.log(this.globalLog, args);\n }\n\n warn(...args: any[]) {\n this.log(this.globalLogWarn, args);\n }\n\n error(...args: any[]) {\n this.log(this.globalLogError, args);\n }\n\n private globalLog = (message: string) => {\n if (global.console && global.console.log) {\n global.console.log(message);\n }\n };\n\n private globalLogWarn(message: string) {\n if (global.console && global.console.warn) {\n global.console.warn(message);\n } else {\n this.globalLog(message);\n }\n }\n\n private globalLogError(message: string) {\n if (global.console && global.console.error) {\n global.console.error(message);\n } else {\n this.globalLogWarn(message);\n }\n }\n\n private log(\n defaultLoggingFunction: (message: string) => void,\n ...args: any[]\n ) {\n var message = stringify.apply(this, arguments);\n if (Pusher.log) {\n Pusher.log(message);\n } else if (Pusher.logToConsole) {\n const log = defaultLoggingFunction.bind(this);\n log(message);\n }\n }\n}\n\nexport default new Logger();\n","import * as Collections from './utils/collections';\nimport TimedCallback from './utils/timers/timed_callback';\nimport { OneOffTimer, PeriodicTimer } from './utils/timers';\n\nvar Util = {\n now(): number {\n if (Date.now) {\n return Date.now();\n } else {\n return new Date().valueOf();\n }\n },\n\n defer(callback: TimedCallback): OneOffTimer {\n return new OneOffTimer(0, callback);\n },\n\n /** Builds a function that will proxy a method call to its first argument.\n *\n * Allows partial application of arguments, so additional arguments are\n * prepended to the argument list.\n *\n * @param {String} name method name\n * @return {Function} proxy function\n */\n method(name: string, ...args: any[]): Function {\n var boundArguments = Array.prototype.slice.call(arguments, 1);\n return function(object) {\n return object[name].apply(object, boundArguments.concat(arguments));\n };\n }\n};\n\nexport default Util;\n","import * as Collections from '../utils/collections';\nimport Callback from './callback';\nimport Metadata from '../channels/metadata';\nimport CallbackRegistry from './callback_registry';\n\n/** Manages callback bindings and event emitting.\n *\n * @param Function failThrough called when no listeners are bound to an event\n */\nexport default class Dispatcher {\n callbacks: CallbackRegistry;\n global_callbacks: Function[];\n failThrough: Function;\n\n constructor(failThrough?: Function) {\n this.callbacks = new CallbackRegistry();\n this.global_callbacks = [];\n this.failThrough = failThrough;\n }\n\n bind(eventName: string, callback: Function, context?: any) {\n this.callbacks.add(eventName, callback, context);\n return this;\n }\n\n bind_global(callback: Function) {\n this.global_callbacks.push(callback);\n return this;\n }\n\n unbind(eventName?: string, callback?: Function, context?: any) {\n this.callbacks.remove(eventName, callback, context);\n return this;\n }\n\n unbind_global(callback?: Function) {\n if (!callback) {\n this.global_callbacks = [];\n return this;\n }\n\n this.global_callbacks = Collections.filter(\n this.global_callbacks || [],\n c => c !== callback\n );\n\n return this;\n }\n\n unbind_all() {\n this.unbind();\n this.unbind_global();\n return this;\n }\n\n emit(eventName: string, data?: any, metadata?: Metadata): Dispatcher {\n for (var i = 0; i < this.global_callbacks.length; i++) {\n this.global_callbacks[i](eventName, data);\n }\n\n var callbacks = this.callbacks.get(eventName);\n var args = [];\n\n if (metadata) {\n // if there's a metadata argument, we need to call the callback with both\n // data and metadata regardless of whether data is undefined\n args.push(data, metadata);\n } else if (data) {\n // metadata is undefined, so we only need to call the callback with data\n // if data exists\n args.push(data);\n }\n\n if (callbacks && callbacks.length > 0) {\n for (var i = 0; i < callbacks.length; i++) {\n callbacks[i].fn.apply(callbacks[i].context || global, args);\n }\n } else if (this.failThrough) {\n this.failThrough(eventName, data);\n }\n\n return this;\n }\n}\n","import Timer from './abstract_timer';\nimport TimedCallback from './timed_callback';\nimport { Delay } from './scheduling';\n\n// We need to bind clear functions this way to avoid exceptions on IE8\nfunction clearTimeout(timer) {\n global.clearTimeout(timer);\n}\nfunction clearInterval(timer) {\n global.clearInterval(timer);\n}\n\n/** Cross-browser compatible one-off timer abstraction.\n *\n * @param {Number} delay\n * @param {Function} callback\n */\nexport class OneOffTimer extends Timer {\n constructor(delay: Delay, callback: TimedCallback) {\n super(setTimeout, clearTimeout, delay, function(timer) {\n callback();\n return null;\n });\n }\n}\n\n/** Cross-browser compatible periodic timer abstraction.\n *\n * @param {Number} delay\n * @param {Function} callback\n */\nexport class PeriodicTimer extends Timer {\n constructor(delay: Delay, callback: TimedCallback) {\n super(setInterval, clearInterval, delay, function(timer) {\n callback();\n return timer;\n });\n }\n}\n","import {\n ChannelAuthorizationOptions,\n UserAuthenticationOptions\n} from './auth/options';\nimport { AuthTransport } from './config';\n\nexport interface DefaultConfig {\n VERSION: string;\n PROTOCOL: number;\n wsPort: number;\n wssPort: number;\n wsPath: string;\n httpHost: string;\n httpPort: number;\n httpsPort: number;\n httpPath: string;\n stats_host: string;\n authEndpoint: string;\n authTransport: AuthTransport;\n activityTimeout: number;\n pongTimeout: number;\n unavailableTimeout: number;\n userAuthentication: UserAuthenticationOptions;\n channelAuthorization: ChannelAuthorizationOptions;\n\n cdn_http?: string;\n cdn_https?: string;\n dependency_suffix?: string;\n}\n\nvar Defaults: DefaultConfig = {\n VERSION: VERSION,\n PROTOCOL: 7,\n\n wsPort: 80,\n wssPort: 443,\n wsPath: '',\n // DEPRECATED: SockJS fallback parameters\n httpHost: 'sockjs.pusher.com',\n httpPort: 80,\n httpsPort: 443,\n httpPath: '/pusher',\n // DEPRECATED: Stats\n stats_host: 'stats.pusher.com',\n // DEPRECATED: Other settings\n authEndpoint: '/pusher/auth',\n authTransport: 'ajax',\n activityTimeout: 120000,\n pongTimeout: 30000,\n unavailableTimeout: 10000,\n userAuthentication: {\n endpoint: '/pusher/user-auth',\n transport: 'ajax'\n },\n channelAuthorization: {\n endpoint: '/pusher/auth',\n transport: 'ajax'\n },\n\n // CDN configuration\n cdn_http: CDN_HTTP,\n cdn_https: CDN_HTTPS,\n dependency_suffix: DEPENDENCY_SUFFIX\n};\n\nexport default Defaults;\n","import Defaults from '../defaults';\nimport { default as URLScheme, URLSchemeParams } from './url_scheme';\n\nfunction getGenericURL(\n baseScheme: string,\n params: URLSchemeParams,\n path: string\n): string {\n var scheme = baseScheme + (params.useTLS ? 's' : '');\n var host = params.useTLS ? params.hostTLS : params.hostNonTLS;\n return scheme + '://' + host + path;\n}\n\nfunction getGenericPath(key: string, queryString?: string): string {\n var path = '/app/' + key;\n var query =\n '?protocol=' +\n Defaults.PROTOCOL +\n '&client=js' +\n '&version=' +\n Defaults.VERSION +\n (queryString ? '&' + queryString : '');\n return path + query;\n}\n\nexport var ws: URLScheme = {\n getInitial: function(key: string, params: URLSchemeParams): string {\n var path = (params.httpPath || '') + getGenericPath(key, 'flash=false');\n return getGenericURL('ws', params, path);\n }\n};\n\nexport var http: URLScheme = {\n getInitial: function(key: string, params: URLSchemeParams): string {\n var path = (params.httpPath || '/pusher') + getGenericPath(key);\n return getGenericURL('http', params, path);\n }\n};\n\nexport var sockjs: URLScheme = {\n getInitial: function(key: string, params: URLSchemeParams): string {\n return getGenericURL('http', params, params.httpPath || '/pusher');\n },\n getPath: function(key: string, params: URLSchemeParams): string {\n return getGenericPath(key);\n }\n};\n","import Util from '../util';\nimport * as Collections from '../utils/collections';\nimport { default as EventsDispatcher } from '../events/dispatcher';\nimport Logger from '../logger';\nimport TransportHooks from './transport_hooks';\nimport Socket from '../socket';\nimport Runtime from 'runtime';\nimport Timeline from '../timeline/timeline';\nimport TransportConnectionOptions from './transport_connection_options';\n\n/** Provides universal API for transport connections.\n *\n * Transport connection is a low-level object that wraps a connection method\n * and exposes a simple evented interface for the connection state and\n * messaging. It does not implement Pusher-specific WebSocket protocol.\n *\n * Additionally, it fetches resources needed for transport to work and exposes\n * an interface for querying transport features.\n *\n * States:\n * - new - initial state after constructing the object\n * - initializing - during initialization phase, usually fetching resources\n * - intialized - ready to establish a connection\n * - connection - when connection is being established\n * - open - when connection ready to be used\n * - closed - after connection was closed be either side\n *\n * Emits:\n * - error - after the connection raised an error\n *\n * Options:\n * - useTLS - whether connection should be over TLS\n * - hostTLS - host to connect to when connection is over TLS\n * - hostNonTLS - host to connect to when connection is over TLS\n *\n * @param {String} key application key\n * @param {Object} options\n */\nexport default class TransportConnection extends EventsDispatcher {\n hooks: TransportHooks;\n name: string;\n priority: number;\n key: string;\n options: TransportConnectionOptions;\n state: string;\n timeline: Timeline;\n activityTimeout: number;\n id: number;\n socket: Socket;\n beforeOpen: Function;\n initialize: Function;\n\n constructor(\n hooks: TransportHooks,\n name: string,\n priority: number,\n key: string,\n options: TransportConnectionOptions\n ) {\n super();\n this.initialize = Runtime.transportConnectionInitializer;\n this.hooks = hooks;\n this.name = name;\n this.priority = priority;\n this.key = key;\n this.options = options;\n\n this.state = 'new';\n this.timeline = options.timeline;\n this.activityTimeout = options.activityTimeout;\n this.id = this.timeline.generateUniqueID();\n }\n\n /** Checks whether the transport handles activity checks by itself.\n *\n * @return {Boolean}\n */\n handlesActivityChecks(): boolean {\n return Boolean(this.hooks.handlesActivityChecks);\n }\n\n /** Checks whether the transport supports the ping/pong API.\n *\n * @return {Boolean}\n */\n supportsPing(): boolean {\n return Boolean(this.hooks.supportsPing);\n }\n\n /** Tries to establish a connection.\n *\n * @returns {Boolean} false if transport is in invalid state\n */\n connect(): boolean {\n if (this.socket || this.state !== 'initialized') {\n return false;\n }\n\n var url = this.hooks.urls.getInitial(this.key, this.options);\n try {\n this.socket = this.hooks.getSocket(url, this.options);\n } catch (e) {\n Util.defer(() => {\n this.onError(e);\n this.changeState('closed');\n });\n return false;\n }\n\n this.bindListeners();\n\n Logger.debug('Connecting', { transport: this.name, url });\n this.changeState('connecting');\n return true;\n }\n\n /** Closes the connection.\n *\n * @return {Boolean} true if there was a connection to close\n */\n close(): boolean {\n if (this.socket) {\n this.socket.close();\n return true;\n } else {\n return false;\n }\n }\n\n /** Sends data over the open connection.\n *\n * @param {String} data\n * @return {Boolean} true only when in the \"open\" state\n */\n send(data: any): boolean {\n if (this.state === 'open') {\n // Workaround for MobileSafari bug (see https://gist.github.com/2052006)\n Util.defer(() => {\n if (this.socket) {\n this.socket.send(data);\n }\n });\n return true;\n } else {\n return false;\n }\n }\n\n /** Sends a ping if the connection is open and transport supports it. */\n ping() {\n if (this.state === 'open' && this.supportsPing()) {\n this.socket.ping();\n }\n }\n\n private onOpen() {\n if (this.hooks.beforeOpen) {\n this.hooks.beforeOpen(\n this.socket,\n this.hooks.urls.getPath(this.key, this.options)\n );\n }\n this.changeState('open');\n this.socket.onopen = undefined;\n }\n\n private onError(error) {\n this.emit('error', { type: 'WebSocketError', error: error });\n this.timeline.error(this.buildTimelineMessage({ error: error.toString() }));\n }\n\n private onClose(closeEvent?: any) {\n if (closeEvent) {\n this.changeState('closed', {\n code: closeEvent.code,\n reason: closeEvent.reason,\n wasClean: closeEvent.wasClean\n });\n } else {\n this.changeState('closed');\n }\n this.unbindListeners();\n this.socket = undefined;\n }\n\n private onMessage(message) {\n this.emit('message', message);\n }\n\n private onActivity() {\n this.emit('activity');\n }\n\n private bindListeners() {\n this.socket.onopen = () => {\n this.onOpen();\n };\n this.socket.onerror = error => {\n this.onError(error);\n };\n this.socket.onclose = closeEvent => {\n this.onClose(closeEvent);\n };\n this.socket.onmessage = message => {\n this.onMessage(message);\n };\n\n if (this.supportsPing()) {\n this.socket.onactivity = () => {\n this.onActivity();\n };\n }\n }\n\n private unbindListeners() {\n if (this.socket) {\n this.socket.onopen = undefined;\n this.socket.onerror = undefined;\n this.socket.onclose = undefined;\n this.socket.onmessage = undefined;\n if (this.supportsPing()) {\n this.socket.onactivity = undefined;\n }\n }\n }\n\n private changeState(state: string, params?: any) {\n this.state = state;\n this.timeline.info(\n this.buildTimelineMessage({\n state: state,\n params: params\n })\n );\n this.emit(state, params);\n }\n\n buildTimelineMessage(message): any {\n return Collections.extend({ cid: this.id }, message);\n }\n}\n","import Factory from '../utils/factory';\nimport TransportHooks from './transport_hooks';\nimport TransportConnection from './transport_connection';\nimport TransportConnectionOptions from './transport_connection_options';\n\n/** Provides interface for transport connection instantiation.\n *\n * Takes transport-specific hooks as the only argument, which allow checking\n * for transport support and creating its connections.\n *\n * Supported hooks: * - file - the name of the file to be fetched during initialization\n * - urls - URL scheme to be used by transport\n * - handlesActivityCheck - true when the transport handles activity checks\n * - supportsPing - true when the transport has a ping/activity API\n * - isSupported - tells whether the transport is supported in the environment\n * - getSocket - creates a WebSocket-compatible transport socket\n *\n * See transports.js for specific implementations.\n *\n * @param {Object} hooks object containing all needed transport hooks\n */\nexport default class Transport {\n hooks: TransportHooks;\n\n constructor(hooks: TransportHooks) {\n this.hooks = hooks;\n }\n\n /** Returns whether the transport is supported in the environment.\n *\n * @param {Object} envronment te environment details (encryption, settings)\n * @returns {Boolean} true when the transport is supported\n */\n isSupported(environment: any): boolean {\n return this.hooks.isSupported(environment);\n }\n\n /** Creates a transport connection.\n *\n * @param {String} name\n * @param {Number} priority\n * @param {String} key the application key\n * @param {Object} options\n * @returns {TransportConnection}\n */\n createConnection(\n name: string,\n priority: number,\n key: string,\n options: any\n ): TransportConnection {\n return new TransportConnection(this.hooks, name, priority, key, options);\n }\n}\n","import * as URLSchemes from 'core/transports/url_schemes';\nimport URLScheme from 'core/transports/url_scheme';\nimport Transport from 'core/transports/transport';\nimport Util from 'core/util';\nimport * as Collections from 'core/utils/collections';\nimport TransportHooks from 'core/transports/transport_hooks';\nimport TransportsTable from 'core/transports/transports_table';\nimport Runtime from 'runtime';\n\n/** WebSocket transport.\n *\n * Uses native WebSocket implementation, including MozWebSocket supported by\n * earlier Firefox versions.\n */\nvar WSTransport = new Transport({\n urls: URLSchemes.ws,\n handlesActivityChecks: false,\n supportsPing: false,\n\n isInitialized: function() {\n return Boolean(Runtime.getWebSocketAPI());\n },\n isSupported: function(): boolean {\n return Boolean(Runtime.getWebSocketAPI());\n },\n getSocket: function(url) {\n return Runtime.createWebSocket(url);\n }\n});\n\nvar httpConfiguration = {\n urls: URLSchemes.http,\n handlesActivityChecks: false,\n supportsPing: true,\n isInitialized: function() {\n return true;\n }\n};\n\nexport var streamingConfiguration = Collections.extend(\n {\n getSocket: function(url) {\n return Runtime.HTTPFactory.createStreamingSocket(url);\n }\n },\n httpConfiguration\n);\nexport var pollingConfiguration = Collections.extend(\n {\n getSocket: function(url) {\n return Runtime.HTTPFactory.createPollingSocket(url);\n }\n },\n httpConfiguration\n);\n\nvar xhrConfiguration = {\n isSupported: function(): boolean {\n return Runtime.isXHRSupported();\n }\n};\n\n/** HTTP streaming transport using CORS-enabled XMLHttpRequest. */\nvar XHRStreamingTransport = new Transport(\n (\n Collections.extend({}, streamingConfiguration, xhrConfiguration)\n )\n);\n\n/** HTTP long-polling transport using CORS-enabled XMLHttpRequest. */\nvar XHRPollingTransport = new Transport(\n Collections.extend({}, pollingConfiguration, xhrConfiguration)\n);\n\nvar Transports: TransportsTable = {\n ws: WSTransport,\n xhr_streaming: XHRStreamingTransport,\n xhr_polling: XHRPollingTransport\n};\n\nexport default Transports;\n","import Util from '../util';\nimport * as Collections from '../utils/collections';\nimport TransportManager from './transport_manager';\nimport TransportConnection from './transport_connection';\nimport Transport from './transport';\nimport PingDelayOptions from './ping_delay_options';\n\n/** Creates transport connections monitored by a transport manager.\n *\n * When a transport is closed, it might mean the environment does not support\n * it. It's possible that messages get stuck in an intermediate buffer or\n * proxies terminate inactive connections. To combat these problems,\n * assistants monitor the connection lifetime, report unclean exits and\n * adjust ping timeouts to keep the connection active. The decision to disable\n * a transport is the manager's responsibility.\n *\n * @param {TransportManager} manager\n * @param {TransportConnection} transport\n * @param {Object} options\n */\nexport default class AssistantToTheTransportManager {\n manager: TransportManager;\n transport: Transport;\n minPingDelay: number;\n maxPingDelay: number;\n pingDelay: number;\n\n constructor(\n manager: TransportManager,\n transport: Transport,\n options: PingDelayOptions\n ) {\n this.manager = manager;\n this.transport = transport;\n this.minPingDelay = options.minPingDelay;\n this.maxPingDelay = options.maxPingDelay;\n this.pingDelay = undefined;\n }\n\n /** Creates a transport connection.\n *\n * This function has the same API as Transport#createConnection.\n *\n * @param {String} name\n * @param {Number} priority\n * @param {String} key the application key\n * @param {Object} options\n * @returns {TransportConnection}\n */\n createConnection(\n name: string,\n priority: number,\n key: string,\n options: Object\n ): TransportConnection {\n options = Collections.extend({}, options, {\n activityTimeout: this.pingDelay\n });\n var connection = this.transport.createConnection(\n name,\n priority,\n key,\n options\n );\n\n var openTimestamp = null;\n\n var onOpen = function() {\n connection.unbind('open', onOpen);\n connection.bind('closed', onClosed);\n openTimestamp = Util.now();\n };\n var onClosed = closeEvent => {\n connection.unbind('closed', onClosed);\n\n if (closeEvent.code === 1002 || closeEvent.code === 1003) {\n // we don't want to use transports not obeying the protocol\n this.manager.reportDeath();\n } else if (!closeEvent.wasClean && openTimestamp) {\n // report deaths only for short-living transport\n var lifespan = Util.now() - openTimestamp;\n if (lifespan < 2 * this.maxPingDelay) {\n this.manager.reportDeath();\n this.pingDelay = Math.max(lifespan / 2, this.minPingDelay);\n }\n }\n };\n\n connection.bind('open', onOpen);\n return connection;\n }\n\n /** Returns whether the transport is supported in the environment.\n *\n * This function has the same API as Transport#isSupported. Might return false\n * when the manager decides to kill the transport.\n *\n * @param {Object} environment the environment details (encryption, settings)\n * @returns {Boolean} true when the transport is supported\n */\n isSupported(environment: string): boolean {\n return this.manager.isAlive() && this.transport.isSupported(environment);\n }\n}\n","import Action from './action';\nimport { PusherEvent } from './message-types';\n/**\n * Provides functions for handling Pusher protocol-specific messages.\n */\n\nconst Protocol = {\n /**\n * Decodes a message in a Pusher format.\n *\n * The MessageEvent we receive from the transport should contain a pusher event\n * (https://pusher.com/docs/pusher_protocol#events) serialized as JSON in the\n * data field\n *\n * The pusher event may contain a data field too, and it may also be\n * serialised as JSON\n *\n * Throws errors when messages are not parse'able.\n *\n * @param {MessageEvent} messageEvent\n * @return {PusherEvent}\n */\n decodeMessage: function(messageEvent: MessageEvent): PusherEvent {\n try {\n var messageData = JSON.parse(messageEvent.data);\n var pusherEventData = messageData.data;\n if (typeof pusherEventData === 'string') {\n try {\n pusherEventData = JSON.parse(messageData.data);\n } catch (e) {}\n }\n var pusherEvent: PusherEvent = {\n event: messageData.event,\n channel: messageData.channel,\n data: pusherEventData\n };\n if (messageData.user_id) {\n pusherEvent.user_id = messageData.user_id;\n }\n return pusherEvent;\n } catch (e) {\n throw { type: 'MessageParseError', error: e, data: messageEvent.data };\n }\n },\n\n /**\n * Encodes a message to be sent.\n *\n * @param {PusherEvent} event\n * @return {String}\n */\n encodeMessage: function(event: PusherEvent): string {\n return JSON.stringify(event);\n },\n\n /**\n * Processes a handshake message and returns appropriate actions.\n *\n * Returns an object with an 'action' and other action-specific properties.\n *\n * There are three outcomes when calling this function. First is a successful\n * connection attempt, when pusher:connection_established is received, which\n * results in a 'connected' action with an 'id' property. When passed a\n * pusher:error event, it returns a result with action appropriate to the\n * close code and an error. Otherwise, it raises an exception.\n *\n * @param {String} message\n * @result Object\n */\n processHandshake: function(messageEvent: MessageEvent): Action {\n var message = Protocol.decodeMessage(messageEvent);\n\n if (message.event === 'pusher:connection_established') {\n if (!message.data.activity_timeout) {\n throw 'No activity timeout specified in handshake';\n }\n return {\n action: 'connected',\n id: message.data.socket_id,\n activityTimeout: message.data.activity_timeout * 1000\n };\n } else if (message.event === 'pusher:error') {\n // From protocol 6 close codes are sent only once, so this only\n // happens when connection does not support close codes\n return {\n action: this.getCloseAction(message.data),\n error: this.getCloseError(message.data)\n };\n } else {\n throw 'Invalid handshake';\n }\n },\n\n /**\n * Dispatches the close event and returns an appropriate action name.\n *\n * See:\n * 1. https://developer.mozilla.org/en-US/docs/WebSockets/WebSockets_reference/CloseEvent\n * 2. http://pusher.com/docs/pusher_protocol\n *\n * @param {CloseEvent} closeEvent\n * @return {String} close action name\n */\n getCloseAction: function(closeEvent): string {\n if (closeEvent.code < 4000) {\n // ignore 1000 CLOSE_NORMAL, 1001 CLOSE_GOING_AWAY,\n // 1005 CLOSE_NO_STATUS, 1006 CLOSE_ABNORMAL\n // ignore 1007...3999\n // handle 1002 CLOSE_PROTOCOL_ERROR, 1003 CLOSE_UNSUPPORTED,\n // 1004 CLOSE_TOO_LARGE\n if (closeEvent.code >= 1002 && closeEvent.code <= 1004) {\n return 'backoff';\n } else {\n return null;\n }\n } else if (closeEvent.code === 4000) {\n return 'tls_only';\n } else if (closeEvent.code < 4100) {\n return 'refused';\n } else if (closeEvent.code < 4200) {\n return 'backoff';\n } else if (closeEvent.code < 4300) {\n return 'retry';\n } else {\n // unknown error\n return 'refused';\n }\n },\n\n /**\n * Returns an error or null basing on the close event.\n *\n * Null is returned when connection was closed cleanly. Otherwise, an object\n * with error details is returned.\n *\n * @param {CloseEvent} closeEvent\n * @return {Object} error object\n */\n getCloseError: function(closeEvent): any {\n if (closeEvent.code !== 1000 && closeEvent.code !== 1001) {\n return {\n type: 'PusherError',\n data: {\n code: closeEvent.code,\n message: closeEvent.reason || closeEvent.message\n }\n };\n } else {\n return null;\n }\n }\n};\n\nexport default Protocol;\n","import * as Collections from '../utils/collections';\nimport { default as EventsDispatcher } from '../events/dispatcher';\nimport Protocol from './protocol/protocol';\nimport { PusherEvent } from './protocol/message-types';\nimport Logger from '../logger';\nimport TransportConnection from '../transports/transport_connection';\nimport Socket from '../socket';\n/**\n * Provides Pusher protocol interface for transports.\n *\n * Emits following events:\n * - message - on received messages\n * - ping - on ping requests\n * - pong - on pong responses\n * - error - when the transport emits an error\n * - closed - after closing the transport\n *\n * It also emits more events when connection closes with a code.\n * See Protocol.getCloseAction to get more details.\n *\n * @param {Number} id\n * @param {AbstractTransport} transport\n */\nexport default class Connection extends EventsDispatcher implements Socket {\n id: string;\n transport: TransportConnection;\n activityTimeout: number;\n\n constructor(id: string, transport: TransportConnection) {\n super();\n this.id = id;\n this.transport = transport;\n this.activityTimeout = transport.activityTimeout;\n this.bindListeners();\n }\n\n /** Returns whether used transport handles activity checks by itself\n *\n * @returns {Boolean} true if activity checks are handled by the transport\n */\n handlesActivityChecks() {\n return this.transport.handlesActivityChecks();\n }\n\n /** Sends raw data.\n *\n * @param {String} data\n */\n send(data: any): boolean {\n return this.transport.send(data);\n }\n\n /** Sends an event.\n *\n * @param {String} name\n * @param {String} data\n * @param {String} [channel]\n * @returns {Boolean} whether message was sent or not\n */\n send_event(name: string, data: any, channel?: string): boolean {\n var event: PusherEvent = { event: name, data: data };\n if (channel) {\n event.channel = channel;\n }\n Logger.debug('Event sent', event);\n return this.send(Protocol.encodeMessage(event));\n }\n\n /** Sends a ping message to the server.\n *\n * Basing on the underlying transport, it might send either transport's\n * protocol-specific ping or pusher:ping event.\n */\n ping() {\n if (this.transport.supportsPing()) {\n this.transport.ping();\n } else {\n this.send_event('pusher:ping', {});\n }\n }\n\n /** Closes the connection. */\n close() {\n this.transport.close();\n }\n\n private bindListeners() {\n var listeners = {\n message: (messageEvent: MessageEvent) => {\n var pusherEvent;\n try {\n pusherEvent = Protocol.decodeMessage(messageEvent);\n } catch (e) {\n this.emit('error', {\n type: 'MessageParseError',\n error: e,\n data: messageEvent.data\n });\n }\n\n if (pusherEvent !== undefined) {\n Logger.debug('Event recd', pusherEvent);\n\n switch (pusherEvent.event) {\n case 'pusher:error':\n this.emit('error', {\n type: 'PusherError',\n data: pusherEvent.data\n });\n break;\n case 'pusher:ping':\n this.emit('ping');\n break;\n case 'pusher:pong':\n this.emit('pong');\n break;\n }\n this.emit('message', pusherEvent);\n }\n },\n activity: () => {\n this.emit('activity');\n },\n error: error => {\n this.emit('error', error);\n },\n closed: closeEvent => {\n unbindListeners();\n\n if (closeEvent && closeEvent.code) {\n this.handleCloseEvent(closeEvent);\n }\n\n this.transport = null;\n this.emit('closed');\n }\n };\n\n var unbindListeners = () => {\n Collections.objectApply(listeners, (listener, event) => {\n this.transport.unbind(event, listener);\n });\n };\n\n Collections.objectApply(listeners, (listener, event) => {\n this.transport.bind(event, listener);\n });\n }\n\n private handleCloseEvent(closeEvent: any) {\n var action = Protocol.getCloseAction(closeEvent);\n var error = Protocol.getCloseError(closeEvent);\n if (error) {\n this.emit('error', error);\n }\n if (action) {\n this.emit(action, { action: action, error: error });\n }\n }\n}\n","import Util from '../../util';\nimport * as Collections from '../../utils/collections';\nimport Protocol from '../protocol/protocol';\nimport Connection from '../connection';\nimport TransportConnection from '../../transports/transport_connection';\nimport HandshakePayload from './handshake_payload';\n\n/**\n * Handles Pusher protocol handshakes for transports.\n *\n * Calls back with a result object after handshake is completed. Results\n * always have two fields:\n * - action - string describing action to be taken after the handshake\n * - transport - the transport object passed to the constructor\n *\n * Different actions can set different additional properties on the result.\n * In the case of 'connected' action, there will be a 'connection' property\n * containing a Connection object for the transport. Other actions should\n * carry an 'error' property.\n *\n * @param {AbstractTransport} transport\n * @param {Function} callback\n */\nexport default class Handshake {\n transport: TransportConnection;\n callback: (HandshakePayload) => void;\n onMessage: Function;\n onClosed: Function;\n\n constructor(\n transport: TransportConnection,\n callback: (HandshakePayload) => void\n ) {\n this.transport = transport;\n this.callback = callback;\n this.bindListeners();\n }\n\n close() {\n this.unbindListeners();\n this.transport.close();\n }\n\n private bindListeners() {\n this.onMessage = m => {\n this.unbindListeners();\n\n var result;\n try {\n result = Protocol.processHandshake(m);\n } catch (e) {\n this.finish('error', { error: e });\n this.transport.close();\n return;\n }\n\n if (result.action === 'connected') {\n this.finish('connected', {\n connection: new Connection(result.id, this.transport),\n activityTimeout: result.activityTimeout\n });\n } else {\n this.finish(result.action, { error: result.error });\n this.transport.close();\n }\n };\n\n this.onClosed = closeEvent => {\n this.unbindListeners();\n\n var action = Protocol.getCloseAction(closeEvent) || 'backoff';\n var error = Protocol.getCloseError(closeEvent);\n this.finish(action, { error: error });\n };\n\n this.transport.bind('message', this.onMessage);\n this.transport.bind('closed', this.onClosed);\n }\n\n private unbindListeners() {\n this.transport.unbind('message', this.onMessage);\n this.transport.unbind('closed', this.onClosed);\n }\n\n private finish(action: string, params: any) {\n this.callback(\n Collections.extend({ transport: this.transport, action: action }, params)\n );\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport base64encode from '../base64';\nimport Timeline from './timeline';\nimport Runtime from 'runtime';\n\nexport interface TimelineSenderOptions {\n host?: string;\n port?: number;\n path?: string;\n}\n\nexport default class TimelineSender {\n timeline: Timeline;\n options: TimelineSenderOptions;\n host: string;\n\n constructor(timeline: Timeline, options: TimelineSenderOptions) {\n this.timeline = timeline;\n this.options = options || {};\n }\n\n send(useTLS: boolean, callback?: Function) {\n if (this.timeline.isEmpty()) {\n return;\n }\n\n this.timeline.send(\n Runtime.TimelineTransport.getAgent(this, useTLS),\n callback\n );\n }\n}\n","/** Error classes used throughout the library. */\n// https://github.com/Microsoft/TypeScript-wiki/blob/master/Breaking-Changes.md#extending-built-ins-like-error-array-and-map-may-no-longer-work\nexport class BadEventName extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\nexport class BadChannelName extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\nexport class RequestTimedOut extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class TransportPriorityTooLow extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class TransportClosed extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class UnsupportedFeature extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class UnsupportedTransport extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class UnsupportedStrategy extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class HTTPAuthError extends Error {\n status: number;\n constructor(status: number, msg?: string) {\n super(msg);\n this.status = status;\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n","/**\n * A place to store help URLs for error messages etc\n */\n\nconst urlStore = {\n baseUrl: 'https://pusher.com',\n urls: {\n authenticationEndpoint: {\n path: '/docs/channels/server_api/authenticating_users'\n },\n authorizationEndpoint: {\n path: '/docs/channels/server_api/authorizing-users/'\n },\n javascriptQuickStart: {\n path: '/docs/javascript_quick_start'\n },\n triggeringClientEvents: {\n path: '/docs/client_api_guide/client_events#trigger-events'\n },\n encryptedChannelSupport: {\n fullUrl:\n 'https://github.com/pusher/pusher-js/tree/cc491015371a4bde5743d1c87a0fbac0feb53195#encrypted-channel-support'\n }\n }\n};\n\n/** Builds a consistent string with links to pusher documentation\n *\n * @param {string} key - relevant key in the url_store.urls object\n * @return {string} suffix string to append to log message\n */\nconst buildLogSuffix = function(key: string): string {\n const urlPrefix = 'See:';\n const urlObj = urlStore.urls[key];\n if (!urlObj) return '';\n\n let url;\n if (urlObj.fullUrl) {\n url = urlObj.fullUrl;\n } else if (urlObj.path) {\n url = urlStore.baseUrl + urlObj.path;\n }\n\n if (!url) return '';\n return `${urlPrefix} ${url}`;\n};\n\nexport default { buildLogSuffix };\n","import { default as EventsDispatcher } from '../events/dispatcher';\nimport * as Errors from '../errors';\nimport Logger from '../logger';\nimport Pusher from '../pusher';\nimport { PusherEvent } from '../connection/protocol/message-types';\nimport Metadata from './metadata';\nimport UrlStore from '../utils/url_store';\nimport {\n ChannelAuthorizationData,\n ChannelAuthorizationCallback\n} from '../auth/options';\nimport { HTTPAuthError } from '../errors';\n\n/** Provides base public channel interface with an event emitter.\n *\n * Emits:\n * - pusher:subscription_succeeded - after subscribing successfully\n * - other non-internal events\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\nexport default class Channel extends EventsDispatcher {\n name: string;\n pusher: Pusher;\n subscribed: boolean;\n subscriptionPending: boolean;\n subscriptionCancelled: boolean;\n subscriptionCount: null;\n\n constructor(name: string, pusher: Pusher) {\n super(function(event, data) {\n Logger.debug('No callbacks on ' + name + ' for ' + event);\n });\n\n this.name = name;\n this.pusher = pusher;\n this.subscribed = false;\n this.subscriptionPending = false;\n this.subscriptionCancelled = false;\n }\n\n /** Skips authorization, since public channels don't require it.\n *\n * @param {Function} callback\n */\n authorize(socketId: string, callback: ChannelAuthorizationCallback) {\n return callback(null, { auth: '' });\n }\n\n /** Triggers an event */\n trigger(event: string, data: any) {\n if (event.indexOf('client-') !== 0) {\n throw new Errors.BadEventName(\n \"Event '\" + event + \"' does not start with 'client-'\"\n );\n }\n if (!this.subscribed) {\n var suffix = UrlStore.buildLogSuffix('triggeringClientEvents');\n Logger.warn(\n `Client event triggered before channel 'subscription_succeeded' event . ${suffix}`\n );\n }\n return this.pusher.send_event(event, data, this.name);\n }\n\n /** Signals disconnection to the channel. For internal use only. */\n disconnect() {\n this.subscribed = false;\n this.subscriptionPending = false;\n }\n\n /** Handles a PusherEvent. For internal use only.\n *\n * @param {PusherEvent} event\n */\n handleEvent(event: PusherEvent) {\n var eventName = event.event;\n var data = event.data;\n if (eventName === 'pusher_internal:subscription_succeeded') {\n this.handleSubscriptionSucceededEvent(event);\n } else if (eventName === 'pusher_internal:subscription_count') {\n this.handleSubscriptionCountEvent(event);\n } else if (eventName.indexOf('pusher_internal:') !== 0) {\n var metadata: Metadata = {};\n this.emit(eventName, data, metadata);\n }\n }\n\n handleSubscriptionSucceededEvent(event: PusherEvent) {\n this.subscriptionPending = false;\n this.subscribed = true;\n if (this.subscriptionCancelled) {\n this.pusher.unsubscribe(this.name);\n } else {\n this.emit('pusher:subscription_succeeded', event.data);\n }\n }\n\n handleSubscriptionCountEvent(event: PusherEvent) {\n if (event.data.subscription_count) {\n this.subscriptionCount = event.data.subscription_count;\n }\n\n this.emit('pusher:subscription_count', event.data);\n }\n\n /** Sends a subscription request. For internal use only. */\n subscribe() {\n if (this.subscribed) {\n return;\n }\n this.subscriptionPending = true;\n this.subscriptionCancelled = false;\n this.authorize(\n this.pusher.connection.socket_id,\n (error: Error | null, data: ChannelAuthorizationData) => {\n if (error) {\n this.subscriptionPending = false;\n // Why not bind to 'pusher:subscription_error' a level up, and log there?\n // Binding to this event would cause the warning about no callbacks being\n // bound (see constructor) to be suppressed, that's not what we want.\n Logger.error(error.toString());\n this.emit(\n 'pusher:subscription_error',\n Object.assign(\n {},\n {\n type: 'AuthError',\n error: error.message\n },\n error instanceof HTTPAuthError ? { status: error.status } : {}\n )\n );\n } else {\n this.pusher.send_event('pusher:subscribe', {\n auth: data.auth,\n channel_data: data.channel_data,\n channel: this.name\n });\n }\n }\n );\n }\n\n /** Sends an unsubscription request. For internal use only. */\n unsubscribe() {\n this.subscribed = false;\n this.pusher.send_event('pusher:unsubscribe', {\n channel: this.name\n });\n }\n\n /** Cancels an in progress subscription. For internal use only. */\n cancelSubscription() {\n this.subscriptionCancelled = true;\n }\n\n /** Reinstates an in progress subscripiton. For internal use only. */\n reinstateSubscription() {\n this.subscriptionCancelled = false;\n }\n}\n","import Factory from '../utils/factory';\nimport Channel from './channel';\nimport { ChannelAuthorizationCallback } from '../auth/options';\n\n/** Extends public channels to provide private channel interface.\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\nexport default class PrivateChannel extends Channel {\n /** Authorizes the connection to use the channel.\n *\n * @param {String} socketId\n * @param {Function} callback\n */\n authorize(socketId: string, callback: ChannelAuthorizationCallback) {\n return this.pusher.config.channelAuthorizer(\n {\n channelName: this.name,\n socketId: socketId\n },\n callback\n );\n }\n}\n","import * as Collections from '../utils/collections';\n\n/** Represents a collection of members of a presence channel. */\nexport default class Members {\n members: any;\n count: number;\n myID: any;\n me: any;\n\n constructor() {\n this.reset();\n }\n\n /** Returns member's info for given id.\n *\n * Resulting object containts two fields - id and info.\n *\n * @param {Number} id\n * @return {Object} member's info or null\n */\n get(id: string): any {\n if (Object.prototype.hasOwnProperty.call(this.members, id)) {\n return {\n id: id,\n info: this.members[id]\n };\n } else {\n return null;\n }\n }\n\n /** Calls back for each member in unspecified order.\n *\n * @param {Function} callback\n */\n each(callback: Function) {\n Collections.objectApply(this.members, (member, id) => {\n callback(this.get(id));\n });\n }\n\n /** Updates the id for connected member. For internal use only. */\n setMyID(id: string) {\n this.myID = id;\n }\n\n /** Handles subscription data. For internal use only. */\n onSubscription(subscriptionData: any) {\n this.members = subscriptionData.presence.hash;\n this.count = subscriptionData.presence.count;\n this.me = this.get(this.myID);\n }\n\n /** Adds a new member to the collection. For internal use only. */\n addMember(memberData: any) {\n if (this.get(memberData.user_id) === null) {\n this.count++;\n }\n this.members[memberData.user_id] = memberData.user_info;\n return this.get(memberData.user_id);\n }\n\n /** Adds a member from the collection. For internal use only. */\n removeMember(memberData: any) {\n var member = this.get(memberData.user_id);\n if (member) {\n delete this.members[memberData.user_id];\n this.count--;\n }\n return member;\n }\n\n /** Resets the collection to the initial state. For internal use only. */\n reset() {\n this.members = {};\n this.count = 0;\n this.myID = null;\n this.me = null;\n }\n}\n","import PrivateChannel from './private_channel';\nimport Logger from '../logger';\nimport Members from './members';\nimport Pusher from '../pusher';\nimport UrlStore from 'core/utils/url_store';\nimport { PusherEvent } from '../connection/protocol/message-types';\nimport Metadata from './metadata';\nimport { ChannelAuthorizationData } from '../auth/options';\n\nexport default class PresenceChannel extends PrivateChannel {\n members: Members;\n\n /** Adds presence channel functionality to private channels.\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\n constructor(name: string, pusher: Pusher) {\n super(name, pusher);\n this.members = new Members();\n }\n\n /** Authorizes the connection as a member of the channel.\n *\n * @param {String} socketId\n * @param {Function} callback\n */\n authorize(socketId: string, callback: Function) {\n super.authorize(socketId, async (error, authData) => {\n if (!error) {\n authData = authData as ChannelAuthorizationData;\n if (authData.channel_data != null) {\n var channelData = JSON.parse(authData.channel_data);\n this.members.setMyID(channelData.user_id);\n } else {\n await this.pusher.user.signinDonePromise;\n if (this.pusher.user.user_data != null) {\n // If the user is signed in, get the id of the authenticated user\n // and allow the presence authorization to continue.\n this.members.setMyID(this.pusher.user.user_data.id);\n } else {\n let suffix = UrlStore.buildLogSuffix('authorizationEndpoint');\n Logger.error(\n `Invalid auth response for channel '${this.name}', ` +\n `expected 'channel_data' field. ${suffix}, ` +\n `or the user should be signed in.`\n );\n callback('Invalid auth response');\n return;\n }\n }\n }\n callback(error, authData);\n });\n }\n\n /** Handles presence and subscription events. For internal use only.\n *\n * @param {PusherEvent} event\n */\n handleEvent(event: PusherEvent) {\n var eventName = event.event;\n if (eventName.indexOf('pusher_internal:') === 0) {\n this.handleInternalEvent(event);\n } else {\n var data = event.data;\n var metadata: Metadata = {};\n if (event.user_id) {\n metadata.user_id = event.user_id;\n }\n this.emit(eventName, data, metadata);\n }\n }\n handleInternalEvent(event: PusherEvent) {\n var eventName = event.event;\n var data = event.data;\n switch (eventName) {\n case 'pusher_internal:subscription_succeeded':\n this.handleSubscriptionSucceededEvent(event);\n break;\n case 'pusher_internal:subscription_count':\n this.handleSubscriptionCountEvent(event);\n break;\n case 'pusher_internal:member_added':\n var addedMember = this.members.addMember(data);\n this.emit('pusher:member_added', addedMember);\n break;\n case 'pusher_internal:member_removed':\n var removedMember = this.members.removeMember(data);\n if (removedMember) {\n this.emit('pusher:member_removed', removedMember);\n }\n break;\n }\n }\n\n handleSubscriptionSucceededEvent(event: PusherEvent) {\n this.subscriptionPending = false;\n this.subscribed = true;\n if (this.subscriptionCancelled) {\n this.pusher.unsubscribe(this.name);\n } else {\n this.members.onSubscription(event.data);\n this.emit('pusher:subscription_succeeded', this.members);\n }\n }\n\n /** Resets the channel state, including members map. For internal use only. */\n disconnect() {\n this.members.reset();\n super.disconnect();\n }\n}\n","import PrivateChannel from './private_channel';\nimport * as Errors from '../errors';\nimport Logger from '../logger';\nimport Pusher from '../pusher';\nimport { decode as encodeUTF8 } from '@stablelib/utf8';\nimport { decode as decodeBase64 } from '@stablelib/base64';\nimport Dispatcher from '../events/dispatcher';\nimport { PusherEvent } from '../connection/protocol/message-types';\nimport {\n ChannelAuthorizationData,\n ChannelAuthorizationCallback\n} from '../auth/options';\nimport * as nacl from 'tweetnacl';\n\n/** Extends private channels to provide encrypted channel interface.\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\nexport default class EncryptedChannel extends PrivateChannel {\n key: Uint8Array = null;\n nacl: nacl;\n\n constructor(name: string, pusher: Pusher, nacl: nacl) {\n super(name, pusher);\n this.nacl = nacl;\n }\n\n /** Authorizes the connection to use the channel.\n *\n * @param {String} socketId\n * @param {Function} callback\n */\n authorize(socketId: string, callback: ChannelAuthorizationCallback) {\n super.authorize(\n socketId,\n (error: Error | null, authData: ChannelAuthorizationData) => {\n if (error) {\n callback(error, authData);\n return;\n }\n let sharedSecret = authData['shared_secret'];\n if (!sharedSecret) {\n callback(\n new Error(\n `No shared_secret key in auth payload for encrypted channel: ${this.name}`\n ),\n null\n );\n return;\n }\n this.key = decodeBase64(sharedSecret);\n delete authData['shared_secret'];\n callback(null, authData);\n }\n );\n }\n\n trigger(event: string, data: any): boolean {\n throw new Errors.UnsupportedFeature(\n 'Client events are not currently supported for encrypted channels'\n );\n }\n\n /** Handles an event. For internal use only.\n *\n * @param {PusherEvent} event\n */\n handleEvent(event: PusherEvent) {\n var eventName = event.event;\n var data = event.data;\n if (\n eventName.indexOf('pusher_internal:') === 0 ||\n eventName.indexOf('pusher:') === 0\n ) {\n super.handleEvent(event);\n return;\n }\n this.handleEncryptedEvent(eventName, data);\n }\n\n private handleEncryptedEvent(event: string, data: any): void {\n if (!this.key) {\n Logger.debug(\n 'Received encrypted event before key has been retrieved from the authEndpoint'\n );\n return;\n }\n if (!data.ciphertext || !data.nonce) {\n Logger.error(\n 'Unexpected format for encrypted event, expected object with `ciphertext` and `nonce` fields, got: ' +\n data\n );\n return;\n }\n let cipherText = decodeBase64(data.ciphertext);\n if (cipherText.length < this.nacl.secretbox.overheadLength) {\n Logger.error(\n `Expected encrypted event ciphertext length to be ${this.nacl.secretbox.overheadLength}, got: ${cipherText.length}`\n );\n return;\n }\n let nonce = decodeBase64(data.nonce);\n if (nonce.length < this.nacl.secretbox.nonceLength) {\n Logger.error(\n `Expected encrypted event nonce length to be ${this.nacl.secretbox.nonceLength}, got: ${nonce.length}`\n );\n return;\n }\n\n let bytes = this.nacl.secretbox.open(cipherText, nonce, this.key);\n if (bytes === null) {\n Logger.debug(\n 'Failed to decrypt an event, probably because it was encrypted with a different key. Fetching a new key from the authEndpoint...'\n );\n // Try a single time to retrieve a new auth key and decrypt the event with it\n // If this fails, a new key will be requested when a new message is received\n this.authorize(this.pusher.connection.socket_id, (error, authData) => {\n if (error) {\n Logger.error(\n `Failed to make a request to the authEndpoint: ${authData}. Unable to fetch new key, so dropping encrypted event`\n );\n return;\n }\n bytes = this.nacl.secretbox.open(cipherText, nonce, this.key);\n if (bytes === null) {\n Logger.error(\n `Failed to decrypt event with new key. Dropping encrypted event`\n );\n return;\n }\n this.emit(event, this.getDataToEmit(bytes));\n return;\n });\n return;\n }\n this.emit(event, this.getDataToEmit(bytes));\n }\n\n // Try and parse the decrypted bytes as JSON. If we can't parse it, just\n // return the utf-8 string\n getDataToEmit(bytes: Uint8Array): string {\n let raw = encodeUTF8(bytes);\n try {\n return JSON.parse(raw);\n } catch {\n return raw;\n }\n }\n}\n","import { default as EventsDispatcher } from '../events/dispatcher';\nimport { OneOffTimer as Timer } from '../utils/timers';\nimport { Config } from '../config';\nimport Logger from '../logger';\nimport HandshakePayload from './handshake/handshake_payload';\nimport Connection from './connection';\nimport Strategy from '../strategies/strategy';\nimport StrategyRunner from '../strategies/strategy_runner';\nimport * as Collections from '../utils/collections';\nimport Timeline from '../timeline/timeline';\nimport ConnectionManagerOptions from './connection_manager_options';\nimport Runtime from 'runtime';\n\nimport {\n ErrorCallbacks,\n HandshakeCallbacks,\n ConnectionCallbacks\n} from './callbacks';\nimport Action from './protocol/action';\n\n/** Manages connection to Pusher.\n *\n * Uses a strategy (currently only default), timers and network availability\n * info to establish a connection and export its state. In case of failures,\n * manages reconnection attempts.\n *\n * Exports state changes as following events:\n * - \"state_change\", { previous: p, current: state }\n * - state\n *\n * States:\n * - initialized - initial state, never transitioned to\n * - connecting - connection is being established\n * - connected - connection has been fully established\n * - disconnected - on requested disconnection\n * - unavailable - after connection timeout or when there's no network\n * - failed - when the connection strategy is not supported\n *\n * Options:\n * - unavailableTimeout - time to transition to unavailable state\n * - activityTimeout - time after which ping message should be sent\n * - pongTimeout - time for Pusher to respond with pong before reconnecting\n *\n * @param {String} key application key\n * @param {Object} options\n */\nexport default class ConnectionManager extends EventsDispatcher {\n key: string;\n options: ConnectionManagerOptions;\n state: string;\n connection: Connection;\n usingTLS: boolean;\n timeline: Timeline;\n socket_id: string;\n unavailableTimer: Timer;\n activityTimer: Timer;\n retryTimer: Timer;\n activityTimeout: number;\n strategy: Strategy;\n runner: StrategyRunner;\n errorCallbacks: ErrorCallbacks;\n handshakeCallbacks: HandshakeCallbacks;\n connectionCallbacks: ConnectionCallbacks;\n\n constructor(key: string, options: ConnectionManagerOptions) {\n super();\n this.state = 'initialized';\n this.connection = null;\n\n this.key = key;\n this.options = options;\n this.timeline = this.options.timeline;\n this.usingTLS = this.options.useTLS;\n\n this.errorCallbacks = this.buildErrorCallbacks();\n this.connectionCallbacks = this.buildConnectionCallbacks(\n this.errorCallbacks\n );\n this.handshakeCallbacks = this.buildHandshakeCallbacks(this.errorCallbacks);\n\n var Network = Runtime.getNetwork();\n\n Network.bind('online', () => {\n this.timeline.info({ netinfo: 'online' });\n if (this.state === 'connecting' || this.state === 'unavailable') {\n this.retryIn(0);\n }\n });\n Network.bind('offline', () => {\n this.timeline.info({ netinfo: 'offline' });\n if (this.connection) {\n this.sendActivityCheck();\n }\n });\n\n this.updateStrategy();\n }\n\n switchCluster(key: string) {\n this.key = key;\n // This ensures that the new config coming from\n // pusher instance are taken into account\n // such as appKey and cluster\n this.updateStrategy();\n this.retryIn(0);\n }\n\n /** Establishes a connection to Pusher.\n *\n * Does nothing when connection is already established. See top-level doc\n * to find events emitted on connection attempts.\n */\n connect() {\n if (this.connection || this.runner) {\n return;\n }\n if (!this.strategy.isSupported()) {\n this.updateState('failed');\n return;\n }\n this.updateState('connecting');\n this.startConnecting();\n this.setUnavailableTimer();\n }\n\n /** Sends raw data.\n *\n * @param {String} data\n */\n send(data) {\n if (this.connection) {\n return this.connection.send(data);\n } else {\n return false;\n }\n }\n\n /** Sends an event.\n *\n * @param {String} name\n * @param {String} data\n * @param {String} [channel]\n * @returns {Boolean} whether message was sent or not\n */\n send_event(name: string, data: any, channel?: string) {\n if (this.connection) {\n return this.connection.send_event(name, data, channel);\n } else {\n return false;\n }\n }\n\n /** Closes the connection. */\n disconnect() {\n this.disconnectInternally();\n this.updateState('disconnected');\n }\n\n isUsingTLS() {\n return this.usingTLS;\n }\n\n private startConnecting() {\n var callback = (error, handshake) => {\n if (error) {\n this.runner = this.strategy.connect(0, callback);\n } else {\n if (handshake.action === 'error') {\n this.emit('error', {\n type: 'HandshakeError',\n error: handshake.error\n });\n this.timeline.error({ handshakeError: handshake.error });\n } else {\n this.abortConnecting(); // we don't support switching connections yet\n this.handshakeCallbacks[handshake.action](handshake);\n }\n }\n };\n this.runner = this.strategy.connect(0, callback);\n }\n\n private abortConnecting() {\n if (this.runner) {\n this.runner.abort();\n this.runner = null;\n }\n }\n\n private disconnectInternally() {\n this.abortConnecting();\n this.clearRetryTimer();\n this.clearUnavailableTimer();\n if (this.connection) {\n var connection = this.abandonConnection();\n connection.close();\n }\n }\n\n private updateStrategy() {\n this.strategy = this.options.getStrategy({\n key: this.key,\n timeline: this.timeline,\n useTLS: this.usingTLS\n });\n }\n\n private retryIn(delay) {\n this.timeline.info({ action: 'retry', delay: delay });\n if (delay > 0) {\n this.emit('connecting_in', Math.round(delay / 1000));\n }\n this.retryTimer = new Timer(delay || 0, () => {\n this.disconnectInternally();\n this.connect();\n });\n }\n\n private clearRetryTimer() {\n if (this.retryTimer) {\n this.retryTimer.ensureAborted();\n this.retryTimer = null;\n }\n }\n\n private setUnavailableTimer() {\n this.unavailableTimer = new Timer(this.options.unavailableTimeout, () => {\n this.updateState('unavailable');\n });\n }\n\n private clearUnavailableTimer() {\n if (this.unavailableTimer) {\n this.unavailableTimer.ensureAborted();\n }\n }\n\n private sendActivityCheck() {\n this.stopActivityCheck();\n this.connection.ping();\n // wait for pong response\n this.activityTimer = new Timer(this.options.pongTimeout, () => {\n this.timeline.error({ pong_timed_out: this.options.pongTimeout });\n this.retryIn(0);\n });\n }\n\n private resetActivityCheck() {\n this.stopActivityCheck();\n // send ping after inactivity\n if (this.connection && !this.connection.handlesActivityChecks()) {\n this.activityTimer = new Timer(this.activityTimeout, () => {\n this.sendActivityCheck();\n });\n }\n }\n\n private stopActivityCheck() {\n if (this.activityTimer) {\n this.activityTimer.ensureAborted();\n }\n }\n\n private buildConnectionCallbacks(\n errorCallbacks: ErrorCallbacks\n ): ConnectionCallbacks {\n return Collections.extend({}, errorCallbacks, {\n message: message => {\n // includes pong messages from server\n this.resetActivityCheck();\n this.emit('message', message);\n },\n ping: () => {\n this.send_event('pusher:pong', {});\n },\n activity: () => {\n this.resetActivityCheck();\n },\n error: error => {\n // just emit error to user - socket will already be closed by browser\n this.emit('error', error);\n },\n closed: () => {\n this.abandonConnection();\n if (this.shouldRetry()) {\n this.retryIn(1000);\n }\n }\n });\n }\n\n private buildHandshakeCallbacks(\n errorCallbacks: ErrorCallbacks\n ): HandshakeCallbacks {\n return Collections.extend({}, errorCallbacks, {\n connected: (handshake: HandshakePayload) => {\n this.activityTimeout = Math.min(\n this.options.activityTimeout,\n handshake.activityTimeout,\n handshake.connection.activityTimeout || Infinity\n );\n this.clearUnavailableTimer();\n this.setConnection(handshake.connection);\n this.socket_id = this.connection.id;\n this.updateState('connected', { socket_id: this.socket_id });\n }\n });\n }\n\n private buildErrorCallbacks(): ErrorCallbacks {\n let withErrorEmitted = callback => {\n return (result: Action | HandshakePayload) => {\n if (result.error) {\n this.emit('error', { type: 'WebSocketError', error: result.error });\n }\n callback(result);\n };\n };\n\n return {\n tls_only: withErrorEmitted(() => {\n this.usingTLS = true;\n this.updateStrategy();\n this.retryIn(0);\n }),\n refused: withErrorEmitted(() => {\n this.disconnect();\n }),\n backoff: withErrorEmitted(() => {\n this.retryIn(1000);\n }),\n retry: withErrorEmitted(() => {\n this.retryIn(0);\n })\n };\n }\n\n private setConnection(connection) {\n this.connection = connection;\n for (var event in this.connectionCallbacks) {\n this.connection.bind(event, this.connectionCallbacks[event]);\n }\n this.resetActivityCheck();\n }\n\n private abandonConnection() {\n if (!this.connection) {\n return;\n }\n this.stopActivityCheck();\n for (var event in this.connectionCallbacks) {\n this.connection.unbind(event, this.connectionCallbacks[event]);\n }\n var connection = this.connection;\n this.connection = null;\n return connection;\n }\n\n private updateState(newState: string, data?: any) {\n var previousState = this.state;\n this.state = newState;\n if (previousState !== newState) {\n var newStateDescription = newState;\n if (newStateDescription === 'connected') {\n newStateDescription += ' with new socket ID ' + data.socket_id;\n }\n Logger.debug(\n 'State changed',\n previousState + ' -> ' + newStateDescription\n );\n this.timeline.info({ state: newState, params: data });\n this.emit('state_change', { previous: previousState, current: newState });\n this.emit(newState, data);\n }\n }\n\n private shouldRetry(): boolean {\n return this.state === 'connecting' || this.state === 'connected';\n }\n}\n","import Channel from './channel';\nimport * as Collections from '../utils/collections';\nimport ChannelTable from './channel_table';\nimport Factory from '../utils/factory';\nimport Pusher from '../pusher';\nimport Logger from '../logger';\nimport * as Errors from '../errors';\nimport urlStore from '../utils/url_store';\n\n/** Handles a channel map. */\nexport default class Channels {\n channels: ChannelTable;\n\n constructor() {\n this.channels = {};\n }\n\n /** Creates or retrieves an existing channel by its name.\n *\n * @param {String} name\n * @param {Pusher} pusher\n * @return {Channel}\n */\n add(name: string, pusher: Pusher) {\n if (!this.channels[name]) {\n this.channels[name] = createChannel(name, pusher);\n }\n return this.channels[name];\n }\n\n /** Returns a list of all channels\n *\n * @return {Array}\n */\n all(): Channel[] {\n return Collections.values(this.channels);\n }\n\n /** Finds a channel by its name.\n *\n * @param {String} name\n * @return {Channel} channel or null if it doesn't exist\n */\n find(name: string) {\n return this.channels[name];\n }\n\n /** Removes a channel from the map.\n *\n * @param {String} name\n */\n remove(name: string) {\n var channel = this.channels[name];\n delete this.channels[name];\n return channel;\n }\n\n /** Proxies disconnection signal to all channels. */\n disconnect() {\n Collections.objectApply(this.channels, function(channel) {\n channel.disconnect();\n });\n }\n}\n\nfunction createChannel(name: string, pusher: Pusher): Channel {\n if (name.indexOf('private-encrypted-') === 0) {\n if (pusher.config.nacl) {\n return Factory.createEncryptedChannel(name, pusher, pusher.config.nacl);\n }\n let errMsg =\n 'Tried to subscribe to a private-encrypted- channel but no nacl implementation available';\n let suffix = urlStore.buildLogSuffix('encryptedChannelSupport');\n throw new Errors.UnsupportedFeature(`${errMsg}. ${suffix}`);\n } else if (name.indexOf('private-') === 0) {\n return Factory.createPrivateChannel(name, pusher);\n } else if (name.indexOf('presence-') === 0) {\n return Factory.createPresenceChannel(name, pusher);\n } else if (name.indexOf('#') === 0) {\n throw new Errors.BadChannelName(\n 'Cannot create a channel with name \"' + name + '\".'\n );\n } else {\n return Factory.createChannel(name, pusher);\n }\n}\n","import AssistantToTheTransportManager from '../transports/assistant_to_the_transport_manager';\nimport PingDelayOptions from '../transports/ping_delay_options';\nimport Transport from '../transports/transport';\nimport TransportManager from '../transports/transport_manager';\nimport Handshake from '../connection/handshake';\nimport TransportConnection from '../transports/transport_connection';\nimport SocketHooks from '../http/socket_hooks';\nimport HTTPSocket from '../http/http_socket';\n\nimport Timeline from '../timeline/timeline';\nimport {\n default as TimelineSender,\n TimelineSenderOptions\n} from '../timeline/timeline_sender';\nimport PresenceChannel from '../channels/presence_channel';\nimport PrivateChannel from '../channels/private_channel';\nimport EncryptedChannel from '../channels/encrypted_channel';\nimport Channel from '../channels/channel';\nimport ConnectionManager from '../connection/connection_manager';\nimport ConnectionManagerOptions from '../connection/connection_manager_options';\nimport Ajax from '../http/ajax';\nimport Channels from '../channels/channels';\nimport Pusher from '../pusher';\nimport { Config } from '../config';\nimport * as nacl from 'tweetnacl';\n\nvar Factory = {\n createChannels(): Channels {\n return new Channels();\n },\n\n createConnectionManager(\n key: string,\n options: ConnectionManagerOptions\n ): ConnectionManager {\n return new ConnectionManager(key, options);\n },\n\n createChannel(name: string, pusher: Pusher): Channel {\n return new Channel(name, pusher);\n },\n\n createPrivateChannel(name: string, pusher: Pusher): PrivateChannel {\n return new PrivateChannel(name, pusher);\n },\n\n createPresenceChannel(name: string, pusher: Pusher): PresenceChannel {\n return new PresenceChannel(name, pusher);\n },\n\n createEncryptedChannel(\n name: string,\n pusher: Pusher,\n nacl: nacl\n ): EncryptedChannel {\n return new EncryptedChannel(name, pusher, nacl);\n },\n\n createTimelineSender(timeline: Timeline, options: TimelineSenderOptions) {\n return new TimelineSender(timeline, options);\n },\n\n createHandshake(\n transport: TransportConnection,\n callback: (HandshakePayload) => void\n ): Handshake {\n return new Handshake(transport, callback);\n },\n\n createAssistantToTheTransportManager(\n manager: TransportManager,\n transport: Transport,\n options: PingDelayOptions\n ): AssistantToTheTransportManager {\n return new AssistantToTheTransportManager(manager, transport, options);\n }\n};\n\nexport default Factory;\n","import AssistantToTheTransportManager from './assistant_to_the_transport_manager';\nimport Transport from './transport';\nimport PingDelayOptions from './ping_delay_options';\nimport Factory from '../utils/factory';\n\nexport interface TransportManagerOptions extends PingDelayOptions {\n lives?: number;\n}\n\n/** Keeps track of the number of lives left for a transport.\n *\n * In the beginning of a session, transports may be assigned a number of\n * lives. When an AssistantToTheTransportManager instance reports a transport\n * connection closed uncleanly, the transport loses a life. When the number\n * of lives drops to zero, the transport gets disabled by its manager.\n *\n * @param {Object} options\n */\nexport default class TransportManager {\n options: TransportManagerOptions;\n livesLeft: number;\n\n constructor(options: TransportManagerOptions) {\n this.options = options || {};\n this.livesLeft = this.options.lives || Infinity;\n }\n\n /** Creates a assistant for the transport.\n *\n * @param {Transport} transport\n * @returns {AssistantToTheTransportManager}\n */\n getAssistant(transport: Transport): AssistantToTheTransportManager {\n return Factory.createAssistantToTheTransportManager(this, transport, {\n minPingDelay: this.options.minPingDelay,\n maxPingDelay: this.options.maxPingDelay\n });\n }\n\n /** Returns whether the transport has any lives left.\n *\n * @returns {Boolean}\n */\n isAlive(): boolean {\n return this.livesLeft > 0;\n }\n\n /** Takes one life from the transport. */\n reportDeath() {\n this.livesLeft -= 1;\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport { OneOffTimer as Timer } from '../utils/timers';\nimport Strategy from './strategy';\nimport StrategyOptions from './strategy_options';\n\n/** Loops through strategies with optional timeouts.\n *\n * Options:\n * - loop - whether it should loop through the substrategy list\n * - timeout - initial timeout for a single substrategy\n * - timeoutLimit - maximum timeout\n *\n * @param {Strategy[]} strategies\n * @param {Object} options\n */\nexport default class SequentialStrategy implements Strategy {\n strategies: Strategy[];\n loop: boolean;\n failFast: boolean;\n timeout: number;\n timeoutLimit: number;\n\n constructor(strategies: Strategy[], options: StrategyOptions) {\n this.strategies = strategies;\n this.loop = Boolean(options.loop);\n this.failFast = Boolean(options.failFast);\n this.timeout = options.timeout;\n this.timeoutLimit = options.timeoutLimit;\n }\n\n isSupported(): boolean {\n return Collections.any(this.strategies, Util.method('isSupported'));\n }\n\n connect(minPriority: number, callback: Function) {\n var strategies = this.strategies;\n var current = 0;\n var timeout = this.timeout;\n var runner = null;\n\n var tryNextStrategy = (error, handshake) => {\n if (handshake) {\n callback(null, handshake);\n } else {\n current = current + 1;\n if (this.loop) {\n current = current % strategies.length;\n }\n\n if (current < strategies.length) {\n if (timeout) {\n timeout = timeout * 2;\n if (this.timeoutLimit) {\n timeout = Math.min(timeout, this.timeoutLimit);\n }\n }\n runner = this.tryStrategy(\n strategies[current],\n minPriority,\n { timeout, failFast: this.failFast },\n tryNextStrategy\n );\n } else {\n callback(true);\n }\n }\n };\n\n runner = this.tryStrategy(\n strategies[current],\n minPriority,\n { timeout: timeout, failFast: this.failFast },\n tryNextStrategy\n );\n\n return {\n abort: function() {\n runner.abort();\n },\n forceMinPriority: function(p) {\n minPriority = p;\n if (runner) {\n runner.forceMinPriority(p);\n }\n }\n };\n }\n\n private tryStrategy(\n strategy: Strategy,\n minPriority: number,\n options: StrategyOptions,\n callback: Function\n ) {\n var timer = null;\n var runner = null;\n\n if (options.timeout > 0) {\n timer = new Timer(options.timeout, function() {\n runner.abort();\n callback(true);\n });\n }\n\n runner = strategy.connect(minPriority, function(error, handshake) {\n if (error && timer && timer.isRunning() && !options.failFast) {\n // advance to the next strategy after the timeout\n return;\n }\n if (timer) {\n timer.ensureAborted();\n }\n callback(error, handshake);\n });\n\n return {\n abort: function() {\n if (timer) {\n timer.ensureAborted();\n }\n runner.abort();\n },\n forceMinPriority: function(p) {\n runner.forceMinPriority(p);\n }\n };\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport Strategy from './strategy';\n\n/** Launches all substrategies and emits prioritized connected transports.\n *\n * @param {Array} strategies\n */\nexport default class BestConnectedEverStrategy implements Strategy {\n strategies: Strategy[];\n\n constructor(strategies: Strategy[]) {\n this.strategies = strategies;\n }\n\n isSupported(): boolean {\n return Collections.any(this.strategies, Util.method('isSupported'));\n }\n\n connect(minPriority: number, callback: Function) {\n return connect(this.strategies, minPriority, function(i, runners) {\n return function(error, handshake) {\n runners[i].error = error;\n if (error) {\n if (allRunnersFailed(runners)) {\n callback(true);\n }\n return;\n }\n Collections.apply(runners, function(runner) {\n runner.forceMinPriority(handshake.transport.priority);\n });\n callback(null, handshake);\n };\n });\n }\n}\n\n/** Connects to all strategies in parallel.\n *\n * Callback builder should be a function that takes two arguments: index\n * and a list of runners. It should return another function that will be\n * passed to the substrategy with given index. Runners can be aborted using\n * abortRunner(s) functions from this class.\n *\n * @param {Array} strategies\n * @param {Function} callbackBuilder\n * @return {Object} strategy runner\n */\nfunction connect(\n strategies: Strategy[],\n minPriority: number,\n callbackBuilder: Function\n) {\n var runners = Collections.map(strategies, function(strategy, i, _, rs) {\n return strategy.connect(minPriority, callbackBuilder(i, rs));\n });\n return {\n abort: function() {\n Collections.apply(runners, abortRunner);\n },\n forceMinPriority: function(p) {\n Collections.apply(runners, function(runner) {\n runner.forceMinPriority(p);\n });\n }\n };\n}\n\nfunction allRunnersFailed(runners): boolean {\n return Collections.all(runners, function(runner) {\n return Boolean(runner.error);\n });\n}\n\nfunction abortRunner(runner) {\n if (!runner.error && !runner.aborted) {\n runner.abort();\n runner.aborted = true;\n }\n}\n","import Util from '../util';\nimport Runtime from 'runtime';\nimport Strategy from './strategy';\nimport SequentialStrategy from './sequential_strategy';\nimport StrategyOptions from './strategy_options';\nimport TransportStrategy from './transport_strategy';\nimport Timeline from '../timeline/timeline';\nimport * as Collections from '../utils/collections';\n\nexport interface TransportStrategyDictionary {\n [key: string]: TransportStrategy;\n}\n\n/** Caches the last successful transport and, after the first few attempts,\n * uses the cached transport for subsequent attempts.\n *\n * @param {Strategy} strategy\n * @param {Object} transports\n * @param {Object} options\n */\nexport default class WebSocketPrioritizedCachedStrategy implements Strategy {\n strategy: Strategy;\n transports: TransportStrategyDictionary;\n ttl: number;\n usingTLS: boolean;\n timeline: Timeline;\n\n constructor(\n strategy: Strategy,\n transports: TransportStrategyDictionary,\n options: StrategyOptions\n ) {\n this.strategy = strategy;\n this.transports = transports;\n this.ttl = options.ttl || 1800 * 1000;\n this.usingTLS = options.useTLS;\n this.timeline = options.timeline;\n }\n\n isSupported(): boolean {\n return this.strategy.isSupported();\n }\n\n connect(minPriority: number, callback: Function) {\n var usingTLS = this.usingTLS;\n var info = fetchTransportCache(usingTLS);\n var cacheSkipCount = info && info.cacheSkipCount ? info.cacheSkipCount : 0;\n\n var strategies = [this.strategy];\n if (info && info.timestamp + this.ttl >= Util.now()) {\n var transport = this.transports[info.transport];\n if (transport) {\n if (['ws', 'wss'].includes(info.transport) || cacheSkipCount > 3) {\n this.timeline.info({\n cached: true,\n transport: info.transport,\n latency: info.latency\n });\n strategies.push(\n new SequentialStrategy([transport], {\n timeout: info.latency * 2 + 1000,\n failFast: true\n })\n );\n } else {\n cacheSkipCount++;\n }\n }\n }\n\n var startTimestamp = Util.now();\n var runner = strategies\n .pop()\n .connect(minPriority, function cb(error, handshake) {\n if (error) {\n flushTransportCache(usingTLS);\n if (strategies.length > 0) {\n startTimestamp = Util.now();\n runner = strategies.pop().connect(minPriority, cb);\n } else {\n callback(error);\n }\n } else {\n storeTransportCache(\n usingTLS,\n handshake.transport.name,\n Util.now() - startTimestamp,\n cacheSkipCount\n );\n callback(null, handshake);\n }\n });\n\n return {\n abort: function() {\n runner.abort();\n },\n forceMinPriority: function(p) {\n minPriority = p;\n if (runner) {\n runner.forceMinPriority(p);\n }\n }\n };\n }\n}\n\nfunction getTransportCacheKey(usingTLS: boolean): string {\n return 'pusherTransport' + (usingTLS ? 'TLS' : 'NonTLS');\n}\n\nfunction fetchTransportCache(usingTLS: boolean): any {\n var storage = Runtime.getLocalStorage();\n if (storage) {\n try {\n var serializedCache = storage[getTransportCacheKey(usingTLS)];\n if (serializedCache) {\n return JSON.parse(serializedCache);\n }\n } catch (e) {\n flushTransportCache(usingTLS);\n }\n }\n return null;\n}\n\nfunction storeTransportCache(\n usingTLS: boolean,\n transport: TransportStrategy,\n latency: number,\n cacheSkipCount: number\n) {\n var storage = Runtime.getLocalStorage();\n if (storage) {\n try {\n storage[getTransportCacheKey(usingTLS)] = Collections.safeJSONStringify({\n timestamp: Util.now(),\n transport: transport,\n latency: latency,\n cacheSkipCount: cacheSkipCount\n });\n } catch (e) {\n // catch over quota exceptions raised by localStorage\n }\n }\n}\n\nfunction flushTransportCache(usingTLS: boolean) {\n var storage = Runtime.getLocalStorage();\n if (storage) {\n try {\n delete storage[getTransportCacheKey(usingTLS)];\n } catch (e) {\n // catch exceptions raised by localStorage\n }\n }\n}\n","import { OneOffTimer as Timer } from '../utils/timers';\nimport Strategy from './strategy';\nimport StrategyOptions from './strategy_options';\n\n/** Runs substrategy after specified delay.\n *\n * Options:\n * - delay - time in miliseconds to delay the substrategy attempt\n *\n * @param {Strategy} strategy\n * @param {Object} options\n */\nexport default class DelayedStrategy implements Strategy {\n strategy: Strategy;\n options: { delay: number };\n\n constructor(strategy: Strategy, { delay: number }) {\n this.strategy = strategy;\n this.options = { delay: number };\n }\n\n isSupported(): boolean {\n return this.strategy.isSupported();\n }\n\n connect(minPriority: number, callback: Function) {\n var strategy = this.strategy;\n var runner;\n var timer = new Timer(this.options.delay, function() {\n runner = strategy.connect(minPriority, callback);\n });\n\n return {\n abort: function() {\n timer.ensureAborted();\n if (runner) {\n runner.abort();\n }\n },\n forceMinPriority: function(p) {\n minPriority = p;\n if (runner) {\n runner.forceMinPriority(p);\n }\n }\n };\n }\n}\n","import Strategy from './strategy';\nimport StrategyRunner from './strategy_runner';\n\n/** Proxies method calls to one of substrategies basing on the test function.\n *\n * @param {Function} test\n * @param {Strategy} trueBranch strategy used when test returns true\n * @param {Strategy} falseBranch strategy used when test returns false\n */\nexport default class IfStrategy implements Strategy {\n test: () => boolean;\n trueBranch: Strategy;\n falseBranch: Strategy;\n\n constructor(\n test: () => boolean,\n trueBranch: Strategy,\n falseBranch: Strategy\n ) {\n this.test = test;\n this.trueBranch = trueBranch;\n this.falseBranch = falseBranch;\n }\n\n isSupported(): boolean {\n var branch = this.test() ? this.trueBranch : this.falseBranch;\n return branch.isSupported();\n }\n\n connect(minPriority: number, callback: Function): StrategyRunner {\n var branch = this.test() ? this.trueBranch : this.falseBranch;\n return branch.connect(minPriority, callback);\n }\n}\n","import Strategy from './strategy';\nimport StrategyRunner from './strategy_runner';\n\n/** Launches the substrategy and terminates on the first open connection.\n *\n * @param {Strategy} strategy\n */\nexport default class FirstConnectedStrategy implements Strategy {\n strategy: Strategy;\n\n constructor(strategy: Strategy) {\n this.strategy = strategy;\n }\n\n isSupported(): boolean {\n return this.strategy.isSupported();\n }\n\n connect(minPriority: number, callback: Function): StrategyRunner {\n var runner = this.strategy.connect(minPriority, function(error, handshake) {\n if (handshake) {\n runner.abort();\n }\n callback(error, handshake);\n });\n return runner;\n }\n}\n","import * as Collections from 'core/utils/collections';\nimport TransportManager from 'core/transports/transport_manager';\nimport Strategy from 'core/strategies/strategy';\nimport SequentialStrategy from 'core/strategies/sequential_strategy';\nimport BestConnectedEverStrategy from 'core/strategies/best_connected_ever_strategy';\nimport WebSocketPrioritizedCachedStrategy, {\n TransportStrategyDictionary\n} from 'core/strategies/websocket_prioritized_cached_strategy';\nimport DelayedStrategy from 'core/strategies/delayed_strategy';\nimport IfStrategy from 'core/strategies/if_strategy';\nimport FirstConnectedStrategy from 'core/strategies/first_connected_strategy';\nimport { Config } from 'core/config';\nimport StrategyOptions from 'core/strategies/strategy_options';\n\nfunction testSupportsStrategy(strategy: Strategy) {\n return function() {\n return strategy.isSupported();\n };\n}\n\nvar getDefaultStrategy = function(\n config: Config,\n baseOptions: StrategyOptions,\n defineTransport: Function\n): Strategy {\n var definedTransports = {};\n\n function defineTransportStrategy(\n name: string,\n type: string,\n priority: number,\n options: StrategyOptions,\n manager?: TransportManager\n ) {\n var transport = defineTransport(\n config,\n name,\n type,\n priority,\n options,\n manager\n );\n\n definedTransports[name] = transport;\n\n return transport;\n }\n\n var ws_options: StrategyOptions = Object.assign({}, baseOptions, {\n hostNonTLS: config.wsHost + ':' + config.wsPort,\n hostTLS: config.wsHost + ':' + config.wssPort,\n httpPath: config.wsPath\n });\n var wss_options: StrategyOptions = Collections.extend({}, ws_options, {\n useTLS: true\n });\n var http_options: StrategyOptions = Object.assign({}, baseOptions, {\n hostNonTLS: config.httpHost + ':' + config.httpPort,\n hostTLS: config.httpHost + ':' + config.httpsPort,\n httpPath: config.httpPath\n });\n var timeouts = {\n loop: true,\n timeout: 15000,\n timeoutLimit: 60000\n };\n\n var ws_manager = new TransportManager({\n minPingDelay: 10000,\n maxPingDelay: config.activityTimeout\n });\n var streaming_manager = new TransportManager({\n lives: 2,\n minPingDelay: 10000,\n maxPingDelay: config.activityTimeout\n });\n\n var ws_transport = defineTransportStrategy(\n 'ws',\n 'ws',\n 3,\n ws_options,\n ws_manager\n );\n var wss_transport = defineTransportStrategy(\n 'wss',\n 'ws',\n 3,\n wss_options,\n ws_manager\n );\n var xhr_streaming_transport = defineTransportStrategy(\n 'xhr_streaming',\n 'xhr_streaming',\n 1,\n http_options,\n streaming_manager\n );\n var xhr_polling_transport = defineTransportStrategy(\n 'xhr_polling',\n 'xhr_polling',\n 1,\n http_options\n );\n\n var ws_loop = new SequentialStrategy([ws_transport], timeouts);\n var wss_loop = new SequentialStrategy([wss_transport], timeouts);\n var streaming_loop = new SequentialStrategy(\n [xhr_streaming_transport],\n timeouts\n );\n var polling_loop = new SequentialStrategy([xhr_polling_transport], timeouts);\n\n var http_loop = new SequentialStrategy(\n [\n new IfStrategy(\n testSupportsStrategy(streaming_loop),\n new BestConnectedEverStrategy([\n streaming_loop,\n new DelayedStrategy(polling_loop, { delay: 4000 })\n ]),\n polling_loop\n )\n ],\n timeouts\n );\n\n var wsStrategy;\n if (baseOptions.useTLS) {\n wsStrategy = new BestConnectedEverStrategy([\n ws_loop,\n new DelayedStrategy(http_loop, { delay: 2000 })\n ]);\n } else {\n wsStrategy = new BestConnectedEverStrategy([\n ws_loop,\n new DelayedStrategy(wss_loop, { delay: 2000 }),\n new DelayedStrategy(http_loop, { delay: 5000 })\n ]);\n }\n\n return new WebSocketPrioritizedCachedStrategy(\n new FirstConnectedStrategy(\n new IfStrategy(testSupportsStrategy(ws_transport), wsStrategy, http_loop)\n ),\n definedTransports,\n {\n ttl: 1800000,\n timeline: baseOptions.timeline,\n useTLS: baseOptions.useTLS\n }\n );\n};\n\nexport default getDefaultStrategy;\n","import Runtime from 'runtime';\nimport RequestHooks from './request_hooks';\nimport Ajax from './ajax';\nimport { default as EventsDispatcher } from '../events/dispatcher';\n\nconst MAX_BUFFER_LENGTH = 256 * 1024;\n\nexport default class HTTPRequest extends EventsDispatcher {\n hooks: RequestHooks;\n method: string;\n url: string;\n position: number;\n xhr: Ajax;\n unloader: Function;\n\n constructor(hooks: RequestHooks, method: string, url: string) {\n super();\n this.hooks = hooks;\n this.method = method;\n this.url = url;\n }\n\n start(payload?: any) {\n this.position = 0;\n this.xhr = this.hooks.getRequest(this);\n\n this.unloader = () => {\n this.close();\n };\n Runtime.addUnloadListener(this.unloader);\n\n this.xhr.open(this.method, this.url, true);\n\n if (this.xhr.setRequestHeader) {\n this.xhr.setRequestHeader('Content-Type', 'application/json'); // ReactNative doesn't set this header by default.\n }\n this.xhr.send(payload);\n }\n\n close() {\n if (this.unloader) {\n Runtime.removeUnloadListener(this.unloader);\n this.unloader = null;\n }\n if (this.xhr) {\n this.hooks.abortRequest(this.xhr);\n this.xhr = null;\n }\n }\n\n onChunk(status: number, data: any) {\n while (true) {\n var chunk = this.advanceBuffer(data);\n if (chunk) {\n this.emit('chunk', { status: status, data: chunk });\n } else {\n break;\n }\n }\n if (this.isBufferTooLong(data)) {\n this.emit('buffer_too_long');\n }\n }\n\n private advanceBuffer(buffer: any[]): any {\n var unreadData = buffer.slice(this.position);\n var endOfLinePosition = unreadData.indexOf('\\n');\n\n if (endOfLinePosition !== -1) {\n this.position += endOfLinePosition + 1;\n return unreadData.slice(0, endOfLinePosition);\n } else {\n // chunk is not finished yet, don't move the buffer pointer\n return null;\n }\n }\n\n private isBufferTooLong(buffer: any): boolean {\n return this.position === buffer.length && buffer.length > MAX_BUFFER_LENGTH;\n }\n}\n","enum State {\n CONNECTING = 0,\n OPEN = 1,\n CLOSED = 3\n}\n\nexport default State;\n","import URLLocation from './url_location';\nimport State from './state';\nimport Socket from '../socket';\nimport SocketHooks from './socket_hooks';\nimport Util from '../util';\nimport Ajax from './ajax';\nimport HTTPRequest from './http_request';\nimport Runtime from 'runtime';\n\nvar autoIncrement = 1;\n\nclass HTTPSocket implements Socket {\n hooks: SocketHooks;\n session: string;\n location: URLLocation;\n readyState: State;\n stream: HTTPRequest;\n\n onopen: () => void;\n onerror: (error: any) => void;\n onclose: (closeEvent: any) => void;\n onmessage: (message: any) => void;\n onactivity: () => void;\n\n constructor(hooks: SocketHooks, url: string) {\n this.hooks = hooks;\n this.session = randomNumber(1000) + '/' + randomString(8);\n this.location = getLocation(url);\n this.readyState = State.CONNECTING;\n this.openStream();\n }\n\n send(payload: any) {\n return this.sendRaw(JSON.stringify([payload]));\n }\n\n ping() {\n this.hooks.sendHeartbeat(this);\n }\n\n close(code: any, reason: any) {\n this.onClose(code, reason, true);\n }\n\n /** For internal use only */\n sendRaw(payload: any): boolean {\n if (this.readyState === State.OPEN) {\n try {\n Runtime.createSocketRequest(\n 'POST',\n getUniqueURL(getSendURL(this.location, this.session))\n ).start(payload);\n return true;\n } catch (e) {\n return false;\n }\n } else {\n return false;\n }\n }\n\n /** For internal use only */\n reconnect() {\n this.closeStream();\n this.openStream();\n }\n\n /** For internal use only */\n onClose(code, reason, wasClean) {\n this.closeStream();\n this.readyState = State.CLOSED;\n if (this.onclose) {\n this.onclose({\n code: code,\n reason: reason,\n wasClean: wasClean\n });\n }\n }\n\n private onChunk(chunk) {\n if (chunk.status !== 200) {\n return;\n }\n if (this.readyState === State.OPEN) {\n this.onActivity();\n }\n\n var payload;\n var type = chunk.data.slice(0, 1);\n switch (type) {\n case 'o':\n payload = JSON.parse(chunk.data.slice(1) || '{}');\n this.onOpen(payload);\n break;\n case 'a':\n payload = JSON.parse(chunk.data.slice(1) || '[]');\n for (var i = 0; i < payload.length; i++) {\n this.onEvent(payload[i]);\n }\n break;\n case 'm':\n payload = JSON.parse(chunk.data.slice(1) || 'null');\n this.onEvent(payload);\n break;\n case 'h':\n this.hooks.onHeartbeat(this);\n break;\n case 'c':\n payload = JSON.parse(chunk.data.slice(1) || '[]');\n this.onClose(payload[0], payload[1], true);\n break;\n }\n }\n\n private onOpen(options) {\n if (this.readyState === State.CONNECTING) {\n if (options && options.hostname) {\n this.location.base = replaceHost(this.location.base, options.hostname);\n }\n this.readyState = State.OPEN;\n\n if (this.onopen) {\n this.onopen();\n }\n } else {\n this.onClose(1006, 'Server lost session', true);\n }\n }\n\n private onEvent(event) {\n if (this.readyState === State.OPEN && this.onmessage) {\n this.onmessage({ data: event });\n }\n }\n\n private onActivity() {\n if (this.onactivity) {\n this.onactivity();\n }\n }\n\n private onError(error) {\n if (this.onerror) {\n this.onerror(error);\n }\n }\n\n private openStream() {\n this.stream = Runtime.createSocketRequest(\n 'POST',\n getUniqueURL(this.hooks.getReceiveURL(this.location, this.session))\n );\n\n this.stream.bind('chunk', chunk => {\n this.onChunk(chunk);\n });\n this.stream.bind('finished', status => {\n this.hooks.onFinished(this, status);\n });\n this.stream.bind('buffer_too_long', () => {\n this.reconnect();\n });\n\n try {\n this.stream.start();\n } catch (error) {\n Util.defer(() => {\n this.onError(error);\n this.onClose(1006, 'Could not start streaming', false);\n });\n }\n }\n\n private closeStream() {\n if (this.stream) {\n this.stream.unbind_all();\n this.stream.close();\n this.stream = null;\n }\n }\n}\n\nfunction getLocation(url): URLLocation {\n var parts = /([^\\?]*)\\/*(\\??.*)/.exec(url);\n return {\n base: parts[1],\n queryString: parts[2]\n };\n}\n\nfunction getSendURL(url: URLLocation, session: string): string {\n return url.base + '/' + session + '/xhr_send';\n}\n\nfunction getUniqueURL(url: string): string {\n var separator = url.indexOf('?') === -1 ? '?' : '&';\n return url + separator + 't=' + +new Date() + '&n=' + autoIncrement++;\n}\n\nfunction replaceHost(url: string, hostname: string): string {\n var urlParts = /(https?:\\/\\/)([^\\/:]+)((\\/|:)?.*)/.exec(url);\n return urlParts[1] + hostname + urlParts[3];\n}\n\nfunction randomNumber(max: number): number {\n return Runtime.randomInt(max);\n}\n\nfunction randomString(length: number): string {\n var result = [];\n\n for (var i = 0; i < length; i++) {\n result.push(randomNumber(32).toString(32));\n }\n\n return result.join('');\n}\n\nexport default HTTPSocket;\n","import SocketHooks from './socket_hooks';\nimport HTTPSocket from './http_socket';\n\nvar hooks: SocketHooks = {\n getReceiveURL: function(url, session) {\n return url.base + '/' + session + '/xhr_streaming' + url.queryString;\n },\n onHeartbeat: function(socket) {\n socket.sendRaw('[]');\n },\n sendHeartbeat: function(socket) {\n socket.sendRaw('[]');\n },\n onFinished: function(socket, status) {\n socket.onClose(1006, 'Connection interrupted (' + status + ')', false);\n }\n};\n\nexport default hooks;\n","import SocketHooks from './socket_hooks';\nimport URLLocation from './url_location';\nimport HTTPSocket from './http_socket';\n\nvar hooks: SocketHooks = {\n getReceiveURL: function(url: URLLocation, session: string): string {\n return url.base + '/' + session + '/xhr' + url.queryString;\n },\n onHeartbeat: function() {\n // next HTTP request will reset server's activity timer\n },\n sendHeartbeat: function(socket) {\n socket.sendRaw('[]');\n },\n onFinished: function(socket, status) {\n if (status === 200) {\n socket.reconnect();\n } else {\n socket.onClose(1006, 'Connection interrupted (' + status + ')', false);\n }\n }\n};\n\nexport default hooks;\n","import HTTPRequest from 'core/http/http_request';\nimport RequestHooks from 'core/http/request_hooks';\nimport Ajax from 'core/http/ajax';\nimport Runtime from 'runtime';\n\nvar hooks: RequestHooks = {\n getRequest: function(socket: HTTPRequest): Ajax {\n var Constructor = Runtime.getXHRAPI();\n var xhr = new Constructor();\n xhr.onreadystatechange = xhr.onprogress = function() {\n switch (xhr.readyState) {\n case 3:\n if (xhr.responseText && xhr.responseText.length > 0) {\n socket.onChunk(xhr.status, xhr.responseText);\n }\n break;\n case 4:\n // this happens only on errors, never after calling close\n if (xhr.responseText && xhr.responseText.length > 0) {\n socket.onChunk(xhr.status, xhr.responseText);\n }\n socket.emit('finished', xhr.status);\n socket.close();\n break;\n }\n };\n return xhr;\n },\n abortRequest: function(xhr: Ajax) {\n xhr.onreadystatechange = null;\n xhr.abort();\n }\n};\n\nexport default hooks;\n","import * as Collections from 'core/utils/collections';\nimport Transports from 'isomorphic/transports/transports';\nimport TimelineSender from 'core/timeline/timeline_sender';\nimport Ajax from 'core/http/ajax';\nimport getDefaultStrategy from './default_strategy';\nimport TransportsTable from 'core/transports/transports_table';\nimport transportConnectionInitializer from './transports/transport_connection_initializer';\nimport HTTPFactory from './http/http';\n\nvar Isomorphic: any = {\n getDefaultStrategy,\n Transports: Transports,\n transportConnectionInitializer,\n HTTPFactory,\n\n setup(PusherClass): void {\n PusherClass.ready();\n },\n\n getLocalStorage(): any {\n return undefined;\n },\n\n getClientFeatures(): any[] {\n return Collections.keys(\n Collections.filterObject({ ws: Transports.ws }, function(t) {\n return t.isSupported({});\n })\n );\n },\n\n getProtocol(): string {\n return 'http:';\n },\n\n isXHRSupported(): boolean {\n return true;\n },\n\n createSocketRequest(method: string, url: string) {\n if (this.isXHRSupported()) {\n return this.HTTPFactory.createXHR(method, url);\n } else {\n throw 'Cross-origin HTTP requests are not supported';\n }\n },\n\n createXHR(): Ajax {\n var Constructor = this.getXHRAPI();\n return new Constructor();\n },\n\n createWebSocket(url: string): any {\n var Constructor = this.getWebSocketAPI();\n return new Constructor(url);\n },\n\n addUnloadListener(listener: any) {},\n removeUnloadListener(listener: any) {}\n};\n\nexport default Isomorphic;\n","/** Initializes the transport.\n *\n * Fetches resources if needed and then transitions to initialized.\n */\nexport default function() {\n var self = this;\n\n self.timeline.info(\n self.buildTimelineMessage({\n transport: self.name + (self.options.useTLS ? 's' : '')\n })\n );\n\n if (self.hooks.isInitialized()) {\n self.changeState('initialized');\n } else {\n self.onClose();\n }\n}\n","import HTTPRequest from 'core/http/http_request';\nimport HTTPSocket from 'core/http/http_socket';\nimport SocketHooks from 'core/http/socket_hooks';\nimport RequestHooks from 'core/http/request_hooks';\nimport streamingHooks from 'core/http/http_streaming_socket';\nimport pollingHooks from 'core/http/http_polling_socket';\nimport xhrHooks from './http_xhr_request';\nimport HTTPFactory from 'core/http/http_factory';\n\nvar HTTP: HTTPFactory = {\n createStreamingSocket(url: string): HTTPSocket {\n return this.createSocket(streamingHooks, url);\n },\n\n createPollingSocket(url: string): HTTPSocket {\n return this.createSocket(pollingHooks, url);\n },\n\n createSocket(hooks: SocketHooks, url: string): HTTPSocket {\n return new HTTPSocket(hooks, url);\n },\n\n createXHR(method: string, url: string): HTTPRequest {\n return this.createRequest(xhrHooks, method, url);\n },\n\n createRequest(hooks: RequestHooks, method: string, url: string): HTTPRequest {\n return new HTTPRequest(hooks, method, url);\n }\n};\n\nexport default HTTP;\n","import { default as NativeNetInfo } from '@react-native-community/netinfo';\nimport EventsDispatcher from 'core/events/dispatcher';\nimport Util from 'core/util';\nimport Reachability from 'core/reachability';\n\nfunction hasOnlineConnectionState(connectionState): boolean {\n return connectionState.type.toLowerCase() !== 'none';\n}\n\nexport class NetInfo extends EventsDispatcher implements Reachability {\n online: boolean;\n\n constructor() {\n super();\n this.online = true;\n\n NativeNetInfo.fetch().then(connectionState => {\n this.online = hasOnlineConnectionState(connectionState);\n });\n\n NativeNetInfo.addEventListener(connectionState => {\n var isNowOnline = hasOnlineConnectionState(connectionState);\n\n // React Native counts the switch from Wi-Fi to Cellular\n // as a state change. Return if current and previous states\n // are both online/offline\n if (this.online === isNowOnline) return;\n this.online = isNowOnline;\n if (this.online) {\n this.emit('online');\n } else {\n this.emit('offline');\n }\n });\n }\n\n isOnline(): boolean {\n return this.online;\n }\n}\n\nexport var Network = new NetInfo();\n","export enum AuthRequestType {\n UserAuthentication = 'user-authentication',\n ChannelAuthorization = 'channel-authorization'\n}\n\nexport interface ChannelAuthorizationData {\n auth: string;\n channel_data?: string;\n shared_secret?: string;\n}\n\nexport type ChannelAuthorizationCallback = (\n error: Error | null,\n authData: ChannelAuthorizationData | null\n) => void;\n\nexport interface ChannelAuthorizationRequestParams {\n socketId: string;\n channelName: string;\n}\n\nexport interface ChannelAuthorizationHandler {\n (\n params: ChannelAuthorizationRequestParams,\n callback: ChannelAuthorizationCallback\n ): void;\n}\n\nexport interface UserAuthenticationData {\n auth: string;\n user_data: string;\n}\n\nexport type UserAuthenticationCallback = (\n error: Error | null,\n authData: UserAuthenticationData | null\n) => void;\n\nexport interface UserAuthenticationRequestParams {\n socketId: string;\n}\n\nexport interface UserAuthenticationHandler {\n (\n params: UserAuthenticationRequestParams,\n callback: UserAuthenticationCallback\n ): void;\n}\n\nexport type AuthTransportCallback =\n | ChannelAuthorizationCallback\n | UserAuthenticationCallback;\n\nexport interface AuthOptionsT {\n transport: 'ajax' | 'jsonp';\n endpoint: string;\n params?: any;\n headers?: any;\n paramsProvider?: () => any;\n headersProvider?: () => any;\n customHandler?: AuthHandler;\n}\n\nexport declare type UserAuthenticationOptions = AuthOptionsT<\n UserAuthenticationHandler\n>;\nexport declare type ChannelAuthorizationOptions = AuthOptionsT<\n ChannelAuthorizationHandler\n>;\n\nexport interface InternalAuthOptions {\n transport: 'ajax' | 'jsonp';\n endpoint: string;\n params?: any;\n headers?: any;\n paramsProvider?: () => any;\n headersProvider?: () => any;\n}\n","import TimelineSender from 'core/timeline/timeline_sender';\nimport * as Collections from 'core/utils/collections';\nimport Util from 'core/util';\nimport Runtime from 'runtime';\nimport { AuthTransport } from 'core/auth/auth_transports';\nimport AbstractRuntime from 'runtimes/interface';\nimport UrlStore from 'core/utils/url_store';\nimport {\n AuthRequestType,\n AuthTransportCallback,\n InternalAuthOptions\n} from 'core/auth/options';\nimport { HTTPAuthError } from 'core/errors';\n\nconst ajax: AuthTransport = function(\n context: AbstractRuntime,\n query: string,\n authOptions: InternalAuthOptions,\n authRequestType: AuthRequestType,\n callback: AuthTransportCallback\n) {\n const xhr = Runtime.createXHR();\n xhr.open('POST', authOptions.endpoint, true);\n\n // add request headers\n xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');\n for (var headerName in authOptions.headers) {\n xhr.setRequestHeader(headerName, authOptions.headers[headerName]);\n }\n if (authOptions.headersProvider != null) {\n let dynamicHeaders = authOptions.headersProvider();\n for (var headerName in dynamicHeaders) {\n xhr.setRequestHeader(headerName, dynamicHeaders[headerName]);\n }\n }\n\n xhr.onreadystatechange = function() {\n if (xhr.readyState === 4) {\n if (xhr.status === 200) {\n let data;\n let parsed = false;\n\n try {\n data = JSON.parse(xhr.responseText);\n parsed = true;\n } catch (e) {\n callback(\n new HTTPAuthError(\n 200,\n `JSON returned from ${authRequestType.toString()} endpoint was invalid, yet status code was 200. Data was: ${\n xhr.responseText\n }`\n ),\n null\n );\n }\n\n if (parsed) {\n // prevents double execution.\n callback(null, data);\n }\n } else {\n let suffix = '';\n switch (authRequestType) {\n case AuthRequestType.UserAuthentication:\n suffix = UrlStore.buildLogSuffix('authenticationEndpoint');\n break;\n case AuthRequestType.ChannelAuthorization:\n suffix = `Clients must be authorized to join private or presence channels. ${UrlStore.buildLogSuffix(\n 'authorizationEndpoint'\n )}`;\n break;\n }\n callback(\n new HTTPAuthError(\n xhr.status,\n `Unable to retrieve auth string from ${authRequestType.toString()} endpoint - ` +\n `received status: ${xhr.status} from ${authOptions.endpoint}. ${suffix}`\n ),\n null\n );\n }\n }\n };\n\n xhr.send(query);\n return xhr;\n};\n\nexport default ajax;\n","import Logger from 'core/logger';\nimport TimelineSender from 'core/timeline/timeline_sender';\nimport * as Collections from 'core/utils/collections';\nimport Util from 'core/util';\nimport Runtime from 'runtime';\nimport TimelineTransport from 'core/timeline/timeline_transport';\n\nvar getAgent = function(sender: TimelineSender, useTLS: boolean) {\n return function(data: any, callback: Function) {\n var scheme = 'http' + (useTLS ? 's' : '') + '://';\n var url =\n scheme + (sender.host || sender.options.host) + sender.options.path;\n var query = Collections.buildQueryString(data);\n\n url += '/' + 2 + '?' + query;\n\n var xhr = Runtime.createXHR();\n xhr.open('GET', url, true);\n\n xhr.onreadystatechange = function() {\n if (xhr.readyState === 4) {\n let { status, responseText } = xhr;\n if (status !== 200) {\n Logger.debug(\n `TimelineSender Error: received ${status} from stats.pusher.com`\n );\n return;\n }\n\n try {\n var { host } = JSON.parse(responseText);\n } catch (e) {\n Logger.debug(`TimelineSenderError: invalid response ${responseText}`);\n }\n if (host) {\n sender.host = host;\n }\n }\n };\n\n xhr.send();\n };\n};\n\nvar xhr = {\n name: 'xhr',\n getAgent\n};\n\nexport default xhr;\n","import Isomorphic from 'isomorphic/runtime';\nimport Runtime from '../interface';\nimport { Network } from './net_info';\nimport xhrAuth from 'isomorphic/auth/xhr_auth';\nimport { AuthTransports } from 'core/auth/auth_transports';\nimport xhrTimeline from 'isomorphic/timeline/xhr_timeline';\n\n// Very verbose but until unavoidable until\n// TypeScript 2.1, when spread attributes will be\n// supported\nconst {\n getDefaultStrategy,\n Transports,\n setup,\n getProtocol,\n isXHRSupported,\n getLocalStorage,\n createXHR,\n createWebSocket,\n addUnloadListener,\n removeUnloadListener,\n transportConnectionInitializer,\n createSocketRequest,\n HTTPFactory\n} = Isomorphic;\n\nconst ReactNative: Runtime = {\n getDefaultStrategy,\n Transports,\n setup,\n getProtocol,\n isXHRSupported,\n getLocalStorage,\n createXHR,\n createWebSocket,\n addUnloadListener,\n removeUnloadListener,\n transportConnectionInitializer,\n createSocketRequest,\n HTTPFactory,\n\n TimelineTransport: xhrTimeline,\n\n getAuthorizers(): AuthTransports {\n return { ajax: xhrAuth };\n },\n\n getWebSocketAPI() {\n return WebSocket;\n },\n\n getXHRAPI() {\n return XMLHttpRequest;\n },\n\n getNetwork() {\n return Network;\n },\n\n randomInt(max: number): number {\n return Math.floor(Math.random() * max);\n }\n};\n\nexport default ReactNative;\n","enum TimelineLevel {\n ERROR = 3,\n INFO = 6,\n DEBUG = 7\n}\n\nexport default TimelineLevel;\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport { default as Level } from './level';\n\nexport interface TimelineOptions {\n level?: Level;\n limit?: number;\n version?: string;\n cluster?: string;\n features?: string[];\n params?: any;\n}\n\nexport default class Timeline {\n key: string;\n session: number;\n events: any[];\n options: TimelineOptions;\n sent: number;\n uniqueID: number;\n\n constructor(key: string, session: number, options: TimelineOptions) {\n this.key = key;\n this.session = session;\n this.events = [];\n this.options = options || {};\n this.sent = 0;\n this.uniqueID = 0;\n }\n\n log(level, event) {\n if (level <= this.options.level) {\n this.events.push(\n Collections.extend({}, event, { timestamp: Util.now() })\n );\n if (this.options.limit && this.events.length > this.options.limit) {\n this.events.shift();\n }\n }\n }\n\n error(event) {\n this.log(Level.ERROR, event);\n }\n\n info(event) {\n this.log(Level.INFO, event);\n }\n\n debug(event) {\n this.log(Level.DEBUG, event);\n }\n\n isEmpty() {\n return this.events.length === 0;\n }\n\n send(sendfn, callback) {\n var data = Collections.extend(\n {\n session: this.session,\n bundle: this.sent + 1,\n key: this.key,\n lib: 'js',\n version: this.options.version,\n cluster: this.options.cluster,\n features: this.options.features,\n timeline: this.events\n },\n this.options.params\n );\n\n this.events = [];\n sendfn(data, (error, result) => {\n if (!error) {\n this.sent++;\n }\n if (callback) {\n callback(error, result);\n }\n });\n\n return true;\n }\n\n generateUniqueID(): number {\n this.uniqueID++;\n return this.uniqueID;\n }\n}\n","import Factory from '../utils/factory';\nimport Util from '../util';\nimport * as Errors from '../errors';\nimport * as Collections from '../utils/collections';\nimport Strategy from './strategy';\nimport Transport from '../transports/transport';\nimport StrategyOptions from './strategy_options';\nimport Handshake from '../connection/handshake';\n\n/** Provides a strategy interface for transports.\n *\n * @param {String} name\n * @param {Number} priority\n * @param {Class} transport\n * @param {Object} options\n */\nexport default class TransportStrategy implements Strategy {\n name: string;\n priority: number;\n transport: Transport;\n options: StrategyOptions;\n\n constructor(\n name: string,\n priority: number,\n transport: Transport,\n options: StrategyOptions\n ) {\n this.name = name;\n this.priority = priority;\n this.transport = transport;\n this.options = options || {};\n }\n\n /** Returns whether the transport is supported in the browser.\n *\n * @returns {Boolean}\n */\n isSupported(): boolean {\n return this.transport.isSupported({\n useTLS: this.options.useTLS\n });\n }\n\n /** Launches a connection attempt and returns a strategy runner.\n *\n * @param {Function} callback\n * @return {Object} strategy runner\n */\n connect(minPriority: number, callback: Function) {\n if (!this.isSupported()) {\n return failAttempt(new Errors.UnsupportedStrategy(), callback);\n } else if (this.priority < minPriority) {\n return failAttempt(new Errors.TransportPriorityTooLow(), callback);\n }\n\n var connected = false;\n var transport = this.transport.createConnection(\n this.name,\n this.priority,\n this.options.key,\n this.options\n );\n var handshake = null;\n\n var onInitialized = function() {\n transport.unbind('initialized', onInitialized);\n transport.connect();\n };\n var onOpen = function() {\n handshake = Factory.createHandshake(transport, function(result) {\n connected = true;\n unbindListeners();\n callback(null, result);\n });\n };\n var onError = function(error) {\n unbindListeners();\n callback(error);\n };\n var onClosed = function() {\n unbindListeners();\n var serializedTransport;\n\n // The reason for this try/catch block is that on React Native\n // the WebSocket object is circular. Therefore transport.socket will\n // throw errors upon stringification. Collections.safeJSONStringify\n // discards circular references when serializing.\n serializedTransport = Collections.safeJSONStringify(transport);\n callback(new Errors.TransportClosed(serializedTransport));\n };\n\n var unbindListeners = function() {\n transport.unbind('initialized', onInitialized);\n transport.unbind('open', onOpen);\n transport.unbind('error', onError);\n transport.unbind('closed', onClosed);\n };\n\n transport.bind('initialized', onInitialized);\n transport.bind('open', onOpen);\n transport.bind('error', onError);\n transport.bind('closed', onClosed);\n\n // connect will be called automatically after initialization\n transport.initialize();\n\n return {\n abort: () => {\n if (connected) {\n return;\n }\n unbindListeners();\n if (handshake) {\n handshake.close();\n } else {\n transport.close();\n }\n },\n forceMinPriority: p => {\n if (connected) {\n return;\n }\n if (this.priority < p) {\n if (handshake) {\n handshake.close();\n } else {\n transport.close();\n }\n }\n }\n };\n }\n}\n\nfunction failAttempt(error: Error, callback: Function) {\n Util.defer(function() {\n callback(error);\n });\n return {\n abort: function() {},\n forceMinPriority: function() {}\n };\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport TransportManager from '../transports/transport_manager';\nimport * as Errors from '../errors';\nimport Strategy from './strategy';\nimport TransportStrategy from './transport_strategy';\nimport StrategyOptions from '../strategies/strategy_options';\nimport { Config } from '../config';\nimport Runtime from 'runtime';\n\nconst { Transports } = Runtime;\n\nexport var defineTransport = function(\n config: Config,\n name: string,\n type: string,\n priority: number,\n options: StrategyOptions,\n manager?: TransportManager\n): Strategy {\n var transportClass = Transports[type];\n if (!transportClass) {\n throw new Errors.UnsupportedTransport(type);\n }\n\n var enabled =\n (!config.enabledTransports ||\n Collections.arrayIndexOf(config.enabledTransports, name) !== -1) &&\n (!config.disabledTransports ||\n Collections.arrayIndexOf(config.disabledTransports, name) === -1);\n\n var transport;\n if (enabled) {\n options = Object.assign(\n { ignoreNullOrigin: config.ignoreNullOrigin },\n options\n );\n\n transport = new TransportStrategy(\n name,\n priority,\n manager ? manager.getAssistant(transportClass) : transportClass,\n options\n );\n } else {\n transport = UnsupportedStrategy;\n }\n\n return transport;\n};\n\nvar UnsupportedStrategy: Strategy = {\n isSupported: function() {\n return false;\n },\n connect: function(_, callback) {\n var deferred = Util.defer(function() {\n callback(new Errors.UnsupportedStrategy());\n });\n return {\n abort: function() {\n deferred.ensureAborted();\n },\n forceMinPriority: function() {}\n };\n }\n};\n","import {\n UserAuthenticationCallback,\n InternalAuthOptions,\n UserAuthenticationHandler,\n UserAuthenticationRequestParams,\n AuthRequestType\n} from './options';\n\nimport Runtime from 'runtime';\n\nconst composeChannelQuery = (\n params: UserAuthenticationRequestParams,\n authOptions: InternalAuthOptions\n) => {\n var query = 'socket_id=' + encodeURIComponent(params.socketId);\n\n for (var key in authOptions.params) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(authOptions.params[key]);\n }\n\n if (authOptions.paramsProvider != null) {\n let dynamicParams = authOptions.paramsProvider();\n for (var key in dynamicParams) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(dynamicParams[key]);\n }\n }\n\n return query;\n};\n\nconst UserAuthenticator = (\n authOptions: InternalAuthOptions\n): UserAuthenticationHandler => {\n if (typeof Runtime.getAuthorizers()[authOptions.transport] === 'undefined') {\n throw `'${authOptions.transport}' is not a recognized auth transport`;\n }\n\n return (\n params: UserAuthenticationRequestParams,\n callback: UserAuthenticationCallback\n ) => {\n const query = composeChannelQuery(params, authOptions);\n\n Runtime.getAuthorizers()[authOptions.transport](\n Runtime,\n query,\n authOptions,\n AuthRequestType.UserAuthentication,\n callback\n );\n };\n};\n\nexport default UserAuthenticator;\n","import {\n AuthRequestType,\n InternalAuthOptions,\n ChannelAuthorizationHandler,\n ChannelAuthorizationRequestParams,\n ChannelAuthorizationCallback\n} from './options';\n\nimport Runtime from 'runtime';\n\nconst composeChannelQuery = (\n params: ChannelAuthorizationRequestParams,\n authOptions: InternalAuthOptions\n) => {\n var query = 'socket_id=' + encodeURIComponent(params.socketId);\n\n query += '&channel_name=' + encodeURIComponent(params.channelName);\n\n for (var key in authOptions.params) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(authOptions.params[key]);\n }\n\n if (authOptions.paramsProvider != null) {\n let dynamicParams = authOptions.paramsProvider();\n for (var key in dynamicParams) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(dynamicParams[key]);\n }\n }\n\n return query;\n};\n\nconst ChannelAuthorizer = (\n authOptions: InternalAuthOptions\n): ChannelAuthorizationHandler => {\n if (typeof Runtime.getAuthorizers()[authOptions.transport] === 'undefined') {\n throw `'${authOptions.transport}' is not a recognized auth transport`;\n }\n\n return (\n params: ChannelAuthorizationRequestParams,\n callback: ChannelAuthorizationCallback\n ) => {\n const query = composeChannelQuery(params, authOptions);\n\n Runtime.getAuthorizers()[authOptions.transport](\n Runtime,\n query,\n authOptions,\n AuthRequestType.ChannelAuthorization,\n callback\n );\n };\n};\n\nexport default ChannelAuthorizer;\n","import { Options } from './options';\nimport Defaults from './defaults';\nimport {\n ChannelAuthorizationHandler,\n UserAuthenticationHandler,\n ChannelAuthorizationOptions\n} from './auth/options';\nimport UserAuthenticator from './auth/user_authenticator';\nimport ChannelAuthorizer from './auth/channel_authorizer';\nimport { ChannelAuthorizerProxy } from './auth/deprecated_channel_authorizer';\nimport Runtime from 'runtime';\nimport * as nacl from 'tweetnacl';\n\nexport type AuthTransport = 'ajax' | 'jsonp';\nexport type Transport =\n | 'ws'\n | 'wss'\n | 'xhr_streaming'\n | 'xhr_polling'\n | 'sockjs';\n\nexport interface Config {\n // these are all 'required' config parameters, it's not necessary for the user\n // to set them, but they have configured defaults.\n activityTimeout: number;\n enableStats: boolean;\n httpHost: string;\n httpPath: string;\n httpPort: number;\n httpsPort: number;\n pongTimeout: number;\n statsHost: string;\n unavailableTimeout: number;\n useTLS: boolean;\n wsHost: string;\n wsPath: string;\n wsPort: number;\n wssPort: number;\n userAuthenticator: UserAuthenticationHandler;\n channelAuthorizer: ChannelAuthorizationHandler;\n\n // these are all optional parameters or overrrides. The customer can set these\n // but it's not strictly necessary\n forceTLS?: boolean;\n cluster?: string;\n disabledTransports?: Transport[];\n enabledTransports?: Transport[];\n ignoreNullOrigin?: boolean;\n nacl?: nacl;\n timelineParams?: any;\n}\n\n// getConfig mainly sets the defaults for the options that are not provided\nexport function getConfig(opts: Options, pusher): Config {\n let config: Config = {\n activityTimeout: opts.activityTimeout || Defaults.activityTimeout,\n cluster: opts.cluster,\n httpPath: opts.httpPath || Defaults.httpPath,\n httpPort: opts.httpPort || Defaults.httpPort,\n httpsPort: opts.httpsPort || Defaults.httpsPort,\n pongTimeout: opts.pongTimeout || Defaults.pongTimeout,\n statsHost: opts.statsHost || Defaults.stats_host,\n unavailableTimeout: opts.unavailableTimeout || Defaults.unavailableTimeout,\n wsPath: opts.wsPath || Defaults.wsPath,\n wsPort: opts.wsPort || Defaults.wsPort,\n wssPort: opts.wssPort || Defaults.wssPort,\n\n enableStats: getEnableStatsConfig(opts),\n httpHost: getHttpHost(opts),\n useTLS: shouldUseTLS(opts),\n wsHost: getWebsocketHost(opts),\n\n userAuthenticator: buildUserAuthenticator(opts),\n channelAuthorizer: buildChannelAuthorizer(opts, pusher)\n };\n\n if ('disabledTransports' in opts)\n config.disabledTransports = opts.disabledTransports;\n if ('enabledTransports' in opts)\n config.enabledTransports = opts.enabledTransports;\n if ('ignoreNullOrigin' in opts)\n config.ignoreNullOrigin = opts.ignoreNullOrigin;\n if ('timelineParams' in opts) config.timelineParams = opts.timelineParams;\n if ('nacl' in opts) {\n config.nacl = opts.nacl;\n }\n\n return config;\n}\n\nfunction getHttpHost(opts: Options): string {\n if (opts.httpHost) {\n return opts.httpHost;\n }\n if (opts.cluster) {\n return `sockjs-${opts.cluster}.pusher.com`;\n }\n return Defaults.httpHost;\n}\n\nfunction getWebsocketHost(opts: Options): string {\n if (opts.wsHost) {\n return opts.wsHost;\n }\n return getWebsocketHostFromCluster(opts.cluster);\n}\n\nfunction getWebsocketHostFromCluster(cluster: string): string {\n return `ws-${cluster}.pusher.com`;\n}\n\nfunction shouldUseTLS(opts: Options): boolean {\n if (Runtime.getProtocol() === 'https:') {\n return true;\n } else if (opts.forceTLS === false) {\n return false;\n }\n return true;\n}\n\n// if enableStats is set take the value\n// if disableStats is set take the inverse\n// otherwise default to false\nfunction getEnableStatsConfig(opts: Options): boolean {\n if ('enableStats' in opts) {\n return opts.enableStats;\n }\n if ('disableStats' in opts) {\n return !opts.disableStats;\n }\n return false;\n}\n\nfunction buildUserAuthenticator(opts: Options): UserAuthenticationHandler {\n const userAuthentication = {\n ...Defaults.userAuthentication,\n ...opts.userAuthentication\n };\n if (\n 'customHandler' in userAuthentication &&\n userAuthentication['customHandler'] != null\n ) {\n return userAuthentication['customHandler'];\n }\n\n return UserAuthenticator(userAuthentication);\n}\n\nfunction buildChannelAuth(opts: Options, pusher): ChannelAuthorizationOptions {\n let channelAuthorization: ChannelAuthorizationOptions;\n if ('channelAuthorization' in opts) {\n channelAuthorization = {\n ...Defaults.channelAuthorization,\n ...opts.channelAuthorization\n };\n } else {\n channelAuthorization = {\n transport: opts.authTransport || Defaults.authTransport,\n endpoint: opts.authEndpoint || Defaults.authEndpoint\n };\n if ('auth' in opts) {\n if ('params' in opts.auth) channelAuthorization.params = opts.auth.params;\n if ('headers' in opts.auth)\n channelAuthorization.headers = opts.auth.headers;\n }\n if ('authorizer' in opts)\n channelAuthorization.customHandler = ChannelAuthorizerProxy(\n pusher,\n channelAuthorization,\n opts.authorizer\n );\n }\n return channelAuthorization;\n}\n\nfunction buildChannelAuthorizer(\n opts: Options,\n pusher\n): ChannelAuthorizationHandler {\n const channelAuthorization = buildChannelAuth(opts, pusher);\n if (\n 'customHandler' in channelAuthorization &&\n channelAuthorization['customHandler'] != null\n ) {\n return channelAuthorization['customHandler'];\n }\n\n return ChannelAuthorizer(channelAuthorization);\n}\n","import Channel from '../channels/channel';\nimport {\n ChannelAuthorizationCallback,\n ChannelAuthorizationHandler,\n ChannelAuthorizationRequestParams,\n InternalAuthOptions\n} from './options';\n\nexport interface DeprecatedChannelAuthorizer {\n authorize(socketId: string, callback: ChannelAuthorizationCallback): void;\n}\n\nexport interface ChannelAuthorizerGenerator {\n (\n channel: Channel,\n options: DeprecatedAuthorizerOptions\n ): DeprecatedChannelAuthorizer;\n}\n\nexport interface DeprecatedAuthOptions {\n params?: any;\n headers?: any;\n}\n\nexport interface DeprecatedAuthorizerOptions {\n authTransport: 'ajax' | 'jsonp';\n authEndpoint: string;\n auth?: DeprecatedAuthOptions;\n}\n\nexport const ChannelAuthorizerProxy = (\n pusher,\n authOptions: InternalAuthOptions,\n channelAuthorizerGenerator: ChannelAuthorizerGenerator\n): ChannelAuthorizationHandler => {\n const deprecatedAuthorizerOptions: DeprecatedAuthorizerOptions = {\n authTransport: authOptions.transport,\n authEndpoint: authOptions.endpoint,\n auth: {\n params: authOptions.params,\n headers: authOptions.headers\n }\n };\n return (\n params: ChannelAuthorizationRequestParams,\n callback: ChannelAuthorizationCallback\n ) => {\n const channel = pusher.channel(params.channelName);\n // This line creates a new channel authorizer every time.\n // In the past, this was only done once per channel and reused.\n // We can do that again if we want to keep this behavior intact.\n const channelAuthorizer: DeprecatedChannelAuthorizer = channelAuthorizerGenerator(\n channel,\n deprecatedAuthorizerOptions\n );\n channelAuthorizer.authorize(params.socketId, callback);\n };\n};\n","import Logger from './logger';\nimport Pusher from './pusher';\nimport EventsDispatcher from './events/dispatcher';\n\nexport default class WatchlistFacade extends EventsDispatcher {\n private pusher: Pusher;\n\n public constructor(pusher: Pusher) {\n super(function(eventName, data) {\n Logger.debug(`No callbacks on watchlist events for ${eventName}`);\n });\n\n this.pusher = pusher;\n this.bindWatchlistInternalEvent();\n }\n\n handleEvent(pusherEvent) {\n pusherEvent.data.events.forEach(watchlistEvent => {\n this.emit(watchlistEvent.name, watchlistEvent);\n });\n }\n\n private bindWatchlistInternalEvent() {\n this.pusher.connection.bind('message', pusherEvent => {\n var eventName = pusherEvent.event;\n if (eventName === 'pusher_internal:watchlist_events') {\n this.handleEvent(pusherEvent);\n }\n });\n }\n}\n","function flatPromise() {\n let resolve, reject;\n const promise = new Promise((res, rej) => {\n resolve = res;\n reject = rej;\n });\n return { promise, resolve, reject };\n}\n\nexport default flatPromise;\n","import Pusher from './pusher';\nimport Logger from './logger';\nimport {\n UserAuthenticationData,\n UserAuthenticationCallback\n} from './auth/options';\nimport Channel from './channels/channel';\nimport WatchlistFacade from './watchlist';\nimport EventsDispatcher from './events/dispatcher';\nimport flatPromise from './utils/flat_promise';\n\nexport default class UserFacade extends EventsDispatcher {\n pusher: Pusher;\n signin_requested: boolean = false;\n user_data: any = null;\n serverToUserChannel: Channel = null;\n signinDonePromise: Promise = null;\n watchlist: WatchlistFacade;\n private _signinDoneResolve: Function = null;\n\n public constructor(pusher: Pusher) {\n super(function(eventName, data) {\n Logger.debug('No callbacks on user for ' + eventName);\n });\n this.pusher = pusher;\n this.pusher.connection.bind('state_change', ({ previous, current }) => {\n if (previous !== 'connected' && current === 'connected') {\n this._signin();\n }\n if (previous === 'connected' && current !== 'connected') {\n this._cleanup();\n this._newSigninPromiseIfNeeded();\n }\n });\n\n this.watchlist = new WatchlistFacade(pusher);\n\n this.pusher.connection.bind('message', event => {\n var eventName = event.event;\n if (eventName === 'pusher:signin_success') {\n this._onSigninSuccess(event.data);\n }\n if (\n this.serverToUserChannel &&\n this.serverToUserChannel.name === event.channel\n ) {\n this.serverToUserChannel.handleEvent(event);\n }\n });\n }\n\n public signin() {\n if (this.signin_requested) {\n return;\n }\n\n this.signin_requested = true;\n this._signin();\n }\n\n private _signin() {\n if (!this.signin_requested) {\n return;\n }\n\n this._newSigninPromiseIfNeeded();\n\n if (this.pusher.connection.state !== 'connected') {\n // Signin will be attempted when the connection is connected\n return;\n }\n\n this.pusher.config.userAuthenticator(\n {\n socketId: this.pusher.connection.socket_id\n },\n this._onAuthorize\n );\n }\n\n private _onAuthorize: UserAuthenticationCallback = (\n err,\n authData: UserAuthenticationData\n ) => {\n if (err) {\n Logger.warn(`Error during signin: ${err}`);\n this._cleanup();\n return;\n }\n\n this.pusher.send_event('pusher:signin', {\n auth: authData.auth,\n user_data: authData.user_data\n });\n\n // Later when we get pusher:singin_success event, the user will be marked as signed in\n };\n\n private _onSigninSuccess(data: any) {\n try {\n this.user_data = JSON.parse(data.user_data);\n } catch (e) {\n Logger.error(`Failed parsing user data after signin: ${data.user_data}`);\n this._cleanup();\n return;\n }\n\n if (typeof this.user_data.id !== 'string' || this.user_data.id === '') {\n Logger.error(\n `user_data doesn't contain an id. user_data: ${this.user_data}`\n );\n this._cleanup();\n return;\n }\n\n // Signin succeeded\n this._signinDoneResolve();\n this._subscribeChannels();\n }\n\n private _subscribeChannels() {\n const ensure_subscribed = channel => {\n if (channel.subscriptionPending && channel.subscriptionCancelled) {\n channel.reinstateSubscription();\n } else if (\n !channel.subscriptionPending &&\n this.pusher.connection.state === 'connected'\n ) {\n channel.subscribe();\n }\n };\n\n this.serverToUserChannel = new Channel(\n `#server-to-user-${this.user_data.id}`,\n this.pusher\n );\n this.serverToUserChannel.bind_global((eventName, data) => {\n if (\n eventName.indexOf('pusher_internal:') === 0 ||\n eventName.indexOf('pusher:') === 0\n ) {\n // ignore internal events\n return;\n }\n this.emit(eventName, data);\n });\n ensure_subscribed(this.serverToUserChannel);\n }\n\n private _cleanup() {\n this.user_data = null;\n if (this.serverToUserChannel) {\n this.serverToUserChannel.unbind_all();\n this.serverToUserChannel.disconnect();\n this.serverToUserChannel = null;\n }\n\n if (this.signin_requested) {\n // If signin is in progress and cleanup is called,\n // Mark the current signin process as done.\n this._signinDoneResolve();\n }\n }\n\n private _newSigninPromiseIfNeeded() {\n if (!this.signin_requested) {\n return;\n }\n\n // If there is a promise and it is not resolved, return without creating a new one.\n if (this.signinDonePromise && !(this.signinDonePromise as any).done) {\n return;\n }\n\n // This promise is never rejected.\n // It gets resolved when the signin process is done whether it failed or succeeded\n const { promise, resolve, reject: _ } = flatPromise();\n (promise as any).done = false;\n const setDone = () => {\n (promise as any).done = true;\n };\n promise.then(setDone).catch(setDone);\n this.signinDonePromise = promise;\n this._signinDoneResolve = resolve;\n }\n}\n","import AbstractRuntime from '../runtimes/interface';\nimport Runtime from 'runtime';\nimport * as Collections from './utils/collections';\nimport Channels from './channels/channels';\nimport Channel from './channels/channel';\nimport { default as EventsDispatcher } from './events/dispatcher';\nimport Timeline from './timeline/timeline';\nimport TimelineSender from './timeline/timeline_sender';\nimport TimelineLevel from './timeline/level';\nimport { defineTransport } from './strategies/strategy_builder';\nimport ConnectionManager from './connection/connection_manager';\nimport { PeriodicTimer } from './utils/timers';\nimport Defaults from './defaults';\nimport Logger from './logger';\nimport Factory from './utils/factory';\nimport { Options, ClusterOptions, validateOptions } from './options';\nimport { Config, getConfig } from './config';\nimport StrategyOptions from './strategies/strategy_options';\nimport UserFacade from './user';\n\nexport default class Pusher {\n /* STATIC PROPERTIES */\n static instances: Pusher[] = [];\n static isReady: boolean = false;\n static logToConsole: boolean = false;\n\n // for jsonp\n static Runtime: AbstractRuntime = Runtime;\n static ScriptReceivers: any = (Runtime).ScriptReceivers;\n static DependenciesReceivers: any = (Runtime).DependenciesReceivers;\n static auth_callbacks: any = (Runtime).auth_callbacks;\n\n static ready() {\n Pusher.isReady = true;\n for (var i = 0, l = Pusher.instances.length; i < l; i++) {\n Pusher.instances[i].connect();\n }\n }\n\n static log: (message: any) => void;\n\n private static getClientFeatures(): string[] {\n return Collections.keys(\n Collections.filterObject({ ws: Runtime.Transports.ws }, function(t) {\n return t.isSupported({});\n })\n );\n }\n\n /* INSTANCE PROPERTIES */\n key: string;\n options: Options;\n config: Config;\n channels: Channels;\n global_emitter: EventsDispatcher;\n sessionID: number;\n timeline: Timeline;\n timelineSender: TimelineSender;\n connection: ConnectionManager;\n timelineSenderTimer: PeriodicTimer;\n user: UserFacade;\n constructor(app_key: string, options: Options) {\n checkAppKey(app_key);\n validateOptions(options);\n this.key = app_key;\n this.config = getConfig(options, this);\n\n this.channels = Factory.createChannels();\n this.global_emitter = new EventsDispatcher();\n this.sessionID = Runtime.randomInt(1000000000);\n\n this.timeline = new Timeline(this.key, this.sessionID, {\n cluster: this.config.cluster,\n features: Pusher.getClientFeatures(),\n params: this.config.timelineParams || {},\n limit: 50,\n level: TimelineLevel.INFO,\n version: Defaults.VERSION\n });\n if (this.config.enableStats) {\n this.timelineSender = Factory.createTimelineSender(this.timeline, {\n host: this.config.statsHost,\n path: '/timeline/v2/' + Runtime.TimelineTransport.name\n });\n }\n\n var getStrategy = (options: StrategyOptions) => {\n return Runtime.getDefaultStrategy(this.config, options, defineTransport);\n };\n\n this.connection = Factory.createConnectionManager(this.key, {\n getStrategy: getStrategy,\n timeline: this.timeline,\n activityTimeout: this.config.activityTimeout,\n pongTimeout: this.config.pongTimeout,\n unavailableTimeout: this.config.unavailableTimeout,\n useTLS: Boolean(this.config.useTLS)\n });\n\n this.connection.bind('connected', () => {\n this.subscribeAll();\n if (this.timelineSender) {\n this.timelineSender.send(this.connection.isUsingTLS());\n }\n });\n\n this.connection.bind('message', event => {\n var eventName = event.event;\n var internal = eventName.indexOf('pusher_internal:') === 0;\n if (event.channel) {\n var channel = this.channel(event.channel);\n if (channel) {\n channel.handleEvent(event);\n }\n }\n // Emit globally [deprecated]\n if (!internal) {\n this.global_emitter.emit(event.event, event.data);\n }\n });\n this.connection.bind('connecting', () => {\n this.channels.disconnect();\n });\n this.connection.bind('disconnected', () => {\n this.channels.disconnect();\n });\n this.connection.bind('error', err => {\n Logger.warn(err);\n });\n\n Pusher.instances.push(this);\n this.timeline.info({ instances: Pusher.instances.length });\n\n this.user = new UserFacade(this);\n\n if (Pusher.isReady) {\n this.connect();\n }\n }\n\n /**\n * Allows you to switch Pusher cluster without\n * losing all the channels/subscription binding\n * as this is internally managed by the SDK.\n */\n switchCluster(options: ClusterOptions) {\n const { appKey, cluster } = options;\n this.key = appKey;\n this.options = { ...this.options, cluster };\n this.config = getConfig(this.options, this);\n this.connection.switchCluster(this.key);\n }\n\n channel(name: string): Channel {\n return this.channels.find(name);\n }\n\n allChannels(): Channel[] {\n return this.channels.all();\n }\n\n connect() {\n this.connection.connect();\n\n if (this.timelineSender) {\n if (!this.timelineSenderTimer) {\n var usingTLS = this.connection.isUsingTLS();\n var timelineSender = this.timelineSender;\n this.timelineSenderTimer = new PeriodicTimer(60000, function() {\n timelineSender.send(usingTLS);\n });\n }\n }\n }\n\n disconnect() {\n this.connection.disconnect();\n\n if (this.timelineSenderTimer) {\n this.timelineSenderTimer.ensureAborted();\n this.timelineSenderTimer = null;\n }\n }\n\n bind(event_name: string, callback: Function, context?: any): Pusher {\n this.global_emitter.bind(event_name, callback, context);\n return this;\n }\n\n unbind(event_name?: string, callback?: Function, context?: any): Pusher {\n this.global_emitter.unbind(event_name, callback, context);\n return this;\n }\n\n bind_global(callback: Function): Pusher {\n this.global_emitter.bind_global(callback);\n return this;\n }\n\n unbind_global(callback?: Function): Pusher {\n this.global_emitter.unbind_global(callback);\n return this;\n }\n\n unbind_all(callback?: Function): Pusher {\n this.global_emitter.unbind_all();\n return this;\n }\n\n subscribeAll() {\n var channelName;\n for (channelName in this.channels.channels) {\n if (this.channels.channels.hasOwnProperty(channelName)) {\n this.subscribe(channelName);\n }\n }\n }\n\n subscribe(channel_name: string) {\n var channel = this.channels.add(channel_name, this);\n if (channel.subscriptionPending && channel.subscriptionCancelled) {\n channel.reinstateSubscription();\n } else if (\n !channel.subscriptionPending &&\n this.connection.state === 'connected'\n ) {\n channel.subscribe();\n }\n return channel;\n }\n\n unsubscribe(channel_name: string) {\n var channel = this.channels.find(channel_name);\n if (channel && channel.subscriptionPending) {\n channel.cancelSubscription();\n } else {\n channel = this.channels.remove(channel_name);\n if (channel && channel.subscribed) {\n channel.unsubscribe();\n }\n }\n }\n\n send_event(event_name: string, data: any, channel?: string) {\n return this.connection.send_event(event_name, data, channel);\n }\n\n shouldUseTLS(): boolean {\n return this.config.useTLS;\n }\n\n signin() {\n this.user.signin();\n }\n}\n\nfunction checkAppKey(key) {\n if (key === null || key === undefined) {\n throw 'You must pass your app key when you instantiate Pusher.';\n }\n}\n\nRuntime.setup(Pusher);\n","var g;\n\n// This works in non-strict mode\ng = (function() {\n\treturn this;\n})();\n\ntry {\n\t// This works if eval is allowed (see CSP)\n\tg = g || new Function(\"return this\")();\n} catch (e) {\n\t// This works if the window reference is available\n\tif (typeof window === \"object\") g = window;\n}\n\n// g can still be undefined, but nothing to do about it...\n// We return undefined, instead of nothing here, so it's\n// easier to handle this case. if(!global) { ...}\n\nmodule.exports = g;\n","import ConnectionManager from './connection/connection_manager';\nimport {\n ChannelAuthorizationOptions,\n UserAuthenticationOptions\n} from './auth/options';\nimport {\n ChannelAuthorizerGenerator,\n DeprecatedAuthOptions\n} from './auth/deprecated_channel_authorizer';\nimport { AuthTransport, Transport } from './config';\nimport * as nacl from 'tweetnacl';\nimport Logger from './logger';\n\nexport interface Options {\n activityTimeout?: number;\n\n auth?: DeprecatedAuthOptions; // DEPRECATED use channelAuthorization instead\n authEndpoint?: string; // DEPRECATED use channelAuthorization instead\n authTransport?: AuthTransport; // DEPRECATED use channelAuthorization instead\n authorizer?: ChannelAuthorizerGenerator; // DEPRECATED use channelAuthorization instead\n\n channelAuthorization?: ChannelAuthorizationOptions;\n userAuthentication?: UserAuthenticationOptions;\n\n cluster: string;\n enableStats?: boolean;\n disableStats?: boolean;\n disabledTransports?: Transport[];\n enabledTransports?: Transport[];\n forceTLS?: boolean;\n httpHost?: string;\n httpPath?: string;\n httpPort?: number;\n httpsPort?: number;\n ignoreNullOrigin?: boolean;\n nacl?: nacl;\n pongTimeout?: number;\n statsHost?: string;\n timelineParams?: any;\n unavailableTimeout?: number;\n wsHost?: string;\n wsPath?: string;\n wsPort?: number;\n wssPort?: number;\n}\n\nexport interface ClusterOptions {\n appKey: string;\n cluster: string;\n}\n\nexport function validateOptions(options) {\n if (options == null) {\n throw 'You must pass an options object';\n }\n if (options.cluster == null) {\n throw 'Options object must provide a cluster';\n }\n if ('disableStats' in options) {\n Logger.warn(\n 'The disableStats option is deprecated in favor of enableStats'\n );\n }\n}\n","// Copyright (C) 2016 Dmitry Chestnykh\n// MIT License. See LICENSE file for details.\n\n/**\n * Package base64 implements Base64 encoding and decoding.\n */\n\n// Invalid character used in decoding to indicate\n// that the character to decode is out of range of\n// alphabet and cannot be decoded.\nconst INVALID_BYTE = 256;\n\n/**\n * Implements standard Base64 encoding.\n *\n * Operates in constant time.\n */\nexport class Coder {\n // TODO(dchest): methods to encode chunk-by-chunk.\n\n constructor(private _paddingCharacter = \"=\") { }\n\n encodedLength(length: number): number {\n if (!this._paddingCharacter) {\n return (length * 8 + 5) / 6 | 0;\n }\n return (length + 2) / 3 * 4 | 0;\n }\n\n encode(data: Uint8Array): string {\n let out = \"\";\n\n let i = 0;\n for (; i < data.length - 2; i += 3) {\n let c = (data[i] << 16) | (data[i + 1] << 8) | (data[i + 2]);\n out += this._encodeByte((c >>> 3 * 6) & 63);\n out += this._encodeByte((c >>> 2 * 6) & 63);\n out += this._encodeByte((c >>> 1 * 6) & 63);\n out += this._encodeByte((c >>> 0 * 6) & 63);\n }\n\n const left = data.length - i;\n if (left > 0) {\n let c = (data[i] << 16) | (left === 2 ? data[i + 1] << 8 : 0);\n out += this._encodeByte((c >>> 3 * 6) & 63);\n out += this._encodeByte((c >>> 2 * 6) & 63);\n if (left === 2) {\n out += this._encodeByte((c >>> 1 * 6) & 63);\n } else {\n out += this._paddingCharacter || \"\";\n }\n out += this._paddingCharacter || \"\";\n }\n\n return out;\n }\n\n maxDecodedLength(length: number): number {\n if (!this._paddingCharacter) {\n return (length * 6 + 7) / 8 | 0;\n }\n return length / 4 * 3 | 0;\n }\n\n decodedLength(s: string): number {\n return this.maxDecodedLength(s.length - this._getPaddingLength(s));\n }\n\n decode(s: string): Uint8Array {\n if (s.length === 0) {\n return new Uint8Array(0);\n }\n const paddingLength = this._getPaddingLength(s);\n const length = s.length - paddingLength;\n const out = new Uint8Array(this.maxDecodedLength(length));\n let op = 0;\n let i = 0;\n let haveBad = 0;\n let v0 = 0, v1 = 0, v2 = 0, v3 = 0;\n for (; i < length - 4; i += 4) {\n v0 = this._decodeChar(s.charCodeAt(i + 0));\n v1 = this._decodeChar(s.charCodeAt(i + 1));\n v2 = this._decodeChar(s.charCodeAt(i + 2));\n v3 = this._decodeChar(s.charCodeAt(i + 3));\n out[op++] = (v0 << 2) | (v1 >>> 4);\n out[op++] = (v1 << 4) | (v2 >>> 2);\n out[op++] = (v2 << 6) | v3;\n haveBad |= v0 & INVALID_BYTE;\n haveBad |= v1 & INVALID_BYTE;\n haveBad |= v2 & INVALID_BYTE;\n haveBad |= v3 & INVALID_BYTE;\n }\n if (i < length - 1) {\n v0 = this._decodeChar(s.charCodeAt(i));\n v1 = this._decodeChar(s.charCodeAt(i + 1));\n out[op++] = (v0 << 2) | (v1 >>> 4);\n haveBad |= v0 & INVALID_BYTE;\n haveBad |= v1 & INVALID_BYTE;\n }\n if (i < length - 2) {\n v2 = this._decodeChar(s.charCodeAt(i + 2));\n out[op++] = (v1 << 4) | (v2 >>> 2);\n haveBad |= v2 & INVALID_BYTE;\n }\n if (i < length - 3) {\n v3 = this._decodeChar(s.charCodeAt(i + 3));\n out[op++] = (v2 << 6) | v3;\n haveBad |= v3 & INVALID_BYTE;\n }\n if (haveBad !== 0) {\n throw new Error(\"Base64Coder: incorrect characters for decoding\");\n }\n return out;\n }\n\n // Standard encoding have the following encoded/decoded ranges,\n // which we need to convert between.\n //\n // ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 0123456789 + /\n // Index: 0 - 25 26 - 51 52 - 61 62 63\n // ASCII: 65 - 90 97 - 122 48 - 57 43 47\n //\n\n // Encode 6 bits in b into a new character.\n protected _encodeByte(b: number): string {\n // Encoding uses constant time operations as follows:\n //\n // 1. Define comparison of A with B using (A - B) >>> 8:\n // if A > B, then result is positive integer\n // if A <= B, then result is 0\n //\n // 2. Define selection of C or 0 using bitwise AND: X & C:\n // if X == 0, then result is 0\n // if X != 0, then result is C\n //\n // 3. Start with the smallest comparison (b >= 0), which is always\n // true, so set the result to the starting ASCII value (65).\n //\n // 4. Continue comparing b to higher ASCII values, and selecting\n // zero if comparison isn't true, otherwise selecting a value\n // to add to result, which:\n //\n // a) undoes the previous addition\n // b) provides new value to add\n //\n let result = b;\n // b >= 0\n result += 65;\n // b > 25\n result += ((25 - b) >>> 8) & ((0 - 65) - 26 + 97);\n // b > 51\n result += ((51 - b) >>> 8) & ((26 - 97) - 52 + 48);\n // b > 61\n result += ((61 - b) >>> 8) & ((52 - 48) - 62 + 43);\n // b > 62\n result += ((62 - b) >>> 8) & ((62 - 43) - 63 + 47);\n\n return String.fromCharCode(result);\n }\n\n // Decode a character code into a byte.\n // Must return 256 if character is out of alphabet range.\n protected _decodeChar(c: number): number {\n // Decoding works similar to encoding: using the same comparison\n // function, but now it works on ranges: result is always incremented\n // by value, but this value becomes zero if the range is not\n // satisfied.\n //\n // Decoding starts with invalid value, 256, which is then\n // subtracted when the range is satisfied. If none of the ranges\n // apply, the function returns 256, which is then checked by\n // the caller to throw error.\n let result = INVALID_BYTE; // start with invalid character\n\n // c == 43 (c > 42 and c < 44)\n result += (((42 - c) & (c - 44)) >>> 8) & (-INVALID_BYTE + c - 43 + 62);\n // c == 47 (c > 46 and c < 48)\n result += (((46 - c) & (c - 48)) >>> 8) & (-INVALID_BYTE + c - 47 + 63);\n // c > 47 and c < 58\n result += (((47 - c) & (c - 58)) >>> 8) & (-INVALID_BYTE + c - 48 + 52);\n // c > 64 and c < 91\n result += (((64 - c) & (c - 91)) >>> 8) & (-INVALID_BYTE + c - 65 + 0);\n // c > 96 and c < 123\n result += (((96 - c) & (c - 123)) >>> 8) & (-INVALID_BYTE + c - 97 + 26);\n\n return result;\n }\n\n private _getPaddingLength(s: string): number {\n let paddingLength = 0;\n if (this._paddingCharacter) {\n for (let i = s.length - 1; i >= 0; i--) {\n if (s[i] !== this._paddingCharacter) {\n break;\n }\n paddingLength++;\n }\n if (s.length < 4 || paddingLength > 2) {\n throw new Error(\"Base64Coder: incorrect padding\");\n }\n }\n return paddingLength;\n }\n\n}\n\nconst stdCoder = new Coder();\n\nexport function encode(data: Uint8Array): string {\n return stdCoder.encode(data);\n}\n\nexport function decode(s: string): Uint8Array {\n return stdCoder.decode(s);\n}\n\n/**\n * Implements URL-safe Base64 encoding.\n * (Same as Base64, but '+' is replaced with '-', and '/' with '_').\n *\n * Operates in constant time.\n */\nexport class URLSafeCoder extends Coder {\n // URL-safe encoding have the following encoded/decoded ranges:\n //\n // ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 0123456789 - _\n // Index: 0 - 25 26 - 51 52 - 61 62 63\n // ASCII: 65 - 90 97 - 122 48 - 57 45 95\n //\n\n protected _encodeByte(b: number): string {\n let result = b;\n // b >= 0\n result += 65;\n // b > 25\n result += ((25 - b) >>> 8) & ((0 - 65) - 26 + 97);\n // b > 51\n result += ((51 - b) >>> 8) & ((26 - 97) - 52 + 48);\n // b > 61\n result += ((61 - b) >>> 8) & ((52 - 48) - 62 + 45);\n // b > 62\n result += ((62 - b) >>> 8) & ((62 - 45) - 63 + 95);\n\n return String.fromCharCode(result);\n }\n\n protected _decodeChar(c: number): number {\n let result = INVALID_BYTE;\n\n // c == 45 (c > 44 and c < 46)\n result += (((44 - c) & (c - 46)) >>> 8) & (-INVALID_BYTE + c - 45 + 62);\n // c == 95 (c > 94 and c < 96)\n result += (((94 - c) & (c - 96)) >>> 8) & (-INVALID_BYTE + c - 95 + 63);\n // c > 47 and c < 58\n result += (((47 - c) & (c - 58)) >>> 8) & (-INVALID_BYTE + c - 48 + 52);\n // c > 64 and c < 91\n result += (((64 - c) & (c - 91)) >>> 8) & (-INVALID_BYTE + c - 65 + 0);\n // c > 96 and c < 123\n result += (((96 - c) & (c - 123)) >>> 8) & (-INVALID_BYTE + c - 97 + 26);\n\n return result;\n }\n}\n\nconst urlSafeCoder = new URLSafeCoder();\n\nexport function encodeURLSafe(data: Uint8Array): string {\n return urlSafeCoder.encode(data);\n}\n\nexport function decodeURLSafe(s: string): Uint8Array {\n return urlSafeCoder.decode(s);\n}\n\n\nexport const encodedLength = (length: number) =>\n stdCoder.encodedLength(length);\n\nexport const maxDecodedLength = (length: number) =>\n stdCoder.maxDecodedLength(length);\n\nexport const decodedLength = (s: string) =>\n stdCoder.decodedLength(s);\n","import TimedCallback from './timed_callback';\nimport { Delay, Scheduler, Canceller } from './scheduling';\n\nabstract class Timer {\n protected clear: Canceller;\n protected timer: number | void;\n\n constructor(\n set: Scheduler,\n clear: Canceller,\n delay: Delay,\n callback: TimedCallback\n ) {\n this.clear = clear;\n this.timer = set(() => {\n if (this.timer) {\n this.timer = callback(this.timer);\n }\n }, delay);\n }\n\n /** Returns whether the timer is still running.\n *\n * @return {Boolean}\n */\n isRunning(): boolean {\n return this.timer !== null;\n }\n\n /** Aborts a timer when it's running. */\n ensureAborted() {\n if (this.timer) {\n this.clear(this.timer);\n this.timer = null;\n }\n }\n}\n\nexport default Timer;\n","module.exports = require(\"@react-native-community/netinfo\");","export default function encode(s: any): string {\n return btoa(utob(s));\n}\n\nvar fromCharCode = String.fromCharCode;\n\nvar b64chars =\n 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';\nvar b64tab = {};\n\nfor (var i = 0, l = b64chars.length; i < l; i++) {\n b64tab[b64chars.charAt(i)] = i;\n}\n\nvar cb_utob = function(c) {\n var cc = c.charCodeAt(0);\n return cc < 0x80\n ? c\n : cc < 0x800\n ? fromCharCode(0xc0 | (cc >>> 6)) + fromCharCode(0x80 | (cc & 0x3f))\n : fromCharCode(0xe0 | ((cc >>> 12) & 0x0f)) +\n fromCharCode(0x80 | ((cc >>> 6) & 0x3f)) +\n fromCharCode(0x80 | (cc & 0x3f));\n};\n\nvar utob = function(u) {\n return u.replace(/[^\\x00-\\x7F]/g, cb_utob);\n};\n\nvar cb_encode = function(ccc) {\n var padlen = [0, 2, 1][ccc.length % 3];\n var ord =\n (ccc.charCodeAt(0) << 16) |\n ((ccc.length > 1 ? ccc.charCodeAt(1) : 0) << 8) |\n (ccc.length > 2 ? ccc.charCodeAt(2) : 0);\n var chars = [\n b64chars.charAt(ord >>> 18),\n b64chars.charAt((ord >>> 12) & 63),\n padlen >= 2 ? '=' : b64chars.charAt((ord >>> 6) & 63),\n padlen >= 1 ? '=' : b64chars.charAt(ord & 63)\n ];\n return chars.join('');\n};\n\nvar btoa =\n global.btoa ||\n function(b) {\n return b.replace(/[\\s\\S]{1,3}/g, cb_encode);\n };\n","import Callback from './callback';\nimport * as Collections from '../utils/collections';\nimport CallbackTable from './callback_table';\n\nexport default class CallbackRegistry {\n _callbacks: CallbackTable;\n\n constructor() {\n this._callbacks = {};\n }\n\n get(name: string): Callback[] {\n return this._callbacks[prefix(name)];\n }\n\n add(name: string, callback: Function, context: any) {\n var prefixedEventName = prefix(name);\n this._callbacks[prefixedEventName] =\n this._callbacks[prefixedEventName] || [];\n this._callbacks[prefixedEventName].push({\n fn: callback,\n context: context\n });\n }\n\n remove(name?: string, callback?: Function, context?: any) {\n if (!name && !callback && !context) {\n this._callbacks = {};\n return;\n }\n\n var names = name ? [prefix(name)] : Collections.keys(this._callbacks);\n\n if (callback || context) {\n this.removeCallback(names, callback, context);\n } else {\n this.removeAllCallbacks(names);\n }\n }\n\n private removeCallback(names: string[], callback: Function, context: any) {\n Collections.apply(\n names,\n function(name) {\n this._callbacks[name] = Collections.filter(\n this._callbacks[name] || [],\n function(binding) {\n return (\n (callback && callback !== binding.fn) ||\n (context && context !== binding.context)\n );\n }\n );\n if (this._callbacks[name].length === 0) {\n delete this._callbacks[name];\n }\n },\n this\n );\n }\n\n private removeAllCallbacks(names: string[]) {\n Collections.apply(\n names,\n function(name) {\n delete this._callbacks[name];\n },\n this\n );\n }\n}\n\nfunction prefix(name: string): string {\n return '_' + name;\n}\n","// Copyright (C) 2016 Dmitry Chestnykh\n// MIT License. See LICENSE file for details.\n\n/**\n * Package utf8 implements UTF-8 encoding and decoding.\n */\n\nconst INVALID_UTF16 = \"utf8: invalid string\";\nconst INVALID_UTF8 = \"utf8: invalid source encoding\";\n\n/**\n * Encodes the given string into UTF-8 byte array.\n * Throws if the source string has invalid UTF-16 encoding.\n */\nexport function encode(s: string): Uint8Array {\n // Calculate result length and allocate output array.\n // encodedLength() also validates string and throws errors,\n // so we don't need repeat validation here.\n const arr = new Uint8Array(encodedLength(s));\n\n let pos = 0;\n for (let i = 0; i < s.length; i++) {\n let c = s.charCodeAt(i);\n if (c < 0x80) {\n arr[pos++] = c;\n } else if (c < 0x800) {\n arr[pos++] = 0xc0 | c >> 6;\n arr[pos++] = 0x80 | c & 0x3f;\n } else if (c < 0xd800) {\n arr[pos++] = 0xe0 | c >> 12;\n arr[pos++] = 0x80 | (c >> 6) & 0x3f;\n arr[pos++] = 0x80 | c & 0x3f;\n } else {\n i++; // get one more character\n c = (c & 0x3ff) << 10;\n c |= s.charCodeAt(i) & 0x3ff;\n c += 0x10000;\n\n arr[pos++] = 0xf0 | c >> 18;\n arr[pos++] = 0x80 | (c >> 12) & 0x3f;\n arr[pos++] = 0x80 | (c >> 6) & 0x3f;\n arr[pos++] = 0x80 | c & 0x3f;\n }\n }\n return arr;\n}\n\n/**\n * Returns the number of bytes required to encode the given string into UTF-8.\n * Throws if the source string has invalid UTF-16 encoding.\n */\nexport function encodedLength(s: string): number {\n let result = 0;\n for (let i = 0; i < s.length; i++) {\n const c = s.charCodeAt(i);\n if (c < 0x80) {\n result += 1;\n } else if (c < 0x800) {\n result += 2;\n } else if (c < 0xd800) {\n result += 3;\n } else if (c <= 0xdfff) {\n if (i >= s.length - 1) {\n throw new Error(INVALID_UTF16);\n }\n i++; // \"eat\" next character\n result += 4;\n } else {\n throw new Error(INVALID_UTF16);\n }\n }\n return result;\n}\n\n/**\n * Decodes the given byte array from UTF-8 into a string.\n * Throws if encoding is invalid.\n */\nexport function decode(arr: Uint8Array): string {\n const chars: string[] = [];\n for (let i = 0; i < arr.length; i++) {\n let b = arr[i];\n\n if (b & 0x80) {\n let min;\n if (b < 0xe0) {\n // Need 1 more byte.\n if (i >= arr.length) {\n throw new Error(INVALID_UTF8);\n }\n const n1 = arr[++i];\n if ((n1 & 0xc0) !== 0x80) {\n throw new Error(INVALID_UTF8);\n }\n b = (b & 0x1f) << 6 | (n1 & 0x3f);\n min = 0x80;\n } else if (b < 0xf0) {\n // Need 2 more bytes.\n if (i >= arr.length - 1) {\n throw new Error(INVALID_UTF8);\n }\n const n1 = arr[++i];\n const n2 = arr[++i];\n if ((n1 & 0xc0) !== 0x80 || (n2 & 0xc0) !== 0x80) {\n throw new Error(INVALID_UTF8);\n }\n b = (b & 0x0f) << 12 | (n1 & 0x3f) << 6 | (n2 & 0x3f);\n min = 0x800;\n } else if (b < 0xf8) {\n // Need 3 more bytes.\n if (i >= arr.length - 2) {\n throw new Error(INVALID_UTF8);\n }\n const n1 = arr[++i];\n const n2 = arr[++i];\n const n3 = arr[++i];\n if ((n1 & 0xc0) !== 0x80 || (n2 & 0xc0) !== 0x80 || (n3 & 0xc0) !== 0x80) {\n throw new Error(INVALID_UTF8);\n }\n b = (b & 0x0f) << 18 | (n1 & 0x3f) << 12 | (n2 & 0x3f) << 6 | (n3 & 0x3f);\n min = 0x10000;\n } else {\n throw new Error(INVALID_UTF8);\n }\n\n if (b < min || (b >= 0xd800 && b <= 0xdfff)) {\n throw new Error(INVALID_UTF8);\n }\n\n if (b >= 0x10000) {\n // Surrogate pair.\n if (b > 0x10ffff) {\n throw new Error(INVALID_UTF8);\n }\n b -= 0x10000;\n chars.push(String.fromCharCode(0xd800 | (b >> 10)));\n b = 0xdc00 | (b & 0x3ff);\n }\n }\n\n chars.push(String.fromCharCode(b));\n }\n return chars.join(\"\");\n}\n","(function(nacl) {\n'use strict';\n\n// Ported in 2014 by Dmitry Chestnykh and Devi Mandiri.\n// Public domain.\n//\n// Implementation derived from TweetNaCl version 20140427.\n// See for details: http://tweetnacl.cr.yp.to/\n\nvar gf = function(init) {\n var i, r = new Float64Array(16);\n if (init) for (i = 0; i < init.length; i++) r[i] = init[i];\n return r;\n};\n\n// Pluggable, initialized in high-level API below.\nvar randombytes = function(/* x, n */) { throw new Error('no PRNG'); };\n\nvar _0 = new Uint8Array(16);\nvar _9 = new Uint8Array(32); _9[0] = 9;\n\nvar gf0 = gf(),\n gf1 = gf([1]),\n _121665 = gf([0xdb41, 1]),\n D = gf([0x78a3, 0x1359, 0x4dca, 0x75eb, 0xd8ab, 0x4141, 0x0a4d, 0x0070, 0xe898, 0x7779, 0x4079, 0x8cc7, 0xfe73, 0x2b6f, 0x6cee, 0x5203]),\n D2 = gf([0xf159, 0x26b2, 0x9b94, 0xebd6, 0xb156, 0x8283, 0x149a, 0x00e0, 0xd130, 0xeef3, 0x80f2, 0x198e, 0xfce7, 0x56df, 0xd9dc, 0x2406]),\n X = gf([0xd51a, 0x8f25, 0x2d60, 0xc956, 0xa7b2, 0x9525, 0xc760, 0x692c, 0xdc5c, 0xfdd6, 0xe231, 0xc0a4, 0x53fe, 0xcd6e, 0x36d3, 0x2169]),\n Y = gf([0x6658, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666]),\n I = gf([0xa0b0, 0x4a0e, 0x1b27, 0xc4ee, 0xe478, 0xad2f, 0x1806, 0x2f43, 0xd7a7, 0x3dfb, 0x0099, 0x2b4d, 0xdf0b, 0x4fc1, 0x2480, 0x2b83]);\n\nfunction ts64(x, i, h, l) {\n x[i] = (h >> 24) & 0xff;\n x[i+1] = (h >> 16) & 0xff;\n x[i+2] = (h >> 8) & 0xff;\n x[i+3] = h & 0xff;\n x[i+4] = (l >> 24) & 0xff;\n x[i+5] = (l >> 16) & 0xff;\n x[i+6] = (l >> 8) & 0xff;\n x[i+7] = l & 0xff;\n}\n\nfunction vn(x, xi, y, yi, n) {\n var i,d = 0;\n for (i = 0; i < n; i++) d |= x[xi+i]^y[yi+i];\n return (1 & ((d - 1) >>> 8)) - 1;\n}\n\nfunction crypto_verify_16(x, xi, y, yi) {\n return vn(x,xi,y,yi,16);\n}\n\nfunction crypto_verify_32(x, xi, y, yi) {\n return vn(x,xi,y,yi,32);\n}\n\nfunction core_salsa20(o, p, k, c) {\n var j0 = c[ 0] & 0xff | (c[ 1] & 0xff)<<8 | (c[ 2] & 0xff)<<16 | (c[ 3] & 0xff)<<24,\n j1 = k[ 0] & 0xff | (k[ 1] & 0xff)<<8 | (k[ 2] & 0xff)<<16 | (k[ 3] & 0xff)<<24,\n j2 = k[ 4] & 0xff | (k[ 5] & 0xff)<<8 | (k[ 6] & 0xff)<<16 | (k[ 7] & 0xff)<<24,\n j3 = k[ 8] & 0xff | (k[ 9] & 0xff)<<8 | (k[10] & 0xff)<<16 | (k[11] & 0xff)<<24,\n j4 = k[12] & 0xff | (k[13] & 0xff)<<8 | (k[14] & 0xff)<<16 | (k[15] & 0xff)<<24,\n j5 = c[ 4] & 0xff | (c[ 5] & 0xff)<<8 | (c[ 6] & 0xff)<<16 | (c[ 7] & 0xff)<<24,\n j6 = p[ 0] & 0xff | (p[ 1] & 0xff)<<8 | (p[ 2] & 0xff)<<16 | (p[ 3] & 0xff)<<24,\n j7 = p[ 4] & 0xff | (p[ 5] & 0xff)<<8 | (p[ 6] & 0xff)<<16 | (p[ 7] & 0xff)<<24,\n j8 = p[ 8] & 0xff | (p[ 9] & 0xff)<<8 | (p[10] & 0xff)<<16 | (p[11] & 0xff)<<24,\n j9 = p[12] & 0xff | (p[13] & 0xff)<<8 | (p[14] & 0xff)<<16 | (p[15] & 0xff)<<24,\n j10 = c[ 8] & 0xff | (c[ 9] & 0xff)<<8 | (c[10] & 0xff)<<16 | (c[11] & 0xff)<<24,\n j11 = k[16] & 0xff | (k[17] & 0xff)<<8 | (k[18] & 0xff)<<16 | (k[19] & 0xff)<<24,\n j12 = k[20] & 0xff | (k[21] & 0xff)<<8 | (k[22] & 0xff)<<16 | (k[23] & 0xff)<<24,\n j13 = k[24] & 0xff | (k[25] & 0xff)<<8 | (k[26] & 0xff)<<16 | (k[27] & 0xff)<<24,\n j14 = k[28] & 0xff | (k[29] & 0xff)<<8 | (k[30] & 0xff)<<16 | (k[31] & 0xff)<<24,\n j15 = c[12] & 0xff | (c[13] & 0xff)<<8 | (c[14] & 0xff)<<16 | (c[15] & 0xff)<<24;\n\n var x0 = j0, x1 = j1, x2 = j2, x3 = j3, x4 = j4, x5 = j5, x6 = j6, x7 = j7,\n x8 = j8, x9 = j9, x10 = j10, x11 = j11, x12 = j12, x13 = j13, x14 = j14,\n x15 = j15, u;\n\n for (var i = 0; i < 20; i += 2) {\n u = x0 + x12 | 0;\n x4 ^= u<<7 | u>>>(32-7);\n u = x4 + x0 | 0;\n x8 ^= u<<9 | u>>>(32-9);\n u = x8 + x4 | 0;\n x12 ^= u<<13 | u>>>(32-13);\n u = x12 + x8 | 0;\n x0 ^= u<<18 | u>>>(32-18);\n\n u = x5 + x1 | 0;\n x9 ^= u<<7 | u>>>(32-7);\n u = x9 + x5 | 0;\n x13 ^= u<<9 | u>>>(32-9);\n u = x13 + x9 | 0;\n x1 ^= u<<13 | u>>>(32-13);\n u = x1 + x13 | 0;\n x5 ^= u<<18 | u>>>(32-18);\n\n u = x10 + x6 | 0;\n x14 ^= u<<7 | u>>>(32-7);\n u = x14 + x10 | 0;\n x2 ^= u<<9 | u>>>(32-9);\n u = x2 + x14 | 0;\n x6 ^= u<<13 | u>>>(32-13);\n u = x6 + x2 | 0;\n x10 ^= u<<18 | u>>>(32-18);\n\n u = x15 + x11 | 0;\n x3 ^= u<<7 | u>>>(32-7);\n u = x3 + x15 | 0;\n x7 ^= u<<9 | u>>>(32-9);\n u = x7 + x3 | 0;\n x11 ^= u<<13 | u>>>(32-13);\n u = x11 + x7 | 0;\n x15 ^= u<<18 | u>>>(32-18);\n\n u = x0 + x3 | 0;\n x1 ^= u<<7 | u>>>(32-7);\n u = x1 + x0 | 0;\n x2 ^= u<<9 | u>>>(32-9);\n u = x2 + x1 | 0;\n x3 ^= u<<13 | u>>>(32-13);\n u = x3 + x2 | 0;\n x0 ^= u<<18 | u>>>(32-18);\n\n u = x5 + x4 | 0;\n x6 ^= u<<7 | u>>>(32-7);\n u = x6 + x5 | 0;\n x7 ^= u<<9 | u>>>(32-9);\n u = x7 + x6 | 0;\n x4 ^= u<<13 | u>>>(32-13);\n u = x4 + x7 | 0;\n x5 ^= u<<18 | u>>>(32-18);\n\n u = x10 + x9 | 0;\n x11 ^= u<<7 | u>>>(32-7);\n u = x11 + x10 | 0;\n x8 ^= u<<9 | u>>>(32-9);\n u = x8 + x11 | 0;\n x9 ^= u<<13 | u>>>(32-13);\n u = x9 + x8 | 0;\n x10 ^= u<<18 | u>>>(32-18);\n\n u = x15 + x14 | 0;\n x12 ^= u<<7 | u>>>(32-7);\n u = x12 + x15 | 0;\n x13 ^= u<<9 | u>>>(32-9);\n u = x13 + x12 | 0;\n x14 ^= u<<13 | u>>>(32-13);\n u = x14 + x13 | 0;\n x15 ^= u<<18 | u>>>(32-18);\n }\n x0 = x0 + j0 | 0;\n x1 = x1 + j1 | 0;\n x2 = x2 + j2 | 0;\n x3 = x3 + j3 | 0;\n x4 = x4 + j4 | 0;\n x5 = x5 + j5 | 0;\n x6 = x6 + j6 | 0;\n x7 = x7 + j7 | 0;\n x8 = x8 + j8 | 0;\n x9 = x9 + j9 | 0;\n x10 = x10 + j10 | 0;\n x11 = x11 + j11 | 0;\n x12 = x12 + j12 | 0;\n x13 = x13 + j13 | 0;\n x14 = x14 + j14 | 0;\n x15 = x15 + j15 | 0;\n\n o[ 0] = x0 >>> 0 & 0xff;\n o[ 1] = x0 >>> 8 & 0xff;\n o[ 2] = x0 >>> 16 & 0xff;\n o[ 3] = x0 >>> 24 & 0xff;\n\n o[ 4] = x1 >>> 0 & 0xff;\n o[ 5] = x1 >>> 8 & 0xff;\n o[ 6] = x1 >>> 16 & 0xff;\n o[ 7] = x1 >>> 24 & 0xff;\n\n o[ 8] = x2 >>> 0 & 0xff;\n o[ 9] = x2 >>> 8 & 0xff;\n o[10] = x2 >>> 16 & 0xff;\n o[11] = x2 >>> 24 & 0xff;\n\n o[12] = x3 >>> 0 & 0xff;\n o[13] = x3 >>> 8 & 0xff;\n o[14] = x3 >>> 16 & 0xff;\n o[15] = x3 >>> 24 & 0xff;\n\n o[16] = x4 >>> 0 & 0xff;\n o[17] = x4 >>> 8 & 0xff;\n o[18] = x4 >>> 16 & 0xff;\n o[19] = x4 >>> 24 & 0xff;\n\n o[20] = x5 >>> 0 & 0xff;\n o[21] = x5 >>> 8 & 0xff;\n o[22] = x5 >>> 16 & 0xff;\n o[23] = x5 >>> 24 & 0xff;\n\n o[24] = x6 >>> 0 & 0xff;\n o[25] = x6 >>> 8 & 0xff;\n o[26] = x6 >>> 16 & 0xff;\n o[27] = x6 >>> 24 & 0xff;\n\n o[28] = x7 >>> 0 & 0xff;\n o[29] = x7 >>> 8 & 0xff;\n o[30] = x7 >>> 16 & 0xff;\n o[31] = x7 >>> 24 & 0xff;\n\n o[32] = x8 >>> 0 & 0xff;\n o[33] = x8 >>> 8 & 0xff;\n o[34] = x8 >>> 16 & 0xff;\n o[35] = x8 >>> 24 & 0xff;\n\n o[36] = x9 >>> 0 & 0xff;\n o[37] = x9 >>> 8 & 0xff;\n o[38] = x9 >>> 16 & 0xff;\n o[39] = x9 >>> 24 & 0xff;\n\n o[40] = x10 >>> 0 & 0xff;\n o[41] = x10 >>> 8 & 0xff;\n o[42] = x10 >>> 16 & 0xff;\n o[43] = x10 >>> 24 & 0xff;\n\n o[44] = x11 >>> 0 & 0xff;\n o[45] = x11 >>> 8 & 0xff;\n o[46] = x11 >>> 16 & 0xff;\n o[47] = x11 >>> 24 & 0xff;\n\n o[48] = x12 >>> 0 & 0xff;\n o[49] = x12 >>> 8 & 0xff;\n o[50] = x12 >>> 16 & 0xff;\n o[51] = x12 >>> 24 & 0xff;\n\n o[52] = x13 >>> 0 & 0xff;\n o[53] = x13 >>> 8 & 0xff;\n o[54] = x13 >>> 16 & 0xff;\n o[55] = x13 >>> 24 & 0xff;\n\n o[56] = x14 >>> 0 & 0xff;\n o[57] = x14 >>> 8 & 0xff;\n o[58] = x14 >>> 16 & 0xff;\n o[59] = x14 >>> 24 & 0xff;\n\n o[60] = x15 >>> 0 & 0xff;\n o[61] = x15 >>> 8 & 0xff;\n o[62] = x15 >>> 16 & 0xff;\n o[63] = x15 >>> 24 & 0xff;\n}\n\nfunction core_hsalsa20(o,p,k,c) {\n var j0 = c[ 0] & 0xff | (c[ 1] & 0xff)<<8 | (c[ 2] & 0xff)<<16 | (c[ 3] & 0xff)<<24,\n j1 = k[ 0] & 0xff | (k[ 1] & 0xff)<<8 | (k[ 2] & 0xff)<<16 | (k[ 3] & 0xff)<<24,\n j2 = k[ 4] & 0xff | (k[ 5] & 0xff)<<8 | (k[ 6] & 0xff)<<16 | (k[ 7] & 0xff)<<24,\n j3 = k[ 8] & 0xff | (k[ 9] & 0xff)<<8 | (k[10] & 0xff)<<16 | (k[11] & 0xff)<<24,\n j4 = k[12] & 0xff | (k[13] & 0xff)<<8 | (k[14] & 0xff)<<16 | (k[15] & 0xff)<<24,\n j5 = c[ 4] & 0xff | (c[ 5] & 0xff)<<8 | (c[ 6] & 0xff)<<16 | (c[ 7] & 0xff)<<24,\n j6 = p[ 0] & 0xff | (p[ 1] & 0xff)<<8 | (p[ 2] & 0xff)<<16 | (p[ 3] & 0xff)<<24,\n j7 = p[ 4] & 0xff | (p[ 5] & 0xff)<<8 | (p[ 6] & 0xff)<<16 | (p[ 7] & 0xff)<<24,\n j8 = p[ 8] & 0xff | (p[ 9] & 0xff)<<8 | (p[10] & 0xff)<<16 | (p[11] & 0xff)<<24,\n j9 = p[12] & 0xff | (p[13] & 0xff)<<8 | (p[14] & 0xff)<<16 | (p[15] & 0xff)<<24,\n j10 = c[ 8] & 0xff | (c[ 9] & 0xff)<<8 | (c[10] & 0xff)<<16 | (c[11] & 0xff)<<24,\n j11 = k[16] & 0xff | (k[17] & 0xff)<<8 | (k[18] & 0xff)<<16 | (k[19] & 0xff)<<24,\n j12 = k[20] & 0xff | (k[21] & 0xff)<<8 | (k[22] & 0xff)<<16 | (k[23] & 0xff)<<24,\n j13 = k[24] & 0xff | (k[25] & 0xff)<<8 | (k[26] & 0xff)<<16 | (k[27] & 0xff)<<24,\n j14 = k[28] & 0xff | (k[29] & 0xff)<<8 | (k[30] & 0xff)<<16 | (k[31] & 0xff)<<24,\n j15 = c[12] & 0xff | (c[13] & 0xff)<<8 | (c[14] & 0xff)<<16 | (c[15] & 0xff)<<24;\n\n var x0 = j0, x1 = j1, x2 = j2, x3 = j3, x4 = j4, x5 = j5, x6 = j6, x7 = j7,\n x8 = j8, x9 = j9, x10 = j10, x11 = j11, x12 = j12, x13 = j13, x14 = j14,\n x15 = j15, u;\n\n for (var i = 0; i < 20; i += 2) {\n u = x0 + x12 | 0;\n x4 ^= u<<7 | u>>>(32-7);\n u = x4 + x0 | 0;\n x8 ^= u<<9 | u>>>(32-9);\n u = x8 + x4 | 0;\n x12 ^= u<<13 | u>>>(32-13);\n u = x12 + x8 | 0;\n x0 ^= u<<18 | u>>>(32-18);\n\n u = x5 + x1 | 0;\n x9 ^= u<<7 | u>>>(32-7);\n u = x9 + x5 | 0;\n x13 ^= u<<9 | u>>>(32-9);\n u = x13 + x9 | 0;\n x1 ^= u<<13 | u>>>(32-13);\n u = x1 + x13 | 0;\n x5 ^= u<<18 | u>>>(32-18);\n\n u = x10 + x6 | 0;\n x14 ^= u<<7 | u>>>(32-7);\n u = x14 + x10 | 0;\n x2 ^= u<<9 | u>>>(32-9);\n u = x2 + x14 | 0;\n x6 ^= u<<13 | u>>>(32-13);\n u = x6 + x2 | 0;\n x10 ^= u<<18 | u>>>(32-18);\n\n u = x15 + x11 | 0;\n x3 ^= u<<7 | u>>>(32-7);\n u = x3 + x15 | 0;\n x7 ^= u<<9 | u>>>(32-9);\n u = x7 + x3 | 0;\n x11 ^= u<<13 | u>>>(32-13);\n u = x11 + x7 | 0;\n x15 ^= u<<18 | u>>>(32-18);\n\n u = x0 + x3 | 0;\n x1 ^= u<<7 | u>>>(32-7);\n u = x1 + x0 | 0;\n x2 ^= u<<9 | u>>>(32-9);\n u = x2 + x1 | 0;\n x3 ^= u<<13 | u>>>(32-13);\n u = x3 + x2 | 0;\n x0 ^= u<<18 | u>>>(32-18);\n\n u = x5 + x4 | 0;\n x6 ^= u<<7 | u>>>(32-7);\n u = x6 + x5 | 0;\n x7 ^= u<<9 | u>>>(32-9);\n u = x7 + x6 | 0;\n x4 ^= u<<13 | u>>>(32-13);\n u = x4 + x7 | 0;\n x5 ^= u<<18 | u>>>(32-18);\n\n u = x10 + x9 | 0;\n x11 ^= u<<7 | u>>>(32-7);\n u = x11 + x10 | 0;\n x8 ^= u<<9 | u>>>(32-9);\n u = x8 + x11 | 0;\n x9 ^= u<<13 | u>>>(32-13);\n u = x9 + x8 | 0;\n x10 ^= u<<18 | u>>>(32-18);\n\n u = x15 + x14 | 0;\n x12 ^= u<<7 | u>>>(32-7);\n u = x12 + x15 | 0;\n x13 ^= u<<9 | u>>>(32-9);\n u = x13 + x12 | 0;\n x14 ^= u<<13 | u>>>(32-13);\n u = x14 + x13 | 0;\n x15 ^= u<<18 | u>>>(32-18);\n }\n\n o[ 0] = x0 >>> 0 & 0xff;\n o[ 1] = x0 >>> 8 & 0xff;\n o[ 2] = x0 >>> 16 & 0xff;\n o[ 3] = x0 >>> 24 & 0xff;\n\n o[ 4] = x5 >>> 0 & 0xff;\n o[ 5] = x5 >>> 8 & 0xff;\n o[ 6] = x5 >>> 16 & 0xff;\n o[ 7] = x5 >>> 24 & 0xff;\n\n o[ 8] = x10 >>> 0 & 0xff;\n o[ 9] = x10 >>> 8 & 0xff;\n o[10] = x10 >>> 16 & 0xff;\n o[11] = x10 >>> 24 & 0xff;\n\n o[12] = x15 >>> 0 & 0xff;\n o[13] = x15 >>> 8 & 0xff;\n o[14] = x15 >>> 16 & 0xff;\n o[15] = x15 >>> 24 & 0xff;\n\n o[16] = x6 >>> 0 & 0xff;\n o[17] = x6 >>> 8 & 0xff;\n o[18] = x6 >>> 16 & 0xff;\n o[19] = x6 >>> 24 & 0xff;\n\n o[20] = x7 >>> 0 & 0xff;\n o[21] = x7 >>> 8 & 0xff;\n o[22] = x7 >>> 16 & 0xff;\n o[23] = x7 >>> 24 & 0xff;\n\n o[24] = x8 >>> 0 & 0xff;\n o[25] = x8 >>> 8 & 0xff;\n o[26] = x8 >>> 16 & 0xff;\n o[27] = x8 >>> 24 & 0xff;\n\n o[28] = x9 >>> 0 & 0xff;\n o[29] = x9 >>> 8 & 0xff;\n o[30] = x9 >>> 16 & 0xff;\n o[31] = x9 >>> 24 & 0xff;\n}\n\nfunction crypto_core_salsa20(out,inp,k,c) {\n core_salsa20(out,inp,k,c);\n}\n\nfunction crypto_core_hsalsa20(out,inp,k,c) {\n core_hsalsa20(out,inp,k,c);\n}\n\nvar sigma = new Uint8Array([101, 120, 112, 97, 110, 100, 32, 51, 50, 45, 98, 121, 116, 101, 32, 107]);\n // \"expand 32-byte k\"\n\nfunction crypto_stream_salsa20_xor(c,cpos,m,mpos,b,n,k) {\n var z = new Uint8Array(16), x = new Uint8Array(64);\n var u, i;\n for (i = 0; i < 16; i++) z[i] = 0;\n for (i = 0; i < 8; i++) z[i] = n[i];\n while (b >= 64) {\n crypto_core_salsa20(x,z,k,sigma);\n for (i = 0; i < 64; i++) c[cpos+i] = m[mpos+i] ^ x[i];\n u = 1;\n for (i = 8; i < 16; i++) {\n u = u + (z[i] & 0xff) | 0;\n z[i] = u & 0xff;\n u >>>= 8;\n }\n b -= 64;\n cpos += 64;\n mpos += 64;\n }\n if (b > 0) {\n crypto_core_salsa20(x,z,k,sigma);\n for (i = 0; i < b; i++) c[cpos+i] = m[mpos+i] ^ x[i];\n }\n return 0;\n}\n\nfunction crypto_stream_salsa20(c,cpos,b,n,k) {\n var z = new Uint8Array(16), x = new Uint8Array(64);\n var u, i;\n for (i = 0; i < 16; i++) z[i] = 0;\n for (i = 0; i < 8; i++) z[i] = n[i];\n while (b >= 64) {\n crypto_core_salsa20(x,z,k,sigma);\n for (i = 0; i < 64; i++) c[cpos+i] = x[i];\n u = 1;\n for (i = 8; i < 16; i++) {\n u = u + (z[i] & 0xff) | 0;\n z[i] = u & 0xff;\n u >>>= 8;\n }\n b -= 64;\n cpos += 64;\n }\n if (b > 0) {\n crypto_core_salsa20(x,z,k,sigma);\n for (i = 0; i < b; i++) c[cpos+i] = x[i];\n }\n return 0;\n}\n\nfunction crypto_stream(c,cpos,d,n,k) {\n var s = new Uint8Array(32);\n crypto_core_hsalsa20(s,n,k,sigma);\n var sn = new Uint8Array(8);\n for (var i = 0; i < 8; i++) sn[i] = n[i+16];\n return crypto_stream_salsa20(c,cpos,d,sn,s);\n}\n\nfunction crypto_stream_xor(c,cpos,m,mpos,d,n,k) {\n var s = new Uint8Array(32);\n crypto_core_hsalsa20(s,n,k,sigma);\n var sn = new Uint8Array(8);\n for (var i = 0; i < 8; i++) sn[i] = n[i+16];\n return crypto_stream_salsa20_xor(c,cpos,m,mpos,d,sn,s);\n}\n\n/*\n* Port of Andrew Moon's Poly1305-donna-16. Public domain.\n* https://github.com/floodyberry/poly1305-donna\n*/\n\nvar poly1305 = function(key) {\n this.buffer = new Uint8Array(16);\n this.r = new Uint16Array(10);\n this.h = new Uint16Array(10);\n this.pad = new Uint16Array(8);\n this.leftover = 0;\n this.fin = 0;\n\n var t0, t1, t2, t3, t4, t5, t6, t7;\n\n t0 = key[ 0] & 0xff | (key[ 1] & 0xff) << 8; this.r[0] = ( t0 ) & 0x1fff;\n t1 = key[ 2] & 0xff | (key[ 3] & 0xff) << 8; this.r[1] = ((t0 >>> 13) | (t1 << 3)) & 0x1fff;\n t2 = key[ 4] & 0xff | (key[ 5] & 0xff) << 8; this.r[2] = ((t1 >>> 10) | (t2 << 6)) & 0x1f03;\n t3 = key[ 6] & 0xff | (key[ 7] & 0xff) << 8; this.r[3] = ((t2 >>> 7) | (t3 << 9)) & 0x1fff;\n t4 = key[ 8] & 0xff | (key[ 9] & 0xff) << 8; this.r[4] = ((t3 >>> 4) | (t4 << 12)) & 0x00ff;\n this.r[5] = ((t4 >>> 1)) & 0x1ffe;\n t5 = key[10] & 0xff | (key[11] & 0xff) << 8; this.r[6] = ((t4 >>> 14) | (t5 << 2)) & 0x1fff;\n t6 = key[12] & 0xff | (key[13] & 0xff) << 8; this.r[7] = ((t5 >>> 11) | (t6 << 5)) & 0x1f81;\n t7 = key[14] & 0xff | (key[15] & 0xff) << 8; this.r[8] = ((t6 >>> 8) | (t7 << 8)) & 0x1fff;\n this.r[9] = ((t7 >>> 5)) & 0x007f;\n\n this.pad[0] = key[16] & 0xff | (key[17] & 0xff) << 8;\n this.pad[1] = key[18] & 0xff | (key[19] & 0xff) << 8;\n this.pad[2] = key[20] & 0xff | (key[21] & 0xff) << 8;\n this.pad[3] = key[22] & 0xff | (key[23] & 0xff) << 8;\n this.pad[4] = key[24] & 0xff | (key[25] & 0xff) << 8;\n this.pad[5] = key[26] & 0xff | (key[27] & 0xff) << 8;\n this.pad[6] = key[28] & 0xff | (key[29] & 0xff) << 8;\n this.pad[7] = key[30] & 0xff | (key[31] & 0xff) << 8;\n};\n\npoly1305.prototype.blocks = function(m, mpos, bytes) {\n var hibit = this.fin ? 0 : (1 << 11);\n var t0, t1, t2, t3, t4, t5, t6, t7, c;\n var d0, d1, d2, d3, d4, d5, d6, d7, d8, d9;\n\n var h0 = this.h[0],\n h1 = this.h[1],\n h2 = this.h[2],\n h3 = this.h[3],\n h4 = this.h[4],\n h5 = this.h[5],\n h6 = this.h[6],\n h7 = this.h[7],\n h8 = this.h[8],\n h9 = this.h[9];\n\n var r0 = this.r[0],\n r1 = this.r[1],\n r2 = this.r[2],\n r3 = this.r[3],\n r4 = this.r[4],\n r5 = this.r[5],\n r6 = this.r[6],\n r7 = this.r[7],\n r8 = this.r[8],\n r9 = this.r[9];\n\n while (bytes >= 16) {\n t0 = m[mpos+ 0] & 0xff | (m[mpos+ 1] & 0xff) << 8; h0 += ( t0 ) & 0x1fff;\n t1 = m[mpos+ 2] & 0xff | (m[mpos+ 3] & 0xff) << 8; h1 += ((t0 >>> 13) | (t1 << 3)) & 0x1fff;\n t2 = m[mpos+ 4] & 0xff | (m[mpos+ 5] & 0xff) << 8; h2 += ((t1 >>> 10) | (t2 << 6)) & 0x1fff;\n t3 = m[mpos+ 6] & 0xff | (m[mpos+ 7] & 0xff) << 8; h3 += ((t2 >>> 7) | (t3 << 9)) & 0x1fff;\n t4 = m[mpos+ 8] & 0xff | (m[mpos+ 9] & 0xff) << 8; h4 += ((t3 >>> 4) | (t4 << 12)) & 0x1fff;\n h5 += ((t4 >>> 1)) & 0x1fff;\n t5 = m[mpos+10] & 0xff | (m[mpos+11] & 0xff) << 8; h6 += ((t4 >>> 14) | (t5 << 2)) & 0x1fff;\n t6 = m[mpos+12] & 0xff | (m[mpos+13] & 0xff) << 8; h7 += ((t5 >>> 11) | (t6 << 5)) & 0x1fff;\n t7 = m[mpos+14] & 0xff | (m[mpos+15] & 0xff) << 8; h8 += ((t6 >>> 8) | (t7 << 8)) & 0x1fff;\n h9 += ((t7 >>> 5)) | hibit;\n\n c = 0;\n\n d0 = c;\n d0 += h0 * r0;\n d0 += h1 * (5 * r9);\n d0 += h2 * (5 * r8);\n d0 += h3 * (5 * r7);\n d0 += h4 * (5 * r6);\n c = (d0 >>> 13); d0 &= 0x1fff;\n d0 += h5 * (5 * r5);\n d0 += h6 * (5 * r4);\n d0 += h7 * (5 * r3);\n d0 += h8 * (5 * r2);\n d0 += h9 * (5 * r1);\n c += (d0 >>> 13); d0 &= 0x1fff;\n\n d1 = c;\n d1 += h0 * r1;\n d1 += h1 * r0;\n d1 += h2 * (5 * r9);\n d1 += h3 * (5 * r8);\n d1 += h4 * (5 * r7);\n c = (d1 >>> 13); d1 &= 0x1fff;\n d1 += h5 * (5 * r6);\n d1 += h6 * (5 * r5);\n d1 += h7 * (5 * r4);\n d1 += h8 * (5 * r3);\n d1 += h9 * (5 * r2);\n c += (d1 >>> 13); d1 &= 0x1fff;\n\n d2 = c;\n d2 += h0 * r2;\n d2 += h1 * r1;\n d2 += h2 * r0;\n d2 += h3 * (5 * r9);\n d2 += h4 * (5 * r8);\n c = (d2 >>> 13); d2 &= 0x1fff;\n d2 += h5 * (5 * r7);\n d2 += h6 * (5 * r6);\n d2 += h7 * (5 * r5);\n d2 += h8 * (5 * r4);\n d2 += h9 * (5 * r3);\n c += (d2 >>> 13); d2 &= 0x1fff;\n\n d3 = c;\n d3 += h0 * r3;\n d3 += h1 * r2;\n d3 += h2 * r1;\n d3 += h3 * r0;\n d3 += h4 * (5 * r9);\n c = (d3 >>> 13); d3 &= 0x1fff;\n d3 += h5 * (5 * r8);\n d3 += h6 * (5 * r7);\n d3 += h7 * (5 * r6);\n d3 += h8 * (5 * r5);\n d3 += h9 * (5 * r4);\n c += (d3 >>> 13); d3 &= 0x1fff;\n\n d4 = c;\n d4 += h0 * r4;\n d4 += h1 * r3;\n d4 += h2 * r2;\n d4 += h3 * r1;\n d4 += h4 * r0;\n c = (d4 >>> 13); d4 &= 0x1fff;\n d4 += h5 * (5 * r9);\n d4 += h6 * (5 * r8);\n d4 += h7 * (5 * r7);\n d4 += h8 * (5 * r6);\n d4 += h9 * (5 * r5);\n c += (d4 >>> 13); d4 &= 0x1fff;\n\n d5 = c;\n d5 += h0 * r5;\n d5 += h1 * r4;\n d5 += h2 * r3;\n d5 += h3 * r2;\n d5 += h4 * r1;\n c = (d5 >>> 13); d5 &= 0x1fff;\n d5 += h5 * r0;\n d5 += h6 * (5 * r9);\n d5 += h7 * (5 * r8);\n d5 += h8 * (5 * r7);\n d5 += h9 * (5 * r6);\n c += (d5 >>> 13); d5 &= 0x1fff;\n\n d6 = c;\n d6 += h0 * r6;\n d6 += h1 * r5;\n d6 += h2 * r4;\n d6 += h3 * r3;\n d6 += h4 * r2;\n c = (d6 >>> 13); d6 &= 0x1fff;\n d6 += h5 * r1;\n d6 += h6 * r0;\n d6 += h7 * (5 * r9);\n d6 += h8 * (5 * r8);\n d6 += h9 * (5 * r7);\n c += (d6 >>> 13); d6 &= 0x1fff;\n\n d7 = c;\n d7 += h0 * r7;\n d7 += h1 * r6;\n d7 += h2 * r5;\n d7 += h3 * r4;\n d7 += h4 * r3;\n c = (d7 >>> 13); d7 &= 0x1fff;\n d7 += h5 * r2;\n d7 += h6 * r1;\n d7 += h7 * r0;\n d7 += h8 * (5 * r9);\n d7 += h9 * (5 * r8);\n c += (d7 >>> 13); d7 &= 0x1fff;\n\n d8 = c;\n d8 += h0 * r8;\n d8 += h1 * r7;\n d8 += h2 * r6;\n d8 += h3 * r5;\n d8 += h4 * r4;\n c = (d8 >>> 13); d8 &= 0x1fff;\n d8 += h5 * r3;\n d8 += h6 * r2;\n d8 += h7 * r1;\n d8 += h8 * r0;\n d8 += h9 * (5 * r9);\n c += (d8 >>> 13); d8 &= 0x1fff;\n\n d9 = c;\n d9 += h0 * r9;\n d9 += h1 * r8;\n d9 += h2 * r7;\n d9 += h3 * r6;\n d9 += h4 * r5;\n c = (d9 >>> 13); d9 &= 0x1fff;\n d9 += h5 * r4;\n d9 += h6 * r3;\n d9 += h7 * r2;\n d9 += h8 * r1;\n d9 += h9 * r0;\n c += (d9 >>> 13); d9 &= 0x1fff;\n\n c = (((c << 2) + c)) | 0;\n c = (c + d0) | 0;\n d0 = c & 0x1fff;\n c = (c >>> 13);\n d1 += c;\n\n h0 = d0;\n h1 = d1;\n h2 = d2;\n h3 = d3;\n h4 = d4;\n h5 = d5;\n h6 = d6;\n h7 = d7;\n h8 = d8;\n h9 = d9;\n\n mpos += 16;\n bytes -= 16;\n }\n this.h[0] = h0;\n this.h[1] = h1;\n this.h[2] = h2;\n this.h[3] = h3;\n this.h[4] = h4;\n this.h[5] = h5;\n this.h[6] = h6;\n this.h[7] = h7;\n this.h[8] = h8;\n this.h[9] = h9;\n};\n\npoly1305.prototype.finish = function(mac, macpos) {\n var g = new Uint16Array(10);\n var c, mask, f, i;\n\n if (this.leftover) {\n i = this.leftover;\n this.buffer[i++] = 1;\n for (; i < 16; i++) this.buffer[i] = 0;\n this.fin = 1;\n this.blocks(this.buffer, 0, 16);\n }\n\n c = this.h[1] >>> 13;\n this.h[1] &= 0x1fff;\n for (i = 2; i < 10; i++) {\n this.h[i] += c;\n c = this.h[i] >>> 13;\n this.h[i] &= 0x1fff;\n }\n this.h[0] += (c * 5);\n c = this.h[0] >>> 13;\n this.h[0] &= 0x1fff;\n this.h[1] += c;\n c = this.h[1] >>> 13;\n this.h[1] &= 0x1fff;\n this.h[2] += c;\n\n g[0] = this.h[0] + 5;\n c = g[0] >>> 13;\n g[0] &= 0x1fff;\n for (i = 1; i < 10; i++) {\n g[i] = this.h[i] + c;\n c = g[i] >>> 13;\n g[i] &= 0x1fff;\n }\n g[9] -= (1 << 13);\n\n mask = (c ^ 1) - 1;\n for (i = 0; i < 10; i++) g[i] &= mask;\n mask = ~mask;\n for (i = 0; i < 10; i++) this.h[i] = (this.h[i] & mask) | g[i];\n\n this.h[0] = ((this.h[0] ) | (this.h[1] << 13) ) & 0xffff;\n this.h[1] = ((this.h[1] >>> 3) | (this.h[2] << 10) ) & 0xffff;\n this.h[2] = ((this.h[2] >>> 6) | (this.h[3] << 7) ) & 0xffff;\n this.h[3] = ((this.h[3] >>> 9) | (this.h[4] << 4) ) & 0xffff;\n this.h[4] = ((this.h[4] >>> 12) | (this.h[5] << 1) | (this.h[6] << 14)) & 0xffff;\n this.h[5] = ((this.h[6] >>> 2) | (this.h[7] << 11) ) & 0xffff;\n this.h[6] = ((this.h[7] >>> 5) | (this.h[8] << 8) ) & 0xffff;\n this.h[7] = ((this.h[8] >>> 8) | (this.h[9] << 5) ) & 0xffff;\n\n f = this.h[0] + this.pad[0];\n this.h[0] = f & 0xffff;\n for (i = 1; i < 8; i++) {\n f = (((this.h[i] + this.pad[i]) | 0) + (f >>> 16)) | 0;\n this.h[i] = f & 0xffff;\n }\n\n mac[macpos+ 0] = (this.h[0] >>> 0) & 0xff;\n mac[macpos+ 1] = (this.h[0] >>> 8) & 0xff;\n mac[macpos+ 2] = (this.h[1] >>> 0) & 0xff;\n mac[macpos+ 3] = (this.h[1] >>> 8) & 0xff;\n mac[macpos+ 4] = (this.h[2] >>> 0) & 0xff;\n mac[macpos+ 5] = (this.h[2] >>> 8) & 0xff;\n mac[macpos+ 6] = (this.h[3] >>> 0) & 0xff;\n mac[macpos+ 7] = (this.h[3] >>> 8) & 0xff;\n mac[macpos+ 8] = (this.h[4] >>> 0) & 0xff;\n mac[macpos+ 9] = (this.h[4] >>> 8) & 0xff;\n mac[macpos+10] = (this.h[5] >>> 0) & 0xff;\n mac[macpos+11] = (this.h[5] >>> 8) & 0xff;\n mac[macpos+12] = (this.h[6] >>> 0) & 0xff;\n mac[macpos+13] = (this.h[6] >>> 8) & 0xff;\n mac[macpos+14] = (this.h[7] >>> 0) & 0xff;\n mac[macpos+15] = (this.h[7] >>> 8) & 0xff;\n};\n\npoly1305.prototype.update = function(m, mpos, bytes) {\n var i, want;\n\n if (this.leftover) {\n want = (16 - this.leftover);\n if (want > bytes)\n want = bytes;\n for (i = 0; i < want; i++)\n this.buffer[this.leftover + i] = m[mpos+i];\n bytes -= want;\n mpos += want;\n this.leftover += want;\n if (this.leftover < 16)\n return;\n this.blocks(this.buffer, 0, 16);\n this.leftover = 0;\n }\n\n if (bytes >= 16) {\n want = bytes - (bytes % 16);\n this.blocks(m, mpos, want);\n mpos += want;\n bytes -= want;\n }\n\n if (bytes) {\n for (i = 0; i < bytes; i++)\n this.buffer[this.leftover + i] = m[mpos+i];\n this.leftover += bytes;\n }\n};\n\nfunction crypto_onetimeauth(out, outpos, m, mpos, n, k) {\n var s = new poly1305(k);\n s.update(m, mpos, n);\n s.finish(out, outpos);\n return 0;\n}\n\nfunction crypto_onetimeauth_verify(h, hpos, m, mpos, n, k) {\n var x = new Uint8Array(16);\n crypto_onetimeauth(x,0,m,mpos,n,k);\n return crypto_verify_16(h,hpos,x,0);\n}\n\nfunction crypto_secretbox(c,m,d,n,k) {\n var i;\n if (d < 32) return -1;\n crypto_stream_xor(c,0,m,0,d,n,k);\n crypto_onetimeauth(c, 16, c, 32, d - 32, c);\n for (i = 0; i < 16; i++) c[i] = 0;\n return 0;\n}\n\nfunction crypto_secretbox_open(m,c,d,n,k) {\n var i;\n var x = new Uint8Array(32);\n if (d < 32) return -1;\n crypto_stream(x,0,32,n,k);\n if (crypto_onetimeauth_verify(c, 16,c, 32,d - 32,x) !== 0) return -1;\n crypto_stream_xor(m,0,c,0,d,n,k);\n for (i = 0; i < 32; i++) m[i] = 0;\n return 0;\n}\n\nfunction set25519(r, a) {\n var i;\n for (i = 0; i < 16; i++) r[i] = a[i]|0;\n}\n\nfunction car25519(o) {\n var i, v, c = 1;\n for (i = 0; i < 16; i++) {\n v = o[i] + c + 65535;\n c = Math.floor(v / 65536);\n o[i] = v - c * 65536;\n }\n o[0] += c-1 + 37 * (c-1);\n}\n\nfunction sel25519(p, q, b) {\n var t, c = ~(b-1);\n for (var i = 0; i < 16; i++) {\n t = c & (p[i] ^ q[i]);\n p[i] ^= t;\n q[i] ^= t;\n }\n}\n\nfunction pack25519(o, n) {\n var i, j, b;\n var m = gf(), t = gf();\n for (i = 0; i < 16; i++) t[i] = n[i];\n car25519(t);\n car25519(t);\n car25519(t);\n for (j = 0; j < 2; j++) {\n m[0] = t[0] - 0xffed;\n for (i = 1; i < 15; i++) {\n m[i] = t[i] - 0xffff - ((m[i-1]>>16) & 1);\n m[i-1] &= 0xffff;\n }\n m[15] = t[15] - 0x7fff - ((m[14]>>16) & 1);\n b = (m[15]>>16) & 1;\n m[14] &= 0xffff;\n sel25519(t, m, 1-b);\n }\n for (i = 0; i < 16; i++) {\n o[2*i] = t[i] & 0xff;\n o[2*i+1] = t[i]>>8;\n }\n}\n\nfunction neq25519(a, b) {\n var c = new Uint8Array(32), d = new Uint8Array(32);\n pack25519(c, a);\n pack25519(d, b);\n return crypto_verify_32(c, 0, d, 0);\n}\n\nfunction par25519(a) {\n var d = new Uint8Array(32);\n pack25519(d, a);\n return d[0] & 1;\n}\n\nfunction unpack25519(o, n) {\n var i;\n for (i = 0; i < 16; i++) o[i] = n[2*i] + (n[2*i+1] << 8);\n o[15] &= 0x7fff;\n}\n\nfunction A(o, a, b) {\n for (var i = 0; i < 16; i++) o[i] = a[i] + b[i];\n}\n\nfunction Z(o, a, b) {\n for (var i = 0; i < 16; i++) o[i] = a[i] - b[i];\n}\n\nfunction M(o, a, b) {\n var v, c,\n t0 = 0, t1 = 0, t2 = 0, t3 = 0, t4 = 0, t5 = 0, t6 = 0, t7 = 0,\n t8 = 0, t9 = 0, t10 = 0, t11 = 0, t12 = 0, t13 = 0, t14 = 0, t15 = 0,\n t16 = 0, t17 = 0, t18 = 0, t19 = 0, t20 = 0, t21 = 0, t22 = 0, t23 = 0,\n t24 = 0, t25 = 0, t26 = 0, t27 = 0, t28 = 0, t29 = 0, t30 = 0,\n b0 = b[0],\n b1 = b[1],\n b2 = b[2],\n b3 = b[3],\n b4 = b[4],\n b5 = b[5],\n b6 = b[6],\n b7 = b[7],\n b8 = b[8],\n b9 = b[9],\n b10 = b[10],\n b11 = b[11],\n b12 = b[12],\n b13 = b[13],\n b14 = b[14],\n b15 = b[15];\n\n v = a[0];\n t0 += v * b0;\n t1 += v * b1;\n t2 += v * b2;\n t3 += v * b3;\n t4 += v * b4;\n t5 += v * b5;\n t6 += v * b6;\n t7 += v * b7;\n t8 += v * b8;\n t9 += v * b9;\n t10 += v * b10;\n t11 += v * b11;\n t12 += v * b12;\n t13 += v * b13;\n t14 += v * b14;\n t15 += v * b15;\n v = a[1];\n t1 += v * b0;\n t2 += v * b1;\n t3 += v * b2;\n t4 += v * b3;\n t5 += v * b4;\n t6 += v * b5;\n t7 += v * b6;\n t8 += v * b7;\n t9 += v * b8;\n t10 += v * b9;\n t11 += v * b10;\n t12 += v * b11;\n t13 += v * b12;\n t14 += v * b13;\n t15 += v * b14;\n t16 += v * b15;\n v = a[2];\n t2 += v * b0;\n t3 += v * b1;\n t4 += v * b2;\n t5 += v * b3;\n t6 += v * b4;\n t7 += v * b5;\n t8 += v * b6;\n t9 += v * b7;\n t10 += v * b8;\n t11 += v * b9;\n t12 += v * b10;\n t13 += v * b11;\n t14 += v * b12;\n t15 += v * b13;\n t16 += v * b14;\n t17 += v * b15;\n v = a[3];\n t3 += v * b0;\n t4 += v * b1;\n t5 += v * b2;\n t6 += v * b3;\n t7 += v * b4;\n t8 += v * b5;\n t9 += v * b6;\n t10 += v * b7;\n t11 += v * b8;\n t12 += v * b9;\n t13 += v * b10;\n t14 += v * b11;\n t15 += v * b12;\n t16 += v * b13;\n t17 += v * b14;\n t18 += v * b15;\n v = a[4];\n t4 += v * b0;\n t5 += v * b1;\n t6 += v * b2;\n t7 += v * b3;\n t8 += v * b4;\n t9 += v * b5;\n t10 += v * b6;\n t11 += v * b7;\n t12 += v * b8;\n t13 += v * b9;\n t14 += v * b10;\n t15 += v * b11;\n t16 += v * b12;\n t17 += v * b13;\n t18 += v * b14;\n t19 += v * b15;\n v = a[5];\n t5 += v * b0;\n t6 += v * b1;\n t7 += v * b2;\n t8 += v * b3;\n t9 += v * b4;\n t10 += v * b5;\n t11 += v * b6;\n t12 += v * b7;\n t13 += v * b8;\n t14 += v * b9;\n t15 += v * b10;\n t16 += v * b11;\n t17 += v * b12;\n t18 += v * b13;\n t19 += v * b14;\n t20 += v * b15;\n v = a[6];\n t6 += v * b0;\n t7 += v * b1;\n t8 += v * b2;\n t9 += v * b3;\n t10 += v * b4;\n t11 += v * b5;\n t12 += v * b6;\n t13 += v * b7;\n t14 += v * b8;\n t15 += v * b9;\n t16 += v * b10;\n t17 += v * b11;\n t18 += v * b12;\n t19 += v * b13;\n t20 += v * b14;\n t21 += v * b15;\n v = a[7];\n t7 += v * b0;\n t8 += v * b1;\n t9 += v * b2;\n t10 += v * b3;\n t11 += v * b4;\n t12 += v * b5;\n t13 += v * b6;\n t14 += v * b7;\n t15 += v * b8;\n t16 += v * b9;\n t17 += v * b10;\n t18 += v * b11;\n t19 += v * b12;\n t20 += v * b13;\n t21 += v * b14;\n t22 += v * b15;\n v = a[8];\n t8 += v * b0;\n t9 += v * b1;\n t10 += v * b2;\n t11 += v * b3;\n t12 += v * b4;\n t13 += v * b5;\n t14 += v * b6;\n t15 += v * b7;\n t16 += v * b8;\n t17 += v * b9;\n t18 += v * b10;\n t19 += v * b11;\n t20 += v * b12;\n t21 += v * b13;\n t22 += v * b14;\n t23 += v * b15;\n v = a[9];\n t9 += v * b0;\n t10 += v * b1;\n t11 += v * b2;\n t12 += v * b3;\n t13 += v * b4;\n t14 += v * b5;\n t15 += v * b6;\n t16 += v * b7;\n t17 += v * b8;\n t18 += v * b9;\n t19 += v * b10;\n t20 += v * b11;\n t21 += v * b12;\n t22 += v * b13;\n t23 += v * b14;\n t24 += v * b15;\n v = a[10];\n t10 += v * b0;\n t11 += v * b1;\n t12 += v * b2;\n t13 += v * b3;\n t14 += v * b4;\n t15 += v * b5;\n t16 += v * b6;\n t17 += v * b7;\n t18 += v * b8;\n t19 += v * b9;\n t20 += v * b10;\n t21 += v * b11;\n t22 += v * b12;\n t23 += v * b13;\n t24 += v * b14;\n t25 += v * b15;\n v = a[11];\n t11 += v * b0;\n t12 += v * b1;\n t13 += v * b2;\n t14 += v * b3;\n t15 += v * b4;\n t16 += v * b5;\n t17 += v * b6;\n t18 += v * b7;\n t19 += v * b8;\n t20 += v * b9;\n t21 += v * b10;\n t22 += v * b11;\n t23 += v * b12;\n t24 += v * b13;\n t25 += v * b14;\n t26 += v * b15;\n v = a[12];\n t12 += v * b0;\n t13 += v * b1;\n t14 += v * b2;\n t15 += v * b3;\n t16 += v * b4;\n t17 += v * b5;\n t18 += v * b6;\n t19 += v * b7;\n t20 += v * b8;\n t21 += v * b9;\n t22 += v * b10;\n t23 += v * b11;\n t24 += v * b12;\n t25 += v * b13;\n t26 += v * b14;\n t27 += v * b15;\n v = a[13];\n t13 += v * b0;\n t14 += v * b1;\n t15 += v * b2;\n t16 += v * b3;\n t17 += v * b4;\n t18 += v * b5;\n t19 += v * b6;\n t20 += v * b7;\n t21 += v * b8;\n t22 += v * b9;\n t23 += v * b10;\n t24 += v * b11;\n t25 += v * b12;\n t26 += v * b13;\n t27 += v * b14;\n t28 += v * b15;\n v = a[14];\n t14 += v * b0;\n t15 += v * b1;\n t16 += v * b2;\n t17 += v * b3;\n t18 += v * b4;\n t19 += v * b5;\n t20 += v * b6;\n t21 += v * b7;\n t22 += v * b8;\n t23 += v * b9;\n t24 += v * b10;\n t25 += v * b11;\n t26 += v * b12;\n t27 += v * b13;\n t28 += v * b14;\n t29 += v * b15;\n v = a[15];\n t15 += v * b0;\n t16 += v * b1;\n t17 += v * b2;\n t18 += v * b3;\n t19 += v * b4;\n t20 += v * b5;\n t21 += v * b6;\n t22 += v * b7;\n t23 += v * b8;\n t24 += v * b9;\n t25 += v * b10;\n t26 += v * b11;\n t27 += v * b12;\n t28 += v * b13;\n t29 += v * b14;\n t30 += v * b15;\n\n t0 += 38 * t16;\n t1 += 38 * t17;\n t2 += 38 * t18;\n t3 += 38 * t19;\n t4 += 38 * t20;\n t5 += 38 * t21;\n t6 += 38 * t22;\n t7 += 38 * t23;\n t8 += 38 * t24;\n t9 += 38 * t25;\n t10 += 38 * t26;\n t11 += 38 * t27;\n t12 += 38 * t28;\n t13 += 38 * t29;\n t14 += 38 * t30;\n // t15 left as is\n\n // first car\n c = 1;\n v = t0 + c + 65535; c = Math.floor(v / 65536); t0 = v - c * 65536;\n v = t1 + c + 65535; c = Math.floor(v / 65536); t1 = v - c * 65536;\n v = t2 + c + 65535; c = Math.floor(v / 65536); t2 = v - c * 65536;\n v = t3 + c + 65535; c = Math.floor(v / 65536); t3 = v - c * 65536;\n v = t4 + c + 65535; c = Math.floor(v / 65536); t4 = v - c * 65536;\n v = t5 + c + 65535; c = Math.floor(v / 65536); t5 = v - c * 65536;\n v = t6 + c + 65535; c = Math.floor(v / 65536); t6 = v - c * 65536;\n v = t7 + c + 65535; c = Math.floor(v / 65536); t7 = v - c * 65536;\n v = t8 + c + 65535; c = Math.floor(v / 65536); t8 = v - c * 65536;\n v = t9 + c + 65535; c = Math.floor(v / 65536); t9 = v - c * 65536;\n v = t10 + c + 65535; c = Math.floor(v / 65536); t10 = v - c * 65536;\n v = t11 + c + 65535; c = Math.floor(v / 65536); t11 = v - c * 65536;\n v = t12 + c + 65535; c = Math.floor(v / 65536); t12 = v - c * 65536;\n v = t13 + c + 65535; c = Math.floor(v / 65536); t13 = v - c * 65536;\n v = t14 + c + 65535; c = Math.floor(v / 65536); t14 = v - c * 65536;\n v = t15 + c + 65535; c = Math.floor(v / 65536); t15 = v - c * 65536;\n t0 += c-1 + 37 * (c-1);\n\n // second car\n c = 1;\n v = t0 + c + 65535; c = Math.floor(v / 65536); t0 = v - c * 65536;\n v = t1 + c + 65535; c = Math.floor(v / 65536); t1 = v - c * 65536;\n v = t2 + c + 65535; c = Math.floor(v / 65536); t2 = v - c * 65536;\n v = t3 + c + 65535; c = Math.floor(v / 65536); t3 = v - c * 65536;\n v = t4 + c + 65535; c = Math.floor(v / 65536); t4 = v - c * 65536;\n v = t5 + c + 65535; c = Math.floor(v / 65536); t5 = v - c * 65536;\n v = t6 + c + 65535; c = Math.floor(v / 65536); t6 = v - c * 65536;\n v = t7 + c + 65535; c = Math.floor(v / 65536); t7 = v - c * 65536;\n v = t8 + c + 65535; c = Math.floor(v / 65536); t8 = v - c * 65536;\n v = t9 + c + 65535; c = Math.floor(v / 65536); t9 = v - c * 65536;\n v = t10 + c + 65535; c = Math.floor(v / 65536); t10 = v - c * 65536;\n v = t11 + c + 65535; c = Math.floor(v / 65536); t11 = v - c * 65536;\n v = t12 + c + 65535; c = Math.floor(v / 65536); t12 = v - c * 65536;\n v = t13 + c + 65535; c = Math.floor(v / 65536); t13 = v - c * 65536;\n v = t14 + c + 65535; c = Math.floor(v / 65536); t14 = v - c * 65536;\n v = t15 + c + 65535; c = Math.floor(v / 65536); t15 = v - c * 65536;\n t0 += c-1 + 37 * (c-1);\n\n o[ 0] = t0;\n o[ 1] = t1;\n o[ 2] = t2;\n o[ 3] = t3;\n o[ 4] = t4;\n o[ 5] = t5;\n o[ 6] = t6;\n o[ 7] = t7;\n o[ 8] = t8;\n o[ 9] = t9;\n o[10] = t10;\n o[11] = t11;\n o[12] = t12;\n o[13] = t13;\n o[14] = t14;\n o[15] = t15;\n}\n\nfunction S(o, a) {\n M(o, a, a);\n}\n\nfunction inv25519(o, i) {\n var c = gf();\n var a;\n for (a = 0; a < 16; a++) c[a] = i[a];\n for (a = 253; a >= 0; a--) {\n S(c, c);\n if(a !== 2 && a !== 4) M(c, c, i);\n }\n for (a = 0; a < 16; a++) o[a] = c[a];\n}\n\nfunction pow2523(o, i) {\n var c = gf();\n var a;\n for (a = 0; a < 16; a++) c[a] = i[a];\n for (a = 250; a >= 0; a--) {\n S(c, c);\n if(a !== 1) M(c, c, i);\n }\n for (a = 0; a < 16; a++) o[a] = c[a];\n}\n\nfunction crypto_scalarmult(q, n, p) {\n var z = new Uint8Array(32);\n var x = new Float64Array(80), r, i;\n var a = gf(), b = gf(), c = gf(),\n d = gf(), e = gf(), f = gf();\n for (i = 0; i < 31; i++) z[i] = n[i];\n z[31]=(n[31]&127)|64;\n z[0]&=248;\n unpack25519(x,p);\n for (i = 0; i < 16; i++) {\n b[i]=x[i];\n d[i]=a[i]=c[i]=0;\n }\n a[0]=d[0]=1;\n for (i=254; i>=0; --i) {\n r=(z[i>>>3]>>>(i&7))&1;\n sel25519(a,b,r);\n sel25519(c,d,r);\n A(e,a,c);\n Z(a,a,c);\n A(c,b,d);\n Z(b,b,d);\n S(d,e);\n S(f,a);\n M(a,c,a);\n M(c,b,e);\n A(e,a,c);\n Z(a,a,c);\n S(b,a);\n Z(c,d,f);\n M(a,c,_121665);\n A(a,a,d);\n M(c,c,a);\n M(a,d,f);\n M(d,b,x);\n S(b,e);\n sel25519(a,b,r);\n sel25519(c,d,r);\n }\n for (i = 0; i < 16; i++) {\n x[i+16]=a[i];\n x[i+32]=c[i];\n x[i+48]=b[i];\n x[i+64]=d[i];\n }\n var x32 = x.subarray(32);\n var x16 = x.subarray(16);\n inv25519(x32,x32);\n M(x16,x16,x32);\n pack25519(q,x16);\n return 0;\n}\n\nfunction crypto_scalarmult_base(q, n) {\n return crypto_scalarmult(q, n, _9);\n}\n\nfunction crypto_box_keypair(y, x) {\n randombytes(x, 32);\n return crypto_scalarmult_base(y, x);\n}\n\nfunction crypto_box_beforenm(k, y, x) {\n var s = new Uint8Array(32);\n crypto_scalarmult(s, x, y);\n return crypto_core_hsalsa20(k, _0, s, sigma);\n}\n\nvar crypto_box_afternm = crypto_secretbox;\nvar crypto_box_open_afternm = crypto_secretbox_open;\n\nfunction crypto_box(c, m, d, n, y, x) {\n var k = new Uint8Array(32);\n crypto_box_beforenm(k, y, x);\n return crypto_box_afternm(c, m, d, n, k);\n}\n\nfunction crypto_box_open(m, c, d, n, y, x) {\n var k = new Uint8Array(32);\n crypto_box_beforenm(k, y, x);\n return crypto_box_open_afternm(m, c, d, n, k);\n}\n\nvar K = [\n 0x428a2f98, 0xd728ae22, 0x71374491, 0x23ef65cd,\n 0xb5c0fbcf, 0xec4d3b2f, 0xe9b5dba5, 0x8189dbbc,\n 0x3956c25b, 0xf348b538, 0x59f111f1, 0xb605d019,\n 0x923f82a4, 0xaf194f9b, 0xab1c5ed5, 0xda6d8118,\n 0xd807aa98, 0xa3030242, 0x12835b01, 0x45706fbe,\n 0x243185be, 0x4ee4b28c, 0x550c7dc3, 0xd5ffb4e2,\n 0x72be5d74, 0xf27b896f, 0x80deb1fe, 0x3b1696b1,\n 0x9bdc06a7, 0x25c71235, 0xc19bf174, 0xcf692694,\n 0xe49b69c1, 0x9ef14ad2, 0xefbe4786, 0x384f25e3,\n 0x0fc19dc6, 0x8b8cd5b5, 0x240ca1cc, 0x77ac9c65,\n 0x2de92c6f, 0x592b0275, 0x4a7484aa, 0x6ea6e483,\n 0x5cb0a9dc, 0xbd41fbd4, 0x76f988da, 0x831153b5,\n 0x983e5152, 0xee66dfab, 0xa831c66d, 0x2db43210,\n 0xb00327c8, 0x98fb213f, 0xbf597fc7, 0xbeef0ee4,\n 0xc6e00bf3, 0x3da88fc2, 0xd5a79147, 0x930aa725,\n 0x06ca6351, 0xe003826f, 0x14292967, 0x0a0e6e70,\n 0x27b70a85, 0x46d22ffc, 0x2e1b2138, 0x5c26c926,\n 0x4d2c6dfc, 0x5ac42aed, 0x53380d13, 0x9d95b3df,\n 0x650a7354, 0x8baf63de, 0x766a0abb, 0x3c77b2a8,\n 0x81c2c92e, 0x47edaee6, 0x92722c85, 0x1482353b,\n 0xa2bfe8a1, 0x4cf10364, 0xa81a664b, 0xbc423001,\n 0xc24b8b70, 0xd0f89791, 0xc76c51a3, 0x0654be30,\n 0xd192e819, 0xd6ef5218, 0xd6990624, 0x5565a910,\n 0xf40e3585, 0x5771202a, 0x106aa070, 0x32bbd1b8,\n 0x19a4c116, 0xb8d2d0c8, 0x1e376c08, 0x5141ab53,\n 0x2748774c, 0xdf8eeb99, 0x34b0bcb5, 0xe19b48a8,\n 0x391c0cb3, 0xc5c95a63, 0x4ed8aa4a, 0xe3418acb,\n 0x5b9cca4f, 0x7763e373, 0x682e6ff3, 0xd6b2b8a3,\n 0x748f82ee, 0x5defb2fc, 0x78a5636f, 0x43172f60,\n 0x84c87814, 0xa1f0ab72, 0x8cc70208, 0x1a6439ec,\n 0x90befffa, 0x23631e28, 0xa4506ceb, 0xde82bde9,\n 0xbef9a3f7, 0xb2c67915, 0xc67178f2, 0xe372532b,\n 0xca273ece, 0xea26619c, 0xd186b8c7, 0x21c0c207,\n 0xeada7dd6, 0xcde0eb1e, 0xf57d4f7f, 0xee6ed178,\n 0x06f067aa, 0x72176fba, 0x0a637dc5, 0xa2c898a6,\n 0x113f9804, 0xbef90dae, 0x1b710b35, 0x131c471b,\n 0x28db77f5, 0x23047d84, 0x32caab7b, 0x40c72493,\n 0x3c9ebe0a, 0x15c9bebc, 0x431d67c4, 0x9c100d4c,\n 0x4cc5d4be, 0xcb3e42b6, 0x597f299c, 0xfc657e2a,\n 0x5fcb6fab, 0x3ad6faec, 0x6c44198c, 0x4a475817\n];\n\nfunction crypto_hashblocks_hl(hh, hl, m, n) {\n var wh = new Int32Array(16), wl = new Int32Array(16),\n bh0, bh1, bh2, bh3, bh4, bh5, bh6, bh7,\n bl0, bl1, bl2, bl3, bl4, bl5, bl6, bl7,\n th, tl, i, j, h, l, a, b, c, d;\n\n var ah0 = hh[0],\n ah1 = hh[1],\n ah2 = hh[2],\n ah3 = hh[3],\n ah4 = hh[4],\n ah5 = hh[5],\n ah6 = hh[6],\n ah7 = hh[7],\n\n al0 = hl[0],\n al1 = hl[1],\n al2 = hl[2],\n al3 = hl[3],\n al4 = hl[4],\n al5 = hl[5],\n al6 = hl[6],\n al7 = hl[7];\n\n var pos = 0;\n while (n >= 128) {\n for (i = 0; i < 16; i++) {\n j = 8 * i + pos;\n wh[i] = (m[j+0] << 24) | (m[j+1] << 16) | (m[j+2] << 8) | m[j+3];\n wl[i] = (m[j+4] << 24) | (m[j+5] << 16) | (m[j+6] << 8) | m[j+7];\n }\n for (i = 0; i < 80; i++) {\n bh0 = ah0;\n bh1 = ah1;\n bh2 = ah2;\n bh3 = ah3;\n bh4 = ah4;\n bh5 = ah5;\n bh6 = ah6;\n bh7 = ah7;\n\n bl0 = al0;\n bl1 = al1;\n bl2 = al2;\n bl3 = al3;\n bl4 = al4;\n bl5 = al5;\n bl6 = al6;\n bl7 = al7;\n\n // add\n h = ah7;\n l = al7;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n // Sigma1\n h = ((ah4 >>> 14) | (al4 << (32-14))) ^ ((ah4 >>> 18) | (al4 << (32-18))) ^ ((al4 >>> (41-32)) | (ah4 << (32-(41-32))));\n l = ((al4 >>> 14) | (ah4 << (32-14))) ^ ((al4 >>> 18) | (ah4 << (32-18))) ^ ((ah4 >>> (41-32)) | (al4 << (32-(41-32))));\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // Ch\n h = (ah4 & ah5) ^ (~ah4 & ah6);\n l = (al4 & al5) ^ (~al4 & al6);\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // K\n h = K[i*2];\n l = K[i*2+1];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // w\n h = wh[i%16];\n l = wl[i%16];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n th = c & 0xffff | d << 16;\n tl = a & 0xffff | b << 16;\n\n // add\n h = th;\n l = tl;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n // Sigma0\n h = ((ah0 >>> 28) | (al0 << (32-28))) ^ ((al0 >>> (34-32)) | (ah0 << (32-(34-32)))) ^ ((al0 >>> (39-32)) | (ah0 << (32-(39-32))));\n l = ((al0 >>> 28) | (ah0 << (32-28))) ^ ((ah0 >>> (34-32)) | (al0 << (32-(34-32)))) ^ ((ah0 >>> (39-32)) | (al0 << (32-(39-32))));\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // Maj\n h = (ah0 & ah1) ^ (ah0 & ah2) ^ (ah1 & ah2);\n l = (al0 & al1) ^ (al0 & al2) ^ (al1 & al2);\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n bh7 = (c & 0xffff) | (d << 16);\n bl7 = (a & 0xffff) | (b << 16);\n\n // add\n h = bh3;\n l = bl3;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = th;\n l = tl;\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n bh3 = (c & 0xffff) | (d << 16);\n bl3 = (a & 0xffff) | (b << 16);\n\n ah1 = bh0;\n ah2 = bh1;\n ah3 = bh2;\n ah4 = bh3;\n ah5 = bh4;\n ah6 = bh5;\n ah7 = bh6;\n ah0 = bh7;\n\n al1 = bl0;\n al2 = bl1;\n al3 = bl2;\n al4 = bl3;\n al5 = bl4;\n al6 = bl5;\n al7 = bl6;\n al0 = bl7;\n\n if (i%16 === 15) {\n for (j = 0; j < 16; j++) {\n // add\n h = wh[j];\n l = wl[j];\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = wh[(j+9)%16];\n l = wl[(j+9)%16];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // sigma0\n th = wh[(j+1)%16];\n tl = wl[(j+1)%16];\n h = ((th >>> 1) | (tl << (32-1))) ^ ((th >>> 8) | (tl << (32-8))) ^ (th >>> 7);\n l = ((tl >>> 1) | (th << (32-1))) ^ ((tl >>> 8) | (th << (32-8))) ^ ((tl >>> 7) | (th << (32-7)));\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // sigma1\n th = wh[(j+14)%16];\n tl = wl[(j+14)%16];\n h = ((th >>> 19) | (tl << (32-19))) ^ ((tl >>> (61-32)) | (th << (32-(61-32)))) ^ (th >>> 6);\n l = ((tl >>> 19) | (th << (32-19))) ^ ((th >>> (61-32)) | (tl << (32-(61-32)))) ^ ((tl >>> 6) | (th << (32-6)));\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n wh[j] = (c & 0xffff) | (d << 16);\n wl[j] = (a & 0xffff) | (b << 16);\n }\n }\n }\n\n // add\n h = ah0;\n l = al0;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[0];\n l = hl[0];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[0] = ah0 = (c & 0xffff) | (d << 16);\n hl[0] = al0 = (a & 0xffff) | (b << 16);\n\n h = ah1;\n l = al1;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[1];\n l = hl[1];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[1] = ah1 = (c & 0xffff) | (d << 16);\n hl[1] = al1 = (a & 0xffff) | (b << 16);\n\n h = ah2;\n l = al2;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[2];\n l = hl[2];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[2] = ah2 = (c & 0xffff) | (d << 16);\n hl[2] = al2 = (a & 0xffff) | (b << 16);\n\n h = ah3;\n l = al3;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[3];\n l = hl[3];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[3] = ah3 = (c & 0xffff) | (d << 16);\n hl[3] = al3 = (a & 0xffff) | (b << 16);\n\n h = ah4;\n l = al4;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[4];\n l = hl[4];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[4] = ah4 = (c & 0xffff) | (d << 16);\n hl[4] = al4 = (a & 0xffff) | (b << 16);\n\n h = ah5;\n l = al5;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[5];\n l = hl[5];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[5] = ah5 = (c & 0xffff) | (d << 16);\n hl[5] = al5 = (a & 0xffff) | (b << 16);\n\n h = ah6;\n l = al6;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[6];\n l = hl[6];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[6] = ah6 = (c & 0xffff) | (d << 16);\n hl[6] = al6 = (a & 0xffff) | (b << 16);\n\n h = ah7;\n l = al7;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[7];\n l = hl[7];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[7] = ah7 = (c & 0xffff) | (d << 16);\n hl[7] = al7 = (a & 0xffff) | (b << 16);\n\n pos += 128;\n n -= 128;\n }\n\n return n;\n}\n\nfunction crypto_hash(out, m, n) {\n var hh = new Int32Array(8),\n hl = new Int32Array(8),\n x = new Uint8Array(256),\n i, b = n;\n\n hh[0] = 0x6a09e667;\n hh[1] = 0xbb67ae85;\n hh[2] = 0x3c6ef372;\n hh[3] = 0xa54ff53a;\n hh[4] = 0x510e527f;\n hh[5] = 0x9b05688c;\n hh[6] = 0x1f83d9ab;\n hh[7] = 0x5be0cd19;\n\n hl[0] = 0xf3bcc908;\n hl[1] = 0x84caa73b;\n hl[2] = 0xfe94f82b;\n hl[3] = 0x5f1d36f1;\n hl[4] = 0xade682d1;\n hl[5] = 0x2b3e6c1f;\n hl[6] = 0xfb41bd6b;\n hl[7] = 0x137e2179;\n\n crypto_hashblocks_hl(hh, hl, m, n);\n n %= 128;\n\n for (i = 0; i < n; i++) x[i] = m[b-n+i];\n x[n] = 128;\n\n n = 256-128*(n<112?1:0);\n x[n-9] = 0;\n ts64(x, n-8, (b / 0x20000000) | 0, b << 3);\n crypto_hashblocks_hl(hh, hl, x, n);\n\n for (i = 0; i < 8; i++) ts64(out, 8*i, hh[i], hl[i]);\n\n return 0;\n}\n\nfunction add(p, q) {\n var a = gf(), b = gf(), c = gf(),\n d = gf(), e = gf(), f = gf(),\n g = gf(), h = gf(), t = gf();\n\n Z(a, p[1], p[0]);\n Z(t, q[1], q[0]);\n M(a, a, t);\n A(b, p[0], p[1]);\n A(t, q[0], q[1]);\n M(b, b, t);\n M(c, p[3], q[3]);\n M(c, c, D2);\n M(d, p[2], q[2]);\n A(d, d, d);\n Z(e, b, a);\n Z(f, d, c);\n A(g, d, c);\n A(h, b, a);\n\n M(p[0], e, f);\n M(p[1], h, g);\n M(p[2], g, f);\n M(p[3], e, h);\n}\n\nfunction cswap(p, q, b) {\n var i;\n for (i = 0; i < 4; i++) {\n sel25519(p[i], q[i], b);\n }\n}\n\nfunction pack(r, p) {\n var tx = gf(), ty = gf(), zi = gf();\n inv25519(zi, p[2]);\n M(tx, p[0], zi);\n M(ty, p[1], zi);\n pack25519(r, ty);\n r[31] ^= par25519(tx) << 7;\n}\n\nfunction scalarmult(p, q, s) {\n var b, i;\n set25519(p[0], gf0);\n set25519(p[1], gf1);\n set25519(p[2], gf1);\n set25519(p[3], gf0);\n for (i = 255; i >= 0; --i) {\n b = (s[(i/8)|0] >> (i&7)) & 1;\n cswap(p, q, b);\n add(q, p);\n add(p, p);\n cswap(p, q, b);\n }\n}\n\nfunction scalarbase(p, s) {\n var q = [gf(), gf(), gf(), gf()];\n set25519(q[0], X);\n set25519(q[1], Y);\n set25519(q[2], gf1);\n M(q[3], X, Y);\n scalarmult(p, q, s);\n}\n\nfunction crypto_sign_keypair(pk, sk, seeded) {\n var d = new Uint8Array(64);\n var p = [gf(), gf(), gf(), gf()];\n var i;\n\n if (!seeded) randombytes(sk, 32);\n crypto_hash(d, sk, 32);\n d[0] &= 248;\n d[31] &= 127;\n d[31] |= 64;\n\n scalarbase(p, d);\n pack(pk, p);\n\n for (i = 0; i < 32; i++) sk[i+32] = pk[i];\n return 0;\n}\n\nvar L = new Float64Array([0xed, 0xd3, 0xf5, 0x5c, 0x1a, 0x63, 0x12, 0x58, 0xd6, 0x9c, 0xf7, 0xa2, 0xde, 0xf9, 0xde, 0x14, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x10]);\n\nfunction modL(r, x) {\n var carry, i, j, k;\n for (i = 63; i >= 32; --i) {\n carry = 0;\n for (j = i - 32, k = i - 12; j < k; ++j) {\n x[j] += carry - 16 * x[i] * L[j - (i - 32)];\n carry = Math.floor((x[j] + 128) / 256);\n x[j] -= carry * 256;\n }\n x[j] += carry;\n x[i] = 0;\n }\n carry = 0;\n for (j = 0; j < 32; j++) {\n x[j] += carry - (x[31] >> 4) * L[j];\n carry = x[j] >> 8;\n x[j] &= 255;\n }\n for (j = 0; j < 32; j++) x[j] -= carry * L[j];\n for (i = 0; i < 32; i++) {\n x[i+1] += x[i] >> 8;\n r[i] = x[i] & 255;\n }\n}\n\nfunction reduce(r) {\n var x = new Float64Array(64), i;\n for (i = 0; i < 64; i++) x[i] = r[i];\n for (i = 0; i < 64; i++) r[i] = 0;\n modL(r, x);\n}\n\n// Note: difference from C - smlen returned, not passed as argument.\nfunction crypto_sign(sm, m, n, sk) {\n var d = new Uint8Array(64), h = new Uint8Array(64), r = new Uint8Array(64);\n var i, j, x = new Float64Array(64);\n var p = [gf(), gf(), gf(), gf()];\n\n crypto_hash(d, sk, 32);\n d[0] &= 248;\n d[31] &= 127;\n d[31] |= 64;\n\n var smlen = n + 64;\n for (i = 0; i < n; i++) sm[64 + i] = m[i];\n for (i = 0; i < 32; i++) sm[32 + i] = d[32 + i];\n\n crypto_hash(r, sm.subarray(32), n+32);\n reduce(r);\n scalarbase(p, r);\n pack(sm, p);\n\n for (i = 32; i < 64; i++) sm[i] = sk[i];\n crypto_hash(h, sm, n + 64);\n reduce(h);\n\n for (i = 0; i < 64; i++) x[i] = 0;\n for (i = 0; i < 32; i++) x[i] = r[i];\n for (i = 0; i < 32; i++) {\n for (j = 0; j < 32; j++) {\n x[i+j] += h[i] * d[j];\n }\n }\n\n modL(sm.subarray(32), x);\n return smlen;\n}\n\nfunction unpackneg(r, p) {\n var t = gf(), chk = gf(), num = gf(),\n den = gf(), den2 = gf(), den4 = gf(),\n den6 = gf();\n\n set25519(r[2], gf1);\n unpack25519(r[1], p);\n S(num, r[1]);\n M(den, num, D);\n Z(num, num, r[2]);\n A(den, r[2], den);\n\n S(den2, den);\n S(den4, den2);\n M(den6, den4, den2);\n M(t, den6, num);\n M(t, t, den);\n\n pow2523(t, t);\n M(t, t, num);\n M(t, t, den);\n M(t, t, den);\n M(r[0], t, den);\n\n S(chk, r[0]);\n M(chk, chk, den);\n if (neq25519(chk, num)) M(r[0], r[0], I);\n\n S(chk, r[0]);\n M(chk, chk, den);\n if (neq25519(chk, num)) return -1;\n\n if (par25519(r[0]) === (p[31]>>7)) Z(r[0], gf0, r[0]);\n\n M(r[3], r[0], r[1]);\n return 0;\n}\n\nfunction crypto_sign_open(m, sm, n, pk) {\n var i;\n var t = new Uint8Array(32), h = new Uint8Array(64);\n var p = [gf(), gf(), gf(), gf()],\n q = [gf(), gf(), gf(), gf()];\n\n if (n < 64) return -1;\n\n if (unpackneg(q, pk)) return -1;\n\n for (i = 0; i < n; i++) m[i] = sm[i];\n for (i = 0; i < 32; i++) m[i+32] = pk[i];\n crypto_hash(h, m, n);\n reduce(h);\n scalarmult(p, q, h);\n\n scalarbase(q, sm.subarray(32));\n add(p, q);\n pack(t, p);\n\n n -= 64;\n if (crypto_verify_32(sm, 0, t, 0)) {\n for (i = 0; i < n; i++) m[i] = 0;\n return -1;\n }\n\n for (i = 0; i < n; i++) m[i] = sm[i + 64];\n return n;\n}\n\nvar crypto_secretbox_KEYBYTES = 32,\n crypto_secretbox_NONCEBYTES = 24,\n crypto_secretbox_ZEROBYTES = 32,\n crypto_secretbox_BOXZEROBYTES = 16,\n crypto_scalarmult_BYTES = 32,\n crypto_scalarmult_SCALARBYTES = 32,\n crypto_box_PUBLICKEYBYTES = 32,\n crypto_box_SECRETKEYBYTES = 32,\n crypto_box_BEFORENMBYTES = 32,\n crypto_box_NONCEBYTES = crypto_secretbox_NONCEBYTES,\n crypto_box_ZEROBYTES = crypto_secretbox_ZEROBYTES,\n crypto_box_BOXZEROBYTES = crypto_secretbox_BOXZEROBYTES,\n crypto_sign_BYTES = 64,\n crypto_sign_PUBLICKEYBYTES = 32,\n crypto_sign_SECRETKEYBYTES = 64,\n crypto_sign_SEEDBYTES = 32,\n crypto_hash_BYTES = 64;\n\nnacl.lowlevel = {\n crypto_core_hsalsa20: crypto_core_hsalsa20,\n crypto_stream_xor: crypto_stream_xor,\n crypto_stream: crypto_stream,\n crypto_stream_salsa20_xor: crypto_stream_salsa20_xor,\n crypto_stream_salsa20: crypto_stream_salsa20,\n crypto_onetimeauth: crypto_onetimeauth,\n crypto_onetimeauth_verify: crypto_onetimeauth_verify,\n crypto_verify_16: crypto_verify_16,\n crypto_verify_32: crypto_verify_32,\n crypto_secretbox: crypto_secretbox,\n crypto_secretbox_open: crypto_secretbox_open,\n crypto_scalarmult: crypto_scalarmult,\n crypto_scalarmult_base: crypto_scalarmult_base,\n crypto_box_beforenm: crypto_box_beforenm,\n crypto_box_afternm: crypto_box_afternm,\n crypto_box: crypto_box,\n crypto_box_open: crypto_box_open,\n crypto_box_keypair: crypto_box_keypair,\n crypto_hash: crypto_hash,\n crypto_sign: crypto_sign,\n crypto_sign_keypair: crypto_sign_keypair,\n crypto_sign_open: crypto_sign_open,\n\n crypto_secretbox_KEYBYTES: crypto_secretbox_KEYBYTES,\n crypto_secretbox_NONCEBYTES: crypto_secretbox_NONCEBYTES,\n crypto_secretbox_ZEROBYTES: crypto_secretbox_ZEROBYTES,\n crypto_secretbox_BOXZEROBYTES: crypto_secretbox_BOXZEROBYTES,\n crypto_scalarmult_BYTES: crypto_scalarmult_BYTES,\n crypto_scalarmult_SCALARBYTES: crypto_scalarmult_SCALARBYTES,\n crypto_box_PUBLICKEYBYTES: crypto_box_PUBLICKEYBYTES,\n crypto_box_SECRETKEYBYTES: crypto_box_SECRETKEYBYTES,\n crypto_box_BEFORENMBYTES: crypto_box_BEFORENMBYTES,\n crypto_box_NONCEBYTES: crypto_box_NONCEBYTES,\n crypto_box_ZEROBYTES: crypto_box_ZEROBYTES,\n crypto_box_BOXZEROBYTES: crypto_box_BOXZEROBYTES,\n crypto_sign_BYTES: crypto_sign_BYTES,\n crypto_sign_PUBLICKEYBYTES: crypto_sign_PUBLICKEYBYTES,\n crypto_sign_SECRETKEYBYTES: crypto_sign_SECRETKEYBYTES,\n crypto_sign_SEEDBYTES: crypto_sign_SEEDBYTES,\n crypto_hash_BYTES: crypto_hash_BYTES,\n\n gf: gf,\n D: D,\n L: L,\n pack25519: pack25519,\n unpack25519: unpack25519,\n M: M,\n A: A,\n S: S,\n Z: Z,\n pow2523: pow2523,\n add: add,\n set25519: set25519,\n modL: modL,\n scalarmult: scalarmult,\n scalarbase: scalarbase,\n};\n\n/* High-level API */\n\nfunction checkLengths(k, n) {\n if (k.length !== crypto_secretbox_KEYBYTES) throw new Error('bad key size');\n if (n.length !== crypto_secretbox_NONCEBYTES) throw new Error('bad nonce size');\n}\n\nfunction checkBoxLengths(pk, sk) {\n if (pk.length !== crypto_box_PUBLICKEYBYTES) throw new Error('bad public key size');\n if (sk.length !== crypto_box_SECRETKEYBYTES) throw new Error('bad secret key size');\n}\n\nfunction checkArrayTypes() {\n for (var i = 0; i < arguments.length; i++) {\n if (!(arguments[i] instanceof Uint8Array))\n throw new TypeError('unexpected type, use Uint8Array');\n }\n}\n\nfunction cleanup(arr) {\n for (var i = 0; i < arr.length; i++) arr[i] = 0;\n}\n\nnacl.randomBytes = function(n) {\n var b = new Uint8Array(n);\n randombytes(b, n);\n return b;\n};\n\nnacl.secretbox = function(msg, nonce, key) {\n checkArrayTypes(msg, nonce, key);\n checkLengths(key, nonce);\n var m = new Uint8Array(crypto_secretbox_ZEROBYTES + msg.length);\n var c = new Uint8Array(m.length);\n for (var i = 0; i < msg.length; i++) m[i+crypto_secretbox_ZEROBYTES] = msg[i];\n crypto_secretbox(c, m, m.length, nonce, key);\n return c.subarray(crypto_secretbox_BOXZEROBYTES);\n};\n\nnacl.secretbox.open = function(box, nonce, key) {\n checkArrayTypes(box, nonce, key);\n checkLengths(key, nonce);\n var c = new Uint8Array(crypto_secretbox_BOXZEROBYTES + box.length);\n var m = new Uint8Array(c.length);\n for (var i = 0; i < box.length; i++) c[i+crypto_secretbox_BOXZEROBYTES] = box[i];\n if (c.length < 32) return null;\n if (crypto_secretbox_open(m, c, c.length, nonce, key) !== 0) return null;\n return m.subarray(crypto_secretbox_ZEROBYTES);\n};\n\nnacl.secretbox.keyLength = crypto_secretbox_KEYBYTES;\nnacl.secretbox.nonceLength = crypto_secretbox_NONCEBYTES;\nnacl.secretbox.overheadLength = crypto_secretbox_BOXZEROBYTES;\n\nnacl.scalarMult = function(n, p) {\n checkArrayTypes(n, p);\n if (n.length !== crypto_scalarmult_SCALARBYTES) throw new Error('bad n size');\n if (p.length !== crypto_scalarmult_BYTES) throw new Error('bad p size');\n var q = new Uint8Array(crypto_scalarmult_BYTES);\n crypto_scalarmult(q, n, p);\n return q;\n};\n\nnacl.scalarMult.base = function(n) {\n checkArrayTypes(n);\n if (n.length !== crypto_scalarmult_SCALARBYTES) throw new Error('bad n size');\n var q = new Uint8Array(crypto_scalarmult_BYTES);\n crypto_scalarmult_base(q, n);\n return q;\n};\n\nnacl.scalarMult.scalarLength = crypto_scalarmult_SCALARBYTES;\nnacl.scalarMult.groupElementLength = crypto_scalarmult_BYTES;\n\nnacl.box = function(msg, nonce, publicKey, secretKey) {\n var k = nacl.box.before(publicKey, secretKey);\n return nacl.secretbox(msg, nonce, k);\n};\n\nnacl.box.before = function(publicKey, secretKey) {\n checkArrayTypes(publicKey, secretKey);\n checkBoxLengths(publicKey, secretKey);\n var k = new Uint8Array(crypto_box_BEFORENMBYTES);\n crypto_box_beforenm(k, publicKey, secretKey);\n return k;\n};\n\nnacl.box.after = nacl.secretbox;\n\nnacl.box.open = function(msg, nonce, publicKey, secretKey) {\n var k = nacl.box.before(publicKey, secretKey);\n return nacl.secretbox.open(msg, nonce, k);\n};\n\nnacl.box.open.after = nacl.secretbox.open;\n\nnacl.box.keyPair = function() {\n var pk = new Uint8Array(crypto_box_PUBLICKEYBYTES);\n var sk = new Uint8Array(crypto_box_SECRETKEYBYTES);\n crypto_box_keypair(pk, sk);\n return {publicKey: pk, secretKey: sk};\n};\n\nnacl.box.keyPair.fromSecretKey = function(secretKey) {\n checkArrayTypes(secretKey);\n if (secretKey.length !== crypto_box_SECRETKEYBYTES)\n throw new Error('bad secret key size');\n var pk = new Uint8Array(crypto_box_PUBLICKEYBYTES);\n crypto_scalarmult_base(pk, secretKey);\n return {publicKey: pk, secretKey: new Uint8Array(secretKey)};\n};\n\nnacl.box.publicKeyLength = crypto_box_PUBLICKEYBYTES;\nnacl.box.secretKeyLength = crypto_box_SECRETKEYBYTES;\nnacl.box.sharedKeyLength = crypto_box_BEFORENMBYTES;\nnacl.box.nonceLength = crypto_box_NONCEBYTES;\nnacl.box.overheadLength = nacl.secretbox.overheadLength;\n\nnacl.sign = function(msg, secretKey) {\n checkArrayTypes(msg, secretKey);\n if (secretKey.length !== crypto_sign_SECRETKEYBYTES)\n throw new Error('bad secret key size');\n var signedMsg = new Uint8Array(crypto_sign_BYTES+msg.length);\n crypto_sign(signedMsg, msg, msg.length, secretKey);\n return signedMsg;\n};\n\nnacl.sign.open = function(signedMsg, publicKey) {\n checkArrayTypes(signedMsg, publicKey);\n if (publicKey.length !== crypto_sign_PUBLICKEYBYTES)\n throw new Error('bad public key size');\n var tmp = new Uint8Array(signedMsg.length);\n var mlen = crypto_sign_open(tmp, signedMsg, signedMsg.length, publicKey);\n if (mlen < 0) return null;\n var m = new Uint8Array(mlen);\n for (var i = 0; i < m.length; i++) m[i] = tmp[i];\n return m;\n};\n\nnacl.sign.detached = function(msg, secretKey) {\n var signedMsg = nacl.sign(msg, secretKey);\n var sig = new Uint8Array(crypto_sign_BYTES);\n for (var i = 0; i < sig.length; i++) sig[i] = signedMsg[i];\n return sig;\n};\n\nnacl.sign.detached.verify = function(msg, sig, publicKey) {\n checkArrayTypes(msg, sig, publicKey);\n if (sig.length !== crypto_sign_BYTES)\n throw new Error('bad signature size');\n if (publicKey.length !== crypto_sign_PUBLICKEYBYTES)\n throw new Error('bad public key size');\n var sm = new Uint8Array(crypto_sign_BYTES + msg.length);\n var m = new Uint8Array(crypto_sign_BYTES + msg.length);\n var i;\n for (i = 0; i < crypto_sign_BYTES; i++) sm[i] = sig[i];\n for (i = 0; i < msg.length; i++) sm[i+crypto_sign_BYTES] = msg[i];\n return (crypto_sign_open(m, sm, sm.length, publicKey) >= 0);\n};\n\nnacl.sign.keyPair = function() {\n var pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);\n var sk = new Uint8Array(crypto_sign_SECRETKEYBYTES);\n crypto_sign_keypair(pk, sk);\n return {publicKey: pk, secretKey: sk};\n};\n\nnacl.sign.keyPair.fromSecretKey = function(secretKey) {\n checkArrayTypes(secretKey);\n if (secretKey.length !== crypto_sign_SECRETKEYBYTES)\n throw new Error('bad secret key size');\n var pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);\n for (var i = 0; i < pk.length; i++) pk[i] = secretKey[32+i];\n return {publicKey: pk, secretKey: new Uint8Array(secretKey)};\n};\n\nnacl.sign.keyPair.fromSeed = function(seed) {\n checkArrayTypes(seed);\n if (seed.length !== crypto_sign_SEEDBYTES)\n throw new Error('bad seed size');\n var pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);\n var sk = new Uint8Array(crypto_sign_SECRETKEYBYTES);\n for (var i = 0; i < 32; i++) sk[i] = seed[i];\n crypto_sign_keypair(pk, sk, true);\n return {publicKey: pk, secretKey: sk};\n};\n\nnacl.sign.publicKeyLength = crypto_sign_PUBLICKEYBYTES;\nnacl.sign.secretKeyLength = crypto_sign_SECRETKEYBYTES;\nnacl.sign.seedLength = crypto_sign_SEEDBYTES;\nnacl.sign.signatureLength = crypto_sign_BYTES;\n\nnacl.hash = function(msg) {\n checkArrayTypes(msg);\n var h = new Uint8Array(crypto_hash_BYTES);\n crypto_hash(h, msg, msg.length);\n return h;\n};\n\nnacl.hash.hashLength = crypto_hash_BYTES;\n\nnacl.verify = function(x, y) {\n checkArrayTypes(x, y);\n // Zero length arguments are considered not equal.\n if (x.length === 0 || y.length === 0) return false;\n if (x.length !== y.length) return false;\n return (vn(x, 0, y, 0, x.length) === 0) ? true : false;\n};\n\nnacl.setPRNG = function(fn) {\n randombytes = fn;\n};\n\n(function() {\n // Initialize PRNG if environment provides CSPRNG.\n // If not, methods calling randombytes will throw.\n var crypto = typeof self !== 'undefined' ? (self.crypto || self.msCrypto) : null;\n if (crypto && crypto.getRandomValues) {\n // Browsers.\n var QUOTA = 65536;\n nacl.setPRNG(function(x, n) {\n var i, v = new Uint8Array(n);\n for (i = 0; i < n; i += QUOTA) {\n crypto.getRandomValues(v.subarray(i, i + Math.min(n - i, QUOTA)));\n }\n for (i = 0; i < n; i++) x[i] = v[i];\n cleanup(v);\n });\n } else if (typeof require !== 'undefined') {\n // Node.js.\n crypto = require('crypto');\n if (crypto && crypto.randomBytes) {\n nacl.setPRNG(function(x, n) {\n var i, v = crypto.randomBytes(n);\n for (i = 0; i < n; i++) x[i] = v[i];\n cleanup(v);\n });\n }\n }\n})();\n\n})(typeof module !== 'undefined' && module.exports ? module.exports : (self.nacl = self.nacl || {}));\n","module.exports = require('./pusher-with-encryption').default;\n","import Pusher from './pusher';\nimport { Options, validateOptions } from './options';\nimport * as nacl from 'tweetnacl';\n\nexport default class PusherWithEncryption extends Pusher {\n constructor(app_key: string, options: Options) {\n Pusher.logToConsole = PusherWithEncryption.logToConsole;\n Pusher.log = PusherWithEncryption.log;\n\n validateOptions(options);\n options.nacl = nacl;\n super(app_key, options);\n }\n}\n"],"sourceRoot":""} \ No newline at end of file diff --git a/dist/web/pusher-with-encryption.js b/dist/web/pusher-with-encryption.js index f84bbfcb6..f3e72840a 100644 --- a/dist/web/pusher-with-encryption.js +++ b/dist/web/pusher-with-encryption.js @@ -1,5 +1,5 @@ /*! - * Pusher JavaScript Library v8.3.0 + * Pusher JavaScript Library v8.4.0 * https://pusher.com/ * * Copyright 2020, Pusher @@ -2996,7 +2996,7 @@ var ScriptReceivers = new ScriptReceiverFactory('_pusher_script_', 'Pusher.Scrip // CONCATENATED MODULE: ./src/core/defaults.ts var Defaults = { - VERSION: "8.3.0", + VERSION: "8.4.0", PROTOCOL: 7, wsPort: 80, wssPort: 443, @@ -4878,6 +4878,11 @@ class connection_manager_ConnectionManager extends dispatcher_Dispatcher { }); this.updateStrategy(); } + switchCluster(key) { + this.key = key; + this.updateStrategy(); + this.retryIn(0); + } connect() { if (this.connection || this.runner) { return; @@ -6884,6 +6889,13 @@ class pusher_Pusher { this.connect(); } } + switchCluster(options) { + const { appKey, cluster } = options; + this.key = appKey; + this.options = Object.assign(Object.assign({}, this.options), { cluster }); + this.config = getConfig(this.options, this); + this.connection.switchCluster(this.key); + } channel(name) { return this.channels.find(name); } diff --git a/dist/web/pusher-with-encryption.js.map b/dist/web/pusher-with-encryption.js.map index 0a2aee41a..6670b0477 100644 --- a/dist/web/pusher-with-encryption.js.map +++ b/dist/web/pusher-with-encryption.js.map @@ -1 +1 @@ -{"version":3,"sources":["webpack://Pusher/webpack/universalModuleDefinition","webpack://Pusher/webpack/bootstrap","webpack://Pusher/./node_modules/@stablelib/base64/base64.ts","webpack://Pusher/./node_modules/@stablelib/utf8/utf8.ts","webpack://Pusher/./node_modules/tweetnacl/nacl-fast.js","webpack://Pusher/./src/core/pusher-with-encryption.js","webpack://Pusher/crypto (ignored)","webpack://Pusher/./src/runtimes/web/dom/script_receiver_factory.ts","webpack://Pusher/./src/core/defaults.ts","webpack://Pusher/./src/runtimes/web/dom/dependency_loader.ts","webpack://Pusher/./src/runtimes/web/dom/dependencies.ts","webpack://Pusher/./src/core/utils/url_store.ts","webpack://Pusher/./src/core/auth/options.ts","webpack://Pusher/./src/core/errors.ts","webpack://Pusher/./src/runtimes/isomorphic/auth/xhr_auth.ts","webpack://Pusher/./src/core/base64.ts","webpack://Pusher/./src/core/utils/timers/abstract_timer.ts","webpack://Pusher/./src/core/utils/timers/index.ts","webpack://Pusher/./src/core/util.ts","webpack://Pusher/./src/core/utils/collections.ts","webpack://Pusher/./src/core/logger.ts","webpack://Pusher/./src/runtimes/web/auth/jsonp_auth.ts","webpack://Pusher/./src/runtimes/web/dom/script_request.ts","webpack://Pusher/./src/runtimes/web/dom/jsonp_request.ts","webpack://Pusher/./src/runtimes/web/timeline/jsonp_timeline.ts","webpack://Pusher/./src/core/transports/url_schemes.ts","webpack://Pusher/./src/core/events/callback_registry.ts","webpack://Pusher/./src/core/events/dispatcher.ts","webpack://Pusher/./src/core/transports/transport_connection.ts","webpack://Pusher/./src/core/transports/transport.ts","webpack://Pusher/./src/runtimes/isomorphic/transports/transports.ts","webpack://Pusher/./src/runtimes/web/transports/transports.ts","webpack://Pusher/./src/runtimes/web/net_info.ts","webpack://Pusher/./src/core/transports/assistant_to_the_transport_manager.ts","webpack://Pusher/./src/core/connection/protocol/protocol.ts","webpack://Pusher/./src/core/connection/connection.ts","webpack://Pusher/./src/core/connection/handshake/index.ts","webpack://Pusher/./src/core/timeline/timeline_sender.ts","webpack://Pusher/./src/core/channels/channel.ts","webpack://Pusher/./src/core/channels/private_channel.ts","webpack://Pusher/./src/core/channels/members.ts","webpack://Pusher/./src/core/channels/presence_channel.ts","webpack://Pusher/./src/core/channels/encrypted_channel.ts","webpack://Pusher/./src/core/connection/connection_manager.ts","webpack://Pusher/./src/core/channels/channels.ts","webpack://Pusher/./src/core/utils/factory.ts","webpack://Pusher/./src/core/transports/transport_manager.ts","webpack://Pusher/./src/core/strategies/sequential_strategy.ts","webpack://Pusher/./src/core/strategies/best_connected_ever_strategy.ts","webpack://Pusher/./src/core/strategies/websocket_prioritized_cached_strategy.ts","webpack://Pusher/./src/core/strategies/delayed_strategy.ts","webpack://Pusher/./src/core/strategies/if_strategy.ts","webpack://Pusher/./src/core/strategies/first_connected_strategy.ts","webpack://Pusher/./src/runtimes/web/default_strategy.ts","webpack://Pusher/./src/runtimes/web/transports/transport_connection_initializer.ts","webpack://Pusher/./src/runtimes/web/http/http_xdomain_request.ts","webpack://Pusher/./src/core/http/http_request.ts","webpack://Pusher/./src/core/http/state.ts","webpack://Pusher/./src/core/http/http_socket.ts","webpack://Pusher/./src/core/http/http_streaming_socket.ts","webpack://Pusher/./src/core/http/http_polling_socket.ts","webpack://Pusher/./src/runtimes/isomorphic/http/http_xhr_request.ts","webpack://Pusher/./src/runtimes/isomorphic/http/http.ts","webpack://Pusher/./src/runtimes/web/http/http.ts","webpack://Pusher/./src/runtimes/web/runtime.ts","webpack://Pusher/./src/core/timeline/level.ts","webpack://Pusher/./src/core/timeline/timeline.ts","webpack://Pusher/./src/core/strategies/transport_strategy.ts","webpack://Pusher/./src/core/strategies/strategy_builder.ts","webpack://Pusher/./src/core/options.ts","webpack://Pusher/./src/core/auth/user_authenticator.ts","webpack://Pusher/./src/core/auth/channel_authorizer.ts","webpack://Pusher/./src/core/auth/deprecated_channel_authorizer.ts","webpack://Pusher/./src/core/config.ts","webpack://Pusher/./src/core/watchlist.ts","webpack://Pusher/./src/core/utils/flat_promise.ts","webpack://Pusher/./src/core/user.ts","webpack://Pusher/./src/core/pusher.ts","webpack://Pusher/./src/core/pusher-with-encryption.ts"],"names":[],"mappings":";;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AACD,O;QCVA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;;QAEA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;;;QAGA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;QACA,0CAA0C,gCAAgC;QAC1E;QACA;;QAEA;QACA;QACA;QACA,wDAAwD,kBAAkB;QAC1E;QACA,iDAAiD,cAAc;QAC/D;;QAEA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA,yCAAyC,iCAAiC;QAC1E,gHAAgH,mBAAmB,EAAE;QACrI;QACA;;QAEA;QACA;QACA;QACA,2BAA2B,0BAA0B,EAAE;QACvD,iCAAiC,eAAe;QAChD;QACA;QACA;;QAEA;QACA,sDAAsD,+DAA+D;;QAErH;QACA;;;QAGA;QACA;;;;;;;;;AClFA,sCAAsC;AACtC,6CAA6C;;;;;;;;;;;;;;;AAE7C;;GAEG;AAEH,iDAAiD;AACjD,kDAAkD;AAClD,kCAAkC;AAClC,IAAM,YAAY,GAAG,GAAG,CAAC;AAEzB;;;;GAIG;AACH;IACI,kDAAkD;IAElD,eAAoB,iBAAuB;QAAvB,2DAAuB;QAAvB,sBAAiB,GAAjB,iBAAiB,CAAM;IAAI,CAAC;IAEhD,6BAAa,GAAb,UAAc,MAAc;QACxB,IAAI,CAAC,IAAI,CAAC,iBAAiB,EAAE;YACzB,OAAO,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CAAC,IAAI,OAAO,EAAE;gBACd,kBAAkB;gBAClB,IAAI,CAAC,GAAG,QAAQ,EAAE;oBACd,MAAM,IAAI,KAAK,CAAC,YAAY,CAAC,CAAC;iBACjC;gBACD,CAAC,IAAI,OAAO,CAAC;gBACb,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,MAAM,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;gBACpD,CAAC,GAAG,MAAM,GAAG,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC;aAC5B;SACJ;QAED,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC;KACtC;IACD,OAAO,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AAC1B,CAAC;AAjED,wBAiEC;;;;;;;AC/ID;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,uBAAuB,iBAAiB;AACxC;AACA;;AAEA;AACA,wCAAwC,4BAA4B;;AAEpE;AACA,4BAA4B;;AAE5B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa,OAAO;AACpB;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,aAAa,QAAQ;AACrB,aAAa,OAAO;AACpB;AACA;AACA,eAAe,QAAQ;AACvB;AACA,eAAe,QAAQ;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB;AACA;AACA;;AAEA;AACA;AACA;AACA,aAAa,QAAQ;AACrB,aAAa,OAAO;AACpB;AACA;AACA,eAAe,QAAQ;AACvB;AACA,eAAe,QAAQ;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,iBAAiB,OAAO;AACxB;AACA;;AAEA;AACA;AACA;AACA;AACA,iBAAiB,OAAO;AACxB;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA,8CAA8C;AAC9C,8CAA8C;AAC9C,8CAA8C;AAC9C,8CAA8C;AAC9C,8CAA8C;AAC9C;AACA,8CAA8C;AAC9C,8CAA8C;AAC9C,8CAA8C;AAC9C;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,sDAAsD;AACtD,sDAAsD;AACtD,sDAAsD;AACtD,sDAAsD;AACtD,sDAAsD;AACtD;AACA,sDAAsD;AACtD,sDAAsD;AACtD,sDAAsD;AACtD;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA,qBAAqB;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA,qBAAqB;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA,qBAAqB;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA,qBAAqB;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA,qBAAqB;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA,qBAAqB;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA,qBAAqB;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA,qBAAqB;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA,qBAAqB;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA,qBAAqB;;AAErB;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA,UAAU,QAAQ;AAClB;AACA;AACA;;AAEA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA;AACA;;AAEA;AACA,aAAa,QAAQ;AACrB;AACA,aAAa,QAAQ;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa,OAAO;AACpB;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,UAAU;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,eAAe,WAAW;AAC1B;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;;AAEA;AACA;AACA,aAAa,QAAQ;AACrB;;AAEA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA,aAAa,OAAO;AACpB;AACA,eAAe,QAAQ;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;;AAEA;AACA,iBAAiB,QAAQ;AACzB;;AAEA;AACA,iBAAiB,QAAQ;AACzB;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD;;AAEA;AACA;AACA,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA,aAAa,QAAQ;AACrB,eAAe,QAAQ;AACvB;AACA;AACA;AACA,aAAa,QAAQ;AACrB;;AAEA;AACA;AACA;AACA,aAAa,QAAQ;AACrB,eAAe,QAAQ;AACvB;AACA;AACA;AACA,aAAa,QAAQ;AACrB;;AAEA;AACA;AACA;AACA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA;AACA,aAAa,MAAM;AACnB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,eAAe,QAAQ;AACvB;AACA;AACA;AACA;AACA,eAAe,QAAQ;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA,qBAAqB;AACrB,qBAAqB;;AAErB;AACA;AACA;;AAEA,sBAAsB;AACtB,sBAAsB;;AAEtB;AACA;AACA;;AAEA,sBAAsB;AACtB,sBAAsB;;AAEtB;AACA;AACA;;AAEA,sBAAsB;AACtB,sBAAsB;;AAEtB;AACA;AACA;;AAEA,sBAAsB;AACtB,sBAAsB;;AAEtB;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA,qBAAqB;AACrB,qBAAqB;;AAErB;AACA;AACA;;AAEA,sBAAsB;AACtB,sBAAsB;;AAEtB;AACA;AACA;;AAEA,sBAAsB;AACtB,sBAAsB;;AAEtB;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA,qBAAqB;AACrB,qBAAqB;;AAErB;AACA;;AAEA,sBAAsB;AACtB,sBAAsB;;AAEtB;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,mBAAmB,QAAQ;AAC3B;AACA;AACA;;AAEA,yBAAyB;AACzB,yBAAyB;;AAEzB;AACA;;AAEA,0BAA0B;AAC1B,0BAA0B;;AAE1B;AACA;AACA;AAC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,OAAO;AACpB;;AAEA;AACA;AACA;AACA;;AAEA,aAAa,OAAO;;AAEpB;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa,OAAO;AACpB;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,QAAQ;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA,aAAa,QAAQ;AACrB;AACA;;AAEA;;AAEA;AACA;AACA,cAAc,SAAS;AACvB;AACA,gCAAgC,OAAO;AACvC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA;AACA,aAAa,QAAQ;AACrB,aAAa,QAAQ;AACrB;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa,QAAQ;AACrB,aAAa,QAAQ;AACrB;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA,aAAa,OAAO;AACpB,aAAa,QAAQ;;AAErB;AACA;AACA;AACA;;AAEA,cAAc,QAAQ;AACtB;AACA;;AAEA,aAAa,QAAQ;AACrB,aAAa,QAAQ;AACrB,aAAa,QAAQ;AACrB,eAAe,QAAQ;AACvB;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;;AAEA,aAAa,OAAO;AACpB,aAAa,QAAQ;AACrB;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA,eAAe,OAAO;AACtB;AACA;;AAEA,aAAa,OAAO;AACpB;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA,iBAAiB,sBAAsB;AACvC;AACA;AACA;AACA;;AAEA;AACA,iBAAiB,gBAAgB;AACjC;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,iBAAiB,gBAAgB;AACjC;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,iBAAiB,gBAAgB;AACjC;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA,UAAU;AACV;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,UAAU;AACV;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAiB,cAAc;AAC/B;AACA;;AAEA;AACA;AACA;AACA,iBAAiB,gBAAgB;AAC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AVxC,6DAAM;AA8N3B,SAAS,WAAW,CAAC,GAAG;IACtB,IAAI,GAAG,KAAK,IAAI,IAAI,GAAG,KAAK,SAAS,EAAE;QACrC,MAAM,yDAAyD,CAAC;KACjE;AACH,CAAC;AAED,OAAO,CAAC,KAAK,CAAC,aAAM,CAAC,CAAC;;;;;;AC5PQ;AACuB;AACnB;AAEnB,MAAM,2CAAqB,SAAQ,WAAM;IACtD,YAAY,OAAe,EAAE,OAAgB;QAC3C,WAAM,CAAC,YAAY,GAAG,2CAAoB,CAAC,YAAY,CAAC;QACxD,WAAM,CAAC,GAAG,GAAG,2CAAoB,CAAC,GAAG,CAAC;QAEtC,eAAe,CAAC,OAAO,CAAC,CAAC;QACzB,OAAO,CAAC,IAAI,GAAG,SAAI,CAAC;QACpB,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAC1B,CAAC;CACF","file":"pusher-with-encryption.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"Pusher\"] = factory();\n\telse\n\t\troot[\"Pusher\"] = factory();\n})(window, function() {\nreturn "," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 3);\n","// Copyright (C) 2016 Dmitry Chestnykh\n// MIT License. See LICENSE file for details.\n\n/**\n * Package base64 implements Base64 encoding and decoding.\n */\n\n// Invalid character used in decoding to indicate\n// that the character to decode is out of range of\n// alphabet and cannot be decoded.\nconst INVALID_BYTE = 256;\n\n/**\n * Implements standard Base64 encoding.\n *\n * Operates in constant time.\n */\nexport class Coder {\n // TODO(dchest): methods to encode chunk-by-chunk.\n\n constructor(private _paddingCharacter = \"=\") { }\n\n encodedLength(length: number): number {\n if (!this._paddingCharacter) {\n return (length * 8 + 5) / 6 | 0;\n }\n return (length + 2) / 3 * 4 | 0;\n }\n\n encode(data: Uint8Array): string {\n let out = \"\";\n\n let i = 0;\n for (; i < data.length - 2; i += 3) {\n let c = (data[i] << 16) | (data[i + 1] << 8) | (data[i + 2]);\n out += this._encodeByte((c >>> 3 * 6) & 63);\n out += this._encodeByte((c >>> 2 * 6) & 63);\n out += this._encodeByte((c >>> 1 * 6) & 63);\n out += this._encodeByte((c >>> 0 * 6) & 63);\n }\n\n const left = data.length - i;\n if (left > 0) {\n let c = (data[i] << 16) | (left === 2 ? data[i + 1] << 8 : 0);\n out += this._encodeByte((c >>> 3 * 6) & 63);\n out += this._encodeByte((c >>> 2 * 6) & 63);\n if (left === 2) {\n out += this._encodeByte((c >>> 1 * 6) & 63);\n } else {\n out += this._paddingCharacter || \"\";\n }\n out += this._paddingCharacter || \"\";\n }\n\n return out;\n }\n\n maxDecodedLength(length: number): number {\n if (!this._paddingCharacter) {\n return (length * 6 + 7) / 8 | 0;\n }\n return length / 4 * 3 | 0;\n }\n\n decodedLength(s: string): number {\n return this.maxDecodedLength(s.length - this._getPaddingLength(s));\n }\n\n decode(s: string): Uint8Array {\n if (s.length === 0) {\n return new Uint8Array(0);\n }\n const paddingLength = this._getPaddingLength(s);\n const length = s.length - paddingLength;\n const out = new Uint8Array(this.maxDecodedLength(length));\n let op = 0;\n let i = 0;\n let haveBad = 0;\n let v0 = 0, v1 = 0, v2 = 0, v3 = 0;\n for (; i < length - 4; i += 4) {\n v0 = this._decodeChar(s.charCodeAt(i + 0));\n v1 = this._decodeChar(s.charCodeAt(i + 1));\n v2 = this._decodeChar(s.charCodeAt(i + 2));\n v3 = this._decodeChar(s.charCodeAt(i + 3));\n out[op++] = (v0 << 2) | (v1 >>> 4);\n out[op++] = (v1 << 4) | (v2 >>> 2);\n out[op++] = (v2 << 6) | v3;\n haveBad |= v0 & INVALID_BYTE;\n haveBad |= v1 & INVALID_BYTE;\n haveBad |= v2 & INVALID_BYTE;\n haveBad |= v3 & INVALID_BYTE;\n }\n if (i < length - 1) {\n v0 = this._decodeChar(s.charCodeAt(i));\n v1 = this._decodeChar(s.charCodeAt(i + 1));\n out[op++] = (v0 << 2) | (v1 >>> 4);\n haveBad |= v0 & INVALID_BYTE;\n haveBad |= v1 & INVALID_BYTE;\n }\n if (i < length - 2) {\n v2 = this._decodeChar(s.charCodeAt(i + 2));\n out[op++] = (v1 << 4) | (v2 >>> 2);\n haveBad |= v2 & INVALID_BYTE;\n }\n if (i < length - 3) {\n v3 = this._decodeChar(s.charCodeAt(i + 3));\n out[op++] = (v2 << 6) | v3;\n haveBad |= v3 & INVALID_BYTE;\n }\n if (haveBad !== 0) {\n throw new Error(\"Base64Coder: incorrect characters for decoding\");\n }\n return out;\n }\n\n // Standard encoding have the following encoded/decoded ranges,\n // which we need to convert between.\n //\n // ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 0123456789 + /\n // Index: 0 - 25 26 - 51 52 - 61 62 63\n // ASCII: 65 - 90 97 - 122 48 - 57 43 47\n //\n\n // Encode 6 bits in b into a new character.\n protected _encodeByte(b: number): string {\n // Encoding uses constant time operations as follows:\n //\n // 1. Define comparison of A with B using (A - B) >>> 8:\n // if A > B, then result is positive integer\n // if A <= B, then result is 0\n //\n // 2. Define selection of C or 0 using bitwise AND: X & C:\n // if X == 0, then result is 0\n // if X != 0, then result is C\n //\n // 3. Start with the smallest comparison (b >= 0), which is always\n // true, so set the result to the starting ASCII value (65).\n //\n // 4. Continue comparing b to higher ASCII values, and selecting\n // zero if comparison isn't true, otherwise selecting a value\n // to add to result, which:\n //\n // a) undoes the previous addition\n // b) provides new value to add\n //\n let result = b;\n // b >= 0\n result += 65;\n // b > 25\n result += ((25 - b) >>> 8) & ((0 - 65) - 26 + 97);\n // b > 51\n result += ((51 - b) >>> 8) & ((26 - 97) - 52 + 48);\n // b > 61\n result += ((61 - b) >>> 8) & ((52 - 48) - 62 + 43);\n // b > 62\n result += ((62 - b) >>> 8) & ((62 - 43) - 63 + 47);\n\n return String.fromCharCode(result);\n }\n\n // Decode a character code into a byte.\n // Must return 256 if character is out of alphabet range.\n protected _decodeChar(c: number): number {\n // Decoding works similar to encoding: using the same comparison\n // function, but now it works on ranges: result is always incremented\n // by value, but this value becomes zero if the range is not\n // satisfied.\n //\n // Decoding starts with invalid value, 256, which is then\n // subtracted when the range is satisfied. If none of the ranges\n // apply, the function returns 256, which is then checked by\n // the caller to throw error.\n let result = INVALID_BYTE; // start with invalid character\n\n // c == 43 (c > 42 and c < 44)\n result += (((42 - c) & (c - 44)) >>> 8) & (-INVALID_BYTE + c - 43 + 62);\n // c == 47 (c > 46 and c < 48)\n result += (((46 - c) & (c - 48)) >>> 8) & (-INVALID_BYTE + c - 47 + 63);\n // c > 47 and c < 58\n result += (((47 - c) & (c - 58)) >>> 8) & (-INVALID_BYTE + c - 48 + 52);\n // c > 64 and c < 91\n result += (((64 - c) & (c - 91)) >>> 8) & (-INVALID_BYTE + c - 65 + 0);\n // c > 96 and c < 123\n result += (((96 - c) & (c - 123)) >>> 8) & (-INVALID_BYTE + c - 97 + 26);\n\n return result;\n }\n\n private _getPaddingLength(s: string): number {\n let paddingLength = 0;\n if (this._paddingCharacter) {\n for (let i = s.length - 1; i >= 0; i--) {\n if (s[i] !== this._paddingCharacter) {\n break;\n }\n paddingLength++;\n }\n if (s.length < 4 || paddingLength > 2) {\n throw new Error(\"Base64Coder: incorrect padding\");\n }\n }\n return paddingLength;\n }\n\n}\n\nconst stdCoder = new Coder();\n\nexport function encode(data: Uint8Array): string {\n return stdCoder.encode(data);\n}\n\nexport function decode(s: string): Uint8Array {\n return stdCoder.decode(s);\n}\n\n/**\n * Implements URL-safe Base64 encoding.\n * (Same as Base64, but '+' is replaced with '-', and '/' with '_').\n *\n * Operates in constant time.\n */\nexport class URLSafeCoder extends Coder {\n // URL-safe encoding have the following encoded/decoded ranges:\n //\n // ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 0123456789 - _\n // Index: 0 - 25 26 - 51 52 - 61 62 63\n // ASCII: 65 - 90 97 - 122 48 - 57 45 95\n //\n\n protected _encodeByte(b: number): string {\n let result = b;\n // b >= 0\n result += 65;\n // b > 25\n result += ((25 - b) >>> 8) & ((0 - 65) - 26 + 97);\n // b > 51\n result += ((51 - b) >>> 8) & ((26 - 97) - 52 + 48);\n // b > 61\n result += ((61 - b) >>> 8) & ((52 - 48) - 62 + 45);\n // b > 62\n result += ((62 - b) >>> 8) & ((62 - 45) - 63 + 95);\n\n return String.fromCharCode(result);\n }\n\n protected _decodeChar(c: number): number {\n let result = INVALID_BYTE;\n\n // c == 45 (c > 44 and c < 46)\n result += (((44 - c) & (c - 46)) >>> 8) & (-INVALID_BYTE + c - 45 + 62);\n // c == 95 (c > 94 and c < 96)\n result += (((94 - c) & (c - 96)) >>> 8) & (-INVALID_BYTE + c - 95 + 63);\n // c > 47 and c < 58\n result += (((47 - c) & (c - 58)) >>> 8) & (-INVALID_BYTE + c - 48 + 52);\n // c > 64 and c < 91\n result += (((64 - c) & (c - 91)) >>> 8) & (-INVALID_BYTE + c - 65 + 0);\n // c > 96 and c < 123\n result += (((96 - c) & (c - 123)) >>> 8) & (-INVALID_BYTE + c - 97 + 26);\n\n return result;\n }\n}\n\nconst urlSafeCoder = new URLSafeCoder();\n\nexport function encodeURLSafe(data: Uint8Array): string {\n return urlSafeCoder.encode(data);\n}\n\nexport function decodeURLSafe(s: string): Uint8Array {\n return urlSafeCoder.decode(s);\n}\n\n\nexport const encodedLength = (length: number) =>\n stdCoder.encodedLength(length);\n\nexport const maxDecodedLength = (length: number) =>\n stdCoder.maxDecodedLength(length);\n\nexport const decodedLength = (s: string) =>\n stdCoder.decodedLength(s);\n","// Copyright (C) 2016 Dmitry Chestnykh\n// MIT License. See LICENSE file for details.\n\n/**\n * Package utf8 implements UTF-8 encoding and decoding.\n */\n\nconst INVALID_UTF16 = \"utf8: invalid string\";\nconst INVALID_UTF8 = \"utf8: invalid source encoding\";\n\n/**\n * Encodes the given string into UTF-8 byte array.\n * Throws if the source string has invalid UTF-16 encoding.\n */\nexport function encode(s: string): Uint8Array {\n // Calculate result length and allocate output array.\n // encodedLength() also validates string and throws errors,\n // so we don't need repeat validation here.\n const arr = new Uint8Array(encodedLength(s));\n\n let pos = 0;\n for (let i = 0; i < s.length; i++) {\n let c = s.charCodeAt(i);\n if (c < 0x80) {\n arr[pos++] = c;\n } else if (c < 0x800) {\n arr[pos++] = 0xc0 | c >> 6;\n arr[pos++] = 0x80 | c & 0x3f;\n } else if (c < 0xd800) {\n arr[pos++] = 0xe0 | c >> 12;\n arr[pos++] = 0x80 | (c >> 6) & 0x3f;\n arr[pos++] = 0x80 | c & 0x3f;\n } else {\n i++; // get one more character\n c = (c & 0x3ff) << 10;\n c |= s.charCodeAt(i) & 0x3ff;\n c += 0x10000;\n\n arr[pos++] = 0xf0 | c >> 18;\n arr[pos++] = 0x80 | (c >> 12) & 0x3f;\n arr[pos++] = 0x80 | (c >> 6) & 0x3f;\n arr[pos++] = 0x80 | c & 0x3f;\n }\n }\n return arr;\n}\n\n/**\n * Returns the number of bytes required to encode the given string into UTF-8.\n * Throws if the source string has invalid UTF-16 encoding.\n */\nexport function encodedLength(s: string): number {\n let result = 0;\n for (let i = 0; i < s.length; i++) {\n const c = s.charCodeAt(i);\n if (c < 0x80) {\n result += 1;\n } else if (c < 0x800) {\n result += 2;\n } else if (c < 0xd800) {\n result += 3;\n } else if (c <= 0xdfff) {\n if (i >= s.length - 1) {\n throw new Error(INVALID_UTF16);\n }\n i++; // \"eat\" next character\n result += 4;\n } else {\n throw new Error(INVALID_UTF16);\n }\n }\n return result;\n}\n\n/**\n * Decodes the given byte array from UTF-8 into a string.\n * Throws if encoding is invalid.\n */\nexport function decode(arr: Uint8Array): string {\n const chars: string[] = [];\n for (let i = 0; i < arr.length; i++) {\n let b = arr[i];\n\n if (b & 0x80) {\n let min;\n if (b < 0xe0) {\n // Need 1 more byte.\n if (i >= arr.length) {\n throw new Error(INVALID_UTF8);\n }\n const n1 = arr[++i];\n if ((n1 & 0xc0) !== 0x80) {\n throw new Error(INVALID_UTF8);\n }\n b = (b & 0x1f) << 6 | (n1 & 0x3f);\n min = 0x80;\n } else if (b < 0xf0) {\n // Need 2 more bytes.\n if (i >= arr.length - 1) {\n throw new Error(INVALID_UTF8);\n }\n const n1 = arr[++i];\n const n2 = arr[++i];\n if ((n1 & 0xc0) !== 0x80 || (n2 & 0xc0) !== 0x80) {\n throw new Error(INVALID_UTF8);\n }\n b = (b & 0x0f) << 12 | (n1 & 0x3f) << 6 | (n2 & 0x3f);\n min = 0x800;\n } else if (b < 0xf8) {\n // Need 3 more bytes.\n if (i >= arr.length - 2) {\n throw new Error(INVALID_UTF8);\n }\n const n1 = arr[++i];\n const n2 = arr[++i];\n const n3 = arr[++i];\n if ((n1 & 0xc0) !== 0x80 || (n2 & 0xc0) !== 0x80 || (n3 & 0xc0) !== 0x80) {\n throw new Error(INVALID_UTF8);\n }\n b = (b & 0x0f) << 18 | (n1 & 0x3f) << 12 | (n2 & 0x3f) << 6 | (n3 & 0x3f);\n min = 0x10000;\n } else {\n throw new Error(INVALID_UTF8);\n }\n\n if (b < min || (b >= 0xd800 && b <= 0xdfff)) {\n throw new Error(INVALID_UTF8);\n }\n\n if (b >= 0x10000) {\n // Surrogate pair.\n if (b > 0x10ffff) {\n throw new Error(INVALID_UTF8);\n }\n b -= 0x10000;\n chars.push(String.fromCharCode(0xd800 | (b >> 10)));\n b = 0xdc00 | (b & 0x3ff);\n }\n }\n\n chars.push(String.fromCharCode(b));\n }\n return chars.join(\"\");\n}\n","(function(nacl) {\n'use strict';\n\n// Ported in 2014 by Dmitry Chestnykh and Devi Mandiri.\n// Public domain.\n//\n// Implementation derived from TweetNaCl version 20140427.\n// See for details: http://tweetnacl.cr.yp.to/\n\nvar gf = function(init) {\n var i, r = new Float64Array(16);\n if (init) for (i = 0; i < init.length; i++) r[i] = init[i];\n return r;\n};\n\n// Pluggable, initialized in high-level API below.\nvar randombytes = function(/* x, n */) { throw new Error('no PRNG'); };\n\nvar _0 = new Uint8Array(16);\nvar _9 = new Uint8Array(32); _9[0] = 9;\n\nvar gf0 = gf(),\n gf1 = gf([1]),\n _121665 = gf([0xdb41, 1]),\n D = gf([0x78a3, 0x1359, 0x4dca, 0x75eb, 0xd8ab, 0x4141, 0x0a4d, 0x0070, 0xe898, 0x7779, 0x4079, 0x8cc7, 0xfe73, 0x2b6f, 0x6cee, 0x5203]),\n D2 = gf([0xf159, 0x26b2, 0x9b94, 0xebd6, 0xb156, 0x8283, 0x149a, 0x00e0, 0xd130, 0xeef3, 0x80f2, 0x198e, 0xfce7, 0x56df, 0xd9dc, 0x2406]),\n X = gf([0xd51a, 0x8f25, 0x2d60, 0xc956, 0xa7b2, 0x9525, 0xc760, 0x692c, 0xdc5c, 0xfdd6, 0xe231, 0xc0a4, 0x53fe, 0xcd6e, 0x36d3, 0x2169]),\n Y = gf([0x6658, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666]),\n I = gf([0xa0b0, 0x4a0e, 0x1b27, 0xc4ee, 0xe478, 0xad2f, 0x1806, 0x2f43, 0xd7a7, 0x3dfb, 0x0099, 0x2b4d, 0xdf0b, 0x4fc1, 0x2480, 0x2b83]);\n\nfunction ts64(x, i, h, l) {\n x[i] = (h >> 24) & 0xff;\n x[i+1] = (h >> 16) & 0xff;\n x[i+2] = (h >> 8) & 0xff;\n x[i+3] = h & 0xff;\n x[i+4] = (l >> 24) & 0xff;\n x[i+5] = (l >> 16) & 0xff;\n x[i+6] = (l >> 8) & 0xff;\n x[i+7] = l & 0xff;\n}\n\nfunction vn(x, xi, y, yi, n) {\n var i,d = 0;\n for (i = 0; i < n; i++) d |= x[xi+i]^y[yi+i];\n return (1 & ((d - 1) >>> 8)) - 1;\n}\n\nfunction crypto_verify_16(x, xi, y, yi) {\n return vn(x,xi,y,yi,16);\n}\n\nfunction crypto_verify_32(x, xi, y, yi) {\n return vn(x,xi,y,yi,32);\n}\n\nfunction core_salsa20(o, p, k, c) {\n var j0 = c[ 0] & 0xff | (c[ 1] & 0xff)<<8 | (c[ 2] & 0xff)<<16 | (c[ 3] & 0xff)<<24,\n j1 = k[ 0] & 0xff | (k[ 1] & 0xff)<<8 | (k[ 2] & 0xff)<<16 | (k[ 3] & 0xff)<<24,\n j2 = k[ 4] & 0xff | (k[ 5] & 0xff)<<8 | (k[ 6] & 0xff)<<16 | (k[ 7] & 0xff)<<24,\n j3 = k[ 8] & 0xff | (k[ 9] & 0xff)<<8 | (k[10] & 0xff)<<16 | (k[11] & 0xff)<<24,\n j4 = k[12] & 0xff | (k[13] & 0xff)<<8 | (k[14] & 0xff)<<16 | (k[15] & 0xff)<<24,\n j5 = c[ 4] & 0xff | (c[ 5] & 0xff)<<8 | (c[ 6] & 0xff)<<16 | (c[ 7] & 0xff)<<24,\n j6 = p[ 0] & 0xff | (p[ 1] & 0xff)<<8 | (p[ 2] & 0xff)<<16 | (p[ 3] & 0xff)<<24,\n j7 = p[ 4] & 0xff | (p[ 5] & 0xff)<<8 | (p[ 6] & 0xff)<<16 | (p[ 7] & 0xff)<<24,\n j8 = p[ 8] & 0xff | (p[ 9] & 0xff)<<8 | (p[10] & 0xff)<<16 | (p[11] & 0xff)<<24,\n j9 = p[12] & 0xff | (p[13] & 0xff)<<8 | (p[14] & 0xff)<<16 | (p[15] & 0xff)<<24,\n j10 = c[ 8] & 0xff | (c[ 9] & 0xff)<<8 | (c[10] & 0xff)<<16 | (c[11] & 0xff)<<24,\n j11 = k[16] & 0xff | (k[17] & 0xff)<<8 | (k[18] & 0xff)<<16 | (k[19] & 0xff)<<24,\n j12 = k[20] & 0xff | (k[21] & 0xff)<<8 | (k[22] & 0xff)<<16 | (k[23] & 0xff)<<24,\n j13 = k[24] & 0xff | (k[25] & 0xff)<<8 | (k[26] & 0xff)<<16 | (k[27] & 0xff)<<24,\n j14 = k[28] & 0xff | (k[29] & 0xff)<<8 | (k[30] & 0xff)<<16 | (k[31] & 0xff)<<24,\n j15 = c[12] & 0xff | (c[13] & 0xff)<<8 | (c[14] & 0xff)<<16 | (c[15] & 0xff)<<24;\n\n var x0 = j0, x1 = j1, x2 = j2, x3 = j3, x4 = j4, x5 = j5, x6 = j6, x7 = j7,\n x8 = j8, x9 = j9, x10 = j10, x11 = j11, x12 = j12, x13 = j13, x14 = j14,\n x15 = j15, u;\n\n for (var i = 0; i < 20; i += 2) {\n u = x0 + x12 | 0;\n x4 ^= u<<7 | u>>>(32-7);\n u = x4 + x0 | 0;\n x8 ^= u<<9 | u>>>(32-9);\n u = x8 + x4 | 0;\n x12 ^= u<<13 | u>>>(32-13);\n u = x12 + x8 | 0;\n x0 ^= u<<18 | u>>>(32-18);\n\n u = x5 + x1 | 0;\n x9 ^= u<<7 | u>>>(32-7);\n u = x9 + x5 | 0;\n x13 ^= u<<9 | u>>>(32-9);\n u = x13 + x9 | 0;\n x1 ^= u<<13 | u>>>(32-13);\n u = x1 + x13 | 0;\n x5 ^= u<<18 | u>>>(32-18);\n\n u = x10 + x6 | 0;\n x14 ^= u<<7 | u>>>(32-7);\n u = x14 + x10 | 0;\n x2 ^= u<<9 | u>>>(32-9);\n u = x2 + x14 | 0;\n x6 ^= u<<13 | u>>>(32-13);\n u = x6 + x2 | 0;\n x10 ^= u<<18 | u>>>(32-18);\n\n u = x15 + x11 | 0;\n x3 ^= u<<7 | u>>>(32-7);\n u = x3 + x15 | 0;\n x7 ^= u<<9 | u>>>(32-9);\n u = x7 + x3 | 0;\n x11 ^= u<<13 | u>>>(32-13);\n u = x11 + x7 | 0;\n x15 ^= u<<18 | u>>>(32-18);\n\n u = x0 + x3 | 0;\n x1 ^= u<<7 | u>>>(32-7);\n u = x1 + x0 | 0;\n x2 ^= u<<9 | u>>>(32-9);\n u = x2 + x1 | 0;\n x3 ^= u<<13 | u>>>(32-13);\n u = x3 + x2 | 0;\n x0 ^= u<<18 | u>>>(32-18);\n\n u = x5 + x4 | 0;\n x6 ^= u<<7 | u>>>(32-7);\n u = x6 + x5 | 0;\n x7 ^= u<<9 | u>>>(32-9);\n u = x7 + x6 | 0;\n x4 ^= u<<13 | u>>>(32-13);\n u = x4 + x7 | 0;\n x5 ^= u<<18 | u>>>(32-18);\n\n u = x10 + x9 | 0;\n x11 ^= u<<7 | u>>>(32-7);\n u = x11 + x10 | 0;\n x8 ^= u<<9 | u>>>(32-9);\n u = x8 + x11 | 0;\n x9 ^= u<<13 | u>>>(32-13);\n u = x9 + x8 | 0;\n x10 ^= u<<18 | u>>>(32-18);\n\n u = x15 + x14 | 0;\n x12 ^= u<<7 | u>>>(32-7);\n u = x12 + x15 | 0;\n x13 ^= u<<9 | u>>>(32-9);\n u = x13 + x12 | 0;\n x14 ^= u<<13 | u>>>(32-13);\n u = x14 + x13 | 0;\n x15 ^= u<<18 | u>>>(32-18);\n }\n x0 = x0 + j0 | 0;\n x1 = x1 + j1 | 0;\n x2 = x2 + j2 | 0;\n x3 = x3 + j3 | 0;\n x4 = x4 + j4 | 0;\n x5 = x5 + j5 | 0;\n x6 = x6 + j6 | 0;\n x7 = x7 + j7 | 0;\n x8 = x8 + j8 | 0;\n x9 = x9 + j9 | 0;\n x10 = x10 + j10 | 0;\n x11 = x11 + j11 | 0;\n x12 = x12 + j12 | 0;\n x13 = x13 + j13 | 0;\n x14 = x14 + j14 | 0;\n x15 = x15 + j15 | 0;\n\n o[ 0] = x0 >>> 0 & 0xff;\n o[ 1] = x0 >>> 8 & 0xff;\n o[ 2] = x0 >>> 16 & 0xff;\n o[ 3] = x0 >>> 24 & 0xff;\n\n o[ 4] = x1 >>> 0 & 0xff;\n o[ 5] = x1 >>> 8 & 0xff;\n o[ 6] = x1 >>> 16 & 0xff;\n o[ 7] = x1 >>> 24 & 0xff;\n\n o[ 8] = x2 >>> 0 & 0xff;\n o[ 9] = x2 >>> 8 & 0xff;\n o[10] = x2 >>> 16 & 0xff;\n o[11] = x2 >>> 24 & 0xff;\n\n o[12] = x3 >>> 0 & 0xff;\n o[13] = x3 >>> 8 & 0xff;\n o[14] = x3 >>> 16 & 0xff;\n o[15] = x3 >>> 24 & 0xff;\n\n o[16] = x4 >>> 0 & 0xff;\n o[17] = x4 >>> 8 & 0xff;\n o[18] = x4 >>> 16 & 0xff;\n o[19] = x4 >>> 24 & 0xff;\n\n o[20] = x5 >>> 0 & 0xff;\n o[21] = x5 >>> 8 & 0xff;\n o[22] = x5 >>> 16 & 0xff;\n o[23] = x5 >>> 24 & 0xff;\n\n o[24] = x6 >>> 0 & 0xff;\n o[25] = x6 >>> 8 & 0xff;\n o[26] = x6 >>> 16 & 0xff;\n o[27] = x6 >>> 24 & 0xff;\n\n o[28] = x7 >>> 0 & 0xff;\n o[29] = x7 >>> 8 & 0xff;\n o[30] = x7 >>> 16 & 0xff;\n o[31] = x7 >>> 24 & 0xff;\n\n o[32] = x8 >>> 0 & 0xff;\n o[33] = x8 >>> 8 & 0xff;\n o[34] = x8 >>> 16 & 0xff;\n o[35] = x8 >>> 24 & 0xff;\n\n o[36] = x9 >>> 0 & 0xff;\n o[37] = x9 >>> 8 & 0xff;\n o[38] = x9 >>> 16 & 0xff;\n o[39] = x9 >>> 24 & 0xff;\n\n o[40] = x10 >>> 0 & 0xff;\n o[41] = x10 >>> 8 & 0xff;\n o[42] = x10 >>> 16 & 0xff;\n o[43] = x10 >>> 24 & 0xff;\n\n o[44] = x11 >>> 0 & 0xff;\n o[45] = x11 >>> 8 & 0xff;\n o[46] = x11 >>> 16 & 0xff;\n o[47] = x11 >>> 24 & 0xff;\n\n o[48] = x12 >>> 0 & 0xff;\n o[49] = x12 >>> 8 & 0xff;\n o[50] = x12 >>> 16 & 0xff;\n o[51] = x12 >>> 24 & 0xff;\n\n o[52] = x13 >>> 0 & 0xff;\n o[53] = x13 >>> 8 & 0xff;\n o[54] = x13 >>> 16 & 0xff;\n o[55] = x13 >>> 24 & 0xff;\n\n o[56] = x14 >>> 0 & 0xff;\n o[57] = x14 >>> 8 & 0xff;\n o[58] = x14 >>> 16 & 0xff;\n o[59] = x14 >>> 24 & 0xff;\n\n o[60] = x15 >>> 0 & 0xff;\n o[61] = x15 >>> 8 & 0xff;\n o[62] = x15 >>> 16 & 0xff;\n o[63] = x15 >>> 24 & 0xff;\n}\n\nfunction core_hsalsa20(o,p,k,c) {\n var j0 = c[ 0] & 0xff | (c[ 1] & 0xff)<<8 | (c[ 2] & 0xff)<<16 | (c[ 3] & 0xff)<<24,\n j1 = k[ 0] & 0xff | (k[ 1] & 0xff)<<8 | (k[ 2] & 0xff)<<16 | (k[ 3] & 0xff)<<24,\n j2 = k[ 4] & 0xff | (k[ 5] & 0xff)<<8 | (k[ 6] & 0xff)<<16 | (k[ 7] & 0xff)<<24,\n j3 = k[ 8] & 0xff | (k[ 9] & 0xff)<<8 | (k[10] & 0xff)<<16 | (k[11] & 0xff)<<24,\n j4 = k[12] & 0xff | (k[13] & 0xff)<<8 | (k[14] & 0xff)<<16 | (k[15] & 0xff)<<24,\n j5 = c[ 4] & 0xff | (c[ 5] & 0xff)<<8 | (c[ 6] & 0xff)<<16 | (c[ 7] & 0xff)<<24,\n j6 = p[ 0] & 0xff | (p[ 1] & 0xff)<<8 | (p[ 2] & 0xff)<<16 | (p[ 3] & 0xff)<<24,\n j7 = p[ 4] & 0xff | (p[ 5] & 0xff)<<8 | (p[ 6] & 0xff)<<16 | (p[ 7] & 0xff)<<24,\n j8 = p[ 8] & 0xff | (p[ 9] & 0xff)<<8 | (p[10] & 0xff)<<16 | (p[11] & 0xff)<<24,\n j9 = p[12] & 0xff | (p[13] & 0xff)<<8 | (p[14] & 0xff)<<16 | (p[15] & 0xff)<<24,\n j10 = c[ 8] & 0xff | (c[ 9] & 0xff)<<8 | (c[10] & 0xff)<<16 | (c[11] & 0xff)<<24,\n j11 = k[16] & 0xff | (k[17] & 0xff)<<8 | (k[18] & 0xff)<<16 | (k[19] & 0xff)<<24,\n j12 = k[20] & 0xff | (k[21] & 0xff)<<8 | (k[22] & 0xff)<<16 | (k[23] & 0xff)<<24,\n j13 = k[24] & 0xff | (k[25] & 0xff)<<8 | (k[26] & 0xff)<<16 | (k[27] & 0xff)<<24,\n j14 = k[28] & 0xff | (k[29] & 0xff)<<8 | (k[30] & 0xff)<<16 | (k[31] & 0xff)<<24,\n j15 = c[12] & 0xff | (c[13] & 0xff)<<8 | (c[14] & 0xff)<<16 | (c[15] & 0xff)<<24;\n\n var x0 = j0, x1 = j1, x2 = j2, x3 = j3, x4 = j4, x5 = j5, x6 = j6, x7 = j7,\n x8 = j8, x9 = j9, x10 = j10, x11 = j11, x12 = j12, x13 = j13, x14 = j14,\n x15 = j15, u;\n\n for (var i = 0; i < 20; i += 2) {\n u = x0 + x12 | 0;\n x4 ^= u<<7 | u>>>(32-7);\n u = x4 + x0 | 0;\n x8 ^= u<<9 | u>>>(32-9);\n u = x8 + x4 | 0;\n x12 ^= u<<13 | u>>>(32-13);\n u = x12 + x8 | 0;\n x0 ^= u<<18 | u>>>(32-18);\n\n u = x5 + x1 | 0;\n x9 ^= u<<7 | u>>>(32-7);\n u = x9 + x5 | 0;\n x13 ^= u<<9 | u>>>(32-9);\n u = x13 + x9 | 0;\n x1 ^= u<<13 | u>>>(32-13);\n u = x1 + x13 | 0;\n x5 ^= u<<18 | u>>>(32-18);\n\n u = x10 + x6 | 0;\n x14 ^= u<<7 | u>>>(32-7);\n u = x14 + x10 | 0;\n x2 ^= u<<9 | u>>>(32-9);\n u = x2 + x14 | 0;\n x6 ^= u<<13 | u>>>(32-13);\n u = x6 + x2 | 0;\n x10 ^= u<<18 | u>>>(32-18);\n\n u = x15 + x11 | 0;\n x3 ^= u<<7 | u>>>(32-7);\n u = x3 + x15 | 0;\n x7 ^= u<<9 | u>>>(32-9);\n u = x7 + x3 | 0;\n x11 ^= u<<13 | u>>>(32-13);\n u = x11 + x7 | 0;\n x15 ^= u<<18 | u>>>(32-18);\n\n u = x0 + x3 | 0;\n x1 ^= u<<7 | u>>>(32-7);\n u = x1 + x0 | 0;\n x2 ^= u<<9 | u>>>(32-9);\n u = x2 + x1 | 0;\n x3 ^= u<<13 | u>>>(32-13);\n u = x3 + x2 | 0;\n x0 ^= u<<18 | u>>>(32-18);\n\n u = x5 + x4 | 0;\n x6 ^= u<<7 | u>>>(32-7);\n u = x6 + x5 | 0;\n x7 ^= u<<9 | u>>>(32-9);\n u = x7 + x6 | 0;\n x4 ^= u<<13 | u>>>(32-13);\n u = x4 + x7 | 0;\n x5 ^= u<<18 | u>>>(32-18);\n\n u = x10 + x9 | 0;\n x11 ^= u<<7 | u>>>(32-7);\n u = x11 + x10 | 0;\n x8 ^= u<<9 | u>>>(32-9);\n u = x8 + x11 | 0;\n x9 ^= u<<13 | u>>>(32-13);\n u = x9 + x8 | 0;\n x10 ^= u<<18 | u>>>(32-18);\n\n u = x15 + x14 | 0;\n x12 ^= u<<7 | u>>>(32-7);\n u = x12 + x15 | 0;\n x13 ^= u<<9 | u>>>(32-9);\n u = x13 + x12 | 0;\n x14 ^= u<<13 | u>>>(32-13);\n u = x14 + x13 | 0;\n x15 ^= u<<18 | u>>>(32-18);\n }\n\n o[ 0] = x0 >>> 0 & 0xff;\n o[ 1] = x0 >>> 8 & 0xff;\n o[ 2] = x0 >>> 16 & 0xff;\n o[ 3] = x0 >>> 24 & 0xff;\n\n o[ 4] = x5 >>> 0 & 0xff;\n o[ 5] = x5 >>> 8 & 0xff;\n o[ 6] = x5 >>> 16 & 0xff;\n o[ 7] = x5 >>> 24 & 0xff;\n\n o[ 8] = x10 >>> 0 & 0xff;\n o[ 9] = x10 >>> 8 & 0xff;\n o[10] = x10 >>> 16 & 0xff;\n o[11] = x10 >>> 24 & 0xff;\n\n o[12] = x15 >>> 0 & 0xff;\n o[13] = x15 >>> 8 & 0xff;\n o[14] = x15 >>> 16 & 0xff;\n o[15] = x15 >>> 24 & 0xff;\n\n o[16] = x6 >>> 0 & 0xff;\n o[17] = x6 >>> 8 & 0xff;\n o[18] = x6 >>> 16 & 0xff;\n o[19] = x6 >>> 24 & 0xff;\n\n o[20] = x7 >>> 0 & 0xff;\n o[21] = x7 >>> 8 & 0xff;\n o[22] = x7 >>> 16 & 0xff;\n o[23] = x7 >>> 24 & 0xff;\n\n o[24] = x8 >>> 0 & 0xff;\n o[25] = x8 >>> 8 & 0xff;\n o[26] = x8 >>> 16 & 0xff;\n o[27] = x8 >>> 24 & 0xff;\n\n o[28] = x9 >>> 0 & 0xff;\n o[29] = x9 >>> 8 & 0xff;\n o[30] = x9 >>> 16 & 0xff;\n o[31] = x9 >>> 24 & 0xff;\n}\n\nfunction crypto_core_salsa20(out,inp,k,c) {\n core_salsa20(out,inp,k,c);\n}\n\nfunction crypto_core_hsalsa20(out,inp,k,c) {\n core_hsalsa20(out,inp,k,c);\n}\n\nvar sigma = new Uint8Array([101, 120, 112, 97, 110, 100, 32, 51, 50, 45, 98, 121, 116, 101, 32, 107]);\n // \"expand 32-byte k\"\n\nfunction crypto_stream_salsa20_xor(c,cpos,m,mpos,b,n,k) {\n var z = new Uint8Array(16), x = new Uint8Array(64);\n var u, i;\n for (i = 0; i < 16; i++) z[i] = 0;\n for (i = 0; i < 8; i++) z[i] = n[i];\n while (b >= 64) {\n crypto_core_salsa20(x,z,k,sigma);\n for (i = 0; i < 64; i++) c[cpos+i] = m[mpos+i] ^ x[i];\n u = 1;\n for (i = 8; i < 16; i++) {\n u = u + (z[i] & 0xff) | 0;\n z[i] = u & 0xff;\n u >>>= 8;\n }\n b -= 64;\n cpos += 64;\n mpos += 64;\n }\n if (b > 0) {\n crypto_core_salsa20(x,z,k,sigma);\n for (i = 0; i < b; i++) c[cpos+i] = m[mpos+i] ^ x[i];\n }\n return 0;\n}\n\nfunction crypto_stream_salsa20(c,cpos,b,n,k) {\n var z = new Uint8Array(16), x = new Uint8Array(64);\n var u, i;\n for (i = 0; i < 16; i++) z[i] = 0;\n for (i = 0; i < 8; i++) z[i] = n[i];\n while (b >= 64) {\n crypto_core_salsa20(x,z,k,sigma);\n for (i = 0; i < 64; i++) c[cpos+i] = x[i];\n u = 1;\n for (i = 8; i < 16; i++) {\n u = u + (z[i] & 0xff) | 0;\n z[i] = u & 0xff;\n u >>>= 8;\n }\n b -= 64;\n cpos += 64;\n }\n if (b > 0) {\n crypto_core_salsa20(x,z,k,sigma);\n for (i = 0; i < b; i++) c[cpos+i] = x[i];\n }\n return 0;\n}\n\nfunction crypto_stream(c,cpos,d,n,k) {\n var s = new Uint8Array(32);\n crypto_core_hsalsa20(s,n,k,sigma);\n var sn = new Uint8Array(8);\n for (var i = 0; i < 8; i++) sn[i] = n[i+16];\n return crypto_stream_salsa20(c,cpos,d,sn,s);\n}\n\nfunction crypto_stream_xor(c,cpos,m,mpos,d,n,k) {\n var s = new Uint8Array(32);\n crypto_core_hsalsa20(s,n,k,sigma);\n var sn = new Uint8Array(8);\n for (var i = 0; i < 8; i++) sn[i] = n[i+16];\n return crypto_stream_salsa20_xor(c,cpos,m,mpos,d,sn,s);\n}\n\n/*\n* Port of Andrew Moon's Poly1305-donna-16. Public domain.\n* https://github.com/floodyberry/poly1305-donna\n*/\n\nvar poly1305 = function(key) {\n this.buffer = new Uint8Array(16);\n this.r = new Uint16Array(10);\n this.h = new Uint16Array(10);\n this.pad = new Uint16Array(8);\n this.leftover = 0;\n this.fin = 0;\n\n var t0, t1, t2, t3, t4, t5, t6, t7;\n\n t0 = key[ 0] & 0xff | (key[ 1] & 0xff) << 8; this.r[0] = ( t0 ) & 0x1fff;\n t1 = key[ 2] & 0xff | (key[ 3] & 0xff) << 8; this.r[1] = ((t0 >>> 13) | (t1 << 3)) & 0x1fff;\n t2 = key[ 4] & 0xff | (key[ 5] & 0xff) << 8; this.r[2] = ((t1 >>> 10) | (t2 << 6)) & 0x1f03;\n t3 = key[ 6] & 0xff | (key[ 7] & 0xff) << 8; this.r[3] = ((t2 >>> 7) | (t3 << 9)) & 0x1fff;\n t4 = key[ 8] & 0xff | (key[ 9] & 0xff) << 8; this.r[4] = ((t3 >>> 4) | (t4 << 12)) & 0x00ff;\n this.r[5] = ((t4 >>> 1)) & 0x1ffe;\n t5 = key[10] & 0xff | (key[11] & 0xff) << 8; this.r[6] = ((t4 >>> 14) | (t5 << 2)) & 0x1fff;\n t6 = key[12] & 0xff | (key[13] & 0xff) << 8; this.r[7] = ((t5 >>> 11) | (t6 << 5)) & 0x1f81;\n t7 = key[14] & 0xff | (key[15] & 0xff) << 8; this.r[8] = ((t6 >>> 8) | (t7 << 8)) & 0x1fff;\n this.r[9] = ((t7 >>> 5)) & 0x007f;\n\n this.pad[0] = key[16] & 0xff | (key[17] & 0xff) << 8;\n this.pad[1] = key[18] & 0xff | (key[19] & 0xff) << 8;\n this.pad[2] = key[20] & 0xff | (key[21] & 0xff) << 8;\n this.pad[3] = key[22] & 0xff | (key[23] & 0xff) << 8;\n this.pad[4] = key[24] & 0xff | (key[25] & 0xff) << 8;\n this.pad[5] = key[26] & 0xff | (key[27] & 0xff) << 8;\n this.pad[6] = key[28] & 0xff | (key[29] & 0xff) << 8;\n this.pad[7] = key[30] & 0xff | (key[31] & 0xff) << 8;\n};\n\npoly1305.prototype.blocks = function(m, mpos, bytes) {\n var hibit = this.fin ? 0 : (1 << 11);\n var t0, t1, t2, t3, t4, t5, t6, t7, c;\n var d0, d1, d2, d3, d4, d5, d6, d7, d8, d9;\n\n var h0 = this.h[0],\n h1 = this.h[1],\n h2 = this.h[2],\n h3 = this.h[3],\n h4 = this.h[4],\n h5 = this.h[5],\n h6 = this.h[6],\n h7 = this.h[7],\n h8 = this.h[8],\n h9 = this.h[9];\n\n var r0 = this.r[0],\n r1 = this.r[1],\n r2 = this.r[2],\n r3 = this.r[3],\n r4 = this.r[4],\n r5 = this.r[5],\n r6 = this.r[6],\n r7 = this.r[7],\n r8 = this.r[8],\n r9 = this.r[9];\n\n while (bytes >= 16) {\n t0 = m[mpos+ 0] & 0xff | (m[mpos+ 1] & 0xff) << 8; h0 += ( t0 ) & 0x1fff;\n t1 = m[mpos+ 2] & 0xff | (m[mpos+ 3] & 0xff) << 8; h1 += ((t0 >>> 13) | (t1 << 3)) & 0x1fff;\n t2 = m[mpos+ 4] & 0xff | (m[mpos+ 5] & 0xff) << 8; h2 += ((t1 >>> 10) | (t2 << 6)) & 0x1fff;\n t3 = m[mpos+ 6] & 0xff | (m[mpos+ 7] & 0xff) << 8; h3 += ((t2 >>> 7) | (t3 << 9)) & 0x1fff;\n t4 = m[mpos+ 8] & 0xff | (m[mpos+ 9] & 0xff) << 8; h4 += ((t3 >>> 4) | (t4 << 12)) & 0x1fff;\n h5 += ((t4 >>> 1)) & 0x1fff;\n t5 = m[mpos+10] & 0xff | (m[mpos+11] & 0xff) << 8; h6 += ((t4 >>> 14) | (t5 << 2)) & 0x1fff;\n t6 = m[mpos+12] & 0xff | (m[mpos+13] & 0xff) << 8; h7 += ((t5 >>> 11) | (t6 << 5)) & 0x1fff;\n t7 = m[mpos+14] & 0xff | (m[mpos+15] & 0xff) << 8; h8 += ((t6 >>> 8) | (t7 << 8)) & 0x1fff;\n h9 += ((t7 >>> 5)) | hibit;\n\n c = 0;\n\n d0 = c;\n d0 += h0 * r0;\n d0 += h1 * (5 * r9);\n d0 += h2 * (5 * r8);\n d0 += h3 * (5 * r7);\n d0 += h4 * (5 * r6);\n c = (d0 >>> 13); d0 &= 0x1fff;\n d0 += h5 * (5 * r5);\n d0 += h6 * (5 * r4);\n d0 += h7 * (5 * r3);\n d0 += h8 * (5 * r2);\n d0 += h9 * (5 * r1);\n c += (d0 >>> 13); d0 &= 0x1fff;\n\n d1 = c;\n d1 += h0 * r1;\n d1 += h1 * r0;\n d1 += h2 * (5 * r9);\n d1 += h3 * (5 * r8);\n d1 += h4 * (5 * r7);\n c = (d1 >>> 13); d1 &= 0x1fff;\n d1 += h5 * (5 * r6);\n d1 += h6 * (5 * r5);\n d1 += h7 * (5 * r4);\n d1 += h8 * (5 * r3);\n d1 += h9 * (5 * r2);\n c += (d1 >>> 13); d1 &= 0x1fff;\n\n d2 = c;\n d2 += h0 * r2;\n d2 += h1 * r1;\n d2 += h2 * r0;\n d2 += h3 * (5 * r9);\n d2 += h4 * (5 * r8);\n c = (d2 >>> 13); d2 &= 0x1fff;\n d2 += h5 * (5 * r7);\n d2 += h6 * (5 * r6);\n d2 += h7 * (5 * r5);\n d2 += h8 * (5 * r4);\n d2 += h9 * (5 * r3);\n c += (d2 >>> 13); d2 &= 0x1fff;\n\n d3 = c;\n d3 += h0 * r3;\n d3 += h1 * r2;\n d3 += h2 * r1;\n d3 += h3 * r0;\n d3 += h4 * (5 * r9);\n c = (d3 >>> 13); d3 &= 0x1fff;\n d3 += h5 * (5 * r8);\n d3 += h6 * (5 * r7);\n d3 += h7 * (5 * r6);\n d3 += h8 * (5 * r5);\n d3 += h9 * (5 * r4);\n c += (d3 >>> 13); d3 &= 0x1fff;\n\n d4 = c;\n d4 += h0 * r4;\n d4 += h1 * r3;\n d4 += h2 * r2;\n d4 += h3 * r1;\n d4 += h4 * r0;\n c = (d4 >>> 13); d4 &= 0x1fff;\n d4 += h5 * (5 * r9);\n d4 += h6 * (5 * r8);\n d4 += h7 * (5 * r7);\n d4 += h8 * (5 * r6);\n d4 += h9 * (5 * r5);\n c += (d4 >>> 13); d4 &= 0x1fff;\n\n d5 = c;\n d5 += h0 * r5;\n d5 += h1 * r4;\n d5 += h2 * r3;\n d5 += h3 * r2;\n d5 += h4 * r1;\n c = (d5 >>> 13); d5 &= 0x1fff;\n d5 += h5 * r0;\n d5 += h6 * (5 * r9);\n d5 += h7 * (5 * r8);\n d5 += h8 * (5 * r7);\n d5 += h9 * (5 * r6);\n c += (d5 >>> 13); d5 &= 0x1fff;\n\n d6 = c;\n d6 += h0 * r6;\n d6 += h1 * r5;\n d6 += h2 * r4;\n d6 += h3 * r3;\n d6 += h4 * r2;\n c = (d6 >>> 13); d6 &= 0x1fff;\n d6 += h5 * r1;\n d6 += h6 * r0;\n d6 += h7 * (5 * r9);\n d6 += h8 * (5 * r8);\n d6 += h9 * (5 * r7);\n c += (d6 >>> 13); d6 &= 0x1fff;\n\n d7 = c;\n d7 += h0 * r7;\n d7 += h1 * r6;\n d7 += h2 * r5;\n d7 += h3 * r4;\n d7 += h4 * r3;\n c = (d7 >>> 13); d7 &= 0x1fff;\n d7 += h5 * r2;\n d7 += h6 * r1;\n d7 += h7 * r0;\n d7 += h8 * (5 * r9);\n d7 += h9 * (5 * r8);\n c += (d7 >>> 13); d7 &= 0x1fff;\n\n d8 = c;\n d8 += h0 * r8;\n d8 += h1 * r7;\n d8 += h2 * r6;\n d8 += h3 * r5;\n d8 += h4 * r4;\n c = (d8 >>> 13); d8 &= 0x1fff;\n d8 += h5 * r3;\n d8 += h6 * r2;\n d8 += h7 * r1;\n d8 += h8 * r0;\n d8 += h9 * (5 * r9);\n c += (d8 >>> 13); d8 &= 0x1fff;\n\n d9 = c;\n d9 += h0 * r9;\n d9 += h1 * r8;\n d9 += h2 * r7;\n d9 += h3 * r6;\n d9 += h4 * r5;\n c = (d9 >>> 13); d9 &= 0x1fff;\n d9 += h5 * r4;\n d9 += h6 * r3;\n d9 += h7 * r2;\n d9 += h8 * r1;\n d9 += h9 * r0;\n c += (d9 >>> 13); d9 &= 0x1fff;\n\n c = (((c << 2) + c)) | 0;\n c = (c + d0) | 0;\n d0 = c & 0x1fff;\n c = (c >>> 13);\n d1 += c;\n\n h0 = d0;\n h1 = d1;\n h2 = d2;\n h3 = d3;\n h4 = d4;\n h5 = d5;\n h6 = d6;\n h7 = d7;\n h8 = d8;\n h9 = d9;\n\n mpos += 16;\n bytes -= 16;\n }\n this.h[0] = h0;\n this.h[1] = h1;\n this.h[2] = h2;\n this.h[3] = h3;\n this.h[4] = h4;\n this.h[5] = h5;\n this.h[6] = h6;\n this.h[7] = h7;\n this.h[8] = h8;\n this.h[9] = h9;\n};\n\npoly1305.prototype.finish = function(mac, macpos) {\n var g = new Uint16Array(10);\n var c, mask, f, i;\n\n if (this.leftover) {\n i = this.leftover;\n this.buffer[i++] = 1;\n for (; i < 16; i++) this.buffer[i] = 0;\n this.fin = 1;\n this.blocks(this.buffer, 0, 16);\n }\n\n c = this.h[1] >>> 13;\n this.h[1] &= 0x1fff;\n for (i = 2; i < 10; i++) {\n this.h[i] += c;\n c = this.h[i] >>> 13;\n this.h[i] &= 0x1fff;\n }\n this.h[0] += (c * 5);\n c = this.h[0] >>> 13;\n this.h[0] &= 0x1fff;\n this.h[1] += c;\n c = this.h[1] >>> 13;\n this.h[1] &= 0x1fff;\n this.h[2] += c;\n\n g[0] = this.h[0] + 5;\n c = g[0] >>> 13;\n g[0] &= 0x1fff;\n for (i = 1; i < 10; i++) {\n g[i] = this.h[i] + c;\n c = g[i] >>> 13;\n g[i] &= 0x1fff;\n }\n g[9] -= (1 << 13);\n\n mask = (c ^ 1) - 1;\n for (i = 0; i < 10; i++) g[i] &= mask;\n mask = ~mask;\n for (i = 0; i < 10; i++) this.h[i] = (this.h[i] & mask) | g[i];\n\n this.h[0] = ((this.h[0] ) | (this.h[1] << 13) ) & 0xffff;\n this.h[1] = ((this.h[1] >>> 3) | (this.h[2] << 10) ) & 0xffff;\n this.h[2] = ((this.h[2] >>> 6) | (this.h[3] << 7) ) & 0xffff;\n this.h[3] = ((this.h[3] >>> 9) | (this.h[4] << 4) ) & 0xffff;\n this.h[4] = ((this.h[4] >>> 12) | (this.h[5] << 1) | (this.h[6] << 14)) & 0xffff;\n this.h[5] = ((this.h[6] >>> 2) | (this.h[7] << 11) ) & 0xffff;\n this.h[6] = ((this.h[7] >>> 5) | (this.h[8] << 8) ) & 0xffff;\n this.h[7] = ((this.h[8] >>> 8) | (this.h[9] << 5) ) & 0xffff;\n\n f = this.h[0] + this.pad[0];\n this.h[0] = f & 0xffff;\n for (i = 1; i < 8; i++) {\n f = (((this.h[i] + this.pad[i]) | 0) + (f >>> 16)) | 0;\n this.h[i] = f & 0xffff;\n }\n\n mac[macpos+ 0] = (this.h[0] >>> 0) & 0xff;\n mac[macpos+ 1] = (this.h[0] >>> 8) & 0xff;\n mac[macpos+ 2] = (this.h[1] >>> 0) & 0xff;\n mac[macpos+ 3] = (this.h[1] >>> 8) & 0xff;\n mac[macpos+ 4] = (this.h[2] >>> 0) & 0xff;\n mac[macpos+ 5] = (this.h[2] >>> 8) & 0xff;\n mac[macpos+ 6] = (this.h[3] >>> 0) & 0xff;\n mac[macpos+ 7] = (this.h[3] >>> 8) & 0xff;\n mac[macpos+ 8] = (this.h[4] >>> 0) & 0xff;\n mac[macpos+ 9] = (this.h[4] >>> 8) & 0xff;\n mac[macpos+10] = (this.h[5] >>> 0) & 0xff;\n mac[macpos+11] = (this.h[5] >>> 8) & 0xff;\n mac[macpos+12] = (this.h[6] >>> 0) & 0xff;\n mac[macpos+13] = (this.h[6] >>> 8) & 0xff;\n mac[macpos+14] = (this.h[7] >>> 0) & 0xff;\n mac[macpos+15] = (this.h[7] >>> 8) & 0xff;\n};\n\npoly1305.prototype.update = function(m, mpos, bytes) {\n var i, want;\n\n if (this.leftover) {\n want = (16 - this.leftover);\n if (want > bytes)\n want = bytes;\n for (i = 0; i < want; i++)\n this.buffer[this.leftover + i] = m[mpos+i];\n bytes -= want;\n mpos += want;\n this.leftover += want;\n if (this.leftover < 16)\n return;\n this.blocks(this.buffer, 0, 16);\n this.leftover = 0;\n }\n\n if (bytes >= 16) {\n want = bytes - (bytes % 16);\n this.blocks(m, mpos, want);\n mpos += want;\n bytes -= want;\n }\n\n if (bytes) {\n for (i = 0; i < bytes; i++)\n this.buffer[this.leftover + i] = m[mpos+i];\n this.leftover += bytes;\n }\n};\n\nfunction crypto_onetimeauth(out, outpos, m, mpos, n, k) {\n var s = new poly1305(k);\n s.update(m, mpos, n);\n s.finish(out, outpos);\n return 0;\n}\n\nfunction crypto_onetimeauth_verify(h, hpos, m, mpos, n, k) {\n var x = new Uint8Array(16);\n crypto_onetimeauth(x,0,m,mpos,n,k);\n return crypto_verify_16(h,hpos,x,0);\n}\n\nfunction crypto_secretbox(c,m,d,n,k) {\n var i;\n if (d < 32) return -1;\n crypto_stream_xor(c,0,m,0,d,n,k);\n crypto_onetimeauth(c, 16, c, 32, d - 32, c);\n for (i = 0; i < 16; i++) c[i] = 0;\n return 0;\n}\n\nfunction crypto_secretbox_open(m,c,d,n,k) {\n var i;\n var x = new Uint8Array(32);\n if (d < 32) return -1;\n crypto_stream(x,0,32,n,k);\n if (crypto_onetimeauth_verify(c, 16,c, 32,d - 32,x) !== 0) return -1;\n crypto_stream_xor(m,0,c,0,d,n,k);\n for (i = 0; i < 32; i++) m[i] = 0;\n return 0;\n}\n\nfunction set25519(r, a) {\n var i;\n for (i = 0; i < 16; i++) r[i] = a[i]|0;\n}\n\nfunction car25519(o) {\n var i, v, c = 1;\n for (i = 0; i < 16; i++) {\n v = o[i] + c + 65535;\n c = Math.floor(v / 65536);\n o[i] = v - c * 65536;\n }\n o[0] += c-1 + 37 * (c-1);\n}\n\nfunction sel25519(p, q, b) {\n var t, c = ~(b-1);\n for (var i = 0; i < 16; i++) {\n t = c & (p[i] ^ q[i]);\n p[i] ^= t;\n q[i] ^= t;\n }\n}\n\nfunction pack25519(o, n) {\n var i, j, b;\n var m = gf(), t = gf();\n for (i = 0; i < 16; i++) t[i] = n[i];\n car25519(t);\n car25519(t);\n car25519(t);\n for (j = 0; j < 2; j++) {\n m[0] = t[0] - 0xffed;\n for (i = 1; i < 15; i++) {\n m[i] = t[i] - 0xffff - ((m[i-1]>>16) & 1);\n m[i-1] &= 0xffff;\n }\n m[15] = t[15] - 0x7fff - ((m[14]>>16) & 1);\n b = (m[15]>>16) & 1;\n m[14] &= 0xffff;\n sel25519(t, m, 1-b);\n }\n for (i = 0; i < 16; i++) {\n o[2*i] = t[i] & 0xff;\n o[2*i+1] = t[i]>>8;\n }\n}\n\nfunction neq25519(a, b) {\n var c = new Uint8Array(32), d = new Uint8Array(32);\n pack25519(c, a);\n pack25519(d, b);\n return crypto_verify_32(c, 0, d, 0);\n}\n\nfunction par25519(a) {\n var d = new Uint8Array(32);\n pack25519(d, a);\n return d[0] & 1;\n}\n\nfunction unpack25519(o, n) {\n var i;\n for (i = 0; i < 16; i++) o[i] = n[2*i] + (n[2*i+1] << 8);\n o[15] &= 0x7fff;\n}\n\nfunction A(o, a, b) {\n for (var i = 0; i < 16; i++) o[i] = a[i] + b[i];\n}\n\nfunction Z(o, a, b) {\n for (var i = 0; i < 16; i++) o[i] = a[i] - b[i];\n}\n\nfunction M(o, a, b) {\n var v, c,\n t0 = 0, t1 = 0, t2 = 0, t3 = 0, t4 = 0, t5 = 0, t6 = 0, t7 = 0,\n t8 = 0, t9 = 0, t10 = 0, t11 = 0, t12 = 0, t13 = 0, t14 = 0, t15 = 0,\n t16 = 0, t17 = 0, t18 = 0, t19 = 0, t20 = 0, t21 = 0, t22 = 0, t23 = 0,\n t24 = 0, t25 = 0, t26 = 0, t27 = 0, t28 = 0, t29 = 0, t30 = 0,\n b0 = b[0],\n b1 = b[1],\n b2 = b[2],\n b3 = b[3],\n b4 = b[4],\n b5 = b[5],\n b6 = b[6],\n b7 = b[7],\n b8 = b[8],\n b9 = b[9],\n b10 = b[10],\n b11 = b[11],\n b12 = b[12],\n b13 = b[13],\n b14 = b[14],\n b15 = b[15];\n\n v = a[0];\n t0 += v * b0;\n t1 += v * b1;\n t2 += v * b2;\n t3 += v * b3;\n t4 += v * b4;\n t5 += v * b5;\n t6 += v * b6;\n t7 += v * b7;\n t8 += v * b8;\n t9 += v * b9;\n t10 += v * b10;\n t11 += v * b11;\n t12 += v * b12;\n t13 += v * b13;\n t14 += v * b14;\n t15 += v * b15;\n v = a[1];\n t1 += v * b0;\n t2 += v * b1;\n t3 += v * b2;\n t4 += v * b3;\n t5 += v * b4;\n t6 += v * b5;\n t7 += v * b6;\n t8 += v * b7;\n t9 += v * b8;\n t10 += v * b9;\n t11 += v * b10;\n t12 += v * b11;\n t13 += v * b12;\n t14 += v * b13;\n t15 += v * b14;\n t16 += v * b15;\n v = a[2];\n t2 += v * b0;\n t3 += v * b1;\n t4 += v * b2;\n t5 += v * b3;\n t6 += v * b4;\n t7 += v * b5;\n t8 += v * b6;\n t9 += v * b7;\n t10 += v * b8;\n t11 += v * b9;\n t12 += v * b10;\n t13 += v * b11;\n t14 += v * b12;\n t15 += v * b13;\n t16 += v * b14;\n t17 += v * b15;\n v = a[3];\n t3 += v * b0;\n t4 += v * b1;\n t5 += v * b2;\n t6 += v * b3;\n t7 += v * b4;\n t8 += v * b5;\n t9 += v * b6;\n t10 += v * b7;\n t11 += v * b8;\n t12 += v * b9;\n t13 += v * b10;\n t14 += v * b11;\n t15 += v * b12;\n t16 += v * b13;\n t17 += v * b14;\n t18 += v * b15;\n v = a[4];\n t4 += v * b0;\n t5 += v * b1;\n t6 += v * b2;\n t7 += v * b3;\n t8 += v * b4;\n t9 += v * b5;\n t10 += v * b6;\n t11 += v * b7;\n t12 += v * b8;\n t13 += v * b9;\n t14 += v * b10;\n t15 += v * b11;\n t16 += v * b12;\n t17 += v * b13;\n t18 += v * b14;\n t19 += v * b15;\n v = a[5];\n t5 += v * b0;\n t6 += v * b1;\n t7 += v * b2;\n t8 += v * b3;\n t9 += v * b4;\n t10 += v * b5;\n t11 += v * b6;\n t12 += v * b7;\n t13 += v * b8;\n t14 += v * b9;\n t15 += v * b10;\n t16 += v * b11;\n t17 += v * b12;\n t18 += v * b13;\n t19 += v * b14;\n t20 += v * b15;\n v = a[6];\n t6 += v * b0;\n t7 += v * b1;\n t8 += v * b2;\n t9 += v * b3;\n t10 += v * b4;\n t11 += v * b5;\n t12 += v * b6;\n t13 += v * b7;\n t14 += v * b8;\n t15 += v * b9;\n t16 += v * b10;\n t17 += v * b11;\n t18 += v * b12;\n t19 += v * b13;\n t20 += v * b14;\n t21 += v * b15;\n v = a[7];\n t7 += v * b0;\n t8 += v * b1;\n t9 += v * b2;\n t10 += v * b3;\n t11 += v * b4;\n t12 += v * b5;\n t13 += v * b6;\n t14 += v * b7;\n t15 += v * b8;\n t16 += v * b9;\n t17 += v * b10;\n t18 += v * b11;\n t19 += v * b12;\n t20 += v * b13;\n t21 += v * b14;\n t22 += v * b15;\n v = a[8];\n t8 += v * b0;\n t9 += v * b1;\n t10 += v * b2;\n t11 += v * b3;\n t12 += v * b4;\n t13 += v * b5;\n t14 += v * b6;\n t15 += v * b7;\n t16 += v * b8;\n t17 += v * b9;\n t18 += v * b10;\n t19 += v * b11;\n t20 += v * b12;\n t21 += v * b13;\n t22 += v * b14;\n t23 += v * b15;\n v = a[9];\n t9 += v * b0;\n t10 += v * b1;\n t11 += v * b2;\n t12 += v * b3;\n t13 += v * b4;\n t14 += v * b5;\n t15 += v * b6;\n t16 += v * b7;\n t17 += v * b8;\n t18 += v * b9;\n t19 += v * b10;\n t20 += v * b11;\n t21 += v * b12;\n t22 += v * b13;\n t23 += v * b14;\n t24 += v * b15;\n v = a[10];\n t10 += v * b0;\n t11 += v * b1;\n t12 += v * b2;\n t13 += v * b3;\n t14 += v * b4;\n t15 += v * b5;\n t16 += v * b6;\n t17 += v * b7;\n t18 += v * b8;\n t19 += v * b9;\n t20 += v * b10;\n t21 += v * b11;\n t22 += v * b12;\n t23 += v * b13;\n t24 += v * b14;\n t25 += v * b15;\n v = a[11];\n t11 += v * b0;\n t12 += v * b1;\n t13 += v * b2;\n t14 += v * b3;\n t15 += v * b4;\n t16 += v * b5;\n t17 += v * b6;\n t18 += v * b7;\n t19 += v * b8;\n t20 += v * b9;\n t21 += v * b10;\n t22 += v * b11;\n t23 += v * b12;\n t24 += v * b13;\n t25 += v * b14;\n t26 += v * b15;\n v = a[12];\n t12 += v * b0;\n t13 += v * b1;\n t14 += v * b2;\n t15 += v * b3;\n t16 += v * b4;\n t17 += v * b5;\n t18 += v * b6;\n t19 += v * b7;\n t20 += v * b8;\n t21 += v * b9;\n t22 += v * b10;\n t23 += v * b11;\n t24 += v * b12;\n t25 += v * b13;\n t26 += v * b14;\n t27 += v * b15;\n v = a[13];\n t13 += v * b0;\n t14 += v * b1;\n t15 += v * b2;\n t16 += v * b3;\n t17 += v * b4;\n t18 += v * b5;\n t19 += v * b6;\n t20 += v * b7;\n t21 += v * b8;\n t22 += v * b9;\n t23 += v * b10;\n t24 += v * b11;\n t25 += v * b12;\n t26 += v * b13;\n t27 += v * b14;\n t28 += v * b15;\n v = a[14];\n t14 += v * b0;\n t15 += v * b1;\n t16 += v * b2;\n t17 += v * b3;\n t18 += v * b4;\n t19 += v * b5;\n t20 += v * b6;\n t21 += v * b7;\n t22 += v * b8;\n t23 += v * b9;\n t24 += v * b10;\n t25 += v * b11;\n t26 += v * b12;\n t27 += v * b13;\n t28 += v * b14;\n t29 += v * b15;\n v = a[15];\n t15 += v * b0;\n t16 += v * b1;\n t17 += v * b2;\n t18 += v * b3;\n t19 += v * b4;\n t20 += v * b5;\n t21 += v * b6;\n t22 += v * b7;\n t23 += v * b8;\n t24 += v * b9;\n t25 += v * b10;\n t26 += v * b11;\n t27 += v * b12;\n t28 += v * b13;\n t29 += v * b14;\n t30 += v * b15;\n\n t0 += 38 * t16;\n t1 += 38 * t17;\n t2 += 38 * t18;\n t3 += 38 * t19;\n t4 += 38 * t20;\n t5 += 38 * t21;\n t6 += 38 * t22;\n t7 += 38 * t23;\n t8 += 38 * t24;\n t9 += 38 * t25;\n t10 += 38 * t26;\n t11 += 38 * t27;\n t12 += 38 * t28;\n t13 += 38 * t29;\n t14 += 38 * t30;\n // t15 left as is\n\n // first car\n c = 1;\n v = t0 + c + 65535; c = Math.floor(v / 65536); t0 = v - c * 65536;\n v = t1 + c + 65535; c = Math.floor(v / 65536); t1 = v - c * 65536;\n v = t2 + c + 65535; c = Math.floor(v / 65536); t2 = v - c * 65536;\n v = t3 + c + 65535; c = Math.floor(v / 65536); t3 = v - c * 65536;\n v = t4 + c + 65535; c = Math.floor(v / 65536); t4 = v - c * 65536;\n v = t5 + c + 65535; c = Math.floor(v / 65536); t5 = v - c * 65536;\n v = t6 + c + 65535; c = Math.floor(v / 65536); t6 = v - c * 65536;\n v = t7 + c + 65535; c = Math.floor(v / 65536); t7 = v - c * 65536;\n v = t8 + c + 65535; c = Math.floor(v / 65536); t8 = v - c * 65536;\n v = t9 + c + 65535; c = Math.floor(v / 65536); t9 = v - c * 65536;\n v = t10 + c + 65535; c = Math.floor(v / 65536); t10 = v - c * 65536;\n v = t11 + c + 65535; c = Math.floor(v / 65536); t11 = v - c * 65536;\n v = t12 + c + 65535; c = Math.floor(v / 65536); t12 = v - c * 65536;\n v = t13 + c + 65535; c = Math.floor(v / 65536); t13 = v - c * 65536;\n v = t14 + c + 65535; c = Math.floor(v / 65536); t14 = v - c * 65536;\n v = t15 + c + 65535; c = Math.floor(v / 65536); t15 = v - c * 65536;\n t0 += c-1 + 37 * (c-1);\n\n // second car\n c = 1;\n v = t0 + c + 65535; c = Math.floor(v / 65536); t0 = v - c * 65536;\n v = t1 + c + 65535; c = Math.floor(v / 65536); t1 = v - c * 65536;\n v = t2 + c + 65535; c = Math.floor(v / 65536); t2 = v - c * 65536;\n v = t3 + c + 65535; c = Math.floor(v / 65536); t3 = v - c * 65536;\n v = t4 + c + 65535; c = Math.floor(v / 65536); t4 = v - c * 65536;\n v = t5 + c + 65535; c = Math.floor(v / 65536); t5 = v - c * 65536;\n v = t6 + c + 65535; c = Math.floor(v / 65536); t6 = v - c * 65536;\n v = t7 + c + 65535; c = Math.floor(v / 65536); t7 = v - c * 65536;\n v = t8 + c + 65535; c = Math.floor(v / 65536); t8 = v - c * 65536;\n v = t9 + c + 65535; c = Math.floor(v / 65536); t9 = v - c * 65536;\n v = t10 + c + 65535; c = Math.floor(v / 65536); t10 = v - c * 65536;\n v = t11 + c + 65535; c = Math.floor(v / 65536); t11 = v - c * 65536;\n v = t12 + c + 65535; c = Math.floor(v / 65536); t12 = v - c * 65536;\n v = t13 + c + 65535; c = Math.floor(v / 65536); t13 = v - c * 65536;\n v = t14 + c + 65535; c = Math.floor(v / 65536); t14 = v - c * 65536;\n v = t15 + c + 65535; c = Math.floor(v / 65536); t15 = v - c * 65536;\n t0 += c-1 + 37 * (c-1);\n\n o[ 0] = t0;\n o[ 1] = t1;\n o[ 2] = t2;\n o[ 3] = t3;\n o[ 4] = t4;\n o[ 5] = t5;\n o[ 6] = t6;\n o[ 7] = t7;\n o[ 8] = t8;\n o[ 9] = t9;\n o[10] = t10;\n o[11] = t11;\n o[12] = t12;\n o[13] = t13;\n o[14] = t14;\n o[15] = t15;\n}\n\nfunction S(o, a) {\n M(o, a, a);\n}\n\nfunction inv25519(o, i) {\n var c = gf();\n var a;\n for (a = 0; a < 16; a++) c[a] = i[a];\n for (a = 253; a >= 0; a--) {\n S(c, c);\n if(a !== 2 && a !== 4) M(c, c, i);\n }\n for (a = 0; a < 16; a++) o[a] = c[a];\n}\n\nfunction pow2523(o, i) {\n var c = gf();\n var a;\n for (a = 0; a < 16; a++) c[a] = i[a];\n for (a = 250; a >= 0; a--) {\n S(c, c);\n if(a !== 1) M(c, c, i);\n }\n for (a = 0; a < 16; a++) o[a] = c[a];\n}\n\nfunction crypto_scalarmult(q, n, p) {\n var z = new Uint8Array(32);\n var x = new Float64Array(80), r, i;\n var a = gf(), b = gf(), c = gf(),\n d = gf(), e = gf(), f = gf();\n for (i = 0; i < 31; i++) z[i] = n[i];\n z[31]=(n[31]&127)|64;\n z[0]&=248;\n unpack25519(x,p);\n for (i = 0; i < 16; i++) {\n b[i]=x[i];\n d[i]=a[i]=c[i]=0;\n }\n a[0]=d[0]=1;\n for (i=254; i>=0; --i) {\n r=(z[i>>>3]>>>(i&7))&1;\n sel25519(a,b,r);\n sel25519(c,d,r);\n A(e,a,c);\n Z(a,a,c);\n A(c,b,d);\n Z(b,b,d);\n S(d,e);\n S(f,a);\n M(a,c,a);\n M(c,b,e);\n A(e,a,c);\n Z(a,a,c);\n S(b,a);\n Z(c,d,f);\n M(a,c,_121665);\n A(a,a,d);\n M(c,c,a);\n M(a,d,f);\n M(d,b,x);\n S(b,e);\n sel25519(a,b,r);\n sel25519(c,d,r);\n }\n for (i = 0; i < 16; i++) {\n x[i+16]=a[i];\n x[i+32]=c[i];\n x[i+48]=b[i];\n x[i+64]=d[i];\n }\n var x32 = x.subarray(32);\n var x16 = x.subarray(16);\n inv25519(x32,x32);\n M(x16,x16,x32);\n pack25519(q,x16);\n return 0;\n}\n\nfunction crypto_scalarmult_base(q, n) {\n return crypto_scalarmult(q, n, _9);\n}\n\nfunction crypto_box_keypair(y, x) {\n randombytes(x, 32);\n return crypto_scalarmult_base(y, x);\n}\n\nfunction crypto_box_beforenm(k, y, x) {\n var s = new Uint8Array(32);\n crypto_scalarmult(s, x, y);\n return crypto_core_hsalsa20(k, _0, s, sigma);\n}\n\nvar crypto_box_afternm = crypto_secretbox;\nvar crypto_box_open_afternm = crypto_secretbox_open;\n\nfunction crypto_box(c, m, d, n, y, x) {\n var k = new Uint8Array(32);\n crypto_box_beforenm(k, y, x);\n return crypto_box_afternm(c, m, d, n, k);\n}\n\nfunction crypto_box_open(m, c, d, n, y, x) {\n var k = new Uint8Array(32);\n crypto_box_beforenm(k, y, x);\n return crypto_box_open_afternm(m, c, d, n, k);\n}\n\nvar K = [\n 0x428a2f98, 0xd728ae22, 0x71374491, 0x23ef65cd,\n 0xb5c0fbcf, 0xec4d3b2f, 0xe9b5dba5, 0x8189dbbc,\n 0x3956c25b, 0xf348b538, 0x59f111f1, 0xb605d019,\n 0x923f82a4, 0xaf194f9b, 0xab1c5ed5, 0xda6d8118,\n 0xd807aa98, 0xa3030242, 0x12835b01, 0x45706fbe,\n 0x243185be, 0x4ee4b28c, 0x550c7dc3, 0xd5ffb4e2,\n 0x72be5d74, 0xf27b896f, 0x80deb1fe, 0x3b1696b1,\n 0x9bdc06a7, 0x25c71235, 0xc19bf174, 0xcf692694,\n 0xe49b69c1, 0x9ef14ad2, 0xefbe4786, 0x384f25e3,\n 0x0fc19dc6, 0x8b8cd5b5, 0x240ca1cc, 0x77ac9c65,\n 0x2de92c6f, 0x592b0275, 0x4a7484aa, 0x6ea6e483,\n 0x5cb0a9dc, 0xbd41fbd4, 0x76f988da, 0x831153b5,\n 0x983e5152, 0xee66dfab, 0xa831c66d, 0x2db43210,\n 0xb00327c8, 0x98fb213f, 0xbf597fc7, 0xbeef0ee4,\n 0xc6e00bf3, 0x3da88fc2, 0xd5a79147, 0x930aa725,\n 0x06ca6351, 0xe003826f, 0x14292967, 0x0a0e6e70,\n 0x27b70a85, 0x46d22ffc, 0x2e1b2138, 0x5c26c926,\n 0x4d2c6dfc, 0x5ac42aed, 0x53380d13, 0x9d95b3df,\n 0x650a7354, 0x8baf63de, 0x766a0abb, 0x3c77b2a8,\n 0x81c2c92e, 0x47edaee6, 0x92722c85, 0x1482353b,\n 0xa2bfe8a1, 0x4cf10364, 0xa81a664b, 0xbc423001,\n 0xc24b8b70, 0xd0f89791, 0xc76c51a3, 0x0654be30,\n 0xd192e819, 0xd6ef5218, 0xd6990624, 0x5565a910,\n 0xf40e3585, 0x5771202a, 0x106aa070, 0x32bbd1b8,\n 0x19a4c116, 0xb8d2d0c8, 0x1e376c08, 0x5141ab53,\n 0x2748774c, 0xdf8eeb99, 0x34b0bcb5, 0xe19b48a8,\n 0x391c0cb3, 0xc5c95a63, 0x4ed8aa4a, 0xe3418acb,\n 0x5b9cca4f, 0x7763e373, 0x682e6ff3, 0xd6b2b8a3,\n 0x748f82ee, 0x5defb2fc, 0x78a5636f, 0x43172f60,\n 0x84c87814, 0xa1f0ab72, 0x8cc70208, 0x1a6439ec,\n 0x90befffa, 0x23631e28, 0xa4506ceb, 0xde82bde9,\n 0xbef9a3f7, 0xb2c67915, 0xc67178f2, 0xe372532b,\n 0xca273ece, 0xea26619c, 0xd186b8c7, 0x21c0c207,\n 0xeada7dd6, 0xcde0eb1e, 0xf57d4f7f, 0xee6ed178,\n 0x06f067aa, 0x72176fba, 0x0a637dc5, 0xa2c898a6,\n 0x113f9804, 0xbef90dae, 0x1b710b35, 0x131c471b,\n 0x28db77f5, 0x23047d84, 0x32caab7b, 0x40c72493,\n 0x3c9ebe0a, 0x15c9bebc, 0x431d67c4, 0x9c100d4c,\n 0x4cc5d4be, 0xcb3e42b6, 0x597f299c, 0xfc657e2a,\n 0x5fcb6fab, 0x3ad6faec, 0x6c44198c, 0x4a475817\n];\n\nfunction crypto_hashblocks_hl(hh, hl, m, n) {\n var wh = new Int32Array(16), wl = new Int32Array(16),\n bh0, bh1, bh2, bh3, bh4, bh5, bh6, bh7,\n bl0, bl1, bl2, bl3, bl4, bl5, bl6, bl7,\n th, tl, i, j, h, l, a, b, c, d;\n\n var ah0 = hh[0],\n ah1 = hh[1],\n ah2 = hh[2],\n ah3 = hh[3],\n ah4 = hh[4],\n ah5 = hh[5],\n ah6 = hh[6],\n ah7 = hh[7],\n\n al0 = hl[0],\n al1 = hl[1],\n al2 = hl[2],\n al3 = hl[3],\n al4 = hl[4],\n al5 = hl[5],\n al6 = hl[6],\n al7 = hl[7];\n\n var pos = 0;\n while (n >= 128) {\n for (i = 0; i < 16; i++) {\n j = 8 * i + pos;\n wh[i] = (m[j+0] << 24) | (m[j+1] << 16) | (m[j+2] << 8) | m[j+3];\n wl[i] = (m[j+4] << 24) | (m[j+5] << 16) | (m[j+6] << 8) | m[j+7];\n }\n for (i = 0; i < 80; i++) {\n bh0 = ah0;\n bh1 = ah1;\n bh2 = ah2;\n bh3 = ah3;\n bh4 = ah4;\n bh5 = ah5;\n bh6 = ah6;\n bh7 = ah7;\n\n bl0 = al0;\n bl1 = al1;\n bl2 = al2;\n bl3 = al3;\n bl4 = al4;\n bl5 = al5;\n bl6 = al6;\n bl7 = al7;\n\n // add\n h = ah7;\n l = al7;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n // Sigma1\n h = ((ah4 >>> 14) | (al4 << (32-14))) ^ ((ah4 >>> 18) | (al4 << (32-18))) ^ ((al4 >>> (41-32)) | (ah4 << (32-(41-32))));\n l = ((al4 >>> 14) | (ah4 << (32-14))) ^ ((al4 >>> 18) | (ah4 << (32-18))) ^ ((ah4 >>> (41-32)) | (al4 << (32-(41-32))));\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // Ch\n h = (ah4 & ah5) ^ (~ah4 & ah6);\n l = (al4 & al5) ^ (~al4 & al6);\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // K\n h = K[i*2];\n l = K[i*2+1];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // w\n h = wh[i%16];\n l = wl[i%16];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n th = c & 0xffff | d << 16;\n tl = a & 0xffff | b << 16;\n\n // add\n h = th;\n l = tl;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n // Sigma0\n h = ((ah0 >>> 28) | (al0 << (32-28))) ^ ((al0 >>> (34-32)) | (ah0 << (32-(34-32)))) ^ ((al0 >>> (39-32)) | (ah0 << (32-(39-32))));\n l = ((al0 >>> 28) | (ah0 << (32-28))) ^ ((ah0 >>> (34-32)) | (al0 << (32-(34-32)))) ^ ((ah0 >>> (39-32)) | (al0 << (32-(39-32))));\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // Maj\n h = (ah0 & ah1) ^ (ah0 & ah2) ^ (ah1 & ah2);\n l = (al0 & al1) ^ (al0 & al2) ^ (al1 & al2);\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n bh7 = (c & 0xffff) | (d << 16);\n bl7 = (a & 0xffff) | (b << 16);\n\n // add\n h = bh3;\n l = bl3;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = th;\n l = tl;\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n bh3 = (c & 0xffff) | (d << 16);\n bl3 = (a & 0xffff) | (b << 16);\n\n ah1 = bh0;\n ah2 = bh1;\n ah3 = bh2;\n ah4 = bh3;\n ah5 = bh4;\n ah6 = bh5;\n ah7 = bh6;\n ah0 = bh7;\n\n al1 = bl0;\n al2 = bl1;\n al3 = bl2;\n al4 = bl3;\n al5 = bl4;\n al6 = bl5;\n al7 = bl6;\n al0 = bl7;\n\n if (i%16 === 15) {\n for (j = 0; j < 16; j++) {\n // add\n h = wh[j];\n l = wl[j];\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = wh[(j+9)%16];\n l = wl[(j+9)%16];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // sigma0\n th = wh[(j+1)%16];\n tl = wl[(j+1)%16];\n h = ((th >>> 1) | (tl << (32-1))) ^ ((th >>> 8) | (tl << (32-8))) ^ (th >>> 7);\n l = ((tl >>> 1) | (th << (32-1))) ^ ((tl >>> 8) | (th << (32-8))) ^ ((tl >>> 7) | (th << (32-7)));\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // sigma1\n th = wh[(j+14)%16];\n tl = wl[(j+14)%16];\n h = ((th >>> 19) | (tl << (32-19))) ^ ((tl >>> (61-32)) | (th << (32-(61-32)))) ^ (th >>> 6);\n l = ((tl >>> 19) | (th << (32-19))) ^ ((th >>> (61-32)) | (tl << (32-(61-32)))) ^ ((tl >>> 6) | (th << (32-6)));\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n wh[j] = (c & 0xffff) | (d << 16);\n wl[j] = (a & 0xffff) | (b << 16);\n }\n }\n }\n\n // add\n h = ah0;\n l = al0;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[0];\n l = hl[0];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[0] = ah0 = (c & 0xffff) | (d << 16);\n hl[0] = al0 = (a & 0xffff) | (b << 16);\n\n h = ah1;\n l = al1;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[1];\n l = hl[1];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[1] = ah1 = (c & 0xffff) | (d << 16);\n hl[1] = al1 = (a & 0xffff) | (b << 16);\n\n h = ah2;\n l = al2;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[2];\n l = hl[2];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[2] = ah2 = (c & 0xffff) | (d << 16);\n hl[2] = al2 = (a & 0xffff) | (b << 16);\n\n h = ah3;\n l = al3;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[3];\n l = hl[3];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[3] = ah3 = (c & 0xffff) | (d << 16);\n hl[3] = al3 = (a & 0xffff) | (b << 16);\n\n h = ah4;\n l = al4;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[4];\n l = hl[4];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[4] = ah4 = (c & 0xffff) | (d << 16);\n hl[4] = al4 = (a & 0xffff) | (b << 16);\n\n h = ah5;\n l = al5;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[5];\n l = hl[5];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[5] = ah5 = (c & 0xffff) | (d << 16);\n hl[5] = al5 = (a & 0xffff) | (b << 16);\n\n h = ah6;\n l = al6;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[6];\n l = hl[6];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[6] = ah6 = (c & 0xffff) | (d << 16);\n hl[6] = al6 = (a & 0xffff) | (b << 16);\n\n h = ah7;\n l = al7;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[7];\n l = hl[7];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[7] = ah7 = (c & 0xffff) | (d << 16);\n hl[7] = al7 = (a & 0xffff) | (b << 16);\n\n pos += 128;\n n -= 128;\n }\n\n return n;\n}\n\nfunction crypto_hash(out, m, n) {\n var hh = new Int32Array(8),\n hl = new Int32Array(8),\n x = new Uint8Array(256),\n i, b = n;\n\n hh[0] = 0x6a09e667;\n hh[1] = 0xbb67ae85;\n hh[2] = 0x3c6ef372;\n hh[3] = 0xa54ff53a;\n hh[4] = 0x510e527f;\n hh[5] = 0x9b05688c;\n hh[6] = 0x1f83d9ab;\n hh[7] = 0x5be0cd19;\n\n hl[0] = 0xf3bcc908;\n hl[1] = 0x84caa73b;\n hl[2] = 0xfe94f82b;\n hl[3] = 0x5f1d36f1;\n hl[4] = 0xade682d1;\n hl[5] = 0x2b3e6c1f;\n hl[6] = 0xfb41bd6b;\n hl[7] = 0x137e2179;\n\n crypto_hashblocks_hl(hh, hl, m, n);\n n %= 128;\n\n for (i = 0; i < n; i++) x[i] = m[b-n+i];\n x[n] = 128;\n\n n = 256-128*(n<112?1:0);\n x[n-9] = 0;\n ts64(x, n-8, (b / 0x20000000) | 0, b << 3);\n crypto_hashblocks_hl(hh, hl, x, n);\n\n for (i = 0; i < 8; i++) ts64(out, 8*i, hh[i], hl[i]);\n\n return 0;\n}\n\nfunction add(p, q) {\n var a = gf(), b = gf(), c = gf(),\n d = gf(), e = gf(), f = gf(),\n g = gf(), h = gf(), t = gf();\n\n Z(a, p[1], p[0]);\n Z(t, q[1], q[0]);\n M(a, a, t);\n A(b, p[0], p[1]);\n A(t, q[0], q[1]);\n M(b, b, t);\n M(c, p[3], q[3]);\n M(c, c, D2);\n M(d, p[2], q[2]);\n A(d, d, d);\n Z(e, b, a);\n Z(f, d, c);\n A(g, d, c);\n A(h, b, a);\n\n M(p[0], e, f);\n M(p[1], h, g);\n M(p[2], g, f);\n M(p[3], e, h);\n}\n\nfunction cswap(p, q, b) {\n var i;\n for (i = 0; i < 4; i++) {\n sel25519(p[i], q[i], b);\n }\n}\n\nfunction pack(r, p) {\n var tx = gf(), ty = gf(), zi = gf();\n inv25519(zi, p[2]);\n M(tx, p[0], zi);\n M(ty, p[1], zi);\n pack25519(r, ty);\n r[31] ^= par25519(tx) << 7;\n}\n\nfunction scalarmult(p, q, s) {\n var b, i;\n set25519(p[0], gf0);\n set25519(p[1], gf1);\n set25519(p[2], gf1);\n set25519(p[3], gf0);\n for (i = 255; i >= 0; --i) {\n b = (s[(i/8)|0] >> (i&7)) & 1;\n cswap(p, q, b);\n add(q, p);\n add(p, p);\n cswap(p, q, b);\n }\n}\n\nfunction scalarbase(p, s) {\n var q = [gf(), gf(), gf(), gf()];\n set25519(q[0], X);\n set25519(q[1], Y);\n set25519(q[2], gf1);\n M(q[3], X, Y);\n scalarmult(p, q, s);\n}\n\nfunction crypto_sign_keypair(pk, sk, seeded) {\n var d = new Uint8Array(64);\n var p = [gf(), gf(), gf(), gf()];\n var i;\n\n if (!seeded) randombytes(sk, 32);\n crypto_hash(d, sk, 32);\n d[0] &= 248;\n d[31] &= 127;\n d[31] |= 64;\n\n scalarbase(p, d);\n pack(pk, p);\n\n for (i = 0; i < 32; i++) sk[i+32] = pk[i];\n return 0;\n}\n\nvar L = new Float64Array([0xed, 0xd3, 0xf5, 0x5c, 0x1a, 0x63, 0x12, 0x58, 0xd6, 0x9c, 0xf7, 0xa2, 0xde, 0xf9, 0xde, 0x14, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x10]);\n\nfunction modL(r, x) {\n var carry, i, j, k;\n for (i = 63; i >= 32; --i) {\n carry = 0;\n for (j = i - 32, k = i - 12; j < k; ++j) {\n x[j] += carry - 16 * x[i] * L[j - (i - 32)];\n carry = Math.floor((x[j] + 128) / 256);\n x[j] -= carry * 256;\n }\n x[j] += carry;\n x[i] = 0;\n }\n carry = 0;\n for (j = 0; j < 32; j++) {\n x[j] += carry - (x[31] >> 4) * L[j];\n carry = x[j] >> 8;\n x[j] &= 255;\n }\n for (j = 0; j < 32; j++) x[j] -= carry * L[j];\n for (i = 0; i < 32; i++) {\n x[i+1] += x[i] >> 8;\n r[i] = x[i] & 255;\n }\n}\n\nfunction reduce(r) {\n var x = new Float64Array(64), i;\n for (i = 0; i < 64; i++) x[i] = r[i];\n for (i = 0; i < 64; i++) r[i] = 0;\n modL(r, x);\n}\n\n// Note: difference from C - smlen returned, not passed as argument.\nfunction crypto_sign(sm, m, n, sk) {\n var d = new Uint8Array(64), h = new Uint8Array(64), r = new Uint8Array(64);\n var i, j, x = new Float64Array(64);\n var p = [gf(), gf(), gf(), gf()];\n\n crypto_hash(d, sk, 32);\n d[0] &= 248;\n d[31] &= 127;\n d[31] |= 64;\n\n var smlen = n + 64;\n for (i = 0; i < n; i++) sm[64 + i] = m[i];\n for (i = 0; i < 32; i++) sm[32 + i] = d[32 + i];\n\n crypto_hash(r, sm.subarray(32), n+32);\n reduce(r);\n scalarbase(p, r);\n pack(sm, p);\n\n for (i = 32; i < 64; i++) sm[i] = sk[i];\n crypto_hash(h, sm, n + 64);\n reduce(h);\n\n for (i = 0; i < 64; i++) x[i] = 0;\n for (i = 0; i < 32; i++) x[i] = r[i];\n for (i = 0; i < 32; i++) {\n for (j = 0; j < 32; j++) {\n x[i+j] += h[i] * d[j];\n }\n }\n\n modL(sm.subarray(32), x);\n return smlen;\n}\n\nfunction unpackneg(r, p) {\n var t = gf(), chk = gf(), num = gf(),\n den = gf(), den2 = gf(), den4 = gf(),\n den6 = gf();\n\n set25519(r[2], gf1);\n unpack25519(r[1], p);\n S(num, r[1]);\n M(den, num, D);\n Z(num, num, r[2]);\n A(den, r[2], den);\n\n S(den2, den);\n S(den4, den2);\n M(den6, den4, den2);\n M(t, den6, num);\n M(t, t, den);\n\n pow2523(t, t);\n M(t, t, num);\n M(t, t, den);\n M(t, t, den);\n M(r[0], t, den);\n\n S(chk, r[0]);\n M(chk, chk, den);\n if (neq25519(chk, num)) M(r[0], r[0], I);\n\n S(chk, r[0]);\n M(chk, chk, den);\n if (neq25519(chk, num)) return -1;\n\n if (par25519(r[0]) === (p[31]>>7)) Z(r[0], gf0, r[0]);\n\n M(r[3], r[0], r[1]);\n return 0;\n}\n\nfunction crypto_sign_open(m, sm, n, pk) {\n var i;\n var t = new Uint8Array(32), h = new Uint8Array(64);\n var p = [gf(), gf(), gf(), gf()],\n q = [gf(), gf(), gf(), gf()];\n\n if (n < 64) return -1;\n\n if (unpackneg(q, pk)) return -1;\n\n for (i = 0; i < n; i++) m[i] = sm[i];\n for (i = 0; i < 32; i++) m[i+32] = pk[i];\n crypto_hash(h, m, n);\n reduce(h);\n scalarmult(p, q, h);\n\n scalarbase(q, sm.subarray(32));\n add(p, q);\n pack(t, p);\n\n n -= 64;\n if (crypto_verify_32(sm, 0, t, 0)) {\n for (i = 0; i < n; i++) m[i] = 0;\n return -1;\n }\n\n for (i = 0; i < n; i++) m[i] = sm[i + 64];\n return n;\n}\n\nvar crypto_secretbox_KEYBYTES = 32,\n crypto_secretbox_NONCEBYTES = 24,\n crypto_secretbox_ZEROBYTES = 32,\n crypto_secretbox_BOXZEROBYTES = 16,\n crypto_scalarmult_BYTES = 32,\n crypto_scalarmult_SCALARBYTES = 32,\n crypto_box_PUBLICKEYBYTES = 32,\n crypto_box_SECRETKEYBYTES = 32,\n crypto_box_BEFORENMBYTES = 32,\n crypto_box_NONCEBYTES = crypto_secretbox_NONCEBYTES,\n crypto_box_ZEROBYTES = crypto_secretbox_ZEROBYTES,\n crypto_box_BOXZEROBYTES = crypto_secretbox_BOXZEROBYTES,\n crypto_sign_BYTES = 64,\n crypto_sign_PUBLICKEYBYTES = 32,\n crypto_sign_SECRETKEYBYTES = 64,\n crypto_sign_SEEDBYTES = 32,\n crypto_hash_BYTES = 64;\n\nnacl.lowlevel = {\n crypto_core_hsalsa20: crypto_core_hsalsa20,\n crypto_stream_xor: crypto_stream_xor,\n crypto_stream: crypto_stream,\n crypto_stream_salsa20_xor: crypto_stream_salsa20_xor,\n crypto_stream_salsa20: crypto_stream_salsa20,\n crypto_onetimeauth: crypto_onetimeauth,\n crypto_onetimeauth_verify: crypto_onetimeauth_verify,\n crypto_verify_16: crypto_verify_16,\n crypto_verify_32: crypto_verify_32,\n crypto_secretbox: crypto_secretbox,\n crypto_secretbox_open: crypto_secretbox_open,\n crypto_scalarmult: crypto_scalarmult,\n crypto_scalarmult_base: crypto_scalarmult_base,\n crypto_box_beforenm: crypto_box_beforenm,\n crypto_box_afternm: crypto_box_afternm,\n crypto_box: crypto_box,\n crypto_box_open: crypto_box_open,\n crypto_box_keypair: crypto_box_keypair,\n crypto_hash: crypto_hash,\n crypto_sign: crypto_sign,\n crypto_sign_keypair: crypto_sign_keypair,\n crypto_sign_open: crypto_sign_open,\n\n crypto_secretbox_KEYBYTES: crypto_secretbox_KEYBYTES,\n crypto_secretbox_NONCEBYTES: crypto_secretbox_NONCEBYTES,\n crypto_secretbox_ZEROBYTES: crypto_secretbox_ZEROBYTES,\n crypto_secretbox_BOXZEROBYTES: crypto_secretbox_BOXZEROBYTES,\n crypto_scalarmult_BYTES: crypto_scalarmult_BYTES,\n crypto_scalarmult_SCALARBYTES: crypto_scalarmult_SCALARBYTES,\n crypto_box_PUBLICKEYBYTES: crypto_box_PUBLICKEYBYTES,\n crypto_box_SECRETKEYBYTES: crypto_box_SECRETKEYBYTES,\n crypto_box_BEFORENMBYTES: crypto_box_BEFORENMBYTES,\n crypto_box_NONCEBYTES: crypto_box_NONCEBYTES,\n crypto_box_ZEROBYTES: crypto_box_ZEROBYTES,\n crypto_box_BOXZEROBYTES: crypto_box_BOXZEROBYTES,\n crypto_sign_BYTES: crypto_sign_BYTES,\n crypto_sign_PUBLICKEYBYTES: crypto_sign_PUBLICKEYBYTES,\n crypto_sign_SECRETKEYBYTES: crypto_sign_SECRETKEYBYTES,\n crypto_sign_SEEDBYTES: crypto_sign_SEEDBYTES,\n crypto_hash_BYTES: crypto_hash_BYTES,\n\n gf: gf,\n D: D,\n L: L,\n pack25519: pack25519,\n unpack25519: unpack25519,\n M: M,\n A: A,\n S: S,\n Z: Z,\n pow2523: pow2523,\n add: add,\n set25519: set25519,\n modL: modL,\n scalarmult: scalarmult,\n scalarbase: scalarbase,\n};\n\n/* High-level API */\n\nfunction checkLengths(k, n) {\n if (k.length !== crypto_secretbox_KEYBYTES) throw new Error('bad key size');\n if (n.length !== crypto_secretbox_NONCEBYTES) throw new Error('bad nonce size');\n}\n\nfunction checkBoxLengths(pk, sk) {\n if (pk.length !== crypto_box_PUBLICKEYBYTES) throw new Error('bad public key size');\n if (sk.length !== crypto_box_SECRETKEYBYTES) throw new Error('bad secret key size');\n}\n\nfunction checkArrayTypes() {\n for (var i = 0; i < arguments.length; i++) {\n if (!(arguments[i] instanceof Uint8Array))\n throw new TypeError('unexpected type, use Uint8Array');\n }\n}\n\nfunction cleanup(arr) {\n for (var i = 0; i < arr.length; i++) arr[i] = 0;\n}\n\nnacl.randomBytes = function(n) {\n var b = new Uint8Array(n);\n randombytes(b, n);\n return b;\n};\n\nnacl.secretbox = function(msg, nonce, key) {\n checkArrayTypes(msg, nonce, key);\n checkLengths(key, nonce);\n var m = new Uint8Array(crypto_secretbox_ZEROBYTES + msg.length);\n var c = new Uint8Array(m.length);\n for (var i = 0; i < msg.length; i++) m[i+crypto_secretbox_ZEROBYTES] = msg[i];\n crypto_secretbox(c, m, m.length, nonce, key);\n return c.subarray(crypto_secretbox_BOXZEROBYTES);\n};\n\nnacl.secretbox.open = function(box, nonce, key) {\n checkArrayTypes(box, nonce, key);\n checkLengths(key, nonce);\n var c = new Uint8Array(crypto_secretbox_BOXZEROBYTES + box.length);\n var m = new Uint8Array(c.length);\n for (var i = 0; i < box.length; i++) c[i+crypto_secretbox_BOXZEROBYTES] = box[i];\n if (c.length < 32) return null;\n if (crypto_secretbox_open(m, c, c.length, nonce, key) !== 0) return null;\n return m.subarray(crypto_secretbox_ZEROBYTES);\n};\n\nnacl.secretbox.keyLength = crypto_secretbox_KEYBYTES;\nnacl.secretbox.nonceLength = crypto_secretbox_NONCEBYTES;\nnacl.secretbox.overheadLength = crypto_secretbox_BOXZEROBYTES;\n\nnacl.scalarMult = function(n, p) {\n checkArrayTypes(n, p);\n if (n.length !== crypto_scalarmult_SCALARBYTES) throw new Error('bad n size');\n if (p.length !== crypto_scalarmult_BYTES) throw new Error('bad p size');\n var q = new Uint8Array(crypto_scalarmult_BYTES);\n crypto_scalarmult(q, n, p);\n return q;\n};\n\nnacl.scalarMult.base = function(n) {\n checkArrayTypes(n);\n if (n.length !== crypto_scalarmult_SCALARBYTES) throw new Error('bad n size');\n var q = new Uint8Array(crypto_scalarmult_BYTES);\n crypto_scalarmult_base(q, n);\n return q;\n};\n\nnacl.scalarMult.scalarLength = crypto_scalarmult_SCALARBYTES;\nnacl.scalarMult.groupElementLength = crypto_scalarmult_BYTES;\n\nnacl.box = function(msg, nonce, publicKey, secretKey) {\n var k = nacl.box.before(publicKey, secretKey);\n return nacl.secretbox(msg, nonce, k);\n};\n\nnacl.box.before = function(publicKey, secretKey) {\n checkArrayTypes(publicKey, secretKey);\n checkBoxLengths(publicKey, secretKey);\n var k = new Uint8Array(crypto_box_BEFORENMBYTES);\n crypto_box_beforenm(k, publicKey, secretKey);\n return k;\n};\n\nnacl.box.after = nacl.secretbox;\n\nnacl.box.open = function(msg, nonce, publicKey, secretKey) {\n var k = nacl.box.before(publicKey, secretKey);\n return nacl.secretbox.open(msg, nonce, k);\n};\n\nnacl.box.open.after = nacl.secretbox.open;\n\nnacl.box.keyPair = function() {\n var pk = new Uint8Array(crypto_box_PUBLICKEYBYTES);\n var sk = new Uint8Array(crypto_box_SECRETKEYBYTES);\n crypto_box_keypair(pk, sk);\n return {publicKey: pk, secretKey: sk};\n};\n\nnacl.box.keyPair.fromSecretKey = function(secretKey) {\n checkArrayTypes(secretKey);\n if (secretKey.length !== crypto_box_SECRETKEYBYTES)\n throw new Error('bad secret key size');\n var pk = new Uint8Array(crypto_box_PUBLICKEYBYTES);\n crypto_scalarmult_base(pk, secretKey);\n return {publicKey: pk, secretKey: new Uint8Array(secretKey)};\n};\n\nnacl.box.publicKeyLength = crypto_box_PUBLICKEYBYTES;\nnacl.box.secretKeyLength = crypto_box_SECRETKEYBYTES;\nnacl.box.sharedKeyLength = crypto_box_BEFORENMBYTES;\nnacl.box.nonceLength = crypto_box_NONCEBYTES;\nnacl.box.overheadLength = nacl.secretbox.overheadLength;\n\nnacl.sign = function(msg, secretKey) {\n checkArrayTypes(msg, secretKey);\n if (secretKey.length !== crypto_sign_SECRETKEYBYTES)\n throw new Error('bad secret key size');\n var signedMsg = new Uint8Array(crypto_sign_BYTES+msg.length);\n crypto_sign(signedMsg, msg, msg.length, secretKey);\n return signedMsg;\n};\n\nnacl.sign.open = function(signedMsg, publicKey) {\n checkArrayTypes(signedMsg, publicKey);\n if (publicKey.length !== crypto_sign_PUBLICKEYBYTES)\n throw new Error('bad public key size');\n var tmp = new Uint8Array(signedMsg.length);\n var mlen = crypto_sign_open(tmp, signedMsg, signedMsg.length, publicKey);\n if (mlen < 0) return null;\n var m = new Uint8Array(mlen);\n for (var i = 0; i < m.length; i++) m[i] = tmp[i];\n return m;\n};\n\nnacl.sign.detached = function(msg, secretKey) {\n var signedMsg = nacl.sign(msg, secretKey);\n var sig = new Uint8Array(crypto_sign_BYTES);\n for (var i = 0; i < sig.length; i++) sig[i] = signedMsg[i];\n return sig;\n};\n\nnacl.sign.detached.verify = function(msg, sig, publicKey) {\n checkArrayTypes(msg, sig, publicKey);\n if (sig.length !== crypto_sign_BYTES)\n throw new Error('bad signature size');\n if (publicKey.length !== crypto_sign_PUBLICKEYBYTES)\n throw new Error('bad public key size');\n var sm = new Uint8Array(crypto_sign_BYTES + msg.length);\n var m = new Uint8Array(crypto_sign_BYTES + msg.length);\n var i;\n for (i = 0; i < crypto_sign_BYTES; i++) sm[i] = sig[i];\n for (i = 0; i < msg.length; i++) sm[i+crypto_sign_BYTES] = msg[i];\n return (crypto_sign_open(m, sm, sm.length, publicKey) >= 0);\n};\n\nnacl.sign.keyPair = function() {\n var pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);\n var sk = new Uint8Array(crypto_sign_SECRETKEYBYTES);\n crypto_sign_keypair(pk, sk);\n return {publicKey: pk, secretKey: sk};\n};\n\nnacl.sign.keyPair.fromSecretKey = function(secretKey) {\n checkArrayTypes(secretKey);\n if (secretKey.length !== crypto_sign_SECRETKEYBYTES)\n throw new Error('bad secret key size');\n var pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);\n for (var i = 0; i < pk.length; i++) pk[i] = secretKey[32+i];\n return {publicKey: pk, secretKey: new Uint8Array(secretKey)};\n};\n\nnacl.sign.keyPair.fromSeed = function(seed) {\n checkArrayTypes(seed);\n if (seed.length !== crypto_sign_SEEDBYTES)\n throw new Error('bad seed size');\n var pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);\n var sk = new Uint8Array(crypto_sign_SECRETKEYBYTES);\n for (var i = 0; i < 32; i++) sk[i] = seed[i];\n crypto_sign_keypair(pk, sk, true);\n return {publicKey: pk, secretKey: sk};\n};\n\nnacl.sign.publicKeyLength = crypto_sign_PUBLICKEYBYTES;\nnacl.sign.secretKeyLength = crypto_sign_SECRETKEYBYTES;\nnacl.sign.seedLength = crypto_sign_SEEDBYTES;\nnacl.sign.signatureLength = crypto_sign_BYTES;\n\nnacl.hash = function(msg) {\n checkArrayTypes(msg);\n var h = new Uint8Array(crypto_hash_BYTES);\n crypto_hash(h, msg, msg.length);\n return h;\n};\n\nnacl.hash.hashLength = crypto_hash_BYTES;\n\nnacl.verify = function(x, y) {\n checkArrayTypes(x, y);\n // Zero length arguments are considered not equal.\n if (x.length === 0 || y.length === 0) return false;\n if (x.length !== y.length) return false;\n return (vn(x, 0, y, 0, x.length) === 0) ? true : false;\n};\n\nnacl.setPRNG = function(fn) {\n randombytes = fn;\n};\n\n(function() {\n // Initialize PRNG if environment provides CSPRNG.\n // If not, methods calling randombytes will throw.\n var crypto = typeof self !== 'undefined' ? (self.crypto || self.msCrypto) : null;\n if (crypto && crypto.getRandomValues) {\n // Browsers.\n var QUOTA = 65536;\n nacl.setPRNG(function(x, n) {\n var i, v = new Uint8Array(n);\n for (i = 0; i < n; i += QUOTA) {\n crypto.getRandomValues(v.subarray(i, i + Math.min(n - i, QUOTA)));\n }\n for (i = 0; i < n; i++) x[i] = v[i];\n cleanup(v);\n });\n } else if (typeof require !== 'undefined') {\n // Node.js.\n crypto = require('crypto');\n if (crypto && crypto.randomBytes) {\n nacl.setPRNG(function(x, n) {\n var i, v = crypto.randomBytes(n);\n for (i = 0; i < n; i++) x[i] = v[i];\n cleanup(v);\n });\n }\n }\n})();\n\n})(typeof module !== 'undefined' && module.exports ? module.exports : (self.nacl = self.nacl || {}));\n","module.exports = require('./pusher-with-encryption').default;\n","/* (ignored) */","import ScriptReceiver from './script_receiver';\n\n/** Builds receivers for JSONP and Script requests.\n *\n * Each receiver is an object with following fields:\n * - number - unique (for the factory instance), numerical id of the receiver\n * - id - a string ID that can be used in DOM attributes\n * - name - name of the function triggering the receiver\n * - callback - callback function\n *\n * Receivers are triggered only once, on the first callback call.\n *\n * Receivers can be called by their name or by accessing factory object\n * by the number key.\n *\n * @param {String} prefix the prefix used in ids\n * @param {String} name the name of the object\n */\nexport class ScriptReceiverFactory {\n lastId: number;\n prefix: string;\n name: string;\n\n constructor(prefix: string, name: string) {\n this.lastId = 0;\n this.prefix = prefix;\n this.name = name;\n }\n\n create(callback: Function): ScriptReceiver {\n this.lastId++;\n\n var number = this.lastId;\n var id = this.prefix + number;\n var name = this.name + '[' + number + ']';\n\n var called = false;\n var callbackWrapper = function() {\n if (!called) {\n callback.apply(null, arguments);\n called = true;\n }\n };\n\n this[number] = callbackWrapper;\n return { number: number, id: id, name: name, callback: callbackWrapper };\n }\n\n remove(receiver: ScriptReceiver) {\n delete this[receiver.number];\n }\n}\n\nexport var ScriptReceivers = new ScriptReceiverFactory(\n '_pusher_script_',\n 'Pusher.ScriptReceivers'\n);\n","import {\n ChannelAuthorizationOptions,\n UserAuthenticationOptions\n} from './auth/options';\nimport { AuthTransport } from './config';\n\nexport interface DefaultConfig {\n VERSION: string;\n PROTOCOL: number;\n wsPort: number;\n wssPort: number;\n wsPath: string;\n httpHost: string;\n httpPort: number;\n httpsPort: number;\n httpPath: string;\n stats_host: string;\n authEndpoint: string;\n authTransport: AuthTransport;\n activityTimeout: number;\n pongTimeout: number;\n unavailableTimeout: number;\n userAuthentication: UserAuthenticationOptions;\n channelAuthorization: ChannelAuthorizationOptions;\n\n cdn_http?: string;\n cdn_https?: string;\n dependency_suffix?: string;\n}\n\nvar Defaults: DefaultConfig = {\n VERSION: VERSION,\n PROTOCOL: 7,\n\n wsPort: 80,\n wssPort: 443,\n wsPath: '',\n // DEPRECATED: SockJS fallback parameters\n httpHost: 'sockjs.pusher.com',\n httpPort: 80,\n httpsPort: 443,\n httpPath: '/pusher',\n // DEPRECATED: Stats\n stats_host: 'stats.pusher.com',\n // DEPRECATED: Other settings\n authEndpoint: '/pusher/auth',\n authTransport: 'ajax',\n activityTimeout: 120000,\n pongTimeout: 30000,\n unavailableTimeout: 10000,\n userAuthentication: {\n endpoint: '/pusher/user-auth',\n transport: 'ajax'\n },\n channelAuthorization: {\n endpoint: '/pusher/auth',\n transport: 'ajax'\n },\n\n // CDN configuration\n cdn_http: CDN_HTTP,\n cdn_https: CDN_HTTPS,\n dependency_suffix: DEPENDENCY_SUFFIX\n};\n\nexport default Defaults;\n","import {\n ScriptReceivers,\n ScriptReceiverFactory\n} from './script_receiver_factory';\nimport Runtime from 'runtime';\nimport ScriptRequest from './script_request';\n\n/** Handles loading dependency files.\n *\n * Dependency loaders don't remember whether a resource has been loaded or\n * not. It is caller's responsibility to make sure the resource is not loaded\n * twice. This is because it's impossible to detect resource loading status\n * without knowing its content.\n *\n * Options:\n * - cdn_http - url to HTTP CND\n * - cdn_https - url to HTTPS CDN\n * - version - version of pusher-js\n * - suffix - suffix appended to all names of dependency files\n *\n * @param {Object} options\n */\nexport default class DependencyLoader {\n options: any;\n receivers: ScriptReceiverFactory;\n loading: any;\n\n constructor(options: any) {\n this.options = options;\n this.receivers = options.receivers || ScriptReceivers;\n this.loading = {};\n }\n\n /** Loads the dependency from CDN.\n *\n * @param {String} name\n * @param {Function} callback\n */\n load(name: string, options: any, callback: Function) {\n var self = this;\n\n if (self.loading[name] && self.loading[name].length > 0) {\n self.loading[name].push(callback);\n } else {\n self.loading[name] = [callback];\n\n var request = Runtime.createScriptRequest(self.getPath(name, options));\n var receiver = self.receivers.create(function(error) {\n self.receivers.remove(receiver);\n\n if (self.loading[name]) {\n var callbacks = self.loading[name];\n delete self.loading[name];\n\n var successCallback = function(wasSuccessful) {\n if (!wasSuccessful) {\n request.cleanup();\n }\n };\n for (var i = 0; i < callbacks.length; i++) {\n callbacks[i](error, successCallback);\n }\n }\n });\n request.send(receiver);\n }\n }\n\n /** Returns a root URL for pusher-js CDN.\n *\n * @returns {String}\n */\n getRoot(options: any): string {\n var cdn;\n var protocol = Runtime.getDocument().location.protocol;\n if ((options && options.useTLS) || protocol === 'https:') {\n cdn = this.options.cdn_https;\n } else {\n cdn = this.options.cdn_http;\n }\n // make sure there are no double slashes\n return cdn.replace(/\\/*$/, '') + '/' + this.options.version;\n }\n\n /** Returns a full path to a dependency file.\n *\n * @param {String} name\n * @returns {String}\n */\n getPath(name: string, options: any): string {\n return this.getRoot(options) + '/' + name + this.options.suffix + '.js';\n }\n}\n","import { ScriptReceiverFactory } from './script_receiver_factory';\nimport Defaults from 'core/defaults';\nimport DependencyLoader from './dependency_loader';\n\nexport var DependenciesReceivers = new ScriptReceiverFactory(\n '_pusher_dependencies',\n 'Pusher.DependenciesReceivers'\n);\n\nexport var Dependencies = new DependencyLoader({\n cdn_http: Defaults.cdn_http,\n cdn_https: Defaults.cdn_https,\n version: Defaults.VERSION,\n suffix: Defaults.dependency_suffix,\n receivers: DependenciesReceivers\n});\n","/**\n * A place to store help URLs for error messages etc\n */\n\nconst urlStore = {\n baseUrl: 'https://pusher.com',\n urls: {\n authenticationEndpoint: {\n path: '/docs/channels/server_api/authenticating_users'\n },\n authorizationEndpoint: {\n path: '/docs/channels/server_api/authorizing-users/'\n },\n javascriptQuickStart: {\n path: '/docs/javascript_quick_start'\n },\n triggeringClientEvents: {\n path: '/docs/client_api_guide/client_events#trigger-events'\n },\n encryptedChannelSupport: {\n fullUrl:\n 'https://github.com/pusher/pusher-js/tree/cc491015371a4bde5743d1c87a0fbac0feb53195#encrypted-channel-support'\n }\n }\n};\n\n/** Builds a consistent string with links to pusher documentation\n *\n * @param {string} key - relevant key in the url_store.urls object\n * @return {string} suffix string to append to log message\n */\nconst buildLogSuffix = function(key: string): string {\n const urlPrefix = 'See:';\n const urlObj = urlStore.urls[key];\n if (!urlObj) return '';\n\n let url;\n if (urlObj.fullUrl) {\n url = urlObj.fullUrl;\n } else if (urlObj.path) {\n url = urlStore.baseUrl + urlObj.path;\n }\n\n if (!url) return '';\n return `${urlPrefix} ${url}`;\n};\n\nexport default { buildLogSuffix };\n","export enum AuthRequestType {\n UserAuthentication = 'user-authentication',\n ChannelAuthorization = 'channel-authorization'\n}\n\nexport interface ChannelAuthorizationData {\n auth: string;\n channel_data?: string;\n shared_secret?: string;\n}\n\nexport type ChannelAuthorizationCallback = (\n error: Error | null,\n authData: ChannelAuthorizationData | null\n) => void;\n\nexport interface ChannelAuthorizationRequestParams {\n socketId: string;\n channelName: string;\n}\n\nexport interface ChannelAuthorizationHandler {\n (\n params: ChannelAuthorizationRequestParams,\n callback: ChannelAuthorizationCallback\n ): void;\n}\n\nexport interface UserAuthenticationData {\n auth: string;\n user_data: string;\n}\n\nexport type UserAuthenticationCallback = (\n error: Error | null,\n authData: UserAuthenticationData | null\n) => void;\n\nexport interface UserAuthenticationRequestParams {\n socketId: string;\n}\n\nexport interface UserAuthenticationHandler {\n (\n params: UserAuthenticationRequestParams,\n callback: UserAuthenticationCallback\n ): void;\n}\n\nexport type AuthTransportCallback =\n | ChannelAuthorizationCallback\n | UserAuthenticationCallback;\n\nexport interface AuthOptionsT {\n transport: 'ajax' | 'jsonp';\n endpoint: string;\n params?: any;\n headers?: any;\n paramsProvider?: () => any;\n headersProvider?: () => any;\n customHandler?: AuthHandler;\n}\n\nexport declare type UserAuthenticationOptions = AuthOptionsT<\n UserAuthenticationHandler\n>;\nexport declare type ChannelAuthorizationOptions = AuthOptionsT<\n ChannelAuthorizationHandler\n>;\n\nexport interface InternalAuthOptions {\n transport: 'ajax' | 'jsonp';\n endpoint: string;\n params?: any;\n headers?: any;\n paramsProvider?: () => any;\n headersProvider?: () => any;\n}\n","/** Error classes used throughout the library. */\n// https://github.com/Microsoft/TypeScript-wiki/blob/master/Breaking-Changes.md#extending-built-ins-like-error-array-and-map-may-no-longer-work\nexport class BadEventName extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\nexport class BadChannelName extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\nexport class RequestTimedOut extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class TransportPriorityTooLow extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class TransportClosed extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class UnsupportedFeature extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class UnsupportedTransport extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class UnsupportedStrategy extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class HTTPAuthError extends Error {\n status: number;\n constructor(status: number, msg?: string) {\n super(msg);\n this.status = status;\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n","import TimelineSender from 'core/timeline/timeline_sender';\nimport * as Collections from 'core/utils/collections';\nimport Util from 'core/util';\nimport Runtime from 'runtime';\nimport { AuthTransport } from 'core/auth/auth_transports';\nimport AbstractRuntime from 'runtimes/interface';\nimport UrlStore from 'core/utils/url_store';\nimport {\n AuthRequestType,\n AuthTransportCallback,\n InternalAuthOptions\n} from 'core/auth/options';\nimport { HTTPAuthError } from 'core/errors';\n\nconst ajax: AuthTransport = function(\n context: AbstractRuntime,\n query: string,\n authOptions: InternalAuthOptions,\n authRequestType: AuthRequestType,\n callback: AuthTransportCallback\n) {\n const xhr = Runtime.createXHR();\n xhr.open('POST', authOptions.endpoint, true);\n\n // add request headers\n xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');\n for (var headerName in authOptions.headers) {\n xhr.setRequestHeader(headerName, authOptions.headers[headerName]);\n }\n if (authOptions.headersProvider != null) {\n let dynamicHeaders = authOptions.headersProvider();\n for (var headerName in dynamicHeaders) {\n xhr.setRequestHeader(headerName, dynamicHeaders[headerName]);\n }\n }\n\n xhr.onreadystatechange = function() {\n if (xhr.readyState === 4) {\n if (xhr.status === 200) {\n let data;\n let parsed = false;\n\n try {\n data = JSON.parse(xhr.responseText);\n parsed = true;\n } catch (e) {\n callback(\n new HTTPAuthError(\n 200,\n `JSON returned from ${authRequestType.toString()} endpoint was invalid, yet status code was 200. Data was: ${\n xhr.responseText\n }`\n ),\n null\n );\n }\n\n if (parsed) {\n // prevents double execution.\n callback(null, data);\n }\n } else {\n let suffix = '';\n switch (authRequestType) {\n case AuthRequestType.UserAuthentication:\n suffix = UrlStore.buildLogSuffix('authenticationEndpoint');\n break;\n case AuthRequestType.ChannelAuthorization:\n suffix = `Clients must be authorized to join private or presence channels. ${UrlStore.buildLogSuffix(\n 'authorizationEndpoint'\n )}`;\n break;\n }\n callback(\n new HTTPAuthError(\n xhr.status,\n `Unable to retrieve auth string from ${authRequestType.toString()} endpoint - ` +\n `received status: ${xhr.status} from ${authOptions.endpoint}. ${suffix}`\n ),\n null\n );\n }\n }\n };\n\n xhr.send(query);\n return xhr;\n};\n\nexport default ajax;\n","export default function encode(s: any): string {\n return btoa(utob(s));\n}\n\nvar fromCharCode = String.fromCharCode;\n\nvar b64chars =\n 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';\nvar b64tab = {};\n\nfor (var i = 0, l = b64chars.length; i < l; i++) {\n b64tab[b64chars.charAt(i)] = i;\n}\n\nvar cb_utob = function(c) {\n var cc = c.charCodeAt(0);\n return cc < 0x80\n ? c\n : cc < 0x800\n ? fromCharCode(0xc0 | (cc >>> 6)) + fromCharCode(0x80 | (cc & 0x3f))\n : fromCharCode(0xe0 | ((cc >>> 12) & 0x0f)) +\n fromCharCode(0x80 | ((cc >>> 6) & 0x3f)) +\n fromCharCode(0x80 | (cc & 0x3f));\n};\n\nvar utob = function(u) {\n return u.replace(/[^\\x00-\\x7F]/g, cb_utob);\n};\n\nvar cb_encode = function(ccc) {\n var padlen = [0, 2, 1][ccc.length % 3];\n var ord =\n (ccc.charCodeAt(0) << 16) |\n ((ccc.length > 1 ? ccc.charCodeAt(1) : 0) << 8) |\n (ccc.length > 2 ? ccc.charCodeAt(2) : 0);\n var chars = [\n b64chars.charAt(ord >>> 18),\n b64chars.charAt((ord >>> 12) & 63),\n padlen >= 2 ? '=' : b64chars.charAt((ord >>> 6) & 63),\n padlen >= 1 ? '=' : b64chars.charAt(ord & 63)\n ];\n return chars.join('');\n};\n\nvar btoa =\n global.btoa ||\n function(b) {\n return b.replace(/[\\s\\S]{1,3}/g, cb_encode);\n };\n","import TimedCallback from './timed_callback';\nimport { Delay, Scheduler, Canceller } from './scheduling';\n\nabstract class Timer {\n protected clear: Canceller;\n protected timer: number | void;\n\n constructor(\n set: Scheduler,\n clear: Canceller,\n delay: Delay,\n callback: TimedCallback\n ) {\n this.clear = clear;\n this.timer = set(() => {\n if (this.timer) {\n this.timer = callback(this.timer);\n }\n }, delay);\n }\n\n /** Returns whether the timer is still running.\n *\n * @return {Boolean}\n */\n isRunning(): boolean {\n return this.timer !== null;\n }\n\n /** Aborts a timer when it's running. */\n ensureAborted() {\n if (this.timer) {\n this.clear(this.timer);\n this.timer = null;\n }\n }\n}\n\nexport default Timer;\n","import Timer from './abstract_timer';\nimport TimedCallback from './timed_callback';\nimport { Delay } from './scheduling';\n\n// We need to bind clear functions this way to avoid exceptions on IE8\nfunction clearTimeout(timer) {\n global.clearTimeout(timer);\n}\nfunction clearInterval(timer) {\n global.clearInterval(timer);\n}\n\n/** Cross-browser compatible one-off timer abstraction.\n *\n * @param {Number} delay\n * @param {Function} callback\n */\nexport class OneOffTimer extends Timer {\n constructor(delay: Delay, callback: TimedCallback) {\n super(setTimeout, clearTimeout, delay, function(timer) {\n callback();\n return null;\n });\n }\n}\n\n/** Cross-browser compatible periodic timer abstraction.\n *\n * @param {Number} delay\n * @param {Function} callback\n */\nexport class PeriodicTimer extends Timer {\n constructor(delay: Delay, callback: TimedCallback) {\n super(setInterval, clearInterval, delay, function(timer) {\n callback();\n return timer;\n });\n }\n}\n","import * as Collections from './utils/collections';\nimport TimedCallback from './utils/timers/timed_callback';\nimport { OneOffTimer, PeriodicTimer } from './utils/timers';\n\nvar Util = {\n now(): number {\n if (Date.now) {\n return Date.now();\n } else {\n return new Date().valueOf();\n }\n },\n\n defer(callback: TimedCallback): OneOffTimer {\n return new OneOffTimer(0, callback);\n },\n\n /** Builds a function that will proxy a method call to its first argument.\n *\n * Allows partial application of arguments, so additional arguments are\n * prepended to the argument list.\n *\n * @param {String} name method name\n * @return {Function} proxy function\n */\n method(name: string, ...args: any[]): Function {\n var boundArguments = Array.prototype.slice.call(arguments, 1);\n return function(object) {\n return object[name].apply(object, boundArguments.concat(arguments));\n };\n }\n};\n\nexport default Util;\n","import base64encode from '../base64';\nimport Util from '../util';\n\n/** Merges multiple objects into the target argument.\n *\n * For properties that are plain Objects, performs a deep-merge. For the\n * rest it just copies the value of the property.\n *\n * To extend prototypes use it as following:\n * Pusher.Util.extend(Target.prototype, Base.prototype)\n *\n * You can also use it to merge objects without altering them:\n * Pusher.Util.extend({}, object1, object2)\n *\n * @param {Object} target\n * @return {Object} the target argument\n */\nexport function extend(target: any, ...sources: any[]): T {\n for (var i = 0; i < sources.length; i++) {\n var extensions = sources[i];\n for (var property in extensions) {\n if (\n extensions[property] &&\n extensions[property].constructor &&\n extensions[property].constructor === Object\n ) {\n target[property] = extend(target[property] || {}, extensions[property]);\n } else {\n target[property] = extensions[property];\n }\n }\n }\n return target;\n}\n\nexport function stringify(): string {\n var m = ['Pusher'];\n for (var i = 0; i < arguments.length; i++) {\n if (typeof arguments[i] === 'string') {\n m.push(arguments[i]);\n } else {\n m.push(safeJSONStringify(arguments[i]));\n }\n }\n return m.join(' : ');\n}\n\nexport function arrayIndexOf(array: any[], item: any): number {\n // MSIE doesn't have array.indexOf\n var nativeIndexOf = Array.prototype.indexOf;\n if (array === null) {\n return -1;\n }\n if (nativeIndexOf && array.indexOf === nativeIndexOf) {\n return array.indexOf(item);\n }\n for (var i = 0, l = array.length; i < l; i++) {\n if (array[i] === item) {\n return i;\n }\n }\n return -1;\n}\n\n/** Applies a function f to all properties of an object.\n *\n * Function f gets 3 arguments passed:\n * - element from the object\n * - key of the element\n * - reference to the object\n *\n * @param {Object} object\n * @param {Function} f\n */\nexport function objectApply(object: any, f: Function) {\n for (var key in object) {\n if (Object.prototype.hasOwnProperty.call(object, key)) {\n f(object[key], key, object);\n }\n }\n}\n\n/** Return a list of objects own proerty keys\n *\n * @param {Object} object\n * @returns {Array}\n */\nexport function keys(object: any): string[] {\n var keys = [];\n objectApply(object, function(_, key) {\n keys.push(key);\n });\n return keys;\n}\n\n/** Return a list of object's own property values\n *\n * @param {Object} object\n * @returns {Array}\n */\nexport function values(object: any): any[] {\n var values = [];\n objectApply(object, function(value) {\n values.push(value);\n });\n return values;\n}\n\n/** Applies a function f to all elements of an array.\n *\n * Function f gets 3 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function apply(array: any[], f: Function, context?: any) {\n for (var i = 0; i < array.length; i++) {\n f.call(context || global, array[i], i, array);\n }\n}\n\n/** Maps all elements of the array and returns the result.\n *\n * Function f gets 4 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n * - reference to the destination array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function map(array: any[], f: Function): any[] {\n var result = [];\n for (var i = 0; i < array.length; i++) {\n result.push(f(array[i], i, array, result));\n }\n return result;\n}\n\n/** Maps all elements of the object and returns the result.\n *\n * Function f gets 4 arguments passed:\n * - element from the object\n * - key of the element\n * - reference to the source object\n * - reference to the destination object\n *\n * @param {Object} object\n * @param {Function} f\n */\nexport function mapObject(object: any, f: Function): any {\n var result = {};\n objectApply(object, function(value, key) {\n result[key] = f(value);\n });\n return result;\n}\n\n/** Filters elements of the array using a test function.\n *\n * Function test gets 4 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n * - reference to the destination array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function filter(array: any[], test: Function): any[] {\n test =\n test ||\n function(value) {\n return !!value;\n };\n\n var result = [];\n for (var i = 0; i < array.length; i++) {\n if (test(array[i], i, array, result)) {\n result.push(array[i]);\n }\n }\n return result;\n}\n\n/** Filters properties of the object using a test function.\n *\n * Function test gets 4 arguments passed:\n * - element from the object\n * - key of the element\n * - reference to the source object\n * - reference to the destination object\n *\n * @param {Object} object\n * @param {Function} f\n */\nexport function filterObject(object: Object, test: Function) {\n var result = {};\n objectApply(object, function(value, key) {\n if ((test && test(value, key, object, result)) || Boolean(value)) {\n result[key] = value;\n }\n });\n return result;\n}\n\n/** Flattens an object into a two-dimensional array.\n *\n * @param {Object} object\n * @return {Array} resulting array of [key, value] pairs\n */\nexport function flatten(object: Object): any[] {\n var result = [];\n objectApply(object, function(value, key) {\n result.push([key, value]);\n });\n return result;\n}\n\n/** Checks whether any element of the array passes the test.\n *\n * Function test gets 3 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function any(array: any[], test: Function): boolean {\n for (var i = 0; i < array.length; i++) {\n if (test(array[i], i, array)) {\n return true;\n }\n }\n return false;\n}\n\n/** Checks whether all elements of the array pass the test.\n *\n * Function test gets 3 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function all(array: any[], test: Function): boolean {\n for (var i = 0; i < array.length; i++) {\n if (!test(array[i], i, array)) {\n return false;\n }\n }\n return true;\n}\n\nexport function encodeParamsObject(data): string {\n return mapObject(data, function(value) {\n if (typeof value === 'object') {\n value = safeJSONStringify(value);\n }\n return encodeURIComponent(base64encode(value.toString()));\n });\n}\n\nexport function buildQueryString(data: any): string {\n var params = filterObject(data, function(value) {\n return value !== undefined;\n });\n\n var query = map(\n flatten(encodeParamsObject(params)),\n Util.method('join', '=')\n ).join('&');\n\n return query;\n}\n\n/**\n * See https://github.com/douglascrockford/JSON-js/blob/master/cycle.js\n *\n * Remove circular references from an object. Required for JSON.stringify in\n * React Native, which tends to blow up a lot.\n *\n * @param {any} object\n * @return {any} Decycled object\n */\nexport function decycleObject(object: any): any {\n var objects = [],\n paths = [];\n\n return (function derez(value, path) {\n var i, name, nu;\n\n switch (typeof value) {\n case 'object':\n if (!value) {\n return null;\n }\n for (i = 0; i < objects.length; i += 1) {\n if (objects[i] === value) {\n return { $ref: paths[i] };\n }\n }\n\n objects.push(value);\n paths.push(path);\n\n if (Object.prototype.toString.apply(value) === '[object Array]') {\n nu = [];\n for (i = 0; i < value.length; i += 1) {\n nu[i] = derez(value[i], path + '[' + i + ']');\n }\n } else {\n nu = {};\n for (name in value) {\n if (Object.prototype.hasOwnProperty.call(value, name)) {\n nu[name] = derez(\n value[name],\n path + '[' + JSON.stringify(name) + ']'\n );\n }\n }\n }\n return nu;\n case 'number':\n case 'string':\n case 'boolean':\n return value;\n }\n })(object, '$');\n}\n\n/**\n * Provides a cross-browser and cross-platform way to safely stringify objects\n * into JSON. This is particularly necessary for ReactNative, where circular JSON\n * structures throw an exception.\n *\n * @param {any} source The object to stringify\n * @return {string} The serialized output.\n */\nexport function safeJSONStringify(source: any): string {\n try {\n return JSON.stringify(source);\n } catch (e) {\n return JSON.stringify(decycleObject(source));\n }\n}\n","import { stringify } from './utils/collections';\nimport Pusher from './pusher';\n\nclass Logger {\n debug(...args: any[]) {\n this.log(this.globalLog, args);\n }\n\n warn(...args: any[]) {\n this.log(this.globalLogWarn, args);\n }\n\n error(...args: any[]) {\n this.log(this.globalLogError, args);\n }\n\n private globalLog = (message: string) => {\n if (global.console && global.console.log) {\n global.console.log(message);\n }\n };\n\n private globalLogWarn(message: string) {\n if (global.console && global.console.warn) {\n global.console.warn(message);\n } else {\n this.globalLog(message);\n }\n }\n\n private globalLogError(message: string) {\n if (global.console && global.console.error) {\n global.console.error(message);\n } else {\n this.globalLogWarn(message);\n }\n }\n\n private log(\n defaultLoggingFunction: (message: string) => void,\n ...args: any[]\n ) {\n var message = stringify.apply(this, arguments);\n if (Pusher.log) {\n Pusher.log(message);\n } else if (Pusher.logToConsole) {\n const log = defaultLoggingFunction.bind(this);\n log(message);\n }\n }\n}\n\nexport default new Logger();\n","import Browser from '../browser';\nimport Logger from 'core/logger';\nimport JSONPRequest from '../dom/jsonp_request';\nimport { ScriptReceivers } from '../dom/script_receiver_factory';\nimport { AuthTransport } from 'core/auth/auth_transports';\nimport {\n AuthRequestType,\n AuthTransportCallback,\n InternalAuthOptions\n} from 'core/auth/options';\n\nvar jsonp: AuthTransport = function(\n context: Browser,\n query: string,\n authOptions: InternalAuthOptions,\n authRequestType: AuthRequestType,\n callback: AuthTransportCallback\n) {\n if (\n authOptions.headers !== undefined ||\n authOptions.headersProvider != null\n ) {\n Logger.warn(\n `To send headers with the ${authRequestType.toString()} request, you must use AJAX, rather than JSONP.`\n );\n }\n\n var callbackName = context.nextAuthCallbackID.toString();\n context.nextAuthCallbackID++;\n\n var document = context.getDocument();\n var script = document.createElement('script');\n // Hacked wrapper.\n context.auth_callbacks[callbackName] = function(data) {\n callback(null, data);\n };\n\n var callback_name = \"Pusher.auth_callbacks['\" + callbackName + \"']\";\n script.src =\n authOptions.endpoint +\n '?callback=' +\n encodeURIComponent(callback_name) +\n '&' +\n query;\n\n var head =\n document.getElementsByTagName('head')[0] || document.documentElement;\n head.insertBefore(script, head.firstChild);\n};\n\nexport default jsonp;\n","import ScriptReceiver from './script_receiver';\n\n/** Sends a generic HTTP GET request using a script tag.\n *\n * By constructing URL in a specific way, it can be used for loading\n * JavaScript resources or JSONP requests. It can notify about errors, but\n * only in certain environments. Please take care of monitoring the state of\n * the request yourself.\n *\n * @param {String} src\n */\nexport default class ScriptRequest {\n src: string;\n script: any;\n errorScript: any;\n\n constructor(src: string) {\n this.src = src;\n }\n\n send(receiver: ScriptReceiver) {\n var self = this;\n var errorString = 'Error loading ' + self.src;\n\n self.script = document.createElement('script');\n self.script.id = receiver.id;\n self.script.src = self.src;\n self.script.type = 'text/javascript';\n self.script.charset = 'UTF-8';\n\n if (self.script.addEventListener) {\n self.script.onerror = function() {\n receiver.callback(errorString);\n };\n self.script.onload = function() {\n receiver.callback(null);\n };\n } else {\n self.script.onreadystatechange = function() {\n if (\n self.script.readyState === 'loaded' ||\n self.script.readyState === 'complete'\n ) {\n receiver.callback(null);\n }\n };\n }\n\n // Opera<11.6 hack for missing onerror callback\n if (\n self.script.async === undefined &&\n (document).attachEvent &&\n /opera/i.test(navigator.userAgent)\n ) {\n self.errorScript = document.createElement('script');\n self.errorScript.id = receiver.id + '_error';\n self.errorScript.text = receiver.name + \"('\" + errorString + \"');\";\n self.script.async = self.errorScript.async = false;\n } else {\n self.script.async = true;\n }\n\n var head = document.getElementsByTagName('head')[0];\n head.insertBefore(self.script, head.firstChild);\n if (self.errorScript) {\n head.insertBefore(self.errorScript, self.script.nextSibling);\n }\n }\n\n /** Cleans up the DOM remains of the script request. */\n cleanup() {\n if (this.script) {\n this.script.onload = this.script.onerror = null;\n this.script.onreadystatechange = null;\n }\n if (this.script && this.script.parentNode) {\n this.script.parentNode.removeChild(this.script);\n }\n if (this.errorScript && this.errorScript.parentNode) {\n this.errorScript.parentNode.removeChild(this.errorScript);\n }\n this.script = null;\n this.errorScript = null;\n }\n}\n","import ScriptReceiver from './script_receiver';\nimport ScriptRequest from './script_request';\nimport * as Collections from 'core/utils/collections';\nimport Util from 'core/util';\nimport Runtime from '../runtime';\n\n/** Sends data via JSONP.\n *\n * Data is a key-value map. Its values are JSON-encoded and then passed\n * through base64. Finally, keys and encoded values are appended to the query\n * string.\n *\n * The class itself does not guarantee raising errors on failures, as it's not\n * possible to support such feature on all browsers. Instead, JSONP endpoint\n * should call back in a way that's easy to distinguish from browser calls,\n * for example by passing a second argument to the receiver.\n *\n * @param {String} url\n * @param {Object} data key-value map of data to be submitted\n */\nexport default class JSONPRequest {\n url: string;\n data: any;\n request: ScriptRequest;\n\n constructor(url: string, data: any) {\n this.url = url;\n this.data = data;\n }\n\n /** Sends the actual JSONP request.\n *\n * @param {ScriptReceiver} receiver\n */\n send(receiver: ScriptReceiver) {\n if (this.request) {\n return;\n }\n\n var query = Collections.buildQueryString(this.data);\n var url = this.url + '/' + receiver.number + '?' + query;\n this.request = Runtime.createScriptRequest(url);\n this.request.send(receiver);\n }\n\n /** Cleans up the DOM remains of the JSONP request. */\n cleanup() {\n if (this.request) {\n this.request.cleanup();\n }\n }\n}\n","import TimelineSender from 'core/timeline/timeline_sender';\nimport TimelineTransport from 'core/timeline/timeline_transport';\nimport Browser from 'runtime';\nimport { AuthTransport } from 'core/auth/auth_transports';\nimport { ScriptReceivers } from '../dom/script_receiver_factory';\n\nvar getAgent = function(sender: TimelineSender, useTLS: boolean) {\n return function(data: any, callback: Function) {\n var scheme = 'http' + (useTLS ? 's' : '') + '://';\n var url =\n scheme + (sender.host || sender.options.host) + sender.options.path;\n var request = Browser.createJSONPRequest(url, data);\n\n var receiver = Browser.ScriptReceivers.create(function(error, result) {\n ScriptReceivers.remove(receiver);\n request.cleanup();\n\n if (result && result.host) {\n sender.host = result.host;\n }\n if (callback) {\n callback(error, result);\n }\n });\n request.send(receiver);\n };\n};\n\nvar jsonp = {\n name: 'jsonp',\n getAgent\n};\n\nexport default jsonp;\n","import Defaults from '../defaults';\nimport { default as URLScheme, URLSchemeParams } from './url_scheme';\n\nfunction getGenericURL(\n baseScheme: string,\n params: URLSchemeParams,\n path: string\n): string {\n var scheme = baseScheme + (params.useTLS ? 's' : '');\n var host = params.useTLS ? params.hostTLS : params.hostNonTLS;\n return scheme + '://' + host + path;\n}\n\nfunction getGenericPath(key: string, queryString?: string): string {\n var path = '/app/' + key;\n var query =\n '?protocol=' +\n Defaults.PROTOCOL +\n '&client=js' +\n '&version=' +\n Defaults.VERSION +\n (queryString ? '&' + queryString : '');\n return path + query;\n}\n\nexport var ws: URLScheme = {\n getInitial: function(key: string, params: URLSchemeParams): string {\n var path = (params.httpPath || '') + getGenericPath(key, 'flash=false');\n return getGenericURL('ws', params, path);\n }\n};\n\nexport var http: URLScheme = {\n getInitial: function(key: string, params: URLSchemeParams): string {\n var path = (params.httpPath || '/pusher') + getGenericPath(key);\n return getGenericURL('http', params, path);\n }\n};\n\nexport var sockjs: URLScheme = {\n getInitial: function(key: string, params: URLSchemeParams): string {\n return getGenericURL('http', params, params.httpPath || '/pusher');\n },\n getPath: function(key: string, params: URLSchemeParams): string {\n return getGenericPath(key);\n }\n};\n","import Callback from './callback';\nimport * as Collections from '../utils/collections';\nimport CallbackTable from './callback_table';\n\nexport default class CallbackRegistry {\n _callbacks: CallbackTable;\n\n constructor() {\n this._callbacks = {};\n }\n\n get(name: string): Callback[] {\n return this._callbacks[prefix(name)];\n }\n\n add(name: string, callback: Function, context: any) {\n var prefixedEventName = prefix(name);\n this._callbacks[prefixedEventName] =\n this._callbacks[prefixedEventName] || [];\n this._callbacks[prefixedEventName].push({\n fn: callback,\n context: context\n });\n }\n\n remove(name?: string, callback?: Function, context?: any) {\n if (!name && !callback && !context) {\n this._callbacks = {};\n return;\n }\n\n var names = name ? [prefix(name)] : Collections.keys(this._callbacks);\n\n if (callback || context) {\n this.removeCallback(names, callback, context);\n } else {\n this.removeAllCallbacks(names);\n }\n }\n\n private removeCallback(names: string[], callback: Function, context: any) {\n Collections.apply(\n names,\n function(name) {\n this._callbacks[name] = Collections.filter(\n this._callbacks[name] || [],\n function(binding) {\n return (\n (callback && callback !== binding.fn) ||\n (context && context !== binding.context)\n );\n }\n );\n if (this._callbacks[name].length === 0) {\n delete this._callbacks[name];\n }\n },\n this\n );\n }\n\n private removeAllCallbacks(names: string[]) {\n Collections.apply(\n names,\n function(name) {\n delete this._callbacks[name];\n },\n this\n );\n }\n}\n\nfunction prefix(name: string): string {\n return '_' + name;\n}\n","import * as Collections from '../utils/collections';\nimport Callback from './callback';\nimport Metadata from '../channels/metadata';\nimport CallbackRegistry from './callback_registry';\n\n/** Manages callback bindings and event emitting.\n *\n * @param Function failThrough called when no listeners are bound to an event\n */\nexport default class Dispatcher {\n callbacks: CallbackRegistry;\n global_callbacks: Function[];\n failThrough: Function;\n\n constructor(failThrough?: Function) {\n this.callbacks = new CallbackRegistry();\n this.global_callbacks = [];\n this.failThrough = failThrough;\n }\n\n bind(eventName: string, callback: Function, context?: any) {\n this.callbacks.add(eventName, callback, context);\n return this;\n }\n\n bind_global(callback: Function) {\n this.global_callbacks.push(callback);\n return this;\n }\n\n unbind(eventName?: string, callback?: Function, context?: any) {\n this.callbacks.remove(eventName, callback, context);\n return this;\n }\n\n unbind_global(callback?: Function) {\n if (!callback) {\n this.global_callbacks = [];\n return this;\n }\n\n this.global_callbacks = Collections.filter(\n this.global_callbacks || [],\n c => c !== callback\n );\n\n return this;\n }\n\n unbind_all() {\n this.unbind();\n this.unbind_global();\n return this;\n }\n\n emit(eventName: string, data?: any, metadata?: Metadata): Dispatcher {\n for (var i = 0; i < this.global_callbacks.length; i++) {\n this.global_callbacks[i](eventName, data);\n }\n\n var callbacks = this.callbacks.get(eventName);\n var args = [];\n\n if (metadata) {\n // if there's a metadata argument, we need to call the callback with both\n // data and metadata regardless of whether data is undefined\n args.push(data, metadata);\n } else if (data) {\n // metadata is undefined, so we only need to call the callback with data\n // if data exists\n args.push(data);\n }\n\n if (callbacks && callbacks.length > 0) {\n for (var i = 0; i < callbacks.length; i++) {\n callbacks[i].fn.apply(callbacks[i].context || global, args);\n }\n } else if (this.failThrough) {\n this.failThrough(eventName, data);\n }\n\n return this;\n }\n}\n","import Util from '../util';\nimport * as Collections from '../utils/collections';\nimport { default as EventsDispatcher } from '../events/dispatcher';\nimport Logger from '../logger';\nimport TransportHooks from './transport_hooks';\nimport Socket from '../socket';\nimport Runtime from 'runtime';\nimport Timeline from '../timeline/timeline';\nimport TransportConnectionOptions from './transport_connection_options';\n\n/** Provides universal API for transport connections.\n *\n * Transport connection is a low-level object that wraps a connection method\n * and exposes a simple evented interface for the connection state and\n * messaging. It does not implement Pusher-specific WebSocket protocol.\n *\n * Additionally, it fetches resources needed for transport to work and exposes\n * an interface for querying transport features.\n *\n * States:\n * - new - initial state after constructing the object\n * - initializing - during initialization phase, usually fetching resources\n * - intialized - ready to establish a connection\n * - connection - when connection is being established\n * - open - when connection ready to be used\n * - closed - after connection was closed be either side\n *\n * Emits:\n * - error - after the connection raised an error\n *\n * Options:\n * - useTLS - whether connection should be over TLS\n * - hostTLS - host to connect to when connection is over TLS\n * - hostNonTLS - host to connect to when connection is over TLS\n *\n * @param {String} key application key\n * @param {Object} options\n */\nexport default class TransportConnection extends EventsDispatcher {\n hooks: TransportHooks;\n name: string;\n priority: number;\n key: string;\n options: TransportConnectionOptions;\n state: string;\n timeline: Timeline;\n activityTimeout: number;\n id: number;\n socket: Socket;\n beforeOpen: Function;\n initialize: Function;\n\n constructor(\n hooks: TransportHooks,\n name: string,\n priority: number,\n key: string,\n options: TransportConnectionOptions\n ) {\n super();\n this.initialize = Runtime.transportConnectionInitializer;\n this.hooks = hooks;\n this.name = name;\n this.priority = priority;\n this.key = key;\n this.options = options;\n\n this.state = 'new';\n this.timeline = options.timeline;\n this.activityTimeout = options.activityTimeout;\n this.id = this.timeline.generateUniqueID();\n }\n\n /** Checks whether the transport handles activity checks by itself.\n *\n * @return {Boolean}\n */\n handlesActivityChecks(): boolean {\n return Boolean(this.hooks.handlesActivityChecks);\n }\n\n /** Checks whether the transport supports the ping/pong API.\n *\n * @return {Boolean}\n */\n supportsPing(): boolean {\n return Boolean(this.hooks.supportsPing);\n }\n\n /** Tries to establish a connection.\n *\n * @returns {Boolean} false if transport is in invalid state\n */\n connect(): boolean {\n if (this.socket || this.state !== 'initialized') {\n return false;\n }\n\n var url = this.hooks.urls.getInitial(this.key, this.options);\n try {\n this.socket = this.hooks.getSocket(url, this.options);\n } catch (e) {\n Util.defer(() => {\n this.onError(e);\n this.changeState('closed');\n });\n return false;\n }\n\n this.bindListeners();\n\n Logger.debug('Connecting', { transport: this.name, url });\n this.changeState('connecting');\n return true;\n }\n\n /** Closes the connection.\n *\n * @return {Boolean} true if there was a connection to close\n */\n close(): boolean {\n if (this.socket) {\n this.socket.close();\n return true;\n } else {\n return false;\n }\n }\n\n /** Sends data over the open connection.\n *\n * @param {String} data\n * @return {Boolean} true only when in the \"open\" state\n */\n send(data: any): boolean {\n if (this.state === 'open') {\n // Workaround for MobileSafari bug (see https://gist.github.com/2052006)\n Util.defer(() => {\n if (this.socket) {\n this.socket.send(data);\n }\n });\n return true;\n } else {\n return false;\n }\n }\n\n /** Sends a ping if the connection is open and transport supports it. */\n ping() {\n if (this.state === 'open' && this.supportsPing()) {\n this.socket.ping();\n }\n }\n\n private onOpen() {\n if (this.hooks.beforeOpen) {\n this.hooks.beforeOpen(\n this.socket,\n this.hooks.urls.getPath(this.key, this.options)\n );\n }\n this.changeState('open');\n this.socket.onopen = undefined;\n }\n\n private onError(error) {\n this.emit('error', { type: 'WebSocketError', error: error });\n this.timeline.error(this.buildTimelineMessage({ error: error.toString() }));\n }\n\n private onClose(closeEvent?: any) {\n if (closeEvent) {\n this.changeState('closed', {\n code: closeEvent.code,\n reason: closeEvent.reason,\n wasClean: closeEvent.wasClean\n });\n } else {\n this.changeState('closed');\n }\n this.unbindListeners();\n this.socket = undefined;\n }\n\n private onMessage(message) {\n this.emit('message', message);\n }\n\n private onActivity() {\n this.emit('activity');\n }\n\n private bindListeners() {\n this.socket.onopen = () => {\n this.onOpen();\n };\n this.socket.onerror = error => {\n this.onError(error);\n };\n this.socket.onclose = closeEvent => {\n this.onClose(closeEvent);\n };\n this.socket.onmessage = message => {\n this.onMessage(message);\n };\n\n if (this.supportsPing()) {\n this.socket.onactivity = () => {\n this.onActivity();\n };\n }\n }\n\n private unbindListeners() {\n if (this.socket) {\n this.socket.onopen = undefined;\n this.socket.onerror = undefined;\n this.socket.onclose = undefined;\n this.socket.onmessage = undefined;\n if (this.supportsPing()) {\n this.socket.onactivity = undefined;\n }\n }\n }\n\n private changeState(state: string, params?: any) {\n this.state = state;\n this.timeline.info(\n this.buildTimelineMessage({\n state: state,\n params: params\n })\n );\n this.emit(state, params);\n }\n\n buildTimelineMessage(message): any {\n return Collections.extend({ cid: this.id }, message);\n }\n}\n","import Factory from '../utils/factory';\nimport TransportHooks from './transport_hooks';\nimport TransportConnection from './transport_connection';\nimport TransportConnectionOptions from './transport_connection_options';\n\n/** Provides interface for transport connection instantiation.\n *\n * Takes transport-specific hooks as the only argument, which allow checking\n * for transport support and creating its connections.\n *\n * Supported hooks: * - file - the name of the file to be fetched during initialization\n * - urls - URL scheme to be used by transport\n * - handlesActivityCheck - true when the transport handles activity checks\n * - supportsPing - true when the transport has a ping/activity API\n * - isSupported - tells whether the transport is supported in the environment\n * - getSocket - creates a WebSocket-compatible transport socket\n *\n * See transports.js for specific implementations.\n *\n * @param {Object} hooks object containing all needed transport hooks\n */\nexport default class Transport {\n hooks: TransportHooks;\n\n constructor(hooks: TransportHooks) {\n this.hooks = hooks;\n }\n\n /** Returns whether the transport is supported in the environment.\n *\n * @param {Object} envronment te environment details (encryption, settings)\n * @returns {Boolean} true when the transport is supported\n */\n isSupported(environment: any): boolean {\n return this.hooks.isSupported(environment);\n }\n\n /** Creates a transport connection.\n *\n * @param {String} name\n * @param {Number} priority\n * @param {String} key the application key\n * @param {Object} options\n * @returns {TransportConnection}\n */\n createConnection(\n name: string,\n priority: number,\n key: string,\n options: any\n ): TransportConnection {\n return new TransportConnection(this.hooks, name, priority, key, options);\n }\n}\n","import * as URLSchemes from 'core/transports/url_schemes';\nimport URLScheme from 'core/transports/url_scheme';\nimport Transport from 'core/transports/transport';\nimport Util from 'core/util';\nimport * as Collections from 'core/utils/collections';\nimport TransportHooks from 'core/transports/transport_hooks';\nimport TransportsTable from 'core/transports/transports_table';\nimport Runtime from 'runtime';\n\n/** WebSocket transport.\n *\n * Uses native WebSocket implementation, including MozWebSocket supported by\n * earlier Firefox versions.\n */\nvar WSTransport = new Transport({\n urls: URLSchemes.ws,\n handlesActivityChecks: false,\n supportsPing: false,\n\n isInitialized: function() {\n return Boolean(Runtime.getWebSocketAPI());\n },\n isSupported: function(): boolean {\n return Boolean(Runtime.getWebSocketAPI());\n },\n getSocket: function(url) {\n return Runtime.createWebSocket(url);\n }\n});\n\nvar httpConfiguration = {\n urls: URLSchemes.http,\n handlesActivityChecks: false,\n supportsPing: true,\n isInitialized: function() {\n return true;\n }\n};\n\nexport var streamingConfiguration = Collections.extend(\n {\n getSocket: function(url) {\n return Runtime.HTTPFactory.createStreamingSocket(url);\n }\n },\n httpConfiguration\n);\nexport var pollingConfiguration = Collections.extend(\n {\n getSocket: function(url) {\n return Runtime.HTTPFactory.createPollingSocket(url);\n }\n },\n httpConfiguration\n);\n\nvar xhrConfiguration = {\n isSupported: function(): boolean {\n return Runtime.isXHRSupported();\n }\n};\n\n/** HTTP streaming transport using CORS-enabled XMLHttpRequest. */\nvar XHRStreamingTransport = new Transport(\n (\n Collections.extend({}, streamingConfiguration, xhrConfiguration)\n )\n);\n\n/** HTTP long-polling transport using CORS-enabled XMLHttpRequest. */\nvar XHRPollingTransport = new Transport(\n Collections.extend({}, pollingConfiguration, xhrConfiguration)\n);\n\nvar Transports: TransportsTable = {\n ws: WSTransport,\n xhr_streaming: XHRStreamingTransport,\n xhr_polling: XHRPollingTransport\n};\n\nexport default Transports;\n","import {\n default as Transports,\n streamingConfiguration,\n pollingConfiguration\n} from 'isomorphic/transports/transports';\nimport Transport from 'core/transports/transport';\nimport TransportHooks from 'core/transports/transport_hooks';\nimport * as URLSchemes from 'core/transports/url_schemes';\nimport Runtime from 'runtime';\nimport { Dependencies } from '../dom/dependencies';\nimport * as Collections from 'core/utils/collections';\n\nvar SockJSTransport = new Transport({\n file: 'sockjs',\n urls: URLSchemes.sockjs,\n handlesActivityChecks: true,\n supportsPing: false,\n\n isSupported: function() {\n return true;\n },\n isInitialized: function() {\n return window.SockJS !== undefined;\n },\n getSocket: function(url, options) {\n return new window.SockJS(url, null, {\n js_path: Dependencies.getPath('sockjs', {\n useTLS: options.useTLS\n }),\n ignore_null_origin: options.ignoreNullOrigin\n });\n },\n beforeOpen: function(socket, path) {\n socket.send(\n JSON.stringify({\n path: path\n })\n );\n }\n});\n\nvar xdrConfiguration = {\n isSupported: function(environment): boolean {\n var yes = Runtime.isXDRSupported(environment.useTLS);\n return yes;\n }\n};\n\n/** HTTP streaming transport using XDomainRequest (IE 8,9). */\nvar XDRStreamingTransport = new Transport(\n (\n Collections.extend({}, streamingConfiguration, xdrConfiguration)\n )\n);\n\n/** HTTP long-polling transport using XDomainRequest (IE 8,9). */\nvar XDRPollingTransport = new Transport(\n Collections.extend({}, pollingConfiguration, xdrConfiguration)\n);\n\nTransports.xdr_streaming = XDRStreamingTransport;\nTransports.xdr_polling = XDRPollingTransport;\nTransports.sockjs = SockJSTransport;\n\nexport default Transports;\n","import Reachability from 'core/reachability';\nimport { default as EventsDispatcher } from 'core/events/dispatcher';\n\n/** Really basic interface providing network availability info.\n *\n * Emits:\n * - online - when browser goes online\n * - offline - when browser goes offline\n */\nexport class NetInfo extends EventsDispatcher implements Reachability {\n constructor() {\n super();\n var self = this;\n // This is okay, as IE doesn't support this stuff anyway.\n if (window.addEventListener !== undefined) {\n window.addEventListener(\n 'online',\n function() {\n self.emit('online');\n },\n false\n );\n window.addEventListener(\n 'offline',\n function() {\n self.emit('offline');\n },\n false\n );\n }\n }\n\n /** Returns whether browser is online or not\n *\n * Offline means definitely offline (no connection to router).\n * Inverse does NOT mean definitely online (only currently supported in Safari\n * and even there only means the device has a connection to the router).\n *\n * @return {Boolean}\n */\n isOnline(): boolean {\n if (window.navigator.onLine === undefined) {\n return true;\n } else {\n return window.navigator.onLine;\n }\n }\n}\n\nexport var Network = new NetInfo();\n","import Util from '../util';\nimport * as Collections from '../utils/collections';\nimport TransportManager from './transport_manager';\nimport TransportConnection from './transport_connection';\nimport Transport from './transport';\nimport PingDelayOptions from './ping_delay_options';\n\n/** Creates transport connections monitored by a transport manager.\n *\n * When a transport is closed, it might mean the environment does not support\n * it. It's possible that messages get stuck in an intermediate buffer or\n * proxies terminate inactive connections. To combat these problems,\n * assistants monitor the connection lifetime, report unclean exits and\n * adjust ping timeouts to keep the connection active. The decision to disable\n * a transport is the manager's responsibility.\n *\n * @param {TransportManager} manager\n * @param {TransportConnection} transport\n * @param {Object} options\n */\nexport default class AssistantToTheTransportManager {\n manager: TransportManager;\n transport: Transport;\n minPingDelay: number;\n maxPingDelay: number;\n pingDelay: number;\n\n constructor(\n manager: TransportManager,\n transport: Transport,\n options: PingDelayOptions\n ) {\n this.manager = manager;\n this.transport = transport;\n this.minPingDelay = options.minPingDelay;\n this.maxPingDelay = options.maxPingDelay;\n this.pingDelay = undefined;\n }\n\n /** Creates a transport connection.\n *\n * This function has the same API as Transport#createConnection.\n *\n * @param {String} name\n * @param {Number} priority\n * @param {String} key the application key\n * @param {Object} options\n * @returns {TransportConnection}\n */\n createConnection(\n name: string,\n priority: number,\n key: string,\n options: Object\n ): TransportConnection {\n options = Collections.extend({}, options, {\n activityTimeout: this.pingDelay\n });\n var connection = this.transport.createConnection(\n name,\n priority,\n key,\n options\n );\n\n var openTimestamp = null;\n\n var onOpen = function() {\n connection.unbind('open', onOpen);\n connection.bind('closed', onClosed);\n openTimestamp = Util.now();\n };\n var onClosed = closeEvent => {\n connection.unbind('closed', onClosed);\n\n if (closeEvent.code === 1002 || closeEvent.code === 1003) {\n // we don't want to use transports not obeying the protocol\n this.manager.reportDeath();\n } else if (!closeEvent.wasClean && openTimestamp) {\n // report deaths only for short-living transport\n var lifespan = Util.now() - openTimestamp;\n if (lifespan < 2 * this.maxPingDelay) {\n this.manager.reportDeath();\n this.pingDelay = Math.max(lifespan / 2, this.minPingDelay);\n }\n }\n };\n\n connection.bind('open', onOpen);\n return connection;\n }\n\n /** Returns whether the transport is supported in the environment.\n *\n * This function has the same API as Transport#isSupported. Might return false\n * when the manager decides to kill the transport.\n *\n * @param {Object} environment the environment details (encryption, settings)\n * @returns {Boolean} true when the transport is supported\n */\n isSupported(environment: string): boolean {\n return this.manager.isAlive() && this.transport.isSupported(environment);\n }\n}\n","import Action from './action';\nimport { PusherEvent } from './message-types';\n/**\n * Provides functions for handling Pusher protocol-specific messages.\n */\n\nconst Protocol = {\n /**\n * Decodes a message in a Pusher format.\n *\n * The MessageEvent we receive from the transport should contain a pusher event\n * (https://pusher.com/docs/pusher_protocol#events) serialized as JSON in the\n * data field\n *\n * The pusher event may contain a data field too, and it may also be\n * serialised as JSON\n *\n * Throws errors when messages are not parse'able.\n *\n * @param {MessageEvent} messageEvent\n * @return {PusherEvent}\n */\n decodeMessage: function(messageEvent: MessageEvent): PusherEvent {\n try {\n var messageData = JSON.parse(messageEvent.data);\n var pusherEventData = messageData.data;\n if (typeof pusherEventData === 'string') {\n try {\n pusherEventData = JSON.parse(messageData.data);\n } catch (e) {}\n }\n var pusherEvent: PusherEvent = {\n event: messageData.event,\n channel: messageData.channel,\n data: pusherEventData\n };\n if (messageData.user_id) {\n pusherEvent.user_id = messageData.user_id;\n }\n return pusherEvent;\n } catch (e) {\n throw { type: 'MessageParseError', error: e, data: messageEvent.data };\n }\n },\n\n /**\n * Encodes a message to be sent.\n *\n * @param {PusherEvent} event\n * @return {String}\n */\n encodeMessage: function(event: PusherEvent): string {\n return JSON.stringify(event);\n },\n\n /**\n * Processes a handshake message and returns appropriate actions.\n *\n * Returns an object with an 'action' and other action-specific properties.\n *\n * There are three outcomes when calling this function. First is a successful\n * connection attempt, when pusher:connection_established is received, which\n * results in a 'connected' action with an 'id' property. When passed a\n * pusher:error event, it returns a result with action appropriate to the\n * close code and an error. Otherwise, it raises an exception.\n *\n * @param {String} message\n * @result Object\n */\n processHandshake: function(messageEvent: MessageEvent): Action {\n var message = Protocol.decodeMessage(messageEvent);\n\n if (message.event === 'pusher:connection_established') {\n if (!message.data.activity_timeout) {\n throw 'No activity timeout specified in handshake';\n }\n return {\n action: 'connected',\n id: message.data.socket_id,\n activityTimeout: message.data.activity_timeout * 1000\n };\n } else if (message.event === 'pusher:error') {\n // From protocol 6 close codes are sent only once, so this only\n // happens when connection does not support close codes\n return {\n action: this.getCloseAction(message.data),\n error: this.getCloseError(message.data)\n };\n } else {\n throw 'Invalid handshake';\n }\n },\n\n /**\n * Dispatches the close event and returns an appropriate action name.\n *\n * See:\n * 1. https://developer.mozilla.org/en-US/docs/WebSockets/WebSockets_reference/CloseEvent\n * 2. http://pusher.com/docs/pusher_protocol\n *\n * @param {CloseEvent} closeEvent\n * @return {String} close action name\n */\n getCloseAction: function(closeEvent): string {\n if (closeEvent.code < 4000) {\n // ignore 1000 CLOSE_NORMAL, 1001 CLOSE_GOING_AWAY,\n // 1005 CLOSE_NO_STATUS, 1006 CLOSE_ABNORMAL\n // ignore 1007...3999\n // handle 1002 CLOSE_PROTOCOL_ERROR, 1003 CLOSE_UNSUPPORTED,\n // 1004 CLOSE_TOO_LARGE\n if (closeEvent.code >= 1002 && closeEvent.code <= 1004) {\n return 'backoff';\n } else {\n return null;\n }\n } else if (closeEvent.code === 4000) {\n return 'tls_only';\n } else if (closeEvent.code < 4100) {\n return 'refused';\n } else if (closeEvent.code < 4200) {\n return 'backoff';\n } else if (closeEvent.code < 4300) {\n return 'retry';\n } else {\n // unknown error\n return 'refused';\n }\n },\n\n /**\n * Returns an error or null basing on the close event.\n *\n * Null is returned when connection was closed cleanly. Otherwise, an object\n * with error details is returned.\n *\n * @param {CloseEvent} closeEvent\n * @return {Object} error object\n */\n getCloseError: function(closeEvent): any {\n if (closeEvent.code !== 1000 && closeEvent.code !== 1001) {\n return {\n type: 'PusherError',\n data: {\n code: closeEvent.code,\n message: closeEvent.reason || closeEvent.message\n }\n };\n } else {\n return null;\n }\n }\n};\n\nexport default Protocol;\n","import * as Collections from '../utils/collections';\nimport { default as EventsDispatcher } from '../events/dispatcher';\nimport Protocol from './protocol/protocol';\nimport { PusherEvent } from './protocol/message-types';\nimport Logger from '../logger';\nimport TransportConnection from '../transports/transport_connection';\nimport Socket from '../socket';\n/**\n * Provides Pusher protocol interface for transports.\n *\n * Emits following events:\n * - message - on received messages\n * - ping - on ping requests\n * - pong - on pong responses\n * - error - when the transport emits an error\n * - closed - after closing the transport\n *\n * It also emits more events when connection closes with a code.\n * See Protocol.getCloseAction to get more details.\n *\n * @param {Number} id\n * @param {AbstractTransport} transport\n */\nexport default class Connection extends EventsDispatcher implements Socket {\n id: string;\n transport: TransportConnection;\n activityTimeout: number;\n\n constructor(id: string, transport: TransportConnection) {\n super();\n this.id = id;\n this.transport = transport;\n this.activityTimeout = transport.activityTimeout;\n this.bindListeners();\n }\n\n /** Returns whether used transport handles activity checks by itself\n *\n * @returns {Boolean} true if activity checks are handled by the transport\n */\n handlesActivityChecks() {\n return this.transport.handlesActivityChecks();\n }\n\n /** Sends raw data.\n *\n * @param {String} data\n */\n send(data: any): boolean {\n return this.transport.send(data);\n }\n\n /** Sends an event.\n *\n * @param {String} name\n * @param {String} data\n * @param {String} [channel]\n * @returns {Boolean} whether message was sent or not\n */\n send_event(name: string, data: any, channel?: string): boolean {\n var event: PusherEvent = { event: name, data: data };\n if (channel) {\n event.channel = channel;\n }\n Logger.debug('Event sent', event);\n return this.send(Protocol.encodeMessage(event));\n }\n\n /** Sends a ping message to the server.\n *\n * Basing on the underlying transport, it might send either transport's\n * protocol-specific ping or pusher:ping event.\n */\n ping() {\n if (this.transport.supportsPing()) {\n this.transport.ping();\n } else {\n this.send_event('pusher:ping', {});\n }\n }\n\n /** Closes the connection. */\n close() {\n this.transport.close();\n }\n\n private bindListeners() {\n var listeners = {\n message: (messageEvent: MessageEvent) => {\n var pusherEvent;\n try {\n pusherEvent = Protocol.decodeMessage(messageEvent);\n } catch (e) {\n this.emit('error', {\n type: 'MessageParseError',\n error: e,\n data: messageEvent.data\n });\n }\n\n if (pusherEvent !== undefined) {\n Logger.debug('Event recd', pusherEvent);\n\n switch (pusherEvent.event) {\n case 'pusher:error':\n this.emit('error', {\n type: 'PusherError',\n data: pusherEvent.data\n });\n break;\n case 'pusher:ping':\n this.emit('ping');\n break;\n case 'pusher:pong':\n this.emit('pong');\n break;\n }\n this.emit('message', pusherEvent);\n }\n },\n activity: () => {\n this.emit('activity');\n },\n error: error => {\n this.emit('error', error);\n },\n closed: closeEvent => {\n unbindListeners();\n\n if (closeEvent && closeEvent.code) {\n this.handleCloseEvent(closeEvent);\n }\n\n this.transport = null;\n this.emit('closed');\n }\n };\n\n var unbindListeners = () => {\n Collections.objectApply(listeners, (listener, event) => {\n this.transport.unbind(event, listener);\n });\n };\n\n Collections.objectApply(listeners, (listener, event) => {\n this.transport.bind(event, listener);\n });\n }\n\n private handleCloseEvent(closeEvent: any) {\n var action = Protocol.getCloseAction(closeEvent);\n var error = Protocol.getCloseError(closeEvent);\n if (error) {\n this.emit('error', error);\n }\n if (action) {\n this.emit(action, { action: action, error: error });\n }\n }\n}\n","import Util from '../../util';\nimport * as Collections from '../../utils/collections';\nimport Protocol from '../protocol/protocol';\nimport Connection from '../connection';\nimport TransportConnection from '../../transports/transport_connection';\nimport HandshakePayload from './handshake_payload';\n\n/**\n * Handles Pusher protocol handshakes for transports.\n *\n * Calls back with a result object after handshake is completed. Results\n * always have two fields:\n * - action - string describing action to be taken after the handshake\n * - transport - the transport object passed to the constructor\n *\n * Different actions can set different additional properties on the result.\n * In the case of 'connected' action, there will be a 'connection' property\n * containing a Connection object for the transport. Other actions should\n * carry an 'error' property.\n *\n * @param {AbstractTransport} transport\n * @param {Function} callback\n */\nexport default class Handshake {\n transport: TransportConnection;\n callback: (HandshakePayload) => void;\n onMessage: Function;\n onClosed: Function;\n\n constructor(\n transport: TransportConnection,\n callback: (HandshakePayload) => void\n ) {\n this.transport = transport;\n this.callback = callback;\n this.bindListeners();\n }\n\n close() {\n this.unbindListeners();\n this.transport.close();\n }\n\n private bindListeners() {\n this.onMessage = m => {\n this.unbindListeners();\n\n var result;\n try {\n result = Protocol.processHandshake(m);\n } catch (e) {\n this.finish('error', { error: e });\n this.transport.close();\n return;\n }\n\n if (result.action === 'connected') {\n this.finish('connected', {\n connection: new Connection(result.id, this.transport),\n activityTimeout: result.activityTimeout\n });\n } else {\n this.finish(result.action, { error: result.error });\n this.transport.close();\n }\n };\n\n this.onClosed = closeEvent => {\n this.unbindListeners();\n\n var action = Protocol.getCloseAction(closeEvent) || 'backoff';\n var error = Protocol.getCloseError(closeEvent);\n this.finish(action, { error: error });\n };\n\n this.transport.bind('message', this.onMessage);\n this.transport.bind('closed', this.onClosed);\n }\n\n private unbindListeners() {\n this.transport.unbind('message', this.onMessage);\n this.transport.unbind('closed', this.onClosed);\n }\n\n private finish(action: string, params: any) {\n this.callback(\n Collections.extend({ transport: this.transport, action: action }, params)\n );\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport base64encode from '../base64';\nimport Timeline from './timeline';\nimport Runtime from 'runtime';\n\nexport interface TimelineSenderOptions {\n host?: string;\n port?: number;\n path?: string;\n}\n\nexport default class TimelineSender {\n timeline: Timeline;\n options: TimelineSenderOptions;\n host: string;\n\n constructor(timeline: Timeline, options: TimelineSenderOptions) {\n this.timeline = timeline;\n this.options = options || {};\n }\n\n send(useTLS: boolean, callback?: Function) {\n if (this.timeline.isEmpty()) {\n return;\n }\n\n this.timeline.send(\n Runtime.TimelineTransport.getAgent(this, useTLS),\n callback\n );\n }\n}\n","import { default as EventsDispatcher } from '../events/dispatcher';\nimport * as Errors from '../errors';\nimport Logger from '../logger';\nimport Pusher from '../pusher';\nimport { PusherEvent } from '../connection/protocol/message-types';\nimport Metadata from './metadata';\nimport UrlStore from '../utils/url_store';\nimport {\n ChannelAuthorizationData,\n ChannelAuthorizationCallback\n} from '../auth/options';\nimport { HTTPAuthError } from '../errors';\n\n/** Provides base public channel interface with an event emitter.\n *\n * Emits:\n * - pusher:subscription_succeeded - after subscribing successfully\n * - other non-internal events\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\nexport default class Channel extends EventsDispatcher {\n name: string;\n pusher: Pusher;\n subscribed: boolean;\n subscriptionPending: boolean;\n subscriptionCancelled: boolean;\n subscriptionCount: null;\n\n constructor(name: string, pusher: Pusher) {\n super(function(event, data) {\n Logger.debug('No callbacks on ' + name + ' for ' + event);\n });\n\n this.name = name;\n this.pusher = pusher;\n this.subscribed = false;\n this.subscriptionPending = false;\n this.subscriptionCancelled = false;\n }\n\n /** Skips authorization, since public channels don't require it.\n *\n * @param {Function} callback\n */\n authorize(socketId: string, callback: ChannelAuthorizationCallback) {\n return callback(null, { auth: '' });\n }\n\n /** Triggers an event */\n trigger(event: string, data: any) {\n if (event.indexOf('client-') !== 0) {\n throw new Errors.BadEventName(\n \"Event '\" + event + \"' does not start with 'client-'\"\n );\n }\n if (!this.subscribed) {\n var suffix = UrlStore.buildLogSuffix('triggeringClientEvents');\n Logger.warn(\n `Client event triggered before channel 'subscription_succeeded' event . ${suffix}`\n );\n }\n return this.pusher.send_event(event, data, this.name);\n }\n\n /** Signals disconnection to the channel. For internal use only. */\n disconnect() {\n this.subscribed = false;\n this.subscriptionPending = false;\n }\n\n /** Handles a PusherEvent. For internal use only.\n *\n * @param {PusherEvent} event\n */\n handleEvent(event: PusherEvent) {\n var eventName = event.event;\n var data = event.data;\n if (eventName === 'pusher_internal:subscription_succeeded') {\n this.handleSubscriptionSucceededEvent(event);\n } else if (eventName === 'pusher_internal:subscription_count') {\n this.handleSubscriptionCountEvent(event);\n } else if (eventName.indexOf('pusher_internal:') !== 0) {\n var metadata: Metadata = {};\n this.emit(eventName, data, metadata);\n }\n }\n\n handleSubscriptionSucceededEvent(event: PusherEvent) {\n this.subscriptionPending = false;\n this.subscribed = true;\n if (this.subscriptionCancelled) {\n this.pusher.unsubscribe(this.name);\n } else {\n this.emit('pusher:subscription_succeeded', event.data);\n }\n }\n\n handleSubscriptionCountEvent(event: PusherEvent) {\n if (event.data.subscription_count) {\n this.subscriptionCount = event.data.subscription_count;\n }\n\n this.emit('pusher:subscription_count', event.data);\n }\n\n /** Sends a subscription request. For internal use only. */\n subscribe() {\n if (this.subscribed) {\n return;\n }\n this.subscriptionPending = true;\n this.subscriptionCancelled = false;\n this.authorize(\n this.pusher.connection.socket_id,\n (error: Error | null, data: ChannelAuthorizationData) => {\n if (error) {\n this.subscriptionPending = false;\n // Why not bind to 'pusher:subscription_error' a level up, and log there?\n // Binding to this event would cause the warning about no callbacks being\n // bound (see constructor) to be suppressed, that's not what we want.\n Logger.error(error.toString());\n this.emit(\n 'pusher:subscription_error',\n Object.assign(\n {},\n {\n type: 'AuthError',\n error: error.message\n },\n error instanceof HTTPAuthError ? { status: error.status } : {}\n )\n );\n } else {\n this.pusher.send_event('pusher:subscribe', {\n auth: data.auth,\n channel_data: data.channel_data,\n channel: this.name\n });\n }\n }\n );\n }\n\n /** Sends an unsubscription request. For internal use only. */\n unsubscribe() {\n this.subscribed = false;\n this.pusher.send_event('pusher:unsubscribe', {\n channel: this.name\n });\n }\n\n /** Cancels an in progress subscription. For internal use only. */\n cancelSubscription() {\n this.subscriptionCancelled = true;\n }\n\n /** Reinstates an in progress subscripiton. For internal use only. */\n reinstateSubscription() {\n this.subscriptionCancelled = false;\n }\n}\n","import Factory from '../utils/factory';\nimport Channel from './channel';\nimport { ChannelAuthorizationCallback } from '../auth/options';\n\n/** Extends public channels to provide private channel interface.\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\nexport default class PrivateChannel extends Channel {\n /** Authorizes the connection to use the channel.\n *\n * @param {String} socketId\n * @param {Function} callback\n */\n authorize(socketId: string, callback: ChannelAuthorizationCallback) {\n return this.pusher.config.channelAuthorizer(\n {\n channelName: this.name,\n socketId: socketId\n },\n callback\n );\n }\n}\n","import * as Collections from '../utils/collections';\n\n/** Represents a collection of members of a presence channel. */\nexport default class Members {\n members: any;\n count: number;\n myID: any;\n me: any;\n\n constructor() {\n this.reset();\n }\n\n /** Returns member's info for given id.\n *\n * Resulting object containts two fields - id and info.\n *\n * @param {Number} id\n * @return {Object} member's info or null\n */\n get(id: string): any {\n if (Object.prototype.hasOwnProperty.call(this.members, id)) {\n return {\n id: id,\n info: this.members[id]\n };\n } else {\n return null;\n }\n }\n\n /** Calls back for each member in unspecified order.\n *\n * @param {Function} callback\n */\n each(callback: Function) {\n Collections.objectApply(this.members, (member, id) => {\n callback(this.get(id));\n });\n }\n\n /** Updates the id for connected member. For internal use only. */\n setMyID(id: string) {\n this.myID = id;\n }\n\n /** Handles subscription data. For internal use only. */\n onSubscription(subscriptionData: any) {\n this.members = subscriptionData.presence.hash;\n this.count = subscriptionData.presence.count;\n this.me = this.get(this.myID);\n }\n\n /** Adds a new member to the collection. For internal use only. */\n addMember(memberData: any) {\n if (this.get(memberData.user_id) === null) {\n this.count++;\n }\n this.members[memberData.user_id] = memberData.user_info;\n return this.get(memberData.user_id);\n }\n\n /** Adds a member from the collection. For internal use only. */\n removeMember(memberData: any) {\n var member = this.get(memberData.user_id);\n if (member) {\n delete this.members[memberData.user_id];\n this.count--;\n }\n return member;\n }\n\n /** Resets the collection to the initial state. For internal use only. */\n reset() {\n this.members = {};\n this.count = 0;\n this.myID = null;\n this.me = null;\n }\n}\n","import PrivateChannel from './private_channel';\nimport Logger from '../logger';\nimport Members from './members';\nimport Pusher from '../pusher';\nimport UrlStore from 'core/utils/url_store';\nimport { PusherEvent } from '../connection/protocol/message-types';\nimport Metadata from './metadata';\nimport { ChannelAuthorizationData } from '../auth/options';\n\nexport default class PresenceChannel extends PrivateChannel {\n members: Members;\n\n /** Adds presence channel functionality to private channels.\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\n constructor(name: string, pusher: Pusher) {\n super(name, pusher);\n this.members = new Members();\n }\n\n /** Authorizes the connection as a member of the channel.\n *\n * @param {String} socketId\n * @param {Function} callback\n */\n authorize(socketId: string, callback: Function) {\n super.authorize(socketId, async (error, authData) => {\n if (!error) {\n authData = authData as ChannelAuthorizationData;\n if (authData.channel_data != null) {\n var channelData = JSON.parse(authData.channel_data);\n this.members.setMyID(channelData.user_id);\n } else {\n await this.pusher.user.signinDonePromise;\n if (this.pusher.user.user_data != null) {\n // If the user is signed in, get the id of the authenticated user\n // and allow the presence authorization to continue.\n this.members.setMyID(this.pusher.user.user_data.id);\n } else {\n let suffix = UrlStore.buildLogSuffix('authorizationEndpoint');\n Logger.error(\n `Invalid auth response for channel '${this.name}', ` +\n `expected 'channel_data' field. ${suffix}, ` +\n `or the user should be signed in.`\n );\n callback('Invalid auth response');\n return;\n }\n }\n }\n callback(error, authData);\n });\n }\n\n /** Handles presence and subscription events. For internal use only.\n *\n * @param {PusherEvent} event\n */\n handleEvent(event: PusherEvent) {\n var eventName = event.event;\n if (eventName.indexOf('pusher_internal:') === 0) {\n this.handleInternalEvent(event);\n } else {\n var data = event.data;\n var metadata: Metadata = {};\n if (event.user_id) {\n metadata.user_id = event.user_id;\n }\n this.emit(eventName, data, metadata);\n }\n }\n handleInternalEvent(event: PusherEvent) {\n var eventName = event.event;\n var data = event.data;\n switch (eventName) {\n case 'pusher_internal:subscription_succeeded':\n this.handleSubscriptionSucceededEvent(event);\n break;\n case 'pusher_internal:subscription_count':\n this.handleSubscriptionCountEvent(event);\n break;\n case 'pusher_internal:member_added':\n var addedMember = this.members.addMember(data);\n this.emit('pusher:member_added', addedMember);\n break;\n case 'pusher_internal:member_removed':\n var removedMember = this.members.removeMember(data);\n if (removedMember) {\n this.emit('pusher:member_removed', removedMember);\n }\n break;\n }\n }\n\n handleSubscriptionSucceededEvent(event: PusherEvent) {\n this.subscriptionPending = false;\n this.subscribed = true;\n if (this.subscriptionCancelled) {\n this.pusher.unsubscribe(this.name);\n } else {\n this.members.onSubscription(event.data);\n this.emit('pusher:subscription_succeeded', this.members);\n }\n }\n\n /** Resets the channel state, including members map. For internal use only. */\n disconnect() {\n this.members.reset();\n super.disconnect();\n }\n}\n","import PrivateChannel from './private_channel';\nimport * as Errors from '../errors';\nimport Logger from '../logger';\nimport Pusher from '../pusher';\nimport { decode as encodeUTF8 } from '@stablelib/utf8';\nimport { decode as decodeBase64 } from '@stablelib/base64';\nimport Dispatcher from '../events/dispatcher';\nimport { PusherEvent } from '../connection/protocol/message-types';\nimport {\n ChannelAuthorizationData,\n ChannelAuthorizationCallback\n} from '../auth/options';\nimport * as nacl from 'tweetnacl';\n\n/** Extends private channels to provide encrypted channel interface.\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\nexport default class EncryptedChannel extends PrivateChannel {\n key: Uint8Array = null;\n nacl: nacl;\n\n constructor(name: string, pusher: Pusher, nacl: nacl) {\n super(name, pusher);\n this.nacl = nacl;\n }\n\n /** Authorizes the connection to use the channel.\n *\n * @param {String} socketId\n * @param {Function} callback\n */\n authorize(socketId: string, callback: ChannelAuthorizationCallback) {\n super.authorize(\n socketId,\n (error: Error | null, authData: ChannelAuthorizationData) => {\n if (error) {\n callback(error, authData);\n return;\n }\n let sharedSecret = authData['shared_secret'];\n if (!sharedSecret) {\n callback(\n new Error(\n `No shared_secret key in auth payload for encrypted channel: ${this.name}`\n ),\n null\n );\n return;\n }\n this.key = decodeBase64(sharedSecret);\n delete authData['shared_secret'];\n callback(null, authData);\n }\n );\n }\n\n trigger(event: string, data: any): boolean {\n throw new Errors.UnsupportedFeature(\n 'Client events are not currently supported for encrypted channels'\n );\n }\n\n /** Handles an event. For internal use only.\n *\n * @param {PusherEvent} event\n */\n handleEvent(event: PusherEvent) {\n var eventName = event.event;\n var data = event.data;\n if (\n eventName.indexOf('pusher_internal:') === 0 ||\n eventName.indexOf('pusher:') === 0\n ) {\n super.handleEvent(event);\n return;\n }\n this.handleEncryptedEvent(eventName, data);\n }\n\n private handleEncryptedEvent(event: string, data: any): void {\n if (!this.key) {\n Logger.debug(\n 'Received encrypted event before key has been retrieved from the authEndpoint'\n );\n return;\n }\n if (!data.ciphertext || !data.nonce) {\n Logger.error(\n 'Unexpected format for encrypted event, expected object with `ciphertext` and `nonce` fields, got: ' +\n data\n );\n return;\n }\n let cipherText = decodeBase64(data.ciphertext);\n if (cipherText.length < this.nacl.secretbox.overheadLength) {\n Logger.error(\n `Expected encrypted event ciphertext length to be ${this.nacl.secretbox.overheadLength}, got: ${cipherText.length}`\n );\n return;\n }\n let nonce = decodeBase64(data.nonce);\n if (nonce.length < this.nacl.secretbox.nonceLength) {\n Logger.error(\n `Expected encrypted event nonce length to be ${this.nacl.secretbox.nonceLength}, got: ${nonce.length}`\n );\n return;\n }\n\n let bytes = this.nacl.secretbox.open(cipherText, nonce, this.key);\n if (bytes === null) {\n Logger.debug(\n 'Failed to decrypt an event, probably because it was encrypted with a different key. Fetching a new key from the authEndpoint...'\n );\n // Try a single time to retrieve a new auth key and decrypt the event with it\n // If this fails, a new key will be requested when a new message is received\n this.authorize(this.pusher.connection.socket_id, (error, authData) => {\n if (error) {\n Logger.error(\n `Failed to make a request to the authEndpoint: ${authData}. Unable to fetch new key, so dropping encrypted event`\n );\n return;\n }\n bytes = this.nacl.secretbox.open(cipherText, nonce, this.key);\n if (bytes === null) {\n Logger.error(\n `Failed to decrypt event with new key. Dropping encrypted event`\n );\n return;\n }\n this.emit(event, this.getDataToEmit(bytes));\n return;\n });\n return;\n }\n this.emit(event, this.getDataToEmit(bytes));\n }\n\n // Try and parse the decrypted bytes as JSON. If we can't parse it, just\n // return the utf-8 string\n getDataToEmit(bytes: Uint8Array): string {\n let raw = encodeUTF8(bytes);\n try {\n return JSON.parse(raw);\n } catch {\n return raw;\n }\n }\n}\n","import { default as EventsDispatcher } from '../events/dispatcher';\nimport { OneOffTimer as Timer } from '../utils/timers';\nimport { Config } from '../config';\nimport Logger from '../logger';\nimport HandshakePayload from './handshake/handshake_payload';\nimport Connection from './connection';\nimport Strategy from '../strategies/strategy';\nimport StrategyRunner from '../strategies/strategy_runner';\nimport * as Collections from '../utils/collections';\nimport Timeline from '../timeline/timeline';\nimport ConnectionManagerOptions from './connection_manager_options';\nimport Runtime from 'runtime';\n\nimport {\n ErrorCallbacks,\n HandshakeCallbacks,\n ConnectionCallbacks\n} from './callbacks';\nimport Action from './protocol/action';\n\n/** Manages connection to Pusher.\n *\n * Uses a strategy (currently only default), timers and network availability\n * info to establish a connection and export its state. In case of failures,\n * manages reconnection attempts.\n *\n * Exports state changes as following events:\n * - \"state_change\", { previous: p, current: state }\n * - state\n *\n * States:\n * - initialized - initial state, never transitioned to\n * - connecting - connection is being established\n * - connected - connection has been fully established\n * - disconnected - on requested disconnection\n * - unavailable - after connection timeout or when there's no network\n * - failed - when the connection strategy is not supported\n *\n * Options:\n * - unavailableTimeout - time to transition to unavailable state\n * - activityTimeout - time after which ping message should be sent\n * - pongTimeout - time for Pusher to respond with pong before reconnecting\n *\n * @param {String} key application key\n * @param {Object} options\n */\nexport default class ConnectionManager extends EventsDispatcher {\n key: string;\n options: ConnectionManagerOptions;\n state: string;\n connection: Connection;\n usingTLS: boolean;\n timeline: Timeline;\n socket_id: string;\n unavailableTimer: Timer;\n activityTimer: Timer;\n retryTimer: Timer;\n activityTimeout: number;\n strategy: Strategy;\n runner: StrategyRunner;\n errorCallbacks: ErrorCallbacks;\n handshakeCallbacks: HandshakeCallbacks;\n connectionCallbacks: ConnectionCallbacks;\n\n constructor(key: string, options: ConnectionManagerOptions) {\n super();\n this.state = 'initialized';\n this.connection = null;\n\n this.key = key;\n this.options = options;\n this.timeline = this.options.timeline;\n this.usingTLS = this.options.useTLS;\n\n this.errorCallbacks = this.buildErrorCallbacks();\n this.connectionCallbacks = this.buildConnectionCallbacks(\n this.errorCallbacks\n );\n this.handshakeCallbacks = this.buildHandshakeCallbacks(this.errorCallbacks);\n\n var Network = Runtime.getNetwork();\n\n Network.bind('online', () => {\n this.timeline.info({ netinfo: 'online' });\n if (this.state === 'connecting' || this.state === 'unavailable') {\n this.retryIn(0);\n }\n });\n Network.bind('offline', () => {\n this.timeline.info({ netinfo: 'offline' });\n if (this.connection) {\n this.sendActivityCheck();\n }\n });\n\n this.updateStrategy();\n }\n\n /** Establishes a connection to Pusher.\n *\n * Does nothing when connection is already established. See top-level doc\n * to find events emitted on connection attempts.\n */\n connect() {\n if (this.connection || this.runner) {\n return;\n }\n if (!this.strategy.isSupported()) {\n this.updateState('failed');\n return;\n }\n this.updateState('connecting');\n this.startConnecting();\n this.setUnavailableTimer();\n }\n\n /** Sends raw data.\n *\n * @param {String} data\n */\n send(data) {\n if (this.connection) {\n return this.connection.send(data);\n } else {\n return false;\n }\n }\n\n /** Sends an event.\n *\n * @param {String} name\n * @param {String} data\n * @param {String} [channel]\n * @returns {Boolean} whether message was sent or not\n */\n send_event(name: string, data: any, channel?: string) {\n if (this.connection) {\n return this.connection.send_event(name, data, channel);\n } else {\n return false;\n }\n }\n\n /** Closes the connection. */\n disconnect() {\n this.disconnectInternally();\n this.updateState('disconnected');\n }\n\n isUsingTLS() {\n return this.usingTLS;\n }\n\n private startConnecting() {\n var callback = (error, handshake) => {\n if (error) {\n this.runner = this.strategy.connect(0, callback);\n } else {\n if (handshake.action === 'error') {\n this.emit('error', {\n type: 'HandshakeError',\n error: handshake.error\n });\n this.timeline.error({ handshakeError: handshake.error });\n } else {\n this.abortConnecting(); // we don't support switching connections yet\n this.handshakeCallbacks[handshake.action](handshake);\n }\n }\n };\n this.runner = this.strategy.connect(0, callback);\n }\n\n private abortConnecting() {\n if (this.runner) {\n this.runner.abort();\n this.runner = null;\n }\n }\n\n private disconnectInternally() {\n this.abortConnecting();\n this.clearRetryTimer();\n this.clearUnavailableTimer();\n if (this.connection) {\n var connection = this.abandonConnection();\n connection.close();\n }\n }\n\n private updateStrategy() {\n this.strategy = this.options.getStrategy({\n key: this.key,\n timeline: this.timeline,\n useTLS: this.usingTLS\n });\n }\n\n private retryIn(delay) {\n this.timeline.info({ action: 'retry', delay: delay });\n if (delay > 0) {\n this.emit('connecting_in', Math.round(delay / 1000));\n }\n this.retryTimer = new Timer(delay || 0, () => {\n this.disconnectInternally();\n this.connect();\n });\n }\n\n private clearRetryTimer() {\n if (this.retryTimer) {\n this.retryTimer.ensureAborted();\n this.retryTimer = null;\n }\n }\n\n private setUnavailableTimer() {\n this.unavailableTimer = new Timer(this.options.unavailableTimeout, () => {\n this.updateState('unavailable');\n });\n }\n\n private clearUnavailableTimer() {\n if (this.unavailableTimer) {\n this.unavailableTimer.ensureAborted();\n }\n }\n\n private sendActivityCheck() {\n this.stopActivityCheck();\n this.connection.ping();\n // wait for pong response\n this.activityTimer = new Timer(this.options.pongTimeout, () => {\n this.timeline.error({ pong_timed_out: this.options.pongTimeout });\n this.retryIn(0);\n });\n }\n\n private resetActivityCheck() {\n this.stopActivityCheck();\n // send ping after inactivity\n if (this.connection && !this.connection.handlesActivityChecks()) {\n this.activityTimer = new Timer(this.activityTimeout, () => {\n this.sendActivityCheck();\n });\n }\n }\n\n private stopActivityCheck() {\n if (this.activityTimer) {\n this.activityTimer.ensureAborted();\n }\n }\n\n private buildConnectionCallbacks(\n errorCallbacks: ErrorCallbacks\n ): ConnectionCallbacks {\n return Collections.extend({}, errorCallbacks, {\n message: message => {\n // includes pong messages from server\n this.resetActivityCheck();\n this.emit('message', message);\n },\n ping: () => {\n this.send_event('pusher:pong', {});\n },\n activity: () => {\n this.resetActivityCheck();\n },\n error: error => {\n // just emit error to user - socket will already be closed by browser\n this.emit('error', error);\n },\n closed: () => {\n this.abandonConnection();\n if (this.shouldRetry()) {\n this.retryIn(1000);\n }\n }\n });\n }\n\n private buildHandshakeCallbacks(\n errorCallbacks: ErrorCallbacks\n ): HandshakeCallbacks {\n return Collections.extend({}, errorCallbacks, {\n connected: (handshake: HandshakePayload) => {\n this.activityTimeout = Math.min(\n this.options.activityTimeout,\n handshake.activityTimeout,\n handshake.connection.activityTimeout || Infinity\n );\n this.clearUnavailableTimer();\n this.setConnection(handshake.connection);\n this.socket_id = this.connection.id;\n this.updateState('connected', { socket_id: this.socket_id });\n }\n });\n }\n\n private buildErrorCallbacks(): ErrorCallbacks {\n let withErrorEmitted = callback => {\n return (result: Action | HandshakePayload) => {\n if (result.error) {\n this.emit('error', { type: 'WebSocketError', error: result.error });\n }\n callback(result);\n };\n };\n\n return {\n tls_only: withErrorEmitted(() => {\n this.usingTLS = true;\n this.updateStrategy();\n this.retryIn(0);\n }),\n refused: withErrorEmitted(() => {\n this.disconnect();\n }),\n backoff: withErrorEmitted(() => {\n this.retryIn(1000);\n }),\n retry: withErrorEmitted(() => {\n this.retryIn(0);\n })\n };\n }\n\n private setConnection(connection) {\n this.connection = connection;\n for (var event in this.connectionCallbacks) {\n this.connection.bind(event, this.connectionCallbacks[event]);\n }\n this.resetActivityCheck();\n }\n\n private abandonConnection() {\n if (!this.connection) {\n return;\n }\n this.stopActivityCheck();\n for (var event in this.connectionCallbacks) {\n this.connection.unbind(event, this.connectionCallbacks[event]);\n }\n var connection = this.connection;\n this.connection = null;\n return connection;\n }\n\n private updateState(newState: string, data?: any) {\n var previousState = this.state;\n this.state = newState;\n if (previousState !== newState) {\n var newStateDescription = newState;\n if (newStateDescription === 'connected') {\n newStateDescription += ' with new socket ID ' + data.socket_id;\n }\n Logger.debug(\n 'State changed',\n previousState + ' -> ' + newStateDescription\n );\n this.timeline.info({ state: newState, params: data });\n this.emit('state_change', { previous: previousState, current: newState });\n this.emit(newState, data);\n }\n }\n\n private shouldRetry(): boolean {\n return this.state === 'connecting' || this.state === 'connected';\n }\n}\n","import Channel from './channel';\nimport * as Collections from '../utils/collections';\nimport ChannelTable from './channel_table';\nimport Factory from '../utils/factory';\nimport Pusher from '../pusher';\nimport Logger from '../logger';\nimport * as Errors from '../errors';\nimport urlStore from '../utils/url_store';\n\n/** Handles a channel map. */\nexport default class Channels {\n channels: ChannelTable;\n\n constructor() {\n this.channels = {};\n }\n\n /** Creates or retrieves an existing channel by its name.\n *\n * @param {String} name\n * @param {Pusher} pusher\n * @return {Channel}\n */\n add(name: string, pusher: Pusher) {\n if (!this.channels[name]) {\n this.channels[name] = createChannel(name, pusher);\n }\n return this.channels[name];\n }\n\n /** Returns a list of all channels\n *\n * @return {Array}\n */\n all(): Channel[] {\n return Collections.values(this.channels);\n }\n\n /** Finds a channel by its name.\n *\n * @param {String} name\n * @return {Channel} channel or null if it doesn't exist\n */\n find(name: string) {\n return this.channels[name];\n }\n\n /** Removes a channel from the map.\n *\n * @param {String} name\n */\n remove(name: string) {\n var channel = this.channels[name];\n delete this.channels[name];\n return channel;\n }\n\n /** Proxies disconnection signal to all channels. */\n disconnect() {\n Collections.objectApply(this.channels, function(channel) {\n channel.disconnect();\n });\n }\n}\n\nfunction createChannel(name: string, pusher: Pusher): Channel {\n if (name.indexOf('private-encrypted-') === 0) {\n if (pusher.config.nacl) {\n return Factory.createEncryptedChannel(name, pusher, pusher.config.nacl);\n }\n let errMsg =\n 'Tried to subscribe to a private-encrypted- channel but no nacl implementation available';\n let suffix = urlStore.buildLogSuffix('encryptedChannelSupport');\n throw new Errors.UnsupportedFeature(`${errMsg}. ${suffix}`);\n } else if (name.indexOf('private-') === 0) {\n return Factory.createPrivateChannel(name, pusher);\n } else if (name.indexOf('presence-') === 0) {\n return Factory.createPresenceChannel(name, pusher);\n } else if (name.indexOf('#') === 0) {\n throw new Errors.BadChannelName(\n 'Cannot create a channel with name \"' + name + '\".'\n );\n } else {\n return Factory.createChannel(name, pusher);\n }\n}\n","import AssistantToTheTransportManager from '../transports/assistant_to_the_transport_manager';\nimport PingDelayOptions from '../transports/ping_delay_options';\nimport Transport from '../transports/transport';\nimport TransportManager from '../transports/transport_manager';\nimport Handshake from '../connection/handshake';\nimport TransportConnection from '../transports/transport_connection';\nimport SocketHooks from '../http/socket_hooks';\nimport HTTPSocket from '../http/http_socket';\n\nimport Timeline from '../timeline/timeline';\nimport {\n default as TimelineSender,\n TimelineSenderOptions\n} from '../timeline/timeline_sender';\nimport PresenceChannel from '../channels/presence_channel';\nimport PrivateChannel from '../channels/private_channel';\nimport EncryptedChannel from '../channels/encrypted_channel';\nimport Channel from '../channels/channel';\nimport ConnectionManager from '../connection/connection_manager';\nimport ConnectionManagerOptions from '../connection/connection_manager_options';\nimport Ajax from '../http/ajax';\nimport Channels from '../channels/channels';\nimport Pusher from '../pusher';\nimport { Config } from '../config';\nimport * as nacl from 'tweetnacl';\n\nvar Factory = {\n createChannels(): Channels {\n return new Channels();\n },\n\n createConnectionManager(\n key: string,\n options: ConnectionManagerOptions\n ): ConnectionManager {\n return new ConnectionManager(key, options);\n },\n\n createChannel(name: string, pusher: Pusher): Channel {\n return new Channel(name, pusher);\n },\n\n createPrivateChannel(name: string, pusher: Pusher): PrivateChannel {\n return new PrivateChannel(name, pusher);\n },\n\n createPresenceChannel(name: string, pusher: Pusher): PresenceChannel {\n return new PresenceChannel(name, pusher);\n },\n\n createEncryptedChannel(\n name: string,\n pusher: Pusher,\n nacl: nacl\n ): EncryptedChannel {\n return new EncryptedChannel(name, pusher, nacl);\n },\n\n createTimelineSender(timeline: Timeline, options: TimelineSenderOptions) {\n return new TimelineSender(timeline, options);\n },\n\n createHandshake(\n transport: TransportConnection,\n callback: (HandshakePayload) => void\n ): Handshake {\n return new Handshake(transport, callback);\n },\n\n createAssistantToTheTransportManager(\n manager: TransportManager,\n transport: Transport,\n options: PingDelayOptions\n ): AssistantToTheTransportManager {\n return new AssistantToTheTransportManager(manager, transport, options);\n }\n};\n\nexport default Factory;\n","import AssistantToTheTransportManager from './assistant_to_the_transport_manager';\nimport Transport from './transport';\nimport PingDelayOptions from './ping_delay_options';\nimport Factory from '../utils/factory';\n\nexport interface TransportManagerOptions extends PingDelayOptions {\n lives?: number;\n}\n\n/** Keeps track of the number of lives left for a transport.\n *\n * In the beginning of a session, transports may be assigned a number of\n * lives. When an AssistantToTheTransportManager instance reports a transport\n * connection closed uncleanly, the transport loses a life. When the number\n * of lives drops to zero, the transport gets disabled by its manager.\n *\n * @param {Object} options\n */\nexport default class TransportManager {\n options: TransportManagerOptions;\n livesLeft: number;\n\n constructor(options: TransportManagerOptions) {\n this.options = options || {};\n this.livesLeft = this.options.lives || Infinity;\n }\n\n /** Creates a assistant for the transport.\n *\n * @param {Transport} transport\n * @returns {AssistantToTheTransportManager}\n */\n getAssistant(transport: Transport): AssistantToTheTransportManager {\n return Factory.createAssistantToTheTransportManager(this, transport, {\n minPingDelay: this.options.minPingDelay,\n maxPingDelay: this.options.maxPingDelay\n });\n }\n\n /** Returns whether the transport has any lives left.\n *\n * @returns {Boolean}\n */\n isAlive(): boolean {\n return this.livesLeft > 0;\n }\n\n /** Takes one life from the transport. */\n reportDeath() {\n this.livesLeft -= 1;\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport { OneOffTimer as Timer } from '../utils/timers';\nimport Strategy from './strategy';\nimport StrategyOptions from './strategy_options';\n\n/** Loops through strategies with optional timeouts.\n *\n * Options:\n * - loop - whether it should loop through the substrategy list\n * - timeout - initial timeout for a single substrategy\n * - timeoutLimit - maximum timeout\n *\n * @param {Strategy[]} strategies\n * @param {Object} options\n */\nexport default class SequentialStrategy implements Strategy {\n strategies: Strategy[];\n loop: boolean;\n failFast: boolean;\n timeout: number;\n timeoutLimit: number;\n\n constructor(strategies: Strategy[], options: StrategyOptions) {\n this.strategies = strategies;\n this.loop = Boolean(options.loop);\n this.failFast = Boolean(options.failFast);\n this.timeout = options.timeout;\n this.timeoutLimit = options.timeoutLimit;\n }\n\n isSupported(): boolean {\n return Collections.any(this.strategies, Util.method('isSupported'));\n }\n\n connect(minPriority: number, callback: Function) {\n var strategies = this.strategies;\n var current = 0;\n var timeout = this.timeout;\n var runner = null;\n\n var tryNextStrategy = (error, handshake) => {\n if (handshake) {\n callback(null, handshake);\n } else {\n current = current + 1;\n if (this.loop) {\n current = current % strategies.length;\n }\n\n if (current < strategies.length) {\n if (timeout) {\n timeout = timeout * 2;\n if (this.timeoutLimit) {\n timeout = Math.min(timeout, this.timeoutLimit);\n }\n }\n runner = this.tryStrategy(\n strategies[current],\n minPriority,\n { timeout, failFast: this.failFast },\n tryNextStrategy\n );\n } else {\n callback(true);\n }\n }\n };\n\n runner = this.tryStrategy(\n strategies[current],\n minPriority,\n { timeout: timeout, failFast: this.failFast },\n tryNextStrategy\n );\n\n return {\n abort: function() {\n runner.abort();\n },\n forceMinPriority: function(p) {\n minPriority = p;\n if (runner) {\n runner.forceMinPriority(p);\n }\n }\n };\n }\n\n private tryStrategy(\n strategy: Strategy,\n minPriority: number,\n options: StrategyOptions,\n callback: Function\n ) {\n var timer = null;\n var runner = null;\n\n if (options.timeout > 0) {\n timer = new Timer(options.timeout, function() {\n runner.abort();\n callback(true);\n });\n }\n\n runner = strategy.connect(minPriority, function(error, handshake) {\n if (error && timer && timer.isRunning() && !options.failFast) {\n // advance to the next strategy after the timeout\n return;\n }\n if (timer) {\n timer.ensureAborted();\n }\n callback(error, handshake);\n });\n\n return {\n abort: function() {\n if (timer) {\n timer.ensureAborted();\n }\n runner.abort();\n },\n forceMinPriority: function(p) {\n runner.forceMinPriority(p);\n }\n };\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport Strategy from './strategy';\n\n/** Launches all substrategies and emits prioritized connected transports.\n *\n * @param {Array} strategies\n */\nexport default class BestConnectedEverStrategy implements Strategy {\n strategies: Strategy[];\n\n constructor(strategies: Strategy[]) {\n this.strategies = strategies;\n }\n\n isSupported(): boolean {\n return Collections.any(this.strategies, Util.method('isSupported'));\n }\n\n connect(minPriority: number, callback: Function) {\n return connect(this.strategies, minPriority, function(i, runners) {\n return function(error, handshake) {\n runners[i].error = error;\n if (error) {\n if (allRunnersFailed(runners)) {\n callback(true);\n }\n return;\n }\n Collections.apply(runners, function(runner) {\n runner.forceMinPriority(handshake.transport.priority);\n });\n callback(null, handshake);\n };\n });\n }\n}\n\n/** Connects to all strategies in parallel.\n *\n * Callback builder should be a function that takes two arguments: index\n * and a list of runners. It should return another function that will be\n * passed to the substrategy with given index. Runners can be aborted using\n * abortRunner(s) functions from this class.\n *\n * @param {Array} strategies\n * @param {Function} callbackBuilder\n * @return {Object} strategy runner\n */\nfunction connect(\n strategies: Strategy[],\n minPriority: number,\n callbackBuilder: Function\n) {\n var runners = Collections.map(strategies, function(strategy, i, _, rs) {\n return strategy.connect(minPriority, callbackBuilder(i, rs));\n });\n return {\n abort: function() {\n Collections.apply(runners, abortRunner);\n },\n forceMinPriority: function(p) {\n Collections.apply(runners, function(runner) {\n runner.forceMinPriority(p);\n });\n }\n };\n}\n\nfunction allRunnersFailed(runners): boolean {\n return Collections.all(runners, function(runner) {\n return Boolean(runner.error);\n });\n}\n\nfunction abortRunner(runner) {\n if (!runner.error && !runner.aborted) {\n runner.abort();\n runner.aborted = true;\n }\n}\n","import Util from '../util';\nimport Runtime from 'runtime';\nimport Strategy from './strategy';\nimport SequentialStrategy from './sequential_strategy';\nimport StrategyOptions from './strategy_options';\nimport TransportStrategy from './transport_strategy';\nimport Timeline from '../timeline/timeline';\nimport * as Collections from '../utils/collections';\n\nexport interface TransportStrategyDictionary {\n [key: string]: TransportStrategy;\n}\n\n/** Caches the last successful transport and, after the first few attempts,\n * uses the cached transport for subsequent attempts.\n *\n * @param {Strategy} strategy\n * @param {Object} transports\n * @param {Object} options\n */\nexport default class WebSocketPrioritizedCachedStrategy implements Strategy {\n strategy: Strategy;\n transports: TransportStrategyDictionary;\n ttl: number;\n usingTLS: boolean;\n timeline: Timeline;\n\n constructor(\n strategy: Strategy,\n transports: TransportStrategyDictionary,\n options: StrategyOptions\n ) {\n this.strategy = strategy;\n this.transports = transports;\n this.ttl = options.ttl || 1800 * 1000;\n this.usingTLS = options.useTLS;\n this.timeline = options.timeline;\n }\n\n isSupported(): boolean {\n return this.strategy.isSupported();\n }\n\n connect(minPriority: number, callback: Function) {\n var usingTLS = this.usingTLS;\n var info = fetchTransportCache(usingTLS);\n var cacheSkipCount = info && info.cacheSkipCount ? info.cacheSkipCount : 0;\n\n var strategies = [this.strategy];\n if (info && info.timestamp + this.ttl >= Util.now()) {\n var transport = this.transports[info.transport];\n if (transport) {\n if (['ws', 'wss'].includes(info.transport) || cacheSkipCount > 3) {\n this.timeline.info({\n cached: true,\n transport: info.transport,\n latency: info.latency\n });\n strategies.push(\n new SequentialStrategy([transport], {\n timeout: info.latency * 2 + 1000,\n failFast: true\n })\n );\n } else {\n cacheSkipCount++;\n }\n }\n }\n\n var startTimestamp = Util.now();\n var runner = strategies\n .pop()\n .connect(minPriority, function cb(error, handshake) {\n if (error) {\n flushTransportCache(usingTLS);\n if (strategies.length > 0) {\n startTimestamp = Util.now();\n runner = strategies.pop().connect(minPriority, cb);\n } else {\n callback(error);\n }\n } else {\n storeTransportCache(\n usingTLS,\n handshake.transport.name,\n Util.now() - startTimestamp,\n cacheSkipCount\n );\n callback(null, handshake);\n }\n });\n\n return {\n abort: function() {\n runner.abort();\n },\n forceMinPriority: function(p) {\n minPriority = p;\n if (runner) {\n runner.forceMinPriority(p);\n }\n }\n };\n }\n}\n\nfunction getTransportCacheKey(usingTLS: boolean): string {\n return 'pusherTransport' + (usingTLS ? 'TLS' : 'NonTLS');\n}\n\nfunction fetchTransportCache(usingTLS: boolean): any {\n var storage = Runtime.getLocalStorage();\n if (storage) {\n try {\n var serializedCache = storage[getTransportCacheKey(usingTLS)];\n if (serializedCache) {\n return JSON.parse(serializedCache);\n }\n } catch (e) {\n flushTransportCache(usingTLS);\n }\n }\n return null;\n}\n\nfunction storeTransportCache(\n usingTLS: boolean,\n transport: TransportStrategy,\n latency: number,\n cacheSkipCount: number\n) {\n var storage = Runtime.getLocalStorage();\n if (storage) {\n try {\n storage[getTransportCacheKey(usingTLS)] = Collections.safeJSONStringify({\n timestamp: Util.now(),\n transport: transport,\n latency: latency,\n cacheSkipCount: cacheSkipCount\n });\n } catch (e) {\n // catch over quota exceptions raised by localStorage\n }\n }\n}\n\nfunction flushTransportCache(usingTLS: boolean) {\n var storage = Runtime.getLocalStorage();\n if (storage) {\n try {\n delete storage[getTransportCacheKey(usingTLS)];\n } catch (e) {\n // catch exceptions raised by localStorage\n }\n }\n}\n","import { OneOffTimer as Timer } from '../utils/timers';\nimport Strategy from './strategy';\nimport StrategyOptions from './strategy_options';\n\n/** Runs substrategy after specified delay.\n *\n * Options:\n * - delay - time in miliseconds to delay the substrategy attempt\n *\n * @param {Strategy} strategy\n * @param {Object} options\n */\nexport default class DelayedStrategy implements Strategy {\n strategy: Strategy;\n options: { delay: number };\n\n constructor(strategy: Strategy, { delay: number }) {\n this.strategy = strategy;\n this.options = { delay: number };\n }\n\n isSupported(): boolean {\n return this.strategy.isSupported();\n }\n\n connect(minPriority: number, callback: Function) {\n var strategy = this.strategy;\n var runner;\n var timer = new Timer(this.options.delay, function() {\n runner = strategy.connect(minPriority, callback);\n });\n\n return {\n abort: function() {\n timer.ensureAborted();\n if (runner) {\n runner.abort();\n }\n },\n forceMinPriority: function(p) {\n minPriority = p;\n if (runner) {\n runner.forceMinPriority(p);\n }\n }\n };\n }\n}\n","import Strategy from './strategy';\nimport StrategyRunner from './strategy_runner';\n\n/** Proxies method calls to one of substrategies basing on the test function.\n *\n * @param {Function} test\n * @param {Strategy} trueBranch strategy used when test returns true\n * @param {Strategy} falseBranch strategy used when test returns false\n */\nexport default class IfStrategy implements Strategy {\n test: () => boolean;\n trueBranch: Strategy;\n falseBranch: Strategy;\n\n constructor(\n test: () => boolean,\n trueBranch: Strategy,\n falseBranch: Strategy\n ) {\n this.test = test;\n this.trueBranch = trueBranch;\n this.falseBranch = falseBranch;\n }\n\n isSupported(): boolean {\n var branch = this.test() ? this.trueBranch : this.falseBranch;\n return branch.isSupported();\n }\n\n connect(minPriority: number, callback: Function): StrategyRunner {\n var branch = this.test() ? this.trueBranch : this.falseBranch;\n return branch.connect(minPriority, callback);\n }\n}\n","import Strategy from './strategy';\nimport StrategyRunner from './strategy_runner';\n\n/** Launches the substrategy and terminates on the first open connection.\n *\n * @param {Strategy} strategy\n */\nexport default class FirstConnectedStrategy implements Strategy {\n strategy: Strategy;\n\n constructor(strategy: Strategy) {\n this.strategy = strategy;\n }\n\n isSupported(): boolean {\n return this.strategy.isSupported();\n }\n\n connect(minPriority: number, callback: Function): StrategyRunner {\n var runner = this.strategy.connect(minPriority, function(error, handshake) {\n if (handshake) {\n runner.abort();\n }\n callback(error, handshake);\n });\n return runner;\n }\n}\n","import * as Collections from 'core/utils/collections';\nimport TransportManager from 'core/transports/transport_manager';\nimport Strategy from 'core/strategies/strategy';\nimport StrategyOptions from 'core/strategies/strategy_options';\nimport SequentialStrategy from 'core/strategies/sequential_strategy';\nimport BestConnectedEverStrategy from 'core/strategies/best_connected_ever_strategy';\nimport WebSocketPrioritizedCachedStrategy, {\n TransportStrategyDictionary\n} from 'core/strategies/websocket_prioritized_cached_strategy';\nimport DelayedStrategy from 'core/strategies/delayed_strategy';\nimport IfStrategy from 'core/strategies/if_strategy';\nimport FirstConnectedStrategy from 'core/strategies/first_connected_strategy';\nimport { Config } from 'core/config';\n\nfunction testSupportsStrategy(strategy: Strategy) {\n return function() {\n return strategy.isSupported();\n };\n}\n\nvar getDefaultStrategy = function(\n config: Config,\n baseOptions: StrategyOptions,\n defineTransport: Function\n): Strategy {\n var definedTransports = {};\n\n function defineTransportStrategy(\n name: string,\n type: string,\n priority: number,\n options: StrategyOptions,\n manager?: TransportManager\n ) {\n var transport = defineTransport(\n config,\n name,\n type,\n priority,\n options,\n manager\n );\n\n definedTransports[name] = transport;\n\n return transport;\n }\n\n var ws_options: StrategyOptions = Object.assign({}, baseOptions, {\n hostNonTLS: config.wsHost + ':' + config.wsPort,\n hostTLS: config.wsHost + ':' + config.wssPort,\n httpPath: config.wsPath\n });\n var wss_options: StrategyOptions = Object.assign({}, ws_options, {\n useTLS: true\n });\n var sockjs_options: StrategyOptions = Object.assign({}, baseOptions, {\n hostNonTLS: config.httpHost + ':' + config.httpPort,\n hostTLS: config.httpHost + ':' + config.httpsPort,\n httpPath: config.httpPath\n });\n\n var timeouts = {\n loop: true,\n timeout: 15000,\n timeoutLimit: 60000\n };\n\n var ws_manager = new TransportManager({\n minPingDelay: 10000,\n maxPingDelay: config.activityTimeout\n });\n var streaming_manager = new TransportManager({\n lives: 2,\n minPingDelay: 10000,\n maxPingDelay: config.activityTimeout\n });\n\n var ws_transport = defineTransportStrategy(\n 'ws',\n 'ws',\n 3,\n ws_options,\n ws_manager\n );\n var wss_transport = defineTransportStrategy(\n 'wss',\n 'ws',\n 3,\n wss_options,\n ws_manager\n );\n var sockjs_transport = defineTransportStrategy(\n 'sockjs',\n 'sockjs',\n 1,\n sockjs_options\n );\n var xhr_streaming_transport = defineTransportStrategy(\n 'xhr_streaming',\n 'xhr_streaming',\n 1,\n sockjs_options,\n streaming_manager\n );\n var xdr_streaming_transport = defineTransportStrategy(\n 'xdr_streaming',\n 'xdr_streaming',\n 1,\n sockjs_options,\n streaming_manager\n );\n var xhr_polling_transport = defineTransportStrategy(\n 'xhr_polling',\n 'xhr_polling',\n 1,\n sockjs_options\n );\n var xdr_polling_transport = defineTransportStrategy(\n 'xdr_polling',\n 'xdr_polling',\n 1,\n sockjs_options\n );\n\n var ws_loop = new SequentialStrategy([ws_transport], timeouts);\n var wss_loop = new SequentialStrategy([wss_transport], timeouts);\n var sockjs_loop = new SequentialStrategy([sockjs_transport], timeouts);\n var streaming_loop = new SequentialStrategy(\n [\n new IfStrategy(\n testSupportsStrategy(xhr_streaming_transport),\n xhr_streaming_transport,\n xdr_streaming_transport\n )\n ],\n timeouts\n );\n var polling_loop = new SequentialStrategy(\n [\n new IfStrategy(\n testSupportsStrategy(xhr_polling_transport),\n xhr_polling_transport,\n xdr_polling_transport\n )\n ],\n timeouts\n );\n\n var http_loop = new SequentialStrategy(\n [\n new IfStrategy(\n testSupportsStrategy(streaming_loop),\n new BestConnectedEverStrategy([\n streaming_loop,\n new DelayedStrategy(polling_loop, { delay: 4000 })\n ]),\n polling_loop\n )\n ],\n timeouts\n );\n\n var http_fallback_loop = new IfStrategy(\n testSupportsStrategy(http_loop),\n http_loop,\n sockjs_loop\n );\n\n var wsStrategy;\n if (baseOptions.useTLS) {\n wsStrategy = new BestConnectedEverStrategy([\n ws_loop,\n new DelayedStrategy(http_fallback_loop, { delay: 2000 })\n ]);\n } else {\n wsStrategy = new BestConnectedEverStrategy([\n ws_loop,\n new DelayedStrategy(wss_loop, { delay: 2000 }),\n new DelayedStrategy(http_fallback_loop, { delay: 5000 })\n ]);\n }\n\n return new WebSocketPrioritizedCachedStrategy(\n new FirstConnectedStrategy(\n new IfStrategy(\n testSupportsStrategy(ws_transport),\n wsStrategy,\n http_fallback_loop\n )\n ),\n definedTransports,\n {\n ttl: 1800000,\n timeline: baseOptions.timeline,\n useTLS: baseOptions.useTLS\n }\n );\n};\n\nexport default getDefaultStrategy;\n","import { Dependencies } from '../dom/dependencies';\n\n/** Initializes the transport.\n *\n * Fetches resources if needed and then transitions to initialized.\n */\nexport default function() {\n var self = this;\n\n self.timeline.info(\n self.buildTimelineMessage({\n transport: self.name + (self.options.useTLS ? 's' : '')\n })\n );\n\n if (self.hooks.isInitialized()) {\n self.changeState('initialized');\n } else if (self.hooks.file) {\n self.changeState('initializing');\n Dependencies.load(\n self.hooks.file,\n { useTLS: self.options.useTLS },\n function(error, callback) {\n if (self.hooks.isInitialized()) {\n self.changeState('initialized');\n callback(true);\n } else {\n if (error) {\n self.onError(error);\n }\n self.onClose();\n callback(false);\n }\n }\n );\n } else {\n self.onClose();\n }\n}\n","import HTTPRequest from 'core/http/http_request';\nimport RequestHooks from 'core/http/request_hooks';\nimport Ajax from 'core/http/ajax';\nimport * as Errors from 'core/errors';\n\nvar hooks: RequestHooks = {\n getRequest: function(socket: HTTPRequest): Ajax {\n var xdr = new (window).XDomainRequest();\n xdr.ontimeout = function() {\n socket.emit('error', new Errors.RequestTimedOut());\n socket.close();\n };\n xdr.onerror = function(e) {\n socket.emit('error', e);\n socket.close();\n };\n xdr.onprogress = function() {\n if (xdr.responseText && xdr.responseText.length > 0) {\n socket.onChunk(200, xdr.responseText);\n }\n };\n xdr.onload = function() {\n if (xdr.responseText && xdr.responseText.length > 0) {\n socket.onChunk(200, xdr.responseText);\n }\n socket.emit('finished', 200);\n socket.close();\n };\n return xdr;\n },\n abortRequest: function(xdr: Ajax) {\n xdr.ontimeout = xdr.onerror = xdr.onprogress = xdr.onload = null;\n xdr.abort();\n }\n};\n\nexport default hooks;\n","import Runtime from 'runtime';\nimport RequestHooks from './request_hooks';\nimport Ajax from './ajax';\nimport { default as EventsDispatcher } from '../events/dispatcher';\n\nconst MAX_BUFFER_LENGTH = 256 * 1024;\n\nexport default class HTTPRequest extends EventsDispatcher {\n hooks: RequestHooks;\n method: string;\n url: string;\n position: number;\n xhr: Ajax;\n unloader: Function;\n\n constructor(hooks: RequestHooks, method: string, url: string) {\n super();\n this.hooks = hooks;\n this.method = method;\n this.url = url;\n }\n\n start(payload?: any) {\n this.position = 0;\n this.xhr = this.hooks.getRequest(this);\n\n this.unloader = () => {\n this.close();\n };\n Runtime.addUnloadListener(this.unloader);\n\n this.xhr.open(this.method, this.url, true);\n\n if (this.xhr.setRequestHeader) {\n this.xhr.setRequestHeader('Content-Type', 'application/json'); // ReactNative doesn't set this header by default.\n }\n this.xhr.send(payload);\n }\n\n close() {\n if (this.unloader) {\n Runtime.removeUnloadListener(this.unloader);\n this.unloader = null;\n }\n if (this.xhr) {\n this.hooks.abortRequest(this.xhr);\n this.xhr = null;\n }\n }\n\n onChunk(status: number, data: any) {\n while (true) {\n var chunk = this.advanceBuffer(data);\n if (chunk) {\n this.emit('chunk', { status: status, data: chunk });\n } else {\n break;\n }\n }\n if (this.isBufferTooLong(data)) {\n this.emit('buffer_too_long');\n }\n }\n\n private advanceBuffer(buffer: any[]): any {\n var unreadData = buffer.slice(this.position);\n var endOfLinePosition = unreadData.indexOf('\\n');\n\n if (endOfLinePosition !== -1) {\n this.position += endOfLinePosition + 1;\n return unreadData.slice(0, endOfLinePosition);\n } else {\n // chunk is not finished yet, don't move the buffer pointer\n return null;\n }\n }\n\n private isBufferTooLong(buffer: any): boolean {\n return this.position === buffer.length && buffer.length > MAX_BUFFER_LENGTH;\n }\n}\n","enum State {\n CONNECTING = 0,\n OPEN = 1,\n CLOSED = 3\n}\n\nexport default State;\n","import URLLocation from './url_location';\nimport State from './state';\nimport Socket from '../socket';\nimport SocketHooks from './socket_hooks';\nimport Util from '../util';\nimport Ajax from './ajax';\nimport HTTPRequest from './http_request';\nimport Runtime from 'runtime';\n\nvar autoIncrement = 1;\n\nclass HTTPSocket implements Socket {\n hooks: SocketHooks;\n session: string;\n location: URLLocation;\n readyState: State;\n stream: HTTPRequest;\n\n onopen: () => void;\n onerror: (error: any) => void;\n onclose: (closeEvent: any) => void;\n onmessage: (message: any) => void;\n onactivity: () => void;\n\n constructor(hooks: SocketHooks, url: string) {\n this.hooks = hooks;\n this.session = randomNumber(1000) + '/' + randomString(8);\n this.location = getLocation(url);\n this.readyState = State.CONNECTING;\n this.openStream();\n }\n\n send(payload: any) {\n return this.sendRaw(JSON.stringify([payload]));\n }\n\n ping() {\n this.hooks.sendHeartbeat(this);\n }\n\n close(code: any, reason: any) {\n this.onClose(code, reason, true);\n }\n\n /** For internal use only */\n sendRaw(payload: any): boolean {\n if (this.readyState === State.OPEN) {\n try {\n Runtime.createSocketRequest(\n 'POST',\n getUniqueURL(getSendURL(this.location, this.session))\n ).start(payload);\n return true;\n } catch (e) {\n return false;\n }\n } else {\n return false;\n }\n }\n\n /** For internal use only */\n reconnect() {\n this.closeStream();\n this.openStream();\n }\n\n /** For internal use only */\n onClose(code, reason, wasClean) {\n this.closeStream();\n this.readyState = State.CLOSED;\n if (this.onclose) {\n this.onclose({\n code: code,\n reason: reason,\n wasClean: wasClean\n });\n }\n }\n\n private onChunk(chunk) {\n if (chunk.status !== 200) {\n return;\n }\n if (this.readyState === State.OPEN) {\n this.onActivity();\n }\n\n var payload;\n var type = chunk.data.slice(0, 1);\n switch (type) {\n case 'o':\n payload = JSON.parse(chunk.data.slice(1) || '{}');\n this.onOpen(payload);\n break;\n case 'a':\n payload = JSON.parse(chunk.data.slice(1) || '[]');\n for (var i = 0; i < payload.length; i++) {\n this.onEvent(payload[i]);\n }\n break;\n case 'm':\n payload = JSON.parse(chunk.data.slice(1) || 'null');\n this.onEvent(payload);\n break;\n case 'h':\n this.hooks.onHeartbeat(this);\n break;\n case 'c':\n payload = JSON.parse(chunk.data.slice(1) || '[]');\n this.onClose(payload[0], payload[1], true);\n break;\n }\n }\n\n private onOpen(options) {\n if (this.readyState === State.CONNECTING) {\n if (options && options.hostname) {\n this.location.base = replaceHost(this.location.base, options.hostname);\n }\n this.readyState = State.OPEN;\n\n if (this.onopen) {\n this.onopen();\n }\n } else {\n this.onClose(1006, 'Server lost session', true);\n }\n }\n\n private onEvent(event) {\n if (this.readyState === State.OPEN && this.onmessage) {\n this.onmessage({ data: event });\n }\n }\n\n private onActivity() {\n if (this.onactivity) {\n this.onactivity();\n }\n }\n\n private onError(error) {\n if (this.onerror) {\n this.onerror(error);\n }\n }\n\n private openStream() {\n this.stream = Runtime.createSocketRequest(\n 'POST',\n getUniqueURL(this.hooks.getReceiveURL(this.location, this.session))\n );\n\n this.stream.bind('chunk', chunk => {\n this.onChunk(chunk);\n });\n this.stream.bind('finished', status => {\n this.hooks.onFinished(this, status);\n });\n this.stream.bind('buffer_too_long', () => {\n this.reconnect();\n });\n\n try {\n this.stream.start();\n } catch (error) {\n Util.defer(() => {\n this.onError(error);\n this.onClose(1006, 'Could not start streaming', false);\n });\n }\n }\n\n private closeStream() {\n if (this.stream) {\n this.stream.unbind_all();\n this.stream.close();\n this.stream = null;\n }\n }\n}\n\nfunction getLocation(url): URLLocation {\n var parts = /([^\\?]*)\\/*(\\??.*)/.exec(url);\n return {\n base: parts[1],\n queryString: parts[2]\n };\n}\n\nfunction getSendURL(url: URLLocation, session: string): string {\n return url.base + '/' + session + '/xhr_send';\n}\n\nfunction getUniqueURL(url: string): string {\n var separator = url.indexOf('?') === -1 ? '?' : '&';\n return url + separator + 't=' + +new Date() + '&n=' + autoIncrement++;\n}\n\nfunction replaceHost(url: string, hostname: string): string {\n var urlParts = /(https?:\\/\\/)([^\\/:]+)((\\/|:)?.*)/.exec(url);\n return urlParts[1] + hostname + urlParts[3];\n}\n\nfunction randomNumber(max: number): number {\n return Runtime.randomInt(max);\n}\n\nfunction randomString(length: number): string {\n var result = [];\n\n for (var i = 0; i < length; i++) {\n result.push(randomNumber(32).toString(32));\n }\n\n return result.join('');\n}\n\nexport default HTTPSocket;\n","import SocketHooks from './socket_hooks';\nimport HTTPSocket from './http_socket';\n\nvar hooks: SocketHooks = {\n getReceiveURL: function(url, session) {\n return url.base + '/' + session + '/xhr_streaming' + url.queryString;\n },\n onHeartbeat: function(socket) {\n socket.sendRaw('[]');\n },\n sendHeartbeat: function(socket) {\n socket.sendRaw('[]');\n },\n onFinished: function(socket, status) {\n socket.onClose(1006, 'Connection interrupted (' + status + ')', false);\n }\n};\n\nexport default hooks;\n","import SocketHooks from './socket_hooks';\nimport URLLocation from './url_location';\nimport HTTPSocket from './http_socket';\n\nvar hooks: SocketHooks = {\n getReceiveURL: function(url: URLLocation, session: string): string {\n return url.base + '/' + session + '/xhr' + url.queryString;\n },\n onHeartbeat: function() {\n // next HTTP request will reset server's activity timer\n },\n sendHeartbeat: function(socket) {\n socket.sendRaw('[]');\n },\n onFinished: function(socket, status) {\n if (status === 200) {\n socket.reconnect();\n } else {\n socket.onClose(1006, 'Connection interrupted (' + status + ')', false);\n }\n }\n};\n\nexport default hooks;\n","import HTTPRequest from 'core/http/http_request';\nimport RequestHooks from 'core/http/request_hooks';\nimport Ajax from 'core/http/ajax';\nimport Runtime from 'runtime';\n\nvar hooks: RequestHooks = {\n getRequest: function(socket: HTTPRequest): Ajax {\n var Constructor = Runtime.getXHRAPI();\n var xhr = new Constructor();\n xhr.onreadystatechange = xhr.onprogress = function() {\n switch (xhr.readyState) {\n case 3:\n if (xhr.responseText && xhr.responseText.length > 0) {\n socket.onChunk(xhr.status, xhr.responseText);\n }\n break;\n case 4:\n // this happens only on errors, never after calling close\n if (xhr.responseText && xhr.responseText.length > 0) {\n socket.onChunk(xhr.status, xhr.responseText);\n }\n socket.emit('finished', xhr.status);\n socket.close();\n break;\n }\n };\n return xhr;\n },\n abortRequest: function(xhr: Ajax) {\n xhr.onreadystatechange = null;\n xhr.abort();\n }\n};\n\nexport default hooks;\n","import HTTPRequest from 'core/http/http_request';\nimport HTTPSocket from 'core/http/http_socket';\nimport SocketHooks from 'core/http/socket_hooks';\nimport RequestHooks from 'core/http/request_hooks';\nimport streamingHooks from 'core/http/http_streaming_socket';\nimport pollingHooks from 'core/http/http_polling_socket';\nimport xhrHooks from './http_xhr_request';\nimport HTTPFactory from 'core/http/http_factory';\n\nvar HTTP: HTTPFactory = {\n createStreamingSocket(url: string): HTTPSocket {\n return this.createSocket(streamingHooks, url);\n },\n\n createPollingSocket(url: string): HTTPSocket {\n return this.createSocket(pollingHooks, url);\n },\n\n createSocket(hooks: SocketHooks, url: string): HTTPSocket {\n return new HTTPSocket(hooks, url);\n },\n\n createXHR(method: string, url: string): HTTPRequest {\n return this.createRequest(xhrHooks, method, url);\n },\n\n createRequest(hooks: RequestHooks, method: string, url: string): HTTPRequest {\n return new HTTPRequest(hooks, method, url);\n }\n};\n\nexport default HTTP;\n","import xdrHooks from './http_xdomain_request';\nimport HTTP from 'isomorphic/http/http';\n\nHTTP.createXDR = function(method, url) {\n return this.createRequest(xdrHooks, method, url);\n};\n\nexport default HTTP;\n","import Browser from './browser';\nimport { Dependencies, DependenciesReceivers } from './dom/dependencies';\nimport { AuthTransport, AuthTransports } from 'core/auth/auth_transports';\nimport xhrAuth from 'isomorphic/auth/xhr_auth';\nimport jsonpAuth from './auth/jsonp_auth';\nimport TimelineTransport from 'core/timeline/timeline_transport';\nimport TimelineSender from 'core/timeline/timeline_sender';\nimport ScriptRequest from './dom/script_request';\nimport JSONPRequest from './dom/jsonp_request';\nimport * as Collections from 'core/utils/collections';\nimport { ScriptReceivers } from './dom/script_receiver_factory';\nimport jsonpTimeline from './timeline/jsonp_timeline';\nimport Transports from './transports/transports';\nimport Ajax from 'core/http/ajax';\nimport { Network } from './net_info';\nimport getDefaultStrategy from './default_strategy';\nimport transportConnectionInitializer from './transports/transport_connection_initializer';\nimport HTTPFactory from './http/http';\nimport HTTPRequest from 'core/http/http_request';\n\nvar Runtime: Browser = {\n // for jsonp auth\n nextAuthCallbackID: 1,\n auth_callbacks: {},\n ScriptReceivers,\n DependenciesReceivers,\n getDefaultStrategy,\n Transports,\n transportConnectionInitializer,\n HTTPFactory,\n\n TimelineTransport: jsonpTimeline,\n\n getXHRAPI() {\n return window.XMLHttpRequest;\n },\n\n getWebSocketAPI() {\n return window.WebSocket || window.MozWebSocket;\n },\n\n setup(PusherClass): void {\n (window).Pusher = PusherClass; // JSONp requires Pusher to be in the global scope.\n var initializeOnDocumentBody = () => {\n this.onDocumentBody(PusherClass.ready);\n };\n if (!(window).JSON) {\n Dependencies.load('json2', {}, initializeOnDocumentBody);\n } else {\n initializeOnDocumentBody();\n }\n },\n\n getDocument(): Document {\n return document;\n },\n\n getProtocol(): string {\n return this.getDocument().location.protocol;\n },\n\n getAuthorizers(): AuthTransports {\n return { ajax: xhrAuth, jsonp: jsonpAuth };\n },\n\n onDocumentBody(callback: Function) {\n if (document.body) {\n callback();\n } else {\n setTimeout(() => {\n this.onDocumentBody(callback);\n }, 0);\n }\n },\n\n createJSONPRequest(url: string, data: any): JSONPRequest {\n return new JSONPRequest(url, data);\n },\n\n createScriptRequest(src: string): ScriptRequest {\n return new ScriptRequest(src);\n },\n\n getLocalStorage() {\n try {\n return window.localStorage;\n } catch (e) {\n return undefined;\n }\n },\n\n createXHR(): Ajax {\n if (this.getXHRAPI()) {\n return this.createXMLHttpRequest();\n } else {\n return this.createMicrosoftXHR();\n }\n },\n\n createXMLHttpRequest(): Ajax {\n var Constructor = this.getXHRAPI();\n return new Constructor();\n },\n\n createMicrosoftXHR(): Ajax {\n return new ActiveXObject('Microsoft.XMLHTTP');\n },\n\n getNetwork() {\n return Network;\n },\n\n createWebSocket(url: string): any {\n var Constructor = this.getWebSocketAPI();\n return new Constructor(url);\n },\n\n createSocketRequest(method: string, url: string): HTTPRequest {\n if (this.isXHRSupported()) {\n return this.HTTPFactory.createXHR(method, url);\n } else if (this.isXDRSupported(url.indexOf('https:') === 0)) {\n return this.HTTPFactory.createXDR(method, url);\n } else {\n throw 'Cross-origin HTTP requests are not supported';\n }\n },\n\n isXHRSupported(): boolean {\n var Constructor = this.getXHRAPI();\n return (\n Boolean(Constructor) && new Constructor().withCredentials !== undefined\n );\n },\n\n isXDRSupported(useTLS?: boolean): boolean {\n var protocol = useTLS ? 'https:' : 'http:';\n var documentProtocol = this.getProtocol();\n return (\n Boolean(window['XDomainRequest']) && documentProtocol === protocol\n );\n },\n\n addUnloadListener(listener: any) {\n if (window.addEventListener !== undefined) {\n window.addEventListener('unload', listener, false);\n } else if (window.attachEvent !== undefined) {\n window.attachEvent('onunload', listener);\n }\n },\n\n removeUnloadListener(listener: any) {\n if (window.addEventListener !== undefined) {\n window.removeEventListener('unload', listener, false);\n } else if (window.detachEvent !== undefined) {\n window.detachEvent('onunload', listener);\n }\n },\n\n randomInt(max: number): number {\n /**\n * Return values in the range of [0, 1[\n */\n const random = function() {\n const crypto = window.crypto || window['msCrypto'];\n const random = crypto.getRandomValues(new Uint32Array(1))[0];\n\n return random / 2 ** 32;\n };\n\n return Math.floor(random() * max);\n }\n};\n\nexport default Runtime;\n","enum TimelineLevel {\n ERROR = 3,\n INFO = 6,\n DEBUG = 7\n}\n\nexport default TimelineLevel;\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport { default as Level } from './level';\n\nexport interface TimelineOptions {\n level?: Level;\n limit?: number;\n version?: string;\n cluster?: string;\n features?: string[];\n params?: any;\n}\n\nexport default class Timeline {\n key: string;\n session: number;\n events: any[];\n options: TimelineOptions;\n sent: number;\n uniqueID: number;\n\n constructor(key: string, session: number, options: TimelineOptions) {\n this.key = key;\n this.session = session;\n this.events = [];\n this.options = options || {};\n this.sent = 0;\n this.uniqueID = 0;\n }\n\n log(level, event) {\n if (level <= this.options.level) {\n this.events.push(\n Collections.extend({}, event, { timestamp: Util.now() })\n );\n if (this.options.limit && this.events.length > this.options.limit) {\n this.events.shift();\n }\n }\n }\n\n error(event) {\n this.log(Level.ERROR, event);\n }\n\n info(event) {\n this.log(Level.INFO, event);\n }\n\n debug(event) {\n this.log(Level.DEBUG, event);\n }\n\n isEmpty() {\n return this.events.length === 0;\n }\n\n send(sendfn, callback) {\n var data = Collections.extend(\n {\n session: this.session,\n bundle: this.sent + 1,\n key: this.key,\n lib: 'js',\n version: this.options.version,\n cluster: this.options.cluster,\n features: this.options.features,\n timeline: this.events\n },\n this.options.params\n );\n\n this.events = [];\n sendfn(data, (error, result) => {\n if (!error) {\n this.sent++;\n }\n if (callback) {\n callback(error, result);\n }\n });\n\n return true;\n }\n\n generateUniqueID(): number {\n this.uniqueID++;\n return this.uniqueID;\n }\n}\n","import Factory from '../utils/factory';\nimport Util from '../util';\nimport * as Errors from '../errors';\nimport * as Collections from '../utils/collections';\nimport Strategy from './strategy';\nimport Transport from '../transports/transport';\nimport StrategyOptions from './strategy_options';\nimport Handshake from '../connection/handshake';\n\n/** Provides a strategy interface for transports.\n *\n * @param {String} name\n * @param {Number} priority\n * @param {Class} transport\n * @param {Object} options\n */\nexport default class TransportStrategy implements Strategy {\n name: string;\n priority: number;\n transport: Transport;\n options: StrategyOptions;\n\n constructor(\n name: string,\n priority: number,\n transport: Transport,\n options: StrategyOptions\n ) {\n this.name = name;\n this.priority = priority;\n this.transport = transport;\n this.options = options || {};\n }\n\n /** Returns whether the transport is supported in the browser.\n *\n * @returns {Boolean}\n */\n isSupported(): boolean {\n return this.transport.isSupported({\n useTLS: this.options.useTLS\n });\n }\n\n /** Launches a connection attempt and returns a strategy runner.\n *\n * @param {Function} callback\n * @return {Object} strategy runner\n */\n connect(minPriority: number, callback: Function) {\n if (!this.isSupported()) {\n return failAttempt(new Errors.UnsupportedStrategy(), callback);\n } else if (this.priority < minPriority) {\n return failAttempt(new Errors.TransportPriorityTooLow(), callback);\n }\n\n var connected = false;\n var transport = this.transport.createConnection(\n this.name,\n this.priority,\n this.options.key,\n this.options\n );\n var handshake = null;\n\n var onInitialized = function() {\n transport.unbind('initialized', onInitialized);\n transport.connect();\n };\n var onOpen = function() {\n handshake = Factory.createHandshake(transport, function(result) {\n connected = true;\n unbindListeners();\n callback(null, result);\n });\n };\n var onError = function(error) {\n unbindListeners();\n callback(error);\n };\n var onClosed = function() {\n unbindListeners();\n var serializedTransport;\n\n // The reason for this try/catch block is that on React Native\n // the WebSocket object is circular. Therefore transport.socket will\n // throw errors upon stringification. Collections.safeJSONStringify\n // discards circular references when serializing.\n serializedTransport = Collections.safeJSONStringify(transport);\n callback(new Errors.TransportClosed(serializedTransport));\n };\n\n var unbindListeners = function() {\n transport.unbind('initialized', onInitialized);\n transport.unbind('open', onOpen);\n transport.unbind('error', onError);\n transport.unbind('closed', onClosed);\n };\n\n transport.bind('initialized', onInitialized);\n transport.bind('open', onOpen);\n transport.bind('error', onError);\n transport.bind('closed', onClosed);\n\n // connect will be called automatically after initialization\n transport.initialize();\n\n return {\n abort: () => {\n if (connected) {\n return;\n }\n unbindListeners();\n if (handshake) {\n handshake.close();\n } else {\n transport.close();\n }\n },\n forceMinPriority: p => {\n if (connected) {\n return;\n }\n if (this.priority < p) {\n if (handshake) {\n handshake.close();\n } else {\n transport.close();\n }\n }\n }\n };\n }\n}\n\nfunction failAttempt(error: Error, callback: Function) {\n Util.defer(function() {\n callback(error);\n });\n return {\n abort: function() {},\n forceMinPriority: function() {}\n };\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport TransportManager from '../transports/transport_manager';\nimport * as Errors from '../errors';\nimport Strategy from './strategy';\nimport TransportStrategy from './transport_strategy';\nimport StrategyOptions from '../strategies/strategy_options';\nimport { Config } from '../config';\nimport Runtime from 'runtime';\n\nconst { Transports } = Runtime;\n\nexport var defineTransport = function(\n config: Config,\n name: string,\n type: string,\n priority: number,\n options: StrategyOptions,\n manager?: TransportManager\n): Strategy {\n var transportClass = Transports[type];\n if (!transportClass) {\n throw new Errors.UnsupportedTransport(type);\n }\n\n var enabled =\n (!config.enabledTransports ||\n Collections.arrayIndexOf(config.enabledTransports, name) !== -1) &&\n (!config.disabledTransports ||\n Collections.arrayIndexOf(config.disabledTransports, name) === -1);\n\n var transport;\n if (enabled) {\n options = Object.assign(\n { ignoreNullOrigin: config.ignoreNullOrigin },\n options\n );\n\n transport = new TransportStrategy(\n name,\n priority,\n manager ? manager.getAssistant(transportClass) : transportClass,\n options\n );\n } else {\n transport = UnsupportedStrategy;\n }\n\n return transport;\n};\n\nvar UnsupportedStrategy: Strategy = {\n isSupported: function() {\n return false;\n },\n connect: function(_, callback) {\n var deferred = Util.defer(function() {\n callback(new Errors.UnsupportedStrategy());\n });\n return {\n abort: function() {\n deferred.ensureAborted();\n },\n forceMinPriority: function() {}\n };\n }\n};\n","import ConnectionManager from './connection/connection_manager';\nimport {\n ChannelAuthorizationOptions,\n UserAuthenticationOptions\n} from './auth/options';\nimport {\n ChannelAuthorizerGenerator,\n DeprecatedAuthOptions\n} from './auth/deprecated_channel_authorizer';\nimport { AuthTransport, Transport } from './config';\nimport * as nacl from 'tweetnacl';\nimport Logger from './logger';\n\nexport interface Options {\n activityTimeout?: number;\n\n auth?: DeprecatedAuthOptions; // DEPRECATED use channelAuthorization instead\n authEndpoint?: string; // DEPRECATED use channelAuthorization instead\n authTransport?: AuthTransport; // DEPRECATED use channelAuthorization instead\n authorizer?: ChannelAuthorizerGenerator; // DEPRECATED use channelAuthorization instead\n\n channelAuthorization?: ChannelAuthorizationOptions;\n userAuthentication?: UserAuthenticationOptions;\n\n cluster: string;\n enableStats?: boolean;\n disableStats?: boolean;\n disabledTransports?: Transport[];\n enabledTransports?: Transport[];\n forceTLS?: boolean;\n httpHost?: string;\n httpPath?: string;\n httpPort?: number;\n httpsPort?: number;\n ignoreNullOrigin?: boolean;\n nacl?: nacl;\n pongTimeout?: number;\n statsHost?: string;\n timelineParams?: any;\n unavailableTimeout?: number;\n wsHost?: string;\n wsPath?: string;\n wsPort?: number;\n wssPort?: number;\n}\n\nexport function validateOptions(options) {\n if (options == null) {\n throw 'You must pass an options object';\n }\n if (options.cluster == null) {\n throw 'Options object must provide a cluster';\n }\n if ('disableStats' in options) {\n Logger.warn(\n 'The disableStats option is deprecated in favor of enableStats'\n );\n }\n}\n","import {\n UserAuthenticationCallback,\n InternalAuthOptions,\n UserAuthenticationHandler,\n UserAuthenticationRequestParams,\n AuthRequestType\n} from './options';\n\nimport Runtime from 'runtime';\n\nconst composeChannelQuery = (\n params: UserAuthenticationRequestParams,\n authOptions: InternalAuthOptions\n) => {\n var query = 'socket_id=' + encodeURIComponent(params.socketId);\n\n for (var key in authOptions.params) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(authOptions.params[key]);\n }\n\n if (authOptions.paramsProvider != null) {\n let dynamicParams = authOptions.paramsProvider();\n for (var key in dynamicParams) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(dynamicParams[key]);\n }\n }\n\n return query;\n};\n\nconst UserAuthenticator = (\n authOptions: InternalAuthOptions\n): UserAuthenticationHandler => {\n if (typeof Runtime.getAuthorizers()[authOptions.transport] === 'undefined') {\n throw `'${authOptions.transport}' is not a recognized auth transport`;\n }\n\n return (\n params: UserAuthenticationRequestParams,\n callback: UserAuthenticationCallback\n ) => {\n const query = composeChannelQuery(params, authOptions);\n\n Runtime.getAuthorizers()[authOptions.transport](\n Runtime,\n query,\n authOptions,\n AuthRequestType.UserAuthentication,\n callback\n );\n };\n};\n\nexport default UserAuthenticator;\n","import {\n AuthRequestType,\n InternalAuthOptions,\n ChannelAuthorizationHandler,\n ChannelAuthorizationRequestParams,\n ChannelAuthorizationCallback\n} from './options';\n\nimport Runtime from 'runtime';\n\nconst composeChannelQuery = (\n params: ChannelAuthorizationRequestParams,\n authOptions: InternalAuthOptions\n) => {\n var query = 'socket_id=' + encodeURIComponent(params.socketId);\n\n query += '&channel_name=' + encodeURIComponent(params.channelName);\n\n for (var key in authOptions.params) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(authOptions.params[key]);\n }\n\n if (authOptions.paramsProvider != null) {\n let dynamicParams = authOptions.paramsProvider();\n for (var key in dynamicParams) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(dynamicParams[key]);\n }\n }\n\n return query;\n};\n\nconst ChannelAuthorizer = (\n authOptions: InternalAuthOptions\n): ChannelAuthorizationHandler => {\n if (typeof Runtime.getAuthorizers()[authOptions.transport] === 'undefined') {\n throw `'${authOptions.transport}' is not a recognized auth transport`;\n }\n\n return (\n params: ChannelAuthorizationRequestParams,\n callback: ChannelAuthorizationCallback\n ) => {\n const query = composeChannelQuery(params, authOptions);\n\n Runtime.getAuthorizers()[authOptions.transport](\n Runtime,\n query,\n authOptions,\n AuthRequestType.ChannelAuthorization,\n callback\n );\n };\n};\n\nexport default ChannelAuthorizer;\n","import Channel from '../channels/channel';\nimport {\n ChannelAuthorizationCallback,\n ChannelAuthorizationHandler,\n ChannelAuthorizationRequestParams,\n InternalAuthOptions\n} from './options';\n\nexport interface DeprecatedChannelAuthorizer {\n authorize(socketId: string, callback: ChannelAuthorizationCallback): void;\n}\n\nexport interface ChannelAuthorizerGenerator {\n (\n channel: Channel,\n options: DeprecatedAuthorizerOptions\n ): DeprecatedChannelAuthorizer;\n}\n\nexport interface DeprecatedAuthOptions {\n params?: any;\n headers?: any;\n}\n\nexport interface DeprecatedAuthorizerOptions {\n authTransport: 'ajax' | 'jsonp';\n authEndpoint: string;\n auth?: DeprecatedAuthOptions;\n}\n\nexport const ChannelAuthorizerProxy = (\n pusher,\n authOptions: InternalAuthOptions,\n channelAuthorizerGenerator: ChannelAuthorizerGenerator\n): ChannelAuthorizationHandler => {\n const deprecatedAuthorizerOptions: DeprecatedAuthorizerOptions = {\n authTransport: authOptions.transport,\n authEndpoint: authOptions.endpoint,\n auth: {\n params: authOptions.params,\n headers: authOptions.headers\n }\n };\n return (\n params: ChannelAuthorizationRequestParams,\n callback: ChannelAuthorizationCallback\n ) => {\n const channel = pusher.channel(params.channelName);\n // This line creates a new channel authorizer every time.\n // In the past, this was only done once per channel and reused.\n // We can do that again if we want to keep this behavior intact.\n const channelAuthorizer: DeprecatedChannelAuthorizer = channelAuthorizerGenerator(\n channel,\n deprecatedAuthorizerOptions\n );\n channelAuthorizer.authorize(params.socketId, callback);\n };\n};\n","import { Options } from './options';\nimport Defaults from './defaults';\nimport {\n ChannelAuthorizationHandler,\n UserAuthenticationHandler,\n ChannelAuthorizationOptions\n} from './auth/options';\nimport UserAuthenticator from './auth/user_authenticator';\nimport ChannelAuthorizer from './auth/channel_authorizer';\nimport { ChannelAuthorizerProxy } from './auth/deprecated_channel_authorizer';\nimport Runtime from 'runtime';\nimport * as nacl from 'tweetnacl';\n\nexport type AuthTransport = 'ajax' | 'jsonp';\nexport type Transport =\n | 'ws'\n | 'wss'\n | 'xhr_streaming'\n | 'xhr_polling'\n | 'sockjs';\n\nexport interface Config {\n // these are all 'required' config parameters, it's not necessary for the user\n // to set them, but they have configured defaults.\n activityTimeout: number;\n enableStats: boolean;\n httpHost: string;\n httpPath: string;\n httpPort: number;\n httpsPort: number;\n pongTimeout: number;\n statsHost: string;\n unavailableTimeout: number;\n useTLS: boolean;\n wsHost: string;\n wsPath: string;\n wsPort: number;\n wssPort: number;\n userAuthenticator: UserAuthenticationHandler;\n channelAuthorizer: ChannelAuthorizationHandler;\n\n // these are all optional parameters or overrrides. The customer can set these\n // but it's not strictly necessary\n forceTLS?: boolean;\n cluster?: string;\n disabledTransports?: Transport[];\n enabledTransports?: Transport[];\n ignoreNullOrigin?: boolean;\n nacl?: nacl;\n timelineParams?: any;\n}\n\n// getConfig mainly sets the defaults for the options that are not provided\nexport function getConfig(opts: Options, pusher): Config {\n let config: Config = {\n activityTimeout: opts.activityTimeout || Defaults.activityTimeout,\n cluster: opts.cluster,\n httpPath: opts.httpPath || Defaults.httpPath,\n httpPort: opts.httpPort || Defaults.httpPort,\n httpsPort: opts.httpsPort || Defaults.httpsPort,\n pongTimeout: opts.pongTimeout || Defaults.pongTimeout,\n statsHost: opts.statsHost || Defaults.stats_host,\n unavailableTimeout: opts.unavailableTimeout || Defaults.unavailableTimeout,\n wsPath: opts.wsPath || Defaults.wsPath,\n wsPort: opts.wsPort || Defaults.wsPort,\n wssPort: opts.wssPort || Defaults.wssPort,\n\n enableStats: getEnableStatsConfig(opts),\n httpHost: getHttpHost(opts),\n useTLS: shouldUseTLS(opts),\n wsHost: getWebsocketHost(opts),\n\n userAuthenticator: buildUserAuthenticator(opts),\n channelAuthorizer: buildChannelAuthorizer(opts, pusher)\n };\n\n if ('disabledTransports' in opts)\n config.disabledTransports = opts.disabledTransports;\n if ('enabledTransports' in opts)\n config.enabledTransports = opts.enabledTransports;\n if ('ignoreNullOrigin' in opts)\n config.ignoreNullOrigin = opts.ignoreNullOrigin;\n if ('timelineParams' in opts) config.timelineParams = opts.timelineParams;\n if ('nacl' in opts) {\n config.nacl = opts.nacl;\n }\n\n return config;\n}\n\nfunction getHttpHost(opts: Options): string {\n if (opts.httpHost) {\n return opts.httpHost;\n }\n if (opts.cluster) {\n return `sockjs-${opts.cluster}.pusher.com`;\n }\n return Defaults.httpHost;\n}\n\nfunction getWebsocketHost(opts: Options): string {\n if (opts.wsHost) {\n return opts.wsHost;\n }\n return getWebsocketHostFromCluster(opts.cluster);\n}\n\nfunction getWebsocketHostFromCluster(cluster: string): string {\n return `ws-${cluster}.pusher.com`;\n}\n\nfunction shouldUseTLS(opts: Options): boolean {\n if (Runtime.getProtocol() === 'https:') {\n return true;\n } else if (opts.forceTLS === false) {\n return false;\n }\n return true;\n}\n\n// if enableStats is set take the value\n// if disableStats is set take the inverse\n// otherwise default to false\nfunction getEnableStatsConfig(opts: Options): boolean {\n if ('enableStats' in opts) {\n return opts.enableStats;\n }\n if ('disableStats' in opts) {\n return !opts.disableStats;\n }\n return false;\n}\n\nfunction buildUserAuthenticator(opts: Options): UserAuthenticationHandler {\n const userAuthentication = {\n ...Defaults.userAuthentication,\n ...opts.userAuthentication\n };\n if (\n 'customHandler' in userAuthentication &&\n userAuthentication['customHandler'] != null\n ) {\n return userAuthentication['customHandler'];\n }\n\n return UserAuthenticator(userAuthentication);\n}\n\nfunction buildChannelAuth(opts: Options, pusher): ChannelAuthorizationOptions {\n let channelAuthorization: ChannelAuthorizationOptions;\n if ('channelAuthorization' in opts) {\n channelAuthorization = {\n ...Defaults.channelAuthorization,\n ...opts.channelAuthorization\n };\n } else {\n channelAuthorization = {\n transport: opts.authTransport || Defaults.authTransport,\n endpoint: opts.authEndpoint || Defaults.authEndpoint\n };\n if ('auth' in opts) {\n if ('params' in opts.auth) channelAuthorization.params = opts.auth.params;\n if ('headers' in opts.auth)\n channelAuthorization.headers = opts.auth.headers;\n }\n if ('authorizer' in opts)\n channelAuthorization.customHandler = ChannelAuthorizerProxy(\n pusher,\n channelAuthorization,\n opts.authorizer\n );\n }\n return channelAuthorization;\n}\n\nfunction buildChannelAuthorizer(\n opts: Options,\n pusher\n): ChannelAuthorizationHandler {\n const channelAuthorization = buildChannelAuth(opts, pusher);\n if (\n 'customHandler' in channelAuthorization &&\n channelAuthorization['customHandler'] != null\n ) {\n return channelAuthorization['customHandler'];\n }\n\n return ChannelAuthorizer(channelAuthorization);\n}\n","import Logger from './logger';\nimport Pusher from './pusher';\nimport EventsDispatcher from './events/dispatcher';\n\nexport default class WatchlistFacade extends EventsDispatcher {\n private pusher: Pusher;\n\n public constructor(pusher: Pusher) {\n super(function(eventName, data) {\n Logger.debug(`No callbacks on watchlist events for ${eventName}`);\n });\n\n this.pusher = pusher;\n this.bindWatchlistInternalEvent();\n }\n\n handleEvent(pusherEvent) {\n pusherEvent.data.events.forEach(watchlistEvent => {\n this.emit(watchlistEvent.name, watchlistEvent);\n });\n }\n\n private bindWatchlistInternalEvent() {\n this.pusher.connection.bind('message', pusherEvent => {\n var eventName = pusherEvent.event;\n if (eventName === 'pusher_internal:watchlist_events') {\n this.handleEvent(pusherEvent);\n }\n });\n }\n}\n","function flatPromise() {\n let resolve, reject;\n const promise = new Promise((res, rej) => {\n resolve = res;\n reject = rej;\n });\n return { promise, resolve, reject };\n}\n\nexport default flatPromise;\n","import Pusher from './pusher';\nimport Logger from './logger';\nimport {\n UserAuthenticationData,\n UserAuthenticationCallback\n} from './auth/options';\nimport Channel from './channels/channel';\nimport WatchlistFacade from './watchlist';\nimport EventsDispatcher from './events/dispatcher';\nimport flatPromise from './utils/flat_promise';\n\nexport default class UserFacade extends EventsDispatcher {\n pusher: Pusher;\n signin_requested: boolean = false;\n user_data: any = null;\n serverToUserChannel: Channel = null;\n signinDonePromise: Promise = null;\n watchlist: WatchlistFacade;\n private _signinDoneResolve: Function = null;\n\n public constructor(pusher: Pusher) {\n super(function(eventName, data) {\n Logger.debug('No callbacks on user for ' + eventName);\n });\n this.pusher = pusher;\n this.pusher.connection.bind('state_change', ({ previous, current }) => {\n if (previous !== 'connected' && current === 'connected') {\n this._signin();\n }\n if (previous === 'connected' && current !== 'connected') {\n this._cleanup();\n this._newSigninPromiseIfNeeded();\n }\n });\n\n this.watchlist = new WatchlistFacade(pusher);\n\n this.pusher.connection.bind('message', event => {\n var eventName = event.event;\n if (eventName === 'pusher:signin_success') {\n this._onSigninSuccess(event.data);\n }\n if (\n this.serverToUserChannel &&\n this.serverToUserChannel.name === event.channel\n ) {\n this.serverToUserChannel.handleEvent(event);\n }\n });\n }\n\n public signin() {\n if (this.signin_requested) {\n return;\n }\n\n this.signin_requested = true;\n this._signin();\n }\n\n private _signin() {\n if (!this.signin_requested) {\n return;\n }\n\n this._newSigninPromiseIfNeeded();\n\n if (this.pusher.connection.state !== 'connected') {\n // Signin will be attempted when the connection is connected\n return;\n }\n\n this.pusher.config.userAuthenticator(\n {\n socketId: this.pusher.connection.socket_id\n },\n this._onAuthorize\n );\n }\n\n private _onAuthorize: UserAuthenticationCallback = (\n err,\n authData: UserAuthenticationData\n ) => {\n if (err) {\n Logger.warn(`Error during signin: ${err}`);\n this._cleanup();\n return;\n }\n\n this.pusher.send_event('pusher:signin', {\n auth: authData.auth,\n user_data: authData.user_data\n });\n\n // Later when we get pusher:singin_success event, the user will be marked as signed in\n };\n\n private _onSigninSuccess(data: any) {\n try {\n this.user_data = JSON.parse(data.user_data);\n } catch (e) {\n Logger.error(`Failed parsing user data after signin: ${data.user_data}`);\n this._cleanup();\n return;\n }\n\n if (typeof this.user_data.id !== 'string' || this.user_data.id === '') {\n Logger.error(\n `user_data doesn't contain an id. user_data: ${this.user_data}`\n );\n this._cleanup();\n return;\n }\n\n // Signin succeeded\n this._signinDoneResolve();\n this._subscribeChannels();\n }\n\n private _subscribeChannels() {\n const ensure_subscribed = channel => {\n if (channel.subscriptionPending && channel.subscriptionCancelled) {\n channel.reinstateSubscription();\n } else if (\n !channel.subscriptionPending &&\n this.pusher.connection.state === 'connected'\n ) {\n channel.subscribe();\n }\n };\n\n this.serverToUserChannel = new Channel(\n `#server-to-user-${this.user_data.id}`,\n this.pusher\n );\n this.serverToUserChannel.bind_global((eventName, data) => {\n if (\n eventName.indexOf('pusher_internal:') === 0 ||\n eventName.indexOf('pusher:') === 0\n ) {\n // ignore internal events\n return;\n }\n this.emit(eventName, data);\n });\n ensure_subscribed(this.serverToUserChannel);\n }\n\n private _cleanup() {\n this.user_data = null;\n if (this.serverToUserChannel) {\n this.serverToUserChannel.unbind_all();\n this.serverToUserChannel.disconnect();\n this.serverToUserChannel = null;\n }\n\n if (this.signin_requested) {\n // If signin is in progress and cleanup is called,\n // Mark the current signin process as done.\n this._signinDoneResolve();\n }\n }\n\n private _newSigninPromiseIfNeeded() {\n if (!this.signin_requested) {\n return;\n }\n\n // If there is a promise and it is not resolved, return without creating a new one.\n if (this.signinDonePromise && !(this.signinDonePromise as any).done) {\n return;\n }\n\n // This promise is never rejected.\n // It gets resolved when the signin process is done whether it failed or succeeded\n const { promise, resolve, reject: _ } = flatPromise();\n (promise as any).done = false;\n const setDone = () => {\n (promise as any).done = true;\n };\n promise.then(setDone).catch(setDone);\n this.signinDonePromise = promise;\n this._signinDoneResolve = resolve;\n }\n}\n","import AbstractRuntime from '../runtimes/interface';\nimport Runtime from 'runtime';\nimport Util from './util';\nimport * as Collections from './utils/collections';\nimport Channels from './channels/channels';\nimport Channel from './channels/channel';\nimport { default as EventsDispatcher } from './events/dispatcher';\nimport Timeline from './timeline/timeline';\nimport TimelineSender from './timeline/timeline_sender';\nimport TimelineLevel from './timeline/level';\nimport { defineTransport } from './strategies/strategy_builder';\nimport ConnectionManager from './connection/connection_manager';\nimport ConnectionManagerOptions from './connection/connection_manager_options';\nimport { PeriodicTimer } from './utils/timers';\nimport Defaults from './defaults';\nimport * as DefaultConfig from './config';\nimport Logger from './logger';\nimport Factory from './utils/factory';\nimport UrlStore from 'core/utils/url_store';\nimport { Options, validateOptions } from './options';\nimport { Config, getConfig } from './config';\nimport StrategyOptions from './strategies/strategy_options';\nimport UserFacade from './user';\n\nexport default class Pusher {\n /* STATIC PROPERTIES */\n static instances: Pusher[] = [];\n static isReady: boolean = false;\n static logToConsole: boolean = false;\n\n // for jsonp\n static Runtime: AbstractRuntime = Runtime;\n static ScriptReceivers: any = (Runtime).ScriptReceivers;\n static DependenciesReceivers: any = (Runtime).DependenciesReceivers;\n static auth_callbacks: any = (Runtime).auth_callbacks;\n\n static ready() {\n Pusher.isReady = true;\n for (var i = 0, l = Pusher.instances.length; i < l; i++) {\n Pusher.instances[i].connect();\n }\n }\n\n static log: (message: any) => void;\n\n private static getClientFeatures(): string[] {\n return Collections.keys(\n Collections.filterObject({ ws: Runtime.Transports.ws }, function(t) {\n return t.isSupported({});\n })\n );\n }\n\n /* INSTANCE PROPERTIES */\n key: string;\n config: Config;\n channels: Channels;\n global_emitter: EventsDispatcher;\n sessionID: number;\n timeline: Timeline;\n timelineSender: TimelineSender;\n connection: ConnectionManager;\n timelineSenderTimer: PeriodicTimer;\n user: UserFacade;\n constructor(app_key: string, options: Options) {\n checkAppKey(app_key);\n validateOptions(options);\n this.key = app_key;\n this.config = getConfig(options, this);\n\n this.channels = Factory.createChannels();\n this.global_emitter = new EventsDispatcher();\n this.sessionID = Runtime.randomInt(1000000000);\n\n this.timeline = new Timeline(this.key, this.sessionID, {\n cluster: this.config.cluster,\n features: Pusher.getClientFeatures(),\n params: this.config.timelineParams || {},\n limit: 50,\n level: TimelineLevel.INFO,\n version: Defaults.VERSION\n });\n if (this.config.enableStats) {\n this.timelineSender = Factory.createTimelineSender(this.timeline, {\n host: this.config.statsHost,\n path: '/timeline/v2/' + Runtime.TimelineTransport.name\n });\n }\n\n var getStrategy = (options: StrategyOptions) => {\n return Runtime.getDefaultStrategy(this.config, options, defineTransport);\n };\n\n this.connection = Factory.createConnectionManager(this.key, {\n getStrategy: getStrategy,\n timeline: this.timeline,\n activityTimeout: this.config.activityTimeout,\n pongTimeout: this.config.pongTimeout,\n unavailableTimeout: this.config.unavailableTimeout,\n useTLS: Boolean(this.config.useTLS)\n });\n\n this.connection.bind('connected', () => {\n this.subscribeAll();\n if (this.timelineSender) {\n this.timelineSender.send(this.connection.isUsingTLS());\n }\n });\n\n this.connection.bind('message', event => {\n var eventName = event.event;\n var internal = eventName.indexOf('pusher_internal:') === 0;\n if (event.channel) {\n var channel = this.channel(event.channel);\n if (channel) {\n channel.handleEvent(event);\n }\n }\n // Emit globally [deprecated]\n if (!internal) {\n this.global_emitter.emit(event.event, event.data);\n }\n });\n this.connection.bind('connecting', () => {\n this.channels.disconnect();\n });\n this.connection.bind('disconnected', () => {\n this.channels.disconnect();\n });\n this.connection.bind('error', err => {\n Logger.warn(err);\n });\n\n Pusher.instances.push(this);\n this.timeline.info({ instances: Pusher.instances.length });\n\n this.user = new UserFacade(this);\n\n if (Pusher.isReady) {\n this.connect();\n }\n }\n\n channel(name: string): Channel {\n return this.channels.find(name);\n }\n\n allChannels(): Channel[] {\n return this.channels.all();\n }\n\n connect() {\n this.connection.connect();\n\n if (this.timelineSender) {\n if (!this.timelineSenderTimer) {\n var usingTLS = this.connection.isUsingTLS();\n var timelineSender = this.timelineSender;\n this.timelineSenderTimer = new PeriodicTimer(60000, function() {\n timelineSender.send(usingTLS);\n });\n }\n }\n }\n\n disconnect() {\n this.connection.disconnect();\n\n if (this.timelineSenderTimer) {\n this.timelineSenderTimer.ensureAborted();\n this.timelineSenderTimer = null;\n }\n }\n\n bind(event_name: string, callback: Function, context?: any): Pusher {\n this.global_emitter.bind(event_name, callback, context);\n return this;\n }\n\n unbind(event_name?: string, callback?: Function, context?: any): Pusher {\n this.global_emitter.unbind(event_name, callback, context);\n return this;\n }\n\n bind_global(callback: Function): Pusher {\n this.global_emitter.bind_global(callback);\n return this;\n }\n\n unbind_global(callback?: Function): Pusher {\n this.global_emitter.unbind_global(callback);\n return this;\n }\n\n unbind_all(callback?: Function): Pusher {\n this.global_emitter.unbind_all();\n return this;\n }\n\n subscribeAll() {\n var channelName;\n for (channelName in this.channels.channels) {\n if (this.channels.channels.hasOwnProperty(channelName)) {\n this.subscribe(channelName);\n }\n }\n }\n\n subscribe(channel_name: string) {\n var channel = this.channels.add(channel_name, this);\n if (channel.subscriptionPending && channel.subscriptionCancelled) {\n channel.reinstateSubscription();\n } else if (\n !channel.subscriptionPending &&\n this.connection.state === 'connected'\n ) {\n channel.subscribe();\n }\n return channel;\n }\n\n unsubscribe(channel_name: string) {\n var channel = this.channels.find(channel_name);\n if (channel && channel.subscriptionPending) {\n channel.cancelSubscription();\n } else {\n channel = this.channels.remove(channel_name);\n if (channel && channel.subscribed) {\n channel.unsubscribe();\n }\n }\n }\n\n send_event(event_name: string, data: any, channel?: string) {\n return this.connection.send_event(event_name, data, channel);\n }\n\n shouldUseTLS(): boolean {\n return this.config.useTLS;\n }\n\n signin() {\n this.user.signin();\n }\n}\n\nfunction checkAppKey(key) {\n if (key === null || key === undefined) {\n throw 'You must pass your app key when you instantiate Pusher.';\n }\n}\n\nRuntime.setup(Pusher);\n","import Pusher from './pusher';\nimport { Options, validateOptions } from './options';\nimport * as nacl from 'tweetnacl';\n\nexport default class PusherWithEncryption extends Pusher {\n constructor(app_key: string, options: Options) {\n Pusher.logToConsole = PusherWithEncryption.logToConsole;\n Pusher.log = PusherWithEncryption.log;\n\n validateOptions(options);\n options.nacl = nacl;\n super(app_key, options);\n }\n}\n"],"sourceRoot":""} \ No newline at end of file +{"version":3,"sources":["webpack://Pusher/webpack/universalModuleDefinition","webpack://Pusher/webpack/bootstrap","webpack://Pusher/./node_modules/@stablelib/base64/base64.ts","webpack://Pusher/./node_modules/@stablelib/utf8/utf8.ts","webpack://Pusher/./node_modules/tweetnacl/nacl-fast.js","webpack://Pusher/./src/core/pusher-with-encryption.js","webpack://Pusher/crypto (ignored)","webpack://Pusher/./src/runtimes/web/dom/script_receiver_factory.ts","webpack://Pusher/./src/core/defaults.ts","webpack://Pusher/./src/runtimes/web/dom/dependency_loader.ts","webpack://Pusher/./src/runtimes/web/dom/dependencies.ts","webpack://Pusher/./src/core/utils/url_store.ts","webpack://Pusher/./src/core/auth/options.ts","webpack://Pusher/./src/core/errors.ts","webpack://Pusher/./src/runtimes/isomorphic/auth/xhr_auth.ts","webpack://Pusher/./src/core/base64.ts","webpack://Pusher/./src/core/utils/timers/abstract_timer.ts","webpack://Pusher/./src/core/utils/timers/index.ts","webpack://Pusher/./src/core/util.ts","webpack://Pusher/./src/core/utils/collections.ts","webpack://Pusher/./src/core/logger.ts","webpack://Pusher/./src/runtimes/web/auth/jsonp_auth.ts","webpack://Pusher/./src/runtimes/web/dom/script_request.ts","webpack://Pusher/./src/runtimes/web/dom/jsonp_request.ts","webpack://Pusher/./src/runtimes/web/timeline/jsonp_timeline.ts","webpack://Pusher/./src/core/transports/url_schemes.ts","webpack://Pusher/./src/core/events/callback_registry.ts","webpack://Pusher/./src/core/events/dispatcher.ts","webpack://Pusher/./src/core/transports/transport_connection.ts","webpack://Pusher/./src/core/transports/transport.ts","webpack://Pusher/./src/runtimes/isomorphic/transports/transports.ts","webpack://Pusher/./src/runtimes/web/transports/transports.ts","webpack://Pusher/./src/runtimes/web/net_info.ts","webpack://Pusher/./src/core/transports/assistant_to_the_transport_manager.ts","webpack://Pusher/./src/core/connection/protocol/protocol.ts","webpack://Pusher/./src/core/connection/connection.ts","webpack://Pusher/./src/core/connection/handshake/index.ts","webpack://Pusher/./src/core/timeline/timeline_sender.ts","webpack://Pusher/./src/core/channels/channel.ts","webpack://Pusher/./src/core/channels/private_channel.ts","webpack://Pusher/./src/core/channels/members.ts","webpack://Pusher/./src/core/channels/presence_channel.ts","webpack://Pusher/./src/core/channels/encrypted_channel.ts","webpack://Pusher/./src/core/connection/connection_manager.ts","webpack://Pusher/./src/core/channels/channels.ts","webpack://Pusher/./src/core/utils/factory.ts","webpack://Pusher/./src/core/transports/transport_manager.ts","webpack://Pusher/./src/core/strategies/sequential_strategy.ts","webpack://Pusher/./src/core/strategies/best_connected_ever_strategy.ts","webpack://Pusher/./src/core/strategies/websocket_prioritized_cached_strategy.ts","webpack://Pusher/./src/core/strategies/delayed_strategy.ts","webpack://Pusher/./src/core/strategies/if_strategy.ts","webpack://Pusher/./src/core/strategies/first_connected_strategy.ts","webpack://Pusher/./src/runtimes/web/default_strategy.ts","webpack://Pusher/./src/runtimes/web/transports/transport_connection_initializer.ts","webpack://Pusher/./src/runtimes/web/http/http_xdomain_request.ts","webpack://Pusher/./src/core/http/http_request.ts","webpack://Pusher/./src/core/http/state.ts","webpack://Pusher/./src/core/http/http_socket.ts","webpack://Pusher/./src/core/http/http_streaming_socket.ts","webpack://Pusher/./src/core/http/http_polling_socket.ts","webpack://Pusher/./src/runtimes/isomorphic/http/http_xhr_request.ts","webpack://Pusher/./src/runtimes/isomorphic/http/http.ts","webpack://Pusher/./src/runtimes/web/http/http.ts","webpack://Pusher/./src/runtimes/web/runtime.ts","webpack://Pusher/./src/core/timeline/level.ts","webpack://Pusher/./src/core/timeline/timeline.ts","webpack://Pusher/./src/core/strategies/transport_strategy.ts","webpack://Pusher/./src/core/strategies/strategy_builder.ts","webpack://Pusher/./src/core/options.ts","webpack://Pusher/./src/core/auth/user_authenticator.ts","webpack://Pusher/./src/core/auth/channel_authorizer.ts","webpack://Pusher/./src/core/auth/deprecated_channel_authorizer.ts","webpack://Pusher/./src/core/config.ts","webpack://Pusher/./src/core/watchlist.ts","webpack://Pusher/./src/core/utils/flat_promise.ts","webpack://Pusher/./src/core/user.ts","webpack://Pusher/./src/core/pusher.ts","webpack://Pusher/./src/core/pusher-with-encryption.ts"],"names":[],"mappings":";;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AACD,O;QCVA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;;QAEA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;;;QAGA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;QACA,0CAA0C,gCAAgC;QAC1E;QACA;;QAEA;QACA;QACA;QACA,wDAAwD,kBAAkB;QAC1E;QACA,iDAAiD,cAAc;QAC/D;;QAEA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA,yCAAyC,iCAAiC;QAC1E,gHAAgH,mBAAmB,EAAE;QACrI;QACA;;QAEA;QACA;QACA;QACA,2BAA2B,0BAA0B,EAAE;QACvD,iCAAiC,eAAe;QAChD;QACA;QACA;;QAEA;QACA,sDAAsD,+DAA+D;;QAErH;QACA;;;QAGA;QACA;;;;;;;;;AClFA,sCAAsC;AACtC,6CAA6C;;;;;;;;;;;;;;;AAE7C;;GAEG;AAEH,iDAAiD;AACjD,kDAAkD;AAClD,kCAAkC;AAClC,IAAM,YAAY,GAAG,GAAG,CAAC;AAEzB;;;;GAIG;AACH;IACI,kDAAkD;IAElD,eAAoB,iBAAuB;QAAvB,2DAAuB;QAAvB,sBAAiB,GAAjB,iBAAiB,CAAM;IAAI,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ACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,aAAa,QAAQ;AACrB,aAAa,OAAO;AACpB;AACA;AACA,eAAe,QAAQ;AACvB;AACA,eAAe,QAAQ;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB;AACA;AACA;;AAEA;AACA;AACA;AACA,aAAa,QAAQ;AACrB,aAAa,OAAO;AACpB;AACA;AACA,eAAe,QAAQ;AACvB;AACA,eAAe,QAAQ;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,iBAAiB,OAAO;AACxB;AACA;;AAEA;AACA;AACA;AACA;AACA,iBAAiB,OAAO;AACxB;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA,8CAA8C;AAC9C,8CAA8C;AAC9C,8CAA8C;AAC9C,8CAA8C;AAC9C,8CAA8C;AAC9C;AACA,8CAA8C;AAC9C,8CAA8C;AAC9C,8CAA8C;AAC9C;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,sDAAsD;AACtD,sDAAsD;AACtD,sDAAsD;AACtD,sDAAsD;AACtD,sDAAsD;AACtD;AACA,sDAAsD;AACtD,sDAAsD;AACtD,sDAAsD;AACtD;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA,qBAAqB;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA,qBAAqB;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA,qBAAqB;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA,qBAAqB;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA,qBAAqB;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA,qBAAqB;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA,qBAAqB;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA,qBAAqB;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA,qBAAqB;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA,qBAAqB;;AAErB;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA,UAAU,QAAQ;AAClB;AACA;AACA;;AAEA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA;AACA;;AAEA;AACA,aAAa,QAAQ;AACrB;AACA,aAAa,QAAQ;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa,OAAO;AACpB;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,UAAU;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,eAAe,WAAW;AAC1B;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;;AAEA;AACA;AACA,aAAa,QAAQ;AACrB;;AAEA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA,aAAa,OAAO;AACpB;AACA,eAAe,QAAQ;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;;AAEA;AACA,iBAAiB,QAAQ;AACzB;;AAEA;AACA,iBAAiB,QAAQ;AACzB;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD;;AAEA;AACA;AACA,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA,aAAa,QAAQ;AACrB,eAAe,QAAQ;AACvB;AACA;AACA;AACA,aAAa,QAAQ;AACrB;;AAEA;AACA;AACA;AACA,aAAa,QAAQ;AACrB,eAAe,QAAQ;AACvB;AACA;AACA;AACA,aAAa,QAAQ;AACrB;;AAEA;AACA;AACA;AACA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA;AACA,aAAa,MAAM;AACnB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,eAAe,QAAQ;AACvB;AACA;AACA;AACA;AACA,eAAe,QAAQ;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA,qBAAqB;AACrB,qBAAqB;;AAErB;AACA;AACA;;AAEA,sBAAsB;AACtB,sBAAsB;;AAEtB;AACA;AACA;;AAEA,sBAAsB;AACtB,sBAAsB;;AAEtB;AACA;AACA;;AAEA,sBAAsB;AACtB,sBAAsB;;AAEtB;AACA;AACA;;AAEA,sBAAsB;AACtB,sBAAsB;;AAEtB;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA,qBAAqB;AACrB,qBAAqB;;AAErB;AACA;AACA;;AAEA,sBAAsB;AACtB,sBAAsB;;AAEtB;AACA;AACA;;AAEA,sBAAsB;AACtB,sBAAsB;;AAEtB;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA,qBAAqB;AACrB,qBAAqB;;AAErB;AACA;;AAEA,sBAAsB;AACtB,sBAAsB;;AAEtB;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,mBAAmB,QAAQ;AAC3B;AACA;AACA;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;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA,aAAa,OAAO;AACpB;;AAEA;AACA;AACA;AACA;;AAEA,aAAa,OAAO;;AAEpB;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa,OAAO;AACpB;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,QAAQ;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA,aAAa,QAAQ;AACrB;AACA;;AAEA;;AAEA;AACA;AACA,cAAc,SAAS;AACvB;AACA,gCAAgC,OAAO;AACvC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA;AACA,aAAa,QAAQ;AACrB,aAAa,QAAQ;AACrB;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa,QAAQ;AACrB,aAAa,QAAQ;AACrB;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA,aAAa,OAAO;AACpB,aAAa,QAAQ;;AAErB;AACA;AACA;AACA;;AAEA,cAAc,QAAQ;AACtB;AACA;;AAEA,aAAa,QAAQ;AACrB,aAAa,QAAQ;AACrB,aAAa,QAAQ;AACrB,eAAe,QAAQ;AACvB;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;;AAEA,aAAa,OAAO;AACpB,aAAa,QAAQ;AACrB;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA,eAAe,OAAO;AACtB;AACA;;AAEA,aAAa,OAAO;AACpB;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA,iBAAiB,sBAAsB;AACvC;AACA;AACA;AACA;;AAEA;AACA,iBAAiB,gBAAgB;AACjC;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,iBAAiB,gBAAgB;AACjC;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,iBAAiB,gBAAgB;AACjC;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA,UAAU;AACV;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,UAAU;AACV;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;A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) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"Pusher\"] = factory();\n\telse\n\t\troot[\"Pusher\"] = factory();\n})(window, function() {\nreturn "," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 3);\n","// Copyright (C) 2016 Dmitry Chestnykh\n// MIT License. See LICENSE file for details.\n\n/**\n * Package base64 implements Base64 encoding and decoding.\n */\n\n// Invalid character used in decoding to indicate\n// that the character to decode is out of range of\n// alphabet and cannot be decoded.\nconst INVALID_BYTE = 256;\n\n/**\n * Implements standard Base64 encoding.\n *\n * Operates in constant time.\n */\nexport class Coder {\n // TODO(dchest): methods to encode chunk-by-chunk.\n\n constructor(private _paddingCharacter = \"=\") { }\n\n encodedLength(length: number): number {\n if (!this._paddingCharacter) {\n return (length * 8 + 5) / 6 | 0;\n }\n return (length + 2) / 3 * 4 | 0;\n }\n\n encode(data: Uint8Array): string {\n let out = \"\";\n\n let i = 0;\n for (; i < data.length - 2; i += 3) {\n let c = (data[i] << 16) | (data[i + 1] << 8) | (data[i + 2]);\n out += this._encodeByte((c >>> 3 * 6) & 63);\n out += this._encodeByte((c >>> 2 * 6) & 63);\n out += this._encodeByte((c >>> 1 * 6) & 63);\n out += this._encodeByte((c >>> 0 * 6) & 63);\n }\n\n const left = data.length - i;\n if (left > 0) {\n let c = (data[i] << 16) | (left === 2 ? data[i + 1] << 8 : 0);\n out += this._encodeByte((c >>> 3 * 6) & 63);\n out += this._encodeByte((c >>> 2 * 6) & 63);\n if (left === 2) {\n out += this._encodeByte((c >>> 1 * 6) & 63);\n } else {\n out += this._paddingCharacter || \"\";\n }\n out += this._paddingCharacter || \"\";\n }\n\n return out;\n }\n\n maxDecodedLength(length: number): number {\n if (!this._paddingCharacter) {\n return (length * 6 + 7) / 8 | 0;\n }\n return length / 4 * 3 | 0;\n }\n\n decodedLength(s: string): number {\n return this.maxDecodedLength(s.length - this._getPaddingLength(s));\n }\n\n decode(s: string): Uint8Array {\n if (s.length === 0) {\n return new Uint8Array(0);\n }\n const paddingLength = this._getPaddingLength(s);\n const length = s.length - paddingLength;\n const out = new Uint8Array(this.maxDecodedLength(length));\n let op = 0;\n let i = 0;\n let haveBad = 0;\n let v0 = 0, v1 = 0, v2 = 0, v3 = 0;\n for (; i < length - 4; i += 4) {\n v0 = this._decodeChar(s.charCodeAt(i + 0));\n v1 = this._decodeChar(s.charCodeAt(i + 1));\n v2 = this._decodeChar(s.charCodeAt(i + 2));\n v3 = this._decodeChar(s.charCodeAt(i + 3));\n out[op++] = (v0 << 2) | (v1 >>> 4);\n out[op++] = (v1 << 4) | (v2 >>> 2);\n out[op++] = (v2 << 6) | v3;\n haveBad |= v0 & INVALID_BYTE;\n haveBad |= v1 & INVALID_BYTE;\n haveBad |= v2 & INVALID_BYTE;\n haveBad |= v3 & INVALID_BYTE;\n }\n if (i < length - 1) {\n v0 = this._decodeChar(s.charCodeAt(i));\n v1 = this._decodeChar(s.charCodeAt(i + 1));\n out[op++] = (v0 << 2) | (v1 >>> 4);\n haveBad |= v0 & INVALID_BYTE;\n haveBad |= v1 & INVALID_BYTE;\n }\n if (i < length - 2) {\n v2 = this._decodeChar(s.charCodeAt(i + 2));\n out[op++] = (v1 << 4) | (v2 >>> 2);\n haveBad |= v2 & INVALID_BYTE;\n }\n if (i < length - 3) {\n v3 = this._decodeChar(s.charCodeAt(i + 3));\n out[op++] = (v2 << 6) | v3;\n haveBad |= v3 & INVALID_BYTE;\n }\n if (haveBad !== 0) {\n throw new Error(\"Base64Coder: incorrect characters for decoding\");\n }\n return out;\n }\n\n // Standard encoding have the following encoded/decoded ranges,\n // which we need to convert between.\n //\n // ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 0123456789 + /\n // Index: 0 - 25 26 - 51 52 - 61 62 63\n // ASCII: 65 - 90 97 - 122 48 - 57 43 47\n //\n\n // Encode 6 bits in b into a new character.\n protected _encodeByte(b: number): string {\n // Encoding uses constant time operations as follows:\n //\n // 1. Define comparison of A with B using (A - B) >>> 8:\n // if A > B, then result is positive integer\n // if A <= B, then result is 0\n //\n // 2. Define selection of C or 0 using bitwise AND: X & C:\n // if X == 0, then result is 0\n // if X != 0, then result is C\n //\n // 3. Start with the smallest comparison (b >= 0), which is always\n // true, so set the result to the starting ASCII value (65).\n //\n // 4. Continue comparing b to higher ASCII values, and selecting\n // zero if comparison isn't true, otherwise selecting a value\n // to add to result, which:\n //\n // a) undoes the previous addition\n // b) provides new value to add\n //\n let result = b;\n // b >= 0\n result += 65;\n // b > 25\n result += ((25 - b) >>> 8) & ((0 - 65) - 26 + 97);\n // b > 51\n result += ((51 - b) >>> 8) & ((26 - 97) - 52 + 48);\n // b > 61\n result += ((61 - b) >>> 8) & ((52 - 48) - 62 + 43);\n // b > 62\n result += ((62 - b) >>> 8) & ((62 - 43) - 63 + 47);\n\n return String.fromCharCode(result);\n }\n\n // Decode a character code into a byte.\n // Must return 256 if character is out of alphabet range.\n protected _decodeChar(c: number): number {\n // Decoding works similar to encoding: using the same comparison\n // function, but now it works on ranges: result is always incremented\n // by value, but this value becomes zero if the range is not\n // satisfied.\n //\n // Decoding starts with invalid value, 256, which is then\n // subtracted when the range is satisfied. If none of the ranges\n // apply, the function returns 256, which is then checked by\n // the caller to throw error.\n let result = INVALID_BYTE; // start with invalid character\n\n // c == 43 (c > 42 and c < 44)\n result += (((42 - c) & (c - 44)) >>> 8) & (-INVALID_BYTE + c - 43 + 62);\n // c == 47 (c > 46 and c < 48)\n result += (((46 - c) & (c - 48)) >>> 8) & (-INVALID_BYTE + c - 47 + 63);\n // c > 47 and c < 58\n result += (((47 - c) & (c - 58)) >>> 8) & (-INVALID_BYTE + c - 48 + 52);\n // c > 64 and c < 91\n result += (((64 - c) & (c - 91)) >>> 8) & (-INVALID_BYTE + c - 65 + 0);\n // c > 96 and c < 123\n result += (((96 - c) & (c - 123)) >>> 8) & (-INVALID_BYTE + c - 97 + 26);\n\n return result;\n }\n\n private _getPaddingLength(s: string): number {\n let paddingLength = 0;\n if (this._paddingCharacter) {\n for (let i = s.length - 1; i >= 0; i--) {\n if (s[i] !== this._paddingCharacter) {\n break;\n }\n paddingLength++;\n }\n if (s.length < 4 || paddingLength > 2) {\n throw new Error(\"Base64Coder: incorrect padding\");\n }\n }\n return paddingLength;\n }\n\n}\n\nconst stdCoder = new Coder();\n\nexport function encode(data: Uint8Array): string {\n return stdCoder.encode(data);\n}\n\nexport function decode(s: string): Uint8Array {\n return stdCoder.decode(s);\n}\n\n/**\n * Implements URL-safe Base64 encoding.\n * (Same as Base64, but '+' is replaced with '-', and '/' with '_').\n *\n * Operates in constant time.\n */\nexport class URLSafeCoder extends Coder {\n // URL-safe encoding have the following encoded/decoded ranges:\n //\n // ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 0123456789 - _\n // Index: 0 - 25 26 - 51 52 - 61 62 63\n // ASCII: 65 - 90 97 - 122 48 - 57 45 95\n //\n\n protected _encodeByte(b: number): string {\n let result = b;\n // b >= 0\n result += 65;\n // b > 25\n result += ((25 - b) >>> 8) & ((0 - 65) - 26 + 97);\n // b > 51\n result += ((51 - b) >>> 8) & ((26 - 97) - 52 + 48);\n // b > 61\n result += ((61 - b) >>> 8) & ((52 - 48) - 62 + 45);\n // b > 62\n result += ((62 - b) >>> 8) & ((62 - 45) - 63 + 95);\n\n return String.fromCharCode(result);\n }\n\n protected _decodeChar(c: number): number {\n let result = INVALID_BYTE;\n\n // c == 45 (c > 44 and c < 46)\n result += (((44 - c) & (c - 46)) >>> 8) & (-INVALID_BYTE + c - 45 + 62);\n // c == 95 (c > 94 and c < 96)\n result += (((94 - c) & (c - 96)) >>> 8) & (-INVALID_BYTE + c - 95 + 63);\n // c > 47 and c < 58\n result += (((47 - c) & (c - 58)) >>> 8) & (-INVALID_BYTE + c - 48 + 52);\n // c > 64 and c < 91\n result += (((64 - c) & (c - 91)) >>> 8) & (-INVALID_BYTE + c - 65 + 0);\n // c > 96 and c < 123\n result += (((96 - c) & (c - 123)) >>> 8) & (-INVALID_BYTE + c - 97 + 26);\n\n return result;\n }\n}\n\nconst urlSafeCoder = new URLSafeCoder();\n\nexport function encodeURLSafe(data: Uint8Array): string {\n return urlSafeCoder.encode(data);\n}\n\nexport function decodeURLSafe(s: string): Uint8Array {\n return urlSafeCoder.decode(s);\n}\n\n\nexport const encodedLength = (length: number) =>\n stdCoder.encodedLength(length);\n\nexport const maxDecodedLength = (length: number) =>\n stdCoder.maxDecodedLength(length);\n\nexport const decodedLength = (s: string) =>\n stdCoder.decodedLength(s);\n","// Copyright (C) 2016 Dmitry Chestnykh\n// MIT License. See LICENSE file for details.\n\n/**\n * Package utf8 implements UTF-8 encoding and decoding.\n */\n\nconst INVALID_UTF16 = \"utf8: invalid string\";\nconst INVALID_UTF8 = \"utf8: invalid source encoding\";\n\n/**\n * Encodes the given string into UTF-8 byte array.\n * Throws if the source string has invalid UTF-16 encoding.\n */\nexport function encode(s: string): Uint8Array {\n // Calculate result length and allocate output array.\n // encodedLength() also validates string and throws errors,\n // so we don't need repeat validation here.\n const arr = new Uint8Array(encodedLength(s));\n\n let pos = 0;\n for (let i = 0; i < s.length; i++) {\n let c = s.charCodeAt(i);\n if (c < 0x80) {\n arr[pos++] = c;\n } else if (c < 0x800) {\n arr[pos++] = 0xc0 | c >> 6;\n arr[pos++] = 0x80 | c & 0x3f;\n } else if (c < 0xd800) {\n arr[pos++] = 0xe0 | c >> 12;\n arr[pos++] = 0x80 | (c >> 6) & 0x3f;\n arr[pos++] = 0x80 | c & 0x3f;\n } else {\n i++; // get one more character\n c = (c & 0x3ff) << 10;\n c |= s.charCodeAt(i) & 0x3ff;\n c += 0x10000;\n\n arr[pos++] = 0xf0 | c >> 18;\n arr[pos++] = 0x80 | (c >> 12) & 0x3f;\n arr[pos++] = 0x80 | (c >> 6) & 0x3f;\n arr[pos++] = 0x80 | c & 0x3f;\n }\n }\n return arr;\n}\n\n/**\n * Returns the number of bytes required to encode the given string into UTF-8.\n * Throws if the source string has invalid UTF-16 encoding.\n */\nexport function encodedLength(s: string): number {\n let result = 0;\n for (let i = 0; i < s.length; i++) {\n const c = s.charCodeAt(i);\n if (c < 0x80) {\n result += 1;\n } else if (c < 0x800) {\n result += 2;\n } else if (c < 0xd800) {\n result += 3;\n } else if (c <= 0xdfff) {\n if (i >= s.length - 1) {\n throw new Error(INVALID_UTF16);\n }\n i++; // \"eat\" next character\n result += 4;\n } else {\n throw new Error(INVALID_UTF16);\n }\n }\n return result;\n}\n\n/**\n * Decodes the given byte array from UTF-8 into a string.\n * Throws if encoding is invalid.\n */\nexport function decode(arr: Uint8Array): string {\n const chars: string[] = [];\n for (let i = 0; i < arr.length; i++) {\n let b = arr[i];\n\n if (b & 0x80) {\n let min;\n if (b < 0xe0) {\n // Need 1 more byte.\n if (i >= arr.length) {\n throw new Error(INVALID_UTF8);\n }\n const n1 = arr[++i];\n if ((n1 & 0xc0) !== 0x80) {\n throw new Error(INVALID_UTF8);\n }\n b = (b & 0x1f) << 6 | (n1 & 0x3f);\n min = 0x80;\n } else if (b < 0xf0) {\n // Need 2 more bytes.\n if (i >= arr.length - 1) {\n throw new Error(INVALID_UTF8);\n }\n const n1 = arr[++i];\n const n2 = arr[++i];\n if ((n1 & 0xc0) !== 0x80 || (n2 & 0xc0) !== 0x80) {\n throw new Error(INVALID_UTF8);\n }\n b = (b & 0x0f) << 12 | (n1 & 0x3f) << 6 | (n2 & 0x3f);\n min = 0x800;\n } else if (b < 0xf8) {\n // Need 3 more bytes.\n if (i >= arr.length - 2) {\n throw new Error(INVALID_UTF8);\n }\n const n1 = arr[++i];\n const n2 = arr[++i];\n const n3 = arr[++i];\n if ((n1 & 0xc0) !== 0x80 || (n2 & 0xc0) !== 0x80 || (n3 & 0xc0) !== 0x80) {\n throw new Error(INVALID_UTF8);\n }\n b = (b & 0x0f) << 18 | (n1 & 0x3f) << 12 | (n2 & 0x3f) << 6 | (n3 & 0x3f);\n min = 0x10000;\n } else {\n throw new Error(INVALID_UTF8);\n }\n\n if (b < min || (b >= 0xd800 && b <= 0xdfff)) {\n throw new Error(INVALID_UTF8);\n }\n\n if (b >= 0x10000) {\n // Surrogate pair.\n if (b > 0x10ffff) {\n throw new Error(INVALID_UTF8);\n }\n b -= 0x10000;\n chars.push(String.fromCharCode(0xd800 | (b >> 10)));\n b = 0xdc00 | (b & 0x3ff);\n }\n }\n\n chars.push(String.fromCharCode(b));\n }\n return chars.join(\"\");\n}\n","(function(nacl) {\n'use strict';\n\n// Ported in 2014 by Dmitry Chestnykh and Devi Mandiri.\n// Public domain.\n//\n// Implementation derived from TweetNaCl version 20140427.\n// See for details: http://tweetnacl.cr.yp.to/\n\nvar gf = function(init) {\n var i, r = new Float64Array(16);\n if (init) for (i = 0; i < init.length; i++) r[i] = init[i];\n return r;\n};\n\n// Pluggable, initialized in high-level API below.\nvar randombytes = function(/* x, n */) { throw new Error('no PRNG'); };\n\nvar _0 = new Uint8Array(16);\nvar _9 = new Uint8Array(32); _9[0] = 9;\n\nvar gf0 = gf(),\n gf1 = gf([1]),\n _121665 = gf([0xdb41, 1]),\n D = gf([0x78a3, 0x1359, 0x4dca, 0x75eb, 0xd8ab, 0x4141, 0x0a4d, 0x0070, 0xe898, 0x7779, 0x4079, 0x8cc7, 0xfe73, 0x2b6f, 0x6cee, 0x5203]),\n D2 = gf([0xf159, 0x26b2, 0x9b94, 0xebd6, 0xb156, 0x8283, 0x149a, 0x00e0, 0xd130, 0xeef3, 0x80f2, 0x198e, 0xfce7, 0x56df, 0xd9dc, 0x2406]),\n X = gf([0xd51a, 0x8f25, 0x2d60, 0xc956, 0xa7b2, 0x9525, 0xc760, 0x692c, 0xdc5c, 0xfdd6, 0xe231, 0xc0a4, 0x53fe, 0xcd6e, 0x36d3, 0x2169]),\n Y = gf([0x6658, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666]),\n I = gf([0xa0b0, 0x4a0e, 0x1b27, 0xc4ee, 0xe478, 0xad2f, 0x1806, 0x2f43, 0xd7a7, 0x3dfb, 0x0099, 0x2b4d, 0xdf0b, 0x4fc1, 0x2480, 0x2b83]);\n\nfunction ts64(x, i, h, l) {\n x[i] = (h >> 24) & 0xff;\n x[i+1] = (h >> 16) & 0xff;\n x[i+2] = (h >> 8) & 0xff;\n x[i+3] = h & 0xff;\n x[i+4] = (l >> 24) & 0xff;\n x[i+5] = (l >> 16) & 0xff;\n x[i+6] = (l >> 8) & 0xff;\n x[i+7] = l & 0xff;\n}\n\nfunction vn(x, xi, y, yi, n) {\n var i,d = 0;\n for (i = 0; i < n; i++) d |= x[xi+i]^y[yi+i];\n return (1 & ((d - 1) >>> 8)) - 1;\n}\n\nfunction crypto_verify_16(x, xi, y, yi) {\n return vn(x,xi,y,yi,16);\n}\n\nfunction crypto_verify_32(x, xi, y, yi) {\n return vn(x,xi,y,yi,32);\n}\n\nfunction core_salsa20(o, p, k, c) {\n var j0 = c[ 0] & 0xff | (c[ 1] & 0xff)<<8 | (c[ 2] & 0xff)<<16 | (c[ 3] & 0xff)<<24,\n j1 = k[ 0] & 0xff | (k[ 1] & 0xff)<<8 | (k[ 2] & 0xff)<<16 | (k[ 3] & 0xff)<<24,\n j2 = k[ 4] & 0xff | (k[ 5] & 0xff)<<8 | (k[ 6] & 0xff)<<16 | (k[ 7] & 0xff)<<24,\n j3 = k[ 8] & 0xff | (k[ 9] & 0xff)<<8 | (k[10] & 0xff)<<16 | (k[11] & 0xff)<<24,\n j4 = k[12] & 0xff | (k[13] & 0xff)<<8 | (k[14] & 0xff)<<16 | (k[15] & 0xff)<<24,\n j5 = c[ 4] & 0xff | (c[ 5] & 0xff)<<8 | (c[ 6] & 0xff)<<16 | (c[ 7] & 0xff)<<24,\n j6 = p[ 0] & 0xff | (p[ 1] & 0xff)<<8 | (p[ 2] & 0xff)<<16 | (p[ 3] & 0xff)<<24,\n j7 = p[ 4] & 0xff | (p[ 5] & 0xff)<<8 | (p[ 6] & 0xff)<<16 | (p[ 7] & 0xff)<<24,\n j8 = p[ 8] & 0xff | (p[ 9] & 0xff)<<8 | (p[10] & 0xff)<<16 | (p[11] & 0xff)<<24,\n j9 = p[12] & 0xff | (p[13] & 0xff)<<8 | (p[14] & 0xff)<<16 | (p[15] & 0xff)<<24,\n j10 = c[ 8] & 0xff | (c[ 9] & 0xff)<<8 | (c[10] & 0xff)<<16 | (c[11] & 0xff)<<24,\n j11 = k[16] & 0xff | (k[17] & 0xff)<<8 | (k[18] & 0xff)<<16 | (k[19] & 0xff)<<24,\n j12 = k[20] & 0xff | (k[21] & 0xff)<<8 | (k[22] & 0xff)<<16 | (k[23] & 0xff)<<24,\n j13 = k[24] & 0xff | (k[25] & 0xff)<<8 | (k[26] & 0xff)<<16 | (k[27] & 0xff)<<24,\n j14 = k[28] & 0xff | (k[29] & 0xff)<<8 | (k[30] & 0xff)<<16 | (k[31] & 0xff)<<24,\n j15 = c[12] & 0xff | (c[13] & 0xff)<<8 | (c[14] & 0xff)<<16 | (c[15] & 0xff)<<24;\n\n var x0 = j0, x1 = j1, x2 = j2, x3 = j3, x4 = j4, x5 = j5, x6 = j6, x7 = j7,\n x8 = j8, x9 = j9, x10 = j10, x11 = j11, x12 = j12, x13 = j13, x14 = j14,\n x15 = j15, u;\n\n for (var i = 0; i < 20; i += 2) {\n u = x0 + x12 | 0;\n x4 ^= u<<7 | u>>>(32-7);\n u = x4 + x0 | 0;\n x8 ^= u<<9 | u>>>(32-9);\n u = x8 + x4 | 0;\n x12 ^= u<<13 | u>>>(32-13);\n u = x12 + x8 | 0;\n x0 ^= u<<18 | u>>>(32-18);\n\n u = x5 + x1 | 0;\n x9 ^= u<<7 | u>>>(32-7);\n u = x9 + x5 | 0;\n x13 ^= u<<9 | u>>>(32-9);\n u = x13 + x9 | 0;\n x1 ^= u<<13 | u>>>(32-13);\n u = x1 + x13 | 0;\n x5 ^= u<<18 | u>>>(32-18);\n\n u = x10 + x6 | 0;\n x14 ^= u<<7 | u>>>(32-7);\n u = x14 + x10 | 0;\n x2 ^= u<<9 | u>>>(32-9);\n u = x2 + x14 | 0;\n x6 ^= u<<13 | u>>>(32-13);\n u = x6 + x2 | 0;\n x10 ^= u<<18 | u>>>(32-18);\n\n u = x15 + x11 | 0;\n x3 ^= u<<7 | u>>>(32-7);\n u = x3 + x15 | 0;\n x7 ^= u<<9 | u>>>(32-9);\n u = x7 + x3 | 0;\n x11 ^= u<<13 | u>>>(32-13);\n u = x11 + x7 | 0;\n x15 ^= u<<18 | u>>>(32-18);\n\n u = x0 + x3 | 0;\n x1 ^= u<<7 | u>>>(32-7);\n u = x1 + x0 | 0;\n x2 ^= u<<9 | u>>>(32-9);\n u = x2 + x1 | 0;\n x3 ^= u<<13 | u>>>(32-13);\n u = x3 + x2 | 0;\n x0 ^= u<<18 | u>>>(32-18);\n\n u = x5 + x4 | 0;\n x6 ^= u<<7 | u>>>(32-7);\n u = x6 + x5 | 0;\n x7 ^= u<<9 | u>>>(32-9);\n u = x7 + x6 | 0;\n x4 ^= u<<13 | u>>>(32-13);\n u = x4 + x7 | 0;\n x5 ^= u<<18 | u>>>(32-18);\n\n u = x10 + x9 | 0;\n x11 ^= u<<7 | u>>>(32-7);\n u = x11 + x10 | 0;\n x8 ^= u<<9 | u>>>(32-9);\n u = x8 + x11 | 0;\n x9 ^= u<<13 | u>>>(32-13);\n u = x9 + x8 | 0;\n x10 ^= u<<18 | u>>>(32-18);\n\n u = x15 + x14 | 0;\n x12 ^= u<<7 | u>>>(32-7);\n u = x12 + x15 | 0;\n x13 ^= u<<9 | u>>>(32-9);\n u = x13 + x12 | 0;\n x14 ^= u<<13 | u>>>(32-13);\n u = x14 + x13 | 0;\n x15 ^= u<<18 | u>>>(32-18);\n }\n x0 = x0 + j0 | 0;\n x1 = x1 + j1 | 0;\n x2 = x2 + j2 | 0;\n x3 = x3 + j3 | 0;\n x4 = x4 + j4 | 0;\n x5 = x5 + j5 | 0;\n x6 = x6 + j6 | 0;\n x7 = x7 + j7 | 0;\n x8 = x8 + j8 | 0;\n x9 = x9 + j9 | 0;\n x10 = x10 + j10 | 0;\n x11 = x11 + j11 | 0;\n x12 = x12 + j12 | 0;\n x13 = x13 + j13 | 0;\n x14 = x14 + j14 | 0;\n x15 = x15 + j15 | 0;\n\n o[ 0] = x0 >>> 0 & 0xff;\n o[ 1] = x0 >>> 8 & 0xff;\n o[ 2] = x0 >>> 16 & 0xff;\n o[ 3] = x0 >>> 24 & 0xff;\n\n o[ 4] = x1 >>> 0 & 0xff;\n o[ 5] = x1 >>> 8 & 0xff;\n o[ 6] = x1 >>> 16 & 0xff;\n o[ 7] = x1 >>> 24 & 0xff;\n\n o[ 8] = x2 >>> 0 & 0xff;\n o[ 9] = x2 >>> 8 & 0xff;\n o[10] = x2 >>> 16 & 0xff;\n o[11] = x2 >>> 24 & 0xff;\n\n o[12] = x3 >>> 0 & 0xff;\n o[13] = x3 >>> 8 & 0xff;\n o[14] = x3 >>> 16 & 0xff;\n o[15] = x3 >>> 24 & 0xff;\n\n o[16] = x4 >>> 0 & 0xff;\n o[17] = x4 >>> 8 & 0xff;\n o[18] = x4 >>> 16 & 0xff;\n o[19] = x4 >>> 24 & 0xff;\n\n o[20] = x5 >>> 0 & 0xff;\n o[21] = x5 >>> 8 & 0xff;\n o[22] = x5 >>> 16 & 0xff;\n o[23] = x5 >>> 24 & 0xff;\n\n o[24] = x6 >>> 0 & 0xff;\n o[25] = x6 >>> 8 & 0xff;\n o[26] = x6 >>> 16 & 0xff;\n o[27] = x6 >>> 24 & 0xff;\n\n o[28] = x7 >>> 0 & 0xff;\n o[29] = x7 >>> 8 & 0xff;\n o[30] = x7 >>> 16 & 0xff;\n o[31] = x7 >>> 24 & 0xff;\n\n o[32] = x8 >>> 0 & 0xff;\n o[33] = x8 >>> 8 & 0xff;\n o[34] = x8 >>> 16 & 0xff;\n o[35] = x8 >>> 24 & 0xff;\n\n o[36] = x9 >>> 0 & 0xff;\n o[37] = x9 >>> 8 & 0xff;\n o[38] = x9 >>> 16 & 0xff;\n o[39] = x9 >>> 24 & 0xff;\n\n o[40] = x10 >>> 0 & 0xff;\n o[41] = x10 >>> 8 & 0xff;\n o[42] = x10 >>> 16 & 0xff;\n o[43] = x10 >>> 24 & 0xff;\n\n o[44] = x11 >>> 0 & 0xff;\n o[45] = x11 >>> 8 & 0xff;\n o[46] = x11 >>> 16 & 0xff;\n o[47] = x11 >>> 24 & 0xff;\n\n o[48] = x12 >>> 0 & 0xff;\n o[49] = x12 >>> 8 & 0xff;\n o[50] = x12 >>> 16 & 0xff;\n o[51] = x12 >>> 24 & 0xff;\n\n o[52] = x13 >>> 0 & 0xff;\n o[53] = x13 >>> 8 & 0xff;\n o[54] = x13 >>> 16 & 0xff;\n o[55] = x13 >>> 24 & 0xff;\n\n o[56] = x14 >>> 0 & 0xff;\n o[57] = x14 >>> 8 & 0xff;\n o[58] = x14 >>> 16 & 0xff;\n o[59] = x14 >>> 24 & 0xff;\n\n o[60] = x15 >>> 0 & 0xff;\n o[61] = x15 >>> 8 & 0xff;\n o[62] = x15 >>> 16 & 0xff;\n o[63] = x15 >>> 24 & 0xff;\n}\n\nfunction core_hsalsa20(o,p,k,c) {\n var j0 = c[ 0] & 0xff | (c[ 1] & 0xff)<<8 | (c[ 2] & 0xff)<<16 | (c[ 3] & 0xff)<<24,\n j1 = k[ 0] & 0xff | (k[ 1] & 0xff)<<8 | (k[ 2] & 0xff)<<16 | (k[ 3] & 0xff)<<24,\n j2 = k[ 4] & 0xff | (k[ 5] & 0xff)<<8 | (k[ 6] & 0xff)<<16 | (k[ 7] & 0xff)<<24,\n j3 = k[ 8] & 0xff | (k[ 9] & 0xff)<<8 | (k[10] & 0xff)<<16 | (k[11] & 0xff)<<24,\n j4 = k[12] & 0xff | (k[13] & 0xff)<<8 | (k[14] & 0xff)<<16 | (k[15] & 0xff)<<24,\n j5 = c[ 4] & 0xff | (c[ 5] & 0xff)<<8 | (c[ 6] & 0xff)<<16 | (c[ 7] & 0xff)<<24,\n j6 = p[ 0] & 0xff | (p[ 1] & 0xff)<<8 | (p[ 2] & 0xff)<<16 | (p[ 3] & 0xff)<<24,\n j7 = p[ 4] & 0xff | (p[ 5] & 0xff)<<8 | (p[ 6] & 0xff)<<16 | (p[ 7] & 0xff)<<24,\n j8 = p[ 8] & 0xff | (p[ 9] & 0xff)<<8 | (p[10] & 0xff)<<16 | (p[11] & 0xff)<<24,\n j9 = p[12] & 0xff | (p[13] & 0xff)<<8 | (p[14] & 0xff)<<16 | (p[15] & 0xff)<<24,\n j10 = c[ 8] & 0xff | (c[ 9] & 0xff)<<8 | (c[10] & 0xff)<<16 | (c[11] & 0xff)<<24,\n j11 = k[16] & 0xff | (k[17] & 0xff)<<8 | (k[18] & 0xff)<<16 | (k[19] & 0xff)<<24,\n j12 = k[20] & 0xff | (k[21] & 0xff)<<8 | (k[22] & 0xff)<<16 | (k[23] & 0xff)<<24,\n j13 = k[24] & 0xff | (k[25] & 0xff)<<8 | (k[26] & 0xff)<<16 | (k[27] & 0xff)<<24,\n j14 = k[28] & 0xff | (k[29] & 0xff)<<8 | (k[30] & 0xff)<<16 | (k[31] & 0xff)<<24,\n j15 = c[12] & 0xff | (c[13] & 0xff)<<8 | (c[14] & 0xff)<<16 | (c[15] & 0xff)<<24;\n\n var x0 = j0, x1 = j1, x2 = j2, x3 = j3, x4 = j4, x5 = j5, x6 = j6, x7 = j7,\n x8 = j8, x9 = j9, x10 = j10, x11 = j11, x12 = j12, x13 = j13, x14 = j14,\n x15 = j15, u;\n\n for (var i = 0; i < 20; i += 2) {\n u = x0 + x12 | 0;\n x4 ^= u<<7 | u>>>(32-7);\n u = x4 + x0 | 0;\n x8 ^= u<<9 | u>>>(32-9);\n u = x8 + x4 | 0;\n x12 ^= u<<13 | u>>>(32-13);\n u = x12 + x8 | 0;\n x0 ^= u<<18 | u>>>(32-18);\n\n u = x5 + x1 | 0;\n x9 ^= u<<7 | u>>>(32-7);\n u = x9 + x5 | 0;\n x13 ^= u<<9 | u>>>(32-9);\n u = x13 + x9 | 0;\n x1 ^= u<<13 | u>>>(32-13);\n u = x1 + x13 | 0;\n x5 ^= u<<18 | u>>>(32-18);\n\n u = x10 + x6 | 0;\n x14 ^= u<<7 | u>>>(32-7);\n u = x14 + x10 | 0;\n x2 ^= u<<9 | u>>>(32-9);\n u = x2 + x14 | 0;\n x6 ^= u<<13 | u>>>(32-13);\n u = x6 + x2 | 0;\n x10 ^= u<<18 | u>>>(32-18);\n\n u = x15 + x11 | 0;\n x3 ^= u<<7 | u>>>(32-7);\n u = x3 + x15 | 0;\n x7 ^= u<<9 | u>>>(32-9);\n u = x7 + x3 | 0;\n x11 ^= u<<13 | u>>>(32-13);\n u = x11 + x7 | 0;\n x15 ^= u<<18 | u>>>(32-18);\n\n u = x0 + x3 | 0;\n x1 ^= u<<7 | u>>>(32-7);\n u = x1 + x0 | 0;\n x2 ^= u<<9 | u>>>(32-9);\n u = x2 + x1 | 0;\n x3 ^= u<<13 | u>>>(32-13);\n u = x3 + x2 | 0;\n x0 ^= u<<18 | u>>>(32-18);\n\n u = x5 + x4 | 0;\n x6 ^= u<<7 | u>>>(32-7);\n u = x6 + x5 | 0;\n x7 ^= u<<9 | u>>>(32-9);\n u = x7 + x6 | 0;\n x4 ^= u<<13 | u>>>(32-13);\n u = x4 + x7 | 0;\n x5 ^= u<<18 | u>>>(32-18);\n\n u = x10 + x9 | 0;\n x11 ^= u<<7 | u>>>(32-7);\n u = x11 + x10 | 0;\n x8 ^= u<<9 | u>>>(32-9);\n u = x8 + x11 | 0;\n x9 ^= u<<13 | u>>>(32-13);\n u = x9 + x8 | 0;\n x10 ^= u<<18 | u>>>(32-18);\n\n u = x15 + x14 | 0;\n x12 ^= u<<7 | u>>>(32-7);\n u = x12 + x15 | 0;\n x13 ^= u<<9 | u>>>(32-9);\n u = x13 + x12 | 0;\n x14 ^= u<<13 | u>>>(32-13);\n u = x14 + x13 | 0;\n x15 ^= u<<18 | u>>>(32-18);\n }\n\n o[ 0] = x0 >>> 0 & 0xff;\n o[ 1] = x0 >>> 8 & 0xff;\n o[ 2] = x0 >>> 16 & 0xff;\n o[ 3] = x0 >>> 24 & 0xff;\n\n o[ 4] = x5 >>> 0 & 0xff;\n o[ 5] = x5 >>> 8 & 0xff;\n o[ 6] = x5 >>> 16 & 0xff;\n o[ 7] = x5 >>> 24 & 0xff;\n\n o[ 8] = x10 >>> 0 & 0xff;\n o[ 9] = x10 >>> 8 & 0xff;\n o[10] = x10 >>> 16 & 0xff;\n o[11] = x10 >>> 24 & 0xff;\n\n o[12] = x15 >>> 0 & 0xff;\n o[13] = x15 >>> 8 & 0xff;\n o[14] = x15 >>> 16 & 0xff;\n o[15] = x15 >>> 24 & 0xff;\n\n o[16] = x6 >>> 0 & 0xff;\n o[17] = x6 >>> 8 & 0xff;\n o[18] = x6 >>> 16 & 0xff;\n o[19] = x6 >>> 24 & 0xff;\n\n o[20] = x7 >>> 0 & 0xff;\n o[21] = x7 >>> 8 & 0xff;\n o[22] = x7 >>> 16 & 0xff;\n o[23] = x7 >>> 24 & 0xff;\n\n o[24] = x8 >>> 0 & 0xff;\n o[25] = x8 >>> 8 & 0xff;\n o[26] = x8 >>> 16 & 0xff;\n o[27] = x8 >>> 24 & 0xff;\n\n o[28] = x9 >>> 0 & 0xff;\n o[29] = x9 >>> 8 & 0xff;\n o[30] = x9 >>> 16 & 0xff;\n o[31] = x9 >>> 24 & 0xff;\n}\n\nfunction crypto_core_salsa20(out,inp,k,c) {\n core_salsa20(out,inp,k,c);\n}\n\nfunction crypto_core_hsalsa20(out,inp,k,c) {\n core_hsalsa20(out,inp,k,c);\n}\n\nvar sigma = new Uint8Array([101, 120, 112, 97, 110, 100, 32, 51, 50, 45, 98, 121, 116, 101, 32, 107]);\n // \"expand 32-byte k\"\n\nfunction crypto_stream_salsa20_xor(c,cpos,m,mpos,b,n,k) {\n var z = new Uint8Array(16), x = new Uint8Array(64);\n var u, i;\n for (i = 0; i < 16; i++) z[i] = 0;\n for (i = 0; i < 8; i++) z[i] = n[i];\n while (b >= 64) {\n crypto_core_salsa20(x,z,k,sigma);\n for (i = 0; i < 64; i++) c[cpos+i] = m[mpos+i] ^ x[i];\n u = 1;\n for (i = 8; i < 16; i++) {\n u = u + (z[i] & 0xff) | 0;\n z[i] = u & 0xff;\n u >>>= 8;\n }\n b -= 64;\n cpos += 64;\n mpos += 64;\n }\n if (b > 0) {\n crypto_core_salsa20(x,z,k,sigma);\n for (i = 0; i < b; i++) c[cpos+i] = m[mpos+i] ^ x[i];\n }\n return 0;\n}\n\nfunction crypto_stream_salsa20(c,cpos,b,n,k) {\n var z = new Uint8Array(16), x = new Uint8Array(64);\n var u, i;\n for (i = 0; i < 16; i++) z[i] = 0;\n for (i = 0; i < 8; i++) z[i] = n[i];\n while (b >= 64) {\n crypto_core_salsa20(x,z,k,sigma);\n for (i = 0; i < 64; i++) c[cpos+i] = x[i];\n u = 1;\n for (i = 8; i < 16; i++) {\n u = u + (z[i] & 0xff) | 0;\n z[i] = u & 0xff;\n u >>>= 8;\n }\n b -= 64;\n cpos += 64;\n }\n if (b > 0) {\n crypto_core_salsa20(x,z,k,sigma);\n for (i = 0; i < b; i++) c[cpos+i] = x[i];\n }\n return 0;\n}\n\nfunction crypto_stream(c,cpos,d,n,k) {\n var s = new Uint8Array(32);\n crypto_core_hsalsa20(s,n,k,sigma);\n var sn = new Uint8Array(8);\n for (var i = 0; i < 8; i++) sn[i] = n[i+16];\n return crypto_stream_salsa20(c,cpos,d,sn,s);\n}\n\nfunction crypto_stream_xor(c,cpos,m,mpos,d,n,k) {\n var s = new Uint8Array(32);\n crypto_core_hsalsa20(s,n,k,sigma);\n var sn = new Uint8Array(8);\n for (var i = 0; i < 8; i++) sn[i] = n[i+16];\n return crypto_stream_salsa20_xor(c,cpos,m,mpos,d,sn,s);\n}\n\n/*\n* Port of Andrew Moon's Poly1305-donna-16. Public domain.\n* https://github.com/floodyberry/poly1305-donna\n*/\n\nvar poly1305 = function(key) {\n this.buffer = new Uint8Array(16);\n this.r = new Uint16Array(10);\n this.h = new Uint16Array(10);\n this.pad = new Uint16Array(8);\n this.leftover = 0;\n this.fin = 0;\n\n var t0, t1, t2, t3, t4, t5, t6, t7;\n\n t0 = key[ 0] & 0xff | (key[ 1] & 0xff) << 8; this.r[0] = ( t0 ) & 0x1fff;\n t1 = key[ 2] & 0xff | (key[ 3] & 0xff) << 8; this.r[1] = ((t0 >>> 13) | (t1 << 3)) & 0x1fff;\n t2 = key[ 4] & 0xff | (key[ 5] & 0xff) << 8; this.r[2] = ((t1 >>> 10) | (t2 << 6)) & 0x1f03;\n t3 = key[ 6] & 0xff | (key[ 7] & 0xff) << 8; this.r[3] = ((t2 >>> 7) | (t3 << 9)) & 0x1fff;\n t4 = key[ 8] & 0xff | (key[ 9] & 0xff) << 8; this.r[4] = ((t3 >>> 4) | (t4 << 12)) & 0x00ff;\n this.r[5] = ((t4 >>> 1)) & 0x1ffe;\n t5 = key[10] & 0xff | (key[11] & 0xff) << 8; this.r[6] = ((t4 >>> 14) | (t5 << 2)) & 0x1fff;\n t6 = key[12] & 0xff | (key[13] & 0xff) << 8; this.r[7] = ((t5 >>> 11) | (t6 << 5)) & 0x1f81;\n t7 = key[14] & 0xff | (key[15] & 0xff) << 8; this.r[8] = ((t6 >>> 8) | (t7 << 8)) & 0x1fff;\n this.r[9] = ((t7 >>> 5)) & 0x007f;\n\n this.pad[0] = key[16] & 0xff | (key[17] & 0xff) << 8;\n this.pad[1] = key[18] & 0xff | (key[19] & 0xff) << 8;\n this.pad[2] = key[20] & 0xff | (key[21] & 0xff) << 8;\n this.pad[3] = key[22] & 0xff | (key[23] & 0xff) << 8;\n this.pad[4] = key[24] & 0xff | (key[25] & 0xff) << 8;\n this.pad[5] = key[26] & 0xff | (key[27] & 0xff) << 8;\n this.pad[6] = key[28] & 0xff | (key[29] & 0xff) << 8;\n this.pad[7] = key[30] & 0xff | (key[31] & 0xff) << 8;\n};\n\npoly1305.prototype.blocks = function(m, mpos, bytes) {\n var hibit = this.fin ? 0 : (1 << 11);\n var t0, t1, t2, t3, t4, t5, t6, t7, c;\n var d0, d1, d2, d3, d4, d5, d6, d7, d8, d9;\n\n var h0 = this.h[0],\n h1 = this.h[1],\n h2 = this.h[2],\n h3 = this.h[3],\n h4 = this.h[4],\n h5 = this.h[5],\n h6 = this.h[6],\n h7 = this.h[7],\n h8 = this.h[8],\n h9 = this.h[9];\n\n var r0 = this.r[0],\n r1 = this.r[1],\n r2 = this.r[2],\n r3 = this.r[3],\n r4 = this.r[4],\n r5 = this.r[5],\n r6 = this.r[6],\n r7 = this.r[7],\n r8 = this.r[8],\n r9 = this.r[9];\n\n while (bytes >= 16) {\n t0 = m[mpos+ 0] & 0xff | (m[mpos+ 1] & 0xff) << 8; h0 += ( t0 ) & 0x1fff;\n t1 = m[mpos+ 2] & 0xff | (m[mpos+ 3] & 0xff) << 8; h1 += ((t0 >>> 13) | (t1 << 3)) & 0x1fff;\n t2 = m[mpos+ 4] & 0xff | (m[mpos+ 5] & 0xff) << 8; h2 += ((t1 >>> 10) | (t2 << 6)) & 0x1fff;\n t3 = m[mpos+ 6] & 0xff | (m[mpos+ 7] & 0xff) << 8; h3 += ((t2 >>> 7) | (t3 << 9)) & 0x1fff;\n t4 = m[mpos+ 8] & 0xff | (m[mpos+ 9] & 0xff) << 8; h4 += ((t3 >>> 4) | (t4 << 12)) & 0x1fff;\n h5 += ((t4 >>> 1)) & 0x1fff;\n t5 = m[mpos+10] & 0xff | (m[mpos+11] & 0xff) << 8; h6 += ((t4 >>> 14) | (t5 << 2)) & 0x1fff;\n t6 = m[mpos+12] & 0xff | (m[mpos+13] & 0xff) << 8; h7 += ((t5 >>> 11) | (t6 << 5)) & 0x1fff;\n t7 = m[mpos+14] & 0xff | (m[mpos+15] & 0xff) << 8; h8 += ((t6 >>> 8) | (t7 << 8)) & 0x1fff;\n h9 += ((t7 >>> 5)) | hibit;\n\n c = 0;\n\n d0 = c;\n d0 += h0 * r0;\n d0 += h1 * (5 * r9);\n d0 += h2 * (5 * r8);\n d0 += h3 * (5 * r7);\n d0 += h4 * (5 * r6);\n c = (d0 >>> 13); d0 &= 0x1fff;\n d0 += h5 * (5 * r5);\n d0 += h6 * (5 * r4);\n d0 += h7 * (5 * r3);\n d0 += h8 * (5 * r2);\n d0 += h9 * (5 * r1);\n c += (d0 >>> 13); d0 &= 0x1fff;\n\n d1 = c;\n d1 += h0 * r1;\n d1 += h1 * r0;\n d1 += h2 * (5 * r9);\n d1 += h3 * (5 * r8);\n d1 += h4 * (5 * r7);\n c = (d1 >>> 13); d1 &= 0x1fff;\n d1 += h5 * (5 * r6);\n d1 += h6 * (5 * r5);\n d1 += h7 * (5 * r4);\n d1 += h8 * (5 * r3);\n d1 += h9 * (5 * r2);\n c += (d1 >>> 13); d1 &= 0x1fff;\n\n d2 = c;\n d2 += h0 * r2;\n d2 += h1 * r1;\n d2 += h2 * r0;\n d2 += h3 * (5 * r9);\n d2 += h4 * (5 * r8);\n c = (d2 >>> 13); d2 &= 0x1fff;\n d2 += h5 * (5 * r7);\n d2 += h6 * (5 * r6);\n d2 += h7 * (5 * r5);\n d2 += h8 * (5 * r4);\n d2 += h9 * (5 * r3);\n c += (d2 >>> 13); d2 &= 0x1fff;\n\n d3 = c;\n d3 += h0 * r3;\n d3 += h1 * r2;\n d3 += h2 * r1;\n d3 += h3 * r0;\n d3 += h4 * (5 * r9);\n c = (d3 >>> 13); d3 &= 0x1fff;\n d3 += h5 * (5 * r8);\n d3 += h6 * (5 * r7);\n d3 += h7 * (5 * r6);\n d3 += h8 * (5 * r5);\n d3 += h9 * (5 * r4);\n c += (d3 >>> 13); d3 &= 0x1fff;\n\n d4 = c;\n d4 += h0 * r4;\n d4 += h1 * r3;\n d4 += h2 * r2;\n d4 += h3 * r1;\n d4 += h4 * r0;\n c = (d4 >>> 13); d4 &= 0x1fff;\n d4 += h5 * (5 * r9);\n d4 += h6 * (5 * r8);\n d4 += h7 * (5 * r7);\n d4 += h8 * (5 * r6);\n d4 += h9 * (5 * r5);\n c += (d4 >>> 13); d4 &= 0x1fff;\n\n d5 = c;\n d5 += h0 * r5;\n d5 += h1 * r4;\n d5 += h2 * r3;\n d5 += h3 * r2;\n d5 += h4 * r1;\n c = (d5 >>> 13); d5 &= 0x1fff;\n d5 += h5 * r0;\n d5 += h6 * (5 * r9);\n d5 += h7 * (5 * r8);\n d5 += h8 * (5 * r7);\n d5 += h9 * (5 * r6);\n c += (d5 >>> 13); d5 &= 0x1fff;\n\n d6 = c;\n d6 += h0 * r6;\n d6 += h1 * r5;\n d6 += h2 * r4;\n d6 += h3 * r3;\n d6 += h4 * r2;\n c = (d6 >>> 13); d6 &= 0x1fff;\n d6 += h5 * r1;\n d6 += h6 * r0;\n d6 += h7 * (5 * r9);\n d6 += h8 * (5 * r8);\n d6 += h9 * (5 * r7);\n c += (d6 >>> 13); d6 &= 0x1fff;\n\n d7 = c;\n d7 += h0 * r7;\n d7 += h1 * r6;\n d7 += h2 * r5;\n d7 += h3 * r4;\n d7 += h4 * r3;\n c = (d7 >>> 13); d7 &= 0x1fff;\n d7 += h5 * r2;\n d7 += h6 * r1;\n d7 += h7 * r0;\n d7 += h8 * (5 * r9);\n d7 += h9 * (5 * r8);\n c += (d7 >>> 13); d7 &= 0x1fff;\n\n d8 = c;\n d8 += h0 * r8;\n d8 += h1 * r7;\n d8 += h2 * r6;\n d8 += h3 * r5;\n d8 += h4 * r4;\n c = (d8 >>> 13); d8 &= 0x1fff;\n d8 += h5 * r3;\n d8 += h6 * r2;\n d8 += h7 * r1;\n d8 += h8 * r0;\n d8 += h9 * (5 * r9);\n c += (d8 >>> 13); d8 &= 0x1fff;\n\n d9 = c;\n d9 += h0 * r9;\n d9 += h1 * r8;\n d9 += h2 * r7;\n d9 += h3 * r6;\n d9 += h4 * r5;\n c = (d9 >>> 13); d9 &= 0x1fff;\n d9 += h5 * r4;\n d9 += h6 * r3;\n d9 += h7 * r2;\n d9 += h8 * r1;\n d9 += h9 * r0;\n c += (d9 >>> 13); d9 &= 0x1fff;\n\n c = (((c << 2) + c)) | 0;\n c = (c + d0) | 0;\n d0 = c & 0x1fff;\n c = (c >>> 13);\n d1 += c;\n\n h0 = d0;\n h1 = d1;\n h2 = d2;\n h3 = d3;\n h4 = d4;\n h5 = d5;\n h6 = d6;\n h7 = d7;\n h8 = d8;\n h9 = d9;\n\n mpos += 16;\n bytes -= 16;\n }\n this.h[0] = h0;\n this.h[1] = h1;\n this.h[2] = h2;\n this.h[3] = h3;\n this.h[4] = h4;\n this.h[5] = h5;\n this.h[6] = h6;\n this.h[7] = h7;\n this.h[8] = h8;\n this.h[9] = h9;\n};\n\npoly1305.prototype.finish = function(mac, macpos) {\n var g = new Uint16Array(10);\n var c, mask, f, i;\n\n if (this.leftover) {\n i = this.leftover;\n this.buffer[i++] = 1;\n for (; i < 16; i++) this.buffer[i] = 0;\n this.fin = 1;\n this.blocks(this.buffer, 0, 16);\n }\n\n c = this.h[1] >>> 13;\n this.h[1] &= 0x1fff;\n for (i = 2; i < 10; i++) {\n this.h[i] += c;\n c = this.h[i] >>> 13;\n this.h[i] &= 0x1fff;\n }\n this.h[0] += (c * 5);\n c = this.h[0] >>> 13;\n this.h[0] &= 0x1fff;\n this.h[1] += c;\n c = this.h[1] >>> 13;\n this.h[1] &= 0x1fff;\n this.h[2] += c;\n\n g[0] = this.h[0] + 5;\n c = g[0] >>> 13;\n g[0] &= 0x1fff;\n for (i = 1; i < 10; i++) {\n g[i] = this.h[i] + c;\n c = g[i] >>> 13;\n g[i] &= 0x1fff;\n }\n g[9] -= (1 << 13);\n\n mask = (c ^ 1) - 1;\n for (i = 0; i < 10; i++) g[i] &= mask;\n mask = ~mask;\n for (i = 0; i < 10; i++) this.h[i] = (this.h[i] & mask) | g[i];\n\n this.h[0] = ((this.h[0] ) | (this.h[1] << 13) ) & 0xffff;\n this.h[1] = ((this.h[1] >>> 3) | (this.h[2] << 10) ) & 0xffff;\n this.h[2] = ((this.h[2] >>> 6) | (this.h[3] << 7) ) & 0xffff;\n this.h[3] = ((this.h[3] >>> 9) | (this.h[4] << 4) ) & 0xffff;\n this.h[4] = ((this.h[4] >>> 12) | (this.h[5] << 1) | (this.h[6] << 14)) & 0xffff;\n this.h[5] = ((this.h[6] >>> 2) | (this.h[7] << 11) ) & 0xffff;\n this.h[6] = ((this.h[7] >>> 5) | (this.h[8] << 8) ) & 0xffff;\n this.h[7] = ((this.h[8] >>> 8) | (this.h[9] << 5) ) & 0xffff;\n\n f = this.h[0] + this.pad[0];\n this.h[0] = f & 0xffff;\n for (i = 1; i < 8; i++) {\n f = (((this.h[i] + this.pad[i]) | 0) + (f >>> 16)) | 0;\n this.h[i] = f & 0xffff;\n }\n\n mac[macpos+ 0] = (this.h[0] >>> 0) & 0xff;\n mac[macpos+ 1] = (this.h[0] >>> 8) & 0xff;\n mac[macpos+ 2] = (this.h[1] >>> 0) & 0xff;\n mac[macpos+ 3] = (this.h[1] >>> 8) & 0xff;\n mac[macpos+ 4] = (this.h[2] >>> 0) & 0xff;\n mac[macpos+ 5] = (this.h[2] >>> 8) & 0xff;\n mac[macpos+ 6] = (this.h[3] >>> 0) & 0xff;\n mac[macpos+ 7] = (this.h[3] >>> 8) & 0xff;\n mac[macpos+ 8] = (this.h[4] >>> 0) & 0xff;\n mac[macpos+ 9] = (this.h[4] >>> 8) & 0xff;\n mac[macpos+10] = (this.h[5] >>> 0) & 0xff;\n mac[macpos+11] = (this.h[5] >>> 8) & 0xff;\n mac[macpos+12] = (this.h[6] >>> 0) & 0xff;\n mac[macpos+13] = (this.h[6] >>> 8) & 0xff;\n mac[macpos+14] = (this.h[7] >>> 0) & 0xff;\n mac[macpos+15] = (this.h[7] >>> 8) & 0xff;\n};\n\npoly1305.prototype.update = function(m, mpos, bytes) {\n var i, want;\n\n if (this.leftover) {\n want = (16 - this.leftover);\n if (want > bytes)\n want = bytes;\n for (i = 0; i < want; i++)\n this.buffer[this.leftover + i] = m[mpos+i];\n bytes -= want;\n mpos += want;\n this.leftover += want;\n if (this.leftover < 16)\n return;\n this.blocks(this.buffer, 0, 16);\n this.leftover = 0;\n }\n\n if (bytes >= 16) {\n want = bytes - (bytes % 16);\n this.blocks(m, mpos, want);\n mpos += want;\n bytes -= want;\n }\n\n if (bytes) {\n for (i = 0; i < bytes; i++)\n this.buffer[this.leftover + i] = m[mpos+i];\n this.leftover += bytes;\n }\n};\n\nfunction crypto_onetimeauth(out, outpos, m, mpos, n, k) {\n var s = new poly1305(k);\n s.update(m, mpos, n);\n s.finish(out, outpos);\n return 0;\n}\n\nfunction crypto_onetimeauth_verify(h, hpos, m, mpos, n, k) {\n var x = new Uint8Array(16);\n crypto_onetimeauth(x,0,m,mpos,n,k);\n return crypto_verify_16(h,hpos,x,0);\n}\n\nfunction crypto_secretbox(c,m,d,n,k) {\n var i;\n if (d < 32) return -1;\n crypto_stream_xor(c,0,m,0,d,n,k);\n crypto_onetimeauth(c, 16, c, 32, d - 32, c);\n for (i = 0; i < 16; i++) c[i] = 0;\n return 0;\n}\n\nfunction crypto_secretbox_open(m,c,d,n,k) {\n var i;\n var x = new Uint8Array(32);\n if (d < 32) return -1;\n crypto_stream(x,0,32,n,k);\n if (crypto_onetimeauth_verify(c, 16,c, 32,d - 32,x) !== 0) return -1;\n crypto_stream_xor(m,0,c,0,d,n,k);\n for (i = 0; i < 32; i++) m[i] = 0;\n return 0;\n}\n\nfunction set25519(r, a) {\n var i;\n for (i = 0; i < 16; i++) r[i] = a[i]|0;\n}\n\nfunction car25519(o) {\n var i, v, c = 1;\n for (i = 0; i < 16; i++) {\n v = o[i] + c + 65535;\n c = Math.floor(v / 65536);\n o[i] = v - c * 65536;\n }\n o[0] += c-1 + 37 * (c-1);\n}\n\nfunction sel25519(p, q, b) {\n var t, c = ~(b-1);\n for (var i = 0; i < 16; i++) {\n t = c & (p[i] ^ q[i]);\n p[i] ^= t;\n q[i] ^= t;\n }\n}\n\nfunction pack25519(o, n) {\n var i, j, b;\n var m = gf(), t = gf();\n for (i = 0; i < 16; i++) t[i] = n[i];\n car25519(t);\n car25519(t);\n car25519(t);\n for (j = 0; j < 2; j++) {\n m[0] = t[0] - 0xffed;\n for (i = 1; i < 15; i++) {\n m[i] = t[i] - 0xffff - ((m[i-1]>>16) & 1);\n m[i-1] &= 0xffff;\n }\n m[15] = t[15] - 0x7fff - ((m[14]>>16) & 1);\n b = (m[15]>>16) & 1;\n m[14] &= 0xffff;\n sel25519(t, m, 1-b);\n }\n for (i = 0; i < 16; i++) {\n o[2*i] = t[i] & 0xff;\n o[2*i+1] = t[i]>>8;\n }\n}\n\nfunction neq25519(a, b) {\n var c = new Uint8Array(32), d = new Uint8Array(32);\n pack25519(c, a);\n pack25519(d, b);\n return crypto_verify_32(c, 0, d, 0);\n}\n\nfunction par25519(a) {\n var d = new Uint8Array(32);\n pack25519(d, a);\n return d[0] & 1;\n}\n\nfunction unpack25519(o, n) {\n var i;\n for (i = 0; i < 16; i++) o[i] = n[2*i] + (n[2*i+1] << 8);\n o[15] &= 0x7fff;\n}\n\nfunction A(o, a, b) {\n for (var i = 0; i < 16; i++) o[i] = a[i] + b[i];\n}\n\nfunction Z(o, a, b) {\n for (var i = 0; i < 16; i++) o[i] = a[i] - b[i];\n}\n\nfunction M(o, a, b) {\n var v, c,\n t0 = 0, t1 = 0, t2 = 0, t3 = 0, t4 = 0, t5 = 0, t6 = 0, t7 = 0,\n t8 = 0, t9 = 0, t10 = 0, t11 = 0, t12 = 0, t13 = 0, t14 = 0, t15 = 0,\n t16 = 0, t17 = 0, t18 = 0, t19 = 0, t20 = 0, t21 = 0, t22 = 0, t23 = 0,\n t24 = 0, t25 = 0, t26 = 0, t27 = 0, t28 = 0, t29 = 0, t30 = 0,\n b0 = b[0],\n b1 = b[1],\n b2 = b[2],\n b3 = b[3],\n b4 = b[4],\n b5 = b[5],\n b6 = b[6],\n b7 = b[7],\n b8 = b[8],\n b9 = b[9],\n b10 = b[10],\n b11 = b[11],\n b12 = b[12],\n b13 = b[13],\n b14 = b[14],\n b15 = b[15];\n\n v = a[0];\n t0 += v * b0;\n t1 += v * b1;\n t2 += v * b2;\n t3 += v * b3;\n t4 += v * b4;\n t5 += v * b5;\n t6 += v * b6;\n t7 += v * b7;\n t8 += v * b8;\n t9 += v * b9;\n t10 += v * b10;\n t11 += v * b11;\n t12 += v * b12;\n t13 += v * b13;\n t14 += v * b14;\n t15 += v * b15;\n v = a[1];\n t1 += v * b0;\n t2 += v * b1;\n t3 += v * b2;\n t4 += v * b3;\n t5 += v * b4;\n t6 += v * b5;\n t7 += v * b6;\n t8 += v * b7;\n t9 += v * b8;\n t10 += v * b9;\n t11 += v * b10;\n t12 += v * b11;\n t13 += v * b12;\n t14 += v * b13;\n t15 += v * b14;\n t16 += v * b15;\n v = a[2];\n t2 += v * b0;\n t3 += v * b1;\n t4 += v * b2;\n t5 += v * b3;\n t6 += v * b4;\n t7 += v * b5;\n t8 += v * b6;\n t9 += v * b7;\n t10 += v * b8;\n t11 += v * b9;\n t12 += v * b10;\n t13 += v * b11;\n t14 += v * b12;\n t15 += v * b13;\n t16 += v * b14;\n t17 += v * b15;\n v = a[3];\n t3 += v * b0;\n t4 += v * b1;\n t5 += v * b2;\n t6 += v * b3;\n t7 += v * b4;\n t8 += v * b5;\n t9 += v * b6;\n t10 += v * b7;\n t11 += v * b8;\n t12 += v * b9;\n t13 += v * b10;\n t14 += v * b11;\n t15 += v * b12;\n t16 += v * b13;\n t17 += v * b14;\n t18 += v * b15;\n v = a[4];\n t4 += v * b0;\n t5 += v * b1;\n t6 += v * b2;\n t7 += v * b3;\n t8 += v * b4;\n t9 += v * b5;\n t10 += v * b6;\n t11 += v * b7;\n t12 += v * b8;\n t13 += v * b9;\n t14 += v * b10;\n t15 += v * b11;\n t16 += v * b12;\n t17 += v * b13;\n t18 += v * b14;\n t19 += v * b15;\n v = a[5];\n t5 += v * b0;\n t6 += v * b1;\n t7 += v * b2;\n t8 += v * b3;\n t9 += v * b4;\n t10 += v * b5;\n t11 += v * b6;\n t12 += v * b7;\n t13 += v * b8;\n t14 += v * b9;\n t15 += v * b10;\n t16 += v * b11;\n t17 += v * b12;\n t18 += v * b13;\n t19 += v * b14;\n t20 += v * b15;\n v = a[6];\n t6 += v * b0;\n t7 += v * b1;\n t8 += v * b2;\n t9 += v * b3;\n t10 += v * b4;\n t11 += v * b5;\n t12 += v * b6;\n t13 += v * b7;\n t14 += v * b8;\n t15 += v * b9;\n t16 += v * b10;\n t17 += v * b11;\n t18 += v * b12;\n t19 += v * b13;\n t20 += v * b14;\n t21 += v * b15;\n v = a[7];\n t7 += v * b0;\n t8 += v * b1;\n t9 += v * b2;\n t10 += v * b3;\n t11 += v * b4;\n t12 += v * b5;\n t13 += v * b6;\n t14 += v * b7;\n t15 += v * b8;\n t16 += v * b9;\n t17 += v * b10;\n t18 += v * b11;\n t19 += v * b12;\n t20 += v * b13;\n t21 += v * b14;\n t22 += v * b15;\n v = a[8];\n t8 += v * b0;\n t9 += v * b1;\n t10 += v * b2;\n t11 += v * b3;\n t12 += v * b4;\n t13 += v * b5;\n t14 += v * b6;\n t15 += v * b7;\n t16 += v * b8;\n t17 += v * b9;\n t18 += v * b10;\n t19 += v * b11;\n t20 += v * b12;\n t21 += v * b13;\n t22 += v * b14;\n t23 += v * b15;\n v = a[9];\n t9 += v * b0;\n t10 += v * b1;\n t11 += v * b2;\n t12 += v * b3;\n t13 += v * b4;\n t14 += v * b5;\n t15 += v * b6;\n t16 += v * b7;\n t17 += v * b8;\n t18 += v * b9;\n t19 += v * b10;\n t20 += v * b11;\n t21 += v * b12;\n t22 += v * b13;\n t23 += v * b14;\n t24 += v * b15;\n v = a[10];\n t10 += v * b0;\n t11 += v * b1;\n t12 += v * b2;\n t13 += v * b3;\n t14 += v * b4;\n t15 += v * b5;\n t16 += v * b6;\n t17 += v * b7;\n t18 += v * b8;\n t19 += v * b9;\n t20 += v * b10;\n t21 += v * b11;\n t22 += v * b12;\n t23 += v * b13;\n t24 += v * b14;\n t25 += v * b15;\n v = a[11];\n t11 += v * b0;\n t12 += v * b1;\n t13 += v * b2;\n t14 += v * b3;\n t15 += v * b4;\n t16 += v * b5;\n t17 += v * b6;\n t18 += v * b7;\n t19 += v * b8;\n t20 += v * b9;\n t21 += v * b10;\n t22 += v * b11;\n t23 += v * b12;\n t24 += v * b13;\n t25 += v * b14;\n t26 += v * b15;\n v = a[12];\n t12 += v * b0;\n t13 += v * b1;\n t14 += v * b2;\n t15 += v * b3;\n t16 += v * b4;\n t17 += v * b5;\n t18 += v * b6;\n t19 += v * b7;\n t20 += v * b8;\n t21 += v * b9;\n t22 += v * b10;\n t23 += v * b11;\n t24 += v * b12;\n t25 += v * b13;\n t26 += v * b14;\n t27 += v * b15;\n v = a[13];\n t13 += v * b0;\n t14 += v * b1;\n t15 += v * b2;\n t16 += v * b3;\n t17 += v * b4;\n t18 += v * b5;\n t19 += v * b6;\n t20 += v * b7;\n t21 += v * b8;\n t22 += v * b9;\n t23 += v * b10;\n t24 += v * b11;\n t25 += v * b12;\n t26 += v * b13;\n t27 += v * b14;\n t28 += v * b15;\n v = a[14];\n t14 += v * b0;\n t15 += v * b1;\n t16 += v * b2;\n t17 += v * b3;\n t18 += v * b4;\n t19 += v * b5;\n t20 += v * b6;\n t21 += v * b7;\n t22 += v * b8;\n t23 += v * b9;\n t24 += v * b10;\n t25 += v * b11;\n t26 += v * b12;\n t27 += v * b13;\n t28 += v * b14;\n t29 += v * b15;\n v = a[15];\n t15 += v * b0;\n t16 += v * b1;\n t17 += v * b2;\n t18 += v * b3;\n t19 += v * b4;\n t20 += v * b5;\n t21 += v * b6;\n t22 += v * b7;\n t23 += v * b8;\n t24 += v * b9;\n t25 += v * b10;\n t26 += v * b11;\n t27 += v * b12;\n t28 += v * b13;\n t29 += v * b14;\n t30 += v * b15;\n\n t0 += 38 * t16;\n t1 += 38 * t17;\n t2 += 38 * t18;\n t3 += 38 * t19;\n t4 += 38 * t20;\n t5 += 38 * t21;\n t6 += 38 * t22;\n t7 += 38 * t23;\n t8 += 38 * t24;\n t9 += 38 * t25;\n t10 += 38 * t26;\n t11 += 38 * t27;\n t12 += 38 * t28;\n t13 += 38 * t29;\n t14 += 38 * t30;\n // t15 left as is\n\n // first car\n c = 1;\n v = t0 + c + 65535; c = Math.floor(v / 65536); t0 = v - c * 65536;\n v = t1 + c + 65535; c = Math.floor(v / 65536); t1 = v - c * 65536;\n v = t2 + c + 65535; c = Math.floor(v / 65536); t2 = v - c * 65536;\n v = t3 + c + 65535; c = Math.floor(v / 65536); t3 = v - c * 65536;\n v = t4 + c + 65535; c = Math.floor(v / 65536); t4 = v - c * 65536;\n v = t5 + c + 65535; c = Math.floor(v / 65536); t5 = v - c * 65536;\n v = t6 + c + 65535; c = Math.floor(v / 65536); t6 = v - c * 65536;\n v = t7 + c + 65535; c = Math.floor(v / 65536); t7 = v - c * 65536;\n v = t8 + c + 65535; c = Math.floor(v / 65536); t8 = v - c * 65536;\n v = t9 + c + 65535; c = Math.floor(v / 65536); t9 = v - c * 65536;\n v = t10 + c + 65535; c = Math.floor(v / 65536); t10 = v - c * 65536;\n v = t11 + c + 65535; c = Math.floor(v / 65536); t11 = v - c * 65536;\n v = t12 + c + 65535; c = Math.floor(v / 65536); t12 = v - c * 65536;\n v = t13 + c + 65535; c = Math.floor(v / 65536); t13 = v - c * 65536;\n v = t14 + c + 65535; c = Math.floor(v / 65536); t14 = v - c * 65536;\n v = t15 + c + 65535; c = Math.floor(v / 65536); t15 = v - c * 65536;\n t0 += c-1 + 37 * (c-1);\n\n // second car\n c = 1;\n v = t0 + c + 65535; c = Math.floor(v / 65536); t0 = v - c * 65536;\n v = t1 + c + 65535; c = Math.floor(v / 65536); t1 = v - c * 65536;\n v = t2 + c + 65535; c = Math.floor(v / 65536); t2 = v - c * 65536;\n v = t3 + c + 65535; c = Math.floor(v / 65536); t3 = v - c * 65536;\n v = t4 + c + 65535; c = Math.floor(v / 65536); t4 = v - c * 65536;\n v = t5 + c + 65535; c = Math.floor(v / 65536); t5 = v - c * 65536;\n v = t6 + c + 65535; c = Math.floor(v / 65536); t6 = v - c * 65536;\n v = t7 + c + 65535; c = Math.floor(v / 65536); t7 = v - c * 65536;\n v = t8 + c + 65535; c = Math.floor(v / 65536); t8 = v - c * 65536;\n v = t9 + c + 65535; c = Math.floor(v / 65536); t9 = v - c * 65536;\n v = t10 + c + 65535; c = Math.floor(v / 65536); t10 = v - c * 65536;\n v = t11 + c + 65535; c = Math.floor(v / 65536); t11 = v - c * 65536;\n v = t12 + c + 65535; c = Math.floor(v / 65536); t12 = v - c * 65536;\n v = t13 + c + 65535; c = Math.floor(v / 65536); t13 = v - c * 65536;\n v = t14 + c + 65535; c = Math.floor(v / 65536); t14 = v - c * 65536;\n v = t15 + c + 65535; c = Math.floor(v / 65536); t15 = v - c * 65536;\n t0 += c-1 + 37 * (c-1);\n\n o[ 0] = t0;\n o[ 1] = t1;\n o[ 2] = t2;\n o[ 3] = t3;\n o[ 4] = t4;\n o[ 5] = t5;\n o[ 6] = t6;\n o[ 7] = t7;\n o[ 8] = t8;\n o[ 9] = t9;\n o[10] = t10;\n o[11] = t11;\n o[12] = t12;\n o[13] = t13;\n o[14] = t14;\n o[15] = t15;\n}\n\nfunction S(o, a) {\n M(o, a, a);\n}\n\nfunction inv25519(o, i) {\n var c = gf();\n var a;\n for (a = 0; a < 16; a++) c[a] = i[a];\n for (a = 253; a >= 0; a--) {\n S(c, c);\n if(a !== 2 && a !== 4) M(c, c, i);\n }\n for (a = 0; a < 16; a++) o[a] = c[a];\n}\n\nfunction pow2523(o, i) {\n var c = gf();\n var a;\n for (a = 0; a < 16; a++) c[a] = i[a];\n for (a = 250; a >= 0; a--) {\n S(c, c);\n if(a !== 1) M(c, c, i);\n }\n for (a = 0; a < 16; a++) o[a] = c[a];\n}\n\nfunction crypto_scalarmult(q, n, p) {\n var z = new Uint8Array(32);\n var x = new Float64Array(80), r, i;\n var a = gf(), b = gf(), c = gf(),\n d = gf(), e = gf(), f = gf();\n for (i = 0; i < 31; i++) z[i] = n[i];\n z[31]=(n[31]&127)|64;\n z[0]&=248;\n unpack25519(x,p);\n for (i = 0; i < 16; i++) {\n b[i]=x[i];\n d[i]=a[i]=c[i]=0;\n }\n a[0]=d[0]=1;\n for (i=254; i>=0; --i) {\n r=(z[i>>>3]>>>(i&7))&1;\n sel25519(a,b,r);\n sel25519(c,d,r);\n A(e,a,c);\n Z(a,a,c);\n A(c,b,d);\n Z(b,b,d);\n S(d,e);\n S(f,a);\n M(a,c,a);\n M(c,b,e);\n A(e,a,c);\n Z(a,a,c);\n S(b,a);\n Z(c,d,f);\n M(a,c,_121665);\n A(a,a,d);\n M(c,c,a);\n M(a,d,f);\n M(d,b,x);\n S(b,e);\n sel25519(a,b,r);\n sel25519(c,d,r);\n }\n for (i = 0; i < 16; i++) {\n x[i+16]=a[i];\n x[i+32]=c[i];\n x[i+48]=b[i];\n x[i+64]=d[i];\n }\n var x32 = x.subarray(32);\n var x16 = x.subarray(16);\n inv25519(x32,x32);\n M(x16,x16,x32);\n pack25519(q,x16);\n return 0;\n}\n\nfunction crypto_scalarmult_base(q, n) {\n return crypto_scalarmult(q, n, _9);\n}\n\nfunction crypto_box_keypair(y, x) {\n randombytes(x, 32);\n return crypto_scalarmult_base(y, x);\n}\n\nfunction crypto_box_beforenm(k, y, x) {\n var s = new Uint8Array(32);\n crypto_scalarmult(s, x, y);\n return crypto_core_hsalsa20(k, _0, s, sigma);\n}\n\nvar crypto_box_afternm = crypto_secretbox;\nvar crypto_box_open_afternm = crypto_secretbox_open;\n\nfunction crypto_box(c, m, d, n, y, x) {\n var k = new Uint8Array(32);\n crypto_box_beforenm(k, y, x);\n return crypto_box_afternm(c, m, d, n, k);\n}\n\nfunction crypto_box_open(m, c, d, n, y, x) {\n var k = new Uint8Array(32);\n crypto_box_beforenm(k, y, x);\n return crypto_box_open_afternm(m, c, d, n, k);\n}\n\nvar K = [\n 0x428a2f98, 0xd728ae22, 0x71374491, 0x23ef65cd,\n 0xb5c0fbcf, 0xec4d3b2f, 0xe9b5dba5, 0x8189dbbc,\n 0x3956c25b, 0xf348b538, 0x59f111f1, 0xb605d019,\n 0x923f82a4, 0xaf194f9b, 0xab1c5ed5, 0xda6d8118,\n 0xd807aa98, 0xa3030242, 0x12835b01, 0x45706fbe,\n 0x243185be, 0x4ee4b28c, 0x550c7dc3, 0xd5ffb4e2,\n 0x72be5d74, 0xf27b896f, 0x80deb1fe, 0x3b1696b1,\n 0x9bdc06a7, 0x25c71235, 0xc19bf174, 0xcf692694,\n 0xe49b69c1, 0x9ef14ad2, 0xefbe4786, 0x384f25e3,\n 0x0fc19dc6, 0x8b8cd5b5, 0x240ca1cc, 0x77ac9c65,\n 0x2de92c6f, 0x592b0275, 0x4a7484aa, 0x6ea6e483,\n 0x5cb0a9dc, 0xbd41fbd4, 0x76f988da, 0x831153b5,\n 0x983e5152, 0xee66dfab, 0xa831c66d, 0x2db43210,\n 0xb00327c8, 0x98fb213f, 0xbf597fc7, 0xbeef0ee4,\n 0xc6e00bf3, 0x3da88fc2, 0xd5a79147, 0x930aa725,\n 0x06ca6351, 0xe003826f, 0x14292967, 0x0a0e6e70,\n 0x27b70a85, 0x46d22ffc, 0x2e1b2138, 0x5c26c926,\n 0x4d2c6dfc, 0x5ac42aed, 0x53380d13, 0x9d95b3df,\n 0x650a7354, 0x8baf63de, 0x766a0abb, 0x3c77b2a8,\n 0x81c2c92e, 0x47edaee6, 0x92722c85, 0x1482353b,\n 0xa2bfe8a1, 0x4cf10364, 0xa81a664b, 0xbc423001,\n 0xc24b8b70, 0xd0f89791, 0xc76c51a3, 0x0654be30,\n 0xd192e819, 0xd6ef5218, 0xd6990624, 0x5565a910,\n 0xf40e3585, 0x5771202a, 0x106aa070, 0x32bbd1b8,\n 0x19a4c116, 0xb8d2d0c8, 0x1e376c08, 0x5141ab53,\n 0x2748774c, 0xdf8eeb99, 0x34b0bcb5, 0xe19b48a8,\n 0x391c0cb3, 0xc5c95a63, 0x4ed8aa4a, 0xe3418acb,\n 0x5b9cca4f, 0x7763e373, 0x682e6ff3, 0xd6b2b8a3,\n 0x748f82ee, 0x5defb2fc, 0x78a5636f, 0x43172f60,\n 0x84c87814, 0xa1f0ab72, 0x8cc70208, 0x1a6439ec,\n 0x90befffa, 0x23631e28, 0xa4506ceb, 0xde82bde9,\n 0xbef9a3f7, 0xb2c67915, 0xc67178f2, 0xe372532b,\n 0xca273ece, 0xea26619c, 0xd186b8c7, 0x21c0c207,\n 0xeada7dd6, 0xcde0eb1e, 0xf57d4f7f, 0xee6ed178,\n 0x06f067aa, 0x72176fba, 0x0a637dc5, 0xa2c898a6,\n 0x113f9804, 0xbef90dae, 0x1b710b35, 0x131c471b,\n 0x28db77f5, 0x23047d84, 0x32caab7b, 0x40c72493,\n 0x3c9ebe0a, 0x15c9bebc, 0x431d67c4, 0x9c100d4c,\n 0x4cc5d4be, 0xcb3e42b6, 0x597f299c, 0xfc657e2a,\n 0x5fcb6fab, 0x3ad6faec, 0x6c44198c, 0x4a475817\n];\n\nfunction crypto_hashblocks_hl(hh, hl, m, n) {\n var wh = new Int32Array(16), wl = new Int32Array(16),\n bh0, bh1, bh2, bh3, bh4, bh5, bh6, bh7,\n bl0, bl1, bl2, bl3, bl4, bl5, bl6, bl7,\n th, tl, i, j, h, l, a, b, c, d;\n\n var ah0 = hh[0],\n ah1 = hh[1],\n ah2 = hh[2],\n ah3 = hh[3],\n ah4 = hh[4],\n ah5 = hh[5],\n ah6 = hh[6],\n ah7 = hh[7],\n\n al0 = hl[0],\n al1 = hl[1],\n al2 = hl[2],\n al3 = hl[3],\n al4 = hl[4],\n al5 = hl[5],\n al6 = hl[6],\n al7 = hl[7];\n\n var pos = 0;\n while (n >= 128) {\n for (i = 0; i < 16; i++) {\n j = 8 * i + pos;\n wh[i] = (m[j+0] << 24) | (m[j+1] << 16) | (m[j+2] << 8) | m[j+3];\n wl[i] = (m[j+4] << 24) | (m[j+5] << 16) | (m[j+6] << 8) | m[j+7];\n }\n for (i = 0; i < 80; i++) {\n bh0 = ah0;\n bh1 = ah1;\n bh2 = ah2;\n bh3 = ah3;\n bh4 = ah4;\n bh5 = ah5;\n bh6 = ah6;\n bh7 = ah7;\n\n bl0 = al0;\n bl1 = al1;\n bl2 = al2;\n bl3 = al3;\n bl4 = al4;\n bl5 = al5;\n bl6 = al6;\n bl7 = al7;\n\n // add\n h = ah7;\n l = al7;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n // Sigma1\n h = ((ah4 >>> 14) | (al4 << (32-14))) ^ ((ah4 >>> 18) | (al4 << (32-18))) ^ ((al4 >>> (41-32)) | (ah4 << (32-(41-32))));\n l = ((al4 >>> 14) | (ah4 << (32-14))) ^ ((al4 >>> 18) | (ah4 << (32-18))) ^ ((ah4 >>> (41-32)) | (al4 << (32-(41-32))));\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // Ch\n h = (ah4 & ah5) ^ (~ah4 & ah6);\n l = (al4 & al5) ^ (~al4 & al6);\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // K\n h = K[i*2];\n l = K[i*2+1];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // w\n h = wh[i%16];\n l = wl[i%16];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n th = c & 0xffff | d << 16;\n tl = a & 0xffff | b << 16;\n\n // add\n h = th;\n l = tl;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n // Sigma0\n h = ((ah0 >>> 28) | (al0 << (32-28))) ^ ((al0 >>> (34-32)) | (ah0 << (32-(34-32)))) ^ ((al0 >>> (39-32)) | (ah0 << (32-(39-32))));\n l = ((al0 >>> 28) | (ah0 << (32-28))) ^ ((ah0 >>> (34-32)) | (al0 << (32-(34-32)))) ^ ((ah0 >>> (39-32)) | (al0 << (32-(39-32))));\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // Maj\n h = (ah0 & ah1) ^ (ah0 & ah2) ^ (ah1 & ah2);\n l = (al0 & al1) ^ (al0 & al2) ^ (al1 & al2);\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n bh7 = (c & 0xffff) | (d << 16);\n bl7 = (a & 0xffff) | (b << 16);\n\n // add\n h = bh3;\n l = bl3;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = th;\n l = tl;\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n bh3 = (c & 0xffff) | (d << 16);\n bl3 = (a & 0xffff) | (b << 16);\n\n ah1 = bh0;\n ah2 = bh1;\n ah3 = bh2;\n ah4 = bh3;\n ah5 = bh4;\n ah6 = bh5;\n ah7 = bh6;\n ah0 = bh7;\n\n al1 = bl0;\n al2 = bl1;\n al3 = bl2;\n al4 = bl3;\n al5 = bl4;\n al6 = bl5;\n al7 = bl6;\n al0 = bl7;\n\n if (i%16 === 15) {\n for (j = 0; j < 16; j++) {\n // add\n h = wh[j];\n l = wl[j];\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = wh[(j+9)%16];\n l = wl[(j+9)%16];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // sigma0\n th = wh[(j+1)%16];\n tl = wl[(j+1)%16];\n h = ((th >>> 1) | (tl << (32-1))) ^ ((th >>> 8) | (tl << (32-8))) ^ (th >>> 7);\n l = ((tl >>> 1) | (th << (32-1))) ^ ((tl >>> 8) | (th << (32-8))) ^ ((tl >>> 7) | (th << (32-7)));\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // sigma1\n th = wh[(j+14)%16];\n tl = wl[(j+14)%16];\n h = ((th >>> 19) | (tl << (32-19))) ^ ((tl >>> (61-32)) | (th << (32-(61-32)))) ^ (th >>> 6);\n l = ((tl >>> 19) | (th << (32-19))) ^ ((th >>> (61-32)) | (tl << (32-(61-32)))) ^ ((tl >>> 6) | (th << (32-6)));\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n wh[j] = (c & 0xffff) | (d << 16);\n wl[j] = (a & 0xffff) | (b << 16);\n }\n }\n }\n\n // add\n h = ah0;\n l = al0;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[0];\n l = hl[0];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[0] = ah0 = (c & 0xffff) | (d << 16);\n hl[0] = al0 = (a & 0xffff) | (b << 16);\n\n h = ah1;\n l = al1;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[1];\n l = hl[1];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[1] = ah1 = (c & 0xffff) | (d << 16);\n hl[1] = al1 = (a & 0xffff) | (b << 16);\n\n h = ah2;\n l = al2;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[2];\n l = hl[2];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[2] = ah2 = (c & 0xffff) | (d << 16);\n hl[2] = al2 = (a & 0xffff) | (b << 16);\n\n h = ah3;\n l = al3;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[3];\n l = hl[3];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[3] = ah3 = (c & 0xffff) | (d << 16);\n hl[3] = al3 = (a & 0xffff) | (b << 16);\n\n h = ah4;\n l = al4;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[4];\n l = hl[4];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[4] = ah4 = (c & 0xffff) | (d << 16);\n hl[4] = al4 = (a & 0xffff) | (b << 16);\n\n h = ah5;\n l = al5;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[5];\n l = hl[5];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[5] = ah5 = (c & 0xffff) | (d << 16);\n hl[5] = al5 = (a & 0xffff) | (b << 16);\n\n h = ah6;\n l = al6;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[6];\n l = hl[6];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[6] = ah6 = (c & 0xffff) | (d << 16);\n hl[6] = al6 = (a & 0xffff) | (b << 16);\n\n h = ah7;\n l = al7;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[7];\n l = hl[7];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[7] = ah7 = (c & 0xffff) | (d << 16);\n hl[7] = al7 = (a & 0xffff) | (b << 16);\n\n pos += 128;\n n -= 128;\n }\n\n return n;\n}\n\nfunction crypto_hash(out, m, n) {\n var hh = new Int32Array(8),\n hl = new Int32Array(8),\n x = new Uint8Array(256),\n i, b = n;\n\n hh[0] = 0x6a09e667;\n hh[1] = 0xbb67ae85;\n hh[2] = 0x3c6ef372;\n hh[3] = 0xa54ff53a;\n hh[4] = 0x510e527f;\n hh[5] = 0x9b05688c;\n hh[6] = 0x1f83d9ab;\n hh[7] = 0x5be0cd19;\n\n hl[0] = 0xf3bcc908;\n hl[1] = 0x84caa73b;\n hl[2] = 0xfe94f82b;\n hl[3] = 0x5f1d36f1;\n hl[4] = 0xade682d1;\n hl[5] = 0x2b3e6c1f;\n hl[6] = 0xfb41bd6b;\n hl[7] = 0x137e2179;\n\n crypto_hashblocks_hl(hh, hl, m, n);\n n %= 128;\n\n for (i = 0; i < n; i++) x[i] = m[b-n+i];\n x[n] = 128;\n\n n = 256-128*(n<112?1:0);\n x[n-9] = 0;\n ts64(x, n-8, (b / 0x20000000) | 0, b << 3);\n crypto_hashblocks_hl(hh, hl, x, n);\n\n for (i = 0; i < 8; i++) ts64(out, 8*i, hh[i], hl[i]);\n\n return 0;\n}\n\nfunction add(p, q) {\n var a = gf(), b = gf(), c = gf(),\n d = gf(), e = gf(), f = gf(),\n g = gf(), h = gf(), t = gf();\n\n Z(a, p[1], p[0]);\n Z(t, q[1], q[0]);\n M(a, a, t);\n A(b, p[0], p[1]);\n A(t, q[0], q[1]);\n M(b, b, t);\n M(c, p[3], q[3]);\n M(c, c, D2);\n M(d, p[2], q[2]);\n A(d, d, d);\n Z(e, b, a);\n Z(f, d, c);\n A(g, d, c);\n A(h, b, a);\n\n M(p[0], e, f);\n M(p[1], h, g);\n M(p[2], g, f);\n M(p[3], e, h);\n}\n\nfunction cswap(p, q, b) {\n var i;\n for (i = 0; i < 4; i++) {\n sel25519(p[i], q[i], b);\n }\n}\n\nfunction pack(r, p) {\n var tx = gf(), ty = gf(), zi = gf();\n inv25519(zi, p[2]);\n M(tx, p[0], zi);\n M(ty, p[1], zi);\n pack25519(r, ty);\n r[31] ^= par25519(tx) << 7;\n}\n\nfunction scalarmult(p, q, s) {\n var b, i;\n set25519(p[0], gf0);\n set25519(p[1], gf1);\n set25519(p[2], gf1);\n set25519(p[3], gf0);\n for (i = 255; i >= 0; --i) {\n b = (s[(i/8)|0] >> (i&7)) & 1;\n cswap(p, q, b);\n add(q, p);\n add(p, p);\n cswap(p, q, b);\n }\n}\n\nfunction scalarbase(p, s) {\n var q = [gf(), gf(), gf(), gf()];\n set25519(q[0], X);\n set25519(q[1], Y);\n set25519(q[2], gf1);\n M(q[3], X, Y);\n scalarmult(p, q, s);\n}\n\nfunction crypto_sign_keypair(pk, sk, seeded) {\n var d = new Uint8Array(64);\n var p = [gf(), gf(), gf(), gf()];\n var i;\n\n if (!seeded) randombytes(sk, 32);\n crypto_hash(d, sk, 32);\n d[0] &= 248;\n d[31] &= 127;\n d[31] |= 64;\n\n scalarbase(p, d);\n pack(pk, p);\n\n for (i = 0; i < 32; i++) sk[i+32] = pk[i];\n return 0;\n}\n\nvar L = new Float64Array([0xed, 0xd3, 0xf5, 0x5c, 0x1a, 0x63, 0x12, 0x58, 0xd6, 0x9c, 0xf7, 0xa2, 0xde, 0xf9, 0xde, 0x14, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x10]);\n\nfunction modL(r, x) {\n var carry, i, j, k;\n for (i = 63; i >= 32; --i) {\n carry = 0;\n for (j = i - 32, k = i - 12; j < k; ++j) {\n x[j] += carry - 16 * x[i] * L[j - (i - 32)];\n carry = Math.floor((x[j] + 128) / 256);\n x[j] -= carry * 256;\n }\n x[j] += carry;\n x[i] = 0;\n }\n carry = 0;\n for (j = 0; j < 32; j++) {\n x[j] += carry - (x[31] >> 4) * L[j];\n carry = x[j] >> 8;\n x[j] &= 255;\n }\n for (j = 0; j < 32; j++) x[j] -= carry * L[j];\n for (i = 0; i < 32; i++) {\n x[i+1] += x[i] >> 8;\n r[i] = x[i] & 255;\n }\n}\n\nfunction reduce(r) {\n var x = new Float64Array(64), i;\n for (i = 0; i < 64; i++) x[i] = r[i];\n for (i = 0; i < 64; i++) r[i] = 0;\n modL(r, x);\n}\n\n// Note: difference from C - smlen returned, not passed as argument.\nfunction crypto_sign(sm, m, n, sk) {\n var d = new Uint8Array(64), h = new Uint8Array(64), r = new Uint8Array(64);\n var i, j, x = new Float64Array(64);\n var p = [gf(), gf(), gf(), gf()];\n\n crypto_hash(d, sk, 32);\n d[0] &= 248;\n d[31] &= 127;\n d[31] |= 64;\n\n var smlen = n + 64;\n for (i = 0; i < n; i++) sm[64 + i] = m[i];\n for (i = 0; i < 32; i++) sm[32 + i] = d[32 + i];\n\n crypto_hash(r, sm.subarray(32), n+32);\n reduce(r);\n scalarbase(p, r);\n pack(sm, p);\n\n for (i = 32; i < 64; i++) sm[i] = sk[i];\n crypto_hash(h, sm, n + 64);\n reduce(h);\n\n for (i = 0; i < 64; i++) x[i] = 0;\n for (i = 0; i < 32; i++) x[i] = r[i];\n for (i = 0; i < 32; i++) {\n for (j = 0; j < 32; j++) {\n x[i+j] += h[i] * d[j];\n }\n }\n\n modL(sm.subarray(32), x);\n return smlen;\n}\n\nfunction unpackneg(r, p) {\n var t = gf(), chk = gf(), num = gf(),\n den = gf(), den2 = gf(), den4 = gf(),\n den6 = gf();\n\n set25519(r[2], gf1);\n unpack25519(r[1], p);\n S(num, r[1]);\n M(den, num, D);\n Z(num, num, r[2]);\n A(den, r[2], den);\n\n S(den2, den);\n S(den4, den2);\n M(den6, den4, den2);\n M(t, den6, num);\n M(t, t, den);\n\n pow2523(t, t);\n M(t, t, num);\n M(t, t, den);\n M(t, t, den);\n M(r[0], t, den);\n\n S(chk, r[0]);\n M(chk, chk, den);\n if (neq25519(chk, num)) M(r[0], r[0], I);\n\n S(chk, r[0]);\n M(chk, chk, den);\n if (neq25519(chk, num)) return -1;\n\n if (par25519(r[0]) === (p[31]>>7)) Z(r[0], gf0, r[0]);\n\n M(r[3], r[0], r[1]);\n return 0;\n}\n\nfunction crypto_sign_open(m, sm, n, pk) {\n var i;\n var t = new Uint8Array(32), h = new Uint8Array(64);\n var p = [gf(), gf(), gf(), gf()],\n q = [gf(), gf(), gf(), gf()];\n\n if (n < 64) return -1;\n\n if (unpackneg(q, pk)) return -1;\n\n for (i = 0; i < n; i++) m[i] = sm[i];\n for (i = 0; i < 32; i++) m[i+32] = pk[i];\n crypto_hash(h, m, n);\n reduce(h);\n scalarmult(p, q, h);\n\n scalarbase(q, sm.subarray(32));\n add(p, q);\n pack(t, p);\n\n n -= 64;\n if (crypto_verify_32(sm, 0, t, 0)) {\n for (i = 0; i < n; i++) m[i] = 0;\n return -1;\n }\n\n for (i = 0; i < n; i++) m[i] = sm[i + 64];\n return n;\n}\n\nvar crypto_secretbox_KEYBYTES = 32,\n crypto_secretbox_NONCEBYTES = 24,\n crypto_secretbox_ZEROBYTES = 32,\n crypto_secretbox_BOXZEROBYTES = 16,\n crypto_scalarmult_BYTES = 32,\n crypto_scalarmult_SCALARBYTES = 32,\n crypto_box_PUBLICKEYBYTES = 32,\n crypto_box_SECRETKEYBYTES = 32,\n crypto_box_BEFORENMBYTES = 32,\n crypto_box_NONCEBYTES = crypto_secretbox_NONCEBYTES,\n crypto_box_ZEROBYTES = crypto_secretbox_ZEROBYTES,\n crypto_box_BOXZEROBYTES = crypto_secretbox_BOXZEROBYTES,\n crypto_sign_BYTES = 64,\n crypto_sign_PUBLICKEYBYTES = 32,\n crypto_sign_SECRETKEYBYTES = 64,\n crypto_sign_SEEDBYTES = 32,\n crypto_hash_BYTES = 64;\n\nnacl.lowlevel = {\n crypto_core_hsalsa20: crypto_core_hsalsa20,\n crypto_stream_xor: crypto_stream_xor,\n crypto_stream: crypto_stream,\n crypto_stream_salsa20_xor: crypto_stream_salsa20_xor,\n crypto_stream_salsa20: crypto_stream_salsa20,\n crypto_onetimeauth: crypto_onetimeauth,\n crypto_onetimeauth_verify: crypto_onetimeauth_verify,\n crypto_verify_16: crypto_verify_16,\n crypto_verify_32: crypto_verify_32,\n crypto_secretbox: crypto_secretbox,\n crypto_secretbox_open: crypto_secretbox_open,\n crypto_scalarmult: crypto_scalarmult,\n crypto_scalarmult_base: crypto_scalarmult_base,\n crypto_box_beforenm: crypto_box_beforenm,\n crypto_box_afternm: crypto_box_afternm,\n crypto_box: crypto_box,\n crypto_box_open: crypto_box_open,\n crypto_box_keypair: crypto_box_keypair,\n crypto_hash: crypto_hash,\n crypto_sign: crypto_sign,\n crypto_sign_keypair: crypto_sign_keypair,\n crypto_sign_open: crypto_sign_open,\n\n crypto_secretbox_KEYBYTES: crypto_secretbox_KEYBYTES,\n crypto_secretbox_NONCEBYTES: crypto_secretbox_NONCEBYTES,\n crypto_secretbox_ZEROBYTES: crypto_secretbox_ZEROBYTES,\n crypto_secretbox_BOXZEROBYTES: crypto_secretbox_BOXZEROBYTES,\n crypto_scalarmult_BYTES: crypto_scalarmult_BYTES,\n crypto_scalarmult_SCALARBYTES: crypto_scalarmult_SCALARBYTES,\n crypto_box_PUBLICKEYBYTES: crypto_box_PUBLICKEYBYTES,\n crypto_box_SECRETKEYBYTES: crypto_box_SECRETKEYBYTES,\n crypto_box_BEFORENMBYTES: crypto_box_BEFORENMBYTES,\n crypto_box_NONCEBYTES: crypto_box_NONCEBYTES,\n crypto_box_ZEROBYTES: crypto_box_ZEROBYTES,\n crypto_box_BOXZEROBYTES: crypto_box_BOXZEROBYTES,\n crypto_sign_BYTES: crypto_sign_BYTES,\n crypto_sign_PUBLICKEYBYTES: crypto_sign_PUBLICKEYBYTES,\n crypto_sign_SECRETKEYBYTES: crypto_sign_SECRETKEYBYTES,\n crypto_sign_SEEDBYTES: crypto_sign_SEEDBYTES,\n crypto_hash_BYTES: crypto_hash_BYTES,\n\n gf: gf,\n D: D,\n L: L,\n pack25519: pack25519,\n unpack25519: unpack25519,\n M: M,\n A: A,\n S: S,\n Z: Z,\n pow2523: pow2523,\n add: add,\n set25519: set25519,\n modL: modL,\n scalarmult: scalarmult,\n scalarbase: scalarbase,\n};\n\n/* High-level API */\n\nfunction checkLengths(k, n) {\n if (k.length !== crypto_secretbox_KEYBYTES) throw new Error('bad key size');\n if (n.length !== crypto_secretbox_NONCEBYTES) throw new Error('bad nonce size');\n}\n\nfunction checkBoxLengths(pk, sk) {\n if (pk.length !== crypto_box_PUBLICKEYBYTES) throw new Error('bad public key size');\n if (sk.length !== crypto_box_SECRETKEYBYTES) throw new Error('bad secret key size');\n}\n\nfunction checkArrayTypes() {\n for (var i = 0; i < arguments.length; i++) {\n if (!(arguments[i] instanceof Uint8Array))\n throw new TypeError('unexpected type, use Uint8Array');\n }\n}\n\nfunction cleanup(arr) {\n for (var i = 0; i < arr.length; i++) arr[i] = 0;\n}\n\nnacl.randomBytes = function(n) {\n var b = new Uint8Array(n);\n randombytes(b, n);\n return b;\n};\n\nnacl.secretbox = function(msg, nonce, key) {\n checkArrayTypes(msg, nonce, key);\n checkLengths(key, nonce);\n var m = new Uint8Array(crypto_secretbox_ZEROBYTES + msg.length);\n var c = new Uint8Array(m.length);\n for (var i = 0; i < msg.length; i++) m[i+crypto_secretbox_ZEROBYTES] = msg[i];\n crypto_secretbox(c, m, m.length, nonce, key);\n return c.subarray(crypto_secretbox_BOXZEROBYTES);\n};\n\nnacl.secretbox.open = function(box, nonce, key) {\n checkArrayTypes(box, nonce, key);\n checkLengths(key, nonce);\n var c = new Uint8Array(crypto_secretbox_BOXZEROBYTES + box.length);\n var m = new Uint8Array(c.length);\n for (var i = 0; i < box.length; i++) c[i+crypto_secretbox_BOXZEROBYTES] = box[i];\n if (c.length < 32) return null;\n if (crypto_secretbox_open(m, c, c.length, nonce, key) !== 0) return null;\n return m.subarray(crypto_secretbox_ZEROBYTES);\n};\n\nnacl.secretbox.keyLength = crypto_secretbox_KEYBYTES;\nnacl.secretbox.nonceLength = crypto_secretbox_NONCEBYTES;\nnacl.secretbox.overheadLength = crypto_secretbox_BOXZEROBYTES;\n\nnacl.scalarMult = function(n, p) {\n checkArrayTypes(n, p);\n if (n.length !== crypto_scalarmult_SCALARBYTES) throw new Error('bad n size');\n if (p.length !== crypto_scalarmult_BYTES) throw new Error('bad p size');\n var q = new Uint8Array(crypto_scalarmult_BYTES);\n crypto_scalarmult(q, n, p);\n return q;\n};\n\nnacl.scalarMult.base = function(n) {\n checkArrayTypes(n);\n if (n.length !== crypto_scalarmult_SCALARBYTES) throw new Error('bad n size');\n var q = new Uint8Array(crypto_scalarmult_BYTES);\n crypto_scalarmult_base(q, n);\n return q;\n};\n\nnacl.scalarMult.scalarLength = crypto_scalarmult_SCALARBYTES;\nnacl.scalarMult.groupElementLength = crypto_scalarmult_BYTES;\n\nnacl.box = function(msg, nonce, publicKey, secretKey) {\n var k = nacl.box.before(publicKey, secretKey);\n return nacl.secretbox(msg, nonce, k);\n};\n\nnacl.box.before = function(publicKey, secretKey) {\n checkArrayTypes(publicKey, secretKey);\n checkBoxLengths(publicKey, secretKey);\n var k = new Uint8Array(crypto_box_BEFORENMBYTES);\n crypto_box_beforenm(k, publicKey, secretKey);\n return k;\n};\n\nnacl.box.after = nacl.secretbox;\n\nnacl.box.open = function(msg, nonce, publicKey, secretKey) {\n var k = nacl.box.before(publicKey, secretKey);\n return nacl.secretbox.open(msg, nonce, k);\n};\n\nnacl.box.open.after = nacl.secretbox.open;\n\nnacl.box.keyPair = function() {\n var pk = new Uint8Array(crypto_box_PUBLICKEYBYTES);\n var sk = new Uint8Array(crypto_box_SECRETKEYBYTES);\n crypto_box_keypair(pk, sk);\n return {publicKey: pk, secretKey: sk};\n};\n\nnacl.box.keyPair.fromSecretKey = function(secretKey) {\n checkArrayTypes(secretKey);\n if (secretKey.length !== crypto_box_SECRETKEYBYTES)\n throw new Error('bad secret key size');\n var pk = new Uint8Array(crypto_box_PUBLICKEYBYTES);\n crypto_scalarmult_base(pk, secretKey);\n return {publicKey: pk, secretKey: new Uint8Array(secretKey)};\n};\n\nnacl.box.publicKeyLength = crypto_box_PUBLICKEYBYTES;\nnacl.box.secretKeyLength = crypto_box_SECRETKEYBYTES;\nnacl.box.sharedKeyLength = crypto_box_BEFORENMBYTES;\nnacl.box.nonceLength = crypto_box_NONCEBYTES;\nnacl.box.overheadLength = nacl.secretbox.overheadLength;\n\nnacl.sign = function(msg, secretKey) {\n checkArrayTypes(msg, secretKey);\n if (secretKey.length !== crypto_sign_SECRETKEYBYTES)\n throw new Error('bad secret key size');\n var signedMsg = new Uint8Array(crypto_sign_BYTES+msg.length);\n crypto_sign(signedMsg, msg, msg.length, secretKey);\n return signedMsg;\n};\n\nnacl.sign.open = function(signedMsg, publicKey) {\n checkArrayTypes(signedMsg, publicKey);\n if (publicKey.length !== crypto_sign_PUBLICKEYBYTES)\n throw new Error('bad public key size');\n var tmp = new Uint8Array(signedMsg.length);\n var mlen = crypto_sign_open(tmp, signedMsg, signedMsg.length, publicKey);\n if (mlen < 0) return null;\n var m = new Uint8Array(mlen);\n for (var i = 0; i < m.length; i++) m[i] = tmp[i];\n return m;\n};\n\nnacl.sign.detached = function(msg, secretKey) {\n var signedMsg = nacl.sign(msg, secretKey);\n var sig = new Uint8Array(crypto_sign_BYTES);\n for (var i = 0; i < sig.length; i++) sig[i] = signedMsg[i];\n return sig;\n};\n\nnacl.sign.detached.verify = function(msg, sig, publicKey) {\n checkArrayTypes(msg, sig, publicKey);\n if (sig.length !== crypto_sign_BYTES)\n throw new Error('bad signature size');\n if (publicKey.length !== crypto_sign_PUBLICKEYBYTES)\n throw new Error('bad public key size');\n var sm = new Uint8Array(crypto_sign_BYTES + msg.length);\n var m = new Uint8Array(crypto_sign_BYTES + msg.length);\n var i;\n for (i = 0; i < crypto_sign_BYTES; i++) sm[i] = sig[i];\n for (i = 0; i < msg.length; i++) sm[i+crypto_sign_BYTES] = msg[i];\n return (crypto_sign_open(m, sm, sm.length, publicKey) >= 0);\n};\n\nnacl.sign.keyPair = function() {\n var pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);\n var sk = new Uint8Array(crypto_sign_SECRETKEYBYTES);\n crypto_sign_keypair(pk, sk);\n return {publicKey: pk, secretKey: sk};\n};\n\nnacl.sign.keyPair.fromSecretKey = function(secretKey) {\n checkArrayTypes(secretKey);\n if (secretKey.length !== crypto_sign_SECRETKEYBYTES)\n throw new Error('bad secret key size');\n var pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);\n for (var i = 0; i < pk.length; i++) pk[i] = secretKey[32+i];\n return {publicKey: pk, secretKey: new Uint8Array(secretKey)};\n};\n\nnacl.sign.keyPair.fromSeed = function(seed) {\n checkArrayTypes(seed);\n if (seed.length !== crypto_sign_SEEDBYTES)\n throw new Error('bad seed size');\n var pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);\n var sk = new Uint8Array(crypto_sign_SECRETKEYBYTES);\n for (var i = 0; i < 32; i++) sk[i] = seed[i];\n crypto_sign_keypair(pk, sk, true);\n return {publicKey: pk, secretKey: sk};\n};\n\nnacl.sign.publicKeyLength = crypto_sign_PUBLICKEYBYTES;\nnacl.sign.secretKeyLength = crypto_sign_SECRETKEYBYTES;\nnacl.sign.seedLength = crypto_sign_SEEDBYTES;\nnacl.sign.signatureLength = crypto_sign_BYTES;\n\nnacl.hash = function(msg) {\n checkArrayTypes(msg);\n var h = new Uint8Array(crypto_hash_BYTES);\n crypto_hash(h, msg, msg.length);\n return h;\n};\n\nnacl.hash.hashLength = crypto_hash_BYTES;\n\nnacl.verify = function(x, y) {\n checkArrayTypes(x, y);\n // Zero length arguments are considered not equal.\n if (x.length === 0 || y.length === 0) return false;\n if (x.length !== y.length) return false;\n return (vn(x, 0, y, 0, x.length) === 0) ? true : false;\n};\n\nnacl.setPRNG = function(fn) {\n randombytes = fn;\n};\n\n(function() {\n // Initialize PRNG if environment provides CSPRNG.\n // If not, methods calling randombytes will throw.\n var crypto = typeof self !== 'undefined' ? (self.crypto || self.msCrypto) : null;\n if (crypto && crypto.getRandomValues) {\n // Browsers.\n var QUOTA = 65536;\n nacl.setPRNG(function(x, n) {\n var i, v = new Uint8Array(n);\n for (i = 0; i < n; i += QUOTA) {\n crypto.getRandomValues(v.subarray(i, i + Math.min(n - i, QUOTA)));\n }\n for (i = 0; i < n; i++) x[i] = v[i];\n cleanup(v);\n });\n } else if (typeof require !== 'undefined') {\n // Node.js.\n crypto = require('crypto');\n if (crypto && crypto.randomBytes) {\n nacl.setPRNG(function(x, n) {\n var i, v = crypto.randomBytes(n);\n for (i = 0; i < n; i++) x[i] = v[i];\n cleanup(v);\n });\n }\n }\n})();\n\n})(typeof module !== 'undefined' && module.exports ? module.exports : (self.nacl = self.nacl || {}));\n","module.exports = require('./pusher-with-encryption').default;\n","/* (ignored) */","import ScriptReceiver from './script_receiver';\n\n/** Builds receivers for JSONP and Script requests.\n *\n * Each receiver is an object with following fields:\n * - number - unique (for the factory instance), numerical id of the receiver\n * - id - a string ID that can be used in DOM attributes\n * - name - name of the function triggering the receiver\n * - callback - callback function\n *\n * Receivers are triggered only once, on the first callback call.\n *\n * Receivers can be called by their name or by accessing factory object\n * by the number key.\n *\n * @param {String} prefix the prefix used in ids\n * @param {String} name the name of the object\n */\nexport class ScriptReceiverFactory {\n lastId: number;\n prefix: string;\n name: string;\n\n constructor(prefix: string, name: string) {\n this.lastId = 0;\n this.prefix = prefix;\n this.name = name;\n }\n\n create(callback: Function): ScriptReceiver {\n this.lastId++;\n\n var number = this.lastId;\n var id = this.prefix + number;\n var name = this.name + '[' + number + ']';\n\n var called = false;\n var callbackWrapper = function() {\n if (!called) {\n callback.apply(null, arguments);\n called = true;\n }\n };\n\n this[number] = callbackWrapper;\n return { number: number, id: id, name: name, callback: callbackWrapper };\n }\n\n remove(receiver: ScriptReceiver) {\n delete this[receiver.number];\n }\n}\n\nexport var ScriptReceivers = new ScriptReceiverFactory(\n '_pusher_script_',\n 'Pusher.ScriptReceivers'\n);\n","import {\n ChannelAuthorizationOptions,\n UserAuthenticationOptions\n} from './auth/options';\nimport { AuthTransport } from './config';\n\nexport interface DefaultConfig {\n VERSION: string;\n PROTOCOL: number;\n wsPort: number;\n wssPort: number;\n wsPath: string;\n httpHost: string;\n httpPort: number;\n httpsPort: number;\n httpPath: string;\n stats_host: string;\n authEndpoint: string;\n authTransport: AuthTransport;\n activityTimeout: number;\n pongTimeout: number;\n unavailableTimeout: number;\n userAuthentication: UserAuthenticationOptions;\n channelAuthorization: ChannelAuthorizationOptions;\n\n cdn_http?: string;\n cdn_https?: string;\n dependency_suffix?: string;\n}\n\nvar Defaults: DefaultConfig = {\n VERSION: VERSION,\n PROTOCOL: 7,\n\n wsPort: 80,\n wssPort: 443,\n wsPath: '',\n // DEPRECATED: SockJS fallback parameters\n httpHost: 'sockjs.pusher.com',\n httpPort: 80,\n httpsPort: 443,\n httpPath: '/pusher',\n // DEPRECATED: Stats\n stats_host: 'stats.pusher.com',\n // DEPRECATED: Other settings\n authEndpoint: '/pusher/auth',\n authTransport: 'ajax',\n activityTimeout: 120000,\n pongTimeout: 30000,\n unavailableTimeout: 10000,\n userAuthentication: {\n endpoint: '/pusher/user-auth',\n transport: 'ajax'\n },\n channelAuthorization: {\n endpoint: '/pusher/auth',\n transport: 'ajax'\n },\n\n // CDN configuration\n cdn_http: CDN_HTTP,\n cdn_https: CDN_HTTPS,\n dependency_suffix: DEPENDENCY_SUFFIX\n};\n\nexport default Defaults;\n","import {\n ScriptReceivers,\n ScriptReceiverFactory\n} from './script_receiver_factory';\nimport Runtime from 'runtime';\nimport ScriptRequest from './script_request';\n\n/** Handles loading dependency files.\n *\n * Dependency loaders don't remember whether a resource has been loaded or\n * not. It is caller's responsibility to make sure the resource is not loaded\n * twice. This is because it's impossible to detect resource loading status\n * without knowing its content.\n *\n * Options:\n * - cdn_http - url to HTTP CND\n * - cdn_https - url to HTTPS CDN\n * - version - version of pusher-js\n * - suffix - suffix appended to all names of dependency files\n *\n * @param {Object} options\n */\nexport default class DependencyLoader {\n options: any;\n receivers: ScriptReceiverFactory;\n loading: any;\n\n constructor(options: any) {\n this.options = options;\n this.receivers = options.receivers || ScriptReceivers;\n this.loading = {};\n }\n\n /** Loads the dependency from CDN.\n *\n * @param {String} name\n * @param {Function} callback\n */\n load(name: string, options: any, callback: Function) {\n var self = this;\n\n if (self.loading[name] && self.loading[name].length > 0) {\n self.loading[name].push(callback);\n } else {\n self.loading[name] = [callback];\n\n var request = Runtime.createScriptRequest(self.getPath(name, options));\n var receiver = self.receivers.create(function(error) {\n self.receivers.remove(receiver);\n\n if (self.loading[name]) {\n var callbacks = self.loading[name];\n delete self.loading[name];\n\n var successCallback = function(wasSuccessful) {\n if (!wasSuccessful) {\n request.cleanup();\n }\n };\n for (var i = 0; i < callbacks.length; i++) {\n callbacks[i](error, successCallback);\n }\n }\n });\n request.send(receiver);\n }\n }\n\n /** Returns a root URL for pusher-js CDN.\n *\n * @returns {String}\n */\n getRoot(options: any): string {\n var cdn;\n var protocol = Runtime.getDocument().location.protocol;\n if ((options && options.useTLS) || protocol === 'https:') {\n cdn = this.options.cdn_https;\n } else {\n cdn = this.options.cdn_http;\n }\n // make sure there are no double slashes\n return cdn.replace(/\\/*$/, '') + '/' + this.options.version;\n }\n\n /** Returns a full path to a dependency file.\n *\n * @param {String} name\n * @returns {String}\n */\n getPath(name: string, options: any): string {\n return this.getRoot(options) + '/' + name + this.options.suffix + '.js';\n }\n}\n","import { ScriptReceiverFactory } from './script_receiver_factory';\nimport Defaults from 'core/defaults';\nimport DependencyLoader from './dependency_loader';\n\nexport var DependenciesReceivers = new ScriptReceiverFactory(\n '_pusher_dependencies',\n 'Pusher.DependenciesReceivers'\n);\n\nexport var Dependencies = new DependencyLoader({\n cdn_http: Defaults.cdn_http,\n cdn_https: Defaults.cdn_https,\n version: Defaults.VERSION,\n suffix: Defaults.dependency_suffix,\n receivers: DependenciesReceivers\n});\n","/**\n * A place to store help URLs for error messages etc\n */\n\nconst urlStore = {\n baseUrl: 'https://pusher.com',\n urls: {\n authenticationEndpoint: {\n path: '/docs/channels/server_api/authenticating_users'\n },\n authorizationEndpoint: {\n path: '/docs/channels/server_api/authorizing-users/'\n },\n javascriptQuickStart: {\n path: '/docs/javascript_quick_start'\n },\n triggeringClientEvents: {\n path: '/docs/client_api_guide/client_events#trigger-events'\n },\n encryptedChannelSupport: {\n fullUrl:\n 'https://github.com/pusher/pusher-js/tree/cc491015371a4bde5743d1c87a0fbac0feb53195#encrypted-channel-support'\n }\n }\n};\n\n/** Builds a consistent string with links to pusher documentation\n *\n * @param {string} key - relevant key in the url_store.urls object\n * @return {string} suffix string to append to log message\n */\nconst buildLogSuffix = function(key: string): string {\n const urlPrefix = 'See:';\n const urlObj = urlStore.urls[key];\n if (!urlObj) return '';\n\n let url;\n if (urlObj.fullUrl) {\n url = urlObj.fullUrl;\n } else if (urlObj.path) {\n url = urlStore.baseUrl + urlObj.path;\n }\n\n if (!url) return '';\n return `${urlPrefix} ${url}`;\n};\n\nexport default { buildLogSuffix };\n","export enum AuthRequestType {\n UserAuthentication = 'user-authentication',\n ChannelAuthorization = 'channel-authorization'\n}\n\nexport interface ChannelAuthorizationData {\n auth: string;\n channel_data?: string;\n shared_secret?: string;\n}\n\nexport type ChannelAuthorizationCallback = (\n error: Error | null,\n authData: ChannelAuthorizationData | null\n) => void;\n\nexport interface ChannelAuthorizationRequestParams {\n socketId: string;\n channelName: string;\n}\n\nexport interface ChannelAuthorizationHandler {\n (\n params: ChannelAuthorizationRequestParams,\n callback: ChannelAuthorizationCallback\n ): void;\n}\n\nexport interface UserAuthenticationData {\n auth: string;\n user_data: string;\n}\n\nexport type UserAuthenticationCallback = (\n error: Error | null,\n authData: UserAuthenticationData | null\n) => void;\n\nexport interface UserAuthenticationRequestParams {\n socketId: string;\n}\n\nexport interface UserAuthenticationHandler {\n (\n params: UserAuthenticationRequestParams,\n callback: UserAuthenticationCallback\n ): void;\n}\n\nexport type AuthTransportCallback =\n | ChannelAuthorizationCallback\n | UserAuthenticationCallback;\n\nexport interface AuthOptionsT {\n transport: 'ajax' | 'jsonp';\n endpoint: string;\n params?: any;\n headers?: any;\n paramsProvider?: () => any;\n headersProvider?: () => any;\n customHandler?: AuthHandler;\n}\n\nexport declare type UserAuthenticationOptions = AuthOptionsT<\n UserAuthenticationHandler\n>;\nexport declare type ChannelAuthorizationOptions = AuthOptionsT<\n ChannelAuthorizationHandler\n>;\n\nexport interface InternalAuthOptions {\n transport: 'ajax' | 'jsonp';\n endpoint: string;\n params?: any;\n headers?: any;\n paramsProvider?: () => any;\n headersProvider?: () => any;\n}\n","/** Error classes used throughout the library. */\n// https://github.com/Microsoft/TypeScript-wiki/blob/master/Breaking-Changes.md#extending-built-ins-like-error-array-and-map-may-no-longer-work\nexport class BadEventName extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\nexport class BadChannelName extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\nexport class RequestTimedOut extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class TransportPriorityTooLow extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class TransportClosed extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class UnsupportedFeature extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class UnsupportedTransport extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class UnsupportedStrategy extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class HTTPAuthError extends Error {\n status: number;\n constructor(status: number, msg?: string) {\n super(msg);\n this.status = status;\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n","import TimelineSender from 'core/timeline/timeline_sender';\nimport * as Collections from 'core/utils/collections';\nimport Util from 'core/util';\nimport Runtime from 'runtime';\nimport { AuthTransport } from 'core/auth/auth_transports';\nimport AbstractRuntime from 'runtimes/interface';\nimport UrlStore from 'core/utils/url_store';\nimport {\n AuthRequestType,\n AuthTransportCallback,\n InternalAuthOptions\n} from 'core/auth/options';\nimport { HTTPAuthError } from 'core/errors';\n\nconst ajax: AuthTransport = function(\n context: AbstractRuntime,\n query: string,\n authOptions: InternalAuthOptions,\n authRequestType: AuthRequestType,\n callback: AuthTransportCallback\n) {\n const xhr = Runtime.createXHR();\n xhr.open('POST', authOptions.endpoint, true);\n\n // add request headers\n xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');\n for (var headerName in authOptions.headers) {\n xhr.setRequestHeader(headerName, authOptions.headers[headerName]);\n }\n if (authOptions.headersProvider != null) {\n let dynamicHeaders = authOptions.headersProvider();\n for (var headerName in dynamicHeaders) {\n xhr.setRequestHeader(headerName, dynamicHeaders[headerName]);\n }\n }\n\n xhr.onreadystatechange = function() {\n if (xhr.readyState === 4) {\n if (xhr.status === 200) {\n let data;\n let parsed = false;\n\n try {\n data = JSON.parse(xhr.responseText);\n parsed = true;\n } catch (e) {\n callback(\n new HTTPAuthError(\n 200,\n `JSON returned from ${authRequestType.toString()} endpoint was invalid, yet status code was 200. Data was: ${\n xhr.responseText\n }`\n ),\n null\n );\n }\n\n if (parsed) {\n // prevents double execution.\n callback(null, data);\n }\n } else {\n let suffix = '';\n switch (authRequestType) {\n case AuthRequestType.UserAuthentication:\n suffix = UrlStore.buildLogSuffix('authenticationEndpoint');\n break;\n case AuthRequestType.ChannelAuthorization:\n suffix = `Clients must be authorized to join private or presence channels. ${UrlStore.buildLogSuffix(\n 'authorizationEndpoint'\n )}`;\n break;\n }\n callback(\n new HTTPAuthError(\n xhr.status,\n `Unable to retrieve auth string from ${authRequestType.toString()} endpoint - ` +\n `received status: ${xhr.status} from ${authOptions.endpoint}. ${suffix}`\n ),\n null\n );\n }\n }\n };\n\n xhr.send(query);\n return xhr;\n};\n\nexport default ajax;\n","export default function encode(s: any): string {\n return btoa(utob(s));\n}\n\nvar fromCharCode = String.fromCharCode;\n\nvar b64chars =\n 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';\nvar b64tab = {};\n\nfor (var i = 0, l = b64chars.length; i < l; i++) {\n b64tab[b64chars.charAt(i)] = i;\n}\n\nvar cb_utob = function(c) {\n var cc = c.charCodeAt(0);\n return cc < 0x80\n ? c\n : cc < 0x800\n ? fromCharCode(0xc0 | (cc >>> 6)) + fromCharCode(0x80 | (cc & 0x3f))\n : fromCharCode(0xe0 | ((cc >>> 12) & 0x0f)) +\n fromCharCode(0x80 | ((cc >>> 6) & 0x3f)) +\n fromCharCode(0x80 | (cc & 0x3f));\n};\n\nvar utob = function(u) {\n return u.replace(/[^\\x00-\\x7F]/g, cb_utob);\n};\n\nvar cb_encode = function(ccc) {\n var padlen = [0, 2, 1][ccc.length % 3];\n var ord =\n (ccc.charCodeAt(0) << 16) |\n ((ccc.length > 1 ? ccc.charCodeAt(1) : 0) << 8) |\n (ccc.length > 2 ? ccc.charCodeAt(2) : 0);\n var chars = [\n b64chars.charAt(ord >>> 18),\n b64chars.charAt((ord >>> 12) & 63),\n padlen >= 2 ? '=' : b64chars.charAt((ord >>> 6) & 63),\n padlen >= 1 ? '=' : b64chars.charAt(ord & 63)\n ];\n return chars.join('');\n};\n\nvar btoa =\n global.btoa ||\n function(b) {\n return b.replace(/[\\s\\S]{1,3}/g, cb_encode);\n };\n","import TimedCallback from './timed_callback';\nimport { Delay, Scheduler, Canceller } from './scheduling';\n\nabstract class Timer {\n protected clear: Canceller;\n protected timer: number | void;\n\n constructor(\n set: Scheduler,\n clear: Canceller,\n delay: Delay,\n callback: TimedCallback\n ) {\n this.clear = clear;\n this.timer = set(() => {\n if (this.timer) {\n this.timer = callback(this.timer);\n }\n }, delay);\n }\n\n /** Returns whether the timer is still running.\n *\n * @return {Boolean}\n */\n isRunning(): boolean {\n return this.timer !== null;\n }\n\n /** Aborts a timer when it's running. */\n ensureAborted() {\n if (this.timer) {\n this.clear(this.timer);\n this.timer = null;\n }\n }\n}\n\nexport default Timer;\n","import Timer from './abstract_timer';\nimport TimedCallback from './timed_callback';\nimport { Delay } from './scheduling';\n\n// We need to bind clear functions this way to avoid exceptions on IE8\nfunction clearTimeout(timer) {\n global.clearTimeout(timer);\n}\nfunction clearInterval(timer) {\n global.clearInterval(timer);\n}\n\n/** Cross-browser compatible one-off timer abstraction.\n *\n * @param {Number} delay\n * @param {Function} callback\n */\nexport class OneOffTimer extends Timer {\n constructor(delay: Delay, callback: TimedCallback) {\n super(setTimeout, clearTimeout, delay, function(timer) {\n callback();\n return null;\n });\n }\n}\n\n/** Cross-browser compatible periodic timer abstraction.\n *\n * @param {Number} delay\n * @param {Function} callback\n */\nexport class PeriodicTimer extends Timer {\n constructor(delay: Delay, callback: TimedCallback) {\n super(setInterval, clearInterval, delay, function(timer) {\n callback();\n return timer;\n });\n }\n}\n","import * as Collections from './utils/collections';\nimport TimedCallback from './utils/timers/timed_callback';\nimport { OneOffTimer, PeriodicTimer } from './utils/timers';\n\nvar Util = {\n now(): number {\n if (Date.now) {\n return Date.now();\n } else {\n return new Date().valueOf();\n }\n },\n\n defer(callback: TimedCallback): OneOffTimer {\n return new OneOffTimer(0, callback);\n },\n\n /** Builds a function that will proxy a method call to its first argument.\n *\n * Allows partial application of arguments, so additional arguments are\n * prepended to the argument list.\n *\n * @param {String} name method name\n * @return {Function} proxy function\n */\n method(name: string, ...args: any[]): Function {\n var boundArguments = Array.prototype.slice.call(arguments, 1);\n return function(object) {\n return object[name].apply(object, boundArguments.concat(arguments));\n };\n }\n};\n\nexport default Util;\n","import base64encode from '../base64';\nimport Util from '../util';\n\n/** Merges multiple objects into the target argument.\n *\n * For properties that are plain Objects, performs a deep-merge. For the\n * rest it just copies the value of the property.\n *\n * To extend prototypes use it as following:\n * Pusher.Util.extend(Target.prototype, Base.prototype)\n *\n * You can also use it to merge objects without altering them:\n * Pusher.Util.extend({}, object1, object2)\n *\n * @param {Object} target\n * @return {Object} the target argument\n */\nexport function extend(target: any, ...sources: any[]): T {\n for (var i = 0; i < sources.length; i++) {\n var extensions = sources[i];\n for (var property in extensions) {\n if (\n extensions[property] &&\n extensions[property].constructor &&\n extensions[property].constructor === Object\n ) {\n target[property] = extend(target[property] || {}, extensions[property]);\n } else {\n target[property] = extensions[property];\n }\n }\n }\n return target;\n}\n\nexport function stringify(): string {\n var m = ['Pusher'];\n for (var i = 0; i < arguments.length; i++) {\n if (typeof arguments[i] === 'string') {\n m.push(arguments[i]);\n } else {\n m.push(safeJSONStringify(arguments[i]));\n }\n }\n return m.join(' : ');\n}\n\nexport function arrayIndexOf(array: any[], item: any): number {\n // MSIE doesn't have array.indexOf\n var nativeIndexOf = Array.prototype.indexOf;\n if (array === null) {\n return -1;\n }\n if (nativeIndexOf && array.indexOf === nativeIndexOf) {\n return array.indexOf(item);\n }\n for (var i = 0, l = array.length; i < l; i++) {\n if (array[i] === item) {\n return i;\n }\n }\n return -1;\n}\n\n/** Applies a function f to all properties of an object.\n *\n * Function f gets 3 arguments passed:\n * - element from the object\n * - key of the element\n * - reference to the object\n *\n * @param {Object} object\n * @param {Function} f\n */\nexport function objectApply(object: any, f: Function) {\n for (var key in object) {\n if (Object.prototype.hasOwnProperty.call(object, key)) {\n f(object[key], key, object);\n }\n }\n}\n\n/** Return a list of objects own proerty keys\n *\n * @param {Object} object\n * @returns {Array}\n */\nexport function keys(object: any): string[] {\n var keys = [];\n objectApply(object, function(_, key) {\n keys.push(key);\n });\n return keys;\n}\n\n/** Return a list of object's own property values\n *\n * @param {Object} object\n * @returns {Array}\n */\nexport function values(object: any): any[] {\n var values = [];\n objectApply(object, function(value) {\n values.push(value);\n });\n return values;\n}\n\n/** Applies a function f to all elements of an array.\n *\n * Function f gets 3 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function apply(array: any[], f: Function, context?: any) {\n for (var i = 0; i < array.length; i++) {\n f.call(context || global, array[i], i, array);\n }\n}\n\n/** Maps all elements of the array and returns the result.\n *\n * Function f gets 4 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n * - reference to the destination array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function map(array: any[], f: Function): any[] {\n var result = [];\n for (var i = 0; i < array.length; i++) {\n result.push(f(array[i], i, array, result));\n }\n return result;\n}\n\n/** Maps all elements of the object and returns the result.\n *\n * Function f gets 4 arguments passed:\n * - element from the object\n * - key of the element\n * - reference to the source object\n * - reference to the destination object\n *\n * @param {Object} object\n * @param {Function} f\n */\nexport function mapObject(object: any, f: Function): any {\n var result = {};\n objectApply(object, function(value, key) {\n result[key] = f(value);\n });\n return result;\n}\n\n/** Filters elements of the array using a test function.\n *\n * Function test gets 4 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n * - reference to the destination array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function filter(array: any[], test: Function): any[] {\n test =\n test ||\n function(value) {\n return !!value;\n };\n\n var result = [];\n for (var i = 0; i < array.length; i++) {\n if (test(array[i], i, array, result)) {\n result.push(array[i]);\n }\n }\n return result;\n}\n\n/** Filters properties of the object using a test function.\n *\n * Function test gets 4 arguments passed:\n * - element from the object\n * - key of the element\n * - reference to the source object\n * - reference to the destination object\n *\n * @param {Object} object\n * @param {Function} f\n */\nexport function filterObject(object: Object, test: Function) {\n var result = {};\n objectApply(object, function(value, key) {\n if ((test && test(value, key, object, result)) || Boolean(value)) {\n result[key] = value;\n }\n });\n return result;\n}\n\n/** Flattens an object into a two-dimensional array.\n *\n * @param {Object} object\n * @return {Array} resulting array of [key, value] pairs\n */\nexport function flatten(object: Object): any[] {\n var result = [];\n objectApply(object, function(value, key) {\n result.push([key, value]);\n });\n return result;\n}\n\n/** Checks whether any element of the array passes the test.\n *\n * Function test gets 3 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function any(array: any[], test: Function): boolean {\n for (var i = 0; i < array.length; i++) {\n if (test(array[i], i, array)) {\n return true;\n }\n }\n return false;\n}\n\n/** Checks whether all elements of the array pass the test.\n *\n * Function test gets 3 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function all(array: any[], test: Function): boolean {\n for (var i = 0; i < array.length; i++) {\n if (!test(array[i], i, array)) {\n return false;\n }\n }\n return true;\n}\n\nexport function encodeParamsObject(data): string {\n return mapObject(data, function(value) {\n if (typeof value === 'object') {\n value = safeJSONStringify(value);\n }\n return encodeURIComponent(base64encode(value.toString()));\n });\n}\n\nexport function buildQueryString(data: any): string {\n var params = filterObject(data, function(value) {\n return value !== undefined;\n });\n\n var query = map(\n flatten(encodeParamsObject(params)),\n Util.method('join', '=')\n ).join('&');\n\n return query;\n}\n\n/**\n * See https://github.com/douglascrockford/JSON-js/blob/master/cycle.js\n *\n * Remove circular references from an object. Required for JSON.stringify in\n * React Native, which tends to blow up a lot.\n *\n * @param {any} object\n * @return {any} Decycled object\n */\nexport function decycleObject(object: any): any {\n var objects = [],\n paths = [];\n\n return (function derez(value, path) {\n var i, name, nu;\n\n switch (typeof value) {\n case 'object':\n if (!value) {\n return null;\n }\n for (i = 0; i < objects.length; i += 1) {\n if (objects[i] === value) {\n return { $ref: paths[i] };\n }\n }\n\n objects.push(value);\n paths.push(path);\n\n if (Object.prototype.toString.apply(value) === '[object Array]') {\n nu = [];\n for (i = 0; i < value.length; i += 1) {\n nu[i] = derez(value[i], path + '[' + i + ']');\n }\n } else {\n nu = {};\n for (name in value) {\n if (Object.prototype.hasOwnProperty.call(value, name)) {\n nu[name] = derez(\n value[name],\n path + '[' + JSON.stringify(name) + ']'\n );\n }\n }\n }\n return nu;\n case 'number':\n case 'string':\n case 'boolean':\n return value;\n }\n })(object, '$');\n}\n\n/**\n * Provides a cross-browser and cross-platform way to safely stringify objects\n * into JSON. This is particularly necessary for ReactNative, where circular JSON\n * structures throw an exception.\n *\n * @param {any} source The object to stringify\n * @return {string} The serialized output.\n */\nexport function safeJSONStringify(source: any): string {\n try {\n return JSON.stringify(source);\n } catch (e) {\n return JSON.stringify(decycleObject(source));\n }\n}\n","import { stringify } from './utils/collections';\nimport Pusher from './pusher';\n\nclass Logger {\n debug(...args: any[]) {\n this.log(this.globalLog, args);\n }\n\n warn(...args: any[]) {\n this.log(this.globalLogWarn, args);\n }\n\n error(...args: any[]) {\n this.log(this.globalLogError, args);\n }\n\n private globalLog = (message: string) => {\n if (global.console && global.console.log) {\n global.console.log(message);\n }\n };\n\n private globalLogWarn(message: string) {\n if (global.console && global.console.warn) {\n global.console.warn(message);\n } else {\n this.globalLog(message);\n }\n }\n\n private globalLogError(message: string) {\n if (global.console && global.console.error) {\n global.console.error(message);\n } else {\n this.globalLogWarn(message);\n }\n }\n\n private log(\n defaultLoggingFunction: (message: string) => void,\n ...args: any[]\n ) {\n var message = stringify.apply(this, arguments);\n if (Pusher.log) {\n Pusher.log(message);\n } else if (Pusher.logToConsole) {\n const log = defaultLoggingFunction.bind(this);\n log(message);\n }\n }\n}\n\nexport default new Logger();\n","import Browser from '../browser';\nimport Logger from 'core/logger';\nimport JSONPRequest from '../dom/jsonp_request';\nimport { ScriptReceivers } from '../dom/script_receiver_factory';\nimport { AuthTransport } from 'core/auth/auth_transports';\nimport {\n AuthRequestType,\n AuthTransportCallback,\n InternalAuthOptions\n} from 'core/auth/options';\n\nvar jsonp: AuthTransport = function(\n context: Browser,\n query: string,\n authOptions: InternalAuthOptions,\n authRequestType: AuthRequestType,\n callback: AuthTransportCallback\n) {\n if (\n authOptions.headers !== undefined ||\n authOptions.headersProvider != null\n ) {\n Logger.warn(\n `To send headers with the ${authRequestType.toString()} request, you must use AJAX, rather than JSONP.`\n );\n }\n\n var callbackName = context.nextAuthCallbackID.toString();\n context.nextAuthCallbackID++;\n\n var document = context.getDocument();\n var script = document.createElement('script');\n // Hacked wrapper.\n context.auth_callbacks[callbackName] = function(data) {\n callback(null, data);\n };\n\n var callback_name = \"Pusher.auth_callbacks['\" + callbackName + \"']\";\n script.src =\n authOptions.endpoint +\n '?callback=' +\n encodeURIComponent(callback_name) +\n '&' +\n query;\n\n var head =\n document.getElementsByTagName('head')[0] || document.documentElement;\n head.insertBefore(script, head.firstChild);\n};\n\nexport default jsonp;\n","import ScriptReceiver from './script_receiver';\n\n/** Sends a generic HTTP GET request using a script tag.\n *\n * By constructing URL in a specific way, it can be used for loading\n * JavaScript resources or JSONP requests. It can notify about errors, but\n * only in certain environments. Please take care of monitoring the state of\n * the request yourself.\n *\n * @param {String} src\n */\nexport default class ScriptRequest {\n src: string;\n script: any;\n errorScript: any;\n\n constructor(src: string) {\n this.src = src;\n }\n\n send(receiver: ScriptReceiver) {\n var self = this;\n var errorString = 'Error loading ' + self.src;\n\n self.script = document.createElement('script');\n self.script.id = receiver.id;\n self.script.src = self.src;\n self.script.type = 'text/javascript';\n self.script.charset = 'UTF-8';\n\n if (self.script.addEventListener) {\n self.script.onerror = function() {\n receiver.callback(errorString);\n };\n self.script.onload = function() {\n receiver.callback(null);\n };\n } else {\n self.script.onreadystatechange = function() {\n if (\n self.script.readyState === 'loaded' ||\n self.script.readyState === 'complete'\n ) {\n receiver.callback(null);\n }\n };\n }\n\n // Opera<11.6 hack for missing onerror callback\n if (\n self.script.async === undefined &&\n (document).attachEvent &&\n /opera/i.test(navigator.userAgent)\n ) {\n self.errorScript = document.createElement('script');\n self.errorScript.id = receiver.id + '_error';\n self.errorScript.text = receiver.name + \"('\" + errorString + \"');\";\n self.script.async = self.errorScript.async = false;\n } else {\n self.script.async = true;\n }\n\n var head = document.getElementsByTagName('head')[0];\n head.insertBefore(self.script, head.firstChild);\n if (self.errorScript) {\n head.insertBefore(self.errorScript, self.script.nextSibling);\n }\n }\n\n /** Cleans up the DOM remains of the script request. */\n cleanup() {\n if (this.script) {\n this.script.onload = this.script.onerror = null;\n this.script.onreadystatechange = null;\n }\n if (this.script && this.script.parentNode) {\n this.script.parentNode.removeChild(this.script);\n }\n if (this.errorScript && this.errorScript.parentNode) {\n this.errorScript.parentNode.removeChild(this.errorScript);\n }\n this.script = null;\n this.errorScript = null;\n }\n}\n","import ScriptReceiver from './script_receiver';\nimport ScriptRequest from './script_request';\nimport * as Collections from 'core/utils/collections';\nimport Util from 'core/util';\nimport Runtime from '../runtime';\n\n/** Sends data via JSONP.\n *\n * Data is a key-value map. Its values are JSON-encoded and then passed\n * through base64. Finally, keys and encoded values are appended to the query\n * string.\n *\n * The class itself does not guarantee raising errors on failures, as it's not\n * possible to support such feature on all browsers. Instead, JSONP endpoint\n * should call back in a way that's easy to distinguish from browser calls,\n * for example by passing a second argument to the receiver.\n *\n * @param {String} url\n * @param {Object} data key-value map of data to be submitted\n */\nexport default class JSONPRequest {\n url: string;\n data: any;\n request: ScriptRequest;\n\n constructor(url: string, data: any) {\n this.url = url;\n this.data = data;\n }\n\n /** Sends the actual JSONP request.\n *\n * @param {ScriptReceiver} receiver\n */\n send(receiver: ScriptReceiver) {\n if (this.request) {\n return;\n }\n\n var query = Collections.buildQueryString(this.data);\n var url = this.url + '/' + receiver.number + '?' + query;\n this.request = Runtime.createScriptRequest(url);\n this.request.send(receiver);\n }\n\n /** Cleans up the DOM remains of the JSONP request. */\n cleanup() {\n if (this.request) {\n this.request.cleanup();\n }\n }\n}\n","import TimelineSender from 'core/timeline/timeline_sender';\nimport TimelineTransport from 'core/timeline/timeline_transport';\nimport Browser from 'runtime';\nimport { AuthTransport } from 'core/auth/auth_transports';\nimport { ScriptReceivers } from '../dom/script_receiver_factory';\n\nvar getAgent = function(sender: TimelineSender, useTLS: boolean) {\n return function(data: any, callback: Function) {\n var scheme = 'http' + (useTLS ? 's' : '') + '://';\n var url =\n scheme + (sender.host || sender.options.host) + sender.options.path;\n var request = Browser.createJSONPRequest(url, data);\n\n var receiver = Browser.ScriptReceivers.create(function(error, result) {\n ScriptReceivers.remove(receiver);\n request.cleanup();\n\n if (result && result.host) {\n sender.host = result.host;\n }\n if (callback) {\n callback(error, result);\n }\n });\n request.send(receiver);\n };\n};\n\nvar jsonp = {\n name: 'jsonp',\n getAgent\n};\n\nexport default jsonp;\n","import Defaults from '../defaults';\nimport { default as URLScheme, URLSchemeParams } from './url_scheme';\n\nfunction getGenericURL(\n baseScheme: string,\n params: URLSchemeParams,\n path: string\n): string {\n var scheme = baseScheme + (params.useTLS ? 's' : '');\n var host = params.useTLS ? params.hostTLS : params.hostNonTLS;\n return scheme + '://' + host + path;\n}\n\nfunction getGenericPath(key: string, queryString?: string): string {\n var path = '/app/' + key;\n var query =\n '?protocol=' +\n Defaults.PROTOCOL +\n '&client=js' +\n '&version=' +\n Defaults.VERSION +\n (queryString ? '&' + queryString : '');\n return path + query;\n}\n\nexport var ws: URLScheme = {\n getInitial: function(key: string, params: URLSchemeParams): string {\n var path = (params.httpPath || '') + getGenericPath(key, 'flash=false');\n return getGenericURL('ws', params, path);\n }\n};\n\nexport var http: URLScheme = {\n getInitial: function(key: string, params: URLSchemeParams): string {\n var path = (params.httpPath || '/pusher') + getGenericPath(key);\n return getGenericURL('http', params, path);\n }\n};\n\nexport var sockjs: URLScheme = {\n getInitial: function(key: string, params: URLSchemeParams): string {\n return getGenericURL('http', params, params.httpPath || '/pusher');\n },\n getPath: function(key: string, params: URLSchemeParams): string {\n return getGenericPath(key);\n }\n};\n","import Callback from './callback';\nimport * as Collections from '../utils/collections';\nimport CallbackTable from './callback_table';\n\nexport default class CallbackRegistry {\n _callbacks: CallbackTable;\n\n constructor() {\n this._callbacks = {};\n }\n\n get(name: string): Callback[] {\n return this._callbacks[prefix(name)];\n }\n\n add(name: string, callback: Function, context: any) {\n var prefixedEventName = prefix(name);\n this._callbacks[prefixedEventName] =\n this._callbacks[prefixedEventName] || [];\n this._callbacks[prefixedEventName].push({\n fn: callback,\n context: context\n });\n }\n\n remove(name?: string, callback?: Function, context?: any) {\n if (!name && !callback && !context) {\n this._callbacks = {};\n return;\n }\n\n var names = name ? [prefix(name)] : Collections.keys(this._callbacks);\n\n if (callback || context) {\n this.removeCallback(names, callback, context);\n } else {\n this.removeAllCallbacks(names);\n }\n }\n\n private removeCallback(names: string[], callback: Function, context: any) {\n Collections.apply(\n names,\n function(name) {\n this._callbacks[name] = Collections.filter(\n this._callbacks[name] || [],\n function(binding) {\n return (\n (callback && callback !== binding.fn) ||\n (context && context !== binding.context)\n );\n }\n );\n if (this._callbacks[name].length === 0) {\n delete this._callbacks[name];\n }\n },\n this\n );\n }\n\n private removeAllCallbacks(names: string[]) {\n Collections.apply(\n names,\n function(name) {\n delete this._callbacks[name];\n },\n this\n );\n }\n}\n\nfunction prefix(name: string): string {\n return '_' + name;\n}\n","import * as Collections from '../utils/collections';\nimport Callback from './callback';\nimport Metadata from '../channels/metadata';\nimport CallbackRegistry from './callback_registry';\n\n/** Manages callback bindings and event emitting.\n *\n * @param Function failThrough called when no listeners are bound to an event\n */\nexport default class Dispatcher {\n callbacks: CallbackRegistry;\n global_callbacks: Function[];\n failThrough: Function;\n\n constructor(failThrough?: Function) {\n this.callbacks = new CallbackRegistry();\n this.global_callbacks = [];\n this.failThrough = failThrough;\n }\n\n bind(eventName: string, callback: Function, context?: any) {\n this.callbacks.add(eventName, callback, context);\n return this;\n }\n\n bind_global(callback: Function) {\n this.global_callbacks.push(callback);\n return this;\n }\n\n unbind(eventName?: string, callback?: Function, context?: any) {\n this.callbacks.remove(eventName, callback, context);\n return this;\n }\n\n unbind_global(callback?: Function) {\n if (!callback) {\n this.global_callbacks = [];\n return this;\n }\n\n this.global_callbacks = Collections.filter(\n this.global_callbacks || [],\n c => c !== callback\n );\n\n return this;\n }\n\n unbind_all() {\n this.unbind();\n this.unbind_global();\n return this;\n }\n\n emit(eventName: string, data?: any, metadata?: Metadata): Dispatcher {\n for (var i = 0; i < this.global_callbacks.length; i++) {\n this.global_callbacks[i](eventName, data);\n }\n\n var callbacks = this.callbacks.get(eventName);\n var args = [];\n\n if (metadata) {\n // if there's a metadata argument, we need to call the callback with both\n // data and metadata regardless of whether data is undefined\n args.push(data, metadata);\n } else if (data) {\n // metadata is undefined, so we only need to call the callback with data\n // if data exists\n args.push(data);\n }\n\n if (callbacks && callbacks.length > 0) {\n for (var i = 0; i < callbacks.length; i++) {\n callbacks[i].fn.apply(callbacks[i].context || global, args);\n }\n } else if (this.failThrough) {\n this.failThrough(eventName, data);\n }\n\n return this;\n }\n}\n","import Util from '../util';\nimport * as Collections from '../utils/collections';\nimport { default as EventsDispatcher } from '../events/dispatcher';\nimport Logger from '../logger';\nimport TransportHooks from './transport_hooks';\nimport Socket from '../socket';\nimport Runtime from 'runtime';\nimport Timeline from '../timeline/timeline';\nimport TransportConnectionOptions from './transport_connection_options';\n\n/** Provides universal API for transport connections.\n *\n * Transport connection is a low-level object that wraps a connection method\n * and exposes a simple evented interface for the connection state and\n * messaging. It does not implement Pusher-specific WebSocket protocol.\n *\n * Additionally, it fetches resources needed for transport to work and exposes\n * an interface for querying transport features.\n *\n * States:\n * - new - initial state after constructing the object\n * - initializing - during initialization phase, usually fetching resources\n * - intialized - ready to establish a connection\n * - connection - when connection is being established\n * - open - when connection ready to be used\n * - closed - after connection was closed be either side\n *\n * Emits:\n * - error - after the connection raised an error\n *\n * Options:\n * - useTLS - whether connection should be over TLS\n * - hostTLS - host to connect to when connection is over TLS\n * - hostNonTLS - host to connect to when connection is over TLS\n *\n * @param {String} key application key\n * @param {Object} options\n */\nexport default class TransportConnection extends EventsDispatcher {\n hooks: TransportHooks;\n name: string;\n priority: number;\n key: string;\n options: TransportConnectionOptions;\n state: string;\n timeline: Timeline;\n activityTimeout: number;\n id: number;\n socket: Socket;\n beforeOpen: Function;\n initialize: Function;\n\n constructor(\n hooks: TransportHooks,\n name: string,\n priority: number,\n key: string,\n options: TransportConnectionOptions\n ) {\n super();\n this.initialize = Runtime.transportConnectionInitializer;\n this.hooks = hooks;\n this.name = name;\n this.priority = priority;\n this.key = key;\n this.options = options;\n\n this.state = 'new';\n this.timeline = options.timeline;\n this.activityTimeout = options.activityTimeout;\n this.id = this.timeline.generateUniqueID();\n }\n\n /** Checks whether the transport handles activity checks by itself.\n *\n * @return {Boolean}\n */\n handlesActivityChecks(): boolean {\n return Boolean(this.hooks.handlesActivityChecks);\n }\n\n /** Checks whether the transport supports the ping/pong API.\n *\n * @return {Boolean}\n */\n supportsPing(): boolean {\n return Boolean(this.hooks.supportsPing);\n }\n\n /** Tries to establish a connection.\n *\n * @returns {Boolean} false if transport is in invalid state\n */\n connect(): boolean {\n if (this.socket || this.state !== 'initialized') {\n return false;\n }\n\n var url = this.hooks.urls.getInitial(this.key, this.options);\n try {\n this.socket = this.hooks.getSocket(url, this.options);\n } catch (e) {\n Util.defer(() => {\n this.onError(e);\n this.changeState('closed');\n });\n return false;\n }\n\n this.bindListeners();\n\n Logger.debug('Connecting', { transport: this.name, url });\n this.changeState('connecting');\n return true;\n }\n\n /** Closes the connection.\n *\n * @return {Boolean} true if there was a connection to close\n */\n close(): boolean {\n if (this.socket) {\n this.socket.close();\n return true;\n } else {\n return false;\n }\n }\n\n /** Sends data over the open connection.\n *\n * @param {String} data\n * @return {Boolean} true only when in the \"open\" state\n */\n send(data: any): boolean {\n if (this.state === 'open') {\n // Workaround for MobileSafari bug (see https://gist.github.com/2052006)\n Util.defer(() => {\n if (this.socket) {\n this.socket.send(data);\n }\n });\n return true;\n } else {\n return false;\n }\n }\n\n /** Sends a ping if the connection is open and transport supports it. */\n ping() {\n if (this.state === 'open' && this.supportsPing()) {\n this.socket.ping();\n }\n }\n\n private onOpen() {\n if (this.hooks.beforeOpen) {\n this.hooks.beforeOpen(\n this.socket,\n this.hooks.urls.getPath(this.key, this.options)\n );\n }\n this.changeState('open');\n this.socket.onopen = undefined;\n }\n\n private onError(error) {\n this.emit('error', { type: 'WebSocketError', error: error });\n this.timeline.error(this.buildTimelineMessage({ error: error.toString() }));\n }\n\n private onClose(closeEvent?: any) {\n if (closeEvent) {\n this.changeState('closed', {\n code: closeEvent.code,\n reason: closeEvent.reason,\n wasClean: closeEvent.wasClean\n });\n } else {\n this.changeState('closed');\n }\n this.unbindListeners();\n this.socket = undefined;\n }\n\n private onMessage(message) {\n this.emit('message', message);\n }\n\n private onActivity() {\n this.emit('activity');\n }\n\n private bindListeners() {\n this.socket.onopen = () => {\n this.onOpen();\n };\n this.socket.onerror = error => {\n this.onError(error);\n };\n this.socket.onclose = closeEvent => {\n this.onClose(closeEvent);\n };\n this.socket.onmessage = message => {\n this.onMessage(message);\n };\n\n if (this.supportsPing()) {\n this.socket.onactivity = () => {\n this.onActivity();\n };\n }\n }\n\n private unbindListeners() {\n if (this.socket) {\n this.socket.onopen = undefined;\n this.socket.onerror = undefined;\n this.socket.onclose = undefined;\n this.socket.onmessage = undefined;\n if (this.supportsPing()) {\n this.socket.onactivity = undefined;\n }\n }\n }\n\n private changeState(state: string, params?: any) {\n this.state = state;\n this.timeline.info(\n this.buildTimelineMessage({\n state: state,\n params: params\n })\n );\n this.emit(state, params);\n }\n\n buildTimelineMessage(message): any {\n return Collections.extend({ cid: this.id }, message);\n }\n}\n","import Factory from '../utils/factory';\nimport TransportHooks from './transport_hooks';\nimport TransportConnection from './transport_connection';\nimport TransportConnectionOptions from './transport_connection_options';\n\n/** Provides interface for transport connection instantiation.\n *\n * Takes transport-specific hooks as the only argument, which allow checking\n * for transport support and creating its connections.\n *\n * Supported hooks: * - file - the name of the file to be fetched during initialization\n * - urls - URL scheme to be used by transport\n * - handlesActivityCheck - true when the transport handles activity checks\n * - supportsPing - true when the transport has a ping/activity API\n * - isSupported - tells whether the transport is supported in the environment\n * - getSocket - creates a WebSocket-compatible transport socket\n *\n * See transports.js for specific implementations.\n *\n * @param {Object} hooks object containing all needed transport hooks\n */\nexport default class Transport {\n hooks: TransportHooks;\n\n constructor(hooks: TransportHooks) {\n this.hooks = hooks;\n }\n\n /** Returns whether the transport is supported in the environment.\n *\n * @param {Object} envronment te environment details (encryption, settings)\n * @returns {Boolean} true when the transport is supported\n */\n isSupported(environment: any): boolean {\n return this.hooks.isSupported(environment);\n }\n\n /** Creates a transport connection.\n *\n * @param {String} name\n * @param {Number} priority\n * @param {String} key the application key\n * @param {Object} options\n * @returns {TransportConnection}\n */\n createConnection(\n name: string,\n priority: number,\n key: string,\n options: any\n ): TransportConnection {\n return new TransportConnection(this.hooks, name, priority, key, options);\n }\n}\n","import * as URLSchemes from 'core/transports/url_schemes';\nimport URLScheme from 'core/transports/url_scheme';\nimport Transport from 'core/transports/transport';\nimport Util from 'core/util';\nimport * as Collections from 'core/utils/collections';\nimport TransportHooks from 'core/transports/transport_hooks';\nimport TransportsTable from 'core/transports/transports_table';\nimport Runtime from 'runtime';\n\n/** WebSocket transport.\n *\n * Uses native WebSocket implementation, including MozWebSocket supported by\n * earlier Firefox versions.\n */\nvar WSTransport = new Transport({\n urls: URLSchemes.ws,\n handlesActivityChecks: false,\n supportsPing: false,\n\n isInitialized: function() {\n return Boolean(Runtime.getWebSocketAPI());\n },\n isSupported: function(): boolean {\n return Boolean(Runtime.getWebSocketAPI());\n },\n getSocket: function(url) {\n return Runtime.createWebSocket(url);\n }\n});\n\nvar httpConfiguration = {\n urls: URLSchemes.http,\n handlesActivityChecks: false,\n supportsPing: true,\n isInitialized: function() {\n return true;\n }\n};\n\nexport var streamingConfiguration = Collections.extend(\n {\n getSocket: function(url) {\n return Runtime.HTTPFactory.createStreamingSocket(url);\n }\n },\n httpConfiguration\n);\nexport var pollingConfiguration = Collections.extend(\n {\n getSocket: function(url) {\n return Runtime.HTTPFactory.createPollingSocket(url);\n }\n },\n httpConfiguration\n);\n\nvar xhrConfiguration = {\n isSupported: function(): boolean {\n return Runtime.isXHRSupported();\n }\n};\n\n/** HTTP streaming transport using CORS-enabled XMLHttpRequest. */\nvar XHRStreamingTransport = new Transport(\n (\n Collections.extend({}, streamingConfiguration, xhrConfiguration)\n )\n);\n\n/** HTTP long-polling transport using CORS-enabled XMLHttpRequest. */\nvar XHRPollingTransport = new Transport(\n Collections.extend({}, pollingConfiguration, xhrConfiguration)\n);\n\nvar Transports: TransportsTable = {\n ws: WSTransport,\n xhr_streaming: XHRStreamingTransport,\n xhr_polling: XHRPollingTransport\n};\n\nexport default Transports;\n","import {\n default as Transports,\n streamingConfiguration,\n pollingConfiguration\n} from 'isomorphic/transports/transports';\nimport Transport from 'core/transports/transport';\nimport TransportHooks from 'core/transports/transport_hooks';\nimport * as URLSchemes from 'core/transports/url_schemes';\nimport Runtime from 'runtime';\nimport { Dependencies } from '../dom/dependencies';\nimport * as Collections from 'core/utils/collections';\n\nvar SockJSTransport = new Transport({\n file: 'sockjs',\n urls: URLSchemes.sockjs,\n handlesActivityChecks: true,\n supportsPing: false,\n\n isSupported: function() {\n return true;\n },\n isInitialized: function() {\n return window.SockJS !== undefined;\n },\n getSocket: function(url, options) {\n return new window.SockJS(url, null, {\n js_path: Dependencies.getPath('sockjs', {\n useTLS: options.useTLS\n }),\n ignore_null_origin: options.ignoreNullOrigin\n });\n },\n beforeOpen: function(socket, path) {\n socket.send(\n JSON.stringify({\n path: path\n })\n );\n }\n});\n\nvar xdrConfiguration = {\n isSupported: function(environment): boolean {\n var yes = Runtime.isXDRSupported(environment.useTLS);\n return yes;\n }\n};\n\n/** HTTP streaming transport using XDomainRequest (IE 8,9). */\nvar XDRStreamingTransport = new Transport(\n (\n Collections.extend({}, streamingConfiguration, xdrConfiguration)\n )\n);\n\n/** HTTP long-polling transport using XDomainRequest (IE 8,9). */\nvar XDRPollingTransport = new Transport(\n Collections.extend({}, pollingConfiguration, xdrConfiguration)\n);\n\nTransports.xdr_streaming = XDRStreamingTransport;\nTransports.xdr_polling = XDRPollingTransport;\nTransports.sockjs = SockJSTransport;\n\nexport default Transports;\n","import Reachability from 'core/reachability';\nimport { default as EventsDispatcher } from 'core/events/dispatcher';\n\n/** Really basic interface providing network availability info.\n *\n * Emits:\n * - online - when browser goes online\n * - offline - when browser goes offline\n */\nexport class NetInfo extends EventsDispatcher implements Reachability {\n constructor() {\n super();\n var self = this;\n // This is okay, as IE doesn't support this stuff anyway.\n if (window.addEventListener !== undefined) {\n window.addEventListener(\n 'online',\n function() {\n self.emit('online');\n },\n false\n );\n window.addEventListener(\n 'offline',\n function() {\n self.emit('offline');\n },\n false\n );\n }\n }\n\n /** Returns whether browser is online or not\n *\n * Offline means definitely offline (no connection to router).\n * Inverse does NOT mean definitely online (only currently supported in Safari\n * and even there only means the device has a connection to the router).\n *\n * @return {Boolean}\n */\n isOnline(): boolean {\n if (window.navigator.onLine === undefined) {\n return true;\n } else {\n return window.navigator.onLine;\n }\n }\n}\n\nexport var Network = new NetInfo();\n","import Util from '../util';\nimport * as Collections from '../utils/collections';\nimport TransportManager from './transport_manager';\nimport TransportConnection from './transport_connection';\nimport Transport from './transport';\nimport PingDelayOptions from './ping_delay_options';\n\n/** Creates transport connections monitored by a transport manager.\n *\n * When a transport is closed, it might mean the environment does not support\n * it. It's possible that messages get stuck in an intermediate buffer or\n * proxies terminate inactive connections. To combat these problems,\n * assistants monitor the connection lifetime, report unclean exits and\n * adjust ping timeouts to keep the connection active. The decision to disable\n * a transport is the manager's responsibility.\n *\n * @param {TransportManager} manager\n * @param {TransportConnection} transport\n * @param {Object} options\n */\nexport default class AssistantToTheTransportManager {\n manager: TransportManager;\n transport: Transport;\n minPingDelay: number;\n maxPingDelay: number;\n pingDelay: number;\n\n constructor(\n manager: TransportManager,\n transport: Transport,\n options: PingDelayOptions\n ) {\n this.manager = manager;\n this.transport = transport;\n this.minPingDelay = options.minPingDelay;\n this.maxPingDelay = options.maxPingDelay;\n this.pingDelay = undefined;\n }\n\n /** Creates a transport connection.\n *\n * This function has the same API as Transport#createConnection.\n *\n * @param {String} name\n * @param {Number} priority\n * @param {String} key the application key\n * @param {Object} options\n * @returns {TransportConnection}\n */\n createConnection(\n name: string,\n priority: number,\n key: string,\n options: Object\n ): TransportConnection {\n options = Collections.extend({}, options, {\n activityTimeout: this.pingDelay\n });\n var connection = this.transport.createConnection(\n name,\n priority,\n key,\n options\n );\n\n var openTimestamp = null;\n\n var onOpen = function() {\n connection.unbind('open', onOpen);\n connection.bind('closed', onClosed);\n openTimestamp = Util.now();\n };\n var onClosed = closeEvent => {\n connection.unbind('closed', onClosed);\n\n if (closeEvent.code === 1002 || closeEvent.code === 1003) {\n // we don't want to use transports not obeying the protocol\n this.manager.reportDeath();\n } else if (!closeEvent.wasClean && openTimestamp) {\n // report deaths only for short-living transport\n var lifespan = Util.now() - openTimestamp;\n if (lifespan < 2 * this.maxPingDelay) {\n this.manager.reportDeath();\n this.pingDelay = Math.max(lifespan / 2, this.minPingDelay);\n }\n }\n };\n\n connection.bind('open', onOpen);\n return connection;\n }\n\n /** Returns whether the transport is supported in the environment.\n *\n * This function has the same API as Transport#isSupported. Might return false\n * when the manager decides to kill the transport.\n *\n * @param {Object} environment the environment details (encryption, settings)\n * @returns {Boolean} true when the transport is supported\n */\n isSupported(environment: string): boolean {\n return this.manager.isAlive() && this.transport.isSupported(environment);\n }\n}\n","import Action from './action';\nimport { PusherEvent } from './message-types';\n/**\n * Provides functions for handling Pusher protocol-specific messages.\n */\n\nconst Protocol = {\n /**\n * Decodes a message in a Pusher format.\n *\n * The MessageEvent we receive from the transport should contain a pusher event\n * (https://pusher.com/docs/pusher_protocol#events) serialized as JSON in the\n * data field\n *\n * The pusher event may contain a data field too, and it may also be\n * serialised as JSON\n *\n * Throws errors when messages are not parse'able.\n *\n * @param {MessageEvent} messageEvent\n * @return {PusherEvent}\n */\n decodeMessage: function(messageEvent: MessageEvent): PusherEvent {\n try {\n var messageData = JSON.parse(messageEvent.data);\n var pusherEventData = messageData.data;\n if (typeof pusherEventData === 'string') {\n try {\n pusherEventData = JSON.parse(messageData.data);\n } catch (e) {}\n }\n var pusherEvent: PusherEvent = {\n event: messageData.event,\n channel: messageData.channel,\n data: pusherEventData\n };\n if (messageData.user_id) {\n pusherEvent.user_id = messageData.user_id;\n }\n return pusherEvent;\n } catch (e) {\n throw { type: 'MessageParseError', error: e, data: messageEvent.data };\n }\n },\n\n /**\n * Encodes a message to be sent.\n *\n * @param {PusherEvent} event\n * @return {String}\n */\n encodeMessage: function(event: PusherEvent): string {\n return JSON.stringify(event);\n },\n\n /**\n * Processes a handshake message and returns appropriate actions.\n *\n * Returns an object with an 'action' and other action-specific properties.\n *\n * There are three outcomes when calling this function. First is a successful\n * connection attempt, when pusher:connection_established is received, which\n * results in a 'connected' action with an 'id' property. When passed a\n * pusher:error event, it returns a result with action appropriate to the\n * close code and an error. Otherwise, it raises an exception.\n *\n * @param {String} message\n * @result Object\n */\n processHandshake: function(messageEvent: MessageEvent): Action {\n var message = Protocol.decodeMessage(messageEvent);\n\n if (message.event === 'pusher:connection_established') {\n if (!message.data.activity_timeout) {\n throw 'No activity timeout specified in handshake';\n }\n return {\n action: 'connected',\n id: message.data.socket_id,\n activityTimeout: message.data.activity_timeout * 1000\n };\n } else if (message.event === 'pusher:error') {\n // From protocol 6 close codes are sent only once, so this only\n // happens when connection does not support close codes\n return {\n action: this.getCloseAction(message.data),\n error: this.getCloseError(message.data)\n };\n } else {\n throw 'Invalid handshake';\n }\n },\n\n /**\n * Dispatches the close event and returns an appropriate action name.\n *\n * See:\n * 1. https://developer.mozilla.org/en-US/docs/WebSockets/WebSockets_reference/CloseEvent\n * 2. http://pusher.com/docs/pusher_protocol\n *\n * @param {CloseEvent} closeEvent\n * @return {String} close action name\n */\n getCloseAction: function(closeEvent): string {\n if (closeEvent.code < 4000) {\n // ignore 1000 CLOSE_NORMAL, 1001 CLOSE_GOING_AWAY,\n // 1005 CLOSE_NO_STATUS, 1006 CLOSE_ABNORMAL\n // ignore 1007...3999\n // handle 1002 CLOSE_PROTOCOL_ERROR, 1003 CLOSE_UNSUPPORTED,\n // 1004 CLOSE_TOO_LARGE\n if (closeEvent.code >= 1002 && closeEvent.code <= 1004) {\n return 'backoff';\n } else {\n return null;\n }\n } else if (closeEvent.code === 4000) {\n return 'tls_only';\n } else if (closeEvent.code < 4100) {\n return 'refused';\n } else if (closeEvent.code < 4200) {\n return 'backoff';\n } else if (closeEvent.code < 4300) {\n return 'retry';\n } else {\n // unknown error\n return 'refused';\n }\n },\n\n /**\n * Returns an error or null basing on the close event.\n *\n * Null is returned when connection was closed cleanly. Otherwise, an object\n * with error details is returned.\n *\n * @param {CloseEvent} closeEvent\n * @return {Object} error object\n */\n getCloseError: function(closeEvent): any {\n if (closeEvent.code !== 1000 && closeEvent.code !== 1001) {\n return {\n type: 'PusherError',\n data: {\n code: closeEvent.code,\n message: closeEvent.reason || closeEvent.message\n }\n };\n } else {\n return null;\n }\n }\n};\n\nexport default Protocol;\n","import * as Collections from '../utils/collections';\nimport { default as EventsDispatcher } from '../events/dispatcher';\nimport Protocol from './protocol/protocol';\nimport { PusherEvent } from './protocol/message-types';\nimport Logger from '../logger';\nimport TransportConnection from '../transports/transport_connection';\nimport Socket from '../socket';\n/**\n * Provides Pusher protocol interface for transports.\n *\n * Emits following events:\n * - message - on received messages\n * - ping - on ping requests\n * - pong - on pong responses\n * - error - when the transport emits an error\n * - closed - after closing the transport\n *\n * It also emits more events when connection closes with a code.\n * See Protocol.getCloseAction to get more details.\n *\n * @param {Number} id\n * @param {AbstractTransport} transport\n */\nexport default class Connection extends EventsDispatcher implements Socket {\n id: string;\n transport: TransportConnection;\n activityTimeout: number;\n\n constructor(id: string, transport: TransportConnection) {\n super();\n this.id = id;\n this.transport = transport;\n this.activityTimeout = transport.activityTimeout;\n this.bindListeners();\n }\n\n /** Returns whether used transport handles activity checks by itself\n *\n * @returns {Boolean} true if activity checks are handled by the transport\n */\n handlesActivityChecks() {\n return this.transport.handlesActivityChecks();\n }\n\n /** Sends raw data.\n *\n * @param {String} data\n */\n send(data: any): boolean {\n return this.transport.send(data);\n }\n\n /** Sends an event.\n *\n * @param {String} name\n * @param {String} data\n * @param {String} [channel]\n * @returns {Boolean} whether message was sent or not\n */\n send_event(name: string, data: any, channel?: string): boolean {\n var event: PusherEvent = { event: name, data: data };\n if (channel) {\n event.channel = channel;\n }\n Logger.debug('Event sent', event);\n return this.send(Protocol.encodeMessage(event));\n }\n\n /** Sends a ping message to the server.\n *\n * Basing on the underlying transport, it might send either transport's\n * protocol-specific ping or pusher:ping event.\n */\n ping() {\n if (this.transport.supportsPing()) {\n this.transport.ping();\n } else {\n this.send_event('pusher:ping', {});\n }\n }\n\n /** Closes the connection. */\n close() {\n this.transport.close();\n }\n\n private bindListeners() {\n var listeners = {\n message: (messageEvent: MessageEvent) => {\n var pusherEvent;\n try {\n pusherEvent = Protocol.decodeMessage(messageEvent);\n } catch (e) {\n this.emit('error', {\n type: 'MessageParseError',\n error: e,\n data: messageEvent.data\n });\n }\n\n if (pusherEvent !== undefined) {\n Logger.debug('Event recd', pusherEvent);\n\n switch (pusherEvent.event) {\n case 'pusher:error':\n this.emit('error', {\n type: 'PusherError',\n data: pusherEvent.data\n });\n break;\n case 'pusher:ping':\n this.emit('ping');\n break;\n case 'pusher:pong':\n this.emit('pong');\n break;\n }\n this.emit('message', pusherEvent);\n }\n },\n activity: () => {\n this.emit('activity');\n },\n error: error => {\n this.emit('error', error);\n },\n closed: closeEvent => {\n unbindListeners();\n\n if (closeEvent && closeEvent.code) {\n this.handleCloseEvent(closeEvent);\n }\n\n this.transport = null;\n this.emit('closed');\n }\n };\n\n var unbindListeners = () => {\n Collections.objectApply(listeners, (listener, event) => {\n this.transport.unbind(event, listener);\n });\n };\n\n Collections.objectApply(listeners, (listener, event) => {\n this.transport.bind(event, listener);\n });\n }\n\n private handleCloseEvent(closeEvent: any) {\n var action = Protocol.getCloseAction(closeEvent);\n var error = Protocol.getCloseError(closeEvent);\n if (error) {\n this.emit('error', error);\n }\n if (action) {\n this.emit(action, { action: action, error: error });\n }\n }\n}\n","import Util from '../../util';\nimport * as Collections from '../../utils/collections';\nimport Protocol from '../protocol/protocol';\nimport Connection from '../connection';\nimport TransportConnection from '../../transports/transport_connection';\nimport HandshakePayload from './handshake_payload';\n\n/**\n * Handles Pusher protocol handshakes for transports.\n *\n * Calls back with a result object after handshake is completed. Results\n * always have two fields:\n * - action - string describing action to be taken after the handshake\n * - transport - the transport object passed to the constructor\n *\n * Different actions can set different additional properties on the result.\n * In the case of 'connected' action, there will be a 'connection' property\n * containing a Connection object for the transport. Other actions should\n * carry an 'error' property.\n *\n * @param {AbstractTransport} transport\n * @param {Function} callback\n */\nexport default class Handshake {\n transport: TransportConnection;\n callback: (HandshakePayload) => void;\n onMessage: Function;\n onClosed: Function;\n\n constructor(\n transport: TransportConnection,\n callback: (HandshakePayload) => void\n ) {\n this.transport = transport;\n this.callback = callback;\n this.bindListeners();\n }\n\n close() {\n this.unbindListeners();\n this.transport.close();\n }\n\n private bindListeners() {\n this.onMessage = m => {\n this.unbindListeners();\n\n var result;\n try {\n result = Protocol.processHandshake(m);\n } catch (e) {\n this.finish('error', { error: e });\n this.transport.close();\n return;\n }\n\n if (result.action === 'connected') {\n this.finish('connected', {\n connection: new Connection(result.id, this.transport),\n activityTimeout: result.activityTimeout\n });\n } else {\n this.finish(result.action, { error: result.error });\n this.transport.close();\n }\n };\n\n this.onClosed = closeEvent => {\n this.unbindListeners();\n\n var action = Protocol.getCloseAction(closeEvent) || 'backoff';\n var error = Protocol.getCloseError(closeEvent);\n this.finish(action, { error: error });\n };\n\n this.transport.bind('message', this.onMessage);\n this.transport.bind('closed', this.onClosed);\n }\n\n private unbindListeners() {\n this.transport.unbind('message', this.onMessage);\n this.transport.unbind('closed', this.onClosed);\n }\n\n private finish(action: string, params: any) {\n this.callback(\n Collections.extend({ transport: this.transport, action: action }, params)\n );\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport base64encode from '../base64';\nimport Timeline from './timeline';\nimport Runtime from 'runtime';\n\nexport interface TimelineSenderOptions {\n host?: string;\n port?: number;\n path?: string;\n}\n\nexport default class TimelineSender {\n timeline: Timeline;\n options: TimelineSenderOptions;\n host: string;\n\n constructor(timeline: Timeline, options: TimelineSenderOptions) {\n this.timeline = timeline;\n this.options = options || {};\n }\n\n send(useTLS: boolean, callback?: Function) {\n if (this.timeline.isEmpty()) {\n return;\n }\n\n this.timeline.send(\n Runtime.TimelineTransport.getAgent(this, useTLS),\n callback\n );\n }\n}\n","import { default as EventsDispatcher } from '../events/dispatcher';\nimport * as Errors from '../errors';\nimport Logger from '../logger';\nimport Pusher from '../pusher';\nimport { PusherEvent } from '../connection/protocol/message-types';\nimport Metadata from './metadata';\nimport UrlStore from '../utils/url_store';\nimport {\n ChannelAuthorizationData,\n ChannelAuthorizationCallback\n} from '../auth/options';\nimport { HTTPAuthError } from '../errors';\n\n/** Provides base public channel interface with an event emitter.\n *\n * Emits:\n * - pusher:subscription_succeeded - after subscribing successfully\n * - other non-internal events\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\nexport default class Channel extends EventsDispatcher {\n name: string;\n pusher: Pusher;\n subscribed: boolean;\n subscriptionPending: boolean;\n subscriptionCancelled: boolean;\n subscriptionCount: null;\n\n constructor(name: string, pusher: Pusher) {\n super(function(event, data) {\n Logger.debug('No callbacks on ' + name + ' for ' + event);\n });\n\n this.name = name;\n this.pusher = pusher;\n this.subscribed = false;\n this.subscriptionPending = false;\n this.subscriptionCancelled = false;\n }\n\n /** Skips authorization, since public channels don't require it.\n *\n * @param {Function} callback\n */\n authorize(socketId: string, callback: ChannelAuthorizationCallback) {\n return callback(null, { auth: '' });\n }\n\n /** Triggers an event */\n trigger(event: string, data: any) {\n if (event.indexOf('client-') !== 0) {\n throw new Errors.BadEventName(\n \"Event '\" + event + \"' does not start with 'client-'\"\n );\n }\n if (!this.subscribed) {\n var suffix = UrlStore.buildLogSuffix('triggeringClientEvents');\n Logger.warn(\n `Client event triggered before channel 'subscription_succeeded' event . ${suffix}`\n );\n }\n return this.pusher.send_event(event, data, this.name);\n }\n\n /** Signals disconnection to the channel. For internal use only. */\n disconnect() {\n this.subscribed = false;\n this.subscriptionPending = false;\n }\n\n /** Handles a PusherEvent. For internal use only.\n *\n * @param {PusherEvent} event\n */\n handleEvent(event: PusherEvent) {\n var eventName = event.event;\n var data = event.data;\n if (eventName === 'pusher_internal:subscription_succeeded') {\n this.handleSubscriptionSucceededEvent(event);\n } else if (eventName === 'pusher_internal:subscription_count') {\n this.handleSubscriptionCountEvent(event);\n } else if (eventName.indexOf('pusher_internal:') !== 0) {\n var metadata: Metadata = {};\n this.emit(eventName, data, metadata);\n }\n }\n\n handleSubscriptionSucceededEvent(event: PusherEvent) {\n this.subscriptionPending = false;\n this.subscribed = true;\n if (this.subscriptionCancelled) {\n this.pusher.unsubscribe(this.name);\n } else {\n this.emit('pusher:subscription_succeeded', event.data);\n }\n }\n\n handleSubscriptionCountEvent(event: PusherEvent) {\n if (event.data.subscription_count) {\n this.subscriptionCount = event.data.subscription_count;\n }\n\n this.emit('pusher:subscription_count', event.data);\n }\n\n /** Sends a subscription request. For internal use only. */\n subscribe() {\n if (this.subscribed) {\n return;\n }\n this.subscriptionPending = true;\n this.subscriptionCancelled = false;\n this.authorize(\n this.pusher.connection.socket_id,\n (error: Error | null, data: ChannelAuthorizationData) => {\n if (error) {\n this.subscriptionPending = false;\n // Why not bind to 'pusher:subscription_error' a level up, and log there?\n // Binding to this event would cause the warning about no callbacks being\n // bound (see constructor) to be suppressed, that's not what we want.\n Logger.error(error.toString());\n this.emit(\n 'pusher:subscription_error',\n Object.assign(\n {},\n {\n type: 'AuthError',\n error: error.message\n },\n error instanceof HTTPAuthError ? { status: error.status } : {}\n )\n );\n } else {\n this.pusher.send_event('pusher:subscribe', {\n auth: data.auth,\n channel_data: data.channel_data,\n channel: this.name\n });\n }\n }\n );\n }\n\n /** Sends an unsubscription request. For internal use only. */\n unsubscribe() {\n this.subscribed = false;\n this.pusher.send_event('pusher:unsubscribe', {\n channel: this.name\n });\n }\n\n /** Cancels an in progress subscription. For internal use only. */\n cancelSubscription() {\n this.subscriptionCancelled = true;\n }\n\n /** Reinstates an in progress subscripiton. For internal use only. */\n reinstateSubscription() {\n this.subscriptionCancelled = false;\n }\n}\n","import Factory from '../utils/factory';\nimport Channel from './channel';\nimport { ChannelAuthorizationCallback } from '../auth/options';\n\n/** Extends public channels to provide private channel interface.\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\nexport default class PrivateChannel extends Channel {\n /** Authorizes the connection to use the channel.\n *\n * @param {String} socketId\n * @param {Function} callback\n */\n authorize(socketId: string, callback: ChannelAuthorizationCallback) {\n return this.pusher.config.channelAuthorizer(\n {\n channelName: this.name,\n socketId: socketId\n },\n callback\n );\n }\n}\n","import * as Collections from '../utils/collections';\n\n/** Represents a collection of members of a presence channel. */\nexport default class Members {\n members: any;\n count: number;\n myID: any;\n me: any;\n\n constructor() {\n this.reset();\n }\n\n /** Returns member's info for given id.\n *\n * Resulting object containts two fields - id and info.\n *\n * @param {Number} id\n * @return {Object} member's info or null\n */\n get(id: string): any {\n if (Object.prototype.hasOwnProperty.call(this.members, id)) {\n return {\n id: id,\n info: this.members[id]\n };\n } else {\n return null;\n }\n }\n\n /** Calls back for each member in unspecified order.\n *\n * @param {Function} callback\n */\n each(callback: Function) {\n Collections.objectApply(this.members, (member, id) => {\n callback(this.get(id));\n });\n }\n\n /** Updates the id for connected member. For internal use only. */\n setMyID(id: string) {\n this.myID = id;\n }\n\n /** Handles subscription data. For internal use only. */\n onSubscription(subscriptionData: any) {\n this.members = subscriptionData.presence.hash;\n this.count = subscriptionData.presence.count;\n this.me = this.get(this.myID);\n }\n\n /** Adds a new member to the collection. For internal use only. */\n addMember(memberData: any) {\n if (this.get(memberData.user_id) === null) {\n this.count++;\n }\n this.members[memberData.user_id] = memberData.user_info;\n return this.get(memberData.user_id);\n }\n\n /** Adds a member from the collection. For internal use only. */\n removeMember(memberData: any) {\n var member = this.get(memberData.user_id);\n if (member) {\n delete this.members[memberData.user_id];\n this.count--;\n }\n return member;\n }\n\n /** Resets the collection to the initial state. For internal use only. */\n reset() {\n this.members = {};\n this.count = 0;\n this.myID = null;\n this.me = null;\n }\n}\n","import PrivateChannel from './private_channel';\nimport Logger from '../logger';\nimport Members from './members';\nimport Pusher from '../pusher';\nimport UrlStore from 'core/utils/url_store';\nimport { PusherEvent } from '../connection/protocol/message-types';\nimport Metadata from './metadata';\nimport { ChannelAuthorizationData } from '../auth/options';\n\nexport default class PresenceChannel extends PrivateChannel {\n members: Members;\n\n /** Adds presence channel functionality to private channels.\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\n constructor(name: string, pusher: Pusher) {\n super(name, pusher);\n this.members = new Members();\n }\n\n /** Authorizes the connection as a member of the channel.\n *\n * @param {String} socketId\n * @param {Function} callback\n */\n authorize(socketId: string, callback: Function) {\n super.authorize(socketId, async (error, authData) => {\n if (!error) {\n authData = authData as ChannelAuthorizationData;\n if (authData.channel_data != null) {\n var channelData = JSON.parse(authData.channel_data);\n this.members.setMyID(channelData.user_id);\n } else {\n await this.pusher.user.signinDonePromise;\n if (this.pusher.user.user_data != null) {\n // If the user is signed in, get the id of the authenticated user\n // and allow the presence authorization to continue.\n this.members.setMyID(this.pusher.user.user_data.id);\n } else {\n let suffix = UrlStore.buildLogSuffix('authorizationEndpoint');\n Logger.error(\n `Invalid auth response for channel '${this.name}', ` +\n `expected 'channel_data' field. ${suffix}, ` +\n `or the user should be signed in.`\n );\n callback('Invalid auth response');\n return;\n }\n }\n }\n callback(error, authData);\n });\n }\n\n /** Handles presence and subscription events. For internal use only.\n *\n * @param {PusherEvent} event\n */\n handleEvent(event: PusherEvent) {\n var eventName = event.event;\n if (eventName.indexOf('pusher_internal:') === 0) {\n this.handleInternalEvent(event);\n } else {\n var data = event.data;\n var metadata: Metadata = {};\n if (event.user_id) {\n metadata.user_id = event.user_id;\n }\n this.emit(eventName, data, metadata);\n }\n }\n handleInternalEvent(event: PusherEvent) {\n var eventName = event.event;\n var data = event.data;\n switch (eventName) {\n case 'pusher_internal:subscription_succeeded':\n this.handleSubscriptionSucceededEvent(event);\n break;\n case 'pusher_internal:subscription_count':\n this.handleSubscriptionCountEvent(event);\n break;\n case 'pusher_internal:member_added':\n var addedMember = this.members.addMember(data);\n this.emit('pusher:member_added', addedMember);\n break;\n case 'pusher_internal:member_removed':\n var removedMember = this.members.removeMember(data);\n if (removedMember) {\n this.emit('pusher:member_removed', removedMember);\n }\n break;\n }\n }\n\n handleSubscriptionSucceededEvent(event: PusherEvent) {\n this.subscriptionPending = false;\n this.subscribed = true;\n if (this.subscriptionCancelled) {\n this.pusher.unsubscribe(this.name);\n } else {\n this.members.onSubscription(event.data);\n this.emit('pusher:subscription_succeeded', this.members);\n }\n }\n\n /** Resets the channel state, including members map. For internal use only. */\n disconnect() {\n this.members.reset();\n super.disconnect();\n }\n}\n","import PrivateChannel from './private_channel';\nimport * as Errors from '../errors';\nimport Logger from '../logger';\nimport Pusher from '../pusher';\nimport { decode as encodeUTF8 } from '@stablelib/utf8';\nimport { decode as decodeBase64 } from '@stablelib/base64';\nimport Dispatcher from '../events/dispatcher';\nimport { PusherEvent } from '../connection/protocol/message-types';\nimport {\n ChannelAuthorizationData,\n ChannelAuthorizationCallback\n} from '../auth/options';\nimport * as nacl from 'tweetnacl';\n\n/** Extends private channels to provide encrypted channel interface.\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\nexport default class EncryptedChannel extends PrivateChannel {\n key: Uint8Array = null;\n nacl: nacl;\n\n constructor(name: string, pusher: Pusher, nacl: nacl) {\n super(name, pusher);\n this.nacl = nacl;\n }\n\n /** Authorizes the connection to use the channel.\n *\n * @param {String} socketId\n * @param {Function} callback\n */\n authorize(socketId: string, callback: ChannelAuthorizationCallback) {\n super.authorize(\n socketId,\n (error: Error | null, authData: ChannelAuthorizationData) => {\n if (error) {\n callback(error, authData);\n return;\n }\n let sharedSecret = authData['shared_secret'];\n if (!sharedSecret) {\n callback(\n new Error(\n `No shared_secret key in auth payload for encrypted channel: ${this.name}`\n ),\n null\n );\n return;\n }\n this.key = decodeBase64(sharedSecret);\n delete authData['shared_secret'];\n callback(null, authData);\n }\n );\n }\n\n trigger(event: string, data: any): boolean {\n throw new Errors.UnsupportedFeature(\n 'Client events are not currently supported for encrypted channels'\n );\n }\n\n /** Handles an event. For internal use only.\n *\n * @param {PusherEvent} event\n */\n handleEvent(event: PusherEvent) {\n var eventName = event.event;\n var data = event.data;\n if (\n eventName.indexOf('pusher_internal:') === 0 ||\n eventName.indexOf('pusher:') === 0\n ) {\n super.handleEvent(event);\n return;\n }\n this.handleEncryptedEvent(eventName, data);\n }\n\n private handleEncryptedEvent(event: string, data: any): void {\n if (!this.key) {\n Logger.debug(\n 'Received encrypted event before key has been retrieved from the authEndpoint'\n );\n return;\n }\n if (!data.ciphertext || !data.nonce) {\n Logger.error(\n 'Unexpected format for encrypted event, expected object with `ciphertext` and `nonce` fields, got: ' +\n data\n );\n return;\n }\n let cipherText = decodeBase64(data.ciphertext);\n if (cipherText.length < this.nacl.secretbox.overheadLength) {\n Logger.error(\n `Expected encrypted event ciphertext length to be ${this.nacl.secretbox.overheadLength}, got: ${cipherText.length}`\n );\n return;\n }\n let nonce = decodeBase64(data.nonce);\n if (nonce.length < this.nacl.secretbox.nonceLength) {\n Logger.error(\n `Expected encrypted event nonce length to be ${this.nacl.secretbox.nonceLength}, got: ${nonce.length}`\n );\n return;\n }\n\n let bytes = this.nacl.secretbox.open(cipherText, nonce, this.key);\n if (bytes === null) {\n Logger.debug(\n 'Failed to decrypt an event, probably because it was encrypted with a different key. Fetching a new key from the authEndpoint...'\n );\n // Try a single time to retrieve a new auth key and decrypt the event with it\n // If this fails, a new key will be requested when a new message is received\n this.authorize(this.pusher.connection.socket_id, (error, authData) => {\n if (error) {\n Logger.error(\n `Failed to make a request to the authEndpoint: ${authData}. Unable to fetch new key, so dropping encrypted event`\n );\n return;\n }\n bytes = this.nacl.secretbox.open(cipherText, nonce, this.key);\n if (bytes === null) {\n Logger.error(\n `Failed to decrypt event with new key. Dropping encrypted event`\n );\n return;\n }\n this.emit(event, this.getDataToEmit(bytes));\n return;\n });\n return;\n }\n this.emit(event, this.getDataToEmit(bytes));\n }\n\n // Try and parse the decrypted bytes as JSON. If we can't parse it, just\n // return the utf-8 string\n getDataToEmit(bytes: Uint8Array): string {\n let raw = encodeUTF8(bytes);\n try {\n return JSON.parse(raw);\n } catch {\n return raw;\n }\n }\n}\n","import { default as EventsDispatcher } from '../events/dispatcher';\nimport { OneOffTimer as Timer } from '../utils/timers';\nimport { Config } from '../config';\nimport Logger from '../logger';\nimport HandshakePayload from './handshake/handshake_payload';\nimport Connection from './connection';\nimport Strategy from '../strategies/strategy';\nimport StrategyRunner from '../strategies/strategy_runner';\nimport * as Collections from '../utils/collections';\nimport Timeline from '../timeline/timeline';\nimport ConnectionManagerOptions from './connection_manager_options';\nimport Runtime from 'runtime';\n\nimport {\n ErrorCallbacks,\n HandshakeCallbacks,\n ConnectionCallbacks\n} from './callbacks';\nimport Action from './protocol/action';\n\n/** Manages connection to Pusher.\n *\n * Uses a strategy (currently only default), timers and network availability\n * info to establish a connection and export its state. In case of failures,\n * manages reconnection attempts.\n *\n * Exports state changes as following events:\n * - \"state_change\", { previous: p, current: state }\n * - state\n *\n * States:\n * - initialized - initial state, never transitioned to\n * - connecting - connection is being established\n * - connected - connection has been fully established\n * - disconnected - on requested disconnection\n * - unavailable - after connection timeout or when there's no network\n * - failed - when the connection strategy is not supported\n *\n * Options:\n * - unavailableTimeout - time to transition to unavailable state\n * - activityTimeout - time after which ping message should be sent\n * - pongTimeout - time for Pusher to respond with pong before reconnecting\n *\n * @param {String} key application key\n * @param {Object} options\n */\nexport default class ConnectionManager extends EventsDispatcher {\n key: string;\n options: ConnectionManagerOptions;\n state: string;\n connection: Connection;\n usingTLS: boolean;\n timeline: Timeline;\n socket_id: string;\n unavailableTimer: Timer;\n activityTimer: Timer;\n retryTimer: Timer;\n activityTimeout: number;\n strategy: Strategy;\n runner: StrategyRunner;\n errorCallbacks: ErrorCallbacks;\n handshakeCallbacks: HandshakeCallbacks;\n connectionCallbacks: ConnectionCallbacks;\n\n constructor(key: string, options: ConnectionManagerOptions) {\n super();\n this.state = 'initialized';\n this.connection = null;\n\n this.key = key;\n this.options = options;\n this.timeline = this.options.timeline;\n this.usingTLS = this.options.useTLS;\n\n this.errorCallbacks = this.buildErrorCallbacks();\n this.connectionCallbacks = this.buildConnectionCallbacks(\n this.errorCallbacks\n );\n this.handshakeCallbacks = this.buildHandshakeCallbacks(this.errorCallbacks);\n\n var Network = Runtime.getNetwork();\n\n Network.bind('online', () => {\n this.timeline.info({ netinfo: 'online' });\n if (this.state === 'connecting' || this.state === 'unavailable') {\n this.retryIn(0);\n }\n });\n Network.bind('offline', () => {\n this.timeline.info({ netinfo: 'offline' });\n if (this.connection) {\n this.sendActivityCheck();\n }\n });\n\n this.updateStrategy();\n }\n\n switchCluster(key: string) {\n this.key = key;\n // This ensures that the new config coming from\n // pusher instance are taken into account\n // such as appKey and cluster\n this.updateStrategy();\n this.retryIn(0);\n }\n\n /** Establishes a connection to Pusher.\n *\n * Does nothing when connection is already established. See top-level doc\n * to find events emitted on connection attempts.\n */\n connect() {\n if (this.connection || this.runner) {\n return;\n }\n if (!this.strategy.isSupported()) {\n this.updateState('failed');\n return;\n }\n this.updateState('connecting');\n this.startConnecting();\n this.setUnavailableTimer();\n }\n\n /** Sends raw data.\n *\n * @param {String} data\n */\n send(data) {\n if (this.connection) {\n return this.connection.send(data);\n } else {\n return false;\n }\n }\n\n /** Sends an event.\n *\n * @param {String} name\n * @param {String} data\n * @param {String} [channel]\n * @returns {Boolean} whether message was sent or not\n */\n send_event(name: string, data: any, channel?: string) {\n if (this.connection) {\n return this.connection.send_event(name, data, channel);\n } else {\n return false;\n }\n }\n\n /** Closes the connection. */\n disconnect() {\n this.disconnectInternally();\n this.updateState('disconnected');\n }\n\n isUsingTLS() {\n return this.usingTLS;\n }\n\n private startConnecting() {\n var callback = (error, handshake) => {\n if (error) {\n this.runner = this.strategy.connect(0, callback);\n } else {\n if (handshake.action === 'error') {\n this.emit('error', {\n type: 'HandshakeError',\n error: handshake.error\n });\n this.timeline.error({ handshakeError: handshake.error });\n } else {\n this.abortConnecting(); // we don't support switching connections yet\n this.handshakeCallbacks[handshake.action](handshake);\n }\n }\n };\n this.runner = this.strategy.connect(0, callback);\n }\n\n private abortConnecting() {\n if (this.runner) {\n this.runner.abort();\n this.runner = null;\n }\n }\n\n private disconnectInternally() {\n this.abortConnecting();\n this.clearRetryTimer();\n this.clearUnavailableTimer();\n if (this.connection) {\n var connection = this.abandonConnection();\n connection.close();\n }\n }\n\n private updateStrategy() {\n this.strategy = this.options.getStrategy({\n key: this.key,\n timeline: this.timeline,\n useTLS: this.usingTLS\n });\n }\n\n private retryIn(delay) {\n this.timeline.info({ action: 'retry', delay: delay });\n if (delay > 0) {\n this.emit('connecting_in', Math.round(delay / 1000));\n }\n this.retryTimer = new Timer(delay || 0, () => {\n this.disconnectInternally();\n this.connect();\n });\n }\n\n private clearRetryTimer() {\n if (this.retryTimer) {\n this.retryTimer.ensureAborted();\n this.retryTimer = null;\n }\n }\n\n private setUnavailableTimer() {\n this.unavailableTimer = new Timer(this.options.unavailableTimeout, () => {\n this.updateState('unavailable');\n });\n }\n\n private clearUnavailableTimer() {\n if (this.unavailableTimer) {\n this.unavailableTimer.ensureAborted();\n }\n }\n\n private sendActivityCheck() {\n this.stopActivityCheck();\n this.connection.ping();\n // wait for pong response\n this.activityTimer = new Timer(this.options.pongTimeout, () => {\n this.timeline.error({ pong_timed_out: this.options.pongTimeout });\n this.retryIn(0);\n });\n }\n\n private resetActivityCheck() {\n this.stopActivityCheck();\n // send ping after inactivity\n if (this.connection && !this.connection.handlesActivityChecks()) {\n this.activityTimer = new Timer(this.activityTimeout, () => {\n this.sendActivityCheck();\n });\n }\n }\n\n private stopActivityCheck() {\n if (this.activityTimer) {\n this.activityTimer.ensureAborted();\n }\n }\n\n private buildConnectionCallbacks(\n errorCallbacks: ErrorCallbacks\n ): ConnectionCallbacks {\n return Collections.extend({}, errorCallbacks, {\n message: message => {\n // includes pong messages from server\n this.resetActivityCheck();\n this.emit('message', message);\n },\n ping: () => {\n this.send_event('pusher:pong', {});\n },\n activity: () => {\n this.resetActivityCheck();\n },\n error: error => {\n // just emit error to user - socket will already be closed by browser\n this.emit('error', error);\n },\n closed: () => {\n this.abandonConnection();\n if (this.shouldRetry()) {\n this.retryIn(1000);\n }\n }\n });\n }\n\n private buildHandshakeCallbacks(\n errorCallbacks: ErrorCallbacks\n ): HandshakeCallbacks {\n return Collections.extend({}, errorCallbacks, {\n connected: (handshake: HandshakePayload) => {\n this.activityTimeout = Math.min(\n this.options.activityTimeout,\n handshake.activityTimeout,\n handshake.connection.activityTimeout || Infinity\n );\n this.clearUnavailableTimer();\n this.setConnection(handshake.connection);\n this.socket_id = this.connection.id;\n this.updateState('connected', { socket_id: this.socket_id });\n }\n });\n }\n\n private buildErrorCallbacks(): ErrorCallbacks {\n let withErrorEmitted = callback => {\n return (result: Action | HandshakePayload) => {\n if (result.error) {\n this.emit('error', { type: 'WebSocketError', error: result.error });\n }\n callback(result);\n };\n };\n\n return {\n tls_only: withErrorEmitted(() => {\n this.usingTLS = true;\n this.updateStrategy();\n this.retryIn(0);\n }),\n refused: withErrorEmitted(() => {\n this.disconnect();\n }),\n backoff: withErrorEmitted(() => {\n this.retryIn(1000);\n }),\n retry: withErrorEmitted(() => {\n this.retryIn(0);\n })\n };\n }\n\n private setConnection(connection) {\n this.connection = connection;\n for (var event in this.connectionCallbacks) {\n this.connection.bind(event, this.connectionCallbacks[event]);\n }\n this.resetActivityCheck();\n }\n\n private abandonConnection() {\n if (!this.connection) {\n return;\n }\n this.stopActivityCheck();\n for (var event in this.connectionCallbacks) {\n this.connection.unbind(event, this.connectionCallbacks[event]);\n }\n var connection = this.connection;\n this.connection = null;\n return connection;\n }\n\n private updateState(newState: string, data?: any) {\n var previousState = this.state;\n this.state = newState;\n if (previousState !== newState) {\n var newStateDescription = newState;\n if (newStateDescription === 'connected') {\n newStateDescription += ' with new socket ID ' + data.socket_id;\n }\n Logger.debug(\n 'State changed',\n previousState + ' -> ' + newStateDescription\n );\n this.timeline.info({ state: newState, params: data });\n this.emit('state_change', { previous: previousState, current: newState });\n this.emit(newState, data);\n }\n }\n\n private shouldRetry(): boolean {\n return this.state === 'connecting' || this.state === 'connected';\n }\n}\n","import Channel from './channel';\nimport * as Collections from '../utils/collections';\nimport ChannelTable from './channel_table';\nimport Factory from '../utils/factory';\nimport Pusher from '../pusher';\nimport Logger from '../logger';\nimport * as Errors from '../errors';\nimport urlStore from '../utils/url_store';\n\n/** Handles a channel map. */\nexport default class Channels {\n channels: ChannelTable;\n\n constructor() {\n this.channels = {};\n }\n\n /** Creates or retrieves an existing channel by its name.\n *\n * @param {String} name\n * @param {Pusher} pusher\n * @return {Channel}\n */\n add(name: string, pusher: Pusher) {\n if (!this.channels[name]) {\n this.channels[name] = createChannel(name, pusher);\n }\n return this.channels[name];\n }\n\n /** Returns a list of all channels\n *\n * @return {Array}\n */\n all(): Channel[] {\n return Collections.values(this.channels);\n }\n\n /** Finds a channel by its name.\n *\n * @param {String} name\n * @return {Channel} channel or null if it doesn't exist\n */\n find(name: string) {\n return this.channels[name];\n }\n\n /** Removes a channel from the map.\n *\n * @param {String} name\n */\n remove(name: string) {\n var channel = this.channels[name];\n delete this.channels[name];\n return channel;\n }\n\n /** Proxies disconnection signal to all channels. */\n disconnect() {\n Collections.objectApply(this.channels, function(channel) {\n channel.disconnect();\n });\n }\n}\n\nfunction createChannel(name: string, pusher: Pusher): Channel {\n if (name.indexOf('private-encrypted-') === 0) {\n if (pusher.config.nacl) {\n return Factory.createEncryptedChannel(name, pusher, pusher.config.nacl);\n }\n let errMsg =\n 'Tried to subscribe to a private-encrypted- channel but no nacl implementation available';\n let suffix = urlStore.buildLogSuffix('encryptedChannelSupport');\n throw new Errors.UnsupportedFeature(`${errMsg}. ${suffix}`);\n } else if (name.indexOf('private-') === 0) {\n return Factory.createPrivateChannel(name, pusher);\n } else if (name.indexOf('presence-') === 0) {\n return Factory.createPresenceChannel(name, pusher);\n } else if (name.indexOf('#') === 0) {\n throw new Errors.BadChannelName(\n 'Cannot create a channel with name \"' + name + '\".'\n );\n } else {\n return Factory.createChannel(name, pusher);\n }\n}\n","import AssistantToTheTransportManager from '../transports/assistant_to_the_transport_manager';\nimport PingDelayOptions from '../transports/ping_delay_options';\nimport Transport from '../transports/transport';\nimport TransportManager from '../transports/transport_manager';\nimport Handshake from '../connection/handshake';\nimport TransportConnection from '../transports/transport_connection';\nimport SocketHooks from '../http/socket_hooks';\nimport HTTPSocket from '../http/http_socket';\n\nimport Timeline from '../timeline/timeline';\nimport {\n default as TimelineSender,\n TimelineSenderOptions\n} from '../timeline/timeline_sender';\nimport PresenceChannel from '../channels/presence_channel';\nimport PrivateChannel from '../channels/private_channel';\nimport EncryptedChannel from '../channels/encrypted_channel';\nimport Channel from '../channels/channel';\nimport ConnectionManager from '../connection/connection_manager';\nimport ConnectionManagerOptions from '../connection/connection_manager_options';\nimport Ajax from '../http/ajax';\nimport Channels from '../channels/channels';\nimport Pusher from '../pusher';\nimport { Config } from '../config';\nimport * as nacl from 'tweetnacl';\n\nvar Factory = {\n createChannels(): Channels {\n return new Channels();\n },\n\n createConnectionManager(\n key: string,\n options: ConnectionManagerOptions\n ): ConnectionManager {\n return new ConnectionManager(key, options);\n },\n\n createChannel(name: string, pusher: Pusher): Channel {\n return new Channel(name, pusher);\n },\n\n createPrivateChannel(name: string, pusher: Pusher): PrivateChannel {\n return new PrivateChannel(name, pusher);\n },\n\n createPresenceChannel(name: string, pusher: Pusher): PresenceChannel {\n return new PresenceChannel(name, pusher);\n },\n\n createEncryptedChannel(\n name: string,\n pusher: Pusher,\n nacl: nacl\n ): EncryptedChannel {\n return new EncryptedChannel(name, pusher, nacl);\n },\n\n createTimelineSender(timeline: Timeline, options: TimelineSenderOptions) {\n return new TimelineSender(timeline, options);\n },\n\n createHandshake(\n transport: TransportConnection,\n callback: (HandshakePayload) => void\n ): Handshake {\n return new Handshake(transport, callback);\n },\n\n createAssistantToTheTransportManager(\n manager: TransportManager,\n transport: Transport,\n options: PingDelayOptions\n ): AssistantToTheTransportManager {\n return new AssistantToTheTransportManager(manager, transport, options);\n }\n};\n\nexport default Factory;\n","import AssistantToTheTransportManager from './assistant_to_the_transport_manager';\nimport Transport from './transport';\nimport PingDelayOptions from './ping_delay_options';\nimport Factory from '../utils/factory';\n\nexport interface TransportManagerOptions extends PingDelayOptions {\n lives?: number;\n}\n\n/** Keeps track of the number of lives left for a transport.\n *\n * In the beginning of a session, transports may be assigned a number of\n * lives. When an AssistantToTheTransportManager instance reports a transport\n * connection closed uncleanly, the transport loses a life. When the number\n * of lives drops to zero, the transport gets disabled by its manager.\n *\n * @param {Object} options\n */\nexport default class TransportManager {\n options: TransportManagerOptions;\n livesLeft: number;\n\n constructor(options: TransportManagerOptions) {\n this.options = options || {};\n this.livesLeft = this.options.lives || Infinity;\n }\n\n /** Creates a assistant for the transport.\n *\n * @param {Transport} transport\n * @returns {AssistantToTheTransportManager}\n */\n getAssistant(transport: Transport): AssistantToTheTransportManager {\n return Factory.createAssistantToTheTransportManager(this, transport, {\n minPingDelay: this.options.minPingDelay,\n maxPingDelay: this.options.maxPingDelay\n });\n }\n\n /** Returns whether the transport has any lives left.\n *\n * @returns {Boolean}\n */\n isAlive(): boolean {\n return this.livesLeft > 0;\n }\n\n /** Takes one life from the transport. */\n reportDeath() {\n this.livesLeft -= 1;\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport { OneOffTimer as Timer } from '../utils/timers';\nimport Strategy from './strategy';\nimport StrategyOptions from './strategy_options';\n\n/** Loops through strategies with optional timeouts.\n *\n * Options:\n * - loop - whether it should loop through the substrategy list\n * - timeout - initial timeout for a single substrategy\n * - timeoutLimit - maximum timeout\n *\n * @param {Strategy[]} strategies\n * @param {Object} options\n */\nexport default class SequentialStrategy implements Strategy {\n strategies: Strategy[];\n loop: boolean;\n failFast: boolean;\n timeout: number;\n timeoutLimit: number;\n\n constructor(strategies: Strategy[], options: StrategyOptions) {\n this.strategies = strategies;\n this.loop = Boolean(options.loop);\n this.failFast = Boolean(options.failFast);\n this.timeout = options.timeout;\n this.timeoutLimit = options.timeoutLimit;\n }\n\n isSupported(): boolean {\n return Collections.any(this.strategies, Util.method('isSupported'));\n }\n\n connect(minPriority: number, callback: Function) {\n var strategies = this.strategies;\n var current = 0;\n var timeout = this.timeout;\n var runner = null;\n\n var tryNextStrategy = (error, handshake) => {\n if (handshake) {\n callback(null, handshake);\n } else {\n current = current + 1;\n if (this.loop) {\n current = current % strategies.length;\n }\n\n if (current < strategies.length) {\n if (timeout) {\n timeout = timeout * 2;\n if (this.timeoutLimit) {\n timeout = Math.min(timeout, this.timeoutLimit);\n }\n }\n runner = this.tryStrategy(\n strategies[current],\n minPriority,\n { timeout, failFast: this.failFast },\n tryNextStrategy\n );\n } else {\n callback(true);\n }\n }\n };\n\n runner = this.tryStrategy(\n strategies[current],\n minPriority,\n { timeout: timeout, failFast: this.failFast },\n tryNextStrategy\n );\n\n return {\n abort: function() {\n runner.abort();\n },\n forceMinPriority: function(p) {\n minPriority = p;\n if (runner) {\n runner.forceMinPriority(p);\n }\n }\n };\n }\n\n private tryStrategy(\n strategy: Strategy,\n minPriority: number,\n options: StrategyOptions,\n callback: Function\n ) {\n var timer = null;\n var runner = null;\n\n if (options.timeout > 0) {\n timer = new Timer(options.timeout, function() {\n runner.abort();\n callback(true);\n });\n }\n\n runner = strategy.connect(minPriority, function(error, handshake) {\n if (error && timer && timer.isRunning() && !options.failFast) {\n // advance to the next strategy after the timeout\n return;\n }\n if (timer) {\n timer.ensureAborted();\n }\n callback(error, handshake);\n });\n\n return {\n abort: function() {\n if (timer) {\n timer.ensureAborted();\n }\n runner.abort();\n },\n forceMinPriority: function(p) {\n runner.forceMinPriority(p);\n }\n };\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport Strategy from './strategy';\n\n/** Launches all substrategies and emits prioritized connected transports.\n *\n * @param {Array} strategies\n */\nexport default class BestConnectedEverStrategy implements Strategy {\n strategies: Strategy[];\n\n constructor(strategies: Strategy[]) {\n this.strategies = strategies;\n }\n\n isSupported(): boolean {\n return Collections.any(this.strategies, Util.method('isSupported'));\n }\n\n connect(minPriority: number, callback: Function) {\n return connect(this.strategies, minPriority, function(i, runners) {\n return function(error, handshake) {\n runners[i].error = error;\n if (error) {\n if (allRunnersFailed(runners)) {\n callback(true);\n }\n return;\n }\n Collections.apply(runners, function(runner) {\n runner.forceMinPriority(handshake.transport.priority);\n });\n callback(null, handshake);\n };\n });\n }\n}\n\n/** Connects to all strategies in parallel.\n *\n * Callback builder should be a function that takes two arguments: index\n * and a list of runners. It should return another function that will be\n * passed to the substrategy with given index. Runners can be aborted using\n * abortRunner(s) functions from this class.\n *\n * @param {Array} strategies\n * @param {Function} callbackBuilder\n * @return {Object} strategy runner\n */\nfunction connect(\n strategies: Strategy[],\n minPriority: number,\n callbackBuilder: Function\n) {\n var runners = Collections.map(strategies, function(strategy, i, _, rs) {\n return strategy.connect(minPriority, callbackBuilder(i, rs));\n });\n return {\n abort: function() {\n Collections.apply(runners, abortRunner);\n },\n forceMinPriority: function(p) {\n Collections.apply(runners, function(runner) {\n runner.forceMinPriority(p);\n });\n }\n };\n}\n\nfunction allRunnersFailed(runners): boolean {\n return Collections.all(runners, function(runner) {\n return Boolean(runner.error);\n });\n}\n\nfunction abortRunner(runner) {\n if (!runner.error && !runner.aborted) {\n runner.abort();\n runner.aborted = true;\n }\n}\n","import Util from '../util';\nimport Runtime from 'runtime';\nimport Strategy from './strategy';\nimport SequentialStrategy from './sequential_strategy';\nimport StrategyOptions from './strategy_options';\nimport TransportStrategy from './transport_strategy';\nimport Timeline from '../timeline/timeline';\nimport * as Collections from '../utils/collections';\n\nexport interface TransportStrategyDictionary {\n [key: string]: TransportStrategy;\n}\n\n/** Caches the last successful transport and, after the first few attempts,\n * uses the cached transport for subsequent attempts.\n *\n * @param {Strategy} strategy\n * @param {Object} transports\n * @param {Object} options\n */\nexport default class WebSocketPrioritizedCachedStrategy implements Strategy {\n strategy: Strategy;\n transports: TransportStrategyDictionary;\n ttl: number;\n usingTLS: boolean;\n timeline: Timeline;\n\n constructor(\n strategy: Strategy,\n transports: TransportStrategyDictionary,\n options: StrategyOptions\n ) {\n this.strategy = strategy;\n this.transports = transports;\n this.ttl = options.ttl || 1800 * 1000;\n this.usingTLS = options.useTLS;\n this.timeline = options.timeline;\n }\n\n isSupported(): boolean {\n return this.strategy.isSupported();\n }\n\n connect(minPriority: number, callback: Function) {\n var usingTLS = this.usingTLS;\n var info = fetchTransportCache(usingTLS);\n var cacheSkipCount = info && info.cacheSkipCount ? info.cacheSkipCount : 0;\n\n var strategies = [this.strategy];\n if (info && info.timestamp + this.ttl >= Util.now()) {\n var transport = this.transports[info.transport];\n if (transport) {\n if (['ws', 'wss'].includes(info.transport) || cacheSkipCount > 3) {\n this.timeline.info({\n cached: true,\n transport: info.transport,\n latency: info.latency\n });\n strategies.push(\n new SequentialStrategy([transport], {\n timeout: info.latency * 2 + 1000,\n failFast: true\n })\n );\n } else {\n cacheSkipCount++;\n }\n }\n }\n\n var startTimestamp = Util.now();\n var runner = strategies\n .pop()\n .connect(minPriority, function cb(error, handshake) {\n if (error) {\n flushTransportCache(usingTLS);\n if (strategies.length > 0) {\n startTimestamp = Util.now();\n runner = strategies.pop().connect(minPriority, cb);\n } else {\n callback(error);\n }\n } else {\n storeTransportCache(\n usingTLS,\n handshake.transport.name,\n Util.now() - startTimestamp,\n cacheSkipCount\n );\n callback(null, handshake);\n }\n });\n\n return {\n abort: function() {\n runner.abort();\n },\n forceMinPriority: function(p) {\n minPriority = p;\n if (runner) {\n runner.forceMinPriority(p);\n }\n }\n };\n }\n}\n\nfunction getTransportCacheKey(usingTLS: boolean): string {\n return 'pusherTransport' + (usingTLS ? 'TLS' : 'NonTLS');\n}\n\nfunction fetchTransportCache(usingTLS: boolean): any {\n var storage = Runtime.getLocalStorage();\n if (storage) {\n try {\n var serializedCache = storage[getTransportCacheKey(usingTLS)];\n if (serializedCache) {\n return JSON.parse(serializedCache);\n }\n } catch (e) {\n flushTransportCache(usingTLS);\n }\n }\n return null;\n}\n\nfunction storeTransportCache(\n usingTLS: boolean,\n transport: TransportStrategy,\n latency: number,\n cacheSkipCount: number\n) {\n var storage = Runtime.getLocalStorage();\n if (storage) {\n try {\n storage[getTransportCacheKey(usingTLS)] = Collections.safeJSONStringify({\n timestamp: Util.now(),\n transport: transport,\n latency: latency,\n cacheSkipCount: cacheSkipCount\n });\n } catch (e) {\n // catch over quota exceptions raised by localStorage\n }\n }\n}\n\nfunction flushTransportCache(usingTLS: boolean) {\n var storage = Runtime.getLocalStorage();\n if (storage) {\n try {\n delete storage[getTransportCacheKey(usingTLS)];\n } catch (e) {\n // catch exceptions raised by localStorage\n }\n }\n}\n","import { OneOffTimer as Timer } from '../utils/timers';\nimport Strategy from './strategy';\nimport StrategyOptions from './strategy_options';\n\n/** Runs substrategy after specified delay.\n *\n * Options:\n * - delay - time in miliseconds to delay the substrategy attempt\n *\n * @param {Strategy} strategy\n * @param {Object} options\n */\nexport default class DelayedStrategy implements Strategy {\n strategy: Strategy;\n options: { delay: number };\n\n constructor(strategy: Strategy, { delay: number }) {\n this.strategy = strategy;\n this.options = { delay: number };\n }\n\n isSupported(): boolean {\n return this.strategy.isSupported();\n }\n\n connect(minPriority: number, callback: Function) {\n var strategy = this.strategy;\n var runner;\n var timer = new Timer(this.options.delay, function() {\n runner = strategy.connect(minPriority, callback);\n });\n\n return {\n abort: function() {\n timer.ensureAborted();\n if (runner) {\n runner.abort();\n }\n },\n forceMinPriority: function(p) {\n minPriority = p;\n if (runner) {\n runner.forceMinPriority(p);\n }\n }\n };\n }\n}\n","import Strategy from './strategy';\nimport StrategyRunner from './strategy_runner';\n\n/** Proxies method calls to one of substrategies basing on the test function.\n *\n * @param {Function} test\n * @param {Strategy} trueBranch strategy used when test returns true\n * @param {Strategy} falseBranch strategy used when test returns false\n */\nexport default class IfStrategy implements Strategy {\n test: () => boolean;\n trueBranch: Strategy;\n falseBranch: Strategy;\n\n constructor(\n test: () => boolean,\n trueBranch: Strategy,\n falseBranch: Strategy\n ) {\n this.test = test;\n this.trueBranch = trueBranch;\n this.falseBranch = falseBranch;\n }\n\n isSupported(): boolean {\n var branch = this.test() ? this.trueBranch : this.falseBranch;\n return branch.isSupported();\n }\n\n connect(minPriority: number, callback: Function): StrategyRunner {\n var branch = this.test() ? this.trueBranch : this.falseBranch;\n return branch.connect(minPriority, callback);\n }\n}\n","import Strategy from './strategy';\nimport StrategyRunner from './strategy_runner';\n\n/** Launches the substrategy and terminates on the first open connection.\n *\n * @param {Strategy} strategy\n */\nexport default class FirstConnectedStrategy implements Strategy {\n strategy: Strategy;\n\n constructor(strategy: Strategy) {\n this.strategy = strategy;\n }\n\n isSupported(): boolean {\n return this.strategy.isSupported();\n }\n\n connect(minPriority: number, callback: Function): StrategyRunner {\n var runner = this.strategy.connect(minPriority, function(error, handshake) {\n if (handshake) {\n runner.abort();\n }\n callback(error, handshake);\n });\n return runner;\n }\n}\n","import * as Collections from 'core/utils/collections';\nimport TransportManager from 'core/transports/transport_manager';\nimport Strategy from 'core/strategies/strategy';\nimport StrategyOptions from 'core/strategies/strategy_options';\nimport SequentialStrategy from 'core/strategies/sequential_strategy';\nimport BestConnectedEverStrategy from 'core/strategies/best_connected_ever_strategy';\nimport WebSocketPrioritizedCachedStrategy, {\n TransportStrategyDictionary\n} from 'core/strategies/websocket_prioritized_cached_strategy';\nimport DelayedStrategy from 'core/strategies/delayed_strategy';\nimport IfStrategy from 'core/strategies/if_strategy';\nimport FirstConnectedStrategy from 'core/strategies/first_connected_strategy';\nimport { Config } from 'core/config';\n\nfunction testSupportsStrategy(strategy: Strategy) {\n return function() {\n return strategy.isSupported();\n };\n}\n\nvar getDefaultStrategy = function(\n config: Config,\n baseOptions: StrategyOptions,\n defineTransport: Function\n): Strategy {\n var definedTransports = {};\n\n function defineTransportStrategy(\n name: string,\n type: string,\n priority: number,\n options: StrategyOptions,\n manager?: TransportManager\n ) {\n var transport = defineTransport(\n config,\n name,\n type,\n priority,\n options,\n manager\n );\n\n definedTransports[name] = transport;\n\n return transport;\n }\n\n var ws_options: StrategyOptions = Object.assign({}, baseOptions, {\n hostNonTLS: config.wsHost + ':' + config.wsPort,\n hostTLS: config.wsHost + ':' + config.wssPort,\n httpPath: config.wsPath\n });\n var wss_options: StrategyOptions = Object.assign({}, ws_options, {\n useTLS: true\n });\n var sockjs_options: StrategyOptions = Object.assign({}, baseOptions, {\n hostNonTLS: config.httpHost + ':' + config.httpPort,\n hostTLS: config.httpHost + ':' + config.httpsPort,\n httpPath: config.httpPath\n });\n\n var timeouts = {\n loop: true,\n timeout: 15000,\n timeoutLimit: 60000\n };\n\n var ws_manager = new TransportManager({\n minPingDelay: 10000,\n maxPingDelay: config.activityTimeout\n });\n var streaming_manager = new TransportManager({\n lives: 2,\n minPingDelay: 10000,\n maxPingDelay: config.activityTimeout\n });\n\n var ws_transport = defineTransportStrategy(\n 'ws',\n 'ws',\n 3,\n ws_options,\n ws_manager\n );\n var wss_transport = defineTransportStrategy(\n 'wss',\n 'ws',\n 3,\n wss_options,\n ws_manager\n );\n var sockjs_transport = defineTransportStrategy(\n 'sockjs',\n 'sockjs',\n 1,\n sockjs_options\n );\n var xhr_streaming_transport = defineTransportStrategy(\n 'xhr_streaming',\n 'xhr_streaming',\n 1,\n sockjs_options,\n streaming_manager\n );\n var xdr_streaming_transport = defineTransportStrategy(\n 'xdr_streaming',\n 'xdr_streaming',\n 1,\n sockjs_options,\n streaming_manager\n );\n var xhr_polling_transport = defineTransportStrategy(\n 'xhr_polling',\n 'xhr_polling',\n 1,\n sockjs_options\n );\n var xdr_polling_transport = defineTransportStrategy(\n 'xdr_polling',\n 'xdr_polling',\n 1,\n sockjs_options\n );\n\n var ws_loop = new SequentialStrategy([ws_transport], timeouts);\n var wss_loop = new SequentialStrategy([wss_transport], timeouts);\n var sockjs_loop = new SequentialStrategy([sockjs_transport], timeouts);\n var streaming_loop = new SequentialStrategy(\n [\n new IfStrategy(\n testSupportsStrategy(xhr_streaming_transport),\n xhr_streaming_transport,\n xdr_streaming_transport\n )\n ],\n timeouts\n );\n var polling_loop = new SequentialStrategy(\n [\n new IfStrategy(\n testSupportsStrategy(xhr_polling_transport),\n xhr_polling_transport,\n xdr_polling_transport\n )\n ],\n timeouts\n );\n\n var http_loop = new SequentialStrategy(\n [\n new IfStrategy(\n testSupportsStrategy(streaming_loop),\n new BestConnectedEverStrategy([\n streaming_loop,\n new DelayedStrategy(polling_loop, { delay: 4000 })\n ]),\n polling_loop\n )\n ],\n timeouts\n );\n\n var http_fallback_loop = new IfStrategy(\n testSupportsStrategy(http_loop),\n http_loop,\n sockjs_loop\n );\n\n var wsStrategy;\n if (baseOptions.useTLS) {\n wsStrategy = new BestConnectedEverStrategy([\n ws_loop,\n new DelayedStrategy(http_fallback_loop, { delay: 2000 })\n ]);\n } else {\n wsStrategy = new BestConnectedEverStrategy([\n ws_loop,\n new DelayedStrategy(wss_loop, { delay: 2000 }),\n new DelayedStrategy(http_fallback_loop, { delay: 5000 })\n ]);\n }\n\n return new WebSocketPrioritizedCachedStrategy(\n new FirstConnectedStrategy(\n new IfStrategy(\n testSupportsStrategy(ws_transport),\n wsStrategy,\n http_fallback_loop\n )\n ),\n definedTransports,\n {\n ttl: 1800000,\n timeline: baseOptions.timeline,\n useTLS: baseOptions.useTLS\n }\n );\n};\n\nexport default getDefaultStrategy;\n","import { Dependencies } from '../dom/dependencies';\n\n/** Initializes the transport.\n *\n * Fetches resources if needed and then transitions to initialized.\n */\nexport default function() {\n var self = this;\n\n self.timeline.info(\n self.buildTimelineMessage({\n transport: self.name + (self.options.useTLS ? 's' : '')\n })\n );\n\n if (self.hooks.isInitialized()) {\n self.changeState('initialized');\n } else if (self.hooks.file) {\n self.changeState('initializing');\n Dependencies.load(\n self.hooks.file,\n { useTLS: self.options.useTLS },\n function(error, callback) {\n if (self.hooks.isInitialized()) {\n self.changeState('initialized');\n callback(true);\n } else {\n if (error) {\n self.onError(error);\n }\n self.onClose();\n callback(false);\n }\n }\n );\n } else {\n self.onClose();\n }\n}\n","import HTTPRequest from 'core/http/http_request';\nimport RequestHooks from 'core/http/request_hooks';\nimport Ajax from 'core/http/ajax';\nimport * as Errors from 'core/errors';\n\nvar hooks: RequestHooks = {\n getRequest: function(socket: HTTPRequest): Ajax {\n var xdr = new (window).XDomainRequest();\n xdr.ontimeout = function() {\n socket.emit('error', new Errors.RequestTimedOut());\n socket.close();\n };\n xdr.onerror = function(e) {\n socket.emit('error', e);\n socket.close();\n };\n xdr.onprogress = function() {\n if (xdr.responseText && xdr.responseText.length > 0) {\n socket.onChunk(200, xdr.responseText);\n }\n };\n xdr.onload = function() {\n if (xdr.responseText && xdr.responseText.length > 0) {\n socket.onChunk(200, xdr.responseText);\n }\n socket.emit('finished', 200);\n socket.close();\n };\n return xdr;\n },\n abortRequest: function(xdr: Ajax) {\n xdr.ontimeout = xdr.onerror = xdr.onprogress = xdr.onload = null;\n xdr.abort();\n }\n};\n\nexport default hooks;\n","import Runtime from 'runtime';\nimport RequestHooks from './request_hooks';\nimport Ajax from './ajax';\nimport { default as EventsDispatcher } from '../events/dispatcher';\n\nconst MAX_BUFFER_LENGTH = 256 * 1024;\n\nexport default class HTTPRequest extends EventsDispatcher {\n hooks: RequestHooks;\n method: string;\n url: string;\n position: number;\n xhr: Ajax;\n unloader: Function;\n\n constructor(hooks: RequestHooks, method: string, url: string) {\n super();\n this.hooks = hooks;\n this.method = method;\n this.url = url;\n }\n\n start(payload?: any) {\n this.position = 0;\n this.xhr = this.hooks.getRequest(this);\n\n this.unloader = () => {\n this.close();\n };\n Runtime.addUnloadListener(this.unloader);\n\n this.xhr.open(this.method, this.url, true);\n\n if (this.xhr.setRequestHeader) {\n this.xhr.setRequestHeader('Content-Type', 'application/json'); // ReactNative doesn't set this header by default.\n }\n this.xhr.send(payload);\n }\n\n close() {\n if (this.unloader) {\n Runtime.removeUnloadListener(this.unloader);\n this.unloader = null;\n }\n if (this.xhr) {\n this.hooks.abortRequest(this.xhr);\n this.xhr = null;\n }\n }\n\n onChunk(status: number, data: any) {\n while (true) {\n var chunk = this.advanceBuffer(data);\n if (chunk) {\n this.emit('chunk', { status: status, data: chunk });\n } else {\n break;\n }\n }\n if (this.isBufferTooLong(data)) {\n this.emit('buffer_too_long');\n }\n }\n\n private advanceBuffer(buffer: any[]): any {\n var unreadData = buffer.slice(this.position);\n var endOfLinePosition = unreadData.indexOf('\\n');\n\n if (endOfLinePosition !== -1) {\n this.position += endOfLinePosition + 1;\n return unreadData.slice(0, endOfLinePosition);\n } else {\n // chunk is not finished yet, don't move the buffer pointer\n return null;\n }\n }\n\n private isBufferTooLong(buffer: any): boolean {\n return this.position === buffer.length && buffer.length > MAX_BUFFER_LENGTH;\n }\n}\n","enum State {\n CONNECTING = 0,\n OPEN = 1,\n CLOSED = 3\n}\n\nexport default State;\n","import URLLocation from './url_location';\nimport State from './state';\nimport Socket from '../socket';\nimport SocketHooks from './socket_hooks';\nimport Util from '../util';\nimport Ajax from './ajax';\nimport HTTPRequest from './http_request';\nimport Runtime from 'runtime';\n\nvar autoIncrement = 1;\n\nclass HTTPSocket implements Socket {\n hooks: SocketHooks;\n session: string;\n location: URLLocation;\n readyState: State;\n stream: HTTPRequest;\n\n onopen: () => void;\n onerror: (error: any) => void;\n onclose: (closeEvent: any) => void;\n onmessage: (message: any) => void;\n onactivity: () => void;\n\n constructor(hooks: SocketHooks, url: string) {\n this.hooks = hooks;\n this.session = randomNumber(1000) + '/' + randomString(8);\n this.location = getLocation(url);\n this.readyState = State.CONNECTING;\n this.openStream();\n }\n\n send(payload: any) {\n return this.sendRaw(JSON.stringify([payload]));\n }\n\n ping() {\n this.hooks.sendHeartbeat(this);\n }\n\n close(code: any, reason: any) {\n this.onClose(code, reason, true);\n }\n\n /** For internal use only */\n sendRaw(payload: any): boolean {\n if (this.readyState === State.OPEN) {\n try {\n Runtime.createSocketRequest(\n 'POST',\n getUniqueURL(getSendURL(this.location, this.session))\n ).start(payload);\n return true;\n } catch (e) {\n return false;\n }\n } else {\n return false;\n }\n }\n\n /** For internal use only */\n reconnect() {\n this.closeStream();\n this.openStream();\n }\n\n /** For internal use only */\n onClose(code, reason, wasClean) {\n this.closeStream();\n this.readyState = State.CLOSED;\n if (this.onclose) {\n this.onclose({\n code: code,\n reason: reason,\n wasClean: wasClean\n });\n }\n }\n\n private onChunk(chunk) {\n if (chunk.status !== 200) {\n return;\n }\n if (this.readyState === State.OPEN) {\n this.onActivity();\n }\n\n var payload;\n var type = chunk.data.slice(0, 1);\n switch (type) {\n case 'o':\n payload = JSON.parse(chunk.data.slice(1) || '{}');\n this.onOpen(payload);\n break;\n case 'a':\n payload = JSON.parse(chunk.data.slice(1) || '[]');\n for (var i = 0; i < payload.length; i++) {\n this.onEvent(payload[i]);\n }\n break;\n case 'm':\n payload = JSON.parse(chunk.data.slice(1) || 'null');\n this.onEvent(payload);\n break;\n case 'h':\n this.hooks.onHeartbeat(this);\n break;\n case 'c':\n payload = JSON.parse(chunk.data.slice(1) || '[]');\n this.onClose(payload[0], payload[1], true);\n break;\n }\n }\n\n private onOpen(options) {\n if (this.readyState === State.CONNECTING) {\n if (options && options.hostname) {\n this.location.base = replaceHost(this.location.base, options.hostname);\n }\n this.readyState = State.OPEN;\n\n if (this.onopen) {\n this.onopen();\n }\n } else {\n this.onClose(1006, 'Server lost session', true);\n }\n }\n\n private onEvent(event) {\n if (this.readyState === State.OPEN && this.onmessage) {\n this.onmessage({ data: event });\n }\n }\n\n private onActivity() {\n if (this.onactivity) {\n this.onactivity();\n }\n }\n\n private onError(error) {\n if (this.onerror) {\n this.onerror(error);\n }\n }\n\n private openStream() {\n this.stream = Runtime.createSocketRequest(\n 'POST',\n getUniqueURL(this.hooks.getReceiveURL(this.location, this.session))\n );\n\n this.stream.bind('chunk', chunk => {\n this.onChunk(chunk);\n });\n this.stream.bind('finished', status => {\n this.hooks.onFinished(this, status);\n });\n this.stream.bind('buffer_too_long', () => {\n this.reconnect();\n });\n\n try {\n this.stream.start();\n } catch (error) {\n Util.defer(() => {\n this.onError(error);\n this.onClose(1006, 'Could not start streaming', false);\n });\n }\n }\n\n private closeStream() {\n if (this.stream) {\n this.stream.unbind_all();\n this.stream.close();\n this.stream = null;\n }\n }\n}\n\nfunction getLocation(url): URLLocation {\n var parts = /([^\\?]*)\\/*(\\??.*)/.exec(url);\n return {\n base: parts[1],\n queryString: parts[2]\n };\n}\n\nfunction getSendURL(url: URLLocation, session: string): string {\n return url.base + '/' + session + '/xhr_send';\n}\n\nfunction getUniqueURL(url: string): string {\n var separator = url.indexOf('?') === -1 ? '?' : '&';\n return url + separator + 't=' + +new Date() + '&n=' + autoIncrement++;\n}\n\nfunction replaceHost(url: string, hostname: string): string {\n var urlParts = /(https?:\\/\\/)([^\\/:]+)((\\/|:)?.*)/.exec(url);\n return urlParts[1] + hostname + urlParts[3];\n}\n\nfunction randomNumber(max: number): number {\n return Runtime.randomInt(max);\n}\n\nfunction randomString(length: number): string {\n var result = [];\n\n for (var i = 0; i < length; i++) {\n result.push(randomNumber(32).toString(32));\n }\n\n return result.join('');\n}\n\nexport default HTTPSocket;\n","import SocketHooks from './socket_hooks';\nimport HTTPSocket from './http_socket';\n\nvar hooks: SocketHooks = {\n getReceiveURL: function(url, session) {\n return url.base + '/' + session + '/xhr_streaming' + url.queryString;\n },\n onHeartbeat: function(socket) {\n socket.sendRaw('[]');\n },\n sendHeartbeat: function(socket) {\n socket.sendRaw('[]');\n },\n onFinished: function(socket, status) {\n socket.onClose(1006, 'Connection interrupted (' + status + ')', false);\n }\n};\n\nexport default hooks;\n","import SocketHooks from './socket_hooks';\nimport URLLocation from './url_location';\nimport HTTPSocket from './http_socket';\n\nvar hooks: SocketHooks = {\n getReceiveURL: function(url: URLLocation, session: string): string {\n return url.base + '/' + session + '/xhr' + url.queryString;\n },\n onHeartbeat: function() {\n // next HTTP request will reset server's activity timer\n },\n sendHeartbeat: function(socket) {\n socket.sendRaw('[]');\n },\n onFinished: function(socket, status) {\n if (status === 200) {\n socket.reconnect();\n } else {\n socket.onClose(1006, 'Connection interrupted (' + status + ')', false);\n }\n }\n};\n\nexport default hooks;\n","import HTTPRequest from 'core/http/http_request';\nimport RequestHooks from 'core/http/request_hooks';\nimport Ajax from 'core/http/ajax';\nimport Runtime from 'runtime';\n\nvar hooks: RequestHooks = {\n getRequest: function(socket: HTTPRequest): Ajax {\n var Constructor = Runtime.getXHRAPI();\n var xhr = new Constructor();\n xhr.onreadystatechange = xhr.onprogress = function() {\n switch (xhr.readyState) {\n case 3:\n if (xhr.responseText && xhr.responseText.length > 0) {\n socket.onChunk(xhr.status, xhr.responseText);\n }\n break;\n case 4:\n // this happens only on errors, never after calling close\n if (xhr.responseText && xhr.responseText.length > 0) {\n socket.onChunk(xhr.status, xhr.responseText);\n }\n socket.emit('finished', xhr.status);\n socket.close();\n break;\n }\n };\n return xhr;\n },\n abortRequest: function(xhr: Ajax) {\n xhr.onreadystatechange = null;\n xhr.abort();\n }\n};\n\nexport default hooks;\n","import HTTPRequest from 'core/http/http_request';\nimport HTTPSocket from 'core/http/http_socket';\nimport SocketHooks from 'core/http/socket_hooks';\nimport RequestHooks from 'core/http/request_hooks';\nimport streamingHooks from 'core/http/http_streaming_socket';\nimport pollingHooks from 'core/http/http_polling_socket';\nimport xhrHooks from './http_xhr_request';\nimport HTTPFactory from 'core/http/http_factory';\n\nvar HTTP: HTTPFactory = {\n createStreamingSocket(url: string): HTTPSocket {\n return this.createSocket(streamingHooks, url);\n },\n\n createPollingSocket(url: string): HTTPSocket {\n return this.createSocket(pollingHooks, url);\n },\n\n createSocket(hooks: SocketHooks, url: string): HTTPSocket {\n return new HTTPSocket(hooks, url);\n },\n\n createXHR(method: string, url: string): HTTPRequest {\n return this.createRequest(xhrHooks, method, url);\n },\n\n createRequest(hooks: RequestHooks, method: string, url: string): HTTPRequest {\n return new HTTPRequest(hooks, method, url);\n }\n};\n\nexport default HTTP;\n","import xdrHooks from './http_xdomain_request';\nimport HTTP from 'isomorphic/http/http';\n\nHTTP.createXDR = function(method, url) {\n return this.createRequest(xdrHooks, method, url);\n};\n\nexport default HTTP;\n","import Browser from './browser';\nimport { Dependencies, DependenciesReceivers } from './dom/dependencies';\nimport { AuthTransport, AuthTransports } from 'core/auth/auth_transports';\nimport xhrAuth from 'isomorphic/auth/xhr_auth';\nimport jsonpAuth from './auth/jsonp_auth';\nimport TimelineTransport from 'core/timeline/timeline_transport';\nimport TimelineSender from 'core/timeline/timeline_sender';\nimport ScriptRequest from './dom/script_request';\nimport JSONPRequest from './dom/jsonp_request';\nimport * as Collections from 'core/utils/collections';\nimport { ScriptReceivers } from './dom/script_receiver_factory';\nimport jsonpTimeline from './timeline/jsonp_timeline';\nimport Transports from './transports/transports';\nimport Ajax from 'core/http/ajax';\nimport { Network } from './net_info';\nimport getDefaultStrategy from './default_strategy';\nimport transportConnectionInitializer from './transports/transport_connection_initializer';\nimport HTTPFactory from './http/http';\nimport HTTPRequest from 'core/http/http_request';\n\nvar Runtime: Browser = {\n // for jsonp auth\n nextAuthCallbackID: 1,\n auth_callbacks: {},\n ScriptReceivers,\n DependenciesReceivers,\n getDefaultStrategy,\n Transports,\n transportConnectionInitializer,\n HTTPFactory,\n\n TimelineTransport: jsonpTimeline,\n\n getXHRAPI() {\n return window.XMLHttpRequest;\n },\n\n getWebSocketAPI() {\n return window.WebSocket || window.MozWebSocket;\n },\n\n setup(PusherClass): void {\n (window).Pusher = PusherClass; // JSONp requires Pusher to be in the global scope.\n var initializeOnDocumentBody = () => {\n this.onDocumentBody(PusherClass.ready);\n };\n if (!(window).JSON) {\n Dependencies.load('json2', {}, initializeOnDocumentBody);\n } else {\n initializeOnDocumentBody();\n }\n },\n\n getDocument(): Document {\n return document;\n },\n\n getProtocol(): string {\n return this.getDocument().location.protocol;\n },\n\n getAuthorizers(): AuthTransports {\n return { ajax: xhrAuth, jsonp: jsonpAuth };\n },\n\n onDocumentBody(callback: Function) {\n if (document.body) {\n callback();\n } else {\n setTimeout(() => {\n this.onDocumentBody(callback);\n }, 0);\n }\n },\n\n createJSONPRequest(url: string, data: any): JSONPRequest {\n return new JSONPRequest(url, data);\n },\n\n createScriptRequest(src: string): ScriptRequest {\n return new ScriptRequest(src);\n },\n\n getLocalStorage() {\n try {\n return window.localStorage;\n } catch (e) {\n return undefined;\n }\n },\n\n createXHR(): Ajax {\n if (this.getXHRAPI()) {\n return this.createXMLHttpRequest();\n } else {\n return this.createMicrosoftXHR();\n }\n },\n\n createXMLHttpRequest(): Ajax {\n var Constructor = this.getXHRAPI();\n return new Constructor();\n },\n\n createMicrosoftXHR(): Ajax {\n return new ActiveXObject('Microsoft.XMLHTTP');\n },\n\n getNetwork() {\n return Network;\n },\n\n createWebSocket(url: string): any {\n var Constructor = this.getWebSocketAPI();\n return new Constructor(url);\n },\n\n createSocketRequest(method: string, url: string): HTTPRequest {\n if (this.isXHRSupported()) {\n return this.HTTPFactory.createXHR(method, url);\n } else if (this.isXDRSupported(url.indexOf('https:') === 0)) {\n return this.HTTPFactory.createXDR(method, url);\n } else {\n throw 'Cross-origin HTTP requests are not supported';\n }\n },\n\n isXHRSupported(): boolean {\n var Constructor = this.getXHRAPI();\n return (\n Boolean(Constructor) && new Constructor().withCredentials !== undefined\n );\n },\n\n isXDRSupported(useTLS?: boolean): boolean {\n var protocol = useTLS ? 'https:' : 'http:';\n var documentProtocol = this.getProtocol();\n return (\n Boolean(window['XDomainRequest']) && documentProtocol === protocol\n );\n },\n\n addUnloadListener(listener: any) {\n if (window.addEventListener !== undefined) {\n window.addEventListener('unload', listener, false);\n } else if (window.attachEvent !== undefined) {\n window.attachEvent('onunload', listener);\n }\n },\n\n removeUnloadListener(listener: any) {\n if (window.addEventListener !== undefined) {\n window.removeEventListener('unload', listener, false);\n } else if (window.detachEvent !== undefined) {\n window.detachEvent('onunload', listener);\n }\n },\n\n randomInt(max: number): number {\n /**\n * Return values in the range of [0, 1[\n */\n const random = function() {\n const crypto = window.crypto || window['msCrypto'];\n const random = crypto.getRandomValues(new Uint32Array(1))[0];\n\n return random / 2 ** 32;\n };\n\n return Math.floor(random() * max);\n }\n};\n\nexport default Runtime;\n","enum TimelineLevel {\n ERROR = 3,\n INFO = 6,\n DEBUG = 7\n}\n\nexport default TimelineLevel;\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport { default as Level } from './level';\n\nexport interface TimelineOptions {\n level?: Level;\n limit?: number;\n version?: string;\n cluster?: string;\n features?: string[];\n params?: any;\n}\n\nexport default class Timeline {\n key: string;\n session: number;\n events: any[];\n options: TimelineOptions;\n sent: number;\n uniqueID: number;\n\n constructor(key: string, session: number, options: TimelineOptions) {\n this.key = key;\n this.session = session;\n this.events = [];\n this.options = options || {};\n this.sent = 0;\n this.uniqueID = 0;\n }\n\n log(level, event) {\n if (level <= this.options.level) {\n this.events.push(\n Collections.extend({}, event, { timestamp: Util.now() })\n );\n if (this.options.limit && this.events.length > this.options.limit) {\n this.events.shift();\n }\n }\n }\n\n error(event) {\n this.log(Level.ERROR, event);\n }\n\n info(event) {\n this.log(Level.INFO, event);\n }\n\n debug(event) {\n this.log(Level.DEBUG, event);\n }\n\n isEmpty() {\n return this.events.length === 0;\n }\n\n send(sendfn, callback) {\n var data = Collections.extend(\n {\n session: this.session,\n bundle: this.sent + 1,\n key: this.key,\n lib: 'js',\n version: this.options.version,\n cluster: this.options.cluster,\n features: this.options.features,\n timeline: this.events\n },\n this.options.params\n );\n\n this.events = [];\n sendfn(data, (error, result) => {\n if (!error) {\n this.sent++;\n }\n if (callback) {\n callback(error, result);\n }\n });\n\n return true;\n }\n\n generateUniqueID(): number {\n this.uniqueID++;\n return this.uniqueID;\n }\n}\n","import Factory from '../utils/factory';\nimport Util from '../util';\nimport * as Errors from '../errors';\nimport * as Collections from '../utils/collections';\nimport Strategy from './strategy';\nimport Transport from '../transports/transport';\nimport StrategyOptions from './strategy_options';\nimport Handshake from '../connection/handshake';\n\n/** Provides a strategy interface for transports.\n *\n * @param {String} name\n * @param {Number} priority\n * @param {Class} transport\n * @param {Object} options\n */\nexport default class TransportStrategy implements Strategy {\n name: string;\n priority: number;\n transport: Transport;\n options: StrategyOptions;\n\n constructor(\n name: string,\n priority: number,\n transport: Transport,\n options: StrategyOptions\n ) {\n this.name = name;\n this.priority = priority;\n this.transport = transport;\n this.options = options || {};\n }\n\n /** Returns whether the transport is supported in the browser.\n *\n * @returns {Boolean}\n */\n isSupported(): boolean {\n return this.transport.isSupported({\n useTLS: this.options.useTLS\n });\n }\n\n /** Launches a connection attempt and returns a strategy runner.\n *\n * @param {Function} callback\n * @return {Object} strategy runner\n */\n connect(minPriority: number, callback: Function) {\n if (!this.isSupported()) {\n return failAttempt(new Errors.UnsupportedStrategy(), callback);\n } else if (this.priority < minPriority) {\n return failAttempt(new Errors.TransportPriorityTooLow(), callback);\n }\n\n var connected = false;\n var transport = this.transport.createConnection(\n this.name,\n this.priority,\n this.options.key,\n this.options\n );\n var handshake = null;\n\n var onInitialized = function() {\n transport.unbind('initialized', onInitialized);\n transport.connect();\n };\n var onOpen = function() {\n handshake = Factory.createHandshake(transport, function(result) {\n connected = true;\n unbindListeners();\n callback(null, result);\n });\n };\n var onError = function(error) {\n unbindListeners();\n callback(error);\n };\n var onClosed = function() {\n unbindListeners();\n var serializedTransport;\n\n // The reason for this try/catch block is that on React Native\n // the WebSocket object is circular. Therefore transport.socket will\n // throw errors upon stringification. Collections.safeJSONStringify\n // discards circular references when serializing.\n serializedTransport = Collections.safeJSONStringify(transport);\n callback(new Errors.TransportClosed(serializedTransport));\n };\n\n var unbindListeners = function() {\n transport.unbind('initialized', onInitialized);\n transport.unbind('open', onOpen);\n transport.unbind('error', onError);\n transport.unbind('closed', onClosed);\n };\n\n transport.bind('initialized', onInitialized);\n transport.bind('open', onOpen);\n transport.bind('error', onError);\n transport.bind('closed', onClosed);\n\n // connect will be called automatically after initialization\n transport.initialize();\n\n return {\n abort: () => {\n if (connected) {\n return;\n }\n unbindListeners();\n if (handshake) {\n handshake.close();\n } else {\n transport.close();\n }\n },\n forceMinPriority: p => {\n if (connected) {\n return;\n }\n if (this.priority < p) {\n if (handshake) {\n handshake.close();\n } else {\n transport.close();\n }\n }\n }\n };\n }\n}\n\nfunction failAttempt(error: Error, callback: Function) {\n Util.defer(function() {\n callback(error);\n });\n return {\n abort: function() {},\n forceMinPriority: function() {}\n };\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport TransportManager from '../transports/transport_manager';\nimport * as Errors from '../errors';\nimport Strategy from './strategy';\nimport TransportStrategy from './transport_strategy';\nimport StrategyOptions from '../strategies/strategy_options';\nimport { Config } from '../config';\nimport Runtime from 'runtime';\n\nconst { Transports } = Runtime;\n\nexport var defineTransport = function(\n config: Config,\n name: string,\n type: string,\n priority: number,\n options: StrategyOptions,\n manager?: TransportManager\n): Strategy {\n var transportClass = Transports[type];\n if (!transportClass) {\n throw new Errors.UnsupportedTransport(type);\n }\n\n var enabled =\n (!config.enabledTransports ||\n Collections.arrayIndexOf(config.enabledTransports, name) !== -1) &&\n (!config.disabledTransports ||\n Collections.arrayIndexOf(config.disabledTransports, name) === -1);\n\n var transport;\n if (enabled) {\n options = Object.assign(\n { ignoreNullOrigin: config.ignoreNullOrigin },\n options\n );\n\n transport = new TransportStrategy(\n name,\n priority,\n manager ? manager.getAssistant(transportClass) : transportClass,\n options\n );\n } else {\n transport = UnsupportedStrategy;\n }\n\n return transport;\n};\n\nvar UnsupportedStrategy: Strategy = {\n isSupported: function() {\n return false;\n },\n connect: function(_, callback) {\n var deferred = Util.defer(function() {\n callback(new Errors.UnsupportedStrategy());\n });\n return {\n abort: function() {\n deferred.ensureAborted();\n },\n forceMinPriority: function() {}\n };\n }\n};\n","import ConnectionManager from './connection/connection_manager';\nimport {\n ChannelAuthorizationOptions,\n UserAuthenticationOptions\n} from './auth/options';\nimport {\n ChannelAuthorizerGenerator,\n DeprecatedAuthOptions\n} from './auth/deprecated_channel_authorizer';\nimport { AuthTransport, Transport } from './config';\nimport * as nacl from 'tweetnacl';\nimport Logger from './logger';\n\nexport interface Options {\n activityTimeout?: number;\n\n auth?: DeprecatedAuthOptions; // DEPRECATED use channelAuthorization instead\n authEndpoint?: string; // DEPRECATED use channelAuthorization instead\n authTransport?: AuthTransport; // DEPRECATED use channelAuthorization instead\n authorizer?: ChannelAuthorizerGenerator; // DEPRECATED use channelAuthorization instead\n\n channelAuthorization?: ChannelAuthorizationOptions;\n userAuthentication?: UserAuthenticationOptions;\n\n cluster: string;\n enableStats?: boolean;\n disableStats?: boolean;\n disabledTransports?: Transport[];\n enabledTransports?: Transport[];\n forceTLS?: boolean;\n httpHost?: string;\n httpPath?: string;\n httpPort?: number;\n httpsPort?: number;\n ignoreNullOrigin?: boolean;\n nacl?: nacl;\n pongTimeout?: number;\n statsHost?: string;\n timelineParams?: any;\n unavailableTimeout?: number;\n wsHost?: string;\n wsPath?: string;\n wsPort?: number;\n wssPort?: number;\n}\n\nexport interface ClusterOptions {\n appKey: string;\n cluster: string;\n}\n\nexport function validateOptions(options) {\n if (options == null) {\n throw 'You must pass an options object';\n }\n if (options.cluster == null) {\n throw 'Options object must provide a cluster';\n }\n if ('disableStats' in options) {\n Logger.warn(\n 'The disableStats option is deprecated in favor of enableStats'\n );\n }\n}\n","import {\n UserAuthenticationCallback,\n InternalAuthOptions,\n UserAuthenticationHandler,\n UserAuthenticationRequestParams,\n AuthRequestType\n} from './options';\n\nimport Runtime from 'runtime';\n\nconst composeChannelQuery = (\n params: UserAuthenticationRequestParams,\n authOptions: InternalAuthOptions\n) => {\n var query = 'socket_id=' + encodeURIComponent(params.socketId);\n\n for (var key in authOptions.params) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(authOptions.params[key]);\n }\n\n if (authOptions.paramsProvider != null) {\n let dynamicParams = authOptions.paramsProvider();\n for (var key in dynamicParams) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(dynamicParams[key]);\n }\n }\n\n return query;\n};\n\nconst UserAuthenticator = (\n authOptions: InternalAuthOptions\n): UserAuthenticationHandler => {\n if (typeof Runtime.getAuthorizers()[authOptions.transport] === 'undefined') {\n throw `'${authOptions.transport}' is not a recognized auth transport`;\n }\n\n return (\n params: UserAuthenticationRequestParams,\n callback: UserAuthenticationCallback\n ) => {\n const query = composeChannelQuery(params, authOptions);\n\n Runtime.getAuthorizers()[authOptions.transport](\n Runtime,\n query,\n authOptions,\n AuthRequestType.UserAuthentication,\n callback\n );\n };\n};\n\nexport default UserAuthenticator;\n","import {\n AuthRequestType,\n InternalAuthOptions,\n ChannelAuthorizationHandler,\n ChannelAuthorizationRequestParams,\n ChannelAuthorizationCallback\n} from './options';\n\nimport Runtime from 'runtime';\n\nconst composeChannelQuery = (\n params: ChannelAuthorizationRequestParams,\n authOptions: InternalAuthOptions\n) => {\n var query = 'socket_id=' + encodeURIComponent(params.socketId);\n\n query += '&channel_name=' + encodeURIComponent(params.channelName);\n\n for (var key in authOptions.params) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(authOptions.params[key]);\n }\n\n if (authOptions.paramsProvider != null) {\n let dynamicParams = authOptions.paramsProvider();\n for (var key in dynamicParams) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(dynamicParams[key]);\n }\n }\n\n return query;\n};\n\nconst ChannelAuthorizer = (\n authOptions: InternalAuthOptions\n): ChannelAuthorizationHandler => {\n if (typeof Runtime.getAuthorizers()[authOptions.transport] === 'undefined') {\n throw `'${authOptions.transport}' is not a recognized auth transport`;\n }\n\n return (\n params: ChannelAuthorizationRequestParams,\n callback: ChannelAuthorizationCallback\n ) => {\n const query = composeChannelQuery(params, authOptions);\n\n Runtime.getAuthorizers()[authOptions.transport](\n Runtime,\n query,\n authOptions,\n AuthRequestType.ChannelAuthorization,\n callback\n );\n };\n};\n\nexport default ChannelAuthorizer;\n","import Channel from '../channels/channel';\nimport {\n ChannelAuthorizationCallback,\n ChannelAuthorizationHandler,\n ChannelAuthorizationRequestParams,\n InternalAuthOptions\n} from './options';\n\nexport interface DeprecatedChannelAuthorizer {\n authorize(socketId: string, callback: ChannelAuthorizationCallback): void;\n}\n\nexport interface ChannelAuthorizerGenerator {\n (\n channel: Channel,\n options: DeprecatedAuthorizerOptions\n ): DeprecatedChannelAuthorizer;\n}\n\nexport interface DeprecatedAuthOptions {\n params?: any;\n headers?: any;\n}\n\nexport interface DeprecatedAuthorizerOptions {\n authTransport: 'ajax' | 'jsonp';\n authEndpoint: string;\n auth?: DeprecatedAuthOptions;\n}\n\nexport const ChannelAuthorizerProxy = (\n pusher,\n authOptions: InternalAuthOptions,\n channelAuthorizerGenerator: ChannelAuthorizerGenerator\n): ChannelAuthorizationHandler => {\n const deprecatedAuthorizerOptions: DeprecatedAuthorizerOptions = {\n authTransport: authOptions.transport,\n authEndpoint: authOptions.endpoint,\n auth: {\n params: authOptions.params,\n headers: authOptions.headers\n }\n };\n return (\n params: ChannelAuthorizationRequestParams,\n callback: ChannelAuthorizationCallback\n ) => {\n const channel = pusher.channel(params.channelName);\n // This line creates a new channel authorizer every time.\n // In the past, this was only done once per channel and reused.\n // We can do that again if we want to keep this behavior intact.\n const channelAuthorizer: DeprecatedChannelAuthorizer = channelAuthorizerGenerator(\n channel,\n deprecatedAuthorizerOptions\n );\n channelAuthorizer.authorize(params.socketId, callback);\n };\n};\n","import { Options } from './options';\nimport Defaults from './defaults';\nimport {\n ChannelAuthorizationHandler,\n UserAuthenticationHandler,\n ChannelAuthorizationOptions\n} from './auth/options';\nimport UserAuthenticator from './auth/user_authenticator';\nimport ChannelAuthorizer from './auth/channel_authorizer';\nimport { ChannelAuthorizerProxy } from './auth/deprecated_channel_authorizer';\nimport Runtime from 'runtime';\nimport * as nacl from 'tweetnacl';\n\nexport type AuthTransport = 'ajax' | 'jsonp';\nexport type Transport =\n | 'ws'\n | 'wss'\n | 'xhr_streaming'\n | 'xhr_polling'\n | 'sockjs';\n\nexport interface Config {\n // these are all 'required' config parameters, it's not necessary for the user\n // to set them, but they have configured defaults.\n activityTimeout: number;\n enableStats: boolean;\n httpHost: string;\n httpPath: string;\n httpPort: number;\n httpsPort: number;\n pongTimeout: number;\n statsHost: string;\n unavailableTimeout: number;\n useTLS: boolean;\n wsHost: string;\n wsPath: string;\n wsPort: number;\n wssPort: number;\n userAuthenticator: UserAuthenticationHandler;\n channelAuthorizer: ChannelAuthorizationHandler;\n\n // these are all optional parameters or overrrides. The customer can set these\n // but it's not strictly necessary\n forceTLS?: boolean;\n cluster?: string;\n disabledTransports?: Transport[];\n enabledTransports?: Transport[];\n ignoreNullOrigin?: boolean;\n nacl?: nacl;\n timelineParams?: any;\n}\n\n// getConfig mainly sets the defaults for the options that are not provided\nexport function getConfig(opts: Options, pusher): Config {\n let config: Config = {\n activityTimeout: opts.activityTimeout || Defaults.activityTimeout,\n cluster: opts.cluster,\n httpPath: opts.httpPath || Defaults.httpPath,\n httpPort: opts.httpPort || Defaults.httpPort,\n httpsPort: opts.httpsPort || Defaults.httpsPort,\n pongTimeout: opts.pongTimeout || Defaults.pongTimeout,\n statsHost: opts.statsHost || Defaults.stats_host,\n unavailableTimeout: opts.unavailableTimeout || Defaults.unavailableTimeout,\n wsPath: opts.wsPath || Defaults.wsPath,\n wsPort: opts.wsPort || Defaults.wsPort,\n wssPort: opts.wssPort || Defaults.wssPort,\n\n enableStats: getEnableStatsConfig(opts),\n httpHost: getHttpHost(opts),\n useTLS: shouldUseTLS(opts),\n wsHost: getWebsocketHost(opts),\n\n userAuthenticator: buildUserAuthenticator(opts),\n channelAuthorizer: buildChannelAuthorizer(opts, pusher)\n };\n\n if ('disabledTransports' in opts)\n config.disabledTransports = opts.disabledTransports;\n if ('enabledTransports' in opts)\n config.enabledTransports = opts.enabledTransports;\n if ('ignoreNullOrigin' in opts)\n config.ignoreNullOrigin = opts.ignoreNullOrigin;\n if ('timelineParams' in opts) config.timelineParams = opts.timelineParams;\n if ('nacl' in opts) {\n config.nacl = opts.nacl;\n }\n\n return config;\n}\n\nfunction getHttpHost(opts: Options): string {\n if (opts.httpHost) {\n return opts.httpHost;\n }\n if (opts.cluster) {\n return `sockjs-${opts.cluster}.pusher.com`;\n }\n return Defaults.httpHost;\n}\n\nfunction getWebsocketHost(opts: Options): string {\n if (opts.wsHost) {\n return opts.wsHost;\n }\n return getWebsocketHostFromCluster(opts.cluster);\n}\n\nfunction getWebsocketHostFromCluster(cluster: string): string {\n return `ws-${cluster}.pusher.com`;\n}\n\nfunction shouldUseTLS(opts: Options): boolean {\n if (Runtime.getProtocol() === 'https:') {\n return true;\n } else if (opts.forceTLS === false) {\n return false;\n }\n return true;\n}\n\n// if enableStats is set take the value\n// if disableStats is set take the inverse\n// otherwise default to false\nfunction getEnableStatsConfig(opts: Options): boolean {\n if ('enableStats' in opts) {\n return opts.enableStats;\n }\n if ('disableStats' in opts) {\n return !opts.disableStats;\n }\n return false;\n}\n\nfunction buildUserAuthenticator(opts: Options): UserAuthenticationHandler {\n const userAuthentication = {\n ...Defaults.userAuthentication,\n ...opts.userAuthentication\n };\n if (\n 'customHandler' in userAuthentication &&\n userAuthentication['customHandler'] != null\n ) {\n return userAuthentication['customHandler'];\n }\n\n return UserAuthenticator(userAuthentication);\n}\n\nfunction buildChannelAuth(opts: Options, pusher): ChannelAuthorizationOptions {\n let channelAuthorization: ChannelAuthorizationOptions;\n if ('channelAuthorization' in opts) {\n channelAuthorization = {\n ...Defaults.channelAuthorization,\n ...opts.channelAuthorization\n };\n } else {\n channelAuthorization = {\n transport: opts.authTransport || Defaults.authTransport,\n endpoint: opts.authEndpoint || Defaults.authEndpoint\n };\n if ('auth' in opts) {\n if ('params' in opts.auth) channelAuthorization.params = opts.auth.params;\n if ('headers' in opts.auth)\n channelAuthorization.headers = opts.auth.headers;\n }\n if ('authorizer' in opts)\n channelAuthorization.customHandler = ChannelAuthorizerProxy(\n pusher,\n channelAuthorization,\n opts.authorizer\n );\n }\n return channelAuthorization;\n}\n\nfunction buildChannelAuthorizer(\n opts: Options,\n pusher\n): ChannelAuthorizationHandler {\n const channelAuthorization = buildChannelAuth(opts, pusher);\n if (\n 'customHandler' in channelAuthorization &&\n channelAuthorization['customHandler'] != null\n ) {\n return channelAuthorization['customHandler'];\n }\n\n return ChannelAuthorizer(channelAuthorization);\n}\n","import Logger from './logger';\nimport Pusher from './pusher';\nimport EventsDispatcher from './events/dispatcher';\n\nexport default class WatchlistFacade extends EventsDispatcher {\n private pusher: Pusher;\n\n public constructor(pusher: Pusher) {\n super(function(eventName, data) {\n Logger.debug(`No callbacks on watchlist events for ${eventName}`);\n });\n\n this.pusher = pusher;\n this.bindWatchlistInternalEvent();\n }\n\n handleEvent(pusherEvent) {\n pusherEvent.data.events.forEach(watchlistEvent => {\n this.emit(watchlistEvent.name, watchlistEvent);\n });\n }\n\n private bindWatchlistInternalEvent() {\n this.pusher.connection.bind('message', pusherEvent => {\n var eventName = pusherEvent.event;\n if (eventName === 'pusher_internal:watchlist_events') {\n this.handleEvent(pusherEvent);\n }\n });\n }\n}\n","function flatPromise() {\n let resolve, reject;\n const promise = new Promise((res, rej) => {\n resolve = res;\n reject = rej;\n });\n return { promise, resolve, reject };\n}\n\nexport default flatPromise;\n","import Pusher from './pusher';\nimport Logger from './logger';\nimport {\n UserAuthenticationData,\n UserAuthenticationCallback\n} from './auth/options';\nimport Channel from './channels/channel';\nimport WatchlistFacade from './watchlist';\nimport EventsDispatcher from './events/dispatcher';\nimport flatPromise from './utils/flat_promise';\n\nexport default class UserFacade extends EventsDispatcher {\n pusher: Pusher;\n signin_requested: boolean = false;\n user_data: any = null;\n serverToUserChannel: Channel = null;\n signinDonePromise: Promise = null;\n watchlist: WatchlistFacade;\n private _signinDoneResolve: Function = null;\n\n public constructor(pusher: Pusher) {\n super(function(eventName, data) {\n Logger.debug('No callbacks on user for ' + eventName);\n });\n this.pusher = pusher;\n this.pusher.connection.bind('state_change', ({ previous, current }) => {\n if (previous !== 'connected' && current === 'connected') {\n this._signin();\n }\n if (previous === 'connected' && current !== 'connected') {\n this._cleanup();\n this._newSigninPromiseIfNeeded();\n }\n });\n\n this.watchlist = new WatchlistFacade(pusher);\n\n this.pusher.connection.bind('message', event => {\n var eventName = event.event;\n if (eventName === 'pusher:signin_success') {\n this._onSigninSuccess(event.data);\n }\n if (\n this.serverToUserChannel &&\n this.serverToUserChannel.name === event.channel\n ) {\n this.serverToUserChannel.handleEvent(event);\n }\n });\n }\n\n public signin() {\n if (this.signin_requested) {\n return;\n }\n\n this.signin_requested = true;\n this._signin();\n }\n\n private _signin() {\n if (!this.signin_requested) {\n return;\n }\n\n this._newSigninPromiseIfNeeded();\n\n if (this.pusher.connection.state !== 'connected') {\n // Signin will be attempted when the connection is connected\n return;\n }\n\n this.pusher.config.userAuthenticator(\n {\n socketId: this.pusher.connection.socket_id\n },\n this._onAuthorize\n );\n }\n\n private _onAuthorize: UserAuthenticationCallback = (\n err,\n authData: UserAuthenticationData\n ) => {\n if (err) {\n Logger.warn(`Error during signin: ${err}`);\n this._cleanup();\n return;\n }\n\n this.pusher.send_event('pusher:signin', {\n auth: authData.auth,\n user_data: authData.user_data\n });\n\n // Later when we get pusher:singin_success event, the user will be marked as signed in\n };\n\n private _onSigninSuccess(data: any) {\n try {\n this.user_data = JSON.parse(data.user_data);\n } catch (e) {\n Logger.error(`Failed parsing user data after signin: ${data.user_data}`);\n this._cleanup();\n return;\n }\n\n if (typeof this.user_data.id !== 'string' || this.user_data.id === '') {\n Logger.error(\n `user_data doesn't contain an id. user_data: ${this.user_data}`\n );\n this._cleanup();\n return;\n }\n\n // Signin succeeded\n this._signinDoneResolve();\n this._subscribeChannels();\n }\n\n private _subscribeChannels() {\n const ensure_subscribed = channel => {\n if (channel.subscriptionPending && channel.subscriptionCancelled) {\n channel.reinstateSubscription();\n } else if (\n !channel.subscriptionPending &&\n this.pusher.connection.state === 'connected'\n ) {\n channel.subscribe();\n }\n };\n\n this.serverToUserChannel = new Channel(\n `#server-to-user-${this.user_data.id}`,\n this.pusher\n );\n this.serverToUserChannel.bind_global((eventName, data) => {\n if (\n eventName.indexOf('pusher_internal:') === 0 ||\n eventName.indexOf('pusher:') === 0\n ) {\n // ignore internal events\n return;\n }\n this.emit(eventName, data);\n });\n ensure_subscribed(this.serverToUserChannel);\n }\n\n private _cleanup() {\n this.user_data = null;\n if (this.serverToUserChannel) {\n this.serverToUserChannel.unbind_all();\n this.serverToUserChannel.disconnect();\n this.serverToUserChannel = null;\n }\n\n if (this.signin_requested) {\n // If signin is in progress and cleanup is called,\n // Mark the current signin process as done.\n this._signinDoneResolve();\n }\n }\n\n private _newSigninPromiseIfNeeded() {\n if (!this.signin_requested) {\n return;\n }\n\n // If there is a promise and it is not resolved, return without creating a new one.\n if (this.signinDonePromise && !(this.signinDonePromise as any).done) {\n return;\n }\n\n // This promise is never rejected.\n // It gets resolved when the signin process is done whether it failed or succeeded\n const { promise, resolve, reject: _ } = flatPromise();\n (promise as any).done = false;\n const setDone = () => {\n (promise as any).done = true;\n };\n promise.then(setDone).catch(setDone);\n this.signinDonePromise = promise;\n this._signinDoneResolve = resolve;\n }\n}\n","import AbstractRuntime from '../runtimes/interface';\nimport Runtime from 'runtime';\nimport * as Collections from './utils/collections';\nimport Channels from './channels/channels';\nimport Channel from './channels/channel';\nimport { default as EventsDispatcher } from './events/dispatcher';\nimport Timeline from './timeline/timeline';\nimport TimelineSender from './timeline/timeline_sender';\nimport TimelineLevel from './timeline/level';\nimport { defineTransport } from './strategies/strategy_builder';\nimport ConnectionManager from './connection/connection_manager';\nimport { PeriodicTimer } from './utils/timers';\nimport Defaults from './defaults';\nimport Logger from './logger';\nimport Factory from './utils/factory';\nimport { Options, ClusterOptions, validateOptions } from './options';\nimport { Config, getConfig } from './config';\nimport StrategyOptions from './strategies/strategy_options';\nimport UserFacade from './user';\n\nexport default class Pusher {\n /* STATIC PROPERTIES */\n static instances: Pusher[] = [];\n static isReady: boolean = false;\n static logToConsole: boolean = false;\n\n // for jsonp\n static Runtime: AbstractRuntime = Runtime;\n static ScriptReceivers: any = (Runtime).ScriptReceivers;\n static DependenciesReceivers: any = (Runtime).DependenciesReceivers;\n static auth_callbacks: any = (Runtime).auth_callbacks;\n\n static ready() {\n Pusher.isReady = true;\n for (var i = 0, l = Pusher.instances.length; i < l; i++) {\n Pusher.instances[i].connect();\n }\n }\n\n static log: (message: any) => void;\n\n private static getClientFeatures(): string[] {\n return Collections.keys(\n Collections.filterObject({ ws: Runtime.Transports.ws }, function(t) {\n return t.isSupported({});\n })\n );\n }\n\n /* INSTANCE PROPERTIES */\n key: string;\n options: Options;\n config: Config;\n channels: Channels;\n global_emitter: EventsDispatcher;\n sessionID: number;\n timeline: Timeline;\n timelineSender: TimelineSender;\n connection: ConnectionManager;\n timelineSenderTimer: PeriodicTimer;\n user: UserFacade;\n constructor(app_key: string, options: Options) {\n checkAppKey(app_key);\n validateOptions(options);\n this.key = app_key;\n this.config = getConfig(options, this);\n\n this.channels = Factory.createChannels();\n this.global_emitter = new EventsDispatcher();\n this.sessionID = Runtime.randomInt(1000000000);\n\n this.timeline = new Timeline(this.key, this.sessionID, {\n cluster: this.config.cluster,\n features: Pusher.getClientFeatures(),\n params: this.config.timelineParams || {},\n limit: 50,\n level: TimelineLevel.INFO,\n version: Defaults.VERSION\n });\n if (this.config.enableStats) {\n this.timelineSender = Factory.createTimelineSender(this.timeline, {\n host: this.config.statsHost,\n path: '/timeline/v2/' + Runtime.TimelineTransport.name\n });\n }\n\n var getStrategy = (options: StrategyOptions) => {\n return Runtime.getDefaultStrategy(this.config, options, defineTransport);\n };\n\n this.connection = Factory.createConnectionManager(this.key, {\n getStrategy: getStrategy,\n timeline: this.timeline,\n activityTimeout: this.config.activityTimeout,\n pongTimeout: this.config.pongTimeout,\n unavailableTimeout: this.config.unavailableTimeout,\n useTLS: Boolean(this.config.useTLS)\n });\n\n this.connection.bind('connected', () => {\n this.subscribeAll();\n if (this.timelineSender) {\n this.timelineSender.send(this.connection.isUsingTLS());\n }\n });\n\n this.connection.bind('message', event => {\n var eventName = event.event;\n var internal = eventName.indexOf('pusher_internal:') === 0;\n if (event.channel) {\n var channel = this.channel(event.channel);\n if (channel) {\n channel.handleEvent(event);\n }\n }\n // Emit globally [deprecated]\n if (!internal) {\n this.global_emitter.emit(event.event, event.data);\n }\n });\n this.connection.bind('connecting', () => {\n this.channels.disconnect();\n });\n this.connection.bind('disconnected', () => {\n this.channels.disconnect();\n });\n this.connection.bind('error', err => {\n Logger.warn(err);\n });\n\n Pusher.instances.push(this);\n this.timeline.info({ instances: Pusher.instances.length });\n\n this.user = new UserFacade(this);\n\n if (Pusher.isReady) {\n this.connect();\n }\n }\n\n /**\n * Allows you to switch Pusher cluster without\n * losing all the channels/subscription binding\n * as this is internally managed by the SDK.\n */\n switchCluster(options: ClusterOptions) {\n const { appKey, cluster } = options;\n this.key = appKey;\n this.options = { ...this.options, cluster };\n this.config = getConfig(this.options, this);\n this.connection.switchCluster(this.key);\n }\n\n channel(name: string): Channel {\n return this.channels.find(name);\n }\n\n allChannels(): Channel[] {\n return this.channels.all();\n }\n\n connect() {\n this.connection.connect();\n\n if (this.timelineSender) {\n if (!this.timelineSenderTimer) {\n var usingTLS = this.connection.isUsingTLS();\n var timelineSender = this.timelineSender;\n this.timelineSenderTimer = new PeriodicTimer(60000, function() {\n timelineSender.send(usingTLS);\n });\n }\n }\n }\n\n disconnect() {\n this.connection.disconnect();\n\n if (this.timelineSenderTimer) {\n this.timelineSenderTimer.ensureAborted();\n this.timelineSenderTimer = null;\n }\n }\n\n bind(event_name: string, callback: Function, context?: any): Pusher {\n this.global_emitter.bind(event_name, callback, context);\n return this;\n }\n\n unbind(event_name?: string, callback?: Function, context?: any): Pusher {\n this.global_emitter.unbind(event_name, callback, context);\n return this;\n }\n\n bind_global(callback: Function): Pusher {\n this.global_emitter.bind_global(callback);\n return this;\n }\n\n unbind_global(callback?: Function): Pusher {\n this.global_emitter.unbind_global(callback);\n return this;\n }\n\n unbind_all(callback?: Function): Pusher {\n this.global_emitter.unbind_all();\n return this;\n }\n\n subscribeAll() {\n var channelName;\n for (channelName in this.channels.channels) {\n if (this.channels.channels.hasOwnProperty(channelName)) {\n this.subscribe(channelName);\n }\n }\n }\n\n subscribe(channel_name: string) {\n var channel = this.channels.add(channel_name, this);\n if (channel.subscriptionPending && channel.subscriptionCancelled) {\n channel.reinstateSubscription();\n } else if (\n !channel.subscriptionPending &&\n this.connection.state === 'connected'\n ) {\n channel.subscribe();\n }\n return channel;\n }\n\n unsubscribe(channel_name: string) {\n var channel = this.channels.find(channel_name);\n if (channel && channel.subscriptionPending) {\n channel.cancelSubscription();\n } else {\n channel = this.channels.remove(channel_name);\n if (channel && channel.subscribed) {\n channel.unsubscribe();\n }\n }\n }\n\n send_event(event_name: string, data: any, channel?: string) {\n return this.connection.send_event(event_name, data, channel);\n }\n\n shouldUseTLS(): boolean {\n return this.config.useTLS;\n }\n\n signin() {\n this.user.signin();\n }\n}\n\nfunction checkAppKey(key) {\n if (key === null || key === undefined) {\n throw 'You must pass your app key when you instantiate Pusher.';\n }\n}\n\nRuntime.setup(Pusher);\n","import Pusher from './pusher';\nimport { Options, validateOptions } from './options';\nimport * as nacl from 'tweetnacl';\n\nexport default class PusherWithEncryption extends Pusher {\n constructor(app_key: string, options: Options) {\n Pusher.logToConsole = PusherWithEncryption.logToConsole;\n Pusher.log = PusherWithEncryption.log;\n\n validateOptions(options);\n options.nacl = nacl;\n super(app_key, options);\n }\n}\n"],"sourceRoot":""} \ No newline at end of file diff --git a/dist/web/pusher-with-encryption.min.js b/dist/web/pusher-with-encryption.min.js index 5f41f0891..d80ed5906 100644 --- a/dist/web/pusher-with-encryption.min.js +++ b/dist/web/pusher-with-encryption.min.js @@ -1,9 +1,9 @@ /*! - * Pusher JavaScript Library v8.3.0 + * Pusher JavaScript Library v8.4.0 * https://pusher.com/ * * Copyright 2020, Pusher * Released under the MIT licence. */ -!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.Pusher=e():t.Pusher=e()}(window,(function(){return function(t){var e={};function n(r){if(e[r])return e[r].exports;var i=e[r]={i:r,l:!1,exports:{}};return t[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)n.d(r,i,function(e){return t[e]}.bind(null,i));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=3)}([function(t,e,n){"use strict";var r,i=this&&this.__extends||(r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)},function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)});Object.defineProperty(e,"__esModule",{value:!0});var s=function(){function t(t){void 0===t&&(t="="),this._paddingCharacter=t}return t.prototype.encodedLength=function(t){return this._paddingCharacter?(t+2)/3*4|0:(8*t+5)/6|0},t.prototype.encode=function(t){for(var e="",n=0;n>>18&63),e+=this._encodeByte(r>>>12&63),e+=this._encodeByte(r>>>6&63),e+=this._encodeByte(r>>>0&63)}var i=t.length-n;if(i>0){r=t[n]<<16|(2===i?t[n+1]<<8:0);e+=this._encodeByte(r>>>18&63),e+=this._encodeByte(r>>>12&63),e+=2===i?this._encodeByte(r>>>6&63):this._paddingCharacter||"",e+=this._paddingCharacter||""}return e},t.prototype.maxDecodedLength=function(t){return this._paddingCharacter?t/4*3|0:(6*t+7)/8|0},t.prototype.decodedLength=function(t){return this.maxDecodedLength(t.length-this._getPaddingLength(t))},t.prototype.decode=function(t){if(0===t.length)return new Uint8Array(0);for(var e=this._getPaddingLength(t),n=t.length-e,r=new Uint8Array(this.maxDecodedLength(n)),i=0,s=0,o=0,a=0,c=0,h=0,u=0;s>>4,r[i++]=c<<4|h>>>2,r[i++]=h<<6|u,o|=256&a,o|=256&c,o|=256&h,o|=256&u;if(s>>4,o|=256&a,o|=256&c),s>>2,o|=256&h),s>>8&6,e+=51-t>>>8&-75,e+=61-t>>>8&-15,e+=62-t>>>8&3,String.fromCharCode(e)},t.prototype._decodeChar=function(t){var e=256;return e+=(42-t&t-44)>>>8&-256+t-43+62,e+=(46-t&t-48)>>>8&-256+t-47+63,e+=(47-t&t-58)>>>8&-256+t-48+52,e+=(64-t&t-91)>>>8&-256+t-65+0,e+=(96-t&t-123)>>>8&-256+t-97+26},t.prototype._getPaddingLength=function(t){var e=0;if(this._paddingCharacter){for(var n=t.length-1;n>=0&&t[n]===this._paddingCharacter;n--)e++;if(t.length<4||e>2)throw new Error("Base64Coder: incorrect padding")}return e},t}();e.Coder=s;var o=new s;e.encode=function(t){return o.encode(t)},e.decode=function(t){return o.decode(t)};var a=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return i(e,t),e.prototype._encodeByte=function(t){var e=t;return e+=65,e+=25-t>>>8&6,e+=51-t>>>8&-75,e+=61-t>>>8&-13,e+=62-t>>>8&49,String.fromCharCode(e)},e.prototype._decodeChar=function(t){var e=256;return e+=(44-t&t-46)>>>8&-256+t-45+62,e+=(94-t&t-96)>>>8&-256+t-95+63,e+=(47-t&t-58)>>>8&-256+t-48+52,e+=(64-t&t-91)>>>8&-256+t-65+0,e+=(96-t&t-123)>>>8&-256+t-97+26},e}(s);e.URLSafeCoder=a;var c=new a;e.encodeURLSafe=function(t){return c.encode(t)},e.decodeURLSafe=function(t){return c.decode(t)},e.encodedLength=function(t){return o.encodedLength(t)},e.maxDecodedLength=function(t){return o.maxDecodedLength(t)},e.decodedLength=function(t){return o.decodedLength(t)}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r="utf8: invalid source encoding";function i(t){for(var e=0,n=0;n=t.length-1)throw new Error("utf8: invalid string");n++,e+=4}}return e}e.encode=function(t){for(var e=new Uint8Array(i(t)),n=0,r=0;r>6,e[n++]=128|63&s):s<55296?(e[n++]=224|s>>12,e[n++]=128|s>>6&63,e[n++]=128|63&s):(r++,s=(1023&s)<<10,s|=1023&t.charCodeAt(r),s+=65536,e[n++]=240|s>>18,e[n++]=128|s>>12&63,e[n++]=128|s>>6&63,e[n++]=128|63&s)}return e},e.encodedLength=i,e.decode=function(t){for(var e=[],n=0;n=t.length)throw new Error(r);if(128!=(192&(o=t[++n])))throw new Error(r);i=(31&i)<<6|63&o,s=128}else if(i<240){if(n>=t.length-1)throw new Error(r);var o=t[++n],a=t[++n];if(128!=(192&o)||128!=(192&a))throw new Error(r);i=(15&i)<<12|(63&o)<<6|63&a,s=2048}else{if(!(i<248))throw new Error(r);if(n>=t.length-2)throw new Error(r);o=t[++n],a=t[++n];var c=t[++n];if(128!=(192&o)||128!=(192&a)||128!=(192&c))throw new Error(r);i=(15&i)<<18|(63&o)<<12|(63&a)<<6|63&c,s=65536}if(i=55296&&i<=57343)throw new Error(r);if(i>=65536){if(i>1114111)throw new Error(r);i-=65536,e.push(String.fromCharCode(55296|i>>10)),i=56320|1023&i}}e.push(String.fromCharCode(i))}return e.join("")}},function(t,e,n){!function(t){"use strict";var e=function(t){var e,n=new Float64Array(16);if(t)for(e=0;e>24&255,t[e+1]=n>>16&255,t[e+2]=n>>8&255,t[e+3]=255&n,t[e+4]=r>>24&255,t[e+5]=r>>16&255,t[e+6]=r>>8&255,t[e+7]=255&r}function g(t,e,n,r,i){var s,o=0;for(s=0;s>>8)-1}function v(t,e,n,r){return g(t,e,n,r,16)}function b(t,e,n,r){return g(t,e,n,r,32)}function y(t,e,n,r){!function(t,e,n,r){for(var i,s=255&r[0]|(255&r[1])<<8|(255&r[2])<<16|(255&r[3])<<24,o=255&n[0]|(255&n[1])<<8|(255&n[2])<<16|(255&n[3])<<24,a=255&n[4]|(255&n[5])<<8|(255&n[6])<<16|(255&n[7])<<24,c=255&n[8]|(255&n[9])<<8|(255&n[10])<<16|(255&n[11])<<24,h=255&n[12]|(255&n[13])<<8|(255&n[14])<<16|(255&n[15])<<24,u=255&r[4]|(255&r[5])<<8|(255&r[6])<<16|(255&r[7])<<24,l=255&e[0]|(255&e[1])<<8|(255&e[2])<<16|(255&e[3])<<24,d=255&e[4]|(255&e[5])<<8|(255&e[6])<<16|(255&e[7])<<24,p=255&e[8]|(255&e[9])<<8|(255&e[10])<<16|(255&e[11])<<24,f=255&e[12]|(255&e[13])<<8|(255&e[14])<<16|(255&e[15])<<24,g=255&r[8]|(255&r[9])<<8|(255&r[10])<<16|(255&r[11])<<24,v=255&n[16]|(255&n[17])<<8|(255&n[18])<<16|(255&n[19])<<24,b=255&n[20]|(255&n[21])<<8|(255&n[22])<<16|(255&n[23])<<24,y=255&n[24]|(255&n[25])<<8|(255&n[26])<<16|(255&n[27])<<24,m=255&n[28]|(255&n[29])<<8|(255&n[30])<<16|(255&n[31])<<24,w=255&r[12]|(255&r[13])<<8|(255&r[14])<<16|(255&r[15])<<24,_=s,S=o,k=a,C=c,T=h,E=u,P=l,x=d,A=p,O=f,L=g,R=v,U=b,M=y,I=m,D=w,N=0;N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14]=C>>>16&255,t[15]=C>>>24&255,t[16]=T>>>0&255,t[17]=T>>>8&255,t[18]=T>>>16&255,t[19]=T>>>24&255,t[20]=E>>>0&255,t[21]=E>>>8&255,t[22]=E>>>16&255,t[23]=E>>>24&255,t[24]=P>>>0&255,t[25]=P>>>8&255,t[26]=P>>>16&255,t[27]=P>>>24&255,t[28]=x>>>0&255,t[29]=x>>>8&255,t[30]=x>>>16&255,t[31]=x>>>24&255,t[32]=A>>>0&255,t[33]=A>>>8&255,t[34]=A>>>16&255,t[35]=A>>>24&255,t[36]=O>>>0&255,t[37]=O>>>8&255,t[38]=O>>>16&255,t[39]=O>>>24&255,t[40]=L>>>0&255,t[41]=L>>>8&255,t[42]=L>>>16&255,t[43]=L>>>24&255,t[44]=R>>>0&255,t[45]=R>>>8&255,t[46]=R>>>16&255,t[47]=R>>>24&255,t[48]=U>>>0&255,t[49]=U>>>8&255,t[50]=U>>>16&255,t[51]=U>>>24&255,t[52]=M>>>0&255,t[53]=M>>>8&255,t[54]=M>>>16&255,t[55]=M>>>24&255,t[56]=I>>>0&255,t[57]=I>>>8&255,t[58]=I>>>16&255,t[59]=I>>>24&255,t[60]=D>>>0&255,t[61]=D>>>8&255,t[62]=D>>>16&255,t[63]=D>>>24&255}(t,e,n,r)}function m(t,e,n,r){!function(t,e,n,r){for(var i,s=255&r[0]|(255&r[1])<<8|(255&r[2])<<16|(255&r[3])<<24,o=255&n[0]|(255&n[1])<<8|(255&n[2])<<16|(255&n[3])<<24,a=255&n[4]|(255&n[5])<<8|(255&n[6])<<16|(255&n[7])<<24,c=255&n[8]|(255&n[9])<<8|(255&n[10])<<16|(255&n[11])<<24,h=255&n[12]|(255&n[13])<<8|(255&n[14])<<16|(255&n[15])<<24,u=255&r[4]|(255&r[5])<<8|(255&r[6])<<16|(255&r[7])<<24,l=255&e[0]|(255&e[1])<<8|(255&e[2])<<16|(255&e[3])<<24,d=255&e[4]|(255&e[5])<<8|(255&e[6])<<16|(255&e[7])<<24,p=255&e[8]|(255&e[9])<<8|(255&e[10])<<16|(255&e[11])<<24,f=255&e[12]|(255&e[13])<<8|(255&e[14])<<16|(255&e[15])<<24,g=255&r[8]|(255&r[9])<<8|(255&r[10])<<16|(255&r[11])<<24,v=255&n[16]|(255&n[17])<<8|(255&n[18])<<16|(255&n[19])<<24,b=255&n[20]|(255&n[21])<<8|(255&n[22])<<16|(255&n[23])<<24,y=255&n[24]|(255&n[25])<<8|(255&n[26])<<16|(255&n[27])<<24,m=255&n[28]|(255&n[29])<<8|(255&n[30])<<16|(255&n[31])<<24,w=255&r[12]|(255&r[13])<<8|(255&r[14])<<16|(255&r[15])<<24,_=0;_<20;_+=2)s^=(i=(b^=(i=(p^=(i=(h^=(i=s+b|0)<<7|i>>>25)+s|0)<<9|i>>>23)+h|0)<<13|i>>>19)+p|0)<<18|i>>>14,u^=(i=(o^=(i=(y^=(i=(f^=(i=u+o|0)<<7|i>>>25)+u|0)<<9|i>>>23)+f|0)<<13|i>>>19)+y|0)<<18|i>>>14,g^=(i=(l^=(i=(a^=(i=(m^=(i=g+l|0)<<7|i>>>25)+g|0)<<9|i>>>23)+m|0)<<13|i>>>19)+a|0)<<18|i>>>14,w^=(i=(v^=(i=(d^=(i=(c^=(i=w+v|0)<<7|i>>>25)+w|0)<<9|i>>>23)+c|0)<<13|i>>>19)+d|0)<<18|i>>>14,s^=(i=(c^=(i=(a^=(i=(o^=(i=s+c|0)<<7|i>>>25)+s|0)<<9|i>>>23)+o|0)<<13|i>>>19)+a|0)<<18|i>>>14,u^=(i=(h^=(i=(d^=(i=(l^=(i=u+h|0)<<7|i>>>25)+u|0)<<9|i>>>23)+l|0)<<13|i>>>19)+d|0)<<18|i>>>14,g^=(i=(f^=(i=(p^=(i=(v^=(i=g+f|0)<<7|i>>>25)+g|0)<<9|i>>>23)+v|0)<<13|i>>>19)+p|0)<<18|i>>>14,w^=(i=(m^=(i=(y^=(i=(b^=(i=w+m|0)<<7|i>>>25)+w|0)<<9|i>>>23)+b|0)<<13|i>>>19)+y|0)<<18|i>>>14;t[0]=s>>>0&255,t[1]=s>>>8&255,t[2]=s>>>16&255,t[3]=s>>>24&255,t[4]=u>>>0&255,t[5]=u>>>8&255,t[6]=u>>>16&255,t[7]=u>>>24&255,t[8]=g>>>0&255,t[9]=g>>>8&255,t[10]=g>>>16&255,t[11]=g>>>24&255,t[12]=w>>>0&255,t[13]=w>>>8&255,t[14]=w>>>16&255,t[15]=w>>>24&255,t[16]=l>>>0&255,t[17]=l>>>8&255,t[18]=l>>>16&255,t[19]=l>>>24&255,t[20]=d>>>0&255,t[21]=d>>>8&255,t[22]=d>>>16&255,t[23]=d>>>24&255,t[24]=p>>>0&255,t[25]=p>>>8&255,t[26]=p>>>16&255,t[27]=p>>>24&255,t[28]=f>>>0&255,t[29]=f>>>8&255,t[30]=f>>>16&255,t[31]=f>>>24&255}(t,e,n,r)}var w=new Uint8Array([101,120,112,97,110,100,32,51,50,45,98,121,116,101,32,107]);function _(t,e,n,r,i,s,o){var a,c,h=new Uint8Array(16),u=new Uint8Array(64);for(c=0;c<16;c++)h[c]=0;for(c=0;c<8;c++)h[c]=s[c];for(;i>=64;){for(y(u,h,o,w),c=0;c<64;c++)t[e+c]=n[r+c]^u[c];for(a=1,c=8;c<16;c++)a=a+(255&h[c])|0,h[c]=255&a,a>>>=8;i-=64,e+=64,r+=64}if(i>0)for(y(u,h,o,w),c=0;c=64;){for(y(c,a,i,w),o=0;o<64;o++)t[e+o]=c[o];for(s=1,o=8;o<16;o++)s=s+(255&a[o])|0,a[o]=255&s,s>>>=8;n-=64,e+=64}if(n>0)for(y(c,a,i,w),o=0;o>>13|n<<3),r=255&t[4]|(255&t[5])<<8,this.r[2]=7939&(n>>>10|r<<6),i=255&t[6]|(255&t[7])<<8,this.r[3]=8191&(r>>>7|i<<9),s=255&t[8]|(255&t[9])<<8,this.r[4]=255&(i>>>4|s<<12),this.r[5]=s>>>1&8190,o=255&t[10]|(255&t[11])<<8,this.r[6]=8191&(s>>>14|o<<2),a=255&t[12]|(255&t[13])<<8,this.r[7]=8065&(o>>>11|a<<5),c=255&t[14]|(255&t[15])<<8,this.r[8]=8191&(a>>>8|c<<8),this.r[9]=c>>>5&127,this.pad[0]=255&t[16]|(255&t[17])<<8,this.pad[1]=255&t[18]|(255&t[19])<<8,this.pad[2]=255&t[20]|(255&t[21])<<8,this.pad[3]=255&t[22]|(255&t[23])<<8,this.pad[4]=255&t[24]|(255&t[25])<<8,this.pad[5]=255&t[26]|(255&t[27])<<8,this.pad[6]=255&t[28]|(255&t[29])<<8,this.pad[7]=255&t[30]|(255&t[31])<<8};function E(t,e,n,r,i,s){var o=new T(s);return o.update(n,r,i),o.finish(t,e),0}function P(t,e,n,r,i,s){var o=new Uint8Array(16);return E(o,0,n,r,i,s),v(t,e,o,0)}function x(t,e,n,r,i){var s;if(n<32)return-1;for(C(t,0,e,0,n,r,i),E(t,16,t,32,n-32,t),s=0;s<16;s++)t[s]=0;return 0}function A(t,e,n,r,i){var s,o=new Uint8Array(32);if(n<32)return-1;if(k(o,0,32,r,i),0!==P(e,16,e,32,n-32,o))return-1;for(C(t,0,e,0,n,r,i),s=0;s<32;s++)t[s]=0;return 0}function O(t,e){var n;for(n=0;n<16;n++)t[n]=0|e[n]}function L(t){var e,n,r=1;for(e=0;e<16;e++)n=t[e]+r+65535,r=Math.floor(n/65536),t[e]=n-65536*r;t[0]+=r-1+37*(r-1)}function R(t,e,n){for(var r,i=~(n-1),s=0;s<16;s++)r=i&(t[s]^e[s]),t[s]^=r,e[s]^=r}function U(t,n){var r,i,s,o=e(),a=e();for(r=0;r<16;r++)a[r]=n[r];for(L(a),L(a),L(a),i=0;i<2;i++){for(o[0]=a[0]-65517,r=1;r<15;r++)o[r]=a[r]-65535-(o[r-1]>>16&1),o[r-1]&=65535;o[15]=a[15]-32767-(o[14]>>16&1),s=o[15]>>16&1,o[14]&=65535,R(a,o,1-s)}for(r=0;r<16;r++)t[2*r]=255&a[r],t[2*r+1]=a[r]>>8}function M(t,e){var n=new Uint8Array(32),r=new Uint8Array(32);return U(n,t),U(r,e),b(n,0,r,0)}function I(t){var e=new Uint8Array(32);return U(e,t),1&e[0]}function D(t,e){var n;for(n=0;n<16;n++)t[n]=e[2*n]+(e[2*n+1]<<8);t[15]&=32767}function N(t,e,n){for(var r=0;r<16;r++)t[r]=e[r]+n[r]}function j(t,e,n){for(var r=0;r<16;r++)t[r]=e[r]-n[r]}function B(t,e,n){var r,i,s=0,o=0,a=0,c=0,h=0,u=0,l=0,d=0,p=0,f=0,g=0,v=0,b=0,y=0,m=0,w=0,_=0,S=0,k=0,C=0,T=0,E=0,P=0,x=0,A=0,O=0,L=0,R=0,U=0,M=0,I=0,D=n[0],N=n[1],j=n[2],B=n[3],z=n[4],H=n[5],q=n[6],F=n[7],X=n[8],J=n[9],Y=n[10],K=n[11],$=n[12],W=n[13],G=n[14],V=n[15];s+=(r=e[0])*D,o+=r*N,a+=r*j,c+=r*B,h+=r*z,u+=r*H,l+=r*q,d+=r*F,p+=r*X,f+=r*J,g+=r*Y,v+=r*K,b+=r*$,y+=r*W,m+=r*G,w+=r*V,o+=(r=e[1])*D,a+=r*N,c+=r*j,h+=r*B,u+=r*z,l+=r*H,d+=r*q,p+=r*F,f+=r*X,g+=r*J,v+=r*Y,b+=r*K,y+=r*$,m+=r*W,w+=r*G,_+=r*V,a+=(r=e[2])*D,c+=r*N,h+=r*j,u+=r*B,l+=r*z,d+=r*H,p+=r*q,f+=r*F,g+=r*X,v+=r*J,b+=r*Y,y+=r*K,m+=r*$,w+=r*W,_+=r*G,S+=r*V,c+=(r=e[3])*D,h+=r*N,u+=r*j,l+=r*B,d+=r*z,p+=r*H,f+=r*q,g+=r*F,v+=r*X,b+=r*J,y+=r*Y,m+=r*K,w+=r*$,_+=r*W,S+=r*G,k+=r*V,h+=(r=e[4])*D,u+=r*N,l+=r*j,d+=r*B,p+=r*z,f+=r*H,g+=r*q,v+=r*F,b+=r*X,y+=r*J,m+=r*Y,w+=r*K,_+=r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C+=r*q,T+=r*F,E+=r*X,P+=r*J,x+=r*Y,A+=r*K,O+=r*$,L+=r*W,R+=r*G,U+=r*V,m+=(r=e[14])*D,w+=r*N,_+=r*j,S+=r*B,k+=r*z,C+=r*H,T+=r*q,E+=r*F,P+=r*X,x+=r*J,A+=r*Y,O+=r*K,L+=r*$,R+=r*W,U+=r*G,M+=r*V,w+=(r=e[15])*D,o+=38*(S+=r*j),a+=38*(k+=r*B),c+=38*(C+=r*z),h+=38*(T+=r*H),u+=38*(E+=r*q),l+=38*(P+=r*F),d+=38*(x+=r*X),p+=38*(A+=r*J),f+=38*(O+=r*Y),g+=38*(L+=r*K),v+=38*(R+=r*$),b+=38*(U+=r*W),y+=38*(M+=r*G),m+=38*(I+=r*V),s=(r=(s+=38*(_+=r*N))+(i=1)+65535)-65536*(i=Math.floor(r/65536)),o=(r=o+i+65535)-65536*(i=Math.floor(r/65536)),a=(r=a+i+65535)-65536*(i=Math.floor(r/65536)),c=(r=c+i+65535)-65536*(i=Math.floor(r/65536)),h=(r=h+i+65535)-65536*(i=Math.floor(r/65536)),u=(r=u+i+65535)-65536*(i=Math.floor(r/65536)),l=(r=l+i+65535)-65536*(i=Math.floor(r/65536)),d=(r=d+i+65535)-65536*(i=Math.floor(r/65536)),p=(r=p+i+65535)-65536*(i=Math.floor(r/65536)),f=(r=f+i+65535)-65536*(i=Math.floor(r/65536)),g=(r=g+i+65535)-65536*(i=Math.floor(r/65536)),v=(r=v+i+65535)-65536*(i=Math.floor(r/65536)),b=(r=b+i+65535)-65536*(i=Math.floor(r/65536)),y=(r=y+i+65535)-65536*(i=Math.floor(r/65536)),m=(r=m+i+65535)-65536*(i=Math.floor(r/65536)),w=(r=w+i+65535)-65536*(i=Math.floor(r/65536)),s=(r=(s+=i-1+37*(i-1))+(i=1)+65535)-65536*(i=Math.floor(r/65536)),o=(r=o+i+65535)-65536*(i=Math.floor(r/65536)),a=(r=a+i+65535)-65536*(i=Math.floor(r/65536)),c=(r=c+i+65535)-65536*(i=Math.floor(r/65536)),h=(r=h+i+65535)-65536*(i=Math.floor(r/65536)),u=(r=u+i+65535)-65536*(i=Math.floor(r/65536)),l=(r=l+i+65535)-65536*(i=Math.floor(r/65536)),d=(r=d+i+65535)-65536*(i=Math.floor(r/65536)),p=(r=p+i+65535)-65536*(i=Math.floor(r/65536)),f=(r=f+i+65535)-65536*(i=Math.floor(r/65536)),g=(r=g+i+65535)-65536*(i=Math.floor(r/65536)),v=(r=v+i+65535)-65536*(i=Math.floor(r/65536)),b=(r=b+i+65535)-65536*(i=Math.floor(r/65536)),y=(r=y+i+65535)-65536*(i=Math.floor(r/65536)),m=(r=m+i+65535)-65536*(i=Math.floor(r/65536)),w=(r=w+i+65535)-65536*(i=Math.floor(r/65536)),s+=i-1+37*(i-1),t[0]=s,t[1]=o,t[2]=a,t[3]=c,t[4]=h,t[5]=u,t[6]=l,t[7]=d,t[8]=p,t[9]=f,t[10]=g,t[11]=v,t[12]=b,t[13]=y,t[14]=m,t[15]=w}function z(t,e){B(t,e,e)}function H(t,n){var r,i=e();for(r=0;r<16;r++)i[r]=n[r];for(r=253;r>=0;r--)z(i,i),2!==r&&4!==r&&B(i,i,n);for(r=0;r<16;r++)t[r]=i[r]}function q(t,n){var r,i=e();for(r=0;r<16;r++)i[r]=n[r];for(r=250;r>=0;r--)z(i,i),1!==r&&B(i,i,n);for(r=0;r<16;r++)t[r]=i[r]}function F(t,n,r){var i,s,o=new Uint8Array(32),a=new Float64Array(80),h=e(),u=e(),l=e(),d=e(),p=e(),f=e();for(s=0;s<31;s++)o[s]=n[s];for(o[31]=127&n[31]|64,o[0]&=248,D(a,r),s=0;s<16;s++)u[s]=a[s],d[s]=h[s]=l[s]=0;for(h[0]=d[0]=1,s=254;s>=0;--s)R(h,u,i=o[s>>>3]>>>(7&s)&1),R(l,d,i),N(p,h,l),j(h,h,l),N(l,u,d),j(u,u,d),z(d,p),z(f,h),B(h,l,h),B(l,u,p),N(p,h,l),j(h,h,l),z(u,h),j(l,d,f),B(h,l,c),N(h,h,d),B(l,l,h),B(h,d,f),B(d,u,a),z(u,p),R(h,u,i),R(l,d,i);for(s=0;s<16;s++)a[s+16]=h[s],a[s+32]=l[s],a[s+48]=u[s],a[s+64]=d[s];var g=a.subarray(32),v=a.subarray(16);return H(g,g),B(v,v,g),U(t,v),0}function X(t,e){return F(t,e,s)}function J(t,e){return r(e,32),X(t,e)}function Y(t,e,n){var r=new Uint8Array(32);return F(r,n,e),m(t,i,r,w)}T.prototype.blocks=function(t,e,n){for(var r,i,s,o,a,c,h,u,l,d,p,f,g,v,b,y,m,w,_,S=this.fin?0:2048,k=this.h[0],C=this.h[1],T=this.h[2],E=this.h[3],P=this.h[4],x=this.h[5],A=this.h[6],O=this.h[7],L=this.h[8],R=this.h[9],U=this.r[0],M=this.r[1],I=this.r[2],D=this.r[3],N=this.r[4],j=this.r[5],B=this.r[6],z=this.r[7],H=this.r[8],q=this.r[9];n>=16;)d=l=0,d+=(k+=8191&(r=255&t[e+0]|(255&t[e+1])<<8))*U,d+=(C+=8191&(r>>>13|(i=255&t[e+2]|(255&t[e+3])<<8)<<3))*(5*q),d+=(T+=8191&(i>>>10|(s=255&t[e+4]|(255&t[e+5])<<8)<<6))*(5*H),d+=(E+=8191&(s>>>7|(o=255&t[e+6]|(255&t[e+7])<<8)<<9))*(5*z),l=(d+=(P+=8191&(o>>>4|(a=255&t[e+8]|(255&t[e+9])<<8)<<12))*(5*B))>>>13,d&=8191,d+=(x+=a>>>1&8191)*(5*j),d+=(A+=8191&(a>>>14|(c=255&t[e+10]|(255&t[e+11])<<8)<<2))*(5*N),d+=(O+=8191&(c>>>11|(h=255&t[e+12]|(255&t[e+13])<<8)<<5))*(5*D),d+=(L+=8191&(h>>>8|(u=255&t[e+14]|(255&t[e+15])<<8)<<8))*(5*I),p=l+=(d+=(R+=u>>>5|S)*(5*M))>>>13,p+=k*M,p+=C*U,p+=T*(5*q),p+=E*(5*H),l=(p+=P*(5*z))>>>13,p&=8191,p+=x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=16;this.h[0]=k,this.h[1]=C,this.h[2]=T,this.h[3]=E,this.h[4]=P,this.h[5]=x,this.h[6]=A,this.h[7]=O,this.h[8]=L,this.h[9]=R},T.prototype.finish=function(t,e){var n,r,i,s,o=new Uint16Array(10);if(this.leftover){for(s=this.leftover,this.buffer[s++]=1;s<16;s++)this.buffer[s]=0;this.fin=1,this.blocks(this.buffer,0,16)}for(n=this.h[1]>>>13,this.h[1]&=8191,s=2;s<10;s++)this.h[s]+=n,n=this.h[s]>>>13,this.h[s]&=8191;for(this.h[0]+=5*n,n=this.h[0]>>>13,this.h[0]&=8191,this.h[1]+=n,n=this.h[1]>>>13,this.h[1]&=8191,this.h[2]+=n,o[0]=this.h[0]+5,n=o[0]>>>13,o[0]&=8191,s=1;s<10;s++)o[s]=this.h[s]+n,n=o[s]>>>13,o[s]&=8191;for(o[9]-=8192,r=(1^n)-1,s=0;s<10;s++)o[s]&=r;for(r=~r,s=0;s<10;s++)this.h[s]=this.h[s]&r|o[s];for(this.h[0]=65535&(this.h[0]|this.h[1]<<13),this.h[1]=65535&(this.h[1]>>>3|this.h[2]<<10),this.h[2]=65535&(this.h[2]>>>6|this.h[3]<<7),this.h[3]=65535&(this.h[3]>>>9|this.h[4]<<4),this.h[4]=65535&(this.h[4]>>>12|this.h[5]<<1|this.h[6]<<14),this.h[5]=65535&(this.h[6]>>>2|this.h[7]<<11),this.h[6]=65535&(this.h[7]>>>5|this.h[8]<<8),this.h[7]=65535&(this.h[8]>>>8|this.h[9]<<5),i=this.h[0]+this.pad[0],this.h[0]=65535&i,s=1;s<8;s++)i=(this.h[s]+this.pad[s]|0)+(i>>>16)|0,this.h[s]=65535&i;t[e+0]=this.h[0]>>>0&255,t[e+1]=this.h[0]>>>8&255,t[e+2]=this.h[1]>>>0&255,t[e+3]=this.h[1]>>>8&255,t[e+4]=this.h[2]>>>0&255,t[e+5]=this.h[2]>>>8&255,t[e+6]=this.h[3]>>>0&255,t[e+7]=this.h[3]>>>8&255,t[e+8]=this.h[4]>>>0&255,t[e+9]=this.h[4]>>>8&255,t[e+10]=this.h[5]>>>0&255,t[e+11]=this.h[5]>>>8&255,t[e+12]=this.h[6]>>>0&255,t[e+13]=this.h[6]>>>8&255,t[e+14]=this.h[7]>>>0&255,t[e+15]=this.h[7]>>>8&255},T.prototype.update=function(t,e,n){var r,i;if(this.leftover){for((i=16-this.leftover)>n&&(i=n),r=0;r=16&&(i=n-n%16,this.blocks(t,e,i),e+=i,n-=i),n){for(r=0;r=128;){for(S=0;S<16;S++)k=8*S+$,O[S]=n[k+0]<<24|n[k+1]<<16|n[k+2]<<8|n[k+3],L[S]=n[k+4]<<24|n[k+5]<<16|n[k+6]<<8|n[k+7];for(S=0;S<80;S++)if(i=R,s=U,o=M,a=I,c=D,h=N,u=j,B,d=z,p=H,f=q,g=F,v=X,b=J,y=Y,K,E=65535&(T=K),P=T>>>16,x=65535&(C=B),A=C>>>16,E+=65535&(T=(X>>>14|D<<18)^(X>>>18|D<<14)^(D>>>9|X<<23)),P+=T>>>16,x+=65535&(C=(D>>>14|X<<18)^(D>>>18|X<<14)^(X>>>9|D<<23)),A+=C>>>16,E+=65535&(T=X&J^~X&Y),P+=T>>>16,x+=65535&(C=D&N^~D&j),A+=C>>>16,E+=65535&(T=W[2*S+1]),P+=T>>>16,x+=65535&(C=W[2*S]),A+=C>>>16,C=O[S%16],P+=(T=L[S%16])>>>16,x+=65535&C,A+=C>>>16,x+=(P+=(E+=65535&T)>>>16)>>>16,E=65535&(T=_=65535&E|P<<16),P=T>>>16,x=65535&(C=w=65535&x|(A+=x>>>16)<<16),A=C>>>16,E+=65535&(T=(z>>>28|R<<4)^(R>>>2|z<<30)^(R>>>7|z<<25)),P+=T>>>16,x+=65535&(C=(R>>>28|z<<4)^(z>>>2|R<<30)^(z>>>7|R<<25)),A+=C>>>16,P+=(T=z&H^z&q^H&q)>>>16,x+=65535&(C=R&U^R&M^U&M),A+=C>>>16,l=65535&(x+=(P+=(E+=65535&T)>>>16)>>>16)|(A+=x>>>16)<<16,m=65535&E|P<<16,E=65535&(T=g),P=T>>>16,x=65535&(C=a),A=C>>>16,P+=(T=_)>>>16,x+=65535&(C=w),A+=C>>>16,U=i,M=s,I=o,D=a=65535&(x+=(P+=(E+=65535&T)>>>16)>>>16)|(A+=x>>>16)<<16,N=c,j=h,B=u,R=l,H=d,q=p,F=f,X=g=65535&E|P<<16,J=v,Y=b,K=y,z=m,S%16==15)for(k=0;k<16;k++)C=O[k],E=65535&(T=L[k]),P=T>>>16,x=65535&C,A=C>>>16,C=O[(k+9)%16],E+=65535&(T=L[(k+9)%16]),P+=T>>>16,x+=65535&C,A+=C>>>16,w=O[(k+1)%16],E+=65535&(T=((_=L[(k+1)%16])>>>1|w<<31)^(_>>>8|w<<24)^(_>>>7|w<<25)),P+=T>>>16,x+=65535&(C=(w>>>1|_<<31)^(w>>>8|_<<24)^w>>>7),A+=C>>>16,w=O[(k+14)%16],P+=(T=((_=L[(k+14)%16])>>>19|w<<13)^(w>>>29|_<<3)^(_>>>6|w<<26))>>>16,x+=65535&(C=(w>>>19|_<<13)^(_>>>29|w<<3)^w>>>6),A+=C>>>16,A+=(x+=(P+=(E+=65535&T)>>>16)>>>16)>>>16,O[k]=65535&x|A<<16,L[k]=65535&E|P<<16;E=65535&(T=z),P=T>>>16,x=65535&(C=R),A=C>>>16,C=t[0],P+=(T=e[0])>>>16,x+=65535&C,A+=C>>>16,A+=(x+=(P+=(E+=65535&T)>>>16)>>>16)>>>16,t[0]=R=65535&x|A<<16,e[0]=z=65535&E|P<<16,E=65535&(T=H),P=T>>>16,x=65535&(C=U),A=C>>>16,C=t[1],P+=(T=e[1])>>>16,x+=65535&C,A+=C>>>16,A+=(x+=(P+=(E+=65535&T)>>>16)>>>16)>>>16,t[1]=U=65535&x|A<<16,e[1]=H=65535&E|P<<16,E=65535&(T=q),P=T>>>16,x=65535&(C=M),A=C>>>16,C=t[2],P+=(T=e[2])>>>16,x+=65535&C,A+=C>>>16,A+=(x+=(P+=(E+=65535&T)>>>16)>>>16)>>>16,t[2]=M=65535&x|A<<16,e[2]=q=65535&E|P<<16,E=65535&(T=F),P=T>>>16,x=65535&(C=I),A=C>>>16,C=t[3],P+=(T=e[3])>>>16,x+=65535&C,A+=C>>>16,A+=(x+=(P+=(E+=65535&T)>>>16)>>>16)>>>16,t[3]=I=65535&x|A<<16,e[3]=F=65535&E|P<<16,E=65535&(T=X),P=T>>>16,x=65535&(C=D),A=C>>>16,C=t[4],P+=(T=e[4])>>>16,x+=65535&C,A+=C>>>16,A+=(x+=(P+=(E+=65535&T)>>>16)>>>16)>>>16,t[4]=D=65535&x|A<<16,e[4]=X=65535&E|P<<16,E=65535&(T=J),P=T>>>16,x=65535&(C=N),A=C>>>16,C=t[5],P+=(T=e[5])>>>16,x+=65535&C,A+=C>>>16,A+=(x+=(P+=(E+=65535&T)>>>16)>>>16)>>>16,t[5]=N=65535&x|A<<16,e[5]=J=65535&E|P<<16,E=65535&(T=Y),P=T>>>16,x=65535&(C=j),A=C>>>16,C=t[6],P+=(T=e[6])>>>16,x+=65535&C,A+=C>>>16,A+=(x+=(P+=(E+=65535&T)>>>16)>>>16)>>>16,t[6]=j=65535&x|A<<16,e[6]=Y=65535&E|P<<16,E=65535&(T=K),P=T>>>16,x=65535&(C=B),A=C>>>16,C=t[7],P+=(T=e[7])>>>16,x+=65535&C,A+=C>>>16,A+=(x+=(P+=(E+=65535&T)>>>16)>>>16)>>>16,t[7]=B=65535&x|A<<16,e[7]=K=65535&E|P<<16,$+=128,r-=128}return r}function V(t,e,n){var r,i=new Int32Array(8),s=new Int32Array(8),o=new Uint8Array(256),a=n;for(i[0]=1779033703,i[1]=3144134277,i[2]=1013904242,i[3]=2773480762,i[4]=1359893119,i[5]=2600822924,i[6]=528734635,i[7]=1541459225,s[0]=4089235720,s[1]=2227873595,s[2]=4271175723,s[3]=1595750129,s[4]=2917565137,s[5]=725511199,s[6]=4215389547,s[7]=327033209,G(i,s,e,n),n%=128,r=0;r=0;--i)Q(t,e,r=n[i/8|0]>>(7&i)&1),Z(e,t),Z(t,t),Q(t,e,r)}function nt(t,n){var r=[e(),e(),e(),e()];O(r[0],l),O(r[1],d),O(r[2],a),B(r[3],l,d),et(t,r,n)}function rt(t,n,i){var s,o=new Uint8Array(64),a=[e(),e(),e(),e()];for(i||r(n,32),V(o,n,32),o[0]&=248,o[31]&=127,o[31]|=64,nt(a,o),tt(t,a),s=0;s<32;s++)n[s+32]=t[s];return 0}var it=new Float64Array([237,211,245,92,26,99,18,88,214,156,247,162,222,249,222,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16]);function st(t,e){var n,r,i,s;for(r=63;r>=32;--r){for(n=0,i=r-32,s=r-12;i>4)*it[i],n=e[i]>>8,e[i]&=255;for(i=0;i<32;i++)e[i]-=n*it[i];for(r=0;r<32;r++)e[r+1]+=e[r]>>8,t[r]=255&e[r]}function ot(t){var e,n=new Float64Array(64);for(e=0;e<64;e++)n[e]=t[e];for(e=0;e<64;e++)t[e]=0;st(t,n)}function at(t,n,r,i){var s,o,a=new Uint8Array(64),c=new Uint8Array(64),h=new Uint8Array(64),u=new Float64Array(64),l=[e(),e(),e(),e()];V(a,i,32),a[0]&=248,a[31]&=127,a[31]|=64;var d=r+64;for(s=0;s>7&&j(t[0],o,t[0]),B(t[3],t[0],t[1]),0)}(d,i))return-1;for(s=0;s=0},t.sign.keyPair=function(){var t=new Uint8Array(32),e=new Uint8Array(64);return rt(t,e),{publicKey:t,secretKey:e}},t.sign.keyPair.fromSecretKey=function(t){if(ut(t),64!==t.length)throw new Error("bad secret key size");for(var e=new Uint8Array(32),n=0;n0)r.loading[t].push(n);else{r.loading[t]=[n];var i=ue.createScriptRequest(r.getPath(t,e)),s=r.receivers.create((function(e){if(r.receivers.remove(s),r.loading[t]){var n=r.loading[t];delete r.loading[t];for(var o=function(t){t||i.cleanup()},a=0;a>>6)+_(128|63&e):_(224|e>>>12&15)+_(128|e>>>6&63)+_(128|63&e)},P=function(t){return t.replace(/[^\x00-\x7F]/g,E)},x=function(t){var e=[0,2,1][t.length%3],n=t.charCodeAt(0)<<16|(t.length>1?t.charCodeAt(1):0)<<8|(t.length>2?t.charCodeAt(2):0);return[S.charAt(n>>>18),S.charAt(n>>>12&63),e>=2?"=":S.charAt(n>>>6&63),e>=1?"=":S.charAt(63&n)].join("")},A=window.btoa||function(t){return t.replace(/[\s\S]{1,3}/g,x)};var O=class{constructor(t,e,n,r){this.clear=e,this.timer=t(()=>{this.timer&&(this.timer=r(this.timer))},n)}isRunning(){return null!==this.timer}ensureAborted(){this.timer&&(this.clear(this.timer),this.timer=null)}};function L(t){window.clearTimeout(t)}function R(t){window.clearInterval(t)}class U extends O{constructor(t,e){super(setTimeout,L,t,(function(t){return e(),null}))}}class M extends O{constructor(t,e){super(setInterval,R,t,(function(t){return e(),t}))}}var I={now:()=>Date.now?Date.now():(new Date).valueOf(),defer:t=>new U(0,t),method(t,...e){var n=Array.prototype.slice.call(arguments,1);return function(e){return e[t].apply(e,n.concat(arguments))}}};function D(t,...e){for(var n=0;n{window.console&&window.console.log&&window.console.log(t)}}debug(...t){this.log(this.globalLog,t)}warn(...t){this.log(this.globalLogWarn,t)}error(...t){this.log(this.globalLogError,t)}globalLogWarn(t){window.console&&window.console.warn?window.console.warn(t):this.globalLog(t)}globalLogError(t){window.console&&window.console.error?window.console.error(t):this.globalLogWarn(t)}log(t,...e){var n=N.apply(this,arguments);if(Le.log)Le.log(n);else if(Le.logToConsole){t.bind(this)(n)}}},G=function(t,e,n,r,i){void 0===n.headers&&null==n.headersProvider||W.warn(`To send headers with the ${r.toString()} request, you must use AJAX, rather than JSONP.`);var s=t.nextAuthCallbackID.toString();t.nextAuthCallbackID++;var o=t.getDocument(),a=o.createElement("script");t.auth_callbacks[s]=function(t){i(null,t)};var c="Pusher.auth_callbacks['"+s+"']";a.src=n.endpoint+"?callback="+encodeURIComponent(c)+"&"+e;var h=o.getElementsByTagName("head")[0]||o.documentElement;h.insertBefore(a,h.firstChild)};class V{constructor(t){this.src=t}send(t){var e=this,n="Error loading "+e.src;e.script=document.createElement("script"),e.script.id=t.id,e.script.src=e.src,e.script.type="text/javascript",e.script.charset="UTF-8",e.script.addEventListener?(e.script.onerror=function(){t.callback(n)},e.script.onload=function(){t.callback(null)}):e.script.onreadystatechange=function(){"loaded"!==e.script.readyState&&"complete"!==e.script.readyState||t.callback(null)},void 0===e.script.async&&document.attachEvent&&/opera/i.test(navigator.userAgent)?(e.errorScript=document.createElement("script"),e.errorScript.id=t.id+"_error",e.errorScript.text=t.name+"('"+n+"');",e.script.async=e.errorScript.async=!1):e.script.async=!0;var r=document.getElementsByTagName("head")[0];r.insertBefore(e.script,r.firstChild),e.errorScript&&r.insertBefore(e.errorScript,e.script.nextSibling)}cleanup(){this.script&&(this.script.onload=this.script.onerror=null,this.script.onreadystatechange=null),this.script&&this.script.parentNode&&this.script.parentNode.removeChild(this.script),this.errorScript&&this.errorScript.parentNode&&this.errorScript.parentNode.removeChild(this.errorScript),this.script=null,this.errorScript=null}}class Z{constructor(t,e){this.url=t,this.data=e}send(t){if(!this.request){var e=K(this.data),n=this.url+"/"+t.number+"?"+e;this.request=ue.createScriptRequest(n),this.request.send(t)}}cleanup(){this.request&&this.request.cleanup()}}var Q={name:"jsonp",getAgent:function(t,e){return function(n,r){var s="http"+(e?"s":"")+"://"+(t.host||t.options.host)+t.options.path,o=ue.createJSONPRequest(s,n),a=ue.ScriptReceivers.create((function(e,n){i.remove(a),o.cleanup(),n&&n.host&&(t.host=n.host),r&&r(e,n)}));o.send(a)}}};function tt(t,e,n){return t+(e.useTLS?"s":"")+"://"+(e.useTLS?e.hostTLS:e.hostNonTLS)+n}function et(t,e){return"/app/"+t+("?protocol="+s.PROTOCOL+"&client=js&version="+s.VERSION+(e?"&"+e:""))}var nt={getInitial:function(t,e){return tt("ws",e,(e.httpPath||"")+et(t,"flash=false"))}},rt={getInitial:function(t,e){return tt("http",e,(e.httpPath||"/pusher")+et(t))}},it={getInitial:function(t,e){return tt("http",e,e.httpPath||"/pusher")},getPath:function(t,e){return et(t)}};class st{constructor(){this._callbacks={}}get(t){return this._callbacks[ot(t)]}add(t,e,n){var r=ot(t);this._callbacks[r]=this._callbacks[r]||[],this._callbacks[r].push({fn:e,context:n})}remove(t,e,n){if(t||e||n){var r=t?[ot(t)]:z(this._callbacks);e||n?this.removeCallback(r,e,n):this.removeAllCallbacks(r)}else this._callbacks={}}removeCallback(t,e,n){H(t,(function(t){this._callbacks[t]=F(this._callbacks[t]||[],(function(t){return e&&e!==t.fn||n&&n!==t.context})),0===this._callbacks[t].length&&delete this._callbacks[t]}),this)}removeAllCallbacks(t){H(t,(function(t){delete this._callbacks[t]}),this)}}function ot(t){return"_"+t}class at{constructor(t){this.callbacks=new st,this.global_callbacks=[],this.failThrough=t}bind(t,e,n){return this.callbacks.add(t,e,n),this}bind_global(t){return this.global_callbacks.push(t),this}unbind(t,e,n){return this.callbacks.remove(t,e,n),this}unbind_global(t){return t?(this.global_callbacks=F(this.global_callbacks||[],e=>e!==t),this):(this.global_callbacks=[],this)}unbind_all(){return this.unbind(),this.unbind_global(),this}emit(t,e,n){for(var r=0;r0)for(r=0;r{this.onError(t),this.changeState("closed")}),!1}return this.bindListeners(),W.debug("Connecting",{transport:this.name,url:t}),this.changeState("connecting"),!0}close(){return!!this.socket&&(this.socket.close(),!0)}send(t){return"open"===this.state&&(I.defer(()=>{this.socket&&this.socket.send(t)}),!0)}ping(){"open"===this.state&&this.supportsPing()&&this.socket.ping()}onOpen(){this.hooks.beforeOpen&&this.hooks.beforeOpen(this.socket,this.hooks.urls.getPath(this.key,this.options)),this.changeState("open"),this.socket.onopen=void 0}onError(t){this.emit("error",{type:"WebSocketError",error:t}),this.timeline.error(this.buildTimelineMessage({error:t.toString()}))}onClose(t){t?this.changeState("closed",{code:t.code,reason:t.reason,wasClean:t.wasClean}):this.changeState("closed"),this.unbindListeners(),this.socket=void 0}onMessage(t){this.emit("message",t)}onActivity(){this.emit("activity")}bindListeners(){this.socket.onopen=()=>{this.onOpen()},this.socket.onerror=t=>{this.onError(t)},this.socket.onclose=t=>{this.onClose(t)},this.socket.onmessage=t=>{this.onMessage(t)},this.supportsPing()&&(this.socket.onactivity=()=>{this.onActivity()})}unbindListeners(){this.socket&&(this.socket.onopen=void 0,this.socket.onerror=void 0,this.socket.onclose=void 0,this.socket.onmessage=void 0,this.supportsPing()&&(this.socket.onactivity=void 0))}changeState(t,e){this.state=t,this.timeline.info(this.buildTimelineMessage({state:t,params:e})),this.emit(t,e)}buildTimelineMessage(t){return D({cid:this.id},t)}}class ht{constructor(t){this.hooks=t}isSupported(t){return this.hooks.isSupported(t)}createConnection(t,e,n,r){return new ct(this.hooks,t,e,n,r)}}var ut=new ht({urls:nt,handlesActivityChecks:!1,supportsPing:!1,isInitialized:function(){return Boolean(ue.getWebSocketAPI())},isSupported:function(){return Boolean(ue.getWebSocketAPI())},getSocket:function(t){return ue.createWebSocket(t)}}),lt={urls:rt,handlesActivityChecks:!1,supportsPing:!0,isInitialized:function(){return!0}},dt=D({getSocket:function(t){return ue.HTTPFactory.createStreamingSocket(t)}},lt),pt=D({getSocket:function(t){return ue.HTTPFactory.createPollingSocket(t)}},lt),ft={isSupported:function(){return ue.isXHRSupported()}},gt={ws:ut,xhr_streaming:new ht(D({},dt,ft)),xhr_polling:new ht(D({},pt,ft))},vt=new ht({file:"sockjs",urls:it,handlesActivityChecks:!0,supportsPing:!1,isSupported:function(){return!0},isInitialized:function(){return void 0!==window.SockJS},getSocket:function(t,e){return new window.SockJS(t,null,{js_path:a.getPath("sockjs",{useTLS:e.useTLS}),ignore_null_origin:e.ignoreNullOrigin})},beforeOpen:function(t,e){t.send(JSON.stringify({path:e}))}}),bt={isSupported:function(t){return ue.isXDRSupported(t.useTLS)}},yt=new ht(D({},dt,bt)),mt=new ht(D({},pt,bt));gt.xdr_streaming=yt,gt.xdr_polling=mt,gt.sockjs=vt;var wt=gt;var _t=new class extends at{constructor(){super();var t=this;void 0!==window.addEventListener&&(window.addEventListener("online",(function(){t.emit("online")}),!1),window.addEventListener("offline",(function(){t.emit("offline")}),!1))}isOnline(){return void 0===window.navigator.onLine||window.navigator.onLine}};class St{constructor(t,e,n){this.manager=t,this.transport=e,this.minPingDelay=n.minPingDelay,this.maxPingDelay=n.maxPingDelay,this.pingDelay=void 0}createConnection(t,e,n,r){r=D({},r,{activityTimeout:this.pingDelay});var i=this.transport.createConnection(t,e,n,r),s=null,o=function(){i.unbind("open",o),i.bind("closed",a),s=I.now()},a=t=>{if(i.unbind("closed",a),1002===t.code||1003===t.code)this.manager.reportDeath();else if(!t.wasClean&&s){var e=I.now()-s;e<2*this.maxPingDelay&&(this.manager.reportDeath(),this.pingDelay=Math.max(e/2,this.minPingDelay))}};return i.bind("open",o),i}isSupported(t){return this.manager.isAlive()&&this.transport.isSupported(t)}}const kt={decodeMessage:function(t){try{var e=JSON.parse(t.data),n=e.data;if("string"==typeof n)try{n=JSON.parse(e.data)}catch(t){}var r={event:e.event,channel:e.channel,data:n};return e.user_id&&(r.user_id=e.user_id),r}catch(e){throw{type:"MessageParseError",error:e,data:t.data}}},encodeMessage:function(t){return JSON.stringify(t)},processHandshake:function(t){var e=kt.decodeMessage(t);if("pusher:connection_established"===e.event){if(!e.data.activity_timeout)throw"No activity timeout specified in handshake";return{action:"connected",id:e.data.socket_id,activityTimeout:1e3*e.data.activity_timeout}}if("pusher:error"===e.event)return{action:this.getCloseAction(e.data),error:this.getCloseError(e.data)};throw"Invalid handshake"},getCloseAction:function(t){return t.code<4e3?t.code>=1002&&t.code<=1004?"backoff":null:4e3===t.code?"tls_only":t.code<4100?"refused":t.code<4200?"backoff":t.code<4300?"retry":"refused"},getCloseError:function(t){return 1e3!==t.code&&1001!==t.code?{type:"PusherError",data:{code:t.code,message:t.reason||t.message}}:null}};var Ct=kt;class Tt extends at{constructor(t,e){super(),this.id=t,this.transport=e,this.activityTimeout=e.activityTimeout,this.bindListeners()}handlesActivityChecks(){return this.transport.handlesActivityChecks()}send(t){return this.transport.send(t)}send_event(t,e,n){var r={event:t,data:e};return n&&(r.channel=n),W.debug("Event sent",r),this.send(Ct.encodeMessage(r))}ping(){this.transport.supportsPing()?this.transport.ping():this.send_event("pusher:ping",{})}close(){this.transport.close()}bindListeners(){var t={message:t=>{var e;try{e=Ct.decodeMessage(t)}catch(e){this.emit("error",{type:"MessageParseError",error:e,data:t.data})}if(void 0!==e){switch(W.debug("Event recd",e),e.event){case"pusher:error":this.emit("error",{type:"PusherError",data:e.data});break;case"pusher:ping":this.emit("ping");break;case"pusher:pong":this.emit("pong")}this.emit("message",e)}},activity:()=>{this.emit("activity")},error:t=>{this.emit("error",t)},closed:t=>{e(),t&&t.code&&this.handleCloseEvent(t),this.transport=null,this.emit("closed")}},e=()=>{B(t,(t,e)=>{this.transport.unbind(e,t)})};B(t,(t,e)=>{this.transport.bind(e,t)})}handleCloseEvent(t){var e=Ct.getCloseAction(t),n=Ct.getCloseError(t);n&&this.emit("error",n),e&&this.emit(e,{action:e,error:n})}}class Et{constructor(t,e){this.transport=t,this.callback=e,this.bindListeners()}close(){this.unbindListeners(),this.transport.close()}bindListeners(){this.onMessage=t=>{var e;this.unbindListeners();try{e=Ct.processHandshake(t)}catch(t){return this.finish("error",{error:t}),void this.transport.close()}"connected"===e.action?this.finish("connected",{connection:new Tt(e.id,this.transport),activityTimeout:e.activityTimeout}):(this.finish(e.action,{error:e.error}),this.transport.close())},this.onClosed=t=>{this.unbindListeners();var e=Ct.getCloseAction(t)||"backoff",n=Ct.getCloseError(t);this.finish(e,{error:n})},this.transport.bind("message",this.onMessage),this.transport.bind("closed",this.onClosed)}unbindListeners(){this.transport.unbind("message",this.onMessage),this.transport.unbind("closed",this.onClosed)}finish(t,e){this.callback(D({transport:this.transport,action:t},e))}}class Pt{constructor(t,e){this.timeline=t,this.options=e||{}}send(t,e){this.timeline.isEmpty()||this.timeline.send(ue.TimelineTransport.getAgent(this,t),e)}}class xt extends at{constructor(t,e){super((function(e,n){W.debug("No callbacks on "+t+" for "+e)})),this.name=t,this.pusher=e,this.subscribed=!1,this.subscriptionPending=!1,this.subscriptionCancelled=!1}authorize(t,e){return e(null,{auth:""})}trigger(t,e){if(0!==t.indexOf("client-"))throw new l("Event '"+t+"' does not start with 'client-'");if(!this.subscribed){var n=u("triggeringClientEvents");W.warn("Client event triggered before channel 'subscription_succeeded' event . "+n)}return this.pusher.send_event(t,e,this.name)}disconnect(){this.subscribed=!1,this.subscriptionPending=!1}handleEvent(t){var e=t.event,n=t.data;if("pusher_internal:subscription_succeeded"===e)this.handleSubscriptionSucceededEvent(t);else if("pusher_internal:subscription_count"===e)this.handleSubscriptionCountEvent(t);else if(0!==e.indexOf("pusher_internal:")){this.emit(e,n,{})}}handleSubscriptionSucceededEvent(t){this.subscriptionPending=!1,this.subscribed=!0,this.subscriptionCancelled?this.pusher.unsubscribe(this.name):this.emit("pusher:subscription_succeeded",t.data)}handleSubscriptionCountEvent(t){t.data.subscription_count&&(this.subscriptionCount=t.data.subscription_count),this.emit("pusher:subscription_count",t.data)}subscribe(){this.subscribed||(this.subscriptionPending=!0,this.subscriptionCancelled=!1,this.authorize(this.pusher.connection.socket_id,(t,e)=>{t?(this.subscriptionPending=!1,W.error(t.toString()),this.emit("pusher:subscription_error",Object.assign({},{type:"AuthError",error:t.message},t instanceof m?{status:t.status}:{}))):this.pusher.send_event("pusher:subscribe",{auth:e.auth,channel_data:e.channel_data,channel:this.name})}))}unsubscribe(){this.subscribed=!1,this.pusher.send_event("pusher:unsubscribe",{channel:this.name})}cancelSubscription(){this.subscriptionCancelled=!0}reinstateSubscription(){this.subscriptionCancelled=!1}}class At extends xt{authorize(t,e){return this.pusher.config.channelAuthorizer({channelName:this.name,socketId:t},e)}}class Ot{constructor(){this.reset()}get(t){return Object.prototype.hasOwnProperty.call(this.members,t)?{id:t,info:this.members[t]}:null}each(t){B(this.members,(e,n)=>{t(this.get(n))})}setMyID(t){this.myID=t}onSubscription(t){this.members=t.presence.hash,this.count=t.presence.count,this.me=this.get(this.myID)}addMember(t){return null===this.get(t.user_id)&&this.count++,this.members[t.user_id]=t.user_info,this.get(t.user_id)}removeMember(t){var e=this.get(t.user_id);return e&&(delete this.members[t.user_id],this.count--),e}reset(){this.members={},this.count=0,this.myID=null,this.me=null}}var Lt=function(t,e,n,r){return new(n||(n=Promise))((function(i,s){function o(t){try{c(r.next(t))}catch(t){s(t)}}function a(t){try{c(r.throw(t))}catch(t){s(t)}}function c(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(o,a)}c((r=r.apply(t,e||[])).next())}))};class Rt extends At{constructor(t,e){super(t,e),this.members=new Ot}authorize(t,e){super.authorize(t,(t,n)=>Lt(this,void 0,void 0,(function*(){if(!t)if(null!=(n=n).channel_data){var r=JSON.parse(n.channel_data);this.members.setMyID(r.user_id)}else{if(yield this.pusher.user.signinDonePromise,null==this.pusher.user.user_data){let t=u("authorizationEndpoint");return W.error(`Invalid auth response for channel '${this.name}', expected 'channel_data' field. ${t}, or the user should be signed in.`),void e("Invalid auth response")}this.members.setMyID(this.pusher.user.user_data.id)}e(t,n)})))}handleEvent(t){var e=t.event;if(0===e.indexOf("pusher_internal:"))this.handleInternalEvent(t);else{var n=t.data,r={};t.user_id&&(r.user_id=t.user_id),this.emit(e,n,r)}}handleInternalEvent(t){var e=t.event,n=t.data;switch(e){case"pusher_internal:subscription_succeeded":this.handleSubscriptionSucceededEvent(t);break;case"pusher_internal:subscription_count":this.handleSubscriptionCountEvent(t);break;case"pusher_internal:member_added":var r=this.members.addMember(n);this.emit("pusher:member_added",r);break;case"pusher_internal:member_removed":var i=this.members.removeMember(n);i&&this.emit("pusher:member_removed",i)}}handleSubscriptionSucceededEvent(t){this.subscriptionPending=!1,this.subscribed=!0,this.subscriptionCancelled?this.pusher.unsubscribe(this.name):(this.members.onSubscription(t.data),this.emit("pusher:subscription_succeeded",this.members))}disconnect(){this.members.reset(),super.disconnect()}}var Ut=n(1),Mt=n(0);class It extends At{constructor(t,e,n){super(t,e),this.key=null,this.nacl=n}authorize(t,e){super.authorize(t,(t,n)=>{if(t)return void e(t,n);let r=n.shared_secret;r?(this.key=Object(Mt.decode)(r),delete n.shared_secret,e(null,n)):e(new Error("No shared_secret key in auth payload for encrypted channel: "+this.name),null)})}trigger(t,e){throw new v("Client events are not currently supported for encrypted channels")}handleEvent(t){var e=t.event,n=t.data;0!==e.indexOf("pusher_internal:")&&0!==e.indexOf("pusher:")?this.handleEncryptedEvent(e,n):super.handleEvent(t)}handleEncryptedEvent(t,e){if(!this.key)return void W.debug("Received encrypted event before key has been retrieved from the authEndpoint");if(!e.ciphertext||!e.nonce)return void W.error("Unexpected format for encrypted event, expected object with `ciphertext` and `nonce` fields, got: "+e);let n=Object(Mt.decode)(e.ciphertext);if(n.length{e?W.error(`Failed to make a request to the authEndpoint: ${s}. Unable to fetch new key, so dropping encrypted event`):(i=this.nacl.secretbox.open(n,r,this.key),null!==i?this.emit(t,this.getDataToEmit(i)):W.error("Failed to decrypt event with new key. Dropping encrypted event"))});this.emit(t,this.getDataToEmit(i))}getDataToEmit(t){let e=Object(Ut.decode)(t);try{return JSON.parse(e)}catch(t){return e}}}class Dt extends at{constructor(t,e){super(),this.state="initialized",this.connection=null,this.key=t,this.options=e,this.timeline=this.options.timeline,this.usingTLS=this.options.useTLS,this.errorCallbacks=this.buildErrorCallbacks(),this.connectionCallbacks=this.buildConnectionCallbacks(this.errorCallbacks),this.handshakeCallbacks=this.buildHandshakeCallbacks(this.errorCallbacks);var n=ue.getNetwork();n.bind("online",()=>{this.timeline.info({netinfo:"online"}),"connecting"!==this.state&&"unavailable"!==this.state||this.retryIn(0)}),n.bind("offline",()=>{this.timeline.info({netinfo:"offline"}),this.connection&&this.sendActivityCheck()}),this.updateStrategy()}connect(){this.connection||this.runner||(this.strategy.isSupported()?(this.updateState("connecting"),this.startConnecting(),this.setUnavailableTimer()):this.updateState("failed"))}send(t){return!!this.connection&&this.connection.send(t)}send_event(t,e,n){return!!this.connection&&this.connection.send_event(t,e,n)}disconnect(){this.disconnectInternally(),this.updateState("disconnected")}isUsingTLS(){return this.usingTLS}startConnecting(){var t=(e,n)=>{e?this.runner=this.strategy.connect(0,t):"error"===n.action?(this.emit("error",{type:"HandshakeError",error:n.error}),this.timeline.error({handshakeError:n.error})):(this.abortConnecting(),this.handshakeCallbacks[n.action](n))};this.runner=this.strategy.connect(0,t)}abortConnecting(){this.runner&&(this.runner.abort(),this.runner=null)}disconnectInternally(){(this.abortConnecting(),this.clearRetryTimer(),this.clearUnavailableTimer(),this.connection)&&this.abandonConnection().close()}updateStrategy(){this.strategy=this.options.getStrategy({key:this.key,timeline:this.timeline,useTLS:this.usingTLS})}retryIn(t){this.timeline.info({action:"retry",delay:t}),t>0&&this.emit("connecting_in",Math.round(t/1e3)),this.retryTimer=new U(t||0,()=>{this.disconnectInternally(),this.connect()})}clearRetryTimer(){this.retryTimer&&(this.retryTimer.ensureAborted(),this.retryTimer=null)}setUnavailableTimer(){this.unavailableTimer=new U(this.options.unavailableTimeout,()=>{this.updateState("unavailable")})}clearUnavailableTimer(){this.unavailableTimer&&this.unavailableTimer.ensureAborted()}sendActivityCheck(){this.stopActivityCheck(),this.connection.ping(),this.activityTimer=new U(this.options.pongTimeout,()=>{this.timeline.error({pong_timed_out:this.options.pongTimeout}),this.retryIn(0)})}resetActivityCheck(){this.stopActivityCheck(),this.connection&&!this.connection.handlesActivityChecks()&&(this.activityTimer=new U(this.activityTimeout,()=>{this.sendActivityCheck()}))}stopActivityCheck(){this.activityTimer&&this.activityTimer.ensureAborted()}buildConnectionCallbacks(t){return D({},t,{message:t=>{this.resetActivityCheck(),this.emit("message",t)},ping:()=>{this.send_event("pusher:pong",{})},activity:()=>{this.resetActivityCheck()},error:t=>{this.emit("error",t)},closed:()=>{this.abandonConnection(),this.shouldRetry()&&this.retryIn(1e3)}})}buildHandshakeCallbacks(t){return D({},t,{connected:t=>{this.activityTimeout=Math.min(this.options.activityTimeout,t.activityTimeout,t.connection.activityTimeout||1/0),this.clearUnavailableTimer(),this.setConnection(t.connection),this.socket_id=this.connection.id,this.updateState("connected",{socket_id:this.socket_id})}})}buildErrorCallbacks(){let t=t=>e=>{e.error&&this.emit("error",{type:"WebSocketError",error:e.error}),t(e)};return{tls_only:t(()=>{this.usingTLS=!0,this.updateStrategy(),this.retryIn(0)}),refused:t(()=>{this.disconnect()}),backoff:t(()=>{this.retryIn(1e3)}),retry:t(()=>{this.retryIn(0)})}}setConnection(t){for(var e in this.connection=t,this.connectionCallbacks)this.connection.bind(e,this.connectionCallbacks[e]);this.resetActivityCheck()}abandonConnection(){if(this.connection){for(var t in this.stopActivityCheck(),this.connectionCallbacks)this.connection.unbind(t,this.connectionCallbacks[t]);var e=this.connection;return this.connection=null,e}}updateState(t,e){var n=this.state;if(this.state=t,n!==t){var r=t;"connected"===r&&(r+=" with new socket ID "+e.socket_id),W.debug("State changed",n+" -> "+r),this.timeline.info({state:t,params:e}),this.emit("state_change",{previous:n,current:t}),this.emit(t,e)}}shouldRetry(){return"connecting"===this.state||"connected"===this.state}}class Nt{constructor(){this.channels={}}add(t,e){return this.channels[t]||(this.channels[t]=function(t,e){if(0===t.indexOf("private-encrypted-")){if(e.config.nacl)return jt.createEncryptedChannel(t,e,e.config.nacl);let n="Tried to subscribe to a private-encrypted- channel but no nacl implementation available",r=u("encryptedChannelSupport");throw new v(`${n}. ${r}`)}if(0===t.indexOf("private-"))return jt.createPrivateChannel(t,e);if(0===t.indexOf("presence-"))return jt.createPresenceChannel(t,e);if(0===t.indexOf("#"))throw new d('Cannot create a channel with name "'+t+'".');return jt.createChannel(t,e)}(t,e)),this.channels[t]}all(){return function(t){var e=[];return B(t,(function(t){e.push(t)})),e}(this.channels)}find(t){return this.channels[t]}remove(t){var e=this.channels[t];return delete this.channels[t],e}disconnect(){B(this.channels,(function(t){t.disconnect()}))}}var jt={createChannels:()=>new Nt,createConnectionManager:(t,e)=>new Dt(t,e),createChannel:(t,e)=>new xt(t,e),createPrivateChannel:(t,e)=>new At(t,e),createPresenceChannel:(t,e)=>new Rt(t,e),createEncryptedChannel:(t,e,n)=>new It(t,e,n),createTimelineSender:(t,e)=>new Pt(t,e),createHandshake:(t,e)=>new Et(t,e),createAssistantToTheTransportManager:(t,e,n)=>new St(t,e,n)};class Bt{constructor(t){this.options=t||{},this.livesLeft=this.options.lives||1/0}getAssistant(t){return jt.createAssistantToTheTransportManager(this,t,{minPingDelay:this.options.minPingDelay,maxPingDelay:this.options.maxPingDelay})}isAlive(){return this.livesLeft>0}reportDeath(){this.livesLeft-=1}}class zt{constructor(t,e){this.strategies=t,this.loop=Boolean(e.loop),this.failFast=Boolean(e.failFast),this.timeout=e.timeout,this.timeoutLimit=e.timeoutLimit}isSupported(){return J(this.strategies,I.method("isSupported"))}connect(t,e){var n=this.strategies,r=0,i=this.timeout,s=null,o=(a,c)=>{c?e(null,c):(r+=1,this.loop&&(r%=n.length),r0&&(i=new U(n.timeout,(function(){s.abort(),r(!0)}))),s=t.connect(e,(function(t,e){t&&i&&i.isRunning()&&!n.failFast||(i&&i.ensureAborted(),r(t,e))})),{abort:function(){i&&i.ensureAborted(),s.abort()},forceMinPriority:function(t){s.forceMinPriority(t)}}}}class Ht{constructor(t){this.strategies=t}isSupported(){return J(this.strategies,I.method("isSupported"))}connect(t,e){return function(t,e,n){var r=q(t,(function(t,r,i,s){return t.connect(e,n(r,s))}));return{abort:function(){H(r,qt)},forceMinPriority:function(t){H(r,(function(e){e.forceMinPriority(t)}))}}}(this.strategies,t,(function(t,n){return function(r,i){n[t].error=r,r?function(t){return function(t,e){for(var n=0;n=I.now()){var o=this.transports[r.transport];o&&(["ws","wss"].includes(r.transport)||i>3?(this.timeline.info({cached:!0,transport:r.transport,latency:r.latency}),s.push(new zt([o],{timeout:2*r.latency+1e3,failFast:!0}))):i++)}var a=I.now(),c=s.pop().connect(t,(function r(o,h){o?(Jt(n),s.length>0?(a=I.now(),c=s.pop().connect(t,r)):e(o)):(!function(t,e,n,r){var i=ue.getLocalStorage();if(i)try{i[Xt(t)]=$({timestamp:I.now(),transport:e,latency:n,cacheSkipCount:r})}catch(t){}}(n,h.transport.name,I.now()-a,i),e(null,h))}));return{abort:function(){c.abort()},forceMinPriority:function(e){t=e,c&&c.forceMinPriority(e)}}}}function Xt(t){return"pusherTransport"+(t?"TLS":"NonTLS")}function Jt(t){var e=ue.getLocalStorage();if(e)try{delete e[Xt(t)]}catch(t){}}class Yt{constructor(t,{delay:e}){this.strategy=t,this.options={delay:e}}isSupported(){return this.strategy.isSupported()}connect(t,e){var n,r=this.strategy,i=new U(this.options.delay,(function(){n=r.connect(t,e)}));return{abort:function(){i.ensureAborted(),n&&n.abort()},forceMinPriority:function(e){t=e,n&&n.forceMinPriority(e)}}}}class Kt{constructor(t,e,n){this.test=t,this.trueBranch=e,this.falseBranch=n}isSupported(){return(this.test()?this.trueBranch:this.falseBranch).isSupported()}connect(t,e){return(this.test()?this.trueBranch:this.falseBranch).connect(t,e)}}class $t{constructor(t){this.strategy=t}isSupported(){return this.strategy.isSupported()}connect(t,e){var n=this.strategy.connect(t,(function(t,r){r&&n.abort(),e(t,r)}));return n}}function Wt(t){return function(){return t.isSupported()}}var Gt=function(t,e,n){var r={};function i(e,i,s,o,a){var c=n(t,e,i,s,o,a);return r[e]=c,c}var s,o=Object.assign({},e,{hostNonTLS:t.wsHost+":"+t.wsPort,hostTLS:t.wsHost+":"+t.wssPort,httpPath:t.wsPath}),a=Object.assign({},o,{useTLS:!0}),c=Object.assign({},e,{hostNonTLS:t.httpHost+":"+t.httpPort,hostTLS:t.httpHost+":"+t.httpsPort,httpPath:t.httpPath}),h={loop:!0,timeout:15e3,timeoutLimit:6e4},u=new Bt({minPingDelay:1e4,maxPingDelay:t.activityTimeout}),l=new Bt({lives:2,minPingDelay:1e4,maxPingDelay:t.activityTimeout}),d=i("ws","ws",3,o,u),p=i("wss","ws",3,a,u),f=i("sockjs","sockjs",1,c),g=i("xhr_streaming","xhr_streaming",1,c,l),v=i("xdr_streaming","xdr_streaming",1,c,l),b=i("xhr_polling","xhr_polling",1,c),y=i("xdr_polling","xdr_polling",1,c),m=new zt([d],h),w=new zt([p],h),_=new zt([f],h),S=new zt([new Kt(Wt(g),g,v)],h),k=new zt([new Kt(Wt(b),b,y)],h),C=new zt([new Kt(Wt(S),new Ht([S,new Yt(k,{delay:4e3})]),k)],h),T=new Kt(Wt(C),C,_);return s=e.useTLS?new Ht([m,new Yt(T,{delay:2e3})]):new Ht([m,new Yt(w,{delay:2e3}),new Yt(T,{delay:5e3})]),new Ft(new $t(new Kt(Wt(d),s,T)),r,{ttl:18e5,timeline:e.timeline,useTLS:e.useTLS})},Vt={getRequest:function(t){var e=new window.XDomainRequest;return e.ontimeout=function(){t.emit("error",new p),t.close()},e.onerror=function(e){t.emit("error",e),t.close()},e.onprogress=function(){e.responseText&&e.responseText.length>0&&t.onChunk(200,e.responseText)},e.onload=function(){e.responseText&&e.responseText.length>0&&t.onChunk(200,e.responseText),t.emit("finished",200),t.close()},e},abortRequest:function(t){t.ontimeout=t.onerror=t.onprogress=t.onload=null,t.abort()}};class Zt extends at{constructor(t,e,n){super(),this.hooks=t,this.method=e,this.url=n}start(t){this.position=0,this.xhr=this.hooks.getRequest(this),this.unloader=()=>{this.close()},ue.addUnloadListener(this.unloader),this.xhr.open(this.method,this.url,!0),this.xhr.setRequestHeader&&this.xhr.setRequestHeader("Content-Type","application/json"),this.xhr.send(t)}close(){this.unloader&&(ue.removeUnloadListener(this.unloader),this.unloader=null),this.xhr&&(this.hooks.abortRequest(this.xhr),this.xhr=null)}onChunk(t,e){for(;;){var n=this.advanceBuffer(e);if(!n)break;this.emit("chunk",{status:t,data:n})}this.isBufferTooLong(e)&&this.emit("buffer_too_long")}advanceBuffer(t){var e=t.slice(this.position),n=e.indexOf("\n");return-1!==n?(this.position+=n+1,e.slice(0,n)):null}isBufferTooLong(t){return this.position===t.length&&t.length>262144}}var Qt;!function(t){t[t.CONNECTING=0]="CONNECTING",t[t.OPEN=1]="OPEN",t[t.CLOSED=3]="CLOSED"}(Qt||(Qt={}));var te=Qt,ee=1;function ne(t){var e=-1===t.indexOf("?")?"?":"&";return t+e+"t="+ +new Date+"&n="+ee++}function re(t){return ue.randomInt(t)}var ie,se=class{constructor(t,e){this.hooks=t,this.session=re(1e3)+"/"+function(t){for(var e=[],n=0;n{this.onChunk(t)}),this.stream.bind("finished",t=>{this.hooks.onFinished(this,t)}),this.stream.bind("buffer_too_long",()=>{this.reconnect()});try{this.stream.start()}catch(t){I.defer(()=>{this.onError(t),this.onClose(1006,"Could not start streaming",!1)})}}closeStream(){this.stream&&(this.stream.unbind_all(),this.stream.close(),this.stream=null)}},oe={getReceiveURL:function(t,e){return t.base+"/"+e+"/xhr_streaming"+t.queryString},onHeartbeat:function(t){t.sendRaw("[]")},sendHeartbeat:function(t){t.sendRaw("[]")},onFinished:function(t,e){t.onClose(1006,"Connection interrupted ("+e+")",!1)}},ae={getReceiveURL:function(t,e){return t.base+"/"+e+"/xhr"+t.queryString},onHeartbeat:function(){},sendHeartbeat:function(t){t.sendRaw("[]")},onFinished:function(t,e){200===e?t.reconnect():t.onClose(1006,"Connection interrupted ("+e+")",!1)}},ce={getRequest:function(t){var e=new(ue.getXHRAPI());return e.onreadystatechange=e.onprogress=function(){switch(e.readyState){case 3:e.responseText&&e.responseText.length>0&&t.onChunk(e.status,e.responseText);break;case 4:e.responseText&&e.responseText.length>0&&t.onChunk(e.status,e.responseText),t.emit("finished",e.status),t.close()}},e},abortRequest:function(t){t.onreadystatechange=null,t.abort()}},he={createStreamingSocket(t){return this.createSocket(oe,t)},createPollingSocket(t){return this.createSocket(ae,t)},createSocket:(t,e)=>new se(t,e),createXHR(t,e){return this.createRequest(ce,t,e)},createRequest:(t,e,n)=>new Zt(t,e,n),createXDR:function(t,e){return this.createRequest(Vt,t,e)}},ue={nextAuthCallbackID:1,auth_callbacks:{},ScriptReceivers:i,DependenciesReceivers:o,getDefaultStrategy:Gt,Transports:wt,transportConnectionInitializer:function(){var t=this;t.timeline.info(t.buildTimelineMessage({transport:t.name+(t.options.useTLS?"s":"")})),t.hooks.isInitialized()?t.changeState("initialized"):t.hooks.file?(t.changeState("initializing"),a.load(t.hooks.file,{useTLS:t.options.useTLS},(function(e,n){t.hooks.isInitialized()?(t.changeState("initialized"),n(!0)):(e&&t.onError(e),t.onClose(),n(!1))}))):t.onClose()},HTTPFactory:he,TimelineTransport:Q,getXHRAPI:()=>window.XMLHttpRequest,getWebSocketAPI:()=>window.WebSocket||window.MozWebSocket,setup(t){window.Pusher=t;var e=()=>{this.onDocumentBody(t.ready)};window.JSON?e():a.load("json2",{},e)},getDocument:()=>document,getProtocol(){return this.getDocument().location.protocol},getAuthorizers:()=>({ajax:w,jsonp:G}),onDocumentBody(t){document.body?t():setTimeout(()=>{this.onDocumentBody(t)},0)},createJSONPRequest:(t,e)=>new Z(t,e),createScriptRequest:t=>new V(t),getLocalStorage(){try{return window.localStorage}catch(t){return}},createXHR(){return this.getXHRAPI()?this.createXMLHttpRequest():this.createMicrosoftXHR()},createXMLHttpRequest(){return new(this.getXHRAPI())},createMicrosoftXHR:()=>new ActiveXObject("Microsoft.XMLHTTP"),getNetwork:()=>_t,createWebSocket(t){return new(this.getWebSocketAPI())(t)},createSocketRequest(t,e){if(this.isXHRSupported())return this.HTTPFactory.createXHR(t,e);if(this.isXDRSupported(0===e.indexOf("https:")))return this.HTTPFactory.createXDR(t,e);throw"Cross-origin HTTP requests are not supported"},isXHRSupported(){var t=this.getXHRAPI();return Boolean(t)&&void 0!==(new t).withCredentials},isXDRSupported(t){var e=t?"https:":"http:",n=this.getProtocol();return Boolean(window.XDomainRequest)&&n===e},addUnloadListener(t){void 0!==window.addEventListener?window.addEventListener("unload",t,!1):void 0!==window.attachEvent&&window.attachEvent("onunload",t)},removeUnloadListener(t){void 0!==window.addEventListener?window.removeEventListener("unload",t,!1):void 0!==window.detachEvent&&window.detachEvent("onunload",t)},randomInt:t=>Math.floor((window.crypto||window.msCrypto).getRandomValues(new Uint32Array(1))[0]/Math.pow(2,32)*t)};!function(t){t[t.ERROR=3]="ERROR",t[t.INFO=6]="INFO",t[t.DEBUG=7]="DEBUG"}(ie||(ie={}));var le=ie;class de{constructor(t,e,n){this.key=t,this.session=e,this.events=[],this.options=n||{},this.sent=0,this.uniqueID=0}log(t,e){t<=this.options.level&&(this.events.push(D({},e,{timestamp:I.now()})),this.options.limit&&this.events.length>this.options.limit&&this.events.shift())}error(t){this.log(le.ERROR,t)}info(t){this.log(le.INFO,t)}debug(t){this.log(le.DEBUG,t)}isEmpty(){return 0===this.events.length}send(t,e){var n=D({session:this.session,bundle:this.sent+1,key:this.key,lib:"js",version:this.options.version,cluster:this.options.cluster,features:this.options.features,timeline:this.events},this.options.params);return this.events=[],t(n,(t,n)=>{t||this.sent++,e&&e(t,n)}),!0}generateUniqueID(){return this.uniqueID++,this.uniqueID}}class pe{constructor(t,e,n,r){this.name=t,this.priority=e,this.transport=n,this.options=r||{}}isSupported(){return this.transport.isSupported({useTLS:this.options.useTLS})}connect(t,e){if(!this.isSupported())return fe(new y,e);if(this.priority{n||(h(),i?i.close():r.close())},forceMinPriority:t=>{n||this.priority{if(void 0===ue.getAuthorizers()[t.transport])throw`'${t.transport}' is not a recognized auth transport`;return(e,n)=>{const r=((t,e)=>{var n="socket_id="+encodeURIComponent(t.socketId);for(var r in e.params)n+="&"+encodeURIComponent(r)+"="+encodeURIComponent(e.params[r]);if(null!=e.paramsProvider){let t=e.paramsProvider();for(var r in t)n+="&"+encodeURIComponent(r)+"="+encodeURIComponent(t[r])}return n})(e,t);ue.getAuthorizers()[t.transport](ue,r,t,h.UserAuthentication,n)}};var we=t=>{if(void 0===ue.getAuthorizers()[t.transport])throw`'${t.transport}' is not a recognized auth transport`;return(e,n)=>{const r=((t,e)=>{var n="socket_id="+encodeURIComponent(t.socketId);for(var r in n+="&channel_name="+encodeURIComponent(t.channelName),e.params)n+="&"+encodeURIComponent(r)+"="+encodeURIComponent(e.params[r]);if(null!=e.paramsProvider){let t=e.paramsProvider();for(var r in t)n+="&"+encodeURIComponent(r)+"="+encodeURIComponent(t[r])}return n})(e,t);ue.getAuthorizers()[t.transport](ue,r,t,h.ChannelAuthorization,n)}};function _e(t){return t.httpHost?t.httpHost:t.cluster?`sockjs-${t.cluster}.pusher.com`:s.httpHost}function Se(t){return t.wsHost?t.wsHost:`ws-${t.cluster}.pusher.com`}function ke(t){return"https:"===ue.getProtocol()||!1!==t.forceTLS}function Ce(t){return"enableStats"in t?t.enableStats:"disableStats"in t&&!t.disableStats}function Te(t){const e=Object.assign(Object.assign({},s.userAuthentication),t.userAuthentication);return"customHandler"in e&&null!=e.customHandler?e.customHandler:me(e)}function Ee(t,e){const n=function(t,e){let n;return"channelAuthorization"in t?n=Object.assign(Object.assign({},s.channelAuthorization),t.channelAuthorization):(n={transport:t.authTransport||s.authTransport,endpoint:t.authEndpoint||s.authEndpoint},"auth"in t&&("params"in t.auth&&(n.params=t.auth.params),"headers"in t.auth&&(n.headers=t.auth.headers)),"authorizer"in t&&(n.customHandler=((t,e,n)=>{const r={authTransport:e.transport,authEndpoint:e.endpoint,auth:{params:e.params,headers:e.headers}};return(e,i)=>{const s=t.channel(e.channelName);n(s,r).authorize(e.socketId,i)}})(e,n,t.authorizer))),n}(t,e);return"customHandler"in n&&null!=n.customHandler?n.customHandler:we(n)}class Pe extends at{constructor(t){super((function(t,e){W.debug("No callbacks on watchlist events for "+t)})),this.pusher=t,this.bindWatchlistInternalEvent()}handleEvent(t){t.data.events.forEach(t=>{this.emit(t.name,t)})}bindWatchlistInternalEvent(){this.pusher.connection.bind("message",t=>{"pusher_internal:watchlist_events"===t.event&&this.handleEvent(t)})}}var xe=function(){let t,e;return{promise:new Promise((n,r)=>{t=n,e=r}),resolve:t,reject:e}};class Ae extends at{constructor(t){super((function(t,e){W.debug("No callbacks on user for "+t)})),this.signin_requested=!1,this.user_data=null,this.serverToUserChannel=null,this.signinDonePromise=null,this._signinDoneResolve=null,this._onAuthorize=(t,e)=>{if(t)return W.warn("Error during signin: "+t),void this._cleanup();this.pusher.send_event("pusher:signin",{auth:e.auth,user_data:e.user_data})},this.pusher=t,this.pusher.connection.bind("state_change",({previous:t,current:e})=>{"connected"!==t&&"connected"===e&&this._signin(),"connected"===t&&"connected"!==e&&(this._cleanup(),this._newSigninPromiseIfNeeded())}),this.watchlist=new Pe(t),this.pusher.connection.bind("message",t=>{"pusher:signin_success"===t.event&&this._onSigninSuccess(t.data),this.serverToUserChannel&&this.serverToUserChannel.name===t.channel&&this.serverToUserChannel.handleEvent(t)})}signin(){this.signin_requested||(this.signin_requested=!0,this._signin())}_signin(){this.signin_requested&&(this._newSigninPromiseIfNeeded(),"connected"===this.pusher.connection.state&&this.pusher.config.userAuthenticator({socketId:this.pusher.connection.socket_id},this._onAuthorize))}_onSigninSuccess(t){try{this.user_data=JSON.parse(t.user_data)}catch(e){return W.error("Failed parsing user data after signin: "+t.user_data),void this._cleanup()}if("string"!=typeof this.user_data.id||""===this.user_data.id)return W.error("user_data doesn't contain an id. user_data: "+this.user_data),void this._cleanup();this._signinDoneResolve(),this._subscribeChannels()}_subscribeChannels(){this.serverToUserChannel=new xt("#server-to-user-"+this.user_data.id,this.pusher),this.serverToUserChannel.bind_global((t,e)=>{0!==t.indexOf("pusher_internal:")&&0!==t.indexOf("pusher:")&&this.emit(t,e)}),(t=>{t.subscriptionPending&&t.subscriptionCancelled?t.reinstateSubscription():t.subscriptionPending||"connected"!==this.pusher.connection.state||t.subscribe()})(this.serverToUserChannel)}_cleanup(){this.user_data=null,this.serverToUserChannel&&(this.serverToUserChannel.unbind_all(),this.serverToUserChannel.disconnect(),this.serverToUserChannel=null),this.signin_requested&&this._signinDoneResolve()}_newSigninPromiseIfNeeded(){if(!this.signin_requested)return;if(this.signinDonePromise&&!this.signinDonePromise.done)return;const{promise:t,resolve:e,reject:n}=xe();t.done=!1;const r=()=>{t.done=!0};t.then(r).catch(r),this.signinDonePromise=t,this._signinDoneResolve=e}}class Oe{static ready(){Oe.isReady=!0;for(var t=0,e=Oe.instances.length;tue.getDefaultStrategy(this.config,t,ve),timeline:this.timeline,activityTimeout:this.config.activityTimeout,pongTimeout:this.config.pongTimeout,unavailableTimeout:this.config.unavailableTimeout,useTLS:Boolean(this.config.useTLS)}),this.connection.bind("connected",()=>{this.subscribeAll(),this.timelineSender&&this.timelineSender.send(this.connection.isUsingTLS())}),this.connection.bind("message",t=>{var e=0===t.event.indexOf("pusher_internal:");if(t.channel){var n=this.channel(t.channel);n&&n.handleEvent(t)}e||this.global_emitter.emit(t.event,t.data)}),this.connection.bind("connecting",()=>{this.channels.disconnect()}),this.connection.bind("disconnected",()=>{this.channels.disconnect()}),this.connection.bind("error",t=>{W.warn(t)}),Oe.instances.push(this),this.timeline.info({instances:Oe.instances.length}),this.user=new Ae(this),Oe.isReady&&this.connect()}channel(t){return this.channels.find(t)}allChannels(){return this.channels.all()}connect(){if(this.connection.connect(),this.timelineSender&&!this.timelineSenderTimer){var t=this.connection.isUsingTLS(),e=this.timelineSender;this.timelineSenderTimer=new M(6e4,(function(){e.send(t)}))}}disconnect(){this.connection.disconnect(),this.timelineSenderTimer&&(this.timelineSenderTimer.ensureAborted(),this.timelineSenderTimer=null)}bind(t,e,n){return this.global_emitter.bind(t,e,n),this}unbind(t,e,n){return this.global_emitter.unbind(t,e,n),this}bind_global(t){return this.global_emitter.bind_global(t),this}unbind_global(t){return this.global_emitter.unbind_global(t),this}unbind_all(t){return this.global_emitter.unbind_all(),this}subscribeAll(){var t;for(t in this.channels.channels)this.channels.channels.hasOwnProperty(t)&&this.subscribe(t)}subscribe(t){var e=this.channels.add(t,this);return e.subscriptionPending&&e.subscriptionCancelled?e.reinstateSubscription():e.subscriptionPending||"connected"!==this.connection.state||e.subscribe(),e}unsubscribe(t){var e=this.channels.find(t);e&&e.subscriptionPending?e.cancelSubscription():(e=this.channels.remove(t))&&e.subscribed&&e.unsubscribe()}send_event(t,e,n){return this.connection.send_event(t,e,n)}shouldUseTLS(){return this.config.useTLS}signin(){this.user.signin()}}Oe.instances=[],Oe.isReady=!1,Oe.logToConsole=!1,Oe.Runtime=ue,Oe.ScriptReceivers=ue.ScriptReceivers,Oe.DependenciesReceivers=ue.DependenciesReceivers,Oe.auth_callbacks=ue.auth_callbacks;var Le=Oe;ue.setup(Oe);var Re=n(2);class Ue extends Le{constructor(t,e){Le.logToConsole=Ue.logToConsole,Le.log=Ue.log,ye(e),e.nacl=Re,super(t,e)}}}])})); +!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.Pusher=e():t.Pusher=e()}(window,(function(){return function(t){var e={};function n(r){if(e[r])return e[r].exports;var i=e[r]={i:r,l:!1,exports:{}};return t[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)n.d(r,i,function(e){return t[e]}.bind(null,i));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=3)}([function(t,e,n){"use strict";var r,i=this&&this.__extends||(r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)},function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)});Object.defineProperty(e,"__esModule",{value:!0});var s=function(){function t(t){void 0===t&&(t="="),this._paddingCharacter=t}return t.prototype.encodedLength=function(t){return this._paddingCharacter?(t+2)/3*4|0:(8*t+5)/6|0},t.prototype.encode=function(t){for(var e="",n=0;n>>18&63),e+=this._encodeByte(r>>>12&63),e+=this._encodeByte(r>>>6&63),e+=this._encodeByte(r>>>0&63)}var i=t.length-n;if(i>0){r=t[n]<<16|(2===i?t[n+1]<<8:0);e+=this._encodeByte(r>>>18&63),e+=this._encodeByte(r>>>12&63),e+=2===i?this._encodeByte(r>>>6&63):this._paddingCharacter||"",e+=this._paddingCharacter||""}return e},t.prototype.maxDecodedLength=function(t){return this._paddingCharacter?t/4*3|0:(6*t+7)/8|0},t.prototype.decodedLength=function(t){return this.maxDecodedLength(t.length-this._getPaddingLength(t))},t.prototype.decode=function(t){if(0===t.length)return new Uint8Array(0);for(var e=this._getPaddingLength(t),n=t.length-e,r=new Uint8Array(this.maxDecodedLength(n)),i=0,s=0,o=0,a=0,c=0,h=0,u=0;s>>4,r[i++]=c<<4|h>>>2,r[i++]=h<<6|u,o|=256&a,o|=256&c,o|=256&h,o|=256&u;if(s>>4,o|=256&a,o|=256&c),s>>2,o|=256&h),s>>8&6,e+=51-t>>>8&-75,e+=61-t>>>8&-15,e+=62-t>>>8&3,String.fromCharCode(e)},t.prototype._decodeChar=function(t){var e=256;return e+=(42-t&t-44)>>>8&-256+t-43+62,e+=(46-t&t-48)>>>8&-256+t-47+63,e+=(47-t&t-58)>>>8&-256+t-48+52,e+=(64-t&t-91)>>>8&-256+t-65+0,e+=(96-t&t-123)>>>8&-256+t-97+26},t.prototype._getPaddingLength=function(t){var e=0;if(this._paddingCharacter){for(var n=t.length-1;n>=0&&t[n]===this._paddingCharacter;n--)e++;if(t.length<4||e>2)throw new Error("Base64Coder: incorrect padding")}return e},t}();e.Coder=s;var o=new s;e.encode=function(t){return o.encode(t)},e.decode=function(t){return o.decode(t)};var a=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return i(e,t),e.prototype._encodeByte=function(t){var e=t;return e+=65,e+=25-t>>>8&6,e+=51-t>>>8&-75,e+=61-t>>>8&-13,e+=62-t>>>8&49,String.fromCharCode(e)},e.prototype._decodeChar=function(t){var e=256;return e+=(44-t&t-46)>>>8&-256+t-45+62,e+=(94-t&t-96)>>>8&-256+t-95+63,e+=(47-t&t-58)>>>8&-256+t-48+52,e+=(64-t&t-91)>>>8&-256+t-65+0,e+=(96-t&t-123)>>>8&-256+t-97+26},e}(s);e.URLSafeCoder=a;var c=new a;e.encodeURLSafe=function(t){return c.encode(t)},e.decodeURLSafe=function(t){return c.decode(t)},e.encodedLength=function(t){return o.encodedLength(t)},e.maxDecodedLength=function(t){return o.maxDecodedLength(t)},e.decodedLength=function(t){return o.decodedLength(t)}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r="utf8: invalid source encoding";function i(t){for(var e=0,n=0;n=t.length-1)throw new Error("utf8: invalid string");n++,e+=4}}return e}e.encode=function(t){for(var e=new Uint8Array(i(t)),n=0,r=0;r>6,e[n++]=128|63&s):s<55296?(e[n++]=224|s>>12,e[n++]=128|s>>6&63,e[n++]=128|63&s):(r++,s=(1023&s)<<10,s|=1023&t.charCodeAt(r),s+=65536,e[n++]=240|s>>18,e[n++]=128|s>>12&63,e[n++]=128|s>>6&63,e[n++]=128|63&s)}return e},e.encodedLength=i,e.decode=function(t){for(var e=[],n=0;n=t.length)throw new Error(r);if(128!=(192&(o=t[++n])))throw new Error(r);i=(31&i)<<6|63&o,s=128}else if(i<240){if(n>=t.length-1)throw new Error(r);var o=t[++n],a=t[++n];if(128!=(192&o)||128!=(192&a))throw new Error(r);i=(15&i)<<12|(63&o)<<6|63&a,s=2048}else{if(!(i<248))throw new Error(r);if(n>=t.length-2)throw new Error(r);o=t[++n],a=t[++n];var c=t[++n];if(128!=(192&o)||128!=(192&a)||128!=(192&c))throw new Error(r);i=(15&i)<<18|(63&o)<<12|(63&a)<<6|63&c,s=65536}if(i=55296&&i<=57343)throw new Error(r);if(i>=65536){if(i>1114111)throw new Error(r);i-=65536,e.push(String.fromCharCode(55296|i>>10)),i=56320|1023&i}}e.push(String.fromCharCode(i))}return e.join("")}},function(t,e,n){!function(t){"use strict";var e=function(t){var e,n=new Float64Array(16);if(t)for(e=0;e>24&255,t[e+1]=n>>16&255,t[e+2]=n>>8&255,t[e+3]=255&n,t[e+4]=r>>24&255,t[e+5]=r>>16&255,t[e+6]=r>>8&255,t[e+7]=255&r}function g(t,e,n,r,i){var s,o=0;for(s=0;s>>8)-1}function v(t,e,n,r){return g(t,e,n,r,16)}function b(t,e,n,r){return g(t,e,n,r,32)}function y(t,e,n,r){!function(t,e,n,r){for(var i,s=255&r[0]|(255&r[1])<<8|(255&r[2])<<16|(255&r[3])<<24,o=255&n[0]|(255&n[1])<<8|(255&n[2])<<16|(255&n[3])<<24,a=255&n[4]|(255&n[5])<<8|(255&n[6])<<16|(255&n[7])<<24,c=255&n[8]|(255&n[9])<<8|(255&n[10])<<16|(255&n[11])<<24,h=255&n[12]|(255&n[13])<<8|(255&n[14])<<16|(255&n[15])<<24,u=255&r[4]|(255&r[5])<<8|(255&r[6])<<16|(255&r[7])<<24,l=255&e[0]|(255&e[1])<<8|(255&e[2])<<16|(255&e[3])<<24,d=255&e[4]|(255&e[5])<<8|(255&e[6])<<16|(255&e[7])<<24,p=255&e[8]|(255&e[9])<<8|(255&e[10])<<16|(255&e[11])<<24,f=255&e[12]|(255&e[13])<<8|(255&e[14])<<16|(255&e[15])<<24,g=255&r[8]|(255&r[9])<<8|(255&r[10])<<16|(255&r[11])<<24,v=255&n[16]|(255&n[17])<<8|(255&n[18])<<16|(255&n[19])<<24,b=255&n[20]|(255&n[21])<<8|(255&n[22])<<16|(255&n[23])<<24,y=255&n[24]|(255&n[25])<<8|(255&n[26])<<16|(255&n[27])<<24,m=255&n[28]|(255&n[29])<<8|(255&n[30])<<16|(255&n[31])<<24,w=255&r[12]|(255&r[13])<<8|(255&r[14])<<16|(255&r[15])<<24,_=s,S=o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k>>>8&255,t[10]=k>>>16&255,t[11]=k>>>24&255,t[12]=C>>>0&255,t[13]=C>>>8&255,t[14]=C>>>16&255,t[15]=C>>>24&255,t[16]=T>>>0&255,t[17]=T>>>8&255,t[18]=T>>>16&255,t[19]=T>>>24&255,t[20]=E>>>0&255,t[21]=E>>>8&255,t[22]=E>>>16&255,t[23]=E>>>24&255,t[24]=P>>>0&255,t[25]=P>>>8&255,t[26]=P>>>16&255,t[27]=P>>>24&255,t[28]=x>>>0&255,t[29]=x>>>8&255,t[30]=x>>>16&255,t[31]=x>>>24&255,t[32]=A>>>0&255,t[33]=A>>>8&255,t[34]=A>>>16&255,t[35]=A>>>24&255,t[36]=O>>>0&255,t[37]=O>>>8&255,t[38]=O>>>16&255,t[39]=O>>>24&255,t[40]=L>>>0&255,t[41]=L>>>8&255,t[42]=L>>>16&255,t[43]=L>>>24&255,t[44]=R>>>0&255,t[45]=R>>>8&255,t[46]=R>>>16&255,t[47]=R>>>24&255,t[48]=U>>>0&255,t[49]=U>>>8&255,t[50]=U>>>16&255,t[51]=U>>>24&255,t[52]=I>>>0&255,t[53]=I>>>8&255,t[54]=I>>>16&255,t[55]=I>>>24&255,t[56]=M>>>0&255,t[57]=M>>>8&255,t[58]=M>>>16&255,t[59]=M>>>24&255,t[60]=D>>>0&255,t[61]=D>>>8&255,t[62]=D>>>16&255,t[63]=D>>>24&255}(t,e,n,r)}function m(t,e,n,r){!function(t,e,n,r){for(var i,s=255&r[0]|(255&r[1])<<8|(255&r[2])<<16|(255&r[3])<<24,o=255&n[0]|(255&n[1])<<8|(255&n[2])<<16|(255&n[3])<<24,a=255&n[4]|(255&n[5])<<8|(255&n[6])<<16|(255&n[7])<<24,c=255&n[8]|(255&n[9])<<8|(255&n[10])<<16|(255&n[11])<<24,h=255&n[12]|(255&n[13])<<8|(255&n[14])<<16|(255&n[15])<<24,u=255&r[4]|(255&r[5])<<8|(255&r[6])<<16|(255&r[7])<<24,l=255&e[0]|(255&e[1])<<8|(255&e[2])<<16|(255&e[3])<<24,d=255&e[4]|(255&e[5])<<8|(255&e[6])<<16|(255&e[7])<<24,p=255&e[8]|(255&e[9])<<8|(255&e[10])<<16|(255&e[11])<<24,f=255&e[12]|(255&e[13])<<8|(255&e[14])<<16|(255&e[15])<<24,g=255&r[8]|(255&r[9])<<8|(255&r[10])<<16|(255&r[11])<<24,v=255&n[16]|(255&n[17])<<8|(255&n[18])<<16|(255&n[19])<<24,b=255&n[20]|(255&n[21])<<8|(255&n[22])<<16|(255&n[23])<<24,y=255&n[24]|(255&n[25])<<8|(255&n[26])<<16|(255&n[27])<<24,m=255&n[28]|(255&n[29])<<8|(255&n[30])<<16|(255&n[31])<<24,w=255&r[12]|(255&r[13])<<8|(255&r[14])<<16|(255&r[15])<<24,_=0;_<20;_+=2)s^=(i=(b^=(i=(p^=(i=(h^=(i=s+b|0)<<7|i>>>25)+s|0)<<9|i>>>23)+h|0)<<13|i>>>19)+p|0)<<18|i>>>14,u^=(i=(o^=(i=(y^=(i=(f^=(i=u+o|0)<<7|i>>>25)+u|0)<<9|i>>>23)+f|0)<<13|i>>>19)+y|0)<<18|i>>>14,g^=(i=(l^=(i=(a^=(i=(m^=(i=g+l|0)<<7|i>>>25)+g|0)<<9|i>>>23)+m|0)<<13|i>>>19)+a|0)<<18|i>>>14,w^=(i=(v^=(i=(d^=(i=(c^=(i=w+v|0)<<7|i>>>25)+w|0)<<9|i>>>23)+c|0)<<13|i>>>19)+d|0)<<18|i>>>14,s^=(i=(c^=(i=(a^=(i=(o^=(i=s+c|0)<<7|i>>>25)+s|0)<<9|i>>>23)+o|0)<<13|i>>>19)+a|0)<<18|i>>>14,u^=(i=(h^=(i=(d^=(i=(l^=(i=u+h|0)<<7|i>>>25)+u|0)<<9|i>>>23)+l|0)<<13|i>>>19)+d|0)<<18|i>>>14,g^=(i=(f^=(i=(p^=(i=(v^=(i=g+f|0)<<7|i>>>25)+g|0)<<9|i>>>23)+v|0)<<13|i>>>19)+p|0)<<18|i>>>14,w^=(i=(m^=(i=(y^=(i=(b^=(i=w+m|0)<<7|i>>>25)+w|0)<<9|i>>>23)+b|0)<<13|i>>>19)+y|0)<<18|i>>>14;t[0]=s>>>0&255,t[1]=s>>>8&255,t[2]=s>>>16&255,t[3]=s>>>24&255,t[4]=u>>>0&255,t[5]=u>>>8&255,t[6]=u>>>16&255,t[7]=u>>>24&255,t[8]=g>>>0&255,t[9]=g>>>8&255,t[10]=g>>>16&255,t[11]=g>>>24&255,t[12]=w>>>0&255,t[13]=w>>>8&255,t[14]=w>>>16&255,t[15]=w>>>24&255,t[16]=l>>>0&255,t[17]=l>>>8&255,t[18]=l>>>16&255,t[19]=l>>>24&255,t[20]=d>>>0&255,t[21]=d>>>8&255,t[22]=d>>>16&255,t[23]=d>>>24&255,t[24]=p>>>0&255,t[25]=p>>>8&255,t[26]=p>>>16&255,t[27]=p>>>24&255,t[28]=f>>>0&255,t[29]=f>>>8&255,t[30]=f>>>16&255,t[31]=f>>>24&255}(t,e,n,r)}var w=new Uint8Array([101,120,112,97,110,100,32,51,50,45,98,121,116,101,32,107]);function _(t,e,n,r,i,s,o){var a,c,h=new Uint8Array(16),u=new Uint8Array(64);for(c=0;c<16;c++)h[c]=0;for(c=0;c<8;c++)h[c]=s[c];for(;i>=64;){for(y(u,h,o,w),c=0;c<64;c++)t[e+c]=n[r+c]^u[c];for(a=1,c=8;c<16;c++)a=a+(255&h[c])|0,h[c]=255&a,a>>>=8;i-=64,e+=64,r+=64}if(i>0)for(y(u,h,o,w),c=0;c=64;){for(y(c,a,i,w),o=0;o<64;o++)t[e+o]=c[o];for(s=1,o=8;o<16;o++)s=s+(255&a[o])|0,a[o]=255&s,s>>>=8;n-=64,e+=64}if(n>0)for(y(c,a,i,w),o=0;o>>13|n<<3),r=255&t[4]|(255&t[5])<<8,this.r[2]=7939&(n>>>10|r<<6),i=255&t[6]|(255&t[7])<<8,this.r[3]=8191&(r>>>7|i<<9),s=255&t[8]|(255&t[9])<<8,this.r[4]=255&(i>>>4|s<<12),this.r[5]=s>>>1&8190,o=255&t[10]|(255&t[11])<<8,this.r[6]=8191&(s>>>14|o<<2),a=255&t[12]|(255&t[13])<<8,this.r[7]=8065&(o>>>11|a<<5),c=255&t[14]|(255&t[15])<<8,this.r[8]=8191&(a>>>8|c<<8),this.r[9]=c>>>5&127,this.pad[0]=255&t[16]|(255&t[17])<<8,this.pad[1]=255&t[18]|(255&t[19])<<8,this.pad[2]=255&t[20]|(255&t[21])<<8,this.pad[3]=255&t[22]|(255&t[23])<<8,this.pad[4]=255&t[24]|(255&t[25])<<8,this.pad[5]=255&t[26]|(255&t[27])<<8,this.pad[6]=255&t[28]|(255&t[29])<<8,this.pad[7]=255&t[30]|(255&t[31])<<8};function E(t,e,n,r,i,s){var o=new T(s);return o.update(n,r,i),o.finish(t,e),0}function P(t,e,n,r,i,s){var o=new Uint8Array(16);return E(o,0,n,r,i,s),v(t,e,o,0)}function x(t,e,n,r,i){var s;if(n<32)return-1;for(C(t,0,e,0,n,r,i),E(t,16,t,32,n-32,t),s=0;s<16;s++)t[s]=0;return 0}function A(t,e,n,r,i){var s,o=new Uint8Array(32);if(n<32)return-1;if(k(o,0,32,r,i),0!==P(e,16,e,32,n-32,o))return-1;for(C(t,0,e,0,n,r,i),s=0;s<32;s++)t[s]=0;return 0}function O(t,e){var n;for(n=0;n<16;n++)t[n]=0|e[n]}function L(t){var e,n,r=1;for(e=0;e<16;e++)n=t[e]+r+65535,r=Math.floor(n/65536),t[e]=n-65536*r;t[0]+=r-1+37*(r-1)}function R(t,e,n){for(var r,i=~(n-1),s=0;s<16;s++)r=i&(t[s]^e[s]),t[s]^=r,e[s]^=r}function U(t,n){var r,i,s,o=e(),a=e();for(r=0;r<16;r++)a[r]=n[r];for(L(a),L(a),L(a),i=0;i<2;i++){for(o[0]=a[0]-65517,r=1;r<15;r++)o[r]=a[r]-65535-(o[r-1]>>16&1),o[r-1]&=65535;o[15]=a[15]-32767-(o[14]>>16&1),s=o[15]>>16&1,o[14]&=65535,R(a,o,1-s)}for(r=0;r<16;r++)t[2*r]=255&a[r],t[2*r+1]=a[r]>>8}function I(t,e){var n=new Uint8Array(32),r=new Uint8Array(32);return U(n,t),U(r,e),b(n,0,r,0)}function M(t){var e=new Uint8Array(32);return U(e,t),1&e[0]}function D(t,e){var n;for(n=0;n<16;n++)t[n]=e[2*n]+(e[2*n+1]<<8);t[15]&=32767}function N(t,e,n){for(var r=0;r<16;r++)t[r]=e[r]+n[r]}function j(t,e,n){for(var r=0;r<16;r++)t[r]=e[r]-n[r]}function B(t,e,n){var r,i,s=0,o=0,a=0,c=0,h=0,u=0,l=0,d=0,p=0,f=0,g=0,v=0,b=0,y=0,m=0,w=0,_=0,S=0,k=0,C=0,T=0,E=0,P=0,x=0,A=0,O=0,L=0,R=0,U=0,I=0,M=0,D=n[0],N=n[1],j=n[2],B=n[3],z=n[4],H=n[5],q=n[6],F=n[7],X=n[8],J=n[9],Y=n[10],K=n[11],$=n[12],W=n[13],G=n[14],V=n[15];s+=(r=e[0])*D,o+=r*N,a+=r*j,c+=r*B,h+=r*z,u+=r*H,l+=r*q,d+=r*F,p+=r*X,f+=r*J,g+=r*Y,v+=r*K,b+=r*$,y+=r*W,m+=r*G,w+=r*V,o+=(r=e[1])*D,a+=r*N,c+=r*j,h+=r*B,u+=r*z,l+=r*H,d+=r*q,p+=r*F,f+=r*X,g+=r*J,v+=r*Y,b+=r*K,y+=r*$,m+=r*W,w+=r*G,_+=r*V,a+=(r=e[2])*D,c+=r*N,h+=r*j,u+=r*B,l+=r*z,d+=r*H,p+=r*q,f+=r*F,g+=r*X,v+=r*J,b+=r*Y,y+=r*K,m+=r*$,w+=r*W,_+=r*G,S+=r*V,c+=(r=e[3])*D,h+=r*N,u+=r*j,l+=r*B,d+=r*z,p+=r*H,f+=r*q,g+=r*F,v+=r*X,b+=r*J,y+=r*Y,m+=r*K,w+=r*$,_+=r*W,S+=r*G,k+=r*V,h+=(r=e[4])*D,u+=r*N,l+=r*j,d+=r*B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L+=r*G,R+=r*V,y+=(r=e[13])*D,m+=r*N,w+=r*j,_+=r*B,S+=r*z,k+=r*H,C+=r*q,T+=r*F,E+=r*X,P+=r*J,x+=r*Y,A+=r*K,O+=r*$,L+=r*W,R+=r*G,U+=r*V,m+=(r=e[14])*D,w+=r*N,_+=r*j,S+=r*B,k+=r*z,C+=r*H,T+=r*q,E+=r*F,P+=r*X,x+=r*J,A+=r*Y,O+=r*K,L+=r*$,R+=r*W,U+=r*G,I+=r*V,w+=(r=e[15])*D,o+=38*(S+=r*j),a+=38*(k+=r*B),c+=38*(C+=r*z),h+=38*(T+=r*H),u+=38*(E+=r*q),l+=38*(P+=r*F),d+=38*(x+=r*X),p+=38*(A+=r*J),f+=38*(O+=r*Y),g+=38*(L+=r*K),v+=38*(R+=r*$),b+=38*(U+=r*W),y+=38*(I+=r*G),m+=38*(M+=r*V),s=(r=(s+=38*(_+=r*N))+(i=1)+65535)-65536*(i=Math.floor(r/65536)),o=(r=o+i+65535)-65536*(i=Math.floor(r/65536)),a=(r=a+i+65535)-65536*(i=Math.floor(r/65536)),c=(r=c+i+65535)-65536*(i=Math.floor(r/65536)),h=(r=h+i+65535)-65536*(i=Math.floor(r/65536)),u=(r=u+i+65535)-65536*(i=Math.floor(r/65536)),l=(r=l+i+65535)-65536*(i=Math.floor(r/65536)),d=(r=d+i+65535)-65536*(i=Math.floor(r/65536)),p=(r=p+i+65535)-65536*(i=Math.floor(r/65536)),f=(r=f+i+65535)-65536*(i=Math.floor(r/65536)),g=(r=g+i+65535)-65536*(i=Math.floor(r/65536)),v=(r=v+i+65535)-65536*(i=Math.floor(r/65536)),b=(r=b+i+65535)-65536*(i=Math.floor(r/65536)),y=(r=y+i+65535)-65536*(i=Math.floor(r/65536)),m=(r=m+i+65535)-65536*(i=Math.floor(r/65536)),w=(r=w+i+65535)-65536*(i=Math.floor(r/65536)),s=(r=(s+=i-1+37*(i-1))+(i=1)+65535)-65536*(i=Math.floor(r/65536)),o=(r=o+i+65535)-65536*(i=Math.floor(r/65536)),a=(r=a+i+65535)-65536*(i=Math.floor(r/65536)),c=(r=c+i+65535)-65536*(i=Math.floor(r/65536)),h=(r=h+i+65535)-65536*(i=Math.floor(r/65536)),u=(r=u+i+65535)-65536*(i=Math.floor(r/65536)),l=(r=l+i+65535)-65536*(i=Math.floor(r/65536)),d=(r=d+i+65535)-65536*(i=Math.floor(r/65536)),p=(r=p+i+65535)-65536*(i=Math.floor(r/65536)),f=(r=f+i+65535)-65536*(i=Math.floor(r/65536)),g=(r=g+i+65535)-65536*(i=Math.floor(r/65536)),v=(r=v+i+65535)-65536*(i=Math.floor(r/65536)),b=(r=b+i+65535)-65536*(i=Math.floor(r/65536)),y=(r=y+i+65535)-65536*(i=Math.floor(r/65536)),m=(r=m+i+65535)-65536*(i=Math.floor(r/65536)),w=(r=w+i+65535)-65536*(i=Math.floor(r/65536)),s+=i-1+37*(i-1),t[0]=s,t[1]=o,t[2]=a,t[3]=c,t[4]=h,t[5]=u,t[6]=l,t[7]=d,t[8]=p,t[9]=f,t[10]=g,t[11]=v,t[12]=b,t[13]=y,t[14]=m,t[15]=w}function z(t,e){B(t,e,e)}function H(t,n){var r,i=e();for(r=0;r<16;r++)i[r]=n[r];for(r=253;r>=0;r--)z(i,i),2!==r&&4!==r&&B(i,i,n);for(r=0;r<16;r++)t[r]=i[r]}function q(t,n){var r,i=e();for(r=0;r<16;r++)i[r]=n[r];for(r=250;r>=0;r--)z(i,i),1!==r&&B(i,i,n);for(r=0;r<16;r++)t[r]=i[r]}function F(t,n,r){var i,s,o=new Uint8Array(32),a=new Float64Array(80),h=e(),u=e(),l=e(),d=e(),p=e(),f=e();for(s=0;s<31;s++)o[s]=n[s];for(o[31]=127&n[31]|64,o[0]&=248,D(a,r),s=0;s<16;s++)u[s]=a[s],d[s]=h[s]=l[s]=0;for(h[0]=d[0]=1,s=254;s>=0;--s)R(h,u,i=o[s>>>3]>>>(7&s)&1),R(l,d,i),N(p,h,l),j(h,h,l),N(l,u,d),j(u,u,d),z(d,p),z(f,h),B(h,l,h),B(l,u,p),N(p,h,l),j(h,h,l),z(u,h),j(l,d,f),B(h,l,c),N(h,h,d),B(l,l,h),B(h,d,f),B(d,u,a),z(u,p),R(h,u,i),R(l,d,i);for(s=0;s<16;s++)a[s+16]=h[s],a[s+32]=l[s],a[s+48]=u[s],a[s+64]=d[s];var g=a.subarray(32),v=a.subarray(16);return H(g,g),B(v,v,g),U(t,v),0}function X(t,e){return F(t,e,s)}function J(t,e){return r(e,32),X(t,e)}function Y(t,e,n){var r=new Uint8Array(32);return F(r,n,e),m(t,i,r,w)}T.prototype.blocks=function(t,e,n){for(var r,i,s,o,a,c,h,u,l,d,p,f,g,v,b,y,m,w,_,S=this.fin?0:2048,k=this.h[0],C=this.h[1],T=this.h[2],E=this.h[3],P=this.h[4],x=this.h[5],A=this.h[6],O=this.h[7],L=this.h[8],R=this.h[9],U=this.r[0],I=this.r[1],M=this.r[2],D=this.r[3],N=this.r[4],j=this.r[5],B=this.r[6],z=this.r[7],H=this.r[8],q=this.r[9];n>=16;)d=l=0,d+=(k+=8191&(r=255&t[e+0]|(255&t[e+1])<<8))*U,d+=(C+=8191&(r>>>13|(i=255&t[e+2]|(255&t[e+3])<<8)<<3))*(5*q),d+=(T+=8191&(i>>>10|(s=255&t[e+4]|(255&t[e+5])<<8)<<6))*(5*H),d+=(E+=8191&(s>>>7|(o=255&t[e+6]|(255&t[e+7])<<8)<<9))*(5*z),l=(d+=(P+=8191&(o>>>4|(a=255&t[e+8]|(255&t[e+9])<<8)<<12))*(5*B))>>>13,d&=8191,d+=(x+=a>>>1&8191)*(5*j),d+=(A+=8191&(a>>>14|(c=255&t[e+10]|(255&t[e+11])<<8)<<2))*(5*N),d+=(O+=8191&(c>>>11|(h=255&t[e+12]|(255&t[e+13])<<8)<<5))*(5*D),d+=(L+=8191&(h>>>8|(u=255&t[e+14]|(255&t[e+15])<<8)<<8))*(5*M),p=l+=(d+=(R+=u>>>5|S)*(5*I))>>>13,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=g&=8191,P=v&=8191,x=b&=8191,A=y&=8191,O=m&=8191,L=w&=8191,R=_&=8191,e+=16,n-=16;this.h[0]=k,this.h[1]=C,this.h[2]=T,this.h[3]=E,this.h[4]=P,this.h[5]=x,this.h[6]=A,this.h[7]=O,this.h[8]=L,this.h[9]=R},T.prototype.finish=function(t,e){var n,r,i,s,o=new Uint16Array(10);if(this.leftover){for(s=this.leftover,this.buffer[s++]=1;s<16;s++)this.buffer[s]=0;this.fin=1,this.blocks(this.buffer,0,16)}for(n=this.h[1]>>>13,this.h[1]&=8191,s=2;s<10;s++)this.h[s]+=n,n=this.h[s]>>>13,this.h[s]&=8191;for(this.h[0]+=5*n,n=this.h[0]>>>13,this.h[0]&=8191,this.h[1]+=n,n=this.h[1]>>>13,this.h[1]&=8191,this.h[2]+=n,o[0]=this.h[0]+5,n=o[0]>>>13,o[0]&=8191,s=1;s<10;s++)o[s]=this.h[s]+n,n=o[s]>>>13,o[s]&=8191;for(o[9]-=8192,r=(1^n)-1,s=0;s<10;s++)o[s]&=r;for(r=~r,s=0;s<10;s++)this.h[s]=this.h[s]&r|o[s];for(this.h[0]=65535&(this.h[0]|this.h[1]<<13),this.h[1]=65535&(this.h[1]>>>3|this.h[2]<<10),this.h[2]=65535&(this.h[2]>>>6|this.h[3]<<7),this.h[3]=65535&(this.h[3]>>>9|this.h[4]<<4),this.h[4]=65535&(this.h[4]>>>12|this.h[5]<<1|this.h[6]<<14),this.h[5]=65535&(this.h[6]>>>2|this.h[7]<<11),this.h[6]=65535&(this.h[7]>>>5|this.h[8]<<8),this.h[7]=65535&(this.h[8]>>>8|this.h[9]<<5),i=this.h[0]+this.pad[0],this.h[0]=65535&i,s=1;s<8;s++)i=(this.h[s]+this.pad[s]|0)+(i>>>16)|0,this.h[s]=65535&i;t[e+0]=this.h[0]>>>0&255,t[e+1]=this.h[0]>>>8&255,t[e+2]=this.h[1]>>>0&255,t[e+3]=this.h[1]>>>8&255,t[e+4]=this.h[2]>>>0&255,t[e+5]=this.h[2]>>>8&255,t[e+6]=this.h[3]>>>0&255,t[e+7]=this.h[3]>>>8&255,t[e+8]=this.h[4]>>>0&255,t[e+9]=this.h[4]>>>8&255,t[e+10]=this.h[5]>>>0&255,t[e+11]=this.h[5]>>>8&255,t[e+12]=this.h[6]>>>0&255,t[e+13]=this.h[6]>>>8&255,t[e+14]=this.h[7]>>>0&255,t[e+15]=this.h[7]>>>8&255},T.prototype.update=function(t,e,n){var r,i;if(this.leftover){for((i=16-this.leftover)>n&&(i=n),r=0;r=16&&(i=n-n%16,this.blocks(t,e,i),e+=i,n-=i),n){for(r=0;r=128;){for(S=0;S<16;S++)k=8*S+$,O[S]=n[k+0]<<24|n[k+1]<<16|n[k+2]<<8|n[k+3],L[S]=n[k+4]<<24|n[k+5]<<16|n[k+6]<<8|n[k+7];for(S=0;S<80;S++)if(i=R,s=U,o=I,a=M,c=D,h=N,u=j,B,d=z,p=H,f=q,g=F,v=X,b=J,y=Y,K,E=65535&(T=K),P=T>>>16,x=65535&(C=B),A=C>>>16,E+=65535&(T=(X>>>14|D<<18)^(X>>>18|D<<14)^(D>>>9|X<<23)),P+=T>>>16,x+=65535&(C=(D>>>14|X<<18)^(D>>>18|X<<14)^(X>>>9|D<<23)),A+=C>>>16,E+=65535&(T=X&J^~X&Y),P+=T>>>16,x+=65535&(C=D&N^~D&j),A+=C>>>16,E+=65535&(T=W[2*S+1]),P+=T>>>16,x+=65535&(C=W[2*S]),A+=C>>>16,C=O[S%16],P+=(T=L[S%16])>>>16,x+=65535&C,A+=C>>>16,x+=(P+=(E+=65535&T)>>>16)>>>16,E=65535&(T=_=65535&E|P<<16),P=T>>>16,x=65535&(C=w=65535&x|(A+=x>>>16)<<16),A=C>>>16,E+=65535&(T=(z>>>28|R<<4)^(R>>>2|z<<30)^(R>>>7|z<<25)),P+=T>>>16,x+=65535&(C=(R>>>28|z<<4)^(z>>>2|R<<30)^(z>>>7|R<<25)),A+=C>>>16,P+=(T=z&H^z&q^H&q)>>>16,x+=65535&(C=R&U^R&I^U&I),A+=C>>>16,l=65535&(x+=(P+=(E+=65535&T)>>>16)>>>16)|(A+=x>>>16)<<16,m=65535&E|P<<16,E=65535&(T=g),P=T>>>16,x=65535&(C=a),A=C>>>16,P+=(T=_)>>>16,x+=65535&(C=w),A+=C>>>16,U=i,I=s,M=o,D=a=65535&(x+=(P+=(E+=65535&T)>>>16)>>>16)|(A+=x>>>16)<<16,N=c,j=h,B=u,R=l,H=d,q=p,F=f,X=g=65535&E|P<<16,J=v,Y=b,K=y,z=m,S%16==15)for(k=0;k<16;k++)C=O[k],E=65535&(T=L[k]),P=T>>>16,x=65535&C,A=C>>>16,C=O[(k+9)%16],E+=65535&(T=L[(k+9)%16]),P+=T>>>16,x+=65535&C,A+=C>>>16,w=O[(k+1)%16],E+=65535&(T=((_=L[(k+1)%16])>>>1|w<<31)^(_>>>8|w<<24)^(_>>>7|w<<25)),P+=T>>>16,x+=65535&(C=(w>>>1|_<<31)^(w>>>8|_<<24)^w>>>7),A+=C>>>16,w=O[(k+14)%16],P+=(T=((_=L[(k+14)%16])>>>19|w<<13)^(w>>>29|_<<3)^(_>>>6|w<<26))>>>16,x+=65535&(C=(w>>>19|_<<13)^(_>>>29|w<<3)^w>>>6),A+=C>>>16,A+=(x+=(P+=(E+=65535&T)>>>16)>>>16)>>>16,O[k]=65535&x|A<<16,L[k]=65535&E|P<<16;E=65535&(T=z),P=T>>>16,x=65535&(C=R),A=C>>>16,C=t[0],P+=(T=e[0])>>>16,x+=65535&C,A+=C>>>16,A+=(x+=(P+=(E+=65535&T)>>>16)>>>16)>>>16,t[0]=R=65535&x|A<<16,e[0]=z=65535&E|P<<16,E=65535&(T=H),P=T>>>16,x=65535&(C=U),A=C>>>16,C=t[1],P+=(T=e[1])>>>16,x+=65535&C,A+=C>>>16,A+=(x+=(P+=(E+=65535&T)>>>16)>>>16)>>>16,t[1]=U=65535&x|A<<16,e[1]=H=65535&E|P<<16,E=65535&(T=q),P=T>>>16,x=65535&(C=I),A=C>>>16,C=t[2],P+=(T=e[2])>>>16,x+=65535&C,A+=C>>>16,A+=(x+=(P+=(E+=65535&T)>>>16)>>>16)>>>16,t[2]=I=65535&x|A<<16,e[2]=q=65535&E|P<<16,E=65535&(T=F),P=T>>>16,x=65535&(C=M),A=C>>>16,C=t[3],P+=(T=e[3])>>>16,x+=65535&C,A+=C>>>16,A+=(x+=(P+=(E+=65535&T)>>>16)>>>16)>>>16,t[3]=M=65535&x|A<<16,e[3]=F=65535&E|P<<16,E=65535&(T=X),P=T>>>16,x=65535&(C=D),A=C>>>16,C=t[4],P+=(T=e[4])>>>16,x+=65535&C,A+=C>>>16,A+=(x+=(P+=(E+=65535&T)>>>16)>>>16)>>>16,t[4]=D=65535&x|A<<16,e[4]=X=65535&E|P<<16,E=65535&(T=J),P=T>>>16,x=65535&(C=N),A=C>>>16,C=t[5],P+=(T=e[5])>>>16,x+=65535&C,A+=C>>>16,A+=(x+=(P+=(E+=65535&T)>>>16)>>>16)>>>16,t[5]=N=65535&x|A<<16,e[5]=J=65535&E|P<<16,E=65535&(T=Y),P=T>>>16,x=65535&(C=j),A=C>>>16,C=t[6],P+=(T=e[6])>>>16,x+=65535&C,A+=C>>>16,A+=(x+=(P+=(E+=65535&T)>>>16)>>>16)>>>16,t[6]=j=65535&x|A<<16,e[6]=Y=65535&E|P<<16,E=65535&(T=K),P=T>>>16,x=65535&(C=B),A=C>>>16,C=t[7],P+=(T=e[7])>>>16,x+=65535&C,A+=C>>>16,A+=(x+=(P+=(E+=65535&T)>>>16)>>>16)>>>16,t[7]=B=65535&x|A<<16,e[7]=K=65535&E|P<<16,$+=128,r-=128}return r}function V(t,e,n){var r,i=new Int32Array(8),s=new Int32Array(8),o=new Uint8Array(256),a=n;for(i[0]=1779033703,i[1]=3144134277,i[2]=1013904242,i[3]=2773480762,i[4]=1359893119,i[5]=2600822924,i[6]=528734635,i[7]=1541459225,s[0]=4089235720,s[1]=2227873595,s[2]=4271175723,s[3]=1595750129,s[4]=2917565137,s[5]=725511199,s[6]=4215389547,s[7]=327033209,G(i,s,e,n),n%=128,r=0;r=0;--i)Q(t,e,r=n[i/8|0]>>(7&i)&1),Z(e,t),Z(t,t),Q(t,e,r)}function nt(t,n){var r=[e(),e(),e(),e()];O(r[0],l),O(r[1],d),O(r[2],a),B(r[3],l,d),et(t,r,n)}function rt(t,n,i){var s,o=new Uint8Array(64),a=[e(),e(),e(),e()];for(i||r(n,32),V(o,n,32),o[0]&=248,o[31]&=127,o[31]|=64,nt(a,o),tt(t,a),s=0;s<32;s++)n[s+32]=t[s];return 0}var it=new Float64Array([237,211,245,92,26,99,18,88,214,156,247,162,222,249,222,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16]);function st(t,e){var n,r,i,s;for(r=63;r>=32;--r){for(n=0,i=r-32,s=r-12;i>4)*it[i],n=e[i]>>8,e[i]&=255;for(i=0;i<32;i++)e[i]-=n*it[i];for(r=0;r<32;r++)e[r+1]+=e[r]>>8,t[r]=255&e[r]}function ot(t){var e,n=new Float64Array(64);for(e=0;e<64;e++)n[e]=t[e];for(e=0;e<64;e++)t[e]=0;st(t,n)}function at(t,n,r,i){var s,o,a=new Uint8Array(64),c=new Uint8Array(64),h=new Uint8Array(64),u=new Float64Array(64),l=[e(),e(),e(),e()];V(a,i,32),a[0]&=248,a[31]&=127,a[31]|=64;var d=r+64;for(s=0;s>7&&j(t[0],o,t[0]),B(t[3],t[0],t[1]),0)}(d,i))return-1;for(s=0;s=0},t.sign.keyPair=function(){var t=new Uint8Array(32),e=new Uint8Array(64);return rt(t,e),{publicKey:t,secretKey:e}},t.sign.keyPair.fromSecretKey=function(t){if(ut(t),64!==t.length)throw new Error("bad secret key size");for(var e=new Uint8Array(32),n=0;n0)r.loading[t].push(n);else{r.loading[t]=[n];var i=ue.createScriptRequest(r.getPath(t,e)),s=r.receivers.create((function(e){if(r.receivers.remove(s),r.loading[t]){var n=r.loading[t];delete r.loading[t];for(var o=function(t){t||i.cleanup()},a=0;a>>6)+_(128|63&e):_(224|e>>>12&15)+_(128|e>>>6&63)+_(128|63&e)},P=function(t){return t.replace(/[^\x00-\x7F]/g,E)},x=function(t){var e=[0,2,1][t.length%3],n=t.charCodeAt(0)<<16|(t.length>1?t.charCodeAt(1):0)<<8|(t.length>2?t.charCodeAt(2):0);return[S.charAt(n>>>18),S.charAt(n>>>12&63),e>=2?"=":S.charAt(n>>>6&63),e>=1?"=":S.charAt(63&n)].join("")},A=window.btoa||function(t){return t.replace(/[\s\S]{1,3}/g,x)};var O=class{constructor(t,e,n,r){this.clear=e,this.timer=t(()=>{this.timer&&(this.timer=r(this.timer))},n)}isRunning(){return null!==this.timer}ensureAborted(){this.timer&&(this.clear(this.timer),this.timer=null)}};function L(t){window.clearTimeout(t)}function R(t){window.clearInterval(t)}class U extends O{constructor(t,e){super(setTimeout,L,t,(function(t){return e(),null}))}}class I extends O{constructor(t,e){super(setInterval,R,t,(function(t){return e(),t}))}}var M={now:()=>Date.now?Date.now():(new Date).valueOf(),defer:t=>new U(0,t),method(t,...e){var n=Array.prototype.slice.call(arguments,1);return function(e){return e[t].apply(e,n.concat(arguments))}}};function D(t,...e){for(var n=0;n{window.console&&window.console.log&&window.console.log(t)}}debug(...t){this.log(this.globalLog,t)}warn(...t){this.log(this.globalLogWarn,t)}error(...t){this.log(this.globalLogError,t)}globalLogWarn(t){window.console&&window.console.warn?window.console.warn(t):this.globalLog(t)}globalLogError(t){window.console&&window.console.error?window.console.error(t):this.globalLogWarn(t)}log(t,...e){var n=N.apply(this,arguments);if(Re.log)Re.log(n);else if(Re.logToConsole){t.bind(this)(n)}}},G=function(t,e,n,r,i){void 0===n.headers&&null==n.headersProvider||W.warn(`To send headers with the ${r.toString()} request, you must use AJAX, rather than JSONP.`);var s=t.nextAuthCallbackID.toString();t.nextAuthCallbackID++;var o=t.getDocument(),a=o.createElement("script");t.auth_callbacks[s]=function(t){i(null,t)};var c="Pusher.auth_callbacks['"+s+"']";a.src=n.endpoint+"?callback="+encodeURIComponent(c)+"&"+e;var h=o.getElementsByTagName("head")[0]||o.documentElement;h.insertBefore(a,h.firstChild)};class V{constructor(t){this.src=t}send(t){var e=this,n="Error loading "+e.src;e.script=document.createElement("script"),e.script.id=t.id,e.script.src=e.src,e.script.type="text/javascript",e.script.charset="UTF-8",e.script.addEventListener?(e.script.onerror=function(){t.callback(n)},e.script.onload=function(){t.callback(null)}):e.script.onreadystatechange=function(){"loaded"!==e.script.readyState&&"complete"!==e.script.readyState||t.callback(null)},void 0===e.script.async&&document.attachEvent&&/opera/i.test(navigator.userAgent)?(e.errorScript=document.createElement("script"),e.errorScript.id=t.id+"_error",e.errorScript.text=t.name+"('"+n+"');",e.script.async=e.errorScript.async=!1):e.script.async=!0;var r=document.getElementsByTagName("head")[0];r.insertBefore(e.script,r.firstChild),e.errorScript&&r.insertBefore(e.errorScript,e.script.nextSibling)}cleanup(){this.script&&(this.script.onload=this.script.onerror=null,this.script.onreadystatechange=null),this.script&&this.script.parentNode&&this.script.parentNode.removeChild(this.script),this.errorScript&&this.errorScript.parentNode&&this.errorScript.parentNode.removeChild(this.errorScript),this.script=null,this.errorScript=null}}class Z{constructor(t,e){this.url=t,this.data=e}send(t){if(!this.request){var e=K(this.data),n=this.url+"/"+t.number+"?"+e;this.request=ue.createScriptRequest(n),this.request.send(t)}}cleanup(){this.request&&this.request.cleanup()}}var Q={name:"jsonp",getAgent:function(t,e){return function(n,r){var s="http"+(e?"s":"")+"://"+(t.host||t.options.host)+t.options.path,o=ue.createJSONPRequest(s,n),a=ue.ScriptReceivers.create((function(e,n){i.remove(a),o.cleanup(),n&&n.host&&(t.host=n.host),r&&r(e,n)}));o.send(a)}}};function tt(t,e,n){return t+(e.useTLS?"s":"")+"://"+(e.useTLS?e.hostTLS:e.hostNonTLS)+n}function et(t,e){return"/app/"+t+("?protocol="+s.PROTOCOL+"&client=js&version="+s.VERSION+(e?"&"+e:""))}var nt={getInitial:function(t,e){return tt("ws",e,(e.httpPath||"")+et(t,"flash=false"))}},rt={getInitial:function(t,e){return tt("http",e,(e.httpPath||"/pusher")+et(t))}},it={getInitial:function(t,e){return tt("http",e,e.httpPath||"/pusher")},getPath:function(t,e){return et(t)}};class st{constructor(){this._callbacks={}}get(t){return this._callbacks[ot(t)]}add(t,e,n){var r=ot(t);this._callbacks[r]=this._callbacks[r]||[],this._callbacks[r].push({fn:e,context:n})}remove(t,e,n){if(t||e||n){var r=t?[ot(t)]:z(this._callbacks);e||n?this.removeCallback(r,e,n):this.removeAllCallbacks(r)}else this._callbacks={}}removeCallback(t,e,n){H(t,(function(t){this._callbacks[t]=F(this._callbacks[t]||[],(function(t){return e&&e!==t.fn||n&&n!==t.context})),0===this._callbacks[t].length&&delete this._callbacks[t]}),this)}removeAllCallbacks(t){H(t,(function(t){delete this._callbacks[t]}),this)}}function ot(t){return"_"+t}class at{constructor(t){this.callbacks=new st,this.global_callbacks=[],this.failThrough=t}bind(t,e,n){return this.callbacks.add(t,e,n),this}bind_global(t){return this.global_callbacks.push(t),this}unbind(t,e,n){return this.callbacks.remove(t,e,n),this}unbind_global(t){return t?(this.global_callbacks=F(this.global_callbacks||[],e=>e!==t),this):(this.global_callbacks=[],this)}unbind_all(){return this.unbind(),this.unbind_global(),this}emit(t,e,n){for(var r=0;r0)for(r=0;r{this.onError(t),this.changeState("closed")}),!1}return this.bindListeners(),W.debug("Connecting",{transport:this.name,url:t}),this.changeState("connecting"),!0}close(){return!!this.socket&&(this.socket.close(),!0)}send(t){return"open"===this.state&&(M.defer(()=>{this.socket&&this.socket.send(t)}),!0)}ping(){"open"===this.state&&this.supportsPing()&&this.socket.ping()}onOpen(){this.hooks.beforeOpen&&this.hooks.beforeOpen(this.socket,this.hooks.urls.getPath(this.key,this.options)),this.changeState("open"),this.socket.onopen=void 0}onError(t){this.emit("error",{type:"WebSocketError",error:t}),this.timeline.error(this.buildTimelineMessage({error:t.toString()}))}onClose(t){t?this.changeState("closed",{code:t.code,reason:t.reason,wasClean:t.wasClean}):this.changeState("closed"),this.unbindListeners(),this.socket=void 0}onMessage(t){this.emit("message",t)}onActivity(){this.emit("activity")}bindListeners(){this.socket.onopen=()=>{this.onOpen()},this.socket.onerror=t=>{this.onError(t)},this.socket.onclose=t=>{this.onClose(t)},this.socket.onmessage=t=>{this.onMessage(t)},this.supportsPing()&&(this.socket.onactivity=()=>{this.onActivity()})}unbindListeners(){this.socket&&(this.socket.onopen=void 0,this.socket.onerror=void 0,this.socket.onclose=void 0,this.socket.onmessage=void 0,this.supportsPing()&&(this.socket.onactivity=void 0))}changeState(t,e){this.state=t,this.timeline.info(this.buildTimelineMessage({state:t,params:e})),this.emit(t,e)}buildTimelineMessage(t){return D({cid:this.id},t)}}class ht{constructor(t){this.hooks=t}isSupported(t){return this.hooks.isSupported(t)}createConnection(t,e,n,r){return new ct(this.hooks,t,e,n,r)}}var ut=new ht({urls:nt,handlesActivityChecks:!1,supportsPing:!1,isInitialized:function(){return Boolean(ue.getWebSocketAPI())},isSupported:function(){return Boolean(ue.getWebSocketAPI())},getSocket:function(t){return ue.createWebSocket(t)}}),lt={urls:rt,handlesActivityChecks:!1,supportsPing:!0,isInitialized:function(){return!0}},dt=D({getSocket:function(t){return ue.HTTPFactory.createStreamingSocket(t)}},lt),pt=D({getSocket:function(t){return ue.HTTPFactory.createPollingSocket(t)}},lt),ft={isSupported:function(){return ue.isXHRSupported()}},gt={ws:ut,xhr_streaming:new ht(D({},dt,ft)),xhr_polling:new ht(D({},pt,ft))},vt=new ht({file:"sockjs",urls:it,handlesActivityChecks:!0,supportsPing:!1,isSupported:function(){return!0},isInitialized:function(){return void 0!==window.SockJS},getSocket:function(t,e){return new window.SockJS(t,null,{js_path:a.getPath("sockjs",{useTLS:e.useTLS}),ignore_null_origin:e.ignoreNullOrigin})},beforeOpen:function(t,e){t.send(JSON.stringify({path:e}))}}),bt={isSupported:function(t){return ue.isXDRSupported(t.useTLS)}},yt=new ht(D({},dt,bt)),mt=new ht(D({},pt,bt));gt.xdr_streaming=yt,gt.xdr_polling=mt,gt.sockjs=vt;var wt=gt;var _t=new class extends at{constructor(){super();var t=this;void 0!==window.addEventListener&&(window.addEventListener("online",(function(){t.emit("online")}),!1),window.addEventListener("offline",(function(){t.emit("offline")}),!1))}isOnline(){return void 0===window.navigator.onLine||window.navigator.onLine}};class St{constructor(t,e,n){this.manager=t,this.transport=e,this.minPingDelay=n.minPingDelay,this.maxPingDelay=n.maxPingDelay,this.pingDelay=void 0}createConnection(t,e,n,r){r=D({},r,{activityTimeout:this.pingDelay});var i=this.transport.createConnection(t,e,n,r),s=null,o=function(){i.unbind("open",o),i.bind("closed",a),s=M.now()},a=t=>{if(i.unbind("closed",a),1002===t.code||1003===t.code)this.manager.reportDeath();else if(!t.wasClean&&s){var e=M.now()-s;e<2*this.maxPingDelay&&(this.manager.reportDeath(),this.pingDelay=Math.max(e/2,this.minPingDelay))}};return i.bind("open",o),i}isSupported(t){return this.manager.isAlive()&&this.transport.isSupported(t)}}const kt={decodeMessage:function(t){try{var e=JSON.parse(t.data),n=e.data;if("string"==typeof n)try{n=JSON.parse(e.data)}catch(t){}var r={event:e.event,channel:e.channel,data:n};return e.user_id&&(r.user_id=e.user_id),r}catch(e){throw{type:"MessageParseError",error:e,data:t.data}}},encodeMessage:function(t){return JSON.stringify(t)},processHandshake:function(t){var e=kt.decodeMessage(t);if("pusher:connection_established"===e.event){if(!e.data.activity_timeout)throw"No activity timeout specified in handshake";return{action:"connected",id:e.data.socket_id,activityTimeout:1e3*e.data.activity_timeout}}if("pusher:error"===e.event)return{action:this.getCloseAction(e.data),error:this.getCloseError(e.data)};throw"Invalid handshake"},getCloseAction:function(t){return t.code<4e3?t.code>=1002&&t.code<=1004?"backoff":null:4e3===t.code?"tls_only":t.code<4100?"refused":t.code<4200?"backoff":t.code<4300?"retry":"refused"},getCloseError:function(t){return 1e3!==t.code&&1001!==t.code?{type:"PusherError",data:{code:t.code,message:t.reason||t.message}}:null}};var Ct=kt;class Tt extends at{constructor(t,e){super(),this.id=t,this.transport=e,this.activityTimeout=e.activityTimeout,this.bindListeners()}handlesActivityChecks(){return this.transport.handlesActivityChecks()}send(t){return this.transport.send(t)}send_event(t,e,n){var r={event:t,data:e};return n&&(r.channel=n),W.debug("Event sent",r),this.send(Ct.encodeMessage(r))}ping(){this.transport.supportsPing()?this.transport.ping():this.send_event("pusher:ping",{})}close(){this.transport.close()}bindListeners(){var t={message:t=>{var e;try{e=Ct.decodeMessage(t)}catch(e){this.emit("error",{type:"MessageParseError",error:e,data:t.data})}if(void 0!==e){switch(W.debug("Event recd",e),e.event){case"pusher:error":this.emit("error",{type:"PusherError",data:e.data});break;case"pusher:ping":this.emit("ping");break;case"pusher:pong":this.emit("pong")}this.emit("message",e)}},activity:()=>{this.emit("activity")},error:t=>{this.emit("error",t)},closed:t=>{e(),t&&t.code&&this.handleCloseEvent(t),this.transport=null,this.emit("closed")}},e=()=>{B(t,(t,e)=>{this.transport.unbind(e,t)})};B(t,(t,e)=>{this.transport.bind(e,t)})}handleCloseEvent(t){var e=Ct.getCloseAction(t),n=Ct.getCloseError(t);n&&this.emit("error",n),e&&this.emit(e,{action:e,error:n})}}class Et{constructor(t,e){this.transport=t,this.callback=e,this.bindListeners()}close(){this.unbindListeners(),this.transport.close()}bindListeners(){this.onMessage=t=>{var e;this.unbindListeners();try{e=Ct.processHandshake(t)}catch(t){return this.finish("error",{error:t}),void this.transport.close()}"connected"===e.action?this.finish("connected",{connection:new Tt(e.id,this.transport),activityTimeout:e.activityTimeout}):(this.finish(e.action,{error:e.error}),this.transport.close())},this.onClosed=t=>{this.unbindListeners();var e=Ct.getCloseAction(t)||"backoff",n=Ct.getCloseError(t);this.finish(e,{error:n})},this.transport.bind("message",this.onMessage),this.transport.bind("closed",this.onClosed)}unbindListeners(){this.transport.unbind("message",this.onMessage),this.transport.unbind("closed",this.onClosed)}finish(t,e){this.callback(D({transport:this.transport,action:t},e))}}class Pt{constructor(t,e){this.timeline=t,this.options=e||{}}send(t,e){this.timeline.isEmpty()||this.timeline.send(ue.TimelineTransport.getAgent(this,t),e)}}class xt extends at{constructor(t,e){super((function(e,n){W.debug("No callbacks on "+t+" for "+e)})),this.name=t,this.pusher=e,this.subscribed=!1,this.subscriptionPending=!1,this.subscriptionCancelled=!1}authorize(t,e){return e(null,{auth:""})}trigger(t,e){if(0!==t.indexOf("client-"))throw new l("Event '"+t+"' does not start with 'client-'");if(!this.subscribed){var n=u("triggeringClientEvents");W.warn("Client event triggered before channel 'subscription_succeeded' event . "+n)}return this.pusher.send_event(t,e,this.name)}disconnect(){this.subscribed=!1,this.subscriptionPending=!1}handleEvent(t){var e=t.event,n=t.data;if("pusher_internal:subscription_succeeded"===e)this.handleSubscriptionSucceededEvent(t);else if("pusher_internal:subscription_count"===e)this.handleSubscriptionCountEvent(t);else if(0!==e.indexOf("pusher_internal:")){this.emit(e,n,{})}}handleSubscriptionSucceededEvent(t){this.subscriptionPending=!1,this.subscribed=!0,this.subscriptionCancelled?this.pusher.unsubscribe(this.name):this.emit("pusher:subscription_succeeded",t.data)}handleSubscriptionCountEvent(t){t.data.subscription_count&&(this.subscriptionCount=t.data.subscription_count),this.emit("pusher:subscription_count",t.data)}subscribe(){this.subscribed||(this.subscriptionPending=!0,this.subscriptionCancelled=!1,this.authorize(this.pusher.connection.socket_id,(t,e)=>{t?(this.subscriptionPending=!1,W.error(t.toString()),this.emit("pusher:subscription_error",Object.assign({},{type:"AuthError",error:t.message},t instanceof m?{status:t.status}:{}))):this.pusher.send_event("pusher:subscribe",{auth:e.auth,channel_data:e.channel_data,channel:this.name})}))}unsubscribe(){this.subscribed=!1,this.pusher.send_event("pusher:unsubscribe",{channel:this.name})}cancelSubscription(){this.subscriptionCancelled=!0}reinstateSubscription(){this.subscriptionCancelled=!1}}class At extends xt{authorize(t,e){return this.pusher.config.channelAuthorizer({channelName:this.name,socketId:t},e)}}class Ot{constructor(){this.reset()}get(t){return Object.prototype.hasOwnProperty.call(this.members,t)?{id:t,info:this.members[t]}:null}each(t){B(this.members,(e,n)=>{t(this.get(n))})}setMyID(t){this.myID=t}onSubscription(t){this.members=t.presence.hash,this.count=t.presence.count,this.me=this.get(this.myID)}addMember(t){return null===this.get(t.user_id)&&this.count++,this.members[t.user_id]=t.user_info,this.get(t.user_id)}removeMember(t){var e=this.get(t.user_id);return e&&(delete this.members[t.user_id],this.count--),e}reset(){this.members={},this.count=0,this.myID=null,this.me=null}}var Lt=function(t,e,n,r){return new(n||(n=Promise))((function(i,s){function o(t){try{c(r.next(t))}catch(t){s(t)}}function a(t){try{c(r.throw(t))}catch(t){s(t)}}function c(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(o,a)}c((r=r.apply(t,e||[])).next())}))};class Rt extends At{constructor(t,e){super(t,e),this.members=new Ot}authorize(t,e){super.authorize(t,(t,n)=>Lt(this,void 0,void 0,(function*(){if(!t)if(null!=(n=n).channel_data){var r=JSON.parse(n.channel_data);this.members.setMyID(r.user_id)}else{if(yield this.pusher.user.signinDonePromise,null==this.pusher.user.user_data){let t=u("authorizationEndpoint");return W.error(`Invalid auth response for channel '${this.name}', expected 'channel_data' field. ${t}, or the user should be signed in.`),void e("Invalid auth response")}this.members.setMyID(this.pusher.user.user_data.id)}e(t,n)})))}handleEvent(t){var e=t.event;if(0===e.indexOf("pusher_internal:"))this.handleInternalEvent(t);else{var n=t.data,r={};t.user_id&&(r.user_id=t.user_id),this.emit(e,n,r)}}handleInternalEvent(t){var e=t.event,n=t.data;switch(e){case"pusher_internal:subscription_succeeded":this.handleSubscriptionSucceededEvent(t);break;case"pusher_internal:subscription_count":this.handleSubscriptionCountEvent(t);break;case"pusher_internal:member_added":var r=this.members.addMember(n);this.emit("pusher:member_added",r);break;case"pusher_internal:member_removed":var i=this.members.removeMember(n);i&&this.emit("pusher:member_removed",i)}}handleSubscriptionSucceededEvent(t){this.subscriptionPending=!1,this.subscribed=!0,this.subscriptionCancelled?this.pusher.unsubscribe(this.name):(this.members.onSubscription(t.data),this.emit("pusher:subscription_succeeded",this.members))}disconnect(){this.members.reset(),super.disconnect()}}var Ut=n(1),It=n(0);class Mt extends At{constructor(t,e,n){super(t,e),this.key=null,this.nacl=n}authorize(t,e){super.authorize(t,(t,n)=>{if(t)return void e(t,n);let r=n.shared_secret;r?(this.key=Object(It.decode)(r),delete n.shared_secret,e(null,n)):e(new Error("No shared_secret key in auth payload for encrypted channel: "+this.name),null)})}trigger(t,e){throw new v("Client events are not currently supported for encrypted channels")}handleEvent(t){var e=t.event,n=t.data;0!==e.indexOf("pusher_internal:")&&0!==e.indexOf("pusher:")?this.handleEncryptedEvent(e,n):super.handleEvent(t)}handleEncryptedEvent(t,e){if(!this.key)return void W.debug("Received encrypted event before key has been retrieved from the authEndpoint");if(!e.ciphertext||!e.nonce)return void W.error("Unexpected format for encrypted event, expected object with `ciphertext` and `nonce` fields, got: "+e);let n=Object(It.decode)(e.ciphertext);if(n.length{e?W.error(`Failed to make a request to the authEndpoint: ${s}. Unable to fetch new key, so dropping encrypted event`):(i=this.nacl.secretbox.open(n,r,this.key),null!==i?this.emit(t,this.getDataToEmit(i)):W.error("Failed to decrypt event with new key. Dropping encrypted event"))});this.emit(t,this.getDataToEmit(i))}getDataToEmit(t){let e=Object(Ut.decode)(t);try{return JSON.parse(e)}catch(t){return e}}}class Dt extends at{constructor(t,e){super(),this.state="initialized",this.connection=null,this.key=t,this.options=e,this.timeline=this.options.timeline,this.usingTLS=this.options.useTLS,this.errorCallbacks=this.buildErrorCallbacks(),this.connectionCallbacks=this.buildConnectionCallbacks(this.errorCallbacks),this.handshakeCallbacks=this.buildHandshakeCallbacks(this.errorCallbacks);var n=ue.getNetwork();n.bind("online",()=>{this.timeline.info({netinfo:"online"}),"connecting"!==this.state&&"unavailable"!==this.state||this.retryIn(0)}),n.bind("offline",()=>{this.timeline.info({netinfo:"offline"}),this.connection&&this.sendActivityCheck()}),this.updateStrategy()}switchCluster(t){this.key=t,this.updateStrategy(),this.retryIn(0)}connect(){this.connection||this.runner||(this.strategy.isSupported()?(this.updateState("connecting"),this.startConnecting(),this.setUnavailableTimer()):this.updateState("failed"))}send(t){return!!this.connection&&this.connection.send(t)}send_event(t,e,n){return!!this.connection&&this.connection.send_event(t,e,n)}disconnect(){this.disconnectInternally(),this.updateState("disconnected")}isUsingTLS(){return this.usingTLS}startConnecting(){var t=(e,n)=>{e?this.runner=this.strategy.connect(0,t):"error"===n.action?(this.emit("error",{type:"HandshakeError",error:n.error}),this.timeline.error({handshakeError:n.error})):(this.abortConnecting(),this.handshakeCallbacks[n.action](n))};this.runner=this.strategy.connect(0,t)}abortConnecting(){this.runner&&(this.runner.abort(),this.runner=null)}disconnectInternally(){(this.abortConnecting(),this.clearRetryTimer(),this.clearUnavailableTimer(),this.connection)&&this.abandonConnection().close()}updateStrategy(){this.strategy=this.options.getStrategy({key:this.key,timeline:this.timeline,useTLS:this.usingTLS})}retryIn(t){this.timeline.info({action:"retry",delay:t}),t>0&&this.emit("connecting_in",Math.round(t/1e3)),this.retryTimer=new U(t||0,()=>{this.disconnectInternally(),this.connect()})}clearRetryTimer(){this.retryTimer&&(this.retryTimer.ensureAborted(),this.retryTimer=null)}setUnavailableTimer(){this.unavailableTimer=new U(this.options.unavailableTimeout,()=>{this.updateState("unavailable")})}clearUnavailableTimer(){this.unavailableTimer&&this.unavailableTimer.ensureAborted()}sendActivityCheck(){this.stopActivityCheck(),this.connection.ping(),this.activityTimer=new U(this.options.pongTimeout,()=>{this.timeline.error({pong_timed_out:this.options.pongTimeout}),this.retryIn(0)})}resetActivityCheck(){this.stopActivityCheck(),this.connection&&!this.connection.handlesActivityChecks()&&(this.activityTimer=new U(this.activityTimeout,()=>{this.sendActivityCheck()}))}stopActivityCheck(){this.activityTimer&&this.activityTimer.ensureAborted()}buildConnectionCallbacks(t){return D({},t,{message:t=>{this.resetActivityCheck(),this.emit("message",t)},ping:()=>{this.send_event("pusher:pong",{})},activity:()=>{this.resetActivityCheck()},error:t=>{this.emit("error",t)},closed:()=>{this.abandonConnection(),this.shouldRetry()&&this.retryIn(1e3)}})}buildHandshakeCallbacks(t){return D({},t,{connected:t=>{this.activityTimeout=Math.min(this.options.activityTimeout,t.activityTimeout,t.connection.activityTimeout||1/0),this.clearUnavailableTimer(),this.setConnection(t.connection),this.socket_id=this.connection.id,this.updateState("connected",{socket_id:this.socket_id})}})}buildErrorCallbacks(){let t=t=>e=>{e.error&&this.emit("error",{type:"WebSocketError",error:e.error}),t(e)};return{tls_only:t(()=>{this.usingTLS=!0,this.updateStrategy(),this.retryIn(0)}),refused:t(()=>{this.disconnect()}),backoff:t(()=>{this.retryIn(1e3)}),retry:t(()=>{this.retryIn(0)})}}setConnection(t){for(var e in this.connection=t,this.connectionCallbacks)this.connection.bind(e,this.connectionCallbacks[e]);this.resetActivityCheck()}abandonConnection(){if(this.connection){for(var t in this.stopActivityCheck(),this.connectionCallbacks)this.connection.unbind(t,this.connectionCallbacks[t]);var e=this.connection;return this.connection=null,e}}updateState(t,e){var n=this.state;if(this.state=t,n!==t){var r=t;"connected"===r&&(r+=" with new socket ID "+e.socket_id),W.debug("State changed",n+" -> "+r),this.timeline.info({state:t,params:e}),this.emit("state_change",{previous:n,current:t}),this.emit(t,e)}}shouldRetry(){return"connecting"===this.state||"connected"===this.state}}class Nt{constructor(){this.channels={}}add(t,e){return this.channels[t]||(this.channels[t]=function(t,e){if(0===t.indexOf("private-encrypted-")){if(e.config.nacl)return jt.createEncryptedChannel(t,e,e.config.nacl);let n="Tried to subscribe to a private-encrypted- channel but no nacl implementation available",r=u("encryptedChannelSupport");throw new v(`${n}. ${r}`)}if(0===t.indexOf("private-"))return jt.createPrivateChannel(t,e);if(0===t.indexOf("presence-"))return jt.createPresenceChannel(t,e);if(0===t.indexOf("#"))throw new d('Cannot create a channel with name "'+t+'".');return jt.createChannel(t,e)}(t,e)),this.channels[t]}all(){return function(t){var e=[];return B(t,(function(t){e.push(t)})),e}(this.channels)}find(t){return this.channels[t]}remove(t){var e=this.channels[t];return delete this.channels[t],e}disconnect(){B(this.channels,(function(t){t.disconnect()}))}}var jt={createChannels:()=>new Nt,createConnectionManager:(t,e)=>new Dt(t,e),createChannel:(t,e)=>new xt(t,e),createPrivateChannel:(t,e)=>new At(t,e),createPresenceChannel:(t,e)=>new Rt(t,e),createEncryptedChannel:(t,e,n)=>new Mt(t,e,n),createTimelineSender:(t,e)=>new Pt(t,e),createHandshake:(t,e)=>new Et(t,e),createAssistantToTheTransportManager:(t,e,n)=>new St(t,e,n)};class Bt{constructor(t){this.options=t||{},this.livesLeft=this.options.lives||1/0}getAssistant(t){return jt.createAssistantToTheTransportManager(this,t,{minPingDelay:this.options.minPingDelay,maxPingDelay:this.options.maxPingDelay})}isAlive(){return this.livesLeft>0}reportDeath(){this.livesLeft-=1}}class zt{constructor(t,e){this.strategies=t,this.loop=Boolean(e.loop),this.failFast=Boolean(e.failFast),this.timeout=e.timeout,this.timeoutLimit=e.timeoutLimit}isSupported(){return J(this.strategies,M.method("isSupported"))}connect(t,e){var n=this.strategies,r=0,i=this.timeout,s=null,o=(a,c)=>{c?e(null,c):(r+=1,this.loop&&(r%=n.length),r0&&(i=new U(n.timeout,(function(){s.abort(),r(!0)}))),s=t.connect(e,(function(t,e){t&&i&&i.isRunning()&&!n.failFast||(i&&i.ensureAborted(),r(t,e))})),{abort:function(){i&&i.ensureAborted(),s.abort()},forceMinPriority:function(t){s.forceMinPriority(t)}}}}class Ht{constructor(t){this.strategies=t}isSupported(){return J(this.strategies,M.method("isSupported"))}connect(t,e){return function(t,e,n){var r=q(t,(function(t,r,i,s){return t.connect(e,n(r,s))}));return{abort:function(){H(r,qt)},forceMinPriority:function(t){H(r,(function(e){e.forceMinPriority(t)}))}}}(this.strategies,t,(function(t,n){return function(r,i){n[t].error=r,r?function(t){return function(t,e){for(var n=0;n=M.now()){var o=this.transports[r.transport];o&&(["ws","wss"].includes(r.transport)||i>3?(this.timeline.info({cached:!0,transport:r.transport,latency:r.latency}),s.push(new zt([o],{timeout:2*r.latency+1e3,failFast:!0}))):i++)}var a=M.now(),c=s.pop().connect(t,(function r(o,h){o?(Jt(n),s.length>0?(a=M.now(),c=s.pop().connect(t,r)):e(o)):(!function(t,e,n,r){var i=ue.getLocalStorage();if(i)try{i[Xt(t)]=$({timestamp:M.now(),transport:e,latency:n,cacheSkipCount:r})}catch(t){}}(n,h.transport.name,M.now()-a,i),e(null,h))}));return{abort:function(){c.abort()},forceMinPriority:function(e){t=e,c&&c.forceMinPriority(e)}}}}function Xt(t){return"pusherTransport"+(t?"TLS":"NonTLS")}function Jt(t){var e=ue.getLocalStorage();if(e)try{delete e[Xt(t)]}catch(t){}}class Yt{constructor(t,{delay:e}){this.strategy=t,this.options={delay:e}}isSupported(){return this.strategy.isSupported()}connect(t,e){var n,r=this.strategy,i=new U(this.options.delay,(function(){n=r.connect(t,e)}));return{abort:function(){i.ensureAborted(),n&&n.abort()},forceMinPriority:function(e){t=e,n&&n.forceMinPriority(e)}}}}class Kt{constructor(t,e,n){this.test=t,this.trueBranch=e,this.falseBranch=n}isSupported(){return(this.test()?this.trueBranch:this.falseBranch).isSupported()}connect(t,e){return(this.test()?this.trueBranch:this.falseBranch).connect(t,e)}}class $t{constructor(t){this.strategy=t}isSupported(){return this.strategy.isSupported()}connect(t,e){var n=this.strategy.connect(t,(function(t,r){r&&n.abort(),e(t,r)}));return n}}function Wt(t){return function(){return t.isSupported()}}var Gt=function(t,e,n){var r={};function i(e,i,s,o,a){var c=n(t,e,i,s,o,a);return r[e]=c,c}var s,o=Object.assign({},e,{hostNonTLS:t.wsHost+":"+t.wsPort,hostTLS:t.wsHost+":"+t.wssPort,httpPath:t.wsPath}),a=Object.assign({},o,{useTLS:!0}),c=Object.assign({},e,{hostNonTLS:t.httpHost+":"+t.httpPort,hostTLS:t.httpHost+":"+t.httpsPort,httpPath:t.httpPath}),h={loop:!0,timeout:15e3,timeoutLimit:6e4},u=new Bt({minPingDelay:1e4,maxPingDelay:t.activityTimeout}),l=new Bt({lives:2,minPingDelay:1e4,maxPingDelay:t.activityTimeout}),d=i("ws","ws",3,o,u),p=i("wss","ws",3,a,u),f=i("sockjs","sockjs",1,c),g=i("xhr_streaming","xhr_streaming",1,c,l),v=i("xdr_streaming","xdr_streaming",1,c,l),b=i("xhr_polling","xhr_polling",1,c),y=i("xdr_polling","xdr_polling",1,c),m=new zt([d],h),w=new zt([p],h),_=new zt([f],h),S=new zt([new Kt(Wt(g),g,v)],h),k=new zt([new Kt(Wt(b),b,y)],h),C=new zt([new Kt(Wt(S),new Ht([S,new Yt(k,{delay:4e3})]),k)],h),T=new Kt(Wt(C),C,_);return s=e.useTLS?new Ht([m,new Yt(T,{delay:2e3})]):new Ht([m,new Yt(w,{delay:2e3}),new Yt(T,{delay:5e3})]),new Ft(new $t(new Kt(Wt(d),s,T)),r,{ttl:18e5,timeline:e.timeline,useTLS:e.useTLS})},Vt={getRequest:function(t){var e=new window.XDomainRequest;return e.ontimeout=function(){t.emit("error",new p),t.close()},e.onerror=function(e){t.emit("error",e),t.close()},e.onprogress=function(){e.responseText&&e.responseText.length>0&&t.onChunk(200,e.responseText)},e.onload=function(){e.responseText&&e.responseText.length>0&&t.onChunk(200,e.responseText),t.emit("finished",200),t.close()},e},abortRequest:function(t){t.ontimeout=t.onerror=t.onprogress=t.onload=null,t.abort()}};class Zt extends at{constructor(t,e,n){super(),this.hooks=t,this.method=e,this.url=n}start(t){this.position=0,this.xhr=this.hooks.getRequest(this),this.unloader=()=>{this.close()},ue.addUnloadListener(this.unloader),this.xhr.open(this.method,this.url,!0),this.xhr.setRequestHeader&&this.xhr.setRequestHeader("Content-Type","application/json"),this.xhr.send(t)}close(){this.unloader&&(ue.removeUnloadListener(this.unloader),this.unloader=null),this.xhr&&(this.hooks.abortRequest(this.xhr),this.xhr=null)}onChunk(t,e){for(;;){var n=this.advanceBuffer(e);if(!n)break;this.emit("chunk",{status:t,data:n})}this.isBufferTooLong(e)&&this.emit("buffer_too_long")}advanceBuffer(t){var e=t.slice(this.position),n=e.indexOf("\n");return-1!==n?(this.position+=n+1,e.slice(0,n)):null}isBufferTooLong(t){return this.position===t.length&&t.length>262144}}var Qt;!function(t){t[t.CONNECTING=0]="CONNECTING",t[t.OPEN=1]="OPEN",t[t.CLOSED=3]="CLOSED"}(Qt||(Qt={}));var te=Qt,ee=1;function ne(t){var e=-1===t.indexOf("?")?"?":"&";return t+e+"t="+ +new Date+"&n="+ee++}function re(t){return ue.randomInt(t)}var ie,se=class{constructor(t,e){this.hooks=t,this.session=re(1e3)+"/"+function(t){for(var e=[],n=0;n{this.onChunk(t)}),this.stream.bind("finished",t=>{this.hooks.onFinished(this,t)}),this.stream.bind("buffer_too_long",()=>{this.reconnect()});try{this.stream.start()}catch(t){M.defer(()=>{this.onError(t),this.onClose(1006,"Could not start streaming",!1)})}}closeStream(){this.stream&&(this.stream.unbind_all(),this.stream.close(),this.stream=null)}},oe={getReceiveURL:function(t,e){return t.base+"/"+e+"/xhr_streaming"+t.queryString},onHeartbeat:function(t){t.sendRaw("[]")},sendHeartbeat:function(t){t.sendRaw("[]")},onFinished:function(t,e){t.onClose(1006,"Connection interrupted ("+e+")",!1)}},ae={getReceiveURL:function(t,e){return t.base+"/"+e+"/xhr"+t.queryString},onHeartbeat:function(){},sendHeartbeat:function(t){t.sendRaw("[]")},onFinished:function(t,e){200===e?t.reconnect():t.onClose(1006,"Connection interrupted ("+e+")",!1)}},ce={getRequest:function(t){var e=new(ue.getXHRAPI());return e.onreadystatechange=e.onprogress=function(){switch(e.readyState){case 3:e.responseText&&e.responseText.length>0&&t.onChunk(e.status,e.responseText);break;case 4:e.responseText&&e.responseText.length>0&&t.onChunk(e.status,e.responseText),t.emit("finished",e.status),t.close()}},e},abortRequest:function(t){t.onreadystatechange=null,t.abort()}},he={createStreamingSocket(t){return this.createSocket(oe,t)},createPollingSocket(t){return this.createSocket(ae,t)},createSocket:(t,e)=>new se(t,e),createXHR(t,e){return this.createRequest(ce,t,e)},createRequest:(t,e,n)=>new Zt(t,e,n),createXDR:function(t,e){return this.createRequest(Vt,t,e)}},ue={nextAuthCallbackID:1,auth_callbacks:{},ScriptReceivers:i,DependenciesReceivers:o,getDefaultStrategy:Gt,Transports:wt,transportConnectionInitializer:function(){var t=this;t.timeline.info(t.buildTimelineMessage({transport:t.name+(t.options.useTLS?"s":"")})),t.hooks.isInitialized()?t.changeState("initialized"):t.hooks.file?(t.changeState("initializing"),a.load(t.hooks.file,{useTLS:t.options.useTLS},(function(e,n){t.hooks.isInitialized()?(t.changeState("initialized"),n(!0)):(e&&t.onError(e),t.onClose(),n(!1))}))):t.onClose()},HTTPFactory:he,TimelineTransport:Q,getXHRAPI:()=>window.XMLHttpRequest,getWebSocketAPI:()=>window.WebSocket||window.MozWebSocket,setup(t){window.Pusher=t;var e=()=>{this.onDocumentBody(t.ready)};window.JSON?e():a.load("json2",{},e)},getDocument:()=>document,getProtocol(){return this.getDocument().location.protocol},getAuthorizers:()=>({ajax:w,jsonp:G}),onDocumentBody(t){document.body?t():setTimeout(()=>{this.onDocumentBody(t)},0)},createJSONPRequest:(t,e)=>new Z(t,e),createScriptRequest:t=>new V(t),getLocalStorage(){try{return window.localStorage}catch(t){return}},createXHR(){return this.getXHRAPI()?this.createXMLHttpRequest():this.createMicrosoftXHR()},createXMLHttpRequest(){return new(this.getXHRAPI())},createMicrosoftXHR:()=>new ActiveXObject("Microsoft.XMLHTTP"),getNetwork:()=>_t,createWebSocket(t){return new(this.getWebSocketAPI())(t)},createSocketRequest(t,e){if(this.isXHRSupported())return this.HTTPFactory.createXHR(t,e);if(this.isXDRSupported(0===e.indexOf("https:")))return this.HTTPFactory.createXDR(t,e);throw"Cross-origin HTTP requests are not supported"},isXHRSupported(){var t=this.getXHRAPI();return Boolean(t)&&void 0!==(new t).withCredentials},isXDRSupported(t){var e=t?"https:":"http:",n=this.getProtocol();return Boolean(window.XDomainRequest)&&n===e},addUnloadListener(t){void 0!==window.addEventListener?window.addEventListener("unload",t,!1):void 0!==window.attachEvent&&window.attachEvent("onunload",t)},removeUnloadListener(t){void 0!==window.addEventListener?window.removeEventListener("unload",t,!1):void 0!==window.detachEvent&&window.detachEvent("onunload",t)},randomInt:t=>Math.floor((window.crypto||window.msCrypto).getRandomValues(new Uint32Array(1))[0]/Math.pow(2,32)*t)};!function(t){t[t.ERROR=3]="ERROR",t[t.INFO=6]="INFO",t[t.DEBUG=7]="DEBUG"}(ie||(ie={}));var le=ie;class de{constructor(t,e,n){this.key=t,this.session=e,this.events=[],this.options=n||{},this.sent=0,this.uniqueID=0}log(t,e){t<=this.options.level&&(this.events.push(D({},e,{timestamp:M.now()})),this.options.limit&&this.events.length>this.options.limit&&this.events.shift())}error(t){this.log(le.ERROR,t)}info(t){this.log(le.INFO,t)}debug(t){this.log(le.DEBUG,t)}isEmpty(){return 0===this.events.length}send(t,e){var n=D({session:this.session,bundle:this.sent+1,key:this.key,lib:"js",version:this.options.version,cluster:this.options.cluster,features:this.options.features,timeline:this.events},this.options.params);return this.events=[],t(n,(t,n)=>{t||this.sent++,e&&e(t,n)}),!0}generateUniqueID(){return this.uniqueID++,this.uniqueID}}class pe{constructor(t,e,n,r){this.name=t,this.priority=e,this.transport=n,this.options=r||{}}isSupported(){return this.transport.isSupported({useTLS:this.options.useTLS})}connect(t,e){if(!this.isSupported())return fe(new y,e);if(this.priority{n||(h(),i?i.close():r.close())},forceMinPriority:t=>{n||this.priority{if(void 0===ue.getAuthorizers()[t.transport])throw`'${t.transport}' is not a recognized auth transport`;return(e,n)=>{const r=((t,e)=>{var n="socket_id="+encodeURIComponent(t.socketId);for(var r in e.params)n+="&"+encodeURIComponent(r)+"="+encodeURIComponent(e.params[r]);if(null!=e.paramsProvider){let t=e.paramsProvider();for(var r in t)n+="&"+encodeURIComponent(r)+"="+encodeURIComponent(t[r])}return n})(e,t);ue.getAuthorizers()[t.transport](ue,r,t,h.UserAuthentication,n)}};var we=t=>{if(void 0===ue.getAuthorizers()[t.transport])throw`'${t.transport}' is not a recognized auth transport`;return(e,n)=>{const r=((t,e)=>{var n="socket_id="+encodeURIComponent(t.socketId);for(var r in n+="&channel_name="+encodeURIComponent(t.channelName),e.params)n+="&"+encodeURIComponent(r)+"="+encodeURIComponent(e.params[r]);if(null!=e.paramsProvider){let t=e.paramsProvider();for(var r in t)n+="&"+encodeURIComponent(r)+"="+encodeURIComponent(t[r])}return n})(e,t);ue.getAuthorizers()[t.transport](ue,r,t,h.ChannelAuthorization,n)}};function _e(t,e){let n={activityTimeout:t.activityTimeout||s.activityTimeout,cluster:t.cluster,httpPath:t.httpPath||s.httpPath,httpPort:t.httpPort||s.httpPort,httpsPort:t.httpsPort||s.httpsPort,pongTimeout:t.pongTimeout||s.pongTimeout,statsHost:t.statsHost||s.stats_host,unavailableTimeout:t.unavailableTimeout||s.unavailableTimeout,wsPath:t.wsPath||s.wsPath,wsPort:t.wsPort||s.wsPort,wssPort:t.wssPort||s.wssPort,enableStats:Te(t),httpHost:Se(t),useTLS:Ce(t),wsHost:ke(t),userAuthenticator:Ee(t),channelAuthorizer:Pe(t,e)};return"disabledTransports"in t&&(n.disabledTransports=t.disabledTransports),"enabledTransports"in t&&(n.enabledTransports=t.enabledTransports),"ignoreNullOrigin"in t&&(n.ignoreNullOrigin=t.ignoreNullOrigin),"timelineParams"in t&&(n.timelineParams=t.timelineParams),"nacl"in t&&(n.nacl=t.nacl),n}function Se(t){return t.httpHost?t.httpHost:t.cluster?`sockjs-${t.cluster}.pusher.com`:s.httpHost}function ke(t){return t.wsHost?t.wsHost:`ws-${t.cluster}.pusher.com`}function Ce(t){return"https:"===ue.getProtocol()||!1!==t.forceTLS}function Te(t){return"enableStats"in t?t.enableStats:"disableStats"in t&&!t.disableStats}function Ee(t){const e=Object.assign(Object.assign({},s.userAuthentication),t.userAuthentication);return"customHandler"in e&&null!=e.customHandler?e.customHandler:me(e)}function Pe(t,e){const n=function(t,e){let n;return"channelAuthorization"in t?n=Object.assign(Object.assign({},s.channelAuthorization),t.channelAuthorization):(n={transport:t.authTransport||s.authTransport,endpoint:t.authEndpoint||s.authEndpoint},"auth"in t&&("params"in t.auth&&(n.params=t.auth.params),"headers"in t.auth&&(n.headers=t.auth.headers)),"authorizer"in t&&(n.customHandler=((t,e,n)=>{const r={authTransport:e.transport,authEndpoint:e.endpoint,auth:{params:e.params,headers:e.headers}};return(e,i)=>{const s=t.channel(e.channelName);n(s,r).authorize(e.socketId,i)}})(e,n,t.authorizer))),n}(t,e);return"customHandler"in n&&null!=n.customHandler?n.customHandler:we(n)}class xe extends at{constructor(t){super((function(t,e){W.debug("No callbacks on watchlist events for "+t)})),this.pusher=t,this.bindWatchlistInternalEvent()}handleEvent(t){t.data.events.forEach(t=>{this.emit(t.name,t)})}bindWatchlistInternalEvent(){this.pusher.connection.bind("message",t=>{"pusher_internal:watchlist_events"===t.event&&this.handleEvent(t)})}}var Ae=function(){let t,e;return{promise:new Promise((n,r)=>{t=n,e=r}),resolve:t,reject:e}};class Oe extends at{constructor(t){super((function(t,e){W.debug("No callbacks on user for "+t)})),this.signin_requested=!1,this.user_data=null,this.serverToUserChannel=null,this.signinDonePromise=null,this._signinDoneResolve=null,this._onAuthorize=(t,e)=>{if(t)return W.warn("Error during signin: "+t),void this._cleanup();this.pusher.send_event("pusher:signin",{auth:e.auth,user_data:e.user_data})},this.pusher=t,this.pusher.connection.bind("state_change",({previous:t,current:e})=>{"connected"!==t&&"connected"===e&&this._signin(),"connected"===t&&"connected"!==e&&(this._cleanup(),this._newSigninPromiseIfNeeded())}),this.watchlist=new xe(t),this.pusher.connection.bind("message",t=>{"pusher:signin_success"===t.event&&this._onSigninSuccess(t.data),this.serverToUserChannel&&this.serverToUserChannel.name===t.channel&&this.serverToUserChannel.handleEvent(t)})}signin(){this.signin_requested||(this.signin_requested=!0,this._signin())}_signin(){this.signin_requested&&(this._newSigninPromiseIfNeeded(),"connected"===this.pusher.connection.state&&this.pusher.config.userAuthenticator({socketId:this.pusher.connection.socket_id},this._onAuthorize))}_onSigninSuccess(t){try{this.user_data=JSON.parse(t.user_data)}catch(e){return W.error("Failed parsing user data after signin: "+t.user_data),void this._cleanup()}if("string"!=typeof this.user_data.id||""===this.user_data.id)return W.error("user_data doesn't contain an id. user_data: "+this.user_data),void this._cleanup();this._signinDoneResolve(),this._subscribeChannels()}_subscribeChannels(){this.serverToUserChannel=new xt("#server-to-user-"+this.user_data.id,this.pusher),this.serverToUserChannel.bind_global((t,e)=>{0!==t.indexOf("pusher_internal:")&&0!==t.indexOf("pusher:")&&this.emit(t,e)}),(t=>{t.subscriptionPending&&t.subscriptionCancelled?t.reinstateSubscription():t.subscriptionPending||"connected"!==this.pusher.connection.state||t.subscribe()})(this.serverToUserChannel)}_cleanup(){this.user_data=null,this.serverToUserChannel&&(this.serverToUserChannel.unbind_all(),this.serverToUserChannel.disconnect(),this.serverToUserChannel=null),this.signin_requested&&this._signinDoneResolve()}_newSigninPromiseIfNeeded(){if(!this.signin_requested)return;if(this.signinDonePromise&&!this.signinDonePromise.done)return;const{promise:t,resolve:e,reject:n}=Ae();t.done=!1;const r=()=>{t.done=!0};t.then(r).catch(r),this.signinDonePromise=t,this._signinDoneResolve=e}}class Le{static ready(){Le.isReady=!0;for(var t=0,e=Le.instances.length;tue.getDefaultStrategy(this.config,t,ve),timeline:this.timeline,activityTimeout:this.config.activityTimeout,pongTimeout:this.config.pongTimeout,unavailableTimeout:this.config.unavailableTimeout,useTLS:Boolean(this.config.useTLS)}),this.connection.bind("connected",()=>{this.subscribeAll(),this.timelineSender&&this.timelineSender.send(this.connection.isUsingTLS())}),this.connection.bind("message",t=>{var e=0===t.event.indexOf("pusher_internal:");if(t.channel){var n=this.channel(t.channel);n&&n.handleEvent(t)}e||this.global_emitter.emit(t.event,t.data)}),this.connection.bind("connecting",()=>{this.channels.disconnect()}),this.connection.bind("disconnected",()=>{this.channels.disconnect()}),this.connection.bind("error",t=>{W.warn(t)}),Le.instances.push(this),this.timeline.info({instances:Le.instances.length}),this.user=new Oe(this),Le.isReady&&this.connect()}switchCluster(t){const{appKey:e,cluster:n}=t;this.key=e,this.options=Object.assign(Object.assign({},this.options),{cluster:n}),this.config=_e(this.options,this),this.connection.switchCluster(this.key)}channel(t){return this.channels.find(t)}allChannels(){return this.channels.all()}connect(){if(this.connection.connect(),this.timelineSender&&!this.timelineSenderTimer){var t=this.connection.isUsingTLS(),e=this.timelineSender;this.timelineSenderTimer=new I(6e4,(function(){e.send(t)}))}}disconnect(){this.connection.disconnect(),this.timelineSenderTimer&&(this.timelineSenderTimer.ensureAborted(),this.timelineSenderTimer=null)}bind(t,e,n){return this.global_emitter.bind(t,e,n),this}unbind(t,e,n){return this.global_emitter.unbind(t,e,n),this}bind_global(t){return this.global_emitter.bind_global(t),this}unbind_global(t){return this.global_emitter.unbind_global(t),this}unbind_all(t){return this.global_emitter.unbind_all(),this}subscribeAll(){var t;for(t in this.channels.channels)this.channels.channels.hasOwnProperty(t)&&this.subscribe(t)}subscribe(t){var e=this.channels.add(t,this);return e.subscriptionPending&&e.subscriptionCancelled?e.reinstateSubscription():e.subscriptionPending||"connected"!==this.connection.state||e.subscribe(),e}unsubscribe(t){var e=this.channels.find(t);e&&e.subscriptionPending?e.cancelSubscription():(e=this.channels.remove(t))&&e.subscribed&&e.unsubscribe()}send_event(t,e,n){return this.connection.send_event(t,e,n)}shouldUseTLS(){return this.config.useTLS}signin(){this.user.signin()}}Le.instances=[],Le.isReady=!1,Le.logToConsole=!1,Le.Runtime=ue,Le.ScriptReceivers=ue.ScriptReceivers,Le.DependenciesReceivers=ue.DependenciesReceivers,Le.auth_callbacks=ue.auth_callbacks;var Re=Le;ue.setup(Le);var Ue=n(2);class Ie extends Re{constructor(t,e){Re.logToConsole=Ie.logToConsole,Re.log=Ie.log,ye(e),e.nacl=Ue,super(t,e)}}}])})); //# sourceMappingURL=pusher-with-encryption.min.js.map \ No newline at end of file diff --git a/dist/web/pusher-with-encryption.min.js.map b/dist/web/pusher-with-encryption.min.js.map index ad9819176..a91b0d5eb 100644 --- a/dist/web/pusher-with-encryption.min.js.map +++ b/dist/web/pusher-with-encryption.min.js.map @@ -1 +1 @@ -{"version":3,"sources":["webpack://Pusher/webpack/universalModuleDefinition","webpack://Pusher/webpack/bootstrap","webpack://Pusher/./node_modules/@stablelib/base64/base64.ts","webpack://Pusher/./node_modules/@stablelib/utf8/utf8.ts","webpack://Pusher/./node_modules/tweetnacl/nacl-fast.js","webpack://Pusher/./src/core/pusher-with-encryption.js","webpack://Pusher/./src/runtimes/web/dom/script_receiver_factory.ts","webpack://Pusher/./src/core/defaults.ts","webpack://Pusher/./src/runtimes/web/dom/dependencies.ts","webpack://Pusher/./src/runtimes/web/dom/dependency_loader.ts","webpack://Pusher/./src/core/utils/url_store.ts","webpack://Pusher/./src/core/auth/options.ts","webpack://Pusher/./src/core/errors.ts","webpack://Pusher/./src/runtimes/isomorphic/auth/xhr_auth.ts","webpack://Pusher/./src/core/base64.ts","webpack://Pusher/./src/core/utils/timers/abstract_timer.ts","webpack://Pusher/./src/core/utils/timers/index.ts","webpack://Pusher/./src/core/util.ts","webpack://Pusher/./src/core/utils/collections.ts","webpack://Pusher/./src/core/logger.ts","webpack://Pusher/./src/runtimes/web/auth/jsonp_auth.ts","webpack://Pusher/./src/runtimes/web/dom/script_request.ts","webpack://Pusher/./src/runtimes/web/dom/jsonp_request.ts","webpack://Pusher/./src/runtimes/web/timeline/jsonp_timeline.ts","webpack://Pusher/./src/core/transports/url_schemes.ts","webpack://Pusher/./src/core/events/callback_registry.ts","webpack://Pusher/./src/core/events/dispatcher.ts","webpack://Pusher/./src/core/transports/transport_connection.ts","webpack://Pusher/./src/core/transports/transport.ts","webpack://Pusher/./src/runtimes/isomorphic/transports/transports.ts","webpack://Pusher/./src/runtimes/web/transports/transports.ts","webpack://Pusher/./src/runtimes/web/net_info.ts","webpack://Pusher/./src/core/transports/assistant_to_the_transport_manager.ts","webpack://Pusher/./src/core/connection/protocol/protocol.ts","webpack://Pusher/./src/core/connection/connection.ts","webpack://Pusher/./src/core/connection/handshake/index.ts","webpack://Pusher/./src/core/timeline/timeline_sender.ts","webpack://Pusher/./src/core/channels/channel.ts","webpack://Pusher/./src/core/channels/private_channel.ts","webpack://Pusher/./src/core/channels/members.ts","webpack://Pusher/./src/core/channels/presence_channel.ts","webpack://Pusher/./src/core/channels/encrypted_channel.ts","webpack://Pusher/./src/core/connection/connection_manager.ts","webpack://Pusher/./src/core/channels/channels.ts","webpack://Pusher/./src/core/utils/factory.ts","webpack://Pusher/./src/core/transports/transport_manager.ts","webpack://Pusher/./src/core/strategies/sequential_strategy.ts","webpack://Pusher/./src/core/strategies/best_connected_ever_strategy.ts","webpack://Pusher/./src/core/strategies/websocket_prioritized_cached_strategy.ts","webpack://Pusher/./src/core/strategies/delayed_strategy.ts","webpack://Pusher/./src/core/strategies/if_strategy.ts","webpack://Pusher/./src/core/strategies/first_connected_strategy.ts","webpack://Pusher/./src/runtimes/web/default_strategy.ts","webpack://Pusher/./src/runtimes/web/http/http_xdomain_request.ts","webpack://Pusher/./src/core/http/http_request.ts","webpack://Pusher/./src/core/http/state.ts","webpack://Pusher/./src/core/http/http_socket.ts","webpack://Pusher/./src/core/timeline/level.ts","webpack://Pusher/./src/core/http/http_streaming_socket.ts","webpack://Pusher/./src/core/http/http_polling_socket.ts","webpack://Pusher/./src/runtimes/isomorphic/http/http_xhr_request.ts","webpack://Pusher/./src/runtimes/isomorphic/http/http.ts","webpack://Pusher/./src/runtimes/web/http/http.ts","webpack://Pusher/./src/runtimes/web/runtime.ts","webpack://Pusher/./src/runtimes/web/transports/transport_connection_initializer.ts","webpack://Pusher/./src/core/timeline/timeline.ts","webpack://Pusher/./src/core/strategies/transport_strategy.ts","webpack://Pusher/./src/core/strategies/strategy_builder.ts","webpack://Pusher/./src/core/options.ts","webpack://Pusher/./src/core/auth/user_authenticator.ts","webpack://Pusher/./src/core/auth/channel_authorizer.ts","webpack://Pusher/./src/core/config.ts","webpack://Pusher/./src/core/auth/deprecated_channel_authorizer.ts","webpack://Pusher/./src/core/watchlist.ts","webpack://Pusher/./src/core/utils/flat_promise.ts","webpack://Pusher/./src/core/user.ts","webpack://Pusher/./src/core/pusher.ts","webpack://Pusher/./src/core/pusher-with-encryption.ts"],"names":["root","factory","exports","module","define","amd","window","installedModules","__webpack_require__","moduleId","i","l","modules","call","m","c","d","name","getter","o","Object","defineProperty","enumerable","get","r","Symbol","toStringTag","value","t","mode","__esModule","ns","create","key","bind","n","object","property","prototype","hasOwnProperty","p","s","_paddingCharacter","encodedLength","length","this","encode","data","out","_encodeByte","left","maxDecodedLength","decodedLength","_getPaddingLength","decode","Uint8Array","paddingLength","op","haveBad","v0","v1","v2","v3","_decodeChar","charCodeAt","Error","b","result","String","fromCharCode","Coder","stdCoder","URLSafeCoder","urlSafeCoder","INVALID_UTF8","arr","pos","chars","min","n1","n2","n3","push","join","nacl","gf","init","Float64Array","randombytes","_0","_9","gf0","gf1","_121665","D","D2","X","Y","I","ts64","x","h","vn","xi","y","yi","crypto_verify_16","crypto_verify_32","crypto_core_salsa20","inp","k","u","j0","j1","j2","j3","j4","j5","j6","j7","j8","j9","j10","j11","j12","j13","j14","j15","x0","x1","x2","x3","x4","x5","x6","x7","x8","x9","x10","x11","x12","x13","x14","x15","core_salsa20","crypto_core_hsalsa20","core_hsalsa20","sigma","crypto_stream_salsa20_xor","cpos","mpos","z","crypto_stream_salsa20","crypto_stream","sn","crypto_stream_xor","poly1305","t0","t1","t2","t3","t4","t5","t6","t7","buffer","Uint16Array","pad","leftover","fin","crypto_onetimeauth","outpos","update","finish","crypto_onetimeauth_verify","hpos","crypto_secretbox","crypto_secretbox_open","set25519","a","car25519","v","Math","floor","sel25519","q","pack25519","j","neq25519","par25519","unpack25519","A","Z","M","t8","t9","t10","t11","t12","t13","t14","t15","t16","t17","t18","t19","t20","t21","t22","t23","t24","t25","t26","t27","t28","t29","t30","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","b10","b11","b12","b13","b14","b15","S","inv25519","pow2523","crypto_scalarmult","e","f","x32","subarray","x16","crypto_scalarmult_base","crypto_box_keypair","crypto_box_beforenm","blocks","bytes","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","hibit","h0","h1","h2","h3","h4","h5","h6","h7","h8","h9","r0","r1","r2","r3","r4","r5","r6","r7","r8","r9","mac","macpos","mask","g","want","crypto_box_afternm","crypto_box_open_afternm","K","crypto_hashblocks_hl","hh","hl","bh0","bh1","bh2","bh3","bh4","bh5","bh6","bh7","bl0","bl1","bl2","bl3","bl4","bl5","bl6","bl7","th","tl","wh","Int32Array","wl","ah0","ah1","ah2","ah3","ah4","ah5","ah6","ah7","al0","al1","al2","al3","al4","al5","al6","al7","crypto_hash","add","cswap","pack","tx","ty","zi","scalarmult","scalarbase","crypto_sign_keypair","pk","sk","seeded","L","modL","carry","reduce","crypto_sign","sm","smlen","crypto_sign_open","chk","num","den","den2","den4","den6","unpackneg","checkLengths","checkArrayTypes","arguments","TypeError","cleanup","lowlevel","crypto_box","crypto_box_open","crypto_secretbox_KEYBYTES","crypto_secretbox_NONCEBYTES","crypto_secretbox_ZEROBYTES","crypto_secretbox_BOXZEROBYTES","crypto_scalarmult_BYTES","crypto_scalarmult_SCALARBYTES","crypto_box_PUBLICKEYBYTES","crypto_box_SECRETKEYBYTES","crypto_box_BEFORENMBYTES","crypto_box_NONCEBYTES","crypto_box_ZEROBYTES","crypto_box_BOXZEROBYTES","crypto_sign_BYTES","crypto_sign_PUBLICKEYBYTES","crypto_sign_SECRETKEYBYTES","crypto_sign_SEEDBYTES","crypto_hash_BYTES","randomBytes","secretbox","msg","nonce","open","box","keyLength","nonceLength","overheadLength","scalarMult","base","scalarLength","groupElementLength","publicKey","secretKey","before","checkBoxLengths","after","keyPair","fromSecretKey","publicKeyLength","secretKeyLength","sharedKeyLength","sign","signedMsg","tmp","mlen","detached","sig","verify","fromSeed","seed","seedLength","signatureLength","hash","hashLength","setPRNG","fn","crypto","self","msCrypto","getRandomValues","default","ScriptReceiverFactory","prefix","lastId","callback","number","id","called","callbackWrapper","apply","receiver","ScriptReceivers","VERSION","PROTOCOL","wsPort","wssPort","wsPath","httpHost","httpPort","httpsPort","httpPath","stats_host","authEndpoint","authTransport","activityTimeout","pongTimeout","unavailableTimeout","userAuthentication","endpoint","transport","channelAuthorization","cdn_http","cdn_https","dependency_suffix","DependenciesReceivers","Dependencies","options","receivers","loading","request","createScriptRequest","getPath","error","remove","callbacks","successCallback","wasSuccessful","send","protocol","getDocument","location","useTLS","replace","version","getRoot","suffix","urlStore","baseUrl","urls","authenticationEndpoint","path","authorizationEndpoint","javascriptQuickStart","triggeringClientEvents","encryptedChannelSupport","fullUrl","AuthRequestType","urlObj","url","BadEventName","super","setPrototypeOf","BadChannelName","RequestTimedOut","TransportPriorityTooLow","TransportClosed","UnsupportedFeature","UnsupportedTransport","UnsupportedStrategy","HTTPAuthError","status","context","query","authOptions","authRequestType","xhr","createXHR","headerName","setRequestHeader","headers","headersProvider","dynamicHeaders","onreadystatechange","readyState","parsed","JSON","parse","responseText","toString","UserAuthentication","ChannelAuthorization","b64chars","b64tab","charAt","cb_utob","cc","utob","cb_encode","ccc","padlen","ord","btoa","set","clear","delay","timer","clearTimeout","clearInterval","setTimeout","setInterval","now","Date","valueOf","defer","args","boundArguments","Array","slice","concat","extend","target","sources","extensions","constructor","stringify","safeJSONStringify","arrayIndexOf","array","item","nativeIndexOf","indexOf","objectApply","keys","_","map","filter","test","filterObject","Boolean","any","encodeParamsObject","encodeURIComponent","buildQueryString","params","undefined","method","source","objects","paths","derez","nu","$ref","globalLog","message","console","log","globalLogWarn","globalLogError","warn","defaultLoggingFunction","logToConsole","callbackName","nextAuthCallbackID","document","script","createElement","auth_callbacks","callback_name","src","head","getElementsByTagName","documentElement","insertBefore","firstChild","ScriptRequest","errorString","type","charset","addEventListener","onerror","onload","async","attachEvent","navigator","userAgent","errorScript","text","nextSibling","parentNode","removeChild","getAgent","sender","host","createJSONPRequest","getGenericURL","baseScheme","hostTLS","hostNonTLS","getGenericPath","queryString","ws","getInitial","http","sockjs","_callbacks","prefixedEventName","names","removeCallback","removeAllCallbacks","binding","failThrough","global_callbacks","eventName","unbind","unbind_global","metadata","hooks","priority","initialize","transportConnectionInitializer","state","timeline","generateUniqueID","handlesActivityChecks","supportsPing","socket","getSocket","onError","changeState","bindListeners","debug","close","ping","beforeOpen","onopen","emit","buildTimelineMessage","closeEvent","code","reason","wasClean","unbindListeners","onOpen","onclose","onClose","onmessage","onMessage","onactivity","onActivity","info","cid","environment","isSupported","WSTransport","isInitialized","getWebSocketAPI","createWebSocket","httpConfiguration","streamingConfiguration","HTTPFactory","createStreamingSocket","pollingConfiguration","createPollingSocket","xhrConfiguration","isXHRSupported","xhr_streaming","xhr_polling","SockJSTransport","file","SockJS","js_path","ignore_null_origin","ignoreNullOrigin","xdrConfiguration","isXDRSupported","XDRStreamingTransport","XDRPollingTransport","xdr_streaming","xdr_polling","onLine","manager","minPingDelay","maxPingDelay","pingDelay","connection","createConnection","openTimestamp","onClosed","reportDeath","lifespan","max","isAlive","Protocol","decodeMessage","messageEvent","messageData","pusherEventData","pusherEvent","event","channel","user_id","encodeMessage","processHandshake","activity_timeout","action","socket_id","getCloseAction","getCloseError","send_event","listeners","activity","closed","handleCloseEvent","listener","isEmpty","TimelineTransport","pusher","subscribed","subscriptionPending","subscriptionCancelled","socketId","auth","handleSubscriptionSucceededEvent","handleSubscriptionCountEvent","unsubscribe","subscription_count","subscriptionCount","authorize","assign","channel_data","config","channelAuthorizer","channelName","reset","members","member","myID","subscriptionData","presence","count","me","memberData","user_info","authData","channelData","setMyID","user","signinDonePromise","user_data","handleInternalEvent","addedMember","addMember","removedMember","removeMember","onSubscription","disconnect","sharedSecret","handleEncryptedEvent","handleEvent","ciphertext","cipherText","getDataToEmit","raw","usingTLS","errorCallbacks","buildErrorCallbacks","connectionCallbacks","buildConnectionCallbacks","handshakeCallbacks","buildHandshakeCallbacks","Network","getNetwork","netinfo","retryIn","sendActivityCheck","updateStrategy","runner","strategy","updateState","startConnecting","setUnavailableTimer","disconnectInternally","handshake","connect","handshakeError","abortConnecting","abort","clearRetryTimer","clearUnavailableTimer","abandonConnection","getStrategy","round","retryTimer","ensureAborted","unavailableTimer","stopActivityCheck","activityTimer","pong_timed_out","resetActivityCheck","shouldRetry","connected","Infinity","setConnection","withErrorEmitted","tls_only","refused","backoff","retry","newState","previousState","newStateDescription","previous","current","channels","createEncryptedChannel","errMsg","createPrivateChannel","createPresenceChannel","createChannel","values","createChannels","createConnectionManager","createTimelineSender","createHandshake","createAssistantToTheTransportManager","livesLeft","lives","strategies","loop","failFast","timeout","timeoutLimit","minPriority","tryNextStrategy","tryStrategy","forceMinPriority","isRunning","callbackBuilder","runners","rs","abortRunner","allRunnersFailed","aborted","transports","ttl","storage","getLocalStorage","serializedCache","getTransportCacheKey","flushTransportCache","fetchTransportCache","cacheSkipCount","timestamp","includes","cached","latency","startTimestamp","pop","cb","storeTransportCache","IfStrategy","trueBranch","falseBranch","FirstConnectedStrategy","testSupportsStrategy","baseOptions","defineTransport","definedTransports","defineTransportStrategy","wsStrategy","ws_options","wsHost","wss_options","sockjs_options","timeouts","ws_manager","streaming_manager","ws_transport","wss_transport","sockjs_transport","xhr_streaming_transport","xdr_streaming_transport","xhr_polling_transport","xdr_polling_transport","ws_loop","wss_loop","sockjs_loop","streaming_loop","polling_loop","http_loop","http_fallback_loop","getRequest","xdr","XDomainRequest","ontimeout","onprogress","onChunk","abortRequest","payload","position","unloader","addUnloadListener","removeUnloadListener","chunk","advanceBuffer","isBufferTooLong","unreadData","endOfLinePosition","State","autoIncrement","getUniqueURL","separator","randomNumber","randomInt","TimelineLevel","session","randomString","parts","exec","getLocation","CONNECTING","openStream","sendRaw","sendHeartbeat","OPEN","createSocketRequest","start","closeStream","CLOSED","onEvent","onHeartbeat","hostname","urlParts","stream","getReceiveURL","onFinished","reconnect","unbind_all","getXHRAPI","createSocket","createRequest","getDefaultStrategy","Transports","load","XMLHttpRequest","WebSocket","MozWebSocket","PusherClass","Pusher","initializeOnDocumentBody","onDocumentBody","ready","getAuthorizers","ajax","jsonp","body","localStorage","createXMLHttpRequest","createMicrosoftXHR","ActiveXObject","createXDR","Constructor","withCredentials","documentProtocol","getProtocol","removeEventListener","detachEvent","Uint32Array","events","sent","uniqueID","level","limit","shift","ERROR","INFO","DEBUG","sendfn","bundle","lib","cluster","features","failAttempt","onInitialized","serializedTransport","transportClass","enabledTransports","disabledTransports","getAssistant","deferred","validateOptions","paramsProvider","dynamicParams","composeChannelQuery","getHttpHost","opts","getWebsocketHost","shouldUseTLS","forceTLS","getEnableStatsConfig","enableStats","disableStats","buildUserAuthenticator","buildChannelAuthorizer","customHandler","channelAuthorizerGenerator","deprecatedAuthorizerOptions","ChannelAuthorizerProxy","authorizer","buildChannelAuth","bindWatchlistInternalEvent","forEach","watchlistEvent","resolve","reject","promise","Promise","res","rej","signin_requested","serverToUserChannel","_signinDoneResolve","_onAuthorize","err","_cleanup","_signin","_newSigninPromiseIfNeeded","watchlist","_onSigninSuccess","userAuthenticator","_subscribeChannels","bind_global","reinstateSubscription","subscribe","ensure_subscribed","done","setDone","then","catch","isReady","instances","app_key","checkAppKey","statsHost","timelineParams","getConfig","global_emitter","sessionID","getClientFeatures","timelineSender","subscribeAll","isUsingTLS","internal","find","all","timelineSenderTimer","event_name","channel_name","cancelSubscription","signin","Runtime","setup"],"mappings":";;;;;;;CAAA,SAA2CA,EAAMC,GAC1B,iBAAZC,SAA0C,iBAAXC,OACxCA,OAAOD,QAAUD,IACQ,mBAAXG,QAAyBA,OAAOC,IAC9CD,OAAO,GAAIH,GACe,iBAAZC,QACdA,QAAgB,OAAID,IAEpBD,EAAa,OAAIC,IARnB,CASGK,QAAQ,WACX,O,YCTE,IAAIC,EAAmB,GAGvB,SAASC,EAAoBC,GAG5B,GAAGF,EAAiBE,GACnB,OAAOF,EAAiBE,GAAUP,QAGnC,IAAIC,EAASI,EAAiBE,GAAY,CACzCC,EAAGD,EACHE,GAAG,EACHT,QAAS,IAUV,OANAU,EAAQH,GAAUI,KAAKV,EAAOD,QAASC,EAAQA,EAAOD,QAASM,GAG/DL,EAAOQ,GAA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AoBhhC,EAAW2qB,GACxC,OAAO7qB,KAAK8pB,WAAWwB,WAAW4V,EAAYhhC,EAAM2qB,GAGtD,eACE,OAAO7qB,KAAK4sB,OAAOjS,OAGrB,SACE3a,KAAK4tB,KAAKyT,UAxNL,GAAAnB,UAAsB,GACtB,GAAAD,SAAmB,EACnB,GAAA/d,cAAwB,EAGxB,GAAAof,QAA2B,GAC3B,GAAAnpB,gBAA6B,GAASA,gBACtC,GAAAuB,sBAAmC,GAASA,sBAC5C,GAAA8I,eAA4B,GAASA,eAVzB,UAoOrB,GAAQ+e,MAAM,I,YCxPC,MAAM,WAA6B,GAChD,YAAYpB,EAAiBvmB,GAC3B,GAAOsI,aAAe,GAAqBA,aAC3C,GAAOL,IAAM,GAAqBA,IAElCmb,GAAgBpjB,GAChBA,EAAQrX,KAAO,GACfuZ,MAAMqkB,EAASvmB","file":"pusher-with-encryption.min.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"Pusher\"] = factory();\n\telse\n\t\troot[\"Pusher\"] = factory();\n})(window, function() {\nreturn "," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 3);\n","// Copyright (C) 2016 Dmitry Chestnykh\n// MIT License. See LICENSE file for details.\n\n/**\n * Package base64 implements Base64 encoding and decoding.\n */\n\n// Invalid character used in decoding to indicate\n// that the character to decode is out of range of\n// alphabet and cannot be decoded.\nconst INVALID_BYTE = 256;\n\n/**\n * Implements standard Base64 encoding.\n *\n * Operates in constant time.\n */\nexport class Coder {\n // TODO(dchest): methods to encode chunk-by-chunk.\n\n constructor(private _paddingCharacter = \"=\") { }\n\n encodedLength(length: number): number {\n if (!this._paddingCharacter) {\n return (length * 8 + 5) / 6 | 0;\n }\n return (length + 2) / 3 * 4 | 0;\n }\n\n encode(data: Uint8Array): string {\n let out = \"\";\n\n let i = 0;\n for (; i < data.length - 2; i += 3) {\n let c = (data[i] << 16) | (data[i + 1] << 8) | (data[i + 2]);\n out += this._encodeByte((c >>> 3 * 6) & 63);\n out += this._encodeByte((c >>> 2 * 6) & 63);\n out += this._encodeByte((c >>> 1 * 6) & 63);\n out += this._encodeByte((c >>> 0 * 6) & 63);\n }\n\n const left = data.length - i;\n if (left > 0) {\n let c = (data[i] << 16) | (left === 2 ? data[i + 1] << 8 : 0);\n out += this._encodeByte((c >>> 3 * 6) & 63);\n out += this._encodeByte((c >>> 2 * 6) & 63);\n if (left === 2) {\n out += this._encodeByte((c >>> 1 * 6) & 63);\n } else {\n out += this._paddingCharacter || \"\";\n }\n out += this._paddingCharacter || \"\";\n }\n\n return out;\n }\n\n maxDecodedLength(length: number): number {\n if (!this._paddingCharacter) {\n return (length * 6 + 7) / 8 | 0;\n }\n return length / 4 * 3 | 0;\n }\n\n decodedLength(s: string): number {\n return this.maxDecodedLength(s.length - this._getPaddingLength(s));\n }\n\n decode(s: string): Uint8Array {\n if (s.length === 0) {\n return new Uint8Array(0);\n }\n const paddingLength = this._getPaddingLength(s);\n const length = s.length - paddingLength;\n const out = new Uint8Array(this.maxDecodedLength(length));\n let op = 0;\n let i = 0;\n let haveBad = 0;\n let v0 = 0, v1 = 0, v2 = 0, v3 = 0;\n for (; i < length - 4; i += 4) {\n v0 = this._decodeChar(s.charCodeAt(i + 0));\n v1 = this._decodeChar(s.charCodeAt(i + 1));\n v2 = this._decodeChar(s.charCodeAt(i + 2));\n v3 = this._decodeChar(s.charCodeAt(i + 3));\n out[op++] = (v0 << 2) | (v1 >>> 4);\n out[op++] = (v1 << 4) | (v2 >>> 2);\n out[op++] = (v2 << 6) | v3;\n haveBad |= v0 & INVALID_BYTE;\n haveBad |= v1 & INVALID_BYTE;\n haveBad |= v2 & INVALID_BYTE;\n haveBad |= v3 & INVALID_BYTE;\n }\n if (i < length - 1) {\n v0 = this._decodeChar(s.charCodeAt(i));\n v1 = this._decodeChar(s.charCodeAt(i + 1));\n out[op++] = (v0 << 2) | (v1 >>> 4);\n haveBad |= v0 & INVALID_BYTE;\n haveBad |= v1 & INVALID_BYTE;\n }\n if (i < length - 2) {\n v2 = this._decodeChar(s.charCodeAt(i + 2));\n out[op++] = (v1 << 4) | (v2 >>> 2);\n haveBad |= v2 & INVALID_BYTE;\n }\n if (i < length - 3) {\n v3 = this._decodeChar(s.charCodeAt(i + 3));\n out[op++] = (v2 << 6) | v3;\n haveBad |= v3 & INVALID_BYTE;\n }\n if (haveBad !== 0) {\n throw new Error(\"Base64Coder: incorrect characters for decoding\");\n }\n return out;\n }\n\n // Standard encoding have the following encoded/decoded ranges,\n // which we need to convert between.\n //\n // ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 0123456789 + /\n // Index: 0 - 25 26 - 51 52 - 61 62 63\n // ASCII: 65 - 90 97 - 122 48 - 57 43 47\n //\n\n // Encode 6 bits in b into a new character.\n protected _encodeByte(b: number): string {\n // Encoding uses constant time operations as follows:\n //\n // 1. Define comparison of A with B using (A - B) >>> 8:\n // if A > B, then result is positive integer\n // if A <= B, then result is 0\n //\n // 2. Define selection of C or 0 using bitwise AND: X & C:\n // if X == 0, then result is 0\n // if X != 0, then result is C\n //\n // 3. Start with the smallest comparison (b >= 0), which is always\n // true, so set the result to the starting ASCII value (65).\n //\n // 4. Continue comparing b to higher ASCII values, and selecting\n // zero if comparison isn't true, otherwise selecting a value\n // to add to result, which:\n //\n // a) undoes the previous addition\n // b) provides new value to add\n //\n let result = b;\n // b >= 0\n result += 65;\n // b > 25\n result += ((25 - b) >>> 8) & ((0 - 65) - 26 + 97);\n // b > 51\n result += ((51 - b) >>> 8) & ((26 - 97) - 52 + 48);\n // b > 61\n result += ((61 - b) >>> 8) & ((52 - 48) - 62 + 43);\n // b > 62\n result += ((62 - b) >>> 8) & ((62 - 43) - 63 + 47);\n\n return String.fromCharCode(result);\n }\n\n // Decode a character code into a byte.\n // Must return 256 if character is out of alphabet range.\n protected _decodeChar(c: number): number {\n // Decoding works similar to encoding: using the same comparison\n // function, but now it works on ranges: result is always incremented\n // by value, but this value becomes zero if the range is not\n // satisfied.\n //\n // Decoding starts with invalid value, 256, which is then\n // subtracted when the range is satisfied. If none of the ranges\n // apply, the function returns 256, which is then checked by\n // the caller to throw error.\n let result = INVALID_BYTE; // start with invalid character\n\n // c == 43 (c > 42 and c < 44)\n result += (((42 - c) & (c - 44)) >>> 8) & (-INVALID_BYTE + c - 43 + 62);\n // c == 47 (c > 46 and c < 48)\n result += (((46 - c) & (c - 48)) >>> 8) & (-INVALID_BYTE + c - 47 + 63);\n // c > 47 and c < 58\n result += (((47 - c) & (c - 58)) >>> 8) & (-INVALID_BYTE + c - 48 + 52);\n // c > 64 and c < 91\n result += (((64 - c) & (c - 91)) >>> 8) & (-INVALID_BYTE + c - 65 + 0);\n // c > 96 and c < 123\n result += (((96 - c) & (c - 123)) >>> 8) & (-INVALID_BYTE + c - 97 + 26);\n\n return result;\n }\n\n private _getPaddingLength(s: string): number {\n let paddingLength = 0;\n if (this._paddingCharacter) {\n for (let i = s.length - 1; i >= 0; i--) {\n if (s[i] !== this._paddingCharacter) {\n break;\n }\n paddingLength++;\n }\n if (s.length < 4 || paddingLength > 2) {\n throw new Error(\"Base64Coder: incorrect padding\");\n }\n }\n return paddingLength;\n }\n\n}\n\nconst stdCoder = new Coder();\n\nexport function encode(data: Uint8Array): string {\n return stdCoder.encode(data);\n}\n\nexport function decode(s: string): Uint8Array {\n return stdCoder.decode(s);\n}\n\n/**\n * Implements URL-safe Base64 encoding.\n * (Same as Base64, but '+' is replaced with '-', and '/' with '_').\n *\n * Operates in constant time.\n */\nexport class URLSafeCoder extends Coder {\n // URL-safe encoding have the following encoded/decoded ranges:\n //\n // ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 0123456789 - _\n // Index: 0 - 25 26 - 51 52 - 61 62 63\n // ASCII: 65 - 90 97 - 122 48 - 57 45 95\n //\n\n protected _encodeByte(b: number): string {\n let result = b;\n // b >= 0\n result += 65;\n // b > 25\n result += ((25 - b) >>> 8) & ((0 - 65) - 26 + 97);\n // b > 51\n result += ((51 - b) >>> 8) & ((26 - 97) - 52 + 48);\n // b > 61\n result += ((61 - b) >>> 8) & ((52 - 48) - 62 + 45);\n // b > 62\n result += ((62 - b) >>> 8) & ((62 - 45) - 63 + 95);\n\n return String.fromCharCode(result);\n }\n\n protected _decodeChar(c: number): number {\n let result = INVALID_BYTE;\n\n // c == 45 (c > 44 and c < 46)\n result += (((44 - c) & (c - 46)) >>> 8) & (-INVALID_BYTE + c - 45 + 62);\n // c == 95 (c > 94 and c < 96)\n result += (((94 - c) & (c - 96)) >>> 8) & (-INVALID_BYTE + c - 95 + 63);\n // c > 47 and c < 58\n result += (((47 - c) & (c - 58)) >>> 8) & (-INVALID_BYTE + c - 48 + 52);\n // c > 64 and c < 91\n result += (((64 - c) & (c - 91)) >>> 8) & (-INVALID_BYTE + c - 65 + 0);\n // c > 96 and c < 123\n result += (((96 - c) & (c - 123)) >>> 8) & (-INVALID_BYTE + c - 97 + 26);\n\n return result;\n }\n}\n\nconst urlSafeCoder = new URLSafeCoder();\n\nexport function encodeURLSafe(data: Uint8Array): string {\n return urlSafeCoder.encode(data);\n}\n\nexport function decodeURLSafe(s: string): Uint8Array {\n return urlSafeCoder.decode(s);\n}\n\n\nexport const encodedLength = (length: number) =>\n stdCoder.encodedLength(length);\n\nexport const maxDecodedLength = (length: number) =>\n stdCoder.maxDecodedLength(length);\n\nexport const decodedLength = (s: string) =>\n stdCoder.decodedLength(s);\n","// Copyright (C) 2016 Dmitry Chestnykh\n// MIT License. See LICENSE file for details.\n\n/**\n * Package utf8 implements UTF-8 encoding and decoding.\n */\n\nconst INVALID_UTF16 = \"utf8: invalid string\";\nconst INVALID_UTF8 = \"utf8: invalid source encoding\";\n\n/**\n * Encodes the given string into UTF-8 byte array.\n * Throws if the source string has invalid UTF-16 encoding.\n */\nexport function encode(s: string): Uint8Array {\n // Calculate result length and allocate output array.\n // encodedLength() also validates string and throws errors,\n // so we don't need repeat validation here.\n const arr = new Uint8Array(encodedLength(s));\n\n let pos = 0;\n for (let i = 0; i < s.length; i++) {\n let c = s.charCodeAt(i);\n if (c < 0x80) {\n arr[pos++] = c;\n } else if (c < 0x800) {\n arr[pos++] = 0xc0 | c >> 6;\n arr[pos++] = 0x80 | c & 0x3f;\n } else if (c < 0xd800) {\n arr[pos++] = 0xe0 | c >> 12;\n arr[pos++] = 0x80 | (c >> 6) & 0x3f;\n arr[pos++] = 0x80 | c & 0x3f;\n } else {\n i++; // get one more character\n c = (c & 0x3ff) << 10;\n c |= s.charCodeAt(i) & 0x3ff;\n c += 0x10000;\n\n arr[pos++] = 0xf0 | c >> 18;\n arr[pos++] = 0x80 | (c >> 12) & 0x3f;\n arr[pos++] = 0x80 | (c >> 6) & 0x3f;\n arr[pos++] = 0x80 | c & 0x3f;\n }\n }\n return arr;\n}\n\n/**\n * Returns the number of bytes required to encode the given string into UTF-8.\n * Throws if the source string has invalid UTF-16 encoding.\n */\nexport function encodedLength(s: string): number {\n let result = 0;\n for (let i = 0; i < s.length; i++) {\n const c = s.charCodeAt(i);\n if (c < 0x80) {\n result += 1;\n } else if (c < 0x800) {\n result += 2;\n } else if (c < 0xd800) {\n result += 3;\n } else if (c <= 0xdfff) {\n if (i >= s.length - 1) {\n throw new Error(INVALID_UTF16);\n }\n i++; // \"eat\" next character\n result += 4;\n } else {\n throw new Error(INVALID_UTF16);\n }\n }\n return result;\n}\n\n/**\n * Decodes the given byte array from UTF-8 into a string.\n * Throws if encoding is invalid.\n */\nexport function decode(arr: Uint8Array): string {\n const chars: string[] = [];\n for (let i = 0; i < arr.length; i++) {\n let b = arr[i];\n\n if (b & 0x80) {\n let min;\n if (b < 0xe0) {\n // Need 1 more byte.\n if (i >= arr.length) {\n throw new Error(INVALID_UTF8);\n }\n const n1 = arr[++i];\n if ((n1 & 0xc0) !== 0x80) {\n throw new Error(INVALID_UTF8);\n }\n b = (b & 0x1f) << 6 | (n1 & 0x3f);\n min = 0x80;\n } else if (b < 0xf0) {\n // Need 2 more bytes.\n if (i >= arr.length - 1) {\n throw new Error(INVALID_UTF8);\n }\n const n1 = arr[++i];\n const n2 = arr[++i];\n if ((n1 & 0xc0) !== 0x80 || (n2 & 0xc0) !== 0x80) {\n throw new Error(INVALID_UTF8);\n }\n b = (b & 0x0f) << 12 | (n1 & 0x3f) << 6 | (n2 & 0x3f);\n min = 0x800;\n } else if (b < 0xf8) {\n // Need 3 more bytes.\n if (i >= arr.length - 2) {\n throw new Error(INVALID_UTF8);\n }\n const n1 = arr[++i];\n const n2 = arr[++i];\n const n3 = arr[++i];\n if ((n1 & 0xc0) !== 0x80 || (n2 & 0xc0) !== 0x80 || (n3 & 0xc0) !== 0x80) {\n throw new Error(INVALID_UTF8);\n }\n b = (b & 0x0f) << 18 | (n1 & 0x3f) << 12 | (n2 & 0x3f) << 6 | (n3 & 0x3f);\n min = 0x10000;\n } else {\n throw new Error(INVALID_UTF8);\n }\n\n if (b < min || (b >= 0xd800 && b <= 0xdfff)) {\n throw new Error(INVALID_UTF8);\n }\n\n if (b >= 0x10000) {\n // Surrogate pair.\n if (b > 0x10ffff) {\n throw new Error(INVALID_UTF8);\n }\n b -= 0x10000;\n chars.push(String.fromCharCode(0xd800 | (b >> 10)));\n b = 0xdc00 | (b & 0x3ff);\n }\n }\n\n chars.push(String.fromCharCode(b));\n }\n return chars.join(\"\");\n}\n","(function(nacl) {\n'use strict';\n\n// Ported in 2014 by Dmitry Chestnykh and Devi Mandiri.\n// Public domain.\n//\n// Implementation derived from TweetNaCl version 20140427.\n// See for details: http://tweetnacl.cr.yp.to/\n\nvar gf = function(init) {\n var i, r = new Float64Array(16);\n if (init) for (i = 0; i < init.length; i++) r[i] = init[i];\n return r;\n};\n\n// Pluggable, initialized in high-level API below.\nvar randombytes = function(/* x, n */) { throw new Error('no PRNG'); };\n\nvar _0 = new Uint8Array(16);\nvar _9 = new Uint8Array(32); _9[0] = 9;\n\nvar gf0 = gf(),\n gf1 = gf([1]),\n _121665 = gf([0xdb41, 1]),\n D = gf([0x78a3, 0x1359, 0x4dca, 0x75eb, 0xd8ab, 0x4141, 0x0a4d, 0x0070, 0xe898, 0x7779, 0x4079, 0x8cc7, 0xfe73, 0x2b6f, 0x6cee, 0x5203]),\n D2 = gf([0xf159, 0x26b2, 0x9b94, 0xebd6, 0xb156, 0x8283, 0x149a, 0x00e0, 0xd130, 0xeef3, 0x80f2, 0x198e, 0xfce7, 0x56df, 0xd9dc, 0x2406]),\n X = gf([0xd51a, 0x8f25, 0x2d60, 0xc956, 0xa7b2, 0x9525, 0xc760, 0x692c, 0xdc5c, 0xfdd6, 0xe231, 0xc0a4, 0x53fe, 0xcd6e, 0x36d3, 0x2169]),\n Y = gf([0x6658, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666]),\n I = gf([0xa0b0, 0x4a0e, 0x1b27, 0xc4ee, 0xe478, 0xad2f, 0x1806, 0x2f43, 0xd7a7, 0x3dfb, 0x0099, 0x2b4d, 0xdf0b, 0x4fc1, 0x2480, 0x2b83]);\n\nfunction ts64(x, i, h, l) {\n x[i] = (h >> 24) & 0xff;\n x[i+1] = (h >> 16) & 0xff;\n x[i+2] = (h >> 8) & 0xff;\n x[i+3] = h & 0xff;\n x[i+4] = (l >> 24) & 0xff;\n x[i+5] = (l >> 16) & 0xff;\n x[i+6] = (l >> 8) & 0xff;\n x[i+7] = l & 0xff;\n}\n\nfunction vn(x, xi, y, yi, n) {\n var i,d = 0;\n for (i = 0; i < n; i++) d |= x[xi+i]^y[yi+i];\n return (1 & ((d - 1) >>> 8)) - 1;\n}\n\nfunction crypto_verify_16(x, xi, y, yi) {\n return vn(x,xi,y,yi,16);\n}\n\nfunction crypto_verify_32(x, xi, y, yi) {\n return vn(x,xi,y,yi,32);\n}\n\nfunction core_salsa20(o, p, k, c) {\n var j0 = c[ 0] & 0xff | (c[ 1] & 0xff)<<8 | (c[ 2] & 0xff)<<16 | (c[ 3] & 0xff)<<24,\n j1 = k[ 0] & 0xff | (k[ 1] & 0xff)<<8 | (k[ 2] & 0xff)<<16 | (k[ 3] & 0xff)<<24,\n j2 = k[ 4] & 0xff | (k[ 5] & 0xff)<<8 | (k[ 6] & 0xff)<<16 | (k[ 7] & 0xff)<<24,\n j3 = k[ 8] & 0xff | (k[ 9] & 0xff)<<8 | (k[10] & 0xff)<<16 | (k[11] & 0xff)<<24,\n j4 = k[12] & 0xff | (k[13] & 0xff)<<8 | (k[14] & 0xff)<<16 | (k[15] & 0xff)<<24,\n j5 = c[ 4] & 0xff | (c[ 5] & 0xff)<<8 | (c[ 6] & 0xff)<<16 | (c[ 7] & 0xff)<<24,\n j6 = p[ 0] & 0xff | (p[ 1] & 0xff)<<8 | (p[ 2] & 0xff)<<16 | (p[ 3] & 0xff)<<24,\n j7 = p[ 4] & 0xff | (p[ 5] & 0xff)<<8 | (p[ 6] & 0xff)<<16 | (p[ 7] & 0xff)<<24,\n j8 = p[ 8] & 0xff | (p[ 9] & 0xff)<<8 | (p[10] & 0xff)<<16 | (p[11] & 0xff)<<24,\n j9 = p[12] & 0xff | (p[13] & 0xff)<<8 | (p[14] & 0xff)<<16 | (p[15] & 0xff)<<24,\n j10 = c[ 8] & 0xff | (c[ 9] & 0xff)<<8 | (c[10] & 0xff)<<16 | (c[11] & 0xff)<<24,\n j11 = k[16] & 0xff | (k[17] & 0xff)<<8 | (k[18] & 0xff)<<16 | (k[19] & 0xff)<<24,\n j12 = k[20] & 0xff | (k[21] & 0xff)<<8 | (k[22] & 0xff)<<16 | (k[23] & 0xff)<<24,\n j13 = k[24] & 0xff | (k[25] & 0xff)<<8 | (k[26] & 0xff)<<16 | (k[27] & 0xff)<<24,\n j14 = k[28] & 0xff | (k[29] & 0xff)<<8 | (k[30] & 0xff)<<16 | (k[31] & 0xff)<<24,\n j15 = c[12] & 0xff | (c[13] & 0xff)<<8 | (c[14] & 0xff)<<16 | (c[15] & 0xff)<<24;\n\n var x0 = j0, x1 = j1, x2 = j2, x3 = j3, x4 = j4, x5 = j5, x6 = j6, x7 = j7,\n x8 = j8, x9 = j9, x10 = j10, x11 = j11, x12 = j12, x13 = j13, x14 = j14,\n x15 = j15, u;\n\n for (var i = 0; i < 20; i += 2) {\n u = x0 + x12 | 0;\n x4 ^= u<<7 | u>>>(32-7);\n u = x4 + x0 | 0;\n x8 ^= u<<9 | u>>>(32-9);\n u = x8 + x4 | 0;\n x12 ^= u<<13 | u>>>(32-13);\n u = x12 + x8 | 0;\n x0 ^= u<<18 | u>>>(32-18);\n\n u = x5 + x1 | 0;\n x9 ^= u<<7 | u>>>(32-7);\n u = x9 + x5 | 0;\n x13 ^= u<<9 | u>>>(32-9);\n u = x13 + x9 | 0;\n x1 ^= u<<13 | u>>>(32-13);\n u = x1 + x13 | 0;\n x5 ^= u<<18 | u>>>(32-18);\n\n u = x10 + x6 | 0;\n x14 ^= u<<7 | u>>>(32-7);\n u = x14 + x10 | 0;\n x2 ^= u<<9 | u>>>(32-9);\n u = x2 + x14 | 0;\n x6 ^= u<<13 | u>>>(32-13);\n u = x6 + x2 | 0;\n x10 ^= u<<18 | u>>>(32-18);\n\n u = x15 + x11 | 0;\n x3 ^= u<<7 | u>>>(32-7);\n u = x3 + x15 | 0;\n x7 ^= u<<9 | u>>>(32-9);\n u = x7 + x3 | 0;\n x11 ^= u<<13 | u>>>(32-13);\n u = x11 + x7 | 0;\n x15 ^= u<<18 | u>>>(32-18);\n\n u = x0 + x3 | 0;\n x1 ^= u<<7 | u>>>(32-7);\n u = x1 + x0 | 0;\n x2 ^= u<<9 | u>>>(32-9);\n u = x2 + x1 | 0;\n x3 ^= u<<13 | u>>>(32-13);\n u = x3 + x2 | 0;\n x0 ^= u<<18 | u>>>(32-18);\n\n u = x5 + x4 | 0;\n x6 ^= u<<7 | u>>>(32-7);\n u = x6 + x5 | 0;\n x7 ^= u<<9 | u>>>(32-9);\n u = x7 + x6 | 0;\n x4 ^= u<<13 | u>>>(32-13);\n u = x4 + x7 | 0;\n x5 ^= u<<18 | u>>>(32-18);\n\n u = x10 + x9 | 0;\n x11 ^= u<<7 | u>>>(32-7);\n u = x11 + x10 | 0;\n x8 ^= u<<9 | u>>>(32-9);\n u = x8 + x11 | 0;\n x9 ^= u<<13 | u>>>(32-13);\n u = x9 + x8 | 0;\n x10 ^= u<<18 | u>>>(32-18);\n\n u = x15 + x14 | 0;\n x12 ^= u<<7 | u>>>(32-7);\n u = x12 + x15 | 0;\n x13 ^= u<<9 | u>>>(32-9);\n u = x13 + x12 | 0;\n x14 ^= u<<13 | u>>>(32-13);\n u = x14 + x13 | 0;\n x15 ^= u<<18 | u>>>(32-18);\n }\n x0 = x0 + j0 | 0;\n x1 = x1 + j1 | 0;\n x2 = x2 + j2 | 0;\n x3 = x3 + j3 | 0;\n x4 = x4 + j4 | 0;\n x5 = x5 + j5 | 0;\n x6 = x6 + j6 | 0;\n x7 = x7 + j7 | 0;\n x8 = x8 + j8 | 0;\n x9 = x9 + j9 | 0;\n x10 = x10 + j10 | 0;\n x11 = x11 + j11 | 0;\n x12 = x12 + j12 | 0;\n x13 = x13 + j13 | 0;\n x14 = x14 + j14 | 0;\n x15 = x15 + j15 | 0;\n\n o[ 0] = x0 >>> 0 & 0xff;\n o[ 1] = x0 >>> 8 & 0xff;\n o[ 2] = x0 >>> 16 & 0xff;\n o[ 3] = x0 >>> 24 & 0xff;\n\n o[ 4] = x1 >>> 0 & 0xff;\n o[ 5] = x1 >>> 8 & 0xff;\n o[ 6] = x1 >>> 16 & 0xff;\n o[ 7] = x1 >>> 24 & 0xff;\n\n o[ 8] = x2 >>> 0 & 0xff;\n o[ 9] = x2 >>> 8 & 0xff;\n o[10] = x2 >>> 16 & 0xff;\n o[11] = x2 >>> 24 & 0xff;\n\n o[12] = x3 >>> 0 & 0xff;\n o[13] = x3 >>> 8 & 0xff;\n o[14] = x3 >>> 16 & 0xff;\n o[15] = x3 >>> 24 & 0xff;\n\n o[16] = x4 >>> 0 & 0xff;\n o[17] = x4 >>> 8 & 0xff;\n o[18] = x4 >>> 16 & 0xff;\n o[19] = x4 >>> 24 & 0xff;\n\n o[20] = x5 >>> 0 & 0xff;\n o[21] = x5 >>> 8 & 0xff;\n o[22] = x5 >>> 16 & 0xff;\n o[23] = x5 >>> 24 & 0xff;\n\n o[24] = x6 >>> 0 & 0xff;\n o[25] = x6 >>> 8 & 0xff;\n o[26] = x6 >>> 16 & 0xff;\n o[27] = x6 >>> 24 & 0xff;\n\n o[28] = x7 >>> 0 & 0xff;\n o[29] = x7 >>> 8 & 0xff;\n o[30] = x7 >>> 16 & 0xff;\n o[31] = x7 >>> 24 & 0xff;\n\n o[32] = x8 >>> 0 & 0xff;\n o[33] = x8 >>> 8 & 0xff;\n o[34] = x8 >>> 16 & 0xff;\n o[35] = x8 >>> 24 & 0xff;\n\n o[36] = x9 >>> 0 & 0xff;\n o[37] = x9 >>> 8 & 0xff;\n o[38] = x9 >>> 16 & 0xff;\n o[39] = x9 >>> 24 & 0xff;\n\n o[40] = x10 >>> 0 & 0xff;\n o[41] = x10 >>> 8 & 0xff;\n o[42] = x10 >>> 16 & 0xff;\n o[43] = x10 >>> 24 & 0xff;\n\n o[44] = x11 >>> 0 & 0xff;\n o[45] = x11 >>> 8 & 0xff;\n o[46] = x11 >>> 16 & 0xff;\n o[47] = x11 >>> 24 & 0xff;\n\n o[48] = x12 >>> 0 & 0xff;\n o[49] = x12 >>> 8 & 0xff;\n o[50] = x12 >>> 16 & 0xff;\n o[51] = x12 >>> 24 & 0xff;\n\n o[52] = x13 >>> 0 & 0xff;\n o[53] = x13 >>> 8 & 0xff;\n o[54] = x13 >>> 16 & 0xff;\n o[55] = x13 >>> 24 & 0xff;\n\n o[56] = x14 >>> 0 & 0xff;\n o[57] = x14 >>> 8 & 0xff;\n o[58] = x14 >>> 16 & 0xff;\n o[59] = x14 >>> 24 & 0xff;\n\n o[60] = x15 >>> 0 & 0xff;\n o[61] = x15 >>> 8 & 0xff;\n o[62] = x15 >>> 16 & 0xff;\n o[63] = x15 >>> 24 & 0xff;\n}\n\nfunction core_hsalsa20(o,p,k,c) {\n var j0 = c[ 0] & 0xff | (c[ 1] & 0xff)<<8 | (c[ 2] & 0xff)<<16 | (c[ 3] & 0xff)<<24,\n j1 = k[ 0] & 0xff | (k[ 1] & 0xff)<<8 | (k[ 2] & 0xff)<<16 | (k[ 3] & 0xff)<<24,\n j2 = k[ 4] & 0xff | (k[ 5] & 0xff)<<8 | (k[ 6] & 0xff)<<16 | (k[ 7] & 0xff)<<24,\n j3 = k[ 8] & 0xff | (k[ 9] & 0xff)<<8 | (k[10] & 0xff)<<16 | (k[11] & 0xff)<<24,\n j4 = k[12] & 0xff | (k[13] & 0xff)<<8 | (k[14] & 0xff)<<16 | (k[15] & 0xff)<<24,\n j5 = c[ 4] & 0xff | (c[ 5] & 0xff)<<8 | (c[ 6] & 0xff)<<16 | (c[ 7] & 0xff)<<24,\n j6 = p[ 0] & 0xff | (p[ 1] & 0xff)<<8 | (p[ 2] & 0xff)<<16 | (p[ 3] & 0xff)<<24,\n j7 = p[ 4] & 0xff | (p[ 5] & 0xff)<<8 | (p[ 6] & 0xff)<<16 | (p[ 7] & 0xff)<<24,\n j8 = p[ 8] & 0xff | (p[ 9] & 0xff)<<8 | (p[10] & 0xff)<<16 | (p[11] & 0xff)<<24,\n j9 = p[12] & 0xff | (p[13] & 0xff)<<8 | (p[14] & 0xff)<<16 | (p[15] & 0xff)<<24,\n j10 = c[ 8] & 0xff | (c[ 9] & 0xff)<<8 | (c[10] & 0xff)<<16 | (c[11] & 0xff)<<24,\n j11 = k[16] & 0xff | (k[17] & 0xff)<<8 | (k[18] & 0xff)<<16 | (k[19] & 0xff)<<24,\n j12 = k[20] & 0xff | (k[21] & 0xff)<<8 | (k[22] & 0xff)<<16 | (k[23] & 0xff)<<24,\n j13 = k[24] & 0xff | (k[25] & 0xff)<<8 | (k[26] & 0xff)<<16 | (k[27] & 0xff)<<24,\n j14 = k[28] & 0xff | (k[29] & 0xff)<<8 | (k[30] & 0xff)<<16 | (k[31] & 0xff)<<24,\n j15 = c[12] & 0xff | (c[13] & 0xff)<<8 | (c[14] & 0xff)<<16 | (c[15] & 0xff)<<24;\n\n var x0 = j0, x1 = j1, x2 = j2, x3 = j3, x4 = j4, x5 = j5, x6 = j6, x7 = j7,\n x8 = j8, x9 = j9, x10 = j10, x11 = j11, x12 = j12, x13 = j13, x14 = j14,\n x15 = j15, u;\n\n for (var i = 0; i < 20; i += 2) {\n u = x0 + x12 | 0;\n x4 ^= u<<7 | u>>>(32-7);\n u = x4 + x0 | 0;\n x8 ^= u<<9 | u>>>(32-9);\n u = x8 + x4 | 0;\n x12 ^= u<<13 | u>>>(32-13);\n u = x12 + x8 | 0;\n x0 ^= u<<18 | u>>>(32-18);\n\n u = x5 + x1 | 0;\n x9 ^= u<<7 | u>>>(32-7);\n u = x9 + x5 | 0;\n x13 ^= u<<9 | u>>>(32-9);\n u = x13 + x9 | 0;\n x1 ^= u<<13 | u>>>(32-13);\n u = x1 + x13 | 0;\n x5 ^= u<<18 | u>>>(32-18);\n\n u = x10 + x6 | 0;\n x14 ^= u<<7 | u>>>(32-7);\n u = x14 + x10 | 0;\n x2 ^= u<<9 | u>>>(32-9);\n u = x2 + x14 | 0;\n x6 ^= u<<13 | u>>>(32-13);\n u = x6 + x2 | 0;\n x10 ^= u<<18 | u>>>(32-18);\n\n u = x15 + x11 | 0;\n x3 ^= u<<7 | u>>>(32-7);\n u = x3 + x15 | 0;\n x7 ^= u<<9 | u>>>(32-9);\n u = x7 + x3 | 0;\n x11 ^= u<<13 | u>>>(32-13);\n u = x11 + x7 | 0;\n x15 ^= u<<18 | u>>>(32-18);\n\n u = x0 + x3 | 0;\n x1 ^= u<<7 | u>>>(32-7);\n u = x1 + x0 | 0;\n x2 ^= u<<9 | u>>>(32-9);\n u = x2 + x1 | 0;\n x3 ^= u<<13 | u>>>(32-13);\n u = x3 + x2 | 0;\n x0 ^= u<<18 | u>>>(32-18);\n\n u = x5 + x4 | 0;\n x6 ^= u<<7 | u>>>(32-7);\n u = x6 + x5 | 0;\n x7 ^= u<<9 | u>>>(32-9);\n u = x7 + x6 | 0;\n x4 ^= u<<13 | u>>>(32-13);\n u = x4 + x7 | 0;\n x5 ^= u<<18 | u>>>(32-18);\n\n u = x10 + x9 | 0;\n x11 ^= u<<7 | u>>>(32-7);\n u = x11 + x10 | 0;\n x8 ^= u<<9 | u>>>(32-9);\n u = x8 + x11 | 0;\n x9 ^= u<<13 | u>>>(32-13);\n u = x9 + x8 | 0;\n x10 ^= u<<18 | u>>>(32-18);\n\n u = x15 + x14 | 0;\n x12 ^= u<<7 | u>>>(32-7);\n u = x12 + x15 | 0;\n x13 ^= u<<9 | u>>>(32-9);\n u = x13 + x12 | 0;\n x14 ^= u<<13 | u>>>(32-13);\n u = x14 + x13 | 0;\n x15 ^= u<<18 | u>>>(32-18);\n }\n\n o[ 0] = x0 >>> 0 & 0xff;\n o[ 1] = x0 >>> 8 & 0xff;\n o[ 2] = x0 >>> 16 & 0xff;\n o[ 3] = x0 >>> 24 & 0xff;\n\n o[ 4] = x5 >>> 0 & 0xff;\n o[ 5] = x5 >>> 8 & 0xff;\n o[ 6] = x5 >>> 16 & 0xff;\n o[ 7] = x5 >>> 24 & 0xff;\n\n o[ 8] = x10 >>> 0 & 0xff;\n o[ 9] = x10 >>> 8 & 0xff;\n o[10] = x10 >>> 16 & 0xff;\n o[11] = x10 >>> 24 & 0xff;\n\n o[12] = x15 >>> 0 & 0xff;\n o[13] = x15 >>> 8 & 0xff;\n o[14] = x15 >>> 16 & 0xff;\n o[15] = x15 >>> 24 & 0xff;\n\n o[16] = x6 >>> 0 & 0xff;\n o[17] = x6 >>> 8 & 0xff;\n o[18] = x6 >>> 16 & 0xff;\n o[19] = x6 >>> 24 & 0xff;\n\n o[20] = x7 >>> 0 & 0xff;\n o[21] = x7 >>> 8 & 0xff;\n o[22] = x7 >>> 16 & 0xff;\n o[23] = x7 >>> 24 & 0xff;\n\n o[24] = x8 >>> 0 & 0xff;\n o[25] = x8 >>> 8 & 0xff;\n o[26] = x8 >>> 16 & 0xff;\n o[27] = x8 >>> 24 & 0xff;\n\n o[28] = x9 >>> 0 & 0xff;\n o[29] = x9 >>> 8 & 0xff;\n o[30] = x9 >>> 16 & 0xff;\n o[31] = x9 >>> 24 & 0xff;\n}\n\nfunction crypto_core_salsa20(out,inp,k,c) {\n core_salsa20(out,inp,k,c);\n}\n\nfunction crypto_core_hsalsa20(out,inp,k,c) {\n core_hsalsa20(out,inp,k,c);\n}\n\nvar sigma = new Uint8Array([101, 120, 112, 97, 110, 100, 32, 51, 50, 45, 98, 121, 116, 101, 32, 107]);\n // \"expand 32-byte k\"\n\nfunction crypto_stream_salsa20_xor(c,cpos,m,mpos,b,n,k) {\n var z = new Uint8Array(16), x = new Uint8Array(64);\n var u, i;\n for (i = 0; i < 16; i++) z[i] = 0;\n for (i = 0; i < 8; i++) z[i] = n[i];\n while (b >= 64) {\n crypto_core_salsa20(x,z,k,sigma);\n for (i = 0; i < 64; i++) c[cpos+i] = m[mpos+i] ^ x[i];\n u = 1;\n for (i = 8; i < 16; i++) {\n u = u + (z[i] & 0xff) | 0;\n z[i] = u & 0xff;\n u >>>= 8;\n }\n b -= 64;\n cpos += 64;\n mpos += 64;\n }\n if (b > 0) {\n crypto_core_salsa20(x,z,k,sigma);\n for (i = 0; i < b; i++) c[cpos+i] = m[mpos+i] ^ x[i];\n }\n return 0;\n}\n\nfunction crypto_stream_salsa20(c,cpos,b,n,k) {\n var z = new Uint8Array(16), x = new Uint8Array(64);\n var u, i;\n for (i = 0; i < 16; i++) z[i] = 0;\n for (i = 0; i < 8; i++) z[i] = n[i];\n while (b >= 64) {\n crypto_core_salsa20(x,z,k,sigma);\n for (i = 0; i < 64; i++) c[cpos+i] = x[i];\n u = 1;\n for (i = 8; i < 16; i++) {\n u = u + (z[i] & 0xff) | 0;\n z[i] = u & 0xff;\n u >>>= 8;\n }\n b -= 64;\n cpos += 64;\n }\n if (b > 0) {\n crypto_core_salsa20(x,z,k,sigma);\n for (i = 0; i < b; i++) c[cpos+i] = x[i];\n }\n return 0;\n}\n\nfunction crypto_stream(c,cpos,d,n,k) {\n var s = new Uint8Array(32);\n crypto_core_hsalsa20(s,n,k,sigma);\n var sn = new Uint8Array(8);\n for (var i = 0; i < 8; i++) sn[i] = n[i+16];\n return crypto_stream_salsa20(c,cpos,d,sn,s);\n}\n\nfunction crypto_stream_xor(c,cpos,m,mpos,d,n,k) {\n var s = new Uint8Array(32);\n crypto_core_hsalsa20(s,n,k,sigma);\n var sn = new Uint8Array(8);\n for (var i = 0; i < 8; i++) sn[i] = n[i+16];\n return crypto_stream_salsa20_xor(c,cpos,m,mpos,d,sn,s);\n}\n\n/*\n* Port of Andrew Moon's Poly1305-donna-16. Public domain.\n* https://github.com/floodyberry/poly1305-donna\n*/\n\nvar poly1305 = function(key) {\n this.buffer = new Uint8Array(16);\n this.r = new Uint16Array(10);\n this.h = new Uint16Array(10);\n this.pad = new Uint16Array(8);\n this.leftover = 0;\n this.fin = 0;\n\n var t0, t1, t2, t3, t4, t5, t6, t7;\n\n t0 = key[ 0] & 0xff | (key[ 1] & 0xff) << 8; this.r[0] = ( t0 ) & 0x1fff;\n t1 = key[ 2] & 0xff | (key[ 3] & 0xff) << 8; this.r[1] = ((t0 >>> 13) | (t1 << 3)) & 0x1fff;\n t2 = key[ 4] & 0xff | (key[ 5] & 0xff) << 8; this.r[2] = ((t1 >>> 10) | (t2 << 6)) & 0x1f03;\n t3 = key[ 6] & 0xff | (key[ 7] & 0xff) << 8; this.r[3] = ((t2 >>> 7) | (t3 << 9)) & 0x1fff;\n t4 = key[ 8] & 0xff | (key[ 9] & 0xff) << 8; this.r[4] = ((t3 >>> 4) | (t4 << 12)) & 0x00ff;\n this.r[5] = ((t4 >>> 1)) & 0x1ffe;\n t5 = key[10] & 0xff | (key[11] & 0xff) << 8; this.r[6] = ((t4 >>> 14) | (t5 << 2)) & 0x1fff;\n t6 = key[12] & 0xff | (key[13] & 0xff) << 8; this.r[7] = ((t5 >>> 11) | (t6 << 5)) & 0x1f81;\n t7 = key[14] & 0xff | (key[15] & 0xff) << 8; this.r[8] = ((t6 >>> 8) | (t7 << 8)) & 0x1fff;\n this.r[9] = ((t7 >>> 5)) & 0x007f;\n\n this.pad[0] = key[16] & 0xff | (key[17] & 0xff) << 8;\n this.pad[1] = key[18] & 0xff | (key[19] & 0xff) << 8;\n this.pad[2] = key[20] & 0xff | (key[21] & 0xff) << 8;\n this.pad[3] = key[22] & 0xff | (key[23] & 0xff) << 8;\n this.pad[4] = key[24] & 0xff | (key[25] & 0xff) << 8;\n this.pad[5] = key[26] & 0xff | (key[27] & 0xff) << 8;\n this.pad[6] = key[28] & 0xff | (key[29] & 0xff) << 8;\n this.pad[7] = key[30] & 0xff | (key[31] & 0xff) << 8;\n};\n\npoly1305.prototype.blocks = function(m, mpos, bytes) {\n var hibit = this.fin ? 0 : (1 << 11);\n var t0, t1, t2, t3, t4, t5, t6, t7, c;\n var d0, d1, d2, d3, d4, d5, d6, d7, d8, d9;\n\n var h0 = this.h[0],\n h1 = this.h[1],\n h2 = this.h[2],\n h3 = this.h[3],\n h4 = this.h[4],\n h5 = this.h[5],\n h6 = this.h[6],\n h7 = this.h[7],\n h8 = this.h[8],\n h9 = this.h[9];\n\n var r0 = this.r[0],\n r1 = this.r[1],\n r2 = this.r[2],\n r3 = this.r[3],\n r4 = this.r[4],\n r5 = this.r[5],\n r6 = this.r[6],\n r7 = this.r[7],\n r8 = this.r[8],\n r9 = this.r[9];\n\n while (bytes >= 16) {\n t0 = m[mpos+ 0] & 0xff | (m[mpos+ 1] & 0xff) << 8; h0 += ( t0 ) & 0x1fff;\n t1 = m[mpos+ 2] & 0xff | (m[mpos+ 3] & 0xff) << 8; h1 += ((t0 >>> 13) | (t1 << 3)) & 0x1fff;\n t2 = m[mpos+ 4] & 0xff | (m[mpos+ 5] & 0xff) << 8; h2 += ((t1 >>> 10) | (t2 << 6)) & 0x1fff;\n t3 = m[mpos+ 6] & 0xff | (m[mpos+ 7] & 0xff) << 8; h3 += ((t2 >>> 7) | (t3 << 9)) & 0x1fff;\n t4 = m[mpos+ 8] & 0xff | (m[mpos+ 9] & 0xff) << 8; h4 += ((t3 >>> 4) | (t4 << 12)) & 0x1fff;\n h5 += ((t4 >>> 1)) & 0x1fff;\n t5 = m[mpos+10] & 0xff | (m[mpos+11] & 0xff) << 8; h6 += ((t4 >>> 14) | (t5 << 2)) & 0x1fff;\n t6 = m[mpos+12] & 0xff | (m[mpos+13] & 0xff) << 8; h7 += ((t5 >>> 11) | (t6 << 5)) & 0x1fff;\n t7 = m[mpos+14] & 0xff | (m[mpos+15] & 0xff) << 8; h8 += ((t6 >>> 8) | (t7 << 8)) & 0x1fff;\n h9 += ((t7 >>> 5)) | hibit;\n\n c = 0;\n\n d0 = c;\n d0 += h0 * r0;\n d0 += h1 * (5 * r9);\n d0 += h2 * (5 * r8);\n d0 += h3 * (5 * r7);\n d0 += h4 * (5 * r6);\n c = (d0 >>> 13); d0 &= 0x1fff;\n d0 += h5 * (5 * r5);\n d0 += h6 * (5 * r4);\n d0 += h7 * (5 * r3);\n d0 += h8 * (5 * r2);\n d0 += h9 * (5 * r1);\n c += (d0 >>> 13); d0 &= 0x1fff;\n\n d1 = c;\n d1 += h0 * r1;\n d1 += h1 * r0;\n d1 += h2 * (5 * r9);\n d1 += h3 * (5 * r8);\n d1 += h4 * (5 * r7);\n c = (d1 >>> 13); d1 &= 0x1fff;\n d1 += h5 * (5 * r6);\n d1 += h6 * (5 * r5);\n d1 += h7 * (5 * r4);\n d1 += h8 * (5 * r3);\n d1 += h9 * (5 * r2);\n c += (d1 >>> 13); d1 &= 0x1fff;\n\n d2 = c;\n d2 += h0 * r2;\n d2 += h1 * r1;\n d2 += h2 * r0;\n d2 += h3 * (5 * r9);\n d2 += h4 * (5 * r8);\n c = (d2 >>> 13); d2 &= 0x1fff;\n d2 += h5 * (5 * r7);\n d2 += h6 * (5 * r6);\n d2 += h7 * (5 * r5);\n d2 += h8 * (5 * r4);\n d2 += h9 * (5 * r3);\n c += (d2 >>> 13); d2 &= 0x1fff;\n\n d3 = c;\n d3 += h0 * r3;\n d3 += h1 * r2;\n d3 += h2 * r1;\n d3 += h3 * r0;\n d3 += h4 * (5 * r9);\n c = (d3 >>> 13); d3 &= 0x1fff;\n d3 += h5 * (5 * r8);\n d3 += h6 * (5 * r7);\n d3 += h7 * (5 * r6);\n d3 += h8 * (5 * r5);\n d3 += h9 * (5 * r4);\n c += (d3 >>> 13); d3 &= 0x1fff;\n\n d4 = c;\n d4 += h0 * r4;\n d4 += h1 * r3;\n d4 += h2 * r2;\n d4 += h3 * r1;\n d4 += h4 * r0;\n c = (d4 >>> 13); d4 &= 0x1fff;\n d4 += h5 * (5 * r9);\n d4 += h6 * (5 * r8);\n d4 += h7 * (5 * r7);\n d4 += h8 * (5 * r6);\n d4 += h9 * (5 * r5);\n c += (d4 >>> 13); d4 &= 0x1fff;\n\n d5 = c;\n d5 += h0 * r5;\n d5 += h1 * r4;\n d5 += h2 * r3;\n d5 += h3 * r2;\n d5 += h4 * r1;\n c = (d5 >>> 13); d5 &= 0x1fff;\n d5 += h5 * r0;\n d5 += h6 * (5 * r9);\n d5 += h7 * (5 * r8);\n d5 += h8 * (5 * r7);\n d5 += h9 * (5 * r6);\n c += (d5 >>> 13); d5 &= 0x1fff;\n\n d6 = c;\n d6 += h0 * r6;\n d6 += h1 * r5;\n d6 += h2 * r4;\n d6 += h3 * r3;\n d6 += h4 * r2;\n c = (d6 >>> 13); d6 &= 0x1fff;\n d6 += h5 * r1;\n d6 += h6 * r0;\n d6 += h7 * (5 * r9);\n d6 += h8 * (5 * r8);\n d6 += h9 * (5 * r7);\n c += (d6 >>> 13); d6 &= 0x1fff;\n\n d7 = c;\n d7 += h0 * r7;\n d7 += h1 * r6;\n d7 += h2 * r5;\n d7 += h3 * r4;\n d7 += h4 * r3;\n c = (d7 >>> 13); d7 &= 0x1fff;\n d7 += h5 * r2;\n d7 += h6 * r1;\n d7 += h7 * r0;\n d7 += h8 * (5 * r9);\n d7 += h9 * (5 * r8);\n c += (d7 >>> 13); d7 &= 0x1fff;\n\n d8 = c;\n d8 += h0 * r8;\n d8 += h1 * r7;\n d8 += h2 * r6;\n d8 += h3 * r5;\n d8 += h4 * r4;\n c = (d8 >>> 13); d8 &= 0x1fff;\n d8 += h5 * r3;\n d8 += h6 * r2;\n d8 += h7 * r1;\n d8 += h8 * r0;\n d8 += h9 * (5 * r9);\n c += (d8 >>> 13); d8 &= 0x1fff;\n\n d9 = c;\n d9 += h0 * r9;\n d9 += h1 * r8;\n d9 += h2 * r7;\n d9 += h3 * r6;\n d9 += h4 * r5;\n c = (d9 >>> 13); d9 &= 0x1fff;\n d9 += h5 * r4;\n d9 += h6 * r3;\n d9 += h7 * r2;\n d9 += h8 * r1;\n d9 += h9 * r0;\n c += (d9 >>> 13); d9 &= 0x1fff;\n\n c = (((c << 2) + c)) | 0;\n c = (c + d0) | 0;\n d0 = c & 0x1fff;\n c = (c >>> 13);\n d1 += c;\n\n h0 = d0;\n h1 = d1;\n h2 = d2;\n h3 = d3;\n h4 = d4;\n h5 = d5;\n h6 = d6;\n h7 = d7;\n h8 = d8;\n h9 = d9;\n\n mpos += 16;\n bytes -= 16;\n }\n this.h[0] = h0;\n this.h[1] = h1;\n this.h[2] = h2;\n this.h[3] = h3;\n this.h[4] = h4;\n this.h[5] = h5;\n this.h[6] = h6;\n this.h[7] = h7;\n this.h[8] = h8;\n this.h[9] = h9;\n};\n\npoly1305.prototype.finish = function(mac, macpos) {\n var g = new Uint16Array(10);\n var c, mask, f, i;\n\n if (this.leftover) {\n i = this.leftover;\n this.buffer[i++] = 1;\n for (; i < 16; i++) this.buffer[i] = 0;\n this.fin = 1;\n this.blocks(this.buffer, 0, 16);\n }\n\n c = this.h[1] >>> 13;\n this.h[1] &= 0x1fff;\n for (i = 2; i < 10; i++) {\n this.h[i] += c;\n c = this.h[i] >>> 13;\n this.h[i] &= 0x1fff;\n }\n this.h[0] += (c * 5);\n c = this.h[0] >>> 13;\n this.h[0] &= 0x1fff;\n this.h[1] += c;\n c = this.h[1] >>> 13;\n this.h[1] &= 0x1fff;\n this.h[2] += c;\n\n g[0] = this.h[0] + 5;\n c = g[0] >>> 13;\n g[0] &= 0x1fff;\n for (i = 1; i < 10; i++) {\n g[i] = this.h[i] + c;\n c = g[i] >>> 13;\n g[i] &= 0x1fff;\n }\n g[9] -= (1 << 13);\n\n mask = (c ^ 1) - 1;\n for (i = 0; i < 10; i++) g[i] &= mask;\n mask = ~mask;\n for (i = 0; i < 10; i++) this.h[i] = (this.h[i] & mask) | g[i];\n\n this.h[0] = ((this.h[0] ) | (this.h[1] << 13) ) & 0xffff;\n this.h[1] = ((this.h[1] >>> 3) | (this.h[2] << 10) ) & 0xffff;\n this.h[2] = ((this.h[2] >>> 6) | (this.h[3] << 7) ) & 0xffff;\n this.h[3] = ((this.h[3] >>> 9) | (this.h[4] << 4) ) & 0xffff;\n this.h[4] = ((this.h[4] >>> 12) | (this.h[5] << 1) | (this.h[6] << 14)) & 0xffff;\n this.h[5] = ((this.h[6] >>> 2) | (this.h[7] << 11) ) & 0xffff;\n this.h[6] = ((this.h[7] >>> 5) | (this.h[8] << 8) ) & 0xffff;\n this.h[7] = ((this.h[8] >>> 8) | (this.h[9] << 5) ) & 0xffff;\n\n f = this.h[0] + this.pad[0];\n this.h[0] = f & 0xffff;\n for (i = 1; i < 8; i++) {\n f = (((this.h[i] + this.pad[i]) | 0) + (f >>> 16)) | 0;\n this.h[i] = f & 0xffff;\n }\n\n mac[macpos+ 0] = (this.h[0] >>> 0) & 0xff;\n mac[macpos+ 1] = (this.h[0] >>> 8) & 0xff;\n mac[macpos+ 2] = (this.h[1] >>> 0) & 0xff;\n mac[macpos+ 3] = (this.h[1] >>> 8) & 0xff;\n mac[macpos+ 4] = (this.h[2] >>> 0) & 0xff;\n mac[macpos+ 5] = (this.h[2] >>> 8) & 0xff;\n mac[macpos+ 6] = (this.h[3] >>> 0) & 0xff;\n mac[macpos+ 7] = (this.h[3] >>> 8) & 0xff;\n mac[macpos+ 8] = (this.h[4] >>> 0) & 0xff;\n mac[macpos+ 9] = (this.h[4] >>> 8) & 0xff;\n mac[macpos+10] = (this.h[5] >>> 0) & 0xff;\n mac[macpos+11] = (this.h[5] >>> 8) & 0xff;\n mac[macpos+12] = (this.h[6] >>> 0) & 0xff;\n mac[macpos+13] = (this.h[6] >>> 8) & 0xff;\n mac[macpos+14] = (this.h[7] >>> 0) & 0xff;\n mac[macpos+15] = (this.h[7] >>> 8) & 0xff;\n};\n\npoly1305.prototype.update = function(m, mpos, bytes) {\n var i, want;\n\n if (this.leftover) {\n want = (16 - this.leftover);\n if (want > bytes)\n want = bytes;\n for (i = 0; i < want; i++)\n this.buffer[this.leftover + i] = m[mpos+i];\n bytes -= want;\n mpos += want;\n this.leftover += want;\n if (this.leftover < 16)\n return;\n this.blocks(this.buffer, 0, 16);\n this.leftover = 0;\n }\n\n if (bytes >= 16) {\n want = bytes - (bytes % 16);\n this.blocks(m, mpos, want);\n mpos += want;\n bytes -= want;\n }\n\n if (bytes) {\n for (i = 0; i < bytes; i++)\n this.buffer[this.leftover + i] = m[mpos+i];\n this.leftover += bytes;\n }\n};\n\nfunction crypto_onetimeauth(out, outpos, m, mpos, n, k) {\n var s = new poly1305(k);\n s.update(m, mpos, n);\n s.finish(out, outpos);\n return 0;\n}\n\nfunction crypto_onetimeauth_verify(h, hpos, m, mpos, n, k) {\n var x = new Uint8Array(16);\n crypto_onetimeauth(x,0,m,mpos,n,k);\n return crypto_verify_16(h,hpos,x,0);\n}\n\nfunction crypto_secretbox(c,m,d,n,k) {\n var i;\n if (d < 32) return -1;\n crypto_stream_xor(c,0,m,0,d,n,k);\n crypto_onetimeauth(c, 16, c, 32, d - 32, c);\n for (i = 0; i < 16; i++) c[i] = 0;\n return 0;\n}\n\nfunction crypto_secretbox_open(m,c,d,n,k) {\n var i;\n var x = new Uint8Array(32);\n if (d < 32) return -1;\n crypto_stream(x,0,32,n,k);\n if (crypto_onetimeauth_verify(c, 16,c, 32,d - 32,x) !== 0) return -1;\n crypto_stream_xor(m,0,c,0,d,n,k);\n for (i = 0; i < 32; i++) m[i] = 0;\n return 0;\n}\n\nfunction set25519(r, a) {\n var i;\n for (i = 0; i < 16; i++) r[i] = a[i]|0;\n}\n\nfunction car25519(o) {\n var i, v, c = 1;\n for (i = 0; i < 16; i++) {\n v = o[i] + c + 65535;\n c = Math.floor(v / 65536);\n o[i] = v - c * 65536;\n }\n o[0] += c-1 + 37 * (c-1);\n}\n\nfunction sel25519(p, q, b) {\n var t, c = ~(b-1);\n for (var i = 0; i < 16; i++) {\n t = c & (p[i] ^ q[i]);\n p[i] ^= t;\n q[i] ^= t;\n }\n}\n\nfunction pack25519(o, n) {\n var i, j, b;\n var m = gf(), t = gf();\n for (i = 0; i < 16; i++) t[i] = n[i];\n car25519(t);\n car25519(t);\n car25519(t);\n for (j = 0; j < 2; j++) {\n m[0] = t[0] - 0xffed;\n for (i = 1; i < 15; i++) {\n m[i] = t[i] - 0xffff - ((m[i-1]>>16) & 1);\n m[i-1] &= 0xffff;\n }\n m[15] = t[15] - 0x7fff - ((m[14]>>16) & 1);\n b = (m[15]>>16) & 1;\n m[14] &= 0xffff;\n sel25519(t, m, 1-b);\n }\n for (i = 0; i < 16; i++) {\n o[2*i] = t[i] & 0xff;\n o[2*i+1] = t[i]>>8;\n }\n}\n\nfunction neq25519(a, b) {\n var c = new Uint8Array(32), d = new Uint8Array(32);\n pack25519(c, a);\n pack25519(d, b);\n return crypto_verify_32(c, 0, d, 0);\n}\n\nfunction par25519(a) {\n var d = new Uint8Array(32);\n pack25519(d, a);\n return d[0] & 1;\n}\n\nfunction unpack25519(o, n) {\n var i;\n for (i = 0; i < 16; i++) o[i] = n[2*i] + (n[2*i+1] << 8);\n o[15] &= 0x7fff;\n}\n\nfunction A(o, a, b) {\n for (var i = 0; i < 16; i++) o[i] = a[i] + b[i];\n}\n\nfunction Z(o, a, b) {\n for (var i = 0; i < 16; i++) o[i] = a[i] - b[i];\n}\n\nfunction M(o, a, b) {\n var v, c,\n t0 = 0, t1 = 0, t2 = 0, t3 = 0, t4 = 0, t5 = 0, t6 = 0, t7 = 0,\n t8 = 0, t9 = 0, t10 = 0, t11 = 0, t12 = 0, t13 = 0, t14 = 0, t15 = 0,\n t16 = 0, t17 = 0, t18 = 0, t19 = 0, t20 = 0, t21 = 0, t22 = 0, t23 = 0,\n t24 = 0, t25 = 0, t26 = 0, t27 = 0, t28 = 0, t29 = 0, t30 = 0,\n b0 = b[0],\n b1 = b[1],\n b2 = b[2],\n b3 = b[3],\n b4 = b[4],\n b5 = b[5],\n b6 = b[6],\n b7 = b[7],\n b8 = b[8],\n b9 = b[9],\n b10 = b[10],\n b11 = b[11],\n b12 = b[12],\n b13 = b[13],\n b14 = b[14],\n b15 = b[15];\n\n v = a[0];\n t0 += v * b0;\n t1 += v * b1;\n t2 += v * b2;\n t3 += v * b3;\n t4 += v * b4;\n t5 += v * b5;\n t6 += v * b6;\n t7 += v * b7;\n t8 += v * b8;\n t9 += v * b9;\n t10 += v * b10;\n t11 += v * b11;\n t12 += v * b12;\n t13 += v * b13;\n t14 += v * b14;\n t15 += v * b15;\n v = a[1];\n t1 += v * b0;\n t2 += v * b1;\n t3 += v * b2;\n t4 += v * b3;\n t5 += v * b4;\n t6 += v * b5;\n t7 += v * b6;\n t8 += v * b7;\n t9 += v * b8;\n t10 += v * b9;\n t11 += v * b10;\n t12 += v * b11;\n t13 += v * b12;\n t14 += v * b13;\n t15 += v * b14;\n t16 += v * b15;\n v = a[2];\n t2 += v * b0;\n t3 += v * b1;\n t4 += v * b2;\n t5 += v * b3;\n t6 += v * b4;\n t7 += v * b5;\n t8 += v * b6;\n t9 += v * b7;\n t10 += v * b8;\n t11 += v * b9;\n t12 += v * b10;\n t13 += v * b11;\n t14 += v * b12;\n t15 += v * b13;\n t16 += v * b14;\n t17 += v * b15;\n v = a[3];\n t3 += v * b0;\n t4 += v * b1;\n t5 += v * b2;\n t6 += v * b3;\n t7 += v * b4;\n t8 += v * b5;\n t9 += v * b6;\n t10 += v * b7;\n t11 += v * b8;\n t12 += v * b9;\n t13 += v * b10;\n t14 += v * b11;\n t15 += v * b12;\n t16 += v * b13;\n t17 += v * b14;\n t18 += v * b15;\n v = a[4];\n t4 += v * b0;\n t5 += v * b1;\n t6 += v * b2;\n t7 += v * b3;\n t8 += v * b4;\n t9 += v * b5;\n t10 += v * b6;\n t11 += v * b7;\n t12 += v * b8;\n t13 += v * b9;\n t14 += v * b10;\n t15 += v * b11;\n t16 += v * b12;\n t17 += v * b13;\n t18 += v * b14;\n t19 += v * b15;\n v = a[5];\n t5 += v * b0;\n t6 += v * b1;\n t7 += v * b2;\n t8 += v * b3;\n t9 += v * b4;\n t10 += v * b5;\n t11 += v * b6;\n t12 += v * b7;\n t13 += v * b8;\n t14 += v * b9;\n t15 += v * b10;\n t16 += v * b11;\n t17 += v * b12;\n t18 += v * b13;\n t19 += v * b14;\n t20 += v * b15;\n v = a[6];\n t6 += v * b0;\n t7 += v * b1;\n t8 += v * b2;\n t9 += v * b3;\n t10 += v * b4;\n t11 += v * b5;\n t12 += v * b6;\n t13 += v * b7;\n t14 += v * b8;\n t15 += v * b9;\n t16 += v * b10;\n t17 += v * b11;\n t18 += v * b12;\n t19 += v * b13;\n t20 += v * b14;\n t21 += v * b15;\n v = a[7];\n t7 += v * b0;\n t8 += v * b1;\n t9 += v * b2;\n t10 += v * b3;\n t11 += v * b4;\n t12 += v * b5;\n t13 += v * b6;\n t14 += v * b7;\n t15 += v * b8;\n t16 += v * b9;\n t17 += v * b10;\n t18 += v * b11;\n t19 += v * b12;\n t20 += v * b13;\n t21 += v * b14;\n t22 += v * b15;\n v = a[8];\n t8 += v * b0;\n t9 += v * b1;\n t10 += v * b2;\n t11 += v * b3;\n t12 += v * b4;\n t13 += v * b5;\n t14 += v * b6;\n t15 += v * b7;\n t16 += v * b8;\n t17 += v * b9;\n t18 += v * b10;\n t19 += v * b11;\n t20 += v * b12;\n t21 += v * b13;\n t22 += v * b14;\n t23 += v * b15;\n v = a[9];\n t9 += v * b0;\n t10 += v * b1;\n t11 += v * b2;\n t12 += v * b3;\n t13 += v * b4;\n t14 += v * b5;\n t15 += v * b6;\n t16 += v * b7;\n t17 += v * b8;\n t18 += v * b9;\n t19 += v * b10;\n t20 += v * b11;\n t21 += v * b12;\n t22 += v * b13;\n t23 += v * b14;\n t24 += v * b15;\n v = a[10];\n t10 += v * b0;\n t11 += v * b1;\n t12 += v * b2;\n t13 += v * b3;\n t14 += v * b4;\n t15 += v * b5;\n t16 += v * b6;\n t17 += v * b7;\n t18 += v * b8;\n t19 += v * b9;\n t20 += v * b10;\n t21 += v * b11;\n t22 += v * b12;\n t23 += v * b13;\n t24 += v * b14;\n t25 += v * b15;\n v = a[11];\n t11 += v * b0;\n t12 += v * b1;\n t13 += v * b2;\n t14 += v * b3;\n t15 += v * b4;\n t16 += v * b5;\n t17 += v * b6;\n t18 += v * b7;\n t19 += v * b8;\n t20 += v * b9;\n t21 += v * b10;\n t22 += v * b11;\n t23 += v * b12;\n t24 += v * b13;\n t25 += v * b14;\n t26 += v * b15;\n v = a[12];\n t12 += v * b0;\n t13 += v * b1;\n t14 += v * b2;\n t15 += v * b3;\n t16 += v * b4;\n t17 += v * b5;\n t18 += v * b6;\n t19 += v * b7;\n t20 += v * b8;\n t21 += v * b9;\n t22 += v * b10;\n t23 += v * b11;\n t24 += v * b12;\n t25 += v * b13;\n t26 += v * b14;\n t27 += v * b15;\n v = a[13];\n t13 += v * b0;\n t14 += v * b1;\n t15 += v * b2;\n t16 += v * b3;\n t17 += v * b4;\n t18 += v * b5;\n t19 += v * b6;\n t20 += v * b7;\n t21 += v * b8;\n t22 += v * b9;\n t23 += v * b10;\n t24 += v * b11;\n t25 += v * b12;\n t26 += v * b13;\n t27 += v * b14;\n t28 += v * b15;\n v = a[14];\n t14 += v * b0;\n t15 += v * b1;\n t16 += v * b2;\n t17 += v * b3;\n t18 += v * b4;\n t19 += v * b5;\n t20 += v * b6;\n t21 += v * b7;\n t22 += v * b8;\n t23 += v * b9;\n t24 += v * b10;\n t25 += v * b11;\n t26 += v * b12;\n t27 += v * b13;\n t28 += v * b14;\n t29 += v * b15;\n v = a[15];\n t15 += v * b0;\n t16 += v * b1;\n t17 += v * b2;\n t18 += v * b3;\n t19 += v * b4;\n t20 += v * b5;\n t21 += v * b6;\n t22 += v * b7;\n t23 += v * b8;\n t24 += v * b9;\n t25 += v * b10;\n t26 += v * b11;\n t27 += v * b12;\n t28 += v * b13;\n t29 += v * b14;\n t30 += v * b15;\n\n t0 += 38 * t16;\n t1 += 38 * t17;\n t2 += 38 * t18;\n t3 += 38 * t19;\n t4 += 38 * t20;\n t5 += 38 * t21;\n t6 += 38 * t22;\n t7 += 38 * t23;\n t8 += 38 * t24;\n t9 += 38 * t25;\n t10 += 38 * t26;\n t11 += 38 * t27;\n t12 += 38 * t28;\n t13 += 38 * t29;\n t14 += 38 * t30;\n // t15 left as is\n\n // first car\n c = 1;\n v = t0 + c + 65535; c = Math.floor(v / 65536); t0 = v - c * 65536;\n v = t1 + c + 65535; c = Math.floor(v / 65536); t1 = v - c * 65536;\n v = t2 + c + 65535; c = Math.floor(v / 65536); t2 = v - c * 65536;\n v = t3 + c + 65535; c = Math.floor(v / 65536); t3 = v - c * 65536;\n v = t4 + c + 65535; c = Math.floor(v / 65536); t4 = v - c * 65536;\n v = t5 + c + 65535; c = Math.floor(v / 65536); t5 = v - c * 65536;\n v = t6 + c + 65535; c = Math.floor(v / 65536); t6 = v - c * 65536;\n v = t7 + c + 65535; c = Math.floor(v / 65536); t7 = v - c * 65536;\n v = t8 + c + 65535; c = Math.floor(v / 65536); t8 = v - c * 65536;\n v = t9 + c + 65535; c = Math.floor(v / 65536); t9 = v - c * 65536;\n v = t10 + c + 65535; c = Math.floor(v / 65536); t10 = v - c * 65536;\n v = t11 + c + 65535; c = Math.floor(v / 65536); t11 = v - c * 65536;\n v = t12 + c + 65535; c = Math.floor(v / 65536); t12 = v - c * 65536;\n v = t13 + c + 65535; c = Math.floor(v / 65536); t13 = v - c * 65536;\n v = t14 + c + 65535; c = Math.floor(v / 65536); t14 = v - c * 65536;\n v = t15 + c + 65535; c = Math.floor(v / 65536); t15 = v - c * 65536;\n t0 += c-1 + 37 * (c-1);\n\n // second car\n c = 1;\n v = t0 + c + 65535; c = Math.floor(v / 65536); t0 = v - c * 65536;\n v = t1 + c + 65535; c = Math.floor(v / 65536); t1 = v - c * 65536;\n v = t2 + c + 65535; c = Math.floor(v / 65536); t2 = v - c * 65536;\n v = t3 + c + 65535; c = Math.floor(v / 65536); t3 = v - c * 65536;\n v = t4 + c + 65535; c = Math.floor(v / 65536); t4 = v - c * 65536;\n v = t5 + c + 65535; c = Math.floor(v / 65536); t5 = v - c * 65536;\n v = t6 + c + 65535; c = Math.floor(v / 65536); t6 = v - c * 65536;\n v = t7 + c + 65535; c = Math.floor(v / 65536); t7 = v - c * 65536;\n v = t8 + c + 65535; c = Math.floor(v / 65536); t8 = v - c * 65536;\n v = t9 + c + 65535; c = Math.floor(v / 65536); t9 = v - c * 65536;\n v = t10 + c + 65535; c = Math.floor(v / 65536); t10 = v - c * 65536;\n v = t11 + c + 65535; c = Math.floor(v / 65536); t11 = v - c * 65536;\n v = t12 + c + 65535; c = Math.floor(v / 65536); t12 = v - c * 65536;\n v = t13 + c + 65535; c = Math.floor(v / 65536); t13 = v - c * 65536;\n v = t14 + c + 65535; c = Math.floor(v / 65536); t14 = v - c * 65536;\n v = t15 + c + 65535; c = Math.floor(v / 65536); t15 = v - c * 65536;\n t0 += c-1 + 37 * (c-1);\n\n o[ 0] = t0;\n o[ 1] = t1;\n o[ 2] = t2;\n o[ 3] = t3;\n o[ 4] = t4;\n o[ 5] = t5;\n o[ 6] = t6;\n o[ 7] = t7;\n o[ 8] = t8;\n o[ 9] = t9;\n o[10] = t10;\n o[11] = t11;\n o[12] = t12;\n o[13] = t13;\n o[14] = t14;\n o[15] = t15;\n}\n\nfunction S(o, a) {\n M(o, a, a);\n}\n\nfunction inv25519(o, i) {\n var c = gf();\n var a;\n for (a = 0; a < 16; a++) c[a] = i[a];\n for (a = 253; a >= 0; a--) {\n S(c, c);\n if(a !== 2 && a !== 4) M(c, c, i);\n }\n for (a = 0; a < 16; a++) o[a] = c[a];\n}\n\nfunction pow2523(o, i) {\n var c = gf();\n var a;\n for (a = 0; a < 16; a++) c[a] = i[a];\n for (a = 250; a >= 0; a--) {\n S(c, c);\n if(a !== 1) M(c, c, i);\n }\n for (a = 0; a < 16; a++) o[a] = c[a];\n}\n\nfunction crypto_scalarmult(q, n, p) {\n var z = new Uint8Array(32);\n var x = new Float64Array(80), r, i;\n var a = gf(), b = gf(), c = gf(),\n d = gf(), e = gf(), f = gf();\n for (i = 0; i < 31; i++) z[i] = n[i];\n z[31]=(n[31]&127)|64;\n z[0]&=248;\n unpack25519(x,p);\n for (i = 0; i < 16; i++) {\n b[i]=x[i];\n d[i]=a[i]=c[i]=0;\n }\n a[0]=d[0]=1;\n for (i=254; i>=0; --i) {\n r=(z[i>>>3]>>>(i&7))&1;\n sel25519(a,b,r);\n sel25519(c,d,r);\n A(e,a,c);\n Z(a,a,c);\n A(c,b,d);\n Z(b,b,d);\n S(d,e);\n S(f,a);\n M(a,c,a);\n M(c,b,e);\n A(e,a,c);\n Z(a,a,c);\n S(b,a);\n Z(c,d,f);\n M(a,c,_121665);\n A(a,a,d);\n M(c,c,a);\n M(a,d,f);\n M(d,b,x);\n S(b,e);\n sel25519(a,b,r);\n sel25519(c,d,r);\n }\n for (i = 0; i < 16; i++) {\n x[i+16]=a[i];\n x[i+32]=c[i];\n x[i+48]=b[i];\n x[i+64]=d[i];\n }\n var x32 = x.subarray(32);\n var x16 = x.subarray(16);\n inv25519(x32,x32);\n M(x16,x16,x32);\n pack25519(q,x16);\n return 0;\n}\n\nfunction crypto_scalarmult_base(q, n) {\n return crypto_scalarmult(q, n, _9);\n}\n\nfunction crypto_box_keypair(y, x) {\n randombytes(x, 32);\n return crypto_scalarmult_base(y, x);\n}\n\nfunction crypto_box_beforenm(k, y, x) {\n var s = new Uint8Array(32);\n crypto_scalarmult(s, x, y);\n return crypto_core_hsalsa20(k, _0, s, sigma);\n}\n\nvar crypto_box_afternm = crypto_secretbox;\nvar crypto_box_open_afternm = crypto_secretbox_open;\n\nfunction crypto_box(c, m, d, n, y, x) {\n var k = new Uint8Array(32);\n crypto_box_beforenm(k, y, x);\n return crypto_box_afternm(c, m, d, n, k);\n}\n\nfunction crypto_box_open(m, c, d, n, y, x) {\n var k = new Uint8Array(32);\n crypto_box_beforenm(k, y, x);\n return crypto_box_open_afternm(m, c, d, n, k);\n}\n\nvar K = [\n 0x428a2f98, 0xd728ae22, 0x71374491, 0x23ef65cd,\n 0xb5c0fbcf, 0xec4d3b2f, 0xe9b5dba5, 0x8189dbbc,\n 0x3956c25b, 0xf348b538, 0x59f111f1, 0xb605d019,\n 0x923f82a4, 0xaf194f9b, 0xab1c5ed5, 0xda6d8118,\n 0xd807aa98, 0xa3030242, 0x12835b01, 0x45706fbe,\n 0x243185be, 0x4ee4b28c, 0x550c7dc3, 0xd5ffb4e2,\n 0x72be5d74, 0xf27b896f, 0x80deb1fe, 0x3b1696b1,\n 0x9bdc06a7, 0x25c71235, 0xc19bf174, 0xcf692694,\n 0xe49b69c1, 0x9ef14ad2, 0xefbe4786, 0x384f25e3,\n 0x0fc19dc6, 0x8b8cd5b5, 0x240ca1cc, 0x77ac9c65,\n 0x2de92c6f, 0x592b0275, 0x4a7484aa, 0x6ea6e483,\n 0x5cb0a9dc, 0xbd41fbd4, 0x76f988da, 0x831153b5,\n 0x983e5152, 0xee66dfab, 0xa831c66d, 0x2db43210,\n 0xb00327c8, 0x98fb213f, 0xbf597fc7, 0xbeef0ee4,\n 0xc6e00bf3, 0x3da88fc2, 0xd5a79147, 0x930aa725,\n 0x06ca6351, 0xe003826f, 0x14292967, 0x0a0e6e70,\n 0x27b70a85, 0x46d22ffc, 0x2e1b2138, 0x5c26c926,\n 0x4d2c6dfc, 0x5ac42aed, 0x53380d13, 0x9d95b3df,\n 0x650a7354, 0x8baf63de, 0x766a0abb, 0x3c77b2a8,\n 0x81c2c92e, 0x47edaee6, 0x92722c85, 0x1482353b,\n 0xa2bfe8a1, 0x4cf10364, 0xa81a664b, 0xbc423001,\n 0xc24b8b70, 0xd0f89791, 0xc76c51a3, 0x0654be30,\n 0xd192e819, 0xd6ef5218, 0xd6990624, 0x5565a910,\n 0xf40e3585, 0x5771202a, 0x106aa070, 0x32bbd1b8,\n 0x19a4c116, 0xb8d2d0c8, 0x1e376c08, 0x5141ab53,\n 0x2748774c, 0xdf8eeb99, 0x34b0bcb5, 0xe19b48a8,\n 0x391c0cb3, 0xc5c95a63, 0x4ed8aa4a, 0xe3418acb,\n 0x5b9cca4f, 0x7763e373, 0x682e6ff3, 0xd6b2b8a3,\n 0x748f82ee, 0x5defb2fc, 0x78a5636f, 0x43172f60,\n 0x84c87814, 0xa1f0ab72, 0x8cc70208, 0x1a6439ec,\n 0x90befffa, 0x23631e28, 0xa4506ceb, 0xde82bde9,\n 0xbef9a3f7, 0xb2c67915, 0xc67178f2, 0xe372532b,\n 0xca273ece, 0xea26619c, 0xd186b8c7, 0x21c0c207,\n 0xeada7dd6, 0xcde0eb1e, 0xf57d4f7f, 0xee6ed178,\n 0x06f067aa, 0x72176fba, 0x0a637dc5, 0xa2c898a6,\n 0x113f9804, 0xbef90dae, 0x1b710b35, 0x131c471b,\n 0x28db77f5, 0x23047d84, 0x32caab7b, 0x40c72493,\n 0x3c9ebe0a, 0x15c9bebc, 0x431d67c4, 0x9c100d4c,\n 0x4cc5d4be, 0xcb3e42b6, 0x597f299c, 0xfc657e2a,\n 0x5fcb6fab, 0x3ad6faec, 0x6c44198c, 0x4a475817\n];\n\nfunction crypto_hashblocks_hl(hh, hl, m, n) {\n var wh = new Int32Array(16), wl = new Int32Array(16),\n bh0, bh1, bh2, bh3, bh4, bh5, bh6, bh7,\n bl0, bl1, bl2, bl3, bl4, bl5, bl6, bl7,\n th, tl, i, j, h, l, a, b, c, d;\n\n var ah0 = hh[0],\n ah1 = hh[1],\n ah2 = hh[2],\n ah3 = hh[3],\n ah4 = hh[4],\n ah5 = hh[5],\n ah6 = hh[6],\n ah7 = hh[7],\n\n al0 = hl[0],\n al1 = hl[1],\n al2 = hl[2],\n al3 = hl[3],\n al4 = hl[4],\n al5 = hl[5],\n al6 = hl[6],\n al7 = hl[7];\n\n var pos = 0;\n while (n >= 128) {\n for (i = 0; i < 16; i++) {\n j = 8 * i + pos;\n wh[i] = (m[j+0] << 24) | (m[j+1] << 16) | (m[j+2] << 8) | m[j+3];\n wl[i] = (m[j+4] << 24) | (m[j+5] << 16) | (m[j+6] << 8) | m[j+7];\n }\n for (i = 0; i < 80; i++) {\n bh0 = ah0;\n bh1 = ah1;\n bh2 = ah2;\n bh3 = ah3;\n bh4 = ah4;\n bh5 = ah5;\n bh6 = ah6;\n bh7 = ah7;\n\n bl0 = al0;\n bl1 = al1;\n bl2 = al2;\n bl3 = al3;\n bl4 = al4;\n bl5 = al5;\n bl6 = al6;\n bl7 = al7;\n\n // add\n h = ah7;\n l = al7;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n // Sigma1\n h = ((ah4 >>> 14) | (al4 << (32-14))) ^ ((ah4 >>> 18) | (al4 << (32-18))) ^ ((al4 >>> (41-32)) | (ah4 << (32-(41-32))));\n l = ((al4 >>> 14) | (ah4 << (32-14))) ^ ((al4 >>> 18) | (ah4 << (32-18))) ^ ((ah4 >>> (41-32)) | (al4 << (32-(41-32))));\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // Ch\n h = (ah4 & ah5) ^ (~ah4 & ah6);\n l = (al4 & al5) ^ (~al4 & al6);\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // K\n h = K[i*2];\n l = K[i*2+1];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // w\n h = wh[i%16];\n l = wl[i%16];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n th = c & 0xffff | d << 16;\n tl = a & 0xffff | b << 16;\n\n // add\n h = th;\n l = tl;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n // Sigma0\n h = ((ah0 >>> 28) | (al0 << (32-28))) ^ ((al0 >>> (34-32)) | (ah0 << (32-(34-32)))) ^ ((al0 >>> (39-32)) | (ah0 << (32-(39-32))));\n l = ((al0 >>> 28) | (ah0 << (32-28))) ^ ((ah0 >>> (34-32)) | (al0 << (32-(34-32)))) ^ ((ah0 >>> (39-32)) | (al0 << (32-(39-32))));\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // Maj\n h = (ah0 & ah1) ^ (ah0 & ah2) ^ (ah1 & ah2);\n l = (al0 & al1) ^ (al0 & al2) ^ (al1 & al2);\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n bh7 = (c & 0xffff) | (d << 16);\n bl7 = (a & 0xffff) | (b << 16);\n\n // add\n h = bh3;\n l = bl3;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = th;\n l = tl;\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n bh3 = (c & 0xffff) | (d << 16);\n bl3 = (a & 0xffff) | (b << 16);\n\n ah1 = bh0;\n ah2 = bh1;\n ah3 = bh2;\n ah4 = bh3;\n ah5 = bh4;\n ah6 = bh5;\n ah7 = bh6;\n ah0 = bh7;\n\n al1 = bl0;\n al2 = bl1;\n al3 = bl2;\n al4 = bl3;\n al5 = bl4;\n al6 = bl5;\n al7 = bl6;\n al0 = bl7;\n\n if (i%16 === 15) {\n for (j = 0; j < 16; j++) {\n // add\n h = wh[j];\n l = wl[j];\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = wh[(j+9)%16];\n l = wl[(j+9)%16];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // sigma0\n th = wh[(j+1)%16];\n tl = wl[(j+1)%16];\n h = ((th >>> 1) | (tl << (32-1))) ^ ((th >>> 8) | (tl << (32-8))) ^ (th >>> 7);\n l = ((tl >>> 1) | (th << (32-1))) ^ ((tl >>> 8) | (th << (32-8))) ^ ((tl >>> 7) | (th << (32-7)));\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // sigma1\n th = wh[(j+14)%16];\n tl = wl[(j+14)%16];\n h = ((th >>> 19) | (tl << (32-19))) ^ ((tl >>> (61-32)) | (th << (32-(61-32)))) ^ (th >>> 6);\n l = ((tl >>> 19) | (th << (32-19))) ^ ((th >>> (61-32)) | (tl << (32-(61-32)))) ^ ((tl >>> 6) | (th << (32-6)));\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n wh[j] = (c & 0xffff) | (d << 16);\n wl[j] = (a & 0xffff) | (b << 16);\n }\n }\n }\n\n // add\n h = ah0;\n l = al0;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[0];\n l = hl[0];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[0] = ah0 = (c & 0xffff) | (d << 16);\n hl[0] = al0 = (a & 0xffff) | (b << 16);\n\n h = ah1;\n l = al1;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[1];\n l = hl[1];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[1] = ah1 = (c & 0xffff) | (d << 16);\n hl[1] = al1 = (a & 0xffff) | (b << 16);\n\n h = ah2;\n l = al2;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[2];\n l = hl[2];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[2] = ah2 = (c & 0xffff) | (d << 16);\n hl[2] = al2 = (a & 0xffff) | (b << 16);\n\n h = ah3;\n l = al3;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[3];\n l = hl[3];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[3] = ah3 = (c & 0xffff) | (d << 16);\n hl[3] = al3 = (a & 0xffff) | (b << 16);\n\n h = ah4;\n l = al4;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[4];\n l = hl[4];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[4] = ah4 = (c & 0xffff) | (d << 16);\n hl[4] = al4 = (a & 0xffff) | (b << 16);\n\n h = ah5;\n l = al5;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[5];\n l = hl[5];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[5] = ah5 = (c & 0xffff) | (d << 16);\n hl[5] = al5 = (a & 0xffff) | (b << 16);\n\n h = ah6;\n l = al6;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[6];\n l = hl[6];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[6] = ah6 = (c & 0xffff) | (d << 16);\n hl[6] = al6 = (a & 0xffff) | (b << 16);\n\n h = ah7;\n l = al7;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[7];\n l = hl[7];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[7] = ah7 = (c & 0xffff) | (d << 16);\n hl[7] = al7 = (a & 0xffff) | (b << 16);\n\n pos += 128;\n n -= 128;\n }\n\n return n;\n}\n\nfunction crypto_hash(out, m, n) {\n var hh = new Int32Array(8),\n hl = new Int32Array(8),\n x = new Uint8Array(256),\n i, b = n;\n\n hh[0] = 0x6a09e667;\n hh[1] = 0xbb67ae85;\n hh[2] = 0x3c6ef372;\n hh[3] = 0xa54ff53a;\n hh[4] = 0x510e527f;\n hh[5] = 0x9b05688c;\n hh[6] = 0x1f83d9ab;\n hh[7] = 0x5be0cd19;\n\n hl[0] = 0xf3bcc908;\n hl[1] = 0x84caa73b;\n hl[2] = 0xfe94f82b;\n hl[3] = 0x5f1d36f1;\n hl[4] = 0xade682d1;\n hl[5] = 0x2b3e6c1f;\n hl[6] = 0xfb41bd6b;\n hl[7] = 0x137e2179;\n\n crypto_hashblocks_hl(hh, hl, m, n);\n n %= 128;\n\n for (i = 0; i < n; i++) x[i] = m[b-n+i];\n x[n] = 128;\n\n n = 256-128*(n<112?1:0);\n x[n-9] = 0;\n ts64(x, n-8, (b / 0x20000000) | 0, b << 3);\n crypto_hashblocks_hl(hh, hl, x, n);\n\n for (i = 0; i < 8; i++) ts64(out, 8*i, hh[i], hl[i]);\n\n return 0;\n}\n\nfunction add(p, q) {\n var a = gf(), b = gf(), c = gf(),\n d = gf(), e = gf(), f = gf(),\n g = gf(), h = gf(), t = gf();\n\n Z(a, p[1], p[0]);\n Z(t, q[1], q[0]);\n M(a, a, t);\n A(b, p[0], p[1]);\n A(t, q[0], q[1]);\n M(b, b, t);\n M(c, p[3], q[3]);\n M(c, c, D2);\n M(d, p[2], q[2]);\n A(d, d, d);\n Z(e, b, a);\n Z(f, d, c);\n A(g, d, c);\n A(h, b, a);\n\n M(p[0], e, f);\n M(p[1], h, g);\n M(p[2], g, f);\n M(p[3], e, h);\n}\n\nfunction cswap(p, q, b) {\n var i;\n for (i = 0; i < 4; i++) {\n sel25519(p[i], q[i], b);\n }\n}\n\nfunction pack(r, p) {\n var tx = gf(), ty = gf(), zi = gf();\n inv25519(zi, p[2]);\n M(tx, p[0], zi);\n M(ty, p[1], zi);\n pack25519(r, ty);\n r[31] ^= par25519(tx) << 7;\n}\n\nfunction scalarmult(p, q, s) {\n var b, i;\n set25519(p[0], gf0);\n set25519(p[1], gf1);\n set25519(p[2], gf1);\n set25519(p[3], gf0);\n for (i = 255; i >= 0; --i) {\n b = (s[(i/8)|0] >> (i&7)) & 1;\n cswap(p, q, b);\n add(q, p);\n add(p, p);\n cswap(p, q, b);\n }\n}\n\nfunction scalarbase(p, s) {\n var q = [gf(), gf(), gf(), gf()];\n set25519(q[0], X);\n set25519(q[1], Y);\n set25519(q[2], gf1);\n M(q[3], X, Y);\n scalarmult(p, q, s);\n}\n\nfunction crypto_sign_keypair(pk, sk, seeded) {\n var d = new Uint8Array(64);\n var p = [gf(), gf(), gf(), gf()];\n var i;\n\n if (!seeded) randombytes(sk, 32);\n crypto_hash(d, sk, 32);\n d[0] &= 248;\n d[31] &= 127;\n d[31] |= 64;\n\n scalarbase(p, d);\n pack(pk, p);\n\n for (i = 0; i < 32; i++) sk[i+32] = pk[i];\n return 0;\n}\n\nvar L = new Float64Array([0xed, 0xd3, 0xf5, 0x5c, 0x1a, 0x63, 0x12, 0x58, 0xd6, 0x9c, 0xf7, 0xa2, 0xde, 0xf9, 0xde, 0x14, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x10]);\n\nfunction modL(r, x) {\n var carry, i, j, k;\n for (i = 63; i >= 32; --i) {\n carry = 0;\n for (j = i - 32, k = i - 12; j < k; ++j) {\n x[j] += carry - 16 * x[i] * L[j - (i - 32)];\n carry = Math.floor((x[j] + 128) / 256);\n x[j] -= carry * 256;\n }\n x[j] += carry;\n x[i] = 0;\n }\n carry = 0;\n for (j = 0; j < 32; j++) {\n x[j] += carry - (x[31] >> 4) * L[j];\n carry = x[j] >> 8;\n x[j] &= 255;\n }\n for (j = 0; j < 32; j++) x[j] -= carry * L[j];\n for (i = 0; i < 32; i++) {\n x[i+1] += x[i] >> 8;\n r[i] = x[i] & 255;\n }\n}\n\nfunction reduce(r) {\n var x = new Float64Array(64), i;\n for (i = 0; i < 64; i++) x[i] = r[i];\n for (i = 0; i < 64; i++) r[i] = 0;\n modL(r, x);\n}\n\n// Note: difference from C - smlen returned, not passed as argument.\nfunction crypto_sign(sm, m, n, sk) {\n var d = new Uint8Array(64), h = new Uint8Array(64), r = new Uint8Array(64);\n var i, j, x = new Float64Array(64);\n var p = [gf(), gf(), gf(), gf()];\n\n crypto_hash(d, sk, 32);\n d[0] &= 248;\n d[31] &= 127;\n d[31] |= 64;\n\n var smlen = n + 64;\n for (i = 0; i < n; i++) sm[64 + i] = m[i];\n for (i = 0; i < 32; i++) sm[32 + i] = d[32 + i];\n\n crypto_hash(r, sm.subarray(32), n+32);\n reduce(r);\n scalarbase(p, r);\n pack(sm, p);\n\n for (i = 32; i < 64; i++) sm[i] = sk[i];\n crypto_hash(h, sm, n + 64);\n reduce(h);\n\n for (i = 0; i < 64; i++) x[i] = 0;\n for (i = 0; i < 32; i++) x[i] = r[i];\n for (i = 0; i < 32; i++) {\n for (j = 0; j < 32; j++) {\n x[i+j] += h[i] * d[j];\n }\n }\n\n modL(sm.subarray(32), x);\n return smlen;\n}\n\nfunction unpackneg(r, p) {\n var t = gf(), chk = gf(), num = gf(),\n den = gf(), den2 = gf(), den4 = gf(),\n den6 = gf();\n\n set25519(r[2], gf1);\n unpack25519(r[1], p);\n S(num, r[1]);\n M(den, num, D);\n Z(num, num, r[2]);\n A(den, r[2], den);\n\n S(den2, den);\n S(den4, den2);\n M(den6, den4, den2);\n M(t, den6, num);\n M(t, t, den);\n\n pow2523(t, t);\n M(t, t, num);\n M(t, t, den);\n M(t, t, den);\n M(r[0], t, den);\n\n S(chk, r[0]);\n M(chk, chk, den);\n if (neq25519(chk, num)) M(r[0], r[0], I);\n\n S(chk, r[0]);\n M(chk, chk, den);\n if (neq25519(chk, num)) return -1;\n\n if (par25519(r[0]) === (p[31]>>7)) Z(r[0], gf0, r[0]);\n\n M(r[3], r[0], r[1]);\n return 0;\n}\n\nfunction crypto_sign_open(m, sm, n, pk) {\n var i;\n var t = new Uint8Array(32), h = new Uint8Array(64);\n var p = [gf(), gf(), gf(), gf()],\n q = [gf(), gf(), gf(), gf()];\n\n if (n < 64) return -1;\n\n if (unpackneg(q, pk)) return -1;\n\n for (i = 0; i < n; i++) m[i] = sm[i];\n for (i = 0; i < 32; i++) m[i+32] = pk[i];\n crypto_hash(h, m, n);\n reduce(h);\n scalarmult(p, q, h);\n\n scalarbase(q, sm.subarray(32));\n add(p, q);\n pack(t, p);\n\n n -= 64;\n if (crypto_verify_32(sm, 0, t, 0)) {\n for (i = 0; i < n; i++) m[i] = 0;\n return -1;\n }\n\n for (i = 0; i < n; i++) m[i] = sm[i + 64];\n return n;\n}\n\nvar crypto_secretbox_KEYBYTES = 32,\n crypto_secretbox_NONCEBYTES = 24,\n crypto_secretbox_ZEROBYTES = 32,\n crypto_secretbox_BOXZEROBYTES = 16,\n crypto_scalarmult_BYTES = 32,\n crypto_scalarmult_SCALARBYTES = 32,\n crypto_box_PUBLICKEYBYTES = 32,\n crypto_box_SECRETKEYBYTES = 32,\n crypto_box_BEFORENMBYTES = 32,\n crypto_box_NONCEBYTES = crypto_secretbox_NONCEBYTES,\n crypto_box_ZEROBYTES = crypto_secretbox_ZEROBYTES,\n crypto_box_BOXZEROBYTES = crypto_secretbox_BOXZEROBYTES,\n crypto_sign_BYTES = 64,\n crypto_sign_PUBLICKEYBYTES = 32,\n crypto_sign_SECRETKEYBYTES = 64,\n crypto_sign_SEEDBYTES = 32,\n crypto_hash_BYTES = 64;\n\nnacl.lowlevel = {\n crypto_core_hsalsa20: crypto_core_hsalsa20,\n crypto_stream_xor: crypto_stream_xor,\n crypto_stream: crypto_stream,\n crypto_stream_salsa20_xor: crypto_stream_salsa20_xor,\n crypto_stream_salsa20: crypto_stream_salsa20,\n crypto_onetimeauth: crypto_onetimeauth,\n crypto_onetimeauth_verify: crypto_onetimeauth_verify,\n crypto_verify_16: crypto_verify_16,\n crypto_verify_32: crypto_verify_32,\n crypto_secretbox: crypto_secretbox,\n crypto_secretbox_open: crypto_secretbox_open,\n crypto_scalarmult: crypto_scalarmult,\n crypto_scalarmult_base: crypto_scalarmult_base,\n crypto_box_beforenm: crypto_box_beforenm,\n crypto_box_afternm: crypto_box_afternm,\n crypto_box: crypto_box,\n crypto_box_open: crypto_box_open,\n crypto_box_keypair: crypto_box_keypair,\n crypto_hash: crypto_hash,\n crypto_sign: crypto_sign,\n crypto_sign_keypair: crypto_sign_keypair,\n crypto_sign_open: crypto_sign_open,\n\n crypto_secretbox_KEYBYTES: crypto_secretbox_KEYBYTES,\n crypto_secretbox_NONCEBYTES: crypto_secretbox_NONCEBYTES,\n crypto_secretbox_ZEROBYTES: crypto_secretbox_ZEROBYTES,\n crypto_secretbox_BOXZEROBYTES: crypto_secretbox_BOXZEROBYTES,\n crypto_scalarmult_BYTES: crypto_scalarmult_BYTES,\n crypto_scalarmult_SCALARBYTES: crypto_scalarmult_SCALARBYTES,\n crypto_box_PUBLICKEYBYTES: crypto_box_PUBLICKEYBYTES,\n crypto_box_SECRETKEYBYTES: crypto_box_SECRETKEYBYTES,\n crypto_box_BEFORENMBYTES: crypto_box_BEFORENMBYTES,\n crypto_box_NONCEBYTES: crypto_box_NONCEBYTES,\n crypto_box_ZEROBYTES: crypto_box_ZEROBYTES,\n crypto_box_BOXZEROBYTES: crypto_box_BOXZEROBYTES,\n crypto_sign_BYTES: crypto_sign_BYTES,\n crypto_sign_PUBLICKEYBYTES: crypto_sign_PUBLICKEYBYTES,\n crypto_sign_SECRETKEYBYTES: crypto_sign_SECRETKEYBYTES,\n crypto_sign_SEEDBYTES: crypto_sign_SEEDBYTES,\n crypto_hash_BYTES: crypto_hash_BYTES,\n\n gf: gf,\n D: D,\n L: L,\n pack25519: pack25519,\n unpack25519: unpack25519,\n M: M,\n A: A,\n S: S,\n Z: Z,\n pow2523: pow2523,\n add: add,\n set25519: set25519,\n modL: modL,\n scalarmult: scalarmult,\n scalarbase: scalarbase,\n};\n\n/* High-level API */\n\nfunction checkLengths(k, n) {\n if (k.length !== crypto_secretbox_KEYBYTES) throw new Error('bad key size');\n if (n.length !== crypto_secretbox_NONCEBYTES) throw new Error('bad nonce size');\n}\n\nfunction checkBoxLengths(pk, sk) {\n if (pk.length !== crypto_box_PUBLICKEYBYTES) throw new Error('bad public key size');\n if (sk.length !== crypto_box_SECRETKEYBYTES) throw new Error('bad secret key size');\n}\n\nfunction checkArrayTypes() {\n for (var i = 0; i < arguments.length; i++) {\n if (!(arguments[i] instanceof Uint8Array))\n throw new TypeError('unexpected type, use Uint8Array');\n }\n}\n\nfunction cleanup(arr) {\n for (var i = 0; i < arr.length; i++) arr[i] = 0;\n}\n\nnacl.randomBytes = function(n) {\n var b = new Uint8Array(n);\n randombytes(b, n);\n return b;\n};\n\nnacl.secretbox = function(msg, nonce, key) {\n checkArrayTypes(msg, nonce, key);\n checkLengths(key, nonce);\n var m = new Uint8Array(crypto_secretbox_ZEROBYTES + msg.length);\n var c = new Uint8Array(m.length);\n for (var i = 0; i < msg.length; i++) m[i+crypto_secretbox_ZEROBYTES] = msg[i];\n crypto_secretbox(c, m, m.length, nonce, key);\n return c.subarray(crypto_secretbox_BOXZEROBYTES);\n};\n\nnacl.secretbox.open = function(box, nonce, key) {\n checkArrayTypes(box, nonce, key);\n checkLengths(key, nonce);\n var c = new Uint8Array(crypto_secretbox_BOXZEROBYTES + box.length);\n var m = new Uint8Array(c.length);\n for (var i = 0; i < box.length; i++) c[i+crypto_secretbox_BOXZEROBYTES] = box[i];\n if (c.length < 32) return null;\n if (crypto_secretbox_open(m, c, c.length, nonce, key) !== 0) return null;\n return m.subarray(crypto_secretbox_ZEROBYTES);\n};\n\nnacl.secretbox.keyLength = crypto_secretbox_KEYBYTES;\nnacl.secretbox.nonceLength = crypto_secretbox_NONCEBYTES;\nnacl.secretbox.overheadLength = crypto_secretbox_BOXZEROBYTES;\n\nnacl.scalarMult = function(n, p) {\n checkArrayTypes(n, p);\n if (n.length !== crypto_scalarmult_SCALARBYTES) throw new Error('bad n size');\n if (p.length !== crypto_scalarmult_BYTES) throw new Error('bad p size');\n var q = new Uint8Array(crypto_scalarmult_BYTES);\n crypto_scalarmult(q, n, p);\n return q;\n};\n\nnacl.scalarMult.base = function(n) {\n checkArrayTypes(n);\n if (n.length !== crypto_scalarmult_SCALARBYTES) throw new Error('bad n size');\n var q = new Uint8Array(crypto_scalarmult_BYTES);\n crypto_scalarmult_base(q, n);\n return q;\n};\n\nnacl.scalarMult.scalarLength = crypto_scalarmult_SCALARBYTES;\nnacl.scalarMult.groupElementLength = crypto_scalarmult_BYTES;\n\nnacl.box = function(msg, nonce, publicKey, secretKey) {\n var k = nacl.box.before(publicKey, secretKey);\n return nacl.secretbox(msg, nonce, k);\n};\n\nnacl.box.before = function(publicKey, secretKey) {\n checkArrayTypes(publicKey, secretKey);\n checkBoxLengths(publicKey, secretKey);\n var k = new Uint8Array(crypto_box_BEFORENMBYTES);\n crypto_box_beforenm(k, publicKey, secretKey);\n return k;\n};\n\nnacl.box.after = nacl.secretbox;\n\nnacl.box.open = function(msg, nonce, publicKey, secretKey) {\n var k = nacl.box.before(publicKey, secretKey);\n return nacl.secretbox.open(msg, nonce, k);\n};\n\nnacl.box.open.after = nacl.secretbox.open;\n\nnacl.box.keyPair = function() {\n var pk = new Uint8Array(crypto_box_PUBLICKEYBYTES);\n var sk = new Uint8Array(crypto_box_SECRETKEYBYTES);\n crypto_box_keypair(pk, sk);\n return {publicKey: pk, secretKey: sk};\n};\n\nnacl.box.keyPair.fromSecretKey = function(secretKey) {\n checkArrayTypes(secretKey);\n if (secretKey.length !== crypto_box_SECRETKEYBYTES)\n throw new Error('bad secret key size');\n var pk = new Uint8Array(crypto_box_PUBLICKEYBYTES);\n crypto_scalarmult_base(pk, secretKey);\n return {publicKey: pk, secretKey: new Uint8Array(secretKey)};\n};\n\nnacl.box.publicKeyLength = crypto_box_PUBLICKEYBYTES;\nnacl.box.secretKeyLength = crypto_box_SECRETKEYBYTES;\nnacl.box.sharedKeyLength = crypto_box_BEFORENMBYTES;\nnacl.box.nonceLength = crypto_box_NONCEBYTES;\nnacl.box.overheadLength = nacl.secretbox.overheadLength;\n\nnacl.sign = function(msg, secretKey) {\n checkArrayTypes(msg, secretKey);\n if (secretKey.length !== crypto_sign_SECRETKEYBYTES)\n throw new Error('bad secret key size');\n var signedMsg = new Uint8Array(crypto_sign_BYTES+msg.length);\n crypto_sign(signedMsg, msg, msg.length, secretKey);\n return signedMsg;\n};\n\nnacl.sign.open = function(signedMsg, publicKey) {\n checkArrayTypes(signedMsg, publicKey);\n if (publicKey.length !== crypto_sign_PUBLICKEYBYTES)\n throw new Error('bad public key size');\n var tmp = new Uint8Array(signedMsg.length);\n var mlen = crypto_sign_open(tmp, signedMsg, signedMsg.length, publicKey);\n if (mlen < 0) return null;\n var m = new Uint8Array(mlen);\n for (var i = 0; i < m.length; i++) m[i] = tmp[i];\n return m;\n};\n\nnacl.sign.detached = function(msg, secretKey) {\n var signedMsg = nacl.sign(msg, secretKey);\n var sig = new Uint8Array(crypto_sign_BYTES);\n for (var i = 0; i < sig.length; i++) sig[i] = signedMsg[i];\n return sig;\n};\n\nnacl.sign.detached.verify = function(msg, sig, publicKey) {\n checkArrayTypes(msg, sig, publicKey);\n if (sig.length !== crypto_sign_BYTES)\n throw new Error('bad signature size');\n if (publicKey.length !== crypto_sign_PUBLICKEYBYTES)\n throw new Error('bad public key size');\n var sm = new Uint8Array(crypto_sign_BYTES + msg.length);\n var m = new Uint8Array(crypto_sign_BYTES + msg.length);\n var i;\n for (i = 0; i < crypto_sign_BYTES; i++) sm[i] = sig[i];\n for (i = 0; i < msg.length; i++) sm[i+crypto_sign_BYTES] = msg[i];\n return (crypto_sign_open(m, sm, sm.length, publicKey) >= 0);\n};\n\nnacl.sign.keyPair = function() {\n var pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);\n var sk = new Uint8Array(crypto_sign_SECRETKEYBYTES);\n crypto_sign_keypair(pk, sk);\n return {publicKey: pk, secretKey: sk};\n};\n\nnacl.sign.keyPair.fromSecretKey = function(secretKey) {\n checkArrayTypes(secretKey);\n if (secretKey.length !== crypto_sign_SECRETKEYBYTES)\n throw new Error('bad secret key size');\n var pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);\n for (var i = 0; i < pk.length; i++) pk[i] = secretKey[32+i];\n return {publicKey: pk, secretKey: new Uint8Array(secretKey)};\n};\n\nnacl.sign.keyPair.fromSeed = function(seed) {\n checkArrayTypes(seed);\n if (seed.length !== crypto_sign_SEEDBYTES)\n throw new Error('bad seed size');\n var pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);\n var sk = new Uint8Array(crypto_sign_SECRETKEYBYTES);\n for (var i = 0; i < 32; i++) sk[i] = seed[i];\n crypto_sign_keypair(pk, sk, true);\n return {publicKey: pk, secretKey: sk};\n};\n\nnacl.sign.publicKeyLength = crypto_sign_PUBLICKEYBYTES;\nnacl.sign.secretKeyLength = crypto_sign_SECRETKEYBYTES;\nnacl.sign.seedLength = crypto_sign_SEEDBYTES;\nnacl.sign.signatureLength = crypto_sign_BYTES;\n\nnacl.hash = function(msg) {\n checkArrayTypes(msg);\n var h = new Uint8Array(crypto_hash_BYTES);\n crypto_hash(h, msg, msg.length);\n return h;\n};\n\nnacl.hash.hashLength = crypto_hash_BYTES;\n\nnacl.verify = function(x, y) {\n checkArrayTypes(x, y);\n // Zero length arguments are considered not equal.\n if (x.length === 0 || y.length === 0) return false;\n if (x.length !== y.length) return false;\n return (vn(x, 0, y, 0, x.length) === 0) ? true : false;\n};\n\nnacl.setPRNG = function(fn) {\n randombytes = fn;\n};\n\n(function() {\n // Initialize PRNG if environment provides CSPRNG.\n // If not, methods calling randombytes will throw.\n var crypto = typeof self !== 'undefined' ? (self.crypto || self.msCrypto) : null;\n if (crypto && crypto.getRandomValues) {\n // Browsers.\n var QUOTA = 65536;\n nacl.setPRNG(function(x, n) {\n var i, v = new Uint8Array(n);\n for (i = 0; i < n; i += QUOTA) {\n crypto.getRandomValues(v.subarray(i, i + Math.min(n - i, QUOTA)));\n }\n for (i = 0; i < n; i++) x[i] = v[i];\n cleanup(v);\n });\n } else if (typeof require !== 'undefined') {\n // Node.js.\n crypto = require('crypto');\n if (crypto && crypto.randomBytes) {\n nacl.setPRNG(function(x, n) {\n var i, v = crypto.randomBytes(n);\n for (i = 0; i < n; i++) x[i] = v[i];\n cleanup(v);\n });\n }\n }\n})();\n\n})(typeof module !== 'undefined' && module.exports ? module.exports : (self.nacl = self.nacl || {}));\n","module.exports = require('./pusher-with-encryption').default;\n","import ScriptReceiver from './script_receiver';\n\n/** Builds receivers for JSONP and Script requests.\n *\n * Each receiver is an object with following fields:\n * - number - unique (for the factory instance), numerical id of the receiver\n * - id - a string ID that can be used in DOM attributes\n * - name - name of the function triggering the receiver\n * - callback - callback function\n *\n * Receivers are triggered only once, on the first callback call.\n *\n * Receivers can be called by their name or by accessing factory object\n * by the number key.\n *\n * @param {String} prefix the prefix used in ids\n * @param {String} name the name of the object\n */\nexport class ScriptReceiverFactory {\n lastId: number;\n prefix: string;\n name: string;\n\n constructor(prefix: string, name: string) {\n this.lastId = 0;\n this.prefix = prefix;\n this.name = name;\n }\n\n create(callback: Function): ScriptReceiver {\n this.lastId++;\n\n var number = this.lastId;\n var id = this.prefix + number;\n var name = this.name + '[' + number + ']';\n\n var called = false;\n var callbackWrapper = function() {\n if (!called) {\n callback.apply(null, arguments);\n called = true;\n }\n };\n\n this[number] = callbackWrapper;\n return { number: number, id: id, name: name, callback: callbackWrapper };\n }\n\n remove(receiver: ScriptReceiver) {\n delete this[receiver.number];\n }\n}\n\nexport var ScriptReceivers = new ScriptReceiverFactory(\n '_pusher_script_',\n 'Pusher.ScriptReceivers'\n);\n","import {\n ChannelAuthorizationOptions,\n UserAuthenticationOptions\n} from './auth/options';\nimport { AuthTransport } from './config';\n\nexport interface DefaultConfig {\n VERSION: string;\n PROTOCOL: number;\n wsPort: number;\n wssPort: number;\n wsPath: string;\n httpHost: string;\n httpPort: number;\n httpsPort: number;\n httpPath: string;\n stats_host: string;\n authEndpoint: string;\n authTransport: AuthTransport;\n activityTimeout: number;\n pongTimeout: number;\n unavailableTimeout: number;\n userAuthentication: UserAuthenticationOptions;\n channelAuthorization: ChannelAuthorizationOptions;\n\n cdn_http?: string;\n cdn_https?: string;\n dependency_suffix?: string;\n}\n\nvar Defaults: DefaultConfig = {\n VERSION: VERSION,\n PROTOCOL: 7,\n\n wsPort: 80,\n wssPort: 443,\n wsPath: '',\n // DEPRECATED: SockJS fallback parameters\n httpHost: 'sockjs.pusher.com',\n httpPort: 80,\n httpsPort: 443,\n httpPath: '/pusher',\n // DEPRECATED: Stats\n stats_host: 'stats.pusher.com',\n // DEPRECATED: Other settings\n authEndpoint: '/pusher/auth',\n authTransport: 'ajax',\n activityTimeout: 120000,\n pongTimeout: 30000,\n unavailableTimeout: 10000,\n userAuthentication: {\n endpoint: '/pusher/user-auth',\n transport: 'ajax'\n },\n channelAuthorization: {\n endpoint: '/pusher/auth',\n transport: 'ajax'\n },\n\n // CDN configuration\n cdn_http: CDN_HTTP,\n cdn_https: CDN_HTTPS,\n dependency_suffix: DEPENDENCY_SUFFIX\n};\n\nexport default Defaults;\n","import { ScriptReceiverFactory } from './script_receiver_factory';\nimport Defaults from 'core/defaults';\nimport DependencyLoader from './dependency_loader';\n\nexport var DependenciesReceivers = new ScriptReceiverFactory(\n '_pusher_dependencies',\n 'Pusher.DependenciesReceivers'\n);\n\nexport var Dependencies = new DependencyLoader({\n cdn_http: Defaults.cdn_http,\n cdn_https: Defaults.cdn_https,\n version: Defaults.VERSION,\n suffix: Defaults.dependency_suffix,\n receivers: DependenciesReceivers\n});\n","import {\n ScriptReceivers,\n ScriptReceiverFactory\n} from './script_receiver_factory';\nimport Runtime from 'runtime';\nimport ScriptRequest from './script_request';\n\n/** Handles loading dependency files.\n *\n * Dependency loaders don't remember whether a resource has been loaded or\n * not. It is caller's responsibility to make sure the resource is not loaded\n * twice. This is because it's impossible to detect resource loading status\n * without knowing its content.\n *\n * Options:\n * - cdn_http - url to HTTP CND\n * - cdn_https - url to HTTPS CDN\n * - version - version of pusher-js\n * - suffix - suffix appended to all names of dependency files\n *\n * @param {Object} options\n */\nexport default class DependencyLoader {\n options: any;\n receivers: ScriptReceiverFactory;\n loading: any;\n\n constructor(options: any) {\n this.options = options;\n this.receivers = options.receivers || ScriptReceivers;\n this.loading = {};\n }\n\n /** Loads the dependency from CDN.\n *\n * @param {String} name\n * @param {Function} callback\n */\n load(name: string, options: any, callback: Function) {\n var self = this;\n\n if (self.loading[name] && self.loading[name].length > 0) {\n self.loading[name].push(callback);\n } else {\n self.loading[name] = [callback];\n\n var request = Runtime.createScriptRequest(self.getPath(name, options));\n var receiver = self.receivers.create(function(error) {\n self.receivers.remove(receiver);\n\n if (self.loading[name]) {\n var callbacks = self.loading[name];\n delete self.loading[name];\n\n var successCallback = function(wasSuccessful) {\n if (!wasSuccessful) {\n request.cleanup();\n }\n };\n for (var i = 0; i < callbacks.length; i++) {\n callbacks[i](error, successCallback);\n }\n }\n });\n request.send(receiver);\n }\n }\n\n /** Returns a root URL for pusher-js CDN.\n *\n * @returns {String}\n */\n getRoot(options: any): string {\n var cdn;\n var protocol = Runtime.getDocument().location.protocol;\n if ((options && options.useTLS) || protocol === 'https:') {\n cdn = this.options.cdn_https;\n } else {\n cdn = this.options.cdn_http;\n }\n // make sure there are no double slashes\n return cdn.replace(/\\/*$/, '') + '/' + this.options.version;\n }\n\n /** Returns a full path to a dependency file.\n *\n * @param {String} name\n * @returns {String}\n */\n getPath(name: string, options: any): string {\n return this.getRoot(options) + '/' + name + this.options.suffix + '.js';\n }\n}\n","/**\n * A place to store help URLs for error messages etc\n */\n\nconst urlStore = {\n baseUrl: 'https://pusher.com',\n urls: {\n authenticationEndpoint: {\n path: '/docs/channels/server_api/authenticating_users'\n },\n authorizationEndpoint: {\n path: '/docs/channels/server_api/authorizing-users/'\n },\n javascriptQuickStart: {\n path: '/docs/javascript_quick_start'\n },\n triggeringClientEvents: {\n path: '/docs/client_api_guide/client_events#trigger-events'\n },\n encryptedChannelSupport: {\n fullUrl:\n 'https://github.com/pusher/pusher-js/tree/cc491015371a4bde5743d1c87a0fbac0feb53195#encrypted-channel-support'\n }\n }\n};\n\n/** Builds a consistent string with links to pusher documentation\n *\n * @param {string} key - relevant key in the url_store.urls object\n * @return {string} suffix string to append to log message\n */\nconst buildLogSuffix = function(key: string): string {\n const urlPrefix = 'See:';\n const urlObj = urlStore.urls[key];\n if (!urlObj) return '';\n\n let url;\n if (urlObj.fullUrl) {\n url = urlObj.fullUrl;\n } else if (urlObj.path) {\n url = urlStore.baseUrl + urlObj.path;\n }\n\n if (!url) return '';\n return `${urlPrefix} ${url}`;\n};\n\nexport default { buildLogSuffix };\n","export enum AuthRequestType {\n UserAuthentication = 'user-authentication',\n ChannelAuthorization = 'channel-authorization'\n}\n\nexport interface ChannelAuthorizationData {\n auth: string;\n channel_data?: string;\n shared_secret?: string;\n}\n\nexport type ChannelAuthorizationCallback = (\n error: Error | null,\n authData: ChannelAuthorizationData | null\n) => void;\n\nexport interface ChannelAuthorizationRequestParams {\n socketId: string;\n channelName: string;\n}\n\nexport interface ChannelAuthorizationHandler {\n (\n params: ChannelAuthorizationRequestParams,\n callback: ChannelAuthorizationCallback\n ): void;\n}\n\nexport interface UserAuthenticationData {\n auth: string;\n user_data: string;\n}\n\nexport type UserAuthenticationCallback = (\n error: Error | null,\n authData: UserAuthenticationData | null\n) => void;\n\nexport interface UserAuthenticationRequestParams {\n socketId: string;\n}\n\nexport interface UserAuthenticationHandler {\n (\n params: UserAuthenticationRequestParams,\n callback: UserAuthenticationCallback\n ): void;\n}\n\nexport type AuthTransportCallback =\n | ChannelAuthorizationCallback\n | UserAuthenticationCallback;\n\nexport interface AuthOptionsT {\n transport: 'ajax' | 'jsonp';\n endpoint: string;\n params?: any;\n headers?: any;\n paramsProvider?: () => any;\n headersProvider?: () => any;\n customHandler?: AuthHandler;\n}\n\nexport declare type UserAuthenticationOptions = AuthOptionsT<\n UserAuthenticationHandler\n>;\nexport declare type ChannelAuthorizationOptions = AuthOptionsT<\n ChannelAuthorizationHandler\n>;\n\nexport interface InternalAuthOptions {\n transport: 'ajax' | 'jsonp';\n endpoint: string;\n params?: any;\n headers?: any;\n paramsProvider?: () => any;\n headersProvider?: () => any;\n}\n","/** Error classes used throughout the library. */\n// https://github.com/Microsoft/TypeScript-wiki/blob/master/Breaking-Changes.md#extending-built-ins-like-error-array-and-map-may-no-longer-work\nexport class BadEventName extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\nexport class BadChannelName extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\nexport class RequestTimedOut extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class TransportPriorityTooLow extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class TransportClosed extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class UnsupportedFeature extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class UnsupportedTransport extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class UnsupportedStrategy extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class HTTPAuthError extends Error {\n status: number;\n constructor(status: number, msg?: string) {\n super(msg);\n this.status = status;\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n","import TimelineSender from 'core/timeline/timeline_sender';\nimport * as Collections from 'core/utils/collections';\nimport Util from 'core/util';\nimport Runtime from 'runtime';\nimport { AuthTransport } from 'core/auth/auth_transports';\nimport AbstractRuntime from 'runtimes/interface';\nimport UrlStore from 'core/utils/url_store';\nimport {\n AuthRequestType,\n AuthTransportCallback,\n InternalAuthOptions\n} from 'core/auth/options';\nimport { HTTPAuthError } from 'core/errors';\n\nconst ajax: AuthTransport = function(\n context: AbstractRuntime,\n query: string,\n authOptions: InternalAuthOptions,\n authRequestType: AuthRequestType,\n callback: AuthTransportCallback\n) {\n const xhr = Runtime.createXHR();\n xhr.open('POST', authOptions.endpoint, true);\n\n // add request headers\n xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');\n for (var headerName in authOptions.headers) {\n xhr.setRequestHeader(headerName, authOptions.headers[headerName]);\n }\n if (authOptions.headersProvider != null) {\n let dynamicHeaders = authOptions.headersProvider();\n for (var headerName in dynamicHeaders) {\n xhr.setRequestHeader(headerName, dynamicHeaders[headerName]);\n }\n }\n\n xhr.onreadystatechange = function() {\n if (xhr.readyState === 4) {\n if (xhr.status === 200) {\n let data;\n let parsed = false;\n\n try {\n data = JSON.parse(xhr.responseText);\n parsed = true;\n } catch (e) {\n callback(\n new HTTPAuthError(\n 200,\n `JSON returned from ${authRequestType.toString()} endpoint was invalid, yet status code was 200. Data was: ${\n xhr.responseText\n }`\n ),\n null\n );\n }\n\n if (parsed) {\n // prevents double execution.\n callback(null, data);\n }\n } else {\n let suffix = '';\n switch (authRequestType) {\n case AuthRequestType.UserAuthentication:\n suffix = UrlStore.buildLogSuffix('authenticationEndpoint');\n break;\n case AuthRequestType.ChannelAuthorization:\n suffix = `Clients must be authorized to join private or presence channels. ${UrlStore.buildLogSuffix(\n 'authorizationEndpoint'\n )}`;\n break;\n }\n callback(\n new HTTPAuthError(\n xhr.status,\n `Unable to retrieve auth string from ${authRequestType.toString()} endpoint - ` +\n `received status: ${xhr.status} from ${authOptions.endpoint}. ${suffix}`\n ),\n null\n );\n }\n }\n };\n\n xhr.send(query);\n return xhr;\n};\n\nexport default ajax;\n","export default function encode(s: any): string {\n return btoa(utob(s));\n}\n\nvar fromCharCode = String.fromCharCode;\n\nvar b64chars =\n 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';\nvar b64tab = {};\n\nfor (var i = 0, l = b64chars.length; i < l; i++) {\n b64tab[b64chars.charAt(i)] = i;\n}\n\nvar cb_utob = function(c) {\n var cc = c.charCodeAt(0);\n return cc < 0x80\n ? c\n : cc < 0x800\n ? fromCharCode(0xc0 | (cc >>> 6)) + fromCharCode(0x80 | (cc & 0x3f))\n : fromCharCode(0xe0 | ((cc >>> 12) & 0x0f)) +\n fromCharCode(0x80 | ((cc >>> 6) & 0x3f)) +\n fromCharCode(0x80 | (cc & 0x3f));\n};\n\nvar utob = function(u) {\n return u.replace(/[^\\x00-\\x7F]/g, cb_utob);\n};\n\nvar cb_encode = function(ccc) {\n var padlen = [0, 2, 1][ccc.length % 3];\n var ord =\n (ccc.charCodeAt(0) << 16) |\n ((ccc.length > 1 ? ccc.charCodeAt(1) : 0) << 8) |\n (ccc.length > 2 ? ccc.charCodeAt(2) : 0);\n var chars = [\n b64chars.charAt(ord >>> 18),\n b64chars.charAt((ord >>> 12) & 63),\n padlen >= 2 ? '=' : b64chars.charAt((ord >>> 6) & 63),\n padlen >= 1 ? '=' : b64chars.charAt(ord & 63)\n ];\n return chars.join('');\n};\n\nvar btoa =\n global.btoa ||\n function(b) {\n return b.replace(/[\\s\\S]{1,3}/g, cb_encode);\n };\n","import TimedCallback from './timed_callback';\nimport { Delay, Scheduler, Canceller } from './scheduling';\n\nabstract class Timer {\n protected clear: Canceller;\n protected timer: number | void;\n\n constructor(\n set: Scheduler,\n clear: Canceller,\n delay: Delay,\n callback: TimedCallback\n ) {\n this.clear = clear;\n this.timer = set(() => {\n if (this.timer) {\n this.timer = callback(this.timer);\n }\n }, delay);\n }\n\n /** Returns whether the timer is still running.\n *\n * @return {Boolean}\n */\n isRunning(): boolean {\n return this.timer !== null;\n }\n\n /** Aborts a timer when it's running. */\n ensureAborted() {\n if (this.timer) {\n this.clear(this.timer);\n this.timer = null;\n }\n }\n}\n\nexport default Timer;\n","import Timer from './abstract_timer';\nimport TimedCallback from './timed_callback';\nimport { Delay } from './scheduling';\n\n// We need to bind clear functions this way to avoid exceptions on IE8\nfunction clearTimeout(timer) {\n global.clearTimeout(timer);\n}\nfunction clearInterval(timer) {\n global.clearInterval(timer);\n}\n\n/** Cross-browser compatible one-off timer abstraction.\n *\n * @param {Number} delay\n * @param {Function} callback\n */\nexport class OneOffTimer extends Timer {\n constructor(delay: Delay, callback: TimedCallback) {\n super(setTimeout, clearTimeout, delay, function(timer) {\n callback();\n return null;\n });\n }\n}\n\n/** Cross-browser compatible periodic timer abstraction.\n *\n * @param {Number} delay\n * @param {Function} callback\n */\nexport class PeriodicTimer extends Timer {\n constructor(delay: Delay, callback: TimedCallback) {\n super(setInterval, clearInterval, delay, function(timer) {\n callback();\n return timer;\n });\n }\n}\n","import * as Collections from './utils/collections';\nimport TimedCallback from './utils/timers/timed_callback';\nimport { OneOffTimer, PeriodicTimer } from './utils/timers';\n\nvar Util = {\n now(): number {\n if (Date.now) {\n return Date.now();\n } else {\n return new Date().valueOf();\n }\n },\n\n defer(callback: TimedCallback): OneOffTimer {\n return new OneOffTimer(0, callback);\n },\n\n /** Builds a function that will proxy a method call to its first argument.\n *\n * Allows partial application of arguments, so additional arguments are\n * prepended to the argument list.\n *\n * @param {String} name method name\n * @return {Function} proxy function\n */\n method(name: string, ...args: any[]): Function {\n var boundArguments = Array.prototype.slice.call(arguments, 1);\n return function(object) {\n return object[name].apply(object, boundArguments.concat(arguments));\n };\n }\n};\n\nexport default Util;\n","import base64encode from '../base64';\nimport Util from '../util';\n\n/** Merges multiple objects into the target argument.\n *\n * For properties that are plain Objects, performs a deep-merge. For the\n * rest it just copies the value of the property.\n *\n * To extend prototypes use it as following:\n * Pusher.Util.extend(Target.prototype, Base.prototype)\n *\n * You can also use it to merge objects without altering them:\n * Pusher.Util.extend({}, object1, object2)\n *\n * @param {Object} target\n * @return {Object} the target argument\n */\nexport function extend(target: any, ...sources: any[]): T {\n for (var i = 0; i < sources.length; i++) {\n var extensions = sources[i];\n for (var property in extensions) {\n if (\n extensions[property] &&\n extensions[property].constructor &&\n extensions[property].constructor === Object\n ) {\n target[property] = extend(target[property] || {}, extensions[property]);\n } else {\n target[property] = extensions[property];\n }\n }\n }\n return target;\n}\n\nexport function stringify(): string {\n var m = ['Pusher'];\n for (var i = 0; i < arguments.length; i++) {\n if (typeof arguments[i] === 'string') {\n m.push(arguments[i]);\n } else {\n m.push(safeJSONStringify(arguments[i]));\n }\n }\n return m.join(' : ');\n}\n\nexport function arrayIndexOf(array: any[], item: any): number {\n // MSIE doesn't have array.indexOf\n var nativeIndexOf = Array.prototype.indexOf;\n if (array === null) {\n return -1;\n }\n if (nativeIndexOf && array.indexOf === nativeIndexOf) {\n return array.indexOf(item);\n }\n for (var i = 0, l = array.length; i < l; i++) {\n if (array[i] === item) {\n return i;\n }\n }\n return -1;\n}\n\n/** Applies a function f to all properties of an object.\n *\n * Function f gets 3 arguments passed:\n * - element from the object\n * - key of the element\n * - reference to the object\n *\n * @param {Object} object\n * @param {Function} f\n */\nexport function objectApply(object: any, f: Function) {\n for (var key in object) {\n if (Object.prototype.hasOwnProperty.call(object, key)) {\n f(object[key], key, object);\n }\n }\n}\n\n/** Return a list of objects own proerty keys\n *\n * @param {Object} object\n * @returns {Array}\n */\nexport function keys(object: any): string[] {\n var keys = [];\n objectApply(object, function(_, key) {\n keys.push(key);\n });\n return keys;\n}\n\n/** Return a list of object's own property values\n *\n * @param {Object} object\n * @returns {Array}\n */\nexport function values(object: any): any[] {\n var values = [];\n objectApply(object, function(value) {\n values.push(value);\n });\n return values;\n}\n\n/** Applies a function f to all elements of an array.\n *\n * Function f gets 3 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function apply(array: any[], f: Function, context?: any) {\n for (var i = 0; i < array.length; i++) {\n f.call(context || global, array[i], i, array);\n }\n}\n\n/** Maps all elements of the array and returns the result.\n *\n * Function f gets 4 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n * - reference to the destination array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function map(array: any[], f: Function): any[] {\n var result = [];\n for (var i = 0; i < array.length; i++) {\n result.push(f(array[i], i, array, result));\n }\n return result;\n}\n\n/** Maps all elements of the object and returns the result.\n *\n * Function f gets 4 arguments passed:\n * - element from the object\n * - key of the element\n * - reference to the source object\n * - reference to the destination object\n *\n * @param {Object} object\n * @param {Function} f\n */\nexport function mapObject(object: any, f: Function): any {\n var result = {};\n objectApply(object, function(value, key) {\n result[key] = f(value);\n });\n return result;\n}\n\n/** Filters elements of the array using a test function.\n *\n * Function test gets 4 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n * - reference to the destination array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function filter(array: any[], test: Function): any[] {\n test =\n test ||\n function(value) {\n return !!value;\n };\n\n var result = [];\n for (var i = 0; i < array.length; i++) {\n if (test(array[i], i, array, result)) {\n result.push(array[i]);\n }\n }\n return result;\n}\n\n/** Filters properties of the object using a test function.\n *\n * Function test gets 4 arguments passed:\n * - element from the object\n * - key of the element\n * - reference to the source object\n * - reference to the destination object\n *\n * @param {Object} object\n * @param {Function} f\n */\nexport function filterObject(object: Object, test: Function) {\n var result = {};\n objectApply(object, function(value, key) {\n if ((test && test(value, key, object, result)) || Boolean(value)) {\n result[key] = value;\n }\n });\n return result;\n}\n\n/** Flattens an object into a two-dimensional array.\n *\n * @param {Object} object\n * @return {Array} resulting array of [key, value] pairs\n */\nexport function flatten(object: Object): any[] {\n var result = [];\n objectApply(object, function(value, key) {\n result.push([key, value]);\n });\n return result;\n}\n\n/** Checks whether any element of the array passes the test.\n *\n * Function test gets 3 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function any(array: any[], test: Function): boolean {\n for (var i = 0; i < array.length; i++) {\n if (test(array[i], i, array)) {\n return true;\n }\n }\n return false;\n}\n\n/** Checks whether all elements of the array pass the test.\n *\n * Function test gets 3 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function all(array: any[], test: Function): boolean {\n for (var i = 0; i < array.length; i++) {\n if (!test(array[i], i, array)) {\n return false;\n }\n }\n return true;\n}\n\nexport function encodeParamsObject(data): string {\n return mapObject(data, function(value) {\n if (typeof value === 'object') {\n value = safeJSONStringify(value);\n }\n return encodeURIComponent(base64encode(value.toString()));\n });\n}\n\nexport function buildQueryString(data: any): string {\n var params = filterObject(data, function(value) {\n return value !== undefined;\n });\n\n var query = map(\n flatten(encodeParamsObject(params)),\n Util.method('join', '=')\n ).join('&');\n\n return query;\n}\n\n/**\n * See https://github.com/douglascrockford/JSON-js/blob/master/cycle.js\n *\n * Remove circular references from an object. Required for JSON.stringify in\n * React Native, which tends to blow up a lot.\n *\n * @param {any} object\n * @return {any} Decycled object\n */\nexport function decycleObject(object: any): any {\n var objects = [],\n paths = [];\n\n return (function derez(value, path) {\n var i, name, nu;\n\n switch (typeof value) {\n case 'object':\n if (!value) {\n return null;\n }\n for (i = 0; i < objects.length; i += 1) {\n if (objects[i] === value) {\n return { $ref: paths[i] };\n }\n }\n\n objects.push(value);\n paths.push(path);\n\n if (Object.prototype.toString.apply(value) === '[object Array]') {\n nu = [];\n for (i = 0; i < value.length; i += 1) {\n nu[i] = derez(value[i], path + '[' + i + ']');\n }\n } else {\n nu = {};\n for (name in value) {\n if (Object.prototype.hasOwnProperty.call(value, name)) {\n nu[name] = derez(\n value[name],\n path + '[' + JSON.stringify(name) + ']'\n );\n }\n }\n }\n return nu;\n case 'number':\n case 'string':\n case 'boolean':\n return value;\n }\n })(object, '$');\n}\n\n/**\n * Provides a cross-browser and cross-platform way to safely stringify objects\n * into JSON. This is particularly necessary for ReactNative, where circular JSON\n * structures throw an exception.\n *\n * @param {any} source The object to stringify\n * @return {string} The serialized output.\n */\nexport function safeJSONStringify(source: any): string {\n try {\n return JSON.stringify(source);\n } catch (e) {\n return JSON.stringify(decycleObject(source));\n }\n}\n","import { stringify } from './utils/collections';\nimport Pusher from './pusher';\n\nclass Logger {\n debug(...args: any[]) {\n this.log(this.globalLog, args);\n }\n\n warn(...args: any[]) {\n this.log(this.globalLogWarn, args);\n }\n\n error(...args: any[]) {\n this.log(this.globalLogError, args);\n }\n\n private globalLog = (message: string) => {\n if (global.console && global.console.log) {\n global.console.log(message);\n }\n };\n\n private globalLogWarn(message: string) {\n if (global.console && global.console.warn) {\n global.console.warn(message);\n } else {\n this.globalLog(message);\n }\n }\n\n private globalLogError(message: string) {\n if (global.console && global.console.error) {\n global.console.error(message);\n } else {\n this.globalLogWarn(message);\n }\n }\n\n private log(\n defaultLoggingFunction: (message: string) => void,\n ...args: any[]\n ) {\n var message = stringify.apply(this, arguments);\n if (Pusher.log) {\n Pusher.log(message);\n } else if (Pusher.logToConsole) {\n const log = defaultLoggingFunction.bind(this);\n log(message);\n }\n }\n}\n\nexport default new Logger();\n","import Browser from '../browser';\nimport Logger from 'core/logger';\nimport JSONPRequest from '../dom/jsonp_request';\nimport { ScriptReceivers } from '../dom/script_receiver_factory';\nimport { AuthTransport } from 'core/auth/auth_transports';\nimport {\n AuthRequestType,\n AuthTransportCallback,\n InternalAuthOptions\n} from 'core/auth/options';\n\nvar jsonp: AuthTransport = function(\n context: Browser,\n query: string,\n authOptions: InternalAuthOptions,\n authRequestType: AuthRequestType,\n callback: AuthTransportCallback\n) {\n if (\n authOptions.headers !== undefined ||\n authOptions.headersProvider != null\n ) {\n Logger.warn(\n `To send headers with the ${authRequestType.toString()} request, you must use AJAX, rather than JSONP.`\n );\n }\n\n var callbackName = context.nextAuthCallbackID.toString();\n context.nextAuthCallbackID++;\n\n var document = context.getDocument();\n var script = document.createElement('script');\n // Hacked wrapper.\n context.auth_callbacks[callbackName] = function(data) {\n callback(null, data);\n };\n\n var callback_name = \"Pusher.auth_callbacks['\" + callbackName + \"']\";\n script.src =\n authOptions.endpoint +\n '?callback=' +\n encodeURIComponent(callback_name) +\n '&' +\n query;\n\n var head =\n document.getElementsByTagName('head')[0] || document.documentElement;\n head.insertBefore(script, head.firstChild);\n};\n\nexport default jsonp;\n","import ScriptReceiver from './script_receiver';\n\n/** Sends a generic HTTP GET request using a script tag.\n *\n * By constructing URL in a specific way, it can be used for loading\n * JavaScript resources or JSONP requests. It can notify about errors, but\n * only in certain environments. Please take care of monitoring the state of\n * the request yourself.\n *\n * @param {String} src\n */\nexport default class ScriptRequest {\n src: string;\n script: any;\n errorScript: any;\n\n constructor(src: string) {\n this.src = src;\n }\n\n send(receiver: ScriptReceiver) {\n var self = this;\n var errorString = 'Error loading ' + self.src;\n\n self.script = document.createElement('script');\n self.script.id = receiver.id;\n self.script.src = self.src;\n self.script.type = 'text/javascript';\n self.script.charset = 'UTF-8';\n\n if (self.script.addEventListener) {\n self.script.onerror = function() {\n receiver.callback(errorString);\n };\n self.script.onload = function() {\n receiver.callback(null);\n };\n } else {\n self.script.onreadystatechange = function() {\n if (\n self.script.readyState === 'loaded' ||\n self.script.readyState === 'complete'\n ) {\n receiver.callback(null);\n }\n };\n }\n\n // Opera<11.6 hack for missing onerror callback\n if (\n self.script.async === undefined &&\n (document).attachEvent &&\n /opera/i.test(navigator.userAgent)\n ) {\n self.errorScript = document.createElement('script');\n self.errorScript.id = receiver.id + '_error';\n self.errorScript.text = receiver.name + \"('\" + errorString + \"');\";\n self.script.async = self.errorScript.async = false;\n } else {\n self.script.async = true;\n }\n\n var head = document.getElementsByTagName('head')[0];\n head.insertBefore(self.script, head.firstChild);\n if (self.errorScript) {\n head.insertBefore(self.errorScript, self.script.nextSibling);\n }\n }\n\n /** Cleans up the DOM remains of the script request. */\n cleanup() {\n if (this.script) {\n this.script.onload = this.script.onerror = null;\n this.script.onreadystatechange = null;\n }\n if (this.script && this.script.parentNode) {\n this.script.parentNode.removeChild(this.script);\n }\n if (this.errorScript && this.errorScript.parentNode) {\n this.errorScript.parentNode.removeChild(this.errorScript);\n }\n this.script = null;\n this.errorScript = null;\n }\n}\n","import ScriptReceiver from './script_receiver';\nimport ScriptRequest from './script_request';\nimport * as Collections from 'core/utils/collections';\nimport Util from 'core/util';\nimport Runtime from '../runtime';\n\n/** Sends data via JSONP.\n *\n * Data is a key-value map. Its values are JSON-encoded and then passed\n * through base64. Finally, keys and encoded values are appended to the query\n * string.\n *\n * The class itself does not guarantee raising errors on failures, as it's not\n * possible to support such feature on all browsers. Instead, JSONP endpoint\n * should call back in a way that's easy to distinguish from browser calls,\n * for example by passing a second argument to the receiver.\n *\n * @param {String} url\n * @param {Object} data key-value map of data to be submitted\n */\nexport default class JSONPRequest {\n url: string;\n data: any;\n request: ScriptRequest;\n\n constructor(url: string, data: any) {\n this.url = url;\n this.data = data;\n }\n\n /** Sends the actual JSONP request.\n *\n * @param {ScriptReceiver} receiver\n */\n send(receiver: ScriptReceiver) {\n if (this.request) {\n return;\n }\n\n var query = Collections.buildQueryString(this.data);\n var url = this.url + '/' + receiver.number + '?' + query;\n this.request = Runtime.createScriptRequest(url);\n this.request.send(receiver);\n }\n\n /** Cleans up the DOM remains of the JSONP request. */\n cleanup() {\n if (this.request) {\n this.request.cleanup();\n }\n }\n}\n","import TimelineSender from 'core/timeline/timeline_sender';\nimport TimelineTransport from 'core/timeline/timeline_transport';\nimport Browser from 'runtime';\nimport { AuthTransport } from 'core/auth/auth_transports';\nimport { ScriptReceivers } from '../dom/script_receiver_factory';\n\nvar getAgent = function(sender: TimelineSender, useTLS: boolean) {\n return function(data: any, callback: Function) {\n var scheme = 'http' + (useTLS ? 's' : '') + '://';\n var url =\n scheme + (sender.host || sender.options.host) + sender.options.path;\n var request = Browser.createJSONPRequest(url, data);\n\n var receiver = Browser.ScriptReceivers.create(function(error, result) {\n ScriptReceivers.remove(receiver);\n request.cleanup();\n\n if (result && result.host) {\n sender.host = result.host;\n }\n if (callback) {\n callback(error, result);\n }\n });\n request.send(receiver);\n };\n};\n\nvar jsonp = {\n name: 'jsonp',\n getAgent\n};\n\nexport default jsonp;\n","import Defaults from '../defaults';\nimport { default as URLScheme, URLSchemeParams } from './url_scheme';\n\nfunction getGenericURL(\n baseScheme: string,\n params: URLSchemeParams,\n path: string\n): string {\n var scheme = baseScheme + (params.useTLS ? 's' : '');\n var host = params.useTLS ? params.hostTLS : params.hostNonTLS;\n return scheme + '://' + host + path;\n}\n\nfunction getGenericPath(key: string, queryString?: string): string {\n var path = '/app/' + key;\n var query =\n '?protocol=' +\n Defaults.PROTOCOL +\n '&client=js' +\n '&version=' +\n Defaults.VERSION +\n (queryString ? '&' + queryString : '');\n return path + query;\n}\n\nexport var ws: URLScheme = {\n getInitial: function(key: string, params: URLSchemeParams): string {\n var path = (params.httpPath || '') + getGenericPath(key, 'flash=false');\n return getGenericURL('ws', params, path);\n }\n};\n\nexport var http: URLScheme = {\n getInitial: function(key: string, params: URLSchemeParams): string {\n var path = (params.httpPath || '/pusher') + getGenericPath(key);\n return getGenericURL('http', params, path);\n }\n};\n\nexport var sockjs: URLScheme = {\n getInitial: function(key: string, params: URLSchemeParams): string {\n return getGenericURL('http', params, params.httpPath || '/pusher');\n },\n getPath: function(key: string, params: URLSchemeParams): string {\n return getGenericPath(key);\n }\n};\n","import Callback from './callback';\nimport * as Collections from '../utils/collections';\nimport CallbackTable from './callback_table';\n\nexport default class CallbackRegistry {\n _callbacks: CallbackTable;\n\n constructor() {\n this._callbacks = {};\n }\n\n get(name: string): Callback[] {\n return this._callbacks[prefix(name)];\n }\n\n add(name: string, callback: Function, context: any) {\n var prefixedEventName = prefix(name);\n this._callbacks[prefixedEventName] =\n this._callbacks[prefixedEventName] || [];\n this._callbacks[prefixedEventName].push({\n fn: callback,\n context: context\n });\n }\n\n remove(name?: string, callback?: Function, context?: any) {\n if (!name && !callback && !context) {\n this._callbacks = {};\n return;\n }\n\n var names = name ? [prefix(name)] : Collections.keys(this._callbacks);\n\n if (callback || context) {\n this.removeCallback(names, callback, context);\n } else {\n this.removeAllCallbacks(names);\n }\n }\n\n private removeCallback(names: string[], callback: Function, context: any) {\n Collections.apply(\n names,\n function(name) {\n this._callbacks[name] = Collections.filter(\n this._callbacks[name] || [],\n function(binding) {\n return (\n (callback && callback !== binding.fn) ||\n (context && context !== binding.context)\n );\n }\n );\n if (this._callbacks[name].length === 0) {\n delete this._callbacks[name];\n }\n },\n this\n );\n }\n\n private removeAllCallbacks(names: string[]) {\n Collections.apply(\n names,\n function(name) {\n delete this._callbacks[name];\n },\n this\n );\n }\n}\n\nfunction prefix(name: string): string {\n return '_' + name;\n}\n","import * as Collections from '../utils/collections';\nimport Callback from './callback';\nimport Metadata from '../channels/metadata';\nimport CallbackRegistry from './callback_registry';\n\n/** Manages callback bindings and event emitting.\n *\n * @param Function failThrough called when no listeners are bound to an event\n */\nexport default class Dispatcher {\n callbacks: CallbackRegistry;\n global_callbacks: Function[];\n failThrough: Function;\n\n constructor(failThrough?: Function) {\n this.callbacks = new CallbackRegistry();\n this.global_callbacks = [];\n this.failThrough = failThrough;\n }\n\n bind(eventName: string, callback: Function, context?: any) {\n this.callbacks.add(eventName, callback, context);\n return this;\n }\n\n bind_global(callback: Function) {\n this.global_callbacks.push(callback);\n return this;\n }\n\n unbind(eventName?: string, callback?: Function, context?: any) {\n this.callbacks.remove(eventName, callback, context);\n return this;\n }\n\n unbind_global(callback?: Function) {\n if (!callback) {\n this.global_callbacks = [];\n return this;\n }\n\n this.global_callbacks = Collections.filter(\n this.global_callbacks || [],\n c => c !== callback\n );\n\n return this;\n }\n\n unbind_all() {\n this.unbind();\n this.unbind_global();\n return this;\n }\n\n emit(eventName: string, data?: any, metadata?: Metadata): Dispatcher {\n for (var i = 0; i < this.global_callbacks.length; i++) {\n this.global_callbacks[i](eventName, data);\n }\n\n var callbacks = this.callbacks.get(eventName);\n var args = [];\n\n if (metadata) {\n // if there's a metadata argument, we need to call the callback with both\n // data and metadata regardless of whether data is undefined\n args.push(data, metadata);\n } else if (data) {\n // metadata is undefined, so we only need to call the callback with data\n // if data exists\n args.push(data);\n }\n\n if (callbacks && callbacks.length > 0) {\n for (var i = 0; i < callbacks.length; i++) {\n callbacks[i].fn.apply(callbacks[i].context || global, args);\n }\n } else if (this.failThrough) {\n this.failThrough(eventName, data);\n }\n\n return this;\n }\n}\n","import Util from '../util';\nimport * as Collections from '../utils/collections';\nimport { default as EventsDispatcher } from '../events/dispatcher';\nimport Logger from '../logger';\nimport TransportHooks from './transport_hooks';\nimport Socket from '../socket';\nimport Runtime from 'runtime';\nimport Timeline from '../timeline/timeline';\nimport TransportConnectionOptions from './transport_connection_options';\n\n/** Provides universal API for transport connections.\n *\n * Transport connection is a low-level object that wraps a connection method\n * and exposes a simple evented interface for the connection state and\n * messaging. It does not implement Pusher-specific WebSocket protocol.\n *\n * Additionally, it fetches resources needed for transport to work and exposes\n * an interface for querying transport features.\n *\n * States:\n * - new - initial state after constructing the object\n * - initializing - during initialization phase, usually fetching resources\n * - intialized - ready to establish a connection\n * - connection - when connection is being established\n * - open - when connection ready to be used\n * - closed - after connection was closed be either side\n *\n * Emits:\n * - error - after the connection raised an error\n *\n * Options:\n * - useTLS - whether connection should be over TLS\n * - hostTLS - host to connect to when connection is over TLS\n * - hostNonTLS - host to connect to when connection is over TLS\n *\n * @param {String} key application key\n * @param {Object} options\n */\nexport default class TransportConnection extends EventsDispatcher {\n hooks: TransportHooks;\n name: string;\n priority: number;\n key: string;\n options: TransportConnectionOptions;\n state: string;\n timeline: Timeline;\n activityTimeout: number;\n id: number;\n socket: Socket;\n beforeOpen: Function;\n initialize: Function;\n\n constructor(\n hooks: TransportHooks,\n name: string,\n priority: number,\n key: string,\n options: TransportConnectionOptions\n ) {\n super();\n this.initialize = Runtime.transportConnectionInitializer;\n this.hooks = hooks;\n this.name = name;\n this.priority = priority;\n this.key = key;\n this.options = options;\n\n this.state = 'new';\n this.timeline = options.timeline;\n this.activityTimeout = options.activityTimeout;\n this.id = this.timeline.generateUniqueID();\n }\n\n /** Checks whether the transport handles activity checks by itself.\n *\n * @return {Boolean}\n */\n handlesActivityChecks(): boolean {\n return Boolean(this.hooks.handlesActivityChecks);\n }\n\n /** Checks whether the transport supports the ping/pong API.\n *\n * @return {Boolean}\n */\n supportsPing(): boolean {\n return Boolean(this.hooks.supportsPing);\n }\n\n /** Tries to establish a connection.\n *\n * @returns {Boolean} false if transport is in invalid state\n */\n connect(): boolean {\n if (this.socket || this.state !== 'initialized') {\n return false;\n }\n\n var url = this.hooks.urls.getInitial(this.key, this.options);\n try {\n this.socket = this.hooks.getSocket(url, this.options);\n } catch (e) {\n Util.defer(() => {\n this.onError(e);\n this.changeState('closed');\n });\n return false;\n }\n\n this.bindListeners();\n\n Logger.debug('Connecting', { transport: this.name, url });\n this.changeState('connecting');\n return true;\n }\n\n /** Closes the connection.\n *\n * @return {Boolean} true if there was a connection to close\n */\n close(): boolean {\n if (this.socket) {\n this.socket.close();\n return true;\n } else {\n return false;\n }\n }\n\n /** Sends data over the open connection.\n *\n * @param {String} data\n * @return {Boolean} true only when in the \"open\" state\n */\n send(data: any): boolean {\n if (this.state === 'open') {\n // Workaround for MobileSafari bug (see https://gist.github.com/2052006)\n Util.defer(() => {\n if (this.socket) {\n this.socket.send(data);\n }\n });\n return true;\n } else {\n return false;\n }\n }\n\n /** Sends a ping if the connection is open and transport supports it. */\n ping() {\n if (this.state === 'open' && this.supportsPing()) {\n this.socket.ping();\n }\n }\n\n private onOpen() {\n if (this.hooks.beforeOpen) {\n this.hooks.beforeOpen(\n this.socket,\n this.hooks.urls.getPath(this.key, this.options)\n );\n }\n this.changeState('open');\n this.socket.onopen = undefined;\n }\n\n private onError(error) {\n this.emit('error', { type: 'WebSocketError', error: error });\n this.timeline.error(this.buildTimelineMessage({ error: error.toString() }));\n }\n\n private onClose(closeEvent?: any) {\n if (closeEvent) {\n this.changeState('closed', {\n code: closeEvent.code,\n reason: closeEvent.reason,\n wasClean: closeEvent.wasClean\n });\n } else {\n this.changeState('closed');\n }\n this.unbindListeners();\n this.socket = undefined;\n }\n\n private onMessage(message) {\n this.emit('message', message);\n }\n\n private onActivity() {\n this.emit('activity');\n }\n\n private bindListeners() {\n this.socket.onopen = () => {\n this.onOpen();\n };\n this.socket.onerror = error => {\n this.onError(error);\n };\n this.socket.onclose = closeEvent => {\n this.onClose(closeEvent);\n };\n this.socket.onmessage = message => {\n this.onMessage(message);\n };\n\n if (this.supportsPing()) {\n this.socket.onactivity = () => {\n this.onActivity();\n };\n }\n }\n\n private unbindListeners() {\n if (this.socket) {\n this.socket.onopen = undefined;\n this.socket.onerror = undefined;\n this.socket.onclose = undefined;\n this.socket.onmessage = undefined;\n if (this.supportsPing()) {\n this.socket.onactivity = undefined;\n }\n }\n }\n\n private changeState(state: string, params?: any) {\n this.state = state;\n this.timeline.info(\n this.buildTimelineMessage({\n state: state,\n params: params\n })\n );\n this.emit(state, params);\n }\n\n buildTimelineMessage(message): any {\n return Collections.extend({ cid: this.id }, message);\n }\n}\n","import Factory from '../utils/factory';\nimport TransportHooks from './transport_hooks';\nimport TransportConnection from './transport_connection';\nimport TransportConnectionOptions from './transport_connection_options';\n\n/** Provides interface for transport connection instantiation.\n *\n * Takes transport-specific hooks as the only argument, which allow checking\n * for transport support and creating its connections.\n *\n * Supported hooks: * - file - the name of the file to be fetched during initialization\n * - urls - URL scheme to be used by transport\n * - handlesActivityCheck - true when the transport handles activity checks\n * - supportsPing - true when the transport has a ping/activity API\n * - isSupported - tells whether the transport is supported in the environment\n * - getSocket - creates a WebSocket-compatible transport socket\n *\n * See transports.js for specific implementations.\n *\n * @param {Object} hooks object containing all needed transport hooks\n */\nexport default class Transport {\n hooks: TransportHooks;\n\n constructor(hooks: TransportHooks) {\n this.hooks = hooks;\n }\n\n /** Returns whether the transport is supported in the environment.\n *\n * @param {Object} envronment te environment details (encryption, settings)\n * @returns {Boolean} true when the transport is supported\n */\n isSupported(environment: any): boolean {\n return this.hooks.isSupported(environment);\n }\n\n /** Creates a transport connection.\n *\n * @param {String} name\n * @param {Number} priority\n * @param {String} key the application key\n * @param {Object} options\n * @returns {TransportConnection}\n */\n createConnection(\n name: string,\n priority: number,\n key: string,\n options: any\n ): TransportConnection {\n return new TransportConnection(this.hooks, name, priority, key, options);\n }\n}\n","import * as URLSchemes from 'core/transports/url_schemes';\nimport URLScheme from 'core/transports/url_scheme';\nimport Transport from 'core/transports/transport';\nimport Util from 'core/util';\nimport * as Collections from 'core/utils/collections';\nimport TransportHooks from 'core/transports/transport_hooks';\nimport TransportsTable from 'core/transports/transports_table';\nimport Runtime from 'runtime';\n\n/** WebSocket transport.\n *\n * Uses native WebSocket implementation, including MozWebSocket supported by\n * earlier Firefox versions.\n */\nvar WSTransport = new Transport({\n urls: URLSchemes.ws,\n handlesActivityChecks: false,\n supportsPing: false,\n\n isInitialized: function() {\n return Boolean(Runtime.getWebSocketAPI());\n },\n isSupported: function(): boolean {\n return Boolean(Runtime.getWebSocketAPI());\n },\n getSocket: function(url) {\n return Runtime.createWebSocket(url);\n }\n});\n\nvar httpConfiguration = {\n urls: URLSchemes.http,\n handlesActivityChecks: false,\n supportsPing: true,\n isInitialized: function() {\n return true;\n }\n};\n\nexport var streamingConfiguration = Collections.extend(\n {\n getSocket: function(url) {\n return Runtime.HTTPFactory.createStreamingSocket(url);\n }\n },\n httpConfiguration\n);\nexport var pollingConfiguration = Collections.extend(\n {\n getSocket: function(url) {\n return Runtime.HTTPFactory.createPollingSocket(url);\n }\n },\n httpConfiguration\n);\n\nvar xhrConfiguration = {\n isSupported: function(): boolean {\n return Runtime.isXHRSupported();\n }\n};\n\n/** HTTP streaming transport using CORS-enabled XMLHttpRequest. */\nvar XHRStreamingTransport = new Transport(\n (\n Collections.extend({}, streamingConfiguration, xhrConfiguration)\n )\n);\n\n/** HTTP long-polling transport using CORS-enabled XMLHttpRequest. */\nvar XHRPollingTransport = new Transport(\n Collections.extend({}, pollingConfiguration, xhrConfiguration)\n);\n\nvar Transports: TransportsTable = {\n ws: WSTransport,\n xhr_streaming: XHRStreamingTransport,\n xhr_polling: XHRPollingTransport\n};\n\nexport default Transports;\n","import {\n default as Transports,\n streamingConfiguration,\n pollingConfiguration\n} from 'isomorphic/transports/transports';\nimport Transport from 'core/transports/transport';\nimport TransportHooks from 'core/transports/transport_hooks';\nimport * as URLSchemes from 'core/transports/url_schemes';\nimport Runtime from 'runtime';\nimport { Dependencies } from '../dom/dependencies';\nimport * as Collections from 'core/utils/collections';\n\nvar SockJSTransport = new Transport({\n file: 'sockjs',\n urls: URLSchemes.sockjs,\n handlesActivityChecks: true,\n supportsPing: false,\n\n isSupported: function() {\n return true;\n },\n isInitialized: function() {\n return window.SockJS !== undefined;\n },\n getSocket: function(url, options) {\n return new window.SockJS(url, null, {\n js_path: Dependencies.getPath('sockjs', {\n useTLS: options.useTLS\n }),\n ignore_null_origin: options.ignoreNullOrigin\n });\n },\n beforeOpen: function(socket, path) {\n socket.send(\n JSON.stringify({\n path: path\n })\n );\n }\n});\n\nvar xdrConfiguration = {\n isSupported: function(environment): boolean {\n var yes = Runtime.isXDRSupported(environment.useTLS);\n return yes;\n }\n};\n\n/** HTTP streaming transport using XDomainRequest (IE 8,9). */\nvar XDRStreamingTransport = new Transport(\n (\n Collections.extend({}, streamingConfiguration, xdrConfiguration)\n )\n);\n\n/** HTTP long-polling transport using XDomainRequest (IE 8,9). */\nvar XDRPollingTransport = new Transport(\n Collections.extend({}, pollingConfiguration, xdrConfiguration)\n);\n\nTransports.xdr_streaming = XDRStreamingTransport;\nTransports.xdr_polling = XDRPollingTransport;\nTransports.sockjs = SockJSTransport;\n\nexport default Transports;\n","import Reachability from 'core/reachability';\nimport { default as EventsDispatcher } from 'core/events/dispatcher';\n\n/** Really basic interface providing network availability info.\n *\n * Emits:\n * - online - when browser goes online\n * - offline - when browser goes offline\n */\nexport class NetInfo extends EventsDispatcher implements Reachability {\n constructor() {\n super();\n var self = this;\n // This is okay, as IE doesn't support this stuff anyway.\n if (window.addEventListener !== undefined) {\n window.addEventListener(\n 'online',\n function() {\n self.emit('online');\n },\n false\n );\n window.addEventListener(\n 'offline',\n function() {\n self.emit('offline');\n },\n false\n );\n }\n }\n\n /** Returns whether browser is online or not\n *\n * Offline means definitely offline (no connection to router).\n * Inverse does NOT mean definitely online (only currently supported in Safari\n * and even there only means the device has a connection to the router).\n *\n * @return {Boolean}\n */\n isOnline(): boolean {\n if (window.navigator.onLine === undefined) {\n return true;\n } else {\n return window.navigator.onLine;\n }\n }\n}\n\nexport var Network = new NetInfo();\n","import Util from '../util';\nimport * as Collections from '../utils/collections';\nimport TransportManager from './transport_manager';\nimport TransportConnection from './transport_connection';\nimport Transport from './transport';\nimport PingDelayOptions from './ping_delay_options';\n\n/** Creates transport connections monitored by a transport manager.\n *\n * When a transport is closed, it might mean the environment does not support\n * it. It's possible that messages get stuck in an intermediate buffer or\n * proxies terminate inactive connections. To combat these problems,\n * assistants monitor the connection lifetime, report unclean exits and\n * adjust ping timeouts to keep the connection active. The decision to disable\n * a transport is the manager's responsibility.\n *\n * @param {TransportManager} manager\n * @param {TransportConnection} transport\n * @param {Object} options\n */\nexport default class AssistantToTheTransportManager {\n manager: TransportManager;\n transport: Transport;\n minPingDelay: number;\n maxPingDelay: number;\n pingDelay: number;\n\n constructor(\n manager: TransportManager,\n transport: Transport,\n options: PingDelayOptions\n ) {\n this.manager = manager;\n this.transport = transport;\n this.minPingDelay = options.minPingDelay;\n this.maxPingDelay = options.maxPingDelay;\n this.pingDelay = undefined;\n }\n\n /** Creates a transport connection.\n *\n * This function has the same API as Transport#createConnection.\n *\n * @param {String} name\n * @param {Number} priority\n * @param {String} key the application key\n * @param {Object} options\n * @returns {TransportConnection}\n */\n createConnection(\n name: string,\n priority: number,\n key: string,\n options: Object\n ): TransportConnection {\n options = Collections.extend({}, options, {\n activityTimeout: this.pingDelay\n });\n var connection = this.transport.createConnection(\n name,\n priority,\n key,\n options\n );\n\n var openTimestamp = null;\n\n var onOpen = function() {\n connection.unbind('open', onOpen);\n connection.bind('closed', onClosed);\n openTimestamp = Util.now();\n };\n var onClosed = closeEvent => {\n connection.unbind('closed', onClosed);\n\n if (closeEvent.code === 1002 || closeEvent.code === 1003) {\n // we don't want to use transports not obeying the protocol\n this.manager.reportDeath();\n } else if (!closeEvent.wasClean && openTimestamp) {\n // report deaths only for short-living transport\n var lifespan = Util.now() - openTimestamp;\n if (lifespan < 2 * this.maxPingDelay) {\n this.manager.reportDeath();\n this.pingDelay = Math.max(lifespan / 2, this.minPingDelay);\n }\n }\n };\n\n connection.bind('open', onOpen);\n return connection;\n }\n\n /** Returns whether the transport is supported in the environment.\n *\n * This function has the same API as Transport#isSupported. Might return false\n * when the manager decides to kill the transport.\n *\n * @param {Object} environment the environment details (encryption, settings)\n * @returns {Boolean} true when the transport is supported\n */\n isSupported(environment: string): boolean {\n return this.manager.isAlive() && this.transport.isSupported(environment);\n }\n}\n","import Action from './action';\nimport { PusherEvent } from './message-types';\n/**\n * Provides functions for handling Pusher protocol-specific messages.\n */\n\nconst Protocol = {\n /**\n * Decodes a message in a Pusher format.\n *\n * The MessageEvent we receive from the transport should contain a pusher event\n * (https://pusher.com/docs/pusher_protocol#events) serialized as JSON in the\n * data field\n *\n * The pusher event may contain a data field too, and it may also be\n * serialised as JSON\n *\n * Throws errors when messages are not parse'able.\n *\n * @param {MessageEvent} messageEvent\n * @return {PusherEvent}\n */\n decodeMessage: function(messageEvent: MessageEvent): PusherEvent {\n try {\n var messageData = JSON.parse(messageEvent.data);\n var pusherEventData = messageData.data;\n if (typeof pusherEventData === 'string') {\n try {\n pusherEventData = JSON.parse(messageData.data);\n } catch (e) {}\n }\n var pusherEvent: PusherEvent = {\n event: messageData.event,\n channel: messageData.channel,\n data: pusherEventData\n };\n if (messageData.user_id) {\n pusherEvent.user_id = messageData.user_id;\n }\n return pusherEvent;\n } catch (e) {\n throw { type: 'MessageParseError', error: e, data: messageEvent.data };\n }\n },\n\n /**\n * Encodes a message to be sent.\n *\n * @param {PusherEvent} event\n * @return {String}\n */\n encodeMessage: function(event: PusherEvent): string {\n return JSON.stringify(event);\n },\n\n /**\n * Processes a handshake message and returns appropriate actions.\n *\n * Returns an object with an 'action' and other action-specific properties.\n *\n * There are three outcomes when calling this function. First is a successful\n * connection attempt, when pusher:connection_established is received, which\n * results in a 'connected' action with an 'id' property. When passed a\n * pusher:error event, it returns a result with action appropriate to the\n * close code and an error. Otherwise, it raises an exception.\n *\n * @param {String} message\n * @result Object\n */\n processHandshake: function(messageEvent: MessageEvent): Action {\n var message = Protocol.decodeMessage(messageEvent);\n\n if (message.event === 'pusher:connection_established') {\n if (!message.data.activity_timeout) {\n throw 'No activity timeout specified in handshake';\n }\n return {\n action: 'connected',\n id: message.data.socket_id,\n activityTimeout: message.data.activity_timeout * 1000\n };\n } else if (message.event === 'pusher:error') {\n // From protocol 6 close codes are sent only once, so this only\n // happens when connection does not support close codes\n return {\n action: this.getCloseAction(message.data),\n error: this.getCloseError(message.data)\n };\n } else {\n throw 'Invalid handshake';\n }\n },\n\n /**\n * Dispatches the close event and returns an appropriate action name.\n *\n * See:\n * 1. https://developer.mozilla.org/en-US/docs/WebSockets/WebSockets_reference/CloseEvent\n * 2. http://pusher.com/docs/pusher_protocol\n *\n * @param {CloseEvent} closeEvent\n * @return {String} close action name\n */\n getCloseAction: function(closeEvent): string {\n if (closeEvent.code < 4000) {\n // ignore 1000 CLOSE_NORMAL, 1001 CLOSE_GOING_AWAY,\n // 1005 CLOSE_NO_STATUS, 1006 CLOSE_ABNORMAL\n // ignore 1007...3999\n // handle 1002 CLOSE_PROTOCOL_ERROR, 1003 CLOSE_UNSUPPORTED,\n // 1004 CLOSE_TOO_LARGE\n if (closeEvent.code >= 1002 && closeEvent.code <= 1004) {\n return 'backoff';\n } else {\n return null;\n }\n } else if (closeEvent.code === 4000) {\n return 'tls_only';\n } else if (closeEvent.code < 4100) {\n return 'refused';\n } else if (closeEvent.code < 4200) {\n return 'backoff';\n } else if (closeEvent.code < 4300) {\n return 'retry';\n } else {\n // unknown error\n return 'refused';\n }\n },\n\n /**\n * Returns an error or null basing on the close event.\n *\n * Null is returned when connection was closed cleanly. Otherwise, an object\n * with error details is returned.\n *\n * @param {CloseEvent} closeEvent\n * @return {Object} error object\n */\n getCloseError: function(closeEvent): any {\n if (closeEvent.code !== 1000 && closeEvent.code !== 1001) {\n return {\n type: 'PusherError',\n data: {\n code: closeEvent.code,\n message: closeEvent.reason || closeEvent.message\n }\n };\n } else {\n return null;\n }\n }\n};\n\nexport default Protocol;\n","import * as Collections from '../utils/collections';\nimport { default as EventsDispatcher } from '../events/dispatcher';\nimport Protocol from './protocol/protocol';\nimport { PusherEvent } from './protocol/message-types';\nimport Logger from '../logger';\nimport TransportConnection from '../transports/transport_connection';\nimport Socket from '../socket';\n/**\n * Provides Pusher protocol interface for transports.\n *\n * Emits following events:\n * - message - on received messages\n * - ping - on ping requests\n * - pong - on pong responses\n * - error - when the transport emits an error\n * - closed - after closing the transport\n *\n * It also emits more events when connection closes with a code.\n * See Protocol.getCloseAction to get more details.\n *\n * @param {Number} id\n * @param {AbstractTransport} transport\n */\nexport default class Connection extends EventsDispatcher implements Socket {\n id: string;\n transport: TransportConnection;\n activityTimeout: number;\n\n constructor(id: string, transport: TransportConnection) {\n super();\n this.id = id;\n this.transport = transport;\n this.activityTimeout = transport.activityTimeout;\n this.bindListeners();\n }\n\n /** Returns whether used transport handles activity checks by itself\n *\n * @returns {Boolean} true if activity checks are handled by the transport\n */\n handlesActivityChecks() {\n return this.transport.handlesActivityChecks();\n }\n\n /** Sends raw data.\n *\n * @param {String} data\n */\n send(data: any): boolean {\n return this.transport.send(data);\n }\n\n /** Sends an event.\n *\n * @param {String} name\n * @param {String} data\n * @param {String} [channel]\n * @returns {Boolean} whether message was sent or not\n */\n send_event(name: string, data: any, channel?: string): boolean {\n var event: PusherEvent = { event: name, data: data };\n if (channel) {\n event.channel = channel;\n }\n Logger.debug('Event sent', event);\n return this.send(Protocol.encodeMessage(event));\n }\n\n /** Sends a ping message to the server.\n *\n * Basing on the underlying transport, it might send either transport's\n * protocol-specific ping or pusher:ping event.\n */\n ping() {\n if (this.transport.supportsPing()) {\n this.transport.ping();\n } else {\n this.send_event('pusher:ping', {});\n }\n }\n\n /** Closes the connection. */\n close() {\n this.transport.close();\n }\n\n private bindListeners() {\n var listeners = {\n message: (messageEvent: MessageEvent) => {\n var pusherEvent;\n try {\n pusherEvent = Protocol.decodeMessage(messageEvent);\n } catch (e) {\n this.emit('error', {\n type: 'MessageParseError',\n error: e,\n data: messageEvent.data\n });\n }\n\n if (pusherEvent !== undefined) {\n Logger.debug('Event recd', pusherEvent);\n\n switch (pusherEvent.event) {\n case 'pusher:error':\n this.emit('error', {\n type: 'PusherError',\n data: pusherEvent.data\n });\n break;\n case 'pusher:ping':\n this.emit('ping');\n break;\n case 'pusher:pong':\n this.emit('pong');\n break;\n }\n this.emit('message', pusherEvent);\n }\n },\n activity: () => {\n this.emit('activity');\n },\n error: error => {\n this.emit('error', error);\n },\n closed: closeEvent => {\n unbindListeners();\n\n if (closeEvent && closeEvent.code) {\n this.handleCloseEvent(closeEvent);\n }\n\n this.transport = null;\n this.emit('closed');\n }\n };\n\n var unbindListeners = () => {\n Collections.objectApply(listeners, (listener, event) => {\n this.transport.unbind(event, listener);\n });\n };\n\n Collections.objectApply(listeners, (listener, event) => {\n this.transport.bind(event, listener);\n });\n }\n\n private handleCloseEvent(closeEvent: any) {\n var action = Protocol.getCloseAction(closeEvent);\n var error = Protocol.getCloseError(closeEvent);\n if (error) {\n this.emit('error', error);\n }\n if (action) {\n this.emit(action, { action: action, error: error });\n }\n }\n}\n","import Util from '../../util';\nimport * as Collections from '../../utils/collections';\nimport Protocol from '../protocol/protocol';\nimport Connection from '../connection';\nimport TransportConnection from '../../transports/transport_connection';\nimport HandshakePayload from './handshake_payload';\n\n/**\n * Handles Pusher protocol handshakes for transports.\n *\n * Calls back with a result object after handshake is completed. Results\n * always have two fields:\n * - action - string describing action to be taken after the handshake\n * - transport - the transport object passed to the constructor\n *\n * Different actions can set different additional properties on the result.\n * In the case of 'connected' action, there will be a 'connection' property\n * containing a Connection object for the transport. Other actions should\n * carry an 'error' property.\n *\n * @param {AbstractTransport} transport\n * @param {Function} callback\n */\nexport default class Handshake {\n transport: TransportConnection;\n callback: (HandshakePayload) => void;\n onMessage: Function;\n onClosed: Function;\n\n constructor(\n transport: TransportConnection,\n callback: (HandshakePayload) => void\n ) {\n this.transport = transport;\n this.callback = callback;\n this.bindListeners();\n }\n\n close() {\n this.unbindListeners();\n this.transport.close();\n }\n\n private bindListeners() {\n this.onMessage = m => {\n this.unbindListeners();\n\n var result;\n try {\n result = Protocol.processHandshake(m);\n } catch (e) {\n this.finish('error', { error: e });\n this.transport.close();\n return;\n }\n\n if (result.action === 'connected') {\n this.finish('connected', {\n connection: new Connection(result.id, this.transport),\n activityTimeout: result.activityTimeout\n });\n } else {\n this.finish(result.action, { error: result.error });\n this.transport.close();\n }\n };\n\n this.onClosed = closeEvent => {\n this.unbindListeners();\n\n var action = Protocol.getCloseAction(closeEvent) || 'backoff';\n var error = Protocol.getCloseError(closeEvent);\n this.finish(action, { error: error });\n };\n\n this.transport.bind('message', this.onMessage);\n this.transport.bind('closed', this.onClosed);\n }\n\n private unbindListeners() {\n this.transport.unbind('message', this.onMessage);\n this.transport.unbind('closed', this.onClosed);\n }\n\n private finish(action: string, params: any) {\n this.callback(\n Collections.extend({ transport: this.transport, action: action }, params)\n );\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport base64encode from '../base64';\nimport Timeline from './timeline';\nimport Runtime from 'runtime';\n\nexport interface TimelineSenderOptions {\n host?: string;\n port?: number;\n path?: string;\n}\n\nexport default class TimelineSender {\n timeline: Timeline;\n options: TimelineSenderOptions;\n host: string;\n\n constructor(timeline: Timeline, options: TimelineSenderOptions) {\n this.timeline = timeline;\n this.options = options || {};\n }\n\n send(useTLS: boolean, callback?: Function) {\n if (this.timeline.isEmpty()) {\n return;\n }\n\n this.timeline.send(\n Runtime.TimelineTransport.getAgent(this, useTLS),\n callback\n );\n }\n}\n","import { default as EventsDispatcher } from '../events/dispatcher';\nimport * as Errors from '../errors';\nimport Logger from '../logger';\nimport Pusher from '../pusher';\nimport { PusherEvent } from '../connection/protocol/message-types';\nimport Metadata from './metadata';\nimport UrlStore from '../utils/url_store';\nimport {\n ChannelAuthorizationData,\n ChannelAuthorizationCallback\n} from '../auth/options';\nimport { HTTPAuthError } from '../errors';\n\n/** Provides base public channel interface with an event emitter.\n *\n * Emits:\n * - pusher:subscription_succeeded - after subscribing successfully\n * - other non-internal events\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\nexport default class Channel extends EventsDispatcher {\n name: string;\n pusher: Pusher;\n subscribed: boolean;\n subscriptionPending: boolean;\n subscriptionCancelled: boolean;\n subscriptionCount: null;\n\n constructor(name: string, pusher: Pusher) {\n super(function(event, data) {\n Logger.debug('No callbacks on ' + name + ' for ' + event);\n });\n\n this.name = name;\n this.pusher = pusher;\n this.subscribed = false;\n this.subscriptionPending = false;\n this.subscriptionCancelled = false;\n }\n\n /** Skips authorization, since public channels don't require it.\n *\n * @param {Function} callback\n */\n authorize(socketId: string, callback: ChannelAuthorizationCallback) {\n return callback(null, { auth: '' });\n }\n\n /** Triggers an event */\n trigger(event: string, data: any) {\n if (event.indexOf('client-') !== 0) {\n throw new Errors.BadEventName(\n \"Event '\" + event + \"' does not start with 'client-'\"\n );\n }\n if (!this.subscribed) {\n var suffix = UrlStore.buildLogSuffix('triggeringClientEvents');\n Logger.warn(\n `Client event triggered before channel 'subscription_succeeded' event . ${suffix}`\n );\n }\n return this.pusher.send_event(event, data, this.name);\n }\n\n /** Signals disconnection to the channel. For internal use only. */\n disconnect() {\n this.subscribed = false;\n this.subscriptionPending = false;\n }\n\n /** Handles a PusherEvent. For internal use only.\n *\n * @param {PusherEvent} event\n */\n handleEvent(event: PusherEvent) {\n var eventName = event.event;\n var data = event.data;\n if (eventName === 'pusher_internal:subscription_succeeded') {\n this.handleSubscriptionSucceededEvent(event);\n } else if (eventName === 'pusher_internal:subscription_count') {\n this.handleSubscriptionCountEvent(event);\n } else if (eventName.indexOf('pusher_internal:') !== 0) {\n var metadata: Metadata = {};\n this.emit(eventName, data, metadata);\n }\n }\n\n handleSubscriptionSucceededEvent(event: PusherEvent) {\n this.subscriptionPending = false;\n this.subscribed = true;\n if (this.subscriptionCancelled) {\n this.pusher.unsubscribe(this.name);\n } else {\n this.emit('pusher:subscription_succeeded', event.data);\n }\n }\n\n handleSubscriptionCountEvent(event: PusherEvent) {\n if (event.data.subscription_count) {\n this.subscriptionCount = event.data.subscription_count;\n }\n\n this.emit('pusher:subscription_count', event.data);\n }\n\n /** Sends a subscription request. For internal use only. */\n subscribe() {\n if (this.subscribed) {\n return;\n }\n this.subscriptionPending = true;\n this.subscriptionCancelled = false;\n this.authorize(\n this.pusher.connection.socket_id,\n (error: Error | null, data: ChannelAuthorizationData) => {\n if (error) {\n this.subscriptionPending = false;\n // Why not bind to 'pusher:subscription_error' a level up, and log there?\n // Binding to this event would cause the warning about no callbacks being\n // bound (see constructor) to be suppressed, that's not what we want.\n Logger.error(error.toString());\n this.emit(\n 'pusher:subscription_error',\n Object.assign(\n {},\n {\n type: 'AuthError',\n error: error.message\n },\n error instanceof HTTPAuthError ? { status: error.status } : {}\n )\n );\n } else {\n this.pusher.send_event('pusher:subscribe', {\n auth: data.auth,\n channel_data: data.channel_data,\n channel: this.name\n });\n }\n }\n );\n }\n\n /** Sends an unsubscription request. For internal use only. */\n unsubscribe() {\n this.subscribed = false;\n this.pusher.send_event('pusher:unsubscribe', {\n channel: this.name\n });\n }\n\n /** Cancels an in progress subscription. For internal use only. */\n cancelSubscription() {\n this.subscriptionCancelled = true;\n }\n\n /** Reinstates an in progress subscripiton. For internal use only. */\n reinstateSubscription() {\n this.subscriptionCancelled = false;\n }\n}\n","import Factory from '../utils/factory';\nimport Channel from './channel';\nimport { ChannelAuthorizationCallback } from '../auth/options';\n\n/** Extends public channels to provide private channel interface.\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\nexport default class PrivateChannel extends Channel {\n /** Authorizes the connection to use the channel.\n *\n * @param {String} socketId\n * @param {Function} callback\n */\n authorize(socketId: string, callback: ChannelAuthorizationCallback) {\n return this.pusher.config.channelAuthorizer(\n {\n channelName: this.name,\n socketId: socketId\n },\n callback\n );\n }\n}\n","import * as Collections from '../utils/collections';\n\n/** Represents a collection of members of a presence channel. */\nexport default class Members {\n members: any;\n count: number;\n myID: any;\n me: any;\n\n constructor() {\n this.reset();\n }\n\n /** Returns member's info for given id.\n *\n * Resulting object containts two fields - id and info.\n *\n * @param {Number} id\n * @return {Object} member's info or null\n */\n get(id: string): any {\n if (Object.prototype.hasOwnProperty.call(this.members, id)) {\n return {\n id: id,\n info: this.members[id]\n };\n } else {\n return null;\n }\n }\n\n /** Calls back for each member in unspecified order.\n *\n * @param {Function} callback\n */\n each(callback: Function) {\n Collections.objectApply(this.members, (member, id) => {\n callback(this.get(id));\n });\n }\n\n /** Updates the id for connected member. For internal use only. */\n setMyID(id: string) {\n this.myID = id;\n }\n\n /** Handles subscription data. For internal use only. */\n onSubscription(subscriptionData: any) {\n this.members = subscriptionData.presence.hash;\n this.count = subscriptionData.presence.count;\n this.me = this.get(this.myID);\n }\n\n /** Adds a new member to the collection. For internal use only. */\n addMember(memberData: any) {\n if (this.get(memberData.user_id) === null) {\n this.count++;\n }\n this.members[memberData.user_id] = memberData.user_info;\n return this.get(memberData.user_id);\n }\n\n /** Adds a member from the collection. For internal use only. */\n removeMember(memberData: any) {\n var member = this.get(memberData.user_id);\n if (member) {\n delete this.members[memberData.user_id];\n this.count--;\n }\n return member;\n }\n\n /** Resets the collection to the initial state. For internal use only. */\n reset() {\n this.members = {};\n this.count = 0;\n this.myID = null;\n this.me = null;\n }\n}\n","import PrivateChannel from './private_channel';\nimport Logger from '../logger';\nimport Members from './members';\nimport Pusher from '../pusher';\nimport UrlStore from 'core/utils/url_store';\nimport { PusherEvent } from '../connection/protocol/message-types';\nimport Metadata from './metadata';\nimport { ChannelAuthorizationData } from '../auth/options';\n\nexport default class PresenceChannel extends PrivateChannel {\n members: Members;\n\n /** Adds presence channel functionality to private channels.\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\n constructor(name: string, pusher: Pusher) {\n super(name, pusher);\n this.members = new Members();\n }\n\n /** Authorizes the connection as a member of the channel.\n *\n * @param {String} socketId\n * @param {Function} callback\n */\n authorize(socketId: string, callback: Function) {\n super.authorize(socketId, async (error, authData) => {\n if (!error) {\n authData = authData as ChannelAuthorizationData;\n if (authData.channel_data != null) {\n var channelData = JSON.parse(authData.channel_data);\n this.members.setMyID(channelData.user_id);\n } else {\n await this.pusher.user.signinDonePromise;\n if (this.pusher.user.user_data != null) {\n // If the user is signed in, get the id of the authenticated user\n // and allow the presence authorization to continue.\n this.members.setMyID(this.pusher.user.user_data.id);\n } else {\n let suffix = UrlStore.buildLogSuffix('authorizationEndpoint');\n Logger.error(\n `Invalid auth response for channel '${this.name}', ` +\n `expected 'channel_data' field. ${suffix}, ` +\n `or the user should be signed in.`\n );\n callback('Invalid auth response');\n return;\n }\n }\n }\n callback(error, authData);\n });\n }\n\n /** Handles presence and subscription events. For internal use only.\n *\n * @param {PusherEvent} event\n */\n handleEvent(event: PusherEvent) {\n var eventName = event.event;\n if (eventName.indexOf('pusher_internal:') === 0) {\n this.handleInternalEvent(event);\n } else {\n var data = event.data;\n var metadata: Metadata = {};\n if (event.user_id) {\n metadata.user_id = event.user_id;\n }\n this.emit(eventName, data, metadata);\n }\n }\n handleInternalEvent(event: PusherEvent) {\n var eventName = event.event;\n var data = event.data;\n switch (eventName) {\n case 'pusher_internal:subscription_succeeded':\n this.handleSubscriptionSucceededEvent(event);\n break;\n case 'pusher_internal:subscription_count':\n this.handleSubscriptionCountEvent(event);\n break;\n case 'pusher_internal:member_added':\n var addedMember = this.members.addMember(data);\n this.emit('pusher:member_added', addedMember);\n break;\n case 'pusher_internal:member_removed':\n var removedMember = this.members.removeMember(data);\n if (removedMember) {\n this.emit('pusher:member_removed', removedMember);\n }\n break;\n }\n }\n\n handleSubscriptionSucceededEvent(event: PusherEvent) {\n this.subscriptionPending = false;\n this.subscribed = true;\n if (this.subscriptionCancelled) {\n this.pusher.unsubscribe(this.name);\n } else {\n this.members.onSubscription(event.data);\n this.emit('pusher:subscription_succeeded', this.members);\n }\n }\n\n /** Resets the channel state, including members map. For internal use only. */\n disconnect() {\n this.members.reset();\n super.disconnect();\n }\n}\n","import PrivateChannel from './private_channel';\nimport * as Errors from '../errors';\nimport Logger from '../logger';\nimport Pusher from '../pusher';\nimport { decode as encodeUTF8 } from '@stablelib/utf8';\nimport { decode as decodeBase64 } from '@stablelib/base64';\nimport Dispatcher from '../events/dispatcher';\nimport { PusherEvent } from '../connection/protocol/message-types';\nimport {\n ChannelAuthorizationData,\n ChannelAuthorizationCallback\n} from '../auth/options';\nimport * as nacl from 'tweetnacl';\n\n/** Extends private channels to provide encrypted channel interface.\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\nexport default class EncryptedChannel extends PrivateChannel {\n key: Uint8Array = null;\n nacl: nacl;\n\n constructor(name: string, pusher: Pusher, nacl: nacl) {\n super(name, pusher);\n this.nacl = nacl;\n }\n\n /** Authorizes the connection to use the channel.\n *\n * @param {String} socketId\n * @param {Function} callback\n */\n authorize(socketId: string, callback: ChannelAuthorizationCallback) {\n super.authorize(\n socketId,\n (error: Error | null, authData: ChannelAuthorizationData) => {\n if (error) {\n callback(error, authData);\n return;\n }\n let sharedSecret = authData['shared_secret'];\n if (!sharedSecret) {\n callback(\n new Error(\n `No shared_secret key in auth payload for encrypted channel: ${this.name}`\n ),\n null\n );\n return;\n }\n this.key = decodeBase64(sharedSecret);\n delete authData['shared_secret'];\n callback(null, authData);\n }\n );\n }\n\n trigger(event: string, data: any): boolean {\n throw new Errors.UnsupportedFeature(\n 'Client events are not currently supported for encrypted channels'\n );\n }\n\n /** Handles an event. For internal use only.\n *\n * @param {PusherEvent} event\n */\n handleEvent(event: PusherEvent) {\n var eventName = event.event;\n var data = event.data;\n if (\n eventName.indexOf('pusher_internal:') === 0 ||\n eventName.indexOf('pusher:') === 0\n ) {\n super.handleEvent(event);\n return;\n }\n this.handleEncryptedEvent(eventName, data);\n }\n\n private handleEncryptedEvent(event: string, data: any): void {\n if (!this.key) {\n Logger.debug(\n 'Received encrypted event before key has been retrieved from the authEndpoint'\n );\n return;\n }\n if (!data.ciphertext || !data.nonce) {\n Logger.error(\n 'Unexpected format for encrypted event, expected object with `ciphertext` and `nonce` fields, got: ' +\n data\n );\n return;\n }\n let cipherText = decodeBase64(data.ciphertext);\n if (cipherText.length < this.nacl.secretbox.overheadLength) {\n Logger.error(\n `Expected encrypted event ciphertext length to be ${this.nacl.secretbox.overheadLength}, got: ${cipherText.length}`\n );\n return;\n }\n let nonce = decodeBase64(data.nonce);\n if (nonce.length < this.nacl.secretbox.nonceLength) {\n Logger.error(\n `Expected encrypted event nonce length to be ${this.nacl.secretbox.nonceLength}, got: ${nonce.length}`\n );\n return;\n }\n\n let bytes = this.nacl.secretbox.open(cipherText, nonce, this.key);\n if (bytes === null) {\n Logger.debug(\n 'Failed to decrypt an event, probably because it was encrypted with a different key. Fetching a new key from the authEndpoint...'\n );\n // Try a single time to retrieve a new auth key and decrypt the event with it\n // If this fails, a new key will be requested when a new message is received\n this.authorize(this.pusher.connection.socket_id, (error, authData) => {\n if (error) {\n Logger.error(\n `Failed to make a request to the authEndpoint: ${authData}. Unable to fetch new key, so dropping encrypted event`\n );\n return;\n }\n bytes = this.nacl.secretbox.open(cipherText, nonce, this.key);\n if (bytes === null) {\n Logger.error(\n `Failed to decrypt event with new key. Dropping encrypted event`\n );\n return;\n }\n this.emit(event, this.getDataToEmit(bytes));\n return;\n });\n return;\n }\n this.emit(event, this.getDataToEmit(bytes));\n }\n\n // Try and parse the decrypted bytes as JSON. If we can't parse it, just\n // return the utf-8 string\n getDataToEmit(bytes: Uint8Array): string {\n let raw = encodeUTF8(bytes);\n try {\n return JSON.parse(raw);\n } catch {\n return raw;\n }\n }\n}\n","import { default as EventsDispatcher } from '../events/dispatcher';\nimport { OneOffTimer as Timer } from '../utils/timers';\nimport { Config } from '../config';\nimport Logger from '../logger';\nimport HandshakePayload from './handshake/handshake_payload';\nimport Connection from './connection';\nimport Strategy from '../strategies/strategy';\nimport StrategyRunner from '../strategies/strategy_runner';\nimport * as Collections from '../utils/collections';\nimport Timeline from '../timeline/timeline';\nimport ConnectionManagerOptions from './connection_manager_options';\nimport Runtime from 'runtime';\n\nimport {\n ErrorCallbacks,\n HandshakeCallbacks,\n ConnectionCallbacks\n} from './callbacks';\nimport Action from './protocol/action';\n\n/** Manages connection to Pusher.\n *\n * Uses a strategy (currently only default), timers and network availability\n * info to establish a connection and export its state. In case of failures,\n * manages reconnection attempts.\n *\n * Exports state changes as following events:\n * - \"state_change\", { previous: p, current: state }\n * - state\n *\n * States:\n * - initialized - initial state, never transitioned to\n * - connecting - connection is being established\n * - connected - connection has been fully established\n * - disconnected - on requested disconnection\n * - unavailable - after connection timeout or when there's no network\n * - failed - when the connection strategy is not supported\n *\n * Options:\n * - unavailableTimeout - time to transition to unavailable state\n * - activityTimeout - time after which ping message should be sent\n * - pongTimeout - time for Pusher to respond with pong before reconnecting\n *\n * @param {String} key application key\n * @param {Object} options\n */\nexport default class ConnectionManager extends EventsDispatcher {\n key: string;\n options: ConnectionManagerOptions;\n state: string;\n connection: Connection;\n usingTLS: boolean;\n timeline: Timeline;\n socket_id: string;\n unavailableTimer: Timer;\n activityTimer: Timer;\n retryTimer: Timer;\n activityTimeout: number;\n strategy: Strategy;\n runner: StrategyRunner;\n errorCallbacks: ErrorCallbacks;\n handshakeCallbacks: HandshakeCallbacks;\n connectionCallbacks: ConnectionCallbacks;\n\n constructor(key: string, options: ConnectionManagerOptions) {\n super();\n this.state = 'initialized';\n this.connection = null;\n\n this.key = key;\n this.options = options;\n this.timeline = this.options.timeline;\n this.usingTLS = this.options.useTLS;\n\n this.errorCallbacks = this.buildErrorCallbacks();\n this.connectionCallbacks = this.buildConnectionCallbacks(\n this.errorCallbacks\n );\n this.handshakeCallbacks = this.buildHandshakeCallbacks(this.errorCallbacks);\n\n var Network = Runtime.getNetwork();\n\n Network.bind('online', () => {\n this.timeline.info({ netinfo: 'online' });\n if (this.state === 'connecting' || this.state === 'unavailable') {\n this.retryIn(0);\n }\n });\n Network.bind('offline', () => {\n this.timeline.info({ netinfo: 'offline' });\n if (this.connection) {\n this.sendActivityCheck();\n }\n });\n\n this.updateStrategy();\n }\n\n /** Establishes a connection to Pusher.\n *\n * Does nothing when connection is already established. See top-level doc\n * to find events emitted on connection attempts.\n */\n connect() {\n if (this.connection || this.runner) {\n return;\n }\n if (!this.strategy.isSupported()) {\n this.updateState('failed');\n return;\n }\n this.updateState('connecting');\n this.startConnecting();\n this.setUnavailableTimer();\n }\n\n /** Sends raw data.\n *\n * @param {String} data\n */\n send(data) {\n if (this.connection) {\n return this.connection.send(data);\n } else {\n return false;\n }\n }\n\n /** Sends an event.\n *\n * @param {String} name\n * @param {String} data\n * @param {String} [channel]\n * @returns {Boolean} whether message was sent or not\n */\n send_event(name: string, data: any, channel?: string) {\n if (this.connection) {\n return this.connection.send_event(name, data, channel);\n } else {\n return false;\n }\n }\n\n /** Closes the connection. */\n disconnect() {\n this.disconnectInternally();\n this.updateState('disconnected');\n }\n\n isUsingTLS() {\n return this.usingTLS;\n }\n\n private startConnecting() {\n var callback = (error, handshake) => {\n if (error) {\n this.runner = this.strategy.connect(0, callback);\n } else {\n if (handshake.action === 'error') {\n this.emit('error', {\n type: 'HandshakeError',\n error: handshake.error\n });\n this.timeline.error({ handshakeError: handshake.error });\n } else {\n this.abortConnecting(); // we don't support switching connections yet\n this.handshakeCallbacks[handshake.action](handshake);\n }\n }\n };\n this.runner = this.strategy.connect(0, callback);\n }\n\n private abortConnecting() {\n if (this.runner) {\n this.runner.abort();\n this.runner = null;\n }\n }\n\n private disconnectInternally() {\n this.abortConnecting();\n this.clearRetryTimer();\n this.clearUnavailableTimer();\n if (this.connection) {\n var connection = this.abandonConnection();\n connection.close();\n }\n }\n\n private updateStrategy() {\n this.strategy = this.options.getStrategy({\n key: this.key,\n timeline: this.timeline,\n useTLS: this.usingTLS\n });\n }\n\n private retryIn(delay) {\n this.timeline.info({ action: 'retry', delay: delay });\n if (delay > 0) {\n this.emit('connecting_in', Math.round(delay / 1000));\n }\n this.retryTimer = new Timer(delay || 0, () => {\n this.disconnectInternally();\n this.connect();\n });\n }\n\n private clearRetryTimer() {\n if (this.retryTimer) {\n this.retryTimer.ensureAborted();\n this.retryTimer = null;\n }\n }\n\n private setUnavailableTimer() {\n this.unavailableTimer = new Timer(this.options.unavailableTimeout, () => {\n this.updateState('unavailable');\n });\n }\n\n private clearUnavailableTimer() {\n if (this.unavailableTimer) {\n this.unavailableTimer.ensureAborted();\n }\n }\n\n private sendActivityCheck() {\n this.stopActivityCheck();\n this.connection.ping();\n // wait for pong response\n this.activityTimer = new Timer(this.options.pongTimeout, () => {\n this.timeline.error({ pong_timed_out: this.options.pongTimeout });\n this.retryIn(0);\n });\n }\n\n private resetActivityCheck() {\n this.stopActivityCheck();\n // send ping after inactivity\n if (this.connection && !this.connection.handlesActivityChecks()) {\n this.activityTimer = new Timer(this.activityTimeout, () => {\n this.sendActivityCheck();\n });\n }\n }\n\n private stopActivityCheck() {\n if (this.activityTimer) {\n this.activityTimer.ensureAborted();\n }\n }\n\n private buildConnectionCallbacks(\n errorCallbacks: ErrorCallbacks\n ): ConnectionCallbacks {\n return Collections.extend({}, errorCallbacks, {\n message: message => {\n // includes pong messages from server\n this.resetActivityCheck();\n this.emit('message', message);\n },\n ping: () => {\n this.send_event('pusher:pong', {});\n },\n activity: () => {\n this.resetActivityCheck();\n },\n error: error => {\n // just emit error to user - socket will already be closed by browser\n this.emit('error', error);\n },\n closed: () => {\n this.abandonConnection();\n if (this.shouldRetry()) {\n this.retryIn(1000);\n }\n }\n });\n }\n\n private buildHandshakeCallbacks(\n errorCallbacks: ErrorCallbacks\n ): HandshakeCallbacks {\n return Collections.extend({}, errorCallbacks, {\n connected: (handshake: HandshakePayload) => {\n this.activityTimeout = Math.min(\n this.options.activityTimeout,\n handshake.activityTimeout,\n handshake.connection.activityTimeout || Infinity\n );\n this.clearUnavailableTimer();\n this.setConnection(handshake.connection);\n this.socket_id = this.connection.id;\n this.updateState('connected', { socket_id: this.socket_id });\n }\n });\n }\n\n private buildErrorCallbacks(): ErrorCallbacks {\n let withErrorEmitted = callback => {\n return (result: Action | HandshakePayload) => {\n if (result.error) {\n this.emit('error', { type: 'WebSocketError', error: result.error });\n }\n callback(result);\n };\n };\n\n return {\n tls_only: withErrorEmitted(() => {\n this.usingTLS = true;\n this.updateStrategy();\n this.retryIn(0);\n }),\n refused: withErrorEmitted(() => {\n this.disconnect();\n }),\n backoff: withErrorEmitted(() => {\n this.retryIn(1000);\n }),\n retry: withErrorEmitted(() => {\n this.retryIn(0);\n })\n };\n }\n\n private setConnection(connection) {\n this.connection = connection;\n for (var event in this.connectionCallbacks) {\n this.connection.bind(event, this.connectionCallbacks[event]);\n }\n this.resetActivityCheck();\n }\n\n private abandonConnection() {\n if (!this.connection) {\n return;\n }\n this.stopActivityCheck();\n for (var event in this.connectionCallbacks) {\n this.connection.unbind(event, this.connectionCallbacks[event]);\n }\n var connection = this.connection;\n this.connection = null;\n return connection;\n }\n\n private updateState(newState: string, data?: any) {\n var previousState = this.state;\n this.state = newState;\n if (previousState !== newState) {\n var newStateDescription = newState;\n if (newStateDescription === 'connected') {\n newStateDescription += ' with new socket ID ' + data.socket_id;\n }\n Logger.debug(\n 'State changed',\n previousState + ' -> ' + newStateDescription\n );\n this.timeline.info({ state: newState, params: data });\n this.emit('state_change', { previous: previousState, current: newState });\n this.emit(newState, data);\n }\n }\n\n private shouldRetry(): boolean {\n return this.state === 'connecting' || this.state === 'connected';\n }\n}\n","import Channel from './channel';\nimport * as Collections from '../utils/collections';\nimport ChannelTable from './channel_table';\nimport Factory from '../utils/factory';\nimport Pusher from '../pusher';\nimport Logger from '../logger';\nimport * as Errors from '../errors';\nimport urlStore from '../utils/url_store';\n\n/** Handles a channel map. */\nexport default class Channels {\n channels: ChannelTable;\n\n constructor() {\n this.channels = {};\n }\n\n /** Creates or retrieves an existing channel by its name.\n *\n * @param {String} name\n * @param {Pusher} pusher\n * @return {Channel}\n */\n add(name: string, pusher: Pusher) {\n if (!this.channels[name]) {\n this.channels[name] = createChannel(name, pusher);\n }\n return this.channels[name];\n }\n\n /** Returns a list of all channels\n *\n * @return {Array}\n */\n all(): Channel[] {\n return Collections.values(this.channels);\n }\n\n /** Finds a channel by its name.\n *\n * @param {String} name\n * @return {Channel} channel or null if it doesn't exist\n */\n find(name: string) {\n return this.channels[name];\n }\n\n /** Removes a channel from the map.\n *\n * @param {String} name\n */\n remove(name: string) {\n var channel = this.channels[name];\n delete this.channels[name];\n return channel;\n }\n\n /** Proxies disconnection signal to all channels. */\n disconnect() {\n Collections.objectApply(this.channels, function(channel) {\n channel.disconnect();\n });\n }\n}\n\nfunction createChannel(name: string, pusher: Pusher): Channel {\n if (name.indexOf('private-encrypted-') === 0) {\n if (pusher.config.nacl) {\n return Factory.createEncryptedChannel(name, pusher, pusher.config.nacl);\n }\n let errMsg =\n 'Tried to subscribe to a private-encrypted- channel but no nacl implementation available';\n let suffix = urlStore.buildLogSuffix('encryptedChannelSupport');\n throw new Errors.UnsupportedFeature(`${errMsg}. ${suffix}`);\n } else if (name.indexOf('private-') === 0) {\n return Factory.createPrivateChannel(name, pusher);\n } else if (name.indexOf('presence-') === 0) {\n return Factory.createPresenceChannel(name, pusher);\n } else if (name.indexOf('#') === 0) {\n throw new Errors.BadChannelName(\n 'Cannot create a channel with name \"' + name + '\".'\n );\n } else {\n return Factory.createChannel(name, pusher);\n }\n}\n","import AssistantToTheTransportManager from '../transports/assistant_to_the_transport_manager';\nimport PingDelayOptions from '../transports/ping_delay_options';\nimport Transport from '../transports/transport';\nimport TransportManager from '../transports/transport_manager';\nimport Handshake from '../connection/handshake';\nimport TransportConnection from '../transports/transport_connection';\nimport SocketHooks from '../http/socket_hooks';\nimport HTTPSocket from '../http/http_socket';\n\nimport Timeline from '../timeline/timeline';\nimport {\n default as TimelineSender,\n TimelineSenderOptions\n} from '../timeline/timeline_sender';\nimport PresenceChannel from '../channels/presence_channel';\nimport PrivateChannel from '../channels/private_channel';\nimport EncryptedChannel from '../channels/encrypted_channel';\nimport Channel from '../channels/channel';\nimport ConnectionManager from '../connection/connection_manager';\nimport ConnectionManagerOptions from '../connection/connection_manager_options';\nimport Ajax from '../http/ajax';\nimport Channels from '../channels/channels';\nimport Pusher from '../pusher';\nimport { Config } from '../config';\nimport * as nacl from 'tweetnacl';\n\nvar Factory = {\n createChannels(): Channels {\n return new Channels();\n },\n\n createConnectionManager(\n key: string,\n options: ConnectionManagerOptions\n ): ConnectionManager {\n return new ConnectionManager(key, options);\n },\n\n createChannel(name: string, pusher: Pusher): Channel {\n return new Channel(name, pusher);\n },\n\n createPrivateChannel(name: string, pusher: Pusher): PrivateChannel {\n return new PrivateChannel(name, pusher);\n },\n\n createPresenceChannel(name: string, pusher: Pusher): PresenceChannel {\n return new PresenceChannel(name, pusher);\n },\n\n createEncryptedChannel(\n name: string,\n pusher: Pusher,\n nacl: nacl\n ): EncryptedChannel {\n return new EncryptedChannel(name, pusher, nacl);\n },\n\n createTimelineSender(timeline: Timeline, options: TimelineSenderOptions) {\n return new TimelineSender(timeline, options);\n },\n\n createHandshake(\n transport: TransportConnection,\n callback: (HandshakePayload) => void\n ): Handshake {\n return new Handshake(transport, callback);\n },\n\n createAssistantToTheTransportManager(\n manager: TransportManager,\n transport: Transport,\n options: PingDelayOptions\n ): AssistantToTheTransportManager {\n return new AssistantToTheTransportManager(manager, transport, options);\n }\n};\n\nexport default Factory;\n","import AssistantToTheTransportManager from './assistant_to_the_transport_manager';\nimport Transport from './transport';\nimport PingDelayOptions from './ping_delay_options';\nimport Factory from '../utils/factory';\n\nexport interface TransportManagerOptions extends PingDelayOptions {\n lives?: number;\n}\n\n/** Keeps track of the number of lives left for a transport.\n *\n * In the beginning of a session, transports may be assigned a number of\n * lives. When an AssistantToTheTransportManager instance reports a transport\n * connection closed uncleanly, the transport loses a life. When the number\n * of lives drops to zero, the transport gets disabled by its manager.\n *\n * @param {Object} options\n */\nexport default class TransportManager {\n options: TransportManagerOptions;\n livesLeft: number;\n\n constructor(options: TransportManagerOptions) {\n this.options = options || {};\n this.livesLeft = this.options.lives || Infinity;\n }\n\n /** Creates a assistant for the transport.\n *\n * @param {Transport} transport\n * @returns {AssistantToTheTransportManager}\n */\n getAssistant(transport: Transport): AssistantToTheTransportManager {\n return Factory.createAssistantToTheTransportManager(this, transport, {\n minPingDelay: this.options.minPingDelay,\n maxPingDelay: this.options.maxPingDelay\n });\n }\n\n /** Returns whether the transport has any lives left.\n *\n * @returns {Boolean}\n */\n isAlive(): boolean {\n return this.livesLeft > 0;\n }\n\n /** Takes one life from the transport. */\n reportDeath() {\n this.livesLeft -= 1;\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport { OneOffTimer as Timer } from '../utils/timers';\nimport Strategy from './strategy';\nimport StrategyOptions from './strategy_options';\n\n/** Loops through strategies with optional timeouts.\n *\n * Options:\n * - loop - whether it should loop through the substrategy list\n * - timeout - initial timeout for a single substrategy\n * - timeoutLimit - maximum timeout\n *\n * @param {Strategy[]} strategies\n * @param {Object} options\n */\nexport default class SequentialStrategy implements Strategy {\n strategies: Strategy[];\n loop: boolean;\n failFast: boolean;\n timeout: number;\n timeoutLimit: number;\n\n constructor(strategies: Strategy[], options: StrategyOptions) {\n this.strategies = strategies;\n this.loop = Boolean(options.loop);\n this.failFast = Boolean(options.failFast);\n this.timeout = options.timeout;\n this.timeoutLimit = options.timeoutLimit;\n }\n\n isSupported(): boolean {\n return Collections.any(this.strategies, Util.method('isSupported'));\n }\n\n connect(minPriority: number, callback: Function) {\n var strategies = this.strategies;\n var current = 0;\n var timeout = this.timeout;\n var runner = null;\n\n var tryNextStrategy = (error, handshake) => {\n if (handshake) {\n callback(null, handshake);\n } else {\n current = current + 1;\n if (this.loop) {\n current = current % strategies.length;\n }\n\n if (current < strategies.length) {\n if (timeout) {\n timeout = timeout * 2;\n if (this.timeoutLimit) {\n timeout = Math.min(timeout, this.timeoutLimit);\n }\n }\n runner = this.tryStrategy(\n strategies[current],\n minPriority,\n { timeout, failFast: this.failFast },\n tryNextStrategy\n );\n } else {\n callback(true);\n }\n }\n };\n\n runner = this.tryStrategy(\n strategies[current],\n minPriority,\n { timeout: timeout, failFast: this.failFast },\n tryNextStrategy\n );\n\n return {\n abort: function() {\n runner.abort();\n },\n forceMinPriority: function(p) {\n minPriority = p;\n if (runner) {\n runner.forceMinPriority(p);\n }\n }\n };\n }\n\n private tryStrategy(\n strategy: Strategy,\n minPriority: number,\n options: StrategyOptions,\n callback: Function\n ) {\n var timer = null;\n var runner = null;\n\n if (options.timeout > 0) {\n timer = new Timer(options.timeout, function() {\n runner.abort();\n callback(true);\n });\n }\n\n runner = strategy.connect(minPriority, function(error, handshake) {\n if (error && timer && timer.isRunning() && !options.failFast) {\n // advance to the next strategy after the timeout\n return;\n }\n if (timer) {\n timer.ensureAborted();\n }\n callback(error, handshake);\n });\n\n return {\n abort: function() {\n if (timer) {\n timer.ensureAborted();\n }\n runner.abort();\n },\n forceMinPriority: function(p) {\n runner.forceMinPriority(p);\n }\n };\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport Strategy from './strategy';\n\n/** Launches all substrategies and emits prioritized connected transports.\n *\n * @param {Array} strategies\n */\nexport default class BestConnectedEverStrategy implements Strategy {\n strategies: Strategy[];\n\n constructor(strategies: Strategy[]) {\n this.strategies = strategies;\n }\n\n isSupported(): boolean {\n return Collections.any(this.strategies, Util.method('isSupported'));\n }\n\n connect(minPriority: number, callback: Function) {\n return connect(this.strategies, minPriority, function(i, runners) {\n return function(error, handshake) {\n runners[i].error = error;\n if (error) {\n if (allRunnersFailed(runners)) {\n callback(true);\n }\n return;\n }\n Collections.apply(runners, function(runner) {\n runner.forceMinPriority(handshake.transport.priority);\n });\n callback(null, handshake);\n };\n });\n }\n}\n\n/** Connects to all strategies in parallel.\n *\n * Callback builder should be a function that takes two arguments: index\n * and a list of runners. It should return another function that will be\n * passed to the substrategy with given index. Runners can be aborted using\n * abortRunner(s) functions from this class.\n *\n * @param {Array} strategies\n * @param {Function} callbackBuilder\n * @return {Object} strategy runner\n */\nfunction connect(\n strategies: Strategy[],\n minPriority: number,\n callbackBuilder: Function\n) {\n var runners = Collections.map(strategies, function(strategy, i, _, rs) {\n return strategy.connect(minPriority, callbackBuilder(i, rs));\n });\n return {\n abort: function() {\n Collections.apply(runners, abortRunner);\n },\n forceMinPriority: function(p) {\n Collections.apply(runners, function(runner) {\n runner.forceMinPriority(p);\n });\n }\n };\n}\n\nfunction allRunnersFailed(runners): boolean {\n return Collections.all(runners, function(runner) {\n return Boolean(runner.error);\n });\n}\n\nfunction abortRunner(runner) {\n if (!runner.error && !runner.aborted) {\n runner.abort();\n runner.aborted = true;\n }\n}\n","import Util from '../util';\nimport Runtime from 'runtime';\nimport Strategy from './strategy';\nimport SequentialStrategy from './sequential_strategy';\nimport StrategyOptions from './strategy_options';\nimport TransportStrategy from './transport_strategy';\nimport Timeline from '../timeline/timeline';\nimport * as Collections from '../utils/collections';\n\nexport interface TransportStrategyDictionary {\n [key: string]: TransportStrategy;\n}\n\n/** Caches the last successful transport and, after the first few attempts,\n * uses the cached transport for subsequent attempts.\n *\n * @param {Strategy} strategy\n * @param {Object} transports\n * @param {Object} options\n */\nexport default class WebSocketPrioritizedCachedStrategy implements Strategy {\n strategy: Strategy;\n transports: TransportStrategyDictionary;\n ttl: number;\n usingTLS: boolean;\n timeline: Timeline;\n\n constructor(\n strategy: Strategy,\n transports: TransportStrategyDictionary,\n options: StrategyOptions\n ) {\n this.strategy = strategy;\n this.transports = transports;\n this.ttl = options.ttl || 1800 * 1000;\n this.usingTLS = options.useTLS;\n this.timeline = options.timeline;\n }\n\n isSupported(): boolean {\n return this.strategy.isSupported();\n }\n\n connect(minPriority: number, callback: Function) {\n var usingTLS = this.usingTLS;\n var info = fetchTransportCache(usingTLS);\n var cacheSkipCount = info && info.cacheSkipCount ? info.cacheSkipCount : 0;\n\n var strategies = [this.strategy];\n if (info && info.timestamp + this.ttl >= Util.now()) {\n var transport = this.transports[info.transport];\n if (transport) {\n if (['ws', 'wss'].includes(info.transport) || cacheSkipCount > 3) {\n this.timeline.info({\n cached: true,\n transport: info.transport,\n latency: info.latency\n });\n strategies.push(\n new SequentialStrategy([transport], {\n timeout: info.latency * 2 + 1000,\n failFast: true\n })\n );\n } else {\n cacheSkipCount++;\n }\n }\n }\n\n var startTimestamp = Util.now();\n var runner = strategies\n .pop()\n .connect(minPriority, function cb(error, handshake) {\n if (error) {\n flushTransportCache(usingTLS);\n if (strategies.length > 0) {\n startTimestamp = Util.now();\n runner = strategies.pop().connect(minPriority, cb);\n } else {\n callback(error);\n }\n } else {\n storeTransportCache(\n usingTLS,\n handshake.transport.name,\n Util.now() - startTimestamp,\n cacheSkipCount\n );\n callback(null, handshake);\n }\n });\n\n return {\n abort: function() {\n runner.abort();\n },\n forceMinPriority: function(p) {\n minPriority = p;\n if (runner) {\n runner.forceMinPriority(p);\n }\n }\n };\n }\n}\n\nfunction getTransportCacheKey(usingTLS: boolean): string {\n return 'pusherTransport' + (usingTLS ? 'TLS' : 'NonTLS');\n}\n\nfunction fetchTransportCache(usingTLS: boolean): any {\n var storage = Runtime.getLocalStorage();\n if (storage) {\n try {\n var serializedCache = storage[getTransportCacheKey(usingTLS)];\n if (serializedCache) {\n return JSON.parse(serializedCache);\n }\n } catch (e) {\n flushTransportCache(usingTLS);\n }\n }\n return null;\n}\n\nfunction storeTransportCache(\n usingTLS: boolean,\n transport: TransportStrategy,\n latency: number,\n cacheSkipCount: number\n) {\n var storage = Runtime.getLocalStorage();\n if (storage) {\n try {\n storage[getTransportCacheKey(usingTLS)] = Collections.safeJSONStringify({\n timestamp: Util.now(),\n transport: transport,\n latency: latency,\n cacheSkipCount: cacheSkipCount\n });\n } catch (e) {\n // catch over quota exceptions raised by localStorage\n }\n }\n}\n\nfunction flushTransportCache(usingTLS: boolean) {\n var storage = Runtime.getLocalStorage();\n if (storage) {\n try {\n delete storage[getTransportCacheKey(usingTLS)];\n } catch (e) {\n // catch exceptions raised by localStorage\n }\n }\n}\n","import { OneOffTimer as Timer } from '../utils/timers';\nimport Strategy from './strategy';\nimport StrategyOptions from './strategy_options';\n\n/** Runs substrategy after specified delay.\n *\n * Options:\n * - delay - time in miliseconds to delay the substrategy attempt\n *\n * @param {Strategy} strategy\n * @param {Object} options\n */\nexport default class DelayedStrategy implements Strategy {\n strategy: Strategy;\n options: { delay: number };\n\n constructor(strategy: Strategy, { delay: number }) {\n this.strategy = strategy;\n this.options = { delay: number };\n }\n\n isSupported(): boolean {\n return this.strategy.isSupported();\n }\n\n connect(minPriority: number, callback: Function) {\n var strategy = this.strategy;\n var runner;\n var timer = new Timer(this.options.delay, function() {\n runner = strategy.connect(minPriority, callback);\n });\n\n return {\n abort: function() {\n timer.ensureAborted();\n if (runner) {\n runner.abort();\n }\n },\n forceMinPriority: function(p) {\n minPriority = p;\n if (runner) {\n runner.forceMinPriority(p);\n }\n }\n };\n }\n}\n","import Strategy from './strategy';\nimport StrategyRunner from './strategy_runner';\n\n/** Proxies method calls to one of substrategies basing on the test function.\n *\n * @param {Function} test\n * @param {Strategy} trueBranch strategy used when test returns true\n * @param {Strategy} falseBranch strategy used when test returns false\n */\nexport default class IfStrategy implements Strategy {\n test: () => boolean;\n trueBranch: Strategy;\n falseBranch: Strategy;\n\n constructor(\n test: () => boolean,\n trueBranch: Strategy,\n falseBranch: Strategy\n ) {\n this.test = test;\n this.trueBranch = trueBranch;\n this.falseBranch = falseBranch;\n }\n\n isSupported(): boolean {\n var branch = this.test() ? this.trueBranch : this.falseBranch;\n return branch.isSupported();\n }\n\n connect(minPriority: number, callback: Function): StrategyRunner {\n var branch = this.test() ? this.trueBranch : this.falseBranch;\n return branch.connect(minPriority, callback);\n }\n}\n","import Strategy from './strategy';\nimport StrategyRunner from './strategy_runner';\n\n/** Launches the substrategy and terminates on the first open connection.\n *\n * @param {Strategy} strategy\n */\nexport default class FirstConnectedStrategy implements Strategy {\n strategy: Strategy;\n\n constructor(strategy: Strategy) {\n this.strategy = strategy;\n }\n\n isSupported(): boolean {\n return this.strategy.isSupported();\n }\n\n connect(minPriority: number, callback: Function): StrategyRunner {\n var runner = this.strategy.connect(minPriority, function(error, handshake) {\n if (handshake) {\n runner.abort();\n }\n callback(error, handshake);\n });\n return runner;\n }\n}\n","import * as Collections from 'core/utils/collections';\nimport TransportManager from 'core/transports/transport_manager';\nimport Strategy from 'core/strategies/strategy';\nimport StrategyOptions from 'core/strategies/strategy_options';\nimport SequentialStrategy from 'core/strategies/sequential_strategy';\nimport BestConnectedEverStrategy from 'core/strategies/best_connected_ever_strategy';\nimport WebSocketPrioritizedCachedStrategy, {\n TransportStrategyDictionary\n} from 'core/strategies/websocket_prioritized_cached_strategy';\nimport DelayedStrategy from 'core/strategies/delayed_strategy';\nimport IfStrategy from 'core/strategies/if_strategy';\nimport FirstConnectedStrategy from 'core/strategies/first_connected_strategy';\nimport { Config } from 'core/config';\n\nfunction testSupportsStrategy(strategy: Strategy) {\n return function() {\n return strategy.isSupported();\n };\n}\n\nvar getDefaultStrategy = function(\n config: Config,\n baseOptions: StrategyOptions,\n defineTransport: Function\n): Strategy {\n var definedTransports = {};\n\n function defineTransportStrategy(\n name: string,\n type: string,\n priority: number,\n options: StrategyOptions,\n manager?: TransportManager\n ) {\n var transport = defineTransport(\n config,\n name,\n type,\n priority,\n options,\n manager\n );\n\n definedTransports[name] = transport;\n\n return transport;\n }\n\n var ws_options: StrategyOptions = Object.assign({}, baseOptions, {\n hostNonTLS: config.wsHost + ':' + config.wsPort,\n hostTLS: config.wsHost + ':' + config.wssPort,\n httpPath: config.wsPath\n });\n var wss_options: StrategyOptions = Object.assign({}, ws_options, {\n useTLS: true\n });\n var sockjs_options: StrategyOptions = Object.assign({}, baseOptions, {\n hostNonTLS: config.httpHost + ':' + config.httpPort,\n hostTLS: config.httpHost + ':' + config.httpsPort,\n httpPath: config.httpPath\n });\n\n var timeouts = {\n loop: true,\n timeout: 15000,\n timeoutLimit: 60000\n };\n\n var ws_manager = new TransportManager({\n minPingDelay: 10000,\n maxPingDelay: config.activityTimeout\n });\n var streaming_manager = new TransportManager({\n lives: 2,\n minPingDelay: 10000,\n maxPingDelay: config.activityTimeout\n });\n\n var ws_transport = defineTransportStrategy(\n 'ws',\n 'ws',\n 3,\n ws_options,\n ws_manager\n );\n var wss_transport = defineTransportStrategy(\n 'wss',\n 'ws',\n 3,\n wss_options,\n ws_manager\n );\n var sockjs_transport = defineTransportStrategy(\n 'sockjs',\n 'sockjs',\n 1,\n sockjs_options\n );\n var xhr_streaming_transport = defineTransportStrategy(\n 'xhr_streaming',\n 'xhr_streaming',\n 1,\n sockjs_options,\n streaming_manager\n );\n var xdr_streaming_transport = defineTransportStrategy(\n 'xdr_streaming',\n 'xdr_streaming',\n 1,\n sockjs_options,\n streaming_manager\n );\n var xhr_polling_transport = defineTransportStrategy(\n 'xhr_polling',\n 'xhr_polling',\n 1,\n sockjs_options\n );\n var xdr_polling_transport = defineTransportStrategy(\n 'xdr_polling',\n 'xdr_polling',\n 1,\n sockjs_options\n );\n\n var ws_loop = new SequentialStrategy([ws_transport], timeouts);\n var wss_loop = new SequentialStrategy([wss_transport], timeouts);\n var sockjs_loop = new SequentialStrategy([sockjs_transport], timeouts);\n var streaming_loop = new SequentialStrategy(\n [\n new IfStrategy(\n testSupportsStrategy(xhr_streaming_transport),\n xhr_streaming_transport,\n xdr_streaming_transport\n )\n ],\n timeouts\n );\n var polling_loop = new SequentialStrategy(\n [\n new IfStrategy(\n testSupportsStrategy(xhr_polling_transport),\n xhr_polling_transport,\n xdr_polling_transport\n )\n ],\n timeouts\n );\n\n var http_loop = new SequentialStrategy(\n [\n new IfStrategy(\n testSupportsStrategy(streaming_loop),\n new BestConnectedEverStrategy([\n streaming_loop,\n new DelayedStrategy(polling_loop, { delay: 4000 })\n ]),\n polling_loop\n )\n ],\n timeouts\n );\n\n var http_fallback_loop = new IfStrategy(\n testSupportsStrategy(http_loop),\n http_loop,\n sockjs_loop\n );\n\n var wsStrategy;\n if (baseOptions.useTLS) {\n wsStrategy = new BestConnectedEverStrategy([\n ws_loop,\n new DelayedStrategy(http_fallback_loop, { delay: 2000 })\n ]);\n } else {\n wsStrategy = new BestConnectedEverStrategy([\n ws_loop,\n new DelayedStrategy(wss_loop, { delay: 2000 }),\n new DelayedStrategy(http_fallback_loop, { delay: 5000 })\n ]);\n }\n\n return new WebSocketPrioritizedCachedStrategy(\n new FirstConnectedStrategy(\n new IfStrategy(\n testSupportsStrategy(ws_transport),\n wsStrategy,\n http_fallback_loop\n )\n ),\n definedTransports,\n {\n ttl: 1800000,\n timeline: baseOptions.timeline,\n useTLS: baseOptions.useTLS\n }\n );\n};\n\nexport default getDefaultStrategy;\n","import HTTPRequest from 'core/http/http_request';\nimport RequestHooks from 'core/http/request_hooks';\nimport Ajax from 'core/http/ajax';\nimport * as Errors from 'core/errors';\n\nvar hooks: RequestHooks = {\n getRequest: function(socket: HTTPRequest): Ajax {\n var xdr = new (window).XDomainRequest();\n xdr.ontimeout = function() {\n socket.emit('error', new Errors.RequestTimedOut());\n socket.close();\n };\n xdr.onerror = function(e) {\n socket.emit('error', e);\n socket.close();\n };\n xdr.onprogress = function() {\n if (xdr.responseText && xdr.responseText.length > 0) {\n socket.onChunk(200, xdr.responseText);\n }\n };\n xdr.onload = function() {\n if (xdr.responseText && xdr.responseText.length > 0) {\n socket.onChunk(200, xdr.responseText);\n }\n socket.emit('finished', 200);\n socket.close();\n };\n return xdr;\n },\n abortRequest: function(xdr: Ajax) {\n xdr.ontimeout = xdr.onerror = xdr.onprogress = xdr.onload = null;\n xdr.abort();\n }\n};\n\nexport default hooks;\n","import Runtime from 'runtime';\nimport RequestHooks from './request_hooks';\nimport Ajax from './ajax';\nimport { default as EventsDispatcher } from '../events/dispatcher';\n\nconst MAX_BUFFER_LENGTH = 256 * 1024;\n\nexport default class HTTPRequest extends EventsDispatcher {\n hooks: RequestHooks;\n method: string;\n url: string;\n position: number;\n xhr: Ajax;\n unloader: Function;\n\n constructor(hooks: RequestHooks, method: string, url: string) {\n super();\n this.hooks = hooks;\n this.method = method;\n this.url = url;\n }\n\n start(payload?: any) {\n this.position = 0;\n this.xhr = this.hooks.getRequest(this);\n\n this.unloader = () => {\n this.close();\n };\n Runtime.addUnloadListener(this.unloader);\n\n this.xhr.open(this.method, this.url, true);\n\n if (this.xhr.setRequestHeader) {\n this.xhr.setRequestHeader('Content-Type', 'application/json'); // ReactNative doesn't set this header by default.\n }\n this.xhr.send(payload);\n }\n\n close() {\n if (this.unloader) {\n Runtime.removeUnloadListener(this.unloader);\n this.unloader = null;\n }\n if (this.xhr) {\n this.hooks.abortRequest(this.xhr);\n this.xhr = null;\n }\n }\n\n onChunk(status: number, data: any) {\n while (true) {\n var chunk = this.advanceBuffer(data);\n if (chunk) {\n this.emit('chunk', { status: status, data: chunk });\n } else {\n break;\n }\n }\n if (this.isBufferTooLong(data)) {\n this.emit('buffer_too_long');\n }\n }\n\n private advanceBuffer(buffer: any[]): any {\n var unreadData = buffer.slice(this.position);\n var endOfLinePosition = unreadData.indexOf('\\n');\n\n if (endOfLinePosition !== -1) {\n this.position += endOfLinePosition + 1;\n return unreadData.slice(0, endOfLinePosition);\n } else {\n // chunk is not finished yet, don't move the buffer pointer\n return null;\n }\n }\n\n private isBufferTooLong(buffer: any): boolean {\n return this.position === buffer.length && buffer.length > MAX_BUFFER_LENGTH;\n }\n}\n","enum State {\n CONNECTING = 0,\n OPEN = 1,\n CLOSED = 3\n}\n\nexport default State;\n","import URLLocation from './url_location';\nimport State from './state';\nimport Socket from '../socket';\nimport SocketHooks from './socket_hooks';\nimport Util from '../util';\nimport Ajax from './ajax';\nimport HTTPRequest from './http_request';\nimport Runtime from 'runtime';\n\nvar autoIncrement = 1;\n\nclass HTTPSocket implements Socket {\n hooks: SocketHooks;\n session: string;\n location: URLLocation;\n readyState: State;\n stream: HTTPRequest;\n\n onopen: () => void;\n onerror: (error: any) => void;\n onclose: (closeEvent: any) => void;\n onmessage: (message: any) => void;\n onactivity: () => void;\n\n constructor(hooks: SocketHooks, url: string) {\n this.hooks = hooks;\n this.session = randomNumber(1000) + '/' + randomString(8);\n this.location = getLocation(url);\n this.readyState = State.CONNECTING;\n this.openStream();\n }\n\n send(payload: any) {\n return this.sendRaw(JSON.stringify([payload]));\n }\n\n ping() {\n this.hooks.sendHeartbeat(this);\n }\n\n close(code: any, reason: any) {\n this.onClose(code, reason, true);\n }\n\n /** For internal use only */\n sendRaw(payload: any): boolean {\n if (this.readyState === State.OPEN) {\n try {\n Runtime.createSocketRequest(\n 'POST',\n getUniqueURL(getSendURL(this.location, this.session))\n ).start(payload);\n return true;\n } catch (e) {\n return false;\n }\n } else {\n return false;\n }\n }\n\n /** For internal use only */\n reconnect() {\n this.closeStream();\n this.openStream();\n }\n\n /** For internal use only */\n onClose(code, reason, wasClean) {\n this.closeStream();\n this.readyState = State.CLOSED;\n if (this.onclose) {\n this.onclose({\n code: code,\n reason: reason,\n wasClean: wasClean\n });\n }\n }\n\n private onChunk(chunk) {\n if (chunk.status !== 200) {\n return;\n }\n if (this.readyState === State.OPEN) {\n this.onActivity();\n }\n\n var payload;\n var type = chunk.data.slice(0, 1);\n switch (type) {\n case 'o':\n payload = JSON.parse(chunk.data.slice(1) || '{}');\n this.onOpen(payload);\n break;\n case 'a':\n payload = JSON.parse(chunk.data.slice(1) || '[]');\n for (var i = 0; i < payload.length; i++) {\n this.onEvent(payload[i]);\n }\n break;\n case 'm':\n payload = JSON.parse(chunk.data.slice(1) || 'null');\n this.onEvent(payload);\n break;\n case 'h':\n this.hooks.onHeartbeat(this);\n break;\n case 'c':\n payload = JSON.parse(chunk.data.slice(1) || '[]');\n this.onClose(payload[0], payload[1], true);\n break;\n }\n }\n\n private onOpen(options) {\n if (this.readyState === State.CONNECTING) {\n if (options && options.hostname) {\n this.location.base = replaceHost(this.location.base, options.hostname);\n }\n this.readyState = State.OPEN;\n\n if (this.onopen) {\n this.onopen();\n }\n } else {\n this.onClose(1006, 'Server lost session', true);\n }\n }\n\n private onEvent(event) {\n if (this.readyState === State.OPEN && this.onmessage) {\n this.onmessage({ data: event });\n }\n }\n\n private onActivity() {\n if (this.onactivity) {\n this.onactivity();\n }\n }\n\n private onError(error) {\n if (this.onerror) {\n this.onerror(error);\n }\n }\n\n private openStream() {\n this.stream = Runtime.createSocketRequest(\n 'POST',\n getUniqueURL(this.hooks.getReceiveURL(this.location, this.session))\n );\n\n this.stream.bind('chunk', chunk => {\n this.onChunk(chunk);\n });\n this.stream.bind('finished', status => {\n this.hooks.onFinished(this, status);\n });\n this.stream.bind('buffer_too_long', () => {\n this.reconnect();\n });\n\n try {\n this.stream.start();\n } catch (error) {\n Util.defer(() => {\n this.onError(error);\n this.onClose(1006, 'Could not start streaming', false);\n });\n }\n }\n\n private closeStream() {\n if (this.stream) {\n this.stream.unbind_all();\n this.stream.close();\n this.stream = null;\n }\n }\n}\n\nfunction getLocation(url): URLLocation {\n var parts = /([^\\?]*)\\/*(\\??.*)/.exec(url);\n return {\n base: parts[1],\n queryString: parts[2]\n };\n}\n\nfunction getSendURL(url: URLLocation, session: string): string {\n return url.base + '/' + session + '/xhr_send';\n}\n\nfunction getUniqueURL(url: string): string {\n var separator = url.indexOf('?') === -1 ? '?' : '&';\n return url + separator + 't=' + +new Date() + '&n=' + autoIncrement++;\n}\n\nfunction replaceHost(url: string, hostname: string): string {\n var urlParts = /(https?:\\/\\/)([^\\/:]+)((\\/|:)?.*)/.exec(url);\n return urlParts[1] + hostname + urlParts[3];\n}\n\nfunction randomNumber(max: number): number {\n return Runtime.randomInt(max);\n}\n\nfunction randomString(length: number): string {\n var result = [];\n\n for (var i = 0; i < length; i++) {\n result.push(randomNumber(32).toString(32));\n }\n\n return result.join('');\n}\n\nexport default HTTPSocket;\n","enum TimelineLevel {\n ERROR = 3,\n INFO = 6,\n DEBUG = 7\n}\n\nexport default TimelineLevel;\n","import SocketHooks from './socket_hooks';\nimport HTTPSocket from './http_socket';\n\nvar hooks: SocketHooks = {\n getReceiveURL: function(url, session) {\n return url.base + '/' + session + '/xhr_streaming' + url.queryString;\n },\n onHeartbeat: function(socket) {\n socket.sendRaw('[]');\n },\n sendHeartbeat: function(socket) {\n socket.sendRaw('[]');\n },\n onFinished: function(socket, status) {\n socket.onClose(1006, 'Connection interrupted (' + status + ')', false);\n }\n};\n\nexport default hooks;\n","import SocketHooks from './socket_hooks';\nimport URLLocation from './url_location';\nimport HTTPSocket from './http_socket';\n\nvar hooks: SocketHooks = {\n getReceiveURL: function(url: URLLocation, session: string): string {\n return url.base + '/' + session + '/xhr' + url.queryString;\n },\n onHeartbeat: function() {\n // next HTTP request will reset server's activity timer\n },\n sendHeartbeat: function(socket) {\n socket.sendRaw('[]');\n },\n onFinished: function(socket, status) {\n if (status === 200) {\n socket.reconnect();\n } else {\n socket.onClose(1006, 'Connection interrupted (' + status + ')', false);\n }\n }\n};\n\nexport default hooks;\n","import HTTPRequest from 'core/http/http_request';\nimport RequestHooks from 'core/http/request_hooks';\nimport Ajax from 'core/http/ajax';\nimport Runtime from 'runtime';\n\nvar hooks: RequestHooks = {\n getRequest: function(socket: HTTPRequest): Ajax {\n var Constructor = Runtime.getXHRAPI();\n var xhr = new Constructor();\n xhr.onreadystatechange = xhr.onprogress = function() {\n switch (xhr.readyState) {\n case 3:\n if (xhr.responseText && xhr.responseText.length > 0) {\n socket.onChunk(xhr.status, xhr.responseText);\n }\n break;\n case 4:\n // this happens only on errors, never after calling close\n if (xhr.responseText && xhr.responseText.length > 0) {\n socket.onChunk(xhr.status, xhr.responseText);\n }\n socket.emit('finished', xhr.status);\n socket.close();\n break;\n }\n };\n return xhr;\n },\n abortRequest: function(xhr: Ajax) {\n xhr.onreadystatechange = null;\n xhr.abort();\n }\n};\n\nexport default hooks;\n","import HTTPRequest from 'core/http/http_request';\nimport HTTPSocket from 'core/http/http_socket';\nimport SocketHooks from 'core/http/socket_hooks';\nimport RequestHooks from 'core/http/request_hooks';\nimport streamingHooks from 'core/http/http_streaming_socket';\nimport pollingHooks from 'core/http/http_polling_socket';\nimport xhrHooks from './http_xhr_request';\nimport HTTPFactory from 'core/http/http_factory';\n\nvar HTTP: HTTPFactory = {\n createStreamingSocket(url: string): HTTPSocket {\n return this.createSocket(streamingHooks, url);\n },\n\n createPollingSocket(url: string): HTTPSocket {\n return this.createSocket(pollingHooks, url);\n },\n\n createSocket(hooks: SocketHooks, url: string): HTTPSocket {\n return new HTTPSocket(hooks, url);\n },\n\n createXHR(method: string, url: string): HTTPRequest {\n return this.createRequest(xhrHooks, method, url);\n },\n\n createRequest(hooks: RequestHooks, method: string, url: string): HTTPRequest {\n return new HTTPRequest(hooks, method, url);\n }\n};\n\nexport default HTTP;\n","import xdrHooks from './http_xdomain_request';\nimport HTTP from 'isomorphic/http/http';\n\nHTTP.createXDR = function(method, url) {\n return this.createRequest(xdrHooks, method, url);\n};\n\nexport default HTTP;\n","import Browser from './browser';\nimport { Dependencies, DependenciesReceivers } from './dom/dependencies';\nimport { AuthTransport, AuthTransports } from 'core/auth/auth_transports';\nimport xhrAuth from 'isomorphic/auth/xhr_auth';\nimport jsonpAuth from './auth/jsonp_auth';\nimport TimelineTransport from 'core/timeline/timeline_transport';\nimport TimelineSender from 'core/timeline/timeline_sender';\nimport ScriptRequest from './dom/script_request';\nimport JSONPRequest from './dom/jsonp_request';\nimport * as Collections from 'core/utils/collections';\nimport { ScriptReceivers } from './dom/script_receiver_factory';\nimport jsonpTimeline from './timeline/jsonp_timeline';\nimport Transports from './transports/transports';\nimport Ajax from 'core/http/ajax';\nimport { Network } from './net_info';\nimport getDefaultStrategy from './default_strategy';\nimport transportConnectionInitializer from './transports/transport_connection_initializer';\nimport HTTPFactory from './http/http';\nimport HTTPRequest from 'core/http/http_request';\n\nvar Runtime: Browser = {\n // for jsonp auth\n nextAuthCallbackID: 1,\n auth_callbacks: {},\n ScriptReceivers,\n DependenciesReceivers,\n getDefaultStrategy,\n Transports,\n transportConnectionInitializer,\n HTTPFactory,\n\n TimelineTransport: jsonpTimeline,\n\n getXHRAPI() {\n return window.XMLHttpRequest;\n },\n\n getWebSocketAPI() {\n return window.WebSocket || window.MozWebSocket;\n },\n\n setup(PusherClass): void {\n (window).Pusher = PusherClass; // JSONp requires Pusher to be in the global scope.\n var initializeOnDocumentBody = () => {\n this.onDocumentBody(PusherClass.ready);\n };\n if (!(window).JSON) {\n Dependencies.load('json2', {}, initializeOnDocumentBody);\n } else {\n initializeOnDocumentBody();\n }\n },\n\n getDocument(): Document {\n return document;\n },\n\n getProtocol(): string {\n return this.getDocument().location.protocol;\n },\n\n getAuthorizers(): AuthTransports {\n return { ajax: xhrAuth, jsonp: jsonpAuth };\n },\n\n onDocumentBody(callback: Function) {\n if (document.body) {\n callback();\n } else {\n setTimeout(() => {\n this.onDocumentBody(callback);\n }, 0);\n }\n },\n\n createJSONPRequest(url: string, data: any): JSONPRequest {\n return new JSONPRequest(url, data);\n },\n\n createScriptRequest(src: string): ScriptRequest {\n return new ScriptRequest(src);\n },\n\n getLocalStorage() {\n try {\n return window.localStorage;\n } catch (e) {\n return undefined;\n }\n },\n\n createXHR(): Ajax {\n if (this.getXHRAPI()) {\n return this.createXMLHttpRequest();\n } else {\n return this.createMicrosoftXHR();\n }\n },\n\n createXMLHttpRequest(): Ajax {\n var Constructor = this.getXHRAPI();\n return new Constructor();\n },\n\n createMicrosoftXHR(): Ajax {\n return new ActiveXObject('Microsoft.XMLHTTP');\n },\n\n getNetwork() {\n return Network;\n },\n\n createWebSocket(url: string): any {\n var Constructor = this.getWebSocketAPI();\n return new Constructor(url);\n },\n\n createSocketRequest(method: string, url: string): HTTPRequest {\n if (this.isXHRSupported()) {\n return this.HTTPFactory.createXHR(method, url);\n } else if (this.isXDRSupported(url.indexOf('https:') === 0)) {\n return this.HTTPFactory.createXDR(method, url);\n } else {\n throw 'Cross-origin HTTP requests are not supported';\n }\n },\n\n isXHRSupported(): boolean {\n var Constructor = this.getXHRAPI();\n return (\n Boolean(Constructor) && new Constructor().withCredentials !== undefined\n );\n },\n\n isXDRSupported(useTLS?: boolean): boolean {\n var protocol = useTLS ? 'https:' : 'http:';\n var documentProtocol = this.getProtocol();\n return (\n Boolean(window['XDomainRequest']) && documentProtocol === protocol\n );\n },\n\n addUnloadListener(listener: any) {\n if (window.addEventListener !== undefined) {\n window.addEventListener('unload', listener, false);\n } else if (window.attachEvent !== undefined) {\n window.attachEvent('onunload', listener);\n }\n },\n\n removeUnloadListener(listener: any) {\n if (window.addEventListener !== undefined) {\n window.removeEventListener('unload', listener, false);\n } else if (window.detachEvent !== undefined) {\n window.detachEvent('onunload', listener);\n }\n },\n\n randomInt(max: number): number {\n /**\n * Return values in the range of [0, 1[\n */\n const random = function() {\n const crypto = window.crypto || window['msCrypto'];\n const random = crypto.getRandomValues(new Uint32Array(1))[0];\n\n return random / 2 ** 32;\n };\n\n return Math.floor(random() * max);\n }\n};\n\nexport default Runtime;\n","import { Dependencies } from '../dom/dependencies';\n\n/** Initializes the transport.\n *\n * Fetches resources if needed and then transitions to initialized.\n */\nexport default function() {\n var self = this;\n\n self.timeline.info(\n self.buildTimelineMessage({\n transport: self.name + (self.options.useTLS ? 's' : '')\n })\n );\n\n if (self.hooks.isInitialized()) {\n self.changeState('initialized');\n } else if (self.hooks.file) {\n self.changeState('initializing');\n Dependencies.load(\n self.hooks.file,\n { useTLS: self.options.useTLS },\n function(error, callback) {\n if (self.hooks.isInitialized()) {\n self.changeState('initialized');\n callback(true);\n } else {\n if (error) {\n self.onError(error);\n }\n self.onClose();\n callback(false);\n }\n }\n );\n } else {\n self.onClose();\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport { default as Level } from './level';\n\nexport interface TimelineOptions {\n level?: Level;\n limit?: number;\n version?: string;\n cluster?: string;\n features?: string[];\n params?: any;\n}\n\nexport default class Timeline {\n key: string;\n session: number;\n events: any[];\n options: TimelineOptions;\n sent: number;\n uniqueID: number;\n\n constructor(key: string, session: number, options: TimelineOptions) {\n this.key = key;\n this.session = session;\n this.events = [];\n this.options = options || {};\n this.sent = 0;\n this.uniqueID = 0;\n }\n\n log(level, event) {\n if (level <= this.options.level) {\n this.events.push(\n Collections.extend({}, event, { timestamp: Util.now() })\n );\n if (this.options.limit && this.events.length > this.options.limit) {\n this.events.shift();\n }\n }\n }\n\n error(event) {\n this.log(Level.ERROR, event);\n }\n\n info(event) {\n this.log(Level.INFO, event);\n }\n\n debug(event) {\n this.log(Level.DEBUG, event);\n }\n\n isEmpty() {\n return this.events.length === 0;\n }\n\n send(sendfn, callback) {\n var data = Collections.extend(\n {\n session: this.session,\n bundle: this.sent + 1,\n key: this.key,\n lib: 'js',\n version: this.options.version,\n cluster: this.options.cluster,\n features: this.options.features,\n timeline: this.events\n },\n this.options.params\n );\n\n this.events = [];\n sendfn(data, (error, result) => {\n if (!error) {\n this.sent++;\n }\n if (callback) {\n callback(error, result);\n }\n });\n\n return true;\n }\n\n generateUniqueID(): number {\n this.uniqueID++;\n return this.uniqueID;\n }\n}\n","import Factory from '../utils/factory';\nimport Util from '../util';\nimport * as Errors from '../errors';\nimport * as Collections from '../utils/collections';\nimport Strategy from './strategy';\nimport Transport from '../transports/transport';\nimport StrategyOptions from './strategy_options';\nimport Handshake from '../connection/handshake';\n\n/** Provides a strategy interface for transports.\n *\n * @param {String} name\n * @param {Number} priority\n * @param {Class} transport\n * @param {Object} options\n */\nexport default class TransportStrategy implements Strategy {\n name: string;\n priority: number;\n transport: Transport;\n options: StrategyOptions;\n\n constructor(\n name: string,\n priority: number,\n transport: Transport,\n options: StrategyOptions\n ) {\n this.name = name;\n this.priority = priority;\n this.transport = transport;\n this.options = options || {};\n }\n\n /** Returns whether the transport is supported in the browser.\n *\n * @returns {Boolean}\n */\n isSupported(): boolean {\n return this.transport.isSupported({\n useTLS: this.options.useTLS\n });\n }\n\n /** Launches a connection attempt and returns a strategy runner.\n *\n * @param {Function} callback\n * @return {Object} strategy runner\n */\n connect(minPriority: number, callback: Function) {\n if (!this.isSupported()) {\n return failAttempt(new Errors.UnsupportedStrategy(), callback);\n } else if (this.priority < minPriority) {\n return failAttempt(new Errors.TransportPriorityTooLow(), callback);\n }\n\n var connected = false;\n var transport = this.transport.createConnection(\n this.name,\n this.priority,\n this.options.key,\n this.options\n );\n var handshake = null;\n\n var onInitialized = function() {\n transport.unbind('initialized', onInitialized);\n transport.connect();\n };\n var onOpen = function() {\n handshake = Factory.createHandshake(transport, function(result) {\n connected = true;\n unbindListeners();\n callback(null, result);\n });\n };\n var onError = function(error) {\n unbindListeners();\n callback(error);\n };\n var onClosed = function() {\n unbindListeners();\n var serializedTransport;\n\n // The reason for this try/catch block is that on React Native\n // the WebSocket object is circular. Therefore transport.socket will\n // throw errors upon stringification. Collections.safeJSONStringify\n // discards circular references when serializing.\n serializedTransport = Collections.safeJSONStringify(transport);\n callback(new Errors.TransportClosed(serializedTransport));\n };\n\n var unbindListeners = function() {\n transport.unbind('initialized', onInitialized);\n transport.unbind('open', onOpen);\n transport.unbind('error', onError);\n transport.unbind('closed', onClosed);\n };\n\n transport.bind('initialized', onInitialized);\n transport.bind('open', onOpen);\n transport.bind('error', onError);\n transport.bind('closed', onClosed);\n\n // connect will be called automatically after initialization\n transport.initialize();\n\n return {\n abort: () => {\n if (connected) {\n return;\n }\n unbindListeners();\n if (handshake) {\n handshake.close();\n } else {\n transport.close();\n }\n },\n forceMinPriority: p => {\n if (connected) {\n return;\n }\n if (this.priority < p) {\n if (handshake) {\n handshake.close();\n } else {\n transport.close();\n }\n }\n }\n };\n }\n}\n\nfunction failAttempt(error: Error, callback: Function) {\n Util.defer(function() {\n callback(error);\n });\n return {\n abort: function() {},\n forceMinPriority: function() {}\n };\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport TransportManager from '../transports/transport_manager';\nimport * as Errors from '../errors';\nimport Strategy from './strategy';\nimport TransportStrategy from './transport_strategy';\nimport StrategyOptions from '../strategies/strategy_options';\nimport { Config } from '../config';\nimport Runtime from 'runtime';\n\nconst { Transports } = Runtime;\n\nexport var defineTransport = function(\n config: Config,\n name: string,\n type: string,\n priority: number,\n options: StrategyOptions,\n manager?: TransportManager\n): Strategy {\n var transportClass = Transports[type];\n if (!transportClass) {\n throw new Errors.UnsupportedTransport(type);\n }\n\n var enabled =\n (!config.enabledTransports ||\n Collections.arrayIndexOf(config.enabledTransports, name) !== -1) &&\n (!config.disabledTransports ||\n Collections.arrayIndexOf(config.disabledTransports, name) === -1);\n\n var transport;\n if (enabled) {\n options = Object.assign(\n { ignoreNullOrigin: config.ignoreNullOrigin },\n options\n );\n\n transport = new TransportStrategy(\n name,\n priority,\n manager ? manager.getAssistant(transportClass) : transportClass,\n options\n );\n } else {\n transport = UnsupportedStrategy;\n }\n\n return transport;\n};\n\nvar UnsupportedStrategy: Strategy = {\n isSupported: function() {\n return false;\n },\n connect: function(_, callback) {\n var deferred = Util.defer(function() {\n callback(new Errors.UnsupportedStrategy());\n });\n return {\n abort: function() {\n deferred.ensureAborted();\n },\n forceMinPriority: function() {}\n };\n }\n};\n","import ConnectionManager from './connection/connection_manager';\nimport {\n ChannelAuthorizationOptions,\n UserAuthenticationOptions\n} from './auth/options';\nimport {\n ChannelAuthorizerGenerator,\n DeprecatedAuthOptions\n} from './auth/deprecated_channel_authorizer';\nimport { AuthTransport, Transport } from './config';\nimport * as nacl from 'tweetnacl';\nimport Logger from './logger';\n\nexport interface Options {\n activityTimeout?: number;\n\n auth?: DeprecatedAuthOptions; // DEPRECATED use channelAuthorization instead\n authEndpoint?: string; // DEPRECATED use channelAuthorization instead\n authTransport?: AuthTransport; // DEPRECATED use channelAuthorization instead\n authorizer?: ChannelAuthorizerGenerator; // DEPRECATED use channelAuthorization instead\n\n channelAuthorization?: ChannelAuthorizationOptions;\n userAuthentication?: UserAuthenticationOptions;\n\n cluster: string;\n enableStats?: boolean;\n disableStats?: boolean;\n disabledTransports?: Transport[];\n enabledTransports?: Transport[];\n forceTLS?: boolean;\n httpHost?: string;\n httpPath?: string;\n httpPort?: number;\n httpsPort?: number;\n ignoreNullOrigin?: boolean;\n nacl?: nacl;\n pongTimeout?: number;\n statsHost?: string;\n timelineParams?: any;\n unavailableTimeout?: number;\n wsHost?: string;\n wsPath?: string;\n wsPort?: number;\n wssPort?: number;\n}\n\nexport function validateOptions(options) {\n if (options == null) {\n throw 'You must pass an options object';\n }\n if (options.cluster == null) {\n throw 'Options object must provide a cluster';\n }\n if ('disableStats' in options) {\n Logger.warn(\n 'The disableStats option is deprecated in favor of enableStats'\n );\n }\n}\n","import {\n UserAuthenticationCallback,\n InternalAuthOptions,\n UserAuthenticationHandler,\n UserAuthenticationRequestParams,\n AuthRequestType\n} from './options';\n\nimport Runtime from 'runtime';\n\nconst composeChannelQuery = (\n params: UserAuthenticationRequestParams,\n authOptions: InternalAuthOptions\n) => {\n var query = 'socket_id=' + encodeURIComponent(params.socketId);\n\n for (var key in authOptions.params) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(authOptions.params[key]);\n }\n\n if (authOptions.paramsProvider != null) {\n let dynamicParams = authOptions.paramsProvider();\n for (var key in dynamicParams) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(dynamicParams[key]);\n }\n }\n\n return query;\n};\n\nconst UserAuthenticator = (\n authOptions: InternalAuthOptions\n): UserAuthenticationHandler => {\n if (typeof Runtime.getAuthorizers()[authOptions.transport] === 'undefined') {\n throw `'${authOptions.transport}' is not a recognized auth transport`;\n }\n\n return (\n params: UserAuthenticationRequestParams,\n callback: UserAuthenticationCallback\n ) => {\n const query = composeChannelQuery(params, authOptions);\n\n Runtime.getAuthorizers()[authOptions.transport](\n Runtime,\n query,\n authOptions,\n AuthRequestType.UserAuthentication,\n callback\n );\n };\n};\n\nexport default UserAuthenticator;\n","import {\n AuthRequestType,\n InternalAuthOptions,\n ChannelAuthorizationHandler,\n ChannelAuthorizationRequestParams,\n ChannelAuthorizationCallback\n} from './options';\n\nimport Runtime from 'runtime';\n\nconst composeChannelQuery = (\n params: ChannelAuthorizationRequestParams,\n authOptions: InternalAuthOptions\n) => {\n var query = 'socket_id=' + encodeURIComponent(params.socketId);\n\n query += '&channel_name=' + encodeURIComponent(params.channelName);\n\n for (var key in authOptions.params) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(authOptions.params[key]);\n }\n\n if (authOptions.paramsProvider != null) {\n let dynamicParams = authOptions.paramsProvider();\n for (var key in dynamicParams) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(dynamicParams[key]);\n }\n }\n\n return query;\n};\n\nconst ChannelAuthorizer = (\n authOptions: InternalAuthOptions\n): ChannelAuthorizationHandler => {\n if (typeof Runtime.getAuthorizers()[authOptions.transport] === 'undefined') {\n throw `'${authOptions.transport}' is not a recognized auth transport`;\n }\n\n return (\n params: ChannelAuthorizationRequestParams,\n callback: ChannelAuthorizationCallback\n ) => {\n const query = composeChannelQuery(params, authOptions);\n\n Runtime.getAuthorizers()[authOptions.transport](\n Runtime,\n query,\n authOptions,\n AuthRequestType.ChannelAuthorization,\n callback\n );\n };\n};\n\nexport default ChannelAuthorizer;\n","import { Options } from './options';\nimport Defaults from './defaults';\nimport {\n ChannelAuthorizationHandler,\n UserAuthenticationHandler,\n ChannelAuthorizationOptions\n} from './auth/options';\nimport UserAuthenticator from './auth/user_authenticator';\nimport ChannelAuthorizer from './auth/channel_authorizer';\nimport { ChannelAuthorizerProxy } from './auth/deprecated_channel_authorizer';\nimport Runtime from 'runtime';\nimport * as nacl from 'tweetnacl';\n\nexport type AuthTransport = 'ajax' | 'jsonp';\nexport type Transport =\n | 'ws'\n | 'wss'\n | 'xhr_streaming'\n | 'xhr_polling'\n | 'sockjs';\n\nexport interface Config {\n // these are all 'required' config parameters, it's not necessary for the user\n // to set them, but they have configured defaults.\n activityTimeout: number;\n enableStats: boolean;\n httpHost: string;\n httpPath: string;\n httpPort: number;\n httpsPort: number;\n pongTimeout: number;\n statsHost: string;\n unavailableTimeout: number;\n useTLS: boolean;\n wsHost: string;\n wsPath: string;\n wsPort: number;\n wssPort: number;\n userAuthenticator: UserAuthenticationHandler;\n channelAuthorizer: ChannelAuthorizationHandler;\n\n // these are all optional parameters or overrrides. The customer can set these\n // but it's not strictly necessary\n forceTLS?: boolean;\n cluster?: string;\n disabledTransports?: Transport[];\n enabledTransports?: Transport[];\n ignoreNullOrigin?: boolean;\n nacl?: nacl;\n timelineParams?: any;\n}\n\n// getConfig mainly sets the defaults for the options that are not provided\nexport function getConfig(opts: Options, pusher): Config {\n let config: Config = {\n activityTimeout: opts.activityTimeout || Defaults.activityTimeout,\n cluster: opts.cluster,\n httpPath: opts.httpPath || Defaults.httpPath,\n httpPort: opts.httpPort || Defaults.httpPort,\n httpsPort: opts.httpsPort || Defaults.httpsPort,\n pongTimeout: opts.pongTimeout || Defaults.pongTimeout,\n statsHost: opts.statsHost || Defaults.stats_host,\n unavailableTimeout: opts.unavailableTimeout || Defaults.unavailableTimeout,\n wsPath: opts.wsPath || Defaults.wsPath,\n wsPort: opts.wsPort || Defaults.wsPort,\n wssPort: opts.wssPort || Defaults.wssPort,\n\n enableStats: getEnableStatsConfig(opts),\n httpHost: getHttpHost(opts),\n useTLS: shouldUseTLS(opts),\n wsHost: getWebsocketHost(opts),\n\n userAuthenticator: buildUserAuthenticator(opts),\n channelAuthorizer: buildChannelAuthorizer(opts, pusher)\n };\n\n if ('disabledTransports' in opts)\n config.disabledTransports = opts.disabledTransports;\n if ('enabledTransports' in opts)\n config.enabledTransports = opts.enabledTransports;\n if ('ignoreNullOrigin' in opts)\n config.ignoreNullOrigin = opts.ignoreNullOrigin;\n if ('timelineParams' in opts) config.timelineParams = opts.timelineParams;\n if ('nacl' in opts) {\n config.nacl = opts.nacl;\n }\n\n return config;\n}\n\nfunction getHttpHost(opts: Options): string {\n if (opts.httpHost) {\n return opts.httpHost;\n }\n if (opts.cluster) {\n return `sockjs-${opts.cluster}.pusher.com`;\n }\n return Defaults.httpHost;\n}\n\nfunction getWebsocketHost(opts: Options): string {\n if (opts.wsHost) {\n return opts.wsHost;\n }\n return getWebsocketHostFromCluster(opts.cluster);\n}\n\nfunction getWebsocketHostFromCluster(cluster: string): string {\n return `ws-${cluster}.pusher.com`;\n}\n\nfunction shouldUseTLS(opts: Options): boolean {\n if (Runtime.getProtocol() === 'https:') {\n return true;\n } else if (opts.forceTLS === false) {\n return false;\n }\n return true;\n}\n\n// if enableStats is set take the value\n// if disableStats is set take the inverse\n// otherwise default to false\nfunction getEnableStatsConfig(opts: Options): boolean {\n if ('enableStats' in opts) {\n return opts.enableStats;\n }\n if ('disableStats' in opts) {\n return !opts.disableStats;\n }\n return false;\n}\n\nfunction buildUserAuthenticator(opts: Options): UserAuthenticationHandler {\n const userAuthentication = {\n ...Defaults.userAuthentication,\n ...opts.userAuthentication\n };\n if (\n 'customHandler' in userAuthentication &&\n userAuthentication['customHandler'] != null\n ) {\n return userAuthentication['customHandler'];\n }\n\n return UserAuthenticator(userAuthentication);\n}\n\nfunction buildChannelAuth(opts: Options, pusher): ChannelAuthorizationOptions {\n let channelAuthorization: ChannelAuthorizationOptions;\n if ('channelAuthorization' in opts) {\n channelAuthorization = {\n ...Defaults.channelAuthorization,\n ...opts.channelAuthorization\n };\n } else {\n channelAuthorization = {\n transport: opts.authTransport || Defaults.authTransport,\n endpoint: opts.authEndpoint || Defaults.authEndpoint\n };\n if ('auth' in opts) {\n if ('params' in opts.auth) channelAuthorization.params = opts.auth.params;\n if ('headers' in opts.auth)\n channelAuthorization.headers = opts.auth.headers;\n }\n if ('authorizer' in opts)\n channelAuthorization.customHandler = ChannelAuthorizerProxy(\n pusher,\n channelAuthorization,\n opts.authorizer\n );\n }\n return channelAuthorization;\n}\n\nfunction buildChannelAuthorizer(\n opts: Options,\n pusher\n): ChannelAuthorizationHandler {\n const channelAuthorization = buildChannelAuth(opts, pusher);\n if (\n 'customHandler' in channelAuthorization &&\n channelAuthorization['customHandler'] != null\n ) {\n return channelAuthorization['customHandler'];\n }\n\n return ChannelAuthorizer(channelAuthorization);\n}\n","import Channel from '../channels/channel';\nimport {\n ChannelAuthorizationCallback,\n ChannelAuthorizationHandler,\n ChannelAuthorizationRequestParams,\n InternalAuthOptions\n} from './options';\n\nexport interface DeprecatedChannelAuthorizer {\n authorize(socketId: string, callback: ChannelAuthorizationCallback): void;\n}\n\nexport interface ChannelAuthorizerGenerator {\n (\n channel: Channel,\n options: DeprecatedAuthorizerOptions\n ): DeprecatedChannelAuthorizer;\n}\n\nexport interface DeprecatedAuthOptions {\n params?: any;\n headers?: any;\n}\n\nexport interface DeprecatedAuthorizerOptions {\n authTransport: 'ajax' | 'jsonp';\n authEndpoint: string;\n auth?: DeprecatedAuthOptions;\n}\n\nexport const ChannelAuthorizerProxy = (\n pusher,\n authOptions: InternalAuthOptions,\n channelAuthorizerGenerator: ChannelAuthorizerGenerator\n): ChannelAuthorizationHandler => {\n const deprecatedAuthorizerOptions: DeprecatedAuthorizerOptions = {\n authTransport: authOptions.transport,\n authEndpoint: authOptions.endpoint,\n auth: {\n params: authOptions.params,\n headers: authOptions.headers\n }\n };\n return (\n params: ChannelAuthorizationRequestParams,\n callback: ChannelAuthorizationCallback\n ) => {\n const channel = pusher.channel(params.channelName);\n // This line creates a new channel authorizer every time.\n // In the past, this was only done once per channel and reused.\n // We can do that again if we want to keep this behavior intact.\n const channelAuthorizer: DeprecatedChannelAuthorizer = channelAuthorizerGenerator(\n channel,\n deprecatedAuthorizerOptions\n );\n channelAuthorizer.authorize(params.socketId, callback);\n };\n};\n","import Logger from './logger';\nimport Pusher from './pusher';\nimport EventsDispatcher from './events/dispatcher';\n\nexport default class WatchlistFacade extends EventsDispatcher {\n private pusher: Pusher;\n\n public constructor(pusher: Pusher) {\n super(function(eventName, data) {\n Logger.debug(`No callbacks on watchlist events for ${eventName}`);\n });\n\n this.pusher = pusher;\n this.bindWatchlistInternalEvent();\n }\n\n handleEvent(pusherEvent) {\n pusherEvent.data.events.forEach(watchlistEvent => {\n this.emit(watchlistEvent.name, watchlistEvent);\n });\n }\n\n private bindWatchlistInternalEvent() {\n this.pusher.connection.bind('message', pusherEvent => {\n var eventName = pusherEvent.event;\n if (eventName === 'pusher_internal:watchlist_events') {\n this.handleEvent(pusherEvent);\n }\n });\n }\n}\n","function flatPromise() {\n let resolve, reject;\n const promise = new Promise((res, rej) => {\n resolve = res;\n reject = rej;\n });\n return { promise, resolve, reject };\n}\n\nexport default flatPromise;\n","import Pusher from './pusher';\nimport Logger from './logger';\nimport {\n UserAuthenticationData,\n UserAuthenticationCallback\n} from './auth/options';\nimport Channel from './channels/channel';\nimport WatchlistFacade from './watchlist';\nimport EventsDispatcher from './events/dispatcher';\nimport flatPromise from './utils/flat_promise';\n\nexport default class UserFacade extends EventsDispatcher {\n pusher: Pusher;\n signin_requested: boolean = false;\n user_data: any = null;\n serverToUserChannel: Channel = null;\n signinDonePromise: Promise = null;\n watchlist: WatchlistFacade;\n private _signinDoneResolve: Function = null;\n\n public constructor(pusher: Pusher) {\n super(function(eventName, data) {\n Logger.debug('No callbacks on user for ' + eventName);\n });\n this.pusher = pusher;\n this.pusher.connection.bind('state_change', ({ previous, current }) => {\n if (previous !== 'connected' && current === 'connected') {\n this._signin();\n }\n if (previous === 'connected' && current !== 'connected') {\n this._cleanup();\n this._newSigninPromiseIfNeeded();\n }\n });\n\n this.watchlist = new WatchlistFacade(pusher);\n\n this.pusher.connection.bind('message', event => {\n var eventName = event.event;\n if (eventName === 'pusher:signin_success') {\n this._onSigninSuccess(event.data);\n }\n if (\n this.serverToUserChannel &&\n this.serverToUserChannel.name === event.channel\n ) {\n this.serverToUserChannel.handleEvent(event);\n }\n });\n }\n\n public signin() {\n if (this.signin_requested) {\n return;\n }\n\n this.signin_requested = true;\n this._signin();\n }\n\n private _signin() {\n if (!this.signin_requested) {\n return;\n }\n\n this._newSigninPromiseIfNeeded();\n\n if (this.pusher.connection.state !== 'connected') {\n // Signin will be attempted when the connection is connected\n return;\n }\n\n this.pusher.config.userAuthenticator(\n {\n socketId: this.pusher.connection.socket_id\n },\n this._onAuthorize\n );\n }\n\n private _onAuthorize: UserAuthenticationCallback = (\n err,\n authData: UserAuthenticationData\n ) => {\n if (err) {\n Logger.warn(`Error during signin: ${err}`);\n this._cleanup();\n return;\n }\n\n this.pusher.send_event('pusher:signin', {\n auth: authData.auth,\n user_data: authData.user_data\n });\n\n // Later when we get pusher:singin_success event, the user will be marked as signed in\n };\n\n private _onSigninSuccess(data: any) {\n try {\n this.user_data = JSON.parse(data.user_data);\n } catch (e) {\n Logger.error(`Failed parsing user data after signin: ${data.user_data}`);\n this._cleanup();\n return;\n }\n\n if (typeof this.user_data.id !== 'string' || this.user_data.id === '') {\n Logger.error(\n `user_data doesn't contain an id. user_data: ${this.user_data}`\n );\n this._cleanup();\n return;\n }\n\n // Signin succeeded\n this._signinDoneResolve();\n this._subscribeChannels();\n }\n\n private _subscribeChannels() {\n const ensure_subscribed = channel => {\n if (channel.subscriptionPending && channel.subscriptionCancelled) {\n channel.reinstateSubscription();\n } else if (\n !channel.subscriptionPending &&\n this.pusher.connection.state === 'connected'\n ) {\n channel.subscribe();\n }\n };\n\n this.serverToUserChannel = new Channel(\n `#server-to-user-${this.user_data.id}`,\n this.pusher\n );\n this.serverToUserChannel.bind_global((eventName, data) => {\n if (\n eventName.indexOf('pusher_internal:') === 0 ||\n eventName.indexOf('pusher:') === 0\n ) {\n // ignore internal events\n return;\n }\n this.emit(eventName, data);\n });\n ensure_subscribed(this.serverToUserChannel);\n }\n\n private _cleanup() {\n this.user_data = null;\n if (this.serverToUserChannel) {\n this.serverToUserChannel.unbind_all();\n this.serverToUserChannel.disconnect();\n this.serverToUserChannel = null;\n }\n\n if (this.signin_requested) {\n // If signin is in progress and cleanup is called,\n // Mark the current signin process as done.\n this._signinDoneResolve();\n }\n }\n\n private _newSigninPromiseIfNeeded() {\n if (!this.signin_requested) {\n return;\n }\n\n // If there is a promise and it is not resolved, return without creating a new one.\n if (this.signinDonePromise && !(this.signinDonePromise as any).done) {\n return;\n }\n\n // This promise is never rejected.\n // It gets resolved when the signin process is done whether it failed or succeeded\n const { promise, resolve, reject: _ } = flatPromise();\n (promise as any).done = false;\n const setDone = () => {\n (promise as any).done = true;\n };\n promise.then(setDone).catch(setDone);\n this.signinDonePromise = promise;\n this._signinDoneResolve = resolve;\n }\n}\n","import AbstractRuntime from '../runtimes/interface';\nimport Runtime from 'runtime';\nimport Util from './util';\nimport * as Collections from './utils/collections';\nimport Channels from './channels/channels';\nimport Channel from './channels/channel';\nimport { default as EventsDispatcher } from './events/dispatcher';\nimport Timeline from './timeline/timeline';\nimport TimelineSender from './timeline/timeline_sender';\nimport TimelineLevel from './timeline/level';\nimport { defineTransport } from './strategies/strategy_builder';\nimport ConnectionManager from './connection/connection_manager';\nimport ConnectionManagerOptions from './connection/connection_manager_options';\nimport { PeriodicTimer } from './utils/timers';\nimport Defaults from './defaults';\nimport * as DefaultConfig from './config';\nimport Logger from './logger';\nimport Factory from './utils/factory';\nimport UrlStore from 'core/utils/url_store';\nimport { Options, validateOptions } from './options';\nimport { Config, getConfig } from './config';\nimport StrategyOptions from './strategies/strategy_options';\nimport UserFacade from './user';\n\nexport default class Pusher {\n /* STATIC PROPERTIES */\n static instances: Pusher[] = [];\n static isReady: boolean = false;\n static logToConsole: boolean = false;\n\n // for jsonp\n static Runtime: AbstractRuntime = Runtime;\n static ScriptReceivers: any = (Runtime).ScriptReceivers;\n static DependenciesReceivers: any = (Runtime).DependenciesReceivers;\n static auth_callbacks: any = (Runtime).auth_callbacks;\n\n static ready() {\n Pusher.isReady = true;\n for (var i = 0, l = Pusher.instances.length; i < l; i++) {\n Pusher.instances[i].connect();\n }\n }\n\n static log: (message: any) => void;\n\n private static getClientFeatures(): string[] {\n return Collections.keys(\n Collections.filterObject({ ws: Runtime.Transports.ws }, function(t) {\n return t.isSupported({});\n })\n );\n }\n\n /* INSTANCE PROPERTIES */\n key: string;\n config: Config;\n channels: Channels;\n global_emitter: EventsDispatcher;\n sessionID: number;\n timeline: Timeline;\n timelineSender: TimelineSender;\n connection: ConnectionManager;\n timelineSenderTimer: PeriodicTimer;\n user: UserFacade;\n constructor(app_key: string, options: Options) {\n checkAppKey(app_key);\n validateOptions(options);\n this.key = app_key;\n this.config = getConfig(options, this);\n\n this.channels = Factory.createChannels();\n this.global_emitter = new EventsDispatcher();\n this.sessionID = Runtime.randomInt(1000000000);\n\n this.timeline = new Timeline(this.key, this.sessionID, {\n cluster: this.config.cluster,\n features: Pusher.getClientFeatures(),\n params: this.config.timelineParams || {},\n limit: 50,\n level: TimelineLevel.INFO,\n version: Defaults.VERSION\n });\n if (this.config.enableStats) {\n this.timelineSender = Factory.createTimelineSender(this.timeline, {\n host: this.config.statsHost,\n path: '/timeline/v2/' + Runtime.TimelineTransport.name\n });\n }\n\n var getStrategy = (options: StrategyOptions) => {\n return Runtime.getDefaultStrategy(this.config, options, defineTransport);\n };\n\n this.connection = Factory.createConnectionManager(this.key, {\n getStrategy: getStrategy,\n timeline: this.timeline,\n activityTimeout: this.config.activityTimeout,\n pongTimeout: this.config.pongTimeout,\n unavailableTimeout: this.config.unavailableTimeout,\n useTLS: Boolean(this.config.useTLS)\n });\n\n this.connection.bind('connected', () => {\n this.subscribeAll();\n if (this.timelineSender) {\n this.timelineSender.send(this.connection.isUsingTLS());\n }\n });\n\n this.connection.bind('message', event => {\n var eventName = event.event;\n var internal = eventName.indexOf('pusher_internal:') === 0;\n if (event.channel) {\n var channel = this.channel(event.channel);\n if (channel) {\n channel.handleEvent(event);\n }\n }\n // Emit globally [deprecated]\n if (!internal) {\n this.global_emitter.emit(event.event, event.data);\n }\n });\n this.connection.bind('connecting', () => {\n this.channels.disconnect();\n });\n this.connection.bind('disconnected', () => {\n this.channels.disconnect();\n });\n this.connection.bind('error', err => {\n Logger.warn(err);\n });\n\n Pusher.instances.push(this);\n this.timeline.info({ instances: Pusher.instances.length });\n\n this.user = new UserFacade(this);\n\n if (Pusher.isReady) {\n this.connect();\n }\n }\n\n channel(name: string): Channel {\n return this.channels.find(name);\n }\n\n allChannels(): Channel[] {\n return this.channels.all();\n }\n\n connect() {\n this.connection.connect();\n\n if (this.timelineSender) {\n if (!this.timelineSenderTimer) {\n var usingTLS = this.connection.isUsingTLS();\n var timelineSender = this.timelineSender;\n this.timelineSenderTimer = new PeriodicTimer(60000, function() {\n timelineSender.send(usingTLS);\n });\n }\n }\n }\n\n disconnect() {\n this.connection.disconnect();\n\n if (this.timelineSenderTimer) {\n this.timelineSenderTimer.ensureAborted();\n this.timelineSenderTimer = null;\n }\n }\n\n bind(event_name: string, callback: Function, context?: any): Pusher {\n this.global_emitter.bind(event_name, callback, context);\n return this;\n }\n\n unbind(event_name?: string, callback?: Function, context?: any): Pusher {\n this.global_emitter.unbind(event_name, callback, context);\n return this;\n }\n\n bind_global(callback: Function): Pusher {\n this.global_emitter.bind_global(callback);\n return this;\n }\n\n unbind_global(callback?: Function): Pusher {\n this.global_emitter.unbind_global(callback);\n return this;\n }\n\n unbind_all(callback?: Function): Pusher {\n this.global_emitter.unbind_all();\n return this;\n }\n\n subscribeAll() {\n var channelName;\n for (channelName in this.channels.channels) {\n if (this.channels.channels.hasOwnProperty(channelName)) {\n this.subscribe(channelName);\n }\n }\n }\n\n subscribe(channel_name: string) {\n var channel = this.channels.add(channel_name, this);\n if (channel.subscriptionPending && channel.subscriptionCancelled) {\n channel.reinstateSubscription();\n } else if (\n !channel.subscriptionPending &&\n this.connection.state === 'connected'\n ) {\n channel.subscribe();\n }\n return channel;\n }\n\n unsubscribe(channel_name: string) {\n var channel = this.channels.find(channel_name);\n if (channel && channel.subscriptionPending) {\n channel.cancelSubscription();\n } else {\n channel = this.channels.remove(channel_name);\n if (channel && channel.subscribed) {\n channel.unsubscribe();\n }\n }\n }\n\n send_event(event_name: string, data: any, channel?: string) {\n return this.connection.send_event(event_name, data, channel);\n }\n\n shouldUseTLS(): boolean {\n return this.config.useTLS;\n }\n\n signin() {\n this.user.signin();\n }\n}\n\nfunction checkAppKey(key) {\n if (key === null || key === undefined) {\n throw 'You must pass your app key when you instantiate Pusher.';\n }\n}\n\nRuntime.setup(Pusher);\n","import Pusher from './pusher';\nimport { Options, validateOptions } from './options';\nimport * as nacl from 'tweetnacl';\n\nexport default class PusherWithEncryption extends Pusher {\n constructor(app_key: string, options: Options) {\n Pusher.logToConsole = PusherWithEncryption.logToConsole;\n Pusher.log = PusherWithEncryption.log;\n\n validateOptions(options);\n options.nacl = nacl;\n super(app_key, options);\n }\n}\n"],"sourceRoot":""} \ No newline at end of file +{"version":3,"sources":["webpack://Pusher/webpack/universalModuleDefinition","webpack://Pusher/webpack/bootstrap","webpack://Pusher/./node_modules/@stablelib/base64/base64.ts","webpack://Pusher/./node_modules/@stablelib/utf8/utf8.ts","webpack://Pusher/./node_modules/tweetnacl/nacl-fast.js","webpack://Pusher/./src/core/pusher-with-encryption.js","webpack://Pusher/./src/runtimes/web/dom/script_receiver_factory.ts","webpack://Pusher/./src/core/defaults.ts","webpack://Pusher/./src/runtimes/web/dom/dependencies.ts","webpack://Pusher/./src/runtimes/web/dom/dependency_loader.ts","webpack://Pusher/./src/core/utils/url_store.ts","webpack://Pusher/./src/core/auth/options.ts","webpack://Pusher/./src/core/errors.ts","webpack://Pusher/./src/runtimes/isomorphic/auth/xhr_auth.ts","webpack://Pusher/./src/core/base64.ts","webpack://Pusher/./src/core/utils/timers/abstract_timer.ts","webpack://Pusher/./src/core/utils/timers/index.ts","webpack://Pusher/./src/core/util.ts","webpack://Pusher/./src/core/utils/collections.ts","webpack://Pusher/./src/core/logger.ts","webpack://Pusher/./src/runtimes/web/auth/jsonp_auth.ts","webpack://Pusher/./src/runtimes/web/dom/script_request.ts","webpack://Pusher/./src/runtimes/web/dom/jsonp_request.ts","webpack://Pusher/./src/runtimes/web/timeline/jsonp_timeline.ts","webpack://Pusher/./src/core/transports/url_schemes.ts","webpack://Pusher/./src/core/events/callback_registry.ts","webpack://Pusher/./src/core/events/dispatcher.ts","webpack://Pusher/./src/core/transports/transport_connection.ts","webpack://Pusher/./src/core/transports/transport.ts","webpack://Pusher/./src/runtimes/isomorphic/transports/transports.ts","webpack://Pusher/./src/runtimes/web/transports/transports.ts","webpack://Pusher/./src/runtimes/web/net_info.ts","webpack://Pusher/./src/core/transports/assistant_to_the_transport_manager.ts","webpack://Pusher/./src/core/connection/protocol/protocol.ts","webpack://Pusher/./src/core/connection/connection.ts","webpack://Pusher/./src/core/connection/handshake/index.ts","webpack://Pusher/./src/core/timeline/timeline_sender.ts","webpack://Pusher/./src/core/channels/channel.ts","webpack://Pusher/./src/core/channels/private_channel.ts","webpack://Pusher/./src/core/channels/members.ts","webpack://Pusher/./src/core/channels/presence_channel.ts","webpack://Pusher/./src/core/channels/encrypted_channel.ts","webpack://Pusher/./src/core/connection/connection_manager.ts","webpack://Pusher/./src/core/channels/channels.ts","webpack://Pusher/./src/core/utils/factory.ts","webpack://Pusher/./src/core/transports/transport_manager.ts","webpack://Pusher/./src/core/strategies/sequential_strategy.ts","webpack://Pusher/./src/core/strategies/best_connected_ever_strategy.ts","webpack://Pusher/./src/core/strategies/websocket_prioritized_cached_strategy.ts","webpack://Pusher/./src/core/strategies/delayed_strategy.ts","webpack://Pusher/./src/core/strategies/if_strategy.ts","webpack://Pusher/./src/core/strategies/first_connected_strategy.ts","webpack://Pusher/./src/runtimes/web/default_strategy.ts","webpack://Pusher/./src/runtimes/web/http/http_xdomain_request.ts","webpack://Pusher/./src/core/http/http_request.ts","webpack://Pusher/./src/core/http/state.ts","webpack://Pusher/./src/core/http/http_socket.ts","webpack://Pusher/./src/core/timeline/level.ts","webpack://Pusher/./src/core/http/http_streaming_socket.ts","webpack://Pusher/./src/core/http/http_polling_socket.ts","webpack://Pusher/./src/runtimes/isomorphic/http/http_xhr_request.ts","webpack://Pusher/./src/runtimes/isomorphic/http/http.ts","webpack://Pusher/./src/runtimes/web/http/http.ts","webpack://Pusher/./src/runtimes/web/runtime.ts","webpack://Pusher/./src/runtimes/web/transports/transport_connection_initializer.ts","webpack://Pusher/./src/core/timeline/timeline.ts","webpack://Pusher/./src/core/strategies/transport_strategy.ts","webpack://Pusher/./src/core/strategies/strategy_builder.ts","webpack://Pusher/./src/core/options.ts","webpack://Pusher/./src/core/auth/user_authenticator.ts","webpack://Pusher/./src/core/auth/channel_authorizer.ts","webpack://Pusher/./src/core/config.ts","webpack://Pusher/./src/core/auth/deprecated_channel_authorizer.ts","webpack://Pusher/./src/core/watchlist.ts","webpack://Pusher/./src/core/utils/flat_promise.ts","webpack://Pusher/./src/core/user.ts","webpack://Pusher/./src/core/pusher.ts","webpack://Pusher/./src/core/pusher-with-encryption.ts"],"names":["root","factory","exports","module","define","amd","window","installedModules","__webpack_require__","moduleId","i","l","modules","call","m","c","d","name","getter","o","Object","defineProperty","enumerable","get","r","Symbol","toStringTag","value","t","mode","__esModule","ns","create","key","bind","n","object","property","prototype","hasOwnProperty","p","s","_paddingCharacter","encodedLength","length","this","encode","data","out","_encodeByte","left","maxDecodedLength","decodedLength","_getPaddingLength","decode","Uint8Array","paddingLength","op","haveBad","v0","v1","v2","v3","_decodeChar","charCodeAt","Error","b","result","String","fromCharCode","Coder","stdCoder","URLSafeCoder","urlSafeCoder","INVALID_UTF8","arr","pos","chars","min","n1","n2","n3","push","join","nacl","gf","init","Float64Array","randombytes","_0","_9","gf0","gf1","_121665","D","D2","X","Y","I","ts64","x","h","vn","xi","y","yi","crypto_verify_16","crypto_verify_32","crypto_core_salsa20","inp","k","u","j0","j1","j2","j3","j4","j5","j6","j7","j8","j9","j10","j11","j12","j13","j14","j15","x0","x1","x2","x3","x4","x5","x6","x7","x8","x9","x10","x11","x12","x13","x14","x15","core_salsa20","crypto_core_hsalsa20","core_hsalsa20","sigma","crypto_stream_salsa20_xor","cpos","mpos","z","crypto_stream_salsa20","crypto_stream","sn","crypto_stream_xor","poly1305","t0","t1","t2","t3","t4","t5","t6","t7","buffer","Uint16Array","pad","leftover","fin","crypto_onetimeauth","outpos","update","finish","crypto_onetimeauth_verify","hpos","crypto_secretbox","crypto_secretbox_open","set25519","a","car25519","v","Math","floor","sel25519","q","pack25519","j","neq25519","par25519","unpack25519","A","Z","M","t8","t9","t10","t11","t12","t13","t14","t15","t16","t17","t18","t19","t20","t21","t22","t23","t24","t25","t26","t27","t28","t29","t30","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","b10","b11","b12","b13","b14","b15","S","inv25519","pow2523","crypto_scalarmult","e","f","x32","subarray","x16","crypto_scalarmult_base","crypto_box_keypair","crypto_box_beforenm","blocks","bytes","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","hibit","h0","h1","h2","h3","h4","h5","h6","h7","h8","h9","r0","r1","r2","r3","r4","r5","r6","r7","r8","r9","mac","macpos","mask","g","want","crypto_box_afternm","crypto_box_open_afternm","K","crypto_hashblocks_hl","hh","hl","bh0","bh1","bh2","bh3","bh4","bh5","bh6","bh7","bl0","bl1","bl2","bl3","bl4","bl5","bl6","bl7","th","tl","wh","Int32Array","wl","ah0","ah1","ah2","ah3","ah4","ah5","ah6","ah7","al0","al1","al2","al3","al4","al5","al6","al7","crypto_hash","add","cswap","pack","tx","ty","zi","scalarmult","scalarbase","crypto_sign_keypair","pk","sk","seeded","L","modL","carry","reduce","crypto_sign","sm","smlen","crypto_sign_open","chk","num","den","den2","den4","den6","unpackneg","checkLengths","checkArrayTypes","arguments","TypeError","cleanup","lowlevel","crypto_box","crypto_box_open","crypto_secretbox_KEYBYTES","crypto_secretbox_NONCEBYTES","crypto_secretbox_ZEROBYTES","crypto_secretbox_BOXZEROBYTES","crypto_scalarmult_BYTES","crypto_scalarmult_SCALARBYTES","crypto_box_PUBLICKEYBYTES","crypto_box_SECRETKEYBYTES","crypto_box_BEFORENMBYTES","crypto_box_NONCEBYTES","crypto_box_ZEROBYTES","crypto_box_BOXZEROBYTES","crypto_sign_BYTES","crypto_sign_PUBLICKEYBYTES","crypto_sign_SECRETKEYBYTES","crypto_sign_SEEDBYTES","crypto_hash_BYTES","randomBytes","secretbox","msg","nonce","open","box","keyLength","nonceLength","overheadLength","scalarMult","base","scalarLength","groupElementLength","publicKey","secretKey","before","checkBoxLengths","after","keyPair","fromSecretKey","publicKeyLength","secretKeyLength","sharedKeyLength","sign","signedMsg","tmp","mlen","detached","sig","verify","fromSeed","seed","seedLength","signatureLength","hash","hashLength","setPRNG","fn","crypto","self","msCrypto","getRandomValues","default","ScriptReceiverFactory","prefix","lastId","callback","number","id","called","callbackWrapper","apply","receiver","ScriptReceivers","VERSION","PROTOCOL","wsPort","wssPort","wsPath","httpHost","httpPort","httpsPort","httpPath","stats_host","authEndpoint","authTransport","activityTimeout","pongTimeout","unavailableTimeout","userAuthentication","endpoint","transport","channelAuthorization","cdn_http","cdn_https","dependency_suffix","DependenciesReceivers","Dependencies","options","receivers","loading","request","createScriptRequest","getPath","error","remove","callbacks","successCallback","wasSuccessful","send","protocol","getDocument","location","useTLS","replace","version","getRoot","suffix","urlStore","baseUrl","urls","authenticationEndpoint","path","authorizationEndpoint","javascriptQuickStart","triggeringClientEvents","encryptedChannelSupport","fullUrl","AuthRequestType","urlObj","url","BadEventName","super","setPrototypeOf","BadChannelName","RequestTimedOut","TransportPriorityTooLow","TransportClosed","UnsupportedFeature","UnsupportedTransport","UnsupportedStrategy","HTTPAuthError","status","context","query","authOptions","authRequestType","xhr","createXHR","headerName","setRequestHeader","headers","headersProvider","dynamicHeaders","onreadystatechange","readyState","parsed","JSON","parse","responseText","toString","UserAuthentication","ChannelAuthorization","b64chars","b64tab","charAt","cb_utob","cc","utob","cb_encode","ccc","padlen","ord","btoa","set","clear","delay","timer","clearTimeout","clearInterval","setTimeout","setInterval","now","Date","valueOf","defer","args","boundArguments","Array","slice","concat","extend","target","sources","extensions","constructor","stringify","safeJSONStringify","arrayIndexOf","array","item","nativeIndexOf","indexOf","objectApply","keys","_","map","filter","test","filterObject","Boolean","any","encodeParamsObject","encodeURIComponent","buildQueryString","params","undefined","method","source","objects","paths","derez","nu","$ref","globalLog","message","console","log","globalLogWarn","globalLogError","warn","defaultLoggingFunction","logToConsole","callbackName","nextAuthCallbackID","document","script","createElement","auth_callbacks","callback_name","src","head","getElementsByTagName","documentElement","insertBefore","firstChild","ScriptRequest","errorString","type","charset","addEventListener","onerror","onload","async","attachEvent","navigator","userAgent","errorScript","text","nextSibling","parentNode","removeChild","getAgent","sender","host","createJSONPRequest","getGenericURL","baseScheme","hostTLS","hostNonTLS","getGenericPath","queryString","ws","getInitial","http","sockjs","_callbacks","prefixedEventName","names","removeCallback","removeAllCallbacks","binding","failThrough","global_callbacks","eventName","unbind","unbind_global","metadata","hooks","priority","initialize","transportConnectionInitializer","state","timeline","generateUniqueID","handlesActivityChecks","supportsPing","socket","getSocket","onError","changeState","bindListeners","debug","close","ping","beforeOpen","onopen","emit","buildTimelineMessage","closeEvent","code","reason","wasClean","unbindListeners","onOpen","onclose","onClose","onmessage","onMessage","onactivity","onActivity","info","cid","environment","isSupported","WSTransport","isInitialized","getWebSocketAPI","createWebSocket","httpConfiguration","streamingConfiguration","HTTPFactory","createStreamingSocket","pollingConfiguration","createPollingSocket","xhrConfiguration","isXHRSupported","xhr_streaming","xhr_polling","SockJSTransport","file","SockJS","js_path","ignore_null_origin","ignoreNullOrigin","xdrConfiguration","isXDRSupported","XDRStreamingTransport","XDRPollingTransport","xdr_streaming","xdr_polling","onLine","manager","minPingDelay","maxPingDelay","pingDelay","connection","createConnection","openTimestamp","onClosed","reportDeath","lifespan","max","isAlive","Protocol","decodeMessage","messageEvent","messageData","pusherEventData","pusherEvent","event","channel","user_id","encodeMessage","processHandshake","activity_timeout","action","socket_id","getCloseAction","getCloseError","send_event","listeners","activity","closed","handleCloseEvent","listener","isEmpty","TimelineTransport","pusher","subscribed","subscriptionPending","subscriptionCancelled","socketId","auth","handleSubscriptionSucceededEvent","handleSubscriptionCountEvent","unsubscribe","subscription_count","subscriptionCount","authorize","assign","channel_data","config","channelAuthorizer","channelName","reset","members","member","myID","subscriptionData","presence","count","me","memberData","user_info","authData","channelData","setMyID","user","signinDonePromise","user_data","handleInternalEvent","addedMember","addMember","removedMember","removeMember","onSubscription","disconnect","sharedSecret","handleEncryptedEvent","handleEvent","ciphertext","cipherText","getDataToEmit","raw","usingTLS","errorCallbacks","buildErrorCallbacks","connectionCallbacks","buildConnectionCallbacks","handshakeCallbacks","buildHandshakeCallbacks","Network","getNetwork","netinfo","retryIn","sendActivityCheck","updateStrategy","runner","strategy","updateState","startConnecting","setUnavailableTimer","disconnectInternally","handshake","connect","handshakeError","abortConnecting","abort","clearRetryTimer","clearUnavailableTimer","abandonConnection","getStrategy","round","retryTimer","ensureAborted","unavailableTimer","stopActivityCheck","activityTimer","pong_timed_out","resetActivityCheck","shouldRetry","connected","Infinity","setConnection","withErrorEmitted","tls_only","refused","backoff","retry","newState","previousState","newStateDescription","previous","current","channels","createEncryptedChannel","errMsg","createPrivateChannel","createPresenceChannel","createChannel","values","createChannels","createConnectionManager","createTimelineSender","createHandshake","createAssistantToTheTransportManager","livesLeft","lives","strategies","loop","failFast","timeout","timeoutLimit","minPriority","tryNextStrategy","tryStrategy","forceMinPriority","isRunning","callbackBuilder","runners","rs","abortRunner","allRunnersFailed","aborted","transports","ttl","storage","getLocalStorage","serializedCache","getTransportCacheKey","flushTransportCache","fetchTransportCache","cacheSkipCount","timestamp","includes","cached","latency","startTimestamp","pop","cb","storeTransportCache","IfStrategy","trueBranch","falseBranch","FirstConnectedStrategy","testSupportsStrategy","baseOptions","defineTransport","definedTransports","defineTransportStrategy","wsStrategy","ws_options","wsHost","wss_options","sockjs_options","timeouts","ws_manager","streaming_manager","ws_transport","wss_transport","sockjs_transport","xhr_streaming_transport","xdr_streaming_transport","xhr_polling_transport","xdr_polling_transport","ws_loop","wss_loop","sockjs_loop","streaming_loop","polling_loop","http_loop","http_fallback_loop","getRequest","xdr","XDomainRequest","ontimeout","onprogress","onChunk","abortRequest","payload","position","unloader","addUnloadListener","removeUnloadListener","chunk","advanceBuffer","isBufferTooLong","unreadData","endOfLinePosition","State","autoIncrement","getUniqueURL","separator","randomNumber","randomInt","TimelineLevel","session","randomString","parts","exec","getLocation","CONNECTING","openStream","sendRaw","sendHeartbeat","OPEN","createSocketRequest","start","closeStream","CLOSED","onEvent","onHeartbeat","hostname","urlParts","stream","getReceiveURL","onFinished","reconnect","unbind_all","getXHRAPI","createSocket","createRequest","getDefaultStrategy","Transports","load","XMLHttpRequest","WebSocket","MozWebSocket","PusherClass","Pusher","initializeOnDocumentBody","onDocumentBody","ready","getAuthorizers","ajax","jsonp","body","localStorage","createXMLHttpRequest","createMicrosoftXHR","ActiveXObject","createXDR","Constructor","withCredentials","documentProtocol","getProtocol","removeEventListener","detachEvent","Uint32Array","events","sent","uniqueID","level","limit","shift","ERROR","INFO","DEBUG","sendfn","bundle","lib","cluster","features","failAttempt","onInitialized","serializedTransport","transportClass","enabledTransports","disabledTransports","getAssistant","deferred","validateOptions","paramsProvider","dynamicParams","composeChannelQuery","getConfig","opts","statsHost","enableStats","getEnableStatsConfig","getHttpHost","shouldUseTLS","getWebsocketHost","userAuthenticator","buildUserAuthenticator","buildChannelAuthorizer","timelineParams","forceTLS","disableStats","customHandler","channelAuthorizerGenerator","deprecatedAuthorizerOptions","ChannelAuthorizerProxy","authorizer","buildChannelAuth","bindWatchlistInternalEvent","forEach","watchlistEvent","resolve","reject","promise","Promise","res","rej","signin_requested","serverToUserChannel","_signinDoneResolve","_onAuthorize","err","_cleanup","_signin","_newSigninPromiseIfNeeded","watchlist","_onSigninSuccess","_subscribeChannels","bind_global","reinstateSubscription","subscribe","ensure_subscribed","done","setDone","then","catch","isReady","instances","app_key","checkAppKey","global_emitter","sessionID","getClientFeatures","timelineSender","subscribeAll","isUsingTLS","internal","appKey","switchCluster","find","all","timelineSenderTimer","event_name","channel_name","cancelSubscription","signin","Runtime","setup"],"mappings":";;;;;;;CAAA,SAA2CA,EAAMC,GAC1B,iBAAZC,SAA0C,iBAAXC,OACxCA,OAAOD,QAAUD,IACQ,mBAAXG,QAAyBA,OAAOC,IAC9CD,OAAO,GAAIH,GACe,iBAAZC,QACdA,QAAgB,OAAID,IAEpBD,EAAa,OAAIC,IARnB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N,GAC3B5X,KAGT,WAAW4X,GAET,OADA5X,KAAKwgC,eAAe7G,aACb35B,KAGT,eACE,IAAI8sB,EACJ,IAAKA,KAAe9sB,KAAK+xB,SAASA,SAC5B/xB,KAAK+xB,SAASA,SAASryB,eAAeotB,IACxC9sB,KAAK8/B,UAAUhT,GAKrB,UAAUuU,GACR,IAAIxW,EAAU7qB,KAAK+xB,SAASrgB,IAAI2vB,EAAcrhC,MAS9C,OARI6qB,EAAQmB,qBAAuBnB,EAAQoB,sBACzCpB,EAAQgV,wBAEPhV,EAAQmB,qBACiB,cAA1BhsB,KAAK8pB,WAAWhE,OAEhB+E,EAAQiV,YAEHjV,EAGT,YAAYwW,GACV,IAAIxW,EAAU7qB,KAAK+xB,SAASkP,KAAKI,GAC7BxW,GAAWA,EAAQmB,oBACrBnB,EAAQyW,sBAERzW,EAAU7qB,KAAK+xB,SAAS5X,OAAOknB,KAChBxW,EAAQkB,YACrBlB,EAAQyB,cAKd,WAAW8U,EAAoBlhC,EAAW2qB,GACxC,OAAO7qB,KAAK8pB,WAAWwB,WAAW8V,EAAYlhC,EAAM2qB,GAGtD,eACE,OAAO7qB,KAAK4sB,OAAOjS,OAGrB,SACE3a,KAAK4tB,KAAK2T,UAtOL,GAAAlB,UAAsB,GACtB,GAAAD,SAAmB,EACnB,GAAAle,cAAwB,EAGxB,GAAAsf,QAA2B,GAC3B,GAAArpB,gBAA6B,GAASA,gBACtC,GAAAuB,sBAAmC,GAASA,sBAC5C,GAAA8I,eAA4B,GAASA,eAVzB,UAkPrB,GAAQif,MAAM,I,YClQC,MAAM,WAA6B,GAChD,YAAYnB,EAAiB1mB,GAC3B,GAAOsI,aAAe,GAAqBA,aAC3C,GAAOL,IAAM,GAAqBA,IAElCmb,GAAgBpjB,GAChBA,EAAQrX,KAAO,GACfuZ,MAAMwkB,EAAS1mB","file":"pusher-with-encryption.min.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"Pusher\"] = factory();\n\telse\n\t\troot[\"Pusher\"] = factory();\n})(window, function() {\nreturn "," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 3);\n","// Copyright (C) 2016 Dmitry Chestnykh\n// MIT License. See LICENSE file for details.\n\n/**\n * Package base64 implements Base64 encoding and decoding.\n */\n\n// Invalid character used in decoding to indicate\n// that the character to decode is out of range of\n// alphabet and cannot be decoded.\nconst INVALID_BYTE = 256;\n\n/**\n * Implements standard Base64 encoding.\n *\n * Operates in constant time.\n */\nexport class Coder {\n // TODO(dchest): methods to encode chunk-by-chunk.\n\n constructor(private _paddingCharacter = \"=\") { }\n\n encodedLength(length: number): number {\n if (!this._paddingCharacter) {\n return (length * 8 + 5) / 6 | 0;\n }\n return (length + 2) / 3 * 4 | 0;\n }\n\n encode(data: Uint8Array): string {\n let out = \"\";\n\n let i = 0;\n for (; i < data.length - 2; i += 3) {\n let c = (data[i] << 16) | (data[i + 1] << 8) | (data[i + 2]);\n out += this._encodeByte((c >>> 3 * 6) & 63);\n out += this._encodeByte((c >>> 2 * 6) & 63);\n out += this._encodeByte((c >>> 1 * 6) & 63);\n out += this._encodeByte((c >>> 0 * 6) & 63);\n }\n\n const left = data.length - i;\n if (left > 0) {\n let c = (data[i] << 16) | (left === 2 ? data[i + 1] << 8 : 0);\n out += this._encodeByte((c >>> 3 * 6) & 63);\n out += this._encodeByte((c >>> 2 * 6) & 63);\n if (left === 2) {\n out += this._encodeByte((c >>> 1 * 6) & 63);\n } else {\n out += this._paddingCharacter || \"\";\n }\n out += this._paddingCharacter || \"\";\n }\n\n return out;\n }\n\n maxDecodedLength(length: number): number {\n if (!this._paddingCharacter) {\n return (length * 6 + 7) / 8 | 0;\n }\n return length / 4 * 3 | 0;\n }\n\n decodedLength(s: string): number {\n return this.maxDecodedLength(s.length - this._getPaddingLength(s));\n }\n\n decode(s: string): Uint8Array {\n if (s.length === 0) {\n return new Uint8Array(0);\n }\n const paddingLength = this._getPaddingLength(s);\n const length = s.length - paddingLength;\n const out = new Uint8Array(this.maxDecodedLength(length));\n let op = 0;\n let i = 0;\n let haveBad = 0;\n let v0 = 0, v1 = 0, v2 = 0, v3 = 0;\n for (; i < length - 4; i += 4) {\n v0 = this._decodeChar(s.charCodeAt(i + 0));\n v1 = this._decodeChar(s.charCodeAt(i + 1));\n v2 = this._decodeChar(s.charCodeAt(i + 2));\n v3 = this._decodeChar(s.charCodeAt(i + 3));\n out[op++] = (v0 << 2) | (v1 >>> 4);\n out[op++] = (v1 << 4) | (v2 >>> 2);\n out[op++] = (v2 << 6) | v3;\n haveBad |= v0 & INVALID_BYTE;\n haveBad |= v1 & INVALID_BYTE;\n haveBad |= v2 & INVALID_BYTE;\n haveBad |= v3 & INVALID_BYTE;\n }\n if (i < length - 1) {\n v0 = this._decodeChar(s.charCodeAt(i));\n v1 = this._decodeChar(s.charCodeAt(i + 1));\n out[op++] = (v0 << 2) | (v1 >>> 4);\n haveBad |= v0 & INVALID_BYTE;\n haveBad |= v1 & INVALID_BYTE;\n }\n if (i < length - 2) {\n v2 = this._decodeChar(s.charCodeAt(i + 2));\n out[op++] = (v1 << 4) | (v2 >>> 2);\n haveBad |= v2 & INVALID_BYTE;\n }\n if (i < length - 3) {\n v3 = this._decodeChar(s.charCodeAt(i + 3));\n out[op++] = (v2 << 6) | v3;\n haveBad |= v3 & INVALID_BYTE;\n }\n if (haveBad !== 0) {\n throw new Error(\"Base64Coder: incorrect characters for decoding\");\n }\n return out;\n }\n\n // Standard encoding have the following encoded/decoded ranges,\n // which we need to convert between.\n //\n // ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 0123456789 + /\n // Index: 0 - 25 26 - 51 52 - 61 62 63\n // ASCII: 65 - 90 97 - 122 48 - 57 43 47\n //\n\n // Encode 6 bits in b into a new character.\n protected _encodeByte(b: number): string {\n // Encoding uses constant time operations as follows:\n //\n // 1. Define comparison of A with B using (A - B) >>> 8:\n // if A > B, then result is positive integer\n // if A <= B, then result is 0\n //\n // 2. Define selection of C or 0 using bitwise AND: X & C:\n // if X == 0, then result is 0\n // if X != 0, then result is C\n //\n // 3. Start with the smallest comparison (b >= 0), which is always\n // true, so set the result to the starting ASCII value (65).\n //\n // 4. Continue comparing b to higher ASCII values, and selecting\n // zero if comparison isn't true, otherwise selecting a value\n // to add to result, which:\n //\n // a) undoes the previous addition\n // b) provides new value to add\n //\n let result = b;\n // b >= 0\n result += 65;\n // b > 25\n result += ((25 - b) >>> 8) & ((0 - 65) - 26 + 97);\n // b > 51\n result += ((51 - b) >>> 8) & ((26 - 97) - 52 + 48);\n // b > 61\n result += ((61 - b) >>> 8) & ((52 - 48) - 62 + 43);\n // b > 62\n result += ((62 - b) >>> 8) & ((62 - 43) - 63 + 47);\n\n return String.fromCharCode(result);\n }\n\n // Decode a character code into a byte.\n // Must return 256 if character is out of alphabet range.\n protected _decodeChar(c: number): number {\n // Decoding works similar to encoding: using the same comparison\n // function, but now it works on ranges: result is always incremented\n // by value, but this value becomes zero if the range is not\n // satisfied.\n //\n // Decoding starts with invalid value, 256, which is then\n // subtracted when the range is satisfied. If none of the ranges\n // apply, the function returns 256, which is then checked by\n // the caller to throw error.\n let result = INVALID_BYTE; // start with invalid character\n\n // c == 43 (c > 42 and c < 44)\n result += (((42 - c) & (c - 44)) >>> 8) & (-INVALID_BYTE + c - 43 + 62);\n // c == 47 (c > 46 and c < 48)\n result += (((46 - c) & (c - 48)) >>> 8) & (-INVALID_BYTE + c - 47 + 63);\n // c > 47 and c < 58\n result += (((47 - c) & (c - 58)) >>> 8) & (-INVALID_BYTE + c - 48 + 52);\n // c > 64 and c < 91\n result += (((64 - c) & (c - 91)) >>> 8) & (-INVALID_BYTE + c - 65 + 0);\n // c > 96 and c < 123\n result += (((96 - c) & (c - 123)) >>> 8) & (-INVALID_BYTE + c - 97 + 26);\n\n return result;\n }\n\n private _getPaddingLength(s: string): number {\n let paddingLength = 0;\n if (this._paddingCharacter) {\n for (let i = s.length - 1; i >= 0; i--) {\n if (s[i] !== this._paddingCharacter) {\n break;\n }\n paddingLength++;\n }\n if (s.length < 4 || paddingLength > 2) {\n throw new Error(\"Base64Coder: incorrect padding\");\n }\n }\n return paddingLength;\n }\n\n}\n\nconst stdCoder = new Coder();\n\nexport function encode(data: Uint8Array): string {\n return stdCoder.encode(data);\n}\n\nexport function decode(s: string): Uint8Array {\n return stdCoder.decode(s);\n}\n\n/**\n * Implements URL-safe Base64 encoding.\n * (Same as Base64, but '+' is replaced with '-', and '/' with '_').\n *\n * Operates in constant time.\n */\nexport class URLSafeCoder extends Coder {\n // URL-safe encoding have the following encoded/decoded ranges:\n //\n // ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 0123456789 - _\n // Index: 0 - 25 26 - 51 52 - 61 62 63\n // ASCII: 65 - 90 97 - 122 48 - 57 45 95\n //\n\n protected _encodeByte(b: number): string {\n let result = b;\n // b >= 0\n result += 65;\n // b > 25\n result += ((25 - b) >>> 8) & ((0 - 65) - 26 + 97);\n // b > 51\n result += ((51 - b) >>> 8) & ((26 - 97) - 52 + 48);\n // b > 61\n result += ((61 - b) >>> 8) & ((52 - 48) - 62 + 45);\n // b > 62\n result += ((62 - b) >>> 8) & ((62 - 45) - 63 + 95);\n\n return String.fromCharCode(result);\n }\n\n protected _decodeChar(c: number): number {\n let result = INVALID_BYTE;\n\n // c == 45 (c > 44 and c < 46)\n result += (((44 - c) & (c - 46)) >>> 8) & (-INVALID_BYTE + c - 45 + 62);\n // c == 95 (c > 94 and c < 96)\n result += (((94 - c) & (c - 96)) >>> 8) & (-INVALID_BYTE + c - 95 + 63);\n // c > 47 and c < 58\n result += (((47 - c) & (c - 58)) >>> 8) & (-INVALID_BYTE + c - 48 + 52);\n // c > 64 and c < 91\n result += (((64 - c) & (c - 91)) >>> 8) & (-INVALID_BYTE + c - 65 + 0);\n // c > 96 and c < 123\n result += (((96 - c) & (c - 123)) >>> 8) & (-INVALID_BYTE + c - 97 + 26);\n\n return result;\n }\n}\n\nconst urlSafeCoder = new URLSafeCoder();\n\nexport function encodeURLSafe(data: Uint8Array): string {\n return urlSafeCoder.encode(data);\n}\n\nexport function decodeURLSafe(s: string): Uint8Array {\n return urlSafeCoder.decode(s);\n}\n\n\nexport const encodedLength = (length: number) =>\n stdCoder.encodedLength(length);\n\nexport const maxDecodedLength = (length: number) =>\n stdCoder.maxDecodedLength(length);\n\nexport const decodedLength = (s: string) =>\n stdCoder.decodedLength(s);\n","// Copyright (C) 2016 Dmitry Chestnykh\n// MIT License. See LICENSE file for details.\n\n/**\n * Package utf8 implements UTF-8 encoding and decoding.\n */\n\nconst INVALID_UTF16 = \"utf8: invalid string\";\nconst INVALID_UTF8 = \"utf8: invalid source encoding\";\n\n/**\n * Encodes the given string into UTF-8 byte array.\n * Throws if the source string has invalid UTF-16 encoding.\n */\nexport function encode(s: string): Uint8Array {\n // Calculate result length and allocate output array.\n // encodedLength() also validates string and throws errors,\n // so we don't need repeat validation here.\n const arr = new Uint8Array(encodedLength(s));\n\n let pos = 0;\n for (let i = 0; i < s.length; i++) {\n let c = s.charCodeAt(i);\n if (c < 0x80) {\n arr[pos++] = c;\n } else if (c < 0x800) {\n arr[pos++] = 0xc0 | c >> 6;\n arr[pos++] = 0x80 | c & 0x3f;\n } else if (c < 0xd800) {\n arr[pos++] = 0xe0 | c >> 12;\n arr[pos++] = 0x80 | (c >> 6) & 0x3f;\n arr[pos++] = 0x80 | c & 0x3f;\n } else {\n i++; // get one more character\n c = (c & 0x3ff) << 10;\n c |= s.charCodeAt(i) & 0x3ff;\n c += 0x10000;\n\n arr[pos++] = 0xf0 | c >> 18;\n arr[pos++] = 0x80 | (c >> 12) & 0x3f;\n arr[pos++] = 0x80 | (c >> 6) & 0x3f;\n arr[pos++] = 0x80 | c & 0x3f;\n }\n }\n return arr;\n}\n\n/**\n * Returns the number of bytes required to encode the given string into UTF-8.\n * Throws if the source string has invalid UTF-16 encoding.\n */\nexport function encodedLength(s: string): number {\n let result = 0;\n for (let i = 0; i < s.length; i++) {\n const c = s.charCodeAt(i);\n if (c < 0x80) {\n result += 1;\n } else if (c < 0x800) {\n result += 2;\n } else if (c < 0xd800) {\n result += 3;\n } else if (c <= 0xdfff) {\n if (i >= s.length - 1) {\n throw new Error(INVALID_UTF16);\n }\n i++; // \"eat\" next character\n result += 4;\n } else {\n throw new Error(INVALID_UTF16);\n }\n }\n return result;\n}\n\n/**\n * Decodes the given byte array from UTF-8 into a string.\n * Throws if encoding is invalid.\n */\nexport function decode(arr: Uint8Array): string {\n const chars: string[] = [];\n for (let i = 0; i < arr.length; i++) {\n let b = arr[i];\n\n if (b & 0x80) {\n let min;\n if (b < 0xe0) {\n // Need 1 more byte.\n if (i >= arr.length) {\n throw new Error(INVALID_UTF8);\n }\n const n1 = arr[++i];\n if ((n1 & 0xc0) !== 0x80) {\n throw new Error(INVALID_UTF8);\n }\n b = (b & 0x1f) << 6 | (n1 & 0x3f);\n min = 0x80;\n } else if (b < 0xf0) {\n // Need 2 more bytes.\n if (i >= arr.length - 1) {\n throw new Error(INVALID_UTF8);\n }\n const n1 = arr[++i];\n const n2 = arr[++i];\n if ((n1 & 0xc0) !== 0x80 || (n2 & 0xc0) !== 0x80) {\n throw new Error(INVALID_UTF8);\n }\n b = (b & 0x0f) << 12 | (n1 & 0x3f) << 6 | (n2 & 0x3f);\n min = 0x800;\n } else if (b < 0xf8) {\n // Need 3 more bytes.\n if (i >= arr.length - 2) {\n throw new Error(INVALID_UTF8);\n }\n const n1 = arr[++i];\n const n2 = arr[++i];\n const n3 = arr[++i];\n if ((n1 & 0xc0) !== 0x80 || (n2 & 0xc0) !== 0x80 || (n3 & 0xc0) !== 0x80) {\n throw new Error(INVALID_UTF8);\n }\n b = (b & 0x0f) << 18 | (n1 & 0x3f) << 12 | (n2 & 0x3f) << 6 | (n3 & 0x3f);\n min = 0x10000;\n } else {\n throw new Error(INVALID_UTF8);\n }\n\n if (b < min || (b >= 0xd800 && b <= 0xdfff)) {\n throw new Error(INVALID_UTF8);\n }\n\n if (b >= 0x10000) {\n // Surrogate pair.\n if (b > 0x10ffff) {\n throw new Error(INVALID_UTF8);\n }\n b -= 0x10000;\n chars.push(String.fromCharCode(0xd800 | (b >> 10)));\n b = 0xdc00 | (b & 0x3ff);\n }\n }\n\n chars.push(String.fromCharCode(b));\n }\n return chars.join(\"\");\n}\n","(function(nacl) {\n'use strict';\n\n// Ported in 2014 by Dmitry Chestnykh and Devi Mandiri.\n// Public domain.\n//\n// Implementation derived from TweetNaCl version 20140427.\n// See for details: http://tweetnacl.cr.yp.to/\n\nvar gf = function(init) {\n var i, r = new Float64Array(16);\n if (init) for (i = 0; i < init.length; i++) r[i] = init[i];\n return r;\n};\n\n// Pluggable, initialized in high-level API below.\nvar randombytes = function(/* x, n */) { throw new Error('no PRNG'); };\n\nvar _0 = new Uint8Array(16);\nvar _9 = new Uint8Array(32); _9[0] = 9;\n\nvar gf0 = gf(),\n gf1 = gf([1]),\n _121665 = gf([0xdb41, 1]),\n D = gf([0x78a3, 0x1359, 0x4dca, 0x75eb, 0xd8ab, 0x4141, 0x0a4d, 0x0070, 0xe898, 0x7779, 0x4079, 0x8cc7, 0xfe73, 0x2b6f, 0x6cee, 0x5203]),\n D2 = gf([0xf159, 0x26b2, 0x9b94, 0xebd6, 0xb156, 0x8283, 0x149a, 0x00e0, 0xd130, 0xeef3, 0x80f2, 0x198e, 0xfce7, 0x56df, 0xd9dc, 0x2406]),\n X = gf([0xd51a, 0x8f25, 0x2d60, 0xc956, 0xa7b2, 0x9525, 0xc760, 0x692c, 0xdc5c, 0xfdd6, 0xe231, 0xc0a4, 0x53fe, 0xcd6e, 0x36d3, 0x2169]),\n Y = gf([0x6658, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666]),\n I = gf([0xa0b0, 0x4a0e, 0x1b27, 0xc4ee, 0xe478, 0xad2f, 0x1806, 0x2f43, 0xd7a7, 0x3dfb, 0x0099, 0x2b4d, 0xdf0b, 0x4fc1, 0x2480, 0x2b83]);\n\nfunction ts64(x, i, h, l) {\n x[i] = (h >> 24) & 0xff;\n x[i+1] = (h >> 16) & 0xff;\n x[i+2] = (h >> 8) & 0xff;\n x[i+3] = h & 0xff;\n x[i+4] = (l >> 24) & 0xff;\n x[i+5] = (l >> 16) & 0xff;\n x[i+6] = (l >> 8) & 0xff;\n x[i+7] = l & 0xff;\n}\n\nfunction vn(x, xi, y, yi, n) {\n var i,d = 0;\n for (i = 0; i < n; i++) d |= x[xi+i]^y[yi+i];\n return (1 & ((d - 1) >>> 8)) - 1;\n}\n\nfunction crypto_verify_16(x, xi, y, yi) {\n return vn(x,xi,y,yi,16);\n}\n\nfunction crypto_verify_32(x, xi, y, yi) {\n return vn(x,xi,y,yi,32);\n}\n\nfunction core_salsa20(o, p, k, c) {\n var j0 = c[ 0] & 0xff | (c[ 1] & 0xff)<<8 | (c[ 2] & 0xff)<<16 | (c[ 3] & 0xff)<<24,\n j1 = k[ 0] & 0xff | (k[ 1] & 0xff)<<8 | (k[ 2] & 0xff)<<16 | (k[ 3] & 0xff)<<24,\n j2 = k[ 4] & 0xff | (k[ 5] & 0xff)<<8 | (k[ 6] & 0xff)<<16 | (k[ 7] & 0xff)<<24,\n j3 = k[ 8] & 0xff | (k[ 9] & 0xff)<<8 | (k[10] & 0xff)<<16 | (k[11] & 0xff)<<24,\n j4 = k[12] & 0xff | (k[13] & 0xff)<<8 | (k[14] & 0xff)<<16 | (k[15] & 0xff)<<24,\n j5 = c[ 4] & 0xff | (c[ 5] & 0xff)<<8 | (c[ 6] & 0xff)<<16 | (c[ 7] & 0xff)<<24,\n j6 = p[ 0] & 0xff | (p[ 1] & 0xff)<<8 | (p[ 2] & 0xff)<<16 | (p[ 3] & 0xff)<<24,\n j7 = p[ 4] & 0xff | (p[ 5] & 0xff)<<8 | (p[ 6] & 0xff)<<16 | (p[ 7] & 0xff)<<24,\n j8 = p[ 8] & 0xff | (p[ 9] & 0xff)<<8 | (p[10] & 0xff)<<16 | (p[11] & 0xff)<<24,\n j9 = p[12] & 0xff | (p[13] & 0xff)<<8 | (p[14] & 0xff)<<16 | (p[15] & 0xff)<<24,\n j10 = c[ 8] & 0xff | (c[ 9] & 0xff)<<8 | (c[10] & 0xff)<<16 | (c[11] & 0xff)<<24,\n j11 = k[16] & 0xff | (k[17] & 0xff)<<8 | (k[18] & 0xff)<<16 | (k[19] & 0xff)<<24,\n j12 = k[20] & 0xff | (k[21] & 0xff)<<8 | (k[22] & 0xff)<<16 | (k[23] & 0xff)<<24,\n j13 = k[24] & 0xff | (k[25] & 0xff)<<8 | (k[26] & 0xff)<<16 | (k[27] & 0xff)<<24,\n j14 = k[28] & 0xff | (k[29] & 0xff)<<8 | (k[30] & 0xff)<<16 | (k[31] & 0xff)<<24,\n j15 = c[12] & 0xff | (c[13] & 0xff)<<8 | (c[14] & 0xff)<<16 | (c[15] & 0xff)<<24;\n\n var x0 = j0, x1 = j1, x2 = j2, x3 = j3, x4 = j4, x5 = j5, x6 = j6, x7 = j7,\n x8 = j8, x9 = j9, x10 = j10, x11 = j11, x12 = j12, x13 = j13, x14 = j14,\n x15 = j15, u;\n\n for (var i = 0; i < 20; i += 2) {\n u = x0 + x12 | 0;\n x4 ^= u<<7 | u>>>(32-7);\n u = x4 + x0 | 0;\n x8 ^= u<<9 | u>>>(32-9);\n u = x8 + x4 | 0;\n x12 ^= u<<13 | u>>>(32-13);\n u = x12 + x8 | 0;\n x0 ^= u<<18 | u>>>(32-18);\n\n u = x5 + x1 | 0;\n x9 ^= u<<7 | u>>>(32-7);\n u = x9 + x5 | 0;\n x13 ^= u<<9 | u>>>(32-9);\n u = x13 + x9 | 0;\n x1 ^= u<<13 | u>>>(32-13);\n u = x1 + x13 | 0;\n x5 ^= u<<18 | u>>>(32-18);\n\n u = x10 + x6 | 0;\n x14 ^= u<<7 | u>>>(32-7);\n u = x14 + x10 | 0;\n x2 ^= u<<9 | u>>>(32-9);\n u = x2 + x14 | 0;\n x6 ^= u<<13 | u>>>(32-13);\n u = x6 + x2 | 0;\n x10 ^= u<<18 | u>>>(32-18);\n\n u = x15 + x11 | 0;\n x3 ^= u<<7 | u>>>(32-7);\n u = x3 + x15 | 0;\n x7 ^= u<<9 | u>>>(32-9);\n u = x7 + x3 | 0;\n x11 ^= u<<13 | u>>>(32-13);\n u = x11 + x7 | 0;\n x15 ^= u<<18 | u>>>(32-18);\n\n u = x0 + x3 | 0;\n x1 ^= u<<7 | u>>>(32-7);\n u = x1 + x0 | 0;\n x2 ^= u<<9 | u>>>(32-9);\n u = x2 + x1 | 0;\n x3 ^= u<<13 | u>>>(32-13);\n u = x3 + x2 | 0;\n x0 ^= u<<18 | u>>>(32-18);\n\n u = x5 + x4 | 0;\n x6 ^= u<<7 | u>>>(32-7);\n u = x6 + x5 | 0;\n x7 ^= u<<9 | u>>>(32-9);\n u = x7 + x6 | 0;\n x4 ^= u<<13 | u>>>(32-13);\n u = x4 + x7 | 0;\n x5 ^= u<<18 | u>>>(32-18);\n\n u = x10 + x9 | 0;\n x11 ^= u<<7 | u>>>(32-7);\n u = x11 + x10 | 0;\n x8 ^= u<<9 | u>>>(32-9);\n u = x8 + x11 | 0;\n x9 ^= u<<13 | u>>>(32-13);\n u = x9 + x8 | 0;\n x10 ^= u<<18 | u>>>(32-18);\n\n u = x15 + x14 | 0;\n x12 ^= u<<7 | u>>>(32-7);\n u = x12 + x15 | 0;\n x13 ^= u<<9 | u>>>(32-9);\n u = x13 + x12 | 0;\n x14 ^= u<<13 | u>>>(32-13);\n u = x14 + x13 | 0;\n x15 ^= u<<18 | u>>>(32-18);\n }\n x0 = x0 + j0 | 0;\n x1 = x1 + j1 | 0;\n x2 = x2 + j2 | 0;\n x3 = x3 + j3 | 0;\n x4 = x4 + j4 | 0;\n x5 = x5 + j5 | 0;\n x6 = x6 + j6 | 0;\n x7 = x7 + j7 | 0;\n x8 = x8 + j8 | 0;\n x9 = x9 + j9 | 0;\n x10 = x10 + j10 | 0;\n x11 = x11 + j11 | 0;\n x12 = x12 + j12 | 0;\n x13 = x13 + j13 | 0;\n x14 = x14 + j14 | 0;\n x15 = x15 + j15 | 0;\n\n o[ 0] = x0 >>> 0 & 0xff;\n o[ 1] = x0 >>> 8 & 0xff;\n o[ 2] = x0 >>> 16 & 0xff;\n o[ 3] = x0 >>> 24 & 0xff;\n\n o[ 4] = x1 >>> 0 & 0xff;\n o[ 5] = x1 >>> 8 & 0xff;\n o[ 6] = x1 >>> 16 & 0xff;\n o[ 7] = x1 >>> 24 & 0xff;\n\n o[ 8] = x2 >>> 0 & 0xff;\n o[ 9] = x2 >>> 8 & 0xff;\n o[10] = x2 >>> 16 & 0xff;\n o[11] = x2 >>> 24 & 0xff;\n\n o[12] = x3 >>> 0 & 0xff;\n o[13] = x3 >>> 8 & 0xff;\n o[14] = x3 >>> 16 & 0xff;\n o[15] = x3 >>> 24 & 0xff;\n\n o[16] = x4 >>> 0 & 0xff;\n o[17] = x4 >>> 8 & 0xff;\n o[18] = x4 >>> 16 & 0xff;\n o[19] = x4 >>> 24 & 0xff;\n\n o[20] = x5 >>> 0 & 0xff;\n o[21] = x5 >>> 8 & 0xff;\n o[22] = x5 >>> 16 & 0xff;\n o[23] = x5 >>> 24 & 0xff;\n\n o[24] = x6 >>> 0 & 0xff;\n o[25] = x6 >>> 8 & 0xff;\n o[26] = x6 >>> 16 & 0xff;\n o[27] = x6 >>> 24 & 0xff;\n\n o[28] = x7 >>> 0 & 0xff;\n o[29] = x7 >>> 8 & 0xff;\n o[30] = x7 >>> 16 & 0xff;\n o[31] = x7 >>> 24 & 0xff;\n\n o[32] = x8 >>> 0 & 0xff;\n o[33] = x8 >>> 8 & 0xff;\n o[34] = x8 >>> 16 & 0xff;\n o[35] = x8 >>> 24 & 0xff;\n\n o[36] = x9 >>> 0 & 0xff;\n o[37] = x9 >>> 8 & 0xff;\n o[38] = x9 >>> 16 & 0xff;\n o[39] = x9 >>> 24 & 0xff;\n\n o[40] = x10 >>> 0 & 0xff;\n o[41] = x10 >>> 8 & 0xff;\n o[42] = x10 >>> 16 & 0xff;\n o[43] = x10 >>> 24 & 0xff;\n\n o[44] = x11 >>> 0 & 0xff;\n o[45] = x11 >>> 8 & 0xff;\n o[46] = x11 >>> 16 & 0xff;\n o[47] = x11 >>> 24 & 0xff;\n\n o[48] = x12 >>> 0 & 0xff;\n o[49] = x12 >>> 8 & 0xff;\n o[50] = x12 >>> 16 & 0xff;\n o[51] = x12 >>> 24 & 0xff;\n\n o[52] = x13 >>> 0 & 0xff;\n o[53] = x13 >>> 8 & 0xff;\n o[54] = x13 >>> 16 & 0xff;\n o[55] = x13 >>> 24 & 0xff;\n\n o[56] = x14 >>> 0 & 0xff;\n o[57] = x14 >>> 8 & 0xff;\n o[58] = x14 >>> 16 & 0xff;\n o[59] = x14 >>> 24 & 0xff;\n\n o[60] = x15 >>> 0 & 0xff;\n o[61] = x15 >>> 8 & 0xff;\n o[62] = x15 >>> 16 & 0xff;\n o[63] = x15 >>> 24 & 0xff;\n}\n\nfunction core_hsalsa20(o,p,k,c) {\n var j0 = c[ 0] & 0xff | (c[ 1] & 0xff)<<8 | (c[ 2] & 0xff)<<16 | (c[ 3] & 0xff)<<24,\n j1 = k[ 0] & 0xff | (k[ 1] & 0xff)<<8 | (k[ 2] & 0xff)<<16 | (k[ 3] & 0xff)<<24,\n j2 = k[ 4] & 0xff | (k[ 5] & 0xff)<<8 | (k[ 6] & 0xff)<<16 | (k[ 7] & 0xff)<<24,\n j3 = k[ 8] & 0xff | (k[ 9] & 0xff)<<8 | (k[10] & 0xff)<<16 | (k[11] & 0xff)<<24,\n j4 = k[12] & 0xff | (k[13] & 0xff)<<8 | (k[14] & 0xff)<<16 | (k[15] & 0xff)<<24,\n j5 = c[ 4] & 0xff | (c[ 5] & 0xff)<<8 | (c[ 6] & 0xff)<<16 | (c[ 7] & 0xff)<<24,\n j6 = p[ 0] & 0xff | (p[ 1] & 0xff)<<8 | (p[ 2] & 0xff)<<16 | (p[ 3] & 0xff)<<24,\n j7 = p[ 4] & 0xff | (p[ 5] & 0xff)<<8 | (p[ 6] & 0xff)<<16 | (p[ 7] & 0xff)<<24,\n j8 = p[ 8] & 0xff | (p[ 9] & 0xff)<<8 | (p[10] & 0xff)<<16 | (p[11] & 0xff)<<24,\n j9 = p[12] & 0xff | (p[13] & 0xff)<<8 | (p[14] & 0xff)<<16 | (p[15] & 0xff)<<24,\n j10 = c[ 8] & 0xff | (c[ 9] & 0xff)<<8 | (c[10] & 0xff)<<16 | (c[11] & 0xff)<<24,\n j11 = k[16] & 0xff | (k[17] & 0xff)<<8 | (k[18] & 0xff)<<16 | (k[19] & 0xff)<<24,\n j12 = k[20] & 0xff | (k[21] & 0xff)<<8 | (k[22] & 0xff)<<16 | (k[23] & 0xff)<<24,\n j13 = k[24] & 0xff | (k[25] & 0xff)<<8 | (k[26] & 0xff)<<16 | (k[27] & 0xff)<<24,\n j14 = k[28] & 0xff | (k[29] & 0xff)<<8 | (k[30] & 0xff)<<16 | (k[31] & 0xff)<<24,\n j15 = c[12] & 0xff | (c[13] & 0xff)<<8 | (c[14] & 0xff)<<16 | (c[15] & 0xff)<<24;\n\n var x0 = j0, x1 = j1, x2 = j2, x3 = j3, x4 = j4, x5 = j5, x6 = j6, x7 = j7,\n x8 = j8, x9 = j9, x10 = j10, x11 = j11, x12 = j12, x13 = j13, x14 = j14,\n x15 = j15, u;\n\n for (var i = 0; i < 20; i += 2) {\n u = x0 + x12 | 0;\n x4 ^= u<<7 | u>>>(32-7);\n u = x4 + x0 | 0;\n x8 ^= u<<9 | u>>>(32-9);\n u = x8 + x4 | 0;\n x12 ^= u<<13 | u>>>(32-13);\n u = x12 + x8 | 0;\n x0 ^= u<<18 | u>>>(32-18);\n\n u = x5 + x1 | 0;\n x9 ^= u<<7 | u>>>(32-7);\n u = x9 + x5 | 0;\n x13 ^= u<<9 | u>>>(32-9);\n u = x13 + x9 | 0;\n x1 ^= u<<13 | u>>>(32-13);\n u = x1 + x13 | 0;\n x5 ^= u<<18 | u>>>(32-18);\n\n u = x10 + x6 | 0;\n x14 ^= u<<7 | u>>>(32-7);\n u = x14 + x10 | 0;\n x2 ^= u<<9 | u>>>(32-9);\n u = x2 + x14 | 0;\n x6 ^= u<<13 | u>>>(32-13);\n u = x6 + x2 | 0;\n x10 ^= u<<18 | u>>>(32-18);\n\n u = x15 + x11 | 0;\n x3 ^= u<<7 | u>>>(32-7);\n u = x3 + x15 | 0;\n x7 ^= u<<9 | u>>>(32-9);\n u = x7 + x3 | 0;\n x11 ^= u<<13 | u>>>(32-13);\n u = x11 + x7 | 0;\n x15 ^= u<<18 | u>>>(32-18);\n\n u = x0 + x3 | 0;\n x1 ^= u<<7 | u>>>(32-7);\n u = x1 + x0 | 0;\n x2 ^= u<<9 | u>>>(32-9);\n u = x2 + x1 | 0;\n x3 ^= u<<13 | u>>>(32-13);\n u = x3 + x2 | 0;\n x0 ^= u<<18 | u>>>(32-18);\n\n u = x5 + x4 | 0;\n x6 ^= u<<7 | u>>>(32-7);\n u = x6 + x5 | 0;\n x7 ^= u<<9 | u>>>(32-9);\n u = x7 + x6 | 0;\n x4 ^= u<<13 | u>>>(32-13);\n u = x4 + x7 | 0;\n x5 ^= u<<18 | u>>>(32-18);\n\n u = x10 + x9 | 0;\n x11 ^= u<<7 | u>>>(32-7);\n u = x11 + x10 | 0;\n x8 ^= u<<9 | u>>>(32-9);\n u = x8 + x11 | 0;\n x9 ^= u<<13 | u>>>(32-13);\n u = x9 + x8 | 0;\n x10 ^= u<<18 | u>>>(32-18);\n\n u = x15 + x14 | 0;\n x12 ^= u<<7 | u>>>(32-7);\n u = x12 + x15 | 0;\n x13 ^= u<<9 | u>>>(32-9);\n u = x13 + x12 | 0;\n x14 ^= u<<13 | u>>>(32-13);\n u = x14 + x13 | 0;\n x15 ^= u<<18 | u>>>(32-18);\n }\n\n o[ 0] = x0 >>> 0 & 0xff;\n o[ 1] = x0 >>> 8 & 0xff;\n o[ 2] = x0 >>> 16 & 0xff;\n o[ 3] = x0 >>> 24 & 0xff;\n\n o[ 4] = x5 >>> 0 & 0xff;\n o[ 5] = x5 >>> 8 & 0xff;\n o[ 6] = x5 >>> 16 & 0xff;\n o[ 7] = x5 >>> 24 & 0xff;\n\n o[ 8] = x10 >>> 0 & 0xff;\n o[ 9] = x10 >>> 8 & 0xff;\n o[10] = x10 >>> 16 & 0xff;\n o[11] = x10 >>> 24 & 0xff;\n\n o[12] = x15 >>> 0 & 0xff;\n o[13] = x15 >>> 8 & 0xff;\n o[14] = x15 >>> 16 & 0xff;\n o[15] = x15 >>> 24 & 0xff;\n\n o[16] = x6 >>> 0 & 0xff;\n o[17] = x6 >>> 8 & 0xff;\n o[18] = x6 >>> 16 & 0xff;\n o[19] = x6 >>> 24 & 0xff;\n\n o[20] = x7 >>> 0 & 0xff;\n o[21] = x7 >>> 8 & 0xff;\n o[22] = x7 >>> 16 & 0xff;\n o[23] = x7 >>> 24 & 0xff;\n\n o[24] = x8 >>> 0 & 0xff;\n o[25] = x8 >>> 8 & 0xff;\n o[26] = x8 >>> 16 & 0xff;\n o[27] = x8 >>> 24 & 0xff;\n\n o[28] = x9 >>> 0 & 0xff;\n o[29] = x9 >>> 8 & 0xff;\n o[30] = x9 >>> 16 & 0xff;\n o[31] = x9 >>> 24 & 0xff;\n}\n\nfunction crypto_core_salsa20(out,inp,k,c) {\n core_salsa20(out,inp,k,c);\n}\n\nfunction crypto_core_hsalsa20(out,inp,k,c) {\n core_hsalsa20(out,inp,k,c);\n}\n\nvar sigma = new Uint8Array([101, 120, 112, 97, 110, 100, 32, 51, 50, 45, 98, 121, 116, 101, 32, 107]);\n // \"expand 32-byte k\"\n\nfunction crypto_stream_salsa20_xor(c,cpos,m,mpos,b,n,k) {\n var z = new Uint8Array(16), x = new Uint8Array(64);\n var u, i;\n for (i = 0; i < 16; i++) z[i] = 0;\n for (i = 0; i < 8; i++) z[i] = n[i];\n while (b >= 64) {\n crypto_core_salsa20(x,z,k,sigma);\n for (i = 0; i < 64; i++) c[cpos+i] = m[mpos+i] ^ x[i];\n u = 1;\n for (i = 8; i < 16; i++) {\n u = u + (z[i] & 0xff) | 0;\n z[i] = u & 0xff;\n u >>>= 8;\n }\n b -= 64;\n cpos += 64;\n mpos += 64;\n }\n if (b > 0) {\n crypto_core_salsa20(x,z,k,sigma);\n for (i = 0; i < b; i++) c[cpos+i] = m[mpos+i] ^ x[i];\n }\n return 0;\n}\n\nfunction crypto_stream_salsa20(c,cpos,b,n,k) {\n var z = new Uint8Array(16), x = new Uint8Array(64);\n var u, i;\n for (i = 0; i < 16; i++) z[i] = 0;\n for (i = 0; i < 8; i++) z[i] = n[i];\n while (b >= 64) {\n crypto_core_salsa20(x,z,k,sigma);\n for (i = 0; i < 64; i++) c[cpos+i] = x[i];\n u = 1;\n for (i = 8; i < 16; i++) {\n u = u + (z[i] & 0xff) | 0;\n z[i] = u & 0xff;\n u >>>= 8;\n }\n b -= 64;\n cpos += 64;\n }\n if (b > 0) {\n crypto_core_salsa20(x,z,k,sigma);\n for (i = 0; i < b; i++) c[cpos+i] = x[i];\n }\n return 0;\n}\n\nfunction crypto_stream(c,cpos,d,n,k) {\n var s = new Uint8Array(32);\n crypto_core_hsalsa20(s,n,k,sigma);\n var sn = new Uint8Array(8);\n for (var i = 0; i < 8; i++) sn[i] = n[i+16];\n return crypto_stream_salsa20(c,cpos,d,sn,s);\n}\n\nfunction crypto_stream_xor(c,cpos,m,mpos,d,n,k) {\n var s = new Uint8Array(32);\n crypto_core_hsalsa20(s,n,k,sigma);\n var sn = new Uint8Array(8);\n for (var i = 0; i < 8; i++) sn[i] = n[i+16];\n return crypto_stream_salsa20_xor(c,cpos,m,mpos,d,sn,s);\n}\n\n/*\n* Port of Andrew Moon's Poly1305-donna-16. Public domain.\n* https://github.com/floodyberry/poly1305-donna\n*/\n\nvar poly1305 = function(key) {\n this.buffer = new Uint8Array(16);\n this.r = new Uint16Array(10);\n this.h = new Uint16Array(10);\n this.pad = new Uint16Array(8);\n this.leftover = 0;\n this.fin = 0;\n\n var t0, t1, t2, t3, t4, t5, t6, t7;\n\n t0 = key[ 0] & 0xff | (key[ 1] & 0xff) << 8; this.r[0] = ( t0 ) & 0x1fff;\n t1 = key[ 2] & 0xff | (key[ 3] & 0xff) << 8; this.r[1] = ((t0 >>> 13) | (t1 << 3)) & 0x1fff;\n t2 = key[ 4] & 0xff | (key[ 5] & 0xff) << 8; this.r[2] = ((t1 >>> 10) | (t2 << 6)) & 0x1f03;\n t3 = key[ 6] & 0xff | (key[ 7] & 0xff) << 8; this.r[3] = ((t2 >>> 7) | (t3 << 9)) & 0x1fff;\n t4 = key[ 8] & 0xff | (key[ 9] & 0xff) << 8; this.r[4] = ((t3 >>> 4) | (t4 << 12)) & 0x00ff;\n this.r[5] = ((t4 >>> 1)) & 0x1ffe;\n t5 = key[10] & 0xff | (key[11] & 0xff) << 8; this.r[6] = ((t4 >>> 14) | (t5 << 2)) & 0x1fff;\n t6 = key[12] & 0xff | (key[13] & 0xff) << 8; this.r[7] = ((t5 >>> 11) | (t6 << 5)) & 0x1f81;\n t7 = key[14] & 0xff | (key[15] & 0xff) << 8; this.r[8] = ((t6 >>> 8) | (t7 << 8)) & 0x1fff;\n this.r[9] = ((t7 >>> 5)) & 0x007f;\n\n this.pad[0] = key[16] & 0xff | (key[17] & 0xff) << 8;\n this.pad[1] = key[18] & 0xff | (key[19] & 0xff) << 8;\n this.pad[2] = key[20] & 0xff | (key[21] & 0xff) << 8;\n this.pad[3] = key[22] & 0xff | (key[23] & 0xff) << 8;\n this.pad[4] = key[24] & 0xff | (key[25] & 0xff) << 8;\n this.pad[5] = key[26] & 0xff | (key[27] & 0xff) << 8;\n this.pad[6] = key[28] & 0xff | (key[29] & 0xff) << 8;\n this.pad[7] = key[30] & 0xff | (key[31] & 0xff) << 8;\n};\n\npoly1305.prototype.blocks = function(m, mpos, bytes) {\n var hibit = this.fin ? 0 : (1 << 11);\n var t0, t1, t2, t3, t4, t5, t6, t7, c;\n var d0, d1, d2, d3, d4, d5, d6, d7, d8, d9;\n\n var h0 = this.h[0],\n h1 = this.h[1],\n h2 = this.h[2],\n h3 = this.h[3],\n h4 = this.h[4],\n h5 = this.h[5],\n h6 = this.h[6],\n h7 = this.h[7],\n h8 = this.h[8],\n h9 = this.h[9];\n\n var r0 = this.r[0],\n r1 = this.r[1],\n r2 = this.r[2],\n r3 = this.r[3],\n r4 = this.r[4],\n r5 = this.r[5],\n r6 = this.r[6],\n r7 = this.r[7],\n r8 = this.r[8],\n r9 = this.r[9];\n\n while (bytes >= 16) {\n t0 = m[mpos+ 0] & 0xff | (m[mpos+ 1] & 0xff) << 8; h0 += ( t0 ) & 0x1fff;\n t1 = m[mpos+ 2] & 0xff | (m[mpos+ 3] & 0xff) << 8; h1 += ((t0 >>> 13) | (t1 << 3)) & 0x1fff;\n t2 = m[mpos+ 4] & 0xff | (m[mpos+ 5] & 0xff) << 8; h2 += ((t1 >>> 10) | (t2 << 6)) & 0x1fff;\n t3 = m[mpos+ 6] & 0xff | (m[mpos+ 7] & 0xff) << 8; h3 += ((t2 >>> 7) | (t3 << 9)) & 0x1fff;\n t4 = m[mpos+ 8] & 0xff | (m[mpos+ 9] & 0xff) << 8; h4 += ((t3 >>> 4) | (t4 << 12)) & 0x1fff;\n h5 += ((t4 >>> 1)) & 0x1fff;\n t5 = m[mpos+10] & 0xff | (m[mpos+11] & 0xff) << 8; h6 += ((t4 >>> 14) | (t5 << 2)) & 0x1fff;\n t6 = m[mpos+12] & 0xff | (m[mpos+13] & 0xff) << 8; h7 += ((t5 >>> 11) | (t6 << 5)) & 0x1fff;\n t7 = m[mpos+14] & 0xff | (m[mpos+15] & 0xff) << 8; h8 += ((t6 >>> 8) | (t7 << 8)) & 0x1fff;\n h9 += ((t7 >>> 5)) | hibit;\n\n c = 0;\n\n d0 = c;\n d0 += h0 * r0;\n d0 += h1 * (5 * r9);\n d0 += h2 * (5 * r8);\n d0 += h3 * (5 * r7);\n d0 += h4 * (5 * r6);\n c = (d0 >>> 13); d0 &= 0x1fff;\n d0 += h5 * (5 * r5);\n d0 += h6 * (5 * r4);\n d0 += h7 * (5 * r3);\n d0 += h8 * (5 * r2);\n d0 += h9 * (5 * r1);\n c += (d0 >>> 13); d0 &= 0x1fff;\n\n d1 = c;\n d1 += h0 * r1;\n d1 += h1 * r0;\n d1 += h2 * (5 * r9);\n d1 += h3 * (5 * r8);\n d1 += h4 * (5 * r7);\n c = (d1 >>> 13); d1 &= 0x1fff;\n d1 += h5 * (5 * r6);\n d1 += h6 * (5 * r5);\n d1 += h7 * (5 * r4);\n d1 += h8 * (5 * r3);\n d1 += h9 * (5 * r2);\n c += (d1 >>> 13); d1 &= 0x1fff;\n\n d2 = c;\n d2 += h0 * r2;\n d2 += h1 * r1;\n d2 += h2 * r0;\n d2 += h3 * (5 * r9);\n d2 += h4 * (5 * r8);\n c = (d2 >>> 13); d2 &= 0x1fff;\n d2 += h5 * (5 * r7);\n d2 += h6 * (5 * r6);\n d2 += h7 * (5 * r5);\n d2 += h8 * (5 * r4);\n d2 += h9 * (5 * r3);\n c += (d2 >>> 13); d2 &= 0x1fff;\n\n d3 = c;\n d3 += h0 * r3;\n d3 += h1 * r2;\n d3 += h2 * r1;\n d3 += h3 * r0;\n d3 += h4 * (5 * r9);\n c = (d3 >>> 13); d3 &= 0x1fff;\n d3 += h5 * (5 * r8);\n d3 += h6 * (5 * r7);\n d3 += h7 * (5 * r6);\n d3 += h8 * (5 * r5);\n d3 += h9 * (5 * r4);\n c += (d3 >>> 13); d3 &= 0x1fff;\n\n d4 = c;\n d4 += h0 * r4;\n d4 += h1 * r3;\n d4 += h2 * r2;\n d4 += h3 * r1;\n d4 += h4 * r0;\n c = (d4 >>> 13); d4 &= 0x1fff;\n d4 += h5 * (5 * r9);\n d4 += h6 * (5 * r8);\n d4 += h7 * (5 * r7);\n d4 += h8 * (5 * r6);\n d4 += h9 * (5 * r5);\n c += (d4 >>> 13); d4 &= 0x1fff;\n\n d5 = c;\n d5 += h0 * r5;\n d5 += h1 * r4;\n d5 += h2 * r3;\n d5 += h3 * r2;\n d5 += h4 * r1;\n c = (d5 >>> 13); d5 &= 0x1fff;\n d5 += h5 * r0;\n d5 += h6 * (5 * r9);\n d5 += h7 * (5 * r8);\n d5 += h8 * (5 * r7);\n d5 += h9 * (5 * r6);\n c += (d5 >>> 13); d5 &= 0x1fff;\n\n d6 = c;\n d6 += h0 * r6;\n d6 += h1 * r5;\n d6 += h2 * r4;\n d6 += h3 * r3;\n d6 += h4 * r2;\n c = (d6 >>> 13); d6 &= 0x1fff;\n d6 += h5 * r1;\n d6 += h6 * r0;\n d6 += h7 * (5 * r9);\n d6 += h8 * (5 * r8);\n d6 += h9 * (5 * r7);\n c += (d6 >>> 13); d6 &= 0x1fff;\n\n d7 = c;\n d7 += h0 * r7;\n d7 += h1 * r6;\n d7 += h2 * r5;\n d7 += h3 * r4;\n d7 += h4 * r3;\n c = (d7 >>> 13); d7 &= 0x1fff;\n d7 += h5 * r2;\n d7 += h6 * r1;\n d7 += h7 * r0;\n d7 += h8 * (5 * r9);\n d7 += h9 * (5 * r8);\n c += (d7 >>> 13); d7 &= 0x1fff;\n\n d8 = c;\n d8 += h0 * r8;\n d8 += h1 * r7;\n d8 += h2 * r6;\n d8 += h3 * r5;\n d8 += h4 * r4;\n c = (d8 >>> 13); d8 &= 0x1fff;\n d8 += h5 * r3;\n d8 += h6 * r2;\n d8 += h7 * r1;\n d8 += h8 * r0;\n d8 += h9 * (5 * r9);\n c += (d8 >>> 13); d8 &= 0x1fff;\n\n d9 = c;\n d9 += h0 * r9;\n d9 += h1 * r8;\n d9 += h2 * r7;\n d9 += h3 * r6;\n d9 += h4 * r5;\n c = (d9 >>> 13); d9 &= 0x1fff;\n d9 += h5 * r4;\n d9 += h6 * r3;\n d9 += h7 * r2;\n d9 += h8 * r1;\n d9 += h9 * r0;\n c += (d9 >>> 13); d9 &= 0x1fff;\n\n c = (((c << 2) + c)) | 0;\n c = (c + d0) | 0;\n d0 = c & 0x1fff;\n c = (c >>> 13);\n d1 += c;\n\n h0 = d0;\n h1 = d1;\n h2 = d2;\n h3 = d3;\n h4 = d4;\n h5 = d5;\n h6 = d6;\n h7 = d7;\n h8 = d8;\n h9 = d9;\n\n mpos += 16;\n bytes -= 16;\n }\n this.h[0] = h0;\n this.h[1] = h1;\n this.h[2] = h2;\n this.h[3] = h3;\n this.h[4] = h4;\n this.h[5] = h5;\n this.h[6] = h6;\n this.h[7] = h7;\n this.h[8] = h8;\n this.h[9] = h9;\n};\n\npoly1305.prototype.finish = function(mac, macpos) {\n var g = new Uint16Array(10);\n var c, mask, f, i;\n\n if (this.leftover) {\n i = this.leftover;\n this.buffer[i++] = 1;\n for (; i < 16; i++) this.buffer[i] = 0;\n this.fin = 1;\n this.blocks(this.buffer, 0, 16);\n }\n\n c = this.h[1] >>> 13;\n this.h[1] &= 0x1fff;\n for (i = 2; i < 10; i++) {\n this.h[i] += c;\n c = this.h[i] >>> 13;\n this.h[i] &= 0x1fff;\n }\n this.h[0] += (c * 5);\n c = this.h[0] >>> 13;\n this.h[0] &= 0x1fff;\n this.h[1] += c;\n c = this.h[1] >>> 13;\n this.h[1] &= 0x1fff;\n this.h[2] += c;\n\n g[0] = this.h[0] + 5;\n c = g[0] >>> 13;\n g[0] &= 0x1fff;\n for (i = 1; i < 10; i++) {\n g[i] = this.h[i] + c;\n c = g[i] >>> 13;\n g[i] &= 0x1fff;\n }\n g[9] -= (1 << 13);\n\n mask = (c ^ 1) - 1;\n for (i = 0; i < 10; i++) g[i] &= mask;\n mask = ~mask;\n for (i = 0; i < 10; i++) this.h[i] = (this.h[i] & mask) | g[i];\n\n this.h[0] = ((this.h[0] ) | (this.h[1] << 13) ) & 0xffff;\n this.h[1] = ((this.h[1] >>> 3) | (this.h[2] << 10) ) & 0xffff;\n this.h[2] = ((this.h[2] >>> 6) | (this.h[3] << 7) ) & 0xffff;\n this.h[3] = ((this.h[3] >>> 9) | (this.h[4] << 4) ) & 0xffff;\n this.h[4] = ((this.h[4] >>> 12) | (this.h[5] << 1) | (this.h[6] << 14)) & 0xffff;\n this.h[5] = ((this.h[6] >>> 2) | (this.h[7] << 11) ) & 0xffff;\n this.h[6] = ((this.h[7] >>> 5) | (this.h[8] << 8) ) & 0xffff;\n this.h[7] = ((this.h[8] >>> 8) | (this.h[9] << 5) ) & 0xffff;\n\n f = this.h[0] + this.pad[0];\n this.h[0] = f & 0xffff;\n for (i = 1; i < 8; i++) {\n f = (((this.h[i] + this.pad[i]) | 0) + (f >>> 16)) | 0;\n this.h[i] = f & 0xffff;\n }\n\n mac[macpos+ 0] = (this.h[0] >>> 0) & 0xff;\n mac[macpos+ 1] = (this.h[0] >>> 8) & 0xff;\n mac[macpos+ 2] = (this.h[1] >>> 0) & 0xff;\n mac[macpos+ 3] = (this.h[1] >>> 8) & 0xff;\n mac[macpos+ 4] = (this.h[2] >>> 0) & 0xff;\n mac[macpos+ 5] = (this.h[2] >>> 8) & 0xff;\n mac[macpos+ 6] = (this.h[3] >>> 0) & 0xff;\n mac[macpos+ 7] = (this.h[3] >>> 8) & 0xff;\n mac[macpos+ 8] = (this.h[4] >>> 0) & 0xff;\n mac[macpos+ 9] = (this.h[4] >>> 8) & 0xff;\n mac[macpos+10] = (this.h[5] >>> 0) & 0xff;\n mac[macpos+11] = (this.h[5] >>> 8) & 0xff;\n mac[macpos+12] = (this.h[6] >>> 0) & 0xff;\n mac[macpos+13] = (this.h[6] >>> 8) & 0xff;\n mac[macpos+14] = (this.h[7] >>> 0) & 0xff;\n mac[macpos+15] = (this.h[7] >>> 8) & 0xff;\n};\n\npoly1305.prototype.update = function(m, mpos, bytes) {\n var i, want;\n\n if (this.leftover) {\n want = (16 - this.leftover);\n if (want > bytes)\n want = bytes;\n for (i = 0; i < want; i++)\n this.buffer[this.leftover + i] = m[mpos+i];\n bytes -= want;\n mpos += want;\n this.leftover += want;\n if (this.leftover < 16)\n return;\n this.blocks(this.buffer, 0, 16);\n this.leftover = 0;\n }\n\n if (bytes >= 16) {\n want = bytes - (bytes % 16);\n this.blocks(m, mpos, want);\n mpos += want;\n bytes -= want;\n }\n\n if (bytes) {\n for (i = 0; i < bytes; i++)\n this.buffer[this.leftover + i] = m[mpos+i];\n this.leftover += bytes;\n }\n};\n\nfunction crypto_onetimeauth(out, outpos, m, mpos, n, k) {\n var s = new poly1305(k);\n s.update(m, mpos, n);\n s.finish(out, outpos);\n return 0;\n}\n\nfunction crypto_onetimeauth_verify(h, hpos, m, mpos, n, k) {\n var x = new Uint8Array(16);\n crypto_onetimeauth(x,0,m,mpos,n,k);\n return crypto_verify_16(h,hpos,x,0);\n}\n\nfunction crypto_secretbox(c,m,d,n,k) {\n var i;\n if (d < 32) return -1;\n crypto_stream_xor(c,0,m,0,d,n,k);\n crypto_onetimeauth(c, 16, c, 32, d - 32, c);\n for (i = 0; i < 16; i++) c[i] = 0;\n return 0;\n}\n\nfunction crypto_secretbox_open(m,c,d,n,k) {\n var i;\n var x = new Uint8Array(32);\n if (d < 32) return -1;\n crypto_stream(x,0,32,n,k);\n if (crypto_onetimeauth_verify(c, 16,c, 32,d - 32,x) !== 0) return -1;\n crypto_stream_xor(m,0,c,0,d,n,k);\n for (i = 0; i < 32; i++) m[i] = 0;\n return 0;\n}\n\nfunction set25519(r, a) {\n var i;\n for (i = 0; i < 16; i++) r[i] = a[i]|0;\n}\n\nfunction car25519(o) {\n var i, v, c = 1;\n for (i = 0; i < 16; i++) {\n v = o[i] + c + 65535;\n c = Math.floor(v / 65536);\n o[i] = v - c * 65536;\n }\n o[0] += c-1 + 37 * (c-1);\n}\n\nfunction sel25519(p, q, b) {\n var t, c = ~(b-1);\n for (var i = 0; i < 16; i++) {\n t = c & (p[i] ^ q[i]);\n p[i] ^= t;\n q[i] ^= t;\n }\n}\n\nfunction pack25519(o, n) {\n var i, j, b;\n var m = gf(), t = gf();\n for (i = 0; i < 16; i++) t[i] = n[i];\n car25519(t);\n car25519(t);\n car25519(t);\n for (j = 0; j < 2; j++) {\n m[0] = t[0] - 0xffed;\n for (i = 1; i < 15; i++) {\n m[i] = t[i] - 0xffff - ((m[i-1]>>16) & 1);\n m[i-1] &= 0xffff;\n }\n m[15] = t[15] - 0x7fff - ((m[14]>>16) & 1);\n b = (m[15]>>16) & 1;\n m[14] &= 0xffff;\n sel25519(t, m, 1-b);\n }\n for (i = 0; i < 16; i++) {\n o[2*i] = t[i] & 0xff;\n o[2*i+1] = t[i]>>8;\n }\n}\n\nfunction neq25519(a, b) {\n var c = new Uint8Array(32), d = new Uint8Array(32);\n pack25519(c, a);\n pack25519(d, b);\n return crypto_verify_32(c, 0, d, 0);\n}\n\nfunction par25519(a) {\n var d = new Uint8Array(32);\n pack25519(d, a);\n return d[0] & 1;\n}\n\nfunction unpack25519(o, n) {\n var i;\n for (i = 0; i < 16; i++) o[i] = n[2*i] + (n[2*i+1] << 8);\n o[15] &= 0x7fff;\n}\n\nfunction A(o, a, b) {\n for (var i = 0; i < 16; i++) o[i] = a[i] + b[i];\n}\n\nfunction Z(o, a, b) {\n for (var i = 0; i < 16; i++) o[i] = a[i] - b[i];\n}\n\nfunction M(o, a, b) {\n var v, c,\n t0 = 0, t1 = 0, t2 = 0, t3 = 0, t4 = 0, t5 = 0, t6 = 0, t7 = 0,\n t8 = 0, t9 = 0, t10 = 0, t11 = 0, t12 = 0, t13 = 0, t14 = 0, t15 = 0,\n t16 = 0, t17 = 0, t18 = 0, t19 = 0, t20 = 0, t21 = 0, t22 = 0, t23 = 0,\n t24 = 0, t25 = 0, t26 = 0, t27 = 0, t28 = 0, t29 = 0, t30 = 0,\n b0 = b[0],\n b1 = b[1],\n b2 = b[2],\n b3 = b[3],\n b4 = b[4],\n b5 = b[5],\n b6 = b[6],\n b7 = b[7],\n b8 = b[8],\n b9 = b[9],\n b10 = b[10],\n b11 = b[11],\n b12 = b[12],\n b13 = b[13],\n b14 = b[14],\n b15 = b[15];\n\n v = a[0];\n t0 += v * b0;\n t1 += v * b1;\n t2 += v * b2;\n t3 += v * b3;\n t4 += v * b4;\n t5 += v * b5;\n t6 += v * b6;\n t7 += v * b7;\n t8 += v * b8;\n t9 += v * b9;\n t10 += v * b10;\n t11 += v * b11;\n t12 += v * b12;\n t13 += v * b13;\n t14 += v * b14;\n t15 += v * b15;\n v = a[1];\n t1 += v * b0;\n t2 += v * b1;\n t3 += v * b2;\n t4 += v * b3;\n t5 += v * b4;\n t6 += v * b5;\n t7 += v * b6;\n t8 += v * b7;\n t9 += v * b8;\n t10 += v * b9;\n t11 += v * b10;\n t12 += v * b11;\n t13 += v * b12;\n t14 += v * b13;\n t15 += v * b14;\n t16 += v * b15;\n v = a[2];\n t2 += v * b0;\n t3 += v * b1;\n t4 += v * b2;\n t5 += v * b3;\n t6 += v * b4;\n t7 += v * b5;\n t8 += v * b6;\n t9 += v * b7;\n t10 += v * b8;\n t11 += v * b9;\n t12 += v * b10;\n t13 += v * b11;\n t14 += v * b12;\n t15 += v * b13;\n t16 += v * b14;\n t17 += v * b15;\n v = a[3];\n t3 += v * b0;\n t4 += v * b1;\n t5 += v * b2;\n t6 += v * b3;\n t7 += v * b4;\n t8 += v * b5;\n t9 += v * b6;\n t10 += v * b7;\n t11 += v * b8;\n t12 += v * b9;\n t13 += v * b10;\n t14 += v * b11;\n t15 += v * b12;\n t16 += v * b13;\n t17 += v * b14;\n t18 += v * b15;\n v = a[4];\n t4 += v * b0;\n t5 += v * b1;\n t6 += v * b2;\n t7 += v * b3;\n t8 += v * b4;\n t9 += v * b5;\n t10 += v * b6;\n t11 += v * b7;\n t12 += v * b8;\n t13 += v * b9;\n t14 += v * b10;\n t15 += v * b11;\n t16 += v * b12;\n t17 += v * b13;\n t18 += v * b14;\n t19 += v * b15;\n v = a[5];\n t5 += v * b0;\n t6 += v * b1;\n t7 += v * b2;\n t8 += v * b3;\n t9 += v * b4;\n t10 += v * b5;\n t11 += v * b6;\n t12 += v * b7;\n t13 += v * b8;\n t14 += v * b9;\n t15 += v * b10;\n t16 += v * b11;\n t17 += v * b12;\n t18 += v * b13;\n t19 += v * b14;\n t20 += v * b15;\n v = a[6];\n t6 += v * b0;\n t7 += v * b1;\n t8 += v * b2;\n t9 += v * b3;\n t10 += v * b4;\n t11 += v * b5;\n t12 += v * b6;\n t13 += v * b7;\n t14 += v * b8;\n t15 += v * b9;\n t16 += v * b10;\n t17 += v * b11;\n t18 += v * b12;\n t19 += v * b13;\n t20 += v * b14;\n t21 += v * b15;\n v = a[7];\n t7 += v * b0;\n t8 += v * b1;\n t9 += v * b2;\n t10 += v * b3;\n t11 += v * b4;\n t12 += v * b5;\n t13 += v * b6;\n t14 += v * b7;\n t15 += v * b8;\n t16 += v * b9;\n t17 += v * b10;\n t18 += v * b11;\n t19 += v * b12;\n t20 += v * b13;\n t21 += v * b14;\n t22 += v * b15;\n v = a[8];\n t8 += v * b0;\n t9 += v * b1;\n t10 += v * b2;\n t11 += v * b3;\n t12 += v * b4;\n t13 += v * b5;\n t14 += v * b6;\n t15 += v * b7;\n t16 += v * b8;\n t17 += v * b9;\n t18 += v * b10;\n t19 += v * b11;\n t20 += v * b12;\n t21 += v * b13;\n t22 += v * b14;\n t23 += v * b15;\n v = a[9];\n t9 += v * b0;\n t10 += v * b1;\n t11 += v * b2;\n t12 += v * b3;\n t13 += v * b4;\n t14 += v * b5;\n t15 += v * b6;\n t16 += v * b7;\n t17 += v * b8;\n t18 += v * b9;\n t19 += v * b10;\n t20 += v * b11;\n t21 += v * b12;\n t22 += v * b13;\n t23 += v * b14;\n t24 += v * b15;\n v = a[10];\n t10 += v * b0;\n t11 += v * b1;\n t12 += v * b2;\n t13 += v * b3;\n t14 += v * b4;\n t15 += v * b5;\n t16 += v * b6;\n t17 += v * b7;\n t18 += v * b8;\n t19 += v * b9;\n t20 += v * b10;\n t21 += v * b11;\n t22 += v * b12;\n t23 += v * b13;\n t24 += v * b14;\n t25 += v * b15;\n v = a[11];\n t11 += v * b0;\n t12 += v * b1;\n t13 += v * b2;\n t14 += v * b3;\n t15 += v * b4;\n t16 += v * b5;\n t17 += v * b6;\n t18 += v * b7;\n t19 += v * b8;\n t20 += v * b9;\n t21 += v * b10;\n t22 += v * b11;\n t23 += v * b12;\n t24 += v * b13;\n t25 += v * b14;\n t26 += v * b15;\n v = a[12];\n t12 += v * b0;\n t13 += v * b1;\n t14 += v * b2;\n t15 += v * b3;\n t16 += v * b4;\n t17 += v * b5;\n t18 += v * b6;\n t19 += v * b7;\n t20 += v * b8;\n t21 += v * b9;\n t22 += v * b10;\n t23 += v * b11;\n t24 += v * b12;\n t25 += v * b13;\n t26 += v * b14;\n t27 += v * b15;\n v = a[13];\n t13 += v * b0;\n t14 += v * b1;\n t15 += v * b2;\n t16 += v * b3;\n t17 += v * b4;\n t18 += v * b5;\n t19 += v * b6;\n t20 += v * b7;\n t21 += v * b8;\n t22 += v * b9;\n t23 += v * b10;\n t24 += v * b11;\n t25 += v * b12;\n t26 += v * b13;\n t27 += v * b14;\n t28 += v * b15;\n v = a[14];\n t14 += v * b0;\n t15 += v * b1;\n t16 += v * b2;\n t17 += v * b3;\n t18 += v * b4;\n t19 += v * b5;\n t20 += v * b6;\n t21 += v * b7;\n t22 += v * b8;\n t23 += v * b9;\n t24 += v * b10;\n t25 += v * b11;\n t26 += v * b12;\n t27 += v * b13;\n t28 += v * b14;\n t29 += v * b15;\n v = a[15];\n t15 += v * b0;\n t16 += v * b1;\n t17 += v * b2;\n t18 += v * b3;\n t19 += v * b4;\n t20 += v * b5;\n t21 += v * b6;\n t22 += v * b7;\n t23 += v * b8;\n t24 += v * b9;\n t25 += v * b10;\n t26 += v * b11;\n t27 += v * b12;\n t28 += v * b13;\n t29 += v * b14;\n t30 += v * b15;\n\n t0 += 38 * t16;\n t1 += 38 * t17;\n t2 += 38 * t18;\n t3 += 38 * t19;\n t4 += 38 * t20;\n t5 += 38 * t21;\n t6 += 38 * t22;\n t7 += 38 * t23;\n t8 += 38 * t24;\n t9 += 38 * t25;\n t10 += 38 * t26;\n t11 += 38 * t27;\n t12 += 38 * t28;\n t13 += 38 * t29;\n t14 += 38 * t30;\n // t15 left as is\n\n // first car\n c = 1;\n v = t0 + c + 65535; c = Math.floor(v / 65536); t0 = v - c * 65536;\n v = t1 + c + 65535; c = Math.floor(v / 65536); t1 = v - c * 65536;\n v = t2 + c + 65535; c = Math.floor(v / 65536); t2 = v - c * 65536;\n v = t3 + c + 65535; c = Math.floor(v / 65536); t3 = v - c * 65536;\n v = t4 + c + 65535; c = Math.floor(v / 65536); t4 = v - c * 65536;\n v = t5 + c + 65535; c = Math.floor(v / 65536); t5 = v - c * 65536;\n v = t6 + c + 65535; c = Math.floor(v / 65536); t6 = v - c * 65536;\n v = t7 + c + 65535; c = Math.floor(v / 65536); t7 = v - c * 65536;\n v = t8 + c + 65535; c = Math.floor(v / 65536); t8 = v - c * 65536;\n v = t9 + c + 65535; c = Math.floor(v / 65536); t9 = v - c * 65536;\n v = t10 + c + 65535; c = Math.floor(v / 65536); t10 = v - c * 65536;\n v = t11 + c + 65535; c = Math.floor(v / 65536); t11 = v - c * 65536;\n v = t12 + c + 65535; c = Math.floor(v / 65536); t12 = v - c * 65536;\n v = t13 + c + 65535; c = Math.floor(v / 65536); t13 = v - c * 65536;\n v = t14 + c + 65535; c = Math.floor(v / 65536); t14 = v - c * 65536;\n v = t15 + c + 65535; c = Math.floor(v / 65536); t15 = v - c * 65536;\n t0 += c-1 + 37 * (c-1);\n\n // second car\n c = 1;\n v = t0 + c + 65535; c = Math.floor(v / 65536); t0 = v - c * 65536;\n v = t1 + c + 65535; c = Math.floor(v / 65536); t1 = v - c * 65536;\n v = t2 + c + 65535; c = Math.floor(v / 65536); t2 = v - c * 65536;\n v = t3 + c + 65535; c = Math.floor(v / 65536); t3 = v - c * 65536;\n v = t4 + c + 65535; c = Math.floor(v / 65536); t4 = v - c * 65536;\n v = t5 + c + 65535; c = Math.floor(v / 65536); t5 = v - c * 65536;\n v = t6 + c + 65535; c = Math.floor(v / 65536); t6 = v - c * 65536;\n v = t7 + c + 65535; c = Math.floor(v / 65536); t7 = v - c * 65536;\n v = t8 + c + 65535; c = Math.floor(v / 65536); t8 = v - c * 65536;\n v = t9 + c + 65535; c = Math.floor(v / 65536); t9 = v - c * 65536;\n v = t10 + c + 65535; c = Math.floor(v / 65536); t10 = v - c * 65536;\n v = t11 + c + 65535; c = Math.floor(v / 65536); t11 = v - c * 65536;\n v = t12 + c + 65535; c = Math.floor(v / 65536); t12 = v - c * 65536;\n v = t13 + c + 65535; c = Math.floor(v / 65536); t13 = v - c * 65536;\n v = t14 + c + 65535; c = Math.floor(v / 65536); t14 = v - c * 65536;\n v = t15 + c + 65535; c = Math.floor(v / 65536); t15 = v - c * 65536;\n t0 += c-1 + 37 * (c-1);\n\n o[ 0] = t0;\n o[ 1] = t1;\n o[ 2] = t2;\n o[ 3] = t3;\n o[ 4] = t4;\n o[ 5] = t5;\n o[ 6] = t6;\n o[ 7] = t7;\n o[ 8] = t8;\n o[ 9] = t9;\n o[10] = t10;\n o[11] = t11;\n o[12] = t12;\n o[13] = t13;\n o[14] = t14;\n o[15] = t15;\n}\n\nfunction S(o, a) {\n M(o, a, a);\n}\n\nfunction inv25519(o, i) {\n var c = gf();\n var a;\n for (a = 0; a < 16; a++) c[a] = i[a];\n for (a = 253; a >= 0; a--) {\n S(c, c);\n if(a !== 2 && a !== 4) M(c, c, i);\n }\n for (a = 0; a < 16; a++) o[a] = c[a];\n}\n\nfunction pow2523(o, i) {\n var c = gf();\n var a;\n for (a = 0; a < 16; a++) c[a] = i[a];\n for (a = 250; a >= 0; a--) {\n S(c, c);\n if(a !== 1) M(c, c, i);\n }\n for (a = 0; a < 16; a++) o[a] = c[a];\n}\n\nfunction crypto_scalarmult(q, n, p) {\n var z = new Uint8Array(32);\n var x = new Float64Array(80), r, i;\n var a = gf(), b = gf(), c = gf(),\n d = gf(), e = gf(), f = gf();\n for (i = 0; i < 31; i++) z[i] = n[i];\n z[31]=(n[31]&127)|64;\n z[0]&=248;\n unpack25519(x,p);\n for (i = 0; i < 16; i++) {\n b[i]=x[i];\n d[i]=a[i]=c[i]=0;\n }\n a[0]=d[0]=1;\n for (i=254; i>=0; --i) {\n r=(z[i>>>3]>>>(i&7))&1;\n sel25519(a,b,r);\n sel25519(c,d,r);\n A(e,a,c);\n Z(a,a,c);\n A(c,b,d);\n Z(b,b,d);\n S(d,e);\n S(f,a);\n M(a,c,a);\n M(c,b,e);\n A(e,a,c);\n Z(a,a,c);\n S(b,a);\n Z(c,d,f);\n M(a,c,_121665);\n A(a,a,d);\n M(c,c,a);\n M(a,d,f);\n M(d,b,x);\n S(b,e);\n sel25519(a,b,r);\n sel25519(c,d,r);\n }\n for (i = 0; i < 16; i++) {\n x[i+16]=a[i];\n x[i+32]=c[i];\n x[i+48]=b[i];\n x[i+64]=d[i];\n }\n var x32 = x.subarray(32);\n var x16 = x.subarray(16);\n inv25519(x32,x32);\n M(x16,x16,x32);\n pack25519(q,x16);\n return 0;\n}\n\nfunction crypto_scalarmult_base(q, n) {\n return crypto_scalarmult(q, n, _9);\n}\n\nfunction crypto_box_keypair(y, x) {\n randombytes(x, 32);\n return crypto_scalarmult_base(y, x);\n}\n\nfunction crypto_box_beforenm(k, y, x) {\n var s = new Uint8Array(32);\n crypto_scalarmult(s, x, y);\n return crypto_core_hsalsa20(k, _0, s, sigma);\n}\n\nvar crypto_box_afternm = crypto_secretbox;\nvar crypto_box_open_afternm = crypto_secretbox_open;\n\nfunction crypto_box(c, m, d, n, y, x) {\n var k = new Uint8Array(32);\n crypto_box_beforenm(k, y, x);\n return crypto_box_afternm(c, m, d, n, k);\n}\n\nfunction crypto_box_open(m, c, d, n, y, x) {\n var k = new Uint8Array(32);\n crypto_box_beforenm(k, y, x);\n return crypto_box_open_afternm(m, c, d, n, k);\n}\n\nvar K = [\n 0x428a2f98, 0xd728ae22, 0x71374491, 0x23ef65cd,\n 0xb5c0fbcf, 0xec4d3b2f, 0xe9b5dba5, 0x8189dbbc,\n 0x3956c25b, 0xf348b538, 0x59f111f1, 0xb605d019,\n 0x923f82a4, 0xaf194f9b, 0xab1c5ed5, 0xda6d8118,\n 0xd807aa98, 0xa3030242, 0x12835b01, 0x45706fbe,\n 0x243185be, 0x4ee4b28c, 0x550c7dc3, 0xd5ffb4e2,\n 0x72be5d74, 0xf27b896f, 0x80deb1fe, 0x3b1696b1,\n 0x9bdc06a7, 0x25c71235, 0xc19bf174, 0xcf692694,\n 0xe49b69c1, 0x9ef14ad2, 0xefbe4786, 0x384f25e3,\n 0x0fc19dc6, 0x8b8cd5b5, 0x240ca1cc, 0x77ac9c65,\n 0x2de92c6f, 0x592b0275, 0x4a7484aa, 0x6ea6e483,\n 0x5cb0a9dc, 0xbd41fbd4, 0x76f988da, 0x831153b5,\n 0x983e5152, 0xee66dfab, 0xa831c66d, 0x2db43210,\n 0xb00327c8, 0x98fb213f, 0xbf597fc7, 0xbeef0ee4,\n 0xc6e00bf3, 0x3da88fc2, 0xd5a79147, 0x930aa725,\n 0x06ca6351, 0xe003826f, 0x14292967, 0x0a0e6e70,\n 0x27b70a85, 0x46d22ffc, 0x2e1b2138, 0x5c26c926,\n 0x4d2c6dfc, 0x5ac42aed, 0x53380d13, 0x9d95b3df,\n 0x650a7354, 0x8baf63de, 0x766a0abb, 0x3c77b2a8,\n 0x81c2c92e, 0x47edaee6, 0x92722c85, 0x1482353b,\n 0xa2bfe8a1, 0x4cf10364, 0xa81a664b, 0xbc423001,\n 0xc24b8b70, 0xd0f89791, 0xc76c51a3, 0x0654be30,\n 0xd192e819, 0xd6ef5218, 0xd6990624, 0x5565a910,\n 0xf40e3585, 0x5771202a, 0x106aa070, 0x32bbd1b8,\n 0x19a4c116, 0xb8d2d0c8, 0x1e376c08, 0x5141ab53,\n 0x2748774c, 0xdf8eeb99, 0x34b0bcb5, 0xe19b48a8,\n 0x391c0cb3, 0xc5c95a63, 0x4ed8aa4a, 0xe3418acb,\n 0x5b9cca4f, 0x7763e373, 0x682e6ff3, 0xd6b2b8a3,\n 0x748f82ee, 0x5defb2fc, 0x78a5636f, 0x43172f60,\n 0x84c87814, 0xa1f0ab72, 0x8cc70208, 0x1a6439ec,\n 0x90befffa, 0x23631e28, 0xa4506ceb, 0xde82bde9,\n 0xbef9a3f7, 0xb2c67915, 0xc67178f2, 0xe372532b,\n 0xca273ece, 0xea26619c, 0xd186b8c7, 0x21c0c207,\n 0xeada7dd6, 0xcde0eb1e, 0xf57d4f7f, 0xee6ed178,\n 0x06f067aa, 0x72176fba, 0x0a637dc5, 0xa2c898a6,\n 0x113f9804, 0xbef90dae, 0x1b710b35, 0x131c471b,\n 0x28db77f5, 0x23047d84, 0x32caab7b, 0x40c72493,\n 0x3c9ebe0a, 0x15c9bebc, 0x431d67c4, 0x9c100d4c,\n 0x4cc5d4be, 0xcb3e42b6, 0x597f299c, 0xfc657e2a,\n 0x5fcb6fab, 0x3ad6faec, 0x6c44198c, 0x4a475817\n];\n\nfunction crypto_hashblocks_hl(hh, hl, m, n) {\n var wh = new Int32Array(16), wl = new Int32Array(16),\n bh0, bh1, bh2, bh3, bh4, bh5, bh6, bh7,\n bl0, bl1, bl2, bl3, bl4, bl5, bl6, bl7,\n th, tl, i, j, h, l, a, b, c, d;\n\n var ah0 = hh[0],\n ah1 = hh[1],\n ah2 = hh[2],\n ah3 = hh[3],\n ah4 = hh[4],\n ah5 = hh[5],\n ah6 = hh[6],\n ah7 = hh[7],\n\n al0 = hl[0],\n al1 = hl[1],\n al2 = hl[2],\n al3 = hl[3],\n al4 = hl[4],\n al5 = hl[5],\n al6 = hl[6],\n al7 = hl[7];\n\n var pos = 0;\n while (n >= 128) {\n for (i = 0; i < 16; i++) {\n j = 8 * i + pos;\n wh[i] = (m[j+0] << 24) | (m[j+1] << 16) | (m[j+2] << 8) | m[j+3];\n wl[i] = (m[j+4] << 24) | (m[j+5] << 16) | (m[j+6] << 8) | m[j+7];\n }\n for (i = 0; i < 80; i++) {\n bh0 = ah0;\n bh1 = ah1;\n bh2 = ah2;\n bh3 = ah3;\n bh4 = ah4;\n bh5 = ah5;\n bh6 = ah6;\n bh7 = ah7;\n\n bl0 = al0;\n bl1 = al1;\n bl2 = al2;\n bl3 = al3;\n bl4 = al4;\n bl5 = al5;\n bl6 = al6;\n bl7 = al7;\n\n // add\n h = ah7;\n l = al7;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n // Sigma1\n h = ((ah4 >>> 14) | (al4 << (32-14))) ^ ((ah4 >>> 18) | (al4 << (32-18))) ^ ((al4 >>> (41-32)) | (ah4 << (32-(41-32))));\n l = ((al4 >>> 14) | (ah4 << (32-14))) ^ ((al4 >>> 18) | (ah4 << (32-18))) ^ ((ah4 >>> (41-32)) | (al4 << (32-(41-32))));\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // Ch\n h = (ah4 & ah5) ^ (~ah4 & ah6);\n l = (al4 & al5) ^ (~al4 & al6);\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // K\n h = K[i*2];\n l = K[i*2+1];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // w\n h = wh[i%16];\n l = wl[i%16];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n th = c & 0xffff | d << 16;\n tl = a & 0xffff | b << 16;\n\n // add\n h = th;\n l = tl;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n // Sigma0\n h = ((ah0 >>> 28) | (al0 << (32-28))) ^ ((al0 >>> (34-32)) | (ah0 << (32-(34-32)))) ^ ((al0 >>> (39-32)) | (ah0 << (32-(39-32))));\n l = ((al0 >>> 28) | (ah0 << (32-28))) ^ ((ah0 >>> (34-32)) | (al0 << (32-(34-32)))) ^ ((ah0 >>> (39-32)) | (al0 << (32-(39-32))));\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // Maj\n h = (ah0 & ah1) ^ (ah0 & ah2) ^ (ah1 & ah2);\n l = (al0 & al1) ^ (al0 & al2) ^ (al1 & al2);\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n bh7 = (c & 0xffff) | (d << 16);\n bl7 = (a & 0xffff) | (b << 16);\n\n // add\n h = bh3;\n l = bl3;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = th;\n l = tl;\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n bh3 = (c & 0xffff) | (d << 16);\n bl3 = (a & 0xffff) | (b << 16);\n\n ah1 = bh0;\n ah2 = bh1;\n ah3 = bh2;\n ah4 = bh3;\n ah5 = bh4;\n ah6 = bh5;\n ah7 = bh6;\n ah0 = bh7;\n\n al1 = bl0;\n al2 = bl1;\n al3 = bl2;\n al4 = bl3;\n al5 = bl4;\n al6 = bl5;\n al7 = bl6;\n al0 = bl7;\n\n if (i%16 === 15) {\n for (j = 0; j < 16; j++) {\n // add\n h = wh[j];\n l = wl[j];\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = wh[(j+9)%16];\n l = wl[(j+9)%16];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // sigma0\n th = wh[(j+1)%16];\n tl = wl[(j+1)%16];\n h = ((th >>> 1) | (tl << (32-1))) ^ ((th >>> 8) | (tl << (32-8))) ^ (th >>> 7);\n l = ((tl >>> 1) | (th << (32-1))) ^ ((tl >>> 8) | (th << (32-8))) ^ ((tl >>> 7) | (th << (32-7)));\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // sigma1\n th = wh[(j+14)%16];\n tl = wl[(j+14)%16];\n h = ((th >>> 19) | (tl << (32-19))) ^ ((tl >>> (61-32)) | (th << (32-(61-32)))) ^ (th >>> 6);\n l = ((tl >>> 19) | (th << (32-19))) ^ ((th >>> (61-32)) | (tl << (32-(61-32)))) ^ ((tl >>> 6) | (th << (32-6)));\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n wh[j] = (c & 0xffff) | (d << 16);\n wl[j] = (a & 0xffff) | (b << 16);\n }\n }\n }\n\n // add\n h = ah0;\n l = al0;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[0];\n l = hl[0];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[0] = ah0 = (c & 0xffff) | (d << 16);\n hl[0] = al0 = (a & 0xffff) | (b << 16);\n\n h = ah1;\n l = al1;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[1];\n l = hl[1];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[1] = ah1 = (c & 0xffff) | (d << 16);\n hl[1] = al1 = (a & 0xffff) | (b << 16);\n\n h = ah2;\n l = al2;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[2];\n l = hl[2];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[2] = ah2 = (c & 0xffff) | (d << 16);\n hl[2] = al2 = (a & 0xffff) | (b << 16);\n\n h = ah3;\n l = al3;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[3];\n l = hl[3];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[3] = ah3 = (c & 0xffff) | (d << 16);\n hl[3] = al3 = (a & 0xffff) | (b << 16);\n\n h = ah4;\n l = al4;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[4];\n l = hl[4];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[4] = ah4 = (c & 0xffff) | (d << 16);\n hl[4] = al4 = (a & 0xffff) | (b << 16);\n\n h = ah5;\n l = al5;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[5];\n l = hl[5];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[5] = ah5 = (c & 0xffff) | (d << 16);\n hl[5] = al5 = (a & 0xffff) | (b << 16);\n\n h = ah6;\n l = al6;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[6];\n l = hl[6];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[6] = ah6 = (c & 0xffff) | (d << 16);\n hl[6] = al6 = (a & 0xffff) | (b << 16);\n\n h = ah7;\n l = al7;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[7];\n l = hl[7];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[7] = ah7 = (c & 0xffff) | (d << 16);\n hl[7] = al7 = (a & 0xffff) | (b << 16);\n\n pos += 128;\n n -= 128;\n }\n\n return n;\n}\n\nfunction crypto_hash(out, m, n) {\n var hh = new Int32Array(8),\n hl = new Int32Array(8),\n x = new Uint8Array(256),\n i, b = n;\n\n hh[0] = 0x6a09e667;\n hh[1] = 0xbb67ae85;\n hh[2] = 0x3c6ef372;\n hh[3] = 0xa54ff53a;\n hh[4] = 0x510e527f;\n hh[5] = 0x9b05688c;\n hh[6] = 0x1f83d9ab;\n hh[7] = 0x5be0cd19;\n\n hl[0] = 0xf3bcc908;\n hl[1] = 0x84caa73b;\n hl[2] = 0xfe94f82b;\n hl[3] = 0x5f1d36f1;\n hl[4] = 0xade682d1;\n hl[5] = 0x2b3e6c1f;\n hl[6] = 0xfb41bd6b;\n hl[7] = 0x137e2179;\n\n crypto_hashblocks_hl(hh, hl, m, n);\n n %= 128;\n\n for (i = 0; i < n; i++) x[i] = m[b-n+i];\n x[n] = 128;\n\n n = 256-128*(n<112?1:0);\n x[n-9] = 0;\n ts64(x, n-8, (b / 0x20000000) | 0, b << 3);\n crypto_hashblocks_hl(hh, hl, x, n);\n\n for (i = 0; i < 8; i++) ts64(out, 8*i, hh[i], hl[i]);\n\n return 0;\n}\n\nfunction add(p, q) {\n var a = gf(), b = gf(), c = gf(),\n d = gf(), e = gf(), f = gf(),\n g = gf(), h = gf(), t = gf();\n\n Z(a, p[1], p[0]);\n Z(t, q[1], q[0]);\n M(a, a, t);\n A(b, p[0], p[1]);\n A(t, q[0], q[1]);\n M(b, b, t);\n M(c, p[3], q[3]);\n M(c, c, D2);\n M(d, p[2], q[2]);\n A(d, d, d);\n Z(e, b, a);\n Z(f, d, c);\n A(g, d, c);\n A(h, b, a);\n\n M(p[0], e, f);\n M(p[1], h, g);\n M(p[2], g, f);\n M(p[3], e, h);\n}\n\nfunction cswap(p, q, b) {\n var i;\n for (i = 0; i < 4; i++) {\n sel25519(p[i], q[i], b);\n }\n}\n\nfunction pack(r, p) {\n var tx = gf(), ty = gf(), zi = gf();\n inv25519(zi, p[2]);\n M(tx, p[0], zi);\n M(ty, p[1], zi);\n pack25519(r, ty);\n r[31] ^= par25519(tx) << 7;\n}\n\nfunction scalarmult(p, q, s) {\n var b, i;\n set25519(p[0], gf0);\n set25519(p[1], gf1);\n set25519(p[2], gf1);\n set25519(p[3], gf0);\n for (i = 255; i >= 0; --i) {\n b = (s[(i/8)|0] >> (i&7)) & 1;\n cswap(p, q, b);\n add(q, p);\n add(p, p);\n cswap(p, q, b);\n }\n}\n\nfunction scalarbase(p, s) {\n var q = [gf(), gf(), gf(), gf()];\n set25519(q[0], X);\n set25519(q[1], Y);\n set25519(q[2], gf1);\n M(q[3], X, Y);\n scalarmult(p, q, s);\n}\n\nfunction crypto_sign_keypair(pk, sk, seeded) {\n var d = new Uint8Array(64);\n var p = [gf(), gf(), gf(), gf()];\n var i;\n\n if (!seeded) randombytes(sk, 32);\n crypto_hash(d, sk, 32);\n d[0] &= 248;\n d[31] &= 127;\n d[31] |= 64;\n\n scalarbase(p, d);\n pack(pk, p);\n\n for (i = 0; i < 32; i++) sk[i+32] = pk[i];\n return 0;\n}\n\nvar L = new Float64Array([0xed, 0xd3, 0xf5, 0x5c, 0x1a, 0x63, 0x12, 0x58, 0xd6, 0x9c, 0xf7, 0xa2, 0xde, 0xf9, 0xde, 0x14, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x10]);\n\nfunction modL(r, x) {\n var carry, i, j, k;\n for (i = 63; i >= 32; --i) {\n carry = 0;\n for (j = i - 32, k = i - 12; j < k; ++j) {\n x[j] += carry - 16 * x[i] * L[j - (i - 32)];\n carry = Math.floor((x[j] + 128) / 256);\n x[j] -= carry * 256;\n }\n x[j] += carry;\n x[i] = 0;\n }\n carry = 0;\n for (j = 0; j < 32; j++) {\n x[j] += carry - (x[31] >> 4) * L[j];\n carry = x[j] >> 8;\n x[j] &= 255;\n }\n for (j = 0; j < 32; j++) x[j] -= carry * L[j];\n for (i = 0; i < 32; i++) {\n x[i+1] += x[i] >> 8;\n r[i] = x[i] & 255;\n }\n}\n\nfunction reduce(r) {\n var x = new Float64Array(64), i;\n for (i = 0; i < 64; i++) x[i] = r[i];\n for (i = 0; i < 64; i++) r[i] = 0;\n modL(r, x);\n}\n\n// Note: difference from C - smlen returned, not passed as argument.\nfunction crypto_sign(sm, m, n, sk) {\n var d = new Uint8Array(64), h = new Uint8Array(64), r = new Uint8Array(64);\n var i, j, x = new Float64Array(64);\n var p = [gf(), gf(), gf(), gf()];\n\n crypto_hash(d, sk, 32);\n d[0] &= 248;\n d[31] &= 127;\n d[31] |= 64;\n\n var smlen = n + 64;\n for (i = 0; i < n; i++) sm[64 + i] = m[i];\n for (i = 0; i < 32; i++) sm[32 + i] = d[32 + i];\n\n crypto_hash(r, sm.subarray(32), n+32);\n reduce(r);\n scalarbase(p, r);\n pack(sm, p);\n\n for (i = 32; i < 64; i++) sm[i] = sk[i];\n crypto_hash(h, sm, n + 64);\n reduce(h);\n\n for (i = 0; i < 64; i++) x[i] = 0;\n for (i = 0; i < 32; i++) x[i] = r[i];\n for (i = 0; i < 32; i++) {\n for (j = 0; j < 32; j++) {\n x[i+j] += h[i] * d[j];\n }\n }\n\n modL(sm.subarray(32), x);\n return smlen;\n}\n\nfunction unpackneg(r, p) {\n var t = gf(), chk = gf(), num = gf(),\n den = gf(), den2 = gf(), den4 = gf(),\n den6 = gf();\n\n set25519(r[2], gf1);\n unpack25519(r[1], p);\n S(num, r[1]);\n M(den, num, D);\n Z(num, num, r[2]);\n A(den, r[2], den);\n\n S(den2, den);\n S(den4, den2);\n M(den6, den4, den2);\n M(t, den6, num);\n M(t, t, den);\n\n pow2523(t, t);\n M(t, t, num);\n M(t, t, den);\n M(t, t, den);\n M(r[0], t, den);\n\n S(chk, r[0]);\n M(chk, chk, den);\n if (neq25519(chk, num)) M(r[0], r[0], I);\n\n S(chk, r[0]);\n M(chk, chk, den);\n if (neq25519(chk, num)) return -1;\n\n if (par25519(r[0]) === (p[31]>>7)) Z(r[0], gf0, r[0]);\n\n M(r[3], r[0], r[1]);\n return 0;\n}\n\nfunction crypto_sign_open(m, sm, n, pk) {\n var i;\n var t = new Uint8Array(32), h = new Uint8Array(64);\n var p = [gf(), gf(), gf(), gf()],\n q = [gf(), gf(), gf(), gf()];\n\n if (n < 64) return -1;\n\n if (unpackneg(q, pk)) return -1;\n\n for (i = 0; i < n; i++) m[i] = sm[i];\n for (i = 0; i < 32; i++) m[i+32] = pk[i];\n crypto_hash(h, m, n);\n reduce(h);\n scalarmult(p, q, h);\n\n scalarbase(q, sm.subarray(32));\n add(p, q);\n pack(t, p);\n\n n -= 64;\n if (crypto_verify_32(sm, 0, t, 0)) {\n for (i = 0; i < n; i++) m[i] = 0;\n return -1;\n }\n\n for (i = 0; i < n; i++) m[i] = sm[i + 64];\n return n;\n}\n\nvar crypto_secretbox_KEYBYTES = 32,\n crypto_secretbox_NONCEBYTES = 24,\n crypto_secretbox_ZEROBYTES = 32,\n crypto_secretbox_BOXZEROBYTES = 16,\n crypto_scalarmult_BYTES = 32,\n crypto_scalarmult_SCALARBYTES = 32,\n crypto_box_PUBLICKEYBYTES = 32,\n crypto_box_SECRETKEYBYTES = 32,\n crypto_box_BEFORENMBYTES = 32,\n crypto_box_NONCEBYTES = crypto_secretbox_NONCEBYTES,\n crypto_box_ZEROBYTES = crypto_secretbox_ZEROBYTES,\n crypto_box_BOXZEROBYTES = crypto_secretbox_BOXZEROBYTES,\n crypto_sign_BYTES = 64,\n crypto_sign_PUBLICKEYBYTES = 32,\n crypto_sign_SECRETKEYBYTES = 64,\n crypto_sign_SEEDBYTES = 32,\n crypto_hash_BYTES = 64;\n\nnacl.lowlevel = {\n crypto_core_hsalsa20: crypto_core_hsalsa20,\n crypto_stream_xor: crypto_stream_xor,\n crypto_stream: crypto_stream,\n crypto_stream_salsa20_xor: crypto_stream_salsa20_xor,\n crypto_stream_salsa20: crypto_stream_salsa20,\n crypto_onetimeauth: crypto_onetimeauth,\n crypto_onetimeauth_verify: crypto_onetimeauth_verify,\n crypto_verify_16: crypto_verify_16,\n crypto_verify_32: crypto_verify_32,\n crypto_secretbox: crypto_secretbox,\n crypto_secretbox_open: crypto_secretbox_open,\n crypto_scalarmult: crypto_scalarmult,\n crypto_scalarmult_base: crypto_scalarmult_base,\n crypto_box_beforenm: crypto_box_beforenm,\n crypto_box_afternm: crypto_box_afternm,\n crypto_box: crypto_box,\n crypto_box_open: crypto_box_open,\n crypto_box_keypair: crypto_box_keypair,\n crypto_hash: crypto_hash,\n crypto_sign: crypto_sign,\n crypto_sign_keypair: crypto_sign_keypair,\n crypto_sign_open: crypto_sign_open,\n\n crypto_secretbox_KEYBYTES: crypto_secretbox_KEYBYTES,\n crypto_secretbox_NONCEBYTES: crypto_secretbox_NONCEBYTES,\n crypto_secretbox_ZEROBYTES: crypto_secretbox_ZEROBYTES,\n crypto_secretbox_BOXZEROBYTES: crypto_secretbox_BOXZEROBYTES,\n crypto_scalarmult_BYTES: crypto_scalarmult_BYTES,\n crypto_scalarmult_SCALARBYTES: crypto_scalarmult_SCALARBYTES,\n crypto_box_PUBLICKEYBYTES: crypto_box_PUBLICKEYBYTES,\n crypto_box_SECRETKEYBYTES: crypto_box_SECRETKEYBYTES,\n crypto_box_BEFORENMBYTES: crypto_box_BEFORENMBYTES,\n crypto_box_NONCEBYTES: crypto_box_NONCEBYTES,\n crypto_box_ZEROBYTES: crypto_box_ZEROBYTES,\n crypto_box_BOXZEROBYTES: crypto_box_BOXZEROBYTES,\n crypto_sign_BYTES: crypto_sign_BYTES,\n crypto_sign_PUBLICKEYBYTES: crypto_sign_PUBLICKEYBYTES,\n crypto_sign_SECRETKEYBYTES: crypto_sign_SECRETKEYBYTES,\n crypto_sign_SEEDBYTES: crypto_sign_SEEDBYTES,\n crypto_hash_BYTES: crypto_hash_BYTES,\n\n gf: gf,\n D: D,\n L: L,\n pack25519: pack25519,\n unpack25519: unpack25519,\n M: M,\n A: A,\n S: S,\n Z: Z,\n pow2523: pow2523,\n add: add,\n set25519: set25519,\n modL: modL,\n scalarmult: scalarmult,\n scalarbase: scalarbase,\n};\n\n/* High-level API */\n\nfunction checkLengths(k, n) {\n if (k.length !== crypto_secretbox_KEYBYTES) throw new Error('bad key size');\n if (n.length !== crypto_secretbox_NONCEBYTES) throw new Error('bad nonce size');\n}\n\nfunction checkBoxLengths(pk, sk) {\n if (pk.length !== crypto_box_PUBLICKEYBYTES) throw new Error('bad public key size');\n if (sk.length !== crypto_box_SECRETKEYBYTES) throw new Error('bad secret key size');\n}\n\nfunction checkArrayTypes() {\n for (var i = 0; i < arguments.length; i++) {\n if (!(arguments[i] instanceof Uint8Array))\n throw new TypeError('unexpected type, use Uint8Array');\n }\n}\n\nfunction cleanup(arr) {\n for (var i = 0; i < arr.length; i++) arr[i] = 0;\n}\n\nnacl.randomBytes = function(n) {\n var b = new Uint8Array(n);\n randombytes(b, n);\n return b;\n};\n\nnacl.secretbox = function(msg, nonce, key) {\n checkArrayTypes(msg, nonce, key);\n checkLengths(key, nonce);\n var m = new Uint8Array(crypto_secretbox_ZEROBYTES + msg.length);\n var c = new Uint8Array(m.length);\n for (var i = 0; i < msg.length; i++) m[i+crypto_secretbox_ZEROBYTES] = msg[i];\n crypto_secretbox(c, m, m.length, nonce, key);\n return c.subarray(crypto_secretbox_BOXZEROBYTES);\n};\n\nnacl.secretbox.open = function(box, nonce, key) {\n checkArrayTypes(box, nonce, key);\n checkLengths(key, nonce);\n var c = new Uint8Array(crypto_secretbox_BOXZEROBYTES + box.length);\n var m = new Uint8Array(c.length);\n for (var i = 0; i < box.length; i++) c[i+crypto_secretbox_BOXZEROBYTES] = box[i];\n if (c.length < 32) return null;\n if (crypto_secretbox_open(m, c, c.length, nonce, key) !== 0) return null;\n return m.subarray(crypto_secretbox_ZEROBYTES);\n};\n\nnacl.secretbox.keyLength = crypto_secretbox_KEYBYTES;\nnacl.secretbox.nonceLength = crypto_secretbox_NONCEBYTES;\nnacl.secretbox.overheadLength = crypto_secretbox_BOXZEROBYTES;\n\nnacl.scalarMult = function(n, p) {\n checkArrayTypes(n, p);\n if (n.length !== crypto_scalarmult_SCALARBYTES) throw new Error('bad n size');\n if (p.length !== crypto_scalarmult_BYTES) throw new Error('bad p size');\n var q = new Uint8Array(crypto_scalarmult_BYTES);\n crypto_scalarmult(q, n, p);\n return q;\n};\n\nnacl.scalarMult.base = function(n) {\n checkArrayTypes(n);\n if (n.length !== crypto_scalarmult_SCALARBYTES) throw new Error('bad n size');\n var q = new Uint8Array(crypto_scalarmult_BYTES);\n crypto_scalarmult_base(q, n);\n return q;\n};\n\nnacl.scalarMult.scalarLength = crypto_scalarmult_SCALARBYTES;\nnacl.scalarMult.groupElementLength = crypto_scalarmult_BYTES;\n\nnacl.box = function(msg, nonce, publicKey, secretKey) {\n var k = nacl.box.before(publicKey, secretKey);\n return nacl.secretbox(msg, nonce, k);\n};\n\nnacl.box.before = function(publicKey, secretKey) {\n checkArrayTypes(publicKey, secretKey);\n checkBoxLengths(publicKey, secretKey);\n var k = new Uint8Array(crypto_box_BEFORENMBYTES);\n crypto_box_beforenm(k, publicKey, secretKey);\n return k;\n};\n\nnacl.box.after = nacl.secretbox;\n\nnacl.box.open = function(msg, nonce, publicKey, secretKey) {\n var k = nacl.box.before(publicKey, secretKey);\n return nacl.secretbox.open(msg, nonce, k);\n};\n\nnacl.box.open.after = nacl.secretbox.open;\n\nnacl.box.keyPair = function() {\n var pk = new Uint8Array(crypto_box_PUBLICKEYBYTES);\n var sk = new Uint8Array(crypto_box_SECRETKEYBYTES);\n crypto_box_keypair(pk, sk);\n return {publicKey: pk, secretKey: sk};\n};\n\nnacl.box.keyPair.fromSecretKey = function(secretKey) {\n checkArrayTypes(secretKey);\n if (secretKey.length !== crypto_box_SECRETKEYBYTES)\n throw new Error('bad secret key size');\n var pk = new Uint8Array(crypto_box_PUBLICKEYBYTES);\n crypto_scalarmult_base(pk, secretKey);\n return {publicKey: pk, secretKey: new Uint8Array(secretKey)};\n};\n\nnacl.box.publicKeyLength = crypto_box_PUBLICKEYBYTES;\nnacl.box.secretKeyLength = crypto_box_SECRETKEYBYTES;\nnacl.box.sharedKeyLength = crypto_box_BEFORENMBYTES;\nnacl.box.nonceLength = crypto_box_NONCEBYTES;\nnacl.box.overheadLength = nacl.secretbox.overheadLength;\n\nnacl.sign = function(msg, secretKey) {\n checkArrayTypes(msg, secretKey);\n if (secretKey.length !== crypto_sign_SECRETKEYBYTES)\n throw new Error('bad secret key size');\n var signedMsg = new Uint8Array(crypto_sign_BYTES+msg.length);\n crypto_sign(signedMsg, msg, msg.length, secretKey);\n return signedMsg;\n};\n\nnacl.sign.open = function(signedMsg, publicKey) {\n checkArrayTypes(signedMsg, publicKey);\n if (publicKey.length !== crypto_sign_PUBLICKEYBYTES)\n throw new Error('bad public key size');\n var tmp = new Uint8Array(signedMsg.length);\n var mlen = crypto_sign_open(tmp, signedMsg, signedMsg.length, publicKey);\n if (mlen < 0) return null;\n var m = new Uint8Array(mlen);\n for (var i = 0; i < m.length; i++) m[i] = tmp[i];\n return m;\n};\n\nnacl.sign.detached = function(msg, secretKey) {\n var signedMsg = nacl.sign(msg, secretKey);\n var sig = new Uint8Array(crypto_sign_BYTES);\n for (var i = 0; i < sig.length; i++) sig[i] = signedMsg[i];\n return sig;\n};\n\nnacl.sign.detached.verify = function(msg, sig, publicKey) {\n checkArrayTypes(msg, sig, publicKey);\n if (sig.length !== crypto_sign_BYTES)\n throw new Error('bad signature size');\n if (publicKey.length !== crypto_sign_PUBLICKEYBYTES)\n throw new Error('bad public key size');\n var sm = new Uint8Array(crypto_sign_BYTES + msg.length);\n var m = new Uint8Array(crypto_sign_BYTES + msg.length);\n var i;\n for (i = 0; i < crypto_sign_BYTES; i++) sm[i] = sig[i];\n for (i = 0; i < msg.length; i++) sm[i+crypto_sign_BYTES] = msg[i];\n return (crypto_sign_open(m, sm, sm.length, publicKey) >= 0);\n};\n\nnacl.sign.keyPair = function() {\n var pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);\n var sk = new Uint8Array(crypto_sign_SECRETKEYBYTES);\n crypto_sign_keypair(pk, sk);\n return {publicKey: pk, secretKey: sk};\n};\n\nnacl.sign.keyPair.fromSecretKey = function(secretKey) {\n checkArrayTypes(secretKey);\n if (secretKey.length !== crypto_sign_SECRETKEYBYTES)\n throw new Error('bad secret key size');\n var pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);\n for (var i = 0; i < pk.length; i++) pk[i] = secretKey[32+i];\n return {publicKey: pk, secretKey: new Uint8Array(secretKey)};\n};\n\nnacl.sign.keyPair.fromSeed = function(seed) {\n checkArrayTypes(seed);\n if (seed.length !== crypto_sign_SEEDBYTES)\n throw new Error('bad seed size');\n var pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);\n var sk = new Uint8Array(crypto_sign_SECRETKEYBYTES);\n for (var i = 0; i < 32; i++) sk[i] = seed[i];\n crypto_sign_keypair(pk, sk, true);\n return {publicKey: pk, secretKey: sk};\n};\n\nnacl.sign.publicKeyLength = crypto_sign_PUBLICKEYBYTES;\nnacl.sign.secretKeyLength = crypto_sign_SECRETKEYBYTES;\nnacl.sign.seedLength = crypto_sign_SEEDBYTES;\nnacl.sign.signatureLength = crypto_sign_BYTES;\n\nnacl.hash = function(msg) {\n checkArrayTypes(msg);\n var h = new Uint8Array(crypto_hash_BYTES);\n crypto_hash(h, msg, msg.length);\n return h;\n};\n\nnacl.hash.hashLength = crypto_hash_BYTES;\n\nnacl.verify = function(x, y) {\n checkArrayTypes(x, y);\n // Zero length arguments are considered not equal.\n if (x.length === 0 || y.length === 0) return false;\n if (x.length !== y.length) return false;\n return (vn(x, 0, y, 0, x.length) === 0) ? true : false;\n};\n\nnacl.setPRNG = function(fn) {\n randombytes = fn;\n};\n\n(function() {\n // Initialize PRNG if environment provides CSPRNG.\n // If not, methods calling randombytes will throw.\n var crypto = typeof self !== 'undefined' ? (self.crypto || self.msCrypto) : null;\n if (crypto && crypto.getRandomValues) {\n // Browsers.\n var QUOTA = 65536;\n nacl.setPRNG(function(x, n) {\n var i, v = new Uint8Array(n);\n for (i = 0; i < n; i += QUOTA) {\n crypto.getRandomValues(v.subarray(i, i + Math.min(n - i, QUOTA)));\n }\n for (i = 0; i < n; i++) x[i] = v[i];\n cleanup(v);\n });\n } else if (typeof require !== 'undefined') {\n // Node.js.\n crypto = require('crypto');\n if (crypto && crypto.randomBytes) {\n nacl.setPRNG(function(x, n) {\n var i, v = crypto.randomBytes(n);\n for (i = 0; i < n; i++) x[i] = v[i];\n cleanup(v);\n });\n }\n }\n})();\n\n})(typeof module !== 'undefined' && module.exports ? module.exports : (self.nacl = self.nacl || {}));\n","module.exports = require('./pusher-with-encryption').default;\n","import ScriptReceiver from './script_receiver';\n\n/** Builds receivers for JSONP and Script requests.\n *\n * Each receiver is an object with following fields:\n * - number - unique (for the factory instance), numerical id of the receiver\n * - id - a string ID that can be used in DOM attributes\n * - name - name of the function triggering the receiver\n * - callback - callback function\n *\n * Receivers are triggered only once, on the first callback call.\n *\n * Receivers can be called by their name or by accessing factory object\n * by the number key.\n *\n * @param {String} prefix the prefix used in ids\n * @param {String} name the name of the object\n */\nexport class ScriptReceiverFactory {\n lastId: number;\n prefix: string;\n name: string;\n\n constructor(prefix: string, name: string) {\n this.lastId = 0;\n this.prefix = prefix;\n this.name = name;\n }\n\n create(callback: Function): ScriptReceiver {\n this.lastId++;\n\n var number = this.lastId;\n var id = this.prefix + number;\n var name = this.name + '[' + number + ']';\n\n var called = false;\n var callbackWrapper = function() {\n if (!called) {\n callback.apply(null, arguments);\n called = true;\n }\n };\n\n this[number] = callbackWrapper;\n return { number: number, id: id, name: name, callback: callbackWrapper };\n }\n\n remove(receiver: ScriptReceiver) {\n delete this[receiver.number];\n }\n}\n\nexport var ScriptReceivers = new ScriptReceiverFactory(\n '_pusher_script_',\n 'Pusher.ScriptReceivers'\n);\n","import {\n ChannelAuthorizationOptions,\n UserAuthenticationOptions\n} from './auth/options';\nimport { AuthTransport } from './config';\n\nexport interface DefaultConfig {\n VERSION: string;\n PROTOCOL: number;\n wsPort: number;\n wssPort: number;\n wsPath: string;\n httpHost: string;\n httpPort: number;\n httpsPort: number;\n httpPath: string;\n stats_host: string;\n authEndpoint: string;\n authTransport: AuthTransport;\n activityTimeout: number;\n pongTimeout: number;\n unavailableTimeout: number;\n userAuthentication: UserAuthenticationOptions;\n channelAuthorization: ChannelAuthorizationOptions;\n\n cdn_http?: string;\n cdn_https?: string;\n dependency_suffix?: string;\n}\n\nvar Defaults: DefaultConfig = {\n VERSION: VERSION,\n PROTOCOL: 7,\n\n wsPort: 80,\n wssPort: 443,\n wsPath: '',\n // DEPRECATED: SockJS fallback parameters\n httpHost: 'sockjs.pusher.com',\n httpPort: 80,\n httpsPort: 443,\n httpPath: '/pusher',\n // DEPRECATED: Stats\n stats_host: 'stats.pusher.com',\n // DEPRECATED: Other settings\n authEndpoint: '/pusher/auth',\n authTransport: 'ajax',\n activityTimeout: 120000,\n pongTimeout: 30000,\n unavailableTimeout: 10000,\n userAuthentication: {\n endpoint: '/pusher/user-auth',\n transport: 'ajax'\n },\n channelAuthorization: {\n endpoint: '/pusher/auth',\n transport: 'ajax'\n },\n\n // CDN configuration\n cdn_http: CDN_HTTP,\n cdn_https: CDN_HTTPS,\n dependency_suffix: DEPENDENCY_SUFFIX\n};\n\nexport default Defaults;\n","import { ScriptReceiverFactory } from './script_receiver_factory';\nimport Defaults from 'core/defaults';\nimport DependencyLoader from './dependency_loader';\n\nexport var DependenciesReceivers = new ScriptReceiverFactory(\n '_pusher_dependencies',\n 'Pusher.DependenciesReceivers'\n);\n\nexport var Dependencies = new DependencyLoader({\n cdn_http: Defaults.cdn_http,\n cdn_https: Defaults.cdn_https,\n version: Defaults.VERSION,\n suffix: Defaults.dependency_suffix,\n receivers: DependenciesReceivers\n});\n","import {\n ScriptReceivers,\n ScriptReceiverFactory\n} from './script_receiver_factory';\nimport Runtime from 'runtime';\nimport ScriptRequest from './script_request';\n\n/** Handles loading dependency files.\n *\n * Dependency loaders don't remember whether a resource has been loaded or\n * not. It is caller's responsibility to make sure the resource is not loaded\n * twice. This is because it's impossible to detect resource loading status\n * without knowing its content.\n *\n * Options:\n * - cdn_http - url to HTTP CND\n * - cdn_https - url to HTTPS CDN\n * - version - version of pusher-js\n * - suffix - suffix appended to all names of dependency files\n *\n * @param {Object} options\n */\nexport default class DependencyLoader {\n options: any;\n receivers: ScriptReceiverFactory;\n loading: any;\n\n constructor(options: any) {\n this.options = options;\n this.receivers = options.receivers || ScriptReceivers;\n this.loading = {};\n }\n\n /** Loads the dependency from CDN.\n *\n * @param {String} name\n * @param {Function} callback\n */\n load(name: string, options: any, callback: Function) {\n var self = this;\n\n if (self.loading[name] && self.loading[name].length > 0) {\n self.loading[name].push(callback);\n } else {\n self.loading[name] = [callback];\n\n var request = Runtime.createScriptRequest(self.getPath(name, options));\n var receiver = self.receivers.create(function(error) {\n self.receivers.remove(receiver);\n\n if (self.loading[name]) {\n var callbacks = self.loading[name];\n delete self.loading[name];\n\n var successCallback = function(wasSuccessful) {\n if (!wasSuccessful) {\n request.cleanup();\n }\n };\n for (var i = 0; i < callbacks.length; i++) {\n callbacks[i](error, successCallback);\n }\n }\n });\n request.send(receiver);\n }\n }\n\n /** Returns a root URL for pusher-js CDN.\n *\n * @returns {String}\n */\n getRoot(options: any): string {\n var cdn;\n var protocol = Runtime.getDocument().location.protocol;\n if ((options && options.useTLS) || protocol === 'https:') {\n cdn = this.options.cdn_https;\n } else {\n cdn = this.options.cdn_http;\n }\n // make sure there are no double slashes\n return cdn.replace(/\\/*$/, '') + '/' + this.options.version;\n }\n\n /** Returns a full path to a dependency file.\n *\n * @param {String} name\n * @returns {String}\n */\n getPath(name: string, options: any): string {\n return this.getRoot(options) + '/' + name + this.options.suffix + '.js';\n }\n}\n","/**\n * A place to store help URLs for error messages etc\n */\n\nconst urlStore = {\n baseUrl: 'https://pusher.com',\n urls: {\n authenticationEndpoint: {\n path: '/docs/channels/server_api/authenticating_users'\n },\n authorizationEndpoint: {\n path: '/docs/channels/server_api/authorizing-users/'\n },\n javascriptQuickStart: {\n path: '/docs/javascript_quick_start'\n },\n triggeringClientEvents: {\n path: '/docs/client_api_guide/client_events#trigger-events'\n },\n encryptedChannelSupport: {\n fullUrl:\n 'https://github.com/pusher/pusher-js/tree/cc491015371a4bde5743d1c87a0fbac0feb53195#encrypted-channel-support'\n }\n }\n};\n\n/** Builds a consistent string with links to pusher documentation\n *\n * @param {string} key - relevant key in the url_store.urls object\n * @return {string} suffix string to append to log message\n */\nconst buildLogSuffix = function(key: string): string {\n const urlPrefix = 'See:';\n const urlObj = urlStore.urls[key];\n if (!urlObj) return '';\n\n let url;\n if (urlObj.fullUrl) {\n url = urlObj.fullUrl;\n } else if (urlObj.path) {\n url = urlStore.baseUrl + urlObj.path;\n }\n\n if (!url) return '';\n return `${urlPrefix} ${url}`;\n};\n\nexport default { buildLogSuffix };\n","export enum AuthRequestType {\n UserAuthentication = 'user-authentication',\n ChannelAuthorization = 'channel-authorization'\n}\n\nexport interface ChannelAuthorizationData {\n auth: string;\n channel_data?: string;\n shared_secret?: string;\n}\n\nexport type ChannelAuthorizationCallback = (\n error: Error | null,\n authData: ChannelAuthorizationData | null\n) => void;\n\nexport interface ChannelAuthorizationRequestParams {\n socketId: string;\n channelName: string;\n}\n\nexport interface ChannelAuthorizationHandler {\n (\n params: ChannelAuthorizationRequestParams,\n callback: ChannelAuthorizationCallback\n ): void;\n}\n\nexport interface UserAuthenticationData {\n auth: string;\n user_data: string;\n}\n\nexport type UserAuthenticationCallback = (\n error: Error | null,\n authData: UserAuthenticationData | null\n) => void;\n\nexport interface UserAuthenticationRequestParams {\n socketId: string;\n}\n\nexport interface UserAuthenticationHandler {\n (\n params: UserAuthenticationRequestParams,\n callback: UserAuthenticationCallback\n ): void;\n}\n\nexport type AuthTransportCallback =\n | ChannelAuthorizationCallback\n | UserAuthenticationCallback;\n\nexport interface AuthOptionsT {\n transport: 'ajax' | 'jsonp';\n endpoint: string;\n params?: any;\n headers?: any;\n paramsProvider?: () => any;\n headersProvider?: () => any;\n customHandler?: AuthHandler;\n}\n\nexport declare type UserAuthenticationOptions = AuthOptionsT<\n UserAuthenticationHandler\n>;\nexport declare type ChannelAuthorizationOptions = AuthOptionsT<\n ChannelAuthorizationHandler\n>;\n\nexport interface InternalAuthOptions {\n transport: 'ajax' | 'jsonp';\n endpoint: string;\n params?: any;\n headers?: any;\n paramsProvider?: () => any;\n headersProvider?: () => any;\n}\n","/** Error classes used throughout the library. */\n// https://github.com/Microsoft/TypeScript-wiki/blob/master/Breaking-Changes.md#extending-built-ins-like-error-array-and-map-may-no-longer-work\nexport class BadEventName extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\nexport class BadChannelName extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\nexport class RequestTimedOut extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class TransportPriorityTooLow extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class TransportClosed extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class UnsupportedFeature extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class UnsupportedTransport extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class UnsupportedStrategy extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class HTTPAuthError extends Error {\n status: number;\n constructor(status: number, msg?: string) {\n super(msg);\n this.status = status;\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n","import TimelineSender from 'core/timeline/timeline_sender';\nimport * as Collections from 'core/utils/collections';\nimport Util from 'core/util';\nimport Runtime from 'runtime';\nimport { AuthTransport } from 'core/auth/auth_transports';\nimport AbstractRuntime from 'runtimes/interface';\nimport UrlStore from 'core/utils/url_store';\nimport {\n AuthRequestType,\n AuthTransportCallback,\n InternalAuthOptions\n} from 'core/auth/options';\nimport { HTTPAuthError } from 'core/errors';\n\nconst ajax: AuthTransport = function(\n context: AbstractRuntime,\n query: string,\n authOptions: InternalAuthOptions,\n authRequestType: AuthRequestType,\n callback: AuthTransportCallback\n) {\n const xhr = Runtime.createXHR();\n xhr.open('POST', authOptions.endpoint, true);\n\n // add request headers\n xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');\n for (var headerName in authOptions.headers) {\n xhr.setRequestHeader(headerName, authOptions.headers[headerName]);\n }\n if (authOptions.headersProvider != null) {\n let dynamicHeaders = authOptions.headersProvider();\n for (var headerName in dynamicHeaders) {\n xhr.setRequestHeader(headerName, dynamicHeaders[headerName]);\n }\n }\n\n xhr.onreadystatechange = function() {\n if (xhr.readyState === 4) {\n if (xhr.status === 200) {\n let data;\n let parsed = false;\n\n try {\n data = JSON.parse(xhr.responseText);\n parsed = true;\n } catch (e) {\n callback(\n new HTTPAuthError(\n 200,\n `JSON returned from ${authRequestType.toString()} endpoint was invalid, yet status code was 200. Data was: ${\n xhr.responseText\n }`\n ),\n null\n );\n }\n\n if (parsed) {\n // prevents double execution.\n callback(null, data);\n }\n } else {\n let suffix = '';\n switch (authRequestType) {\n case AuthRequestType.UserAuthentication:\n suffix = UrlStore.buildLogSuffix('authenticationEndpoint');\n break;\n case AuthRequestType.ChannelAuthorization:\n suffix = `Clients must be authorized to join private or presence channels. ${UrlStore.buildLogSuffix(\n 'authorizationEndpoint'\n )}`;\n break;\n }\n callback(\n new HTTPAuthError(\n xhr.status,\n `Unable to retrieve auth string from ${authRequestType.toString()} endpoint - ` +\n `received status: ${xhr.status} from ${authOptions.endpoint}. ${suffix}`\n ),\n null\n );\n }\n }\n };\n\n xhr.send(query);\n return xhr;\n};\n\nexport default ajax;\n","export default function encode(s: any): string {\n return btoa(utob(s));\n}\n\nvar fromCharCode = String.fromCharCode;\n\nvar b64chars =\n 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';\nvar b64tab = {};\n\nfor (var i = 0, l = b64chars.length; i < l; i++) {\n b64tab[b64chars.charAt(i)] = i;\n}\n\nvar cb_utob = function(c) {\n var cc = c.charCodeAt(0);\n return cc < 0x80\n ? c\n : cc < 0x800\n ? fromCharCode(0xc0 | (cc >>> 6)) + fromCharCode(0x80 | (cc & 0x3f))\n : fromCharCode(0xe0 | ((cc >>> 12) & 0x0f)) +\n fromCharCode(0x80 | ((cc >>> 6) & 0x3f)) +\n fromCharCode(0x80 | (cc & 0x3f));\n};\n\nvar utob = function(u) {\n return u.replace(/[^\\x00-\\x7F]/g, cb_utob);\n};\n\nvar cb_encode = function(ccc) {\n var padlen = [0, 2, 1][ccc.length % 3];\n var ord =\n (ccc.charCodeAt(0) << 16) |\n ((ccc.length > 1 ? ccc.charCodeAt(1) : 0) << 8) |\n (ccc.length > 2 ? ccc.charCodeAt(2) : 0);\n var chars = [\n b64chars.charAt(ord >>> 18),\n b64chars.charAt((ord >>> 12) & 63),\n padlen >= 2 ? '=' : b64chars.charAt((ord >>> 6) & 63),\n padlen >= 1 ? '=' : b64chars.charAt(ord & 63)\n ];\n return chars.join('');\n};\n\nvar btoa =\n global.btoa ||\n function(b) {\n return b.replace(/[\\s\\S]{1,3}/g, cb_encode);\n };\n","import TimedCallback from './timed_callback';\nimport { Delay, Scheduler, Canceller } from './scheduling';\n\nabstract class Timer {\n protected clear: Canceller;\n protected timer: number | void;\n\n constructor(\n set: Scheduler,\n clear: Canceller,\n delay: Delay,\n callback: TimedCallback\n ) {\n this.clear = clear;\n this.timer = set(() => {\n if (this.timer) {\n this.timer = callback(this.timer);\n }\n }, delay);\n }\n\n /** Returns whether the timer is still running.\n *\n * @return {Boolean}\n */\n isRunning(): boolean {\n return this.timer !== null;\n }\n\n /** Aborts a timer when it's running. */\n ensureAborted() {\n if (this.timer) {\n this.clear(this.timer);\n this.timer = null;\n }\n }\n}\n\nexport default Timer;\n","import Timer from './abstract_timer';\nimport TimedCallback from './timed_callback';\nimport { Delay } from './scheduling';\n\n// We need to bind clear functions this way to avoid exceptions on IE8\nfunction clearTimeout(timer) {\n global.clearTimeout(timer);\n}\nfunction clearInterval(timer) {\n global.clearInterval(timer);\n}\n\n/** Cross-browser compatible one-off timer abstraction.\n *\n * @param {Number} delay\n * @param {Function} callback\n */\nexport class OneOffTimer extends Timer {\n constructor(delay: Delay, callback: TimedCallback) {\n super(setTimeout, clearTimeout, delay, function(timer) {\n callback();\n return null;\n });\n }\n}\n\n/** Cross-browser compatible periodic timer abstraction.\n *\n * @param {Number} delay\n * @param {Function} callback\n */\nexport class PeriodicTimer extends Timer {\n constructor(delay: Delay, callback: TimedCallback) {\n super(setInterval, clearInterval, delay, function(timer) {\n callback();\n return timer;\n });\n }\n}\n","import * as Collections from './utils/collections';\nimport TimedCallback from './utils/timers/timed_callback';\nimport { OneOffTimer, PeriodicTimer } from './utils/timers';\n\nvar Util = {\n now(): number {\n if (Date.now) {\n return Date.now();\n } else {\n return new Date().valueOf();\n }\n },\n\n defer(callback: TimedCallback): OneOffTimer {\n return new OneOffTimer(0, callback);\n },\n\n /** Builds a function that will proxy a method call to its first argument.\n *\n * Allows partial application of arguments, so additional arguments are\n * prepended to the argument list.\n *\n * @param {String} name method name\n * @return {Function} proxy function\n */\n method(name: string, ...args: any[]): Function {\n var boundArguments = Array.prototype.slice.call(arguments, 1);\n return function(object) {\n return object[name].apply(object, boundArguments.concat(arguments));\n };\n }\n};\n\nexport default Util;\n","import base64encode from '../base64';\nimport Util from '../util';\n\n/** Merges multiple objects into the target argument.\n *\n * For properties that are plain Objects, performs a deep-merge. For the\n * rest it just copies the value of the property.\n *\n * To extend prototypes use it as following:\n * Pusher.Util.extend(Target.prototype, Base.prototype)\n *\n * You can also use it to merge objects without altering them:\n * Pusher.Util.extend({}, object1, object2)\n *\n * @param {Object} target\n * @return {Object} the target argument\n */\nexport function extend(target: any, ...sources: any[]): T {\n for (var i = 0; i < sources.length; i++) {\n var extensions = sources[i];\n for (var property in extensions) {\n if (\n extensions[property] &&\n extensions[property].constructor &&\n extensions[property].constructor === Object\n ) {\n target[property] = extend(target[property] || {}, extensions[property]);\n } else {\n target[property] = extensions[property];\n }\n }\n }\n return target;\n}\n\nexport function stringify(): string {\n var m = ['Pusher'];\n for (var i = 0; i < arguments.length; i++) {\n if (typeof arguments[i] === 'string') {\n m.push(arguments[i]);\n } else {\n m.push(safeJSONStringify(arguments[i]));\n }\n }\n return m.join(' : ');\n}\n\nexport function arrayIndexOf(array: any[], item: any): number {\n // MSIE doesn't have array.indexOf\n var nativeIndexOf = Array.prototype.indexOf;\n if (array === null) {\n return -1;\n }\n if (nativeIndexOf && array.indexOf === nativeIndexOf) {\n return array.indexOf(item);\n }\n for (var i = 0, l = array.length; i < l; i++) {\n if (array[i] === item) {\n return i;\n }\n }\n return -1;\n}\n\n/** Applies a function f to all properties of an object.\n *\n * Function f gets 3 arguments passed:\n * - element from the object\n * - key of the element\n * - reference to the object\n *\n * @param {Object} object\n * @param {Function} f\n */\nexport function objectApply(object: any, f: Function) {\n for (var key in object) {\n if (Object.prototype.hasOwnProperty.call(object, key)) {\n f(object[key], key, object);\n }\n }\n}\n\n/** Return a list of objects own proerty keys\n *\n * @param {Object} object\n * @returns {Array}\n */\nexport function keys(object: any): string[] {\n var keys = [];\n objectApply(object, function(_, key) {\n keys.push(key);\n });\n return keys;\n}\n\n/** Return a list of object's own property values\n *\n * @param {Object} object\n * @returns {Array}\n */\nexport function values(object: any): any[] {\n var values = [];\n objectApply(object, function(value) {\n values.push(value);\n });\n return values;\n}\n\n/** Applies a function f to all elements of an array.\n *\n * Function f gets 3 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function apply(array: any[], f: Function, context?: any) {\n for (var i = 0; i < array.length; i++) {\n f.call(context || global, array[i], i, array);\n }\n}\n\n/** Maps all elements of the array and returns the result.\n *\n * Function f gets 4 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n * - reference to the destination array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function map(array: any[], f: Function): any[] {\n var result = [];\n for (var i = 0; i < array.length; i++) {\n result.push(f(array[i], i, array, result));\n }\n return result;\n}\n\n/** Maps all elements of the object and returns the result.\n *\n * Function f gets 4 arguments passed:\n * - element from the object\n * - key of the element\n * - reference to the source object\n * - reference to the destination object\n *\n * @param {Object} object\n * @param {Function} f\n */\nexport function mapObject(object: any, f: Function): any {\n var result = {};\n objectApply(object, function(value, key) {\n result[key] = f(value);\n });\n return result;\n}\n\n/** Filters elements of the array using a test function.\n *\n * Function test gets 4 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n * - reference to the destination array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function filter(array: any[], test: Function): any[] {\n test =\n test ||\n function(value) {\n return !!value;\n };\n\n var result = [];\n for (var i = 0; i < array.length; i++) {\n if (test(array[i], i, array, result)) {\n result.push(array[i]);\n }\n }\n return result;\n}\n\n/** Filters properties of the object using a test function.\n *\n * Function test gets 4 arguments passed:\n * - element from the object\n * - key of the element\n * - reference to the source object\n * - reference to the destination object\n *\n * @param {Object} object\n * @param {Function} f\n */\nexport function filterObject(object: Object, test: Function) {\n var result = {};\n objectApply(object, function(value, key) {\n if ((test && test(value, key, object, result)) || Boolean(value)) {\n result[key] = value;\n }\n });\n return result;\n}\n\n/** Flattens an object into a two-dimensional array.\n *\n * @param {Object} object\n * @return {Array} resulting array of [key, value] pairs\n */\nexport function flatten(object: Object): any[] {\n var result = [];\n objectApply(object, function(value, key) {\n result.push([key, value]);\n });\n return result;\n}\n\n/** Checks whether any element of the array passes the test.\n *\n * Function test gets 3 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function any(array: any[], test: Function): boolean {\n for (var i = 0; i < array.length; i++) {\n if (test(array[i], i, array)) {\n return true;\n }\n }\n return false;\n}\n\n/** Checks whether all elements of the array pass the test.\n *\n * Function test gets 3 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function all(array: any[], test: Function): boolean {\n for (var i = 0; i < array.length; i++) {\n if (!test(array[i], i, array)) {\n return false;\n }\n }\n return true;\n}\n\nexport function encodeParamsObject(data): string {\n return mapObject(data, function(value) {\n if (typeof value === 'object') {\n value = safeJSONStringify(value);\n }\n return encodeURIComponent(base64encode(value.toString()));\n });\n}\n\nexport function buildQueryString(data: any): string {\n var params = filterObject(data, function(value) {\n return value !== undefined;\n });\n\n var query = map(\n flatten(encodeParamsObject(params)),\n Util.method('join', '=')\n ).join('&');\n\n return query;\n}\n\n/**\n * See https://github.com/douglascrockford/JSON-js/blob/master/cycle.js\n *\n * Remove circular references from an object. Required for JSON.stringify in\n * React Native, which tends to blow up a lot.\n *\n * @param {any} object\n * @return {any} Decycled object\n */\nexport function decycleObject(object: any): any {\n var objects = [],\n paths = [];\n\n return (function derez(value, path) {\n var i, name, nu;\n\n switch (typeof value) {\n case 'object':\n if (!value) {\n return null;\n }\n for (i = 0; i < objects.length; i += 1) {\n if (objects[i] === value) {\n return { $ref: paths[i] };\n }\n }\n\n objects.push(value);\n paths.push(path);\n\n if (Object.prototype.toString.apply(value) === '[object Array]') {\n nu = [];\n for (i = 0; i < value.length; i += 1) {\n nu[i] = derez(value[i], path + '[' + i + ']');\n }\n } else {\n nu = {};\n for (name in value) {\n if (Object.prototype.hasOwnProperty.call(value, name)) {\n nu[name] = derez(\n value[name],\n path + '[' + JSON.stringify(name) + ']'\n );\n }\n }\n }\n return nu;\n case 'number':\n case 'string':\n case 'boolean':\n return value;\n }\n })(object, '$');\n}\n\n/**\n * Provides a cross-browser and cross-platform way to safely stringify objects\n * into JSON. This is particularly necessary for ReactNative, where circular JSON\n * structures throw an exception.\n *\n * @param {any} source The object to stringify\n * @return {string} The serialized output.\n */\nexport function safeJSONStringify(source: any): string {\n try {\n return JSON.stringify(source);\n } catch (e) {\n return JSON.stringify(decycleObject(source));\n }\n}\n","import { stringify } from './utils/collections';\nimport Pusher from './pusher';\n\nclass Logger {\n debug(...args: any[]) {\n this.log(this.globalLog, args);\n }\n\n warn(...args: any[]) {\n this.log(this.globalLogWarn, args);\n }\n\n error(...args: any[]) {\n this.log(this.globalLogError, args);\n }\n\n private globalLog = (message: string) => {\n if (global.console && global.console.log) {\n global.console.log(message);\n }\n };\n\n private globalLogWarn(message: string) {\n if (global.console && global.console.warn) {\n global.console.warn(message);\n } else {\n this.globalLog(message);\n }\n }\n\n private globalLogError(message: string) {\n if (global.console && global.console.error) {\n global.console.error(message);\n } else {\n this.globalLogWarn(message);\n }\n }\n\n private log(\n defaultLoggingFunction: (message: string) => void,\n ...args: any[]\n ) {\n var message = stringify.apply(this, arguments);\n if (Pusher.log) {\n Pusher.log(message);\n } else if (Pusher.logToConsole) {\n const log = defaultLoggingFunction.bind(this);\n log(message);\n }\n }\n}\n\nexport default new Logger();\n","import Browser from '../browser';\nimport Logger from 'core/logger';\nimport JSONPRequest from '../dom/jsonp_request';\nimport { ScriptReceivers } from '../dom/script_receiver_factory';\nimport { AuthTransport } from 'core/auth/auth_transports';\nimport {\n AuthRequestType,\n AuthTransportCallback,\n InternalAuthOptions\n} from 'core/auth/options';\n\nvar jsonp: AuthTransport = function(\n context: Browser,\n query: string,\n authOptions: InternalAuthOptions,\n authRequestType: AuthRequestType,\n callback: AuthTransportCallback\n) {\n if (\n authOptions.headers !== undefined ||\n authOptions.headersProvider != null\n ) {\n Logger.warn(\n `To send headers with the ${authRequestType.toString()} request, you must use AJAX, rather than JSONP.`\n );\n }\n\n var callbackName = context.nextAuthCallbackID.toString();\n context.nextAuthCallbackID++;\n\n var document = context.getDocument();\n var script = document.createElement('script');\n // Hacked wrapper.\n context.auth_callbacks[callbackName] = function(data) {\n callback(null, data);\n };\n\n var callback_name = \"Pusher.auth_callbacks['\" + callbackName + \"']\";\n script.src =\n authOptions.endpoint +\n '?callback=' +\n encodeURIComponent(callback_name) +\n '&' +\n query;\n\n var head =\n document.getElementsByTagName('head')[0] || document.documentElement;\n head.insertBefore(script, head.firstChild);\n};\n\nexport default jsonp;\n","import ScriptReceiver from './script_receiver';\n\n/** Sends a generic HTTP GET request using a script tag.\n *\n * By constructing URL in a specific way, it can be used for loading\n * JavaScript resources or JSONP requests. It can notify about errors, but\n * only in certain environments. Please take care of monitoring the state of\n * the request yourself.\n *\n * @param {String} src\n */\nexport default class ScriptRequest {\n src: string;\n script: any;\n errorScript: any;\n\n constructor(src: string) {\n this.src = src;\n }\n\n send(receiver: ScriptReceiver) {\n var self = this;\n var errorString = 'Error loading ' + self.src;\n\n self.script = document.createElement('script');\n self.script.id = receiver.id;\n self.script.src = self.src;\n self.script.type = 'text/javascript';\n self.script.charset = 'UTF-8';\n\n if (self.script.addEventListener) {\n self.script.onerror = function() {\n receiver.callback(errorString);\n };\n self.script.onload = function() {\n receiver.callback(null);\n };\n } else {\n self.script.onreadystatechange = function() {\n if (\n self.script.readyState === 'loaded' ||\n self.script.readyState === 'complete'\n ) {\n receiver.callback(null);\n }\n };\n }\n\n // Opera<11.6 hack for missing onerror callback\n if (\n self.script.async === undefined &&\n (document).attachEvent &&\n /opera/i.test(navigator.userAgent)\n ) {\n self.errorScript = document.createElement('script');\n self.errorScript.id = receiver.id + '_error';\n self.errorScript.text = receiver.name + \"('\" + errorString + \"');\";\n self.script.async = self.errorScript.async = false;\n } else {\n self.script.async = true;\n }\n\n var head = document.getElementsByTagName('head')[0];\n head.insertBefore(self.script, head.firstChild);\n if (self.errorScript) {\n head.insertBefore(self.errorScript, self.script.nextSibling);\n }\n }\n\n /** Cleans up the DOM remains of the script request. */\n cleanup() {\n if (this.script) {\n this.script.onload = this.script.onerror = null;\n this.script.onreadystatechange = null;\n }\n if (this.script && this.script.parentNode) {\n this.script.parentNode.removeChild(this.script);\n }\n if (this.errorScript && this.errorScript.parentNode) {\n this.errorScript.parentNode.removeChild(this.errorScript);\n }\n this.script = null;\n this.errorScript = null;\n }\n}\n","import ScriptReceiver from './script_receiver';\nimport ScriptRequest from './script_request';\nimport * as Collections from 'core/utils/collections';\nimport Util from 'core/util';\nimport Runtime from '../runtime';\n\n/** Sends data via JSONP.\n *\n * Data is a key-value map. Its values are JSON-encoded and then passed\n * through base64. Finally, keys and encoded values are appended to the query\n * string.\n *\n * The class itself does not guarantee raising errors on failures, as it's not\n * possible to support such feature on all browsers. Instead, JSONP endpoint\n * should call back in a way that's easy to distinguish from browser calls,\n * for example by passing a second argument to the receiver.\n *\n * @param {String} url\n * @param {Object} data key-value map of data to be submitted\n */\nexport default class JSONPRequest {\n url: string;\n data: any;\n request: ScriptRequest;\n\n constructor(url: string, data: any) {\n this.url = url;\n this.data = data;\n }\n\n /** Sends the actual JSONP request.\n *\n * @param {ScriptReceiver} receiver\n */\n send(receiver: ScriptReceiver) {\n if (this.request) {\n return;\n }\n\n var query = Collections.buildQueryString(this.data);\n var url = this.url + '/' + receiver.number + '?' + query;\n this.request = Runtime.createScriptRequest(url);\n this.request.send(receiver);\n }\n\n /** Cleans up the DOM remains of the JSONP request. */\n cleanup() {\n if (this.request) {\n this.request.cleanup();\n }\n }\n}\n","import TimelineSender from 'core/timeline/timeline_sender';\nimport TimelineTransport from 'core/timeline/timeline_transport';\nimport Browser from 'runtime';\nimport { AuthTransport } from 'core/auth/auth_transports';\nimport { ScriptReceivers } from '../dom/script_receiver_factory';\n\nvar getAgent = function(sender: TimelineSender, useTLS: boolean) {\n return function(data: any, callback: Function) {\n var scheme = 'http' + (useTLS ? 's' : '') + '://';\n var url =\n scheme + (sender.host || sender.options.host) + sender.options.path;\n var request = Browser.createJSONPRequest(url, data);\n\n var receiver = Browser.ScriptReceivers.create(function(error, result) {\n ScriptReceivers.remove(receiver);\n request.cleanup();\n\n if (result && result.host) {\n sender.host = result.host;\n }\n if (callback) {\n callback(error, result);\n }\n });\n request.send(receiver);\n };\n};\n\nvar jsonp = {\n name: 'jsonp',\n getAgent\n};\n\nexport default jsonp;\n","import Defaults from '../defaults';\nimport { default as URLScheme, URLSchemeParams } from './url_scheme';\n\nfunction getGenericURL(\n baseScheme: string,\n params: URLSchemeParams,\n path: string\n): string {\n var scheme = baseScheme + (params.useTLS ? 's' : '');\n var host = params.useTLS ? params.hostTLS : params.hostNonTLS;\n return scheme + '://' + host + path;\n}\n\nfunction getGenericPath(key: string, queryString?: string): string {\n var path = '/app/' + key;\n var query =\n '?protocol=' +\n Defaults.PROTOCOL +\n '&client=js' +\n '&version=' +\n Defaults.VERSION +\n (queryString ? '&' + queryString : '');\n return path + query;\n}\n\nexport var ws: URLScheme = {\n getInitial: function(key: string, params: URLSchemeParams): string {\n var path = (params.httpPath || '') + getGenericPath(key, 'flash=false');\n return getGenericURL('ws', params, path);\n }\n};\n\nexport var http: URLScheme = {\n getInitial: function(key: string, params: URLSchemeParams): string {\n var path = (params.httpPath || '/pusher') + getGenericPath(key);\n return getGenericURL('http', params, path);\n }\n};\n\nexport var sockjs: URLScheme = {\n getInitial: function(key: string, params: URLSchemeParams): string {\n return getGenericURL('http', params, params.httpPath || '/pusher');\n },\n getPath: function(key: string, params: URLSchemeParams): string {\n return getGenericPath(key);\n }\n};\n","import Callback from './callback';\nimport * as Collections from '../utils/collections';\nimport CallbackTable from './callback_table';\n\nexport default class CallbackRegistry {\n _callbacks: CallbackTable;\n\n constructor() {\n this._callbacks = {};\n }\n\n get(name: string): Callback[] {\n return this._callbacks[prefix(name)];\n }\n\n add(name: string, callback: Function, context: any) {\n var prefixedEventName = prefix(name);\n this._callbacks[prefixedEventName] =\n this._callbacks[prefixedEventName] || [];\n this._callbacks[prefixedEventName].push({\n fn: callback,\n context: context\n });\n }\n\n remove(name?: string, callback?: Function, context?: any) {\n if (!name && !callback && !context) {\n this._callbacks = {};\n return;\n }\n\n var names = name ? [prefix(name)] : Collections.keys(this._callbacks);\n\n if (callback || context) {\n this.removeCallback(names, callback, context);\n } else {\n this.removeAllCallbacks(names);\n }\n }\n\n private removeCallback(names: string[], callback: Function, context: any) {\n Collections.apply(\n names,\n function(name) {\n this._callbacks[name] = Collections.filter(\n this._callbacks[name] || [],\n function(binding) {\n return (\n (callback && callback !== binding.fn) ||\n (context && context !== binding.context)\n );\n }\n );\n if (this._callbacks[name].length === 0) {\n delete this._callbacks[name];\n }\n },\n this\n );\n }\n\n private removeAllCallbacks(names: string[]) {\n Collections.apply(\n names,\n function(name) {\n delete this._callbacks[name];\n },\n this\n );\n }\n}\n\nfunction prefix(name: string): string {\n return '_' + name;\n}\n","import * as Collections from '../utils/collections';\nimport Callback from './callback';\nimport Metadata from '../channels/metadata';\nimport CallbackRegistry from './callback_registry';\n\n/** Manages callback bindings and event emitting.\n *\n * @param Function failThrough called when no listeners are bound to an event\n */\nexport default class Dispatcher {\n callbacks: CallbackRegistry;\n global_callbacks: Function[];\n failThrough: Function;\n\n constructor(failThrough?: Function) {\n this.callbacks = new CallbackRegistry();\n this.global_callbacks = [];\n this.failThrough = failThrough;\n }\n\n bind(eventName: string, callback: Function, context?: any) {\n this.callbacks.add(eventName, callback, context);\n return this;\n }\n\n bind_global(callback: Function) {\n this.global_callbacks.push(callback);\n return this;\n }\n\n unbind(eventName?: string, callback?: Function, context?: any) {\n this.callbacks.remove(eventName, callback, context);\n return this;\n }\n\n unbind_global(callback?: Function) {\n if (!callback) {\n this.global_callbacks = [];\n return this;\n }\n\n this.global_callbacks = Collections.filter(\n this.global_callbacks || [],\n c => c !== callback\n );\n\n return this;\n }\n\n unbind_all() {\n this.unbind();\n this.unbind_global();\n return this;\n }\n\n emit(eventName: string, data?: any, metadata?: Metadata): Dispatcher {\n for (var i = 0; i < this.global_callbacks.length; i++) {\n this.global_callbacks[i](eventName, data);\n }\n\n var callbacks = this.callbacks.get(eventName);\n var args = [];\n\n if (metadata) {\n // if there's a metadata argument, we need to call the callback with both\n // data and metadata regardless of whether data is undefined\n args.push(data, metadata);\n } else if (data) {\n // metadata is undefined, so we only need to call the callback with data\n // if data exists\n args.push(data);\n }\n\n if (callbacks && callbacks.length > 0) {\n for (var i = 0; i < callbacks.length; i++) {\n callbacks[i].fn.apply(callbacks[i].context || global, args);\n }\n } else if (this.failThrough) {\n this.failThrough(eventName, data);\n }\n\n return this;\n }\n}\n","import Util from '../util';\nimport * as Collections from '../utils/collections';\nimport { default as EventsDispatcher } from '../events/dispatcher';\nimport Logger from '../logger';\nimport TransportHooks from './transport_hooks';\nimport Socket from '../socket';\nimport Runtime from 'runtime';\nimport Timeline from '../timeline/timeline';\nimport TransportConnectionOptions from './transport_connection_options';\n\n/** Provides universal API for transport connections.\n *\n * Transport connection is a low-level object that wraps a connection method\n * and exposes a simple evented interface for the connection state and\n * messaging. It does not implement Pusher-specific WebSocket protocol.\n *\n * Additionally, it fetches resources needed for transport to work and exposes\n * an interface for querying transport features.\n *\n * States:\n * - new - initial state after constructing the object\n * - initializing - during initialization phase, usually fetching resources\n * - intialized - ready to establish a connection\n * - connection - when connection is being established\n * - open - when connection ready to be used\n * - closed - after connection was closed be either side\n *\n * Emits:\n * - error - after the connection raised an error\n *\n * Options:\n * - useTLS - whether connection should be over TLS\n * - hostTLS - host to connect to when connection is over TLS\n * - hostNonTLS - host to connect to when connection is over TLS\n *\n * @param {String} key application key\n * @param {Object} options\n */\nexport default class TransportConnection extends EventsDispatcher {\n hooks: TransportHooks;\n name: string;\n priority: number;\n key: string;\n options: TransportConnectionOptions;\n state: string;\n timeline: Timeline;\n activityTimeout: number;\n id: number;\n socket: Socket;\n beforeOpen: Function;\n initialize: Function;\n\n constructor(\n hooks: TransportHooks,\n name: string,\n priority: number,\n key: string,\n options: TransportConnectionOptions\n ) {\n super();\n this.initialize = Runtime.transportConnectionInitializer;\n this.hooks = hooks;\n this.name = name;\n this.priority = priority;\n this.key = key;\n this.options = options;\n\n this.state = 'new';\n this.timeline = options.timeline;\n this.activityTimeout = options.activityTimeout;\n this.id = this.timeline.generateUniqueID();\n }\n\n /** Checks whether the transport handles activity checks by itself.\n *\n * @return {Boolean}\n */\n handlesActivityChecks(): boolean {\n return Boolean(this.hooks.handlesActivityChecks);\n }\n\n /** Checks whether the transport supports the ping/pong API.\n *\n * @return {Boolean}\n */\n supportsPing(): boolean {\n return Boolean(this.hooks.supportsPing);\n }\n\n /** Tries to establish a connection.\n *\n * @returns {Boolean} false if transport is in invalid state\n */\n connect(): boolean {\n if (this.socket || this.state !== 'initialized') {\n return false;\n }\n\n var url = this.hooks.urls.getInitial(this.key, this.options);\n try {\n this.socket = this.hooks.getSocket(url, this.options);\n } catch (e) {\n Util.defer(() => {\n this.onError(e);\n this.changeState('closed');\n });\n return false;\n }\n\n this.bindListeners();\n\n Logger.debug('Connecting', { transport: this.name, url });\n this.changeState('connecting');\n return true;\n }\n\n /** Closes the connection.\n *\n * @return {Boolean} true if there was a connection to close\n */\n close(): boolean {\n if (this.socket) {\n this.socket.close();\n return true;\n } else {\n return false;\n }\n }\n\n /** Sends data over the open connection.\n *\n * @param {String} data\n * @return {Boolean} true only when in the \"open\" state\n */\n send(data: any): boolean {\n if (this.state === 'open') {\n // Workaround for MobileSafari bug (see https://gist.github.com/2052006)\n Util.defer(() => {\n if (this.socket) {\n this.socket.send(data);\n }\n });\n return true;\n } else {\n return false;\n }\n }\n\n /** Sends a ping if the connection is open and transport supports it. */\n ping() {\n if (this.state === 'open' && this.supportsPing()) {\n this.socket.ping();\n }\n }\n\n private onOpen() {\n if (this.hooks.beforeOpen) {\n this.hooks.beforeOpen(\n this.socket,\n this.hooks.urls.getPath(this.key, this.options)\n );\n }\n this.changeState('open');\n this.socket.onopen = undefined;\n }\n\n private onError(error) {\n this.emit('error', { type: 'WebSocketError', error: error });\n this.timeline.error(this.buildTimelineMessage({ error: error.toString() }));\n }\n\n private onClose(closeEvent?: any) {\n if (closeEvent) {\n this.changeState('closed', {\n code: closeEvent.code,\n reason: closeEvent.reason,\n wasClean: closeEvent.wasClean\n });\n } else {\n this.changeState('closed');\n }\n this.unbindListeners();\n this.socket = undefined;\n }\n\n private onMessage(message) {\n this.emit('message', message);\n }\n\n private onActivity() {\n this.emit('activity');\n }\n\n private bindListeners() {\n this.socket.onopen = () => {\n this.onOpen();\n };\n this.socket.onerror = error => {\n this.onError(error);\n };\n this.socket.onclose = closeEvent => {\n this.onClose(closeEvent);\n };\n this.socket.onmessage = message => {\n this.onMessage(message);\n };\n\n if (this.supportsPing()) {\n this.socket.onactivity = () => {\n this.onActivity();\n };\n }\n }\n\n private unbindListeners() {\n if (this.socket) {\n this.socket.onopen = undefined;\n this.socket.onerror = undefined;\n this.socket.onclose = undefined;\n this.socket.onmessage = undefined;\n if (this.supportsPing()) {\n this.socket.onactivity = undefined;\n }\n }\n }\n\n private changeState(state: string, params?: any) {\n this.state = state;\n this.timeline.info(\n this.buildTimelineMessage({\n state: state,\n params: params\n })\n );\n this.emit(state, params);\n }\n\n buildTimelineMessage(message): any {\n return Collections.extend({ cid: this.id }, message);\n }\n}\n","import Factory from '../utils/factory';\nimport TransportHooks from './transport_hooks';\nimport TransportConnection from './transport_connection';\nimport TransportConnectionOptions from './transport_connection_options';\n\n/** Provides interface for transport connection instantiation.\n *\n * Takes transport-specific hooks as the only argument, which allow checking\n * for transport support and creating its connections.\n *\n * Supported hooks: * - file - the name of the file to be fetched during initialization\n * - urls - URL scheme to be used by transport\n * - handlesActivityCheck - true when the transport handles activity checks\n * - supportsPing - true when the transport has a ping/activity API\n * - isSupported - tells whether the transport is supported in the environment\n * - getSocket - creates a WebSocket-compatible transport socket\n *\n * See transports.js for specific implementations.\n *\n * @param {Object} hooks object containing all needed transport hooks\n */\nexport default class Transport {\n hooks: TransportHooks;\n\n constructor(hooks: TransportHooks) {\n this.hooks = hooks;\n }\n\n /** Returns whether the transport is supported in the environment.\n *\n * @param {Object} envronment te environment details (encryption, settings)\n * @returns {Boolean} true when the transport is supported\n */\n isSupported(environment: any): boolean {\n return this.hooks.isSupported(environment);\n }\n\n /** Creates a transport connection.\n *\n * @param {String} name\n * @param {Number} priority\n * @param {String} key the application key\n * @param {Object} options\n * @returns {TransportConnection}\n */\n createConnection(\n name: string,\n priority: number,\n key: string,\n options: any\n ): TransportConnection {\n return new TransportConnection(this.hooks, name, priority, key, options);\n }\n}\n","import * as URLSchemes from 'core/transports/url_schemes';\nimport URLScheme from 'core/transports/url_scheme';\nimport Transport from 'core/transports/transport';\nimport Util from 'core/util';\nimport * as Collections from 'core/utils/collections';\nimport TransportHooks from 'core/transports/transport_hooks';\nimport TransportsTable from 'core/transports/transports_table';\nimport Runtime from 'runtime';\n\n/** WebSocket transport.\n *\n * Uses native WebSocket implementation, including MozWebSocket supported by\n * earlier Firefox versions.\n */\nvar WSTransport = new Transport({\n urls: URLSchemes.ws,\n handlesActivityChecks: false,\n supportsPing: false,\n\n isInitialized: function() {\n return Boolean(Runtime.getWebSocketAPI());\n },\n isSupported: function(): boolean {\n return Boolean(Runtime.getWebSocketAPI());\n },\n getSocket: function(url) {\n return Runtime.createWebSocket(url);\n }\n});\n\nvar httpConfiguration = {\n urls: URLSchemes.http,\n handlesActivityChecks: false,\n supportsPing: true,\n isInitialized: function() {\n return true;\n }\n};\n\nexport var streamingConfiguration = Collections.extend(\n {\n getSocket: function(url) {\n return Runtime.HTTPFactory.createStreamingSocket(url);\n }\n },\n httpConfiguration\n);\nexport var pollingConfiguration = Collections.extend(\n {\n getSocket: function(url) {\n return Runtime.HTTPFactory.createPollingSocket(url);\n }\n },\n httpConfiguration\n);\n\nvar xhrConfiguration = {\n isSupported: function(): boolean {\n return Runtime.isXHRSupported();\n }\n};\n\n/** HTTP streaming transport using CORS-enabled XMLHttpRequest. */\nvar XHRStreamingTransport = new Transport(\n (\n Collections.extend({}, streamingConfiguration, xhrConfiguration)\n )\n);\n\n/** HTTP long-polling transport using CORS-enabled XMLHttpRequest. */\nvar XHRPollingTransport = new Transport(\n Collections.extend({}, pollingConfiguration, xhrConfiguration)\n);\n\nvar Transports: TransportsTable = {\n ws: WSTransport,\n xhr_streaming: XHRStreamingTransport,\n xhr_polling: XHRPollingTransport\n};\n\nexport default Transports;\n","import {\n default as Transports,\n streamingConfiguration,\n pollingConfiguration\n} from 'isomorphic/transports/transports';\nimport Transport from 'core/transports/transport';\nimport TransportHooks from 'core/transports/transport_hooks';\nimport * as URLSchemes from 'core/transports/url_schemes';\nimport Runtime from 'runtime';\nimport { Dependencies } from '../dom/dependencies';\nimport * as Collections from 'core/utils/collections';\n\nvar SockJSTransport = new Transport({\n file: 'sockjs',\n urls: URLSchemes.sockjs,\n handlesActivityChecks: true,\n supportsPing: false,\n\n isSupported: function() {\n return true;\n },\n isInitialized: function() {\n return window.SockJS !== undefined;\n },\n getSocket: function(url, options) {\n return new window.SockJS(url, null, {\n js_path: Dependencies.getPath('sockjs', {\n useTLS: options.useTLS\n }),\n ignore_null_origin: options.ignoreNullOrigin\n });\n },\n beforeOpen: function(socket, path) {\n socket.send(\n JSON.stringify({\n path: path\n })\n );\n }\n});\n\nvar xdrConfiguration = {\n isSupported: function(environment): boolean {\n var yes = Runtime.isXDRSupported(environment.useTLS);\n return yes;\n }\n};\n\n/** HTTP streaming transport using XDomainRequest (IE 8,9). */\nvar XDRStreamingTransport = new Transport(\n (\n Collections.extend({}, streamingConfiguration, xdrConfiguration)\n )\n);\n\n/** HTTP long-polling transport using XDomainRequest (IE 8,9). */\nvar XDRPollingTransport = new Transport(\n Collections.extend({}, pollingConfiguration, xdrConfiguration)\n);\n\nTransports.xdr_streaming = XDRStreamingTransport;\nTransports.xdr_polling = XDRPollingTransport;\nTransports.sockjs = SockJSTransport;\n\nexport default Transports;\n","import Reachability from 'core/reachability';\nimport { default as EventsDispatcher } from 'core/events/dispatcher';\n\n/** Really basic interface providing network availability info.\n *\n * Emits:\n * - online - when browser goes online\n * - offline - when browser goes offline\n */\nexport class NetInfo extends EventsDispatcher implements Reachability {\n constructor() {\n super();\n var self = this;\n // This is okay, as IE doesn't support this stuff anyway.\n if (window.addEventListener !== undefined) {\n window.addEventListener(\n 'online',\n function() {\n self.emit('online');\n },\n false\n );\n window.addEventListener(\n 'offline',\n function() {\n self.emit('offline');\n },\n false\n );\n }\n }\n\n /** Returns whether browser is online or not\n *\n * Offline means definitely offline (no connection to router).\n * Inverse does NOT mean definitely online (only currently supported in Safari\n * and even there only means the device has a connection to the router).\n *\n * @return {Boolean}\n */\n isOnline(): boolean {\n if (window.navigator.onLine === undefined) {\n return true;\n } else {\n return window.navigator.onLine;\n }\n }\n}\n\nexport var Network = new NetInfo();\n","import Util from '../util';\nimport * as Collections from '../utils/collections';\nimport TransportManager from './transport_manager';\nimport TransportConnection from './transport_connection';\nimport Transport from './transport';\nimport PingDelayOptions from './ping_delay_options';\n\n/** Creates transport connections monitored by a transport manager.\n *\n * When a transport is closed, it might mean the environment does not support\n * it. It's possible that messages get stuck in an intermediate buffer or\n * proxies terminate inactive connections. To combat these problems,\n * assistants monitor the connection lifetime, report unclean exits and\n * adjust ping timeouts to keep the connection active. The decision to disable\n * a transport is the manager's responsibility.\n *\n * @param {TransportManager} manager\n * @param {TransportConnection} transport\n * @param {Object} options\n */\nexport default class AssistantToTheTransportManager {\n manager: TransportManager;\n transport: Transport;\n minPingDelay: number;\n maxPingDelay: number;\n pingDelay: number;\n\n constructor(\n manager: TransportManager,\n transport: Transport,\n options: PingDelayOptions\n ) {\n this.manager = manager;\n this.transport = transport;\n this.minPingDelay = options.minPingDelay;\n this.maxPingDelay = options.maxPingDelay;\n this.pingDelay = undefined;\n }\n\n /** Creates a transport connection.\n *\n * This function has the same API as Transport#createConnection.\n *\n * @param {String} name\n * @param {Number} priority\n * @param {String} key the application key\n * @param {Object} options\n * @returns {TransportConnection}\n */\n createConnection(\n name: string,\n priority: number,\n key: string,\n options: Object\n ): TransportConnection {\n options = Collections.extend({}, options, {\n activityTimeout: this.pingDelay\n });\n var connection = this.transport.createConnection(\n name,\n priority,\n key,\n options\n );\n\n var openTimestamp = null;\n\n var onOpen = function() {\n connection.unbind('open', onOpen);\n connection.bind('closed', onClosed);\n openTimestamp = Util.now();\n };\n var onClosed = closeEvent => {\n connection.unbind('closed', onClosed);\n\n if (closeEvent.code === 1002 || closeEvent.code === 1003) {\n // we don't want to use transports not obeying the protocol\n this.manager.reportDeath();\n } else if (!closeEvent.wasClean && openTimestamp) {\n // report deaths only for short-living transport\n var lifespan = Util.now() - openTimestamp;\n if (lifespan < 2 * this.maxPingDelay) {\n this.manager.reportDeath();\n this.pingDelay = Math.max(lifespan / 2, this.minPingDelay);\n }\n }\n };\n\n connection.bind('open', onOpen);\n return connection;\n }\n\n /** Returns whether the transport is supported in the environment.\n *\n * This function has the same API as Transport#isSupported. Might return false\n * when the manager decides to kill the transport.\n *\n * @param {Object} environment the environment details (encryption, settings)\n * @returns {Boolean} true when the transport is supported\n */\n isSupported(environment: string): boolean {\n return this.manager.isAlive() && this.transport.isSupported(environment);\n }\n}\n","import Action from './action';\nimport { PusherEvent } from './message-types';\n/**\n * Provides functions for handling Pusher protocol-specific messages.\n */\n\nconst Protocol = {\n /**\n * Decodes a message in a Pusher format.\n *\n * The MessageEvent we receive from the transport should contain a pusher event\n * (https://pusher.com/docs/pusher_protocol#events) serialized as JSON in the\n * data field\n *\n * The pusher event may contain a data field too, and it may also be\n * serialised as JSON\n *\n * Throws errors when messages are not parse'able.\n *\n * @param {MessageEvent} messageEvent\n * @return {PusherEvent}\n */\n decodeMessage: function(messageEvent: MessageEvent): PusherEvent {\n try {\n var messageData = JSON.parse(messageEvent.data);\n var pusherEventData = messageData.data;\n if (typeof pusherEventData === 'string') {\n try {\n pusherEventData = JSON.parse(messageData.data);\n } catch (e) {}\n }\n var pusherEvent: PusherEvent = {\n event: messageData.event,\n channel: messageData.channel,\n data: pusherEventData\n };\n if (messageData.user_id) {\n pusherEvent.user_id = messageData.user_id;\n }\n return pusherEvent;\n } catch (e) {\n throw { type: 'MessageParseError', error: e, data: messageEvent.data };\n }\n },\n\n /**\n * Encodes a message to be sent.\n *\n * @param {PusherEvent} event\n * @return {String}\n */\n encodeMessage: function(event: PusherEvent): string {\n return JSON.stringify(event);\n },\n\n /**\n * Processes a handshake message and returns appropriate actions.\n *\n * Returns an object with an 'action' and other action-specific properties.\n *\n * There are three outcomes when calling this function. First is a successful\n * connection attempt, when pusher:connection_established is received, which\n * results in a 'connected' action with an 'id' property. When passed a\n * pusher:error event, it returns a result with action appropriate to the\n * close code and an error. Otherwise, it raises an exception.\n *\n * @param {String} message\n * @result Object\n */\n processHandshake: function(messageEvent: MessageEvent): Action {\n var message = Protocol.decodeMessage(messageEvent);\n\n if (message.event === 'pusher:connection_established') {\n if (!message.data.activity_timeout) {\n throw 'No activity timeout specified in handshake';\n }\n return {\n action: 'connected',\n id: message.data.socket_id,\n activityTimeout: message.data.activity_timeout * 1000\n };\n } else if (message.event === 'pusher:error') {\n // From protocol 6 close codes are sent only once, so this only\n // happens when connection does not support close codes\n return {\n action: this.getCloseAction(message.data),\n error: this.getCloseError(message.data)\n };\n } else {\n throw 'Invalid handshake';\n }\n },\n\n /**\n * Dispatches the close event and returns an appropriate action name.\n *\n * See:\n * 1. https://developer.mozilla.org/en-US/docs/WebSockets/WebSockets_reference/CloseEvent\n * 2. http://pusher.com/docs/pusher_protocol\n *\n * @param {CloseEvent} closeEvent\n * @return {String} close action name\n */\n getCloseAction: function(closeEvent): string {\n if (closeEvent.code < 4000) {\n // ignore 1000 CLOSE_NORMAL, 1001 CLOSE_GOING_AWAY,\n // 1005 CLOSE_NO_STATUS, 1006 CLOSE_ABNORMAL\n // ignore 1007...3999\n // handle 1002 CLOSE_PROTOCOL_ERROR, 1003 CLOSE_UNSUPPORTED,\n // 1004 CLOSE_TOO_LARGE\n if (closeEvent.code >= 1002 && closeEvent.code <= 1004) {\n return 'backoff';\n } else {\n return null;\n }\n } else if (closeEvent.code === 4000) {\n return 'tls_only';\n } else if (closeEvent.code < 4100) {\n return 'refused';\n } else if (closeEvent.code < 4200) {\n return 'backoff';\n } else if (closeEvent.code < 4300) {\n return 'retry';\n } else {\n // unknown error\n return 'refused';\n }\n },\n\n /**\n * Returns an error or null basing on the close event.\n *\n * Null is returned when connection was closed cleanly. Otherwise, an object\n * with error details is returned.\n *\n * @param {CloseEvent} closeEvent\n * @return {Object} error object\n */\n getCloseError: function(closeEvent): any {\n if (closeEvent.code !== 1000 && closeEvent.code !== 1001) {\n return {\n type: 'PusherError',\n data: {\n code: closeEvent.code,\n message: closeEvent.reason || closeEvent.message\n }\n };\n } else {\n return null;\n }\n }\n};\n\nexport default Protocol;\n","import * as Collections from '../utils/collections';\nimport { default as EventsDispatcher } from '../events/dispatcher';\nimport Protocol from './protocol/protocol';\nimport { PusherEvent } from './protocol/message-types';\nimport Logger from '../logger';\nimport TransportConnection from '../transports/transport_connection';\nimport Socket from '../socket';\n/**\n * Provides Pusher protocol interface for transports.\n *\n * Emits following events:\n * - message - on received messages\n * - ping - on ping requests\n * - pong - on pong responses\n * - error - when the transport emits an error\n * - closed - after closing the transport\n *\n * It also emits more events when connection closes with a code.\n * See Protocol.getCloseAction to get more details.\n *\n * @param {Number} id\n * @param {AbstractTransport} transport\n */\nexport default class Connection extends EventsDispatcher implements Socket {\n id: string;\n transport: TransportConnection;\n activityTimeout: number;\n\n constructor(id: string, transport: TransportConnection) {\n super();\n this.id = id;\n this.transport = transport;\n this.activityTimeout = transport.activityTimeout;\n this.bindListeners();\n }\n\n /** Returns whether used transport handles activity checks by itself\n *\n * @returns {Boolean} true if activity checks are handled by the transport\n */\n handlesActivityChecks() {\n return this.transport.handlesActivityChecks();\n }\n\n /** Sends raw data.\n *\n * @param {String} data\n */\n send(data: any): boolean {\n return this.transport.send(data);\n }\n\n /** Sends an event.\n *\n * @param {String} name\n * @param {String} data\n * @param {String} [channel]\n * @returns {Boolean} whether message was sent or not\n */\n send_event(name: string, data: any, channel?: string): boolean {\n var event: PusherEvent = { event: name, data: data };\n if (channel) {\n event.channel = channel;\n }\n Logger.debug('Event sent', event);\n return this.send(Protocol.encodeMessage(event));\n }\n\n /** Sends a ping message to the server.\n *\n * Basing on the underlying transport, it might send either transport's\n * protocol-specific ping or pusher:ping event.\n */\n ping() {\n if (this.transport.supportsPing()) {\n this.transport.ping();\n } else {\n this.send_event('pusher:ping', {});\n }\n }\n\n /** Closes the connection. */\n close() {\n this.transport.close();\n }\n\n private bindListeners() {\n var listeners = {\n message: (messageEvent: MessageEvent) => {\n var pusherEvent;\n try {\n pusherEvent = Protocol.decodeMessage(messageEvent);\n } catch (e) {\n this.emit('error', {\n type: 'MessageParseError',\n error: e,\n data: messageEvent.data\n });\n }\n\n if (pusherEvent !== undefined) {\n Logger.debug('Event recd', pusherEvent);\n\n switch (pusherEvent.event) {\n case 'pusher:error':\n this.emit('error', {\n type: 'PusherError',\n data: pusherEvent.data\n });\n break;\n case 'pusher:ping':\n this.emit('ping');\n break;\n case 'pusher:pong':\n this.emit('pong');\n break;\n }\n this.emit('message', pusherEvent);\n }\n },\n activity: () => {\n this.emit('activity');\n },\n error: error => {\n this.emit('error', error);\n },\n closed: closeEvent => {\n unbindListeners();\n\n if (closeEvent && closeEvent.code) {\n this.handleCloseEvent(closeEvent);\n }\n\n this.transport = null;\n this.emit('closed');\n }\n };\n\n var unbindListeners = () => {\n Collections.objectApply(listeners, (listener, event) => {\n this.transport.unbind(event, listener);\n });\n };\n\n Collections.objectApply(listeners, (listener, event) => {\n this.transport.bind(event, listener);\n });\n }\n\n private handleCloseEvent(closeEvent: any) {\n var action = Protocol.getCloseAction(closeEvent);\n var error = Protocol.getCloseError(closeEvent);\n if (error) {\n this.emit('error', error);\n }\n if (action) {\n this.emit(action, { action: action, error: error });\n }\n }\n}\n","import Util from '../../util';\nimport * as Collections from '../../utils/collections';\nimport Protocol from '../protocol/protocol';\nimport Connection from '../connection';\nimport TransportConnection from '../../transports/transport_connection';\nimport HandshakePayload from './handshake_payload';\n\n/**\n * Handles Pusher protocol handshakes for transports.\n *\n * Calls back with a result object after handshake is completed. Results\n * always have two fields:\n * - action - string describing action to be taken after the handshake\n * - transport - the transport object passed to the constructor\n *\n * Different actions can set different additional properties on the result.\n * In the case of 'connected' action, there will be a 'connection' property\n * containing a Connection object for the transport. Other actions should\n * carry an 'error' property.\n *\n * @param {AbstractTransport} transport\n * @param {Function} callback\n */\nexport default class Handshake {\n transport: TransportConnection;\n callback: (HandshakePayload) => void;\n onMessage: Function;\n onClosed: Function;\n\n constructor(\n transport: TransportConnection,\n callback: (HandshakePayload) => void\n ) {\n this.transport = transport;\n this.callback = callback;\n this.bindListeners();\n }\n\n close() {\n this.unbindListeners();\n this.transport.close();\n }\n\n private bindListeners() {\n this.onMessage = m => {\n this.unbindListeners();\n\n var result;\n try {\n result = Protocol.processHandshake(m);\n } catch (e) {\n this.finish('error', { error: e });\n this.transport.close();\n return;\n }\n\n if (result.action === 'connected') {\n this.finish('connected', {\n connection: new Connection(result.id, this.transport),\n activityTimeout: result.activityTimeout\n });\n } else {\n this.finish(result.action, { error: result.error });\n this.transport.close();\n }\n };\n\n this.onClosed = closeEvent => {\n this.unbindListeners();\n\n var action = Protocol.getCloseAction(closeEvent) || 'backoff';\n var error = Protocol.getCloseError(closeEvent);\n this.finish(action, { error: error });\n };\n\n this.transport.bind('message', this.onMessage);\n this.transport.bind('closed', this.onClosed);\n }\n\n private unbindListeners() {\n this.transport.unbind('message', this.onMessage);\n this.transport.unbind('closed', this.onClosed);\n }\n\n private finish(action: string, params: any) {\n this.callback(\n Collections.extend({ transport: this.transport, action: action }, params)\n );\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport base64encode from '../base64';\nimport Timeline from './timeline';\nimport Runtime from 'runtime';\n\nexport interface TimelineSenderOptions {\n host?: string;\n port?: number;\n path?: string;\n}\n\nexport default class TimelineSender {\n timeline: Timeline;\n options: TimelineSenderOptions;\n host: string;\n\n constructor(timeline: Timeline, options: TimelineSenderOptions) {\n this.timeline = timeline;\n this.options = options || {};\n }\n\n send(useTLS: boolean, callback?: Function) {\n if (this.timeline.isEmpty()) {\n return;\n }\n\n this.timeline.send(\n Runtime.TimelineTransport.getAgent(this, useTLS),\n callback\n );\n }\n}\n","import { default as EventsDispatcher } from '../events/dispatcher';\nimport * as Errors from '../errors';\nimport Logger from '../logger';\nimport Pusher from '../pusher';\nimport { PusherEvent } from '../connection/protocol/message-types';\nimport Metadata from './metadata';\nimport UrlStore from '../utils/url_store';\nimport {\n ChannelAuthorizationData,\n ChannelAuthorizationCallback\n} from '../auth/options';\nimport { HTTPAuthError } from '../errors';\n\n/** Provides base public channel interface with an event emitter.\n *\n * Emits:\n * - pusher:subscription_succeeded - after subscribing successfully\n * - other non-internal events\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\nexport default class Channel extends EventsDispatcher {\n name: string;\n pusher: Pusher;\n subscribed: boolean;\n subscriptionPending: boolean;\n subscriptionCancelled: boolean;\n subscriptionCount: null;\n\n constructor(name: string, pusher: Pusher) {\n super(function(event, data) {\n Logger.debug('No callbacks on ' + name + ' for ' + event);\n });\n\n this.name = name;\n this.pusher = pusher;\n this.subscribed = false;\n this.subscriptionPending = false;\n this.subscriptionCancelled = false;\n }\n\n /** Skips authorization, since public channels don't require it.\n *\n * @param {Function} callback\n */\n authorize(socketId: string, callback: ChannelAuthorizationCallback) {\n return callback(null, { auth: '' });\n }\n\n /** Triggers an event */\n trigger(event: string, data: any) {\n if (event.indexOf('client-') !== 0) {\n throw new Errors.BadEventName(\n \"Event '\" + event + \"' does not start with 'client-'\"\n );\n }\n if (!this.subscribed) {\n var suffix = UrlStore.buildLogSuffix('triggeringClientEvents');\n Logger.warn(\n `Client event triggered before channel 'subscription_succeeded' event . ${suffix}`\n );\n }\n return this.pusher.send_event(event, data, this.name);\n }\n\n /** Signals disconnection to the channel. For internal use only. */\n disconnect() {\n this.subscribed = false;\n this.subscriptionPending = false;\n }\n\n /** Handles a PusherEvent. For internal use only.\n *\n * @param {PusherEvent} event\n */\n handleEvent(event: PusherEvent) {\n var eventName = event.event;\n var data = event.data;\n if (eventName === 'pusher_internal:subscription_succeeded') {\n this.handleSubscriptionSucceededEvent(event);\n } else if (eventName === 'pusher_internal:subscription_count') {\n this.handleSubscriptionCountEvent(event);\n } else if (eventName.indexOf('pusher_internal:') !== 0) {\n var metadata: Metadata = {};\n this.emit(eventName, data, metadata);\n }\n }\n\n handleSubscriptionSucceededEvent(event: PusherEvent) {\n this.subscriptionPending = false;\n this.subscribed = true;\n if (this.subscriptionCancelled) {\n this.pusher.unsubscribe(this.name);\n } else {\n this.emit('pusher:subscription_succeeded', event.data);\n }\n }\n\n handleSubscriptionCountEvent(event: PusherEvent) {\n if (event.data.subscription_count) {\n this.subscriptionCount = event.data.subscription_count;\n }\n\n this.emit('pusher:subscription_count', event.data);\n }\n\n /** Sends a subscription request. For internal use only. */\n subscribe() {\n if (this.subscribed) {\n return;\n }\n this.subscriptionPending = true;\n this.subscriptionCancelled = false;\n this.authorize(\n this.pusher.connection.socket_id,\n (error: Error | null, data: ChannelAuthorizationData) => {\n if (error) {\n this.subscriptionPending = false;\n // Why not bind to 'pusher:subscription_error' a level up, and log there?\n // Binding to this event would cause the warning about no callbacks being\n // bound (see constructor) to be suppressed, that's not what we want.\n Logger.error(error.toString());\n this.emit(\n 'pusher:subscription_error',\n Object.assign(\n {},\n {\n type: 'AuthError',\n error: error.message\n },\n error instanceof HTTPAuthError ? { status: error.status } : {}\n )\n );\n } else {\n this.pusher.send_event('pusher:subscribe', {\n auth: data.auth,\n channel_data: data.channel_data,\n channel: this.name\n });\n }\n }\n );\n }\n\n /** Sends an unsubscription request. For internal use only. */\n unsubscribe() {\n this.subscribed = false;\n this.pusher.send_event('pusher:unsubscribe', {\n channel: this.name\n });\n }\n\n /** Cancels an in progress subscription. For internal use only. */\n cancelSubscription() {\n this.subscriptionCancelled = true;\n }\n\n /** Reinstates an in progress subscripiton. For internal use only. */\n reinstateSubscription() {\n this.subscriptionCancelled = false;\n }\n}\n","import Factory from '../utils/factory';\nimport Channel from './channel';\nimport { ChannelAuthorizationCallback } from '../auth/options';\n\n/** Extends public channels to provide private channel interface.\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\nexport default class PrivateChannel extends Channel {\n /** Authorizes the connection to use the channel.\n *\n * @param {String} socketId\n * @param {Function} callback\n */\n authorize(socketId: string, callback: ChannelAuthorizationCallback) {\n return this.pusher.config.channelAuthorizer(\n {\n channelName: this.name,\n socketId: socketId\n },\n callback\n );\n }\n}\n","import * as Collections from '../utils/collections';\n\n/** Represents a collection of members of a presence channel. */\nexport default class Members {\n members: any;\n count: number;\n myID: any;\n me: any;\n\n constructor() {\n this.reset();\n }\n\n /** Returns member's info for given id.\n *\n * Resulting object containts two fields - id and info.\n *\n * @param {Number} id\n * @return {Object} member's info or null\n */\n get(id: string): any {\n if (Object.prototype.hasOwnProperty.call(this.members, id)) {\n return {\n id: id,\n info: this.members[id]\n };\n } else {\n return null;\n }\n }\n\n /** Calls back for each member in unspecified order.\n *\n * @param {Function} callback\n */\n each(callback: Function) {\n Collections.objectApply(this.members, (member, id) => {\n callback(this.get(id));\n });\n }\n\n /** Updates the id for connected member. For internal use only. */\n setMyID(id: string) {\n this.myID = id;\n }\n\n /** Handles subscription data. For internal use only. */\n onSubscription(subscriptionData: any) {\n this.members = subscriptionData.presence.hash;\n this.count = subscriptionData.presence.count;\n this.me = this.get(this.myID);\n }\n\n /** Adds a new member to the collection. For internal use only. */\n addMember(memberData: any) {\n if (this.get(memberData.user_id) === null) {\n this.count++;\n }\n this.members[memberData.user_id] = memberData.user_info;\n return this.get(memberData.user_id);\n }\n\n /** Adds a member from the collection. For internal use only. */\n removeMember(memberData: any) {\n var member = this.get(memberData.user_id);\n if (member) {\n delete this.members[memberData.user_id];\n this.count--;\n }\n return member;\n }\n\n /** Resets the collection to the initial state. For internal use only. */\n reset() {\n this.members = {};\n this.count = 0;\n this.myID = null;\n this.me = null;\n }\n}\n","import PrivateChannel from './private_channel';\nimport Logger from '../logger';\nimport Members from './members';\nimport Pusher from '../pusher';\nimport UrlStore from 'core/utils/url_store';\nimport { PusherEvent } from '../connection/protocol/message-types';\nimport Metadata from './metadata';\nimport { ChannelAuthorizationData } from '../auth/options';\n\nexport default class PresenceChannel extends PrivateChannel {\n members: Members;\n\n /** Adds presence channel functionality to private channels.\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\n constructor(name: string, pusher: Pusher) {\n super(name, pusher);\n this.members = new Members();\n }\n\n /** Authorizes the connection as a member of the channel.\n *\n * @param {String} socketId\n * @param {Function} callback\n */\n authorize(socketId: string, callback: Function) {\n super.authorize(socketId, async (error, authData) => {\n if (!error) {\n authData = authData as ChannelAuthorizationData;\n if (authData.channel_data != null) {\n var channelData = JSON.parse(authData.channel_data);\n this.members.setMyID(channelData.user_id);\n } else {\n await this.pusher.user.signinDonePromise;\n if (this.pusher.user.user_data != null) {\n // If the user is signed in, get the id of the authenticated user\n // and allow the presence authorization to continue.\n this.members.setMyID(this.pusher.user.user_data.id);\n } else {\n let suffix = UrlStore.buildLogSuffix('authorizationEndpoint');\n Logger.error(\n `Invalid auth response for channel '${this.name}', ` +\n `expected 'channel_data' field. ${suffix}, ` +\n `or the user should be signed in.`\n );\n callback('Invalid auth response');\n return;\n }\n }\n }\n callback(error, authData);\n });\n }\n\n /** Handles presence and subscription events. For internal use only.\n *\n * @param {PusherEvent} event\n */\n handleEvent(event: PusherEvent) {\n var eventName = event.event;\n if (eventName.indexOf('pusher_internal:') === 0) {\n this.handleInternalEvent(event);\n } else {\n var data = event.data;\n var metadata: Metadata = {};\n if (event.user_id) {\n metadata.user_id = event.user_id;\n }\n this.emit(eventName, data, metadata);\n }\n }\n handleInternalEvent(event: PusherEvent) {\n var eventName = event.event;\n var data = event.data;\n switch (eventName) {\n case 'pusher_internal:subscription_succeeded':\n this.handleSubscriptionSucceededEvent(event);\n break;\n case 'pusher_internal:subscription_count':\n this.handleSubscriptionCountEvent(event);\n break;\n case 'pusher_internal:member_added':\n var addedMember = this.members.addMember(data);\n this.emit('pusher:member_added', addedMember);\n break;\n case 'pusher_internal:member_removed':\n var removedMember = this.members.removeMember(data);\n if (removedMember) {\n this.emit('pusher:member_removed', removedMember);\n }\n break;\n }\n }\n\n handleSubscriptionSucceededEvent(event: PusherEvent) {\n this.subscriptionPending = false;\n this.subscribed = true;\n if (this.subscriptionCancelled) {\n this.pusher.unsubscribe(this.name);\n } else {\n this.members.onSubscription(event.data);\n this.emit('pusher:subscription_succeeded', this.members);\n }\n }\n\n /** Resets the channel state, including members map. For internal use only. */\n disconnect() {\n this.members.reset();\n super.disconnect();\n }\n}\n","import PrivateChannel from './private_channel';\nimport * as Errors from '../errors';\nimport Logger from '../logger';\nimport Pusher from '../pusher';\nimport { decode as encodeUTF8 } from '@stablelib/utf8';\nimport { decode as decodeBase64 } from '@stablelib/base64';\nimport Dispatcher from '../events/dispatcher';\nimport { PusherEvent } from '../connection/protocol/message-types';\nimport {\n ChannelAuthorizationData,\n ChannelAuthorizationCallback\n} from '../auth/options';\nimport * as nacl from 'tweetnacl';\n\n/** Extends private channels to provide encrypted channel interface.\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\nexport default class EncryptedChannel extends PrivateChannel {\n key: Uint8Array = null;\n nacl: nacl;\n\n constructor(name: string, pusher: Pusher, nacl: nacl) {\n super(name, pusher);\n this.nacl = nacl;\n }\n\n /** Authorizes the connection to use the channel.\n *\n * @param {String} socketId\n * @param {Function} callback\n */\n authorize(socketId: string, callback: ChannelAuthorizationCallback) {\n super.authorize(\n socketId,\n (error: Error | null, authData: ChannelAuthorizationData) => {\n if (error) {\n callback(error, authData);\n return;\n }\n let sharedSecret = authData['shared_secret'];\n if (!sharedSecret) {\n callback(\n new Error(\n `No shared_secret key in auth payload for encrypted channel: ${this.name}`\n ),\n null\n );\n return;\n }\n this.key = decodeBase64(sharedSecret);\n delete authData['shared_secret'];\n callback(null, authData);\n }\n );\n }\n\n trigger(event: string, data: any): boolean {\n throw new Errors.UnsupportedFeature(\n 'Client events are not currently supported for encrypted channels'\n );\n }\n\n /** Handles an event. For internal use only.\n *\n * @param {PusherEvent} event\n */\n handleEvent(event: PusherEvent) {\n var eventName = event.event;\n var data = event.data;\n if (\n eventName.indexOf('pusher_internal:') === 0 ||\n eventName.indexOf('pusher:') === 0\n ) {\n super.handleEvent(event);\n return;\n }\n this.handleEncryptedEvent(eventName, data);\n }\n\n private handleEncryptedEvent(event: string, data: any): void {\n if (!this.key) {\n Logger.debug(\n 'Received encrypted event before key has been retrieved from the authEndpoint'\n );\n return;\n }\n if (!data.ciphertext || !data.nonce) {\n Logger.error(\n 'Unexpected format for encrypted event, expected object with `ciphertext` and `nonce` fields, got: ' +\n data\n );\n return;\n }\n let cipherText = decodeBase64(data.ciphertext);\n if (cipherText.length < this.nacl.secretbox.overheadLength) {\n Logger.error(\n `Expected encrypted event ciphertext length to be ${this.nacl.secretbox.overheadLength}, got: ${cipherText.length}`\n );\n return;\n }\n let nonce = decodeBase64(data.nonce);\n if (nonce.length < this.nacl.secretbox.nonceLength) {\n Logger.error(\n `Expected encrypted event nonce length to be ${this.nacl.secretbox.nonceLength}, got: ${nonce.length}`\n );\n return;\n }\n\n let bytes = this.nacl.secretbox.open(cipherText, nonce, this.key);\n if (bytes === null) {\n Logger.debug(\n 'Failed to decrypt an event, probably because it was encrypted with a different key. Fetching a new key from the authEndpoint...'\n );\n // Try a single time to retrieve a new auth key and decrypt the event with it\n // If this fails, a new key will be requested when a new message is received\n this.authorize(this.pusher.connection.socket_id, (error, authData) => {\n if (error) {\n Logger.error(\n `Failed to make a request to the authEndpoint: ${authData}. Unable to fetch new key, so dropping encrypted event`\n );\n return;\n }\n bytes = this.nacl.secretbox.open(cipherText, nonce, this.key);\n if (bytes === null) {\n Logger.error(\n `Failed to decrypt event with new key. Dropping encrypted event`\n );\n return;\n }\n this.emit(event, this.getDataToEmit(bytes));\n return;\n });\n return;\n }\n this.emit(event, this.getDataToEmit(bytes));\n }\n\n // Try and parse the decrypted bytes as JSON. If we can't parse it, just\n // return the utf-8 string\n getDataToEmit(bytes: Uint8Array): string {\n let raw = encodeUTF8(bytes);\n try {\n return JSON.parse(raw);\n } catch {\n return raw;\n }\n }\n}\n","import { default as EventsDispatcher } from '../events/dispatcher';\nimport { OneOffTimer as Timer } from '../utils/timers';\nimport { Config } from '../config';\nimport Logger from '../logger';\nimport HandshakePayload from './handshake/handshake_payload';\nimport Connection from './connection';\nimport Strategy from '../strategies/strategy';\nimport StrategyRunner from '../strategies/strategy_runner';\nimport * as Collections from '../utils/collections';\nimport Timeline from '../timeline/timeline';\nimport ConnectionManagerOptions from './connection_manager_options';\nimport Runtime from 'runtime';\n\nimport {\n ErrorCallbacks,\n HandshakeCallbacks,\n ConnectionCallbacks\n} from './callbacks';\nimport Action from './protocol/action';\n\n/** Manages connection to Pusher.\n *\n * Uses a strategy (currently only default), timers and network availability\n * info to establish a connection and export its state. In case of failures,\n * manages reconnection attempts.\n *\n * Exports state changes as following events:\n * - \"state_change\", { previous: p, current: state }\n * - state\n *\n * States:\n * - initialized - initial state, never transitioned to\n * - connecting - connection is being established\n * - connected - connection has been fully established\n * - disconnected - on requested disconnection\n * - unavailable - after connection timeout or when there's no network\n * - failed - when the connection strategy is not supported\n *\n * Options:\n * - unavailableTimeout - time to transition to unavailable state\n * - activityTimeout - time after which ping message should be sent\n * - pongTimeout - time for Pusher to respond with pong before reconnecting\n *\n * @param {String} key application key\n * @param {Object} options\n */\nexport default class ConnectionManager extends EventsDispatcher {\n key: string;\n options: ConnectionManagerOptions;\n state: string;\n connection: Connection;\n usingTLS: boolean;\n timeline: Timeline;\n socket_id: string;\n unavailableTimer: Timer;\n activityTimer: Timer;\n retryTimer: Timer;\n activityTimeout: number;\n strategy: Strategy;\n runner: StrategyRunner;\n errorCallbacks: ErrorCallbacks;\n handshakeCallbacks: HandshakeCallbacks;\n connectionCallbacks: ConnectionCallbacks;\n\n constructor(key: string, options: ConnectionManagerOptions) {\n super();\n this.state = 'initialized';\n this.connection = null;\n\n this.key = key;\n this.options = options;\n this.timeline = this.options.timeline;\n this.usingTLS = this.options.useTLS;\n\n this.errorCallbacks = this.buildErrorCallbacks();\n this.connectionCallbacks = this.buildConnectionCallbacks(\n this.errorCallbacks\n );\n this.handshakeCallbacks = this.buildHandshakeCallbacks(this.errorCallbacks);\n\n var Network = Runtime.getNetwork();\n\n Network.bind('online', () => {\n this.timeline.info({ netinfo: 'online' });\n if (this.state === 'connecting' || this.state === 'unavailable') {\n this.retryIn(0);\n }\n });\n Network.bind('offline', () => {\n this.timeline.info({ netinfo: 'offline' });\n if (this.connection) {\n this.sendActivityCheck();\n }\n });\n\n this.updateStrategy();\n }\n\n switchCluster(key: string) {\n this.key = key;\n // This ensures that the new config coming from\n // pusher instance are taken into account\n // such as appKey and cluster\n this.updateStrategy();\n this.retryIn(0);\n }\n\n /** Establishes a connection to Pusher.\n *\n * Does nothing when connection is already established. See top-level doc\n * to find events emitted on connection attempts.\n */\n connect() {\n if (this.connection || this.runner) {\n return;\n }\n if (!this.strategy.isSupported()) {\n this.updateState('failed');\n return;\n }\n this.updateState('connecting');\n this.startConnecting();\n this.setUnavailableTimer();\n }\n\n /** Sends raw data.\n *\n * @param {String} data\n */\n send(data) {\n if (this.connection) {\n return this.connection.send(data);\n } else {\n return false;\n }\n }\n\n /** Sends an event.\n *\n * @param {String} name\n * @param {String} data\n * @param {String} [channel]\n * @returns {Boolean} whether message was sent or not\n */\n send_event(name: string, data: any, channel?: string) {\n if (this.connection) {\n return this.connection.send_event(name, data, channel);\n } else {\n return false;\n }\n }\n\n /** Closes the connection. */\n disconnect() {\n this.disconnectInternally();\n this.updateState('disconnected');\n }\n\n isUsingTLS() {\n return this.usingTLS;\n }\n\n private startConnecting() {\n var callback = (error, handshake) => {\n if (error) {\n this.runner = this.strategy.connect(0, callback);\n } else {\n if (handshake.action === 'error') {\n this.emit('error', {\n type: 'HandshakeError',\n error: handshake.error\n });\n this.timeline.error({ handshakeError: handshake.error });\n } else {\n this.abortConnecting(); // we don't support switching connections yet\n this.handshakeCallbacks[handshake.action](handshake);\n }\n }\n };\n this.runner = this.strategy.connect(0, callback);\n }\n\n private abortConnecting() {\n if (this.runner) {\n this.runner.abort();\n this.runner = null;\n }\n }\n\n private disconnectInternally() {\n this.abortConnecting();\n this.clearRetryTimer();\n this.clearUnavailableTimer();\n if (this.connection) {\n var connection = this.abandonConnection();\n connection.close();\n }\n }\n\n private updateStrategy() {\n this.strategy = this.options.getStrategy({\n key: this.key,\n timeline: this.timeline,\n useTLS: this.usingTLS\n });\n }\n\n private retryIn(delay) {\n this.timeline.info({ action: 'retry', delay: delay });\n if (delay > 0) {\n this.emit('connecting_in', Math.round(delay / 1000));\n }\n this.retryTimer = new Timer(delay || 0, () => {\n this.disconnectInternally();\n this.connect();\n });\n }\n\n private clearRetryTimer() {\n if (this.retryTimer) {\n this.retryTimer.ensureAborted();\n this.retryTimer = null;\n }\n }\n\n private setUnavailableTimer() {\n this.unavailableTimer = new Timer(this.options.unavailableTimeout, () => {\n this.updateState('unavailable');\n });\n }\n\n private clearUnavailableTimer() {\n if (this.unavailableTimer) {\n this.unavailableTimer.ensureAborted();\n }\n }\n\n private sendActivityCheck() {\n this.stopActivityCheck();\n this.connection.ping();\n // wait for pong response\n this.activityTimer = new Timer(this.options.pongTimeout, () => {\n this.timeline.error({ pong_timed_out: this.options.pongTimeout });\n this.retryIn(0);\n });\n }\n\n private resetActivityCheck() {\n this.stopActivityCheck();\n // send ping after inactivity\n if (this.connection && !this.connection.handlesActivityChecks()) {\n this.activityTimer = new Timer(this.activityTimeout, () => {\n this.sendActivityCheck();\n });\n }\n }\n\n private stopActivityCheck() {\n if (this.activityTimer) {\n this.activityTimer.ensureAborted();\n }\n }\n\n private buildConnectionCallbacks(\n errorCallbacks: ErrorCallbacks\n ): ConnectionCallbacks {\n return Collections.extend({}, errorCallbacks, {\n message: message => {\n // includes pong messages from server\n this.resetActivityCheck();\n this.emit('message', message);\n },\n ping: () => {\n this.send_event('pusher:pong', {});\n },\n activity: () => {\n this.resetActivityCheck();\n },\n error: error => {\n // just emit error to user - socket will already be closed by browser\n this.emit('error', error);\n },\n closed: () => {\n this.abandonConnection();\n if (this.shouldRetry()) {\n this.retryIn(1000);\n }\n }\n });\n }\n\n private buildHandshakeCallbacks(\n errorCallbacks: ErrorCallbacks\n ): HandshakeCallbacks {\n return Collections.extend({}, errorCallbacks, {\n connected: (handshake: HandshakePayload) => {\n this.activityTimeout = Math.min(\n this.options.activityTimeout,\n handshake.activityTimeout,\n handshake.connection.activityTimeout || Infinity\n );\n this.clearUnavailableTimer();\n this.setConnection(handshake.connection);\n this.socket_id = this.connection.id;\n this.updateState('connected', { socket_id: this.socket_id });\n }\n });\n }\n\n private buildErrorCallbacks(): ErrorCallbacks {\n let withErrorEmitted = callback => {\n return (result: Action | HandshakePayload) => {\n if (result.error) {\n this.emit('error', { type: 'WebSocketError', error: result.error });\n }\n callback(result);\n };\n };\n\n return {\n tls_only: withErrorEmitted(() => {\n this.usingTLS = true;\n this.updateStrategy();\n this.retryIn(0);\n }),\n refused: withErrorEmitted(() => {\n this.disconnect();\n }),\n backoff: withErrorEmitted(() => {\n this.retryIn(1000);\n }),\n retry: withErrorEmitted(() => {\n this.retryIn(0);\n })\n };\n }\n\n private setConnection(connection) {\n this.connection = connection;\n for (var event in this.connectionCallbacks) {\n this.connection.bind(event, this.connectionCallbacks[event]);\n }\n this.resetActivityCheck();\n }\n\n private abandonConnection() {\n if (!this.connection) {\n return;\n }\n this.stopActivityCheck();\n for (var event in this.connectionCallbacks) {\n this.connection.unbind(event, this.connectionCallbacks[event]);\n }\n var connection = this.connection;\n this.connection = null;\n return connection;\n }\n\n private updateState(newState: string, data?: any) {\n var previousState = this.state;\n this.state = newState;\n if (previousState !== newState) {\n var newStateDescription = newState;\n if (newStateDescription === 'connected') {\n newStateDescription += ' with new socket ID ' + data.socket_id;\n }\n Logger.debug(\n 'State changed',\n previousState + ' -> ' + newStateDescription\n );\n this.timeline.info({ state: newState, params: data });\n this.emit('state_change', { previous: previousState, current: newState });\n this.emit(newState, data);\n }\n }\n\n private shouldRetry(): boolean {\n return this.state === 'connecting' || this.state === 'connected';\n }\n}\n","import Channel from './channel';\nimport * as Collections from '../utils/collections';\nimport ChannelTable from './channel_table';\nimport Factory from '../utils/factory';\nimport Pusher from '../pusher';\nimport Logger from '../logger';\nimport * as Errors from '../errors';\nimport urlStore from '../utils/url_store';\n\n/** Handles a channel map. */\nexport default class Channels {\n channels: ChannelTable;\n\n constructor() {\n this.channels = {};\n }\n\n /** Creates or retrieves an existing channel by its name.\n *\n * @param {String} name\n * @param {Pusher} pusher\n * @return {Channel}\n */\n add(name: string, pusher: Pusher) {\n if (!this.channels[name]) {\n this.channels[name] = createChannel(name, pusher);\n }\n return this.channels[name];\n }\n\n /** Returns a list of all channels\n *\n * @return {Array}\n */\n all(): Channel[] {\n return Collections.values(this.channels);\n }\n\n /** Finds a channel by its name.\n *\n * @param {String} name\n * @return {Channel} channel or null if it doesn't exist\n */\n find(name: string) {\n return this.channels[name];\n }\n\n /** Removes a channel from the map.\n *\n * @param {String} name\n */\n remove(name: string) {\n var channel = this.channels[name];\n delete this.channels[name];\n return channel;\n }\n\n /** Proxies disconnection signal to all channels. */\n disconnect() {\n Collections.objectApply(this.channels, function(channel) {\n channel.disconnect();\n });\n }\n}\n\nfunction createChannel(name: string, pusher: Pusher): Channel {\n if (name.indexOf('private-encrypted-') === 0) {\n if (pusher.config.nacl) {\n return Factory.createEncryptedChannel(name, pusher, pusher.config.nacl);\n }\n let errMsg =\n 'Tried to subscribe to a private-encrypted- channel but no nacl implementation available';\n let suffix = urlStore.buildLogSuffix('encryptedChannelSupport');\n throw new Errors.UnsupportedFeature(`${errMsg}. ${suffix}`);\n } else if (name.indexOf('private-') === 0) {\n return Factory.createPrivateChannel(name, pusher);\n } else if (name.indexOf('presence-') === 0) {\n return Factory.createPresenceChannel(name, pusher);\n } else if (name.indexOf('#') === 0) {\n throw new Errors.BadChannelName(\n 'Cannot create a channel with name \"' + name + '\".'\n );\n } else {\n return Factory.createChannel(name, pusher);\n }\n}\n","import AssistantToTheTransportManager from '../transports/assistant_to_the_transport_manager';\nimport PingDelayOptions from '../transports/ping_delay_options';\nimport Transport from '../transports/transport';\nimport TransportManager from '../transports/transport_manager';\nimport Handshake from '../connection/handshake';\nimport TransportConnection from '../transports/transport_connection';\nimport SocketHooks from '../http/socket_hooks';\nimport HTTPSocket from '../http/http_socket';\n\nimport Timeline from '../timeline/timeline';\nimport {\n default as TimelineSender,\n TimelineSenderOptions\n} from '../timeline/timeline_sender';\nimport PresenceChannel from '../channels/presence_channel';\nimport PrivateChannel from '../channels/private_channel';\nimport EncryptedChannel from '../channels/encrypted_channel';\nimport Channel from '../channels/channel';\nimport ConnectionManager from '../connection/connection_manager';\nimport ConnectionManagerOptions from '../connection/connection_manager_options';\nimport Ajax from '../http/ajax';\nimport Channels from '../channels/channels';\nimport Pusher from '../pusher';\nimport { Config } from '../config';\nimport * as nacl from 'tweetnacl';\n\nvar Factory = {\n createChannels(): Channels {\n return new Channels();\n },\n\n createConnectionManager(\n key: string,\n options: ConnectionManagerOptions\n ): ConnectionManager {\n return new ConnectionManager(key, options);\n },\n\n createChannel(name: string, pusher: Pusher): Channel {\n return new Channel(name, pusher);\n },\n\n createPrivateChannel(name: string, pusher: Pusher): PrivateChannel {\n return new PrivateChannel(name, pusher);\n },\n\n createPresenceChannel(name: string, pusher: Pusher): PresenceChannel {\n return new PresenceChannel(name, pusher);\n },\n\n createEncryptedChannel(\n name: string,\n pusher: Pusher,\n nacl: nacl\n ): EncryptedChannel {\n return new EncryptedChannel(name, pusher, nacl);\n },\n\n createTimelineSender(timeline: Timeline, options: TimelineSenderOptions) {\n return new TimelineSender(timeline, options);\n },\n\n createHandshake(\n transport: TransportConnection,\n callback: (HandshakePayload) => void\n ): Handshake {\n return new Handshake(transport, callback);\n },\n\n createAssistantToTheTransportManager(\n manager: TransportManager,\n transport: Transport,\n options: PingDelayOptions\n ): AssistantToTheTransportManager {\n return new AssistantToTheTransportManager(manager, transport, options);\n }\n};\n\nexport default Factory;\n","import AssistantToTheTransportManager from './assistant_to_the_transport_manager';\nimport Transport from './transport';\nimport PingDelayOptions from './ping_delay_options';\nimport Factory from '../utils/factory';\n\nexport interface TransportManagerOptions extends PingDelayOptions {\n lives?: number;\n}\n\n/** Keeps track of the number of lives left for a transport.\n *\n * In the beginning of a session, transports may be assigned a number of\n * lives. When an AssistantToTheTransportManager instance reports a transport\n * connection closed uncleanly, the transport loses a life. When the number\n * of lives drops to zero, the transport gets disabled by its manager.\n *\n * @param {Object} options\n */\nexport default class TransportManager {\n options: TransportManagerOptions;\n livesLeft: number;\n\n constructor(options: TransportManagerOptions) {\n this.options = options || {};\n this.livesLeft = this.options.lives || Infinity;\n }\n\n /** Creates a assistant for the transport.\n *\n * @param {Transport} transport\n * @returns {AssistantToTheTransportManager}\n */\n getAssistant(transport: Transport): AssistantToTheTransportManager {\n return Factory.createAssistantToTheTransportManager(this, transport, {\n minPingDelay: this.options.minPingDelay,\n maxPingDelay: this.options.maxPingDelay\n });\n }\n\n /** Returns whether the transport has any lives left.\n *\n * @returns {Boolean}\n */\n isAlive(): boolean {\n return this.livesLeft > 0;\n }\n\n /** Takes one life from the transport. */\n reportDeath() {\n this.livesLeft -= 1;\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport { OneOffTimer as Timer } from '../utils/timers';\nimport Strategy from './strategy';\nimport StrategyOptions from './strategy_options';\n\n/** Loops through strategies with optional timeouts.\n *\n * Options:\n * - loop - whether it should loop through the substrategy list\n * - timeout - initial timeout for a single substrategy\n * - timeoutLimit - maximum timeout\n *\n * @param {Strategy[]} strategies\n * @param {Object} options\n */\nexport default class SequentialStrategy implements Strategy {\n strategies: Strategy[];\n loop: boolean;\n failFast: boolean;\n timeout: number;\n timeoutLimit: number;\n\n constructor(strategies: Strategy[], options: StrategyOptions) {\n this.strategies = strategies;\n this.loop = Boolean(options.loop);\n this.failFast = Boolean(options.failFast);\n this.timeout = options.timeout;\n this.timeoutLimit = options.timeoutLimit;\n }\n\n isSupported(): boolean {\n return Collections.any(this.strategies, Util.method('isSupported'));\n }\n\n connect(minPriority: number, callback: Function) {\n var strategies = this.strategies;\n var current = 0;\n var timeout = this.timeout;\n var runner = null;\n\n var tryNextStrategy = (error, handshake) => {\n if (handshake) {\n callback(null, handshake);\n } else {\n current = current + 1;\n if (this.loop) {\n current = current % strategies.length;\n }\n\n if (current < strategies.length) {\n if (timeout) {\n timeout = timeout * 2;\n if (this.timeoutLimit) {\n timeout = Math.min(timeout, this.timeoutLimit);\n }\n }\n runner = this.tryStrategy(\n strategies[current],\n minPriority,\n { timeout, failFast: this.failFast },\n tryNextStrategy\n );\n } else {\n callback(true);\n }\n }\n };\n\n runner = this.tryStrategy(\n strategies[current],\n minPriority,\n { timeout: timeout, failFast: this.failFast },\n tryNextStrategy\n );\n\n return {\n abort: function() {\n runner.abort();\n },\n forceMinPriority: function(p) {\n minPriority = p;\n if (runner) {\n runner.forceMinPriority(p);\n }\n }\n };\n }\n\n private tryStrategy(\n strategy: Strategy,\n minPriority: number,\n options: StrategyOptions,\n callback: Function\n ) {\n var timer = null;\n var runner = null;\n\n if (options.timeout > 0) {\n timer = new Timer(options.timeout, function() {\n runner.abort();\n callback(true);\n });\n }\n\n runner = strategy.connect(minPriority, function(error, handshake) {\n if (error && timer && timer.isRunning() && !options.failFast) {\n // advance to the next strategy after the timeout\n return;\n }\n if (timer) {\n timer.ensureAborted();\n }\n callback(error, handshake);\n });\n\n return {\n abort: function() {\n if (timer) {\n timer.ensureAborted();\n }\n runner.abort();\n },\n forceMinPriority: function(p) {\n runner.forceMinPriority(p);\n }\n };\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport Strategy from './strategy';\n\n/** Launches all substrategies and emits prioritized connected transports.\n *\n * @param {Array} strategies\n */\nexport default class BestConnectedEverStrategy implements Strategy {\n strategies: Strategy[];\n\n constructor(strategies: Strategy[]) {\n this.strategies = strategies;\n }\n\n isSupported(): boolean {\n return Collections.any(this.strategies, Util.method('isSupported'));\n }\n\n connect(minPriority: number, callback: Function) {\n return connect(this.strategies, minPriority, function(i, runners) {\n return function(error, handshake) {\n runners[i].error = error;\n if (error) {\n if (allRunnersFailed(runners)) {\n callback(true);\n }\n return;\n }\n Collections.apply(runners, function(runner) {\n runner.forceMinPriority(handshake.transport.priority);\n });\n callback(null, handshake);\n };\n });\n }\n}\n\n/** Connects to all strategies in parallel.\n *\n * Callback builder should be a function that takes two arguments: index\n * and a list of runners. It should return another function that will be\n * passed to the substrategy with given index. Runners can be aborted using\n * abortRunner(s) functions from this class.\n *\n * @param {Array} strategies\n * @param {Function} callbackBuilder\n * @return {Object} strategy runner\n */\nfunction connect(\n strategies: Strategy[],\n minPriority: number,\n callbackBuilder: Function\n) {\n var runners = Collections.map(strategies, function(strategy, i, _, rs) {\n return strategy.connect(minPriority, callbackBuilder(i, rs));\n });\n return {\n abort: function() {\n Collections.apply(runners, abortRunner);\n },\n forceMinPriority: function(p) {\n Collections.apply(runners, function(runner) {\n runner.forceMinPriority(p);\n });\n }\n };\n}\n\nfunction allRunnersFailed(runners): boolean {\n return Collections.all(runners, function(runner) {\n return Boolean(runner.error);\n });\n}\n\nfunction abortRunner(runner) {\n if (!runner.error && !runner.aborted) {\n runner.abort();\n runner.aborted = true;\n }\n}\n","import Util from '../util';\nimport Runtime from 'runtime';\nimport Strategy from './strategy';\nimport SequentialStrategy from './sequential_strategy';\nimport StrategyOptions from './strategy_options';\nimport TransportStrategy from './transport_strategy';\nimport Timeline from '../timeline/timeline';\nimport * as Collections from '../utils/collections';\n\nexport interface TransportStrategyDictionary {\n [key: string]: TransportStrategy;\n}\n\n/** Caches the last successful transport and, after the first few attempts,\n * uses the cached transport for subsequent attempts.\n *\n * @param {Strategy} strategy\n * @param {Object} transports\n * @param {Object} options\n */\nexport default class WebSocketPrioritizedCachedStrategy implements Strategy {\n strategy: Strategy;\n transports: TransportStrategyDictionary;\n ttl: number;\n usingTLS: boolean;\n timeline: Timeline;\n\n constructor(\n strategy: Strategy,\n transports: TransportStrategyDictionary,\n options: StrategyOptions\n ) {\n this.strategy = strategy;\n this.transports = transports;\n this.ttl = options.ttl || 1800 * 1000;\n this.usingTLS = options.useTLS;\n this.timeline = options.timeline;\n }\n\n isSupported(): boolean {\n return this.strategy.isSupported();\n }\n\n connect(minPriority: number, callback: Function) {\n var usingTLS = this.usingTLS;\n var info = fetchTransportCache(usingTLS);\n var cacheSkipCount = info && info.cacheSkipCount ? info.cacheSkipCount : 0;\n\n var strategies = [this.strategy];\n if (info && info.timestamp + this.ttl >= Util.now()) {\n var transport = this.transports[info.transport];\n if (transport) {\n if (['ws', 'wss'].includes(info.transport) || cacheSkipCount > 3) {\n this.timeline.info({\n cached: true,\n transport: info.transport,\n latency: info.latency\n });\n strategies.push(\n new SequentialStrategy([transport], {\n timeout: info.latency * 2 + 1000,\n failFast: true\n })\n );\n } else {\n cacheSkipCount++;\n }\n }\n }\n\n var startTimestamp = Util.now();\n var runner = strategies\n .pop()\n .connect(minPriority, function cb(error, handshake) {\n if (error) {\n flushTransportCache(usingTLS);\n if (strategies.length > 0) {\n startTimestamp = Util.now();\n runner = strategies.pop().connect(minPriority, cb);\n } else {\n callback(error);\n }\n } else {\n storeTransportCache(\n usingTLS,\n handshake.transport.name,\n Util.now() - startTimestamp,\n cacheSkipCount\n );\n callback(null, handshake);\n }\n });\n\n return {\n abort: function() {\n runner.abort();\n },\n forceMinPriority: function(p) {\n minPriority = p;\n if (runner) {\n runner.forceMinPriority(p);\n }\n }\n };\n }\n}\n\nfunction getTransportCacheKey(usingTLS: boolean): string {\n return 'pusherTransport' + (usingTLS ? 'TLS' : 'NonTLS');\n}\n\nfunction fetchTransportCache(usingTLS: boolean): any {\n var storage = Runtime.getLocalStorage();\n if (storage) {\n try {\n var serializedCache = storage[getTransportCacheKey(usingTLS)];\n if (serializedCache) {\n return JSON.parse(serializedCache);\n }\n } catch (e) {\n flushTransportCache(usingTLS);\n }\n }\n return null;\n}\n\nfunction storeTransportCache(\n usingTLS: boolean,\n transport: TransportStrategy,\n latency: number,\n cacheSkipCount: number\n) {\n var storage = Runtime.getLocalStorage();\n if (storage) {\n try {\n storage[getTransportCacheKey(usingTLS)] = Collections.safeJSONStringify({\n timestamp: Util.now(),\n transport: transport,\n latency: latency,\n cacheSkipCount: cacheSkipCount\n });\n } catch (e) {\n // catch over quota exceptions raised by localStorage\n }\n }\n}\n\nfunction flushTransportCache(usingTLS: boolean) {\n var storage = Runtime.getLocalStorage();\n if (storage) {\n try {\n delete storage[getTransportCacheKey(usingTLS)];\n } catch (e) {\n // catch exceptions raised by localStorage\n }\n }\n}\n","import { OneOffTimer as Timer } from '../utils/timers';\nimport Strategy from './strategy';\nimport StrategyOptions from './strategy_options';\n\n/** Runs substrategy after specified delay.\n *\n * Options:\n * - delay - time in miliseconds to delay the substrategy attempt\n *\n * @param {Strategy} strategy\n * @param {Object} options\n */\nexport default class DelayedStrategy implements Strategy {\n strategy: Strategy;\n options: { delay: number };\n\n constructor(strategy: Strategy, { delay: number }) {\n this.strategy = strategy;\n this.options = { delay: number };\n }\n\n isSupported(): boolean {\n return this.strategy.isSupported();\n }\n\n connect(minPriority: number, callback: Function) {\n var strategy = this.strategy;\n var runner;\n var timer = new Timer(this.options.delay, function() {\n runner = strategy.connect(minPriority, callback);\n });\n\n return {\n abort: function() {\n timer.ensureAborted();\n if (runner) {\n runner.abort();\n }\n },\n forceMinPriority: function(p) {\n minPriority = p;\n if (runner) {\n runner.forceMinPriority(p);\n }\n }\n };\n }\n}\n","import Strategy from './strategy';\nimport StrategyRunner from './strategy_runner';\n\n/** Proxies method calls to one of substrategies basing on the test function.\n *\n * @param {Function} test\n * @param {Strategy} trueBranch strategy used when test returns true\n * @param {Strategy} falseBranch strategy used when test returns false\n */\nexport default class IfStrategy implements Strategy {\n test: () => boolean;\n trueBranch: Strategy;\n falseBranch: Strategy;\n\n constructor(\n test: () => boolean,\n trueBranch: Strategy,\n falseBranch: Strategy\n ) {\n this.test = test;\n this.trueBranch = trueBranch;\n this.falseBranch = falseBranch;\n }\n\n isSupported(): boolean {\n var branch = this.test() ? this.trueBranch : this.falseBranch;\n return branch.isSupported();\n }\n\n connect(minPriority: number, callback: Function): StrategyRunner {\n var branch = this.test() ? this.trueBranch : this.falseBranch;\n return branch.connect(minPriority, callback);\n }\n}\n","import Strategy from './strategy';\nimport StrategyRunner from './strategy_runner';\n\n/** Launches the substrategy and terminates on the first open connection.\n *\n * @param {Strategy} strategy\n */\nexport default class FirstConnectedStrategy implements Strategy {\n strategy: Strategy;\n\n constructor(strategy: Strategy) {\n this.strategy = strategy;\n }\n\n isSupported(): boolean {\n return this.strategy.isSupported();\n }\n\n connect(minPriority: number, callback: Function): StrategyRunner {\n var runner = this.strategy.connect(minPriority, function(error, handshake) {\n if (handshake) {\n runner.abort();\n }\n callback(error, handshake);\n });\n return runner;\n }\n}\n","import * as Collections from 'core/utils/collections';\nimport TransportManager from 'core/transports/transport_manager';\nimport Strategy from 'core/strategies/strategy';\nimport StrategyOptions from 'core/strategies/strategy_options';\nimport SequentialStrategy from 'core/strategies/sequential_strategy';\nimport BestConnectedEverStrategy from 'core/strategies/best_connected_ever_strategy';\nimport WebSocketPrioritizedCachedStrategy, {\n TransportStrategyDictionary\n} from 'core/strategies/websocket_prioritized_cached_strategy';\nimport DelayedStrategy from 'core/strategies/delayed_strategy';\nimport IfStrategy from 'core/strategies/if_strategy';\nimport FirstConnectedStrategy from 'core/strategies/first_connected_strategy';\nimport { Config } from 'core/config';\n\nfunction testSupportsStrategy(strategy: Strategy) {\n return function() {\n return strategy.isSupported();\n };\n}\n\nvar getDefaultStrategy = function(\n config: Config,\n baseOptions: StrategyOptions,\n defineTransport: Function\n): Strategy {\n var definedTransports = {};\n\n function defineTransportStrategy(\n name: string,\n type: string,\n priority: number,\n options: StrategyOptions,\n manager?: TransportManager\n ) {\n var transport = defineTransport(\n config,\n name,\n type,\n priority,\n options,\n manager\n );\n\n definedTransports[name] = transport;\n\n return transport;\n }\n\n var ws_options: StrategyOptions = Object.assign({}, baseOptions, {\n hostNonTLS: config.wsHost + ':' + config.wsPort,\n hostTLS: config.wsHost + ':' + config.wssPort,\n httpPath: config.wsPath\n });\n var wss_options: StrategyOptions = Object.assign({}, ws_options, {\n useTLS: true\n });\n var sockjs_options: StrategyOptions = Object.assign({}, baseOptions, {\n hostNonTLS: config.httpHost + ':' + config.httpPort,\n hostTLS: config.httpHost + ':' + config.httpsPort,\n httpPath: config.httpPath\n });\n\n var timeouts = {\n loop: true,\n timeout: 15000,\n timeoutLimit: 60000\n };\n\n var ws_manager = new TransportManager({\n minPingDelay: 10000,\n maxPingDelay: config.activityTimeout\n });\n var streaming_manager = new TransportManager({\n lives: 2,\n minPingDelay: 10000,\n maxPingDelay: config.activityTimeout\n });\n\n var ws_transport = defineTransportStrategy(\n 'ws',\n 'ws',\n 3,\n ws_options,\n ws_manager\n );\n var wss_transport = defineTransportStrategy(\n 'wss',\n 'ws',\n 3,\n wss_options,\n ws_manager\n );\n var sockjs_transport = defineTransportStrategy(\n 'sockjs',\n 'sockjs',\n 1,\n sockjs_options\n );\n var xhr_streaming_transport = defineTransportStrategy(\n 'xhr_streaming',\n 'xhr_streaming',\n 1,\n sockjs_options,\n streaming_manager\n );\n var xdr_streaming_transport = defineTransportStrategy(\n 'xdr_streaming',\n 'xdr_streaming',\n 1,\n sockjs_options,\n streaming_manager\n );\n var xhr_polling_transport = defineTransportStrategy(\n 'xhr_polling',\n 'xhr_polling',\n 1,\n sockjs_options\n );\n var xdr_polling_transport = defineTransportStrategy(\n 'xdr_polling',\n 'xdr_polling',\n 1,\n sockjs_options\n );\n\n var ws_loop = new SequentialStrategy([ws_transport], timeouts);\n var wss_loop = new SequentialStrategy([wss_transport], timeouts);\n var sockjs_loop = new SequentialStrategy([sockjs_transport], timeouts);\n var streaming_loop = new SequentialStrategy(\n [\n new IfStrategy(\n testSupportsStrategy(xhr_streaming_transport),\n xhr_streaming_transport,\n xdr_streaming_transport\n )\n ],\n timeouts\n );\n var polling_loop = new SequentialStrategy(\n [\n new IfStrategy(\n testSupportsStrategy(xhr_polling_transport),\n xhr_polling_transport,\n xdr_polling_transport\n )\n ],\n timeouts\n );\n\n var http_loop = new SequentialStrategy(\n [\n new IfStrategy(\n testSupportsStrategy(streaming_loop),\n new BestConnectedEverStrategy([\n streaming_loop,\n new DelayedStrategy(polling_loop, { delay: 4000 })\n ]),\n polling_loop\n )\n ],\n timeouts\n );\n\n var http_fallback_loop = new IfStrategy(\n testSupportsStrategy(http_loop),\n http_loop,\n sockjs_loop\n );\n\n var wsStrategy;\n if (baseOptions.useTLS) {\n wsStrategy = new BestConnectedEverStrategy([\n ws_loop,\n new DelayedStrategy(http_fallback_loop, { delay: 2000 })\n ]);\n } else {\n wsStrategy = new BestConnectedEverStrategy([\n ws_loop,\n new DelayedStrategy(wss_loop, { delay: 2000 }),\n new DelayedStrategy(http_fallback_loop, { delay: 5000 })\n ]);\n }\n\n return new WebSocketPrioritizedCachedStrategy(\n new FirstConnectedStrategy(\n new IfStrategy(\n testSupportsStrategy(ws_transport),\n wsStrategy,\n http_fallback_loop\n )\n ),\n definedTransports,\n {\n ttl: 1800000,\n timeline: baseOptions.timeline,\n useTLS: baseOptions.useTLS\n }\n );\n};\n\nexport default getDefaultStrategy;\n","import HTTPRequest from 'core/http/http_request';\nimport RequestHooks from 'core/http/request_hooks';\nimport Ajax from 'core/http/ajax';\nimport * as Errors from 'core/errors';\n\nvar hooks: RequestHooks = {\n getRequest: function(socket: HTTPRequest): Ajax {\n var xdr = new (window).XDomainRequest();\n xdr.ontimeout = function() {\n socket.emit('error', new Errors.RequestTimedOut());\n socket.close();\n };\n xdr.onerror = function(e) {\n socket.emit('error', e);\n socket.close();\n };\n xdr.onprogress = function() {\n if (xdr.responseText && xdr.responseText.length > 0) {\n socket.onChunk(200, xdr.responseText);\n }\n };\n xdr.onload = function() {\n if (xdr.responseText && xdr.responseText.length > 0) {\n socket.onChunk(200, xdr.responseText);\n }\n socket.emit('finished', 200);\n socket.close();\n };\n return xdr;\n },\n abortRequest: function(xdr: Ajax) {\n xdr.ontimeout = xdr.onerror = xdr.onprogress = xdr.onload = null;\n xdr.abort();\n }\n};\n\nexport default hooks;\n","import Runtime from 'runtime';\nimport RequestHooks from './request_hooks';\nimport Ajax from './ajax';\nimport { default as EventsDispatcher } from '../events/dispatcher';\n\nconst MAX_BUFFER_LENGTH = 256 * 1024;\n\nexport default class HTTPRequest extends EventsDispatcher {\n hooks: RequestHooks;\n method: string;\n url: string;\n position: number;\n xhr: Ajax;\n unloader: Function;\n\n constructor(hooks: RequestHooks, method: string, url: string) {\n super();\n this.hooks = hooks;\n this.method = method;\n this.url = url;\n }\n\n start(payload?: any) {\n this.position = 0;\n this.xhr = this.hooks.getRequest(this);\n\n this.unloader = () => {\n this.close();\n };\n Runtime.addUnloadListener(this.unloader);\n\n this.xhr.open(this.method, this.url, true);\n\n if (this.xhr.setRequestHeader) {\n this.xhr.setRequestHeader('Content-Type', 'application/json'); // ReactNative doesn't set this header by default.\n }\n this.xhr.send(payload);\n }\n\n close() {\n if (this.unloader) {\n Runtime.removeUnloadListener(this.unloader);\n this.unloader = null;\n }\n if (this.xhr) {\n this.hooks.abortRequest(this.xhr);\n this.xhr = null;\n }\n }\n\n onChunk(status: number, data: any) {\n while (true) {\n var chunk = this.advanceBuffer(data);\n if (chunk) {\n this.emit('chunk', { status: status, data: chunk });\n } else {\n break;\n }\n }\n if (this.isBufferTooLong(data)) {\n this.emit('buffer_too_long');\n }\n }\n\n private advanceBuffer(buffer: any[]): any {\n var unreadData = buffer.slice(this.position);\n var endOfLinePosition = unreadData.indexOf('\\n');\n\n if (endOfLinePosition !== -1) {\n this.position += endOfLinePosition + 1;\n return unreadData.slice(0, endOfLinePosition);\n } else {\n // chunk is not finished yet, don't move the buffer pointer\n return null;\n }\n }\n\n private isBufferTooLong(buffer: any): boolean {\n return this.position === buffer.length && buffer.length > MAX_BUFFER_LENGTH;\n }\n}\n","enum State {\n CONNECTING = 0,\n OPEN = 1,\n CLOSED = 3\n}\n\nexport default State;\n","import URLLocation from './url_location';\nimport State from './state';\nimport Socket from '../socket';\nimport SocketHooks from './socket_hooks';\nimport Util from '../util';\nimport Ajax from './ajax';\nimport HTTPRequest from './http_request';\nimport Runtime from 'runtime';\n\nvar autoIncrement = 1;\n\nclass HTTPSocket implements Socket {\n hooks: SocketHooks;\n session: string;\n location: URLLocation;\n readyState: State;\n stream: HTTPRequest;\n\n onopen: () => void;\n onerror: (error: any) => void;\n onclose: (closeEvent: any) => void;\n onmessage: (message: any) => void;\n onactivity: () => void;\n\n constructor(hooks: SocketHooks, url: string) {\n this.hooks = hooks;\n this.session = randomNumber(1000) + '/' + randomString(8);\n this.location = getLocation(url);\n this.readyState = State.CONNECTING;\n this.openStream();\n }\n\n send(payload: any) {\n return this.sendRaw(JSON.stringify([payload]));\n }\n\n ping() {\n this.hooks.sendHeartbeat(this);\n }\n\n close(code: any, reason: any) {\n this.onClose(code, reason, true);\n }\n\n /** For internal use only */\n sendRaw(payload: any): boolean {\n if (this.readyState === State.OPEN) {\n try {\n Runtime.createSocketRequest(\n 'POST',\n getUniqueURL(getSendURL(this.location, this.session))\n ).start(payload);\n return true;\n } catch (e) {\n return false;\n }\n } else {\n return false;\n }\n }\n\n /** For internal use only */\n reconnect() {\n this.closeStream();\n this.openStream();\n }\n\n /** For internal use only */\n onClose(code, reason, wasClean) {\n this.closeStream();\n this.readyState = State.CLOSED;\n if (this.onclose) {\n this.onclose({\n code: code,\n reason: reason,\n wasClean: wasClean\n });\n }\n }\n\n private onChunk(chunk) {\n if (chunk.status !== 200) {\n return;\n }\n if (this.readyState === State.OPEN) {\n this.onActivity();\n }\n\n var payload;\n var type = chunk.data.slice(0, 1);\n switch (type) {\n case 'o':\n payload = JSON.parse(chunk.data.slice(1) || '{}');\n this.onOpen(payload);\n break;\n case 'a':\n payload = JSON.parse(chunk.data.slice(1) || '[]');\n for (var i = 0; i < payload.length; i++) {\n this.onEvent(payload[i]);\n }\n break;\n case 'm':\n payload = JSON.parse(chunk.data.slice(1) || 'null');\n this.onEvent(payload);\n break;\n case 'h':\n this.hooks.onHeartbeat(this);\n break;\n case 'c':\n payload = JSON.parse(chunk.data.slice(1) || '[]');\n this.onClose(payload[0], payload[1], true);\n break;\n }\n }\n\n private onOpen(options) {\n if (this.readyState === State.CONNECTING) {\n if (options && options.hostname) {\n this.location.base = replaceHost(this.location.base, options.hostname);\n }\n this.readyState = State.OPEN;\n\n if (this.onopen) {\n this.onopen();\n }\n } else {\n this.onClose(1006, 'Server lost session', true);\n }\n }\n\n private onEvent(event) {\n if (this.readyState === State.OPEN && this.onmessage) {\n this.onmessage({ data: event });\n }\n }\n\n private onActivity() {\n if (this.onactivity) {\n this.onactivity();\n }\n }\n\n private onError(error) {\n if (this.onerror) {\n this.onerror(error);\n }\n }\n\n private openStream() {\n this.stream = Runtime.createSocketRequest(\n 'POST',\n getUniqueURL(this.hooks.getReceiveURL(this.location, this.session))\n );\n\n this.stream.bind('chunk', chunk => {\n this.onChunk(chunk);\n });\n this.stream.bind('finished', status => {\n this.hooks.onFinished(this, status);\n });\n this.stream.bind('buffer_too_long', () => {\n this.reconnect();\n });\n\n try {\n this.stream.start();\n } catch (error) {\n Util.defer(() => {\n this.onError(error);\n this.onClose(1006, 'Could not start streaming', false);\n });\n }\n }\n\n private closeStream() {\n if (this.stream) {\n this.stream.unbind_all();\n this.stream.close();\n this.stream = null;\n }\n }\n}\n\nfunction getLocation(url): URLLocation {\n var parts = /([^\\?]*)\\/*(\\??.*)/.exec(url);\n return {\n base: parts[1],\n queryString: parts[2]\n };\n}\n\nfunction getSendURL(url: URLLocation, session: string): string {\n return url.base + '/' + session + '/xhr_send';\n}\n\nfunction getUniqueURL(url: string): string {\n var separator = url.indexOf('?') === -1 ? '?' : '&';\n return url + separator + 't=' + +new Date() + '&n=' + autoIncrement++;\n}\n\nfunction replaceHost(url: string, hostname: string): string {\n var urlParts = /(https?:\\/\\/)([^\\/:]+)((\\/|:)?.*)/.exec(url);\n return urlParts[1] + hostname + urlParts[3];\n}\n\nfunction randomNumber(max: number): number {\n return Runtime.randomInt(max);\n}\n\nfunction randomString(length: number): string {\n var result = [];\n\n for (var i = 0; i < length; i++) {\n result.push(randomNumber(32).toString(32));\n }\n\n return result.join('');\n}\n\nexport default HTTPSocket;\n","enum TimelineLevel {\n ERROR = 3,\n INFO = 6,\n DEBUG = 7\n}\n\nexport default TimelineLevel;\n","import SocketHooks from './socket_hooks';\nimport HTTPSocket from './http_socket';\n\nvar hooks: SocketHooks = {\n getReceiveURL: function(url, session) {\n return url.base + '/' + session + '/xhr_streaming' + url.queryString;\n },\n onHeartbeat: function(socket) {\n socket.sendRaw('[]');\n },\n sendHeartbeat: function(socket) {\n socket.sendRaw('[]');\n },\n onFinished: function(socket, status) {\n socket.onClose(1006, 'Connection interrupted (' + status + ')', false);\n }\n};\n\nexport default hooks;\n","import SocketHooks from './socket_hooks';\nimport URLLocation from './url_location';\nimport HTTPSocket from './http_socket';\n\nvar hooks: SocketHooks = {\n getReceiveURL: function(url: URLLocation, session: string): string {\n return url.base + '/' + session + '/xhr' + url.queryString;\n },\n onHeartbeat: function() {\n // next HTTP request will reset server's activity timer\n },\n sendHeartbeat: function(socket) {\n socket.sendRaw('[]');\n },\n onFinished: function(socket, status) {\n if (status === 200) {\n socket.reconnect();\n } else {\n socket.onClose(1006, 'Connection interrupted (' + status + ')', false);\n }\n }\n};\n\nexport default hooks;\n","import HTTPRequest from 'core/http/http_request';\nimport RequestHooks from 'core/http/request_hooks';\nimport Ajax from 'core/http/ajax';\nimport Runtime from 'runtime';\n\nvar hooks: RequestHooks = {\n getRequest: function(socket: HTTPRequest): Ajax {\n var Constructor = Runtime.getXHRAPI();\n var xhr = new Constructor();\n xhr.onreadystatechange = xhr.onprogress = function() {\n switch (xhr.readyState) {\n case 3:\n if (xhr.responseText && xhr.responseText.length > 0) {\n socket.onChunk(xhr.status, xhr.responseText);\n }\n break;\n case 4:\n // this happens only on errors, never after calling close\n if (xhr.responseText && xhr.responseText.length > 0) {\n socket.onChunk(xhr.status, xhr.responseText);\n }\n socket.emit('finished', xhr.status);\n socket.close();\n break;\n }\n };\n return xhr;\n },\n abortRequest: function(xhr: Ajax) {\n xhr.onreadystatechange = null;\n xhr.abort();\n }\n};\n\nexport default hooks;\n","import HTTPRequest from 'core/http/http_request';\nimport HTTPSocket from 'core/http/http_socket';\nimport SocketHooks from 'core/http/socket_hooks';\nimport RequestHooks from 'core/http/request_hooks';\nimport streamingHooks from 'core/http/http_streaming_socket';\nimport pollingHooks from 'core/http/http_polling_socket';\nimport xhrHooks from './http_xhr_request';\nimport HTTPFactory from 'core/http/http_factory';\n\nvar HTTP: HTTPFactory = {\n createStreamingSocket(url: string): HTTPSocket {\n return this.createSocket(streamingHooks, url);\n },\n\n createPollingSocket(url: string): HTTPSocket {\n return this.createSocket(pollingHooks, url);\n },\n\n createSocket(hooks: SocketHooks, url: string): HTTPSocket {\n return new HTTPSocket(hooks, url);\n },\n\n createXHR(method: string, url: string): HTTPRequest {\n return this.createRequest(xhrHooks, method, url);\n },\n\n createRequest(hooks: RequestHooks, method: string, url: string): HTTPRequest {\n return new HTTPRequest(hooks, method, url);\n }\n};\n\nexport default HTTP;\n","import xdrHooks from './http_xdomain_request';\nimport HTTP from 'isomorphic/http/http';\n\nHTTP.createXDR = function(method, url) {\n return this.createRequest(xdrHooks, method, url);\n};\n\nexport default HTTP;\n","import Browser from './browser';\nimport { Dependencies, DependenciesReceivers } from './dom/dependencies';\nimport { AuthTransport, AuthTransports } from 'core/auth/auth_transports';\nimport xhrAuth from 'isomorphic/auth/xhr_auth';\nimport jsonpAuth from './auth/jsonp_auth';\nimport TimelineTransport from 'core/timeline/timeline_transport';\nimport TimelineSender from 'core/timeline/timeline_sender';\nimport ScriptRequest from './dom/script_request';\nimport JSONPRequest from './dom/jsonp_request';\nimport * as Collections from 'core/utils/collections';\nimport { ScriptReceivers } from './dom/script_receiver_factory';\nimport jsonpTimeline from './timeline/jsonp_timeline';\nimport Transports from './transports/transports';\nimport Ajax from 'core/http/ajax';\nimport { Network } from './net_info';\nimport getDefaultStrategy from './default_strategy';\nimport transportConnectionInitializer from './transports/transport_connection_initializer';\nimport HTTPFactory from './http/http';\nimport HTTPRequest from 'core/http/http_request';\n\nvar Runtime: Browser = {\n // for jsonp auth\n nextAuthCallbackID: 1,\n auth_callbacks: {},\n ScriptReceivers,\n DependenciesReceivers,\n getDefaultStrategy,\n Transports,\n transportConnectionInitializer,\n HTTPFactory,\n\n TimelineTransport: jsonpTimeline,\n\n getXHRAPI() {\n return window.XMLHttpRequest;\n },\n\n getWebSocketAPI() {\n return window.WebSocket || window.MozWebSocket;\n },\n\n setup(PusherClass): void {\n (window).Pusher = PusherClass; // JSONp requires Pusher to be in the global scope.\n var initializeOnDocumentBody = () => {\n this.onDocumentBody(PusherClass.ready);\n };\n if (!(window).JSON) {\n Dependencies.load('json2', {}, initializeOnDocumentBody);\n } else {\n initializeOnDocumentBody();\n }\n },\n\n getDocument(): Document {\n return document;\n },\n\n getProtocol(): string {\n return this.getDocument().location.protocol;\n },\n\n getAuthorizers(): AuthTransports {\n return { ajax: xhrAuth, jsonp: jsonpAuth };\n },\n\n onDocumentBody(callback: Function) {\n if (document.body) {\n callback();\n } else {\n setTimeout(() => {\n this.onDocumentBody(callback);\n }, 0);\n }\n },\n\n createJSONPRequest(url: string, data: any): JSONPRequest {\n return new JSONPRequest(url, data);\n },\n\n createScriptRequest(src: string): ScriptRequest {\n return new ScriptRequest(src);\n },\n\n getLocalStorage() {\n try {\n return window.localStorage;\n } catch (e) {\n return undefined;\n }\n },\n\n createXHR(): Ajax {\n if (this.getXHRAPI()) {\n return this.createXMLHttpRequest();\n } else {\n return this.createMicrosoftXHR();\n }\n },\n\n createXMLHttpRequest(): Ajax {\n var Constructor = this.getXHRAPI();\n return new Constructor();\n },\n\n createMicrosoftXHR(): Ajax {\n return new ActiveXObject('Microsoft.XMLHTTP');\n },\n\n getNetwork() {\n return Network;\n },\n\n createWebSocket(url: string): any {\n var Constructor = this.getWebSocketAPI();\n return new Constructor(url);\n },\n\n createSocketRequest(method: string, url: string): HTTPRequest {\n if (this.isXHRSupported()) {\n return this.HTTPFactory.createXHR(method, url);\n } else if (this.isXDRSupported(url.indexOf('https:') === 0)) {\n return this.HTTPFactory.createXDR(method, url);\n } else {\n throw 'Cross-origin HTTP requests are not supported';\n }\n },\n\n isXHRSupported(): boolean {\n var Constructor = this.getXHRAPI();\n return (\n Boolean(Constructor) && new Constructor().withCredentials !== undefined\n );\n },\n\n isXDRSupported(useTLS?: boolean): boolean {\n var protocol = useTLS ? 'https:' : 'http:';\n var documentProtocol = this.getProtocol();\n return (\n Boolean(window['XDomainRequest']) && documentProtocol === protocol\n );\n },\n\n addUnloadListener(listener: any) {\n if (window.addEventListener !== undefined) {\n window.addEventListener('unload', listener, false);\n } else if (window.attachEvent !== undefined) {\n window.attachEvent('onunload', listener);\n }\n },\n\n removeUnloadListener(listener: any) {\n if (window.addEventListener !== undefined) {\n window.removeEventListener('unload', listener, false);\n } else if (window.detachEvent !== undefined) {\n window.detachEvent('onunload', listener);\n }\n },\n\n randomInt(max: number): number {\n /**\n * Return values in the range of [0, 1[\n */\n const random = function() {\n const crypto = window.crypto || window['msCrypto'];\n const random = crypto.getRandomValues(new Uint32Array(1))[0];\n\n return random / 2 ** 32;\n };\n\n return Math.floor(random() * max);\n }\n};\n\nexport default Runtime;\n","import { Dependencies } from '../dom/dependencies';\n\n/** Initializes the transport.\n *\n * Fetches resources if needed and then transitions to initialized.\n */\nexport default function() {\n var self = this;\n\n self.timeline.info(\n self.buildTimelineMessage({\n transport: self.name + (self.options.useTLS ? 's' : '')\n })\n );\n\n if (self.hooks.isInitialized()) {\n self.changeState('initialized');\n } else if (self.hooks.file) {\n self.changeState('initializing');\n Dependencies.load(\n self.hooks.file,\n { useTLS: self.options.useTLS },\n function(error, callback) {\n if (self.hooks.isInitialized()) {\n self.changeState('initialized');\n callback(true);\n } else {\n if (error) {\n self.onError(error);\n }\n self.onClose();\n callback(false);\n }\n }\n );\n } else {\n self.onClose();\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport { default as Level } from './level';\n\nexport interface TimelineOptions {\n level?: Level;\n limit?: number;\n version?: string;\n cluster?: string;\n features?: string[];\n params?: any;\n}\n\nexport default class Timeline {\n key: string;\n session: number;\n events: any[];\n options: TimelineOptions;\n sent: number;\n uniqueID: number;\n\n constructor(key: string, session: number, options: TimelineOptions) {\n this.key = key;\n this.session = session;\n this.events = [];\n this.options = options || {};\n this.sent = 0;\n this.uniqueID = 0;\n }\n\n log(level, event) {\n if (level <= this.options.level) {\n this.events.push(\n Collections.extend({}, event, { timestamp: Util.now() })\n );\n if (this.options.limit && this.events.length > this.options.limit) {\n this.events.shift();\n }\n }\n }\n\n error(event) {\n this.log(Level.ERROR, event);\n }\n\n info(event) {\n this.log(Level.INFO, event);\n }\n\n debug(event) {\n this.log(Level.DEBUG, event);\n }\n\n isEmpty() {\n return this.events.length === 0;\n }\n\n send(sendfn, callback) {\n var data = Collections.extend(\n {\n session: this.session,\n bundle: this.sent + 1,\n key: this.key,\n lib: 'js',\n version: this.options.version,\n cluster: this.options.cluster,\n features: this.options.features,\n timeline: this.events\n },\n this.options.params\n );\n\n this.events = [];\n sendfn(data, (error, result) => {\n if (!error) {\n this.sent++;\n }\n if (callback) {\n callback(error, result);\n }\n });\n\n return true;\n }\n\n generateUniqueID(): number {\n this.uniqueID++;\n return this.uniqueID;\n }\n}\n","import Factory from '../utils/factory';\nimport Util from '../util';\nimport * as Errors from '../errors';\nimport * as Collections from '../utils/collections';\nimport Strategy from './strategy';\nimport Transport from '../transports/transport';\nimport StrategyOptions from './strategy_options';\nimport Handshake from '../connection/handshake';\n\n/** Provides a strategy interface for transports.\n *\n * @param {String} name\n * @param {Number} priority\n * @param {Class} transport\n * @param {Object} options\n */\nexport default class TransportStrategy implements Strategy {\n name: string;\n priority: number;\n transport: Transport;\n options: StrategyOptions;\n\n constructor(\n name: string,\n priority: number,\n transport: Transport,\n options: StrategyOptions\n ) {\n this.name = name;\n this.priority = priority;\n this.transport = transport;\n this.options = options || {};\n }\n\n /** Returns whether the transport is supported in the browser.\n *\n * @returns {Boolean}\n */\n isSupported(): boolean {\n return this.transport.isSupported({\n useTLS: this.options.useTLS\n });\n }\n\n /** Launches a connection attempt and returns a strategy runner.\n *\n * @param {Function} callback\n * @return {Object} strategy runner\n */\n connect(minPriority: number, callback: Function) {\n if (!this.isSupported()) {\n return failAttempt(new Errors.UnsupportedStrategy(), callback);\n } else if (this.priority < minPriority) {\n return failAttempt(new Errors.TransportPriorityTooLow(), callback);\n }\n\n var connected = false;\n var transport = this.transport.createConnection(\n this.name,\n this.priority,\n this.options.key,\n this.options\n );\n var handshake = null;\n\n var onInitialized = function() {\n transport.unbind('initialized', onInitialized);\n transport.connect();\n };\n var onOpen = function() {\n handshake = Factory.createHandshake(transport, function(result) {\n connected = true;\n unbindListeners();\n callback(null, result);\n });\n };\n var onError = function(error) {\n unbindListeners();\n callback(error);\n };\n var onClosed = function() {\n unbindListeners();\n var serializedTransport;\n\n // The reason for this try/catch block is that on React Native\n // the WebSocket object is circular. Therefore transport.socket will\n // throw errors upon stringification. Collections.safeJSONStringify\n // discards circular references when serializing.\n serializedTransport = Collections.safeJSONStringify(transport);\n callback(new Errors.TransportClosed(serializedTransport));\n };\n\n var unbindListeners = function() {\n transport.unbind('initialized', onInitialized);\n transport.unbind('open', onOpen);\n transport.unbind('error', onError);\n transport.unbind('closed', onClosed);\n };\n\n transport.bind('initialized', onInitialized);\n transport.bind('open', onOpen);\n transport.bind('error', onError);\n transport.bind('closed', onClosed);\n\n // connect will be called automatically after initialization\n transport.initialize();\n\n return {\n abort: () => {\n if (connected) {\n return;\n }\n unbindListeners();\n if (handshake) {\n handshake.close();\n } else {\n transport.close();\n }\n },\n forceMinPriority: p => {\n if (connected) {\n return;\n }\n if (this.priority < p) {\n if (handshake) {\n handshake.close();\n } else {\n transport.close();\n }\n }\n }\n };\n }\n}\n\nfunction failAttempt(error: Error, callback: Function) {\n Util.defer(function() {\n callback(error);\n });\n return {\n abort: function() {},\n forceMinPriority: function() {}\n };\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport TransportManager from '../transports/transport_manager';\nimport * as Errors from '../errors';\nimport Strategy from './strategy';\nimport TransportStrategy from './transport_strategy';\nimport StrategyOptions from '../strategies/strategy_options';\nimport { Config } from '../config';\nimport Runtime from 'runtime';\n\nconst { Transports } = Runtime;\n\nexport var defineTransport = function(\n config: Config,\n name: string,\n type: string,\n priority: number,\n options: StrategyOptions,\n manager?: TransportManager\n): Strategy {\n var transportClass = Transports[type];\n if (!transportClass) {\n throw new Errors.UnsupportedTransport(type);\n }\n\n var enabled =\n (!config.enabledTransports ||\n Collections.arrayIndexOf(config.enabledTransports, name) !== -1) &&\n (!config.disabledTransports ||\n Collections.arrayIndexOf(config.disabledTransports, name) === -1);\n\n var transport;\n if (enabled) {\n options = Object.assign(\n { ignoreNullOrigin: config.ignoreNullOrigin },\n options\n );\n\n transport = new TransportStrategy(\n name,\n priority,\n manager ? manager.getAssistant(transportClass) : transportClass,\n options\n );\n } else {\n transport = UnsupportedStrategy;\n }\n\n return transport;\n};\n\nvar UnsupportedStrategy: Strategy = {\n isSupported: function() {\n return false;\n },\n connect: function(_, callback) {\n var deferred = Util.defer(function() {\n callback(new Errors.UnsupportedStrategy());\n });\n return {\n abort: function() {\n deferred.ensureAborted();\n },\n forceMinPriority: function() {}\n };\n }\n};\n","import ConnectionManager from './connection/connection_manager';\nimport {\n ChannelAuthorizationOptions,\n UserAuthenticationOptions\n} from './auth/options';\nimport {\n ChannelAuthorizerGenerator,\n DeprecatedAuthOptions\n} from './auth/deprecated_channel_authorizer';\nimport { AuthTransport, Transport } from './config';\nimport * as nacl from 'tweetnacl';\nimport Logger from './logger';\n\nexport interface Options {\n activityTimeout?: number;\n\n auth?: DeprecatedAuthOptions; // DEPRECATED use channelAuthorization instead\n authEndpoint?: string; // DEPRECATED use channelAuthorization instead\n authTransport?: AuthTransport; // DEPRECATED use channelAuthorization instead\n authorizer?: ChannelAuthorizerGenerator; // DEPRECATED use channelAuthorization instead\n\n channelAuthorization?: ChannelAuthorizationOptions;\n userAuthentication?: UserAuthenticationOptions;\n\n cluster: string;\n enableStats?: boolean;\n disableStats?: boolean;\n disabledTransports?: Transport[];\n enabledTransports?: Transport[];\n forceTLS?: boolean;\n httpHost?: string;\n httpPath?: string;\n httpPort?: number;\n httpsPort?: number;\n ignoreNullOrigin?: boolean;\n nacl?: nacl;\n pongTimeout?: number;\n statsHost?: string;\n timelineParams?: any;\n unavailableTimeout?: number;\n wsHost?: string;\n wsPath?: string;\n wsPort?: number;\n wssPort?: number;\n}\n\nexport interface ClusterOptions {\n appKey: string;\n cluster: string;\n}\n\nexport function validateOptions(options) {\n if (options == null) {\n throw 'You must pass an options object';\n }\n if (options.cluster == null) {\n throw 'Options object must provide a cluster';\n }\n if ('disableStats' in options) {\n Logger.warn(\n 'The disableStats option is deprecated in favor of enableStats'\n );\n }\n}\n","import {\n UserAuthenticationCallback,\n InternalAuthOptions,\n UserAuthenticationHandler,\n UserAuthenticationRequestParams,\n AuthRequestType\n} from './options';\n\nimport Runtime from 'runtime';\n\nconst composeChannelQuery = (\n params: UserAuthenticationRequestParams,\n authOptions: InternalAuthOptions\n) => {\n var query = 'socket_id=' + encodeURIComponent(params.socketId);\n\n for (var key in authOptions.params) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(authOptions.params[key]);\n }\n\n if (authOptions.paramsProvider != null) {\n let dynamicParams = authOptions.paramsProvider();\n for (var key in dynamicParams) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(dynamicParams[key]);\n }\n }\n\n return query;\n};\n\nconst UserAuthenticator = (\n authOptions: InternalAuthOptions\n): UserAuthenticationHandler => {\n if (typeof Runtime.getAuthorizers()[authOptions.transport] === 'undefined') {\n throw `'${authOptions.transport}' is not a recognized auth transport`;\n }\n\n return (\n params: UserAuthenticationRequestParams,\n callback: UserAuthenticationCallback\n ) => {\n const query = composeChannelQuery(params, authOptions);\n\n Runtime.getAuthorizers()[authOptions.transport](\n Runtime,\n query,\n authOptions,\n AuthRequestType.UserAuthentication,\n callback\n );\n };\n};\n\nexport default UserAuthenticator;\n","import {\n AuthRequestType,\n InternalAuthOptions,\n ChannelAuthorizationHandler,\n ChannelAuthorizationRequestParams,\n ChannelAuthorizationCallback\n} from './options';\n\nimport Runtime from 'runtime';\n\nconst composeChannelQuery = (\n params: ChannelAuthorizationRequestParams,\n authOptions: InternalAuthOptions\n) => {\n var query = 'socket_id=' + encodeURIComponent(params.socketId);\n\n query += '&channel_name=' + encodeURIComponent(params.channelName);\n\n for (var key in authOptions.params) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(authOptions.params[key]);\n }\n\n if (authOptions.paramsProvider != null) {\n let dynamicParams = authOptions.paramsProvider();\n for (var key in dynamicParams) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(dynamicParams[key]);\n }\n }\n\n return query;\n};\n\nconst ChannelAuthorizer = (\n authOptions: InternalAuthOptions\n): ChannelAuthorizationHandler => {\n if (typeof Runtime.getAuthorizers()[authOptions.transport] === 'undefined') {\n throw `'${authOptions.transport}' is not a recognized auth transport`;\n }\n\n return (\n params: ChannelAuthorizationRequestParams,\n callback: ChannelAuthorizationCallback\n ) => {\n const query = composeChannelQuery(params, authOptions);\n\n Runtime.getAuthorizers()[authOptions.transport](\n Runtime,\n query,\n authOptions,\n AuthRequestType.ChannelAuthorization,\n callback\n );\n };\n};\n\nexport default ChannelAuthorizer;\n","import { Options } from './options';\nimport Defaults from './defaults';\nimport {\n ChannelAuthorizationHandler,\n UserAuthenticationHandler,\n ChannelAuthorizationOptions\n} from './auth/options';\nimport UserAuthenticator from './auth/user_authenticator';\nimport ChannelAuthorizer from './auth/channel_authorizer';\nimport { ChannelAuthorizerProxy } from './auth/deprecated_channel_authorizer';\nimport Runtime from 'runtime';\nimport * as nacl from 'tweetnacl';\n\nexport type AuthTransport = 'ajax' | 'jsonp';\nexport type Transport =\n | 'ws'\n | 'wss'\n | 'xhr_streaming'\n | 'xhr_polling'\n | 'sockjs';\n\nexport interface Config {\n // these are all 'required' config parameters, it's not necessary for the user\n // to set them, but they have configured defaults.\n activityTimeout: number;\n enableStats: boolean;\n httpHost: string;\n httpPath: string;\n httpPort: number;\n httpsPort: number;\n pongTimeout: number;\n statsHost: string;\n unavailableTimeout: number;\n useTLS: boolean;\n wsHost: string;\n wsPath: string;\n wsPort: number;\n wssPort: number;\n userAuthenticator: UserAuthenticationHandler;\n channelAuthorizer: ChannelAuthorizationHandler;\n\n // these are all optional parameters or overrrides. The customer can set these\n // but it's not strictly necessary\n forceTLS?: boolean;\n cluster?: string;\n disabledTransports?: Transport[];\n enabledTransports?: Transport[];\n ignoreNullOrigin?: boolean;\n nacl?: nacl;\n timelineParams?: any;\n}\n\n// getConfig mainly sets the defaults for the options that are not provided\nexport function getConfig(opts: Options, pusher): Config {\n let config: Config = {\n activityTimeout: opts.activityTimeout || Defaults.activityTimeout,\n cluster: opts.cluster,\n httpPath: opts.httpPath || Defaults.httpPath,\n httpPort: opts.httpPort || Defaults.httpPort,\n httpsPort: opts.httpsPort || Defaults.httpsPort,\n pongTimeout: opts.pongTimeout || Defaults.pongTimeout,\n statsHost: opts.statsHost || Defaults.stats_host,\n unavailableTimeout: opts.unavailableTimeout || Defaults.unavailableTimeout,\n wsPath: opts.wsPath || Defaults.wsPath,\n wsPort: opts.wsPort || Defaults.wsPort,\n wssPort: opts.wssPort || Defaults.wssPort,\n\n enableStats: getEnableStatsConfig(opts),\n httpHost: getHttpHost(opts),\n useTLS: shouldUseTLS(opts),\n wsHost: getWebsocketHost(opts),\n\n userAuthenticator: buildUserAuthenticator(opts),\n channelAuthorizer: buildChannelAuthorizer(opts, pusher)\n };\n\n if ('disabledTransports' in opts)\n config.disabledTransports = opts.disabledTransports;\n if ('enabledTransports' in opts)\n config.enabledTransports = opts.enabledTransports;\n if ('ignoreNullOrigin' in opts)\n config.ignoreNullOrigin = opts.ignoreNullOrigin;\n if ('timelineParams' in opts) config.timelineParams = opts.timelineParams;\n if ('nacl' in opts) {\n config.nacl = opts.nacl;\n }\n\n return config;\n}\n\nfunction getHttpHost(opts: Options): string {\n if (opts.httpHost) {\n return opts.httpHost;\n }\n if (opts.cluster) {\n return `sockjs-${opts.cluster}.pusher.com`;\n }\n return Defaults.httpHost;\n}\n\nfunction getWebsocketHost(opts: Options): string {\n if (opts.wsHost) {\n return opts.wsHost;\n }\n return getWebsocketHostFromCluster(opts.cluster);\n}\n\nfunction getWebsocketHostFromCluster(cluster: string): string {\n return `ws-${cluster}.pusher.com`;\n}\n\nfunction shouldUseTLS(opts: Options): boolean {\n if (Runtime.getProtocol() === 'https:') {\n return true;\n } else if (opts.forceTLS === false) {\n return false;\n }\n return true;\n}\n\n// if enableStats is set take the value\n// if disableStats is set take the inverse\n// otherwise default to false\nfunction getEnableStatsConfig(opts: Options): boolean {\n if ('enableStats' in opts) {\n return opts.enableStats;\n }\n if ('disableStats' in opts) {\n return !opts.disableStats;\n }\n return false;\n}\n\nfunction buildUserAuthenticator(opts: Options): UserAuthenticationHandler {\n const userAuthentication = {\n ...Defaults.userAuthentication,\n ...opts.userAuthentication\n };\n if (\n 'customHandler' in userAuthentication &&\n userAuthentication['customHandler'] != null\n ) {\n return userAuthentication['customHandler'];\n }\n\n return UserAuthenticator(userAuthentication);\n}\n\nfunction buildChannelAuth(opts: Options, pusher): ChannelAuthorizationOptions {\n let channelAuthorization: ChannelAuthorizationOptions;\n if ('channelAuthorization' in opts) {\n channelAuthorization = {\n ...Defaults.channelAuthorization,\n ...opts.channelAuthorization\n };\n } else {\n channelAuthorization = {\n transport: opts.authTransport || Defaults.authTransport,\n endpoint: opts.authEndpoint || Defaults.authEndpoint\n };\n if ('auth' in opts) {\n if ('params' in opts.auth) channelAuthorization.params = opts.auth.params;\n if ('headers' in opts.auth)\n channelAuthorization.headers = opts.auth.headers;\n }\n if ('authorizer' in opts)\n channelAuthorization.customHandler = ChannelAuthorizerProxy(\n pusher,\n channelAuthorization,\n opts.authorizer\n );\n }\n return channelAuthorization;\n}\n\nfunction buildChannelAuthorizer(\n opts: Options,\n pusher\n): ChannelAuthorizationHandler {\n const channelAuthorization = buildChannelAuth(opts, pusher);\n if (\n 'customHandler' in channelAuthorization &&\n channelAuthorization['customHandler'] != null\n ) {\n return channelAuthorization['customHandler'];\n }\n\n return ChannelAuthorizer(channelAuthorization);\n}\n","import Channel from '../channels/channel';\nimport {\n ChannelAuthorizationCallback,\n ChannelAuthorizationHandler,\n ChannelAuthorizationRequestParams,\n InternalAuthOptions\n} from './options';\n\nexport interface DeprecatedChannelAuthorizer {\n authorize(socketId: string, callback: ChannelAuthorizationCallback): void;\n}\n\nexport interface ChannelAuthorizerGenerator {\n (\n channel: Channel,\n options: DeprecatedAuthorizerOptions\n ): DeprecatedChannelAuthorizer;\n}\n\nexport interface DeprecatedAuthOptions {\n params?: any;\n headers?: any;\n}\n\nexport interface DeprecatedAuthorizerOptions {\n authTransport: 'ajax' | 'jsonp';\n authEndpoint: string;\n auth?: DeprecatedAuthOptions;\n}\n\nexport const ChannelAuthorizerProxy = (\n pusher,\n authOptions: InternalAuthOptions,\n channelAuthorizerGenerator: ChannelAuthorizerGenerator\n): ChannelAuthorizationHandler => {\n const deprecatedAuthorizerOptions: DeprecatedAuthorizerOptions = {\n authTransport: authOptions.transport,\n authEndpoint: authOptions.endpoint,\n auth: {\n params: authOptions.params,\n headers: authOptions.headers\n }\n };\n return (\n params: ChannelAuthorizationRequestParams,\n callback: ChannelAuthorizationCallback\n ) => {\n const channel = pusher.channel(params.channelName);\n // This line creates a new channel authorizer every time.\n // In the past, this was only done once per channel and reused.\n // We can do that again if we want to keep this behavior intact.\n const channelAuthorizer: DeprecatedChannelAuthorizer = channelAuthorizerGenerator(\n channel,\n deprecatedAuthorizerOptions\n );\n channelAuthorizer.authorize(params.socketId, callback);\n };\n};\n","import Logger from './logger';\nimport Pusher from './pusher';\nimport EventsDispatcher from './events/dispatcher';\n\nexport default class WatchlistFacade extends EventsDispatcher {\n private pusher: Pusher;\n\n public constructor(pusher: Pusher) {\n super(function(eventName, data) {\n Logger.debug(`No callbacks on watchlist events for ${eventName}`);\n });\n\n this.pusher = pusher;\n this.bindWatchlistInternalEvent();\n }\n\n handleEvent(pusherEvent) {\n pusherEvent.data.events.forEach(watchlistEvent => {\n this.emit(watchlistEvent.name, watchlistEvent);\n });\n }\n\n private bindWatchlistInternalEvent() {\n this.pusher.connection.bind('message', pusherEvent => {\n var eventName = pusherEvent.event;\n if (eventName === 'pusher_internal:watchlist_events') {\n this.handleEvent(pusherEvent);\n }\n });\n }\n}\n","function flatPromise() {\n let resolve, reject;\n const promise = new Promise((res, rej) => {\n resolve = res;\n reject = rej;\n });\n return { promise, resolve, reject };\n}\n\nexport default flatPromise;\n","import Pusher from './pusher';\nimport Logger from './logger';\nimport {\n UserAuthenticationData,\n UserAuthenticationCallback\n} from './auth/options';\nimport Channel from './channels/channel';\nimport WatchlistFacade from './watchlist';\nimport EventsDispatcher from './events/dispatcher';\nimport flatPromise from './utils/flat_promise';\n\nexport default class UserFacade extends EventsDispatcher {\n pusher: Pusher;\n signin_requested: boolean = false;\n user_data: any = null;\n serverToUserChannel: Channel = null;\n signinDonePromise: Promise = null;\n watchlist: WatchlistFacade;\n private _signinDoneResolve: Function = null;\n\n public constructor(pusher: Pusher) {\n super(function(eventName, data) {\n Logger.debug('No callbacks on user for ' + eventName);\n });\n this.pusher = pusher;\n this.pusher.connection.bind('state_change', ({ previous, current }) => {\n if (previous !== 'connected' && current === 'connected') {\n this._signin();\n }\n if (previous === 'connected' && current !== 'connected') {\n this._cleanup();\n this._newSigninPromiseIfNeeded();\n }\n });\n\n this.watchlist = new WatchlistFacade(pusher);\n\n this.pusher.connection.bind('message', event => {\n var eventName = event.event;\n if (eventName === 'pusher:signin_success') {\n this._onSigninSuccess(event.data);\n }\n if (\n this.serverToUserChannel &&\n this.serverToUserChannel.name === event.channel\n ) {\n this.serverToUserChannel.handleEvent(event);\n }\n });\n }\n\n public signin() {\n if (this.signin_requested) {\n return;\n }\n\n this.signin_requested = true;\n this._signin();\n }\n\n private _signin() {\n if (!this.signin_requested) {\n return;\n }\n\n this._newSigninPromiseIfNeeded();\n\n if (this.pusher.connection.state !== 'connected') {\n // Signin will be attempted when the connection is connected\n return;\n }\n\n this.pusher.config.userAuthenticator(\n {\n socketId: this.pusher.connection.socket_id\n },\n this._onAuthorize\n );\n }\n\n private _onAuthorize: UserAuthenticationCallback = (\n err,\n authData: UserAuthenticationData\n ) => {\n if (err) {\n Logger.warn(`Error during signin: ${err}`);\n this._cleanup();\n return;\n }\n\n this.pusher.send_event('pusher:signin', {\n auth: authData.auth,\n user_data: authData.user_data\n });\n\n // Later when we get pusher:singin_success event, the user will be marked as signed in\n };\n\n private _onSigninSuccess(data: any) {\n try {\n this.user_data = JSON.parse(data.user_data);\n } catch (e) {\n Logger.error(`Failed parsing user data after signin: ${data.user_data}`);\n this._cleanup();\n return;\n }\n\n if (typeof this.user_data.id !== 'string' || this.user_data.id === '') {\n Logger.error(\n `user_data doesn't contain an id. user_data: ${this.user_data}`\n );\n this._cleanup();\n return;\n }\n\n // Signin succeeded\n this._signinDoneResolve();\n this._subscribeChannels();\n }\n\n private _subscribeChannels() {\n const ensure_subscribed = channel => {\n if (channel.subscriptionPending && channel.subscriptionCancelled) {\n channel.reinstateSubscription();\n } else if (\n !channel.subscriptionPending &&\n this.pusher.connection.state === 'connected'\n ) {\n channel.subscribe();\n }\n };\n\n this.serverToUserChannel = new Channel(\n `#server-to-user-${this.user_data.id}`,\n this.pusher\n );\n this.serverToUserChannel.bind_global((eventName, data) => {\n if (\n eventName.indexOf('pusher_internal:') === 0 ||\n eventName.indexOf('pusher:') === 0\n ) {\n // ignore internal events\n return;\n }\n this.emit(eventName, data);\n });\n ensure_subscribed(this.serverToUserChannel);\n }\n\n private _cleanup() {\n this.user_data = null;\n if (this.serverToUserChannel) {\n this.serverToUserChannel.unbind_all();\n this.serverToUserChannel.disconnect();\n this.serverToUserChannel = null;\n }\n\n if (this.signin_requested) {\n // If signin is in progress and cleanup is called,\n // Mark the current signin process as done.\n this._signinDoneResolve();\n }\n }\n\n private _newSigninPromiseIfNeeded() {\n if (!this.signin_requested) {\n return;\n }\n\n // If there is a promise and it is not resolved, return without creating a new one.\n if (this.signinDonePromise && !(this.signinDonePromise as any).done) {\n return;\n }\n\n // This promise is never rejected.\n // It gets resolved when the signin process is done whether it failed or succeeded\n const { promise, resolve, reject: _ } = flatPromise();\n (promise as any).done = false;\n const setDone = () => {\n (promise as any).done = true;\n };\n promise.then(setDone).catch(setDone);\n this.signinDonePromise = promise;\n this._signinDoneResolve = resolve;\n }\n}\n","import AbstractRuntime from '../runtimes/interface';\nimport Runtime from 'runtime';\nimport * as Collections from './utils/collections';\nimport Channels from './channels/channels';\nimport Channel from './channels/channel';\nimport { default as EventsDispatcher } from './events/dispatcher';\nimport Timeline from './timeline/timeline';\nimport TimelineSender from './timeline/timeline_sender';\nimport TimelineLevel from './timeline/level';\nimport { defineTransport } from './strategies/strategy_builder';\nimport ConnectionManager from './connection/connection_manager';\nimport { PeriodicTimer } from './utils/timers';\nimport Defaults from './defaults';\nimport Logger from './logger';\nimport Factory from './utils/factory';\nimport { Options, ClusterOptions, validateOptions } from './options';\nimport { Config, getConfig } from './config';\nimport StrategyOptions from './strategies/strategy_options';\nimport UserFacade from './user';\n\nexport default class Pusher {\n /* STATIC PROPERTIES */\n static instances: Pusher[] = [];\n static isReady: boolean = false;\n static logToConsole: boolean = false;\n\n // for jsonp\n static Runtime: AbstractRuntime = Runtime;\n static ScriptReceivers: any = (Runtime).ScriptReceivers;\n static DependenciesReceivers: any = (Runtime).DependenciesReceivers;\n static auth_callbacks: any = (Runtime).auth_callbacks;\n\n static ready() {\n Pusher.isReady = true;\n for (var i = 0, l = Pusher.instances.length; i < l; i++) {\n Pusher.instances[i].connect();\n }\n }\n\n static log: (message: any) => void;\n\n private static getClientFeatures(): string[] {\n return Collections.keys(\n Collections.filterObject({ ws: Runtime.Transports.ws }, function(t) {\n return t.isSupported({});\n })\n );\n }\n\n /* INSTANCE PROPERTIES */\n key: string;\n options: Options;\n config: Config;\n channels: Channels;\n global_emitter: EventsDispatcher;\n sessionID: number;\n timeline: Timeline;\n timelineSender: TimelineSender;\n connection: ConnectionManager;\n timelineSenderTimer: PeriodicTimer;\n user: UserFacade;\n constructor(app_key: string, options: Options) {\n checkAppKey(app_key);\n validateOptions(options);\n this.key = app_key;\n this.config = getConfig(options, this);\n\n this.channels = Factory.createChannels();\n this.global_emitter = new EventsDispatcher();\n this.sessionID = Runtime.randomInt(1000000000);\n\n this.timeline = new Timeline(this.key, this.sessionID, {\n cluster: this.config.cluster,\n features: Pusher.getClientFeatures(),\n params: this.config.timelineParams || {},\n limit: 50,\n level: TimelineLevel.INFO,\n version: Defaults.VERSION\n });\n if (this.config.enableStats) {\n this.timelineSender = Factory.createTimelineSender(this.timeline, {\n host: this.config.statsHost,\n path: '/timeline/v2/' + Runtime.TimelineTransport.name\n });\n }\n\n var getStrategy = (options: StrategyOptions) => {\n return Runtime.getDefaultStrategy(this.config, options, defineTransport);\n };\n\n this.connection = Factory.createConnectionManager(this.key, {\n getStrategy: getStrategy,\n timeline: this.timeline,\n activityTimeout: this.config.activityTimeout,\n pongTimeout: this.config.pongTimeout,\n unavailableTimeout: this.config.unavailableTimeout,\n useTLS: Boolean(this.config.useTLS)\n });\n\n this.connection.bind('connected', () => {\n this.subscribeAll();\n if (this.timelineSender) {\n this.timelineSender.send(this.connection.isUsingTLS());\n }\n });\n\n this.connection.bind('message', event => {\n var eventName = event.event;\n var internal = eventName.indexOf('pusher_internal:') === 0;\n if (event.channel) {\n var channel = this.channel(event.channel);\n if (channel) {\n channel.handleEvent(event);\n }\n }\n // Emit globally [deprecated]\n if (!internal) {\n this.global_emitter.emit(event.event, event.data);\n }\n });\n this.connection.bind('connecting', () => {\n this.channels.disconnect();\n });\n this.connection.bind('disconnected', () => {\n this.channels.disconnect();\n });\n this.connection.bind('error', err => {\n Logger.warn(err);\n });\n\n Pusher.instances.push(this);\n this.timeline.info({ instances: Pusher.instances.length });\n\n this.user = new UserFacade(this);\n\n if (Pusher.isReady) {\n this.connect();\n }\n }\n\n /**\n * Allows you to switch Pusher cluster without\n * losing all the channels/subscription binding\n * as this is internally managed by the SDK.\n */\n switchCluster(options: ClusterOptions) {\n const { appKey, cluster } = options;\n this.key = appKey;\n this.options = { ...this.options, cluster };\n this.config = getConfig(this.options, this);\n this.connection.switchCluster(this.key);\n }\n\n channel(name: string): Channel {\n return this.channels.find(name);\n }\n\n allChannels(): Channel[] {\n return this.channels.all();\n }\n\n connect() {\n this.connection.connect();\n\n if (this.timelineSender) {\n if (!this.timelineSenderTimer) {\n var usingTLS = this.connection.isUsingTLS();\n var timelineSender = this.timelineSender;\n this.timelineSenderTimer = new PeriodicTimer(60000, function() {\n timelineSender.send(usingTLS);\n });\n }\n }\n }\n\n disconnect() {\n this.connection.disconnect();\n\n if (this.timelineSenderTimer) {\n this.timelineSenderTimer.ensureAborted();\n this.timelineSenderTimer = null;\n }\n }\n\n bind(event_name: string, callback: Function, context?: any): Pusher {\n this.global_emitter.bind(event_name, callback, context);\n return this;\n }\n\n unbind(event_name?: string, callback?: Function, context?: any): Pusher {\n this.global_emitter.unbind(event_name, callback, context);\n return this;\n }\n\n bind_global(callback: Function): Pusher {\n this.global_emitter.bind_global(callback);\n return this;\n }\n\n unbind_global(callback?: Function): Pusher {\n this.global_emitter.unbind_global(callback);\n return this;\n }\n\n unbind_all(callback?: Function): Pusher {\n this.global_emitter.unbind_all();\n return this;\n }\n\n subscribeAll() {\n var channelName;\n for (channelName in this.channels.channels) {\n if (this.channels.channels.hasOwnProperty(channelName)) {\n this.subscribe(channelName);\n }\n }\n }\n\n subscribe(channel_name: string) {\n var channel = this.channels.add(channel_name, this);\n if (channel.subscriptionPending && channel.subscriptionCancelled) {\n channel.reinstateSubscription();\n } else if (\n !channel.subscriptionPending &&\n this.connection.state === 'connected'\n ) {\n channel.subscribe();\n }\n return channel;\n }\n\n unsubscribe(channel_name: string) {\n var channel = this.channels.find(channel_name);\n if (channel && channel.subscriptionPending) {\n channel.cancelSubscription();\n } else {\n channel = this.channels.remove(channel_name);\n if (channel && channel.subscribed) {\n channel.unsubscribe();\n }\n }\n }\n\n send_event(event_name: string, data: any, channel?: string) {\n return this.connection.send_event(event_name, data, channel);\n }\n\n shouldUseTLS(): boolean {\n return this.config.useTLS;\n }\n\n signin() {\n this.user.signin();\n }\n}\n\nfunction checkAppKey(key) {\n if (key === null || key === undefined) {\n throw 'You must pass your app key when you instantiate Pusher.';\n }\n}\n\nRuntime.setup(Pusher);\n","import Pusher from './pusher';\nimport { Options, validateOptions } from './options';\nimport * as nacl from 'tweetnacl';\n\nexport default class PusherWithEncryption extends Pusher {\n constructor(app_key: string, options: Options) {\n Pusher.logToConsole = PusherWithEncryption.logToConsole;\n Pusher.log = PusherWithEncryption.log;\n\n validateOptions(options);\n options.nacl = nacl;\n super(app_key, options);\n }\n}\n"],"sourceRoot":""} \ No newline at end of file diff --git a/dist/web/pusher.js b/dist/web/pusher.js index f1d491f45..8a7fed47a 100644 --- a/dist/web/pusher.js +++ b/dist/web/pusher.js @@ -1,5 +1,5 @@ /*! - * Pusher JavaScript Library v8.3.0 + * Pusher JavaScript Library v8.4.0 * https://pusher.com/ * * Copyright 2020, Pusher @@ -591,7 +591,7 @@ var ScriptReceivers = new ScriptReceiverFactory('_pusher_script_', 'Pusher.Scrip // CONCATENATED MODULE: ./src/core/defaults.ts var Defaults = { - VERSION: "8.3.0", + VERSION: "8.4.0", PROTOCOL: 7, wsPort: 80, wssPort: 443, @@ -2473,6 +2473,11 @@ class connection_manager_ConnectionManager extends dispatcher_Dispatcher { }); this.updateStrategy(); } + switchCluster(key) { + this.key = key; + this.updateStrategy(); + this.retryIn(0); + } connect() { if (this.connection || this.runner) { return; @@ -4479,6 +4484,13 @@ class pusher_Pusher { this.connect(); } } + switchCluster(options) { + const { appKey, cluster } = options; + this.key = appKey; + this.options = Object.assign(Object.assign({}, this.options), { cluster }); + this.config = getConfig(this.options, this); + this.connection.switchCluster(this.key); + } channel(name) { return this.channels.find(name); } diff --git a/dist/web/pusher.js.map b/dist/web/pusher.js.map index 966470045..1ec92ad7e 100644 --- a/dist/web/pusher.js.map +++ b/dist/web/pusher.js.map @@ -1 +1 @@ -{"version":3,"sources":["webpack://Pusher/webpack/universalModuleDefinition","webpack://Pusher/webpack/bootstrap","webpack://Pusher/./node_modules/@stablelib/base64/base64.ts","webpack://Pusher/./node_modules/@stablelib/utf8/utf8.ts","webpack://Pusher/./src/core/pusher.js","webpack://Pusher/./src/runtimes/web/dom/script_receiver_factory.ts","webpack://Pusher/./src/core/defaults.ts","webpack://Pusher/./src/runtimes/web/dom/dependency_loader.ts","webpack://Pusher/./src/runtimes/web/dom/dependencies.ts","webpack://Pusher/./src/core/utils/url_store.ts","webpack://Pusher/./src/core/auth/options.ts","webpack://Pusher/./src/core/errors.ts","webpack://Pusher/./src/runtimes/isomorphic/auth/xhr_auth.ts","webpack://Pusher/./src/core/base64.ts","webpack://Pusher/./src/core/utils/timers/abstract_timer.ts","webpack://Pusher/./src/core/utils/timers/index.ts","webpack://Pusher/./src/core/util.ts","webpack://Pusher/./src/core/utils/collections.ts","webpack://Pusher/./src/core/logger.ts","webpack://Pusher/./src/runtimes/web/auth/jsonp_auth.ts","webpack://Pusher/./src/runtimes/web/dom/script_request.ts","webpack://Pusher/./src/runtimes/web/dom/jsonp_request.ts","webpack://Pusher/./src/runtimes/web/timeline/jsonp_timeline.ts","webpack://Pusher/./src/core/transports/url_schemes.ts","webpack://Pusher/./src/core/events/callback_registry.ts","webpack://Pusher/./src/core/events/dispatcher.ts","webpack://Pusher/./src/core/transports/transport_connection.ts","webpack://Pusher/./src/core/transports/transport.ts","webpack://Pusher/./src/runtimes/isomorphic/transports/transports.ts","webpack://Pusher/./src/runtimes/web/transports/transports.ts","webpack://Pusher/./src/runtimes/web/net_info.ts","webpack://Pusher/./src/core/transports/assistant_to_the_transport_manager.ts","webpack://Pusher/./src/core/connection/protocol/protocol.ts","webpack://Pusher/./src/core/connection/connection.ts","webpack://Pusher/./src/core/connection/handshake/index.ts","webpack://Pusher/./src/core/timeline/timeline_sender.ts","webpack://Pusher/./src/core/channels/channel.ts","webpack://Pusher/./src/core/channels/private_channel.ts","webpack://Pusher/./src/core/channels/members.ts","webpack://Pusher/./src/core/channels/presence_channel.ts","webpack://Pusher/./src/core/channels/encrypted_channel.ts","webpack://Pusher/./src/core/connection/connection_manager.ts","webpack://Pusher/./src/core/channels/channels.ts","webpack://Pusher/./src/core/utils/factory.ts","webpack://Pusher/./src/core/transports/transport_manager.ts","webpack://Pusher/./src/core/strategies/sequential_strategy.ts","webpack://Pusher/./src/core/strategies/best_connected_ever_strategy.ts","webpack://Pusher/./src/core/strategies/websocket_prioritized_cached_strategy.ts","webpack://Pusher/./src/core/strategies/delayed_strategy.ts","webpack://Pusher/./src/core/strategies/if_strategy.ts","webpack://Pusher/./src/core/strategies/first_connected_strategy.ts","webpack://Pusher/./src/runtimes/web/default_strategy.ts","webpack://Pusher/./src/runtimes/web/transports/transport_connection_initializer.ts","webpack://Pusher/./src/runtimes/web/http/http_xdomain_request.ts","webpack://Pusher/./src/core/http/http_request.ts","webpack://Pusher/./src/core/http/state.ts","webpack://Pusher/./src/core/http/http_socket.ts","webpack://Pusher/./src/core/http/http_streaming_socket.ts","webpack://Pusher/./src/core/http/http_polling_socket.ts","webpack://Pusher/./src/runtimes/isomorphic/http/http_xhr_request.ts","webpack://Pusher/./src/runtimes/isomorphic/http/http.ts","webpack://Pusher/./src/runtimes/web/http/http.ts","webpack://Pusher/./src/runtimes/web/runtime.ts","webpack://Pusher/./src/core/timeline/level.ts","webpack://Pusher/./src/core/timeline/timeline.ts","webpack://Pusher/./src/core/strategies/transport_strategy.ts","webpack://Pusher/./src/core/strategies/strategy_builder.ts","webpack://Pusher/./src/core/options.ts","webpack://Pusher/./src/core/auth/user_authenticator.ts","webpack://Pusher/./src/core/auth/channel_authorizer.ts","webpack://Pusher/./src/core/auth/deprecated_channel_authorizer.ts","webpack://Pusher/./src/core/config.ts","webpack://Pusher/./src/core/watchlist.ts","webpack://Pusher/./src/core/utils/flat_promise.ts","webpack://Pusher/./src/core/user.ts","webpack://Pusher/./src/core/pusher.ts"],"names":[],"mappings":";;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AACD,O;QCVA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;;QAEA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;;;QAGA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;QACA,0CAA0C,gCAAgC;QAC1E;QACA;;QAEA;QACA;QACA;QACA,wDAAwD,kBAAkB;QAC1E;QACA,iDAAiD,cAAc;QAC/D;;QAEA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA,yCAAyC,iCAAiC;QAC1E,gHAAgH,mBAAmB,EAAE;QACrI;QACA;;QAEA;QACA;QACA;QACA,2BAA2B,0BAA0B,EAAE;QACvD,iCAAiC,eAAe;QAChD;QACA;QACA;;QA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AAC;AACzB,qBAAO,GAAY,KAAK,CAAC;AACzB,0BAAY,GAAY,KAAK,CAAC;AAG9B,qBAAO,GAAoB,OAAO,CAAC;AACnC,6BAAe,GAAc,OAAQ,CAAC,eAAe,CAAC;AACtD,mCAAqB,GAAc,OAAQ,CAAC,qBAAqB,CAAC;AAClE,4BAAc,GAAc,OAAQ,CAAC,cAAc,CAAC;AAVxC,8FAAM;AA8N3B,SAAS,WAAW,CAAC,GAAG;IACtB,IAAI,GAAG,KAAK,IAAI,IAAI,GAAG,KAAK,SAAS,EAAE;QACrC,MAAM,yDAAyD,CAAC;KACjE;AACH,CAAC;AAED,OAAO,CAAC,KAAK,CAAC,aAAM,CAAC,CAAC","file":"pusher.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"Pusher\"] = factory();\n\telse\n\t\troot[\"Pusher\"] = factory();\n})(window, function() {\nreturn "," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 2);\n","// Copyright (C) 2016 Dmitry Chestnykh\n// MIT License. See LICENSE file for details.\n\n/**\n * Package base64 implements Base64 encoding and decoding.\n */\n\n// Invalid character used in decoding to indicate\n// that the character to decode is out of range of\n// alphabet and cannot be decoded.\nconst INVALID_BYTE = 256;\n\n/**\n * Implements standard Base64 encoding.\n *\n * Operates in constant time.\n */\nexport class Coder {\n // TODO(dchest): methods to encode chunk-by-chunk.\n\n constructor(private _paddingCharacter = \"=\") { }\n\n encodedLength(length: number): number {\n if (!this._paddingCharacter) {\n return (length * 8 + 5) / 6 | 0;\n }\n return (length + 2) / 3 * 4 | 0;\n }\n\n encode(data: Uint8Array): string {\n let out = \"\";\n\n let i = 0;\n for (; i < data.length - 2; i += 3) {\n let c = (data[i] << 16) | (data[i + 1] << 8) | (data[i + 2]);\n out += this._encodeByte((c >>> 3 * 6) & 63);\n out += this._encodeByte((c >>> 2 * 6) & 63);\n out += this._encodeByte((c >>> 1 * 6) & 63);\n out += this._encodeByte((c >>> 0 * 6) & 63);\n }\n\n const left = data.length - i;\n if (left > 0) {\n let c = (data[i] << 16) | (left === 2 ? data[i + 1] << 8 : 0);\n out += this._encodeByte((c >>> 3 * 6) & 63);\n out += this._encodeByte((c >>> 2 * 6) & 63);\n if (left === 2) {\n out += this._encodeByte((c >>> 1 * 6) & 63);\n } else {\n out += this._paddingCharacter || \"\";\n }\n out += this._paddingCharacter || \"\";\n }\n\n return out;\n }\n\n maxDecodedLength(length: number): number {\n if (!this._paddingCharacter) {\n return (length * 6 + 7) / 8 | 0;\n }\n return length / 4 * 3 | 0;\n }\n\n decodedLength(s: string): number {\n return this.maxDecodedLength(s.length - this._getPaddingLength(s));\n }\n\n decode(s: string): Uint8Array {\n if (s.length === 0) {\n return new Uint8Array(0);\n }\n const paddingLength = this._getPaddingLength(s);\n const length = s.length - paddingLength;\n const out = new Uint8Array(this.maxDecodedLength(length));\n let op = 0;\n let i = 0;\n let haveBad = 0;\n let v0 = 0, v1 = 0, v2 = 0, v3 = 0;\n for (; i < length - 4; i += 4) {\n v0 = this._decodeChar(s.charCodeAt(i + 0));\n v1 = this._decodeChar(s.charCodeAt(i + 1));\n v2 = this._decodeChar(s.charCodeAt(i + 2));\n v3 = this._decodeChar(s.charCodeAt(i + 3));\n out[op++] = (v0 << 2) | (v1 >>> 4);\n out[op++] = (v1 << 4) | (v2 >>> 2);\n out[op++] = (v2 << 6) | v3;\n haveBad |= v0 & INVALID_BYTE;\n haveBad |= v1 & INVALID_BYTE;\n haveBad |= v2 & INVALID_BYTE;\n haveBad |= v3 & INVALID_BYTE;\n }\n if (i < length - 1) {\n v0 = this._decodeChar(s.charCodeAt(i));\n v1 = this._decodeChar(s.charCodeAt(i + 1));\n out[op++] = (v0 << 2) | (v1 >>> 4);\n haveBad |= v0 & INVALID_BYTE;\n haveBad |= v1 & INVALID_BYTE;\n }\n if (i < length - 2) {\n v2 = this._decodeChar(s.charCodeAt(i + 2));\n out[op++] = (v1 << 4) | (v2 >>> 2);\n haveBad |= v2 & INVALID_BYTE;\n }\n if (i < length - 3) {\n v3 = this._decodeChar(s.charCodeAt(i + 3));\n out[op++] = (v2 << 6) | v3;\n haveBad |= v3 & INVALID_BYTE;\n }\n if (haveBad !== 0) {\n throw new Error(\"Base64Coder: incorrect characters for decoding\");\n }\n return out;\n }\n\n // Standard encoding have the following encoded/decoded ranges,\n // which we need to convert between.\n //\n // ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 0123456789 + /\n // Index: 0 - 25 26 - 51 52 - 61 62 63\n // ASCII: 65 - 90 97 - 122 48 - 57 43 47\n //\n\n // Encode 6 bits in b into a new character.\n protected _encodeByte(b: number): string {\n // Encoding uses constant time operations as follows:\n //\n // 1. Define comparison of A with B using (A - B) >>> 8:\n // if A > B, then result is positive integer\n // if A <= B, then result is 0\n //\n // 2. Define selection of C or 0 using bitwise AND: X & C:\n // if X == 0, then result is 0\n // if X != 0, then result is C\n //\n // 3. Start with the smallest comparison (b >= 0), which is always\n // true, so set the result to the starting ASCII value (65).\n //\n // 4. Continue comparing b to higher ASCII values, and selecting\n // zero if comparison isn't true, otherwise selecting a value\n // to add to result, which:\n //\n // a) undoes the previous addition\n // b) provides new value to add\n //\n let result = b;\n // b >= 0\n result += 65;\n // b > 25\n result += ((25 - b) >>> 8) & ((0 - 65) - 26 + 97);\n // b > 51\n result += ((51 - b) >>> 8) & ((26 - 97) - 52 + 48);\n // b > 61\n result += ((61 - b) >>> 8) & ((52 - 48) - 62 + 43);\n // b > 62\n result += ((62 - b) >>> 8) & ((62 - 43) - 63 + 47);\n\n return String.fromCharCode(result);\n }\n\n // Decode a character code into a byte.\n // Must return 256 if character is out of alphabet range.\n protected _decodeChar(c: number): number {\n // Decoding works similar to encoding: using the same comparison\n // function, but now it works on ranges: result is always incremented\n // by value, but this value becomes zero if the range is not\n // satisfied.\n //\n // Decoding starts with invalid value, 256, which is then\n // subtracted when the range is satisfied. If none of the ranges\n // apply, the function returns 256, which is then checked by\n // the caller to throw error.\n let result = INVALID_BYTE; // start with invalid character\n\n // c == 43 (c > 42 and c < 44)\n result += (((42 - c) & (c - 44)) >>> 8) & (-INVALID_BYTE + c - 43 + 62);\n // c == 47 (c > 46 and c < 48)\n result += (((46 - c) & (c - 48)) >>> 8) & (-INVALID_BYTE + c - 47 + 63);\n // c > 47 and c < 58\n result += (((47 - c) & (c - 58)) >>> 8) & (-INVALID_BYTE + c - 48 + 52);\n // c > 64 and c < 91\n result += (((64 - c) & (c - 91)) >>> 8) & (-INVALID_BYTE + c - 65 + 0);\n // c > 96 and c < 123\n result += (((96 - c) & (c - 123)) >>> 8) & (-INVALID_BYTE + c - 97 + 26);\n\n return result;\n }\n\n private _getPaddingLength(s: string): number {\n let paddingLength = 0;\n if (this._paddingCharacter) {\n for (let i = s.length - 1; i >= 0; i--) {\n if (s[i] !== this._paddingCharacter) {\n break;\n }\n paddingLength++;\n }\n if (s.length < 4 || paddingLength > 2) {\n throw new Error(\"Base64Coder: incorrect padding\");\n }\n }\n return paddingLength;\n }\n\n}\n\nconst stdCoder = new Coder();\n\nexport function encode(data: Uint8Array): string {\n return stdCoder.encode(data);\n}\n\nexport function decode(s: string): Uint8Array {\n return stdCoder.decode(s);\n}\n\n/**\n * Implements URL-safe Base64 encoding.\n * (Same as Base64, but '+' is replaced with '-', and '/' with '_').\n *\n * Operates in constant time.\n */\nexport class URLSafeCoder extends Coder {\n // URL-safe encoding have the following encoded/decoded ranges:\n //\n // ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 0123456789 - _\n // Index: 0 - 25 26 - 51 52 - 61 62 63\n // ASCII: 65 - 90 97 - 122 48 - 57 45 95\n //\n\n protected _encodeByte(b: number): string {\n let result = b;\n // b >= 0\n result += 65;\n // b > 25\n result += ((25 - b) >>> 8) & ((0 - 65) - 26 + 97);\n // b > 51\n result += ((51 - b) >>> 8) & ((26 - 97) - 52 + 48);\n // b > 61\n result += ((61 - b) >>> 8) & ((52 - 48) - 62 + 45);\n // b > 62\n result += ((62 - b) >>> 8) & ((62 - 45) - 63 + 95);\n\n return String.fromCharCode(result);\n }\n\n protected _decodeChar(c: number): number {\n let result = INVALID_BYTE;\n\n // c == 45 (c > 44 and c < 46)\n result += (((44 - c) & (c - 46)) >>> 8) & (-INVALID_BYTE + c - 45 + 62);\n // c == 95 (c > 94 and c < 96)\n result += (((94 - c) & (c - 96)) >>> 8) & (-INVALID_BYTE + c - 95 + 63);\n // c > 47 and c < 58\n result += (((47 - c) & (c - 58)) >>> 8) & (-INVALID_BYTE + c - 48 + 52);\n // c > 64 and c < 91\n result += (((64 - c) & (c - 91)) >>> 8) & (-INVALID_BYTE + c - 65 + 0);\n // c > 96 and c < 123\n result += (((96 - c) & (c - 123)) >>> 8) & (-INVALID_BYTE + c - 97 + 26);\n\n return result;\n }\n}\n\nconst urlSafeCoder = new URLSafeCoder();\n\nexport function encodeURLSafe(data: Uint8Array): string {\n return urlSafeCoder.encode(data);\n}\n\nexport function decodeURLSafe(s: string): Uint8Array {\n return urlSafeCoder.decode(s);\n}\n\n\nexport const encodedLength = (length: number) =>\n stdCoder.encodedLength(length);\n\nexport const maxDecodedLength = (length: number) =>\n stdCoder.maxDecodedLength(length);\n\nexport const decodedLength = (s: string) =>\n stdCoder.decodedLength(s);\n","// Copyright (C) 2016 Dmitry Chestnykh\n// MIT License. See LICENSE file for details.\n\n/**\n * Package utf8 implements UTF-8 encoding and decoding.\n */\n\nconst INVALID_UTF16 = \"utf8: invalid string\";\nconst INVALID_UTF8 = \"utf8: invalid source encoding\";\n\n/**\n * Encodes the given string into UTF-8 byte array.\n * Throws if the source string has invalid UTF-16 encoding.\n */\nexport function encode(s: string): Uint8Array {\n // Calculate result length and allocate output array.\n // encodedLength() also validates string and throws errors,\n // so we don't need repeat validation here.\n const arr = new Uint8Array(encodedLength(s));\n\n let pos = 0;\n for (let i = 0; i < s.length; i++) {\n let c = s.charCodeAt(i);\n if (c < 0x80) {\n arr[pos++] = c;\n } else if (c < 0x800) {\n arr[pos++] = 0xc0 | c >> 6;\n arr[pos++] = 0x80 | c & 0x3f;\n } else if (c < 0xd800) {\n arr[pos++] = 0xe0 | c >> 12;\n arr[pos++] = 0x80 | (c >> 6) & 0x3f;\n arr[pos++] = 0x80 | c & 0x3f;\n } else {\n i++; // get one more character\n c = (c & 0x3ff) << 10;\n c |= s.charCodeAt(i) & 0x3ff;\n c += 0x10000;\n\n arr[pos++] = 0xf0 | c >> 18;\n arr[pos++] = 0x80 | (c >> 12) & 0x3f;\n arr[pos++] = 0x80 | (c >> 6) & 0x3f;\n arr[pos++] = 0x80 | c & 0x3f;\n }\n }\n return arr;\n}\n\n/**\n * Returns the number of bytes required to encode the given string into UTF-8.\n * Throws if the source string has invalid UTF-16 encoding.\n */\nexport function encodedLength(s: string): number {\n let result = 0;\n for (let i = 0; i < s.length; i++) {\n const c = s.charCodeAt(i);\n if (c < 0x80) {\n result += 1;\n } else if (c < 0x800) {\n result += 2;\n } else if (c < 0xd800) {\n result += 3;\n } else if (c <= 0xdfff) {\n if (i >= s.length - 1) {\n throw new Error(INVALID_UTF16);\n }\n i++; // \"eat\" next character\n result += 4;\n } else {\n throw new Error(INVALID_UTF16);\n }\n }\n return result;\n}\n\n/**\n * Decodes the given byte array from UTF-8 into a string.\n * Throws if encoding is invalid.\n */\nexport function decode(arr: Uint8Array): string {\n const chars: string[] = [];\n for (let i = 0; i < arr.length; i++) {\n let b = arr[i];\n\n if (b & 0x80) {\n let min;\n if (b < 0xe0) {\n // Need 1 more byte.\n if (i >= arr.length) {\n throw new Error(INVALID_UTF8);\n }\n const n1 = arr[++i];\n if ((n1 & 0xc0) !== 0x80) {\n throw new Error(INVALID_UTF8);\n }\n b = (b & 0x1f) << 6 | (n1 & 0x3f);\n min = 0x80;\n } else if (b < 0xf0) {\n // Need 2 more bytes.\n if (i >= arr.length - 1) {\n throw new Error(INVALID_UTF8);\n }\n const n1 = arr[++i];\n const n2 = arr[++i];\n if ((n1 & 0xc0) !== 0x80 || (n2 & 0xc0) !== 0x80) {\n throw new Error(INVALID_UTF8);\n }\n b = (b & 0x0f) << 12 | (n1 & 0x3f) << 6 | (n2 & 0x3f);\n min = 0x800;\n } else if (b < 0xf8) {\n // Need 3 more bytes.\n if (i >= arr.length - 2) {\n throw new Error(INVALID_UTF8);\n }\n const n1 = arr[++i];\n const n2 = arr[++i];\n const n3 = arr[++i];\n if ((n1 & 0xc0) !== 0x80 || (n2 & 0xc0) !== 0x80 || (n3 & 0xc0) !== 0x80) {\n throw new Error(INVALID_UTF8);\n }\n b = (b & 0x0f) << 18 | (n1 & 0x3f) << 12 | (n2 & 0x3f) << 6 | (n3 & 0x3f);\n min = 0x10000;\n } else {\n throw new Error(INVALID_UTF8);\n }\n\n if (b < min || (b >= 0xd800 && b <= 0xdfff)) {\n throw new Error(INVALID_UTF8);\n }\n\n if (b >= 0x10000) {\n // Surrogate pair.\n if (b > 0x10ffff) {\n throw new Error(INVALID_UTF8);\n }\n b -= 0x10000;\n chars.push(String.fromCharCode(0xd800 | (b >> 10)));\n b = 0xdc00 | (b & 0x3ff);\n }\n }\n\n chars.push(String.fromCharCode(b));\n }\n return chars.join(\"\");\n}\n","// required so we don't have to do require('pusher').default etc.\nmodule.exports = require('./pusher').default;\n","import ScriptReceiver from './script_receiver';\n\n/** Builds receivers for JSONP and Script requests.\n *\n * Each receiver is an object with following fields:\n * - number - unique (for the factory instance), numerical id of the receiver\n * - id - a string ID that can be used in DOM attributes\n * - name - name of the function triggering the receiver\n * - callback - callback function\n *\n * Receivers are triggered only once, on the first callback call.\n *\n * Receivers can be called by their name or by accessing factory object\n * by the number key.\n *\n * @param {String} prefix the prefix used in ids\n * @param {String} name the name of the object\n */\nexport class ScriptReceiverFactory {\n lastId: number;\n prefix: string;\n name: string;\n\n constructor(prefix: string, name: string) {\n this.lastId = 0;\n this.prefix = prefix;\n this.name = name;\n }\n\n create(callback: Function): ScriptReceiver {\n this.lastId++;\n\n var number = this.lastId;\n var id = this.prefix + number;\n var name = this.name + '[' + number + ']';\n\n var called = false;\n var callbackWrapper = function() {\n if (!called) {\n callback.apply(null, arguments);\n called = true;\n }\n };\n\n this[number] = callbackWrapper;\n return { number: number, id: id, name: name, callback: callbackWrapper };\n }\n\n remove(receiver: ScriptReceiver) {\n delete this[receiver.number];\n }\n}\n\nexport var ScriptReceivers = new ScriptReceiverFactory(\n '_pusher_script_',\n 'Pusher.ScriptReceivers'\n);\n","import {\n ChannelAuthorizationOptions,\n UserAuthenticationOptions\n} from './auth/options';\nimport { AuthTransport } from './config';\n\nexport interface DefaultConfig {\n VERSION: string;\n PROTOCOL: number;\n wsPort: number;\n wssPort: number;\n wsPath: string;\n httpHost: string;\n httpPort: number;\n httpsPort: number;\n httpPath: string;\n stats_host: string;\n authEndpoint: string;\n authTransport: AuthTransport;\n activityTimeout: number;\n pongTimeout: number;\n unavailableTimeout: number;\n userAuthentication: UserAuthenticationOptions;\n channelAuthorization: ChannelAuthorizationOptions;\n\n cdn_http?: string;\n cdn_https?: string;\n dependency_suffix?: string;\n}\n\nvar Defaults: DefaultConfig = {\n VERSION: VERSION,\n PROTOCOL: 7,\n\n wsPort: 80,\n wssPort: 443,\n wsPath: '',\n // DEPRECATED: SockJS fallback parameters\n httpHost: 'sockjs.pusher.com',\n httpPort: 80,\n httpsPort: 443,\n httpPath: '/pusher',\n // DEPRECATED: Stats\n stats_host: 'stats.pusher.com',\n // DEPRECATED: Other settings\n authEndpoint: '/pusher/auth',\n authTransport: 'ajax',\n activityTimeout: 120000,\n pongTimeout: 30000,\n unavailableTimeout: 10000,\n userAuthentication: {\n endpoint: '/pusher/user-auth',\n transport: 'ajax'\n },\n channelAuthorization: {\n endpoint: '/pusher/auth',\n transport: 'ajax'\n },\n\n // CDN configuration\n cdn_http: CDN_HTTP,\n cdn_https: CDN_HTTPS,\n dependency_suffix: DEPENDENCY_SUFFIX\n};\n\nexport default Defaults;\n","import {\n ScriptReceivers,\n ScriptReceiverFactory\n} from './script_receiver_factory';\nimport Runtime from 'runtime';\nimport ScriptRequest from './script_request';\n\n/** Handles loading dependency files.\n *\n * Dependency loaders don't remember whether a resource has been loaded or\n * not. It is caller's responsibility to make sure the resource is not loaded\n * twice. This is because it's impossible to detect resource loading status\n * without knowing its content.\n *\n * Options:\n * - cdn_http - url to HTTP CND\n * - cdn_https - url to HTTPS CDN\n * - version - version of pusher-js\n * - suffix - suffix appended to all names of dependency files\n *\n * @param {Object} options\n */\nexport default class DependencyLoader {\n options: any;\n receivers: ScriptReceiverFactory;\n loading: any;\n\n constructor(options: any) {\n this.options = options;\n this.receivers = options.receivers || ScriptReceivers;\n this.loading = {};\n }\n\n /** Loads the dependency from CDN.\n *\n * @param {String} name\n * @param {Function} callback\n */\n load(name: string, options: any, callback: Function) {\n var self = this;\n\n if (self.loading[name] && self.loading[name].length > 0) {\n self.loading[name].push(callback);\n } else {\n self.loading[name] = [callback];\n\n var request = Runtime.createScriptRequest(self.getPath(name, options));\n var receiver = self.receivers.create(function(error) {\n self.receivers.remove(receiver);\n\n if (self.loading[name]) {\n var callbacks = self.loading[name];\n delete self.loading[name];\n\n var successCallback = function(wasSuccessful) {\n if (!wasSuccessful) {\n request.cleanup();\n }\n };\n for (var i = 0; i < callbacks.length; i++) {\n callbacks[i](error, successCallback);\n }\n }\n });\n request.send(receiver);\n }\n }\n\n /** Returns a root URL for pusher-js CDN.\n *\n * @returns {String}\n */\n getRoot(options: any): string {\n var cdn;\n var protocol = Runtime.getDocument().location.protocol;\n if ((options && options.useTLS) || protocol === 'https:') {\n cdn = this.options.cdn_https;\n } else {\n cdn = this.options.cdn_http;\n }\n // make sure there are no double slashes\n return cdn.replace(/\\/*$/, '') + '/' + this.options.version;\n }\n\n /** Returns a full path to a dependency file.\n *\n * @param {String} name\n * @returns {String}\n */\n getPath(name: string, options: any): string {\n return this.getRoot(options) + '/' + name + this.options.suffix + '.js';\n }\n}\n","import { ScriptReceiverFactory } from './script_receiver_factory';\nimport Defaults from 'core/defaults';\nimport DependencyLoader from './dependency_loader';\n\nexport var DependenciesReceivers = new ScriptReceiverFactory(\n '_pusher_dependencies',\n 'Pusher.DependenciesReceivers'\n);\n\nexport var Dependencies = new DependencyLoader({\n cdn_http: Defaults.cdn_http,\n cdn_https: Defaults.cdn_https,\n version: Defaults.VERSION,\n suffix: Defaults.dependency_suffix,\n receivers: DependenciesReceivers\n});\n","/**\n * A place to store help URLs for error messages etc\n */\n\nconst urlStore = {\n baseUrl: 'https://pusher.com',\n urls: {\n authenticationEndpoint: {\n path: '/docs/channels/server_api/authenticating_users'\n },\n authorizationEndpoint: {\n path: '/docs/channels/server_api/authorizing-users/'\n },\n javascriptQuickStart: {\n path: '/docs/javascript_quick_start'\n },\n triggeringClientEvents: {\n path: '/docs/client_api_guide/client_events#trigger-events'\n },\n encryptedChannelSupport: {\n fullUrl:\n 'https://github.com/pusher/pusher-js/tree/cc491015371a4bde5743d1c87a0fbac0feb53195#encrypted-channel-support'\n }\n }\n};\n\n/** Builds a consistent string with links to pusher documentation\n *\n * @param {string} key - relevant key in the url_store.urls object\n * @return {string} suffix string to append to log message\n */\nconst buildLogSuffix = function(key: string): string {\n const urlPrefix = 'See:';\n const urlObj = urlStore.urls[key];\n if (!urlObj) return '';\n\n let url;\n if (urlObj.fullUrl) {\n url = urlObj.fullUrl;\n } else if (urlObj.path) {\n url = urlStore.baseUrl + urlObj.path;\n }\n\n if (!url) return '';\n return `${urlPrefix} ${url}`;\n};\n\nexport default { buildLogSuffix };\n","export enum AuthRequestType {\n UserAuthentication = 'user-authentication',\n ChannelAuthorization = 'channel-authorization'\n}\n\nexport interface ChannelAuthorizationData {\n auth: string;\n channel_data?: string;\n shared_secret?: string;\n}\n\nexport type ChannelAuthorizationCallback = (\n error: Error | null,\n authData: ChannelAuthorizationData | null\n) => void;\n\nexport interface ChannelAuthorizationRequestParams {\n socketId: string;\n channelName: string;\n}\n\nexport interface ChannelAuthorizationHandler {\n (\n params: ChannelAuthorizationRequestParams,\n callback: ChannelAuthorizationCallback\n ): void;\n}\n\nexport interface UserAuthenticationData {\n auth: string;\n user_data: string;\n}\n\nexport type UserAuthenticationCallback = (\n error: Error | null,\n authData: UserAuthenticationData | null\n) => void;\n\nexport interface UserAuthenticationRequestParams {\n socketId: string;\n}\n\nexport interface UserAuthenticationHandler {\n (\n params: UserAuthenticationRequestParams,\n callback: UserAuthenticationCallback\n ): void;\n}\n\nexport type AuthTransportCallback =\n | ChannelAuthorizationCallback\n | UserAuthenticationCallback;\n\nexport interface AuthOptionsT {\n transport: 'ajax' | 'jsonp';\n endpoint: string;\n params?: any;\n headers?: any;\n paramsProvider?: () => any;\n headersProvider?: () => any;\n customHandler?: AuthHandler;\n}\n\nexport declare type UserAuthenticationOptions = AuthOptionsT<\n UserAuthenticationHandler\n>;\nexport declare type ChannelAuthorizationOptions = AuthOptionsT<\n ChannelAuthorizationHandler\n>;\n\nexport interface InternalAuthOptions {\n transport: 'ajax' | 'jsonp';\n endpoint: string;\n params?: any;\n headers?: any;\n paramsProvider?: () => any;\n headersProvider?: () => any;\n}\n","/** Error classes used throughout the library. */\n// https://github.com/Microsoft/TypeScript-wiki/blob/master/Breaking-Changes.md#extending-built-ins-like-error-array-and-map-may-no-longer-work\nexport class BadEventName extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\nexport class BadChannelName extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\nexport class RequestTimedOut extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class TransportPriorityTooLow extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class TransportClosed extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class UnsupportedFeature extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class UnsupportedTransport extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class UnsupportedStrategy extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class HTTPAuthError extends Error {\n status: number;\n constructor(status: number, msg?: string) {\n super(msg);\n this.status = status;\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n","import TimelineSender from 'core/timeline/timeline_sender';\nimport * as Collections from 'core/utils/collections';\nimport Util from 'core/util';\nimport Runtime from 'runtime';\nimport { AuthTransport } from 'core/auth/auth_transports';\nimport AbstractRuntime from 'runtimes/interface';\nimport UrlStore from 'core/utils/url_store';\nimport {\n AuthRequestType,\n AuthTransportCallback,\n InternalAuthOptions\n} from 'core/auth/options';\nimport { HTTPAuthError } from 'core/errors';\n\nconst ajax: AuthTransport = function(\n context: AbstractRuntime,\n query: string,\n authOptions: InternalAuthOptions,\n authRequestType: AuthRequestType,\n callback: AuthTransportCallback\n) {\n const xhr = Runtime.createXHR();\n xhr.open('POST', authOptions.endpoint, true);\n\n // add request headers\n xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');\n for (var headerName in authOptions.headers) {\n xhr.setRequestHeader(headerName, authOptions.headers[headerName]);\n }\n if (authOptions.headersProvider != null) {\n let dynamicHeaders = authOptions.headersProvider();\n for (var headerName in dynamicHeaders) {\n xhr.setRequestHeader(headerName, dynamicHeaders[headerName]);\n }\n }\n\n xhr.onreadystatechange = function() {\n if (xhr.readyState === 4) {\n if (xhr.status === 200) {\n let data;\n let parsed = false;\n\n try {\n data = JSON.parse(xhr.responseText);\n parsed = true;\n } catch (e) {\n callback(\n new HTTPAuthError(\n 200,\n `JSON returned from ${authRequestType.toString()} endpoint was invalid, yet status code was 200. Data was: ${\n xhr.responseText\n }`\n ),\n null\n );\n }\n\n if (parsed) {\n // prevents double execution.\n callback(null, data);\n }\n } else {\n let suffix = '';\n switch (authRequestType) {\n case AuthRequestType.UserAuthentication:\n suffix = UrlStore.buildLogSuffix('authenticationEndpoint');\n break;\n case AuthRequestType.ChannelAuthorization:\n suffix = `Clients must be authorized to join private or presence channels. ${UrlStore.buildLogSuffix(\n 'authorizationEndpoint'\n )}`;\n break;\n }\n callback(\n new HTTPAuthError(\n xhr.status,\n `Unable to retrieve auth string from ${authRequestType.toString()} endpoint - ` +\n `received status: ${xhr.status} from ${authOptions.endpoint}. ${suffix}`\n ),\n null\n );\n }\n }\n };\n\n xhr.send(query);\n return xhr;\n};\n\nexport default ajax;\n","export default function encode(s: any): string {\n return btoa(utob(s));\n}\n\nvar fromCharCode = String.fromCharCode;\n\nvar b64chars =\n 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';\nvar b64tab = {};\n\nfor (var i = 0, l = b64chars.length; i < l; i++) {\n b64tab[b64chars.charAt(i)] = i;\n}\n\nvar cb_utob = function(c) {\n var cc = c.charCodeAt(0);\n return cc < 0x80\n ? c\n : cc < 0x800\n ? fromCharCode(0xc0 | (cc >>> 6)) + fromCharCode(0x80 | (cc & 0x3f))\n : fromCharCode(0xe0 | ((cc >>> 12) & 0x0f)) +\n fromCharCode(0x80 | ((cc >>> 6) & 0x3f)) +\n fromCharCode(0x80 | (cc & 0x3f));\n};\n\nvar utob = function(u) {\n return u.replace(/[^\\x00-\\x7F]/g, cb_utob);\n};\n\nvar cb_encode = function(ccc) {\n var padlen = [0, 2, 1][ccc.length % 3];\n var ord =\n (ccc.charCodeAt(0) << 16) |\n ((ccc.length > 1 ? ccc.charCodeAt(1) : 0) << 8) |\n (ccc.length > 2 ? ccc.charCodeAt(2) : 0);\n var chars = [\n b64chars.charAt(ord >>> 18),\n b64chars.charAt((ord >>> 12) & 63),\n padlen >= 2 ? '=' : b64chars.charAt((ord >>> 6) & 63),\n padlen >= 1 ? '=' : b64chars.charAt(ord & 63)\n ];\n return chars.join('');\n};\n\nvar btoa =\n global.btoa ||\n function(b) {\n return b.replace(/[\\s\\S]{1,3}/g, cb_encode);\n };\n","import TimedCallback from './timed_callback';\nimport { Delay, Scheduler, Canceller } from './scheduling';\n\nabstract class Timer {\n protected clear: Canceller;\n protected timer: number | void;\n\n constructor(\n set: Scheduler,\n clear: Canceller,\n delay: Delay,\n callback: TimedCallback\n ) {\n this.clear = clear;\n this.timer = set(() => {\n if (this.timer) {\n this.timer = callback(this.timer);\n }\n }, delay);\n }\n\n /** Returns whether the timer is still running.\n *\n * @return {Boolean}\n */\n isRunning(): boolean {\n return this.timer !== null;\n }\n\n /** Aborts a timer when it's running. */\n ensureAborted() {\n if (this.timer) {\n this.clear(this.timer);\n this.timer = null;\n }\n }\n}\n\nexport default Timer;\n","import Timer from './abstract_timer';\nimport TimedCallback from './timed_callback';\nimport { Delay } from './scheduling';\n\n// We need to bind clear functions this way to avoid exceptions on IE8\nfunction clearTimeout(timer) {\n global.clearTimeout(timer);\n}\nfunction clearInterval(timer) {\n global.clearInterval(timer);\n}\n\n/** Cross-browser compatible one-off timer abstraction.\n *\n * @param {Number} delay\n * @param {Function} callback\n */\nexport class OneOffTimer extends Timer {\n constructor(delay: Delay, callback: TimedCallback) {\n super(setTimeout, clearTimeout, delay, function(timer) {\n callback();\n return null;\n });\n }\n}\n\n/** Cross-browser compatible periodic timer abstraction.\n *\n * @param {Number} delay\n * @param {Function} callback\n */\nexport class PeriodicTimer extends Timer {\n constructor(delay: Delay, callback: TimedCallback) {\n super(setInterval, clearInterval, delay, function(timer) {\n callback();\n return timer;\n });\n }\n}\n","import * as Collections from './utils/collections';\nimport TimedCallback from './utils/timers/timed_callback';\nimport { OneOffTimer, PeriodicTimer } from './utils/timers';\n\nvar Util = {\n now(): number {\n if (Date.now) {\n return Date.now();\n } else {\n return new Date().valueOf();\n }\n },\n\n defer(callback: TimedCallback): OneOffTimer {\n return new OneOffTimer(0, callback);\n },\n\n /** Builds a function that will proxy a method call to its first argument.\n *\n * Allows partial application of arguments, so additional arguments are\n * prepended to the argument list.\n *\n * @param {String} name method name\n * @return {Function} proxy function\n */\n method(name: string, ...args: any[]): Function {\n var boundArguments = Array.prototype.slice.call(arguments, 1);\n return function(object) {\n return object[name].apply(object, boundArguments.concat(arguments));\n };\n }\n};\n\nexport default Util;\n","import base64encode from '../base64';\nimport Util from '../util';\n\n/** Merges multiple objects into the target argument.\n *\n * For properties that are plain Objects, performs a deep-merge. For the\n * rest it just copies the value of the property.\n *\n * To extend prototypes use it as following:\n * Pusher.Util.extend(Target.prototype, Base.prototype)\n *\n * You can also use it to merge objects without altering them:\n * Pusher.Util.extend({}, object1, object2)\n *\n * @param {Object} target\n * @return {Object} the target argument\n */\nexport function extend(target: any, ...sources: any[]): T {\n for (var i = 0; i < sources.length; i++) {\n var extensions = sources[i];\n for (var property in extensions) {\n if (\n extensions[property] &&\n extensions[property].constructor &&\n extensions[property].constructor === Object\n ) {\n target[property] = extend(target[property] || {}, extensions[property]);\n } else {\n target[property] = extensions[property];\n }\n }\n }\n return target;\n}\n\nexport function stringify(): string {\n var m = ['Pusher'];\n for (var i = 0; i < arguments.length; i++) {\n if (typeof arguments[i] === 'string') {\n m.push(arguments[i]);\n } else {\n m.push(safeJSONStringify(arguments[i]));\n }\n }\n return m.join(' : ');\n}\n\nexport function arrayIndexOf(array: any[], item: any): number {\n // MSIE doesn't have array.indexOf\n var nativeIndexOf = Array.prototype.indexOf;\n if (array === null) {\n return -1;\n }\n if (nativeIndexOf && array.indexOf === nativeIndexOf) {\n return array.indexOf(item);\n }\n for (var i = 0, l = array.length; i < l; i++) {\n if (array[i] === item) {\n return i;\n }\n }\n return -1;\n}\n\n/** Applies a function f to all properties of an object.\n *\n * Function f gets 3 arguments passed:\n * - element from the object\n * - key of the element\n * - reference to the object\n *\n * @param {Object} object\n * @param {Function} f\n */\nexport function objectApply(object: any, f: Function) {\n for (var key in object) {\n if (Object.prototype.hasOwnProperty.call(object, key)) {\n f(object[key], key, object);\n }\n }\n}\n\n/** Return a list of objects own proerty keys\n *\n * @param {Object} object\n * @returns {Array}\n */\nexport function keys(object: any): string[] {\n var keys = [];\n objectApply(object, function(_, key) {\n keys.push(key);\n });\n return keys;\n}\n\n/** Return a list of object's own property values\n *\n * @param {Object} object\n * @returns {Array}\n */\nexport function values(object: any): any[] {\n var values = [];\n objectApply(object, function(value) {\n values.push(value);\n });\n return values;\n}\n\n/** Applies a function f to all elements of an array.\n *\n * Function f gets 3 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function apply(array: any[], f: Function, context?: any) {\n for (var i = 0; i < array.length; i++) {\n f.call(context || global, array[i], i, array);\n }\n}\n\n/** Maps all elements of the array and returns the result.\n *\n * Function f gets 4 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n * - reference to the destination array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function map(array: any[], f: Function): any[] {\n var result = [];\n for (var i = 0; i < array.length; i++) {\n result.push(f(array[i], i, array, result));\n }\n return result;\n}\n\n/** Maps all elements of the object and returns the result.\n *\n * Function f gets 4 arguments passed:\n * - element from the object\n * - key of the element\n * - reference to the source object\n * - reference to the destination object\n *\n * @param {Object} object\n * @param {Function} f\n */\nexport function mapObject(object: any, f: Function): any {\n var result = {};\n objectApply(object, function(value, key) {\n result[key] = f(value);\n });\n return result;\n}\n\n/** Filters elements of the array using a test function.\n *\n * Function test gets 4 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n * - reference to the destination array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function filter(array: any[], test: Function): any[] {\n test =\n test ||\n function(value) {\n return !!value;\n };\n\n var result = [];\n for (var i = 0; i < array.length; i++) {\n if (test(array[i], i, array, result)) {\n result.push(array[i]);\n }\n }\n return result;\n}\n\n/** Filters properties of the object using a test function.\n *\n * Function test gets 4 arguments passed:\n * - element from the object\n * - key of the element\n * - reference to the source object\n * - reference to the destination object\n *\n * @param {Object} object\n * @param {Function} f\n */\nexport function filterObject(object: Object, test: Function) {\n var result = {};\n objectApply(object, function(value, key) {\n if ((test && test(value, key, object, result)) || Boolean(value)) {\n result[key] = value;\n }\n });\n return result;\n}\n\n/** Flattens an object into a two-dimensional array.\n *\n * @param {Object} object\n * @return {Array} resulting array of [key, value] pairs\n */\nexport function flatten(object: Object): any[] {\n var result = [];\n objectApply(object, function(value, key) {\n result.push([key, value]);\n });\n return result;\n}\n\n/** Checks whether any element of the array passes the test.\n *\n * Function test gets 3 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function any(array: any[], test: Function): boolean {\n for (var i = 0; i < array.length; i++) {\n if (test(array[i], i, array)) {\n return true;\n }\n }\n return false;\n}\n\n/** Checks whether all elements of the array pass the test.\n *\n * Function test gets 3 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function all(array: any[], test: Function): boolean {\n for (var i = 0; i < array.length; i++) {\n if (!test(array[i], i, array)) {\n return false;\n }\n }\n return true;\n}\n\nexport function encodeParamsObject(data): string {\n return mapObject(data, function(value) {\n if (typeof value === 'object') {\n value = safeJSONStringify(value);\n }\n return encodeURIComponent(base64encode(value.toString()));\n });\n}\n\nexport function buildQueryString(data: any): string {\n var params = filterObject(data, function(value) {\n return value !== undefined;\n });\n\n var query = map(\n flatten(encodeParamsObject(params)),\n Util.method('join', '=')\n ).join('&');\n\n return query;\n}\n\n/**\n * See https://github.com/douglascrockford/JSON-js/blob/master/cycle.js\n *\n * Remove circular references from an object. Required for JSON.stringify in\n * React Native, which tends to blow up a lot.\n *\n * @param {any} object\n * @return {any} Decycled object\n */\nexport function decycleObject(object: any): any {\n var objects = [],\n paths = [];\n\n return (function derez(value, path) {\n var i, name, nu;\n\n switch (typeof value) {\n case 'object':\n if (!value) {\n return null;\n }\n for (i = 0; i < objects.length; i += 1) {\n if (objects[i] === value) {\n return { $ref: paths[i] };\n }\n }\n\n objects.push(value);\n paths.push(path);\n\n if (Object.prototype.toString.apply(value) === '[object Array]') {\n nu = [];\n for (i = 0; i < value.length; i += 1) {\n nu[i] = derez(value[i], path + '[' + i + ']');\n }\n } else {\n nu = {};\n for (name in value) {\n if (Object.prototype.hasOwnProperty.call(value, name)) {\n nu[name] = derez(\n value[name],\n path + '[' + JSON.stringify(name) + ']'\n );\n }\n }\n }\n return nu;\n case 'number':\n case 'string':\n case 'boolean':\n return value;\n }\n })(object, '$');\n}\n\n/**\n * Provides a cross-browser and cross-platform way to safely stringify objects\n * into JSON. This is particularly necessary for ReactNative, where circular JSON\n * structures throw an exception.\n *\n * @param {any} source The object to stringify\n * @return {string} The serialized output.\n */\nexport function safeJSONStringify(source: any): string {\n try {\n return JSON.stringify(source);\n } catch (e) {\n return JSON.stringify(decycleObject(source));\n }\n}\n","import { stringify } from './utils/collections';\nimport Pusher from './pusher';\n\nclass Logger {\n debug(...args: any[]) {\n this.log(this.globalLog, args);\n }\n\n warn(...args: any[]) {\n this.log(this.globalLogWarn, args);\n }\n\n error(...args: any[]) {\n this.log(this.globalLogError, args);\n }\n\n private globalLog = (message: string) => {\n if (global.console && global.console.log) {\n global.console.log(message);\n }\n };\n\n private globalLogWarn(message: string) {\n if (global.console && global.console.warn) {\n global.console.warn(message);\n } else {\n this.globalLog(message);\n }\n }\n\n private globalLogError(message: string) {\n if (global.console && global.console.error) {\n global.console.error(message);\n } else {\n this.globalLogWarn(message);\n }\n }\n\n private log(\n defaultLoggingFunction: (message: string) => void,\n ...args: any[]\n ) {\n var message = stringify.apply(this, arguments);\n if (Pusher.log) {\n Pusher.log(message);\n } else if (Pusher.logToConsole) {\n const log = defaultLoggingFunction.bind(this);\n log(message);\n }\n }\n}\n\nexport default new Logger();\n","import Browser from '../browser';\nimport Logger from 'core/logger';\nimport JSONPRequest from '../dom/jsonp_request';\nimport { ScriptReceivers } from '../dom/script_receiver_factory';\nimport { AuthTransport } from 'core/auth/auth_transports';\nimport {\n AuthRequestType,\n AuthTransportCallback,\n InternalAuthOptions\n} from 'core/auth/options';\n\nvar jsonp: AuthTransport = function(\n context: Browser,\n query: string,\n authOptions: InternalAuthOptions,\n authRequestType: AuthRequestType,\n callback: AuthTransportCallback\n) {\n if (\n authOptions.headers !== undefined ||\n authOptions.headersProvider != null\n ) {\n Logger.warn(\n `To send headers with the ${authRequestType.toString()} request, you must use AJAX, rather than JSONP.`\n );\n }\n\n var callbackName = context.nextAuthCallbackID.toString();\n context.nextAuthCallbackID++;\n\n var document = context.getDocument();\n var script = document.createElement('script');\n // Hacked wrapper.\n context.auth_callbacks[callbackName] = function(data) {\n callback(null, data);\n };\n\n var callback_name = \"Pusher.auth_callbacks['\" + callbackName + \"']\";\n script.src =\n authOptions.endpoint +\n '?callback=' +\n encodeURIComponent(callback_name) +\n '&' +\n query;\n\n var head =\n document.getElementsByTagName('head')[0] || document.documentElement;\n head.insertBefore(script, head.firstChild);\n};\n\nexport default jsonp;\n","import ScriptReceiver from './script_receiver';\n\n/** Sends a generic HTTP GET request using a script tag.\n *\n * By constructing URL in a specific way, it can be used for loading\n * JavaScript resources or JSONP requests. It can notify about errors, but\n * only in certain environments. Please take care of monitoring the state of\n * the request yourself.\n *\n * @param {String} src\n */\nexport default class ScriptRequest {\n src: string;\n script: any;\n errorScript: any;\n\n constructor(src: string) {\n this.src = src;\n }\n\n send(receiver: ScriptReceiver) {\n var self = this;\n var errorString = 'Error loading ' + self.src;\n\n self.script = document.createElement('script');\n self.script.id = receiver.id;\n self.script.src = self.src;\n self.script.type = 'text/javascript';\n self.script.charset = 'UTF-8';\n\n if (self.script.addEventListener) {\n self.script.onerror = function() {\n receiver.callback(errorString);\n };\n self.script.onload = function() {\n receiver.callback(null);\n };\n } else {\n self.script.onreadystatechange = function() {\n if (\n self.script.readyState === 'loaded' ||\n self.script.readyState === 'complete'\n ) {\n receiver.callback(null);\n }\n };\n }\n\n // Opera<11.6 hack for missing onerror callback\n if (\n self.script.async === undefined &&\n (document).attachEvent &&\n /opera/i.test(navigator.userAgent)\n ) {\n self.errorScript = document.createElement('script');\n self.errorScript.id = receiver.id + '_error';\n self.errorScript.text = receiver.name + \"('\" + errorString + \"');\";\n self.script.async = self.errorScript.async = false;\n } else {\n self.script.async = true;\n }\n\n var head = document.getElementsByTagName('head')[0];\n head.insertBefore(self.script, head.firstChild);\n if (self.errorScript) {\n head.insertBefore(self.errorScript, self.script.nextSibling);\n }\n }\n\n /** Cleans up the DOM remains of the script request. */\n cleanup() {\n if (this.script) {\n this.script.onload = this.script.onerror = null;\n this.script.onreadystatechange = null;\n }\n if (this.script && this.script.parentNode) {\n this.script.parentNode.removeChild(this.script);\n }\n if (this.errorScript && this.errorScript.parentNode) {\n this.errorScript.parentNode.removeChild(this.errorScript);\n }\n this.script = null;\n this.errorScript = null;\n }\n}\n","import ScriptReceiver from './script_receiver';\nimport ScriptRequest from './script_request';\nimport * as Collections from 'core/utils/collections';\nimport Util from 'core/util';\nimport Runtime from '../runtime';\n\n/** Sends data via JSONP.\n *\n * Data is a key-value map. Its values are JSON-encoded and then passed\n * through base64. Finally, keys and encoded values are appended to the query\n * string.\n *\n * The class itself does not guarantee raising errors on failures, as it's not\n * possible to support such feature on all browsers. Instead, JSONP endpoint\n * should call back in a way that's easy to distinguish from browser calls,\n * for example by passing a second argument to the receiver.\n *\n * @param {String} url\n * @param {Object} data key-value map of data to be submitted\n */\nexport default class JSONPRequest {\n url: string;\n data: any;\n request: ScriptRequest;\n\n constructor(url: string, data: any) {\n this.url = url;\n this.data = data;\n }\n\n /** Sends the actual JSONP request.\n *\n * @param {ScriptReceiver} receiver\n */\n send(receiver: ScriptReceiver) {\n if (this.request) {\n return;\n }\n\n var query = Collections.buildQueryString(this.data);\n var url = this.url + '/' + receiver.number + '?' + query;\n this.request = Runtime.createScriptRequest(url);\n this.request.send(receiver);\n }\n\n /** Cleans up the DOM remains of the JSONP request. */\n cleanup() {\n if (this.request) {\n this.request.cleanup();\n }\n }\n}\n","import TimelineSender from 'core/timeline/timeline_sender';\nimport TimelineTransport from 'core/timeline/timeline_transport';\nimport Browser from 'runtime';\nimport { AuthTransport } from 'core/auth/auth_transports';\nimport { ScriptReceivers } from '../dom/script_receiver_factory';\n\nvar getAgent = function(sender: TimelineSender, useTLS: boolean) {\n return function(data: any, callback: Function) {\n var scheme = 'http' + (useTLS ? 's' : '') + '://';\n var url =\n scheme + (sender.host || sender.options.host) + sender.options.path;\n var request = Browser.createJSONPRequest(url, data);\n\n var receiver = Browser.ScriptReceivers.create(function(error, result) {\n ScriptReceivers.remove(receiver);\n request.cleanup();\n\n if (result && result.host) {\n sender.host = result.host;\n }\n if (callback) {\n callback(error, result);\n }\n });\n request.send(receiver);\n };\n};\n\nvar jsonp = {\n name: 'jsonp',\n getAgent\n};\n\nexport default jsonp;\n","import Defaults from '../defaults';\nimport { default as URLScheme, URLSchemeParams } from './url_scheme';\n\nfunction getGenericURL(\n baseScheme: string,\n params: URLSchemeParams,\n path: string\n): string {\n var scheme = baseScheme + (params.useTLS ? 's' : '');\n var host = params.useTLS ? params.hostTLS : params.hostNonTLS;\n return scheme + '://' + host + path;\n}\n\nfunction getGenericPath(key: string, queryString?: string): string {\n var path = '/app/' + key;\n var query =\n '?protocol=' +\n Defaults.PROTOCOL +\n '&client=js' +\n '&version=' +\n Defaults.VERSION +\n (queryString ? '&' + queryString : '');\n return path + query;\n}\n\nexport var ws: URLScheme = {\n getInitial: function(key: string, params: URLSchemeParams): string {\n var path = (params.httpPath || '') + getGenericPath(key, 'flash=false');\n return getGenericURL('ws', params, path);\n }\n};\n\nexport var http: URLScheme = {\n getInitial: function(key: string, params: URLSchemeParams): string {\n var path = (params.httpPath || '/pusher') + getGenericPath(key);\n return getGenericURL('http', params, path);\n }\n};\n\nexport var sockjs: URLScheme = {\n getInitial: function(key: string, params: URLSchemeParams): string {\n return getGenericURL('http', params, params.httpPath || '/pusher');\n },\n getPath: function(key: string, params: URLSchemeParams): string {\n return getGenericPath(key);\n }\n};\n","import Callback from './callback';\nimport * as Collections from '../utils/collections';\nimport CallbackTable from './callback_table';\n\nexport default class CallbackRegistry {\n _callbacks: CallbackTable;\n\n constructor() {\n this._callbacks = {};\n }\n\n get(name: string): Callback[] {\n return this._callbacks[prefix(name)];\n }\n\n add(name: string, callback: Function, context: any) {\n var prefixedEventName = prefix(name);\n this._callbacks[prefixedEventName] =\n this._callbacks[prefixedEventName] || [];\n this._callbacks[prefixedEventName].push({\n fn: callback,\n context: context\n });\n }\n\n remove(name?: string, callback?: Function, context?: any) {\n if (!name && !callback && !context) {\n this._callbacks = {};\n return;\n }\n\n var names = name ? [prefix(name)] : Collections.keys(this._callbacks);\n\n if (callback || context) {\n this.removeCallback(names, callback, context);\n } else {\n this.removeAllCallbacks(names);\n }\n }\n\n private removeCallback(names: string[], callback: Function, context: any) {\n Collections.apply(\n names,\n function(name) {\n this._callbacks[name] = Collections.filter(\n this._callbacks[name] || [],\n function(binding) {\n return (\n (callback && callback !== binding.fn) ||\n (context && context !== binding.context)\n );\n }\n );\n if (this._callbacks[name].length === 0) {\n delete this._callbacks[name];\n }\n },\n this\n );\n }\n\n private removeAllCallbacks(names: string[]) {\n Collections.apply(\n names,\n function(name) {\n delete this._callbacks[name];\n },\n this\n );\n }\n}\n\nfunction prefix(name: string): string {\n return '_' + name;\n}\n","import * as Collections from '../utils/collections';\nimport Callback from './callback';\nimport Metadata from '../channels/metadata';\nimport CallbackRegistry from './callback_registry';\n\n/** Manages callback bindings and event emitting.\n *\n * @param Function failThrough called when no listeners are bound to an event\n */\nexport default class Dispatcher {\n callbacks: CallbackRegistry;\n global_callbacks: Function[];\n failThrough: Function;\n\n constructor(failThrough?: Function) {\n this.callbacks = new CallbackRegistry();\n this.global_callbacks = [];\n this.failThrough = failThrough;\n }\n\n bind(eventName: string, callback: Function, context?: any) {\n this.callbacks.add(eventName, callback, context);\n return this;\n }\n\n bind_global(callback: Function) {\n this.global_callbacks.push(callback);\n return this;\n }\n\n unbind(eventName?: string, callback?: Function, context?: any) {\n this.callbacks.remove(eventName, callback, context);\n return this;\n }\n\n unbind_global(callback?: Function) {\n if (!callback) {\n this.global_callbacks = [];\n return this;\n }\n\n this.global_callbacks = Collections.filter(\n this.global_callbacks || [],\n c => c !== callback\n );\n\n return this;\n }\n\n unbind_all() {\n this.unbind();\n this.unbind_global();\n return this;\n }\n\n emit(eventName: string, data?: any, metadata?: Metadata): Dispatcher {\n for (var i = 0; i < this.global_callbacks.length; i++) {\n this.global_callbacks[i](eventName, data);\n }\n\n var callbacks = this.callbacks.get(eventName);\n var args = [];\n\n if (metadata) {\n // if there's a metadata argument, we need to call the callback with both\n // data and metadata regardless of whether data is undefined\n args.push(data, metadata);\n } else if (data) {\n // metadata is undefined, so we only need to call the callback with data\n // if data exists\n args.push(data);\n }\n\n if (callbacks && callbacks.length > 0) {\n for (var i = 0; i < callbacks.length; i++) {\n callbacks[i].fn.apply(callbacks[i].context || global, args);\n }\n } else if (this.failThrough) {\n this.failThrough(eventName, data);\n }\n\n return this;\n }\n}\n","import Util from '../util';\nimport * as Collections from '../utils/collections';\nimport { default as EventsDispatcher } from '../events/dispatcher';\nimport Logger from '../logger';\nimport TransportHooks from './transport_hooks';\nimport Socket from '../socket';\nimport Runtime from 'runtime';\nimport Timeline from '../timeline/timeline';\nimport TransportConnectionOptions from './transport_connection_options';\n\n/** Provides universal API for transport connections.\n *\n * Transport connection is a low-level object that wraps a connection method\n * and exposes a simple evented interface for the connection state and\n * messaging. It does not implement Pusher-specific WebSocket protocol.\n *\n * Additionally, it fetches resources needed for transport to work and exposes\n * an interface for querying transport features.\n *\n * States:\n * - new - initial state after constructing the object\n * - initializing - during initialization phase, usually fetching resources\n * - intialized - ready to establish a connection\n * - connection - when connection is being established\n * - open - when connection ready to be used\n * - closed - after connection was closed be either side\n *\n * Emits:\n * - error - after the connection raised an error\n *\n * Options:\n * - useTLS - whether connection should be over TLS\n * - hostTLS - host to connect to when connection is over TLS\n * - hostNonTLS - host to connect to when connection is over TLS\n *\n * @param {String} key application key\n * @param {Object} options\n */\nexport default class TransportConnection extends EventsDispatcher {\n hooks: TransportHooks;\n name: string;\n priority: number;\n key: string;\n options: TransportConnectionOptions;\n state: string;\n timeline: Timeline;\n activityTimeout: number;\n id: number;\n socket: Socket;\n beforeOpen: Function;\n initialize: Function;\n\n constructor(\n hooks: TransportHooks,\n name: string,\n priority: number,\n key: string,\n options: TransportConnectionOptions\n ) {\n super();\n this.initialize = Runtime.transportConnectionInitializer;\n this.hooks = hooks;\n this.name = name;\n this.priority = priority;\n this.key = key;\n this.options = options;\n\n this.state = 'new';\n this.timeline = options.timeline;\n this.activityTimeout = options.activityTimeout;\n this.id = this.timeline.generateUniqueID();\n }\n\n /** Checks whether the transport handles activity checks by itself.\n *\n * @return {Boolean}\n */\n handlesActivityChecks(): boolean {\n return Boolean(this.hooks.handlesActivityChecks);\n }\n\n /** Checks whether the transport supports the ping/pong API.\n *\n * @return {Boolean}\n */\n supportsPing(): boolean {\n return Boolean(this.hooks.supportsPing);\n }\n\n /** Tries to establish a connection.\n *\n * @returns {Boolean} false if transport is in invalid state\n */\n connect(): boolean {\n if (this.socket || this.state !== 'initialized') {\n return false;\n }\n\n var url = this.hooks.urls.getInitial(this.key, this.options);\n try {\n this.socket = this.hooks.getSocket(url, this.options);\n } catch (e) {\n Util.defer(() => {\n this.onError(e);\n this.changeState('closed');\n });\n return false;\n }\n\n this.bindListeners();\n\n Logger.debug('Connecting', { transport: this.name, url });\n this.changeState('connecting');\n return true;\n }\n\n /** Closes the connection.\n *\n * @return {Boolean} true if there was a connection to close\n */\n close(): boolean {\n if (this.socket) {\n this.socket.close();\n return true;\n } else {\n return false;\n }\n }\n\n /** Sends data over the open connection.\n *\n * @param {String} data\n * @return {Boolean} true only when in the \"open\" state\n */\n send(data: any): boolean {\n if (this.state === 'open') {\n // Workaround for MobileSafari bug (see https://gist.github.com/2052006)\n Util.defer(() => {\n if (this.socket) {\n this.socket.send(data);\n }\n });\n return true;\n } else {\n return false;\n }\n }\n\n /** Sends a ping if the connection is open and transport supports it. */\n ping() {\n if (this.state === 'open' && this.supportsPing()) {\n this.socket.ping();\n }\n }\n\n private onOpen() {\n if (this.hooks.beforeOpen) {\n this.hooks.beforeOpen(\n this.socket,\n this.hooks.urls.getPath(this.key, this.options)\n );\n }\n this.changeState('open');\n this.socket.onopen = undefined;\n }\n\n private onError(error) {\n this.emit('error', { type: 'WebSocketError', error: error });\n this.timeline.error(this.buildTimelineMessage({ error: error.toString() }));\n }\n\n private onClose(closeEvent?: any) {\n if (closeEvent) {\n this.changeState('closed', {\n code: closeEvent.code,\n reason: closeEvent.reason,\n wasClean: closeEvent.wasClean\n });\n } else {\n this.changeState('closed');\n }\n this.unbindListeners();\n this.socket = undefined;\n }\n\n private onMessage(message) {\n this.emit('message', message);\n }\n\n private onActivity() {\n this.emit('activity');\n }\n\n private bindListeners() {\n this.socket.onopen = () => {\n this.onOpen();\n };\n this.socket.onerror = error => {\n this.onError(error);\n };\n this.socket.onclose = closeEvent => {\n this.onClose(closeEvent);\n };\n this.socket.onmessage = message => {\n this.onMessage(message);\n };\n\n if (this.supportsPing()) {\n this.socket.onactivity = () => {\n this.onActivity();\n };\n }\n }\n\n private unbindListeners() {\n if (this.socket) {\n this.socket.onopen = undefined;\n this.socket.onerror = undefined;\n this.socket.onclose = undefined;\n this.socket.onmessage = undefined;\n if (this.supportsPing()) {\n this.socket.onactivity = undefined;\n }\n }\n }\n\n private changeState(state: string, params?: any) {\n this.state = state;\n this.timeline.info(\n this.buildTimelineMessage({\n state: state,\n params: params\n })\n );\n this.emit(state, params);\n }\n\n buildTimelineMessage(message): any {\n return Collections.extend({ cid: this.id }, message);\n }\n}\n","import Factory from '../utils/factory';\nimport TransportHooks from './transport_hooks';\nimport TransportConnection from './transport_connection';\nimport TransportConnectionOptions from './transport_connection_options';\n\n/** Provides interface for transport connection instantiation.\n *\n * Takes transport-specific hooks as the only argument, which allow checking\n * for transport support and creating its connections.\n *\n * Supported hooks: * - file - the name of the file to be fetched during initialization\n * - urls - URL scheme to be used by transport\n * - handlesActivityCheck - true when the transport handles activity checks\n * - supportsPing - true when the transport has a ping/activity API\n * - isSupported - tells whether the transport is supported in the environment\n * - getSocket - creates a WebSocket-compatible transport socket\n *\n * See transports.js for specific implementations.\n *\n * @param {Object} hooks object containing all needed transport hooks\n */\nexport default class Transport {\n hooks: TransportHooks;\n\n constructor(hooks: TransportHooks) {\n this.hooks = hooks;\n }\n\n /** Returns whether the transport is supported in the environment.\n *\n * @param {Object} envronment te environment details (encryption, settings)\n * @returns {Boolean} true when the transport is supported\n */\n isSupported(environment: any): boolean {\n return this.hooks.isSupported(environment);\n }\n\n /** Creates a transport connection.\n *\n * @param {String} name\n * @param {Number} priority\n * @param {String} key the application key\n * @param {Object} options\n * @returns {TransportConnection}\n */\n createConnection(\n name: string,\n priority: number,\n key: string,\n options: any\n ): TransportConnection {\n return new TransportConnection(this.hooks, name, priority, key, options);\n }\n}\n","import * as URLSchemes from 'core/transports/url_schemes';\nimport URLScheme from 'core/transports/url_scheme';\nimport Transport from 'core/transports/transport';\nimport Util from 'core/util';\nimport * as Collections from 'core/utils/collections';\nimport TransportHooks from 'core/transports/transport_hooks';\nimport TransportsTable from 'core/transports/transports_table';\nimport Runtime from 'runtime';\n\n/** WebSocket transport.\n *\n * Uses native WebSocket implementation, including MozWebSocket supported by\n * earlier Firefox versions.\n */\nvar WSTransport = new Transport({\n urls: URLSchemes.ws,\n handlesActivityChecks: false,\n supportsPing: false,\n\n isInitialized: function() {\n return Boolean(Runtime.getWebSocketAPI());\n },\n isSupported: function(): boolean {\n return Boolean(Runtime.getWebSocketAPI());\n },\n getSocket: function(url) {\n return Runtime.createWebSocket(url);\n }\n});\n\nvar httpConfiguration = {\n urls: URLSchemes.http,\n handlesActivityChecks: false,\n supportsPing: true,\n isInitialized: function() {\n return true;\n }\n};\n\nexport var streamingConfiguration = Collections.extend(\n {\n getSocket: function(url) {\n return Runtime.HTTPFactory.createStreamingSocket(url);\n }\n },\n httpConfiguration\n);\nexport var pollingConfiguration = Collections.extend(\n {\n getSocket: function(url) {\n return Runtime.HTTPFactory.createPollingSocket(url);\n }\n },\n httpConfiguration\n);\n\nvar xhrConfiguration = {\n isSupported: function(): boolean {\n return Runtime.isXHRSupported();\n }\n};\n\n/** HTTP streaming transport using CORS-enabled XMLHttpRequest. */\nvar XHRStreamingTransport = new Transport(\n (\n Collections.extend({}, streamingConfiguration, xhrConfiguration)\n )\n);\n\n/** HTTP long-polling transport using CORS-enabled XMLHttpRequest. */\nvar XHRPollingTransport = new Transport(\n Collections.extend({}, pollingConfiguration, xhrConfiguration)\n);\n\nvar Transports: TransportsTable = {\n ws: WSTransport,\n xhr_streaming: XHRStreamingTransport,\n xhr_polling: XHRPollingTransport\n};\n\nexport default Transports;\n","import {\n default as Transports,\n streamingConfiguration,\n pollingConfiguration\n} from 'isomorphic/transports/transports';\nimport Transport from 'core/transports/transport';\nimport TransportHooks from 'core/transports/transport_hooks';\nimport * as URLSchemes from 'core/transports/url_schemes';\nimport Runtime from 'runtime';\nimport { Dependencies } from '../dom/dependencies';\nimport * as Collections from 'core/utils/collections';\n\nvar SockJSTransport = new Transport({\n file: 'sockjs',\n urls: URLSchemes.sockjs,\n handlesActivityChecks: true,\n supportsPing: false,\n\n isSupported: function() {\n return true;\n },\n isInitialized: function() {\n return window.SockJS !== undefined;\n },\n getSocket: function(url, options) {\n return new window.SockJS(url, null, {\n js_path: Dependencies.getPath('sockjs', {\n useTLS: options.useTLS\n }),\n ignore_null_origin: options.ignoreNullOrigin\n });\n },\n beforeOpen: function(socket, path) {\n socket.send(\n JSON.stringify({\n path: path\n })\n );\n }\n});\n\nvar xdrConfiguration = {\n isSupported: function(environment): boolean {\n var yes = Runtime.isXDRSupported(environment.useTLS);\n return yes;\n }\n};\n\n/** HTTP streaming transport using XDomainRequest (IE 8,9). */\nvar XDRStreamingTransport = new Transport(\n (\n Collections.extend({}, streamingConfiguration, xdrConfiguration)\n )\n);\n\n/** HTTP long-polling transport using XDomainRequest (IE 8,9). */\nvar XDRPollingTransport = new Transport(\n Collections.extend({}, pollingConfiguration, xdrConfiguration)\n);\n\nTransports.xdr_streaming = XDRStreamingTransport;\nTransports.xdr_polling = XDRPollingTransport;\nTransports.sockjs = SockJSTransport;\n\nexport default Transports;\n","import Reachability from 'core/reachability';\nimport { default as EventsDispatcher } from 'core/events/dispatcher';\n\n/** Really basic interface providing network availability info.\n *\n * Emits:\n * - online - when browser goes online\n * - offline - when browser goes offline\n */\nexport class NetInfo extends EventsDispatcher implements Reachability {\n constructor() {\n super();\n var self = this;\n // This is okay, as IE doesn't support this stuff anyway.\n if (window.addEventListener !== undefined) {\n window.addEventListener(\n 'online',\n function() {\n self.emit('online');\n },\n false\n );\n window.addEventListener(\n 'offline',\n function() {\n self.emit('offline');\n },\n false\n );\n }\n }\n\n /** Returns whether browser is online or not\n *\n * Offline means definitely offline (no connection to router).\n * Inverse does NOT mean definitely online (only currently supported in Safari\n * and even there only means the device has a connection to the router).\n *\n * @return {Boolean}\n */\n isOnline(): boolean {\n if (window.navigator.onLine === undefined) {\n return true;\n } else {\n return window.navigator.onLine;\n }\n }\n}\n\nexport var Network = new NetInfo();\n","import Util from '../util';\nimport * as Collections from '../utils/collections';\nimport TransportManager from './transport_manager';\nimport TransportConnection from './transport_connection';\nimport Transport from './transport';\nimport PingDelayOptions from './ping_delay_options';\n\n/** Creates transport connections monitored by a transport manager.\n *\n * When a transport is closed, it might mean the environment does not support\n * it. It's possible that messages get stuck in an intermediate buffer or\n * proxies terminate inactive connections. To combat these problems,\n * assistants monitor the connection lifetime, report unclean exits and\n * adjust ping timeouts to keep the connection active. The decision to disable\n * a transport is the manager's responsibility.\n *\n * @param {TransportManager} manager\n * @param {TransportConnection} transport\n * @param {Object} options\n */\nexport default class AssistantToTheTransportManager {\n manager: TransportManager;\n transport: Transport;\n minPingDelay: number;\n maxPingDelay: number;\n pingDelay: number;\n\n constructor(\n manager: TransportManager,\n transport: Transport,\n options: PingDelayOptions\n ) {\n this.manager = manager;\n this.transport = transport;\n this.minPingDelay = options.minPingDelay;\n this.maxPingDelay = options.maxPingDelay;\n this.pingDelay = undefined;\n }\n\n /** Creates a transport connection.\n *\n * This function has the same API as Transport#createConnection.\n *\n * @param {String} name\n * @param {Number} priority\n * @param {String} key the application key\n * @param {Object} options\n * @returns {TransportConnection}\n */\n createConnection(\n name: string,\n priority: number,\n key: string,\n options: Object\n ): TransportConnection {\n options = Collections.extend({}, options, {\n activityTimeout: this.pingDelay\n });\n var connection = this.transport.createConnection(\n name,\n priority,\n key,\n options\n );\n\n var openTimestamp = null;\n\n var onOpen = function() {\n connection.unbind('open', onOpen);\n connection.bind('closed', onClosed);\n openTimestamp = Util.now();\n };\n var onClosed = closeEvent => {\n connection.unbind('closed', onClosed);\n\n if (closeEvent.code === 1002 || closeEvent.code === 1003) {\n // we don't want to use transports not obeying the protocol\n this.manager.reportDeath();\n } else if (!closeEvent.wasClean && openTimestamp) {\n // report deaths only for short-living transport\n var lifespan = Util.now() - openTimestamp;\n if (lifespan < 2 * this.maxPingDelay) {\n this.manager.reportDeath();\n this.pingDelay = Math.max(lifespan / 2, this.minPingDelay);\n }\n }\n };\n\n connection.bind('open', onOpen);\n return connection;\n }\n\n /** Returns whether the transport is supported in the environment.\n *\n * This function has the same API as Transport#isSupported. Might return false\n * when the manager decides to kill the transport.\n *\n * @param {Object} environment the environment details (encryption, settings)\n * @returns {Boolean} true when the transport is supported\n */\n isSupported(environment: string): boolean {\n return this.manager.isAlive() && this.transport.isSupported(environment);\n }\n}\n","import Action from './action';\nimport { PusherEvent } from './message-types';\n/**\n * Provides functions for handling Pusher protocol-specific messages.\n */\n\nconst Protocol = {\n /**\n * Decodes a message in a Pusher format.\n *\n * The MessageEvent we receive from the transport should contain a pusher event\n * (https://pusher.com/docs/pusher_protocol#events) serialized as JSON in the\n * data field\n *\n * The pusher event may contain a data field too, and it may also be\n * serialised as JSON\n *\n * Throws errors when messages are not parse'able.\n *\n * @param {MessageEvent} messageEvent\n * @return {PusherEvent}\n */\n decodeMessage: function(messageEvent: MessageEvent): PusherEvent {\n try {\n var messageData = JSON.parse(messageEvent.data);\n var pusherEventData = messageData.data;\n if (typeof pusherEventData === 'string') {\n try {\n pusherEventData = JSON.parse(messageData.data);\n } catch (e) {}\n }\n var pusherEvent: PusherEvent = {\n event: messageData.event,\n channel: messageData.channel,\n data: pusherEventData\n };\n if (messageData.user_id) {\n pusherEvent.user_id = messageData.user_id;\n }\n return pusherEvent;\n } catch (e) {\n throw { type: 'MessageParseError', error: e, data: messageEvent.data };\n }\n },\n\n /**\n * Encodes a message to be sent.\n *\n * @param {PusherEvent} event\n * @return {String}\n */\n encodeMessage: function(event: PusherEvent): string {\n return JSON.stringify(event);\n },\n\n /**\n * Processes a handshake message and returns appropriate actions.\n *\n * Returns an object with an 'action' and other action-specific properties.\n *\n * There are three outcomes when calling this function. First is a successful\n * connection attempt, when pusher:connection_established is received, which\n * results in a 'connected' action with an 'id' property. When passed a\n * pusher:error event, it returns a result with action appropriate to the\n * close code and an error. Otherwise, it raises an exception.\n *\n * @param {String} message\n * @result Object\n */\n processHandshake: function(messageEvent: MessageEvent): Action {\n var message = Protocol.decodeMessage(messageEvent);\n\n if (message.event === 'pusher:connection_established') {\n if (!message.data.activity_timeout) {\n throw 'No activity timeout specified in handshake';\n }\n return {\n action: 'connected',\n id: message.data.socket_id,\n activityTimeout: message.data.activity_timeout * 1000\n };\n } else if (message.event === 'pusher:error') {\n // From protocol 6 close codes are sent only once, so this only\n // happens when connection does not support close codes\n return {\n action: this.getCloseAction(message.data),\n error: this.getCloseError(message.data)\n };\n } else {\n throw 'Invalid handshake';\n }\n },\n\n /**\n * Dispatches the close event and returns an appropriate action name.\n *\n * See:\n * 1. https://developer.mozilla.org/en-US/docs/WebSockets/WebSockets_reference/CloseEvent\n * 2. http://pusher.com/docs/pusher_protocol\n *\n * @param {CloseEvent} closeEvent\n * @return {String} close action name\n */\n getCloseAction: function(closeEvent): string {\n if (closeEvent.code < 4000) {\n // ignore 1000 CLOSE_NORMAL, 1001 CLOSE_GOING_AWAY,\n // 1005 CLOSE_NO_STATUS, 1006 CLOSE_ABNORMAL\n // ignore 1007...3999\n // handle 1002 CLOSE_PROTOCOL_ERROR, 1003 CLOSE_UNSUPPORTED,\n // 1004 CLOSE_TOO_LARGE\n if (closeEvent.code >= 1002 && closeEvent.code <= 1004) {\n return 'backoff';\n } else {\n return null;\n }\n } else if (closeEvent.code === 4000) {\n return 'tls_only';\n } else if (closeEvent.code < 4100) {\n return 'refused';\n } else if (closeEvent.code < 4200) {\n return 'backoff';\n } else if (closeEvent.code < 4300) {\n return 'retry';\n } else {\n // unknown error\n return 'refused';\n }\n },\n\n /**\n * Returns an error or null basing on the close event.\n *\n * Null is returned when connection was closed cleanly. Otherwise, an object\n * with error details is returned.\n *\n * @param {CloseEvent} closeEvent\n * @return {Object} error object\n */\n getCloseError: function(closeEvent): any {\n if (closeEvent.code !== 1000 && closeEvent.code !== 1001) {\n return {\n type: 'PusherError',\n data: {\n code: closeEvent.code,\n message: closeEvent.reason || closeEvent.message\n }\n };\n } else {\n return null;\n }\n }\n};\n\nexport default Protocol;\n","import * as Collections from '../utils/collections';\nimport { default as EventsDispatcher } from '../events/dispatcher';\nimport Protocol from './protocol/protocol';\nimport { PusherEvent } from './protocol/message-types';\nimport Logger from '../logger';\nimport TransportConnection from '../transports/transport_connection';\nimport Socket from '../socket';\n/**\n * Provides Pusher protocol interface for transports.\n *\n * Emits following events:\n * - message - on received messages\n * - ping - on ping requests\n * - pong - on pong responses\n * - error - when the transport emits an error\n * - closed - after closing the transport\n *\n * It also emits more events when connection closes with a code.\n * See Protocol.getCloseAction to get more details.\n *\n * @param {Number} id\n * @param {AbstractTransport} transport\n */\nexport default class Connection extends EventsDispatcher implements Socket {\n id: string;\n transport: TransportConnection;\n activityTimeout: number;\n\n constructor(id: string, transport: TransportConnection) {\n super();\n this.id = id;\n this.transport = transport;\n this.activityTimeout = transport.activityTimeout;\n this.bindListeners();\n }\n\n /** Returns whether used transport handles activity checks by itself\n *\n * @returns {Boolean} true if activity checks are handled by the transport\n */\n handlesActivityChecks() {\n return this.transport.handlesActivityChecks();\n }\n\n /** Sends raw data.\n *\n * @param {String} data\n */\n send(data: any): boolean {\n return this.transport.send(data);\n }\n\n /** Sends an event.\n *\n * @param {String} name\n * @param {String} data\n * @param {String} [channel]\n * @returns {Boolean} whether message was sent or not\n */\n send_event(name: string, data: any, channel?: string): boolean {\n var event: PusherEvent = { event: name, data: data };\n if (channel) {\n event.channel = channel;\n }\n Logger.debug('Event sent', event);\n return this.send(Protocol.encodeMessage(event));\n }\n\n /** Sends a ping message to the server.\n *\n * Basing on the underlying transport, it might send either transport's\n * protocol-specific ping or pusher:ping event.\n */\n ping() {\n if (this.transport.supportsPing()) {\n this.transport.ping();\n } else {\n this.send_event('pusher:ping', {});\n }\n }\n\n /** Closes the connection. */\n close() {\n this.transport.close();\n }\n\n private bindListeners() {\n var listeners = {\n message: (messageEvent: MessageEvent) => {\n var pusherEvent;\n try {\n pusherEvent = Protocol.decodeMessage(messageEvent);\n } catch (e) {\n this.emit('error', {\n type: 'MessageParseError',\n error: e,\n data: messageEvent.data\n });\n }\n\n if (pusherEvent !== undefined) {\n Logger.debug('Event recd', pusherEvent);\n\n switch (pusherEvent.event) {\n case 'pusher:error':\n this.emit('error', {\n type: 'PusherError',\n data: pusherEvent.data\n });\n break;\n case 'pusher:ping':\n this.emit('ping');\n break;\n case 'pusher:pong':\n this.emit('pong');\n break;\n }\n this.emit('message', pusherEvent);\n }\n },\n activity: () => {\n this.emit('activity');\n },\n error: error => {\n this.emit('error', error);\n },\n closed: closeEvent => {\n unbindListeners();\n\n if (closeEvent && closeEvent.code) {\n this.handleCloseEvent(closeEvent);\n }\n\n this.transport = null;\n this.emit('closed');\n }\n };\n\n var unbindListeners = () => {\n Collections.objectApply(listeners, (listener, event) => {\n this.transport.unbind(event, listener);\n });\n };\n\n Collections.objectApply(listeners, (listener, event) => {\n this.transport.bind(event, listener);\n });\n }\n\n private handleCloseEvent(closeEvent: any) {\n var action = Protocol.getCloseAction(closeEvent);\n var error = Protocol.getCloseError(closeEvent);\n if (error) {\n this.emit('error', error);\n }\n if (action) {\n this.emit(action, { action: action, error: error });\n }\n }\n}\n","import Util from '../../util';\nimport * as Collections from '../../utils/collections';\nimport Protocol from '../protocol/protocol';\nimport Connection from '../connection';\nimport TransportConnection from '../../transports/transport_connection';\nimport HandshakePayload from './handshake_payload';\n\n/**\n * Handles Pusher protocol handshakes for transports.\n *\n * Calls back with a result object after handshake is completed. Results\n * always have two fields:\n * - action - string describing action to be taken after the handshake\n * - transport - the transport object passed to the constructor\n *\n * Different actions can set different additional properties on the result.\n * In the case of 'connected' action, there will be a 'connection' property\n * containing a Connection object for the transport. Other actions should\n * carry an 'error' property.\n *\n * @param {AbstractTransport} transport\n * @param {Function} callback\n */\nexport default class Handshake {\n transport: TransportConnection;\n callback: (HandshakePayload) => void;\n onMessage: Function;\n onClosed: Function;\n\n constructor(\n transport: TransportConnection,\n callback: (HandshakePayload) => void\n ) {\n this.transport = transport;\n this.callback = callback;\n this.bindListeners();\n }\n\n close() {\n this.unbindListeners();\n this.transport.close();\n }\n\n private bindListeners() {\n this.onMessage = m => {\n this.unbindListeners();\n\n var result;\n try {\n result = Protocol.processHandshake(m);\n } catch (e) {\n this.finish('error', { error: e });\n this.transport.close();\n return;\n }\n\n if (result.action === 'connected') {\n this.finish('connected', {\n connection: new Connection(result.id, this.transport),\n activityTimeout: result.activityTimeout\n });\n } else {\n this.finish(result.action, { error: result.error });\n this.transport.close();\n }\n };\n\n this.onClosed = closeEvent => {\n this.unbindListeners();\n\n var action = Protocol.getCloseAction(closeEvent) || 'backoff';\n var error = Protocol.getCloseError(closeEvent);\n this.finish(action, { error: error });\n };\n\n this.transport.bind('message', this.onMessage);\n this.transport.bind('closed', this.onClosed);\n }\n\n private unbindListeners() {\n this.transport.unbind('message', this.onMessage);\n this.transport.unbind('closed', this.onClosed);\n }\n\n private finish(action: string, params: any) {\n this.callback(\n Collections.extend({ transport: this.transport, action: action }, params)\n );\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport base64encode from '../base64';\nimport Timeline from './timeline';\nimport Runtime from 'runtime';\n\nexport interface TimelineSenderOptions {\n host?: string;\n port?: number;\n path?: string;\n}\n\nexport default class TimelineSender {\n timeline: Timeline;\n options: TimelineSenderOptions;\n host: string;\n\n constructor(timeline: Timeline, options: TimelineSenderOptions) {\n this.timeline = timeline;\n this.options = options || {};\n }\n\n send(useTLS: boolean, callback?: Function) {\n if (this.timeline.isEmpty()) {\n return;\n }\n\n this.timeline.send(\n Runtime.TimelineTransport.getAgent(this, useTLS),\n callback\n );\n }\n}\n","import { default as EventsDispatcher } from '../events/dispatcher';\nimport * as Errors from '../errors';\nimport Logger from '../logger';\nimport Pusher from '../pusher';\nimport { PusherEvent } from '../connection/protocol/message-types';\nimport Metadata from './metadata';\nimport UrlStore from '../utils/url_store';\nimport {\n ChannelAuthorizationData,\n ChannelAuthorizationCallback\n} from '../auth/options';\nimport { HTTPAuthError } from '../errors';\n\n/** Provides base public channel interface with an event emitter.\n *\n * Emits:\n * - pusher:subscription_succeeded - after subscribing successfully\n * - other non-internal events\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\nexport default class Channel extends EventsDispatcher {\n name: string;\n pusher: Pusher;\n subscribed: boolean;\n subscriptionPending: boolean;\n subscriptionCancelled: boolean;\n subscriptionCount: null;\n\n constructor(name: string, pusher: Pusher) {\n super(function(event, data) {\n Logger.debug('No callbacks on ' + name + ' for ' + event);\n });\n\n this.name = name;\n this.pusher = pusher;\n this.subscribed = false;\n this.subscriptionPending = false;\n this.subscriptionCancelled = false;\n }\n\n /** Skips authorization, since public channels don't require it.\n *\n * @param {Function} callback\n */\n authorize(socketId: string, callback: ChannelAuthorizationCallback) {\n return callback(null, { auth: '' });\n }\n\n /** Triggers an event */\n trigger(event: string, data: any) {\n if (event.indexOf('client-') !== 0) {\n throw new Errors.BadEventName(\n \"Event '\" + event + \"' does not start with 'client-'\"\n );\n }\n if (!this.subscribed) {\n var suffix = UrlStore.buildLogSuffix('triggeringClientEvents');\n Logger.warn(\n `Client event triggered before channel 'subscription_succeeded' event . ${suffix}`\n );\n }\n return this.pusher.send_event(event, data, this.name);\n }\n\n /** Signals disconnection to the channel. For internal use only. */\n disconnect() {\n this.subscribed = false;\n this.subscriptionPending = false;\n }\n\n /** Handles a PusherEvent. For internal use only.\n *\n * @param {PusherEvent} event\n */\n handleEvent(event: PusherEvent) {\n var eventName = event.event;\n var data = event.data;\n if (eventName === 'pusher_internal:subscription_succeeded') {\n this.handleSubscriptionSucceededEvent(event);\n } else if (eventName === 'pusher_internal:subscription_count') {\n this.handleSubscriptionCountEvent(event);\n } else if (eventName.indexOf('pusher_internal:') !== 0) {\n var metadata: Metadata = {};\n this.emit(eventName, data, metadata);\n }\n }\n\n handleSubscriptionSucceededEvent(event: PusherEvent) {\n this.subscriptionPending = false;\n this.subscribed = true;\n if (this.subscriptionCancelled) {\n this.pusher.unsubscribe(this.name);\n } else {\n this.emit('pusher:subscription_succeeded', event.data);\n }\n }\n\n handleSubscriptionCountEvent(event: PusherEvent) {\n if (event.data.subscription_count) {\n this.subscriptionCount = event.data.subscription_count;\n }\n\n this.emit('pusher:subscription_count', event.data);\n }\n\n /** Sends a subscription request. For internal use only. */\n subscribe() {\n if (this.subscribed) {\n return;\n }\n this.subscriptionPending = true;\n this.subscriptionCancelled = false;\n this.authorize(\n this.pusher.connection.socket_id,\n (error: Error | null, data: ChannelAuthorizationData) => {\n if (error) {\n this.subscriptionPending = false;\n // Why not bind to 'pusher:subscription_error' a level up, and log there?\n // Binding to this event would cause the warning about no callbacks being\n // bound (see constructor) to be suppressed, that's not what we want.\n Logger.error(error.toString());\n this.emit(\n 'pusher:subscription_error',\n Object.assign(\n {},\n {\n type: 'AuthError',\n error: error.message\n },\n error instanceof HTTPAuthError ? { status: error.status } : {}\n )\n );\n } else {\n this.pusher.send_event('pusher:subscribe', {\n auth: data.auth,\n channel_data: data.channel_data,\n channel: this.name\n });\n }\n }\n );\n }\n\n /** Sends an unsubscription request. For internal use only. */\n unsubscribe() {\n this.subscribed = false;\n this.pusher.send_event('pusher:unsubscribe', {\n channel: this.name\n });\n }\n\n /** Cancels an in progress subscription. For internal use only. */\n cancelSubscription() {\n this.subscriptionCancelled = true;\n }\n\n /** Reinstates an in progress subscripiton. For internal use only. */\n reinstateSubscription() {\n this.subscriptionCancelled = false;\n }\n}\n","import Factory from '../utils/factory';\nimport Channel from './channel';\nimport { ChannelAuthorizationCallback } from '../auth/options';\n\n/** Extends public channels to provide private channel interface.\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\nexport default class PrivateChannel extends Channel {\n /** Authorizes the connection to use the channel.\n *\n * @param {String} socketId\n * @param {Function} callback\n */\n authorize(socketId: string, callback: ChannelAuthorizationCallback) {\n return this.pusher.config.channelAuthorizer(\n {\n channelName: this.name,\n socketId: socketId\n },\n callback\n );\n }\n}\n","import * as Collections from '../utils/collections';\n\n/** Represents a collection of members of a presence channel. */\nexport default class Members {\n members: any;\n count: number;\n myID: any;\n me: any;\n\n constructor() {\n this.reset();\n }\n\n /** Returns member's info for given id.\n *\n * Resulting object containts two fields - id and info.\n *\n * @param {Number} id\n * @return {Object} member's info or null\n */\n get(id: string): any {\n if (Object.prototype.hasOwnProperty.call(this.members, id)) {\n return {\n id: id,\n info: this.members[id]\n };\n } else {\n return null;\n }\n }\n\n /** Calls back for each member in unspecified order.\n *\n * @param {Function} callback\n */\n each(callback: Function) {\n Collections.objectApply(this.members, (member, id) => {\n callback(this.get(id));\n });\n }\n\n /** Updates the id for connected member. For internal use only. */\n setMyID(id: string) {\n this.myID = id;\n }\n\n /** Handles subscription data. For internal use only. */\n onSubscription(subscriptionData: any) {\n this.members = subscriptionData.presence.hash;\n this.count = subscriptionData.presence.count;\n this.me = this.get(this.myID);\n }\n\n /** Adds a new member to the collection. For internal use only. */\n addMember(memberData: any) {\n if (this.get(memberData.user_id) === null) {\n this.count++;\n }\n this.members[memberData.user_id] = memberData.user_info;\n return this.get(memberData.user_id);\n }\n\n /** Adds a member from the collection. For internal use only. */\n removeMember(memberData: any) {\n var member = this.get(memberData.user_id);\n if (member) {\n delete this.members[memberData.user_id];\n this.count--;\n }\n return member;\n }\n\n /** Resets the collection to the initial state. For internal use only. */\n reset() {\n this.members = {};\n this.count = 0;\n this.myID = null;\n this.me = null;\n }\n}\n","import PrivateChannel from './private_channel';\nimport Logger from '../logger';\nimport Members from './members';\nimport Pusher from '../pusher';\nimport UrlStore from 'core/utils/url_store';\nimport { PusherEvent } from '../connection/protocol/message-types';\nimport Metadata from './metadata';\nimport { ChannelAuthorizationData } from '../auth/options';\n\nexport default class PresenceChannel extends PrivateChannel {\n members: Members;\n\n /** Adds presence channel functionality to private channels.\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\n constructor(name: string, pusher: Pusher) {\n super(name, pusher);\n this.members = new Members();\n }\n\n /** Authorizes the connection as a member of the channel.\n *\n * @param {String} socketId\n * @param {Function} callback\n */\n authorize(socketId: string, callback: Function) {\n super.authorize(socketId, async (error, authData) => {\n if (!error) {\n authData = authData as ChannelAuthorizationData;\n if (authData.channel_data != null) {\n var channelData = JSON.parse(authData.channel_data);\n this.members.setMyID(channelData.user_id);\n } else {\n await this.pusher.user.signinDonePromise;\n if (this.pusher.user.user_data != null) {\n // If the user is signed in, get the id of the authenticated user\n // and allow the presence authorization to continue.\n this.members.setMyID(this.pusher.user.user_data.id);\n } else {\n let suffix = UrlStore.buildLogSuffix('authorizationEndpoint');\n Logger.error(\n `Invalid auth response for channel '${this.name}', ` +\n `expected 'channel_data' field. ${suffix}, ` +\n `or the user should be signed in.`\n );\n callback('Invalid auth response');\n return;\n }\n }\n }\n callback(error, authData);\n });\n }\n\n /** Handles presence and subscription events. For internal use only.\n *\n * @param {PusherEvent} event\n */\n handleEvent(event: PusherEvent) {\n var eventName = event.event;\n if (eventName.indexOf('pusher_internal:') === 0) {\n this.handleInternalEvent(event);\n } else {\n var data = event.data;\n var metadata: Metadata = {};\n if (event.user_id) {\n metadata.user_id = event.user_id;\n }\n this.emit(eventName, data, metadata);\n }\n }\n handleInternalEvent(event: PusherEvent) {\n var eventName = event.event;\n var data = event.data;\n switch (eventName) {\n case 'pusher_internal:subscription_succeeded':\n this.handleSubscriptionSucceededEvent(event);\n break;\n case 'pusher_internal:subscription_count':\n this.handleSubscriptionCountEvent(event);\n break;\n case 'pusher_internal:member_added':\n var addedMember = this.members.addMember(data);\n this.emit('pusher:member_added', addedMember);\n break;\n case 'pusher_internal:member_removed':\n var removedMember = this.members.removeMember(data);\n if (removedMember) {\n this.emit('pusher:member_removed', removedMember);\n }\n break;\n }\n }\n\n handleSubscriptionSucceededEvent(event: PusherEvent) {\n this.subscriptionPending = false;\n this.subscribed = true;\n if (this.subscriptionCancelled) {\n this.pusher.unsubscribe(this.name);\n } else {\n this.members.onSubscription(event.data);\n this.emit('pusher:subscription_succeeded', this.members);\n }\n }\n\n /** Resets the channel state, including members map. For internal use only. */\n disconnect() {\n this.members.reset();\n super.disconnect();\n }\n}\n","import PrivateChannel from './private_channel';\nimport * as Errors from '../errors';\nimport Logger from '../logger';\nimport Pusher from '../pusher';\nimport { decode as encodeUTF8 } from '@stablelib/utf8';\nimport { decode as decodeBase64 } from '@stablelib/base64';\nimport Dispatcher from '../events/dispatcher';\nimport { PusherEvent } from '../connection/protocol/message-types';\nimport {\n ChannelAuthorizationData,\n ChannelAuthorizationCallback\n} from '../auth/options';\nimport * as nacl from 'tweetnacl';\n\n/** Extends private channels to provide encrypted channel interface.\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\nexport default class EncryptedChannel extends PrivateChannel {\n key: Uint8Array = null;\n nacl: nacl;\n\n constructor(name: string, pusher: Pusher, nacl: nacl) {\n super(name, pusher);\n this.nacl = nacl;\n }\n\n /** Authorizes the connection to use the channel.\n *\n * @param {String} socketId\n * @param {Function} callback\n */\n authorize(socketId: string, callback: ChannelAuthorizationCallback) {\n super.authorize(\n socketId,\n (error: Error | null, authData: ChannelAuthorizationData) => {\n if (error) {\n callback(error, authData);\n return;\n }\n let sharedSecret = authData['shared_secret'];\n if (!sharedSecret) {\n callback(\n new Error(\n `No shared_secret key in auth payload for encrypted channel: ${this.name}`\n ),\n null\n );\n return;\n }\n this.key = decodeBase64(sharedSecret);\n delete authData['shared_secret'];\n callback(null, authData);\n }\n );\n }\n\n trigger(event: string, data: any): boolean {\n throw new Errors.UnsupportedFeature(\n 'Client events are not currently supported for encrypted channels'\n );\n }\n\n /** Handles an event. For internal use only.\n *\n * @param {PusherEvent} event\n */\n handleEvent(event: PusherEvent) {\n var eventName = event.event;\n var data = event.data;\n if (\n eventName.indexOf('pusher_internal:') === 0 ||\n eventName.indexOf('pusher:') === 0\n ) {\n super.handleEvent(event);\n return;\n }\n this.handleEncryptedEvent(eventName, data);\n }\n\n private handleEncryptedEvent(event: string, data: any): void {\n if (!this.key) {\n Logger.debug(\n 'Received encrypted event before key has been retrieved from the authEndpoint'\n );\n return;\n }\n if (!data.ciphertext || !data.nonce) {\n Logger.error(\n 'Unexpected format for encrypted event, expected object with `ciphertext` and `nonce` fields, got: ' +\n data\n );\n return;\n }\n let cipherText = decodeBase64(data.ciphertext);\n if (cipherText.length < this.nacl.secretbox.overheadLength) {\n Logger.error(\n `Expected encrypted event ciphertext length to be ${this.nacl.secretbox.overheadLength}, got: ${cipherText.length}`\n );\n return;\n }\n let nonce = decodeBase64(data.nonce);\n if (nonce.length < this.nacl.secretbox.nonceLength) {\n Logger.error(\n `Expected encrypted event nonce length to be ${this.nacl.secretbox.nonceLength}, got: ${nonce.length}`\n );\n return;\n }\n\n let bytes = this.nacl.secretbox.open(cipherText, nonce, this.key);\n if (bytes === null) {\n Logger.debug(\n 'Failed to decrypt an event, probably because it was encrypted with a different key. Fetching a new key from the authEndpoint...'\n );\n // Try a single time to retrieve a new auth key and decrypt the event with it\n // If this fails, a new key will be requested when a new message is received\n this.authorize(this.pusher.connection.socket_id, (error, authData) => {\n if (error) {\n Logger.error(\n `Failed to make a request to the authEndpoint: ${authData}. Unable to fetch new key, so dropping encrypted event`\n );\n return;\n }\n bytes = this.nacl.secretbox.open(cipherText, nonce, this.key);\n if (bytes === null) {\n Logger.error(\n `Failed to decrypt event with new key. Dropping encrypted event`\n );\n return;\n }\n this.emit(event, this.getDataToEmit(bytes));\n return;\n });\n return;\n }\n this.emit(event, this.getDataToEmit(bytes));\n }\n\n // Try and parse the decrypted bytes as JSON. If we can't parse it, just\n // return the utf-8 string\n getDataToEmit(bytes: Uint8Array): string {\n let raw = encodeUTF8(bytes);\n try {\n return JSON.parse(raw);\n } catch {\n return raw;\n }\n }\n}\n","import { default as EventsDispatcher } from '../events/dispatcher';\nimport { OneOffTimer as Timer } from '../utils/timers';\nimport { Config } from '../config';\nimport Logger from '../logger';\nimport HandshakePayload from './handshake/handshake_payload';\nimport Connection from './connection';\nimport Strategy from '../strategies/strategy';\nimport StrategyRunner from '../strategies/strategy_runner';\nimport * as Collections from '../utils/collections';\nimport Timeline from '../timeline/timeline';\nimport ConnectionManagerOptions from './connection_manager_options';\nimport Runtime from 'runtime';\n\nimport {\n ErrorCallbacks,\n HandshakeCallbacks,\n ConnectionCallbacks\n} from './callbacks';\nimport Action from './protocol/action';\n\n/** Manages connection to Pusher.\n *\n * Uses a strategy (currently only default), timers and network availability\n * info to establish a connection and export its state. In case of failures,\n * manages reconnection attempts.\n *\n * Exports state changes as following events:\n * - \"state_change\", { previous: p, current: state }\n * - state\n *\n * States:\n * - initialized - initial state, never transitioned to\n * - connecting - connection is being established\n * - connected - connection has been fully established\n * - disconnected - on requested disconnection\n * - unavailable - after connection timeout or when there's no network\n * - failed - when the connection strategy is not supported\n *\n * Options:\n * - unavailableTimeout - time to transition to unavailable state\n * - activityTimeout - time after which ping message should be sent\n * - pongTimeout - time for Pusher to respond with pong before reconnecting\n *\n * @param {String} key application key\n * @param {Object} options\n */\nexport default class ConnectionManager extends EventsDispatcher {\n key: string;\n options: ConnectionManagerOptions;\n state: string;\n connection: Connection;\n usingTLS: boolean;\n timeline: Timeline;\n socket_id: string;\n unavailableTimer: Timer;\n activityTimer: Timer;\n retryTimer: Timer;\n activityTimeout: number;\n strategy: Strategy;\n runner: StrategyRunner;\n errorCallbacks: ErrorCallbacks;\n handshakeCallbacks: HandshakeCallbacks;\n connectionCallbacks: ConnectionCallbacks;\n\n constructor(key: string, options: ConnectionManagerOptions) {\n super();\n this.state = 'initialized';\n this.connection = null;\n\n this.key = key;\n this.options = options;\n this.timeline = this.options.timeline;\n this.usingTLS = this.options.useTLS;\n\n this.errorCallbacks = this.buildErrorCallbacks();\n this.connectionCallbacks = this.buildConnectionCallbacks(\n this.errorCallbacks\n );\n this.handshakeCallbacks = this.buildHandshakeCallbacks(this.errorCallbacks);\n\n var Network = Runtime.getNetwork();\n\n Network.bind('online', () => {\n this.timeline.info({ netinfo: 'online' });\n if (this.state === 'connecting' || this.state === 'unavailable') {\n this.retryIn(0);\n }\n });\n Network.bind('offline', () => {\n this.timeline.info({ netinfo: 'offline' });\n if (this.connection) {\n this.sendActivityCheck();\n }\n });\n\n this.updateStrategy();\n }\n\n /** Establishes a connection to Pusher.\n *\n * Does nothing when connection is already established. See top-level doc\n * to find events emitted on connection attempts.\n */\n connect() {\n if (this.connection || this.runner) {\n return;\n }\n if (!this.strategy.isSupported()) {\n this.updateState('failed');\n return;\n }\n this.updateState('connecting');\n this.startConnecting();\n this.setUnavailableTimer();\n }\n\n /** Sends raw data.\n *\n * @param {String} data\n */\n send(data) {\n if (this.connection) {\n return this.connection.send(data);\n } else {\n return false;\n }\n }\n\n /** Sends an event.\n *\n * @param {String} name\n * @param {String} data\n * @param {String} [channel]\n * @returns {Boolean} whether message was sent or not\n */\n send_event(name: string, data: any, channel?: string) {\n if (this.connection) {\n return this.connection.send_event(name, data, channel);\n } else {\n return false;\n }\n }\n\n /** Closes the connection. */\n disconnect() {\n this.disconnectInternally();\n this.updateState('disconnected');\n }\n\n isUsingTLS() {\n return this.usingTLS;\n }\n\n private startConnecting() {\n var callback = (error, handshake) => {\n if (error) {\n this.runner = this.strategy.connect(0, callback);\n } else {\n if (handshake.action === 'error') {\n this.emit('error', {\n type: 'HandshakeError',\n error: handshake.error\n });\n this.timeline.error({ handshakeError: handshake.error });\n } else {\n this.abortConnecting(); // we don't support switching connections yet\n this.handshakeCallbacks[handshake.action](handshake);\n }\n }\n };\n this.runner = this.strategy.connect(0, callback);\n }\n\n private abortConnecting() {\n if (this.runner) {\n this.runner.abort();\n this.runner = null;\n }\n }\n\n private disconnectInternally() {\n this.abortConnecting();\n this.clearRetryTimer();\n this.clearUnavailableTimer();\n if (this.connection) {\n var connection = this.abandonConnection();\n connection.close();\n }\n }\n\n private updateStrategy() {\n this.strategy = this.options.getStrategy({\n key: this.key,\n timeline: this.timeline,\n useTLS: this.usingTLS\n });\n }\n\n private retryIn(delay) {\n this.timeline.info({ action: 'retry', delay: delay });\n if (delay > 0) {\n this.emit('connecting_in', Math.round(delay / 1000));\n }\n this.retryTimer = new Timer(delay || 0, () => {\n this.disconnectInternally();\n this.connect();\n });\n }\n\n private clearRetryTimer() {\n if (this.retryTimer) {\n this.retryTimer.ensureAborted();\n this.retryTimer = null;\n }\n }\n\n private setUnavailableTimer() {\n this.unavailableTimer = new Timer(this.options.unavailableTimeout, () => {\n this.updateState('unavailable');\n });\n }\n\n private clearUnavailableTimer() {\n if (this.unavailableTimer) {\n this.unavailableTimer.ensureAborted();\n }\n }\n\n private sendActivityCheck() {\n this.stopActivityCheck();\n this.connection.ping();\n // wait for pong response\n this.activityTimer = new Timer(this.options.pongTimeout, () => {\n this.timeline.error({ pong_timed_out: this.options.pongTimeout });\n this.retryIn(0);\n });\n }\n\n private resetActivityCheck() {\n this.stopActivityCheck();\n // send ping after inactivity\n if (this.connection && !this.connection.handlesActivityChecks()) {\n this.activityTimer = new Timer(this.activityTimeout, () => {\n this.sendActivityCheck();\n });\n }\n }\n\n private stopActivityCheck() {\n if (this.activityTimer) {\n this.activityTimer.ensureAborted();\n }\n }\n\n private buildConnectionCallbacks(\n errorCallbacks: ErrorCallbacks\n ): ConnectionCallbacks {\n return Collections.extend({}, errorCallbacks, {\n message: message => {\n // includes pong messages from server\n this.resetActivityCheck();\n this.emit('message', message);\n },\n ping: () => {\n this.send_event('pusher:pong', {});\n },\n activity: () => {\n this.resetActivityCheck();\n },\n error: error => {\n // just emit error to user - socket will already be closed by browser\n this.emit('error', error);\n },\n closed: () => {\n this.abandonConnection();\n if (this.shouldRetry()) {\n this.retryIn(1000);\n }\n }\n });\n }\n\n private buildHandshakeCallbacks(\n errorCallbacks: ErrorCallbacks\n ): HandshakeCallbacks {\n return Collections.extend({}, errorCallbacks, {\n connected: (handshake: HandshakePayload) => {\n this.activityTimeout = Math.min(\n this.options.activityTimeout,\n handshake.activityTimeout,\n handshake.connection.activityTimeout || Infinity\n );\n this.clearUnavailableTimer();\n this.setConnection(handshake.connection);\n this.socket_id = this.connection.id;\n this.updateState('connected', { socket_id: this.socket_id });\n }\n });\n }\n\n private buildErrorCallbacks(): ErrorCallbacks {\n let withErrorEmitted = callback => {\n return (result: Action | HandshakePayload) => {\n if (result.error) {\n this.emit('error', { type: 'WebSocketError', error: result.error });\n }\n callback(result);\n };\n };\n\n return {\n tls_only: withErrorEmitted(() => {\n this.usingTLS = true;\n this.updateStrategy();\n this.retryIn(0);\n }),\n refused: withErrorEmitted(() => {\n this.disconnect();\n }),\n backoff: withErrorEmitted(() => {\n this.retryIn(1000);\n }),\n retry: withErrorEmitted(() => {\n this.retryIn(0);\n })\n };\n }\n\n private setConnection(connection) {\n this.connection = connection;\n for (var event in this.connectionCallbacks) {\n this.connection.bind(event, this.connectionCallbacks[event]);\n }\n this.resetActivityCheck();\n }\n\n private abandonConnection() {\n if (!this.connection) {\n return;\n }\n this.stopActivityCheck();\n for (var event in this.connectionCallbacks) {\n this.connection.unbind(event, this.connectionCallbacks[event]);\n }\n var connection = this.connection;\n this.connection = null;\n return connection;\n }\n\n private updateState(newState: string, data?: any) {\n var previousState = this.state;\n this.state = newState;\n if (previousState !== newState) {\n var newStateDescription = newState;\n if (newStateDescription === 'connected') {\n newStateDescription += ' with new socket ID ' + data.socket_id;\n }\n Logger.debug(\n 'State changed',\n previousState + ' -> ' + newStateDescription\n );\n this.timeline.info({ state: newState, params: data });\n this.emit('state_change', { previous: previousState, current: newState });\n this.emit(newState, data);\n }\n }\n\n private shouldRetry(): boolean {\n return this.state === 'connecting' || this.state === 'connected';\n }\n}\n","import Channel from './channel';\nimport * as Collections from '../utils/collections';\nimport ChannelTable from './channel_table';\nimport Factory from '../utils/factory';\nimport Pusher from '../pusher';\nimport Logger from '../logger';\nimport * as Errors from '../errors';\nimport urlStore from '../utils/url_store';\n\n/** Handles a channel map. */\nexport default class Channels {\n channels: ChannelTable;\n\n constructor() {\n this.channels = {};\n }\n\n /** Creates or retrieves an existing channel by its name.\n *\n * @param {String} name\n * @param {Pusher} pusher\n * @return {Channel}\n */\n add(name: string, pusher: Pusher) {\n if (!this.channels[name]) {\n this.channels[name] = createChannel(name, pusher);\n }\n return this.channels[name];\n }\n\n /** Returns a list of all channels\n *\n * @return {Array}\n */\n all(): Channel[] {\n return Collections.values(this.channels);\n }\n\n /** Finds a channel by its name.\n *\n * @param {String} name\n * @return {Channel} channel or null if it doesn't exist\n */\n find(name: string) {\n return this.channels[name];\n }\n\n /** Removes a channel from the map.\n *\n * @param {String} name\n */\n remove(name: string) {\n var channel = this.channels[name];\n delete this.channels[name];\n return channel;\n }\n\n /** Proxies disconnection signal to all channels. */\n disconnect() {\n Collections.objectApply(this.channels, function(channel) {\n channel.disconnect();\n });\n }\n}\n\nfunction createChannel(name: string, pusher: Pusher): Channel {\n if (name.indexOf('private-encrypted-') === 0) {\n if (pusher.config.nacl) {\n return Factory.createEncryptedChannel(name, pusher, pusher.config.nacl);\n }\n let errMsg =\n 'Tried to subscribe to a private-encrypted- channel but no nacl implementation available';\n let suffix = urlStore.buildLogSuffix('encryptedChannelSupport');\n throw new Errors.UnsupportedFeature(`${errMsg}. ${suffix}`);\n } else if (name.indexOf('private-') === 0) {\n return Factory.createPrivateChannel(name, pusher);\n } else if (name.indexOf('presence-') === 0) {\n return Factory.createPresenceChannel(name, pusher);\n } else if (name.indexOf('#') === 0) {\n throw new Errors.BadChannelName(\n 'Cannot create a channel with name \"' + name + '\".'\n );\n } else {\n return Factory.createChannel(name, pusher);\n }\n}\n","import AssistantToTheTransportManager from '../transports/assistant_to_the_transport_manager';\nimport PingDelayOptions from '../transports/ping_delay_options';\nimport Transport from '../transports/transport';\nimport TransportManager from '../transports/transport_manager';\nimport Handshake from '../connection/handshake';\nimport TransportConnection from '../transports/transport_connection';\nimport SocketHooks from '../http/socket_hooks';\nimport HTTPSocket from '../http/http_socket';\n\nimport Timeline from '../timeline/timeline';\nimport {\n default as TimelineSender,\n TimelineSenderOptions\n} from '../timeline/timeline_sender';\nimport PresenceChannel from '../channels/presence_channel';\nimport PrivateChannel from '../channels/private_channel';\nimport EncryptedChannel from '../channels/encrypted_channel';\nimport Channel from '../channels/channel';\nimport ConnectionManager from '../connection/connection_manager';\nimport ConnectionManagerOptions from '../connection/connection_manager_options';\nimport Ajax from '../http/ajax';\nimport Channels from '../channels/channels';\nimport Pusher from '../pusher';\nimport { Config } from '../config';\nimport * as nacl from 'tweetnacl';\n\nvar Factory = {\n createChannels(): Channels {\n return new Channels();\n },\n\n createConnectionManager(\n key: string,\n options: ConnectionManagerOptions\n ): ConnectionManager {\n return new ConnectionManager(key, options);\n },\n\n createChannel(name: string, pusher: Pusher): Channel {\n return new Channel(name, pusher);\n },\n\n createPrivateChannel(name: string, pusher: Pusher): PrivateChannel {\n return new PrivateChannel(name, pusher);\n },\n\n createPresenceChannel(name: string, pusher: Pusher): PresenceChannel {\n return new PresenceChannel(name, pusher);\n },\n\n createEncryptedChannel(\n name: string,\n pusher: Pusher,\n nacl: nacl\n ): EncryptedChannel {\n return new EncryptedChannel(name, pusher, nacl);\n },\n\n createTimelineSender(timeline: Timeline, options: TimelineSenderOptions) {\n return new TimelineSender(timeline, options);\n },\n\n createHandshake(\n transport: TransportConnection,\n callback: (HandshakePayload) => void\n ): Handshake {\n return new Handshake(transport, callback);\n },\n\n createAssistantToTheTransportManager(\n manager: TransportManager,\n transport: Transport,\n options: PingDelayOptions\n ): AssistantToTheTransportManager {\n return new AssistantToTheTransportManager(manager, transport, options);\n }\n};\n\nexport default Factory;\n","import AssistantToTheTransportManager from './assistant_to_the_transport_manager';\nimport Transport from './transport';\nimport PingDelayOptions from './ping_delay_options';\nimport Factory from '../utils/factory';\n\nexport interface TransportManagerOptions extends PingDelayOptions {\n lives?: number;\n}\n\n/** Keeps track of the number of lives left for a transport.\n *\n * In the beginning of a session, transports may be assigned a number of\n * lives. When an AssistantToTheTransportManager instance reports a transport\n * connection closed uncleanly, the transport loses a life. When the number\n * of lives drops to zero, the transport gets disabled by its manager.\n *\n * @param {Object} options\n */\nexport default class TransportManager {\n options: TransportManagerOptions;\n livesLeft: number;\n\n constructor(options: TransportManagerOptions) {\n this.options = options || {};\n this.livesLeft = this.options.lives || Infinity;\n }\n\n /** Creates a assistant for the transport.\n *\n * @param {Transport} transport\n * @returns {AssistantToTheTransportManager}\n */\n getAssistant(transport: Transport): AssistantToTheTransportManager {\n return Factory.createAssistantToTheTransportManager(this, transport, {\n minPingDelay: this.options.minPingDelay,\n maxPingDelay: this.options.maxPingDelay\n });\n }\n\n /** Returns whether the transport has any lives left.\n *\n * @returns {Boolean}\n */\n isAlive(): boolean {\n return this.livesLeft > 0;\n }\n\n /** Takes one life from the transport. */\n reportDeath() {\n this.livesLeft -= 1;\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport { OneOffTimer as Timer } from '../utils/timers';\nimport Strategy from './strategy';\nimport StrategyOptions from './strategy_options';\n\n/** Loops through strategies with optional timeouts.\n *\n * Options:\n * - loop - whether it should loop through the substrategy list\n * - timeout - initial timeout for a single substrategy\n * - timeoutLimit - maximum timeout\n *\n * @param {Strategy[]} strategies\n * @param {Object} options\n */\nexport default class SequentialStrategy implements Strategy {\n strategies: Strategy[];\n loop: boolean;\n failFast: boolean;\n timeout: number;\n timeoutLimit: number;\n\n constructor(strategies: Strategy[], options: StrategyOptions) {\n this.strategies = strategies;\n this.loop = Boolean(options.loop);\n this.failFast = Boolean(options.failFast);\n this.timeout = options.timeout;\n this.timeoutLimit = options.timeoutLimit;\n }\n\n isSupported(): boolean {\n return Collections.any(this.strategies, Util.method('isSupported'));\n }\n\n connect(minPriority: number, callback: Function) {\n var strategies = this.strategies;\n var current = 0;\n var timeout = this.timeout;\n var runner = null;\n\n var tryNextStrategy = (error, handshake) => {\n if (handshake) {\n callback(null, handshake);\n } else {\n current = current + 1;\n if (this.loop) {\n current = current % strategies.length;\n }\n\n if (current < strategies.length) {\n if (timeout) {\n timeout = timeout * 2;\n if (this.timeoutLimit) {\n timeout = Math.min(timeout, this.timeoutLimit);\n }\n }\n runner = this.tryStrategy(\n strategies[current],\n minPriority,\n { timeout, failFast: this.failFast },\n tryNextStrategy\n );\n } else {\n callback(true);\n }\n }\n };\n\n runner = this.tryStrategy(\n strategies[current],\n minPriority,\n { timeout: timeout, failFast: this.failFast },\n tryNextStrategy\n );\n\n return {\n abort: function() {\n runner.abort();\n },\n forceMinPriority: function(p) {\n minPriority = p;\n if (runner) {\n runner.forceMinPriority(p);\n }\n }\n };\n }\n\n private tryStrategy(\n strategy: Strategy,\n minPriority: number,\n options: StrategyOptions,\n callback: Function\n ) {\n var timer = null;\n var runner = null;\n\n if (options.timeout > 0) {\n timer = new Timer(options.timeout, function() {\n runner.abort();\n callback(true);\n });\n }\n\n runner = strategy.connect(minPriority, function(error, handshake) {\n if (error && timer && timer.isRunning() && !options.failFast) {\n // advance to the next strategy after the timeout\n return;\n }\n if (timer) {\n timer.ensureAborted();\n }\n callback(error, handshake);\n });\n\n return {\n abort: function() {\n if (timer) {\n timer.ensureAborted();\n }\n runner.abort();\n },\n forceMinPriority: function(p) {\n runner.forceMinPriority(p);\n }\n };\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport Strategy from './strategy';\n\n/** Launches all substrategies and emits prioritized connected transports.\n *\n * @param {Array} strategies\n */\nexport default class BestConnectedEverStrategy implements Strategy {\n strategies: Strategy[];\n\n constructor(strategies: Strategy[]) {\n this.strategies = strategies;\n }\n\n isSupported(): boolean {\n return Collections.any(this.strategies, Util.method('isSupported'));\n }\n\n connect(minPriority: number, callback: Function) {\n return connect(this.strategies, minPriority, function(i, runners) {\n return function(error, handshake) {\n runners[i].error = error;\n if (error) {\n if (allRunnersFailed(runners)) {\n callback(true);\n }\n return;\n }\n Collections.apply(runners, function(runner) {\n runner.forceMinPriority(handshake.transport.priority);\n });\n callback(null, handshake);\n };\n });\n }\n}\n\n/** Connects to all strategies in parallel.\n *\n * Callback builder should be a function that takes two arguments: index\n * and a list of runners. It should return another function that will be\n * passed to the substrategy with given index. Runners can be aborted using\n * abortRunner(s) functions from this class.\n *\n * @param {Array} strategies\n * @param {Function} callbackBuilder\n * @return {Object} strategy runner\n */\nfunction connect(\n strategies: Strategy[],\n minPriority: number,\n callbackBuilder: Function\n) {\n var runners = Collections.map(strategies, function(strategy, i, _, rs) {\n return strategy.connect(minPriority, callbackBuilder(i, rs));\n });\n return {\n abort: function() {\n Collections.apply(runners, abortRunner);\n },\n forceMinPriority: function(p) {\n Collections.apply(runners, function(runner) {\n runner.forceMinPriority(p);\n });\n }\n };\n}\n\nfunction allRunnersFailed(runners): boolean {\n return Collections.all(runners, function(runner) {\n return Boolean(runner.error);\n });\n}\n\nfunction abortRunner(runner) {\n if (!runner.error && !runner.aborted) {\n runner.abort();\n runner.aborted = true;\n }\n}\n","import Util from '../util';\nimport Runtime from 'runtime';\nimport Strategy from './strategy';\nimport SequentialStrategy from './sequential_strategy';\nimport StrategyOptions from './strategy_options';\nimport TransportStrategy from './transport_strategy';\nimport Timeline from '../timeline/timeline';\nimport * as Collections from '../utils/collections';\n\nexport interface TransportStrategyDictionary {\n [key: string]: TransportStrategy;\n}\n\n/** Caches the last successful transport and, after the first few attempts,\n * uses the cached transport for subsequent attempts.\n *\n * @param {Strategy} strategy\n * @param {Object} transports\n * @param {Object} options\n */\nexport default class WebSocketPrioritizedCachedStrategy implements Strategy {\n strategy: Strategy;\n transports: TransportStrategyDictionary;\n ttl: number;\n usingTLS: boolean;\n timeline: Timeline;\n\n constructor(\n strategy: Strategy,\n transports: TransportStrategyDictionary,\n options: StrategyOptions\n ) {\n this.strategy = strategy;\n this.transports = transports;\n this.ttl = options.ttl || 1800 * 1000;\n this.usingTLS = options.useTLS;\n this.timeline = options.timeline;\n }\n\n isSupported(): boolean {\n return this.strategy.isSupported();\n }\n\n connect(minPriority: number, callback: Function) {\n var usingTLS = this.usingTLS;\n var info = fetchTransportCache(usingTLS);\n var cacheSkipCount = info && info.cacheSkipCount ? info.cacheSkipCount : 0;\n\n var strategies = [this.strategy];\n if (info && info.timestamp + this.ttl >= Util.now()) {\n var transport = this.transports[info.transport];\n if (transport) {\n if (['ws', 'wss'].includes(info.transport) || cacheSkipCount > 3) {\n this.timeline.info({\n cached: true,\n transport: info.transport,\n latency: info.latency\n });\n strategies.push(\n new SequentialStrategy([transport], {\n timeout: info.latency * 2 + 1000,\n failFast: true\n })\n );\n } else {\n cacheSkipCount++;\n }\n }\n }\n\n var startTimestamp = Util.now();\n var runner = strategies\n .pop()\n .connect(minPriority, function cb(error, handshake) {\n if (error) {\n flushTransportCache(usingTLS);\n if (strategies.length > 0) {\n startTimestamp = Util.now();\n runner = strategies.pop().connect(minPriority, cb);\n } else {\n callback(error);\n }\n } else {\n storeTransportCache(\n usingTLS,\n handshake.transport.name,\n Util.now() - startTimestamp,\n cacheSkipCount\n );\n callback(null, handshake);\n }\n });\n\n return {\n abort: function() {\n runner.abort();\n },\n forceMinPriority: function(p) {\n minPriority = p;\n if (runner) {\n runner.forceMinPriority(p);\n }\n }\n };\n }\n}\n\nfunction getTransportCacheKey(usingTLS: boolean): string {\n return 'pusherTransport' + (usingTLS ? 'TLS' : 'NonTLS');\n}\n\nfunction fetchTransportCache(usingTLS: boolean): any {\n var storage = Runtime.getLocalStorage();\n if (storage) {\n try {\n var serializedCache = storage[getTransportCacheKey(usingTLS)];\n if (serializedCache) {\n return JSON.parse(serializedCache);\n }\n } catch (e) {\n flushTransportCache(usingTLS);\n }\n }\n return null;\n}\n\nfunction storeTransportCache(\n usingTLS: boolean,\n transport: TransportStrategy,\n latency: number,\n cacheSkipCount: number\n) {\n var storage = Runtime.getLocalStorage();\n if (storage) {\n try {\n storage[getTransportCacheKey(usingTLS)] = Collections.safeJSONStringify({\n timestamp: Util.now(),\n transport: transport,\n latency: latency,\n cacheSkipCount: cacheSkipCount\n });\n } catch (e) {\n // catch over quota exceptions raised by localStorage\n }\n }\n}\n\nfunction flushTransportCache(usingTLS: boolean) {\n var storage = Runtime.getLocalStorage();\n if (storage) {\n try {\n delete storage[getTransportCacheKey(usingTLS)];\n } catch (e) {\n // catch exceptions raised by localStorage\n }\n }\n}\n","import { OneOffTimer as Timer } from '../utils/timers';\nimport Strategy from './strategy';\nimport StrategyOptions from './strategy_options';\n\n/** Runs substrategy after specified delay.\n *\n * Options:\n * - delay - time in miliseconds to delay the substrategy attempt\n *\n * @param {Strategy} strategy\n * @param {Object} options\n */\nexport default class DelayedStrategy implements Strategy {\n strategy: Strategy;\n options: { delay: number };\n\n constructor(strategy: Strategy, { delay: number }) {\n this.strategy = strategy;\n this.options = { delay: number };\n }\n\n isSupported(): boolean {\n return this.strategy.isSupported();\n }\n\n connect(minPriority: number, callback: Function) {\n var strategy = this.strategy;\n var runner;\n var timer = new Timer(this.options.delay, function() {\n runner = strategy.connect(minPriority, callback);\n });\n\n return {\n abort: function() {\n timer.ensureAborted();\n if (runner) {\n runner.abort();\n }\n },\n forceMinPriority: function(p) {\n minPriority = p;\n if (runner) {\n runner.forceMinPriority(p);\n }\n }\n };\n }\n}\n","import Strategy from './strategy';\nimport StrategyRunner from './strategy_runner';\n\n/** Proxies method calls to one of substrategies basing on the test function.\n *\n * @param {Function} test\n * @param {Strategy} trueBranch strategy used when test returns true\n * @param {Strategy} falseBranch strategy used when test returns false\n */\nexport default class IfStrategy implements Strategy {\n test: () => boolean;\n trueBranch: Strategy;\n falseBranch: Strategy;\n\n constructor(\n test: () => boolean,\n trueBranch: Strategy,\n falseBranch: Strategy\n ) {\n this.test = test;\n this.trueBranch = trueBranch;\n this.falseBranch = falseBranch;\n }\n\n isSupported(): boolean {\n var branch = this.test() ? this.trueBranch : this.falseBranch;\n return branch.isSupported();\n }\n\n connect(minPriority: number, callback: Function): StrategyRunner {\n var branch = this.test() ? this.trueBranch : this.falseBranch;\n return branch.connect(minPriority, callback);\n }\n}\n","import Strategy from './strategy';\nimport StrategyRunner from './strategy_runner';\n\n/** Launches the substrategy and terminates on the first open connection.\n *\n * @param {Strategy} strategy\n */\nexport default class FirstConnectedStrategy implements Strategy {\n strategy: Strategy;\n\n constructor(strategy: Strategy) {\n this.strategy = strategy;\n }\n\n isSupported(): boolean {\n return this.strategy.isSupported();\n }\n\n connect(minPriority: number, callback: Function): StrategyRunner {\n var runner = this.strategy.connect(minPriority, function(error, handshake) {\n if (handshake) {\n runner.abort();\n }\n callback(error, handshake);\n });\n return runner;\n }\n}\n","import * as Collections from 'core/utils/collections';\nimport TransportManager from 'core/transports/transport_manager';\nimport Strategy from 'core/strategies/strategy';\nimport StrategyOptions from 'core/strategies/strategy_options';\nimport SequentialStrategy from 'core/strategies/sequential_strategy';\nimport BestConnectedEverStrategy from 'core/strategies/best_connected_ever_strategy';\nimport WebSocketPrioritizedCachedStrategy, {\n TransportStrategyDictionary\n} from 'core/strategies/websocket_prioritized_cached_strategy';\nimport DelayedStrategy from 'core/strategies/delayed_strategy';\nimport IfStrategy from 'core/strategies/if_strategy';\nimport FirstConnectedStrategy from 'core/strategies/first_connected_strategy';\nimport { Config } from 'core/config';\n\nfunction testSupportsStrategy(strategy: Strategy) {\n return function() {\n return strategy.isSupported();\n };\n}\n\nvar getDefaultStrategy = function(\n config: Config,\n baseOptions: StrategyOptions,\n defineTransport: Function\n): Strategy {\n var definedTransports = {};\n\n function defineTransportStrategy(\n name: string,\n type: string,\n priority: number,\n options: StrategyOptions,\n manager?: TransportManager\n ) {\n var transport = defineTransport(\n config,\n name,\n type,\n priority,\n options,\n manager\n );\n\n definedTransports[name] = transport;\n\n return transport;\n }\n\n var ws_options: StrategyOptions = Object.assign({}, baseOptions, {\n hostNonTLS: config.wsHost + ':' + config.wsPort,\n hostTLS: config.wsHost + ':' + config.wssPort,\n httpPath: config.wsPath\n });\n var wss_options: StrategyOptions = Object.assign({}, ws_options, {\n useTLS: true\n });\n var sockjs_options: StrategyOptions = Object.assign({}, baseOptions, {\n hostNonTLS: config.httpHost + ':' + config.httpPort,\n hostTLS: config.httpHost + ':' + config.httpsPort,\n httpPath: config.httpPath\n });\n\n var timeouts = {\n loop: true,\n timeout: 15000,\n timeoutLimit: 60000\n };\n\n var ws_manager = new TransportManager({\n minPingDelay: 10000,\n maxPingDelay: config.activityTimeout\n });\n var streaming_manager = new TransportManager({\n lives: 2,\n minPingDelay: 10000,\n maxPingDelay: config.activityTimeout\n });\n\n var ws_transport = defineTransportStrategy(\n 'ws',\n 'ws',\n 3,\n ws_options,\n ws_manager\n );\n var wss_transport = defineTransportStrategy(\n 'wss',\n 'ws',\n 3,\n wss_options,\n ws_manager\n );\n var sockjs_transport = defineTransportStrategy(\n 'sockjs',\n 'sockjs',\n 1,\n sockjs_options\n );\n var xhr_streaming_transport = defineTransportStrategy(\n 'xhr_streaming',\n 'xhr_streaming',\n 1,\n sockjs_options,\n streaming_manager\n );\n var xdr_streaming_transport = defineTransportStrategy(\n 'xdr_streaming',\n 'xdr_streaming',\n 1,\n sockjs_options,\n streaming_manager\n );\n var xhr_polling_transport = defineTransportStrategy(\n 'xhr_polling',\n 'xhr_polling',\n 1,\n sockjs_options\n );\n var xdr_polling_transport = defineTransportStrategy(\n 'xdr_polling',\n 'xdr_polling',\n 1,\n sockjs_options\n );\n\n var ws_loop = new SequentialStrategy([ws_transport], timeouts);\n var wss_loop = new SequentialStrategy([wss_transport], timeouts);\n var sockjs_loop = new SequentialStrategy([sockjs_transport], timeouts);\n var streaming_loop = new SequentialStrategy(\n [\n new IfStrategy(\n testSupportsStrategy(xhr_streaming_transport),\n xhr_streaming_transport,\n xdr_streaming_transport\n )\n ],\n timeouts\n );\n var polling_loop = new SequentialStrategy(\n [\n new IfStrategy(\n testSupportsStrategy(xhr_polling_transport),\n xhr_polling_transport,\n xdr_polling_transport\n )\n ],\n timeouts\n );\n\n var http_loop = new SequentialStrategy(\n [\n new IfStrategy(\n testSupportsStrategy(streaming_loop),\n new BestConnectedEverStrategy([\n streaming_loop,\n new DelayedStrategy(polling_loop, { delay: 4000 })\n ]),\n polling_loop\n )\n ],\n timeouts\n );\n\n var http_fallback_loop = new IfStrategy(\n testSupportsStrategy(http_loop),\n http_loop,\n sockjs_loop\n );\n\n var wsStrategy;\n if (baseOptions.useTLS) {\n wsStrategy = new BestConnectedEverStrategy([\n ws_loop,\n new DelayedStrategy(http_fallback_loop, { delay: 2000 })\n ]);\n } else {\n wsStrategy = new BestConnectedEverStrategy([\n ws_loop,\n new DelayedStrategy(wss_loop, { delay: 2000 }),\n new DelayedStrategy(http_fallback_loop, { delay: 5000 })\n ]);\n }\n\n return new WebSocketPrioritizedCachedStrategy(\n new FirstConnectedStrategy(\n new IfStrategy(\n testSupportsStrategy(ws_transport),\n wsStrategy,\n http_fallback_loop\n )\n ),\n definedTransports,\n {\n ttl: 1800000,\n timeline: baseOptions.timeline,\n useTLS: baseOptions.useTLS\n }\n );\n};\n\nexport default getDefaultStrategy;\n","import { Dependencies } from '../dom/dependencies';\n\n/** Initializes the transport.\n *\n * Fetches resources if needed and then transitions to initialized.\n */\nexport default function() {\n var self = this;\n\n self.timeline.info(\n self.buildTimelineMessage({\n transport: self.name + (self.options.useTLS ? 's' : '')\n })\n );\n\n if (self.hooks.isInitialized()) {\n self.changeState('initialized');\n } else if (self.hooks.file) {\n self.changeState('initializing');\n Dependencies.load(\n self.hooks.file,\n { useTLS: self.options.useTLS },\n function(error, callback) {\n if (self.hooks.isInitialized()) {\n self.changeState('initialized');\n callback(true);\n } else {\n if (error) {\n self.onError(error);\n }\n self.onClose();\n callback(false);\n }\n }\n );\n } else {\n self.onClose();\n }\n}\n","import HTTPRequest from 'core/http/http_request';\nimport RequestHooks from 'core/http/request_hooks';\nimport Ajax from 'core/http/ajax';\nimport * as Errors from 'core/errors';\n\nvar hooks: RequestHooks = {\n getRequest: function(socket: HTTPRequest): Ajax {\n var xdr = new (window).XDomainRequest();\n xdr.ontimeout = function() {\n socket.emit('error', new Errors.RequestTimedOut());\n socket.close();\n };\n xdr.onerror = function(e) {\n socket.emit('error', e);\n socket.close();\n };\n xdr.onprogress = function() {\n if (xdr.responseText && xdr.responseText.length > 0) {\n socket.onChunk(200, xdr.responseText);\n }\n };\n xdr.onload = function() {\n if (xdr.responseText && xdr.responseText.length > 0) {\n socket.onChunk(200, xdr.responseText);\n }\n socket.emit('finished', 200);\n socket.close();\n };\n return xdr;\n },\n abortRequest: function(xdr: Ajax) {\n xdr.ontimeout = xdr.onerror = xdr.onprogress = xdr.onload = null;\n xdr.abort();\n }\n};\n\nexport default hooks;\n","import Runtime from 'runtime';\nimport RequestHooks from './request_hooks';\nimport Ajax from './ajax';\nimport { default as EventsDispatcher } from '../events/dispatcher';\n\nconst MAX_BUFFER_LENGTH = 256 * 1024;\n\nexport default class HTTPRequest extends EventsDispatcher {\n hooks: RequestHooks;\n method: string;\n url: string;\n position: number;\n xhr: Ajax;\n unloader: Function;\n\n constructor(hooks: RequestHooks, method: string, url: string) {\n super();\n this.hooks = hooks;\n this.method = method;\n this.url = url;\n }\n\n start(payload?: any) {\n this.position = 0;\n this.xhr = this.hooks.getRequest(this);\n\n this.unloader = () => {\n this.close();\n };\n Runtime.addUnloadListener(this.unloader);\n\n this.xhr.open(this.method, this.url, true);\n\n if (this.xhr.setRequestHeader) {\n this.xhr.setRequestHeader('Content-Type', 'application/json'); // ReactNative doesn't set this header by default.\n }\n this.xhr.send(payload);\n }\n\n close() {\n if (this.unloader) {\n Runtime.removeUnloadListener(this.unloader);\n this.unloader = null;\n }\n if (this.xhr) {\n this.hooks.abortRequest(this.xhr);\n this.xhr = null;\n }\n }\n\n onChunk(status: number, data: any) {\n while (true) {\n var chunk = this.advanceBuffer(data);\n if (chunk) {\n this.emit('chunk', { status: status, data: chunk });\n } else {\n break;\n }\n }\n if (this.isBufferTooLong(data)) {\n this.emit('buffer_too_long');\n }\n }\n\n private advanceBuffer(buffer: any[]): any {\n var unreadData = buffer.slice(this.position);\n var endOfLinePosition = unreadData.indexOf('\\n');\n\n if (endOfLinePosition !== -1) {\n this.position += endOfLinePosition + 1;\n return unreadData.slice(0, endOfLinePosition);\n } else {\n // chunk is not finished yet, don't move the buffer pointer\n return null;\n }\n }\n\n private isBufferTooLong(buffer: any): boolean {\n return this.position === buffer.length && buffer.length > MAX_BUFFER_LENGTH;\n }\n}\n","enum State {\n CONNECTING = 0,\n OPEN = 1,\n CLOSED = 3\n}\n\nexport default State;\n","import URLLocation from './url_location';\nimport State from './state';\nimport Socket from '../socket';\nimport SocketHooks from './socket_hooks';\nimport Util from '../util';\nimport Ajax from './ajax';\nimport HTTPRequest from './http_request';\nimport Runtime from 'runtime';\n\nvar autoIncrement = 1;\n\nclass HTTPSocket implements Socket {\n hooks: SocketHooks;\n session: string;\n location: URLLocation;\n readyState: State;\n stream: HTTPRequest;\n\n onopen: () => void;\n onerror: (error: any) => void;\n onclose: (closeEvent: any) => void;\n onmessage: (message: any) => void;\n onactivity: () => void;\n\n constructor(hooks: SocketHooks, url: string) {\n this.hooks = hooks;\n this.session = randomNumber(1000) + '/' + randomString(8);\n this.location = getLocation(url);\n this.readyState = State.CONNECTING;\n this.openStream();\n }\n\n send(payload: any) {\n return this.sendRaw(JSON.stringify([payload]));\n }\n\n ping() {\n this.hooks.sendHeartbeat(this);\n }\n\n close(code: any, reason: any) {\n this.onClose(code, reason, true);\n }\n\n /** For internal use only */\n sendRaw(payload: any): boolean {\n if (this.readyState === State.OPEN) {\n try {\n Runtime.createSocketRequest(\n 'POST',\n getUniqueURL(getSendURL(this.location, this.session))\n ).start(payload);\n return true;\n } catch (e) {\n return false;\n }\n } else {\n return false;\n }\n }\n\n /** For internal use only */\n reconnect() {\n this.closeStream();\n this.openStream();\n }\n\n /** For internal use only */\n onClose(code, reason, wasClean) {\n this.closeStream();\n this.readyState = State.CLOSED;\n if (this.onclose) {\n this.onclose({\n code: code,\n reason: reason,\n wasClean: wasClean\n });\n }\n }\n\n private onChunk(chunk) {\n if (chunk.status !== 200) {\n return;\n }\n if (this.readyState === State.OPEN) {\n this.onActivity();\n }\n\n var payload;\n var type = chunk.data.slice(0, 1);\n switch (type) {\n case 'o':\n payload = JSON.parse(chunk.data.slice(1) || '{}');\n this.onOpen(payload);\n break;\n case 'a':\n payload = JSON.parse(chunk.data.slice(1) || '[]');\n for (var i = 0; i < payload.length; i++) {\n this.onEvent(payload[i]);\n }\n break;\n case 'm':\n payload = JSON.parse(chunk.data.slice(1) || 'null');\n this.onEvent(payload);\n break;\n case 'h':\n this.hooks.onHeartbeat(this);\n break;\n case 'c':\n payload = JSON.parse(chunk.data.slice(1) || '[]');\n this.onClose(payload[0], payload[1], true);\n break;\n }\n }\n\n private onOpen(options) {\n if (this.readyState === State.CONNECTING) {\n if (options && options.hostname) {\n this.location.base = replaceHost(this.location.base, options.hostname);\n }\n this.readyState = State.OPEN;\n\n if (this.onopen) {\n this.onopen();\n }\n } else {\n this.onClose(1006, 'Server lost session', true);\n }\n }\n\n private onEvent(event) {\n if (this.readyState === State.OPEN && this.onmessage) {\n this.onmessage({ data: event });\n }\n }\n\n private onActivity() {\n if (this.onactivity) {\n this.onactivity();\n }\n }\n\n private onError(error) {\n if (this.onerror) {\n this.onerror(error);\n }\n }\n\n private openStream() {\n this.stream = Runtime.createSocketRequest(\n 'POST',\n getUniqueURL(this.hooks.getReceiveURL(this.location, this.session))\n );\n\n this.stream.bind('chunk', chunk => {\n this.onChunk(chunk);\n });\n this.stream.bind('finished', status => {\n this.hooks.onFinished(this, status);\n });\n this.stream.bind('buffer_too_long', () => {\n this.reconnect();\n });\n\n try {\n this.stream.start();\n } catch (error) {\n Util.defer(() => {\n this.onError(error);\n this.onClose(1006, 'Could not start streaming', false);\n });\n }\n }\n\n private closeStream() {\n if (this.stream) {\n this.stream.unbind_all();\n this.stream.close();\n this.stream = null;\n }\n }\n}\n\nfunction getLocation(url): URLLocation {\n var parts = /([^\\?]*)\\/*(\\??.*)/.exec(url);\n return {\n base: parts[1],\n queryString: parts[2]\n };\n}\n\nfunction getSendURL(url: URLLocation, session: string): string {\n return url.base + '/' + session + '/xhr_send';\n}\n\nfunction getUniqueURL(url: string): string {\n var separator = url.indexOf('?') === -1 ? '?' : '&';\n return url + separator + 't=' + +new Date() + '&n=' + autoIncrement++;\n}\n\nfunction replaceHost(url: string, hostname: string): string {\n var urlParts = /(https?:\\/\\/)([^\\/:]+)((\\/|:)?.*)/.exec(url);\n return urlParts[1] + hostname + urlParts[3];\n}\n\nfunction randomNumber(max: number): number {\n return Runtime.randomInt(max);\n}\n\nfunction randomString(length: number): string {\n var result = [];\n\n for (var i = 0; i < length; i++) {\n result.push(randomNumber(32).toString(32));\n }\n\n return result.join('');\n}\n\nexport default HTTPSocket;\n","import SocketHooks from './socket_hooks';\nimport HTTPSocket from './http_socket';\n\nvar hooks: SocketHooks = {\n getReceiveURL: function(url, session) {\n return url.base + '/' + session + '/xhr_streaming' + url.queryString;\n },\n onHeartbeat: function(socket) {\n socket.sendRaw('[]');\n },\n sendHeartbeat: function(socket) {\n socket.sendRaw('[]');\n },\n onFinished: function(socket, status) {\n socket.onClose(1006, 'Connection interrupted (' + status + ')', false);\n }\n};\n\nexport default hooks;\n","import SocketHooks from './socket_hooks';\nimport URLLocation from './url_location';\nimport HTTPSocket from './http_socket';\n\nvar hooks: SocketHooks = {\n getReceiveURL: function(url: URLLocation, session: string): string {\n return url.base + '/' + session + '/xhr' + url.queryString;\n },\n onHeartbeat: function() {\n // next HTTP request will reset server's activity timer\n },\n sendHeartbeat: function(socket) {\n socket.sendRaw('[]');\n },\n onFinished: function(socket, status) {\n if (status === 200) {\n socket.reconnect();\n } else {\n socket.onClose(1006, 'Connection interrupted (' + status + ')', false);\n }\n }\n};\n\nexport default hooks;\n","import HTTPRequest from 'core/http/http_request';\nimport RequestHooks from 'core/http/request_hooks';\nimport Ajax from 'core/http/ajax';\nimport Runtime from 'runtime';\n\nvar hooks: RequestHooks = {\n getRequest: function(socket: HTTPRequest): Ajax {\n var Constructor = Runtime.getXHRAPI();\n var xhr = new Constructor();\n xhr.onreadystatechange = xhr.onprogress = function() {\n switch (xhr.readyState) {\n case 3:\n if (xhr.responseText && xhr.responseText.length > 0) {\n socket.onChunk(xhr.status, xhr.responseText);\n }\n break;\n case 4:\n // this happens only on errors, never after calling close\n if (xhr.responseText && xhr.responseText.length > 0) {\n socket.onChunk(xhr.status, xhr.responseText);\n }\n socket.emit('finished', xhr.status);\n socket.close();\n break;\n }\n };\n return xhr;\n },\n abortRequest: function(xhr: Ajax) {\n xhr.onreadystatechange = null;\n xhr.abort();\n }\n};\n\nexport default hooks;\n","import HTTPRequest from 'core/http/http_request';\nimport HTTPSocket from 'core/http/http_socket';\nimport SocketHooks from 'core/http/socket_hooks';\nimport RequestHooks from 'core/http/request_hooks';\nimport streamingHooks from 'core/http/http_streaming_socket';\nimport pollingHooks from 'core/http/http_polling_socket';\nimport xhrHooks from './http_xhr_request';\nimport HTTPFactory from 'core/http/http_factory';\n\nvar HTTP: HTTPFactory = {\n createStreamingSocket(url: string): HTTPSocket {\n return this.createSocket(streamingHooks, url);\n },\n\n createPollingSocket(url: string): HTTPSocket {\n return this.createSocket(pollingHooks, url);\n },\n\n createSocket(hooks: SocketHooks, url: string): HTTPSocket {\n return new HTTPSocket(hooks, url);\n },\n\n createXHR(method: string, url: string): HTTPRequest {\n return this.createRequest(xhrHooks, method, url);\n },\n\n createRequest(hooks: RequestHooks, method: string, url: string): HTTPRequest {\n return new HTTPRequest(hooks, method, url);\n }\n};\n\nexport default HTTP;\n","import xdrHooks from './http_xdomain_request';\nimport HTTP from 'isomorphic/http/http';\n\nHTTP.createXDR = function(method, url) {\n return this.createRequest(xdrHooks, method, url);\n};\n\nexport default HTTP;\n","import Browser from './browser';\nimport { Dependencies, DependenciesReceivers } from './dom/dependencies';\nimport { AuthTransport, AuthTransports } from 'core/auth/auth_transports';\nimport xhrAuth from 'isomorphic/auth/xhr_auth';\nimport jsonpAuth from './auth/jsonp_auth';\nimport TimelineTransport from 'core/timeline/timeline_transport';\nimport TimelineSender from 'core/timeline/timeline_sender';\nimport ScriptRequest from './dom/script_request';\nimport JSONPRequest from './dom/jsonp_request';\nimport * as Collections from 'core/utils/collections';\nimport { ScriptReceivers } from './dom/script_receiver_factory';\nimport jsonpTimeline from './timeline/jsonp_timeline';\nimport Transports from './transports/transports';\nimport Ajax from 'core/http/ajax';\nimport { Network } from './net_info';\nimport getDefaultStrategy from './default_strategy';\nimport transportConnectionInitializer from './transports/transport_connection_initializer';\nimport HTTPFactory from './http/http';\nimport HTTPRequest from 'core/http/http_request';\n\nvar Runtime: Browser = {\n // for jsonp auth\n nextAuthCallbackID: 1,\n auth_callbacks: {},\n ScriptReceivers,\n DependenciesReceivers,\n getDefaultStrategy,\n Transports,\n transportConnectionInitializer,\n HTTPFactory,\n\n TimelineTransport: jsonpTimeline,\n\n getXHRAPI() {\n return window.XMLHttpRequest;\n },\n\n getWebSocketAPI() {\n return window.WebSocket || window.MozWebSocket;\n },\n\n setup(PusherClass): void {\n (window).Pusher = PusherClass; // JSONp requires Pusher to be in the global scope.\n var initializeOnDocumentBody = () => {\n this.onDocumentBody(PusherClass.ready);\n };\n if (!(window).JSON) {\n Dependencies.load('json2', {}, initializeOnDocumentBody);\n } else {\n initializeOnDocumentBody();\n }\n },\n\n getDocument(): Document {\n return document;\n },\n\n getProtocol(): string {\n return this.getDocument().location.protocol;\n },\n\n getAuthorizers(): AuthTransports {\n return { ajax: xhrAuth, jsonp: jsonpAuth };\n },\n\n onDocumentBody(callback: Function) {\n if (document.body) {\n callback();\n } else {\n setTimeout(() => {\n this.onDocumentBody(callback);\n }, 0);\n }\n },\n\n createJSONPRequest(url: string, data: any): JSONPRequest {\n return new JSONPRequest(url, data);\n },\n\n createScriptRequest(src: string): ScriptRequest {\n return new ScriptRequest(src);\n },\n\n getLocalStorage() {\n try {\n return window.localStorage;\n } catch (e) {\n return undefined;\n }\n },\n\n createXHR(): Ajax {\n if (this.getXHRAPI()) {\n return this.createXMLHttpRequest();\n } else {\n return this.createMicrosoftXHR();\n }\n },\n\n createXMLHttpRequest(): Ajax {\n var Constructor = this.getXHRAPI();\n return new Constructor();\n },\n\n createMicrosoftXHR(): Ajax {\n return new ActiveXObject('Microsoft.XMLHTTP');\n },\n\n getNetwork() {\n return Network;\n },\n\n createWebSocket(url: string): any {\n var Constructor = this.getWebSocketAPI();\n return new Constructor(url);\n },\n\n createSocketRequest(method: string, url: string): HTTPRequest {\n if (this.isXHRSupported()) {\n return this.HTTPFactory.createXHR(method, url);\n } else if (this.isXDRSupported(url.indexOf('https:') === 0)) {\n return this.HTTPFactory.createXDR(method, url);\n } else {\n throw 'Cross-origin HTTP requests are not supported';\n }\n },\n\n isXHRSupported(): boolean {\n var Constructor = this.getXHRAPI();\n return (\n Boolean(Constructor) && new Constructor().withCredentials !== undefined\n );\n },\n\n isXDRSupported(useTLS?: boolean): boolean {\n var protocol = useTLS ? 'https:' : 'http:';\n var documentProtocol = this.getProtocol();\n return (\n Boolean(window['XDomainRequest']) && documentProtocol === protocol\n );\n },\n\n addUnloadListener(listener: any) {\n if (window.addEventListener !== undefined) {\n window.addEventListener('unload', listener, false);\n } else if (window.attachEvent !== undefined) {\n window.attachEvent('onunload', listener);\n }\n },\n\n removeUnloadListener(listener: any) {\n if (window.addEventListener !== undefined) {\n window.removeEventListener('unload', listener, false);\n } else if (window.detachEvent !== undefined) {\n window.detachEvent('onunload', listener);\n }\n },\n\n randomInt(max: number): number {\n /**\n * Return values in the range of [0, 1[\n */\n const random = function() {\n const crypto = window.crypto || window['msCrypto'];\n const random = crypto.getRandomValues(new Uint32Array(1))[0];\n\n return random / 2 ** 32;\n };\n\n return Math.floor(random() * max);\n }\n};\n\nexport default Runtime;\n","enum TimelineLevel {\n ERROR = 3,\n INFO = 6,\n DEBUG = 7\n}\n\nexport default TimelineLevel;\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport { default as Level } from './level';\n\nexport interface TimelineOptions {\n level?: Level;\n limit?: number;\n version?: string;\n cluster?: string;\n features?: string[];\n params?: any;\n}\n\nexport default class Timeline {\n key: string;\n session: number;\n events: any[];\n options: TimelineOptions;\n sent: number;\n uniqueID: number;\n\n constructor(key: string, session: number, options: TimelineOptions) {\n this.key = key;\n this.session = session;\n this.events = [];\n this.options = options || {};\n this.sent = 0;\n this.uniqueID = 0;\n }\n\n log(level, event) {\n if (level <= this.options.level) {\n this.events.push(\n Collections.extend({}, event, { timestamp: Util.now() })\n );\n if (this.options.limit && this.events.length > this.options.limit) {\n this.events.shift();\n }\n }\n }\n\n error(event) {\n this.log(Level.ERROR, event);\n }\n\n info(event) {\n this.log(Level.INFO, event);\n }\n\n debug(event) {\n this.log(Level.DEBUG, event);\n }\n\n isEmpty() {\n return this.events.length === 0;\n }\n\n send(sendfn, callback) {\n var data = Collections.extend(\n {\n session: this.session,\n bundle: this.sent + 1,\n key: this.key,\n lib: 'js',\n version: this.options.version,\n cluster: this.options.cluster,\n features: this.options.features,\n timeline: this.events\n },\n this.options.params\n );\n\n this.events = [];\n sendfn(data, (error, result) => {\n if (!error) {\n this.sent++;\n }\n if (callback) {\n callback(error, result);\n }\n });\n\n return true;\n }\n\n generateUniqueID(): number {\n this.uniqueID++;\n return this.uniqueID;\n }\n}\n","import Factory from '../utils/factory';\nimport Util from '../util';\nimport * as Errors from '../errors';\nimport * as Collections from '../utils/collections';\nimport Strategy from './strategy';\nimport Transport from '../transports/transport';\nimport StrategyOptions from './strategy_options';\nimport Handshake from '../connection/handshake';\n\n/** Provides a strategy interface for transports.\n *\n * @param {String} name\n * @param {Number} priority\n * @param {Class} transport\n * @param {Object} options\n */\nexport default class TransportStrategy implements Strategy {\n name: string;\n priority: number;\n transport: Transport;\n options: StrategyOptions;\n\n constructor(\n name: string,\n priority: number,\n transport: Transport,\n options: StrategyOptions\n ) {\n this.name = name;\n this.priority = priority;\n this.transport = transport;\n this.options = options || {};\n }\n\n /** Returns whether the transport is supported in the browser.\n *\n * @returns {Boolean}\n */\n isSupported(): boolean {\n return this.transport.isSupported({\n useTLS: this.options.useTLS\n });\n }\n\n /** Launches a connection attempt and returns a strategy runner.\n *\n * @param {Function} callback\n * @return {Object} strategy runner\n */\n connect(minPriority: number, callback: Function) {\n if (!this.isSupported()) {\n return failAttempt(new Errors.UnsupportedStrategy(), callback);\n } else if (this.priority < minPriority) {\n return failAttempt(new Errors.TransportPriorityTooLow(), callback);\n }\n\n var connected = false;\n var transport = this.transport.createConnection(\n this.name,\n this.priority,\n this.options.key,\n this.options\n );\n var handshake = null;\n\n var onInitialized = function() {\n transport.unbind('initialized', onInitialized);\n transport.connect();\n };\n var onOpen = function() {\n handshake = Factory.createHandshake(transport, function(result) {\n connected = true;\n unbindListeners();\n callback(null, result);\n });\n };\n var onError = function(error) {\n unbindListeners();\n callback(error);\n };\n var onClosed = function() {\n unbindListeners();\n var serializedTransport;\n\n // The reason for this try/catch block is that on React Native\n // the WebSocket object is circular. Therefore transport.socket will\n // throw errors upon stringification. Collections.safeJSONStringify\n // discards circular references when serializing.\n serializedTransport = Collections.safeJSONStringify(transport);\n callback(new Errors.TransportClosed(serializedTransport));\n };\n\n var unbindListeners = function() {\n transport.unbind('initialized', onInitialized);\n transport.unbind('open', onOpen);\n transport.unbind('error', onError);\n transport.unbind('closed', onClosed);\n };\n\n transport.bind('initialized', onInitialized);\n transport.bind('open', onOpen);\n transport.bind('error', onError);\n transport.bind('closed', onClosed);\n\n // connect will be called automatically after initialization\n transport.initialize();\n\n return {\n abort: () => {\n if (connected) {\n return;\n }\n unbindListeners();\n if (handshake) {\n handshake.close();\n } else {\n transport.close();\n }\n },\n forceMinPriority: p => {\n if (connected) {\n return;\n }\n if (this.priority < p) {\n if (handshake) {\n handshake.close();\n } else {\n transport.close();\n }\n }\n }\n };\n }\n}\n\nfunction failAttempt(error: Error, callback: Function) {\n Util.defer(function() {\n callback(error);\n });\n return {\n abort: function() {},\n forceMinPriority: function() {}\n };\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport TransportManager from '../transports/transport_manager';\nimport * as Errors from '../errors';\nimport Strategy from './strategy';\nimport TransportStrategy from './transport_strategy';\nimport StrategyOptions from '../strategies/strategy_options';\nimport { Config } from '../config';\nimport Runtime from 'runtime';\n\nconst { Transports } = Runtime;\n\nexport var defineTransport = function(\n config: Config,\n name: string,\n type: string,\n priority: number,\n options: StrategyOptions,\n manager?: TransportManager\n): Strategy {\n var transportClass = Transports[type];\n if (!transportClass) {\n throw new Errors.UnsupportedTransport(type);\n }\n\n var enabled =\n (!config.enabledTransports ||\n Collections.arrayIndexOf(config.enabledTransports, name) !== -1) &&\n (!config.disabledTransports ||\n Collections.arrayIndexOf(config.disabledTransports, name) === -1);\n\n var transport;\n if (enabled) {\n options = Object.assign(\n { ignoreNullOrigin: config.ignoreNullOrigin },\n options\n );\n\n transport = new TransportStrategy(\n name,\n priority,\n manager ? manager.getAssistant(transportClass) : transportClass,\n options\n );\n } else {\n transport = UnsupportedStrategy;\n }\n\n return transport;\n};\n\nvar UnsupportedStrategy: Strategy = {\n isSupported: function() {\n return false;\n },\n connect: function(_, callback) {\n var deferred = Util.defer(function() {\n callback(new Errors.UnsupportedStrategy());\n });\n return {\n abort: function() {\n deferred.ensureAborted();\n },\n forceMinPriority: function() {}\n };\n }\n};\n","import ConnectionManager from './connection/connection_manager';\nimport {\n ChannelAuthorizationOptions,\n UserAuthenticationOptions\n} from './auth/options';\nimport {\n ChannelAuthorizerGenerator,\n DeprecatedAuthOptions\n} from './auth/deprecated_channel_authorizer';\nimport { AuthTransport, Transport } from './config';\nimport * as nacl from 'tweetnacl';\nimport Logger from './logger';\n\nexport interface Options {\n activityTimeout?: number;\n\n auth?: DeprecatedAuthOptions; // DEPRECATED use channelAuthorization instead\n authEndpoint?: string; // DEPRECATED use channelAuthorization instead\n authTransport?: AuthTransport; // DEPRECATED use channelAuthorization instead\n authorizer?: ChannelAuthorizerGenerator; // DEPRECATED use channelAuthorization instead\n\n channelAuthorization?: ChannelAuthorizationOptions;\n userAuthentication?: UserAuthenticationOptions;\n\n cluster: string;\n enableStats?: boolean;\n disableStats?: boolean;\n disabledTransports?: Transport[];\n enabledTransports?: Transport[];\n forceTLS?: boolean;\n httpHost?: string;\n httpPath?: string;\n httpPort?: number;\n httpsPort?: number;\n ignoreNullOrigin?: boolean;\n nacl?: nacl;\n pongTimeout?: number;\n statsHost?: string;\n timelineParams?: any;\n unavailableTimeout?: number;\n wsHost?: string;\n wsPath?: string;\n wsPort?: number;\n wssPort?: number;\n}\n\nexport function validateOptions(options) {\n if (options == null) {\n throw 'You must pass an options object';\n }\n if (options.cluster == null) {\n throw 'Options object must provide a cluster';\n }\n if ('disableStats' in options) {\n Logger.warn(\n 'The disableStats option is deprecated in favor of enableStats'\n );\n }\n}\n","import {\n UserAuthenticationCallback,\n InternalAuthOptions,\n UserAuthenticationHandler,\n UserAuthenticationRequestParams,\n AuthRequestType\n} from './options';\n\nimport Runtime from 'runtime';\n\nconst composeChannelQuery = (\n params: UserAuthenticationRequestParams,\n authOptions: InternalAuthOptions\n) => {\n var query = 'socket_id=' + encodeURIComponent(params.socketId);\n\n for (var key in authOptions.params) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(authOptions.params[key]);\n }\n\n if (authOptions.paramsProvider != null) {\n let dynamicParams = authOptions.paramsProvider();\n for (var key in dynamicParams) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(dynamicParams[key]);\n }\n }\n\n return query;\n};\n\nconst UserAuthenticator = (\n authOptions: InternalAuthOptions\n): UserAuthenticationHandler => {\n if (typeof Runtime.getAuthorizers()[authOptions.transport] === 'undefined') {\n throw `'${authOptions.transport}' is not a recognized auth transport`;\n }\n\n return (\n params: UserAuthenticationRequestParams,\n callback: UserAuthenticationCallback\n ) => {\n const query = composeChannelQuery(params, authOptions);\n\n Runtime.getAuthorizers()[authOptions.transport](\n Runtime,\n query,\n authOptions,\n AuthRequestType.UserAuthentication,\n callback\n );\n };\n};\n\nexport default UserAuthenticator;\n","import {\n AuthRequestType,\n InternalAuthOptions,\n ChannelAuthorizationHandler,\n ChannelAuthorizationRequestParams,\n ChannelAuthorizationCallback\n} from './options';\n\nimport Runtime from 'runtime';\n\nconst composeChannelQuery = (\n params: ChannelAuthorizationRequestParams,\n authOptions: InternalAuthOptions\n) => {\n var query = 'socket_id=' + encodeURIComponent(params.socketId);\n\n query += '&channel_name=' + encodeURIComponent(params.channelName);\n\n for (var key in authOptions.params) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(authOptions.params[key]);\n }\n\n if (authOptions.paramsProvider != null) {\n let dynamicParams = authOptions.paramsProvider();\n for (var key in dynamicParams) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(dynamicParams[key]);\n }\n }\n\n return query;\n};\n\nconst ChannelAuthorizer = (\n authOptions: InternalAuthOptions\n): ChannelAuthorizationHandler => {\n if (typeof Runtime.getAuthorizers()[authOptions.transport] === 'undefined') {\n throw `'${authOptions.transport}' is not a recognized auth transport`;\n }\n\n return (\n params: ChannelAuthorizationRequestParams,\n callback: ChannelAuthorizationCallback\n ) => {\n const query = composeChannelQuery(params, authOptions);\n\n Runtime.getAuthorizers()[authOptions.transport](\n Runtime,\n query,\n authOptions,\n AuthRequestType.ChannelAuthorization,\n callback\n );\n };\n};\n\nexport default ChannelAuthorizer;\n","import Channel from '../channels/channel';\nimport {\n ChannelAuthorizationCallback,\n ChannelAuthorizationHandler,\n ChannelAuthorizationRequestParams,\n InternalAuthOptions\n} from './options';\n\nexport interface DeprecatedChannelAuthorizer {\n authorize(socketId: string, callback: ChannelAuthorizationCallback): void;\n}\n\nexport interface ChannelAuthorizerGenerator {\n (\n channel: Channel,\n options: DeprecatedAuthorizerOptions\n ): DeprecatedChannelAuthorizer;\n}\n\nexport interface DeprecatedAuthOptions {\n params?: any;\n headers?: any;\n}\n\nexport interface DeprecatedAuthorizerOptions {\n authTransport: 'ajax' | 'jsonp';\n authEndpoint: string;\n auth?: DeprecatedAuthOptions;\n}\n\nexport const ChannelAuthorizerProxy = (\n pusher,\n authOptions: InternalAuthOptions,\n channelAuthorizerGenerator: ChannelAuthorizerGenerator\n): ChannelAuthorizationHandler => {\n const deprecatedAuthorizerOptions: DeprecatedAuthorizerOptions = {\n authTransport: authOptions.transport,\n authEndpoint: authOptions.endpoint,\n auth: {\n params: authOptions.params,\n headers: authOptions.headers\n }\n };\n return (\n params: ChannelAuthorizationRequestParams,\n callback: ChannelAuthorizationCallback\n ) => {\n const channel = pusher.channel(params.channelName);\n // This line creates a new channel authorizer every time.\n // In the past, this was only done once per channel and reused.\n // We can do that again if we want to keep this behavior intact.\n const channelAuthorizer: DeprecatedChannelAuthorizer = channelAuthorizerGenerator(\n channel,\n deprecatedAuthorizerOptions\n );\n channelAuthorizer.authorize(params.socketId, callback);\n };\n};\n","import { Options } from './options';\nimport Defaults from './defaults';\nimport {\n ChannelAuthorizationHandler,\n UserAuthenticationHandler,\n ChannelAuthorizationOptions\n} from './auth/options';\nimport UserAuthenticator from './auth/user_authenticator';\nimport ChannelAuthorizer from './auth/channel_authorizer';\nimport { ChannelAuthorizerProxy } from './auth/deprecated_channel_authorizer';\nimport Runtime from 'runtime';\nimport * as nacl from 'tweetnacl';\n\nexport type AuthTransport = 'ajax' | 'jsonp';\nexport type Transport =\n | 'ws'\n | 'wss'\n | 'xhr_streaming'\n | 'xhr_polling'\n | 'sockjs';\n\nexport interface Config {\n // these are all 'required' config parameters, it's not necessary for the user\n // to set them, but they have configured defaults.\n activityTimeout: number;\n enableStats: boolean;\n httpHost: string;\n httpPath: string;\n httpPort: number;\n httpsPort: number;\n pongTimeout: number;\n statsHost: string;\n unavailableTimeout: number;\n useTLS: boolean;\n wsHost: string;\n wsPath: string;\n wsPort: number;\n wssPort: number;\n userAuthenticator: UserAuthenticationHandler;\n channelAuthorizer: ChannelAuthorizationHandler;\n\n // these are all optional parameters or overrrides. The customer can set these\n // but it's not strictly necessary\n forceTLS?: boolean;\n cluster?: string;\n disabledTransports?: Transport[];\n enabledTransports?: Transport[];\n ignoreNullOrigin?: boolean;\n nacl?: nacl;\n timelineParams?: any;\n}\n\n// getConfig mainly sets the defaults for the options that are not provided\nexport function getConfig(opts: Options, pusher): Config {\n let config: Config = {\n activityTimeout: opts.activityTimeout || Defaults.activityTimeout,\n cluster: opts.cluster,\n httpPath: opts.httpPath || Defaults.httpPath,\n httpPort: opts.httpPort || Defaults.httpPort,\n httpsPort: opts.httpsPort || Defaults.httpsPort,\n pongTimeout: opts.pongTimeout || Defaults.pongTimeout,\n statsHost: opts.statsHost || Defaults.stats_host,\n unavailableTimeout: opts.unavailableTimeout || Defaults.unavailableTimeout,\n wsPath: opts.wsPath || Defaults.wsPath,\n wsPort: opts.wsPort || Defaults.wsPort,\n wssPort: opts.wssPort || Defaults.wssPort,\n\n enableStats: getEnableStatsConfig(opts),\n httpHost: getHttpHost(opts),\n useTLS: shouldUseTLS(opts),\n wsHost: getWebsocketHost(opts),\n\n userAuthenticator: buildUserAuthenticator(opts),\n channelAuthorizer: buildChannelAuthorizer(opts, pusher)\n };\n\n if ('disabledTransports' in opts)\n config.disabledTransports = opts.disabledTransports;\n if ('enabledTransports' in opts)\n config.enabledTransports = opts.enabledTransports;\n if ('ignoreNullOrigin' in opts)\n config.ignoreNullOrigin = opts.ignoreNullOrigin;\n if ('timelineParams' in opts) config.timelineParams = opts.timelineParams;\n if ('nacl' in opts) {\n config.nacl = opts.nacl;\n }\n\n return config;\n}\n\nfunction getHttpHost(opts: Options): string {\n if (opts.httpHost) {\n return opts.httpHost;\n }\n if (opts.cluster) {\n return `sockjs-${opts.cluster}.pusher.com`;\n }\n return Defaults.httpHost;\n}\n\nfunction getWebsocketHost(opts: Options): string {\n if (opts.wsHost) {\n return opts.wsHost;\n }\n return getWebsocketHostFromCluster(opts.cluster);\n}\n\nfunction getWebsocketHostFromCluster(cluster: string): string {\n return `ws-${cluster}.pusher.com`;\n}\n\nfunction shouldUseTLS(opts: Options): boolean {\n if (Runtime.getProtocol() === 'https:') {\n return true;\n } else if (opts.forceTLS === false) {\n return false;\n }\n return true;\n}\n\n// if enableStats is set take the value\n// if disableStats is set take the inverse\n// otherwise default to false\nfunction getEnableStatsConfig(opts: Options): boolean {\n if ('enableStats' in opts) {\n return opts.enableStats;\n }\n if ('disableStats' in opts) {\n return !opts.disableStats;\n }\n return false;\n}\n\nfunction buildUserAuthenticator(opts: Options): UserAuthenticationHandler {\n const userAuthentication = {\n ...Defaults.userAuthentication,\n ...opts.userAuthentication\n };\n if (\n 'customHandler' in userAuthentication &&\n userAuthentication['customHandler'] != null\n ) {\n return userAuthentication['customHandler'];\n }\n\n return UserAuthenticator(userAuthentication);\n}\n\nfunction buildChannelAuth(opts: Options, pusher): ChannelAuthorizationOptions {\n let channelAuthorization: ChannelAuthorizationOptions;\n if ('channelAuthorization' in opts) {\n channelAuthorization = {\n ...Defaults.channelAuthorization,\n ...opts.channelAuthorization\n };\n } else {\n channelAuthorization = {\n transport: opts.authTransport || Defaults.authTransport,\n endpoint: opts.authEndpoint || Defaults.authEndpoint\n };\n if ('auth' in opts) {\n if ('params' in opts.auth) channelAuthorization.params = opts.auth.params;\n if ('headers' in opts.auth)\n channelAuthorization.headers = opts.auth.headers;\n }\n if ('authorizer' in opts)\n channelAuthorization.customHandler = ChannelAuthorizerProxy(\n pusher,\n channelAuthorization,\n opts.authorizer\n );\n }\n return channelAuthorization;\n}\n\nfunction buildChannelAuthorizer(\n opts: Options,\n pusher\n): ChannelAuthorizationHandler {\n const channelAuthorization = buildChannelAuth(opts, pusher);\n if (\n 'customHandler' in channelAuthorization &&\n channelAuthorization['customHandler'] != null\n ) {\n return channelAuthorization['customHandler'];\n }\n\n return ChannelAuthorizer(channelAuthorization);\n}\n","import Logger from './logger';\nimport Pusher from './pusher';\nimport EventsDispatcher from './events/dispatcher';\n\nexport default class WatchlistFacade extends EventsDispatcher {\n private pusher: Pusher;\n\n public constructor(pusher: Pusher) {\n super(function(eventName, data) {\n Logger.debug(`No callbacks on watchlist events for ${eventName}`);\n });\n\n this.pusher = pusher;\n this.bindWatchlistInternalEvent();\n }\n\n handleEvent(pusherEvent) {\n pusherEvent.data.events.forEach(watchlistEvent => {\n this.emit(watchlistEvent.name, watchlistEvent);\n });\n }\n\n private bindWatchlistInternalEvent() {\n this.pusher.connection.bind('message', pusherEvent => {\n var eventName = pusherEvent.event;\n if (eventName === 'pusher_internal:watchlist_events') {\n this.handleEvent(pusherEvent);\n }\n });\n }\n}\n","function flatPromise() {\n let resolve, reject;\n const promise = new Promise((res, rej) => {\n resolve = res;\n reject = rej;\n });\n return { promise, resolve, reject };\n}\n\nexport default flatPromise;\n","import Pusher from './pusher';\nimport Logger from './logger';\nimport {\n UserAuthenticationData,\n UserAuthenticationCallback\n} from './auth/options';\nimport Channel from './channels/channel';\nimport WatchlistFacade from './watchlist';\nimport EventsDispatcher from './events/dispatcher';\nimport flatPromise from './utils/flat_promise';\n\nexport default class UserFacade extends EventsDispatcher {\n pusher: Pusher;\n signin_requested: boolean = false;\n user_data: any = null;\n serverToUserChannel: Channel = null;\n signinDonePromise: Promise = null;\n watchlist: WatchlistFacade;\n private _signinDoneResolve: Function = null;\n\n public constructor(pusher: Pusher) {\n super(function(eventName, data) {\n Logger.debug('No callbacks on user for ' + eventName);\n });\n this.pusher = pusher;\n this.pusher.connection.bind('state_change', ({ previous, current }) => {\n if (previous !== 'connected' && current === 'connected') {\n this._signin();\n }\n if (previous === 'connected' && current !== 'connected') {\n this._cleanup();\n this._newSigninPromiseIfNeeded();\n }\n });\n\n this.watchlist = new WatchlistFacade(pusher);\n\n this.pusher.connection.bind('message', event => {\n var eventName = event.event;\n if (eventName === 'pusher:signin_success') {\n this._onSigninSuccess(event.data);\n }\n if (\n this.serverToUserChannel &&\n this.serverToUserChannel.name === event.channel\n ) {\n this.serverToUserChannel.handleEvent(event);\n }\n });\n }\n\n public signin() {\n if (this.signin_requested) {\n return;\n }\n\n this.signin_requested = true;\n this._signin();\n }\n\n private _signin() {\n if (!this.signin_requested) {\n return;\n }\n\n this._newSigninPromiseIfNeeded();\n\n if (this.pusher.connection.state !== 'connected') {\n // Signin will be attempted when the connection is connected\n return;\n }\n\n this.pusher.config.userAuthenticator(\n {\n socketId: this.pusher.connection.socket_id\n },\n this._onAuthorize\n );\n }\n\n private _onAuthorize: UserAuthenticationCallback = (\n err,\n authData: UserAuthenticationData\n ) => {\n if (err) {\n Logger.warn(`Error during signin: ${err}`);\n this._cleanup();\n return;\n }\n\n this.pusher.send_event('pusher:signin', {\n auth: authData.auth,\n user_data: authData.user_data\n });\n\n // Later when we get pusher:singin_success event, the user will be marked as signed in\n };\n\n private _onSigninSuccess(data: any) {\n try {\n this.user_data = JSON.parse(data.user_data);\n } catch (e) {\n Logger.error(`Failed parsing user data after signin: ${data.user_data}`);\n this._cleanup();\n return;\n }\n\n if (typeof this.user_data.id !== 'string' || this.user_data.id === '') {\n Logger.error(\n `user_data doesn't contain an id. user_data: ${this.user_data}`\n );\n this._cleanup();\n return;\n }\n\n // Signin succeeded\n this._signinDoneResolve();\n this._subscribeChannels();\n }\n\n private _subscribeChannels() {\n const ensure_subscribed = channel => {\n if (channel.subscriptionPending && channel.subscriptionCancelled) {\n channel.reinstateSubscription();\n } else if (\n !channel.subscriptionPending &&\n this.pusher.connection.state === 'connected'\n ) {\n channel.subscribe();\n }\n };\n\n this.serverToUserChannel = new Channel(\n `#server-to-user-${this.user_data.id}`,\n this.pusher\n );\n this.serverToUserChannel.bind_global((eventName, data) => {\n if (\n eventName.indexOf('pusher_internal:') === 0 ||\n eventName.indexOf('pusher:') === 0\n ) {\n // ignore internal events\n return;\n }\n this.emit(eventName, data);\n });\n ensure_subscribed(this.serverToUserChannel);\n }\n\n private _cleanup() {\n this.user_data = null;\n if (this.serverToUserChannel) {\n this.serverToUserChannel.unbind_all();\n this.serverToUserChannel.disconnect();\n this.serverToUserChannel = null;\n }\n\n if (this.signin_requested) {\n // If signin is in progress and cleanup is called,\n // Mark the current signin process as done.\n this._signinDoneResolve();\n }\n }\n\n private _newSigninPromiseIfNeeded() {\n if (!this.signin_requested) {\n return;\n }\n\n // If there is a promise and it is not resolved, return without creating a new one.\n if (this.signinDonePromise && !(this.signinDonePromise as any).done) {\n return;\n }\n\n // This promise is never rejected.\n // It gets resolved when the signin process is done whether it failed or succeeded\n const { promise, resolve, reject: _ } = flatPromise();\n (promise as any).done = false;\n const setDone = () => {\n (promise as any).done = true;\n };\n promise.then(setDone).catch(setDone);\n this.signinDonePromise = promise;\n this._signinDoneResolve = resolve;\n }\n}\n","import AbstractRuntime from '../runtimes/interface';\nimport Runtime from 'runtime';\nimport Util from './util';\nimport * as Collections from './utils/collections';\nimport Channels from './channels/channels';\nimport Channel from './channels/channel';\nimport { default as EventsDispatcher } from './events/dispatcher';\nimport Timeline from './timeline/timeline';\nimport TimelineSender from './timeline/timeline_sender';\nimport TimelineLevel from './timeline/level';\nimport { defineTransport } from './strategies/strategy_builder';\nimport ConnectionManager from './connection/connection_manager';\nimport ConnectionManagerOptions from './connection/connection_manager_options';\nimport { PeriodicTimer } from './utils/timers';\nimport Defaults from './defaults';\nimport * as DefaultConfig from './config';\nimport Logger from './logger';\nimport Factory from './utils/factory';\nimport UrlStore from 'core/utils/url_store';\nimport { Options, validateOptions } from './options';\nimport { Config, getConfig } from './config';\nimport StrategyOptions from './strategies/strategy_options';\nimport UserFacade from './user';\n\nexport default class Pusher {\n /* STATIC PROPERTIES */\n static instances: Pusher[] = [];\n static isReady: boolean = false;\n static logToConsole: boolean = false;\n\n // for jsonp\n static Runtime: AbstractRuntime = Runtime;\n static ScriptReceivers: any = (Runtime).ScriptReceivers;\n static DependenciesReceivers: any = (Runtime).DependenciesReceivers;\n static auth_callbacks: any = (Runtime).auth_callbacks;\n\n static ready() {\n Pusher.isReady = true;\n for (var i = 0, l = Pusher.instances.length; i < l; i++) {\n Pusher.instances[i].connect();\n }\n }\n\n static log: (message: any) => void;\n\n private static getClientFeatures(): string[] {\n return Collections.keys(\n Collections.filterObject({ ws: Runtime.Transports.ws }, function(t) {\n return t.isSupported({});\n })\n );\n }\n\n /* INSTANCE PROPERTIES */\n key: string;\n config: Config;\n channels: Channels;\n global_emitter: EventsDispatcher;\n sessionID: number;\n timeline: Timeline;\n timelineSender: TimelineSender;\n connection: ConnectionManager;\n timelineSenderTimer: PeriodicTimer;\n user: UserFacade;\n constructor(app_key: string, options: Options) {\n checkAppKey(app_key);\n validateOptions(options);\n this.key = app_key;\n this.config = getConfig(options, this);\n\n this.channels = Factory.createChannels();\n this.global_emitter = new EventsDispatcher();\n this.sessionID = Runtime.randomInt(1000000000);\n\n this.timeline = new Timeline(this.key, this.sessionID, {\n cluster: this.config.cluster,\n features: Pusher.getClientFeatures(),\n params: this.config.timelineParams || {},\n limit: 50,\n level: TimelineLevel.INFO,\n version: Defaults.VERSION\n });\n if (this.config.enableStats) {\n this.timelineSender = Factory.createTimelineSender(this.timeline, {\n host: this.config.statsHost,\n path: '/timeline/v2/' + Runtime.TimelineTransport.name\n });\n }\n\n var getStrategy = (options: StrategyOptions) => {\n return Runtime.getDefaultStrategy(this.config, options, defineTransport);\n };\n\n this.connection = Factory.createConnectionManager(this.key, {\n getStrategy: getStrategy,\n timeline: this.timeline,\n activityTimeout: this.config.activityTimeout,\n pongTimeout: this.config.pongTimeout,\n unavailableTimeout: this.config.unavailableTimeout,\n useTLS: Boolean(this.config.useTLS)\n });\n\n this.connection.bind('connected', () => {\n this.subscribeAll();\n if (this.timelineSender) {\n this.timelineSender.send(this.connection.isUsingTLS());\n }\n });\n\n this.connection.bind('message', event => {\n var eventName = event.event;\n var internal = eventName.indexOf('pusher_internal:') === 0;\n if (event.channel) {\n var channel = this.channel(event.channel);\n if (channel) {\n channel.handleEvent(event);\n }\n }\n // Emit globally [deprecated]\n if (!internal) {\n this.global_emitter.emit(event.event, event.data);\n }\n });\n this.connection.bind('connecting', () => {\n this.channels.disconnect();\n });\n this.connection.bind('disconnected', () => {\n this.channels.disconnect();\n });\n this.connection.bind('error', err => {\n Logger.warn(err);\n });\n\n Pusher.instances.push(this);\n this.timeline.info({ instances: Pusher.instances.length });\n\n this.user = new UserFacade(this);\n\n if (Pusher.isReady) {\n this.connect();\n }\n }\n\n channel(name: string): Channel {\n return this.channels.find(name);\n }\n\n allChannels(): Channel[] {\n return this.channels.all();\n }\n\n connect() {\n this.connection.connect();\n\n if (this.timelineSender) {\n if (!this.timelineSenderTimer) {\n var usingTLS = this.connection.isUsingTLS();\n var timelineSender = this.timelineSender;\n this.timelineSenderTimer = new PeriodicTimer(60000, function() {\n timelineSender.send(usingTLS);\n });\n }\n }\n }\n\n disconnect() {\n this.connection.disconnect();\n\n if (this.timelineSenderTimer) {\n this.timelineSenderTimer.ensureAborted();\n this.timelineSenderTimer = null;\n }\n }\n\n bind(event_name: string, callback: Function, context?: any): Pusher {\n this.global_emitter.bind(event_name, callback, context);\n return this;\n }\n\n unbind(event_name?: string, callback?: Function, context?: any): Pusher {\n this.global_emitter.unbind(event_name, callback, context);\n return this;\n }\n\n bind_global(callback: Function): Pusher {\n this.global_emitter.bind_global(callback);\n return this;\n }\n\n unbind_global(callback?: Function): Pusher {\n this.global_emitter.unbind_global(callback);\n return this;\n }\n\n unbind_all(callback?: Function): Pusher {\n this.global_emitter.unbind_all();\n return this;\n }\n\n subscribeAll() {\n var channelName;\n for (channelName in this.channels.channels) {\n if (this.channels.channels.hasOwnProperty(channelName)) {\n this.subscribe(channelName);\n }\n }\n }\n\n subscribe(channel_name: string) {\n var channel = this.channels.add(channel_name, this);\n if (channel.subscriptionPending && channel.subscriptionCancelled) {\n channel.reinstateSubscription();\n } else if (\n !channel.subscriptionPending &&\n this.connection.state === 'connected'\n ) {\n channel.subscribe();\n }\n return channel;\n }\n\n unsubscribe(channel_name: string) {\n var channel = this.channels.find(channel_name);\n if (channel && channel.subscriptionPending) {\n channel.cancelSubscription();\n } else {\n channel = this.channels.remove(channel_name);\n if (channel && channel.subscribed) {\n channel.unsubscribe();\n }\n }\n }\n\n send_event(event_name: string, data: any, channel?: string) {\n return this.connection.send_event(event_name, data, channel);\n }\n\n shouldUseTLS(): boolean {\n return this.config.useTLS;\n }\n\n signin() {\n this.user.signin();\n }\n}\n\nfunction checkAppKey(key) {\n if (key === null || key === undefined) {\n throw 'You must pass your app key when you instantiate Pusher.';\n }\n}\n\nRuntime.setup(Pusher);\n"],"sourceRoot":""} \ No newline at end of file +{"version":3,"sources":["webpack://Pusher/webpack/universalModuleDefinition","webpack://Pusher/webpack/bootstrap","webpack://Pusher/./node_modules/@stablelib/base64/base64.ts","webpack://Pusher/./node_modules/@stablelib/utf8/utf8.ts","webpack://Pusher/./src/core/pusher.js","webpack://Pusher/./src/runtimes/web/dom/script_receiver_factory.ts","webpack://Pusher/./src/core/defaults.ts","webpack://Pusher/./src/runtimes/web/dom/dependency_loader.ts","webpack://Pusher/./src/runtimes/web/dom/dependencies.ts","webpack://Pusher/./src/core/utils/url_store.ts","webpack://Pusher/./src/core/auth/options.ts","webpack://Pusher/./src/core/errors.ts","webpack://Pusher/./src/runtimes/isomorphic/auth/xhr_auth.ts","webpack://Pusher/./src/core/base64.ts","webpack://Pusher/./src/core/utils/timers/abstract_timer.ts","webpack://Pusher/./src/core/utils/timers/index.ts","webpack://Pusher/./src/core/util.ts","webpack://Pusher/./src/core/utils/collections.ts","webpack://Pusher/./src/core/logger.ts","webpack://Pusher/./src/runtimes/web/auth/jsonp_auth.ts","webpack://Pusher/./src/runtimes/web/dom/script_request.ts","webpack://Pusher/./src/runtimes/web/dom/jsonp_request.ts","webpack://Pusher/./src/runtimes/web/timeline/jsonp_timeline.ts","webpack://Pusher/./src/core/transports/url_schemes.ts","webpack://Pusher/./src/core/events/callback_registry.ts","webpack://Pusher/./src/core/events/dispatcher.ts","webpack://Pusher/./src/core/transports/transport_connection.ts","webpack://Pusher/./src/core/transports/transport.ts","webpack://Pusher/./src/runtimes/isomorphic/transports/transports.ts","webpack://Pusher/./src/runtimes/web/transports/transports.ts","webpack://Pusher/./src/runtimes/web/net_info.ts","webpack://Pusher/./src/core/transports/assistant_to_the_transport_manager.ts","webpack://Pusher/./src/core/connection/protocol/protocol.ts","webpack://Pusher/./src/core/connection/connection.ts","webpack://Pusher/./src/core/connection/handshake/index.ts","webpack://Pusher/./src/core/timeline/timeline_sender.ts","webpack://Pusher/./src/core/channels/channel.ts","webpack://Pusher/./src/core/channels/private_channel.ts","webpack://Pusher/./src/core/channels/members.ts","webpack://Pusher/./src/core/channels/presence_channel.ts","webpack://Pusher/./src/core/channels/encrypted_channel.ts","webpack://Pusher/./src/core/connection/connection_manager.ts","webpack://Pusher/./src/core/channels/channels.ts","webpack://Pusher/./src/core/utils/factory.ts","webpack://Pusher/./src/core/transports/transport_manager.ts","webpack://Pusher/./src/core/strategies/sequential_strategy.ts","webpack://Pusher/./src/core/strategies/best_connected_ever_strategy.ts","webpack://Pusher/./src/core/strategies/websocket_prioritized_cached_strategy.ts","webpack://Pusher/./src/core/strategies/delayed_strategy.ts","webpack://Pusher/./src/core/strategies/if_strategy.ts","webpack://Pusher/./src/core/strategies/first_connected_strategy.ts","webpack://Pusher/./src/runtimes/web/default_strategy.ts","webpack://Pusher/./src/runtimes/web/transports/transport_connection_initializer.ts","webpack://Pusher/./src/runtimes/web/http/http_xdomain_request.ts","webpack://Pusher/./src/core/http/http_request.ts","webpack://Pusher/./src/core/http/state.ts","webpack://Pusher/./src/core/http/http_socket.ts","webpack://Pusher/./src/core/http/http_streaming_socket.ts","webpack://Pusher/./src/core/http/http_polling_socket.ts","webpack://Pusher/./src/runtimes/isomorphic/http/http_xhr_request.ts","webpack://Pusher/./src/runtimes/isomorphic/http/http.ts","webpack://Pusher/./src/runtimes/web/http/http.ts","webpack://Pusher/./src/runtimes/web/runtime.ts","webpack://Pusher/./src/core/timeline/level.ts","webpack://Pusher/./src/core/timeline/timeline.ts","webpack://Pusher/./src/core/strategies/transport_strategy.ts","webpack://Pusher/./src/core/strategies/strategy_builder.ts","webpack://Pusher/./src/core/options.ts","webpack://Pusher/./src/core/auth/user_authenticator.ts","webpack://Pusher/./src/core/auth/channel_authorizer.ts","webpack://Pusher/./src/core/auth/deprecated_channel_authorizer.ts","webpack://Pusher/./src/core/config.ts","webpack://Pusher/./src/core/watchlist.ts","webpack://Pusher/./src/core/utils/flat_promise.ts","webpack://Pusher/./src/core/user.ts","webpack://Pusher/./src/core/pusher.ts"],"names":[],"mappings":";;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AACD,O;QCVA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;;QAEA;QACA;;QAEA;QACA;;QAE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AAS,EAAE;QACrC,MAAM,yDAAyD,CAAC;KACjE;AACH,CAAC;AAED,OAAO,CAAC,KAAK,CAAC,aAAM,CAAC,CAAC","file":"pusher.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"Pusher\"] = factory();\n\telse\n\t\troot[\"Pusher\"] = factory();\n})(window, function() {\nreturn "," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 2);\n","// Copyright (C) 2016 Dmitry Chestnykh\n// MIT License. See LICENSE file for details.\n\n/**\n * Package base64 implements Base64 encoding and decoding.\n */\n\n// Invalid character used in decoding to indicate\n// that the character to decode is out of range of\n// alphabet and cannot be decoded.\nconst INVALID_BYTE = 256;\n\n/**\n * Implements standard Base64 encoding.\n *\n * Operates in constant time.\n */\nexport class Coder {\n // TODO(dchest): methods to encode chunk-by-chunk.\n\n constructor(private _paddingCharacter = \"=\") { }\n\n encodedLength(length: number): number {\n if (!this._paddingCharacter) {\n return (length * 8 + 5) / 6 | 0;\n }\n return (length + 2) / 3 * 4 | 0;\n }\n\n encode(data: Uint8Array): string {\n let out = \"\";\n\n let i = 0;\n for (; i < data.length - 2; i += 3) {\n let c = (data[i] << 16) | (data[i + 1] << 8) | (data[i + 2]);\n out += this._encodeByte((c >>> 3 * 6) & 63);\n out += this._encodeByte((c >>> 2 * 6) & 63);\n out += this._encodeByte((c >>> 1 * 6) & 63);\n out += this._encodeByte((c >>> 0 * 6) & 63);\n }\n\n const left = data.length - i;\n if (left > 0) {\n let c = (data[i] << 16) | (left === 2 ? data[i + 1] << 8 : 0);\n out += this._encodeByte((c >>> 3 * 6) & 63);\n out += this._encodeByte((c >>> 2 * 6) & 63);\n if (left === 2) {\n out += this._encodeByte((c >>> 1 * 6) & 63);\n } else {\n out += this._paddingCharacter || \"\";\n }\n out += this._paddingCharacter || \"\";\n }\n\n return out;\n }\n\n maxDecodedLength(length: number): number {\n if (!this._paddingCharacter) {\n return (length * 6 + 7) / 8 | 0;\n }\n return length / 4 * 3 | 0;\n }\n\n decodedLength(s: string): number {\n return this.maxDecodedLength(s.length - this._getPaddingLength(s));\n }\n\n decode(s: string): Uint8Array {\n if (s.length === 0) {\n return new Uint8Array(0);\n }\n const paddingLength = this._getPaddingLength(s);\n const length = s.length - paddingLength;\n const out = new Uint8Array(this.maxDecodedLength(length));\n let op = 0;\n let i = 0;\n let haveBad = 0;\n let v0 = 0, v1 = 0, v2 = 0, v3 = 0;\n for (; i < length - 4; i += 4) {\n v0 = this._decodeChar(s.charCodeAt(i + 0));\n v1 = this._decodeChar(s.charCodeAt(i + 1));\n v2 = this._decodeChar(s.charCodeAt(i + 2));\n v3 = this._decodeChar(s.charCodeAt(i + 3));\n out[op++] = (v0 << 2) | (v1 >>> 4);\n out[op++] = (v1 << 4) | (v2 >>> 2);\n out[op++] = (v2 << 6) | v3;\n haveBad |= v0 & INVALID_BYTE;\n haveBad |= v1 & INVALID_BYTE;\n haveBad |= v2 & INVALID_BYTE;\n haveBad |= v3 & INVALID_BYTE;\n }\n if (i < length - 1) {\n v0 = this._decodeChar(s.charCodeAt(i));\n v1 = this._decodeChar(s.charCodeAt(i + 1));\n out[op++] = (v0 << 2) | (v1 >>> 4);\n haveBad |= v0 & INVALID_BYTE;\n haveBad |= v1 & INVALID_BYTE;\n }\n if (i < length - 2) {\n v2 = this._decodeChar(s.charCodeAt(i + 2));\n out[op++] = (v1 << 4) | (v2 >>> 2);\n haveBad |= v2 & INVALID_BYTE;\n }\n if (i < length - 3) {\n v3 = this._decodeChar(s.charCodeAt(i + 3));\n out[op++] = (v2 << 6) | v3;\n haveBad |= v3 & INVALID_BYTE;\n }\n if (haveBad !== 0) {\n throw new Error(\"Base64Coder: incorrect characters for decoding\");\n }\n return out;\n }\n\n // Standard encoding have the following encoded/decoded ranges,\n // which we need to convert between.\n //\n // ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 0123456789 + /\n // Index: 0 - 25 26 - 51 52 - 61 62 63\n // ASCII: 65 - 90 97 - 122 48 - 57 43 47\n //\n\n // Encode 6 bits in b into a new character.\n protected _encodeByte(b: number): string {\n // Encoding uses constant time operations as follows:\n //\n // 1. Define comparison of A with B using (A - B) >>> 8:\n // if A > B, then result is positive integer\n // if A <= B, then result is 0\n //\n // 2. Define selection of C or 0 using bitwise AND: X & C:\n // if X == 0, then result is 0\n // if X != 0, then result is C\n //\n // 3. Start with the smallest comparison (b >= 0), which is always\n // true, so set the result to the starting ASCII value (65).\n //\n // 4. Continue comparing b to higher ASCII values, and selecting\n // zero if comparison isn't true, otherwise selecting a value\n // to add to result, which:\n //\n // a) undoes the previous addition\n // b) provides new value to add\n //\n let result = b;\n // b >= 0\n result += 65;\n // b > 25\n result += ((25 - b) >>> 8) & ((0 - 65) - 26 + 97);\n // b > 51\n result += ((51 - b) >>> 8) & ((26 - 97) - 52 + 48);\n // b > 61\n result += ((61 - b) >>> 8) & ((52 - 48) - 62 + 43);\n // b > 62\n result += ((62 - b) >>> 8) & ((62 - 43) - 63 + 47);\n\n return String.fromCharCode(result);\n }\n\n // Decode a character code into a byte.\n // Must return 256 if character is out of alphabet range.\n protected _decodeChar(c: number): number {\n // Decoding works similar to encoding: using the same comparison\n // function, but now it works on ranges: result is always incremented\n // by value, but this value becomes zero if the range is not\n // satisfied.\n //\n // Decoding starts with invalid value, 256, which is then\n // subtracted when the range is satisfied. If none of the ranges\n // apply, the function returns 256, which is then checked by\n // the caller to throw error.\n let result = INVALID_BYTE; // start with invalid character\n\n // c == 43 (c > 42 and c < 44)\n result += (((42 - c) & (c - 44)) >>> 8) & (-INVALID_BYTE + c - 43 + 62);\n // c == 47 (c > 46 and c < 48)\n result += (((46 - c) & (c - 48)) >>> 8) & (-INVALID_BYTE + c - 47 + 63);\n // c > 47 and c < 58\n result += (((47 - c) & (c - 58)) >>> 8) & (-INVALID_BYTE + c - 48 + 52);\n // c > 64 and c < 91\n result += (((64 - c) & (c - 91)) >>> 8) & (-INVALID_BYTE + c - 65 + 0);\n // c > 96 and c < 123\n result += (((96 - c) & (c - 123)) >>> 8) & (-INVALID_BYTE + c - 97 + 26);\n\n return result;\n }\n\n private _getPaddingLength(s: string): number {\n let paddingLength = 0;\n if (this._paddingCharacter) {\n for (let i = s.length - 1; i >= 0; i--) {\n if (s[i] !== this._paddingCharacter) {\n break;\n }\n paddingLength++;\n }\n if (s.length < 4 || paddingLength > 2) {\n throw new Error(\"Base64Coder: incorrect padding\");\n }\n }\n return paddingLength;\n }\n\n}\n\nconst stdCoder = new Coder();\n\nexport function encode(data: Uint8Array): string {\n return stdCoder.encode(data);\n}\n\nexport function decode(s: string): Uint8Array {\n return stdCoder.decode(s);\n}\n\n/**\n * Implements URL-safe Base64 encoding.\n * (Same as Base64, but '+' is replaced with '-', and '/' with '_').\n *\n * Operates in constant time.\n */\nexport class URLSafeCoder extends Coder {\n // URL-safe encoding have the following encoded/decoded ranges:\n //\n // ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 0123456789 - _\n // Index: 0 - 25 26 - 51 52 - 61 62 63\n // ASCII: 65 - 90 97 - 122 48 - 57 45 95\n //\n\n protected _encodeByte(b: number): string {\n let result = b;\n // b >= 0\n result += 65;\n // b > 25\n result += ((25 - b) >>> 8) & ((0 - 65) - 26 + 97);\n // b > 51\n result += ((51 - b) >>> 8) & ((26 - 97) - 52 + 48);\n // b > 61\n result += ((61 - b) >>> 8) & ((52 - 48) - 62 + 45);\n // b > 62\n result += ((62 - b) >>> 8) & ((62 - 45) - 63 + 95);\n\n return String.fromCharCode(result);\n }\n\n protected _decodeChar(c: number): number {\n let result = INVALID_BYTE;\n\n // c == 45 (c > 44 and c < 46)\n result += (((44 - c) & (c - 46)) >>> 8) & (-INVALID_BYTE + c - 45 + 62);\n // c == 95 (c > 94 and c < 96)\n result += (((94 - c) & (c - 96)) >>> 8) & (-INVALID_BYTE + c - 95 + 63);\n // c > 47 and c < 58\n result += (((47 - c) & (c - 58)) >>> 8) & (-INVALID_BYTE + c - 48 + 52);\n // c > 64 and c < 91\n result += (((64 - c) & (c - 91)) >>> 8) & (-INVALID_BYTE + c - 65 + 0);\n // c > 96 and c < 123\n result += (((96 - c) & (c - 123)) >>> 8) & (-INVALID_BYTE + c - 97 + 26);\n\n return result;\n }\n}\n\nconst urlSafeCoder = new URLSafeCoder();\n\nexport function encodeURLSafe(data: Uint8Array): string {\n return urlSafeCoder.encode(data);\n}\n\nexport function decodeURLSafe(s: string): Uint8Array {\n return urlSafeCoder.decode(s);\n}\n\n\nexport const encodedLength = (length: number) =>\n stdCoder.encodedLength(length);\n\nexport const maxDecodedLength = (length: number) =>\n stdCoder.maxDecodedLength(length);\n\nexport const decodedLength = (s: string) =>\n stdCoder.decodedLength(s);\n","// Copyright (C) 2016 Dmitry Chestnykh\n// MIT License. See LICENSE file for details.\n\n/**\n * Package utf8 implements UTF-8 encoding and decoding.\n */\n\nconst INVALID_UTF16 = \"utf8: invalid string\";\nconst INVALID_UTF8 = \"utf8: invalid source encoding\";\n\n/**\n * Encodes the given string into UTF-8 byte array.\n * Throws if the source string has invalid UTF-16 encoding.\n */\nexport function encode(s: string): Uint8Array {\n // Calculate result length and allocate output array.\n // encodedLength() also validates string and throws errors,\n // so we don't need repeat validation here.\n const arr = new Uint8Array(encodedLength(s));\n\n let pos = 0;\n for (let i = 0; i < s.length; i++) {\n let c = s.charCodeAt(i);\n if (c < 0x80) {\n arr[pos++] = c;\n } else if (c < 0x800) {\n arr[pos++] = 0xc0 | c >> 6;\n arr[pos++] = 0x80 | c & 0x3f;\n } else if (c < 0xd800) {\n arr[pos++] = 0xe0 | c >> 12;\n arr[pos++] = 0x80 | (c >> 6) & 0x3f;\n arr[pos++] = 0x80 | c & 0x3f;\n } else {\n i++; // get one more character\n c = (c & 0x3ff) << 10;\n c |= s.charCodeAt(i) & 0x3ff;\n c += 0x10000;\n\n arr[pos++] = 0xf0 | c >> 18;\n arr[pos++] = 0x80 | (c >> 12) & 0x3f;\n arr[pos++] = 0x80 | (c >> 6) & 0x3f;\n arr[pos++] = 0x80 | c & 0x3f;\n }\n }\n return arr;\n}\n\n/**\n * Returns the number of bytes required to encode the given string into UTF-8.\n * Throws if the source string has invalid UTF-16 encoding.\n */\nexport function encodedLength(s: string): number {\n let result = 0;\n for (let i = 0; i < s.length; i++) {\n const c = s.charCodeAt(i);\n if (c < 0x80) {\n result += 1;\n } else if (c < 0x800) {\n result += 2;\n } else if (c < 0xd800) {\n result += 3;\n } else if (c <= 0xdfff) {\n if (i >= s.length - 1) {\n throw new Error(INVALID_UTF16);\n }\n i++; // \"eat\" next character\n result += 4;\n } else {\n throw new Error(INVALID_UTF16);\n }\n }\n return result;\n}\n\n/**\n * Decodes the given byte array from UTF-8 into a string.\n * Throws if encoding is invalid.\n */\nexport function decode(arr: Uint8Array): string {\n const chars: string[] = [];\n for (let i = 0; i < arr.length; i++) {\n let b = arr[i];\n\n if (b & 0x80) {\n let min;\n if (b < 0xe0) {\n // Need 1 more byte.\n if (i >= arr.length) {\n throw new Error(INVALID_UTF8);\n }\n const n1 = arr[++i];\n if ((n1 & 0xc0) !== 0x80) {\n throw new Error(INVALID_UTF8);\n }\n b = (b & 0x1f) << 6 | (n1 & 0x3f);\n min = 0x80;\n } else if (b < 0xf0) {\n // Need 2 more bytes.\n if (i >= arr.length - 1) {\n throw new Error(INVALID_UTF8);\n }\n const n1 = arr[++i];\n const n2 = arr[++i];\n if ((n1 & 0xc0) !== 0x80 || (n2 & 0xc0) !== 0x80) {\n throw new Error(INVALID_UTF8);\n }\n b = (b & 0x0f) << 12 | (n1 & 0x3f) << 6 | (n2 & 0x3f);\n min = 0x800;\n } else if (b < 0xf8) {\n // Need 3 more bytes.\n if (i >= arr.length - 2) {\n throw new Error(INVALID_UTF8);\n }\n const n1 = arr[++i];\n const n2 = arr[++i];\n const n3 = arr[++i];\n if ((n1 & 0xc0) !== 0x80 || (n2 & 0xc0) !== 0x80 || (n3 & 0xc0) !== 0x80) {\n throw new Error(INVALID_UTF8);\n }\n b = (b & 0x0f) << 18 | (n1 & 0x3f) << 12 | (n2 & 0x3f) << 6 | (n3 & 0x3f);\n min = 0x10000;\n } else {\n throw new Error(INVALID_UTF8);\n }\n\n if (b < min || (b >= 0xd800 && b <= 0xdfff)) {\n throw new Error(INVALID_UTF8);\n }\n\n if (b >= 0x10000) {\n // Surrogate pair.\n if (b > 0x10ffff) {\n throw new Error(INVALID_UTF8);\n }\n b -= 0x10000;\n chars.push(String.fromCharCode(0xd800 | (b >> 10)));\n b = 0xdc00 | (b & 0x3ff);\n }\n }\n\n chars.push(String.fromCharCode(b));\n }\n return chars.join(\"\");\n}\n","// required so we don't have to do require('pusher').default etc.\nmodule.exports = require('./pusher').default;\n","import ScriptReceiver from './script_receiver';\n\n/** Builds receivers for JSONP and Script requests.\n *\n * Each receiver is an object with following fields:\n * - number - unique (for the factory instance), numerical id of the receiver\n * - id - a string ID that can be used in DOM attributes\n * - name - name of the function triggering the receiver\n * - callback - callback function\n *\n * Receivers are triggered only once, on the first callback call.\n *\n * Receivers can be called by their name or by accessing factory object\n * by the number key.\n *\n * @param {String} prefix the prefix used in ids\n * @param {String} name the name of the object\n */\nexport class ScriptReceiverFactory {\n lastId: number;\n prefix: string;\n name: string;\n\n constructor(prefix: string, name: string) {\n this.lastId = 0;\n this.prefix = prefix;\n this.name = name;\n }\n\n create(callback: Function): ScriptReceiver {\n this.lastId++;\n\n var number = this.lastId;\n var id = this.prefix + number;\n var name = this.name + '[' + number + ']';\n\n var called = false;\n var callbackWrapper = function() {\n if (!called) {\n callback.apply(null, arguments);\n called = true;\n }\n };\n\n this[number] = callbackWrapper;\n return { number: number, id: id, name: name, callback: callbackWrapper };\n }\n\n remove(receiver: ScriptReceiver) {\n delete this[receiver.number];\n }\n}\n\nexport var ScriptReceivers = new ScriptReceiverFactory(\n '_pusher_script_',\n 'Pusher.ScriptReceivers'\n);\n","import {\n ChannelAuthorizationOptions,\n UserAuthenticationOptions\n} from './auth/options';\nimport { AuthTransport } from './config';\n\nexport interface DefaultConfig {\n VERSION: string;\n PROTOCOL: number;\n wsPort: number;\n wssPort: number;\n wsPath: string;\n httpHost: string;\n httpPort: number;\n httpsPort: number;\n httpPath: string;\n stats_host: string;\n authEndpoint: string;\n authTransport: AuthTransport;\n activityTimeout: number;\n pongTimeout: number;\n unavailableTimeout: number;\n userAuthentication: UserAuthenticationOptions;\n channelAuthorization: ChannelAuthorizationOptions;\n\n cdn_http?: string;\n cdn_https?: string;\n dependency_suffix?: string;\n}\n\nvar Defaults: DefaultConfig = {\n VERSION: VERSION,\n PROTOCOL: 7,\n\n wsPort: 80,\n wssPort: 443,\n wsPath: '',\n // DEPRECATED: SockJS fallback parameters\n httpHost: 'sockjs.pusher.com',\n httpPort: 80,\n httpsPort: 443,\n httpPath: '/pusher',\n // DEPRECATED: Stats\n stats_host: 'stats.pusher.com',\n // DEPRECATED: Other settings\n authEndpoint: '/pusher/auth',\n authTransport: 'ajax',\n activityTimeout: 120000,\n pongTimeout: 30000,\n unavailableTimeout: 10000,\n userAuthentication: {\n endpoint: '/pusher/user-auth',\n transport: 'ajax'\n },\n channelAuthorization: {\n endpoint: '/pusher/auth',\n transport: 'ajax'\n },\n\n // CDN configuration\n cdn_http: CDN_HTTP,\n cdn_https: CDN_HTTPS,\n dependency_suffix: DEPENDENCY_SUFFIX\n};\n\nexport default Defaults;\n","import {\n ScriptReceivers,\n ScriptReceiverFactory\n} from './script_receiver_factory';\nimport Runtime from 'runtime';\nimport ScriptRequest from './script_request';\n\n/** Handles loading dependency files.\n *\n * Dependency loaders don't remember whether a resource has been loaded or\n * not. It is caller's responsibility to make sure the resource is not loaded\n * twice. This is because it's impossible to detect resource loading status\n * without knowing its content.\n *\n * Options:\n * - cdn_http - url to HTTP CND\n * - cdn_https - url to HTTPS CDN\n * - version - version of pusher-js\n * - suffix - suffix appended to all names of dependency files\n *\n * @param {Object} options\n */\nexport default class DependencyLoader {\n options: any;\n receivers: ScriptReceiverFactory;\n loading: any;\n\n constructor(options: any) {\n this.options = options;\n this.receivers = options.receivers || ScriptReceivers;\n this.loading = {};\n }\n\n /** Loads the dependency from CDN.\n *\n * @param {String} name\n * @param {Function} callback\n */\n load(name: string, options: any, callback: Function) {\n var self = this;\n\n if (self.loading[name] && self.loading[name].length > 0) {\n self.loading[name].push(callback);\n } else {\n self.loading[name] = [callback];\n\n var request = Runtime.createScriptRequest(self.getPath(name, options));\n var receiver = self.receivers.create(function(error) {\n self.receivers.remove(receiver);\n\n if (self.loading[name]) {\n var callbacks = self.loading[name];\n delete self.loading[name];\n\n var successCallback = function(wasSuccessful) {\n if (!wasSuccessful) {\n request.cleanup();\n }\n };\n for (var i = 0; i < callbacks.length; i++) {\n callbacks[i](error, successCallback);\n }\n }\n });\n request.send(receiver);\n }\n }\n\n /** Returns a root URL for pusher-js CDN.\n *\n * @returns {String}\n */\n getRoot(options: any): string {\n var cdn;\n var protocol = Runtime.getDocument().location.protocol;\n if ((options && options.useTLS) || protocol === 'https:') {\n cdn = this.options.cdn_https;\n } else {\n cdn = this.options.cdn_http;\n }\n // make sure there are no double slashes\n return cdn.replace(/\\/*$/, '') + '/' + this.options.version;\n }\n\n /** Returns a full path to a dependency file.\n *\n * @param {String} name\n * @returns {String}\n */\n getPath(name: string, options: any): string {\n return this.getRoot(options) + '/' + name + this.options.suffix + '.js';\n }\n}\n","import { ScriptReceiverFactory } from './script_receiver_factory';\nimport Defaults from 'core/defaults';\nimport DependencyLoader from './dependency_loader';\n\nexport var DependenciesReceivers = new ScriptReceiverFactory(\n '_pusher_dependencies',\n 'Pusher.DependenciesReceivers'\n);\n\nexport var Dependencies = new DependencyLoader({\n cdn_http: Defaults.cdn_http,\n cdn_https: Defaults.cdn_https,\n version: Defaults.VERSION,\n suffix: Defaults.dependency_suffix,\n receivers: DependenciesReceivers\n});\n","/**\n * A place to store help URLs for error messages etc\n */\n\nconst urlStore = {\n baseUrl: 'https://pusher.com',\n urls: {\n authenticationEndpoint: {\n path: '/docs/channels/server_api/authenticating_users'\n },\n authorizationEndpoint: {\n path: '/docs/channels/server_api/authorizing-users/'\n },\n javascriptQuickStart: {\n path: '/docs/javascript_quick_start'\n },\n triggeringClientEvents: {\n path: '/docs/client_api_guide/client_events#trigger-events'\n },\n encryptedChannelSupport: {\n fullUrl:\n 'https://github.com/pusher/pusher-js/tree/cc491015371a4bde5743d1c87a0fbac0feb53195#encrypted-channel-support'\n }\n }\n};\n\n/** Builds a consistent string with links to pusher documentation\n *\n * @param {string} key - relevant key in the url_store.urls object\n * @return {string} suffix string to append to log message\n */\nconst buildLogSuffix = function(key: string): string {\n const urlPrefix = 'See:';\n const urlObj = urlStore.urls[key];\n if (!urlObj) return '';\n\n let url;\n if (urlObj.fullUrl) {\n url = urlObj.fullUrl;\n } else if (urlObj.path) {\n url = urlStore.baseUrl + urlObj.path;\n }\n\n if (!url) return '';\n return `${urlPrefix} ${url}`;\n};\n\nexport default { buildLogSuffix };\n","export enum AuthRequestType {\n UserAuthentication = 'user-authentication',\n ChannelAuthorization = 'channel-authorization'\n}\n\nexport interface ChannelAuthorizationData {\n auth: string;\n channel_data?: string;\n shared_secret?: string;\n}\n\nexport type ChannelAuthorizationCallback = (\n error: Error | null,\n authData: ChannelAuthorizationData | null\n) => void;\n\nexport interface ChannelAuthorizationRequestParams {\n socketId: string;\n channelName: string;\n}\n\nexport interface ChannelAuthorizationHandler {\n (\n params: ChannelAuthorizationRequestParams,\n callback: ChannelAuthorizationCallback\n ): void;\n}\n\nexport interface UserAuthenticationData {\n auth: string;\n user_data: string;\n}\n\nexport type UserAuthenticationCallback = (\n error: Error | null,\n authData: UserAuthenticationData | null\n) => void;\n\nexport interface UserAuthenticationRequestParams {\n socketId: string;\n}\n\nexport interface UserAuthenticationHandler {\n (\n params: UserAuthenticationRequestParams,\n callback: UserAuthenticationCallback\n ): void;\n}\n\nexport type AuthTransportCallback =\n | ChannelAuthorizationCallback\n | UserAuthenticationCallback;\n\nexport interface AuthOptionsT {\n transport: 'ajax' | 'jsonp';\n endpoint: string;\n params?: any;\n headers?: any;\n paramsProvider?: () => any;\n headersProvider?: () => any;\n customHandler?: AuthHandler;\n}\n\nexport declare type UserAuthenticationOptions = AuthOptionsT<\n UserAuthenticationHandler\n>;\nexport declare type ChannelAuthorizationOptions = AuthOptionsT<\n ChannelAuthorizationHandler\n>;\n\nexport interface InternalAuthOptions {\n transport: 'ajax' | 'jsonp';\n endpoint: string;\n params?: any;\n headers?: any;\n paramsProvider?: () => any;\n headersProvider?: () => any;\n}\n","/** Error classes used throughout the library. */\n// https://github.com/Microsoft/TypeScript-wiki/blob/master/Breaking-Changes.md#extending-built-ins-like-error-array-and-map-may-no-longer-work\nexport class BadEventName extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\nexport class BadChannelName extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\nexport class RequestTimedOut extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class TransportPriorityTooLow extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class TransportClosed extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class UnsupportedFeature extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class UnsupportedTransport extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class UnsupportedStrategy extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class HTTPAuthError extends Error {\n status: number;\n constructor(status: number, msg?: string) {\n super(msg);\n this.status = status;\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n","import TimelineSender from 'core/timeline/timeline_sender';\nimport * as Collections from 'core/utils/collections';\nimport Util from 'core/util';\nimport Runtime from 'runtime';\nimport { AuthTransport } from 'core/auth/auth_transports';\nimport AbstractRuntime from 'runtimes/interface';\nimport UrlStore from 'core/utils/url_store';\nimport {\n AuthRequestType,\n AuthTransportCallback,\n InternalAuthOptions\n} from 'core/auth/options';\nimport { HTTPAuthError } from 'core/errors';\n\nconst ajax: AuthTransport = function(\n context: AbstractRuntime,\n query: string,\n authOptions: InternalAuthOptions,\n authRequestType: AuthRequestType,\n callback: AuthTransportCallback\n) {\n const xhr = Runtime.createXHR();\n xhr.open('POST', authOptions.endpoint, true);\n\n // add request headers\n xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');\n for (var headerName in authOptions.headers) {\n xhr.setRequestHeader(headerName, authOptions.headers[headerName]);\n }\n if (authOptions.headersProvider != null) {\n let dynamicHeaders = authOptions.headersProvider();\n for (var headerName in dynamicHeaders) {\n xhr.setRequestHeader(headerName, dynamicHeaders[headerName]);\n }\n }\n\n xhr.onreadystatechange = function() {\n if (xhr.readyState === 4) {\n if (xhr.status === 200) {\n let data;\n let parsed = false;\n\n try {\n data = JSON.parse(xhr.responseText);\n parsed = true;\n } catch (e) {\n callback(\n new HTTPAuthError(\n 200,\n `JSON returned from ${authRequestType.toString()} endpoint was invalid, yet status code was 200. Data was: ${\n xhr.responseText\n }`\n ),\n null\n );\n }\n\n if (parsed) {\n // prevents double execution.\n callback(null, data);\n }\n } else {\n let suffix = '';\n switch (authRequestType) {\n case AuthRequestType.UserAuthentication:\n suffix = UrlStore.buildLogSuffix('authenticationEndpoint');\n break;\n case AuthRequestType.ChannelAuthorization:\n suffix = `Clients must be authorized to join private or presence channels. ${UrlStore.buildLogSuffix(\n 'authorizationEndpoint'\n )}`;\n break;\n }\n callback(\n new HTTPAuthError(\n xhr.status,\n `Unable to retrieve auth string from ${authRequestType.toString()} endpoint - ` +\n `received status: ${xhr.status} from ${authOptions.endpoint}. ${suffix}`\n ),\n null\n );\n }\n }\n };\n\n xhr.send(query);\n return xhr;\n};\n\nexport default ajax;\n","export default function encode(s: any): string {\n return btoa(utob(s));\n}\n\nvar fromCharCode = String.fromCharCode;\n\nvar b64chars =\n 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';\nvar b64tab = {};\n\nfor (var i = 0, l = b64chars.length; i < l; i++) {\n b64tab[b64chars.charAt(i)] = i;\n}\n\nvar cb_utob = function(c) {\n var cc = c.charCodeAt(0);\n return cc < 0x80\n ? c\n : cc < 0x800\n ? fromCharCode(0xc0 | (cc >>> 6)) + fromCharCode(0x80 | (cc & 0x3f))\n : fromCharCode(0xe0 | ((cc >>> 12) & 0x0f)) +\n fromCharCode(0x80 | ((cc >>> 6) & 0x3f)) +\n fromCharCode(0x80 | (cc & 0x3f));\n};\n\nvar utob = function(u) {\n return u.replace(/[^\\x00-\\x7F]/g, cb_utob);\n};\n\nvar cb_encode = function(ccc) {\n var padlen = [0, 2, 1][ccc.length % 3];\n var ord =\n (ccc.charCodeAt(0) << 16) |\n ((ccc.length > 1 ? ccc.charCodeAt(1) : 0) << 8) |\n (ccc.length > 2 ? ccc.charCodeAt(2) : 0);\n var chars = [\n b64chars.charAt(ord >>> 18),\n b64chars.charAt((ord >>> 12) & 63),\n padlen >= 2 ? '=' : b64chars.charAt((ord >>> 6) & 63),\n padlen >= 1 ? '=' : b64chars.charAt(ord & 63)\n ];\n return chars.join('');\n};\n\nvar btoa =\n global.btoa ||\n function(b) {\n return b.replace(/[\\s\\S]{1,3}/g, cb_encode);\n };\n","import TimedCallback from './timed_callback';\nimport { Delay, Scheduler, Canceller } from './scheduling';\n\nabstract class Timer {\n protected clear: Canceller;\n protected timer: number | void;\n\n constructor(\n set: Scheduler,\n clear: Canceller,\n delay: Delay,\n callback: TimedCallback\n ) {\n this.clear = clear;\n this.timer = set(() => {\n if (this.timer) {\n this.timer = callback(this.timer);\n }\n }, delay);\n }\n\n /** Returns whether the timer is still running.\n *\n * @return {Boolean}\n */\n isRunning(): boolean {\n return this.timer !== null;\n }\n\n /** Aborts a timer when it's running. */\n ensureAborted() {\n if (this.timer) {\n this.clear(this.timer);\n this.timer = null;\n }\n }\n}\n\nexport default Timer;\n","import Timer from './abstract_timer';\nimport TimedCallback from './timed_callback';\nimport { Delay } from './scheduling';\n\n// We need to bind clear functions this way to avoid exceptions on IE8\nfunction clearTimeout(timer) {\n global.clearTimeout(timer);\n}\nfunction clearInterval(timer) {\n global.clearInterval(timer);\n}\n\n/** Cross-browser compatible one-off timer abstraction.\n *\n * @param {Number} delay\n * @param {Function} callback\n */\nexport class OneOffTimer extends Timer {\n constructor(delay: Delay, callback: TimedCallback) {\n super(setTimeout, clearTimeout, delay, function(timer) {\n callback();\n return null;\n });\n }\n}\n\n/** Cross-browser compatible periodic timer abstraction.\n *\n * @param {Number} delay\n * @param {Function} callback\n */\nexport class PeriodicTimer extends Timer {\n constructor(delay: Delay, callback: TimedCallback) {\n super(setInterval, clearInterval, delay, function(timer) {\n callback();\n return timer;\n });\n }\n}\n","import * as Collections from './utils/collections';\nimport TimedCallback from './utils/timers/timed_callback';\nimport { OneOffTimer, PeriodicTimer } from './utils/timers';\n\nvar Util = {\n now(): number {\n if (Date.now) {\n return Date.now();\n } else {\n return new Date().valueOf();\n }\n },\n\n defer(callback: TimedCallback): OneOffTimer {\n return new OneOffTimer(0, callback);\n },\n\n /** Builds a function that will proxy a method call to its first argument.\n *\n * Allows partial application of arguments, so additional arguments are\n * prepended to the argument list.\n *\n * @param {String} name method name\n * @return {Function} proxy function\n */\n method(name: string, ...args: any[]): Function {\n var boundArguments = Array.prototype.slice.call(arguments, 1);\n return function(object) {\n return object[name].apply(object, boundArguments.concat(arguments));\n };\n }\n};\n\nexport default Util;\n","import base64encode from '../base64';\nimport Util from '../util';\n\n/** Merges multiple objects into the target argument.\n *\n * For properties that are plain Objects, performs a deep-merge. For the\n * rest it just copies the value of the property.\n *\n * To extend prototypes use it as following:\n * Pusher.Util.extend(Target.prototype, Base.prototype)\n *\n * You can also use it to merge objects without altering them:\n * Pusher.Util.extend({}, object1, object2)\n *\n * @param {Object} target\n * @return {Object} the target argument\n */\nexport function extend(target: any, ...sources: any[]): T {\n for (var i = 0; i < sources.length; i++) {\n var extensions = sources[i];\n for (var property in extensions) {\n if (\n extensions[property] &&\n extensions[property].constructor &&\n extensions[property].constructor === Object\n ) {\n target[property] = extend(target[property] || {}, extensions[property]);\n } else {\n target[property] = extensions[property];\n }\n }\n }\n return target;\n}\n\nexport function stringify(): string {\n var m = ['Pusher'];\n for (var i = 0; i < arguments.length; i++) {\n if (typeof arguments[i] === 'string') {\n m.push(arguments[i]);\n } else {\n m.push(safeJSONStringify(arguments[i]));\n }\n }\n return m.join(' : ');\n}\n\nexport function arrayIndexOf(array: any[], item: any): number {\n // MSIE doesn't have array.indexOf\n var nativeIndexOf = Array.prototype.indexOf;\n if (array === null) {\n return -1;\n }\n if (nativeIndexOf && array.indexOf === nativeIndexOf) {\n return array.indexOf(item);\n }\n for (var i = 0, l = array.length; i < l; i++) {\n if (array[i] === item) {\n return i;\n }\n }\n return -1;\n}\n\n/** Applies a function f to all properties of an object.\n *\n * Function f gets 3 arguments passed:\n * - element from the object\n * - key of the element\n * - reference to the object\n *\n * @param {Object} object\n * @param {Function} f\n */\nexport function objectApply(object: any, f: Function) {\n for (var key in object) {\n if (Object.prototype.hasOwnProperty.call(object, key)) {\n f(object[key], key, object);\n }\n }\n}\n\n/** Return a list of objects own proerty keys\n *\n * @param {Object} object\n * @returns {Array}\n */\nexport function keys(object: any): string[] {\n var keys = [];\n objectApply(object, function(_, key) {\n keys.push(key);\n });\n return keys;\n}\n\n/** Return a list of object's own property values\n *\n * @param {Object} object\n * @returns {Array}\n */\nexport function values(object: any): any[] {\n var values = [];\n objectApply(object, function(value) {\n values.push(value);\n });\n return values;\n}\n\n/** Applies a function f to all elements of an array.\n *\n * Function f gets 3 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function apply(array: any[], f: Function, context?: any) {\n for (var i = 0; i < array.length; i++) {\n f.call(context || global, array[i], i, array);\n }\n}\n\n/** Maps all elements of the array and returns the result.\n *\n * Function f gets 4 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n * - reference to the destination array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function map(array: any[], f: Function): any[] {\n var result = [];\n for (var i = 0; i < array.length; i++) {\n result.push(f(array[i], i, array, result));\n }\n return result;\n}\n\n/** Maps all elements of the object and returns the result.\n *\n * Function f gets 4 arguments passed:\n * - element from the object\n * - key of the element\n * - reference to the source object\n * - reference to the destination object\n *\n * @param {Object} object\n * @param {Function} f\n */\nexport function mapObject(object: any, f: Function): any {\n var result = {};\n objectApply(object, function(value, key) {\n result[key] = f(value);\n });\n return result;\n}\n\n/** Filters elements of the array using a test function.\n *\n * Function test gets 4 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n * - reference to the destination array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function filter(array: any[], test: Function): any[] {\n test =\n test ||\n function(value) {\n return !!value;\n };\n\n var result = [];\n for (var i = 0; i < array.length; i++) {\n if (test(array[i], i, array, result)) {\n result.push(array[i]);\n }\n }\n return result;\n}\n\n/** Filters properties of the object using a test function.\n *\n * Function test gets 4 arguments passed:\n * - element from the object\n * - key of the element\n * - reference to the source object\n * - reference to the destination object\n *\n * @param {Object} object\n * @param {Function} f\n */\nexport function filterObject(object: Object, test: Function) {\n var result = {};\n objectApply(object, function(value, key) {\n if ((test && test(value, key, object, result)) || Boolean(value)) {\n result[key] = value;\n }\n });\n return result;\n}\n\n/** Flattens an object into a two-dimensional array.\n *\n * @param {Object} object\n * @return {Array} resulting array of [key, value] pairs\n */\nexport function flatten(object: Object): any[] {\n var result = [];\n objectApply(object, function(value, key) {\n result.push([key, value]);\n });\n return result;\n}\n\n/** Checks whether any element of the array passes the test.\n *\n * Function test gets 3 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function any(array: any[], test: Function): boolean {\n for (var i = 0; i < array.length; i++) {\n if (test(array[i], i, array)) {\n return true;\n }\n }\n return false;\n}\n\n/** Checks whether all elements of the array pass the test.\n *\n * Function test gets 3 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function all(array: any[], test: Function): boolean {\n for (var i = 0; i < array.length; i++) {\n if (!test(array[i], i, array)) {\n return false;\n }\n }\n return true;\n}\n\nexport function encodeParamsObject(data): string {\n return mapObject(data, function(value) {\n if (typeof value === 'object') {\n value = safeJSONStringify(value);\n }\n return encodeURIComponent(base64encode(value.toString()));\n });\n}\n\nexport function buildQueryString(data: any): string {\n var params = filterObject(data, function(value) {\n return value !== undefined;\n });\n\n var query = map(\n flatten(encodeParamsObject(params)),\n Util.method('join', '=')\n ).join('&');\n\n return query;\n}\n\n/**\n * See https://github.com/douglascrockford/JSON-js/blob/master/cycle.js\n *\n * Remove circular references from an object. Required for JSON.stringify in\n * React Native, which tends to blow up a lot.\n *\n * @param {any} object\n * @return {any} Decycled object\n */\nexport function decycleObject(object: any): any {\n var objects = [],\n paths = [];\n\n return (function derez(value, path) {\n var i, name, nu;\n\n switch (typeof value) {\n case 'object':\n if (!value) {\n return null;\n }\n for (i = 0; i < objects.length; i += 1) {\n if (objects[i] === value) {\n return { $ref: paths[i] };\n }\n }\n\n objects.push(value);\n paths.push(path);\n\n if (Object.prototype.toString.apply(value) === '[object Array]') {\n nu = [];\n for (i = 0; i < value.length; i += 1) {\n nu[i] = derez(value[i], path + '[' + i + ']');\n }\n } else {\n nu = {};\n for (name in value) {\n if (Object.prototype.hasOwnProperty.call(value, name)) {\n nu[name] = derez(\n value[name],\n path + '[' + JSON.stringify(name) + ']'\n );\n }\n }\n }\n return nu;\n case 'number':\n case 'string':\n case 'boolean':\n return value;\n }\n })(object, '$');\n}\n\n/**\n * Provides a cross-browser and cross-platform way to safely stringify objects\n * into JSON. This is particularly necessary for ReactNative, where circular JSON\n * structures throw an exception.\n *\n * @param {any} source The object to stringify\n * @return {string} The serialized output.\n */\nexport function safeJSONStringify(source: any): string {\n try {\n return JSON.stringify(source);\n } catch (e) {\n return JSON.stringify(decycleObject(source));\n }\n}\n","import { stringify } from './utils/collections';\nimport Pusher from './pusher';\n\nclass Logger {\n debug(...args: any[]) {\n this.log(this.globalLog, args);\n }\n\n warn(...args: any[]) {\n this.log(this.globalLogWarn, args);\n }\n\n error(...args: any[]) {\n this.log(this.globalLogError, args);\n }\n\n private globalLog = (message: string) => {\n if (global.console && global.console.log) {\n global.console.log(message);\n }\n };\n\n private globalLogWarn(message: string) {\n if (global.console && global.console.warn) {\n global.console.warn(message);\n } else {\n this.globalLog(message);\n }\n }\n\n private globalLogError(message: string) {\n if (global.console && global.console.error) {\n global.console.error(message);\n } else {\n this.globalLogWarn(message);\n }\n }\n\n private log(\n defaultLoggingFunction: (message: string) => void,\n ...args: any[]\n ) {\n var message = stringify.apply(this, arguments);\n if (Pusher.log) {\n Pusher.log(message);\n } else if (Pusher.logToConsole) {\n const log = defaultLoggingFunction.bind(this);\n log(message);\n }\n }\n}\n\nexport default new Logger();\n","import Browser from '../browser';\nimport Logger from 'core/logger';\nimport JSONPRequest from '../dom/jsonp_request';\nimport { ScriptReceivers } from '../dom/script_receiver_factory';\nimport { AuthTransport } from 'core/auth/auth_transports';\nimport {\n AuthRequestType,\n AuthTransportCallback,\n InternalAuthOptions\n} from 'core/auth/options';\n\nvar jsonp: AuthTransport = function(\n context: Browser,\n query: string,\n authOptions: InternalAuthOptions,\n authRequestType: AuthRequestType,\n callback: AuthTransportCallback\n) {\n if (\n authOptions.headers !== undefined ||\n authOptions.headersProvider != null\n ) {\n Logger.warn(\n `To send headers with the ${authRequestType.toString()} request, you must use AJAX, rather than JSONP.`\n );\n }\n\n var callbackName = context.nextAuthCallbackID.toString();\n context.nextAuthCallbackID++;\n\n var document = context.getDocument();\n var script = document.createElement('script');\n // Hacked wrapper.\n context.auth_callbacks[callbackName] = function(data) {\n callback(null, data);\n };\n\n var callback_name = \"Pusher.auth_callbacks['\" + callbackName + \"']\";\n script.src =\n authOptions.endpoint +\n '?callback=' +\n encodeURIComponent(callback_name) +\n '&' +\n query;\n\n var head =\n document.getElementsByTagName('head')[0] || document.documentElement;\n head.insertBefore(script, head.firstChild);\n};\n\nexport default jsonp;\n","import ScriptReceiver from './script_receiver';\n\n/** Sends a generic HTTP GET request using a script tag.\n *\n * By constructing URL in a specific way, it can be used for loading\n * JavaScript resources or JSONP requests. It can notify about errors, but\n * only in certain environments. Please take care of monitoring the state of\n * the request yourself.\n *\n * @param {String} src\n */\nexport default class ScriptRequest {\n src: string;\n script: any;\n errorScript: any;\n\n constructor(src: string) {\n this.src = src;\n }\n\n send(receiver: ScriptReceiver) {\n var self = this;\n var errorString = 'Error loading ' + self.src;\n\n self.script = document.createElement('script');\n self.script.id = receiver.id;\n self.script.src = self.src;\n self.script.type = 'text/javascript';\n self.script.charset = 'UTF-8';\n\n if (self.script.addEventListener) {\n self.script.onerror = function() {\n receiver.callback(errorString);\n };\n self.script.onload = function() {\n receiver.callback(null);\n };\n } else {\n self.script.onreadystatechange = function() {\n if (\n self.script.readyState === 'loaded' ||\n self.script.readyState === 'complete'\n ) {\n receiver.callback(null);\n }\n };\n }\n\n // Opera<11.6 hack for missing onerror callback\n if (\n self.script.async === undefined &&\n (document).attachEvent &&\n /opera/i.test(navigator.userAgent)\n ) {\n self.errorScript = document.createElement('script');\n self.errorScript.id = receiver.id + '_error';\n self.errorScript.text = receiver.name + \"('\" + errorString + \"');\";\n self.script.async = self.errorScript.async = false;\n } else {\n self.script.async = true;\n }\n\n var head = document.getElementsByTagName('head')[0];\n head.insertBefore(self.script, head.firstChild);\n if (self.errorScript) {\n head.insertBefore(self.errorScript, self.script.nextSibling);\n }\n }\n\n /** Cleans up the DOM remains of the script request. */\n cleanup() {\n if (this.script) {\n this.script.onload = this.script.onerror = null;\n this.script.onreadystatechange = null;\n }\n if (this.script && this.script.parentNode) {\n this.script.parentNode.removeChild(this.script);\n }\n if (this.errorScript && this.errorScript.parentNode) {\n this.errorScript.parentNode.removeChild(this.errorScript);\n }\n this.script = null;\n this.errorScript = null;\n }\n}\n","import ScriptReceiver from './script_receiver';\nimport ScriptRequest from './script_request';\nimport * as Collections from 'core/utils/collections';\nimport Util from 'core/util';\nimport Runtime from '../runtime';\n\n/** Sends data via JSONP.\n *\n * Data is a key-value map. Its values are JSON-encoded and then passed\n * through base64. Finally, keys and encoded values are appended to the query\n * string.\n *\n * The class itself does not guarantee raising errors on failures, as it's not\n * possible to support such feature on all browsers. Instead, JSONP endpoint\n * should call back in a way that's easy to distinguish from browser calls,\n * for example by passing a second argument to the receiver.\n *\n * @param {String} url\n * @param {Object} data key-value map of data to be submitted\n */\nexport default class JSONPRequest {\n url: string;\n data: any;\n request: ScriptRequest;\n\n constructor(url: string, data: any) {\n this.url = url;\n this.data = data;\n }\n\n /** Sends the actual JSONP request.\n *\n * @param {ScriptReceiver} receiver\n */\n send(receiver: ScriptReceiver) {\n if (this.request) {\n return;\n }\n\n var query = Collections.buildQueryString(this.data);\n var url = this.url + '/' + receiver.number + '?' + query;\n this.request = Runtime.createScriptRequest(url);\n this.request.send(receiver);\n }\n\n /** Cleans up the DOM remains of the JSONP request. */\n cleanup() {\n if (this.request) {\n this.request.cleanup();\n }\n }\n}\n","import TimelineSender from 'core/timeline/timeline_sender';\nimport TimelineTransport from 'core/timeline/timeline_transport';\nimport Browser from 'runtime';\nimport { AuthTransport } from 'core/auth/auth_transports';\nimport { ScriptReceivers } from '../dom/script_receiver_factory';\n\nvar getAgent = function(sender: TimelineSender, useTLS: boolean) {\n return function(data: any, callback: Function) {\n var scheme = 'http' + (useTLS ? 's' : '') + '://';\n var url =\n scheme + (sender.host || sender.options.host) + sender.options.path;\n var request = Browser.createJSONPRequest(url, data);\n\n var receiver = Browser.ScriptReceivers.create(function(error, result) {\n ScriptReceivers.remove(receiver);\n request.cleanup();\n\n if (result && result.host) {\n sender.host = result.host;\n }\n if (callback) {\n callback(error, result);\n }\n });\n request.send(receiver);\n };\n};\n\nvar jsonp = {\n name: 'jsonp',\n getAgent\n};\n\nexport default jsonp;\n","import Defaults from '../defaults';\nimport { default as URLScheme, URLSchemeParams } from './url_scheme';\n\nfunction getGenericURL(\n baseScheme: string,\n params: URLSchemeParams,\n path: string\n): string {\n var scheme = baseScheme + (params.useTLS ? 's' : '');\n var host = params.useTLS ? params.hostTLS : params.hostNonTLS;\n return scheme + '://' + host + path;\n}\n\nfunction getGenericPath(key: string, queryString?: string): string {\n var path = '/app/' + key;\n var query =\n '?protocol=' +\n Defaults.PROTOCOL +\n '&client=js' +\n '&version=' +\n Defaults.VERSION +\n (queryString ? '&' + queryString : '');\n return path + query;\n}\n\nexport var ws: URLScheme = {\n getInitial: function(key: string, params: URLSchemeParams): string {\n var path = (params.httpPath || '') + getGenericPath(key, 'flash=false');\n return getGenericURL('ws', params, path);\n }\n};\n\nexport var http: URLScheme = {\n getInitial: function(key: string, params: URLSchemeParams): string {\n var path = (params.httpPath || '/pusher') + getGenericPath(key);\n return getGenericURL('http', params, path);\n }\n};\n\nexport var sockjs: URLScheme = {\n getInitial: function(key: string, params: URLSchemeParams): string {\n return getGenericURL('http', params, params.httpPath || '/pusher');\n },\n getPath: function(key: string, params: URLSchemeParams): string {\n return getGenericPath(key);\n }\n};\n","import Callback from './callback';\nimport * as Collections from '../utils/collections';\nimport CallbackTable from './callback_table';\n\nexport default class CallbackRegistry {\n _callbacks: CallbackTable;\n\n constructor() {\n this._callbacks = {};\n }\n\n get(name: string): Callback[] {\n return this._callbacks[prefix(name)];\n }\n\n add(name: string, callback: Function, context: any) {\n var prefixedEventName = prefix(name);\n this._callbacks[prefixedEventName] =\n this._callbacks[prefixedEventName] || [];\n this._callbacks[prefixedEventName].push({\n fn: callback,\n context: context\n });\n }\n\n remove(name?: string, callback?: Function, context?: any) {\n if (!name && !callback && !context) {\n this._callbacks = {};\n return;\n }\n\n var names = name ? [prefix(name)] : Collections.keys(this._callbacks);\n\n if (callback || context) {\n this.removeCallback(names, callback, context);\n } else {\n this.removeAllCallbacks(names);\n }\n }\n\n private removeCallback(names: string[], callback: Function, context: any) {\n Collections.apply(\n names,\n function(name) {\n this._callbacks[name] = Collections.filter(\n this._callbacks[name] || [],\n function(binding) {\n return (\n (callback && callback !== binding.fn) ||\n (context && context !== binding.context)\n );\n }\n );\n if (this._callbacks[name].length === 0) {\n delete this._callbacks[name];\n }\n },\n this\n );\n }\n\n private removeAllCallbacks(names: string[]) {\n Collections.apply(\n names,\n function(name) {\n delete this._callbacks[name];\n },\n this\n );\n }\n}\n\nfunction prefix(name: string): string {\n return '_' + name;\n}\n","import * as Collections from '../utils/collections';\nimport Callback from './callback';\nimport Metadata from '../channels/metadata';\nimport CallbackRegistry from './callback_registry';\n\n/** Manages callback bindings and event emitting.\n *\n * @param Function failThrough called when no listeners are bound to an event\n */\nexport default class Dispatcher {\n callbacks: CallbackRegistry;\n global_callbacks: Function[];\n failThrough: Function;\n\n constructor(failThrough?: Function) {\n this.callbacks = new CallbackRegistry();\n this.global_callbacks = [];\n this.failThrough = failThrough;\n }\n\n bind(eventName: string, callback: Function, context?: any) {\n this.callbacks.add(eventName, callback, context);\n return this;\n }\n\n bind_global(callback: Function) {\n this.global_callbacks.push(callback);\n return this;\n }\n\n unbind(eventName?: string, callback?: Function, context?: any) {\n this.callbacks.remove(eventName, callback, context);\n return this;\n }\n\n unbind_global(callback?: Function) {\n if (!callback) {\n this.global_callbacks = [];\n return this;\n }\n\n this.global_callbacks = Collections.filter(\n this.global_callbacks || [],\n c => c !== callback\n );\n\n return this;\n }\n\n unbind_all() {\n this.unbind();\n this.unbind_global();\n return this;\n }\n\n emit(eventName: string, data?: any, metadata?: Metadata): Dispatcher {\n for (var i = 0; i < this.global_callbacks.length; i++) {\n this.global_callbacks[i](eventName, data);\n }\n\n var callbacks = this.callbacks.get(eventName);\n var args = [];\n\n if (metadata) {\n // if there's a metadata argument, we need to call the callback with both\n // data and metadata regardless of whether data is undefined\n args.push(data, metadata);\n } else if (data) {\n // metadata is undefined, so we only need to call the callback with data\n // if data exists\n args.push(data);\n }\n\n if (callbacks && callbacks.length > 0) {\n for (var i = 0; i < callbacks.length; i++) {\n callbacks[i].fn.apply(callbacks[i].context || global, args);\n }\n } else if (this.failThrough) {\n this.failThrough(eventName, data);\n }\n\n return this;\n }\n}\n","import Util from '../util';\nimport * as Collections from '../utils/collections';\nimport { default as EventsDispatcher } from '../events/dispatcher';\nimport Logger from '../logger';\nimport TransportHooks from './transport_hooks';\nimport Socket from '../socket';\nimport Runtime from 'runtime';\nimport Timeline from '../timeline/timeline';\nimport TransportConnectionOptions from './transport_connection_options';\n\n/** Provides universal API for transport connections.\n *\n * Transport connection is a low-level object that wraps a connection method\n * and exposes a simple evented interface for the connection state and\n * messaging. It does not implement Pusher-specific WebSocket protocol.\n *\n * Additionally, it fetches resources needed for transport to work and exposes\n * an interface for querying transport features.\n *\n * States:\n * - new - initial state after constructing the object\n * - initializing - during initialization phase, usually fetching resources\n * - intialized - ready to establish a connection\n * - connection - when connection is being established\n * - open - when connection ready to be used\n * - closed - after connection was closed be either side\n *\n * Emits:\n * - error - after the connection raised an error\n *\n * Options:\n * - useTLS - whether connection should be over TLS\n * - hostTLS - host to connect to when connection is over TLS\n * - hostNonTLS - host to connect to when connection is over TLS\n *\n * @param {String} key application key\n * @param {Object} options\n */\nexport default class TransportConnection extends EventsDispatcher {\n hooks: TransportHooks;\n name: string;\n priority: number;\n key: string;\n options: TransportConnectionOptions;\n state: string;\n timeline: Timeline;\n activityTimeout: number;\n id: number;\n socket: Socket;\n beforeOpen: Function;\n initialize: Function;\n\n constructor(\n hooks: TransportHooks,\n name: string,\n priority: number,\n key: string,\n options: TransportConnectionOptions\n ) {\n super();\n this.initialize = Runtime.transportConnectionInitializer;\n this.hooks = hooks;\n this.name = name;\n this.priority = priority;\n this.key = key;\n this.options = options;\n\n this.state = 'new';\n this.timeline = options.timeline;\n this.activityTimeout = options.activityTimeout;\n this.id = this.timeline.generateUniqueID();\n }\n\n /** Checks whether the transport handles activity checks by itself.\n *\n * @return {Boolean}\n */\n handlesActivityChecks(): boolean {\n return Boolean(this.hooks.handlesActivityChecks);\n }\n\n /** Checks whether the transport supports the ping/pong API.\n *\n * @return {Boolean}\n */\n supportsPing(): boolean {\n return Boolean(this.hooks.supportsPing);\n }\n\n /** Tries to establish a connection.\n *\n * @returns {Boolean} false if transport is in invalid state\n */\n connect(): boolean {\n if (this.socket || this.state !== 'initialized') {\n return false;\n }\n\n var url = this.hooks.urls.getInitial(this.key, this.options);\n try {\n this.socket = this.hooks.getSocket(url, this.options);\n } catch (e) {\n Util.defer(() => {\n this.onError(e);\n this.changeState('closed');\n });\n return false;\n }\n\n this.bindListeners();\n\n Logger.debug('Connecting', { transport: this.name, url });\n this.changeState('connecting');\n return true;\n }\n\n /** Closes the connection.\n *\n * @return {Boolean} true if there was a connection to close\n */\n close(): boolean {\n if (this.socket) {\n this.socket.close();\n return true;\n } else {\n return false;\n }\n }\n\n /** Sends data over the open connection.\n *\n * @param {String} data\n * @return {Boolean} true only when in the \"open\" state\n */\n send(data: any): boolean {\n if (this.state === 'open') {\n // Workaround for MobileSafari bug (see https://gist.github.com/2052006)\n Util.defer(() => {\n if (this.socket) {\n this.socket.send(data);\n }\n });\n return true;\n } else {\n return false;\n }\n }\n\n /** Sends a ping if the connection is open and transport supports it. */\n ping() {\n if (this.state === 'open' && this.supportsPing()) {\n this.socket.ping();\n }\n }\n\n private onOpen() {\n if (this.hooks.beforeOpen) {\n this.hooks.beforeOpen(\n this.socket,\n this.hooks.urls.getPath(this.key, this.options)\n );\n }\n this.changeState('open');\n this.socket.onopen = undefined;\n }\n\n private onError(error) {\n this.emit('error', { type: 'WebSocketError', error: error });\n this.timeline.error(this.buildTimelineMessage({ error: error.toString() }));\n }\n\n private onClose(closeEvent?: any) {\n if (closeEvent) {\n this.changeState('closed', {\n code: closeEvent.code,\n reason: closeEvent.reason,\n wasClean: closeEvent.wasClean\n });\n } else {\n this.changeState('closed');\n }\n this.unbindListeners();\n this.socket = undefined;\n }\n\n private onMessage(message) {\n this.emit('message', message);\n }\n\n private onActivity() {\n this.emit('activity');\n }\n\n private bindListeners() {\n this.socket.onopen = () => {\n this.onOpen();\n };\n this.socket.onerror = error => {\n this.onError(error);\n };\n this.socket.onclose = closeEvent => {\n this.onClose(closeEvent);\n };\n this.socket.onmessage = message => {\n this.onMessage(message);\n };\n\n if (this.supportsPing()) {\n this.socket.onactivity = () => {\n this.onActivity();\n };\n }\n }\n\n private unbindListeners() {\n if (this.socket) {\n this.socket.onopen = undefined;\n this.socket.onerror = undefined;\n this.socket.onclose = undefined;\n this.socket.onmessage = undefined;\n if (this.supportsPing()) {\n this.socket.onactivity = undefined;\n }\n }\n }\n\n private changeState(state: string, params?: any) {\n this.state = state;\n this.timeline.info(\n this.buildTimelineMessage({\n state: state,\n params: params\n })\n );\n this.emit(state, params);\n }\n\n buildTimelineMessage(message): any {\n return Collections.extend({ cid: this.id }, message);\n }\n}\n","import Factory from '../utils/factory';\nimport TransportHooks from './transport_hooks';\nimport TransportConnection from './transport_connection';\nimport TransportConnectionOptions from './transport_connection_options';\n\n/** Provides interface for transport connection instantiation.\n *\n * Takes transport-specific hooks as the only argument, which allow checking\n * for transport support and creating its connections.\n *\n * Supported hooks: * - file - the name of the file to be fetched during initialization\n * - urls - URL scheme to be used by transport\n * - handlesActivityCheck - true when the transport handles activity checks\n * - supportsPing - true when the transport has a ping/activity API\n * - isSupported - tells whether the transport is supported in the environment\n * - getSocket - creates a WebSocket-compatible transport socket\n *\n * See transports.js for specific implementations.\n *\n * @param {Object} hooks object containing all needed transport hooks\n */\nexport default class Transport {\n hooks: TransportHooks;\n\n constructor(hooks: TransportHooks) {\n this.hooks = hooks;\n }\n\n /** Returns whether the transport is supported in the environment.\n *\n * @param {Object} envronment te environment details (encryption, settings)\n * @returns {Boolean} true when the transport is supported\n */\n isSupported(environment: any): boolean {\n return this.hooks.isSupported(environment);\n }\n\n /** Creates a transport connection.\n *\n * @param {String} name\n * @param {Number} priority\n * @param {String} key the application key\n * @param {Object} options\n * @returns {TransportConnection}\n */\n createConnection(\n name: string,\n priority: number,\n key: string,\n options: any\n ): TransportConnection {\n return new TransportConnection(this.hooks, name, priority, key, options);\n }\n}\n","import * as URLSchemes from 'core/transports/url_schemes';\nimport URLScheme from 'core/transports/url_scheme';\nimport Transport from 'core/transports/transport';\nimport Util from 'core/util';\nimport * as Collections from 'core/utils/collections';\nimport TransportHooks from 'core/transports/transport_hooks';\nimport TransportsTable from 'core/transports/transports_table';\nimport Runtime from 'runtime';\n\n/** WebSocket transport.\n *\n * Uses native WebSocket implementation, including MozWebSocket supported by\n * earlier Firefox versions.\n */\nvar WSTransport = new Transport({\n urls: URLSchemes.ws,\n handlesActivityChecks: false,\n supportsPing: false,\n\n isInitialized: function() {\n return Boolean(Runtime.getWebSocketAPI());\n },\n isSupported: function(): boolean {\n return Boolean(Runtime.getWebSocketAPI());\n },\n getSocket: function(url) {\n return Runtime.createWebSocket(url);\n }\n});\n\nvar httpConfiguration = {\n urls: URLSchemes.http,\n handlesActivityChecks: false,\n supportsPing: true,\n isInitialized: function() {\n return true;\n }\n};\n\nexport var streamingConfiguration = Collections.extend(\n {\n getSocket: function(url) {\n return Runtime.HTTPFactory.createStreamingSocket(url);\n }\n },\n httpConfiguration\n);\nexport var pollingConfiguration = Collections.extend(\n {\n getSocket: function(url) {\n return Runtime.HTTPFactory.createPollingSocket(url);\n }\n },\n httpConfiguration\n);\n\nvar xhrConfiguration = {\n isSupported: function(): boolean {\n return Runtime.isXHRSupported();\n }\n};\n\n/** HTTP streaming transport using CORS-enabled XMLHttpRequest. */\nvar XHRStreamingTransport = new Transport(\n (\n Collections.extend({}, streamingConfiguration, xhrConfiguration)\n )\n);\n\n/** HTTP long-polling transport using CORS-enabled XMLHttpRequest. */\nvar XHRPollingTransport = new Transport(\n Collections.extend({}, pollingConfiguration, xhrConfiguration)\n);\n\nvar Transports: TransportsTable = {\n ws: WSTransport,\n xhr_streaming: XHRStreamingTransport,\n xhr_polling: XHRPollingTransport\n};\n\nexport default Transports;\n","import {\n default as Transports,\n streamingConfiguration,\n pollingConfiguration\n} from 'isomorphic/transports/transports';\nimport Transport from 'core/transports/transport';\nimport TransportHooks from 'core/transports/transport_hooks';\nimport * as URLSchemes from 'core/transports/url_schemes';\nimport Runtime from 'runtime';\nimport { Dependencies } from '../dom/dependencies';\nimport * as Collections from 'core/utils/collections';\n\nvar SockJSTransport = new Transport({\n file: 'sockjs',\n urls: URLSchemes.sockjs,\n handlesActivityChecks: true,\n supportsPing: false,\n\n isSupported: function() {\n return true;\n },\n isInitialized: function() {\n return window.SockJS !== undefined;\n },\n getSocket: function(url, options) {\n return new window.SockJS(url, null, {\n js_path: Dependencies.getPath('sockjs', {\n useTLS: options.useTLS\n }),\n ignore_null_origin: options.ignoreNullOrigin\n });\n },\n beforeOpen: function(socket, path) {\n socket.send(\n JSON.stringify({\n path: path\n })\n );\n }\n});\n\nvar xdrConfiguration = {\n isSupported: function(environment): boolean {\n var yes = Runtime.isXDRSupported(environment.useTLS);\n return yes;\n }\n};\n\n/** HTTP streaming transport using XDomainRequest (IE 8,9). */\nvar XDRStreamingTransport = new Transport(\n (\n Collections.extend({}, streamingConfiguration, xdrConfiguration)\n )\n);\n\n/** HTTP long-polling transport using XDomainRequest (IE 8,9). */\nvar XDRPollingTransport = new Transport(\n Collections.extend({}, pollingConfiguration, xdrConfiguration)\n);\n\nTransports.xdr_streaming = XDRStreamingTransport;\nTransports.xdr_polling = XDRPollingTransport;\nTransports.sockjs = SockJSTransport;\n\nexport default Transports;\n","import Reachability from 'core/reachability';\nimport { default as EventsDispatcher } from 'core/events/dispatcher';\n\n/** Really basic interface providing network availability info.\n *\n * Emits:\n * - online - when browser goes online\n * - offline - when browser goes offline\n */\nexport class NetInfo extends EventsDispatcher implements Reachability {\n constructor() {\n super();\n var self = this;\n // This is okay, as IE doesn't support this stuff anyway.\n if (window.addEventListener !== undefined) {\n window.addEventListener(\n 'online',\n function() {\n self.emit('online');\n },\n false\n );\n window.addEventListener(\n 'offline',\n function() {\n self.emit('offline');\n },\n false\n );\n }\n }\n\n /** Returns whether browser is online or not\n *\n * Offline means definitely offline (no connection to router).\n * Inverse does NOT mean definitely online (only currently supported in Safari\n * and even there only means the device has a connection to the router).\n *\n * @return {Boolean}\n */\n isOnline(): boolean {\n if (window.navigator.onLine === undefined) {\n return true;\n } else {\n return window.navigator.onLine;\n }\n }\n}\n\nexport var Network = new NetInfo();\n","import Util from '../util';\nimport * as Collections from '../utils/collections';\nimport TransportManager from './transport_manager';\nimport TransportConnection from './transport_connection';\nimport Transport from './transport';\nimport PingDelayOptions from './ping_delay_options';\n\n/** Creates transport connections monitored by a transport manager.\n *\n * When a transport is closed, it might mean the environment does not support\n * it. It's possible that messages get stuck in an intermediate buffer or\n * proxies terminate inactive connections. To combat these problems,\n * assistants monitor the connection lifetime, report unclean exits and\n * adjust ping timeouts to keep the connection active. The decision to disable\n * a transport is the manager's responsibility.\n *\n * @param {TransportManager} manager\n * @param {TransportConnection} transport\n * @param {Object} options\n */\nexport default class AssistantToTheTransportManager {\n manager: TransportManager;\n transport: Transport;\n minPingDelay: number;\n maxPingDelay: number;\n pingDelay: number;\n\n constructor(\n manager: TransportManager,\n transport: Transport,\n options: PingDelayOptions\n ) {\n this.manager = manager;\n this.transport = transport;\n this.minPingDelay = options.minPingDelay;\n this.maxPingDelay = options.maxPingDelay;\n this.pingDelay = undefined;\n }\n\n /** Creates a transport connection.\n *\n * This function has the same API as Transport#createConnection.\n *\n * @param {String} name\n * @param {Number} priority\n * @param {String} key the application key\n * @param {Object} options\n * @returns {TransportConnection}\n */\n createConnection(\n name: string,\n priority: number,\n key: string,\n options: Object\n ): TransportConnection {\n options = Collections.extend({}, options, {\n activityTimeout: this.pingDelay\n });\n var connection = this.transport.createConnection(\n name,\n priority,\n key,\n options\n );\n\n var openTimestamp = null;\n\n var onOpen = function() {\n connection.unbind('open', onOpen);\n connection.bind('closed', onClosed);\n openTimestamp = Util.now();\n };\n var onClosed = closeEvent => {\n connection.unbind('closed', onClosed);\n\n if (closeEvent.code === 1002 || closeEvent.code === 1003) {\n // we don't want to use transports not obeying the protocol\n this.manager.reportDeath();\n } else if (!closeEvent.wasClean && openTimestamp) {\n // report deaths only for short-living transport\n var lifespan = Util.now() - openTimestamp;\n if (lifespan < 2 * this.maxPingDelay) {\n this.manager.reportDeath();\n this.pingDelay = Math.max(lifespan / 2, this.minPingDelay);\n }\n }\n };\n\n connection.bind('open', onOpen);\n return connection;\n }\n\n /** Returns whether the transport is supported in the environment.\n *\n * This function has the same API as Transport#isSupported. Might return false\n * when the manager decides to kill the transport.\n *\n * @param {Object} environment the environment details (encryption, settings)\n * @returns {Boolean} true when the transport is supported\n */\n isSupported(environment: string): boolean {\n return this.manager.isAlive() && this.transport.isSupported(environment);\n }\n}\n","import Action from './action';\nimport { PusherEvent } from './message-types';\n/**\n * Provides functions for handling Pusher protocol-specific messages.\n */\n\nconst Protocol = {\n /**\n * Decodes a message in a Pusher format.\n *\n * The MessageEvent we receive from the transport should contain a pusher event\n * (https://pusher.com/docs/pusher_protocol#events) serialized as JSON in the\n * data field\n *\n * The pusher event may contain a data field too, and it may also be\n * serialised as JSON\n *\n * Throws errors when messages are not parse'able.\n *\n * @param {MessageEvent} messageEvent\n * @return {PusherEvent}\n */\n decodeMessage: function(messageEvent: MessageEvent): PusherEvent {\n try {\n var messageData = JSON.parse(messageEvent.data);\n var pusherEventData = messageData.data;\n if (typeof pusherEventData === 'string') {\n try {\n pusherEventData = JSON.parse(messageData.data);\n } catch (e) {}\n }\n var pusherEvent: PusherEvent = {\n event: messageData.event,\n channel: messageData.channel,\n data: pusherEventData\n };\n if (messageData.user_id) {\n pusherEvent.user_id = messageData.user_id;\n }\n return pusherEvent;\n } catch (e) {\n throw { type: 'MessageParseError', error: e, data: messageEvent.data };\n }\n },\n\n /**\n * Encodes a message to be sent.\n *\n * @param {PusherEvent} event\n * @return {String}\n */\n encodeMessage: function(event: PusherEvent): string {\n return JSON.stringify(event);\n },\n\n /**\n * Processes a handshake message and returns appropriate actions.\n *\n * Returns an object with an 'action' and other action-specific properties.\n *\n * There are three outcomes when calling this function. First is a successful\n * connection attempt, when pusher:connection_established is received, which\n * results in a 'connected' action with an 'id' property. When passed a\n * pusher:error event, it returns a result with action appropriate to the\n * close code and an error. Otherwise, it raises an exception.\n *\n * @param {String} message\n * @result Object\n */\n processHandshake: function(messageEvent: MessageEvent): Action {\n var message = Protocol.decodeMessage(messageEvent);\n\n if (message.event === 'pusher:connection_established') {\n if (!message.data.activity_timeout) {\n throw 'No activity timeout specified in handshake';\n }\n return {\n action: 'connected',\n id: message.data.socket_id,\n activityTimeout: message.data.activity_timeout * 1000\n };\n } else if (message.event === 'pusher:error') {\n // From protocol 6 close codes are sent only once, so this only\n // happens when connection does not support close codes\n return {\n action: this.getCloseAction(message.data),\n error: this.getCloseError(message.data)\n };\n } else {\n throw 'Invalid handshake';\n }\n },\n\n /**\n * Dispatches the close event and returns an appropriate action name.\n *\n * See:\n * 1. https://developer.mozilla.org/en-US/docs/WebSockets/WebSockets_reference/CloseEvent\n * 2. http://pusher.com/docs/pusher_protocol\n *\n * @param {CloseEvent} closeEvent\n * @return {String} close action name\n */\n getCloseAction: function(closeEvent): string {\n if (closeEvent.code < 4000) {\n // ignore 1000 CLOSE_NORMAL, 1001 CLOSE_GOING_AWAY,\n // 1005 CLOSE_NO_STATUS, 1006 CLOSE_ABNORMAL\n // ignore 1007...3999\n // handle 1002 CLOSE_PROTOCOL_ERROR, 1003 CLOSE_UNSUPPORTED,\n // 1004 CLOSE_TOO_LARGE\n if (closeEvent.code >= 1002 && closeEvent.code <= 1004) {\n return 'backoff';\n } else {\n return null;\n }\n } else if (closeEvent.code === 4000) {\n return 'tls_only';\n } else if (closeEvent.code < 4100) {\n return 'refused';\n } else if (closeEvent.code < 4200) {\n return 'backoff';\n } else if (closeEvent.code < 4300) {\n return 'retry';\n } else {\n // unknown error\n return 'refused';\n }\n },\n\n /**\n * Returns an error or null basing on the close event.\n *\n * Null is returned when connection was closed cleanly. Otherwise, an object\n * with error details is returned.\n *\n * @param {CloseEvent} closeEvent\n * @return {Object} error object\n */\n getCloseError: function(closeEvent): any {\n if (closeEvent.code !== 1000 && closeEvent.code !== 1001) {\n return {\n type: 'PusherError',\n data: {\n code: closeEvent.code,\n message: closeEvent.reason || closeEvent.message\n }\n };\n } else {\n return null;\n }\n }\n};\n\nexport default Protocol;\n","import * as Collections from '../utils/collections';\nimport { default as EventsDispatcher } from '../events/dispatcher';\nimport Protocol from './protocol/protocol';\nimport { PusherEvent } from './protocol/message-types';\nimport Logger from '../logger';\nimport TransportConnection from '../transports/transport_connection';\nimport Socket from '../socket';\n/**\n * Provides Pusher protocol interface for transports.\n *\n * Emits following events:\n * - message - on received messages\n * - ping - on ping requests\n * - pong - on pong responses\n * - error - when the transport emits an error\n * - closed - after closing the transport\n *\n * It also emits more events when connection closes with a code.\n * See Protocol.getCloseAction to get more details.\n *\n * @param {Number} id\n * @param {AbstractTransport} transport\n */\nexport default class Connection extends EventsDispatcher implements Socket {\n id: string;\n transport: TransportConnection;\n activityTimeout: number;\n\n constructor(id: string, transport: TransportConnection) {\n super();\n this.id = id;\n this.transport = transport;\n this.activityTimeout = transport.activityTimeout;\n this.bindListeners();\n }\n\n /** Returns whether used transport handles activity checks by itself\n *\n * @returns {Boolean} true if activity checks are handled by the transport\n */\n handlesActivityChecks() {\n return this.transport.handlesActivityChecks();\n }\n\n /** Sends raw data.\n *\n * @param {String} data\n */\n send(data: any): boolean {\n return this.transport.send(data);\n }\n\n /** Sends an event.\n *\n * @param {String} name\n * @param {String} data\n * @param {String} [channel]\n * @returns {Boolean} whether message was sent or not\n */\n send_event(name: string, data: any, channel?: string): boolean {\n var event: PusherEvent = { event: name, data: data };\n if (channel) {\n event.channel = channel;\n }\n Logger.debug('Event sent', event);\n return this.send(Protocol.encodeMessage(event));\n }\n\n /** Sends a ping message to the server.\n *\n * Basing on the underlying transport, it might send either transport's\n * protocol-specific ping or pusher:ping event.\n */\n ping() {\n if (this.transport.supportsPing()) {\n this.transport.ping();\n } else {\n this.send_event('pusher:ping', {});\n }\n }\n\n /** Closes the connection. */\n close() {\n this.transport.close();\n }\n\n private bindListeners() {\n var listeners = {\n message: (messageEvent: MessageEvent) => {\n var pusherEvent;\n try {\n pusherEvent = Protocol.decodeMessage(messageEvent);\n } catch (e) {\n this.emit('error', {\n type: 'MessageParseError',\n error: e,\n data: messageEvent.data\n });\n }\n\n if (pusherEvent !== undefined) {\n Logger.debug('Event recd', pusherEvent);\n\n switch (pusherEvent.event) {\n case 'pusher:error':\n this.emit('error', {\n type: 'PusherError',\n data: pusherEvent.data\n });\n break;\n case 'pusher:ping':\n this.emit('ping');\n break;\n case 'pusher:pong':\n this.emit('pong');\n break;\n }\n this.emit('message', pusherEvent);\n }\n },\n activity: () => {\n this.emit('activity');\n },\n error: error => {\n this.emit('error', error);\n },\n closed: closeEvent => {\n unbindListeners();\n\n if (closeEvent && closeEvent.code) {\n this.handleCloseEvent(closeEvent);\n }\n\n this.transport = null;\n this.emit('closed');\n }\n };\n\n var unbindListeners = () => {\n Collections.objectApply(listeners, (listener, event) => {\n this.transport.unbind(event, listener);\n });\n };\n\n Collections.objectApply(listeners, (listener, event) => {\n this.transport.bind(event, listener);\n });\n }\n\n private handleCloseEvent(closeEvent: any) {\n var action = Protocol.getCloseAction(closeEvent);\n var error = Protocol.getCloseError(closeEvent);\n if (error) {\n this.emit('error', error);\n }\n if (action) {\n this.emit(action, { action: action, error: error });\n }\n }\n}\n","import Util from '../../util';\nimport * as Collections from '../../utils/collections';\nimport Protocol from '../protocol/protocol';\nimport Connection from '../connection';\nimport TransportConnection from '../../transports/transport_connection';\nimport HandshakePayload from './handshake_payload';\n\n/**\n * Handles Pusher protocol handshakes for transports.\n *\n * Calls back with a result object after handshake is completed. Results\n * always have two fields:\n * - action - string describing action to be taken after the handshake\n * - transport - the transport object passed to the constructor\n *\n * Different actions can set different additional properties on the result.\n * In the case of 'connected' action, there will be a 'connection' property\n * containing a Connection object for the transport. Other actions should\n * carry an 'error' property.\n *\n * @param {AbstractTransport} transport\n * @param {Function} callback\n */\nexport default class Handshake {\n transport: TransportConnection;\n callback: (HandshakePayload) => void;\n onMessage: Function;\n onClosed: Function;\n\n constructor(\n transport: TransportConnection,\n callback: (HandshakePayload) => void\n ) {\n this.transport = transport;\n this.callback = callback;\n this.bindListeners();\n }\n\n close() {\n this.unbindListeners();\n this.transport.close();\n }\n\n private bindListeners() {\n this.onMessage = m => {\n this.unbindListeners();\n\n var result;\n try {\n result = Protocol.processHandshake(m);\n } catch (e) {\n this.finish('error', { error: e });\n this.transport.close();\n return;\n }\n\n if (result.action === 'connected') {\n this.finish('connected', {\n connection: new Connection(result.id, this.transport),\n activityTimeout: result.activityTimeout\n });\n } else {\n this.finish(result.action, { error: result.error });\n this.transport.close();\n }\n };\n\n this.onClosed = closeEvent => {\n this.unbindListeners();\n\n var action = Protocol.getCloseAction(closeEvent) || 'backoff';\n var error = Protocol.getCloseError(closeEvent);\n this.finish(action, { error: error });\n };\n\n this.transport.bind('message', this.onMessage);\n this.transport.bind('closed', this.onClosed);\n }\n\n private unbindListeners() {\n this.transport.unbind('message', this.onMessage);\n this.transport.unbind('closed', this.onClosed);\n }\n\n private finish(action: string, params: any) {\n this.callback(\n Collections.extend({ transport: this.transport, action: action }, params)\n );\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport base64encode from '../base64';\nimport Timeline from './timeline';\nimport Runtime from 'runtime';\n\nexport interface TimelineSenderOptions {\n host?: string;\n port?: number;\n path?: string;\n}\n\nexport default class TimelineSender {\n timeline: Timeline;\n options: TimelineSenderOptions;\n host: string;\n\n constructor(timeline: Timeline, options: TimelineSenderOptions) {\n this.timeline = timeline;\n this.options = options || {};\n }\n\n send(useTLS: boolean, callback?: Function) {\n if (this.timeline.isEmpty()) {\n return;\n }\n\n this.timeline.send(\n Runtime.TimelineTransport.getAgent(this, useTLS),\n callback\n );\n }\n}\n","import { default as EventsDispatcher } from '../events/dispatcher';\nimport * as Errors from '../errors';\nimport Logger from '../logger';\nimport Pusher from '../pusher';\nimport { PusherEvent } from '../connection/protocol/message-types';\nimport Metadata from './metadata';\nimport UrlStore from '../utils/url_store';\nimport {\n ChannelAuthorizationData,\n ChannelAuthorizationCallback\n} from '../auth/options';\nimport { HTTPAuthError } from '../errors';\n\n/** Provides base public channel interface with an event emitter.\n *\n * Emits:\n * - pusher:subscription_succeeded - after subscribing successfully\n * - other non-internal events\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\nexport default class Channel extends EventsDispatcher {\n name: string;\n pusher: Pusher;\n subscribed: boolean;\n subscriptionPending: boolean;\n subscriptionCancelled: boolean;\n subscriptionCount: null;\n\n constructor(name: string, pusher: Pusher) {\n super(function(event, data) {\n Logger.debug('No callbacks on ' + name + ' for ' + event);\n });\n\n this.name = name;\n this.pusher = pusher;\n this.subscribed = false;\n this.subscriptionPending = false;\n this.subscriptionCancelled = false;\n }\n\n /** Skips authorization, since public channels don't require it.\n *\n * @param {Function} callback\n */\n authorize(socketId: string, callback: ChannelAuthorizationCallback) {\n return callback(null, { auth: '' });\n }\n\n /** Triggers an event */\n trigger(event: string, data: any) {\n if (event.indexOf('client-') !== 0) {\n throw new Errors.BadEventName(\n \"Event '\" + event + \"' does not start with 'client-'\"\n );\n }\n if (!this.subscribed) {\n var suffix = UrlStore.buildLogSuffix('triggeringClientEvents');\n Logger.warn(\n `Client event triggered before channel 'subscription_succeeded' event . ${suffix}`\n );\n }\n return this.pusher.send_event(event, data, this.name);\n }\n\n /** Signals disconnection to the channel. For internal use only. */\n disconnect() {\n this.subscribed = false;\n this.subscriptionPending = false;\n }\n\n /** Handles a PusherEvent. For internal use only.\n *\n * @param {PusherEvent} event\n */\n handleEvent(event: PusherEvent) {\n var eventName = event.event;\n var data = event.data;\n if (eventName === 'pusher_internal:subscription_succeeded') {\n this.handleSubscriptionSucceededEvent(event);\n } else if (eventName === 'pusher_internal:subscription_count') {\n this.handleSubscriptionCountEvent(event);\n } else if (eventName.indexOf('pusher_internal:') !== 0) {\n var metadata: Metadata = {};\n this.emit(eventName, data, metadata);\n }\n }\n\n handleSubscriptionSucceededEvent(event: PusherEvent) {\n this.subscriptionPending = false;\n this.subscribed = true;\n if (this.subscriptionCancelled) {\n this.pusher.unsubscribe(this.name);\n } else {\n this.emit('pusher:subscription_succeeded', event.data);\n }\n }\n\n handleSubscriptionCountEvent(event: PusherEvent) {\n if (event.data.subscription_count) {\n this.subscriptionCount = event.data.subscription_count;\n }\n\n this.emit('pusher:subscription_count', event.data);\n }\n\n /** Sends a subscription request. For internal use only. */\n subscribe() {\n if (this.subscribed) {\n return;\n }\n this.subscriptionPending = true;\n this.subscriptionCancelled = false;\n this.authorize(\n this.pusher.connection.socket_id,\n (error: Error | null, data: ChannelAuthorizationData) => {\n if (error) {\n this.subscriptionPending = false;\n // Why not bind to 'pusher:subscription_error' a level up, and log there?\n // Binding to this event would cause the warning about no callbacks being\n // bound (see constructor) to be suppressed, that's not what we want.\n Logger.error(error.toString());\n this.emit(\n 'pusher:subscription_error',\n Object.assign(\n {},\n {\n type: 'AuthError',\n error: error.message\n },\n error instanceof HTTPAuthError ? { status: error.status } : {}\n )\n );\n } else {\n this.pusher.send_event('pusher:subscribe', {\n auth: data.auth,\n channel_data: data.channel_data,\n channel: this.name\n });\n }\n }\n );\n }\n\n /** Sends an unsubscription request. For internal use only. */\n unsubscribe() {\n this.subscribed = false;\n this.pusher.send_event('pusher:unsubscribe', {\n channel: this.name\n });\n }\n\n /** Cancels an in progress subscription. For internal use only. */\n cancelSubscription() {\n this.subscriptionCancelled = true;\n }\n\n /** Reinstates an in progress subscripiton. For internal use only. */\n reinstateSubscription() {\n this.subscriptionCancelled = false;\n }\n}\n","import Factory from '../utils/factory';\nimport Channel from './channel';\nimport { ChannelAuthorizationCallback } from '../auth/options';\n\n/** Extends public channels to provide private channel interface.\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\nexport default class PrivateChannel extends Channel {\n /** Authorizes the connection to use the channel.\n *\n * @param {String} socketId\n * @param {Function} callback\n */\n authorize(socketId: string, callback: ChannelAuthorizationCallback) {\n return this.pusher.config.channelAuthorizer(\n {\n channelName: this.name,\n socketId: socketId\n },\n callback\n );\n }\n}\n","import * as Collections from '../utils/collections';\n\n/** Represents a collection of members of a presence channel. */\nexport default class Members {\n members: any;\n count: number;\n myID: any;\n me: any;\n\n constructor() {\n this.reset();\n }\n\n /** Returns member's info for given id.\n *\n * Resulting object containts two fields - id and info.\n *\n * @param {Number} id\n * @return {Object} member's info or null\n */\n get(id: string): any {\n if (Object.prototype.hasOwnProperty.call(this.members, id)) {\n return {\n id: id,\n info: this.members[id]\n };\n } else {\n return null;\n }\n }\n\n /** Calls back for each member in unspecified order.\n *\n * @param {Function} callback\n */\n each(callback: Function) {\n Collections.objectApply(this.members, (member, id) => {\n callback(this.get(id));\n });\n }\n\n /** Updates the id for connected member. For internal use only. */\n setMyID(id: string) {\n this.myID = id;\n }\n\n /** Handles subscription data. For internal use only. */\n onSubscription(subscriptionData: any) {\n this.members = subscriptionData.presence.hash;\n this.count = subscriptionData.presence.count;\n this.me = this.get(this.myID);\n }\n\n /** Adds a new member to the collection. For internal use only. */\n addMember(memberData: any) {\n if (this.get(memberData.user_id) === null) {\n this.count++;\n }\n this.members[memberData.user_id] = memberData.user_info;\n return this.get(memberData.user_id);\n }\n\n /** Adds a member from the collection. For internal use only. */\n removeMember(memberData: any) {\n var member = this.get(memberData.user_id);\n if (member) {\n delete this.members[memberData.user_id];\n this.count--;\n }\n return member;\n }\n\n /** Resets the collection to the initial state. For internal use only. */\n reset() {\n this.members = {};\n this.count = 0;\n this.myID = null;\n this.me = null;\n }\n}\n","import PrivateChannel from './private_channel';\nimport Logger from '../logger';\nimport Members from './members';\nimport Pusher from '../pusher';\nimport UrlStore from 'core/utils/url_store';\nimport { PusherEvent } from '../connection/protocol/message-types';\nimport Metadata from './metadata';\nimport { ChannelAuthorizationData } from '../auth/options';\n\nexport default class PresenceChannel extends PrivateChannel {\n members: Members;\n\n /** Adds presence channel functionality to private channels.\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\n constructor(name: string, pusher: Pusher) {\n super(name, pusher);\n this.members = new Members();\n }\n\n /** Authorizes the connection as a member of the channel.\n *\n * @param {String} socketId\n * @param {Function} callback\n */\n authorize(socketId: string, callback: Function) {\n super.authorize(socketId, async (error, authData) => {\n if (!error) {\n authData = authData as ChannelAuthorizationData;\n if (authData.channel_data != null) {\n var channelData = JSON.parse(authData.channel_data);\n this.members.setMyID(channelData.user_id);\n } else {\n await this.pusher.user.signinDonePromise;\n if (this.pusher.user.user_data != null) {\n // If the user is signed in, get the id of the authenticated user\n // and allow the presence authorization to continue.\n this.members.setMyID(this.pusher.user.user_data.id);\n } else {\n let suffix = UrlStore.buildLogSuffix('authorizationEndpoint');\n Logger.error(\n `Invalid auth response for channel '${this.name}', ` +\n `expected 'channel_data' field. ${suffix}, ` +\n `or the user should be signed in.`\n );\n callback('Invalid auth response');\n return;\n }\n }\n }\n callback(error, authData);\n });\n }\n\n /** Handles presence and subscription events. For internal use only.\n *\n * @param {PusherEvent} event\n */\n handleEvent(event: PusherEvent) {\n var eventName = event.event;\n if (eventName.indexOf('pusher_internal:') === 0) {\n this.handleInternalEvent(event);\n } else {\n var data = event.data;\n var metadata: Metadata = {};\n if (event.user_id) {\n metadata.user_id = event.user_id;\n }\n this.emit(eventName, data, metadata);\n }\n }\n handleInternalEvent(event: PusherEvent) {\n var eventName = event.event;\n var data = event.data;\n switch (eventName) {\n case 'pusher_internal:subscription_succeeded':\n this.handleSubscriptionSucceededEvent(event);\n break;\n case 'pusher_internal:subscription_count':\n this.handleSubscriptionCountEvent(event);\n break;\n case 'pusher_internal:member_added':\n var addedMember = this.members.addMember(data);\n this.emit('pusher:member_added', addedMember);\n break;\n case 'pusher_internal:member_removed':\n var removedMember = this.members.removeMember(data);\n if (removedMember) {\n this.emit('pusher:member_removed', removedMember);\n }\n break;\n }\n }\n\n handleSubscriptionSucceededEvent(event: PusherEvent) {\n this.subscriptionPending = false;\n this.subscribed = true;\n if (this.subscriptionCancelled) {\n this.pusher.unsubscribe(this.name);\n } else {\n this.members.onSubscription(event.data);\n this.emit('pusher:subscription_succeeded', this.members);\n }\n }\n\n /** Resets the channel state, including members map. For internal use only. */\n disconnect() {\n this.members.reset();\n super.disconnect();\n }\n}\n","import PrivateChannel from './private_channel';\nimport * as Errors from '../errors';\nimport Logger from '../logger';\nimport Pusher from '../pusher';\nimport { decode as encodeUTF8 } from '@stablelib/utf8';\nimport { decode as decodeBase64 } from '@stablelib/base64';\nimport Dispatcher from '../events/dispatcher';\nimport { PusherEvent } from '../connection/protocol/message-types';\nimport {\n ChannelAuthorizationData,\n ChannelAuthorizationCallback\n} from '../auth/options';\nimport * as nacl from 'tweetnacl';\n\n/** Extends private channels to provide encrypted channel interface.\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\nexport default class EncryptedChannel extends PrivateChannel {\n key: Uint8Array = null;\n nacl: nacl;\n\n constructor(name: string, pusher: Pusher, nacl: nacl) {\n super(name, pusher);\n this.nacl = nacl;\n }\n\n /** Authorizes the connection to use the channel.\n *\n * @param {String} socketId\n * @param {Function} callback\n */\n authorize(socketId: string, callback: ChannelAuthorizationCallback) {\n super.authorize(\n socketId,\n (error: Error | null, authData: ChannelAuthorizationData) => {\n if (error) {\n callback(error, authData);\n return;\n }\n let sharedSecret = authData['shared_secret'];\n if (!sharedSecret) {\n callback(\n new Error(\n `No shared_secret key in auth payload for encrypted channel: ${this.name}`\n ),\n null\n );\n return;\n }\n this.key = decodeBase64(sharedSecret);\n delete authData['shared_secret'];\n callback(null, authData);\n }\n );\n }\n\n trigger(event: string, data: any): boolean {\n throw new Errors.UnsupportedFeature(\n 'Client events are not currently supported for encrypted channels'\n );\n }\n\n /** Handles an event. For internal use only.\n *\n * @param {PusherEvent} event\n */\n handleEvent(event: PusherEvent) {\n var eventName = event.event;\n var data = event.data;\n if (\n eventName.indexOf('pusher_internal:') === 0 ||\n eventName.indexOf('pusher:') === 0\n ) {\n super.handleEvent(event);\n return;\n }\n this.handleEncryptedEvent(eventName, data);\n }\n\n private handleEncryptedEvent(event: string, data: any): void {\n if (!this.key) {\n Logger.debug(\n 'Received encrypted event before key has been retrieved from the authEndpoint'\n );\n return;\n }\n if (!data.ciphertext || !data.nonce) {\n Logger.error(\n 'Unexpected format for encrypted event, expected object with `ciphertext` and `nonce` fields, got: ' +\n data\n );\n return;\n }\n let cipherText = decodeBase64(data.ciphertext);\n if (cipherText.length < this.nacl.secretbox.overheadLength) {\n Logger.error(\n `Expected encrypted event ciphertext length to be ${this.nacl.secretbox.overheadLength}, got: ${cipherText.length}`\n );\n return;\n }\n let nonce = decodeBase64(data.nonce);\n if (nonce.length < this.nacl.secretbox.nonceLength) {\n Logger.error(\n `Expected encrypted event nonce length to be ${this.nacl.secretbox.nonceLength}, got: ${nonce.length}`\n );\n return;\n }\n\n let bytes = this.nacl.secretbox.open(cipherText, nonce, this.key);\n if (bytes === null) {\n Logger.debug(\n 'Failed to decrypt an event, probably because it was encrypted with a different key. Fetching a new key from the authEndpoint...'\n );\n // Try a single time to retrieve a new auth key and decrypt the event with it\n // If this fails, a new key will be requested when a new message is received\n this.authorize(this.pusher.connection.socket_id, (error, authData) => {\n if (error) {\n Logger.error(\n `Failed to make a request to the authEndpoint: ${authData}. Unable to fetch new key, so dropping encrypted event`\n );\n return;\n }\n bytes = this.nacl.secretbox.open(cipherText, nonce, this.key);\n if (bytes === null) {\n Logger.error(\n `Failed to decrypt event with new key. Dropping encrypted event`\n );\n return;\n }\n this.emit(event, this.getDataToEmit(bytes));\n return;\n });\n return;\n }\n this.emit(event, this.getDataToEmit(bytes));\n }\n\n // Try and parse the decrypted bytes as JSON. If we can't parse it, just\n // return the utf-8 string\n getDataToEmit(bytes: Uint8Array): string {\n let raw = encodeUTF8(bytes);\n try {\n return JSON.parse(raw);\n } catch {\n return raw;\n }\n }\n}\n","import { default as EventsDispatcher } from '../events/dispatcher';\nimport { OneOffTimer as Timer } from '../utils/timers';\nimport { Config } from '../config';\nimport Logger from '../logger';\nimport HandshakePayload from './handshake/handshake_payload';\nimport Connection from './connection';\nimport Strategy from '../strategies/strategy';\nimport StrategyRunner from '../strategies/strategy_runner';\nimport * as Collections from '../utils/collections';\nimport Timeline from '../timeline/timeline';\nimport ConnectionManagerOptions from './connection_manager_options';\nimport Runtime from 'runtime';\n\nimport {\n ErrorCallbacks,\n HandshakeCallbacks,\n ConnectionCallbacks\n} from './callbacks';\nimport Action from './protocol/action';\n\n/** Manages connection to Pusher.\n *\n * Uses a strategy (currently only default), timers and network availability\n * info to establish a connection and export its state. In case of failures,\n * manages reconnection attempts.\n *\n * Exports state changes as following events:\n * - \"state_change\", { previous: p, current: state }\n * - state\n *\n * States:\n * - initialized - initial state, never transitioned to\n * - connecting - connection is being established\n * - connected - connection has been fully established\n * - disconnected - on requested disconnection\n * - unavailable - after connection timeout or when there's no network\n * - failed - when the connection strategy is not supported\n *\n * Options:\n * - unavailableTimeout - time to transition to unavailable state\n * - activityTimeout - time after which ping message should be sent\n * - pongTimeout - time for Pusher to respond with pong before reconnecting\n *\n * @param {String} key application key\n * @param {Object} options\n */\nexport default class ConnectionManager extends EventsDispatcher {\n key: string;\n options: ConnectionManagerOptions;\n state: string;\n connection: Connection;\n usingTLS: boolean;\n timeline: Timeline;\n socket_id: string;\n unavailableTimer: Timer;\n activityTimer: Timer;\n retryTimer: Timer;\n activityTimeout: number;\n strategy: Strategy;\n runner: StrategyRunner;\n errorCallbacks: ErrorCallbacks;\n handshakeCallbacks: HandshakeCallbacks;\n connectionCallbacks: ConnectionCallbacks;\n\n constructor(key: string, options: ConnectionManagerOptions) {\n super();\n this.state = 'initialized';\n this.connection = null;\n\n this.key = key;\n this.options = options;\n this.timeline = this.options.timeline;\n this.usingTLS = this.options.useTLS;\n\n this.errorCallbacks = this.buildErrorCallbacks();\n this.connectionCallbacks = this.buildConnectionCallbacks(\n this.errorCallbacks\n );\n this.handshakeCallbacks = this.buildHandshakeCallbacks(this.errorCallbacks);\n\n var Network = Runtime.getNetwork();\n\n Network.bind('online', () => {\n this.timeline.info({ netinfo: 'online' });\n if (this.state === 'connecting' || this.state === 'unavailable') {\n this.retryIn(0);\n }\n });\n Network.bind('offline', () => {\n this.timeline.info({ netinfo: 'offline' });\n if (this.connection) {\n this.sendActivityCheck();\n }\n });\n\n this.updateStrategy();\n }\n\n switchCluster(key: string) {\n this.key = key;\n // This ensures that the new config coming from\n // pusher instance are taken into account\n // such as appKey and cluster\n this.updateStrategy();\n this.retryIn(0);\n }\n\n /** Establishes a connection to Pusher.\n *\n * Does nothing when connection is already established. See top-level doc\n * to find events emitted on connection attempts.\n */\n connect() {\n if (this.connection || this.runner) {\n return;\n }\n if (!this.strategy.isSupported()) {\n this.updateState('failed');\n return;\n }\n this.updateState('connecting');\n this.startConnecting();\n this.setUnavailableTimer();\n }\n\n /** Sends raw data.\n *\n * @param {String} data\n */\n send(data) {\n if (this.connection) {\n return this.connection.send(data);\n } else {\n return false;\n }\n }\n\n /** Sends an event.\n *\n * @param {String} name\n * @param {String} data\n * @param {String} [channel]\n * @returns {Boolean} whether message was sent or not\n */\n send_event(name: string, data: any, channel?: string) {\n if (this.connection) {\n return this.connection.send_event(name, data, channel);\n } else {\n return false;\n }\n }\n\n /** Closes the connection. */\n disconnect() {\n this.disconnectInternally();\n this.updateState('disconnected');\n }\n\n isUsingTLS() {\n return this.usingTLS;\n }\n\n private startConnecting() {\n var callback = (error, handshake) => {\n if (error) {\n this.runner = this.strategy.connect(0, callback);\n } else {\n if (handshake.action === 'error') {\n this.emit('error', {\n type: 'HandshakeError',\n error: handshake.error\n });\n this.timeline.error({ handshakeError: handshake.error });\n } else {\n this.abortConnecting(); // we don't support switching connections yet\n this.handshakeCallbacks[handshake.action](handshake);\n }\n }\n };\n this.runner = this.strategy.connect(0, callback);\n }\n\n private abortConnecting() {\n if (this.runner) {\n this.runner.abort();\n this.runner = null;\n }\n }\n\n private disconnectInternally() {\n this.abortConnecting();\n this.clearRetryTimer();\n this.clearUnavailableTimer();\n if (this.connection) {\n var connection = this.abandonConnection();\n connection.close();\n }\n }\n\n private updateStrategy() {\n this.strategy = this.options.getStrategy({\n key: this.key,\n timeline: this.timeline,\n useTLS: this.usingTLS\n });\n }\n\n private retryIn(delay) {\n this.timeline.info({ action: 'retry', delay: delay });\n if (delay > 0) {\n this.emit('connecting_in', Math.round(delay / 1000));\n }\n this.retryTimer = new Timer(delay || 0, () => {\n this.disconnectInternally();\n this.connect();\n });\n }\n\n private clearRetryTimer() {\n if (this.retryTimer) {\n this.retryTimer.ensureAborted();\n this.retryTimer = null;\n }\n }\n\n private setUnavailableTimer() {\n this.unavailableTimer = new Timer(this.options.unavailableTimeout, () => {\n this.updateState('unavailable');\n });\n }\n\n private clearUnavailableTimer() {\n if (this.unavailableTimer) {\n this.unavailableTimer.ensureAborted();\n }\n }\n\n private sendActivityCheck() {\n this.stopActivityCheck();\n this.connection.ping();\n // wait for pong response\n this.activityTimer = new Timer(this.options.pongTimeout, () => {\n this.timeline.error({ pong_timed_out: this.options.pongTimeout });\n this.retryIn(0);\n });\n }\n\n private resetActivityCheck() {\n this.stopActivityCheck();\n // send ping after inactivity\n if (this.connection && !this.connection.handlesActivityChecks()) {\n this.activityTimer = new Timer(this.activityTimeout, () => {\n this.sendActivityCheck();\n });\n }\n }\n\n private stopActivityCheck() {\n if (this.activityTimer) {\n this.activityTimer.ensureAborted();\n }\n }\n\n private buildConnectionCallbacks(\n errorCallbacks: ErrorCallbacks\n ): ConnectionCallbacks {\n return Collections.extend({}, errorCallbacks, {\n message: message => {\n // includes pong messages from server\n this.resetActivityCheck();\n this.emit('message', message);\n },\n ping: () => {\n this.send_event('pusher:pong', {});\n },\n activity: () => {\n this.resetActivityCheck();\n },\n error: error => {\n // just emit error to user - socket will already be closed by browser\n this.emit('error', error);\n },\n closed: () => {\n this.abandonConnection();\n if (this.shouldRetry()) {\n this.retryIn(1000);\n }\n }\n });\n }\n\n private buildHandshakeCallbacks(\n errorCallbacks: ErrorCallbacks\n ): HandshakeCallbacks {\n return Collections.extend({}, errorCallbacks, {\n connected: (handshake: HandshakePayload) => {\n this.activityTimeout = Math.min(\n this.options.activityTimeout,\n handshake.activityTimeout,\n handshake.connection.activityTimeout || Infinity\n );\n this.clearUnavailableTimer();\n this.setConnection(handshake.connection);\n this.socket_id = this.connection.id;\n this.updateState('connected', { socket_id: this.socket_id });\n }\n });\n }\n\n private buildErrorCallbacks(): ErrorCallbacks {\n let withErrorEmitted = callback => {\n return (result: Action | HandshakePayload) => {\n if (result.error) {\n this.emit('error', { type: 'WebSocketError', error: result.error });\n }\n callback(result);\n };\n };\n\n return {\n tls_only: withErrorEmitted(() => {\n this.usingTLS = true;\n this.updateStrategy();\n this.retryIn(0);\n }),\n refused: withErrorEmitted(() => {\n this.disconnect();\n }),\n backoff: withErrorEmitted(() => {\n this.retryIn(1000);\n }),\n retry: withErrorEmitted(() => {\n this.retryIn(0);\n })\n };\n }\n\n private setConnection(connection) {\n this.connection = connection;\n for (var event in this.connectionCallbacks) {\n this.connection.bind(event, this.connectionCallbacks[event]);\n }\n this.resetActivityCheck();\n }\n\n private abandonConnection() {\n if (!this.connection) {\n return;\n }\n this.stopActivityCheck();\n for (var event in this.connectionCallbacks) {\n this.connection.unbind(event, this.connectionCallbacks[event]);\n }\n var connection = this.connection;\n this.connection = null;\n return connection;\n }\n\n private updateState(newState: string, data?: any) {\n var previousState = this.state;\n this.state = newState;\n if (previousState !== newState) {\n var newStateDescription = newState;\n if (newStateDescription === 'connected') {\n newStateDescription += ' with new socket ID ' + data.socket_id;\n }\n Logger.debug(\n 'State changed',\n previousState + ' -> ' + newStateDescription\n );\n this.timeline.info({ state: newState, params: data });\n this.emit('state_change', { previous: previousState, current: newState });\n this.emit(newState, data);\n }\n }\n\n private shouldRetry(): boolean {\n return this.state === 'connecting' || this.state === 'connected';\n }\n}\n","import Channel from './channel';\nimport * as Collections from '../utils/collections';\nimport ChannelTable from './channel_table';\nimport Factory from '../utils/factory';\nimport Pusher from '../pusher';\nimport Logger from '../logger';\nimport * as Errors from '../errors';\nimport urlStore from '../utils/url_store';\n\n/** Handles a channel map. */\nexport default class Channels {\n channels: ChannelTable;\n\n constructor() {\n this.channels = {};\n }\n\n /** Creates or retrieves an existing channel by its name.\n *\n * @param {String} name\n * @param {Pusher} pusher\n * @return {Channel}\n */\n add(name: string, pusher: Pusher) {\n if (!this.channels[name]) {\n this.channels[name] = createChannel(name, pusher);\n }\n return this.channels[name];\n }\n\n /** Returns a list of all channels\n *\n * @return {Array}\n */\n all(): Channel[] {\n return Collections.values(this.channels);\n }\n\n /** Finds a channel by its name.\n *\n * @param {String} name\n * @return {Channel} channel or null if it doesn't exist\n */\n find(name: string) {\n return this.channels[name];\n }\n\n /** Removes a channel from the map.\n *\n * @param {String} name\n */\n remove(name: string) {\n var channel = this.channels[name];\n delete this.channels[name];\n return channel;\n }\n\n /** Proxies disconnection signal to all channels. */\n disconnect() {\n Collections.objectApply(this.channels, function(channel) {\n channel.disconnect();\n });\n }\n}\n\nfunction createChannel(name: string, pusher: Pusher): Channel {\n if (name.indexOf('private-encrypted-') === 0) {\n if (pusher.config.nacl) {\n return Factory.createEncryptedChannel(name, pusher, pusher.config.nacl);\n }\n let errMsg =\n 'Tried to subscribe to a private-encrypted- channel but no nacl implementation available';\n let suffix = urlStore.buildLogSuffix('encryptedChannelSupport');\n throw new Errors.UnsupportedFeature(`${errMsg}. ${suffix}`);\n } else if (name.indexOf('private-') === 0) {\n return Factory.createPrivateChannel(name, pusher);\n } else if (name.indexOf('presence-') === 0) {\n return Factory.createPresenceChannel(name, pusher);\n } else if (name.indexOf('#') === 0) {\n throw new Errors.BadChannelName(\n 'Cannot create a channel with name \"' + name + '\".'\n );\n } else {\n return Factory.createChannel(name, pusher);\n }\n}\n","import AssistantToTheTransportManager from '../transports/assistant_to_the_transport_manager';\nimport PingDelayOptions from '../transports/ping_delay_options';\nimport Transport from '../transports/transport';\nimport TransportManager from '../transports/transport_manager';\nimport Handshake from '../connection/handshake';\nimport TransportConnection from '../transports/transport_connection';\nimport SocketHooks from '../http/socket_hooks';\nimport HTTPSocket from '../http/http_socket';\n\nimport Timeline from '../timeline/timeline';\nimport {\n default as TimelineSender,\n TimelineSenderOptions\n} from '../timeline/timeline_sender';\nimport PresenceChannel from '../channels/presence_channel';\nimport PrivateChannel from '../channels/private_channel';\nimport EncryptedChannel from '../channels/encrypted_channel';\nimport Channel from '../channels/channel';\nimport ConnectionManager from '../connection/connection_manager';\nimport ConnectionManagerOptions from '../connection/connection_manager_options';\nimport Ajax from '../http/ajax';\nimport Channels from '../channels/channels';\nimport Pusher from '../pusher';\nimport { Config } from '../config';\nimport * as nacl from 'tweetnacl';\n\nvar Factory = {\n createChannels(): Channels {\n return new Channels();\n },\n\n createConnectionManager(\n key: string,\n options: ConnectionManagerOptions\n ): ConnectionManager {\n return new ConnectionManager(key, options);\n },\n\n createChannel(name: string, pusher: Pusher): Channel {\n return new Channel(name, pusher);\n },\n\n createPrivateChannel(name: string, pusher: Pusher): PrivateChannel {\n return new PrivateChannel(name, pusher);\n },\n\n createPresenceChannel(name: string, pusher: Pusher): PresenceChannel {\n return new PresenceChannel(name, pusher);\n },\n\n createEncryptedChannel(\n name: string,\n pusher: Pusher,\n nacl: nacl\n ): EncryptedChannel {\n return new EncryptedChannel(name, pusher, nacl);\n },\n\n createTimelineSender(timeline: Timeline, options: TimelineSenderOptions) {\n return new TimelineSender(timeline, options);\n },\n\n createHandshake(\n transport: TransportConnection,\n callback: (HandshakePayload) => void\n ): Handshake {\n return new Handshake(transport, callback);\n },\n\n createAssistantToTheTransportManager(\n manager: TransportManager,\n transport: Transport,\n options: PingDelayOptions\n ): AssistantToTheTransportManager {\n return new AssistantToTheTransportManager(manager, transport, options);\n }\n};\n\nexport default Factory;\n","import AssistantToTheTransportManager from './assistant_to_the_transport_manager';\nimport Transport from './transport';\nimport PingDelayOptions from './ping_delay_options';\nimport Factory from '../utils/factory';\n\nexport interface TransportManagerOptions extends PingDelayOptions {\n lives?: number;\n}\n\n/** Keeps track of the number of lives left for a transport.\n *\n * In the beginning of a session, transports may be assigned a number of\n * lives. When an AssistantToTheTransportManager instance reports a transport\n * connection closed uncleanly, the transport loses a life. When the number\n * of lives drops to zero, the transport gets disabled by its manager.\n *\n * @param {Object} options\n */\nexport default class TransportManager {\n options: TransportManagerOptions;\n livesLeft: number;\n\n constructor(options: TransportManagerOptions) {\n this.options = options || {};\n this.livesLeft = this.options.lives || Infinity;\n }\n\n /** Creates a assistant for the transport.\n *\n * @param {Transport} transport\n * @returns {AssistantToTheTransportManager}\n */\n getAssistant(transport: Transport): AssistantToTheTransportManager {\n return Factory.createAssistantToTheTransportManager(this, transport, {\n minPingDelay: this.options.minPingDelay,\n maxPingDelay: this.options.maxPingDelay\n });\n }\n\n /** Returns whether the transport has any lives left.\n *\n * @returns {Boolean}\n */\n isAlive(): boolean {\n return this.livesLeft > 0;\n }\n\n /** Takes one life from the transport. */\n reportDeath() {\n this.livesLeft -= 1;\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport { OneOffTimer as Timer } from '../utils/timers';\nimport Strategy from './strategy';\nimport StrategyOptions from './strategy_options';\n\n/** Loops through strategies with optional timeouts.\n *\n * Options:\n * - loop - whether it should loop through the substrategy list\n * - timeout - initial timeout for a single substrategy\n * - timeoutLimit - maximum timeout\n *\n * @param {Strategy[]} strategies\n * @param {Object} options\n */\nexport default class SequentialStrategy implements Strategy {\n strategies: Strategy[];\n loop: boolean;\n failFast: boolean;\n timeout: number;\n timeoutLimit: number;\n\n constructor(strategies: Strategy[], options: StrategyOptions) {\n this.strategies = strategies;\n this.loop = Boolean(options.loop);\n this.failFast = Boolean(options.failFast);\n this.timeout = options.timeout;\n this.timeoutLimit = options.timeoutLimit;\n }\n\n isSupported(): boolean {\n return Collections.any(this.strategies, Util.method('isSupported'));\n }\n\n connect(minPriority: number, callback: Function) {\n var strategies = this.strategies;\n var current = 0;\n var timeout = this.timeout;\n var runner = null;\n\n var tryNextStrategy = (error, handshake) => {\n if (handshake) {\n callback(null, handshake);\n } else {\n current = current + 1;\n if (this.loop) {\n current = current % strategies.length;\n }\n\n if (current < strategies.length) {\n if (timeout) {\n timeout = timeout * 2;\n if (this.timeoutLimit) {\n timeout = Math.min(timeout, this.timeoutLimit);\n }\n }\n runner = this.tryStrategy(\n strategies[current],\n minPriority,\n { timeout, failFast: this.failFast },\n tryNextStrategy\n );\n } else {\n callback(true);\n }\n }\n };\n\n runner = this.tryStrategy(\n strategies[current],\n minPriority,\n { timeout: timeout, failFast: this.failFast },\n tryNextStrategy\n );\n\n return {\n abort: function() {\n runner.abort();\n },\n forceMinPriority: function(p) {\n minPriority = p;\n if (runner) {\n runner.forceMinPriority(p);\n }\n }\n };\n }\n\n private tryStrategy(\n strategy: Strategy,\n minPriority: number,\n options: StrategyOptions,\n callback: Function\n ) {\n var timer = null;\n var runner = null;\n\n if (options.timeout > 0) {\n timer = new Timer(options.timeout, function() {\n runner.abort();\n callback(true);\n });\n }\n\n runner = strategy.connect(minPriority, function(error, handshake) {\n if (error && timer && timer.isRunning() && !options.failFast) {\n // advance to the next strategy after the timeout\n return;\n }\n if (timer) {\n timer.ensureAborted();\n }\n callback(error, handshake);\n });\n\n return {\n abort: function() {\n if (timer) {\n timer.ensureAborted();\n }\n runner.abort();\n },\n forceMinPriority: function(p) {\n runner.forceMinPriority(p);\n }\n };\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport Strategy from './strategy';\n\n/** Launches all substrategies and emits prioritized connected transports.\n *\n * @param {Array} strategies\n */\nexport default class BestConnectedEverStrategy implements Strategy {\n strategies: Strategy[];\n\n constructor(strategies: Strategy[]) {\n this.strategies = strategies;\n }\n\n isSupported(): boolean {\n return Collections.any(this.strategies, Util.method('isSupported'));\n }\n\n connect(minPriority: number, callback: Function) {\n return connect(this.strategies, minPriority, function(i, runners) {\n return function(error, handshake) {\n runners[i].error = error;\n if (error) {\n if (allRunnersFailed(runners)) {\n callback(true);\n }\n return;\n }\n Collections.apply(runners, function(runner) {\n runner.forceMinPriority(handshake.transport.priority);\n });\n callback(null, handshake);\n };\n });\n }\n}\n\n/** Connects to all strategies in parallel.\n *\n * Callback builder should be a function that takes two arguments: index\n * and a list of runners. It should return another function that will be\n * passed to the substrategy with given index. Runners can be aborted using\n * abortRunner(s) functions from this class.\n *\n * @param {Array} strategies\n * @param {Function} callbackBuilder\n * @return {Object} strategy runner\n */\nfunction connect(\n strategies: Strategy[],\n minPriority: number,\n callbackBuilder: Function\n) {\n var runners = Collections.map(strategies, function(strategy, i, _, rs) {\n return strategy.connect(minPriority, callbackBuilder(i, rs));\n });\n return {\n abort: function() {\n Collections.apply(runners, abortRunner);\n },\n forceMinPriority: function(p) {\n Collections.apply(runners, function(runner) {\n runner.forceMinPriority(p);\n });\n }\n };\n}\n\nfunction allRunnersFailed(runners): boolean {\n return Collections.all(runners, function(runner) {\n return Boolean(runner.error);\n });\n}\n\nfunction abortRunner(runner) {\n if (!runner.error && !runner.aborted) {\n runner.abort();\n runner.aborted = true;\n }\n}\n","import Util from '../util';\nimport Runtime from 'runtime';\nimport Strategy from './strategy';\nimport SequentialStrategy from './sequential_strategy';\nimport StrategyOptions from './strategy_options';\nimport TransportStrategy from './transport_strategy';\nimport Timeline from '../timeline/timeline';\nimport * as Collections from '../utils/collections';\n\nexport interface TransportStrategyDictionary {\n [key: string]: TransportStrategy;\n}\n\n/** Caches the last successful transport and, after the first few attempts,\n * uses the cached transport for subsequent attempts.\n *\n * @param {Strategy} strategy\n * @param {Object} transports\n * @param {Object} options\n */\nexport default class WebSocketPrioritizedCachedStrategy implements Strategy {\n strategy: Strategy;\n transports: TransportStrategyDictionary;\n ttl: number;\n usingTLS: boolean;\n timeline: Timeline;\n\n constructor(\n strategy: Strategy,\n transports: TransportStrategyDictionary,\n options: StrategyOptions\n ) {\n this.strategy = strategy;\n this.transports = transports;\n this.ttl = options.ttl || 1800 * 1000;\n this.usingTLS = options.useTLS;\n this.timeline = options.timeline;\n }\n\n isSupported(): boolean {\n return this.strategy.isSupported();\n }\n\n connect(minPriority: number, callback: Function) {\n var usingTLS = this.usingTLS;\n var info = fetchTransportCache(usingTLS);\n var cacheSkipCount = info && info.cacheSkipCount ? info.cacheSkipCount : 0;\n\n var strategies = [this.strategy];\n if (info && info.timestamp + this.ttl >= Util.now()) {\n var transport = this.transports[info.transport];\n if (transport) {\n if (['ws', 'wss'].includes(info.transport) || cacheSkipCount > 3) {\n this.timeline.info({\n cached: true,\n transport: info.transport,\n latency: info.latency\n });\n strategies.push(\n new SequentialStrategy([transport], {\n timeout: info.latency * 2 + 1000,\n failFast: true\n })\n );\n } else {\n cacheSkipCount++;\n }\n }\n }\n\n var startTimestamp = Util.now();\n var runner = strategies\n .pop()\n .connect(minPriority, function cb(error, handshake) {\n if (error) {\n flushTransportCache(usingTLS);\n if (strategies.length > 0) {\n startTimestamp = Util.now();\n runner = strategies.pop().connect(minPriority, cb);\n } else {\n callback(error);\n }\n } else {\n storeTransportCache(\n usingTLS,\n handshake.transport.name,\n Util.now() - startTimestamp,\n cacheSkipCount\n );\n callback(null, handshake);\n }\n });\n\n return {\n abort: function() {\n runner.abort();\n },\n forceMinPriority: function(p) {\n minPriority = p;\n if (runner) {\n runner.forceMinPriority(p);\n }\n }\n };\n }\n}\n\nfunction getTransportCacheKey(usingTLS: boolean): string {\n return 'pusherTransport' + (usingTLS ? 'TLS' : 'NonTLS');\n}\n\nfunction fetchTransportCache(usingTLS: boolean): any {\n var storage = Runtime.getLocalStorage();\n if (storage) {\n try {\n var serializedCache = storage[getTransportCacheKey(usingTLS)];\n if (serializedCache) {\n return JSON.parse(serializedCache);\n }\n } catch (e) {\n flushTransportCache(usingTLS);\n }\n }\n return null;\n}\n\nfunction storeTransportCache(\n usingTLS: boolean,\n transport: TransportStrategy,\n latency: number,\n cacheSkipCount: number\n) {\n var storage = Runtime.getLocalStorage();\n if (storage) {\n try {\n storage[getTransportCacheKey(usingTLS)] = Collections.safeJSONStringify({\n timestamp: Util.now(),\n transport: transport,\n latency: latency,\n cacheSkipCount: cacheSkipCount\n });\n } catch (e) {\n // catch over quota exceptions raised by localStorage\n }\n }\n}\n\nfunction flushTransportCache(usingTLS: boolean) {\n var storage = Runtime.getLocalStorage();\n if (storage) {\n try {\n delete storage[getTransportCacheKey(usingTLS)];\n } catch (e) {\n // catch exceptions raised by localStorage\n }\n }\n}\n","import { OneOffTimer as Timer } from '../utils/timers';\nimport Strategy from './strategy';\nimport StrategyOptions from './strategy_options';\n\n/** Runs substrategy after specified delay.\n *\n * Options:\n * - delay - time in miliseconds to delay the substrategy attempt\n *\n * @param {Strategy} strategy\n * @param {Object} options\n */\nexport default class DelayedStrategy implements Strategy {\n strategy: Strategy;\n options: { delay: number };\n\n constructor(strategy: Strategy, { delay: number }) {\n this.strategy = strategy;\n this.options = { delay: number };\n }\n\n isSupported(): boolean {\n return this.strategy.isSupported();\n }\n\n connect(minPriority: number, callback: Function) {\n var strategy = this.strategy;\n var runner;\n var timer = new Timer(this.options.delay, function() {\n runner = strategy.connect(minPriority, callback);\n });\n\n return {\n abort: function() {\n timer.ensureAborted();\n if (runner) {\n runner.abort();\n }\n },\n forceMinPriority: function(p) {\n minPriority = p;\n if (runner) {\n runner.forceMinPriority(p);\n }\n }\n };\n }\n}\n","import Strategy from './strategy';\nimport StrategyRunner from './strategy_runner';\n\n/** Proxies method calls to one of substrategies basing on the test function.\n *\n * @param {Function} test\n * @param {Strategy} trueBranch strategy used when test returns true\n * @param {Strategy} falseBranch strategy used when test returns false\n */\nexport default class IfStrategy implements Strategy {\n test: () => boolean;\n trueBranch: Strategy;\n falseBranch: Strategy;\n\n constructor(\n test: () => boolean,\n trueBranch: Strategy,\n falseBranch: Strategy\n ) {\n this.test = test;\n this.trueBranch = trueBranch;\n this.falseBranch = falseBranch;\n }\n\n isSupported(): boolean {\n var branch = this.test() ? this.trueBranch : this.falseBranch;\n return branch.isSupported();\n }\n\n connect(minPriority: number, callback: Function): StrategyRunner {\n var branch = this.test() ? this.trueBranch : this.falseBranch;\n return branch.connect(minPriority, callback);\n }\n}\n","import Strategy from './strategy';\nimport StrategyRunner from './strategy_runner';\n\n/** Launches the substrategy and terminates on the first open connection.\n *\n * @param {Strategy} strategy\n */\nexport default class FirstConnectedStrategy implements Strategy {\n strategy: Strategy;\n\n constructor(strategy: Strategy) {\n this.strategy = strategy;\n }\n\n isSupported(): boolean {\n return this.strategy.isSupported();\n }\n\n connect(minPriority: number, callback: Function): StrategyRunner {\n var runner = this.strategy.connect(minPriority, function(error, handshake) {\n if (handshake) {\n runner.abort();\n }\n callback(error, handshake);\n });\n return runner;\n }\n}\n","import * as Collections from 'core/utils/collections';\nimport TransportManager from 'core/transports/transport_manager';\nimport Strategy from 'core/strategies/strategy';\nimport StrategyOptions from 'core/strategies/strategy_options';\nimport SequentialStrategy from 'core/strategies/sequential_strategy';\nimport BestConnectedEverStrategy from 'core/strategies/best_connected_ever_strategy';\nimport WebSocketPrioritizedCachedStrategy, {\n TransportStrategyDictionary\n} from 'core/strategies/websocket_prioritized_cached_strategy';\nimport DelayedStrategy from 'core/strategies/delayed_strategy';\nimport IfStrategy from 'core/strategies/if_strategy';\nimport FirstConnectedStrategy from 'core/strategies/first_connected_strategy';\nimport { Config } from 'core/config';\n\nfunction testSupportsStrategy(strategy: Strategy) {\n return function() {\n return strategy.isSupported();\n };\n}\n\nvar getDefaultStrategy = function(\n config: Config,\n baseOptions: StrategyOptions,\n defineTransport: Function\n): Strategy {\n var definedTransports = {};\n\n function defineTransportStrategy(\n name: string,\n type: string,\n priority: number,\n options: StrategyOptions,\n manager?: TransportManager\n ) {\n var transport = defineTransport(\n config,\n name,\n type,\n priority,\n options,\n manager\n );\n\n definedTransports[name] = transport;\n\n return transport;\n }\n\n var ws_options: StrategyOptions = Object.assign({}, baseOptions, {\n hostNonTLS: config.wsHost + ':' + config.wsPort,\n hostTLS: config.wsHost + ':' + config.wssPort,\n httpPath: config.wsPath\n });\n var wss_options: StrategyOptions = Object.assign({}, ws_options, {\n useTLS: true\n });\n var sockjs_options: StrategyOptions = Object.assign({}, baseOptions, {\n hostNonTLS: config.httpHost + ':' + config.httpPort,\n hostTLS: config.httpHost + ':' + config.httpsPort,\n httpPath: config.httpPath\n });\n\n var timeouts = {\n loop: true,\n timeout: 15000,\n timeoutLimit: 60000\n };\n\n var ws_manager = new TransportManager({\n minPingDelay: 10000,\n maxPingDelay: config.activityTimeout\n });\n var streaming_manager = new TransportManager({\n lives: 2,\n minPingDelay: 10000,\n maxPingDelay: config.activityTimeout\n });\n\n var ws_transport = defineTransportStrategy(\n 'ws',\n 'ws',\n 3,\n ws_options,\n ws_manager\n );\n var wss_transport = defineTransportStrategy(\n 'wss',\n 'ws',\n 3,\n wss_options,\n ws_manager\n );\n var sockjs_transport = defineTransportStrategy(\n 'sockjs',\n 'sockjs',\n 1,\n sockjs_options\n );\n var xhr_streaming_transport = defineTransportStrategy(\n 'xhr_streaming',\n 'xhr_streaming',\n 1,\n sockjs_options,\n streaming_manager\n );\n var xdr_streaming_transport = defineTransportStrategy(\n 'xdr_streaming',\n 'xdr_streaming',\n 1,\n sockjs_options,\n streaming_manager\n );\n var xhr_polling_transport = defineTransportStrategy(\n 'xhr_polling',\n 'xhr_polling',\n 1,\n sockjs_options\n );\n var xdr_polling_transport = defineTransportStrategy(\n 'xdr_polling',\n 'xdr_polling',\n 1,\n sockjs_options\n );\n\n var ws_loop = new SequentialStrategy([ws_transport], timeouts);\n var wss_loop = new SequentialStrategy([wss_transport], timeouts);\n var sockjs_loop = new SequentialStrategy([sockjs_transport], timeouts);\n var streaming_loop = new SequentialStrategy(\n [\n new IfStrategy(\n testSupportsStrategy(xhr_streaming_transport),\n xhr_streaming_transport,\n xdr_streaming_transport\n )\n ],\n timeouts\n );\n var polling_loop = new SequentialStrategy(\n [\n new IfStrategy(\n testSupportsStrategy(xhr_polling_transport),\n xhr_polling_transport,\n xdr_polling_transport\n )\n ],\n timeouts\n );\n\n var http_loop = new SequentialStrategy(\n [\n new IfStrategy(\n testSupportsStrategy(streaming_loop),\n new BestConnectedEverStrategy([\n streaming_loop,\n new DelayedStrategy(polling_loop, { delay: 4000 })\n ]),\n polling_loop\n )\n ],\n timeouts\n );\n\n var http_fallback_loop = new IfStrategy(\n testSupportsStrategy(http_loop),\n http_loop,\n sockjs_loop\n );\n\n var wsStrategy;\n if (baseOptions.useTLS) {\n wsStrategy = new BestConnectedEverStrategy([\n ws_loop,\n new DelayedStrategy(http_fallback_loop, { delay: 2000 })\n ]);\n } else {\n wsStrategy = new BestConnectedEverStrategy([\n ws_loop,\n new DelayedStrategy(wss_loop, { delay: 2000 }),\n new DelayedStrategy(http_fallback_loop, { delay: 5000 })\n ]);\n }\n\n return new WebSocketPrioritizedCachedStrategy(\n new FirstConnectedStrategy(\n new IfStrategy(\n testSupportsStrategy(ws_transport),\n wsStrategy,\n http_fallback_loop\n )\n ),\n definedTransports,\n {\n ttl: 1800000,\n timeline: baseOptions.timeline,\n useTLS: baseOptions.useTLS\n }\n );\n};\n\nexport default getDefaultStrategy;\n","import { Dependencies } from '../dom/dependencies';\n\n/** Initializes the transport.\n *\n * Fetches resources if needed and then transitions to initialized.\n */\nexport default function() {\n var self = this;\n\n self.timeline.info(\n self.buildTimelineMessage({\n transport: self.name + (self.options.useTLS ? 's' : '')\n })\n );\n\n if (self.hooks.isInitialized()) {\n self.changeState('initialized');\n } else if (self.hooks.file) {\n self.changeState('initializing');\n Dependencies.load(\n self.hooks.file,\n { useTLS: self.options.useTLS },\n function(error, callback) {\n if (self.hooks.isInitialized()) {\n self.changeState('initialized');\n callback(true);\n } else {\n if (error) {\n self.onError(error);\n }\n self.onClose();\n callback(false);\n }\n }\n );\n } else {\n self.onClose();\n }\n}\n","import HTTPRequest from 'core/http/http_request';\nimport RequestHooks from 'core/http/request_hooks';\nimport Ajax from 'core/http/ajax';\nimport * as Errors from 'core/errors';\n\nvar hooks: RequestHooks = {\n getRequest: function(socket: HTTPRequest): Ajax {\n var xdr = new (window).XDomainRequest();\n xdr.ontimeout = function() {\n socket.emit('error', new Errors.RequestTimedOut());\n socket.close();\n };\n xdr.onerror = function(e) {\n socket.emit('error', e);\n socket.close();\n };\n xdr.onprogress = function() {\n if (xdr.responseText && xdr.responseText.length > 0) {\n socket.onChunk(200, xdr.responseText);\n }\n };\n xdr.onload = function() {\n if (xdr.responseText && xdr.responseText.length > 0) {\n socket.onChunk(200, xdr.responseText);\n }\n socket.emit('finished', 200);\n socket.close();\n };\n return xdr;\n },\n abortRequest: function(xdr: Ajax) {\n xdr.ontimeout = xdr.onerror = xdr.onprogress = xdr.onload = null;\n xdr.abort();\n }\n};\n\nexport default hooks;\n","import Runtime from 'runtime';\nimport RequestHooks from './request_hooks';\nimport Ajax from './ajax';\nimport { default as EventsDispatcher } from '../events/dispatcher';\n\nconst MAX_BUFFER_LENGTH = 256 * 1024;\n\nexport default class HTTPRequest extends EventsDispatcher {\n hooks: RequestHooks;\n method: string;\n url: string;\n position: number;\n xhr: Ajax;\n unloader: Function;\n\n constructor(hooks: RequestHooks, method: string, url: string) {\n super();\n this.hooks = hooks;\n this.method = method;\n this.url = url;\n }\n\n start(payload?: any) {\n this.position = 0;\n this.xhr = this.hooks.getRequest(this);\n\n this.unloader = () => {\n this.close();\n };\n Runtime.addUnloadListener(this.unloader);\n\n this.xhr.open(this.method, this.url, true);\n\n if (this.xhr.setRequestHeader) {\n this.xhr.setRequestHeader('Content-Type', 'application/json'); // ReactNative doesn't set this header by default.\n }\n this.xhr.send(payload);\n }\n\n close() {\n if (this.unloader) {\n Runtime.removeUnloadListener(this.unloader);\n this.unloader = null;\n }\n if (this.xhr) {\n this.hooks.abortRequest(this.xhr);\n this.xhr = null;\n }\n }\n\n onChunk(status: number, data: any) {\n while (true) {\n var chunk = this.advanceBuffer(data);\n if (chunk) {\n this.emit('chunk', { status: status, data: chunk });\n } else {\n break;\n }\n }\n if (this.isBufferTooLong(data)) {\n this.emit('buffer_too_long');\n }\n }\n\n private advanceBuffer(buffer: any[]): any {\n var unreadData = buffer.slice(this.position);\n var endOfLinePosition = unreadData.indexOf('\\n');\n\n if (endOfLinePosition !== -1) {\n this.position += endOfLinePosition + 1;\n return unreadData.slice(0, endOfLinePosition);\n } else {\n // chunk is not finished yet, don't move the buffer pointer\n return null;\n }\n }\n\n private isBufferTooLong(buffer: any): boolean {\n return this.position === buffer.length && buffer.length > MAX_BUFFER_LENGTH;\n }\n}\n","enum State {\n CONNECTING = 0,\n OPEN = 1,\n CLOSED = 3\n}\n\nexport default State;\n","import URLLocation from './url_location';\nimport State from './state';\nimport Socket from '../socket';\nimport SocketHooks from './socket_hooks';\nimport Util from '../util';\nimport Ajax from './ajax';\nimport HTTPRequest from './http_request';\nimport Runtime from 'runtime';\n\nvar autoIncrement = 1;\n\nclass HTTPSocket implements Socket {\n hooks: SocketHooks;\n session: string;\n location: URLLocation;\n readyState: State;\n stream: HTTPRequest;\n\n onopen: () => void;\n onerror: (error: any) => void;\n onclose: (closeEvent: any) => void;\n onmessage: (message: any) => void;\n onactivity: () => void;\n\n constructor(hooks: SocketHooks, url: string) {\n this.hooks = hooks;\n this.session = randomNumber(1000) + '/' + randomString(8);\n this.location = getLocation(url);\n this.readyState = State.CONNECTING;\n this.openStream();\n }\n\n send(payload: any) {\n return this.sendRaw(JSON.stringify([payload]));\n }\n\n ping() {\n this.hooks.sendHeartbeat(this);\n }\n\n close(code: any, reason: any) {\n this.onClose(code, reason, true);\n }\n\n /** For internal use only */\n sendRaw(payload: any): boolean {\n if (this.readyState === State.OPEN) {\n try {\n Runtime.createSocketRequest(\n 'POST',\n getUniqueURL(getSendURL(this.location, this.session))\n ).start(payload);\n return true;\n } catch (e) {\n return false;\n }\n } else {\n return false;\n }\n }\n\n /** For internal use only */\n reconnect() {\n this.closeStream();\n this.openStream();\n }\n\n /** For internal use only */\n onClose(code, reason, wasClean) {\n this.closeStream();\n this.readyState = State.CLOSED;\n if (this.onclose) {\n this.onclose({\n code: code,\n reason: reason,\n wasClean: wasClean\n });\n }\n }\n\n private onChunk(chunk) {\n if (chunk.status !== 200) {\n return;\n }\n if (this.readyState === State.OPEN) {\n this.onActivity();\n }\n\n var payload;\n var type = chunk.data.slice(0, 1);\n switch (type) {\n case 'o':\n payload = JSON.parse(chunk.data.slice(1) || '{}');\n this.onOpen(payload);\n break;\n case 'a':\n payload = JSON.parse(chunk.data.slice(1) || '[]');\n for (var i = 0; i < payload.length; i++) {\n this.onEvent(payload[i]);\n }\n break;\n case 'm':\n payload = JSON.parse(chunk.data.slice(1) || 'null');\n this.onEvent(payload);\n break;\n case 'h':\n this.hooks.onHeartbeat(this);\n break;\n case 'c':\n payload = JSON.parse(chunk.data.slice(1) || '[]');\n this.onClose(payload[0], payload[1], true);\n break;\n }\n }\n\n private onOpen(options) {\n if (this.readyState === State.CONNECTING) {\n if (options && options.hostname) {\n this.location.base = replaceHost(this.location.base, options.hostname);\n }\n this.readyState = State.OPEN;\n\n if (this.onopen) {\n this.onopen();\n }\n } else {\n this.onClose(1006, 'Server lost session', true);\n }\n }\n\n private onEvent(event) {\n if (this.readyState === State.OPEN && this.onmessage) {\n this.onmessage({ data: event });\n }\n }\n\n private onActivity() {\n if (this.onactivity) {\n this.onactivity();\n }\n }\n\n private onError(error) {\n if (this.onerror) {\n this.onerror(error);\n }\n }\n\n private openStream() {\n this.stream = Runtime.createSocketRequest(\n 'POST',\n getUniqueURL(this.hooks.getReceiveURL(this.location, this.session))\n );\n\n this.stream.bind('chunk', chunk => {\n this.onChunk(chunk);\n });\n this.stream.bind('finished', status => {\n this.hooks.onFinished(this, status);\n });\n this.stream.bind('buffer_too_long', () => {\n this.reconnect();\n });\n\n try {\n this.stream.start();\n } catch (error) {\n Util.defer(() => {\n this.onError(error);\n this.onClose(1006, 'Could not start streaming', false);\n });\n }\n }\n\n private closeStream() {\n if (this.stream) {\n this.stream.unbind_all();\n this.stream.close();\n this.stream = null;\n }\n }\n}\n\nfunction getLocation(url): URLLocation {\n var parts = /([^\\?]*)\\/*(\\??.*)/.exec(url);\n return {\n base: parts[1],\n queryString: parts[2]\n };\n}\n\nfunction getSendURL(url: URLLocation, session: string): string {\n return url.base + '/' + session + '/xhr_send';\n}\n\nfunction getUniqueURL(url: string): string {\n var separator = url.indexOf('?') === -1 ? '?' : '&';\n return url + separator + 't=' + +new Date() + '&n=' + autoIncrement++;\n}\n\nfunction replaceHost(url: string, hostname: string): string {\n var urlParts = /(https?:\\/\\/)([^\\/:]+)((\\/|:)?.*)/.exec(url);\n return urlParts[1] + hostname + urlParts[3];\n}\n\nfunction randomNumber(max: number): number {\n return Runtime.randomInt(max);\n}\n\nfunction randomString(length: number): string {\n var result = [];\n\n for (var i = 0; i < length; i++) {\n result.push(randomNumber(32).toString(32));\n }\n\n return result.join('');\n}\n\nexport default HTTPSocket;\n","import SocketHooks from './socket_hooks';\nimport HTTPSocket from './http_socket';\n\nvar hooks: SocketHooks = {\n getReceiveURL: function(url, session) {\n return url.base + '/' + session + '/xhr_streaming' + url.queryString;\n },\n onHeartbeat: function(socket) {\n socket.sendRaw('[]');\n },\n sendHeartbeat: function(socket) {\n socket.sendRaw('[]');\n },\n onFinished: function(socket, status) {\n socket.onClose(1006, 'Connection interrupted (' + status + ')', false);\n }\n};\n\nexport default hooks;\n","import SocketHooks from './socket_hooks';\nimport URLLocation from './url_location';\nimport HTTPSocket from './http_socket';\n\nvar hooks: SocketHooks = {\n getReceiveURL: function(url: URLLocation, session: string): string {\n return url.base + '/' + session + '/xhr' + url.queryString;\n },\n onHeartbeat: function() {\n // next HTTP request will reset server's activity timer\n },\n sendHeartbeat: function(socket) {\n socket.sendRaw('[]');\n },\n onFinished: function(socket, status) {\n if (status === 200) {\n socket.reconnect();\n } else {\n socket.onClose(1006, 'Connection interrupted (' + status + ')', false);\n }\n }\n};\n\nexport default hooks;\n","import HTTPRequest from 'core/http/http_request';\nimport RequestHooks from 'core/http/request_hooks';\nimport Ajax from 'core/http/ajax';\nimport Runtime from 'runtime';\n\nvar hooks: RequestHooks = {\n getRequest: function(socket: HTTPRequest): Ajax {\n var Constructor = Runtime.getXHRAPI();\n var xhr = new Constructor();\n xhr.onreadystatechange = xhr.onprogress = function() {\n switch (xhr.readyState) {\n case 3:\n if (xhr.responseText && xhr.responseText.length > 0) {\n socket.onChunk(xhr.status, xhr.responseText);\n }\n break;\n case 4:\n // this happens only on errors, never after calling close\n if (xhr.responseText && xhr.responseText.length > 0) {\n socket.onChunk(xhr.status, xhr.responseText);\n }\n socket.emit('finished', xhr.status);\n socket.close();\n break;\n }\n };\n return xhr;\n },\n abortRequest: function(xhr: Ajax) {\n xhr.onreadystatechange = null;\n xhr.abort();\n }\n};\n\nexport default hooks;\n","import HTTPRequest from 'core/http/http_request';\nimport HTTPSocket from 'core/http/http_socket';\nimport SocketHooks from 'core/http/socket_hooks';\nimport RequestHooks from 'core/http/request_hooks';\nimport streamingHooks from 'core/http/http_streaming_socket';\nimport pollingHooks from 'core/http/http_polling_socket';\nimport xhrHooks from './http_xhr_request';\nimport HTTPFactory from 'core/http/http_factory';\n\nvar HTTP: HTTPFactory = {\n createStreamingSocket(url: string): HTTPSocket {\n return this.createSocket(streamingHooks, url);\n },\n\n createPollingSocket(url: string): HTTPSocket {\n return this.createSocket(pollingHooks, url);\n },\n\n createSocket(hooks: SocketHooks, url: string): HTTPSocket {\n return new HTTPSocket(hooks, url);\n },\n\n createXHR(method: string, url: string): HTTPRequest {\n return this.createRequest(xhrHooks, method, url);\n },\n\n createRequest(hooks: RequestHooks, method: string, url: string): HTTPRequest {\n return new HTTPRequest(hooks, method, url);\n }\n};\n\nexport default HTTP;\n","import xdrHooks from './http_xdomain_request';\nimport HTTP from 'isomorphic/http/http';\n\nHTTP.createXDR = function(method, url) {\n return this.createRequest(xdrHooks, method, url);\n};\n\nexport default HTTP;\n","import Browser from './browser';\nimport { Dependencies, DependenciesReceivers } from './dom/dependencies';\nimport { AuthTransport, AuthTransports } from 'core/auth/auth_transports';\nimport xhrAuth from 'isomorphic/auth/xhr_auth';\nimport jsonpAuth from './auth/jsonp_auth';\nimport TimelineTransport from 'core/timeline/timeline_transport';\nimport TimelineSender from 'core/timeline/timeline_sender';\nimport ScriptRequest from './dom/script_request';\nimport JSONPRequest from './dom/jsonp_request';\nimport * as Collections from 'core/utils/collections';\nimport { ScriptReceivers } from './dom/script_receiver_factory';\nimport jsonpTimeline from './timeline/jsonp_timeline';\nimport Transports from './transports/transports';\nimport Ajax from 'core/http/ajax';\nimport { Network } from './net_info';\nimport getDefaultStrategy from './default_strategy';\nimport transportConnectionInitializer from './transports/transport_connection_initializer';\nimport HTTPFactory from './http/http';\nimport HTTPRequest from 'core/http/http_request';\n\nvar Runtime: Browser = {\n // for jsonp auth\n nextAuthCallbackID: 1,\n auth_callbacks: {},\n ScriptReceivers,\n DependenciesReceivers,\n getDefaultStrategy,\n Transports,\n transportConnectionInitializer,\n HTTPFactory,\n\n TimelineTransport: jsonpTimeline,\n\n getXHRAPI() {\n return window.XMLHttpRequest;\n },\n\n getWebSocketAPI() {\n return window.WebSocket || window.MozWebSocket;\n },\n\n setup(PusherClass): void {\n (window).Pusher = PusherClass; // JSONp requires Pusher to be in the global scope.\n var initializeOnDocumentBody = () => {\n this.onDocumentBody(PusherClass.ready);\n };\n if (!(window).JSON) {\n Dependencies.load('json2', {}, initializeOnDocumentBody);\n } else {\n initializeOnDocumentBody();\n }\n },\n\n getDocument(): Document {\n return document;\n },\n\n getProtocol(): string {\n return this.getDocument().location.protocol;\n },\n\n getAuthorizers(): AuthTransports {\n return { ajax: xhrAuth, jsonp: jsonpAuth };\n },\n\n onDocumentBody(callback: Function) {\n if (document.body) {\n callback();\n } else {\n setTimeout(() => {\n this.onDocumentBody(callback);\n }, 0);\n }\n },\n\n createJSONPRequest(url: string, data: any): JSONPRequest {\n return new JSONPRequest(url, data);\n },\n\n createScriptRequest(src: string): ScriptRequest {\n return new ScriptRequest(src);\n },\n\n getLocalStorage() {\n try {\n return window.localStorage;\n } catch (e) {\n return undefined;\n }\n },\n\n createXHR(): Ajax {\n if (this.getXHRAPI()) {\n return this.createXMLHttpRequest();\n } else {\n return this.createMicrosoftXHR();\n }\n },\n\n createXMLHttpRequest(): Ajax {\n var Constructor = this.getXHRAPI();\n return new Constructor();\n },\n\n createMicrosoftXHR(): Ajax {\n return new ActiveXObject('Microsoft.XMLHTTP');\n },\n\n getNetwork() {\n return Network;\n },\n\n createWebSocket(url: string): any {\n var Constructor = this.getWebSocketAPI();\n return new Constructor(url);\n },\n\n createSocketRequest(method: string, url: string): HTTPRequest {\n if (this.isXHRSupported()) {\n return this.HTTPFactory.createXHR(method, url);\n } else if (this.isXDRSupported(url.indexOf('https:') === 0)) {\n return this.HTTPFactory.createXDR(method, url);\n } else {\n throw 'Cross-origin HTTP requests are not supported';\n }\n },\n\n isXHRSupported(): boolean {\n var Constructor = this.getXHRAPI();\n return (\n Boolean(Constructor) && new Constructor().withCredentials !== undefined\n );\n },\n\n isXDRSupported(useTLS?: boolean): boolean {\n var protocol = useTLS ? 'https:' : 'http:';\n var documentProtocol = this.getProtocol();\n return (\n Boolean(window['XDomainRequest']) && documentProtocol === protocol\n );\n },\n\n addUnloadListener(listener: any) {\n if (window.addEventListener !== undefined) {\n window.addEventListener('unload', listener, false);\n } else if (window.attachEvent !== undefined) {\n window.attachEvent('onunload', listener);\n }\n },\n\n removeUnloadListener(listener: any) {\n if (window.addEventListener !== undefined) {\n window.removeEventListener('unload', listener, false);\n } else if (window.detachEvent !== undefined) {\n window.detachEvent('onunload', listener);\n }\n },\n\n randomInt(max: number): number {\n /**\n * Return values in the range of [0, 1[\n */\n const random = function() {\n const crypto = window.crypto || window['msCrypto'];\n const random = crypto.getRandomValues(new Uint32Array(1))[0];\n\n return random / 2 ** 32;\n };\n\n return Math.floor(random() * max);\n }\n};\n\nexport default Runtime;\n","enum TimelineLevel {\n ERROR = 3,\n INFO = 6,\n DEBUG = 7\n}\n\nexport default TimelineLevel;\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport { default as Level } from './level';\n\nexport interface TimelineOptions {\n level?: Level;\n limit?: number;\n version?: string;\n cluster?: string;\n features?: string[];\n params?: any;\n}\n\nexport default class Timeline {\n key: string;\n session: number;\n events: any[];\n options: TimelineOptions;\n sent: number;\n uniqueID: number;\n\n constructor(key: string, session: number, options: TimelineOptions) {\n this.key = key;\n this.session = session;\n this.events = [];\n this.options = options || {};\n this.sent = 0;\n this.uniqueID = 0;\n }\n\n log(level, event) {\n if (level <= this.options.level) {\n this.events.push(\n Collections.extend({}, event, { timestamp: Util.now() })\n );\n if (this.options.limit && this.events.length > this.options.limit) {\n this.events.shift();\n }\n }\n }\n\n error(event) {\n this.log(Level.ERROR, event);\n }\n\n info(event) {\n this.log(Level.INFO, event);\n }\n\n debug(event) {\n this.log(Level.DEBUG, event);\n }\n\n isEmpty() {\n return this.events.length === 0;\n }\n\n send(sendfn, callback) {\n var data = Collections.extend(\n {\n session: this.session,\n bundle: this.sent + 1,\n key: this.key,\n lib: 'js',\n version: this.options.version,\n cluster: this.options.cluster,\n features: this.options.features,\n timeline: this.events\n },\n this.options.params\n );\n\n this.events = [];\n sendfn(data, (error, result) => {\n if (!error) {\n this.sent++;\n }\n if (callback) {\n callback(error, result);\n }\n });\n\n return true;\n }\n\n generateUniqueID(): number {\n this.uniqueID++;\n return this.uniqueID;\n }\n}\n","import Factory from '../utils/factory';\nimport Util from '../util';\nimport * as Errors from '../errors';\nimport * as Collections from '../utils/collections';\nimport Strategy from './strategy';\nimport Transport from '../transports/transport';\nimport StrategyOptions from './strategy_options';\nimport Handshake from '../connection/handshake';\n\n/** Provides a strategy interface for transports.\n *\n * @param {String} name\n * @param {Number} priority\n * @param {Class} transport\n * @param {Object} options\n */\nexport default class TransportStrategy implements Strategy {\n name: string;\n priority: number;\n transport: Transport;\n options: StrategyOptions;\n\n constructor(\n name: string,\n priority: number,\n transport: Transport,\n options: StrategyOptions\n ) {\n this.name = name;\n this.priority = priority;\n this.transport = transport;\n this.options = options || {};\n }\n\n /** Returns whether the transport is supported in the browser.\n *\n * @returns {Boolean}\n */\n isSupported(): boolean {\n return this.transport.isSupported({\n useTLS: this.options.useTLS\n });\n }\n\n /** Launches a connection attempt and returns a strategy runner.\n *\n * @param {Function} callback\n * @return {Object} strategy runner\n */\n connect(minPriority: number, callback: Function) {\n if (!this.isSupported()) {\n return failAttempt(new Errors.UnsupportedStrategy(), callback);\n } else if (this.priority < minPriority) {\n return failAttempt(new Errors.TransportPriorityTooLow(), callback);\n }\n\n var connected = false;\n var transport = this.transport.createConnection(\n this.name,\n this.priority,\n this.options.key,\n this.options\n );\n var handshake = null;\n\n var onInitialized = function() {\n transport.unbind('initialized', onInitialized);\n transport.connect();\n };\n var onOpen = function() {\n handshake = Factory.createHandshake(transport, function(result) {\n connected = true;\n unbindListeners();\n callback(null, result);\n });\n };\n var onError = function(error) {\n unbindListeners();\n callback(error);\n };\n var onClosed = function() {\n unbindListeners();\n var serializedTransport;\n\n // The reason for this try/catch block is that on React Native\n // the WebSocket object is circular. Therefore transport.socket will\n // throw errors upon stringification. Collections.safeJSONStringify\n // discards circular references when serializing.\n serializedTransport = Collections.safeJSONStringify(transport);\n callback(new Errors.TransportClosed(serializedTransport));\n };\n\n var unbindListeners = function() {\n transport.unbind('initialized', onInitialized);\n transport.unbind('open', onOpen);\n transport.unbind('error', onError);\n transport.unbind('closed', onClosed);\n };\n\n transport.bind('initialized', onInitialized);\n transport.bind('open', onOpen);\n transport.bind('error', onError);\n transport.bind('closed', onClosed);\n\n // connect will be called automatically after initialization\n transport.initialize();\n\n return {\n abort: () => {\n if (connected) {\n return;\n }\n unbindListeners();\n if (handshake) {\n handshake.close();\n } else {\n transport.close();\n }\n },\n forceMinPriority: p => {\n if (connected) {\n return;\n }\n if (this.priority < p) {\n if (handshake) {\n handshake.close();\n } else {\n transport.close();\n }\n }\n }\n };\n }\n}\n\nfunction failAttempt(error: Error, callback: Function) {\n Util.defer(function() {\n callback(error);\n });\n return {\n abort: function() {},\n forceMinPriority: function() {}\n };\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport TransportManager from '../transports/transport_manager';\nimport * as Errors from '../errors';\nimport Strategy from './strategy';\nimport TransportStrategy from './transport_strategy';\nimport StrategyOptions from '../strategies/strategy_options';\nimport { Config } from '../config';\nimport Runtime from 'runtime';\n\nconst { Transports } = Runtime;\n\nexport var defineTransport = function(\n config: Config,\n name: string,\n type: string,\n priority: number,\n options: StrategyOptions,\n manager?: TransportManager\n): Strategy {\n var transportClass = Transports[type];\n if (!transportClass) {\n throw new Errors.UnsupportedTransport(type);\n }\n\n var enabled =\n (!config.enabledTransports ||\n Collections.arrayIndexOf(config.enabledTransports, name) !== -1) &&\n (!config.disabledTransports ||\n Collections.arrayIndexOf(config.disabledTransports, name) === -1);\n\n var transport;\n if (enabled) {\n options = Object.assign(\n { ignoreNullOrigin: config.ignoreNullOrigin },\n options\n );\n\n transport = new TransportStrategy(\n name,\n priority,\n manager ? manager.getAssistant(transportClass) : transportClass,\n options\n );\n } else {\n transport = UnsupportedStrategy;\n }\n\n return transport;\n};\n\nvar UnsupportedStrategy: Strategy = {\n isSupported: function() {\n return false;\n },\n connect: function(_, callback) {\n var deferred = Util.defer(function() {\n callback(new Errors.UnsupportedStrategy());\n });\n return {\n abort: function() {\n deferred.ensureAborted();\n },\n forceMinPriority: function() {}\n };\n }\n};\n","import ConnectionManager from './connection/connection_manager';\nimport {\n ChannelAuthorizationOptions,\n UserAuthenticationOptions\n} from './auth/options';\nimport {\n ChannelAuthorizerGenerator,\n DeprecatedAuthOptions\n} from './auth/deprecated_channel_authorizer';\nimport { AuthTransport, Transport } from './config';\nimport * as nacl from 'tweetnacl';\nimport Logger from './logger';\n\nexport interface Options {\n activityTimeout?: number;\n\n auth?: DeprecatedAuthOptions; // DEPRECATED use channelAuthorization instead\n authEndpoint?: string; // DEPRECATED use channelAuthorization instead\n authTransport?: AuthTransport; // DEPRECATED use channelAuthorization instead\n authorizer?: ChannelAuthorizerGenerator; // DEPRECATED use channelAuthorization instead\n\n channelAuthorization?: ChannelAuthorizationOptions;\n userAuthentication?: UserAuthenticationOptions;\n\n cluster: string;\n enableStats?: boolean;\n disableStats?: boolean;\n disabledTransports?: Transport[];\n enabledTransports?: Transport[];\n forceTLS?: boolean;\n httpHost?: string;\n httpPath?: string;\n httpPort?: number;\n httpsPort?: number;\n ignoreNullOrigin?: boolean;\n nacl?: nacl;\n pongTimeout?: number;\n statsHost?: string;\n timelineParams?: any;\n unavailableTimeout?: number;\n wsHost?: string;\n wsPath?: string;\n wsPort?: number;\n wssPort?: number;\n}\n\nexport interface ClusterOptions {\n appKey: string;\n cluster: string;\n}\n\nexport function validateOptions(options) {\n if (options == null) {\n throw 'You must pass an options object';\n }\n if (options.cluster == null) {\n throw 'Options object must provide a cluster';\n }\n if ('disableStats' in options) {\n Logger.warn(\n 'The disableStats option is deprecated in favor of enableStats'\n );\n }\n}\n","import {\n UserAuthenticationCallback,\n InternalAuthOptions,\n UserAuthenticationHandler,\n UserAuthenticationRequestParams,\n AuthRequestType\n} from './options';\n\nimport Runtime from 'runtime';\n\nconst composeChannelQuery = (\n params: UserAuthenticationRequestParams,\n authOptions: InternalAuthOptions\n) => {\n var query = 'socket_id=' + encodeURIComponent(params.socketId);\n\n for (var key in authOptions.params) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(authOptions.params[key]);\n }\n\n if (authOptions.paramsProvider != null) {\n let dynamicParams = authOptions.paramsProvider();\n for (var key in dynamicParams) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(dynamicParams[key]);\n }\n }\n\n return query;\n};\n\nconst UserAuthenticator = (\n authOptions: InternalAuthOptions\n): UserAuthenticationHandler => {\n if (typeof Runtime.getAuthorizers()[authOptions.transport] === 'undefined') {\n throw `'${authOptions.transport}' is not a recognized auth transport`;\n }\n\n return (\n params: UserAuthenticationRequestParams,\n callback: UserAuthenticationCallback\n ) => {\n const query = composeChannelQuery(params, authOptions);\n\n Runtime.getAuthorizers()[authOptions.transport](\n Runtime,\n query,\n authOptions,\n AuthRequestType.UserAuthentication,\n callback\n );\n };\n};\n\nexport default UserAuthenticator;\n","import {\n AuthRequestType,\n InternalAuthOptions,\n ChannelAuthorizationHandler,\n ChannelAuthorizationRequestParams,\n ChannelAuthorizationCallback\n} from './options';\n\nimport Runtime from 'runtime';\n\nconst composeChannelQuery = (\n params: ChannelAuthorizationRequestParams,\n authOptions: InternalAuthOptions\n) => {\n var query = 'socket_id=' + encodeURIComponent(params.socketId);\n\n query += '&channel_name=' + encodeURIComponent(params.channelName);\n\n for (var key in authOptions.params) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(authOptions.params[key]);\n }\n\n if (authOptions.paramsProvider != null) {\n let dynamicParams = authOptions.paramsProvider();\n for (var key in dynamicParams) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(dynamicParams[key]);\n }\n }\n\n return query;\n};\n\nconst ChannelAuthorizer = (\n authOptions: InternalAuthOptions\n): ChannelAuthorizationHandler => {\n if (typeof Runtime.getAuthorizers()[authOptions.transport] === 'undefined') {\n throw `'${authOptions.transport}' is not a recognized auth transport`;\n }\n\n return (\n params: ChannelAuthorizationRequestParams,\n callback: ChannelAuthorizationCallback\n ) => {\n const query = composeChannelQuery(params, authOptions);\n\n Runtime.getAuthorizers()[authOptions.transport](\n Runtime,\n query,\n authOptions,\n AuthRequestType.ChannelAuthorization,\n callback\n );\n };\n};\n\nexport default ChannelAuthorizer;\n","import Channel from '../channels/channel';\nimport {\n ChannelAuthorizationCallback,\n ChannelAuthorizationHandler,\n ChannelAuthorizationRequestParams,\n InternalAuthOptions\n} from './options';\n\nexport interface DeprecatedChannelAuthorizer {\n authorize(socketId: string, callback: ChannelAuthorizationCallback): void;\n}\n\nexport interface ChannelAuthorizerGenerator {\n (\n channel: Channel,\n options: DeprecatedAuthorizerOptions\n ): DeprecatedChannelAuthorizer;\n}\n\nexport interface DeprecatedAuthOptions {\n params?: any;\n headers?: any;\n}\n\nexport interface DeprecatedAuthorizerOptions {\n authTransport: 'ajax' | 'jsonp';\n authEndpoint: string;\n auth?: DeprecatedAuthOptions;\n}\n\nexport const ChannelAuthorizerProxy = (\n pusher,\n authOptions: InternalAuthOptions,\n channelAuthorizerGenerator: ChannelAuthorizerGenerator\n): ChannelAuthorizationHandler => {\n const deprecatedAuthorizerOptions: DeprecatedAuthorizerOptions = {\n authTransport: authOptions.transport,\n authEndpoint: authOptions.endpoint,\n auth: {\n params: authOptions.params,\n headers: authOptions.headers\n }\n };\n return (\n params: ChannelAuthorizationRequestParams,\n callback: ChannelAuthorizationCallback\n ) => {\n const channel = pusher.channel(params.channelName);\n // This line creates a new channel authorizer every time.\n // In the past, this was only done once per channel and reused.\n // We can do that again if we want to keep this behavior intact.\n const channelAuthorizer: DeprecatedChannelAuthorizer = channelAuthorizerGenerator(\n channel,\n deprecatedAuthorizerOptions\n );\n channelAuthorizer.authorize(params.socketId, callback);\n };\n};\n","import { Options } from './options';\nimport Defaults from './defaults';\nimport {\n ChannelAuthorizationHandler,\n UserAuthenticationHandler,\n ChannelAuthorizationOptions\n} from './auth/options';\nimport UserAuthenticator from './auth/user_authenticator';\nimport ChannelAuthorizer from './auth/channel_authorizer';\nimport { ChannelAuthorizerProxy } from './auth/deprecated_channel_authorizer';\nimport Runtime from 'runtime';\nimport * as nacl from 'tweetnacl';\n\nexport type AuthTransport = 'ajax' | 'jsonp';\nexport type Transport =\n | 'ws'\n | 'wss'\n | 'xhr_streaming'\n | 'xhr_polling'\n | 'sockjs';\n\nexport interface Config {\n // these are all 'required' config parameters, it's not necessary for the user\n // to set them, but they have configured defaults.\n activityTimeout: number;\n enableStats: boolean;\n httpHost: string;\n httpPath: string;\n httpPort: number;\n httpsPort: number;\n pongTimeout: number;\n statsHost: string;\n unavailableTimeout: number;\n useTLS: boolean;\n wsHost: string;\n wsPath: string;\n wsPort: number;\n wssPort: number;\n userAuthenticator: UserAuthenticationHandler;\n channelAuthorizer: ChannelAuthorizationHandler;\n\n // these are all optional parameters or overrrides. The customer can set these\n // but it's not strictly necessary\n forceTLS?: boolean;\n cluster?: string;\n disabledTransports?: Transport[];\n enabledTransports?: Transport[];\n ignoreNullOrigin?: boolean;\n nacl?: nacl;\n timelineParams?: any;\n}\n\n// getConfig mainly sets the defaults for the options that are not provided\nexport function getConfig(opts: Options, pusher): Config {\n let config: Config = {\n activityTimeout: opts.activityTimeout || Defaults.activityTimeout,\n cluster: opts.cluster,\n httpPath: opts.httpPath || Defaults.httpPath,\n httpPort: opts.httpPort || Defaults.httpPort,\n httpsPort: opts.httpsPort || Defaults.httpsPort,\n pongTimeout: opts.pongTimeout || Defaults.pongTimeout,\n statsHost: opts.statsHost || Defaults.stats_host,\n unavailableTimeout: opts.unavailableTimeout || Defaults.unavailableTimeout,\n wsPath: opts.wsPath || Defaults.wsPath,\n wsPort: opts.wsPort || Defaults.wsPort,\n wssPort: opts.wssPort || Defaults.wssPort,\n\n enableStats: getEnableStatsConfig(opts),\n httpHost: getHttpHost(opts),\n useTLS: shouldUseTLS(opts),\n wsHost: getWebsocketHost(opts),\n\n userAuthenticator: buildUserAuthenticator(opts),\n channelAuthorizer: buildChannelAuthorizer(opts, pusher)\n };\n\n if ('disabledTransports' in opts)\n config.disabledTransports = opts.disabledTransports;\n if ('enabledTransports' in opts)\n config.enabledTransports = opts.enabledTransports;\n if ('ignoreNullOrigin' in opts)\n config.ignoreNullOrigin = opts.ignoreNullOrigin;\n if ('timelineParams' in opts) config.timelineParams = opts.timelineParams;\n if ('nacl' in opts) {\n config.nacl = opts.nacl;\n }\n\n return config;\n}\n\nfunction getHttpHost(opts: Options): string {\n if (opts.httpHost) {\n return opts.httpHost;\n }\n if (opts.cluster) {\n return `sockjs-${opts.cluster}.pusher.com`;\n }\n return Defaults.httpHost;\n}\n\nfunction getWebsocketHost(opts: Options): string {\n if (opts.wsHost) {\n return opts.wsHost;\n }\n return getWebsocketHostFromCluster(opts.cluster);\n}\n\nfunction getWebsocketHostFromCluster(cluster: string): string {\n return `ws-${cluster}.pusher.com`;\n}\n\nfunction shouldUseTLS(opts: Options): boolean {\n if (Runtime.getProtocol() === 'https:') {\n return true;\n } else if (opts.forceTLS === false) {\n return false;\n }\n return true;\n}\n\n// if enableStats is set take the value\n// if disableStats is set take the inverse\n// otherwise default to false\nfunction getEnableStatsConfig(opts: Options): boolean {\n if ('enableStats' in opts) {\n return opts.enableStats;\n }\n if ('disableStats' in opts) {\n return !opts.disableStats;\n }\n return false;\n}\n\nfunction buildUserAuthenticator(opts: Options): UserAuthenticationHandler {\n const userAuthentication = {\n ...Defaults.userAuthentication,\n ...opts.userAuthentication\n };\n if (\n 'customHandler' in userAuthentication &&\n userAuthentication['customHandler'] != null\n ) {\n return userAuthentication['customHandler'];\n }\n\n return UserAuthenticator(userAuthentication);\n}\n\nfunction buildChannelAuth(opts: Options, pusher): ChannelAuthorizationOptions {\n let channelAuthorization: ChannelAuthorizationOptions;\n if ('channelAuthorization' in opts) {\n channelAuthorization = {\n ...Defaults.channelAuthorization,\n ...opts.channelAuthorization\n };\n } else {\n channelAuthorization = {\n transport: opts.authTransport || Defaults.authTransport,\n endpoint: opts.authEndpoint || Defaults.authEndpoint\n };\n if ('auth' in opts) {\n if ('params' in opts.auth) channelAuthorization.params = opts.auth.params;\n if ('headers' in opts.auth)\n channelAuthorization.headers = opts.auth.headers;\n }\n if ('authorizer' in opts)\n channelAuthorization.customHandler = ChannelAuthorizerProxy(\n pusher,\n channelAuthorization,\n opts.authorizer\n );\n }\n return channelAuthorization;\n}\n\nfunction buildChannelAuthorizer(\n opts: Options,\n pusher\n): ChannelAuthorizationHandler {\n const channelAuthorization = buildChannelAuth(opts, pusher);\n if (\n 'customHandler' in channelAuthorization &&\n channelAuthorization['customHandler'] != null\n ) {\n return channelAuthorization['customHandler'];\n }\n\n return ChannelAuthorizer(channelAuthorization);\n}\n","import Logger from './logger';\nimport Pusher from './pusher';\nimport EventsDispatcher from './events/dispatcher';\n\nexport default class WatchlistFacade extends EventsDispatcher {\n private pusher: Pusher;\n\n public constructor(pusher: Pusher) {\n super(function(eventName, data) {\n Logger.debug(`No callbacks on watchlist events for ${eventName}`);\n });\n\n this.pusher = pusher;\n this.bindWatchlistInternalEvent();\n }\n\n handleEvent(pusherEvent) {\n pusherEvent.data.events.forEach(watchlistEvent => {\n this.emit(watchlistEvent.name, watchlistEvent);\n });\n }\n\n private bindWatchlistInternalEvent() {\n this.pusher.connection.bind('message', pusherEvent => {\n var eventName = pusherEvent.event;\n if (eventName === 'pusher_internal:watchlist_events') {\n this.handleEvent(pusherEvent);\n }\n });\n }\n}\n","function flatPromise() {\n let resolve, reject;\n const promise = new Promise((res, rej) => {\n resolve = res;\n reject = rej;\n });\n return { promise, resolve, reject };\n}\n\nexport default flatPromise;\n","import Pusher from './pusher';\nimport Logger from './logger';\nimport {\n UserAuthenticationData,\n UserAuthenticationCallback\n} from './auth/options';\nimport Channel from './channels/channel';\nimport WatchlistFacade from './watchlist';\nimport EventsDispatcher from './events/dispatcher';\nimport flatPromise from './utils/flat_promise';\n\nexport default class UserFacade extends EventsDispatcher {\n pusher: Pusher;\n signin_requested: boolean = false;\n user_data: any = null;\n serverToUserChannel: Channel = null;\n signinDonePromise: Promise = null;\n watchlist: WatchlistFacade;\n private _signinDoneResolve: Function = null;\n\n public constructor(pusher: Pusher) {\n super(function(eventName, data) {\n Logger.debug('No callbacks on user for ' + eventName);\n });\n this.pusher = pusher;\n this.pusher.connection.bind('state_change', ({ previous, current }) => {\n if (previous !== 'connected' && current === 'connected') {\n this._signin();\n }\n if (previous === 'connected' && current !== 'connected') {\n this._cleanup();\n this._newSigninPromiseIfNeeded();\n }\n });\n\n this.watchlist = new WatchlistFacade(pusher);\n\n this.pusher.connection.bind('message', event => {\n var eventName = event.event;\n if (eventName === 'pusher:signin_success') {\n this._onSigninSuccess(event.data);\n }\n if (\n this.serverToUserChannel &&\n this.serverToUserChannel.name === event.channel\n ) {\n this.serverToUserChannel.handleEvent(event);\n }\n });\n }\n\n public signin() {\n if (this.signin_requested) {\n return;\n }\n\n this.signin_requested = true;\n this._signin();\n }\n\n private _signin() {\n if (!this.signin_requested) {\n return;\n }\n\n this._newSigninPromiseIfNeeded();\n\n if (this.pusher.connection.state !== 'connected') {\n // Signin will be attempted when the connection is connected\n return;\n }\n\n this.pusher.config.userAuthenticator(\n {\n socketId: this.pusher.connection.socket_id\n },\n this._onAuthorize\n );\n }\n\n private _onAuthorize: UserAuthenticationCallback = (\n err,\n authData: UserAuthenticationData\n ) => {\n if (err) {\n Logger.warn(`Error during signin: ${err}`);\n this._cleanup();\n return;\n }\n\n this.pusher.send_event('pusher:signin', {\n auth: authData.auth,\n user_data: authData.user_data\n });\n\n // Later when we get pusher:singin_success event, the user will be marked as signed in\n };\n\n private _onSigninSuccess(data: any) {\n try {\n this.user_data = JSON.parse(data.user_data);\n } catch (e) {\n Logger.error(`Failed parsing user data after signin: ${data.user_data}`);\n this._cleanup();\n return;\n }\n\n if (typeof this.user_data.id !== 'string' || this.user_data.id === '') {\n Logger.error(\n `user_data doesn't contain an id. user_data: ${this.user_data}`\n );\n this._cleanup();\n return;\n }\n\n // Signin succeeded\n this._signinDoneResolve();\n this._subscribeChannels();\n }\n\n private _subscribeChannels() {\n const ensure_subscribed = channel => {\n if (channel.subscriptionPending && channel.subscriptionCancelled) {\n channel.reinstateSubscription();\n } else if (\n !channel.subscriptionPending &&\n this.pusher.connection.state === 'connected'\n ) {\n channel.subscribe();\n }\n };\n\n this.serverToUserChannel = new Channel(\n `#server-to-user-${this.user_data.id}`,\n this.pusher\n );\n this.serverToUserChannel.bind_global((eventName, data) => {\n if (\n eventName.indexOf('pusher_internal:') === 0 ||\n eventName.indexOf('pusher:') === 0\n ) {\n // ignore internal events\n return;\n }\n this.emit(eventName, data);\n });\n ensure_subscribed(this.serverToUserChannel);\n }\n\n private _cleanup() {\n this.user_data = null;\n if (this.serverToUserChannel) {\n this.serverToUserChannel.unbind_all();\n this.serverToUserChannel.disconnect();\n this.serverToUserChannel = null;\n }\n\n if (this.signin_requested) {\n // If signin is in progress and cleanup is called,\n // Mark the current signin process as done.\n this._signinDoneResolve();\n }\n }\n\n private _newSigninPromiseIfNeeded() {\n if (!this.signin_requested) {\n return;\n }\n\n // If there is a promise and it is not resolved, return without creating a new one.\n if (this.signinDonePromise && !(this.signinDonePromise as any).done) {\n return;\n }\n\n // This promise is never rejected.\n // It gets resolved when the signin process is done whether it failed or succeeded\n const { promise, resolve, reject: _ } = flatPromise();\n (promise as any).done = false;\n const setDone = () => {\n (promise as any).done = true;\n };\n promise.then(setDone).catch(setDone);\n this.signinDonePromise = promise;\n this._signinDoneResolve = resolve;\n }\n}\n","import AbstractRuntime from '../runtimes/interface';\nimport Runtime from 'runtime';\nimport * as Collections from './utils/collections';\nimport Channels from './channels/channels';\nimport Channel from './channels/channel';\nimport { default as EventsDispatcher } from './events/dispatcher';\nimport Timeline from './timeline/timeline';\nimport TimelineSender from './timeline/timeline_sender';\nimport TimelineLevel from './timeline/level';\nimport { defineTransport } from './strategies/strategy_builder';\nimport ConnectionManager from './connection/connection_manager';\nimport { PeriodicTimer } from './utils/timers';\nimport Defaults from './defaults';\nimport Logger from './logger';\nimport Factory from './utils/factory';\nimport { Options, ClusterOptions, validateOptions } from './options';\nimport { Config, getConfig } from './config';\nimport StrategyOptions from './strategies/strategy_options';\nimport UserFacade from './user';\n\nexport default class Pusher {\n /* STATIC PROPERTIES */\n static instances: Pusher[] = [];\n static isReady: boolean = false;\n static logToConsole: boolean = false;\n\n // for jsonp\n static Runtime: AbstractRuntime = Runtime;\n static ScriptReceivers: any = (Runtime).ScriptReceivers;\n static DependenciesReceivers: any = (Runtime).DependenciesReceivers;\n static auth_callbacks: any = (Runtime).auth_callbacks;\n\n static ready() {\n Pusher.isReady = true;\n for (var i = 0, l = Pusher.instances.length; i < l; i++) {\n Pusher.instances[i].connect();\n }\n }\n\n static log: (message: any) => void;\n\n private static getClientFeatures(): string[] {\n return Collections.keys(\n Collections.filterObject({ ws: Runtime.Transports.ws }, function(t) {\n return t.isSupported({});\n })\n );\n }\n\n /* INSTANCE PROPERTIES */\n key: string;\n options: Options;\n config: Config;\n channels: Channels;\n global_emitter: EventsDispatcher;\n sessionID: number;\n timeline: Timeline;\n timelineSender: TimelineSender;\n connection: ConnectionManager;\n timelineSenderTimer: PeriodicTimer;\n user: UserFacade;\n constructor(app_key: string, options: Options) {\n checkAppKey(app_key);\n validateOptions(options);\n this.key = app_key;\n this.config = getConfig(options, this);\n\n this.channels = Factory.createChannels();\n this.global_emitter = new EventsDispatcher();\n this.sessionID = Runtime.randomInt(1000000000);\n\n this.timeline = new Timeline(this.key, this.sessionID, {\n cluster: this.config.cluster,\n features: Pusher.getClientFeatures(),\n params: this.config.timelineParams || {},\n limit: 50,\n level: TimelineLevel.INFO,\n version: Defaults.VERSION\n });\n if (this.config.enableStats) {\n this.timelineSender = Factory.createTimelineSender(this.timeline, {\n host: this.config.statsHost,\n path: '/timeline/v2/' + Runtime.TimelineTransport.name\n });\n }\n\n var getStrategy = (options: StrategyOptions) => {\n return Runtime.getDefaultStrategy(this.config, options, defineTransport);\n };\n\n this.connection = Factory.createConnectionManager(this.key, {\n getStrategy: getStrategy,\n timeline: this.timeline,\n activityTimeout: this.config.activityTimeout,\n pongTimeout: this.config.pongTimeout,\n unavailableTimeout: this.config.unavailableTimeout,\n useTLS: Boolean(this.config.useTLS)\n });\n\n this.connection.bind('connected', () => {\n this.subscribeAll();\n if (this.timelineSender) {\n this.timelineSender.send(this.connection.isUsingTLS());\n }\n });\n\n this.connection.bind('message', event => {\n var eventName = event.event;\n var internal = eventName.indexOf('pusher_internal:') === 0;\n if (event.channel) {\n var channel = this.channel(event.channel);\n if (channel) {\n channel.handleEvent(event);\n }\n }\n // Emit globally [deprecated]\n if (!internal) {\n this.global_emitter.emit(event.event, event.data);\n }\n });\n this.connection.bind('connecting', () => {\n this.channels.disconnect();\n });\n this.connection.bind('disconnected', () => {\n this.channels.disconnect();\n });\n this.connection.bind('error', err => {\n Logger.warn(err);\n });\n\n Pusher.instances.push(this);\n this.timeline.info({ instances: Pusher.instances.length });\n\n this.user = new UserFacade(this);\n\n if (Pusher.isReady) {\n this.connect();\n }\n }\n\n /**\n * Allows you to switch Pusher cluster without\n * losing all the channels/subscription binding\n * as this is internally managed by the SDK.\n */\n switchCluster(options: ClusterOptions) {\n const { appKey, cluster } = options;\n this.key = appKey;\n this.options = { ...this.options, cluster };\n this.config = getConfig(this.options, this);\n this.connection.switchCluster(this.key);\n }\n\n channel(name: string): Channel {\n return this.channels.find(name);\n }\n\n allChannels(): Channel[] {\n return this.channels.all();\n }\n\n connect() {\n this.connection.connect();\n\n if (this.timelineSender) {\n if (!this.timelineSenderTimer) {\n var usingTLS = this.connection.isUsingTLS();\n var timelineSender = this.timelineSender;\n this.timelineSenderTimer = new PeriodicTimer(60000, function() {\n timelineSender.send(usingTLS);\n });\n }\n }\n }\n\n disconnect() {\n this.connection.disconnect();\n\n if (this.timelineSenderTimer) {\n this.timelineSenderTimer.ensureAborted();\n this.timelineSenderTimer = null;\n }\n }\n\n bind(event_name: string, callback: Function, context?: any): Pusher {\n this.global_emitter.bind(event_name, callback, context);\n return this;\n }\n\n unbind(event_name?: string, callback?: Function, context?: any): Pusher {\n this.global_emitter.unbind(event_name, callback, context);\n return this;\n }\n\n bind_global(callback: Function): Pusher {\n this.global_emitter.bind_global(callback);\n return this;\n }\n\n unbind_global(callback?: Function): Pusher {\n this.global_emitter.unbind_global(callback);\n return this;\n }\n\n unbind_all(callback?: Function): Pusher {\n this.global_emitter.unbind_all();\n return this;\n }\n\n subscribeAll() {\n var channelName;\n for (channelName in this.channels.channels) {\n if (this.channels.channels.hasOwnProperty(channelName)) {\n this.subscribe(channelName);\n }\n }\n }\n\n subscribe(channel_name: string) {\n var channel = this.channels.add(channel_name, this);\n if (channel.subscriptionPending && channel.subscriptionCancelled) {\n channel.reinstateSubscription();\n } else if (\n !channel.subscriptionPending &&\n this.connection.state === 'connected'\n ) {\n channel.subscribe();\n }\n return channel;\n }\n\n unsubscribe(channel_name: string) {\n var channel = this.channels.find(channel_name);\n if (channel && channel.subscriptionPending) {\n channel.cancelSubscription();\n } else {\n channel = this.channels.remove(channel_name);\n if (channel && channel.subscribed) {\n channel.unsubscribe();\n }\n }\n }\n\n send_event(event_name: string, data: any, channel?: string) {\n return this.connection.send_event(event_name, data, channel);\n }\n\n shouldUseTLS(): boolean {\n return this.config.useTLS;\n }\n\n signin() {\n this.user.signin();\n }\n}\n\nfunction checkAppKey(key) {\n if (key === null || key === undefined) {\n throw 'You must pass your app key when you instantiate Pusher.';\n }\n}\n\nRuntime.setup(Pusher);\n"],"sourceRoot":""} \ No newline at end of file diff --git a/dist/web/pusher.min.js b/dist/web/pusher.min.js index 0570518a2..0d5328a48 100644 --- a/dist/web/pusher.min.js +++ b/dist/web/pusher.min.js @@ -1,9 +1,9 @@ /*! - * Pusher JavaScript Library v8.3.0 + * Pusher JavaScript Library v8.4.0 * https://pusher.com/ * * Copyright 2020, Pusher * Released under the MIT licence. */ -!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.Pusher=e():t.Pusher=e()}(window,(function(){return function(t){var e={};function n(i){if(e[i])return e[i].exports;var r=e[i]={i:i,l:!1,exports:{}};return t[i].call(r.exports,r,r.exports,n),r.l=!0,r.exports}return n.m=t,n.c=e,n.d=function(t,e,i){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:i})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var i=Object.create(null);if(n.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var r in t)n.d(i,r,function(e){return t[e]}.bind(null,r));return i},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=2)}([function(t,e,n){"use strict";var i,r=this&&this.__extends||(i=function(t,e){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)},function(t,e){function n(){this.constructor=t}i(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)});Object.defineProperty(e,"__esModule",{value:!0});var s=function(){function t(t){void 0===t&&(t="="),this._paddingCharacter=t}return t.prototype.encodedLength=function(t){return this._paddingCharacter?(t+2)/3*4|0:(8*t+5)/6|0},t.prototype.encode=function(t){for(var e="",n=0;n>>18&63),e+=this._encodeByte(i>>>12&63),e+=this._encodeByte(i>>>6&63),e+=this._encodeByte(i>>>0&63)}var r=t.length-n;if(r>0){i=t[n]<<16|(2===r?t[n+1]<<8:0);e+=this._encodeByte(i>>>18&63),e+=this._encodeByte(i>>>12&63),e+=2===r?this._encodeByte(i>>>6&63):this._paddingCharacter||"",e+=this._paddingCharacter||""}return e},t.prototype.maxDecodedLength=function(t){return this._paddingCharacter?t/4*3|0:(6*t+7)/8|0},t.prototype.decodedLength=function(t){return this.maxDecodedLength(t.length-this._getPaddingLength(t))},t.prototype.decode=function(t){if(0===t.length)return new Uint8Array(0);for(var e=this._getPaddingLength(t),n=t.length-e,i=new Uint8Array(this.maxDecodedLength(n)),r=0,s=0,o=0,a=0,c=0,h=0,u=0;s>>4,i[r++]=c<<4|h>>>2,i[r++]=h<<6|u,o|=256&a,o|=256&c,o|=256&h,o|=256&u;if(s>>4,o|=256&a,o|=256&c),s>>2,o|=256&h),s>>8&6,e+=51-t>>>8&-75,e+=61-t>>>8&-15,e+=62-t>>>8&3,String.fromCharCode(e)},t.prototype._decodeChar=function(t){var e=256;return e+=(42-t&t-44)>>>8&-256+t-43+62,e+=(46-t&t-48)>>>8&-256+t-47+63,e+=(47-t&t-58)>>>8&-256+t-48+52,e+=(64-t&t-91)>>>8&-256+t-65+0,e+=(96-t&t-123)>>>8&-256+t-97+26},t.prototype._getPaddingLength=function(t){var e=0;if(this._paddingCharacter){for(var n=t.length-1;n>=0&&t[n]===this._paddingCharacter;n--)e++;if(t.length<4||e>2)throw new Error("Base64Coder: incorrect padding")}return e},t}();e.Coder=s;var o=new s;e.encode=function(t){return o.encode(t)},e.decode=function(t){return o.decode(t)};var a=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r(e,t),e.prototype._encodeByte=function(t){var e=t;return e+=65,e+=25-t>>>8&6,e+=51-t>>>8&-75,e+=61-t>>>8&-13,e+=62-t>>>8&49,String.fromCharCode(e)},e.prototype._decodeChar=function(t){var e=256;return e+=(44-t&t-46)>>>8&-256+t-45+62,e+=(94-t&t-96)>>>8&-256+t-95+63,e+=(47-t&t-58)>>>8&-256+t-48+52,e+=(64-t&t-91)>>>8&-256+t-65+0,e+=(96-t&t-123)>>>8&-256+t-97+26},e}(s);e.URLSafeCoder=a;var c=new a;e.encodeURLSafe=function(t){return c.encode(t)},e.decodeURLSafe=function(t){return c.decode(t)},e.encodedLength=function(t){return o.encodedLength(t)},e.maxDecodedLength=function(t){return o.maxDecodedLength(t)},e.decodedLength=function(t){return o.decodedLength(t)}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i="utf8: invalid source encoding";function r(t){for(var e=0,n=0;n=t.length-1)throw new Error("utf8: invalid string");n++,e+=4}}return e}e.encode=function(t){for(var e=new Uint8Array(r(t)),n=0,i=0;i>6,e[n++]=128|63&s):s<55296?(e[n++]=224|s>>12,e[n++]=128|s>>6&63,e[n++]=128|63&s):(i++,s=(1023&s)<<10,s|=1023&t.charCodeAt(i),s+=65536,e[n++]=240|s>>18,e[n++]=128|s>>12&63,e[n++]=128|s>>6&63,e[n++]=128|63&s)}return e},e.encodedLength=r,e.decode=function(t){for(var e=[],n=0;n=t.length)throw new Error(i);if(128!=(192&(o=t[++n])))throw new Error(i);r=(31&r)<<6|63&o,s=128}else if(r<240){if(n>=t.length-1)throw new Error(i);var o=t[++n],a=t[++n];if(128!=(192&o)||128!=(192&a))throw new Error(i);r=(15&r)<<12|(63&o)<<6|63&a,s=2048}else{if(!(r<248))throw new Error(i);if(n>=t.length-2)throw new Error(i);o=t[++n],a=t[++n];var c=t[++n];if(128!=(192&o)||128!=(192&a)||128!=(192&c))throw new Error(i);r=(15&r)<<18|(63&o)<<12|(63&a)<<6|63&c,s=65536}if(r=55296&&r<=57343)throw new Error(i);if(r>=65536){if(r>1114111)throw new Error(i);r-=65536,e.push(String.fromCharCode(55296|r>>10)),r=56320|1023&r}}e.push(String.fromCharCode(r))}return e.join("")}},function(t,e,n){t.exports=n(3).default},function(t,e,n){"use strict";n.r(e);class i{constructor(t,e){this.lastId=0,this.prefix=t,this.name=e}create(t){this.lastId++;var e=this.lastId,n=this.prefix+e,i=this.name+"["+e+"]",r=!1,s=function(){r||(t.apply(null,arguments),r=!0)};return this[e]=s,{number:e,id:n,name:i,callback:s}}remove(t){delete this[t.number]}}var r=new i("_pusher_script_","Pusher.ScriptReceivers"),s={VERSION:"8.3.0",PROTOCOL:7,wsPort:80,wssPort:443,wsPath:"",httpHost:"sockjs.pusher.com",httpPort:80,httpsPort:443,httpPath:"/pusher",stats_host:"stats.pusher.com",authEndpoint:"/pusher/auth",authTransport:"ajax",activityTimeout:12e4,pongTimeout:3e4,unavailableTimeout:1e4,userAuthentication:{endpoint:"/pusher/user-auth",transport:"ajax"},channelAuthorization:{endpoint:"/pusher/auth",transport:"ajax"},cdn_http:"http://js.pusher.com",cdn_https:"https://js.pusher.com",dependency_suffix:""};var o=new i("_pusher_dependencies","Pusher.DependenciesReceivers"),a=new class{constructor(t){this.options=t,this.receivers=t.receivers||r,this.loading={}}load(t,e,n){var i=this;if(i.loading[t]&&i.loading[t].length>0)i.loading[t].push(n);else{i.loading[t]=[n];var r=ue.createScriptRequest(i.getPath(t,e)),s=i.receivers.create((function(e){if(i.receivers.remove(s),i.loading[t]){var n=i.loading[t];delete i.loading[t];for(var o=function(t){t||r.cleanup()},a=0;a>>6)+S(128|63&e):S(224|e>>>12&15)+S(128|e>>>6&63)+S(128|63&e)},E=function(t){return t.replace(/[^\x00-\x7F]/g,P)},O=function(t){var e=[0,2,1][t.length%3],n=t.charCodeAt(0)<<16|(t.length>1?t.charCodeAt(1):0)<<8|(t.length>2?t.charCodeAt(2):0);return[_.charAt(n>>>18),_.charAt(n>>>12&63),e>=2?"=":_.charAt(n>>>6&63),e>=1?"=":_.charAt(63&n)].join("")},x=window.btoa||function(t){return t.replace(/[\s\S]{1,3}/g,O)};var L=class{constructor(t,e,n,i){this.clear=e,this.timer=t(()=>{this.timer&&(this.timer=i(this.timer))},n)}isRunning(){return null!==this.timer}ensureAborted(){this.timer&&(this.clear(this.timer),this.timer=null)}};function A(t){window.clearTimeout(t)}function R(t){window.clearInterval(t)}class I extends L{constructor(t,e){super(setTimeout,A,t,(function(t){return e(),null}))}}class D extends L{constructor(t,e){super(setInterval,R,t,(function(t){return e(),t}))}}var j={now:()=>Date.now?Date.now():(new Date).valueOf(),defer:t=>new I(0,t),method(t,...e){var n=Array.prototype.slice.call(arguments,1);return function(e){return e[t].apply(e,n.concat(arguments))}}};function N(t,...e){for(var n=0;n{window.console&&window.console.log&&window.console.log(t)}}debug(...t){this.log(this.globalLog,t)}warn(...t){this.log(this.globalLogWarn,t)}error(...t){this.log(this.globalLogError,t)}globalLogWarn(t){window.console&&window.console.warn?window.console.warn(t):this.globalLog(t)}globalLogError(t){window.console&&window.console.error?window.console.error(t):this.globalLogWarn(t)}log(t,...e){var n=H.apply(this,arguments);if(Le.log)Le.log(n);else if(Le.logToConsole){t.bind(this)(n)}}},Y=function(t,e,n,i,r){void 0===n.headers&&null==n.headersProvider||V.warn(`To send headers with the ${i.toString()} request, you must use AJAX, rather than JSONP.`);var s=t.nextAuthCallbackID.toString();t.nextAuthCallbackID++;var o=t.getDocument(),a=o.createElement("script");t.auth_callbacks[s]=function(t){r(null,t)};var c="Pusher.auth_callbacks['"+s+"']";a.src=n.endpoint+"?callback="+encodeURIComponent(c)+"&"+e;var h=o.getElementsByTagName("head")[0]||o.documentElement;h.insertBefore(a,h.firstChild)};class Q{constructor(t){this.src=t}send(t){var e=this,n="Error loading "+e.src;e.script=document.createElement("script"),e.script.id=t.id,e.script.src=e.src,e.script.type="text/javascript",e.script.charset="UTF-8",e.script.addEventListener?(e.script.onerror=function(){t.callback(n)},e.script.onload=function(){t.callback(null)}):e.script.onreadystatechange=function(){"loaded"!==e.script.readyState&&"complete"!==e.script.readyState||t.callback(null)},void 0===e.script.async&&document.attachEvent&&/opera/i.test(navigator.userAgent)?(e.errorScript=document.createElement("script"),e.errorScript.id=t.id+"_error",e.errorScript.text=t.name+"('"+n+"');",e.script.async=e.errorScript.async=!1):e.script.async=!0;var i=document.getElementsByTagName("head")[0];i.insertBefore(e.script,i.firstChild),e.errorScript&&i.insertBefore(e.errorScript,e.script.nextSibling)}cleanup(){this.script&&(this.script.onload=this.script.onerror=null,this.script.onreadystatechange=null),this.script&&this.script.parentNode&&this.script.parentNode.removeChild(this.script),this.errorScript&&this.errorScript.parentNode&&this.errorScript.parentNode.removeChild(this.errorScript),this.script=null,this.errorScript=null}}class K{constructor(t,e){this.url=t,this.data=e}send(t){if(!this.request){var e=W(this.data),n=this.url+"/"+t.number+"?"+e;this.request=ue.createScriptRequest(n),this.request.send(t)}}cleanup(){this.request&&this.request.cleanup()}}var Z={name:"jsonp",getAgent:function(t,e){return function(n,i){var s="http"+(e?"s":"")+"://"+(t.host||t.options.host)+t.options.path,o=ue.createJSONPRequest(s,n),a=ue.ScriptReceivers.create((function(e,n){r.remove(a),o.cleanup(),n&&n.host&&(t.host=n.host),i&&i(e,n)}));o.send(a)}}};function tt(t,e,n){return t+(e.useTLS?"s":"")+"://"+(e.useTLS?e.hostTLS:e.hostNonTLS)+n}function et(t,e){return"/app/"+t+("?protocol="+s.PROTOCOL+"&client=js&version="+s.VERSION+(e?"&"+e:""))}var nt={getInitial:function(t,e){return tt("ws",e,(e.httpPath||"")+et(t,"flash=false"))}},it={getInitial:function(t,e){return tt("http",e,(e.httpPath||"/pusher")+et(t))}},rt={getInitial:function(t,e){return tt("http",e,e.httpPath||"/pusher")},getPath:function(t,e){return et(t)}};class st{constructor(){this._callbacks={}}get(t){return this._callbacks[ot(t)]}add(t,e,n){var i=ot(t);this._callbacks[i]=this._callbacks[i]||[],this._callbacks[i].push({fn:e,context:n})}remove(t,e,n){if(t||e||n){var i=t?[ot(t)]:z(this._callbacks);e||n?this.removeCallback(i,e,n):this.removeAllCallbacks(i)}else this._callbacks={}}removeCallback(t,e,n){q(t,(function(t){this._callbacks[t]=F(this._callbacks[t]||[],(function(t){return e&&e!==t.fn||n&&n!==t.context})),0===this._callbacks[t].length&&delete this._callbacks[t]}),this)}removeAllCallbacks(t){q(t,(function(t){delete this._callbacks[t]}),this)}}function ot(t){return"_"+t}class at{constructor(t){this.callbacks=new st,this.global_callbacks=[],this.failThrough=t}bind(t,e,n){return this.callbacks.add(t,e,n),this}bind_global(t){return this.global_callbacks.push(t),this}unbind(t,e,n){return this.callbacks.remove(t,e,n),this}unbind_global(t){return t?(this.global_callbacks=F(this.global_callbacks||[],e=>e!==t),this):(this.global_callbacks=[],this)}unbind_all(){return this.unbind(),this.unbind_global(),this}emit(t,e,n){for(var i=0;i0)for(i=0;i{this.onError(t),this.changeState("closed")}),!1}return this.bindListeners(),V.debug("Connecting",{transport:this.name,url:t}),this.changeState("connecting"),!0}close(){return!!this.socket&&(this.socket.close(),!0)}send(t){return"open"===this.state&&(j.defer(()=>{this.socket&&this.socket.send(t)}),!0)}ping(){"open"===this.state&&this.supportsPing()&&this.socket.ping()}onOpen(){this.hooks.beforeOpen&&this.hooks.beforeOpen(this.socket,this.hooks.urls.getPath(this.key,this.options)),this.changeState("open"),this.socket.onopen=void 0}onError(t){this.emit("error",{type:"WebSocketError",error:t}),this.timeline.error(this.buildTimelineMessage({error:t.toString()}))}onClose(t){t?this.changeState("closed",{code:t.code,reason:t.reason,wasClean:t.wasClean}):this.changeState("closed"),this.unbindListeners(),this.socket=void 0}onMessage(t){this.emit("message",t)}onActivity(){this.emit("activity")}bindListeners(){this.socket.onopen=()=>{this.onOpen()},this.socket.onerror=t=>{this.onError(t)},this.socket.onclose=t=>{this.onClose(t)},this.socket.onmessage=t=>{this.onMessage(t)},this.supportsPing()&&(this.socket.onactivity=()=>{this.onActivity()})}unbindListeners(){this.socket&&(this.socket.onopen=void 0,this.socket.onerror=void 0,this.socket.onclose=void 0,this.socket.onmessage=void 0,this.supportsPing()&&(this.socket.onactivity=void 0))}changeState(t,e){this.state=t,this.timeline.info(this.buildTimelineMessage({state:t,params:e})),this.emit(t,e)}buildTimelineMessage(t){return N({cid:this.id},t)}}class ht{constructor(t){this.hooks=t}isSupported(t){return this.hooks.isSupported(t)}createConnection(t,e,n,i){return new ct(this.hooks,t,e,n,i)}}var ut=new ht({urls:nt,handlesActivityChecks:!1,supportsPing:!1,isInitialized:function(){return Boolean(ue.getWebSocketAPI())},isSupported:function(){return Boolean(ue.getWebSocketAPI())},getSocket:function(t){return ue.createWebSocket(t)}}),lt={urls:it,handlesActivityChecks:!1,supportsPing:!0,isInitialized:function(){return!0}},dt=N({getSocket:function(t){return ue.HTTPFactory.createStreamingSocket(t)}},lt),pt=N({getSocket:function(t){return ue.HTTPFactory.createPollingSocket(t)}},lt),ft={isSupported:function(){return ue.isXHRSupported()}},gt={ws:ut,xhr_streaming:new ht(N({},dt,ft)),xhr_polling:new ht(N({},pt,ft))},vt=new ht({file:"sockjs",urls:rt,handlesActivityChecks:!0,supportsPing:!1,isSupported:function(){return!0},isInitialized:function(){return void 0!==window.SockJS},getSocket:function(t,e){return new window.SockJS(t,null,{js_path:a.getPath("sockjs",{useTLS:e.useTLS}),ignore_null_origin:e.ignoreNullOrigin})},beforeOpen:function(t,e){t.send(JSON.stringify({path:e}))}}),mt={isSupported:function(t){return ue.isXDRSupported(t.useTLS)}},bt=new ht(N({},dt,mt)),yt=new ht(N({},pt,mt));gt.xdr_streaming=bt,gt.xdr_polling=yt,gt.sockjs=vt;var wt=gt;var St=new class extends at{constructor(){super();var t=this;void 0!==window.addEventListener&&(window.addEventListener("online",(function(){t.emit("online")}),!1),window.addEventListener("offline",(function(){t.emit("offline")}),!1))}isOnline(){return void 0===window.navigator.onLine||window.navigator.onLine}};class _t{constructor(t,e,n){this.manager=t,this.transport=e,this.minPingDelay=n.minPingDelay,this.maxPingDelay=n.maxPingDelay,this.pingDelay=void 0}createConnection(t,e,n,i){i=N({},i,{activityTimeout:this.pingDelay});var r=this.transport.createConnection(t,e,n,i),s=null,o=function(){r.unbind("open",o),r.bind("closed",a),s=j.now()},a=t=>{if(r.unbind("closed",a),1002===t.code||1003===t.code)this.manager.reportDeath();else if(!t.wasClean&&s){var e=j.now()-s;e<2*this.maxPingDelay&&(this.manager.reportDeath(),this.pingDelay=Math.max(e/2,this.minPingDelay))}};return r.bind("open",o),r}isSupported(t){return this.manager.isAlive()&&this.transport.isSupported(t)}}const kt={decodeMessage:function(t){try{var e=JSON.parse(t.data),n=e.data;if("string"==typeof n)try{n=JSON.parse(e.data)}catch(t){}var i={event:e.event,channel:e.channel,data:n};return e.user_id&&(i.user_id=e.user_id),i}catch(e){throw{type:"MessageParseError",error:e,data:t.data}}},encodeMessage:function(t){return JSON.stringify(t)},processHandshake:function(t){var e=kt.decodeMessage(t);if("pusher:connection_established"===e.event){if(!e.data.activity_timeout)throw"No activity timeout specified in handshake";return{action:"connected",id:e.data.socket_id,activityTimeout:1e3*e.data.activity_timeout}}if("pusher:error"===e.event)return{action:this.getCloseAction(e.data),error:this.getCloseError(e.data)};throw"Invalid handshake"},getCloseAction:function(t){return t.code<4e3?t.code>=1002&&t.code<=1004?"backoff":null:4e3===t.code?"tls_only":t.code<4100?"refused":t.code<4200?"backoff":t.code<4300?"retry":"refused"},getCloseError:function(t){return 1e3!==t.code&&1001!==t.code?{type:"PusherError",data:{code:t.code,message:t.reason||t.message}}:null}};var Ct=kt;class Tt extends at{constructor(t,e){super(),this.id=t,this.transport=e,this.activityTimeout=e.activityTimeout,this.bindListeners()}handlesActivityChecks(){return this.transport.handlesActivityChecks()}send(t){return this.transport.send(t)}send_event(t,e,n){var i={event:t,data:e};return n&&(i.channel=n),V.debug("Event sent",i),this.send(Ct.encodeMessage(i))}ping(){this.transport.supportsPing()?this.transport.ping():this.send_event("pusher:ping",{})}close(){this.transport.close()}bindListeners(){var t={message:t=>{var e;try{e=Ct.decodeMessage(t)}catch(e){this.emit("error",{type:"MessageParseError",error:e,data:t.data})}if(void 0!==e){switch(V.debug("Event recd",e),e.event){case"pusher:error":this.emit("error",{type:"PusherError",data:e.data});break;case"pusher:ping":this.emit("ping");break;case"pusher:pong":this.emit("pong")}this.emit("message",e)}},activity:()=>{this.emit("activity")},error:t=>{this.emit("error",t)},closed:t=>{e(),t&&t.code&&this.handleCloseEvent(t),this.transport=null,this.emit("closed")}},e=()=>{M(t,(t,e)=>{this.transport.unbind(e,t)})};M(t,(t,e)=>{this.transport.bind(e,t)})}handleCloseEvent(t){var e=Ct.getCloseAction(t),n=Ct.getCloseError(t);n&&this.emit("error",n),e&&this.emit(e,{action:e,error:n})}}class Pt{constructor(t,e){this.transport=t,this.callback=e,this.bindListeners()}close(){this.unbindListeners(),this.transport.close()}bindListeners(){this.onMessage=t=>{var e;this.unbindListeners();try{e=Ct.processHandshake(t)}catch(t){return this.finish("error",{error:t}),void this.transport.close()}"connected"===e.action?this.finish("connected",{connection:new Tt(e.id,this.transport),activityTimeout:e.activityTimeout}):(this.finish(e.action,{error:e.error}),this.transport.close())},this.onClosed=t=>{this.unbindListeners();var e=Ct.getCloseAction(t)||"backoff",n=Ct.getCloseError(t);this.finish(e,{error:n})},this.transport.bind("message",this.onMessage),this.transport.bind("closed",this.onClosed)}unbindListeners(){this.transport.unbind("message",this.onMessage),this.transport.unbind("closed",this.onClosed)}finish(t,e){this.callback(N({transport:this.transport,action:t},e))}}class Et{constructor(t,e){this.timeline=t,this.options=e||{}}send(t,e){this.timeline.isEmpty()||this.timeline.send(ue.TimelineTransport.getAgent(this,t),e)}}class Ot extends at{constructor(t,e){super((function(e,n){V.debug("No callbacks on "+t+" for "+e)})),this.name=t,this.pusher=e,this.subscribed=!1,this.subscriptionPending=!1,this.subscriptionCancelled=!1}authorize(t,e){return e(null,{auth:""})}trigger(t,e){if(0!==t.indexOf("client-"))throw new l("Event '"+t+"' does not start with 'client-'");if(!this.subscribed){var n=u("triggeringClientEvents");V.warn("Client event triggered before channel 'subscription_succeeded' event . "+n)}return this.pusher.send_event(t,e,this.name)}disconnect(){this.subscribed=!1,this.subscriptionPending=!1}handleEvent(t){var e=t.event,n=t.data;if("pusher_internal:subscription_succeeded"===e)this.handleSubscriptionSucceededEvent(t);else if("pusher_internal:subscription_count"===e)this.handleSubscriptionCountEvent(t);else if(0!==e.indexOf("pusher_internal:")){this.emit(e,n,{})}}handleSubscriptionSucceededEvent(t){this.subscriptionPending=!1,this.subscribed=!0,this.subscriptionCancelled?this.pusher.unsubscribe(this.name):this.emit("pusher:subscription_succeeded",t.data)}handleSubscriptionCountEvent(t){t.data.subscription_count&&(this.subscriptionCount=t.data.subscription_count),this.emit("pusher:subscription_count",t.data)}subscribe(){this.subscribed||(this.subscriptionPending=!0,this.subscriptionCancelled=!1,this.authorize(this.pusher.connection.socket_id,(t,e)=>{t?(this.subscriptionPending=!1,V.error(t.toString()),this.emit("pusher:subscription_error",Object.assign({},{type:"AuthError",error:t.message},t instanceof y?{status:t.status}:{}))):this.pusher.send_event("pusher:subscribe",{auth:e.auth,channel_data:e.channel_data,channel:this.name})}))}unsubscribe(){this.subscribed=!1,this.pusher.send_event("pusher:unsubscribe",{channel:this.name})}cancelSubscription(){this.subscriptionCancelled=!0}reinstateSubscription(){this.subscriptionCancelled=!1}}class xt extends Ot{authorize(t,e){return this.pusher.config.channelAuthorizer({channelName:this.name,socketId:t},e)}}class Lt{constructor(){this.reset()}get(t){return Object.prototype.hasOwnProperty.call(this.members,t)?{id:t,info:this.members[t]}:null}each(t){M(this.members,(e,n)=>{t(this.get(n))})}setMyID(t){this.myID=t}onSubscription(t){this.members=t.presence.hash,this.count=t.presence.count,this.me=this.get(this.myID)}addMember(t){return null===this.get(t.user_id)&&this.count++,this.members[t.user_id]=t.user_info,this.get(t.user_id)}removeMember(t){var e=this.get(t.user_id);return e&&(delete this.members[t.user_id],this.count--),e}reset(){this.members={},this.count=0,this.myID=null,this.me=null}}var At=function(t,e,n,i){return new(n||(n=Promise))((function(r,s){function o(t){try{c(i.next(t))}catch(t){s(t)}}function a(t){try{c(i.throw(t))}catch(t){s(t)}}function c(t){var e;t.done?r(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(o,a)}c((i=i.apply(t,e||[])).next())}))};class Rt extends xt{constructor(t,e){super(t,e),this.members=new Lt}authorize(t,e){super.authorize(t,(t,n)=>At(this,void 0,void 0,(function*(){if(!t)if(null!=(n=n).channel_data){var i=JSON.parse(n.channel_data);this.members.setMyID(i.user_id)}else{if(yield this.pusher.user.signinDonePromise,null==this.pusher.user.user_data){let t=u("authorizationEndpoint");return V.error(`Invalid auth response for channel '${this.name}', expected 'channel_data' field. ${t}, or the user should be signed in.`),void e("Invalid auth response")}this.members.setMyID(this.pusher.user.user_data.id)}e(t,n)})))}handleEvent(t){var e=t.event;if(0===e.indexOf("pusher_internal:"))this.handleInternalEvent(t);else{var n=t.data,i={};t.user_id&&(i.user_id=t.user_id),this.emit(e,n,i)}}handleInternalEvent(t){var e=t.event,n=t.data;switch(e){case"pusher_internal:subscription_succeeded":this.handleSubscriptionSucceededEvent(t);break;case"pusher_internal:subscription_count":this.handleSubscriptionCountEvent(t);break;case"pusher_internal:member_added":var i=this.members.addMember(n);this.emit("pusher:member_added",i);break;case"pusher_internal:member_removed":var r=this.members.removeMember(n);r&&this.emit("pusher:member_removed",r)}}handleSubscriptionSucceededEvent(t){this.subscriptionPending=!1,this.subscribed=!0,this.subscriptionCancelled?this.pusher.unsubscribe(this.name):(this.members.onSubscription(t.data),this.emit("pusher:subscription_succeeded",this.members))}disconnect(){this.members.reset(),super.disconnect()}}var It=n(1),Dt=n(0);class jt extends xt{constructor(t,e,n){super(t,e),this.key=null,this.nacl=n}authorize(t,e){super.authorize(t,(t,n)=>{if(t)return void e(t,n);let i=n.shared_secret;i?(this.key=Object(Dt.decode)(i),delete n.shared_secret,e(null,n)):e(new Error("No shared_secret key in auth payload for encrypted channel: "+this.name),null)})}trigger(t,e){throw new v("Client events are not currently supported for encrypted channels")}handleEvent(t){var e=t.event,n=t.data;0!==e.indexOf("pusher_internal:")&&0!==e.indexOf("pusher:")?this.handleEncryptedEvent(e,n):super.handleEvent(t)}handleEncryptedEvent(t,e){if(!this.key)return void V.debug("Received encrypted event before key has been retrieved from the authEndpoint");if(!e.ciphertext||!e.nonce)return void V.error("Unexpected format for encrypted event, expected object with `ciphertext` and `nonce` fields, got: "+e);let n=Object(Dt.decode)(e.ciphertext);if(n.length{e?V.error(`Failed to make a request to the authEndpoint: ${s}. Unable to fetch new key, so dropping encrypted event`):(r=this.nacl.secretbox.open(n,i,this.key),null!==r?this.emit(t,this.getDataToEmit(r)):V.error("Failed to decrypt event with new key. Dropping encrypted event"))});this.emit(t,this.getDataToEmit(r))}getDataToEmit(t){let e=Object(It.decode)(t);try{return JSON.parse(e)}catch(t){return e}}}class Nt extends at{constructor(t,e){super(),this.state="initialized",this.connection=null,this.key=t,this.options=e,this.timeline=this.options.timeline,this.usingTLS=this.options.useTLS,this.errorCallbacks=this.buildErrorCallbacks(),this.connectionCallbacks=this.buildConnectionCallbacks(this.errorCallbacks),this.handshakeCallbacks=this.buildHandshakeCallbacks(this.errorCallbacks);var n=ue.getNetwork();n.bind("online",()=>{this.timeline.info({netinfo:"online"}),"connecting"!==this.state&&"unavailable"!==this.state||this.retryIn(0)}),n.bind("offline",()=>{this.timeline.info({netinfo:"offline"}),this.connection&&this.sendActivityCheck()}),this.updateStrategy()}connect(){this.connection||this.runner||(this.strategy.isSupported()?(this.updateState("connecting"),this.startConnecting(),this.setUnavailableTimer()):this.updateState("failed"))}send(t){return!!this.connection&&this.connection.send(t)}send_event(t,e,n){return!!this.connection&&this.connection.send_event(t,e,n)}disconnect(){this.disconnectInternally(),this.updateState("disconnected")}isUsingTLS(){return this.usingTLS}startConnecting(){var t=(e,n)=>{e?this.runner=this.strategy.connect(0,t):"error"===n.action?(this.emit("error",{type:"HandshakeError",error:n.error}),this.timeline.error({handshakeError:n.error})):(this.abortConnecting(),this.handshakeCallbacks[n.action](n))};this.runner=this.strategy.connect(0,t)}abortConnecting(){this.runner&&(this.runner.abort(),this.runner=null)}disconnectInternally(){(this.abortConnecting(),this.clearRetryTimer(),this.clearUnavailableTimer(),this.connection)&&this.abandonConnection().close()}updateStrategy(){this.strategy=this.options.getStrategy({key:this.key,timeline:this.timeline,useTLS:this.usingTLS})}retryIn(t){this.timeline.info({action:"retry",delay:t}),t>0&&this.emit("connecting_in",Math.round(t/1e3)),this.retryTimer=new I(t||0,()=>{this.disconnectInternally(),this.connect()})}clearRetryTimer(){this.retryTimer&&(this.retryTimer.ensureAborted(),this.retryTimer=null)}setUnavailableTimer(){this.unavailableTimer=new I(this.options.unavailableTimeout,()=>{this.updateState("unavailable")})}clearUnavailableTimer(){this.unavailableTimer&&this.unavailableTimer.ensureAborted()}sendActivityCheck(){this.stopActivityCheck(),this.connection.ping(),this.activityTimer=new I(this.options.pongTimeout,()=>{this.timeline.error({pong_timed_out:this.options.pongTimeout}),this.retryIn(0)})}resetActivityCheck(){this.stopActivityCheck(),this.connection&&!this.connection.handlesActivityChecks()&&(this.activityTimer=new I(this.activityTimeout,()=>{this.sendActivityCheck()}))}stopActivityCheck(){this.activityTimer&&this.activityTimer.ensureAborted()}buildConnectionCallbacks(t){return N({},t,{message:t=>{this.resetActivityCheck(),this.emit("message",t)},ping:()=>{this.send_event("pusher:pong",{})},activity:()=>{this.resetActivityCheck()},error:t=>{this.emit("error",t)},closed:()=>{this.abandonConnection(),this.shouldRetry()&&this.retryIn(1e3)}})}buildHandshakeCallbacks(t){return N({},t,{connected:t=>{this.activityTimeout=Math.min(this.options.activityTimeout,t.activityTimeout,t.connection.activityTimeout||1/0),this.clearUnavailableTimer(),this.setConnection(t.connection),this.socket_id=this.connection.id,this.updateState("connected",{socket_id:this.socket_id})}})}buildErrorCallbacks(){let t=t=>e=>{e.error&&this.emit("error",{type:"WebSocketError",error:e.error}),t(e)};return{tls_only:t(()=>{this.usingTLS=!0,this.updateStrategy(),this.retryIn(0)}),refused:t(()=>{this.disconnect()}),backoff:t(()=>{this.retryIn(1e3)}),retry:t(()=>{this.retryIn(0)})}}setConnection(t){for(var e in this.connection=t,this.connectionCallbacks)this.connection.bind(e,this.connectionCallbacks[e]);this.resetActivityCheck()}abandonConnection(){if(this.connection){for(var t in this.stopActivityCheck(),this.connectionCallbacks)this.connection.unbind(t,this.connectionCallbacks[t]);var e=this.connection;return this.connection=null,e}}updateState(t,e){var n=this.state;if(this.state=t,n!==t){var i=t;"connected"===i&&(i+=" with new socket ID "+e.socket_id),V.debug("State changed",n+" -> "+i),this.timeline.info({state:t,params:e}),this.emit("state_change",{previous:n,current:t}),this.emit(t,e)}}shouldRetry(){return"connecting"===this.state||"connected"===this.state}}class Ht{constructor(){this.channels={}}add(t,e){return this.channels[t]||(this.channels[t]=function(t,e){if(0===t.indexOf("private-encrypted-")){if(e.config.nacl)return Ut.createEncryptedChannel(t,e,e.config.nacl);let n="Tried to subscribe to a private-encrypted- channel but no nacl implementation available",i=u("encryptedChannelSupport");throw new v(`${n}. ${i}`)}if(0===t.indexOf("private-"))return Ut.createPrivateChannel(t,e);if(0===t.indexOf("presence-"))return Ut.createPresenceChannel(t,e);if(0===t.indexOf("#"))throw new d('Cannot create a channel with name "'+t+'".');return Ut.createChannel(t,e)}(t,e)),this.channels[t]}all(){return function(t){var e=[];return M(t,(function(t){e.push(t)})),e}(this.channels)}find(t){return this.channels[t]}remove(t){var e=this.channels[t];return delete this.channels[t],e}disconnect(){M(this.channels,(function(t){t.disconnect()}))}}var Ut={createChannels:()=>new Ht,createConnectionManager:(t,e)=>new Nt(t,e),createChannel:(t,e)=>new Ot(t,e),createPrivateChannel:(t,e)=>new xt(t,e),createPresenceChannel:(t,e)=>new Rt(t,e),createEncryptedChannel:(t,e,n)=>new jt(t,e,n),createTimelineSender:(t,e)=>new Et(t,e),createHandshake:(t,e)=>new Pt(t,e),createAssistantToTheTransportManager:(t,e,n)=>new _t(t,e,n)};class Mt{constructor(t){this.options=t||{},this.livesLeft=this.options.lives||1/0}getAssistant(t){return Ut.createAssistantToTheTransportManager(this,t,{minPingDelay:this.options.minPingDelay,maxPingDelay:this.options.maxPingDelay})}isAlive(){return this.livesLeft>0}reportDeath(){this.livesLeft-=1}}class zt{constructor(t,e){this.strategies=t,this.loop=Boolean(e.loop),this.failFast=Boolean(e.failFast),this.timeout=e.timeout,this.timeoutLimit=e.timeoutLimit}isSupported(){return J(this.strategies,j.method("isSupported"))}connect(t,e){var n=this.strategies,i=0,r=this.timeout,s=null,o=(a,c)=>{c?e(null,c):(i+=1,this.loop&&(i%=n.length),i0&&(r=new I(n.timeout,(function(){s.abort(),i(!0)}))),s=t.connect(e,(function(t,e){t&&r&&r.isRunning()&&!n.failFast||(r&&r.ensureAborted(),i(t,e))})),{abort:function(){r&&r.ensureAborted(),s.abort()},forceMinPriority:function(t){s.forceMinPriority(t)}}}}class qt{constructor(t){this.strategies=t}isSupported(){return J(this.strategies,j.method("isSupported"))}connect(t,e){return function(t,e,n){var i=B(t,(function(t,i,r,s){return t.connect(e,n(i,s))}));return{abort:function(){q(i,Bt)},forceMinPriority:function(t){q(i,(function(e){e.forceMinPriority(t)}))}}}(this.strategies,t,(function(t,n){return function(i,r){n[t].error=i,i?function(t){return function(t,e){for(var n=0;n=j.now()){var o=this.transports[i.transport];o&&(["ws","wss"].includes(i.transport)||r>3?(this.timeline.info({cached:!0,transport:i.transport,latency:i.latency}),s.push(new zt([o],{timeout:2*i.latency+1e3,failFast:!0}))):r++)}var a=j.now(),c=s.pop().connect(t,(function i(o,h){o?(Jt(n),s.length>0?(a=j.now(),c=s.pop().connect(t,i)):e(o)):(!function(t,e,n,i){var r=ue.getLocalStorage();if(r)try{r[Xt(t)]=G({timestamp:j.now(),transport:e,latency:n,cacheSkipCount:i})}catch(t){}}(n,h.transport.name,j.now()-a,r),e(null,h))}));return{abort:function(){c.abort()},forceMinPriority:function(e){t=e,c&&c.forceMinPriority(e)}}}}function Xt(t){return"pusherTransport"+(t?"TLS":"NonTLS")}function Jt(t){var e=ue.getLocalStorage();if(e)try{delete e[Xt(t)]}catch(t){}}class $t{constructor(t,{delay:e}){this.strategy=t,this.options={delay:e}}isSupported(){return this.strategy.isSupported()}connect(t,e){var n,i=this.strategy,r=new I(this.options.delay,(function(){n=i.connect(t,e)}));return{abort:function(){r.ensureAborted(),n&&n.abort()},forceMinPriority:function(e){t=e,n&&n.forceMinPriority(e)}}}}class Wt{constructor(t,e,n){this.test=t,this.trueBranch=e,this.falseBranch=n}isSupported(){return(this.test()?this.trueBranch:this.falseBranch).isSupported()}connect(t,e){return(this.test()?this.trueBranch:this.falseBranch).connect(t,e)}}class Gt{constructor(t){this.strategy=t}isSupported(){return this.strategy.isSupported()}connect(t,e){var n=this.strategy.connect(t,(function(t,i){i&&n.abort(),e(t,i)}));return n}}function Vt(t){return function(){return t.isSupported()}}var Yt=function(t,e,n){var i={};function r(e,r,s,o,a){var c=n(t,e,r,s,o,a);return i[e]=c,c}var s,o=Object.assign({},e,{hostNonTLS:t.wsHost+":"+t.wsPort,hostTLS:t.wsHost+":"+t.wssPort,httpPath:t.wsPath}),a=Object.assign({},o,{useTLS:!0}),c=Object.assign({},e,{hostNonTLS:t.httpHost+":"+t.httpPort,hostTLS:t.httpHost+":"+t.httpsPort,httpPath:t.httpPath}),h={loop:!0,timeout:15e3,timeoutLimit:6e4},u=new Mt({minPingDelay:1e4,maxPingDelay:t.activityTimeout}),l=new Mt({lives:2,minPingDelay:1e4,maxPingDelay:t.activityTimeout}),d=r("ws","ws",3,o,u),p=r("wss","ws",3,a,u),f=r("sockjs","sockjs",1,c),g=r("xhr_streaming","xhr_streaming",1,c,l),v=r("xdr_streaming","xdr_streaming",1,c,l),m=r("xhr_polling","xhr_polling",1,c),b=r("xdr_polling","xdr_polling",1,c),y=new zt([d],h),w=new zt([p],h),S=new zt([f],h),_=new zt([new Wt(Vt(g),g,v)],h),k=new zt([new Wt(Vt(m),m,b)],h),C=new zt([new Wt(Vt(_),new qt([_,new $t(k,{delay:4e3})]),k)],h),T=new Wt(Vt(C),C,S);return s=e.useTLS?new qt([y,new $t(T,{delay:2e3})]):new qt([y,new $t(w,{delay:2e3}),new $t(T,{delay:5e3})]),new Ft(new Gt(new Wt(Vt(d),s,T)),i,{ttl:18e5,timeline:e.timeline,useTLS:e.useTLS})},Qt={getRequest:function(t){var e=new window.XDomainRequest;return e.ontimeout=function(){t.emit("error",new p),t.close()},e.onerror=function(e){t.emit("error",e),t.close()},e.onprogress=function(){e.responseText&&e.responseText.length>0&&t.onChunk(200,e.responseText)},e.onload=function(){e.responseText&&e.responseText.length>0&&t.onChunk(200,e.responseText),t.emit("finished",200),t.close()},e},abortRequest:function(t){t.ontimeout=t.onerror=t.onprogress=t.onload=null,t.abort()}};class Kt extends at{constructor(t,e,n){super(),this.hooks=t,this.method=e,this.url=n}start(t){this.position=0,this.xhr=this.hooks.getRequest(this),this.unloader=()=>{this.close()},ue.addUnloadListener(this.unloader),this.xhr.open(this.method,this.url,!0),this.xhr.setRequestHeader&&this.xhr.setRequestHeader("Content-Type","application/json"),this.xhr.send(t)}close(){this.unloader&&(ue.removeUnloadListener(this.unloader),this.unloader=null),this.xhr&&(this.hooks.abortRequest(this.xhr),this.xhr=null)}onChunk(t,e){for(;;){var n=this.advanceBuffer(e);if(!n)break;this.emit("chunk",{status:t,data:n})}this.isBufferTooLong(e)&&this.emit("buffer_too_long")}advanceBuffer(t){var e=t.slice(this.position),n=e.indexOf("\n");return-1!==n?(this.position+=n+1,e.slice(0,n)):null}isBufferTooLong(t){return this.position===t.length&&t.length>262144}}var Zt;!function(t){t[t.CONNECTING=0]="CONNECTING",t[t.OPEN=1]="OPEN",t[t.CLOSED=3]="CLOSED"}(Zt||(Zt={}));var te=Zt,ee=1;function ne(t){var e=-1===t.indexOf("?")?"?":"&";return t+e+"t="+ +new Date+"&n="+ee++}function ie(t){return ue.randomInt(t)}var re,se=class{constructor(t,e){this.hooks=t,this.session=ie(1e3)+"/"+function(t){for(var e=[],n=0;n{this.onChunk(t)}),this.stream.bind("finished",t=>{this.hooks.onFinished(this,t)}),this.stream.bind("buffer_too_long",()=>{this.reconnect()});try{this.stream.start()}catch(t){j.defer(()=>{this.onError(t),this.onClose(1006,"Could not start streaming",!1)})}}closeStream(){this.stream&&(this.stream.unbind_all(),this.stream.close(),this.stream=null)}},oe={getReceiveURL:function(t,e){return t.base+"/"+e+"/xhr_streaming"+t.queryString},onHeartbeat:function(t){t.sendRaw("[]")},sendHeartbeat:function(t){t.sendRaw("[]")},onFinished:function(t,e){t.onClose(1006,"Connection interrupted ("+e+")",!1)}},ae={getReceiveURL:function(t,e){return t.base+"/"+e+"/xhr"+t.queryString},onHeartbeat:function(){},sendHeartbeat:function(t){t.sendRaw("[]")},onFinished:function(t,e){200===e?t.reconnect():t.onClose(1006,"Connection interrupted ("+e+")",!1)}},ce={getRequest:function(t){var e=new(ue.getXHRAPI());return e.onreadystatechange=e.onprogress=function(){switch(e.readyState){case 3:e.responseText&&e.responseText.length>0&&t.onChunk(e.status,e.responseText);break;case 4:e.responseText&&e.responseText.length>0&&t.onChunk(e.status,e.responseText),t.emit("finished",e.status),t.close()}},e},abortRequest:function(t){t.onreadystatechange=null,t.abort()}},he={createStreamingSocket(t){return this.createSocket(oe,t)},createPollingSocket(t){return this.createSocket(ae,t)},createSocket:(t,e)=>new se(t,e),createXHR(t,e){return this.createRequest(ce,t,e)},createRequest:(t,e,n)=>new Kt(t,e,n),createXDR:function(t,e){return this.createRequest(Qt,t,e)}},ue={nextAuthCallbackID:1,auth_callbacks:{},ScriptReceivers:r,DependenciesReceivers:o,getDefaultStrategy:Yt,Transports:wt,transportConnectionInitializer:function(){var t=this;t.timeline.info(t.buildTimelineMessage({transport:t.name+(t.options.useTLS?"s":"")})),t.hooks.isInitialized()?t.changeState("initialized"):t.hooks.file?(t.changeState("initializing"),a.load(t.hooks.file,{useTLS:t.options.useTLS},(function(e,n){t.hooks.isInitialized()?(t.changeState("initialized"),n(!0)):(e&&t.onError(e),t.onClose(),n(!1))}))):t.onClose()},HTTPFactory:he,TimelineTransport:Z,getXHRAPI:()=>window.XMLHttpRequest,getWebSocketAPI:()=>window.WebSocket||window.MozWebSocket,setup(t){window.Pusher=t;var e=()=>{this.onDocumentBody(t.ready)};window.JSON?e():a.load("json2",{},e)},getDocument:()=>document,getProtocol(){return this.getDocument().location.protocol},getAuthorizers:()=>({ajax:w,jsonp:Y}),onDocumentBody(t){document.body?t():setTimeout(()=>{this.onDocumentBody(t)},0)},createJSONPRequest:(t,e)=>new K(t,e),createScriptRequest:t=>new Q(t),getLocalStorage(){try{return window.localStorage}catch(t){return}},createXHR(){return this.getXHRAPI()?this.createXMLHttpRequest():this.createMicrosoftXHR()},createXMLHttpRequest(){return new(this.getXHRAPI())},createMicrosoftXHR:()=>new ActiveXObject("Microsoft.XMLHTTP"),getNetwork:()=>St,createWebSocket(t){return new(this.getWebSocketAPI())(t)},createSocketRequest(t,e){if(this.isXHRSupported())return this.HTTPFactory.createXHR(t,e);if(this.isXDRSupported(0===e.indexOf("https:")))return this.HTTPFactory.createXDR(t,e);throw"Cross-origin HTTP requests are not supported"},isXHRSupported(){var t=this.getXHRAPI();return Boolean(t)&&void 0!==(new t).withCredentials},isXDRSupported(t){var e=t?"https:":"http:",n=this.getProtocol();return Boolean(window.XDomainRequest)&&n===e},addUnloadListener(t){void 0!==window.addEventListener?window.addEventListener("unload",t,!1):void 0!==window.attachEvent&&window.attachEvent("onunload",t)},removeUnloadListener(t){void 0!==window.addEventListener?window.removeEventListener("unload",t,!1):void 0!==window.detachEvent&&window.detachEvent("onunload",t)},randomInt:t=>Math.floor((window.crypto||window.msCrypto).getRandomValues(new Uint32Array(1))[0]/Math.pow(2,32)*t)};!function(t){t[t.ERROR=3]="ERROR",t[t.INFO=6]="INFO",t[t.DEBUG=7]="DEBUG"}(re||(re={}));var le=re;class de{constructor(t,e,n){this.key=t,this.session=e,this.events=[],this.options=n||{},this.sent=0,this.uniqueID=0}log(t,e){t<=this.options.level&&(this.events.push(N({},e,{timestamp:j.now()})),this.options.limit&&this.events.length>this.options.limit&&this.events.shift())}error(t){this.log(le.ERROR,t)}info(t){this.log(le.INFO,t)}debug(t){this.log(le.DEBUG,t)}isEmpty(){return 0===this.events.length}send(t,e){var n=N({session:this.session,bundle:this.sent+1,key:this.key,lib:"js",version:this.options.version,cluster:this.options.cluster,features:this.options.features,timeline:this.events},this.options.params);return this.events=[],t(n,(t,n)=>{t||this.sent++,e&&e(t,n)}),!0}generateUniqueID(){return this.uniqueID++,this.uniqueID}}class pe{constructor(t,e,n,i){this.name=t,this.priority=e,this.transport=n,this.options=i||{}}isSupported(){return this.transport.isSupported({useTLS:this.options.useTLS})}connect(t,e){if(!this.isSupported())return fe(new b,e);if(this.priority{n||(h(),r?r.close():i.close())},forceMinPriority:t=>{n||this.priority{if(void 0===ue.getAuthorizers()[t.transport])throw`'${t.transport}' is not a recognized auth transport`;return(e,n)=>{const i=((t,e)=>{var n="socket_id="+encodeURIComponent(t.socketId);for(var i in e.params)n+="&"+encodeURIComponent(i)+"="+encodeURIComponent(e.params[i]);if(null!=e.paramsProvider){let t=e.paramsProvider();for(var i in t)n+="&"+encodeURIComponent(i)+"="+encodeURIComponent(t[i])}return n})(e,t);ue.getAuthorizers()[t.transport](ue,i,t,h.UserAuthentication,n)}};var ye=t=>{if(void 0===ue.getAuthorizers()[t.transport])throw`'${t.transport}' is not a recognized auth transport`;return(e,n)=>{const i=((t,e)=>{var n="socket_id="+encodeURIComponent(t.socketId);for(var i in n+="&channel_name="+encodeURIComponent(t.channelName),e.params)n+="&"+encodeURIComponent(i)+"="+encodeURIComponent(e.params[i]);if(null!=e.paramsProvider){let t=e.paramsProvider();for(var i in t)n+="&"+encodeURIComponent(i)+"="+encodeURIComponent(t[i])}return n})(e,t);ue.getAuthorizers()[t.transport](ue,i,t,h.ChannelAuthorization,n)}};function we(t){return t.httpHost?t.httpHost:t.cluster?`sockjs-${t.cluster}.pusher.com`:s.httpHost}function Se(t){return t.wsHost?t.wsHost:`ws-${t.cluster}.pusher.com`}function _e(t){return"https:"===ue.getProtocol()||!1!==t.forceTLS}function ke(t){return"enableStats"in t?t.enableStats:"disableStats"in t&&!t.disableStats}function Ce(t){const e=Object.assign(Object.assign({},s.userAuthentication),t.userAuthentication);return"customHandler"in e&&null!=e.customHandler?e.customHandler:be(e)}function Te(t,e){const n=function(t,e){let n;return"channelAuthorization"in t?n=Object.assign(Object.assign({},s.channelAuthorization),t.channelAuthorization):(n={transport:t.authTransport||s.authTransport,endpoint:t.authEndpoint||s.authEndpoint},"auth"in t&&("params"in t.auth&&(n.params=t.auth.params),"headers"in t.auth&&(n.headers=t.auth.headers)),"authorizer"in t&&(n.customHandler=((t,e,n)=>{const i={authTransport:e.transport,authEndpoint:e.endpoint,auth:{params:e.params,headers:e.headers}};return(e,r)=>{const s=t.channel(e.channelName);n(s,i).authorize(e.socketId,r)}})(e,n,t.authorizer))),n}(t,e);return"customHandler"in n&&null!=n.customHandler?n.customHandler:ye(n)}class Pe extends at{constructor(t){super((function(t,e){V.debug("No callbacks on watchlist events for "+t)})),this.pusher=t,this.bindWatchlistInternalEvent()}handleEvent(t){t.data.events.forEach(t=>{this.emit(t.name,t)})}bindWatchlistInternalEvent(){this.pusher.connection.bind("message",t=>{"pusher_internal:watchlist_events"===t.event&&this.handleEvent(t)})}}var Ee=function(){let t,e;return{promise:new Promise((n,i)=>{t=n,e=i}),resolve:t,reject:e}};class Oe extends at{constructor(t){super((function(t,e){V.debug("No callbacks on user for "+t)})),this.signin_requested=!1,this.user_data=null,this.serverToUserChannel=null,this.signinDonePromise=null,this._signinDoneResolve=null,this._onAuthorize=(t,e)=>{if(t)return V.warn("Error during signin: "+t),void this._cleanup();this.pusher.send_event("pusher:signin",{auth:e.auth,user_data:e.user_data})},this.pusher=t,this.pusher.connection.bind("state_change",({previous:t,current:e})=>{"connected"!==t&&"connected"===e&&this._signin(),"connected"===t&&"connected"!==e&&(this._cleanup(),this._newSigninPromiseIfNeeded())}),this.watchlist=new Pe(t),this.pusher.connection.bind("message",t=>{"pusher:signin_success"===t.event&&this._onSigninSuccess(t.data),this.serverToUserChannel&&this.serverToUserChannel.name===t.channel&&this.serverToUserChannel.handleEvent(t)})}signin(){this.signin_requested||(this.signin_requested=!0,this._signin())}_signin(){this.signin_requested&&(this._newSigninPromiseIfNeeded(),"connected"===this.pusher.connection.state&&this.pusher.config.userAuthenticator({socketId:this.pusher.connection.socket_id},this._onAuthorize))}_onSigninSuccess(t){try{this.user_data=JSON.parse(t.user_data)}catch(e){return V.error("Failed parsing user data after signin: "+t.user_data),void this._cleanup()}if("string"!=typeof this.user_data.id||""===this.user_data.id)return V.error("user_data doesn't contain an id. user_data: "+this.user_data),void this._cleanup();this._signinDoneResolve(),this._subscribeChannels()}_subscribeChannels(){this.serverToUserChannel=new Ot("#server-to-user-"+this.user_data.id,this.pusher),this.serverToUserChannel.bind_global((t,e)=>{0!==t.indexOf("pusher_internal:")&&0!==t.indexOf("pusher:")&&this.emit(t,e)}),(t=>{t.subscriptionPending&&t.subscriptionCancelled?t.reinstateSubscription():t.subscriptionPending||"connected"!==this.pusher.connection.state||t.subscribe()})(this.serverToUserChannel)}_cleanup(){this.user_data=null,this.serverToUserChannel&&(this.serverToUserChannel.unbind_all(),this.serverToUserChannel.disconnect(),this.serverToUserChannel=null),this.signin_requested&&this._signinDoneResolve()}_newSigninPromiseIfNeeded(){if(!this.signin_requested)return;if(this.signinDonePromise&&!this.signinDonePromise.done)return;const{promise:t,resolve:e,reject:n}=Ee();t.done=!1;const i=()=>{t.done=!0};t.then(i).catch(i),this.signinDonePromise=t,this._signinDoneResolve=e}}class xe{static ready(){xe.isReady=!0;for(var t=0,e=xe.instances.length;tue.getDefaultStrategy(this.config,t,ve),timeline:this.timeline,activityTimeout:this.config.activityTimeout,pongTimeout:this.config.pongTimeout,unavailableTimeout:this.config.unavailableTimeout,useTLS:Boolean(this.config.useTLS)}),this.connection.bind("connected",()=>{this.subscribeAll(),this.timelineSender&&this.timelineSender.send(this.connection.isUsingTLS())}),this.connection.bind("message",t=>{var e=0===t.event.indexOf("pusher_internal:");if(t.channel){var n=this.channel(t.channel);n&&n.handleEvent(t)}e||this.global_emitter.emit(t.event,t.data)}),this.connection.bind("connecting",()=>{this.channels.disconnect()}),this.connection.bind("disconnected",()=>{this.channels.disconnect()}),this.connection.bind("error",t=>{V.warn(t)}),xe.instances.push(this),this.timeline.info({instances:xe.instances.length}),this.user=new Oe(this),xe.isReady&&this.connect()}channel(t){return this.channels.find(t)}allChannels(){return this.channels.all()}connect(){if(this.connection.connect(),this.timelineSender&&!this.timelineSenderTimer){var t=this.connection.isUsingTLS(),e=this.timelineSender;this.timelineSenderTimer=new D(6e4,(function(){e.send(t)}))}}disconnect(){this.connection.disconnect(),this.timelineSenderTimer&&(this.timelineSenderTimer.ensureAborted(),this.timelineSenderTimer=null)}bind(t,e,n){return this.global_emitter.bind(t,e,n),this}unbind(t,e,n){return this.global_emitter.unbind(t,e,n),this}bind_global(t){return this.global_emitter.bind_global(t),this}unbind_global(t){return this.global_emitter.unbind_global(t),this}unbind_all(t){return this.global_emitter.unbind_all(),this}subscribeAll(){var t;for(t in this.channels.channels)this.channels.channels.hasOwnProperty(t)&&this.subscribe(t)}subscribe(t){var e=this.channels.add(t,this);return e.subscriptionPending&&e.subscriptionCancelled?e.reinstateSubscription():e.subscriptionPending||"connected"!==this.connection.state||e.subscribe(),e}unsubscribe(t){var e=this.channels.find(t);e&&e.subscriptionPending?e.cancelSubscription():(e=this.channels.remove(t))&&e.subscribed&&e.unsubscribe()}send_event(t,e,n){return this.connection.send_event(t,e,n)}shouldUseTLS(){return this.config.useTLS}signin(){this.user.signin()}}xe.instances=[],xe.isReady=!1,xe.logToConsole=!1,xe.Runtime=ue,xe.ScriptReceivers=ue.ScriptReceivers,xe.DependenciesReceivers=ue.DependenciesReceivers,xe.auth_callbacks=ue.auth_callbacks;var Le=e.default=xe;ue.setup(xe)}])})); +!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.Pusher=e():t.Pusher=e()}(window,(function(){return function(t){var e={};function n(i){if(e[i])return e[i].exports;var r=e[i]={i:i,l:!1,exports:{}};return t[i].call(r.exports,r,r.exports,n),r.l=!0,r.exports}return n.m=t,n.c=e,n.d=function(t,e,i){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:i})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var i=Object.create(null);if(n.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var r in t)n.d(i,r,function(e){return t[e]}.bind(null,r));return i},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=2)}([function(t,e,n){"use strict";var i,r=this&&this.__extends||(i=function(t,e){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)},function(t,e){function n(){this.constructor=t}i(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)});Object.defineProperty(e,"__esModule",{value:!0});var s=function(){function t(t){void 0===t&&(t="="),this._paddingCharacter=t}return t.prototype.encodedLength=function(t){return this._paddingCharacter?(t+2)/3*4|0:(8*t+5)/6|0},t.prototype.encode=function(t){for(var e="",n=0;n>>18&63),e+=this._encodeByte(i>>>12&63),e+=this._encodeByte(i>>>6&63),e+=this._encodeByte(i>>>0&63)}var r=t.length-n;if(r>0){i=t[n]<<16|(2===r?t[n+1]<<8:0);e+=this._encodeByte(i>>>18&63),e+=this._encodeByte(i>>>12&63),e+=2===r?this._encodeByte(i>>>6&63):this._paddingCharacter||"",e+=this._paddingCharacter||""}return e},t.prototype.maxDecodedLength=function(t){return this._paddingCharacter?t/4*3|0:(6*t+7)/8|0},t.prototype.decodedLength=function(t){return this.maxDecodedLength(t.length-this._getPaddingLength(t))},t.prototype.decode=function(t){if(0===t.length)return new Uint8Array(0);for(var e=this._getPaddingLength(t),n=t.length-e,i=new Uint8Array(this.maxDecodedLength(n)),r=0,s=0,o=0,a=0,c=0,h=0,u=0;s>>4,i[r++]=c<<4|h>>>2,i[r++]=h<<6|u,o|=256&a,o|=256&c,o|=256&h,o|=256&u;if(s>>4,o|=256&a,o|=256&c),s>>2,o|=256&h),s>>8&6,e+=51-t>>>8&-75,e+=61-t>>>8&-15,e+=62-t>>>8&3,String.fromCharCode(e)},t.prototype._decodeChar=function(t){var e=256;return e+=(42-t&t-44)>>>8&-256+t-43+62,e+=(46-t&t-48)>>>8&-256+t-47+63,e+=(47-t&t-58)>>>8&-256+t-48+52,e+=(64-t&t-91)>>>8&-256+t-65+0,e+=(96-t&t-123)>>>8&-256+t-97+26},t.prototype._getPaddingLength=function(t){var e=0;if(this._paddingCharacter){for(var n=t.length-1;n>=0&&t[n]===this._paddingCharacter;n--)e++;if(t.length<4||e>2)throw new Error("Base64Coder: incorrect padding")}return e},t}();e.Coder=s;var o=new s;e.encode=function(t){return o.encode(t)},e.decode=function(t){return o.decode(t)};var a=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r(e,t),e.prototype._encodeByte=function(t){var e=t;return e+=65,e+=25-t>>>8&6,e+=51-t>>>8&-75,e+=61-t>>>8&-13,e+=62-t>>>8&49,String.fromCharCode(e)},e.prototype._decodeChar=function(t){var e=256;return e+=(44-t&t-46)>>>8&-256+t-45+62,e+=(94-t&t-96)>>>8&-256+t-95+63,e+=(47-t&t-58)>>>8&-256+t-48+52,e+=(64-t&t-91)>>>8&-256+t-65+0,e+=(96-t&t-123)>>>8&-256+t-97+26},e}(s);e.URLSafeCoder=a;var c=new a;e.encodeURLSafe=function(t){return c.encode(t)},e.decodeURLSafe=function(t){return c.decode(t)},e.encodedLength=function(t){return o.encodedLength(t)},e.maxDecodedLength=function(t){return o.maxDecodedLength(t)},e.decodedLength=function(t){return o.decodedLength(t)}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i="utf8: invalid source encoding";function r(t){for(var e=0,n=0;n=t.length-1)throw new Error("utf8: invalid string");n++,e+=4}}return e}e.encode=function(t){for(var e=new Uint8Array(r(t)),n=0,i=0;i>6,e[n++]=128|63&s):s<55296?(e[n++]=224|s>>12,e[n++]=128|s>>6&63,e[n++]=128|63&s):(i++,s=(1023&s)<<10,s|=1023&t.charCodeAt(i),s+=65536,e[n++]=240|s>>18,e[n++]=128|s>>12&63,e[n++]=128|s>>6&63,e[n++]=128|63&s)}return e},e.encodedLength=r,e.decode=function(t){for(var e=[],n=0;n=t.length)throw new Error(i);if(128!=(192&(o=t[++n])))throw new Error(i);r=(31&r)<<6|63&o,s=128}else if(r<240){if(n>=t.length-1)throw new Error(i);var o=t[++n],a=t[++n];if(128!=(192&o)||128!=(192&a))throw new Error(i);r=(15&r)<<12|(63&o)<<6|63&a,s=2048}else{if(!(r<248))throw new Error(i);if(n>=t.length-2)throw new Error(i);o=t[++n],a=t[++n];var c=t[++n];if(128!=(192&o)||128!=(192&a)||128!=(192&c))throw new Error(i);r=(15&r)<<18|(63&o)<<12|(63&a)<<6|63&c,s=65536}if(r=55296&&r<=57343)throw new Error(i);if(r>=65536){if(r>1114111)throw new Error(i);r-=65536,e.push(String.fromCharCode(55296|r>>10)),r=56320|1023&r}}e.push(String.fromCharCode(r))}return e.join("")}},function(t,e,n){t.exports=n(3).default},function(t,e,n){"use strict";n.r(e);class i{constructor(t,e){this.lastId=0,this.prefix=t,this.name=e}create(t){this.lastId++;var e=this.lastId,n=this.prefix+e,i=this.name+"["+e+"]",r=!1,s=function(){r||(t.apply(null,arguments),r=!0)};return this[e]=s,{number:e,id:n,name:i,callback:s}}remove(t){delete this[t.number]}}var r=new i("_pusher_script_","Pusher.ScriptReceivers"),s={VERSION:"8.4.0",PROTOCOL:7,wsPort:80,wssPort:443,wsPath:"",httpHost:"sockjs.pusher.com",httpPort:80,httpsPort:443,httpPath:"/pusher",stats_host:"stats.pusher.com",authEndpoint:"/pusher/auth",authTransport:"ajax",activityTimeout:12e4,pongTimeout:3e4,unavailableTimeout:1e4,userAuthentication:{endpoint:"/pusher/user-auth",transport:"ajax"},channelAuthorization:{endpoint:"/pusher/auth",transport:"ajax"},cdn_http:"http://js.pusher.com",cdn_https:"https://js.pusher.com",dependency_suffix:""};var o=new i("_pusher_dependencies","Pusher.DependenciesReceivers"),a=new class{constructor(t){this.options=t,this.receivers=t.receivers||r,this.loading={}}load(t,e,n){var i=this;if(i.loading[t]&&i.loading[t].length>0)i.loading[t].push(n);else{i.loading[t]=[n];var r=ue.createScriptRequest(i.getPath(t,e)),s=i.receivers.create((function(e){if(i.receivers.remove(s),i.loading[t]){var n=i.loading[t];delete i.loading[t];for(var o=function(t){t||r.cleanup()},a=0;a>>6)+S(128|63&e):S(224|e>>>12&15)+S(128|e>>>6&63)+S(128|63&e)},E=function(t){return t.replace(/[^\x00-\x7F]/g,P)},O=function(t){var e=[0,2,1][t.length%3],n=t.charCodeAt(0)<<16|(t.length>1?t.charCodeAt(1):0)<<8|(t.length>2?t.charCodeAt(2):0);return[_.charAt(n>>>18),_.charAt(n>>>12&63),e>=2?"=":_.charAt(n>>>6&63),e>=1?"=":_.charAt(63&n)].join("")},x=window.btoa||function(t){return t.replace(/[\s\S]{1,3}/g,O)};var L=class{constructor(t,e,n,i){this.clear=e,this.timer=t(()=>{this.timer&&(this.timer=i(this.timer))},n)}isRunning(){return null!==this.timer}ensureAborted(){this.timer&&(this.clear(this.timer),this.timer=null)}};function A(t){window.clearTimeout(t)}function R(t){window.clearInterval(t)}class I extends L{constructor(t,e){super(setTimeout,A,t,(function(t){return e(),null}))}}class D extends L{constructor(t,e){super(setInterval,R,t,(function(t){return e(),t}))}}var j={now:()=>Date.now?Date.now():(new Date).valueOf(),defer:t=>new I(0,t),method(t,...e){var n=Array.prototype.slice.call(arguments,1);return function(e){return e[t].apply(e,n.concat(arguments))}}};function N(t,...e){for(var n=0;n{window.console&&window.console.log&&window.console.log(t)}}debug(...t){this.log(this.globalLog,t)}warn(...t){this.log(this.globalLogWarn,t)}error(...t){this.log(this.globalLogError,t)}globalLogWarn(t){window.console&&window.console.warn?window.console.warn(t):this.globalLog(t)}globalLogError(t){window.console&&window.console.error?window.console.error(t):this.globalLogWarn(t)}log(t,...e){var n=H.apply(this,arguments);if(Ae.log)Ae.log(n);else if(Ae.logToConsole){t.bind(this)(n)}}},Y=function(t,e,n,i,r){void 0===n.headers&&null==n.headersProvider||V.warn(`To send headers with the ${i.toString()} request, you must use AJAX, rather than JSONP.`);var s=t.nextAuthCallbackID.toString();t.nextAuthCallbackID++;var o=t.getDocument(),a=o.createElement("script");t.auth_callbacks[s]=function(t){r(null,t)};var c="Pusher.auth_callbacks['"+s+"']";a.src=n.endpoint+"?callback="+encodeURIComponent(c)+"&"+e;var h=o.getElementsByTagName("head")[0]||o.documentElement;h.insertBefore(a,h.firstChild)};class K{constructor(t){this.src=t}send(t){var e=this,n="Error loading "+e.src;e.script=document.createElement("script"),e.script.id=t.id,e.script.src=e.src,e.script.type="text/javascript",e.script.charset="UTF-8",e.script.addEventListener?(e.script.onerror=function(){t.callback(n)},e.script.onload=function(){t.callback(null)}):e.script.onreadystatechange=function(){"loaded"!==e.script.readyState&&"complete"!==e.script.readyState||t.callback(null)},void 0===e.script.async&&document.attachEvent&&/opera/i.test(navigator.userAgent)?(e.errorScript=document.createElement("script"),e.errorScript.id=t.id+"_error",e.errorScript.text=t.name+"('"+n+"');",e.script.async=e.errorScript.async=!1):e.script.async=!0;var i=document.getElementsByTagName("head")[0];i.insertBefore(e.script,i.firstChild),e.errorScript&&i.insertBefore(e.errorScript,e.script.nextSibling)}cleanup(){this.script&&(this.script.onload=this.script.onerror=null,this.script.onreadystatechange=null),this.script&&this.script.parentNode&&this.script.parentNode.removeChild(this.script),this.errorScript&&this.errorScript.parentNode&&this.errorScript.parentNode.removeChild(this.errorScript),this.script=null,this.errorScript=null}}class Q{constructor(t,e){this.url=t,this.data=e}send(t){if(!this.request){var e=W(this.data),n=this.url+"/"+t.number+"?"+e;this.request=ue.createScriptRequest(n),this.request.send(t)}}cleanup(){this.request&&this.request.cleanup()}}var Z={name:"jsonp",getAgent:function(t,e){return function(n,i){var s="http"+(e?"s":"")+"://"+(t.host||t.options.host)+t.options.path,o=ue.createJSONPRequest(s,n),a=ue.ScriptReceivers.create((function(e,n){r.remove(a),o.cleanup(),n&&n.host&&(t.host=n.host),i&&i(e,n)}));o.send(a)}}};function tt(t,e,n){return t+(e.useTLS?"s":"")+"://"+(e.useTLS?e.hostTLS:e.hostNonTLS)+n}function et(t,e){return"/app/"+t+("?protocol="+s.PROTOCOL+"&client=js&version="+s.VERSION+(e?"&"+e:""))}var nt={getInitial:function(t,e){return tt("ws",e,(e.httpPath||"")+et(t,"flash=false"))}},it={getInitial:function(t,e){return tt("http",e,(e.httpPath||"/pusher")+et(t))}},rt={getInitial:function(t,e){return tt("http",e,e.httpPath||"/pusher")},getPath:function(t,e){return et(t)}};class st{constructor(){this._callbacks={}}get(t){return this._callbacks[ot(t)]}add(t,e,n){var i=ot(t);this._callbacks[i]=this._callbacks[i]||[],this._callbacks[i].push({fn:e,context:n})}remove(t,e,n){if(t||e||n){var i=t?[ot(t)]:z(this._callbacks);e||n?this.removeCallback(i,e,n):this.removeAllCallbacks(i)}else this._callbacks={}}removeCallback(t,e,n){q(t,(function(t){this._callbacks[t]=F(this._callbacks[t]||[],(function(t){return e&&e!==t.fn||n&&n!==t.context})),0===this._callbacks[t].length&&delete this._callbacks[t]}),this)}removeAllCallbacks(t){q(t,(function(t){delete this._callbacks[t]}),this)}}function ot(t){return"_"+t}class at{constructor(t){this.callbacks=new st,this.global_callbacks=[],this.failThrough=t}bind(t,e,n){return this.callbacks.add(t,e,n),this}bind_global(t){return this.global_callbacks.push(t),this}unbind(t,e,n){return this.callbacks.remove(t,e,n),this}unbind_global(t){return t?(this.global_callbacks=F(this.global_callbacks||[],e=>e!==t),this):(this.global_callbacks=[],this)}unbind_all(){return this.unbind(),this.unbind_global(),this}emit(t,e,n){for(var i=0;i0)for(i=0;i{this.onError(t),this.changeState("closed")}),!1}return this.bindListeners(),V.debug("Connecting",{transport:this.name,url:t}),this.changeState("connecting"),!0}close(){return!!this.socket&&(this.socket.close(),!0)}send(t){return"open"===this.state&&(j.defer(()=>{this.socket&&this.socket.send(t)}),!0)}ping(){"open"===this.state&&this.supportsPing()&&this.socket.ping()}onOpen(){this.hooks.beforeOpen&&this.hooks.beforeOpen(this.socket,this.hooks.urls.getPath(this.key,this.options)),this.changeState("open"),this.socket.onopen=void 0}onError(t){this.emit("error",{type:"WebSocketError",error:t}),this.timeline.error(this.buildTimelineMessage({error:t.toString()}))}onClose(t){t?this.changeState("closed",{code:t.code,reason:t.reason,wasClean:t.wasClean}):this.changeState("closed"),this.unbindListeners(),this.socket=void 0}onMessage(t){this.emit("message",t)}onActivity(){this.emit("activity")}bindListeners(){this.socket.onopen=()=>{this.onOpen()},this.socket.onerror=t=>{this.onError(t)},this.socket.onclose=t=>{this.onClose(t)},this.socket.onmessage=t=>{this.onMessage(t)},this.supportsPing()&&(this.socket.onactivity=()=>{this.onActivity()})}unbindListeners(){this.socket&&(this.socket.onopen=void 0,this.socket.onerror=void 0,this.socket.onclose=void 0,this.socket.onmessage=void 0,this.supportsPing()&&(this.socket.onactivity=void 0))}changeState(t,e){this.state=t,this.timeline.info(this.buildTimelineMessage({state:t,params:e})),this.emit(t,e)}buildTimelineMessage(t){return N({cid:this.id},t)}}class ht{constructor(t){this.hooks=t}isSupported(t){return this.hooks.isSupported(t)}createConnection(t,e,n,i){return new ct(this.hooks,t,e,n,i)}}var ut=new ht({urls:nt,handlesActivityChecks:!1,supportsPing:!1,isInitialized:function(){return Boolean(ue.getWebSocketAPI())},isSupported:function(){return Boolean(ue.getWebSocketAPI())},getSocket:function(t){return ue.createWebSocket(t)}}),lt={urls:it,handlesActivityChecks:!1,supportsPing:!0,isInitialized:function(){return!0}},dt=N({getSocket:function(t){return ue.HTTPFactory.createStreamingSocket(t)}},lt),pt=N({getSocket:function(t){return ue.HTTPFactory.createPollingSocket(t)}},lt),ft={isSupported:function(){return ue.isXHRSupported()}},gt={ws:ut,xhr_streaming:new ht(N({},dt,ft)),xhr_polling:new ht(N({},pt,ft))},vt=new ht({file:"sockjs",urls:rt,handlesActivityChecks:!0,supportsPing:!1,isSupported:function(){return!0},isInitialized:function(){return void 0!==window.SockJS},getSocket:function(t,e){return new window.SockJS(t,null,{js_path:a.getPath("sockjs",{useTLS:e.useTLS}),ignore_null_origin:e.ignoreNullOrigin})},beforeOpen:function(t,e){t.send(JSON.stringify({path:e}))}}),mt={isSupported:function(t){return ue.isXDRSupported(t.useTLS)}},bt=new ht(N({},dt,mt)),yt=new ht(N({},pt,mt));gt.xdr_streaming=bt,gt.xdr_polling=yt,gt.sockjs=vt;var wt=gt;var St=new class extends at{constructor(){super();var t=this;void 0!==window.addEventListener&&(window.addEventListener("online",(function(){t.emit("online")}),!1),window.addEventListener("offline",(function(){t.emit("offline")}),!1))}isOnline(){return void 0===window.navigator.onLine||window.navigator.onLine}};class _t{constructor(t,e,n){this.manager=t,this.transport=e,this.minPingDelay=n.minPingDelay,this.maxPingDelay=n.maxPingDelay,this.pingDelay=void 0}createConnection(t,e,n,i){i=N({},i,{activityTimeout:this.pingDelay});var r=this.transport.createConnection(t,e,n,i),s=null,o=function(){r.unbind("open",o),r.bind("closed",a),s=j.now()},a=t=>{if(r.unbind("closed",a),1002===t.code||1003===t.code)this.manager.reportDeath();else if(!t.wasClean&&s){var e=j.now()-s;e<2*this.maxPingDelay&&(this.manager.reportDeath(),this.pingDelay=Math.max(e/2,this.minPingDelay))}};return r.bind("open",o),r}isSupported(t){return this.manager.isAlive()&&this.transport.isSupported(t)}}const kt={decodeMessage:function(t){try{var e=JSON.parse(t.data),n=e.data;if("string"==typeof n)try{n=JSON.parse(e.data)}catch(t){}var i={event:e.event,channel:e.channel,data:n};return e.user_id&&(i.user_id=e.user_id),i}catch(e){throw{type:"MessageParseError",error:e,data:t.data}}},encodeMessage:function(t){return JSON.stringify(t)},processHandshake:function(t){var e=kt.decodeMessage(t);if("pusher:connection_established"===e.event){if(!e.data.activity_timeout)throw"No activity timeout specified in handshake";return{action:"connected",id:e.data.socket_id,activityTimeout:1e3*e.data.activity_timeout}}if("pusher:error"===e.event)return{action:this.getCloseAction(e.data),error:this.getCloseError(e.data)};throw"Invalid handshake"},getCloseAction:function(t){return t.code<4e3?t.code>=1002&&t.code<=1004?"backoff":null:4e3===t.code?"tls_only":t.code<4100?"refused":t.code<4200?"backoff":t.code<4300?"retry":"refused"},getCloseError:function(t){return 1e3!==t.code&&1001!==t.code?{type:"PusherError",data:{code:t.code,message:t.reason||t.message}}:null}};var Ct=kt;class Tt extends at{constructor(t,e){super(),this.id=t,this.transport=e,this.activityTimeout=e.activityTimeout,this.bindListeners()}handlesActivityChecks(){return this.transport.handlesActivityChecks()}send(t){return this.transport.send(t)}send_event(t,e,n){var i={event:t,data:e};return n&&(i.channel=n),V.debug("Event sent",i),this.send(Ct.encodeMessage(i))}ping(){this.transport.supportsPing()?this.transport.ping():this.send_event("pusher:ping",{})}close(){this.transport.close()}bindListeners(){var t={message:t=>{var e;try{e=Ct.decodeMessage(t)}catch(e){this.emit("error",{type:"MessageParseError",error:e,data:t.data})}if(void 0!==e){switch(V.debug("Event recd",e),e.event){case"pusher:error":this.emit("error",{type:"PusherError",data:e.data});break;case"pusher:ping":this.emit("ping");break;case"pusher:pong":this.emit("pong")}this.emit("message",e)}},activity:()=>{this.emit("activity")},error:t=>{this.emit("error",t)},closed:t=>{e(),t&&t.code&&this.handleCloseEvent(t),this.transport=null,this.emit("closed")}},e=()=>{M(t,(t,e)=>{this.transport.unbind(e,t)})};M(t,(t,e)=>{this.transport.bind(e,t)})}handleCloseEvent(t){var e=Ct.getCloseAction(t),n=Ct.getCloseError(t);n&&this.emit("error",n),e&&this.emit(e,{action:e,error:n})}}class Pt{constructor(t,e){this.transport=t,this.callback=e,this.bindListeners()}close(){this.unbindListeners(),this.transport.close()}bindListeners(){this.onMessage=t=>{var e;this.unbindListeners();try{e=Ct.processHandshake(t)}catch(t){return this.finish("error",{error:t}),void this.transport.close()}"connected"===e.action?this.finish("connected",{connection:new Tt(e.id,this.transport),activityTimeout:e.activityTimeout}):(this.finish(e.action,{error:e.error}),this.transport.close())},this.onClosed=t=>{this.unbindListeners();var e=Ct.getCloseAction(t)||"backoff",n=Ct.getCloseError(t);this.finish(e,{error:n})},this.transport.bind("message",this.onMessage),this.transport.bind("closed",this.onClosed)}unbindListeners(){this.transport.unbind("message",this.onMessage),this.transport.unbind("closed",this.onClosed)}finish(t,e){this.callback(N({transport:this.transport,action:t},e))}}class Et{constructor(t,e){this.timeline=t,this.options=e||{}}send(t,e){this.timeline.isEmpty()||this.timeline.send(ue.TimelineTransport.getAgent(this,t),e)}}class Ot extends at{constructor(t,e){super((function(e,n){V.debug("No callbacks on "+t+" for "+e)})),this.name=t,this.pusher=e,this.subscribed=!1,this.subscriptionPending=!1,this.subscriptionCancelled=!1}authorize(t,e){return e(null,{auth:""})}trigger(t,e){if(0!==t.indexOf("client-"))throw new l("Event '"+t+"' does not start with 'client-'");if(!this.subscribed){var n=u("triggeringClientEvents");V.warn("Client event triggered before channel 'subscription_succeeded' event . "+n)}return this.pusher.send_event(t,e,this.name)}disconnect(){this.subscribed=!1,this.subscriptionPending=!1}handleEvent(t){var e=t.event,n=t.data;if("pusher_internal:subscription_succeeded"===e)this.handleSubscriptionSucceededEvent(t);else if("pusher_internal:subscription_count"===e)this.handleSubscriptionCountEvent(t);else if(0!==e.indexOf("pusher_internal:")){this.emit(e,n,{})}}handleSubscriptionSucceededEvent(t){this.subscriptionPending=!1,this.subscribed=!0,this.subscriptionCancelled?this.pusher.unsubscribe(this.name):this.emit("pusher:subscription_succeeded",t.data)}handleSubscriptionCountEvent(t){t.data.subscription_count&&(this.subscriptionCount=t.data.subscription_count),this.emit("pusher:subscription_count",t.data)}subscribe(){this.subscribed||(this.subscriptionPending=!0,this.subscriptionCancelled=!1,this.authorize(this.pusher.connection.socket_id,(t,e)=>{t?(this.subscriptionPending=!1,V.error(t.toString()),this.emit("pusher:subscription_error",Object.assign({},{type:"AuthError",error:t.message},t instanceof y?{status:t.status}:{}))):this.pusher.send_event("pusher:subscribe",{auth:e.auth,channel_data:e.channel_data,channel:this.name})}))}unsubscribe(){this.subscribed=!1,this.pusher.send_event("pusher:unsubscribe",{channel:this.name})}cancelSubscription(){this.subscriptionCancelled=!0}reinstateSubscription(){this.subscriptionCancelled=!1}}class xt extends Ot{authorize(t,e){return this.pusher.config.channelAuthorizer({channelName:this.name,socketId:t},e)}}class Lt{constructor(){this.reset()}get(t){return Object.prototype.hasOwnProperty.call(this.members,t)?{id:t,info:this.members[t]}:null}each(t){M(this.members,(e,n)=>{t(this.get(n))})}setMyID(t){this.myID=t}onSubscription(t){this.members=t.presence.hash,this.count=t.presence.count,this.me=this.get(this.myID)}addMember(t){return null===this.get(t.user_id)&&this.count++,this.members[t.user_id]=t.user_info,this.get(t.user_id)}removeMember(t){var e=this.get(t.user_id);return e&&(delete this.members[t.user_id],this.count--),e}reset(){this.members={},this.count=0,this.myID=null,this.me=null}}var At=function(t,e,n,i){return new(n||(n=Promise))((function(r,s){function o(t){try{c(i.next(t))}catch(t){s(t)}}function a(t){try{c(i.throw(t))}catch(t){s(t)}}function c(t){var e;t.done?r(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(o,a)}c((i=i.apply(t,e||[])).next())}))};class Rt extends xt{constructor(t,e){super(t,e),this.members=new Lt}authorize(t,e){super.authorize(t,(t,n)=>At(this,void 0,void 0,(function*(){if(!t)if(null!=(n=n).channel_data){var i=JSON.parse(n.channel_data);this.members.setMyID(i.user_id)}else{if(yield this.pusher.user.signinDonePromise,null==this.pusher.user.user_data){let t=u("authorizationEndpoint");return V.error(`Invalid auth response for channel '${this.name}', expected 'channel_data' field. ${t}, or the user should be signed in.`),void e("Invalid auth response")}this.members.setMyID(this.pusher.user.user_data.id)}e(t,n)})))}handleEvent(t){var e=t.event;if(0===e.indexOf("pusher_internal:"))this.handleInternalEvent(t);else{var n=t.data,i={};t.user_id&&(i.user_id=t.user_id),this.emit(e,n,i)}}handleInternalEvent(t){var e=t.event,n=t.data;switch(e){case"pusher_internal:subscription_succeeded":this.handleSubscriptionSucceededEvent(t);break;case"pusher_internal:subscription_count":this.handleSubscriptionCountEvent(t);break;case"pusher_internal:member_added":var i=this.members.addMember(n);this.emit("pusher:member_added",i);break;case"pusher_internal:member_removed":var r=this.members.removeMember(n);r&&this.emit("pusher:member_removed",r)}}handleSubscriptionSucceededEvent(t){this.subscriptionPending=!1,this.subscribed=!0,this.subscriptionCancelled?this.pusher.unsubscribe(this.name):(this.members.onSubscription(t.data),this.emit("pusher:subscription_succeeded",this.members))}disconnect(){this.members.reset(),super.disconnect()}}var It=n(1),Dt=n(0);class jt extends xt{constructor(t,e,n){super(t,e),this.key=null,this.nacl=n}authorize(t,e){super.authorize(t,(t,n)=>{if(t)return void e(t,n);let i=n.shared_secret;i?(this.key=Object(Dt.decode)(i),delete n.shared_secret,e(null,n)):e(new Error("No shared_secret key in auth payload for encrypted channel: "+this.name),null)})}trigger(t,e){throw new v("Client events are not currently supported for encrypted channels")}handleEvent(t){var e=t.event,n=t.data;0!==e.indexOf("pusher_internal:")&&0!==e.indexOf("pusher:")?this.handleEncryptedEvent(e,n):super.handleEvent(t)}handleEncryptedEvent(t,e){if(!this.key)return void V.debug("Received encrypted event before key has been retrieved from the authEndpoint");if(!e.ciphertext||!e.nonce)return void V.error("Unexpected format for encrypted event, expected object with `ciphertext` and `nonce` fields, got: "+e);let n=Object(Dt.decode)(e.ciphertext);if(n.length{e?V.error(`Failed to make a request to the authEndpoint: ${s}. Unable to fetch new key, so dropping encrypted event`):(r=this.nacl.secretbox.open(n,i,this.key),null!==r?this.emit(t,this.getDataToEmit(r)):V.error("Failed to decrypt event with new key. Dropping encrypted event"))});this.emit(t,this.getDataToEmit(r))}getDataToEmit(t){let e=Object(It.decode)(t);try{return JSON.parse(e)}catch(t){return e}}}class Nt extends at{constructor(t,e){super(),this.state="initialized",this.connection=null,this.key=t,this.options=e,this.timeline=this.options.timeline,this.usingTLS=this.options.useTLS,this.errorCallbacks=this.buildErrorCallbacks(),this.connectionCallbacks=this.buildConnectionCallbacks(this.errorCallbacks),this.handshakeCallbacks=this.buildHandshakeCallbacks(this.errorCallbacks);var n=ue.getNetwork();n.bind("online",()=>{this.timeline.info({netinfo:"online"}),"connecting"!==this.state&&"unavailable"!==this.state||this.retryIn(0)}),n.bind("offline",()=>{this.timeline.info({netinfo:"offline"}),this.connection&&this.sendActivityCheck()}),this.updateStrategy()}switchCluster(t){this.key=t,this.updateStrategy(),this.retryIn(0)}connect(){this.connection||this.runner||(this.strategy.isSupported()?(this.updateState("connecting"),this.startConnecting(),this.setUnavailableTimer()):this.updateState("failed"))}send(t){return!!this.connection&&this.connection.send(t)}send_event(t,e,n){return!!this.connection&&this.connection.send_event(t,e,n)}disconnect(){this.disconnectInternally(),this.updateState("disconnected")}isUsingTLS(){return this.usingTLS}startConnecting(){var t=(e,n)=>{e?this.runner=this.strategy.connect(0,t):"error"===n.action?(this.emit("error",{type:"HandshakeError",error:n.error}),this.timeline.error({handshakeError:n.error})):(this.abortConnecting(),this.handshakeCallbacks[n.action](n))};this.runner=this.strategy.connect(0,t)}abortConnecting(){this.runner&&(this.runner.abort(),this.runner=null)}disconnectInternally(){(this.abortConnecting(),this.clearRetryTimer(),this.clearUnavailableTimer(),this.connection)&&this.abandonConnection().close()}updateStrategy(){this.strategy=this.options.getStrategy({key:this.key,timeline:this.timeline,useTLS:this.usingTLS})}retryIn(t){this.timeline.info({action:"retry",delay:t}),t>0&&this.emit("connecting_in",Math.round(t/1e3)),this.retryTimer=new I(t||0,()=>{this.disconnectInternally(),this.connect()})}clearRetryTimer(){this.retryTimer&&(this.retryTimer.ensureAborted(),this.retryTimer=null)}setUnavailableTimer(){this.unavailableTimer=new I(this.options.unavailableTimeout,()=>{this.updateState("unavailable")})}clearUnavailableTimer(){this.unavailableTimer&&this.unavailableTimer.ensureAborted()}sendActivityCheck(){this.stopActivityCheck(),this.connection.ping(),this.activityTimer=new I(this.options.pongTimeout,()=>{this.timeline.error({pong_timed_out:this.options.pongTimeout}),this.retryIn(0)})}resetActivityCheck(){this.stopActivityCheck(),this.connection&&!this.connection.handlesActivityChecks()&&(this.activityTimer=new I(this.activityTimeout,()=>{this.sendActivityCheck()}))}stopActivityCheck(){this.activityTimer&&this.activityTimer.ensureAborted()}buildConnectionCallbacks(t){return N({},t,{message:t=>{this.resetActivityCheck(),this.emit("message",t)},ping:()=>{this.send_event("pusher:pong",{})},activity:()=>{this.resetActivityCheck()},error:t=>{this.emit("error",t)},closed:()=>{this.abandonConnection(),this.shouldRetry()&&this.retryIn(1e3)}})}buildHandshakeCallbacks(t){return N({},t,{connected:t=>{this.activityTimeout=Math.min(this.options.activityTimeout,t.activityTimeout,t.connection.activityTimeout||1/0),this.clearUnavailableTimer(),this.setConnection(t.connection),this.socket_id=this.connection.id,this.updateState("connected",{socket_id:this.socket_id})}})}buildErrorCallbacks(){let t=t=>e=>{e.error&&this.emit("error",{type:"WebSocketError",error:e.error}),t(e)};return{tls_only:t(()=>{this.usingTLS=!0,this.updateStrategy(),this.retryIn(0)}),refused:t(()=>{this.disconnect()}),backoff:t(()=>{this.retryIn(1e3)}),retry:t(()=>{this.retryIn(0)})}}setConnection(t){for(var e in this.connection=t,this.connectionCallbacks)this.connection.bind(e,this.connectionCallbacks[e]);this.resetActivityCheck()}abandonConnection(){if(this.connection){for(var t in this.stopActivityCheck(),this.connectionCallbacks)this.connection.unbind(t,this.connectionCallbacks[t]);var e=this.connection;return this.connection=null,e}}updateState(t,e){var n=this.state;if(this.state=t,n!==t){var i=t;"connected"===i&&(i+=" with new socket ID "+e.socket_id),V.debug("State changed",n+" -> "+i),this.timeline.info({state:t,params:e}),this.emit("state_change",{previous:n,current:t}),this.emit(t,e)}}shouldRetry(){return"connecting"===this.state||"connected"===this.state}}class Ht{constructor(){this.channels={}}add(t,e){return this.channels[t]||(this.channels[t]=function(t,e){if(0===t.indexOf("private-encrypted-")){if(e.config.nacl)return Ut.createEncryptedChannel(t,e,e.config.nacl);let n="Tried to subscribe to a private-encrypted- channel but no nacl implementation available",i=u("encryptedChannelSupport");throw new v(`${n}. ${i}`)}if(0===t.indexOf("private-"))return Ut.createPrivateChannel(t,e);if(0===t.indexOf("presence-"))return Ut.createPresenceChannel(t,e);if(0===t.indexOf("#"))throw new d('Cannot create a channel with name "'+t+'".');return Ut.createChannel(t,e)}(t,e)),this.channels[t]}all(){return function(t){var e=[];return M(t,(function(t){e.push(t)})),e}(this.channels)}find(t){return this.channels[t]}remove(t){var e=this.channels[t];return delete this.channels[t],e}disconnect(){M(this.channels,(function(t){t.disconnect()}))}}var Ut={createChannels:()=>new Ht,createConnectionManager:(t,e)=>new Nt(t,e),createChannel:(t,e)=>new Ot(t,e),createPrivateChannel:(t,e)=>new xt(t,e),createPresenceChannel:(t,e)=>new Rt(t,e),createEncryptedChannel:(t,e,n)=>new jt(t,e,n),createTimelineSender:(t,e)=>new Et(t,e),createHandshake:(t,e)=>new Pt(t,e),createAssistantToTheTransportManager:(t,e,n)=>new _t(t,e,n)};class Mt{constructor(t){this.options=t||{},this.livesLeft=this.options.lives||1/0}getAssistant(t){return Ut.createAssistantToTheTransportManager(this,t,{minPingDelay:this.options.minPingDelay,maxPingDelay:this.options.maxPingDelay})}isAlive(){return this.livesLeft>0}reportDeath(){this.livesLeft-=1}}class zt{constructor(t,e){this.strategies=t,this.loop=Boolean(e.loop),this.failFast=Boolean(e.failFast),this.timeout=e.timeout,this.timeoutLimit=e.timeoutLimit}isSupported(){return J(this.strategies,j.method("isSupported"))}connect(t,e){var n=this.strategies,i=0,r=this.timeout,s=null,o=(a,c)=>{c?e(null,c):(i+=1,this.loop&&(i%=n.length),i0&&(r=new I(n.timeout,(function(){s.abort(),i(!0)}))),s=t.connect(e,(function(t,e){t&&r&&r.isRunning()&&!n.failFast||(r&&r.ensureAborted(),i(t,e))})),{abort:function(){r&&r.ensureAborted(),s.abort()},forceMinPriority:function(t){s.forceMinPriority(t)}}}}class qt{constructor(t){this.strategies=t}isSupported(){return J(this.strategies,j.method("isSupported"))}connect(t,e){return function(t,e,n){var i=B(t,(function(t,i,r,s){return t.connect(e,n(i,s))}));return{abort:function(){q(i,Bt)},forceMinPriority:function(t){q(i,(function(e){e.forceMinPriority(t)}))}}}(this.strategies,t,(function(t,n){return function(i,r){n[t].error=i,i?function(t){return function(t,e){for(var n=0;n=j.now()){var o=this.transports[i.transport];o&&(["ws","wss"].includes(i.transport)||r>3?(this.timeline.info({cached:!0,transport:i.transport,latency:i.latency}),s.push(new zt([o],{timeout:2*i.latency+1e3,failFast:!0}))):r++)}var a=j.now(),c=s.pop().connect(t,(function i(o,h){o?(Jt(n),s.length>0?(a=j.now(),c=s.pop().connect(t,i)):e(o)):(!function(t,e,n,i){var r=ue.getLocalStorage();if(r)try{r[Xt(t)]=G({timestamp:j.now(),transport:e,latency:n,cacheSkipCount:i})}catch(t){}}(n,h.transport.name,j.now()-a,r),e(null,h))}));return{abort:function(){c.abort()},forceMinPriority:function(e){t=e,c&&c.forceMinPriority(e)}}}}function Xt(t){return"pusherTransport"+(t?"TLS":"NonTLS")}function Jt(t){var e=ue.getLocalStorage();if(e)try{delete e[Xt(t)]}catch(t){}}class $t{constructor(t,{delay:e}){this.strategy=t,this.options={delay:e}}isSupported(){return this.strategy.isSupported()}connect(t,e){var n,i=this.strategy,r=new I(this.options.delay,(function(){n=i.connect(t,e)}));return{abort:function(){r.ensureAborted(),n&&n.abort()},forceMinPriority:function(e){t=e,n&&n.forceMinPriority(e)}}}}class Wt{constructor(t,e,n){this.test=t,this.trueBranch=e,this.falseBranch=n}isSupported(){return(this.test()?this.trueBranch:this.falseBranch).isSupported()}connect(t,e){return(this.test()?this.trueBranch:this.falseBranch).connect(t,e)}}class Gt{constructor(t){this.strategy=t}isSupported(){return this.strategy.isSupported()}connect(t,e){var n=this.strategy.connect(t,(function(t,i){i&&n.abort(),e(t,i)}));return n}}function Vt(t){return function(){return t.isSupported()}}var Yt=function(t,e,n){var i={};function r(e,r,s,o,a){var c=n(t,e,r,s,o,a);return i[e]=c,c}var s,o=Object.assign({},e,{hostNonTLS:t.wsHost+":"+t.wsPort,hostTLS:t.wsHost+":"+t.wssPort,httpPath:t.wsPath}),a=Object.assign({},o,{useTLS:!0}),c=Object.assign({},e,{hostNonTLS:t.httpHost+":"+t.httpPort,hostTLS:t.httpHost+":"+t.httpsPort,httpPath:t.httpPath}),h={loop:!0,timeout:15e3,timeoutLimit:6e4},u=new Mt({minPingDelay:1e4,maxPingDelay:t.activityTimeout}),l=new Mt({lives:2,minPingDelay:1e4,maxPingDelay:t.activityTimeout}),d=r("ws","ws",3,o,u),p=r("wss","ws",3,a,u),f=r("sockjs","sockjs",1,c),g=r("xhr_streaming","xhr_streaming",1,c,l),v=r("xdr_streaming","xdr_streaming",1,c,l),m=r("xhr_polling","xhr_polling",1,c),b=r("xdr_polling","xdr_polling",1,c),y=new zt([d],h),w=new zt([p],h),S=new zt([f],h),_=new zt([new Wt(Vt(g),g,v)],h),k=new zt([new Wt(Vt(m),m,b)],h),C=new zt([new Wt(Vt(_),new qt([_,new $t(k,{delay:4e3})]),k)],h),T=new Wt(Vt(C),C,S);return s=e.useTLS?new qt([y,new $t(T,{delay:2e3})]):new qt([y,new $t(w,{delay:2e3}),new $t(T,{delay:5e3})]),new Ft(new Gt(new Wt(Vt(d),s,T)),i,{ttl:18e5,timeline:e.timeline,useTLS:e.useTLS})},Kt={getRequest:function(t){var e=new window.XDomainRequest;return e.ontimeout=function(){t.emit("error",new p),t.close()},e.onerror=function(e){t.emit("error",e),t.close()},e.onprogress=function(){e.responseText&&e.responseText.length>0&&t.onChunk(200,e.responseText)},e.onload=function(){e.responseText&&e.responseText.length>0&&t.onChunk(200,e.responseText),t.emit("finished",200),t.close()},e},abortRequest:function(t){t.ontimeout=t.onerror=t.onprogress=t.onload=null,t.abort()}};class Qt extends at{constructor(t,e,n){super(),this.hooks=t,this.method=e,this.url=n}start(t){this.position=0,this.xhr=this.hooks.getRequest(this),this.unloader=()=>{this.close()},ue.addUnloadListener(this.unloader),this.xhr.open(this.method,this.url,!0),this.xhr.setRequestHeader&&this.xhr.setRequestHeader("Content-Type","application/json"),this.xhr.send(t)}close(){this.unloader&&(ue.removeUnloadListener(this.unloader),this.unloader=null),this.xhr&&(this.hooks.abortRequest(this.xhr),this.xhr=null)}onChunk(t,e){for(;;){var n=this.advanceBuffer(e);if(!n)break;this.emit("chunk",{status:t,data:n})}this.isBufferTooLong(e)&&this.emit("buffer_too_long")}advanceBuffer(t){var e=t.slice(this.position),n=e.indexOf("\n");return-1!==n?(this.position+=n+1,e.slice(0,n)):null}isBufferTooLong(t){return this.position===t.length&&t.length>262144}}var Zt;!function(t){t[t.CONNECTING=0]="CONNECTING",t[t.OPEN=1]="OPEN",t[t.CLOSED=3]="CLOSED"}(Zt||(Zt={}));var te=Zt,ee=1;function ne(t){var e=-1===t.indexOf("?")?"?":"&";return t+e+"t="+ +new Date+"&n="+ee++}function ie(t){return ue.randomInt(t)}var re,se=class{constructor(t,e){this.hooks=t,this.session=ie(1e3)+"/"+function(t){for(var e=[],n=0;n{this.onChunk(t)}),this.stream.bind("finished",t=>{this.hooks.onFinished(this,t)}),this.stream.bind("buffer_too_long",()=>{this.reconnect()});try{this.stream.start()}catch(t){j.defer(()=>{this.onError(t),this.onClose(1006,"Could not start streaming",!1)})}}closeStream(){this.stream&&(this.stream.unbind_all(),this.stream.close(),this.stream=null)}},oe={getReceiveURL:function(t,e){return t.base+"/"+e+"/xhr_streaming"+t.queryString},onHeartbeat:function(t){t.sendRaw("[]")},sendHeartbeat:function(t){t.sendRaw("[]")},onFinished:function(t,e){t.onClose(1006,"Connection interrupted ("+e+")",!1)}},ae={getReceiveURL:function(t,e){return t.base+"/"+e+"/xhr"+t.queryString},onHeartbeat:function(){},sendHeartbeat:function(t){t.sendRaw("[]")},onFinished:function(t,e){200===e?t.reconnect():t.onClose(1006,"Connection interrupted ("+e+")",!1)}},ce={getRequest:function(t){var e=new(ue.getXHRAPI());return e.onreadystatechange=e.onprogress=function(){switch(e.readyState){case 3:e.responseText&&e.responseText.length>0&&t.onChunk(e.status,e.responseText);break;case 4:e.responseText&&e.responseText.length>0&&t.onChunk(e.status,e.responseText),t.emit("finished",e.status),t.close()}},e},abortRequest:function(t){t.onreadystatechange=null,t.abort()}},he={createStreamingSocket(t){return this.createSocket(oe,t)},createPollingSocket(t){return this.createSocket(ae,t)},createSocket:(t,e)=>new se(t,e),createXHR(t,e){return this.createRequest(ce,t,e)},createRequest:(t,e,n)=>new Qt(t,e,n),createXDR:function(t,e){return this.createRequest(Kt,t,e)}},ue={nextAuthCallbackID:1,auth_callbacks:{},ScriptReceivers:r,DependenciesReceivers:o,getDefaultStrategy:Yt,Transports:wt,transportConnectionInitializer:function(){var t=this;t.timeline.info(t.buildTimelineMessage({transport:t.name+(t.options.useTLS?"s":"")})),t.hooks.isInitialized()?t.changeState("initialized"):t.hooks.file?(t.changeState("initializing"),a.load(t.hooks.file,{useTLS:t.options.useTLS},(function(e,n){t.hooks.isInitialized()?(t.changeState("initialized"),n(!0)):(e&&t.onError(e),t.onClose(),n(!1))}))):t.onClose()},HTTPFactory:he,TimelineTransport:Z,getXHRAPI:()=>window.XMLHttpRequest,getWebSocketAPI:()=>window.WebSocket||window.MozWebSocket,setup(t){window.Pusher=t;var e=()=>{this.onDocumentBody(t.ready)};window.JSON?e():a.load("json2",{},e)},getDocument:()=>document,getProtocol(){return this.getDocument().location.protocol},getAuthorizers:()=>({ajax:w,jsonp:Y}),onDocumentBody(t){document.body?t():setTimeout(()=>{this.onDocumentBody(t)},0)},createJSONPRequest:(t,e)=>new Q(t,e),createScriptRequest:t=>new K(t),getLocalStorage(){try{return window.localStorage}catch(t){return}},createXHR(){return this.getXHRAPI()?this.createXMLHttpRequest():this.createMicrosoftXHR()},createXMLHttpRequest(){return new(this.getXHRAPI())},createMicrosoftXHR:()=>new ActiveXObject("Microsoft.XMLHTTP"),getNetwork:()=>St,createWebSocket(t){return new(this.getWebSocketAPI())(t)},createSocketRequest(t,e){if(this.isXHRSupported())return this.HTTPFactory.createXHR(t,e);if(this.isXDRSupported(0===e.indexOf("https:")))return this.HTTPFactory.createXDR(t,e);throw"Cross-origin HTTP requests are not supported"},isXHRSupported(){var t=this.getXHRAPI();return Boolean(t)&&void 0!==(new t).withCredentials},isXDRSupported(t){var e=t?"https:":"http:",n=this.getProtocol();return Boolean(window.XDomainRequest)&&n===e},addUnloadListener(t){void 0!==window.addEventListener?window.addEventListener("unload",t,!1):void 0!==window.attachEvent&&window.attachEvent("onunload",t)},removeUnloadListener(t){void 0!==window.addEventListener?window.removeEventListener("unload",t,!1):void 0!==window.detachEvent&&window.detachEvent("onunload",t)},randomInt:t=>Math.floor((window.crypto||window.msCrypto).getRandomValues(new Uint32Array(1))[0]/Math.pow(2,32)*t)};!function(t){t[t.ERROR=3]="ERROR",t[t.INFO=6]="INFO",t[t.DEBUG=7]="DEBUG"}(re||(re={}));var le=re;class de{constructor(t,e,n){this.key=t,this.session=e,this.events=[],this.options=n||{},this.sent=0,this.uniqueID=0}log(t,e){t<=this.options.level&&(this.events.push(N({},e,{timestamp:j.now()})),this.options.limit&&this.events.length>this.options.limit&&this.events.shift())}error(t){this.log(le.ERROR,t)}info(t){this.log(le.INFO,t)}debug(t){this.log(le.DEBUG,t)}isEmpty(){return 0===this.events.length}send(t,e){var n=N({session:this.session,bundle:this.sent+1,key:this.key,lib:"js",version:this.options.version,cluster:this.options.cluster,features:this.options.features,timeline:this.events},this.options.params);return this.events=[],t(n,(t,n)=>{t||this.sent++,e&&e(t,n)}),!0}generateUniqueID(){return this.uniqueID++,this.uniqueID}}class pe{constructor(t,e,n,i){this.name=t,this.priority=e,this.transport=n,this.options=i||{}}isSupported(){return this.transport.isSupported({useTLS:this.options.useTLS})}connect(t,e){if(!this.isSupported())return fe(new b,e);if(this.priority{n||(h(),r?r.close():i.close())},forceMinPriority:t=>{n||this.priority{if(void 0===ue.getAuthorizers()[t.transport])throw`'${t.transport}' is not a recognized auth transport`;return(e,n)=>{const i=((t,e)=>{var n="socket_id="+encodeURIComponent(t.socketId);for(var i in e.params)n+="&"+encodeURIComponent(i)+"="+encodeURIComponent(e.params[i]);if(null!=e.paramsProvider){let t=e.paramsProvider();for(var i in t)n+="&"+encodeURIComponent(i)+"="+encodeURIComponent(t[i])}return n})(e,t);ue.getAuthorizers()[t.transport](ue,i,t,h.UserAuthentication,n)}};var ye=t=>{if(void 0===ue.getAuthorizers()[t.transport])throw`'${t.transport}' is not a recognized auth transport`;return(e,n)=>{const i=((t,e)=>{var n="socket_id="+encodeURIComponent(t.socketId);for(var i in n+="&channel_name="+encodeURIComponent(t.channelName),e.params)n+="&"+encodeURIComponent(i)+"="+encodeURIComponent(e.params[i]);if(null!=e.paramsProvider){let t=e.paramsProvider();for(var i in t)n+="&"+encodeURIComponent(i)+"="+encodeURIComponent(t[i])}return n})(e,t);ue.getAuthorizers()[t.transport](ue,i,t,h.ChannelAuthorization,n)}};function we(t,e){let n={activityTimeout:t.activityTimeout||s.activityTimeout,cluster:t.cluster,httpPath:t.httpPath||s.httpPath,httpPort:t.httpPort||s.httpPort,httpsPort:t.httpsPort||s.httpsPort,pongTimeout:t.pongTimeout||s.pongTimeout,statsHost:t.statsHost||s.stats_host,unavailableTimeout:t.unavailableTimeout||s.unavailableTimeout,wsPath:t.wsPath||s.wsPath,wsPort:t.wsPort||s.wsPort,wssPort:t.wssPort||s.wssPort,enableStats:Ce(t),httpHost:Se(t),useTLS:ke(t),wsHost:_e(t),userAuthenticator:Te(t),channelAuthorizer:Pe(t,e)};return"disabledTransports"in t&&(n.disabledTransports=t.disabledTransports),"enabledTransports"in t&&(n.enabledTransports=t.enabledTransports),"ignoreNullOrigin"in t&&(n.ignoreNullOrigin=t.ignoreNullOrigin),"timelineParams"in t&&(n.timelineParams=t.timelineParams),"nacl"in t&&(n.nacl=t.nacl),n}function Se(t){return t.httpHost?t.httpHost:t.cluster?`sockjs-${t.cluster}.pusher.com`:s.httpHost}function _e(t){return t.wsHost?t.wsHost:`ws-${t.cluster}.pusher.com`}function ke(t){return"https:"===ue.getProtocol()||!1!==t.forceTLS}function Ce(t){return"enableStats"in t?t.enableStats:"disableStats"in t&&!t.disableStats}function Te(t){const e=Object.assign(Object.assign({},s.userAuthentication),t.userAuthentication);return"customHandler"in e&&null!=e.customHandler?e.customHandler:be(e)}function Pe(t,e){const n=function(t,e){let n;return"channelAuthorization"in t?n=Object.assign(Object.assign({},s.channelAuthorization),t.channelAuthorization):(n={transport:t.authTransport||s.authTransport,endpoint:t.authEndpoint||s.authEndpoint},"auth"in t&&("params"in t.auth&&(n.params=t.auth.params),"headers"in t.auth&&(n.headers=t.auth.headers)),"authorizer"in t&&(n.customHandler=((t,e,n)=>{const i={authTransport:e.transport,authEndpoint:e.endpoint,auth:{params:e.params,headers:e.headers}};return(e,r)=>{const s=t.channel(e.channelName);n(s,i).authorize(e.socketId,r)}})(e,n,t.authorizer))),n}(t,e);return"customHandler"in n&&null!=n.customHandler?n.customHandler:ye(n)}class Ee extends at{constructor(t){super((function(t,e){V.debug("No callbacks on watchlist events for "+t)})),this.pusher=t,this.bindWatchlistInternalEvent()}handleEvent(t){t.data.events.forEach(t=>{this.emit(t.name,t)})}bindWatchlistInternalEvent(){this.pusher.connection.bind("message",t=>{"pusher_internal:watchlist_events"===t.event&&this.handleEvent(t)})}}var Oe=function(){let t,e;return{promise:new Promise((n,i)=>{t=n,e=i}),resolve:t,reject:e}};class xe extends at{constructor(t){super((function(t,e){V.debug("No callbacks on user for "+t)})),this.signin_requested=!1,this.user_data=null,this.serverToUserChannel=null,this.signinDonePromise=null,this._signinDoneResolve=null,this._onAuthorize=(t,e)=>{if(t)return V.warn("Error during signin: "+t),void this._cleanup();this.pusher.send_event("pusher:signin",{auth:e.auth,user_data:e.user_data})},this.pusher=t,this.pusher.connection.bind("state_change",({previous:t,current:e})=>{"connected"!==t&&"connected"===e&&this._signin(),"connected"===t&&"connected"!==e&&(this._cleanup(),this._newSigninPromiseIfNeeded())}),this.watchlist=new Ee(t),this.pusher.connection.bind("message",t=>{"pusher:signin_success"===t.event&&this._onSigninSuccess(t.data),this.serverToUserChannel&&this.serverToUserChannel.name===t.channel&&this.serverToUserChannel.handleEvent(t)})}signin(){this.signin_requested||(this.signin_requested=!0,this._signin())}_signin(){this.signin_requested&&(this._newSigninPromiseIfNeeded(),"connected"===this.pusher.connection.state&&this.pusher.config.userAuthenticator({socketId:this.pusher.connection.socket_id},this._onAuthorize))}_onSigninSuccess(t){try{this.user_data=JSON.parse(t.user_data)}catch(e){return V.error("Failed parsing user data after signin: "+t.user_data),void this._cleanup()}if("string"!=typeof this.user_data.id||""===this.user_data.id)return V.error("user_data doesn't contain an id. user_data: "+this.user_data),void this._cleanup();this._signinDoneResolve(),this._subscribeChannels()}_subscribeChannels(){this.serverToUserChannel=new Ot("#server-to-user-"+this.user_data.id,this.pusher),this.serverToUserChannel.bind_global((t,e)=>{0!==t.indexOf("pusher_internal:")&&0!==t.indexOf("pusher:")&&this.emit(t,e)}),(t=>{t.subscriptionPending&&t.subscriptionCancelled?t.reinstateSubscription():t.subscriptionPending||"connected"!==this.pusher.connection.state||t.subscribe()})(this.serverToUserChannel)}_cleanup(){this.user_data=null,this.serverToUserChannel&&(this.serverToUserChannel.unbind_all(),this.serverToUserChannel.disconnect(),this.serverToUserChannel=null),this.signin_requested&&this._signinDoneResolve()}_newSigninPromiseIfNeeded(){if(!this.signin_requested)return;if(this.signinDonePromise&&!this.signinDonePromise.done)return;const{promise:t,resolve:e,reject:n}=Oe();t.done=!1;const i=()=>{t.done=!0};t.then(i).catch(i),this.signinDonePromise=t,this._signinDoneResolve=e}}class Le{static ready(){Le.isReady=!0;for(var t=0,e=Le.instances.length;tue.getDefaultStrategy(this.config,t,ve),timeline:this.timeline,activityTimeout:this.config.activityTimeout,pongTimeout:this.config.pongTimeout,unavailableTimeout:this.config.unavailableTimeout,useTLS:Boolean(this.config.useTLS)}),this.connection.bind("connected",()=>{this.subscribeAll(),this.timelineSender&&this.timelineSender.send(this.connection.isUsingTLS())}),this.connection.bind("message",t=>{var e=0===t.event.indexOf("pusher_internal:");if(t.channel){var n=this.channel(t.channel);n&&n.handleEvent(t)}e||this.global_emitter.emit(t.event,t.data)}),this.connection.bind("connecting",()=>{this.channels.disconnect()}),this.connection.bind("disconnected",()=>{this.channels.disconnect()}),this.connection.bind("error",t=>{V.warn(t)}),Le.instances.push(this),this.timeline.info({instances:Le.instances.length}),this.user=new xe(this),Le.isReady&&this.connect()}switchCluster(t){const{appKey:e,cluster:n}=t;this.key=e,this.options=Object.assign(Object.assign({},this.options),{cluster:n}),this.config=we(this.options,this),this.connection.switchCluster(this.key)}channel(t){return this.channels.find(t)}allChannels(){return this.channels.all()}connect(){if(this.connection.connect(),this.timelineSender&&!this.timelineSenderTimer){var t=this.connection.isUsingTLS(),e=this.timelineSender;this.timelineSenderTimer=new D(6e4,(function(){e.send(t)}))}}disconnect(){this.connection.disconnect(),this.timelineSenderTimer&&(this.timelineSenderTimer.ensureAborted(),this.timelineSenderTimer=null)}bind(t,e,n){return this.global_emitter.bind(t,e,n),this}unbind(t,e,n){return this.global_emitter.unbind(t,e,n),this}bind_global(t){return this.global_emitter.bind_global(t),this}unbind_global(t){return this.global_emitter.unbind_global(t),this}unbind_all(t){return this.global_emitter.unbind_all(),this}subscribeAll(){var t;for(t in this.channels.channels)this.channels.channels.hasOwnProperty(t)&&this.subscribe(t)}subscribe(t){var e=this.channels.add(t,this);return e.subscriptionPending&&e.subscriptionCancelled?e.reinstateSubscription():e.subscriptionPending||"connected"!==this.connection.state||e.subscribe(),e}unsubscribe(t){var e=this.channels.find(t);e&&e.subscriptionPending?e.cancelSubscription():(e=this.channels.remove(t))&&e.subscribed&&e.unsubscribe()}send_event(t,e,n){return this.connection.send_event(t,e,n)}shouldUseTLS(){return this.config.useTLS}signin(){this.user.signin()}}Le.instances=[],Le.isReady=!1,Le.logToConsole=!1,Le.Runtime=ue,Le.ScriptReceivers=ue.ScriptReceivers,Le.DependenciesReceivers=ue.DependenciesReceivers,Le.auth_callbacks=ue.auth_callbacks;var Ae=e.default=Le;ue.setup(Le)}])})); //# sourceMappingURL=pusher.min.js.map \ No newline at end of file diff --git a/dist/web/pusher.min.js.map b/dist/web/pusher.min.js.map index 98dd3202a..c1935fd3b 100644 --- a/dist/web/pusher.min.js.map +++ b/dist/web/pusher.min.js.map @@ -1 +1 @@ -{"version":3,"sources":["webpack://Pusher/webpack/universalModuleDefinition","webpack://Pusher/webpack/bootstrap","webpack://Pusher/./node_modules/@stablelib/base64/base64.ts","webpack://Pusher/./node_modules/@stablelib/utf8/utf8.ts","webpack://Pusher/./src/core/pusher.js","webpack://Pusher/./src/runtimes/web/dom/script_receiver_factory.ts","webpack://Pusher/./src/core/defaults.ts","webpack://Pusher/./src/runtimes/web/dom/dependencies.ts","webpack://Pusher/./src/runtimes/web/dom/dependency_loader.ts","webpack://Pusher/./src/core/utils/url_store.ts","webpack://Pusher/./src/core/auth/options.ts","webpack://Pusher/./src/core/errors.ts","webpack://Pusher/./src/runtimes/isomorphic/auth/xhr_auth.ts","webpack://Pusher/./src/core/base64.ts","webpack://Pusher/./src/core/utils/timers/abstract_timer.ts","webpack://Pusher/./src/core/utils/timers/index.ts","webpack://Pusher/./src/core/util.ts","webpack://Pusher/./src/core/utils/collections.ts","webpack://Pusher/./src/core/logger.ts","webpack://Pusher/./src/runtimes/web/auth/jsonp_auth.ts","webpack://Pusher/./src/runtimes/web/dom/script_request.ts","webpack://Pusher/./src/runtimes/web/dom/jsonp_request.ts","webpack://Pusher/./src/runtimes/web/timeline/jsonp_timeline.ts","webpack://Pusher/./src/core/transports/url_schemes.ts","webpack://Pusher/./src/core/events/callback_registry.ts","webpack://Pusher/./src/core/events/dispatcher.ts","webpack://Pusher/./src/core/transports/transport_connection.ts","webpack://Pusher/./src/core/transports/transport.ts","webpack://Pusher/./src/runtimes/isomorphic/transports/transports.ts","webpack://Pusher/./src/runtimes/web/transports/transports.ts","webpack://Pusher/./src/runtimes/web/net_info.ts","webpack://Pusher/./src/core/transports/assistant_to_the_transport_manager.ts","webpack://Pusher/./src/core/connection/protocol/protocol.ts","webpack://Pusher/./src/core/connection/connection.ts","webpack://Pusher/./src/core/connection/handshake/index.ts","webpack://Pusher/./src/core/timeline/timeline_sender.ts","webpack://Pusher/./src/core/channels/channel.ts","webpack://Pusher/./src/core/channels/private_channel.ts","webpack://Pusher/./src/core/channels/members.ts","webpack://Pusher/./src/core/channels/presence_channel.ts","webpack://Pusher/./src/core/channels/encrypted_channel.ts","webpack://Pusher/./src/core/connection/connection_manager.ts","webpack://Pusher/./src/core/channels/channels.ts","webpack://Pusher/./src/core/utils/factory.ts","webpack://Pusher/./src/core/transports/transport_manager.ts","webpack://Pusher/./src/core/strategies/sequential_strategy.ts","webpack://Pusher/./src/core/strategies/best_connected_ever_strategy.ts","webpack://Pusher/./src/core/strategies/websocket_prioritized_cached_strategy.ts","webpack://Pusher/./src/core/strategies/delayed_strategy.ts","webpack://Pusher/./src/core/strategies/if_strategy.ts","webpack://Pusher/./src/core/strategies/first_connected_strategy.ts","webpack://Pusher/./src/runtimes/web/default_strategy.ts","webpack://Pusher/./src/runtimes/web/http/http_xdomain_request.ts","webpack://Pusher/./src/core/http/http_request.ts","webpack://Pusher/./src/core/http/state.ts","webpack://Pusher/./src/core/http/http_socket.ts","webpack://Pusher/./src/core/timeline/level.ts","webpack://Pusher/./src/core/http/http_streaming_socket.ts","webpack://Pusher/./src/core/http/http_polling_socket.ts","webpack://Pusher/./src/runtimes/isomorphic/http/http_xhr_request.ts","webpack://Pusher/./src/runtimes/isomorphic/http/http.ts","webpack://Pusher/./src/runtimes/web/http/http.ts","webpack://Pusher/./src/runtimes/web/runtime.ts","webpack://Pusher/./src/runtimes/web/transports/transport_connection_initializer.ts","webpack://Pusher/./src/core/timeline/timeline.ts","webpack://Pusher/./src/core/strategies/transport_strategy.ts","webpack://Pusher/./src/core/strategies/strategy_builder.ts","webpack://Pusher/./src/core/auth/user_authenticator.ts","webpack://Pusher/./src/core/auth/channel_authorizer.ts","webpack://Pusher/./src/core/config.ts","webpack://Pusher/./src/core/auth/deprecated_channel_authorizer.ts","webpack://Pusher/./src/core/watchlist.ts","webpack://Pusher/./src/core/utils/flat_promise.ts","webpack://Pusher/./src/core/user.ts","webpack://Pusher/./src/core/pusher.ts","webpack://Pusher/./src/core/options.ts"],"names":["root","factory","exports","module","define","amd","window","installedModules","__webpack_require__","moduleId","i","l","modules","call","m","c","d","name","getter","o","Object","defineProperty","enumerable","get","r","Symbol","toStringTag","value","t","mode","__esModule","ns","create","key","bind","n","object","property","prototype","hasOwnProperty","p","s","_paddingCharacter","encodedLength","length","this","encode","data","out","_encodeByte","left","maxDecodedLength","decodedLength","_getPaddingLength","decode","Uint8Array","paddingLength","op","haveBad","v0","v1","v2","v3","_decodeChar","charCodeAt","Error","b","result","String","fromCharCode","Coder","stdCoder","URLSafeCoder","urlSafeCoder","INVALID_UTF8","arr","pos","chars","min","n1","n2","n3","push","join","default","ScriptReceiverFactory","prefix","lastId","callback","number","id","called","callbackWrapper","apply","arguments","receiver","ScriptReceivers","VERSION","PROTOCOL","wsPort","wssPort","wsPath","httpHost","httpPort","httpsPort","httpPath","stats_host","authEndpoint","authTransport","activityTimeout","pongTimeout","unavailableTimeout","userAuthentication","endpoint","transport","channelAuthorization","cdn_http","cdn_https","dependency_suffix","DependenciesReceivers","Dependencies","options","receivers","loading","self","request","createScriptRequest","getPath","error","remove","callbacks","successCallback","wasSuccessful","cleanup","send","protocol","getDocument","location","useTLS","replace","version","getRoot","suffix","urlStore","baseUrl","urls","authenticationEndpoint","path","authorizationEndpoint","javascriptQuickStart","triggeringClientEvents","encryptedChannelSupport","fullUrl","AuthRequestType","urlObj","url","BadEventName","msg","super","setPrototypeOf","BadChannelName","RequestTimedOut","TransportPriorityTooLow","TransportClosed","UnsupportedFeature","UnsupportedTransport","UnsupportedStrategy","HTTPAuthError","status","context","query","authOptions","authRequestType","xhr","createXHR","headerName","open","setRequestHeader","headers","headersProvider","dynamicHeaders","onreadystatechange","readyState","parsed","JSON","parse","responseText","e","toString","UserAuthentication","ChannelAuthorization","b64chars","b64tab","charAt","cb_utob","cc","utob","u","cb_encode","ccc","padlen","ord","btoa","set","clear","delay","timer","clearTimeout","clearInterval","setTimeout","setInterval","now","Date","valueOf","defer","args","boundArguments","Array","slice","concat","extend","target","sources","extensions","constructor","stringify","safeJSONStringify","arrayIndexOf","array","item","nativeIndexOf","indexOf","objectApply","f","keys","_","map","filter","test","filterObject","Boolean","any","encodeParamsObject","encodeURIComponent","buildQueryString","params","undefined","method","source","objects","paths","derez","nu","$ref","globalLog","message","console","log","globalLogWarn","globalLogError","warn","defaultLoggingFunction","logToConsole","callbackName","nextAuthCallbackID","document","script","createElement","auth_callbacks","callback_name","src","head","getElementsByTagName","documentElement","insertBefore","firstChild","ScriptRequest","errorString","type","charset","addEventListener","onerror","onload","async","attachEvent","navigator","userAgent","errorScript","text","nextSibling","parentNode","removeChild","getAgent","sender","host","createJSONPRequest","getGenericURL","baseScheme","hostTLS","hostNonTLS","getGenericPath","queryString","ws","getInitial","http","sockjs","_callbacks","prefixedEventName","fn","names","removeCallback","removeAllCallbacks","binding","failThrough","global_callbacks","eventName","add","unbind","unbind_global","metadata","hooks","priority","initialize","transportConnectionInitializer","state","timeline","generateUniqueID","handlesActivityChecks","supportsPing","socket","getSocket","onError","changeState","bindListeners","debug","close","ping","beforeOpen","onopen","emit","buildTimelineMessage","closeEvent","code","reason","wasClean","unbindListeners","onOpen","onclose","onClose","onmessage","onMessage","onactivity","onActivity","info","cid","environment","isSupported","WSTransport","isInitialized","getWebSocketAPI","createWebSocket","httpConfiguration","streamingConfiguration","HTTPFactory","createStreamingSocket","pollingConfiguration","createPollingSocket","xhrConfiguration","isXHRSupported","xhr_streaming","xhr_polling","SockJSTransport","file","SockJS","js_path","ignore_null_origin","ignoreNullOrigin","xdrConfiguration","isXDRSupported","XDRStreamingTransport","XDRPollingTransport","xdr_streaming","xdr_polling","onLine","manager","minPingDelay","maxPingDelay","pingDelay","connection","createConnection","openTimestamp","onClosed","reportDeath","lifespan","Math","max","isAlive","Protocol","decodeMessage","messageEvent","messageData","pusherEventData","pusherEvent","event","channel","user_id","encodeMessage","processHandshake","activity_timeout","action","socket_id","getCloseAction","getCloseError","send_event","listeners","activity","closed","handleCloseEvent","listener","finish","isEmpty","TimelineTransport","pusher","subscribed","subscriptionPending","subscriptionCancelled","socketId","auth","handleSubscriptionSucceededEvent","handleSubscriptionCountEvent","unsubscribe","subscription_count","subscriptionCount","authorize","assign","channel_data","config","channelAuthorizer","channelName","reset","members","member","myID","subscriptionData","presence","hash","count","me","memberData","user_info","authData","channelData","setMyID","user","signinDonePromise","user_data","handleInternalEvent","addedMember","addMember","removedMember","removeMember","onSubscription","disconnect","nacl","sharedSecret","handleEncryptedEvent","handleEvent","ciphertext","nonce","cipherText","secretbox","overheadLength","nonceLength","bytes","getDataToEmit","raw","usingTLS","errorCallbacks","buildErrorCallbacks","connectionCallbacks","buildConnectionCallbacks","handshakeCallbacks","buildHandshakeCallbacks","Network","getNetwork","netinfo","retryIn","sendActivityCheck","updateStrategy","runner","strategy","updateState","startConnecting","setUnavailableTimer","disconnectInternally","handshake","connect","handshakeError","abortConnecting","abort","clearRetryTimer","clearUnavailableTimer","abandonConnection","getStrategy","round","retryTimer","ensureAborted","unavailableTimer","stopActivityCheck","activityTimer","pong_timed_out","resetActivityCheck","shouldRetry","connected","Infinity","setConnection","withErrorEmitted","tls_only","refused","backoff","retry","newState","previousState","newStateDescription","previous","current","channels","createEncryptedChannel","errMsg","createPrivateChannel","createPresenceChannel","createChannel","values","createChannels","createConnectionManager","createTimelineSender","createHandshake","createAssistantToTheTransportManager","livesLeft","lives","strategies","loop","failFast","timeout","timeoutLimit","minPriority","tryNextStrategy","tryStrategy","forceMinPriority","isRunning","callbackBuilder","runners","rs","abortRunner","allRunnersFailed","aborted","transports","ttl","storage","getLocalStorage","serializedCache","getTransportCacheKey","flushTransportCache","fetchTransportCache","cacheSkipCount","timestamp","includes","cached","latency","startTimestamp","pop","cb","storeTransportCache","IfStrategy","trueBranch","falseBranch","FirstConnectedStrategy","testSupportsStrategy","baseOptions","defineTransport","definedTransports","defineTransportStrategy","wsStrategy","ws_options","wsHost","wss_options","sockjs_options","timeouts","ws_manager","streaming_manager","ws_transport","wss_transport","sockjs_transport","xhr_streaming_transport","xdr_streaming_transport","xhr_polling_transport","xdr_polling_transport","ws_loop","wss_loop","sockjs_loop","streaming_loop","polling_loop","http_loop","http_fallback_loop","getRequest","xdr","XDomainRequest","ontimeout","onprogress","onChunk","abortRequest","payload","position","unloader","addUnloadListener","removeUnloadListener","chunk","advanceBuffer","isBufferTooLong","buffer","unreadData","endOfLinePosition","State","autoIncrement","getUniqueURL","separator","randomNumber","randomInt","TimelineLevel","session","randomString","parts","exec","base","getLocation","CONNECTING","openStream","sendRaw","sendHeartbeat","OPEN","createSocketRequest","start","closeStream","CLOSED","onEvent","onHeartbeat","hostname","urlParts","stream","getReceiveURL","onFinished","reconnect","unbind_all","getXHRAPI","createSocket","createRequest","getDefaultStrategy","Transports","load","XMLHttpRequest","WebSocket","MozWebSocket","PusherClass","Pusher","initializeOnDocumentBody","onDocumentBody","ready","getAuthorizers","ajax","jsonp","body","localStorage","createXMLHttpRequest","createMicrosoftXHR","ActiveXObject","createXDR","Constructor","withCredentials","documentProtocol","getProtocol","removeEventListener","detachEvent","floor","crypto","getRandomValues","Uint32Array","events","sent","uniqueID","level","limit","shift","ERROR","INFO","DEBUG","sendfn","bundle","lib","cluster","features","failAttempt","onInitialized","serializedTransport","transportClass","enabledTransports","disabledTransports","getAssistant","deferred","paramsProvider","dynamicParams","composeChannelQuery","getHttpHost","opts","getWebsocketHost","shouldUseTLS","forceTLS","getEnableStatsConfig","enableStats","disableStats","buildUserAuthenticator","buildChannelAuthorizer","customHandler","channelAuthorizerGenerator","deprecatedAuthorizerOptions","ChannelAuthorizerProxy","authorizer","buildChannelAuth","bindWatchlistInternalEvent","forEach","watchlistEvent","resolve","reject","promise","Promise","res","rej","signin_requested","serverToUserChannel","_signinDoneResolve","_onAuthorize","err","_cleanup","_signin","_newSigninPromiseIfNeeded","watchlist","_onSigninSuccess","userAuthenticator","_subscribeChannels","bind_global","reinstateSubscription","subscribe","ensure_subscribed","done","setDone","then","catch","isReady","instances","app_key","checkAppKey","validateOptions","statsHost","timelineParams","getConfig","global_emitter","sessionID","getClientFeatures","timelineSender","subscribeAll","isUsingTLS","internal","find","all","timelineSenderTimer","event_name","channel_name","cancelSubscription","signin","Runtime","setup"],"mappings":";;;;;;;CAAA,SAA2CA,EAAMC,GAC1B,iBAAZC,SAA0C,iBAAXC,OACxCA,OAAOD,QAAUD,IACQ,mBAAXG,QAAyBA,OAAOC,IAC9CD,OAAO,GAAIH,GACe,iBAAZC,QACdA,QAAgB,OAAID,IAEpBD,EAAa,OAAIC,IARnB,CASGK,QAAQ,WACX,O,YCTE,IAAIC,EAAmB,GAGvB,SAASC,EAAoBC,GAG5B,GAAGF,EAAiBE,GACnB,OAAOF,EAAiBE,GAAUP,QAGnC,IAAIC,EAASI,EAAiBE,GAAY,CACzCC,EAAGD,EACHE,GAAG,EACHT,QAAS,IAUV,OANAU,EAAQH,GAAUI,KAAKV,EAAOD,QAASC,EAAQA,EAAOD,QAASM,GAG/DL,EAAOQ,GAAI,EAGJR,EAAOD,QA0Df,OArDAM,EAAoBM,EAAIF,EAGxBJ,EAAoBO,EAAIR,EAGxBC,EAAoBQ,EAAI,SAASd,EAASe,EAAMC,GAC3CV,EAAoBW,EAAEjB,EAASe,IAClCG,OAAOC,eAAenB,EAASe,EAAM,CAAEK,YAAY,EAAMC,IAAKL,KAKhEV,EAAoBgB,EAAI,SAAStB,GACX,oBAAXuB,QAA0BA,OAAOC,aAC1CN,OAAOC,eAAenB,EAASuB,OAAOC,YAAa,CAAEC,MAAO,WAE7DP,OAAOC,eAAenB,EAAS,aAAc,CAAEyB,OAAO,KAQvDnB,EAAoBoB,EAAI,SAASD,EAAOE,GAEvC,GADU,EAAPA,IAAUF,EAAQnB,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AOvW,KAAKuV,WAAWyB,WAAWyW,EAAYvtB,EAAMqW,GAGtD,eACE,OAAOvW,KAAKuY,OAAO1S,OAGrB,SACE7F,KAAKwZ,KAAKoU,UAxNL,GAAApB,UAAsB,GACtB,GAAAD,SAAmB,EACnB,GAAA9e,cAAwB,EAGxB,GAAAogB,QAA2B,GAC3B,GAAA1qB,gBAA6B,GAASA,gBACtC,GAAAuB,sBAAmC,GAASA,sBAC5C,GAAAqJ,eAA4B,GAASA,eAVzB,oBAoOrB,GAAQ+f,MAAM","file":"pusher.min.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"Pusher\"] = factory();\n\telse\n\t\troot[\"Pusher\"] = factory();\n})(window, function() {\nreturn "," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 2);\n","// Copyright (C) 2016 Dmitry Chestnykh\n// MIT License. See LICENSE file for details.\n\n/**\n * Package base64 implements Base64 encoding and decoding.\n */\n\n// Invalid character used in decoding to indicate\n// that the character to decode is out of range of\n// alphabet and cannot be decoded.\nconst INVALID_BYTE = 256;\n\n/**\n * Implements standard Base64 encoding.\n *\n * Operates in constant time.\n */\nexport class Coder {\n // TODO(dchest): methods to encode chunk-by-chunk.\n\n constructor(private _paddingCharacter = \"=\") { }\n\n encodedLength(length: number): number {\n if (!this._paddingCharacter) {\n return (length * 8 + 5) / 6 | 0;\n }\n return (length + 2) / 3 * 4 | 0;\n }\n\n encode(data: Uint8Array): string {\n let out = \"\";\n\n let i = 0;\n for (; i < data.length - 2; i += 3) {\n let c = (data[i] << 16) | (data[i + 1] << 8) | (data[i + 2]);\n out += this._encodeByte((c >>> 3 * 6) & 63);\n out += this._encodeByte((c >>> 2 * 6) & 63);\n out += this._encodeByte((c >>> 1 * 6) & 63);\n out += this._encodeByte((c >>> 0 * 6) & 63);\n }\n\n const left = data.length - i;\n if (left > 0) {\n let c = (data[i] << 16) | (left === 2 ? data[i + 1] << 8 : 0);\n out += this._encodeByte((c >>> 3 * 6) & 63);\n out += this._encodeByte((c >>> 2 * 6) & 63);\n if (left === 2) {\n out += this._encodeByte((c >>> 1 * 6) & 63);\n } else {\n out += this._paddingCharacter || \"\";\n }\n out += this._paddingCharacter || \"\";\n }\n\n return out;\n }\n\n maxDecodedLength(length: number): number {\n if (!this._paddingCharacter) {\n return (length * 6 + 7) / 8 | 0;\n }\n return length / 4 * 3 | 0;\n }\n\n decodedLength(s: string): number {\n return this.maxDecodedLength(s.length - this._getPaddingLength(s));\n }\n\n decode(s: string): Uint8Array {\n if (s.length === 0) {\n return new Uint8Array(0);\n }\n const paddingLength = this._getPaddingLength(s);\n const length = s.length - paddingLength;\n const out = new Uint8Array(this.maxDecodedLength(length));\n let op = 0;\n let i = 0;\n let haveBad = 0;\n let v0 = 0, v1 = 0, v2 = 0, v3 = 0;\n for (; i < length - 4; i += 4) {\n v0 = this._decodeChar(s.charCodeAt(i + 0));\n v1 = this._decodeChar(s.charCodeAt(i + 1));\n v2 = this._decodeChar(s.charCodeAt(i + 2));\n v3 = this._decodeChar(s.charCodeAt(i + 3));\n out[op++] = (v0 << 2) | (v1 >>> 4);\n out[op++] = (v1 << 4) | (v2 >>> 2);\n out[op++] = (v2 << 6) | v3;\n haveBad |= v0 & INVALID_BYTE;\n haveBad |= v1 & INVALID_BYTE;\n haveBad |= v2 & INVALID_BYTE;\n haveBad |= v3 & INVALID_BYTE;\n }\n if (i < length - 1) {\n v0 = this._decodeChar(s.charCodeAt(i));\n v1 = this._decodeChar(s.charCodeAt(i + 1));\n out[op++] = (v0 << 2) | (v1 >>> 4);\n haveBad |= v0 & INVALID_BYTE;\n haveBad |= v1 & INVALID_BYTE;\n }\n if (i < length - 2) {\n v2 = this._decodeChar(s.charCodeAt(i + 2));\n out[op++] = (v1 << 4) | (v2 >>> 2);\n haveBad |= v2 & INVALID_BYTE;\n }\n if (i < length - 3) {\n v3 = this._decodeChar(s.charCodeAt(i + 3));\n out[op++] = (v2 << 6) | v3;\n haveBad |= v3 & INVALID_BYTE;\n }\n if (haveBad !== 0) {\n throw new Error(\"Base64Coder: incorrect characters for decoding\");\n }\n return out;\n }\n\n // Standard encoding have the following encoded/decoded ranges,\n // which we need to convert between.\n //\n // ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 0123456789 + /\n // Index: 0 - 25 26 - 51 52 - 61 62 63\n // ASCII: 65 - 90 97 - 122 48 - 57 43 47\n //\n\n // Encode 6 bits in b into a new character.\n protected _encodeByte(b: number): string {\n // Encoding uses constant time operations as follows:\n //\n // 1. Define comparison of A with B using (A - B) >>> 8:\n // if A > B, then result is positive integer\n // if A <= B, then result is 0\n //\n // 2. Define selection of C or 0 using bitwise AND: X & C:\n // if X == 0, then result is 0\n // if X != 0, then result is C\n //\n // 3. Start with the smallest comparison (b >= 0), which is always\n // true, so set the result to the starting ASCII value (65).\n //\n // 4. Continue comparing b to higher ASCII values, and selecting\n // zero if comparison isn't true, otherwise selecting a value\n // to add to result, which:\n //\n // a) undoes the previous addition\n // b) provides new value to add\n //\n let result = b;\n // b >= 0\n result += 65;\n // b > 25\n result += ((25 - b) >>> 8) & ((0 - 65) - 26 + 97);\n // b > 51\n result += ((51 - b) >>> 8) & ((26 - 97) - 52 + 48);\n // b > 61\n result += ((61 - b) >>> 8) & ((52 - 48) - 62 + 43);\n // b > 62\n result += ((62 - b) >>> 8) & ((62 - 43) - 63 + 47);\n\n return String.fromCharCode(result);\n }\n\n // Decode a character code into a byte.\n // Must return 256 if character is out of alphabet range.\n protected _decodeChar(c: number): number {\n // Decoding works similar to encoding: using the same comparison\n // function, but now it works on ranges: result is always incremented\n // by value, but this value becomes zero if the range is not\n // satisfied.\n //\n // Decoding starts with invalid value, 256, which is then\n // subtracted when the range is satisfied. If none of the ranges\n // apply, the function returns 256, which is then checked by\n // the caller to throw error.\n let result = INVALID_BYTE; // start with invalid character\n\n // c == 43 (c > 42 and c < 44)\n result += (((42 - c) & (c - 44)) >>> 8) & (-INVALID_BYTE + c - 43 + 62);\n // c == 47 (c > 46 and c < 48)\n result += (((46 - c) & (c - 48)) >>> 8) & (-INVALID_BYTE + c - 47 + 63);\n // c > 47 and c < 58\n result += (((47 - c) & (c - 58)) >>> 8) & (-INVALID_BYTE + c - 48 + 52);\n // c > 64 and c < 91\n result += (((64 - c) & (c - 91)) >>> 8) & (-INVALID_BYTE + c - 65 + 0);\n // c > 96 and c < 123\n result += (((96 - c) & (c - 123)) >>> 8) & (-INVALID_BYTE + c - 97 + 26);\n\n return result;\n }\n\n private _getPaddingLength(s: string): number {\n let paddingLength = 0;\n if (this._paddingCharacter) {\n for (let i = s.length - 1; i >= 0; i--) {\n if (s[i] !== this._paddingCharacter) {\n break;\n }\n paddingLength++;\n }\n if (s.length < 4 || paddingLength > 2) {\n throw new Error(\"Base64Coder: incorrect padding\");\n }\n }\n return paddingLength;\n }\n\n}\n\nconst stdCoder = new Coder();\n\nexport function encode(data: Uint8Array): string {\n return stdCoder.encode(data);\n}\n\nexport function decode(s: string): Uint8Array {\n return stdCoder.decode(s);\n}\n\n/**\n * Implements URL-safe Base64 encoding.\n * (Same as Base64, but '+' is replaced with '-', and '/' with '_').\n *\n * Operates in constant time.\n */\nexport class URLSafeCoder extends Coder {\n // URL-safe encoding have the following encoded/decoded ranges:\n //\n // ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 0123456789 - _\n // Index: 0 - 25 26 - 51 52 - 61 62 63\n // ASCII: 65 - 90 97 - 122 48 - 57 45 95\n //\n\n protected _encodeByte(b: number): string {\n let result = b;\n // b >= 0\n result += 65;\n // b > 25\n result += ((25 - b) >>> 8) & ((0 - 65) - 26 + 97);\n // b > 51\n result += ((51 - b) >>> 8) & ((26 - 97) - 52 + 48);\n // b > 61\n result += ((61 - b) >>> 8) & ((52 - 48) - 62 + 45);\n // b > 62\n result += ((62 - b) >>> 8) & ((62 - 45) - 63 + 95);\n\n return String.fromCharCode(result);\n }\n\n protected _decodeChar(c: number): number {\n let result = INVALID_BYTE;\n\n // c == 45 (c > 44 and c < 46)\n result += (((44 - c) & (c - 46)) >>> 8) & (-INVALID_BYTE + c - 45 + 62);\n // c == 95 (c > 94 and c < 96)\n result += (((94 - c) & (c - 96)) >>> 8) & (-INVALID_BYTE + c - 95 + 63);\n // c > 47 and c < 58\n result += (((47 - c) & (c - 58)) >>> 8) & (-INVALID_BYTE + c - 48 + 52);\n // c > 64 and c < 91\n result += (((64 - c) & (c - 91)) >>> 8) & (-INVALID_BYTE + c - 65 + 0);\n // c > 96 and c < 123\n result += (((96 - c) & (c - 123)) >>> 8) & (-INVALID_BYTE + c - 97 + 26);\n\n return result;\n }\n}\n\nconst urlSafeCoder = new URLSafeCoder();\n\nexport function encodeURLSafe(data: Uint8Array): string {\n return urlSafeCoder.encode(data);\n}\n\nexport function decodeURLSafe(s: string): Uint8Array {\n return urlSafeCoder.decode(s);\n}\n\n\nexport const encodedLength = (length: number) =>\n stdCoder.encodedLength(length);\n\nexport const maxDecodedLength = (length: number) =>\n stdCoder.maxDecodedLength(length);\n\nexport const decodedLength = (s: string) =>\n stdCoder.decodedLength(s);\n","// Copyright (C) 2016 Dmitry Chestnykh\n// MIT License. See LICENSE file for details.\n\n/**\n * Package utf8 implements UTF-8 encoding and decoding.\n */\n\nconst INVALID_UTF16 = \"utf8: invalid string\";\nconst INVALID_UTF8 = \"utf8: invalid source encoding\";\n\n/**\n * Encodes the given string into UTF-8 byte array.\n * Throws if the source string has invalid UTF-16 encoding.\n */\nexport function encode(s: string): Uint8Array {\n // Calculate result length and allocate output array.\n // encodedLength() also validates string and throws errors,\n // so we don't need repeat validation here.\n const arr = new Uint8Array(encodedLength(s));\n\n let pos = 0;\n for (let i = 0; i < s.length; i++) {\n let c = s.charCodeAt(i);\n if (c < 0x80) {\n arr[pos++] = c;\n } else if (c < 0x800) {\n arr[pos++] = 0xc0 | c >> 6;\n arr[pos++] = 0x80 | c & 0x3f;\n } else if (c < 0xd800) {\n arr[pos++] = 0xe0 | c >> 12;\n arr[pos++] = 0x80 | (c >> 6) & 0x3f;\n arr[pos++] = 0x80 | c & 0x3f;\n } else {\n i++; // get one more character\n c = (c & 0x3ff) << 10;\n c |= s.charCodeAt(i) & 0x3ff;\n c += 0x10000;\n\n arr[pos++] = 0xf0 | c >> 18;\n arr[pos++] = 0x80 | (c >> 12) & 0x3f;\n arr[pos++] = 0x80 | (c >> 6) & 0x3f;\n arr[pos++] = 0x80 | c & 0x3f;\n }\n }\n return arr;\n}\n\n/**\n * Returns the number of bytes required to encode the given string into UTF-8.\n * Throws if the source string has invalid UTF-16 encoding.\n */\nexport function encodedLength(s: string): number {\n let result = 0;\n for (let i = 0; i < s.length; i++) {\n const c = s.charCodeAt(i);\n if (c < 0x80) {\n result += 1;\n } else if (c < 0x800) {\n result += 2;\n } else if (c < 0xd800) {\n result += 3;\n } else if (c <= 0xdfff) {\n if (i >= s.length - 1) {\n throw new Error(INVALID_UTF16);\n }\n i++; // \"eat\" next character\n result += 4;\n } else {\n throw new Error(INVALID_UTF16);\n }\n }\n return result;\n}\n\n/**\n * Decodes the given byte array from UTF-8 into a string.\n * Throws if encoding is invalid.\n */\nexport function decode(arr: Uint8Array): string {\n const chars: string[] = [];\n for (let i = 0; i < arr.length; i++) {\n let b = arr[i];\n\n if (b & 0x80) {\n let min;\n if (b < 0xe0) {\n // Need 1 more byte.\n if (i >= arr.length) {\n throw new Error(INVALID_UTF8);\n }\n const n1 = arr[++i];\n if ((n1 & 0xc0) !== 0x80) {\n throw new Error(INVALID_UTF8);\n }\n b = (b & 0x1f) << 6 | (n1 & 0x3f);\n min = 0x80;\n } else if (b < 0xf0) {\n // Need 2 more bytes.\n if (i >= arr.length - 1) {\n throw new Error(INVALID_UTF8);\n }\n const n1 = arr[++i];\n const n2 = arr[++i];\n if ((n1 & 0xc0) !== 0x80 || (n2 & 0xc0) !== 0x80) {\n throw new Error(INVALID_UTF8);\n }\n b = (b & 0x0f) << 12 | (n1 & 0x3f) << 6 | (n2 & 0x3f);\n min = 0x800;\n } else if (b < 0xf8) {\n // Need 3 more bytes.\n if (i >= arr.length - 2) {\n throw new Error(INVALID_UTF8);\n }\n const n1 = arr[++i];\n const n2 = arr[++i];\n const n3 = arr[++i];\n if ((n1 & 0xc0) !== 0x80 || (n2 & 0xc0) !== 0x80 || (n3 & 0xc0) !== 0x80) {\n throw new Error(INVALID_UTF8);\n }\n b = (b & 0x0f) << 18 | (n1 & 0x3f) << 12 | (n2 & 0x3f) << 6 | (n3 & 0x3f);\n min = 0x10000;\n } else {\n throw new Error(INVALID_UTF8);\n }\n\n if (b < min || (b >= 0xd800 && b <= 0xdfff)) {\n throw new Error(INVALID_UTF8);\n }\n\n if (b >= 0x10000) {\n // Surrogate pair.\n if (b > 0x10ffff) {\n throw new Error(INVALID_UTF8);\n }\n b -= 0x10000;\n chars.push(String.fromCharCode(0xd800 | (b >> 10)));\n b = 0xdc00 | (b & 0x3ff);\n }\n }\n\n chars.push(String.fromCharCode(b));\n }\n return chars.join(\"\");\n}\n","// required so we don't have to do require('pusher').default etc.\nmodule.exports = require('./pusher').default;\n","import ScriptReceiver from './script_receiver';\n\n/** Builds receivers for JSONP and Script requests.\n *\n * Each receiver is an object with following fields:\n * - number - unique (for the factory instance), numerical id of the receiver\n * - id - a string ID that can be used in DOM attributes\n * - name - name of the function triggering the receiver\n * - callback - callback function\n *\n * Receivers are triggered only once, on the first callback call.\n *\n * Receivers can be called by their name or by accessing factory object\n * by the number key.\n *\n * @param {String} prefix the prefix used in ids\n * @param {String} name the name of the object\n */\nexport class ScriptReceiverFactory {\n lastId: number;\n prefix: string;\n name: string;\n\n constructor(prefix: string, name: string) {\n this.lastId = 0;\n this.prefix = prefix;\n this.name = name;\n }\n\n create(callback: Function): ScriptReceiver {\n this.lastId++;\n\n var number = this.lastId;\n var id = this.prefix + number;\n var name = this.name + '[' + number + ']';\n\n var called = false;\n var callbackWrapper = function() {\n if (!called) {\n callback.apply(null, arguments);\n called = true;\n }\n };\n\n this[number] = callbackWrapper;\n return { number: number, id: id, name: name, callback: callbackWrapper };\n }\n\n remove(receiver: ScriptReceiver) {\n delete this[receiver.number];\n }\n}\n\nexport var ScriptReceivers = new ScriptReceiverFactory(\n '_pusher_script_',\n 'Pusher.ScriptReceivers'\n);\n","import {\n ChannelAuthorizationOptions,\n UserAuthenticationOptions\n} from './auth/options';\nimport { AuthTransport } from './config';\n\nexport interface DefaultConfig {\n VERSION: string;\n PROTOCOL: number;\n wsPort: number;\n wssPort: number;\n wsPath: string;\n httpHost: string;\n httpPort: number;\n httpsPort: number;\n httpPath: string;\n stats_host: string;\n authEndpoint: string;\n authTransport: AuthTransport;\n activityTimeout: number;\n pongTimeout: number;\n unavailableTimeout: number;\n userAuthentication: UserAuthenticationOptions;\n channelAuthorization: ChannelAuthorizationOptions;\n\n cdn_http?: string;\n cdn_https?: string;\n dependency_suffix?: string;\n}\n\nvar Defaults: DefaultConfig = {\n VERSION: VERSION,\n PROTOCOL: 7,\n\n wsPort: 80,\n wssPort: 443,\n wsPath: '',\n // DEPRECATED: SockJS fallback parameters\n httpHost: 'sockjs.pusher.com',\n httpPort: 80,\n httpsPort: 443,\n httpPath: '/pusher',\n // DEPRECATED: Stats\n stats_host: 'stats.pusher.com',\n // DEPRECATED: Other settings\n authEndpoint: '/pusher/auth',\n authTransport: 'ajax',\n activityTimeout: 120000,\n pongTimeout: 30000,\n unavailableTimeout: 10000,\n userAuthentication: {\n endpoint: '/pusher/user-auth',\n transport: 'ajax'\n },\n channelAuthorization: {\n endpoint: '/pusher/auth',\n transport: 'ajax'\n },\n\n // CDN configuration\n cdn_http: CDN_HTTP,\n cdn_https: CDN_HTTPS,\n dependency_suffix: DEPENDENCY_SUFFIX\n};\n\nexport default Defaults;\n","import { ScriptReceiverFactory } from './script_receiver_factory';\nimport Defaults from 'core/defaults';\nimport DependencyLoader from './dependency_loader';\n\nexport var DependenciesReceivers = new ScriptReceiverFactory(\n '_pusher_dependencies',\n 'Pusher.DependenciesReceivers'\n);\n\nexport var Dependencies = new DependencyLoader({\n cdn_http: Defaults.cdn_http,\n cdn_https: Defaults.cdn_https,\n version: Defaults.VERSION,\n suffix: Defaults.dependency_suffix,\n receivers: DependenciesReceivers\n});\n","import {\n ScriptReceivers,\n ScriptReceiverFactory\n} from './script_receiver_factory';\nimport Runtime from 'runtime';\nimport ScriptRequest from './script_request';\n\n/** Handles loading dependency files.\n *\n * Dependency loaders don't remember whether a resource has been loaded or\n * not. It is caller's responsibility to make sure the resource is not loaded\n * twice. This is because it's impossible to detect resource loading status\n * without knowing its content.\n *\n * Options:\n * - cdn_http - url to HTTP CND\n * - cdn_https - url to HTTPS CDN\n * - version - version of pusher-js\n * - suffix - suffix appended to all names of dependency files\n *\n * @param {Object} options\n */\nexport default class DependencyLoader {\n options: any;\n receivers: ScriptReceiverFactory;\n loading: any;\n\n constructor(options: any) {\n this.options = options;\n this.receivers = options.receivers || ScriptReceivers;\n this.loading = {};\n }\n\n /** Loads the dependency from CDN.\n *\n * @param {String} name\n * @param {Function} callback\n */\n load(name: string, options: any, callback: Function) {\n var self = this;\n\n if (self.loading[name] && self.loading[name].length > 0) {\n self.loading[name].push(callback);\n } else {\n self.loading[name] = [callback];\n\n var request = Runtime.createScriptRequest(self.getPath(name, options));\n var receiver = self.receivers.create(function(error) {\n self.receivers.remove(receiver);\n\n if (self.loading[name]) {\n var callbacks = self.loading[name];\n delete self.loading[name];\n\n var successCallback = function(wasSuccessful) {\n if (!wasSuccessful) {\n request.cleanup();\n }\n };\n for (var i = 0; i < callbacks.length; i++) {\n callbacks[i](error, successCallback);\n }\n }\n });\n request.send(receiver);\n }\n }\n\n /** Returns a root URL for pusher-js CDN.\n *\n * @returns {String}\n */\n getRoot(options: any): string {\n var cdn;\n var protocol = Runtime.getDocument().location.protocol;\n if ((options && options.useTLS) || protocol === 'https:') {\n cdn = this.options.cdn_https;\n } else {\n cdn = this.options.cdn_http;\n }\n // make sure there are no double slashes\n return cdn.replace(/\\/*$/, '') + '/' + this.options.version;\n }\n\n /** Returns a full path to a dependency file.\n *\n * @param {String} name\n * @returns {String}\n */\n getPath(name: string, options: any): string {\n return this.getRoot(options) + '/' + name + this.options.suffix + '.js';\n }\n}\n","/**\n * A place to store help URLs for error messages etc\n */\n\nconst urlStore = {\n baseUrl: 'https://pusher.com',\n urls: {\n authenticationEndpoint: {\n path: '/docs/channels/server_api/authenticating_users'\n },\n authorizationEndpoint: {\n path: '/docs/channels/server_api/authorizing-users/'\n },\n javascriptQuickStart: {\n path: '/docs/javascript_quick_start'\n },\n triggeringClientEvents: {\n path: '/docs/client_api_guide/client_events#trigger-events'\n },\n encryptedChannelSupport: {\n fullUrl:\n 'https://github.com/pusher/pusher-js/tree/cc491015371a4bde5743d1c87a0fbac0feb53195#encrypted-channel-support'\n }\n }\n};\n\n/** Builds a consistent string with links to pusher documentation\n *\n * @param {string} key - relevant key in the url_store.urls object\n * @return {string} suffix string to append to log message\n */\nconst buildLogSuffix = function(key: string): string {\n const urlPrefix = 'See:';\n const urlObj = urlStore.urls[key];\n if (!urlObj) return '';\n\n let url;\n if (urlObj.fullUrl) {\n url = urlObj.fullUrl;\n } else if (urlObj.path) {\n url = urlStore.baseUrl + urlObj.path;\n }\n\n if (!url) return '';\n return `${urlPrefix} ${url}`;\n};\n\nexport default { buildLogSuffix };\n","export enum AuthRequestType {\n UserAuthentication = 'user-authentication',\n ChannelAuthorization = 'channel-authorization'\n}\n\nexport interface ChannelAuthorizationData {\n auth: string;\n channel_data?: string;\n shared_secret?: string;\n}\n\nexport type ChannelAuthorizationCallback = (\n error: Error | null,\n authData: ChannelAuthorizationData | null\n) => void;\n\nexport interface ChannelAuthorizationRequestParams {\n socketId: string;\n channelName: string;\n}\n\nexport interface ChannelAuthorizationHandler {\n (\n params: ChannelAuthorizationRequestParams,\n callback: ChannelAuthorizationCallback\n ): void;\n}\n\nexport interface UserAuthenticationData {\n auth: string;\n user_data: string;\n}\n\nexport type UserAuthenticationCallback = (\n error: Error | null,\n authData: UserAuthenticationData | null\n) => void;\n\nexport interface UserAuthenticationRequestParams {\n socketId: string;\n}\n\nexport interface UserAuthenticationHandler {\n (\n params: UserAuthenticationRequestParams,\n callback: UserAuthenticationCallback\n ): void;\n}\n\nexport type AuthTransportCallback =\n | ChannelAuthorizationCallback\n | UserAuthenticationCallback;\n\nexport interface AuthOptionsT {\n transport: 'ajax' | 'jsonp';\n endpoint: string;\n params?: any;\n headers?: any;\n paramsProvider?: () => any;\n headersProvider?: () => any;\n customHandler?: AuthHandler;\n}\n\nexport declare type UserAuthenticationOptions = AuthOptionsT<\n UserAuthenticationHandler\n>;\nexport declare type ChannelAuthorizationOptions = AuthOptionsT<\n ChannelAuthorizationHandler\n>;\n\nexport interface InternalAuthOptions {\n transport: 'ajax' | 'jsonp';\n endpoint: string;\n params?: any;\n headers?: any;\n paramsProvider?: () => any;\n headersProvider?: () => any;\n}\n","/** Error classes used throughout the library. */\n// https://github.com/Microsoft/TypeScript-wiki/blob/master/Breaking-Changes.md#extending-built-ins-like-error-array-and-map-may-no-longer-work\nexport class BadEventName extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\nexport class BadChannelName extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\nexport class RequestTimedOut extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class TransportPriorityTooLow extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class TransportClosed extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class UnsupportedFeature extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class UnsupportedTransport extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class UnsupportedStrategy extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class HTTPAuthError extends Error {\n status: number;\n constructor(status: number, msg?: string) {\n super(msg);\n this.status = status;\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n","import TimelineSender from 'core/timeline/timeline_sender';\nimport * as Collections from 'core/utils/collections';\nimport Util from 'core/util';\nimport Runtime from 'runtime';\nimport { AuthTransport } from 'core/auth/auth_transports';\nimport AbstractRuntime from 'runtimes/interface';\nimport UrlStore from 'core/utils/url_store';\nimport {\n AuthRequestType,\n AuthTransportCallback,\n InternalAuthOptions\n} from 'core/auth/options';\nimport { HTTPAuthError } from 'core/errors';\n\nconst ajax: AuthTransport = function(\n context: AbstractRuntime,\n query: string,\n authOptions: InternalAuthOptions,\n authRequestType: AuthRequestType,\n callback: AuthTransportCallback\n) {\n const xhr = Runtime.createXHR();\n xhr.open('POST', authOptions.endpoint, true);\n\n // add request headers\n xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');\n for (var headerName in authOptions.headers) {\n xhr.setRequestHeader(headerName, authOptions.headers[headerName]);\n }\n if (authOptions.headersProvider != null) {\n let dynamicHeaders = authOptions.headersProvider();\n for (var headerName in dynamicHeaders) {\n xhr.setRequestHeader(headerName, dynamicHeaders[headerName]);\n }\n }\n\n xhr.onreadystatechange = function() {\n if (xhr.readyState === 4) {\n if (xhr.status === 200) {\n let data;\n let parsed = false;\n\n try {\n data = JSON.parse(xhr.responseText);\n parsed = true;\n } catch (e) {\n callback(\n new HTTPAuthError(\n 200,\n `JSON returned from ${authRequestType.toString()} endpoint was invalid, yet status code was 200. Data was: ${\n xhr.responseText\n }`\n ),\n null\n );\n }\n\n if (parsed) {\n // prevents double execution.\n callback(null, data);\n }\n } else {\n let suffix = '';\n switch (authRequestType) {\n case AuthRequestType.UserAuthentication:\n suffix = UrlStore.buildLogSuffix('authenticationEndpoint');\n break;\n case AuthRequestType.ChannelAuthorization:\n suffix = `Clients must be authorized to join private or presence channels. ${UrlStore.buildLogSuffix(\n 'authorizationEndpoint'\n )}`;\n break;\n }\n callback(\n new HTTPAuthError(\n xhr.status,\n `Unable to retrieve auth string from ${authRequestType.toString()} endpoint - ` +\n `received status: ${xhr.status} from ${authOptions.endpoint}. ${suffix}`\n ),\n null\n );\n }\n }\n };\n\n xhr.send(query);\n return xhr;\n};\n\nexport default ajax;\n","export default function encode(s: any): string {\n return btoa(utob(s));\n}\n\nvar fromCharCode = String.fromCharCode;\n\nvar b64chars =\n 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';\nvar b64tab = {};\n\nfor (var i = 0, l = b64chars.length; i < l; i++) {\n b64tab[b64chars.charAt(i)] = i;\n}\n\nvar cb_utob = function(c) {\n var cc = c.charCodeAt(0);\n return cc < 0x80\n ? c\n : cc < 0x800\n ? fromCharCode(0xc0 | (cc >>> 6)) + fromCharCode(0x80 | (cc & 0x3f))\n : fromCharCode(0xe0 | ((cc >>> 12) & 0x0f)) +\n fromCharCode(0x80 | ((cc >>> 6) & 0x3f)) +\n fromCharCode(0x80 | (cc & 0x3f));\n};\n\nvar utob = function(u) {\n return u.replace(/[^\\x00-\\x7F]/g, cb_utob);\n};\n\nvar cb_encode = function(ccc) {\n var padlen = [0, 2, 1][ccc.length % 3];\n var ord =\n (ccc.charCodeAt(0) << 16) |\n ((ccc.length > 1 ? ccc.charCodeAt(1) : 0) << 8) |\n (ccc.length > 2 ? ccc.charCodeAt(2) : 0);\n var chars = [\n b64chars.charAt(ord >>> 18),\n b64chars.charAt((ord >>> 12) & 63),\n padlen >= 2 ? '=' : b64chars.charAt((ord >>> 6) & 63),\n padlen >= 1 ? '=' : b64chars.charAt(ord & 63)\n ];\n return chars.join('');\n};\n\nvar btoa =\n global.btoa ||\n function(b) {\n return b.replace(/[\\s\\S]{1,3}/g, cb_encode);\n };\n","import TimedCallback from './timed_callback';\nimport { Delay, Scheduler, Canceller } from './scheduling';\n\nabstract class Timer {\n protected clear: Canceller;\n protected timer: number | void;\n\n constructor(\n set: Scheduler,\n clear: Canceller,\n delay: Delay,\n callback: TimedCallback\n ) {\n this.clear = clear;\n this.timer = set(() => {\n if (this.timer) {\n this.timer = callback(this.timer);\n }\n }, delay);\n }\n\n /** Returns whether the timer is still running.\n *\n * @return {Boolean}\n */\n isRunning(): boolean {\n return this.timer !== null;\n }\n\n /** Aborts a timer when it's running. */\n ensureAborted() {\n if (this.timer) {\n this.clear(this.timer);\n this.timer = null;\n }\n }\n}\n\nexport default Timer;\n","import Timer from './abstract_timer';\nimport TimedCallback from './timed_callback';\nimport { Delay } from './scheduling';\n\n// We need to bind clear functions this way to avoid exceptions on IE8\nfunction clearTimeout(timer) {\n global.clearTimeout(timer);\n}\nfunction clearInterval(timer) {\n global.clearInterval(timer);\n}\n\n/** Cross-browser compatible one-off timer abstraction.\n *\n * @param {Number} delay\n * @param {Function} callback\n */\nexport class OneOffTimer extends Timer {\n constructor(delay: Delay, callback: TimedCallback) {\n super(setTimeout, clearTimeout, delay, function(timer) {\n callback();\n return null;\n });\n }\n}\n\n/** Cross-browser compatible periodic timer abstraction.\n *\n * @param {Number} delay\n * @param {Function} callback\n */\nexport class PeriodicTimer extends Timer {\n constructor(delay: Delay, callback: TimedCallback) {\n super(setInterval, clearInterval, delay, function(timer) {\n callback();\n return timer;\n });\n }\n}\n","import * as Collections from './utils/collections';\nimport TimedCallback from './utils/timers/timed_callback';\nimport { OneOffTimer, PeriodicTimer } from './utils/timers';\n\nvar Util = {\n now(): number {\n if (Date.now) {\n return Date.now();\n } else {\n return new Date().valueOf();\n }\n },\n\n defer(callback: TimedCallback): OneOffTimer {\n return new OneOffTimer(0, callback);\n },\n\n /** Builds a function that will proxy a method call to its first argument.\n *\n * Allows partial application of arguments, so additional arguments are\n * prepended to the argument list.\n *\n * @param {String} name method name\n * @return {Function} proxy function\n */\n method(name: string, ...args: any[]): Function {\n var boundArguments = Array.prototype.slice.call(arguments, 1);\n return function(object) {\n return object[name].apply(object, boundArguments.concat(arguments));\n };\n }\n};\n\nexport default Util;\n","import base64encode from '../base64';\nimport Util from '../util';\n\n/** Merges multiple objects into the target argument.\n *\n * For properties that are plain Objects, performs a deep-merge. For the\n * rest it just copies the value of the property.\n *\n * To extend prototypes use it as following:\n * Pusher.Util.extend(Target.prototype, Base.prototype)\n *\n * You can also use it to merge objects without altering them:\n * Pusher.Util.extend({}, object1, object2)\n *\n * @param {Object} target\n * @return {Object} the target argument\n */\nexport function extend(target: any, ...sources: any[]): T {\n for (var i = 0; i < sources.length; i++) {\n var extensions = sources[i];\n for (var property in extensions) {\n if (\n extensions[property] &&\n extensions[property].constructor &&\n extensions[property].constructor === Object\n ) {\n target[property] = extend(target[property] || {}, extensions[property]);\n } else {\n target[property] = extensions[property];\n }\n }\n }\n return target;\n}\n\nexport function stringify(): string {\n var m = ['Pusher'];\n for (var i = 0; i < arguments.length; i++) {\n if (typeof arguments[i] === 'string') {\n m.push(arguments[i]);\n } else {\n m.push(safeJSONStringify(arguments[i]));\n }\n }\n return m.join(' : ');\n}\n\nexport function arrayIndexOf(array: any[], item: any): number {\n // MSIE doesn't have array.indexOf\n var nativeIndexOf = Array.prototype.indexOf;\n if (array === null) {\n return -1;\n }\n if (nativeIndexOf && array.indexOf === nativeIndexOf) {\n return array.indexOf(item);\n }\n for (var i = 0, l = array.length; i < l; i++) {\n if (array[i] === item) {\n return i;\n }\n }\n return -1;\n}\n\n/** Applies a function f to all properties of an object.\n *\n * Function f gets 3 arguments passed:\n * - element from the object\n * - key of the element\n * - reference to the object\n *\n * @param {Object} object\n * @param {Function} f\n */\nexport function objectApply(object: any, f: Function) {\n for (var key in object) {\n if (Object.prototype.hasOwnProperty.call(object, key)) {\n f(object[key], key, object);\n }\n }\n}\n\n/** Return a list of objects own proerty keys\n *\n * @param {Object} object\n * @returns {Array}\n */\nexport function keys(object: any): string[] {\n var keys = [];\n objectApply(object, function(_, key) {\n keys.push(key);\n });\n return keys;\n}\n\n/** Return a list of object's own property values\n *\n * @param {Object} object\n * @returns {Array}\n */\nexport function values(object: any): any[] {\n var values = [];\n objectApply(object, function(value) {\n values.push(value);\n });\n return values;\n}\n\n/** Applies a function f to all elements of an array.\n *\n * Function f gets 3 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function apply(array: any[], f: Function, context?: any) {\n for (var i = 0; i < array.length; i++) {\n f.call(context || global, array[i], i, array);\n }\n}\n\n/** Maps all elements of the array and returns the result.\n *\n * Function f gets 4 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n * - reference to the destination array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function map(array: any[], f: Function): any[] {\n var result = [];\n for (var i = 0; i < array.length; i++) {\n result.push(f(array[i], i, array, result));\n }\n return result;\n}\n\n/** Maps all elements of the object and returns the result.\n *\n * Function f gets 4 arguments passed:\n * - element from the object\n * - key of the element\n * - reference to the source object\n * - reference to the destination object\n *\n * @param {Object} object\n * @param {Function} f\n */\nexport function mapObject(object: any, f: Function): any {\n var result = {};\n objectApply(object, function(value, key) {\n result[key] = f(value);\n });\n return result;\n}\n\n/** Filters elements of the array using a test function.\n *\n * Function test gets 4 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n * - reference to the destination array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function filter(array: any[], test: Function): any[] {\n test =\n test ||\n function(value) {\n return !!value;\n };\n\n var result = [];\n for (var i = 0; i < array.length; i++) {\n if (test(array[i], i, array, result)) {\n result.push(array[i]);\n }\n }\n return result;\n}\n\n/** Filters properties of the object using a test function.\n *\n * Function test gets 4 arguments passed:\n * - element from the object\n * - key of the element\n * - reference to the source object\n * - reference to the destination object\n *\n * @param {Object} object\n * @param {Function} f\n */\nexport function filterObject(object: Object, test: Function) {\n var result = {};\n objectApply(object, function(value, key) {\n if ((test && test(value, key, object, result)) || Boolean(value)) {\n result[key] = value;\n }\n });\n return result;\n}\n\n/** Flattens an object into a two-dimensional array.\n *\n * @param {Object} object\n * @return {Array} resulting array of [key, value] pairs\n */\nexport function flatten(object: Object): any[] {\n var result = [];\n objectApply(object, function(value, key) {\n result.push([key, value]);\n });\n return result;\n}\n\n/** Checks whether any element of the array passes the test.\n *\n * Function test gets 3 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function any(array: any[], test: Function): boolean {\n for (var i = 0; i < array.length; i++) {\n if (test(array[i], i, array)) {\n return true;\n }\n }\n return false;\n}\n\n/** Checks whether all elements of the array pass the test.\n *\n * Function test gets 3 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function all(array: any[], test: Function): boolean {\n for (var i = 0; i < array.length; i++) {\n if (!test(array[i], i, array)) {\n return false;\n }\n }\n return true;\n}\n\nexport function encodeParamsObject(data): string {\n return mapObject(data, function(value) {\n if (typeof value === 'object') {\n value = safeJSONStringify(value);\n }\n return encodeURIComponent(base64encode(value.toString()));\n });\n}\n\nexport function buildQueryString(data: any): string {\n var params = filterObject(data, function(value) {\n return value !== undefined;\n });\n\n var query = map(\n flatten(encodeParamsObject(params)),\n Util.method('join', '=')\n ).join('&');\n\n return query;\n}\n\n/**\n * See https://github.com/douglascrockford/JSON-js/blob/master/cycle.js\n *\n * Remove circular references from an object. Required for JSON.stringify in\n * React Native, which tends to blow up a lot.\n *\n * @param {any} object\n * @return {any} Decycled object\n */\nexport function decycleObject(object: any): any {\n var objects = [],\n paths = [];\n\n return (function derez(value, path) {\n var i, name, nu;\n\n switch (typeof value) {\n case 'object':\n if (!value) {\n return null;\n }\n for (i = 0; i < objects.length; i += 1) {\n if (objects[i] === value) {\n return { $ref: paths[i] };\n }\n }\n\n objects.push(value);\n paths.push(path);\n\n if (Object.prototype.toString.apply(value) === '[object Array]') {\n nu = [];\n for (i = 0; i < value.length; i += 1) {\n nu[i] = derez(value[i], path + '[' + i + ']');\n }\n } else {\n nu = {};\n for (name in value) {\n if (Object.prototype.hasOwnProperty.call(value, name)) {\n nu[name] = derez(\n value[name],\n path + '[' + JSON.stringify(name) + ']'\n );\n }\n }\n }\n return nu;\n case 'number':\n case 'string':\n case 'boolean':\n return value;\n }\n })(object, '$');\n}\n\n/**\n * Provides a cross-browser and cross-platform way to safely stringify objects\n * into JSON. This is particularly necessary for ReactNative, where circular JSON\n * structures throw an exception.\n *\n * @param {any} source The object to stringify\n * @return {string} The serialized output.\n */\nexport function safeJSONStringify(source: any): string {\n try {\n return JSON.stringify(source);\n } catch (e) {\n return JSON.stringify(decycleObject(source));\n }\n}\n","import { stringify } from './utils/collections';\nimport Pusher from './pusher';\n\nclass Logger {\n debug(...args: any[]) {\n this.log(this.globalLog, args);\n }\n\n warn(...args: any[]) {\n this.log(this.globalLogWarn, args);\n }\n\n error(...args: any[]) {\n this.log(this.globalLogError, args);\n }\n\n private globalLog = (message: string) => {\n if (global.console && global.console.log) {\n global.console.log(message);\n }\n };\n\n private globalLogWarn(message: string) {\n if (global.console && global.console.warn) {\n global.console.warn(message);\n } else {\n this.globalLog(message);\n }\n }\n\n private globalLogError(message: string) {\n if (global.console && global.console.error) {\n global.console.error(message);\n } else {\n this.globalLogWarn(message);\n }\n }\n\n private log(\n defaultLoggingFunction: (message: string) => void,\n ...args: any[]\n ) {\n var message = stringify.apply(this, arguments);\n if (Pusher.log) {\n Pusher.log(message);\n } else if (Pusher.logToConsole) {\n const log = defaultLoggingFunction.bind(this);\n log(message);\n }\n }\n}\n\nexport default new Logger();\n","import Browser from '../browser';\nimport Logger from 'core/logger';\nimport JSONPRequest from '../dom/jsonp_request';\nimport { ScriptReceivers } from '../dom/script_receiver_factory';\nimport { AuthTransport } from 'core/auth/auth_transports';\nimport {\n AuthRequestType,\n AuthTransportCallback,\n InternalAuthOptions\n} from 'core/auth/options';\n\nvar jsonp: AuthTransport = function(\n context: Browser,\n query: string,\n authOptions: InternalAuthOptions,\n authRequestType: AuthRequestType,\n callback: AuthTransportCallback\n) {\n if (\n authOptions.headers !== undefined ||\n authOptions.headersProvider != null\n ) {\n Logger.warn(\n `To send headers with the ${authRequestType.toString()} request, you must use AJAX, rather than JSONP.`\n );\n }\n\n var callbackName = context.nextAuthCallbackID.toString();\n context.nextAuthCallbackID++;\n\n var document = context.getDocument();\n var script = document.createElement('script');\n // Hacked wrapper.\n context.auth_callbacks[callbackName] = function(data) {\n callback(null, data);\n };\n\n var callback_name = \"Pusher.auth_callbacks['\" + callbackName + \"']\";\n script.src =\n authOptions.endpoint +\n '?callback=' +\n encodeURIComponent(callback_name) +\n '&' +\n query;\n\n var head =\n document.getElementsByTagName('head')[0] || document.documentElement;\n head.insertBefore(script, head.firstChild);\n};\n\nexport default jsonp;\n","import ScriptReceiver from './script_receiver';\n\n/** Sends a generic HTTP GET request using a script tag.\n *\n * By constructing URL in a specific way, it can be used for loading\n * JavaScript resources or JSONP requests. It can notify about errors, but\n * only in certain environments. Please take care of monitoring the state of\n * the request yourself.\n *\n * @param {String} src\n */\nexport default class ScriptRequest {\n src: string;\n script: any;\n errorScript: any;\n\n constructor(src: string) {\n this.src = src;\n }\n\n send(receiver: ScriptReceiver) {\n var self = this;\n var errorString = 'Error loading ' + self.src;\n\n self.script = document.createElement('script');\n self.script.id = receiver.id;\n self.script.src = self.src;\n self.script.type = 'text/javascript';\n self.script.charset = 'UTF-8';\n\n if (self.script.addEventListener) {\n self.script.onerror = function() {\n receiver.callback(errorString);\n };\n self.script.onload = function() {\n receiver.callback(null);\n };\n } else {\n self.script.onreadystatechange = function() {\n if (\n self.script.readyState === 'loaded' ||\n self.script.readyState === 'complete'\n ) {\n receiver.callback(null);\n }\n };\n }\n\n // Opera<11.6 hack for missing onerror callback\n if (\n self.script.async === undefined &&\n (document).attachEvent &&\n /opera/i.test(navigator.userAgent)\n ) {\n self.errorScript = document.createElement('script');\n self.errorScript.id = receiver.id + '_error';\n self.errorScript.text = receiver.name + \"('\" + errorString + \"');\";\n self.script.async = self.errorScript.async = false;\n } else {\n self.script.async = true;\n }\n\n var head = document.getElementsByTagName('head')[0];\n head.insertBefore(self.script, head.firstChild);\n if (self.errorScript) {\n head.insertBefore(self.errorScript, self.script.nextSibling);\n }\n }\n\n /** Cleans up the DOM remains of the script request. */\n cleanup() {\n if (this.script) {\n this.script.onload = this.script.onerror = null;\n this.script.onreadystatechange = null;\n }\n if (this.script && this.script.parentNode) {\n this.script.parentNode.removeChild(this.script);\n }\n if (this.errorScript && this.errorScript.parentNode) {\n this.errorScript.parentNode.removeChild(this.errorScript);\n }\n this.script = null;\n this.errorScript = null;\n }\n}\n","import ScriptReceiver from './script_receiver';\nimport ScriptRequest from './script_request';\nimport * as Collections from 'core/utils/collections';\nimport Util from 'core/util';\nimport Runtime from '../runtime';\n\n/** Sends data via JSONP.\n *\n * Data is a key-value map. Its values are JSON-encoded and then passed\n * through base64. Finally, keys and encoded values are appended to the query\n * string.\n *\n * The class itself does not guarantee raising errors on failures, as it's not\n * possible to support such feature on all browsers. Instead, JSONP endpoint\n * should call back in a way that's easy to distinguish from browser calls,\n * for example by passing a second argument to the receiver.\n *\n * @param {String} url\n * @param {Object} data key-value map of data to be submitted\n */\nexport default class JSONPRequest {\n url: string;\n data: any;\n request: ScriptRequest;\n\n constructor(url: string, data: any) {\n this.url = url;\n this.data = data;\n }\n\n /** Sends the actual JSONP request.\n *\n * @param {ScriptReceiver} receiver\n */\n send(receiver: ScriptReceiver) {\n if (this.request) {\n return;\n }\n\n var query = Collections.buildQueryString(this.data);\n var url = this.url + '/' + receiver.number + '?' + query;\n this.request = Runtime.createScriptRequest(url);\n this.request.send(receiver);\n }\n\n /** Cleans up the DOM remains of the JSONP request. */\n cleanup() {\n if (this.request) {\n this.request.cleanup();\n }\n }\n}\n","import TimelineSender from 'core/timeline/timeline_sender';\nimport TimelineTransport from 'core/timeline/timeline_transport';\nimport Browser from 'runtime';\nimport { AuthTransport } from 'core/auth/auth_transports';\nimport { ScriptReceivers } from '../dom/script_receiver_factory';\n\nvar getAgent = function(sender: TimelineSender, useTLS: boolean) {\n return function(data: any, callback: Function) {\n var scheme = 'http' + (useTLS ? 's' : '') + '://';\n var url =\n scheme + (sender.host || sender.options.host) + sender.options.path;\n var request = Browser.createJSONPRequest(url, data);\n\n var receiver = Browser.ScriptReceivers.create(function(error, result) {\n ScriptReceivers.remove(receiver);\n request.cleanup();\n\n if (result && result.host) {\n sender.host = result.host;\n }\n if (callback) {\n callback(error, result);\n }\n });\n request.send(receiver);\n };\n};\n\nvar jsonp = {\n name: 'jsonp',\n getAgent\n};\n\nexport default jsonp;\n","import Defaults from '../defaults';\nimport { default as URLScheme, URLSchemeParams } from './url_scheme';\n\nfunction getGenericURL(\n baseScheme: string,\n params: URLSchemeParams,\n path: string\n): string {\n var scheme = baseScheme + (params.useTLS ? 's' : '');\n var host = params.useTLS ? params.hostTLS : params.hostNonTLS;\n return scheme + '://' + host + path;\n}\n\nfunction getGenericPath(key: string, queryString?: string): string {\n var path = '/app/' + key;\n var query =\n '?protocol=' +\n Defaults.PROTOCOL +\n '&client=js' +\n '&version=' +\n Defaults.VERSION +\n (queryString ? '&' + queryString : '');\n return path + query;\n}\n\nexport var ws: URLScheme = {\n getInitial: function(key: string, params: URLSchemeParams): string {\n var path = (params.httpPath || '') + getGenericPath(key, 'flash=false');\n return getGenericURL('ws', params, path);\n }\n};\n\nexport var http: URLScheme = {\n getInitial: function(key: string, params: URLSchemeParams): string {\n var path = (params.httpPath || '/pusher') + getGenericPath(key);\n return getGenericURL('http', params, path);\n }\n};\n\nexport var sockjs: URLScheme = {\n getInitial: function(key: string, params: URLSchemeParams): string {\n return getGenericURL('http', params, params.httpPath || '/pusher');\n },\n getPath: function(key: string, params: URLSchemeParams): string {\n return getGenericPath(key);\n }\n};\n","import Callback from './callback';\nimport * as Collections from '../utils/collections';\nimport CallbackTable from './callback_table';\n\nexport default class CallbackRegistry {\n _callbacks: CallbackTable;\n\n constructor() {\n this._callbacks = {};\n }\n\n get(name: string): Callback[] {\n return this._callbacks[prefix(name)];\n }\n\n add(name: string, callback: Function, context: any) {\n var prefixedEventName = prefix(name);\n this._callbacks[prefixedEventName] =\n this._callbacks[prefixedEventName] || [];\n this._callbacks[prefixedEventName].push({\n fn: callback,\n context: context\n });\n }\n\n remove(name?: string, callback?: Function, context?: any) {\n if (!name && !callback && !context) {\n this._callbacks = {};\n return;\n }\n\n var names = name ? [prefix(name)] : Collections.keys(this._callbacks);\n\n if (callback || context) {\n this.removeCallback(names, callback, context);\n } else {\n this.removeAllCallbacks(names);\n }\n }\n\n private removeCallback(names: string[], callback: Function, context: any) {\n Collections.apply(\n names,\n function(name) {\n this._callbacks[name] = Collections.filter(\n this._callbacks[name] || [],\n function(binding) {\n return (\n (callback && callback !== binding.fn) ||\n (context && context !== binding.context)\n );\n }\n );\n if (this._callbacks[name].length === 0) {\n delete this._callbacks[name];\n }\n },\n this\n );\n }\n\n private removeAllCallbacks(names: string[]) {\n Collections.apply(\n names,\n function(name) {\n delete this._callbacks[name];\n },\n this\n );\n }\n}\n\nfunction prefix(name: string): string {\n return '_' + name;\n}\n","import * as Collections from '../utils/collections';\nimport Callback from './callback';\nimport Metadata from '../channels/metadata';\nimport CallbackRegistry from './callback_registry';\n\n/** Manages callback bindings and event emitting.\n *\n * @param Function failThrough called when no listeners are bound to an event\n */\nexport default class Dispatcher {\n callbacks: CallbackRegistry;\n global_callbacks: Function[];\n failThrough: Function;\n\n constructor(failThrough?: Function) {\n this.callbacks = new CallbackRegistry();\n this.global_callbacks = [];\n this.failThrough = failThrough;\n }\n\n bind(eventName: string, callback: Function, context?: any) {\n this.callbacks.add(eventName, callback, context);\n return this;\n }\n\n bind_global(callback: Function) {\n this.global_callbacks.push(callback);\n return this;\n }\n\n unbind(eventName?: string, callback?: Function, context?: any) {\n this.callbacks.remove(eventName, callback, context);\n return this;\n }\n\n unbind_global(callback?: Function) {\n if (!callback) {\n this.global_callbacks = [];\n return this;\n }\n\n this.global_callbacks = Collections.filter(\n this.global_callbacks || [],\n c => c !== callback\n );\n\n return this;\n }\n\n unbind_all() {\n this.unbind();\n this.unbind_global();\n return this;\n }\n\n emit(eventName: string, data?: any, metadata?: Metadata): Dispatcher {\n for (var i = 0; i < this.global_callbacks.length; i++) {\n this.global_callbacks[i](eventName, data);\n }\n\n var callbacks = this.callbacks.get(eventName);\n var args = [];\n\n if (metadata) {\n // if there's a metadata argument, we need to call the callback with both\n // data and metadata regardless of whether data is undefined\n args.push(data, metadata);\n } else if (data) {\n // metadata is undefined, so we only need to call the callback with data\n // if data exists\n args.push(data);\n }\n\n if (callbacks && callbacks.length > 0) {\n for (var i = 0; i < callbacks.length; i++) {\n callbacks[i].fn.apply(callbacks[i].context || global, args);\n }\n } else if (this.failThrough) {\n this.failThrough(eventName, data);\n }\n\n return this;\n }\n}\n","import Util from '../util';\nimport * as Collections from '../utils/collections';\nimport { default as EventsDispatcher } from '../events/dispatcher';\nimport Logger from '../logger';\nimport TransportHooks from './transport_hooks';\nimport Socket from '../socket';\nimport Runtime from 'runtime';\nimport Timeline from '../timeline/timeline';\nimport TransportConnectionOptions from './transport_connection_options';\n\n/** Provides universal API for transport connections.\n *\n * Transport connection is a low-level object that wraps a connection method\n * and exposes a simple evented interface for the connection state and\n * messaging. It does not implement Pusher-specific WebSocket protocol.\n *\n * Additionally, it fetches resources needed for transport to work and exposes\n * an interface for querying transport features.\n *\n * States:\n * - new - initial state after constructing the object\n * - initializing - during initialization phase, usually fetching resources\n * - intialized - ready to establish a connection\n * - connection - when connection is being established\n * - open - when connection ready to be used\n * - closed - after connection was closed be either side\n *\n * Emits:\n * - error - after the connection raised an error\n *\n * Options:\n * - useTLS - whether connection should be over TLS\n * - hostTLS - host to connect to when connection is over TLS\n * - hostNonTLS - host to connect to when connection is over TLS\n *\n * @param {String} key application key\n * @param {Object} options\n */\nexport default class TransportConnection extends EventsDispatcher {\n hooks: TransportHooks;\n name: string;\n priority: number;\n key: string;\n options: TransportConnectionOptions;\n state: string;\n timeline: Timeline;\n activityTimeout: number;\n id: number;\n socket: Socket;\n beforeOpen: Function;\n initialize: Function;\n\n constructor(\n hooks: TransportHooks,\n name: string,\n priority: number,\n key: string,\n options: TransportConnectionOptions\n ) {\n super();\n this.initialize = Runtime.transportConnectionInitializer;\n this.hooks = hooks;\n this.name = name;\n this.priority = priority;\n this.key = key;\n this.options = options;\n\n this.state = 'new';\n this.timeline = options.timeline;\n this.activityTimeout = options.activityTimeout;\n this.id = this.timeline.generateUniqueID();\n }\n\n /** Checks whether the transport handles activity checks by itself.\n *\n * @return {Boolean}\n */\n handlesActivityChecks(): boolean {\n return Boolean(this.hooks.handlesActivityChecks);\n }\n\n /** Checks whether the transport supports the ping/pong API.\n *\n * @return {Boolean}\n */\n supportsPing(): boolean {\n return Boolean(this.hooks.supportsPing);\n }\n\n /** Tries to establish a connection.\n *\n * @returns {Boolean} false if transport is in invalid state\n */\n connect(): boolean {\n if (this.socket || this.state !== 'initialized') {\n return false;\n }\n\n var url = this.hooks.urls.getInitial(this.key, this.options);\n try {\n this.socket = this.hooks.getSocket(url, this.options);\n } catch (e) {\n Util.defer(() => {\n this.onError(e);\n this.changeState('closed');\n });\n return false;\n }\n\n this.bindListeners();\n\n Logger.debug('Connecting', { transport: this.name, url });\n this.changeState('connecting');\n return true;\n }\n\n /** Closes the connection.\n *\n * @return {Boolean} true if there was a connection to close\n */\n close(): boolean {\n if (this.socket) {\n this.socket.close();\n return true;\n } else {\n return false;\n }\n }\n\n /** Sends data over the open connection.\n *\n * @param {String} data\n * @return {Boolean} true only when in the \"open\" state\n */\n send(data: any): boolean {\n if (this.state === 'open') {\n // Workaround for MobileSafari bug (see https://gist.github.com/2052006)\n Util.defer(() => {\n if (this.socket) {\n this.socket.send(data);\n }\n });\n return true;\n } else {\n return false;\n }\n }\n\n /** Sends a ping if the connection is open and transport supports it. */\n ping() {\n if (this.state === 'open' && this.supportsPing()) {\n this.socket.ping();\n }\n }\n\n private onOpen() {\n if (this.hooks.beforeOpen) {\n this.hooks.beforeOpen(\n this.socket,\n this.hooks.urls.getPath(this.key, this.options)\n );\n }\n this.changeState('open');\n this.socket.onopen = undefined;\n }\n\n private onError(error) {\n this.emit('error', { type: 'WebSocketError', error: error });\n this.timeline.error(this.buildTimelineMessage({ error: error.toString() }));\n }\n\n private onClose(closeEvent?: any) {\n if (closeEvent) {\n this.changeState('closed', {\n code: closeEvent.code,\n reason: closeEvent.reason,\n wasClean: closeEvent.wasClean\n });\n } else {\n this.changeState('closed');\n }\n this.unbindListeners();\n this.socket = undefined;\n }\n\n private onMessage(message) {\n this.emit('message', message);\n }\n\n private onActivity() {\n this.emit('activity');\n }\n\n private bindListeners() {\n this.socket.onopen = () => {\n this.onOpen();\n };\n this.socket.onerror = error => {\n this.onError(error);\n };\n this.socket.onclose = closeEvent => {\n this.onClose(closeEvent);\n };\n this.socket.onmessage = message => {\n this.onMessage(message);\n };\n\n if (this.supportsPing()) {\n this.socket.onactivity = () => {\n this.onActivity();\n };\n }\n }\n\n private unbindListeners() {\n if (this.socket) {\n this.socket.onopen = undefined;\n this.socket.onerror = undefined;\n this.socket.onclose = undefined;\n this.socket.onmessage = undefined;\n if (this.supportsPing()) {\n this.socket.onactivity = undefined;\n }\n }\n }\n\n private changeState(state: string, params?: any) {\n this.state = state;\n this.timeline.info(\n this.buildTimelineMessage({\n state: state,\n params: params\n })\n );\n this.emit(state, params);\n }\n\n buildTimelineMessage(message): any {\n return Collections.extend({ cid: this.id }, message);\n }\n}\n","import Factory from '../utils/factory';\nimport TransportHooks from './transport_hooks';\nimport TransportConnection from './transport_connection';\nimport TransportConnectionOptions from './transport_connection_options';\n\n/** Provides interface for transport connection instantiation.\n *\n * Takes transport-specific hooks as the only argument, which allow checking\n * for transport support and creating its connections.\n *\n * Supported hooks: * - file - the name of the file to be fetched during initialization\n * - urls - URL scheme to be used by transport\n * - handlesActivityCheck - true when the transport handles activity checks\n * - supportsPing - true when the transport has a ping/activity API\n * - isSupported - tells whether the transport is supported in the environment\n * - getSocket - creates a WebSocket-compatible transport socket\n *\n * See transports.js for specific implementations.\n *\n * @param {Object} hooks object containing all needed transport hooks\n */\nexport default class Transport {\n hooks: TransportHooks;\n\n constructor(hooks: TransportHooks) {\n this.hooks = hooks;\n }\n\n /** Returns whether the transport is supported in the environment.\n *\n * @param {Object} envronment te environment details (encryption, settings)\n * @returns {Boolean} true when the transport is supported\n */\n isSupported(environment: any): boolean {\n return this.hooks.isSupported(environment);\n }\n\n /** Creates a transport connection.\n *\n * @param {String} name\n * @param {Number} priority\n * @param {String} key the application key\n * @param {Object} options\n * @returns {TransportConnection}\n */\n createConnection(\n name: string,\n priority: number,\n key: string,\n options: any\n ): TransportConnection {\n return new TransportConnection(this.hooks, name, priority, key, options);\n }\n}\n","import * as URLSchemes from 'core/transports/url_schemes';\nimport URLScheme from 'core/transports/url_scheme';\nimport Transport from 'core/transports/transport';\nimport Util from 'core/util';\nimport * as Collections from 'core/utils/collections';\nimport TransportHooks from 'core/transports/transport_hooks';\nimport TransportsTable from 'core/transports/transports_table';\nimport Runtime from 'runtime';\n\n/** WebSocket transport.\n *\n * Uses native WebSocket implementation, including MozWebSocket supported by\n * earlier Firefox versions.\n */\nvar WSTransport = new Transport({\n urls: URLSchemes.ws,\n handlesActivityChecks: false,\n supportsPing: false,\n\n isInitialized: function() {\n return Boolean(Runtime.getWebSocketAPI());\n },\n isSupported: function(): boolean {\n return Boolean(Runtime.getWebSocketAPI());\n },\n getSocket: function(url) {\n return Runtime.createWebSocket(url);\n }\n});\n\nvar httpConfiguration = {\n urls: URLSchemes.http,\n handlesActivityChecks: false,\n supportsPing: true,\n isInitialized: function() {\n return true;\n }\n};\n\nexport var streamingConfiguration = Collections.extend(\n {\n getSocket: function(url) {\n return Runtime.HTTPFactory.createStreamingSocket(url);\n }\n },\n httpConfiguration\n);\nexport var pollingConfiguration = Collections.extend(\n {\n getSocket: function(url) {\n return Runtime.HTTPFactory.createPollingSocket(url);\n }\n },\n httpConfiguration\n);\n\nvar xhrConfiguration = {\n isSupported: function(): boolean {\n return Runtime.isXHRSupported();\n }\n};\n\n/** HTTP streaming transport using CORS-enabled XMLHttpRequest. */\nvar XHRStreamingTransport = new Transport(\n (\n Collections.extend({}, streamingConfiguration, xhrConfiguration)\n )\n);\n\n/** HTTP long-polling transport using CORS-enabled XMLHttpRequest. */\nvar XHRPollingTransport = new Transport(\n Collections.extend({}, pollingConfiguration, xhrConfiguration)\n);\n\nvar Transports: TransportsTable = {\n ws: WSTransport,\n xhr_streaming: XHRStreamingTransport,\n xhr_polling: XHRPollingTransport\n};\n\nexport default Transports;\n","import {\n default as Transports,\n streamingConfiguration,\n pollingConfiguration\n} from 'isomorphic/transports/transports';\nimport Transport from 'core/transports/transport';\nimport TransportHooks from 'core/transports/transport_hooks';\nimport * as URLSchemes from 'core/transports/url_schemes';\nimport Runtime from 'runtime';\nimport { Dependencies } from '../dom/dependencies';\nimport * as Collections from 'core/utils/collections';\n\nvar SockJSTransport = new Transport({\n file: 'sockjs',\n urls: URLSchemes.sockjs,\n handlesActivityChecks: true,\n supportsPing: false,\n\n isSupported: function() {\n return true;\n },\n isInitialized: function() {\n return window.SockJS !== undefined;\n },\n getSocket: function(url, options) {\n return new window.SockJS(url, null, {\n js_path: Dependencies.getPath('sockjs', {\n useTLS: options.useTLS\n }),\n ignore_null_origin: options.ignoreNullOrigin\n });\n },\n beforeOpen: function(socket, path) {\n socket.send(\n JSON.stringify({\n path: path\n })\n );\n }\n});\n\nvar xdrConfiguration = {\n isSupported: function(environment): boolean {\n var yes = Runtime.isXDRSupported(environment.useTLS);\n return yes;\n }\n};\n\n/** HTTP streaming transport using XDomainRequest (IE 8,9). */\nvar XDRStreamingTransport = new Transport(\n (\n Collections.extend({}, streamingConfiguration, xdrConfiguration)\n )\n);\n\n/** HTTP long-polling transport using XDomainRequest (IE 8,9). */\nvar XDRPollingTransport = new Transport(\n Collections.extend({}, pollingConfiguration, xdrConfiguration)\n);\n\nTransports.xdr_streaming = XDRStreamingTransport;\nTransports.xdr_polling = XDRPollingTransport;\nTransports.sockjs = SockJSTransport;\n\nexport default Transports;\n","import Reachability from 'core/reachability';\nimport { default as EventsDispatcher } from 'core/events/dispatcher';\n\n/** Really basic interface providing network availability info.\n *\n * Emits:\n * - online - when browser goes online\n * - offline - when browser goes offline\n */\nexport class NetInfo extends EventsDispatcher implements Reachability {\n constructor() {\n super();\n var self = this;\n // This is okay, as IE doesn't support this stuff anyway.\n if (window.addEventListener !== undefined) {\n window.addEventListener(\n 'online',\n function() {\n self.emit('online');\n },\n false\n );\n window.addEventListener(\n 'offline',\n function() {\n self.emit('offline');\n },\n false\n );\n }\n }\n\n /** Returns whether browser is online or not\n *\n * Offline means definitely offline (no connection to router).\n * Inverse does NOT mean definitely online (only currently supported in Safari\n * and even there only means the device has a connection to the router).\n *\n * @return {Boolean}\n */\n isOnline(): boolean {\n if (window.navigator.onLine === undefined) {\n return true;\n } else {\n return window.navigator.onLine;\n }\n }\n}\n\nexport var Network = new NetInfo();\n","import Util from '../util';\nimport * as Collections from '../utils/collections';\nimport TransportManager from './transport_manager';\nimport TransportConnection from './transport_connection';\nimport Transport from './transport';\nimport PingDelayOptions from './ping_delay_options';\n\n/** Creates transport connections monitored by a transport manager.\n *\n * When a transport is closed, it might mean the environment does not support\n * it. It's possible that messages get stuck in an intermediate buffer or\n * proxies terminate inactive connections. To combat these problems,\n * assistants monitor the connection lifetime, report unclean exits and\n * adjust ping timeouts to keep the connection active. The decision to disable\n * a transport is the manager's responsibility.\n *\n * @param {TransportManager} manager\n * @param {TransportConnection} transport\n * @param {Object} options\n */\nexport default class AssistantToTheTransportManager {\n manager: TransportManager;\n transport: Transport;\n minPingDelay: number;\n maxPingDelay: number;\n pingDelay: number;\n\n constructor(\n manager: TransportManager,\n transport: Transport,\n options: PingDelayOptions\n ) {\n this.manager = manager;\n this.transport = transport;\n this.minPingDelay = options.minPingDelay;\n this.maxPingDelay = options.maxPingDelay;\n this.pingDelay = undefined;\n }\n\n /** Creates a transport connection.\n *\n * This function has the same API as Transport#createConnection.\n *\n * @param {String} name\n * @param {Number} priority\n * @param {String} key the application key\n * @param {Object} options\n * @returns {TransportConnection}\n */\n createConnection(\n name: string,\n priority: number,\n key: string,\n options: Object\n ): TransportConnection {\n options = Collections.extend({}, options, {\n activityTimeout: this.pingDelay\n });\n var connection = this.transport.createConnection(\n name,\n priority,\n key,\n options\n );\n\n var openTimestamp = null;\n\n var onOpen = function() {\n connection.unbind('open', onOpen);\n connection.bind('closed', onClosed);\n openTimestamp = Util.now();\n };\n var onClosed = closeEvent => {\n connection.unbind('closed', onClosed);\n\n if (closeEvent.code === 1002 || closeEvent.code === 1003) {\n // we don't want to use transports not obeying the protocol\n this.manager.reportDeath();\n } else if (!closeEvent.wasClean && openTimestamp) {\n // report deaths only for short-living transport\n var lifespan = Util.now() - openTimestamp;\n if (lifespan < 2 * this.maxPingDelay) {\n this.manager.reportDeath();\n this.pingDelay = Math.max(lifespan / 2, this.minPingDelay);\n }\n }\n };\n\n connection.bind('open', onOpen);\n return connection;\n }\n\n /** Returns whether the transport is supported in the environment.\n *\n * This function has the same API as Transport#isSupported. Might return false\n * when the manager decides to kill the transport.\n *\n * @param {Object} environment the environment details (encryption, settings)\n * @returns {Boolean} true when the transport is supported\n */\n isSupported(environment: string): boolean {\n return this.manager.isAlive() && this.transport.isSupported(environment);\n }\n}\n","import Action from './action';\nimport { PusherEvent } from './message-types';\n/**\n * Provides functions for handling Pusher protocol-specific messages.\n */\n\nconst Protocol = {\n /**\n * Decodes a message in a Pusher format.\n *\n * The MessageEvent we receive from the transport should contain a pusher event\n * (https://pusher.com/docs/pusher_protocol#events) serialized as JSON in the\n * data field\n *\n * The pusher event may contain a data field too, and it may also be\n * serialised as JSON\n *\n * Throws errors when messages are not parse'able.\n *\n * @param {MessageEvent} messageEvent\n * @return {PusherEvent}\n */\n decodeMessage: function(messageEvent: MessageEvent): PusherEvent {\n try {\n var messageData = JSON.parse(messageEvent.data);\n var pusherEventData = messageData.data;\n if (typeof pusherEventData === 'string') {\n try {\n pusherEventData = JSON.parse(messageData.data);\n } catch (e) {}\n }\n var pusherEvent: PusherEvent = {\n event: messageData.event,\n channel: messageData.channel,\n data: pusherEventData\n };\n if (messageData.user_id) {\n pusherEvent.user_id = messageData.user_id;\n }\n return pusherEvent;\n } catch (e) {\n throw { type: 'MessageParseError', error: e, data: messageEvent.data };\n }\n },\n\n /**\n * Encodes a message to be sent.\n *\n * @param {PusherEvent} event\n * @return {String}\n */\n encodeMessage: function(event: PusherEvent): string {\n return JSON.stringify(event);\n },\n\n /**\n * Processes a handshake message and returns appropriate actions.\n *\n * Returns an object with an 'action' and other action-specific properties.\n *\n * There are three outcomes when calling this function. First is a successful\n * connection attempt, when pusher:connection_established is received, which\n * results in a 'connected' action with an 'id' property. When passed a\n * pusher:error event, it returns a result with action appropriate to the\n * close code and an error. Otherwise, it raises an exception.\n *\n * @param {String} message\n * @result Object\n */\n processHandshake: function(messageEvent: MessageEvent): Action {\n var message = Protocol.decodeMessage(messageEvent);\n\n if (message.event === 'pusher:connection_established') {\n if (!message.data.activity_timeout) {\n throw 'No activity timeout specified in handshake';\n }\n return {\n action: 'connected',\n id: message.data.socket_id,\n activityTimeout: message.data.activity_timeout * 1000\n };\n } else if (message.event === 'pusher:error') {\n // From protocol 6 close codes are sent only once, so this only\n // happens when connection does not support close codes\n return {\n action: this.getCloseAction(message.data),\n error: this.getCloseError(message.data)\n };\n } else {\n throw 'Invalid handshake';\n }\n },\n\n /**\n * Dispatches the close event and returns an appropriate action name.\n *\n * See:\n * 1. https://developer.mozilla.org/en-US/docs/WebSockets/WebSockets_reference/CloseEvent\n * 2. http://pusher.com/docs/pusher_protocol\n *\n * @param {CloseEvent} closeEvent\n * @return {String} close action name\n */\n getCloseAction: function(closeEvent): string {\n if (closeEvent.code < 4000) {\n // ignore 1000 CLOSE_NORMAL, 1001 CLOSE_GOING_AWAY,\n // 1005 CLOSE_NO_STATUS, 1006 CLOSE_ABNORMAL\n // ignore 1007...3999\n // handle 1002 CLOSE_PROTOCOL_ERROR, 1003 CLOSE_UNSUPPORTED,\n // 1004 CLOSE_TOO_LARGE\n if (closeEvent.code >= 1002 && closeEvent.code <= 1004) {\n return 'backoff';\n } else {\n return null;\n }\n } else if (closeEvent.code === 4000) {\n return 'tls_only';\n } else if (closeEvent.code < 4100) {\n return 'refused';\n } else if (closeEvent.code < 4200) {\n return 'backoff';\n } else if (closeEvent.code < 4300) {\n return 'retry';\n } else {\n // unknown error\n return 'refused';\n }\n },\n\n /**\n * Returns an error or null basing on the close event.\n *\n * Null is returned when connection was closed cleanly. Otherwise, an object\n * with error details is returned.\n *\n * @param {CloseEvent} closeEvent\n * @return {Object} error object\n */\n getCloseError: function(closeEvent): any {\n if (closeEvent.code !== 1000 && closeEvent.code !== 1001) {\n return {\n type: 'PusherError',\n data: {\n code: closeEvent.code,\n message: closeEvent.reason || closeEvent.message\n }\n };\n } else {\n return null;\n }\n }\n};\n\nexport default Protocol;\n","import * as Collections from '../utils/collections';\nimport { default as EventsDispatcher } from '../events/dispatcher';\nimport Protocol from './protocol/protocol';\nimport { PusherEvent } from './protocol/message-types';\nimport Logger from '../logger';\nimport TransportConnection from '../transports/transport_connection';\nimport Socket from '../socket';\n/**\n * Provides Pusher protocol interface for transports.\n *\n * Emits following events:\n * - message - on received messages\n * - ping - on ping requests\n * - pong - on pong responses\n * - error - when the transport emits an error\n * - closed - after closing the transport\n *\n * It also emits more events when connection closes with a code.\n * See Protocol.getCloseAction to get more details.\n *\n * @param {Number} id\n * @param {AbstractTransport} transport\n */\nexport default class Connection extends EventsDispatcher implements Socket {\n id: string;\n transport: TransportConnection;\n activityTimeout: number;\n\n constructor(id: string, transport: TransportConnection) {\n super();\n this.id = id;\n this.transport = transport;\n this.activityTimeout = transport.activityTimeout;\n this.bindListeners();\n }\n\n /** Returns whether used transport handles activity checks by itself\n *\n * @returns {Boolean} true if activity checks are handled by the transport\n */\n handlesActivityChecks() {\n return this.transport.handlesActivityChecks();\n }\n\n /** Sends raw data.\n *\n * @param {String} data\n */\n send(data: any): boolean {\n return this.transport.send(data);\n }\n\n /** Sends an event.\n *\n * @param {String} name\n * @param {String} data\n * @param {String} [channel]\n * @returns {Boolean} whether message was sent or not\n */\n send_event(name: string, data: any, channel?: string): boolean {\n var event: PusherEvent = { event: name, data: data };\n if (channel) {\n event.channel = channel;\n }\n Logger.debug('Event sent', event);\n return this.send(Protocol.encodeMessage(event));\n }\n\n /** Sends a ping message to the server.\n *\n * Basing on the underlying transport, it might send either transport's\n * protocol-specific ping or pusher:ping event.\n */\n ping() {\n if (this.transport.supportsPing()) {\n this.transport.ping();\n } else {\n this.send_event('pusher:ping', {});\n }\n }\n\n /** Closes the connection. */\n close() {\n this.transport.close();\n }\n\n private bindListeners() {\n var listeners = {\n message: (messageEvent: MessageEvent) => {\n var pusherEvent;\n try {\n pusherEvent = Protocol.decodeMessage(messageEvent);\n } catch (e) {\n this.emit('error', {\n type: 'MessageParseError',\n error: e,\n data: messageEvent.data\n });\n }\n\n if (pusherEvent !== undefined) {\n Logger.debug('Event recd', pusherEvent);\n\n switch (pusherEvent.event) {\n case 'pusher:error':\n this.emit('error', {\n type: 'PusherError',\n data: pusherEvent.data\n });\n break;\n case 'pusher:ping':\n this.emit('ping');\n break;\n case 'pusher:pong':\n this.emit('pong');\n break;\n }\n this.emit('message', pusherEvent);\n }\n },\n activity: () => {\n this.emit('activity');\n },\n error: error => {\n this.emit('error', error);\n },\n closed: closeEvent => {\n unbindListeners();\n\n if (closeEvent && closeEvent.code) {\n this.handleCloseEvent(closeEvent);\n }\n\n this.transport = null;\n this.emit('closed');\n }\n };\n\n var unbindListeners = () => {\n Collections.objectApply(listeners, (listener, event) => {\n this.transport.unbind(event, listener);\n });\n };\n\n Collections.objectApply(listeners, (listener, event) => {\n this.transport.bind(event, listener);\n });\n }\n\n private handleCloseEvent(closeEvent: any) {\n var action = Protocol.getCloseAction(closeEvent);\n var error = Protocol.getCloseError(closeEvent);\n if (error) {\n this.emit('error', error);\n }\n if (action) {\n this.emit(action, { action: action, error: error });\n }\n }\n}\n","import Util from '../../util';\nimport * as Collections from '../../utils/collections';\nimport Protocol from '../protocol/protocol';\nimport Connection from '../connection';\nimport TransportConnection from '../../transports/transport_connection';\nimport HandshakePayload from './handshake_payload';\n\n/**\n * Handles Pusher protocol handshakes for transports.\n *\n * Calls back with a result object after handshake is completed. Results\n * always have two fields:\n * - action - string describing action to be taken after the handshake\n * - transport - the transport object passed to the constructor\n *\n * Different actions can set different additional properties on the result.\n * In the case of 'connected' action, there will be a 'connection' property\n * containing a Connection object for the transport. Other actions should\n * carry an 'error' property.\n *\n * @param {AbstractTransport} transport\n * @param {Function} callback\n */\nexport default class Handshake {\n transport: TransportConnection;\n callback: (HandshakePayload) => void;\n onMessage: Function;\n onClosed: Function;\n\n constructor(\n transport: TransportConnection,\n callback: (HandshakePayload) => void\n ) {\n this.transport = transport;\n this.callback = callback;\n this.bindListeners();\n }\n\n close() {\n this.unbindListeners();\n this.transport.close();\n }\n\n private bindListeners() {\n this.onMessage = m => {\n this.unbindListeners();\n\n var result;\n try {\n result = Protocol.processHandshake(m);\n } catch (e) {\n this.finish('error', { error: e });\n this.transport.close();\n return;\n }\n\n if (result.action === 'connected') {\n this.finish('connected', {\n connection: new Connection(result.id, this.transport),\n activityTimeout: result.activityTimeout\n });\n } else {\n this.finish(result.action, { error: result.error });\n this.transport.close();\n }\n };\n\n this.onClosed = closeEvent => {\n this.unbindListeners();\n\n var action = Protocol.getCloseAction(closeEvent) || 'backoff';\n var error = Protocol.getCloseError(closeEvent);\n this.finish(action, { error: error });\n };\n\n this.transport.bind('message', this.onMessage);\n this.transport.bind('closed', this.onClosed);\n }\n\n private unbindListeners() {\n this.transport.unbind('message', this.onMessage);\n this.transport.unbind('closed', this.onClosed);\n }\n\n private finish(action: string, params: any) {\n this.callback(\n Collections.extend({ transport: this.transport, action: action }, params)\n );\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport base64encode from '../base64';\nimport Timeline from './timeline';\nimport Runtime from 'runtime';\n\nexport interface TimelineSenderOptions {\n host?: string;\n port?: number;\n path?: string;\n}\n\nexport default class TimelineSender {\n timeline: Timeline;\n options: TimelineSenderOptions;\n host: string;\n\n constructor(timeline: Timeline, options: TimelineSenderOptions) {\n this.timeline = timeline;\n this.options = options || {};\n }\n\n send(useTLS: boolean, callback?: Function) {\n if (this.timeline.isEmpty()) {\n return;\n }\n\n this.timeline.send(\n Runtime.TimelineTransport.getAgent(this, useTLS),\n callback\n );\n }\n}\n","import { default as EventsDispatcher } from '../events/dispatcher';\nimport * as Errors from '../errors';\nimport Logger from '../logger';\nimport Pusher from '../pusher';\nimport { PusherEvent } from '../connection/protocol/message-types';\nimport Metadata from './metadata';\nimport UrlStore from '../utils/url_store';\nimport {\n ChannelAuthorizationData,\n ChannelAuthorizationCallback\n} from '../auth/options';\nimport { HTTPAuthError } from '../errors';\n\n/** Provides base public channel interface with an event emitter.\n *\n * Emits:\n * - pusher:subscription_succeeded - after subscribing successfully\n * - other non-internal events\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\nexport default class Channel extends EventsDispatcher {\n name: string;\n pusher: Pusher;\n subscribed: boolean;\n subscriptionPending: boolean;\n subscriptionCancelled: boolean;\n subscriptionCount: null;\n\n constructor(name: string, pusher: Pusher) {\n super(function(event, data) {\n Logger.debug('No callbacks on ' + name + ' for ' + event);\n });\n\n this.name = name;\n this.pusher = pusher;\n this.subscribed = false;\n this.subscriptionPending = false;\n this.subscriptionCancelled = false;\n }\n\n /** Skips authorization, since public channels don't require it.\n *\n * @param {Function} callback\n */\n authorize(socketId: string, callback: ChannelAuthorizationCallback) {\n return callback(null, { auth: '' });\n }\n\n /** Triggers an event */\n trigger(event: string, data: any) {\n if (event.indexOf('client-') !== 0) {\n throw new Errors.BadEventName(\n \"Event '\" + event + \"' does not start with 'client-'\"\n );\n }\n if (!this.subscribed) {\n var suffix = UrlStore.buildLogSuffix('triggeringClientEvents');\n Logger.warn(\n `Client event triggered before channel 'subscription_succeeded' event . ${suffix}`\n );\n }\n return this.pusher.send_event(event, data, this.name);\n }\n\n /** Signals disconnection to the channel. For internal use only. */\n disconnect() {\n this.subscribed = false;\n this.subscriptionPending = false;\n }\n\n /** Handles a PusherEvent. For internal use only.\n *\n * @param {PusherEvent} event\n */\n handleEvent(event: PusherEvent) {\n var eventName = event.event;\n var data = event.data;\n if (eventName === 'pusher_internal:subscription_succeeded') {\n this.handleSubscriptionSucceededEvent(event);\n } else if (eventName === 'pusher_internal:subscription_count') {\n this.handleSubscriptionCountEvent(event);\n } else if (eventName.indexOf('pusher_internal:') !== 0) {\n var metadata: Metadata = {};\n this.emit(eventName, data, metadata);\n }\n }\n\n handleSubscriptionSucceededEvent(event: PusherEvent) {\n this.subscriptionPending = false;\n this.subscribed = true;\n if (this.subscriptionCancelled) {\n this.pusher.unsubscribe(this.name);\n } else {\n this.emit('pusher:subscription_succeeded', event.data);\n }\n }\n\n handleSubscriptionCountEvent(event: PusherEvent) {\n if (event.data.subscription_count) {\n this.subscriptionCount = event.data.subscription_count;\n }\n\n this.emit('pusher:subscription_count', event.data);\n }\n\n /** Sends a subscription request. For internal use only. */\n subscribe() {\n if (this.subscribed) {\n return;\n }\n this.subscriptionPending = true;\n this.subscriptionCancelled = false;\n this.authorize(\n this.pusher.connection.socket_id,\n (error: Error | null, data: ChannelAuthorizationData) => {\n if (error) {\n this.subscriptionPending = false;\n // Why not bind to 'pusher:subscription_error' a level up, and log there?\n // Binding to this event would cause the warning about no callbacks being\n // bound (see constructor) to be suppressed, that's not what we want.\n Logger.error(error.toString());\n this.emit(\n 'pusher:subscription_error',\n Object.assign(\n {},\n {\n type: 'AuthError',\n error: error.message\n },\n error instanceof HTTPAuthError ? { status: error.status } : {}\n )\n );\n } else {\n this.pusher.send_event('pusher:subscribe', {\n auth: data.auth,\n channel_data: data.channel_data,\n channel: this.name\n });\n }\n }\n );\n }\n\n /** Sends an unsubscription request. For internal use only. */\n unsubscribe() {\n this.subscribed = false;\n this.pusher.send_event('pusher:unsubscribe', {\n channel: this.name\n });\n }\n\n /** Cancels an in progress subscription. For internal use only. */\n cancelSubscription() {\n this.subscriptionCancelled = true;\n }\n\n /** Reinstates an in progress subscripiton. For internal use only. */\n reinstateSubscription() {\n this.subscriptionCancelled = false;\n }\n}\n","import Factory from '../utils/factory';\nimport Channel from './channel';\nimport { ChannelAuthorizationCallback } from '../auth/options';\n\n/** Extends public channels to provide private channel interface.\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\nexport default class PrivateChannel extends Channel {\n /** Authorizes the connection to use the channel.\n *\n * @param {String} socketId\n * @param {Function} callback\n */\n authorize(socketId: string, callback: ChannelAuthorizationCallback) {\n return this.pusher.config.channelAuthorizer(\n {\n channelName: this.name,\n socketId: socketId\n },\n callback\n );\n }\n}\n","import * as Collections from '../utils/collections';\n\n/** Represents a collection of members of a presence channel. */\nexport default class Members {\n members: any;\n count: number;\n myID: any;\n me: any;\n\n constructor() {\n this.reset();\n }\n\n /** Returns member's info for given id.\n *\n * Resulting object containts two fields - id and info.\n *\n * @param {Number} id\n * @return {Object} member's info or null\n */\n get(id: string): any {\n if (Object.prototype.hasOwnProperty.call(this.members, id)) {\n return {\n id: id,\n info: this.members[id]\n };\n } else {\n return null;\n }\n }\n\n /** Calls back for each member in unspecified order.\n *\n * @param {Function} callback\n */\n each(callback: Function) {\n Collections.objectApply(this.members, (member, id) => {\n callback(this.get(id));\n });\n }\n\n /** Updates the id for connected member. For internal use only. */\n setMyID(id: string) {\n this.myID = id;\n }\n\n /** Handles subscription data. For internal use only. */\n onSubscription(subscriptionData: any) {\n this.members = subscriptionData.presence.hash;\n this.count = subscriptionData.presence.count;\n this.me = this.get(this.myID);\n }\n\n /** Adds a new member to the collection. For internal use only. */\n addMember(memberData: any) {\n if (this.get(memberData.user_id) === null) {\n this.count++;\n }\n this.members[memberData.user_id] = memberData.user_info;\n return this.get(memberData.user_id);\n }\n\n /** Adds a member from the collection. For internal use only. */\n removeMember(memberData: any) {\n var member = this.get(memberData.user_id);\n if (member) {\n delete this.members[memberData.user_id];\n this.count--;\n }\n return member;\n }\n\n /** Resets the collection to the initial state. For internal use only. */\n reset() {\n this.members = {};\n this.count = 0;\n this.myID = null;\n this.me = null;\n }\n}\n","import PrivateChannel from './private_channel';\nimport Logger from '../logger';\nimport Members from './members';\nimport Pusher from '../pusher';\nimport UrlStore from 'core/utils/url_store';\nimport { PusherEvent } from '../connection/protocol/message-types';\nimport Metadata from './metadata';\nimport { ChannelAuthorizationData } from '../auth/options';\n\nexport default class PresenceChannel extends PrivateChannel {\n members: Members;\n\n /** Adds presence channel functionality to private channels.\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\n constructor(name: string, pusher: Pusher) {\n super(name, pusher);\n this.members = new Members();\n }\n\n /** Authorizes the connection as a member of the channel.\n *\n * @param {String} socketId\n * @param {Function} callback\n */\n authorize(socketId: string, callback: Function) {\n super.authorize(socketId, async (error, authData) => {\n if (!error) {\n authData = authData as ChannelAuthorizationData;\n if (authData.channel_data != null) {\n var channelData = JSON.parse(authData.channel_data);\n this.members.setMyID(channelData.user_id);\n } else {\n await this.pusher.user.signinDonePromise;\n if (this.pusher.user.user_data != null) {\n // If the user is signed in, get the id of the authenticated user\n // and allow the presence authorization to continue.\n this.members.setMyID(this.pusher.user.user_data.id);\n } else {\n let suffix = UrlStore.buildLogSuffix('authorizationEndpoint');\n Logger.error(\n `Invalid auth response for channel '${this.name}', ` +\n `expected 'channel_data' field. ${suffix}, ` +\n `or the user should be signed in.`\n );\n callback('Invalid auth response');\n return;\n }\n }\n }\n callback(error, authData);\n });\n }\n\n /** Handles presence and subscription events. For internal use only.\n *\n * @param {PusherEvent} event\n */\n handleEvent(event: PusherEvent) {\n var eventName = event.event;\n if (eventName.indexOf('pusher_internal:') === 0) {\n this.handleInternalEvent(event);\n } else {\n var data = event.data;\n var metadata: Metadata = {};\n if (event.user_id) {\n metadata.user_id = event.user_id;\n }\n this.emit(eventName, data, metadata);\n }\n }\n handleInternalEvent(event: PusherEvent) {\n var eventName = event.event;\n var data = event.data;\n switch (eventName) {\n case 'pusher_internal:subscription_succeeded':\n this.handleSubscriptionSucceededEvent(event);\n break;\n case 'pusher_internal:subscription_count':\n this.handleSubscriptionCountEvent(event);\n break;\n case 'pusher_internal:member_added':\n var addedMember = this.members.addMember(data);\n this.emit('pusher:member_added', addedMember);\n break;\n case 'pusher_internal:member_removed':\n var removedMember = this.members.removeMember(data);\n if (removedMember) {\n this.emit('pusher:member_removed', removedMember);\n }\n break;\n }\n }\n\n handleSubscriptionSucceededEvent(event: PusherEvent) {\n this.subscriptionPending = false;\n this.subscribed = true;\n if (this.subscriptionCancelled) {\n this.pusher.unsubscribe(this.name);\n } else {\n this.members.onSubscription(event.data);\n this.emit('pusher:subscription_succeeded', this.members);\n }\n }\n\n /** Resets the channel state, including members map. For internal use only. */\n disconnect() {\n this.members.reset();\n super.disconnect();\n }\n}\n","import PrivateChannel from './private_channel';\nimport * as Errors from '../errors';\nimport Logger from '../logger';\nimport Pusher from '../pusher';\nimport { decode as encodeUTF8 } from '@stablelib/utf8';\nimport { decode as decodeBase64 } from '@stablelib/base64';\nimport Dispatcher from '../events/dispatcher';\nimport { PusherEvent } from '../connection/protocol/message-types';\nimport {\n ChannelAuthorizationData,\n ChannelAuthorizationCallback\n} from '../auth/options';\nimport * as nacl from 'tweetnacl';\n\n/** Extends private channels to provide encrypted channel interface.\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\nexport default class EncryptedChannel extends PrivateChannel {\n key: Uint8Array = null;\n nacl: nacl;\n\n constructor(name: string, pusher: Pusher, nacl: nacl) {\n super(name, pusher);\n this.nacl = nacl;\n }\n\n /** Authorizes the connection to use the channel.\n *\n * @param {String} socketId\n * @param {Function} callback\n */\n authorize(socketId: string, callback: ChannelAuthorizationCallback) {\n super.authorize(\n socketId,\n (error: Error | null, authData: ChannelAuthorizationData) => {\n if (error) {\n callback(error, authData);\n return;\n }\n let sharedSecret = authData['shared_secret'];\n if (!sharedSecret) {\n callback(\n new Error(\n `No shared_secret key in auth payload for encrypted channel: ${this.name}`\n ),\n null\n );\n return;\n }\n this.key = decodeBase64(sharedSecret);\n delete authData['shared_secret'];\n callback(null, authData);\n }\n );\n }\n\n trigger(event: string, data: any): boolean {\n throw new Errors.UnsupportedFeature(\n 'Client events are not currently supported for encrypted channels'\n );\n }\n\n /** Handles an event. For internal use only.\n *\n * @param {PusherEvent} event\n */\n handleEvent(event: PusherEvent) {\n var eventName = event.event;\n var data = event.data;\n if (\n eventName.indexOf('pusher_internal:') === 0 ||\n eventName.indexOf('pusher:') === 0\n ) {\n super.handleEvent(event);\n return;\n }\n this.handleEncryptedEvent(eventName, data);\n }\n\n private handleEncryptedEvent(event: string, data: any): void {\n if (!this.key) {\n Logger.debug(\n 'Received encrypted event before key has been retrieved from the authEndpoint'\n );\n return;\n }\n if (!data.ciphertext || !data.nonce) {\n Logger.error(\n 'Unexpected format for encrypted event, expected object with `ciphertext` and `nonce` fields, got: ' +\n data\n );\n return;\n }\n let cipherText = decodeBase64(data.ciphertext);\n if (cipherText.length < this.nacl.secretbox.overheadLength) {\n Logger.error(\n `Expected encrypted event ciphertext length to be ${this.nacl.secretbox.overheadLength}, got: ${cipherText.length}`\n );\n return;\n }\n let nonce = decodeBase64(data.nonce);\n if (nonce.length < this.nacl.secretbox.nonceLength) {\n Logger.error(\n `Expected encrypted event nonce length to be ${this.nacl.secretbox.nonceLength}, got: ${nonce.length}`\n );\n return;\n }\n\n let bytes = this.nacl.secretbox.open(cipherText, nonce, this.key);\n if (bytes === null) {\n Logger.debug(\n 'Failed to decrypt an event, probably because it was encrypted with a different key. Fetching a new key from the authEndpoint...'\n );\n // Try a single time to retrieve a new auth key and decrypt the event with it\n // If this fails, a new key will be requested when a new message is received\n this.authorize(this.pusher.connection.socket_id, (error, authData) => {\n if (error) {\n Logger.error(\n `Failed to make a request to the authEndpoint: ${authData}. Unable to fetch new key, so dropping encrypted event`\n );\n return;\n }\n bytes = this.nacl.secretbox.open(cipherText, nonce, this.key);\n if (bytes === null) {\n Logger.error(\n `Failed to decrypt event with new key. Dropping encrypted event`\n );\n return;\n }\n this.emit(event, this.getDataToEmit(bytes));\n return;\n });\n return;\n }\n this.emit(event, this.getDataToEmit(bytes));\n }\n\n // Try and parse the decrypted bytes as JSON. If we can't parse it, just\n // return the utf-8 string\n getDataToEmit(bytes: Uint8Array): string {\n let raw = encodeUTF8(bytes);\n try {\n return JSON.parse(raw);\n } catch {\n return raw;\n }\n }\n}\n","import { default as EventsDispatcher } from '../events/dispatcher';\nimport { OneOffTimer as Timer } from '../utils/timers';\nimport { Config } from '../config';\nimport Logger from '../logger';\nimport HandshakePayload from './handshake/handshake_payload';\nimport Connection from './connection';\nimport Strategy from '../strategies/strategy';\nimport StrategyRunner from '../strategies/strategy_runner';\nimport * as Collections from '../utils/collections';\nimport Timeline from '../timeline/timeline';\nimport ConnectionManagerOptions from './connection_manager_options';\nimport Runtime from 'runtime';\n\nimport {\n ErrorCallbacks,\n HandshakeCallbacks,\n ConnectionCallbacks\n} from './callbacks';\nimport Action from './protocol/action';\n\n/** Manages connection to Pusher.\n *\n * Uses a strategy (currently only default), timers and network availability\n * info to establish a connection and export its state. In case of failures,\n * manages reconnection attempts.\n *\n * Exports state changes as following events:\n * - \"state_change\", { previous: p, current: state }\n * - state\n *\n * States:\n * - initialized - initial state, never transitioned to\n * - connecting - connection is being established\n * - connected - connection has been fully established\n * - disconnected - on requested disconnection\n * - unavailable - after connection timeout or when there's no network\n * - failed - when the connection strategy is not supported\n *\n * Options:\n * - unavailableTimeout - time to transition to unavailable state\n * - activityTimeout - time after which ping message should be sent\n * - pongTimeout - time for Pusher to respond with pong before reconnecting\n *\n * @param {String} key application key\n * @param {Object} options\n */\nexport default class ConnectionManager extends EventsDispatcher {\n key: string;\n options: ConnectionManagerOptions;\n state: string;\n connection: Connection;\n usingTLS: boolean;\n timeline: Timeline;\n socket_id: string;\n unavailableTimer: Timer;\n activityTimer: Timer;\n retryTimer: Timer;\n activityTimeout: number;\n strategy: Strategy;\n runner: StrategyRunner;\n errorCallbacks: ErrorCallbacks;\n handshakeCallbacks: HandshakeCallbacks;\n connectionCallbacks: ConnectionCallbacks;\n\n constructor(key: string, options: ConnectionManagerOptions) {\n super();\n this.state = 'initialized';\n this.connection = null;\n\n this.key = key;\n this.options = options;\n this.timeline = this.options.timeline;\n this.usingTLS = this.options.useTLS;\n\n this.errorCallbacks = this.buildErrorCallbacks();\n this.connectionCallbacks = this.buildConnectionCallbacks(\n this.errorCallbacks\n );\n this.handshakeCallbacks = this.buildHandshakeCallbacks(this.errorCallbacks);\n\n var Network = Runtime.getNetwork();\n\n Network.bind('online', () => {\n this.timeline.info({ netinfo: 'online' });\n if (this.state === 'connecting' || this.state === 'unavailable') {\n this.retryIn(0);\n }\n });\n Network.bind('offline', () => {\n this.timeline.info({ netinfo: 'offline' });\n if (this.connection) {\n this.sendActivityCheck();\n }\n });\n\n this.updateStrategy();\n }\n\n /** Establishes a connection to Pusher.\n *\n * Does nothing when connection is already established. See top-level doc\n * to find events emitted on connection attempts.\n */\n connect() {\n if (this.connection || this.runner) {\n return;\n }\n if (!this.strategy.isSupported()) {\n this.updateState('failed');\n return;\n }\n this.updateState('connecting');\n this.startConnecting();\n this.setUnavailableTimer();\n }\n\n /** Sends raw data.\n *\n * @param {String} data\n */\n send(data) {\n if (this.connection) {\n return this.connection.send(data);\n } else {\n return false;\n }\n }\n\n /** Sends an event.\n *\n * @param {String} name\n * @param {String} data\n * @param {String} [channel]\n * @returns {Boolean} whether message was sent or not\n */\n send_event(name: string, data: any, channel?: string) {\n if (this.connection) {\n return this.connection.send_event(name, data, channel);\n } else {\n return false;\n }\n }\n\n /** Closes the connection. */\n disconnect() {\n this.disconnectInternally();\n this.updateState('disconnected');\n }\n\n isUsingTLS() {\n return this.usingTLS;\n }\n\n private startConnecting() {\n var callback = (error, handshake) => {\n if (error) {\n this.runner = this.strategy.connect(0, callback);\n } else {\n if (handshake.action === 'error') {\n this.emit('error', {\n type: 'HandshakeError',\n error: handshake.error\n });\n this.timeline.error({ handshakeError: handshake.error });\n } else {\n this.abortConnecting(); // we don't support switching connections yet\n this.handshakeCallbacks[handshake.action](handshake);\n }\n }\n };\n this.runner = this.strategy.connect(0, callback);\n }\n\n private abortConnecting() {\n if (this.runner) {\n this.runner.abort();\n this.runner = null;\n }\n }\n\n private disconnectInternally() {\n this.abortConnecting();\n this.clearRetryTimer();\n this.clearUnavailableTimer();\n if (this.connection) {\n var connection = this.abandonConnection();\n connection.close();\n }\n }\n\n private updateStrategy() {\n this.strategy = this.options.getStrategy({\n key: this.key,\n timeline: this.timeline,\n useTLS: this.usingTLS\n });\n }\n\n private retryIn(delay) {\n this.timeline.info({ action: 'retry', delay: delay });\n if (delay > 0) {\n this.emit('connecting_in', Math.round(delay / 1000));\n }\n this.retryTimer = new Timer(delay || 0, () => {\n this.disconnectInternally();\n this.connect();\n });\n }\n\n private clearRetryTimer() {\n if (this.retryTimer) {\n this.retryTimer.ensureAborted();\n this.retryTimer = null;\n }\n }\n\n private setUnavailableTimer() {\n this.unavailableTimer = new Timer(this.options.unavailableTimeout, () => {\n this.updateState('unavailable');\n });\n }\n\n private clearUnavailableTimer() {\n if (this.unavailableTimer) {\n this.unavailableTimer.ensureAborted();\n }\n }\n\n private sendActivityCheck() {\n this.stopActivityCheck();\n this.connection.ping();\n // wait for pong response\n this.activityTimer = new Timer(this.options.pongTimeout, () => {\n this.timeline.error({ pong_timed_out: this.options.pongTimeout });\n this.retryIn(0);\n });\n }\n\n private resetActivityCheck() {\n this.stopActivityCheck();\n // send ping after inactivity\n if (this.connection && !this.connection.handlesActivityChecks()) {\n this.activityTimer = new Timer(this.activityTimeout, () => {\n this.sendActivityCheck();\n });\n }\n }\n\n private stopActivityCheck() {\n if (this.activityTimer) {\n this.activityTimer.ensureAborted();\n }\n }\n\n private buildConnectionCallbacks(\n errorCallbacks: ErrorCallbacks\n ): ConnectionCallbacks {\n return Collections.extend({}, errorCallbacks, {\n message: message => {\n // includes pong messages from server\n this.resetActivityCheck();\n this.emit('message', message);\n },\n ping: () => {\n this.send_event('pusher:pong', {});\n },\n activity: () => {\n this.resetActivityCheck();\n },\n error: error => {\n // just emit error to user - socket will already be closed by browser\n this.emit('error', error);\n },\n closed: () => {\n this.abandonConnection();\n if (this.shouldRetry()) {\n this.retryIn(1000);\n }\n }\n });\n }\n\n private buildHandshakeCallbacks(\n errorCallbacks: ErrorCallbacks\n ): HandshakeCallbacks {\n return Collections.extend({}, errorCallbacks, {\n connected: (handshake: HandshakePayload) => {\n this.activityTimeout = Math.min(\n this.options.activityTimeout,\n handshake.activityTimeout,\n handshake.connection.activityTimeout || Infinity\n );\n this.clearUnavailableTimer();\n this.setConnection(handshake.connection);\n this.socket_id = this.connection.id;\n this.updateState('connected', { socket_id: this.socket_id });\n }\n });\n }\n\n private buildErrorCallbacks(): ErrorCallbacks {\n let withErrorEmitted = callback => {\n return (result: Action | HandshakePayload) => {\n if (result.error) {\n this.emit('error', { type: 'WebSocketError', error: result.error });\n }\n callback(result);\n };\n };\n\n return {\n tls_only: withErrorEmitted(() => {\n this.usingTLS = true;\n this.updateStrategy();\n this.retryIn(0);\n }),\n refused: withErrorEmitted(() => {\n this.disconnect();\n }),\n backoff: withErrorEmitted(() => {\n this.retryIn(1000);\n }),\n retry: withErrorEmitted(() => {\n this.retryIn(0);\n })\n };\n }\n\n private setConnection(connection) {\n this.connection = connection;\n for (var event in this.connectionCallbacks) {\n this.connection.bind(event, this.connectionCallbacks[event]);\n }\n this.resetActivityCheck();\n }\n\n private abandonConnection() {\n if (!this.connection) {\n return;\n }\n this.stopActivityCheck();\n for (var event in this.connectionCallbacks) {\n this.connection.unbind(event, this.connectionCallbacks[event]);\n }\n var connection = this.connection;\n this.connection = null;\n return connection;\n }\n\n private updateState(newState: string, data?: any) {\n var previousState = this.state;\n this.state = newState;\n if (previousState !== newState) {\n var newStateDescription = newState;\n if (newStateDescription === 'connected') {\n newStateDescription += ' with new socket ID ' + data.socket_id;\n }\n Logger.debug(\n 'State changed',\n previousState + ' -> ' + newStateDescription\n );\n this.timeline.info({ state: newState, params: data });\n this.emit('state_change', { previous: previousState, current: newState });\n this.emit(newState, data);\n }\n }\n\n private shouldRetry(): boolean {\n return this.state === 'connecting' || this.state === 'connected';\n }\n}\n","import Channel from './channel';\nimport * as Collections from '../utils/collections';\nimport ChannelTable from './channel_table';\nimport Factory from '../utils/factory';\nimport Pusher from '../pusher';\nimport Logger from '../logger';\nimport * as Errors from '../errors';\nimport urlStore from '../utils/url_store';\n\n/** Handles a channel map. */\nexport default class Channels {\n channels: ChannelTable;\n\n constructor() {\n this.channels = {};\n }\n\n /** Creates or retrieves an existing channel by its name.\n *\n * @param {String} name\n * @param {Pusher} pusher\n * @return {Channel}\n */\n add(name: string, pusher: Pusher) {\n if (!this.channels[name]) {\n this.channels[name] = createChannel(name, pusher);\n }\n return this.channels[name];\n }\n\n /** Returns a list of all channels\n *\n * @return {Array}\n */\n all(): Channel[] {\n return Collections.values(this.channels);\n }\n\n /** Finds a channel by its name.\n *\n * @param {String} name\n * @return {Channel} channel or null if it doesn't exist\n */\n find(name: string) {\n return this.channels[name];\n }\n\n /** Removes a channel from the map.\n *\n * @param {String} name\n */\n remove(name: string) {\n var channel = this.channels[name];\n delete this.channels[name];\n return channel;\n }\n\n /** Proxies disconnection signal to all channels. */\n disconnect() {\n Collections.objectApply(this.channels, function(channel) {\n channel.disconnect();\n });\n }\n}\n\nfunction createChannel(name: string, pusher: Pusher): Channel {\n if (name.indexOf('private-encrypted-') === 0) {\n if (pusher.config.nacl) {\n return Factory.createEncryptedChannel(name, pusher, pusher.config.nacl);\n }\n let errMsg =\n 'Tried to subscribe to a private-encrypted- channel but no nacl implementation available';\n let suffix = urlStore.buildLogSuffix('encryptedChannelSupport');\n throw new Errors.UnsupportedFeature(`${errMsg}. ${suffix}`);\n } else if (name.indexOf('private-') === 0) {\n return Factory.createPrivateChannel(name, pusher);\n } else if (name.indexOf('presence-') === 0) {\n return Factory.createPresenceChannel(name, pusher);\n } else if (name.indexOf('#') === 0) {\n throw new Errors.BadChannelName(\n 'Cannot create a channel with name \"' + name + '\".'\n );\n } else {\n return Factory.createChannel(name, pusher);\n }\n}\n","import AssistantToTheTransportManager from '../transports/assistant_to_the_transport_manager';\nimport PingDelayOptions from '../transports/ping_delay_options';\nimport Transport from '../transports/transport';\nimport TransportManager from '../transports/transport_manager';\nimport Handshake from '../connection/handshake';\nimport TransportConnection from '../transports/transport_connection';\nimport SocketHooks from '../http/socket_hooks';\nimport HTTPSocket from '../http/http_socket';\n\nimport Timeline from '../timeline/timeline';\nimport {\n default as TimelineSender,\n TimelineSenderOptions\n} from '../timeline/timeline_sender';\nimport PresenceChannel from '../channels/presence_channel';\nimport PrivateChannel from '../channels/private_channel';\nimport EncryptedChannel from '../channels/encrypted_channel';\nimport Channel from '../channels/channel';\nimport ConnectionManager from '../connection/connection_manager';\nimport ConnectionManagerOptions from '../connection/connection_manager_options';\nimport Ajax from '../http/ajax';\nimport Channels from '../channels/channels';\nimport Pusher from '../pusher';\nimport { Config } from '../config';\nimport * as nacl from 'tweetnacl';\n\nvar Factory = {\n createChannels(): Channels {\n return new Channels();\n },\n\n createConnectionManager(\n key: string,\n options: ConnectionManagerOptions\n ): ConnectionManager {\n return new ConnectionManager(key, options);\n },\n\n createChannel(name: string, pusher: Pusher): Channel {\n return new Channel(name, pusher);\n },\n\n createPrivateChannel(name: string, pusher: Pusher): PrivateChannel {\n return new PrivateChannel(name, pusher);\n },\n\n createPresenceChannel(name: string, pusher: Pusher): PresenceChannel {\n return new PresenceChannel(name, pusher);\n },\n\n createEncryptedChannel(\n name: string,\n pusher: Pusher,\n nacl: nacl\n ): EncryptedChannel {\n return new EncryptedChannel(name, pusher, nacl);\n },\n\n createTimelineSender(timeline: Timeline, options: TimelineSenderOptions) {\n return new TimelineSender(timeline, options);\n },\n\n createHandshake(\n transport: TransportConnection,\n callback: (HandshakePayload) => void\n ): Handshake {\n return new Handshake(transport, callback);\n },\n\n createAssistantToTheTransportManager(\n manager: TransportManager,\n transport: Transport,\n options: PingDelayOptions\n ): AssistantToTheTransportManager {\n return new AssistantToTheTransportManager(manager, transport, options);\n }\n};\n\nexport default Factory;\n","import AssistantToTheTransportManager from './assistant_to_the_transport_manager';\nimport Transport from './transport';\nimport PingDelayOptions from './ping_delay_options';\nimport Factory from '../utils/factory';\n\nexport interface TransportManagerOptions extends PingDelayOptions {\n lives?: number;\n}\n\n/** Keeps track of the number of lives left for a transport.\n *\n * In the beginning of a session, transports may be assigned a number of\n * lives. When an AssistantToTheTransportManager instance reports a transport\n * connection closed uncleanly, the transport loses a life. When the number\n * of lives drops to zero, the transport gets disabled by its manager.\n *\n * @param {Object} options\n */\nexport default class TransportManager {\n options: TransportManagerOptions;\n livesLeft: number;\n\n constructor(options: TransportManagerOptions) {\n this.options = options || {};\n this.livesLeft = this.options.lives || Infinity;\n }\n\n /** Creates a assistant for the transport.\n *\n * @param {Transport} transport\n * @returns {AssistantToTheTransportManager}\n */\n getAssistant(transport: Transport): AssistantToTheTransportManager {\n return Factory.createAssistantToTheTransportManager(this, transport, {\n minPingDelay: this.options.minPingDelay,\n maxPingDelay: this.options.maxPingDelay\n });\n }\n\n /** Returns whether the transport has any lives left.\n *\n * @returns {Boolean}\n */\n isAlive(): boolean {\n return this.livesLeft > 0;\n }\n\n /** Takes one life from the transport. */\n reportDeath() {\n this.livesLeft -= 1;\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport { OneOffTimer as Timer } from '../utils/timers';\nimport Strategy from './strategy';\nimport StrategyOptions from './strategy_options';\n\n/** Loops through strategies with optional timeouts.\n *\n * Options:\n * - loop - whether it should loop through the substrategy list\n * - timeout - initial timeout for a single substrategy\n * - timeoutLimit - maximum timeout\n *\n * @param {Strategy[]} strategies\n * @param {Object} options\n */\nexport default class SequentialStrategy implements Strategy {\n strategies: Strategy[];\n loop: boolean;\n failFast: boolean;\n timeout: number;\n timeoutLimit: number;\n\n constructor(strategies: Strategy[], options: StrategyOptions) {\n this.strategies = strategies;\n this.loop = Boolean(options.loop);\n this.failFast = Boolean(options.failFast);\n this.timeout = options.timeout;\n this.timeoutLimit = options.timeoutLimit;\n }\n\n isSupported(): boolean {\n return Collections.any(this.strategies, Util.method('isSupported'));\n }\n\n connect(minPriority: number, callback: Function) {\n var strategies = this.strategies;\n var current = 0;\n var timeout = this.timeout;\n var runner = null;\n\n var tryNextStrategy = (error, handshake) => {\n if (handshake) {\n callback(null, handshake);\n } else {\n current = current + 1;\n if (this.loop) {\n current = current % strategies.length;\n }\n\n if (current < strategies.length) {\n if (timeout) {\n timeout = timeout * 2;\n if (this.timeoutLimit) {\n timeout = Math.min(timeout, this.timeoutLimit);\n }\n }\n runner = this.tryStrategy(\n strategies[current],\n minPriority,\n { timeout, failFast: this.failFast },\n tryNextStrategy\n );\n } else {\n callback(true);\n }\n }\n };\n\n runner = this.tryStrategy(\n strategies[current],\n minPriority,\n { timeout: timeout, failFast: this.failFast },\n tryNextStrategy\n );\n\n return {\n abort: function() {\n runner.abort();\n },\n forceMinPriority: function(p) {\n minPriority = p;\n if (runner) {\n runner.forceMinPriority(p);\n }\n }\n };\n }\n\n private tryStrategy(\n strategy: Strategy,\n minPriority: number,\n options: StrategyOptions,\n callback: Function\n ) {\n var timer = null;\n var runner = null;\n\n if (options.timeout > 0) {\n timer = new Timer(options.timeout, function() {\n runner.abort();\n callback(true);\n });\n }\n\n runner = strategy.connect(minPriority, function(error, handshake) {\n if (error && timer && timer.isRunning() && !options.failFast) {\n // advance to the next strategy after the timeout\n return;\n }\n if (timer) {\n timer.ensureAborted();\n }\n callback(error, handshake);\n });\n\n return {\n abort: function() {\n if (timer) {\n timer.ensureAborted();\n }\n runner.abort();\n },\n forceMinPriority: function(p) {\n runner.forceMinPriority(p);\n }\n };\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport Strategy from './strategy';\n\n/** Launches all substrategies and emits prioritized connected transports.\n *\n * @param {Array} strategies\n */\nexport default class BestConnectedEverStrategy implements Strategy {\n strategies: Strategy[];\n\n constructor(strategies: Strategy[]) {\n this.strategies = strategies;\n }\n\n isSupported(): boolean {\n return Collections.any(this.strategies, Util.method('isSupported'));\n }\n\n connect(minPriority: number, callback: Function) {\n return connect(this.strategies, minPriority, function(i, runners) {\n return function(error, handshake) {\n runners[i].error = error;\n if (error) {\n if (allRunnersFailed(runners)) {\n callback(true);\n }\n return;\n }\n Collections.apply(runners, function(runner) {\n runner.forceMinPriority(handshake.transport.priority);\n });\n callback(null, handshake);\n };\n });\n }\n}\n\n/** Connects to all strategies in parallel.\n *\n * Callback builder should be a function that takes two arguments: index\n * and a list of runners. It should return another function that will be\n * passed to the substrategy with given index. Runners can be aborted using\n * abortRunner(s) functions from this class.\n *\n * @param {Array} strategies\n * @param {Function} callbackBuilder\n * @return {Object} strategy runner\n */\nfunction connect(\n strategies: Strategy[],\n minPriority: number,\n callbackBuilder: Function\n) {\n var runners = Collections.map(strategies, function(strategy, i, _, rs) {\n return strategy.connect(minPriority, callbackBuilder(i, rs));\n });\n return {\n abort: function() {\n Collections.apply(runners, abortRunner);\n },\n forceMinPriority: function(p) {\n Collections.apply(runners, function(runner) {\n runner.forceMinPriority(p);\n });\n }\n };\n}\n\nfunction allRunnersFailed(runners): boolean {\n return Collections.all(runners, function(runner) {\n return Boolean(runner.error);\n });\n}\n\nfunction abortRunner(runner) {\n if (!runner.error && !runner.aborted) {\n runner.abort();\n runner.aborted = true;\n }\n}\n","import Util from '../util';\nimport Runtime from 'runtime';\nimport Strategy from './strategy';\nimport SequentialStrategy from './sequential_strategy';\nimport StrategyOptions from './strategy_options';\nimport TransportStrategy from './transport_strategy';\nimport Timeline from '../timeline/timeline';\nimport * as Collections from '../utils/collections';\n\nexport interface TransportStrategyDictionary {\n [key: string]: TransportStrategy;\n}\n\n/** Caches the last successful transport and, after the first few attempts,\n * uses the cached transport for subsequent attempts.\n *\n * @param {Strategy} strategy\n * @param {Object} transports\n * @param {Object} options\n */\nexport default class WebSocketPrioritizedCachedStrategy implements Strategy {\n strategy: Strategy;\n transports: TransportStrategyDictionary;\n ttl: number;\n usingTLS: boolean;\n timeline: Timeline;\n\n constructor(\n strategy: Strategy,\n transports: TransportStrategyDictionary,\n options: StrategyOptions\n ) {\n this.strategy = strategy;\n this.transports = transports;\n this.ttl = options.ttl || 1800 * 1000;\n this.usingTLS = options.useTLS;\n this.timeline = options.timeline;\n }\n\n isSupported(): boolean {\n return this.strategy.isSupported();\n }\n\n connect(minPriority: number, callback: Function) {\n var usingTLS = this.usingTLS;\n var info = fetchTransportCache(usingTLS);\n var cacheSkipCount = info && info.cacheSkipCount ? info.cacheSkipCount : 0;\n\n var strategies = [this.strategy];\n if (info && info.timestamp + this.ttl >= Util.now()) {\n var transport = this.transports[info.transport];\n if (transport) {\n if (['ws', 'wss'].includes(info.transport) || cacheSkipCount > 3) {\n this.timeline.info({\n cached: true,\n transport: info.transport,\n latency: info.latency\n });\n strategies.push(\n new SequentialStrategy([transport], {\n timeout: info.latency * 2 + 1000,\n failFast: true\n })\n );\n } else {\n cacheSkipCount++;\n }\n }\n }\n\n var startTimestamp = Util.now();\n var runner = strategies\n .pop()\n .connect(minPriority, function cb(error, handshake) {\n if (error) {\n flushTransportCache(usingTLS);\n if (strategies.length > 0) {\n startTimestamp = Util.now();\n runner = strategies.pop().connect(minPriority, cb);\n } else {\n callback(error);\n }\n } else {\n storeTransportCache(\n usingTLS,\n handshake.transport.name,\n Util.now() - startTimestamp,\n cacheSkipCount\n );\n callback(null, handshake);\n }\n });\n\n return {\n abort: function() {\n runner.abort();\n },\n forceMinPriority: function(p) {\n minPriority = p;\n if (runner) {\n runner.forceMinPriority(p);\n }\n }\n };\n }\n}\n\nfunction getTransportCacheKey(usingTLS: boolean): string {\n return 'pusherTransport' + (usingTLS ? 'TLS' : 'NonTLS');\n}\n\nfunction fetchTransportCache(usingTLS: boolean): any {\n var storage = Runtime.getLocalStorage();\n if (storage) {\n try {\n var serializedCache = storage[getTransportCacheKey(usingTLS)];\n if (serializedCache) {\n return JSON.parse(serializedCache);\n }\n } catch (e) {\n flushTransportCache(usingTLS);\n }\n }\n return null;\n}\n\nfunction storeTransportCache(\n usingTLS: boolean,\n transport: TransportStrategy,\n latency: number,\n cacheSkipCount: number\n) {\n var storage = Runtime.getLocalStorage();\n if (storage) {\n try {\n storage[getTransportCacheKey(usingTLS)] = Collections.safeJSONStringify({\n timestamp: Util.now(),\n transport: transport,\n latency: latency,\n cacheSkipCount: cacheSkipCount\n });\n } catch (e) {\n // catch over quota exceptions raised by localStorage\n }\n }\n}\n\nfunction flushTransportCache(usingTLS: boolean) {\n var storage = Runtime.getLocalStorage();\n if (storage) {\n try {\n delete storage[getTransportCacheKey(usingTLS)];\n } catch (e) {\n // catch exceptions raised by localStorage\n }\n }\n}\n","import { OneOffTimer as Timer } from '../utils/timers';\nimport Strategy from './strategy';\nimport StrategyOptions from './strategy_options';\n\n/** Runs substrategy after specified delay.\n *\n * Options:\n * - delay - time in miliseconds to delay the substrategy attempt\n *\n * @param {Strategy} strategy\n * @param {Object} options\n */\nexport default class DelayedStrategy implements Strategy {\n strategy: Strategy;\n options: { delay: number };\n\n constructor(strategy: Strategy, { delay: number }) {\n this.strategy = strategy;\n this.options = { delay: number };\n }\n\n isSupported(): boolean {\n return this.strategy.isSupported();\n }\n\n connect(minPriority: number, callback: Function) {\n var strategy = this.strategy;\n var runner;\n var timer = new Timer(this.options.delay, function() {\n runner = strategy.connect(minPriority, callback);\n });\n\n return {\n abort: function() {\n timer.ensureAborted();\n if (runner) {\n runner.abort();\n }\n },\n forceMinPriority: function(p) {\n minPriority = p;\n if (runner) {\n runner.forceMinPriority(p);\n }\n }\n };\n }\n}\n","import Strategy from './strategy';\nimport StrategyRunner from './strategy_runner';\n\n/** Proxies method calls to one of substrategies basing on the test function.\n *\n * @param {Function} test\n * @param {Strategy} trueBranch strategy used when test returns true\n * @param {Strategy} falseBranch strategy used when test returns false\n */\nexport default class IfStrategy implements Strategy {\n test: () => boolean;\n trueBranch: Strategy;\n falseBranch: Strategy;\n\n constructor(\n test: () => boolean,\n trueBranch: Strategy,\n falseBranch: Strategy\n ) {\n this.test = test;\n this.trueBranch = trueBranch;\n this.falseBranch = falseBranch;\n }\n\n isSupported(): boolean {\n var branch = this.test() ? this.trueBranch : this.falseBranch;\n return branch.isSupported();\n }\n\n connect(minPriority: number, callback: Function): StrategyRunner {\n var branch = this.test() ? this.trueBranch : this.falseBranch;\n return branch.connect(minPriority, callback);\n }\n}\n","import Strategy from './strategy';\nimport StrategyRunner from './strategy_runner';\n\n/** Launches the substrategy and terminates on the first open connection.\n *\n * @param {Strategy} strategy\n */\nexport default class FirstConnectedStrategy implements Strategy {\n strategy: Strategy;\n\n constructor(strategy: Strategy) {\n this.strategy = strategy;\n }\n\n isSupported(): boolean {\n return this.strategy.isSupported();\n }\n\n connect(minPriority: number, callback: Function): StrategyRunner {\n var runner = this.strategy.connect(minPriority, function(error, handshake) {\n if (handshake) {\n runner.abort();\n }\n callback(error, handshake);\n });\n return runner;\n }\n}\n","import * as Collections from 'core/utils/collections';\nimport TransportManager from 'core/transports/transport_manager';\nimport Strategy from 'core/strategies/strategy';\nimport StrategyOptions from 'core/strategies/strategy_options';\nimport SequentialStrategy from 'core/strategies/sequential_strategy';\nimport BestConnectedEverStrategy from 'core/strategies/best_connected_ever_strategy';\nimport WebSocketPrioritizedCachedStrategy, {\n TransportStrategyDictionary\n} from 'core/strategies/websocket_prioritized_cached_strategy';\nimport DelayedStrategy from 'core/strategies/delayed_strategy';\nimport IfStrategy from 'core/strategies/if_strategy';\nimport FirstConnectedStrategy from 'core/strategies/first_connected_strategy';\nimport { Config } from 'core/config';\n\nfunction testSupportsStrategy(strategy: Strategy) {\n return function() {\n return strategy.isSupported();\n };\n}\n\nvar getDefaultStrategy = function(\n config: Config,\n baseOptions: StrategyOptions,\n defineTransport: Function\n): Strategy {\n var definedTransports = {};\n\n function defineTransportStrategy(\n name: string,\n type: string,\n priority: number,\n options: StrategyOptions,\n manager?: TransportManager\n ) {\n var transport = defineTransport(\n config,\n name,\n type,\n priority,\n options,\n manager\n );\n\n definedTransports[name] = transport;\n\n return transport;\n }\n\n var ws_options: StrategyOptions = Object.assign({}, baseOptions, {\n hostNonTLS: config.wsHost + ':' + config.wsPort,\n hostTLS: config.wsHost + ':' + config.wssPort,\n httpPath: config.wsPath\n });\n var wss_options: StrategyOptions = Object.assign({}, ws_options, {\n useTLS: true\n });\n var sockjs_options: StrategyOptions = Object.assign({}, baseOptions, {\n hostNonTLS: config.httpHost + ':' + config.httpPort,\n hostTLS: config.httpHost + ':' + config.httpsPort,\n httpPath: config.httpPath\n });\n\n var timeouts = {\n loop: true,\n timeout: 15000,\n timeoutLimit: 60000\n };\n\n var ws_manager = new TransportManager({\n minPingDelay: 10000,\n maxPingDelay: config.activityTimeout\n });\n var streaming_manager = new TransportManager({\n lives: 2,\n minPingDelay: 10000,\n maxPingDelay: config.activityTimeout\n });\n\n var ws_transport = defineTransportStrategy(\n 'ws',\n 'ws',\n 3,\n ws_options,\n ws_manager\n );\n var wss_transport = defineTransportStrategy(\n 'wss',\n 'ws',\n 3,\n wss_options,\n ws_manager\n );\n var sockjs_transport = defineTransportStrategy(\n 'sockjs',\n 'sockjs',\n 1,\n sockjs_options\n );\n var xhr_streaming_transport = defineTransportStrategy(\n 'xhr_streaming',\n 'xhr_streaming',\n 1,\n sockjs_options,\n streaming_manager\n );\n var xdr_streaming_transport = defineTransportStrategy(\n 'xdr_streaming',\n 'xdr_streaming',\n 1,\n sockjs_options,\n streaming_manager\n );\n var xhr_polling_transport = defineTransportStrategy(\n 'xhr_polling',\n 'xhr_polling',\n 1,\n sockjs_options\n );\n var xdr_polling_transport = defineTransportStrategy(\n 'xdr_polling',\n 'xdr_polling',\n 1,\n sockjs_options\n );\n\n var ws_loop = new SequentialStrategy([ws_transport], timeouts);\n var wss_loop = new SequentialStrategy([wss_transport], timeouts);\n var sockjs_loop = new SequentialStrategy([sockjs_transport], timeouts);\n var streaming_loop = new SequentialStrategy(\n [\n new IfStrategy(\n testSupportsStrategy(xhr_streaming_transport),\n xhr_streaming_transport,\n xdr_streaming_transport\n )\n ],\n timeouts\n );\n var polling_loop = new SequentialStrategy(\n [\n new IfStrategy(\n testSupportsStrategy(xhr_polling_transport),\n xhr_polling_transport,\n xdr_polling_transport\n )\n ],\n timeouts\n );\n\n var http_loop = new SequentialStrategy(\n [\n new IfStrategy(\n testSupportsStrategy(streaming_loop),\n new BestConnectedEverStrategy([\n streaming_loop,\n new DelayedStrategy(polling_loop, { delay: 4000 })\n ]),\n polling_loop\n )\n ],\n timeouts\n );\n\n var http_fallback_loop = new IfStrategy(\n testSupportsStrategy(http_loop),\n http_loop,\n sockjs_loop\n );\n\n var wsStrategy;\n if (baseOptions.useTLS) {\n wsStrategy = new BestConnectedEverStrategy([\n ws_loop,\n new DelayedStrategy(http_fallback_loop, { delay: 2000 })\n ]);\n } else {\n wsStrategy = new BestConnectedEverStrategy([\n ws_loop,\n new DelayedStrategy(wss_loop, { delay: 2000 }),\n new DelayedStrategy(http_fallback_loop, { delay: 5000 })\n ]);\n }\n\n return new WebSocketPrioritizedCachedStrategy(\n new FirstConnectedStrategy(\n new IfStrategy(\n testSupportsStrategy(ws_transport),\n wsStrategy,\n http_fallback_loop\n )\n ),\n definedTransports,\n {\n ttl: 1800000,\n timeline: baseOptions.timeline,\n useTLS: baseOptions.useTLS\n }\n );\n};\n\nexport default getDefaultStrategy;\n","import HTTPRequest from 'core/http/http_request';\nimport RequestHooks from 'core/http/request_hooks';\nimport Ajax from 'core/http/ajax';\nimport * as Errors from 'core/errors';\n\nvar hooks: RequestHooks = {\n getRequest: function(socket: HTTPRequest): Ajax {\n var xdr = new (window).XDomainRequest();\n xdr.ontimeout = function() {\n socket.emit('error', new Errors.RequestTimedOut());\n socket.close();\n };\n xdr.onerror = function(e) {\n socket.emit('error', e);\n socket.close();\n };\n xdr.onprogress = function() {\n if (xdr.responseText && xdr.responseText.length > 0) {\n socket.onChunk(200, xdr.responseText);\n }\n };\n xdr.onload = function() {\n if (xdr.responseText && xdr.responseText.length > 0) {\n socket.onChunk(200, xdr.responseText);\n }\n socket.emit('finished', 200);\n socket.close();\n };\n return xdr;\n },\n abortRequest: function(xdr: Ajax) {\n xdr.ontimeout = xdr.onerror = xdr.onprogress = xdr.onload = null;\n xdr.abort();\n }\n};\n\nexport default hooks;\n","import Runtime from 'runtime';\nimport RequestHooks from './request_hooks';\nimport Ajax from './ajax';\nimport { default as EventsDispatcher } from '../events/dispatcher';\n\nconst MAX_BUFFER_LENGTH = 256 * 1024;\n\nexport default class HTTPRequest extends EventsDispatcher {\n hooks: RequestHooks;\n method: string;\n url: string;\n position: number;\n xhr: Ajax;\n unloader: Function;\n\n constructor(hooks: RequestHooks, method: string, url: string) {\n super();\n this.hooks = hooks;\n this.method = method;\n this.url = url;\n }\n\n start(payload?: any) {\n this.position = 0;\n this.xhr = this.hooks.getRequest(this);\n\n this.unloader = () => {\n this.close();\n };\n Runtime.addUnloadListener(this.unloader);\n\n this.xhr.open(this.method, this.url, true);\n\n if (this.xhr.setRequestHeader) {\n this.xhr.setRequestHeader('Content-Type', 'application/json'); // ReactNative doesn't set this header by default.\n }\n this.xhr.send(payload);\n }\n\n close() {\n if (this.unloader) {\n Runtime.removeUnloadListener(this.unloader);\n this.unloader = null;\n }\n if (this.xhr) {\n this.hooks.abortRequest(this.xhr);\n this.xhr = null;\n }\n }\n\n onChunk(status: number, data: any) {\n while (true) {\n var chunk = this.advanceBuffer(data);\n if (chunk) {\n this.emit('chunk', { status: status, data: chunk });\n } else {\n break;\n }\n }\n if (this.isBufferTooLong(data)) {\n this.emit('buffer_too_long');\n }\n }\n\n private advanceBuffer(buffer: any[]): any {\n var unreadData = buffer.slice(this.position);\n var endOfLinePosition = unreadData.indexOf('\\n');\n\n if (endOfLinePosition !== -1) {\n this.position += endOfLinePosition + 1;\n return unreadData.slice(0, endOfLinePosition);\n } else {\n // chunk is not finished yet, don't move the buffer pointer\n return null;\n }\n }\n\n private isBufferTooLong(buffer: any): boolean {\n return this.position === buffer.length && buffer.length > MAX_BUFFER_LENGTH;\n }\n}\n","enum State {\n CONNECTING = 0,\n OPEN = 1,\n CLOSED = 3\n}\n\nexport default State;\n","import URLLocation from './url_location';\nimport State from './state';\nimport Socket from '../socket';\nimport SocketHooks from './socket_hooks';\nimport Util from '../util';\nimport Ajax from './ajax';\nimport HTTPRequest from './http_request';\nimport Runtime from 'runtime';\n\nvar autoIncrement = 1;\n\nclass HTTPSocket implements Socket {\n hooks: SocketHooks;\n session: string;\n location: URLLocation;\n readyState: State;\n stream: HTTPRequest;\n\n onopen: () => void;\n onerror: (error: any) => void;\n onclose: (closeEvent: any) => void;\n onmessage: (message: any) => void;\n onactivity: () => void;\n\n constructor(hooks: SocketHooks, url: string) {\n this.hooks = hooks;\n this.session = randomNumber(1000) + '/' + randomString(8);\n this.location = getLocation(url);\n this.readyState = State.CONNECTING;\n this.openStream();\n }\n\n send(payload: any) {\n return this.sendRaw(JSON.stringify([payload]));\n }\n\n ping() {\n this.hooks.sendHeartbeat(this);\n }\n\n close(code: any, reason: any) {\n this.onClose(code, reason, true);\n }\n\n /** For internal use only */\n sendRaw(payload: any): boolean {\n if (this.readyState === State.OPEN) {\n try {\n Runtime.createSocketRequest(\n 'POST',\n getUniqueURL(getSendURL(this.location, this.session))\n ).start(payload);\n return true;\n } catch (e) {\n return false;\n }\n } else {\n return false;\n }\n }\n\n /** For internal use only */\n reconnect() {\n this.closeStream();\n this.openStream();\n }\n\n /** For internal use only */\n onClose(code, reason, wasClean) {\n this.closeStream();\n this.readyState = State.CLOSED;\n if (this.onclose) {\n this.onclose({\n code: code,\n reason: reason,\n wasClean: wasClean\n });\n }\n }\n\n private onChunk(chunk) {\n if (chunk.status !== 200) {\n return;\n }\n if (this.readyState === State.OPEN) {\n this.onActivity();\n }\n\n var payload;\n var type = chunk.data.slice(0, 1);\n switch (type) {\n case 'o':\n payload = JSON.parse(chunk.data.slice(1) || '{}');\n this.onOpen(payload);\n break;\n case 'a':\n payload = JSON.parse(chunk.data.slice(1) || '[]');\n for (var i = 0; i < payload.length; i++) {\n this.onEvent(payload[i]);\n }\n break;\n case 'm':\n payload = JSON.parse(chunk.data.slice(1) || 'null');\n this.onEvent(payload);\n break;\n case 'h':\n this.hooks.onHeartbeat(this);\n break;\n case 'c':\n payload = JSON.parse(chunk.data.slice(1) || '[]');\n this.onClose(payload[0], payload[1], true);\n break;\n }\n }\n\n private onOpen(options) {\n if (this.readyState === State.CONNECTING) {\n if (options && options.hostname) {\n this.location.base = replaceHost(this.location.base, options.hostname);\n }\n this.readyState = State.OPEN;\n\n if (this.onopen) {\n this.onopen();\n }\n } else {\n this.onClose(1006, 'Server lost session', true);\n }\n }\n\n private onEvent(event) {\n if (this.readyState === State.OPEN && this.onmessage) {\n this.onmessage({ data: event });\n }\n }\n\n private onActivity() {\n if (this.onactivity) {\n this.onactivity();\n }\n }\n\n private onError(error) {\n if (this.onerror) {\n this.onerror(error);\n }\n }\n\n private openStream() {\n this.stream = Runtime.createSocketRequest(\n 'POST',\n getUniqueURL(this.hooks.getReceiveURL(this.location, this.session))\n );\n\n this.stream.bind('chunk', chunk => {\n this.onChunk(chunk);\n });\n this.stream.bind('finished', status => {\n this.hooks.onFinished(this, status);\n });\n this.stream.bind('buffer_too_long', () => {\n this.reconnect();\n });\n\n try {\n this.stream.start();\n } catch (error) {\n Util.defer(() => {\n this.onError(error);\n this.onClose(1006, 'Could not start streaming', false);\n });\n }\n }\n\n private closeStream() {\n if (this.stream) {\n this.stream.unbind_all();\n this.stream.close();\n this.stream = null;\n }\n }\n}\n\nfunction getLocation(url): URLLocation {\n var parts = /([^\\?]*)\\/*(\\??.*)/.exec(url);\n return {\n base: parts[1],\n queryString: parts[2]\n };\n}\n\nfunction getSendURL(url: URLLocation, session: string): string {\n return url.base + '/' + session + '/xhr_send';\n}\n\nfunction getUniqueURL(url: string): string {\n var separator = url.indexOf('?') === -1 ? '?' : '&';\n return url + separator + 't=' + +new Date() + '&n=' + autoIncrement++;\n}\n\nfunction replaceHost(url: string, hostname: string): string {\n var urlParts = /(https?:\\/\\/)([^\\/:]+)((\\/|:)?.*)/.exec(url);\n return urlParts[1] + hostname + urlParts[3];\n}\n\nfunction randomNumber(max: number): number {\n return Runtime.randomInt(max);\n}\n\nfunction randomString(length: number): string {\n var result = [];\n\n for (var i = 0; i < length; i++) {\n result.push(randomNumber(32).toString(32));\n }\n\n return result.join('');\n}\n\nexport default HTTPSocket;\n","enum TimelineLevel {\n ERROR = 3,\n INFO = 6,\n DEBUG = 7\n}\n\nexport default TimelineLevel;\n","import SocketHooks from './socket_hooks';\nimport HTTPSocket from './http_socket';\n\nvar hooks: SocketHooks = {\n getReceiveURL: function(url, session) {\n return url.base + '/' + session + '/xhr_streaming' + url.queryString;\n },\n onHeartbeat: function(socket) {\n socket.sendRaw('[]');\n },\n sendHeartbeat: function(socket) {\n socket.sendRaw('[]');\n },\n onFinished: function(socket, status) {\n socket.onClose(1006, 'Connection interrupted (' + status + ')', false);\n }\n};\n\nexport default hooks;\n","import SocketHooks from './socket_hooks';\nimport URLLocation from './url_location';\nimport HTTPSocket from './http_socket';\n\nvar hooks: SocketHooks = {\n getReceiveURL: function(url: URLLocation, session: string): string {\n return url.base + '/' + session + '/xhr' + url.queryString;\n },\n onHeartbeat: function() {\n // next HTTP request will reset server's activity timer\n },\n sendHeartbeat: function(socket) {\n socket.sendRaw('[]');\n },\n onFinished: function(socket, status) {\n if (status === 200) {\n socket.reconnect();\n } else {\n socket.onClose(1006, 'Connection interrupted (' + status + ')', false);\n }\n }\n};\n\nexport default hooks;\n","import HTTPRequest from 'core/http/http_request';\nimport RequestHooks from 'core/http/request_hooks';\nimport Ajax from 'core/http/ajax';\nimport Runtime from 'runtime';\n\nvar hooks: RequestHooks = {\n getRequest: function(socket: HTTPRequest): Ajax {\n var Constructor = Runtime.getXHRAPI();\n var xhr = new Constructor();\n xhr.onreadystatechange = xhr.onprogress = function() {\n switch (xhr.readyState) {\n case 3:\n if (xhr.responseText && xhr.responseText.length > 0) {\n socket.onChunk(xhr.status, xhr.responseText);\n }\n break;\n case 4:\n // this happens only on errors, never after calling close\n if (xhr.responseText && xhr.responseText.length > 0) {\n socket.onChunk(xhr.status, xhr.responseText);\n }\n socket.emit('finished', xhr.status);\n socket.close();\n break;\n }\n };\n return xhr;\n },\n abortRequest: function(xhr: Ajax) {\n xhr.onreadystatechange = null;\n xhr.abort();\n }\n};\n\nexport default hooks;\n","import HTTPRequest from 'core/http/http_request';\nimport HTTPSocket from 'core/http/http_socket';\nimport SocketHooks from 'core/http/socket_hooks';\nimport RequestHooks from 'core/http/request_hooks';\nimport streamingHooks from 'core/http/http_streaming_socket';\nimport pollingHooks from 'core/http/http_polling_socket';\nimport xhrHooks from './http_xhr_request';\nimport HTTPFactory from 'core/http/http_factory';\n\nvar HTTP: HTTPFactory = {\n createStreamingSocket(url: string): HTTPSocket {\n return this.createSocket(streamingHooks, url);\n },\n\n createPollingSocket(url: string): HTTPSocket {\n return this.createSocket(pollingHooks, url);\n },\n\n createSocket(hooks: SocketHooks, url: string): HTTPSocket {\n return new HTTPSocket(hooks, url);\n },\n\n createXHR(method: string, url: string): HTTPRequest {\n return this.createRequest(xhrHooks, method, url);\n },\n\n createRequest(hooks: RequestHooks, method: string, url: string): HTTPRequest {\n return new HTTPRequest(hooks, method, url);\n }\n};\n\nexport default HTTP;\n","import xdrHooks from './http_xdomain_request';\nimport HTTP from 'isomorphic/http/http';\n\nHTTP.createXDR = function(method, url) {\n return this.createRequest(xdrHooks, method, url);\n};\n\nexport default HTTP;\n","import Browser from './browser';\nimport { Dependencies, DependenciesReceivers } from './dom/dependencies';\nimport { AuthTransport, AuthTransports } from 'core/auth/auth_transports';\nimport xhrAuth from 'isomorphic/auth/xhr_auth';\nimport jsonpAuth from './auth/jsonp_auth';\nimport TimelineTransport from 'core/timeline/timeline_transport';\nimport TimelineSender from 'core/timeline/timeline_sender';\nimport ScriptRequest from './dom/script_request';\nimport JSONPRequest from './dom/jsonp_request';\nimport * as Collections from 'core/utils/collections';\nimport { ScriptReceivers } from './dom/script_receiver_factory';\nimport jsonpTimeline from './timeline/jsonp_timeline';\nimport Transports from './transports/transports';\nimport Ajax from 'core/http/ajax';\nimport { Network } from './net_info';\nimport getDefaultStrategy from './default_strategy';\nimport transportConnectionInitializer from './transports/transport_connection_initializer';\nimport HTTPFactory from './http/http';\nimport HTTPRequest from 'core/http/http_request';\n\nvar Runtime: Browser = {\n // for jsonp auth\n nextAuthCallbackID: 1,\n auth_callbacks: {},\n ScriptReceivers,\n DependenciesReceivers,\n getDefaultStrategy,\n Transports,\n transportConnectionInitializer,\n HTTPFactory,\n\n TimelineTransport: jsonpTimeline,\n\n getXHRAPI() {\n return window.XMLHttpRequest;\n },\n\n getWebSocketAPI() {\n return window.WebSocket || window.MozWebSocket;\n },\n\n setup(PusherClass): void {\n (window).Pusher = PusherClass; // JSONp requires Pusher to be in the global scope.\n var initializeOnDocumentBody = () => {\n this.onDocumentBody(PusherClass.ready);\n };\n if (!(window).JSON) {\n Dependencies.load('json2', {}, initializeOnDocumentBody);\n } else {\n initializeOnDocumentBody();\n }\n },\n\n getDocument(): Document {\n return document;\n },\n\n getProtocol(): string {\n return this.getDocument().location.protocol;\n },\n\n getAuthorizers(): AuthTransports {\n return { ajax: xhrAuth, jsonp: jsonpAuth };\n },\n\n onDocumentBody(callback: Function) {\n if (document.body) {\n callback();\n } else {\n setTimeout(() => {\n this.onDocumentBody(callback);\n }, 0);\n }\n },\n\n createJSONPRequest(url: string, data: any): JSONPRequest {\n return new JSONPRequest(url, data);\n },\n\n createScriptRequest(src: string): ScriptRequest {\n return new ScriptRequest(src);\n },\n\n getLocalStorage() {\n try {\n return window.localStorage;\n } catch (e) {\n return undefined;\n }\n },\n\n createXHR(): Ajax {\n if (this.getXHRAPI()) {\n return this.createXMLHttpRequest();\n } else {\n return this.createMicrosoftXHR();\n }\n },\n\n createXMLHttpRequest(): Ajax {\n var Constructor = this.getXHRAPI();\n return new Constructor();\n },\n\n createMicrosoftXHR(): Ajax {\n return new ActiveXObject('Microsoft.XMLHTTP');\n },\n\n getNetwork() {\n return Network;\n },\n\n createWebSocket(url: string): any {\n var Constructor = this.getWebSocketAPI();\n return new Constructor(url);\n },\n\n createSocketRequest(method: string, url: string): HTTPRequest {\n if (this.isXHRSupported()) {\n return this.HTTPFactory.createXHR(method, url);\n } else if (this.isXDRSupported(url.indexOf('https:') === 0)) {\n return this.HTTPFactory.createXDR(method, url);\n } else {\n throw 'Cross-origin HTTP requests are not supported';\n }\n },\n\n isXHRSupported(): boolean {\n var Constructor = this.getXHRAPI();\n return (\n Boolean(Constructor) && new Constructor().withCredentials !== undefined\n );\n },\n\n isXDRSupported(useTLS?: boolean): boolean {\n var protocol = useTLS ? 'https:' : 'http:';\n var documentProtocol = this.getProtocol();\n return (\n Boolean(window['XDomainRequest']) && documentProtocol === protocol\n );\n },\n\n addUnloadListener(listener: any) {\n if (window.addEventListener !== undefined) {\n window.addEventListener('unload', listener, false);\n } else if (window.attachEvent !== undefined) {\n window.attachEvent('onunload', listener);\n }\n },\n\n removeUnloadListener(listener: any) {\n if (window.addEventListener !== undefined) {\n window.removeEventListener('unload', listener, false);\n } else if (window.detachEvent !== undefined) {\n window.detachEvent('onunload', listener);\n }\n },\n\n randomInt(max: number): number {\n /**\n * Return values in the range of [0, 1[\n */\n const random = function() {\n const crypto = window.crypto || window['msCrypto'];\n const random = crypto.getRandomValues(new Uint32Array(1))[0];\n\n return random / 2 ** 32;\n };\n\n return Math.floor(random() * max);\n }\n};\n\nexport default Runtime;\n","import { Dependencies } from '../dom/dependencies';\n\n/** Initializes the transport.\n *\n * Fetches resources if needed and then transitions to initialized.\n */\nexport default function() {\n var self = this;\n\n self.timeline.info(\n self.buildTimelineMessage({\n transport: self.name + (self.options.useTLS ? 's' : '')\n })\n );\n\n if (self.hooks.isInitialized()) {\n self.changeState('initialized');\n } else if (self.hooks.file) {\n self.changeState('initializing');\n Dependencies.load(\n self.hooks.file,\n { useTLS: self.options.useTLS },\n function(error, callback) {\n if (self.hooks.isInitialized()) {\n self.changeState('initialized');\n callback(true);\n } else {\n if (error) {\n self.onError(error);\n }\n self.onClose();\n callback(false);\n }\n }\n );\n } else {\n self.onClose();\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport { default as Level } from './level';\n\nexport interface TimelineOptions {\n level?: Level;\n limit?: number;\n version?: string;\n cluster?: string;\n features?: string[];\n params?: any;\n}\n\nexport default class Timeline {\n key: string;\n session: number;\n events: any[];\n options: TimelineOptions;\n sent: number;\n uniqueID: number;\n\n constructor(key: string, session: number, options: TimelineOptions) {\n this.key = key;\n this.session = session;\n this.events = [];\n this.options = options || {};\n this.sent = 0;\n this.uniqueID = 0;\n }\n\n log(level, event) {\n if (level <= this.options.level) {\n this.events.push(\n Collections.extend({}, event, { timestamp: Util.now() })\n );\n if (this.options.limit && this.events.length > this.options.limit) {\n this.events.shift();\n }\n }\n }\n\n error(event) {\n this.log(Level.ERROR, event);\n }\n\n info(event) {\n this.log(Level.INFO, event);\n }\n\n debug(event) {\n this.log(Level.DEBUG, event);\n }\n\n isEmpty() {\n return this.events.length === 0;\n }\n\n send(sendfn, callback) {\n var data = Collections.extend(\n {\n session: this.session,\n bundle: this.sent + 1,\n key: this.key,\n lib: 'js',\n version: this.options.version,\n cluster: this.options.cluster,\n features: this.options.features,\n timeline: this.events\n },\n this.options.params\n );\n\n this.events = [];\n sendfn(data, (error, result) => {\n if (!error) {\n this.sent++;\n }\n if (callback) {\n callback(error, result);\n }\n });\n\n return true;\n }\n\n generateUniqueID(): number {\n this.uniqueID++;\n return this.uniqueID;\n }\n}\n","import Factory from '../utils/factory';\nimport Util from '../util';\nimport * as Errors from '../errors';\nimport * as Collections from '../utils/collections';\nimport Strategy from './strategy';\nimport Transport from '../transports/transport';\nimport StrategyOptions from './strategy_options';\nimport Handshake from '../connection/handshake';\n\n/** Provides a strategy interface for transports.\n *\n * @param {String} name\n * @param {Number} priority\n * @param {Class} transport\n * @param {Object} options\n */\nexport default class TransportStrategy implements Strategy {\n name: string;\n priority: number;\n transport: Transport;\n options: StrategyOptions;\n\n constructor(\n name: string,\n priority: number,\n transport: Transport,\n options: StrategyOptions\n ) {\n this.name = name;\n this.priority = priority;\n this.transport = transport;\n this.options = options || {};\n }\n\n /** Returns whether the transport is supported in the browser.\n *\n * @returns {Boolean}\n */\n isSupported(): boolean {\n return this.transport.isSupported({\n useTLS: this.options.useTLS\n });\n }\n\n /** Launches a connection attempt and returns a strategy runner.\n *\n * @param {Function} callback\n * @return {Object} strategy runner\n */\n connect(minPriority: number, callback: Function) {\n if (!this.isSupported()) {\n return failAttempt(new Errors.UnsupportedStrategy(), callback);\n } else if (this.priority < minPriority) {\n return failAttempt(new Errors.TransportPriorityTooLow(), callback);\n }\n\n var connected = false;\n var transport = this.transport.createConnection(\n this.name,\n this.priority,\n this.options.key,\n this.options\n );\n var handshake = null;\n\n var onInitialized = function() {\n transport.unbind('initialized', onInitialized);\n transport.connect();\n };\n var onOpen = function() {\n handshake = Factory.createHandshake(transport, function(result) {\n connected = true;\n unbindListeners();\n callback(null, result);\n });\n };\n var onError = function(error) {\n unbindListeners();\n callback(error);\n };\n var onClosed = function() {\n unbindListeners();\n var serializedTransport;\n\n // The reason for this try/catch block is that on React Native\n // the WebSocket object is circular. Therefore transport.socket will\n // throw errors upon stringification. Collections.safeJSONStringify\n // discards circular references when serializing.\n serializedTransport = Collections.safeJSONStringify(transport);\n callback(new Errors.TransportClosed(serializedTransport));\n };\n\n var unbindListeners = function() {\n transport.unbind('initialized', onInitialized);\n transport.unbind('open', onOpen);\n transport.unbind('error', onError);\n transport.unbind('closed', onClosed);\n };\n\n transport.bind('initialized', onInitialized);\n transport.bind('open', onOpen);\n transport.bind('error', onError);\n transport.bind('closed', onClosed);\n\n // connect will be called automatically after initialization\n transport.initialize();\n\n return {\n abort: () => {\n if (connected) {\n return;\n }\n unbindListeners();\n if (handshake) {\n handshake.close();\n } else {\n transport.close();\n }\n },\n forceMinPriority: p => {\n if (connected) {\n return;\n }\n if (this.priority < p) {\n if (handshake) {\n handshake.close();\n } else {\n transport.close();\n }\n }\n }\n };\n }\n}\n\nfunction failAttempt(error: Error, callback: Function) {\n Util.defer(function() {\n callback(error);\n });\n return {\n abort: function() {},\n forceMinPriority: function() {}\n };\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport TransportManager from '../transports/transport_manager';\nimport * as Errors from '../errors';\nimport Strategy from './strategy';\nimport TransportStrategy from './transport_strategy';\nimport StrategyOptions from '../strategies/strategy_options';\nimport { Config } from '../config';\nimport Runtime from 'runtime';\n\nconst { Transports } = Runtime;\n\nexport var defineTransport = function(\n config: Config,\n name: string,\n type: string,\n priority: number,\n options: StrategyOptions,\n manager?: TransportManager\n): Strategy {\n var transportClass = Transports[type];\n if (!transportClass) {\n throw new Errors.UnsupportedTransport(type);\n }\n\n var enabled =\n (!config.enabledTransports ||\n Collections.arrayIndexOf(config.enabledTransports, name) !== -1) &&\n (!config.disabledTransports ||\n Collections.arrayIndexOf(config.disabledTransports, name) === -1);\n\n var transport;\n if (enabled) {\n options = Object.assign(\n { ignoreNullOrigin: config.ignoreNullOrigin },\n options\n );\n\n transport = new TransportStrategy(\n name,\n priority,\n manager ? manager.getAssistant(transportClass) : transportClass,\n options\n );\n } else {\n transport = UnsupportedStrategy;\n }\n\n return transport;\n};\n\nvar UnsupportedStrategy: Strategy = {\n isSupported: function() {\n return false;\n },\n connect: function(_, callback) {\n var deferred = Util.defer(function() {\n callback(new Errors.UnsupportedStrategy());\n });\n return {\n abort: function() {\n deferred.ensureAborted();\n },\n forceMinPriority: function() {}\n };\n }\n};\n","import {\n UserAuthenticationCallback,\n InternalAuthOptions,\n UserAuthenticationHandler,\n UserAuthenticationRequestParams,\n AuthRequestType\n} from './options';\n\nimport Runtime from 'runtime';\n\nconst composeChannelQuery = (\n params: UserAuthenticationRequestParams,\n authOptions: InternalAuthOptions\n) => {\n var query = 'socket_id=' + encodeURIComponent(params.socketId);\n\n for (var key in authOptions.params) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(authOptions.params[key]);\n }\n\n if (authOptions.paramsProvider != null) {\n let dynamicParams = authOptions.paramsProvider();\n for (var key in dynamicParams) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(dynamicParams[key]);\n }\n }\n\n return query;\n};\n\nconst UserAuthenticator = (\n authOptions: InternalAuthOptions\n): UserAuthenticationHandler => {\n if (typeof Runtime.getAuthorizers()[authOptions.transport] === 'undefined') {\n throw `'${authOptions.transport}' is not a recognized auth transport`;\n }\n\n return (\n params: UserAuthenticationRequestParams,\n callback: UserAuthenticationCallback\n ) => {\n const query = composeChannelQuery(params, authOptions);\n\n Runtime.getAuthorizers()[authOptions.transport](\n Runtime,\n query,\n authOptions,\n AuthRequestType.UserAuthentication,\n callback\n );\n };\n};\n\nexport default UserAuthenticator;\n","import {\n AuthRequestType,\n InternalAuthOptions,\n ChannelAuthorizationHandler,\n ChannelAuthorizationRequestParams,\n ChannelAuthorizationCallback\n} from './options';\n\nimport Runtime from 'runtime';\n\nconst composeChannelQuery = (\n params: ChannelAuthorizationRequestParams,\n authOptions: InternalAuthOptions\n) => {\n var query = 'socket_id=' + encodeURIComponent(params.socketId);\n\n query += '&channel_name=' + encodeURIComponent(params.channelName);\n\n for (var key in authOptions.params) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(authOptions.params[key]);\n }\n\n if (authOptions.paramsProvider != null) {\n let dynamicParams = authOptions.paramsProvider();\n for (var key in dynamicParams) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(dynamicParams[key]);\n }\n }\n\n return query;\n};\n\nconst ChannelAuthorizer = (\n authOptions: InternalAuthOptions\n): ChannelAuthorizationHandler => {\n if (typeof Runtime.getAuthorizers()[authOptions.transport] === 'undefined') {\n throw `'${authOptions.transport}' is not a recognized auth transport`;\n }\n\n return (\n params: ChannelAuthorizationRequestParams,\n callback: ChannelAuthorizationCallback\n ) => {\n const query = composeChannelQuery(params, authOptions);\n\n Runtime.getAuthorizers()[authOptions.transport](\n Runtime,\n query,\n authOptions,\n AuthRequestType.ChannelAuthorization,\n callback\n );\n };\n};\n\nexport default ChannelAuthorizer;\n","import { Options } from './options';\nimport Defaults from './defaults';\nimport {\n ChannelAuthorizationHandler,\n UserAuthenticationHandler,\n ChannelAuthorizationOptions\n} from './auth/options';\nimport UserAuthenticator from './auth/user_authenticator';\nimport ChannelAuthorizer from './auth/channel_authorizer';\nimport { ChannelAuthorizerProxy } from './auth/deprecated_channel_authorizer';\nimport Runtime from 'runtime';\nimport * as nacl from 'tweetnacl';\n\nexport type AuthTransport = 'ajax' | 'jsonp';\nexport type Transport =\n | 'ws'\n | 'wss'\n | 'xhr_streaming'\n | 'xhr_polling'\n | 'sockjs';\n\nexport interface Config {\n // these are all 'required' config parameters, it's not necessary for the user\n // to set them, but they have configured defaults.\n activityTimeout: number;\n enableStats: boolean;\n httpHost: string;\n httpPath: string;\n httpPort: number;\n httpsPort: number;\n pongTimeout: number;\n statsHost: string;\n unavailableTimeout: number;\n useTLS: boolean;\n wsHost: string;\n wsPath: string;\n wsPort: number;\n wssPort: number;\n userAuthenticator: UserAuthenticationHandler;\n channelAuthorizer: ChannelAuthorizationHandler;\n\n // these are all optional parameters or overrrides. The customer can set these\n // but it's not strictly necessary\n forceTLS?: boolean;\n cluster?: string;\n disabledTransports?: Transport[];\n enabledTransports?: Transport[];\n ignoreNullOrigin?: boolean;\n nacl?: nacl;\n timelineParams?: any;\n}\n\n// getConfig mainly sets the defaults for the options that are not provided\nexport function getConfig(opts: Options, pusher): Config {\n let config: Config = {\n activityTimeout: opts.activityTimeout || Defaults.activityTimeout,\n cluster: opts.cluster,\n httpPath: opts.httpPath || Defaults.httpPath,\n httpPort: opts.httpPort || Defaults.httpPort,\n httpsPort: opts.httpsPort || Defaults.httpsPort,\n pongTimeout: opts.pongTimeout || Defaults.pongTimeout,\n statsHost: opts.statsHost || Defaults.stats_host,\n unavailableTimeout: opts.unavailableTimeout || Defaults.unavailableTimeout,\n wsPath: opts.wsPath || Defaults.wsPath,\n wsPort: opts.wsPort || Defaults.wsPort,\n wssPort: opts.wssPort || Defaults.wssPort,\n\n enableStats: getEnableStatsConfig(opts),\n httpHost: getHttpHost(opts),\n useTLS: shouldUseTLS(opts),\n wsHost: getWebsocketHost(opts),\n\n userAuthenticator: buildUserAuthenticator(opts),\n channelAuthorizer: buildChannelAuthorizer(opts, pusher)\n };\n\n if ('disabledTransports' in opts)\n config.disabledTransports = opts.disabledTransports;\n if ('enabledTransports' in opts)\n config.enabledTransports = opts.enabledTransports;\n if ('ignoreNullOrigin' in opts)\n config.ignoreNullOrigin = opts.ignoreNullOrigin;\n if ('timelineParams' in opts) config.timelineParams = opts.timelineParams;\n if ('nacl' in opts) {\n config.nacl = opts.nacl;\n }\n\n return config;\n}\n\nfunction getHttpHost(opts: Options): string {\n if (opts.httpHost) {\n return opts.httpHost;\n }\n if (opts.cluster) {\n return `sockjs-${opts.cluster}.pusher.com`;\n }\n return Defaults.httpHost;\n}\n\nfunction getWebsocketHost(opts: Options): string {\n if (opts.wsHost) {\n return opts.wsHost;\n }\n return getWebsocketHostFromCluster(opts.cluster);\n}\n\nfunction getWebsocketHostFromCluster(cluster: string): string {\n return `ws-${cluster}.pusher.com`;\n}\n\nfunction shouldUseTLS(opts: Options): boolean {\n if (Runtime.getProtocol() === 'https:') {\n return true;\n } else if (opts.forceTLS === false) {\n return false;\n }\n return true;\n}\n\n// if enableStats is set take the value\n// if disableStats is set take the inverse\n// otherwise default to false\nfunction getEnableStatsConfig(opts: Options): boolean {\n if ('enableStats' in opts) {\n return opts.enableStats;\n }\n if ('disableStats' in opts) {\n return !opts.disableStats;\n }\n return false;\n}\n\nfunction buildUserAuthenticator(opts: Options): UserAuthenticationHandler {\n const userAuthentication = {\n ...Defaults.userAuthentication,\n ...opts.userAuthentication\n };\n if (\n 'customHandler' in userAuthentication &&\n userAuthentication['customHandler'] != null\n ) {\n return userAuthentication['customHandler'];\n }\n\n return UserAuthenticator(userAuthentication);\n}\n\nfunction buildChannelAuth(opts: Options, pusher): ChannelAuthorizationOptions {\n let channelAuthorization: ChannelAuthorizationOptions;\n if ('channelAuthorization' in opts) {\n channelAuthorization = {\n ...Defaults.channelAuthorization,\n ...opts.channelAuthorization\n };\n } else {\n channelAuthorization = {\n transport: opts.authTransport || Defaults.authTransport,\n endpoint: opts.authEndpoint || Defaults.authEndpoint\n };\n if ('auth' in opts) {\n if ('params' in opts.auth) channelAuthorization.params = opts.auth.params;\n if ('headers' in opts.auth)\n channelAuthorization.headers = opts.auth.headers;\n }\n if ('authorizer' in opts)\n channelAuthorization.customHandler = ChannelAuthorizerProxy(\n pusher,\n channelAuthorization,\n opts.authorizer\n );\n }\n return channelAuthorization;\n}\n\nfunction buildChannelAuthorizer(\n opts: Options,\n pusher\n): ChannelAuthorizationHandler {\n const channelAuthorization = buildChannelAuth(opts, pusher);\n if (\n 'customHandler' in channelAuthorization &&\n channelAuthorization['customHandler'] != null\n ) {\n return channelAuthorization['customHandler'];\n }\n\n return ChannelAuthorizer(channelAuthorization);\n}\n","import Channel from '../channels/channel';\nimport {\n ChannelAuthorizationCallback,\n ChannelAuthorizationHandler,\n ChannelAuthorizationRequestParams,\n InternalAuthOptions\n} from './options';\n\nexport interface DeprecatedChannelAuthorizer {\n authorize(socketId: string, callback: ChannelAuthorizationCallback): void;\n}\n\nexport interface ChannelAuthorizerGenerator {\n (\n channel: Channel,\n options: DeprecatedAuthorizerOptions\n ): DeprecatedChannelAuthorizer;\n}\n\nexport interface DeprecatedAuthOptions {\n params?: any;\n headers?: any;\n}\n\nexport interface DeprecatedAuthorizerOptions {\n authTransport: 'ajax' | 'jsonp';\n authEndpoint: string;\n auth?: DeprecatedAuthOptions;\n}\n\nexport const ChannelAuthorizerProxy = (\n pusher,\n authOptions: InternalAuthOptions,\n channelAuthorizerGenerator: ChannelAuthorizerGenerator\n): ChannelAuthorizationHandler => {\n const deprecatedAuthorizerOptions: DeprecatedAuthorizerOptions = {\n authTransport: authOptions.transport,\n authEndpoint: authOptions.endpoint,\n auth: {\n params: authOptions.params,\n headers: authOptions.headers\n }\n };\n return (\n params: ChannelAuthorizationRequestParams,\n callback: ChannelAuthorizationCallback\n ) => {\n const channel = pusher.channel(params.channelName);\n // This line creates a new channel authorizer every time.\n // In the past, this was only done once per channel and reused.\n // We can do that again if we want to keep this behavior intact.\n const channelAuthorizer: DeprecatedChannelAuthorizer = channelAuthorizerGenerator(\n channel,\n deprecatedAuthorizerOptions\n );\n channelAuthorizer.authorize(params.socketId, callback);\n };\n};\n","import Logger from './logger';\nimport Pusher from './pusher';\nimport EventsDispatcher from './events/dispatcher';\n\nexport default class WatchlistFacade extends EventsDispatcher {\n private pusher: Pusher;\n\n public constructor(pusher: Pusher) {\n super(function(eventName, data) {\n Logger.debug(`No callbacks on watchlist events for ${eventName}`);\n });\n\n this.pusher = pusher;\n this.bindWatchlistInternalEvent();\n }\n\n handleEvent(pusherEvent) {\n pusherEvent.data.events.forEach(watchlistEvent => {\n this.emit(watchlistEvent.name, watchlistEvent);\n });\n }\n\n private bindWatchlistInternalEvent() {\n this.pusher.connection.bind('message', pusherEvent => {\n var eventName = pusherEvent.event;\n if (eventName === 'pusher_internal:watchlist_events') {\n this.handleEvent(pusherEvent);\n }\n });\n }\n}\n","function flatPromise() {\n let resolve, reject;\n const promise = new Promise((res, rej) => {\n resolve = res;\n reject = rej;\n });\n return { promise, resolve, reject };\n}\n\nexport default flatPromise;\n","import Pusher from './pusher';\nimport Logger from './logger';\nimport {\n UserAuthenticationData,\n UserAuthenticationCallback\n} from './auth/options';\nimport Channel from './channels/channel';\nimport WatchlistFacade from './watchlist';\nimport EventsDispatcher from './events/dispatcher';\nimport flatPromise from './utils/flat_promise';\n\nexport default class UserFacade extends EventsDispatcher {\n pusher: Pusher;\n signin_requested: boolean = false;\n user_data: any = null;\n serverToUserChannel: Channel = null;\n signinDonePromise: Promise = null;\n watchlist: WatchlistFacade;\n private _signinDoneResolve: Function = null;\n\n public constructor(pusher: Pusher) {\n super(function(eventName, data) {\n Logger.debug('No callbacks on user for ' + eventName);\n });\n this.pusher = pusher;\n this.pusher.connection.bind('state_change', ({ previous, current }) => {\n if (previous !== 'connected' && current === 'connected') {\n this._signin();\n }\n if (previous === 'connected' && current !== 'connected') {\n this._cleanup();\n this._newSigninPromiseIfNeeded();\n }\n });\n\n this.watchlist = new WatchlistFacade(pusher);\n\n this.pusher.connection.bind('message', event => {\n var eventName = event.event;\n if (eventName === 'pusher:signin_success') {\n this._onSigninSuccess(event.data);\n }\n if (\n this.serverToUserChannel &&\n this.serverToUserChannel.name === event.channel\n ) {\n this.serverToUserChannel.handleEvent(event);\n }\n });\n }\n\n public signin() {\n if (this.signin_requested) {\n return;\n }\n\n this.signin_requested = true;\n this._signin();\n }\n\n private _signin() {\n if (!this.signin_requested) {\n return;\n }\n\n this._newSigninPromiseIfNeeded();\n\n if (this.pusher.connection.state !== 'connected') {\n // Signin will be attempted when the connection is connected\n return;\n }\n\n this.pusher.config.userAuthenticator(\n {\n socketId: this.pusher.connection.socket_id\n },\n this._onAuthorize\n );\n }\n\n private _onAuthorize: UserAuthenticationCallback = (\n err,\n authData: UserAuthenticationData\n ) => {\n if (err) {\n Logger.warn(`Error during signin: ${err}`);\n this._cleanup();\n return;\n }\n\n this.pusher.send_event('pusher:signin', {\n auth: authData.auth,\n user_data: authData.user_data\n });\n\n // Later when we get pusher:singin_success event, the user will be marked as signed in\n };\n\n private _onSigninSuccess(data: any) {\n try {\n this.user_data = JSON.parse(data.user_data);\n } catch (e) {\n Logger.error(`Failed parsing user data after signin: ${data.user_data}`);\n this._cleanup();\n return;\n }\n\n if (typeof this.user_data.id !== 'string' || this.user_data.id === '') {\n Logger.error(\n `user_data doesn't contain an id. user_data: ${this.user_data}`\n );\n this._cleanup();\n return;\n }\n\n // Signin succeeded\n this._signinDoneResolve();\n this._subscribeChannels();\n }\n\n private _subscribeChannels() {\n const ensure_subscribed = channel => {\n if (channel.subscriptionPending && channel.subscriptionCancelled) {\n channel.reinstateSubscription();\n } else if (\n !channel.subscriptionPending &&\n this.pusher.connection.state === 'connected'\n ) {\n channel.subscribe();\n }\n };\n\n this.serverToUserChannel = new Channel(\n `#server-to-user-${this.user_data.id}`,\n this.pusher\n );\n this.serverToUserChannel.bind_global((eventName, data) => {\n if (\n eventName.indexOf('pusher_internal:') === 0 ||\n eventName.indexOf('pusher:') === 0\n ) {\n // ignore internal events\n return;\n }\n this.emit(eventName, data);\n });\n ensure_subscribed(this.serverToUserChannel);\n }\n\n private _cleanup() {\n this.user_data = null;\n if (this.serverToUserChannel) {\n this.serverToUserChannel.unbind_all();\n this.serverToUserChannel.disconnect();\n this.serverToUserChannel = null;\n }\n\n if (this.signin_requested) {\n // If signin is in progress and cleanup is called,\n // Mark the current signin process as done.\n this._signinDoneResolve();\n }\n }\n\n private _newSigninPromiseIfNeeded() {\n if (!this.signin_requested) {\n return;\n }\n\n // If there is a promise and it is not resolved, return without creating a new one.\n if (this.signinDonePromise && !(this.signinDonePromise as any).done) {\n return;\n }\n\n // This promise is never rejected.\n // It gets resolved when the signin process is done whether it failed or succeeded\n const { promise, resolve, reject: _ } = flatPromise();\n (promise as any).done = false;\n const setDone = () => {\n (promise as any).done = true;\n };\n promise.then(setDone).catch(setDone);\n this.signinDonePromise = promise;\n this._signinDoneResolve = resolve;\n }\n}\n","import AbstractRuntime from '../runtimes/interface';\nimport Runtime from 'runtime';\nimport Util from './util';\nimport * as Collections from './utils/collections';\nimport Channels from './channels/channels';\nimport Channel from './channels/channel';\nimport { default as EventsDispatcher } from './events/dispatcher';\nimport Timeline from './timeline/timeline';\nimport TimelineSender from './timeline/timeline_sender';\nimport TimelineLevel from './timeline/level';\nimport { defineTransport } from './strategies/strategy_builder';\nimport ConnectionManager from './connection/connection_manager';\nimport ConnectionManagerOptions from './connection/connection_manager_options';\nimport { PeriodicTimer } from './utils/timers';\nimport Defaults from './defaults';\nimport * as DefaultConfig from './config';\nimport Logger from './logger';\nimport Factory from './utils/factory';\nimport UrlStore from 'core/utils/url_store';\nimport { Options, validateOptions } from './options';\nimport { Config, getConfig } from './config';\nimport StrategyOptions from './strategies/strategy_options';\nimport UserFacade from './user';\n\nexport default class Pusher {\n /* STATIC PROPERTIES */\n static instances: Pusher[] = [];\n static isReady: boolean = false;\n static logToConsole: boolean = false;\n\n // for jsonp\n static Runtime: AbstractRuntime = Runtime;\n static ScriptReceivers: any = (Runtime).ScriptReceivers;\n static DependenciesReceivers: any = (Runtime).DependenciesReceivers;\n static auth_callbacks: any = (Runtime).auth_callbacks;\n\n static ready() {\n Pusher.isReady = true;\n for (var i = 0, l = Pusher.instances.length; i < l; i++) {\n Pusher.instances[i].connect();\n }\n }\n\n static log: (message: any) => void;\n\n private static getClientFeatures(): string[] {\n return Collections.keys(\n Collections.filterObject({ ws: Runtime.Transports.ws }, function(t) {\n return t.isSupported({});\n })\n );\n }\n\n /* INSTANCE PROPERTIES */\n key: string;\n config: Config;\n channels: Channels;\n global_emitter: EventsDispatcher;\n sessionID: number;\n timeline: Timeline;\n timelineSender: TimelineSender;\n connection: ConnectionManager;\n timelineSenderTimer: PeriodicTimer;\n user: UserFacade;\n constructor(app_key: string, options: Options) {\n checkAppKey(app_key);\n validateOptions(options);\n this.key = app_key;\n this.config = getConfig(options, this);\n\n this.channels = Factory.createChannels();\n this.global_emitter = new EventsDispatcher();\n this.sessionID = Runtime.randomInt(1000000000);\n\n this.timeline = new Timeline(this.key, this.sessionID, {\n cluster: this.config.cluster,\n features: Pusher.getClientFeatures(),\n params: this.config.timelineParams || {},\n limit: 50,\n level: TimelineLevel.INFO,\n version: Defaults.VERSION\n });\n if (this.config.enableStats) {\n this.timelineSender = Factory.createTimelineSender(this.timeline, {\n host: this.config.statsHost,\n path: '/timeline/v2/' + Runtime.TimelineTransport.name\n });\n }\n\n var getStrategy = (options: StrategyOptions) => {\n return Runtime.getDefaultStrategy(this.config, options, defineTransport);\n };\n\n this.connection = Factory.createConnectionManager(this.key, {\n getStrategy: getStrategy,\n timeline: this.timeline,\n activityTimeout: this.config.activityTimeout,\n pongTimeout: this.config.pongTimeout,\n unavailableTimeout: this.config.unavailableTimeout,\n useTLS: Boolean(this.config.useTLS)\n });\n\n this.connection.bind('connected', () => {\n this.subscribeAll();\n if (this.timelineSender) {\n this.timelineSender.send(this.connection.isUsingTLS());\n }\n });\n\n this.connection.bind('message', event => {\n var eventName = event.event;\n var internal = eventName.indexOf('pusher_internal:') === 0;\n if (event.channel) {\n var channel = this.channel(event.channel);\n if (channel) {\n channel.handleEvent(event);\n }\n }\n // Emit globally [deprecated]\n if (!internal) {\n this.global_emitter.emit(event.event, event.data);\n }\n });\n this.connection.bind('connecting', () => {\n this.channels.disconnect();\n });\n this.connection.bind('disconnected', () => {\n this.channels.disconnect();\n });\n this.connection.bind('error', err => {\n Logger.warn(err);\n });\n\n Pusher.instances.push(this);\n this.timeline.info({ instances: Pusher.instances.length });\n\n this.user = new UserFacade(this);\n\n if (Pusher.isReady) {\n this.connect();\n }\n }\n\n channel(name: string): Channel {\n return this.channels.find(name);\n }\n\n allChannels(): Channel[] {\n return this.channels.all();\n }\n\n connect() {\n this.connection.connect();\n\n if (this.timelineSender) {\n if (!this.timelineSenderTimer) {\n var usingTLS = this.connection.isUsingTLS();\n var timelineSender = this.timelineSender;\n this.timelineSenderTimer = new PeriodicTimer(60000, function() {\n timelineSender.send(usingTLS);\n });\n }\n }\n }\n\n disconnect() {\n this.connection.disconnect();\n\n if (this.timelineSenderTimer) {\n this.timelineSenderTimer.ensureAborted();\n this.timelineSenderTimer = null;\n }\n }\n\n bind(event_name: string, callback: Function, context?: any): Pusher {\n this.global_emitter.bind(event_name, callback, context);\n return this;\n }\n\n unbind(event_name?: string, callback?: Function, context?: any): Pusher {\n this.global_emitter.unbind(event_name, callback, context);\n return this;\n }\n\n bind_global(callback: Function): Pusher {\n this.global_emitter.bind_global(callback);\n return this;\n }\n\n unbind_global(callback?: Function): Pusher {\n this.global_emitter.unbind_global(callback);\n return this;\n }\n\n unbind_all(callback?: Function): Pusher {\n this.global_emitter.unbind_all();\n return this;\n }\n\n subscribeAll() {\n var channelName;\n for (channelName in this.channels.channels) {\n if (this.channels.channels.hasOwnProperty(channelName)) {\n this.subscribe(channelName);\n }\n }\n }\n\n subscribe(channel_name: string) {\n var channel = this.channels.add(channel_name, this);\n if (channel.subscriptionPending && channel.subscriptionCancelled) {\n channel.reinstateSubscription();\n } else if (\n !channel.subscriptionPending &&\n this.connection.state === 'connected'\n ) {\n channel.subscribe();\n }\n return channel;\n }\n\n unsubscribe(channel_name: string) {\n var channel = this.channels.find(channel_name);\n if (channel && channel.subscriptionPending) {\n channel.cancelSubscription();\n } else {\n channel = this.channels.remove(channel_name);\n if (channel && channel.subscribed) {\n channel.unsubscribe();\n }\n }\n }\n\n send_event(event_name: string, data: any, channel?: string) {\n return this.connection.send_event(event_name, data, channel);\n }\n\n shouldUseTLS(): boolean {\n return this.config.useTLS;\n }\n\n signin() {\n this.user.signin();\n }\n}\n\nfunction checkAppKey(key) {\n if (key === null || key === undefined) {\n throw 'You must pass your app key when you instantiate Pusher.';\n }\n}\n\nRuntime.setup(Pusher);\n","import ConnectionManager from './connection/connection_manager';\nimport {\n ChannelAuthorizationOptions,\n UserAuthenticationOptions\n} from './auth/options';\nimport {\n ChannelAuthorizerGenerator,\n DeprecatedAuthOptions\n} from './auth/deprecated_channel_authorizer';\nimport { AuthTransport, Transport } from './config';\nimport * as nacl from 'tweetnacl';\nimport Logger from './logger';\n\nexport interface Options {\n activityTimeout?: number;\n\n auth?: DeprecatedAuthOptions; // DEPRECATED use channelAuthorization instead\n authEndpoint?: string; // DEPRECATED use channelAuthorization instead\n authTransport?: AuthTransport; // DEPRECATED use channelAuthorization instead\n authorizer?: ChannelAuthorizerGenerator; // DEPRECATED use channelAuthorization instead\n\n channelAuthorization?: ChannelAuthorizationOptions;\n userAuthentication?: UserAuthenticationOptions;\n\n cluster: string;\n enableStats?: boolean;\n disableStats?: boolean;\n disabledTransports?: Transport[];\n enabledTransports?: Transport[];\n forceTLS?: boolean;\n httpHost?: string;\n httpPath?: string;\n httpPort?: number;\n httpsPort?: number;\n ignoreNullOrigin?: boolean;\n nacl?: nacl;\n pongTimeout?: number;\n statsHost?: string;\n timelineParams?: any;\n unavailableTimeout?: number;\n wsHost?: string;\n wsPath?: string;\n wsPort?: number;\n wssPort?: number;\n}\n\nexport function validateOptions(options) {\n if (options == null) {\n throw 'You must pass an options object';\n }\n if (options.cluster == null) {\n throw 'Options object must provide a cluster';\n }\n if ('disableStats' in options) {\n Logger.warn(\n 'The disableStats option is deprecated in favor of enableStats'\n );\n }\n}\n"],"sourceRoot":""} \ No newline at end of file +{"version":3,"sources":["webpack://Pusher/webpack/universalModuleDefinition","webpack://Pusher/webpack/bootstrap","webpack://Pusher/./node_modules/@stablelib/base64/base64.ts","webpack://Pusher/./node_modules/@stablelib/utf8/utf8.ts","webpack://Pusher/./src/core/pusher.js","webpack://Pusher/./src/runtimes/web/dom/script_receiver_factory.ts","webpack://Pusher/./src/core/defaults.ts","webpack://Pusher/./src/runtimes/web/dom/dependencies.ts","webpack://Pusher/./src/runtimes/web/dom/dependency_loader.ts","webpack://Pusher/./src/core/utils/url_store.ts","webpack://Pusher/./src/core/auth/options.ts","webpack://Pusher/./src/core/errors.ts","webpack://Pusher/./src/runtimes/isomorphic/auth/xhr_auth.ts","webpack://Pusher/./src/core/base64.ts","webpack://Pusher/./src/core/utils/timers/abstract_timer.ts","webpack://Pusher/./src/core/utils/timers/index.ts","webpack://Pusher/./src/core/util.ts","webpack://Pusher/./src/core/utils/collections.ts","webpack://Pusher/./src/core/logger.ts","webpack://Pusher/./src/runtimes/web/auth/jsonp_auth.ts","webpack://Pusher/./src/runtimes/web/dom/script_request.ts","webpack://Pusher/./src/runtimes/web/dom/jsonp_request.ts","webpack://Pusher/./src/runtimes/web/timeline/jsonp_timeline.ts","webpack://Pusher/./src/core/transports/url_schemes.ts","webpack://Pusher/./src/core/events/callback_registry.ts","webpack://Pusher/./src/core/events/dispatcher.ts","webpack://Pusher/./src/core/transports/transport_connection.ts","webpack://Pusher/./src/core/transports/transport.ts","webpack://Pusher/./src/runtimes/isomorphic/transports/transports.ts","webpack://Pusher/./src/runtimes/web/transports/transports.ts","webpack://Pusher/./src/runtimes/web/net_info.ts","webpack://Pusher/./src/core/transports/assistant_to_the_transport_manager.ts","webpack://Pusher/./src/core/connection/protocol/protocol.ts","webpack://Pusher/./src/core/connection/connection.ts","webpack://Pusher/./src/core/connection/handshake/index.ts","webpack://Pusher/./src/core/timeline/timeline_sender.ts","webpack://Pusher/./src/core/channels/channel.ts","webpack://Pusher/./src/core/channels/private_channel.ts","webpack://Pusher/./src/core/channels/members.ts","webpack://Pusher/./src/core/channels/presence_channel.ts","webpack://Pusher/./src/core/channels/encrypted_channel.ts","webpack://Pusher/./src/core/connection/connection_manager.ts","webpack://Pusher/./src/core/channels/channels.ts","webpack://Pusher/./src/core/utils/factory.ts","webpack://Pusher/./src/core/transports/transport_manager.ts","webpack://Pusher/./src/core/strategies/sequential_strategy.ts","webpack://Pusher/./src/core/strategies/best_connected_ever_strategy.ts","webpack://Pusher/./src/core/strategies/websocket_prioritized_cached_strategy.ts","webpack://Pusher/./src/core/strategies/delayed_strategy.ts","webpack://Pusher/./src/core/strategies/if_strategy.ts","webpack://Pusher/./src/core/strategies/first_connected_strategy.ts","webpack://Pusher/./src/runtimes/web/default_strategy.ts","webpack://Pusher/./src/runtimes/web/http/http_xdomain_request.ts","webpack://Pusher/./src/core/http/http_request.ts","webpack://Pusher/./src/core/http/state.ts","webpack://Pusher/./src/core/http/http_socket.ts","webpack://Pusher/./src/core/timeline/level.ts","webpack://Pusher/./src/core/http/http_streaming_socket.ts","webpack://Pusher/./src/core/http/http_polling_socket.ts","webpack://Pusher/./src/runtimes/isomorphic/http/http_xhr_request.ts","webpack://Pusher/./src/runtimes/isomorphic/http/http.ts","webpack://Pusher/./src/runtimes/web/http/http.ts","webpack://Pusher/./src/runtimes/web/runtime.ts","webpack://Pusher/./src/runtimes/web/transports/transport_connection_initializer.ts","webpack://Pusher/./src/core/timeline/timeline.ts","webpack://Pusher/./src/core/strategies/transport_strategy.ts","webpack://Pusher/./src/core/strategies/strategy_builder.ts","webpack://Pusher/./src/core/auth/user_authenticator.ts","webpack://Pusher/./src/core/auth/channel_authorizer.ts","webpack://Pusher/./src/core/config.ts","webpack://Pusher/./src/core/auth/deprecated_channel_authorizer.ts","webpack://Pusher/./src/core/watchlist.ts","webpack://Pusher/./src/core/utils/flat_promise.ts","webpack://Pusher/./src/core/user.ts","webpack://Pusher/./src/core/pusher.ts","webpack://Pusher/./src/core/options.ts"],"names":["root","factory","exports","module","define","amd","window","installedModules","__webpack_require__","moduleId","i","l","modules","call","m","c","d","name","getter","o","Object","defineProperty","enumerable","get","r","Symbol","toStringTag","value","t","mode","__esModule","ns","create","key","bind","n","object","property","prototype","hasOwnProperty","p","s","_paddingCharacter","encodedLength","length","this","encode","data","out","_encodeByte","left","maxDecodedLength","decodedLength","_getPaddingLength","decode","Uint8Array","paddingLength","op","haveBad","v0","v1","v2","v3","_decodeChar","charCodeAt","Error","b","result","String","fromCharCode","Coder","stdCoder","URLSafeCoder","urlSafeCoder","INVALID_UTF8","arr","pos","chars","min","n1","n2","n3","push","join","default","ScriptReceiverFactory","prefix","lastId","callback","number","id","called","callbackWrapper","apply","arguments","receiver","ScriptReceivers","VERSION","PROTOCOL","wsPort","wssPort","wsPath","httpHost","httpPort","httpsPort","httpPath","stats_host","authEndpoint","authTransport","activityTimeout","pongTimeout","unavailableTimeout","userAuthentication","endpoint","transport","channelAuthorization","cdn_http","cdn_https","dependency_suffix","DependenciesReceivers","Dependencies","options","receivers","loading","self","request","createScriptRequest","getPath","error","remove","callbacks","successCallback","wasSuccessful","cleanup","send","protocol","getDocument","location","useTLS","replace","version","getRoot","suffix","urlStore","baseUrl","urls","authenticationEndpoint","path","authorizationEndpoint","javascriptQuickStart","triggeringClientEvents","encryptedChannelSupport","fullUrl","AuthRequestType","urlObj","url","BadEventName","msg","super","setPrototypeOf","BadChannelName","RequestTimedOut","TransportPriorityTooLow","TransportClosed","UnsupportedFeature","UnsupportedTransport","UnsupportedStrategy","HTTPAuthError","status","context","query","authOptions","authRequestType","xhr","createXHR","headerName","open","setRequestHeader","headers","headersProvider","dynamicHeaders","onreadystatechange","readyState","parsed","JSON","parse","responseText","e","toString","UserAuthentication","ChannelAuthorization","b64chars","b64tab","charAt","cb_utob","cc","utob","u","cb_encode","ccc","padlen","ord","btoa","set","clear","delay","timer","clearTimeout","clearInterval","setTimeout","setInterval","now","Date","valueOf","defer","args","boundArguments","Array","slice","concat","extend","target","sources","extensions","constructor","stringify","safeJSONStringify","arrayIndexOf","array","item","nativeIndexOf","indexOf","objectApply","f","keys","_","map","filter","test","filterObject","Boolean","any","encodeParamsObject","encodeURIComponent","buildQueryString","params","undefined","method","source","objects","paths","derez","nu","$ref","globalLog","message","console","log","globalLogWarn","globalLogError","warn","defaultLoggingFunction","logToConsole","callbackName","nextAuthCallbackID","document","script","createElement","auth_callbacks","callback_name","src","head","getElementsByTagName","documentElement","insertBefore","firstChild","ScriptRequest","errorString","type","charset","addEventListener","onerror","onload","async","attachEvent","navigator","userAgent","errorScript","text","nextSibling","parentNode","removeChild","getAgent","sender","host","createJSONPRequest","getGenericURL","baseScheme","hostTLS","hostNonTLS","getGenericPath","queryString","ws","getInitial","http","sockjs","_callbacks","prefixedEventName","fn","names","removeCallback","removeAllCallbacks","binding","failThrough","global_callbacks","eventName","add","unbind","unbind_global","metadata","hooks","priority","initialize","transportConnectionInitializer","state","timeline","generateUniqueID","handlesActivityChecks","supportsPing","socket","getSocket","onError","changeState","bindListeners","debug","close","ping","beforeOpen","onopen","emit","buildTimelineMessage","closeEvent","code","reason","wasClean","unbindListeners","onOpen","onclose","onClose","onmessage","onMessage","onactivity","onActivity","info","cid","environment","isSupported","WSTransport","isInitialized","getWebSocketAPI","createWebSocket","httpConfiguration","streamingConfiguration","HTTPFactory","createStreamingSocket","pollingConfiguration","createPollingSocket","xhrConfiguration","isXHRSupported","xhr_streaming","xhr_polling","SockJSTransport","file","SockJS","js_path","ignore_null_origin","ignoreNullOrigin","xdrConfiguration","isXDRSupported","XDRStreamingTransport","XDRPollingTransport","xdr_streaming","xdr_polling","onLine","manager","minPingDelay","maxPingDelay","pingDelay","connection","createConnection","openTimestamp","onClosed","reportDeath","lifespan","Math","max","isAlive","Protocol","decodeMessage","messageEvent","messageData","pusherEventData","pusherEvent","event","channel","user_id","encodeMessage","processHandshake","activity_timeout","action","socket_id","getCloseAction","getCloseError","send_event","listeners","activity","closed","handleCloseEvent","listener","finish","isEmpty","TimelineTransport","pusher","subscribed","subscriptionPending","subscriptionCancelled","socketId","auth","handleSubscriptionSucceededEvent","handleSubscriptionCountEvent","unsubscribe","subscription_count","subscriptionCount","authorize","assign","channel_data","config","channelAuthorizer","channelName","reset","members","member","myID","subscriptionData","presence","hash","count","me","memberData","user_info","authData","channelData","setMyID","user","signinDonePromise","user_data","handleInternalEvent","addedMember","addMember","removedMember","removeMember","onSubscription","disconnect","nacl","sharedSecret","handleEncryptedEvent","handleEvent","ciphertext","nonce","cipherText","secretbox","overheadLength","nonceLength","bytes","getDataToEmit","raw","usingTLS","errorCallbacks","buildErrorCallbacks","connectionCallbacks","buildConnectionCallbacks","handshakeCallbacks","buildHandshakeCallbacks","Network","getNetwork","netinfo","retryIn","sendActivityCheck","updateStrategy","runner","strategy","updateState","startConnecting","setUnavailableTimer","disconnectInternally","handshake","connect","handshakeError","abortConnecting","abort","clearRetryTimer","clearUnavailableTimer","abandonConnection","getStrategy","round","retryTimer","ensureAborted","unavailableTimer","stopActivityCheck","activityTimer","pong_timed_out","resetActivityCheck","shouldRetry","connected","Infinity","setConnection","withErrorEmitted","tls_only","refused","backoff","retry","newState","previousState","newStateDescription","previous","current","channels","createEncryptedChannel","errMsg","createPrivateChannel","createPresenceChannel","createChannel","values","createChannels","createConnectionManager","createTimelineSender","createHandshake","createAssistantToTheTransportManager","livesLeft","lives","strategies","loop","failFast","timeout","timeoutLimit","minPriority","tryNextStrategy","tryStrategy","forceMinPriority","isRunning","callbackBuilder","runners","rs","abortRunner","allRunnersFailed","aborted","transports","ttl","storage","getLocalStorage","serializedCache","getTransportCacheKey","flushTransportCache","fetchTransportCache","cacheSkipCount","timestamp","includes","cached","latency","startTimestamp","pop","cb","storeTransportCache","IfStrategy","trueBranch","falseBranch","FirstConnectedStrategy","testSupportsStrategy","baseOptions","defineTransport","definedTransports","defineTransportStrategy","wsStrategy","ws_options","wsHost","wss_options","sockjs_options","timeouts","ws_manager","streaming_manager","ws_transport","wss_transport","sockjs_transport","xhr_streaming_transport","xdr_streaming_transport","xhr_polling_transport","xdr_polling_transport","ws_loop","wss_loop","sockjs_loop","streaming_loop","polling_loop","http_loop","http_fallback_loop","getRequest","xdr","XDomainRequest","ontimeout","onprogress","onChunk","abortRequest","payload","position","unloader","addUnloadListener","removeUnloadListener","chunk","advanceBuffer","isBufferTooLong","buffer","unreadData","endOfLinePosition","State","autoIncrement","getUniqueURL","separator","randomNumber","randomInt","TimelineLevel","session","randomString","parts","exec","base","getLocation","CONNECTING","openStream","sendRaw","sendHeartbeat","OPEN","createSocketRequest","start","closeStream","CLOSED","onEvent","onHeartbeat","hostname","urlParts","stream","getReceiveURL","onFinished","reconnect","unbind_all","getXHRAPI","createSocket","createRequest","getDefaultStrategy","Transports","load","XMLHttpRequest","WebSocket","MozWebSocket","PusherClass","Pusher","initializeOnDocumentBody","onDocumentBody","ready","getAuthorizers","ajax","jsonp","body","localStorage","createXMLHttpRequest","createMicrosoftXHR","ActiveXObject","createXDR","Constructor","withCredentials","documentProtocol","getProtocol","removeEventListener","detachEvent","floor","crypto","getRandomValues","Uint32Array","events","sent","uniqueID","level","limit","shift","ERROR","INFO","DEBUG","sendfn","bundle","lib","cluster","features","failAttempt","onInitialized","serializedTransport","transportClass","enabledTransports","disabledTransports","getAssistant","deferred","paramsProvider","dynamicParams","composeChannelQuery","getConfig","opts","statsHost","enableStats","getEnableStatsConfig","getHttpHost","shouldUseTLS","getWebsocketHost","userAuthenticator","buildUserAuthenticator","buildChannelAuthorizer","timelineParams","forceTLS","disableStats","customHandler","channelAuthorizerGenerator","deprecatedAuthorizerOptions","ChannelAuthorizerProxy","authorizer","buildChannelAuth","bindWatchlistInternalEvent","forEach","watchlistEvent","resolve","reject","promise","Promise","res","rej","signin_requested","serverToUserChannel","_signinDoneResolve","_onAuthorize","err","_cleanup","_signin","_newSigninPromiseIfNeeded","watchlist","_onSigninSuccess","_subscribeChannels","bind_global","reinstateSubscription","subscribe","ensure_subscribed","done","setDone","then","catch","isReady","instances","app_key","checkAppKey","validateOptions","global_emitter","sessionID","getClientFeatures","timelineSender","subscribeAll","isUsingTLS","internal","appKey","switchCluster","find","all","timelineSenderTimer","event_name","channel_name","cancelSubscription","signin","Runtime","setup"],"mappings":";;;;;;;CAAA,SAA2CA,EAAMC,GAC1B,iBAAZC,SAA0C,iBAAXC,OACxCA,OAAOD,QAAUD,IACQ,mBAAXG,QAAyBA,OAAOC,IAC9CD,OAAO,GAAIH,GACe,iBAAZC,QACdA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UAAsB,GACtB,GAAAD,SAAmB,EACnB,GAAAjf,cAAwB,EAGxB,GAAAsgB,QAA2B,GAC3B,GAAA5qB,gBAA6B,GAASA,gBACtC,GAAAuB,sBAAmC,GAASA,sBAC5C,GAAAqJ,eAA4B,GAASA,eAVzB,oBAkPrB,GAAQigB,MAAM","file":"pusher.min.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"Pusher\"] = factory();\n\telse\n\t\troot[\"Pusher\"] = factory();\n})(window, function() {\nreturn "," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 2);\n","// Copyright (C) 2016 Dmitry Chestnykh\n// MIT License. See LICENSE file for details.\n\n/**\n * Package base64 implements Base64 encoding and decoding.\n */\n\n// Invalid character used in decoding to indicate\n// that the character to decode is out of range of\n// alphabet and cannot be decoded.\nconst INVALID_BYTE = 256;\n\n/**\n * Implements standard Base64 encoding.\n *\n * Operates in constant time.\n */\nexport class Coder {\n // TODO(dchest): methods to encode chunk-by-chunk.\n\n constructor(private _paddingCharacter = \"=\") { }\n\n encodedLength(length: number): number {\n if (!this._paddingCharacter) {\n return (length * 8 + 5) / 6 | 0;\n }\n return (length + 2) / 3 * 4 | 0;\n }\n\n encode(data: Uint8Array): string {\n let out = \"\";\n\n let i = 0;\n for (; i < data.length - 2; i += 3) {\n let c = (data[i] << 16) | (data[i + 1] << 8) | (data[i + 2]);\n out += this._encodeByte((c >>> 3 * 6) & 63);\n out += this._encodeByte((c >>> 2 * 6) & 63);\n out += this._encodeByte((c >>> 1 * 6) & 63);\n out += this._encodeByte((c >>> 0 * 6) & 63);\n }\n\n const left = data.length - i;\n if (left > 0) {\n let c = (data[i] << 16) | (left === 2 ? data[i + 1] << 8 : 0);\n out += this._encodeByte((c >>> 3 * 6) & 63);\n out += this._encodeByte((c >>> 2 * 6) & 63);\n if (left === 2) {\n out += this._encodeByte((c >>> 1 * 6) & 63);\n } else {\n out += this._paddingCharacter || \"\";\n }\n out += this._paddingCharacter || \"\";\n }\n\n return out;\n }\n\n maxDecodedLength(length: number): number {\n if (!this._paddingCharacter) {\n return (length * 6 + 7) / 8 | 0;\n }\n return length / 4 * 3 | 0;\n }\n\n decodedLength(s: string): number {\n return this.maxDecodedLength(s.length - this._getPaddingLength(s));\n }\n\n decode(s: string): Uint8Array {\n if (s.length === 0) {\n return new Uint8Array(0);\n }\n const paddingLength = this._getPaddingLength(s);\n const length = s.length - paddingLength;\n const out = new Uint8Array(this.maxDecodedLength(length));\n let op = 0;\n let i = 0;\n let haveBad = 0;\n let v0 = 0, v1 = 0, v2 = 0, v3 = 0;\n for (; i < length - 4; i += 4) {\n v0 = this._decodeChar(s.charCodeAt(i + 0));\n v1 = this._decodeChar(s.charCodeAt(i + 1));\n v2 = this._decodeChar(s.charCodeAt(i + 2));\n v3 = this._decodeChar(s.charCodeAt(i + 3));\n out[op++] = (v0 << 2) | (v1 >>> 4);\n out[op++] = (v1 << 4) | (v2 >>> 2);\n out[op++] = (v2 << 6) | v3;\n haveBad |= v0 & INVALID_BYTE;\n haveBad |= v1 & INVALID_BYTE;\n haveBad |= v2 & INVALID_BYTE;\n haveBad |= v3 & INVALID_BYTE;\n }\n if (i < length - 1) {\n v0 = this._decodeChar(s.charCodeAt(i));\n v1 = this._decodeChar(s.charCodeAt(i + 1));\n out[op++] = (v0 << 2) | (v1 >>> 4);\n haveBad |= v0 & INVALID_BYTE;\n haveBad |= v1 & INVALID_BYTE;\n }\n if (i < length - 2) {\n v2 = this._decodeChar(s.charCodeAt(i + 2));\n out[op++] = (v1 << 4) | (v2 >>> 2);\n haveBad |= v2 & INVALID_BYTE;\n }\n if (i < length - 3) {\n v3 = this._decodeChar(s.charCodeAt(i + 3));\n out[op++] = (v2 << 6) | v3;\n haveBad |= v3 & INVALID_BYTE;\n }\n if (haveBad !== 0) {\n throw new Error(\"Base64Coder: incorrect characters for decoding\");\n }\n return out;\n }\n\n // Standard encoding have the following encoded/decoded ranges,\n // which we need to convert between.\n //\n // ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 0123456789 + /\n // Index: 0 - 25 26 - 51 52 - 61 62 63\n // ASCII: 65 - 90 97 - 122 48 - 57 43 47\n //\n\n // Encode 6 bits in b into a new character.\n protected _encodeByte(b: number): string {\n // Encoding uses constant time operations as follows:\n //\n // 1. Define comparison of A with B using (A - B) >>> 8:\n // if A > B, then result is positive integer\n // if A <= B, then result is 0\n //\n // 2. Define selection of C or 0 using bitwise AND: X & C:\n // if X == 0, then result is 0\n // if X != 0, then result is C\n //\n // 3. Start with the smallest comparison (b >= 0), which is always\n // true, so set the result to the starting ASCII value (65).\n //\n // 4. Continue comparing b to higher ASCII values, and selecting\n // zero if comparison isn't true, otherwise selecting a value\n // to add to result, which:\n //\n // a) undoes the previous addition\n // b) provides new value to add\n //\n let result = b;\n // b >= 0\n result += 65;\n // b > 25\n result += ((25 - b) >>> 8) & ((0 - 65) - 26 + 97);\n // b > 51\n result += ((51 - b) >>> 8) & ((26 - 97) - 52 + 48);\n // b > 61\n result += ((61 - b) >>> 8) & ((52 - 48) - 62 + 43);\n // b > 62\n result += ((62 - b) >>> 8) & ((62 - 43) - 63 + 47);\n\n return String.fromCharCode(result);\n }\n\n // Decode a character code into a byte.\n // Must return 256 if character is out of alphabet range.\n protected _decodeChar(c: number): number {\n // Decoding works similar to encoding: using the same comparison\n // function, but now it works on ranges: result is always incremented\n // by value, but this value becomes zero if the range is not\n // satisfied.\n //\n // Decoding starts with invalid value, 256, which is then\n // subtracted when the range is satisfied. If none of the ranges\n // apply, the function returns 256, which is then checked by\n // the caller to throw error.\n let result = INVALID_BYTE; // start with invalid character\n\n // c == 43 (c > 42 and c < 44)\n result += (((42 - c) & (c - 44)) >>> 8) & (-INVALID_BYTE + c - 43 + 62);\n // c == 47 (c > 46 and c < 48)\n result += (((46 - c) & (c - 48)) >>> 8) & (-INVALID_BYTE + c - 47 + 63);\n // c > 47 and c < 58\n result += (((47 - c) & (c - 58)) >>> 8) & (-INVALID_BYTE + c - 48 + 52);\n // c > 64 and c < 91\n result += (((64 - c) & (c - 91)) >>> 8) & (-INVALID_BYTE + c - 65 + 0);\n // c > 96 and c < 123\n result += (((96 - c) & (c - 123)) >>> 8) & (-INVALID_BYTE + c - 97 + 26);\n\n return result;\n }\n\n private _getPaddingLength(s: string): number {\n let paddingLength = 0;\n if (this._paddingCharacter) {\n for (let i = s.length - 1; i >= 0; i--) {\n if (s[i] !== this._paddingCharacter) {\n break;\n }\n paddingLength++;\n }\n if (s.length < 4 || paddingLength > 2) {\n throw new Error(\"Base64Coder: incorrect padding\");\n }\n }\n return paddingLength;\n }\n\n}\n\nconst stdCoder = new Coder();\n\nexport function encode(data: Uint8Array): string {\n return stdCoder.encode(data);\n}\n\nexport function decode(s: string): Uint8Array {\n return stdCoder.decode(s);\n}\n\n/**\n * Implements URL-safe Base64 encoding.\n * (Same as Base64, but '+' is replaced with '-', and '/' with '_').\n *\n * Operates in constant time.\n */\nexport class URLSafeCoder extends Coder {\n // URL-safe encoding have the following encoded/decoded ranges:\n //\n // ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 0123456789 - _\n // Index: 0 - 25 26 - 51 52 - 61 62 63\n // ASCII: 65 - 90 97 - 122 48 - 57 45 95\n //\n\n protected _encodeByte(b: number): string {\n let result = b;\n // b >= 0\n result += 65;\n // b > 25\n result += ((25 - b) >>> 8) & ((0 - 65) - 26 + 97);\n // b > 51\n result += ((51 - b) >>> 8) & ((26 - 97) - 52 + 48);\n // b > 61\n result += ((61 - b) >>> 8) & ((52 - 48) - 62 + 45);\n // b > 62\n result += ((62 - b) >>> 8) & ((62 - 45) - 63 + 95);\n\n return String.fromCharCode(result);\n }\n\n protected _decodeChar(c: number): number {\n let result = INVALID_BYTE;\n\n // c == 45 (c > 44 and c < 46)\n result += (((44 - c) & (c - 46)) >>> 8) & (-INVALID_BYTE + c - 45 + 62);\n // c == 95 (c > 94 and c < 96)\n result += (((94 - c) & (c - 96)) >>> 8) & (-INVALID_BYTE + c - 95 + 63);\n // c > 47 and c < 58\n result += (((47 - c) & (c - 58)) >>> 8) & (-INVALID_BYTE + c - 48 + 52);\n // c > 64 and c < 91\n result += (((64 - c) & (c - 91)) >>> 8) & (-INVALID_BYTE + c - 65 + 0);\n // c > 96 and c < 123\n result += (((96 - c) & (c - 123)) >>> 8) & (-INVALID_BYTE + c - 97 + 26);\n\n return result;\n }\n}\n\nconst urlSafeCoder = new URLSafeCoder();\n\nexport function encodeURLSafe(data: Uint8Array): string {\n return urlSafeCoder.encode(data);\n}\n\nexport function decodeURLSafe(s: string): Uint8Array {\n return urlSafeCoder.decode(s);\n}\n\n\nexport const encodedLength = (length: number) =>\n stdCoder.encodedLength(length);\n\nexport const maxDecodedLength = (length: number) =>\n stdCoder.maxDecodedLength(length);\n\nexport const decodedLength = (s: string) =>\n stdCoder.decodedLength(s);\n","// Copyright (C) 2016 Dmitry Chestnykh\n// MIT License. See LICENSE file for details.\n\n/**\n * Package utf8 implements UTF-8 encoding and decoding.\n */\n\nconst INVALID_UTF16 = \"utf8: invalid string\";\nconst INVALID_UTF8 = \"utf8: invalid source encoding\";\n\n/**\n * Encodes the given string into UTF-8 byte array.\n * Throws if the source string has invalid UTF-16 encoding.\n */\nexport function encode(s: string): Uint8Array {\n // Calculate result length and allocate output array.\n // encodedLength() also validates string and throws errors,\n // so we don't need repeat validation here.\n const arr = new Uint8Array(encodedLength(s));\n\n let pos = 0;\n for (let i = 0; i < s.length; i++) {\n let c = s.charCodeAt(i);\n if (c < 0x80) {\n arr[pos++] = c;\n } else if (c < 0x800) {\n arr[pos++] = 0xc0 | c >> 6;\n arr[pos++] = 0x80 | c & 0x3f;\n } else if (c < 0xd800) {\n arr[pos++] = 0xe0 | c >> 12;\n arr[pos++] = 0x80 | (c >> 6) & 0x3f;\n arr[pos++] = 0x80 | c & 0x3f;\n } else {\n i++; // get one more character\n c = (c & 0x3ff) << 10;\n c |= s.charCodeAt(i) & 0x3ff;\n c += 0x10000;\n\n arr[pos++] = 0xf0 | c >> 18;\n arr[pos++] = 0x80 | (c >> 12) & 0x3f;\n arr[pos++] = 0x80 | (c >> 6) & 0x3f;\n arr[pos++] = 0x80 | c & 0x3f;\n }\n }\n return arr;\n}\n\n/**\n * Returns the number of bytes required to encode the given string into UTF-8.\n * Throws if the source string has invalid UTF-16 encoding.\n */\nexport function encodedLength(s: string): number {\n let result = 0;\n for (let i = 0; i < s.length; i++) {\n const c = s.charCodeAt(i);\n if (c < 0x80) {\n result += 1;\n } else if (c < 0x800) {\n result += 2;\n } else if (c < 0xd800) {\n result += 3;\n } else if (c <= 0xdfff) {\n if (i >= s.length - 1) {\n throw new Error(INVALID_UTF16);\n }\n i++; // \"eat\" next character\n result += 4;\n } else {\n throw new Error(INVALID_UTF16);\n }\n }\n return result;\n}\n\n/**\n * Decodes the given byte array from UTF-8 into a string.\n * Throws if encoding is invalid.\n */\nexport function decode(arr: Uint8Array): string {\n const chars: string[] = [];\n for (let i = 0; i < arr.length; i++) {\n let b = arr[i];\n\n if (b & 0x80) {\n let min;\n if (b < 0xe0) {\n // Need 1 more byte.\n if (i >= arr.length) {\n throw new Error(INVALID_UTF8);\n }\n const n1 = arr[++i];\n if ((n1 & 0xc0) !== 0x80) {\n throw new Error(INVALID_UTF8);\n }\n b = (b & 0x1f) << 6 | (n1 & 0x3f);\n min = 0x80;\n } else if (b < 0xf0) {\n // Need 2 more bytes.\n if (i >= arr.length - 1) {\n throw new Error(INVALID_UTF8);\n }\n const n1 = arr[++i];\n const n2 = arr[++i];\n if ((n1 & 0xc0) !== 0x80 || (n2 & 0xc0) !== 0x80) {\n throw new Error(INVALID_UTF8);\n }\n b = (b & 0x0f) << 12 | (n1 & 0x3f) << 6 | (n2 & 0x3f);\n min = 0x800;\n } else if (b < 0xf8) {\n // Need 3 more bytes.\n if (i >= arr.length - 2) {\n throw new Error(INVALID_UTF8);\n }\n const n1 = arr[++i];\n const n2 = arr[++i];\n const n3 = arr[++i];\n if ((n1 & 0xc0) !== 0x80 || (n2 & 0xc0) !== 0x80 || (n3 & 0xc0) !== 0x80) {\n throw new Error(INVALID_UTF8);\n }\n b = (b & 0x0f) << 18 | (n1 & 0x3f) << 12 | (n2 & 0x3f) << 6 | (n3 & 0x3f);\n min = 0x10000;\n } else {\n throw new Error(INVALID_UTF8);\n }\n\n if (b < min || (b >= 0xd800 && b <= 0xdfff)) {\n throw new Error(INVALID_UTF8);\n }\n\n if (b >= 0x10000) {\n // Surrogate pair.\n if (b > 0x10ffff) {\n throw new Error(INVALID_UTF8);\n }\n b -= 0x10000;\n chars.push(String.fromCharCode(0xd800 | (b >> 10)));\n b = 0xdc00 | (b & 0x3ff);\n }\n }\n\n chars.push(String.fromCharCode(b));\n }\n return chars.join(\"\");\n}\n","// required so we don't have to do require('pusher').default etc.\nmodule.exports = require('./pusher').default;\n","import ScriptReceiver from './script_receiver';\n\n/** Builds receivers for JSONP and Script requests.\n *\n * Each receiver is an object with following fields:\n * - number - unique (for the factory instance), numerical id of the receiver\n * - id - a string ID that can be used in DOM attributes\n * - name - name of the function triggering the receiver\n * - callback - callback function\n *\n * Receivers are triggered only once, on the first callback call.\n *\n * Receivers can be called by their name or by accessing factory object\n * by the number key.\n *\n * @param {String} prefix the prefix used in ids\n * @param {String} name the name of the object\n */\nexport class ScriptReceiverFactory {\n lastId: number;\n prefix: string;\n name: string;\n\n constructor(prefix: string, name: string) {\n this.lastId = 0;\n this.prefix = prefix;\n this.name = name;\n }\n\n create(callback: Function): ScriptReceiver {\n this.lastId++;\n\n var number = this.lastId;\n var id = this.prefix + number;\n var name = this.name + '[' + number + ']';\n\n var called = false;\n var callbackWrapper = function() {\n if (!called) {\n callback.apply(null, arguments);\n called = true;\n }\n };\n\n this[number] = callbackWrapper;\n return { number: number, id: id, name: name, callback: callbackWrapper };\n }\n\n remove(receiver: ScriptReceiver) {\n delete this[receiver.number];\n }\n}\n\nexport var ScriptReceivers = new ScriptReceiverFactory(\n '_pusher_script_',\n 'Pusher.ScriptReceivers'\n);\n","import {\n ChannelAuthorizationOptions,\n UserAuthenticationOptions\n} from './auth/options';\nimport { AuthTransport } from './config';\n\nexport interface DefaultConfig {\n VERSION: string;\n PROTOCOL: number;\n wsPort: number;\n wssPort: number;\n wsPath: string;\n httpHost: string;\n httpPort: number;\n httpsPort: number;\n httpPath: string;\n stats_host: string;\n authEndpoint: string;\n authTransport: AuthTransport;\n activityTimeout: number;\n pongTimeout: number;\n unavailableTimeout: number;\n userAuthentication: UserAuthenticationOptions;\n channelAuthorization: ChannelAuthorizationOptions;\n\n cdn_http?: string;\n cdn_https?: string;\n dependency_suffix?: string;\n}\n\nvar Defaults: DefaultConfig = {\n VERSION: VERSION,\n PROTOCOL: 7,\n\n wsPort: 80,\n wssPort: 443,\n wsPath: '',\n // DEPRECATED: SockJS fallback parameters\n httpHost: 'sockjs.pusher.com',\n httpPort: 80,\n httpsPort: 443,\n httpPath: '/pusher',\n // DEPRECATED: Stats\n stats_host: 'stats.pusher.com',\n // DEPRECATED: Other settings\n authEndpoint: '/pusher/auth',\n authTransport: 'ajax',\n activityTimeout: 120000,\n pongTimeout: 30000,\n unavailableTimeout: 10000,\n userAuthentication: {\n endpoint: '/pusher/user-auth',\n transport: 'ajax'\n },\n channelAuthorization: {\n endpoint: '/pusher/auth',\n transport: 'ajax'\n },\n\n // CDN configuration\n cdn_http: CDN_HTTP,\n cdn_https: CDN_HTTPS,\n dependency_suffix: DEPENDENCY_SUFFIX\n};\n\nexport default Defaults;\n","import { ScriptReceiverFactory } from './script_receiver_factory';\nimport Defaults from 'core/defaults';\nimport DependencyLoader from './dependency_loader';\n\nexport var DependenciesReceivers = new ScriptReceiverFactory(\n '_pusher_dependencies',\n 'Pusher.DependenciesReceivers'\n);\n\nexport var Dependencies = new DependencyLoader({\n cdn_http: Defaults.cdn_http,\n cdn_https: Defaults.cdn_https,\n version: Defaults.VERSION,\n suffix: Defaults.dependency_suffix,\n receivers: DependenciesReceivers\n});\n","import {\n ScriptReceivers,\n ScriptReceiverFactory\n} from './script_receiver_factory';\nimport Runtime from 'runtime';\nimport ScriptRequest from './script_request';\n\n/** Handles loading dependency files.\n *\n * Dependency loaders don't remember whether a resource has been loaded or\n * not. It is caller's responsibility to make sure the resource is not loaded\n * twice. This is because it's impossible to detect resource loading status\n * without knowing its content.\n *\n * Options:\n * - cdn_http - url to HTTP CND\n * - cdn_https - url to HTTPS CDN\n * - version - version of pusher-js\n * - suffix - suffix appended to all names of dependency files\n *\n * @param {Object} options\n */\nexport default class DependencyLoader {\n options: any;\n receivers: ScriptReceiverFactory;\n loading: any;\n\n constructor(options: any) {\n this.options = options;\n this.receivers = options.receivers || ScriptReceivers;\n this.loading = {};\n }\n\n /** Loads the dependency from CDN.\n *\n * @param {String} name\n * @param {Function} callback\n */\n load(name: string, options: any, callback: Function) {\n var self = this;\n\n if (self.loading[name] && self.loading[name].length > 0) {\n self.loading[name].push(callback);\n } else {\n self.loading[name] = [callback];\n\n var request = Runtime.createScriptRequest(self.getPath(name, options));\n var receiver = self.receivers.create(function(error) {\n self.receivers.remove(receiver);\n\n if (self.loading[name]) {\n var callbacks = self.loading[name];\n delete self.loading[name];\n\n var successCallback = function(wasSuccessful) {\n if (!wasSuccessful) {\n request.cleanup();\n }\n };\n for (var i = 0; i < callbacks.length; i++) {\n callbacks[i](error, successCallback);\n }\n }\n });\n request.send(receiver);\n }\n }\n\n /** Returns a root URL for pusher-js CDN.\n *\n * @returns {String}\n */\n getRoot(options: any): string {\n var cdn;\n var protocol = Runtime.getDocument().location.protocol;\n if ((options && options.useTLS) || protocol === 'https:') {\n cdn = this.options.cdn_https;\n } else {\n cdn = this.options.cdn_http;\n }\n // make sure there are no double slashes\n return cdn.replace(/\\/*$/, '') + '/' + this.options.version;\n }\n\n /** Returns a full path to a dependency file.\n *\n * @param {String} name\n * @returns {String}\n */\n getPath(name: string, options: any): string {\n return this.getRoot(options) + '/' + name + this.options.suffix + '.js';\n }\n}\n","/**\n * A place to store help URLs for error messages etc\n */\n\nconst urlStore = {\n baseUrl: 'https://pusher.com',\n urls: {\n authenticationEndpoint: {\n path: '/docs/channels/server_api/authenticating_users'\n },\n authorizationEndpoint: {\n path: '/docs/channels/server_api/authorizing-users/'\n },\n javascriptQuickStart: {\n path: '/docs/javascript_quick_start'\n },\n triggeringClientEvents: {\n path: '/docs/client_api_guide/client_events#trigger-events'\n },\n encryptedChannelSupport: {\n fullUrl:\n 'https://github.com/pusher/pusher-js/tree/cc491015371a4bde5743d1c87a0fbac0feb53195#encrypted-channel-support'\n }\n }\n};\n\n/** Builds a consistent string with links to pusher documentation\n *\n * @param {string} key - relevant key in the url_store.urls object\n * @return {string} suffix string to append to log message\n */\nconst buildLogSuffix = function(key: string): string {\n const urlPrefix = 'See:';\n const urlObj = urlStore.urls[key];\n if (!urlObj) return '';\n\n let url;\n if (urlObj.fullUrl) {\n url = urlObj.fullUrl;\n } else if (urlObj.path) {\n url = urlStore.baseUrl + urlObj.path;\n }\n\n if (!url) return '';\n return `${urlPrefix} ${url}`;\n};\n\nexport default { buildLogSuffix };\n","export enum AuthRequestType {\n UserAuthentication = 'user-authentication',\n ChannelAuthorization = 'channel-authorization'\n}\n\nexport interface ChannelAuthorizationData {\n auth: string;\n channel_data?: string;\n shared_secret?: string;\n}\n\nexport type ChannelAuthorizationCallback = (\n error: Error | null,\n authData: ChannelAuthorizationData | null\n) => void;\n\nexport interface ChannelAuthorizationRequestParams {\n socketId: string;\n channelName: string;\n}\n\nexport interface ChannelAuthorizationHandler {\n (\n params: ChannelAuthorizationRequestParams,\n callback: ChannelAuthorizationCallback\n ): void;\n}\n\nexport interface UserAuthenticationData {\n auth: string;\n user_data: string;\n}\n\nexport type UserAuthenticationCallback = (\n error: Error | null,\n authData: UserAuthenticationData | null\n) => void;\n\nexport interface UserAuthenticationRequestParams {\n socketId: string;\n}\n\nexport interface UserAuthenticationHandler {\n (\n params: UserAuthenticationRequestParams,\n callback: UserAuthenticationCallback\n ): void;\n}\n\nexport type AuthTransportCallback =\n | ChannelAuthorizationCallback\n | UserAuthenticationCallback;\n\nexport interface AuthOptionsT {\n transport: 'ajax' | 'jsonp';\n endpoint: string;\n params?: any;\n headers?: any;\n paramsProvider?: () => any;\n headersProvider?: () => any;\n customHandler?: AuthHandler;\n}\n\nexport declare type UserAuthenticationOptions = AuthOptionsT<\n UserAuthenticationHandler\n>;\nexport declare type ChannelAuthorizationOptions = AuthOptionsT<\n ChannelAuthorizationHandler\n>;\n\nexport interface InternalAuthOptions {\n transport: 'ajax' | 'jsonp';\n endpoint: string;\n params?: any;\n headers?: any;\n paramsProvider?: () => any;\n headersProvider?: () => any;\n}\n","/** Error classes used throughout the library. */\n// https://github.com/Microsoft/TypeScript-wiki/blob/master/Breaking-Changes.md#extending-built-ins-like-error-array-and-map-may-no-longer-work\nexport class BadEventName extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\nexport class BadChannelName extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\nexport class RequestTimedOut extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class TransportPriorityTooLow extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class TransportClosed extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class UnsupportedFeature extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class UnsupportedTransport extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class UnsupportedStrategy extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class HTTPAuthError extends Error {\n status: number;\n constructor(status: number, msg?: string) {\n super(msg);\n this.status = status;\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n","import TimelineSender from 'core/timeline/timeline_sender';\nimport * as Collections from 'core/utils/collections';\nimport Util from 'core/util';\nimport Runtime from 'runtime';\nimport { AuthTransport } from 'core/auth/auth_transports';\nimport AbstractRuntime from 'runtimes/interface';\nimport UrlStore from 'core/utils/url_store';\nimport {\n AuthRequestType,\n AuthTransportCallback,\n InternalAuthOptions\n} from 'core/auth/options';\nimport { HTTPAuthError } from 'core/errors';\n\nconst ajax: AuthTransport = function(\n context: AbstractRuntime,\n query: string,\n authOptions: InternalAuthOptions,\n authRequestType: AuthRequestType,\n callback: AuthTransportCallback\n) {\n const xhr = Runtime.createXHR();\n xhr.open('POST', authOptions.endpoint, true);\n\n // add request headers\n xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');\n for (var headerName in authOptions.headers) {\n xhr.setRequestHeader(headerName, authOptions.headers[headerName]);\n }\n if (authOptions.headersProvider != null) {\n let dynamicHeaders = authOptions.headersProvider();\n for (var headerName in dynamicHeaders) {\n xhr.setRequestHeader(headerName, dynamicHeaders[headerName]);\n }\n }\n\n xhr.onreadystatechange = function() {\n if (xhr.readyState === 4) {\n if (xhr.status === 200) {\n let data;\n let parsed = false;\n\n try {\n data = JSON.parse(xhr.responseText);\n parsed = true;\n } catch (e) {\n callback(\n new HTTPAuthError(\n 200,\n `JSON returned from ${authRequestType.toString()} endpoint was invalid, yet status code was 200. Data was: ${\n xhr.responseText\n }`\n ),\n null\n );\n }\n\n if (parsed) {\n // prevents double execution.\n callback(null, data);\n }\n } else {\n let suffix = '';\n switch (authRequestType) {\n case AuthRequestType.UserAuthentication:\n suffix = UrlStore.buildLogSuffix('authenticationEndpoint');\n break;\n case AuthRequestType.ChannelAuthorization:\n suffix = `Clients must be authorized to join private or presence channels. ${UrlStore.buildLogSuffix(\n 'authorizationEndpoint'\n )}`;\n break;\n }\n callback(\n new HTTPAuthError(\n xhr.status,\n `Unable to retrieve auth string from ${authRequestType.toString()} endpoint - ` +\n `received status: ${xhr.status} from ${authOptions.endpoint}. ${suffix}`\n ),\n null\n );\n }\n }\n };\n\n xhr.send(query);\n return xhr;\n};\n\nexport default ajax;\n","export default function encode(s: any): string {\n return btoa(utob(s));\n}\n\nvar fromCharCode = String.fromCharCode;\n\nvar b64chars =\n 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';\nvar b64tab = {};\n\nfor (var i = 0, l = b64chars.length; i < l; i++) {\n b64tab[b64chars.charAt(i)] = i;\n}\n\nvar cb_utob = function(c) {\n var cc = c.charCodeAt(0);\n return cc < 0x80\n ? c\n : cc < 0x800\n ? fromCharCode(0xc0 | (cc >>> 6)) + fromCharCode(0x80 | (cc & 0x3f))\n : fromCharCode(0xe0 | ((cc >>> 12) & 0x0f)) +\n fromCharCode(0x80 | ((cc >>> 6) & 0x3f)) +\n fromCharCode(0x80 | (cc & 0x3f));\n};\n\nvar utob = function(u) {\n return u.replace(/[^\\x00-\\x7F]/g, cb_utob);\n};\n\nvar cb_encode = function(ccc) {\n var padlen = [0, 2, 1][ccc.length % 3];\n var ord =\n (ccc.charCodeAt(0) << 16) |\n ((ccc.length > 1 ? ccc.charCodeAt(1) : 0) << 8) |\n (ccc.length > 2 ? ccc.charCodeAt(2) : 0);\n var chars = [\n b64chars.charAt(ord >>> 18),\n b64chars.charAt((ord >>> 12) & 63),\n padlen >= 2 ? '=' : b64chars.charAt((ord >>> 6) & 63),\n padlen >= 1 ? '=' : b64chars.charAt(ord & 63)\n ];\n return chars.join('');\n};\n\nvar btoa =\n global.btoa ||\n function(b) {\n return b.replace(/[\\s\\S]{1,3}/g, cb_encode);\n };\n","import TimedCallback from './timed_callback';\nimport { Delay, Scheduler, Canceller } from './scheduling';\n\nabstract class Timer {\n protected clear: Canceller;\n protected timer: number | void;\n\n constructor(\n set: Scheduler,\n clear: Canceller,\n delay: Delay,\n callback: TimedCallback\n ) {\n this.clear = clear;\n this.timer = set(() => {\n if (this.timer) {\n this.timer = callback(this.timer);\n }\n }, delay);\n }\n\n /** Returns whether the timer is still running.\n *\n * @return {Boolean}\n */\n isRunning(): boolean {\n return this.timer !== null;\n }\n\n /** Aborts a timer when it's running. */\n ensureAborted() {\n if (this.timer) {\n this.clear(this.timer);\n this.timer = null;\n }\n }\n}\n\nexport default Timer;\n","import Timer from './abstract_timer';\nimport TimedCallback from './timed_callback';\nimport { Delay } from './scheduling';\n\n// We need to bind clear functions this way to avoid exceptions on IE8\nfunction clearTimeout(timer) {\n global.clearTimeout(timer);\n}\nfunction clearInterval(timer) {\n global.clearInterval(timer);\n}\n\n/** Cross-browser compatible one-off timer abstraction.\n *\n * @param {Number} delay\n * @param {Function} callback\n */\nexport class OneOffTimer extends Timer {\n constructor(delay: Delay, callback: TimedCallback) {\n super(setTimeout, clearTimeout, delay, function(timer) {\n callback();\n return null;\n });\n }\n}\n\n/** Cross-browser compatible periodic timer abstraction.\n *\n * @param {Number} delay\n * @param {Function} callback\n */\nexport class PeriodicTimer extends Timer {\n constructor(delay: Delay, callback: TimedCallback) {\n super(setInterval, clearInterval, delay, function(timer) {\n callback();\n return timer;\n });\n }\n}\n","import * as Collections from './utils/collections';\nimport TimedCallback from './utils/timers/timed_callback';\nimport { OneOffTimer, PeriodicTimer } from './utils/timers';\n\nvar Util = {\n now(): number {\n if (Date.now) {\n return Date.now();\n } else {\n return new Date().valueOf();\n }\n },\n\n defer(callback: TimedCallback): OneOffTimer {\n return new OneOffTimer(0, callback);\n },\n\n /** Builds a function that will proxy a method call to its first argument.\n *\n * Allows partial application of arguments, so additional arguments are\n * prepended to the argument list.\n *\n * @param {String} name method name\n * @return {Function} proxy function\n */\n method(name: string, ...args: any[]): Function {\n var boundArguments = Array.prototype.slice.call(arguments, 1);\n return function(object) {\n return object[name].apply(object, boundArguments.concat(arguments));\n };\n }\n};\n\nexport default Util;\n","import base64encode from '../base64';\nimport Util from '../util';\n\n/** Merges multiple objects into the target argument.\n *\n * For properties that are plain Objects, performs a deep-merge. For the\n * rest it just copies the value of the property.\n *\n * To extend prototypes use it as following:\n * Pusher.Util.extend(Target.prototype, Base.prototype)\n *\n * You can also use it to merge objects without altering them:\n * Pusher.Util.extend({}, object1, object2)\n *\n * @param {Object} target\n * @return {Object} the target argument\n */\nexport function extend(target: any, ...sources: any[]): T {\n for (var i = 0; i < sources.length; i++) {\n var extensions = sources[i];\n for (var property in extensions) {\n if (\n extensions[property] &&\n extensions[property].constructor &&\n extensions[property].constructor === Object\n ) {\n target[property] = extend(target[property] || {}, extensions[property]);\n } else {\n target[property] = extensions[property];\n }\n }\n }\n return target;\n}\n\nexport function stringify(): string {\n var m = ['Pusher'];\n for (var i = 0; i < arguments.length; i++) {\n if (typeof arguments[i] === 'string') {\n m.push(arguments[i]);\n } else {\n m.push(safeJSONStringify(arguments[i]));\n }\n }\n return m.join(' : ');\n}\n\nexport function arrayIndexOf(array: any[], item: any): number {\n // MSIE doesn't have array.indexOf\n var nativeIndexOf = Array.prototype.indexOf;\n if (array === null) {\n return -1;\n }\n if (nativeIndexOf && array.indexOf === nativeIndexOf) {\n return array.indexOf(item);\n }\n for (var i = 0, l = array.length; i < l; i++) {\n if (array[i] === item) {\n return i;\n }\n }\n return -1;\n}\n\n/** Applies a function f to all properties of an object.\n *\n * Function f gets 3 arguments passed:\n * - element from the object\n * - key of the element\n * - reference to the object\n *\n * @param {Object} object\n * @param {Function} f\n */\nexport function objectApply(object: any, f: Function) {\n for (var key in object) {\n if (Object.prototype.hasOwnProperty.call(object, key)) {\n f(object[key], key, object);\n }\n }\n}\n\n/** Return a list of objects own proerty keys\n *\n * @param {Object} object\n * @returns {Array}\n */\nexport function keys(object: any): string[] {\n var keys = [];\n objectApply(object, function(_, key) {\n keys.push(key);\n });\n return keys;\n}\n\n/** Return a list of object's own property values\n *\n * @param {Object} object\n * @returns {Array}\n */\nexport function values(object: any): any[] {\n var values = [];\n objectApply(object, function(value) {\n values.push(value);\n });\n return values;\n}\n\n/** Applies a function f to all elements of an array.\n *\n * Function f gets 3 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function apply(array: any[], f: Function, context?: any) {\n for (var i = 0; i < array.length; i++) {\n f.call(context || global, array[i], i, array);\n }\n}\n\n/** Maps all elements of the array and returns the result.\n *\n * Function f gets 4 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n * - reference to the destination array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function map(array: any[], f: Function): any[] {\n var result = [];\n for (var i = 0; i < array.length; i++) {\n result.push(f(array[i], i, array, result));\n }\n return result;\n}\n\n/** Maps all elements of the object and returns the result.\n *\n * Function f gets 4 arguments passed:\n * - element from the object\n * - key of the element\n * - reference to the source object\n * - reference to the destination object\n *\n * @param {Object} object\n * @param {Function} f\n */\nexport function mapObject(object: any, f: Function): any {\n var result = {};\n objectApply(object, function(value, key) {\n result[key] = f(value);\n });\n return result;\n}\n\n/** Filters elements of the array using a test function.\n *\n * Function test gets 4 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n * - reference to the destination array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function filter(array: any[], test: Function): any[] {\n test =\n test ||\n function(value) {\n return !!value;\n };\n\n var result = [];\n for (var i = 0; i < array.length; i++) {\n if (test(array[i], i, array, result)) {\n result.push(array[i]);\n }\n }\n return result;\n}\n\n/** Filters properties of the object using a test function.\n *\n * Function test gets 4 arguments passed:\n * - element from the object\n * - key of the element\n * - reference to the source object\n * - reference to the destination object\n *\n * @param {Object} object\n * @param {Function} f\n */\nexport function filterObject(object: Object, test: Function) {\n var result = {};\n objectApply(object, function(value, key) {\n if ((test && test(value, key, object, result)) || Boolean(value)) {\n result[key] = value;\n }\n });\n return result;\n}\n\n/** Flattens an object into a two-dimensional array.\n *\n * @param {Object} object\n * @return {Array} resulting array of [key, value] pairs\n */\nexport function flatten(object: Object): any[] {\n var result = [];\n objectApply(object, function(value, key) {\n result.push([key, value]);\n });\n return result;\n}\n\n/** Checks whether any element of the array passes the test.\n *\n * Function test gets 3 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function any(array: any[], test: Function): boolean {\n for (var i = 0; i < array.length; i++) {\n if (test(array[i], i, array)) {\n return true;\n }\n }\n return false;\n}\n\n/** Checks whether all elements of the array pass the test.\n *\n * Function test gets 3 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function all(array: any[], test: Function): boolean {\n for (var i = 0; i < array.length; i++) {\n if (!test(array[i], i, array)) {\n return false;\n }\n }\n return true;\n}\n\nexport function encodeParamsObject(data): string {\n return mapObject(data, function(value) {\n if (typeof value === 'object') {\n value = safeJSONStringify(value);\n }\n return encodeURIComponent(base64encode(value.toString()));\n });\n}\n\nexport function buildQueryString(data: any): string {\n var params = filterObject(data, function(value) {\n return value !== undefined;\n });\n\n var query = map(\n flatten(encodeParamsObject(params)),\n Util.method('join', '=')\n ).join('&');\n\n return query;\n}\n\n/**\n * See https://github.com/douglascrockford/JSON-js/blob/master/cycle.js\n *\n * Remove circular references from an object. Required for JSON.stringify in\n * React Native, which tends to blow up a lot.\n *\n * @param {any} object\n * @return {any} Decycled object\n */\nexport function decycleObject(object: any): any {\n var objects = [],\n paths = [];\n\n return (function derez(value, path) {\n var i, name, nu;\n\n switch (typeof value) {\n case 'object':\n if (!value) {\n return null;\n }\n for (i = 0; i < objects.length; i += 1) {\n if (objects[i] === value) {\n return { $ref: paths[i] };\n }\n }\n\n objects.push(value);\n paths.push(path);\n\n if (Object.prototype.toString.apply(value) === '[object Array]') {\n nu = [];\n for (i = 0; i < value.length; i += 1) {\n nu[i] = derez(value[i], path + '[' + i + ']');\n }\n } else {\n nu = {};\n for (name in value) {\n if (Object.prototype.hasOwnProperty.call(value, name)) {\n nu[name] = derez(\n value[name],\n path + '[' + JSON.stringify(name) + ']'\n );\n }\n }\n }\n return nu;\n case 'number':\n case 'string':\n case 'boolean':\n return value;\n }\n })(object, '$');\n}\n\n/**\n * Provides a cross-browser and cross-platform way to safely stringify objects\n * into JSON. This is particularly necessary for ReactNative, where circular JSON\n * structures throw an exception.\n *\n * @param {any} source The object to stringify\n * @return {string} The serialized output.\n */\nexport function safeJSONStringify(source: any): string {\n try {\n return JSON.stringify(source);\n } catch (e) {\n return JSON.stringify(decycleObject(source));\n }\n}\n","import { stringify } from './utils/collections';\nimport Pusher from './pusher';\n\nclass Logger {\n debug(...args: any[]) {\n this.log(this.globalLog, args);\n }\n\n warn(...args: any[]) {\n this.log(this.globalLogWarn, args);\n }\n\n error(...args: any[]) {\n this.log(this.globalLogError, args);\n }\n\n private globalLog = (message: string) => {\n if (global.console && global.console.log) {\n global.console.log(message);\n }\n };\n\n private globalLogWarn(message: string) {\n if (global.console && global.console.warn) {\n global.console.warn(message);\n } else {\n this.globalLog(message);\n }\n }\n\n private globalLogError(message: string) {\n if (global.console && global.console.error) {\n global.console.error(message);\n } else {\n this.globalLogWarn(message);\n }\n }\n\n private log(\n defaultLoggingFunction: (message: string) => void,\n ...args: any[]\n ) {\n var message = stringify.apply(this, arguments);\n if (Pusher.log) {\n Pusher.log(message);\n } else if (Pusher.logToConsole) {\n const log = defaultLoggingFunction.bind(this);\n log(message);\n }\n }\n}\n\nexport default new Logger();\n","import Browser from '../browser';\nimport Logger from 'core/logger';\nimport JSONPRequest from '../dom/jsonp_request';\nimport { ScriptReceivers } from '../dom/script_receiver_factory';\nimport { AuthTransport } from 'core/auth/auth_transports';\nimport {\n AuthRequestType,\n AuthTransportCallback,\n InternalAuthOptions\n} from 'core/auth/options';\n\nvar jsonp: AuthTransport = function(\n context: Browser,\n query: string,\n authOptions: InternalAuthOptions,\n authRequestType: AuthRequestType,\n callback: AuthTransportCallback\n) {\n if (\n authOptions.headers !== undefined ||\n authOptions.headersProvider != null\n ) {\n Logger.warn(\n `To send headers with the ${authRequestType.toString()} request, you must use AJAX, rather than JSONP.`\n );\n }\n\n var callbackName = context.nextAuthCallbackID.toString();\n context.nextAuthCallbackID++;\n\n var document = context.getDocument();\n var script = document.createElement('script');\n // Hacked wrapper.\n context.auth_callbacks[callbackName] = function(data) {\n callback(null, data);\n };\n\n var callback_name = \"Pusher.auth_callbacks['\" + callbackName + \"']\";\n script.src =\n authOptions.endpoint +\n '?callback=' +\n encodeURIComponent(callback_name) +\n '&' +\n query;\n\n var head =\n document.getElementsByTagName('head')[0] || document.documentElement;\n head.insertBefore(script, head.firstChild);\n};\n\nexport default jsonp;\n","import ScriptReceiver from './script_receiver';\n\n/** Sends a generic HTTP GET request using a script tag.\n *\n * By constructing URL in a specific way, it can be used for loading\n * JavaScript resources or JSONP requests. It can notify about errors, but\n * only in certain environments. Please take care of monitoring the state of\n * the request yourself.\n *\n * @param {String} src\n */\nexport default class ScriptRequest {\n src: string;\n script: any;\n errorScript: any;\n\n constructor(src: string) {\n this.src = src;\n }\n\n send(receiver: ScriptReceiver) {\n var self = this;\n var errorString = 'Error loading ' + self.src;\n\n self.script = document.createElement('script');\n self.script.id = receiver.id;\n self.script.src = self.src;\n self.script.type = 'text/javascript';\n self.script.charset = 'UTF-8';\n\n if (self.script.addEventListener) {\n self.script.onerror = function() {\n receiver.callback(errorString);\n };\n self.script.onload = function() {\n receiver.callback(null);\n };\n } else {\n self.script.onreadystatechange = function() {\n if (\n self.script.readyState === 'loaded' ||\n self.script.readyState === 'complete'\n ) {\n receiver.callback(null);\n }\n };\n }\n\n // Opera<11.6 hack for missing onerror callback\n if (\n self.script.async === undefined &&\n (document).attachEvent &&\n /opera/i.test(navigator.userAgent)\n ) {\n self.errorScript = document.createElement('script');\n self.errorScript.id = receiver.id + '_error';\n self.errorScript.text = receiver.name + \"('\" + errorString + \"');\";\n self.script.async = self.errorScript.async = false;\n } else {\n self.script.async = true;\n }\n\n var head = document.getElementsByTagName('head')[0];\n head.insertBefore(self.script, head.firstChild);\n if (self.errorScript) {\n head.insertBefore(self.errorScript, self.script.nextSibling);\n }\n }\n\n /** Cleans up the DOM remains of the script request. */\n cleanup() {\n if (this.script) {\n this.script.onload = this.script.onerror = null;\n this.script.onreadystatechange = null;\n }\n if (this.script && this.script.parentNode) {\n this.script.parentNode.removeChild(this.script);\n }\n if (this.errorScript && this.errorScript.parentNode) {\n this.errorScript.parentNode.removeChild(this.errorScript);\n }\n this.script = null;\n this.errorScript = null;\n }\n}\n","import ScriptReceiver from './script_receiver';\nimport ScriptRequest from './script_request';\nimport * as Collections from 'core/utils/collections';\nimport Util from 'core/util';\nimport Runtime from '../runtime';\n\n/** Sends data via JSONP.\n *\n * Data is a key-value map. Its values are JSON-encoded and then passed\n * through base64. Finally, keys and encoded values are appended to the query\n * string.\n *\n * The class itself does not guarantee raising errors on failures, as it's not\n * possible to support such feature on all browsers. Instead, JSONP endpoint\n * should call back in a way that's easy to distinguish from browser calls,\n * for example by passing a second argument to the receiver.\n *\n * @param {String} url\n * @param {Object} data key-value map of data to be submitted\n */\nexport default class JSONPRequest {\n url: string;\n data: any;\n request: ScriptRequest;\n\n constructor(url: string, data: any) {\n this.url = url;\n this.data = data;\n }\n\n /** Sends the actual JSONP request.\n *\n * @param {ScriptReceiver} receiver\n */\n send(receiver: ScriptReceiver) {\n if (this.request) {\n return;\n }\n\n var query = Collections.buildQueryString(this.data);\n var url = this.url + '/' + receiver.number + '?' + query;\n this.request = Runtime.createScriptRequest(url);\n this.request.send(receiver);\n }\n\n /** Cleans up the DOM remains of the JSONP request. */\n cleanup() {\n if (this.request) {\n this.request.cleanup();\n }\n }\n}\n","import TimelineSender from 'core/timeline/timeline_sender';\nimport TimelineTransport from 'core/timeline/timeline_transport';\nimport Browser from 'runtime';\nimport { AuthTransport } from 'core/auth/auth_transports';\nimport { ScriptReceivers } from '../dom/script_receiver_factory';\n\nvar getAgent = function(sender: TimelineSender, useTLS: boolean) {\n return function(data: any, callback: Function) {\n var scheme = 'http' + (useTLS ? 's' : '') + '://';\n var url =\n scheme + (sender.host || sender.options.host) + sender.options.path;\n var request = Browser.createJSONPRequest(url, data);\n\n var receiver = Browser.ScriptReceivers.create(function(error, result) {\n ScriptReceivers.remove(receiver);\n request.cleanup();\n\n if (result && result.host) {\n sender.host = result.host;\n }\n if (callback) {\n callback(error, result);\n }\n });\n request.send(receiver);\n };\n};\n\nvar jsonp = {\n name: 'jsonp',\n getAgent\n};\n\nexport default jsonp;\n","import Defaults from '../defaults';\nimport { default as URLScheme, URLSchemeParams } from './url_scheme';\n\nfunction getGenericURL(\n baseScheme: string,\n params: URLSchemeParams,\n path: string\n): string {\n var scheme = baseScheme + (params.useTLS ? 's' : '');\n var host = params.useTLS ? params.hostTLS : params.hostNonTLS;\n return scheme + '://' + host + path;\n}\n\nfunction getGenericPath(key: string, queryString?: string): string {\n var path = '/app/' + key;\n var query =\n '?protocol=' +\n Defaults.PROTOCOL +\n '&client=js' +\n '&version=' +\n Defaults.VERSION +\n (queryString ? '&' + queryString : '');\n return path + query;\n}\n\nexport var ws: URLScheme = {\n getInitial: function(key: string, params: URLSchemeParams): string {\n var path = (params.httpPath || '') + getGenericPath(key, 'flash=false');\n return getGenericURL('ws', params, path);\n }\n};\n\nexport var http: URLScheme = {\n getInitial: function(key: string, params: URLSchemeParams): string {\n var path = (params.httpPath || '/pusher') + getGenericPath(key);\n return getGenericURL('http', params, path);\n }\n};\n\nexport var sockjs: URLScheme = {\n getInitial: function(key: string, params: URLSchemeParams): string {\n return getGenericURL('http', params, params.httpPath || '/pusher');\n },\n getPath: function(key: string, params: URLSchemeParams): string {\n return getGenericPath(key);\n }\n};\n","import Callback from './callback';\nimport * as Collections from '../utils/collections';\nimport CallbackTable from './callback_table';\n\nexport default class CallbackRegistry {\n _callbacks: CallbackTable;\n\n constructor() {\n this._callbacks = {};\n }\n\n get(name: string): Callback[] {\n return this._callbacks[prefix(name)];\n }\n\n add(name: string, callback: Function, context: any) {\n var prefixedEventName = prefix(name);\n this._callbacks[prefixedEventName] =\n this._callbacks[prefixedEventName] || [];\n this._callbacks[prefixedEventName].push({\n fn: callback,\n context: context\n });\n }\n\n remove(name?: string, callback?: Function, context?: any) {\n if (!name && !callback && !context) {\n this._callbacks = {};\n return;\n }\n\n var names = name ? [prefix(name)] : Collections.keys(this._callbacks);\n\n if (callback || context) {\n this.removeCallback(names, callback, context);\n } else {\n this.removeAllCallbacks(names);\n }\n }\n\n private removeCallback(names: string[], callback: Function, context: any) {\n Collections.apply(\n names,\n function(name) {\n this._callbacks[name] = Collections.filter(\n this._callbacks[name] || [],\n function(binding) {\n return (\n (callback && callback !== binding.fn) ||\n (context && context !== binding.context)\n );\n }\n );\n if (this._callbacks[name].length === 0) {\n delete this._callbacks[name];\n }\n },\n this\n );\n }\n\n private removeAllCallbacks(names: string[]) {\n Collections.apply(\n names,\n function(name) {\n delete this._callbacks[name];\n },\n this\n );\n }\n}\n\nfunction prefix(name: string): string {\n return '_' + name;\n}\n","import * as Collections from '../utils/collections';\nimport Callback from './callback';\nimport Metadata from '../channels/metadata';\nimport CallbackRegistry from './callback_registry';\n\n/** Manages callback bindings and event emitting.\n *\n * @param Function failThrough called when no listeners are bound to an event\n */\nexport default class Dispatcher {\n callbacks: CallbackRegistry;\n global_callbacks: Function[];\n failThrough: Function;\n\n constructor(failThrough?: Function) {\n this.callbacks = new CallbackRegistry();\n this.global_callbacks = [];\n this.failThrough = failThrough;\n }\n\n bind(eventName: string, callback: Function, context?: any) {\n this.callbacks.add(eventName, callback, context);\n return this;\n }\n\n bind_global(callback: Function) {\n this.global_callbacks.push(callback);\n return this;\n }\n\n unbind(eventName?: string, callback?: Function, context?: any) {\n this.callbacks.remove(eventName, callback, context);\n return this;\n }\n\n unbind_global(callback?: Function) {\n if (!callback) {\n this.global_callbacks = [];\n return this;\n }\n\n this.global_callbacks = Collections.filter(\n this.global_callbacks || [],\n c => c !== callback\n );\n\n return this;\n }\n\n unbind_all() {\n this.unbind();\n this.unbind_global();\n return this;\n }\n\n emit(eventName: string, data?: any, metadata?: Metadata): Dispatcher {\n for (var i = 0; i < this.global_callbacks.length; i++) {\n this.global_callbacks[i](eventName, data);\n }\n\n var callbacks = this.callbacks.get(eventName);\n var args = [];\n\n if (metadata) {\n // if there's a metadata argument, we need to call the callback with both\n // data and metadata regardless of whether data is undefined\n args.push(data, metadata);\n } else if (data) {\n // metadata is undefined, so we only need to call the callback with data\n // if data exists\n args.push(data);\n }\n\n if (callbacks && callbacks.length > 0) {\n for (var i = 0; i < callbacks.length; i++) {\n callbacks[i].fn.apply(callbacks[i].context || global, args);\n }\n } else if (this.failThrough) {\n this.failThrough(eventName, data);\n }\n\n return this;\n }\n}\n","import Util from '../util';\nimport * as Collections from '../utils/collections';\nimport { default as EventsDispatcher } from '../events/dispatcher';\nimport Logger from '../logger';\nimport TransportHooks from './transport_hooks';\nimport Socket from '../socket';\nimport Runtime from 'runtime';\nimport Timeline from '../timeline/timeline';\nimport TransportConnectionOptions from './transport_connection_options';\n\n/** Provides universal API for transport connections.\n *\n * Transport connection is a low-level object that wraps a connection method\n * and exposes a simple evented interface for the connection state and\n * messaging. It does not implement Pusher-specific WebSocket protocol.\n *\n * Additionally, it fetches resources needed for transport to work and exposes\n * an interface for querying transport features.\n *\n * States:\n * - new - initial state after constructing the object\n * - initializing - during initialization phase, usually fetching resources\n * - intialized - ready to establish a connection\n * - connection - when connection is being established\n * - open - when connection ready to be used\n * - closed - after connection was closed be either side\n *\n * Emits:\n * - error - after the connection raised an error\n *\n * Options:\n * - useTLS - whether connection should be over TLS\n * - hostTLS - host to connect to when connection is over TLS\n * - hostNonTLS - host to connect to when connection is over TLS\n *\n * @param {String} key application key\n * @param {Object} options\n */\nexport default class TransportConnection extends EventsDispatcher {\n hooks: TransportHooks;\n name: string;\n priority: number;\n key: string;\n options: TransportConnectionOptions;\n state: string;\n timeline: Timeline;\n activityTimeout: number;\n id: number;\n socket: Socket;\n beforeOpen: Function;\n initialize: Function;\n\n constructor(\n hooks: TransportHooks,\n name: string,\n priority: number,\n key: string,\n options: TransportConnectionOptions\n ) {\n super();\n this.initialize = Runtime.transportConnectionInitializer;\n this.hooks = hooks;\n this.name = name;\n this.priority = priority;\n this.key = key;\n this.options = options;\n\n this.state = 'new';\n this.timeline = options.timeline;\n this.activityTimeout = options.activityTimeout;\n this.id = this.timeline.generateUniqueID();\n }\n\n /** Checks whether the transport handles activity checks by itself.\n *\n * @return {Boolean}\n */\n handlesActivityChecks(): boolean {\n return Boolean(this.hooks.handlesActivityChecks);\n }\n\n /** Checks whether the transport supports the ping/pong API.\n *\n * @return {Boolean}\n */\n supportsPing(): boolean {\n return Boolean(this.hooks.supportsPing);\n }\n\n /** Tries to establish a connection.\n *\n * @returns {Boolean} false if transport is in invalid state\n */\n connect(): boolean {\n if (this.socket || this.state !== 'initialized') {\n return false;\n }\n\n var url = this.hooks.urls.getInitial(this.key, this.options);\n try {\n this.socket = this.hooks.getSocket(url, this.options);\n } catch (e) {\n Util.defer(() => {\n this.onError(e);\n this.changeState('closed');\n });\n return false;\n }\n\n this.bindListeners();\n\n Logger.debug('Connecting', { transport: this.name, url });\n this.changeState('connecting');\n return true;\n }\n\n /** Closes the connection.\n *\n * @return {Boolean} true if there was a connection to close\n */\n close(): boolean {\n if (this.socket) {\n this.socket.close();\n return true;\n } else {\n return false;\n }\n }\n\n /** Sends data over the open connection.\n *\n * @param {String} data\n * @return {Boolean} true only when in the \"open\" state\n */\n send(data: any): boolean {\n if (this.state === 'open') {\n // Workaround for MobileSafari bug (see https://gist.github.com/2052006)\n Util.defer(() => {\n if (this.socket) {\n this.socket.send(data);\n }\n });\n return true;\n } else {\n return false;\n }\n }\n\n /** Sends a ping if the connection is open and transport supports it. */\n ping() {\n if (this.state === 'open' && this.supportsPing()) {\n this.socket.ping();\n }\n }\n\n private onOpen() {\n if (this.hooks.beforeOpen) {\n this.hooks.beforeOpen(\n this.socket,\n this.hooks.urls.getPath(this.key, this.options)\n );\n }\n this.changeState('open');\n this.socket.onopen = undefined;\n }\n\n private onError(error) {\n this.emit('error', { type: 'WebSocketError', error: error });\n this.timeline.error(this.buildTimelineMessage({ error: error.toString() }));\n }\n\n private onClose(closeEvent?: any) {\n if (closeEvent) {\n this.changeState('closed', {\n code: closeEvent.code,\n reason: closeEvent.reason,\n wasClean: closeEvent.wasClean\n });\n } else {\n this.changeState('closed');\n }\n this.unbindListeners();\n this.socket = undefined;\n }\n\n private onMessage(message) {\n this.emit('message', message);\n }\n\n private onActivity() {\n this.emit('activity');\n }\n\n private bindListeners() {\n this.socket.onopen = () => {\n this.onOpen();\n };\n this.socket.onerror = error => {\n this.onError(error);\n };\n this.socket.onclose = closeEvent => {\n this.onClose(closeEvent);\n };\n this.socket.onmessage = message => {\n this.onMessage(message);\n };\n\n if (this.supportsPing()) {\n this.socket.onactivity = () => {\n this.onActivity();\n };\n }\n }\n\n private unbindListeners() {\n if (this.socket) {\n this.socket.onopen = undefined;\n this.socket.onerror = undefined;\n this.socket.onclose = undefined;\n this.socket.onmessage = undefined;\n if (this.supportsPing()) {\n this.socket.onactivity = undefined;\n }\n }\n }\n\n private changeState(state: string, params?: any) {\n this.state = state;\n this.timeline.info(\n this.buildTimelineMessage({\n state: state,\n params: params\n })\n );\n this.emit(state, params);\n }\n\n buildTimelineMessage(message): any {\n return Collections.extend({ cid: this.id }, message);\n }\n}\n","import Factory from '../utils/factory';\nimport TransportHooks from './transport_hooks';\nimport TransportConnection from './transport_connection';\nimport TransportConnectionOptions from './transport_connection_options';\n\n/** Provides interface for transport connection instantiation.\n *\n * Takes transport-specific hooks as the only argument, which allow checking\n * for transport support and creating its connections.\n *\n * Supported hooks: * - file - the name of the file to be fetched during initialization\n * - urls - URL scheme to be used by transport\n * - handlesActivityCheck - true when the transport handles activity checks\n * - supportsPing - true when the transport has a ping/activity API\n * - isSupported - tells whether the transport is supported in the environment\n * - getSocket - creates a WebSocket-compatible transport socket\n *\n * See transports.js for specific implementations.\n *\n * @param {Object} hooks object containing all needed transport hooks\n */\nexport default class Transport {\n hooks: TransportHooks;\n\n constructor(hooks: TransportHooks) {\n this.hooks = hooks;\n }\n\n /** Returns whether the transport is supported in the environment.\n *\n * @param {Object} envronment te environment details (encryption, settings)\n * @returns {Boolean} true when the transport is supported\n */\n isSupported(environment: any): boolean {\n return this.hooks.isSupported(environment);\n }\n\n /** Creates a transport connection.\n *\n * @param {String} name\n * @param {Number} priority\n * @param {String} key the application key\n * @param {Object} options\n * @returns {TransportConnection}\n */\n createConnection(\n name: string,\n priority: number,\n key: string,\n options: any\n ): TransportConnection {\n return new TransportConnection(this.hooks, name, priority, key, options);\n }\n}\n","import * as URLSchemes from 'core/transports/url_schemes';\nimport URLScheme from 'core/transports/url_scheme';\nimport Transport from 'core/transports/transport';\nimport Util from 'core/util';\nimport * as Collections from 'core/utils/collections';\nimport TransportHooks from 'core/transports/transport_hooks';\nimport TransportsTable from 'core/transports/transports_table';\nimport Runtime from 'runtime';\n\n/** WebSocket transport.\n *\n * Uses native WebSocket implementation, including MozWebSocket supported by\n * earlier Firefox versions.\n */\nvar WSTransport = new Transport({\n urls: URLSchemes.ws,\n handlesActivityChecks: false,\n supportsPing: false,\n\n isInitialized: function() {\n return Boolean(Runtime.getWebSocketAPI());\n },\n isSupported: function(): boolean {\n return Boolean(Runtime.getWebSocketAPI());\n },\n getSocket: function(url) {\n return Runtime.createWebSocket(url);\n }\n});\n\nvar httpConfiguration = {\n urls: URLSchemes.http,\n handlesActivityChecks: false,\n supportsPing: true,\n isInitialized: function() {\n return true;\n }\n};\n\nexport var streamingConfiguration = Collections.extend(\n {\n getSocket: function(url) {\n return Runtime.HTTPFactory.createStreamingSocket(url);\n }\n },\n httpConfiguration\n);\nexport var pollingConfiguration = Collections.extend(\n {\n getSocket: function(url) {\n return Runtime.HTTPFactory.createPollingSocket(url);\n }\n },\n httpConfiguration\n);\n\nvar xhrConfiguration = {\n isSupported: function(): boolean {\n return Runtime.isXHRSupported();\n }\n};\n\n/** HTTP streaming transport using CORS-enabled XMLHttpRequest. */\nvar XHRStreamingTransport = new Transport(\n (\n Collections.extend({}, streamingConfiguration, xhrConfiguration)\n )\n);\n\n/** HTTP long-polling transport using CORS-enabled XMLHttpRequest. */\nvar XHRPollingTransport = new Transport(\n Collections.extend({}, pollingConfiguration, xhrConfiguration)\n);\n\nvar Transports: TransportsTable = {\n ws: WSTransport,\n xhr_streaming: XHRStreamingTransport,\n xhr_polling: XHRPollingTransport\n};\n\nexport default Transports;\n","import {\n default as Transports,\n streamingConfiguration,\n pollingConfiguration\n} from 'isomorphic/transports/transports';\nimport Transport from 'core/transports/transport';\nimport TransportHooks from 'core/transports/transport_hooks';\nimport * as URLSchemes from 'core/transports/url_schemes';\nimport Runtime from 'runtime';\nimport { Dependencies } from '../dom/dependencies';\nimport * as Collections from 'core/utils/collections';\n\nvar SockJSTransport = new Transport({\n file: 'sockjs',\n urls: URLSchemes.sockjs,\n handlesActivityChecks: true,\n supportsPing: false,\n\n isSupported: function() {\n return true;\n },\n isInitialized: function() {\n return window.SockJS !== undefined;\n },\n getSocket: function(url, options) {\n return new window.SockJS(url, null, {\n js_path: Dependencies.getPath('sockjs', {\n useTLS: options.useTLS\n }),\n ignore_null_origin: options.ignoreNullOrigin\n });\n },\n beforeOpen: function(socket, path) {\n socket.send(\n JSON.stringify({\n path: path\n })\n );\n }\n});\n\nvar xdrConfiguration = {\n isSupported: function(environment): boolean {\n var yes = Runtime.isXDRSupported(environment.useTLS);\n return yes;\n }\n};\n\n/** HTTP streaming transport using XDomainRequest (IE 8,9). */\nvar XDRStreamingTransport = new Transport(\n (\n Collections.extend({}, streamingConfiguration, xdrConfiguration)\n )\n);\n\n/** HTTP long-polling transport using XDomainRequest (IE 8,9). */\nvar XDRPollingTransport = new Transport(\n Collections.extend({}, pollingConfiguration, xdrConfiguration)\n);\n\nTransports.xdr_streaming = XDRStreamingTransport;\nTransports.xdr_polling = XDRPollingTransport;\nTransports.sockjs = SockJSTransport;\n\nexport default Transports;\n","import Reachability from 'core/reachability';\nimport { default as EventsDispatcher } from 'core/events/dispatcher';\n\n/** Really basic interface providing network availability info.\n *\n * Emits:\n * - online - when browser goes online\n * - offline - when browser goes offline\n */\nexport class NetInfo extends EventsDispatcher implements Reachability {\n constructor() {\n super();\n var self = this;\n // This is okay, as IE doesn't support this stuff anyway.\n if (window.addEventListener !== undefined) {\n window.addEventListener(\n 'online',\n function() {\n self.emit('online');\n },\n false\n );\n window.addEventListener(\n 'offline',\n function() {\n self.emit('offline');\n },\n false\n );\n }\n }\n\n /** Returns whether browser is online or not\n *\n * Offline means definitely offline (no connection to router).\n * Inverse does NOT mean definitely online (only currently supported in Safari\n * and even there only means the device has a connection to the router).\n *\n * @return {Boolean}\n */\n isOnline(): boolean {\n if (window.navigator.onLine === undefined) {\n return true;\n } else {\n return window.navigator.onLine;\n }\n }\n}\n\nexport var Network = new NetInfo();\n","import Util from '../util';\nimport * as Collections from '../utils/collections';\nimport TransportManager from './transport_manager';\nimport TransportConnection from './transport_connection';\nimport Transport from './transport';\nimport PingDelayOptions from './ping_delay_options';\n\n/** Creates transport connections monitored by a transport manager.\n *\n * When a transport is closed, it might mean the environment does not support\n * it. It's possible that messages get stuck in an intermediate buffer or\n * proxies terminate inactive connections. To combat these problems,\n * assistants monitor the connection lifetime, report unclean exits and\n * adjust ping timeouts to keep the connection active. The decision to disable\n * a transport is the manager's responsibility.\n *\n * @param {TransportManager} manager\n * @param {TransportConnection} transport\n * @param {Object} options\n */\nexport default class AssistantToTheTransportManager {\n manager: TransportManager;\n transport: Transport;\n minPingDelay: number;\n maxPingDelay: number;\n pingDelay: number;\n\n constructor(\n manager: TransportManager,\n transport: Transport,\n options: PingDelayOptions\n ) {\n this.manager = manager;\n this.transport = transport;\n this.minPingDelay = options.minPingDelay;\n this.maxPingDelay = options.maxPingDelay;\n this.pingDelay = undefined;\n }\n\n /** Creates a transport connection.\n *\n * This function has the same API as Transport#createConnection.\n *\n * @param {String} name\n * @param {Number} priority\n * @param {String} key the application key\n * @param {Object} options\n * @returns {TransportConnection}\n */\n createConnection(\n name: string,\n priority: number,\n key: string,\n options: Object\n ): TransportConnection {\n options = Collections.extend({}, options, {\n activityTimeout: this.pingDelay\n });\n var connection = this.transport.createConnection(\n name,\n priority,\n key,\n options\n );\n\n var openTimestamp = null;\n\n var onOpen = function() {\n connection.unbind('open', onOpen);\n connection.bind('closed', onClosed);\n openTimestamp = Util.now();\n };\n var onClosed = closeEvent => {\n connection.unbind('closed', onClosed);\n\n if (closeEvent.code === 1002 || closeEvent.code === 1003) {\n // we don't want to use transports not obeying the protocol\n this.manager.reportDeath();\n } else if (!closeEvent.wasClean && openTimestamp) {\n // report deaths only for short-living transport\n var lifespan = Util.now() - openTimestamp;\n if (lifespan < 2 * this.maxPingDelay) {\n this.manager.reportDeath();\n this.pingDelay = Math.max(lifespan / 2, this.minPingDelay);\n }\n }\n };\n\n connection.bind('open', onOpen);\n return connection;\n }\n\n /** Returns whether the transport is supported in the environment.\n *\n * This function has the same API as Transport#isSupported. Might return false\n * when the manager decides to kill the transport.\n *\n * @param {Object} environment the environment details (encryption, settings)\n * @returns {Boolean} true when the transport is supported\n */\n isSupported(environment: string): boolean {\n return this.manager.isAlive() && this.transport.isSupported(environment);\n }\n}\n","import Action from './action';\nimport { PusherEvent } from './message-types';\n/**\n * Provides functions for handling Pusher protocol-specific messages.\n */\n\nconst Protocol = {\n /**\n * Decodes a message in a Pusher format.\n *\n * The MessageEvent we receive from the transport should contain a pusher event\n * (https://pusher.com/docs/pusher_protocol#events) serialized as JSON in the\n * data field\n *\n * The pusher event may contain a data field too, and it may also be\n * serialised as JSON\n *\n * Throws errors when messages are not parse'able.\n *\n * @param {MessageEvent} messageEvent\n * @return {PusherEvent}\n */\n decodeMessage: function(messageEvent: MessageEvent): PusherEvent {\n try {\n var messageData = JSON.parse(messageEvent.data);\n var pusherEventData = messageData.data;\n if (typeof pusherEventData === 'string') {\n try {\n pusherEventData = JSON.parse(messageData.data);\n } catch (e) {}\n }\n var pusherEvent: PusherEvent = {\n event: messageData.event,\n channel: messageData.channel,\n data: pusherEventData\n };\n if (messageData.user_id) {\n pusherEvent.user_id = messageData.user_id;\n }\n return pusherEvent;\n } catch (e) {\n throw { type: 'MessageParseError', error: e, data: messageEvent.data };\n }\n },\n\n /**\n * Encodes a message to be sent.\n *\n * @param {PusherEvent} event\n * @return {String}\n */\n encodeMessage: function(event: PusherEvent): string {\n return JSON.stringify(event);\n },\n\n /**\n * Processes a handshake message and returns appropriate actions.\n *\n * Returns an object with an 'action' and other action-specific properties.\n *\n * There are three outcomes when calling this function. First is a successful\n * connection attempt, when pusher:connection_established is received, which\n * results in a 'connected' action with an 'id' property. When passed a\n * pusher:error event, it returns a result with action appropriate to the\n * close code and an error. Otherwise, it raises an exception.\n *\n * @param {String} message\n * @result Object\n */\n processHandshake: function(messageEvent: MessageEvent): Action {\n var message = Protocol.decodeMessage(messageEvent);\n\n if (message.event === 'pusher:connection_established') {\n if (!message.data.activity_timeout) {\n throw 'No activity timeout specified in handshake';\n }\n return {\n action: 'connected',\n id: message.data.socket_id,\n activityTimeout: message.data.activity_timeout * 1000\n };\n } else if (message.event === 'pusher:error') {\n // From protocol 6 close codes are sent only once, so this only\n // happens when connection does not support close codes\n return {\n action: this.getCloseAction(message.data),\n error: this.getCloseError(message.data)\n };\n } else {\n throw 'Invalid handshake';\n }\n },\n\n /**\n * Dispatches the close event and returns an appropriate action name.\n *\n * See:\n * 1. https://developer.mozilla.org/en-US/docs/WebSockets/WebSockets_reference/CloseEvent\n * 2. http://pusher.com/docs/pusher_protocol\n *\n * @param {CloseEvent} closeEvent\n * @return {String} close action name\n */\n getCloseAction: function(closeEvent): string {\n if (closeEvent.code < 4000) {\n // ignore 1000 CLOSE_NORMAL, 1001 CLOSE_GOING_AWAY,\n // 1005 CLOSE_NO_STATUS, 1006 CLOSE_ABNORMAL\n // ignore 1007...3999\n // handle 1002 CLOSE_PROTOCOL_ERROR, 1003 CLOSE_UNSUPPORTED,\n // 1004 CLOSE_TOO_LARGE\n if (closeEvent.code >= 1002 && closeEvent.code <= 1004) {\n return 'backoff';\n } else {\n return null;\n }\n } else if (closeEvent.code === 4000) {\n return 'tls_only';\n } else if (closeEvent.code < 4100) {\n return 'refused';\n } else if (closeEvent.code < 4200) {\n return 'backoff';\n } else if (closeEvent.code < 4300) {\n return 'retry';\n } else {\n // unknown error\n return 'refused';\n }\n },\n\n /**\n * Returns an error or null basing on the close event.\n *\n * Null is returned when connection was closed cleanly. Otherwise, an object\n * with error details is returned.\n *\n * @param {CloseEvent} closeEvent\n * @return {Object} error object\n */\n getCloseError: function(closeEvent): any {\n if (closeEvent.code !== 1000 && closeEvent.code !== 1001) {\n return {\n type: 'PusherError',\n data: {\n code: closeEvent.code,\n message: closeEvent.reason || closeEvent.message\n }\n };\n } else {\n return null;\n }\n }\n};\n\nexport default Protocol;\n","import * as Collections from '../utils/collections';\nimport { default as EventsDispatcher } from '../events/dispatcher';\nimport Protocol from './protocol/protocol';\nimport { PusherEvent } from './protocol/message-types';\nimport Logger from '../logger';\nimport TransportConnection from '../transports/transport_connection';\nimport Socket from '../socket';\n/**\n * Provides Pusher protocol interface for transports.\n *\n * Emits following events:\n * - message - on received messages\n * - ping - on ping requests\n * - pong - on pong responses\n * - error - when the transport emits an error\n * - closed - after closing the transport\n *\n * It also emits more events when connection closes with a code.\n * See Protocol.getCloseAction to get more details.\n *\n * @param {Number} id\n * @param {AbstractTransport} transport\n */\nexport default class Connection extends EventsDispatcher implements Socket {\n id: string;\n transport: TransportConnection;\n activityTimeout: number;\n\n constructor(id: string, transport: TransportConnection) {\n super();\n this.id = id;\n this.transport = transport;\n this.activityTimeout = transport.activityTimeout;\n this.bindListeners();\n }\n\n /** Returns whether used transport handles activity checks by itself\n *\n * @returns {Boolean} true if activity checks are handled by the transport\n */\n handlesActivityChecks() {\n return this.transport.handlesActivityChecks();\n }\n\n /** Sends raw data.\n *\n * @param {String} data\n */\n send(data: any): boolean {\n return this.transport.send(data);\n }\n\n /** Sends an event.\n *\n * @param {String} name\n * @param {String} data\n * @param {String} [channel]\n * @returns {Boolean} whether message was sent or not\n */\n send_event(name: string, data: any, channel?: string): boolean {\n var event: PusherEvent = { event: name, data: data };\n if (channel) {\n event.channel = channel;\n }\n Logger.debug('Event sent', event);\n return this.send(Protocol.encodeMessage(event));\n }\n\n /** Sends a ping message to the server.\n *\n * Basing on the underlying transport, it might send either transport's\n * protocol-specific ping or pusher:ping event.\n */\n ping() {\n if (this.transport.supportsPing()) {\n this.transport.ping();\n } else {\n this.send_event('pusher:ping', {});\n }\n }\n\n /** Closes the connection. */\n close() {\n this.transport.close();\n }\n\n private bindListeners() {\n var listeners = {\n message: (messageEvent: MessageEvent) => {\n var pusherEvent;\n try {\n pusherEvent = Protocol.decodeMessage(messageEvent);\n } catch (e) {\n this.emit('error', {\n type: 'MessageParseError',\n error: e,\n data: messageEvent.data\n });\n }\n\n if (pusherEvent !== undefined) {\n Logger.debug('Event recd', pusherEvent);\n\n switch (pusherEvent.event) {\n case 'pusher:error':\n this.emit('error', {\n type: 'PusherError',\n data: pusherEvent.data\n });\n break;\n case 'pusher:ping':\n this.emit('ping');\n break;\n case 'pusher:pong':\n this.emit('pong');\n break;\n }\n this.emit('message', pusherEvent);\n }\n },\n activity: () => {\n this.emit('activity');\n },\n error: error => {\n this.emit('error', error);\n },\n closed: closeEvent => {\n unbindListeners();\n\n if (closeEvent && closeEvent.code) {\n this.handleCloseEvent(closeEvent);\n }\n\n this.transport = null;\n this.emit('closed');\n }\n };\n\n var unbindListeners = () => {\n Collections.objectApply(listeners, (listener, event) => {\n this.transport.unbind(event, listener);\n });\n };\n\n Collections.objectApply(listeners, (listener, event) => {\n this.transport.bind(event, listener);\n });\n }\n\n private handleCloseEvent(closeEvent: any) {\n var action = Protocol.getCloseAction(closeEvent);\n var error = Protocol.getCloseError(closeEvent);\n if (error) {\n this.emit('error', error);\n }\n if (action) {\n this.emit(action, { action: action, error: error });\n }\n }\n}\n","import Util from '../../util';\nimport * as Collections from '../../utils/collections';\nimport Protocol from '../protocol/protocol';\nimport Connection from '../connection';\nimport TransportConnection from '../../transports/transport_connection';\nimport HandshakePayload from './handshake_payload';\n\n/**\n * Handles Pusher protocol handshakes for transports.\n *\n * Calls back with a result object after handshake is completed. Results\n * always have two fields:\n * - action - string describing action to be taken after the handshake\n * - transport - the transport object passed to the constructor\n *\n * Different actions can set different additional properties on the result.\n * In the case of 'connected' action, there will be a 'connection' property\n * containing a Connection object for the transport. Other actions should\n * carry an 'error' property.\n *\n * @param {AbstractTransport} transport\n * @param {Function} callback\n */\nexport default class Handshake {\n transport: TransportConnection;\n callback: (HandshakePayload) => void;\n onMessage: Function;\n onClosed: Function;\n\n constructor(\n transport: TransportConnection,\n callback: (HandshakePayload) => void\n ) {\n this.transport = transport;\n this.callback = callback;\n this.bindListeners();\n }\n\n close() {\n this.unbindListeners();\n this.transport.close();\n }\n\n private bindListeners() {\n this.onMessage = m => {\n this.unbindListeners();\n\n var result;\n try {\n result = Protocol.processHandshake(m);\n } catch (e) {\n this.finish('error', { error: e });\n this.transport.close();\n return;\n }\n\n if (result.action === 'connected') {\n this.finish('connected', {\n connection: new Connection(result.id, this.transport),\n activityTimeout: result.activityTimeout\n });\n } else {\n this.finish(result.action, { error: result.error });\n this.transport.close();\n }\n };\n\n this.onClosed = closeEvent => {\n this.unbindListeners();\n\n var action = Protocol.getCloseAction(closeEvent) || 'backoff';\n var error = Protocol.getCloseError(closeEvent);\n this.finish(action, { error: error });\n };\n\n this.transport.bind('message', this.onMessage);\n this.transport.bind('closed', this.onClosed);\n }\n\n private unbindListeners() {\n this.transport.unbind('message', this.onMessage);\n this.transport.unbind('closed', this.onClosed);\n }\n\n private finish(action: string, params: any) {\n this.callback(\n Collections.extend({ transport: this.transport, action: action }, params)\n );\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport base64encode from '../base64';\nimport Timeline from './timeline';\nimport Runtime from 'runtime';\n\nexport interface TimelineSenderOptions {\n host?: string;\n port?: number;\n path?: string;\n}\n\nexport default class TimelineSender {\n timeline: Timeline;\n options: TimelineSenderOptions;\n host: string;\n\n constructor(timeline: Timeline, options: TimelineSenderOptions) {\n this.timeline = timeline;\n this.options = options || {};\n }\n\n send(useTLS: boolean, callback?: Function) {\n if (this.timeline.isEmpty()) {\n return;\n }\n\n this.timeline.send(\n Runtime.TimelineTransport.getAgent(this, useTLS),\n callback\n );\n }\n}\n","import { default as EventsDispatcher } from '../events/dispatcher';\nimport * as Errors from '../errors';\nimport Logger from '../logger';\nimport Pusher from '../pusher';\nimport { PusherEvent } from '../connection/protocol/message-types';\nimport Metadata from './metadata';\nimport UrlStore from '../utils/url_store';\nimport {\n ChannelAuthorizationData,\n ChannelAuthorizationCallback\n} from '../auth/options';\nimport { HTTPAuthError } from '../errors';\n\n/** Provides base public channel interface with an event emitter.\n *\n * Emits:\n * - pusher:subscription_succeeded - after subscribing successfully\n * - other non-internal events\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\nexport default class Channel extends EventsDispatcher {\n name: string;\n pusher: Pusher;\n subscribed: boolean;\n subscriptionPending: boolean;\n subscriptionCancelled: boolean;\n subscriptionCount: null;\n\n constructor(name: string, pusher: Pusher) {\n super(function(event, data) {\n Logger.debug('No callbacks on ' + name + ' for ' + event);\n });\n\n this.name = name;\n this.pusher = pusher;\n this.subscribed = false;\n this.subscriptionPending = false;\n this.subscriptionCancelled = false;\n }\n\n /** Skips authorization, since public channels don't require it.\n *\n * @param {Function} callback\n */\n authorize(socketId: string, callback: ChannelAuthorizationCallback) {\n return callback(null, { auth: '' });\n }\n\n /** Triggers an event */\n trigger(event: string, data: any) {\n if (event.indexOf('client-') !== 0) {\n throw new Errors.BadEventName(\n \"Event '\" + event + \"' does not start with 'client-'\"\n );\n }\n if (!this.subscribed) {\n var suffix = UrlStore.buildLogSuffix('triggeringClientEvents');\n Logger.warn(\n `Client event triggered before channel 'subscription_succeeded' event . ${suffix}`\n );\n }\n return this.pusher.send_event(event, data, this.name);\n }\n\n /** Signals disconnection to the channel. For internal use only. */\n disconnect() {\n this.subscribed = false;\n this.subscriptionPending = false;\n }\n\n /** Handles a PusherEvent. For internal use only.\n *\n * @param {PusherEvent} event\n */\n handleEvent(event: PusherEvent) {\n var eventName = event.event;\n var data = event.data;\n if (eventName === 'pusher_internal:subscription_succeeded') {\n this.handleSubscriptionSucceededEvent(event);\n } else if (eventName === 'pusher_internal:subscription_count') {\n this.handleSubscriptionCountEvent(event);\n } else if (eventName.indexOf('pusher_internal:') !== 0) {\n var metadata: Metadata = {};\n this.emit(eventName, data, metadata);\n }\n }\n\n handleSubscriptionSucceededEvent(event: PusherEvent) {\n this.subscriptionPending = false;\n this.subscribed = true;\n if (this.subscriptionCancelled) {\n this.pusher.unsubscribe(this.name);\n } else {\n this.emit('pusher:subscription_succeeded', event.data);\n }\n }\n\n handleSubscriptionCountEvent(event: PusherEvent) {\n if (event.data.subscription_count) {\n this.subscriptionCount = event.data.subscription_count;\n }\n\n this.emit('pusher:subscription_count', event.data);\n }\n\n /** Sends a subscription request. For internal use only. */\n subscribe() {\n if (this.subscribed) {\n return;\n }\n this.subscriptionPending = true;\n this.subscriptionCancelled = false;\n this.authorize(\n this.pusher.connection.socket_id,\n (error: Error | null, data: ChannelAuthorizationData) => {\n if (error) {\n this.subscriptionPending = false;\n // Why not bind to 'pusher:subscription_error' a level up, and log there?\n // Binding to this event would cause the warning about no callbacks being\n // bound (see constructor) to be suppressed, that's not what we want.\n Logger.error(error.toString());\n this.emit(\n 'pusher:subscription_error',\n Object.assign(\n {},\n {\n type: 'AuthError',\n error: error.message\n },\n error instanceof HTTPAuthError ? { status: error.status } : {}\n )\n );\n } else {\n this.pusher.send_event('pusher:subscribe', {\n auth: data.auth,\n channel_data: data.channel_data,\n channel: this.name\n });\n }\n }\n );\n }\n\n /** Sends an unsubscription request. For internal use only. */\n unsubscribe() {\n this.subscribed = false;\n this.pusher.send_event('pusher:unsubscribe', {\n channel: this.name\n });\n }\n\n /** Cancels an in progress subscription. For internal use only. */\n cancelSubscription() {\n this.subscriptionCancelled = true;\n }\n\n /** Reinstates an in progress subscripiton. For internal use only. */\n reinstateSubscription() {\n this.subscriptionCancelled = false;\n }\n}\n","import Factory from '../utils/factory';\nimport Channel from './channel';\nimport { ChannelAuthorizationCallback } from '../auth/options';\n\n/** Extends public channels to provide private channel interface.\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\nexport default class PrivateChannel extends Channel {\n /** Authorizes the connection to use the channel.\n *\n * @param {String} socketId\n * @param {Function} callback\n */\n authorize(socketId: string, callback: ChannelAuthorizationCallback) {\n return this.pusher.config.channelAuthorizer(\n {\n channelName: this.name,\n socketId: socketId\n },\n callback\n );\n }\n}\n","import * as Collections from '../utils/collections';\n\n/** Represents a collection of members of a presence channel. */\nexport default class Members {\n members: any;\n count: number;\n myID: any;\n me: any;\n\n constructor() {\n this.reset();\n }\n\n /** Returns member's info for given id.\n *\n * Resulting object containts two fields - id and info.\n *\n * @param {Number} id\n * @return {Object} member's info or null\n */\n get(id: string): any {\n if (Object.prototype.hasOwnProperty.call(this.members, id)) {\n return {\n id: id,\n info: this.members[id]\n };\n } else {\n return null;\n }\n }\n\n /** Calls back for each member in unspecified order.\n *\n * @param {Function} callback\n */\n each(callback: Function) {\n Collections.objectApply(this.members, (member, id) => {\n callback(this.get(id));\n });\n }\n\n /** Updates the id for connected member. For internal use only. */\n setMyID(id: string) {\n this.myID = id;\n }\n\n /** Handles subscription data. For internal use only. */\n onSubscription(subscriptionData: any) {\n this.members = subscriptionData.presence.hash;\n this.count = subscriptionData.presence.count;\n this.me = this.get(this.myID);\n }\n\n /** Adds a new member to the collection. For internal use only. */\n addMember(memberData: any) {\n if (this.get(memberData.user_id) === null) {\n this.count++;\n }\n this.members[memberData.user_id] = memberData.user_info;\n return this.get(memberData.user_id);\n }\n\n /** Adds a member from the collection. For internal use only. */\n removeMember(memberData: any) {\n var member = this.get(memberData.user_id);\n if (member) {\n delete this.members[memberData.user_id];\n this.count--;\n }\n return member;\n }\n\n /** Resets the collection to the initial state. For internal use only. */\n reset() {\n this.members = {};\n this.count = 0;\n this.myID = null;\n this.me = null;\n }\n}\n","import PrivateChannel from './private_channel';\nimport Logger from '../logger';\nimport Members from './members';\nimport Pusher from '../pusher';\nimport UrlStore from 'core/utils/url_store';\nimport { PusherEvent } from '../connection/protocol/message-types';\nimport Metadata from './metadata';\nimport { ChannelAuthorizationData } from '../auth/options';\n\nexport default class PresenceChannel extends PrivateChannel {\n members: Members;\n\n /** Adds presence channel functionality to private channels.\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\n constructor(name: string, pusher: Pusher) {\n super(name, pusher);\n this.members = new Members();\n }\n\n /** Authorizes the connection as a member of the channel.\n *\n * @param {String} socketId\n * @param {Function} callback\n */\n authorize(socketId: string, callback: Function) {\n super.authorize(socketId, async (error, authData) => {\n if (!error) {\n authData = authData as ChannelAuthorizationData;\n if (authData.channel_data != null) {\n var channelData = JSON.parse(authData.channel_data);\n this.members.setMyID(channelData.user_id);\n } else {\n await this.pusher.user.signinDonePromise;\n if (this.pusher.user.user_data != null) {\n // If the user is signed in, get the id of the authenticated user\n // and allow the presence authorization to continue.\n this.members.setMyID(this.pusher.user.user_data.id);\n } else {\n let suffix = UrlStore.buildLogSuffix('authorizationEndpoint');\n Logger.error(\n `Invalid auth response for channel '${this.name}', ` +\n `expected 'channel_data' field. ${suffix}, ` +\n `or the user should be signed in.`\n );\n callback('Invalid auth response');\n return;\n }\n }\n }\n callback(error, authData);\n });\n }\n\n /** Handles presence and subscription events. For internal use only.\n *\n * @param {PusherEvent} event\n */\n handleEvent(event: PusherEvent) {\n var eventName = event.event;\n if (eventName.indexOf('pusher_internal:') === 0) {\n this.handleInternalEvent(event);\n } else {\n var data = event.data;\n var metadata: Metadata = {};\n if (event.user_id) {\n metadata.user_id = event.user_id;\n }\n this.emit(eventName, data, metadata);\n }\n }\n handleInternalEvent(event: PusherEvent) {\n var eventName = event.event;\n var data = event.data;\n switch (eventName) {\n case 'pusher_internal:subscription_succeeded':\n this.handleSubscriptionSucceededEvent(event);\n break;\n case 'pusher_internal:subscription_count':\n this.handleSubscriptionCountEvent(event);\n break;\n case 'pusher_internal:member_added':\n var addedMember = this.members.addMember(data);\n this.emit('pusher:member_added', addedMember);\n break;\n case 'pusher_internal:member_removed':\n var removedMember = this.members.removeMember(data);\n if (removedMember) {\n this.emit('pusher:member_removed', removedMember);\n }\n break;\n }\n }\n\n handleSubscriptionSucceededEvent(event: PusherEvent) {\n this.subscriptionPending = false;\n this.subscribed = true;\n if (this.subscriptionCancelled) {\n this.pusher.unsubscribe(this.name);\n } else {\n this.members.onSubscription(event.data);\n this.emit('pusher:subscription_succeeded', this.members);\n }\n }\n\n /** Resets the channel state, including members map. For internal use only. */\n disconnect() {\n this.members.reset();\n super.disconnect();\n }\n}\n","import PrivateChannel from './private_channel';\nimport * as Errors from '../errors';\nimport Logger from '../logger';\nimport Pusher from '../pusher';\nimport { decode as encodeUTF8 } from '@stablelib/utf8';\nimport { decode as decodeBase64 } from '@stablelib/base64';\nimport Dispatcher from '../events/dispatcher';\nimport { PusherEvent } from '../connection/protocol/message-types';\nimport {\n ChannelAuthorizationData,\n ChannelAuthorizationCallback\n} from '../auth/options';\nimport * as nacl from 'tweetnacl';\n\n/** Extends private channels to provide encrypted channel interface.\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\nexport default class EncryptedChannel extends PrivateChannel {\n key: Uint8Array = null;\n nacl: nacl;\n\n constructor(name: string, pusher: Pusher, nacl: nacl) {\n super(name, pusher);\n this.nacl = nacl;\n }\n\n /** Authorizes the connection to use the channel.\n *\n * @param {String} socketId\n * @param {Function} callback\n */\n authorize(socketId: string, callback: ChannelAuthorizationCallback) {\n super.authorize(\n socketId,\n (error: Error | null, authData: ChannelAuthorizationData) => {\n if (error) {\n callback(error, authData);\n return;\n }\n let sharedSecret = authData['shared_secret'];\n if (!sharedSecret) {\n callback(\n new Error(\n `No shared_secret key in auth payload for encrypted channel: ${this.name}`\n ),\n null\n );\n return;\n }\n this.key = decodeBase64(sharedSecret);\n delete authData['shared_secret'];\n callback(null, authData);\n }\n );\n }\n\n trigger(event: string, data: any): boolean {\n throw new Errors.UnsupportedFeature(\n 'Client events are not currently supported for encrypted channels'\n );\n }\n\n /** Handles an event. For internal use only.\n *\n * @param {PusherEvent} event\n */\n handleEvent(event: PusherEvent) {\n var eventName = event.event;\n var data = event.data;\n if (\n eventName.indexOf('pusher_internal:') === 0 ||\n eventName.indexOf('pusher:') === 0\n ) {\n super.handleEvent(event);\n return;\n }\n this.handleEncryptedEvent(eventName, data);\n }\n\n private handleEncryptedEvent(event: string, data: any): void {\n if (!this.key) {\n Logger.debug(\n 'Received encrypted event before key has been retrieved from the authEndpoint'\n );\n return;\n }\n if (!data.ciphertext || !data.nonce) {\n Logger.error(\n 'Unexpected format for encrypted event, expected object with `ciphertext` and `nonce` fields, got: ' +\n data\n );\n return;\n }\n let cipherText = decodeBase64(data.ciphertext);\n if (cipherText.length < this.nacl.secretbox.overheadLength) {\n Logger.error(\n `Expected encrypted event ciphertext length to be ${this.nacl.secretbox.overheadLength}, got: ${cipherText.length}`\n );\n return;\n }\n let nonce = decodeBase64(data.nonce);\n if (nonce.length < this.nacl.secretbox.nonceLength) {\n Logger.error(\n `Expected encrypted event nonce length to be ${this.nacl.secretbox.nonceLength}, got: ${nonce.length}`\n );\n return;\n }\n\n let bytes = this.nacl.secretbox.open(cipherText, nonce, this.key);\n if (bytes === null) {\n Logger.debug(\n 'Failed to decrypt an event, probably because it was encrypted with a different key. Fetching a new key from the authEndpoint...'\n );\n // Try a single time to retrieve a new auth key and decrypt the event with it\n // If this fails, a new key will be requested when a new message is received\n this.authorize(this.pusher.connection.socket_id, (error, authData) => {\n if (error) {\n Logger.error(\n `Failed to make a request to the authEndpoint: ${authData}. Unable to fetch new key, so dropping encrypted event`\n );\n return;\n }\n bytes = this.nacl.secretbox.open(cipherText, nonce, this.key);\n if (bytes === null) {\n Logger.error(\n `Failed to decrypt event with new key. Dropping encrypted event`\n );\n return;\n }\n this.emit(event, this.getDataToEmit(bytes));\n return;\n });\n return;\n }\n this.emit(event, this.getDataToEmit(bytes));\n }\n\n // Try and parse the decrypted bytes as JSON. If we can't parse it, just\n // return the utf-8 string\n getDataToEmit(bytes: Uint8Array): string {\n let raw = encodeUTF8(bytes);\n try {\n return JSON.parse(raw);\n } catch {\n return raw;\n }\n }\n}\n","import { default as EventsDispatcher } from '../events/dispatcher';\nimport { OneOffTimer as Timer } from '../utils/timers';\nimport { Config } from '../config';\nimport Logger from '../logger';\nimport HandshakePayload from './handshake/handshake_payload';\nimport Connection from './connection';\nimport Strategy from '../strategies/strategy';\nimport StrategyRunner from '../strategies/strategy_runner';\nimport * as Collections from '../utils/collections';\nimport Timeline from '../timeline/timeline';\nimport ConnectionManagerOptions from './connection_manager_options';\nimport Runtime from 'runtime';\n\nimport {\n ErrorCallbacks,\n HandshakeCallbacks,\n ConnectionCallbacks\n} from './callbacks';\nimport Action from './protocol/action';\n\n/** Manages connection to Pusher.\n *\n * Uses a strategy (currently only default), timers and network availability\n * info to establish a connection and export its state. In case of failures,\n * manages reconnection attempts.\n *\n * Exports state changes as following events:\n * - \"state_change\", { previous: p, current: state }\n * - state\n *\n * States:\n * - initialized - initial state, never transitioned to\n * - connecting - connection is being established\n * - connected - connection has been fully established\n * - disconnected - on requested disconnection\n * - unavailable - after connection timeout or when there's no network\n * - failed - when the connection strategy is not supported\n *\n * Options:\n * - unavailableTimeout - time to transition to unavailable state\n * - activityTimeout - time after which ping message should be sent\n * - pongTimeout - time for Pusher to respond with pong before reconnecting\n *\n * @param {String} key application key\n * @param {Object} options\n */\nexport default class ConnectionManager extends EventsDispatcher {\n key: string;\n options: ConnectionManagerOptions;\n state: string;\n connection: Connection;\n usingTLS: boolean;\n timeline: Timeline;\n socket_id: string;\n unavailableTimer: Timer;\n activityTimer: Timer;\n retryTimer: Timer;\n activityTimeout: number;\n strategy: Strategy;\n runner: StrategyRunner;\n errorCallbacks: ErrorCallbacks;\n handshakeCallbacks: HandshakeCallbacks;\n connectionCallbacks: ConnectionCallbacks;\n\n constructor(key: string, options: ConnectionManagerOptions) {\n super();\n this.state = 'initialized';\n this.connection = null;\n\n this.key = key;\n this.options = options;\n this.timeline = this.options.timeline;\n this.usingTLS = this.options.useTLS;\n\n this.errorCallbacks = this.buildErrorCallbacks();\n this.connectionCallbacks = this.buildConnectionCallbacks(\n this.errorCallbacks\n );\n this.handshakeCallbacks = this.buildHandshakeCallbacks(this.errorCallbacks);\n\n var Network = Runtime.getNetwork();\n\n Network.bind('online', () => {\n this.timeline.info({ netinfo: 'online' });\n if (this.state === 'connecting' || this.state === 'unavailable') {\n this.retryIn(0);\n }\n });\n Network.bind('offline', () => {\n this.timeline.info({ netinfo: 'offline' });\n if (this.connection) {\n this.sendActivityCheck();\n }\n });\n\n this.updateStrategy();\n }\n\n switchCluster(key: string) {\n this.key = key;\n // This ensures that the new config coming from\n // pusher instance are taken into account\n // such as appKey and cluster\n this.updateStrategy();\n this.retryIn(0);\n }\n\n /** Establishes a connection to Pusher.\n *\n * Does nothing when connection is already established. See top-level doc\n * to find events emitted on connection attempts.\n */\n connect() {\n if (this.connection || this.runner) {\n return;\n }\n if (!this.strategy.isSupported()) {\n this.updateState('failed');\n return;\n }\n this.updateState('connecting');\n this.startConnecting();\n this.setUnavailableTimer();\n }\n\n /** Sends raw data.\n *\n * @param {String} data\n */\n send(data) {\n if (this.connection) {\n return this.connection.send(data);\n } else {\n return false;\n }\n }\n\n /** Sends an event.\n *\n * @param {String} name\n * @param {String} data\n * @param {String} [channel]\n * @returns {Boolean} whether message was sent or not\n */\n send_event(name: string, data: any, channel?: string) {\n if (this.connection) {\n return this.connection.send_event(name, data, channel);\n } else {\n return false;\n }\n }\n\n /** Closes the connection. */\n disconnect() {\n this.disconnectInternally();\n this.updateState('disconnected');\n }\n\n isUsingTLS() {\n return this.usingTLS;\n }\n\n private startConnecting() {\n var callback = (error, handshake) => {\n if (error) {\n this.runner = this.strategy.connect(0, callback);\n } else {\n if (handshake.action === 'error') {\n this.emit('error', {\n type: 'HandshakeError',\n error: handshake.error\n });\n this.timeline.error({ handshakeError: handshake.error });\n } else {\n this.abortConnecting(); // we don't support switching connections yet\n this.handshakeCallbacks[handshake.action](handshake);\n }\n }\n };\n this.runner = this.strategy.connect(0, callback);\n }\n\n private abortConnecting() {\n if (this.runner) {\n this.runner.abort();\n this.runner = null;\n }\n }\n\n private disconnectInternally() {\n this.abortConnecting();\n this.clearRetryTimer();\n this.clearUnavailableTimer();\n if (this.connection) {\n var connection = this.abandonConnection();\n connection.close();\n }\n }\n\n private updateStrategy() {\n this.strategy = this.options.getStrategy({\n key: this.key,\n timeline: this.timeline,\n useTLS: this.usingTLS\n });\n }\n\n private retryIn(delay) {\n this.timeline.info({ action: 'retry', delay: delay });\n if (delay > 0) {\n this.emit('connecting_in', Math.round(delay / 1000));\n }\n this.retryTimer = new Timer(delay || 0, () => {\n this.disconnectInternally();\n this.connect();\n });\n }\n\n private clearRetryTimer() {\n if (this.retryTimer) {\n this.retryTimer.ensureAborted();\n this.retryTimer = null;\n }\n }\n\n private setUnavailableTimer() {\n this.unavailableTimer = new Timer(this.options.unavailableTimeout, () => {\n this.updateState('unavailable');\n });\n }\n\n private clearUnavailableTimer() {\n if (this.unavailableTimer) {\n this.unavailableTimer.ensureAborted();\n }\n }\n\n private sendActivityCheck() {\n this.stopActivityCheck();\n this.connection.ping();\n // wait for pong response\n this.activityTimer = new Timer(this.options.pongTimeout, () => {\n this.timeline.error({ pong_timed_out: this.options.pongTimeout });\n this.retryIn(0);\n });\n }\n\n private resetActivityCheck() {\n this.stopActivityCheck();\n // send ping after inactivity\n if (this.connection && !this.connection.handlesActivityChecks()) {\n this.activityTimer = new Timer(this.activityTimeout, () => {\n this.sendActivityCheck();\n });\n }\n }\n\n private stopActivityCheck() {\n if (this.activityTimer) {\n this.activityTimer.ensureAborted();\n }\n }\n\n private buildConnectionCallbacks(\n errorCallbacks: ErrorCallbacks\n ): ConnectionCallbacks {\n return Collections.extend({}, errorCallbacks, {\n message: message => {\n // includes pong messages from server\n this.resetActivityCheck();\n this.emit('message', message);\n },\n ping: () => {\n this.send_event('pusher:pong', {});\n },\n activity: () => {\n this.resetActivityCheck();\n },\n error: error => {\n // just emit error to user - socket will already be closed by browser\n this.emit('error', error);\n },\n closed: () => {\n this.abandonConnection();\n if (this.shouldRetry()) {\n this.retryIn(1000);\n }\n }\n });\n }\n\n private buildHandshakeCallbacks(\n errorCallbacks: ErrorCallbacks\n ): HandshakeCallbacks {\n return Collections.extend({}, errorCallbacks, {\n connected: (handshake: HandshakePayload) => {\n this.activityTimeout = Math.min(\n this.options.activityTimeout,\n handshake.activityTimeout,\n handshake.connection.activityTimeout || Infinity\n );\n this.clearUnavailableTimer();\n this.setConnection(handshake.connection);\n this.socket_id = this.connection.id;\n this.updateState('connected', { socket_id: this.socket_id });\n }\n });\n }\n\n private buildErrorCallbacks(): ErrorCallbacks {\n let withErrorEmitted = callback => {\n return (result: Action | HandshakePayload) => {\n if (result.error) {\n this.emit('error', { type: 'WebSocketError', error: result.error });\n }\n callback(result);\n };\n };\n\n return {\n tls_only: withErrorEmitted(() => {\n this.usingTLS = true;\n this.updateStrategy();\n this.retryIn(0);\n }),\n refused: withErrorEmitted(() => {\n this.disconnect();\n }),\n backoff: withErrorEmitted(() => {\n this.retryIn(1000);\n }),\n retry: withErrorEmitted(() => {\n this.retryIn(0);\n })\n };\n }\n\n private setConnection(connection) {\n this.connection = connection;\n for (var event in this.connectionCallbacks) {\n this.connection.bind(event, this.connectionCallbacks[event]);\n }\n this.resetActivityCheck();\n }\n\n private abandonConnection() {\n if (!this.connection) {\n return;\n }\n this.stopActivityCheck();\n for (var event in this.connectionCallbacks) {\n this.connection.unbind(event, this.connectionCallbacks[event]);\n }\n var connection = this.connection;\n this.connection = null;\n return connection;\n }\n\n private updateState(newState: string, data?: any) {\n var previousState = this.state;\n this.state = newState;\n if (previousState !== newState) {\n var newStateDescription = newState;\n if (newStateDescription === 'connected') {\n newStateDescription += ' with new socket ID ' + data.socket_id;\n }\n Logger.debug(\n 'State changed',\n previousState + ' -> ' + newStateDescription\n );\n this.timeline.info({ state: newState, params: data });\n this.emit('state_change', { previous: previousState, current: newState });\n this.emit(newState, data);\n }\n }\n\n private shouldRetry(): boolean {\n return this.state === 'connecting' || this.state === 'connected';\n }\n}\n","import Channel from './channel';\nimport * as Collections from '../utils/collections';\nimport ChannelTable from './channel_table';\nimport Factory from '../utils/factory';\nimport Pusher from '../pusher';\nimport Logger from '../logger';\nimport * as Errors from '../errors';\nimport urlStore from '../utils/url_store';\n\n/** Handles a channel map. */\nexport default class Channels {\n channels: ChannelTable;\n\n constructor() {\n this.channels = {};\n }\n\n /** Creates or retrieves an existing channel by its name.\n *\n * @param {String} name\n * @param {Pusher} pusher\n * @return {Channel}\n */\n add(name: string, pusher: Pusher) {\n if (!this.channels[name]) {\n this.channels[name] = createChannel(name, pusher);\n }\n return this.channels[name];\n }\n\n /** Returns a list of all channels\n *\n * @return {Array}\n */\n all(): Channel[] {\n return Collections.values(this.channels);\n }\n\n /** Finds a channel by its name.\n *\n * @param {String} name\n * @return {Channel} channel or null if it doesn't exist\n */\n find(name: string) {\n return this.channels[name];\n }\n\n /** Removes a channel from the map.\n *\n * @param {String} name\n */\n remove(name: string) {\n var channel = this.channels[name];\n delete this.channels[name];\n return channel;\n }\n\n /** Proxies disconnection signal to all channels. */\n disconnect() {\n Collections.objectApply(this.channels, function(channel) {\n channel.disconnect();\n });\n }\n}\n\nfunction createChannel(name: string, pusher: Pusher): Channel {\n if (name.indexOf('private-encrypted-') === 0) {\n if (pusher.config.nacl) {\n return Factory.createEncryptedChannel(name, pusher, pusher.config.nacl);\n }\n let errMsg =\n 'Tried to subscribe to a private-encrypted- channel but no nacl implementation available';\n let suffix = urlStore.buildLogSuffix('encryptedChannelSupport');\n throw new Errors.UnsupportedFeature(`${errMsg}. ${suffix}`);\n } else if (name.indexOf('private-') === 0) {\n return Factory.createPrivateChannel(name, pusher);\n } else if (name.indexOf('presence-') === 0) {\n return Factory.createPresenceChannel(name, pusher);\n } else if (name.indexOf('#') === 0) {\n throw new Errors.BadChannelName(\n 'Cannot create a channel with name \"' + name + '\".'\n );\n } else {\n return Factory.createChannel(name, pusher);\n }\n}\n","import AssistantToTheTransportManager from '../transports/assistant_to_the_transport_manager';\nimport PingDelayOptions from '../transports/ping_delay_options';\nimport Transport from '../transports/transport';\nimport TransportManager from '../transports/transport_manager';\nimport Handshake from '../connection/handshake';\nimport TransportConnection from '../transports/transport_connection';\nimport SocketHooks from '../http/socket_hooks';\nimport HTTPSocket from '../http/http_socket';\n\nimport Timeline from '../timeline/timeline';\nimport {\n default as TimelineSender,\n TimelineSenderOptions\n} from '../timeline/timeline_sender';\nimport PresenceChannel from '../channels/presence_channel';\nimport PrivateChannel from '../channels/private_channel';\nimport EncryptedChannel from '../channels/encrypted_channel';\nimport Channel from '../channels/channel';\nimport ConnectionManager from '../connection/connection_manager';\nimport ConnectionManagerOptions from '../connection/connection_manager_options';\nimport Ajax from '../http/ajax';\nimport Channels from '../channels/channels';\nimport Pusher from '../pusher';\nimport { Config } from '../config';\nimport * as nacl from 'tweetnacl';\n\nvar Factory = {\n createChannels(): Channels {\n return new Channels();\n },\n\n createConnectionManager(\n key: string,\n options: ConnectionManagerOptions\n ): ConnectionManager {\n return new ConnectionManager(key, options);\n },\n\n createChannel(name: string, pusher: Pusher): Channel {\n return new Channel(name, pusher);\n },\n\n createPrivateChannel(name: string, pusher: Pusher): PrivateChannel {\n return new PrivateChannel(name, pusher);\n },\n\n createPresenceChannel(name: string, pusher: Pusher): PresenceChannel {\n return new PresenceChannel(name, pusher);\n },\n\n createEncryptedChannel(\n name: string,\n pusher: Pusher,\n nacl: nacl\n ): EncryptedChannel {\n return new EncryptedChannel(name, pusher, nacl);\n },\n\n createTimelineSender(timeline: Timeline, options: TimelineSenderOptions) {\n return new TimelineSender(timeline, options);\n },\n\n createHandshake(\n transport: TransportConnection,\n callback: (HandshakePayload) => void\n ): Handshake {\n return new Handshake(transport, callback);\n },\n\n createAssistantToTheTransportManager(\n manager: TransportManager,\n transport: Transport,\n options: PingDelayOptions\n ): AssistantToTheTransportManager {\n return new AssistantToTheTransportManager(manager, transport, options);\n }\n};\n\nexport default Factory;\n","import AssistantToTheTransportManager from './assistant_to_the_transport_manager';\nimport Transport from './transport';\nimport PingDelayOptions from './ping_delay_options';\nimport Factory from '../utils/factory';\n\nexport interface TransportManagerOptions extends PingDelayOptions {\n lives?: number;\n}\n\n/** Keeps track of the number of lives left for a transport.\n *\n * In the beginning of a session, transports may be assigned a number of\n * lives. When an AssistantToTheTransportManager instance reports a transport\n * connection closed uncleanly, the transport loses a life. When the number\n * of lives drops to zero, the transport gets disabled by its manager.\n *\n * @param {Object} options\n */\nexport default class TransportManager {\n options: TransportManagerOptions;\n livesLeft: number;\n\n constructor(options: TransportManagerOptions) {\n this.options = options || {};\n this.livesLeft = this.options.lives || Infinity;\n }\n\n /** Creates a assistant for the transport.\n *\n * @param {Transport} transport\n * @returns {AssistantToTheTransportManager}\n */\n getAssistant(transport: Transport): AssistantToTheTransportManager {\n return Factory.createAssistantToTheTransportManager(this, transport, {\n minPingDelay: this.options.minPingDelay,\n maxPingDelay: this.options.maxPingDelay\n });\n }\n\n /** Returns whether the transport has any lives left.\n *\n * @returns {Boolean}\n */\n isAlive(): boolean {\n return this.livesLeft > 0;\n }\n\n /** Takes one life from the transport. */\n reportDeath() {\n this.livesLeft -= 1;\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport { OneOffTimer as Timer } from '../utils/timers';\nimport Strategy from './strategy';\nimport StrategyOptions from './strategy_options';\n\n/** Loops through strategies with optional timeouts.\n *\n * Options:\n * - loop - whether it should loop through the substrategy list\n * - timeout - initial timeout for a single substrategy\n * - timeoutLimit - maximum timeout\n *\n * @param {Strategy[]} strategies\n * @param {Object} options\n */\nexport default class SequentialStrategy implements Strategy {\n strategies: Strategy[];\n loop: boolean;\n failFast: boolean;\n timeout: number;\n timeoutLimit: number;\n\n constructor(strategies: Strategy[], options: StrategyOptions) {\n this.strategies = strategies;\n this.loop = Boolean(options.loop);\n this.failFast = Boolean(options.failFast);\n this.timeout = options.timeout;\n this.timeoutLimit = options.timeoutLimit;\n }\n\n isSupported(): boolean {\n return Collections.any(this.strategies, Util.method('isSupported'));\n }\n\n connect(minPriority: number, callback: Function) {\n var strategies = this.strategies;\n var current = 0;\n var timeout = this.timeout;\n var runner = null;\n\n var tryNextStrategy = (error, handshake) => {\n if (handshake) {\n callback(null, handshake);\n } else {\n current = current + 1;\n if (this.loop) {\n current = current % strategies.length;\n }\n\n if (current < strategies.length) {\n if (timeout) {\n timeout = timeout * 2;\n if (this.timeoutLimit) {\n timeout = Math.min(timeout, this.timeoutLimit);\n }\n }\n runner = this.tryStrategy(\n strategies[current],\n minPriority,\n { timeout, failFast: this.failFast },\n tryNextStrategy\n );\n } else {\n callback(true);\n }\n }\n };\n\n runner = this.tryStrategy(\n strategies[current],\n minPriority,\n { timeout: timeout, failFast: this.failFast },\n tryNextStrategy\n );\n\n return {\n abort: function() {\n runner.abort();\n },\n forceMinPriority: function(p) {\n minPriority = p;\n if (runner) {\n runner.forceMinPriority(p);\n }\n }\n };\n }\n\n private tryStrategy(\n strategy: Strategy,\n minPriority: number,\n options: StrategyOptions,\n callback: Function\n ) {\n var timer = null;\n var runner = null;\n\n if (options.timeout > 0) {\n timer = new Timer(options.timeout, function() {\n runner.abort();\n callback(true);\n });\n }\n\n runner = strategy.connect(minPriority, function(error, handshake) {\n if (error && timer && timer.isRunning() && !options.failFast) {\n // advance to the next strategy after the timeout\n return;\n }\n if (timer) {\n timer.ensureAborted();\n }\n callback(error, handshake);\n });\n\n return {\n abort: function() {\n if (timer) {\n timer.ensureAborted();\n }\n runner.abort();\n },\n forceMinPriority: function(p) {\n runner.forceMinPriority(p);\n }\n };\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport Strategy from './strategy';\n\n/** Launches all substrategies and emits prioritized connected transports.\n *\n * @param {Array} strategies\n */\nexport default class BestConnectedEverStrategy implements Strategy {\n strategies: Strategy[];\n\n constructor(strategies: Strategy[]) {\n this.strategies = strategies;\n }\n\n isSupported(): boolean {\n return Collections.any(this.strategies, Util.method('isSupported'));\n }\n\n connect(minPriority: number, callback: Function) {\n return connect(this.strategies, minPriority, function(i, runners) {\n return function(error, handshake) {\n runners[i].error = error;\n if (error) {\n if (allRunnersFailed(runners)) {\n callback(true);\n }\n return;\n }\n Collections.apply(runners, function(runner) {\n runner.forceMinPriority(handshake.transport.priority);\n });\n callback(null, handshake);\n };\n });\n }\n}\n\n/** Connects to all strategies in parallel.\n *\n * Callback builder should be a function that takes two arguments: index\n * and a list of runners. It should return another function that will be\n * passed to the substrategy with given index. Runners can be aborted using\n * abortRunner(s) functions from this class.\n *\n * @param {Array} strategies\n * @param {Function} callbackBuilder\n * @return {Object} strategy runner\n */\nfunction connect(\n strategies: Strategy[],\n minPriority: number,\n callbackBuilder: Function\n) {\n var runners = Collections.map(strategies, function(strategy, i, _, rs) {\n return strategy.connect(minPriority, callbackBuilder(i, rs));\n });\n return {\n abort: function() {\n Collections.apply(runners, abortRunner);\n },\n forceMinPriority: function(p) {\n Collections.apply(runners, function(runner) {\n runner.forceMinPriority(p);\n });\n }\n };\n}\n\nfunction allRunnersFailed(runners): boolean {\n return Collections.all(runners, function(runner) {\n return Boolean(runner.error);\n });\n}\n\nfunction abortRunner(runner) {\n if (!runner.error && !runner.aborted) {\n runner.abort();\n runner.aborted = true;\n }\n}\n","import Util from '../util';\nimport Runtime from 'runtime';\nimport Strategy from './strategy';\nimport SequentialStrategy from './sequential_strategy';\nimport StrategyOptions from './strategy_options';\nimport TransportStrategy from './transport_strategy';\nimport Timeline from '../timeline/timeline';\nimport * as Collections from '../utils/collections';\n\nexport interface TransportStrategyDictionary {\n [key: string]: TransportStrategy;\n}\n\n/** Caches the last successful transport and, after the first few attempts,\n * uses the cached transport for subsequent attempts.\n *\n * @param {Strategy} strategy\n * @param {Object} transports\n * @param {Object} options\n */\nexport default class WebSocketPrioritizedCachedStrategy implements Strategy {\n strategy: Strategy;\n transports: TransportStrategyDictionary;\n ttl: number;\n usingTLS: boolean;\n timeline: Timeline;\n\n constructor(\n strategy: Strategy,\n transports: TransportStrategyDictionary,\n options: StrategyOptions\n ) {\n this.strategy = strategy;\n this.transports = transports;\n this.ttl = options.ttl || 1800 * 1000;\n this.usingTLS = options.useTLS;\n this.timeline = options.timeline;\n }\n\n isSupported(): boolean {\n return this.strategy.isSupported();\n }\n\n connect(minPriority: number, callback: Function) {\n var usingTLS = this.usingTLS;\n var info = fetchTransportCache(usingTLS);\n var cacheSkipCount = info && info.cacheSkipCount ? info.cacheSkipCount : 0;\n\n var strategies = [this.strategy];\n if (info && info.timestamp + this.ttl >= Util.now()) {\n var transport = this.transports[info.transport];\n if (transport) {\n if (['ws', 'wss'].includes(info.transport) || cacheSkipCount > 3) {\n this.timeline.info({\n cached: true,\n transport: info.transport,\n latency: info.latency\n });\n strategies.push(\n new SequentialStrategy([transport], {\n timeout: info.latency * 2 + 1000,\n failFast: true\n })\n );\n } else {\n cacheSkipCount++;\n }\n }\n }\n\n var startTimestamp = Util.now();\n var runner = strategies\n .pop()\n .connect(minPriority, function cb(error, handshake) {\n if (error) {\n flushTransportCache(usingTLS);\n if (strategies.length > 0) {\n startTimestamp = Util.now();\n runner = strategies.pop().connect(minPriority, cb);\n } else {\n callback(error);\n }\n } else {\n storeTransportCache(\n usingTLS,\n handshake.transport.name,\n Util.now() - startTimestamp,\n cacheSkipCount\n );\n callback(null, handshake);\n }\n });\n\n return {\n abort: function() {\n runner.abort();\n },\n forceMinPriority: function(p) {\n minPriority = p;\n if (runner) {\n runner.forceMinPriority(p);\n }\n }\n };\n }\n}\n\nfunction getTransportCacheKey(usingTLS: boolean): string {\n return 'pusherTransport' + (usingTLS ? 'TLS' : 'NonTLS');\n}\n\nfunction fetchTransportCache(usingTLS: boolean): any {\n var storage = Runtime.getLocalStorage();\n if (storage) {\n try {\n var serializedCache = storage[getTransportCacheKey(usingTLS)];\n if (serializedCache) {\n return JSON.parse(serializedCache);\n }\n } catch (e) {\n flushTransportCache(usingTLS);\n }\n }\n return null;\n}\n\nfunction storeTransportCache(\n usingTLS: boolean,\n transport: TransportStrategy,\n latency: number,\n cacheSkipCount: number\n) {\n var storage = Runtime.getLocalStorage();\n if (storage) {\n try {\n storage[getTransportCacheKey(usingTLS)] = Collections.safeJSONStringify({\n timestamp: Util.now(),\n transport: transport,\n latency: latency,\n cacheSkipCount: cacheSkipCount\n });\n } catch (e) {\n // catch over quota exceptions raised by localStorage\n }\n }\n}\n\nfunction flushTransportCache(usingTLS: boolean) {\n var storage = Runtime.getLocalStorage();\n if (storage) {\n try {\n delete storage[getTransportCacheKey(usingTLS)];\n } catch (e) {\n // catch exceptions raised by localStorage\n }\n }\n}\n","import { OneOffTimer as Timer } from '../utils/timers';\nimport Strategy from './strategy';\nimport StrategyOptions from './strategy_options';\n\n/** Runs substrategy after specified delay.\n *\n * Options:\n * - delay - time in miliseconds to delay the substrategy attempt\n *\n * @param {Strategy} strategy\n * @param {Object} options\n */\nexport default class DelayedStrategy implements Strategy {\n strategy: Strategy;\n options: { delay: number };\n\n constructor(strategy: Strategy, { delay: number }) {\n this.strategy = strategy;\n this.options = { delay: number };\n }\n\n isSupported(): boolean {\n return this.strategy.isSupported();\n }\n\n connect(minPriority: number, callback: Function) {\n var strategy = this.strategy;\n var runner;\n var timer = new Timer(this.options.delay, function() {\n runner = strategy.connect(minPriority, callback);\n });\n\n return {\n abort: function() {\n timer.ensureAborted();\n if (runner) {\n runner.abort();\n }\n },\n forceMinPriority: function(p) {\n minPriority = p;\n if (runner) {\n runner.forceMinPriority(p);\n }\n }\n };\n }\n}\n","import Strategy from './strategy';\nimport StrategyRunner from './strategy_runner';\n\n/** Proxies method calls to one of substrategies basing on the test function.\n *\n * @param {Function} test\n * @param {Strategy} trueBranch strategy used when test returns true\n * @param {Strategy} falseBranch strategy used when test returns false\n */\nexport default class IfStrategy implements Strategy {\n test: () => boolean;\n trueBranch: Strategy;\n falseBranch: Strategy;\n\n constructor(\n test: () => boolean,\n trueBranch: Strategy,\n falseBranch: Strategy\n ) {\n this.test = test;\n this.trueBranch = trueBranch;\n this.falseBranch = falseBranch;\n }\n\n isSupported(): boolean {\n var branch = this.test() ? this.trueBranch : this.falseBranch;\n return branch.isSupported();\n }\n\n connect(minPriority: number, callback: Function): StrategyRunner {\n var branch = this.test() ? this.trueBranch : this.falseBranch;\n return branch.connect(minPriority, callback);\n }\n}\n","import Strategy from './strategy';\nimport StrategyRunner from './strategy_runner';\n\n/** Launches the substrategy and terminates on the first open connection.\n *\n * @param {Strategy} strategy\n */\nexport default class FirstConnectedStrategy implements Strategy {\n strategy: Strategy;\n\n constructor(strategy: Strategy) {\n this.strategy = strategy;\n }\n\n isSupported(): boolean {\n return this.strategy.isSupported();\n }\n\n connect(minPriority: number, callback: Function): StrategyRunner {\n var runner = this.strategy.connect(minPriority, function(error, handshake) {\n if (handshake) {\n runner.abort();\n }\n callback(error, handshake);\n });\n return runner;\n }\n}\n","import * as Collections from 'core/utils/collections';\nimport TransportManager from 'core/transports/transport_manager';\nimport Strategy from 'core/strategies/strategy';\nimport StrategyOptions from 'core/strategies/strategy_options';\nimport SequentialStrategy from 'core/strategies/sequential_strategy';\nimport BestConnectedEverStrategy from 'core/strategies/best_connected_ever_strategy';\nimport WebSocketPrioritizedCachedStrategy, {\n TransportStrategyDictionary\n} from 'core/strategies/websocket_prioritized_cached_strategy';\nimport DelayedStrategy from 'core/strategies/delayed_strategy';\nimport IfStrategy from 'core/strategies/if_strategy';\nimport FirstConnectedStrategy from 'core/strategies/first_connected_strategy';\nimport { Config } from 'core/config';\n\nfunction testSupportsStrategy(strategy: Strategy) {\n return function() {\n return strategy.isSupported();\n };\n}\n\nvar getDefaultStrategy = function(\n config: Config,\n baseOptions: StrategyOptions,\n defineTransport: Function\n): Strategy {\n var definedTransports = {};\n\n function defineTransportStrategy(\n name: string,\n type: string,\n priority: number,\n options: StrategyOptions,\n manager?: TransportManager\n ) {\n var transport = defineTransport(\n config,\n name,\n type,\n priority,\n options,\n manager\n );\n\n definedTransports[name] = transport;\n\n return transport;\n }\n\n var ws_options: StrategyOptions = Object.assign({}, baseOptions, {\n hostNonTLS: config.wsHost + ':' + config.wsPort,\n hostTLS: config.wsHost + ':' + config.wssPort,\n httpPath: config.wsPath\n });\n var wss_options: StrategyOptions = Object.assign({}, ws_options, {\n useTLS: true\n });\n var sockjs_options: StrategyOptions = Object.assign({}, baseOptions, {\n hostNonTLS: config.httpHost + ':' + config.httpPort,\n hostTLS: config.httpHost + ':' + config.httpsPort,\n httpPath: config.httpPath\n });\n\n var timeouts = {\n loop: true,\n timeout: 15000,\n timeoutLimit: 60000\n };\n\n var ws_manager = new TransportManager({\n minPingDelay: 10000,\n maxPingDelay: config.activityTimeout\n });\n var streaming_manager = new TransportManager({\n lives: 2,\n minPingDelay: 10000,\n maxPingDelay: config.activityTimeout\n });\n\n var ws_transport = defineTransportStrategy(\n 'ws',\n 'ws',\n 3,\n ws_options,\n ws_manager\n );\n var wss_transport = defineTransportStrategy(\n 'wss',\n 'ws',\n 3,\n wss_options,\n ws_manager\n );\n var sockjs_transport = defineTransportStrategy(\n 'sockjs',\n 'sockjs',\n 1,\n sockjs_options\n );\n var xhr_streaming_transport = defineTransportStrategy(\n 'xhr_streaming',\n 'xhr_streaming',\n 1,\n sockjs_options,\n streaming_manager\n );\n var xdr_streaming_transport = defineTransportStrategy(\n 'xdr_streaming',\n 'xdr_streaming',\n 1,\n sockjs_options,\n streaming_manager\n );\n var xhr_polling_transport = defineTransportStrategy(\n 'xhr_polling',\n 'xhr_polling',\n 1,\n sockjs_options\n );\n var xdr_polling_transport = defineTransportStrategy(\n 'xdr_polling',\n 'xdr_polling',\n 1,\n sockjs_options\n );\n\n var ws_loop = new SequentialStrategy([ws_transport], timeouts);\n var wss_loop = new SequentialStrategy([wss_transport], timeouts);\n var sockjs_loop = new SequentialStrategy([sockjs_transport], timeouts);\n var streaming_loop = new SequentialStrategy(\n [\n new IfStrategy(\n testSupportsStrategy(xhr_streaming_transport),\n xhr_streaming_transport,\n xdr_streaming_transport\n )\n ],\n timeouts\n );\n var polling_loop = new SequentialStrategy(\n [\n new IfStrategy(\n testSupportsStrategy(xhr_polling_transport),\n xhr_polling_transport,\n xdr_polling_transport\n )\n ],\n timeouts\n );\n\n var http_loop = new SequentialStrategy(\n [\n new IfStrategy(\n testSupportsStrategy(streaming_loop),\n new BestConnectedEverStrategy([\n streaming_loop,\n new DelayedStrategy(polling_loop, { delay: 4000 })\n ]),\n polling_loop\n )\n ],\n timeouts\n );\n\n var http_fallback_loop = new IfStrategy(\n testSupportsStrategy(http_loop),\n http_loop,\n sockjs_loop\n );\n\n var wsStrategy;\n if (baseOptions.useTLS) {\n wsStrategy = new BestConnectedEverStrategy([\n ws_loop,\n new DelayedStrategy(http_fallback_loop, { delay: 2000 })\n ]);\n } else {\n wsStrategy = new BestConnectedEverStrategy([\n ws_loop,\n new DelayedStrategy(wss_loop, { delay: 2000 }),\n new DelayedStrategy(http_fallback_loop, { delay: 5000 })\n ]);\n }\n\n return new WebSocketPrioritizedCachedStrategy(\n new FirstConnectedStrategy(\n new IfStrategy(\n testSupportsStrategy(ws_transport),\n wsStrategy,\n http_fallback_loop\n )\n ),\n definedTransports,\n {\n ttl: 1800000,\n timeline: baseOptions.timeline,\n useTLS: baseOptions.useTLS\n }\n );\n};\n\nexport default getDefaultStrategy;\n","import HTTPRequest from 'core/http/http_request';\nimport RequestHooks from 'core/http/request_hooks';\nimport Ajax from 'core/http/ajax';\nimport * as Errors from 'core/errors';\n\nvar hooks: RequestHooks = {\n getRequest: function(socket: HTTPRequest): Ajax {\n var xdr = new (window).XDomainRequest();\n xdr.ontimeout = function() {\n socket.emit('error', new Errors.RequestTimedOut());\n socket.close();\n };\n xdr.onerror = function(e) {\n socket.emit('error', e);\n socket.close();\n };\n xdr.onprogress = function() {\n if (xdr.responseText && xdr.responseText.length > 0) {\n socket.onChunk(200, xdr.responseText);\n }\n };\n xdr.onload = function() {\n if (xdr.responseText && xdr.responseText.length > 0) {\n socket.onChunk(200, xdr.responseText);\n }\n socket.emit('finished', 200);\n socket.close();\n };\n return xdr;\n },\n abortRequest: function(xdr: Ajax) {\n xdr.ontimeout = xdr.onerror = xdr.onprogress = xdr.onload = null;\n xdr.abort();\n }\n};\n\nexport default hooks;\n","import Runtime from 'runtime';\nimport RequestHooks from './request_hooks';\nimport Ajax from './ajax';\nimport { default as EventsDispatcher } from '../events/dispatcher';\n\nconst MAX_BUFFER_LENGTH = 256 * 1024;\n\nexport default class HTTPRequest extends EventsDispatcher {\n hooks: RequestHooks;\n method: string;\n url: string;\n position: number;\n xhr: Ajax;\n unloader: Function;\n\n constructor(hooks: RequestHooks, method: string, url: string) {\n super();\n this.hooks = hooks;\n this.method = method;\n this.url = url;\n }\n\n start(payload?: any) {\n this.position = 0;\n this.xhr = this.hooks.getRequest(this);\n\n this.unloader = () => {\n this.close();\n };\n Runtime.addUnloadListener(this.unloader);\n\n this.xhr.open(this.method, this.url, true);\n\n if (this.xhr.setRequestHeader) {\n this.xhr.setRequestHeader('Content-Type', 'application/json'); // ReactNative doesn't set this header by default.\n }\n this.xhr.send(payload);\n }\n\n close() {\n if (this.unloader) {\n Runtime.removeUnloadListener(this.unloader);\n this.unloader = null;\n }\n if (this.xhr) {\n this.hooks.abortRequest(this.xhr);\n this.xhr = null;\n }\n }\n\n onChunk(status: number, data: any) {\n while (true) {\n var chunk = this.advanceBuffer(data);\n if (chunk) {\n this.emit('chunk', { status: status, data: chunk });\n } else {\n break;\n }\n }\n if (this.isBufferTooLong(data)) {\n this.emit('buffer_too_long');\n }\n }\n\n private advanceBuffer(buffer: any[]): any {\n var unreadData = buffer.slice(this.position);\n var endOfLinePosition = unreadData.indexOf('\\n');\n\n if (endOfLinePosition !== -1) {\n this.position += endOfLinePosition + 1;\n return unreadData.slice(0, endOfLinePosition);\n } else {\n // chunk is not finished yet, don't move the buffer pointer\n return null;\n }\n }\n\n private isBufferTooLong(buffer: any): boolean {\n return this.position === buffer.length && buffer.length > MAX_BUFFER_LENGTH;\n }\n}\n","enum State {\n CONNECTING = 0,\n OPEN = 1,\n CLOSED = 3\n}\n\nexport default State;\n","import URLLocation from './url_location';\nimport State from './state';\nimport Socket from '../socket';\nimport SocketHooks from './socket_hooks';\nimport Util from '../util';\nimport Ajax from './ajax';\nimport HTTPRequest from './http_request';\nimport Runtime from 'runtime';\n\nvar autoIncrement = 1;\n\nclass HTTPSocket implements Socket {\n hooks: SocketHooks;\n session: string;\n location: URLLocation;\n readyState: State;\n stream: HTTPRequest;\n\n onopen: () => void;\n onerror: (error: any) => void;\n onclose: (closeEvent: any) => void;\n onmessage: (message: any) => void;\n onactivity: () => void;\n\n constructor(hooks: SocketHooks, url: string) {\n this.hooks = hooks;\n this.session = randomNumber(1000) + '/' + randomString(8);\n this.location = getLocation(url);\n this.readyState = State.CONNECTING;\n this.openStream();\n }\n\n send(payload: any) {\n return this.sendRaw(JSON.stringify([payload]));\n }\n\n ping() {\n this.hooks.sendHeartbeat(this);\n }\n\n close(code: any, reason: any) {\n this.onClose(code, reason, true);\n }\n\n /** For internal use only */\n sendRaw(payload: any): boolean {\n if (this.readyState === State.OPEN) {\n try {\n Runtime.createSocketRequest(\n 'POST',\n getUniqueURL(getSendURL(this.location, this.session))\n ).start(payload);\n return true;\n } catch (e) {\n return false;\n }\n } else {\n return false;\n }\n }\n\n /** For internal use only */\n reconnect() {\n this.closeStream();\n this.openStream();\n }\n\n /** For internal use only */\n onClose(code, reason, wasClean) {\n this.closeStream();\n this.readyState = State.CLOSED;\n if (this.onclose) {\n this.onclose({\n code: code,\n reason: reason,\n wasClean: wasClean\n });\n }\n }\n\n private onChunk(chunk) {\n if (chunk.status !== 200) {\n return;\n }\n if (this.readyState === State.OPEN) {\n this.onActivity();\n }\n\n var payload;\n var type = chunk.data.slice(0, 1);\n switch (type) {\n case 'o':\n payload = JSON.parse(chunk.data.slice(1) || '{}');\n this.onOpen(payload);\n break;\n case 'a':\n payload = JSON.parse(chunk.data.slice(1) || '[]');\n for (var i = 0; i < payload.length; i++) {\n this.onEvent(payload[i]);\n }\n break;\n case 'm':\n payload = JSON.parse(chunk.data.slice(1) || 'null');\n this.onEvent(payload);\n break;\n case 'h':\n this.hooks.onHeartbeat(this);\n break;\n case 'c':\n payload = JSON.parse(chunk.data.slice(1) || '[]');\n this.onClose(payload[0], payload[1], true);\n break;\n }\n }\n\n private onOpen(options) {\n if (this.readyState === State.CONNECTING) {\n if (options && options.hostname) {\n this.location.base = replaceHost(this.location.base, options.hostname);\n }\n this.readyState = State.OPEN;\n\n if (this.onopen) {\n this.onopen();\n }\n } else {\n this.onClose(1006, 'Server lost session', true);\n }\n }\n\n private onEvent(event) {\n if (this.readyState === State.OPEN && this.onmessage) {\n this.onmessage({ data: event });\n }\n }\n\n private onActivity() {\n if (this.onactivity) {\n this.onactivity();\n }\n }\n\n private onError(error) {\n if (this.onerror) {\n this.onerror(error);\n }\n }\n\n private openStream() {\n this.stream = Runtime.createSocketRequest(\n 'POST',\n getUniqueURL(this.hooks.getReceiveURL(this.location, this.session))\n );\n\n this.stream.bind('chunk', chunk => {\n this.onChunk(chunk);\n });\n this.stream.bind('finished', status => {\n this.hooks.onFinished(this, status);\n });\n this.stream.bind('buffer_too_long', () => {\n this.reconnect();\n });\n\n try {\n this.stream.start();\n } catch (error) {\n Util.defer(() => {\n this.onError(error);\n this.onClose(1006, 'Could not start streaming', false);\n });\n }\n }\n\n private closeStream() {\n if (this.stream) {\n this.stream.unbind_all();\n this.stream.close();\n this.stream = null;\n }\n }\n}\n\nfunction getLocation(url): URLLocation {\n var parts = /([^\\?]*)\\/*(\\??.*)/.exec(url);\n return {\n base: parts[1],\n queryString: parts[2]\n };\n}\n\nfunction getSendURL(url: URLLocation, session: string): string {\n return url.base + '/' + session + '/xhr_send';\n}\n\nfunction getUniqueURL(url: string): string {\n var separator = url.indexOf('?') === -1 ? '?' : '&';\n return url + separator + 't=' + +new Date() + '&n=' + autoIncrement++;\n}\n\nfunction replaceHost(url: string, hostname: string): string {\n var urlParts = /(https?:\\/\\/)([^\\/:]+)((\\/|:)?.*)/.exec(url);\n return urlParts[1] + hostname + urlParts[3];\n}\n\nfunction randomNumber(max: number): number {\n return Runtime.randomInt(max);\n}\n\nfunction randomString(length: number): string {\n var result = [];\n\n for (var i = 0; i < length; i++) {\n result.push(randomNumber(32).toString(32));\n }\n\n return result.join('');\n}\n\nexport default HTTPSocket;\n","enum TimelineLevel {\n ERROR = 3,\n INFO = 6,\n DEBUG = 7\n}\n\nexport default TimelineLevel;\n","import SocketHooks from './socket_hooks';\nimport HTTPSocket from './http_socket';\n\nvar hooks: SocketHooks = {\n getReceiveURL: function(url, session) {\n return url.base + '/' + session + '/xhr_streaming' + url.queryString;\n },\n onHeartbeat: function(socket) {\n socket.sendRaw('[]');\n },\n sendHeartbeat: function(socket) {\n socket.sendRaw('[]');\n },\n onFinished: function(socket, status) {\n socket.onClose(1006, 'Connection interrupted (' + status + ')', false);\n }\n};\n\nexport default hooks;\n","import SocketHooks from './socket_hooks';\nimport URLLocation from './url_location';\nimport HTTPSocket from './http_socket';\n\nvar hooks: SocketHooks = {\n getReceiveURL: function(url: URLLocation, session: string): string {\n return url.base + '/' + session + '/xhr' + url.queryString;\n },\n onHeartbeat: function() {\n // next HTTP request will reset server's activity timer\n },\n sendHeartbeat: function(socket) {\n socket.sendRaw('[]');\n },\n onFinished: function(socket, status) {\n if (status === 200) {\n socket.reconnect();\n } else {\n socket.onClose(1006, 'Connection interrupted (' + status + ')', false);\n }\n }\n};\n\nexport default hooks;\n","import HTTPRequest from 'core/http/http_request';\nimport RequestHooks from 'core/http/request_hooks';\nimport Ajax from 'core/http/ajax';\nimport Runtime from 'runtime';\n\nvar hooks: RequestHooks = {\n getRequest: function(socket: HTTPRequest): Ajax {\n var Constructor = Runtime.getXHRAPI();\n var xhr = new Constructor();\n xhr.onreadystatechange = xhr.onprogress = function() {\n switch (xhr.readyState) {\n case 3:\n if (xhr.responseText && xhr.responseText.length > 0) {\n socket.onChunk(xhr.status, xhr.responseText);\n }\n break;\n case 4:\n // this happens only on errors, never after calling close\n if (xhr.responseText && xhr.responseText.length > 0) {\n socket.onChunk(xhr.status, xhr.responseText);\n }\n socket.emit('finished', xhr.status);\n socket.close();\n break;\n }\n };\n return xhr;\n },\n abortRequest: function(xhr: Ajax) {\n xhr.onreadystatechange = null;\n xhr.abort();\n }\n};\n\nexport default hooks;\n","import HTTPRequest from 'core/http/http_request';\nimport HTTPSocket from 'core/http/http_socket';\nimport SocketHooks from 'core/http/socket_hooks';\nimport RequestHooks from 'core/http/request_hooks';\nimport streamingHooks from 'core/http/http_streaming_socket';\nimport pollingHooks from 'core/http/http_polling_socket';\nimport xhrHooks from './http_xhr_request';\nimport HTTPFactory from 'core/http/http_factory';\n\nvar HTTP: HTTPFactory = {\n createStreamingSocket(url: string): HTTPSocket {\n return this.createSocket(streamingHooks, url);\n },\n\n createPollingSocket(url: string): HTTPSocket {\n return this.createSocket(pollingHooks, url);\n },\n\n createSocket(hooks: SocketHooks, url: string): HTTPSocket {\n return new HTTPSocket(hooks, url);\n },\n\n createXHR(method: string, url: string): HTTPRequest {\n return this.createRequest(xhrHooks, method, url);\n },\n\n createRequest(hooks: RequestHooks, method: string, url: string): HTTPRequest {\n return new HTTPRequest(hooks, method, url);\n }\n};\n\nexport default HTTP;\n","import xdrHooks from './http_xdomain_request';\nimport HTTP from 'isomorphic/http/http';\n\nHTTP.createXDR = function(method, url) {\n return this.createRequest(xdrHooks, method, url);\n};\n\nexport default HTTP;\n","import Browser from './browser';\nimport { Dependencies, DependenciesReceivers } from './dom/dependencies';\nimport { AuthTransport, AuthTransports } from 'core/auth/auth_transports';\nimport xhrAuth from 'isomorphic/auth/xhr_auth';\nimport jsonpAuth from './auth/jsonp_auth';\nimport TimelineTransport from 'core/timeline/timeline_transport';\nimport TimelineSender from 'core/timeline/timeline_sender';\nimport ScriptRequest from './dom/script_request';\nimport JSONPRequest from './dom/jsonp_request';\nimport * as Collections from 'core/utils/collections';\nimport { ScriptReceivers } from './dom/script_receiver_factory';\nimport jsonpTimeline from './timeline/jsonp_timeline';\nimport Transports from './transports/transports';\nimport Ajax from 'core/http/ajax';\nimport { Network } from './net_info';\nimport getDefaultStrategy from './default_strategy';\nimport transportConnectionInitializer from './transports/transport_connection_initializer';\nimport HTTPFactory from './http/http';\nimport HTTPRequest from 'core/http/http_request';\n\nvar Runtime: Browser = {\n // for jsonp auth\n nextAuthCallbackID: 1,\n auth_callbacks: {},\n ScriptReceivers,\n DependenciesReceivers,\n getDefaultStrategy,\n Transports,\n transportConnectionInitializer,\n HTTPFactory,\n\n TimelineTransport: jsonpTimeline,\n\n getXHRAPI() {\n return window.XMLHttpRequest;\n },\n\n getWebSocketAPI() {\n return window.WebSocket || window.MozWebSocket;\n },\n\n setup(PusherClass): void {\n (window).Pusher = PusherClass; // JSONp requires Pusher to be in the global scope.\n var initializeOnDocumentBody = () => {\n this.onDocumentBody(PusherClass.ready);\n };\n if (!(window).JSON) {\n Dependencies.load('json2', {}, initializeOnDocumentBody);\n } else {\n initializeOnDocumentBody();\n }\n },\n\n getDocument(): Document {\n return document;\n },\n\n getProtocol(): string {\n return this.getDocument().location.protocol;\n },\n\n getAuthorizers(): AuthTransports {\n return { ajax: xhrAuth, jsonp: jsonpAuth };\n },\n\n onDocumentBody(callback: Function) {\n if (document.body) {\n callback();\n } else {\n setTimeout(() => {\n this.onDocumentBody(callback);\n }, 0);\n }\n },\n\n createJSONPRequest(url: string, data: any): JSONPRequest {\n return new JSONPRequest(url, data);\n },\n\n createScriptRequest(src: string): ScriptRequest {\n return new ScriptRequest(src);\n },\n\n getLocalStorage() {\n try {\n return window.localStorage;\n } catch (e) {\n return undefined;\n }\n },\n\n createXHR(): Ajax {\n if (this.getXHRAPI()) {\n return this.createXMLHttpRequest();\n } else {\n return this.createMicrosoftXHR();\n }\n },\n\n createXMLHttpRequest(): Ajax {\n var Constructor = this.getXHRAPI();\n return new Constructor();\n },\n\n createMicrosoftXHR(): Ajax {\n return new ActiveXObject('Microsoft.XMLHTTP');\n },\n\n getNetwork() {\n return Network;\n },\n\n createWebSocket(url: string): any {\n var Constructor = this.getWebSocketAPI();\n return new Constructor(url);\n },\n\n createSocketRequest(method: string, url: string): HTTPRequest {\n if (this.isXHRSupported()) {\n return this.HTTPFactory.createXHR(method, url);\n } else if (this.isXDRSupported(url.indexOf('https:') === 0)) {\n return this.HTTPFactory.createXDR(method, url);\n } else {\n throw 'Cross-origin HTTP requests are not supported';\n }\n },\n\n isXHRSupported(): boolean {\n var Constructor = this.getXHRAPI();\n return (\n Boolean(Constructor) && new Constructor().withCredentials !== undefined\n );\n },\n\n isXDRSupported(useTLS?: boolean): boolean {\n var protocol = useTLS ? 'https:' : 'http:';\n var documentProtocol = this.getProtocol();\n return (\n Boolean(window['XDomainRequest']) && documentProtocol === protocol\n );\n },\n\n addUnloadListener(listener: any) {\n if (window.addEventListener !== undefined) {\n window.addEventListener('unload', listener, false);\n } else if (window.attachEvent !== undefined) {\n window.attachEvent('onunload', listener);\n }\n },\n\n removeUnloadListener(listener: any) {\n if (window.addEventListener !== undefined) {\n window.removeEventListener('unload', listener, false);\n } else if (window.detachEvent !== undefined) {\n window.detachEvent('onunload', listener);\n }\n },\n\n randomInt(max: number): number {\n /**\n * Return values in the range of [0, 1[\n */\n const random = function() {\n const crypto = window.crypto || window['msCrypto'];\n const random = crypto.getRandomValues(new Uint32Array(1))[0];\n\n return random / 2 ** 32;\n };\n\n return Math.floor(random() * max);\n }\n};\n\nexport default Runtime;\n","import { Dependencies } from '../dom/dependencies';\n\n/** Initializes the transport.\n *\n * Fetches resources if needed and then transitions to initialized.\n */\nexport default function() {\n var self = this;\n\n self.timeline.info(\n self.buildTimelineMessage({\n transport: self.name + (self.options.useTLS ? 's' : '')\n })\n );\n\n if (self.hooks.isInitialized()) {\n self.changeState('initialized');\n } else if (self.hooks.file) {\n self.changeState('initializing');\n Dependencies.load(\n self.hooks.file,\n { useTLS: self.options.useTLS },\n function(error, callback) {\n if (self.hooks.isInitialized()) {\n self.changeState('initialized');\n callback(true);\n } else {\n if (error) {\n self.onError(error);\n }\n self.onClose();\n callback(false);\n }\n }\n );\n } else {\n self.onClose();\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport { default as Level } from './level';\n\nexport interface TimelineOptions {\n level?: Level;\n limit?: number;\n version?: string;\n cluster?: string;\n features?: string[];\n params?: any;\n}\n\nexport default class Timeline {\n key: string;\n session: number;\n events: any[];\n options: TimelineOptions;\n sent: number;\n uniqueID: number;\n\n constructor(key: string, session: number, options: TimelineOptions) {\n this.key = key;\n this.session = session;\n this.events = [];\n this.options = options || {};\n this.sent = 0;\n this.uniqueID = 0;\n }\n\n log(level, event) {\n if (level <= this.options.level) {\n this.events.push(\n Collections.extend({}, event, { timestamp: Util.now() })\n );\n if (this.options.limit && this.events.length > this.options.limit) {\n this.events.shift();\n }\n }\n }\n\n error(event) {\n this.log(Level.ERROR, event);\n }\n\n info(event) {\n this.log(Level.INFO, event);\n }\n\n debug(event) {\n this.log(Level.DEBUG, event);\n }\n\n isEmpty() {\n return this.events.length === 0;\n }\n\n send(sendfn, callback) {\n var data = Collections.extend(\n {\n session: this.session,\n bundle: this.sent + 1,\n key: this.key,\n lib: 'js',\n version: this.options.version,\n cluster: this.options.cluster,\n features: this.options.features,\n timeline: this.events\n },\n this.options.params\n );\n\n this.events = [];\n sendfn(data, (error, result) => {\n if (!error) {\n this.sent++;\n }\n if (callback) {\n callback(error, result);\n }\n });\n\n return true;\n }\n\n generateUniqueID(): number {\n this.uniqueID++;\n return this.uniqueID;\n }\n}\n","import Factory from '../utils/factory';\nimport Util from '../util';\nimport * as Errors from '../errors';\nimport * as Collections from '../utils/collections';\nimport Strategy from './strategy';\nimport Transport from '../transports/transport';\nimport StrategyOptions from './strategy_options';\nimport Handshake from '../connection/handshake';\n\n/** Provides a strategy interface for transports.\n *\n * @param {String} name\n * @param {Number} priority\n * @param {Class} transport\n * @param {Object} options\n */\nexport default class TransportStrategy implements Strategy {\n name: string;\n priority: number;\n transport: Transport;\n options: StrategyOptions;\n\n constructor(\n name: string,\n priority: number,\n transport: Transport,\n options: StrategyOptions\n ) {\n this.name = name;\n this.priority = priority;\n this.transport = transport;\n this.options = options || {};\n }\n\n /** Returns whether the transport is supported in the browser.\n *\n * @returns {Boolean}\n */\n isSupported(): boolean {\n return this.transport.isSupported({\n useTLS: this.options.useTLS\n });\n }\n\n /** Launches a connection attempt and returns a strategy runner.\n *\n * @param {Function} callback\n * @return {Object} strategy runner\n */\n connect(minPriority: number, callback: Function) {\n if (!this.isSupported()) {\n return failAttempt(new Errors.UnsupportedStrategy(), callback);\n } else if (this.priority < minPriority) {\n return failAttempt(new Errors.TransportPriorityTooLow(), callback);\n }\n\n var connected = false;\n var transport = this.transport.createConnection(\n this.name,\n this.priority,\n this.options.key,\n this.options\n );\n var handshake = null;\n\n var onInitialized = function() {\n transport.unbind('initialized', onInitialized);\n transport.connect();\n };\n var onOpen = function() {\n handshake = Factory.createHandshake(transport, function(result) {\n connected = true;\n unbindListeners();\n callback(null, result);\n });\n };\n var onError = function(error) {\n unbindListeners();\n callback(error);\n };\n var onClosed = function() {\n unbindListeners();\n var serializedTransport;\n\n // The reason for this try/catch block is that on React Native\n // the WebSocket object is circular. Therefore transport.socket will\n // throw errors upon stringification. Collections.safeJSONStringify\n // discards circular references when serializing.\n serializedTransport = Collections.safeJSONStringify(transport);\n callback(new Errors.TransportClosed(serializedTransport));\n };\n\n var unbindListeners = function() {\n transport.unbind('initialized', onInitialized);\n transport.unbind('open', onOpen);\n transport.unbind('error', onError);\n transport.unbind('closed', onClosed);\n };\n\n transport.bind('initialized', onInitialized);\n transport.bind('open', onOpen);\n transport.bind('error', onError);\n transport.bind('closed', onClosed);\n\n // connect will be called automatically after initialization\n transport.initialize();\n\n return {\n abort: () => {\n if (connected) {\n return;\n }\n unbindListeners();\n if (handshake) {\n handshake.close();\n } else {\n transport.close();\n }\n },\n forceMinPriority: p => {\n if (connected) {\n return;\n }\n if (this.priority < p) {\n if (handshake) {\n handshake.close();\n } else {\n transport.close();\n }\n }\n }\n };\n }\n}\n\nfunction failAttempt(error: Error, callback: Function) {\n Util.defer(function() {\n callback(error);\n });\n return {\n abort: function() {},\n forceMinPriority: function() {}\n };\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport TransportManager from '../transports/transport_manager';\nimport * as Errors from '../errors';\nimport Strategy from './strategy';\nimport TransportStrategy from './transport_strategy';\nimport StrategyOptions from '../strategies/strategy_options';\nimport { Config } from '../config';\nimport Runtime from 'runtime';\n\nconst { Transports } = Runtime;\n\nexport var defineTransport = function(\n config: Config,\n name: string,\n type: string,\n priority: number,\n options: StrategyOptions,\n manager?: TransportManager\n): Strategy {\n var transportClass = Transports[type];\n if (!transportClass) {\n throw new Errors.UnsupportedTransport(type);\n }\n\n var enabled =\n (!config.enabledTransports ||\n Collections.arrayIndexOf(config.enabledTransports, name) !== -1) &&\n (!config.disabledTransports ||\n Collections.arrayIndexOf(config.disabledTransports, name) === -1);\n\n var transport;\n if (enabled) {\n options = Object.assign(\n { ignoreNullOrigin: config.ignoreNullOrigin },\n options\n );\n\n transport = new TransportStrategy(\n name,\n priority,\n manager ? manager.getAssistant(transportClass) : transportClass,\n options\n );\n } else {\n transport = UnsupportedStrategy;\n }\n\n return transport;\n};\n\nvar UnsupportedStrategy: Strategy = {\n isSupported: function() {\n return false;\n },\n connect: function(_, callback) {\n var deferred = Util.defer(function() {\n callback(new Errors.UnsupportedStrategy());\n });\n return {\n abort: function() {\n deferred.ensureAborted();\n },\n forceMinPriority: function() {}\n };\n }\n};\n","import {\n UserAuthenticationCallback,\n InternalAuthOptions,\n UserAuthenticationHandler,\n UserAuthenticationRequestParams,\n AuthRequestType\n} from './options';\n\nimport Runtime from 'runtime';\n\nconst composeChannelQuery = (\n params: UserAuthenticationRequestParams,\n authOptions: InternalAuthOptions\n) => {\n var query = 'socket_id=' + encodeURIComponent(params.socketId);\n\n for (var key in authOptions.params) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(authOptions.params[key]);\n }\n\n if (authOptions.paramsProvider != null) {\n let dynamicParams = authOptions.paramsProvider();\n for (var key in dynamicParams) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(dynamicParams[key]);\n }\n }\n\n return query;\n};\n\nconst UserAuthenticator = (\n authOptions: InternalAuthOptions\n): UserAuthenticationHandler => {\n if (typeof Runtime.getAuthorizers()[authOptions.transport] === 'undefined') {\n throw `'${authOptions.transport}' is not a recognized auth transport`;\n }\n\n return (\n params: UserAuthenticationRequestParams,\n callback: UserAuthenticationCallback\n ) => {\n const query = composeChannelQuery(params, authOptions);\n\n Runtime.getAuthorizers()[authOptions.transport](\n Runtime,\n query,\n authOptions,\n AuthRequestType.UserAuthentication,\n callback\n );\n };\n};\n\nexport default UserAuthenticator;\n","import {\n AuthRequestType,\n InternalAuthOptions,\n ChannelAuthorizationHandler,\n ChannelAuthorizationRequestParams,\n ChannelAuthorizationCallback\n} from './options';\n\nimport Runtime from 'runtime';\n\nconst composeChannelQuery = (\n params: ChannelAuthorizationRequestParams,\n authOptions: InternalAuthOptions\n) => {\n var query = 'socket_id=' + encodeURIComponent(params.socketId);\n\n query += '&channel_name=' + encodeURIComponent(params.channelName);\n\n for (var key in authOptions.params) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(authOptions.params[key]);\n }\n\n if (authOptions.paramsProvider != null) {\n let dynamicParams = authOptions.paramsProvider();\n for (var key in dynamicParams) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(dynamicParams[key]);\n }\n }\n\n return query;\n};\n\nconst ChannelAuthorizer = (\n authOptions: InternalAuthOptions\n): ChannelAuthorizationHandler => {\n if (typeof Runtime.getAuthorizers()[authOptions.transport] === 'undefined') {\n throw `'${authOptions.transport}' is not a recognized auth transport`;\n }\n\n return (\n params: ChannelAuthorizationRequestParams,\n callback: ChannelAuthorizationCallback\n ) => {\n const query = composeChannelQuery(params, authOptions);\n\n Runtime.getAuthorizers()[authOptions.transport](\n Runtime,\n query,\n authOptions,\n AuthRequestType.ChannelAuthorization,\n callback\n );\n };\n};\n\nexport default ChannelAuthorizer;\n","import { Options } from './options';\nimport Defaults from './defaults';\nimport {\n ChannelAuthorizationHandler,\n UserAuthenticationHandler,\n ChannelAuthorizationOptions\n} from './auth/options';\nimport UserAuthenticator from './auth/user_authenticator';\nimport ChannelAuthorizer from './auth/channel_authorizer';\nimport { ChannelAuthorizerProxy } from './auth/deprecated_channel_authorizer';\nimport Runtime from 'runtime';\nimport * as nacl from 'tweetnacl';\n\nexport type AuthTransport = 'ajax' | 'jsonp';\nexport type Transport =\n | 'ws'\n | 'wss'\n | 'xhr_streaming'\n | 'xhr_polling'\n | 'sockjs';\n\nexport interface Config {\n // these are all 'required' config parameters, it's not necessary for the user\n // to set them, but they have configured defaults.\n activityTimeout: number;\n enableStats: boolean;\n httpHost: string;\n httpPath: string;\n httpPort: number;\n httpsPort: number;\n pongTimeout: number;\n statsHost: string;\n unavailableTimeout: number;\n useTLS: boolean;\n wsHost: string;\n wsPath: string;\n wsPort: number;\n wssPort: number;\n userAuthenticator: UserAuthenticationHandler;\n channelAuthorizer: ChannelAuthorizationHandler;\n\n // these are all optional parameters or overrrides. The customer can set these\n // but it's not strictly necessary\n forceTLS?: boolean;\n cluster?: string;\n disabledTransports?: Transport[];\n enabledTransports?: Transport[];\n ignoreNullOrigin?: boolean;\n nacl?: nacl;\n timelineParams?: any;\n}\n\n// getConfig mainly sets the defaults for the options that are not provided\nexport function getConfig(opts: Options, pusher): Config {\n let config: Config = {\n activityTimeout: opts.activityTimeout || Defaults.activityTimeout,\n cluster: opts.cluster,\n httpPath: opts.httpPath || Defaults.httpPath,\n httpPort: opts.httpPort || Defaults.httpPort,\n httpsPort: opts.httpsPort || Defaults.httpsPort,\n pongTimeout: opts.pongTimeout || Defaults.pongTimeout,\n statsHost: opts.statsHost || Defaults.stats_host,\n unavailableTimeout: opts.unavailableTimeout || Defaults.unavailableTimeout,\n wsPath: opts.wsPath || Defaults.wsPath,\n wsPort: opts.wsPort || Defaults.wsPort,\n wssPort: opts.wssPort || Defaults.wssPort,\n\n enableStats: getEnableStatsConfig(opts),\n httpHost: getHttpHost(opts),\n useTLS: shouldUseTLS(opts),\n wsHost: getWebsocketHost(opts),\n\n userAuthenticator: buildUserAuthenticator(opts),\n channelAuthorizer: buildChannelAuthorizer(opts, pusher)\n };\n\n if ('disabledTransports' in opts)\n config.disabledTransports = opts.disabledTransports;\n if ('enabledTransports' in opts)\n config.enabledTransports = opts.enabledTransports;\n if ('ignoreNullOrigin' in opts)\n config.ignoreNullOrigin = opts.ignoreNullOrigin;\n if ('timelineParams' in opts) config.timelineParams = opts.timelineParams;\n if ('nacl' in opts) {\n config.nacl = opts.nacl;\n }\n\n return config;\n}\n\nfunction getHttpHost(opts: Options): string {\n if (opts.httpHost) {\n return opts.httpHost;\n }\n if (opts.cluster) {\n return `sockjs-${opts.cluster}.pusher.com`;\n }\n return Defaults.httpHost;\n}\n\nfunction getWebsocketHost(opts: Options): string {\n if (opts.wsHost) {\n return opts.wsHost;\n }\n return getWebsocketHostFromCluster(opts.cluster);\n}\n\nfunction getWebsocketHostFromCluster(cluster: string): string {\n return `ws-${cluster}.pusher.com`;\n}\n\nfunction shouldUseTLS(opts: Options): boolean {\n if (Runtime.getProtocol() === 'https:') {\n return true;\n } else if (opts.forceTLS === false) {\n return false;\n }\n return true;\n}\n\n// if enableStats is set take the value\n// if disableStats is set take the inverse\n// otherwise default to false\nfunction getEnableStatsConfig(opts: Options): boolean {\n if ('enableStats' in opts) {\n return opts.enableStats;\n }\n if ('disableStats' in opts) {\n return !opts.disableStats;\n }\n return false;\n}\n\nfunction buildUserAuthenticator(opts: Options): UserAuthenticationHandler {\n const userAuthentication = {\n ...Defaults.userAuthentication,\n ...opts.userAuthentication\n };\n if (\n 'customHandler' in userAuthentication &&\n userAuthentication['customHandler'] != null\n ) {\n return userAuthentication['customHandler'];\n }\n\n return UserAuthenticator(userAuthentication);\n}\n\nfunction buildChannelAuth(opts: Options, pusher): ChannelAuthorizationOptions {\n let channelAuthorization: ChannelAuthorizationOptions;\n if ('channelAuthorization' in opts) {\n channelAuthorization = {\n ...Defaults.channelAuthorization,\n ...opts.channelAuthorization\n };\n } else {\n channelAuthorization = {\n transport: opts.authTransport || Defaults.authTransport,\n endpoint: opts.authEndpoint || Defaults.authEndpoint\n };\n if ('auth' in opts) {\n if ('params' in opts.auth) channelAuthorization.params = opts.auth.params;\n if ('headers' in opts.auth)\n channelAuthorization.headers = opts.auth.headers;\n }\n if ('authorizer' in opts)\n channelAuthorization.customHandler = ChannelAuthorizerProxy(\n pusher,\n channelAuthorization,\n opts.authorizer\n );\n }\n return channelAuthorization;\n}\n\nfunction buildChannelAuthorizer(\n opts: Options,\n pusher\n): ChannelAuthorizationHandler {\n const channelAuthorization = buildChannelAuth(opts, pusher);\n if (\n 'customHandler' in channelAuthorization &&\n channelAuthorization['customHandler'] != null\n ) {\n return channelAuthorization['customHandler'];\n }\n\n return ChannelAuthorizer(channelAuthorization);\n}\n","import Channel from '../channels/channel';\nimport {\n ChannelAuthorizationCallback,\n ChannelAuthorizationHandler,\n ChannelAuthorizationRequestParams,\n InternalAuthOptions\n} from './options';\n\nexport interface DeprecatedChannelAuthorizer {\n authorize(socketId: string, callback: ChannelAuthorizationCallback): void;\n}\n\nexport interface ChannelAuthorizerGenerator {\n (\n channel: Channel,\n options: DeprecatedAuthorizerOptions\n ): DeprecatedChannelAuthorizer;\n}\n\nexport interface DeprecatedAuthOptions {\n params?: any;\n headers?: any;\n}\n\nexport interface DeprecatedAuthorizerOptions {\n authTransport: 'ajax' | 'jsonp';\n authEndpoint: string;\n auth?: DeprecatedAuthOptions;\n}\n\nexport const ChannelAuthorizerProxy = (\n pusher,\n authOptions: InternalAuthOptions,\n channelAuthorizerGenerator: ChannelAuthorizerGenerator\n): ChannelAuthorizationHandler => {\n const deprecatedAuthorizerOptions: DeprecatedAuthorizerOptions = {\n authTransport: authOptions.transport,\n authEndpoint: authOptions.endpoint,\n auth: {\n params: authOptions.params,\n headers: authOptions.headers\n }\n };\n return (\n params: ChannelAuthorizationRequestParams,\n callback: ChannelAuthorizationCallback\n ) => {\n const channel = pusher.channel(params.channelName);\n // This line creates a new channel authorizer every time.\n // In the past, this was only done once per channel and reused.\n // We can do that again if we want to keep this behavior intact.\n const channelAuthorizer: DeprecatedChannelAuthorizer = channelAuthorizerGenerator(\n channel,\n deprecatedAuthorizerOptions\n );\n channelAuthorizer.authorize(params.socketId, callback);\n };\n};\n","import Logger from './logger';\nimport Pusher from './pusher';\nimport EventsDispatcher from './events/dispatcher';\n\nexport default class WatchlistFacade extends EventsDispatcher {\n private pusher: Pusher;\n\n public constructor(pusher: Pusher) {\n super(function(eventName, data) {\n Logger.debug(`No callbacks on watchlist events for ${eventName}`);\n });\n\n this.pusher = pusher;\n this.bindWatchlistInternalEvent();\n }\n\n handleEvent(pusherEvent) {\n pusherEvent.data.events.forEach(watchlistEvent => {\n this.emit(watchlistEvent.name, watchlistEvent);\n });\n }\n\n private bindWatchlistInternalEvent() {\n this.pusher.connection.bind('message', pusherEvent => {\n var eventName = pusherEvent.event;\n if (eventName === 'pusher_internal:watchlist_events') {\n this.handleEvent(pusherEvent);\n }\n });\n }\n}\n","function flatPromise() {\n let resolve, reject;\n const promise = new Promise((res, rej) => {\n resolve = res;\n reject = rej;\n });\n return { promise, resolve, reject };\n}\n\nexport default flatPromise;\n","import Pusher from './pusher';\nimport Logger from './logger';\nimport {\n UserAuthenticationData,\n UserAuthenticationCallback\n} from './auth/options';\nimport Channel from './channels/channel';\nimport WatchlistFacade from './watchlist';\nimport EventsDispatcher from './events/dispatcher';\nimport flatPromise from './utils/flat_promise';\n\nexport default class UserFacade extends EventsDispatcher {\n pusher: Pusher;\n signin_requested: boolean = false;\n user_data: any = null;\n serverToUserChannel: Channel = null;\n signinDonePromise: Promise = null;\n watchlist: WatchlistFacade;\n private _signinDoneResolve: Function = null;\n\n public constructor(pusher: Pusher) {\n super(function(eventName, data) {\n Logger.debug('No callbacks on user for ' + eventName);\n });\n this.pusher = pusher;\n this.pusher.connection.bind('state_change', ({ previous, current }) => {\n if (previous !== 'connected' && current === 'connected') {\n this._signin();\n }\n if (previous === 'connected' && current !== 'connected') {\n this._cleanup();\n this._newSigninPromiseIfNeeded();\n }\n });\n\n this.watchlist = new WatchlistFacade(pusher);\n\n this.pusher.connection.bind('message', event => {\n var eventName = event.event;\n if (eventName === 'pusher:signin_success') {\n this._onSigninSuccess(event.data);\n }\n if (\n this.serverToUserChannel &&\n this.serverToUserChannel.name === event.channel\n ) {\n this.serverToUserChannel.handleEvent(event);\n }\n });\n }\n\n public signin() {\n if (this.signin_requested) {\n return;\n }\n\n this.signin_requested = true;\n this._signin();\n }\n\n private _signin() {\n if (!this.signin_requested) {\n return;\n }\n\n this._newSigninPromiseIfNeeded();\n\n if (this.pusher.connection.state !== 'connected') {\n // Signin will be attempted when the connection is connected\n return;\n }\n\n this.pusher.config.userAuthenticator(\n {\n socketId: this.pusher.connection.socket_id\n },\n this._onAuthorize\n );\n }\n\n private _onAuthorize: UserAuthenticationCallback = (\n err,\n authData: UserAuthenticationData\n ) => {\n if (err) {\n Logger.warn(`Error during signin: ${err}`);\n this._cleanup();\n return;\n }\n\n this.pusher.send_event('pusher:signin', {\n auth: authData.auth,\n user_data: authData.user_data\n });\n\n // Later when we get pusher:singin_success event, the user will be marked as signed in\n };\n\n private _onSigninSuccess(data: any) {\n try {\n this.user_data = JSON.parse(data.user_data);\n } catch (e) {\n Logger.error(`Failed parsing user data after signin: ${data.user_data}`);\n this._cleanup();\n return;\n }\n\n if (typeof this.user_data.id !== 'string' || this.user_data.id === '') {\n Logger.error(\n `user_data doesn't contain an id. user_data: ${this.user_data}`\n );\n this._cleanup();\n return;\n }\n\n // Signin succeeded\n this._signinDoneResolve();\n this._subscribeChannels();\n }\n\n private _subscribeChannels() {\n const ensure_subscribed = channel => {\n if (channel.subscriptionPending && channel.subscriptionCancelled) {\n channel.reinstateSubscription();\n } else if (\n !channel.subscriptionPending &&\n this.pusher.connection.state === 'connected'\n ) {\n channel.subscribe();\n }\n };\n\n this.serverToUserChannel = new Channel(\n `#server-to-user-${this.user_data.id}`,\n this.pusher\n );\n this.serverToUserChannel.bind_global((eventName, data) => {\n if (\n eventName.indexOf('pusher_internal:') === 0 ||\n eventName.indexOf('pusher:') === 0\n ) {\n // ignore internal events\n return;\n }\n this.emit(eventName, data);\n });\n ensure_subscribed(this.serverToUserChannel);\n }\n\n private _cleanup() {\n this.user_data = null;\n if (this.serverToUserChannel) {\n this.serverToUserChannel.unbind_all();\n this.serverToUserChannel.disconnect();\n this.serverToUserChannel = null;\n }\n\n if (this.signin_requested) {\n // If signin is in progress and cleanup is called,\n // Mark the current signin process as done.\n this._signinDoneResolve();\n }\n }\n\n private _newSigninPromiseIfNeeded() {\n if (!this.signin_requested) {\n return;\n }\n\n // If there is a promise and it is not resolved, return without creating a new one.\n if (this.signinDonePromise && !(this.signinDonePromise as any).done) {\n return;\n }\n\n // This promise is never rejected.\n // It gets resolved when the signin process is done whether it failed or succeeded\n const { promise, resolve, reject: _ } = flatPromise();\n (promise as any).done = false;\n const setDone = () => {\n (promise as any).done = true;\n };\n promise.then(setDone).catch(setDone);\n this.signinDonePromise = promise;\n this._signinDoneResolve = resolve;\n }\n}\n","import AbstractRuntime from '../runtimes/interface';\nimport Runtime from 'runtime';\nimport * as Collections from './utils/collections';\nimport Channels from './channels/channels';\nimport Channel from './channels/channel';\nimport { default as EventsDispatcher } from './events/dispatcher';\nimport Timeline from './timeline/timeline';\nimport TimelineSender from './timeline/timeline_sender';\nimport TimelineLevel from './timeline/level';\nimport { defineTransport } from './strategies/strategy_builder';\nimport ConnectionManager from './connection/connection_manager';\nimport { PeriodicTimer } from './utils/timers';\nimport Defaults from './defaults';\nimport Logger from './logger';\nimport Factory from './utils/factory';\nimport { Options, ClusterOptions, validateOptions } from './options';\nimport { Config, getConfig } from './config';\nimport StrategyOptions from './strategies/strategy_options';\nimport UserFacade from './user';\n\nexport default class Pusher {\n /* STATIC PROPERTIES */\n static instances: Pusher[] = [];\n static isReady: boolean = false;\n static logToConsole: boolean = false;\n\n // for jsonp\n static Runtime: AbstractRuntime = Runtime;\n static ScriptReceivers: any = (Runtime).ScriptReceivers;\n static DependenciesReceivers: any = (Runtime).DependenciesReceivers;\n static auth_callbacks: any = (Runtime).auth_callbacks;\n\n static ready() {\n Pusher.isReady = true;\n for (var i = 0, l = Pusher.instances.length; i < l; i++) {\n Pusher.instances[i].connect();\n }\n }\n\n static log: (message: any) => void;\n\n private static getClientFeatures(): string[] {\n return Collections.keys(\n Collections.filterObject({ ws: Runtime.Transports.ws }, function(t) {\n return t.isSupported({});\n })\n );\n }\n\n /* INSTANCE PROPERTIES */\n key: string;\n options: Options;\n config: Config;\n channels: Channels;\n global_emitter: EventsDispatcher;\n sessionID: number;\n timeline: Timeline;\n timelineSender: TimelineSender;\n connection: ConnectionManager;\n timelineSenderTimer: PeriodicTimer;\n user: UserFacade;\n constructor(app_key: string, options: Options) {\n checkAppKey(app_key);\n validateOptions(options);\n this.key = app_key;\n this.config = getConfig(options, this);\n\n this.channels = Factory.createChannels();\n this.global_emitter = new EventsDispatcher();\n this.sessionID = Runtime.randomInt(1000000000);\n\n this.timeline = new Timeline(this.key, this.sessionID, {\n cluster: this.config.cluster,\n features: Pusher.getClientFeatures(),\n params: this.config.timelineParams || {},\n limit: 50,\n level: TimelineLevel.INFO,\n version: Defaults.VERSION\n });\n if (this.config.enableStats) {\n this.timelineSender = Factory.createTimelineSender(this.timeline, {\n host: this.config.statsHost,\n path: '/timeline/v2/' + Runtime.TimelineTransport.name\n });\n }\n\n var getStrategy = (options: StrategyOptions) => {\n return Runtime.getDefaultStrategy(this.config, options, defineTransport);\n };\n\n this.connection = Factory.createConnectionManager(this.key, {\n getStrategy: getStrategy,\n timeline: this.timeline,\n activityTimeout: this.config.activityTimeout,\n pongTimeout: this.config.pongTimeout,\n unavailableTimeout: this.config.unavailableTimeout,\n useTLS: Boolean(this.config.useTLS)\n });\n\n this.connection.bind('connected', () => {\n this.subscribeAll();\n if (this.timelineSender) {\n this.timelineSender.send(this.connection.isUsingTLS());\n }\n });\n\n this.connection.bind('message', event => {\n var eventName = event.event;\n var internal = eventName.indexOf('pusher_internal:') === 0;\n if (event.channel) {\n var channel = this.channel(event.channel);\n if (channel) {\n channel.handleEvent(event);\n }\n }\n // Emit globally [deprecated]\n if (!internal) {\n this.global_emitter.emit(event.event, event.data);\n }\n });\n this.connection.bind('connecting', () => {\n this.channels.disconnect();\n });\n this.connection.bind('disconnected', () => {\n this.channels.disconnect();\n });\n this.connection.bind('error', err => {\n Logger.warn(err);\n });\n\n Pusher.instances.push(this);\n this.timeline.info({ instances: Pusher.instances.length });\n\n this.user = new UserFacade(this);\n\n if (Pusher.isReady) {\n this.connect();\n }\n }\n\n /**\n * Allows you to switch Pusher cluster without\n * losing all the channels/subscription binding\n * as this is internally managed by the SDK.\n */\n switchCluster(options: ClusterOptions) {\n const { appKey, cluster } = options;\n this.key = appKey;\n this.options = { ...this.options, cluster };\n this.config = getConfig(this.options, this);\n this.connection.switchCluster(this.key);\n }\n\n channel(name: string): Channel {\n return this.channels.find(name);\n }\n\n allChannels(): Channel[] {\n return this.channels.all();\n }\n\n connect() {\n this.connection.connect();\n\n if (this.timelineSender) {\n if (!this.timelineSenderTimer) {\n var usingTLS = this.connection.isUsingTLS();\n var timelineSender = this.timelineSender;\n this.timelineSenderTimer = new PeriodicTimer(60000, function() {\n timelineSender.send(usingTLS);\n });\n }\n }\n }\n\n disconnect() {\n this.connection.disconnect();\n\n if (this.timelineSenderTimer) {\n this.timelineSenderTimer.ensureAborted();\n this.timelineSenderTimer = null;\n }\n }\n\n bind(event_name: string, callback: Function, context?: any): Pusher {\n this.global_emitter.bind(event_name, callback, context);\n return this;\n }\n\n unbind(event_name?: string, callback?: Function, context?: any): Pusher {\n this.global_emitter.unbind(event_name, callback, context);\n return this;\n }\n\n bind_global(callback: Function): Pusher {\n this.global_emitter.bind_global(callback);\n return this;\n }\n\n unbind_global(callback?: Function): Pusher {\n this.global_emitter.unbind_global(callback);\n return this;\n }\n\n unbind_all(callback?: Function): Pusher {\n this.global_emitter.unbind_all();\n return this;\n }\n\n subscribeAll() {\n var channelName;\n for (channelName in this.channels.channels) {\n if (this.channels.channels.hasOwnProperty(channelName)) {\n this.subscribe(channelName);\n }\n }\n }\n\n subscribe(channel_name: string) {\n var channel = this.channels.add(channel_name, this);\n if (channel.subscriptionPending && channel.subscriptionCancelled) {\n channel.reinstateSubscription();\n } else if (\n !channel.subscriptionPending &&\n this.connection.state === 'connected'\n ) {\n channel.subscribe();\n }\n return channel;\n }\n\n unsubscribe(channel_name: string) {\n var channel = this.channels.find(channel_name);\n if (channel && channel.subscriptionPending) {\n channel.cancelSubscription();\n } else {\n channel = this.channels.remove(channel_name);\n if (channel && channel.subscribed) {\n channel.unsubscribe();\n }\n }\n }\n\n send_event(event_name: string, data: any, channel?: string) {\n return this.connection.send_event(event_name, data, channel);\n }\n\n shouldUseTLS(): boolean {\n return this.config.useTLS;\n }\n\n signin() {\n this.user.signin();\n }\n}\n\nfunction checkAppKey(key) {\n if (key === null || key === undefined) {\n throw 'You must pass your app key when you instantiate Pusher.';\n }\n}\n\nRuntime.setup(Pusher);\n","import ConnectionManager from './connection/connection_manager';\nimport {\n ChannelAuthorizationOptions,\n UserAuthenticationOptions\n} from './auth/options';\nimport {\n ChannelAuthorizerGenerator,\n DeprecatedAuthOptions\n} from './auth/deprecated_channel_authorizer';\nimport { AuthTransport, Transport } from './config';\nimport * as nacl from 'tweetnacl';\nimport Logger from './logger';\n\nexport interface Options {\n activityTimeout?: number;\n\n auth?: DeprecatedAuthOptions; // DEPRECATED use channelAuthorization instead\n authEndpoint?: string; // DEPRECATED use channelAuthorization instead\n authTransport?: AuthTransport; // DEPRECATED use channelAuthorization instead\n authorizer?: ChannelAuthorizerGenerator; // DEPRECATED use channelAuthorization instead\n\n channelAuthorization?: ChannelAuthorizationOptions;\n userAuthentication?: UserAuthenticationOptions;\n\n cluster: string;\n enableStats?: boolean;\n disableStats?: boolean;\n disabledTransports?: Transport[];\n enabledTransports?: Transport[];\n forceTLS?: boolean;\n httpHost?: string;\n httpPath?: string;\n httpPort?: number;\n httpsPort?: number;\n ignoreNullOrigin?: boolean;\n nacl?: nacl;\n pongTimeout?: number;\n statsHost?: string;\n timelineParams?: any;\n unavailableTimeout?: number;\n wsHost?: string;\n wsPath?: string;\n wsPort?: number;\n wssPort?: number;\n}\n\nexport interface ClusterOptions {\n appKey: string;\n cluster: string;\n}\n\nexport function validateOptions(options) {\n if (options == null) {\n throw 'You must pass an options object';\n }\n if (options.cluster == null) {\n throw 'Options object must provide a cluster';\n }\n if ('disableStats' in options) {\n Logger.warn(\n 'The disableStats option is deprecated in favor of enableStats'\n );\n }\n}\n"],"sourceRoot":""} \ No newline at end of file diff --git a/dist/worker/pusher-with-encryption.worker.js b/dist/worker/pusher-with-encryption.worker.js index a0b4ae110..a2ebda472 100644 --- a/dist/worker/pusher-with-encryption.worker.js +++ b/dist/worker/pusher-with-encryption.worker.js @@ -1,5 +1,5 @@ /*! - * Pusher JavaScript Library v8.3.0 + * Pusher JavaScript Library v8.4.0 * https://pusher.com/ * * Copyright 2020, Pusher @@ -3273,7 +3273,7 @@ function safeJSONStringify(source) { // CONCATENATED MODULE: ./src/core/defaults.ts var Defaults = { - VERSION: "8.3.0", + VERSION: "8.4.0", PROTOCOL: 7, wsPort: 80, wssPort: 443, @@ -4515,6 +4515,11 @@ class connection_manager_ConnectionManager extends dispatcher_Dispatcher { }); this.updateStrategy(); } + switchCluster(key) { + this.key = key; + this.updateStrategy(); + this.retryIn(0); + } connect() { if (this.connection || this.runner) { return; @@ -6497,6 +6502,13 @@ class pusher_Pusher { this.connect(); } } + switchCluster(options) { + const { appKey, cluster } = options; + this.key = appKey; + this.options = Object.assign(Object.assign({}, this.options), { cluster }); + this.config = getConfig(this.options, this); + this.connection.switchCluster(this.key); + } channel(name) { return this.channels.find(name); } diff --git a/dist/worker/pusher-with-encryption.worker.js.map b/dist/worker/pusher-with-encryption.worker.js.map index 9cca5f2b1..9a96ac022 100644 --- a/dist/worker/pusher-with-encryption.worker.js.map +++ b/dist/worker/pusher-with-encryption.worker.js.map @@ -1 +1 @@ -{"version":3,"sources":["webpack://Pusher/webpack/universalModuleDefinition","webpack://Pusher/webpack/bootstrap","webpack://Pusher/./node_modules/@stablelib/base64/base64.ts","webpack://Pusher/./node_modules/@stablelib/utf8/utf8.ts","webpack://Pusher/./node_modules/tweetnacl/nacl-fast.js","webpack://Pusher/./src/core/pusher-with-encryption.js","webpack://Pusher/crypto (ignored)","webpack://Pusher/./src/core/base64.ts","webpack://Pusher/./src/core/utils/timers/abstract_timer.ts","webpack://Pusher/./src/core/utils/timers/index.ts","webpack://Pusher/./src/core/util.ts","webpack://Pusher/./src/core/utils/collections.ts","webpack://Pusher/./src/core/defaults.ts","webpack://Pusher/./src/core/transports/url_schemes.ts","webpack://Pusher/./src/core/events/callback_registry.ts","webpack://Pusher/./src/core/events/dispatcher.ts","webpack://Pusher/./src/core/logger.ts","webpack://Pusher/./src/core/transports/transport_connection.ts","webpack://Pusher/./src/core/transports/transport.ts","webpack://Pusher/./src/runtimes/isomorphic/transports/transports.ts","webpack://Pusher/./src/core/transports/assistant_to_the_transport_manager.ts","webpack://Pusher/./src/core/connection/protocol/protocol.ts","webpack://Pusher/./src/core/connection/connection.ts","webpack://Pusher/./src/core/connection/handshake/index.ts","webpack://Pusher/./src/core/timeline/timeline_sender.ts","webpack://Pusher/./src/core/errors.ts","webpack://Pusher/./src/core/utils/url_store.ts","webpack://Pusher/./src/core/channels/channel.ts","webpack://Pusher/./src/core/channels/private_channel.ts","webpack://Pusher/./src/core/channels/members.ts","webpack://Pusher/./src/core/channels/presence_channel.ts","webpack://Pusher/./src/core/channels/encrypted_channel.ts","webpack://Pusher/./src/core/connection/connection_manager.ts","webpack://Pusher/./src/core/channels/channels.ts","webpack://Pusher/./src/core/utils/factory.ts","webpack://Pusher/./src/core/transports/transport_manager.ts","webpack://Pusher/./src/core/strategies/sequential_strategy.ts","webpack://Pusher/./src/core/strategies/best_connected_ever_strategy.ts","webpack://Pusher/./src/core/strategies/websocket_prioritized_cached_strategy.ts","webpack://Pusher/./src/core/strategies/delayed_strategy.ts","webpack://Pusher/./src/core/strategies/if_strategy.ts","webpack://Pusher/./src/core/strategies/first_connected_strategy.ts","webpack://Pusher/./src/runtimes/isomorphic/default_strategy.ts","webpack://Pusher/./src/runtimes/isomorphic/transports/transport_connection_initializer.ts","webpack://Pusher/./src/core/http/http_request.ts","webpack://Pusher/./src/core/http/state.ts","webpack://Pusher/./src/core/http/http_socket.ts","webpack://Pusher/./src/core/http/http_streaming_socket.ts","webpack://Pusher/./src/core/http/http_polling_socket.ts","webpack://Pusher/./src/runtimes/isomorphic/http/http_xhr_request.ts","webpack://Pusher/./src/runtimes/isomorphic/http/http.ts","webpack://Pusher/./src/runtimes/isomorphic/runtime.ts","webpack://Pusher/./src/runtimes/worker/net_info.ts","webpack://Pusher/./src/runtimes/worker/auth/fetch_auth.ts","webpack://Pusher/./src/runtimes/worker/timeline/fetch_timeline.ts","webpack://Pusher/./src/runtimes/worker/runtime.ts","webpack://Pusher/./src/core/timeline/level.ts","webpack://Pusher/./src/core/timeline/timeline.ts","webpack://Pusher/./src/core/strategies/transport_strategy.ts","webpack://Pusher/./src/core/strategies/strategy_builder.ts","webpack://Pusher/./src/core/options.ts","webpack://Pusher/./src/core/auth/options.ts","webpack://Pusher/./src/core/auth/user_authenticator.ts","webpack://Pusher/./src/core/auth/channel_authorizer.ts","webpack://Pusher/./src/core/auth/deprecated_channel_authorizer.ts","webpack://Pusher/./src/core/config.ts","webpack://Pusher/./src/core/watchlist.ts","webpack://Pusher/./src/core/utils/flat_promise.ts","webpack://Pusher/./src/core/user.ts","webpack://Pusher/./src/core/pusher.ts","webpack://Pusher/./src/core/pusher-with-encryption.ts"],"names":[],"mappings":";;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AACD,O;QCVA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;;QAEA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;;;QAGA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;QACA,0CAA0C,gCAAgC;QAC1E;QACA;;QAEA;QACA;QACA;QACA,wDAAwD,kBAAkB;QAC1E;QACA,iDAAiD,cAAc;QAC/D;;QAEA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA,yCAAyC,iCAAiC;QAC1E,gHAAgH,mBAAmB,EAAE;QACrI;QACA;;QAEA;QACA;QACA;QACA,2BAA2B,0BAA0B,EAAE;QACvD,iCAAiC,eAAe;QAChD;QACA;QACA;;QAEA;QACA,sDAAsD,+DAA+D;;QAErH;QACA;;;QAGA;QACA;;;;;;;;;AClFA,sCAAsC;AACtC,6CAA6C;;;;;;;;;;;;;;;AAE7C;;GAEG;AAEH,iDAAiD;AACjD,kDAAkD;AAClD,kCAAkC;AACl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A;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,aAAa,QAAQ;AACrB,aAAa,OAAO;AACpB;AACA;AACA,eAAe,QAAQ;AACvB;AACA,eAAe,QAAQ;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB;AACA;AACA;;AAEA;AACA;AACA;AACA,aAAa,QAAQ;AACrB,aAAa,OAAO;AACpB;AACA;AACA,eAAe,QAAQ;AACvB;AACA,eAAe,QAAQ;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,iBAAiB,OAAO;AACxB;AACA;;AAEA;AACA;AACA;AACA;AACA,iBAAiB,OAAO;AACxB;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA,8CAA8C;AAC9C,8CAA8C;AAC9C,8CAA8C;AAC9C,8CAA8C;AAC9C,8CAA8C;AAC9C;AACA,8CAA8C;AAC9C,8CAA8C;AAC9C,8CAA8C;AAC9C;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,sDAAsD;AACtD,sDAAsD;AACtD,sDAAsD;AACtD,sDAAsD;AACtD,sDAAsD;AACtD;AACA,sDAAsD;AACtD,sDAAsD;AACtD,sDAAsD;AACtD;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA,qBAAqB;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA,qBAAqB;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA,qBAAqB;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA,qBAAqB;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA,qBAAqB;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA,qBAAqB;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA,qBAAqB;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA,qBAAqB;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA,qBAAqB;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA,qBAAqB;;AAErB;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA,UAAU,QAAQ;AAClB;AACA;AACA;;AAEA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA;AACA;;AAEA;AACA,aAAa,QAAQ;AACrB;AACA,aAAa,QAAQ;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa,OAAO;AACpB;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,UAAU;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,eAAe,WAAW;AAC1B;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;;AAEA;AACA;AACA,aAAa,QAAQ;AACrB;;AAEA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA,aAAa,OAAO;AACpB;AACA,eAAe,QAAQ;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;;AAEA;AACA,iBAAiB,QAAQ;AACzB;;AAEA;AACA,iBAAiB,QAAQ;AACzB;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,sBAAsB,2BA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;AACA;AACA;AACA;AACA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,eAAe,QAAQ;AACvB;AACA;AACA;AACA;AACA,eAAe,QAAQ;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA,qBAAqB;AACrB,qBAAqB;;AAErB;AACA;AACA;;AAEA,sBAAsB;AACtB,sBAAsB;;AAEtB;AACA;AACA;;AAEA,sBAAsB;AACtB,sBAAsB;;AAEtB;AACA;AACA;;AAEA,sBAAsB;AACtB,sBAAsB;;AAEtB;AACA;AACA;;AAEA,sBAAsB;AACtB,sBAAsB;;AAEtB;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA,qBAAqB;AACrB,qBAAqB;;AAErB;AACA;AACA;;AAEA,sBAAsB;AACtB,sBAAsB;;AAEtB;AACA;AACA;;AAEA,sBAAsB;AACtB,sBAAsB;;AAEtB;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA,qBAAqB;AACrB,qBAAqB;;AAErB;AACA;;AAEA,sBAAsB;AACtB,sBAAsB;;AAEtB;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mBAAmB;;AAEnB;AACA;;AAEA,oBAAoB;AACpB,oBAAoB;;AAEpB;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA,aAAa,OAAO;AACpB;;AAEA;AACA;AACA;AACA;;AAEA,aAAa,OAAO;;AAEpB;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa,OAAO;AACpB;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,QAAQ;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA,aAAa,QAAQ;AACrB;AACA;;AAEA;;AAEA;AACA;AACA,cAAc,SAAS;AACvB;AACA,gCAAgC,OAAO;AACvC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA;AACA,aAAa,QAAQ;AACrB,aAAa,QAAQ;AACrB;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa,QAAQ;AACrB,aAAa,QAAQ;AACrB;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA,aAAa,OAAO;AACpB,aAAa,QAAQ;;AAErB;AACA;AACA;AACA;;AAEA,cAAc,QAAQ;AACtB;AACA;;AAEA,aAAa,QAAQ;AACrB,aAAa,QAAQ;AACrB,aAAa,QAAQ;AACrB,eAAe,QAAQ;AACvB;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;;AAEA,aAAa,OAAO;AACpB,aAAa,QAAQ;AACrB;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA,eAAe,OAAO;AACtB;AACA;;AAEA,aAAa,OAAO;AACpB;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA,iBAAiB,sBAAsB;AACvC;AACA;AACA;AACA;;AAEA;AACA,iBAAiB,gBAAgB;AACjC;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,iBAAiB,gBAAgB;AACjC;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,iBAAiB,gBAAgB;AACjC;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA,UAAU;AACV;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,UAAU;AACV;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAiB,cAAc;AAC/B;AACA;;AAEA;AACA;AACA;AACA,iBAAiB,gBAAgB;AACjC;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa,uBAAuB;AACpC,aAAa,gBAAgB;AAC7B;AACA;;AAEA;AACA;AACA;AACA;AACA,UAAU;AACV;;AAEA;AACA;AACA;AACA;AACA;AACA,iBAAiB,eAAe;AAChC,UAAU;AACV;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAiB,QAAQ;AACzB;AACA,UAAU;AACV;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAiB,OAAO;AACxB;AACA;AACA,iBAAiB,OAAO;AACxB;AACA,KAAK;AACL,GAAG,UAAU,IAA8B;AAC3C;AACA,aAAa,mBAAO,CAAC,CAAQ;AAC7B;AACA;AACA;AACA,mBAAmB,OAAO;AAC1B;AACA,OAAO;AACP;AACA;AACA,CAAC;;AAED,CAAC,EAAE,KAA6B,kEAAkE;;;;;;;ACt1ElG,iBAAiB,mBAAO,CAAC,CAA0B;;;;;;;ACAnD,e;;;;;;;;;;;;;;ACAe,SAAS,MAAM,CAAC,CAAM;IACnC,OAAO,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;AACvB,CAAC;AAED,IAAI,YAAY,GAAG,MAAM,CAAC,YAAY,CAAC;AAEvC,IAAI,QAAQ,GACV,kEAAkE,CAAC;AACrE,IAAI,MAAM,GAAG,EAAE,CAAC;AAEhB,KAA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CAAC;QAEtC,eAAe,CAAC,OAAO,CAAC,CAAC;QACzB,OAAO,CAAC,IAAI,GAAG,SAAI,CAAC;QACpB,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAC1B,CAAC;CACF","file":"pusher-with-encryption.worker.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"Pusher\"] = factory();\n\telse\n\t\troot[\"Pusher\"] = factory();\n})(this, function() {\nreturn "," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 3);\n","// Copyright (C) 2016 Dmitry Chestnykh\n// MIT License. See LICENSE file for details.\n\n/**\n * Package base64 implements Base64 encoding and decoding.\n */\n\n// Invalid character used in decoding to indicate\n// that the character to decode is out of range of\n// alphabet and cannot be decoded.\nconst INVALID_BYTE = 256;\n\n/**\n * Implements standard Base64 encoding.\n *\n * Operates in constant time.\n */\nexport class Coder {\n // TODO(dchest): methods to encode chunk-by-chunk.\n\n constructor(private _paddingCharacter = \"=\") { }\n\n encodedLength(length: number): number {\n if (!this._paddingCharacter) {\n return (length * 8 + 5) / 6 | 0;\n }\n return (length + 2) / 3 * 4 | 0;\n }\n\n encode(data: Uint8Array): string {\n let out = \"\";\n\n let i = 0;\n for (; i < data.length - 2; i += 3) {\n let c = (data[i] << 16) | (data[i + 1] << 8) | (data[i + 2]);\n out += this._encodeByte((c >>> 3 * 6) & 63);\n out += this._encodeByte((c >>> 2 * 6) & 63);\n out += this._encodeByte((c >>> 1 * 6) & 63);\n out += this._encodeByte((c >>> 0 * 6) & 63);\n }\n\n const left = data.length - i;\n if (left > 0) {\n let c = (data[i] << 16) | (left === 2 ? data[i + 1] << 8 : 0);\n out += this._encodeByte((c >>> 3 * 6) & 63);\n out += this._encodeByte((c >>> 2 * 6) & 63);\n if (left === 2) {\n out += this._encodeByte((c >>> 1 * 6) & 63);\n } else {\n out += this._paddingCharacter || \"\";\n }\n out += this._paddingCharacter || \"\";\n }\n\n return out;\n }\n\n maxDecodedLength(length: number): number {\n if (!this._paddingCharacter) {\n return (length * 6 + 7) / 8 | 0;\n }\n return length / 4 * 3 | 0;\n }\n\n decodedLength(s: string): number {\n return this.maxDecodedLength(s.length - this._getPaddingLength(s));\n }\n\n decode(s: string): Uint8Array {\n if (s.length === 0) {\n return new Uint8Array(0);\n }\n const paddingLength = this._getPaddingLength(s);\n const length = s.length - paddingLength;\n const out = new Uint8Array(this.maxDecodedLength(length));\n let op = 0;\n let i = 0;\n let haveBad = 0;\n let v0 = 0, v1 = 0, v2 = 0, v3 = 0;\n for (; i < length - 4; i += 4) {\n v0 = this._decodeChar(s.charCodeAt(i + 0));\n v1 = this._decodeChar(s.charCodeAt(i + 1));\n v2 = this._decodeChar(s.charCodeAt(i + 2));\n v3 = this._decodeChar(s.charCodeAt(i + 3));\n out[op++] = (v0 << 2) | (v1 >>> 4);\n out[op++] = (v1 << 4) | (v2 >>> 2);\n out[op++] = (v2 << 6) | v3;\n haveBad |= v0 & INVALID_BYTE;\n haveBad |= v1 & INVALID_BYTE;\n haveBad |= v2 & INVALID_BYTE;\n haveBad |= v3 & INVALID_BYTE;\n }\n if (i < length - 1) {\n v0 = this._decodeChar(s.charCodeAt(i));\n v1 = this._decodeChar(s.charCodeAt(i + 1));\n out[op++] = (v0 << 2) | (v1 >>> 4);\n haveBad |= v0 & INVALID_BYTE;\n haveBad |= v1 & INVALID_BYTE;\n }\n if (i < length - 2) {\n v2 = this._decodeChar(s.charCodeAt(i + 2));\n out[op++] = (v1 << 4) | (v2 >>> 2);\n haveBad |= v2 & INVALID_BYTE;\n }\n if (i < length - 3) {\n v3 = this._decodeChar(s.charCodeAt(i + 3));\n out[op++] = (v2 << 6) | v3;\n haveBad |= v3 & INVALID_BYTE;\n }\n if (haveBad !== 0) {\n throw new Error(\"Base64Coder: incorrect characters for decoding\");\n }\n return out;\n }\n\n // Standard encoding have the following encoded/decoded ranges,\n // which we need to convert between.\n //\n // ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 0123456789 + /\n // Index: 0 - 25 26 - 51 52 - 61 62 63\n // ASCII: 65 - 90 97 - 122 48 - 57 43 47\n //\n\n // Encode 6 bits in b into a new character.\n protected _encodeByte(b: number): string {\n // Encoding uses constant time operations as follows:\n //\n // 1. Define comparison of A with B using (A - B) >>> 8:\n // if A > B, then result is positive integer\n // if A <= B, then result is 0\n //\n // 2. Define selection of C or 0 using bitwise AND: X & C:\n // if X == 0, then result is 0\n // if X != 0, then result is C\n //\n // 3. Start with the smallest comparison (b >= 0), which is always\n // true, so set the result to the starting ASCII value (65).\n //\n // 4. Continue comparing b to higher ASCII values, and selecting\n // zero if comparison isn't true, otherwise selecting a value\n // to add to result, which:\n //\n // a) undoes the previous addition\n // b) provides new value to add\n //\n let result = b;\n // b >= 0\n result += 65;\n // b > 25\n result += ((25 - b) >>> 8) & ((0 - 65) - 26 + 97);\n // b > 51\n result += ((51 - b) >>> 8) & ((26 - 97) - 52 + 48);\n // b > 61\n result += ((61 - b) >>> 8) & ((52 - 48) - 62 + 43);\n // b > 62\n result += ((62 - b) >>> 8) & ((62 - 43) - 63 + 47);\n\n return String.fromCharCode(result);\n }\n\n // Decode a character code into a byte.\n // Must return 256 if character is out of alphabet range.\n protected _decodeChar(c: number): number {\n // Decoding works similar to encoding: using the same comparison\n // function, but now it works on ranges: result is always incremented\n // by value, but this value becomes zero if the range is not\n // satisfied.\n //\n // Decoding starts with invalid value, 256, which is then\n // subtracted when the range is satisfied. If none of the ranges\n // apply, the function returns 256, which is then checked by\n // the caller to throw error.\n let result = INVALID_BYTE; // start with invalid character\n\n // c == 43 (c > 42 and c < 44)\n result += (((42 - c) & (c - 44)) >>> 8) & (-INVALID_BYTE + c - 43 + 62);\n // c == 47 (c > 46 and c < 48)\n result += (((46 - c) & (c - 48)) >>> 8) & (-INVALID_BYTE + c - 47 + 63);\n // c > 47 and c < 58\n result += (((47 - c) & (c - 58)) >>> 8) & (-INVALID_BYTE + c - 48 + 52);\n // c > 64 and c < 91\n result += (((64 - c) & (c - 91)) >>> 8) & (-INVALID_BYTE + c - 65 + 0);\n // c > 96 and c < 123\n result += (((96 - c) & (c - 123)) >>> 8) & (-INVALID_BYTE + c - 97 + 26);\n\n return result;\n }\n\n private _getPaddingLength(s: string): number {\n let paddingLength = 0;\n if (this._paddingCharacter) {\n for (let i = s.length - 1; i >= 0; i--) {\n if (s[i] !== this._paddingCharacter) {\n break;\n }\n paddingLength++;\n }\n if (s.length < 4 || paddingLength > 2) {\n throw new Error(\"Base64Coder: incorrect padding\");\n }\n }\n return paddingLength;\n }\n\n}\n\nconst stdCoder = new Coder();\n\nexport function encode(data: Uint8Array): string {\n return stdCoder.encode(data);\n}\n\nexport function decode(s: string): Uint8Array {\n return stdCoder.decode(s);\n}\n\n/**\n * Implements URL-safe Base64 encoding.\n * (Same as Base64, but '+' is replaced with '-', and '/' with '_').\n *\n * Operates in constant time.\n */\nexport class URLSafeCoder extends Coder {\n // URL-safe encoding have the following encoded/decoded ranges:\n //\n // ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 0123456789 - _\n // Index: 0 - 25 26 - 51 52 - 61 62 63\n // ASCII: 65 - 90 97 - 122 48 - 57 45 95\n //\n\n protected _encodeByte(b: number): string {\n let result = b;\n // b >= 0\n result += 65;\n // b > 25\n result += ((25 - b) >>> 8) & ((0 - 65) - 26 + 97);\n // b > 51\n result += ((51 - b) >>> 8) & ((26 - 97) - 52 + 48);\n // b > 61\n result += ((61 - b) >>> 8) & ((52 - 48) - 62 + 45);\n // b > 62\n result += ((62 - b) >>> 8) & ((62 - 45) - 63 + 95);\n\n return String.fromCharCode(result);\n }\n\n protected _decodeChar(c: number): number {\n let result = INVALID_BYTE;\n\n // c == 45 (c > 44 and c < 46)\n result += (((44 - c) & (c - 46)) >>> 8) & (-INVALID_BYTE + c - 45 + 62);\n // c == 95 (c > 94 and c < 96)\n result += (((94 - c) & (c - 96)) >>> 8) & (-INVALID_BYTE + c - 95 + 63);\n // c > 47 and c < 58\n result += (((47 - c) & (c - 58)) >>> 8) & (-INVALID_BYTE + c - 48 + 52);\n // c > 64 and c < 91\n result += (((64 - c) & (c - 91)) >>> 8) & (-INVALID_BYTE + c - 65 + 0);\n // c > 96 and c < 123\n result += (((96 - c) & (c - 123)) >>> 8) & (-INVALID_BYTE + c - 97 + 26);\n\n return result;\n }\n}\n\nconst urlSafeCoder = new URLSafeCoder();\n\nexport function encodeURLSafe(data: Uint8Array): string {\n return urlSafeCoder.encode(data);\n}\n\nexport function decodeURLSafe(s: string): Uint8Array {\n return urlSafeCoder.decode(s);\n}\n\n\nexport const encodedLength = (length: number) =>\n stdCoder.encodedLength(length);\n\nexport const maxDecodedLength = (length: number) =>\n stdCoder.maxDecodedLength(length);\n\nexport const decodedLength = (s: string) =>\n stdCoder.decodedLength(s);\n","// Copyright (C) 2016 Dmitry Chestnykh\n// MIT License. See LICENSE file for details.\n\n/**\n * Package utf8 implements UTF-8 encoding and decoding.\n */\n\nconst INVALID_UTF16 = \"utf8: invalid string\";\nconst INVALID_UTF8 = \"utf8: invalid source encoding\";\n\n/**\n * Encodes the given string into UTF-8 byte array.\n * Throws if the source string has invalid UTF-16 encoding.\n */\nexport function encode(s: string): Uint8Array {\n // Calculate result length and allocate output array.\n // encodedLength() also validates string and throws errors,\n // so we don't need repeat validation here.\n const arr = new Uint8Array(encodedLength(s));\n\n let pos = 0;\n for (let i = 0; i < s.length; i++) {\n let c = s.charCodeAt(i);\n if (c < 0x80) {\n arr[pos++] = c;\n } else if (c < 0x800) {\n arr[pos++] = 0xc0 | c >> 6;\n arr[pos++] = 0x80 | c & 0x3f;\n } else if (c < 0xd800) {\n arr[pos++] = 0xe0 | c >> 12;\n arr[pos++] = 0x80 | (c >> 6) & 0x3f;\n arr[pos++] = 0x80 | c & 0x3f;\n } else {\n i++; // get one more character\n c = (c & 0x3ff) << 10;\n c |= s.charCodeAt(i) & 0x3ff;\n c += 0x10000;\n\n arr[pos++] = 0xf0 | c >> 18;\n arr[pos++] = 0x80 | (c >> 12) & 0x3f;\n arr[pos++] = 0x80 | (c >> 6) & 0x3f;\n arr[pos++] = 0x80 | c & 0x3f;\n }\n }\n return arr;\n}\n\n/**\n * Returns the number of bytes required to encode the given string into UTF-8.\n * Throws if the source string has invalid UTF-16 encoding.\n */\nexport function encodedLength(s: string): number {\n let result = 0;\n for (let i = 0; i < s.length; i++) {\n const c = s.charCodeAt(i);\n if (c < 0x80) {\n result += 1;\n } else if (c < 0x800) {\n result += 2;\n } else if (c < 0xd800) {\n result += 3;\n } else if (c <= 0xdfff) {\n if (i >= s.length - 1) {\n throw new Error(INVALID_UTF16);\n }\n i++; // \"eat\" next character\n result += 4;\n } else {\n throw new Error(INVALID_UTF16);\n }\n }\n return result;\n}\n\n/**\n * Decodes the given byte array from UTF-8 into a string.\n * Throws if encoding is invalid.\n */\nexport function decode(arr: Uint8Array): string {\n const chars: string[] = [];\n for (let i = 0; i < arr.length; i++) {\n let b = arr[i];\n\n if (b & 0x80) {\n let min;\n if (b < 0xe0) {\n // Need 1 more byte.\n if (i >= arr.length) {\n throw new Error(INVALID_UTF8);\n }\n const n1 = arr[++i];\n if ((n1 & 0xc0) !== 0x80) {\n throw new Error(INVALID_UTF8);\n }\n b = (b & 0x1f) << 6 | (n1 & 0x3f);\n min = 0x80;\n } else if (b < 0xf0) {\n // Need 2 more bytes.\n if (i >= arr.length - 1) {\n throw new Error(INVALID_UTF8);\n }\n const n1 = arr[++i];\n const n2 = arr[++i];\n if ((n1 & 0xc0) !== 0x80 || (n2 & 0xc0) !== 0x80) {\n throw new Error(INVALID_UTF8);\n }\n b = (b & 0x0f) << 12 | (n1 & 0x3f) << 6 | (n2 & 0x3f);\n min = 0x800;\n } else if (b < 0xf8) {\n // Need 3 more bytes.\n if (i >= arr.length - 2) {\n throw new Error(INVALID_UTF8);\n }\n const n1 = arr[++i];\n const n2 = arr[++i];\n const n3 = arr[++i];\n if ((n1 & 0xc0) !== 0x80 || (n2 & 0xc0) !== 0x80 || (n3 & 0xc0) !== 0x80) {\n throw new Error(INVALID_UTF8);\n }\n b = (b & 0x0f) << 18 | (n1 & 0x3f) << 12 | (n2 & 0x3f) << 6 | (n3 & 0x3f);\n min = 0x10000;\n } else {\n throw new Error(INVALID_UTF8);\n }\n\n if (b < min || (b >= 0xd800 && b <= 0xdfff)) {\n throw new Error(INVALID_UTF8);\n }\n\n if (b >= 0x10000) {\n // Surrogate pair.\n if (b > 0x10ffff) {\n throw new Error(INVALID_UTF8);\n }\n b -= 0x10000;\n chars.push(String.fromCharCode(0xd800 | (b >> 10)));\n b = 0xdc00 | (b & 0x3ff);\n }\n }\n\n chars.push(String.fromCharCode(b));\n }\n return chars.join(\"\");\n}\n","(function(nacl) {\n'use strict';\n\n// Ported in 2014 by Dmitry Chestnykh and Devi Mandiri.\n// Public domain.\n//\n// Implementation derived from TweetNaCl version 20140427.\n// See for details: http://tweetnacl.cr.yp.to/\n\nvar gf = function(init) {\n var i, r = new Float64Array(16);\n if (init) for (i = 0; i < init.length; i++) r[i] = init[i];\n return r;\n};\n\n// Pluggable, initialized in high-level API below.\nvar randombytes = function(/* x, n */) { throw new Error('no PRNG'); };\n\nvar _0 = new Uint8Array(16);\nvar _9 = new Uint8Array(32); _9[0] = 9;\n\nvar gf0 = gf(),\n gf1 = gf([1]),\n _121665 = gf([0xdb41, 1]),\n D = gf([0x78a3, 0x1359, 0x4dca, 0x75eb, 0xd8ab, 0x4141, 0x0a4d, 0x0070, 0xe898, 0x7779, 0x4079, 0x8cc7, 0xfe73, 0x2b6f, 0x6cee, 0x5203]),\n D2 = gf([0xf159, 0x26b2, 0x9b94, 0xebd6, 0xb156, 0x8283, 0x149a, 0x00e0, 0xd130, 0xeef3, 0x80f2, 0x198e, 0xfce7, 0x56df, 0xd9dc, 0x2406]),\n X = gf([0xd51a, 0x8f25, 0x2d60, 0xc956, 0xa7b2, 0x9525, 0xc760, 0x692c, 0xdc5c, 0xfdd6, 0xe231, 0xc0a4, 0x53fe, 0xcd6e, 0x36d3, 0x2169]),\n Y = gf([0x6658, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666]),\n I = gf([0xa0b0, 0x4a0e, 0x1b27, 0xc4ee, 0xe478, 0xad2f, 0x1806, 0x2f43, 0xd7a7, 0x3dfb, 0x0099, 0x2b4d, 0xdf0b, 0x4fc1, 0x2480, 0x2b83]);\n\nfunction ts64(x, i, h, l) {\n x[i] = (h >> 24) & 0xff;\n x[i+1] = (h >> 16) & 0xff;\n x[i+2] = (h >> 8) & 0xff;\n x[i+3] = h & 0xff;\n x[i+4] = (l >> 24) & 0xff;\n x[i+5] = (l >> 16) & 0xff;\n x[i+6] = (l >> 8) & 0xff;\n x[i+7] = l & 0xff;\n}\n\nfunction vn(x, xi, y, yi, n) {\n var i,d = 0;\n for (i = 0; i < n; i++) d |= x[xi+i]^y[yi+i];\n return (1 & ((d - 1) >>> 8)) - 1;\n}\n\nfunction crypto_verify_16(x, xi, y, yi) {\n return vn(x,xi,y,yi,16);\n}\n\nfunction crypto_verify_32(x, xi, y, yi) {\n return vn(x,xi,y,yi,32);\n}\n\nfunction core_salsa20(o, p, k, c) {\n var j0 = c[ 0] & 0xff | (c[ 1] & 0xff)<<8 | (c[ 2] & 0xff)<<16 | (c[ 3] & 0xff)<<24,\n j1 = k[ 0] & 0xff | (k[ 1] & 0xff)<<8 | (k[ 2] & 0xff)<<16 | (k[ 3] & 0xff)<<24,\n j2 = k[ 4] & 0xff | (k[ 5] & 0xff)<<8 | (k[ 6] & 0xff)<<16 | (k[ 7] & 0xff)<<24,\n j3 = k[ 8] & 0xff | (k[ 9] & 0xff)<<8 | (k[10] & 0xff)<<16 | (k[11] & 0xff)<<24,\n j4 = k[12] & 0xff | (k[13] & 0xff)<<8 | (k[14] & 0xff)<<16 | (k[15] & 0xff)<<24,\n j5 = c[ 4] & 0xff | (c[ 5] & 0xff)<<8 | (c[ 6] & 0xff)<<16 | (c[ 7] & 0xff)<<24,\n j6 = p[ 0] & 0xff | (p[ 1] & 0xff)<<8 | (p[ 2] & 0xff)<<16 | (p[ 3] & 0xff)<<24,\n j7 = p[ 4] & 0xff | (p[ 5] & 0xff)<<8 | (p[ 6] & 0xff)<<16 | (p[ 7] & 0xff)<<24,\n j8 = p[ 8] & 0xff | (p[ 9] & 0xff)<<8 | (p[10] & 0xff)<<16 | (p[11] & 0xff)<<24,\n j9 = p[12] & 0xff | (p[13] & 0xff)<<8 | (p[14] & 0xff)<<16 | (p[15] & 0xff)<<24,\n j10 = c[ 8] & 0xff | (c[ 9] & 0xff)<<8 | (c[10] & 0xff)<<16 | (c[11] & 0xff)<<24,\n j11 = k[16] & 0xff | (k[17] & 0xff)<<8 | (k[18] & 0xff)<<16 | (k[19] & 0xff)<<24,\n j12 = k[20] & 0xff | (k[21] & 0xff)<<8 | (k[22] & 0xff)<<16 | (k[23] & 0xff)<<24,\n j13 = k[24] & 0xff | (k[25] & 0xff)<<8 | (k[26] & 0xff)<<16 | (k[27] & 0xff)<<24,\n j14 = k[28] & 0xff | (k[29] & 0xff)<<8 | (k[30] & 0xff)<<16 | (k[31] & 0xff)<<24,\n j15 = c[12] & 0xff | (c[13] & 0xff)<<8 | (c[14] & 0xff)<<16 | (c[15] & 0xff)<<24;\n\n var x0 = j0, x1 = j1, x2 = j2, x3 = j3, x4 = j4, x5 = j5, x6 = j6, x7 = j7,\n x8 = j8, x9 = j9, x10 = j10, x11 = j11, x12 = j12, x13 = j13, x14 = j14,\n x15 = j15, u;\n\n for (var i = 0; i < 20; i += 2) {\n u = x0 + x12 | 0;\n x4 ^= u<<7 | u>>>(32-7);\n u = x4 + x0 | 0;\n x8 ^= u<<9 | u>>>(32-9);\n u = x8 + x4 | 0;\n x12 ^= u<<13 | u>>>(32-13);\n u = x12 + x8 | 0;\n x0 ^= u<<18 | u>>>(32-18);\n\n u = x5 + x1 | 0;\n x9 ^= u<<7 | u>>>(32-7);\n u = x9 + x5 | 0;\n x13 ^= u<<9 | u>>>(32-9);\n u = x13 + x9 | 0;\n x1 ^= u<<13 | u>>>(32-13);\n u = x1 + x13 | 0;\n x5 ^= u<<18 | u>>>(32-18);\n\n u = x10 + x6 | 0;\n x14 ^= u<<7 | u>>>(32-7);\n u = x14 + x10 | 0;\n x2 ^= u<<9 | u>>>(32-9);\n u = x2 + x14 | 0;\n x6 ^= u<<13 | u>>>(32-13);\n u = x6 + x2 | 0;\n x10 ^= u<<18 | u>>>(32-18);\n\n u = x15 + x11 | 0;\n x3 ^= u<<7 | u>>>(32-7);\n u = x3 + x15 | 0;\n x7 ^= u<<9 | u>>>(32-9);\n u = x7 + x3 | 0;\n x11 ^= u<<13 | u>>>(32-13);\n u = x11 + x7 | 0;\n x15 ^= u<<18 | u>>>(32-18);\n\n u = x0 + x3 | 0;\n x1 ^= u<<7 | u>>>(32-7);\n u = x1 + x0 | 0;\n x2 ^= u<<9 | u>>>(32-9);\n u = x2 + x1 | 0;\n x3 ^= u<<13 | u>>>(32-13);\n u = x3 + x2 | 0;\n x0 ^= u<<18 | u>>>(32-18);\n\n u = x5 + x4 | 0;\n x6 ^= u<<7 | u>>>(32-7);\n u = x6 + x5 | 0;\n x7 ^= u<<9 | u>>>(32-9);\n u = x7 + x6 | 0;\n x4 ^= u<<13 | u>>>(32-13);\n u = x4 + x7 | 0;\n x5 ^= u<<18 | u>>>(32-18);\n\n u = x10 + x9 | 0;\n x11 ^= u<<7 | u>>>(32-7);\n u = x11 + x10 | 0;\n x8 ^= u<<9 | u>>>(32-9);\n u = x8 + x11 | 0;\n x9 ^= u<<13 | u>>>(32-13);\n u = x9 + x8 | 0;\n x10 ^= u<<18 | u>>>(32-18);\n\n u = x15 + x14 | 0;\n x12 ^= u<<7 | u>>>(32-7);\n u = x12 + x15 | 0;\n x13 ^= u<<9 | u>>>(32-9);\n u = x13 + x12 | 0;\n x14 ^= u<<13 | u>>>(32-13);\n u = x14 + x13 | 0;\n x15 ^= u<<18 | u>>>(32-18);\n }\n x0 = x0 + j0 | 0;\n x1 = x1 + j1 | 0;\n x2 = x2 + j2 | 0;\n x3 = x3 + j3 | 0;\n x4 = x4 + j4 | 0;\n x5 = x5 + j5 | 0;\n x6 = x6 + j6 | 0;\n x7 = x7 + j7 | 0;\n x8 = x8 + j8 | 0;\n x9 = x9 + j9 | 0;\n x10 = x10 + j10 | 0;\n x11 = x11 + j11 | 0;\n x12 = x12 + j12 | 0;\n x13 = x13 + j13 | 0;\n x14 = x14 + j14 | 0;\n x15 = x15 + j15 | 0;\n\n o[ 0] = x0 >>> 0 & 0xff;\n o[ 1] = x0 >>> 8 & 0xff;\n o[ 2] = x0 >>> 16 & 0xff;\n o[ 3] = x0 >>> 24 & 0xff;\n\n o[ 4] = x1 >>> 0 & 0xff;\n o[ 5] = x1 >>> 8 & 0xff;\n o[ 6] = x1 >>> 16 & 0xff;\n o[ 7] = x1 >>> 24 & 0xff;\n\n o[ 8] = x2 >>> 0 & 0xff;\n o[ 9] = x2 >>> 8 & 0xff;\n o[10] = x2 >>> 16 & 0xff;\n o[11] = x2 >>> 24 & 0xff;\n\n o[12] = x3 >>> 0 & 0xff;\n o[13] = x3 >>> 8 & 0xff;\n o[14] = x3 >>> 16 & 0xff;\n o[15] = x3 >>> 24 & 0xff;\n\n o[16] = x4 >>> 0 & 0xff;\n o[17] = x4 >>> 8 & 0xff;\n o[18] = x4 >>> 16 & 0xff;\n o[19] = x4 >>> 24 & 0xff;\n\n o[20] = x5 >>> 0 & 0xff;\n o[21] = x5 >>> 8 & 0xff;\n o[22] = x5 >>> 16 & 0xff;\n o[23] = x5 >>> 24 & 0xff;\n\n o[24] = x6 >>> 0 & 0xff;\n o[25] = x6 >>> 8 & 0xff;\n o[26] = x6 >>> 16 & 0xff;\n o[27] = x6 >>> 24 & 0xff;\n\n o[28] = x7 >>> 0 & 0xff;\n o[29] = x7 >>> 8 & 0xff;\n o[30] = x7 >>> 16 & 0xff;\n o[31] = x7 >>> 24 & 0xff;\n\n o[32] = x8 >>> 0 & 0xff;\n o[33] = x8 >>> 8 & 0xff;\n o[34] = x8 >>> 16 & 0xff;\n o[35] = x8 >>> 24 & 0xff;\n\n o[36] = x9 >>> 0 & 0xff;\n o[37] = x9 >>> 8 & 0xff;\n o[38] = x9 >>> 16 & 0xff;\n o[39] = x9 >>> 24 & 0xff;\n\n o[40] = x10 >>> 0 & 0xff;\n o[41] = x10 >>> 8 & 0xff;\n o[42] = x10 >>> 16 & 0xff;\n o[43] = x10 >>> 24 & 0xff;\n\n o[44] = x11 >>> 0 & 0xff;\n o[45] = x11 >>> 8 & 0xff;\n o[46] = x11 >>> 16 & 0xff;\n o[47] = x11 >>> 24 & 0xff;\n\n o[48] = x12 >>> 0 & 0xff;\n o[49] = x12 >>> 8 & 0xff;\n o[50] = x12 >>> 16 & 0xff;\n o[51] = x12 >>> 24 & 0xff;\n\n o[52] = x13 >>> 0 & 0xff;\n o[53] = x13 >>> 8 & 0xff;\n o[54] = x13 >>> 16 & 0xff;\n o[55] = x13 >>> 24 & 0xff;\n\n o[56] = x14 >>> 0 & 0xff;\n o[57] = x14 >>> 8 & 0xff;\n o[58] = x14 >>> 16 & 0xff;\n o[59] = x14 >>> 24 & 0xff;\n\n o[60] = x15 >>> 0 & 0xff;\n o[61] = x15 >>> 8 & 0xff;\n o[62] = x15 >>> 16 & 0xff;\n o[63] = x15 >>> 24 & 0xff;\n}\n\nfunction core_hsalsa20(o,p,k,c) {\n var j0 = c[ 0] & 0xff | (c[ 1] & 0xff)<<8 | (c[ 2] & 0xff)<<16 | (c[ 3] & 0xff)<<24,\n j1 = k[ 0] & 0xff | (k[ 1] & 0xff)<<8 | (k[ 2] & 0xff)<<16 | (k[ 3] & 0xff)<<24,\n j2 = k[ 4] & 0xff | (k[ 5] & 0xff)<<8 | (k[ 6] & 0xff)<<16 | (k[ 7] & 0xff)<<24,\n j3 = k[ 8] & 0xff | (k[ 9] & 0xff)<<8 | (k[10] & 0xff)<<16 | (k[11] & 0xff)<<24,\n j4 = k[12] & 0xff | (k[13] & 0xff)<<8 | (k[14] & 0xff)<<16 | (k[15] & 0xff)<<24,\n j5 = c[ 4] & 0xff | (c[ 5] & 0xff)<<8 | (c[ 6] & 0xff)<<16 | (c[ 7] & 0xff)<<24,\n j6 = p[ 0] & 0xff | (p[ 1] & 0xff)<<8 | (p[ 2] & 0xff)<<16 | (p[ 3] & 0xff)<<24,\n j7 = p[ 4] & 0xff | (p[ 5] & 0xff)<<8 | (p[ 6] & 0xff)<<16 | (p[ 7] & 0xff)<<24,\n j8 = p[ 8] & 0xff | (p[ 9] & 0xff)<<8 | (p[10] & 0xff)<<16 | (p[11] & 0xff)<<24,\n j9 = p[12] & 0xff | (p[13] & 0xff)<<8 | (p[14] & 0xff)<<16 | (p[15] & 0xff)<<24,\n j10 = c[ 8] & 0xff | (c[ 9] & 0xff)<<8 | (c[10] & 0xff)<<16 | (c[11] & 0xff)<<24,\n j11 = k[16] & 0xff | (k[17] & 0xff)<<8 | (k[18] & 0xff)<<16 | (k[19] & 0xff)<<24,\n j12 = k[20] & 0xff | (k[21] & 0xff)<<8 | (k[22] & 0xff)<<16 | (k[23] & 0xff)<<24,\n j13 = k[24] & 0xff | (k[25] & 0xff)<<8 | (k[26] & 0xff)<<16 | (k[27] & 0xff)<<24,\n j14 = k[28] & 0xff | (k[29] & 0xff)<<8 | (k[30] & 0xff)<<16 | (k[31] & 0xff)<<24,\n j15 = c[12] & 0xff | (c[13] & 0xff)<<8 | (c[14] & 0xff)<<16 | (c[15] & 0xff)<<24;\n\n var x0 = j0, x1 = j1, x2 = j2, x3 = j3, x4 = j4, x5 = j5, x6 = j6, x7 = j7,\n x8 = j8, x9 = j9, x10 = j10, x11 = j11, x12 = j12, x13 = j13, x14 = j14,\n x15 = j15, u;\n\n for (var i = 0; i < 20; i += 2) {\n u = x0 + x12 | 0;\n x4 ^= u<<7 | u>>>(32-7);\n u = x4 + x0 | 0;\n x8 ^= u<<9 | u>>>(32-9);\n u = x8 + x4 | 0;\n x12 ^= u<<13 | u>>>(32-13);\n u = x12 + x8 | 0;\n x0 ^= u<<18 | u>>>(32-18);\n\n u = x5 + x1 | 0;\n x9 ^= u<<7 | u>>>(32-7);\n u = x9 + x5 | 0;\n x13 ^= u<<9 | u>>>(32-9);\n u = x13 + x9 | 0;\n x1 ^= u<<13 | u>>>(32-13);\n u = x1 + x13 | 0;\n x5 ^= u<<18 | u>>>(32-18);\n\n u = x10 + x6 | 0;\n x14 ^= u<<7 | u>>>(32-7);\n u = x14 + x10 | 0;\n x2 ^= u<<9 | u>>>(32-9);\n u = x2 + x14 | 0;\n x6 ^= u<<13 | u>>>(32-13);\n u = x6 + x2 | 0;\n x10 ^= u<<18 | u>>>(32-18);\n\n u = x15 + x11 | 0;\n x3 ^= u<<7 | u>>>(32-7);\n u = x3 + x15 | 0;\n x7 ^= u<<9 | u>>>(32-9);\n u = x7 + x3 | 0;\n x11 ^= u<<13 | u>>>(32-13);\n u = x11 + x7 | 0;\n x15 ^= u<<18 | u>>>(32-18);\n\n u = x0 + x3 | 0;\n x1 ^= u<<7 | u>>>(32-7);\n u = x1 + x0 | 0;\n x2 ^= u<<9 | u>>>(32-9);\n u = x2 + x1 | 0;\n x3 ^= u<<13 | u>>>(32-13);\n u = x3 + x2 | 0;\n x0 ^= u<<18 | u>>>(32-18);\n\n u = x5 + x4 | 0;\n x6 ^= u<<7 | u>>>(32-7);\n u = x6 + x5 | 0;\n x7 ^= u<<9 | u>>>(32-9);\n u = x7 + x6 | 0;\n x4 ^= u<<13 | u>>>(32-13);\n u = x4 + x7 | 0;\n x5 ^= u<<18 | u>>>(32-18);\n\n u = x10 + x9 | 0;\n x11 ^= u<<7 | u>>>(32-7);\n u = x11 + x10 | 0;\n x8 ^= u<<9 | u>>>(32-9);\n u = x8 + x11 | 0;\n x9 ^= u<<13 | u>>>(32-13);\n u = x9 + x8 | 0;\n x10 ^= u<<18 | u>>>(32-18);\n\n u = x15 + x14 | 0;\n x12 ^= u<<7 | u>>>(32-7);\n u = x12 + x15 | 0;\n x13 ^= u<<9 | u>>>(32-9);\n u = x13 + x12 | 0;\n x14 ^= u<<13 | u>>>(32-13);\n u = x14 + x13 | 0;\n x15 ^= u<<18 | u>>>(32-18);\n }\n\n o[ 0] = x0 >>> 0 & 0xff;\n o[ 1] = x0 >>> 8 & 0xff;\n o[ 2] = x0 >>> 16 & 0xff;\n o[ 3] = x0 >>> 24 & 0xff;\n\n o[ 4] = x5 >>> 0 & 0xff;\n o[ 5] = x5 >>> 8 & 0xff;\n o[ 6] = x5 >>> 16 & 0xff;\n o[ 7] = x5 >>> 24 & 0xff;\n\n o[ 8] = x10 >>> 0 & 0xff;\n o[ 9] = x10 >>> 8 & 0xff;\n o[10] = x10 >>> 16 & 0xff;\n o[11] = x10 >>> 24 & 0xff;\n\n o[12] = x15 >>> 0 & 0xff;\n o[13] = x15 >>> 8 & 0xff;\n o[14] = x15 >>> 16 & 0xff;\n o[15] = x15 >>> 24 & 0xff;\n\n o[16] = x6 >>> 0 & 0xff;\n o[17] = x6 >>> 8 & 0xff;\n o[18] = x6 >>> 16 & 0xff;\n o[19] = x6 >>> 24 & 0xff;\n\n o[20] = x7 >>> 0 & 0xff;\n o[21] = x7 >>> 8 & 0xff;\n o[22] = x7 >>> 16 & 0xff;\n o[23] = x7 >>> 24 & 0xff;\n\n o[24] = x8 >>> 0 & 0xff;\n o[25] = x8 >>> 8 & 0xff;\n o[26] = x8 >>> 16 & 0xff;\n o[27] = x8 >>> 24 & 0xff;\n\n o[28] = x9 >>> 0 & 0xff;\n o[29] = x9 >>> 8 & 0xff;\n o[30] = x9 >>> 16 & 0xff;\n o[31] = x9 >>> 24 & 0xff;\n}\n\nfunction crypto_core_salsa20(out,inp,k,c) {\n core_salsa20(out,inp,k,c);\n}\n\nfunction crypto_core_hsalsa20(out,inp,k,c) {\n core_hsalsa20(out,inp,k,c);\n}\n\nvar sigma = new Uint8Array([101, 120, 112, 97, 110, 100, 32, 51, 50, 45, 98, 121, 116, 101, 32, 107]);\n // \"expand 32-byte k\"\n\nfunction crypto_stream_salsa20_xor(c,cpos,m,mpos,b,n,k) {\n var z = new Uint8Array(16), x = new Uint8Array(64);\n var u, i;\n for (i = 0; i < 16; i++) z[i] = 0;\n for (i = 0; i < 8; i++) z[i] = n[i];\n while (b >= 64) {\n crypto_core_salsa20(x,z,k,sigma);\n for (i = 0; i < 64; i++) c[cpos+i] = m[mpos+i] ^ x[i];\n u = 1;\n for (i = 8; i < 16; i++) {\n u = u + (z[i] & 0xff) | 0;\n z[i] = u & 0xff;\n u >>>= 8;\n }\n b -= 64;\n cpos += 64;\n mpos += 64;\n }\n if (b > 0) {\n crypto_core_salsa20(x,z,k,sigma);\n for (i = 0; i < b; i++) c[cpos+i] = m[mpos+i] ^ x[i];\n }\n return 0;\n}\n\nfunction crypto_stream_salsa20(c,cpos,b,n,k) {\n var z = new Uint8Array(16), x = new Uint8Array(64);\n var u, i;\n for (i = 0; i < 16; i++) z[i] = 0;\n for (i = 0; i < 8; i++) z[i] = n[i];\n while (b >= 64) {\n crypto_core_salsa20(x,z,k,sigma);\n for (i = 0; i < 64; i++) c[cpos+i] = x[i];\n u = 1;\n for (i = 8; i < 16; i++) {\n u = u + (z[i] & 0xff) | 0;\n z[i] = u & 0xff;\n u >>>= 8;\n }\n b -= 64;\n cpos += 64;\n }\n if (b > 0) {\n crypto_core_salsa20(x,z,k,sigma);\n for (i = 0; i < b; i++) c[cpos+i] = x[i];\n }\n return 0;\n}\n\nfunction crypto_stream(c,cpos,d,n,k) {\n var s = new Uint8Array(32);\n crypto_core_hsalsa20(s,n,k,sigma);\n var sn = new Uint8Array(8);\n for (var i = 0; i < 8; i++) sn[i] = n[i+16];\n return crypto_stream_salsa20(c,cpos,d,sn,s);\n}\n\nfunction crypto_stream_xor(c,cpos,m,mpos,d,n,k) {\n var s = new Uint8Array(32);\n crypto_core_hsalsa20(s,n,k,sigma);\n var sn = new Uint8Array(8);\n for (var i = 0; i < 8; i++) sn[i] = n[i+16];\n return crypto_stream_salsa20_xor(c,cpos,m,mpos,d,sn,s);\n}\n\n/*\n* Port of Andrew Moon's Poly1305-donna-16. Public domain.\n* https://github.com/floodyberry/poly1305-donna\n*/\n\nvar poly1305 = function(key) {\n this.buffer = new Uint8Array(16);\n this.r = new Uint16Array(10);\n this.h = new Uint16Array(10);\n this.pad = new Uint16Array(8);\n this.leftover = 0;\n this.fin = 0;\n\n var t0, t1, t2, t3, t4, t5, t6, t7;\n\n t0 = key[ 0] & 0xff | (key[ 1] & 0xff) << 8; this.r[0] = ( t0 ) & 0x1fff;\n t1 = key[ 2] & 0xff | (key[ 3] & 0xff) << 8; this.r[1] = ((t0 >>> 13) | (t1 << 3)) & 0x1fff;\n t2 = key[ 4] & 0xff | (key[ 5] & 0xff) << 8; this.r[2] = ((t1 >>> 10) | (t2 << 6)) & 0x1f03;\n t3 = key[ 6] & 0xff | (key[ 7] & 0xff) << 8; this.r[3] = ((t2 >>> 7) | (t3 << 9)) & 0x1fff;\n t4 = key[ 8] & 0xff | (key[ 9] & 0xff) << 8; this.r[4] = ((t3 >>> 4) | (t4 << 12)) & 0x00ff;\n this.r[5] = ((t4 >>> 1)) & 0x1ffe;\n t5 = key[10] & 0xff | (key[11] & 0xff) << 8; this.r[6] = ((t4 >>> 14) | (t5 << 2)) & 0x1fff;\n t6 = key[12] & 0xff | (key[13] & 0xff) << 8; this.r[7] = ((t5 >>> 11) | (t6 << 5)) & 0x1f81;\n t7 = key[14] & 0xff | (key[15] & 0xff) << 8; this.r[8] = ((t6 >>> 8) | (t7 << 8)) & 0x1fff;\n this.r[9] = ((t7 >>> 5)) & 0x007f;\n\n this.pad[0] = key[16] & 0xff | (key[17] & 0xff) << 8;\n this.pad[1] = key[18] & 0xff | (key[19] & 0xff) << 8;\n this.pad[2] = key[20] & 0xff | (key[21] & 0xff) << 8;\n this.pad[3] = key[22] & 0xff | (key[23] & 0xff) << 8;\n this.pad[4] = key[24] & 0xff | (key[25] & 0xff) << 8;\n this.pad[5] = key[26] & 0xff | (key[27] & 0xff) << 8;\n this.pad[6] = key[28] & 0xff | (key[29] & 0xff) << 8;\n this.pad[7] = key[30] & 0xff | (key[31] & 0xff) << 8;\n};\n\npoly1305.prototype.blocks = function(m, mpos, bytes) {\n var hibit = this.fin ? 0 : (1 << 11);\n var t0, t1, t2, t3, t4, t5, t6, t7, c;\n var d0, d1, d2, d3, d4, d5, d6, d7, d8, d9;\n\n var h0 = this.h[0],\n h1 = this.h[1],\n h2 = this.h[2],\n h3 = this.h[3],\n h4 = this.h[4],\n h5 = this.h[5],\n h6 = this.h[6],\n h7 = this.h[7],\n h8 = this.h[8],\n h9 = this.h[9];\n\n var r0 = this.r[0],\n r1 = this.r[1],\n r2 = this.r[2],\n r3 = this.r[3],\n r4 = this.r[4],\n r5 = this.r[5],\n r6 = this.r[6],\n r7 = this.r[7],\n r8 = this.r[8],\n r9 = this.r[9];\n\n while (bytes >= 16) {\n t0 = m[mpos+ 0] & 0xff | (m[mpos+ 1] & 0xff) << 8; h0 += ( t0 ) & 0x1fff;\n t1 = m[mpos+ 2] & 0xff | (m[mpos+ 3] & 0xff) << 8; h1 += ((t0 >>> 13) | (t1 << 3)) & 0x1fff;\n t2 = m[mpos+ 4] & 0xff | (m[mpos+ 5] & 0xff) << 8; h2 += ((t1 >>> 10) | (t2 << 6)) & 0x1fff;\n t3 = m[mpos+ 6] & 0xff | (m[mpos+ 7] & 0xff) << 8; h3 += ((t2 >>> 7) | (t3 << 9)) & 0x1fff;\n t4 = m[mpos+ 8] & 0xff | (m[mpos+ 9] & 0xff) << 8; h4 += ((t3 >>> 4) | (t4 << 12)) & 0x1fff;\n h5 += ((t4 >>> 1)) & 0x1fff;\n t5 = m[mpos+10] & 0xff | (m[mpos+11] & 0xff) << 8; h6 += ((t4 >>> 14) | (t5 << 2)) & 0x1fff;\n t6 = m[mpos+12] & 0xff | (m[mpos+13] & 0xff) << 8; h7 += ((t5 >>> 11) | (t6 << 5)) & 0x1fff;\n t7 = m[mpos+14] & 0xff | (m[mpos+15] & 0xff) << 8; h8 += ((t6 >>> 8) | (t7 << 8)) & 0x1fff;\n h9 += ((t7 >>> 5)) | hibit;\n\n c = 0;\n\n d0 = c;\n d0 += h0 * r0;\n d0 += h1 * (5 * r9);\n d0 += h2 * (5 * r8);\n d0 += h3 * (5 * r7);\n d0 += h4 * (5 * r6);\n c = (d0 >>> 13); d0 &= 0x1fff;\n d0 += h5 * (5 * r5);\n d0 += h6 * (5 * r4);\n d0 += h7 * (5 * r3);\n d0 += h8 * (5 * r2);\n d0 += h9 * (5 * r1);\n c += (d0 >>> 13); d0 &= 0x1fff;\n\n d1 = c;\n d1 += h0 * r1;\n d1 += h1 * r0;\n d1 += h2 * (5 * r9);\n d1 += h3 * (5 * r8);\n d1 += h4 * (5 * r7);\n c = (d1 >>> 13); d1 &= 0x1fff;\n d1 += h5 * (5 * r6);\n d1 += h6 * (5 * r5);\n d1 += h7 * (5 * r4);\n d1 += h8 * (5 * r3);\n d1 += h9 * (5 * r2);\n c += (d1 >>> 13); d1 &= 0x1fff;\n\n d2 = c;\n d2 += h0 * r2;\n d2 += h1 * r1;\n d2 += h2 * r0;\n d2 += h3 * (5 * r9);\n d2 += h4 * (5 * r8);\n c = (d2 >>> 13); d2 &= 0x1fff;\n d2 += h5 * (5 * r7);\n d2 += h6 * (5 * r6);\n d2 += h7 * (5 * r5);\n d2 += h8 * (5 * r4);\n d2 += h9 * (5 * r3);\n c += (d2 >>> 13); d2 &= 0x1fff;\n\n d3 = c;\n d3 += h0 * r3;\n d3 += h1 * r2;\n d3 += h2 * r1;\n d3 += h3 * r0;\n d3 += h4 * (5 * r9);\n c = (d3 >>> 13); d3 &= 0x1fff;\n d3 += h5 * (5 * r8);\n d3 += h6 * (5 * r7);\n d3 += h7 * (5 * r6);\n d3 += h8 * (5 * r5);\n d3 += h9 * (5 * r4);\n c += (d3 >>> 13); d3 &= 0x1fff;\n\n d4 = c;\n d4 += h0 * r4;\n d4 += h1 * r3;\n d4 += h2 * r2;\n d4 += h3 * r1;\n d4 += h4 * r0;\n c = (d4 >>> 13); d4 &= 0x1fff;\n d4 += h5 * (5 * r9);\n d4 += h6 * (5 * r8);\n d4 += h7 * (5 * r7);\n d4 += h8 * (5 * r6);\n d4 += h9 * (5 * r5);\n c += (d4 >>> 13); d4 &= 0x1fff;\n\n d5 = c;\n d5 += h0 * r5;\n d5 += h1 * r4;\n d5 += h2 * r3;\n d5 += h3 * r2;\n d5 += h4 * r1;\n c = (d5 >>> 13); d5 &= 0x1fff;\n d5 += h5 * r0;\n d5 += h6 * (5 * r9);\n d5 += h7 * (5 * r8);\n d5 += h8 * (5 * r7);\n d5 += h9 * (5 * r6);\n c += (d5 >>> 13); d5 &= 0x1fff;\n\n d6 = c;\n d6 += h0 * r6;\n d6 += h1 * r5;\n d6 += h2 * r4;\n d6 += h3 * r3;\n d6 += h4 * r2;\n c = (d6 >>> 13); d6 &= 0x1fff;\n d6 += h5 * r1;\n d6 += h6 * r0;\n d6 += h7 * (5 * r9);\n d6 += h8 * (5 * r8);\n d6 += h9 * (5 * r7);\n c += (d6 >>> 13); d6 &= 0x1fff;\n\n d7 = c;\n d7 += h0 * r7;\n d7 += h1 * r6;\n d7 += h2 * r5;\n d7 += h3 * r4;\n d7 += h4 * r3;\n c = (d7 >>> 13); d7 &= 0x1fff;\n d7 += h5 * r2;\n d7 += h6 * r1;\n d7 += h7 * r0;\n d7 += h8 * (5 * r9);\n d7 += h9 * (5 * r8);\n c += (d7 >>> 13); d7 &= 0x1fff;\n\n d8 = c;\n d8 += h0 * r8;\n d8 += h1 * r7;\n d8 += h2 * r6;\n d8 += h3 * r5;\n d8 += h4 * r4;\n c = (d8 >>> 13); d8 &= 0x1fff;\n d8 += h5 * r3;\n d8 += h6 * r2;\n d8 += h7 * r1;\n d8 += h8 * r0;\n d8 += h9 * (5 * r9);\n c += (d8 >>> 13); d8 &= 0x1fff;\n\n d9 = c;\n d9 += h0 * r9;\n d9 += h1 * r8;\n d9 += h2 * r7;\n d9 += h3 * r6;\n d9 += h4 * r5;\n c = (d9 >>> 13); d9 &= 0x1fff;\n d9 += h5 * r4;\n d9 += h6 * r3;\n d9 += h7 * r2;\n d9 += h8 * r1;\n d9 += h9 * r0;\n c += (d9 >>> 13); d9 &= 0x1fff;\n\n c = (((c << 2) + c)) | 0;\n c = (c + d0) | 0;\n d0 = c & 0x1fff;\n c = (c >>> 13);\n d1 += c;\n\n h0 = d0;\n h1 = d1;\n h2 = d2;\n h3 = d3;\n h4 = d4;\n h5 = d5;\n h6 = d6;\n h7 = d7;\n h8 = d8;\n h9 = d9;\n\n mpos += 16;\n bytes -= 16;\n }\n this.h[0] = h0;\n this.h[1] = h1;\n this.h[2] = h2;\n this.h[3] = h3;\n this.h[4] = h4;\n this.h[5] = h5;\n this.h[6] = h6;\n this.h[7] = h7;\n this.h[8] = h8;\n this.h[9] = h9;\n};\n\npoly1305.prototype.finish = function(mac, macpos) {\n var g = new Uint16Array(10);\n var c, mask, f, i;\n\n if (this.leftover) {\n i = this.leftover;\n this.buffer[i++] = 1;\n for (; i < 16; i++) this.buffer[i] = 0;\n this.fin = 1;\n this.blocks(this.buffer, 0, 16);\n }\n\n c = this.h[1] >>> 13;\n this.h[1] &= 0x1fff;\n for (i = 2; i < 10; i++) {\n this.h[i] += c;\n c = this.h[i] >>> 13;\n this.h[i] &= 0x1fff;\n }\n this.h[0] += (c * 5);\n c = this.h[0] >>> 13;\n this.h[0] &= 0x1fff;\n this.h[1] += c;\n c = this.h[1] >>> 13;\n this.h[1] &= 0x1fff;\n this.h[2] += c;\n\n g[0] = this.h[0] + 5;\n c = g[0] >>> 13;\n g[0] &= 0x1fff;\n for (i = 1; i < 10; i++) {\n g[i] = this.h[i] + c;\n c = g[i] >>> 13;\n g[i] &= 0x1fff;\n }\n g[9] -= (1 << 13);\n\n mask = (c ^ 1) - 1;\n for (i = 0; i < 10; i++) g[i] &= mask;\n mask = ~mask;\n for (i = 0; i < 10; i++) this.h[i] = (this.h[i] & mask) | g[i];\n\n this.h[0] = ((this.h[0] ) | (this.h[1] << 13) ) & 0xffff;\n this.h[1] = ((this.h[1] >>> 3) | (this.h[2] << 10) ) & 0xffff;\n this.h[2] = ((this.h[2] >>> 6) | (this.h[3] << 7) ) & 0xffff;\n this.h[3] = ((this.h[3] >>> 9) | (this.h[4] << 4) ) & 0xffff;\n this.h[4] = ((this.h[4] >>> 12) | (this.h[5] << 1) | (this.h[6] << 14)) & 0xffff;\n this.h[5] = ((this.h[6] >>> 2) | (this.h[7] << 11) ) & 0xffff;\n this.h[6] = ((this.h[7] >>> 5) | (this.h[8] << 8) ) & 0xffff;\n this.h[7] = ((this.h[8] >>> 8) | (this.h[9] << 5) ) & 0xffff;\n\n f = this.h[0] + this.pad[0];\n this.h[0] = f & 0xffff;\n for (i = 1; i < 8; i++) {\n f = (((this.h[i] + this.pad[i]) | 0) + (f >>> 16)) | 0;\n this.h[i] = f & 0xffff;\n }\n\n mac[macpos+ 0] = (this.h[0] >>> 0) & 0xff;\n mac[macpos+ 1] = (this.h[0] >>> 8) & 0xff;\n mac[macpos+ 2] = (this.h[1] >>> 0) & 0xff;\n mac[macpos+ 3] = (this.h[1] >>> 8) & 0xff;\n mac[macpos+ 4] = (this.h[2] >>> 0) & 0xff;\n mac[macpos+ 5] = (this.h[2] >>> 8) & 0xff;\n mac[macpos+ 6] = (this.h[3] >>> 0) & 0xff;\n mac[macpos+ 7] = (this.h[3] >>> 8) & 0xff;\n mac[macpos+ 8] = (this.h[4] >>> 0) & 0xff;\n mac[macpos+ 9] = (this.h[4] >>> 8) & 0xff;\n mac[macpos+10] = (this.h[5] >>> 0) & 0xff;\n mac[macpos+11] = (this.h[5] >>> 8) & 0xff;\n mac[macpos+12] = (this.h[6] >>> 0) & 0xff;\n mac[macpos+13] = (this.h[6] >>> 8) & 0xff;\n mac[macpos+14] = (this.h[7] >>> 0) & 0xff;\n mac[macpos+15] = (this.h[7] >>> 8) & 0xff;\n};\n\npoly1305.prototype.update = function(m, mpos, bytes) {\n var i, want;\n\n if (this.leftover) {\n want = (16 - this.leftover);\n if (want > bytes)\n want = bytes;\n for (i = 0; i < want; i++)\n this.buffer[this.leftover + i] = m[mpos+i];\n bytes -= want;\n mpos += want;\n this.leftover += want;\n if (this.leftover < 16)\n return;\n this.blocks(this.buffer, 0, 16);\n this.leftover = 0;\n }\n\n if (bytes >= 16) {\n want = bytes - (bytes % 16);\n this.blocks(m, mpos, want);\n mpos += want;\n bytes -= want;\n }\n\n if (bytes) {\n for (i = 0; i < bytes; i++)\n this.buffer[this.leftover + i] = m[mpos+i];\n this.leftover += bytes;\n }\n};\n\nfunction crypto_onetimeauth(out, outpos, m, mpos, n, k) {\n var s = new poly1305(k);\n s.update(m, mpos, n);\n s.finish(out, outpos);\n return 0;\n}\n\nfunction crypto_onetimeauth_verify(h, hpos, m, mpos, n, k) {\n var x = new Uint8Array(16);\n crypto_onetimeauth(x,0,m,mpos,n,k);\n return crypto_verify_16(h,hpos,x,0);\n}\n\nfunction crypto_secretbox(c,m,d,n,k) {\n var i;\n if (d < 32) return -1;\n crypto_stream_xor(c,0,m,0,d,n,k);\n crypto_onetimeauth(c, 16, c, 32, d - 32, c);\n for (i = 0; i < 16; i++) c[i] = 0;\n return 0;\n}\n\nfunction crypto_secretbox_open(m,c,d,n,k) {\n var i;\n var x = new Uint8Array(32);\n if (d < 32) return -1;\n crypto_stream(x,0,32,n,k);\n if (crypto_onetimeauth_verify(c, 16,c, 32,d - 32,x) !== 0) return -1;\n crypto_stream_xor(m,0,c,0,d,n,k);\n for (i = 0; i < 32; i++) m[i] = 0;\n return 0;\n}\n\nfunction set25519(r, a) {\n var i;\n for (i = 0; i < 16; i++) r[i] = a[i]|0;\n}\n\nfunction car25519(o) {\n var i, v, c = 1;\n for (i = 0; i < 16; i++) {\n v = o[i] + c + 65535;\n c = Math.floor(v / 65536);\n o[i] = v - c * 65536;\n }\n o[0] += c-1 + 37 * (c-1);\n}\n\nfunction sel25519(p, q, b) {\n var t, c = ~(b-1);\n for (var i = 0; i < 16; i++) {\n t = c & (p[i] ^ q[i]);\n p[i] ^= t;\n q[i] ^= t;\n }\n}\n\nfunction pack25519(o, n) {\n var i, j, b;\n var m = gf(), t = gf();\n for (i = 0; i < 16; i++) t[i] = n[i];\n car25519(t);\n car25519(t);\n car25519(t);\n for (j = 0; j < 2; j++) {\n m[0] = t[0] - 0xffed;\n for (i = 1; i < 15; i++) {\n m[i] = t[i] - 0xffff - ((m[i-1]>>16) & 1);\n m[i-1] &= 0xffff;\n }\n m[15] = t[15] - 0x7fff - ((m[14]>>16) & 1);\n b = (m[15]>>16) & 1;\n m[14] &= 0xffff;\n sel25519(t, m, 1-b);\n }\n for (i = 0; i < 16; i++) {\n o[2*i] = t[i] & 0xff;\n o[2*i+1] = t[i]>>8;\n }\n}\n\nfunction neq25519(a, b) {\n var c = new Uint8Array(32), d = new Uint8Array(32);\n pack25519(c, a);\n pack25519(d, b);\n return crypto_verify_32(c, 0, d, 0);\n}\n\nfunction par25519(a) {\n var d = new Uint8Array(32);\n pack25519(d, a);\n return d[0] & 1;\n}\n\nfunction unpack25519(o, n) {\n var i;\n for (i = 0; i < 16; i++) o[i] = n[2*i] + (n[2*i+1] << 8);\n o[15] &= 0x7fff;\n}\n\nfunction A(o, a, b) {\n for (var i = 0; i < 16; i++) o[i] = a[i] + b[i];\n}\n\nfunction Z(o, a, b) {\n for (var i = 0; i < 16; i++) o[i] = a[i] - b[i];\n}\n\nfunction M(o, a, b) {\n var v, c,\n t0 = 0, t1 = 0, t2 = 0, t3 = 0, t4 = 0, t5 = 0, t6 = 0, t7 = 0,\n t8 = 0, t9 = 0, t10 = 0, t11 = 0, t12 = 0, t13 = 0, t14 = 0, t15 = 0,\n t16 = 0, t17 = 0, t18 = 0, t19 = 0, t20 = 0, t21 = 0, t22 = 0, t23 = 0,\n t24 = 0, t25 = 0, t26 = 0, t27 = 0, t28 = 0, t29 = 0, t30 = 0,\n b0 = b[0],\n b1 = b[1],\n b2 = b[2],\n b3 = b[3],\n b4 = b[4],\n b5 = b[5],\n b6 = b[6],\n b7 = b[7],\n b8 = b[8],\n b9 = b[9],\n b10 = b[10],\n b11 = b[11],\n b12 = b[12],\n b13 = b[13],\n b14 = b[14],\n b15 = b[15];\n\n v = a[0];\n t0 += v * b0;\n t1 += v * b1;\n t2 += v * b2;\n t3 += v * b3;\n t4 += v * b4;\n t5 += v * b5;\n t6 += v * b6;\n t7 += v * b7;\n t8 += v * b8;\n t9 += v * b9;\n t10 += v * b10;\n t11 += v * b11;\n t12 += v * b12;\n t13 += v * b13;\n t14 += v * b14;\n t15 += v * b15;\n v = a[1];\n t1 += v * b0;\n t2 += v * b1;\n t3 += v * b2;\n t4 += v * b3;\n t5 += v * b4;\n t6 += v * b5;\n t7 += v * b6;\n t8 += v * b7;\n t9 += v * b8;\n t10 += v * b9;\n t11 += v * b10;\n t12 += v * b11;\n t13 += v * b12;\n t14 += v * b13;\n t15 += v * b14;\n t16 += v * b15;\n v = a[2];\n t2 += v * b0;\n t3 += v * b1;\n t4 += v * b2;\n t5 += v * b3;\n t6 += v * b4;\n t7 += v * b5;\n t8 += v * b6;\n t9 += v * b7;\n t10 += v * b8;\n t11 += v * b9;\n t12 += v * b10;\n t13 += v * b11;\n t14 += v * b12;\n t15 += v * b13;\n t16 += v * b14;\n t17 += v * b15;\n v = a[3];\n t3 += v * b0;\n t4 += v * b1;\n t5 += v * b2;\n t6 += v * b3;\n t7 += v * b4;\n t8 += v * b5;\n t9 += v * b6;\n t10 += v * b7;\n t11 += v * b8;\n t12 += v * b9;\n t13 += v * b10;\n t14 += v * b11;\n t15 += v * b12;\n t16 += v * b13;\n t17 += v * b14;\n t18 += v * b15;\n v = a[4];\n t4 += v * b0;\n t5 += v * b1;\n t6 += v * b2;\n t7 += v * b3;\n t8 += v * b4;\n t9 += v * b5;\n t10 += v * b6;\n t11 += v * b7;\n t12 += v * b8;\n t13 += v * b9;\n t14 += v * b10;\n t15 += v * b11;\n t16 += v * b12;\n t17 += v * b13;\n t18 += v * b14;\n t19 += v * b15;\n v = a[5];\n t5 += v * b0;\n t6 += v * b1;\n t7 += v * b2;\n t8 += v * b3;\n t9 += v * b4;\n t10 += v * b5;\n t11 += v * b6;\n t12 += v * b7;\n t13 += v * b8;\n t14 += v * b9;\n t15 += v * b10;\n t16 += v * b11;\n t17 += v * b12;\n t18 += v * b13;\n t19 += v * b14;\n t20 += v * b15;\n v = a[6];\n t6 += v * b0;\n t7 += v * b1;\n t8 += v * b2;\n t9 += v * b3;\n t10 += v * b4;\n t11 += v * b5;\n t12 += v * b6;\n t13 += v * b7;\n t14 += v * b8;\n t15 += v * b9;\n t16 += v * b10;\n t17 += v * b11;\n t18 += v * b12;\n t19 += v * b13;\n t20 += v * b14;\n t21 += v * b15;\n v = a[7];\n t7 += v * b0;\n t8 += v * b1;\n t9 += v * b2;\n t10 += v * b3;\n t11 += v * b4;\n t12 += v * b5;\n t13 += v * b6;\n t14 += v * b7;\n t15 += v * b8;\n t16 += v * b9;\n t17 += v * b10;\n t18 += v * b11;\n t19 += v * b12;\n t20 += v * b13;\n t21 += v * b14;\n t22 += v * b15;\n v = a[8];\n t8 += v * b0;\n t9 += v * b1;\n t10 += v * b2;\n t11 += v * b3;\n t12 += v * b4;\n t13 += v * b5;\n t14 += v * b6;\n t15 += v * b7;\n t16 += v * b8;\n t17 += v * b9;\n t18 += v * b10;\n t19 += v * b11;\n t20 += v * b12;\n t21 += v * b13;\n t22 += v * b14;\n t23 += v * b15;\n v = a[9];\n t9 += v * b0;\n t10 += v * b1;\n t11 += v * b2;\n t12 += v * b3;\n t13 += v * b4;\n t14 += v * b5;\n t15 += v * b6;\n t16 += v * b7;\n t17 += v * b8;\n t18 += v * b9;\n t19 += v * b10;\n t20 += v * b11;\n t21 += v * b12;\n t22 += v * b13;\n t23 += v * b14;\n t24 += v * b15;\n v = a[10];\n t10 += v * b0;\n t11 += v * b1;\n t12 += v * b2;\n t13 += v * b3;\n t14 += v * b4;\n t15 += v * b5;\n t16 += v * b6;\n t17 += v * b7;\n t18 += v * b8;\n t19 += v * b9;\n t20 += v * b10;\n t21 += v * b11;\n t22 += v * b12;\n t23 += v * b13;\n t24 += v * b14;\n t25 += v * b15;\n v = a[11];\n t11 += v * b0;\n t12 += v * b1;\n t13 += v * b2;\n t14 += v * b3;\n t15 += v * b4;\n t16 += v * b5;\n t17 += v * b6;\n t18 += v * b7;\n t19 += v * b8;\n t20 += v * b9;\n t21 += v * b10;\n t22 += v * b11;\n t23 += v * b12;\n t24 += v * b13;\n t25 += v * b14;\n t26 += v * b15;\n v = a[12];\n t12 += v * b0;\n t13 += v * b1;\n t14 += v * b2;\n t15 += v * b3;\n t16 += v * b4;\n t17 += v * b5;\n t18 += v * b6;\n t19 += v * b7;\n t20 += v * b8;\n t21 += v * b9;\n t22 += v * b10;\n t23 += v * b11;\n t24 += v * b12;\n t25 += v * b13;\n t26 += v * b14;\n t27 += v * b15;\n v = a[13];\n t13 += v * b0;\n t14 += v * b1;\n t15 += v * b2;\n t16 += v * b3;\n t17 += v * b4;\n t18 += v * b5;\n t19 += v * b6;\n t20 += v * b7;\n t21 += v * b8;\n t22 += v * b9;\n t23 += v * b10;\n t24 += v * b11;\n t25 += v * b12;\n t26 += v * b13;\n t27 += v * b14;\n t28 += v * b15;\n v = a[14];\n t14 += v * b0;\n t15 += v * b1;\n t16 += v * b2;\n t17 += v * b3;\n t18 += v * b4;\n t19 += v * b5;\n t20 += v * b6;\n t21 += v * b7;\n t22 += v * b8;\n t23 += v * b9;\n t24 += v * b10;\n t25 += v * b11;\n t26 += v * b12;\n t27 += v * b13;\n t28 += v * b14;\n t29 += v * b15;\n v = a[15];\n t15 += v * b0;\n t16 += v * b1;\n t17 += v * b2;\n t18 += v * b3;\n t19 += v * b4;\n t20 += v * b5;\n t21 += v * b6;\n t22 += v * b7;\n t23 += v * b8;\n t24 += v * b9;\n t25 += v * b10;\n t26 += v * b11;\n t27 += v * b12;\n t28 += v * b13;\n t29 += v * b14;\n t30 += v * b15;\n\n t0 += 38 * t16;\n t1 += 38 * t17;\n t2 += 38 * t18;\n t3 += 38 * t19;\n t4 += 38 * t20;\n t5 += 38 * t21;\n t6 += 38 * t22;\n t7 += 38 * t23;\n t8 += 38 * t24;\n t9 += 38 * t25;\n t10 += 38 * t26;\n t11 += 38 * t27;\n t12 += 38 * t28;\n t13 += 38 * t29;\n t14 += 38 * t30;\n // t15 left as is\n\n // first car\n c = 1;\n v = t0 + c + 65535; c = Math.floor(v / 65536); t0 = v - c * 65536;\n v = t1 + c + 65535; c = Math.floor(v / 65536); t1 = v - c * 65536;\n v = t2 + c + 65535; c = Math.floor(v / 65536); t2 = v - c * 65536;\n v = t3 + c + 65535; c = Math.floor(v / 65536); t3 = v - c * 65536;\n v = t4 + c + 65535; c = Math.floor(v / 65536); t4 = v - c * 65536;\n v = t5 + c + 65535; c = Math.floor(v / 65536); t5 = v - c * 65536;\n v = t6 + c + 65535; c = Math.floor(v / 65536); t6 = v - c * 65536;\n v = t7 + c + 65535; c = Math.floor(v / 65536); t7 = v - c * 65536;\n v = t8 + c + 65535; c = Math.floor(v / 65536); t8 = v - c * 65536;\n v = t9 + c + 65535; c = Math.floor(v / 65536); t9 = v - c * 65536;\n v = t10 + c + 65535; c = Math.floor(v / 65536); t10 = v - c * 65536;\n v = t11 + c + 65535; c = Math.floor(v / 65536); t11 = v - c * 65536;\n v = t12 + c + 65535; c = Math.floor(v / 65536); t12 = v - c * 65536;\n v = t13 + c + 65535; c = Math.floor(v / 65536); t13 = v - c * 65536;\n v = t14 + c + 65535; c = Math.floor(v / 65536); t14 = v - c * 65536;\n v = t15 + c + 65535; c = Math.floor(v / 65536); t15 = v - c * 65536;\n t0 += c-1 + 37 * (c-1);\n\n // second car\n c = 1;\n v = t0 + c + 65535; c = Math.floor(v / 65536); t0 = v - c * 65536;\n v = t1 + c + 65535; c = Math.floor(v / 65536); t1 = v - c * 65536;\n v = t2 + c + 65535; c = Math.floor(v / 65536); t2 = v - c * 65536;\n v = t3 + c + 65535; c = Math.floor(v / 65536); t3 = v - c * 65536;\n v = t4 + c + 65535; c = Math.floor(v / 65536); t4 = v - c * 65536;\n v = t5 + c + 65535; c = Math.floor(v / 65536); t5 = v - c * 65536;\n v = t6 + c + 65535; c = Math.floor(v / 65536); t6 = v - c * 65536;\n v = t7 + c + 65535; c = Math.floor(v / 65536); t7 = v - c * 65536;\n v = t8 + c + 65535; c = Math.floor(v / 65536); t8 = v - c * 65536;\n v = t9 + c + 65535; c = Math.floor(v / 65536); t9 = v - c * 65536;\n v = t10 + c + 65535; c = Math.floor(v / 65536); t10 = v - c * 65536;\n v = t11 + c + 65535; c = Math.floor(v / 65536); t11 = v - c * 65536;\n v = t12 + c + 65535; c = Math.floor(v / 65536); t12 = v - c * 65536;\n v = t13 + c + 65535; c = Math.floor(v / 65536); t13 = v - c * 65536;\n v = t14 + c + 65535; c = Math.floor(v / 65536); t14 = v - c * 65536;\n v = t15 + c + 65535; c = Math.floor(v / 65536); t15 = v - c * 65536;\n t0 += c-1 + 37 * (c-1);\n\n o[ 0] = t0;\n o[ 1] = t1;\n o[ 2] = t2;\n o[ 3] = t3;\n o[ 4] = t4;\n o[ 5] = t5;\n o[ 6] = t6;\n o[ 7] = t7;\n o[ 8] = t8;\n o[ 9] = t9;\n o[10] = t10;\n o[11] = t11;\n o[12] = t12;\n o[13] = t13;\n o[14] = t14;\n o[15] = t15;\n}\n\nfunction S(o, a) {\n M(o, a, a);\n}\n\nfunction inv25519(o, i) {\n var c = gf();\n var a;\n for (a = 0; a < 16; a++) c[a] = i[a];\n for (a = 253; a >= 0; a--) {\n S(c, c);\n if(a !== 2 && a !== 4) M(c, c, i);\n }\n for (a = 0; a < 16; a++) o[a] = c[a];\n}\n\nfunction pow2523(o, i) {\n var c = gf();\n var a;\n for (a = 0; a < 16; a++) c[a] = i[a];\n for (a = 250; a >= 0; a--) {\n S(c, c);\n if(a !== 1) M(c, c, i);\n }\n for (a = 0; a < 16; a++) o[a] = c[a];\n}\n\nfunction crypto_scalarmult(q, n, p) {\n var z = new Uint8Array(32);\n var x = new Float64Array(80), r, i;\n var a = gf(), b = gf(), c = gf(),\n d = gf(), e = gf(), f = gf();\n for (i = 0; i < 31; i++) z[i] = n[i];\n z[31]=(n[31]&127)|64;\n z[0]&=248;\n unpack25519(x,p);\n for (i = 0; i < 16; i++) {\n b[i]=x[i];\n d[i]=a[i]=c[i]=0;\n }\n a[0]=d[0]=1;\n for (i=254; i>=0; --i) {\n r=(z[i>>>3]>>>(i&7))&1;\n sel25519(a,b,r);\n sel25519(c,d,r);\n A(e,a,c);\n Z(a,a,c);\n A(c,b,d);\n Z(b,b,d);\n S(d,e);\n S(f,a);\n M(a,c,a);\n M(c,b,e);\n A(e,a,c);\n Z(a,a,c);\n S(b,a);\n Z(c,d,f);\n M(a,c,_121665);\n A(a,a,d);\n M(c,c,a);\n M(a,d,f);\n M(d,b,x);\n S(b,e);\n sel25519(a,b,r);\n sel25519(c,d,r);\n }\n for (i = 0; i < 16; i++) {\n x[i+16]=a[i];\n x[i+32]=c[i];\n x[i+48]=b[i];\n x[i+64]=d[i];\n }\n var x32 = x.subarray(32);\n var x16 = x.subarray(16);\n inv25519(x32,x32);\n M(x16,x16,x32);\n pack25519(q,x16);\n return 0;\n}\n\nfunction crypto_scalarmult_base(q, n) {\n return crypto_scalarmult(q, n, _9);\n}\n\nfunction crypto_box_keypair(y, x) {\n randombytes(x, 32);\n return crypto_scalarmult_base(y, x);\n}\n\nfunction crypto_box_beforenm(k, y, x) {\n var s = new Uint8Array(32);\n crypto_scalarmult(s, x, y);\n return crypto_core_hsalsa20(k, _0, s, sigma);\n}\n\nvar crypto_box_afternm = crypto_secretbox;\nvar crypto_box_open_afternm = crypto_secretbox_open;\n\nfunction crypto_box(c, m, d, n, y, x) {\n var k = new Uint8Array(32);\n crypto_box_beforenm(k, y, x);\n return crypto_box_afternm(c, m, d, n, k);\n}\n\nfunction crypto_box_open(m, c, d, n, y, x) {\n var k = new Uint8Array(32);\n crypto_box_beforenm(k, y, x);\n return crypto_box_open_afternm(m, c, d, n, k);\n}\n\nvar K = [\n 0x428a2f98, 0xd728ae22, 0x71374491, 0x23ef65cd,\n 0xb5c0fbcf, 0xec4d3b2f, 0xe9b5dba5, 0x8189dbbc,\n 0x3956c25b, 0xf348b538, 0x59f111f1, 0xb605d019,\n 0x923f82a4, 0xaf194f9b, 0xab1c5ed5, 0xda6d8118,\n 0xd807aa98, 0xa3030242, 0x12835b01, 0x45706fbe,\n 0x243185be, 0x4ee4b28c, 0x550c7dc3, 0xd5ffb4e2,\n 0x72be5d74, 0xf27b896f, 0x80deb1fe, 0x3b1696b1,\n 0x9bdc06a7, 0x25c71235, 0xc19bf174, 0xcf692694,\n 0xe49b69c1, 0x9ef14ad2, 0xefbe4786, 0x384f25e3,\n 0x0fc19dc6, 0x8b8cd5b5, 0x240ca1cc, 0x77ac9c65,\n 0x2de92c6f, 0x592b0275, 0x4a7484aa, 0x6ea6e483,\n 0x5cb0a9dc, 0xbd41fbd4, 0x76f988da, 0x831153b5,\n 0x983e5152, 0xee66dfab, 0xa831c66d, 0x2db43210,\n 0xb00327c8, 0x98fb213f, 0xbf597fc7, 0xbeef0ee4,\n 0xc6e00bf3, 0x3da88fc2, 0xd5a79147, 0x930aa725,\n 0x06ca6351, 0xe003826f, 0x14292967, 0x0a0e6e70,\n 0x27b70a85, 0x46d22ffc, 0x2e1b2138, 0x5c26c926,\n 0x4d2c6dfc, 0x5ac42aed, 0x53380d13, 0x9d95b3df,\n 0x650a7354, 0x8baf63de, 0x766a0abb, 0x3c77b2a8,\n 0x81c2c92e, 0x47edaee6, 0x92722c85, 0x1482353b,\n 0xa2bfe8a1, 0x4cf10364, 0xa81a664b, 0xbc423001,\n 0xc24b8b70, 0xd0f89791, 0xc76c51a3, 0x0654be30,\n 0xd192e819, 0xd6ef5218, 0xd6990624, 0x5565a910,\n 0xf40e3585, 0x5771202a, 0x106aa070, 0x32bbd1b8,\n 0x19a4c116, 0xb8d2d0c8, 0x1e376c08, 0x5141ab53,\n 0x2748774c, 0xdf8eeb99, 0x34b0bcb5, 0xe19b48a8,\n 0x391c0cb3, 0xc5c95a63, 0x4ed8aa4a, 0xe3418acb,\n 0x5b9cca4f, 0x7763e373, 0x682e6ff3, 0xd6b2b8a3,\n 0x748f82ee, 0x5defb2fc, 0x78a5636f, 0x43172f60,\n 0x84c87814, 0xa1f0ab72, 0x8cc70208, 0x1a6439ec,\n 0x90befffa, 0x23631e28, 0xa4506ceb, 0xde82bde9,\n 0xbef9a3f7, 0xb2c67915, 0xc67178f2, 0xe372532b,\n 0xca273ece, 0xea26619c, 0xd186b8c7, 0x21c0c207,\n 0xeada7dd6, 0xcde0eb1e, 0xf57d4f7f, 0xee6ed178,\n 0x06f067aa, 0x72176fba, 0x0a637dc5, 0xa2c898a6,\n 0x113f9804, 0xbef90dae, 0x1b710b35, 0x131c471b,\n 0x28db77f5, 0x23047d84, 0x32caab7b, 0x40c72493,\n 0x3c9ebe0a, 0x15c9bebc, 0x431d67c4, 0x9c100d4c,\n 0x4cc5d4be, 0xcb3e42b6, 0x597f299c, 0xfc657e2a,\n 0x5fcb6fab, 0x3ad6faec, 0x6c44198c, 0x4a475817\n];\n\nfunction crypto_hashblocks_hl(hh, hl, m, n) {\n var wh = new Int32Array(16), wl = new Int32Array(16),\n bh0, bh1, bh2, bh3, bh4, bh5, bh6, bh7,\n bl0, bl1, bl2, bl3, bl4, bl5, bl6, bl7,\n th, tl, i, j, h, l, a, b, c, d;\n\n var ah0 = hh[0],\n ah1 = hh[1],\n ah2 = hh[2],\n ah3 = hh[3],\n ah4 = hh[4],\n ah5 = hh[5],\n ah6 = hh[6],\n ah7 = hh[7],\n\n al0 = hl[0],\n al1 = hl[1],\n al2 = hl[2],\n al3 = hl[3],\n al4 = hl[4],\n al5 = hl[5],\n al6 = hl[6],\n al7 = hl[7];\n\n var pos = 0;\n while (n >= 128) {\n for (i = 0; i < 16; i++) {\n j = 8 * i + pos;\n wh[i] = (m[j+0] << 24) | (m[j+1] << 16) | (m[j+2] << 8) | m[j+3];\n wl[i] = (m[j+4] << 24) | (m[j+5] << 16) | (m[j+6] << 8) | m[j+7];\n }\n for (i = 0; i < 80; i++) {\n bh0 = ah0;\n bh1 = ah1;\n bh2 = ah2;\n bh3 = ah3;\n bh4 = ah4;\n bh5 = ah5;\n bh6 = ah6;\n bh7 = ah7;\n\n bl0 = al0;\n bl1 = al1;\n bl2 = al2;\n bl3 = al3;\n bl4 = al4;\n bl5 = al5;\n bl6 = al6;\n bl7 = al7;\n\n // add\n h = ah7;\n l = al7;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n // Sigma1\n h = ((ah4 >>> 14) | (al4 << (32-14))) ^ ((ah4 >>> 18) | (al4 << (32-18))) ^ ((al4 >>> (41-32)) | (ah4 << (32-(41-32))));\n l = ((al4 >>> 14) | (ah4 << (32-14))) ^ ((al4 >>> 18) | (ah4 << (32-18))) ^ ((ah4 >>> (41-32)) | (al4 << (32-(41-32))));\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // Ch\n h = (ah4 & ah5) ^ (~ah4 & ah6);\n l = (al4 & al5) ^ (~al4 & al6);\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // K\n h = K[i*2];\n l = K[i*2+1];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // w\n h = wh[i%16];\n l = wl[i%16];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n th = c & 0xffff | d << 16;\n tl = a & 0xffff | b << 16;\n\n // add\n h = th;\n l = tl;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n // Sigma0\n h = ((ah0 >>> 28) | (al0 << (32-28))) ^ ((al0 >>> (34-32)) | (ah0 << (32-(34-32)))) ^ ((al0 >>> (39-32)) | (ah0 << (32-(39-32))));\n l = ((al0 >>> 28) | (ah0 << (32-28))) ^ ((ah0 >>> (34-32)) | (al0 << (32-(34-32)))) ^ ((ah0 >>> (39-32)) | (al0 << (32-(39-32))));\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // Maj\n h = (ah0 & ah1) ^ (ah0 & ah2) ^ (ah1 & ah2);\n l = (al0 & al1) ^ (al0 & al2) ^ (al1 & al2);\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n bh7 = (c & 0xffff) | (d << 16);\n bl7 = (a & 0xffff) | (b << 16);\n\n // add\n h = bh3;\n l = bl3;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = th;\n l = tl;\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n bh3 = (c & 0xffff) | (d << 16);\n bl3 = (a & 0xffff) | (b << 16);\n\n ah1 = bh0;\n ah2 = bh1;\n ah3 = bh2;\n ah4 = bh3;\n ah5 = bh4;\n ah6 = bh5;\n ah7 = bh6;\n ah0 = bh7;\n\n al1 = bl0;\n al2 = bl1;\n al3 = bl2;\n al4 = bl3;\n al5 = bl4;\n al6 = bl5;\n al7 = bl6;\n al0 = bl7;\n\n if (i%16 === 15) {\n for (j = 0; j < 16; j++) {\n // add\n h = wh[j];\n l = wl[j];\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = wh[(j+9)%16];\n l = wl[(j+9)%16];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // sigma0\n th = wh[(j+1)%16];\n tl = wl[(j+1)%16];\n h = ((th >>> 1) | (tl << (32-1))) ^ ((th >>> 8) | (tl << (32-8))) ^ (th >>> 7);\n l = ((tl >>> 1) | (th << (32-1))) ^ ((tl >>> 8) | (th << (32-8))) ^ ((tl >>> 7) | (th << (32-7)));\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // sigma1\n th = wh[(j+14)%16];\n tl = wl[(j+14)%16];\n h = ((th >>> 19) | (tl << (32-19))) ^ ((tl >>> (61-32)) | (th << (32-(61-32)))) ^ (th >>> 6);\n l = ((tl >>> 19) | (th << (32-19))) ^ ((th >>> (61-32)) | (tl << (32-(61-32)))) ^ ((tl >>> 6) | (th << (32-6)));\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n wh[j] = (c & 0xffff) | (d << 16);\n wl[j] = (a & 0xffff) | (b << 16);\n }\n }\n }\n\n // add\n h = ah0;\n l = al0;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[0];\n l = hl[0];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[0] = ah0 = (c & 0xffff) | (d << 16);\n hl[0] = al0 = (a & 0xffff) | (b << 16);\n\n h = ah1;\n l = al1;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[1];\n l = hl[1];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[1] = ah1 = (c & 0xffff) | (d << 16);\n hl[1] = al1 = (a & 0xffff) | (b << 16);\n\n h = ah2;\n l = al2;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[2];\n l = hl[2];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[2] = ah2 = (c & 0xffff) | (d << 16);\n hl[2] = al2 = (a & 0xffff) | (b << 16);\n\n h = ah3;\n l = al3;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[3];\n l = hl[3];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[3] = ah3 = (c & 0xffff) | (d << 16);\n hl[3] = al3 = (a & 0xffff) | (b << 16);\n\n h = ah4;\n l = al4;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[4];\n l = hl[4];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[4] = ah4 = (c & 0xffff) | (d << 16);\n hl[4] = al4 = (a & 0xffff) | (b << 16);\n\n h = ah5;\n l = al5;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[5];\n l = hl[5];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[5] = ah5 = (c & 0xffff) | (d << 16);\n hl[5] = al5 = (a & 0xffff) | (b << 16);\n\n h = ah6;\n l = al6;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[6];\n l = hl[6];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[6] = ah6 = (c & 0xffff) | (d << 16);\n hl[6] = al6 = (a & 0xffff) | (b << 16);\n\n h = ah7;\n l = al7;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[7];\n l = hl[7];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[7] = ah7 = (c & 0xffff) | (d << 16);\n hl[7] = al7 = (a & 0xffff) | (b << 16);\n\n pos += 128;\n n -= 128;\n }\n\n return n;\n}\n\nfunction crypto_hash(out, m, n) {\n var hh = new Int32Array(8),\n hl = new Int32Array(8),\n x = new Uint8Array(256),\n i, b = n;\n\n hh[0] = 0x6a09e667;\n hh[1] = 0xbb67ae85;\n hh[2] = 0x3c6ef372;\n hh[3] = 0xa54ff53a;\n hh[4] = 0x510e527f;\n hh[5] = 0x9b05688c;\n hh[6] = 0x1f83d9ab;\n hh[7] = 0x5be0cd19;\n\n hl[0] = 0xf3bcc908;\n hl[1] = 0x84caa73b;\n hl[2] = 0xfe94f82b;\n hl[3] = 0x5f1d36f1;\n hl[4] = 0xade682d1;\n hl[5] = 0x2b3e6c1f;\n hl[6] = 0xfb41bd6b;\n hl[7] = 0x137e2179;\n\n crypto_hashblocks_hl(hh, hl, m, n);\n n %= 128;\n\n for (i = 0; i < n; i++) x[i] = m[b-n+i];\n x[n] = 128;\n\n n = 256-128*(n<112?1:0);\n x[n-9] = 0;\n ts64(x, n-8, (b / 0x20000000) | 0, b << 3);\n crypto_hashblocks_hl(hh, hl, x, n);\n\n for (i = 0; i < 8; i++) ts64(out, 8*i, hh[i], hl[i]);\n\n return 0;\n}\n\nfunction add(p, q) {\n var a = gf(), b = gf(), c = gf(),\n d = gf(), e = gf(), f = gf(),\n g = gf(), h = gf(), t = gf();\n\n Z(a, p[1], p[0]);\n Z(t, q[1], q[0]);\n M(a, a, t);\n A(b, p[0], p[1]);\n A(t, q[0], q[1]);\n M(b, b, t);\n M(c, p[3], q[3]);\n M(c, c, D2);\n M(d, p[2], q[2]);\n A(d, d, d);\n Z(e, b, a);\n Z(f, d, c);\n A(g, d, c);\n A(h, b, a);\n\n M(p[0], e, f);\n M(p[1], h, g);\n M(p[2], g, f);\n M(p[3], e, h);\n}\n\nfunction cswap(p, q, b) {\n var i;\n for (i = 0; i < 4; i++) {\n sel25519(p[i], q[i], b);\n }\n}\n\nfunction pack(r, p) {\n var tx = gf(), ty = gf(), zi = gf();\n inv25519(zi, p[2]);\n M(tx, p[0], zi);\n M(ty, p[1], zi);\n pack25519(r, ty);\n r[31] ^= par25519(tx) << 7;\n}\n\nfunction scalarmult(p, q, s) {\n var b, i;\n set25519(p[0], gf0);\n set25519(p[1], gf1);\n set25519(p[2], gf1);\n set25519(p[3], gf0);\n for (i = 255; i >= 0; --i) {\n b = (s[(i/8)|0] >> (i&7)) & 1;\n cswap(p, q, b);\n add(q, p);\n add(p, p);\n cswap(p, q, b);\n }\n}\n\nfunction scalarbase(p, s) {\n var q = [gf(), gf(), gf(), gf()];\n set25519(q[0], X);\n set25519(q[1], Y);\n set25519(q[2], gf1);\n M(q[3], X, Y);\n scalarmult(p, q, s);\n}\n\nfunction crypto_sign_keypair(pk, sk, seeded) {\n var d = new Uint8Array(64);\n var p = [gf(), gf(), gf(), gf()];\n var i;\n\n if (!seeded) randombytes(sk, 32);\n crypto_hash(d, sk, 32);\n d[0] &= 248;\n d[31] &= 127;\n d[31] |= 64;\n\n scalarbase(p, d);\n pack(pk, p);\n\n for (i = 0; i < 32; i++) sk[i+32] = pk[i];\n return 0;\n}\n\nvar L = new Float64Array([0xed, 0xd3, 0xf5, 0x5c, 0x1a, 0x63, 0x12, 0x58, 0xd6, 0x9c, 0xf7, 0xa2, 0xde, 0xf9, 0xde, 0x14, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x10]);\n\nfunction modL(r, x) {\n var carry, i, j, k;\n for (i = 63; i >= 32; --i) {\n carry = 0;\n for (j = i - 32, k = i - 12; j < k; ++j) {\n x[j] += carry - 16 * x[i] * L[j - (i - 32)];\n carry = Math.floor((x[j] + 128) / 256);\n x[j] -= carry * 256;\n }\n x[j] += carry;\n x[i] = 0;\n }\n carry = 0;\n for (j = 0; j < 32; j++) {\n x[j] += carry - (x[31] >> 4) * L[j];\n carry = x[j] >> 8;\n x[j] &= 255;\n }\n for (j = 0; j < 32; j++) x[j] -= carry * L[j];\n for (i = 0; i < 32; i++) {\n x[i+1] += x[i] >> 8;\n r[i] = x[i] & 255;\n }\n}\n\nfunction reduce(r) {\n var x = new Float64Array(64), i;\n for (i = 0; i < 64; i++) x[i] = r[i];\n for (i = 0; i < 64; i++) r[i] = 0;\n modL(r, x);\n}\n\n// Note: difference from C - smlen returned, not passed as argument.\nfunction crypto_sign(sm, m, n, sk) {\n var d = new Uint8Array(64), h = new Uint8Array(64), r = new Uint8Array(64);\n var i, j, x = new Float64Array(64);\n var p = [gf(), gf(), gf(), gf()];\n\n crypto_hash(d, sk, 32);\n d[0] &= 248;\n d[31] &= 127;\n d[31] |= 64;\n\n var smlen = n + 64;\n for (i = 0; i < n; i++) sm[64 + i] = m[i];\n for (i = 0; i < 32; i++) sm[32 + i] = d[32 + i];\n\n crypto_hash(r, sm.subarray(32), n+32);\n reduce(r);\n scalarbase(p, r);\n pack(sm, p);\n\n for (i = 32; i < 64; i++) sm[i] = sk[i];\n crypto_hash(h, sm, n + 64);\n reduce(h);\n\n for (i = 0; i < 64; i++) x[i] = 0;\n for (i = 0; i < 32; i++) x[i] = r[i];\n for (i = 0; i < 32; i++) {\n for (j = 0; j < 32; j++) {\n x[i+j] += h[i] * d[j];\n }\n }\n\n modL(sm.subarray(32), x);\n return smlen;\n}\n\nfunction unpackneg(r, p) {\n var t = gf(), chk = gf(), num = gf(),\n den = gf(), den2 = gf(), den4 = gf(),\n den6 = gf();\n\n set25519(r[2], gf1);\n unpack25519(r[1], p);\n S(num, r[1]);\n M(den, num, D);\n Z(num, num, r[2]);\n A(den, r[2], den);\n\n S(den2, den);\n S(den4, den2);\n M(den6, den4, den2);\n M(t, den6, num);\n M(t, t, den);\n\n pow2523(t, t);\n M(t, t, num);\n M(t, t, den);\n M(t, t, den);\n M(r[0], t, den);\n\n S(chk, r[0]);\n M(chk, chk, den);\n if (neq25519(chk, num)) M(r[0], r[0], I);\n\n S(chk, r[0]);\n M(chk, chk, den);\n if (neq25519(chk, num)) return -1;\n\n if (par25519(r[0]) === (p[31]>>7)) Z(r[0], gf0, r[0]);\n\n M(r[3], r[0], r[1]);\n return 0;\n}\n\nfunction crypto_sign_open(m, sm, n, pk) {\n var i;\n var t = new Uint8Array(32), h = new Uint8Array(64);\n var p = [gf(), gf(), gf(), gf()],\n q = [gf(), gf(), gf(), gf()];\n\n if (n < 64) return -1;\n\n if (unpackneg(q, pk)) return -1;\n\n for (i = 0; i < n; i++) m[i] = sm[i];\n for (i = 0; i < 32; i++) m[i+32] = pk[i];\n crypto_hash(h, m, n);\n reduce(h);\n scalarmult(p, q, h);\n\n scalarbase(q, sm.subarray(32));\n add(p, q);\n pack(t, p);\n\n n -= 64;\n if (crypto_verify_32(sm, 0, t, 0)) {\n for (i = 0; i < n; i++) m[i] = 0;\n return -1;\n }\n\n for (i = 0; i < n; i++) m[i] = sm[i + 64];\n return n;\n}\n\nvar crypto_secretbox_KEYBYTES = 32,\n crypto_secretbox_NONCEBYTES = 24,\n crypto_secretbox_ZEROBYTES = 32,\n crypto_secretbox_BOXZEROBYTES = 16,\n crypto_scalarmult_BYTES = 32,\n crypto_scalarmult_SCALARBYTES = 32,\n crypto_box_PUBLICKEYBYTES = 32,\n crypto_box_SECRETKEYBYTES = 32,\n crypto_box_BEFORENMBYTES = 32,\n crypto_box_NONCEBYTES = crypto_secretbox_NONCEBYTES,\n crypto_box_ZEROBYTES = crypto_secretbox_ZEROBYTES,\n crypto_box_BOXZEROBYTES = crypto_secretbox_BOXZEROBYTES,\n crypto_sign_BYTES = 64,\n crypto_sign_PUBLICKEYBYTES = 32,\n crypto_sign_SECRETKEYBYTES = 64,\n crypto_sign_SEEDBYTES = 32,\n crypto_hash_BYTES = 64;\n\nnacl.lowlevel = {\n crypto_core_hsalsa20: crypto_core_hsalsa20,\n crypto_stream_xor: crypto_stream_xor,\n crypto_stream: crypto_stream,\n crypto_stream_salsa20_xor: crypto_stream_salsa20_xor,\n crypto_stream_salsa20: crypto_stream_salsa20,\n crypto_onetimeauth: crypto_onetimeauth,\n crypto_onetimeauth_verify: crypto_onetimeauth_verify,\n crypto_verify_16: crypto_verify_16,\n crypto_verify_32: crypto_verify_32,\n crypto_secretbox: crypto_secretbox,\n crypto_secretbox_open: crypto_secretbox_open,\n crypto_scalarmult: crypto_scalarmult,\n crypto_scalarmult_base: crypto_scalarmult_base,\n crypto_box_beforenm: crypto_box_beforenm,\n crypto_box_afternm: crypto_box_afternm,\n crypto_box: crypto_box,\n crypto_box_open: crypto_box_open,\n crypto_box_keypair: crypto_box_keypair,\n crypto_hash: crypto_hash,\n crypto_sign: crypto_sign,\n crypto_sign_keypair: crypto_sign_keypair,\n crypto_sign_open: crypto_sign_open,\n\n crypto_secretbox_KEYBYTES: crypto_secretbox_KEYBYTES,\n crypto_secretbox_NONCEBYTES: crypto_secretbox_NONCEBYTES,\n crypto_secretbox_ZEROBYTES: crypto_secretbox_ZEROBYTES,\n crypto_secretbox_BOXZEROBYTES: crypto_secretbox_BOXZEROBYTES,\n crypto_scalarmult_BYTES: crypto_scalarmult_BYTES,\n crypto_scalarmult_SCALARBYTES: crypto_scalarmult_SCALARBYTES,\n crypto_box_PUBLICKEYBYTES: crypto_box_PUBLICKEYBYTES,\n crypto_box_SECRETKEYBYTES: crypto_box_SECRETKEYBYTES,\n crypto_box_BEFORENMBYTES: crypto_box_BEFORENMBYTES,\n crypto_box_NONCEBYTES: crypto_box_NONCEBYTES,\n crypto_box_ZEROBYTES: crypto_box_ZEROBYTES,\n crypto_box_BOXZEROBYTES: crypto_box_BOXZEROBYTES,\n crypto_sign_BYTES: crypto_sign_BYTES,\n crypto_sign_PUBLICKEYBYTES: crypto_sign_PUBLICKEYBYTES,\n crypto_sign_SECRETKEYBYTES: crypto_sign_SECRETKEYBYTES,\n crypto_sign_SEEDBYTES: crypto_sign_SEEDBYTES,\n crypto_hash_BYTES: crypto_hash_BYTES,\n\n gf: gf,\n D: D,\n L: L,\n pack25519: pack25519,\n unpack25519: unpack25519,\n M: M,\n A: A,\n S: S,\n Z: Z,\n pow2523: pow2523,\n add: add,\n set25519: set25519,\n modL: modL,\n scalarmult: scalarmult,\n scalarbase: scalarbase,\n};\n\n/* High-level API */\n\nfunction checkLengths(k, n) {\n if (k.length !== crypto_secretbox_KEYBYTES) throw new Error('bad key size');\n if (n.length !== crypto_secretbox_NONCEBYTES) throw new Error('bad nonce size');\n}\n\nfunction checkBoxLengths(pk, sk) {\n if (pk.length !== crypto_box_PUBLICKEYBYTES) throw new Error('bad public key size');\n if (sk.length !== crypto_box_SECRETKEYBYTES) throw new Error('bad secret key size');\n}\n\nfunction checkArrayTypes() {\n for (var i = 0; i < arguments.length; i++) {\n if (!(arguments[i] instanceof Uint8Array))\n throw new TypeError('unexpected type, use Uint8Array');\n }\n}\n\nfunction cleanup(arr) {\n for (var i = 0; i < arr.length; i++) arr[i] = 0;\n}\n\nnacl.randomBytes = function(n) {\n var b = new Uint8Array(n);\n randombytes(b, n);\n return b;\n};\n\nnacl.secretbox = function(msg, nonce, key) {\n checkArrayTypes(msg, nonce, key);\n checkLengths(key, nonce);\n var m = new Uint8Array(crypto_secretbox_ZEROBYTES + msg.length);\n var c = new Uint8Array(m.length);\n for (var i = 0; i < msg.length; i++) m[i+crypto_secretbox_ZEROBYTES] = msg[i];\n crypto_secretbox(c, m, m.length, nonce, key);\n return c.subarray(crypto_secretbox_BOXZEROBYTES);\n};\n\nnacl.secretbox.open = function(box, nonce, key) {\n checkArrayTypes(box, nonce, key);\n checkLengths(key, nonce);\n var c = new Uint8Array(crypto_secretbox_BOXZEROBYTES + box.length);\n var m = new Uint8Array(c.length);\n for (var i = 0; i < box.length; i++) c[i+crypto_secretbox_BOXZEROBYTES] = box[i];\n if (c.length < 32) return null;\n if (crypto_secretbox_open(m, c, c.length, nonce, key) !== 0) return null;\n return m.subarray(crypto_secretbox_ZEROBYTES);\n};\n\nnacl.secretbox.keyLength = crypto_secretbox_KEYBYTES;\nnacl.secretbox.nonceLength = crypto_secretbox_NONCEBYTES;\nnacl.secretbox.overheadLength = crypto_secretbox_BOXZEROBYTES;\n\nnacl.scalarMult = function(n, p) {\n checkArrayTypes(n, p);\n if (n.length !== crypto_scalarmult_SCALARBYTES) throw new Error('bad n size');\n if (p.length !== crypto_scalarmult_BYTES) throw new Error('bad p size');\n var q = new Uint8Array(crypto_scalarmult_BYTES);\n crypto_scalarmult(q, n, p);\n return q;\n};\n\nnacl.scalarMult.base = function(n) {\n checkArrayTypes(n);\n if (n.length !== crypto_scalarmult_SCALARBYTES) throw new Error('bad n size');\n var q = new Uint8Array(crypto_scalarmult_BYTES);\n crypto_scalarmult_base(q, n);\n return q;\n};\n\nnacl.scalarMult.scalarLength = crypto_scalarmult_SCALARBYTES;\nnacl.scalarMult.groupElementLength = crypto_scalarmult_BYTES;\n\nnacl.box = function(msg, nonce, publicKey, secretKey) {\n var k = nacl.box.before(publicKey, secretKey);\n return nacl.secretbox(msg, nonce, k);\n};\n\nnacl.box.before = function(publicKey, secretKey) {\n checkArrayTypes(publicKey, secretKey);\n checkBoxLengths(publicKey, secretKey);\n var k = new Uint8Array(crypto_box_BEFORENMBYTES);\n crypto_box_beforenm(k, publicKey, secretKey);\n return k;\n};\n\nnacl.box.after = nacl.secretbox;\n\nnacl.box.open = function(msg, nonce, publicKey, secretKey) {\n var k = nacl.box.before(publicKey, secretKey);\n return nacl.secretbox.open(msg, nonce, k);\n};\n\nnacl.box.open.after = nacl.secretbox.open;\n\nnacl.box.keyPair = function() {\n var pk = new Uint8Array(crypto_box_PUBLICKEYBYTES);\n var sk = new Uint8Array(crypto_box_SECRETKEYBYTES);\n crypto_box_keypair(pk, sk);\n return {publicKey: pk, secretKey: sk};\n};\n\nnacl.box.keyPair.fromSecretKey = function(secretKey) {\n checkArrayTypes(secretKey);\n if (secretKey.length !== crypto_box_SECRETKEYBYTES)\n throw new Error('bad secret key size');\n var pk = new Uint8Array(crypto_box_PUBLICKEYBYTES);\n crypto_scalarmult_base(pk, secretKey);\n return {publicKey: pk, secretKey: new Uint8Array(secretKey)};\n};\n\nnacl.box.publicKeyLength = crypto_box_PUBLICKEYBYTES;\nnacl.box.secretKeyLength = crypto_box_SECRETKEYBYTES;\nnacl.box.sharedKeyLength = crypto_box_BEFORENMBYTES;\nnacl.box.nonceLength = crypto_box_NONCEBYTES;\nnacl.box.overheadLength = nacl.secretbox.overheadLength;\n\nnacl.sign = function(msg, secretKey) {\n checkArrayTypes(msg, secretKey);\n if (secretKey.length !== crypto_sign_SECRETKEYBYTES)\n throw new Error('bad secret key size');\n var signedMsg = new Uint8Array(crypto_sign_BYTES+msg.length);\n crypto_sign(signedMsg, msg, msg.length, secretKey);\n return signedMsg;\n};\n\nnacl.sign.open = function(signedMsg, publicKey) {\n checkArrayTypes(signedMsg, publicKey);\n if (publicKey.length !== crypto_sign_PUBLICKEYBYTES)\n throw new Error('bad public key size');\n var tmp = new Uint8Array(signedMsg.length);\n var mlen = crypto_sign_open(tmp, signedMsg, signedMsg.length, publicKey);\n if (mlen < 0) return null;\n var m = new Uint8Array(mlen);\n for (var i = 0; i < m.length; i++) m[i] = tmp[i];\n return m;\n};\n\nnacl.sign.detached = function(msg, secretKey) {\n var signedMsg = nacl.sign(msg, secretKey);\n var sig = new Uint8Array(crypto_sign_BYTES);\n for (var i = 0; i < sig.length; i++) sig[i] = signedMsg[i];\n return sig;\n};\n\nnacl.sign.detached.verify = function(msg, sig, publicKey) {\n checkArrayTypes(msg, sig, publicKey);\n if (sig.length !== crypto_sign_BYTES)\n throw new Error('bad signature size');\n if (publicKey.length !== crypto_sign_PUBLICKEYBYTES)\n throw new Error('bad public key size');\n var sm = new Uint8Array(crypto_sign_BYTES + msg.length);\n var m = new Uint8Array(crypto_sign_BYTES + msg.length);\n var i;\n for (i = 0; i < crypto_sign_BYTES; i++) sm[i] = sig[i];\n for (i = 0; i < msg.length; i++) sm[i+crypto_sign_BYTES] = msg[i];\n return (crypto_sign_open(m, sm, sm.length, publicKey) >= 0);\n};\n\nnacl.sign.keyPair = function() {\n var pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);\n var sk = new Uint8Array(crypto_sign_SECRETKEYBYTES);\n crypto_sign_keypair(pk, sk);\n return {publicKey: pk, secretKey: sk};\n};\n\nnacl.sign.keyPair.fromSecretKey = function(secretKey) {\n checkArrayTypes(secretKey);\n if (secretKey.length !== crypto_sign_SECRETKEYBYTES)\n throw new Error('bad secret key size');\n var pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);\n for (var i = 0; i < pk.length; i++) pk[i] = secretKey[32+i];\n return {publicKey: pk, secretKey: new Uint8Array(secretKey)};\n};\n\nnacl.sign.keyPair.fromSeed = function(seed) {\n checkArrayTypes(seed);\n if (seed.length !== crypto_sign_SEEDBYTES)\n throw new Error('bad seed size');\n var pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);\n var sk = new Uint8Array(crypto_sign_SECRETKEYBYTES);\n for (var i = 0; i < 32; i++) sk[i] = seed[i];\n crypto_sign_keypair(pk, sk, true);\n return {publicKey: pk, secretKey: sk};\n};\n\nnacl.sign.publicKeyLength = crypto_sign_PUBLICKEYBYTES;\nnacl.sign.secretKeyLength = crypto_sign_SECRETKEYBYTES;\nnacl.sign.seedLength = crypto_sign_SEEDBYTES;\nnacl.sign.signatureLength = crypto_sign_BYTES;\n\nnacl.hash = function(msg) {\n checkArrayTypes(msg);\n var h = new Uint8Array(crypto_hash_BYTES);\n crypto_hash(h, msg, msg.length);\n return h;\n};\n\nnacl.hash.hashLength = crypto_hash_BYTES;\n\nnacl.verify = function(x, y) {\n checkArrayTypes(x, y);\n // Zero length arguments are considered not equal.\n if (x.length === 0 || y.length === 0) return false;\n if (x.length !== y.length) return false;\n return (vn(x, 0, y, 0, x.length) === 0) ? true : false;\n};\n\nnacl.setPRNG = function(fn) {\n randombytes = fn;\n};\n\n(function() {\n // Initialize PRNG if environment provides CSPRNG.\n // If not, methods calling randombytes will throw.\n var crypto = typeof self !== 'undefined' ? (self.crypto || self.msCrypto) : null;\n if (crypto && crypto.getRandomValues) {\n // Browsers.\n var QUOTA = 65536;\n nacl.setPRNG(function(x, n) {\n var i, v = new Uint8Array(n);\n for (i = 0; i < n; i += QUOTA) {\n crypto.getRandomValues(v.subarray(i, i + Math.min(n - i, QUOTA)));\n }\n for (i = 0; i < n; i++) x[i] = v[i];\n cleanup(v);\n });\n } else if (typeof require !== 'undefined') {\n // Node.js.\n crypto = require('crypto');\n if (crypto && crypto.randomBytes) {\n nacl.setPRNG(function(x, n) {\n var i, v = crypto.randomBytes(n);\n for (i = 0; i < n; i++) x[i] = v[i];\n cleanup(v);\n });\n }\n }\n})();\n\n})(typeof module !== 'undefined' && module.exports ? module.exports : (self.nacl = self.nacl || {}));\n","module.exports = require('./pusher-with-encryption').default;\n","/* (ignored) */","export default function encode(s: any): string {\n return btoa(utob(s));\n}\n\nvar fromCharCode = String.fromCharCode;\n\nvar b64chars =\n 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';\nvar b64tab = {};\n\nfor (var i = 0, l = b64chars.length; i < l; i++) {\n b64tab[b64chars.charAt(i)] = i;\n}\n\nvar cb_utob = function(c) {\n var cc = c.charCodeAt(0);\n return cc < 0x80\n ? c\n : cc < 0x800\n ? fromCharCode(0xc0 | (cc >>> 6)) + fromCharCode(0x80 | (cc & 0x3f))\n : fromCharCode(0xe0 | ((cc >>> 12) & 0x0f)) +\n fromCharCode(0x80 | ((cc >>> 6) & 0x3f)) +\n fromCharCode(0x80 | (cc & 0x3f));\n};\n\nvar utob = function(u) {\n return u.replace(/[^\\x00-\\x7F]/g, cb_utob);\n};\n\nvar cb_encode = function(ccc) {\n var padlen = [0, 2, 1][ccc.length % 3];\n var ord =\n (ccc.charCodeAt(0) << 16) |\n ((ccc.length > 1 ? ccc.charCodeAt(1) : 0) << 8) |\n (ccc.length > 2 ? ccc.charCodeAt(2) : 0);\n var chars = [\n b64chars.charAt(ord >>> 18),\n b64chars.charAt((ord >>> 12) & 63),\n padlen >= 2 ? '=' : b64chars.charAt((ord >>> 6) & 63),\n padlen >= 1 ? '=' : b64chars.charAt(ord & 63)\n ];\n return chars.join('');\n};\n\nvar btoa =\n global.btoa ||\n function(b) {\n return b.replace(/[\\s\\S]{1,3}/g, cb_encode);\n };\n","import TimedCallback from './timed_callback';\nimport { Delay, Scheduler, Canceller } from './scheduling';\n\nabstract class Timer {\n protected clear: Canceller;\n protected timer: number | void;\n\n constructor(\n set: Scheduler,\n clear: Canceller,\n delay: Delay,\n callback: TimedCallback\n ) {\n this.clear = clear;\n this.timer = set(() => {\n if (this.timer) {\n this.timer = callback(this.timer);\n }\n }, delay);\n }\n\n /** Returns whether the timer is still running.\n *\n * @return {Boolean}\n */\n isRunning(): boolean {\n return this.timer !== null;\n }\n\n /** Aborts a timer when it's running. */\n ensureAborted() {\n if (this.timer) {\n this.clear(this.timer);\n this.timer = null;\n }\n }\n}\n\nexport default Timer;\n","import Timer from './abstract_timer';\nimport TimedCallback from './timed_callback';\nimport { Delay } from './scheduling';\n\n// We need to bind clear functions this way to avoid exceptions on IE8\nfunction clearTimeout(timer) {\n global.clearTimeout(timer);\n}\nfunction clearInterval(timer) {\n global.clearInterval(timer);\n}\n\n/** Cross-browser compatible one-off timer abstraction.\n *\n * @param {Number} delay\n * @param {Function} callback\n */\nexport class OneOffTimer extends Timer {\n constructor(delay: Delay, callback: TimedCallback) {\n super(setTimeout, clearTimeout, delay, function(timer) {\n callback();\n return null;\n });\n }\n}\n\n/** Cross-browser compatible periodic timer abstraction.\n *\n * @param {Number} delay\n * @param {Function} callback\n */\nexport class PeriodicTimer extends Timer {\n constructor(delay: Delay, callback: TimedCallback) {\n super(setInterval, clearInterval, delay, function(timer) {\n callback();\n return timer;\n });\n }\n}\n","import * as Collections from './utils/collections';\nimport TimedCallback from './utils/timers/timed_callback';\nimport { OneOffTimer, PeriodicTimer } from './utils/timers';\n\nvar Util = {\n now(): number {\n if (Date.now) {\n return Date.now();\n } else {\n return new Date().valueOf();\n }\n },\n\n defer(callback: TimedCallback): OneOffTimer {\n return new OneOffTimer(0, callback);\n },\n\n /** Builds a function that will proxy a method call to its first argument.\n *\n * Allows partial application of arguments, so additional arguments are\n * prepended to the argument list.\n *\n * @param {String} name method name\n * @return {Function} proxy function\n */\n method(name: string, ...args: any[]): Function {\n var boundArguments = Array.prototype.slice.call(arguments, 1);\n return function(object) {\n return object[name].apply(object, boundArguments.concat(arguments));\n };\n }\n};\n\nexport default Util;\n","import base64encode from '../base64';\nimport Util from '../util';\n\n/** Merges multiple objects into the target argument.\n *\n * For properties that are plain Objects, performs a deep-merge. For the\n * rest it just copies the value of the property.\n *\n * To extend prototypes use it as following:\n * Pusher.Util.extend(Target.prototype, Base.prototype)\n *\n * You can also use it to merge objects without altering them:\n * Pusher.Util.extend({}, object1, object2)\n *\n * @param {Object} target\n * @return {Object} the target argument\n */\nexport function extend(target: any, ...sources: any[]): T {\n for (var i = 0; i < sources.length; i++) {\n var extensions = sources[i];\n for (var property in extensions) {\n if (\n extensions[property] &&\n extensions[property].constructor &&\n extensions[property].constructor === Object\n ) {\n target[property] = extend(target[property] || {}, extensions[property]);\n } else {\n target[property] = extensions[property];\n }\n }\n }\n return target;\n}\n\nexport function stringify(): string {\n var m = ['Pusher'];\n for (var i = 0; i < arguments.length; i++) {\n if (typeof arguments[i] === 'string') {\n m.push(arguments[i]);\n } else {\n m.push(safeJSONStringify(arguments[i]));\n }\n }\n return m.join(' : ');\n}\n\nexport function arrayIndexOf(array: any[], item: any): number {\n // MSIE doesn't have array.indexOf\n var nativeIndexOf = Array.prototype.indexOf;\n if (array === null) {\n return -1;\n }\n if (nativeIndexOf && array.indexOf === nativeIndexOf) {\n return array.indexOf(item);\n }\n for (var i = 0, l = array.length; i < l; i++) {\n if (array[i] === item) {\n return i;\n }\n }\n return -1;\n}\n\n/** Applies a function f to all properties of an object.\n *\n * Function f gets 3 arguments passed:\n * - element from the object\n * - key of the element\n * - reference to the object\n *\n * @param {Object} object\n * @param {Function} f\n */\nexport function objectApply(object: any, f: Function) {\n for (var key in object) {\n if (Object.prototype.hasOwnProperty.call(object, key)) {\n f(object[key], key, object);\n }\n }\n}\n\n/** Return a list of objects own proerty keys\n *\n * @param {Object} object\n * @returns {Array}\n */\nexport function keys(object: any): string[] {\n var keys = [];\n objectApply(object, function(_, key) {\n keys.push(key);\n });\n return keys;\n}\n\n/** Return a list of object's own property values\n *\n * @param {Object} object\n * @returns {Array}\n */\nexport function values(object: any): any[] {\n var values = [];\n objectApply(object, function(value) {\n values.push(value);\n });\n return values;\n}\n\n/** Applies a function f to all elements of an array.\n *\n * Function f gets 3 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function apply(array: any[], f: Function, context?: any) {\n for (var i = 0; i < array.length; i++) {\n f.call(context || global, array[i], i, array);\n }\n}\n\n/** Maps all elements of the array and returns the result.\n *\n * Function f gets 4 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n * - reference to the destination array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function map(array: any[], f: Function): any[] {\n var result = [];\n for (var i = 0; i < array.length; i++) {\n result.push(f(array[i], i, array, result));\n }\n return result;\n}\n\n/** Maps all elements of the object and returns the result.\n *\n * Function f gets 4 arguments passed:\n * - element from the object\n * - key of the element\n * - reference to the source object\n * - reference to the destination object\n *\n * @param {Object} object\n * @param {Function} f\n */\nexport function mapObject(object: any, f: Function): any {\n var result = {};\n objectApply(object, function(value, key) {\n result[key] = f(value);\n });\n return result;\n}\n\n/** Filters elements of the array using a test function.\n *\n * Function test gets 4 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n * - reference to the destination array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function filter(array: any[], test: Function): any[] {\n test =\n test ||\n function(value) {\n return !!value;\n };\n\n var result = [];\n for (var i = 0; i < array.length; i++) {\n if (test(array[i], i, array, result)) {\n result.push(array[i]);\n }\n }\n return result;\n}\n\n/** Filters properties of the object using a test function.\n *\n * Function test gets 4 arguments passed:\n * - element from the object\n * - key of the element\n * - reference to the source object\n * - reference to the destination object\n *\n * @param {Object} object\n * @param {Function} f\n */\nexport function filterObject(object: Object, test: Function) {\n var result = {};\n objectApply(object, function(value, key) {\n if ((test && test(value, key, object, result)) || Boolean(value)) {\n result[key] = value;\n }\n });\n return result;\n}\n\n/** Flattens an object into a two-dimensional array.\n *\n * @param {Object} object\n * @return {Array} resulting array of [key, value] pairs\n */\nexport function flatten(object: Object): any[] {\n var result = [];\n objectApply(object, function(value, key) {\n result.push([key, value]);\n });\n return result;\n}\n\n/** Checks whether any element of the array passes the test.\n *\n * Function test gets 3 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function any(array: any[], test: Function): boolean {\n for (var i = 0; i < array.length; i++) {\n if (test(array[i], i, array)) {\n return true;\n }\n }\n return false;\n}\n\n/** Checks whether all elements of the array pass the test.\n *\n * Function test gets 3 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function all(array: any[], test: Function): boolean {\n for (var i = 0; i < array.length; i++) {\n if (!test(array[i], i, array)) {\n return false;\n }\n }\n return true;\n}\n\nexport function encodeParamsObject(data): string {\n return mapObject(data, function(value) {\n if (typeof value === 'object') {\n value = safeJSONStringify(value);\n }\n return encodeURIComponent(base64encode(value.toString()));\n });\n}\n\nexport function buildQueryString(data: any): string {\n var params = filterObject(data, function(value) {\n return value !== undefined;\n });\n\n var query = map(\n flatten(encodeParamsObject(params)),\n Util.method('join', '=')\n ).join('&');\n\n return query;\n}\n\n/**\n * See https://github.com/douglascrockford/JSON-js/blob/master/cycle.js\n *\n * Remove circular references from an object. Required for JSON.stringify in\n * React Native, which tends to blow up a lot.\n *\n * @param {any} object\n * @return {any} Decycled object\n */\nexport function decycleObject(object: any): any {\n var objects = [],\n paths = [];\n\n return (function derez(value, path) {\n var i, name, nu;\n\n switch (typeof value) {\n case 'object':\n if (!value) {\n return null;\n }\n for (i = 0; i < objects.length; i += 1) {\n if (objects[i] === value) {\n return { $ref: paths[i] };\n }\n }\n\n objects.push(value);\n paths.push(path);\n\n if (Object.prototype.toString.apply(value) === '[object Array]') {\n nu = [];\n for (i = 0; i < value.length; i += 1) {\n nu[i] = derez(value[i], path + '[' + i + ']');\n }\n } else {\n nu = {};\n for (name in value) {\n if (Object.prototype.hasOwnProperty.call(value, name)) {\n nu[name] = derez(\n value[name],\n path + '[' + JSON.stringify(name) + ']'\n );\n }\n }\n }\n return nu;\n case 'number':\n case 'string':\n case 'boolean':\n return value;\n }\n })(object, '$');\n}\n\n/**\n * Provides a cross-browser and cross-platform way to safely stringify objects\n * into JSON. This is particularly necessary for ReactNative, where circular JSON\n * structures throw an exception.\n *\n * @param {any} source The object to stringify\n * @return {string} The serialized output.\n */\nexport function safeJSONStringify(source: any): string {\n try {\n return JSON.stringify(source);\n } catch (e) {\n return JSON.stringify(decycleObject(source));\n }\n}\n","import {\n ChannelAuthorizationOptions,\n UserAuthenticationOptions\n} from './auth/options';\nimport { AuthTransport } from './config';\n\nexport interface DefaultConfig {\n VERSION: string;\n PROTOCOL: number;\n wsPort: number;\n wssPort: number;\n wsPath: string;\n httpHost: string;\n httpPort: number;\n httpsPort: number;\n httpPath: string;\n stats_host: string;\n authEndpoint: string;\n authTransport: AuthTransport;\n activityTimeout: number;\n pongTimeout: number;\n unavailableTimeout: number;\n userAuthentication: UserAuthenticationOptions;\n channelAuthorization: ChannelAuthorizationOptions;\n\n cdn_http?: string;\n cdn_https?: string;\n dependency_suffix?: string;\n}\n\nvar Defaults: DefaultConfig = {\n VERSION: VERSION,\n PROTOCOL: 7,\n\n wsPort: 80,\n wssPort: 443,\n wsPath: '',\n // DEPRECATED: SockJS fallback parameters\n httpHost: 'sockjs.pusher.com',\n httpPort: 80,\n httpsPort: 443,\n httpPath: '/pusher',\n // DEPRECATED: Stats\n stats_host: 'stats.pusher.com',\n // DEPRECATED: Other settings\n authEndpoint: '/pusher/auth',\n authTransport: 'ajax',\n activityTimeout: 120000,\n pongTimeout: 30000,\n unavailableTimeout: 10000,\n userAuthentication: {\n endpoint: '/pusher/user-auth',\n transport: 'ajax'\n },\n channelAuthorization: {\n endpoint: '/pusher/auth',\n transport: 'ajax'\n },\n\n // CDN configuration\n cdn_http: CDN_HTTP,\n cdn_https: CDN_HTTPS,\n dependency_suffix: DEPENDENCY_SUFFIX\n};\n\nexport default Defaults;\n","import Defaults from '../defaults';\nimport { default as URLScheme, URLSchemeParams } from './url_scheme';\n\nfunction getGenericURL(\n baseScheme: string,\n params: URLSchemeParams,\n path: string\n): string {\n var scheme = baseScheme + (params.useTLS ? 's' : '');\n var host = params.useTLS ? params.hostTLS : params.hostNonTLS;\n return scheme + '://' + host + path;\n}\n\nfunction getGenericPath(key: string, queryString?: string): string {\n var path = '/app/' + key;\n var query =\n '?protocol=' +\n Defaults.PROTOCOL +\n '&client=js' +\n '&version=' +\n Defaults.VERSION +\n (queryString ? '&' + queryString : '');\n return path + query;\n}\n\nexport var ws: URLScheme = {\n getInitial: function(key: string, params: URLSchemeParams): string {\n var path = (params.httpPath || '') + getGenericPath(key, 'flash=false');\n return getGenericURL('ws', params, path);\n }\n};\n\nexport var http: URLScheme = {\n getInitial: function(key: string, params: URLSchemeParams): string {\n var path = (params.httpPath || '/pusher') + getGenericPath(key);\n return getGenericURL('http', params, path);\n }\n};\n\nexport var sockjs: URLScheme = {\n getInitial: function(key: string, params: URLSchemeParams): string {\n return getGenericURL('http', params, params.httpPath || '/pusher');\n },\n getPath: function(key: string, params: URLSchemeParams): string {\n return getGenericPath(key);\n }\n};\n","import Callback from './callback';\nimport * as Collections from '../utils/collections';\nimport CallbackTable from './callback_table';\n\nexport default class CallbackRegistry {\n _callbacks: CallbackTable;\n\n constructor() {\n this._callbacks = {};\n }\n\n get(name: string): Callback[] {\n return this._callbacks[prefix(name)];\n }\n\n add(name: string, callback: Function, context: any) {\n var prefixedEventName = prefix(name);\n this._callbacks[prefixedEventName] =\n this._callbacks[prefixedEventName] || [];\n this._callbacks[prefixedEventName].push({\n fn: callback,\n context: context\n });\n }\n\n remove(name?: string, callback?: Function, context?: any) {\n if (!name && !callback && !context) {\n this._callbacks = {};\n return;\n }\n\n var names = name ? [prefix(name)] : Collections.keys(this._callbacks);\n\n if (callback || context) {\n this.removeCallback(names, callback, context);\n } else {\n this.removeAllCallbacks(names);\n }\n }\n\n private removeCallback(names: string[], callback: Function, context: any) {\n Collections.apply(\n names,\n function(name) {\n this._callbacks[name] = Collections.filter(\n this._callbacks[name] || [],\n function(binding) {\n return (\n (callback && callback !== binding.fn) ||\n (context && context !== binding.context)\n );\n }\n );\n if (this._callbacks[name].length === 0) {\n delete this._callbacks[name];\n }\n },\n this\n );\n }\n\n private removeAllCallbacks(names: string[]) {\n Collections.apply(\n names,\n function(name) {\n delete this._callbacks[name];\n },\n this\n );\n }\n}\n\nfunction prefix(name: string): string {\n return '_' + name;\n}\n","import * as Collections from '../utils/collections';\nimport Callback from './callback';\nimport Metadata from '../channels/metadata';\nimport CallbackRegistry from './callback_registry';\n\n/** Manages callback bindings and event emitting.\n *\n * @param Function failThrough called when no listeners are bound to an event\n */\nexport default class Dispatcher {\n callbacks: CallbackRegistry;\n global_callbacks: Function[];\n failThrough: Function;\n\n constructor(failThrough?: Function) {\n this.callbacks = new CallbackRegistry();\n this.global_callbacks = [];\n this.failThrough = failThrough;\n }\n\n bind(eventName: string, callback: Function, context?: any) {\n this.callbacks.add(eventName, callback, context);\n return this;\n }\n\n bind_global(callback: Function) {\n this.global_callbacks.push(callback);\n return this;\n }\n\n unbind(eventName?: string, callback?: Function, context?: any) {\n this.callbacks.remove(eventName, callback, context);\n return this;\n }\n\n unbind_global(callback?: Function) {\n if (!callback) {\n this.global_callbacks = [];\n return this;\n }\n\n this.global_callbacks = Collections.filter(\n this.global_callbacks || [],\n c => c !== callback\n );\n\n return this;\n }\n\n unbind_all() {\n this.unbind();\n this.unbind_global();\n return this;\n }\n\n emit(eventName: string, data?: any, metadata?: Metadata): Dispatcher {\n for (var i = 0; i < this.global_callbacks.length; i++) {\n this.global_callbacks[i](eventName, data);\n }\n\n var callbacks = this.callbacks.get(eventName);\n var args = [];\n\n if (metadata) {\n // if there's a metadata argument, we need to call the callback with both\n // data and metadata regardless of whether data is undefined\n args.push(data, metadata);\n } else if (data) {\n // metadata is undefined, so we only need to call the callback with data\n // if data exists\n args.push(data);\n }\n\n if (callbacks && callbacks.length > 0) {\n for (var i = 0; i < callbacks.length; i++) {\n callbacks[i].fn.apply(callbacks[i].context || global, args);\n }\n } else if (this.failThrough) {\n this.failThrough(eventName, data);\n }\n\n return this;\n }\n}\n","import { stringify } from './utils/collections';\nimport Pusher from './pusher';\n\nclass Logger {\n debug(...args: any[]) {\n this.log(this.globalLog, args);\n }\n\n warn(...args: any[]) {\n this.log(this.globalLogWarn, args);\n }\n\n error(...args: any[]) {\n this.log(this.globalLogError, args);\n }\n\n private globalLog = (message: string) => {\n if (global.console && global.console.log) {\n global.console.log(message);\n }\n };\n\n private globalLogWarn(message: string) {\n if (global.console && global.console.warn) {\n global.console.warn(message);\n } else {\n this.globalLog(message);\n }\n }\n\n private globalLogError(message: string) {\n if (global.console && global.console.error) {\n global.console.error(message);\n } else {\n this.globalLogWarn(message);\n }\n }\n\n private log(\n defaultLoggingFunction: (message: string) => void,\n ...args: any[]\n ) {\n var message = stringify.apply(this, arguments);\n if (Pusher.log) {\n Pusher.log(message);\n } else if (Pusher.logToConsole) {\n const log = defaultLoggingFunction.bind(this);\n log(message);\n }\n }\n}\n\nexport default new Logger();\n","import Util from '../util';\nimport * as Collections from '../utils/collections';\nimport { default as EventsDispatcher } from '../events/dispatcher';\nimport Logger from '../logger';\nimport TransportHooks from './transport_hooks';\nimport Socket from '../socket';\nimport Runtime from 'runtime';\nimport Timeline from '../timeline/timeline';\nimport TransportConnectionOptions from './transport_connection_options';\n\n/** Provides universal API for transport connections.\n *\n * Transport connection is a low-level object that wraps a connection method\n * and exposes a simple evented interface for the connection state and\n * messaging. It does not implement Pusher-specific WebSocket protocol.\n *\n * Additionally, it fetches resources needed for transport to work and exposes\n * an interface for querying transport features.\n *\n * States:\n * - new - initial state after constructing the object\n * - initializing - during initialization phase, usually fetching resources\n * - intialized - ready to establish a connection\n * - connection - when connection is being established\n * - open - when connection ready to be used\n * - closed - after connection was closed be either side\n *\n * Emits:\n * - error - after the connection raised an error\n *\n * Options:\n * - useTLS - whether connection should be over TLS\n * - hostTLS - host to connect to when connection is over TLS\n * - hostNonTLS - host to connect to when connection is over TLS\n *\n * @param {String} key application key\n * @param {Object} options\n */\nexport default class TransportConnection extends EventsDispatcher {\n hooks: TransportHooks;\n name: string;\n priority: number;\n key: string;\n options: TransportConnectionOptions;\n state: string;\n timeline: Timeline;\n activityTimeout: number;\n id: number;\n socket: Socket;\n beforeOpen: Function;\n initialize: Function;\n\n constructor(\n hooks: TransportHooks,\n name: string,\n priority: number,\n key: string,\n options: TransportConnectionOptions\n ) {\n super();\n this.initialize = Runtime.transportConnectionInitializer;\n this.hooks = hooks;\n this.name = name;\n this.priority = priority;\n this.key = key;\n this.options = options;\n\n this.state = 'new';\n this.timeline = options.timeline;\n this.activityTimeout = options.activityTimeout;\n this.id = this.timeline.generateUniqueID();\n }\n\n /** Checks whether the transport handles activity checks by itself.\n *\n * @return {Boolean}\n */\n handlesActivityChecks(): boolean {\n return Boolean(this.hooks.handlesActivityChecks);\n }\n\n /** Checks whether the transport supports the ping/pong API.\n *\n * @return {Boolean}\n */\n supportsPing(): boolean {\n return Boolean(this.hooks.supportsPing);\n }\n\n /** Tries to establish a connection.\n *\n * @returns {Boolean} false if transport is in invalid state\n */\n connect(): boolean {\n if (this.socket || this.state !== 'initialized') {\n return false;\n }\n\n var url = this.hooks.urls.getInitial(this.key, this.options);\n try {\n this.socket = this.hooks.getSocket(url, this.options);\n } catch (e) {\n Util.defer(() => {\n this.onError(e);\n this.changeState('closed');\n });\n return false;\n }\n\n this.bindListeners();\n\n Logger.debug('Connecting', { transport: this.name, url });\n this.changeState('connecting');\n return true;\n }\n\n /** Closes the connection.\n *\n * @return {Boolean} true if there was a connection to close\n */\n close(): boolean {\n if (this.socket) {\n this.socket.close();\n return true;\n } else {\n return false;\n }\n }\n\n /** Sends data over the open connection.\n *\n * @param {String} data\n * @return {Boolean} true only when in the \"open\" state\n */\n send(data: any): boolean {\n if (this.state === 'open') {\n // Workaround for MobileSafari bug (see https://gist.github.com/2052006)\n Util.defer(() => {\n if (this.socket) {\n this.socket.send(data);\n }\n });\n return true;\n } else {\n return false;\n }\n }\n\n /** Sends a ping if the connection is open and transport supports it. */\n ping() {\n if (this.state === 'open' && this.supportsPing()) {\n this.socket.ping();\n }\n }\n\n private onOpen() {\n if (this.hooks.beforeOpen) {\n this.hooks.beforeOpen(\n this.socket,\n this.hooks.urls.getPath(this.key, this.options)\n );\n }\n this.changeState('open');\n this.socket.onopen = undefined;\n }\n\n private onError(error) {\n this.emit('error', { type: 'WebSocketError', error: error });\n this.timeline.error(this.buildTimelineMessage({ error: error.toString() }));\n }\n\n private onClose(closeEvent?: any) {\n if (closeEvent) {\n this.changeState('closed', {\n code: closeEvent.code,\n reason: closeEvent.reason,\n wasClean: closeEvent.wasClean\n });\n } else {\n this.changeState('closed');\n }\n this.unbindListeners();\n this.socket = undefined;\n }\n\n private onMessage(message) {\n this.emit('message', message);\n }\n\n private onActivity() {\n this.emit('activity');\n }\n\n private bindListeners() {\n this.socket.onopen = () => {\n this.onOpen();\n };\n this.socket.onerror = error => {\n this.onError(error);\n };\n this.socket.onclose = closeEvent => {\n this.onClose(closeEvent);\n };\n this.socket.onmessage = message => {\n this.onMessage(message);\n };\n\n if (this.supportsPing()) {\n this.socket.onactivity = () => {\n this.onActivity();\n };\n }\n }\n\n private unbindListeners() {\n if (this.socket) {\n this.socket.onopen = undefined;\n this.socket.onerror = undefined;\n this.socket.onclose = undefined;\n this.socket.onmessage = undefined;\n if (this.supportsPing()) {\n this.socket.onactivity = undefined;\n }\n }\n }\n\n private changeState(state: string, params?: any) {\n this.state = state;\n this.timeline.info(\n this.buildTimelineMessage({\n state: state,\n params: params\n })\n );\n this.emit(state, params);\n }\n\n buildTimelineMessage(message): any {\n return Collections.extend({ cid: this.id }, message);\n }\n}\n","import Factory from '../utils/factory';\nimport TransportHooks from './transport_hooks';\nimport TransportConnection from './transport_connection';\nimport TransportConnectionOptions from './transport_connection_options';\n\n/** Provides interface for transport connection instantiation.\n *\n * Takes transport-specific hooks as the only argument, which allow checking\n * for transport support and creating its connections.\n *\n * Supported hooks: * - file - the name of the file to be fetched during initialization\n * - urls - URL scheme to be used by transport\n * - handlesActivityCheck - true when the transport handles activity checks\n * - supportsPing - true when the transport has a ping/activity API\n * - isSupported - tells whether the transport is supported in the environment\n * - getSocket - creates a WebSocket-compatible transport socket\n *\n * See transports.js for specific implementations.\n *\n * @param {Object} hooks object containing all needed transport hooks\n */\nexport default class Transport {\n hooks: TransportHooks;\n\n constructor(hooks: TransportHooks) {\n this.hooks = hooks;\n }\n\n /** Returns whether the transport is supported in the environment.\n *\n * @param {Object} envronment te environment details (encryption, settings)\n * @returns {Boolean} true when the transport is supported\n */\n isSupported(environment: any): boolean {\n return this.hooks.isSupported(environment);\n }\n\n /** Creates a transport connection.\n *\n * @param {String} name\n * @param {Number} priority\n * @param {String} key the application key\n * @param {Object} options\n * @returns {TransportConnection}\n */\n createConnection(\n name: string,\n priority: number,\n key: string,\n options: any\n ): TransportConnection {\n return new TransportConnection(this.hooks, name, priority, key, options);\n }\n}\n","import * as URLSchemes from 'core/transports/url_schemes';\nimport URLScheme from 'core/transports/url_scheme';\nimport Transport from 'core/transports/transport';\nimport Util from 'core/util';\nimport * as Collections from 'core/utils/collections';\nimport TransportHooks from 'core/transports/transport_hooks';\nimport TransportsTable from 'core/transports/transports_table';\nimport Runtime from 'runtime';\n\n/** WebSocket transport.\n *\n * Uses native WebSocket implementation, including MozWebSocket supported by\n * earlier Firefox versions.\n */\nvar WSTransport = new Transport({\n urls: URLSchemes.ws,\n handlesActivityChecks: false,\n supportsPing: false,\n\n isInitialized: function() {\n return Boolean(Runtime.getWebSocketAPI());\n },\n isSupported: function(): boolean {\n return Boolean(Runtime.getWebSocketAPI());\n },\n getSocket: function(url) {\n return Runtime.createWebSocket(url);\n }\n});\n\nvar httpConfiguration = {\n urls: URLSchemes.http,\n handlesActivityChecks: false,\n supportsPing: true,\n isInitialized: function() {\n return true;\n }\n};\n\nexport var streamingConfiguration = Collections.extend(\n {\n getSocket: function(url) {\n return Runtime.HTTPFactory.createStreamingSocket(url);\n }\n },\n httpConfiguration\n);\nexport var pollingConfiguration = Collections.extend(\n {\n getSocket: function(url) {\n return Runtime.HTTPFactory.createPollingSocket(url);\n }\n },\n httpConfiguration\n);\n\nvar xhrConfiguration = {\n isSupported: function(): boolean {\n return Runtime.isXHRSupported();\n }\n};\n\n/** HTTP streaming transport using CORS-enabled XMLHttpRequest. */\nvar XHRStreamingTransport = new Transport(\n (\n Collections.extend({}, streamingConfiguration, xhrConfiguration)\n )\n);\n\n/** HTTP long-polling transport using CORS-enabled XMLHttpRequest. */\nvar XHRPollingTransport = new Transport(\n Collections.extend({}, pollingConfiguration, xhrConfiguration)\n);\n\nvar Transports: TransportsTable = {\n ws: WSTransport,\n xhr_streaming: XHRStreamingTransport,\n xhr_polling: XHRPollingTransport\n};\n\nexport default Transports;\n","import Util from '../util';\nimport * as Collections from '../utils/collections';\nimport TransportManager from './transport_manager';\nimport TransportConnection from './transport_connection';\nimport Transport from './transport';\nimport PingDelayOptions from './ping_delay_options';\n\n/** Creates transport connections monitored by a transport manager.\n *\n * When a transport is closed, it might mean the environment does not support\n * it. It's possible that messages get stuck in an intermediate buffer or\n * proxies terminate inactive connections. To combat these problems,\n * assistants monitor the connection lifetime, report unclean exits and\n * adjust ping timeouts to keep the connection active. The decision to disable\n * a transport is the manager's responsibility.\n *\n * @param {TransportManager} manager\n * @param {TransportConnection} transport\n * @param {Object} options\n */\nexport default class AssistantToTheTransportManager {\n manager: TransportManager;\n transport: Transport;\n minPingDelay: number;\n maxPingDelay: number;\n pingDelay: number;\n\n constructor(\n manager: TransportManager,\n transport: Transport,\n options: PingDelayOptions\n ) {\n this.manager = manager;\n this.transport = transport;\n this.minPingDelay = options.minPingDelay;\n this.maxPingDelay = options.maxPingDelay;\n this.pingDelay = undefined;\n }\n\n /** Creates a transport connection.\n *\n * This function has the same API as Transport#createConnection.\n *\n * @param {String} name\n * @param {Number} priority\n * @param {String} key the application key\n * @param {Object} options\n * @returns {TransportConnection}\n */\n createConnection(\n name: string,\n priority: number,\n key: string,\n options: Object\n ): TransportConnection {\n options = Collections.extend({}, options, {\n activityTimeout: this.pingDelay\n });\n var connection = this.transport.createConnection(\n name,\n priority,\n key,\n options\n );\n\n var openTimestamp = null;\n\n var onOpen = function() {\n connection.unbind('open', onOpen);\n connection.bind('closed', onClosed);\n openTimestamp = Util.now();\n };\n var onClosed = closeEvent => {\n connection.unbind('closed', onClosed);\n\n if (closeEvent.code === 1002 || closeEvent.code === 1003) {\n // we don't want to use transports not obeying the protocol\n this.manager.reportDeath();\n } else if (!closeEvent.wasClean && openTimestamp) {\n // report deaths only for short-living transport\n var lifespan = Util.now() - openTimestamp;\n if (lifespan < 2 * this.maxPingDelay) {\n this.manager.reportDeath();\n this.pingDelay = Math.max(lifespan / 2, this.minPingDelay);\n }\n }\n };\n\n connection.bind('open', onOpen);\n return connection;\n }\n\n /** Returns whether the transport is supported in the environment.\n *\n * This function has the same API as Transport#isSupported. Might return false\n * when the manager decides to kill the transport.\n *\n * @param {Object} environment the environment details (encryption, settings)\n * @returns {Boolean} true when the transport is supported\n */\n isSupported(environment: string): boolean {\n return this.manager.isAlive() && this.transport.isSupported(environment);\n }\n}\n","import Action from './action';\nimport { PusherEvent } from './message-types';\n/**\n * Provides functions for handling Pusher protocol-specific messages.\n */\n\nconst Protocol = {\n /**\n * Decodes a message in a Pusher format.\n *\n * The MessageEvent we receive from the transport should contain a pusher event\n * (https://pusher.com/docs/pusher_protocol#events) serialized as JSON in the\n * data field\n *\n * The pusher event may contain a data field too, and it may also be\n * serialised as JSON\n *\n * Throws errors when messages are not parse'able.\n *\n * @param {MessageEvent} messageEvent\n * @return {PusherEvent}\n */\n decodeMessage: function(messageEvent: MessageEvent): PusherEvent {\n try {\n var messageData = JSON.parse(messageEvent.data);\n var pusherEventData = messageData.data;\n if (typeof pusherEventData === 'string') {\n try {\n pusherEventData = JSON.parse(messageData.data);\n } catch (e) {}\n }\n var pusherEvent: PusherEvent = {\n event: messageData.event,\n channel: messageData.channel,\n data: pusherEventData\n };\n if (messageData.user_id) {\n pusherEvent.user_id = messageData.user_id;\n }\n return pusherEvent;\n } catch (e) {\n throw { type: 'MessageParseError', error: e, data: messageEvent.data };\n }\n },\n\n /**\n * Encodes a message to be sent.\n *\n * @param {PusherEvent} event\n * @return {String}\n */\n encodeMessage: function(event: PusherEvent): string {\n return JSON.stringify(event);\n },\n\n /**\n * Processes a handshake message and returns appropriate actions.\n *\n * Returns an object with an 'action' and other action-specific properties.\n *\n * There are three outcomes when calling this function. First is a successful\n * connection attempt, when pusher:connection_established is received, which\n * results in a 'connected' action with an 'id' property. When passed a\n * pusher:error event, it returns a result with action appropriate to the\n * close code and an error. Otherwise, it raises an exception.\n *\n * @param {String} message\n * @result Object\n */\n processHandshake: function(messageEvent: MessageEvent): Action {\n var message = Protocol.decodeMessage(messageEvent);\n\n if (message.event === 'pusher:connection_established') {\n if (!message.data.activity_timeout) {\n throw 'No activity timeout specified in handshake';\n }\n return {\n action: 'connected',\n id: message.data.socket_id,\n activityTimeout: message.data.activity_timeout * 1000\n };\n } else if (message.event === 'pusher:error') {\n // From protocol 6 close codes are sent only once, so this only\n // happens when connection does not support close codes\n return {\n action: this.getCloseAction(message.data),\n error: this.getCloseError(message.data)\n };\n } else {\n throw 'Invalid handshake';\n }\n },\n\n /**\n * Dispatches the close event and returns an appropriate action name.\n *\n * See:\n * 1. https://developer.mozilla.org/en-US/docs/WebSockets/WebSockets_reference/CloseEvent\n * 2. http://pusher.com/docs/pusher_protocol\n *\n * @param {CloseEvent} closeEvent\n * @return {String} close action name\n */\n getCloseAction: function(closeEvent): string {\n if (closeEvent.code < 4000) {\n // ignore 1000 CLOSE_NORMAL, 1001 CLOSE_GOING_AWAY,\n // 1005 CLOSE_NO_STATUS, 1006 CLOSE_ABNORMAL\n // ignore 1007...3999\n // handle 1002 CLOSE_PROTOCOL_ERROR, 1003 CLOSE_UNSUPPORTED,\n // 1004 CLOSE_TOO_LARGE\n if (closeEvent.code >= 1002 && closeEvent.code <= 1004) {\n return 'backoff';\n } else {\n return null;\n }\n } else if (closeEvent.code === 4000) {\n return 'tls_only';\n } else if (closeEvent.code < 4100) {\n return 'refused';\n } else if (closeEvent.code < 4200) {\n return 'backoff';\n } else if (closeEvent.code < 4300) {\n return 'retry';\n } else {\n // unknown error\n return 'refused';\n }\n },\n\n /**\n * Returns an error or null basing on the close event.\n *\n * Null is returned when connection was closed cleanly. Otherwise, an object\n * with error details is returned.\n *\n * @param {CloseEvent} closeEvent\n * @return {Object} error object\n */\n getCloseError: function(closeEvent): any {\n if (closeEvent.code !== 1000 && closeEvent.code !== 1001) {\n return {\n type: 'PusherError',\n data: {\n code: closeEvent.code,\n message: closeEvent.reason || closeEvent.message\n }\n };\n } else {\n return null;\n }\n }\n};\n\nexport default Protocol;\n","import * as Collections from '../utils/collections';\nimport { default as EventsDispatcher } from '../events/dispatcher';\nimport Protocol from './protocol/protocol';\nimport { PusherEvent } from './protocol/message-types';\nimport Logger from '../logger';\nimport TransportConnection from '../transports/transport_connection';\nimport Socket from '../socket';\n/**\n * Provides Pusher protocol interface for transports.\n *\n * Emits following events:\n * - message - on received messages\n * - ping - on ping requests\n * - pong - on pong responses\n * - error - when the transport emits an error\n * - closed - after closing the transport\n *\n * It also emits more events when connection closes with a code.\n * See Protocol.getCloseAction to get more details.\n *\n * @param {Number} id\n * @param {AbstractTransport} transport\n */\nexport default class Connection extends EventsDispatcher implements Socket {\n id: string;\n transport: TransportConnection;\n activityTimeout: number;\n\n constructor(id: string, transport: TransportConnection) {\n super();\n this.id = id;\n this.transport = transport;\n this.activityTimeout = transport.activityTimeout;\n this.bindListeners();\n }\n\n /** Returns whether used transport handles activity checks by itself\n *\n * @returns {Boolean} true if activity checks are handled by the transport\n */\n handlesActivityChecks() {\n return this.transport.handlesActivityChecks();\n }\n\n /** Sends raw data.\n *\n * @param {String} data\n */\n send(data: any): boolean {\n return this.transport.send(data);\n }\n\n /** Sends an event.\n *\n * @param {String} name\n * @param {String} data\n * @param {String} [channel]\n * @returns {Boolean} whether message was sent or not\n */\n send_event(name: string, data: any, channel?: string): boolean {\n var event: PusherEvent = { event: name, data: data };\n if (channel) {\n event.channel = channel;\n }\n Logger.debug('Event sent', event);\n return this.send(Protocol.encodeMessage(event));\n }\n\n /** Sends a ping message to the server.\n *\n * Basing on the underlying transport, it might send either transport's\n * protocol-specific ping or pusher:ping event.\n */\n ping() {\n if (this.transport.supportsPing()) {\n this.transport.ping();\n } else {\n this.send_event('pusher:ping', {});\n }\n }\n\n /** Closes the connection. */\n close() {\n this.transport.close();\n }\n\n private bindListeners() {\n var listeners = {\n message: (messageEvent: MessageEvent) => {\n var pusherEvent;\n try {\n pusherEvent = Protocol.decodeMessage(messageEvent);\n } catch (e) {\n this.emit('error', {\n type: 'MessageParseError',\n error: e,\n data: messageEvent.data\n });\n }\n\n if (pusherEvent !== undefined) {\n Logger.debug('Event recd', pusherEvent);\n\n switch (pusherEvent.event) {\n case 'pusher:error':\n this.emit('error', {\n type: 'PusherError',\n data: pusherEvent.data\n });\n break;\n case 'pusher:ping':\n this.emit('ping');\n break;\n case 'pusher:pong':\n this.emit('pong');\n break;\n }\n this.emit('message', pusherEvent);\n }\n },\n activity: () => {\n this.emit('activity');\n },\n error: error => {\n this.emit('error', error);\n },\n closed: closeEvent => {\n unbindListeners();\n\n if (closeEvent && closeEvent.code) {\n this.handleCloseEvent(closeEvent);\n }\n\n this.transport = null;\n this.emit('closed');\n }\n };\n\n var unbindListeners = () => {\n Collections.objectApply(listeners, (listener, event) => {\n this.transport.unbind(event, listener);\n });\n };\n\n Collections.objectApply(listeners, (listener, event) => {\n this.transport.bind(event, listener);\n });\n }\n\n private handleCloseEvent(closeEvent: any) {\n var action = Protocol.getCloseAction(closeEvent);\n var error = Protocol.getCloseError(closeEvent);\n if (error) {\n this.emit('error', error);\n }\n if (action) {\n this.emit(action, { action: action, error: error });\n }\n }\n}\n","import Util from '../../util';\nimport * as Collections from '../../utils/collections';\nimport Protocol from '../protocol/protocol';\nimport Connection from '../connection';\nimport TransportConnection from '../../transports/transport_connection';\nimport HandshakePayload from './handshake_payload';\n\n/**\n * Handles Pusher protocol handshakes for transports.\n *\n * Calls back with a result object after handshake is completed. Results\n * always have two fields:\n * - action - string describing action to be taken after the handshake\n * - transport - the transport object passed to the constructor\n *\n * Different actions can set different additional properties on the result.\n * In the case of 'connected' action, there will be a 'connection' property\n * containing a Connection object for the transport. Other actions should\n * carry an 'error' property.\n *\n * @param {AbstractTransport} transport\n * @param {Function} callback\n */\nexport default class Handshake {\n transport: TransportConnection;\n callback: (HandshakePayload) => void;\n onMessage: Function;\n onClosed: Function;\n\n constructor(\n transport: TransportConnection,\n callback: (HandshakePayload) => void\n ) {\n this.transport = transport;\n this.callback = callback;\n this.bindListeners();\n }\n\n close() {\n this.unbindListeners();\n this.transport.close();\n }\n\n private bindListeners() {\n this.onMessage = m => {\n this.unbindListeners();\n\n var result;\n try {\n result = Protocol.processHandshake(m);\n } catch (e) {\n this.finish('error', { error: e });\n this.transport.close();\n return;\n }\n\n if (result.action === 'connected') {\n this.finish('connected', {\n connection: new Connection(result.id, this.transport),\n activityTimeout: result.activityTimeout\n });\n } else {\n this.finish(result.action, { error: result.error });\n this.transport.close();\n }\n };\n\n this.onClosed = closeEvent => {\n this.unbindListeners();\n\n var action = Protocol.getCloseAction(closeEvent) || 'backoff';\n var error = Protocol.getCloseError(closeEvent);\n this.finish(action, { error: error });\n };\n\n this.transport.bind('message', this.onMessage);\n this.transport.bind('closed', this.onClosed);\n }\n\n private unbindListeners() {\n this.transport.unbind('message', this.onMessage);\n this.transport.unbind('closed', this.onClosed);\n }\n\n private finish(action: string, params: any) {\n this.callback(\n Collections.extend({ transport: this.transport, action: action }, params)\n );\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport base64encode from '../base64';\nimport Timeline from './timeline';\nimport Runtime from 'runtime';\n\nexport interface TimelineSenderOptions {\n host?: string;\n port?: number;\n path?: string;\n}\n\nexport default class TimelineSender {\n timeline: Timeline;\n options: TimelineSenderOptions;\n host: string;\n\n constructor(timeline: Timeline, options: TimelineSenderOptions) {\n this.timeline = timeline;\n this.options = options || {};\n }\n\n send(useTLS: boolean, callback?: Function) {\n if (this.timeline.isEmpty()) {\n return;\n }\n\n this.timeline.send(\n Runtime.TimelineTransport.getAgent(this, useTLS),\n callback\n );\n }\n}\n","/** Error classes used throughout the library. */\n// https://github.com/Microsoft/TypeScript-wiki/blob/master/Breaking-Changes.md#extending-built-ins-like-error-array-and-map-may-no-longer-work\nexport class BadEventName extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\nexport class BadChannelName extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\nexport class RequestTimedOut extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class TransportPriorityTooLow extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class TransportClosed extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class UnsupportedFeature extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class UnsupportedTransport extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class UnsupportedStrategy extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class HTTPAuthError extends Error {\n status: number;\n constructor(status: number, msg?: string) {\n super(msg);\n this.status = status;\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n","/**\n * A place to store help URLs for error messages etc\n */\n\nconst urlStore = {\n baseUrl: 'https://pusher.com',\n urls: {\n authenticationEndpoint: {\n path: '/docs/channels/server_api/authenticating_users'\n },\n authorizationEndpoint: {\n path: '/docs/channels/server_api/authorizing-users/'\n },\n javascriptQuickStart: {\n path: '/docs/javascript_quick_start'\n },\n triggeringClientEvents: {\n path: '/docs/client_api_guide/client_events#trigger-events'\n },\n encryptedChannelSupport: {\n fullUrl:\n 'https://github.com/pusher/pusher-js/tree/cc491015371a4bde5743d1c87a0fbac0feb53195#encrypted-channel-support'\n }\n }\n};\n\n/** Builds a consistent string with links to pusher documentation\n *\n * @param {string} key - relevant key in the url_store.urls object\n * @return {string} suffix string to append to log message\n */\nconst buildLogSuffix = function(key: string): string {\n const urlPrefix = 'See:';\n const urlObj = urlStore.urls[key];\n if (!urlObj) return '';\n\n let url;\n if (urlObj.fullUrl) {\n url = urlObj.fullUrl;\n } else if (urlObj.path) {\n url = urlStore.baseUrl + urlObj.path;\n }\n\n if (!url) return '';\n return `${urlPrefix} ${url}`;\n};\n\nexport default { buildLogSuffix };\n","import { default as EventsDispatcher } from '../events/dispatcher';\nimport * as Errors from '../errors';\nimport Logger from '../logger';\nimport Pusher from '../pusher';\nimport { PusherEvent } from '../connection/protocol/message-types';\nimport Metadata from './metadata';\nimport UrlStore from '../utils/url_store';\nimport {\n ChannelAuthorizationData,\n ChannelAuthorizationCallback\n} from '../auth/options';\nimport { HTTPAuthError } from '../errors';\n\n/** Provides base public channel interface with an event emitter.\n *\n * Emits:\n * - pusher:subscription_succeeded - after subscribing successfully\n * - other non-internal events\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\nexport default class Channel extends EventsDispatcher {\n name: string;\n pusher: Pusher;\n subscribed: boolean;\n subscriptionPending: boolean;\n subscriptionCancelled: boolean;\n subscriptionCount: null;\n\n constructor(name: string, pusher: Pusher) {\n super(function(event, data) {\n Logger.debug('No callbacks on ' + name + ' for ' + event);\n });\n\n this.name = name;\n this.pusher = pusher;\n this.subscribed = false;\n this.subscriptionPending = false;\n this.subscriptionCancelled = false;\n }\n\n /** Skips authorization, since public channels don't require it.\n *\n * @param {Function} callback\n */\n authorize(socketId: string, callback: ChannelAuthorizationCallback) {\n return callback(null, { auth: '' });\n }\n\n /** Triggers an event */\n trigger(event: string, data: any) {\n if (event.indexOf('client-') !== 0) {\n throw new Errors.BadEventName(\n \"Event '\" + event + \"' does not start with 'client-'\"\n );\n }\n if (!this.subscribed) {\n var suffix = UrlStore.buildLogSuffix('triggeringClientEvents');\n Logger.warn(\n `Client event triggered before channel 'subscription_succeeded' event . ${suffix}`\n );\n }\n return this.pusher.send_event(event, data, this.name);\n }\n\n /** Signals disconnection to the channel. For internal use only. */\n disconnect() {\n this.subscribed = false;\n this.subscriptionPending = false;\n }\n\n /** Handles a PusherEvent. For internal use only.\n *\n * @param {PusherEvent} event\n */\n handleEvent(event: PusherEvent) {\n var eventName = event.event;\n var data = event.data;\n if (eventName === 'pusher_internal:subscription_succeeded') {\n this.handleSubscriptionSucceededEvent(event);\n } else if (eventName === 'pusher_internal:subscription_count') {\n this.handleSubscriptionCountEvent(event);\n } else if (eventName.indexOf('pusher_internal:') !== 0) {\n var metadata: Metadata = {};\n this.emit(eventName, data, metadata);\n }\n }\n\n handleSubscriptionSucceededEvent(event: PusherEvent) {\n this.subscriptionPending = false;\n this.subscribed = true;\n if (this.subscriptionCancelled) {\n this.pusher.unsubscribe(this.name);\n } else {\n this.emit('pusher:subscription_succeeded', event.data);\n }\n }\n\n handleSubscriptionCountEvent(event: PusherEvent) {\n if (event.data.subscription_count) {\n this.subscriptionCount = event.data.subscription_count;\n }\n\n this.emit('pusher:subscription_count', event.data);\n }\n\n /** Sends a subscription request. For internal use only. */\n subscribe() {\n if (this.subscribed) {\n return;\n }\n this.subscriptionPending = true;\n this.subscriptionCancelled = false;\n this.authorize(\n this.pusher.connection.socket_id,\n (error: Error | null, data: ChannelAuthorizationData) => {\n if (error) {\n this.subscriptionPending = false;\n // Why not bind to 'pusher:subscription_error' a level up, and log there?\n // Binding to this event would cause the warning about no callbacks being\n // bound (see constructor) to be suppressed, that's not what we want.\n Logger.error(error.toString());\n this.emit(\n 'pusher:subscription_error',\n Object.assign(\n {},\n {\n type: 'AuthError',\n error: error.message\n },\n error instanceof HTTPAuthError ? { status: error.status } : {}\n )\n );\n } else {\n this.pusher.send_event('pusher:subscribe', {\n auth: data.auth,\n channel_data: data.channel_data,\n channel: this.name\n });\n }\n }\n );\n }\n\n /** Sends an unsubscription request. For internal use only. */\n unsubscribe() {\n this.subscribed = false;\n this.pusher.send_event('pusher:unsubscribe', {\n channel: this.name\n });\n }\n\n /** Cancels an in progress subscription. For internal use only. */\n cancelSubscription() {\n this.subscriptionCancelled = true;\n }\n\n /** Reinstates an in progress subscripiton. For internal use only. */\n reinstateSubscription() {\n this.subscriptionCancelled = false;\n }\n}\n","import Factory from '../utils/factory';\nimport Channel from './channel';\nimport { ChannelAuthorizationCallback } from '../auth/options';\n\n/** Extends public channels to provide private channel interface.\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\nexport default class PrivateChannel extends Channel {\n /** Authorizes the connection to use the channel.\n *\n * @param {String} socketId\n * @param {Function} callback\n */\n authorize(socketId: string, callback: ChannelAuthorizationCallback) {\n return this.pusher.config.channelAuthorizer(\n {\n channelName: this.name,\n socketId: socketId\n },\n callback\n );\n }\n}\n","import * as Collections from '../utils/collections';\n\n/** Represents a collection of members of a presence channel. */\nexport default class Members {\n members: any;\n count: number;\n myID: any;\n me: any;\n\n constructor() {\n this.reset();\n }\n\n /** Returns member's info for given id.\n *\n * Resulting object containts two fields - id and info.\n *\n * @param {Number} id\n * @return {Object} member's info or null\n */\n get(id: string): any {\n if (Object.prototype.hasOwnProperty.call(this.members, id)) {\n return {\n id: id,\n info: this.members[id]\n };\n } else {\n return null;\n }\n }\n\n /** Calls back for each member in unspecified order.\n *\n * @param {Function} callback\n */\n each(callback: Function) {\n Collections.objectApply(this.members, (member, id) => {\n callback(this.get(id));\n });\n }\n\n /** Updates the id for connected member. For internal use only. */\n setMyID(id: string) {\n this.myID = id;\n }\n\n /** Handles subscription data. For internal use only. */\n onSubscription(subscriptionData: any) {\n this.members = subscriptionData.presence.hash;\n this.count = subscriptionData.presence.count;\n this.me = this.get(this.myID);\n }\n\n /** Adds a new member to the collection. For internal use only. */\n addMember(memberData: any) {\n if (this.get(memberData.user_id) === null) {\n this.count++;\n }\n this.members[memberData.user_id] = memberData.user_info;\n return this.get(memberData.user_id);\n }\n\n /** Adds a member from the collection. For internal use only. */\n removeMember(memberData: any) {\n var member = this.get(memberData.user_id);\n if (member) {\n delete this.members[memberData.user_id];\n this.count--;\n }\n return member;\n }\n\n /** Resets the collection to the initial state. For internal use only. */\n reset() {\n this.members = {};\n this.count = 0;\n this.myID = null;\n this.me = null;\n }\n}\n","import PrivateChannel from './private_channel';\nimport Logger from '../logger';\nimport Members from './members';\nimport Pusher from '../pusher';\nimport UrlStore from 'core/utils/url_store';\nimport { PusherEvent } from '../connection/protocol/message-types';\nimport Metadata from './metadata';\nimport { ChannelAuthorizationData } from '../auth/options';\n\nexport default class PresenceChannel extends PrivateChannel {\n members: Members;\n\n /** Adds presence channel functionality to private channels.\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\n constructor(name: string, pusher: Pusher) {\n super(name, pusher);\n this.members = new Members();\n }\n\n /** Authorizes the connection as a member of the channel.\n *\n * @param {String} socketId\n * @param {Function} callback\n */\n authorize(socketId: string, callback: Function) {\n super.authorize(socketId, async (error, authData) => {\n if (!error) {\n authData = authData as ChannelAuthorizationData;\n if (authData.channel_data != null) {\n var channelData = JSON.parse(authData.channel_data);\n this.members.setMyID(channelData.user_id);\n } else {\n await this.pusher.user.signinDonePromise;\n if (this.pusher.user.user_data != null) {\n // If the user is signed in, get the id of the authenticated user\n // and allow the presence authorization to continue.\n this.members.setMyID(this.pusher.user.user_data.id);\n } else {\n let suffix = UrlStore.buildLogSuffix('authorizationEndpoint');\n Logger.error(\n `Invalid auth response for channel '${this.name}', ` +\n `expected 'channel_data' field. ${suffix}, ` +\n `or the user should be signed in.`\n );\n callback('Invalid auth response');\n return;\n }\n }\n }\n callback(error, authData);\n });\n }\n\n /** Handles presence and subscription events. For internal use only.\n *\n * @param {PusherEvent} event\n */\n handleEvent(event: PusherEvent) {\n var eventName = event.event;\n if (eventName.indexOf('pusher_internal:') === 0) {\n this.handleInternalEvent(event);\n } else {\n var data = event.data;\n var metadata: Metadata = {};\n if (event.user_id) {\n metadata.user_id = event.user_id;\n }\n this.emit(eventName, data, metadata);\n }\n }\n handleInternalEvent(event: PusherEvent) {\n var eventName = event.event;\n var data = event.data;\n switch (eventName) {\n case 'pusher_internal:subscription_succeeded':\n this.handleSubscriptionSucceededEvent(event);\n break;\n case 'pusher_internal:subscription_count':\n this.handleSubscriptionCountEvent(event);\n break;\n case 'pusher_internal:member_added':\n var addedMember = this.members.addMember(data);\n this.emit('pusher:member_added', addedMember);\n break;\n case 'pusher_internal:member_removed':\n var removedMember = this.members.removeMember(data);\n if (removedMember) {\n this.emit('pusher:member_removed', removedMember);\n }\n break;\n }\n }\n\n handleSubscriptionSucceededEvent(event: PusherEvent) {\n this.subscriptionPending = false;\n this.subscribed = true;\n if (this.subscriptionCancelled) {\n this.pusher.unsubscribe(this.name);\n } else {\n this.members.onSubscription(event.data);\n this.emit('pusher:subscription_succeeded', this.members);\n }\n }\n\n /** Resets the channel state, including members map. For internal use only. */\n disconnect() {\n this.members.reset();\n super.disconnect();\n }\n}\n","import PrivateChannel from './private_channel';\nimport * as Errors from '../errors';\nimport Logger from '../logger';\nimport Pusher from '../pusher';\nimport { decode as encodeUTF8 } from '@stablelib/utf8';\nimport { decode as decodeBase64 } from '@stablelib/base64';\nimport Dispatcher from '../events/dispatcher';\nimport { PusherEvent } from '../connection/protocol/message-types';\nimport {\n ChannelAuthorizationData,\n ChannelAuthorizationCallback\n} from '../auth/options';\nimport * as nacl from 'tweetnacl';\n\n/** Extends private channels to provide encrypted channel interface.\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\nexport default class EncryptedChannel extends PrivateChannel {\n key: Uint8Array = null;\n nacl: nacl;\n\n constructor(name: string, pusher: Pusher, nacl: nacl) {\n super(name, pusher);\n this.nacl = nacl;\n }\n\n /** Authorizes the connection to use the channel.\n *\n * @param {String} socketId\n * @param {Function} callback\n */\n authorize(socketId: string, callback: ChannelAuthorizationCallback) {\n super.authorize(\n socketId,\n (error: Error | null, authData: ChannelAuthorizationData) => {\n if (error) {\n callback(error, authData);\n return;\n }\n let sharedSecret = authData['shared_secret'];\n if (!sharedSecret) {\n callback(\n new Error(\n `No shared_secret key in auth payload for encrypted channel: ${this.name}`\n ),\n null\n );\n return;\n }\n this.key = decodeBase64(sharedSecret);\n delete authData['shared_secret'];\n callback(null, authData);\n }\n );\n }\n\n trigger(event: string, data: any): boolean {\n throw new Errors.UnsupportedFeature(\n 'Client events are not currently supported for encrypted channels'\n );\n }\n\n /** Handles an event. For internal use only.\n *\n * @param {PusherEvent} event\n */\n handleEvent(event: PusherEvent) {\n var eventName = event.event;\n var data = event.data;\n if (\n eventName.indexOf('pusher_internal:') === 0 ||\n eventName.indexOf('pusher:') === 0\n ) {\n super.handleEvent(event);\n return;\n }\n this.handleEncryptedEvent(eventName, data);\n }\n\n private handleEncryptedEvent(event: string, data: any): void {\n if (!this.key) {\n Logger.debug(\n 'Received encrypted event before key has been retrieved from the authEndpoint'\n );\n return;\n }\n if (!data.ciphertext || !data.nonce) {\n Logger.error(\n 'Unexpected format for encrypted event, expected object with `ciphertext` and `nonce` fields, got: ' +\n data\n );\n return;\n }\n let cipherText = decodeBase64(data.ciphertext);\n if (cipherText.length < this.nacl.secretbox.overheadLength) {\n Logger.error(\n `Expected encrypted event ciphertext length to be ${this.nacl.secretbox.overheadLength}, got: ${cipherText.length}`\n );\n return;\n }\n let nonce = decodeBase64(data.nonce);\n if (nonce.length < this.nacl.secretbox.nonceLength) {\n Logger.error(\n `Expected encrypted event nonce length to be ${this.nacl.secretbox.nonceLength}, got: ${nonce.length}`\n );\n return;\n }\n\n let bytes = this.nacl.secretbox.open(cipherText, nonce, this.key);\n if (bytes === null) {\n Logger.debug(\n 'Failed to decrypt an event, probably because it was encrypted with a different key. Fetching a new key from the authEndpoint...'\n );\n // Try a single time to retrieve a new auth key and decrypt the event with it\n // If this fails, a new key will be requested when a new message is received\n this.authorize(this.pusher.connection.socket_id, (error, authData) => {\n if (error) {\n Logger.error(\n `Failed to make a request to the authEndpoint: ${authData}. Unable to fetch new key, so dropping encrypted event`\n );\n return;\n }\n bytes = this.nacl.secretbox.open(cipherText, nonce, this.key);\n if (bytes === null) {\n Logger.error(\n `Failed to decrypt event with new key. Dropping encrypted event`\n );\n return;\n }\n this.emit(event, this.getDataToEmit(bytes));\n return;\n });\n return;\n }\n this.emit(event, this.getDataToEmit(bytes));\n }\n\n // Try and parse the decrypted bytes as JSON. If we can't parse it, just\n // return the utf-8 string\n getDataToEmit(bytes: Uint8Array): string {\n let raw = encodeUTF8(bytes);\n try {\n return JSON.parse(raw);\n } catch {\n return raw;\n }\n }\n}\n","import { default as EventsDispatcher } from '../events/dispatcher';\nimport { OneOffTimer as Timer } from '../utils/timers';\nimport { Config } from '../config';\nimport Logger from '../logger';\nimport HandshakePayload from './handshake/handshake_payload';\nimport Connection from './connection';\nimport Strategy from '../strategies/strategy';\nimport StrategyRunner from '../strategies/strategy_runner';\nimport * as Collections from '../utils/collections';\nimport Timeline from '../timeline/timeline';\nimport ConnectionManagerOptions from './connection_manager_options';\nimport Runtime from 'runtime';\n\nimport {\n ErrorCallbacks,\n HandshakeCallbacks,\n ConnectionCallbacks\n} from './callbacks';\nimport Action from './protocol/action';\n\n/** Manages connection to Pusher.\n *\n * Uses a strategy (currently only default), timers and network availability\n * info to establish a connection and export its state. In case of failures,\n * manages reconnection attempts.\n *\n * Exports state changes as following events:\n * - \"state_change\", { previous: p, current: state }\n * - state\n *\n * States:\n * - initialized - initial state, never transitioned to\n * - connecting - connection is being established\n * - connected - connection has been fully established\n * - disconnected - on requested disconnection\n * - unavailable - after connection timeout or when there's no network\n * - failed - when the connection strategy is not supported\n *\n * Options:\n * - unavailableTimeout - time to transition to unavailable state\n * - activityTimeout - time after which ping message should be sent\n * - pongTimeout - time for Pusher to respond with pong before reconnecting\n *\n * @param {String} key application key\n * @param {Object} options\n */\nexport default class ConnectionManager extends EventsDispatcher {\n key: string;\n options: ConnectionManagerOptions;\n state: string;\n connection: Connection;\n usingTLS: boolean;\n timeline: Timeline;\n socket_id: string;\n unavailableTimer: Timer;\n activityTimer: Timer;\n retryTimer: Timer;\n activityTimeout: number;\n strategy: Strategy;\n runner: StrategyRunner;\n errorCallbacks: ErrorCallbacks;\n handshakeCallbacks: HandshakeCallbacks;\n connectionCallbacks: ConnectionCallbacks;\n\n constructor(key: string, options: ConnectionManagerOptions) {\n super();\n this.state = 'initialized';\n this.connection = null;\n\n this.key = key;\n this.options = options;\n this.timeline = this.options.timeline;\n this.usingTLS = this.options.useTLS;\n\n this.errorCallbacks = this.buildErrorCallbacks();\n this.connectionCallbacks = this.buildConnectionCallbacks(\n this.errorCallbacks\n );\n this.handshakeCallbacks = this.buildHandshakeCallbacks(this.errorCallbacks);\n\n var Network = Runtime.getNetwork();\n\n Network.bind('online', () => {\n this.timeline.info({ netinfo: 'online' });\n if (this.state === 'connecting' || this.state === 'unavailable') {\n this.retryIn(0);\n }\n });\n Network.bind('offline', () => {\n this.timeline.info({ netinfo: 'offline' });\n if (this.connection) {\n this.sendActivityCheck();\n }\n });\n\n this.updateStrategy();\n }\n\n /** Establishes a connection to Pusher.\n *\n * Does nothing when connection is already established. See top-level doc\n * to find events emitted on connection attempts.\n */\n connect() {\n if (this.connection || this.runner) {\n return;\n }\n if (!this.strategy.isSupported()) {\n this.updateState('failed');\n return;\n }\n this.updateState('connecting');\n this.startConnecting();\n this.setUnavailableTimer();\n }\n\n /** Sends raw data.\n *\n * @param {String} data\n */\n send(data) {\n if (this.connection) {\n return this.connection.send(data);\n } else {\n return false;\n }\n }\n\n /** Sends an event.\n *\n * @param {String} name\n * @param {String} data\n * @param {String} [channel]\n * @returns {Boolean} whether message was sent or not\n */\n send_event(name: string, data: any, channel?: string) {\n if (this.connection) {\n return this.connection.send_event(name, data, channel);\n } else {\n return false;\n }\n }\n\n /** Closes the connection. */\n disconnect() {\n this.disconnectInternally();\n this.updateState('disconnected');\n }\n\n isUsingTLS() {\n return this.usingTLS;\n }\n\n private startConnecting() {\n var callback = (error, handshake) => {\n if (error) {\n this.runner = this.strategy.connect(0, callback);\n } else {\n if (handshake.action === 'error') {\n this.emit('error', {\n type: 'HandshakeError',\n error: handshake.error\n });\n this.timeline.error({ handshakeError: handshake.error });\n } else {\n this.abortConnecting(); // we don't support switching connections yet\n this.handshakeCallbacks[handshake.action](handshake);\n }\n }\n };\n this.runner = this.strategy.connect(0, callback);\n }\n\n private abortConnecting() {\n if (this.runner) {\n this.runner.abort();\n this.runner = null;\n }\n }\n\n private disconnectInternally() {\n this.abortConnecting();\n this.clearRetryTimer();\n this.clearUnavailableTimer();\n if (this.connection) {\n var connection = this.abandonConnection();\n connection.close();\n }\n }\n\n private updateStrategy() {\n this.strategy = this.options.getStrategy({\n key: this.key,\n timeline: this.timeline,\n useTLS: this.usingTLS\n });\n }\n\n private retryIn(delay) {\n this.timeline.info({ action: 'retry', delay: delay });\n if (delay > 0) {\n this.emit('connecting_in', Math.round(delay / 1000));\n }\n this.retryTimer = new Timer(delay || 0, () => {\n this.disconnectInternally();\n this.connect();\n });\n }\n\n private clearRetryTimer() {\n if (this.retryTimer) {\n this.retryTimer.ensureAborted();\n this.retryTimer = null;\n }\n }\n\n private setUnavailableTimer() {\n this.unavailableTimer = new Timer(this.options.unavailableTimeout, () => {\n this.updateState('unavailable');\n });\n }\n\n private clearUnavailableTimer() {\n if (this.unavailableTimer) {\n this.unavailableTimer.ensureAborted();\n }\n }\n\n private sendActivityCheck() {\n this.stopActivityCheck();\n this.connection.ping();\n // wait for pong response\n this.activityTimer = new Timer(this.options.pongTimeout, () => {\n this.timeline.error({ pong_timed_out: this.options.pongTimeout });\n this.retryIn(0);\n });\n }\n\n private resetActivityCheck() {\n this.stopActivityCheck();\n // send ping after inactivity\n if (this.connection && !this.connection.handlesActivityChecks()) {\n this.activityTimer = new Timer(this.activityTimeout, () => {\n this.sendActivityCheck();\n });\n }\n }\n\n private stopActivityCheck() {\n if (this.activityTimer) {\n this.activityTimer.ensureAborted();\n }\n }\n\n private buildConnectionCallbacks(\n errorCallbacks: ErrorCallbacks\n ): ConnectionCallbacks {\n return Collections.extend({}, errorCallbacks, {\n message: message => {\n // includes pong messages from server\n this.resetActivityCheck();\n this.emit('message', message);\n },\n ping: () => {\n this.send_event('pusher:pong', {});\n },\n activity: () => {\n this.resetActivityCheck();\n },\n error: error => {\n // just emit error to user - socket will already be closed by browser\n this.emit('error', error);\n },\n closed: () => {\n this.abandonConnection();\n if (this.shouldRetry()) {\n this.retryIn(1000);\n }\n }\n });\n }\n\n private buildHandshakeCallbacks(\n errorCallbacks: ErrorCallbacks\n ): HandshakeCallbacks {\n return Collections.extend({}, errorCallbacks, {\n connected: (handshake: HandshakePayload) => {\n this.activityTimeout = Math.min(\n this.options.activityTimeout,\n handshake.activityTimeout,\n handshake.connection.activityTimeout || Infinity\n );\n this.clearUnavailableTimer();\n this.setConnection(handshake.connection);\n this.socket_id = this.connection.id;\n this.updateState('connected', { socket_id: this.socket_id });\n }\n });\n }\n\n private buildErrorCallbacks(): ErrorCallbacks {\n let withErrorEmitted = callback => {\n return (result: Action | HandshakePayload) => {\n if (result.error) {\n this.emit('error', { type: 'WebSocketError', error: result.error });\n }\n callback(result);\n };\n };\n\n return {\n tls_only: withErrorEmitted(() => {\n this.usingTLS = true;\n this.updateStrategy();\n this.retryIn(0);\n }),\n refused: withErrorEmitted(() => {\n this.disconnect();\n }),\n backoff: withErrorEmitted(() => {\n this.retryIn(1000);\n }),\n retry: withErrorEmitted(() => {\n this.retryIn(0);\n })\n };\n }\n\n private setConnection(connection) {\n this.connection = connection;\n for (var event in this.connectionCallbacks) {\n this.connection.bind(event, this.connectionCallbacks[event]);\n }\n this.resetActivityCheck();\n }\n\n private abandonConnection() {\n if (!this.connection) {\n return;\n }\n this.stopActivityCheck();\n for (var event in this.connectionCallbacks) {\n this.connection.unbind(event, this.connectionCallbacks[event]);\n }\n var connection = this.connection;\n this.connection = null;\n return connection;\n }\n\n private updateState(newState: string, data?: any) {\n var previousState = this.state;\n this.state = newState;\n if (previousState !== newState) {\n var newStateDescription = newState;\n if (newStateDescription === 'connected') {\n newStateDescription += ' with new socket ID ' + data.socket_id;\n }\n Logger.debug(\n 'State changed',\n previousState + ' -> ' + newStateDescription\n );\n this.timeline.info({ state: newState, params: data });\n this.emit('state_change', { previous: previousState, current: newState });\n this.emit(newState, data);\n }\n }\n\n private shouldRetry(): boolean {\n return this.state === 'connecting' || this.state === 'connected';\n }\n}\n","import Channel from './channel';\nimport * as Collections from '../utils/collections';\nimport ChannelTable from './channel_table';\nimport Factory from '../utils/factory';\nimport Pusher from '../pusher';\nimport Logger from '../logger';\nimport * as Errors from '../errors';\nimport urlStore from '../utils/url_store';\n\n/** Handles a channel map. */\nexport default class Channels {\n channels: ChannelTable;\n\n constructor() {\n this.channels = {};\n }\n\n /** Creates or retrieves an existing channel by its name.\n *\n * @param {String} name\n * @param {Pusher} pusher\n * @return {Channel}\n */\n add(name: string, pusher: Pusher) {\n if (!this.channels[name]) {\n this.channels[name] = createChannel(name, pusher);\n }\n return this.channels[name];\n }\n\n /** Returns a list of all channels\n *\n * @return {Array}\n */\n all(): Channel[] {\n return Collections.values(this.channels);\n }\n\n /** Finds a channel by its name.\n *\n * @param {String} name\n * @return {Channel} channel or null if it doesn't exist\n */\n find(name: string) {\n return this.channels[name];\n }\n\n /** Removes a channel from the map.\n *\n * @param {String} name\n */\n remove(name: string) {\n var channel = this.channels[name];\n delete this.channels[name];\n return channel;\n }\n\n /** Proxies disconnection signal to all channels. */\n disconnect() {\n Collections.objectApply(this.channels, function(channel) {\n channel.disconnect();\n });\n }\n}\n\nfunction createChannel(name: string, pusher: Pusher): Channel {\n if (name.indexOf('private-encrypted-') === 0) {\n if (pusher.config.nacl) {\n return Factory.createEncryptedChannel(name, pusher, pusher.config.nacl);\n }\n let errMsg =\n 'Tried to subscribe to a private-encrypted- channel but no nacl implementation available';\n let suffix = urlStore.buildLogSuffix('encryptedChannelSupport');\n throw new Errors.UnsupportedFeature(`${errMsg}. ${suffix}`);\n } else if (name.indexOf('private-') === 0) {\n return Factory.createPrivateChannel(name, pusher);\n } else if (name.indexOf('presence-') === 0) {\n return Factory.createPresenceChannel(name, pusher);\n } else if (name.indexOf('#') === 0) {\n throw new Errors.BadChannelName(\n 'Cannot create a channel with name \"' + name + '\".'\n );\n } else {\n return Factory.createChannel(name, pusher);\n }\n}\n","import AssistantToTheTransportManager from '../transports/assistant_to_the_transport_manager';\nimport PingDelayOptions from '../transports/ping_delay_options';\nimport Transport from '../transports/transport';\nimport TransportManager from '../transports/transport_manager';\nimport Handshake from '../connection/handshake';\nimport TransportConnection from '../transports/transport_connection';\nimport SocketHooks from '../http/socket_hooks';\nimport HTTPSocket from '../http/http_socket';\n\nimport Timeline from '../timeline/timeline';\nimport {\n default as TimelineSender,\n TimelineSenderOptions\n} from '../timeline/timeline_sender';\nimport PresenceChannel from '../channels/presence_channel';\nimport PrivateChannel from '../channels/private_channel';\nimport EncryptedChannel from '../channels/encrypted_channel';\nimport Channel from '../channels/channel';\nimport ConnectionManager from '../connection/connection_manager';\nimport ConnectionManagerOptions from '../connection/connection_manager_options';\nimport Ajax from '../http/ajax';\nimport Channels from '../channels/channels';\nimport Pusher from '../pusher';\nimport { Config } from '../config';\nimport * as nacl from 'tweetnacl';\n\nvar Factory = {\n createChannels(): Channels {\n return new Channels();\n },\n\n createConnectionManager(\n key: string,\n options: ConnectionManagerOptions\n ): ConnectionManager {\n return new ConnectionManager(key, options);\n },\n\n createChannel(name: string, pusher: Pusher): Channel {\n return new Channel(name, pusher);\n },\n\n createPrivateChannel(name: string, pusher: Pusher): PrivateChannel {\n return new PrivateChannel(name, pusher);\n },\n\n createPresenceChannel(name: string, pusher: Pusher): PresenceChannel {\n return new PresenceChannel(name, pusher);\n },\n\n createEncryptedChannel(\n name: string,\n pusher: Pusher,\n nacl: nacl\n ): EncryptedChannel {\n return new EncryptedChannel(name, pusher, nacl);\n },\n\n createTimelineSender(timeline: Timeline, options: TimelineSenderOptions) {\n return new TimelineSender(timeline, options);\n },\n\n createHandshake(\n transport: TransportConnection,\n callback: (HandshakePayload) => void\n ): Handshake {\n return new Handshake(transport, callback);\n },\n\n createAssistantToTheTransportManager(\n manager: TransportManager,\n transport: Transport,\n options: PingDelayOptions\n ): AssistantToTheTransportManager {\n return new AssistantToTheTransportManager(manager, transport, options);\n }\n};\n\nexport default Factory;\n","import AssistantToTheTransportManager from './assistant_to_the_transport_manager';\nimport Transport from './transport';\nimport PingDelayOptions from './ping_delay_options';\nimport Factory from '../utils/factory';\n\nexport interface TransportManagerOptions extends PingDelayOptions {\n lives?: number;\n}\n\n/** Keeps track of the number of lives left for a transport.\n *\n * In the beginning of a session, transports may be assigned a number of\n * lives. When an AssistantToTheTransportManager instance reports a transport\n * connection closed uncleanly, the transport loses a life. When the number\n * of lives drops to zero, the transport gets disabled by its manager.\n *\n * @param {Object} options\n */\nexport default class TransportManager {\n options: TransportManagerOptions;\n livesLeft: number;\n\n constructor(options: TransportManagerOptions) {\n this.options = options || {};\n this.livesLeft = this.options.lives || Infinity;\n }\n\n /** Creates a assistant for the transport.\n *\n * @param {Transport} transport\n * @returns {AssistantToTheTransportManager}\n */\n getAssistant(transport: Transport): AssistantToTheTransportManager {\n return Factory.createAssistantToTheTransportManager(this, transport, {\n minPingDelay: this.options.minPingDelay,\n maxPingDelay: this.options.maxPingDelay\n });\n }\n\n /** Returns whether the transport has any lives left.\n *\n * @returns {Boolean}\n */\n isAlive(): boolean {\n return this.livesLeft > 0;\n }\n\n /** Takes one life from the transport. */\n reportDeath() {\n this.livesLeft -= 1;\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport { OneOffTimer as Timer } from '../utils/timers';\nimport Strategy from './strategy';\nimport StrategyOptions from './strategy_options';\n\n/** Loops through strategies with optional timeouts.\n *\n * Options:\n * - loop - whether it should loop through the substrategy list\n * - timeout - initial timeout for a single substrategy\n * - timeoutLimit - maximum timeout\n *\n * @param {Strategy[]} strategies\n * @param {Object} options\n */\nexport default class SequentialStrategy implements Strategy {\n strategies: Strategy[];\n loop: boolean;\n failFast: boolean;\n timeout: number;\n timeoutLimit: number;\n\n constructor(strategies: Strategy[], options: StrategyOptions) {\n this.strategies = strategies;\n this.loop = Boolean(options.loop);\n this.failFast = Boolean(options.failFast);\n this.timeout = options.timeout;\n this.timeoutLimit = options.timeoutLimit;\n }\n\n isSupported(): boolean {\n return Collections.any(this.strategies, Util.method('isSupported'));\n }\n\n connect(minPriority: number, callback: Function) {\n var strategies = this.strategies;\n var current = 0;\n var timeout = this.timeout;\n var runner = null;\n\n var tryNextStrategy = (error, handshake) => {\n if (handshake) {\n callback(null, handshake);\n } else {\n current = current + 1;\n if (this.loop) {\n current = current % strategies.length;\n }\n\n if (current < strategies.length) {\n if (timeout) {\n timeout = timeout * 2;\n if (this.timeoutLimit) {\n timeout = Math.min(timeout, this.timeoutLimit);\n }\n }\n runner = this.tryStrategy(\n strategies[current],\n minPriority,\n { timeout, failFast: this.failFast },\n tryNextStrategy\n );\n } else {\n callback(true);\n }\n }\n };\n\n runner = this.tryStrategy(\n strategies[current],\n minPriority,\n { timeout: timeout, failFast: this.failFast },\n tryNextStrategy\n );\n\n return {\n abort: function() {\n runner.abort();\n },\n forceMinPriority: function(p) {\n minPriority = p;\n if (runner) {\n runner.forceMinPriority(p);\n }\n }\n };\n }\n\n private tryStrategy(\n strategy: Strategy,\n minPriority: number,\n options: StrategyOptions,\n callback: Function\n ) {\n var timer = null;\n var runner = null;\n\n if (options.timeout > 0) {\n timer = new Timer(options.timeout, function() {\n runner.abort();\n callback(true);\n });\n }\n\n runner = strategy.connect(minPriority, function(error, handshake) {\n if (error && timer && timer.isRunning() && !options.failFast) {\n // advance to the next strategy after the timeout\n return;\n }\n if (timer) {\n timer.ensureAborted();\n }\n callback(error, handshake);\n });\n\n return {\n abort: function() {\n if (timer) {\n timer.ensureAborted();\n }\n runner.abort();\n },\n forceMinPriority: function(p) {\n runner.forceMinPriority(p);\n }\n };\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport Strategy from './strategy';\n\n/** Launches all substrategies and emits prioritized connected transports.\n *\n * @param {Array} strategies\n */\nexport default class BestConnectedEverStrategy implements Strategy {\n strategies: Strategy[];\n\n constructor(strategies: Strategy[]) {\n this.strategies = strategies;\n }\n\n isSupported(): boolean {\n return Collections.any(this.strategies, Util.method('isSupported'));\n }\n\n connect(minPriority: number, callback: Function) {\n return connect(this.strategies, minPriority, function(i, runners) {\n return function(error, handshake) {\n runners[i].error = error;\n if (error) {\n if (allRunnersFailed(runners)) {\n callback(true);\n }\n return;\n }\n Collections.apply(runners, function(runner) {\n runner.forceMinPriority(handshake.transport.priority);\n });\n callback(null, handshake);\n };\n });\n }\n}\n\n/** Connects to all strategies in parallel.\n *\n * Callback builder should be a function that takes two arguments: index\n * and a list of runners. It should return another function that will be\n * passed to the substrategy with given index. Runners can be aborted using\n * abortRunner(s) functions from this class.\n *\n * @param {Array} strategies\n * @param {Function} callbackBuilder\n * @return {Object} strategy runner\n */\nfunction connect(\n strategies: Strategy[],\n minPriority: number,\n callbackBuilder: Function\n) {\n var runners = Collections.map(strategies, function(strategy, i, _, rs) {\n return strategy.connect(minPriority, callbackBuilder(i, rs));\n });\n return {\n abort: function() {\n Collections.apply(runners, abortRunner);\n },\n forceMinPriority: function(p) {\n Collections.apply(runners, function(runner) {\n runner.forceMinPriority(p);\n });\n }\n };\n}\n\nfunction allRunnersFailed(runners): boolean {\n return Collections.all(runners, function(runner) {\n return Boolean(runner.error);\n });\n}\n\nfunction abortRunner(runner) {\n if (!runner.error && !runner.aborted) {\n runner.abort();\n runner.aborted = true;\n }\n}\n","import Util from '../util';\nimport Runtime from 'runtime';\nimport Strategy from './strategy';\nimport SequentialStrategy from './sequential_strategy';\nimport StrategyOptions from './strategy_options';\nimport TransportStrategy from './transport_strategy';\nimport Timeline from '../timeline/timeline';\nimport * as Collections from '../utils/collections';\n\nexport interface TransportStrategyDictionary {\n [key: string]: TransportStrategy;\n}\n\n/** Caches the last successful transport and, after the first few attempts,\n * uses the cached transport for subsequent attempts.\n *\n * @param {Strategy} strategy\n * @param {Object} transports\n * @param {Object} options\n */\nexport default class WebSocketPrioritizedCachedStrategy implements Strategy {\n strategy: Strategy;\n transports: TransportStrategyDictionary;\n ttl: number;\n usingTLS: boolean;\n timeline: Timeline;\n\n constructor(\n strategy: Strategy,\n transports: TransportStrategyDictionary,\n options: StrategyOptions\n ) {\n this.strategy = strategy;\n this.transports = transports;\n this.ttl = options.ttl || 1800 * 1000;\n this.usingTLS = options.useTLS;\n this.timeline = options.timeline;\n }\n\n isSupported(): boolean {\n return this.strategy.isSupported();\n }\n\n connect(minPriority: number, callback: Function) {\n var usingTLS = this.usingTLS;\n var info = fetchTransportCache(usingTLS);\n var cacheSkipCount = info && info.cacheSkipCount ? info.cacheSkipCount : 0;\n\n var strategies = [this.strategy];\n if (info && info.timestamp + this.ttl >= Util.now()) {\n var transport = this.transports[info.transport];\n if (transport) {\n if (['ws', 'wss'].includes(info.transport) || cacheSkipCount > 3) {\n this.timeline.info({\n cached: true,\n transport: info.transport,\n latency: info.latency\n });\n strategies.push(\n new SequentialStrategy([transport], {\n timeout: info.latency * 2 + 1000,\n failFast: true\n })\n );\n } else {\n cacheSkipCount++;\n }\n }\n }\n\n var startTimestamp = Util.now();\n var runner = strategies\n .pop()\n .connect(minPriority, function cb(error, handshake) {\n if (error) {\n flushTransportCache(usingTLS);\n if (strategies.length > 0) {\n startTimestamp = Util.now();\n runner = strategies.pop().connect(minPriority, cb);\n } else {\n callback(error);\n }\n } else {\n storeTransportCache(\n usingTLS,\n handshake.transport.name,\n Util.now() - startTimestamp,\n cacheSkipCount\n );\n callback(null, handshake);\n }\n });\n\n return {\n abort: function() {\n runner.abort();\n },\n forceMinPriority: function(p) {\n minPriority = p;\n if (runner) {\n runner.forceMinPriority(p);\n }\n }\n };\n }\n}\n\nfunction getTransportCacheKey(usingTLS: boolean): string {\n return 'pusherTransport' + (usingTLS ? 'TLS' : 'NonTLS');\n}\n\nfunction fetchTransportCache(usingTLS: boolean): any {\n var storage = Runtime.getLocalStorage();\n if (storage) {\n try {\n var serializedCache = storage[getTransportCacheKey(usingTLS)];\n if (serializedCache) {\n return JSON.parse(serializedCache);\n }\n } catch (e) {\n flushTransportCache(usingTLS);\n }\n }\n return null;\n}\n\nfunction storeTransportCache(\n usingTLS: boolean,\n transport: TransportStrategy,\n latency: number,\n cacheSkipCount: number\n) {\n var storage = Runtime.getLocalStorage();\n if (storage) {\n try {\n storage[getTransportCacheKey(usingTLS)] = Collections.safeJSONStringify({\n timestamp: Util.now(),\n transport: transport,\n latency: latency,\n cacheSkipCount: cacheSkipCount\n });\n } catch (e) {\n // catch over quota exceptions raised by localStorage\n }\n }\n}\n\nfunction flushTransportCache(usingTLS: boolean) {\n var storage = Runtime.getLocalStorage();\n if (storage) {\n try {\n delete storage[getTransportCacheKey(usingTLS)];\n } catch (e) {\n // catch exceptions raised by localStorage\n }\n }\n}\n","import { OneOffTimer as Timer } from '../utils/timers';\nimport Strategy from './strategy';\nimport StrategyOptions from './strategy_options';\n\n/** Runs substrategy after specified delay.\n *\n * Options:\n * - delay - time in miliseconds to delay the substrategy attempt\n *\n * @param {Strategy} strategy\n * @param {Object} options\n */\nexport default class DelayedStrategy implements Strategy {\n strategy: Strategy;\n options: { delay: number };\n\n constructor(strategy: Strategy, { delay: number }) {\n this.strategy = strategy;\n this.options = { delay: number };\n }\n\n isSupported(): boolean {\n return this.strategy.isSupported();\n }\n\n connect(minPriority: number, callback: Function) {\n var strategy = this.strategy;\n var runner;\n var timer = new Timer(this.options.delay, function() {\n runner = strategy.connect(minPriority, callback);\n });\n\n return {\n abort: function() {\n timer.ensureAborted();\n if (runner) {\n runner.abort();\n }\n },\n forceMinPriority: function(p) {\n minPriority = p;\n if (runner) {\n runner.forceMinPriority(p);\n }\n }\n };\n }\n}\n","import Strategy from './strategy';\nimport StrategyRunner from './strategy_runner';\n\n/** Proxies method calls to one of substrategies basing on the test function.\n *\n * @param {Function} test\n * @param {Strategy} trueBranch strategy used when test returns true\n * @param {Strategy} falseBranch strategy used when test returns false\n */\nexport default class IfStrategy implements Strategy {\n test: () => boolean;\n trueBranch: Strategy;\n falseBranch: Strategy;\n\n constructor(\n test: () => boolean,\n trueBranch: Strategy,\n falseBranch: Strategy\n ) {\n this.test = test;\n this.trueBranch = trueBranch;\n this.falseBranch = falseBranch;\n }\n\n isSupported(): boolean {\n var branch = this.test() ? this.trueBranch : this.falseBranch;\n return branch.isSupported();\n }\n\n connect(minPriority: number, callback: Function): StrategyRunner {\n var branch = this.test() ? this.trueBranch : this.falseBranch;\n return branch.connect(minPriority, callback);\n }\n}\n","import Strategy from './strategy';\nimport StrategyRunner from './strategy_runner';\n\n/** Launches the substrategy and terminates on the first open connection.\n *\n * @param {Strategy} strategy\n */\nexport default class FirstConnectedStrategy implements Strategy {\n strategy: Strategy;\n\n constructor(strategy: Strategy) {\n this.strategy = strategy;\n }\n\n isSupported(): boolean {\n return this.strategy.isSupported();\n }\n\n connect(minPriority: number, callback: Function): StrategyRunner {\n var runner = this.strategy.connect(minPriority, function(error, handshake) {\n if (handshake) {\n runner.abort();\n }\n callback(error, handshake);\n });\n return runner;\n }\n}\n","import * as Collections from 'core/utils/collections';\nimport TransportManager from 'core/transports/transport_manager';\nimport Strategy from 'core/strategies/strategy';\nimport SequentialStrategy from 'core/strategies/sequential_strategy';\nimport BestConnectedEverStrategy from 'core/strategies/best_connected_ever_strategy';\nimport WebSocketPrioritizedCachedStrategy, {\n TransportStrategyDictionary\n} from 'core/strategies/websocket_prioritized_cached_strategy';\nimport DelayedStrategy from 'core/strategies/delayed_strategy';\nimport IfStrategy from 'core/strategies/if_strategy';\nimport FirstConnectedStrategy from 'core/strategies/first_connected_strategy';\nimport { Config } from 'core/config';\nimport StrategyOptions from 'core/strategies/strategy_options';\n\nfunction testSupportsStrategy(strategy: Strategy) {\n return function() {\n return strategy.isSupported();\n };\n}\n\nvar getDefaultStrategy = function(\n config: Config,\n baseOptions: StrategyOptions,\n defineTransport: Function\n): Strategy {\n var definedTransports = {};\n\n function defineTransportStrategy(\n name: string,\n type: string,\n priority: number,\n options: StrategyOptions,\n manager?: TransportManager\n ) {\n var transport = defineTransport(\n config,\n name,\n type,\n priority,\n options,\n manager\n );\n\n definedTransports[name] = transport;\n\n return transport;\n }\n\n var ws_options: StrategyOptions = Object.assign({}, baseOptions, {\n hostNonTLS: config.wsHost + ':' + config.wsPort,\n hostTLS: config.wsHost + ':' + config.wssPort,\n httpPath: config.wsPath\n });\n var wss_options: StrategyOptions = Collections.extend({}, ws_options, {\n useTLS: true\n });\n var http_options: StrategyOptions = Object.assign({}, baseOptions, {\n hostNonTLS: config.httpHost + ':' + config.httpPort,\n hostTLS: config.httpHost + ':' + config.httpsPort,\n httpPath: config.httpPath\n });\n var timeouts = {\n loop: true,\n timeout: 15000,\n timeoutLimit: 60000\n };\n\n var ws_manager = new TransportManager({\n minPingDelay: 10000,\n maxPingDelay: config.activityTimeout\n });\n var streaming_manager = new TransportManager({\n lives: 2,\n minPingDelay: 10000,\n maxPingDelay: config.activityTimeout\n });\n\n var ws_transport = defineTransportStrategy(\n 'ws',\n 'ws',\n 3,\n ws_options,\n ws_manager\n );\n var wss_transport = defineTransportStrategy(\n 'wss',\n 'ws',\n 3,\n wss_options,\n ws_manager\n );\n var xhr_streaming_transport = defineTransportStrategy(\n 'xhr_streaming',\n 'xhr_streaming',\n 1,\n http_options,\n streaming_manager\n );\n var xhr_polling_transport = defineTransportStrategy(\n 'xhr_polling',\n 'xhr_polling',\n 1,\n http_options\n );\n\n var ws_loop = new SequentialStrategy([ws_transport], timeouts);\n var wss_loop = new SequentialStrategy([wss_transport], timeouts);\n var streaming_loop = new SequentialStrategy(\n [xhr_streaming_transport],\n timeouts\n );\n var polling_loop = new SequentialStrategy([xhr_polling_transport], timeouts);\n\n var http_loop = new SequentialStrategy(\n [\n new IfStrategy(\n testSupportsStrategy(streaming_loop),\n new BestConnectedEverStrategy([\n streaming_loop,\n new DelayedStrategy(polling_loop, { delay: 4000 })\n ]),\n polling_loop\n )\n ],\n timeouts\n );\n\n var wsStrategy;\n if (baseOptions.useTLS) {\n wsStrategy = new BestConnectedEverStrategy([\n ws_loop,\n new DelayedStrategy(http_loop, { delay: 2000 })\n ]);\n } else {\n wsStrategy = new BestConnectedEverStrategy([\n ws_loop,\n new DelayedStrategy(wss_loop, { delay: 2000 }),\n new DelayedStrategy(http_loop, { delay: 5000 })\n ]);\n }\n\n return new WebSocketPrioritizedCachedStrategy(\n new FirstConnectedStrategy(\n new IfStrategy(testSupportsStrategy(ws_transport), wsStrategy, http_loop)\n ),\n definedTransports,\n {\n ttl: 1800000,\n timeline: baseOptions.timeline,\n useTLS: baseOptions.useTLS\n }\n );\n};\n\nexport default getDefaultStrategy;\n","/** Initializes the transport.\n *\n * Fetches resources if needed and then transitions to initialized.\n */\nexport default function() {\n var self = this;\n\n self.timeline.info(\n self.buildTimelineMessage({\n transport: self.name + (self.options.useTLS ? 's' : '')\n })\n );\n\n if (self.hooks.isInitialized()) {\n self.changeState('initialized');\n } else {\n self.onClose();\n }\n}\n","import Runtime from 'runtime';\nimport RequestHooks from './request_hooks';\nimport Ajax from './ajax';\nimport { default as EventsDispatcher } from '../events/dispatcher';\n\nconst MAX_BUFFER_LENGTH = 256 * 1024;\n\nexport default class HTTPRequest extends EventsDispatcher {\n hooks: RequestHooks;\n method: string;\n url: string;\n position: number;\n xhr: Ajax;\n unloader: Function;\n\n constructor(hooks: RequestHooks, method: string, url: string) {\n super();\n this.hooks = hooks;\n this.method = method;\n this.url = url;\n }\n\n start(payload?: any) {\n this.position = 0;\n this.xhr = this.hooks.getRequest(this);\n\n this.unloader = () => {\n this.close();\n };\n Runtime.addUnloadListener(this.unloader);\n\n this.xhr.open(this.method, this.url, true);\n\n if (this.xhr.setRequestHeader) {\n this.xhr.setRequestHeader('Content-Type', 'application/json'); // ReactNative doesn't set this header by default.\n }\n this.xhr.send(payload);\n }\n\n close() {\n if (this.unloader) {\n Runtime.removeUnloadListener(this.unloader);\n this.unloader = null;\n }\n if (this.xhr) {\n this.hooks.abortRequest(this.xhr);\n this.xhr = null;\n }\n }\n\n onChunk(status: number, data: any) {\n while (true) {\n var chunk = this.advanceBuffer(data);\n if (chunk) {\n this.emit('chunk', { status: status, data: chunk });\n } else {\n break;\n }\n }\n if (this.isBufferTooLong(data)) {\n this.emit('buffer_too_long');\n }\n }\n\n private advanceBuffer(buffer: any[]): any {\n var unreadData = buffer.slice(this.position);\n var endOfLinePosition = unreadData.indexOf('\\n');\n\n if (endOfLinePosition !== -1) {\n this.position += endOfLinePosition + 1;\n return unreadData.slice(0, endOfLinePosition);\n } else {\n // chunk is not finished yet, don't move the buffer pointer\n return null;\n }\n }\n\n private isBufferTooLong(buffer: any): boolean {\n return this.position === buffer.length && buffer.length > MAX_BUFFER_LENGTH;\n }\n}\n","enum State {\n CONNECTING = 0,\n OPEN = 1,\n CLOSED = 3\n}\n\nexport default State;\n","import URLLocation from './url_location';\nimport State from './state';\nimport Socket from '../socket';\nimport SocketHooks from './socket_hooks';\nimport Util from '../util';\nimport Ajax from './ajax';\nimport HTTPRequest from './http_request';\nimport Runtime from 'runtime';\n\nvar autoIncrement = 1;\n\nclass HTTPSocket implements Socket {\n hooks: SocketHooks;\n session: string;\n location: URLLocation;\n readyState: State;\n stream: HTTPRequest;\n\n onopen: () => void;\n onerror: (error: any) => void;\n onclose: (closeEvent: any) => void;\n onmessage: (message: any) => void;\n onactivity: () => void;\n\n constructor(hooks: SocketHooks, url: string) {\n this.hooks = hooks;\n this.session = randomNumber(1000) + '/' + randomString(8);\n this.location = getLocation(url);\n this.readyState = State.CONNECTING;\n this.openStream();\n }\n\n send(payload: any) {\n return this.sendRaw(JSON.stringify([payload]));\n }\n\n ping() {\n this.hooks.sendHeartbeat(this);\n }\n\n close(code: any, reason: any) {\n this.onClose(code, reason, true);\n }\n\n /** For internal use only */\n sendRaw(payload: any): boolean {\n if (this.readyState === State.OPEN) {\n try {\n Runtime.createSocketRequest(\n 'POST',\n getUniqueURL(getSendURL(this.location, this.session))\n ).start(payload);\n return true;\n } catch (e) {\n return false;\n }\n } else {\n return false;\n }\n }\n\n /** For internal use only */\n reconnect() {\n this.closeStream();\n this.openStream();\n }\n\n /** For internal use only */\n onClose(code, reason, wasClean) {\n this.closeStream();\n this.readyState = State.CLOSED;\n if (this.onclose) {\n this.onclose({\n code: code,\n reason: reason,\n wasClean: wasClean\n });\n }\n }\n\n private onChunk(chunk) {\n if (chunk.status !== 200) {\n return;\n }\n if (this.readyState === State.OPEN) {\n this.onActivity();\n }\n\n var payload;\n var type = chunk.data.slice(0, 1);\n switch (type) {\n case 'o':\n payload = JSON.parse(chunk.data.slice(1) || '{}');\n this.onOpen(payload);\n break;\n case 'a':\n payload = JSON.parse(chunk.data.slice(1) || '[]');\n for (var i = 0; i < payload.length; i++) {\n this.onEvent(payload[i]);\n }\n break;\n case 'm':\n payload = JSON.parse(chunk.data.slice(1) || 'null');\n this.onEvent(payload);\n break;\n case 'h':\n this.hooks.onHeartbeat(this);\n break;\n case 'c':\n payload = JSON.parse(chunk.data.slice(1) || '[]');\n this.onClose(payload[0], payload[1], true);\n break;\n }\n }\n\n private onOpen(options) {\n if (this.readyState === State.CONNECTING) {\n if (options && options.hostname) {\n this.location.base = replaceHost(this.location.base, options.hostname);\n }\n this.readyState = State.OPEN;\n\n if (this.onopen) {\n this.onopen();\n }\n } else {\n this.onClose(1006, 'Server lost session', true);\n }\n }\n\n private onEvent(event) {\n if (this.readyState === State.OPEN && this.onmessage) {\n this.onmessage({ data: event });\n }\n }\n\n private onActivity() {\n if (this.onactivity) {\n this.onactivity();\n }\n }\n\n private onError(error) {\n if (this.onerror) {\n this.onerror(error);\n }\n }\n\n private openStream() {\n this.stream = Runtime.createSocketRequest(\n 'POST',\n getUniqueURL(this.hooks.getReceiveURL(this.location, this.session))\n );\n\n this.stream.bind('chunk', chunk => {\n this.onChunk(chunk);\n });\n this.stream.bind('finished', status => {\n this.hooks.onFinished(this, status);\n });\n this.stream.bind('buffer_too_long', () => {\n this.reconnect();\n });\n\n try {\n this.stream.start();\n } catch (error) {\n Util.defer(() => {\n this.onError(error);\n this.onClose(1006, 'Could not start streaming', false);\n });\n }\n }\n\n private closeStream() {\n if (this.stream) {\n this.stream.unbind_all();\n this.stream.close();\n this.stream = null;\n }\n }\n}\n\nfunction getLocation(url): URLLocation {\n var parts = /([^\\?]*)\\/*(\\??.*)/.exec(url);\n return {\n base: parts[1],\n queryString: parts[2]\n };\n}\n\nfunction getSendURL(url: URLLocation, session: string): string {\n return url.base + '/' + session + '/xhr_send';\n}\n\nfunction getUniqueURL(url: string): string {\n var separator = url.indexOf('?') === -1 ? '?' : '&';\n return url + separator + 't=' + +new Date() + '&n=' + autoIncrement++;\n}\n\nfunction replaceHost(url: string, hostname: string): string {\n var urlParts = /(https?:\\/\\/)([^\\/:]+)((\\/|:)?.*)/.exec(url);\n return urlParts[1] + hostname + urlParts[3];\n}\n\nfunction randomNumber(max: number): number {\n return Runtime.randomInt(max);\n}\n\nfunction randomString(length: number): string {\n var result = [];\n\n for (var i = 0; i < length; i++) {\n result.push(randomNumber(32).toString(32));\n }\n\n return result.join('');\n}\n\nexport default HTTPSocket;\n","import SocketHooks from './socket_hooks';\nimport HTTPSocket from './http_socket';\n\nvar hooks: SocketHooks = {\n getReceiveURL: function(url, session) {\n return url.base + '/' + session + '/xhr_streaming' + url.queryString;\n },\n onHeartbeat: function(socket) {\n socket.sendRaw('[]');\n },\n sendHeartbeat: function(socket) {\n socket.sendRaw('[]');\n },\n onFinished: function(socket, status) {\n socket.onClose(1006, 'Connection interrupted (' + status + ')', false);\n }\n};\n\nexport default hooks;\n","import SocketHooks from './socket_hooks';\nimport URLLocation from './url_location';\nimport HTTPSocket from './http_socket';\n\nvar hooks: SocketHooks = {\n getReceiveURL: function(url: URLLocation, session: string): string {\n return url.base + '/' + session + '/xhr' + url.queryString;\n },\n onHeartbeat: function() {\n // next HTTP request will reset server's activity timer\n },\n sendHeartbeat: function(socket) {\n socket.sendRaw('[]');\n },\n onFinished: function(socket, status) {\n if (status === 200) {\n socket.reconnect();\n } else {\n socket.onClose(1006, 'Connection interrupted (' + status + ')', false);\n }\n }\n};\n\nexport default hooks;\n","import HTTPRequest from 'core/http/http_request';\nimport RequestHooks from 'core/http/request_hooks';\nimport Ajax from 'core/http/ajax';\nimport Runtime from 'runtime';\n\nvar hooks: RequestHooks = {\n getRequest: function(socket: HTTPRequest): Ajax {\n var Constructor = Runtime.getXHRAPI();\n var xhr = new Constructor();\n xhr.onreadystatechange = xhr.onprogress = function() {\n switch (xhr.readyState) {\n case 3:\n if (xhr.responseText && xhr.responseText.length > 0) {\n socket.onChunk(xhr.status, xhr.responseText);\n }\n break;\n case 4:\n // this happens only on errors, never after calling close\n if (xhr.responseText && xhr.responseText.length > 0) {\n socket.onChunk(xhr.status, xhr.responseText);\n }\n socket.emit('finished', xhr.status);\n socket.close();\n break;\n }\n };\n return xhr;\n },\n abortRequest: function(xhr: Ajax) {\n xhr.onreadystatechange = null;\n xhr.abort();\n }\n};\n\nexport default hooks;\n","import HTTPRequest from 'core/http/http_request';\nimport HTTPSocket from 'core/http/http_socket';\nimport SocketHooks from 'core/http/socket_hooks';\nimport RequestHooks from 'core/http/request_hooks';\nimport streamingHooks from 'core/http/http_streaming_socket';\nimport pollingHooks from 'core/http/http_polling_socket';\nimport xhrHooks from './http_xhr_request';\nimport HTTPFactory from 'core/http/http_factory';\n\nvar HTTP: HTTPFactory = {\n createStreamingSocket(url: string): HTTPSocket {\n return this.createSocket(streamingHooks, url);\n },\n\n createPollingSocket(url: string): HTTPSocket {\n return this.createSocket(pollingHooks, url);\n },\n\n createSocket(hooks: SocketHooks, url: string): HTTPSocket {\n return new HTTPSocket(hooks, url);\n },\n\n createXHR(method: string, url: string): HTTPRequest {\n return this.createRequest(xhrHooks, method, url);\n },\n\n createRequest(hooks: RequestHooks, method: string, url: string): HTTPRequest {\n return new HTTPRequest(hooks, method, url);\n }\n};\n\nexport default HTTP;\n","import * as Collections from 'core/utils/collections';\nimport Transports from 'isomorphic/transports/transports';\nimport TimelineSender from 'core/timeline/timeline_sender';\nimport Ajax from 'core/http/ajax';\nimport getDefaultStrategy from './default_strategy';\nimport TransportsTable from 'core/transports/transports_table';\nimport transportConnectionInitializer from './transports/transport_connection_initializer';\nimport HTTPFactory from './http/http';\n\nvar Isomorphic: any = {\n getDefaultStrategy,\n Transports: Transports,\n transportConnectionInitializer,\n HTTPFactory,\n\n setup(PusherClass): void {\n PusherClass.ready();\n },\n\n getLocalStorage(): any {\n return undefined;\n },\n\n getClientFeatures(): any[] {\n return Collections.keys(\n Collections.filterObject({ ws: Transports.ws }, function(t) {\n return t.isSupported({});\n })\n );\n },\n\n getProtocol(): string {\n return 'http:';\n },\n\n isXHRSupported(): boolean {\n return true;\n },\n\n createSocketRequest(method: string, url: string) {\n if (this.isXHRSupported()) {\n return this.HTTPFactory.createXHR(method, url);\n } else {\n throw 'Cross-origin HTTP requests are not supported';\n }\n },\n\n createXHR(): Ajax {\n var Constructor = this.getXHRAPI();\n return new Constructor();\n },\n\n createWebSocket(url: string): any {\n var Constructor = this.getWebSocketAPI();\n return new Constructor(url);\n },\n\n addUnloadListener(listener: any) {},\n removeUnloadListener(listener: any) {}\n};\n\nexport default Isomorphic;\n","import { default as EventsDispatcher } from 'core/events/dispatcher';\nimport Reachability from 'core/reachability';\n\nexport class NetInfo extends EventsDispatcher implements Reachability {\n isOnline(): boolean {\n return true;\n }\n}\n\nexport var Network = new NetInfo();\n","import AbstractRuntime from 'runtimes/interface';\nimport { AuthTransport } from 'core/auth/auth_transports';\nimport {\n AuthRequestType,\n AuthTransportCallback,\n InternalAuthOptions\n} from 'core/auth/options';\nimport { HTTPAuthError } from 'core/errors';\n\nvar fetchAuth: AuthTransport = function(\n context: AbstractRuntime,\n query: string,\n authOptions: InternalAuthOptions,\n authRequestType: AuthRequestType,\n callback: AuthTransportCallback\n) {\n var headers = new Headers();\n headers.set('Content-Type', 'application/x-www-form-urlencoded');\n\n for (var headerName in authOptions.headers) {\n headers.set(headerName, authOptions.headers[headerName]);\n }\n\n if (authOptions.headersProvider != null) {\n const dynamicHeaders = authOptions.headersProvider();\n for (var headerName in dynamicHeaders) {\n headers.set(headerName, dynamicHeaders[headerName]);\n }\n }\n\n var body = query;\n var request = new Request(authOptions.endpoint, {\n headers,\n body,\n credentials: 'same-origin',\n method: 'POST'\n });\n\n return fetch(request)\n .then(response => {\n let { status } = response;\n if (status === 200) {\n // manually parse the json so we can provide a more helpful error in\n // failure case\n return response.text();\n }\n throw new HTTPAuthError(\n status,\n `Could not get ${authRequestType.toString()} info from your auth endpoint, status: ${status}`\n );\n })\n .then(data => {\n let parsedData;\n try {\n parsedData = JSON.parse(data);\n } catch (e) {\n throw new HTTPAuthError(\n 200,\n `JSON returned from ${authRequestType.toString()} endpoint was invalid, yet status code was 200. Data was: ${data}`\n );\n }\n callback(null, parsedData);\n })\n .catch(err => {\n callback(err, null);\n });\n};\n\nexport default fetchAuth;\n","import Logger from 'core/logger';\nimport TimelineSender from 'core/timeline/timeline_sender';\nimport * as Collections from 'core/utils/collections';\nimport Util from 'core/util';\nimport Runtime from 'runtime';\nimport TimelineTransport from 'core/timeline/timeline_transport';\n\nvar getAgent = function(sender: TimelineSender, useTLS: boolean) {\n return function(data: any, callback: Function) {\n var scheme = 'http' + (useTLS ? 's' : '') + '://';\n var url =\n scheme + (sender.host || sender.options.host) + sender.options.path;\n var query = Collections.buildQueryString(data);\n url += '/' + 2 + '?' + query;\n\n fetch(url)\n .then(response => {\n if (response.status !== 200) {\n throw `received ${response.status} from stats.pusher.com`;\n }\n return response.json();\n })\n .then(({ host }) => {\n if (host) {\n sender.host = host;\n }\n })\n .catch(err => {\n Logger.debug('TimelineSender Error: ', err);\n });\n };\n};\n\nvar fetchTimeline = {\n name: 'xhr',\n getAgent\n};\n\nexport default fetchTimeline;\n","import Isomorphic from 'isomorphic/runtime';\nimport Runtime from '../interface';\nimport { Network } from './net_info';\nimport fetchAuth from './auth/fetch_auth';\nimport { AuthTransports } from 'core/auth/auth_transports';\nimport fetchTimeline from './timeline/fetch_timeline';\n\n// Very verbose but until unavoidable until\n// TypeScript 2.1, when spread attributes will be\n// supported\nconst {\n getDefaultStrategy,\n Transports,\n setup,\n getProtocol,\n isXHRSupported,\n getLocalStorage,\n createXHR,\n createWebSocket,\n addUnloadListener,\n removeUnloadListener,\n transportConnectionInitializer,\n createSocketRequest,\n HTTPFactory\n} = Isomorphic;\n\nconst Worker: Runtime = {\n getDefaultStrategy,\n Transports,\n setup,\n getProtocol,\n isXHRSupported,\n getLocalStorage,\n createXHR,\n createWebSocket,\n addUnloadListener,\n removeUnloadListener,\n transportConnectionInitializer,\n createSocketRequest,\n HTTPFactory,\n\n TimelineTransport: fetchTimeline,\n\n getAuthorizers(): AuthTransports {\n return { ajax: fetchAuth };\n },\n\n getWebSocketAPI() {\n return WebSocket;\n },\n\n getXHRAPI() {\n return XMLHttpRequest;\n },\n\n getNetwork() {\n return Network;\n },\n\n randomInt(max: number): number {\n /**\n * Return values in the range of [0, 1[\n */\n const random = function() {\n const crypto = globalThis.crypto || globalThis['msCrypto'];\n const random = crypto.getRandomValues(new Uint32Array(1))[0];\n\n return random / 2 ** 32;\n };\n\n return Math.floor(random() * max);\n }\n};\n\nexport default Worker;\n","enum TimelineLevel {\n ERROR = 3,\n INFO = 6,\n DEBUG = 7\n}\n\nexport default TimelineLevel;\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport { default as Level } from './level';\n\nexport interface TimelineOptions {\n level?: Level;\n limit?: number;\n version?: string;\n cluster?: string;\n features?: string[];\n params?: any;\n}\n\nexport default class Timeline {\n key: string;\n session: number;\n events: any[];\n options: TimelineOptions;\n sent: number;\n uniqueID: number;\n\n constructor(key: string, session: number, options: TimelineOptions) {\n this.key = key;\n this.session = session;\n this.events = [];\n this.options = options || {};\n this.sent = 0;\n this.uniqueID = 0;\n }\n\n log(level, event) {\n if (level <= this.options.level) {\n this.events.push(\n Collections.extend({}, event, { timestamp: Util.now() })\n );\n if (this.options.limit && this.events.length > this.options.limit) {\n this.events.shift();\n }\n }\n }\n\n error(event) {\n this.log(Level.ERROR, event);\n }\n\n info(event) {\n this.log(Level.INFO, event);\n }\n\n debug(event) {\n this.log(Level.DEBUG, event);\n }\n\n isEmpty() {\n return this.events.length === 0;\n }\n\n send(sendfn, callback) {\n var data = Collections.extend(\n {\n session: this.session,\n bundle: this.sent + 1,\n key: this.key,\n lib: 'js',\n version: this.options.version,\n cluster: this.options.cluster,\n features: this.options.features,\n timeline: this.events\n },\n this.options.params\n );\n\n this.events = [];\n sendfn(data, (error, result) => {\n if (!error) {\n this.sent++;\n }\n if (callback) {\n callback(error, result);\n }\n });\n\n return true;\n }\n\n generateUniqueID(): number {\n this.uniqueID++;\n return this.uniqueID;\n }\n}\n","import Factory from '../utils/factory';\nimport Util from '../util';\nimport * as Errors from '../errors';\nimport * as Collections from '../utils/collections';\nimport Strategy from './strategy';\nimport Transport from '../transports/transport';\nimport StrategyOptions from './strategy_options';\nimport Handshake from '../connection/handshake';\n\n/** Provides a strategy interface for transports.\n *\n * @param {String} name\n * @param {Number} priority\n * @param {Class} transport\n * @param {Object} options\n */\nexport default class TransportStrategy implements Strategy {\n name: string;\n priority: number;\n transport: Transport;\n options: StrategyOptions;\n\n constructor(\n name: string,\n priority: number,\n transport: Transport,\n options: StrategyOptions\n ) {\n this.name = name;\n this.priority = priority;\n this.transport = transport;\n this.options = options || {};\n }\n\n /** Returns whether the transport is supported in the browser.\n *\n * @returns {Boolean}\n */\n isSupported(): boolean {\n return this.transport.isSupported({\n useTLS: this.options.useTLS\n });\n }\n\n /** Launches a connection attempt and returns a strategy runner.\n *\n * @param {Function} callback\n * @return {Object} strategy runner\n */\n connect(minPriority: number, callback: Function) {\n if (!this.isSupported()) {\n return failAttempt(new Errors.UnsupportedStrategy(), callback);\n } else if (this.priority < minPriority) {\n return failAttempt(new Errors.TransportPriorityTooLow(), callback);\n }\n\n var connected = false;\n var transport = this.transport.createConnection(\n this.name,\n this.priority,\n this.options.key,\n this.options\n );\n var handshake = null;\n\n var onInitialized = function() {\n transport.unbind('initialized', onInitialized);\n transport.connect();\n };\n var onOpen = function() {\n handshake = Factory.createHandshake(transport, function(result) {\n connected = true;\n unbindListeners();\n callback(null, result);\n });\n };\n var onError = function(error) {\n unbindListeners();\n callback(error);\n };\n var onClosed = function() {\n unbindListeners();\n var serializedTransport;\n\n // The reason for this try/catch block is that on React Native\n // the WebSocket object is circular. Therefore transport.socket will\n // throw errors upon stringification. Collections.safeJSONStringify\n // discards circular references when serializing.\n serializedTransport = Collections.safeJSONStringify(transport);\n callback(new Errors.TransportClosed(serializedTransport));\n };\n\n var unbindListeners = function() {\n transport.unbind('initialized', onInitialized);\n transport.unbind('open', onOpen);\n transport.unbind('error', onError);\n transport.unbind('closed', onClosed);\n };\n\n transport.bind('initialized', onInitialized);\n transport.bind('open', onOpen);\n transport.bind('error', onError);\n transport.bind('closed', onClosed);\n\n // connect will be called automatically after initialization\n transport.initialize();\n\n return {\n abort: () => {\n if (connected) {\n return;\n }\n unbindListeners();\n if (handshake) {\n handshake.close();\n } else {\n transport.close();\n }\n },\n forceMinPriority: p => {\n if (connected) {\n return;\n }\n if (this.priority < p) {\n if (handshake) {\n handshake.close();\n } else {\n transport.close();\n }\n }\n }\n };\n }\n}\n\nfunction failAttempt(error: Error, callback: Function) {\n Util.defer(function() {\n callback(error);\n });\n return {\n abort: function() {},\n forceMinPriority: function() {}\n };\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport TransportManager from '../transports/transport_manager';\nimport * as Errors from '../errors';\nimport Strategy from './strategy';\nimport TransportStrategy from './transport_strategy';\nimport StrategyOptions from '../strategies/strategy_options';\nimport { Config } from '../config';\nimport Runtime from 'runtime';\n\nconst { Transports } = Runtime;\n\nexport var defineTransport = function(\n config: Config,\n name: string,\n type: string,\n priority: number,\n options: StrategyOptions,\n manager?: TransportManager\n): Strategy {\n var transportClass = Transports[type];\n if (!transportClass) {\n throw new Errors.UnsupportedTransport(type);\n }\n\n var enabled =\n (!config.enabledTransports ||\n Collections.arrayIndexOf(config.enabledTransports, name) !== -1) &&\n (!config.disabledTransports ||\n Collections.arrayIndexOf(config.disabledTransports, name) === -1);\n\n var transport;\n if (enabled) {\n options = Object.assign(\n { ignoreNullOrigin: config.ignoreNullOrigin },\n options\n );\n\n transport = new TransportStrategy(\n name,\n priority,\n manager ? manager.getAssistant(transportClass) : transportClass,\n options\n );\n } else {\n transport = UnsupportedStrategy;\n }\n\n return transport;\n};\n\nvar UnsupportedStrategy: Strategy = {\n isSupported: function() {\n return false;\n },\n connect: function(_, callback) {\n var deferred = Util.defer(function() {\n callback(new Errors.UnsupportedStrategy());\n });\n return {\n abort: function() {\n deferred.ensureAborted();\n },\n forceMinPriority: function() {}\n };\n }\n};\n","import ConnectionManager from './connection/connection_manager';\nimport {\n ChannelAuthorizationOptions,\n UserAuthenticationOptions\n} from './auth/options';\nimport {\n ChannelAuthorizerGenerator,\n DeprecatedAuthOptions\n} from './auth/deprecated_channel_authorizer';\nimport { AuthTransport, Transport } from './config';\nimport * as nacl from 'tweetnacl';\nimport Logger from './logger';\n\nexport interface Options {\n activityTimeout?: number;\n\n auth?: DeprecatedAuthOptions; // DEPRECATED use channelAuthorization instead\n authEndpoint?: string; // DEPRECATED use channelAuthorization instead\n authTransport?: AuthTransport; // DEPRECATED use channelAuthorization instead\n authorizer?: ChannelAuthorizerGenerator; // DEPRECATED use channelAuthorization instead\n\n channelAuthorization?: ChannelAuthorizationOptions;\n userAuthentication?: UserAuthenticationOptions;\n\n cluster: string;\n enableStats?: boolean;\n disableStats?: boolean;\n disabledTransports?: Transport[];\n enabledTransports?: Transport[];\n forceTLS?: boolean;\n httpHost?: string;\n httpPath?: string;\n httpPort?: number;\n httpsPort?: number;\n ignoreNullOrigin?: boolean;\n nacl?: nacl;\n pongTimeout?: number;\n statsHost?: string;\n timelineParams?: any;\n unavailableTimeout?: number;\n wsHost?: string;\n wsPath?: string;\n wsPort?: number;\n wssPort?: number;\n}\n\nexport function validateOptions(options) {\n if (options == null) {\n throw 'You must pass an options object';\n }\n if (options.cluster == null) {\n throw 'Options object must provide a cluster';\n }\n if ('disableStats' in options) {\n Logger.warn(\n 'The disableStats option is deprecated in favor of enableStats'\n );\n }\n}\n","export enum AuthRequestType {\n UserAuthentication = 'user-authentication',\n ChannelAuthorization = 'channel-authorization'\n}\n\nexport interface ChannelAuthorizationData {\n auth: string;\n channel_data?: string;\n shared_secret?: string;\n}\n\nexport type ChannelAuthorizationCallback = (\n error: Error | null,\n authData: ChannelAuthorizationData | null\n) => void;\n\nexport interface ChannelAuthorizationRequestParams {\n socketId: string;\n channelName: string;\n}\n\nexport interface ChannelAuthorizationHandler {\n (\n params: ChannelAuthorizationRequestParams,\n callback: ChannelAuthorizationCallback\n ): void;\n}\n\nexport interface UserAuthenticationData {\n auth: string;\n user_data: string;\n}\n\nexport type UserAuthenticationCallback = (\n error: Error | null,\n authData: UserAuthenticationData | null\n) => void;\n\nexport interface UserAuthenticationRequestParams {\n socketId: string;\n}\n\nexport interface UserAuthenticationHandler {\n (\n params: UserAuthenticationRequestParams,\n callback: UserAuthenticationCallback\n ): void;\n}\n\nexport type AuthTransportCallback =\n | ChannelAuthorizationCallback\n | UserAuthenticationCallback;\n\nexport interface AuthOptionsT {\n transport: 'ajax' | 'jsonp';\n endpoint: string;\n params?: any;\n headers?: any;\n paramsProvider?: () => any;\n headersProvider?: () => any;\n customHandler?: AuthHandler;\n}\n\nexport declare type UserAuthenticationOptions = AuthOptionsT<\n UserAuthenticationHandler\n>;\nexport declare type ChannelAuthorizationOptions = AuthOptionsT<\n ChannelAuthorizationHandler\n>;\n\nexport interface InternalAuthOptions {\n transport: 'ajax' | 'jsonp';\n endpoint: string;\n params?: any;\n headers?: any;\n paramsProvider?: () => any;\n headersProvider?: () => any;\n}\n","import {\n UserAuthenticationCallback,\n InternalAuthOptions,\n UserAuthenticationHandler,\n UserAuthenticationRequestParams,\n AuthRequestType\n} from './options';\n\nimport Runtime from 'runtime';\n\nconst composeChannelQuery = (\n params: UserAuthenticationRequestParams,\n authOptions: InternalAuthOptions\n) => {\n var query = 'socket_id=' + encodeURIComponent(params.socketId);\n\n for (var key in authOptions.params) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(authOptions.params[key]);\n }\n\n if (authOptions.paramsProvider != null) {\n let dynamicParams = authOptions.paramsProvider();\n for (var key in dynamicParams) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(dynamicParams[key]);\n }\n }\n\n return query;\n};\n\nconst UserAuthenticator = (\n authOptions: InternalAuthOptions\n): UserAuthenticationHandler => {\n if (typeof Runtime.getAuthorizers()[authOptions.transport] === 'undefined') {\n throw `'${authOptions.transport}' is not a recognized auth transport`;\n }\n\n return (\n params: UserAuthenticationRequestParams,\n callback: UserAuthenticationCallback\n ) => {\n const query = composeChannelQuery(params, authOptions);\n\n Runtime.getAuthorizers()[authOptions.transport](\n Runtime,\n query,\n authOptions,\n AuthRequestType.UserAuthentication,\n callback\n );\n };\n};\n\nexport default UserAuthenticator;\n","import {\n AuthRequestType,\n InternalAuthOptions,\n ChannelAuthorizationHandler,\n ChannelAuthorizationRequestParams,\n ChannelAuthorizationCallback\n} from './options';\n\nimport Runtime from 'runtime';\n\nconst composeChannelQuery = (\n params: ChannelAuthorizationRequestParams,\n authOptions: InternalAuthOptions\n) => {\n var query = 'socket_id=' + encodeURIComponent(params.socketId);\n\n query += '&channel_name=' + encodeURIComponent(params.channelName);\n\n for (var key in authOptions.params) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(authOptions.params[key]);\n }\n\n if (authOptions.paramsProvider != null) {\n let dynamicParams = authOptions.paramsProvider();\n for (var key in dynamicParams) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(dynamicParams[key]);\n }\n }\n\n return query;\n};\n\nconst ChannelAuthorizer = (\n authOptions: InternalAuthOptions\n): ChannelAuthorizationHandler => {\n if (typeof Runtime.getAuthorizers()[authOptions.transport] === 'undefined') {\n throw `'${authOptions.transport}' is not a recognized auth transport`;\n }\n\n return (\n params: ChannelAuthorizationRequestParams,\n callback: ChannelAuthorizationCallback\n ) => {\n const query = composeChannelQuery(params, authOptions);\n\n Runtime.getAuthorizers()[authOptions.transport](\n Runtime,\n query,\n authOptions,\n AuthRequestType.ChannelAuthorization,\n callback\n );\n };\n};\n\nexport default ChannelAuthorizer;\n","import Channel from '../channels/channel';\nimport {\n ChannelAuthorizationCallback,\n ChannelAuthorizationHandler,\n ChannelAuthorizationRequestParams,\n InternalAuthOptions\n} from './options';\n\nexport interface DeprecatedChannelAuthorizer {\n authorize(socketId: string, callback: ChannelAuthorizationCallback): void;\n}\n\nexport interface ChannelAuthorizerGenerator {\n (\n channel: Channel,\n options: DeprecatedAuthorizerOptions\n ): DeprecatedChannelAuthorizer;\n}\n\nexport interface DeprecatedAuthOptions {\n params?: any;\n headers?: any;\n}\n\nexport interface DeprecatedAuthorizerOptions {\n authTransport: 'ajax' | 'jsonp';\n authEndpoint: string;\n auth?: DeprecatedAuthOptions;\n}\n\nexport const ChannelAuthorizerProxy = (\n pusher,\n authOptions: InternalAuthOptions,\n channelAuthorizerGenerator: ChannelAuthorizerGenerator\n): ChannelAuthorizationHandler => {\n const deprecatedAuthorizerOptions: DeprecatedAuthorizerOptions = {\n authTransport: authOptions.transport,\n authEndpoint: authOptions.endpoint,\n auth: {\n params: authOptions.params,\n headers: authOptions.headers\n }\n };\n return (\n params: ChannelAuthorizationRequestParams,\n callback: ChannelAuthorizationCallback\n ) => {\n const channel = pusher.channel(params.channelName);\n // This line creates a new channel authorizer every time.\n // In the past, this was only done once per channel and reused.\n // We can do that again if we want to keep this behavior intact.\n const channelAuthorizer: DeprecatedChannelAuthorizer = channelAuthorizerGenerator(\n channel,\n deprecatedAuthorizerOptions\n );\n channelAuthorizer.authorize(params.socketId, callback);\n };\n};\n","import { Options } from './options';\nimport Defaults from './defaults';\nimport {\n ChannelAuthorizationHandler,\n UserAuthenticationHandler,\n ChannelAuthorizationOptions\n} from './auth/options';\nimport UserAuthenticator from './auth/user_authenticator';\nimport ChannelAuthorizer from './auth/channel_authorizer';\nimport { ChannelAuthorizerProxy } from './auth/deprecated_channel_authorizer';\nimport Runtime from 'runtime';\nimport * as nacl from 'tweetnacl';\n\nexport type AuthTransport = 'ajax' | 'jsonp';\nexport type Transport =\n | 'ws'\n | 'wss'\n | 'xhr_streaming'\n | 'xhr_polling'\n | 'sockjs';\n\nexport interface Config {\n // these are all 'required' config parameters, it's not necessary for the user\n // to set them, but they have configured defaults.\n activityTimeout: number;\n enableStats: boolean;\n httpHost: string;\n httpPath: string;\n httpPort: number;\n httpsPort: number;\n pongTimeout: number;\n statsHost: string;\n unavailableTimeout: number;\n useTLS: boolean;\n wsHost: string;\n wsPath: string;\n wsPort: number;\n wssPort: number;\n userAuthenticator: UserAuthenticationHandler;\n channelAuthorizer: ChannelAuthorizationHandler;\n\n // these are all optional parameters or overrrides. The customer can set these\n // but it's not strictly necessary\n forceTLS?: boolean;\n cluster?: string;\n disabledTransports?: Transport[];\n enabledTransports?: Transport[];\n ignoreNullOrigin?: boolean;\n nacl?: nacl;\n timelineParams?: any;\n}\n\n// getConfig mainly sets the defaults for the options that are not provided\nexport function getConfig(opts: Options, pusher): Config {\n let config: Config = {\n activityTimeout: opts.activityTimeout || Defaults.activityTimeout,\n cluster: opts.cluster,\n httpPath: opts.httpPath || Defaults.httpPath,\n httpPort: opts.httpPort || Defaults.httpPort,\n httpsPort: opts.httpsPort || Defaults.httpsPort,\n pongTimeout: opts.pongTimeout || Defaults.pongTimeout,\n statsHost: opts.statsHost || Defaults.stats_host,\n unavailableTimeout: opts.unavailableTimeout || Defaults.unavailableTimeout,\n wsPath: opts.wsPath || Defaults.wsPath,\n wsPort: opts.wsPort || Defaults.wsPort,\n wssPort: opts.wssPort || Defaults.wssPort,\n\n enableStats: getEnableStatsConfig(opts),\n httpHost: getHttpHost(opts),\n useTLS: shouldUseTLS(opts),\n wsHost: getWebsocketHost(opts),\n\n userAuthenticator: buildUserAuthenticator(opts),\n channelAuthorizer: buildChannelAuthorizer(opts, pusher)\n };\n\n if ('disabledTransports' in opts)\n config.disabledTransports = opts.disabledTransports;\n if ('enabledTransports' in opts)\n config.enabledTransports = opts.enabledTransports;\n if ('ignoreNullOrigin' in opts)\n config.ignoreNullOrigin = opts.ignoreNullOrigin;\n if ('timelineParams' in opts) config.timelineParams = opts.timelineParams;\n if ('nacl' in opts) {\n config.nacl = opts.nacl;\n }\n\n return config;\n}\n\nfunction getHttpHost(opts: Options): string {\n if (opts.httpHost) {\n return opts.httpHost;\n }\n if (opts.cluster) {\n return `sockjs-${opts.cluster}.pusher.com`;\n }\n return Defaults.httpHost;\n}\n\nfunction getWebsocketHost(opts: Options): string {\n if (opts.wsHost) {\n return opts.wsHost;\n }\n return getWebsocketHostFromCluster(opts.cluster);\n}\n\nfunction getWebsocketHostFromCluster(cluster: string): string {\n return `ws-${cluster}.pusher.com`;\n}\n\nfunction shouldUseTLS(opts: Options): boolean {\n if (Runtime.getProtocol() === 'https:') {\n return true;\n } else if (opts.forceTLS === false) {\n return false;\n }\n return true;\n}\n\n// if enableStats is set take the value\n// if disableStats is set take the inverse\n// otherwise default to false\nfunction getEnableStatsConfig(opts: Options): boolean {\n if ('enableStats' in opts) {\n return opts.enableStats;\n }\n if ('disableStats' in opts) {\n return !opts.disableStats;\n }\n return false;\n}\n\nfunction buildUserAuthenticator(opts: Options): UserAuthenticationHandler {\n const userAuthentication = {\n ...Defaults.userAuthentication,\n ...opts.userAuthentication\n };\n if (\n 'customHandler' in userAuthentication &&\n userAuthentication['customHandler'] != null\n ) {\n return userAuthentication['customHandler'];\n }\n\n return UserAuthenticator(userAuthentication);\n}\n\nfunction buildChannelAuth(opts: Options, pusher): ChannelAuthorizationOptions {\n let channelAuthorization: ChannelAuthorizationOptions;\n if ('channelAuthorization' in opts) {\n channelAuthorization = {\n ...Defaults.channelAuthorization,\n ...opts.channelAuthorization\n };\n } else {\n channelAuthorization = {\n transport: opts.authTransport || Defaults.authTransport,\n endpoint: opts.authEndpoint || Defaults.authEndpoint\n };\n if ('auth' in opts) {\n if ('params' in opts.auth) channelAuthorization.params = opts.auth.params;\n if ('headers' in opts.auth)\n channelAuthorization.headers = opts.auth.headers;\n }\n if ('authorizer' in opts)\n channelAuthorization.customHandler = ChannelAuthorizerProxy(\n pusher,\n channelAuthorization,\n opts.authorizer\n );\n }\n return channelAuthorization;\n}\n\nfunction buildChannelAuthorizer(\n opts: Options,\n pusher\n): ChannelAuthorizationHandler {\n const channelAuthorization = buildChannelAuth(opts, pusher);\n if (\n 'customHandler' in channelAuthorization &&\n channelAuthorization['customHandler'] != null\n ) {\n return channelAuthorization['customHandler'];\n }\n\n return ChannelAuthorizer(channelAuthorization);\n}\n","import Logger from './logger';\nimport Pusher from './pusher';\nimport EventsDispatcher from './events/dispatcher';\n\nexport default class WatchlistFacade extends EventsDispatcher {\n private pusher: Pusher;\n\n public constructor(pusher: Pusher) {\n super(function(eventName, data) {\n Logger.debug(`No callbacks on watchlist events for ${eventName}`);\n });\n\n this.pusher = pusher;\n this.bindWatchlistInternalEvent();\n }\n\n handleEvent(pusherEvent) {\n pusherEvent.data.events.forEach(watchlistEvent => {\n this.emit(watchlistEvent.name, watchlistEvent);\n });\n }\n\n private bindWatchlistInternalEvent() {\n this.pusher.connection.bind('message', pusherEvent => {\n var eventName = pusherEvent.event;\n if (eventName === 'pusher_internal:watchlist_events') {\n this.handleEvent(pusherEvent);\n }\n });\n }\n}\n","function flatPromise() {\n let resolve, reject;\n const promise = new Promise((res, rej) => {\n resolve = res;\n reject = rej;\n });\n return { promise, resolve, reject };\n}\n\nexport default flatPromise;\n","import Pusher from './pusher';\nimport Logger from './logger';\nimport {\n UserAuthenticationData,\n UserAuthenticationCallback\n} from './auth/options';\nimport Channel from './channels/channel';\nimport WatchlistFacade from './watchlist';\nimport EventsDispatcher from './events/dispatcher';\nimport flatPromise from './utils/flat_promise';\n\nexport default class UserFacade extends EventsDispatcher {\n pusher: Pusher;\n signin_requested: boolean = false;\n user_data: any = null;\n serverToUserChannel: Channel = null;\n signinDonePromise: Promise = null;\n watchlist: WatchlistFacade;\n private _signinDoneResolve: Function = null;\n\n public constructor(pusher: Pusher) {\n super(function(eventName, data) {\n Logger.debug('No callbacks on user for ' + eventName);\n });\n this.pusher = pusher;\n this.pusher.connection.bind('state_change', ({ previous, current }) => {\n if (previous !== 'connected' && current === 'connected') {\n this._signin();\n }\n if (previous === 'connected' && current !== 'connected') {\n this._cleanup();\n this._newSigninPromiseIfNeeded();\n }\n });\n\n this.watchlist = new WatchlistFacade(pusher);\n\n this.pusher.connection.bind('message', event => {\n var eventName = event.event;\n if (eventName === 'pusher:signin_success') {\n this._onSigninSuccess(event.data);\n }\n if (\n this.serverToUserChannel &&\n this.serverToUserChannel.name === event.channel\n ) {\n this.serverToUserChannel.handleEvent(event);\n }\n });\n }\n\n public signin() {\n if (this.signin_requested) {\n return;\n }\n\n this.signin_requested = true;\n this._signin();\n }\n\n private _signin() {\n if (!this.signin_requested) {\n return;\n }\n\n this._newSigninPromiseIfNeeded();\n\n if (this.pusher.connection.state !== 'connected') {\n // Signin will be attempted when the connection is connected\n return;\n }\n\n this.pusher.config.userAuthenticator(\n {\n socketId: this.pusher.connection.socket_id\n },\n this._onAuthorize\n );\n }\n\n private _onAuthorize: UserAuthenticationCallback = (\n err,\n authData: UserAuthenticationData\n ) => {\n if (err) {\n Logger.warn(`Error during signin: ${err}`);\n this._cleanup();\n return;\n }\n\n this.pusher.send_event('pusher:signin', {\n auth: authData.auth,\n user_data: authData.user_data\n });\n\n // Later when we get pusher:singin_success event, the user will be marked as signed in\n };\n\n private _onSigninSuccess(data: any) {\n try {\n this.user_data = JSON.parse(data.user_data);\n } catch (e) {\n Logger.error(`Failed parsing user data after signin: ${data.user_data}`);\n this._cleanup();\n return;\n }\n\n if (typeof this.user_data.id !== 'string' || this.user_data.id === '') {\n Logger.error(\n `user_data doesn't contain an id. user_data: ${this.user_data}`\n );\n this._cleanup();\n return;\n }\n\n // Signin succeeded\n this._signinDoneResolve();\n this._subscribeChannels();\n }\n\n private _subscribeChannels() {\n const ensure_subscribed = channel => {\n if (channel.subscriptionPending && channel.subscriptionCancelled) {\n channel.reinstateSubscription();\n } else if (\n !channel.subscriptionPending &&\n this.pusher.connection.state === 'connected'\n ) {\n channel.subscribe();\n }\n };\n\n this.serverToUserChannel = new Channel(\n `#server-to-user-${this.user_data.id}`,\n this.pusher\n );\n this.serverToUserChannel.bind_global((eventName, data) => {\n if (\n eventName.indexOf('pusher_internal:') === 0 ||\n eventName.indexOf('pusher:') === 0\n ) {\n // ignore internal events\n return;\n }\n this.emit(eventName, data);\n });\n ensure_subscribed(this.serverToUserChannel);\n }\n\n private _cleanup() {\n this.user_data = null;\n if (this.serverToUserChannel) {\n this.serverToUserChannel.unbind_all();\n this.serverToUserChannel.disconnect();\n this.serverToUserChannel = null;\n }\n\n if (this.signin_requested) {\n // If signin is in progress and cleanup is called,\n // Mark the current signin process as done.\n this._signinDoneResolve();\n }\n }\n\n private _newSigninPromiseIfNeeded() {\n if (!this.signin_requested) {\n return;\n }\n\n // If there is a promise and it is not resolved, return without creating a new one.\n if (this.signinDonePromise && !(this.signinDonePromise as any).done) {\n return;\n }\n\n // This promise is never rejected.\n // It gets resolved when the signin process is done whether it failed or succeeded\n const { promise, resolve, reject: _ } = flatPromise();\n (promise as any).done = false;\n const setDone = () => {\n (promise as any).done = true;\n };\n promise.then(setDone).catch(setDone);\n this.signinDonePromise = promise;\n this._signinDoneResolve = resolve;\n }\n}\n","import AbstractRuntime from '../runtimes/interface';\nimport Runtime from 'runtime';\nimport Util from './util';\nimport * as Collections from './utils/collections';\nimport Channels from './channels/channels';\nimport Channel from './channels/channel';\nimport { default as EventsDispatcher } from './events/dispatcher';\nimport Timeline from './timeline/timeline';\nimport TimelineSender from './timeline/timeline_sender';\nimport TimelineLevel from './timeline/level';\nimport { defineTransport } from './strategies/strategy_builder';\nimport ConnectionManager from './connection/connection_manager';\nimport ConnectionManagerOptions from './connection/connection_manager_options';\nimport { PeriodicTimer } from './utils/timers';\nimport Defaults from './defaults';\nimport * as DefaultConfig from './config';\nimport Logger from './logger';\nimport Factory from './utils/factory';\nimport UrlStore from 'core/utils/url_store';\nimport { Options, validateOptions } from './options';\nimport { Config, getConfig } from './config';\nimport StrategyOptions from './strategies/strategy_options';\nimport UserFacade from './user';\n\nexport default class Pusher {\n /* STATIC PROPERTIES */\n static instances: Pusher[] = [];\n static isReady: boolean = false;\n static logToConsole: boolean = false;\n\n // for jsonp\n static Runtime: AbstractRuntime = Runtime;\n static ScriptReceivers: any = (Runtime).ScriptReceivers;\n static DependenciesReceivers: any = (Runtime).DependenciesReceivers;\n static auth_callbacks: any = (Runtime).auth_callbacks;\n\n static ready() {\n Pusher.isReady = true;\n for (var i = 0, l = Pusher.instances.length; i < l; i++) {\n Pusher.instances[i].connect();\n }\n }\n\n static log: (message: any) => void;\n\n private static getClientFeatures(): string[] {\n return Collections.keys(\n Collections.filterObject({ ws: Runtime.Transports.ws }, function(t) {\n return t.isSupported({});\n })\n );\n }\n\n /* INSTANCE PROPERTIES */\n key: string;\n config: Config;\n channels: Channels;\n global_emitter: EventsDispatcher;\n sessionID: number;\n timeline: Timeline;\n timelineSender: TimelineSender;\n connection: ConnectionManager;\n timelineSenderTimer: PeriodicTimer;\n user: UserFacade;\n constructor(app_key: string, options: Options) {\n checkAppKey(app_key);\n validateOptions(options);\n this.key = app_key;\n this.config = getConfig(options, this);\n\n this.channels = Factory.createChannels();\n this.global_emitter = new EventsDispatcher();\n this.sessionID = Runtime.randomInt(1000000000);\n\n this.timeline = new Timeline(this.key, this.sessionID, {\n cluster: this.config.cluster,\n features: Pusher.getClientFeatures(),\n params: this.config.timelineParams || {},\n limit: 50,\n level: TimelineLevel.INFO,\n version: Defaults.VERSION\n });\n if (this.config.enableStats) {\n this.timelineSender = Factory.createTimelineSender(this.timeline, {\n host: this.config.statsHost,\n path: '/timeline/v2/' + Runtime.TimelineTransport.name\n });\n }\n\n var getStrategy = (options: StrategyOptions) => {\n return Runtime.getDefaultStrategy(this.config, options, defineTransport);\n };\n\n this.connection = Factory.createConnectionManager(this.key, {\n getStrategy: getStrategy,\n timeline: this.timeline,\n activityTimeout: this.config.activityTimeout,\n pongTimeout: this.config.pongTimeout,\n unavailableTimeout: this.config.unavailableTimeout,\n useTLS: Boolean(this.config.useTLS)\n });\n\n this.connection.bind('connected', () => {\n this.subscribeAll();\n if (this.timelineSender) {\n this.timelineSender.send(this.connection.isUsingTLS());\n }\n });\n\n this.connection.bind('message', event => {\n var eventName = event.event;\n var internal = eventName.indexOf('pusher_internal:') === 0;\n if (event.channel) {\n var channel = this.channel(event.channel);\n if (channel) {\n channel.handleEvent(event);\n }\n }\n // Emit globally [deprecated]\n if (!internal) {\n this.global_emitter.emit(event.event, event.data);\n }\n });\n this.connection.bind('connecting', () => {\n this.channels.disconnect();\n });\n this.connection.bind('disconnected', () => {\n this.channels.disconnect();\n });\n this.connection.bind('error', err => {\n Logger.warn(err);\n });\n\n Pusher.instances.push(this);\n this.timeline.info({ instances: Pusher.instances.length });\n\n this.user = new UserFacade(this);\n\n if (Pusher.isReady) {\n this.connect();\n }\n }\n\n channel(name: string): Channel {\n return this.channels.find(name);\n }\n\n allChannels(): Channel[] {\n return this.channels.all();\n }\n\n connect() {\n this.connection.connect();\n\n if (this.timelineSender) {\n if (!this.timelineSenderTimer) {\n var usingTLS = this.connection.isUsingTLS();\n var timelineSender = this.timelineSender;\n this.timelineSenderTimer = new PeriodicTimer(60000, function() {\n timelineSender.send(usingTLS);\n });\n }\n }\n }\n\n disconnect() {\n this.connection.disconnect();\n\n if (this.timelineSenderTimer) {\n this.timelineSenderTimer.ensureAborted();\n this.timelineSenderTimer = null;\n }\n }\n\n bind(event_name: string, callback: Function, context?: any): Pusher {\n this.global_emitter.bind(event_name, callback, context);\n return this;\n }\n\n unbind(event_name?: string, callback?: Function, context?: any): Pusher {\n this.global_emitter.unbind(event_name, callback, context);\n return this;\n }\n\n bind_global(callback: Function): Pusher {\n this.global_emitter.bind_global(callback);\n return this;\n }\n\n unbind_global(callback?: Function): Pusher {\n this.global_emitter.unbind_global(callback);\n return this;\n }\n\n unbind_all(callback?: Function): Pusher {\n this.global_emitter.unbind_all();\n return this;\n }\n\n subscribeAll() {\n var channelName;\n for (channelName in this.channels.channels) {\n if (this.channels.channels.hasOwnProperty(channelName)) {\n this.subscribe(channelName);\n }\n }\n }\n\n subscribe(channel_name: string) {\n var channel = this.channels.add(channel_name, this);\n if (channel.subscriptionPending && channel.subscriptionCancelled) {\n channel.reinstateSubscription();\n } else if (\n !channel.subscriptionPending &&\n this.connection.state === 'connected'\n ) {\n channel.subscribe();\n }\n return channel;\n }\n\n unsubscribe(channel_name: string) {\n var channel = this.channels.find(channel_name);\n if (channel && channel.subscriptionPending) {\n channel.cancelSubscription();\n } else {\n channel = this.channels.remove(channel_name);\n if (channel && channel.subscribed) {\n channel.unsubscribe();\n }\n }\n }\n\n send_event(event_name: string, data: any, channel?: string) {\n return this.connection.send_event(event_name, data, channel);\n }\n\n shouldUseTLS(): boolean {\n return this.config.useTLS;\n }\n\n signin() {\n this.user.signin();\n }\n}\n\nfunction checkAppKey(key) {\n if (key === null || key === undefined) {\n throw 'You must pass your app key when you instantiate Pusher.';\n }\n}\n\nRuntime.setup(Pusher);\n","import Pusher from './pusher';\nimport { Options, validateOptions } from './options';\nimport * as nacl from 'tweetnacl';\n\nexport default class PusherWithEncryption extends Pusher {\n constructor(app_key: string, options: Options) {\n Pusher.logToConsole = PusherWithEncryption.logToConsole;\n Pusher.log = PusherWithEncryption.log;\n\n validateOptions(options);\n options.nacl = nacl;\n super(app_key, options);\n }\n}\n"],"sourceRoot":""} \ No newline at end of file +{"version":3,"sources":["webpack://Pusher/webpack/universalModuleDefinition","webpack://Pusher/webpack/bootstrap","webpack://Pusher/./node_modules/@stablelib/base64/base64.ts","webpack://Pusher/./node_modules/@stablelib/utf8/utf8.ts","webpack://Pusher/./node_modules/tweetnacl/nacl-fast.js","webpack://Pusher/./src/core/pusher-with-encryption.js","webpack://Pusher/crypto (ignored)","webpack://Pusher/./src/core/base64.ts","webpack://Pusher/./src/core/utils/timers/abstract_timer.ts","webpack://Pusher/./src/core/utils/timers/index.ts","webpack://Pusher/./src/core/util.ts","webpack://Pusher/./src/core/utils/collections.ts","webpack://Pusher/./src/core/defaults.ts","webpack://Pusher/./src/core/transports/url_schemes.ts","webpack://Pusher/./src/core/events/callback_registry.ts","webpack://Pusher/./src/core/events/dispatcher.ts","webpack://Pusher/./src/core/logger.ts","webpack://Pusher/./src/core/transports/transport_connection.ts","webpack://Pusher/./src/core/transports/transport.ts","webpack://Pusher/./src/runtimes/isomorphic/transports/transports.ts","webpack://Pusher/./src/core/transports/assistant_to_the_transport_manager.ts","webpack://Pusher/./src/core/connection/protocol/protocol.ts","webpack://Pusher/./src/core/connection/connection.ts","webpack://Pusher/./src/core/connection/handshake/index.ts","webpack://Pusher/./src/core/timeline/timeline_sender.ts","webpack://Pusher/./src/core/errors.ts","webpack://Pusher/./src/core/utils/url_store.ts","webpack://Pusher/./src/core/channels/channel.ts","webpack://Pusher/./src/core/channels/private_channel.ts","webpack://Pusher/./src/core/channels/members.ts","webpack://Pusher/./src/core/channels/presence_channel.ts","webpack://Pusher/./src/core/channels/encrypted_channel.ts","webpack://Pusher/./src/core/connection/connection_manager.ts","webpack://Pusher/./src/core/channels/channels.ts","webpack://Pusher/./src/core/utils/factory.ts","webpack://Pusher/./src/core/transports/transport_manager.ts","webpack://Pusher/./src/core/strategies/sequential_strategy.ts","webpack://Pusher/./src/core/strategies/best_connected_ever_strategy.ts","webpack://Pusher/./src/core/strategies/websocket_prioritized_cached_strategy.ts","webpack://Pusher/./src/core/strategies/delayed_strategy.ts","webpack://Pusher/./src/core/strategies/if_strategy.ts","webpack://Pusher/./src/core/strategies/first_connected_strategy.ts","webpack://Pusher/./src/runtimes/isomorphic/default_strategy.ts","webpack://Pusher/./src/runtimes/isomorphic/transports/transport_connection_initializer.ts","webpack://Pusher/./src/core/http/http_request.ts","webpack://Pusher/./src/core/http/state.ts","webpack://Pusher/./src/core/http/http_socket.ts","webpack://Pusher/./src/core/http/http_streaming_socket.ts","webpack://Pusher/./src/core/http/http_polling_socket.ts","webpack://Pusher/./src/runtimes/isomorphic/http/http_xhr_request.ts","webpack://Pusher/./src/runtimes/isomorphic/http/http.ts","webpack://Pusher/./src/runtimes/isomorphic/runtime.ts","webpack://Pusher/./src/runtimes/worker/net_info.ts","webpack://Pusher/./src/runtimes/worker/auth/fetch_auth.ts","webpack://Pusher/./src/runtimes/worker/timeline/fetch_timeline.ts","webpack://Pusher/./src/runtimes/worker/runtime.ts","webpack://Pusher/./src/core/timeline/level.ts","webpack://Pusher/./src/core/timeline/timeline.ts","webpack://Pusher/./src/core/strategies/transport_strategy.ts","webpack://Pusher/./src/core/strategies/strategy_builder.ts","webpack://Pusher/./src/core/options.ts","webpack://Pusher/./src/core/auth/options.ts","webpack://Pusher/./src/core/auth/user_authenticator.ts","webpack://Pusher/./src/core/auth/channel_authorizer.ts","webpack://Pusher/./src/core/auth/deprecated_channel_authorizer.ts","webpack://Pusher/./src/core/config.ts","webpack://Pusher/./src/core/watchlist.ts","webpack://Pusher/./src/core/utils/flat_promise.ts","webpack://Pusher/./src/core/user.ts","webpack://Pusher/./src/core/pusher.ts","webpack://Pusher/./src/core/pusher-with-encryption.ts"],"names":[],"mappings":";;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AACD,O;QCVA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;;QAEA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;;;QAGA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;QACA,0CAA0C,gCAAgC;QAC1E;QACA;;QAEA;QACA;QACA;QACA,wDAAwD,kBAAkB;QAC1E;QACA,iDAAiD,cAAc;QAC/D;;QAEA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA,yCAAyC,iCAA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;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa,OAAO;AACpB;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,aAAa,QAAQ;AACrB,aAAa,OAAO;AACpB;AACA;AACA,eAAe,QAAQ;AACvB;AACA,eAAe,QAAQ;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB;AACA;AACA;;AAEA;AACA;AACA;AACA,aAAa,QAAQ;AACrB,aAAa,OAAO;AACpB;AACA;AACA,eAAe,QAAQ;AACvB;AACA,eAAe,QAAQ;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,iBAAiB,OAAO;AACxB;AACA;;AAEA;AACA;AACA;AACA;AACA,iBAAiB,OAAO;AACxB;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA,8CAA8C;AAC9C,8CAA8C;AAC9C,8CAA8C;AAC9C,8CAA8C;AAC9C,8CAA8C;AAC9C;AACA,8CAA8C;AAC9C,8CAA8C;AAC9C,8CAA8C;AAC9C;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,sDAAsD;AACtD,sDAAsD;AACtD,sDAAsD;AACtD,sDAAsD;AACtD,sDAAsD;AACtD;AACA,sDAAsD;AACtD,sDAAsD;AACtD,sDAAsD;AACtD;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA,qBAAqB;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA,qBAAqB;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA,qBAAqB;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA,qBAAqB;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA,qBAAqB;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA,qBAAqB;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA,qBAAqB;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA,qBAAqB;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA,qBAAqB;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA,qBAAqB;;AAErB;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA,UAAU,QAAQ;AAClB;AACA;AACA;;AAEA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA;AACA;;AAEA;AACA,aAAa,QAAQ;AACrB;AACA,aAAa,QAAQ;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa,OAAO;AACpB;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,UAAU;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,eAAe,WAAW;AAC1B;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;;AAEA;AACA;AACA,aAAa,QAAQ;AACrB;;AAEA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA,aAAa,OAAO;AACpB;AACA,eAAe,QAAQ;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;;AAEA;AACA,iBAAiB,QAAQ;AACzB;;AAEA;AACA,iBAAiB,QAAQ;AACzB;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD;;AAEA;AACA;AACA,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA,aAAa,QAAQ;AACrB,eAAe,QAAQ;AACvB;AACA;AACA;AACA,aAAa,QAAQ;AACrB;;AAEA;AACA;AACA;AACA,aAAa,QAAQ;AACrB,eAAe,QAAQ;AACvB;AACA;AACA;AACA,aAAa,QAAQ;AACrB;;AAEA;AACA;AACA;AACA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA;AACA,aAAa,MAAM;AACnB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,eAAe,QAAQ;AACvB;AACA;AACA;AACA;AACA,eAAe,QAAQ;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA,qBAAqB;AACrB,qBAAqB;;AAErB;AACA;AACA;;AAEA,sBAAsB;AACtB,sBAAsB;;AAEtB;AACA;AACA;;AAEA,sBAAsB;AACtB,sBAAsB;;AAEtB;AACA;AACA;;AAEA,sBAAsB;AACtB,sBAAsB;;AAEtB;AACA;AACA;;AAEA,sBAAsB;AACtB,sBAAsB;;AA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;;AAEpB;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA,mBAAmB;AACnB,mBAAmB;;AAEnB;AACA;;AAEA,oBAAoB;AACpB,oBAAoB;;AAEpB;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA,mBAAmB;AACnB,mBAAmB;;AAEnB;AACA;;AAEA,oBAAoB;AACpB,oBAAoB;;AAEpB;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA,mBAAmB;AACnB,mBAAmB;;AAEnB;AACA;;AAEA,oBAAoB;AACpB,oBAAoB;;AAEpB;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA,aAAa,OAAO;AACpB;;AAEA;AACA;AACA;AACA;;AAEA,aAAa,OAAO;;AAEpB;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa,OAAO;AACpB;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,QAAQ;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA,aAAa,QAAQ;AACrB;AACA;;AAEA;;AAEA;AACA;AACA,cAAc,SAAS;AACvB;AACA,gCAAgC,OAAO;AACvC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA;AACA,aAAa,QAAQ;AACrB,aAAa,QAAQ;AACrB;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa,QAAQ;AACrB,aAAa,QAAQ;AACrB;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA,aAAa,OAAO;AACpB,aAAa,QAAQ;;AAErB;AACA;AACA;AACA;;AAEA,cAAc,QAAQ;AACtB;AACA;;AAEA,aAAa,QAAQ;AACrB,aAAa,QAAQ;AACrB,aAAa,QAAQ;AACrB,eAAe,QAAQ;AACvB;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;;AAEA,aAAa,OAAO;AACpB,aAAa,QAAQ;AACrB;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA,eAAe,OAAO;AACtB;AACA;;AAEA,aAAa,OAAO;AACpB;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA,iBAAiB,sBAAsB;AACvC;AACA;AACA;AACA;;AAEA;AACA,iBAAiB,gBAAgB;AACjC;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,iBAAiB,gBAAgB;AACjC;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,iBAAiB,gBAAgB;AACjC;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA,UAAU;AACV;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,UAAU;AACV;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAiB,cAAc;AAC/B;AACA;;AAEA;AACA;AACA;AACA,iBAAiB,gBAAgB;AACjC;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa,uBAAuB;AACpC,aAAa,gBAAgB;AAC7B;AACA;;AAEA;AACA;AACA;AACA;AACA,UAAU;AACV;;AAEA;AACA;AACA;AACA;AACA;AACA,iBAAiB,eAAe;AAChC,UAAU;AACV;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAiB,QAAQ;AACzB;AACA,UAAU;AACV;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAiB,OAAO;AACxB;AACA;AACA,iBAAiB,OAAO;AACxB;AACA,KAAK;AACL,GAAG,UAAU,IAA8B;AAC3C;AACA,aAAa,mBAAO,CAAC,CAAQ;AAC7B;AACA;AACA;AACA,mBAAmB,OAAO;AAC1B;AACA,OAAO;AACP;AACA;AACA,CAAC;;AAED,CAAC,EAAE,KAA6B,kEAAkE;;;;;;;ACt1ElG,i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AAC,CAAC;IAC/D,CAAC;IAED,YAAY;QACV,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC;IAC5B,CAAC;IAED,MAAM;QACJ,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;IACrB,CAAC;;AAvOM,uBAAS,GAAa,EAAE,CAAC;AACzB,qBAAO,GAAY,KAAK,CAAC;AACzB,0BAAY,GAAY,KAAK,CAAC;AAG9B,qBAAO,GAAoB,cAAO,CAAC;AACnC,6BAAe,GAAc,cAAQ,CAAC,eAAe,CAAC;AACtD,mCAAqB,GAAc,cAAQ,CAAC,qBAAqB,CAAC;AAClE,4BAAc,GAAc,cAAQ,CAAC,cAAc,CAAC;AAVxC,6DAAM;AA4O3B,SAAS,WAAW,CAAC,GAAG;IACtB,IAAI,GAAG,KAAK,IAAI,IAAI,GAAG,KAAK,SAAS,EAAE;QACrC,MAAM,yDAAyD,CAAC;KACjE;AACH,CAAC;AAED,cAAO,CAAC,KAAK,CAAC,aAAM,CAAC,CAAC;;;;;;ACtQQ;AACuB;AACnB;AAEnB,MAAM,2CAAqB,SAAQ,WAAM;IACtD,YAAY,OAAe,EAAE,OAAgB;QAC3C,WAAM,CAAC,YAAY,GAAG,2CAAoB,CAAC,YAAY,CAAC;QACxD,WAAM,CAAC,GAAG,GAAG,2CAAoB,CAAC,GAAG,CAAC;QAEtC,eAAe,CAAC,OAAO,CAAC,CAAC;QACzB,OAAO,CAAC,IAAI,GAAG,SAAI,CAAC;QACpB,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAC1B,CAAC;CACF","file":"pusher-with-encryption.worker.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"Pusher\"] = factory();\n\telse\n\t\troot[\"Pusher\"] = factory();\n})(this, function() {\nreturn "," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 3);\n","// Copyright (C) 2016 Dmitry Chestnykh\n// MIT License. See LICENSE file for details.\n\n/**\n * Package base64 implements Base64 encoding and decoding.\n */\n\n// Invalid character used in decoding to indicate\n// that the character to decode is out of range of\n// alphabet and cannot be decoded.\nconst INVALID_BYTE = 256;\n\n/**\n * Implements standard Base64 encoding.\n *\n * Operates in constant time.\n */\nexport class Coder {\n // TODO(dchest): methods to encode chunk-by-chunk.\n\n constructor(private _paddingCharacter = \"=\") { }\n\n encodedLength(length: number): number {\n if (!this._paddingCharacter) {\n return (length * 8 + 5) / 6 | 0;\n }\n return (length + 2) / 3 * 4 | 0;\n }\n\n encode(data: Uint8Array): string {\n let out = \"\";\n\n let i = 0;\n for (; i < data.length - 2; i += 3) {\n let c = (data[i] << 16) | (data[i + 1] << 8) | (data[i + 2]);\n out += this._encodeByte((c >>> 3 * 6) & 63);\n out += this._encodeByte((c >>> 2 * 6) & 63);\n out += this._encodeByte((c >>> 1 * 6) & 63);\n out += this._encodeByte((c >>> 0 * 6) & 63);\n }\n\n const left = data.length - i;\n if (left > 0) {\n let c = (data[i] << 16) | (left === 2 ? data[i + 1] << 8 : 0);\n out += this._encodeByte((c >>> 3 * 6) & 63);\n out += this._encodeByte((c >>> 2 * 6) & 63);\n if (left === 2) {\n out += this._encodeByte((c >>> 1 * 6) & 63);\n } else {\n out += this._paddingCharacter || \"\";\n }\n out += this._paddingCharacter || \"\";\n }\n\n return out;\n }\n\n maxDecodedLength(length: number): number {\n if (!this._paddingCharacter) {\n return (length * 6 + 7) / 8 | 0;\n }\n return length / 4 * 3 | 0;\n }\n\n decodedLength(s: string): number {\n return this.maxDecodedLength(s.length - this._getPaddingLength(s));\n }\n\n decode(s: string): Uint8Array {\n if (s.length === 0) {\n return new Uint8Array(0);\n }\n const paddingLength = this._getPaddingLength(s);\n const length = s.length - paddingLength;\n const out = new Uint8Array(this.maxDecodedLength(length));\n let op = 0;\n let i = 0;\n let haveBad = 0;\n let v0 = 0, v1 = 0, v2 = 0, v3 = 0;\n for (; i < length - 4; i += 4) {\n v0 = this._decodeChar(s.charCodeAt(i + 0));\n v1 = this._decodeChar(s.charCodeAt(i + 1));\n v2 = this._decodeChar(s.charCodeAt(i + 2));\n v3 = this._decodeChar(s.charCodeAt(i + 3));\n out[op++] = (v0 << 2) | (v1 >>> 4);\n out[op++] = (v1 << 4) | (v2 >>> 2);\n out[op++] = (v2 << 6) | v3;\n haveBad |= v0 & INVALID_BYTE;\n haveBad |= v1 & INVALID_BYTE;\n haveBad |= v2 & INVALID_BYTE;\n haveBad |= v3 & INVALID_BYTE;\n }\n if (i < length - 1) {\n v0 = this._decodeChar(s.charCodeAt(i));\n v1 = this._decodeChar(s.charCodeAt(i + 1));\n out[op++] = (v0 << 2) | (v1 >>> 4);\n haveBad |= v0 & INVALID_BYTE;\n haveBad |= v1 & INVALID_BYTE;\n }\n if (i < length - 2) {\n v2 = this._decodeChar(s.charCodeAt(i + 2));\n out[op++] = (v1 << 4) | (v2 >>> 2);\n haveBad |= v2 & INVALID_BYTE;\n }\n if (i < length - 3) {\n v3 = this._decodeChar(s.charCodeAt(i + 3));\n out[op++] = (v2 << 6) | v3;\n haveBad |= v3 & INVALID_BYTE;\n }\n if (haveBad !== 0) {\n throw new Error(\"Base64Coder: incorrect characters for decoding\");\n }\n return out;\n }\n\n // Standard encoding have the following encoded/decoded ranges,\n // which we need to convert between.\n //\n // ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 0123456789 + /\n // Index: 0 - 25 26 - 51 52 - 61 62 63\n // ASCII: 65 - 90 97 - 122 48 - 57 43 47\n //\n\n // Encode 6 bits in b into a new character.\n protected _encodeByte(b: number): string {\n // Encoding uses constant time operations as follows:\n //\n // 1. Define comparison of A with B using (A - B) >>> 8:\n // if A > B, then result is positive integer\n // if A <= B, then result is 0\n //\n // 2. Define selection of C or 0 using bitwise AND: X & C:\n // if X == 0, then result is 0\n // if X != 0, then result is C\n //\n // 3. Start with the smallest comparison (b >= 0), which is always\n // true, so set the result to the starting ASCII value (65).\n //\n // 4. Continue comparing b to higher ASCII values, and selecting\n // zero if comparison isn't true, otherwise selecting a value\n // to add to result, which:\n //\n // a) undoes the previous addition\n // b) provides new value to add\n //\n let result = b;\n // b >= 0\n result += 65;\n // b > 25\n result += ((25 - b) >>> 8) & ((0 - 65) - 26 + 97);\n // b > 51\n result += ((51 - b) >>> 8) & ((26 - 97) - 52 + 48);\n // b > 61\n result += ((61 - b) >>> 8) & ((52 - 48) - 62 + 43);\n // b > 62\n result += ((62 - b) >>> 8) & ((62 - 43) - 63 + 47);\n\n return String.fromCharCode(result);\n }\n\n // Decode a character code into a byte.\n // Must return 256 if character is out of alphabet range.\n protected _decodeChar(c: number): number {\n // Decoding works similar to encoding: using the same comparison\n // function, but now it works on ranges: result is always incremented\n // by value, but this value becomes zero if the range is not\n // satisfied.\n //\n // Decoding starts with invalid value, 256, which is then\n // subtracted when the range is satisfied. If none of the ranges\n // apply, the function returns 256, which is then checked by\n // the caller to throw error.\n let result = INVALID_BYTE; // start with invalid character\n\n // c == 43 (c > 42 and c < 44)\n result += (((42 - c) & (c - 44)) >>> 8) & (-INVALID_BYTE + c - 43 + 62);\n // c == 47 (c > 46 and c < 48)\n result += (((46 - c) & (c - 48)) >>> 8) & (-INVALID_BYTE + c - 47 + 63);\n // c > 47 and c < 58\n result += (((47 - c) & (c - 58)) >>> 8) & (-INVALID_BYTE + c - 48 + 52);\n // c > 64 and c < 91\n result += (((64 - c) & (c - 91)) >>> 8) & (-INVALID_BYTE + c - 65 + 0);\n // c > 96 and c < 123\n result += (((96 - c) & (c - 123)) >>> 8) & (-INVALID_BYTE + c - 97 + 26);\n\n return result;\n }\n\n private _getPaddingLength(s: string): number {\n let paddingLength = 0;\n if (this._paddingCharacter) {\n for (let i = s.length - 1; i >= 0; i--) {\n if (s[i] !== this._paddingCharacter) {\n break;\n }\n paddingLength++;\n }\n if (s.length < 4 || paddingLength > 2) {\n throw new Error(\"Base64Coder: incorrect padding\");\n }\n }\n return paddingLength;\n }\n\n}\n\nconst stdCoder = new Coder();\n\nexport function encode(data: Uint8Array): string {\n return stdCoder.encode(data);\n}\n\nexport function decode(s: string): Uint8Array {\n return stdCoder.decode(s);\n}\n\n/**\n * Implements URL-safe Base64 encoding.\n * (Same as Base64, but '+' is replaced with '-', and '/' with '_').\n *\n * Operates in constant time.\n */\nexport class URLSafeCoder extends Coder {\n // URL-safe encoding have the following encoded/decoded ranges:\n //\n // ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 0123456789 - _\n // Index: 0 - 25 26 - 51 52 - 61 62 63\n // ASCII: 65 - 90 97 - 122 48 - 57 45 95\n //\n\n protected _encodeByte(b: number): string {\n let result = b;\n // b >= 0\n result += 65;\n // b > 25\n result += ((25 - b) >>> 8) & ((0 - 65) - 26 + 97);\n // b > 51\n result += ((51 - b) >>> 8) & ((26 - 97) - 52 + 48);\n // b > 61\n result += ((61 - b) >>> 8) & ((52 - 48) - 62 + 45);\n // b > 62\n result += ((62 - b) >>> 8) & ((62 - 45) - 63 + 95);\n\n return String.fromCharCode(result);\n }\n\n protected _decodeChar(c: number): number {\n let result = INVALID_BYTE;\n\n // c == 45 (c > 44 and c < 46)\n result += (((44 - c) & (c - 46)) >>> 8) & (-INVALID_BYTE + c - 45 + 62);\n // c == 95 (c > 94 and c < 96)\n result += (((94 - c) & (c - 96)) >>> 8) & (-INVALID_BYTE + c - 95 + 63);\n // c > 47 and c < 58\n result += (((47 - c) & (c - 58)) >>> 8) & (-INVALID_BYTE + c - 48 + 52);\n // c > 64 and c < 91\n result += (((64 - c) & (c - 91)) >>> 8) & (-INVALID_BYTE + c - 65 + 0);\n // c > 96 and c < 123\n result += (((96 - c) & (c - 123)) >>> 8) & (-INVALID_BYTE + c - 97 + 26);\n\n return result;\n }\n}\n\nconst urlSafeCoder = new URLSafeCoder();\n\nexport function encodeURLSafe(data: Uint8Array): string {\n return urlSafeCoder.encode(data);\n}\n\nexport function decodeURLSafe(s: string): Uint8Array {\n return urlSafeCoder.decode(s);\n}\n\n\nexport const encodedLength = (length: number) =>\n stdCoder.encodedLength(length);\n\nexport const maxDecodedLength = (length: number) =>\n stdCoder.maxDecodedLength(length);\n\nexport const decodedLength = (s: string) =>\n stdCoder.decodedLength(s);\n","// Copyright (C) 2016 Dmitry Chestnykh\n// MIT License. See LICENSE file for details.\n\n/**\n * Package utf8 implements UTF-8 encoding and decoding.\n */\n\nconst INVALID_UTF16 = \"utf8: invalid string\";\nconst INVALID_UTF8 = \"utf8: invalid source encoding\";\n\n/**\n * Encodes the given string into UTF-8 byte array.\n * Throws if the source string has invalid UTF-16 encoding.\n */\nexport function encode(s: string): Uint8Array {\n // Calculate result length and allocate output array.\n // encodedLength() also validates string and throws errors,\n // so we don't need repeat validation here.\n const arr = new Uint8Array(encodedLength(s));\n\n let pos = 0;\n for (let i = 0; i < s.length; i++) {\n let c = s.charCodeAt(i);\n if (c < 0x80) {\n arr[pos++] = c;\n } else if (c < 0x800) {\n arr[pos++] = 0xc0 | c >> 6;\n arr[pos++] = 0x80 | c & 0x3f;\n } else if (c < 0xd800) {\n arr[pos++] = 0xe0 | c >> 12;\n arr[pos++] = 0x80 | (c >> 6) & 0x3f;\n arr[pos++] = 0x80 | c & 0x3f;\n } else {\n i++; // get one more character\n c = (c & 0x3ff) << 10;\n c |= s.charCodeAt(i) & 0x3ff;\n c += 0x10000;\n\n arr[pos++] = 0xf0 | c >> 18;\n arr[pos++] = 0x80 | (c >> 12) & 0x3f;\n arr[pos++] = 0x80 | (c >> 6) & 0x3f;\n arr[pos++] = 0x80 | c & 0x3f;\n }\n }\n return arr;\n}\n\n/**\n * Returns the number of bytes required to encode the given string into UTF-8.\n * Throws if the source string has invalid UTF-16 encoding.\n */\nexport function encodedLength(s: string): number {\n let result = 0;\n for (let i = 0; i < s.length; i++) {\n const c = s.charCodeAt(i);\n if (c < 0x80) {\n result += 1;\n } else if (c < 0x800) {\n result += 2;\n } else if (c < 0xd800) {\n result += 3;\n } else if (c <= 0xdfff) {\n if (i >= s.length - 1) {\n throw new Error(INVALID_UTF16);\n }\n i++; // \"eat\" next character\n result += 4;\n } else {\n throw new Error(INVALID_UTF16);\n }\n }\n return result;\n}\n\n/**\n * Decodes the given byte array from UTF-8 into a string.\n * Throws if encoding is invalid.\n */\nexport function decode(arr: Uint8Array): string {\n const chars: string[] = [];\n for (let i = 0; i < arr.length; i++) {\n let b = arr[i];\n\n if (b & 0x80) {\n let min;\n if (b < 0xe0) {\n // Need 1 more byte.\n if (i >= arr.length) {\n throw new Error(INVALID_UTF8);\n }\n const n1 = arr[++i];\n if ((n1 & 0xc0) !== 0x80) {\n throw new Error(INVALID_UTF8);\n }\n b = (b & 0x1f) << 6 | (n1 & 0x3f);\n min = 0x80;\n } else if (b < 0xf0) {\n // Need 2 more bytes.\n if (i >= arr.length - 1) {\n throw new Error(INVALID_UTF8);\n }\n const n1 = arr[++i];\n const n2 = arr[++i];\n if ((n1 & 0xc0) !== 0x80 || (n2 & 0xc0) !== 0x80) {\n throw new Error(INVALID_UTF8);\n }\n b = (b & 0x0f) << 12 | (n1 & 0x3f) << 6 | (n2 & 0x3f);\n min = 0x800;\n } else if (b < 0xf8) {\n // Need 3 more bytes.\n if (i >= arr.length - 2) {\n throw new Error(INVALID_UTF8);\n }\n const n1 = arr[++i];\n const n2 = arr[++i];\n const n3 = arr[++i];\n if ((n1 & 0xc0) !== 0x80 || (n2 & 0xc0) !== 0x80 || (n3 & 0xc0) !== 0x80) {\n throw new Error(INVALID_UTF8);\n }\n b = (b & 0x0f) << 18 | (n1 & 0x3f) << 12 | (n2 & 0x3f) << 6 | (n3 & 0x3f);\n min = 0x10000;\n } else {\n throw new Error(INVALID_UTF8);\n }\n\n if (b < min || (b >= 0xd800 && b <= 0xdfff)) {\n throw new Error(INVALID_UTF8);\n }\n\n if (b >= 0x10000) {\n // Surrogate pair.\n if (b > 0x10ffff) {\n throw new Error(INVALID_UTF8);\n }\n b -= 0x10000;\n chars.push(String.fromCharCode(0xd800 | (b >> 10)));\n b = 0xdc00 | (b & 0x3ff);\n }\n }\n\n chars.push(String.fromCharCode(b));\n }\n return chars.join(\"\");\n}\n","(function(nacl) {\n'use strict';\n\n// Ported in 2014 by Dmitry Chestnykh and Devi Mandiri.\n// Public domain.\n//\n// Implementation derived from TweetNaCl version 20140427.\n// See for details: http://tweetnacl.cr.yp.to/\n\nvar gf = function(init) {\n var i, r = new Float64Array(16);\n if (init) for (i = 0; i < init.length; i++) r[i] = init[i];\n return r;\n};\n\n// Pluggable, initialized in high-level API below.\nvar randombytes = function(/* x, n */) { throw new Error('no PRNG'); };\n\nvar _0 = new Uint8Array(16);\nvar _9 = new Uint8Array(32); _9[0] = 9;\n\nvar gf0 = gf(),\n gf1 = gf([1]),\n _121665 = gf([0xdb41, 1]),\n D = gf([0x78a3, 0x1359, 0x4dca, 0x75eb, 0xd8ab, 0x4141, 0x0a4d, 0x0070, 0xe898, 0x7779, 0x4079, 0x8cc7, 0xfe73, 0x2b6f, 0x6cee, 0x5203]),\n D2 = gf([0xf159, 0x26b2, 0x9b94, 0xebd6, 0xb156, 0x8283, 0x149a, 0x00e0, 0xd130, 0xeef3, 0x80f2, 0x198e, 0xfce7, 0x56df, 0xd9dc, 0x2406]),\n X = gf([0xd51a, 0x8f25, 0x2d60, 0xc956, 0xa7b2, 0x9525, 0xc760, 0x692c, 0xdc5c, 0xfdd6, 0xe231, 0xc0a4, 0x53fe, 0xcd6e, 0x36d3, 0x2169]),\n Y = gf([0x6658, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666]),\n I = gf([0xa0b0, 0x4a0e, 0x1b27, 0xc4ee, 0xe478, 0xad2f, 0x1806, 0x2f43, 0xd7a7, 0x3dfb, 0x0099, 0x2b4d, 0xdf0b, 0x4fc1, 0x2480, 0x2b83]);\n\nfunction ts64(x, i, h, l) {\n x[i] = (h >> 24) & 0xff;\n x[i+1] = (h >> 16) & 0xff;\n x[i+2] = (h >> 8) & 0xff;\n x[i+3] = h & 0xff;\n x[i+4] = (l >> 24) & 0xff;\n x[i+5] = (l >> 16) & 0xff;\n x[i+6] = (l >> 8) & 0xff;\n x[i+7] = l & 0xff;\n}\n\nfunction vn(x, xi, y, yi, n) {\n var i,d = 0;\n for (i = 0; i < n; i++) d |= x[xi+i]^y[yi+i];\n return (1 & ((d - 1) >>> 8)) - 1;\n}\n\nfunction crypto_verify_16(x, xi, y, yi) {\n return vn(x,xi,y,yi,16);\n}\n\nfunction crypto_verify_32(x, xi, y, yi) {\n return vn(x,xi,y,yi,32);\n}\n\nfunction core_salsa20(o, p, k, c) {\n var j0 = c[ 0] & 0xff | (c[ 1] & 0xff)<<8 | (c[ 2] & 0xff)<<16 | (c[ 3] & 0xff)<<24,\n j1 = k[ 0] & 0xff | (k[ 1] & 0xff)<<8 | (k[ 2] & 0xff)<<16 | (k[ 3] & 0xff)<<24,\n j2 = k[ 4] & 0xff | (k[ 5] & 0xff)<<8 | (k[ 6] & 0xff)<<16 | (k[ 7] & 0xff)<<24,\n j3 = k[ 8] & 0xff | (k[ 9] & 0xff)<<8 | (k[10] & 0xff)<<16 | (k[11] & 0xff)<<24,\n j4 = k[12] & 0xff | (k[13] & 0xff)<<8 | (k[14] & 0xff)<<16 | (k[15] & 0xff)<<24,\n j5 = c[ 4] & 0xff | (c[ 5] & 0xff)<<8 | (c[ 6] & 0xff)<<16 | (c[ 7] & 0xff)<<24,\n j6 = p[ 0] & 0xff | (p[ 1] & 0xff)<<8 | (p[ 2] & 0xff)<<16 | (p[ 3] & 0xff)<<24,\n j7 = p[ 4] & 0xff | (p[ 5] & 0xff)<<8 | (p[ 6] & 0xff)<<16 | (p[ 7] & 0xff)<<24,\n j8 = p[ 8] & 0xff | (p[ 9] & 0xff)<<8 | (p[10] & 0xff)<<16 | (p[11] & 0xff)<<24,\n j9 = p[12] & 0xff | (p[13] & 0xff)<<8 | (p[14] & 0xff)<<16 | (p[15] & 0xff)<<24,\n j10 = c[ 8] & 0xff | (c[ 9] & 0xff)<<8 | (c[10] & 0xff)<<16 | (c[11] & 0xff)<<24,\n j11 = k[16] & 0xff | (k[17] & 0xff)<<8 | (k[18] & 0xff)<<16 | (k[19] & 0xff)<<24,\n j12 = k[20] & 0xff | (k[21] & 0xff)<<8 | (k[22] & 0xff)<<16 | (k[23] & 0xff)<<24,\n j13 = k[24] & 0xff | (k[25] & 0xff)<<8 | (k[26] & 0xff)<<16 | (k[27] & 0xff)<<24,\n j14 = k[28] & 0xff | (k[29] & 0xff)<<8 | (k[30] & 0xff)<<16 | (k[31] & 0xff)<<24,\n j15 = c[12] & 0xff | (c[13] & 0xff)<<8 | (c[14] & 0xff)<<16 | (c[15] & 0xff)<<24;\n\n var x0 = j0, x1 = j1, x2 = j2, x3 = j3, x4 = j4, x5 = j5, x6 = j6, x7 = j7,\n x8 = j8, x9 = j9, x10 = j10, x11 = j11, x12 = j12, x13 = j13, x14 = j14,\n x15 = j15, u;\n\n for (var i = 0; i < 20; i += 2) {\n u = x0 + x12 | 0;\n x4 ^= u<<7 | u>>>(32-7);\n u = x4 + x0 | 0;\n x8 ^= u<<9 | u>>>(32-9);\n u = x8 + x4 | 0;\n x12 ^= u<<13 | u>>>(32-13);\n u = x12 + x8 | 0;\n x0 ^= u<<18 | u>>>(32-18);\n\n u = x5 + x1 | 0;\n x9 ^= u<<7 | u>>>(32-7);\n u = x9 + x5 | 0;\n x13 ^= u<<9 | u>>>(32-9);\n u = x13 + x9 | 0;\n x1 ^= u<<13 | u>>>(32-13);\n u = x1 + x13 | 0;\n x5 ^= u<<18 | u>>>(32-18);\n\n u = x10 + x6 | 0;\n x14 ^= u<<7 | u>>>(32-7);\n u = x14 + x10 | 0;\n x2 ^= u<<9 | u>>>(32-9);\n u = x2 + x14 | 0;\n x6 ^= u<<13 | u>>>(32-13);\n u = x6 + x2 | 0;\n x10 ^= u<<18 | u>>>(32-18);\n\n u = x15 + x11 | 0;\n x3 ^= u<<7 | u>>>(32-7);\n u = x3 + x15 | 0;\n x7 ^= u<<9 | u>>>(32-9);\n u = x7 + x3 | 0;\n x11 ^= u<<13 | u>>>(32-13);\n u = x11 + x7 | 0;\n x15 ^= u<<18 | u>>>(32-18);\n\n u = x0 + x3 | 0;\n x1 ^= u<<7 | u>>>(32-7);\n u = x1 + x0 | 0;\n x2 ^= u<<9 | u>>>(32-9);\n u = x2 + x1 | 0;\n x3 ^= u<<13 | u>>>(32-13);\n u = x3 + x2 | 0;\n x0 ^= u<<18 | u>>>(32-18);\n\n u = x5 + x4 | 0;\n x6 ^= u<<7 | u>>>(32-7);\n u = x6 + x5 | 0;\n x7 ^= u<<9 | u>>>(32-9);\n u = x7 + x6 | 0;\n x4 ^= u<<13 | u>>>(32-13);\n u = x4 + x7 | 0;\n x5 ^= u<<18 | u>>>(32-18);\n\n u = x10 + x9 | 0;\n x11 ^= u<<7 | u>>>(32-7);\n u = x11 + x10 | 0;\n x8 ^= u<<9 | u>>>(32-9);\n u = x8 + x11 | 0;\n x9 ^= u<<13 | u>>>(32-13);\n u = x9 + x8 | 0;\n x10 ^= u<<18 | u>>>(32-18);\n\n u = x15 + x14 | 0;\n x12 ^= u<<7 | u>>>(32-7);\n u = x12 + x15 | 0;\n x13 ^= u<<9 | u>>>(32-9);\n u = x13 + x12 | 0;\n x14 ^= u<<13 | u>>>(32-13);\n u = x14 + x13 | 0;\n x15 ^= u<<18 | u>>>(32-18);\n }\n x0 = x0 + j0 | 0;\n x1 = x1 + j1 | 0;\n x2 = x2 + j2 | 0;\n x3 = x3 + j3 | 0;\n x4 = x4 + j4 | 0;\n x5 = x5 + j5 | 0;\n x6 = x6 + j6 | 0;\n x7 = x7 + j7 | 0;\n x8 = x8 + j8 | 0;\n x9 = x9 + j9 | 0;\n x10 = x10 + j10 | 0;\n x11 = x11 + j11 | 0;\n x12 = x12 + j12 | 0;\n x13 = x13 + j13 | 0;\n x14 = x14 + j14 | 0;\n x15 = x15 + j15 | 0;\n\n o[ 0] = x0 >>> 0 & 0xff;\n o[ 1] = x0 >>> 8 & 0xff;\n o[ 2] = x0 >>> 16 & 0xff;\n o[ 3] = x0 >>> 24 & 0xff;\n\n o[ 4] = x1 >>> 0 & 0xff;\n o[ 5] = x1 >>> 8 & 0xff;\n o[ 6] = x1 >>> 16 & 0xff;\n o[ 7] = x1 >>> 24 & 0xff;\n\n o[ 8] = x2 >>> 0 & 0xff;\n o[ 9] = x2 >>> 8 & 0xff;\n o[10] = x2 >>> 16 & 0xff;\n o[11] = x2 >>> 24 & 0xff;\n\n o[12] = x3 >>> 0 & 0xff;\n o[13] = x3 >>> 8 & 0xff;\n o[14] = x3 >>> 16 & 0xff;\n o[15] = x3 >>> 24 & 0xff;\n\n o[16] = x4 >>> 0 & 0xff;\n o[17] = x4 >>> 8 & 0xff;\n o[18] = x4 >>> 16 & 0xff;\n o[19] = x4 >>> 24 & 0xff;\n\n o[20] = x5 >>> 0 & 0xff;\n o[21] = x5 >>> 8 & 0xff;\n o[22] = x5 >>> 16 & 0xff;\n o[23] = x5 >>> 24 & 0xff;\n\n o[24] = x6 >>> 0 & 0xff;\n o[25] = x6 >>> 8 & 0xff;\n o[26] = x6 >>> 16 & 0xff;\n o[27] = x6 >>> 24 & 0xff;\n\n o[28] = x7 >>> 0 & 0xff;\n o[29] = x7 >>> 8 & 0xff;\n o[30] = x7 >>> 16 & 0xff;\n o[31] = x7 >>> 24 & 0xff;\n\n o[32] = x8 >>> 0 & 0xff;\n o[33] = x8 >>> 8 & 0xff;\n o[34] = x8 >>> 16 & 0xff;\n o[35] = x8 >>> 24 & 0xff;\n\n o[36] = x9 >>> 0 & 0xff;\n o[37] = x9 >>> 8 & 0xff;\n o[38] = x9 >>> 16 & 0xff;\n o[39] = x9 >>> 24 & 0xff;\n\n o[40] = x10 >>> 0 & 0xff;\n o[41] = x10 >>> 8 & 0xff;\n o[42] = x10 >>> 16 & 0xff;\n o[43] = x10 >>> 24 & 0xff;\n\n o[44] = x11 >>> 0 & 0xff;\n o[45] = x11 >>> 8 & 0xff;\n o[46] = x11 >>> 16 & 0xff;\n o[47] = x11 >>> 24 & 0xff;\n\n o[48] = x12 >>> 0 & 0xff;\n o[49] = x12 >>> 8 & 0xff;\n o[50] = x12 >>> 16 & 0xff;\n o[51] = x12 >>> 24 & 0xff;\n\n o[52] = x13 >>> 0 & 0xff;\n o[53] = x13 >>> 8 & 0xff;\n o[54] = x13 >>> 16 & 0xff;\n o[55] = x13 >>> 24 & 0xff;\n\n o[56] = x14 >>> 0 & 0xff;\n o[57] = x14 >>> 8 & 0xff;\n o[58] = x14 >>> 16 & 0xff;\n o[59] = x14 >>> 24 & 0xff;\n\n o[60] = x15 >>> 0 & 0xff;\n o[61] = x15 >>> 8 & 0xff;\n o[62] = x15 >>> 16 & 0xff;\n o[63] = x15 >>> 24 & 0xff;\n}\n\nfunction core_hsalsa20(o,p,k,c) {\n var j0 = c[ 0] & 0xff | (c[ 1] & 0xff)<<8 | (c[ 2] & 0xff)<<16 | (c[ 3] & 0xff)<<24,\n j1 = k[ 0] & 0xff | (k[ 1] & 0xff)<<8 | (k[ 2] & 0xff)<<16 | (k[ 3] & 0xff)<<24,\n j2 = k[ 4] & 0xff | (k[ 5] & 0xff)<<8 | (k[ 6] & 0xff)<<16 | (k[ 7] & 0xff)<<24,\n j3 = k[ 8] & 0xff | (k[ 9] & 0xff)<<8 | (k[10] & 0xff)<<16 | (k[11] & 0xff)<<24,\n j4 = k[12] & 0xff | (k[13] & 0xff)<<8 | (k[14] & 0xff)<<16 | (k[15] & 0xff)<<24,\n j5 = c[ 4] & 0xff | (c[ 5] & 0xff)<<8 | (c[ 6] & 0xff)<<16 | (c[ 7] & 0xff)<<24,\n j6 = p[ 0] & 0xff | (p[ 1] & 0xff)<<8 | (p[ 2] & 0xff)<<16 | (p[ 3] & 0xff)<<24,\n j7 = p[ 4] & 0xff | (p[ 5] & 0xff)<<8 | (p[ 6] & 0xff)<<16 | (p[ 7] & 0xff)<<24,\n j8 = p[ 8] & 0xff | (p[ 9] & 0xff)<<8 | (p[10] & 0xff)<<16 | (p[11] & 0xff)<<24,\n j9 = p[12] & 0xff | (p[13] & 0xff)<<8 | (p[14] & 0xff)<<16 | (p[15] & 0xff)<<24,\n j10 = c[ 8] & 0xff | (c[ 9] & 0xff)<<8 | (c[10] & 0xff)<<16 | (c[11] & 0xff)<<24,\n j11 = k[16] & 0xff | (k[17] & 0xff)<<8 | (k[18] & 0xff)<<16 | (k[19] & 0xff)<<24,\n j12 = k[20] & 0xff | (k[21] & 0xff)<<8 | (k[22] & 0xff)<<16 | (k[23] & 0xff)<<24,\n j13 = k[24] & 0xff | (k[25] & 0xff)<<8 | (k[26] & 0xff)<<16 | (k[27] & 0xff)<<24,\n j14 = k[28] & 0xff | (k[29] & 0xff)<<8 | (k[30] & 0xff)<<16 | (k[31] & 0xff)<<24,\n j15 = c[12] & 0xff | (c[13] & 0xff)<<8 | (c[14] & 0xff)<<16 | (c[15] & 0xff)<<24;\n\n var x0 = j0, x1 = j1, x2 = j2, x3 = j3, x4 = j4, x5 = j5, x6 = j6, x7 = j7,\n x8 = j8, x9 = j9, x10 = j10, x11 = j11, x12 = j12, x13 = j13, x14 = j14,\n x15 = j15, u;\n\n for (var i = 0; i < 20; i += 2) {\n u = x0 + x12 | 0;\n x4 ^= u<<7 | u>>>(32-7);\n u = x4 + x0 | 0;\n x8 ^= u<<9 | u>>>(32-9);\n u = x8 + x4 | 0;\n x12 ^= u<<13 | u>>>(32-13);\n u = x12 + x8 | 0;\n x0 ^= u<<18 | u>>>(32-18);\n\n u = x5 + x1 | 0;\n x9 ^= u<<7 | u>>>(32-7);\n u = x9 + x5 | 0;\n x13 ^= u<<9 | u>>>(32-9);\n u = x13 + x9 | 0;\n x1 ^= u<<13 | u>>>(32-13);\n u = x1 + x13 | 0;\n x5 ^= u<<18 | u>>>(32-18);\n\n u = x10 + x6 | 0;\n x14 ^= u<<7 | u>>>(32-7);\n u = x14 + x10 | 0;\n x2 ^= u<<9 | u>>>(32-9);\n u = x2 + x14 | 0;\n x6 ^= u<<13 | u>>>(32-13);\n u = x6 + x2 | 0;\n x10 ^= u<<18 | u>>>(32-18);\n\n u = x15 + x11 | 0;\n x3 ^= u<<7 | u>>>(32-7);\n u = x3 + x15 | 0;\n x7 ^= u<<9 | u>>>(32-9);\n u = x7 + x3 | 0;\n x11 ^= u<<13 | u>>>(32-13);\n u = x11 + x7 | 0;\n x15 ^= u<<18 | u>>>(32-18);\n\n u = x0 + x3 | 0;\n x1 ^= u<<7 | u>>>(32-7);\n u = x1 + x0 | 0;\n x2 ^= u<<9 | u>>>(32-9);\n u = x2 + x1 | 0;\n x3 ^= u<<13 | u>>>(32-13);\n u = x3 + x2 | 0;\n x0 ^= u<<18 | u>>>(32-18);\n\n u = x5 + x4 | 0;\n x6 ^= u<<7 | u>>>(32-7);\n u = x6 + x5 | 0;\n x7 ^= u<<9 | u>>>(32-9);\n u = x7 + x6 | 0;\n x4 ^= u<<13 | u>>>(32-13);\n u = x4 + x7 | 0;\n x5 ^= u<<18 | u>>>(32-18);\n\n u = x10 + x9 | 0;\n x11 ^= u<<7 | u>>>(32-7);\n u = x11 + x10 | 0;\n x8 ^= u<<9 | u>>>(32-9);\n u = x8 + x11 | 0;\n x9 ^= u<<13 | u>>>(32-13);\n u = x9 + x8 | 0;\n x10 ^= u<<18 | u>>>(32-18);\n\n u = x15 + x14 | 0;\n x12 ^= u<<7 | u>>>(32-7);\n u = x12 + x15 | 0;\n x13 ^= u<<9 | u>>>(32-9);\n u = x13 + x12 | 0;\n x14 ^= u<<13 | u>>>(32-13);\n u = x14 + x13 | 0;\n x15 ^= u<<18 | u>>>(32-18);\n }\n\n o[ 0] = x0 >>> 0 & 0xff;\n o[ 1] = x0 >>> 8 & 0xff;\n o[ 2] = x0 >>> 16 & 0xff;\n o[ 3] = x0 >>> 24 & 0xff;\n\n o[ 4] = x5 >>> 0 & 0xff;\n o[ 5] = x5 >>> 8 & 0xff;\n o[ 6] = x5 >>> 16 & 0xff;\n o[ 7] = x5 >>> 24 & 0xff;\n\n o[ 8] = x10 >>> 0 & 0xff;\n o[ 9] = x10 >>> 8 & 0xff;\n o[10] = x10 >>> 16 & 0xff;\n o[11] = x10 >>> 24 & 0xff;\n\n o[12] = x15 >>> 0 & 0xff;\n o[13] = x15 >>> 8 & 0xff;\n o[14] = x15 >>> 16 & 0xff;\n o[15] = x15 >>> 24 & 0xff;\n\n o[16] = x6 >>> 0 & 0xff;\n o[17] = x6 >>> 8 & 0xff;\n o[18] = x6 >>> 16 & 0xff;\n o[19] = x6 >>> 24 & 0xff;\n\n o[20] = x7 >>> 0 & 0xff;\n o[21] = x7 >>> 8 & 0xff;\n o[22] = x7 >>> 16 & 0xff;\n o[23] = x7 >>> 24 & 0xff;\n\n o[24] = x8 >>> 0 & 0xff;\n o[25] = x8 >>> 8 & 0xff;\n o[26] = x8 >>> 16 & 0xff;\n o[27] = x8 >>> 24 & 0xff;\n\n o[28] = x9 >>> 0 & 0xff;\n o[29] = x9 >>> 8 & 0xff;\n o[30] = x9 >>> 16 & 0xff;\n o[31] = x9 >>> 24 & 0xff;\n}\n\nfunction crypto_core_salsa20(out,inp,k,c) {\n core_salsa20(out,inp,k,c);\n}\n\nfunction crypto_core_hsalsa20(out,inp,k,c) {\n core_hsalsa20(out,inp,k,c);\n}\n\nvar sigma = new Uint8Array([101, 120, 112, 97, 110, 100, 32, 51, 50, 45, 98, 121, 116, 101, 32, 107]);\n // \"expand 32-byte k\"\n\nfunction crypto_stream_salsa20_xor(c,cpos,m,mpos,b,n,k) {\n var z = new Uint8Array(16), x = new Uint8Array(64);\n var u, i;\n for (i = 0; i < 16; i++) z[i] = 0;\n for (i = 0; i < 8; i++) z[i] = n[i];\n while (b >= 64) {\n crypto_core_salsa20(x,z,k,sigma);\n for (i = 0; i < 64; i++) c[cpos+i] = m[mpos+i] ^ x[i];\n u = 1;\n for (i = 8; i < 16; i++) {\n u = u + (z[i] & 0xff) | 0;\n z[i] = u & 0xff;\n u >>>= 8;\n }\n b -= 64;\n cpos += 64;\n mpos += 64;\n }\n if (b > 0) {\n crypto_core_salsa20(x,z,k,sigma);\n for (i = 0; i < b; i++) c[cpos+i] = m[mpos+i] ^ x[i];\n }\n return 0;\n}\n\nfunction crypto_stream_salsa20(c,cpos,b,n,k) {\n var z = new Uint8Array(16), x = new Uint8Array(64);\n var u, i;\n for (i = 0; i < 16; i++) z[i] = 0;\n for (i = 0; i < 8; i++) z[i] = n[i];\n while (b >= 64) {\n crypto_core_salsa20(x,z,k,sigma);\n for (i = 0; i < 64; i++) c[cpos+i] = x[i];\n u = 1;\n for (i = 8; i < 16; i++) {\n u = u + (z[i] & 0xff) | 0;\n z[i] = u & 0xff;\n u >>>= 8;\n }\n b -= 64;\n cpos += 64;\n }\n if (b > 0) {\n crypto_core_salsa20(x,z,k,sigma);\n for (i = 0; i < b; i++) c[cpos+i] = x[i];\n }\n return 0;\n}\n\nfunction crypto_stream(c,cpos,d,n,k) {\n var s = new Uint8Array(32);\n crypto_core_hsalsa20(s,n,k,sigma);\n var sn = new Uint8Array(8);\n for (var i = 0; i < 8; i++) sn[i] = n[i+16];\n return crypto_stream_salsa20(c,cpos,d,sn,s);\n}\n\nfunction crypto_stream_xor(c,cpos,m,mpos,d,n,k) {\n var s = new Uint8Array(32);\n crypto_core_hsalsa20(s,n,k,sigma);\n var sn = new Uint8Array(8);\n for (var i = 0; i < 8; i++) sn[i] = n[i+16];\n return crypto_stream_salsa20_xor(c,cpos,m,mpos,d,sn,s);\n}\n\n/*\n* Port of Andrew Moon's Poly1305-donna-16. Public domain.\n* https://github.com/floodyberry/poly1305-donna\n*/\n\nvar poly1305 = function(key) {\n this.buffer = new Uint8Array(16);\n this.r = new Uint16Array(10);\n this.h = new Uint16Array(10);\n this.pad = new Uint16Array(8);\n this.leftover = 0;\n this.fin = 0;\n\n var t0, t1, t2, t3, t4, t5, t6, t7;\n\n t0 = key[ 0] & 0xff | (key[ 1] & 0xff) << 8; this.r[0] = ( t0 ) & 0x1fff;\n t1 = key[ 2] & 0xff | (key[ 3] & 0xff) << 8; this.r[1] = ((t0 >>> 13) | (t1 << 3)) & 0x1fff;\n t2 = key[ 4] & 0xff | (key[ 5] & 0xff) << 8; this.r[2] = ((t1 >>> 10) | (t2 << 6)) & 0x1f03;\n t3 = key[ 6] & 0xff | (key[ 7] & 0xff) << 8; this.r[3] = ((t2 >>> 7) | (t3 << 9)) & 0x1fff;\n t4 = key[ 8] & 0xff | (key[ 9] & 0xff) << 8; this.r[4] = ((t3 >>> 4) | (t4 << 12)) & 0x00ff;\n this.r[5] = ((t4 >>> 1)) & 0x1ffe;\n t5 = key[10] & 0xff | (key[11] & 0xff) << 8; this.r[6] = ((t4 >>> 14) | (t5 << 2)) & 0x1fff;\n t6 = key[12] & 0xff | (key[13] & 0xff) << 8; this.r[7] = ((t5 >>> 11) | (t6 << 5)) & 0x1f81;\n t7 = key[14] & 0xff | (key[15] & 0xff) << 8; this.r[8] = ((t6 >>> 8) | (t7 << 8)) & 0x1fff;\n this.r[9] = ((t7 >>> 5)) & 0x007f;\n\n this.pad[0] = key[16] & 0xff | (key[17] & 0xff) << 8;\n this.pad[1] = key[18] & 0xff | (key[19] & 0xff) << 8;\n this.pad[2] = key[20] & 0xff | (key[21] & 0xff) << 8;\n this.pad[3] = key[22] & 0xff | (key[23] & 0xff) << 8;\n this.pad[4] = key[24] & 0xff | (key[25] & 0xff) << 8;\n this.pad[5] = key[26] & 0xff | (key[27] & 0xff) << 8;\n this.pad[6] = key[28] & 0xff | (key[29] & 0xff) << 8;\n this.pad[7] = key[30] & 0xff | (key[31] & 0xff) << 8;\n};\n\npoly1305.prototype.blocks = function(m, mpos, bytes) {\n var hibit = this.fin ? 0 : (1 << 11);\n var t0, t1, t2, t3, t4, t5, t6, t7, c;\n var d0, d1, d2, d3, d4, d5, d6, d7, d8, d9;\n\n var h0 = this.h[0],\n h1 = this.h[1],\n h2 = this.h[2],\n h3 = this.h[3],\n h4 = this.h[4],\n h5 = this.h[5],\n h6 = this.h[6],\n h7 = this.h[7],\n h8 = this.h[8],\n h9 = this.h[9];\n\n var r0 = this.r[0],\n r1 = this.r[1],\n r2 = this.r[2],\n r3 = this.r[3],\n r4 = this.r[4],\n r5 = this.r[5],\n r6 = this.r[6],\n r7 = this.r[7],\n r8 = this.r[8],\n r9 = this.r[9];\n\n while (bytes >= 16) {\n t0 = m[mpos+ 0] & 0xff | (m[mpos+ 1] & 0xff) << 8; h0 += ( t0 ) & 0x1fff;\n t1 = m[mpos+ 2] & 0xff | (m[mpos+ 3] & 0xff) << 8; h1 += ((t0 >>> 13) | (t1 << 3)) & 0x1fff;\n t2 = m[mpos+ 4] & 0xff | (m[mpos+ 5] & 0xff) << 8; h2 += ((t1 >>> 10) | (t2 << 6)) & 0x1fff;\n t3 = m[mpos+ 6] & 0xff | (m[mpos+ 7] & 0xff) << 8; h3 += ((t2 >>> 7) | (t3 << 9)) & 0x1fff;\n t4 = m[mpos+ 8] & 0xff | (m[mpos+ 9] & 0xff) << 8; h4 += ((t3 >>> 4) | (t4 << 12)) & 0x1fff;\n h5 += ((t4 >>> 1)) & 0x1fff;\n t5 = m[mpos+10] & 0xff | (m[mpos+11] & 0xff) << 8; h6 += ((t4 >>> 14) | (t5 << 2)) & 0x1fff;\n t6 = m[mpos+12] & 0xff | (m[mpos+13] & 0xff) << 8; h7 += ((t5 >>> 11) | (t6 << 5)) & 0x1fff;\n t7 = m[mpos+14] & 0xff | (m[mpos+15] & 0xff) << 8; h8 += ((t6 >>> 8) | (t7 << 8)) & 0x1fff;\n h9 += ((t7 >>> 5)) | hibit;\n\n c = 0;\n\n d0 = c;\n d0 += h0 * r0;\n d0 += h1 * (5 * r9);\n d0 += h2 * (5 * r8);\n d0 += h3 * (5 * r7);\n d0 += h4 * (5 * r6);\n c = (d0 >>> 13); d0 &= 0x1fff;\n d0 += h5 * (5 * r5);\n d0 += h6 * (5 * r4);\n d0 += h7 * (5 * r3);\n d0 += h8 * (5 * r2);\n d0 += h9 * (5 * r1);\n c += (d0 >>> 13); d0 &= 0x1fff;\n\n d1 = c;\n d1 += h0 * r1;\n d1 += h1 * r0;\n d1 += h2 * (5 * r9);\n d1 += h3 * (5 * r8);\n d1 += h4 * (5 * r7);\n c = (d1 >>> 13); d1 &= 0x1fff;\n d1 += h5 * (5 * r6);\n d1 += h6 * (5 * r5);\n d1 += h7 * (5 * r4);\n d1 += h8 * (5 * r3);\n d1 += h9 * (5 * r2);\n c += (d1 >>> 13); d1 &= 0x1fff;\n\n d2 = c;\n d2 += h0 * r2;\n d2 += h1 * r1;\n d2 += h2 * r0;\n d2 += h3 * (5 * r9);\n d2 += h4 * (5 * r8);\n c = (d2 >>> 13); d2 &= 0x1fff;\n d2 += h5 * (5 * r7);\n d2 += h6 * (5 * r6);\n d2 += h7 * (5 * r5);\n d2 += h8 * (5 * r4);\n d2 += h9 * (5 * r3);\n c += (d2 >>> 13); d2 &= 0x1fff;\n\n d3 = c;\n d3 += h0 * r3;\n d3 += h1 * r2;\n d3 += h2 * r1;\n d3 += h3 * r0;\n d3 += h4 * (5 * r9);\n c = (d3 >>> 13); d3 &= 0x1fff;\n d3 += h5 * (5 * r8);\n d3 += h6 * (5 * r7);\n d3 += h7 * (5 * r6);\n d3 += h8 * (5 * r5);\n d3 += h9 * (5 * r4);\n c += (d3 >>> 13); d3 &= 0x1fff;\n\n d4 = c;\n d4 += h0 * r4;\n d4 += h1 * r3;\n d4 += h2 * r2;\n d4 += h3 * r1;\n d4 += h4 * r0;\n c = (d4 >>> 13); d4 &= 0x1fff;\n d4 += h5 * (5 * r9);\n d4 += h6 * (5 * r8);\n d4 += h7 * (5 * r7);\n d4 += h8 * (5 * r6);\n d4 += h9 * (5 * r5);\n c += (d4 >>> 13); d4 &= 0x1fff;\n\n d5 = c;\n d5 += h0 * r5;\n d5 += h1 * r4;\n d5 += h2 * r3;\n d5 += h3 * r2;\n d5 += h4 * r1;\n c = (d5 >>> 13); d5 &= 0x1fff;\n d5 += h5 * r0;\n d5 += h6 * (5 * r9);\n d5 += h7 * (5 * r8);\n d5 += h8 * (5 * r7);\n d5 += h9 * (5 * r6);\n c += (d5 >>> 13); d5 &= 0x1fff;\n\n d6 = c;\n d6 += h0 * r6;\n d6 += h1 * r5;\n d6 += h2 * r4;\n d6 += h3 * r3;\n d6 += h4 * r2;\n c = (d6 >>> 13); d6 &= 0x1fff;\n d6 += h5 * r1;\n d6 += h6 * r0;\n d6 += h7 * (5 * r9);\n d6 += h8 * (5 * r8);\n d6 += h9 * (5 * r7);\n c += (d6 >>> 13); d6 &= 0x1fff;\n\n d7 = c;\n d7 += h0 * r7;\n d7 += h1 * r6;\n d7 += h2 * r5;\n d7 += h3 * r4;\n d7 += h4 * r3;\n c = (d7 >>> 13); d7 &= 0x1fff;\n d7 += h5 * r2;\n d7 += h6 * r1;\n d7 += h7 * r0;\n d7 += h8 * (5 * r9);\n d7 += h9 * (5 * r8);\n c += (d7 >>> 13); d7 &= 0x1fff;\n\n d8 = c;\n d8 += h0 * r8;\n d8 += h1 * r7;\n d8 += h2 * r6;\n d8 += h3 * r5;\n d8 += h4 * r4;\n c = (d8 >>> 13); d8 &= 0x1fff;\n d8 += h5 * r3;\n d8 += h6 * r2;\n d8 += h7 * r1;\n d8 += h8 * r0;\n d8 += h9 * (5 * r9);\n c += (d8 >>> 13); d8 &= 0x1fff;\n\n d9 = c;\n d9 += h0 * r9;\n d9 += h1 * r8;\n d9 += h2 * r7;\n d9 += h3 * r6;\n d9 += h4 * r5;\n c = (d9 >>> 13); d9 &= 0x1fff;\n d9 += h5 * r4;\n d9 += h6 * r3;\n d9 += h7 * r2;\n d9 += h8 * r1;\n d9 += h9 * r0;\n c += (d9 >>> 13); d9 &= 0x1fff;\n\n c = (((c << 2) + c)) | 0;\n c = (c + d0) | 0;\n d0 = c & 0x1fff;\n c = (c >>> 13);\n d1 += c;\n\n h0 = d0;\n h1 = d1;\n h2 = d2;\n h3 = d3;\n h4 = d4;\n h5 = d5;\n h6 = d6;\n h7 = d7;\n h8 = d8;\n h9 = d9;\n\n mpos += 16;\n bytes -= 16;\n }\n this.h[0] = h0;\n this.h[1] = h1;\n this.h[2] = h2;\n this.h[3] = h3;\n this.h[4] = h4;\n this.h[5] = h5;\n this.h[6] = h6;\n this.h[7] = h7;\n this.h[8] = h8;\n this.h[9] = h9;\n};\n\npoly1305.prototype.finish = function(mac, macpos) {\n var g = new Uint16Array(10);\n var c, mask, f, i;\n\n if (this.leftover) {\n i = this.leftover;\n this.buffer[i++] = 1;\n for (; i < 16; i++) this.buffer[i] = 0;\n this.fin = 1;\n this.blocks(this.buffer, 0, 16);\n }\n\n c = this.h[1] >>> 13;\n this.h[1] &= 0x1fff;\n for (i = 2; i < 10; i++) {\n this.h[i] += c;\n c = this.h[i] >>> 13;\n this.h[i] &= 0x1fff;\n }\n this.h[0] += (c * 5);\n c = this.h[0] >>> 13;\n this.h[0] &= 0x1fff;\n this.h[1] += c;\n c = this.h[1] >>> 13;\n this.h[1] &= 0x1fff;\n this.h[2] += c;\n\n g[0] = this.h[0] + 5;\n c = g[0] >>> 13;\n g[0] &= 0x1fff;\n for (i = 1; i < 10; i++) {\n g[i] = this.h[i] + c;\n c = g[i] >>> 13;\n g[i] &= 0x1fff;\n }\n g[9] -= (1 << 13);\n\n mask = (c ^ 1) - 1;\n for (i = 0; i < 10; i++) g[i] &= mask;\n mask = ~mask;\n for (i = 0; i < 10; i++) this.h[i] = (this.h[i] & mask) | g[i];\n\n this.h[0] = ((this.h[0] ) | (this.h[1] << 13) ) & 0xffff;\n this.h[1] = ((this.h[1] >>> 3) | (this.h[2] << 10) ) & 0xffff;\n this.h[2] = ((this.h[2] >>> 6) | (this.h[3] << 7) ) & 0xffff;\n this.h[3] = ((this.h[3] >>> 9) | (this.h[4] << 4) ) & 0xffff;\n this.h[4] = ((this.h[4] >>> 12) | (this.h[5] << 1) | (this.h[6] << 14)) & 0xffff;\n this.h[5] = ((this.h[6] >>> 2) | (this.h[7] << 11) ) & 0xffff;\n this.h[6] = ((this.h[7] >>> 5) | (this.h[8] << 8) ) & 0xffff;\n this.h[7] = ((this.h[8] >>> 8) | (this.h[9] << 5) ) & 0xffff;\n\n f = this.h[0] + this.pad[0];\n this.h[0] = f & 0xffff;\n for (i = 1; i < 8; i++) {\n f = (((this.h[i] + this.pad[i]) | 0) + (f >>> 16)) | 0;\n this.h[i] = f & 0xffff;\n }\n\n mac[macpos+ 0] = (this.h[0] >>> 0) & 0xff;\n mac[macpos+ 1] = (this.h[0] >>> 8) & 0xff;\n mac[macpos+ 2] = (this.h[1] >>> 0) & 0xff;\n mac[macpos+ 3] = (this.h[1] >>> 8) & 0xff;\n mac[macpos+ 4] = (this.h[2] >>> 0) & 0xff;\n mac[macpos+ 5] = (this.h[2] >>> 8) & 0xff;\n mac[macpos+ 6] = (this.h[3] >>> 0) & 0xff;\n mac[macpos+ 7] = (this.h[3] >>> 8) & 0xff;\n mac[macpos+ 8] = (this.h[4] >>> 0) & 0xff;\n mac[macpos+ 9] = (this.h[4] >>> 8) & 0xff;\n mac[macpos+10] = (this.h[5] >>> 0) & 0xff;\n mac[macpos+11] = (this.h[5] >>> 8) & 0xff;\n mac[macpos+12] = (this.h[6] >>> 0) & 0xff;\n mac[macpos+13] = (this.h[6] >>> 8) & 0xff;\n mac[macpos+14] = (this.h[7] >>> 0) & 0xff;\n mac[macpos+15] = (this.h[7] >>> 8) & 0xff;\n};\n\npoly1305.prototype.update = function(m, mpos, bytes) {\n var i, want;\n\n if (this.leftover) {\n want = (16 - this.leftover);\n if (want > bytes)\n want = bytes;\n for (i = 0; i < want; i++)\n this.buffer[this.leftover + i] = m[mpos+i];\n bytes -= want;\n mpos += want;\n this.leftover += want;\n if (this.leftover < 16)\n return;\n this.blocks(this.buffer, 0, 16);\n this.leftover = 0;\n }\n\n if (bytes >= 16) {\n want = bytes - (bytes % 16);\n this.blocks(m, mpos, want);\n mpos += want;\n bytes -= want;\n }\n\n if (bytes) {\n for (i = 0; i < bytes; i++)\n this.buffer[this.leftover + i] = m[mpos+i];\n this.leftover += bytes;\n }\n};\n\nfunction crypto_onetimeauth(out, outpos, m, mpos, n, k) {\n var s = new poly1305(k);\n s.update(m, mpos, n);\n s.finish(out, outpos);\n return 0;\n}\n\nfunction crypto_onetimeauth_verify(h, hpos, m, mpos, n, k) {\n var x = new Uint8Array(16);\n crypto_onetimeauth(x,0,m,mpos,n,k);\n return crypto_verify_16(h,hpos,x,0);\n}\n\nfunction crypto_secretbox(c,m,d,n,k) {\n var i;\n if (d < 32) return -1;\n crypto_stream_xor(c,0,m,0,d,n,k);\n crypto_onetimeauth(c, 16, c, 32, d - 32, c);\n for (i = 0; i < 16; i++) c[i] = 0;\n return 0;\n}\n\nfunction crypto_secretbox_open(m,c,d,n,k) {\n var i;\n var x = new Uint8Array(32);\n if (d < 32) return -1;\n crypto_stream(x,0,32,n,k);\n if (crypto_onetimeauth_verify(c, 16,c, 32,d - 32,x) !== 0) return -1;\n crypto_stream_xor(m,0,c,0,d,n,k);\n for (i = 0; i < 32; i++) m[i] = 0;\n return 0;\n}\n\nfunction set25519(r, a) {\n var i;\n for (i = 0; i < 16; i++) r[i] = a[i]|0;\n}\n\nfunction car25519(o) {\n var i, v, c = 1;\n for (i = 0; i < 16; i++) {\n v = o[i] + c + 65535;\n c = Math.floor(v / 65536);\n o[i] = v - c * 65536;\n }\n o[0] += c-1 + 37 * (c-1);\n}\n\nfunction sel25519(p, q, b) {\n var t, c = ~(b-1);\n for (var i = 0; i < 16; i++) {\n t = c & (p[i] ^ q[i]);\n p[i] ^= t;\n q[i] ^= t;\n }\n}\n\nfunction pack25519(o, n) {\n var i, j, b;\n var m = gf(), t = gf();\n for (i = 0; i < 16; i++) t[i] = n[i];\n car25519(t);\n car25519(t);\n car25519(t);\n for (j = 0; j < 2; j++) {\n m[0] = t[0] - 0xffed;\n for (i = 1; i < 15; i++) {\n m[i] = t[i] - 0xffff - ((m[i-1]>>16) & 1);\n m[i-1] &= 0xffff;\n }\n m[15] = t[15] - 0x7fff - ((m[14]>>16) & 1);\n b = (m[15]>>16) & 1;\n m[14] &= 0xffff;\n sel25519(t, m, 1-b);\n }\n for (i = 0; i < 16; i++) {\n o[2*i] = t[i] & 0xff;\n o[2*i+1] = t[i]>>8;\n }\n}\n\nfunction neq25519(a, b) {\n var c = new Uint8Array(32), d = new Uint8Array(32);\n pack25519(c, a);\n pack25519(d, b);\n return crypto_verify_32(c, 0, d, 0);\n}\n\nfunction par25519(a) {\n var d = new Uint8Array(32);\n pack25519(d, a);\n return d[0] & 1;\n}\n\nfunction unpack25519(o, n) {\n var i;\n for (i = 0; i < 16; i++) o[i] = n[2*i] + (n[2*i+1] << 8);\n o[15] &= 0x7fff;\n}\n\nfunction A(o, a, b) {\n for (var i = 0; i < 16; i++) o[i] = a[i] + b[i];\n}\n\nfunction Z(o, a, b) {\n for (var i = 0; i < 16; i++) o[i] = a[i] - b[i];\n}\n\nfunction M(o, a, b) {\n var v, c,\n t0 = 0, t1 = 0, t2 = 0, t3 = 0, t4 = 0, t5 = 0, t6 = 0, t7 = 0,\n t8 = 0, t9 = 0, t10 = 0, t11 = 0, t12 = 0, t13 = 0, t14 = 0, t15 = 0,\n t16 = 0, t17 = 0, t18 = 0, t19 = 0, t20 = 0, t21 = 0, t22 = 0, t23 = 0,\n t24 = 0, t25 = 0, t26 = 0, t27 = 0, t28 = 0, t29 = 0, t30 = 0,\n b0 = b[0],\n b1 = b[1],\n b2 = b[2],\n b3 = b[3],\n b4 = b[4],\n b5 = b[5],\n b6 = b[6],\n b7 = b[7],\n b8 = b[8],\n b9 = b[9],\n b10 = b[10],\n b11 = b[11],\n b12 = b[12],\n b13 = b[13],\n b14 = b[14],\n b15 = b[15];\n\n v = a[0];\n t0 += v * b0;\n t1 += v * b1;\n t2 += v * b2;\n t3 += v * b3;\n t4 += v * b4;\n t5 += v * b5;\n t6 += v * b6;\n t7 += v * b7;\n t8 += v * b8;\n t9 += v * b9;\n t10 += v * b10;\n t11 += v * b11;\n t12 += v * b12;\n t13 += v * b13;\n t14 += v * b14;\n t15 += v * b15;\n v = a[1];\n t1 += v * b0;\n t2 += v * b1;\n t3 += v * b2;\n t4 += v * b3;\n t5 += v * b4;\n t6 += v * b5;\n t7 += v * b6;\n t8 += v * b7;\n t9 += v * b8;\n t10 += v * b9;\n t11 += v * b10;\n t12 += v * b11;\n t13 += v * b12;\n t14 += v * b13;\n t15 += v * b14;\n t16 += v * b15;\n v = a[2];\n t2 += v * b0;\n t3 += v * b1;\n t4 += v * b2;\n t5 += v * b3;\n t6 += v * b4;\n t7 += v * b5;\n t8 += v * b6;\n t9 += v * b7;\n t10 += v * b8;\n t11 += v * b9;\n t12 += v * b10;\n t13 += v * b11;\n t14 += v * b12;\n t15 += v * b13;\n t16 += v * b14;\n t17 += v * b15;\n v = a[3];\n t3 += v * b0;\n t4 += v * b1;\n t5 += v * b2;\n t6 += v * b3;\n t7 += v * b4;\n t8 += v * b5;\n t9 += v * b6;\n t10 += v * b7;\n t11 += v * b8;\n t12 += v * b9;\n t13 += v * b10;\n t14 += v * b11;\n t15 += v * b12;\n t16 += v * b13;\n t17 += v * b14;\n t18 += v * b15;\n v = a[4];\n t4 += v * b0;\n t5 += v * b1;\n t6 += v * b2;\n t7 += v * b3;\n t8 += v * b4;\n t9 += v * b5;\n t10 += v * b6;\n t11 += v * b7;\n t12 += v * b8;\n t13 += v * b9;\n t14 += v * b10;\n t15 += v * b11;\n t16 += v * b12;\n t17 += v * b13;\n t18 += v * b14;\n t19 += v * b15;\n v = a[5];\n t5 += v * b0;\n t6 += v * b1;\n t7 += v * b2;\n t8 += v * b3;\n t9 += v * b4;\n t10 += v * b5;\n t11 += v * b6;\n t12 += v * b7;\n t13 += v * b8;\n t14 += v * b9;\n t15 += v * b10;\n t16 += v * b11;\n t17 += v * b12;\n t18 += v * b13;\n t19 += v * b14;\n t20 += v * b15;\n v = a[6];\n t6 += v * b0;\n t7 += v * b1;\n t8 += v * b2;\n t9 += v * b3;\n t10 += v * b4;\n t11 += v * b5;\n t12 += v * b6;\n t13 += v * b7;\n t14 += v * b8;\n t15 += v * b9;\n t16 += v * b10;\n t17 += v * b11;\n t18 += v * b12;\n t19 += v * b13;\n t20 += v * b14;\n t21 += v * b15;\n v = a[7];\n t7 += v * b0;\n t8 += v * b1;\n t9 += v * b2;\n t10 += v * b3;\n t11 += v * b4;\n t12 += v * b5;\n t13 += v * b6;\n t14 += v * b7;\n t15 += v * b8;\n t16 += v * b9;\n t17 += v * b10;\n t18 += v * b11;\n t19 += v * b12;\n t20 += v * b13;\n t21 += v * b14;\n t22 += v * b15;\n v = a[8];\n t8 += v * b0;\n t9 += v * b1;\n t10 += v * b2;\n t11 += v * b3;\n t12 += v * b4;\n t13 += v * b5;\n t14 += v * b6;\n t15 += v * b7;\n t16 += v * b8;\n t17 += v * b9;\n t18 += v * b10;\n t19 += v * b11;\n t20 += v * b12;\n t21 += v * b13;\n t22 += v * b14;\n t23 += v * b15;\n v = a[9];\n t9 += v * b0;\n t10 += v * b1;\n t11 += v * b2;\n t12 += v * b3;\n t13 += v * b4;\n t14 += v * b5;\n t15 += v * b6;\n t16 += v * b7;\n t17 += v * b8;\n t18 += v * b9;\n t19 += v * b10;\n t20 += v * b11;\n t21 += v * b12;\n t22 += v * b13;\n t23 += v * b14;\n t24 += v * b15;\n v = a[10];\n t10 += v * b0;\n t11 += v * b1;\n t12 += v * b2;\n t13 += v * b3;\n t14 += v * b4;\n t15 += v * b5;\n t16 += v * b6;\n t17 += v * b7;\n t18 += v * b8;\n t19 += v * b9;\n t20 += v * b10;\n t21 += v * b11;\n t22 += v * b12;\n t23 += v * b13;\n t24 += v * b14;\n t25 += v * b15;\n v = a[11];\n t11 += v * b0;\n t12 += v * b1;\n t13 += v * b2;\n t14 += v * b3;\n t15 += v * b4;\n t16 += v * b5;\n t17 += v * b6;\n t18 += v * b7;\n t19 += v * b8;\n t20 += v * b9;\n t21 += v * b10;\n t22 += v * b11;\n t23 += v * b12;\n t24 += v * b13;\n t25 += v * b14;\n t26 += v * b15;\n v = a[12];\n t12 += v * b0;\n t13 += v * b1;\n t14 += v * b2;\n t15 += v * b3;\n t16 += v * b4;\n t17 += v * b5;\n t18 += v * b6;\n t19 += v * b7;\n t20 += v * b8;\n t21 += v * b9;\n t22 += v * b10;\n t23 += v * b11;\n t24 += v * b12;\n t25 += v * b13;\n t26 += v * b14;\n t27 += v * b15;\n v = a[13];\n t13 += v * b0;\n t14 += v * b1;\n t15 += v * b2;\n t16 += v * b3;\n t17 += v * b4;\n t18 += v * b5;\n t19 += v * b6;\n t20 += v * b7;\n t21 += v * b8;\n t22 += v * b9;\n t23 += v * b10;\n t24 += v * b11;\n t25 += v * b12;\n t26 += v * b13;\n t27 += v * b14;\n t28 += v * b15;\n v = a[14];\n t14 += v * b0;\n t15 += v * b1;\n t16 += v * b2;\n t17 += v * b3;\n t18 += v * b4;\n t19 += v * b5;\n t20 += v * b6;\n t21 += v * b7;\n t22 += v * b8;\n t23 += v * b9;\n t24 += v * b10;\n t25 += v * b11;\n t26 += v * b12;\n t27 += v * b13;\n t28 += v * b14;\n t29 += v * b15;\n v = a[15];\n t15 += v * b0;\n t16 += v * b1;\n t17 += v * b2;\n t18 += v * b3;\n t19 += v * b4;\n t20 += v * b5;\n t21 += v * b6;\n t22 += v * b7;\n t23 += v * b8;\n t24 += v * b9;\n t25 += v * b10;\n t26 += v * b11;\n t27 += v * b12;\n t28 += v * b13;\n t29 += v * b14;\n t30 += v * b15;\n\n t0 += 38 * t16;\n t1 += 38 * t17;\n t2 += 38 * t18;\n t3 += 38 * t19;\n t4 += 38 * t20;\n t5 += 38 * t21;\n t6 += 38 * t22;\n t7 += 38 * t23;\n t8 += 38 * t24;\n t9 += 38 * t25;\n t10 += 38 * t26;\n t11 += 38 * t27;\n t12 += 38 * t28;\n t13 += 38 * t29;\n t14 += 38 * t30;\n // t15 left as is\n\n // first car\n c = 1;\n v = t0 + c + 65535; c = Math.floor(v / 65536); t0 = v - c * 65536;\n v = t1 + c + 65535; c = Math.floor(v / 65536); t1 = v - c * 65536;\n v = t2 + c + 65535; c = Math.floor(v / 65536); t2 = v - c * 65536;\n v = t3 + c + 65535; c = Math.floor(v / 65536); t3 = v - c * 65536;\n v = t4 + c + 65535; c = Math.floor(v / 65536); t4 = v - c * 65536;\n v = t5 + c + 65535; c = Math.floor(v / 65536); t5 = v - c * 65536;\n v = t6 + c + 65535; c = Math.floor(v / 65536); t6 = v - c * 65536;\n v = t7 + c + 65535; c = Math.floor(v / 65536); t7 = v - c * 65536;\n v = t8 + c + 65535; c = Math.floor(v / 65536); t8 = v - c * 65536;\n v = t9 + c + 65535; c = Math.floor(v / 65536); t9 = v - c * 65536;\n v = t10 + c + 65535; c = Math.floor(v / 65536); t10 = v - c * 65536;\n v = t11 + c + 65535; c = Math.floor(v / 65536); t11 = v - c * 65536;\n v = t12 + c + 65535; c = Math.floor(v / 65536); t12 = v - c * 65536;\n v = t13 + c + 65535; c = Math.floor(v / 65536); t13 = v - c * 65536;\n v = t14 + c + 65535; c = Math.floor(v / 65536); t14 = v - c * 65536;\n v = t15 + c + 65535; c = Math.floor(v / 65536); t15 = v - c * 65536;\n t0 += c-1 + 37 * (c-1);\n\n // second car\n c = 1;\n v = t0 + c + 65535; c = Math.floor(v / 65536); t0 = v - c * 65536;\n v = t1 + c + 65535; c = Math.floor(v / 65536); t1 = v - c * 65536;\n v = t2 + c + 65535; c = Math.floor(v / 65536); t2 = v - c * 65536;\n v = t3 + c + 65535; c = Math.floor(v / 65536); t3 = v - c * 65536;\n v = t4 + c + 65535; c = Math.floor(v / 65536); t4 = v - c * 65536;\n v = t5 + c + 65535; c = Math.floor(v / 65536); t5 = v - c * 65536;\n v = t6 + c + 65535; c = Math.floor(v / 65536); t6 = v - c * 65536;\n v = t7 + c + 65535; c = Math.floor(v / 65536); t7 = v - c * 65536;\n v = t8 + c + 65535; c = Math.floor(v / 65536); t8 = v - c * 65536;\n v = t9 + c + 65535; c = Math.floor(v / 65536); t9 = v - c * 65536;\n v = t10 + c + 65535; c = Math.floor(v / 65536); t10 = v - c * 65536;\n v = t11 + c + 65535; c = Math.floor(v / 65536); t11 = v - c * 65536;\n v = t12 + c + 65535; c = Math.floor(v / 65536); t12 = v - c * 65536;\n v = t13 + c + 65535; c = Math.floor(v / 65536); t13 = v - c * 65536;\n v = t14 + c + 65535; c = Math.floor(v / 65536); t14 = v - c * 65536;\n v = t15 + c + 65535; c = Math.floor(v / 65536); t15 = v - c * 65536;\n t0 += c-1 + 37 * (c-1);\n\n o[ 0] = t0;\n o[ 1] = t1;\n o[ 2] = t2;\n o[ 3] = t3;\n o[ 4] = t4;\n o[ 5] = t5;\n o[ 6] = t6;\n o[ 7] = t7;\n o[ 8] = t8;\n o[ 9] = t9;\n o[10] = t10;\n o[11] = t11;\n o[12] = t12;\n o[13] = t13;\n o[14] = t14;\n o[15] = t15;\n}\n\nfunction S(o, a) {\n M(o, a, a);\n}\n\nfunction inv25519(o, i) {\n var c = gf();\n var a;\n for (a = 0; a < 16; a++) c[a] = i[a];\n for (a = 253; a >= 0; a--) {\n S(c, c);\n if(a !== 2 && a !== 4) M(c, c, i);\n }\n for (a = 0; a < 16; a++) o[a] = c[a];\n}\n\nfunction pow2523(o, i) {\n var c = gf();\n var a;\n for (a = 0; a < 16; a++) c[a] = i[a];\n for (a = 250; a >= 0; a--) {\n S(c, c);\n if(a !== 1) M(c, c, i);\n }\n for (a = 0; a < 16; a++) o[a] = c[a];\n}\n\nfunction crypto_scalarmult(q, n, p) {\n var z = new Uint8Array(32);\n var x = new Float64Array(80), r, i;\n var a = gf(), b = gf(), c = gf(),\n d = gf(), e = gf(), f = gf();\n for (i = 0; i < 31; i++) z[i] = n[i];\n z[31]=(n[31]&127)|64;\n z[0]&=248;\n unpack25519(x,p);\n for (i = 0; i < 16; i++) {\n b[i]=x[i];\n d[i]=a[i]=c[i]=0;\n }\n a[0]=d[0]=1;\n for (i=254; i>=0; --i) {\n r=(z[i>>>3]>>>(i&7))&1;\n sel25519(a,b,r);\n sel25519(c,d,r);\n A(e,a,c);\n Z(a,a,c);\n A(c,b,d);\n Z(b,b,d);\n S(d,e);\n S(f,a);\n M(a,c,a);\n M(c,b,e);\n A(e,a,c);\n Z(a,a,c);\n S(b,a);\n Z(c,d,f);\n M(a,c,_121665);\n A(a,a,d);\n M(c,c,a);\n M(a,d,f);\n M(d,b,x);\n S(b,e);\n sel25519(a,b,r);\n sel25519(c,d,r);\n }\n for (i = 0; i < 16; i++) {\n x[i+16]=a[i];\n x[i+32]=c[i];\n x[i+48]=b[i];\n x[i+64]=d[i];\n }\n var x32 = x.subarray(32);\n var x16 = x.subarray(16);\n inv25519(x32,x32);\n M(x16,x16,x32);\n pack25519(q,x16);\n return 0;\n}\n\nfunction crypto_scalarmult_base(q, n) {\n return crypto_scalarmult(q, n, _9);\n}\n\nfunction crypto_box_keypair(y, x) {\n randombytes(x, 32);\n return crypto_scalarmult_base(y, x);\n}\n\nfunction crypto_box_beforenm(k, y, x) {\n var s = new Uint8Array(32);\n crypto_scalarmult(s, x, y);\n return crypto_core_hsalsa20(k, _0, s, sigma);\n}\n\nvar crypto_box_afternm = crypto_secretbox;\nvar crypto_box_open_afternm = crypto_secretbox_open;\n\nfunction crypto_box(c, m, d, n, y, x) {\n var k = new Uint8Array(32);\n crypto_box_beforenm(k, y, x);\n return crypto_box_afternm(c, m, d, n, k);\n}\n\nfunction crypto_box_open(m, c, d, n, y, x) {\n var k = new Uint8Array(32);\n crypto_box_beforenm(k, y, x);\n return crypto_box_open_afternm(m, c, d, n, k);\n}\n\nvar K = [\n 0x428a2f98, 0xd728ae22, 0x71374491, 0x23ef65cd,\n 0xb5c0fbcf, 0xec4d3b2f, 0xe9b5dba5, 0x8189dbbc,\n 0x3956c25b, 0xf348b538, 0x59f111f1, 0xb605d019,\n 0x923f82a4, 0xaf194f9b, 0xab1c5ed5, 0xda6d8118,\n 0xd807aa98, 0xa3030242, 0x12835b01, 0x45706fbe,\n 0x243185be, 0x4ee4b28c, 0x550c7dc3, 0xd5ffb4e2,\n 0x72be5d74, 0xf27b896f, 0x80deb1fe, 0x3b1696b1,\n 0x9bdc06a7, 0x25c71235, 0xc19bf174, 0xcf692694,\n 0xe49b69c1, 0x9ef14ad2, 0xefbe4786, 0x384f25e3,\n 0x0fc19dc6, 0x8b8cd5b5, 0x240ca1cc, 0x77ac9c65,\n 0x2de92c6f, 0x592b0275, 0x4a7484aa, 0x6ea6e483,\n 0x5cb0a9dc, 0xbd41fbd4, 0x76f988da, 0x831153b5,\n 0x983e5152, 0xee66dfab, 0xa831c66d, 0x2db43210,\n 0xb00327c8, 0x98fb213f, 0xbf597fc7, 0xbeef0ee4,\n 0xc6e00bf3, 0x3da88fc2, 0xd5a79147, 0x930aa725,\n 0x06ca6351, 0xe003826f, 0x14292967, 0x0a0e6e70,\n 0x27b70a85, 0x46d22ffc, 0x2e1b2138, 0x5c26c926,\n 0x4d2c6dfc, 0x5ac42aed, 0x53380d13, 0x9d95b3df,\n 0x650a7354, 0x8baf63de, 0x766a0abb, 0x3c77b2a8,\n 0x81c2c92e, 0x47edaee6, 0x92722c85, 0x1482353b,\n 0xa2bfe8a1, 0x4cf10364, 0xa81a664b, 0xbc423001,\n 0xc24b8b70, 0xd0f89791, 0xc76c51a3, 0x0654be30,\n 0xd192e819, 0xd6ef5218, 0xd6990624, 0x5565a910,\n 0xf40e3585, 0x5771202a, 0x106aa070, 0x32bbd1b8,\n 0x19a4c116, 0xb8d2d0c8, 0x1e376c08, 0x5141ab53,\n 0x2748774c, 0xdf8eeb99, 0x34b0bcb5, 0xe19b48a8,\n 0x391c0cb3, 0xc5c95a63, 0x4ed8aa4a, 0xe3418acb,\n 0x5b9cca4f, 0x7763e373, 0x682e6ff3, 0xd6b2b8a3,\n 0x748f82ee, 0x5defb2fc, 0x78a5636f, 0x43172f60,\n 0x84c87814, 0xa1f0ab72, 0x8cc70208, 0x1a6439ec,\n 0x90befffa, 0x23631e28, 0xa4506ceb, 0xde82bde9,\n 0xbef9a3f7, 0xb2c67915, 0xc67178f2, 0xe372532b,\n 0xca273ece, 0xea26619c, 0xd186b8c7, 0x21c0c207,\n 0xeada7dd6, 0xcde0eb1e, 0xf57d4f7f, 0xee6ed178,\n 0x06f067aa, 0x72176fba, 0x0a637dc5, 0xa2c898a6,\n 0x113f9804, 0xbef90dae, 0x1b710b35, 0x131c471b,\n 0x28db77f5, 0x23047d84, 0x32caab7b, 0x40c72493,\n 0x3c9ebe0a, 0x15c9bebc, 0x431d67c4, 0x9c100d4c,\n 0x4cc5d4be, 0xcb3e42b6, 0x597f299c, 0xfc657e2a,\n 0x5fcb6fab, 0x3ad6faec, 0x6c44198c, 0x4a475817\n];\n\nfunction crypto_hashblocks_hl(hh, hl, m, n) {\n var wh = new Int32Array(16), wl = new Int32Array(16),\n bh0, bh1, bh2, bh3, bh4, bh5, bh6, bh7,\n bl0, bl1, bl2, bl3, bl4, bl5, bl6, bl7,\n th, tl, i, j, h, l, a, b, c, d;\n\n var ah0 = hh[0],\n ah1 = hh[1],\n ah2 = hh[2],\n ah3 = hh[3],\n ah4 = hh[4],\n ah5 = hh[5],\n ah6 = hh[6],\n ah7 = hh[7],\n\n al0 = hl[0],\n al1 = hl[1],\n al2 = hl[2],\n al3 = hl[3],\n al4 = hl[4],\n al5 = hl[5],\n al6 = hl[6],\n al7 = hl[7];\n\n var pos = 0;\n while (n >= 128) {\n for (i = 0; i < 16; i++) {\n j = 8 * i + pos;\n wh[i] = (m[j+0] << 24) | (m[j+1] << 16) | (m[j+2] << 8) | m[j+3];\n wl[i] = (m[j+4] << 24) | (m[j+5] << 16) | (m[j+6] << 8) | m[j+7];\n }\n for (i = 0; i < 80; i++) {\n bh0 = ah0;\n bh1 = ah1;\n bh2 = ah2;\n bh3 = ah3;\n bh4 = ah4;\n bh5 = ah5;\n bh6 = ah6;\n bh7 = ah7;\n\n bl0 = al0;\n bl1 = al1;\n bl2 = al2;\n bl3 = al3;\n bl4 = al4;\n bl5 = al5;\n bl6 = al6;\n bl7 = al7;\n\n // add\n h = ah7;\n l = al7;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n // Sigma1\n h = ((ah4 >>> 14) | (al4 << (32-14))) ^ ((ah4 >>> 18) | (al4 << (32-18))) ^ ((al4 >>> (41-32)) | (ah4 << (32-(41-32))));\n l = ((al4 >>> 14) | (ah4 << (32-14))) ^ ((al4 >>> 18) | (ah4 << (32-18))) ^ ((ah4 >>> (41-32)) | (al4 << (32-(41-32))));\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // Ch\n h = (ah4 & ah5) ^ (~ah4 & ah6);\n l = (al4 & al5) ^ (~al4 & al6);\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // K\n h = K[i*2];\n l = K[i*2+1];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // w\n h = wh[i%16];\n l = wl[i%16];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n th = c & 0xffff | d << 16;\n tl = a & 0xffff | b << 16;\n\n // add\n h = th;\n l = tl;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n // Sigma0\n h = ((ah0 >>> 28) | (al0 << (32-28))) ^ ((al0 >>> (34-32)) | (ah0 << (32-(34-32)))) ^ ((al0 >>> (39-32)) | (ah0 << (32-(39-32))));\n l = ((al0 >>> 28) | (ah0 << (32-28))) ^ ((ah0 >>> (34-32)) | (al0 << (32-(34-32)))) ^ ((ah0 >>> (39-32)) | (al0 << (32-(39-32))));\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // Maj\n h = (ah0 & ah1) ^ (ah0 & ah2) ^ (ah1 & ah2);\n l = (al0 & al1) ^ (al0 & al2) ^ (al1 & al2);\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n bh7 = (c & 0xffff) | (d << 16);\n bl7 = (a & 0xffff) | (b << 16);\n\n // add\n h = bh3;\n l = bl3;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = th;\n l = tl;\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n bh3 = (c & 0xffff) | (d << 16);\n bl3 = (a & 0xffff) | (b << 16);\n\n ah1 = bh0;\n ah2 = bh1;\n ah3 = bh2;\n ah4 = bh3;\n ah5 = bh4;\n ah6 = bh5;\n ah7 = bh6;\n ah0 = bh7;\n\n al1 = bl0;\n al2 = bl1;\n al3 = bl2;\n al4 = bl3;\n al5 = bl4;\n al6 = bl5;\n al7 = bl6;\n al0 = bl7;\n\n if (i%16 === 15) {\n for (j = 0; j < 16; j++) {\n // add\n h = wh[j];\n l = wl[j];\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = wh[(j+9)%16];\n l = wl[(j+9)%16];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // sigma0\n th = wh[(j+1)%16];\n tl = wl[(j+1)%16];\n h = ((th >>> 1) | (tl << (32-1))) ^ ((th >>> 8) | (tl << (32-8))) ^ (th >>> 7);\n l = ((tl >>> 1) | (th << (32-1))) ^ ((tl >>> 8) | (th << (32-8))) ^ ((tl >>> 7) | (th << (32-7)));\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // sigma1\n th = wh[(j+14)%16];\n tl = wl[(j+14)%16];\n h = ((th >>> 19) | (tl << (32-19))) ^ ((tl >>> (61-32)) | (th << (32-(61-32)))) ^ (th >>> 6);\n l = ((tl >>> 19) | (th << (32-19))) ^ ((th >>> (61-32)) | (tl << (32-(61-32)))) ^ ((tl >>> 6) | (th << (32-6)));\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n wh[j] = (c & 0xffff) | (d << 16);\n wl[j] = (a & 0xffff) | (b << 16);\n }\n }\n }\n\n // add\n h = ah0;\n l = al0;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[0];\n l = hl[0];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[0] = ah0 = (c & 0xffff) | (d << 16);\n hl[0] = al0 = (a & 0xffff) | (b << 16);\n\n h = ah1;\n l = al1;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[1];\n l = hl[1];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[1] = ah1 = (c & 0xffff) | (d << 16);\n hl[1] = al1 = (a & 0xffff) | (b << 16);\n\n h = ah2;\n l = al2;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[2];\n l = hl[2];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[2] = ah2 = (c & 0xffff) | (d << 16);\n hl[2] = al2 = (a & 0xffff) | (b << 16);\n\n h = ah3;\n l = al3;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[3];\n l = hl[3];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[3] = ah3 = (c & 0xffff) | (d << 16);\n hl[3] = al3 = (a & 0xffff) | (b << 16);\n\n h = ah4;\n l = al4;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[4];\n l = hl[4];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[4] = ah4 = (c & 0xffff) | (d << 16);\n hl[4] = al4 = (a & 0xffff) | (b << 16);\n\n h = ah5;\n l = al5;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[5];\n l = hl[5];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[5] = ah5 = (c & 0xffff) | (d << 16);\n hl[5] = al5 = (a & 0xffff) | (b << 16);\n\n h = ah6;\n l = al6;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[6];\n l = hl[6];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[6] = ah6 = (c & 0xffff) | (d << 16);\n hl[6] = al6 = (a & 0xffff) | (b << 16);\n\n h = ah7;\n l = al7;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[7];\n l = hl[7];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[7] = ah7 = (c & 0xffff) | (d << 16);\n hl[7] = al7 = (a & 0xffff) | (b << 16);\n\n pos += 128;\n n -= 128;\n }\n\n return n;\n}\n\nfunction crypto_hash(out, m, n) {\n var hh = new Int32Array(8),\n hl = new Int32Array(8),\n x = new Uint8Array(256),\n i, b = n;\n\n hh[0] = 0x6a09e667;\n hh[1] = 0xbb67ae85;\n hh[2] = 0x3c6ef372;\n hh[3] = 0xa54ff53a;\n hh[4] = 0x510e527f;\n hh[5] = 0x9b05688c;\n hh[6] = 0x1f83d9ab;\n hh[7] = 0x5be0cd19;\n\n hl[0] = 0xf3bcc908;\n hl[1] = 0x84caa73b;\n hl[2] = 0xfe94f82b;\n hl[3] = 0x5f1d36f1;\n hl[4] = 0xade682d1;\n hl[5] = 0x2b3e6c1f;\n hl[6] = 0xfb41bd6b;\n hl[7] = 0x137e2179;\n\n crypto_hashblocks_hl(hh, hl, m, n);\n n %= 128;\n\n for (i = 0; i < n; i++) x[i] = m[b-n+i];\n x[n] = 128;\n\n n = 256-128*(n<112?1:0);\n x[n-9] = 0;\n ts64(x, n-8, (b / 0x20000000) | 0, b << 3);\n crypto_hashblocks_hl(hh, hl, x, n);\n\n for (i = 0; i < 8; i++) ts64(out, 8*i, hh[i], hl[i]);\n\n return 0;\n}\n\nfunction add(p, q) {\n var a = gf(), b = gf(), c = gf(),\n d = gf(), e = gf(), f = gf(),\n g = gf(), h = gf(), t = gf();\n\n Z(a, p[1], p[0]);\n Z(t, q[1], q[0]);\n M(a, a, t);\n A(b, p[0], p[1]);\n A(t, q[0], q[1]);\n M(b, b, t);\n M(c, p[3], q[3]);\n M(c, c, D2);\n M(d, p[2], q[2]);\n A(d, d, d);\n Z(e, b, a);\n Z(f, d, c);\n A(g, d, c);\n A(h, b, a);\n\n M(p[0], e, f);\n M(p[1], h, g);\n M(p[2], g, f);\n M(p[3], e, h);\n}\n\nfunction cswap(p, q, b) {\n var i;\n for (i = 0; i < 4; i++) {\n sel25519(p[i], q[i], b);\n }\n}\n\nfunction pack(r, p) {\n var tx = gf(), ty = gf(), zi = gf();\n inv25519(zi, p[2]);\n M(tx, p[0], zi);\n M(ty, p[1], zi);\n pack25519(r, ty);\n r[31] ^= par25519(tx) << 7;\n}\n\nfunction scalarmult(p, q, s) {\n var b, i;\n set25519(p[0], gf0);\n set25519(p[1], gf1);\n set25519(p[2], gf1);\n set25519(p[3], gf0);\n for (i = 255; i >= 0; --i) {\n b = (s[(i/8)|0] >> (i&7)) & 1;\n cswap(p, q, b);\n add(q, p);\n add(p, p);\n cswap(p, q, b);\n }\n}\n\nfunction scalarbase(p, s) {\n var q = [gf(), gf(), gf(), gf()];\n set25519(q[0], X);\n set25519(q[1], Y);\n set25519(q[2], gf1);\n M(q[3], X, Y);\n scalarmult(p, q, s);\n}\n\nfunction crypto_sign_keypair(pk, sk, seeded) {\n var d = new Uint8Array(64);\n var p = [gf(), gf(), gf(), gf()];\n var i;\n\n if (!seeded) randombytes(sk, 32);\n crypto_hash(d, sk, 32);\n d[0] &= 248;\n d[31] &= 127;\n d[31] |= 64;\n\n scalarbase(p, d);\n pack(pk, p);\n\n for (i = 0; i < 32; i++) sk[i+32] = pk[i];\n return 0;\n}\n\nvar L = new Float64Array([0xed, 0xd3, 0xf5, 0x5c, 0x1a, 0x63, 0x12, 0x58, 0xd6, 0x9c, 0xf7, 0xa2, 0xde, 0xf9, 0xde, 0x14, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x10]);\n\nfunction modL(r, x) {\n var carry, i, j, k;\n for (i = 63; i >= 32; --i) {\n carry = 0;\n for (j = i - 32, k = i - 12; j < k; ++j) {\n x[j] += carry - 16 * x[i] * L[j - (i - 32)];\n carry = Math.floor((x[j] + 128) / 256);\n x[j] -= carry * 256;\n }\n x[j] += carry;\n x[i] = 0;\n }\n carry = 0;\n for (j = 0; j < 32; j++) {\n x[j] += carry - (x[31] >> 4) * L[j];\n carry = x[j] >> 8;\n x[j] &= 255;\n }\n for (j = 0; j < 32; j++) x[j] -= carry * L[j];\n for (i = 0; i < 32; i++) {\n x[i+1] += x[i] >> 8;\n r[i] = x[i] & 255;\n }\n}\n\nfunction reduce(r) {\n var x = new Float64Array(64), i;\n for (i = 0; i < 64; i++) x[i] = r[i];\n for (i = 0; i < 64; i++) r[i] = 0;\n modL(r, x);\n}\n\n// Note: difference from C - smlen returned, not passed as argument.\nfunction crypto_sign(sm, m, n, sk) {\n var d = new Uint8Array(64), h = new Uint8Array(64), r = new Uint8Array(64);\n var i, j, x = new Float64Array(64);\n var p = [gf(), gf(), gf(), gf()];\n\n crypto_hash(d, sk, 32);\n d[0] &= 248;\n d[31] &= 127;\n d[31] |= 64;\n\n var smlen = n + 64;\n for (i = 0; i < n; i++) sm[64 + i] = m[i];\n for (i = 0; i < 32; i++) sm[32 + i] = d[32 + i];\n\n crypto_hash(r, sm.subarray(32), n+32);\n reduce(r);\n scalarbase(p, r);\n pack(sm, p);\n\n for (i = 32; i < 64; i++) sm[i] = sk[i];\n crypto_hash(h, sm, n + 64);\n reduce(h);\n\n for (i = 0; i < 64; i++) x[i] = 0;\n for (i = 0; i < 32; i++) x[i] = r[i];\n for (i = 0; i < 32; i++) {\n for (j = 0; j < 32; j++) {\n x[i+j] += h[i] * d[j];\n }\n }\n\n modL(sm.subarray(32), x);\n return smlen;\n}\n\nfunction unpackneg(r, p) {\n var t = gf(), chk = gf(), num = gf(),\n den = gf(), den2 = gf(), den4 = gf(),\n den6 = gf();\n\n set25519(r[2], gf1);\n unpack25519(r[1], p);\n S(num, r[1]);\n M(den, num, D);\n Z(num, num, r[2]);\n A(den, r[2], den);\n\n S(den2, den);\n S(den4, den2);\n M(den6, den4, den2);\n M(t, den6, num);\n M(t, t, den);\n\n pow2523(t, t);\n M(t, t, num);\n M(t, t, den);\n M(t, t, den);\n M(r[0], t, den);\n\n S(chk, r[0]);\n M(chk, chk, den);\n if (neq25519(chk, num)) M(r[0], r[0], I);\n\n S(chk, r[0]);\n M(chk, chk, den);\n if (neq25519(chk, num)) return -1;\n\n if (par25519(r[0]) === (p[31]>>7)) Z(r[0], gf0, r[0]);\n\n M(r[3], r[0], r[1]);\n return 0;\n}\n\nfunction crypto_sign_open(m, sm, n, pk) {\n var i;\n var t = new Uint8Array(32), h = new Uint8Array(64);\n var p = [gf(), gf(), gf(), gf()],\n q = [gf(), gf(), gf(), gf()];\n\n if (n < 64) return -1;\n\n if (unpackneg(q, pk)) return -1;\n\n for (i = 0; i < n; i++) m[i] = sm[i];\n for (i = 0; i < 32; i++) m[i+32] = pk[i];\n crypto_hash(h, m, n);\n reduce(h);\n scalarmult(p, q, h);\n\n scalarbase(q, sm.subarray(32));\n add(p, q);\n pack(t, p);\n\n n -= 64;\n if (crypto_verify_32(sm, 0, t, 0)) {\n for (i = 0; i < n; i++) m[i] = 0;\n return -1;\n }\n\n for (i = 0; i < n; i++) m[i] = sm[i + 64];\n return n;\n}\n\nvar crypto_secretbox_KEYBYTES = 32,\n crypto_secretbox_NONCEBYTES = 24,\n crypto_secretbox_ZEROBYTES = 32,\n crypto_secretbox_BOXZEROBYTES = 16,\n crypto_scalarmult_BYTES = 32,\n crypto_scalarmult_SCALARBYTES = 32,\n crypto_box_PUBLICKEYBYTES = 32,\n crypto_box_SECRETKEYBYTES = 32,\n crypto_box_BEFORENMBYTES = 32,\n crypto_box_NONCEBYTES = crypto_secretbox_NONCEBYTES,\n crypto_box_ZEROBYTES = crypto_secretbox_ZEROBYTES,\n crypto_box_BOXZEROBYTES = crypto_secretbox_BOXZEROBYTES,\n crypto_sign_BYTES = 64,\n crypto_sign_PUBLICKEYBYTES = 32,\n crypto_sign_SECRETKEYBYTES = 64,\n crypto_sign_SEEDBYTES = 32,\n crypto_hash_BYTES = 64;\n\nnacl.lowlevel = {\n crypto_core_hsalsa20: crypto_core_hsalsa20,\n crypto_stream_xor: crypto_stream_xor,\n crypto_stream: crypto_stream,\n crypto_stream_salsa20_xor: crypto_stream_salsa20_xor,\n crypto_stream_salsa20: crypto_stream_salsa20,\n crypto_onetimeauth: crypto_onetimeauth,\n crypto_onetimeauth_verify: crypto_onetimeauth_verify,\n crypto_verify_16: crypto_verify_16,\n crypto_verify_32: crypto_verify_32,\n crypto_secretbox: crypto_secretbox,\n crypto_secretbox_open: crypto_secretbox_open,\n crypto_scalarmult: crypto_scalarmult,\n crypto_scalarmult_base: crypto_scalarmult_base,\n crypto_box_beforenm: crypto_box_beforenm,\n crypto_box_afternm: crypto_box_afternm,\n crypto_box: crypto_box,\n crypto_box_open: crypto_box_open,\n crypto_box_keypair: crypto_box_keypair,\n crypto_hash: crypto_hash,\n crypto_sign: crypto_sign,\n crypto_sign_keypair: crypto_sign_keypair,\n crypto_sign_open: crypto_sign_open,\n\n crypto_secretbox_KEYBYTES: crypto_secretbox_KEYBYTES,\n crypto_secretbox_NONCEBYTES: crypto_secretbox_NONCEBYTES,\n crypto_secretbox_ZEROBYTES: crypto_secretbox_ZEROBYTES,\n crypto_secretbox_BOXZEROBYTES: crypto_secretbox_BOXZEROBYTES,\n crypto_scalarmult_BYTES: crypto_scalarmult_BYTES,\n crypto_scalarmult_SCALARBYTES: crypto_scalarmult_SCALARBYTES,\n crypto_box_PUBLICKEYBYTES: crypto_box_PUBLICKEYBYTES,\n crypto_box_SECRETKEYBYTES: crypto_box_SECRETKEYBYTES,\n crypto_box_BEFORENMBYTES: crypto_box_BEFORENMBYTES,\n crypto_box_NONCEBYTES: crypto_box_NONCEBYTES,\n crypto_box_ZEROBYTES: crypto_box_ZEROBYTES,\n crypto_box_BOXZEROBYTES: crypto_box_BOXZEROBYTES,\n crypto_sign_BYTES: crypto_sign_BYTES,\n crypto_sign_PUBLICKEYBYTES: crypto_sign_PUBLICKEYBYTES,\n crypto_sign_SECRETKEYBYTES: crypto_sign_SECRETKEYBYTES,\n crypto_sign_SEEDBYTES: crypto_sign_SEEDBYTES,\n crypto_hash_BYTES: crypto_hash_BYTES,\n\n gf: gf,\n D: D,\n L: L,\n pack25519: pack25519,\n unpack25519: unpack25519,\n M: M,\n A: A,\n S: S,\n Z: Z,\n pow2523: pow2523,\n add: add,\n set25519: set25519,\n modL: modL,\n scalarmult: scalarmult,\n scalarbase: scalarbase,\n};\n\n/* High-level API */\n\nfunction checkLengths(k, n) {\n if (k.length !== crypto_secretbox_KEYBYTES) throw new Error('bad key size');\n if (n.length !== crypto_secretbox_NONCEBYTES) throw new Error('bad nonce size');\n}\n\nfunction checkBoxLengths(pk, sk) {\n if (pk.length !== crypto_box_PUBLICKEYBYTES) throw new Error('bad public key size');\n if (sk.length !== crypto_box_SECRETKEYBYTES) throw new Error('bad secret key size');\n}\n\nfunction checkArrayTypes() {\n for (var i = 0; i < arguments.length; i++) {\n if (!(arguments[i] instanceof Uint8Array))\n throw new TypeError('unexpected type, use Uint8Array');\n }\n}\n\nfunction cleanup(arr) {\n for (var i = 0; i < arr.length; i++) arr[i] = 0;\n}\n\nnacl.randomBytes = function(n) {\n var b = new Uint8Array(n);\n randombytes(b, n);\n return b;\n};\n\nnacl.secretbox = function(msg, nonce, key) {\n checkArrayTypes(msg, nonce, key);\n checkLengths(key, nonce);\n var m = new Uint8Array(crypto_secretbox_ZEROBYTES + msg.length);\n var c = new Uint8Array(m.length);\n for (var i = 0; i < msg.length; i++) m[i+crypto_secretbox_ZEROBYTES] = msg[i];\n crypto_secretbox(c, m, m.length, nonce, key);\n return c.subarray(crypto_secretbox_BOXZEROBYTES);\n};\n\nnacl.secretbox.open = function(box, nonce, key) {\n checkArrayTypes(box, nonce, key);\n checkLengths(key, nonce);\n var c = new Uint8Array(crypto_secretbox_BOXZEROBYTES + box.length);\n var m = new Uint8Array(c.length);\n for (var i = 0; i < box.length; i++) c[i+crypto_secretbox_BOXZEROBYTES] = box[i];\n if (c.length < 32) return null;\n if (crypto_secretbox_open(m, c, c.length, nonce, key) !== 0) return null;\n return m.subarray(crypto_secretbox_ZEROBYTES);\n};\n\nnacl.secretbox.keyLength = crypto_secretbox_KEYBYTES;\nnacl.secretbox.nonceLength = crypto_secretbox_NONCEBYTES;\nnacl.secretbox.overheadLength = crypto_secretbox_BOXZEROBYTES;\n\nnacl.scalarMult = function(n, p) {\n checkArrayTypes(n, p);\n if (n.length !== crypto_scalarmult_SCALARBYTES) throw new Error('bad n size');\n if (p.length !== crypto_scalarmult_BYTES) throw new Error('bad p size');\n var q = new Uint8Array(crypto_scalarmult_BYTES);\n crypto_scalarmult(q, n, p);\n return q;\n};\n\nnacl.scalarMult.base = function(n) {\n checkArrayTypes(n);\n if (n.length !== crypto_scalarmult_SCALARBYTES) throw new Error('bad n size');\n var q = new Uint8Array(crypto_scalarmult_BYTES);\n crypto_scalarmult_base(q, n);\n return q;\n};\n\nnacl.scalarMult.scalarLength = crypto_scalarmult_SCALARBYTES;\nnacl.scalarMult.groupElementLength = crypto_scalarmult_BYTES;\n\nnacl.box = function(msg, nonce, publicKey, secretKey) {\n var k = nacl.box.before(publicKey, secretKey);\n return nacl.secretbox(msg, nonce, k);\n};\n\nnacl.box.before = function(publicKey, secretKey) {\n checkArrayTypes(publicKey, secretKey);\n checkBoxLengths(publicKey, secretKey);\n var k = new Uint8Array(crypto_box_BEFORENMBYTES);\n crypto_box_beforenm(k, publicKey, secretKey);\n return k;\n};\n\nnacl.box.after = nacl.secretbox;\n\nnacl.box.open = function(msg, nonce, publicKey, secretKey) {\n var k = nacl.box.before(publicKey, secretKey);\n return nacl.secretbox.open(msg, nonce, k);\n};\n\nnacl.box.open.after = nacl.secretbox.open;\n\nnacl.box.keyPair = function() {\n var pk = new Uint8Array(crypto_box_PUBLICKEYBYTES);\n var sk = new Uint8Array(crypto_box_SECRETKEYBYTES);\n crypto_box_keypair(pk, sk);\n return {publicKey: pk, secretKey: sk};\n};\n\nnacl.box.keyPair.fromSecretKey = function(secretKey) {\n checkArrayTypes(secretKey);\n if (secretKey.length !== crypto_box_SECRETKEYBYTES)\n throw new Error('bad secret key size');\n var pk = new Uint8Array(crypto_box_PUBLICKEYBYTES);\n crypto_scalarmult_base(pk, secretKey);\n return {publicKey: pk, secretKey: new Uint8Array(secretKey)};\n};\n\nnacl.box.publicKeyLength = crypto_box_PUBLICKEYBYTES;\nnacl.box.secretKeyLength = crypto_box_SECRETKEYBYTES;\nnacl.box.sharedKeyLength = crypto_box_BEFORENMBYTES;\nnacl.box.nonceLength = crypto_box_NONCEBYTES;\nnacl.box.overheadLength = nacl.secretbox.overheadLength;\n\nnacl.sign = function(msg, secretKey) {\n checkArrayTypes(msg, secretKey);\n if (secretKey.length !== crypto_sign_SECRETKEYBYTES)\n throw new Error('bad secret key size');\n var signedMsg = new Uint8Array(crypto_sign_BYTES+msg.length);\n crypto_sign(signedMsg, msg, msg.length, secretKey);\n return signedMsg;\n};\n\nnacl.sign.open = function(signedMsg, publicKey) {\n checkArrayTypes(signedMsg, publicKey);\n if (publicKey.length !== crypto_sign_PUBLICKEYBYTES)\n throw new Error('bad public key size');\n var tmp = new Uint8Array(signedMsg.length);\n var mlen = crypto_sign_open(tmp, signedMsg, signedMsg.length, publicKey);\n if (mlen < 0) return null;\n var m = new Uint8Array(mlen);\n for (var i = 0; i < m.length; i++) m[i] = tmp[i];\n return m;\n};\n\nnacl.sign.detached = function(msg, secretKey) {\n var signedMsg = nacl.sign(msg, secretKey);\n var sig = new Uint8Array(crypto_sign_BYTES);\n for (var i = 0; i < sig.length; i++) sig[i] = signedMsg[i];\n return sig;\n};\n\nnacl.sign.detached.verify = function(msg, sig, publicKey) {\n checkArrayTypes(msg, sig, publicKey);\n if (sig.length !== crypto_sign_BYTES)\n throw new Error('bad signature size');\n if (publicKey.length !== crypto_sign_PUBLICKEYBYTES)\n throw new Error('bad public key size');\n var sm = new Uint8Array(crypto_sign_BYTES + msg.length);\n var m = new Uint8Array(crypto_sign_BYTES + msg.length);\n var i;\n for (i = 0; i < crypto_sign_BYTES; i++) sm[i] = sig[i];\n for (i = 0; i < msg.length; i++) sm[i+crypto_sign_BYTES] = msg[i];\n return (crypto_sign_open(m, sm, sm.length, publicKey) >= 0);\n};\n\nnacl.sign.keyPair = function() {\n var pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);\n var sk = new Uint8Array(crypto_sign_SECRETKEYBYTES);\n crypto_sign_keypair(pk, sk);\n return {publicKey: pk, secretKey: sk};\n};\n\nnacl.sign.keyPair.fromSecretKey = function(secretKey) {\n checkArrayTypes(secretKey);\n if (secretKey.length !== crypto_sign_SECRETKEYBYTES)\n throw new Error('bad secret key size');\n var pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);\n for (var i = 0; i < pk.length; i++) pk[i] = secretKey[32+i];\n return {publicKey: pk, secretKey: new Uint8Array(secretKey)};\n};\n\nnacl.sign.keyPair.fromSeed = function(seed) {\n checkArrayTypes(seed);\n if (seed.length !== crypto_sign_SEEDBYTES)\n throw new Error('bad seed size');\n var pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);\n var sk = new Uint8Array(crypto_sign_SECRETKEYBYTES);\n for (var i = 0; i < 32; i++) sk[i] = seed[i];\n crypto_sign_keypair(pk, sk, true);\n return {publicKey: pk, secretKey: sk};\n};\n\nnacl.sign.publicKeyLength = crypto_sign_PUBLICKEYBYTES;\nnacl.sign.secretKeyLength = crypto_sign_SECRETKEYBYTES;\nnacl.sign.seedLength = crypto_sign_SEEDBYTES;\nnacl.sign.signatureLength = crypto_sign_BYTES;\n\nnacl.hash = function(msg) {\n checkArrayTypes(msg);\n var h = new Uint8Array(crypto_hash_BYTES);\n crypto_hash(h, msg, msg.length);\n return h;\n};\n\nnacl.hash.hashLength = crypto_hash_BYTES;\n\nnacl.verify = function(x, y) {\n checkArrayTypes(x, y);\n // Zero length arguments are considered not equal.\n if (x.length === 0 || y.length === 0) return false;\n if (x.length !== y.length) return false;\n return (vn(x, 0, y, 0, x.length) === 0) ? true : false;\n};\n\nnacl.setPRNG = function(fn) {\n randombytes = fn;\n};\n\n(function() {\n // Initialize PRNG if environment provides CSPRNG.\n // If not, methods calling randombytes will throw.\n var crypto = typeof self !== 'undefined' ? (self.crypto || self.msCrypto) : null;\n if (crypto && crypto.getRandomValues) {\n // Browsers.\n var QUOTA = 65536;\n nacl.setPRNG(function(x, n) {\n var i, v = new Uint8Array(n);\n for (i = 0; i < n; i += QUOTA) {\n crypto.getRandomValues(v.subarray(i, i + Math.min(n - i, QUOTA)));\n }\n for (i = 0; i < n; i++) x[i] = v[i];\n cleanup(v);\n });\n } else if (typeof require !== 'undefined') {\n // Node.js.\n crypto = require('crypto');\n if (crypto && crypto.randomBytes) {\n nacl.setPRNG(function(x, n) {\n var i, v = crypto.randomBytes(n);\n for (i = 0; i < n; i++) x[i] = v[i];\n cleanup(v);\n });\n }\n }\n})();\n\n})(typeof module !== 'undefined' && module.exports ? module.exports : (self.nacl = self.nacl || {}));\n","module.exports = require('./pusher-with-encryption').default;\n","/* (ignored) */","export default function encode(s: any): string {\n return btoa(utob(s));\n}\n\nvar fromCharCode = String.fromCharCode;\n\nvar b64chars =\n 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';\nvar b64tab = {};\n\nfor (var i = 0, l = b64chars.length; i < l; i++) {\n b64tab[b64chars.charAt(i)] = i;\n}\n\nvar cb_utob = function(c) {\n var cc = c.charCodeAt(0);\n return cc < 0x80\n ? c\n : cc < 0x800\n ? fromCharCode(0xc0 | (cc >>> 6)) + fromCharCode(0x80 | (cc & 0x3f))\n : fromCharCode(0xe0 | ((cc >>> 12) & 0x0f)) +\n fromCharCode(0x80 | ((cc >>> 6) & 0x3f)) +\n fromCharCode(0x80 | (cc & 0x3f));\n};\n\nvar utob = function(u) {\n return u.replace(/[^\\x00-\\x7F]/g, cb_utob);\n};\n\nvar cb_encode = function(ccc) {\n var padlen = [0, 2, 1][ccc.length % 3];\n var ord =\n (ccc.charCodeAt(0) << 16) |\n ((ccc.length > 1 ? ccc.charCodeAt(1) : 0) << 8) |\n (ccc.length > 2 ? ccc.charCodeAt(2) : 0);\n var chars = [\n b64chars.charAt(ord >>> 18),\n b64chars.charAt((ord >>> 12) & 63),\n padlen >= 2 ? '=' : b64chars.charAt((ord >>> 6) & 63),\n padlen >= 1 ? '=' : b64chars.charAt(ord & 63)\n ];\n return chars.join('');\n};\n\nvar btoa =\n global.btoa ||\n function(b) {\n return b.replace(/[\\s\\S]{1,3}/g, cb_encode);\n };\n","import TimedCallback from './timed_callback';\nimport { Delay, Scheduler, Canceller } from './scheduling';\n\nabstract class Timer {\n protected clear: Canceller;\n protected timer: number | void;\n\n constructor(\n set: Scheduler,\n clear: Canceller,\n delay: Delay,\n callback: TimedCallback\n ) {\n this.clear = clear;\n this.timer = set(() => {\n if (this.timer) {\n this.timer = callback(this.timer);\n }\n }, delay);\n }\n\n /** Returns whether the timer is still running.\n *\n * @return {Boolean}\n */\n isRunning(): boolean {\n return this.timer !== null;\n }\n\n /** Aborts a timer when it's running. */\n ensureAborted() {\n if (this.timer) {\n this.clear(this.timer);\n this.timer = null;\n }\n }\n}\n\nexport default Timer;\n","import Timer from './abstract_timer';\nimport TimedCallback from './timed_callback';\nimport { Delay } from './scheduling';\n\n// We need to bind clear functions this way to avoid exceptions on IE8\nfunction clearTimeout(timer) {\n global.clearTimeout(timer);\n}\nfunction clearInterval(timer) {\n global.clearInterval(timer);\n}\n\n/** Cross-browser compatible one-off timer abstraction.\n *\n * @param {Number} delay\n * @param {Function} callback\n */\nexport class OneOffTimer extends Timer {\n constructor(delay: Delay, callback: TimedCallback) {\n super(setTimeout, clearTimeout, delay, function(timer) {\n callback();\n return null;\n });\n }\n}\n\n/** Cross-browser compatible periodic timer abstraction.\n *\n * @param {Number} delay\n * @param {Function} callback\n */\nexport class PeriodicTimer extends Timer {\n constructor(delay: Delay, callback: TimedCallback) {\n super(setInterval, clearInterval, delay, function(timer) {\n callback();\n return timer;\n });\n }\n}\n","import * as Collections from './utils/collections';\nimport TimedCallback from './utils/timers/timed_callback';\nimport { OneOffTimer, PeriodicTimer } from './utils/timers';\n\nvar Util = {\n now(): number {\n if (Date.now) {\n return Date.now();\n } else {\n return new Date().valueOf();\n }\n },\n\n defer(callback: TimedCallback): OneOffTimer {\n return new OneOffTimer(0, callback);\n },\n\n /** Builds a function that will proxy a method call to its first argument.\n *\n * Allows partial application of arguments, so additional arguments are\n * prepended to the argument list.\n *\n * @param {String} name method name\n * @return {Function} proxy function\n */\n method(name: string, ...args: any[]): Function {\n var boundArguments = Array.prototype.slice.call(arguments, 1);\n return function(object) {\n return object[name].apply(object, boundArguments.concat(arguments));\n };\n }\n};\n\nexport default Util;\n","import base64encode from '../base64';\nimport Util from '../util';\n\n/** Merges multiple objects into the target argument.\n *\n * For properties that are plain Objects, performs a deep-merge. For the\n * rest it just copies the value of the property.\n *\n * To extend prototypes use it as following:\n * Pusher.Util.extend(Target.prototype, Base.prototype)\n *\n * You can also use it to merge objects without altering them:\n * Pusher.Util.extend({}, object1, object2)\n *\n * @param {Object} target\n * @return {Object} the target argument\n */\nexport function extend(target: any, ...sources: any[]): T {\n for (var i = 0; i < sources.length; i++) {\n var extensions = sources[i];\n for (var property in extensions) {\n if (\n extensions[property] &&\n extensions[property].constructor &&\n extensions[property].constructor === Object\n ) {\n target[property] = extend(target[property] || {}, extensions[property]);\n } else {\n target[property] = extensions[property];\n }\n }\n }\n return target;\n}\n\nexport function stringify(): string {\n var m = ['Pusher'];\n for (var i = 0; i < arguments.length; i++) {\n if (typeof arguments[i] === 'string') {\n m.push(arguments[i]);\n } else {\n m.push(safeJSONStringify(arguments[i]));\n }\n }\n return m.join(' : ');\n}\n\nexport function arrayIndexOf(array: any[], item: any): number {\n // MSIE doesn't have array.indexOf\n var nativeIndexOf = Array.prototype.indexOf;\n if (array === null) {\n return -1;\n }\n if (nativeIndexOf && array.indexOf === nativeIndexOf) {\n return array.indexOf(item);\n }\n for (var i = 0, l = array.length; i < l; i++) {\n if (array[i] === item) {\n return i;\n }\n }\n return -1;\n}\n\n/** Applies a function f to all properties of an object.\n *\n * Function f gets 3 arguments passed:\n * - element from the object\n * - key of the element\n * - reference to the object\n *\n * @param {Object} object\n * @param {Function} f\n */\nexport function objectApply(object: any, f: Function) {\n for (var key in object) {\n if (Object.prototype.hasOwnProperty.call(object, key)) {\n f(object[key], key, object);\n }\n }\n}\n\n/** Return a list of objects own proerty keys\n *\n * @param {Object} object\n * @returns {Array}\n */\nexport function keys(object: any): string[] {\n var keys = [];\n objectApply(object, function(_, key) {\n keys.push(key);\n });\n return keys;\n}\n\n/** Return a list of object's own property values\n *\n * @param {Object} object\n * @returns {Array}\n */\nexport function values(object: any): any[] {\n var values = [];\n objectApply(object, function(value) {\n values.push(value);\n });\n return values;\n}\n\n/** Applies a function f to all elements of an array.\n *\n * Function f gets 3 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function apply(array: any[], f: Function, context?: any) {\n for (var i = 0; i < array.length; i++) {\n f.call(context || global, array[i], i, array);\n }\n}\n\n/** Maps all elements of the array and returns the result.\n *\n * Function f gets 4 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n * - reference to the destination array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function map(array: any[], f: Function): any[] {\n var result = [];\n for (var i = 0; i < array.length; i++) {\n result.push(f(array[i], i, array, result));\n }\n return result;\n}\n\n/** Maps all elements of the object and returns the result.\n *\n * Function f gets 4 arguments passed:\n * - element from the object\n * - key of the element\n * - reference to the source object\n * - reference to the destination object\n *\n * @param {Object} object\n * @param {Function} f\n */\nexport function mapObject(object: any, f: Function): any {\n var result = {};\n objectApply(object, function(value, key) {\n result[key] = f(value);\n });\n return result;\n}\n\n/** Filters elements of the array using a test function.\n *\n * Function test gets 4 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n * - reference to the destination array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function filter(array: any[], test: Function): any[] {\n test =\n test ||\n function(value) {\n return !!value;\n };\n\n var result = [];\n for (var i = 0; i < array.length; i++) {\n if (test(array[i], i, array, result)) {\n result.push(array[i]);\n }\n }\n return result;\n}\n\n/** Filters properties of the object using a test function.\n *\n * Function test gets 4 arguments passed:\n * - element from the object\n * - key of the element\n * - reference to the source object\n * - reference to the destination object\n *\n * @param {Object} object\n * @param {Function} f\n */\nexport function filterObject(object: Object, test: Function) {\n var result = {};\n objectApply(object, function(value, key) {\n if ((test && test(value, key, object, result)) || Boolean(value)) {\n result[key] = value;\n }\n });\n return result;\n}\n\n/** Flattens an object into a two-dimensional array.\n *\n * @param {Object} object\n * @return {Array} resulting array of [key, value] pairs\n */\nexport function flatten(object: Object): any[] {\n var result = [];\n objectApply(object, function(value, key) {\n result.push([key, value]);\n });\n return result;\n}\n\n/** Checks whether any element of the array passes the test.\n *\n * Function test gets 3 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function any(array: any[], test: Function): boolean {\n for (var i = 0; i < array.length; i++) {\n if (test(array[i], i, array)) {\n return true;\n }\n }\n return false;\n}\n\n/** Checks whether all elements of the array pass the test.\n *\n * Function test gets 3 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function all(array: any[], test: Function): boolean {\n for (var i = 0; i < array.length; i++) {\n if (!test(array[i], i, array)) {\n return false;\n }\n }\n return true;\n}\n\nexport function encodeParamsObject(data): string {\n return mapObject(data, function(value) {\n if (typeof value === 'object') {\n value = safeJSONStringify(value);\n }\n return encodeURIComponent(base64encode(value.toString()));\n });\n}\n\nexport function buildQueryString(data: any): string {\n var params = filterObject(data, function(value) {\n return value !== undefined;\n });\n\n var query = map(\n flatten(encodeParamsObject(params)),\n Util.method('join', '=')\n ).join('&');\n\n return query;\n}\n\n/**\n * See https://github.com/douglascrockford/JSON-js/blob/master/cycle.js\n *\n * Remove circular references from an object. Required for JSON.stringify in\n * React Native, which tends to blow up a lot.\n *\n * @param {any} object\n * @return {any} Decycled object\n */\nexport function decycleObject(object: any): any {\n var objects = [],\n paths = [];\n\n return (function derez(value, path) {\n var i, name, nu;\n\n switch (typeof value) {\n case 'object':\n if (!value) {\n return null;\n }\n for (i = 0; i < objects.length; i += 1) {\n if (objects[i] === value) {\n return { $ref: paths[i] };\n }\n }\n\n objects.push(value);\n paths.push(path);\n\n if (Object.prototype.toString.apply(value) === '[object Array]') {\n nu = [];\n for (i = 0; i < value.length; i += 1) {\n nu[i] = derez(value[i], path + '[' + i + ']');\n }\n } else {\n nu = {};\n for (name in value) {\n if (Object.prototype.hasOwnProperty.call(value, name)) {\n nu[name] = derez(\n value[name],\n path + '[' + JSON.stringify(name) + ']'\n );\n }\n }\n }\n return nu;\n case 'number':\n case 'string':\n case 'boolean':\n return value;\n }\n })(object, '$');\n}\n\n/**\n * Provides a cross-browser and cross-platform way to safely stringify objects\n * into JSON. This is particularly necessary for ReactNative, where circular JSON\n * structures throw an exception.\n *\n * @param {any} source The object to stringify\n * @return {string} The serialized output.\n */\nexport function safeJSONStringify(source: any): string {\n try {\n return JSON.stringify(source);\n } catch (e) {\n return JSON.stringify(decycleObject(source));\n }\n}\n","import {\n ChannelAuthorizationOptions,\n UserAuthenticationOptions\n} from './auth/options';\nimport { AuthTransport } from './config';\n\nexport interface DefaultConfig {\n VERSION: string;\n PROTOCOL: number;\n wsPort: number;\n wssPort: number;\n wsPath: string;\n httpHost: string;\n httpPort: number;\n httpsPort: number;\n httpPath: string;\n stats_host: string;\n authEndpoint: string;\n authTransport: AuthTransport;\n activityTimeout: number;\n pongTimeout: number;\n unavailableTimeout: number;\n userAuthentication: UserAuthenticationOptions;\n channelAuthorization: ChannelAuthorizationOptions;\n\n cdn_http?: string;\n cdn_https?: string;\n dependency_suffix?: string;\n}\n\nvar Defaults: DefaultConfig = {\n VERSION: VERSION,\n PROTOCOL: 7,\n\n wsPort: 80,\n wssPort: 443,\n wsPath: '',\n // DEPRECATED: SockJS fallback parameters\n httpHost: 'sockjs.pusher.com',\n httpPort: 80,\n httpsPort: 443,\n httpPath: '/pusher',\n // DEPRECATED: Stats\n stats_host: 'stats.pusher.com',\n // DEPRECATED: Other settings\n authEndpoint: '/pusher/auth',\n authTransport: 'ajax',\n activityTimeout: 120000,\n pongTimeout: 30000,\n unavailableTimeout: 10000,\n userAuthentication: {\n endpoint: '/pusher/user-auth',\n transport: 'ajax'\n },\n channelAuthorization: {\n endpoint: '/pusher/auth',\n transport: 'ajax'\n },\n\n // CDN configuration\n cdn_http: CDN_HTTP,\n cdn_https: CDN_HTTPS,\n dependency_suffix: DEPENDENCY_SUFFIX\n};\n\nexport default Defaults;\n","import Defaults from '../defaults';\nimport { default as URLScheme, URLSchemeParams } from './url_scheme';\n\nfunction getGenericURL(\n baseScheme: string,\n params: URLSchemeParams,\n path: string\n): string {\n var scheme = baseScheme + (params.useTLS ? 's' : '');\n var host = params.useTLS ? params.hostTLS : params.hostNonTLS;\n return scheme + '://' + host + path;\n}\n\nfunction getGenericPath(key: string, queryString?: string): string {\n var path = '/app/' + key;\n var query =\n '?protocol=' +\n Defaults.PROTOCOL +\n '&client=js' +\n '&version=' +\n Defaults.VERSION +\n (queryString ? '&' + queryString : '');\n return path + query;\n}\n\nexport var ws: URLScheme = {\n getInitial: function(key: string, params: URLSchemeParams): string {\n var path = (params.httpPath || '') + getGenericPath(key, 'flash=false');\n return getGenericURL('ws', params, path);\n }\n};\n\nexport var http: URLScheme = {\n getInitial: function(key: string, params: URLSchemeParams): string {\n var path = (params.httpPath || '/pusher') + getGenericPath(key);\n return getGenericURL('http', params, path);\n }\n};\n\nexport var sockjs: URLScheme = {\n getInitial: function(key: string, params: URLSchemeParams): string {\n return getGenericURL('http', params, params.httpPath || '/pusher');\n },\n getPath: function(key: string, params: URLSchemeParams): string {\n return getGenericPath(key);\n }\n};\n","import Callback from './callback';\nimport * as Collections from '../utils/collections';\nimport CallbackTable from './callback_table';\n\nexport default class CallbackRegistry {\n _callbacks: CallbackTable;\n\n constructor() {\n this._callbacks = {};\n }\n\n get(name: string): Callback[] {\n return this._callbacks[prefix(name)];\n }\n\n add(name: string, callback: Function, context: any) {\n var prefixedEventName = prefix(name);\n this._callbacks[prefixedEventName] =\n this._callbacks[prefixedEventName] || [];\n this._callbacks[prefixedEventName].push({\n fn: callback,\n context: context\n });\n }\n\n remove(name?: string, callback?: Function, context?: any) {\n if (!name && !callback && !context) {\n this._callbacks = {};\n return;\n }\n\n var names = name ? [prefix(name)] : Collections.keys(this._callbacks);\n\n if (callback || context) {\n this.removeCallback(names, callback, context);\n } else {\n this.removeAllCallbacks(names);\n }\n }\n\n private removeCallback(names: string[], callback: Function, context: any) {\n Collections.apply(\n names,\n function(name) {\n this._callbacks[name] = Collections.filter(\n this._callbacks[name] || [],\n function(binding) {\n return (\n (callback && callback !== binding.fn) ||\n (context && context !== binding.context)\n );\n }\n );\n if (this._callbacks[name].length === 0) {\n delete this._callbacks[name];\n }\n },\n this\n );\n }\n\n private removeAllCallbacks(names: string[]) {\n Collections.apply(\n names,\n function(name) {\n delete this._callbacks[name];\n },\n this\n );\n }\n}\n\nfunction prefix(name: string): string {\n return '_' + name;\n}\n","import * as Collections from '../utils/collections';\nimport Callback from './callback';\nimport Metadata from '../channels/metadata';\nimport CallbackRegistry from './callback_registry';\n\n/** Manages callback bindings and event emitting.\n *\n * @param Function failThrough called when no listeners are bound to an event\n */\nexport default class Dispatcher {\n callbacks: CallbackRegistry;\n global_callbacks: Function[];\n failThrough: Function;\n\n constructor(failThrough?: Function) {\n this.callbacks = new CallbackRegistry();\n this.global_callbacks = [];\n this.failThrough = failThrough;\n }\n\n bind(eventName: string, callback: Function, context?: any) {\n this.callbacks.add(eventName, callback, context);\n return this;\n }\n\n bind_global(callback: Function) {\n this.global_callbacks.push(callback);\n return this;\n }\n\n unbind(eventName?: string, callback?: Function, context?: any) {\n this.callbacks.remove(eventName, callback, context);\n return this;\n }\n\n unbind_global(callback?: Function) {\n if (!callback) {\n this.global_callbacks = [];\n return this;\n }\n\n this.global_callbacks = Collections.filter(\n this.global_callbacks || [],\n c => c !== callback\n );\n\n return this;\n }\n\n unbind_all() {\n this.unbind();\n this.unbind_global();\n return this;\n }\n\n emit(eventName: string, data?: any, metadata?: Metadata): Dispatcher {\n for (var i = 0; i < this.global_callbacks.length; i++) {\n this.global_callbacks[i](eventName, data);\n }\n\n var callbacks = this.callbacks.get(eventName);\n var args = [];\n\n if (metadata) {\n // if there's a metadata argument, we need to call the callback with both\n // data and metadata regardless of whether data is undefined\n args.push(data, metadata);\n } else if (data) {\n // metadata is undefined, so we only need to call the callback with data\n // if data exists\n args.push(data);\n }\n\n if (callbacks && callbacks.length > 0) {\n for (var i = 0; i < callbacks.length; i++) {\n callbacks[i].fn.apply(callbacks[i].context || global, args);\n }\n } else if (this.failThrough) {\n this.failThrough(eventName, data);\n }\n\n return this;\n }\n}\n","import { stringify } from './utils/collections';\nimport Pusher from './pusher';\n\nclass Logger {\n debug(...args: any[]) {\n this.log(this.globalLog, args);\n }\n\n warn(...args: any[]) {\n this.log(this.globalLogWarn, args);\n }\n\n error(...args: any[]) {\n this.log(this.globalLogError, args);\n }\n\n private globalLog = (message: string) => {\n if (global.console && global.console.log) {\n global.console.log(message);\n }\n };\n\n private globalLogWarn(message: string) {\n if (global.console && global.console.warn) {\n global.console.warn(message);\n } else {\n this.globalLog(message);\n }\n }\n\n private globalLogError(message: string) {\n if (global.console && global.console.error) {\n global.console.error(message);\n } else {\n this.globalLogWarn(message);\n }\n }\n\n private log(\n defaultLoggingFunction: (message: string) => void,\n ...args: any[]\n ) {\n var message = stringify.apply(this, arguments);\n if (Pusher.log) {\n Pusher.log(message);\n } else if (Pusher.logToConsole) {\n const log = defaultLoggingFunction.bind(this);\n log(message);\n }\n }\n}\n\nexport default new Logger();\n","import Util from '../util';\nimport * as Collections from '../utils/collections';\nimport { default as EventsDispatcher } from '../events/dispatcher';\nimport Logger from '../logger';\nimport TransportHooks from './transport_hooks';\nimport Socket from '../socket';\nimport Runtime from 'runtime';\nimport Timeline from '../timeline/timeline';\nimport TransportConnectionOptions from './transport_connection_options';\n\n/** Provides universal API for transport connections.\n *\n * Transport connection is a low-level object that wraps a connection method\n * and exposes a simple evented interface for the connection state and\n * messaging. It does not implement Pusher-specific WebSocket protocol.\n *\n * Additionally, it fetches resources needed for transport to work and exposes\n * an interface for querying transport features.\n *\n * States:\n * - new - initial state after constructing the object\n * - initializing - during initialization phase, usually fetching resources\n * - intialized - ready to establish a connection\n * - connection - when connection is being established\n * - open - when connection ready to be used\n * - closed - after connection was closed be either side\n *\n * Emits:\n * - error - after the connection raised an error\n *\n * Options:\n * - useTLS - whether connection should be over TLS\n * - hostTLS - host to connect to when connection is over TLS\n * - hostNonTLS - host to connect to when connection is over TLS\n *\n * @param {String} key application key\n * @param {Object} options\n */\nexport default class TransportConnection extends EventsDispatcher {\n hooks: TransportHooks;\n name: string;\n priority: number;\n key: string;\n options: TransportConnectionOptions;\n state: string;\n timeline: Timeline;\n activityTimeout: number;\n id: number;\n socket: Socket;\n beforeOpen: Function;\n initialize: Function;\n\n constructor(\n hooks: TransportHooks,\n name: string,\n priority: number,\n key: string,\n options: TransportConnectionOptions\n ) {\n super();\n this.initialize = Runtime.transportConnectionInitializer;\n this.hooks = hooks;\n this.name = name;\n this.priority = priority;\n this.key = key;\n this.options = options;\n\n this.state = 'new';\n this.timeline = options.timeline;\n this.activityTimeout = options.activityTimeout;\n this.id = this.timeline.generateUniqueID();\n }\n\n /** Checks whether the transport handles activity checks by itself.\n *\n * @return {Boolean}\n */\n handlesActivityChecks(): boolean {\n return Boolean(this.hooks.handlesActivityChecks);\n }\n\n /** Checks whether the transport supports the ping/pong API.\n *\n * @return {Boolean}\n */\n supportsPing(): boolean {\n return Boolean(this.hooks.supportsPing);\n }\n\n /** Tries to establish a connection.\n *\n * @returns {Boolean} false if transport is in invalid state\n */\n connect(): boolean {\n if (this.socket || this.state !== 'initialized') {\n return false;\n }\n\n var url = this.hooks.urls.getInitial(this.key, this.options);\n try {\n this.socket = this.hooks.getSocket(url, this.options);\n } catch (e) {\n Util.defer(() => {\n this.onError(e);\n this.changeState('closed');\n });\n return false;\n }\n\n this.bindListeners();\n\n Logger.debug('Connecting', { transport: this.name, url });\n this.changeState('connecting');\n return true;\n }\n\n /** Closes the connection.\n *\n * @return {Boolean} true if there was a connection to close\n */\n close(): boolean {\n if (this.socket) {\n this.socket.close();\n return true;\n } else {\n return false;\n }\n }\n\n /** Sends data over the open connection.\n *\n * @param {String} data\n * @return {Boolean} true only when in the \"open\" state\n */\n send(data: any): boolean {\n if (this.state === 'open') {\n // Workaround for MobileSafari bug (see https://gist.github.com/2052006)\n Util.defer(() => {\n if (this.socket) {\n this.socket.send(data);\n }\n });\n return true;\n } else {\n return false;\n }\n }\n\n /** Sends a ping if the connection is open and transport supports it. */\n ping() {\n if (this.state === 'open' && this.supportsPing()) {\n this.socket.ping();\n }\n }\n\n private onOpen() {\n if (this.hooks.beforeOpen) {\n this.hooks.beforeOpen(\n this.socket,\n this.hooks.urls.getPath(this.key, this.options)\n );\n }\n this.changeState('open');\n this.socket.onopen = undefined;\n }\n\n private onError(error) {\n this.emit('error', { type: 'WebSocketError', error: error });\n this.timeline.error(this.buildTimelineMessage({ error: error.toString() }));\n }\n\n private onClose(closeEvent?: any) {\n if (closeEvent) {\n this.changeState('closed', {\n code: closeEvent.code,\n reason: closeEvent.reason,\n wasClean: closeEvent.wasClean\n });\n } else {\n this.changeState('closed');\n }\n this.unbindListeners();\n this.socket = undefined;\n }\n\n private onMessage(message) {\n this.emit('message', message);\n }\n\n private onActivity() {\n this.emit('activity');\n }\n\n private bindListeners() {\n this.socket.onopen = () => {\n this.onOpen();\n };\n this.socket.onerror = error => {\n this.onError(error);\n };\n this.socket.onclose = closeEvent => {\n this.onClose(closeEvent);\n };\n this.socket.onmessage = message => {\n this.onMessage(message);\n };\n\n if (this.supportsPing()) {\n this.socket.onactivity = () => {\n this.onActivity();\n };\n }\n }\n\n private unbindListeners() {\n if (this.socket) {\n this.socket.onopen = undefined;\n this.socket.onerror = undefined;\n this.socket.onclose = undefined;\n this.socket.onmessage = undefined;\n if (this.supportsPing()) {\n this.socket.onactivity = undefined;\n }\n }\n }\n\n private changeState(state: string, params?: any) {\n this.state = state;\n this.timeline.info(\n this.buildTimelineMessage({\n state: state,\n params: params\n })\n );\n this.emit(state, params);\n }\n\n buildTimelineMessage(message): any {\n return Collections.extend({ cid: this.id }, message);\n }\n}\n","import Factory from '../utils/factory';\nimport TransportHooks from './transport_hooks';\nimport TransportConnection from './transport_connection';\nimport TransportConnectionOptions from './transport_connection_options';\n\n/** Provides interface for transport connection instantiation.\n *\n * Takes transport-specific hooks as the only argument, which allow checking\n * for transport support and creating its connections.\n *\n * Supported hooks: * - file - the name of the file to be fetched during initialization\n * - urls - URL scheme to be used by transport\n * - handlesActivityCheck - true when the transport handles activity checks\n * - supportsPing - true when the transport has a ping/activity API\n * - isSupported - tells whether the transport is supported in the environment\n * - getSocket - creates a WebSocket-compatible transport socket\n *\n * See transports.js for specific implementations.\n *\n * @param {Object} hooks object containing all needed transport hooks\n */\nexport default class Transport {\n hooks: TransportHooks;\n\n constructor(hooks: TransportHooks) {\n this.hooks = hooks;\n }\n\n /** Returns whether the transport is supported in the environment.\n *\n * @param {Object} envronment te environment details (encryption, settings)\n * @returns {Boolean} true when the transport is supported\n */\n isSupported(environment: any): boolean {\n return this.hooks.isSupported(environment);\n }\n\n /** Creates a transport connection.\n *\n * @param {String} name\n * @param {Number} priority\n * @param {String} key the application key\n * @param {Object} options\n * @returns {TransportConnection}\n */\n createConnection(\n name: string,\n priority: number,\n key: string,\n options: any\n ): TransportConnection {\n return new TransportConnection(this.hooks, name, priority, key, options);\n }\n}\n","import * as URLSchemes from 'core/transports/url_schemes';\nimport URLScheme from 'core/transports/url_scheme';\nimport Transport from 'core/transports/transport';\nimport Util from 'core/util';\nimport * as Collections from 'core/utils/collections';\nimport TransportHooks from 'core/transports/transport_hooks';\nimport TransportsTable from 'core/transports/transports_table';\nimport Runtime from 'runtime';\n\n/** WebSocket transport.\n *\n * Uses native WebSocket implementation, including MozWebSocket supported by\n * earlier Firefox versions.\n */\nvar WSTransport = new Transport({\n urls: URLSchemes.ws,\n handlesActivityChecks: false,\n supportsPing: false,\n\n isInitialized: function() {\n return Boolean(Runtime.getWebSocketAPI());\n },\n isSupported: function(): boolean {\n return Boolean(Runtime.getWebSocketAPI());\n },\n getSocket: function(url) {\n return Runtime.createWebSocket(url);\n }\n});\n\nvar httpConfiguration = {\n urls: URLSchemes.http,\n handlesActivityChecks: false,\n supportsPing: true,\n isInitialized: function() {\n return true;\n }\n};\n\nexport var streamingConfiguration = Collections.extend(\n {\n getSocket: function(url) {\n return Runtime.HTTPFactory.createStreamingSocket(url);\n }\n },\n httpConfiguration\n);\nexport var pollingConfiguration = Collections.extend(\n {\n getSocket: function(url) {\n return Runtime.HTTPFactory.createPollingSocket(url);\n }\n },\n httpConfiguration\n);\n\nvar xhrConfiguration = {\n isSupported: function(): boolean {\n return Runtime.isXHRSupported();\n }\n};\n\n/** HTTP streaming transport using CORS-enabled XMLHttpRequest. */\nvar XHRStreamingTransport = new Transport(\n (\n Collections.extend({}, streamingConfiguration, xhrConfiguration)\n )\n);\n\n/** HTTP long-polling transport using CORS-enabled XMLHttpRequest. */\nvar XHRPollingTransport = new Transport(\n Collections.extend({}, pollingConfiguration, xhrConfiguration)\n);\n\nvar Transports: TransportsTable = {\n ws: WSTransport,\n xhr_streaming: XHRStreamingTransport,\n xhr_polling: XHRPollingTransport\n};\n\nexport default Transports;\n","import Util from '../util';\nimport * as Collections from '../utils/collections';\nimport TransportManager from './transport_manager';\nimport TransportConnection from './transport_connection';\nimport Transport from './transport';\nimport PingDelayOptions from './ping_delay_options';\n\n/** Creates transport connections monitored by a transport manager.\n *\n * When a transport is closed, it might mean the environment does not support\n * it. It's possible that messages get stuck in an intermediate buffer or\n * proxies terminate inactive connections. To combat these problems,\n * assistants monitor the connection lifetime, report unclean exits and\n * adjust ping timeouts to keep the connection active. The decision to disable\n * a transport is the manager's responsibility.\n *\n * @param {TransportManager} manager\n * @param {TransportConnection} transport\n * @param {Object} options\n */\nexport default class AssistantToTheTransportManager {\n manager: TransportManager;\n transport: Transport;\n minPingDelay: number;\n maxPingDelay: number;\n pingDelay: number;\n\n constructor(\n manager: TransportManager,\n transport: Transport,\n options: PingDelayOptions\n ) {\n this.manager = manager;\n this.transport = transport;\n this.minPingDelay = options.minPingDelay;\n this.maxPingDelay = options.maxPingDelay;\n this.pingDelay = undefined;\n }\n\n /** Creates a transport connection.\n *\n * This function has the same API as Transport#createConnection.\n *\n * @param {String} name\n * @param {Number} priority\n * @param {String} key the application key\n * @param {Object} options\n * @returns {TransportConnection}\n */\n createConnection(\n name: string,\n priority: number,\n key: string,\n options: Object\n ): TransportConnection {\n options = Collections.extend({}, options, {\n activityTimeout: this.pingDelay\n });\n var connection = this.transport.createConnection(\n name,\n priority,\n key,\n options\n );\n\n var openTimestamp = null;\n\n var onOpen = function() {\n connection.unbind('open', onOpen);\n connection.bind('closed', onClosed);\n openTimestamp = Util.now();\n };\n var onClosed = closeEvent => {\n connection.unbind('closed', onClosed);\n\n if (closeEvent.code === 1002 || closeEvent.code === 1003) {\n // we don't want to use transports not obeying the protocol\n this.manager.reportDeath();\n } else if (!closeEvent.wasClean && openTimestamp) {\n // report deaths only for short-living transport\n var lifespan = Util.now() - openTimestamp;\n if (lifespan < 2 * this.maxPingDelay) {\n this.manager.reportDeath();\n this.pingDelay = Math.max(lifespan / 2, this.minPingDelay);\n }\n }\n };\n\n connection.bind('open', onOpen);\n return connection;\n }\n\n /** Returns whether the transport is supported in the environment.\n *\n * This function has the same API as Transport#isSupported. Might return false\n * when the manager decides to kill the transport.\n *\n * @param {Object} environment the environment details (encryption, settings)\n * @returns {Boolean} true when the transport is supported\n */\n isSupported(environment: string): boolean {\n return this.manager.isAlive() && this.transport.isSupported(environment);\n }\n}\n","import Action from './action';\nimport { PusherEvent } from './message-types';\n/**\n * Provides functions for handling Pusher protocol-specific messages.\n */\n\nconst Protocol = {\n /**\n * Decodes a message in a Pusher format.\n *\n * The MessageEvent we receive from the transport should contain a pusher event\n * (https://pusher.com/docs/pusher_protocol#events) serialized as JSON in the\n * data field\n *\n * The pusher event may contain a data field too, and it may also be\n * serialised as JSON\n *\n * Throws errors when messages are not parse'able.\n *\n * @param {MessageEvent} messageEvent\n * @return {PusherEvent}\n */\n decodeMessage: function(messageEvent: MessageEvent): PusherEvent {\n try {\n var messageData = JSON.parse(messageEvent.data);\n var pusherEventData = messageData.data;\n if (typeof pusherEventData === 'string') {\n try {\n pusherEventData = JSON.parse(messageData.data);\n } catch (e) {}\n }\n var pusherEvent: PusherEvent = {\n event: messageData.event,\n channel: messageData.channel,\n data: pusherEventData\n };\n if (messageData.user_id) {\n pusherEvent.user_id = messageData.user_id;\n }\n return pusherEvent;\n } catch (e) {\n throw { type: 'MessageParseError', error: e, data: messageEvent.data };\n }\n },\n\n /**\n * Encodes a message to be sent.\n *\n * @param {PusherEvent} event\n * @return {String}\n */\n encodeMessage: function(event: PusherEvent): string {\n return JSON.stringify(event);\n },\n\n /**\n * Processes a handshake message and returns appropriate actions.\n *\n * Returns an object with an 'action' and other action-specific properties.\n *\n * There are three outcomes when calling this function. First is a successful\n * connection attempt, when pusher:connection_established is received, which\n * results in a 'connected' action with an 'id' property. When passed a\n * pusher:error event, it returns a result with action appropriate to the\n * close code and an error. Otherwise, it raises an exception.\n *\n * @param {String} message\n * @result Object\n */\n processHandshake: function(messageEvent: MessageEvent): Action {\n var message = Protocol.decodeMessage(messageEvent);\n\n if (message.event === 'pusher:connection_established') {\n if (!message.data.activity_timeout) {\n throw 'No activity timeout specified in handshake';\n }\n return {\n action: 'connected',\n id: message.data.socket_id,\n activityTimeout: message.data.activity_timeout * 1000\n };\n } else if (message.event === 'pusher:error') {\n // From protocol 6 close codes are sent only once, so this only\n // happens when connection does not support close codes\n return {\n action: this.getCloseAction(message.data),\n error: this.getCloseError(message.data)\n };\n } else {\n throw 'Invalid handshake';\n }\n },\n\n /**\n * Dispatches the close event and returns an appropriate action name.\n *\n * See:\n * 1. https://developer.mozilla.org/en-US/docs/WebSockets/WebSockets_reference/CloseEvent\n * 2. http://pusher.com/docs/pusher_protocol\n *\n * @param {CloseEvent} closeEvent\n * @return {String} close action name\n */\n getCloseAction: function(closeEvent): string {\n if (closeEvent.code < 4000) {\n // ignore 1000 CLOSE_NORMAL, 1001 CLOSE_GOING_AWAY,\n // 1005 CLOSE_NO_STATUS, 1006 CLOSE_ABNORMAL\n // ignore 1007...3999\n // handle 1002 CLOSE_PROTOCOL_ERROR, 1003 CLOSE_UNSUPPORTED,\n // 1004 CLOSE_TOO_LARGE\n if (closeEvent.code >= 1002 && closeEvent.code <= 1004) {\n return 'backoff';\n } else {\n return null;\n }\n } else if (closeEvent.code === 4000) {\n return 'tls_only';\n } else if (closeEvent.code < 4100) {\n return 'refused';\n } else if (closeEvent.code < 4200) {\n return 'backoff';\n } else if (closeEvent.code < 4300) {\n return 'retry';\n } else {\n // unknown error\n return 'refused';\n }\n },\n\n /**\n * Returns an error or null basing on the close event.\n *\n * Null is returned when connection was closed cleanly. Otherwise, an object\n * with error details is returned.\n *\n * @param {CloseEvent} closeEvent\n * @return {Object} error object\n */\n getCloseError: function(closeEvent): any {\n if (closeEvent.code !== 1000 && closeEvent.code !== 1001) {\n return {\n type: 'PusherError',\n data: {\n code: closeEvent.code,\n message: closeEvent.reason || closeEvent.message\n }\n };\n } else {\n return null;\n }\n }\n};\n\nexport default Protocol;\n","import * as Collections from '../utils/collections';\nimport { default as EventsDispatcher } from '../events/dispatcher';\nimport Protocol from './protocol/protocol';\nimport { PusherEvent } from './protocol/message-types';\nimport Logger from '../logger';\nimport TransportConnection from '../transports/transport_connection';\nimport Socket from '../socket';\n/**\n * Provides Pusher protocol interface for transports.\n *\n * Emits following events:\n * - message - on received messages\n * - ping - on ping requests\n * - pong - on pong responses\n * - error - when the transport emits an error\n * - closed - after closing the transport\n *\n * It also emits more events when connection closes with a code.\n * See Protocol.getCloseAction to get more details.\n *\n * @param {Number} id\n * @param {AbstractTransport} transport\n */\nexport default class Connection extends EventsDispatcher implements Socket {\n id: string;\n transport: TransportConnection;\n activityTimeout: number;\n\n constructor(id: string, transport: TransportConnection) {\n super();\n this.id = id;\n this.transport = transport;\n this.activityTimeout = transport.activityTimeout;\n this.bindListeners();\n }\n\n /** Returns whether used transport handles activity checks by itself\n *\n * @returns {Boolean} true if activity checks are handled by the transport\n */\n handlesActivityChecks() {\n return this.transport.handlesActivityChecks();\n }\n\n /** Sends raw data.\n *\n * @param {String} data\n */\n send(data: any): boolean {\n return this.transport.send(data);\n }\n\n /** Sends an event.\n *\n * @param {String} name\n * @param {String} data\n * @param {String} [channel]\n * @returns {Boolean} whether message was sent or not\n */\n send_event(name: string, data: any, channel?: string): boolean {\n var event: PusherEvent = { event: name, data: data };\n if (channel) {\n event.channel = channel;\n }\n Logger.debug('Event sent', event);\n return this.send(Protocol.encodeMessage(event));\n }\n\n /** Sends a ping message to the server.\n *\n * Basing on the underlying transport, it might send either transport's\n * protocol-specific ping or pusher:ping event.\n */\n ping() {\n if (this.transport.supportsPing()) {\n this.transport.ping();\n } else {\n this.send_event('pusher:ping', {});\n }\n }\n\n /** Closes the connection. */\n close() {\n this.transport.close();\n }\n\n private bindListeners() {\n var listeners = {\n message: (messageEvent: MessageEvent) => {\n var pusherEvent;\n try {\n pusherEvent = Protocol.decodeMessage(messageEvent);\n } catch (e) {\n this.emit('error', {\n type: 'MessageParseError',\n error: e,\n data: messageEvent.data\n });\n }\n\n if (pusherEvent !== undefined) {\n Logger.debug('Event recd', pusherEvent);\n\n switch (pusherEvent.event) {\n case 'pusher:error':\n this.emit('error', {\n type: 'PusherError',\n data: pusherEvent.data\n });\n break;\n case 'pusher:ping':\n this.emit('ping');\n break;\n case 'pusher:pong':\n this.emit('pong');\n break;\n }\n this.emit('message', pusherEvent);\n }\n },\n activity: () => {\n this.emit('activity');\n },\n error: error => {\n this.emit('error', error);\n },\n closed: closeEvent => {\n unbindListeners();\n\n if (closeEvent && closeEvent.code) {\n this.handleCloseEvent(closeEvent);\n }\n\n this.transport = null;\n this.emit('closed');\n }\n };\n\n var unbindListeners = () => {\n Collections.objectApply(listeners, (listener, event) => {\n this.transport.unbind(event, listener);\n });\n };\n\n Collections.objectApply(listeners, (listener, event) => {\n this.transport.bind(event, listener);\n });\n }\n\n private handleCloseEvent(closeEvent: any) {\n var action = Protocol.getCloseAction(closeEvent);\n var error = Protocol.getCloseError(closeEvent);\n if (error) {\n this.emit('error', error);\n }\n if (action) {\n this.emit(action, { action: action, error: error });\n }\n }\n}\n","import Util from '../../util';\nimport * as Collections from '../../utils/collections';\nimport Protocol from '../protocol/protocol';\nimport Connection from '../connection';\nimport TransportConnection from '../../transports/transport_connection';\nimport HandshakePayload from './handshake_payload';\n\n/**\n * Handles Pusher protocol handshakes for transports.\n *\n * Calls back with a result object after handshake is completed. Results\n * always have two fields:\n * - action - string describing action to be taken after the handshake\n * - transport - the transport object passed to the constructor\n *\n * Different actions can set different additional properties on the result.\n * In the case of 'connected' action, there will be a 'connection' property\n * containing a Connection object for the transport. Other actions should\n * carry an 'error' property.\n *\n * @param {AbstractTransport} transport\n * @param {Function} callback\n */\nexport default class Handshake {\n transport: TransportConnection;\n callback: (HandshakePayload) => void;\n onMessage: Function;\n onClosed: Function;\n\n constructor(\n transport: TransportConnection,\n callback: (HandshakePayload) => void\n ) {\n this.transport = transport;\n this.callback = callback;\n this.bindListeners();\n }\n\n close() {\n this.unbindListeners();\n this.transport.close();\n }\n\n private bindListeners() {\n this.onMessage = m => {\n this.unbindListeners();\n\n var result;\n try {\n result = Protocol.processHandshake(m);\n } catch (e) {\n this.finish('error', { error: e });\n this.transport.close();\n return;\n }\n\n if (result.action === 'connected') {\n this.finish('connected', {\n connection: new Connection(result.id, this.transport),\n activityTimeout: result.activityTimeout\n });\n } else {\n this.finish(result.action, { error: result.error });\n this.transport.close();\n }\n };\n\n this.onClosed = closeEvent => {\n this.unbindListeners();\n\n var action = Protocol.getCloseAction(closeEvent) || 'backoff';\n var error = Protocol.getCloseError(closeEvent);\n this.finish(action, { error: error });\n };\n\n this.transport.bind('message', this.onMessage);\n this.transport.bind('closed', this.onClosed);\n }\n\n private unbindListeners() {\n this.transport.unbind('message', this.onMessage);\n this.transport.unbind('closed', this.onClosed);\n }\n\n private finish(action: string, params: any) {\n this.callback(\n Collections.extend({ transport: this.transport, action: action }, params)\n );\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport base64encode from '../base64';\nimport Timeline from './timeline';\nimport Runtime from 'runtime';\n\nexport interface TimelineSenderOptions {\n host?: string;\n port?: number;\n path?: string;\n}\n\nexport default class TimelineSender {\n timeline: Timeline;\n options: TimelineSenderOptions;\n host: string;\n\n constructor(timeline: Timeline, options: TimelineSenderOptions) {\n this.timeline = timeline;\n this.options = options || {};\n }\n\n send(useTLS: boolean, callback?: Function) {\n if (this.timeline.isEmpty()) {\n return;\n }\n\n this.timeline.send(\n Runtime.TimelineTransport.getAgent(this, useTLS),\n callback\n );\n }\n}\n","/** Error classes used throughout the library. */\n// https://github.com/Microsoft/TypeScript-wiki/blob/master/Breaking-Changes.md#extending-built-ins-like-error-array-and-map-may-no-longer-work\nexport class BadEventName extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\nexport class BadChannelName extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\nexport class RequestTimedOut extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class TransportPriorityTooLow extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class TransportClosed extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class UnsupportedFeature extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class UnsupportedTransport extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class UnsupportedStrategy extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class HTTPAuthError extends Error {\n status: number;\n constructor(status: number, msg?: string) {\n super(msg);\n this.status = status;\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n","/**\n * A place to store help URLs for error messages etc\n */\n\nconst urlStore = {\n baseUrl: 'https://pusher.com',\n urls: {\n authenticationEndpoint: {\n path: '/docs/channels/server_api/authenticating_users'\n },\n authorizationEndpoint: {\n path: '/docs/channels/server_api/authorizing-users/'\n },\n javascriptQuickStart: {\n path: '/docs/javascript_quick_start'\n },\n triggeringClientEvents: {\n path: '/docs/client_api_guide/client_events#trigger-events'\n },\n encryptedChannelSupport: {\n fullUrl:\n 'https://github.com/pusher/pusher-js/tree/cc491015371a4bde5743d1c87a0fbac0feb53195#encrypted-channel-support'\n }\n }\n};\n\n/** Builds a consistent string with links to pusher documentation\n *\n * @param {string} key - relevant key in the url_store.urls object\n * @return {string} suffix string to append to log message\n */\nconst buildLogSuffix = function(key: string): string {\n const urlPrefix = 'See:';\n const urlObj = urlStore.urls[key];\n if (!urlObj) return '';\n\n let url;\n if (urlObj.fullUrl) {\n url = urlObj.fullUrl;\n } else if (urlObj.path) {\n url = urlStore.baseUrl + urlObj.path;\n }\n\n if (!url) return '';\n return `${urlPrefix} ${url}`;\n};\n\nexport default { buildLogSuffix };\n","import { default as EventsDispatcher } from '../events/dispatcher';\nimport * as Errors from '../errors';\nimport Logger from '../logger';\nimport Pusher from '../pusher';\nimport { PusherEvent } from '../connection/protocol/message-types';\nimport Metadata from './metadata';\nimport UrlStore from '../utils/url_store';\nimport {\n ChannelAuthorizationData,\n ChannelAuthorizationCallback\n} from '../auth/options';\nimport { HTTPAuthError } from '../errors';\n\n/** Provides base public channel interface with an event emitter.\n *\n * Emits:\n * - pusher:subscription_succeeded - after subscribing successfully\n * - other non-internal events\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\nexport default class Channel extends EventsDispatcher {\n name: string;\n pusher: Pusher;\n subscribed: boolean;\n subscriptionPending: boolean;\n subscriptionCancelled: boolean;\n subscriptionCount: null;\n\n constructor(name: string, pusher: Pusher) {\n super(function(event, data) {\n Logger.debug('No callbacks on ' + name + ' for ' + event);\n });\n\n this.name = name;\n this.pusher = pusher;\n this.subscribed = false;\n this.subscriptionPending = false;\n this.subscriptionCancelled = false;\n }\n\n /** Skips authorization, since public channels don't require it.\n *\n * @param {Function} callback\n */\n authorize(socketId: string, callback: ChannelAuthorizationCallback) {\n return callback(null, { auth: '' });\n }\n\n /** Triggers an event */\n trigger(event: string, data: any) {\n if (event.indexOf('client-') !== 0) {\n throw new Errors.BadEventName(\n \"Event '\" + event + \"' does not start with 'client-'\"\n );\n }\n if (!this.subscribed) {\n var suffix = UrlStore.buildLogSuffix('triggeringClientEvents');\n Logger.warn(\n `Client event triggered before channel 'subscription_succeeded' event . ${suffix}`\n );\n }\n return this.pusher.send_event(event, data, this.name);\n }\n\n /** Signals disconnection to the channel. For internal use only. */\n disconnect() {\n this.subscribed = false;\n this.subscriptionPending = false;\n }\n\n /** Handles a PusherEvent. For internal use only.\n *\n * @param {PusherEvent} event\n */\n handleEvent(event: PusherEvent) {\n var eventName = event.event;\n var data = event.data;\n if (eventName === 'pusher_internal:subscription_succeeded') {\n this.handleSubscriptionSucceededEvent(event);\n } else if (eventName === 'pusher_internal:subscription_count') {\n this.handleSubscriptionCountEvent(event);\n } else if (eventName.indexOf('pusher_internal:') !== 0) {\n var metadata: Metadata = {};\n this.emit(eventName, data, metadata);\n }\n }\n\n handleSubscriptionSucceededEvent(event: PusherEvent) {\n this.subscriptionPending = false;\n this.subscribed = true;\n if (this.subscriptionCancelled) {\n this.pusher.unsubscribe(this.name);\n } else {\n this.emit('pusher:subscription_succeeded', event.data);\n }\n }\n\n handleSubscriptionCountEvent(event: PusherEvent) {\n if (event.data.subscription_count) {\n this.subscriptionCount = event.data.subscription_count;\n }\n\n this.emit('pusher:subscription_count', event.data);\n }\n\n /** Sends a subscription request. For internal use only. */\n subscribe() {\n if (this.subscribed) {\n return;\n }\n this.subscriptionPending = true;\n this.subscriptionCancelled = false;\n this.authorize(\n this.pusher.connection.socket_id,\n (error: Error | null, data: ChannelAuthorizationData) => {\n if (error) {\n this.subscriptionPending = false;\n // Why not bind to 'pusher:subscription_error' a level up, and log there?\n // Binding to this event would cause the warning about no callbacks being\n // bound (see constructor) to be suppressed, that's not what we want.\n Logger.error(error.toString());\n this.emit(\n 'pusher:subscription_error',\n Object.assign(\n {},\n {\n type: 'AuthError',\n error: error.message\n },\n error instanceof HTTPAuthError ? { status: error.status } : {}\n )\n );\n } else {\n this.pusher.send_event('pusher:subscribe', {\n auth: data.auth,\n channel_data: data.channel_data,\n channel: this.name\n });\n }\n }\n );\n }\n\n /** Sends an unsubscription request. For internal use only. */\n unsubscribe() {\n this.subscribed = false;\n this.pusher.send_event('pusher:unsubscribe', {\n channel: this.name\n });\n }\n\n /** Cancels an in progress subscription. For internal use only. */\n cancelSubscription() {\n this.subscriptionCancelled = true;\n }\n\n /** Reinstates an in progress subscripiton. For internal use only. */\n reinstateSubscription() {\n this.subscriptionCancelled = false;\n }\n}\n","import Factory from '../utils/factory';\nimport Channel from './channel';\nimport { ChannelAuthorizationCallback } from '../auth/options';\n\n/** Extends public channels to provide private channel interface.\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\nexport default class PrivateChannel extends Channel {\n /** Authorizes the connection to use the channel.\n *\n * @param {String} socketId\n * @param {Function} callback\n */\n authorize(socketId: string, callback: ChannelAuthorizationCallback) {\n return this.pusher.config.channelAuthorizer(\n {\n channelName: this.name,\n socketId: socketId\n },\n callback\n );\n }\n}\n","import * as Collections from '../utils/collections';\n\n/** Represents a collection of members of a presence channel. */\nexport default class Members {\n members: any;\n count: number;\n myID: any;\n me: any;\n\n constructor() {\n this.reset();\n }\n\n /** Returns member's info for given id.\n *\n * Resulting object containts two fields - id and info.\n *\n * @param {Number} id\n * @return {Object} member's info or null\n */\n get(id: string): any {\n if (Object.prototype.hasOwnProperty.call(this.members, id)) {\n return {\n id: id,\n info: this.members[id]\n };\n } else {\n return null;\n }\n }\n\n /** Calls back for each member in unspecified order.\n *\n * @param {Function} callback\n */\n each(callback: Function) {\n Collections.objectApply(this.members, (member, id) => {\n callback(this.get(id));\n });\n }\n\n /** Updates the id for connected member. For internal use only. */\n setMyID(id: string) {\n this.myID = id;\n }\n\n /** Handles subscription data. For internal use only. */\n onSubscription(subscriptionData: any) {\n this.members = subscriptionData.presence.hash;\n this.count = subscriptionData.presence.count;\n this.me = this.get(this.myID);\n }\n\n /** Adds a new member to the collection. For internal use only. */\n addMember(memberData: any) {\n if (this.get(memberData.user_id) === null) {\n this.count++;\n }\n this.members[memberData.user_id] = memberData.user_info;\n return this.get(memberData.user_id);\n }\n\n /** Adds a member from the collection. For internal use only. */\n removeMember(memberData: any) {\n var member = this.get(memberData.user_id);\n if (member) {\n delete this.members[memberData.user_id];\n this.count--;\n }\n return member;\n }\n\n /** Resets the collection to the initial state. For internal use only. */\n reset() {\n this.members = {};\n this.count = 0;\n this.myID = null;\n this.me = null;\n }\n}\n","import PrivateChannel from './private_channel';\nimport Logger from '../logger';\nimport Members from './members';\nimport Pusher from '../pusher';\nimport UrlStore from 'core/utils/url_store';\nimport { PusherEvent } from '../connection/protocol/message-types';\nimport Metadata from './metadata';\nimport { ChannelAuthorizationData } from '../auth/options';\n\nexport default class PresenceChannel extends PrivateChannel {\n members: Members;\n\n /** Adds presence channel functionality to private channels.\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\n constructor(name: string, pusher: Pusher) {\n super(name, pusher);\n this.members = new Members();\n }\n\n /** Authorizes the connection as a member of the channel.\n *\n * @param {String} socketId\n * @param {Function} callback\n */\n authorize(socketId: string, callback: Function) {\n super.authorize(socketId, async (error, authData) => {\n if (!error) {\n authData = authData as ChannelAuthorizationData;\n if (authData.channel_data != null) {\n var channelData = JSON.parse(authData.channel_data);\n this.members.setMyID(channelData.user_id);\n } else {\n await this.pusher.user.signinDonePromise;\n if (this.pusher.user.user_data != null) {\n // If the user is signed in, get the id of the authenticated user\n // and allow the presence authorization to continue.\n this.members.setMyID(this.pusher.user.user_data.id);\n } else {\n let suffix = UrlStore.buildLogSuffix('authorizationEndpoint');\n Logger.error(\n `Invalid auth response for channel '${this.name}', ` +\n `expected 'channel_data' field. ${suffix}, ` +\n `or the user should be signed in.`\n );\n callback('Invalid auth response');\n return;\n }\n }\n }\n callback(error, authData);\n });\n }\n\n /** Handles presence and subscription events. For internal use only.\n *\n * @param {PusherEvent} event\n */\n handleEvent(event: PusherEvent) {\n var eventName = event.event;\n if (eventName.indexOf('pusher_internal:') === 0) {\n this.handleInternalEvent(event);\n } else {\n var data = event.data;\n var metadata: Metadata = {};\n if (event.user_id) {\n metadata.user_id = event.user_id;\n }\n this.emit(eventName, data, metadata);\n }\n }\n handleInternalEvent(event: PusherEvent) {\n var eventName = event.event;\n var data = event.data;\n switch (eventName) {\n case 'pusher_internal:subscription_succeeded':\n this.handleSubscriptionSucceededEvent(event);\n break;\n case 'pusher_internal:subscription_count':\n this.handleSubscriptionCountEvent(event);\n break;\n case 'pusher_internal:member_added':\n var addedMember = this.members.addMember(data);\n this.emit('pusher:member_added', addedMember);\n break;\n case 'pusher_internal:member_removed':\n var removedMember = this.members.removeMember(data);\n if (removedMember) {\n this.emit('pusher:member_removed', removedMember);\n }\n break;\n }\n }\n\n handleSubscriptionSucceededEvent(event: PusherEvent) {\n this.subscriptionPending = false;\n this.subscribed = true;\n if (this.subscriptionCancelled) {\n this.pusher.unsubscribe(this.name);\n } else {\n this.members.onSubscription(event.data);\n this.emit('pusher:subscription_succeeded', this.members);\n }\n }\n\n /** Resets the channel state, including members map. For internal use only. */\n disconnect() {\n this.members.reset();\n super.disconnect();\n }\n}\n","import PrivateChannel from './private_channel';\nimport * as Errors from '../errors';\nimport Logger from '../logger';\nimport Pusher from '../pusher';\nimport { decode as encodeUTF8 } from '@stablelib/utf8';\nimport { decode as decodeBase64 } from '@stablelib/base64';\nimport Dispatcher from '../events/dispatcher';\nimport { PusherEvent } from '../connection/protocol/message-types';\nimport {\n ChannelAuthorizationData,\n ChannelAuthorizationCallback\n} from '../auth/options';\nimport * as nacl from 'tweetnacl';\n\n/** Extends private channels to provide encrypted channel interface.\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\nexport default class EncryptedChannel extends PrivateChannel {\n key: Uint8Array = null;\n nacl: nacl;\n\n constructor(name: string, pusher: Pusher, nacl: nacl) {\n super(name, pusher);\n this.nacl = nacl;\n }\n\n /** Authorizes the connection to use the channel.\n *\n * @param {String} socketId\n * @param {Function} callback\n */\n authorize(socketId: string, callback: ChannelAuthorizationCallback) {\n super.authorize(\n socketId,\n (error: Error | null, authData: ChannelAuthorizationData) => {\n if (error) {\n callback(error, authData);\n return;\n }\n let sharedSecret = authData['shared_secret'];\n if (!sharedSecret) {\n callback(\n new Error(\n `No shared_secret key in auth payload for encrypted channel: ${this.name}`\n ),\n null\n );\n return;\n }\n this.key = decodeBase64(sharedSecret);\n delete authData['shared_secret'];\n callback(null, authData);\n }\n );\n }\n\n trigger(event: string, data: any): boolean {\n throw new Errors.UnsupportedFeature(\n 'Client events are not currently supported for encrypted channels'\n );\n }\n\n /** Handles an event. For internal use only.\n *\n * @param {PusherEvent} event\n */\n handleEvent(event: PusherEvent) {\n var eventName = event.event;\n var data = event.data;\n if (\n eventName.indexOf('pusher_internal:') === 0 ||\n eventName.indexOf('pusher:') === 0\n ) {\n super.handleEvent(event);\n return;\n }\n this.handleEncryptedEvent(eventName, data);\n }\n\n private handleEncryptedEvent(event: string, data: any): void {\n if (!this.key) {\n Logger.debug(\n 'Received encrypted event before key has been retrieved from the authEndpoint'\n );\n return;\n }\n if (!data.ciphertext || !data.nonce) {\n Logger.error(\n 'Unexpected format for encrypted event, expected object with `ciphertext` and `nonce` fields, got: ' +\n data\n );\n return;\n }\n let cipherText = decodeBase64(data.ciphertext);\n if (cipherText.length < this.nacl.secretbox.overheadLength) {\n Logger.error(\n `Expected encrypted event ciphertext length to be ${this.nacl.secretbox.overheadLength}, got: ${cipherText.length}`\n );\n return;\n }\n let nonce = decodeBase64(data.nonce);\n if (nonce.length < this.nacl.secretbox.nonceLength) {\n Logger.error(\n `Expected encrypted event nonce length to be ${this.nacl.secretbox.nonceLength}, got: ${nonce.length}`\n );\n return;\n }\n\n let bytes = this.nacl.secretbox.open(cipherText, nonce, this.key);\n if (bytes === null) {\n Logger.debug(\n 'Failed to decrypt an event, probably because it was encrypted with a different key. Fetching a new key from the authEndpoint...'\n );\n // Try a single time to retrieve a new auth key and decrypt the event with it\n // If this fails, a new key will be requested when a new message is received\n this.authorize(this.pusher.connection.socket_id, (error, authData) => {\n if (error) {\n Logger.error(\n `Failed to make a request to the authEndpoint: ${authData}. Unable to fetch new key, so dropping encrypted event`\n );\n return;\n }\n bytes = this.nacl.secretbox.open(cipherText, nonce, this.key);\n if (bytes === null) {\n Logger.error(\n `Failed to decrypt event with new key. Dropping encrypted event`\n );\n return;\n }\n this.emit(event, this.getDataToEmit(bytes));\n return;\n });\n return;\n }\n this.emit(event, this.getDataToEmit(bytes));\n }\n\n // Try and parse the decrypted bytes as JSON. If we can't parse it, just\n // return the utf-8 string\n getDataToEmit(bytes: Uint8Array): string {\n let raw = encodeUTF8(bytes);\n try {\n return JSON.parse(raw);\n } catch {\n return raw;\n }\n }\n}\n","import { default as EventsDispatcher } from '../events/dispatcher';\nimport { OneOffTimer as Timer } from '../utils/timers';\nimport { Config } from '../config';\nimport Logger from '../logger';\nimport HandshakePayload from './handshake/handshake_payload';\nimport Connection from './connection';\nimport Strategy from '../strategies/strategy';\nimport StrategyRunner from '../strategies/strategy_runner';\nimport * as Collections from '../utils/collections';\nimport Timeline from '../timeline/timeline';\nimport ConnectionManagerOptions from './connection_manager_options';\nimport Runtime from 'runtime';\n\nimport {\n ErrorCallbacks,\n HandshakeCallbacks,\n ConnectionCallbacks\n} from './callbacks';\nimport Action from './protocol/action';\n\n/** Manages connection to Pusher.\n *\n * Uses a strategy (currently only default), timers and network availability\n * info to establish a connection and export its state. In case of failures,\n * manages reconnection attempts.\n *\n * Exports state changes as following events:\n * - \"state_change\", { previous: p, current: state }\n * - state\n *\n * States:\n * - initialized - initial state, never transitioned to\n * - connecting - connection is being established\n * - connected - connection has been fully established\n * - disconnected - on requested disconnection\n * - unavailable - after connection timeout or when there's no network\n * - failed - when the connection strategy is not supported\n *\n * Options:\n * - unavailableTimeout - time to transition to unavailable state\n * - activityTimeout - time after which ping message should be sent\n * - pongTimeout - time for Pusher to respond with pong before reconnecting\n *\n * @param {String} key application key\n * @param {Object} options\n */\nexport default class ConnectionManager extends EventsDispatcher {\n key: string;\n options: ConnectionManagerOptions;\n state: string;\n connection: Connection;\n usingTLS: boolean;\n timeline: Timeline;\n socket_id: string;\n unavailableTimer: Timer;\n activityTimer: Timer;\n retryTimer: Timer;\n activityTimeout: number;\n strategy: Strategy;\n runner: StrategyRunner;\n errorCallbacks: ErrorCallbacks;\n handshakeCallbacks: HandshakeCallbacks;\n connectionCallbacks: ConnectionCallbacks;\n\n constructor(key: string, options: ConnectionManagerOptions) {\n super();\n this.state = 'initialized';\n this.connection = null;\n\n this.key = key;\n this.options = options;\n this.timeline = this.options.timeline;\n this.usingTLS = this.options.useTLS;\n\n this.errorCallbacks = this.buildErrorCallbacks();\n this.connectionCallbacks = this.buildConnectionCallbacks(\n this.errorCallbacks\n );\n this.handshakeCallbacks = this.buildHandshakeCallbacks(this.errorCallbacks);\n\n var Network = Runtime.getNetwork();\n\n Network.bind('online', () => {\n this.timeline.info({ netinfo: 'online' });\n if (this.state === 'connecting' || this.state === 'unavailable') {\n this.retryIn(0);\n }\n });\n Network.bind('offline', () => {\n this.timeline.info({ netinfo: 'offline' });\n if (this.connection) {\n this.sendActivityCheck();\n }\n });\n\n this.updateStrategy();\n }\n\n switchCluster(key: string) {\n this.key = key;\n // This ensures that the new config coming from\n // pusher instance are taken into account\n // such as appKey and cluster\n this.updateStrategy();\n this.retryIn(0);\n }\n\n /** Establishes a connection to Pusher.\n *\n * Does nothing when connection is already established. See top-level doc\n * to find events emitted on connection attempts.\n */\n connect() {\n if (this.connection || this.runner) {\n return;\n }\n if (!this.strategy.isSupported()) {\n this.updateState('failed');\n return;\n }\n this.updateState('connecting');\n this.startConnecting();\n this.setUnavailableTimer();\n }\n\n /** Sends raw data.\n *\n * @param {String} data\n */\n send(data) {\n if (this.connection) {\n return this.connection.send(data);\n } else {\n return false;\n }\n }\n\n /** Sends an event.\n *\n * @param {String} name\n * @param {String} data\n * @param {String} [channel]\n * @returns {Boolean} whether message was sent or not\n */\n send_event(name: string, data: any, channel?: string) {\n if (this.connection) {\n return this.connection.send_event(name, data, channel);\n } else {\n return false;\n }\n }\n\n /** Closes the connection. */\n disconnect() {\n this.disconnectInternally();\n this.updateState('disconnected');\n }\n\n isUsingTLS() {\n return this.usingTLS;\n }\n\n private startConnecting() {\n var callback = (error, handshake) => {\n if (error) {\n this.runner = this.strategy.connect(0, callback);\n } else {\n if (handshake.action === 'error') {\n this.emit('error', {\n type: 'HandshakeError',\n error: handshake.error\n });\n this.timeline.error({ handshakeError: handshake.error });\n } else {\n this.abortConnecting(); // we don't support switching connections yet\n this.handshakeCallbacks[handshake.action](handshake);\n }\n }\n };\n this.runner = this.strategy.connect(0, callback);\n }\n\n private abortConnecting() {\n if (this.runner) {\n this.runner.abort();\n this.runner = null;\n }\n }\n\n private disconnectInternally() {\n this.abortConnecting();\n this.clearRetryTimer();\n this.clearUnavailableTimer();\n if (this.connection) {\n var connection = this.abandonConnection();\n connection.close();\n }\n }\n\n private updateStrategy() {\n this.strategy = this.options.getStrategy({\n key: this.key,\n timeline: this.timeline,\n useTLS: this.usingTLS\n });\n }\n\n private retryIn(delay) {\n this.timeline.info({ action: 'retry', delay: delay });\n if (delay > 0) {\n this.emit('connecting_in', Math.round(delay / 1000));\n }\n this.retryTimer = new Timer(delay || 0, () => {\n this.disconnectInternally();\n this.connect();\n });\n }\n\n private clearRetryTimer() {\n if (this.retryTimer) {\n this.retryTimer.ensureAborted();\n this.retryTimer = null;\n }\n }\n\n private setUnavailableTimer() {\n this.unavailableTimer = new Timer(this.options.unavailableTimeout, () => {\n this.updateState('unavailable');\n });\n }\n\n private clearUnavailableTimer() {\n if (this.unavailableTimer) {\n this.unavailableTimer.ensureAborted();\n }\n }\n\n private sendActivityCheck() {\n this.stopActivityCheck();\n this.connection.ping();\n // wait for pong response\n this.activityTimer = new Timer(this.options.pongTimeout, () => {\n this.timeline.error({ pong_timed_out: this.options.pongTimeout });\n this.retryIn(0);\n });\n }\n\n private resetActivityCheck() {\n this.stopActivityCheck();\n // send ping after inactivity\n if (this.connection && !this.connection.handlesActivityChecks()) {\n this.activityTimer = new Timer(this.activityTimeout, () => {\n this.sendActivityCheck();\n });\n }\n }\n\n private stopActivityCheck() {\n if (this.activityTimer) {\n this.activityTimer.ensureAborted();\n }\n }\n\n private buildConnectionCallbacks(\n errorCallbacks: ErrorCallbacks\n ): ConnectionCallbacks {\n return Collections.extend({}, errorCallbacks, {\n message: message => {\n // includes pong messages from server\n this.resetActivityCheck();\n this.emit('message', message);\n },\n ping: () => {\n this.send_event('pusher:pong', {});\n },\n activity: () => {\n this.resetActivityCheck();\n },\n error: error => {\n // just emit error to user - socket will already be closed by browser\n this.emit('error', error);\n },\n closed: () => {\n this.abandonConnection();\n if (this.shouldRetry()) {\n this.retryIn(1000);\n }\n }\n });\n }\n\n private buildHandshakeCallbacks(\n errorCallbacks: ErrorCallbacks\n ): HandshakeCallbacks {\n return Collections.extend({}, errorCallbacks, {\n connected: (handshake: HandshakePayload) => {\n this.activityTimeout = Math.min(\n this.options.activityTimeout,\n handshake.activityTimeout,\n handshake.connection.activityTimeout || Infinity\n );\n this.clearUnavailableTimer();\n this.setConnection(handshake.connection);\n this.socket_id = this.connection.id;\n this.updateState('connected', { socket_id: this.socket_id });\n }\n });\n }\n\n private buildErrorCallbacks(): ErrorCallbacks {\n let withErrorEmitted = callback => {\n return (result: Action | HandshakePayload) => {\n if (result.error) {\n this.emit('error', { type: 'WebSocketError', error: result.error });\n }\n callback(result);\n };\n };\n\n return {\n tls_only: withErrorEmitted(() => {\n this.usingTLS = true;\n this.updateStrategy();\n this.retryIn(0);\n }),\n refused: withErrorEmitted(() => {\n this.disconnect();\n }),\n backoff: withErrorEmitted(() => {\n this.retryIn(1000);\n }),\n retry: withErrorEmitted(() => {\n this.retryIn(0);\n })\n };\n }\n\n private setConnection(connection) {\n this.connection = connection;\n for (var event in this.connectionCallbacks) {\n this.connection.bind(event, this.connectionCallbacks[event]);\n }\n this.resetActivityCheck();\n }\n\n private abandonConnection() {\n if (!this.connection) {\n return;\n }\n this.stopActivityCheck();\n for (var event in this.connectionCallbacks) {\n this.connection.unbind(event, this.connectionCallbacks[event]);\n }\n var connection = this.connection;\n this.connection = null;\n return connection;\n }\n\n private updateState(newState: string, data?: any) {\n var previousState = this.state;\n this.state = newState;\n if (previousState !== newState) {\n var newStateDescription = newState;\n if (newStateDescription === 'connected') {\n newStateDescription += ' with new socket ID ' + data.socket_id;\n }\n Logger.debug(\n 'State changed',\n previousState + ' -> ' + newStateDescription\n );\n this.timeline.info({ state: newState, params: data });\n this.emit('state_change', { previous: previousState, current: newState });\n this.emit(newState, data);\n }\n }\n\n private shouldRetry(): boolean {\n return this.state === 'connecting' || this.state === 'connected';\n }\n}\n","import Channel from './channel';\nimport * as Collections from '../utils/collections';\nimport ChannelTable from './channel_table';\nimport Factory from '../utils/factory';\nimport Pusher from '../pusher';\nimport Logger from '../logger';\nimport * as Errors from '../errors';\nimport urlStore from '../utils/url_store';\n\n/** Handles a channel map. */\nexport default class Channels {\n channels: ChannelTable;\n\n constructor() {\n this.channels = {};\n }\n\n /** Creates or retrieves an existing channel by its name.\n *\n * @param {String} name\n * @param {Pusher} pusher\n * @return {Channel}\n */\n add(name: string, pusher: Pusher) {\n if (!this.channels[name]) {\n this.channels[name] = createChannel(name, pusher);\n }\n return this.channels[name];\n }\n\n /** Returns a list of all channels\n *\n * @return {Array}\n */\n all(): Channel[] {\n return Collections.values(this.channels);\n }\n\n /** Finds a channel by its name.\n *\n * @param {String} name\n * @return {Channel} channel or null if it doesn't exist\n */\n find(name: string) {\n return this.channels[name];\n }\n\n /** Removes a channel from the map.\n *\n * @param {String} name\n */\n remove(name: string) {\n var channel = this.channels[name];\n delete this.channels[name];\n return channel;\n }\n\n /** Proxies disconnection signal to all channels. */\n disconnect() {\n Collections.objectApply(this.channels, function(channel) {\n channel.disconnect();\n });\n }\n}\n\nfunction createChannel(name: string, pusher: Pusher): Channel {\n if (name.indexOf('private-encrypted-') === 0) {\n if (pusher.config.nacl) {\n return Factory.createEncryptedChannel(name, pusher, pusher.config.nacl);\n }\n let errMsg =\n 'Tried to subscribe to a private-encrypted- channel but no nacl implementation available';\n let suffix = urlStore.buildLogSuffix('encryptedChannelSupport');\n throw new Errors.UnsupportedFeature(`${errMsg}. ${suffix}`);\n } else if (name.indexOf('private-') === 0) {\n return Factory.createPrivateChannel(name, pusher);\n } else if (name.indexOf('presence-') === 0) {\n return Factory.createPresenceChannel(name, pusher);\n } else if (name.indexOf('#') === 0) {\n throw new Errors.BadChannelName(\n 'Cannot create a channel with name \"' + name + '\".'\n );\n } else {\n return Factory.createChannel(name, pusher);\n }\n}\n","import AssistantToTheTransportManager from '../transports/assistant_to_the_transport_manager';\nimport PingDelayOptions from '../transports/ping_delay_options';\nimport Transport from '../transports/transport';\nimport TransportManager from '../transports/transport_manager';\nimport Handshake from '../connection/handshake';\nimport TransportConnection from '../transports/transport_connection';\nimport SocketHooks from '../http/socket_hooks';\nimport HTTPSocket from '../http/http_socket';\n\nimport Timeline from '../timeline/timeline';\nimport {\n default as TimelineSender,\n TimelineSenderOptions\n} from '../timeline/timeline_sender';\nimport PresenceChannel from '../channels/presence_channel';\nimport PrivateChannel from '../channels/private_channel';\nimport EncryptedChannel from '../channels/encrypted_channel';\nimport Channel from '../channels/channel';\nimport ConnectionManager from '../connection/connection_manager';\nimport ConnectionManagerOptions from '../connection/connection_manager_options';\nimport Ajax from '../http/ajax';\nimport Channels from '../channels/channels';\nimport Pusher from '../pusher';\nimport { Config } from '../config';\nimport * as nacl from 'tweetnacl';\n\nvar Factory = {\n createChannels(): Channels {\n return new Channels();\n },\n\n createConnectionManager(\n key: string,\n options: ConnectionManagerOptions\n ): ConnectionManager {\n return new ConnectionManager(key, options);\n },\n\n createChannel(name: string, pusher: Pusher): Channel {\n return new Channel(name, pusher);\n },\n\n createPrivateChannel(name: string, pusher: Pusher): PrivateChannel {\n return new PrivateChannel(name, pusher);\n },\n\n createPresenceChannel(name: string, pusher: Pusher): PresenceChannel {\n return new PresenceChannel(name, pusher);\n },\n\n createEncryptedChannel(\n name: string,\n pusher: Pusher,\n nacl: nacl\n ): EncryptedChannel {\n return new EncryptedChannel(name, pusher, nacl);\n },\n\n createTimelineSender(timeline: Timeline, options: TimelineSenderOptions) {\n return new TimelineSender(timeline, options);\n },\n\n createHandshake(\n transport: TransportConnection,\n callback: (HandshakePayload) => void\n ): Handshake {\n return new Handshake(transport, callback);\n },\n\n createAssistantToTheTransportManager(\n manager: TransportManager,\n transport: Transport,\n options: PingDelayOptions\n ): AssistantToTheTransportManager {\n return new AssistantToTheTransportManager(manager, transport, options);\n }\n};\n\nexport default Factory;\n","import AssistantToTheTransportManager from './assistant_to_the_transport_manager';\nimport Transport from './transport';\nimport PingDelayOptions from './ping_delay_options';\nimport Factory from '../utils/factory';\n\nexport interface TransportManagerOptions extends PingDelayOptions {\n lives?: number;\n}\n\n/** Keeps track of the number of lives left for a transport.\n *\n * In the beginning of a session, transports may be assigned a number of\n * lives. When an AssistantToTheTransportManager instance reports a transport\n * connection closed uncleanly, the transport loses a life. When the number\n * of lives drops to zero, the transport gets disabled by its manager.\n *\n * @param {Object} options\n */\nexport default class TransportManager {\n options: TransportManagerOptions;\n livesLeft: number;\n\n constructor(options: TransportManagerOptions) {\n this.options = options || {};\n this.livesLeft = this.options.lives || Infinity;\n }\n\n /** Creates a assistant for the transport.\n *\n * @param {Transport} transport\n * @returns {AssistantToTheTransportManager}\n */\n getAssistant(transport: Transport): AssistantToTheTransportManager {\n return Factory.createAssistantToTheTransportManager(this, transport, {\n minPingDelay: this.options.minPingDelay,\n maxPingDelay: this.options.maxPingDelay\n });\n }\n\n /** Returns whether the transport has any lives left.\n *\n * @returns {Boolean}\n */\n isAlive(): boolean {\n return this.livesLeft > 0;\n }\n\n /** Takes one life from the transport. */\n reportDeath() {\n this.livesLeft -= 1;\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport { OneOffTimer as Timer } from '../utils/timers';\nimport Strategy from './strategy';\nimport StrategyOptions from './strategy_options';\n\n/** Loops through strategies with optional timeouts.\n *\n * Options:\n * - loop - whether it should loop through the substrategy list\n * - timeout - initial timeout for a single substrategy\n * - timeoutLimit - maximum timeout\n *\n * @param {Strategy[]} strategies\n * @param {Object} options\n */\nexport default class SequentialStrategy implements Strategy {\n strategies: Strategy[];\n loop: boolean;\n failFast: boolean;\n timeout: number;\n timeoutLimit: number;\n\n constructor(strategies: Strategy[], options: StrategyOptions) {\n this.strategies = strategies;\n this.loop = Boolean(options.loop);\n this.failFast = Boolean(options.failFast);\n this.timeout = options.timeout;\n this.timeoutLimit = options.timeoutLimit;\n }\n\n isSupported(): boolean {\n return Collections.any(this.strategies, Util.method('isSupported'));\n }\n\n connect(minPriority: number, callback: Function) {\n var strategies = this.strategies;\n var current = 0;\n var timeout = this.timeout;\n var runner = null;\n\n var tryNextStrategy = (error, handshake) => {\n if (handshake) {\n callback(null, handshake);\n } else {\n current = current + 1;\n if (this.loop) {\n current = current % strategies.length;\n }\n\n if (current < strategies.length) {\n if (timeout) {\n timeout = timeout * 2;\n if (this.timeoutLimit) {\n timeout = Math.min(timeout, this.timeoutLimit);\n }\n }\n runner = this.tryStrategy(\n strategies[current],\n minPriority,\n { timeout, failFast: this.failFast },\n tryNextStrategy\n );\n } else {\n callback(true);\n }\n }\n };\n\n runner = this.tryStrategy(\n strategies[current],\n minPriority,\n { timeout: timeout, failFast: this.failFast },\n tryNextStrategy\n );\n\n return {\n abort: function() {\n runner.abort();\n },\n forceMinPriority: function(p) {\n minPriority = p;\n if (runner) {\n runner.forceMinPriority(p);\n }\n }\n };\n }\n\n private tryStrategy(\n strategy: Strategy,\n minPriority: number,\n options: StrategyOptions,\n callback: Function\n ) {\n var timer = null;\n var runner = null;\n\n if (options.timeout > 0) {\n timer = new Timer(options.timeout, function() {\n runner.abort();\n callback(true);\n });\n }\n\n runner = strategy.connect(minPriority, function(error, handshake) {\n if (error && timer && timer.isRunning() && !options.failFast) {\n // advance to the next strategy after the timeout\n return;\n }\n if (timer) {\n timer.ensureAborted();\n }\n callback(error, handshake);\n });\n\n return {\n abort: function() {\n if (timer) {\n timer.ensureAborted();\n }\n runner.abort();\n },\n forceMinPriority: function(p) {\n runner.forceMinPriority(p);\n }\n };\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport Strategy from './strategy';\n\n/** Launches all substrategies and emits prioritized connected transports.\n *\n * @param {Array} strategies\n */\nexport default class BestConnectedEverStrategy implements Strategy {\n strategies: Strategy[];\n\n constructor(strategies: Strategy[]) {\n this.strategies = strategies;\n }\n\n isSupported(): boolean {\n return Collections.any(this.strategies, Util.method('isSupported'));\n }\n\n connect(minPriority: number, callback: Function) {\n return connect(this.strategies, minPriority, function(i, runners) {\n return function(error, handshake) {\n runners[i].error = error;\n if (error) {\n if (allRunnersFailed(runners)) {\n callback(true);\n }\n return;\n }\n Collections.apply(runners, function(runner) {\n runner.forceMinPriority(handshake.transport.priority);\n });\n callback(null, handshake);\n };\n });\n }\n}\n\n/** Connects to all strategies in parallel.\n *\n * Callback builder should be a function that takes two arguments: index\n * and a list of runners. It should return another function that will be\n * passed to the substrategy with given index. Runners can be aborted using\n * abortRunner(s) functions from this class.\n *\n * @param {Array} strategies\n * @param {Function} callbackBuilder\n * @return {Object} strategy runner\n */\nfunction connect(\n strategies: Strategy[],\n minPriority: number,\n callbackBuilder: Function\n) {\n var runners = Collections.map(strategies, function(strategy, i, _, rs) {\n return strategy.connect(minPriority, callbackBuilder(i, rs));\n });\n return {\n abort: function() {\n Collections.apply(runners, abortRunner);\n },\n forceMinPriority: function(p) {\n Collections.apply(runners, function(runner) {\n runner.forceMinPriority(p);\n });\n }\n };\n}\n\nfunction allRunnersFailed(runners): boolean {\n return Collections.all(runners, function(runner) {\n return Boolean(runner.error);\n });\n}\n\nfunction abortRunner(runner) {\n if (!runner.error && !runner.aborted) {\n runner.abort();\n runner.aborted = true;\n }\n}\n","import Util from '../util';\nimport Runtime from 'runtime';\nimport Strategy from './strategy';\nimport SequentialStrategy from './sequential_strategy';\nimport StrategyOptions from './strategy_options';\nimport TransportStrategy from './transport_strategy';\nimport Timeline from '../timeline/timeline';\nimport * as Collections from '../utils/collections';\n\nexport interface TransportStrategyDictionary {\n [key: string]: TransportStrategy;\n}\n\n/** Caches the last successful transport and, after the first few attempts,\n * uses the cached transport for subsequent attempts.\n *\n * @param {Strategy} strategy\n * @param {Object} transports\n * @param {Object} options\n */\nexport default class WebSocketPrioritizedCachedStrategy implements Strategy {\n strategy: Strategy;\n transports: TransportStrategyDictionary;\n ttl: number;\n usingTLS: boolean;\n timeline: Timeline;\n\n constructor(\n strategy: Strategy,\n transports: TransportStrategyDictionary,\n options: StrategyOptions\n ) {\n this.strategy = strategy;\n this.transports = transports;\n this.ttl = options.ttl || 1800 * 1000;\n this.usingTLS = options.useTLS;\n this.timeline = options.timeline;\n }\n\n isSupported(): boolean {\n return this.strategy.isSupported();\n }\n\n connect(minPriority: number, callback: Function) {\n var usingTLS = this.usingTLS;\n var info = fetchTransportCache(usingTLS);\n var cacheSkipCount = info && info.cacheSkipCount ? info.cacheSkipCount : 0;\n\n var strategies = [this.strategy];\n if (info && info.timestamp + this.ttl >= Util.now()) {\n var transport = this.transports[info.transport];\n if (transport) {\n if (['ws', 'wss'].includes(info.transport) || cacheSkipCount > 3) {\n this.timeline.info({\n cached: true,\n transport: info.transport,\n latency: info.latency\n });\n strategies.push(\n new SequentialStrategy([transport], {\n timeout: info.latency * 2 + 1000,\n failFast: true\n })\n );\n } else {\n cacheSkipCount++;\n }\n }\n }\n\n var startTimestamp = Util.now();\n var runner = strategies\n .pop()\n .connect(minPriority, function cb(error, handshake) {\n if (error) {\n flushTransportCache(usingTLS);\n if (strategies.length > 0) {\n startTimestamp = Util.now();\n runner = strategies.pop().connect(minPriority, cb);\n } else {\n callback(error);\n }\n } else {\n storeTransportCache(\n usingTLS,\n handshake.transport.name,\n Util.now() - startTimestamp,\n cacheSkipCount\n );\n callback(null, handshake);\n }\n });\n\n return {\n abort: function() {\n runner.abort();\n },\n forceMinPriority: function(p) {\n minPriority = p;\n if (runner) {\n runner.forceMinPriority(p);\n }\n }\n };\n }\n}\n\nfunction getTransportCacheKey(usingTLS: boolean): string {\n return 'pusherTransport' + (usingTLS ? 'TLS' : 'NonTLS');\n}\n\nfunction fetchTransportCache(usingTLS: boolean): any {\n var storage = Runtime.getLocalStorage();\n if (storage) {\n try {\n var serializedCache = storage[getTransportCacheKey(usingTLS)];\n if (serializedCache) {\n return JSON.parse(serializedCache);\n }\n } catch (e) {\n flushTransportCache(usingTLS);\n }\n }\n return null;\n}\n\nfunction storeTransportCache(\n usingTLS: boolean,\n transport: TransportStrategy,\n latency: number,\n cacheSkipCount: number\n) {\n var storage = Runtime.getLocalStorage();\n if (storage) {\n try {\n storage[getTransportCacheKey(usingTLS)] = Collections.safeJSONStringify({\n timestamp: Util.now(),\n transport: transport,\n latency: latency,\n cacheSkipCount: cacheSkipCount\n });\n } catch (e) {\n // catch over quota exceptions raised by localStorage\n }\n }\n}\n\nfunction flushTransportCache(usingTLS: boolean) {\n var storage = Runtime.getLocalStorage();\n if (storage) {\n try {\n delete storage[getTransportCacheKey(usingTLS)];\n } catch (e) {\n // catch exceptions raised by localStorage\n }\n }\n}\n","import { OneOffTimer as Timer } from '../utils/timers';\nimport Strategy from './strategy';\nimport StrategyOptions from './strategy_options';\n\n/** Runs substrategy after specified delay.\n *\n * Options:\n * - delay - time in miliseconds to delay the substrategy attempt\n *\n * @param {Strategy} strategy\n * @param {Object} options\n */\nexport default class DelayedStrategy implements Strategy {\n strategy: Strategy;\n options: { delay: number };\n\n constructor(strategy: Strategy, { delay: number }) {\n this.strategy = strategy;\n this.options = { delay: number };\n }\n\n isSupported(): boolean {\n return this.strategy.isSupported();\n }\n\n connect(minPriority: number, callback: Function) {\n var strategy = this.strategy;\n var runner;\n var timer = new Timer(this.options.delay, function() {\n runner = strategy.connect(minPriority, callback);\n });\n\n return {\n abort: function() {\n timer.ensureAborted();\n if (runner) {\n runner.abort();\n }\n },\n forceMinPriority: function(p) {\n minPriority = p;\n if (runner) {\n runner.forceMinPriority(p);\n }\n }\n };\n }\n}\n","import Strategy from './strategy';\nimport StrategyRunner from './strategy_runner';\n\n/** Proxies method calls to one of substrategies basing on the test function.\n *\n * @param {Function} test\n * @param {Strategy} trueBranch strategy used when test returns true\n * @param {Strategy} falseBranch strategy used when test returns false\n */\nexport default class IfStrategy implements Strategy {\n test: () => boolean;\n trueBranch: Strategy;\n falseBranch: Strategy;\n\n constructor(\n test: () => boolean,\n trueBranch: Strategy,\n falseBranch: Strategy\n ) {\n this.test = test;\n this.trueBranch = trueBranch;\n this.falseBranch = falseBranch;\n }\n\n isSupported(): boolean {\n var branch = this.test() ? this.trueBranch : this.falseBranch;\n return branch.isSupported();\n }\n\n connect(minPriority: number, callback: Function): StrategyRunner {\n var branch = this.test() ? this.trueBranch : this.falseBranch;\n return branch.connect(minPriority, callback);\n }\n}\n","import Strategy from './strategy';\nimport StrategyRunner from './strategy_runner';\n\n/** Launches the substrategy and terminates on the first open connection.\n *\n * @param {Strategy} strategy\n */\nexport default class FirstConnectedStrategy implements Strategy {\n strategy: Strategy;\n\n constructor(strategy: Strategy) {\n this.strategy = strategy;\n }\n\n isSupported(): boolean {\n return this.strategy.isSupported();\n }\n\n connect(minPriority: number, callback: Function): StrategyRunner {\n var runner = this.strategy.connect(minPriority, function(error, handshake) {\n if (handshake) {\n runner.abort();\n }\n callback(error, handshake);\n });\n return runner;\n }\n}\n","import * as Collections from 'core/utils/collections';\nimport TransportManager from 'core/transports/transport_manager';\nimport Strategy from 'core/strategies/strategy';\nimport SequentialStrategy from 'core/strategies/sequential_strategy';\nimport BestConnectedEverStrategy from 'core/strategies/best_connected_ever_strategy';\nimport WebSocketPrioritizedCachedStrategy, {\n TransportStrategyDictionary\n} from 'core/strategies/websocket_prioritized_cached_strategy';\nimport DelayedStrategy from 'core/strategies/delayed_strategy';\nimport IfStrategy from 'core/strategies/if_strategy';\nimport FirstConnectedStrategy from 'core/strategies/first_connected_strategy';\nimport { Config } from 'core/config';\nimport StrategyOptions from 'core/strategies/strategy_options';\n\nfunction testSupportsStrategy(strategy: Strategy) {\n return function() {\n return strategy.isSupported();\n };\n}\n\nvar getDefaultStrategy = function(\n config: Config,\n baseOptions: StrategyOptions,\n defineTransport: Function\n): Strategy {\n var definedTransports = {};\n\n function defineTransportStrategy(\n name: string,\n type: string,\n priority: number,\n options: StrategyOptions,\n manager?: TransportManager\n ) {\n var transport = defineTransport(\n config,\n name,\n type,\n priority,\n options,\n manager\n );\n\n definedTransports[name] = transport;\n\n return transport;\n }\n\n var ws_options: StrategyOptions = Object.assign({}, baseOptions, {\n hostNonTLS: config.wsHost + ':' + config.wsPort,\n hostTLS: config.wsHost + ':' + config.wssPort,\n httpPath: config.wsPath\n });\n var wss_options: StrategyOptions = Collections.extend({}, ws_options, {\n useTLS: true\n });\n var http_options: StrategyOptions = Object.assign({}, baseOptions, {\n hostNonTLS: config.httpHost + ':' + config.httpPort,\n hostTLS: config.httpHost + ':' + config.httpsPort,\n httpPath: config.httpPath\n });\n var timeouts = {\n loop: true,\n timeout: 15000,\n timeoutLimit: 60000\n };\n\n var ws_manager = new TransportManager({\n minPingDelay: 10000,\n maxPingDelay: config.activityTimeout\n });\n var streaming_manager = new TransportManager({\n lives: 2,\n minPingDelay: 10000,\n maxPingDelay: config.activityTimeout\n });\n\n var ws_transport = defineTransportStrategy(\n 'ws',\n 'ws',\n 3,\n ws_options,\n ws_manager\n );\n var wss_transport = defineTransportStrategy(\n 'wss',\n 'ws',\n 3,\n wss_options,\n ws_manager\n );\n var xhr_streaming_transport = defineTransportStrategy(\n 'xhr_streaming',\n 'xhr_streaming',\n 1,\n http_options,\n streaming_manager\n );\n var xhr_polling_transport = defineTransportStrategy(\n 'xhr_polling',\n 'xhr_polling',\n 1,\n http_options\n );\n\n var ws_loop = new SequentialStrategy([ws_transport], timeouts);\n var wss_loop = new SequentialStrategy([wss_transport], timeouts);\n var streaming_loop = new SequentialStrategy(\n [xhr_streaming_transport],\n timeouts\n );\n var polling_loop = new SequentialStrategy([xhr_polling_transport], timeouts);\n\n var http_loop = new SequentialStrategy(\n [\n new IfStrategy(\n testSupportsStrategy(streaming_loop),\n new BestConnectedEverStrategy([\n streaming_loop,\n new DelayedStrategy(polling_loop, { delay: 4000 })\n ]),\n polling_loop\n )\n ],\n timeouts\n );\n\n var wsStrategy;\n if (baseOptions.useTLS) {\n wsStrategy = new BestConnectedEverStrategy([\n ws_loop,\n new DelayedStrategy(http_loop, { delay: 2000 })\n ]);\n } else {\n wsStrategy = new BestConnectedEverStrategy([\n ws_loop,\n new DelayedStrategy(wss_loop, { delay: 2000 }),\n new DelayedStrategy(http_loop, { delay: 5000 })\n ]);\n }\n\n return new WebSocketPrioritizedCachedStrategy(\n new FirstConnectedStrategy(\n new IfStrategy(testSupportsStrategy(ws_transport), wsStrategy, http_loop)\n ),\n definedTransports,\n {\n ttl: 1800000,\n timeline: baseOptions.timeline,\n useTLS: baseOptions.useTLS\n }\n );\n};\n\nexport default getDefaultStrategy;\n","/** Initializes the transport.\n *\n * Fetches resources if needed and then transitions to initialized.\n */\nexport default function() {\n var self = this;\n\n self.timeline.info(\n self.buildTimelineMessage({\n transport: self.name + (self.options.useTLS ? 's' : '')\n })\n );\n\n if (self.hooks.isInitialized()) {\n self.changeState('initialized');\n } else {\n self.onClose();\n }\n}\n","import Runtime from 'runtime';\nimport RequestHooks from './request_hooks';\nimport Ajax from './ajax';\nimport { default as EventsDispatcher } from '../events/dispatcher';\n\nconst MAX_BUFFER_LENGTH = 256 * 1024;\n\nexport default class HTTPRequest extends EventsDispatcher {\n hooks: RequestHooks;\n method: string;\n url: string;\n position: number;\n xhr: Ajax;\n unloader: Function;\n\n constructor(hooks: RequestHooks, method: string, url: string) {\n super();\n this.hooks = hooks;\n this.method = method;\n this.url = url;\n }\n\n start(payload?: any) {\n this.position = 0;\n this.xhr = this.hooks.getRequest(this);\n\n this.unloader = () => {\n this.close();\n };\n Runtime.addUnloadListener(this.unloader);\n\n this.xhr.open(this.method, this.url, true);\n\n if (this.xhr.setRequestHeader) {\n this.xhr.setRequestHeader('Content-Type', 'application/json'); // ReactNative doesn't set this header by default.\n }\n this.xhr.send(payload);\n }\n\n close() {\n if (this.unloader) {\n Runtime.removeUnloadListener(this.unloader);\n this.unloader = null;\n }\n if (this.xhr) {\n this.hooks.abortRequest(this.xhr);\n this.xhr = null;\n }\n }\n\n onChunk(status: number, data: any) {\n while (true) {\n var chunk = this.advanceBuffer(data);\n if (chunk) {\n this.emit('chunk', { status: status, data: chunk });\n } else {\n break;\n }\n }\n if (this.isBufferTooLong(data)) {\n this.emit('buffer_too_long');\n }\n }\n\n private advanceBuffer(buffer: any[]): any {\n var unreadData = buffer.slice(this.position);\n var endOfLinePosition = unreadData.indexOf('\\n');\n\n if (endOfLinePosition !== -1) {\n this.position += endOfLinePosition + 1;\n return unreadData.slice(0, endOfLinePosition);\n } else {\n // chunk is not finished yet, don't move the buffer pointer\n return null;\n }\n }\n\n private isBufferTooLong(buffer: any): boolean {\n return this.position === buffer.length && buffer.length > MAX_BUFFER_LENGTH;\n }\n}\n","enum State {\n CONNECTING = 0,\n OPEN = 1,\n CLOSED = 3\n}\n\nexport default State;\n","import URLLocation from './url_location';\nimport State from './state';\nimport Socket from '../socket';\nimport SocketHooks from './socket_hooks';\nimport Util from '../util';\nimport Ajax from './ajax';\nimport HTTPRequest from './http_request';\nimport Runtime from 'runtime';\n\nvar autoIncrement = 1;\n\nclass HTTPSocket implements Socket {\n hooks: SocketHooks;\n session: string;\n location: URLLocation;\n readyState: State;\n stream: HTTPRequest;\n\n onopen: () => void;\n onerror: (error: any) => void;\n onclose: (closeEvent: any) => void;\n onmessage: (message: any) => void;\n onactivity: () => void;\n\n constructor(hooks: SocketHooks, url: string) {\n this.hooks = hooks;\n this.session = randomNumber(1000) + '/' + randomString(8);\n this.location = getLocation(url);\n this.readyState = State.CONNECTING;\n this.openStream();\n }\n\n send(payload: any) {\n return this.sendRaw(JSON.stringify([payload]));\n }\n\n ping() {\n this.hooks.sendHeartbeat(this);\n }\n\n close(code: any, reason: any) {\n this.onClose(code, reason, true);\n }\n\n /** For internal use only */\n sendRaw(payload: any): boolean {\n if (this.readyState === State.OPEN) {\n try {\n Runtime.createSocketRequest(\n 'POST',\n getUniqueURL(getSendURL(this.location, this.session))\n ).start(payload);\n return true;\n } catch (e) {\n return false;\n }\n } else {\n return false;\n }\n }\n\n /** For internal use only */\n reconnect() {\n this.closeStream();\n this.openStream();\n }\n\n /** For internal use only */\n onClose(code, reason, wasClean) {\n this.closeStream();\n this.readyState = State.CLOSED;\n if (this.onclose) {\n this.onclose({\n code: code,\n reason: reason,\n wasClean: wasClean\n });\n }\n }\n\n private onChunk(chunk) {\n if (chunk.status !== 200) {\n return;\n }\n if (this.readyState === State.OPEN) {\n this.onActivity();\n }\n\n var payload;\n var type = chunk.data.slice(0, 1);\n switch (type) {\n case 'o':\n payload = JSON.parse(chunk.data.slice(1) || '{}');\n this.onOpen(payload);\n break;\n case 'a':\n payload = JSON.parse(chunk.data.slice(1) || '[]');\n for (var i = 0; i < payload.length; i++) {\n this.onEvent(payload[i]);\n }\n break;\n case 'm':\n payload = JSON.parse(chunk.data.slice(1) || 'null');\n this.onEvent(payload);\n break;\n case 'h':\n this.hooks.onHeartbeat(this);\n break;\n case 'c':\n payload = JSON.parse(chunk.data.slice(1) || '[]');\n this.onClose(payload[0], payload[1], true);\n break;\n }\n }\n\n private onOpen(options) {\n if (this.readyState === State.CONNECTING) {\n if (options && options.hostname) {\n this.location.base = replaceHost(this.location.base, options.hostname);\n }\n this.readyState = State.OPEN;\n\n if (this.onopen) {\n this.onopen();\n }\n } else {\n this.onClose(1006, 'Server lost session', true);\n }\n }\n\n private onEvent(event) {\n if (this.readyState === State.OPEN && this.onmessage) {\n this.onmessage({ data: event });\n }\n }\n\n private onActivity() {\n if (this.onactivity) {\n this.onactivity();\n }\n }\n\n private onError(error) {\n if (this.onerror) {\n this.onerror(error);\n }\n }\n\n private openStream() {\n this.stream = Runtime.createSocketRequest(\n 'POST',\n getUniqueURL(this.hooks.getReceiveURL(this.location, this.session))\n );\n\n this.stream.bind('chunk', chunk => {\n this.onChunk(chunk);\n });\n this.stream.bind('finished', status => {\n this.hooks.onFinished(this, status);\n });\n this.stream.bind('buffer_too_long', () => {\n this.reconnect();\n });\n\n try {\n this.stream.start();\n } catch (error) {\n Util.defer(() => {\n this.onError(error);\n this.onClose(1006, 'Could not start streaming', false);\n });\n }\n }\n\n private closeStream() {\n if (this.stream) {\n this.stream.unbind_all();\n this.stream.close();\n this.stream = null;\n }\n }\n}\n\nfunction getLocation(url): URLLocation {\n var parts = /([^\\?]*)\\/*(\\??.*)/.exec(url);\n return {\n base: parts[1],\n queryString: parts[2]\n };\n}\n\nfunction getSendURL(url: URLLocation, session: string): string {\n return url.base + '/' + session + '/xhr_send';\n}\n\nfunction getUniqueURL(url: string): string {\n var separator = url.indexOf('?') === -1 ? '?' : '&';\n return url + separator + 't=' + +new Date() + '&n=' + autoIncrement++;\n}\n\nfunction replaceHost(url: string, hostname: string): string {\n var urlParts = /(https?:\\/\\/)([^\\/:]+)((\\/|:)?.*)/.exec(url);\n return urlParts[1] + hostname + urlParts[3];\n}\n\nfunction randomNumber(max: number): number {\n return Runtime.randomInt(max);\n}\n\nfunction randomString(length: number): string {\n var result = [];\n\n for (var i = 0; i < length; i++) {\n result.push(randomNumber(32).toString(32));\n }\n\n return result.join('');\n}\n\nexport default HTTPSocket;\n","import SocketHooks from './socket_hooks';\nimport HTTPSocket from './http_socket';\n\nvar hooks: SocketHooks = {\n getReceiveURL: function(url, session) {\n return url.base + '/' + session + '/xhr_streaming' + url.queryString;\n },\n onHeartbeat: function(socket) {\n socket.sendRaw('[]');\n },\n sendHeartbeat: function(socket) {\n socket.sendRaw('[]');\n },\n onFinished: function(socket, status) {\n socket.onClose(1006, 'Connection interrupted (' + status + ')', false);\n }\n};\n\nexport default hooks;\n","import SocketHooks from './socket_hooks';\nimport URLLocation from './url_location';\nimport HTTPSocket from './http_socket';\n\nvar hooks: SocketHooks = {\n getReceiveURL: function(url: URLLocation, session: string): string {\n return url.base + '/' + session + '/xhr' + url.queryString;\n },\n onHeartbeat: function() {\n // next HTTP request will reset server's activity timer\n },\n sendHeartbeat: function(socket) {\n socket.sendRaw('[]');\n },\n onFinished: function(socket, status) {\n if (status === 200) {\n socket.reconnect();\n } else {\n socket.onClose(1006, 'Connection interrupted (' + status + ')', false);\n }\n }\n};\n\nexport default hooks;\n","import HTTPRequest from 'core/http/http_request';\nimport RequestHooks from 'core/http/request_hooks';\nimport Ajax from 'core/http/ajax';\nimport Runtime from 'runtime';\n\nvar hooks: RequestHooks = {\n getRequest: function(socket: HTTPRequest): Ajax {\n var Constructor = Runtime.getXHRAPI();\n var xhr = new Constructor();\n xhr.onreadystatechange = xhr.onprogress = function() {\n switch (xhr.readyState) {\n case 3:\n if (xhr.responseText && xhr.responseText.length > 0) {\n socket.onChunk(xhr.status, xhr.responseText);\n }\n break;\n case 4:\n // this happens only on errors, never after calling close\n if (xhr.responseText && xhr.responseText.length > 0) {\n socket.onChunk(xhr.status, xhr.responseText);\n }\n socket.emit('finished', xhr.status);\n socket.close();\n break;\n }\n };\n return xhr;\n },\n abortRequest: function(xhr: Ajax) {\n xhr.onreadystatechange = null;\n xhr.abort();\n }\n};\n\nexport default hooks;\n","import HTTPRequest from 'core/http/http_request';\nimport HTTPSocket from 'core/http/http_socket';\nimport SocketHooks from 'core/http/socket_hooks';\nimport RequestHooks from 'core/http/request_hooks';\nimport streamingHooks from 'core/http/http_streaming_socket';\nimport pollingHooks from 'core/http/http_polling_socket';\nimport xhrHooks from './http_xhr_request';\nimport HTTPFactory from 'core/http/http_factory';\n\nvar HTTP: HTTPFactory = {\n createStreamingSocket(url: string): HTTPSocket {\n return this.createSocket(streamingHooks, url);\n },\n\n createPollingSocket(url: string): HTTPSocket {\n return this.createSocket(pollingHooks, url);\n },\n\n createSocket(hooks: SocketHooks, url: string): HTTPSocket {\n return new HTTPSocket(hooks, url);\n },\n\n createXHR(method: string, url: string): HTTPRequest {\n return this.createRequest(xhrHooks, method, url);\n },\n\n createRequest(hooks: RequestHooks, method: string, url: string): HTTPRequest {\n return new HTTPRequest(hooks, method, url);\n }\n};\n\nexport default HTTP;\n","import * as Collections from 'core/utils/collections';\nimport Transports from 'isomorphic/transports/transports';\nimport TimelineSender from 'core/timeline/timeline_sender';\nimport Ajax from 'core/http/ajax';\nimport getDefaultStrategy from './default_strategy';\nimport TransportsTable from 'core/transports/transports_table';\nimport transportConnectionInitializer from './transports/transport_connection_initializer';\nimport HTTPFactory from './http/http';\n\nvar Isomorphic: any = {\n getDefaultStrategy,\n Transports: Transports,\n transportConnectionInitializer,\n HTTPFactory,\n\n setup(PusherClass): void {\n PusherClass.ready();\n },\n\n getLocalStorage(): any {\n return undefined;\n },\n\n getClientFeatures(): any[] {\n return Collections.keys(\n Collections.filterObject({ ws: Transports.ws }, function(t) {\n return t.isSupported({});\n })\n );\n },\n\n getProtocol(): string {\n return 'http:';\n },\n\n isXHRSupported(): boolean {\n return true;\n },\n\n createSocketRequest(method: string, url: string) {\n if (this.isXHRSupported()) {\n return this.HTTPFactory.createXHR(method, url);\n } else {\n throw 'Cross-origin HTTP requests are not supported';\n }\n },\n\n createXHR(): Ajax {\n var Constructor = this.getXHRAPI();\n return new Constructor();\n },\n\n createWebSocket(url: string): any {\n var Constructor = this.getWebSocketAPI();\n return new Constructor(url);\n },\n\n addUnloadListener(listener: any) {},\n removeUnloadListener(listener: any) {}\n};\n\nexport default Isomorphic;\n","import { default as EventsDispatcher } from 'core/events/dispatcher';\nimport Reachability from 'core/reachability';\n\nexport class NetInfo extends EventsDispatcher implements Reachability {\n isOnline(): boolean {\n return true;\n }\n}\n\nexport var Network = new NetInfo();\n","import AbstractRuntime from 'runtimes/interface';\nimport { AuthTransport } from 'core/auth/auth_transports';\nimport {\n AuthRequestType,\n AuthTransportCallback,\n InternalAuthOptions\n} from 'core/auth/options';\nimport { HTTPAuthError } from 'core/errors';\n\nvar fetchAuth: AuthTransport = function(\n context: AbstractRuntime,\n query: string,\n authOptions: InternalAuthOptions,\n authRequestType: AuthRequestType,\n callback: AuthTransportCallback\n) {\n var headers = new Headers();\n headers.set('Content-Type', 'application/x-www-form-urlencoded');\n\n for (var headerName in authOptions.headers) {\n headers.set(headerName, authOptions.headers[headerName]);\n }\n\n if (authOptions.headersProvider != null) {\n const dynamicHeaders = authOptions.headersProvider();\n for (var headerName in dynamicHeaders) {\n headers.set(headerName, dynamicHeaders[headerName]);\n }\n }\n\n var body = query;\n var request = new Request(authOptions.endpoint, {\n headers,\n body,\n credentials: 'same-origin',\n method: 'POST'\n });\n\n return fetch(request)\n .then(response => {\n let { status } = response;\n if (status === 200) {\n // manually parse the json so we can provide a more helpful error in\n // failure case\n return response.text();\n }\n throw new HTTPAuthError(\n status,\n `Could not get ${authRequestType.toString()} info from your auth endpoint, status: ${status}`\n );\n })\n .then(data => {\n let parsedData;\n try {\n parsedData = JSON.parse(data);\n } catch (e) {\n throw new HTTPAuthError(\n 200,\n `JSON returned from ${authRequestType.toString()} endpoint was invalid, yet status code was 200. Data was: ${data}`\n );\n }\n callback(null, parsedData);\n })\n .catch(err => {\n callback(err, null);\n });\n};\n\nexport default fetchAuth;\n","import Logger from 'core/logger';\nimport TimelineSender from 'core/timeline/timeline_sender';\nimport * as Collections from 'core/utils/collections';\nimport Util from 'core/util';\nimport Runtime from 'runtime';\nimport TimelineTransport from 'core/timeline/timeline_transport';\n\nvar getAgent = function(sender: TimelineSender, useTLS: boolean) {\n return function(data: any, callback: Function) {\n var scheme = 'http' + (useTLS ? 's' : '') + '://';\n var url =\n scheme + (sender.host || sender.options.host) + sender.options.path;\n var query = Collections.buildQueryString(data);\n url += '/' + 2 + '?' + query;\n\n fetch(url)\n .then(response => {\n if (response.status !== 200) {\n throw `received ${response.status} from stats.pusher.com`;\n }\n return response.json();\n })\n .then(({ host }) => {\n if (host) {\n sender.host = host;\n }\n })\n .catch(err => {\n Logger.debug('TimelineSender Error: ', err);\n });\n };\n};\n\nvar fetchTimeline = {\n name: 'xhr',\n getAgent\n};\n\nexport default fetchTimeline;\n","import Isomorphic from 'isomorphic/runtime';\nimport Runtime from '../interface';\nimport { Network } from './net_info';\nimport fetchAuth from './auth/fetch_auth';\nimport { AuthTransports } from 'core/auth/auth_transports';\nimport fetchTimeline from './timeline/fetch_timeline';\n\n// Very verbose but until unavoidable until\n// TypeScript 2.1, when spread attributes will be\n// supported\nconst {\n getDefaultStrategy,\n Transports,\n setup,\n getProtocol,\n isXHRSupported,\n getLocalStorage,\n createXHR,\n createWebSocket,\n addUnloadListener,\n removeUnloadListener,\n transportConnectionInitializer,\n createSocketRequest,\n HTTPFactory\n} = Isomorphic;\n\nconst Worker: Runtime = {\n getDefaultStrategy,\n Transports,\n setup,\n getProtocol,\n isXHRSupported,\n getLocalStorage,\n createXHR,\n createWebSocket,\n addUnloadListener,\n removeUnloadListener,\n transportConnectionInitializer,\n createSocketRequest,\n HTTPFactory,\n\n TimelineTransport: fetchTimeline,\n\n getAuthorizers(): AuthTransports {\n return { ajax: fetchAuth };\n },\n\n getWebSocketAPI() {\n return WebSocket;\n },\n\n getXHRAPI() {\n return XMLHttpRequest;\n },\n\n getNetwork() {\n return Network;\n },\n\n randomInt(max: number): number {\n /**\n * Return values in the range of [0, 1[\n */\n const random = function() {\n const crypto = globalThis.crypto || globalThis['msCrypto'];\n const random = crypto.getRandomValues(new Uint32Array(1))[0];\n\n return random / 2 ** 32;\n };\n\n return Math.floor(random() * max);\n }\n};\n\nexport default Worker;\n","enum TimelineLevel {\n ERROR = 3,\n INFO = 6,\n DEBUG = 7\n}\n\nexport default TimelineLevel;\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport { default as Level } from './level';\n\nexport interface TimelineOptions {\n level?: Level;\n limit?: number;\n version?: string;\n cluster?: string;\n features?: string[];\n params?: any;\n}\n\nexport default class Timeline {\n key: string;\n session: number;\n events: any[];\n options: TimelineOptions;\n sent: number;\n uniqueID: number;\n\n constructor(key: string, session: number, options: TimelineOptions) {\n this.key = key;\n this.session = session;\n this.events = [];\n this.options = options || {};\n this.sent = 0;\n this.uniqueID = 0;\n }\n\n log(level, event) {\n if (level <= this.options.level) {\n this.events.push(\n Collections.extend({}, event, { timestamp: Util.now() })\n );\n if (this.options.limit && this.events.length > this.options.limit) {\n this.events.shift();\n }\n }\n }\n\n error(event) {\n this.log(Level.ERROR, event);\n }\n\n info(event) {\n this.log(Level.INFO, event);\n }\n\n debug(event) {\n this.log(Level.DEBUG, event);\n }\n\n isEmpty() {\n return this.events.length === 0;\n }\n\n send(sendfn, callback) {\n var data = Collections.extend(\n {\n session: this.session,\n bundle: this.sent + 1,\n key: this.key,\n lib: 'js',\n version: this.options.version,\n cluster: this.options.cluster,\n features: this.options.features,\n timeline: this.events\n },\n this.options.params\n );\n\n this.events = [];\n sendfn(data, (error, result) => {\n if (!error) {\n this.sent++;\n }\n if (callback) {\n callback(error, result);\n }\n });\n\n return true;\n }\n\n generateUniqueID(): number {\n this.uniqueID++;\n return this.uniqueID;\n }\n}\n","import Factory from '../utils/factory';\nimport Util from '../util';\nimport * as Errors from '../errors';\nimport * as Collections from '../utils/collections';\nimport Strategy from './strategy';\nimport Transport from '../transports/transport';\nimport StrategyOptions from './strategy_options';\nimport Handshake from '../connection/handshake';\n\n/** Provides a strategy interface for transports.\n *\n * @param {String} name\n * @param {Number} priority\n * @param {Class} transport\n * @param {Object} options\n */\nexport default class TransportStrategy implements Strategy {\n name: string;\n priority: number;\n transport: Transport;\n options: StrategyOptions;\n\n constructor(\n name: string,\n priority: number,\n transport: Transport,\n options: StrategyOptions\n ) {\n this.name = name;\n this.priority = priority;\n this.transport = transport;\n this.options = options || {};\n }\n\n /** Returns whether the transport is supported in the browser.\n *\n * @returns {Boolean}\n */\n isSupported(): boolean {\n return this.transport.isSupported({\n useTLS: this.options.useTLS\n });\n }\n\n /** Launches a connection attempt and returns a strategy runner.\n *\n * @param {Function} callback\n * @return {Object} strategy runner\n */\n connect(minPriority: number, callback: Function) {\n if (!this.isSupported()) {\n return failAttempt(new Errors.UnsupportedStrategy(), callback);\n } else if (this.priority < minPriority) {\n return failAttempt(new Errors.TransportPriorityTooLow(), callback);\n }\n\n var connected = false;\n var transport = this.transport.createConnection(\n this.name,\n this.priority,\n this.options.key,\n this.options\n );\n var handshake = null;\n\n var onInitialized = function() {\n transport.unbind('initialized', onInitialized);\n transport.connect();\n };\n var onOpen = function() {\n handshake = Factory.createHandshake(transport, function(result) {\n connected = true;\n unbindListeners();\n callback(null, result);\n });\n };\n var onError = function(error) {\n unbindListeners();\n callback(error);\n };\n var onClosed = function() {\n unbindListeners();\n var serializedTransport;\n\n // The reason for this try/catch block is that on React Native\n // the WebSocket object is circular. Therefore transport.socket will\n // throw errors upon stringification. Collections.safeJSONStringify\n // discards circular references when serializing.\n serializedTransport = Collections.safeJSONStringify(transport);\n callback(new Errors.TransportClosed(serializedTransport));\n };\n\n var unbindListeners = function() {\n transport.unbind('initialized', onInitialized);\n transport.unbind('open', onOpen);\n transport.unbind('error', onError);\n transport.unbind('closed', onClosed);\n };\n\n transport.bind('initialized', onInitialized);\n transport.bind('open', onOpen);\n transport.bind('error', onError);\n transport.bind('closed', onClosed);\n\n // connect will be called automatically after initialization\n transport.initialize();\n\n return {\n abort: () => {\n if (connected) {\n return;\n }\n unbindListeners();\n if (handshake) {\n handshake.close();\n } else {\n transport.close();\n }\n },\n forceMinPriority: p => {\n if (connected) {\n return;\n }\n if (this.priority < p) {\n if (handshake) {\n handshake.close();\n } else {\n transport.close();\n }\n }\n }\n };\n }\n}\n\nfunction failAttempt(error: Error, callback: Function) {\n Util.defer(function() {\n callback(error);\n });\n return {\n abort: function() {},\n forceMinPriority: function() {}\n };\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport TransportManager from '../transports/transport_manager';\nimport * as Errors from '../errors';\nimport Strategy from './strategy';\nimport TransportStrategy from './transport_strategy';\nimport StrategyOptions from '../strategies/strategy_options';\nimport { Config } from '../config';\nimport Runtime from 'runtime';\n\nconst { Transports } = Runtime;\n\nexport var defineTransport = function(\n config: Config,\n name: string,\n type: string,\n priority: number,\n options: StrategyOptions,\n manager?: TransportManager\n): Strategy {\n var transportClass = Transports[type];\n if (!transportClass) {\n throw new Errors.UnsupportedTransport(type);\n }\n\n var enabled =\n (!config.enabledTransports ||\n Collections.arrayIndexOf(config.enabledTransports, name) !== -1) &&\n (!config.disabledTransports ||\n Collections.arrayIndexOf(config.disabledTransports, name) === -1);\n\n var transport;\n if (enabled) {\n options = Object.assign(\n { ignoreNullOrigin: config.ignoreNullOrigin },\n options\n );\n\n transport = new TransportStrategy(\n name,\n priority,\n manager ? manager.getAssistant(transportClass) : transportClass,\n options\n );\n } else {\n transport = UnsupportedStrategy;\n }\n\n return transport;\n};\n\nvar UnsupportedStrategy: Strategy = {\n isSupported: function() {\n return false;\n },\n connect: function(_, callback) {\n var deferred = Util.defer(function() {\n callback(new Errors.UnsupportedStrategy());\n });\n return {\n abort: function() {\n deferred.ensureAborted();\n },\n forceMinPriority: function() {}\n };\n }\n};\n","import ConnectionManager from './connection/connection_manager';\nimport {\n ChannelAuthorizationOptions,\n UserAuthenticationOptions\n} from './auth/options';\nimport {\n ChannelAuthorizerGenerator,\n DeprecatedAuthOptions\n} from './auth/deprecated_channel_authorizer';\nimport { AuthTransport, Transport } from './config';\nimport * as nacl from 'tweetnacl';\nimport Logger from './logger';\n\nexport interface Options {\n activityTimeout?: number;\n\n auth?: DeprecatedAuthOptions; // DEPRECATED use channelAuthorization instead\n authEndpoint?: string; // DEPRECATED use channelAuthorization instead\n authTransport?: AuthTransport; // DEPRECATED use channelAuthorization instead\n authorizer?: ChannelAuthorizerGenerator; // DEPRECATED use channelAuthorization instead\n\n channelAuthorization?: ChannelAuthorizationOptions;\n userAuthentication?: UserAuthenticationOptions;\n\n cluster: string;\n enableStats?: boolean;\n disableStats?: boolean;\n disabledTransports?: Transport[];\n enabledTransports?: Transport[];\n forceTLS?: boolean;\n httpHost?: string;\n httpPath?: string;\n httpPort?: number;\n httpsPort?: number;\n ignoreNullOrigin?: boolean;\n nacl?: nacl;\n pongTimeout?: number;\n statsHost?: string;\n timelineParams?: any;\n unavailableTimeout?: number;\n wsHost?: string;\n wsPath?: string;\n wsPort?: number;\n wssPort?: number;\n}\n\nexport interface ClusterOptions {\n appKey: string;\n cluster: string;\n}\n\nexport function validateOptions(options) {\n if (options == null) {\n throw 'You must pass an options object';\n }\n if (options.cluster == null) {\n throw 'Options object must provide a cluster';\n }\n if ('disableStats' in options) {\n Logger.warn(\n 'The disableStats option is deprecated in favor of enableStats'\n );\n }\n}\n","export enum AuthRequestType {\n UserAuthentication = 'user-authentication',\n ChannelAuthorization = 'channel-authorization'\n}\n\nexport interface ChannelAuthorizationData {\n auth: string;\n channel_data?: string;\n shared_secret?: string;\n}\n\nexport type ChannelAuthorizationCallback = (\n error: Error | null,\n authData: ChannelAuthorizationData | null\n) => void;\n\nexport interface ChannelAuthorizationRequestParams {\n socketId: string;\n channelName: string;\n}\n\nexport interface ChannelAuthorizationHandler {\n (\n params: ChannelAuthorizationRequestParams,\n callback: ChannelAuthorizationCallback\n ): void;\n}\n\nexport interface UserAuthenticationData {\n auth: string;\n user_data: string;\n}\n\nexport type UserAuthenticationCallback = (\n error: Error | null,\n authData: UserAuthenticationData | null\n) => void;\n\nexport interface UserAuthenticationRequestParams {\n socketId: string;\n}\n\nexport interface UserAuthenticationHandler {\n (\n params: UserAuthenticationRequestParams,\n callback: UserAuthenticationCallback\n ): void;\n}\n\nexport type AuthTransportCallback =\n | ChannelAuthorizationCallback\n | UserAuthenticationCallback;\n\nexport interface AuthOptionsT {\n transport: 'ajax' | 'jsonp';\n endpoint: string;\n params?: any;\n headers?: any;\n paramsProvider?: () => any;\n headersProvider?: () => any;\n customHandler?: AuthHandler;\n}\n\nexport declare type UserAuthenticationOptions = AuthOptionsT<\n UserAuthenticationHandler\n>;\nexport declare type ChannelAuthorizationOptions = AuthOptionsT<\n ChannelAuthorizationHandler\n>;\n\nexport interface InternalAuthOptions {\n transport: 'ajax' | 'jsonp';\n endpoint: string;\n params?: any;\n headers?: any;\n paramsProvider?: () => any;\n headersProvider?: () => any;\n}\n","import {\n UserAuthenticationCallback,\n InternalAuthOptions,\n UserAuthenticationHandler,\n UserAuthenticationRequestParams,\n AuthRequestType\n} from './options';\n\nimport Runtime from 'runtime';\n\nconst composeChannelQuery = (\n params: UserAuthenticationRequestParams,\n authOptions: InternalAuthOptions\n) => {\n var query = 'socket_id=' + encodeURIComponent(params.socketId);\n\n for (var key in authOptions.params) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(authOptions.params[key]);\n }\n\n if (authOptions.paramsProvider != null) {\n let dynamicParams = authOptions.paramsProvider();\n for (var key in dynamicParams) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(dynamicParams[key]);\n }\n }\n\n return query;\n};\n\nconst UserAuthenticator = (\n authOptions: InternalAuthOptions\n): UserAuthenticationHandler => {\n if (typeof Runtime.getAuthorizers()[authOptions.transport] === 'undefined') {\n throw `'${authOptions.transport}' is not a recognized auth transport`;\n }\n\n return (\n params: UserAuthenticationRequestParams,\n callback: UserAuthenticationCallback\n ) => {\n const query = composeChannelQuery(params, authOptions);\n\n Runtime.getAuthorizers()[authOptions.transport](\n Runtime,\n query,\n authOptions,\n AuthRequestType.UserAuthentication,\n callback\n );\n };\n};\n\nexport default UserAuthenticator;\n","import {\n AuthRequestType,\n InternalAuthOptions,\n ChannelAuthorizationHandler,\n ChannelAuthorizationRequestParams,\n ChannelAuthorizationCallback\n} from './options';\n\nimport Runtime from 'runtime';\n\nconst composeChannelQuery = (\n params: ChannelAuthorizationRequestParams,\n authOptions: InternalAuthOptions\n) => {\n var query = 'socket_id=' + encodeURIComponent(params.socketId);\n\n query += '&channel_name=' + encodeURIComponent(params.channelName);\n\n for (var key in authOptions.params) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(authOptions.params[key]);\n }\n\n if (authOptions.paramsProvider != null) {\n let dynamicParams = authOptions.paramsProvider();\n for (var key in dynamicParams) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(dynamicParams[key]);\n }\n }\n\n return query;\n};\n\nconst ChannelAuthorizer = (\n authOptions: InternalAuthOptions\n): ChannelAuthorizationHandler => {\n if (typeof Runtime.getAuthorizers()[authOptions.transport] === 'undefined') {\n throw `'${authOptions.transport}' is not a recognized auth transport`;\n }\n\n return (\n params: ChannelAuthorizationRequestParams,\n callback: ChannelAuthorizationCallback\n ) => {\n const query = composeChannelQuery(params, authOptions);\n\n Runtime.getAuthorizers()[authOptions.transport](\n Runtime,\n query,\n authOptions,\n AuthRequestType.ChannelAuthorization,\n callback\n );\n };\n};\n\nexport default ChannelAuthorizer;\n","import Channel from '../channels/channel';\nimport {\n ChannelAuthorizationCallback,\n ChannelAuthorizationHandler,\n ChannelAuthorizationRequestParams,\n InternalAuthOptions\n} from './options';\n\nexport interface DeprecatedChannelAuthorizer {\n authorize(socketId: string, callback: ChannelAuthorizationCallback): void;\n}\n\nexport interface ChannelAuthorizerGenerator {\n (\n channel: Channel,\n options: DeprecatedAuthorizerOptions\n ): DeprecatedChannelAuthorizer;\n}\n\nexport interface DeprecatedAuthOptions {\n params?: any;\n headers?: any;\n}\n\nexport interface DeprecatedAuthorizerOptions {\n authTransport: 'ajax' | 'jsonp';\n authEndpoint: string;\n auth?: DeprecatedAuthOptions;\n}\n\nexport const ChannelAuthorizerProxy = (\n pusher,\n authOptions: InternalAuthOptions,\n channelAuthorizerGenerator: ChannelAuthorizerGenerator\n): ChannelAuthorizationHandler => {\n const deprecatedAuthorizerOptions: DeprecatedAuthorizerOptions = {\n authTransport: authOptions.transport,\n authEndpoint: authOptions.endpoint,\n auth: {\n params: authOptions.params,\n headers: authOptions.headers\n }\n };\n return (\n params: ChannelAuthorizationRequestParams,\n callback: ChannelAuthorizationCallback\n ) => {\n const channel = pusher.channel(params.channelName);\n // This line creates a new channel authorizer every time.\n // In the past, this was only done once per channel and reused.\n // We can do that again if we want to keep this behavior intact.\n const channelAuthorizer: DeprecatedChannelAuthorizer = channelAuthorizerGenerator(\n channel,\n deprecatedAuthorizerOptions\n );\n channelAuthorizer.authorize(params.socketId, callback);\n };\n};\n","import { Options } from './options';\nimport Defaults from './defaults';\nimport {\n ChannelAuthorizationHandler,\n UserAuthenticationHandler,\n ChannelAuthorizationOptions\n} from './auth/options';\nimport UserAuthenticator from './auth/user_authenticator';\nimport ChannelAuthorizer from './auth/channel_authorizer';\nimport { ChannelAuthorizerProxy } from './auth/deprecated_channel_authorizer';\nimport Runtime from 'runtime';\nimport * as nacl from 'tweetnacl';\n\nexport type AuthTransport = 'ajax' | 'jsonp';\nexport type Transport =\n | 'ws'\n | 'wss'\n | 'xhr_streaming'\n | 'xhr_polling'\n | 'sockjs';\n\nexport interface Config {\n // these are all 'required' config parameters, it's not necessary for the user\n // to set them, but they have configured defaults.\n activityTimeout: number;\n enableStats: boolean;\n httpHost: string;\n httpPath: string;\n httpPort: number;\n httpsPort: number;\n pongTimeout: number;\n statsHost: string;\n unavailableTimeout: number;\n useTLS: boolean;\n wsHost: string;\n wsPath: string;\n wsPort: number;\n wssPort: number;\n userAuthenticator: UserAuthenticationHandler;\n channelAuthorizer: ChannelAuthorizationHandler;\n\n // these are all optional parameters or overrrides. The customer can set these\n // but it's not strictly necessary\n forceTLS?: boolean;\n cluster?: string;\n disabledTransports?: Transport[];\n enabledTransports?: Transport[];\n ignoreNullOrigin?: boolean;\n nacl?: nacl;\n timelineParams?: any;\n}\n\n// getConfig mainly sets the defaults for the options that are not provided\nexport function getConfig(opts: Options, pusher): Config {\n let config: Config = {\n activityTimeout: opts.activityTimeout || Defaults.activityTimeout,\n cluster: opts.cluster,\n httpPath: opts.httpPath || Defaults.httpPath,\n httpPort: opts.httpPort || Defaults.httpPort,\n httpsPort: opts.httpsPort || Defaults.httpsPort,\n pongTimeout: opts.pongTimeout || Defaults.pongTimeout,\n statsHost: opts.statsHost || Defaults.stats_host,\n unavailableTimeout: opts.unavailableTimeout || Defaults.unavailableTimeout,\n wsPath: opts.wsPath || Defaults.wsPath,\n wsPort: opts.wsPort || Defaults.wsPort,\n wssPort: opts.wssPort || Defaults.wssPort,\n\n enableStats: getEnableStatsConfig(opts),\n httpHost: getHttpHost(opts),\n useTLS: shouldUseTLS(opts),\n wsHost: getWebsocketHost(opts),\n\n userAuthenticator: buildUserAuthenticator(opts),\n channelAuthorizer: buildChannelAuthorizer(opts, pusher)\n };\n\n if ('disabledTransports' in opts)\n config.disabledTransports = opts.disabledTransports;\n if ('enabledTransports' in opts)\n config.enabledTransports = opts.enabledTransports;\n if ('ignoreNullOrigin' in opts)\n config.ignoreNullOrigin = opts.ignoreNullOrigin;\n if ('timelineParams' in opts) config.timelineParams = opts.timelineParams;\n if ('nacl' in opts) {\n config.nacl = opts.nacl;\n }\n\n return config;\n}\n\nfunction getHttpHost(opts: Options): string {\n if (opts.httpHost) {\n return opts.httpHost;\n }\n if (opts.cluster) {\n return `sockjs-${opts.cluster}.pusher.com`;\n }\n return Defaults.httpHost;\n}\n\nfunction getWebsocketHost(opts: Options): string {\n if (opts.wsHost) {\n return opts.wsHost;\n }\n return getWebsocketHostFromCluster(opts.cluster);\n}\n\nfunction getWebsocketHostFromCluster(cluster: string): string {\n return `ws-${cluster}.pusher.com`;\n}\n\nfunction shouldUseTLS(opts: Options): boolean {\n if (Runtime.getProtocol() === 'https:') {\n return true;\n } else if (opts.forceTLS === false) {\n return false;\n }\n return true;\n}\n\n// if enableStats is set take the value\n// if disableStats is set take the inverse\n// otherwise default to false\nfunction getEnableStatsConfig(opts: Options): boolean {\n if ('enableStats' in opts) {\n return opts.enableStats;\n }\n if ('disableStats' in opts) {\n return !opts.disableStats;\n }\n return false;\n}\n\nfunction buildUserAuthenticator(opts: Options): UserAuthenticationHandler {\n const userAuthentication = {\n ...Defaults.userAuthentication,\n ...opts.userAuthentication\n };\n if (\n 'customHandler' in userAuthentication &&\n userAuthentication['customHandler'] != null\n ) {\n return userAuthentication['customHandler'];\n }\n\n return UserAuthenticator(userAuthentication);\n}\n\nfunction buildChannelAuth(opts: Options, pusher): ChannelAuthorizationOptions {\n let channelAuthorization: ChannelAuthorizationOptions;\n if ('channelAuthorization' in opts) {\n channelAuthorization = {\n ...Defaults.channelAuthorization,\n ...opts.channelAuthorization\n };\n } else {\n channelAuthorization = {\n transport: opts.authTransport || Defaults.authTransport,\n endpoint: opts.authEndpoint || Defaults.authEndpoint\n };\n if ('auth' in opts) {\n if ('params' in opts.auth) channelAuthorization.params = opts.auth.params;\n if ('headers' in opts.auth)\n channelAuthorization.headers = opts.auth.headers;\n }\n if ('authorizer' in opts)\n channelAuthorization.customHandler = ChannelAuthorizerProxy(\n pusher,\n channelAuthorization,\n opts.authorizer\n );\n }\n return channelAuthorization;\n}\n\nfunction buildChannelAuthorizer(\n opts: Options,\n pusher\n): ChannelAuthorizationHandler {\n const channelAuthorization = buildChannelAuth(opts, pusher);\n if (\n 'customHandler' in channelAuthorization &&\n channelAuthorization['customHandler'] != null\n ) {\n return channelAuthorization['customHandler'];\n }\n\n return ChannelAuthorizer(channelAuthorization);\n}\n","import Logger from './logger';\nimport Pusher from './pusher';\nimport EventsDispatcher from './events/dispatcher';\n\nexport default class WatchlistFacade extends EventsDispatcher {\n private pusher: Pusher;\n\n public constructor(pusher: Pusher) {\n super(function(eventName, data) {\n Logger.debug(`No callbacks on watchlist events for ${eventName}`);\n });\n\n this.pusher = pusher;\n this.bindWatchlistInternalEvent();\n }\n\n handleEvent(pusherEvent) {\n pusherEvent.data.events.forEach(watchlistEvent => {\n this.emit(watchlistEvent.name, watchlistEvent);\n });\n }\n\n private bindWatchlistInternalEvent() {\n this.pusher.connection.bind('message', pusherEvent => {\n var eventName = pusherEvent.event;\n if (eventName === 'pusher_internal:watchlist_events') {\n this.handleEvent(pusherEvent);\n }\n });\n }\n}\n","function flatPromise() {\n let resolve, reject;\n const promise = new Promise((res, rej) => {\n resolve = res;\n reject = rej;\n });\n return { promise, resolve, reject };\n}\n\nexport default flatPromise;\n","import Pusher from './pusher';\nimport Logger from './logger';\nimport {\n UserAuthenticationData,\n UserAuthenticationCallback\n} from './auth/options';\nimport Channel from './channels/channel';\nimport WatchlistFacade from './watchlist';\nimport EventsDispatcher from './events/dispatcher';\nimport flatPromise from './utils/flat_promise';\n\nexport default class UserFacade extends EventsDispatcher {\n pusher: Pusher;\n signin_requested: boolean = false;\n user_data: any = null;\n serverToUserChannel: Channel = null;\n signinDonePromise: Promise = null;\n watchlist: WatchlistFacade;\n private _signinDoneResolve: Function = null;\n\n public constructor(pusher: Pusher) {\n super(function(eventName, data) {\n Logger.debug('No callbacks on user for ' + eventName);\n });\n this.pusher = pusher;\n this.pusher.connection.bind('state_change', ({ previous, current }) => {\n if (previous !== 'connected' && current === 'connected') {\n this._signin();\n }\n if (previous === 'connected' && current !== 'connected') {\n this._cleanup();\n this._newSigninPromiseIfNeeded();\n }\n });\n\n this.watchlist = new WatchlistFacade(pusher);\n\n this.pusher.connection.bind('message', event => {\n var eventName = event.event;\n if (eventName === 'pusher:signin_success') {\n this._onSigninSuccess(event.data);\n }\n if (\n this.serverToUserChannel &&\n this.serverToUserChannel.name === event.channel\n ) {\n this.serverToUserChannel.handleEvent(event);\n }\n });\n }\n\n public signin() {\n if (this.signin_requested) {\n return;\n }\n\n this.signin_requested = true;\n this._signin();\n }\n\n private _signin() {\n if (!this.signin_requested) {\n return;\n }\n\n this._newSigninPromiseIfNeeded();\n\n if (this.pusher.connection.state !== 'connected') {\n // Signin will be attempted when the connection is connected\n return;\n }\n\n this.pusher.config.userAuthenticator(\n {\n socketId: this.pusher.connection.socket_id\n },\n this._onAuthorize\n );\n }\n\n private _onAuthorize: UserAuthenticationCallback = (\n err,\n authData: UserAuthenticationData\n ) => {\n if (err) {\n Logger.warn(`Error during signin: ${err}`);\n this._cleanup();\n return;\n }\n\n this.pusher.send_event('pusher:signin', {\n auth: authData.auth,\n user_data: authData.user_data\n });\n\n // Later when we get pusher:singin_success event, the user will be marked as signed in\n };\n\n private _onSigninSuccess(data: any) {\n try {\n this.user_data = JSON.parse(data.user_data);\n } catch (e) {\n Logger.error(`Failed parsing user data after signin: ${data.user_data}`);\n this._cleanup();\n return;\n }\n\n if (typeof this.user_data.id !== 'string' || this.user_data.id === '') {\n Logger.error(\n `user_data doesn't contain an id. user_data: ${this.user_data}`\n );\n this._cleanup();\n return;\n }\n\n // Signin succeeded\n this._signinDoneResolve();\n this._subscribeChannels();\n }\n\n private _subscribeChannels() {\n const ensure_subscribed = channel => {\n if (channel.subscriptionPending && channel.subscriptionCancelled) {\n channel.reinstateSubscription();\n } else if (\n !channel.subscriptionPending &&\n this.pusher.connection.state === 'connected'\n ) {\n channel.subscribe();\n }\n };\n\n this.serverToUserChannel = new Channel(\n `#server-to-user-${this.user_data.id}`,\n this.pusher\n );\n this.serverToUserChannel.bind_global((eventName, data) => {\n if (\n eventName.indexOf('pusher_internal:') === 0 ||\n eventName.indexOf('pusher:') === 0\n ) {\n // ignore internal events\n return;\n }\n this.emit(eventName, data);\n });\n ensure_subscribed(this.serverToUserChannel);\n }\n\n private _cleanup() {\n this.user_data = null;\n if (this.serverToUserChannel) {\n this.serverToUserChannel.unbind_all();\n this.serverToUserChannel.disconnect();\n this.serverToUserChannel = null;\n }\n\n if (this.signin_requested) {\n // If signin is in progress and cleanup is called,\n // Mark the current signin process as done.\n this._signinDoneResolve();\n }\n }\n\n private _newSigninPromiseIfNeeded() {\n if (!this.signin_requested) {\n return;\n }\n\n // If there is a promise and it is not resolved, return without creating a new one.\n if (this.signinDonePromise && !(this.signinDonePromise as any).done) {\n return;\n }\n\n // This promise is never rejected.\n // It gets resolved when the signin process is done whether it failed or succeeded\n const { promise, resolve, reject: _ } = flatPromise();\n (promise as any).done = false;\n const setDone = () => {\n (promise as any).done = true;\n };\n promise.then(setDone).catch(setDone);\n this.signinDonePromise = promise;\n this._signinDoneResolve = resolve;\n }\n}\n","import AbstractRuntime from '../runtimes/interface';\nimport Runtime from 'runtime';\nimport * as Collections from './utils/collections';\nimport Channels from './channels/channels';\nimport Channel from './channels/channel';\nimport { default as EventsDispatcher } from './events/dispatcher';\nimport Timeline from './timeline/timeline';\nimport TimelineSender from './timeline/timeline_sender';\nimport TimelineLevel from './timeline/level';\nimport { defineTransport } from './strategies/strategy_builder';\nimport ConnectionManager from './connection/connection_manager';\nimport { PeriodicTimer } from './utils/timers';\nimport Defaults from './defaults';\nimport Logger from './logger';\nimport Factory from './utils/factory';\nimport { Options, ClusterOptions, validateOptions } from './options';\nimport { Config, getConfig } from './config';\nimport StrategyOptions from './strategies/strategy_options';\nimport UserFacade from './user';\n\nexport default class Pusher {\n /* STATIC PROPERTIES */\n static instances: Pusher[] = [];\n static isReady: boolean = false;\n static logToConsole: boolean = false;\n\n // for jsonp\n static Runtime: AbstractRuntime = Runtime;\n static ScriptReceivers: any = (Runtime).ScriptReceivers;\n static DependenciesReceivers: any = (Runtime).DependenciesReceivers;\n static auth_callbacks: any = (Runtime).auth_callbacks;\n\n static ready() {\n Pusher.isReady = true;\n for (var i = 0, l = Pusher.instances.length; i < l; i++) {\n Pusher.instances[i].connect();\n }\n }\n\n static log: (message: any) => void;\n\n private static getClientFeatures(): string[] {\n return Collections.keys(\n Collections.filterObject({ ws: Runtime.Transports.ws }, function(t) {\n return t.isSupported({});\n })\n );\n }\n\n /* INSTANCE PROPERTIES */\n key: string;\n options: Options;\n config: Config;\n channels: Channels;\n global_emitter: EventsDispatcher;\n sessionID: number;\n timeline: Timeline;\n timelineSender: TimelineSender;\n connection: ConnectionManager;\n timelineSenderTimer: PeriodicTimer;\n user: UserFacade;\n constructor(app_key: string, options: Options) {\n checkAppKey(app_key);\n validateOptions(options);\n this.key = app_key;\n this.config = getConfig(options, this);\n\n this.channels = Factory.createChannels();\n this.global_emitter = new EventsDispatcher();\n this.sessionID = Runtime.randomInt(1000000000);\n\n this.timeline = new Timeline(this.key, this.sessionID, {\n cluster: this.config.cluster,\n features: Pusher.getClientFeatures(),\n params: this.config.timelineParams || {},\n limit: 50,\n level: TimelineLevel.INFO,\n version: Defaults.VERSION\n });\n if (this.config.enableStats) {\n this.timelineSender = Factory.createTimelineSender(this.timeline, {\n host: this.config.statsHost,\n path: '/timeline/v2/' + Runtime.TimelineTransport.name\n });\n }\n\n var getStrategy = (options: StrategyOptions) => {\n return Runtime.getDefaultStrategy(this.config, options, defineTransport);\n };\n\n this.connection = Factory.createConnectionManager(this.key, {\n getStrategy: getStrategy,\n timeline: this.timeline,\n activityTimeout: this.config.activityTimeout,\n pongTimeout: this.config.pongTimeout,\n unavailableTimeout: this.config.unavailableTimeout,\n useTLS: Boolean(this.config.useTLS)\n });\n\n this.connection.bind('connected', () => {\n this.subscribeAll();\n if (this.timelineSender) {\n this.timelineSender.send(this.connection.isUsingTLS());\n }\n });\n\n this.connection.bind('message', event => {\n var eventName = event.event;\n var internal = eventName.indexOf('pusher_internal:') === 0;\n if (event.channel) {\n var channel = this.channel(event.channel);\n if (channel) {\n channel.handleEvent(event);\n }\n }\n // Emit globally [deprecated]\n if (!internal) {\n this.global_emitter.emit(event.event, event.data);\n }\n });\n this.connection.bind('connecting', () => {\n this.channels.disconnect();\n });\n this.connection.bind('disconnected', () => {\n this.channels.disconnect();\n });\n this.connection.bind('error', err => {\n Logger.warn(err);\n });\n\n Pusher.instances.push(this);\n this.timeline.info({ instances: Pusher.instances.length });\n\n this.user = new UserFacade(this);\n\n if (Pusher.isReady) {\n this.connect();\n }\n }\n\n /**\n * Allows you to switch Pusher cluster without\n * losing all the channels/subscription binding\n * as this is internally managed by the SDK.\n */\n switchCluster(options: ClusterOptions) {\n const { appKey, cluster } = options;\n this.key = appKey;\n this.options = { ...this.options, cluster };\n this.config = getConfig(this.options, this);\n this.connection.switchCluster(this.key);\n }\n\n channel(name: string): Channel {\n return this.channels.find(name);\n }\n\n allChannels(): Channel[] {\n return this.channels.all();\n }\n\n connect() {\n this.connection.connect();\n\n if (this.timelineSender) {\n if (!this.timelineSenderTimer) {\n var usingTLS = this.connection.isUsingTLS();\n var timelineSender = this.timelineSender;\n this.timelineSenderTimer = new PeriodicTimer(60000, function() {\n timelineSender.send(usingTLS);\n });\n }\n }\n }\n\n disconnect() {\n this.connection.disconnect();\n\n if (this.timelineSenderTimer) {\n this.timelineSenderTimer.ensureAborted();\n this.timelineSenderTimer = null;\n }\n }\n\n bind(event_name: string, callback: Function, context?: any): Pusher {\n this.global_emitter.bind(event_name, callback, context);\n return this;\n }\n\n unbind(event_name?: string, callback?: Function, context?: any): Pusher {\n this.global_emitter.unbind(event_name, callback, context);\n return this;\n }\n\n bind_global(callback: Function): Pusher {\n this.global_emitter.bind_global(callback);\n return this;\n }\n\n unbind_global(callback?: Function): Pusher {\n this.global_emitter.unbind_global(callback);\n return this;\n }\n\n unbind_all(callback?: Function): Pusher {\n this.global_emitter.unbind_all();\n return this;\n }\n\n subscribeAll() {\n var channelName;\n for (channelName in this.channels.channels) {\n if (this.channels.channels.hasOwnProperty(channelName)) {\n this.subscribe(channelName);\n }\n }\n }\n\n subscribe(channel_name: string) {\n var channel = this.channels.add(channel_name, this);\n if (channel.subscriptionPending && channel.subscriptionCancelled) {\n channel.reinstateSubscription();\n } else if (\n !channel.subscriptionPending &&\n this.connection.state === 'connected'\n ) {\n channel.subscribe();\n }\n return channel;\n }\n\n unsubscribe(channel_name: string) {\n var channel = this.channels.find(channel_name);\n if (channel && channel.subscriptionPending) {\n channel.cancelSubscription();\n } else {\n channel = this.channels.remove(channel_name);\n if (channel && channel.subscribed) {\n channel.unsubscribe();\n }\n }\n }\n\n send_event(event_name: string, data: any, channel?: string) {\n return this.connection.send_event(event_name, data, channel);\n }\n\n shouldUseTLS(): boolean {\n return this.config.useTLS;\n }\n\n signin() {\n this.user.signin();\n }\n}\n\nfunction checkAppKey(key) {\n if (key === null || key === undefined) {\n throw 'You must pass your app key when you instantiate Pusher.';\n }\n}\n\nRuntime.setup(Pusher);\n","import Pusher from './pusher';\nimport { Options, validateOptions } from './options';\nimport * as nacl from 'tweetnacl';\n\nexport default class PusherWithEncryption extends Pusher {\n constructor(app_key: string, options: Options) {\n Pusher.logToConsole = PusherWithEncryption.logToConsole;\n Pusher.log = PusherWithEncryption.log;\n\n validateOptions(options);\n options.nacl = nacl;\n super(app_key, options);\n }\n}\n"],"sourceRoot":""} \ No newline at end of file diff --git a/dist/worker/pusher-with-encryption.worker.min.js b/dist/worker/pusher-with-encryption.worker.min.js index 2392e35e1..f83b992a3 100644 --- a/dist/worker/pusher-with-encryption.worker.min.js +++ b/dist/worker/pusher-with-encryption.worker.min.js @@ -1,9 +1,9 @@ /*! - * Pusher JavaScript Library v8.3.0 + * Pusher JavaScript Library v8.4.0 * https://pusher.com/ * * Copyright 2020, Pusher * Released under the MIT licence. */ -!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.Pusher=e():t.Pusher=e()}(this,(function(){return function(t){var e={};function n(r){if(e[r])return e[r].exports;var i=e[r]={i:r,l:!1,exports:{}};return t[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)n.d(r,i,function(e){return t[e]}.bind(null,i));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=3)}([function(t,e,n){"use strict";var r,i=this&&this.__extends||(r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)},function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)});Object.defineProperty(e,"__esModule",{value:!0});var s=function(){function t(t){void 0===t&&(t="="),this._paddingCharacter=t}return t.prototype.encodedLength=function(t){return this._paddingCharacter?(t+2)/3*4|0:(8*t+5)/6|0},t.prototype.encode=function(t){for(var e="",n=0;n>>18&63),e+=this._encodeByte(r>>>12&63),e+=this._encodeByte(r>>>6&63),e+=this._encodeByte(r>>>0&63)}var i=t.length-n;if(i>0){r=t[n]<<16|(2===i?t[n+1]<<8:0);e+=this._encodeByte(r>>>18&63),e+=this._encodeByte(r>>>12&63),e+=2===i?this._encodeByte(r>>>6&63):this._paddingCharacter||"",e+=this._paddingCharacter||""}return e},t.prototype.maxDecodedLength=function(t){return this._paddingCharacter?t/4*3|0:(6*t+7)/8|0},t.prototype.decodedLength=function(t){return this.maxDecodedLength(t.length-this._getPaddingLength(t))},t.prototype.decode=function(t){if(0===t.length)return new Uint8Array(0);for(var e=this._getPaddingLength(t),n=t.length-e,r=new Uint8Array(this.maxDecodedLength(n)),i=0,s=0,o=0,a=0,h=0,c=0,u=0;s>>4,r[i++]=h<<4|c>>>2,r[i++]=c<<6|u,o|=256&a,o|=256&h,o|=256&c,o|=256&u;if(s>>4,o|=256&a,o|=256&h),s>>2,o|=256&c),s>>8&6,e+=51-t>>>8&-75,e+=61-t>>>8&-15,e+=62-t>>>8&3,String.fromCharCode(e)},t.prototype._decodeChar=function(t){var e=256;return e+=(42-t&t-44)>>>8&-256+t-43+62,e+=(46-t&t-48)>>>8&-256+t-47+63,e+=(47-t&t-58)>>>8&-256+t-48+52,e+=(64-t&t-91)>>>8&-256+t-65+0,e+=(96-t&t-123)>>>8&-256+t-97+26},t.prototype._getPaddingLength=function(t){var e=0;if(this._paddingCharacter){for(var n=t.length-1;n>=0&&t[n]===this._paddingCharacter;n--)e++;if(t.length<4||e>2)throw new Error("Base64Coder: incorrect padding")}return e},t}();e.Coder=s;var o=new s;e.encode=function(t){return o.encode(t)},e.decode=function(t){return o.decode(t)};var a=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return i(e,t),e.prototype._encodeByte=function(t){var e=t;return e+=65,e+=25-t>>>8&6,e+=51-t>>>8&-75,e+=61-t>>>8&-13,e+=62-t>>>8&49,String.fromCharCode(e)},e.prototype._decodeChar=function(t){var e=256;return e+=(44-t&t-46)>>>8&-256+t-45+62,e+=(94-t&t-96)>>>8&-256+t-95+63,e+=(47-t&t-58)>>>8&-256+t-48+52,e+=(64-t&t-91)>>>8&-256+t-65+0,e+=(96-t&t-123)>>>8&-256+t-97+26},e}(s);e.URLSafeCoder=a;var h=new a;e.encodeURLSafe=function(t){return h.encode(t)},e.decodeURLSafe=function(t){return h.decode(t)},e.encodedLength=function(t){return o.encodedLength(t)},e.maxDecodedLength=function(t){return o.maxDecodedLength(t)},e.decodedLength=function(t){return o.decodedLength(t)}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r="utf8: invalid source encoding";function i(t){for(var e=0,n=0;n=t.length-1)throw new Error("utf8: invalid string");n++,e+=4}}return e}e.encode=function(t){for(var e=new Uint8Array(i(t)),n=0,r=0;r>6,e[n++]=128|63&s):s<55296?(e[n++]=224|s>>12,e[n++]=128|s>>6&63,e[n++]=128|63&s):(r++,s=(1023&s)<<10,s|=1023&t.charCodeAt(r),s+=65536,e[n++]=240|s>>18,e[n++]=128|s>>12&63,e[n++]=128|s>>6&63,e[n++]=128|63&s)}return e},e.encodedLength=i,e.decode=function(t){for(var e=[],n=0;n=t.length)throw new Error(r);if(128!=(192&(o=t[++n])))throw new Error(r);i=(31&i)<<6|63&o,s=128}else if(i<240){if(n>=t.length-1)throw new Error(r);var o=t[++n],a=t[++n];if(128!=(192&o)||128!=(192&a))throw new Error(r);i=(15&i)<<12|(63&o)<<6|63&a,s=2048}else{if(!(i<248))throw new Error(r);if(n>=t.length-2)throw new Error(r);o=t[++n],a=t[++n];var h=t[++n];if(128!=(192&o)||128!=(192&a)||128!=(192&h))throw new Error(r);i=(15&i)<<18|(63&o)<<12|(63&a)<<6|63&h,s=65536}if(i=55296&&i<=57343)throw new Error(r);if(i>=65536){if(i>1114111)throw new Error(r);i-=65536,e.push(String.fromCharCode(55296|i>>10)),i=56320|1023&i}}e.push(String.fromCharCode(i))}return e.join("")}},function(t,e,n){!function(t){"use strict";var e=function(t){var e,n=new Float64Array(16);if(t)for(e=0;e>24&255,t[e+1]=n>>16&255,t[e+2]=n>>8&255,t[e+3]=255&n,t[e+4]=r>>24&255,t[e+5]=r>>16&255,t[e+6]=r>>8&255,t[e+7]=255&r}function g(t,e,n,r,i){var s,o=0;for(s=0;s>>8)-1}function b(t,e,n,r){return g(t,e,n,r,16)}function v(t,e,n,r){return g(t,e,n,r,32)}function y(t,e,n,r){!function(t,e,n,r){for(var i,s=255&r[0]|(255&r[1])<<8|(255&r[2])<<16|(255&r[3])<<24,o=255&n[0]|(255&n[1])<<8|(255&n[2])<<16|(255&n[3])<<24,a=255&n[4]|(255&n[5])<<8|(255&n[6])<<16|(255&n[7])<<24,h=255&n[8]|(255&n[9])<<8|(255&n[10])<<16|(255&n[11])<<24,c=255&n[12]|(255&n[13])<<8|(255&n[14])<<16|(255&n[15])<<24,u=255&r[4]|(255&r[5])<<8|(255&r[6])<<16|(255&r[7])<<24,l=255&e[0]|(255&e[1])<<8|(255&e[2])<<16|(255&e[3])<<24,d=255&e[4]|(255&e[5])<<8|(255&e[6])<<16|(255&e[7])<<24,p=255&e[8]|(255&e[9])<<8|(255&e[10])<<16|(255&e[11])<<24,f=255&e[12]|(255&e[13])<<8|(255&e[14])<<16|(255&e[15])<<24,g=255&r[8]|(255&r[9])<<8|(255&r[10])<<16|(255&r[11])<<24,b=255&n[16]|(255&n[17])<<8|(255&n[18])<<16|(255&n[19])<<24,v=255&n[20]|(255&n[21])<<8|(255&n[22])<<16|(255&n[23])<<24,y=255&n[24]|(255&n[25])<<8|(255&n[26])<<16|(255&n[27])<<24,m=255&n[28]|(255&n[29])<<8|(255&n[30])<<16|(255&n[31])<<24,w=255&r[12]|(255&r[13])<<8|(255&r[14])<<16|(255&r[15])<<24,_=s,S=o,k=a,C=h,T=c,P=u,A=l,E=d,x=p,O=f,L=g,U=b,R=v,M=y,I=m,N=w,D=0;D<20;D+=2)_^=(i=(R^=(i=(x^=(i=(T^=(i=_+R|0)<<7|i>>>25)+_|0)<<9|i>>>23)+T|0)<<13|i>>>19)+x|0)<<18|i>>>14,P^=(i=(S^=(i=(M^=(i=(O^=(i=P+S|0)<<7|i>>>25)+P|0)<<9|i>>>23)+O|0)<<13|i>>>19)+M|0)<<18|i>>>14,L^=(i=(A^=(i=(k^=(i=(I^=(i=L+A|0)<<7|i>>>25)+L|0)<<9|i>>>23)+I|0)<<13|i>>>19)+k|0)<<18|i>>>14,N^=(i=(U^=(i=(E^=(i=(C^=(i=N+U|0)<<7|i>>>25)+N|0)<<9|i>>>23)+C|0)<<13|i>>>19)+E|0)<<18|i>>>14,_^=(i=(C^=(i=(k^=(i=(S^=(i=_+C|0)<<7|i>>>25)+_|0)<<9|i>>>23)+S|0)<<13|i>>>19)+k|0)<<18|i>>>14,P^=(i=(T^=(i=(E^=(i=(A^=(i=P+T|0)<<7|i>>>25)+P|0)<<9|i>>>23)+A|0)<<13|i>>>19)+E|0)<<18|i>>>14,L^=(i=(O^=(i=(x^=(i=(U^=(i=L+O|0)<<7|i>>>25)+L|0)<<9|i>>>23)+U|0)<<13|i>>>19)+x|0)<<18|i>>>14,N^=(i=(I^=(i=(M^=(i=(R^=(i=N+I|0)<<7|i>>>25)+N|0)<<9|i>>>23)+R|0)<<13|i>>>19)+M|0)<<18|i>>>14;_=_+s|0,S=S+o|0,k=k+a|0,C=C+h|0,T=T+c|0,P=P+u|0,A=A+l|0,E=E+d|0,x=x+p|0,O=O+f|0,L=L+g|0,U=U+b|0,R=R+v|0,M=M+y|0,I=I+m|0,N=N+w|0,t[0]=_>>>0&255,t[1]=_>>>8&255,t[2]=_>>>16&255,t[3]=_>>>24&255,t[4]=S>>>0&255,t[5]=S>>>8&255,t[6]=S>>>16&255,t[7]=S>>>24&255,t[8]=k>>>0&255,t[9]=k>>>8&255,t[10]=k>>>16&255,t[11]=k>>>24&255,t[12]=C>>>0&255,t[13]=C>>>8&255,t[14]=C>>>16&255,t[15]=C>>>24&255,t[16]=T>>>0&255,t[17]=T>>>8&255,t[18]=T>>>16&255,t[19]=T>>>24&255,t[20]=P>>>0&255,t[21]=P>>>8&255,t[22]=P>>>16&255,t[23]=P>>>24&255,t[24]=A>>>0&255,t[25]=A>>>8&255,t[26]=A>>>16&255,t[27]=A>>>24&255,t[28]=E>>>0&255,t[29]=E>>>8&255,t[30]=E>>>16&255,t[31]=E>>>24&255,t[32]=x>>>0&255,t[33]=x>>>8&255,t[34]=x>>>16&255,t[35]=x>>>24&255,t[36]=O>>>0&255,t[37]=O>>>8&255,t[38]=O>>>16&255,t[39]=O>>>24&255,t[40]=L>>>0&255,t[41]=L>>>8&255,t[42]=L>>>16&255,t[43]=L>>>24&255,t[44]=U>>>0&255,t[45]=U>>>8&255,t[46]=U>>>16&255,t[47]=U>>>24&255,t[48]=R>>>0&255,t[49]=R>>>8&255,t[50]=R>>>16&255,t[51]=R>>>24&255,t[52]=M>>>0&255,t[53]=M>>>8&255,t[54]=M>>>16&255,t[55]=M>>>24&255,t[56]=I>>>0&255,t[57]=I>>>8&255,t[58]=I>>>16&255,t[59]=I>>>24&255,t[60]=N>>>0&255,t[61]=N>>>8&255,t[62]=N>>>16&255,t[63]=N>>>24&255}(t,e,n,r)}function m(t,e,n,r){!function(t,e,n,r){for(var i,s=255&r[0]|(255&r[1])<<8|(255&r[2])<<16|(255&r[3])<<24,o=255&n[0]|(255&n[1])<<8|(255&n[2])<<16|(255&n[3])<<24,a=255&n[4]|(255&n[5])<<8|(255&n[6])<<16|(255&n[7])<<24,h=255&n[8]|(255&n[9])<<8|(255&n[10])<<16|(255&n[11])<<24,c=255&n[12]|(255&n[13])<<8|(255&n[14])<<16|(255&n[15])<<24,u=255&r[4]|(255&r[5])<<8|(255&r[6])<<16|(255&r[7])<<24,l=255&e[0]|(255&e[1])<<8|(255&e[2])<<16|(255&e[3])<<24,d=255&e[4]|(255&e[5])<<8|(255&e[6])<<16|(255&e[7])<<24,p=255&e[8]|(255&e[9])<<8|(255&e[10])<<16|(255&e[11])<<24,f=255&e[12]|(255&e[13])<<8|(255&e[14])<<16|(255&e[15])<<24,g=255&r[8]|(255&r[9])<<8|(255&r[10])<<16|(255&r[11])<<24,b=255&n[16]|(255&n[17])<<8|(255&n[18])<<16|(255&n[19])<<24,v=255&n[20]|(255&n[21])<<8|(255&n[22])<<16|(255&n[23])<<24,y=255&n[24]|(255&n[25])<<8|(255&n[26])<<16|(255&n[27])<<24,m=255&n[28]|(255&n[29])<<8|(255&n[30])<<16|(255&n[31])<<24,w=255&r[12]|(255&r[13])<<8|(255&r[14])<<16|(255&r[15])<<24,_=0;_<20;_+=2)s^=(i=(v^=(i=(p^=(i=(c^=(i=s+v|0)<<7|i>>>25)+s|0)<<9|i>>>23)+c|0)<<13|i>>>19)+p|0)<<18|i>>>14,u^=(i=(o^=(i=(y^=(i=(f^=(i=u+o|0)<<7|i>>>25)+u|0)<<9|i>>>23)+f|0)<<13|i>>>19)+y|0)<<18|i>>>14,g^=(i=(l^=(i=(a^=(i=(m^=(i=g+l|0)<<7|i>>>25)+g|0)<<9|i>>>23)+m|0)<<13|i>>>19)+a|0)<<18|i>>>14,w^=(i=(b^=(i=(d^=(i=(h^=(i=w+b|0)<<7|i>>>25)+w|0)<<9|i>>>23)+h|0)<<13|i>>>19)+d|0)<<18|i>>>14,s^=(i=(h^=(i=(a^=(i=(o^=(i=s+h|0)<<7|i>>>25)+s|0)<<9|i>>>23)+o|0)<<13|i>>>19)+a|0)<<18|i>>>14,u^=(i=(c^=(i=(d^=(i=(l^=(i=u+c|0)<<7|i>>>25)+u|0)<<9|i>>>23)+l|0)<<13|i>>>19)+d|0)<<18|i>>>14,g^=(i=(f^=(i=(p^=(i=(b^=(i=g+f|0)<<7|i>>>25)+g|0)<<9|i>>>23)+b|0)<<13|i>>>19)+p|0)<<18|i>>>14,w^=(i=(m^=(i=(y^=(i=(v^=(i=w+m|0)<<7|i>>>25)+w|0)<<9|i>>>23)+v|0)<<13|i>>>19)+y|0)<<18|i>>>14;t[0]=s>>>0&255,t[1]=s>>>8&255,t[2]=s>>>16&255,t[3]=s>>>24&255,t[4]=u>>>0&255,t[5]=u>>>8&255,t[6]=u>>>16&255,t[7]=u>>>24&255,t[8]=g>>>0&255,t[9]=g>>>8&255,t[10]=g>>>16&255,t[11]=g>>>24&255,t[12]=w>>>0&255,t[13]=w>>>8&255,t[14]=w>>>16&255,t[15]=w>>>24&255,t[16]=l>>>0&255,t[17]=l>>>8&255,t[18]=l>>>16&255,t[19]=l>>>24&255,t[20]=d>>>0&255,t[21]=d>>>8&255,t[22]=d>>>16&255,t[23]=d>>>24&255,t[24]=p>>>0&255,t[25]=p>>>8&255,t[26]=p>>>16&255,t[27]=p>>>24&255,t[28]=f>>>0&255,t[29]=f>>>8&255,t[30]=f>>>16&255,t[31]=f>>>24&255}(t,e,n,r)}var w=new Uint8Array([101,120,112,97,110,100,32,51,50,45,98,121,116,101,32,107]);function _(t,e,n,r,i,s,o){var a,h,c=new Uint8Array(16),u=new Uint8Array(64);for(h=0;h<16;h++)c[h]=0;for(h=0;h<8;h++)c[h]=s[h];for(;i>=64;){for(y(u,c,o,w),h=0;h<64;h++)t[e+h]=n[r+h]^u[h];for(a=1,h=8;h<16;h++)a=a+(255&c[h])|0,c[h]=255&a,a>>>=8;i-=64,e+=64,r+=64}if(i>0)for(y(u,c,o,w),h=0;h=64;){for(y(h,a,i,w),o=0;o<64;o++)t[e+o]=h[o];for(s=1,o=8;o<16;o++)s=s+(255&a[o])|0,a[o]=255&s,s>>>=8;n-=64,e+=64}if(n>0)for(y(h,a,i,w),o=0;o>>13|n<<3),r=255&t[4]|(255&t[5])<<8,this.r[2]=7939&(n>>>10|r<<6),i=255&t[6]|(255&t[7])<<8,this.r[3]=8191&(r>>>7|i<<9),s=255&t[8]|(255&t[9])<<8,this.r[4]=255&(i>>>4|s<<12),this.r[5]=s>>>1&8190,o=255&t[10]|(255&t[11])<<8,this.r[6]=8191&(s>>>14|o<<2),a=255&t[12]|(255&t[13])<<8,this.r[7]=8065&(o>>>11|a<<5),h=255&t[14]|(255&t[15])<<8,this.r[8]=8191&(a>>>8|h<<8),this.r[9]=h>>>5&127,this.pad[0]=255&t[16]|(255&t[17])<<8,this.pad[1]=255&t[18]|(255&t[19])<<8,this.pad[2]=255&t[20]|(255&t[21])<<8,this.pad[3]=255&t[22]|(255&t[23])<<8,this.pad[4]=255&t[24]|(255&t[25])<<8,this.pad[5]=255&t[26]|(255&t[27])<<8,this.pad[6]=255&t[28]|(255&t[29])<<8,this.pad[7]=255&t[30]|(255&t[31])<<8};function P(t,e,n,r,i,s){var o=new T(s);return o.update(n,r,i),o.finish(t,e),0}function A(t,e,n,r,i,s){var o=new Uint8Array(16);return P(o,0,n,r,i,s),b(t,e,o,0)}function E(t,e,n,r,i){var s;if(n<32)return-1;for(C(t,0,e,0,n,r,i),P(t,16,t,32,n-32,t),s=0;s<16;s++)t[s]=0;return 0}function x(t,e,n,r,i){var s,o=new Uint8Array(32);if(n<32)return-1;if(k(o,0,32,r,i),0!==A(e,16,e,32,n-32,o))return-1;for(C(t,0,e,0,n,r,i),s=0;s<32;s++)t[s]=0;return 0}function O(t,e){var n;for(n=0;n<16;n++)t[n]=0|e[n]}function L(t){var e,n,r=1;for(e=0;e<16;e++)n=t[e]+r+65535,r=Math.floor(n/65536),t[e]=n-65536*r;t[0]+=r-1+37*(r-1)}function U(t,e,n){for(var r,i=~(n-1),s=0;s<16;s++)r=i&(t[s]^e[s]),t[s]^=r,e[s]^=r}function R(t,n){var r,i,s,o=e(),a=e();for(r=0;r<16;r++)a[r]=n[r];for(L(a),L(a),L(a),i=0;i<2;i++){for(o[0]=a[0]-65517,r=1;r<15;r++)o[r]=a[r]-65535-(o[r-1]>>16&1),o[r-1]&=65535;o[15]=a[15]-32767-(o[14]>>16&1),s=o[15]>>16&1,o[14]&=65535,U(a,o,1-s)}for(r=0;r<16;r++)t[2*r]=255&a[r],t[2*r+1]=a[r]>>8}function M(t,e){var n=new Uint8Array(32),r=new Uint8Array(32);return R(n,t),R(r,e),v(n,0,r,0)}function I(t){var e=new Uint8Array(32);return R(e,t),1&e[0]}function N(t,e){var n;for(n=0;n<16;n++)t[n]=e[2*n]+(e[2*n+1]<<8);t[15]&=32767}function D(t,e,n){for(var r=0;r<16;r++)t[r]=e[r]+n[r]}function j(t,e,n){for(var r=0;r<16;r++)t[r]=e[r]-n[r]}function z(t,e,n){var r,i,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38*(C+=r*H),c+=38*(T+=r*B),u+=38*(P+=r*F),l+=38*(A+=r*q),d+=38*(E+=r*Y),p+=38*(x+=r*K),f+=38*(O+=r*$),g+=38*(L+=r*J),b+=38*(U+=r*W),v+=38*(R+=r*X),y+=38*(M+=r*G),m+=38*(I+=r*V),s=(r=(s+=38*(_+=r*D))+(i=1)+65535)-65536*(i=Math.floor(r/65536)),o=(r=o+i+65535)-65536*(i=Math.floor(r/65536)),a=(r=a+i+65535)-65536*(i=Math.floor(r/65536)),h=(r=h+i+65535)-65536*(i=Math.floor(r/65536)),c=(r=c+i+65535)-65536*(i=Math.floor(r/65536)),u=(r=u+i+65535)-65536*(i=Math.floor(r/65536)),l=(r=l+i+65535)-65536*(i=Math.floor(r/65536)),d=(r=d+i+65535)-65536*(i=Math.floor(r/65536)),p=(r=p+i+65535)-65536*(i=Math.floor(r/65536)),f=(r=f+i+65535)-65536*(i=Math.floor(r/65536)),g=(r=g+i+65535)-65536*(i=Math.floor(r/65536)),b=(r=b+i+65535)-65536*(i=Math.floor(r/65536)),v=(r=v+i+65535)-65536*(i=Math.floor(r/65536)),y=(r=y+i+65535)-65536*(i=Math.floor(r/65536)),m=(r=m+i+65535)-65536*(i=Math.floor(r/65536)),w=(r=w+i+65535)-65536*(i=Math.floor(r/65536)),s=(r=(s+=i-1+37*(i-1))+(i=1)+65535)-65536*(i=Math.floor(r/65536)),o=(r=o+i+65535)-65536*(i=Math.floor(r/65536)),a=(r=a+i+65535)-65536*(i=Math.floor(r/65536)),h=(r=h+i+65535)-65536*(i=Math.floor(r/65536)),c=(r=c+i+65535)-65536*(i=Math.floor(r/65536)),u=(r=u+i+65535)-65536*(i=Math.floor(r/65536)),l=(r=l+i+65535)-65536*(i=Math.floor(r/65536)),d=(r=d+i+65535)-65536*(i=Math.floor(r/65536)),p=(r=p+i+65535)-65536*(i=Math.floor(r/65536)),f=(r=f+i+65535)-65536*(i=Math.floor(r/65536)),g=(r=g+i+65535)-65536*(i=Math.floor(r/65536)),b=(r=b+i+65535)-65536*(i=Math.floor(r/65536)),v=(r=v+i+65535)-65536*(i=Math.floor(r/65536)),y=(r=y+i+65535)-65536*(i=Math.floor(r/65536)),m=(r=m+i+65535)-65536*(i=Math.floor(r/65536)),w=(r=w+i+65535)-65536*(i=Math.floor(r/65536)),s+=i-1+37*(i-1),t[0]=s,t[1]=o,t[2]=a,t[3]=h,t[4]=c,t[5]=u,t[6]=l,t[7]=d,t[8]=p,t[9]=f,t[10]=g,t[11]=b,t[12]=v,t[13]=y,t[14]=m,t[15]=w}function H(t,e){z(t,e,e)}function B(t,n){var r,i=e();for(r=0;r<16;r++)i[r]=n[r];for(r=253;r>=0;r--)H(i,i),2!==r&&4!==r&&z(i,i,n);for(r=0;r<16;r++)t[r]=i[r]}function F(t,n){var r,i=e();for(r=0;r<16;r++)i[r]=n[r];for(r=250;r>=0;r--)H(i,i),1!==r&&z(i,i,n);for(r=0;r<16;r++)t[r]=i[r]}function q(t,n,r){var i,s,o=new Uint8Array(32),a=new Float64Array(80),c=e(),u=e(),l=e(),d=e(),p=e(),f=e();for(s=0;s<31;s++)o[s]=n[s];for(o[31]=127&n[31]|64,o[0]&=248,N(a,r),s=0;s<16;s++)u[s]=a[s],d[s]=c[s]=l[s]=0;for(c[0]=d[0]=1,s=254;s>=0;--s)U(c,u,i=o[s>>>3]>>>(7&s)&1),U(l,d,i),D(p,c,l),j(c,c,l),D(l,u,d),j(u,u,d),H(d,p),H(f,c),z(c,l,c),z(l,u,p),D(p,c,l),j(c,c,l),H(u,c),j(l,d,f),z(c,l,h),D(c,c,d),z(l,l,c),z(c,d,f),z(d,u,a),H(u,p),U(c,u,i),U(l,d,i);for(s=0;s<16;s++)a[s+16]=c[s],a[s+32]=l[s],a[s+48]=u[s],a[s+64]=d[s];var g=a.subarray(32),b=a.subarray(16);return B(g,g),z(b,b,g),R(t,b),0}function Y(t,e){return q(t,e,s)}function K(t,e){return r(e,32),Y(t,e)}function $(t,e,n){var r=new Uint8Array(32);return q(r,n,e),m(t,i,r,w)}T.prototype.blocks=function(t,e,n){for(var r,i,s,o,a,h,c,u,l,d,p,f,g,b,v,y,m,w,_,S=this.fin?0:2048,k=this.h[0],C=this.h[1],T=this.h[2],P=this.h[3],A=this.h[4],E=this.h[5],x=this.h[6],O=this.h[7],L=this.h[8],U=this.h[9],R=this.r[0],M=this.r[1],I=this.r[2],N=this.r[3],D=this.r[4],j=this.r[5],z=this.r[6],H=this.r[7],B=this.r[8],F=this.r[9];n>=16;)d=l=0,d+=(k+=8191&(r=255&t[e+0]|(255&t[e+1])<<8))*R,d+=(C+=8191&(r>>>13|(i=255&t[e+2]|(255&t[e+3])<<8)<<3))*(5*F),d+=(T+=8191&(i>>>10|(s=255&t[e+4]|(255&t[e+5])<<8)<<6))*(5*B),d+=(P+=8191&(s>>>7|(o=255&t[e+6]|(255&t[e+7])<<8)<<9))*(5*H),l=(d+=(A+=8191&(o>>>4|(a=255&t[e+8]|(255&t[e+9])<<8)<<12))*(5*z))>>>13,d&=8191,d+=(E+=a>>>1&8191)*(5*j),d+=(x+=8191&(a>>>14|(h=255&t[e+10]|(255&t[e+11])<<8)<<2))*(5*D),d+=(O+=8191&(h>>>11|(c=255&t[e+12]|(255&t[e+13])<<8)<<5))*(5*N),d+=(L+=8191&(c>>>8|(u=255&t[e+14]|(255&t[e+15])<<8)<<8))*(5*I),p=l+=(d+=(U+=u>>>5|S)*(5*M))>>>13,p+=k*M,p+=C*R,p+=T*(5*F),p+=P*(5*B),l=(p+=A*(5*H))>>>13,p&=8191,p+=E*(5*z),p+=x*(5*j),p+=O*(5*D),p+=L*(5*N),l+=(p+=U*(5*I))>>>13,p&=8191,f=l,f+=k*I,f+=C*M,f+=T*R,f+=P*(5*F),l=(f+=A*(5*B))>>>13,f&=8191,f+=E*(5*H),f+=x*(5*z),f+=O*(5*j),f+=L*(5*D),g=l+=(f+=U*(5*N))>>>13,g+=k*N,g+=C*I,g+=T*M,g+=P*R,l=(g+=A*(5*F))>>>13,g&=8191,g+=E*(5*B),g+=x*(5*H),g+=O*(5*z),g+=L*(5*j),b=l+=(g+=U*(5*D))>>>13,b+=k*D,b+=C*N,b+=T*I,b+=P*M,l=(b+=A*R)>>>13,b&=8191,b+=E*(5*F),b+=x*(5*B),b+=O*(5*H),b+=L*(5*z),v=l+=(b+=U*(5*j))>>>13,v+=k*j,v+=C*D,v+=T*N,v+=P*I,l=(v+=A*M)>>>13,v&=8191,v+=E*R,v+=x*(5*F),v+=O*(5*B),v+=L*(5*H),y=l+=(v+=U*(5*z))>>>13,y+=k*z,y+=C*j,y+=T*D,y+=P*N,l=(y+=A*I)>>>13,y&=8191,y+=E*M,y+=x*R,y+=O*(5*F),y+=L*(5*B),m=l+=(y+=U*(5*H))>>>13,m+=k*H,m+=C*z,m+=T*j,m+=P*D,l=(m+=A*N)>>>13,m&=8191,m+=E*I,m+=x*M,m+=O*R,m+=L*(5*F),w=l+=(m+=U*(5*B))>>>13,w+=k*B,w+=C*H,w+=T*z,w+=P*j,l=(w+=A*D)>>>13,w&=8191,w+=E*N,w+=x*I,w+=O*M,w+=L*R,_=l+=(w+=U*(5*F))>>>13,_+=k*F,_+=C*B,_+=T*H,_+=P*z,l=(_+=A*j)>>>13,_&=8191,_+=E*D,_+=x*N,_+=O*I,_+=L*M,k=d=8191&(l=(l=((l+=(_+=U*R)>>>13)<<2)+l|0)+(d&=8191)|0),C=p+=l>>>=13,T=f&=8191,P=g&=8191,A=b&=8191,E=v&=8191,x=y&=8191,O=m&=8191,L=w&=8191,U=_&=8191,e+=16,n-=16;this.h[0]=k,this.h[1]=C,this.h[2]=T,this.h[3]=P,this.h[4]=A,this.h[5]=E,this.h[6]=x,this.h[7]=O,this.h[8]=L,this.h[9]=U},T.prototype.finish=function(t,e){var n,r,i,s,o=new Uint16Array(10);if(this.leftover){for(s=this.leftover,this.buffer[s++]=1;s<16;s++)this.buffer[s]=0;this.fin=1,this.blocks(this.buffer,0,16)}for(n=this.h[1]>>>13,this.h[1]&=8191,s=2;s<10;s++)this.h[s]+=n,n=this.h[s]>>>13,this.h[s]&=8191;for(this.h[0]+=5*n,n=this.h[0]>>>13,this.h[0]&=8191,this.h[1]+=n,n=this.h[1]>>>13,this.h[1]&=8191,this.h[2]+=n,o[0]=this.h[0]+5,n=o[0]>>>13,o[0]&=8191,s=1;s<10;s++)o[s]=this.h[s]+n,n=o[s]>>>13,o[s]&=8191;for(o[9]-=8192,r=(1^n)-1,s=0;s<10;s++)o[s]&=r;for(r=~r,s=0;s<10;s++)this.h[s]=this.h[s]&r|o[s];for(this.h[0]=65535&(this.h[0]|this.h[1]<<13),this.h[1]=65535&(this.h[1]>>>3|this.h[2]<<10),this.h[2]=65535&(this.h[2]>>>6|this.h[3]<<7),this.h[3]=65535&(this.h[3]>>>9|this.h[4]<<4),this.h[4]=65535&(this.h[4]>>>12|this.h[5]<<1|this.h[6]<<14),this.h[5]=65535&(this.h[6]>>>2|this.h[7]<<11),this.h[6]=65535&(this.h[7]>>>5|this.h[8]<<8),this.h[7]=65535&(this.h[8]>>>8|this.h[9]<<5),i=this.h[0]+this.pad[0],this.h[0]=65535&i,s=1;s<8;s++)i=(this.h[s]+this.pad[s]|0)+(i>>>16)|0,this.h[s]=65535&i;t[e+0]=this.h[0]>>>0&255,t[e+1]=this.h[0]>>>8&255,t[e+2]=this.h[1]>>>0&255,t[e+3]=this.h[1]>>>8&255,t[e+4]=this.h[2]>>>0&255,t[e+5]=this.h[2]>>>8&255,t[e+6]=this.h[3]>>>0&255,t[e+7]=this.h[3]>>>8&255,t[e+8]=this.h[4]>>>0&255,t[e+9]=this.h[4]>>>8&255,t[e+10]=this.h[5]>>>0&255,t[e+11]=this.h[5]>>>8&255,t[e+12]=this.h[6]>>>0&255,t[e+13]=this.h[6]>>>8&255,t[e+14]=this.h[7]>>>0&255,t[e+15]=this.h[7]>>>8&255},T.prototype.update=function(t,e,n){var r,i;if(this.leftover){for((i=16-this.leftover)>n&&(i=n),r=0;r=16&&(i=n-n%16,this.blocks(t,e,i),e+=i,n-=i),n){for(r=0;r=128;){for(S=0;S<16;S++)k=8*S+W,O[S]=n[k+0]<<24|n[k+1]<<16|n[k+2]<<8|n[k+3],L[S]=n[k+4]<<24|n[k+5]<<16|n[k+6]<<8|n[k+7];for(S=0;S<80;S++)if(i=U,s=R,o=M,a=I,h=N,c=D,u=j,z,d=H,p=B,f=F,g=q,b=Y,v=K,y=$,J,P=65535&(T=J),A=T>>>16,E=65535&(C=z),x=C>>>16,P+=65535&(T=(Y>>>14|N<<18)^(Y>>>18|N<<14)^(N>>>9|Y<<23)),A+=T>>>16,E+=65535&(C=(N>>>14|Y<<18)^(N>>>18|Y<<14)^(Y>>>9|N<<23)),x+=C>>>16,P+=65535&(T=Y&K^~Y&$),A+=T>>>16,E+=65535&(C=N&D^~N&j),x+=C>>>16,P+=65535&(T=X[2*S+1]),A+=T>>>16,E+=65535&(C=X[2*S]),x+=C>>>16,C=O[S%16],A+=(T=L[S%16])>>>16,E+=65535&C,x+=C>>>16,E+=(A+=(P+=65535&T)>>>16)>>>16,P=65535&(T=_=65535&P|A<<16),A=T>>>16,E=65535&(C=w=65535&E|(x+=E>>>16)<<16),x=C>>>16,P+=65535&(T=(H>>>28|U<<4)^(U>>>2|H<<30)^(U>>>7|H<<25)),A+=T>>>16,E+=65535&(C=(U>>>28|H<<4)^(H>>>2|U<<30)^(H>>>7|U<<25)),x+=C>>>16,A+=(T=H&B^H&F^B&F)>>>16,E+=65535&(C=U&R^U&M^R&M),x+=C>>>16,l=65535&(E+=(A+=(P+=65535&T)>>>16)>>>16)|(x+=E>>>16)<<16,m=65535&P|A<<16,P=65535&(T=g),A=T>>>16,E=65535&(C=a),x=C>>>16,A+=(T=_)>>>16,E+=65535&(C=w),x+=C>>>16,R=i,M=s,I=o,N=a=65535&(E+=(A+=(P+=65535&T)>>>16)>>>16)|(x+=E>>>16)<<16,D=h,j=c,z=u,U=l,B=d,F=p,q=f,Y=g=65535&P|A<<16,K=b,$=v,J=y,H=m,S%16==15)for(k=0;k<16;k++)C=O[k],P=65535&(T=L[k]),A=T>>>16,E=65535&C,x=C>>>16,C=O[(k+9)%16],P+=65535&(T=L[(k+9)%16]),A+=T>>>16,E+=65535&C,x+=C>>>16,w=O[(k+1)%16],P+=65535&(T=((_=L[(k+1)%16])>>>1|w<<31)^(_>>>8|w<<24)^(_>>>7|w<<25)),A+=T>>>16,E+=65535&(C=(w>>>1|_<<31)^(w>>>8|_<<24)^w>>>7),x+=C>>>16,w=O[(k+14)%16],A+=(T=((_=L[(k+14)%16])>>>19|w<<13)^(w>>>29|_<<3)^(_>>>6|w<<26))>>>16,E+=65535&(C=(w>>>19|_<<13)^(_>>>29|w<<3)^w>>>6),x+=C>>>16,x+=(E+=(A+=(P+=65535&T)>>>16)>>>16)>>>16,O[k]=65535&E|x<<16,L[k]=65535&P|A<<16;P=65535&(T=H),A=T>>>16,E=65535&(C=U),x=C>>>16,C=t[0],A+=(T=e[0])>>>16,E+=65535&C,x+=C>>>16,x+=(E+=(A+=(P+=65535&T)>>>16)>>>16)>>>16,t[0]=U=65535&E|x<<16,e[0]=H=65535&P|A<<16,P=65535&(T=B),A=T>>>16,E=65535&(C=R),x=C>>>16,C=t[1],A+=(T=e[1])>>>16,E+=65535&C,x+=C>>>16,x+=(E+=(A+=(P+=65535&T)>>>16)>>>16)>>>16,t[1]=R=65535&E|x<<16,e[1]=B=65535&P|A<<16,P=65535&(T=F),A=T>>>16,E=65535&(C=M),x=C>>>16,C=t[2],A+=(T=e[2])>>>16,E+=65535&C,x+=C>>>16,x+=(E+=(A+=(P+=65535&T)>>>16)>>>16)>>>16,t[2]=M=65535&E|x<<16,e[2]=F=65535&P|A<<16,P=65535&(T=q),A=T>>>16,E=65535&(C=I),x=C>>>16,C=t[3],A+=(T=e[3])>>>16,E+=65535&C,x+=C>>>16,x+=(E+=(A+=(P+=65535&T)>>>16)>>>16)>>>16,t[3]=I=65535&E|x<<16,e[3]=q=65535&P|A<<16,P=65535&(T=Y),A=T>>>16,E=65535&(C=N),x=C>>>16,C=t[4],A+=(T=e[4])>>>16,E+=65535&C,x+=C>>>16,x+=(E+=(A+=(P+=65535&T)>>>16)>>>16)>>>16,t[4]=N=65535&E|x<<16,e[4]=Y=65535&P|A<<16,P=65535&(T=K),A=T>>>16,E=65535&(C=D),x=C>>>16,C=t[5],A+=(T=e[5])>>>16,E+=65535&C,x+=C>>>16,x+=(E+=(A+=(P+=65535&T)>>>16)>>>16)>>>16,t[5]=D=65535&E|x<<16,e[5]=K=65535&P|A<<16,P=65535&(T=$),A=T>>>16,E=65535&(C=j),x=C>>>16,C=t[6],A+=(T=e[6])>>>16,E+=65535&C,x+=C>>>16,x+=(E+=(A+=(P+=65535&T)>>>16)>>>16)>>>16,t[6]=j=65535&E|x<<16,e[6]=$=65535&P|A<<16,P=65535&(T=J),A=T>>>16,E=65535&(C=z),x=C>>>16,C=t[7],A+=(T=e[7])>>>16,E+=65535&C,x+=C>>>16,x+=(E+=(A+=(P+=65535&T)>>>16)>>>16)>>>16,t[7]=z=65535&E|x<<16,e[7]=J=65535&P|A<<16,W+=128,r-=128}return r}function V(t,e,n){var r,i=new Int32Array(8),s=new Int32Array(8),o=new Uint8Array(256),a=n;for(i[0]=1779033703,i[1]=3144134277,i[2]=1013904242,i[3]=2773480762,i[4]=1359893119,i[5]=2600822924,i[6]=528734635,i[7]=1541459225,s[0]=4089235720,s[1]=2227873595,s[2]=4271175723,s[3]=1595750129,s[4]=2917565137,s[5]=725511199,s[6]=4215389547,s[7]=327033209,G(i,s,e,n),n%=128,r=0;r=0;--i)Q(t,e,r=n[i/8|0]>>(7&i)&1),Z(e,t),Z(t,t),Q(t,e,r)}function nt(t,n){var r=[e(),e(),e(),e()];O(r[0],l),O(r[1],d),O(r[2],a),z(r[3],l,d),et(t,r,n)}function rt(t,n,i){var s,o=new Uint8Array(64),a=[e(),e(),e(),e()];for(i||r(n,32),V(o,n,32),o[0]&=248,o[31]&=127,o[31]|=64,nt(a,o),tt(t,a),s=0;s<32;s++)n[s+32]=t[s];return 0}var it=new Float64Array([237,211,245,92,26,99,18,88,214,156,247,162,222,249,222,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16]);function st(t,e){var n,r,i,s;for(r=63;r>=32;--r){for(n=0,i=r-32,s=r-12;i>4)*it[i],n=e[i]>>8,e[i]&=255;for(i=0;i<32;i++)e[i]-=n*it[i];for(r=0;r<32;r++)e[r+1]+=e[r]>>8,t[r]=255&e[r]}function ot(t){var e,n=new Float64Array(64);for(e=0;e<64;e++)n[e]=t[e];for(e=0;e<64;e++)t[e]=0;st(t,n)}function at(t,n,r,i){var s,o,a=new Uint8Array(64),h=new Uint8Array(64),c=new Uint8Array(64),u=new Float64Array(64),l=[e(),e(),e(),e()];V(a,i,32),a[0]&=248,a[31]&=127,a[31]|=64;var d=r+64;for(s=0;s>7&&j(t[0],o,t[0]),z(t[3],t[0],t[1]),0)}(d,i))return-1;for(s=0;s=0},t.sign.keyPair=function(){var t=new Uint8Array(32),e=new Uint8Array(64);return rt(t,e),{publicKey:t,secretKey:e}},t.sign.keyPair.fromSecretKey=function(t){if(ut(t),64!==t.length)throw new Error("bad secret key size");for(var e=new Uint8Array(32),n=0;n>>6)+r(128|63&e):r(224|e>>>12&15)+r(128|e>>>6&63)+r(128|63&e)},c=function(t){return t.replace(/[^\x00-\x7F]/g,h)},u=function(t){var e=[0,2,1][t.length%3],n=t.charCodeAt(0)<<16|(t.length>1?t.charCodeAt(1):0)<<8|(t.length>2?t.charCodeAt(2):0);return[i.charAt(n>>>18),i.charAt(n>>>12&63),e>=2?"=":i.charAt(n>>>6&63),e>=1?"=":i.charAt(63&n)].join("")},l=self.btoa||function(t){return t.replace(/[\s\S]{1,3}/g,u)};var d=class{constructor(t,e,n,r){this.clear=e,this.timer=t(()=>{this.timer&&(this.timer=r(this.timer))},n)}isRunning(){return null!==this.timer}ensureAborted(){this.timer&&(this.clear(this.timer),this.timer=null)}};function p(t){self.clearTimeout(t)}function f(t){self.clearInterval(t)}class g extends d{constructor(t,e){super(setTimeout,p,t,(function(t){return e(),null}))}}class b extends d{constructor(t,e){super(setInterval,f,t,(function(t){return e(),t}))}}var v={now:()=>Date.now?Date.now():(new Date).valueOf(),defer:t=>new g(0,t),method(t,...e){var n=Array.prototype.slice.call(arguments,1);return function(e){return e[t].apply(e,n.concat(arguments))}}};function y(t,...e){for(var n=0;ne!==t),this):(this.global_callbacks=[],this)}unbind_all(){return this.unbind(),this.unbind_global(),this}emit(t,e,n){for(var r=0;r0)for(r=0;r{self.console&&self.console.log&&self.console.log(t)}}debug(...t){this.log(this.globalLog,t)}warn(...t){this.log(this.globalLogWarn,t)}error(...t){this.log(this.globalLogError,t)}globalLogWarn(t){self.console&&self.console.warn?self.console.warn(t):this.globalLog(t)}globalLogError(t){self.console&&self.console.error?self.console.error(t):this.globalLogWarn(t)}log(t,...e){var n=m.apply(this,arguments);if(xe.log)xe.log(n);else if(xe.logToConsole){t.bind(this)(n)}}};class H extends j{constructor(t,e,n,r,i){super(),this.initialize=ae.transportConnectionInitializer,this.hooks=t,this.name=e,this.priority=n,this.key=r,this.options=i,this.state="new",this.timeline=i.timeline,this.activityTimeout=i.activityTimeout,this.id=this.timeline.generateUniqueID()}handlesActivityChecks(){return Boolean(this.hooks.handlesActivityChecks)}supportsPing(){return Boolean(this.hooks.supportsPing)}connect(){if(this.socket||"initialized"!==this.state)return!1;var t=this.hooks.urls.getInitial(this.key,this.options);try{this.socket=this.hooks.getSocket(t,this.options)}catch(t){return v.defer(()=>{this.onError(t),this.changeState("closed")}),!1}return this.bindListeners(),z.debug("Connecting",{transport:this.name,url:t}),this.changeState("connecting"),!0}close(){return!!this.socket&&(this.socket.close(),!0)}send(t){return"open"===this.state&&(v.defer(()=>{this.socket&&this.socket.send(t)}),!0)}ping(){"open"===this.state&&this.supportsPing()&&this.socket.ping()}onOpen(){this.hooks.beforeOpen&&this.hooks.beforeOpen(this.socket,this.hooks.urls.getPath(this.key,this.options)),this.changeState("open"),this.socket.onopen=void 0}onError(t){this.emit("error",{type:"WebSocketError",error:t}),this.timeline.error(this.buildTimelineMessage({error:t.toString()}))}onClose(t){t?this.changeState("closed",{code:t.code,reason:t.reason,wasClean:t.wasClean}):this.changeState("closed"),this.unbindListeners(),this.socket=void 0}onMessage(t){this.emit("message",t)}onActivity(){this.emit("activity")}bindListeners(){this.socket.onopen=()=>{this.onOpen()},this.socket.onerror=t=>{this.onError(t)},this.socket.onclose=t=>{this.onClose(t)},this.socket.onmessage=t=>{this.onMessage(t)},this.supportsPing()&&(this.socket.onactivity=()=>{this.onActivity()})}unbindListeners(){this.socket&&(this.socket.onopen=void 0,this.socket.onerror=void 0,this.socket.onclose=void 0,this.socket.onmessage=void 0,this.supportsPing()&&(this.socket.onactivity=void 0))}changeState(t,e){this.state=t,this.timeline.info(this.buildTimelineMessage({state:t,params:e})),this.emit(t,e)}buildTimelineMessage(t){return y({cid:this.id},t)}}class B{constructor(t){this.hooks=t}isSupported(t){return this.hooks.isSupported(t)}createConnection(t,e,n,r){return new H(this.hooks,t,e,n,r)}}var F=new B({urls:M,handlesActivityChecks:!1,supportsPing:!1,isInitialized:function(){return Boolean(ae.getWebSocketAPI())},isSupported:function(){return Boolean(ae.getWebSocketAPI())},getSocket:function(t){return ae.createWebSocket(t)}}),q={urls:I,handlesActivityChecks:!1,supportsPing:!0,isInitialized:function(){return!0}},Y=y({getSocket:function(t){return ae.HTTPFactory.createStreamingSocket(t)}},q),K=y({getSocket:function(t){return ae.HTTPFactory.createPollingSocket(t)}},q),$={isSupported:function(){return ae.isXHRSupported()}},J={ws:F,xhr_streaming:new B(y({},Y,$)),xhr_polling:new B(y({},K,$))};class W{constructor(t,e,n){this.manager=t,this.transport=e,this.minPingDelay=n.minPingDelay,this.maxPingDelay=n.maxPingDelay,this.pingDelay=void 0}createConnection(t,e,n,r){r=y({},r,{activityTimeout:this.pingDelay});var i=this.transport.createConnection(t,e,n,r),s=null,o=function(){i.unbind("open",o),i.bind("closed",a),s=v.now()},a=t=>{if(i.unbind("closed",a),1002===t.code||1003===t.code)this.manager.reportDeath();else if(!t.wasClean&&s){var e=v.now()-s;e<2*this.maxPingDelay&&(this.manager.reportDeath(),this.pingDelay=Math.max(e/2,this.minPingDelay))}};return i.bind("open",o),i}isSupported(t){return this.manager.isAlive()&&this.transport.isSupported(t)}}const X={decodeMessage:function(t){try{var e=JSON.parse(t.data),n=e.data;if("string"==typeof n)try{n=JSON.parse(e.data)}catch(t){}var r={event:e.event,channel:e.channel,data:n};return e.user_id&&(r.user_id=e.user_id),r}catch(e){throw{type:"MessageParseError",error:e,data:t.data}}},encodeMessage:function(t){return JSON.stringify(t)},processHandshake:function(t){var e=X.decodeMessage(t);if("pusher:connection_established"===e.event){if(!e.data.activity_timeout)throw"No activity timeout specified in handshake";return{action:"connected",id:e.data.socket_id,activityTimeout:1e3*e.data.activity_timeout}}if("pusher:error"===e.event)return{action:this.getCloseAction(e.data),error:this.getCloseError(e.data)};throw"Invalid handshake"},getCloseAction:function(t){return t.code<4e3?t.code>=1002&&t.code<=1004?"backoff":null:4e3===t.code?"tls_only":t.code<4100?"refused":t.code<4200?"backoff":t.code<4300?"retry":"refused"},getCloseError:function(t){return 1e3!==t.code&&1001!==t.code?{type:"PusherError",data:{code:t.code,message:t.reason||t.message}}:null}};var G=X;class V extends j{constructor(t,e){super(),this.id=t,this.transport=e,this.activityTimeout=e.activityTimeout,this.bindListeners()}handlesActivityChecks(){return this.transport.handlesActivityChecks()}send(t){return this.transport.send(t)}send_event(t,e,n){var r={event:t,data:e};return n&&(r.channel=n),z.debug("Event sent",r),this.send(G.encodeMessage(r))}ping(){this.transport.supportsPing()?this.transport.ping():this.send_event("pusher:ping",{})}close(){this.transport.close()}bindListeners(){var t={message:t=>{var e;try{e=G.decodeMessage(t)}catch(e){this.emit("error",{type:"MessageParseError",error:e,data:t.data})}if(void 0!==e){switch(z.debug("Event recd",e),e.event){case"pusher:error":this.emit("error",{type:"PusherError",data:e.data});break;case"pusher:ping":this.emit("ping");break;case"pusher:pong":this.emit("pong")}this.emit("message",e)}},activity:()=>{this.emit("activity")},error:t=>{this.emit("error",t)},closed:t=>{e(),t&&t.code&&this.handleCloseEvent(t),this.transport=null,this.emit("closed")}},e=()=>{_(t,(t,e)=>{this.transport.unbind(e,t)})};_(t,(t,e)=>{this.transport.bind(e,t)})}handleCloseEvent(t){var e=G.getCloseAction(t),n=G.getCloseError(t);n&&this.emit("error",n),e&&this.emit(e,{action:e,error:n})}}class Z{constructor(t,e){this.transport=t,this.callback=e,this.bindListeners()}close(){this.unbindListeners(),this.transport.close()}bindListeners(){this.onMessage=t=>{var e;this.unbindListeners();try{e=G.processHandshake(t)}catch(t){return this.finish("error",{error:t}),void this.transport.close()}"connected"===e.action?this.finish("connected",{connection:new V(e.id,this.transport),activityTimeout:e.activityTimeout}):(this.finish(e.action,{error:e.error}),this.transport.close())},this.onClosed=t=>{this.unbindListeners();var e=G.getCloseAction(t)||"backoff",n=G.getCloseError(t);this.finish(e,{error:n})},this.transport.bind("message",this.onMessage),this.transport.bind("closed",this.onClosed)}unbindListeners(){this.transport.unbind("message",this.onMessage),this.transport.unbind("closed",this.onClosed)}finish(t,e){this.callback(y({transport:this.transport,action:t},e))}}class Q{constructor(t,e){this.timeline=t,this.options=e||{}}send(t,e){this.timeline.isEmpty()||this.timeline.send(ae.TimelineTransport.getAgent(this,t),e)}}class tt extends Error{constructor(t){super(t),Object.setPrototypeOf(this,new.target.prototype)}}class et extends Error{constructor(t){super(t),Object.setPrototypeOf(this,new.target.prototype)}}Error;class nt extends Error{constructor(t){super(t),Object.setPrototypeOf(this,new.target.prototype)}}class rt extends Error{constructor(t){super(t),Object.setPrototypeOf(this,new.target.prototype)}}class it extends Error{constructor(t){super(t),Object.setPrototypeOf(this,new.target.prototype)}}class st extends Error{constructor(t){super(t),Object.setPrototypeOf(this,new.target.prototype)}}class ot extends Error{constructor(t){super(t),Object.setPrototypeOf(this,new.target.prototype)}}class at extends Error{constructor(t,e){super(e),this.status=t,Object.setPrototypeOf(this,new.target.prototype)}}const ht={baseUrl:"https://pusher.com",urls:{authenticationEndpoint:{path:"/docs/channels/server_api/authenticating_users"},authorizationEndpoint:{path:"/docs/channels/server_api/authorizing-users/"},javascriptQuickStart:{path:"/docs/javascript_quick_start"},triggeringClientEvents:{path:"/docs/client_api_guide/client_events#trigger-events"},encryptedChannelSupport:{fullUrl:"https://github.com/pusher/pusher-js/tree/cc491015371a4bde5743d1c87a0fbac0feb53195#encrypted-channel-support"}}};var ct=function(t){const e=ht.urls[t];if(!e)return"";let n;return e.fullUrl?n=e.fullUrl:e.path&&(n=ht.baseUrl+e.path),n?"See: "+n:""};class ut extends j{constructor(t,e){super((function(e,n){z.debug("No callbacks on "+t+" for "+e)})),this.name=t,this.pusher=e,this.subscribed=!1,this.subscriptionPending=!1,this.subscriptionCancelled=!1}authorize(t,e){return e(null,{auth:""})}trigger(t,e){if(0!==t.indexOf("client-"))throw new tt("Event '"+t+"' does not start with 'client-'");if(!this.subscribed){var n=ct("triggeringClientEvents");z.warn("Client event triggered before channel 'subscription_succeeded' event . "+n)}return this.pusher.send_event(t,e,this.name)}disconnect(){this.subscribed=!1,this.subscriptionPending=!1}handleEvent(t){var e=t.event,n=t.data;if("pusher_internal:subscription_succeeded"===e)this.handleSubscriptionSucceededEvent(t);else if("pusher_internal:subscription_count"===e)this.handleSubscriptionCountEvent(t);else if(0!==e.indexOf("pusher_internal:")){this.emit(e,n,{})}}handleSubscriptionSucceededEvent(t){this.subscriptionPending=!1,this.subscribed=!0,this.subscriptionCancelled?this.pusher.unsubscribe(this.name):this.emit("pusher:subscription_succeeded",t.data)}handleSubscriptionCountEvent(t){t.data.subscription_count&&(this.subscriptionCount=t.data.subscription_count),this.emit("pusher:subscription_count",t.data)}subscribe(){this.subscribed||(this.subscriptionPending=!0,this.subscriptionCancelled=!1,this.authorize(this.pusher.connection.socket_id,(t,e)=>{t?(this.subscriptionPending=!1,z.error(t.toString()),this.emit("pusher:subscription_error",Object.assign({},{type:"AuthError",error:t.message},t instanceof at?{status:t.status}:{}))):this.pusher.send_event("pusher:subscribe",{auth:e.auth,channel_data:e.channel_data,channel:this.name})}))}unsubscribe(){this.subscribed=!1,this.pusher.send_event("pusher:unsubscribe",{channel:this.name})}cancelSubscription(){this.subscriptionCancelled=!0}reinstateSubscription(){this.subscriptionCancelled=!1}}class lt extends ut{authorize(t,e){return this.pusher.config.channelAuthorizer({channelName:this.name,socketId:t},e)}}class dt{constructor(){this.reset()}get(t){return Object.prototype.hasOwnProperty.call(this.members,t)?{id:t,info:this.members[t]}:null}each(t){_(this.members,(e,n)=>{t(this.get(n))})}setMyID(t){this.myID=t}onSubscription(t){this.members=t.presence.hash,this.count=t.presence.count,this.me=this.get(this.myID)}addMember(t){return null===this.get(t.user_id)&&this.count++,this.members[t.user_id]=t.user_info,this.get(t.user_id)}removeMember(t){var e=this.get(t.user_id);return e&&(delete this.members[t.user_id],this.count--),e}reset(){this.members={},this.count=0,this.myID=null,this.me=null}}var pt=function(t,e,n,r){return new(n||(n=Promise))((function(i,s){function o(t){try{h(r.next(t))}catch(t){s(t)}}function a(t){try{h(r.throw(t))}catch(t){s(t)}}function h(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(o,a)}h((r=r.apply(t,e||[])).next())}))};class ft extends lt{constructor(t,e){super(t,e),this.members=new dt}authorize(t,e){super.authorize(t,(t,n)=>pt(this,void 0,void 0,(function*(){if(!t)if(null!=(n=n).channel_data){var r=JSON.parse(n.channel_data);this.members.setMyID(r.user_id)}else{if(yield this.pusher.user.signinDonePromise,null==this.pusher.user.user_data){let t=ct("authorizationEndpoint");return z.error(`Invalid auth response for channel '${this.name}', expected 'channel_data' field. ${t}, or the user should be signed in.`),void e("Invalid auth response")}this.members.setMyID(this.pusher.user.user_data.id)}e(t,n)})))}handleEvent(t){var e=t.event;if(0===e.indexOf("pusher_internal:"))this.handleInternalEvent(t);else{var n=t.data,r={};t.user_id&&(r.user_id=t.user_id),this.emit(e,n,r)}}handleInternalEvent(t){var e=t.event,n=t.data;switch(e){case"pusher_internal:subscription_succeeded":this.handleSubscriptionSucceededEvent(t);break;case"pusher_internal:subscription_count":this.handleSubscriptionCountEvent(t);break;case"pusher_internal:member_added":var r=this.members.addMember(n);this.emit("pusher:member_added",r);break;case"pusher_internal:member_removed":var i=this.members.removeMember(n);i&&this.emit("pusher:member_removed",i)}}handleSubscriptionSucceededEvent(t){this.subscriptionPending=!1,this.subscribed=!0,this.subscriptionCancelled?this.pusher.unsubscribe(this.name):(this.members.onSubscription(t.data),this.emit("pusher:subscription_succeeded",this.members))}disconnect(){this.members.reset(),super.disconnect()}}var gt=n(1),bt=n(0);class vt extends lt{constructor(t,e,n){super(t,e),this.key=null,this.nacl=n}authorize(t,e){super.authorize(t,(t,n)=>{if(t)return void e(t,n);let r=n.shared_secret;r?(this.key=Object(bt.decode)(r),delete n.shared_secret,e(null,n)):e(new Error("No shared_secret key in auth payload for encrypted channel: "+this.name),null)})}trigger(t,e){throw new it("Client events are not currently supported for encrypted channels")}handleEvent(t){var e=t.event,n=t.data;0!==e.indexOf("pusher_internal:")&&0!==e.indexOf("pusher:")?this.handleEncryptedEvent(e,n):super.handleEvent(t)}handleEncryptedEvent(t,e){if(!this.key)return void z.debug("Received encrypted event before key has been retrieved from the authEndpoint");if(!e.ciphertext||!e.nonce)return void z.error("Unexpected format for encrypted event, expected object with `ciphertext` and `nonce` fields, got: "+e);let n=Object(bt.decode)(e.ciphertext);if(n.length{e?z.error(`Failed to make a request to the authEndpoint: ${s}. Unable to fetch new key, so dropping encrypted event`):(i=this.nacl.secretbox.open(n,r,this.key),null!==i?this.emit(t,this.getDataToEmit(i)):z.error("Failed to decrypt event with new key. Dropping encrypted event"))});this.emit(t,this.getDataToEmit(i))}getDataToEmit(t){let e=Object(gt.decode)(t);try{return JSON.parse(e)}catch(t){return e}}}class yt extends j{constructor(t,e){super(),this.state="initialized",this.connection=null,this.key=t,this.options=e,this.timeline=this.options.timeline,this.usingTLS=this.options.useTLS,this.errorCallbacks=this.buildErrorCallbacks(),this.connectionCallbacks=this.buildConnectionCallbacks(this.errorCallbacks),this.handshakeCallbacks=this.buildHandshakeCallbacks(this.errorCallbacks);var n=ae.getNetwork();n.bind("online",()=>{this.timeline.info({netinfo:"online"}),"connecting"!==this.state&&"unavailable"!==this.state||this.retryIn(0)}),n.bind("offline",()=>{this.timeline.info({netinfo:"offline"}),this.connection&&this.sendActivityCheck()}),this.updateStrategy()}connect(){this.connection||this.runner||(this.strategy.isSupported()?(this.updateState("connecting"),this.startConnecting(),this.setUnavailableTimer()):this.updateState("failed"))}send(t){return!!this.connection&&this.connection.send(t)}send_event(t,e,n){return!!this.connection&&this.connection.send_event(t,e,n)}disconnect(){this.disconnectInternally(),this.updateState("disconnected")}isUsingTLS(){return this.usingTLS}startConnecting(){var t=(e,n)=>{e?this.runner=this.strategy.connect(0,t):"error"===n.action?(this.emit("error",{type:"HandshakeError",error:n.error}),this.timeline.error({handshakeError:n.error})):(this.abortConnecting(),this.handshakeCallbacks[n.action](n))};this.runner=this.strategy.connect(0,t)}abortConnecting(){this.runner&&(this.runner.abort(),this.runner=null)}disconnectInternally(){(this.abortConnecting(),this.clearRetryTimer(),this.clearUnavailableTimer(),this.connection)&&this.abandonConnection().close()}updateStrategy(){this.strategy=this.options.getStrategy({key:this.key,timeline:this.timeline,useTLS:this.usingTLS})}retryIn(t){this.timeline.info({action:"retry",delay:t}),t>0&&this.emit("connecting_in",Math.round(t/1e3)),this.retryTimer=new g(t||0,()=>{this.disconnectInternally(),this.connect()})}clearRetryTimer(){this.retryTimer&&(this.retryTimer.ensureAborted(),this.retryTimer=null)}setUnavailableTimer(){this.unavailableTimer=new g(this.options.unavailableTimeout,()=>{this.updateState("unavailable")})}clearUnavailableTimer(){this.unavailableTimer&&this.unavailableTimer.ensureAborted()}sendActivityCheck(){this.stopActivityCheck(),this.connection.ping(),this.activityTimer=new g(this.options.pongTimeout,()=>{this.timeline.error({pong_timed_out:this.options.pongTimeout}),this.retryIn(0)})}resetActivityCheck(){this.stopActivityCheck(),this.connection&&!this.connection.handlesActivityChecks()&&(this.activityTimer=new g(this.activityTimeout,()=>{this.sendActivityCheck()}))}stopActivityCheck(){this.activityTimer&&this.activityTimer.ensureAborted()}buildConnectionCallbacks(t){return y({},t,{message:t=>{this.resetActivityCheck(),this.emit("message",t)},ping:()=>{this.send_event("pusher:pong",{})},activity:()=>{this.resetActivityCheck()},error:t=>{this.emit("error",t)},closed:()=>{this.abandonConnection(),this.shouldRetry()&&this.retryIn(1e3)}})}buildHandshakeCallbacks(t){return y({},t,{connected:t=>{this.activityTimeout=Math.min(this.options.activityTimeout,t.activityTimeout,t.connection.activityTimeout||1/0),this.clearUnavailableTimer(),this.setConnection(t.connection),this.socket_id=this.connection.id,this.updateState("connected",{socket_id:this.socket_id})}})}buildErrorCallbacks(){let t=t=>e=>{e.error&&this.emit("error",{type:"WebSocketError",error:e.error}),t(e)};return{tls_only:t(()=>{this.usingTLS=!0,this.updateStrategy(),this.retryIn(0)}),refused:t(()=>{this.disconnect()}),backoff:t(()=>{this.retryIn(1e3)}),retry:t(()=>{this.retryIn(0)})}}setConnection(t){for(var e in this.connection=t,this.connectionCallbacks)this.connection.bind(e,this.connectionCallbacks[e]);this.resetActivityCheck()}abandonConnection(){if(this.connection){for(var t in this.stopActivityCheck(),this.connectionCallbacks)this.connection.unbind(t,this.connectionCallbacks[t]);var e=this.connection;return this.connection=null,e}}updateState(t,e){var n=this.state;if(this.state=t,n!==t){var r=t;"connected"===r&&(r+=" with new socket ID "+e.socket_id),z.debug("State changed",n+" -> "+r),this.timeline.info({state:t,params:e}),this.emit("state_change",{previous:n,current:t}),this.emit(t,e)}}shouldRetry(){return"connecting"===this.state||"connected"===this.state}}class mt{constructor(){this.channels={}}add(t,e){return this.channels[t]||(this.channels[t]=function(t,e){if(0===t.indexOf("private-encrypted-")){if(e.config.nacl)return wt.createEncryptedChannel(t,e,e.config.nacl);let n="Tried to subscribe to a private-encrypted- channel but no nacl implementation available",r=ct("encryptedChannelSupport");throw new it(`${n}. ${r}`)}if(0===t.indexOf("private-"))return wt.createPrivateChannel(t,e);if(0===t.indexOf("presence-"))return wt.createPresenceChannel(t,e);if(0===t.indexOf("#"))throw new et('Cannot create a channel with name "'+t+'".');return wt.createChannel(t,e)}(t,e)),this.channels[t]}all(){return function(t){var e=[];return _(t,(function(t){e.push(t)})),e}(this.channels)}find(t){return this.channels[t]}remove(t){var e=this.channels[t];return delete this.channels[t],e}disconnect(){_(this.channels,(function(t){t.disconnect()}))}}var wt={createChannels:()=>new mt,createConnectionManager:(t,e)=>new yt(t,e),createChannel:(t,e)=>new ut(t,e),createPrivateChannel:(t,e)=>new lt(t,e),createPresenceChannel:(t,e)=>new ft(t,e),createEncryptedChannel:(t,e,n)=>new vt(t,e,n),createTimelineSender:(t,e)=>new Q(t,e),createHandshake:(t,e)=>new Z(t,e),createAssistantToTheTransportManager:(t,e,n)=>new W(t,e,n)};class _t{constructor(t){this.options=t||{},this.livesLeft=this.options.lives||1/0}getAssistant(t){return wt.createAssistantToTheTransportManager(this,t,{minPingDelay:this.options.minPingDelay,maxPingDelay:this.options.maxPingDelay})}isAlive(){return this.livesLeft>0}reportDeath(){this.livesLeft-=1}}class St{constructor(t,e){this.strategies=t,this.loop=Boolean(e.loop),this.failFast=Boolean(e.failFast),this.timeout=e.timeout,this.timeoutLimit=e.timeoutLimit}isSupported(){return A(this.strategies,v.method("isSupported"))}connect(t,e){var n=this.strategies,r=0,i=this.timeout,s=null,o=(a,h)=>{h?e(null,h):(r+=1,this.loop&&(r%=n.length),r0&&(i=new g(n.timeout,(function(){s.abort(),r(!0)}))),s=t.connect(e,(function(t,e){t&&i&&i.isRunning()&&!n.failFast||(i&&i.ensureAborted(),r(t,e))})),{abort:function(){i&&i.ensureAborted(),s.abort()},forceMinPriority:function(t){s.forceMinPriority(t)}}}}class kt{constructor(t){this.strategies=t}isSupported(){return A(this.strategies,v.method("isSupported"))}connect(t,e){return function(t,e,n){var r=C(t,(function(t,r,i,s){return t.connect(e,n(r,s))}));return{abort:function(){k(r,Ct)},forceMinPriority:function(t){k(r,(function(e){e.forceMinPriority(t)}))}}}(this.strategies,t,(function(t,n){return function(r,i){n[t].error=r,r?function(t){return function(t,e){for(var n=0;n=v.now()){var o=this.transports[r.transport];o&&(["ws","wss"].includes(r.transport)||i>3?(this.timeline.info({cached:!0,transport:r.transport,latency:r.latency}),s.push(new St([o],{timeout:2*r.latency+1e3,failFast:!0}))):i++)}var a=v.now(),h=s.pop().connect(t,(function r(o,c){o?(At(n),s.length>0?(a=v.now(),h=s.pop().connect(t,r)):e(o)):(!function(t,e,n,r){var i=ae.getLocalStorage();if(i)try{i[Pt(t)]=O({timestamp:v.now(),transport:e,latency:n,cacheSkipCount:r})}catch(t){}}(n,c.transport.name,v.now()-a,i),e(null,c))}));return{abort:function(){h.abort()},forceMinPriority:function(e){t=e,h&&h.forceMinPriority(e)}}}}function Pt(t){return"pusherTransport"+(t?"TLS":"NonTLS")}function At(t){var e=ae.getLocalStorage();if(e)try{delete e[Pt(t)]}catch(t){}}class Et{constructor(t,{delay:e}){this.strategy=t,this.options={delay:e}}isSupported(){return this.strategy.isSupported()}connect(t,e){var n,r=this.strategy,i=new g(this.options.delay,(function(){n=r.connect(t,e)}));return{abort:function(){i.ensureAborted(),n&&n.abort()},forceMinPriority:function(e){t=e,n&&n.forceMinPriority(e)}}}}class xt{constructor(t,e,n){this.test=t,this.trueBranch=e,this.falseBranch=n}isSupported(){return(this.test()?this.trueBranch:this.falseBranch).isSupported()}connect(t,e){return(this.test()?this.trueBranch:this.falseBranch).connect(t,e)}}class Ot{constructor(t){this.strategy=t}isSupported(){return this.strategy.isSupported()}connect(t,e){var n=this.strategy.connect(t,(function(t,r){r&&n.abort(),e(t,r)}));return n}}function Lt(t){return function(){return t.isSupported()}}var Ut=function(t,e,n){var r={};function i(e,i,s,o,a){var h=n(t,e,i,s,o,a);return r[e]=h,h}var s,o=Object.assign({},e,{hostNonTLS:t.wsHost+":"+t.wsPort,hostTLS:t.wsHost+":"+t.wssPort,httpPath:t.wsPath}),a=y({},o,{useTLS:!0}),h=Object.assign({},e,{hostNonTLS:t.httpHost+":"+t.httpPort,hostTLS:t.httpHost+":"+t.httpsPort,httpPath:t.httpPath}),c={loop:!0,timeout:15e3,timeoutLimit:6e4},u=new _t({minPingDelay:1e4,maxPingDelay:t.activityTimeout}),l=new _t({lives:2,minPingDelay:1e4,maxPingDelay:t.activityTimeout}),d=i("ws","ws",3,o,u),p=i("wss","ws",3,a,u),f=i("xhr_streaming","xhr_streaming",1,h,l),g=i("xhr_polling","xhr_polling",1,h),b=new St([d],c),v=new St([p],c),m=new St([f],c),w=new St([g],c),_=new St([new xt(Lt(m),new kt([m,new Et(w,{delay:4e3})]),w)],c);return s=e.useTLS?new kt([b,new Et(_,{delay:2e3})]):new kt([b,new Et(v,{delay:2e3}),new Et(_,{delay:5e3})]),new Tt(new Ot(new xt(Lt(d),s,_)),r,{ttl:18e5,timeline:e.timeline,useTLS:e.useTLS})};class Rt extends j{constructor(t,e,n){super(),this.hooks=t,this.method=e,this.url=n}start(t){this.position=0,this.xhr=this.hooks.getRequest(this),this.unloader=()=>{this.close()},ae.addUnloadListener(this.unloader),this.xhr.open(this.method,this.url,!0),this.xhr.setRequestHeader&&this.xhr.setRequestHeader("Content-Type","application/json"),this.xhr.send(t)}close(){this.unloader&&(ae.removeUnloadListener(this.unloader),this.unloader=null),this.xhr&&(this.hooks.abortRequest(this.xhr),this.xhr=null)}onChunk(t,e){for(;;){var n=this.advanceBuffer(e);if(!n)break;this.emit("chunk",{status:t,data:n})}this.isBufferTooLong(e)&&this.emit("buffer_too_long")}advanceBuffer(t){var e=t.slice(this.position),n=e.indexOf("\n");return-1!==n?(this.position+=n+1,e.slice(0,n)):null}isBufferTooLong(t){return this.position===t.length&&t.length>262144}}var Mt;!function(t){t[t.CONNECTING=0]="CONNECTING",t[t.OPEN=1]="OPEN",t[t.CLOSED=3]="CLOSED"}(Mt||(Mt={}));var It=Mt,Nt=1;function Dt(t){var e=-1===t.indexOf("?")?"?":"&";return t+e+"t="+ +new Date+"&n="+Nt++}function jt(t){return ae.randomInt(t)}var zt=class{constructor(t,e){this.hooks=t,this.session=jt(1e3)+"/"+function(t){for(var e=[],n=0;n{this.onChunk(t)}),this.stream.bind("finished",t=>{this.hooks.onFinished(this,t)}),this.stream.bind("buffer_too_long",()=>{this.reconnect()});try{this.stream.start()}catch(t){v.defer(()=>{this.onError(t),this.onClose(1006,"Could not start streaming",!1)})}}closeStream(){this.stream&&(this.stream.unbind_all(),this.stream.close(),this.stream=null)}},Ht={getReceiveURL:function(t,e){return t.base+"/"+e+"/xhr_streaming"+t.queryString},onHeartbeat:function(t){t.sendRaw("[]")},sendHeartbeat:function(t){t.sendRaw("[]")},onFinished:function(t,e){t.onClose(1006,"Connection interrupted ("+e+")",!1)}},Bt={getReceiveURL:function(t,e){return t.base+"/"+e+"/xhr"+t.queryString},onHeartbeat:function(){},sendHeartbeat:function(t){t.sendRaw("[]")},onFinished:function(t,e){200===e?t.reconnect():t.onClose(1006,"Connection interrupted ("+e+")",!1)}},Ft={getRequest:function(t){var e=new(ae.getXHRAPI());return e.onreadystatechange=e.onprogress=function(){switch(e.readyState){case 3:e.responseText&&e.responseText.length>0&&t.onChunk(e.status,e.responseText);break;case 4:e.responseText&&e.responseText.length>0&&t.onChunk(e.status,e.responseText),t.emit("finished",e.status),t.close()}},e},abortRequest:function(t){t.onreadystatechange=null,t.abort()}},qt={getDefaultStrategy:Ut,Transports:J,transportConnectionInitializer:function(){this.timeline.info(this.buildTimelineMessage({transport:this.name+(this.options.useTLS?"s":"")})),this.hooks.isInitialized()?this.changeState("initialized"):this.onClose()},HTTPFactory:{createStreamingSocket(t){return this.createSocket(Ht,t)},createPollingSocket(t){return this.createSocket(Bt,t)},createSocket:(t,e)=>new zt(t,e),createXHR(t,e){return this.createRequest(Ft,t,e)},createRequest:(t,e,n)=>new Rt(t,e,n)},setup(t){t.ready()},getLocalStorage(){},getClientFeatures:()=>S(P({ws:J.ws},(function(t){return t.isSupported({})}))),getProtocol:()=>"http:",isXHRSupported:()=>!0,createSocketRequest(t,e){if(this.isXHRSupported())return this.HTTPFactory.createXHR(t,e);throw"Cross-origin HTTP requests are not supported"},createXHR(){return new(this.getXHRAPI())},createWebSocket(t){return new(this.getWebSocketAPI())(t)},addUnloadListener(t){},removeUnloadListener(t){}};var Yt=new class extends j{isOnline(){return!0}},Kt=function(t,e,n,r,i){var s=new Headers;for(var o in s.set("Content-Type","application/x-www-form-urlencoded"),n.headers)s.set(o,n.headers[o]);if(null!=n.headersProvider){const t=n.headersProvider();for(var o in t)s.set(o,t[o])}var a=e,h=new Request(n.endpoint,{headers:s,body:a,credentials:"same-origin",method:"POST"});return fetch(h).then(t=>{let{status:e}=t;if(200===e)return t.text();throw new at(e,`Could not get ${r.toString()} info from your auth endpoint, status: ${e}`)}).then(t=>{let e;try{e=JSON.parse(t)}catch(e){throw new at(200,`JSON returned from ${r.toString()} endpoint was invalid, yet status code was 200. Data was: ${t}`)}i(null,e)}).catch(t=>{i(t,null)})},$t={name:"xhr",getAgent:function(t,e){return function(n,r){var i="http"+(e?"s":"")+"://"+(t.host||t.options.host)+t.options.path,s=x(n);fetch(i+="/2?"+s).then(t=>{if(200!==t.status)throw`received ${t.status} from stats.pusher.com`;return t.json()}).then(({host:e})=>{e&&(t.host=e)}).catch(t=>{z.debug("TimelineSender Error: ",t)})}}};const{getDefaultStrategy:Jt,Transports:Wt,setup:Xt,getProtocol:Gt,isXHRSupported:Vt,getLocalStorage:Zt,createXHR:Qt,createWebSocket:te,addUnloadListener:ee,removeUnloadListener:ne,transportConnectionInitializer:re,createSocketRequest:ie,HTTPFactory:se}=qt;var oe,ae={getDefaultStrategy:Jt,Transports:Wt,setup:Xt,getProtocol:Gt,isXHRSupported:Vt,getLocalStorage:Zt,createXHR:Qt,createWebSocket:te,addUnloadListener:ee,removeUnloadListener:ne,transportConnectionInitializer:re,createSocketRequest:ie,HTTPFactory:se,TimelineTransport:$t,getAuthorizers:()=>({ajax:Kt}),getWebSocketAPI:()=>WebSocket,getXHRAPI:()=>XMLHttpRequest,getNetwork:()=>Yt,randomInt:t=>Math.floor((globalThis.crypto||globalThis.msCrypto).getRandomValues(new Uint32Array(1))[0]/Math.pow(2,32)*t)};!function(t){t[t.ERROR=3]="ERROR",t[t.INFO=6]="INFO",t[t.DEBUG=7]="DEBUG"}(oe||(oe={}));var he=oe;class ce{constructor(t,e,n){this.key=t,this.session=e,this.events=[],this.options=n||{},this.sent=0,this.uniqueID=0}log(t,e){t<=this.options.level&&(this.events.push(y({},e,{timestamp:v.now()})),this.options.limit&&this.events.length>this.options.limit&&this.events.shift())}error(t){this.log(he.ERROR,t)}info(t){this.log(he.INFO,t)}debug(t){this.log(he.DEBUG,t)}isEmpty(){return 0===this.events.length}send(t,e){var n=y({session:this.session,bundle:this.sent+1,key:this.key,lib:"js",version:this.options.version,cluster:this.options.cluster,features:this.options.features,timeline:this.events},this.options.params);return this.events=[],t(n,(t,n)=>{t||this.sent++,e&&e(t,n)}),!0}generateUniqueID(){return this.uniqueID++,this.uniqueID}}class ue{constructor(t,e,n,r){this.name=t,this.priority=e,this.transport=n,this.options=r||{}}isSupported(){return this.transport.isSupported({useTLS:this.options.useTLS})}connect(t,e){if(!this.isSupported())return le(new ot,e);if(this.priority{n||(c(),i?i.close():r.close())},forceMinPriority:t=>{n||this.priority{if(void 0===ae.getAuthorizers()[t.transport])throw`'${t.transport}' is not a recognized auth transport`;return(e,n)=>{const r=((t,e)=>{var n="socket_id="+encodeURIComponent(t.socketId);for(var r in e.params)n+="&"+encodeURIComponent(r)+"="+encodeURIComponent(e.params[r]);if(null!=e.paramsProvider){let t=e.paramsProvider();for(var r in t)n+="&"+encodeURIComponent(r)+"="+encodeURIComponent(t[r])}return n})(e,t);ae.getAuthorizers()[t.transport](ae,r,t,pe.UserAuthentication,n)}};var ye=t=>{if(void 0===ae.getAuthorizers()[t.transport])throw`'${t.transport}' is not a recognized auth transport`;return(e,n)=>{const r=((t,e)=>{var n="socket_id="+encodeURIComponent(t.socketId);for(var r in n+="&channel_name="+encodeURIComponent(t.channelName),e.params)n+="&"+encodeURIComponent(r)+"="+encodeURIComponent(e.params[r]);if(null!=e.paramsProvider){let t=e.paramsProvider();for(var r in t)n+="&"+encodeURIComponent(r)+"="+encodeURIComponent(t[r])}return n})(e,t);ae.getAuthorizers()[t.transport](ae,r,t,pe.ChannelAuthorization,n)}};function me(t){return t.httpHost?t.httpHost:t.cluster?`sockjs-${t.cluster}.pusher.com`:L.httpHost}function we(t){return t.wsHost?t.wsHost:`ws-${t.cluster}.pusher.com`}function _e(t){return"https:"===ae.getProtocol()||!1!==t.forceTLS}function Se(t){return"enableStats"in t?t.enableStats:"disableStats"in t&&!t.disableStats}function ke(t){const e=Object.assign(Object.assign({},L.userAuthentication),t.userAuthentication);return"customHandler"in e&&null!=e.customHandler?e.customHandler:ve(e)}function Ce(t,e){const n=function(t,e){let n;return"channelAuthorization"in t?n=Object.assign(Object.assign({},L.channelAuthorization),t.channelAuthorization):(n={transport:t.authTransport||L.authTransport,endpoint:t.authEndpoint||L.authEndpoint},"auth"in t&&("params"in t.auth&&(n.params=t.auth.params),"headers"in t.auth&&(n.headers=t.auth.headers)),"authorizer"in t&&(n.customHandler=((t,e,n)=>{const r={authTransport:e.transport,authEndpoint:e.endpoint,auth:{params:e.params,headers:e.headers}};return(e,i)=>{const s=t.channel(e.channelName);n(s,r).authorize(e.socketId,i)}})(e,n,t.authorizer))),n}(t,e);return"customHandler"in n&&null!=n.customHandler?n.customHandler:ye(n)}class Te extends j{constructor(t){super((function(t,e){z.debug("No callbacks on watchlist events for "+t)})),this.pusher=t,this.bindWatchlistInternalEvent()}handleEvent(t){t.data.events.forEach(t=>{this.emit(t.name,t)})}bindWatchlistInternalEvent(){this.pusher.connection.bind("message",t=>{"pusher_internal:watchlist_events"===t.event&&this.handleEvent(t)})}}var Pe=function(){let t,e;return{promise:new Promise((n,r)=>{t=n,e=r}),resolve:t,reject:e}};class Ae extends j{constructor(t){super((function(t,e){z.debug("No callbacks on user for "+t)})),this.signin_requested=!1,this.user_data=null,this.serverToUserChannel=null,this.signinDonePromise=null,this._signinDoneResolve=null,this._onAuthorize=(t,e)=>{if(t)return z.warn("Error during signin: "+t),void this._cleanup();this.pusher.send_event("pusher:signin",{auth:e.auth,user_data:e.user_data})},this.pusher=t,this.pusher.connection.bind("state_change",({previous:t,current:e})=>{"connected"!==t&&"connected"===e&&this._signin(),"connected"===t&&"connected"!==e&&(this._cleanup(),this._newSigninPromiseIfNeeded())}),this.watchlist=new Te(t),this.pusher.connection.bind("message",t=>{"pusher:signin_success"===t.event&&this._onSigninSuccess(t.data),this.serverToUserChannel&&this.serverToUserChannel.name===t.channel&&this.serverToUserChannel.handleEvent(t)})}signin(){this.signin_requested||(this.signin_requested=!0,this._signin())}_signin(){this.signin_requested&&(this._newSigninPromiseIfNeeded(),"connected"===this.pusher.connection.state&&this.pusher.config.userAuthenticator({socketId:this.pusher.connection.socket_id},this._onAuthorize))}_onSigninSuccess(t){try{this.user_data=JSON.parse(t.user_data)}catch(e){return z.error("Failed parsing user data after signin: "+t.user_data),void this._cleanup()}if("string"!=typeof this.user_data.id||""===this.user_data.id)return z.error("user_data doesn't contain an id. user_data: "+this.user_data),void this._cleanup();this._signinDoneResolve(),this._subscribeChannels()}_subscribeChannels(){this.serverToUserChannel=new ut("#server-to-user-"+this.user_data.id,this.pusher),this.serverToUserChannel.bind_global((t,e)=>{0!==t.indexOf("pusher_internal:")&&0!==t.indexOf("pusher:")&&this.emit(t,e)}),(t=>{t.subscriptionPending&&t.subscriptionCancelled?t.reinstateSubscription():t.subscriptionPending||"connected"!==this.pusher.connection.state||t.subscribe()})(this.serverToUserChannel)}_cleanup(){this.user_data=null,this.serverToUserChannel&&(this.serverToUserChannel.unbind_all(),this.serverToUserChannel.disconnect(),this.serverToUserChannel=null),this.signin_requested&&this._signinDoneResolve()}_newSigninPromiseIfNeeded(){if(!this.signin_requested)return;if(this.signinDonePromise&&!this.signinDonePromise.done)return;const{promise:t,resolve:e,reject:n}=Pe();t.done=!1;const r=()=>{t.done=!0};t.then(r).catch(r),this.signinDonePromise=t,this._signinDoneResolve=e}}class Ee{static ready(){Ee.isReady=!0;for(var t=0,e=Ee.instances.length;tae.getDefaultStrategy(this.config,t,fe),timeline:this.timeline,activityTimeout:this.config.activityTimeout,pongTimeout:this.config.pongTimeout,unavailableTimeout:this.config.unavailableTimeout,useTLS:Boolean(this.config.useTLS)}),this.connection.bind("connected",()=>{this.subscribeAll(),this.timelineSender&&this.timelineSender.send(this.connection.isUsingTLS())}),this.connection.bind("message",t=>{var e=0===t.event.indexOf("pusher_internal:");if(t.channel){var n=this.channel(t.channel);n&&n.handleEvent(t)}e||this.global_emitter.emit(t.event,t.data)}),this.connection.bind("connecting",()=>{this.channels.disconnect()}),this.connection.bind("disconnected",()=>{this.channels.disconnect()}),this.connection.bind("error",t=>{z.warn(t)}),Ee.instances.push(this),this.timeline.info({instances:Ee.instances.length}),this.user=new Ae(this),Ee.isReady&&this.connect()}channel(t){return this.channels.find(t)}allChannels(){return this.channels.all()}connect(){if(this.connection.connect(),this.timelineSender&&!this.timelineSenderTimer){var t=this.connection.isUsingTLS(),e=this.timelineSender;this.timelineSenderTimer=new b(6e4,(function(){e.send(t)}))}}disconnect(){this.connection.disconnect(),this.timelineSenderTimer&&(this.timelineSenderTimer.ensureAborted(),this.timelineSenderTimer=null)}bind(t,e,n){return this.global_emitter.bind(t,e,n),this}unbind(t,e,n){return this.global_emitter.unbind(t,e,n),this}bind_global(t){return this.global_emitter.bind_global(t),this}unbind_global(t){return this.global_emitter.unbind_global(t),this}unbind_all(t){return this.global_emitter.unbind_all(),this}subscribeAll(){var t;for(t in this.channels.channels)this.channels.channels.hasOwnProperty(t)&&this.subscribe(t)}subscribe(t){var e=this.channels.add(t,this);return e.subscriptionPending&&e.subscriptionCancelled?e.reinstateSubscription():e.subscriptionPending||"connected"!==this.connection.state||e.subscribe(),e}unsubscribe(t){var e=this.channels.find(t);e&&e.subscriptionPending?e.cancelSubscription():(e=this.channels.remove(t))&&e.subscribed&&e.unsubscribe()}send_event(t,e,n){return this.connection.send_event(t,e,n)}shouldUseTLS(){return this.config.useTLS}signin(){this.user.signin()}}Ee.instances=[],Ee.isReady=!1,Ee.logToConsole=!1,Ee.Runtime=ae,Ee.ScriptReceivers=ae.ScriptReceivers,Ee.DependenciesReceivers=ae.DependenciesReceivers,Ee.auth_callbacks=ae.auth_callbacks;var xe=Ee;ae.setup(Ee);var Oe=n(2);class Le extends xe{constructor(t,e){xe.logToConsole=Le.logToConsole,xe.log=Le.log,be(e),e.nacl=Oe,super(t,e)}}}])})); +!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.Pusher=e():t.Pusher=e()}(this,(function(){return function(t){var e={};function n(r){if(e[r])return e[r].exports;var i=e[r]={i:r,l:!1,exports:{}};return t[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)n.d(r,i,function(e){return t[e]}.bind(null,i));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=3)}([function(t,e,n){"use strict";var r,i=this&&this.__extends||(r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)},function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)});Object.defineProperty(e,"__esModule",{value:!0});var s=function(){function t(t){void 0===t&&(t="="),this._paddingCharacter=t}return t.prototype.encodedLength=function(t){return this._paddingCharacter?(t+2)/3*4|0:(8*t+5)/6|0},t.prototype.encode=function(t){for(var e="",n=0;n>>18&63),e+=this._encodeByte(r>>>12&63),e+=this._encodeByte(r>>>6&63),e+=this._encodeByte(r>>>0&63)}var i=t.length-n;if(i>0){r=t[n]<<16|(2===i?t[n+1]<<8:0);e+=this._encodeByte(r>>>18&63),e+=this._encodeByte(r>>>12&63),e+=2===i?this._encodeByte(r>>>6&63):this._paddingCharacter||"",e+=this._paddingCharacter||""}return e},t.prototype.maxDecodedLength=function(t){return this._paddingCharacter?t/4*3|0:(6*t+7)/8|0},t.prototype.decodedLength=function(t){return this.maxDecodedLength(t.length-this._getPaddingLength(t))},t.prototype.decode=function(t){if(0===t.length)return new Uint8Array(0);for(var e=this._getPaddingLength(t),n=t.length-e,r=new Uint8Array(this.maxDecodedLength(n)),i=0,s=0,o=0,a=0,h=0,c=0,u=0;s>>4,r[i++]=h<<4|c>>>2,r[i++]=c<<6|u,o|=256&a,o|=256&h,o|=256&c,o|=256&u;if(s>>4,o|=256&a,o|=256&h),s>>2,o|=256&c),s>>8&6,e+=51-t>>>8&-75,e+=61-t>>>8&-15,e+=62-t>>>8&3,String.fromCharCode(e)},t.prototype._decodeChar=function(t){var e=256;return e+=(42-t&t-44)>>>8&-256+t-43+62,e+=(46-t&t-48)>>>8&-256+t-47+63,e+=(47-t&t-58)>>>8&-256+t-48+52,e+=(64-t&t-91)>>>8&-256+t-65+0,e+=(96-t&t-123)>>>8&-256+t-97+26},t.prototype._getPaddingLength=function(t){var e=0;if(this._paddingCharacter){for(var n=t.length-1;n>=0&&t[n]===this._paddingCharacter;n--)e++;if(t.length<4||e>2)throw new Error("Base64Coder: incorrect padding")}return e},t}();e.Coder=s;var o=new s;e.encode=function(t){return o.encode(t)},e.decode=function(t){return o.decode(t)};var a=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return i(e,t),e.prototype._encodeByte=function(t){var e=t;return e+=65,e+=25-t>>>8&6,e+=51-t>>>8&-75,e+=61-t>>>8&-13,e+=62-t>>>8&49,String.fromCharCode(e)},e.prototype._decodeChar=function(t){var e=256;return e+=(44-t&t-46)>>>8&-256+t-45+62,e+=(94-t&t-96)>>>8&-256+t-95+63,e+=(47-t&t-58)>>>8&-256+t-48+52,e+=(64-t&t-91)>>>8&-256+t-65+0,e+=(96-t&t-123)>>>8&-256+t-97+26},e}(s);e.URLSafeCoder=a;var h=new a;e.encodeURLSafe=function(t){return h.encode(t)},e.decodeURLSafe=function(t){return h.decode(t)},e.encodedLength=function(t){return o.encodedLength(t)},e.maxDecodedLength=function(t){return o.maxDecodedLength(t)},e.decodedLength=function(t){return o.decodedLength(t)}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r="utf8: invalid source encoding";function i(t){for(var e=0,n=0;n=t.length-1)throw new Error("utf8: invalid string");n++,e+=4}}return e}e.encode=function(t){for(var e=new Uint8Array(i(t)),n=0,r=0;r>6,e[n++]=128|63&s):s<55296?(e[n++]=224|s>>12,e[n++]=128|s>>6&63,e[n++]=128|63&s):(r++,s=(1023&s)<<10,s|=1023&t.charCodeAt(r),s+=65536,e[n++]=240|s>>18,e[n++]=128|s>>12&63,e[n++]=128|s>>6&63,e[n++]=128|63&s)}return e},e.encodedLength=i,e.decode=function(t){for(var e=[],n=0;n=t.length)throw new Error(r);if(128!=(192&(o=t[++n])))throw new Error(r);i=(31&i)<<6|63&o,s=128}else if(i<240){if(n>=t.length-1)throw new Error(r);var o=t[++n],a=t[++n];if(128!=(192&o)||128!=(192&a))throw new Error(r);i=(15&i)<<12|(63&o)<<6|63&a,s=2048}else{if(!(i<248))throw new Error(r);if(n>=t.length-2)throw new Error(r);o=t[++n],a=t[++n];var h=t[++n];if(128!=(192&o)||128!=(192&a)||128!=(192&h))throw new Error(r);i=(15&i)<<18|(63&o)<<12|(63&a)<<6|63&h,s=65536}if(i=55296&&i<=57343)throw new Error(r);if(i>=65536){if(i>1114111)throw new Error(r);i-=65536,e.push(String.fromCharCode(55296|i>>10)),i=56320|1023&i}}e.push(String.fromCharCode(i))}return e.join("")}},function(t,e,n){!function(t){"use strict";var e=function(t){var e,n=new Float64Array(16);if(t)for(e=0;e>24&255,t[e+1]=n>>16&255,t[e+2]=n>>8&255,t[e+3]=255&n,t[e+4]=r>>24&255,t[e+5]=r>>16&255,t[e+6]=r>>8&255,t[e+7]=255&r}function g(t,e,n,r,i){var s,o=0;for(s=0;s>>8)-1}function b(t,e,n,r){return g(t,e,n,r,16)}function v(t,e,n,r){return g(t,e,n,r,32)}function y(t,e,n,r){!function(t,e,n,r){for(var i,s=255&r[0]|(255&r[1])<<8|(255&r[2])<<16|(255&r[3])<<24,o=255&n[0]|(255&n[1])<<8|(255&n[2])<<16|(255&n[3])<<24,a=255&n[4]|(255&n[5])<<8|(255&n[6])<<16|(255&n[7])<<24,h=255&n[8]|(255&n[9])<<8|(255&n[10])<<16|(255&n[11])<<24,c=255&n[12]|(255&n[13])<<8|(255&n[14])<<16|(255&n[15])<<24,u=255&r[4]|(255&r[5])<<8|(255&r[6])<<16|(255&r[7])<<24,l=255&e[0]|(255&e[1])<<8|(255&e[2])<<16|(255&e[3])<<24,d=255&e[4]|(255&e[5])<<8|(255&e[6])<<16|(255&e[7])<<24,p=255&e[8]|(255&e[9])<<8|(255&e[10])<<16|(255&e[11])<<24,f=255&e[12]|(255&e[13])<<8|(255&e[14])<<16|(255&e[15])<<24,g=255&r[8]|(255&r[9])<<8|(255&r[10])<<16|(255&r[11])<<24,b=255&n[16]|(255&n[17])<<8|(255&n[18])<<16|(255&n[19])<<24,v=255&n[20]|(255&n[21])<<8|(255&n[22])<<16|(255&n[23])<<24,y=255&n[24]|(255&n[25])<<8|(255&n[26])<<16|(255&n[27])<<24,m=255&n[28]|(255&n[29])<<8|(255&n[30])<<16|(255&n[31])<<24,w=255&r[12]|(255&r[13])<<8|(255&r[14])<<16|(255&r[15])<<24,_=s,S=o,k=a,C=h,T=c,P=u,A=l,E=d,x=p,O=f,L=g,U=b,R=v,M=y,I=m,N=w,D=0;D<20;D+=2)_^=(i=(R^=(i=(x^=(i=(T^=(i=_+R|0)<<7|i>>>25)+_|0)<<9|i>>>23)+T|0)<<13|i>>>19)+x|0)<<18|i>>>14,P^=(i=(S^=(i=(M^=(i=(O^=(i=P+S|0)<<7|i>>>25)+P|0)<<9|i>>>23)+O|0)<<13|i>>>19)+M|0)<<18|i>>>14,L^=(i=(A^=(i=(k^=(i=(I^=(i=L+A|0)<<7|i>>>25)+L|0)<<9|i>>>23)+I|0)<<13|i>>>19)+k|0)<<18|i>>>14,N^=(i=(U^=(i=(E^=(i=(C^=(i=N+U|0)<<7|i>>>25)+N|0)<<9|i>>>23)+C|0)<<13|i>>>19)+E|0)<<18|i>>>14,_^=(i=(C^=(i=(k^=(i=(S^=(i=_+C|0)<<7|i>>>25)+_|0)<<9|i>>>23)+S|0)<<13|i>>>19)+k|0)<<18|i>>>14,P^=(i=(T^=(i=(E^=(i=(A^=(i=P+T|0)<<7|i>>>25)+P|0)<<9|i>>>23)+A|0)<<13|i>>>19)+E|0)<<18|i>>>14,L^=(i=(O^=(i=(x^=(i=(U^=(i=L+O|0)<<7|i>>>25)+L|0)<<9|i>>>23)+U|0)<<13|i>>>19)+x|0)<<18|i>>>14,N^=(i=(I^=(i=(M^=(i=(R^=(i=N+I|0)<<7|i>>>25)+N|0)<<9|i>>>23)+R|0)<<13|i>>>19)+M|0)<<18|i>>>14;_=_+s|0,S=S+o|0,k=k+a|0,C=C+h|0,T=T+c|0,P=P+u|0,A=A+l|0,E=E+d|0,x=x+p|0,O=O+f|0,L=L+g|0,U=U+b|0,R=R+v|0,M=M+y|0,I=I+m|0,N=N+w|0,t[0]=_>>>0&255,t[1]=_>>>8&255,t[2]=_>>>16&255,t[3]=_>>>24&255,t[4]=S>>>0&255,t[5]=S>>>8&255,t[6]=S>>>16&255,t[7]=S>>>24&255,t[8]=k>>>0&255,t[9]=k>>>8&255,t[10]=k>>>16&255,t[11]=k>>>24&255,t[12]=C>>>0&255,t[13]=C>>>8&255,t[14]=C>>>16&255,t[15]=C>>>24&255,t[16]=T>>>0&255,t[17]=T>>>8&255,t[18]=T>>>16&255,t[19]=T>>>24&255,t[20]=P>>>0&255,t[21]=P>>>8&255,t[22]=P>>>16&255,t[23]=P>>>24&255,t[24]=A>>>0&255,t[25]=A>>>8&255,t[26]=A>>>16&255,t[27]=A>>>24&255,t[28]=E>>>0&255,t[29]=E>>>8&255,t[30]=E>>>16&255,t[31]=E>>>24&255,t[32]=x>>>0&255,t[33]=x>>>8&255,t[34]=x>>>16&255,t[35]=x>>>24&255,t[36]=O>>>0&255,t[37]=O>>>8&255,t[38]=O>>>16&255,t[39]=O>>>24&255,t[40]=L>>>0&255,t[41]=L>>>8&255,t[42]=L>>>16&255,t[43]=L>>>24&255,t[44]=U>>>0&255,t[45]=U>>>8&255,t[46]=U>>>16&255,t[47]=U>>>24&255,t[48]=R>>>0&255,t[49]=R>>>8&255,t[50]=R>>>16&255,t[51]=R>>>24&255,t[52]=M>>>0&255,t[53]=M>>>8&255,t[54]=M>>>16&255,t[55]=M>>>24&255,t[56]=I>>>0&255,t[57]=I>>>8&255,t[58]=I>>>16&255,t[59]=I>>>24&255,t[60]=N>>>0&255,t[61]=N>>>8&255,t[62]=N>>>16&255,t[63]=N>>>24&255}(t,e,n,r)}function m(t,e,n,r){!function(t,e,n,r){for(var i,s=255&r[0]|(255&r[1])<<8|(255&r[2])<<16|(255&r[3])<<24,o=255&n[0]|(255&n[1])<<8|(255&n[2])<<16|(255&n[3])<<24,a=255&n[4]|(255&n[5])<<8|(255&n[6])<<16|(255&n[7])<<24,h=255&n[8]|(255&n[9])<<8|(255&n[10])<<16|(255&n[11])<<24,c=255&n[12]|(255&n[13])<<8|(255&n[14])<<16|(255&n[15])<<24,u=255&r[4]|(255&r[5])<<8|(255&r[6])<<16|(255&r[7])<<24,l=255&e[0]|(255&e[1])<<8|(255&e[2])<<16|(255&e[3])<<24,d=255&e[4]|(255&e[5])<<8|(255&e[6])<<16|(255&e[7])<<24,p=255&e[8]|(255&e[9])<<8|(255&e[10])<<16|(255&e[11])<<24,f=255&e[12]|(255&e[13])<<8|(255&e[14])<<16|(255&e[15])<<24,g=255&r[8]|(255&r[9])<<8|(255&r[10])<<16|(255&r[11])<<24,b=255&n[16]|(255&n[17])<<8|(255&n[18])<<16|(255&n[19])<<24,v=255&n[20]|(255&n[21])<<8|(255&n[22])<<16|(255&n[23])<<24,y=255&n[24]|(255&n[25])<<8|(255&n[26])<<16|(255&n[27])<<24,m=255&n[28]|(255&n[29])<<8|(255&n[30])<<16|(255&n[31])<<24,w=255&r[12]|(255&r[13])<<8|(255&r[14])<<16|(255&r[15])<<24,_=0;_<20;_+=2)s^=(i=(v^=(i=(p^=(i=(c^=(i=s+v|0)<<7|i>>>25)+s|0)<<9|i>>>23)+c|0)<<13|i>>>19)+p|0)<<18|i>>>14,u^=(i=(o^=(i=(y^=(i=(f^=(i=u+o|0)<<7|i>>>25)+u|0)<<9|i>>>23)+f|0)<<13|i>>>19)+y|0)<<18|i>>>14,g^=(i=(l^=(i=(a^=(i=(m^=(i=g+l|0)<<7|i>>>25)+g|0)<<9|i>>>23)+m|0)<<13|i>>>19)+a|0)<<18|i>>>14,w^=(i=(b^=(i=(d^=(i=(h^=(i=w+b|0)<<7|i>>>25)+w|0)<<9|i>>>23)+h|0)<<13|i>>>19)+d|0)<<18|i>>>14,s^=(i=(h^=(i=(a^=(i=(o^=(i=s+h|0)<<7|i>>>25)+s|0)<<9|i>>>23)+o|0)<<13|i>>>19)+a|0)<<18|i>>>14,u^=(i=(c^=(i=(d^=(i=(l^=(i=u+c|0)<<7|i>>>25)+u|0)<<9|i>>>23)+l|0)<<13|i>>>19)+d|0)<<18|i>>>14,g^=(i=(f^=(i=(p^=(i=(b^=(i=g+f|0)<<7|i>>>25)+g|0)<<9|i>>>23)+b|0)<<13|i>>>19)+p|0)<<18|i>>>14,w^=(i=(m^=(i=(y^=(i=(v^=(i=w+m|0)<<7|i>>>25)+w|0)<<9|i>>>23)+v|0)<<13|i>>>19)+y|0)<<18|i>>>14;t[0]=s>>>0&255,t[1]=s>>>8&255,t[2]=s>>>16&255,t[3]=s>>>24&255,t[4]=u>>>0&255,t[5]=u>>>8&255,t[6]=u>>>16&255,t[7]=u>>>24&255,t[8]=g>>>0&255,t[9]=g>>>8&255,t[10]=g>>>16&255,t[11]=g>>>24&255,t[12]=w>>>0&255,t[13]=w>>>8&255,t[14]=w>>>16&255,t[15]=w>>>24&255,t[16]=l>>>0&255,t[17]=l>>>8&255,t[18]=l>>>16&255,t[19]=l>>>24&255,t[20]=d>>>0&255,t[21]=d>>>8&255,t[22]=d>>>16&255,t[23]=d>>>24&255,t[24]=p>>>0&255,t[25]=p>>>8&255,t[26]=p>>>16&255,t[27]=p>>>24&255,t[28]=f>>>0&255,t[29]=f>>>8&255,t[30]=f>>>16&255,t[31]=f>>>24&255}(t,e,n,r)}var w=new Uint8Array([101,120,112,97,110,100,32,51,50,45,98,121,116,101,32,107]);function _(t,e,n,r,i,s,o){var a,h,c=new Uint8Array(16),u=new Uint8Array(64);for(h=0;h<16;h++)c[h]=0;for(h=0;h<8;h++)c[h]=s[h];for(;i>=64;){for(y(u,c,o,w),h=0;h<64;h++)t[e+h]=n[r+h]^u[h];for(a=1,h=8;h<16;h++)a=a+(255&c[h])|0,c[h]=255&a,a>>>=8;i-=64,e+=64,r+=64}if(i>0)for(y(u,c,o,w),h=0;h=64;){for(y(h,a,i,w),o=0;o<64;o++)t[e+o]=h[o];for(s=1,o=8;o<16;o++)s=s+(255&a[o])|0,a[o]=255&s,s>>>=8;n-=64,e+=64}if(n>0)for(y(h,a,i,w),o=0;o>>13|n<<3),r=255&t[4]|(255&t[5])<<8,this.r[2]=7939&(n>>>10|r<<6),i=255&t[6]|(255&t[7])<<8,this.r[3]=8191&(r>>>7|i<<9),s=255&t[8]|(255&t[9])<<8,this.r[4]=255&(i>>>4|s<<12),this.r[5]=s>>>1&8190,o=255&t[10]|(255&t[11])<<8,this.r[6]=8191&(s>>>14|o<<2),a=255&t[12]|(255&t[13])<<8,this.r[7]=8065&(o>>>11|a<<5),h=255&t[14]|(255&t[15])<<8,this.r[8]=8191&(a>>>8|h<<8),this.r[9]=h>>>5&127,this.pad[0]=255&t[16]|(255&t[17])<<8,this.pad[1]=255&t[18]|(255&t[19])<<8,this.pad[2]=255&t[20]|(255&t[21])<<8,this.pad[3]=255&t[22]|(255&t[23])<<8,this.pad[4]=255&t[24]|(255&t[25])<<8,this.pad[5]=255&t[26]|(255&t[27])<<8,this.pad[6]=255&t[28]|(255&t[29])<<8,this.pad[7]=255&t[30]|(255&t[31])<<8};function P(t,e,n,r,i,s){var o=new T(s);return o.update(n,r,i),o.finish(t,e),0}function A(t,e,n,r,i,s){var o=new Uint8Array(16);return P(o,0,n,r,i,s),b(t,e,o,0)}function E(t,e,n,r,i){var s;if(n<32)return-1;for(C(t,0,e,0,n,r,i),P(t,16,t,32,n-32,t),s=0;s<16;s++)t[s]=0;return 0}function x(t,e,n,r,i){var s,o=new Uint8Array(32);if(n<32)return-1;if(k(o,0,32,r,i),0!==A(e,16,e,32,n-32,o))return-1;for(C(t,0,e,0,n,r,i),s=0;s<32;s++)t[s]=0;return 0}function O(t,e){var n;for(n=0;n<16;n++)t[n]=0|e[n]}function L(t){var e,n,r=1;for(e=0;e<16;e++)n=t[e]+r+65535,r=Math.floor(n/65536),t[e]=n-65536*r;t[0]+=r-1+37*(r-1)}function U(t,e,n){for(var r,i=~(n-1),s=0;s<16;s++)r=i&(t[s]^e[s]),t[s]^=r,e[s]^=r}function R(t,n){var r,i,s,o=e(),a=e();for(r=0;r<16;r++)a[r]=n[r];for(L(a),L(a),L(a),i=0;i<2;i++){for(o[0]=a[0]-65517,r=1;r<15;r++)o[r]=a[r]-65535-(o[r-1]>>16&1),o[r-1]&=65535;o[15]=a[15]-32767-(o[14]>>16&1),s=o[15]>>16&1,o[14]&=65535,U(a,o,1-s)}for(r=0;r<16;r++)t[2*r]=255&a[r],t[2*r+1]=a[r]>>8}function M(t,e){var n=new Uint8Array(32),r=new Uint8Array(32);return R(n,t),R(r,e),v(n,0,r,0)}function I(t){var e=new Uint8Array(32);return R(e,t),1&e[0]}function N(t,e){var n;for(n=0;n<16;n++)t[n]=e[2*n]+(e[2*n+1]<<8);t[15]&=32767}function D(t,e,n){for(var r=0;r<16;r++)t[r]=e[r]+n[r]}function j(t,e,n){for(var r=0;r<16;r++)t[r]=e[r]-n[r]}function z(t,e,n){var r,i,s=0,o=0,a=0,h=0,c=0,u=0,l=0,d=0,p=0,f=0,g=0,b=0,v=0,y=0,m=0,w=0,_=0,S=0,k=0,C=0,T=0,P=0,A=0,E=0,x=0,O=0,L=0,U=0,R=0,M=0,I=0,N=n[0],D=n[1],j=n[2],z=n[3],H=n[4],B=n[5],F=n[6],q=n[7],Y=n[8],K=n[9],$=n[10],J=n[11],W=n[12],X=n[13],G=n[14],V=n[15];s+=(r=e[0])*N,o+=r*D,a+=r*j,h+=r*z,c+=r*H,u+=r*B,l+=r*F,d+=r*q,p+=r*Y,f+=r*K,g+=r*$,b+=r*J,v+=r*W,y+=r*X,m+=r*G,w+=r*V,o+=(r=e[1])*N,a+=r*D,h+=r*j,c+=r*z,u+=r*H,l+=r*B,d+=r*F,p+=r*q,f+=r*Y,g+=r*K,b+=r*$,v+=r*J,y+=r*W,m+=r*X,w+=r*G,_+=r*V,a+=(r=e[2])*N,h+=r*D,c+=r*j,u+=r*z,l+=r*H,d+=r*B,p+=r*F,f+=r*q,g+=r*Y,b+=r*K,v+=r*$,y+=r*J,m+=r*W,w+=r*X,_+=r*G,S+=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y,T+=r*K,P+=r*$,A+=r*J,E+=r*W,x+=r*X,O+=r*G,L+=r*V,v+=(r=e[12])*N,y+=r*D,m+=r*j,w+=r*z,_+=r*H,S+=r*B,k+=r*F,C+=r*q,T+=r*Y,P+=r*K,A+=r*$,E+=r*J,x+=r*W,O+=r*X,L+=r*G,U+=r*V,y+=(r=e[13])*N,m+=r*D,w+=r*j,_+=r*z,S+=r*H,k+=r*B,C+=r*F,T+=r*q,P+=r*Y,A+=r*K,E+=r*$,x+=r*J,O+=r*W,L+=r*X,U+=r*G,R+=r*V,m+=(r=e[14])*N,w+=r*D,_+=r*j,S+=r*z,k+=r*H,C+=r*B,T+=r*F,P+=r*q,A+=r*Y,E+=r*K,x+=r*$,O+=r*J,L+=r*W,U+=r*X,R+=r*G,M+=r*V,w+=(r=e[15])*N,o+=38*(S+=r*j),a+=38*(k+=r*z),h+=38*(C+=r*H),c+=38*(T+=r*B),u+=38*(P+=r*F),l+=38*(A+=r*q),d+=38*(E+=r*Y),p+=38*(x+=r*K),f+=38*(O+=r*$),g+=38*(L+=r*J),b+=38*(U+=r*W),v+=38*(R+=r*X),y+=38*(M+=r*G),m+=38*(I+=r*V),s=(r=(s+=38*(_+=r*D))+(i=1)+65535)-65536*(i=Math.floor(r/65536)),o=(r=o+i+65535)-65536*(i=Math.floor(r/65536)),a=(r=a+i+65535)-65536*(i=Math.floor(r/65536)),h=(r=h+i+65535)-65536*(i=Math.floor(r/65536)),c=(r=c+i+65535)-65536*(i=Math.floor(r/65536)),u=(r=u+i+65535)-65536*(i=Math.floor(r/65536)),l=(r=l+i+65535)-65536*(i=Math.floor(r/65536)),d=(r=d+i+65535)-65536*(i=Math.floor(r/65536)),p=(r=p+i+65535)-65536*(i=Math.floor(r/65536)),f=(r=f+i+65535)-65536*(i=Math.floor(r/65536)),g=(r=g+i+65535)-65536*(i=Math.floor(r/65536)),b=(r=b+i+65535)-65536*(i=Math.floor(r/65536)),v=(r=v+i+65535)-65536*(i=Math.floor(r/65536)),y=(r=y+i+65535)-65536*(i=Math.floor(r/65536)),m=(r=m+i+65535)-65536*(i=Math.floor(r/65536)),w=(r=w+i+65535)-65536*(i=Math.floor(r/65536)),s=(r=(s+=i-1+37*(i-1))+(i=1)+65535)-65536*(i=Math.floor(r/65536)),o=(r=o+i+65535)-65536*(i=Math.floor(r/65536)),a=(r=a+i+65535)-65536*(i=Math.floor(r/65536)),h=(r=h+i+65535)-65536*(i=Math.floor(r/65536)),c=(r=c+i+65535)-65536*(i=Math.floor(r/65536)),u=(r=u+i+65535)-65536*(i=Math.floor(r/65536)),l=(r=l+i+65535)-65536*(i=Math.floor(r/65536)),d=(r=d+i+65535)-65536*(i=Math.floor(r/65536)),p=(r=p+i+65535)-65536*(i=Math.floor(r/65536)),f=(r=f+i+65535)-65536*(i=Math.floor(r/65536)),g=(r=g+i+65535)-65536*(i=Math.floor(r/65536)),b=(r=b+i+65535)-65536*(i=Math.floor(r/65536)),v=(r=v+i+65535)-65536*(i=Math.floor(r/65536)),y=(r=y+i+65535)-65536*(i=Math.floor(r/65536)),m=(r=m+i+65535)-65536*(i=Math.floor(r/65536)),w=(r=w+i+65535)-65536*(i=Math.floor(r/65536)),s+=i-1+37*(i-1),t[0]=s,t[1]=o,t[2]=a,t[3]=h,t[4]=c,t[5]=u,t[6]=l,t[7]=d,t[8]=p,t[9]=f,t[10]=g,t[11]=b,t[12]=v,t[13]=y,t[14]=m,t[15]=w}function H(t,e){z(t,e,e)}function B(t,n){var r,i=e();for(r=0;r<16;r++)i[r]=n[r];for(r=253;r>=0;r--)H(i,i),2!==r&&4!==r&&z(i,i,n);for(r=0;r<16;r++)t[r]=i[r]}function F(t,n){var r,i=e();for(r=0;r<16;r++)i[r]=n[r];for(r=250;r>=0;r--)H(i,i),1!==r&&z(i,i,n);for(r=0;r<16;r++)t[r]=i[r]}function q(t,n,r){var i,s,o=new Uint8Array(32),a=new Float64Array(80),c=e(),u=e(),l=e(),d=e(),p=e(),f=e();for(s=0;s<31;s++)o[s]=n[s];for(o[31]=127&n[31]|64,o[0]&=248,N(a,r),s=0;s<16;s++)u[s]=a[s],d[s]=c[s]=l[s]=0;for(c[0]=d[0]=1,s=254;s>=0;--s)U(c,u,i=o[s>>>3]>>>(7&s)&1),U(l,d,i),D(p,c,l),j(c,c,l),D(l,u,d),j(u,u,d),H(d,p),H(f,c),z(c,l,c),z(l,u,p),D(p,c,l),j(c,c,l),H(u,c),j(l,d,f),z(c,l,h),D(c,c,d),z(l,l,c),z(c,d,f),z(d,u,a),H(u,p),U(c,u,i),U(l,d,i);for(s=0;s<16;s++)a[s+16]=c[s],a[s+32]=l[s],a[s+48]=u[s],a[s+64]=d[s];var g=a.subarray(32),b=a.subarray(16);return B(g,g),z(b,b,g),R(t,b),0}function Y(t,e){return q(t,e,s)}function K(t,e){return r(e,32),Y(t,e)}function $(t,e,n){var r=new Uint8Array(32);return q(r,n,e),m(t,i,r,w)}T.prototype.blocks=function(t,e,n){for(var r,i,s,o,a,h,c,u,l,d,p,f,g,b,v,y,m,w,_,S=this.fin?0:2048,k=this.h[0],C=this.h[1],T=this.h[2],P=this.h[3],A=this.h[4],E=this.h[5],x=this.h[6],O=this.h[7],L=this.h[8],U=this.h[9],R=this.r[0],M=this.r[1],I=this.r[2],N=this.r[3],D=this.r[4],j=this.r[5],z=this.r[6],H=this.r[7],B=this.r[8],F=this.r[9];n>=16;)d=l=0,d+=(k+=8191&(r=255&t[e+0]|(255&t[e+1])<<8))*R,d+=(C+=8191&(r>>>13|(i=255&t[e+2]|(255&t[e+3])<<8)<<3))*(5*F),d+=(T+=8191&(i>>>10|(s=255&t[e+4]|(255&t[e+5])<<8)<<6))*(5*B),d+=(P+=8191&(s>>>7|(o=255&t[e+6]|(255&t[e+7])<<8)<<9))*(5*H),l=(d+=(A+=8191&(o>>>4|(a=255&t[e+8]|(255&t[e+9])<<8)<<12))*(5*z))>>>13,d&=8191,d+=(E+=a>>>1&8191)*(5*j),d+=(x+=8191&(a>>>14|(h=255&t[e+10]|(255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5*F))>>>13,_+=k*F,_+=C*B,_+=T*H,_+=P*z,l=(_+=A*j)>>>13,_&=8191,_+=E*D,_+=x*N,_+=O*I,_+=L*M,k=d=8191&(l=(l=((l+=(_+=U*R)>>>13)<<2)+l|0)+(d&=8191)|0),C=p+=l>>>=13,T=f&=8191,P=g&=8191,A=b&=8191,E=v&=8191,x=y&=8191,O=m&=8191,L=w&=8191,U=_&=8191,e+=16,n-=16;this.h[0]=k,this.h[1]=C,this.h[2]=T,this.h[3]=P,this.h[4]=A,this.h[5]=E,this.h[6]=x,this.h[7]=O,this.h[8]=L,this.h[9]=U},T.prototype.finish=function(t,e){var n,r,i,s,o=new Uint16Array(10);if(this.leftover){for(s=this.leftover,this.buffer[s++]=1;s<16;s++)this.buffer[s]=0;this.fin=1,this.blocks(this.buffer,0,16)}for(n=this.h[1]>>>13,this.h[1]&=8191,s=2;s<10;s++)this.h[s]+=n,n=this.h[s]>>>13,this.h[s]&=8191;for(this.h[0]+=5*n,n=this.h[0]>>>13,this.h[0]&=8191,this.h[1]+=n,n=this.h[1]>>>13,this.h[1]&=8191,this.h[2]+=n,o[0]=this.h[0]+5,n=o[0]>>>13,o[0]&=8191,s=1;s<10;s++)o[s]=this.h[s]+n,n=o[s]>>>13,o[s]&=8191;for(o[9]-=8192,r=(1^n)-1,s=0;s<10;s++)o[s]&=r;for(r=~r,s=0;s<10;s++)this.h[s]=this.h[s]&r|o[s];for(this.h[0]=65535&(this.h[0]|this.h[1]<<13),this.h[1]=65535&(this.h[1]>>>3|this.h[2]<<10),this.h[2]=65535&(this.h[2]>>>6|this.h[3]<<7),this.h[3]=65535&(this.h[3]>>>9|this.h[4]<<4),this.h[4]=65535&(this.h[4]>>>12|this.h[5]<<1|this.h[6]<<14),this.h[5]=65535&(this.h[6]>>>2|this.h[7]<<11),this.h[6]=65535&(this.h[7]>>>5|this.h[8]<<8),this.h[7]=65535&(this.h[8]>>>8|this.h[9]<<5),i=this.h[0]+this.pad[0],this.h[0]=65535&i,s=1;s<8;s++)i=(this.h[s]+this.pad[s]|0)+(i>>>16)|0,this.h[s]=65535&i;t[e+0]=this.h[0]>>>0&255,t[e+1]=this.h[0]>>>8&255,t[e+2]=this.h[1]>>>0&255,t[e+3]=this.h[1]>>>8&255,t[e+4]=this.h[2]>>>0&255,t[e+5]=this.h[2]>>>8&255,t[e+6]=this.h[3]>>>0&255,t[e+7]=this.h[3]>>>8&255,t[e+8]=this.h[4]>>>0&255,t[e+9]=this.h[4]>>>8&255,t[e+10]=this.h[5]>>>0&255,t[e+11]=this.h[5]>>>8&255,t[e+12]=this.h[6]>>>0&255,t[e+13]=this.h[6]>>>8&255,t[e+14]=this.h[7]>>>0&255,t[e+15]=this.h[7]>>>8&255},T.prototype.update=function(t,e,n){var r,i;if(this.leftover){for((i=16-this.leftover)>n&&(i=n),r=0;r=16&&(i=n-n%16,this.blocks(t,e,i),e+=i,n-=i),n){for(r=0;r=128;){for(S=0;S<16;S++)k=8*S+W,O[S]=n[k+0]<<24|n[k+1]<<16|n[k+2]<<8|n[k+3],L[S]=n[k+4]<<24|n[k+5]<<16|n[k+6]<<8|n[k+7];for(S=0;S<80;S++)if(i=U,s=R,o=M,a=I,h=N,c=D,u=j,z,d=H,p=B,f=F,g=q,b=Y,v=K,y=$,J,P=65535&(T=J),A=T>>>16,E=65535&(C=z),x=C>>>16,P+=65535&(T=(Y>>>14|N<<18)^(Y>>>18|N<<14)^(N>>>9|Y<<23)),A+=T>>>16,E+=65535&(C=(N>>>14|Y<<18)^(N>>>18|Y<<14)^(Y>>>9|N<<23)),x+=C>>>16,P+=65535&(T=Y&K^~Y&$),A+=T>>>16,E+=65535&(C=N&D^~N&j),x+=C>>>16,P+=65535&(T=X[2*S+1]),A+=T>>>16,E+=65535&(C=X[2*S]),x+=C>>>16,C=O[S%16],A+=(T=L[S%16])>>>16,E+=65535&C,x+=C>>>16,E+=(A+=(P+=65535&T)>>>16)>>>16,P=65535&(T=_=65535&P|A<<16),A=T>>>16,E=65535&(C=w=65535&E|(x+=E>>>16)<<16),x=C>>>16,P+=65535&(T=(H>>>28|U<<4)^(U>>>2|H<<30)^(U>>>7|H<<25)),A+=T>>>16,E+=65535&(C=(U>>>28|H<<4)^(H>>>2|U<<30)^(H>>>7|U<<25)),x+=C>>>16,A+=(T=H&B^H&F^B&F)>>>16,E+=65535&(C=U&R^U&M^R&M),x+=C>>>16,l=65535&(E+=(A+=(P+=65535&T)>>>16)>>>16)|(x+=E>>>16)<<16,m=65535&P|A<<16,P=65535&(T=g),A=T>>>16,E=65535&(C=a),x=C>>>16,A+=(T=_)>>>16,E+=65535&(C=w),x+=C>>>16,R=i,M=s,I=o,N=a=65535&(E+=(A+=(P+=65535&T)>>>16)>>>16)|(x+=E>>>16)<<16,D=h,j=c,z=u,U=l,B=d,F=p,q=f,Y=g=65535&P|A<<16,K=b,$=v,J=y,H=m,S%16==15)for(k=0;k<16;k++)C=O[k],P=65535&(T=L[k]),A=T>>>16,E=65535&C,x=C>>>16,C=O[(k+9)%16],P+=65535&(T=L[(k+9)%16]),A+=T>>>16,E+=65535&C,x+=C>>>16,w=O[(k+1)%16],P+=65535&(T=((_=L[(k+1)%16])>>>1|w<<31)^(_>>>8|w<<24)^(_>>>7|w<<25)),A+=T>>>16,E+=65535&(C=(w>>>1|_<<31)^(w>>>8|_<<24)^w>>>7),x+=C>>>16,w=O[(k+14)%16],A+=(T=((_=L[(k+14)%16])>>>19|w<<13)^(w>>>29|_<<3)^(_>>>6|w<<26))>>>16,E+=65535&(C=(w>>>19|_<<13)^(_>>>29|w<<3)^w>>>6),x+=C>>>16,x+=(E+=(A+=(P+=65535&T)>>>16)>>>16)>>>16,O[k]=65535&E|x<<16,L[k]=65535&P|A<<16;P=65535&(T=H),A=T>>>16,E=65535&(C=U),x=C>>>16,C=t[0],A+=(T=e[0])>>>16,E+=65535&C,x+=C>>>16,x+=(E+=(A+=(P+=65535&T)>>>16)>>>16)>>>16,t[0]=U=65535&E|x<<16,e[0]=H=65535&P|A<<16,P=65535&(T=B),A=T>>>16,E=65535&(C=R),x=C>>>16,C=t[1],A+=(T=e[1])>>>16,E+=65535&C,x+=C>>>16,x+=(E+=(A+=(P+=65535&T)>>>16)>>>16)>>>16,t[1]=R=65535&E|x<<16,e[1]=B=65535&P|A<<16,P=65535&(T=F),A=T>>>16,E=65535&(C=M),x=C>>>16,C=t[2],A+=(T=e[2])>>>16,E+=65535&C,x+=C>>>16,x+=(E+=(A+=(P+=65535&T)>>>16)>>>16)>>>16,t[2]=M=65535&E|x<<16,e[2]=F=65535&P|A<<16,P=65535&(T=q),A=T>>>16,E=65535&(C=I),x=C>>>16,C=t[3],A+=(T=e[3])>>>16,E+=65535&C,x+=C>>>16,x+=(E+=(A+=(P+=65535&T)>>>16)>>>16)>>>16,t[3]=I=65535&E|x<<16,e[3]=q=65535&P|A<<16,P=65535&(T=Y),A=T>>>16,E=65535&(C=N),x=C>>>16,C=t[4],A+=(T=e[4])>>>16,E+=65535&C,x+=C>>>16,x+=(E+=(A+=(P+=65535&T)>>>16)>>>16)>>>16,t[4]=N=65535&E|x<<16,e[4]=Y=65535&P|A<<16,P=65535&(T=K),A=T>>>16,E=65535&(C=D),x=C>>>16,C=t[5],A+=(T=e[5])>>>16,E+=65535&C,x+=C>>>16,x+=(E+=(A+=(P+=65535&T)>>>16)>>>16)>>>16,t[5]=D=65535&E|x<<16,e[5]=K=65535&P|A<<16,P=65535&(T=$),A=T>>>16,E=65535&(C=j),x=C>>>16,C=t[6],A+=(T=e[6])>>>16,E+=65535&C,x+=C>>>16,x+=(E+=(A+=(P+=65535&T)>>>16)>>>16)>>>16,t[6]=j=65535&E|x<<16,e[6]=$=65535&P|A<<16,P=65535&(T=J),A=T>>>16,E=65535&(C=z),x=C>>>16,C=t[7],A+=(T=e[7])>>>16,E+=65535&C,x+=C>>>16,x+=(E+=(A+=(P+=65535&T)>>>16)>>>16)>>>16,t[7]=z=65535&E|x<<16,e[7]=J=65535&P|A<<16,W+=128,r-=128}return r}function V(t,e,n){var r,i=new Int32Array(8),s=new Int32Array(8),o=new Uint8Array(256),a=n;for(i[0]=1779033703,i[1]=3144134277,i[2]=1013904242,i[3]=2773480762,i[4]=1359893119,i[5]=2600822924,i[6]=528734635,i[7]=1541459225,s[0]=4089235720,s[1]=2227873595,s[2]=4271175723,s[3]=1595750129,s[4]=2917565137,s[5]=725511199,s[6]=4215389547,s[7]=327033209,G(i,s,e,n),n%=128,r=0;r=0;--i)Q(t,e,r=n[i/8|0]>>(7&i)&1),Z(e,t),Z(t,t),Q(t,e,r)}function nt(t,n){var r=[e(),e(),e(),e()];O(r[0],l),O(r[1],d),O(r[2],a),z(r[3],l,d),et(t,r,n)}function rt(t,n,i){var s,o=new Uint8Array(64),a=[e(),e(),e(),e()];for(i||r(n,32),V(o,n,32),o[0]&=248,o[31]&=127,o[31]|=64,nt(a,o),tt(t,a),s=0;s<32;s++)n[s+32]=t[s];return 0}var it=new Float64Array([237,211,245,92,26,99,18,88,214,156,247,162,222,249,222,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16]);function st(t,e){var n,r,i,s;for(r=63;r>=32;--r){for(n=0,i=r-32,s=r-12;i>4)*it[i],n=e[i]>>8,e[i]&=255;for(i=0;i<32;i++)e[i]-=n*it[i];for(r=0;r<32;r++)e[r+1]+=e[r]>>8,t[r]=255&e[r]}function ot(t){var e,n=new Float64Array(64);for(e=0;e<64;e++)n[e]=t[e];for(e=0;e<64;e++)t[e]=0;st(t,n)}function at(t,n,r,i){var s,o,a=new Uint8Array(64),h=new Uint8Array(64),c=new Uint8Array(64),u=new Float64Array(64),l=[e(),e(),e(),e()];V(a,i,32),a[0]&=248,a[31]&=127,a[31]|=64;var d=r+64;for(s=0;s>7&&j(t[0],o,t[0]),z(t[3],t[0],t[1]),0)}(d,i))return-1;for(s=0;s=0},t.sign.keyPair=function(){var t=new Uint8Array(32),e=new Uint8Array(64);return rt(t,e),{publicKey:t,secretKey:e}},t.sign.keyPair.fromSecretKey=function(t){if(ut(t),64!==t.length)throw new Error("bad secret key size");for(var e=new Uint8Array(32),n=0;n>>6)+r(128|63&e):r(224|e>>>12&15)+r(128|e>>>6&63)+r(128|63&e)},c=function(t){return t.replace(/[^\x00-\x7F]/g,h)},u=function(t){var e=[0,2,1][t.length%3],n=t.charCodeAt(0)<<16|(t.length>1?t.charCodeAt(1):0)<<8|(t.length>2?t.charCodeAt(2):0);return[i.charAt(n>>>18),i.charAt(n>>>12&63),e>=2?"=":i.charAt(n>>>6&63),e>=1?"=":i.charAt(63&n)].join("")},l=self.btoa||function(t){return t.replace(/[\s\S]{1,3}/g,u)};var d=class{constructor(t,e,n,r){this.clear=e,this.timer=t(()=>{this.timer&&(this.timer=r(this.timer))},n)}isRunning(){return null!==this.timer}ensureAborted(){this.timer&&(this.clear(this.timer),this.timer=null)}};function p(t){self.clearTimeout(t)}function f(t){self.clearInterval(t)}class g extends d{constructor(t,e){super(setTimeout,p,t,(function(t){return e(),null}))}}class b extends d{constructor(t,e){super(setInterval,f,t,(function(t){return e(),t}))}}var v={now:()=>Date.now?Date.now():(new Date).valueOf(),defer:t=>new g(0,t),method(t,...e){var n=Array.prototype.slice.call(arguments,1);return function(e){return e[t].apply(e,n.concat(arguments))}}};function y(t,...e){for(var n=0;ne!==t),this):(this.global_callbacks=[],this)}unbind_all(){return this.unbind(),this.unbind_global(),this}emit(t,e,n){for(var r=0;r0)for(r=0;r{self.console&&self.console.log&&self.console.log(t)}}debug(...t){this.log(this.globalLog,t)}warn(...t){this.log(this.globalLogWarn,t)}error(...t){this.log(this.globalLogError,t)}globalLogWarn(t){self.console&&self.console.warn?self.console.warn(t):this.globalLog(t)}globalLogError(t){self.console&&self.console.error?self.console.error(t):this.globalLogWarn(t)}log(t,...e){var n=m.apply(this,arguments);if(Oe.log)Oe.log(n);else if(Oe.logToConsole){t.bind(this)(n)}}};class H extends j{constructor(t,e,n,r,i){super(),this.initialize=ae.transportConnectionInitializer,this.hooks=t,this.name=e,this.priority=n,this.key=r,this.options=i,this.state="new",this.timeline=i.timeline,this.activityTimeout=i.activityTimeout,this.id=this.timeline.generateUniqueID()}handlesActivityChecks(){return Boolean(this.hooks.handlesActivityChecks)}supportsPing(){return Boolean(this.hooks.supportsPing)}connect(){if(this.socket||"initialized"!==this.state)return!1;var t=this.hooks.urls.getInitial(this.key,this.options);try{this.socket=this.hooks.getSocket(t,this.options)}catch(t){return v.defer(()=>{this.onError(t),this.changeState("closed")}),!1}return this.bindListeners(),z.debug("Connecting",{transport:this.name,url:t}),this.changeState("connecting"),!0}close(){return!!this.socket&&(this.socket.close(),!0)}send(t){return"open"===this.state&&(v.defer(()=>{this.socket&&this.socket.send(t)}),!0)}ping(){"open"===this.state&&this.supportsPing()&&this.socket.ping()}onOpen(){this.hooks.beforeOpen&&this.hooks.beforeOpen(this.socket,this.hooks.urls.getPath(this.key,this.options)),this.changeState("open"),this.socket.onopen=void 0}onError(t){this.emit("error",{type:"WebSocketError",error:t}),this.timeline.error(this.buildTimelineMessage({error:t.toString()}))}onClose(t){t?this.changeState("closed",{code:t.code,reason:t.reason,wasClean:t.wasClean}):this.changeState("closed"),this.unbindListeners(),this.socket=void 0}onMessage(t){this.emit("message",t)}onActivity(){this.emit("activity")}bindListeners(){this.socket.onopen=()=>{this.onOpen()},this.socket.onerror=t=>{this.onError(t)},this.socket.onclose=t=>{this.onClose(t)},this.socket.onmessage=t=>{this.onMessage(t)},this.supportsPing()&&(this.socket.onactivity=()=>{this.onActivity()})}unbindListeners(){this.socket&&(this.socket.onopen=void 0,this.socket.onerror=void 0,this.socket.onclose=void 0,this.socket.onmessage=void 0,this.supportsPing()&&(this.socket.onactivity=void 0))}changeState(t,e){this.state=t,this.timeline.info(this.buildTimelineMessage({state:t,params:e})),this.emit(t,e)}buildTimelineMessage(t){return y({cid:this.id},t)}}class B{constructor(t){this.hooks=t}isSupported(t){return this.hooks.isSupported(t)}createConnection(t,e,n,r){return new H(this.hooks,t,e,n,r)}}var F=new B({urls:M,handlesActivityChecks:!1,supportsPing:!1,isInitialized:function(){return Boolean(ae.getWebSocketAPI())},isSupported:function(){return Boolean(ae.getWebSocketAPI())},getSocket:function(t){return ae.createWebSocket(t)}}),q={urls:I,handlesActivityChecks:!1,supportsPing:!0,isInitialized:function(){return!0}},Y=y({getSocket:function(t){return ae.HTTPFactory.createStreamingSocket(t)}},q),K=y({getSocket:function(t){return ae.HTTPFactory.createPollingSocket(t)}},q),$={isSupported:function(){return ae.isXHRSupported()}},J={ws:F,xhr_streaming:new B(y({},Y,$)),xhr_polling:new B(y({},K,$))};class W{constructor(t,e,n){this.manager=t,this.transport=e,this.minPingDelay=n.minPingDelay,this.maxPingDelay=n.maxPingDelay,this.pingDelay=void 0}createConnection(t,e,n,r){r=y({},r,{activityTimeout:this.pingDelay});var i=this.transport.createConnection(t,e,n,r),s=null,o=function(){i.unbind("open",o),i.bind("closed",a),s=v.now()},a=t=>{if(i.unbind("closed",a),1002===t.code||1003===t.code)this.manager.reportDeath();else if(!t.wasClean&&s){var e=v.now()-s;e<2*this.maxPingDelay&&(this.manager.reportDeath(),this.pingDelay=Math.max(e/2,this.minPingDelay))}};return i.bind("open",o),i}isSupported(t){return this.manager.isAlive()&&this.transport.isSupported(t)}}const X={decodeMessage:function(t){try{var e=JSON.parse(t.data),n=e.data;if("string"==typeof n)try{n=JSON.parse(e.data)}catch(t){}var r={event:e.event,channel:e.channel,data:n};return e.user_id&&(r.user_id=e.user_id),r}catch(e){throw{type:"MessageParseError",error:e,data:t.data}}},encodeMessage:function(t){return JSON.stringify(t)},processHandshake:function(t){var e=X.decodeMessage(t);if("pusher:connection_established"===e.event){if(!e.data.activity_timeout)throw"No activity timeout specified in handshake";return{action:"connected",id:e.data.socket_id,activityTimeout:1e3*e.data.activity_timeout}}if("pusher:error"===e.event)return{action:this.getCloseAction(e.data),error:this.getCloseError(e.data)};throw"Invalid handshake"},getCloseAction:function(t){return t.code<4e3?t.code>=1002&&t.code<=1004?"backoff":null:4e3===t.code?"tls_only":t.code<4100?"refused":t.code<4200?"backoff":t.code<4300?"retry":"refused"},getCloseError:function(t){return 1e3!==t.code&&1001!==t.code?{type:"PusherError",data:{code:t.code,message:t.reason||t.message}}:null}};var G=X;class V extends j{constructor(t,e){super(),this.id=t,this.transport=e,this.activityTimeout=e.activityTimeout,this.bindListeners()}handlesActivityChecks(){return this.transport.handlesActivityChecks()}send(t){return this.transport.send(t)}send_event(t,e,n){var r={event:t,data:e};return n&&(r.channel=n),z.debug("Event sent",r),this.send(G.encodeMessage(r))}ping(){this.transport.supportsPing()?this.transport.ping():this.send_event("pusher:ping",{})}close(){this.transport.close()}bindListeners(){var t={message:t=>{var e;try{e=G.decodeMessage(t)}catch(e){this.emit("error",{type:"MessageParseError",error:e,data:t.data})}if(void 0!==e){switch(z.debug("Event recd",e),e.event){case"pusher:error":this.emit("error",{type:"PusherError",data:e.data});break;case"pusher:ping":this.emit("ping");break;case"pusher:pong":this.emit("pong")}this.emit("message",e)}},activity:()=>{this.emit("activity")},error:t=>{this.emit("error",t)},closed:t=>{e(),t&&t.code&&this.handleCloseEvent(t),this.transport=null,this.emit("closed")}},e=()=>{_(t,(t,e)=>{this.transport.unbind(e,t)})};_(t,(t,e)=>{this.transport.bind(e,t)})}handleCloseEvent(t){var e=G.getCloseAction(t),n=G.getCloseError(t);n&&this.emit("error",n),e&&this.emit(e,{action:e,error:n})}}class Z{constructor(t,e){this.transport=t,this.callback=e,this.bindListeners()}close(){this.unbindListeners(),this.transport.close()}bindListeners(){this.onMessage=t=>{var e;this.unbindListeners();try{e=G.processHandshake(t)}catch(t){return this.finish("error",{error:t}),void this.transport.close()}"connected"===e.action?this.finish("connected",{connection:new V(e.id,this.transport),activityTimeout:e.activityTimeout}):(this.finish(e.action,{error:e.error}),this.transport.close())},this.onClosed=t=>{this.unbindListeners();var e=G.getCloseAction(t)||"backoff",n=G.getCloseError(t);this.finish(e,{error:n})},this.transport.bind("message",this.onMessage),this.transport.bind("closed",this.onClosed)}unbindListeners(){this.transport.unbind("message",this.onMessage),this.transport.unbind("closed",this.onClosed)}finish(t,e){this.callback(y({transport:this.transport,action:t},e))}}class Q{constructor(t,e){this.timeline=t,this.options=e||{}}send(t,e){this.timeline.isEmpty()||this.timeline.send(ae.TimelineTransport.getAgent(this,t),e)}}class tt extends Error{constructor(t){super(t),Object.setPrototypeOf(this,new.target.prototype)}}class et extends Error{constructor(t){super(t),Object.setPrototypeOf(this,new.target.prototype)}}Error;class nt extends Error{constructor(t){super(t),Object.setPrototypeOf(this,new.target.prototype)}}class rt extends Error{constructor(t){super(t),Object.setPrototypeOf(this,new.target.prototype)}}class it extends Error{constructor(t){super(t),Object.setPrototypeOf(this,new.target.prototype)}}class st extends Error{constructor(t){super(t),Object.setPrototypeOf(this,new.target.prototype)}}class ot extends Error{constructor(t){super(t),Object.setPrototypeOf(this,new.target.prototype)}}class at extends Error{constructor(t,e){super(e),this.status=t,Object.setPrototypeOf(this,new.target.prototype)}}const ht={baseUrl:"https://pusher.com",urls:{authenticationEndpoint:{path:"/docs/channels/server_api/authenticating_users"},authorizationEndpoint:{path:"/docs/channels/server_api/authorizing-users/"},javascriptQuickStart:{path:"/docs/javascript_quick_start"},triggeringClientEvents:{path:"/docs/client_api_guide/client_events#trigger-events"},encryptedChannelSupport:{fullUrl:"https://github.com/pusher/pusher-js/tree/cc491015371a4bde5743d1c87a0fbac0feb53195#encrypted-channel-support"}}};var ct=function(t){const e=ht.urls[t];if(!e)return"";let n;return e.fullUrl?n=e.fullUrl:e.path&&(n=ht.baseUrl+e.path),n?"See: "+n:""};class ut extends j{constructor(t,e){super((function(e,n){z.debug("No callbacks on "+t+" for "+e)})),this.name=t,this.pusher=e,this.subscribed=!1,this.subscriptionPending=!1,this.subscriptionCancelled=!1}authorize(t,e){return e(null,{auth:""})}trigger(t,e){if(0!==t.indexOf("client-"))throw new tt("Event '"+t+"' does not start with 'client-'");if(!this.subscribed){var n=ct("triggeringClientEvents");z.warn("Client event triggered before channel 'subscription_succeeded' event . "+n)}return this.pusher.send_event(t,e,this.name)}disconnect(){this.subscribed=!1,this.subscriptionPending=!1}handleEvent(t){var e=t.event,n=t.data;if("pusher_internal:subscription_succeeded"===e)this.handleSubscriptionSucceededEvent(t);else if("pusher_internal:subscription_count"===e)this.handleSubscriptionCountEvent(t);else if(0!==e.indexOf("pusher_internal:")){this.emit(e,n,{})}}handleSubscriptionSucceededEvent(t){this.subscriptionPending=!1,this.subscribed=!0,this.subscriptionCancelled?this.pusher.unsubscribe(this.name):this.emit("pusher:subscription_succeeded",t.data)}handleSubscriptionCountEvent(t){t.data.subscription_count&&(this.subscriptionCount=t.data.subscription_count),this.emit("pusher:subscription_count",t.data)}subscribe(){this.subscribed||(this.subscriptionPending=!0,this.subscriptionCancelled=!1,this.authorize(this.pusher.connection.socket_id,(t,e)=>{t?(this.subscriptionPending=!1,z.error(t.toString()),this.emit("pusher:subscription_error",Object.assign({},{type:"AuthError",error:t.message},t instanceof at?{status:t.status}:{}))):this.pusher.send_event("pusher:subscribe",{auth:e.auth,channel_data:e.channel_data,channel:this.name})}))}unsubscribe(){this.subscribed=!1,this.pusher.send_event("pusher:unsubscribe",{channel:this.name})}cancelSubscription(){this.subscriptionCancelled=!0}reinstateSubscription(){this.subscriptionCancelled=!1}}class lt extends ut{authorize(t,e){return this.pusher.config.channelAuthorizer({channelName:this.name,socketId:t},e)}}class dt{constructor(){this.reset()}get(t){return Object.prototype.hasOwnProperty.call(this.members,t)?{id:t,info:this.members[t]}:null}each(t){_(this.members,(e,n)=>{t(this.get(n))})}setMyID(t){this.myID=t}onSubscription(t){this.members=t.presence.hash,this.count=t.presence.count,this.me=this.get(this.myID)}addMember(t){return null===this.get(t.user_id)&&this.count++,this.members[t.user_id]=t.user_info,this.get(t.user_id)}removeMember(t){var e=this.get(t.user_id);return e&&(delete this.members[t.user_id],this.count--),e}reset(){this.members={},this.count=0,this.myID=null,this.me=null}}var pt=function(t,e,n,r){return new(n||(n=Promise))((function(i,s){function o(t){try{h(r.next(t))}catch(t){s(t)}}function a(t){try{h(r.throw(t))}catch(t){s(t)}}function h(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(o,a)}h((r=r.apply(t,e||[])).next())}))};class ft extends lt{constructor(t,e){super(t,e),this.members=new dt}authorize(t,e){super.authorize(t,(t,n)=>pt(this,void 0,void 0,(function*(){if(!t)if(null!=(n=n).channel_data){var r=JSON.parse(n.channel_data);this.members.setMyID(r.user_id)}else{if(yield this.pusher.user.signinDonePromise,null==this.pusher.user.user_data){let t=ct("authorizationEndpoint");return z.error(`Invalid auth response for channel '${this.name}', expected 'channel_data' field. ${t}, or the user should be signed in.`),void e("Invalid auth response")}this.members.setMyID(this.pusher.user.user_data.id)}e(t,n)})))}handleEvent(t){var e=t.event;if(0===e.indexOf("pusher_internal:"))this.handleInternalEvent(t);else{var n=t.data,r={};t.user_id&&(r.user_id=t.user_id),this.emit(e,n,r)}}handleInternalEvent(t){var e=t.event,n=t.data;switch(e){case"pusher_internal:subscription_succeeded":this.handleSubscriptionSucceededEvent(t);break;case"pusher_internal:subscription_count":this.handleSubscriptionCountEvent(t);break;case"pusher_internal:member_added":var r=this.members.addMember(n);this.emit("pusher:member_added",r);break;case"pusher_internal:member_removed":var i=this.members.removeMember(n);i&&this.emit("pusher:member_removed",i)}}handleSubscriptionSucceededEvent(t){this.subscriptionPending=!1,this.subscribed=!0,this.subscriptionCancelled?this.pusher.unsubscribe(this.name):(this.members.onSubscription(t.data),this.emit("pusher:subscription_succeeded",this.members))}disconnect(){this.members.reset(),super.disconnect()}}var gt=n(1),bt=n(0);class vt extends lt{constructor(t,e,n){super(t,e),this.key=null,this.nacl=n}authorize(t,e){super.authorize(t,(t,n)=>{if(t)return void e(t,n);let r=n.shared_secret;r?(this.key=Object(bt.decode)(r),delete n.shared_secret,e(null,n)):e(new Error("No shared_secret key in auth payload for encrypted channel: "+this.name),null)})}trigger(t,e){throw new it("Client events are not currently supported for encrypted channels")}handleEvent(t){var e=t.event,n=t.data;0!==e.indexOf("pusher_internal:")&&0!==e.indexOf("pusher:")?this.handleEncryptedEvent(e,n):super.handleEvent(t)}handleEncryptedEvent(t,e){if(!this.key)return void z.debug("Received encrypted event before key has been retrieved from the authEndpoint");if(!e.ciphertext||!e.nonce)return void z.error("Unexpected format for encrypted event, expected object with `ciphertext` and `nonce` fields, got: "+e);let n=Object(bt.decode)(e.ciphertext);if(n.length{e?z.error(`Failed to make a request to the authEndpoint: ${s}. Unable to fetch new key, so dropping encrypted event`):(i=this.nacl.secretbox.open(n,r,this.key),null!==i?this.emit(t,this.getDataToEmit(i)):z.error("Failed to decrypt event with new key. Dropping encrypted event"))});this.emit(t,this.getDataToEmit(i))}getDataToEmit(t){let e=Object(gt.decode)(t);try{return JSON.parse(e)}catch(t){return e}}}class yt extends j{constructor(t,e){super(),this.state="initialized",this.connection=null,this.key=t,this.options=e,this.timeline=this.options.timeline,this.usingTLS=this.options.useTLS,this.errorCallbacks=this.buildErrorCallbacks(),this.connectionCallbacks=this.buildConnectionCallbacks(this.errorCallbacks),this.handshakeCallbacks=this.buildHandshakeCallbacks(this.errorCallbacks);var n=ae.getNetwork();n.bind("online",()=>{this.timeline.info({netinfo:"online"}),"connecting"!==this.state&&"unavailable"!==this.state||this.retryIn(0)}),n.bind("offline",()=>{this.timeline.info({netinfo:"offline"}),this.connection&&this.sendActivityCheck()}),this.updateStrategy()}switchCluster(t){this.key=t,this.updateStrategy(),this.retryIn(0)}connect(){this.connection||this.runner||(this.strategy.isSupported()?(this.updateState("connecting"),this.startConnecting(),this.setUnavailableTimer()):this.updateState("failed"))}send(t){return!!this.connection&&this.connection.send(t)}send_event(t,e,n){return!!this.connection&&this.connection.send_event(t,e,n)}disconnect(){this.disconnectInternally(),this.updateState("disconnected")}isUsingTLS(){return this.usingTLS}startConnecting(){var t=(e,n)=>{e?this.runner=this.strategy.connect(0,t):"error"===n.action?(this.emit("error",{type:"HandshakeError",error:n.error}),this.timeline.error({handshakeError:n.error})):(this.abortConnecting(),this.handshakeCallbacks[n.action](n))};this.runner=this.strategy.connect(0,t)}abortConnecting(){this.runner&&(this.runner.abort(),this.runner=null)}disconnectInternally(){(this.abortConnecting(),this.clearRetryTimer(),this.clearUnavailableTimer(),this.connection)&&this.abandonConnection().close()}updateStrategy(){this.strategy=this.options.getStrategy({key:this.key,timeline:this.timeline,useTLS:this.usingTLS})}retryIn(t){this.timeline.info({action:"retry",delay:t}),t>0&&this.emit("connecting_in",Math.round(t/1e3)),this.retryTimer=new g(t||0,()=>{this.disconnectInternally(),this.connect()})}clearRetryTimer(){this.retryTimer&&(this.retryTimer.ensureAborted(),this.retryTimer=null)}setUnavailableTimer(){this.unavailableTimer=new g(this.options.unavailableTimeout,()=>{this.updateState("unavailable")})}clearUnavailableTimer(){this.unavailableTimer&&this.unavailableTimer.ensureAborted()}sendActivityCheck(){this.stopActivityCheck(),this.connection.ping(),this.activityTimer=new g(this.options.pongTimeout,()=>{this.timeline.error({pong_timed_out:this.options.pongTimeout}),this.retryIn(0)})}resetActivityCheck(){this.stopActivityCheck(),this.connection&&!this.connection.handlesActivityChecks()&&(this.activityTimer=new g(this.activityTimeout,()=>{this.sendActivityCheck()}))}stopActivityCheck(){this.activityTimer&&this.activityTimer.ensureAborted()}buildConnectionCallbacks(t){return y({},t,{message:t=>{this.resetActivityCheck(),this.emit("message",t)},ping:()=>{this.send_event("pusher:pong",{})},activity:()=>{this.resetActivityCheck()},error:t=>{this.emit("error",t)},closed:()=>{this.abandonConnection(),this.shouldRetry()&&this.retryIn(1e3)}})}buildHandshakeCallbacks(t){return y({},t,{connected:t=>{this.activityTimeout=Math.min(this.options.activityTimeout,t.activityTimeout,t.connection.activityTimeout||1/0),this.clearUnavailableTimer(),this.setConnection(t.connection),this.socket_id=this.connection.id,this.updateState("connected",{socket_id:this.socket_id})}})}buildErrorCallbacks(){let t=t=>e=>{e.error&&this.emit("error",{type:"WebSocketError",error:e.error}),t(e)};return{tls_only:t(()=>{this.usingTLS=!0,this.updateStrategy(),this.retryIn(0)}),refused:t(()=>{this.disconnect()}),backoff:t(()=>{this.retryIn(1e3)}),retry:t(()=>{this.retryIn(0)})}}setConnection(t){for(var e in this.connection=t,this.connectionCallbacks)this.connection.bind(e,this.connectionCallbacks[e]);this.resetActivityCheck()}abandonConnection(){if(this.connection){for(var t in this.stopActivityCheck(),this.connectionCallbacks)this.connection.unbind(t,this.connectionCallbacks[t]);var e=this.connection;return this.connection=null,e}}updateState(t,e){var n=this.state;if(this.state=t,n!==t){var r=t;"connected"===r&&(r+=" with new socket ID "+e.socket_id),z.debug("State changed",n+" -> "+r),this.timeline.info({state:t,params:e}),this.emit("state_change",{previous:n,current:t}),this.emit(t,e)}}shouldRetry(){return"connecting"===this.state||"connected"===this.state}}class mt{constructor(){this.channels={}}add(t,e){return this.channels[t]||(this.channels[t]=function(t,e){if(0===t.indexOf("private-encrypted-")){if(e.config.nacl)return wt.createEncryptedChannel(t,e,e.config.nacl);let n="Tried to subscribe to a private-encrypted- channel but no nacl implementation available",r=ct("encryptedChannelSupport");throw new it(`${n}. ${r}`)}if(0===t.indexOf("private-"))return wt.createPrivateChannel(t,e);if(0===t.indexOf("presence-"))return wt.createPresenceChannel(t,e);if(0===t.indexOf("#"))throw new et('Cannot create a channel with name "'+t+'".');return wt.createChannel(t,e)}(t,e)),this.channels[t]}all(){return function(t){var e=[];return _(t,(function(t){e.push(t)})),e}(this.channels)}find(t){return this.channels[t]}remove(t){var e=this.channels[t];return delete this.channels[t],e}disconnect(){_(this.channels,(function(t){t.disconnect()}))}}var wt={createChannels:()=>new mt,createConnectionManager:(t,e)=>new yt(t,e),createChannel:(t,e)=>new ut(t,e),createPrivateChannel:(t,e)=>new lt(t,e),createPresenceChannel:(t,e)=>new ft(t,e),createEncryptedChannel:(t,e,n)=>new vt(t,e,n),createTimelineSender:(t,e)=>new Q(t,e),createHandshake:(t,e)=>new Z(t,e),createAssistantToTheTransportManager:(t,e,n)=>new W(t,e,n)};class _t{constructor(t){this.options=t||{},this.livesLeft=this.options.lives||1/0}getAssistant(t){return wt.createAssistantToTheTransportManager(this,t,{minPingDelay:this.options.minPingDelay,maxPingDelay:this.options.maxPingDelay})}isAlive(){return this.livesLeft>0}reportDeath(){this.livesLeft-=1}}class St{constructor(t,e){this.strategies=t,this.loop=Boolean(e.loop),this.failFast=Boolean(e.failFast),this.timeout=e.timeout,this.timeoutLimit=e.timeoutLimit}isSupported(){return A(this.strategies,v.method("isSupported"))}connect(t,e){var n=this.strategies,r=0,i=this.timeout,s=null,o=(a,h)=>{h?e(null,h):(r+=1,this.loop&&(r%=n.length),r0&&(i=new g(n.timeout,(function(){s.abort(),r(!0)}))),s=t.connect(e,(function(t,e){t&&i&&i.isRunning()&&!n.failFast||(i&&i.ensureAborted(),r(t,e))})),{abort:function(){i&&i.ensureAborted(),s.abort()},forceMinPriority:function(t){s.forceMinPriority(t)}}}}class kt{constructor(t){this.strategies=t}isSupported(){return A(this.strategies,v.method("isSupported"))}connect(t,e){return function(t,e,n){var r=C(t,(function(t,r,i,s){return t.connect(e,n(r,s))}));return{abort:function(){k(r,Ct)},forceMinPriority:function(t){k(r,(function(e){e.forceMinPriority(t)}))}}}(this.strategies,t,(function(t,n){return function(r,i){n[t].error=r,r?function(t){return function(t,e){for(var n=0;n=v.now()){var o=this.transports[r.transport];o&&(["ws","wss"].includes(r.transport)||i>3?(this.timeline.info({cached:!0,transport:r.transport,latency:r.latency}),s.push(new St([o],{timeout:2*r.latency+1e3,failFast:!0}))):i++)}var a=v.now(),h=s.pop().connect(t,(function r(o,c){o?(At(n),s.length>0?(a=v.now(),h=s.pop().connect(t,r)):e(o)):(!function(t,e,n,r){var i=ae.getLocalStorage();if(i)try{i[Pt(t)]=O({timestamp:v.now(),transport:e,latency:n,cacheSkipCount:r})}catch(t){}}(n,c.transport.name,v.now()-a,i),e(null,c))}));return{abort:function(){h.abort()},forceMinPriority:function(e){t=e,h&&h.forceMinPriority(e)}}}}function Pt(t){return"pusherTransport"+(t?"TLS":"NonTLS")}function At(t){var e=ae.getLocalStorage();if(e)try{delete e[Pt(t)]}catch(t){}}class Et{constructor(t,{delay:e}){this.strategy=t,this.options={delay:e}}isSupported(){return this.strategy.isSupported()}connect(t,e){var n,r=this.strategy,i=new g(this.options.delay,(function(){n=r.connect(t,e)}));return{abort:function(){i.ensureAborted(),n&&n.abort()},forceMinPriority:function(e){t=e,n&&n.forceMinPriority(e)}}}}class xt{constructor(t,e,n){this.test=t,this.trueBranch=e,this.falseBranch=n}isSupported(){return(this.test()?this.trueBranch:this.falseBranch).isSupported()}connect(t,e){return(this.test()?this.trueBranch:this.falseBranch).connect(t,e)}}class Ot{constructor(t){this.strategy=t}isSupported(){return this.strategy.isSupported()}connect(t,e){var n=this.strategy.connect(t,(function(t,r){r&&n.abort(),e(t,r)}));return n}}function Lt(t){return function(){return t.isSupported()}}var Ut=function(t,e,n){var r={};function i(e,i,s,o,a){var h=n(t,e,i,s,o,a);return r[e]=h,h}var s,o=Object.assign({},e,{hostNonTLS:t.wsHost+":"+t.wsPort,hostTLS:t.wsHost+":"+t.wssPort,httpPath:t.wsPath}),a=y({},o,{useTLS:!0}),h=Object.assign({},e,{hostNonTLS:t.httpHost+":"+t.httpPort,hostTLS:t.httpHost+":"+t.httpsPort,httpPath:t.httpPath}),c={loop:!0,timeout:15e3,timeoutLimit:6e4},u=new _t({minPingDelay:1e4,maxPingDelay:t.activityTimeout}),l=new _t({lives:2,minPingDelay:1e4,maxPingDelay:t.activityTimeout}),d=i("ws","ws",3,o,u),p=i("wss","ws",3,a,u),f=i("xhr_streaming","xhr_streaming",1,h,l),g=i("xhr_polling","xhr_polling",1,h),b=new St([d],c),v=new St([p],c),m=new St([f],c),w=new St([g],c),_=new St([new xt(Lt(m),new kt([m,new Et(w,{delay:4e3})]),w)],c);return s=e.useTLS?new kt([b,new Et(_,{delay:2e3})]):new kt([b,new Et(v,{delay:2e3}),new Et(_,{delay:5e3})]),new Tt(new Ot(new xt(Lt(d),s,_)),r,{ttl:18e5,timeline:e.timeline,useTLS:e.useTLS})};class Rt extends j{constructor(t,e,n){super(),this.hooks=t,this.method=e,this.url=n}start(t){this.position=0,this.xhr=this.hooks.getRequest(this),this.unloader=()=>{this.close()},ae.addUnloadListener(this.unloader),this.xhr.open(this.method,this.url,!0),this.xhr.setRequestHeader&&this.xhr.setRequestHeader("Content-Type","application/json"),this.xhr.send(t)}close(){this.unloader&&(ae.removeUnloadListener(this.unloader),this.unloader=null),this.xhr&&(this.hooks.abortRequest(this.xhr),this.xhr=null)}onChunk(t,e){for(;;){var n=this.advanceBuffer(e);if(!n)break;this.emit("chunk",{status:t,data:n})}this.isBufferTooLong(e)&&this.emit("buffer_too_long")}advanceBuffer(t){var e=t.slice(this.position),n=e.indexOf("\n");return-1!==n?(this.position+=n+1,e.slice(0,n)):null}isBufferTooLong(t){return this.position===t.length&&t.length>262144}}var Mt;!function(t){t[t.CONNECTING=0]="CONNECTING",t[t.OPEN=1]="OPEN",t[t.CLOSED=3]="CLOSED"}(Mt||(Mt={}));var It=Mt,Nt=1;function Dt(t){var e=-1===t.indexOf("?")?"?":"&";return t+e+"t="+ +new Date+"&n="+Nt++}function jt(t){return ae.randomInt(t)}var zt=class{constructor(t,e){this.hooks=t,this.session=jt(1e3)+"/"+function(t){for(var e=[],n=0;n{this.onChunk(t)}),this.stream.bind("finished",t=>{this.hooks.onFinished(this,t)}),this.stream.bind("buffer_too_long",()=>{this.reconnect()});try{this.stream.start()}catch(t){v.defer(()=>{this.onError(t),this.onClose(1006,"Could not start streaming",!1)})}}closeStream(){this.stream&&(this.stream.unbind_all(),this.stream.close(),this.stream=null)}},Ht={getReceiveURL:function(t,e){return t.base+"/"+e+"/xhr_streaming"+t.queryString},onHeartbeat:function(t){t.sendRaw("[]")},sendHeartbeat:function(t){t.sendRaw("[]")},onFinished:function(t,e){t.onClose(1006,"Connection interrupted ("+e+")",!1)}},Bt={getReceiveURL:function(t,e){return t.base+"/"+e+"/xhr"+t.queryString},onHeartbeat:function(){},sendHeartbeat:function(t){t.sendRaw("[]")},onFinished:function(t,e){200===e?t.reconnect():t.onClose(1006,"Connection interrupted ("+e+")",!1)}},Ft={getRequest:function(t){var e=new(ae.getXHRAPI());return e.onreadystatechange=e.onprogress=function(){switch(e.readyState){case 3:e.responseText&&e.responseText.length>0&&t.onChunk(e.status,e.responseText);break;case 4:e.responseText&&e.responseText.length>0&&t.onChunk(e.status,e.responseText),t.emit("finished",e.status),t.close()}},e},abortRequest:function(t){t.onreadystatechange=null,t.abort()}},qt={getDefaultStrategy:Ut,Transports:J,transportConnectionInitializer:function(){this.timeline.info(this.buildTimelineMessage({transport:this.name+(this.options.useTLS?"s":"")})),this.hooks.isInitialized()?this.changeState("initialized"):this.onClose()},HTTPFactory:{createStreamingSocket(t){return this.createSocket(Ht,t)},createPollingSocket(t){return this.createSocket(Bt,t)},createSocket:(t,e)=>new zt(t,e),createXHR(t,e){return this.createRequest(Ft,t,e)},createRequest:(t,e,n)=>new Rt(t,e,n)},setup(t){t.ready()},getLocalStorage(){},getClientFeatures:()=>S(P({ws:J.ws},(function(t){return t.isSupported({})}))),getProtocol:()=>"http:",isXHRSupported:()=>!0,createSocketRequest(t,e){if(this.isXHRSupported())return this.HTTPFactory.createXHR(t,e);throw"Cross-origin HTTP requests are not supported"},createXHR(){return new(this.getXHRAPI())},createWebSocket(t){return new(this.getWebSocketAPI())(t)},addUnloadListener(t){},removeUnloadListener(t){}};var Yt=new class extends j{isOnline(){return!0}},Kt=function(t,e,n,r,i){var s=new Headers;for(var o in s.set("Content-Type","application/x-www-form-urlencoded"),n.headers)s.set(o,n.headers[o]);if(null!=n.headersProvider){const t=n.headersProvider();for(var o in t)s.set(o,t[o])}var a=e,h=new Request(n.endpoint,{headers:s,body:a,credentials:"same-origin",method:"POST"});return fetch(h).then(t=>{let{status:e}=t;if(200===e)return t.text();throw new at(e,`Could not get ${r.toString()} info from your auth endpoint, status: ${e}`)}).then(t=>{let e;try{e=JSON.parse(t)}catch(e){throw new at(200,`JSON returned from ${r.toString()} endpoint was invalid, yet status code was 200. Data was: ${t}`)}i(null,e)}).catch(t=>{i(t,null)})},$t={name:"xhr",getAgent:function(t,e){return function(n,r){var i="http"+(e?"s":"")+"://"+(t.host||t.options.host)+t.options.path,s=x(n);fetch(i+="/2?"+s).then(t=>{if(200!==t.status)throw`received ${t.status} from stats.pusher.com`;return t.json()}).then(({host:e})=>{e&&(t.host=e)}).catch(t=>{z.debug("TimelineSender Error: ",t)})}}};const{getDefaultStrategy:Jt,Transports:Wt,setup:Xt,getProtocol:Gt,isXHRSupported:Vt,getLocalStorage:Zt,createXHR:Qt,createWebSocket:te,addUnloadListener:ee,removeUnloadListener:ne,transportConnectionInitializer:re,createSocketRequest:ie,HTTPFactory:se}=qt;var oe,ae={getDefaultStrategy:Jt,Transports:Wt,setup:Xt,getProtocol:Gt,isXHRSupported:Vt,getLocalStorage:Zt,createXHR:Qt,createWebSocket:te,addUnloadListener:ee,removeUnloadListener:ne,transportConnectionInitializer:re,createSocketRequest:ie,HTTPFactory:se,TimelineTransport:$t,getAuthorizers:()=>({ajax:Kt}),getWebSocketAPI:()=>WebSocket,getXHRAPI:()=>XMLHttpRequest,getNetwork:()=>Yt,randomInt:t=>Math.floor((globalThis.crypto||globalThis.msCrypto).getRandomValues(new Uint32Array(1))[0]/Math.pow(2,32)*t)};!function(t){t[t.ERROR=3]="ERROR",t[t.INFO=6]="INFO",t[t.DEBUG=7]="DEBUG"}(oe||(oe={}));var he=oe;class ce{constructor(t,e,n){this.key=t,this.session=e,this.events=[],this.options=n||{},this.sent=0,this.uniqueID=0}log(t,e){t<=this.options.level&&(this.events.push(y({},e,{timestamp:v.now()})),this.options.limit&&this.events.length>this.options.limit&&this.events.shift())}error(t){this.log(he.ERROR,t)}info(t){this.log(he.INFO,t)}debug(t){this.log(he.DEBUG,t)}isEmpty(){return 0===this.events.length}send(t,e){var n=y({session:this.session,bundle:this.sent+1,key:this.key,lib:"js",version:this.options.version,cluster:this.options.cluster,features:this.options.features,timeline:this.events},this.options.params);return this.events=[],t(n,(t,n)=>{t||this.sent++,e&&e(t,n)}),!0}generateUniqueID(){return this.uniqueID++,this.uniqueID}}class ue{constructor(t,e,n,r){this.name=t,this.priority=e,this.transport=n,this.options=r||{}}isSupported(){return this.transport.isSupported({useTLS:this.options.useTLS})}connect(t,e){if(!this.isSupported())return le(new ot,e);if(this.priority{n||(c(),i?i.close():r.close())},forceMinPriority:t=>{n||this.priority{if(void 0===ae.getAuthorizers()[t.transport])throw`'${t.transport}' is not a recognized auth transport`;return(e,n)=>{const r=((t,e)=>{var n="socket_id="+encodeURIComponent(t.socketId);for(var r in e.params)n+="&"+encodeURIComponent(r)+"="+encodeURIComponent(e.params[r]);if(null!=e.paramsProvider){let t=e.paramsProvider();for(var r in t)n+="&"+encodeURIComponent(r)+"="+encodeURIComponent(t[r])}return n})(e,t);ae.getAuthorizers()[t.transport](ae,r,t,pe.UserAuthentication,n)}};var ye=t=>{if(void 0===ae.getAuthorizers()[t.transport])throw`'${t.transport}' is not a recognized auth transport`;return(e,n)=>{const r=((t,e)=>{var n="socket_id="+encodeURIComponent(t.socketId);for(var r in n+="&channel_name="+encodeURIComponent(t.channelName),e.params)n+="&"+encodeURIComponent(r)+"="+encodeURIComponent(e.params[r]);if(null!=e.paramsProvider){let t=e.paramsProvider();for(var r in t)n+="&"+encodeURIComponent(r)+"="+encodeURIComponent(t[r])}return n})(e,t);ae.getAuthorizers()[t.transport](ae,r,t,pe.ChannelAuthorization,n)}};function me(t,e){let n={activityTimeout:t.activityTimeout||L.activityTimeout,cluster:t.cluster,httpPath:t.httpPath||L.httpPath,httpPort:t.httpPort||L.httpPort,httpsPort:t.httpsPort||L.httpsPort,pongTimeout:t.pongTimeout||L.pongTimeout,statsHost:t.statsHost||L.stats_host,unavailableTimeout:t.unavailableTimeout||L.unavailableTimeout,wsPath:t.wsPath||L.wsPath,wsPort:t.wsPort||L.wsPort,wssPort:t.wssPort||L.wssPort,enableStats:ke(t),httpHost:we(t),useTLS:Se(t),wsHost:_e(t),userAuthenticator:Ce(t),channelAuthorizer:Te(t,e)};return"disabledTransports"in t&&(n.disabledTransports=t.disabledTransports),"enabledTransports"in t&&(n.enabledTransports=t.enabledTransports),"ignoreNullOrigin"in t&&(n.ignoreNullOrigin=t.ignoreNullOrigin),"timelineParams"in t&&(n.timelineParams=t.timelineParams),"nacl"in t&&(n.nacl=t.nacl),n}function we(t){return t.httpHost?t.httpHost:t.cluster?`sockjs-${t.cluster}.pusher.com`:L.httpHost}function _e(t){return t.wsHost?t.wsHost:`ws-${t.cluster}.pusher.com`}function Se(t){return"https:"===ae.getProtocol()||!1!==t.forceTLS}function ke(t){return"enableStats"in t?t.enableStats:"disableStats"in t&&!t.disableStats}function Ce(t){const e=Object.assign(Object.assign({},L.userAuthentication),t.userAuthentication);return"customHandler"in e&&null!=e.customHandler?e.customHandler:ve(e)}function Te(t,e){const n=function(t,e){let n;return"channelAuthorization"in t?n=Object.assign(Object.assign({},L.channelAuthorization),t.channelAuthorization):(n={transport:t.authTransport||L.authTransport,endpoint:t.authEndpoint||L.authEndpoint},"auth"in t&&("params"in t.auth&&(n.params=t.auth.params),"headers"in t.auth&&(n.headers=t.auth.headers)),"authorizer"in t&&(n.customHandler=((t,e,n)=>{const r={authTransport:e.transport,authEndpoint:e.endpoint,auth:{params:e.params,headers:e.headers}};return(e,i)=>{const s=t.channel(e.channelName);n(s,r).authorize(e.socketId,i)}})(e,n,t.authorizer))),n}(t,e);return"customHandler"in n&&null!=n.customHandler?n.customHandler:ye(n)}class Pe extends j{constructor(t){super((function(t,e){z.debug("No callbacks on watchlist events for "+t)})),this.pusher=t,this.bindWatchlistInternalEvent()}handleEvent(t){t.data.events.forEach(t=>{this.emit(t.name,t)})}bindWatchlistInternalEvent(){this.pusher.connection.bind("message",t=>{"pusher_internal:watchlist_events"===t.event&&this.handleEvent(t)})}}var Ae=function(){let t,e;return{promise:new Promise((n,r)=>{t=n,e=r}),resolve:t,reject:e}};class Ee extends j{constructor(t){super((function(t,e){z.debug("No callbacks on user for "+t)})),this.signin_requested=!1,this.user_data=null,this.serverToUserChannel=null,this.signinDonePromise=null,this._signinDoneResolve=null,this._onAuthorize=(t,e)=>{if(t)return z.warn("Error during signin: "+t),void this._cleanup();this.pusher.send_event("pusher:signin",{auth:e.auth,user_data:e.user_data})},this.pusher=t,this.pusher.connection.bind("state_change",({previous:t,current:e})=>{"connected"!==t&&"connected"===e&&this._signin(),"connected"===t&&"connected"!==e&&(this._cleanup(),this._newSigninPromiseIfNeeded())}),this.watchlist=new Pe(t),this.pusher.connection.bind("message",t=>{"pusher:signin_success"===t.event&&this._onSigninSuccess(t.data),this.serverToUserChannel&&this.serverToUserChannel.name===t.channel&&this.serverToUserChannel.handleEvent(t)})}signin(){this.signin_requested||(this.signin_requested=!0,this._signin())}_signin(){this.signin_requested&&(this._newSigninPromiseIfNeeded(),"connected"===this.pusher.connection.state&&this.pusher.config.userAuthenticator({socketId:this.pusher.connection.socket_id},this._onAuthorize))}_onSigninSuccess(t){try{this.user_data=JSON.parse(t.user_data)}catch(e){return z.error("Failed parsing user data after signin: "+t.user_data),void this._cleanup()}if("string"!=typeof this.user_data.id||""===this.user_data.id)return z.error("user_data doesn't contain an id. user_data: "+this.user_data),void this._cleanup();this._signinDoneResolve(),this._subscribeChannels()}_subscribeChannels(){this.serverToUserChannel=new ut("#server-to-user-"+this.user_data.id,this.pusher),this.serverToUserChannel.bind_global((t,e)=>{0!==t.indexOf("pusher_internal:")&&0!==t.indexOf("pusher:")&&this.emit(t,e)}),(t=>{t.subscriptionPending&&t.subscriptionCancelled?t.reinstateSubscription():t.subscriptionPending||"connected"!==this.pusher.connection.state||t.subscribe()})(this.serverToUserChannel)}_cleanup(){this.user_data=null,this.serverToUserChannel&&(this.serverToUserChannel.unbind_all(),this.serverToUserChannel.disconnect(),this.serverToUserChannel=null),this.signin_requested&&this._signinDoneResolve()}_newSigninPromiseIfNeeded(){if(!this.signin_requested)return;if(this.signinDonePromise&&!this.signinDonePromise.done)return;const{promise:t,resolve:e,reject:n}=Ae();t.done=!1;const r=()=>{t.done=!0};t.then(r).catch(r),this.signinDonePromise=t,this._signinDoneResolve=e}}class xe{static ready(){xe.isReady=!0;for(var t=0,e=xe.instances.length;tae.getDefaultStrategy(this.config,t,fe),timeline:this.timeline,activityTimeout:this.config.activityTimeout,pongTimeout:this.config.pongTimeout,unavailableTimeout:this.config.unavailableTimeout,useTLS:Boolean(this.config.useTLS)}),this.connection.bind("connected",()=>{this.subscribeAll(),this.timelineSender&&this.timelineSender.send(this.connection.isUsingTLS())}),this.connection.bind("message",t=>{var e=0===t.event.indexOf("pusher_internal:");if(t.channel){var n=this.channel(t.channel);n&&n.handleEvent(t)}e||this.global_emitter.emit(t.event,t.data)}),this.connection.bind("connecting",()=>{this.channels.disconnect()}),this.connection.bind("disconnected",()=>{this.channels.disconnect()}),this.connection.bind("error",t=>{z.warn(t)}),xe.instances.push(this),this.timeline.info({instances:xe.instances.length}),this.user=new Ee(this),xe.isReady&&this.connect()}switchCluster(t){const{appKey:e,cluster:n}=t;this.key=e,this.options=Object.assign(Object.assign({},this.options),{cluster:n}),this.config=me(this.options,this),this.connection.switchCluster(this.key)}channel(t){return this.channels.find(t)}allChannels(){return this.channels.all()}connect(){if(this.connection.connect(),this.timelineSender&&!this.timelineSenderTimer){var t=this.connection.isUsingTLS(),e=this.timelineSender;this.timelineSenderTimer=new b(6e4,(function(){e.send(t)}))}}disconnect(){this.connection.disconnect(),this.timelineSenderTimer&&(this.timelineSenderTimer.ensureAborted(),this.timelineSenderTimer=null)}bind(t,e,n){return this.global_emitter.bind(t,e,n),this}unbind(t,e,n){return this.global_emitter.unbind(t,e,n),this}bind_global(t){return this.global_emitter.bind_global(t),this}unbind_global(t){return this.global_emitter.unbind_global(t),this}unbind_all(t){return this.global_emitter.unbind_all(),this}subscribeAll(){var t;for(t in this.channels.channels)this.channels.channels.hasOwnProperty(t)&&this.subscribe(t)}subscribe(t){var e=this.channels.add(t,this);return e.subscriptionPending&&e.subscriptionCancelled?e.reinstateSubscription():e.subscriptionPending||"connected"!==this.connection.state||e.subscribe(),e}unsubscribe(t){var e=this.channels.find(t);e&&e.subscriptionPending?e.cancelSubscription():(e=this.channels.remove(t))&&e.subscribed&&e.unsubscribe()}send_event(t,e,n){return this.connection.send_event(t,e,n)}shouldUseTLS(){return this.config.useTLS}signin(){this.user.signin()}}xe.instances=[],xe.isReady=!1,xe.logToConsole=!1,xe.Runtime=ae,xe.ScriptReceivers=ae.ScriptReceivers,xe.DependenciesReceivers=ae.DependenciesReceivers,xe.auth_callbacks=ae.auth_callbacks;var Oe=xe;ae.setup(xe);var Le=n(2);class Ue extends Oe{constructor(t,e){Oe.logToConsole=Ue.logToConsole,Oe.log=Ue.log,be(e),e.nacl=Le,super(t,e)}}}])})); //# sourceMappingURL=pusher-with-encryption.worker.min.js.map \ No newline at end of file diff --git a/dist/worker/pusher-with-encryption.worker.min.js.map b/dist/worker/pusher-with-encryption.worker.min.js.map index d983e433a..df7b9e0ab 100644 --- a/dist/worker/pusher-with-encryption.worker.min.js.map +++ b/dist/worker/pusher-with-encryption.worker.min.js.map @@ -1 +1 @@ -{"version":3,"sources":["webpack://Pusher/webpack/universalModuleDefinition","webpack://Pusher/webpack/bootstrap","webpack://Pusher/./node_modules/@stablelib/base64/base64.ts","webpack://Pusher/./node_modules/@stablelib/utf8/utf8.ts","webpack://Pusher/./node_modules/tweetnacl/nacl-fast.js","webpack://Pusher/./src/core/pusher-with-encryption.js","webpack://Pusher/./src/core/base64.ts","webpack://Pusher/./src/core/utils/timers/abstract_timer.ts","webpack://Pusher/./src/core/utils/timers/index.ts","webpack://Pusher/./src/core/util.ts","webpack://Pusher/./src/core/utils/collections.ts","webpack://Pusher/./src/core/defaults.ts","webpack://Pusher/./src/core/transports/url_schemes.ts","webpack://Pusher/./src/core/events/callback_registry.ts","webpack://Pusher/./src/core/events/dispatcher.ts","webpack://Pusher/./src/core/logger.ts","webpack://Pusher/./src/core/transports/transport_connection.ts","webpack://Pusher/./src/core/transports/transport.ts","webpack://Pusher/./src/runtimes/isomorphic/transports/transports.ts","webpack://Pusher/./src/core/transports/assistant_to_the_transport_manager.ts","webpack://Pusher/./src/core/connection/protocol/protocol.ts","webpack://Pusher/./src/core/connection/connection.ts","webpack://Pusher/./src/core/connection/handshake/index.ts","webpack://Pusher/./src/core/timeline/timeline_sender.ts","webpack://Pusher/./src/core/errors.ts","webpack://Pusher/./src/core/utils/url_store.ts","webpack://Pusher/./src/core/channels/channel.ts","webpack://Pusher/./src/core/channels/private_channel.ts","webpack://Pusher/./src/core/channels/members.ts","webpack://Pusher/./src/core/channels/presence_channel.ts","webpack://Pusher/./src/core/channels/encrypted_channel.ts","webpack://Pusher/./src/core/connection/connection_manager.ts","webpack://Pusher/./src/core/channels/channels.ts","webpack://Pusher/./src/core/utils/factory.ts","webpack://Pusher/./src/core/transports/transport_manager.ts","webpack://Pusher/./src/core/strategies/sequential_strategy.ts","webpack://Pusher/./src/core/strategies/best_connected_ever_strategy.ts","webpack://Pusher/./src/core/strategies/websocket_prioritized_cached_strategy.ts","webpack://Pusher/./src/core/strategies/delayed_strategy.ts","webpack://Pusher/./src/core/strategies/if_strategy.ts","webpack://Pusher/./src/core/strategies/first_connected_strategy.ts","webpack://Pusher/./src/runtimes/isomorphic/default_strategy.ts","webpack://Pusher/./src/core/http/http_request.ts","webpack://Pusher/./src/core/http/state.ts","webpack://Pusher/./src/core/http/http_socket.ts","webpack://Pusher/./src/core/http/http_streaming_socket.ts","webpack://Pusher/./src/core/http/http_polling_socket.ts","webpack://Pusher/./src/runtimes/isomorphic/http/http_xhr_request.ts","webpack://Pusher/./src/runtimes/isomorphic/runtime.ts","webpack://Pusher/./src/runtimes/isomorphic/transports/transport_connection_initializer.ts","webpack://Pusher/./src/runtimes/isomorphic/http/http.ts","webpack://Pusher/./src/runtimes/worker/net_info.ts","webpack://Pusher/./src/runtimes/worker/auth/fetch_auth.ts","webpack://Pusher/./src/runtimes/worker/timeline/fetch_timeline.ts","webpack://Pusher/./src/runtimes/worker/runtime.ts","webpack://Pusher/./src/core/timeline/level.ts","webpack://Pusher/./src/core/timeline/timeline.ts","webpack://Pusher/./src/core/strategies/transport_strategy.ts","webpack://Pusher/./src/core/strategies/strategy_builder.ts","webpack://Pusher/./src/core/auth/options.ts","webpack://Pusher/./src/core/options.ts","webpack://Pusher/./src/core/auth/user_authenticator.ts","webpack://Pusher/./src/core/auth/channel_authorizer.ts","webpack://Pusher/./src/core/config.ts","webpack://Pusher/./src/core/auth/deprecated_channel_authorizer.ts","webpack://Pusher/./src/core/watchlist.ts","webpack://Pusher/./src/core/utils/flat_promise.ts","webpack://Pusher/./src/core/user.ts","webpack://Pusher/./src/core/pusher.ts","webpack://Pusher/./src/core/pusher-with-encryption.ts"],"names":["root","factory","exports","module","define","amd","this","installedModules","__webpack_require__","moduleId","i","l","modules","call","m","c","d","name","getter","o","Object","defineProperty","enumerable","get","r","Symbol","toStringTag","value","t","mode","__esModule","ns","create","key","bind","n","object","property","prototype","hasOwnProperty","p","s","_paddingCharacter","encodedLength","length","encode","data","out","_encodeByte","left","maxDecodedLength","decodedLength","_getPaddingLength","decode","Uint8Array","paddingLength","op","haveBad","v0","v1","v2","v3","_decodeChar","charCodeAt","Error","b","result","String","fromCharCode","Coder","stdCoder","URLSafeCoder","urlSafeCoder","INVALID_UTF8","arr","pos","chars","min","n1","n2","n3","push","join","nacl","gf","init","Float64Array","randombytes","_0","_9","gf0","gf1","_121665","D","D2","X","Y","I","ts64","x","h","vn","xi","y","yi","crypto_verify_16","crypto_verify_32","crypto_core_salsa20","inp","k","u","j0","j1","j2","j3","j4","j5","j6","j7","j8","j9","j10","j11","j12","j13","j14","j15","x0","x1","x2","x3","x4","x5","x6","x7","x8","x9","x10","x11","x12","x13","x14","x15","core_salsa20","crypto_core_hsalsa20","core_hsalsa20","sigma","crypto_stream_salsa20_xor","cpos","mpos","z","crypto_stream_salsa20","crypto_stream","sn","crypto_stream_xor","poly1305","t0","t1","t2","t3","t4","t5","t6","t7","buffer","Uint16Array","pad","leftover","fin","crypto_onetimeauth","outpos","update","finish","crypto_onetimeauth_verify","hpos","crypto_secretbox","crypto_secretbox_open","set25519","a","car25519","v","Math","floor","sel25519","q","pack25519","j","neq25519","par25519","unpack25519","A","Z","M","t8","t9","t10","t11","t12","t13","t14","t15","t16","t17","t18","t19","t20","t21","t22","t23","t24","t25","t26","t27","t28","t29","t30","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","b10","b11","b12","b13","b14","b15","S","inv25519","pow2523","crypto_scalarmult","e","f","x32","subarray","x16","crypto_scalarmult_base","crypto_box_keypair","crypto_box_beforenm","blocks","bytes","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","hibit","h0","h1","h2","h3","h4","h5","h6","h7","h8","h9","r0","r1","r2","r3","r4","r5","r6","r7","r8","r9","mac","macpos","mask","g","want","crypto_box_afternm","crypto_box_open_afternm","K","crypto_hashblocks_hl","hh","hl","bh0","bh1","bh2","bh3","bh4","bh5","bh6","bh7","bl0","bl1","bl2","bl3","bl4","bl5","bl6","bl7","th","tl","wh","Int32Array","wl","ah0","ah1","ah2","ah3","ah4","ah5","ah6","ah7","al0","al1","al2","al3","al4","al5","al6","al7","crypto_hash","add","cswap","pack","tx","ty","zi","scalarmult","scalarbase","crypto_sign_keypair","pk","sk","seeded","L","modL","carry","reduce","crypto_sign","sm","smlen","crypto_sign_open","chk","num","den","den2","den4","den6","unpackneg","checkLengths","checkArrayTypes","arguments","TypeError","cleanup","lowlevel","crypto_box","crypto_box_open","crypto_secretbox_KEYBYTES","crypto_secretbox_NONCEBYTES","crypto_secretbox_ZEROBYTES","crypto_secretbox_BOXZEROBYTES","crypto_scalarmult_BYTES","crypto_scalarmult_SCALARBYTES","crypto_box_PUBLICKEYBYTES","crypto_box_SECRETKEYBYTES","crypto_box_BEFORENMBYTES","crypto_box_NONCEBYTES","crypto_box_ZEROBYTES","crypto_box_BOXZEROBYTES","crypto_sign_BYTES","crypto_sign_PUBLICKEYBYTES","crypto_sign_SECRETKEYBYTES","crypto_sign_SEEDBYTES","crypto_hash_BYTES","randomBytes","secretbox","msg","nonce","open","box","keyLength","nonceLength","overheadLength","scalarMult","base","scalarLength","groupElementLength","publicKey","secretKey","before","checkBoxLengths","after","keyPair","fromSecretKey","publicKeyLength","secretKeyLength","sharedKeyLength","sign","signedMsg","tmp","mlen","detached","sig","verify","fromSeed","seed","seedLength","signatureLength","hash","hashLength","setPRNG","fn","crypto","self","msCrypto","getRandomValues","default","b64chars","b64tab","charAt","cb_utob","cc","utob","replace","cb_encode","ccc","padlen","ord","btoa","set","clear","delay","callback","timer","clearTimeout","clearInterval","super","setTimeout","setInterval","now","Date","valueOf","defer","args","boundArguments","Array","slice","apply","concat","extend","target","sources","extensions","constructor","stringify","safeJSONStringify","arrayIndexOf","array","item","nativeIndexOf","indexOf","objectApply","keys","_","context","map","filter","test","filterObject","Boolean","any","encodeParamsObject","encodeURIComponent","toString","buildQueryString","params","undefined","method","source","JSON","objects","paths","derez","path","nu","$ref","VERSION","PROTOCOL","wsPort","wssPort","wsPath","httpHost","httpPort","httpsPort","httpPath","stats_host","authEndpoint","authTransport","activityTimeout","pongTimeout","unavailableTimeout","userAuthentication","endpoint","transport","channelAuthorization","cdn_http","cdn_https","dependency_suffix","getGenericURL","baseScheme","useTLS","hostTLS","hostNonTLS","getGenericPath","queryString","ws","getInitial","http","_callbacks","prefix","prefixedEventName","names","removeCallback","removeAllCallbacks","binding","failThrough","callbacks","global_callbacks","eventName","remove","unbind","unbind_global","metadata","globalLog","message","console","log","globalLogWarn","globalLogError","warn","error","defaultLoggingFunction","logToConsole","hooks","priority","options","initialize","transportConnectionInitializer","state","timeline","id","generateUniqueID","handlesActivityChecks","supportsPing","socket","url","urls","getSocket","onError","changeState","bindListeners","debug","close","send","ping","beforeOpen","getPath","onopen","emit","type","buildTimelineMessage","closeEvent","code","reason","wasClean","unbindListeners","onOpen","onerror","onclose","onClose","onmessage","onMessage","onactivity","onActivity","info","cid","environment","isSupported","WSTransport","isInitialized","getWebSocketAPI","createWebSocket","httpConfiguration","streamingConfiguration","HTTPFactory","createStreamingSocket","pollingConfiguration","createPollingSocket","xhrConfiguration","isXHRSupported","xhr_streaming","xhr_polling","manager","minPingDelay","maxPingDelay","pingDelay","connection","createConnection","openTimestamp","onClosed","reportDeath","lifespan","max","isAlive","Protocol","decodeMessage","messageEvent","messageData","parse","pusherEventData","pusherEvent","event","channel","user_id","encodeMessage","processHandshake","activity_timeout","action","socket_id","getCloseAction","getCloseError","send_event","listeners","activity","closed","handleCloseEvent","listener","isEmpty","TimelineTransport","getAgent","BadEventName","setPrototypeOf","BadChannelName","TransportPriorityTooLow","TransportClosed","UnsupportedFeature","UnsupportedTransport","UnsupportedStrategy","HTTPAuthError","status","urlStore","baseUrl","authenticationEndpoint","authorizationEndpoint","javascriptQuickStart","triggeringClientEvents","encryptedChannelSupport","fullUrl","urlObj","pusher","subscribed","subscriptionPending","subscriptionCancelled","socketId","auth","suffix","handleSubscriptionSucceededEvent","handleSubscriptionCountEvent","unsubscribe","subscription_count","subscriptionCount","authorize","assign","channel_data","config","channelAuthorizer","channelName","reset","members","member","myID","subscriptionData","presence","count","me","memberData","user_info","authData","channelData","setMyID","user","signinDonePromise","user_data","handleInternalEvent","addedMember","addMember","removedMember","removeMember","onSubscription","disconnect","sharedSecret","handleEncryptedEvent","handleEvent","ciphertext","cipherText","getDataToEmit","raw","usingTLS","errorCallbacks","buildErrorCallbacks","connectionCallbacks","buildConnectionCallbacks","handshakeCallbacks","buildHandshakeCallbacks","Network","getNetwork","netinfo","retryIn","sendActivityCheck","updateStrategy","runner","strategy","updateState","startConnecting","setUnavailableTimer","disconnectInternally","handshake","connect","handshakeError","abortConnecting","abort","clearRetryTimer","clearUnavailableTimer","abandonConnection","getStrategy","round","retryTimer","ensureAborted","unavailableTimer","stopActivityCheck","activityTimer","pong_timed_out","resetActivityCheck","shouldRetry","connected","Infinity","setConnection","withErrorEmitted","tls_only","refused","backoff","retry","newState","previousState","newStateDescription","previous","current","channels","createEncryptedChannel","errMsg","createPrivateChannel","createPresenceChannel","createChannel","values","createChannels","createConnectionManager","createTimelineSender","createHandshake","createAssistantToTheTransportManager","livesLeft","lives","strategies","loop","failFast","timeout","timeoutLimit","minPriority","tryNextStrategy","tryStrategy","forceMinPriority","isRunning","callbackBuilder","runners","rs","abortRunner","allRunnersFailed","aborted","transports","ttl","storage","getLocalStorage","serializedCache","getTransportCacheKey","flushTransportCache","fetchTransportCache","cacheSkipCount","timestamp","includes","cached","latency","startTimestamp","pop","cb","storeTransportCache","number","IfStrategy","trueBranch","falseBranch","FirstConnectedStrategy","testSupportsStrategy","baseOptions","defineTransport","definedTransports","defineTransportStrategy","wsStrategy","ws_options","wsHost","wss_options","http_options","timeouts","ws_manager","streaming_manager","ws_transport","wss_transport","xhr_streaming_transport","xhr_polling_transport","ws_loop","wss_loop","streaming_loop","polling_loop","http_loop","payload","position","xhr","getRequest","unloader","addUnloadListener","setRequestHeader","removeUnloadListener","abortRequest","chunk","advanceBuffer","isBufferTooLong","unreadData","endOfLinePosition","State","autoIncrement","getUniqueURL","separator","randomNumber","randomInt","session","randomString","location","parts","exec","getLocation","readyState","CONNECTING","openStream","sendRaw","sendHeartbeat","OPEN","createSocketRequest","start","closeStream","CLOSED","onEvent","onHeartbeat","hostname","urlParts","stream","getReceiveURL","onChunk","onFinished","reconnect","unbind_all","getXHRAPI","onreadystatechange","onprogress","responseText","getDefaultStrategy","Transports","createSocket","createRequest","PusherClass","ready","getClientFeatures","getProtocol","createXHR","query","authOptions","authRequestType","headers","Headers","headerName","headersProvider","dynamicHeaders","body","request","Request","credentials","fetch","then","response","text","parsedData","catch","err","sender","host","json","setup","TimelineLevel","getAuthorizers","ajax","WebSocket","XMLHttpRequest","globalThis","Uint32Array","events","sent","uniqueID","level","limit","shift","ERROR","INFO","DEBUG","sendfn","bundle","lib","version","cluster","features","failAttempt","onInitialized","serializedTransport","AuthRequestType","transportClass","enabledTransports","disabledTransports","ignoreNullOrigin","getAssistant","deferred","validateOptions","paramsProvider","dynamicParams","composeChannelQuery","UserAuthentication","ChannelAuthorization","getHttpHost","opts","getWebsocketHost","shouldUseTLS","forceTLS","getEnableStatsConfig","enableStats","disableStats","buildUserAuthenticator","buildChannelAuthorizer","customHandler","channelAuthorizerGenerator","deprecatedAuthorizerOptions","ChannelAuthorizerProxy","authorizer","buildChannelAuth","bindWatchlistInternalEvent","forEach","watchlistEvent","resolve","reject","promise","Promise","res","rej","signin_requested","serverToUserChannel","_signinDoneResolve","_onAuthorize","_cleanup","_signin","_newSigninPromiseIfNeeded","watchlist","_onSigninSuccess","userAuthenticator","_subscribeChannels","bind_global","reinstateSubscription","subscribe","ensure_subscribed","done","setDone","isReady","instances","app_key","checkAppKey","statsHost","timelineParams","getConfig","global_emitter","sessionID","timelineSender","subscribeAll","isUsingTLS","internal","find","all","timelineSenderTimer","event_name","channel_name","cancelSubscription","signin","Runtime","ScriptReceivers","DependenciesReceivers","auth_callbacks"],"mappings":";;;;;;;CAAA,SAA2CA,EAAMC,GAC1B,iBAAZC,SAA0C,iBAAXC,OACxCA,OAAOD,QAAUD,IACQ,mBAAXG,QAAyBA,OAAOC,IAC9CD,OAAO,GAAIH,GACe,iBAAZC,QACdA,QAAgB,OAAID,IAEpBD,EAAa,OAAIC,IARnB,CASGK,MAAM,WACT,O,YCTE,IAAIC,EAAmB,GAGvB,SAASC,EAAoBC,GAG5B,GAAGF,EAAiBE,GACnB,OAAOF,EAAiBE,GAAUP,QAGnC,IAAIC,EAASI,EAAiBE,GAAY,CACzCC,EAAGD,EACHE,GAAG,EACHT,QAAS,IAUV,OANAU,EAAQH,GAAUI,KAAKV,EAAOD,QAASC,EAAQA,EAAOD,QAASM,GAG/DL,EAAOQ,GAAI,EAGJR,EAAOD,QA0Df,OArDAM,EAAoBM,EAAIF,EAGxBJ,EAAoBO,EAAIR,EAGxBC,EAAoBQ,EAAI,SAASd,EAASe,EAAMC,GAC3CV,EAAoBW,EAAEjB,EAASe,IAClCG,OAAOC,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3B,GAAOH,aAAe,GAAqBA,aAC3C,GAAON,IAAM,GAAqBA,IAElCyZ,GAAgBhZ,GAChBA,EAAQld,KAAO,GACfqW,MAAM+iB,EAASlc","file":"pusher-with-encryption.worker.min.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"Pusher\"] = factory();\n\telse\n\t\troot[\"Pusher\"] = factory();\n})(this, function() {\nreturn "," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 3);\n","// Copyright (C) 2016 Dmitry Chestnykh\n// MIT License. See LICENSE file for details.\n\n/**\n * Package base64 implements Base64 encoding and decoding.\n */\n\n// Invalid character used in decoding to indicate\n// that the character to decode is out of range of\n// alphabet and cannot be decoded.\nconst INVALID_BYTE = 256;\n\n/**\n * Implements standard Base64 encoding.\n *\n * Operates in constant time.\n */\nexport class Coder {\n // TODO(dchest): methods to encode chunk-by-chunk.\n\n constructor(private _paddingCharacter = \"=\") { }\n\n encodedLength(length: number): number {\n if (!this._paddingCharacter) {\n return (length * 8 + 5) / 6 | 0;\n }\n return (length + 2) / 3 * 4 | 0;\n }\n\n encode(data: Uint8Array): string {\n let out = \"\";\n\n let i = 0;\n for (; i < data.length - 2; i += 3) {\n let c = (data[i] << 16) | (data[i + 1] << 8) | (data[i + 2]);\n out += this._encodeByte((c >>> 3 * 6) & 63);\n out += this._encodeByte((c >>> 2 * 6) & 63);\n out += this._encodeByte((c >>> 1 * 6) & 63);\n out += this._encodeByte((c >>> 0 * 6) & 63);\n }\n\n const left = data.length - i;\n if (left > 0) {\n let c = (data[i] << 16) | (left === 2 ? data[i + 1] << 8 : 0);\n out += this._encodeByte((c >>> 3 * 6) & 63);\n out += this._encodeByte((c >>> 2 * 6) & 63);\n if (left === 2) {\n out += this._encodeByte((c >>> 1 * 6) & 63);\n } else {\n out += this._paddingCharacter || \"\";\n }\n out += this._paddingCharacter || \"\";\n }\n\n return out;\n }\n\n maxDecodedLength(length: number): number {\n if (!this._paddingCharacter) {\n return (length * 6 + 7) / 8 | 0;\n }\n return length / 4 * 3 | 0;\n }\n\n decodedLength(s: string): number {\n return this.maxDecodedLength(s.length - this._getPaddingLength(s));\n }\n\n decode(s: string): Uint8Array {\n if (s.length === 0) {\n return new Uint8Array(0);\n }\n const paddingLength = this._getPaddingLength(s);\n const length = s.length - paddingLength;\n const out = new Uint8Array(this.maxDecodedLength(length));\n let op = 0;\n let i = 0;\n let haveBad = 0;\n let v0 = 0, v1 = 0, v2 = 0, v3 = 0;\n for (; i < length - 4; i += 4) {\n v0 = this._decodeChar(s.charCodeAt(i + 0));\n v1 = this._decodeChar(s.charCodeAt(i + 1));\n v2 = this._decodeChar(s.charCodeAt(i + 2));\n v3 = this._decodeChar(s.charCodeAt(i + 3));\n out[op++] = (v0 << 2) | (v1 >>> 4);\n out[op++] = (v1 << 4) | (v2 >>> 2);\n out[op++] = (v2 << 6) | v3;\n haveBad |= v0 & INVALID_BYTE;\n haveBad |= v1 & INVALID_BYTE;\n haveBad |= v2 & INVALID_BYTE;\n haveBad |= v3 & INVALID_BYTE;\n }\n if (i < length - 1) {\n v0 = this._decodeChar(s.charCodeAt(i));\n v1 = this._decodeChar(s.charCodeAt(i + 1));\n out[op++] = (v0 << 2) | (v1 >>> 4);\n haveBad |= v0 & INVALID_BYTE;\n haveBad |= v1 & INVALID_BYTE;\n }\n if (i < length - 2) {\n v2 = this._decodeChar(s.charCodeAt(i + 2));\n out[op++] = (v1 << 4) | (v2 >>> 2);\n haveBad |= v2 & INVALID_BYTE;\n }\n if (i < length - 3) {\n v3 = this._decodeChar(s.charCodeAt(i + 3));\n out[op++] = (v2 << 6) | v3;\n haveBad |= v3 & INVALID_BYTE;\n }\n if (haveBad !== 0) {\n throw new Error(\"Base64Coder: incorrect characters for decoding\");\n }\n return out;\n }\n\n // Standard encoding have the following encoded/decoded ranges,\n // which we need to convert between.\n //\n // ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 0123456789 + /\n // Index: 0 - 25 26 - 51 52 - 61 62 63\n // ASCII: 65 - 90 97 - 122 48 - 57 43 47\n //\n\n // Encode 6 bits in b into a new character.\n protected _encodeByte(b: number): string {\n // Encoding uses constant time operations as follows:\n //\n // 1. Define comparison of A with B using (A - B) >>> 8:\n // if A > B, then result is positive integer\n // if A <= B, then result is 0\n //\n // 2. Define selection of C or 0 using bitwise AND: X & C:\n // if X == 0, then result is 0\n // if X != 0, then result is C\n //\n // 3. Start with the smallest comparison (b >= 0), which is always\n // true, so set the result to the starting ASCII value (65).\n //\n // 4. Continue comparing b to higher ASCII values, and selecting\n // zero if comparison isn't true, otherwise selecting a value\n // to add to result, which:\n //\n // a) undoes the previous addition\n // b) provides new value to add\n //\n let result = b;\n // b >= 0\n result += 65;\n // b > 25\n result += ((25 - b) >>> 8) & ((0 - 65) - 26 + 97);\n // b > 51\n result += ((51 - b) >>> 8) & ((26 - 97) - 52 + 48);\n // b > 61\n result += ((61 - b) >>> 8) & ((52 - 48) - 62 + 43);\n // b > 62\n result += ((62 - b) >>> 8) & ((62 - 43) - 63 + 47);\n\n return String.fromCharCode(result);\n }\n\n // Decode a character code into a byte.\n // Must return 256 if character is out of alphabet range.\n protected _decodeChar(c: number): number {\n // Decoding works similar to encoding: using the same comparison\n // function, but now it works on ranges: result is always incremented\n // by value, but this value becomes zero if the range is not\n // satisfied.\n //\n // Decoding starts with invalid value, 256, which is then\n // subtracted when the range is satisfied. If none of the ranges\n // apply, the function returns 256, which is then checked by\n // the caller to throw error.\n let result = INVALID_BYTE; // start with invalid character\n\n // c == 43 (c > 42 and c < 44)\n result += (((42 - c) & (c - 44)) >>> 8) & (-INVALID_BYTE + c - 43 + 62);\n // c == 47 (c > 46 and c < 48)\n result += (((46 - c) & (c - 48)) >>> 8) & (-INVALID_BYTE + c - 47 + 63);\n // c > 47 and c < 58\n result += (((47 - c) & (c - 58)) >>> 8) & (-INVALID_BYTE + c - 48 + 52);\n // c > 64 and c < 91\n result += (((64 - c) & (c - 91)) >>> 8) & (-INVALID_BYTE + c - 65 + 0);\n // c > 96 and c < 123\n result += (((96 - c) & (c - 123)) >>> 8) & (-INVALID_BYTE + c - 97 + 26);\n\n return result;\n }\n\n private _getPaddingLength(s: string): number {\n let paddingLength = 0;\n if (this._paddingCharacter) {\n for (let i = s.length - 1; i >= 0; i--) {\n if (s[i] !== this._paddingCharacter) {\n break;\n }\n paddingLength++;\n }\n if (s.length < 4 || paddingLength > 2) {\n throw new Error(\"Base64Coder: incorrect padding\");\n }\n }\n return paddingLength;\n }\n\n}\n\nconst stdCoder = new Coder();\n\nexport function encode(data: Uint8Array): string {\n return stdCoder.encode(data);\n}\n\nexport function decode(s: string): Uint8Array {\n return stdCoder.decode(s);\n}\n\n/**\n * Implements URL-safe Base64 encoding.\n * (Same as Base64, but '+' is replaced with '-', and '/' with '_').\n *\n * Operates in constant time.\n */\nexport class URLSafeCoder extends Coder {\n // URL-safe encoding have the following encoded/decoded ranges:\n //\n // ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 0123456789 - _\n // Index: 0 - 25 26 - 51 52 - 61 62 63\n // ASCII: 65 - 90 97 - 122 48 - 57 45 95\n //\n\n protected _encodeByte(b: number): string {\n let result = b;\n // b >= 0\n result += 65;\n // b > 25\n result += ((25 - b) >>> 8) & ((0 - 65) - 26 + 97);\n // b > 51\n result += ((51 - b) >>> 8) & ((26 - 97) - 52 + 48);\n // b > 61\n result += ((61 - b) >>> 8) & ((52 - 48) - 62 + 45);\n // b > 62\n result += ((62 - b) >>> 8) & ((62 - 45) - 63 + 95);\n\n return String.fromCharCode(result);\n }\n\n protected _decodeChar(c: number): number {\n let result = INVALID_BYTE;\n\n // c == 45 (c > 44 and c < 46)\n result += (((44 - c) & (c - 46)) >>> 8) & (-INVALID_BYTE + c - 45 + 62);\n // c == 95 (c > 94 and c < 96)\n result += (((94 - c) & (c - 96)) >>> 8) & (-INVALID_BYTE + c - 95 + 63);\n // c > 47 and c < 58\n result += (((47 - c) & (c - 58)) >>> 8) & (-INVALID_BYTE + c - 48 + 52);\n // c > 64 and c < 91\n result += (((64 - c) & (c - 91)) >>> 8) & (-INVALID_BYTE + c - 65 + 0);\n // c > 96 and c < 123\n result += (((96 - c) & (c - 123)) >>> 8) & (-INVALID_BYTE + c - 97 + 26);\n\n return result;\n }\n}\n\nconst urlSafeCoder = new URLSafeCoder();\n\nexport function encodeURLSafe(data: Uint8Array): string {\n return urlSafeCoder.encode(data);\n}\n\nexport function decodeURLSafe(s: string): Uint8Array {\n return urlSafeCoder.decode(s);\n}\n\n\nexport const encodedLength = (length: number) =>\n stdCoder.encodedLength(length);\n\nexport const maxDecodedLength = (length: number) =>\n stdCoder.maxDecodedLength(length);\n\nexport const decodedLength = (s: string) =>\n stdCoder.decodedLength(s);\n","// Copyright (C) 2016 Dmitry Chestnykh\n// MIT License. See LICENSE file for details.\n\n/**\n * Package utf8 implements UTF-8 encoding and decoding.\n */\n\nconst INVALID_UTF16 = \"utf8: invalid string\";\nconst INVALID_UTF8 = \"utf8: invalid source encoding\";\n\n/**\n * Encodes the given string into UTF-8 byte array.\n * Throws if the source string has invalid UTF-16 encoding.\n */\nexport function encode(s: string): Uint8Array {\n // Calculate result length and allocate output array.\n // encodedLength() also validates string and throws errors,\n // so we don't need repeat validation here.\n const arr = new Uint8Array(encodedLength(s));\n\n let pos = 0;\n for (let i = 0; i < s.length; i++) {\n let c = s.charCodeAt(i);\n if (c < 0x80) {\n arr[pos++] = c;\n } else if (c < 0x800) {\n arr[pos++] = 0xc0 | c >> 6;\n arr[pos++] = 0x80 | c & 0x3f;\n } else if (c < 0xd800) {\n arr[pos++] = 0xe0 | c >> 12;\n arr[pos++] = 0x80 | (c >> 6) & 0x3f;\n arr[pos++] = 0x80 | c & 0x3f;\n } else {\n i++; // get one more character\n c = (c & 0x3ff) << 10;\n c |= s.charCodeAt(i) & 0x3ff;\n c += 0x10000;\n\n arr[pos++] = 0xf0 | c >> 18;\n arr[pos++] = 0x80 | (c >> 12) & 0x3f;\n arr[pos++] = 0x80 | (c >> 6) & 0x3f;\n arr[pos++] = 0x80 | c & 0x3f;\n }\n }\n return arr;\n}\n\n/**\n * Returns the number of bytes required to encode the given string into UTF-8.\n * Throws if the source string has invalid UTF-16 encoding.\n */\nexport function encodedLength(s: string): number {\n let result = 0;\n for (let i = 0; i < s.length; i++) {\n const c = s.charCodeAt(i);\n if (c < 0x80) {\n result += 1;\n } else if (c < 0x800) {\n result += 2;\n } else if (c < 0xd800) {\n result += 3;\n } else if (c <= 0xdfff) {\n if (i >= s.length - 1) {\n throw new Error(INVALID_UTF16);\n }\n i++; // \"eat\" next character\n result += 4;\n } else {\n throw new Error(INVALID_UTF16);\n }\n }\n return result;\n}\n\n/**\n * Decodes the given byte array from UTF-8 into a string.\n * Throws if encoding is invalid.\n */\nexport function decode(arr: Uint8Array): string {\n const chars: string[] = [];\n for (let i = 0; i < arr.length; i++) {\n let b = arr[i];\n\n if (b & 0x80) {\n let min;\n if (b < 0xe0) {\n // Need 1 more byte.\n if (i >= arr.length) {\n throw new Error(INVALID_UTF8);\n }\n const n1 = arr[++i];\n if ((n1 & 0xc0) !== 0x80) {\n throw new Error(INVALID_UTF8);\n }\n b = (b & 0x1f) << 6 | (n1 & 0x3f);\n min = 0x80;\n } else if (b < 0xf0) {\n // Need 2 more bytes.\n if (i >= arr.length - 1) {\n throw new Error(INVALID_UTF8);\n }\n const n1 = arr[++i];\n const n2 = arr[++i];\n if ((n1 & 0xc0) !== 0x80 || (n2 & 0xc0) !== 0x80) {\n throw new Error(INVALID_UTF8);\n }\n b = (b & 0x0f) << 12 | (n1 & 0x3f) << 6 | (n2 & 0x3f);\n min = 0x800;\n } else if (b < 0xf8) {\n // Need 3 more bytes.\n if (i >= arr.length - 2) {\n throw new Error(INVALID_UTF8);\n }\n const n1 = arr[++i];\n const n2 = arr[++i];\n const n3 = arr[++i];\n if ((n1 & 0xc0) !== 0x80 || (n2 & 0xc0) !== 0x80 || (n3 & 0xc0) !== 0x80) {\n throw new Error(INVALID_UTF8);\n }\n b = (b & 0x0f) << 18 | (n1 & 0x3f) << 12 | (n2 & 0x3f) << 6 | (n3 & 0x3f);\n min = 0x10000;\n } else {\n throw new Error(INVALID_UTF8);\n }\n\n if (b < min || (b >= 0xd800 && b <= 0xdfff)) {\n throw new Error(INVALID_UTF8);\n }\n\n if (b >= 0x10000) {\n // Surrogate pair.\n if (b > 0x10ffff) {\n throw new Error(INVALID_UTF8);\n }\n b -= 0x10000;\n chars.push(String.fromCharCode(0xd800 | (b >> 10)));\n b = 0xdc00 | (b & 0x3ff);\n }\n }\n\n chars.push(String.fromCharCode(b));\n }\n return chars.join(\"\");\n}\n","(function(nacl) {\n'use strict';\n\n// Ported in 2014 by Dmitry Chestnykh and Devi Mandiri.\n// Public domain.\n//\n// Implementation derived from TweetNaCl version 20140427.\n// See for details: http://tweetnacl.cr.yp.to/\n\nvar gf = function(init) {\n var i, r = new Float64Array(16);\n if (init) for (i = 0; i < init.length; i++) r[i] = init[i];\n return r;\n};\n\n// Pluggable, initialized in high-level API below.\nvar randombytes = function(/* x, n */) { throw new Error('no PRNG'); };\n\nvar _0 = new Uint8Array(16);\nvar _9 = new Uint8Array(32); _9[0] = 9;\n\nvar gf0 = gf(),\n gf1 = gf([1]),\n _121665 = gf([0xdb41, 1]),\n D = gf([0x78a3, 0x1359, 0x4dca, 0x75eb, 0xd8ab, 0x4141, 0x0a4d, 0x0070, 0xe898, 0x7779, 0x4079, 0x8cc7, 0xfe73, 0x2b6f, 0x6cee, 0x5203]),\n D2 = gf([0xf159, 0x26b2, 0x9b94, 0xebd6, 0xb156, 0x8283, 0x149a, 0x00e0, 0xd130, 0xeef3, 0x80f2, 0x198e, 0xfce7, 0x56df, 0xd9dc, 0x2406]),\n X = gf([0xd51a, 0x8f25, 0x2d60, 0xc956, 0xa7b2, 0x9525, 0xc760, 0x692c, 0xdc5c, 0xfdd6, 0xe231, 0xc0a4, 0x53fe, 0xcd6e, 0x36d3, 0x2169]),\n Y = gf([0x6658, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666]),\n I = gf([0xa0b0, 0x4a0e, 0x1b27, 0xc4ee, 0xe478, 0xad2f, 0x1806, 0x2f43, 0xd7a7, 0x3dfb, 0x0099, 0x2b4d, 0xdf0b, 0x4fc1, 0x2480, 0x2b83]);\n\nfunction ts64(x, i, h, l) {\n x[i] = (h >> 24) & 0xff;\n x[i+1] = (h >> 16) & 0xff;\n x[i+2] = (h >> 8) & 0xff;\n x[i+3] = h & 0xff;\n x[i+4] = (l >> 24) & 0xff;\n x[i+5] = (l >> 16) & 0xff;\n x[i+6] = (l >> 8) & 0xff;\n x[i+7] = l & 0xff;\n}\n\nfunction vn(x, xi, y, yi, n) {\n var i,d = 0;\n for (i = 0; i < n; i++) d |= x[xi+i]^y[yi+i];\n return (1 & ((d - 1) >>> 8)) - 1;\n}\n\nfunction crypto_verify_16(x, xi, y, yi) {\n return vn(x,xi,y,yi,16);\n}\n\nfunction crypto_verify_32(x, xi, y, yi) {\n return vn(x,xi,y,yi,32);\n}\n\nfunction core_salsa20(o, p, k, c) {\n var j0 = c[ 0] & 0xff | (c[ 1] & 0xff)<<8 | (c[ 2] & 0xff)<<16 | (c[ 3] & 0xff)<<24,\n j1 = k[ 0] & 0xff | (k[ 1] & 0xff)<<8 | (k[ 2] & 0xff)<<16 | (k[ 3] & 0xff)<<24,\n j2 = k[ 4] & 0xff | (k[ 5] & 0xff)<<8 | (k[ 6] & 0xff)<<16 | (k[ 7] & 0xff)<<24,\n j3 = k[ 8] & 0xff | (k[ 9] & 0xff)<<8 | (k[10] & 0xff)<<16 | (k[11] & 0xff)<<24,\n j4 = k[12] & 0xff | (k[13] & 0xff)<<8 | (k[14] & 0xff)<<16 | (k[15] & 0xff)<<24,\n j5 = c[ 4] & 0xff | (c[ 5] & 0xff)<<8 | (c[ 6] & 0xff)<<16 | (c[ 7] & 0xff)<<24,\n j6 = p[ 0] & 0xff | (p[ 1] & 0xff)<<8 | (p[ 2] & 0xff)<<16 | (p[ 3] & 0xff)<<24,\n j7 = p[ 4] & 0xff | (p[ 5] & 0xff)<<8 | (p[ 6] & 0xff)<<16 | (p[ 7] & 0xff)<<24,\n j8 = p[ 8] & 0xff | (p[ 9] & 0xff)<<8 | (p[10] & 0xff)<<16 | (p[11] & 0xff)<<24,\n j9 = p[12] & 0xff | (p[13] & 0xff)<<8 | (p[14] & 0xff)<<16 | (p[15] & 0xff)<<24,\n j10 = c[ 8] & 0xff | (c[ 9] & 0xff)<<8 | (c[10] & 0xff)<<16 | (c[11] & 0xff)<<24,\n j11 = k[16] & 0xff | (k[17] & 0xff)<<8 | (k[18] & 0xff)<<16 | (k[19] & 0xff)<<24,\n j12 = k[20] & 0xff | (k[21] & 0xff)<<8 | (k[22] & 0xff)<<16 | (k[23] & 0xff)<<24,\n j13 = k[24] & 0xff | (k[25] & 0xff)<<8 | (k[26] & 0xff)<<16 | (k[27] & 0xff)<<24,\n j14 = k[28] & 0xff | (k[29] & 0xff)<<8 | (k[30] & 0xff)<<16 | (k[31] & 0xff)<<24,\n j15 = c[12] & 0xff | (c[13] & 0xff)<<8 | (c[14] & 0xff)<<16 | (c[15] & 0xff)<<24;\n\n var x0 = j0, x1 = j1, x2 = j2, x3 = j3, x4 = j4, x5 = j5, x6 = j6, x7 = j7,\n x8 = j8, x9 = j9, x10 = j10, x11 = j11, x12 = j12, x13 = j13, x14 = j14,\n x15 = j15, u;\n\n for (var i = 0; i < 20; i += 2) {\n u = x0 + x12 | 0;\n x4 ^= u<<7 | u>>>(32-7);\n u = x4 + x0 | 0;\n x8 ^= u<<9 | u>>>(32-9);\n u = x8 + x4 | 0;\n x12 ^= u<<13 | u>>>(32-13);\n u = x12 + x8 | 0;\n x0 ^= u<<18 | u>>>(32-18);\n\n u = x5 + x1 | 0;\n x9 ^= u<<7 | u>>>(32-7);\n u = x9 + x5 | 0;\n x13 ^= u<<9 | u>>>(32-9);\n u = x13 + x9 | 0;\n x1 ^= u<<13 | u>>>(32-13);\n u = x1 + x13 | 0;\n x5 ^= u<<18 | u>>>(32-18);\n\n u = x10 + x6 | 0;\n x14 ^= u<<7 | u>>>(32-7);\n u = x14 + x10 | 0;\n x2 ^= u<<9 | u>>>(32-9);\n u = x2 + x14 | 0;\n x6 ^= u<<13 | u>>>(32-13);\n u = x6 + x2 | 0;\n x10 ^= u<<18 | u>>>(32-18);\n\n u = x15 + x11 | 0;\n x3 ^= u<<7 | u>>>(32-7);\n u = x3 + x15 | 0;\n x7 ^= u<<9 | u>>>(32-9);\n u = x7 + x3 | 0;\n x11 ^= u<<13 | u>>>(32-13);\n u = x11 + x7 | 0;\n x15 ^= u<<18 | u>>>(32-18);\n\n u = x0 + x3 | 0;\n x1 ^= u<<7 | u>>>(32-7);\n u = x1 + x0 | 0;\n x2 ^= u<<9 | u>>>(32-9);\n u = x2 + x1 | 0;\n x3 ^= u<<13 | u>>>(32-13);\n u = x3 + x2 | 0;\n x0 ^= u<<18 | u>>>(32-18);\n\n u = x5 + x4 | 0;\n x6 ^= u<<7 | u>>>(32-7);\n u = x6 + x5 | 0;\n x7 ^= u<<9 | u>>>(32-9);\n u = x7 + x6 | 0;\n x4 ^= u<<13 | u>>>(32-13);\n u = x4 + x7 | 0;\n x5 ^= u<<18 | u>>>(32-18);\n\n u = x10 + x9 | 0;\n x11 ^= u<<7 | u>>>(32-7);\n u = x11 + x10 | 0;\n x8 ^= u<<9 | u>>>(32-9);\n u = x8 + x11 | 0;\n x9 ^= u<<13 | u>>>(32-13);\n u = x9 + x8 | 0;\n x10 ^= u<<18 | u>>>(32-18);\n\n u = x15 + x14 | 0;\n x12 ^= u<<7 | u>>>(32-7);\n u = x12 + x15 | 0;\n x13 ^= u<<9 | u>>>(32-9);\n u = x13 + x12 | 0;\n x14 ^= u<<13 | u>>>(32-13);\n u = x14 + x13 | 0;\n x15 ^= u<<18 | u>>>(32-18);\n }\n x0 = x0 + j0 | 0;\n x1 = x1 + j1 | 0;\n x2 = x2 + j2 | 0;\n x3 = x3 + j3 | 0;\n x4 = x4 + j4 | 0;\n x5 = x5 + j5 | 0;\n x6 = x6 + j6 | 0;\n x7 = x7 + j7 | 0;\n x8 = x8 + j8 | 0;\n x9 = x9 + j9 | 0;\n x10 = x10 + j10 | 0;\n x11 = x11 + j11 | 0;\n x12 = x12 + j12 | 0;\n x13 = x13 + j13 | 0;\n x14 = x14 + j14 | 0;\n x15 = x15 + j15 | 0;\n\n o[ 0] = x0 >>> 0 & 0xff;\n o[ 1] = x0 >>> 8 & 0xff;\n o[ 2] = x0 >>> 16 & 0xff;\n o[ 3] = x0 >>> 24 & 0xff;\n\n o[ 4] = x1 >>> 0 & 0xff;\n o[ 5] = x1 >>> 8 & 0xff;\n o[ 6] = x1 >>> 16 & 0xff;\n o[ 7] = x1 >>> 24 & 0xff;\n\n o[ 8] = x2 >>> 0 & 0xff;\n o[ 9] = x2 >>> 8 & 0xff;\n o[10] = x2 >>> 16 & 0xff;\n o[11] = x2 >>> 24 & 0xff;\n\n o[12] = x3 >>> 0 & 0xff;\n o[13] = x3 >>> 8 & 0xff;\n o[14] = x3 >>> 16 & 0xff;\n o[15] = x3 >>> 24 & 0xff;\n\n o[16] = x4 >>> 0 & 0xff;\n o[17] = x4 >>> 8 & 0xff;\n o[18] = x4 >>> 16 & 0xff;\n o[19] = x4 >>> 24 & 0xff;\n\n o[20] = x5 >>> 0 & 0xff;\n o[21] = x5 >>> 8 & 0xff;\n o[22] = x5 >>> 16 & 0xff;\n o[23] = x5 >>> 24 & 0xff;\n\n o[24] = x6 >>> 0 & 0xff;\n o[25] = x6 >>> 8 & 0xff;\n o[26] = x6 >>> 16 & 0xff;\n o[27] = x6 >>> 24 & 0xff;\n\n o[28] = x7 >>> 0 & 0xff;\n o[29] = x7 >>> 8 & 0xff;\n o[30] = x7 >>> 16 & 0xff;\n o[31] = x7 >>> 24 & 0xff;\n\n o[32] = x8 >>> 0 & 0xff;\n o[33] = x8 >>> 8 & 0xff;\n o[34] = x8 >>> 16 & 0xff;\n o[35] = x8 >>> 24 & 0xff;\n\n o[36] = x9 >>> 0 & 0xff;\n o[37] = x9 >>> 8 & 0xff;\n o[38] = x9 >>> 16 & 0xff;\n o[39] = x9 >>> 24 & 0xff;\n\n o[40] = x10 >>> 0 & 0xff;\n o[41] = x10 >>> 8 & 0xff;\n o[42] = x10 >>> 16 & 0xff;\n o[43] = x10 >>> 24 & 0xff;\n\n o[44] = x11 >>> 0 & 0xff;\n o[45] = x11 >>> 8 & 0xff;\n o[46] = x11 >>> 16 & 0xff;\n o[47] = x11 >>> 24 & 0xff;\n\n o[48] = x12 >>> 0 & 0xff;\n o[49] = x12 >>> 8 & 0xff;\n o[50] = x12 >>> 16 & 0xff;\n o[51] = x12 >>> 24 & 0xff;\n\n o[52] = x13 >>> 0 & 0xff;\n o[53] = x13 >>> 8 & 0xff;\n o[54] = x13 >>> 16 & 0xff;\n o[55] = x13 >>> 24 & 0xff;\n\n o[56] = x14 >>> 0 & 0xff;\n o[57] = x14 >>> 8 & 0xff;\n o[58] = x14 >>> 16 & 0xff;\n o[59] = x14 >>> 24 & 0xff;\n\n o[60] = x15 >>> 0 & 0xff;\n o[61] = x15 >>> 8 & 0xff;\n o[62] = x15 >>> 16 & 0xff;\n o[63] = x15 >>> 24 & 0xff;\n}\n\nfunction core_hsalsa20(o,p,k,c) {\n var j0 = c[ 0] & 0xff | (c[ 1] & 0xff)<<8 | (c[ 2] & 0xff)<<16 | (c[ 3] & 0xff)<<24,\n j1 = k[ 0] & 0xff | (k[ 1] & 0xff)<<8 | (k[ 2] & 0xff)<<16 | (k[ 3] & 0xff)<<24,\n j2 = k[ 4] & 0xff | (k[ 5] & 0xff)<<8 | (k[ 6] & 0xff)<<16 | (k[ 7] & 0xff)<<24,\n j3 = k[ 8] & 0xff | (k[ 9] & 0xff)<<8 | (k[10] & 0xff)<<16 | (k[11] & 0xff)<<24,\n j4 = k[12] & 0xff | (k[13] & 0xff)<<8 | (k[14] & 0xff)<<16 | (k[15] & 0xff)<<24,\n j5 = c[ 4] & 0xff | (c[ 5] & 0xff)<<8 | (c[ 6] & 0xff)<<16 | (c[ 7] & 0xff)<<24,\n j6 = p[ 0] & 0xff | (p[ 1] & 0xff)<<8 | (p[ 2] & 0xff)<<16 | (p[ 3] & 0xff)<<24,\n j7 = p[ 4] & 0xff | (p[ 5] & 0xff)<<8 | (p[ 6] & 0xff)<<16 | (p[ 7] & 0xff)<<24,\n j8 = p[ 8] & 0xff | (p[ 9] & 0xff)<<8 | (p[10] & 0xff)<<16 | (p[11] & 0xff)<<24,\n j9 = p[12] & 0xff | (p[13] & 0xff)<<8 | (p[14] & 0xff)<<16 | (p[15] & 0xff)<<24,\n j10 = c[ 8] & 0xff | (c[ 9] & 0xff)<<8 | (c[10] & 0xff)<<16 | (c[11] & 0xff)<<24,\n j11 = k[16] & 0xff | (k[17] & 0xff)<<8 | (k[18] & 0xff)<<16 | (k[19] & 0xff)<<24,\n j12 = k[20] & 0xff | (k[21] & 0xff)<<8 | (k[22] & 0xff)<<16 | (k[23] & 0xff)<<24,\n j13 = k[24] & 0xff | (k[25] & 0xff)<<8 | (k[26] & 0xff)<<16 | (k[27] & 0xff)<<24,\n j14 = k[28] & 0xff | (k[29] & 0xff)<<8 | (k[30] & 0xff)<<16 | (k[31] & 0xff)<<24,\n j15 = c[12] & 0xff | (c[13] & 0xff)<<8 | (c[14] & 0xff)<<16 | (c[15] & 0xff)<<24;\n\n var x0 = j0, x1 = j1, x2 = j2, x3 = j3, x4 = j4, x5 = j5, x6 = j6, x7 = j7,\n x8 = j8, x9 = j9, x10 = j10, x11 = j11, x12 = j12, x13 = j13, x14 = j14,\n x15 = j15, u;\n\n for (var i = 0; i < 20; i += 2) {\n u = x0 + x12 | 0;\n x4 ^= u<<7 | u>>>(32-7);\n u = x4 + x0 | 0;\n x8 ^= u<<9 | u>>>(32-9);\n u = x8 + x4 | 0;\n x12 ^= u<<13 | u>>>(32-13);\n u = x12 + x8 | 0;\n x0 ^= u<<18 | u>>>(32-18);\n\n u = x5 + x1 | 0;\n x9 ^= u<<7 | u>>>(32-7);\n u = x9 + x5 | 0;\n x13 ^= u<<9 | u>>>(32-9);\n u = x13 + x9 | 0;\n x1 ^= u<<13 | u>>>(32-13);\n u = x1 + x13 | 0;\n x5 ^= u<<18 | u>>>(32-18);\n\n u = x10 + x6 | 0;\n x14 ^= u<<7 | u>>>(32-7);\n u = x14 + x10 | 0;\n x2 ^= u<<9 | u>>>(32-9);\n u = x2 + x14 | 0;\n x6 ^= u<<13 | u>>>(32-13);\n u = x6 + x2 | 0;\n x10 ^= u<<18 | u>>>(32-18);\n\n u = x15 + x11 | 0;\n x3 ^= u<<7 | u>>>(32-7);\n u = x3 + x15 | 0;\n x7 ^= u<<9 | u>>>(32-9);\n u = x7 + x3 | 0;\n x11 ^= u<<13 | u>>>(32-13);\n u = x11 + x7 | 0;\n x15 ^= u<<18 | u>>>(32-18);\n\n u = x0 + x3 | 0;\n x1 ^= u<<7 | u>>>(32-7);\n u = x1 + x0 | 0;\n x2 ^= u<<9 | u>>>(32-9);\n u = x2 + x1 | 0;\n x3 ^= u<<13 | u>>>(32-13);\n u = x3 + x2 | 0;\n x0 ^= u<<18 | u>>>(32-18);\n\n u = x5 + x4 | 0;\n x6 ^= u<<7 | u>>>(32-7);\n u = x6 + x5 | 0;\n x7 ^= u<<9 | u>>>(32-9);\n u = x7 + x6 | 0;\n x4 ^= u<<13 | u>>>(32-13);\n u = x4 + x7 | 0;\n x5 ^= u<<18 | u>>>(32-18);\n\n u = x10 + x9 | 0;\n x11 ^= u<<7 | u>>>(32-7);\n u = x11 + x10 | 0;\n x8 ^= u<<9 | u>>>(32-9);\n u = x8 + x11 | 0;\n x9 ^= u<<13 | u>>>(32-13);\n u = x9 + x8 | 0;\n x10 ^= u<<18 | u>>>(32-18);\n\n u = x15 + x14 | 0;\n x12 ^= u<<7 | u>>>(32-7);\n u = x12 + x15 | 0;\n x13 ^= u<<9 | u>>>(32-9);\n u = x13 + x12 | 0;\n x14 ^= u<<13 | u>>>(32-13);\n u = x14 + x13 | 0;\n x15 ^= u<<18 | u>>>(32-18);\n }\n\n o[ 0] = x0 >>> 0 & 0xff;\n o[ 1] = x0 >>> 8 & 0xff;\n o[ 2] = x0 >>> 16 & 0xff;\n o[ 3] = x0 >>> 24 & 0xff;\n\n o[ 4] = x5 >>> 0 & 0xff;\n o[ 5] = x5 >>> 8 & 0xff;\n o[ 6] = x5 >>> 16 & 0xff;\n o[ 7] = x5 >>> 24 & 0xff;\n\n o[ 8] = x10 >>> 0 & 0xff;\n o[ 9] = x10 >>> 8 & 0xff;\n o[10] = x10 >>> 16 & 0xff;\n o[11] = x10 >>> 24 & 0xff;\n\n o[12] = x15 >>> 0 & 0xff;\n o[13] = x15 >>> 8 & 0xff;\n o[14] = x15 >>> 16 & 0xff;\n o[15] = x15 >>> 24 & 0xff;\n\n o[16] = x6 >>> 0 & 0xff;\n o[17] = x6 >>> 8 & 0xff;\n o[18] = x6 >>> 16 & 0xff;\n o[19] = x6 >>> 24 & 0xff;\n\n o[20] = x7 >>> 0 & 0xff;\n o[21] = x7 >>> 8 & 0xff;\n o[22] = x7 >>> 16 & 0xff;\n o[23] = x7 >>> 24 & 0xff;\n\n o[24] = x8 >>> 0 & 0xff;\n o[25] = x8 >>> 8 & 0xff;\n o[26] = x8 >>> 16 & 0xff;\n o[27] = x8 >>> 24 & 0xff;\n\n o[28] = x9 >>> 0 & 0xff;\n o[29] = x9 >>> 8 & 0xff;\n o[30] = x9 >>> 16 & 0xff;\n o[31] = x9 >>> 24 & 0xff;\n}\n\nfunction crypto_core_salsa20(out,inp,k,c) {\n core_salsa20(out,inp,k,c);\n}\n\nfunction crypto_core_hsalsa20(out,inp,k,c) {\n core_hsalsa20(out,inp,k,c);\n}\n\nvar sigma = new Uint8Array([101, 120, 112, 97, 110, 100, 32, 51, 50, 45, 98, 121, 116, 101, 32, 107]);\n // \"expand 32-byte k\"\n\nfunction crypto_stream_salsa20_xor(c,cpos,m,mpos,b,n,k) {\n var z = new Uint8Array(16), x = new Uint8Array(64);\n var u, i;\n for (i = 0; i < 16; i++) z[i] = 0;\n for (i = 0; i < 8; i++) z[i] = n[i];\n while (b >= 64) {\n crypto_core_salsa20(x,z,k,sigma);\n for (i = 0; i < 64; i++) c[cpos+i] = m[mpos+i] ^ x[i];\n u = 1;\n for (i = 8; i < 16; i++) {\n u = u + (z[i] & 0xff) | 0;\n z[i] = u & 0xff;\n u >>>= 8;\n }\n b -= 64;\n cpos += 64;\n mpos += 64;\n }\n if (b > 0) {\n crypto_core_salsa20(x,z,k,sigma);\n for (i = 0; i < b; i++) c[cpos+i] = m[mpos+i] ^ x[i];\n }\n return 0;\n}\n\nfunction crypto_stream_salsa20(c,cpos,b,n,k) {\n var z = new Uint8Array(16), x = new Uint8Array(64);\n var u, i;\n for (i = 0; i < 16; i++) z[i] = 0;\n for (i = 0; i < 8; i++) z[i] = n[i];\n while (b >= 64) {\n crypto_core_salsa20(x,z,k,sigma);\n for (i = 0; i < 64; i++) c[cpos+i] = x[i];\n u = 1;\n for (i = 8; i < 16; i++) {\n u = u + (z[i] & 0xff) | 0;\n z[i] = u & 0xff;\n u >>>= 8;\n }\n b -= 64;\n cpos += 64;\n }\n if (b > 0) {\n crypto_core_salsa20(x,z,k,sigma);\n for (i = 0; i < b; i++) c[cpos+i] = x[i];\n }\n return 0;\n}\n\nfunction crypto_stream(c,cpos,d,n,k) {\n var s = new Uint8Array(32);\n crypto_core_hsalsa20(s,n,k,sigma);\n var sn = new Uint8Array(8);\n for (var i = 0; i < 8; i++) sn[i] = n[i+16];\n return crypto_stream_salsa20(c,cpos,d,sn,s);\n}\n\nfunction crypto_stream_xor(c,cpos,m,mpos,d,n,k) {\n var s = new Uint8Array(32);\n crypto_core_hsalsa20(s,n,k,sigma);\n var sn = new Uint8Array(8);\n for (var i = 0; i < 8; i++) sn[i] = n[i+16];\n return crypto_stream_salsa20_xor(c,cpos,m,mpos,d,sn,s);\n}\n\n/*\n* Port of Andrew Moon's Poly1305-donna-16. Public domain.\n* https://github.com/floodyberry/poly1305-donna\n*/\n\nvar poly1305 = function(key) {\n this.buffer = new Uint8Array(16);\n this.r = new Uint16Array(10);\n this.h = new Uint16Array(10);\n this.pad = new Uint16Array(8);\n this.leftover = 0;\n this.fin = 0;\n\n var t0, t1, t2, t3, t4, t5, t6, t7;\n\n t0 = key[ 0] & 0xff | (key[ 1] & 0xff) << 8; this.r[0] = ( t0 ) & 0x1fff;\n t1 = key[ 2] & 0xff | (key[ 3] & 0xff) << 8; this.r[1] = ((t0 >>> 13) | (t1 << 3)) & 0x1fff;\n t2 = key[ 4] & 0xff | (key[ 5] & 0xff) << 8; this.r[2] = ((t1 >>> 10) | (t2 << 6)) & 0x1f03;\n t3 = key[ 6] & 0xff | (key[ 7] & 0xff) << 8; this.r[3] = ((t2 >>> 7) | (t3 << 9)) & 0x1fff;\n t4 = key[ 8] & 0xff | (key[ 9] & 0xff) << 8; this.r[4] = ((t3 >>> 4) | (t4 << 12)) & 0x00ff;\n this.r[5] = ((t4 >>> 1)) & 0x1ffe;\n t5 = key[10] & 0xff | (key[11] & 0xff) << 8; this.r[6] = ((t4 >>> 14) | (t5 << 2)) & 0x1fff;\n t6 = key[12] & 0xff | (key[13] & 0xff) << 8; this.r[7] = ((t5 >>> 11) | (t6 << 5)) & 0x1f81;\n t7 = key[14] & 0xff | (key[15] & 0xff) << 8; this.r[8] = ((t6 >>> 8) | (t7 << 8)) & 0x1fff;\n this.r[9] = ((t7 >>> 5)) & 0x007f;\n\n this.pad[0] = key[16] & 0xff | (key[17] & 0xff) << 8;\n this.pad[1] = key[18] & 0xff | (key[19] & 0xff) << 8;\n this.pad[2] = key[20] & 0xff | (key[21] & 0xff) << 8;\n this.pad[3] = key[22] & 0xff | (key[23] & 0xff) << 8;\n this.pad[4] = key[24] & 0xff | (key[25] & 0xff) << 8;\n this.pad[5] = key[26] & 0xff | (key[27] & 0xff) << 8;\n this.pad[6] = key[28] & 0xff | (key[29] & 0xff) << 8;\n this.pad[7] = key[30] & 0xff | (key[31] & 0xff) << 8;\n};\n\npoly1305.prototype.blocks = function(m, mpos, bytes) {\n var hibit = this.fin ? 0 : (1 << 11);\n var t0, t1, t2, t3, t4, t5, t6, t7, c;\n var d0, d1, d2, d3, d4, d5, d6, d7, d8, d9;\n\n var h0 = this.h[0],\n h1 = this.h[1],\n h2 = this.h[2],\n h3 = this.h[3],\n h4 = this.h[4],\n h5 = this.h[5],\n h6 = this.h[6],\n h7 = this.h[7],\n h8 = this.h[8],\n h9 = this.h[9];\n\n var r0 = this.r[0],\n r1 = this.r[1],\n r2 = this.r[2],\n r3 = this.r[3],\n r4 = this.r[4],\n r5 = this.r[5],\n r6 = this.r[6],\n r7 = this.r[7],\n r8 = this.r[8],\n r9 = this.r[9];\n\n while (bytes >= 16) {\n t0 = m[mpos+ 0] & 0xff | (m[mpos+ 1] & 0xff) << 8; h0 += ( t0 ) & 0x1fff;\n t1 = m[mpos+ 2] & 0xff | (m[mpos+ 3] & 0xff) << 8; h1 += ((t0 >>> 13) | (t1 << 3)) & 0x1fff;\n t2 = m[mpos+ 4] & 0xff | (m[mpos+ 5] & 0xff) << 8; h2 += ((t1 >>> 10) | (t2 << 6)) & 0x1fff;\n t3 = m[mpos+ 6] & 0xff | (m[mpos+ 7] & 0xff) << 8; h3 += ((t2 >>> 7) | (t3 << 9)) & 0x1fff;\n t4 = m[mpos+ 8] & 0xff | (m[mpos+ 9] & 0xff) << 8; h4 += ((t3 >>> 4) | (t4 << 12)) & 0x1fff;\n h5 += ((t4 >>> 1)) & 0x1fff;\n t5 = m[mpos+10] & 0xff | (m[mpos+11] & 0xff) << 8; h6 += ((t4 >>> 14) | (t5 << 2)) & 0x1fff;\n t6 = m[mpos+12] & 0xff | (m[mpos+13] & 0xff) << 8; h7 += ((t5 >>> 11) | (t6 << 5)) & 0x1fff;\n t7 = m[mpos+14] & 0xff | (m[mpos+15] & 0xff) << 8; h8 += ((t6 >>> 8) | (t7 << 8)) & 0x1fff;\n h9 += ((t7 >>> 5)) | hibit;\n\n c = 0;\n\n d0 = c;\n d0 += h0 * r0;\n d0 += h1 * (5 * r9);\n d0 += h2 * (5 * r8);\n d0 += h3 * (5 * r7);\n d0 += h4 * (5 * r6);\n c = (d0 >>> 13); d0 &= 0x1fff;\n d0 += h5 * (5 * r5);\n d0 += h6 * (5 * r4);\n d0 += h7 * (5 * r3);\n d0 += h8 * (5 * r2);\n d0 += h9 * (5 * r1);\n c += (d0 >>> 13); d0 &= 0x1fff;\n\n d1 = c;\n d1 += h0 * r1;\n d1 += h1 * r0;\n d1 += h2 * (5 * r9);\n d1 += h3 * (5 * r8);\n d1 += h4 * (5 * r7);\n c = (d1 >>> 13); d1 &= 0x1fff;\n d1 += h5 * (5 * r6);\n d1 += h6 * (5 * r5);\n d1 += h7 * (5 * r4);\n d1 += h8 * (5 * r3);\n d1 += h9 * (5 * r2);\n c += (d1 >>> 13); d1 &= 0x1fff;\n\n d2 = c;\n d2 += h0 * r2;\n d2 += h1 * r1;\n d2 += h2 * r0;\n d2 += h3 * (5 * r9);\n d2 += h4 * (5 * r8);\n c = (d2 >>> 13); d2 &= 0x1fff;\n d2 += h5 * (5 * r7);\n d2 += h6 * (5 * r6);\n d2 += h7 * (5 * r5);\n d2 += h8 * (5 * r4);\n d2 += h9 * (5 * r3);\n c += (d2 >>> 13); d2 &= 0x1fff;\n\n d3 = c;\n d3 += h0 * r3;\n d3 += h1 * r2;\n d3 += h2 * r1;\n d3 += h3 * r0;\n d3 += h4 * (5 * r9);\n c = (d3 >>> 13); d3 &= 0x1fff;\n d3 += h5 * (5 * r8);\n d3 += h6 * (5 * r7);\n d3 += h7 * (5 * r6);\n d3 += h8 * (5 * r5);\n d3 += h9 * (5 * r4);\n c += (d3 >>> 13); d3 &= 0x1fff;\n\n d4 = c;\n d4 += h0 * r4;\n d4 += h1 * r3;\n d4 += h2 * r2;\n d4 += h3 * r1;\n d4 += h4 * r0;\n c = (d4 >>> 13); d4 &= 0x1fff;\n d4 += h5 * (5 * r9);\n d4 += h6 * (5 * r8);\n d4 += h7 * (5 * r7);\n d4 += h8 * (5 * r6);\n d4 += h9 * (5 * r5);\n c += (d4 >>> 13); d4 &= 0x1fff;\n\n d5 = c;\n d5 += h0 * r5;\n d5 += h1 * r4;\n d5 += h2 * r3;\n d5 += h3 * r2;\n d5 += h4 * r1;\n c = (d5 >>> 13); d5 &= 0x1fff;\n d5 += h5 * r0;\n d5 += h6 * (5 * r9);\n d5 += h7 * (5 * r8);\n d5 += h8 * (5 * r7);\n d5 += h9 * (5 * r6);\n c += (d5 >>> 13); d5 &= 0x1fff;\n\n d6 = c;\n d6 += h0 * r6;\n d6 += h1 * r5;\n d6 += h2 * r4;\n d6 += h3 * r3;\n d6 += h4 * r2;\n c = (d6 >>> 13); d6 &= 0x1fff;\n d6 += h5 * r1;\n d6 += h6 * r0;\n d6 += h7 * (5 * r9);\n d6 += h8 * (5 * r8);\n d6 += h9 * (5 * r7);\n c += (d6 >>> 13); d6 &= 0x1fff;\n\n d7 = c;\n d7 += h0 * r7;\n d7 += h1 * r6;\n d7 += h2 * r5;\n d7 += h3 * r4;\n d7 += h4 * r3;\n c = (d7 >>> 13); d7 &= 0x1fff;\n d7 += h5 * r2;\n d7 += h6 * r1;\n d7 += h7 * r0;\n d7 += h8 * (5 * r9);\n d7 += h9 * (5 * r8);\n c += (d7 >>> 13); d7 &= 0x1fff;\n\n d8 = c;\n d8 += h0 * r8;\n d8 += h1 * r7;\n d8 += h2 * r6;\n d8 += h3 * r5;\n d8 += h4 * r4;\n c = (d8 >>> 13); d8 &= 0x1fff;\n d8 += h5 * r3;\n d8 += h6 * r2;\n d8 += h7 * r1;\n d8 += h8 * r0;\n d8 += h9 * (5 * r9);\n c += (d8 >>> 13); d8 &= 0x1fff;\n\n d9 = c;\n d9 += h0 * r9;\n d9 += h1 * r8;\n d9 += h2 * r7;\n d9 += h3 * r6;\n d9 += h4 * r5;\n c = (d9 >>> 13); d9 &= 0x1fff;\n d9 += h5 * r4;\n d9 += h6 * r3;\n d9 += h7 * r2;\n d9 += h8 * r1;\n d9 += h9 * r0;\n c += (d9 >>> 13); d9 &= 0x1fff;\n\n c = (((c << 2) + c)) | 0;\n c = (c + d0) | 0;\n d0 = c & 0x1fff;\n c = (c >>> 13);\n d1 += c;\n\n h0 = d0;\n h1 = d1;\n h2 = d2;\n h3 = d3;\n h4 = d4;\n h5 = d5;\n h6 = d6;\n h7 = d7;\n h8 = d8;\n h9 = d9;\n\n mpos += 16;\n bytes -= 16;\n }\n this.h[0] = h0;\n this.h[1] = h1;\n this.h[2] = h2;\n this.h[3] = h3;\n this.h[4] = h4;\n this.h[5] = h5;\n this.h[6] = h6;\n this.h[7] = h7;\n this.h[8] = h8;\n this.h[9] = h9;\n};\n\npoly1305.prototype.finish = function(mac, macpos) {\n var g = new Uint16Array(10);\n var c, mask, f, i;\n\n if (this.leftover) {\n i = this.leftover;\n this.buffer[i++] = 1;\n for (; i < 16; i++) this.buffer[i] = 0;\n this.fin = 1;\n this.blocks(this.buffer, 0, 16);\n }\n\n c = this.h[1] >>> 13;\n this.h[1] &= 0x1fff;\n for (i = 2; i < 10; i++) {\n this.h[i] += c;\n c = this.h[i] >>> 13;\n this.h[i] &= 0x1fff;\n }\n this.h[0] += (c * 5);\n c = this.h[0] >>> 13;\n this.h[0] &= 0x1fff;\n this.h[1] += c;\n c = this.h[1] >>> 13;\n this.h[1] &= 0x1fff;\n this.h[2] += c;\n\n g[0] = this.h[0] + 5;\n c = g[0] >>> 13;\n g[0] &= 0x1fff;\n for (i = 1; i < 10; i++) {\n g[i] = this.h[i] + c;\n c = g[i] >>> 13;\n g[i] &= 0x1fff;\n }\n g[9] -= (1 << 13);\n\n mask = (c ^ 1) - 1;\n for (i = 0; i < 10; i++) g[i] &= mask;\n mask = ~mask;\n for (i = 0; i < 10; i++) this.h[i] = (this.h[i] & mask) | g[i];\n\n this.h[0] = ((this.h[0] ) | (this.h[1] << 13) ) & 0xffff;\n this.h[1] = ((this.h[1] >>> 3) | (this.h[2] << 10) ) & 0xffff;\n this.h[2] = ((this.h[2] >>> 6) | (this.h[3] << 7) ) & 0xffff;\n this.h[3] = ((this.h[3] >>> 9) | (this.h[4] << 4) ) & 0xffff;\n this.h[4] = ((this.h[4] >>> 12) | (this.h[5] << 1) | (this.h[6] << 14)) & 0xffff;\n this.h[5] = ((this.h[6] >>> 2) | (this.h[7] << 11) ) & 0xffff;\n this.h[6] = ((this.h[7] >>> 5) | (this.h[8] << 8) ) & 0xffff;\n this.h[7] = ((this.h[8] >>> 8) | (this.h[9] << 5) ) & 0xffff;\n\n f = this.h[0] + this.pad[0];\n this.h[0] = f & 0xffff;\n for (i = 1; i < 8; i++) {\n f = (((this.h[i] + this.pad[i]) | 0) + (f >>> 16)) | 0;\n this.h[i] = f & 0xffff;\n }\n\n mac[macpos+ 0] = (this.h[0] >>> 0) & 0xff;\n mac[macpos+ 1] = (this.h[0] >>> 8) & 0xff;\n mac[macpos+ 2] = (this.h[1] >>> 0) & 0xff;\n mac[macpos+ 3] = (this.h[1] >>> 8) & 0xff;\n mac[macpos+ 4] = (this.h[2] >>> 0) & 0xff;\n mac[macpos+ 5] = (this.h[2] >>> 8) & 0xff;\n mac[macpos+ 6] = (this.h[3] >>> 0) & 0xff;\n mac[macpos+ 7] = (this.h[3] >>> 8) & 0xff;\n mac[macpos+ 8] = (this.h[4] >>> 0) & 0xff;\n mac[macpos+ 9] = (this.h[4] >>> 8) & 0xff;\n mac[macpos+10] = (this.h[5] >>> 0) & 0xff;\n mac[macpos+11] = (this.h[5] >>> 8) & 0xff;\n mac[macpos+12] = (this.h[6] >>> 0) & 0xff;\n mac[macpos+13] = (this.h[6] >>> 8) & 0xff;\n mac[macpos+14] = (this.h[7] >>> 0) & 0xff;\n mac[macpos+15] = (this.h[7] >>> 8) & 0xff;\n};\n\npoly1305.prototype.update = function(m, mpos, bytes) {\n var i, want;\n\n if (this.leftover) {\n want = (16 - this.leftover);\n if (want > bytes)\n want = bytes;\n for (i = 0; i < want; i++)\n this.buffer[this.leftover + i] = m[mpos+i];\n bytes -= want;\n mpos += want;\n this.leftover += want;\n if (this.leftover < 16)\n return;\n this.blocks(this.buffer, 0, 16);\n this.leftover = 0;\n }\n\n if (bytes >= 16) {\n want = bytes - (bytes % 16);\n this.blocks(m, mpos, want);\n mpos += want;\n bytes -= want;\n }\n\n if (bytes) {\n for (i = 0; i < bytes; i++)\n this.buffer[this.leftover + i] = m[mpos+i];\n this.leftover += bytes;\n }\n};\n\nfunction crypto_onetimeauth(out, outpos, m, mpos, n, k) {\n var s = new poly1305(k);\n s.update(m, mpos, n);\n s.finish(out, outpos);\n return 0;\n}\n\nfunction crypto_onetimeauth_verify(h, hpos, m, mpos, n, k) {\n var x = new Uint8Array(16);\n crypto_onetimeauth(x,0,m,mpos,n,k);\n return crypto_verify_16(h,hpos,x,0);\n}\n\nfunction crypto_secretbox(c,m,d,n,k) {\n var i;\n if (d < 32) return -1;\n crypto_stream_xor(c,0,m,0,d,n,k);\n crypto_onetimeauth(c, 16, c, 32, d - 32, c);\n for (i = 0; i < 16; i++) c[i] = 0;\n return 0;\n}\n\nfunction crypto_secretbox_open(m,c,d,n,k) {\n var i;\n var x = new Uint8Array(32);\n if (d < 32) return -1;\n crypto_stream(x,0,32,n,k);\n if (crypto_onetimeauth_verify(c, 16,c, 32,d - 32,x) !== 0) return -1;\n crypto_stream_xor(m,0,c,0,d,n,k);\n for (i = 0; i < 32; i++) m[i] = 0;\n return 0;\n}\n\nfunction set25519(r, a) {\n var i;\n for (i = 0; i < 16; i++) r[i] = a[i]|0;\n}\n\nfunction car25519(o) {\n var i, v, c = 1;\n for (i = 0; i < 16; i++) {\n v = o[i] + c + 65535;\n c = Math.floor(v / 65536);\n o[i] = v - c * 65536;\n }\n o[0] += c-1 + 37 * (c-1);\n}\n\nfunction sel25519(p, q, b) {\n var t, c = ~(b-1);\n for (var i = 0; i < 16; i++) {\n t = c & (p[i] ^ q[i]);\n p[i] ^= t;\n q[i] ^= t;\n }\n}\n\nfunction pack25519(o, n) {\n var i, j, b;\n var m = gf(), t = gf();\n for (i = 0; i < 16; i++) t[i] = n[i];\n car25519(t);\n car25519(t);\n car25519(t);\n for (j = 0; j < 2; j++) {\n m[0] = t[0] - 0xffed;\n for (i = 1; i < 15; i++) {\n m[i] = t[i] - 0xffff - ((m[i-1]>>16) & 1);\n m[i-1] &= 0xffff;\n }\n m[15] = t[15] - 0x7fff - ((m[14]>>16) & 1);\n b = (m[15]>>16) & 1;\n m[14] &= 0xffff;\n sel25519(t, m, 1-b);\n }\n for (i = 0; i < 16; i++) {\n o[2*i] = t[i] & 0xff;\n o[2*i+1] = t[i]>>8;\n }\n}\n\nfunction neq25519(a, b) {\n var c = new Uint8Array(32), d = new Uint8Array(32);\n pack25519(c, a);\n pack25519(d, b);\n return crypto_verify_32(c, 0, d, 0);\n}\n\nfunction par25519(a) {\n var d = new Uint8Array(32);\n pack25519(d, a);\n return d[0] & 1;\n}\n\nfunction unpack25519(o, n) {\n var i;\n for (i = 0; i < 16; i++) o[i] = n[2*i] + (n[2*i+1] << 8);\n o[15] &= 0x7fff;\n}\n\nfunction A(o, a, b) {\n for (var i = 0; i < 16; i++) o[i] = a[i] + b[i];\n}\n\nfunction Z(o, a, b) {\n for (var i = 0; i < 16; i++) o[i] = a[i] - b[i];\n}\n\nfunction M(o, a, b) {\n var v, c,\n t0 = 0, t1 = 0, t2 = 0, t3 = 0, t4 = 0, t5 = 0, t6 = 0, t7 = 0,\n t8 = 0, t9 = 0, t10 = 0, t11 = 0, t12 = 0, t13 = 0, t14 = 0, t15 = 0,\n t16 = 0, t17 = 0, t18 = 0, t19 = 0, t20 = 0, t21 = 0, t22 = 0, t23 = 0,\n t24 = 0, t25 = 0, t26 = 0, t27 = 0, t28 = 0, t29 = 0, t30 = 0,\n b0 = b[0],\n b1 = b[1],\n b2 = b[2],\n b3 = b[3],\n b4 = b[4],\n b5 = b[5],\n b6 = b[6],\n b7 = b[7],\n b8 = b[8],\n b9 = b[9],\n b10 = b[10],\n b11 = b[11],\n b12 = b[12],\n b13 = b[13],\n b14 = b[14],\n b15 = b[15];\n\n v = a[0];\n t0 += v * b0;\n t1 += v * b1;\n t2 += v * b2;\n t3 += v * b3;\n t4 += v * b4;\n t5 += v * b5;\n t6 += v * b6;\n t7 += v * b7;\n t8 += v * b8;\n t9 += v * b9;\n t10 += v * b10;\n t11 += v * b11;\n t12 += v * b12;\n t13 += v * b13;\n t14 += v * b14;\n t15 += v * b15;\n v = a[1];\n t1 += v * b0;\n t2 += v * b1;\n t3 += v * b2;\n t4 += v * b3;\n t5 += v * b4;\n t6 += v * b5;\n t7 += v * b6;\n t8 += v * b7;\n t9 += v * b8;\n t10 += v * b9;\n t11 += v * b10;\n t12 += v * b11;\n t13 += v * b12;\n t14 += v * b13;\n t15 += v * b14;\n t16 += v * b15;\n v = a[2];\n t2 += v * b0;\n t3 += v * b1;\n t4 += v * b2;\n t5 += v * b3;\n t6 += v * b4;\n t7 += v * b5;\n t8 += v * b6;\n t9 += v * b7;\n t10 += v * b8;\n t11 += v * b9;\n t12 += v * b10;\n t13 += v * b11;\n t14 += v * b12;\n t15 += v * b13;\n t16 += v * b14;\n t17 += v * b15;\n v = a[3];\n t3 += v * b0;\n t4 += v * b1;\n t5 += v * b2;\n t6 += v * b3;\n t7 += v * b4;\n t8 += v * b5;\n t9 += v * b6;\n t10 += v * b7;\n t11 += v * b8;\n t12 += v * b9;\n t13 += v * b10;\n t14 += v * b11;\n t15 += v * b12;\n t16 += v * b13;\n t17 += v * b14;\n t18 += v * b15;\n v = a[4];\n t4 += v * b0;\n t5 += v * b1;\n t6 += v * b2;\n t7 += v * b3;\n t8 += v * b4;\n t9 += v * b5;\n t10 += v * b6;\n t11 += v * b7;\n t12 += v * b8;\n t13 += v * b9;\n t14 += v * b10;\n t15 += v * b11;\n t16 += v * b12;\n t17 += v * b13;\n t18 += v * b14;\n t19 += v * b15;\n v = a[5];\n t5 += v * b0;\n t6 += v * b1;\n t7 += v * b2;\n t8 += v * b3;\n t9 += v * b4;\n t10 += v * b5;\n t11 += v * b6;\n t12 += v * b7;\n t13 += v * b8;\n t14 += v * b9;\n t15 += v * b10;\n t16 += v * b11;\n t17 += v * b12;\n t18 += v * b13;\n t19 += v * b14;\n t20 += v * b15;\n v = a[6];\n t6 += v * b0;\n t7 += v * b1;\n t8 += v * b2;\n t9 += v * b3;\n t10 += v * b4;\n t11 += v * b5;\n t12 += v * b6;\n t13 += v * b7;\n t14 += v * b8;\n t15 += v * b9;\n t16 += v * b10;\n t17 += v * b11;\n t18 += v * b12;\n t19 += v * b13;\n t20 += v * b14;\n t21 += v * b15;\n v = a[7];\n t7 += v * b0;\n t8 += v * b1;\n t9 += v * b2;\n t10 += v * b3;\n t11 += v * b4;\n t12 += v * b5;\n t13 += v * b6;\n t14 += v * b7;\n t15 += v * b8;\n t16 += v * b9;\n t17 += v * b10;\n t18 += v * b11;\n t19 += v * b12;\n t20 += v * b13;\n t21 += v * b14;\n t22 += v * b15;\n v = a[8];\n t8 += v * b0;\n t9 += v * b1;\n t10 += v * b2;\n t11 += v * b3;\n t12 += v * b4;\n t13 += v * b5;\n t14 += v * b6;\n t15 += v * b7;\n t16 += v * b8;\n t17 += v * b9;\n t18 += v * b10;\n t19 += v * b11;\n t20 += v * b12;\n t21 += v * b13;\n t22 += v * b14;\n t23 += v * b15;\n v = a[9];\n t9 += v * b0;\n t10 += v * b1;\n t11 += v * b2;\n t12 += v * b3;\n t13 += v * b4;\n t14 += v * b5;\n t15 += v * b6;\n t16 += v * b7;\n t17 += v * b8;\n t18 += v * b9;\n t19 += v * b10;\n t20 += v * b11;\n t21 += v * b12;\n t22 += v * b13;\n t23 += v * b14;\n t24 += v * b15;\n v = a[10];\n t10 += v * b0;\n t11 += v * b1;\n t12 += v * b2;\n t13 += v * b3;\n t14 += v * b4;\n t15 += v * b5;\n t16 += v * b6;\n t17 += v * b7;\n t18 += v * b8;\n t19 += v * b9;\n t20 += v * b10;\n t21 += v * b11;\n t22 += v * b12;\n t23 += v * b13;\n t24 += v * b14;\n t25 += v * b15;\n v = a[11];\n t11 += v * b0;\n t12 += v * b1;\n t13 += v * b2;\n t14 += v * b3;\n t15 += v * b4;\n t16 += v * b5;\n t17 += v * b6;\n t18 += v * b7;\n t19 += v * b8;\n t20 += v * b9;\n t21 += v * b10;\n t22 += v * b11;\n t23 += v * b12;\n t24 += v * b13;\n t25 += v * b14;\n t26 += v * b15;\n v = a[12];\n t12 += v * b0;\n t13 += v * b1;\n t14 += v * b2;\n t15 += v * b3;\n t16 += v * b4;\n t17 += v * b5;\n t18 += v * b6;\n t19 += v * b7;\n t20 += v * b8;\n t21 += v * b9;\n t22 += v * b10;\n t23 += v * b11;\n t24 += v * b12;\n t25 += v * b13;\n t26 += v * b14;\n t27 += v * b15;\n v = a[13];\n t13 += v * b0;\n t14 += v * b1;\n t15 += v * b2;\n t16 += v * b3;\n t17 += v * b4;\n t18 += v * b5;\n t19 += v * b6;\n t20 += v * b7;\n t21 += v * b8;\n t22 += v * b9;\n t23 += v * b10;\n t24 += v * b11;\n t25 += v * b12;\n t26 += v * b13;\n t27 += v * b14;\n t28 += v * b15;\n v = a[14];\n t14 += v * b0;\n t15 += v * b1;\n t16 += v * b2;\n t17 += v * b3;\n t18 += v * b4;\n t19 += v * b5;\n t20 += v * b6;\n t21 += v * b7;\n t22 += v * b8;\n t23 += v * b9;\n t24 += v * b10;\n t25 += v * b11;\n t26 += v * b12;\n t27 += v * b13;\n t28 += v * b14;\n t29 += v * b15;\n v = a[15];\n t15 += v * b0;\n t16 += v * b1;\n t17 += v * b2;\n t18 += v * b3;\n t19 += v * b4;\n t20 += v * b5;\n t21 += v * b6;\n t22 += v * b7;\n t23 += v * b8;\n t24 += v * b9;\n t25 += v * b10;\n t26 += v * b11;\n t27 += v * b12;\n t28 += v * b13;\n t29 += v * b14;\n t30 += v * b15;\n\n t0 += 38 * t16;\n t1 += 38 * t17;\n t2 += 38 * t18;\n t3 += 38 * t19;\n t4 += 38 * t20;\n t5 += 38 * t21;\n t6 += 38 * t22;\n t7 += 38 * t23;\n t8 += 38 * t24;\n t9 += 38 * t25;\n t10 += 38 * t26;\n t11 += 38 * t27;\n t12 += 38 * t28;\n t13 += 38 * t29;\n t14 += 38 * t30;\n // t15 left as is\n\n // first car\n c = 1;\n v = t0 + c + 65535; c = Math.floor(v / 65536); t0 = v - c * 65536;\n v = t1 + c + 65535; c = Math.floor(v / 65536); t1 = v - c * 65536;\n v = t2 + c + 65535; c = Math.floor(v / 65536); t2 = v - c * 65536;\n v = t3 + c + 65535; c = Math.floor(v / 65536); t3 = v - c * 65536;\n v = t4 + c + 65535; c = Math.floor(v / 65536); t4 = v - c * 65536;\n v = t5 + c + 65535; c = Math.floor(v / 65536); t5 = v - c * 65536;\n v = t6 + c + 65535; c = Math.floor(v / 65536); t6 = v - c * 65536;\n v = t7 + c + 65535; c = Math.floor(v / 65536); t7 = v - c * 65536;\n v = t8 + c + 65535; c = Math.floor(v / 65536); t8 = v - c * 65536;\n v = t9 + c + 65535; c = Math.floor(v / 65536); t9 = v - c * 65536;\n v = t10 + c + 65535; c = Math.floor(v / 65536); t10 = v - c * 65536;\n v = t11 + c + 65535; c = Math.floor(v / 65536); t11 = v - c * 65536;\n v = t12 + c + 65535; c = Math.floor(v / 65536); t12 = v - c * 65536;\n v = t13 + c + 65535; c = Math.floor(v / 65536); t13 = v - c * 65536;\n v = t14 + c + 65535; c = Math.floor(v / 65536); t14 = v - c * 65536;\n v = t15 + c + 65535; c = Math.floor(v / 65536); t15 = v - c * 65536;\n t0 += c-1 + 37 * (c-1);\n\n // second car\n c = 1;\n v = t0 + c + 65535; c = Math.floor(v / 65536); t0 = v - c * 65536;\n v = t1 + c + 65535; c = Math.floor(v / 65536); t1 = v - c * 65536;\n v = t2 + c + 65535; c = Math.floor(v / 65536); t2 = v - c * 65536;\n v = t3 + c + 65535; c = Math.floor(v / 65536); t3 = v - c * 65536;\n v = t4 + c + 65535; c = Math.floor(v / 65536); t4 = v - c * 65536;\n v = t5 + c + 65535; c = Math.floor(v / 65536); t5 = v - c * 65536;\n v = t6 + c + 65535; c = Math.floor(v / 65536); t6 = v - c * 65536;\n v = t7 + c + 65535; c = Math.floor(v / 65536); t7 = v - c * 65536;\n v = t8 + c + 65535; c = Math.floor(v / 65536); t8 = v - c * 65536;\n v = t9 + c + 65535; c = Math.floor(v / 65536); t9 = v - c * 65536;\n v = t10 + c + 65535; c = Math.floor(v / 65536); t10 = v - c * 65536;\n v = t11 + c + 65535; c = Math.floor(v / 65536); t11 = v - c * 65536;\n v = t12 + c + 65535; c = Math.floor(v / 65536); t12 = v - c * 65536;\n v = t13 + c + 65535; c = Math.floor(v / 65536); t13 = v - c * 65536;\n v = t14 + c + 65535; c = Math.floor(v / 65536); t14 = v - c * 65536;\n v = t15 + c + 65535; c = Math.floor(v / 65536); t15 = v - c * 65536;\n t0 += c-1 + 37 * (c-1);\n\n o[ 0] = t0;\n o[ 1] = t1;\n o[ 2] = t2;\n o[ 3] = t3;\n o[ 4] = t4;\n o[ 5] = t5;\n o[ 6] = t6;\n o[ 7] = t7;\n o[ 8] = t8;\n o[ 9] = t9;\n o[10] = t10;\n o[11] = t11;\n o[12] = t12;\n o[13] = t13;\n o[14] = t14;\n o[15] = t15;\n}\n\nfunction S(o, a) {\n M(o, a, a);\n}\n\nfunction inv25519(o, i) {\n var c = gf();\n var a;\n for (a = 0; a < 16; a++) c[a] = i[a];\n for (a = 253; a >= 0; a--) {\n S(c, c);\n if(a !== 2 && a !== 4) M(c, c, i);\n }\n for (a = 0; a < 16; a++) o[a] = c[a];\n}\n\nfunction pow2523(o, i) {\n var c = gf();\n var a;\n for (a = 0; a < 16; a++) c[a] = i[a];\n for (a = 250; a >= 0; a--) {\n S(c, c);\n if(a !== 1) M(c, c, i);\n }\n for (a = 0; a < 16; a++) o[a] = c[a];\n}\n\nfunction crypto_scalarmult(q, n, p) {\n var z = new Uint8Array(32);\n var x = new Float64Array(80), r, i;\n var a = gf(), b = gf(), c = gf(),\n d = gf(), e = gf(), f = gf();\n for (i = 0; i < 31; i++) z[i] = n[i];\n z[31]=(n[31]&127)|64;\n z[0]&=248;\n unpack25519(x,p);\n for (i = 0; i < 16; i++) {\n b[i]=x[i];\n d[i]=a[i]=c[i]=0;\n }\n a[0]=d[0]=1;\n for (i=254; i>=0; --i) {\n r=(z[i>>>3]>>>(i&7))&1;\n sel25519(a,b,r);\n sel25519(c,d,r);\n A(e,a,c);\n Z(a,a,c);\n A(c,b,d);\n Z(b,b,d);\n S(d,e);\n S(f,a);\n M(a,c,a);\n M(c,b,e);\n A(e,a,c);\n Z(a,a,c);\n S(b,a);\n Z(c,d,f);\n M(a,c,_121665);\n A(a,a,d);\n M(c,c,a);\n M(a,d,f);\n M(d,b,x);\n S(b,e);\n sel25519(a,b,r);\n sel25519(c,d,r);\n }\n for (i = 0; i < 16; i++) {\n x[i+16]=a[i];\n x[i+32]=c[i];\n x[i+48]=b[i];\n x[i+64]=d[i];\n }\n var x32 = x.subarray(32);\n var x16 = x.subarray(16);\n inv25519(x32,x32);\n M(x16,x16,x32);\n pack25519(q,x16);\n return 0;\n}\n\nfunction crypto_scalarmult_base(q, n) {\n return crypto_scalarmult(q, n, _9);\n}\n\nfunction crypto_box_keypair(y, x) {\n randombytes(x, 32);\n return crypto_scalarmult_base(y, x);\n}\n\nfunction crypto_box_beforenm(k, y, x) {\n var s = new Uint8Array(32);\n crypto_scalarmult(s, x, y);\n return crypto_core_hsalsa20(k, _0, s, sigma);\n}\n\nvar crypto_box_afternm = crypto_secretbox;\nvar crypto_box_open_afternm = crypto_secretbox_open;\n\nfunction crypto_box(c, m, d, n, y, x) {\n var k = new Uint8Array(32);\n crypto_box_beforenm(k, y, x);\n return crypto_box_afternm(c, m, d, n, k);\n}\n\nfunction crypto_box_open(m, c, d, n, y, x) {\n var k = new Uint8Array(32);\n crypto_box_beforenm(k, y, x);\n return crypto_box_open_afternm(m, c, d, n, k);\n}\n\nvar K = [\n 0x428a2f98, 0xd728ae22, 0x71374491, 0x23ef65cd,\n 0xb5c0fbcf, 0xec4d3b2f, 0xe9b5dba5, 0x8189dbbc,\n 0x3956c25b, 0xf348b538, 0x59f111f1, 0xb605d019,\n 0x923f82a4, 0xaf194f9b, 0xab1c5ed5, 0xda6d8118,\n 0xd807aa98, 0xa3030242, 0x12835b01, 0x45706fbe,\n 0x243185be, 0x4ee4b28c, 0x550c7dc3, 0xd5ffb4e2,\n 0x72be5d74, 0xf27b896f, 0x80deb1fe, 0x3b1696b1,\n 0x9bdc06a7, 0x25c71235, 0xc19bf174, 0xcf692694,\n 0xe49b69c1, 0x9ef14ad2, 0xefbe4786, 0x384f25e3,\n 0x0fc19dc6, 0x8b8cd5b5, 0x240ca1cc, 0x77ac9c65,\n 0x2de92c6f, 0x592b0275, 0x4a7484aa, 0x6ea6e483,\n 0x5cb0a9dc, 0xbd41fbd4, 0x76f988da, 0x831153b5,\n 0x983e5152, 0xee66dfab, 0xa831c66d, 0x2db43210,\n 0xb00327c8, 0x98fb213f, 0xbf597fc7, 0xbeef0ee4,\n 0xc6e00bf3, 0x3da88fc2, 0xd5a79147, 0x930aa725,\n 0x06ca6351, 0xe003826f, 0x14292967, 0x0a0e6e70,\n 0x27b70a85, 0x46d22ffc, 0x2e1b2138, 0x5c26c926,\n 0x4d2c6dfc, 0x5ac42aed, 0x53380d13, 0x9d95b3df,\n 0x650a7354, 0x8baf63de, 0x766a0abb, 0x3c77b2a8,\n 0x81c2c92e, 0x47edaee6, 0x92722c85, 0x1482353b,\n 0xa2bfe8a1, 0x4cf10364, 0xa81a664b, 0xbc423001,\n 0xc24b8b70, 0xd0f89791, 0xc76c51a3, 0x0654be30,\n 0xd192e819, 0xd6ef5218, 0xd6990624, 0x5565a910,\n 0xf40e3585, 0x5771202a, 0x106aa070, 0x32bbd1b8,\n 0x19a4c116, 0xb8d2d0c8, 0x1e376c08, 0x5141ab53,\n 0x2748774c, 0xdf8eeb99, 0x34b0bcb5, 0xe19b48a8,\n 0x391c0cb3, 0xc5c95a63, 0x4ed8aa4a, 0xe3418acb,\n 0x5b9cca4f, 0x7763e373, 0x682e6ff3, 0xd6b2b8a3,\n 0x748f82ee, 0x5defb2fc, 0x78a5636f, 0x43172f60,\n 0x84c87814, 0xa1f0ab72, 0x8cc70208, 0x1a6439ec,\n 0x90befffa, 0x23631e28, 0xa4506ceb, 0xde82bde9,\n 0xbef9a3f7, 0xb2c67915, 0xc67178f2, 0xe372532b,\n 0xca273ece, 0xea26619c, 0xd186b8c7, 0x21c0c207,\n 0xeada7dd6, 0xcde0eb1e, 0xf57d4f7f, 0xee6ed178,\n 0x06f067aa, 0x72176fba, 0x0a637dc5, 0xa2c898a6,\n 0x113f9804, 0xbef90dae, 0x1b710b35, 0x131c471b,\n 0x28db77f5, 0x23047d84, 0x32caab7b, 0x40c72493,\n 0x3c9ebe0a, 0x15c9bebc, 0x431d67c4, 0x9c100d4c,\n 0x4cc5d4be, 0xcb3e42b6, 0x597f299c, 0xfc657e2a,\n 0x5fcb6fab, 0x3ad6faec, 0x6c44198c, 0x4a475817\n];\n\nfunction crypto_hashblocks_hl(hh, hl, m, n) {\n var wh = new Int32Array(16), wl = new Int32Array(16),\n bh0, bh1, bh2, bh3, bh4, bh5, bh6, bh7,\n bl0, bl1, bl2, bl3, bl4, bl5, bl6, bl7,\n th, tl, i, j, h, l, a, b, c, d;\n\n var ah0 = hh[0],\n ah1 = hh[1],\n ah2 = hh[2],\n ah3 = hh[3],\n ah4 = hh[4],\n ah5 = hh[5],\n ah6 = hh[6],\n ah7 = hh[7],\n\n al0 = hl[0],\n al1 = hl[1],\n al2 = hl[2],\n al3 = hl[3],\n al4 = hl[4],\n al5 = hl[5],\n al6 = hl[6],\n al7 = hl[7];\n\n var pos = 0;\n while (n >= 128) {\n for (i = 0; i < 16; i++) {\n j = 8 * i + pos;\n wh[i] = (m[j+0] << 24) | (m[j+1] << 16) | (m[j+2] << 8) | m[j+3];\n wl[i] = (m[j+4] << 24) | (m[j+5] << 16) | (m[j+6] << 8) | m[j+7];\n }\n for (i = 0; i < 80; i++) {\n bh0 = ah0;\n bh1 = ah1;\n bh2 = ah2;\n bh3 = ah3;\n bh4 = ah4;\n bh5 = ah5;\n bh6 = ah6;\n bh7 = ah7;\n\n bl0 = al0;\n bl1 = al1;\n bl2 = al2;\n bl3 = al3;\n bl4 = al4;\n bl5 = al5;\n bl6 = al6;\n bl7 = al7;\n\n // add\n h = ah7;\n l = al7;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n // Sigma1\n h = ((ah4 >>> 14) | (al4 << (32-14))) ^ ((ah4 >>> 18) | (al4 << (32-18))) ^ ((al4 >>> (41-32)) | (ah4 << (32-(41-32))));\n l = ((al4 >>> 14) | (ah4 << (32-14))) ^ ((al4 >>> 18) | (ah4 << (32-18))) ^ ((ah4 >>> (41-32)) | (al4 << (32-(41-32))));\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // Ch\n h = (ah4 & ah5) ^ (~ah4 & ah6);\n l = (al4 & al5) ^ (~al4 & al6);\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // K\n h = K[i*2];\n l = K[i*2+1];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // w\n h = wh[i%16];\n l = wl[i%16];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n th = c & 0xffff | d << 16;\n tl = a & 0xffff | b << 16;\n\n // add\n h = th;\n l = tl;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n // Sigma0\n h = ((ah0 >>> 28) | (al0 << (32-28))) ^ ((al0 >>> (34-32)) | (ah0 << (32-(34-32)))) ^ ((al0 >>> (39-32)) | (ah0 << (32-(39-32))));\n l = ((al0 >>> 28) | (ah0 << (32-28))) ^ ((ah0 >>> (34-32)) | (al0 << (32-(34-32)))) ^ ((ah0 >>> (39-32)) | (al0 << (32-(39-32))));\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // Maj\n h = (ah0 & ah1) ^ (ah0 & ah2) ^ (ah1 & ah2);\n l = (al0 & al1) ^ (al0 & al2) ^ (al1 & al2);\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n bh7 = (c & 0xffff) | (d << 16);\n bl7 = (a & 0xffff) | (b << 16);\n\n // add\n h = bh3;\n l = bl3;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = th;\n l = tl;\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n bh3 = (c & 0xffff) | (d << 16);\n bl3 = (a & 0xffff) | (b << 16);\n\n ah1 = bh0;\n ah2 = bh1;\n ah3 = bh2;\n ah4 = bh3;\n ah5 = bh4;\n ah6 = bh5;\n ah7 = bh6;\n ah0 = bh7;\n\n al1 = bl0;\n al2 = bl1;\n al3 = bl2;\n al4 = bl3;\n al5 = bl4;\n al6 = bl5;\n al7 = bl6;\n al0 = bl7;\n\n if (i%16 === 15) {\n for (j = 0; j < 16; j++) {\n // add\n h = wh[j];\n l = wl[j];\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = wh[(j+9)%16];\n l = wl[(j+9)%16];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // sigma0\n th = wh[(j+1)%16];\n tl = wl[(j+1)%16];\n h = ((th >>> 1) | (tl << (32-1))) ^ ((th >>> 8) | (tl << (32-8))) ^ (th >>> 7);\n l = ((tl >>> 1) | (th << (32-1))) ^ ((tl >>> 8) | (th << (32-8))) ^ ((tl >>> 7) | (th << (32-7)));\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // sigma1\n th = wh[(j+14)%16];\n tl = wl[(j+14)%16];\n h = ((th >>> 19) | (tl << (32-19))) ^ ((tl >>> (61-32)) | (th << (32-(61-32)))) ^ (th >>> 6);\n l = ((tl >>> 19) | (th << (32-19))) ^ ((th >>> (61-32)) | (tl << (32-(61-32)))) ^ ((tl >>> 6) | (th << (32-6)));\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n wh[j] = (c & 0xffff) | (d << 16);\n wl[j] = (a & 0xffff) | (b << 16);\n }\n }\n }\n\n // add\n h = ah0;\n l = al0;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[0];\n l = hl[0];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[0] = ah0 = (c & 0xffff) | (d << 16);\n hl[0] = al0 = (a & 0xffff) | (b << 16);\n\n h = ah1;\n l = al1;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[1];\n l = hl[1];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[1] = ah1 = (c & 0xffff) | (d << 16);\n hl[1] = al1 = (a & 0xffff) | (b << 16);\n\n h = ah2;\n l = al2;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[2];\n l = hl[2];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[2] = ah2 = (c & 0xffff) | (d << 16);\n hl[2] = al2 = (a & 0xffff) | (b << 16);\n\n h = ah3;\n l = al3;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[3];\n l = hl[3];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[3] = ah3 = (c & 0xffff) | (d << 16);\n hl[3] = al3 = (a & 0xffff) | (b << 16);\n\n h = ah4;\n l = al4;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[4];\n l = hl[4];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[4] = ah4 = (c & 0xffff) | (d << 16);\n hl[4] = al4 = (a & 0xffff) | (b << 16);\n\n h = ah5;\n l = al5;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[5];\n l = hl[5];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[5] = ah5 = (c & 0xffff) | (d << 16);\n hl[5] = al5 = (a & 0xffff) | (b << 16);\n\n h = ah6;\n l = al6;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[6];\n l = hl[6];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[6] = ah6 = (c & 0xffff) | (d << 16);\n hl[6] = al6 = (a & 0xffff) | (b << 16);\n\n h = ah7;\n l = al7;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[7];\n l = hl[7];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[7] = ah7 = (c & 0xffff) | (d << 16);\n hl[7] = al7 = (a & 0xffff) | (b << 16);\n\n pos += 128;\n n -= 128;\n }\n\n return n;\n}\n\nfunction crypto_hash(out, m, n) {\n var hh = new Int32Array(8),\n hl = new Int32Array(8),\n x = new Uint8Array(256),\n i, b = n;\n\n hh[0] = 0x6a09e667;\n hh[1] = 0xbb67ae85;\n hh[2] = 0x3c6ef372;\n hh[3] = 0xa54ff53a;\n hh[4] = 0x510e527f;\n hh[5] = 0x9b05688c;\n hh[6] = 0x1f83d9ab;\n hh[7] = 0x5be0cd19;\n\n hl[0] = 0xf3bcc908;\n hl[1] = 0x84caa73b;\n hl[2] = 0xfe94f82b;\n hl[3] = 0x5f1d36f1;\n hl[4] = 0xade682d1;\n hl[5] = 0x2b3e6c1f;\n hl[6] = 0xfb41bd6b;\n hl[7] = 0x137e2179;\n\n crypto_hashblocks_hl(hh, hl, m, n);\n n %= 128;\n\n for (i = 0; i < n; i++) x[i] = m[b-n+i];\n x[n] = 128;\n\n n = 256-128*(n<112?1:0);\n x[n-9] = 0;\n ts64(x, n-8, (b / 0x20000000) | 0, b << 3);\n crypto_hashblocks_hl(hh, hl, x, n);\n\n for (i = 0; i < 8; i++) ts64(out, 8*i, hh[i], hl[i]);\n\n return 0;\n}\n\nfunction add(p, q) {\n var a = gf(), b = gf(), c = gf(),\n d = gf(), e = gf(), f = gf(),\n g = gf(), h = gf(), t = gf();\n\n Z(a, p[1], p[0]);\n Z(t, q[1], q[0]);\n M(a, a, t);\n A(b, p[0], p[1]);\n A(t, q[0], q[1]);\n M(b, b, t);\n M(c, p[3], q[3]);\n M(c, c, D2);\n M(d, p[2], q[2]);\n A(d, d, d);\n Z(e, b, a);\n Z(f, d, c);\n A(g, d, c);\n A(h, b, a);\n\n M(p[0], e, f);\n M(p[1], h, g);\n M(p[2], g, f);\n M(p[3], e, h);\n}\n\nfunction cswap(p, q, b) {\n var i;\n for (i = 0; i < 4; i++) {\n sel25519(p[i], q[i], b);\n }\n}\n\nfunction pack(r, p) {\n var tx = gf(), ty = gf(), zi = gf();\n inv25519(zi, p[2]);\n M(tx, p[0], zi);\n M(ty, p[1], zi);\n pack25519(r, ty);\n r[31] ^= par25519(tx) << 7;\n}\n\nfunction scalarmult(p, q, s) {\n var b, i;\n set25519(p[0], gf0);\n set25519(p[1], gf1);\n set25519(p[2], gf1);\n set25519(p[3], gf0);\n for (i = 255; i >= 0; --i) {\n b = (s[(i/8)|0] >> (i&7)) & 1;\n cswap(p, q, b);\n add(q, p);\n add(p, p);\n cswap(p, q, b);\n }\n}\n\nfunction scalarbase(p, s) {\n var q = [gf(), gf(), gf(), gf()];\n set25519(q[0], X);\n set25519(q[1], Y);\n set25519(q[2], gf1);\n M(q[3], X, Y);\n scalarmult(p, q, s);\n}\n\nfunction crypto_sign_keypair(pk, sk, seeded) {\n var d = new Uint8Array(64);\n var p = [gf(), gf(), gf(), gf()];\n var i;\n\n if (!seeded) randombytes(sk, 32);\n crypto_hash(d, sk, 32);\n d[0] &= 248;\n d[31] &= 127;\n d[31] |= 64;\n\n scalarbase(p, d);\n pack(pk, p);\n\n for (i = 0; i < 32; i++) sk[i+32] = pk[i];\n return 0;\n}\n\nvar L = new Float64Array([0xed, 0xd3, 0xf5, 0x5c, 0x1a, 0x63, 0x12, 0x58, 0xd6, 0x9c, 0xf7, 0xa2, 0xde, 0xf9, 0xde, 0x14, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x10]);\n\nfunction modL(r, x) {\n var carry, i, j, k;\n for (i = 63; i >= 32; --i) {\n carry = 0;\n for (j = i - 32, k = i - 12; j < k; ++j) {\n x[j] += carry - 16 * x[i] * L[j - (i - 32)];\n carry = Math.floor((x[j] + 128) / 256);\n x[j] -= carry * 256;\n }\n x[j] += carry;\n x[i] = 0;\n }\n carry = 0;\n for (j = 0; j < 32; j++) {\n x[j] += carry - (x[31] >> 4) * L[j];\n carry = x[j] >> 8;\n x[j] &= 255;\n }\n for (j = 0; j < 32; j++) x[j] -= carry * L[j];\n for (i = 0; i < 32; i++) {\n x[i+1] += x[i] >> 8;\n r[i] = x[i] & 255;\n }\n}\n\nfunction reduce(r) {\n var x = new Float64Array(64), i;\n for (i = 0; i < 64; i++) x[i] = r[i];\n for (i = 0; i < 64; i++) r[i] = 0;\n modL(r, x);\n}\n\n// Note: difference from C - smlen returned, not passed as argument.\nfunction crypto_sign(sm, m, n, sk) {\n var d = new Uint8Array(64), h = new Uint8Array(64), r = new Uint8Array(64);\n var i, j, x = new Float64Array(64);\n var p = [gf(), gf(), gf(), gf()];\n\n crypto_hash(d, sk, 32);\n d[0] &= 248;\n d[31] &= 127;\n d[31] |= 64;\n\n var smlen = n + 64;\n for (i = 0; i < n; i++) sm[64 + i] = m[i];\n for (i = 0; i < 32; i++) sm[32 + i] = d[32 + i];\n\n crypto_hash(r, sm.subarray(32), n+32);\n reduce(r);\n scalarbase(p, r);\n pack(sm, p);\n\n for (i = 32; i < 64; i++) sm[i] = sk[i];\n crypto_hash(h, sm, n + 64);\n reduce(h);\n\n for (i = 0; i < 64; i++) x[i] = 0;\n for (i = 0; i < 32; i++) x[i] = r[i];\n for (i = 0; i < 32; i++) {\n for (j = 0; j < 32; j++) {\n x[i+j] += h[i] * d[j];\n }\n }\n\n modL(sm.subarray(32), x);\n return smlen;\n}\n\nfunction unpackneg(r, p) {\n var t = gf(), chk = gf(), num = gf(),\n den = gf(), den2 = gf(), den4 = gf(),\n den6 = gf();\n\n set25519(r[2], gf1);\n unpack25519(r[1], p);\n S(num, r[1]);\n M(den, num, D);\n Z(num, num, r[2]);\n A(den, r[2], den);\n\n S(den2, den);\n S(den4, den2);\n M(den6, den4, den2);\n M(t, den6, num);\n M(t, t, den);\n\n pow2523(t, t);\n M(t, t, num);\n M(t, t, den);\n M(t, t, den);\n M(r[0], t, den);\n\n S(chk, r[0]);\n M(chk, chk, den);\n if (neq25519(chk, num)) M(r[0], r[0], I);\n\n S(chk, r[0]);\n M(chk, chk, den);\n if (neq25519(chk, num)) return -1;\n\n if (par25519(r[0]) === (p[31]>>7)) Z(r[0], gf0, r[0]);\n\n M(r[3], r[0], r[1]);\n return 0;\n}\n\nfunction crypto_sign_open(m, sm, n, pk) {\n var i;\n var t = new Uint8Array(32), h = new Uint8Array(64);\n var p = [gf(), gf(), gf(), gf()],\n q = [gf(), gf(), gf(), gf()];\n\n if (n < 64) return -1;\n\n if (unpackneg(q, pk)) return -1;\n\n for (i = 0; i < n; i++) m[i] = sm[i];\n for (i = 0; i < 32; i++) m[i+32] = pk[i];\n crypto_hash(h, m, n);\n reduce(h);\n scalarmult(p, q, h);\n\n scalarbase(q, sm.subarray(32));\n add(p, q);\n pack(t, p);\n\n n -= 64;\n if (crypto_verify_32(sm, 0, t, 0)) {\n for (i = 0; i < n; i++) m[i] = 0;\n return -1;\n }\n\n for (i = 0; i < n; i++) m[i] = sm[i + 64];\n return n;\n}\n\nvar crypto_secretbox_KEYBYTES = 32,\n crypto_secretbox_NONCEBYTES = 24,\n crypto_secretbox_ZEROBYTES = 32,\n crypto_secretbox_BOXZEROBYTES = 16,\n crypto_scalarmult_BYTES = 32,\n crypto_scalarmult_SCALARBYTES = 32,\n crypto_box_PUBLICKEYBYTES = 32,\n crypto_box_SECRETKEYBYTES = 32,\n crypto_box_BEFORENMBYTES = 32,\n crypto_box_NONCEBYTES = crypto_secretbox_NONCEBYTES,\n crypto_box_ZEROBYTES = crypto_secretbox_ZEROBYTES,\n crypto_box_BOXZEROBYTES = crypto_secretbox_BOXZEROBYTES,\n crypto_sign_BYTES = 64,\n crypto_sign_PUBLICKEYBYTES = 32,\n crypto_sign_SECRETKEYBYTES = 64,\n crypto_sign_SEEDBYTES = 32,\n crypto_hash_BYTES = 64;\n\nnacl.lowlevel = {\n crypto_core_hsalsa20: crypto_core_hsalsa20,\n crypto_stream_xor: crypto_stream_xor,\n crypto_stream: crypto_stream,\n crypto_stream_salsa20_xor: crypto_stream_salsa20_xor,\n crypto_stream_salsa20: crypto_stream_salsa20,\n crypto_onetimeauth: crypto_onetimeauth,\n crypto_onetimeauth_verify: crypto_onetimeauth_verify,\n crypto_verify_16: crypto_verify_16,\n crypto_verify_32: crypto_verify_32,\n crypto_secretbox: crypto_secretbox,\n crypto_secretbox_open: crypto_secretbox_open,\n crypto_scalarmult: crypto_scalarmult,\n crypto_scalarmult_base: crypto_scalarmult_base,\n crypto_box_beforenm: crypto_box_beforenm,\n crypto_box_afternm: crypto_box_afternm,\n crypto_box: crypto_box,\n crypto_box_open: crypto_box_open,\n crypto_box_keypair: crypto_box_keypair,\n crypto_hash: crypto_hash,\n crypto_sign: crypto_sign,\n crypto_sign_keypair: crypto_sign_keypair,\n crypto_sign_open: crypto_sign_open,\n\n crypto_secretbox_KEYBYTES: crypto_secretbox_KEYBYTES,\n crypto_secretbox_NONCEBYTES: crypto_secretbox_NONCEBYTES,\n crypto_secretbox_ZEROBYTES: crypto_secretbox_ZEROBYTES,\n crypto_secretbox_BOXZEROBYTES: crypto_secretbox_BOXZEROBYTES,\n crypto_scalarmult_BYTES: crypto_scalarmult_BYTES,\n crypto_scalarmult_SCALARBYTES: crypto_scalarmult_SCALARBYTES,\n crypto_box_PUBLICKEYBYTES: crypto_box_PUBLICKEYBYTES,\n crypto_box_SECRETKEYBYTES: crypto_box_SECRETKEYBYTES,\n crypto_box_BEFORENMBYTES: crypto_box_BEFORENMBYTES,\n crypto_box_NONCEBYTES: crypto_box_NONCEBYTES,\n crypto_box_ZEROBYTES: crypto_box_ZEROBYTES,\n crypto_box_BOXZEROBYTES: crypto_box_BOXZEROBYTES,\n crypto_sign_BYTES: crypto_sign_BYTES,\n crypto_sign_PUBLICKEYBYTES: crypto_sign_PUBLICKEYBYTES,\n crypto_sign_SECRETKEYBYTES: crypto_sign_SECRETKEYBYTES,\n crypto_sign_SEEDBYTES: crypto_sign_SEEDBYTES,\n crypto_hash_BYTES: crypto_hash_BYTES,\n\n gf: gf,\n D: D,\n L: L,\n pack25519: pack25519,\n unpack25519: unpack25519,\n M: M,\n A: A,\n S: S,\n Z: Z,\n pow2523: pow2523,\n add: add,\n set25519: set25519,\n modL: modL,\n scalarmult: scalarmult,\n scalarbase: scalarbase,\n};\n\n/* High-level API */\n\nfunction checkLengths(k, n) {\n if (k.length !== crypto_secretbox_KEYBYTES) throw new Error('bad key size');\n if (n.length !== crypto_secretbox_NONCEBYTES) throw new Error('bad nonce size');\n}\n\nfunction checkBoxLengths(pk, sk) {\n if (pk.length !== crypto_box_PUBLICKEYBYTES) throw new Error('bad public key size');\n if (sk.length !== crypto_box_SECRETKEYBYTES) throw new Error('bad secret key size');\n}\n\nfunction checkArrayTypes() {\n for (var i = 0; i < arguments.length; i++) {\n if (!(arguments[i] instanceof Uint8Array))\n throw new TypeError('unexpected type, use Uint8Array');\n }\n}\n\nfunction cleanup(arr) {\n for (var i = 0; i < arr.length; i++) arr[i] = 0;\n}\n\nnacl.randomBytes = function(n) {\n var b = new Uint8Array(n);\n randombytes(b, n);\n return b;\n};\n\nnacl.secretbox = function(msg, nonce, key) {\n checkArrayTypes(msg, nonce, key);\n checkLengths(key, nonce);\n var m = new Uint8Array(crypto_secretbox_ZEROBYTES + msg.length);\n var c = new Uint8Array(m.length);\n for (var i = 0; i < msg.length; i++) m[i+crypto_secretbox_ZEROBYTES] = msg[i];\n crypto_secretbox(c, m, m.length, nonce, key);\n return c.subarray(crypto_secretbox_BOXZEROBYTES);\n};\n\nnacl.secretbox.open = function(box, nonce, key) {\n checkArrayTypes(box, nonce, key);\n checkLengths(key, nonce);\n var c = new Uint8Array(crypto_secretbox_BOXZEROBYTES + box.length);\n var m = new Uint8Array(c.length);\n for (var i = 0; i < box.length; i++) c[i+crypto_secretbox_BOXZEROBYTES] = box[i];\n if (c.length < 32) return null;\n if (crypto_secretbox_open(m, c, c.length, nonce, key) !== 0) return null;\n return m.subarray(crypto_secretbox_ZEROBYTES);\n};\n\nnacl.secretbox.keyLength = crypto_secretbox_KEYBYTES;\nnacl.secretbox.nonceLength = crypto_secretbox_NONCEBYTES;\nnacl.secretbox.overheadLength = crypto_secretbox_BOXZEROBYTES;\n\nnacl.scalarMult = function(n, p) {\n checkArrayTypes(n, p);\n if (n.length !== crypto_scalarmult_SCALARBYTES) throw new Error('bad n size');\n if (p.length !== crypto_scalarmult_BYTES) throw new Error('bad p size');\n var q = new Uint8Array(crypto_scalarmult_BYTES);\n crypto_scalarmult(q, n, p);\n return q;\n};\n\nnacl.scalarMult.base = function(n) {\n checkArrayTypes(n);\n if (n.length !== crypto_scalarmult_SCALARBYTES) throw new Error('bad n size');\n var q = new Uint8Array(crypto_scalarmult_BYTES);\n crypto_scalarmult_base(q, n);\n return q;\n};\n\nnacl.scalarMult.scalarLength = crypto_scalarmult_SCALARBYTES;\nnacl.scalarMult.groupElementLength = crypto_scalarmult_BYTES;\n\nnacl.box = function(msg, nonce, publicKey, secretKey) {\n var k = nacl.box.before(publicKey, secretKey);\n return nacl.secretbox(msg, nonce, k);\n};\n\nnacl.box.before = function(publicKey, secretKey) {\n checkArrayTypes(publicKey, secretKey);\n checkBoxLengths(publicKey, secretKey);\n var k = new Uint8Array(crypto_box_BEFORENMBYTES);\n crypto_box_beforenm(k, publicKey, secretKey);\n return k;\n};\n\nnacl.box.after = nacl.secretbox;\n\nnacl.box.open = function(msg, nonce, publicKey, secretKey) {\n var k = nacl.box.before(publicKey, secretKey);\n return nacl.secretbox.open(msg, nonce, k);\n};\n\nnacl.box.open.after = nacl.secretbox.open;\n\nnacl.box.keyPair = function() {\n var pk = new Uint8Array(crypto_box_PUBLICKEYBYTES);\n var sk = new Uint8Array(crypto_box_SECRETKEYBYTES);\n crypto_box_keypair(pk, sk);\n return {publicKey: pk, secretKey: sk};\n};\n\nnacl.box.keyPair.fromSecretKey = function(secretKey) {\n checkArrayTypes(secretKey);\n if (secretKey.length !== crypto_box_SECRETKEYBYTES)\n throw new Error('bad secret key size');\n var pk = new Uint8Array(crypto_box_PUBLICKEYBYTES);\n crypto_scalarmult_base(pk, secretKey);\n return {publicKey: pk, secretKey: new Uint8Array(secretKey)};\n};\n\nnacl.box.publicKeyLength = crypto_box_PUBLICKEYBYTES;\nnacl.box.secretKeyLength = crypto_box_SECRETKEYBYTES;\nnacl.box.sharedKeyLength = crypto_box_BEFORENMBYTES;\nnacl.box.nonceLength = crypto_box_NONCEBYTES;\nnacl.box.overheadLength = nacl.secretbox.overheadLength;\n\nnacl.sign = function(msg, secretKey) {\n checkArrayTypes(msg, secretKey);\n if (secretKey.length !== crypto_sign_SECRETKEYBYTES)\n throw new Error('bad secret key size');\n var signedMsg = new Uint8Array(crypto_sign_BYTES+msg.length);\n crypto_sign(signedMsg, msg, msg.length, secretKey);\n return signedMsg;\n};\n\nnacl.sign.open = function(signedMsg, publicKey) {\n checkArrayTypes(signedMsg, publicKey);\n if (publicKey.length !== crypto_sign_PUBLICKEYBYTES)\n throw new Error('bad public key size');\n var tmp = new Uint8Array(signedMsg.length);\n var mlen = crypto_sign_open(tmp, signedMsg, signedMsg.length, publicKey);\n if (mlen < 0) return null;\n var m = new Uint8Array(mlen);\n for (var i = 0; i < m.length; i++) m[i] = tmp[i];\n return m;\n};\n\nnacl.sign.detached = function(msg, secretKey) {\n var signedMsg = nacl.sign(msg, secretKey);\n var sig = new Uint8Array(crypto_sign_BYTES);\n for (var i = 0; i < sig.length; i++) sig[i] = signedMsg[i];\n return sig;\n};\n\nnacl.sign.detached.verify = function(msg, sig, publicKey) {\n checkArrayTypes(msg, sig, publicKey);\n if (sig.length !== crypto_sign_BYTES)\n throw new Error('bad signature size');\n if (publicKey.length !== crypto_sign_PUBLICKEYBYTES)\n throw new Error('bad public key size');\n var sm = new Uint8Array(crypto_sign_BYTES + msg.length);\n var m = new Uint8Array(crypto_sign_BYTES + msg.length);\n var i;\n for (i = 0; i < crypto_sign_BYTES; i++) sm[i] = sig[i];\n for (i = 0; i < msg.length; i++) sm[i+crypto_sign_BYTES] = msg[i];\n return (crypto_sign_open(m, sm, sm.length, publicKey) >= 0);\n};\n\nnacl.sign.keyPair = function() {\n var pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);\n var sk = new Uint8Array(crypto_sign_SECRETKEYBYTES);\n crypto_sign_keypair(pk, sk);\n return {publicKey: pk, secretKey: sk};\n};\n\nnacl.sign.keyPair.fromSecretKey = function(secretKey) {\n checkArrayTypes(secretKey);\n if (secretKey.length !== crypto_sign_SECRETKEYBYTES)\n throw new Error('bad secret key size');\n var pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);\n for (var i = 0; i < pk.length; i++) pk[i] = secretKey[32+i];\n return {publicKey: pk, secretKey: new Uint8Array(secretKey)};\n};\n\nnacl.sign.keyPair.fromSeed = function(seed) {\n checkArrayTypes(seed);\n if (seed.length !== crypto_sign_SEEDBYTES)\n throw new Error('bad seed size');\n var pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);\n var sk = new Uint8Array(crypto_sign_SECRETKEYBYTES);\n for (var i = 0; i < 32; i++) sk[i] = seed[i];\n crypto_sign_keypair(pk, sk, true);\n return {publicKey: pk, secretKey: sk};\n};\n\nnacl.sign.publicKeyLength = crypto_sign_PUBLICKEYBYTES;\nnacl.sign.secretKeyLength = crypto_sign_SECRETKEYBYTES;\nnacl.sign.seedLength = crypto_sign_SEEDBYTES;\nnacl.sign.signatureLength = crypto_sign_BYTES;\n\nnacl.hash = function(msg) {\n checkArrayTypes(msg);\n var h = new Uint8Array(crypto_hash_BYTES);\n crypto_hash(h, msg, msg.length);\n return h;\n};\n\nnacl.hash.hashLength = crypto_hash_BYTES;\n\nnacl.verify = function(x, y) {\n checkArrayTypes(x, y);\n // Zero length arguments are considered not equal.\n if (x.length === 0 || y.length === 0) return false;\n if (x.length !== y.length) return false;\n return (vn(x, 0, y, 0, x.length) === 0) ? true : false;\n};\n\nnacl.setPRNG = function(fn) {\n randombytes = fn;\n};\n\n(function() {\n // Initialize PRNG if environment provides CSPRNG.\n // If not, methods calling randombytes will throw.\n var crypto = typeof self !== 'undefined' ? (self.crypto || self.msCrypto) : null;\n if (crypto && crypto.getRandomValues) {\n // Browsers.\n var QUOTA = 65536;\n nacl.setPRNG(function(x, n) {\n var i, v = new Uint8Array(n);\n for (i = 0; i < n; i += QUOTA) {\n crypto.getRandomValues(v.subarray(i, i + Math.min(n - i, QUOTA)));\n }\n for (i = 0; i < n; i++) x[i] = v[i];\n cleanup(v);\n });\n } else if (typeof require !== 'undefined') {\n // Node.js.\n crypto = require('crypto');\n if (crypto && crypto.randomBytes) {\n nacl.setPRNG(function(x, n) {\n var i, v = crypto.randomBytes(n);\n for (i = 0; i < n; i++) x[i] = v[i];\n cleanup(v);\n });\n }\n }\n})();\n\n})(typeof module !== 'undefined' && module.exports ? module.exports : (self.nacl = self.nacl || {}));\n","module.exports = require('./pusher-with-encryption').default;\n","export default function encode(s: any): string {\n return btoa(utob(s));\n}\n\nvar fromCharCode = String.fromCharCode;\n\nvar b64chars =\n 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';\nvar b64tab = {};\n\nfor (var i = 0, l = b64chars.length; i < l; i++) {\n b64tab[b64chars.charAt(i)] = i;\n}\n\nvar cb_utob = function(c) {\n var cc = c.charCodeAt(0);\n return cc < 0x80\n ? c\n : cc < 0x800\n ? fromCharCode(0xc0 | (cc >>> 6)) + fromCharCode(0x80 | (cc & 0x3f))\n : fromCharCode(0xe0 | ((cc >>> 12) & 0x0f)) +\n fromCharCode(0x80 | ((cc >>> 6) & 0x3f)) +\n fromCharCode(0x80 | (cc & 0x3f));\n};\n\nvar utob = function(u) {\n return u.replace(/[^\\x00-\\x7F]/g, cb_utob);\n};\n\nvar cb_encode = function(ccc) {\n var padlen = [0, 2, 1][ccc.length % 3];\n var ord =\n (ccc.charCodeAt(0) << 16) |\n ((ccc.length > 1 ? ccc.charCodeAt(1) : 0) << 8) |\n (ccc.length > 2 ? ccc.charCodeAt(2) : 0);\n var chars = [\n b64chars.charAt(ord >>> 18),\n b64chars.charAt((ord >>> 12) & 63),\n padlen >= 2 ? '=' : b64chars.charAt((ord >>> 6) & 63),\n padlen >= 1 ? '=' : b64chars.charAt(ord & 63)\n ];\n return chars.join('');\n};\n\nvar btoa =\n global.btoa ||\n function(b) {\n return b.replace(/[\\s\\S]{1,3}/g, cb_encode);\n };\n","import TimedCallback from './timed_callback';\nimport { Delay, Scheduler, Canceller } from './scheduling';\n\nabstract class Timer {\n protected clear: Canceller;\n protected timer: number | void;\n\n constructor(\n set: Scheduler,\n clear: Canceller,\n delay: Delay,\n callback: TimedCallback\n ) {\n this.clear = clear;\n this.timer = set(() => {\n if (this.timer) {\n this.timer = callback(this.timer);\n }\n }, delay);\n }\n\n /** Returns whether the timer is still running.\n *\n * @return {Boolean}\n */\n isRunning(): boolean {\n return this.timer !== null;\n }\n\n /** Aborts a timer when it's running. */\n ensureAborted() {\n if (this.timer) {\n this.clear(this.timer);\n this.timer = null;\n }\n }\n}\n\nexport default Timer;\n","import Timer from './abstract_timer';\nimport TimedCallback from './timed_callback';\nimport { Delay } from './scheduling';\n\n// We need to bind clear functions this way to avoid exceptions on IE8\nfunction clearTimeout(timer) {\n global.clearTimeout(timer);\n}\nfunction clearInterval(timer) {\n global.clearInterval(timer);\n}\n\n/** Cross-browser compatible one-off timer abstraction.\n *\n * @param {Number} delay\n * @param {Function} callback\n */\nexport class OneOffTimer extends Timer {\n constructor(delay: Delay, callback: TimedCallback) {\n super(setTimeout, clearTimeout, delay, function(timer) {\n callback();\n return null;\n });\n }\n}\n\n/** Cross-browser compatible periodic timer abstraction.\n *\n * @param {Number} delay\n * @param {Function} callback\n */\nexport class PeriodicTimer extends Timer {\n constructor(delay: Delay, callback: TimedCallback) {\n super(setInterval, clearInterval, delay, function(timer) {\n callback();\n return timer;\n });\n }\n}\n","import * as Collections from './utils/collections';\nimport TimedCallback from './utils/timers/timed_callback';\nimport { OneOffTimer, PeriodicTimer } from './utils/timers';\n\nvar Util = {\n now(): number {\n if (Date.now) {\n return Date.now();\n } else {\n return new Date().valueOf();\n }\n },\n\n defer(callback: TimedCallback): OneOffTimer {\n return new OneOffTimer(0, callback);\n },\n\n /** Builds a function that will proxy a method call to its first argument.\n *\n * Allows partial application of arguments, so additional arguments are\n * prepended to the argument list.\n *\n * @param {String} name method name\n * @return {Function} proxy function\n */\n method(name: string, ...args: any[]): Function {\n var boundArguments = Array.prototype.slice.call(arguments, 1);\n return function(object) {\n return object[name].apply(object, boundArguments.concat(arguments));\n };\n }\n};\n\nexport default Util;\n","import base64encode from '../base64';\nimport Util from '../util';\n\n/** Merges multiple objects into the target argument.\n *\n * For properties that are plain Objects, performs a deep-merge. For the\n * rest it just copies the value of the property.\n *\n * To extend prototypes use it as following:\n * Pusher.Util.extend(Target.prototype, Base.prototype)\n *\n * You can also use it to merge objects without altering them:\n * Pusher.Util.extend({}, object1, object2)\n *\n * @param {Object} target\n * @return {Object} the target argument\n */\nexport function extend(target: any, ...sources: any[]): T {\n for (var i = 0; i < sources.length; i++) {\n var extensions = sources[i];\n for (var property in extensions) {\n if (\n extensions[property] &&\n extensions[property].constructor &&\n extensions[property].constructor === Object\n ) {\n target[property] = extend(target[property] || {}, extensions[property]);\n } else {\n target[property] = extensions[property];\n }\n }\n }\n return target;\n}\n\nexport function stringify(): string {\n var m = ['Pusher'];\n for (var i = 0; i < arguments.length; i++) {\n if (typeof arguments[i] === 'string') {\n m.push(arguments[i]);\n } else {\n m.push(safeJSONStringify(arguments[i]));\n }\n }\n return m.join(' : ');\n}\n\nexport function arrayIndexOf(array: any[], item: any): number {\n // MSIE doesn't have array.indexOf\n var nativeIndexOf = Array.prototype.indexOf;\n if (array === null) {\n return -1;\n }\n if (nativeIndexOf && array.indexOf === nativeIndexOf) {\n return array.indexOf(item);\n }\n for (var i = 0, l = array.length; i < l; i++) {\n if (array[i] === item) {\n return i;\n }\n }\n return -1;\n}\n\n/** Applies a function f to all properties of an object.\n *\n * Function f gets 3 arguments passed:\n * - element from the object\n * - key of the element\n * - reference to the object\n *\n * @param {Object} object\n * @param {Function} f\n */\nexport function objectApply(object: any, f: Function) {\n for (var key in object) {\n if (Object.prototype.hasOwnProperty.call(object, key)) {\n f(object[key], key, object);\n }\n }\n}\n\n/** Return a list of objects own proerty keys\n *\n * @param {Object} object\n * @returns {Array}\n */\nexport function keys(object: any): string[] {\n var keys = [];\n objectApply(object, function(_, key) {\n keys.push(key);\n });\n return keys;\n}\n\n/** Return a list of object's own property values\n *\n * @param {Object} object\n * @returns {Array}\n */\nexport function values(object: any): any[] {\n var values = [];\n objectApply(object, function(value) {\n values.push(value);\n });\n return values;\n}\n\n/** Applies a function f to all elements of an array.\n *\n * Function f gets 3 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function apply(array: any[], f: Function, context?: any) {\n for (var i = 0; i < array.length; i++) {\n f.call(context || global, array[i], i, array);\n }\n}\n\n/** Maps all elements of the array and returns the result.\n *\n * Function f gets 4 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n * - reference to the destination array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function map(array: any[], f: Function): any[] {\n var result = [];\n for (var i = 0; i < array.length; i++) {\n result.push(f(array[i], i, array, result));\n }\n return result;\n}\n\n/** Maps all elements of the object and returns the result.\n *\n * Function f gets 4 arguments passed:\n * - element from the object\n * - key of the element\n * - reference to the source object\n * - reference to the destination object\n *\n * @param {Object} object\n * @param {Function} f\n */\nexport function mapObject(object: any, f: Function): any {\n var result = {};\n objectApply(object, function(value, key) {\n result[key] = f(value);\n });\n return result;\n}\n\n/** Filters elements of the array using a test function.\n *\n * Function test gets 4 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n * - reference to the destination array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function filter(array: any[], test: Function): any[] {\n test =\n test ||\n function(value) {\n return !!value;\n };\n\n var result = [];\n for (var i = 0; i < array.length; i++) {\n if (test(array[i], i, array, result)) {\n result.push(array[i]);\n }\n }\n return result;\n}\n\n/** Filters properties of the object using a test function.\n *\n * Function test gets 4 arguments passed:\n * - element from the object\n * - key of the element\n * - reference to the source object\n * - reference to the destination object\n *\n * @param {Object} object\n * @param {Function} f\n */\nexport function filterObject(object: Object, test: Function) {\n var result = {};\n objectApply(object, function(value, key) {\n if ((test && test(value, key, object, result)) || Boolean(value)) {\n result[key] = value;\n }\n });\n return result;\n}\n\n/** Flattens an object into a two-dimensional array.\n *\n * @param {Object} object\n * @return {Array} resulting array of [key, value] pairs\n */\nexport function flatten(object: Object): any[] {\n var result = [];\n objectApply(object, function(value, key) {\n result.push([key, value]);\n });\n return result;\n}\n\n/** Checks whether any element of the array passes the test.\n *\n * Function test gets 3 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function any(array: any[], test: Function): boolean {\n for (var i = 0; i < array.length; i++) {\n if (test(array[i], i, array)) {\n return true;\n }\n }\n return false;\n}\n\n/** Checks whether all elements of the array pass the test.\n *\n * Function test gets 3 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function all(array: any[], test: Function): boolean {\n for (var i = 0; i < array.length; i++) {\n if (!test(array[i], i, array)) {\n return false;\n }\n }\n return true;\n}\n\nexport function encodeParamsObject(data): string {\n return mapObject(data, function(value) {\n if (typeof value === 'object') {\n value = safeJSONStringify(value);\n }\n return encodeURIComponent(base64encode(value.toString()));\n });\n}\n\nexport function buildQueryString(data: any): string {\n var params = filterObject(data, function(value) {\n return value !== undefined;\n });\n\n var query = map(\n flatten(encodeParamsObject(params)),\n Util.method('join', '=')\n ).join('&');\n\n return query;\n}\n\n/**\n * See https://github.com/douglascrockford/JSON-js/blob/master/cycle.js\n *\n * Remove circular references from an object. Required for JSON.stringify in\n * React Native, which tends to blow up a lot.\n *\n * @param {any} object\n * @return {any} Decycled object\n */\nexport function decycleObject(object: any): any {\n var objects = [],\n paths = [];\n\n return (function derez(value, path) {\n var i, name, nu;\n\n switch (typeof value) {\n case 'object':\n if (!value) {\n return null;\n }\n for (i = 0; i < objects.length; i += 1) {\n if (objects[i] === value) {\n return { $ref: paths[i] };\n }\n }\n\n objects.push(value);\n paths.push(path);\n\n if (Object.prototype.toString.apply(value) === '[object Array]') {\n nu = [];\n for (i = 0; i < value.length; i += 1) {\n nu[i] = derez(value[i], path + '[' + i + ']');\n }\n } else {\n nu = {};\n for (name in value) {\n if (Object.prototype.hasOwnProperty.call(value, name)) {\n nu[name] = derez(\n value[name],\n path + '[' + JSON.stringify(name) + ']'\n );\n }\n }\n }\n return nu;\n case 'number':\n case 'string':\n case 'boolean':\n return value;\n }\n })(object, '$');\n}\n\n/**\n * Provides a cross-browser and cross-platform way to safely stringify objects\n * into JSON. This is particularly necessary for ReactNative, where circular JSON\n * structures throw an exception.\n *\n * @param {any} source The object to stringify\n * @return {string} The serialized output.\n */\nexport function safeJSONStringify(source: any): string {\n try {\n return JSON.stringify(source);\n } catch (e) {\n return JSON.stringify(decycleObject(source));\n }\n}\n","import {\n ChannelAuthorizationOptions,\n UserAuthenticationOptions\n} from './auth/options';\nimport { AuthTransport } from './config';\n\nexport interface DefaultConfig {\n VERSION: string;\n PROTOCOL: number;\n wsPort: number;\n wssPort: number;\n wsPath: string;\n httpHost: string;\n httpPort: number;\n httpsPort: number;\n httpPath: string;\n stats_host: string;\n authEndpoint: string;\n authTransport: AuthTransport;\n activityTimeout: number;\n pongTimeout: number;\n unavailableTimeout: number;\n userAuthentication: UserAuthenticationOptions;\n channelAuthorization: ChannelAuthorizationOptions;\n\n cdn_http?: string;\n cdn_https?: string;\n dependency_suffix?: string;\n}\n\nvar Defaults: DefaultConfig = {\n VERSION: VERSION,\n PROTOCOL: 7,\n\n wsPort: 80,\n wssPort: 443,\n wsPath: '',\n // DEPRECATED: SockJS fallback parameters\n httpHost: 'sockjs.pusher.com',\n httpPort: 80,\n httpsPort: 443,\n httpPath: '/pusher',\n // DEPRECATED: Stats\n stats_host: 'stats.pusher.com',\n // DEPRECATED: Other settings\n authEndpoint: '/pusher/auth',\n authTransport: 'ajax',\n activityTimeout: 120000,\n pongTimeout: 30000,\n unavailableTimeout: 10000,\n userAuthentication: {\n endpoint: '/pusher/user-auth',\n transport: 'ajax'\n },\n channelAuthorization: {\n endpoint: '/pusher/auth',\n transport: 'ajax'\n },\n\n // CDN configuration\n cdn_http: CDN_HTTP,\n cdn_https: CDN_HTTPS,\n dependency_suffix: DEPENDENCY_SUFFIX\n};\n\nexport default Defaults;\n","import Defaults from '../defaults';\nimport { default as URLScheme, URLSchemeParams } from './url_scheme';\n\nfunction getGenericURL(\n baseScheme: string,\n params: URLSchemeParams,\n path: string\n): string {\n var scheme = baseScheme + (params.useTLS ? 's' : '');\n var host = params.useTLS ? params.hostTLS : params.hostNonTLS;\n return scheme + '://' + host + path;\n}\n\nfunction getGenericPath(key: string, queryString?: string): string {\n var path = '/app/' + key;\n var query =\n '?protocol=' +\n Defaults.PROTOCOL +\n '&client=js' +\n '&version=' +\n Defaults.VERSION +\n (queryString ? '&' + queryString : '');\n return path + query;\n}\n\nexport var ws: URLScheme = {\n getInitial: function(key: string, params: URLSchemeParams): string {\n var path = (params.httpPath || '') + getGenericPath(key, 'flash=false');\n return getGenericURL('ws', params, path);\n }\n};\n\nexport var http: URLScheme = {\n getInitial: function(key: string, params: URLSchemeParams): string {\n var path = (params.httpPath || '/pusher') + getGenericPath(key);\n return getGenericURL('http', params, path);\n }\n};\n\nexport var sockjs: URLScheme = {\n getInitial: function(key: string, params: URLSchemeParams): string {\n return getGenericURL('http', params, params.httpPath || '/pusher');\n },\n getPath: function(key: string, params: URLSchemeParams): string {\n return getGenericPath(key);\n }\n};\n","import Callback from './callback';\nimport * as Collections from '../utils/collections';\nimport CallbackTable from './callback_table';\n\nexport default class CallbackRegistry {\n _callbacks: CallbackTable;\n\n constructor() {\n this._callbacks = {};\n }\n\n get(name: string): Callback[] {\n return this._callbacks[prefix(name)];\n }\n\n add(name: string, callback: Function, context: any) {\n var prefixedEventName = prefix(name);\n this._callbacks[prefixedEventName] =\n this._callbacks[prefixedEventName] || [];\n this._callbacks[prefixedEventName].push({\n fn: callback,\n context: context\n });\n }\n\n remove(name?: string, callback?: Function, context?: any) {\n if (!name && !callback && !context) {\n this._callbacks = {};\n return;\n }\n\n var names = name ? [prefix(name)] : Collections.keys(this._callbacks);\n\n if (callback || context) {\n this.removeCallback(names, callback, context);\n } else {\n this.removeAllCallbacks(names);\n }\n }\n\n private removeCallback(names: string[], callback: Function, context: any) {\n Collections.apply(\n names,\n function(name) {\n this._callbacks[name] = Collections.filter(\n this._callbacks[name] || [],\n function(binding) {\n return (\n (callback && callback !== binding.fn) ||\n (context && context !== binding.context)\n );\n }\n );\n if (this._callbacks[name].length === 0) {\n delete this._callbacks[name];\n }\n },\n this\n );\n }\n\n private removeAllCallbacks(names: string[]) {\n Collections.apply(\n names,\n function(name) {\n delete this._callbacks[name];\n },\n this\n );\n }\n}\n\nfunction prefix(name: string): string {\n return '_' + name;\n}\n","import * as Collections from '../utils/collections';\nimport Callback from './callback';\nimport Metadata from '../channels/metadata';\nimport CallbackRegistry from './callback_registry';\n\n/** Manages callback bindings and event emitting.\n *\n * @param Function failThrough called when no listeners are bound to an event\n */\nexport default class Dispatcher {\n callbacks: CallbackRegistry;\n global_callbacks: Function[];\n failThrough: Function;\n\n constructor(failThrough?: Function) {\n this.callbacks = new CallbackRegistry();\n this.global_callbacks = [];\n this.failThrough = failThrough;\n }\n\n bind(eventName: string, callback: Function, context?: any) {\n this.callbacks.add(eventName, callback, context);\n return this;\n }\n\n bind_global(callback: Function) {\n this.global_callbacks.push(callback);\n return this;\n }\n\n unbind(eventName?: string, callback?: Function, context?: any) {\n this.callbacks.remove(eventName, callback, context);\n return this;\n }\n\n unbind_global(callback?: Function) {\n if (!callback) {\n this.global_callbacks = [];\n return this;\n }\n\n this.global_callbacks = Collections.filter(\n this.global_callbacks || [],\n c => c !== callback\n );\n\n return this;\n }\n\n unbind_all() {\n this.unbind();\n this.unbind_global();\n return this;\n }\n\n emit(eventName: string, data?: any, metadata?: Metadata): Dispatcher {\n for (var i = 0; i < this.global_callbacks.length; i++) {\n this.global_callbacks[i](eventName, data);\n }\n\n var callbacks = this.callbacks.get(eventName);\n var args = [];\n\n if (metadata) {\n // if there's a metadata argument, we need to call the callback with both\n // data and metadata regardless of whether data is undefined\n args.push(data, metadata);\n } else if (data) {\n // metadata is undefined, so we only need to call the callback with data\n // if data exists\n args.push(data);\n }\n\n if (callbacks && callbacks.length > 0) {\n for (var i = 0; i < callbacks.length; i++) {\n callbacks[i].fn.apply(callbacks[i].context || global, args);\n }\n } else if (this.failThrough) {\n this.failThrough(eventName, data);\n }\n\n return this;\n }\n}\n","import { stringify } from './utils/collections';\nimport Pusher from './pusher';\n\nclass Logger {\n debug(...args: any[]) {\n this.log(this.globalLog, args);\n }\n\n warn(...args: any[]) {\n this.log(this.globalLogWarn, args);\n }\n\n error(...args: any[]) {\n this.log(this.globalLogError, args);\n }\n\n private globalLog = (message: string) => {\n if (global.console && global.console.log) {\n global.console.log(message);\n }\n };\n\n private globalLogWarn(message: string) {\n if (global.console && global.console.warn) {\n global.console.warn(message);\n } else {\n this.globalLog(message);\n }\n }\n\n private globalLogError(message: string) {\n if (global.console && global.console.error) {\n global.console.error(message);\n } else {\n this.globalLogWarn(message);\n }\n }\n\n private log(\n defaultLoggingFunction: (message: string) => void,\n ...args: any[]\n ) {\n var message = stringify.apply(this, arguments);\n if (Pusher.log) {\n Pusher.log(message);\n } else if (Pusher.logToConsole) {\n const log = defaultLoggingFunction.bind(this);\n log(message);\n }\n }\n}\n\nexport default new Logger();\n","import Util from '../util';\nimport * as Collections from '../utils/collections';\nimport { default as EventsDispatcher } from '../events/dispatcher';\nimport Logger from '../logger';\nimport TransportHooks from './transport_hooks';\nimport Socket from '../socket';\nimport Runtime from 'runtime';\nimport Timeline from '../timeline/timeline';\nimport TransportConnectionOptions from './transport_connection_options';\n\n/** Provides universal API for transport connections.\n *\n * Transport connection is a low-level object that wraps a connection method\n * and exposes a simple evented interface for the connection state and\n * messaging. It does not implement Pusher-specific WebSocket protocol.\n *\n * Additionally, it fetches resources needed for transport to work and exposes\n * an interface for querying transport features.\n *\n * States:\n * - new - initial state after constructing the object\n * - initializing - during initialization phase, usually fetching resources\n * - intialized - ready to establish a connection\n * - connection - when connection is being established\n * - open - when connection ready to be used\n * - closed - after connection was closed be either side\n *\n * Emits:\n * - error - after the connection raised an error\n *\n * Options:\n * - useTLS - whether connection should be over TLS\n * - hostTLS - host to connect to when connection is over TLS\n * - hostNonTLS - host to connect to when connection is over TLS\n *\n * @param {String} key application key\n * @param {Object} options\n */\nexport default class TransportConnection extends EventsDispatcher {\n hooks: TransportHooks;\n name: string;\n priority: number;\n key: string;\n options: TransportConnectionOptions;\n state: string;\n timeline: Timeline;\n activityTimeout: number;\n id: number;\n socket: Socket;\n beforeOpen: Function;\n initialize: Function;\n\n constructor(\n hooks: TransportHooks,\n name: string,\n priority: number,\n key: string,\n options: TransportConnectionOptions\n ) {\n super();\n this.initialize = Runtime.transportConnectionInitializer;\n this.hooks = hooks;\n this.name = name;\n this.priority = priority;\n this.key = key;\n this.options = options;\n\n this.state = 'new';\n this.timeline = options.timeline;\n this.activityTimeout = options.activityTimeout;\n this.id = this.timeline.generateUniqueID();\n }\n\n /** Checks whether the transport handles activity checks by itself.\n *\n * @return {Boolean}\n */\n handlesActivityChecks(): boolean {\n return Boolean(this.hooks.handlesActivityChecks);\n }\n\n /** Checks whether the transport supports the ping/pong API.\n *\n * @return {Boolean}\n */\n supportsPing(): boolean {\n return Boolean(this.hooks.supportsPing);\n }\n\n /** Tries to establish a connection.\n *\n * @returns {Boolean} false if transport is in invalid state\n */\n connect(): boolean {\n if (this.socket || this.state !== 'initialized') {\n return false;\n }\n\n var url = this.hooks.urls.getInitial(this.key, this.options);\n try {\n this.socket = this.hooks.getSocket(url, this.options);\n } catch (e) {\n Util.defer(() => {\n this.onError(e);\n this.changeState('closed');\n });\n return false;\n }\n\n this.bindListeners();\n\n Logger.debug('Connecting', { transport: this.name, url });\n this.changeState('connecting');\n return true;\n }\n\n /** Closes the connection.\n *\n * @return {Boolean} true if there was a connection to close\n */\n close(): boolean {\n if (this.socket) {\n this.socket.close();\n return true;\n } else {\n return false;\n }\n }\n\n /** Sends data over the open connection.\n *\n * @param {String} data\n * @return {Boolean} true only when in the \"open\" state\n */\n send(data: any): boolean {\n if (this.state === 'open') {\n // Workaround for MobileSafari bug (see https://gist.github.com/2052006)\n Util.defer(() => {\n if (this.socket) {\n this.socket.send(data);\n }\n });\n return true;\n } else {\n return false;\n }\n }\n\n /** Sends a ping if the connection is open and transport supports it. */\n ping() {\n if (this.state === 'open' && this.supportsPing()) {\n this.socket.ping();\n }\n }\n\n private onOpen() {\n if (this.hooks.beforeOpen) {\n this.hooks.beforeOpen(\n this.socket,\n this.hooks.urls.getPath(this.key, this.options)\n );\n }\n this.changeState('open');\n this.socket.onopen = undefined;\n }\n\n private onError(error) {\n this.emit('error', { type: 'WebSocketError', error: error });\n this.timeline.error(this.buildTimelineMessage({ error: error.toString() }));\n }\n\n private onClose(closeEvent?: any) {\n if (closeEvent) {\n this.changeState('closed', {\n code: closeEvent.code,\n reason: closeEvent.reason,\n wasClean: closeEvent.wasClean\n });\n } else {\n this.changeState('closed');\n }\n this.unbindListeners();\n this.socket = undefined;\n }\n\n private onMessage(message) {\n this.emit('message', message);\n }\n\n private onActivity() {\n this.emit('activity');\n }\n\n private bindListeners() {\n this.socket.onopen = () => {\n this.onOpen();\n };\n this.socket.onerror = error => {\n this.onError(error);\n };\n this.socket.onclose = closeEvent => {\n this.onClose(closeEvent);\n };\n this.socket.onmessage = message => {\n this.onMessage(message);\n };\n\n if (this.supportsPing()) {\n this.socket.onactivity = () => {\n this.onActivity();\n };\n }\n }\n\n private unbindListeners() {\n if (this.socket) {\n this.socket.onopen = undefined;\n this.socket.onerror = undefined;\n this.socket.onclose = undefined;\n this.socket.onmessage = undefined;\n if (this.supportsPing()) {\n this.socket.onactivity = undefined;\n }\n }\n }\n\n private changeState(state: string, params?: any) {\n this.state = state;\n this.timeline.info(\n this.buildTimelineMessage({\n state: state,\n params: params\n })\n );\n this.emit(state, params);\n }\n\n buildTimelineMessage(message): any {\n return Collections.extend({ cid: this.id }, message);\n }\n}\n","import Factory from '../utils/factory';\nimport TransportHooks from './transport_hooks';\nimport TransportConnection from './transport_connection';\nimport TransportConnectionOptions from './transport_connection_options';\n\n/** Provides interface for transport connection instantiation.\n *\n * Takes transport-specific hooks as the only argument, which allow checking\n * for transport support and creating its connections.\n *\n * Supported hooks: * - file - the name of the file to be fetched during initialization\n * - urls - URL scheme to be used by transport\n * - handlesActivityCheck - true when the transport handles activity checks\n * - supportsPing - true when the transport has a ping/activity API\n * - isSupported - tells whether the transport is supported in the environment\n * - getSocket - creates a WebSocket-compatible transport socket\n *\n * See transports.js for specific implementations.\n *\n * @param {Object} hooks object containing all needed transport hooks\n */\nexport default class Transport {\n hooks: TransportHooks;\n\n constructor(hooks: TransportHooks) {\n this.hooks = hooks;\n }\n\n /** Returns whether the transport is supported in the environment.\n *\n * @param {Object} envronment te environment details (encryption, settings)\n * @returns {Boolean} true when the transport is supported\n */\n isSupported(environment: any): boolean {\n return this.hooks.isSupported(environment);\n }\n\n /** Creates a transport connection.\n *\n * @param {String} name\n * @param {Number} priority\n * @param {String} key the application key\n * @param {Object} options\n * @returns {TransportConnection}\n */\n createConnection(\n name: string,\n priority: number,\n key: string,\n options: any\n ): TransportConnection {\n return new TransportConnection(this.hooks, name, priority, key, options);\n }\n}\n","import * as URLSchemes from 'core/transports/url_schemes';\nimport URLScheme from 'core/transports/url_scheme';\nimport Transport from 'core/transports/transport';\nimport Util from 'core/util';\nimport * as Collections from 'core/utils/collections';\nimport TransportHooks from 'core/transports/transport_hooks';\nimport TransportsTable from 'core/transports/transports_table';\nimport Runtime from 'runtime';\n\n/** WebSocket transport.\n *\n * Uses native WebSocket implementation, including MozWebSocket supported by\n * earlier Firefox versions.\n */\nvar WSTransport = new Transport({\n urls: URLSchemes.ws,\n handlesActivityChecks: false,\n supportsPing: false,\n\n isInitialized: function() {\n return Boolean(Runtime.getWebSocketAPI());\n },\n isSupported: function(): boolean {\n return Boolean(Runtime.getWebSocketAPI());\n },\n getSocket: function(url) {\n return Runtime.createWebSocket(url);\n }\n});\n\nvar httpConfiguration = {\n urls: URLSchemes.http,\n handlesActivityChecks: false,\n supportsPing: true,\n isInitialized: function() {\n return true;\n }\n};\n\nexport var streamingConfiguration = Collections.extend(\n {\n getSocket: function(url) {\n return Runtime.HTTPFactory.createStreamingSocket(url);\n }\n },\n httpConfiguration\n);\nexport var pollingConfiguration = Collections.extend(\n {\n getSocket: function(url) {\n return Runtime.HTTPFactory.createPollingSocket(url);\n }\n },\n httpConfiguration\n);\n\nvar xhrConfiguration = {\n isSupported: function(): boolean {\n return Runtime.isXHRSupported();\n }\n};\n\n/** HTTP streaming transport using CORS-enabled XMLHttpRequest. */\nvar XHRStreamingTransport = new Transport(\n (\n Collections.extend({}, streamingConfiguration, xhrConfiguration)\n )\n);\n\n/** HTTP long-polling transport using CORS-enabled XMLHttpRequest. */\nvar XHRPollingTransport = new Transport(\n Collections.extend({}, pollingConfiguration, xhrConfiguration)\n);\n\nvar Transports: TransportsTable = {\n ws: WSTransport,\n xhr_streaming: XHRStreamingTransport,\n xhr_polling: XHRPollingTransport\n};\n\nexport default Transports;\n","import Util from '../util';\nimport * as Collections from '../utils/collections';\nimport TransportManager from './transport_manager';\nimport TransportConnection from './transport_connection';\nimport Transport from './transport';\nimport PingDelayOptions from './ping_delay_options';\n\n/** Creates transport connections monitored by a transport manager.\n *\n * When a transport is closed, it might mean the environment does not support\n * it. It's possible that messages get stuck in an intermediate buffer or\n * proxies terminate inactive connections. To combat these problems,\n * assistants monitor the connection lifetime, report unclean exits and\n * adjust ping timeouts to keep the connection active. The decision to disable\n * a transport is the manager's responsibility.\n *\n * @param {TransportManager} manager\n * @param {TransportConnection} transport\n * @param {Object} options\n */\nexport default class AssistantToTheTransportManager {\n manager: TransportManager;\n transport: Transport;\n minPingDelay: number;\n maxPingDelay: number;\n pingDelay: number;\n\n constructor(\n manager: TransportManager,\n transport: Transport,\n options: PingDelayOptions\n ) {\n this.manager = manager;\n this.transport = transport;\n this.minPingDelay = options.minPingDelay;\n this.maxPingDelay = options.maxPingDelay;\n this.pingDelay = undefined;\n }\n\n /** Creates a transport connection.\n *\n * This function has the same API as Transport#createConnection.\n *\n * @param {String} name\n * @param {Number} priority\n * @param {String} key the application key\n * @param {Object} options\n * @returns {TransportConnection}\n */\n createConnection(\n name: string,\n priority: number,\n key: string,\n options: Object\n ): TransportConnection {\n options = Collections.extend({}, options, {\n activityTimeout: this.pingDelay\n });\n var connection = this.transport.createConnection(\n name,\n priority,\n key,\n options\n );\n\n var openTimestamp = null;\n\n var onOpen = function() {\n connection.unbind('open', onOpen);\n connection.bind('closed', onClosed);\n openTimestamp = Util.now();\n };\n var onClosed = closeEvent => {\n connection.unbind('closed', onClosed);\n\n if (closeEvent.code === 1002 || closeEvent.code === 1003) {\n // we don't want to use transports not obeying the protocol\n this.manager.reportDeath();\n } else if (!closeEvent.wasClean && openTimestamp) {\n // report deaths only for short-living transport\n var lifespan = Util.now() - openTimestamp;\n if (lifespan < 2 * this.maxPingDelay) {\n this.manager.reportDeath();\n this.pingDelay = Math.max(lifespan / 2, this.minPingDelay);\n }\n }\n };\n\n connection.bind('open', onOpen);\n return connection;\n }\n\n /** Returns whether the transport is supported in the environment.\n *\n * This function has the same API as Transport#isSupported. Might return false\n * when the manager decides to kill the transport.\n *\n * @param {Object} environment the environment details (encryption, settings)\n * @returns {Boolean} true when the transport is supported\n */\n isSupported(environment: string): boolean {\n return this.manager.isAlive() && this.transport.isSupported(environment);\n }\n}\n","import Action from './action';\nimport { PusherEvent } from './message-types';\n/**\n * Provides functions for handling Pusher protocol-specific messages.\n */\n\nconst Protocol = {\n /**\n * Decodes a message in a Pusher format.\n *\n * The MessageEvent we receive from the transport should contain a pusher event\n * (https://pusher.com/docs/pusher_protocol#events) serialized as JSON in the\n * data field\n *\n * The pusher event may contain a data field too, and it may also be\n * serialised as JSON\n *\n * Throws errors when messages are not parse'able.\n *\n * @param {MessageEvent} messageEvent\n * @return {PusherEvent}\n */\n decodeMessage: function(messageEvent: MessageEvent): PusherEvent {\n try {\n var messageData = JSON.parse(messageEvent.data);\n var pusherEventData = messageData.data;\n if (typeof pusherEventData === 'string') {\n try {\n pusherEventData = JSON.parse(messageData.data);\n } catch (e) {}\n }\n var pusherEvent: PusherEvent = {\n event: messageData.event,\n channel: messageData.channel,\n data: pusherEventData\n };\n if (messageData.user_id) {\n pusherEvent.user_id = messageData.user_id;\n }\n return pusherEvent;\n } catch (e) {\n throw { type: 'MessageParseError', error: e, data: messageEvent.data };\n }\n },\n\n /**\n * Encodes a message to be sent.\n *\n * @param {PusherEvent} event\n * @return {String}\n */\n encodeMessage: function(event: PusherEvent): string {\n return JSON.stringify(event);\n },\n\n /**\n * Processes a handshake message and returns appropriate actions.\n *\n * Returns an object with an 'action' and other action-specific properties.\n *\n * There are three outcomes when calling this function. First is a successful\n * connection attempt, when pusher:connection_established is received, which\n * results in a 'connected' action with an 'id' property. When passed a\n * pusher:error event, it returns a result with action appropriate to the\n * close code and an error. Otherwise, it raises an exception.\n *\n * @param {String} message\n * @result Object\n */\n processHandshake: function(messageEvent: MessageEvent): Action {\n var message = Protocol.decodeMessage(messageEvent);\n\n if (message.event === 'pusher:connection_established') {\n if (!message.data.activity_timeout) {\n throw 'No activity timeout specified in handshake';\n }\n return {\n action: 'connected',\n id: message.data.socket_id,\n activityTimeout: message.data.activity_timeout * 1000\n };\n } else if (message.event === 'pusher:error') {\n // From protocol 6 close codes are sent only once, so this only\n // happens when connection does not support close codes\n return {\n action: this.getCloseAction(message.data),\n error: this.getCloseError(message.data)\n };\n } else {\n throw 'Invalid handshake';\n }\n },\n\n /**\n * Dispatches the close event and returns an appropriate action name.\n *\n * See:\n * 1. https://developer.mozilla.org/en-US/docs/WebSockets/WebSockets_reference/CloseEvent\n * 2. http://pusher.com/docs/pusher_protocol\n *\n * @param {CloseEvent} closeEvent\n * @return {String} close action name\n */\n getCloseAction: function(closeEvent): string {\n if (closeEvent.code < 4000) {\n // ignore 1000 CLOSE_NORMAL, 1001 CLOSE_GOING_AWAY,\n // 1005 CLOSE_NO_STATUS, 1006 CLOSE_ABNORMAL\n // ignore 1007...3999\n // handle 1002 CLOSE_PROTOCOL_ERROR, 1003 CLOSE_UNSUPPORTED,\n // 1004 CLOSE_TOO_LARGE\n if (closeEvent.code >= 1002 && closeEvent.code <= 1004) {\n return 'backoff';\n } else {\n return null;\n }\n } else if (closeEvent.code === 4000) {\n return 'tls_only';\n } else if (closeEvent.code < 4100) {\n return 'refused';\n } else if (closeEvent.code < 4200) {\n return 'backoff';\n } else if (closeEvent.code < 4300) {\n return 'retry';\n } else {\n // unknown error\n return 'refused';\n }\n },\n\n /**\n * Returns an error or null basing on the close event.\n *\n * Null is returned when connection was closed cleanly. Otherwise, an object\n * with error details is returned.\n *\n * @param {CloseEvent} closeEvent\n * @return {Object} error object\n */\n getCloseError: function(closeEvent): any {\n if (closeEvent.code !== 1000 && closeEvent.code !== 1001) {\n return {\n type: 'PusherError',\n data: {\n code: closeEvent.code,\n message: closeEvent.reason || closeEvent.message\n }\n };\n } else {\n return null;\n }\n }\n};\n\nexport default Protocol;\n","import * as Collections from '../utils/collections';\nimport { default as EventsDispatcher } from '../events/dispatcher';\nimport Protocol from './protocol/protocol';\nimport { PusherEvent } from './protocol/message-types';\nimport Logger from '../logger';\nimport TransportConnection from '../transports/transport_connection';\nimport Socket from '../socket';\n/**\n * Provides Pusher protocol interface for transports.\n *\n * Emits following events:\n * - message - on received messages\n * - ping - on ping requests\n * - pong - on pong responses\n * - error - when the transport emits an error\n * - closed - after closing the transport\n *\n * It also emits more events when connection closes with a code.\n * See Protocol.getCloseAction to get more details.\n *\n * @param {Number} id\n * @param {AbstractTransport} transport\n */\nexport default class Connection extends EventsDispatcher implements Socket {\n id: string;\n transport: TransportConnection;\n activityTimeout: number;\n\n constructor(id: string, transport: TransportConnection) {\n super();\n this.id = id;\n this.transport = transport;\n this.activityTimeout = transport.activityTimeout;\n this.bindListeners();\n }\n\n /** Returns whether used transport handles activity checks by itself\n *\n * @returns {Boolean} true if activity checks are handled by the transport\n */\n handlesActivityChecks() {\n return this.transport.handlesActivityChecks();\n }\n\n /** Sends raw data.\n *\n * @param {String} data\n */\n send(data: any): boolean {\n return this.transport.send(data);\n }\n\n /** Sends an event.\n *\n * @param {String} name\n * @param {String} data\n * @param {String} [channel]\n * @returns {Boolean} whether message was sent or not\n */\n send_event(name: string, data: any, channel?: string): boolean {\n var event: PusherEvent = { event: name, data: data };\n if (channel) {\n event.channel = channel;\n }\n Logger.debug('Event sent', event);\n return this.send(Protocol.encodeMessage(event));\n }\n\n /** Sends a ping message to the server.\n *\n * Basing on the underlying transport, it might send either transport's\n * protocol-specific ping or pusher:ping event.\n */\n ping() {\n if (this.transport.supportsPing()) {\n this.transport.ping();\n } else {\n this.send_event('pusher:ping', {});\n }\n }\n\n /** Closes the connection. */\n close() {\n this.transport.close();\n }\n\n private bindListeners() {\n var listeners = {\n message: (messageEvent: MessageEvent) => {\n var pusherEvent;\n try {\n pusherEvent = Protocol.decodeMessage(messageEvent);\n } catch (e) {\n this.emit('error', {\n type: 'MessageParseError',\n error: e,\n data: messageEvent.data\n });\n }\n\n if (pusherEvent !== undefined) {\n Logger.debug('Event recd', pusherEvent);\n\n switch (pusherEvent.event) {\n case 'pusher:error':\n this.emit('error', {\n type: 'PusherError',\n data: pusherEvent.data\n });\n break;\n case 'pusher:ping':\n this.emit('ping');\n break;\n case 'pusher:pong':\n this.emit('pong');\n break;\n }\n this.emit('message', pusherEvent);\n }\n },\n activity: () => {\n this.emit('activity');\n },\n error: error => {\n this.emit('error', error);\n },\n closed: closeEvent => {\n unbindListeners();\n\n if (closeEvent && closeEvent.code) {\n this.handleCloseEvent(closeEvent);\n }\n\n this.transport = null;\n this.emit('closed');\n }\n };\n\n var unbindListeners = () => {\n Collections.objectApply(listeners, (listener, event) => {\n this.transport.unbind(event, listener);\n });\n };\n\n Collections.objectApply(listeners, (listener, event) => {\n this.transport.bind(event, listener);\n });\n }\n\n private handleCloseEvent(closeEvent: any) {\n var action = Protocol.getCloseAction(closeEvent);\n var error = Protocol.getCloseError(closeEvent);\n if (error) {\n this.emit('error', error);\n }\n if (action) {\n this.emit(action, { action: action, error: error });\n }\n }\n}\n","import Util from '../../util';\nimport * as Collections from '../../utils/collections';\nimport Protocol from '../protocol/protocol';\nimport Connection from '../connection';\nimport TransportConnection from '../../transports/transport_connection';\nimport HandshakePayload from './handshake_payload';\n\n/**\n * Handles Pusher protocol handshakes for transports.\n *\n * Calls back with a result object after handshake is completed. Results\n * always have two fields:\n * - action - string describing action to be taken after the handshake\n * - transport - the transport object passed to the constructor\n *\n * Different actions can set different additional properties on the result.\n * In the case of 'connected' action, there will be a 'connection' property\n * containing a Connection object for the transport. Other actions should\n * carry an 'error' property.\n *\n * @param {AbstractTransport} transport\n * @param {Function} callback\n */\nexport default class Handshake {\n transport: TransportConnection;\n callback: (HandshakePayload) => void;\n onMessage: Function;\n onClosed: Function;\n\n constructor(\n transport: TransportConnection,\n callback: (HandshakePayload) => void\n ) {\n this.transport = transport;\n this.callback = callback;\n this.bindListeners();\n }\n\n close() {\n this.unbindListeners();\n this.transport.close();\n }\n\n private bindListeners() {\n this.onMessage = m => {\n this.unbindListeners();\n\n var result;\n try {\n result = Protocol.processHandshake(m);\n } catch (e) {\n this.finish('error', { error: e });\n this.transport.close();\n return;\n }\n\n if (result.action === 'connected') {\n this.finish('connected', {\n connection: new Connection(result.id, this.transport),\n activityTimeout: result.activityTimeout\n });\n } else {\n this.finish(result.action, { error: result.error });\n this.transport.close();\n }\n };\n\n this.onClosed = closeEvent => {\n this.unbindListeners();\n\n var action = Protocol.getCloseAction(closeEvent) || 'backoff';\n var error = Protocol.getCloseError(closeEvent);\n this.finish(action, { error: error });\n };\n\n this.transport.bind('message', this.onMessage);\n this.transport.bind('closed', this.onClosed);\n }\n\n private unbindListeners() {\n this.transport.unbind('message', this.onMessage);\n this.transport.unbind('closed', this.onClosed);\n }\n\n private finish(action: string, params: any) {\n this.callback(\n Collections.extend({ transport: this.transport, action: action }, params)\n );\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport base64encode from '../base64';\nimport Timeline from './timeline';\nimport Runtime from 'runtime';\n\nexport interface TimelineSenderOptions {\n host?: string;\n port?: number;\n path?: string;\n}\n\nexport default class TimelineSender {\n timeline: Timeline;\n options: TimelineSenderOptions;\n host: string;\n\n constructor(timeline: Timeline, options: TimelineSenderOptions) {\n this.timeline = timeline;\n this.options = options || {};\n }\n\n send(useTLS: boolean, callback?: Function) {\n if (this.timeline.isEmpty()) {\n return;\n }\n\n this.timeline.send(\n Runtime.TimelineTransport.getAgent(this, useTLS),\n callback\n );\n }\n}\n","/** Error classes used throughout the library. */\n// https://github.com/Microsoft/TypeScript-wiki/blob/master/Breaking-Changes.md#extending-built-ins-like-error-array-and-map-may-no-longer-work\nexport class BadEventName extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\nexport class BadChannelName extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\nexport class RequestTimedOut extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class TransportPriorityTooLow extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class TransportClosed extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class UnsupportedFeature extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class UnsupportedTransport extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class UnsupportedStrategy extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class HTTPAuthError extends Error {\n status: number;\n constructor(status: number, msg?: string) {\n super(msg);\n this.status = status;\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n","/**\n * A place to store help URLs for error messages etc\n */\n\nconst urlStore = {\n baseUrl: 'https://pusher.com',\n urls: {\n authenticationEndpoint: {\n path: '/docs/channels/server_api/authenticating_users'\n },\n authorizationEndpoint: {\n path: '/docs/channels/server_api/authorizing-users/'\n },\n javascriptQuickStart: {\n path: '/docs/javascript_quick_start'\n },\n triggeringClientEvents: {\n path: '/docs/client_api_guide/client_events#trigger-events'\n },\n encryptedChannelSupport: {\n fullUrl:\n 'https://github.com/pusher/pusher-js/tree/cc491015371a4bde5743d1c87a0fbac0feb53195#encrypted-channel-support'\n }\n }\n};\n\n/** Builds a consistent string with links to pusher documentation\n *\n * @param {string} key - relevant key in the url_store.urls object\n * @return {string} suffix string to append to log message\n */\nconst buildLogSuffix = function(key: string): string {\n const urlPrefix = 'See:';\n const urlObj = urlStore.urls[key];\n if (!urlObj) return '';\n\n let url;\n if (urlObj.fullUrl) {\n url = urlObj.fullUrl;\n } else if (urlObj.path) {\n url = urlStore.baseUrl + urlObj.path;\n }\n\n if (!url) return '';\n return `${urlPrefix} ${url}`;\n};\n\nexport default { buildLogSuffix };\n","import { default as EventsDispatcher } from '../events/dispatcher';\nimport * as Errors from '../errors';\nimport Logger from '../logger';\nimport Pusher from '../pusher';\nimport { PusherEvent } from '../connection/protocol/message-types';\nimport Metadata from './metadata';\nimport UrlStore from '../utils/url_store';\nimport {\n ChannelAuthorizationData,\n ChannelAuthorizationCallback\n} from '../auth/options';\nimport { HTTPAuthError } from '../errors';\n\n/** Provides base public channel interface with an event emitter.\n *\n * Emits:\n * - pusher:subscription_succeeded - after subscribing successfully\n * - other non-internal events\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\nexport default class Channel extends EventsDispatcher {\n name: string;\n pusher: Pusher;\n subscribed: boolean;\n subscriptionPending: boolean;\n subscriptionCancelled: boolean;\n subscriptionCount: null;\n\n constructor(name: string, pusher: Pusher) {\n super(function(event, data) {\n Logger.debug('No callbacks on ' + name + ' for ' + event);\n });\n\n this.name = name;\n this.pusher = pusher;\n this.subscribed = false;\n this.subscriptionPending = false;\n this.subscriptionCancelled = false;\n }\n\n /** Skips authorization, since public channels don't require it.\n *\n * @param {Function} callback\n */\n authorize(socketId: string, callback: ChannelAuthorizationCallback) {\n return callback(null, { auth: '' });\n }\n\n /** Triggers an event */\n trigger(event: string, data: any) {\n if (event.indexOf('client-') !== 0) {\n throw new Errors.BadEventName(\n \"Event '\" + event + \"' does not start with 'client-'\"\n );\n }\n if (!this.subscribed) {\n var suffix = UrlStore.buildLogSuffix('triggeringClientEvents');\n Logger.warn(\n `Client event triggered before channel 'subscription_succeeded' event . ${suffix}`\n );\n }\n return this.pusher.send_event(event, data, this.name);\n }\n\n /** Signals disconnection to the channel. For internal use only. */\n disconnect() {\n this.subscribed = false;\n this.subscriptionPending = false;\n }\n\n /** Handles a PusherEvent. For internal use only.\n *\n * @param {PusherEvent} event\n */\n handleEvent(event: PusherEvent) {\n var eventName = event.event;\n var data = event.data;\n if (eventName === 'pusher_internal:subscription_succeeded') {\n this.handleSubscriptionSucceededEvent(event);\n } else if (eventName === 'pusher_internal:subscription_count') {\n this.handleSubscriptionCountEvent(event);\n } else if (eventName.indexOf('pusher_internal:') !== 0) {\n var metadata: Metadata = {};\n this.emit(eventName, data, metadata);\n }\n }\n\n handleSubscriptionSucceededEvent(event: PusherEvent) {\n this.subscriptionPending = false;\n this.subscribed = true;\n if (this.subscriptionCancelled) {\n this.pusher.unsubscribe(this.name);\n } else {\n this.emit('pusher:subscription_succeeded', event.data);\n }\n }\n\n handleSubscriptionCountEvent(event: PusherEvent) {\n if (event.data.subscription_count) {\n this.subscriptionCount = event.data.subscription_count;\n }\n\n this.emit('pusher:subscription_count', event.data);\n }\n\n /** Sends a subscription request. For internal use only. */\n subscribe() {\n if (this.subscribed) {\n return;\n }\n this.subscriptionPending = true;\n this.subscriptionCancelled = false;\n this.authorize(\n this.pusher.connection.socket_id,\n (error: Error | null, data: ChannelAuthorizationData) => {\n if (error) {\n this.subscriptionPending = false;\n // Why not bind to 'pusher:subscription_error' a level up, and log there?\n // Binding to this event would cause the warning about no callbacks being\n // bound (see constructor) to be suppressed, that's not what we want.\n Logger.error(error.toString());\n this.emit(\n 'pusher:subscription_error',\n Object.assign(\n {},\n {\n type: 'AuthError',\n error: error.message\n },\n error instanceof HTTPAuthError ? { status: error.status } : {}\n )\n );\n } else {\n this.pusher.send_event('pusher:subscribe', {\n auth: data.auth,\n channel_data: data.channel_data,\n channel: this.name\n });\n }\n }\n );\n }\n\n /** Sends an unsubscription request. For internal use only. */\n unsubscribe() {\n this.subscribed = false;\n this.pusher.send_event('pusher:unsubscribe', {\n channel: this.name\n });\n }\n\n /** Cancels an in progress subscription. For internal use only. */\n cancelSubscription() {\n this.subscriptionCancelled = true;\n }\n\n /** Reinstates an in progress subscripiton. For internal use only. */\n reinstateSubscription() {\n this.subscriptionCancelled = false;\n }\n}\n","import Factory from '../utils/factory';\nimport Channel from './channel';\nimport { ChannelAuthorizationCallback } from '../auth/options';\n\n/** Extends public channels to provide private channel interface.\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\nexport default class PrivateChannel extends Channel {\n /** Authorizes the connection to use the channel.\n *\n * @param {String} socketId\n * @param {Function} callback\n */\n authorize(socketId: string, callback: ChannelAuthorizationCallback) {\n return this.pusher.config.channelAuthorizer(\n {\n channelName: this.name,\n socketId: socketId\n },\n callback\n );\n }\n}\n","import * as Collections from '../utils/collections';\n\n/** Represents a collection of members of a presence channel. */\nexport default class Members {\n members: any;\n count: number;\n myID: any;\n me: any;\n\n constructor() {\n this.reset();\n }\n\n /** Returns member's info for given id.\n *\n * Resulting object containts two fields - id and info.\n *\n * @param {Number} id\n * @return {Object} member's info or null\n */\n get(id: string): any {\n if (Object.prototype.hasOwnProperty.call(this.members, id)) {\n return {\n id: id,\n info: this.members[id]\n };\n } else {\n return null;\n }\n }\n\n /** Calls back for each member in unspecified order.\n *\n * @param {Function} callback\n */\n each(callback: Function) {\n Collections.objectApply(this.members, (member, id) => {\n callback(this.get(id));\n });\n }\n\n /** Updates the id for connected member. For internal use only. */\n setMyID(id: string) {\n this.myID = id;\n }\n\n /** Handles subscription data. For internal use only. */\n onSubscription(subscriptionData: any) {\n this.members = subscriptionData.presence.hash;\n this.count = subscriptionData.presence.count;\n this.me = this.get(this.myID);\n }\n\n /** Adds a new member to the collection. For internal use only. */\n addMember(memberData: any) {\n if (this.get(memberData.user_id) === null) {\n this.count++;\n }\n this.members[memberData.user_id] = memberData.user_info;\n return this.get(memberData.user_id);\n }\n\n /** Adds a member from the collection. For internal use only. */\n removeMember(memberData: any) {\n var member = this.get(memberData.user_id);\n if (member) {\n delete this.members[memberData.user_id];\n this.count--;\n }\n return member;\n }\n\n /** Resets the collection to the initial state. For internal use only. */\n reset() {\n this.members = {};\n this.count = 0;\n this.myID = null;\n this.me = null;\n }\n}\n","import PrivateChannel from './private_channel';\nimport Logger from '../logger';\nimport Members from './members';\nimport Pusher from '../pusher';\nimport UrlStore from 'core/utils/url_store';\nimport { PusherEvent } from '../connection/protocol/message-types';\nimport Metadata from './metadata';\nimport { ChannelAuthorizationData } from '../auth/options';\n\nexport default class PresenceChannel extends PrivateChannel {\n members: Members;\n\n /** Adds presence channel functionality to private channels.\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\n constructor(name: string, pusher: Pusher) {\n super(name, pusher);\n this.members = new Members();\n }\n\n /** Authorizes the connection as a member of the channel.\n *\n * @param {String} socketId\n * @param {Function} callback\n */\n authorize(socketId: string, callback: Function) {\n super.authorize(socketId, async (error, authData) => {\n if (!error) {\n authData = authData as ChannelAuthorizationData;\n if (authData.channel_data != null) {\n var channelData = JSON.parse(authData.channel_data);\n this.members.setMyID(channelData.user_id);\n } else {\n await this.pusher.user.signinDonePromise;\n if (this.pusher.user.user_data != null) {\n // If the user is signed in, get the id of the authenticated user\n // and allow the presence authorization to continue.\n this.members.setMyID(this.pusher.user.user_data.id);\n } else {\n let suffix = UrlStore.buildLogSuffix('authorizationEndpoint');\n Logger.error(\n `Invalid auth response for channel '${this.name}', ` +\n `expected 'channel_data' field. ${suffix}, ` +\n `or the user should be signed in.`\n );\n callback('Invalid auth response');\n return;\n }\n }\n }\n callback(error, authData);\n });\n }\n\n /** Handles presence and subscription events. For internal use only.\n *\n * @param {PusherEvent} event\n */\n handleEvent(event: PusherEvent) {\n var eventName = event.event;\n if (eventName.indexOf('pusher_internal:') === 0) {\n this.handleInternalEvent(event);\n } else {\n var data = event.data;\n var metadata: Metadata = {};\n if (event.user_id) {\n metadata.user_id = event.user_id;\n }\n this.emit(eventName, data, metadata);\n }\n }\n handleInternalEvent(event: PusherEvent) {\n var eventName = event.event;\n var data = event.data;\n switch (eventName) {\n case 'pusher_internal:subscription_succeeded':\n this.handleSubscriptionSucceededEvent(event);\n break;\n case 'pusher_internal:subscription_count':\n this.handleSubscriptionCountEvent(event);\n break;\n case 'pusher_internal:member_added':\n var addedMember = this.members.addMember(data);\n this.emit('pusher:member_added', addedMember);\n break;\n case 'pusher_internal:member_removed':\n var removedMember = this.members.removeMember(data);\n if (removedMember) {\n this.emit('pusher:member_removed', removedMember);\n }\n break;\n }\n }\n\n handleSubscriptionSucceededEvent(event: PusherEvent) {\n this.subscriptionPending = false;\n this.subscribed = true;\n if (this.subscriptionCancelled) {\n this.pusher.unsubscribe(this.name);\n } else {\n this.members.onSubscription(event.data);\n this.emit('pusher:subscription_succeeded', this.members);\n }\n }\n\n /** Resets the channel state, including members map. For internal use only. */\n disconnect() {\n this.members.reset();\n super.disconnect();\n }\n}\n","import PrivateChannel from './private_channel';\nimport * as Errors from '../errors';\nimport Logger from '../logger';\nimport Pusher from '../pusher';\nimport { decode as encodeUTF8 } from '@stablelib/utf8';\nimport { decode as decodeBase64 } from '@stablelib/base64';\nimport Dispatcher from '../events/dispatcher';\nimport { PusherEvent } from '../connection/protocol/message-types';\nimport {\n ChannelAuthorizationData,\n ChannelAuthorizationCallback\n} from '../auth/options';\nimport * as nacl from 'tweetnacl';\n\n/** Extends private channels to provide encrypted channel interface.\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\nexport default class EncryptedChannel extends PrivateChannel {\n key: Uint8Array = null;\n nacl: nacl;\n\n constructor(name: string, pusher: Pusher, nacl: nacl) {\n super(name, pusher);\n this.nacl = nacl;\n }\n\n /** Authorizes the connection to use the channel.\n *\n * @param {String} socketId\n * @param {Function} callback\n */\n authorize(socketId: string, callback: ChannelAuthorizationCallback) {\n super.authorize(\n socketId,\n (error: Error | null, authData: ChannelAuthorizationData) => {\n if (error) {\n callback(error, authData);\n return;\n }\n let sharedSecret = authData['shared_secret'];\n if (!sharedSecret) {\n callback(\n new Error(\n `No shared_secret key in auth payload for encrypted channel: ${this.name}`\n ),\n null\n );\n return;\n }\n this.key = decodeBase64(sharedSecret);\n delete authData['shared_secret'];\n callback(null, authData);\n }\n );\n }\n\n trigger(event: string, data: any): boolean {\n throw new Errors.UnsupportedFeature(\n 'Client events are not currently supported for encrypted channels'\n );\n }\n\n /** Handles an event. For internal use only.\n *\n * @param {PusherEvent} event\n */\n handleEvent(event: PusherEvent) {\n var eventName = event.event;\n var data = event.data;\n if (\n eventName.indexOf('pusher_internal:') === 0 ||\n eventName.indexOf('pusher:') === 0\n ) {\n super.handleEvent(event);\n return;\n }\n this.handleEncryptedEvent(eventName, data);\n }\n\n private handleEncryptedEvent(event: string, data: any): void {\n if (!this.key) {\n Logger.debug(\n 'Received encrypted event before key has been retrieved from the authEndpoint'\n );\n return;\n }\n if (!data.ciphertext || !data.nonce) {\n Logger.error(\n 'Unexpected format for encrypted event, expected object with `ciphertext` and `nonce` fields, got: ' +\n data\n );\n return;\n }\n let cipherText = decodeBase64(data.ciphertext);\n if (cipherText.length < this.nacl.secretbox.overheadLength) {\n Logger.error(\n `Expected encrypted event ciphertext length to be ${this.nacl.secretbox.overheadLength}, got: ${cipherText.length}`\n );\n return;\n }\n let nonce = decodeBase64(data.nonce);\n if (nonce.length < this.nacl.secretbox.nonceLength) {\n Logger.error(\n `Expected encrypted event nonce length to be ${this.nacl.secretbox.nonceLength}, got: ${nonce.length}`\n );\n return;\n }\n\n let bytes = this.nacl.secretbox.open(cipherText, nonce, this.key);\n if (bytes === null) {\n Logger.debug(\n 'Failed to decrypt an event, probably because it was encrypted with a different key. Fetching a new key from the authEndpoint...'\n );\n // Try a single time to retrieve a new auth key and decrypt the event with it\n // If this fails, a new key will be requested when a new message is received\n this.authorize(this.pusher.connection.socket_id, (error, authData) => {\n if (error) {\n Logger.error(\n `Failed to make a request to the authEndpoint: ${authData}. Unable to fetch new key, so dropping encrypted event`\n );\n return;\n }\n bytes = this.nacl.secretbox.open(cipherText, nonce, this.key);\n if (bytes === null) {\n Logger.error(\n `Failed to decrypt event with new key. Dropping encrypted event`\n );\n return;\n }\n this.emit(event, this.getDataToEmit(bytes));\n return;\n });\n return;\n }\n this.emit(event, this.getDataToEmit(bytes));\n }\n\n // Try and parse the decrypted bytes as JSON. If we can't parse it, just\n // return the utf-8 string\n getDataToEmit(bytes: Uint8Array): string {\n let raw = encodeUTF8(bytes);\n try {\n return JSON.parse(raw);\n } catch {\n return raw;\n }\n }\n}\n","import { default as EventsDispatcher } from '../events/dispatcher';\nimport { OneOffTimer as Timer } from '../utils/timers';\nimport { Config } from '../config';\nimport Logger from '../logger';\nimport HandshakePayload from './handshake/handshake_payload';\nimport Connection from './connection';\nimport Strategy from '../strategies/strategy';\nimport StrategyRunner from '../strategies/strategy_runner';\nimport * as Collections from '../utils/collections';\nimport Timeline from '../timeline/timeline';\nimport ConnectionManagerOptions from './connection_manager_options';\nimport Runtime from 'runtime';\n\nimport {\n ErrorCallbacks,\n HandshakeCallbacks,\n ConnectionCallbacks\n} from './callbacks';\nimport Action from './protocol/action';\n\n/** Manages connection to Pusher.\n *\n * Uses a strategy (currently only default), timers and network availability\n * info to establish a connection and export its state. In case of failures,\n * manages reconnection attempts.\n *\n * Exports state changes as following events:\n * - \"state_change\", { previous: p, current: state }\n * - state\n *\n * States:\n * - initialized - initial state, never transitioned to\n * - connecting - connection is being established\n * - connected - connection has been fully established\n * - disconnected - on requested disconnection\n * - unavailable - after connection timeout or when there's no network\n * - failed - when the connection strategy is not supported\n *\n * Options:\n * - unavailableTimeout - time to transition to unavailable state\n * - activityTimeout - time after which ping message should be sent\n * - pongTimeout - time for Pusher to respond with pong before reconnecting\n *\n * @param {String} key application key\n * @param {Object} options\n */\nexport default class ConnectionManager extends EventsDispatcher {\n key: string;\n options: ConnectionManagerOptions;\n state: string;\n connection: Connection;\n usingTLS: boolean;\n timeline: Timeline;\n socket_id: string;\n unavailableTimer: Timer;\n activityTimer: Timer;\n retryTimer: Timer;\n activityTimeout: number;\n strategy: Strategy;\n runner: StrategyRunner;\n errorCallbacks: ErrorCallbacks;\n handshakeCallbacks: HandshakeCallbacks;\n connectionCallbacks: ConnectionCallbacks;\n\n constructor(key: string, options: ConnectionManagerOptions) {\n super();\n this.state = 'initialized';\n this.connection = null;\n\n this.key = key;\n this.options = options;\n this.timeline = this.options.timeline;\n this.usingTLS = this.options.useTLS;\n\n this.errorCallbacks = this.buildErrorCallbacks();\n this.connectionCallbacks = this.buildConnectionCallbacks(\n this.errorCallbacks\n );\n this.handshakeCallbacks = this.buildHandshakeCallbacks(this.errorCallbacks);\n\n var Network = Runtime.getNetwork();\n\n Network.bind('online', () => {\n this.timeline.info({ netinfo: 'online' });\n if (this.state === 'connecting' || this.state === 'unavailable') {\n this.retryIn(0);\n }\n });\n Network.bind('offline', () => {\n this.timeline.info({ netinfo: 'offline' });\n if (this.connection) {\n this.sendActivityCheck();\n }\n });\n\n this.updateStrategy();\n }\n\n /** Establishes a connection to Pusher.\n *\n * Does nothing when connection is already established. See top-level doc\n * to find events emitted on connection attempts.\n */\n connect() {\n if (this.connection || this.runner) {\n return;\n }\n if (!this.strategy.isSupported()) {\n this.updateState('failed');\n return;\n }\n this.updateState('connecting');\n this.startConnecting();\n this.setUnavailableTimer();\n }\n\n /** Sends raw data.\n *\n * @param {String} data\n */\n send(data) {\n if (this.connection) {\n return this.connection.send(data);\n } else {\n return false;\n }\n }\n\n /** Sends an event.\n *\n * @param {String} name\n * @param {String} data\n * @param {String} [channel]\n * @returns {Boolean} whether message was sent or not\n */\n send_event(name: string, data: any, channel?: string) {\n if (this.connection) {\n return this.connection.send_event(name, data, channel);\n } else {\n return false;\n }\n }\n\n /** Closes the connection. */\n disconnect() {\n this.disconnectInternally();\n this.updateState('disconnected');\n }\n\n isUsingTLS() {\n return this.usingTLS;\n }\n\n private startConnecting() {\n var callback = (error, handshake) => {\n if (error) {\n this.runner = this.strategy.connect(0, callback);\n } else {\n if (handshake.action === 'error') {\n this.emit('error', {\n type: 'HandshakeError',\n error: handshake.error\n });\n this.timeline.error({ handshakeError: handshake.error });\n } else {\n this.abortConnecting(); // we don't support switching connections yet\n this.handshakeCallbacks[handshake.action](handshake);\n }\n }\n };\n this.runner = this.strategy.connect(0, callback);\n }\n\n private abortConnecting() {\n if (this.runner) {\n this.runner.abort();\n this.runner = null;\n }\n }\n\n private disconnectInternally() {\n this.abortConnecting();\n this.clearRetryTimer();\n this.clearUnavailableTimer();\n if (this.connection) {\n var connection = this.abandonConnection();\n connection.close();\n }\n }\n\n private updateStrategy() {\n this.strategy = this.options.getStrategy({\n key: this.key,\n timeline: this.timeline,\n useTLS: this.usingTLS\n });\n }\n\n private retryIn(delay) {\n this.timeline.info({ action: 'retry', delay: delay });\n if (delay > 0) {\n this.emit('connecting_in', Math.round(delay / 1000));\n }\n this.retryTimer = new Timer(delay || 0, () => {\n this.disconnectInternally();\n this.connect();\n });\n }\n\n private clearRetryTimer() {\n if (this.retryTimer) {\n this.retryTimer.ensureAborted();\n this.retryTimer = null;\n }\n }\n\n private setUnavailableTimer() {\n this.unavailableTimer = new Timer(this.options.unavailableTimeout, () => {\n this.updateState('unavailable');\n });\n }\n\n private clearUnavailableTimer() {\n if (this.unavailableTimer) {\n this.unavailableTimer.ensureAborted();\n }\n }\n\n private sendActivityCheck() {\n this.stopActivityCheck();\n this.connection.ping();\n // wait for pong response\n this.activityTimer = new Timer(this.options.pongTimeout, () => {\n this.timeline.error({ pong_timed_out: this.options.pongTimeout });\n this.retryIn(0);\n });\n }\n\n private resetActivityCheck() {\n this.stopActivityCheck();\n // send ping after inactivity\n if (this.connection && !this.connection.handlesActivityChecks()) {\n this.activityTimer = new Timer(this.activityTimeout, () => {\n this.sendActivityCheck();\n });\n }\n }\n\n private stopActivityCheck() {\n if (this.activityTimer) {\n this.activityTimer.ensureAborted();\n }\n }\n\n private buildConnectionCallbacks(\n errorCallbacks: ErrorCallbacks\n ): ConnectionCallbacks {\n return Collections.extend({}, errorCallbacks, {\n message: message => {\n // includes pong messages from server\n this.resetActivityCheck();\n this.emit('message', message);\n },\n ping: () => {\n this.send_event('pusher:pong', {});\n },\n activity: () => {\n this.resetActivityCheck();\n },\n error: error => {\n // just emit error to user - socket will already be closed by browser\n this.emit('error', error);\n },\n closed: () => {\n this.abandonConnection();\n if (this.shouldRetry()) {\n this.retryIn(1000);\n }\n }\n });\n }\n\n private buildHandshakeCallbacks(\n errorCallbacks: ErrorCallbacks\n ): HandshakeCallbacks {\n return Collections.extend({}, errorCallbacks, {\n connected: (handshake: HandshakePayload) => {\n this.activityTimeout = Math.min(\n this.options.activityTimeout,\n handshake.activityTimeout,\n handshake.connection.activityTimeout || Infinity\n );\n this.clearUnavailableTimer();\n this.setConnection(handshake.connection);\n this.socket_id = this.connection.id;\n this.updateState('connected', { socket_id: this.socket_id });\n }\n });\n }\n\n private buildErrorCallbacks(): ErrorCallbacks {\n let withErrorEmitted = callback => {\n return (result: Action | HandshakePayload) => {\n if (result.error) {\n this.emit('error', { type: 'WebSocketError', error: result.error });\n }\n callback(result);\n };\n };\n\n return {\n tls_only: withErrorEmitted(() => {\n this.usingTLS = true;\n this.updateStrategy();\n this.retryIn(0);\n }),\n refused: withErrorEmitted(() => {\n this.disconnect();\n }),\n backoff: withErrorEmitted(() => {\n this.retryIn(1000);\n }),\n retry: withErrorEmitted(() => {\n this.retryIn(0);\n })\n };\n }\n\n private setConnection(connection) {\n this.connection = connection;\n for (var event in this.connectionCallbacks) {\n this.connection.bind(event, this.connectionCallbacks[event]);\n }\n this.resetActivityCheck();\n }\n\n private abandonConnection() {\n if (!this.connection) {\n return;\n }\n this.stopActivityCheck();\n for (var event in this.connectionCallbacks) {\n this.connection.unbind(event, this.connectionCallbacks[event]);\n }\n var connection = this.connection;\n this.connection = null;\n return connection;\n }\n\n private updateState(newState: string, data?: any) {\n var previousState = this.state;\n this.state = newState;\n if (previousState !== newState) {\n var newStateDescription = newState;\n if (newStateDescription === 'connected') {\n newStateDescription += ' with new socket ID ' + data.socket_id;\n }\n Logger.debug(\n 'State changed',\n previousState + ' -> ' + newStateDescription\n );\n this.timeline.info({ state: newState, params: data });\n this.emit('state_change', { previous: previousState, current: newState });\n this.emit(newState, data);\n }\n }\n\n private shouldRetry(): boolean {\n return this.state === 'connecting' || this.state === 'connected';\n }\n}\n","import Channel from './channel';\nimport * as Collections from '../utils/collections';\nimport ChannelTable from './channel_table';\nimport Factory from '../utils/factory';\nimport Pusher from '../pusher';\nimport Logger from '../logger';\nimport * as Errors from '../errors';\nimport urlStore from '../utils/url_store';\n\n/** Handles a channel map. */\nexport default class Channels {\n channels: ChannelTable;\n\n constructor() {\n this.channels = {};\n }\n\n /** Creates or retrieves an existing channel by its name.\n *\n * @param {String} name\n * @param {Pusher} pusher\n * @return {Channel}\n */\n add(name: string, pusher: Pusher) {\n if (!this.channels[name]) {\n this.channels[name] = createChannel(name, pusher);\n }\n return this.channels[name];\n }\n\n /** Returns a list of all channels\n *\n * @return {Array}\n */\n all(): Channel[] {\n return Collections.values(this.channels);\n }\n\n /** Finds a channel by its name.\n *\n * @param {String} name\n * @return {Channel} channel or null if it doesn't exist\n */\n find(name: string) {\n return this.channels[name];\n }\n\n /** Removes a channel from the map.\n *\n * @param {String} name\n */\n remove(name: string) {\n var channel = this.channels[name];\n delete this.channels[name];\n return channel;\n }\n\n /** Proxies disconnection signal to all channels. */\n disconnect() {\n Collections.objectApply(this.channels, function(channel) {\n channel.disconnect();\n });\n }\n}\n\nfunction createChannel(name: string, pusher: Pusher): Channel {\n if (name.indexOf('private-encrypted-') === 0) {\n if (pusher.config.nacl) {\n return Factory.createEncryptedChannel(name, pusher, pusher.config.nacl);\n }\n let errMsg =\n 'Tried to subscribe to a private-encrypted- channel but no nacl implementation available';\n let suffix = urlStore.buildLogSuffix('encryptedChannelSupport');\n throw new Errors.UnsupportedFeature(`${errMsg}. ${suffix}`);\n } else if (name.indexOf('private-') === 0) {\n return Factory.createPrivateChannel(name, pusher);\n } else if (name.indexOf('presence-') === 0) {\n return Factory.createPresenceChannel(name, pusher);\n } else if (name.indexOf('#') === 0) {\n throw new Errors.BadChannelName(\n 'Cannot create a channel with name \"' + name + '\".'\n );\n } else {\n return Factory.createChannel(name, pusher);\n }\n}\n","import AssistantToTheTransportManager from '../transports/assistant_to_the_transport_manager';\nimport PingDelayOptions from '../transports/ping_delay_options';\nimport Transport from '../transports/transport';\nimport TransportManager from '../transports/transport_manager';\nimport Handshake from '../connection/handshake';\nimport TransportConnection from '../transports/transport_connection';\nimport SocketHooks from '../http/socket_hooks';\nimport HTTPSocket from '../http/http_socket';\n\nimport Timeline from '../timeline/timeline';\nimport {\n default as TimelineSender,\n TimelineSenderOptions\n} from '../timeline/timeline_sender';\nimport PresenceChannel from '../channels/presence_channel';\nimport PrivateChannel from '../channels/private_channel';\nimport EncryptedChannel from '../channels/encrypted_channel';\nimport Channel from '../channels/channel';\nimport ConnectionManager from '../connection/connection_manager';\nimport ConnectionManagerOptions from '../connection/connection_manager_options';\nimport Ajax from '../http/ajax';\nimport Channels from '../channels/channels';\nimport Pusher from '../pusher';\nimport { Config } from '../config';\nimport * as nacl from 'tweetnacl';\n\nvar Factory = {\n createChannels(): Channels {\n return new Channels();\n },\n\n createConnectionManager(\n key: string,\n options: ConnectionManagerOptions\n ): ConnectionManager {\n return new ConnectionManager(key, options);\n },\n\n createChannel(name: string, pusher: Pusher): Channel {\n return new Channel(name, pusher);\n },\n\n createPrivateChannel(name: string, pusher: Pusher): PrivateChannel {\n return new PrivateChannel(name, pusher);\n },\n\n createPresenceChannel(name: string, pusher: Pusher): PresenceChannel {\n return new PresenceChannel(name, pusher);\n },\n\n createEncryptedChannel(\n name: string,\n pusher: Pusher,\n nacl: nacl\n ): EncryptedChannel {\n return new EncryptedChannel(name, pusher, nacl);\n },\n\n createTimelineSender(timeline: Timeline, options: TimelineSenderOptions) {\n return new TimelineSender(timeline, options);\n },\n\n createHandshake(\n transport: TransportConnection,\n callback: (HandshakePayload) => void\n ): Handshake {\n return new Handshake(transport, callback);\n },\n\n createAssistantToTheTransportManager(\n manager: TransportManager,\n transport: Transport,\n options: PingDelayOptions\n ): AssistantToTheTransportManager {\n return new AssistantToTheTransportManager(manager, transport, options);\n }\n};\n\nexport default Factory;\n","import AssistantToTheTransportManager from './assistant_to_the_transport_manager';\nimport Transport from './transport';\nimport PingDelayOptions from './ping_delay_options';\nimport Factory from '../utils/factory';\n\nexport interface TransportManagerOptions extends PingDelayOptions {\n lives?: number;\n}\n\n/** Keeps track of the number of lives left for a transport.\n *\n * In the beginning of a session, transports may be assigned a number of\n * lives. When an AssistantToTheTransportManager instance reports a transport\n * connection closed uncleanly, the transport loses a life. When the number\n * of lives drops to zero, the transport gets disabled by its manager.\n *\n * @param {Object} options\n */\nexport default class TransportManager {\n options: TransportManagerOptions;\n livesLeft: number;\n\n constructor(options: TransportManagerOptions) {\n this.options = options || {};\n this.livesLeft = this.options.lives || Infinity;\n }\n\n /** Creates a assistant for the transport.\n *\n * @param {Transport} transport\n * @returns {AssistantToTheTransportManager}\n */\n getAssistant(transport: Transport): AssistantToTheTransportManager {\n return Factory.createAssistantToTheTransportManager(this, transport, {\n minPingDelay: this.options.minPingDelay,\n maxPingDelay: this.options.maxPingDelay\n });\n }\n\n /** Returns whether the transport has any lives left.\n *\n * @returns {Boolean}\n */\n isAlive(): boolean {\n return this.livesLeft > 0;\n }\n\n /** Takes one life from the transport. */\n reportDeath() {\n this.livesLeft -= 1;\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport { OneOffTimer as Timer } from '../utils/timers';\nimport Strategy from './strategy';\nimport StrategyOptions from './strategy_options';\n\n/** Loops through strategies with optional timeouts.\n *\n * Options:\n * - loop - whether it should loop through the substrategy list\n * - timeout - initial timeout for a single substrategy\n * - timeoutLimit - maximum timeout\n *\n * @param {Strategy[]} strategies\n * @param {Object} options\n */\nexport default class SequentialStrategy implements Strategy {\n strategies: Strategy[];\n loop: boolean;\n failFast: boolean;\n timeout: number;\n timeoutLimit: number;\n\n constructor(strategies: Strategy[], options: StrategyOptions) {\n this.strategies = strategies;\n this.loop = Boolean(options.loop);\n this.failFast = Boolean(options.failFast);\n this.timeout = options.timeout;\n this.timeoutLimit = options.timeoutLimit;\n }\n\n isSupported(): boolean {\n return Collections.any(this.strategies, Util.method('isSupported'));\n }\n\n connect(minPriority: number, callback: Function) {\n var strategies = this.strategies;\n var current = 0;\n var timeout = this.timeout;\n var runner = null;\n\n var tryNextStrategy = (error, handshake) => {\n if (handshake) {\n callback(null, handshake);\n } else {\n current = current + 1;\n if (this.loop) {\n current = current % strategies.length;\n }\n\n if (current < strategies.length) {\n if (timeout) {\n timeout = timeout * 2;\n if (this.timeoutLimit) {\n timeout = Math.min(timeout, this.timeoutLimit);\n }\n }\n runner = this.tryStrategy(\n strategies[current],\n minPriority,\n { timeout, failFast: this.failFast },\n tryNextStrategy\n );\n } else {\n callback(true);\n }\n }\n };\n\n runner = this.tryStrategy(\n strategies[current],\n minPriority,\n { timeout: timeout, failFast: this.failFast },\n tryNextStrategy\n );\n\n return {\n abort: function() {\n runner.abort();\n },\n forceMinPriority: function(p) {\n minPriority = p;\n if (runner) {\n runner.forceMinPriority(p);\n }\n }\n };\n }\n\n private tryStrategy(\n strategy: Strategy,\n minPriority: number,\n options: StrategyOptions,\n callback: Function\n ) {\n var timer = null;\n var runner = null;\n\n if (options.timeout > 0) {\n timer = new Timer(options.timeout, function() {\n runner.abort();\n callback(true);\n });\n }\n\n runner = strategy.connect(minPriority, function(error, handshake) {\n if (error && timer && timer.isRunning() && !options.failFast) {\n // advance to the next strategy after the timeout\n return;\n }\n if (timer) {\n timer.ensureAborted();\n }\n callback(error, handshake);\n });\n\n return {\n abort: function() {\n if (timer) {\n timer.ensureAborted();\n }\n runner.abort();\n },\n forceMinPriority: function(p) {\n runner.forceMinPriority(p);\n }\n };\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport Strategy from './strategy';\n\n/** Launches all substrategies and emits prioritized connected transports.\n *\n * @param {Array} strategies\n */\nexport default class BestConnectedEverStrategy implements Strategy {\n strategies: Strategy[];\n\n constructor(strategies: Strategy[]) {\n this.strategies = strategies;\n }\n\n isSupported(): boolean {\n return Collections.any(this.strategies, Util.method('isSupported'));\n }\n\n connect(minPriority: number, callback: Function) {\n return connect(this.strategies, minPriority, function(i, runners) {\n return function(error, handshake) {\n runners[i].error = error;\n if (error) {\n if (allRunnersFailed(runners)) {\n callback(true);\n }\n return;\n }\n Collections.apply(runners, function(runner) {\n runner.forceMinPriority(handshake.transport.priority);\n });\n callback(null, handshake);\n };\n });\n }\n}\n\n/** Connects to all strategies in parallel.\n *\n * Callback builder should be a function that takes two arguments: index\n * and a list of runners. It should return another function that will be\n * passed to the substrategy with given index. Runners can be aborted using\n * abortRunner(s) functions from this class.\n *\n * @param {Array} strategies\n * @param {Function} callbackBuilder\n * @return {Object} strategy runner\n */\nfunction connect(\n strategies: Strategy[],\n minPriority: number,\n callbackBuilder: Function\n) {\n var runners = Collections.map(strategies, function(strategy, i, _, rs) {\n return strategy.connect(minPriority, callbackBuilder(i, rs));\n });\n return {\n abort: function() {\n Collections.apply(runners, abortRunner);\n },\n forceMinPriority: function(p) {\n Collections.apply(runners, function(runner) {\n runner.forceMinPriority(p);\n });\n }\n };\n}\n\nfunction allRunnersFailed(runners): boolean {\n return Collections.all(runners, function(runner) {\n return Boolean(runner.error);\n });\n}\n\nfunction abortRunner(runner) {\n if (!runner.error && !runner.aborted) {\n runner.abort();\n runner.aborted = true;\n }\n}\n","import Util from '../util';\nimport Runtime from 'runtime';\nimport Strategy from './strategy';\nimport SequentialStrategy from './sequential_strategy';\nimport StrategyOptions from './strategy_options';\nimport TransportStrategy from './transport_strategy';\nimport Timeline from '../timeline/timeline';\nimport * as Collections from '../utils/collections';\n\nexport interface TransportStrategyDictionary {\n [key: string]: TransportStrategy;\n}\n\n/** Caches the last successful transport and, after the first few attempts,\n * uses the cached transport for subsequent attempts.\n *\n * @param {Strategy} strategy\n * @param {Object} transports\n * @param {Object} options\n */\nexport default class WebSocketPrioritizedCachedStrategy implements Strategy {\n strategy: Strategy;\n transports: TransportStrategyDictionary;\n ttl: number;\n usingTLS: boolean;\n timeline: Timeline;\n\n constructor(\n strategy: Strategy,\n transports: TransportStrategyDictionary,\n options: StrategyOptions\n ) {\n this.strategy = strategy;\n this.transports = transports;\n this.ttl = options.ttl || 1800 * 1000;\n this.usingTLS = options.useTLS;\n this.timeline = options.timeline;\n }\n\n isSupported(): boolean {\n return this.strategy.isSupported();\n }\n\n connect(minPriority: number, callback: Function) {\n var usingTLS = this.usingTLS;\n var info = fetchTransportCache(usingTLS);\n var cacheSkipCount = info && info.cacheSkipCount ? info.cacheSkipCount : 0;\n\n var strategies = [this.strategy];\n if (info && info.timestamp + this.ttl >= Util.now()) {\n var transport = this.transports[info.transport];\n if (transport) {\n if (['ws', 'wss'].includes(info.transport) || cacheSkipCount > 3) {\n this.timeline.info({\n cached: true,\n transport: info.transport,\n latency: info.latency\n });\n strategies.push(\n new SequentialStrategy([transport], {\n timeout: info.latency * 2 + 1000,\n failFast: true\n })\n );\n } else {\n cacheSkipCount++;\n }\n }\n }\n\n var startTimestamp = Util.now();\n var runner = strategies\n .pop()\n .connect(minPriority, function cb(error, handshake) {\n if (error) {\n flushTransportCache(usingTLS);\n if (strategies.length > 0) {\n startTimestamp = Util.now();\n runner = strategies.pop().connect(minPriority, cb);\n } else {\n callback(error);\n }\n } else {\n storeTransportCache(\n usingTLS,\n handshake.transport.name,\n Util.now() - startTimestamp,\n cacheSkipCount\n );\n callback(null, handshake);\n }\n });\n\n return {\n abort: function() {\n runner.abort();\n },\n forceMinPriority: function(p) {\n minPriority = p;\n if (runner) {\n runner.forceMinPriority(p);\n }\n }\n };\n }\n}\n\nfunction getTransportCacheKey(usingTLS: boolean): string {\n return 'pusherTransport' + (usingTLS ? 'TLS' : 'NonTLS');\n}\n\nfunction fetchTransportCache(usingTLS: boolean): any {\n var storage = Runtime.getLocalStorage();\n if (storage) {\n try {\n var serializedCache = storage[getTransportCacheKey(usingTLS)];\n if (serializedCache) {\n return JSON.parse(serializedCache);\n }\n } catch (e) {\n flushTransportCache(usingTLS);\n }\n }\n return null;\n}\n\nfunction storeTransportCache(\n usingTLS: boolean,\n transport: TransportStrategy,\n latency: number,\n cacheSkipCount: number\n) {\n var storage = Runtime.getLocalStorage();\n if (storage) {\n try {\n storage[getTransportCacheKey(usingTLS)] = Collections.safeJSONStringify({\n timestamp: Util.now(),\n transport: transport,\n latency: latency,\n cacheSkipCount: cacheSkipCount\n });\n } catch (e) {\n // catch over quota exceptions raised by localStorage\n }\n }\n}\n\nfunction flushTransportCache(usingTLS: boolean) {\n var storage = Runtime.getLocalStorage();\n if (storage) {\n try {\n delete storage[getTransportCacheKey(usingTLS)];\n } catch (e) {\n // catch exceptions raised by localStorage\n }\n }\n}\n","import { OneOffTimer as Timer } from '../utils/timers';\nimport Strategy from './strategy';\nimport StrategyOptions from './strategy_options';\n\n/** Runs substrategy after specified delay.\n *\n * Options:\n * - delay - time in miliseconds to delay the substrategy attempt\n *\n * @param {Strategy} strategy\n * @param {Object} options\n */\nexport default class DelayedStrategy implements Strategy {\n strategy: Strategy;\n options: { delay: number };\n\n constructor(strategy: Strategy, { delay: number }) {\n this.strategy = strategy;\n this.options = { delay: number };\n }\n\n isSupported(): boolean {\n return this.strategy.isSupported();\n }\n\n connect(minPriority: number, callback: Function) {\n var strategy = this.strategy;\n var runner;\n var timer = new Timer(this.options.delay, function() {\n runner = strategy.connect(minPriority, callback);\n });\n\n return {\n abort: function() {\n timer.ensureAborted();\n if (runner) {\n runner.abort();\n }\n },\n forceMinPriority: function(p) {\n minPriority = p;\n if (runner) {\n runner.forceMinPriority(p);\n }\n }\n };\n }\n}\n","import Strategy from './strategy';\nimport StrategyRunner from './strategy_runner';\n\n/** Proxies method calls to one of substrategies basing on the test function.\n *\n * @param {Function} test\n * @param {Strategy} trueBranch strategy used when test returns true\n * @param {Strategy} falseBranch strategy used when test returns false\n */\nexport default class IfStrategy implements Strategy {\n test: () => boolean;\n trueBranch: Strategy;\n falseBranch: Strategy;\n\n constructor(\n test: () => boolean,\n trueBranch: Strategy,\n falseBranch: Strategy\n ) {\n this.test = test;\n this.trueBranch = trueBranch;\n this.falseBranch = falseBranch;\n }\n\n isSupported(): boolean {\n var branch = this.test() ? this.trueBranch : this.falseBranch;\n return branch.isSupported();\n }\n\n connect(minPriority: number, callback: Function): StrategyRunner {\n var branch = this.test() ? this.trueBranch : this.falseBranch;\n return branch.connect(minPriority, callback);\n }\n}\n","import Strategy from './strategy';\nimport StrategyRunner from './strategy_runner';\n\n/** Launches the substrategy and terminates on the first open connection.\n *\n * @param {Strategy} strategy\n */\nexport default class FirstConnectedStrategy implements Strategy {\n strategy: Strategy;\n\n constructor(strategy: Strategy) {\n this.strategy = strategy;\n }\n\n isSupported(): boolean {\n return this.strategy.isSupported();\n }\n\n connect(minPriority: number, callback: Function): StrategyRunner {\n var runner = this.strategy.connect(minPriority, function(error, handshake) {\n if (handshake) {\n runner.abort();\n }\n callback(error, handshake);\n });\n return runner;\n }\n}\n","import * as Collections from 'core/utils/collections';\nimport TransportManager from 'core/transports/transport_manager';\nimport Strategy from 'core/strategies/strategy';\nimport SequentialStrategy from 'core/strategies/sequential_strategy';\nimport BestConnectedEverStrategy from 'core/strategies/best_connected_ever_strategy';\nimport WebSocketPrioritizedCachedStrategy, {\n TransportStrategyDictionary\n} from 'core/strategies/websocket_prioritized_cached_strategy';\nimport DelayedStrategy from 'core/strategies/delayed_strategy';\nimport IfStrategy from 'core/strategies/if_strategy';\nimport FirstConnectedStrategy from 'core/strategies/first_connected_strategy';\nimport { Config } from 'core/config';\nimport StrategyOptions from 'core/strategies/strategy_options';\n\nfunction testSupportsStrategy(strategy: Strategy) {\n return function() {\n return strategy.isSupported();\n };\n}\n\nvar getDefaultStrategy = function(\n config: Config,\n baseOptions: StrategyOptions,\n defineTransport: Function\n): Strategy {\n var definedTransports = {};\n\n function defineTransportStrategy(\n name: string,\n type: string,\n priority: number,\n options: StrategyOptions,\n manager?: TransportManager\n ) {\n var transport = defineTransport(\n config,\n name,\n type,\n priority,\n options,\n manager\n );\n\n definedTransports[name] = transport;\n\n return transport;\n }\n\n var ws_options: StrategyOptions = Object.assign({}, baseOptions, {\n hostNonTLS: config.wsHost + ':' + config.wsPort,\n hostTLS: config.wsHost + ':' + config.wssPort,\n httpPath: config.wsPath\n });\n var wss_options: StrategyOptions = Collections.extend({}, ws_options, {\n useTLS: true\n });\n var http_options: StrategyOptions = Object.assign({}, baseOptions, {\n hostNonTLS: config.httpHost + ':' + config.httpPort,\n hostTLS: config.httpHost + ':' + config.httpsPort,\n httpPath: config.httpPath\n });\n var timeouts = {\n loop: true,\n timeout: 15000,\n timeoutLimit: 60000\n };\n\n var ws_manager = new TransportManager({\n minPingDelay: 10000,\n maxPingDelay: config.activityTimeout\n });\n var streaming_manager = new TransportManager({\n lives: 2,\n minPingDelay: 10000,\n maxPingDelay: config.activityTimeout\n });\n\n var ws_transport = defineTransportStrategy(\n 'ws',\n 'ws',\n 3,\n ws_options,\n ws_manager\n );\n var wss_transport = defineTransportStrategy(\n 'wss',\n 'ws',\n 3,\n wss_options,\n ws_manager\n );\n var xhr_streaming_transport = defineTransportStrategy(\n 'xhr_streaming',\n 'xhr_streaming',\n 1,\n http_options,\n streaming_manager\n );\n var xhr_polling_transport = defineTransportStrategy(\n 'xhr_polling',\n 'xhr_polling',\n 1,\n http_options\n );\n\n var ws_loop = new SequentialStrategy([ws_transport], timeouts);\n var wss_loop = new SequentialStrategy([wss_transport], timeouts);\n var streaming_loop = new SequentialStrategy(\n [xhr_streaming_transport],\n timeouts\n );\n var polling_loop = new SequentialStrategy([xhr_polling_transport], timeouts);\n\n var http_loop = new SequentialStrategy(\n [\n new IfStrategy(\n testSupportsStrategy(streaming_loop),\n new BestConnectedEverStrategy([\n streaming_loop,\n new DelayedStrategy(polling_loop, { delay: 4000 })\n ]),\n polling_loop\n )\n ],\n timeouts\n );\n\n var wsStrategy;\n if (baseOptions.useTLS) {\n wsStrategy = new BestConnectedEverStrategy([\n ws_loop,\n new DelayedStrategy(http_loop, { delay: 2000 })\n ]);\n } else {\n wsStrategy = new BestConnectedEverStrategy([\n ws_loop,\n new DelayedStrategy(wss_loop, { delay: 2000 }),\n new DelayedStrategy(http_loop, { delay: 5000 })\n ]);\n }\n\n return new WebSocketPrioritizedCachedStrategy(\n new FirstConnectedStrategy(\n new IfStrategy(testSupportsStrategy(ws_transport), wsStrategy, http_loop)\n ),\n definedTransports,\n {\n ttl: 1800000,\n timeline: baseOptions.timeline,\n useTLS: baseOptions.useTLS\n }\n );\n};\n\nexport default getDefaultStrategy;\n","import Runtime from 'runtime';\nimport RequestHooks from './request_hooks';\nimport Ajax from './ajax';\nimport { default as EventsDispatcher } from '../events/dispatcher';\n\nconst MAX_BUFFER_LENGTH = 256 * 1024;\n\nexport default class HTTPRequest extends EventsDispatcher {\n hooks: RequestHooks;\n method: string;\n url: string;\n position: number;\n xhr: Ajax;\n unloader: Function;\n\n constructor(hooks: RequestHooks, method: string, url: string) {\n super();\n this.hooks = hooks;\n this.method = method;\n this.url = url;\n }\n\n start(payload?: any) {\n this.position = 0;\n this.xhr = this.hooks.getRequest(this);\n\n this.unloader = () => {\n this.close();\n };\n Runtime.addUnloadListener(this.unloader);\n\n this.xhr.open(this.method, this.url, true);\n\n if (this.xhr.setRequestHeader) {\n this.xhr.setRequestHeader('Content-Type', 'application/json'); // ReactNative doesn't set this header by default.\n }\n this.xhr.send(payload);\n }\n\n close() {\n if (this.unloader) {\n Runtime.removeUnloadListener(this.unloader);\n this.unloader = null;\n }\n if (this.xhr) {\n this.hooks.abortRequest(this.xhr);\n this.xhr = null;\n }\n }\n\n onChunk(status: number, data: any) {\n while (true) {\n var chunk = this.advanceBuffer(data);\n if (chunk) {\n this.emit('chunk', { status: status, data: chunk });\n } else {\n break;\n }\n }\n if (this.isBufferTooLong(data)) {\n this.emit('buffer_too_long');\n }\n }\n\n private advanceBuffer(buffer: any[]): any {\n var unreadData = buffer.slice(this.position);\n var endOfLinePosition = unreadData.indexOf('\\n');\n\n if (endOfLinePosition !== -1) {\n this.position += endOfLinePosition + 1;\n return unreadData.slice(0, endOfLinePosition);\n } else {\n // chunk is not finished yet, don't move the buffer pointer\n return null;\n }\n }\n\n private isBufferTooLong(buffer: any): boolean {\n return this.position === buffer.length && buffer.length > MAX_BUFFER_LENGTH;\n }\n}\n","enum State {\n CONNECTING = 0,\n OPEN = 1,\n CLOSED = 3\n}\n\nexport default State;\n","import URLLocation from './url_location';\nimport State from './state';\nimport Socket from '../socket';\nimport SocketHooks from './socket_hooks';\nimport Util from '../util';\nimport Ajax from './ajax';\nimport HTTPRequest from './http_request';\nimport Runtime from 'runtime';\n\nvar autoIncrement = 1;\n\nclass HTTPSocket implements Socket {\n hooks: SocketHooks;\n session: string;\n location: URLLocation;\n readyState: State;\n stream: HTTPRequest;\n\n onopen: () => void;\n onerror: (error: any) => void;\n onclose: (closeEvent: any) => void;\n onmessage: (message: any) => void;\n onactivity: () => void;\n\n constructor(hooks: SocketHooks, url: string) {\n this.hooks = hooks;\n this.session = randomNumber(1000) + '/' + randomString(8);\n this.location = getLocation(url);\n this.readyState = State.CONNECTING;\n this.openStream();\n }\n\n send(payload: any) {\n return this.sendRaw(JSON.stringify([payload]));\n }\n\n ping() {\n this.hooks.sendHeartbeat(this);\n }\n\n close(code: any, reason: any) {\n this.onClose(code, reason, true);\n }\n\n /** For internal use only */\n sendRaw(payload: any): boolean {\n if (this.readyState === State.OPEN) {\n try {\n Runtime.createSocketRequest(\n 'POST',\n getUniqueURL(getSendURL(this.location, this.session))\n ).start(payload);\n return true;\n } catch (e) {\n return false;\n }\n } else {\n return false;\n }\n }\n\n /** For internal use only */\n reconnect() {\n this.closeStream();\n this.openStream();\n }\n\n /** For internal use only */\n onClose(code, reason, wasClean) {\n this.closeStream();\n this.readyState = State.CLOSED;\n if (this.onclose) {\n this.onclose({\n code: code,\n reason: reason,\n wasClean: wasClean\n });\n }\n }\n\n private onChunk(chunk) {\n if (chunk.status !== 200) {\n return;\n }\n if (this.readyState === State.OPEN) {\n this.onActivity();\n }\n\n var payload;\n var type = chunk.data.slice(0, 1);\n switch (type) {\n case 'o':\n payload = JSON.parse(chunk.data.slice(1) || '{}');\n this.onOpen(payload);\n break;\n case 'a':\n payload = JSON.parse(chunk.data.slice(1) || '[]');\n for (var i = 0; i < payload.length; i++) {\n this.onEvent(payload[i]);\n }\n break;\n case 'm':\n payload = JSON.parse(chunk.data.slice(1) || 'null');\n this.onEvent(payload);\n break;\n case 'h':\n this.hooks.onHeartbeat(this);\n break;\n case 'c':\n payload = JSON.parse(chunk.data.slice(1) || '[]');\n this.onClose(payload[0], payload[1], true);\n break;\n }\n }\n\n private onOpen(options) {\n if (this.readyState === State.CONNECTING) {\n if (options && options.hostname) {\n this.location.base = replaceHost(this.location.base, options.hostname);\n }\n this.readyState = State.OPEN;\n\n if (this.onopen) {\n this.onopen();\n }\n } else {\n this.onClose(1006, 'Server lost session', true);\n }\n }\n\n private onEvent(event) {\n if (this.readyState === State.OPEN && this.onmessage) {\n this.onmessage({ data: event });\n }\n }\n\n private onActivity() {\n if (this.onactivity) {\n this.onactivity();\n }\n }\n\n private onError(error) {\n if (this.onerror) {\n this.onerror(error);\n }\n }\n\n private openStream() {\n this.stream = Runtime.createSocketRequest(\n 'POST',\n getUniqueURL(this.hooks.getReceiveURL(this.location, this.session))\n );\n\n this.stream.bind('chunk', chunk => {\n this.onChunk(chunk);\n });\n this.stream.bind('finished', status => {\n this.hooks.onFinished(this, status);\n });\n this.stream.bind('buffer_too_long', () => {\n this.reconnect();\n });\n\n try {\n this.stream.start();\n } catch (error) {\n Util.defer(() => {\n this.onError(error);\n this.onClose(1006, 'Could not start streaming', false);\n });\n }\n }\n\n private closeStream() {\n if (this.stream) {\n this.stream.unbind_all();\n this.stream.close();\n this.stream = null;\n }\n }\n}\n\nfunction getLocation(url): URLLocation {\n var parts = /([^\\?]*)\\/*(\\??.*)/.exec(url);\n return {\n base: parts[1],\n queryString: parts[2]\n };\n}\n\nfunction getSendURL(url: URLLocation, session: string): string {\n return url.base + '/' + session + '/xhr_send';\n}\n\nfunction getUniqueURL(url: string): string {\n var separator = url.indexOf('?') === -1 ? '?' : '&';\n return url + separator + 't=' + +new Date() + '&n=' + autoIncrement++;\n}\n\nfunction replaceHost(url: string, hostname: string): string {\n var urlParts = /(https?:\\/\\/)([^\\/:]+)((\\/|:)?.*)/.exec(url);\n return urlParts[1] + hostname + urlParts[3];\n}\n\nfunction randomNumber(max: number): number {\n return Runtime.randomInt(max);\n}\n\nfunction randomString(length: number): string {\n var result = [];\n\n for (var i = 0; i < length; i++) {\n result.push(randomNumber(32).toString(32));\n }\n\n return result.join('');\n}\n\nexport default HTTPSocket;\n","import SocketHooks from './socket_hooks';\nimport HTTPSocket from './http_socket';\n\nvar hooks: SocketHooks = {\n getReceiveURL: function(url, session) {\n return url.base + '/' + session + '/xhr_streaming' + url.queryString;\n },\n onHeartbeat: function(socket) {\n socket.sendRaw('[]');\n },\n sendHeartbeat: function(socket) {\n socket.sendRaw('[]');\n },\n onFinished: function(socket, status) {\n socket.onClose(1006, 'Connection interrupted (' + status + ')', false);\n }\n};\n\nexport default hooks;\n","import SocketHooks from './socket_hooks';\nimport URLLocation from './url_location';\nimport HTTPSocket from './http_socket';\n\nvar hooks: SocketHooks = {\n getReceiveURL: function(url: URLLocation, session: string): string {\n return url.base + '/' + session + '/xhr' + url.queryString;\n },\n onHeartbeat: function() {\n // next HTTP request will reset server's activity timer\n },\n sendHeartbeat: function(socket) {\n socket.sendRaw('[]');\n },\n onFinished: function(socket, status) {\n if (status === 200) {\n socket.reconnect();\n } else {\n socket.onClose(1006, 'Connection interrupted (' + status + ')', false);\n }\n }\n};\n\nexport default hooks;\n","import HTTPRequest from 'core/http/http_request';\nimport RequestHooks from 'core/http/request_hooks';\nimport Ajax from 'core/http/ajax';\nimport Runtime from 'runtime';\n\nvar hooks: RequestHooks = {\n getRequest: function(socket: HTTPRequest): Ajax {\n var Constructor = Runtime.getXHRAPI();\n var xhr = new Constructor();\n xhr.onreadystatechange = xhr.onprogress = function() {\n switch (xhr.readyState) {\n case 3:\n if (xhr.responseText && xhr.responseText.length > 0) {\n socket.onChunk(xhr.status, xhr.responseText);\n }\n break;\n case 4:\n // this happens only on errors, never after calling close\n if (xhr.responseText && xhr.responseText.length > 0) {\n socket.onChunk(xhr.status, xhr.responseText);\n }\n socket.emit('finished', xhr.status);\n socket.close();\n break;\n }\n };\n return xhr;\n },\n abortRequest: function(xhr: Ajax) {\n xhr.onreadystatechange = null;\n xhr.abort();\n }\n};\n\nexport default hooks;\n","import * as Collections from 'core/utils/collections';\nimport Transports from 'isomorphic/transports/transports';\nimport TimelineSender from 'core/timeline/timeline_sender';\nimport Ajax from 'core/http/ajax';\nimport getDefaultStrategy from './default_strategy';\nimport TransportsTable from 'core/transports/transports_table';\nimport transportConnectionInitializer from './transports/transport_connection_initializer';\nimport HTTPFactory from './http/http';\n\nvar Isomorphic: any = {\n getDefaultStrategy,\n Transports: Transports,\n transportConnectionInitializer,\n HTTPFactory,\n\n setup(PusherClass): void {\n PusherClass.ready();\n },\n\n getLocalStorage(): any {\n return undefined;\n },\n\n getClientFeatures(): any[] {\n return Collections.keys(\n Collections.filterObject({ ws: Transports.ws }, function(t) {\n return t.isSupported({});\n })\n );\n },\n\n getProtocol(): string {\n return 'http:';\n },\n\n isXHRSupported(): boolean {\n return true;\n },\n\n createSocketRequest(method: string, url: string) {\n if (this.isXHRSupported()) {\n return this.HTTPFactory.createXHR(method, url);\n } else {\n throw 'Cross-origin HTTP requests are not supported';\n }\n },\n\n createXHR(): Ajax {\n var Constructor = this.getXHRAPI();\n return new Constructor();\n },\n\n createWebSocket(url: string): any {\n var Constructor = this.getWebSocketAPI();\n return new Constructor(url);\n },\n\n addUnloadListener(listener: any) {},\n removeUnloadListener(listener: any) {}\n};\n\nexport default Isomorphic;\n","/** Initializes the transport.\n *\n * Fetches resources if needed and then transitions to initialized.\n */\nexport default function() {\n var self = this;\n\n self.timeline.info(\n self.buildTimelineMessage({\n transport: self.name + (self.options.useTLS ? 's' : '')\n })\n );\n\n if (self.hooks.isInitialized()) {\n self.changeState('initialized');\n } else {\n self.onClose();\n }\n}\n","import HTTPRequest from 'core/http/http_request';\nimport HTTPSocket from 'core/http/http_socket';\nimport SocketHooks from 'core/http/socket_hooks';\nimport RequestHooks from 'core/http/request_hooks';\nimport streamingHooks from 'core/http/http_streaming_socket';\nimport pollingHooks from 'core/http/http_polling_socket';\nimport xhrHooks from './http_xhr_request';\nimport HTTPFactory from 'core/http/http_factory';\n\nvar HTTP: HTTPFactory = {\n createStreamingSocket(url: string): HTTPSocket {\n return this.createSocket(streamingHooks, url);\n },\n\n createPollingSocket(url: string): HTTPSocket {\n return this.createSocket(pollingHooks, url);\n },\n\n createSocket(hooks: SocketHooks, url: string): HTTPSocket {\n return new HTTPSocket(hooks, url);\n },\n\n createXHR(method: string, url: string): HTTPRequest {\n return this.createRequest(xhrHooks, method, url);\n },\n\n createRequest(hooks: RequestHooks, method: string, url: string): HTTPRequest {\n return new HTTPRequest(hooks, method, url);\n }\n};\n\nexport default HTTP;\n","import { default as EventsDispatcher } from 'core/events/dispatcher';\nimport Reachability from 'core/reachability';\n\nexport class NetInfo extends EventsDispatcher implements Reachability {\n isOnline(): boolean {\n return true;\n }\n}\n\nexport var Network = new NetInfo();\n","import AbstractRuntime from 'runtimes/interface';\nimport { AuthTransport } from 'core/auth/auth_transports';\nimport {\n AuthRequestType,\n AuthTransportCallback,\n InternalAuthOptions\n} from 'core/auth/options';\nimport { HTTPAuthError } from 'core/errors';\n\nvar fetchAuth: AuthTransport = function(\n context: AbstractRuntime,\n query: string,\n authOptions: InternalAuthOptions,\n authRequestType: AuthRequestType,\n callback: AuthTransportCallback\n) {\n var headers = new Headers();\n headers.set('Content-Type', 'application/x-www-form-urlencoded');\n\n for (var headerName in authOptions.headers) {\n headers.set(headerName, authOptions.headers[headerName]);\n }\n\n if (authOptions.headersProvider != null) {\n const dynamicHeaders = authOptions.headersProvider();\n for (var headerName in dynamicHeaders) {\n headers.set(headerName, dynamicHeaders[headerName]);\n }\n }\n\n var body = query;\n var request = new Request(authOptions.endpoint, {\n headers,\n body,\n credentials: 'same-origin',\n method: 'POST'\n });\n\n return fetch(request)\n .then(response => {\n let { status } = response;\n if (status === 200) {\n // manually parse the json so we can provide a more helpful error in\n // failure case\n return response.text();\n }\n throw new HTTPAuthError(\n status,\n `Could not get ${authRequestType.toString()} info from your auth endpoint, status: ${status}`\n );\n })\n .then(data => {\n let parsedData;\n try {\n parsedData = JSON.parse(data);\n } catch (e) {\n throw new HTTPAuthError(\n 200,\n `JSON returned from ${authRequestType.toString()} endpoint was invalid, yet status code was 200. Data was: ${data}`\n );\n }\n callback(null, parsedData);\n })\n .catch(err => {\n callback(err, null);\n });\n};\n\nexport default fetchAuth;\n","import Logger from 'core/logger';\nimport TimelineSender from 'core/timeline/timeline_sender';\nimport * as Collections from 'core/utils/collections';\nimport Util from 'core/util';\nimport Runtime from 'runtime';\nimport TimelineTransport from 'core/timeline/timeline_transport';\n\nvar getAgent = function(sender: TimelineSender, useTLS: boolean) {\n return function(data: any, callback: Function) {\n var scheme = 'http' + (useTLS ? 's' : '') + '://';\n var url =\n scheme + (sender.host || sender.options.host) + sender.options.path;\n var query = Collections.buildQueryString(data);\n url += '/' + 2 + '?' + query;\n\n fetch(url)\n .then(response => {\n if (response.status !== 200) {\n throw `received ${response.status} from stats.pusher.com`;\n }\n return response.json();\n })\n .then(({ host }) => {\n if (host) {\n sender.host = host;\n }\n })\n .catch(err => {\n Logger.debug('TimelineSender Error: ', err);\n });\n };\n};\n\nvar fetchTimeline = {\n name: 'xhr',\n getAgent\n};\n\nexport default fetchTimeline;\n","import Isomorphic from 'isomorphic/runtime';\nimport Runtime from '../interface';\nimport { Network } from './net_info';\nimport fetchAuth from './auth/fetch_auth';\nimport { AuthTransports } from 'core/auth/auth_transports';\nimport fetchTimeline from './timeline/fetch_timeline';\n\n// Very verbose but until unavoidable until\n// TypeScript 2.1, when spread attributes will be\n// supported\nconst {\n getDefaultStrategy,\n Transports,\n setup,\n getProtocol,\n isXHRSupported,\n getLocalStorage,\n createXHR,\n createWebSocket,\n addUnloadListener,\n removeUnloadListener,\n transportConnectionInitializer,\n createSocketRequest,\n HTTPFactory\n} = Isomorphic;\n\nconst Worker: Runtime = {\n getDefaultStrategy,\n Transports,\n setup,\n getProtocol,\n isXHRSupported,\n getLocalStorage,\n createXHR,\n createWebSocket,\n addUnloadListener,\n removeUnloadListener,\n transportConnectionInitializer,\n createSocketRequest,\n HTTPFactory,\n\n TimelineTransport: fetchTimeline,\n\n getAuthorizers(): AuthTransports {\n return { ajax: fetchAuth };\n },\n\n getWebSocketAPI() {\n return WebSocket;\n },\n\n getXHRAPI() {\n return XMLHttpRequest;\n },\n\n getNetwork() {\n return Network;\n },\n\n randomInt(max: number): number {\n /**\n * Return values in the range of [0, 1[\n */\n const random = function() {\n const crypto = globalThis.crypto || globalThis['msCrypto'];\n const random = crypto.getRandomValues(new Uint32Array(1))[0];\n\n return random / 2 ** 32;\n };\n\n return Math.floor(random() * max);\n }\n};\n\nexport default Worker;\n","enum TimelineLevel {\n ERROR = 3,\n INFO = 6,\n DEBUG = 7\n}\n\nexport default TimelineLevel;\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport { default as Level } from './level';\n\nexport interface TimelineOptions {\n level?: Level;\n limit?: number;\n version?: string;\n cluster?: string;\n features?: string[];\n params?: any;\n}\n\nexport default class Timeline {\n key: string;\n session: number;\n events: any[];\n options: TimelineOptions;\n sent: number;\n uniqueID: number;\n\n constructor(key: string, session: number, options: TimelineOptions) {\n this.key = key;\n this.session = session;\n this.events = [];\n this.options = options || {};\n this.sent = 0;\n this.uniqueID = 0;\n }\n\n log(level, event) {\n if (level <= this.options.level) {\n this.events.push(\n Collections.extend({}, event, { timestamp: Util.now() })\n );\n if (this.options.limit && this.events.length > this.options.limit) {\n this.events.shift();\n }\n }\n }\n\n error(event) {\n this.log(Level.ERROR, event);\n }\n\n info(event) {\n this.log(Level.INFO, event);\n }\n\n debug(event) {\n this.log(Level.DEBUG, event);\n }\n\n isEmpty() {\n return this.events.length === 0;\n }\n\n send(sendfn, callback) {\n var data = Collections.extend(\n {\n session: this.session,\n bundle: this.sent + 1,\n key: this.key,\n lib: 'js',\n version: this.options.version,\n cluster: this.options.cluster,\n features: this.options.features,\n timeline: this.events\n },\n this.options.params\n );\n\n this.events = [];\n sendfn(data, (error, result) => {\n if (!error) {\n this.sent++;\n }\n if (callback) {\n callback(error, result);\n }\n });\n\n return true;\n }\n\n generateUniqueID(): number {\n this.uniqueID++;\n return this.uniqueID;\n }\n}\n","import Factory from '../utils/factory';\nimport Util from '../util';\nimport * as Errors from '../errors';\nimport * as Collections from '../utils/collections';\nimport Strategy from './strategy';\nimport Transport from '../transports/transport';\nimport StrategyOptions from './strategy_options';\nimport Handshake from '../connection/handshake';\n\n/** Provides a strategy interface for transports.\n *\n * @param {String} name\n * @param {Number} priority\n * @param {Class} transport\n * @param {Object} options\n */\nexport default class TransportStrategy implements Strategy {\n name: string;\n priority: number;\n transport: Transport;\n options: StrategyOptions;\n\n constructor(\n name: string,\n priority: number,\n transport: Transport,\n options: StrategyOptions\n ) {\n this.name = name;\n this.priority = priority;\n this.transport = transport;\n this.options = options || {};\n }\n\n /** Returns whether the transport is supported in the browser.\n *\n * @returns {Boolean}\n */\n isSupported(): boolean {\n return this.transport.isSupported({\n useTLS: this.options.useTLS\n });\n }\n\n /** Launches a connection attempt and returns a strategy runner.\n *\n * @param {Function} callback\n * @return {Object} strategy runner\n */\n connect(minPriority: number, callback: Function) {\n if (!this.isSupported()) {\n return failAttempt(new Errors.UnsupportedStrategy(), callback);\n } else if (this.priority < minPriority) {\n return failAttempt(new Errors.TransportPriorityTooLow(), callback);\n }\n\n var connected = false;\n var transport = this.transport.createConnection(\n this.name,\n this.priority,\n this.options.key,\n this.options\n );\n var handshake = null;\n\n var onInitialized = function() {\n transport.unbind('initialized', onInitialized);\n transport.connect();\n };\n var onOpen = function() {\n handshake = Factory.createHandshake(transport, function(result) {\n connected = true;\n unbindListeners();\n callback(null, result);\n });\n };\n var onError = function(error) {\n unbindListeners();\n callback(error);\n };\n var onClosed = function() {\n unbindListeners();\n var serializedTransport;\n\n // The reason for this try/catch block is that on React Native\n // the WebSocket object is circular. Therefore transport.socket will\n // throw errors upon stringification. Collections.safeJSONStringify\n // discards circular references when serializing.\n serializedTransport = Collections.safeJSONStringify(transport);\n callback(new Errors.TransportClosed(serializedTransport));\n };\n\n var unbindListeners = function() {\n transport.unbind('initialized', onInitialized);\n transport.unbind('open', onOpen);\n transport.unbind('error', onError);\n transport.unbind('closed', onClosed);\n };\n\n transport.bind('initialized', onInitialized);\n transport.bind('open', onOpen);\n transport.bind('error', onError);\n transport.bind('closed', onClosed);\n\n // connect will be called automatically after initialization\n transport.initialize();\n\n return {\n abort: () => {\n if (connected) {\n return;\n }\n unbindListeners();\n if (handshake) {\n handshake.close();\n } else {\n transport.close();\n }\n },\n forceMinPriority: p => {\n if (connected) {\n return;\n }\n if (this.priority < p) {\n if (handshake) {\n handshake.close();\n } else {\n transport.close();\n }\n }\n }\n };\n }\n}\n\nfunction failAttempt(error: Error, callback: Function) {\n Util.defer(function() {\n callback(error);\n });\n return {\n abort: function() {},\n forceMinPriority: function() {}\n };\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport TransportManager from '../transports/transport_manager';\nimport * as Errors from '../errors';\nimport Strategy from './strategy';\nimport TransportStrategy from './transport_strategy';\nimport StrategyOptions from '../strategies/strategy_options';\nimport { Config } from '../config';\nimport Runtime from 'runtime';\n\nconst { Transports } = Runtime;\n\nexport var defineTransport = function(\n config: Config,\n name: string,\n type: string,\n priority: number,\n options: StrategyOptions,\n manager?: TransportManager\n): Strategy {\n var transportClass = Transports[type];\n if (!transportClass) {\n throw new Errors.UnsupportedTransport(type);\n }\n\n var enabled =\n (!config.enabledTransports ||\n Collections.arrayIndexOf(config.enabledTransports, name) !== -1) &&\n (!config.disabledTransports ||\n Collections.arrayIndexOf(config.disabledTransports, name) === -1);\n\n var transport;\n if (enabled) {\n options = Object.assign(\n { ignoreNullOrigin: config.ignoreNullOrigin },\n options\n );\n\n transport = new TransportStrategy(\n name,\n priority,\n manager ? manager.getAssistant(transportClass) : transportClass,\n options\n );\n } else {\n transport = UnsupportedStrategy;\n }\n\n return transport;\n};\n\nvar UnsupportedStrategy: Strategy = {\n isSupported: function() {\n return false;\n },\n connect: function(_, callback) {\n var deferred = Util.defer(function() {\n callback(new Errors.UnsupportedStrategy());\n });\n return {\n abort: function() {\n deferred.ensureAborted();\n },\n forceMinPriority: function() {}\n };\n }\n};\n","export enum AuthRequestType {\n UserAuthentication = 'user-authentication',\n ChannelAuthorization = 'channel-authorization'\n}\n\nexport interface ChannelAuthorizationData {\n auth: string;\n channel_data?: string;\n shared_secret?: string;\n}\n\nexport type ChannelAuthorizationCallback = (\n error: Error | null,\n authData: ChannelAuthorizationData | null\n) => void;\n\nexport interface ChannelAuthorizationRequestParams {\n socketId: string;\n channelName: string;\n}\n\nexport interface ChannelAuthorizationHandler {\n (\n params: ChannelAuthorizationRequestParams,\n callback: ChannelAuthorizationCallback\n ): void;\n}\n\nexport interface UserAuthenticationData {\n auth: string;\n user_data: string;\n}\n\nexport type UserAuthenticationCallback = (\n error: Error | null,\n authData: UserAuthenticationData | null\n) => void;\n\nexport interface UserAuthenticationRequestParams {\n socketId: string;\n}\n\nexport interface UserAuthenticationHandler {\n (\n params: UserAuthenticationRequestParams,\n callback: UserAuthenticationCallback\n ): void;\n}\n\nexport type AuthTransportCallback =\n | ChannelAuthorizationCallback\n | UserAuthenticationCallback;\n\nexport interface AuthOptionsT {\n transport: 'ajax' | 'jsonp';\n endpoint: string;\n params?: any;\n headers?: any;\n paramsProvider?: () => any;\n headersProvider?: () => any;\n customHandler?: AuthHandler;\n}\n\nexport declare type UserAuthenticationOptions = AuthOptionsT<\n UserAuthenticationHandler\n>;\nexport declare type ChannelAuthorizationOptions = AuthOptionsT<\n ChannelAuthorizationHandler\n>;\n\nexport interface InternalAuthOptions {\n transport: 'ajax' | 'jsonp';\n endpoint: string;\n params?: any;\n headers?: any;\n paramsProvider?: () => any;\n headersProvider?: () => any;\n}\n","import ConnectionManager from './connection/connection_manager';\nimport {\n ChannelAuthorizationOptions,\n UserAuthenticationOptions\n} from './auth/options';\nimport {\n ChannelAuthorizerGenerator,\n DeprecatedAuthOptions\n} from './auth/deprecated_channel_authorizer';\nimport { AuthTransport, Transport } from './config';\nimport * as nacl from 'tweetnacl';\nimport Logger from './logger';\n\nexport interface Options {\n activityTimeout?: number;\n\n auth?: DeprecatedAuthOptions; // DEPRECATED use channelAuthorization instead\n authEndpoint?: string; // DEPRECATED use channelAuthorization instead\n authTransport?: AuthTransport; // DEPRECATED use channelAuthorization instead\n authorizer?: ChannelAuthorizerGenerator; // DEPRECATED use channelAuthorization instead\n\n channelAuthorization?: ChannelAuthorizationOptions;\n userAuthentication?: UserAuthenticationOptions;\n\n cluster: string;\n enableStats?: boolean;\n disableStats?: boolean;\n disabledTransports?: Transport[];\n enabledTransports?: Transport[];\n forceTLS?: boolean;\n httpHost?: string;\n httpPath?: string;\n httpPort?: number;\n httpsPort?: number;\n ignoreNullOrigin?: boolean;\n nacl?: nacl;\n pongTimeout?: number;\n statsHost?: string;\n timelineParams?: any;\n unavailableTimeout?: number;\n wsHost?: string;\n wsPath?: string;\n wsPort?: number;\n wssPort?: number;\n}\n\nexport function validateOptions(options) {\n if (options == null) {\n throw 'You must pass an options object';\n }\n if (options.cluster == null) {\n throw 'Options object must provide a cluster';\n }\n if ('disableStats' in options) {\n Logger.warn(\n 'The disableStats option is deprecated in favor of enableStats'\n );\n }\n}\n","import {\n UserAuthenticationCallback,\n InternalAuthOptions,\n UserAuthenticationHandler,\n UserAuthenticationRequestParams,\n AuthRequestType\n} from './options';\n\nimport Runtime from 'runtime';\n\nconst composeChannelQuery = (\n params: UserAuthenticationRequestParams,\n authOptions: InternalAuthOptions\n) => {\n var query = 'socket_id=' + encodeURIComponent(params.socketId);\n\n for (var key in authOptions.params) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(authOptions.params[key]);\n }\n\n if (authOptions.paramsProvider != null) {\n let dynamicParams = authOptions.paramsProvider();\n for (var key in dynamicParams) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(dynamicParams[key]);\n }\n }\n\n return query;\n};\n\nconst UserAuthenticator = (\n authOptions: InternalAuthOptions\n): UserAuthenticationHandler => {\n if (typeof Runtime.getAuthorizers()[authOptions.transport] === 'undefined') {\n throw `'${authOptions.transport}' is not a recognized auth transport`;\n }\n\n return (\n params: UserAuthenticationRequestParams,\n callback: UserAuthenticationCallback\n ) => {\n const query = composeChannelQuery(params, authOptions);\n\n Runtime.getAuthorizers()[authOptions.transport](\n Runtime,\n query,\n authOptions,\n AuthRequestType.UserAuthentication,\n callback\n );\n };\n};\n\nexport default UserAuthenticator;\n","import {\n AuthRequestType,\n InternalAuthOptions,\n ChannelAuthorizationHandler,\n ChannelAuthorizationRequestParams,\n ChannelAuthorizationCallback\n} from './options';\n\nimport Runtime from 'runtime';\n\nconst composeChannelQuery = (\n params: ChannelAuthorizationRequestParams,\n authOptions: InternalAuthOptions\n) => {\n var query = 'socket_id=' + encodeURIComponent(params.socketId);\n\n query += '&channel_name=' + encodeURIComponent(params.channelName);\n\n for (var key in authOptions.params) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(authOptions.params[key]);\n }\n\n if (authOptions.paramsProvider != null) {\n let dynamicParams = authOptions.paramsProvider();\n for (var key in dynamicParams) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(dynamicParams[key]);\n }\n }\n\n return query;\n};\n\nconst ChannelAuthorizer = (\n authOptions: InternalAuthOptions\n): ChannelAuthorizationHandler => {\n if (typeof Runtime.getAuthorizers()[authOptions.transport] === 'undefined') {\n throw `'${authOptions.transport}' is not a recognized auth transport`;\n }\n\n return (\n params: ChannelAuthorizationRequestParams,\n callback: ChannelAuthorizationCallback\n ) => {\n const query = composeChannelQuery(params, authOptions);\n\n Runtime.getAuthorizers()[authOptions.transport](\n Runtime,\n query,\n authOptions,\n AuthRequestType.ChannelAuthorization,\n callback\n );\n };\n};\n\nexport default ChannelAuthorizer;\n","import { Options } from './options';\nimport Defaults from './defaults';\nimport {\n ChannelAuthorizationHandler,\n UserAuthenticationHandler,\n ChannelAuthorizationOptions\n} from './auth/options';\nimport UserAuthenticator from './auth/user_authenticator';\nimport ChannelAuthorizer from './auth/channel_authorizer';\nimport { ChannelAuthorizerProxy } from './auth/deprecated_channel_authorizer';\nimport Runtime from 'runtime';\nimport * as nacl from 'tweetnacl';\n\nexport type AuthTransport = 'ajax' | 'jsonp';\nexport type Transport =\n | 'ws'\n | 'wss'\n | 'xhr_streaming'\n | 'xhr_polling'\n | 'sockjs';\n\nexport interface Config {\n // these are all 'required' config parameters, it's not necessary for the user\n // to set them, but they have configured defaults.\n activityTimeout: number;\n enableStats: boolean;\n httpHost: string;\n httpPath: string;\n httpPort: number;\n httpsPort: number;\n pongTimeout: number;\n statsHost: string;\n unavailableTimeout: number;\n useTLS: boolean;\n wsHost: string;\n wsPath: string;\n wsPort: number;\n wssPort: number;\n userAuthenticator: UserAuthenticationHandler;\n channelAuthorizer: ChannelAuthorizationHandler;\n\n // these are all optional parameters or overrrides. The customer can set these\n // but it's not strictly necessary\n forceTLS?: boolean;\n cluster?: string;\n disabledTransports?: Transport[];\n enabledTransports?: Transport[];\n ignoreNullOrigin?: boolean;\n nacl?: nacl;\n timelineParams?: any;\n}\n\n// getConfig mainly sets the defaults for the options that are not provided\nexport function getConfig(opts: Options, pusher): Config {\n let config: Config = {\n activityTimeout: opts.activityTimeout || Defaults.activityTimeout,\n cluster: opts.cluster,\n httpPath: opts.httpPath || Defaults.httpPath,\n httpPort: opts.httpPort || Defaults.httpPort,\n httpsPort: opts.httpsPort || Defaults.httpsPort,\n pongTimeout: opts.pongTimeout || Defaults.pongTimeout,\n statsHost: opts.statsHost || Defaults.stats_host,\n unavailableTimeout: opts.unavailableTimeout || Defaults.unavailableTimeout,\n wsPath: opts.wsPath || Defaults.wsPath,\n wsPort: opts.wsPort || Defaults.wsPort,\n wssPort: opts.wssPort || Defaults.wssPort,\n\n enableStats: getEnableStatsConfig(opts),\n httpHost: getHttpHost(opts),\n useTLS: shouldUseTLS(opts),\n wsHost: getWebsocketHost(opts),\n\n userAuthenticator: buildUserAuthenticator(opts),\n channelAuthorizer: buildChannelAuthorizer(opts, pusher)\n };\n\n if ('disabledTransports' in opts)\n config.disabledTransports = opts.disabledTransports;\n if ('enabledTransports' in opts)\n config.enabledTransports = opts.enabledTransports;\n if ('ignoreNullOrigin' in opts)\n config.ignoreNullOrigin = opts.ignoreNullOrigin;\n if ('timelineParams' in opts) config.timelineParams = opts.timelineParams;\n if ('nacl' in opts) {\n config.nacl = opts.nacl;\n }\n\n return config;\n}\n\nfunction getHttpHost(opts: Options): string {\n if (opts.httpHost) {\n return opts.httpHost;\n }\n if (opts.cluster) {\n return `sockjs-${opts.cluster}.pusher.com`;\n }\n return Defaults.httpHost;\n}\n\nfunction getWebsocketHost(opts: Options): string {\n if (opts.wsHost) {\n return opts.wsHost;\n }\n return getWebsocketHostFromCluster(opts.cluster);\n}\n\nfunction getWebsocketHostFromCluster(cluster: string): string {\n return `ws-${cluster}.pusher.com`;\n}\n\nfunction shouldUseTLS(opts: Options): boolean {\n if (Runtime.getProtocol() === 'https:') {\n return true;\n } else if (opts.forceTLS === false) {\n return false;\n }\n return true;\n}\n\n// if enableStats is set take the value\n// if disableStats is set take the inverse\n// otherwise default to false\nfunction getEnableStatsConfig(opts: Options): boolean {\n if ('enableStats' in opts) {\n return opts.enableStats;\n }\n if ('disableStats' in opts) {\n return !opts.disableStats;\n }\n return false;\n}\n\nfunction buildUserAuthenticator(opts: Options): UserAuthenticationHandler {\n const userAuthentication = {\n ...Defaults.userAuthentication,\n ...opts.userAuthentication\n };\n if (\n 'customHandler' in userAuthentication &&\n userAuthentication['customHandler'] != null\n ) {\n return userAuthentication['customHandler'];\n }\n\n return UserAuthenticator(userAuthentication);\n}\n\nfunction buildChannelAuth(opts: Options, pusher): ChannelAuthorizationOptions {\n let channelAuthorization: ChannelAuthorizationOptions;\n if ('channelAuthorization' in opts) {\n channelAuthorization = {\n ...Defaults.channelAuthorization,\n ...opts.channelAuthorization\n };\n } else {\n channelAuthorization = {\n transport: opts.authTransport || Defaults.authTransport,\n endpoint: opts.authEndpoint || Defaults.authEndpoint\n };\n if ('auth' in opts) {\n if ('params' in opts.auth) channelAuthorization.params = opts.auth.params;\n if ('headers' in opts.auth)\n channelAuthorization.headers = opts.auth.headers;\n }\n if ('authorizer' in opts)\n channelAuthorization.customHandler = ChannelAuthorizerProxy(\n pusher,\n channelAuthorization,\n opts.authorizer\n );\n }\n return channelAuthorization;\n}\n\nfunction buildChannelAuthorizer(\n opts: Options,\n pusher\n): ChannelAuthorizationHandler {\n const channelAuthorization = buildChannelAuth(opts, pusher);\n if (\n 'customHandler' in channelAuthorization &&\n channelAuthorization['customHandler'] != null\n ) {\n return channelAuthorization['customHandler'];\n }\n\n return ChannelAuthorizer(channelAuthorization);\n}\n","import Channel from '../channels/channel';\nimport {\n ChannelAuthorizationCallback,\n ChannelAuthorizationHandler,\n ChannelAuthorizationRequestParams,\n InternalAuthOptions\n} from './options';\n\nexport interface DeprecatedChannelAuthorizer {\n authorize(socketId: string, callback: ChannelAuthorizationCallback): void;\n}\n\nexport interface ChannelAuthorizerGenerator {\n (\n channel: Channel,\n options: DeprecatedAuthorizerOptions\n ): DeprecatedChannelAuthorizer;\n}\n\nexport interface DeprecatedAuthOptions {\n params?: any;\n headers?: any;\n}\n\nexport interface DeprecatedAuthorizerOptions {\n authTransport: 'ajax' | 'jsonp';\n authEndpoint: string;\n auth?: DeprecatedAuthOptions;\n}\n\nexport const ChannelAuthorizerProxy = (\n pusher,\n authOptions: InternalAuthOptions,\n channelAuthorizerGenerator: ChannelAuthorizerGenerator\n): ChannelAuthorizationHandler => {\n const deprecatedAuthorizerOptions: DeprecatedAuthorizerOptions = {\n authTransport: authOptions.transport,\n authEndpoint: authOptions.endpoint,\n auth: {\n params: authOptions.params,\n headers: authOptions.headers\n }\n };\n return (\n params: ChannelAuthorizationRequestParams,\n callback: ChannelAuthorizationCallback\n ) => {\n const channel = pusher.channel(params.channelName);\n // This line creates a new channel authorizer every time.\n // In the past, this was only done once per channel and reused.\n // We can do that again if we want to keep this behavior intact.\n const channelAuthorizer: DeprecatedChannelAuthorizer = channelAuthorizerGenerator(\n channel,\n deprecatedAuthorizerOptions\n );\n channelAuthorizer.authorize(params.socketId, callback);\n };\n};\n","import Logger from './logger';\nimport Pusher from './pusher';\nimport EventsDispatcher from './events/dispatcher';\n\nexport default class WatchlistFacade extends EventsDispatcher {\n private pusher: Pusher;\n\n public constructor(pusher: Pusher) {\n super(function(eventName, data) {\n Logger.debug(`No callbacks on watchlist events for ${eventName}`);\n });\n\n this.pusher = pusher;\n this.bindWatchlistInternalEvent();\n }\n\n handleEvent(pusherEvent) {\n pusherEvent.data.events.forEach(watchlistEvent => {\n this.emit(watchlistEvent.name, watchlistEvent);\n });\n }\n\n private bindWatchlistInternalEvent() {\n this.pusher.connection.bind('message', pusherEvent => {\n var eventName = pusherEvent.event;\n if (eventName === 'pusher_internal:watchlist_events') {\n this.handleEvent(pusherEvent);\n }\n });\n }\n}\n","function flatPromise() {\n let resolve, reject;\n const promise = new Promise((res, rej) => {\n resolve = res;\n reject = rej;\n });\n return { promise, resolve, reject };\n}\n\nexport default flatPromise;\n","import Pusher from './pusher';\nimport Logger from './logger';\nimport {\n UserAuthenticationData,\n UserAuthenticationCallback\n} from './auth/options';\nimport Channel from './channels/channel';\nimport WatchlistFacade from './watchlist';\nimport EventsDispatcher from './events/dispatcher';\nimport flatPromise from './utils/flat_promise';\n\nexport default class UserFacade extends EventsDispatcher {\n pusher: Pusher;\n signin_requested: boolean = false;\n user_data: any = null;\n serverToUserChannel: Channel = null;\n signinDonePromise: Promise = null;\n watchlist: WatchlistFacade;\n private _signinDoneResolve: Function = null;\n\n public constructor(pusher: Pusher) {\n super(function(eventName, data) {\n Logger.debug('No callbacks on user for ' + eventName);\n });\n this.pusher = pusher;\n this.pusher.connection.bind('state_change', ({ previous, current }) => {\n if (previous !== 'connected' && current === 'connected') {\n this._signin();\n }\n if (previous === 'connected' && current !== 'connected') {\n this._cleanup();\n this._newSigninPromiseIfNeeded();\n }\n });\n\n this.watchlist = new WatchlistFacade(pusher);\n\n this.pusher.connection.bind('message', event => {\n var eventName = event.event;\n if (eventName === 'pusher:signin_success') {\n this._onSigninSuccess(event.data);\n }\n if (\n this.serverToUserChannel &&\n this.serverToUserChannel.name === event.channel\n ) {\n this.serverToUserChannel.handleEvent(event);\n }\n });\n }\n\n public signin() {\n if (this.signin_requested) {\n return;\n }\n\n this.signin_requested = true;\n this._signin();\n }\n\n private _signin() {\n if (!this.signin_requested) {\n return;\n }\n\n this._newSigninPromiseIfNeeded();\n\n if (this.pusher.connection.state !== 'connected') {\n // Signin will be attempted when the connection is connected\n return;\n }\n\n this.pusher.config.userAuthenticator(\n {\n socketId: this.pusher.connection.socket_id\n },\n this._onAuthorize\n );\n }\n\n private _onAuthorize: UserAuthenticationCallback = (\n err,\n authData: UserAuthenticationData\n ) => {\n if (err) {\n Logger.warn(`Error during signin: ${err}`);\n this._cleanup();\n return;\n }\n\n this.pusher.send_event('pusher:signin', {\n auth: authData.auth,\n user_data: authData.user_data\n });\n\n // Later when we get pusher:singin_success event, the user will be marked as signed in\n };\n\n private _onSigninSuccess(data: any) {\n try {\n this.user_data = JSON.parse(data.user_data);\n } catch (e) {\n Logger.error(`Failed parsing user data after signin: ${data.user_data}`);\n this._cleanup();\n return;\n }\n\n if (typeof this.user_data.id !== 'string' || this.user_data.id === '') {\n Logger.error(\n `user_data doesn't contain an id. user_data: ${this.user_data}`\n );\n this._cleanup();\n return;\n }\n\n // Signin succeeded\n this._signinDoneResolve();\n this._subscribeChannels();\n }\n\n private _subscribeChannels() {\n const ensure_subscribed = channel => {\n if (channel.subscriptionPending && channel.subscriptionCancelled) {\n channel.reinstateSubscription();\n } else if (\n !channel.subscriptionPending &&\n this.pusher.connection.state === 'connected'\n ) {\n channel.subscribe();\n }\n };\n\n this.serverToUserChannel = new Channel(\n `#server-to-user-${this.user_data.id}`,\n this.pusher\n );\n this.serverToUserChannel.bind_global((eventName, data) => {\n if (\n eventName.indexOf('pusher_internal:') === 0 ||\n eventName.indexOf('pusher:') === 0\n ) {\n // ignore internal events\n return;\n }\n this.emit(eventName, data);\n });\n ensure_subscribed(this.serverToUserChannel);\n }\n\n private _cleanup() {\n this.user_data = null;\n if (this.serverToUserChannel) {\n this.serverToUserChannel.unbind_all();\n this.serverToUserChannel.disconnect();\n this.serverToUserChannel = null;\n }\n\n if (this.signin_requested) {\n // If signin is in progress and cleanup is called,\n // Mark the current signin process as done.\n this._signinDoneResolve();\n }\n }\n\n private _newSigninPromiseIfNeeded() {\n if (!this.signin_requested) {\n return;\n }\n\n // If there is a promise and it is not resolved, return without creating a new one.\n if (this.signinDonePromise && !(this.signinDonePromise as any).done) {\n return;\n }\n\n // This promise is never rejected.\n // It gets resolved when the signin process is done whether it failed or succeeded\n const { promise, resolve, reject: _ } = flatPromise();\n (promise as any).done = false;\n const setDone = () => {\n (promise as any).done = true;\n };\n promise.then(setDone).catch(setDone);\n this.signinDonePromise = promise;\n this._signinDoneResolve = resolve;\n }\n}\n","import AbstractRuntime from '../runtimes/interface';\nimport Runtime from 'runtime';\nimport Util from './util';\nimport * as Collections from './utils/collections';\nimport Channels from './channels/channels';\nimport Channel from './channels/channel';\nimport { default as EventsDispatcher } from './events/dispatcher';\nimport Timeline from './timeline/timeline';\nimport TimelineSender from './timeline/timeline_sender';\nimport TimelineLevel from './timeline/level';\nimport { defineTransport } from './strategies/strategy_builder';\nimport ConnectionManager from './connection/connection_manager';\nimport ConnectionManagerOptions from './connection/connection_manager_options';\nimport { PeriodicTimer } from './utils/timers';\nimport Defaults from './defaults';\nimport * as DefaultConfig from './config';\nimport Logger from './logger';\nimport Factory from './utils/factory';\nimport UrlStore from 'core/utils/url_store';\nimport { Options, validateOptions } from './options';\nimport { Config, getConfig } from './config';\nimport StrategyOptions from './strategies/strategy_options';\nimport UserFacade from './user';\n\nexport default class Pusher {\n /* STATIC PROPERTIES */\n static instances: Pusher[] = [];\n static isReady: boolean = false;\n static logToConsole: boolean = false;\n\n // for jsonp\n static Runtime: AbstractRuntime = Runtime;\n static ScriptReceivers: any = (Runtime).ScriptReceivers;\n static DependenciesReceivers: any = (Runtime).DependenciesReceivers;\n static auth_callbacks: any = (Runtime).auth_callbacks;\n\n static ready() {\n Pusher.isReady = true;\n for (var i = 0, l = Pusher.instances.length; i < l; i++) {\n Pusher.instances[i].connect();\n }\n }\n\n static log: (message: any) => void;\n\n private static getClientFeatures(): string[] {\n return Collections.keys(\n Collections.filterObject({ ws: Runtime.Transports.ws }, function(t) {\n return t.isSupported({});\n })\n );\n }\n\n /* INSTANCE PROPERTIES */\n key: string;\n config: Config;\n channels: Channels;\n global_emitter: EventsDispatcher;\n sessionID: number;\n timeline: Timeline;\n timelineSender: TimelineSender;\n connection: ConnectionManager;\n timelineSenderTimer: PeriodicTimer;\n user: UserFacade;\n constructor(app_key: string, options: Options) {\n checkAppKey(app_key);\n validateOptions(options);\n this.key = app_key;\n this.config = getConfig(options, this);\n\n this.channels = Factory.createChannels();\n this.global_emitter = new EventsDispatcher();\n this.sessionID = Runtime.randomInt(1000000000);\n\n this.timeline = new Timeline(this.key, this.sessionID, {\n cluster: this.config.cluster,\n features: Pusher.getClientFeatures(),\n params: this.config.timelineParams || {},\n limit: 50,\n level: TimelineLevel.INFO,\n version: Defaults.VERSION\n });\n if (this.config.enableStats) {\n this.timelineSender = Factory.createTimelineSender(this.timeline, {\n host: this.config.statsHost,\n path: '/timeline/v2/' + Runtime.TimelineTransport.name\n });\n }\n\n var getStrategy = (options: StrategyOptions) => {\n return Runtime.getDefaultStrategy(this.config, options, defineTransport);\n };\n\n this.connection = Factory.createConnectionManager(this.key, {\n getStrategy: getStrategy,\n timeline: this.timeline,\n activityTimeout: this.config.activityTimeout,\n pongTimeout: this.config.pongTimeout,\n unavailableTimeout: this.config.unavailableTimeout,\n useTLS: Boolean(this.config.useTLS)\n });\n\n this.connection.bind('connected', () => {\n this.subscribeAll();\n if (this.timelineSender) {\n this.timelineSender.send(this.connection.isUsingTLS());\n }\n });\n\n this.connection.bind('message', event => {\n var eventName = event.event;\n var internal = eventName.indexOf('pusher_internal:') === 0;\n if (event.channel) {\n var channel = this.channel(event.channel);\n if (channel) {\n channel.handleEvent(event);\n }\n }\n // Emit globally [deprecated]\n if (!internal) {\n this.global_emitter.emit(event.event, event.data);\n }\n });\n this.connection.bind('connecting', () => {\n this.channels.disconnect();\n });\n this.connection.bind('disconnected', () => {\n this.channels.disconnect();\n });\n this.connection.bind('error', err => {\n Logger.warn(err);\n });\n\n Pusher.instances.push(this);\n this.timeline.info({ instances: Pusher.instances.length });\n\n this.user = new UserFacade(this);\n\n if (Pusher.isReady) {\n this.connect();\n }\n }\n\n channel(name: string): Channel {\n return this.channels.find(name);\n }\n\n allChannels(): Channel[] {\n return this.channels.all();\n }\n\n connect() {\n this.connection.connect();\n\n if (this.timelineSender) {\n if (!this.timelineSenderTimer) {\n var usingTLS = this.connection.isUsingTLS();\n var timelineSender = this.timelineSender;\n this.timelineSenderTimer = new PeriodicTimer(60000, function() {\n timelineSender.send(usingTLS);\n });\n }\n }\n }\n\n disconnect() {\n this.connection.disconnect();\n\n if (this.timelineSenderTimer) {\n this.timelineSenderTimer.ensureAborted();\n this.timelineSenderTimer = null;\n }\n }\n\n bind(event_name: string, callback: Function, context?: any): Pusher {\n this.global_emitter.bind(event_name, callback, context);\n return this;\n }\n\n unbind(event_name?: string, callback?: Function, context?: any): Pusher {\n this.global_emitter.unbind(event_name, callback, context);\n return this;\n }\n\n bind_global(callback: Function): Pusher {\n this.global_emitter.bind_global(callback);\n return this;\n }\n\n unbind_global(callback?: Function): Pusher {\n this.global_emitter.unbind_global(callback);\n return this;\n }\n\n unbind_all(callback?: Function): Pusher {\n this.global_emitter.unbind_all();\n return this;\n }\n\n subscribeAll() {\n var channelName;\n for (channelName in this.channels.channels) {\n if (this.channels.channels.hasOwnProperty(channelName)) {\n this.subscribe(channelName);\n }\n }\n }\n\n subscribe(channel_name: string) {\n var channel = this.channels.add(channel_name, this);\n if (channel.subscriptionPending && channel.subscriptionCancelled) {\n channel.reinstateSubscription();\n } else if (\n !channel.subscriptionPending &&\n this.connection.state === 'connected'\n ) {\n channel.subscribe();\n }\n return channel;\n }\n\n unsubscribe(channel_name: string) {\n var channel = this.channels.find(channel_name);\n if (channel && channel.subscriptionPending) {\n channel.cancelSubscription();\n } else {\n channel = this.channels.remove(channel_name);\n if (channel && channel.subscribed) {\n channel.unsubscribe();\n }\n }\n }\n\n send_event(event_name: string, data: any, channel?: string) {\n return this.connection.send_event(event_name, data, channel);\n }\n\n shouldUseTLS(): boolean {\n return this.config.useTLS;\n }\n\n signin() {\n this.user.signin();\n }\n}\n\nfunction checkAppKey(key) {\n if (key === null || key === undefined) {\n throw 'You must pass your app key when you instantiate Pusher.';\n }\n}\n\nRuntime.setup(Pusher);\n","import Pusher from './pusher';\nimport { Options, validateOptions } from './options';\nimport * as nacl from 'tweetnacl';\n\nexport default class PusherWithEncryption extends Pusher {\n constructor(app_key: string, options: Options) {\n Pusher.logToConsole = PusherWithEncryption.logToConsole;\n Pusher.log = PusherWithEncryption.log;\n\n validateOptions(options);\n options.nacl = nacl;\n super(app_key, options);\n }\n}\n"],"sourceRoot":""} \ No newline at end of file +{"version":3,"sources":["webpack://Pusher/webpack/universalModuleDefinition","webpack://Pusher/webpack/bootstrap","webpack://Pusher/./node_modules/@stablelib/base64/base64.ts","webpack://Pusher/./node_modules/@stablelib/utf8/utf8.ts","webpack://Pusher/./node_modules/tweetnacl/nacl-fast.js","webpack://Pusher/./src/core/pusher-with-encryption.js","webpack://Pusher/./src/core/base64.ts","webpack://Pusher/./src/core/utils/timers/abstract_timer.ts","webpack://Pusher/./src/core/utils/timers/index.ts","webpack://Pusher/./src/core/util.ts","webpack://Pusher/./src/core/utils/collections.ts","webpack://Pusher/./src/core/defaults.ts","webpack://Pusher/./src/core/transports/url_schemes.ts","webpack://Pusher/./src/core/events/callback_registry.ts","webpack://Pusher/./src/core/events/dispatcher.ts","webpack://Pusher/./src/core/logger.ts","webpack://Pusher/./src/core/transports/transport_connection.ts","webpack://Pusher/./src/core/transports/transport.ts","webpack://Pusher/./src/runtimes/isomorphic/transports/transports.ts","webpack://Pusher/./src/core/transports/assistant_to_the_transport_manager.ts","webpack://Pusher/./src/core/connection/protocol/protocol.ts","webpack://Pusher/./src/core/connection/connection.ts","webpack://Pusher/./src/core/connection/handshake/index.ts","webpack://Pusher/./src/core/timeline/timeline_sender.ts","webpack://Pusher/./src/core/errors.ts","webpack://Pusher/./src/core/utils/url_store.ts","webpack://Pusher/./src/core/channels/channel.ts","webpack://Pusher/./src/core/channels/private_channel.ts","webpack://Pusher/./src/core/channels/members.ts","webpack://Pusher/./src/core/channels/presence_channel.ts","webpack://Pusher/./src/core/channels/encrypted_channel.ts","webpack://Pusher/./src/core/connection/connection_manager.ts","webpack://Pusher/./src/core/channels/channels.ts","webpack://Pusher/./src/core/utils/factory.ts","webpack://Pusher/./src/core/transports/transport_manager.ts","webpack://Pusher/./src/core/strategies/sequential_strategy.ts","webpack://Pusher/./src/core/strategies/best_connected_ever_strategy.ts","webpack://Pusher/./src/core/strategies/websocket_prioritized_cached_strategy.ts","webpack://Pusher/./src/core/strategies/delayed_strategy.ts","webpack://Pusher/./src/core/strategies/if_strategy.ts","webpack://Pusher/./src/core/strategies/first_connected_strategy.ts","webpack://Pusher/./src/runtimes/isomorphic/default_strategy.ts","webpack://Pusher/./src/core/http/http_request.ts","webpack://Pusher/./src/core/http/state.ts","webpack://Pusher/./src/core/http/http_socket.ts","webpack://Pusher/./src/core/http/http_streaming_socket.ts","webpack://Pusher/./src/core/http/http_polling_socket.ts","webpack://Pusher/./src/runtimes/isomorphic/http/http_xhr_request.ts","webpack://Pusher/./src/runtimes/isomorphic/runtime.ts","webpack://Pusher/./src/runtimes/isomorphic/transports/transport_connection_initializer.ts","webpack://Pusher/./src/runtimes/isomorphic/http/http.ts","webpack://Pusher/./src/runtimes/worker/net_info.ts","webpack://Pusher/./src/runtimes/worker/auth/fetch_auth.ts","webpack://Pusher/./src/runtimes/worker/timeline/fetch_timeline.ts","webpack://Pusher/./src/runtimes/worker/runtime.ts","webpack://Pusher/./src/core/timeline/level.ts","webpack://Pusher/./src/core/timeline/timeline.ts","webpack://Pusher/./src/core/strategies/transport_strategy.ts","webpack://Pusher/./src/core/strategies/strategy_builder.ts","webpack://Pusher/./src/core/auth/options.ts","webpack://Pusher/./src/core/options.ts","webpack://Pusher/./src/core/auth/user_authenticator.ts","webpack://Pusher/./src/core/auth/channel_authorizer.ts","webpack://Pusher/./src/core/config.ts","webpack://Pusher/./src/core/auth/deprecated_channel_authorizer.ts","webpack://Pusher/./src/core/watchlist.ts","webpack://Pusher/./src/core/utils/flat_promise.ts","webpack://Pusher/./src/core/user.ts","webpack://Pusher/./src/core/pusher.ts","webpack://Pusher/./src/core/pusher-with-encryption.ts"],"names":["root","factory","exports","module","define","amd","this","installedModules","__webpack_require__","moduleId","i","l","modules","call","m","c","d","name","getter","o","Object","defineProperty","enumerable","get","r","Symbol","toStringTag","value","t","mode","__esModule","ns","create","key","bind","n","object","property","prototype","hasOwnProperty","p","s","_paddingCharacter","encodedLength","length","encode","data","out","_encodeByte","left","maxDecodedLength","decodedLength","_getPaddingLength","decode","Uint8Array","paddingLength","op","haveBad","v0","v1","v2","v3","_decodeChar","charCodeAt","Error","b","result","String","fromCharCode","Coder","stdCoder","URLSafeCoder","urlSafeCoder","INVALID_UTF8","arr","pos","chars","min","n1","n2","n3","push","join","nacl","gf","init","Float64Array","randombytes","_0","_9","gf0","gf1","_121665","D","D2","X","Y","I","ts64","x","h","vn","xi","y","yi","crypto_verify_16","crypto_verify_32","crypto_core_salsa20","inp","k","u","j0","j1","j2","j3","j4","j5","j6","j7","j8","j9","j10","j11","j12","j13","j14","j15","x0","x1","x2","x3","x4","x5","x6","x7","x8","x9","x10","x11","x12","x13","x14","x15","core_salsa20","crypto_core_hsalsa20","core_hsalsa20","sigma","crypto_stream_salsa20_xor","cpos","mpos","z","crypto_stream_salsa20","crypto_stream","sn","crypto_stream_xor","poly1305","t0","t1","t2","t3","t4","t5","t6","t7","buffer","Uint16Array","pad","leftover","fin","crypto_onetimeauth","outpos","update","finish","crypto_onetimeauth_verify","hpos","crypto_secretbox","crypto_secretbox_open","set25519","a","car25519","v","Math","floor","sel25519","q","pack25519","j","neq25519","par25519","unpack25519","A","Z","M","t8","t9","t10","t11","t12","t13","t14","t15","t16","t17","t18","t19","t20","t21","t22","t23","t24","t25","t26","t27","t28","t29","t30","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","b10","b11","b12","b13","b14","b15","S","inv25519","pow2523","crypto_scalarmult","e","f","x32","subarray","x16","crypto_scalarmult_base","crypto_box_keypair","crypto_box_beforenm","blocks","bytes","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","hibit","h0","h1","h2","h3","h4","h5","h6","h7","h8","h9","r0","r1","r2","r3","r4","r5","r6","r7","r8","r9","mac","macpos","mask","g","want","crypto_box_afternm","crypto_box_open_afternm","K","crypto_hashblocks_hl","hh","hl","bh0","bh1","bh2","bh3","bh4","bh5","bh6","bh7","bl0","bl1","bl2","bl3","bl4","bl5","bl6","bl7","th","tl","wh","Int32Array","wl","ah0","ah1","ah2","ah3","ah4","ah5","ah6","ah7","al0","al1","al2","al3","al4","al5","al6","al7","crypto_hash","add","cswap","pack","tx","ty","zi","scalarmult","scalarbase","crypto_sign_keypair","pk","sk","seeded","L","modL","carry","reduce","crypto_sign","sm","smlen","crypto_sign_open","chk","num","den","den2","den4","den6","unpackneg","checkLengths","checkArrayTypes","arguments","TypeError","cleanup","lowlevel","crypto_box","crypto_box_open","crypto_secretbox_KEYBYTES","crypto_secretbox_NONCEBYTES","crypto_secretbox_ZEROBYTES","crypto_secretbox_BOXZEROBYTES","crypto_scalarmult_BYTES","crypto_scalarmult_SCALARBYTES","crypto_box_PUBLICKEYBYTES","crypto_box_SECRETKEYBYTES","crypto_box_BEFORENMBYTES","crypto_box_NONCEBYTES","crypto_box_ZEROBYTES","crypto_box_BOXZEROBYTES","crypto_sign_BYTES","crypto_sign_PUBLICKEYBYTES","crypto_sign_SECRETKEYBYTES","crypto_sign_SEEDBYTES","crypto_hash_BYTES","randomBytes","secretbox","msg","nonce","open","box","keyLength","nonceLength","overheadLength","scalarMult","base","scalarLength","groupElementLength","publicKey","secretKey","before","checkBoxLengths","after","keyPair","fromSecretKey","publicKeyLength","secretKeyLength","sharedKeyLength","sign","signedMsg","tmp","mlen","detached","sig","verify","fromSeed","seed","seedLength","signatureLength","hash","hashLength","setPRNG","fn","crypto","self","msCrypto","getRandomValues","default","b64chars","b64tab","charAt","cb_utob","cc","utob","replace","cb_encode","ccc","padlen","ord","btoa","set","clear","delay","callback","timer","clearTimeout","clearInterval","super","setTimeout","setInterval","now","Date","valueOf","defer","args","boundArguments","Array","slice","apply","concat","extend","target","sources","extensions","constructor","stringify","safeJSONStringify","arrayIndexOf","array","item","nativeIndexOf","indexOf","objectApply","keys","_","context","map","filter","test","filterObject","Boolean","any","encodeParamsObject","encodeURIComponent","toString","buildQueryString","params","undefined","method","source","JSON","objects","paths","derez","path","nu","$ref","VERSION","PROTOCOL","wsPort","wssPort","wsPath","httpHost","httpPort","httpsPort","httpPath","stats_host","authEndpoint","authTransport","activityTimeout","pongTimeout","unavailableTimeout","userAuthentication","endpoint","transport","channelAuthorization","cdn_http","cdn_https","dependency_suffix","getGenericURL","baseScheme","useTLS","hostTLS","hostNonTLS","getGenericPath","queryString","ws","getInitial","http","_callbacks","prefix","prefixedEventName","names","removeCallback","removeAllCallbacks","binding","failThrough","callbacks","global_callbacks","eventName","remove","unbind","unbind_global","metadata","globalLog","message","console","log","globalLogWarn","globalLogError","warn","error","defaultLoggingFunction","logToConsole","hooks","priority","options","initialize","transportConnectionInitializer","state","timeline","id","generateUniqueID","handlesActivityChecks","supportsPing","socket","url","urls","getSocket","onError","changeState","bindListeners","debug","close","send","ping","beforeOpen","getPath","onopen","emit","type","buildTimelineMessage","closeEvent","code","reason","wasClean","unbindListeners","onOpen","onerror","onclose","onClose","onmessage","onMessage","onactivity","onActivity","info","cid","environment","isSupported","WSTransport","isInitialized","getWebSocketAPI","createWebSocket","httpConfiguration","streamingConfiguration","HTTPFactory","createStreamingSocket","pollingConfiguration","createPollingSocket","xhrConfiguration","isXHRSupported","xhr_streaming","xhr_polling","manager","minPingDelay","maxPingDelay","pingDelay","connection","createConnection","openTimestamp","onClosed","reportDeath","lifespan","max","isAlive","Protocol","decodeMessage","messageEvent","messageData","parse","pusherEventData","pusherEvent","event","channel","user_id","encodeMessage","processHandshake","activity_timeout","action","socket_id","getCloseAction","getCloseError","send_event","listeners","activity","closed","handleCloseEvent","listener","isEmpty","TimelineTransport","getAgent","BadEventName","setPrototypeOf","BadChannelName","TransportPriorityTooLow","TransportClosed","UnsupportedFeature","UnsupportedTransport","UnsupportedStrategy","HTTPAuthError","status","urlStore","baseUrl","authenticationEndpoint","authorizationEndpoint","javascriptQuickStart","triggeringClientEvents","encryptedChannelSupport","fullUrl","urlObj","pusher","subscribed","subscriptionPending","subscriptionCancelled","socketId","auth","suffix","handleSubscriptionSucceededEvent","handleSubscriptionCountEvent","unsubscribe","subscription_count","subscriptionCount","authorize","assign","channel_data","config","channelAuthorizer","channelName","reset","members","member","myID","subscriptionData","presence","count","me","memberData","user_info","authData","channelData","setMyID","user","signinDonePromise","user_data","handleInternalEvent","addedMember","addMember","removedMember","removeMember","onSubscription","disconnect","sharedSecret","handleEncryptedEvent","handleEvent","ciphertext","cipherText","getDataToEmit","raw","usingTLS","errorCallbacks","buildErrorCallbacks","connectionCallbacks","buildConnectionCallbacks","handshakeCallbacks","buildHandshakeCallbacks","Network","getNetwork","netinfo","retryIn","sendActivityCheck","updateStrategy","runner","strategy","updateState","startConnecting","setUnavailableTimer","disconnectInternally","handshake","connect","handshakeError","abortConnecting","abort","clearRetryTimer","clearUnavailableTimer","abandonConnection","getStrategy","round","retryTimer","ensureAborted","unavailableTimer","stopActivityCheck","activityTimer","pong_timed_out","resetActivityCheck","shouldRetry","connected","Infinity","setConnection","withErrorEmitted","tls_only","refused","backoff","retry","newState","previousState","newStateDescription","previous","current","channels","createEncryptedChannel","errMsg","createPrivateChannel","createPresenceChannel","createChannel","values","createChannels","createConnectionManager","createTimelineSender","createHandshake","createAssistantToTheTransportManager","livesLeft","lives","strategies","loop","failFast","timeout","timeoutLimit","minPriority","tryNextStrategy","tryStrategy","forceMinPriority","isRunning","callbackBuilder","runners","rs","abortRunner","allRunnersFailed","aborted","transports","ttl","storage","getLocalStorage","serializedCache","getTransportCacheKey","flushTransportCache","fetchTransportCache","cacheSkipCount","timestamp","includes","cached","latency","startTimestamp","pop","cb","storeTransportCache","number","IfStrategy","trueBranch","falseBranch","FirstConnectedStrategy","testSupportsStrategy","baseOptions","defineTransport","definedTransports","defineTransportStrategy","wsStrategy","ws_options","wsHost","wss_options","http_options","timeouts","ws_manager","streaming_manager","ws_transport","wss_transport","xhr_streaming_transport","xhr_polling_transport","ws_loop","wss_loop","streaming_loop","polling_loop","http_loop","payload","position","xhr","getRequest","unloader","addUnloadListener","setRequestHeader","removeUnloadListener","abortRequest","chunk","advanceBuffer","isBufferTooLong","unreadData","endOfLinePosition","State","autoIncrement","getUniqueURL","separator","randomNumber","randomInt","session","randomString","location","parts","exec","getLocation","readyState","CONNECTING","openStream","sendRaw","sendHeartbeat","OPEN","createSocketRequest","start","closeStream","CLOSED","onEvent","onHeartbeat","hostname","urlParts","stream","getReceiveURL","onChunk","onFinished","reconnect","unbind_all","getXHRAPI","onreadystatechange","onprogress","responseText","getDefaultStrategy","Transports","createSocket","createRequest","PusherClass","ready","getClientFeatures","getProtocol","createXHR","query","authOptions","authRequestType","headers","Headers","headerName","headersProvider","dynamicHeaders","body","request","Request","credentials","fetch","then","response","text","parsedData","catch","err","sender","host","json","setup","TimelineLevel","getAuthorizers","ajax","WebSocket","XMLHttpRequest","globalThis","Uint32Array","events","sent","uniqueID","level","limit","shift","ERROR","INFO","DEBUG","sendfn","bundle","lib","version","cluster","features","failAttempt","onInitialized","serializedTransport","AuthRequestType","transportClass","enabledTransports","disabledTransports","ignoreNullOrigin","getAssistant","deferred","validateOptions","paramsProvider","dynamicParams","composeChannelQuery","UserAuthentication","ChannelAuthorization","getConfig","opts","statsHost","enableStats","getEnableStatsConfig","getHttpHost","shouldUseTLS","getWebsocketHost","userAuthenticator","buildUserAuthenticator","buildChannelAuthorizer","timelineParams","forceTLS","disableStats","customHandler","channelAuthorizerGenerator","deprecatedAuthorizerOptions","ChannelAuthorizerProxy","authorizer","buildChannelAuth","bindWatchlistInternalEvent","forEach","watchlistEvent","resolve","reject","promise","Promise","res","rej","signin_requested","serverToUserChannel","_signinDoneResolve","_onAuthorize","_cleanup","_signin","_newSigninPromiseIfNeeded","watchlist","_onSigninSuccess","_subscribeChannels","bind_global","reinstateSubscription","subscribe","ensure_subscribed","done","setDone","isReady","instances","app_key","checkAppKey","global_emitter","sessionID","timelineSender","subscribeAll","isUsingTLS","internal","appKey","switchCluster","find","all","timelineSenderTimer","event_name","channel_name","cancelSubscription","signin","Runtime","ScriptReceivers","DependenciesReceivers","auth_callbacks"],"mappings":";;;;;;;CAAA,SAA2CA,EAAMC,GAC1B,iBAAZC,SAA0C,iBAAXC,OACxCA,OAAOD,QAAUD,IACQ,mBAAXG,QAAyBA,OAAOC,IAC9CD,OAAO,GAAIH,GACe,iBAAZC,QACdA,QAAgB,OAAID,IAEpBD,EAAa,OAAIC,IARnB,CASGK,MAAM,WACT,O,YCTE,IAAIC,EAAmB,GAGvB,SAASC,EAAoBC,GAG5B,GAAGF,EAAiBE,GACnB,OAAOF,EAAiBE,GAAUP,QAGnC,IAAIC,EA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,WAAW1D,OAEhB0E,EAAQkX,YAEHlX,EAGT,YAAYsY,GACV,IAAItY,EAAU5mB,KAAKmvB,SAAS2P,KAAKI,GAC7BtY,GAAWA,EAAQuC,oBACrBvC,EAAQuY,sBAERvY,EAAU5mB,KAAKmvB,SAASpO,OAAOme,KAChBtY,EAAQsC,YACrBtC,EAAQ8C,cAKd,WAAWuV,EAAoBz8B,EAAWokB,GACxC,OAAO5mB,KAAK4lB,WAAWyB,WAAW4X,EAAYz8B,EAAMokB,GAGtD,eACE,OAAO5mB,KAAKgqB,OAAOpK,OAGrB,SACE5f,KAAKgrB,KAAKoU,UAtOL,GAAAjB,UAAsB,GACtB,GAAAD,SAAmB,EACnB,GAAAtc,cAAwB,EAGxB,GAAAyd,QAA2B,GAC3B,GAAAC,gBAA6B,GAASA,gBACtC,GAAAC,sBAAmC,GAASA,sBAC5C,GAAAC,eAA4B,GAASA,eAVzB,UAkPrB,GAAQ1G,MAAM,I,YClQC,MAAM,WAA6B,GAChD,YAAYsF,EAAiBrc,GAC3B,GAAOH,aAAe,GAAqBA,aAC3C,GAAON,IAAM,GAAqBA,IAElCyZ,GAAgBhZ,GAChBA,EAAQld,KAAO,GACfqW,MAAMkjB,EAASrc","file":"pusher-with-encryption.worker.min.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"Pusher\"] = factory();\n\telse\n\t\troot[\"Pusher\"] = factory();\n})(this, function() {\nreturn "," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 3);\n","// Copyright (C) 2016 Dmitry Chestnykh\n// MIT License. See LICENSE file for details.\n\n/**\n * Package base64 implements Base64 encoding and decoding.\n */\n\n// Invalid character used in decoding to indicate\n// that the character to decode is out of range of\n// alphabet and cannot be decoded.\nconst INVALID_BYTE = 256;\n\n/**\n * Implements standard Base64 encoding.\n *\n * Operates in constant time.\n */\nexport class Coder {\n // TODO(dchest): methods to encode chunk-by-chunk.\n\n constructor(private _paddingCharacter = \"=\") { }\n\n encodedLength(length: number): number {\n if (!this._paddingCharacter) {\n return (length * 8 + 5) / 6 | 0;\n }\n return (length + 2) / 3 * 4 | 0;\n }\n\n encode(data: Uint8Array): string {\n let out = \"\";\n\n let i = 0;\n for (; i < data.length - 2; i += 3) {\n let c = (data[i] << 16) | (data[i + 1] << 8) | (data[i + 2]);\n out += this._encodeByte((c >>> 3 * 6) & 63);\n out += this._encodeByte((c >>> 2 * 6) & 63);\n out += this._encodeByte((c >>> 1 * 6) & 63);\n out += this._encodeByte((c >>> 0 * 6) & 63);\n }\n\n const left = data.length - i;\n if (left > 0) {\n let c = (data[i] << 16) | (left === 2 ? data[i + 1] << 8 : 0);\n out += this._encodeByte((c >>> 3 * 6) & 63);\n out += this._encodeByte((c >>> 2 * 6) & 63);\n if (left === 2) {\n out += this._encodeByte((c >>> 1 * 6) & 63);\n } else {\n out += this._paddingCharacter || \"\";\n }\n out += this._paddingCharacter || \"\";\n }\n\n return out;\n }\n\n maxDecodedLength(length: number): number {\n if (!this._paddingCharacter) {\n return (length * 6 + 7) / 8 | 0;\n }\n return length / 4 * 3 | 0;\n }\n\n decodedLength(s: string): number {\n return this.maxDecodedLength(s.length - this._getPaddingLength(s));\n }\n\n decode(s: string): Uint8Array {\n if (s.length === 0) {\n return new Uint8Array(0);\n }\n const paddingLength = this._getPaddingLength(s);\n const length = s.length - paddingLength;\n const out = new Uint8Array(this.maxDecodedLength(length));\n let op = 0;\n let i = 0;\n let haveBad = 0;\n let v0 = 0, v1 = 0, v2 = 0, v3 = 0;\n for (; i < length - 4; i += 4) {\n v0 = this._decodeChar(s.charCodeAt(i + 0));\n v1 = this._decodeChar(s.charCodeAt(i + 1));\n v2 = this._decodeChar(s.charCodeAt(i + 2));\n v3 = this._decodeChar(s.charCodeAt(i + 3));\n out[op++] = (v0 << 2) | (v1 >>> 4);\n out[op++] = (v1 << 4) | (v2 >>> 2);\n out[op++] = (v2 << 6) | v3;\n haveBad |= v0 & INVALID_BYTE;\n haveBad |= v1 & INVALID_BYTE;\n haveBad |= v2 & INVALID_BYTE;\n haveBad |= v3 & INVALID_BYTE;\n }\n if (i < length - 1) {\n v0 = this._decodeChar(s.charCodeAt(i));\n v1 = this._decodeChar(s.charCodeAt(i + 1));\n out[op++] = (v0 << 2) | (v1 >>> 4);\n haveBad |= v0 & INVALID_BYTE;\n haveBad |= v1 & INVALID_BYTE;\n }\n if (i < length - 2) {\n v2 = this._decodeChar(s.charCodeAt(i + 2));\n out[op++] = (v1 << 4) | (v2 >>> 2);\n haveBad |= v2 & INVALID_BYTE;\n }\n if (i < length - 3) {\n v3 = this._decodeChar(s.charCodeAt(i + 3));\n out[op++] = (v2 << 6) | v3;\n haveBad |= v3 & INVALID_BYTE;\n }\n if (haveBad !== 0) {\n throw new Error(\"Base64Coder: incorrect characters for decoding\");\n }\n return out;\n }\n\n // Standard encoding have the following encoded/decoded ranges,\n // which we need to convert between.\n //\n // ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 0123456789 + /\n // Index: 0 - 25 26 - 51 52 - 61 62 63\n // ASCII: 65 - 90 97 - 122 48 - 57 43 47\n //\n\n // Encode 6 bits in b into a new character.\n protected _encodeByte(b: number): string {\n // Encoding uses constant time operations as follows:\n //\n // 1. Define comparison of A with B using (A - B) >>> 8:\n // if A > B, then result is positive integer\n // if A <= B, then result is 0\n //\n // 2. Define selection of C or 0 using bitwise AND: X & C:\n // if X == 0, then result is 0\n // if X != 0, then result is C\n //\n // 3. Start with the smallest comparison (b >= 0), which is always\n // true, so set the result to the starting ASCII value (65).\n //\n // 4. Continue comparing b to higher ASCII values, and selecting\n // zero if comparison isn't true, otherwise selecting a value\n // to add to result, which:\n //\n // a) undoes the previous addition\n // b) provides new value to add\n //\n let result = b;\n // b >= 0\n result += 65;\n // b > 25\n result += ((25 - b) >>> 8) & ((0 - 65) - 26 + 97);\n // b > 51\n result += ((51 - b) >>> 8) & ((26 - 97) - 52 + 48);\n // b > 61\n result += ((61 - b) >>> 8) & ((52 - 48) - 62 + 43);\n // b > 62\n result += ((62 - b) >>> 8) & ((62 - 43) - 63 + 47);\n\n return String.fromCharCode(result);\n }\n\n // Decode a character code into a byte.\n // Must return 256 if character is out of alphabet range.\n protected _decodeChar(c: number): number {\n // Decoding works similar to encoding: using the same comparison\n // function, but now it works on ranges: result is always incremented\n // by value, but this value becomes zero if the range is not\n // satisfied.\n //\n // Decoding starts with invalid value, 256, which is then\n // subtracted when the range is satisfied. If none of the ranges\n // apply, the function returns 256, which is then checked by\n // the caller to throw error.\n let result = INVALID_BYTE; // start with invalid character\n\n // c == 43 (c > 42 and c < 44)\n result += (((42 - c) & (c - 44)) >>> 8) & (-INVALID_BYTE + c - 43 + 62);\n // c == 47 (c > 46 and c < 48)\n result += (((46 - c) & (c - 48)) >>> 8) & (-INVALID_BYTE + c - 47 + 63);\n // c > 47 and c < 58\n result += (((47 - c) & (c - 58)) >>> 8) & (-INVALID_BYTE + c - 48 + 52);\n // c > 64 and c < 91\n result += (((64 - c) & (c - 91)) >>> 8) & (-INVALID_BYTE + c - 65 + 0);\n // c > 96 and c < 123\n result += (((96 - c) & (c - 123)) >>> 8) & (-INVALID_BYTE + c - 97 + 26);\n\n return result;\n }\n\n private _getPaddingLength(s: string): number {\n let paddingLength = 0;\n if (this._paddingCharacter) {\n for (let i = s.length - 1; i >= 0; i--) {\n if (s[i] !== this._paddingCharacter) {\n break;\n }\n paddingLength++;\n }\n if (s.length < 4 || paddingLength > 2) {\n throw new Error(\"Base64Coder: incorrect padding\");\n }\n }\n return paddingLength;\n }\n\n}\n\nconst stdCoder = new Coder();\n\nexport function encode(data: Uint8Array): string {\n return stdCoder.encode(data);\n}\n\nexport function decode(s: string): Uint8Array {\n return stdCoder.decode(s);\n}\n\n/**\n * Implements URL-safe Base64 encoding.\n * (Same as Base64, but '+' is replaced with '-', and '/' with '_').\n *\n * Operates in constant time.\n */\nexport class URLSafeCoder extends Coder {\n // URL-safe encoding have the following encoded/decoded ranges:\n //\n // ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 0123456789 - _\n // Index: 0 - 25 26 - 51 52 - 61 62 63\n // ASCII: 65 - 90 97 - 122 48 - 57 45 95\n //\n\n protected _encodeByte(b: number): string {\n let result = b;\n // b >= 0\n result += 65;\n // b > 25\n result += ((25 - b) >>> 8) & ((0 - 65) - 26 + 97);\n // b > 51\n result += ((51 - b) >>> 8) & ((26 - 97) - 52 + 48);\n // b > 61\n result += ((61 - b) >>> 8) & ((52 - 48) - 62 + 45);\n // b > 62\n result += ((62 - b) >>> 8) & ((62 - 45) - 63 + 95);\n\n return String.fromCharCode(result);\n }\n\n protected _decodeChar(c: number): number {\n let result = INVALID_BYTE;\n\n // c == 45 (c > 44 and c < 46)\n result += (((44 - c) & (c - 46)) >>> 8) & (-INVALID_BYTE + c - 45 + 62);\n // c == 95 (c > 94 and c < 96)\n result += (((94 - c) & (c - 96)) >>> 8) & (-INVALID_BYTE + c - 95 + 63);\n // c > 47 and c < 58\n result += (((47 - c) & (c - 58)) >>> 8) & (-INVALID_BYTE + c - 48 + 52);\n // c > 64 and c < 91\n result += (((64 - c) & (c - 91)) >>> 8) & (-INVALID_BYTE + c - 65 + 0);\n // c > 96 and c < 123\n result += (((96 - c) & (c - 123)) >>> 8) & (-INVALID_BYTE + c - 97 + 26);\n\n return result;\n }\n}\n\nconst urlSafeCoder = new URLSafeCoder();\n\nexport function encodeURLSafe(data: Uint8Array): string {\n return urlSafeCoder.encode(data);\n}\n\nexport function decodeURLSafe(s: string): Uint8Array {\n return urlSafeCoder.decode(s);\n}\n\n\nexport const encodedLength = (length: number) =>\n stdCoder.encodedLength(length);\n\nexport const maxDecodedLength = (length: number) =>\n stdCoder.maxDecodedLength(length);\n\nexport const decodedLength = (s: string) =>\n stdCoder.decodedLength(s);\n","// Copyright (C) 2016 Dmitry Chestnykh\n// MIT License. See LICENSE file for details.\n\n/**\n * Package utf8 implements UTF-8 encoding and decoding.\n */\n\nconst INVALID_UTF16 = \"utf8: invalid string\";\nconst INVALID_UTF8 = \"utf8: invalid source encoding\";\n\n/**\n * Encodes the given string into UTF-8 byte array.\n * Throws if the source string has invalid UTF-16 encoding.\n */\nexport function encode(s: string): Uint8Array {\n // Calculate result length and allocate output array.\n // encodedLength() also validates string and throws errors,\n // so we don't need repeat validation here.\n const arr = new Uint8Array(encodedLength(s));\n\n let pos = 0;\n for (let i = 0; i < s.length; i++) {\n let c = s.charCodeAt(i);\n if (c < 0x80) {\n arr[pos++] = c;\n } else if (c < 0x800) {\n arr[pos++] = 0xc0 | c >> 6;\n arr[pos++] = 0x80 | c & 0x3f;\n } else if (c < 0xd800) {\n arr[pos++] = 0xe0 | c >> 12;\n arr[pos++] = 0x80 | (c >> 6) & 0x3f;\n arr[pos++] = 0x80 | c & 0x3f;\n } else {\n i++; // get one more character\n c = (c & 0x3ff) << 10;\n c |= s.charCodeAt(i) & 0x3ff;\n c += 0x10000;\n\n arr[pos++] = 0xf0 | c >> 18;\n arr[pos++] = 0x80 | (c >> 12) & 0x3f;\n arr[pos++] = 0x80 | (c >> 6) & 0x3f;\n arr[pos++] = 0x80 | c & 0x3f;\n }\n }\n return arr;\n}\n\n/**\n * Returns the number of bytes required to encode the given string into UTF-8.\n * Throws if the source string has invalid UTF-16 encoding.\n */\nexport function encodedLength(s: string): number {\n let result = 0;\n for (let i = 0; i < s.length; i++) {\n const c = s.charCodeAt(i);\n if (c < 0x80) {\n result += 1;\n } else if (c < 0x800) {\n result += 2;\n } else if (c < 0xd800) {\n result += 3;\n } else if (c <= 0xdfff) {\n if (i >= s.length - 1) {\n throw new Error(INVALID_UTF16);\n }\n i++; // \"eat\" next character\n result += 4;\n } else {\n throw new Error(INVALID_UTF16);\n }\n }\n return result;\n}\n\n/**\n * Decodes the given byte array from UTF-8 into a string.\n * Throws if encoding is invalid.\n */\nexport function decode(arr: Uint8Array): string {\n const chars: string[] = [];\n for (let i = 0; i < arr.length; i++) {\n let b = arr[i];\n\n if (b & 0x80) {\n let min;\n if (b < 0xe0) {\n // Need 1 more byte.\n if (i >= arr.length) {\n throw new Error(INVALID_UTF8);\n }\n const n1 = arr[++i];\n if ((n1 & 0xc0) !== 0x80) {\n throw new Error(INVALID_UTF8);\n }\n b = (b & 0x1f) << 6 | (n1 & 0x3f);\n min = 0x80;\n } else if (b < 0xf0) {\n // Need 2 more bytes.\n if (i >= arr.length - 1) {\n throw new Error(INVALID_UTF8);\n }\n const n1 = arr[++i];\n const n2 = arr[++i];\n if ((n1 & 0xc0) !== 0x80 || (n2 & 0xc0) !== 0x80) {\n throw new Error(INVALID_UTF8);\n }\n b = (b & 0x0f) << 12 | (n1 & 0x3f) << 6 | (n2 & 0x3f);\n min = 0x800;\n } else if (b < 0xf8) {\n // Need 3 more bytes.\n if (i >= arr.length - 2) {\n throw new Error(INVALID_UTF8);\n }\n const n1 = arr[++i];\n const n2 = arr[++i];\n const n3 = arr[++i];\n if ((n1 & 0xc0) !== 0x80 || (n2 & 0xc0) !== 0x80 || (n3 & 0xc0) !== 0x80) {\n throw new Error(INVALID_UTF8);\n }\n b = (b & 0x0f) << 18 | (n1 & 0x3f) << 12 | (n2 & 0x3f) << 6 | (n3 & 0x3f);\n min = 0x10000;\n } else {\n throw new Error(INVALID_UTF8);\n }\n\n if (b < min || (b >= 0xd800 && b <= 0xdfff)) {\n throw new Error(INVALID_UTF8);\n }\n\n if (b >= 0x10000) {\n // Surrogate pair.\n if (b > 0x10ffff) {\n throw new Error(INVALID_UTF8);\n }\n b -= 0x10000;\n chars.push(String.fromCharCode(0xd800 | (b >> 10)));\n b = 0xdc00 | (b & 0x3ff);\n }\n }\n\n chars.push(String.fromCharCode(b));\n }\n return chars.join(\"\");\n}\n","(function(nacl) {\n'use strict';\n\n// Ported in 2014 by Dmitry Chestnykh and Devi Mandiri.\n// Public domain.\n//\n// Implementation derived from TweetNaCl version 20140427.\n// See for details: http://tweetnacl.cr.yp.to/\n\nvar gf = function(init) {\n var i, r = new Float64Array(16);\n if (init) for (i = 0; i < init.length; i++) r[i] = init[i];\n return r;\n};\n\n// Pluggable, initialized in high-level API below.\nvar randombytes = function(/* x, n */) { throw new Error('no PRNG'); };\n\nvar _0 = new Uint8Array(16);\nvar _9 = new Uint8Array(32); _9[0] = 9;\n\nvar gf0 = gf(),\n gf1 = gf([1]),\n _121665 = gf([0xdb41, 1]),\n D = gf([0x78a3, 0x1359, 0x4dca, 0x75eb, 0xd8ab, 0x4141, 0x0a4d, 0x0070, 0xe898, 0x7779, 0x4079, 0x8cc7, 0xfe73, 0x2b6f, 0x6cee, 0x5203]),\n D2 = gf([0xf159, 0x26b2, 0x9b94, 0xebd6, 0xb156, 0x8283, 0x149a, 0x00e0, 0xd130, 0xeef3, 0x80f2, 0x198e, 0xfce7, 0x56df, 0xd9dc, 0x2406]),\n X = gf([0xd51a, 0x8f25, 0x2d60, 0xc956, 0xa7b2, 0x9525, 0xc760, 0x692c, 0xdc5c, 0xfdd6, 0xe231, 0xc0a4, 0x53fe, 0xcd6e, 0x36d3, 0x2169]),\n Y = gf([0x6658, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666]),\n I = gf([0xa0b0, 0x4a0e, 0x1b27, 0xc4ee, 0xe478, 0xad2f, 0x1806, 0x2f43, 0xd7a7, 0x3dfb, 0x0099, 0x2b4d, 0xdf0b, 0x4fc1, 0x2480, 0x2b83]);\n\nfunction ts64(x, i, h, l) {\n x[i] = (h >> 24) & 0xff;\n x[i+1] = (h >> 16) & 0xff;\n x[i+2] = (h >> 8) & 0xff;\n x[i+3] = h & 0xff;\n x[i+4] = (l >> 24) & 0xff;\n x[i+5] = (l >> 16) & 0xff;\n x[i+6] = (l >> 8) & 0xff;\n x[i+7] = l & 0xff;\n}\n\nfunction vn(x, xi, y, yi, n) {\n var i,d = 0;\n for (i = 0; i < n; i++) d |= x[xi+i]^y[yi+i];\n return (1 & ((d - 1) >>> 8)) - 1;\n}\n\nfunction crypto_verify_16(x, xi, y, yi) {\n return vn(x,xi,y,yi,16);\n}\n\nfunction crypto_verify_32(x, xi, y, yi) {\n return vn(x,xi,y,yi,32);\n}\n\nfunction core_salsa20(o, p, k, c) {\n var j0 = c[ 0] & 0xff | (c[ 1] & 0xff)<<8 | (c[ 2] & 0xff)<<16 | (c[ 3] & 0xff)<<24,\n j1 = k[ 0] & 0xff | (k[ 1] & 0xff)<<8 | (k[ 2] & 0xff)<<16 | (k[ 3] & 0xff)<<24,\n j2 = k[ 4] & 0xff | (k[ 5] & 0xff)<<8 | (k[ 6] & 0xff)<<16 | (k[ 7] & 0xff)<<24,\n j3 = k[ 8] & 0xff | (k[ 9] & 0xff)<<8 | (k[10] & 0xff)<<16 | (k[11] & 0xff)<<24,\n j4 = k[12] & 0xff | (k[13] & 0xff)<<8 | (k[14] & 0xff)<<16 | (k[15] & 0xff)<<24,\n j5 = c[ 4] & 0xff | (c[ 5] & 0xff)<<8 | (c[ 6] & 0xff)<<16 | (c[ 7] & 0xff)<<24,\n j6 = p[ 0] & 0xff | (p[ 1] & 0xff)<<8 | (p[ 2] & 0xff)<<16 | (p[ 3] & 0xff)<<24,\n j7 = p[ 4] & 0xff | (p[ 5] & 0xff)<<8 | (p[ 6] & 0xff)<<16 | (p[ 7] & 0xff)<<24,\n j8 = p[ 8] & 0xff | (p[ 9] & 0xff)<<8 | (p[10] & 0xff)<<16 | (p[11] & 0xff)<<24,\n j9 = p[12] & 0xff | (p[13] & 0xff)<<8 | (p[14] & 0xff)<<16 | (p[15] & 0xff)<<24,\n j10 = c[ 8] & 0xff | (c[ 9] & 0xff)<<8 | (c[10] & 0xff)<<16 | (c[11] & 0xff)<<24,\n j11 = k[16] & 0xff | (k[17] & 0xff)<<8 | (k[18] & 0xff)<<16 | (k[19] & 0xff)<<24,\n j12 = k[20] & 0xff | (k[21] & 0xff)<<8 | (k[22] & 0xff)<<16 | (k[23] & 0xff)<<24,\n j13 = k[24] & 0xff | (k[25] & 0xff)<<8 | (k[26] & 0xff)<<16 | (k[27] & 0xff)<<24,\n j14 = k[28] & 0xff | (k[29] & 0xff)<<8 | (k[30] & 0xff)<<16 | (k[31] & 0xff)<<24,\n j15 = c[12] & 0xff | (c[13] & 0xff)<<8 | (c[14] & 0xff)<<16 | (c[15] & 0xff)<<24;\n\n var x0 = j0, x1 = j1, x2 = j2, x3 = j3, x4 = j4, x5 = j5, x6 = j6, x7 = j7,\n x8 = j8, x9 = j9, x10 = j10, x11 = j11, x12 = j12, x13 = j13, x14 = j14,\n x15 = j15, u;\n\n for (var i = 0; i < 20; i += 2) {\n u = x0 + x12 | 0;\n x4 ^= u<<7 | u>>>(32-7);\n u = x4 + x0 | 0;\n x8 ^= u<<9 | u>>>(32-9);\n u = x8 + x4 | 0;\n x12 ^= u<<13 | u>>>(32-13);\n u = x12 + x8 | 0;\n x0 ^= u<<18 | u>>>(32-18);\n\n u = x5 + x1 | 0;\n x9 ^= u<<7 | u>>>(32-7);\n u = x9 + x5 | 0;\n x13 ^= u<<9 | u>>>(32-9);\n u = x13 + x9 | 0;\n x1 ^= u<<13 | u>>>(32-13);\n u = x1 + x13 | 0;\n x5 ^= u<<18 | u>>>(32-18);\n\n u = x10 + x6 | 0;\n x14 ^= u<<7 | u>>>(32-7);\n u = x14 + x10 | 0;\n x2 ^= u<<9 | u>>>(32-9);\n u = x2 + x14 | 0;\n x6 ^= u<<13 | u>>>(32-13);\n u = x6 + x2 | 0;\n x10 ^= u<<18 | u>>>(32-18);\n\n u = x15 + x11 | 0;\n x3 ^= u<<7 | u>>>(32-7);\n u = x3 + x15 | 0;\n x7 ^= u<<9 | u>>>(32-9);\n u = x7 + x3 | 0;\n x11 ^= u<<13 | u>>>(32-13);\n u = x11 + x7 | 0;\n x15 ^= u<<18 | u>>>(32-18);\n\n u = x0 + x3 | 0;\n x1 ^= u<<7 | u>>>(32-7);\n u = x1 + x0 | 0;\n x2 ^= u<<9 | u>>>(32-9);\n u = x2 + x1 | 0;\n x3 ^= u<<13 | u>>>(32-13);\n u = x3 + x2 | 0;\n x0 ^= u<<18 | u>>>(32-18);\n\n u = x5 + x4 | 0;\n x6 ^= u<<7 | u>>>(32-7);\n u = x6 + x5 | 0;\n x7 ^= u<<9 | u>>>(32-9);\n u = x7 + x6 | 0;\n x4 ^= u<<13 | u>>>(32-13);\n u = x4 + x7 | 0;\n x5 ^= u<<18 | u>>>(32-18);\n\n u = x10 + x9 | 0;\n x11 ^= u<<7 | u>>>(32-7);\n u = x11 + x10 | 0;\n x8 ^= u<<9 | u>>>(32-9);\n u = x8 + x11 | 0;\n x9 ^= u<<13 | u>>>(32-13);\n u = x9 + x8 | 0;\n x10 ^= u<<18 | u>>>(32-18);\n\n u = x15 + x14 | 0;\n x12 ^= u<<7 | u>>>(32-7);\n u = x12 + x15 | 0;\n x13 ^= u<<9 | u>>>(32-9);\n u = x13 + x12 | 0;\n x14 ^= u<<13 | u>>>(32-13);\n u = x14 + x13 | 0;\n x15 ^= u<<18 | u>>>(32-18);\n }\n x0 = x0 + j0 | 0;\n x1 = x1 + j1 | 0;\n x2 = x2 + j2 | 0;\n x3 = x3 + j3 | 0;\n x4 = x4 + j4 | 0;\n x5 = x5 + j5 | 0;\n x6 = x6 + j6 | 0;\n x7 = x7 + j7 | 0;\n x8 = x8 + j8 | 0;\n x9 = x9 + j9 | 0;\n x10 = x10 + j10 | 0;\n x11 = x11 + j11 | 0;\n x12 = x12 + j12 | 0;\n x13 = x13 + j13 | 0;\n x14 = x14 + j14 | 0;\n x15 = x15 + j15 | 0;\n\n o[ 0] = x0 >>> 0 & 0xff;\n o[ 1] = x0 >>> 8 & 0xff;\n o[ 2] = x0 >>> 16 & 0xff;\n o[ 3] = x0 >>> 24 & 0xff;\n\n o[ 4] = x1 >>> 0 & 0xff;\n o[ 5] = x1 >>> 8 & 0xff;\n o[ 6] = x1 >>> 16 & 0xff;\n o[ 7] = x1 >>> 24 & 0xff;\n\n o[ 8] = x2 >>> 0 & 0xff;\n o[ 9] = x2 >>> 8 & 0xff;\n o[10] = x2 >>> 16 & 0xff;\n o[11] = x2 >>> 24 & 0xff;\n\n o[12] = x3 >>> 0 & 0xff;\n o[13] = x3 >>> 8 & 0xff;\n o[14] = x3 >>> 16 & 0xff;\n o[15] = x3 >>> 24 & 0xff;\n\n o[16] = x4 >>> 0 & 0xff;\n o[17] = x4 >>> 8 & 0xff;\n o[18] = x4 >>> 16 & 0xff;\n o[19] = x4 >>> 24 & 0xff;\n\n o[20] = x5 >>> 0 & 0xff;\n o[21] = x5 >>> 8 & 0xff;\n o[22] = x5 >>> 16 & 0xff;\n o[23] = x5 >>> 24 & 0xff;\n\n o[24] = x6 >>> 0 & 0xff;\n o[25] = x6 >>> 8 & 0xff;\n o[26] = x6 >>> 16 & 0xff;\n o[27] = x6 >>> 24 & 0xff;\n\n o[28] = x7 >>> 0 & 0xff;\n o[29] = x7 >>> 8 & 0xff;\n o[30] = x7 >>> 16 & 0xff;\n o[31] = x7 >>> 24 & 0xff;\n\n o[32] = x8 >>> 0 & 0xff;\n o[33] = x8 >>> 8 & 0xff;\n o[34] = x8 >>> 16 & 0xff;\n o[35] = x8 >>> 24 & 0xff;\n\n o[36] = x9 >>> 0 & 0xff;\n o[37] = x9 >>> 8 & 0xff;\n o[38] = x9 >>> 16 & 0xff;\n o[39] = x9 >>> 24 & 0xff;\n\n o[40] = x10 >>> 0 & 0xff;\n o[41] = x10 >>> 8 & 0xff;\n o[42] = x10 >>> 16 & 0xff;\n o[43] = x10 >>> 24 & 0xff;\n\n o[44] = x11 >>> 0 & 0xff;\n o[45] = x11 >>> 8 & 0xff;\n o[46] = x11 >>> 16 & 0xff;\n o[47] = x11 >>> 24 & 0xff;\n\n o[48] = x12 >>> 0 & 0xff;\n o[49] = x12 >>> 8 & 0xff;\n o[50] = x12 >>> 16 & 0xff;\n o[51] = x12 >>> 24 & 0xff;\n\n o[52] = x13 >>> 0 & 0xff;\n o[53] = x13 >>> 8 & 0xff;\n o[54] = x13 >>> 16 & 0xff;\n o[55] = x13 >>> 24 & 0xff;\n\n o[56] = x14 >>> 0 & 0xff;\n o[57] = x14 >>> 8 & 0xff;\n o[58] = x14 >>> 16 & 0xff;\n o[59] = x14 >>> 24 & 0xff;\n\n o[60] = x15 >>> 0 & 0xff;\n o[61] = x15 >>> 8 & 0xff;\n o[62] = x15 >>> 16 & 0xff;\n o[63] = x15 >>> 24 & 0xff;\n}\n\nfunction core_hsalsa20(o,p,k,c) {\n var j0 = c[ 0] & 0xff | (c[ 1] & 0xff)<<8 | (c[ 2] & 0xff)<<16 | (c[ 3] & 0xff)<<24,\n j1 = k[ 0] & 0xff | (k[ 1] & 0xff)<<8 | (k[ 2] & 0xff)<<16 | (k[ 3] & 0xff)<<24,\n j2 = k[ 4] & 0xff | (k[ 5] & 0xff)<<8 | (k[ 6] & 0xff)<<16 | (k[ 7] & 0xff)<<24,\n j3 = k[ 8] & 0xff | (k[ 9] & 0xff)<<8 | (k[10] & 0xff)<<16 | (k[11] & 0xff)<<24,\n j4 = k[12] & 0xff | (k[13] & 0xff)<<8 | (k[14] & 0xff)<<16 | (k[15] & 0xff)<<24,\n j5 = c[ 4] & 0xff | (c[ 5] & 0xff)<<8 | (c[ 6] & 0xff)<<16 | (c[ 7] & 0xff)<<24,\n j6 = p[ 0] & 0xff | (p[ 1] & 0xff)<<8 | (p[ 2] & 0xff)<<16 | (p[ 3] & 0xff)<<24,\n j7 = p[ 4] & 0xff | (p[ 5] & 0xff)<<8 | (p[ 6] & 0xff)<<16 | (p[ 7] & 0xff)<<24,\n j8 = p[ 8] & 0xff | (p[ 9] & 0xff)<<8 | (p[10] & 0xff)<<16 | (p[11] & 0xff)<<24,\n j9 = p[12] & 0xff | (p[13] & 0xff)<<8 | (p[14] & 0xff)<<16 | (p[15] & 0xff)<<24,\n j10 = c[ 8] & 0xff | (c[ 9] & 0xff)<<8 | (c[10] & 0xff)<<16 | (c[11] & 0xff)<<24,\n j11 = k[16] & 0xff | (k[17] & 0xff)<<8 | (k[18] & 0xff)<<16 | (k[19] & 0xff)<<24,\n j12 = k[20] & 0xff | (k[21] & 0xff)<<8 | (k[22] & 0xff)<<16 | (k[23] & 0xff)<<24,\n j13 = k[24] & 0xff | (k[25] & 0xff)<<8 | (k[26] & 0xff)<<16 | (k[27] & 0xff)<<24,\n j14 = k[28] & 0xff | (k[29] & 0xff)<<8 | (k[30] & 0xff)<<16 | (k[31] & 0xff)<<24,\n j15 = c[12] & 0xff | (c[13] & 0xff)<<8 | (c[14] & 0xff)<<16 | (c[15] & 0xff)<<24;\n\n var x0 = j0, x1 = j1, x2 = j2, x3 = j3, x4 = j4, x5 = j5, x6 = j6, x7 = j7,\n x8 = j8, x9 = j9, x10 = j10, x11 = j11, x12 = j12, x13 = j13, x14 = j14,\n x15 = j15, u;\n\n for (var i = 0; i < 20; i += 2) {\n u = x0 + x12 | 0;\n x4 ^= u<<7 | u>>>(32-7);\n u = x4 + x0 | 0;\n x8 ^= u<<9 | u>>>(32-9);\n u = x8 + x4 | 0;\n x12 ^= u<<13 | u>>>(32-13);\n u = x12 + x8 | 0;\n x0 ^= u<<18 | u>>>(32-18);\n\n u = x5 + x1 | 0;\n x9 ^= u<<7 | u>>>(32-7);\n u = x9 + x5 | 0;\n x13 ^= u<<9 | u>>>(32-9);\n u = x13 + x9 | 0;\n x1 ^= u<<13 | u>>>(32-13);\n u = x1 + x13 | 0;\n x5 ^= u<<18 | u>>>(32-18);\n\n u = x10 + x6 | 0;\n x14 ^= u<<7 | u>>>(32-7);\n u = x14 + x10 | 0;\n x2 ^= u<<9 | u>>>(32-9);\n u = x2 + x14 | 0;\n x6 ^= u<<13 | u>>>(32-13);\n u = x6 + x2 | 0;\n x10 ^= u<<18 | u>>>(32-18);\n\n u = x15 + x11 | 0;\n x3 ^= u<<7 | u>>>(32-7);\n u = x3 + x15 | 0;\n x7 ^= u<<9 | u>>>(32-9);\n u = x7 + x3 | 0;\n x11 ^= u<<13 | u>>>(32-13);\n u = x11 + x7 | 0;\n x15 ^= u<<18 | u>>>(32-18);\n\n u = x0 + x3 | 0;\n x1 ^= u<<7 | u>>>(32-7);\n u = x1 + x0 | 0;\n x2 ^= u<<9 | u>>>(32-9);\n u = x2 + x1 | 0;\n x3 ^= u<<13 | u>>>(32-13);\n u = x3 + x2 | 0;\n x0 ^= u<<18 | u>>>(32-18);\n\n u = x5 + x4 | 0;\n x6 ^= u<<7 | u>>>(32-7);\n u = x6 + x5 | 0;\n x7 ^= u<<9 | u>>>(32-9);\n u = x7 + x6 | 0;\n x4 ^= u<<13 | u>>>(32-13);\n u = x4 + x7 | 0;\n x5 ^= u<<18 | u>>>(32-18);\n\n u = x10 + x9 | 0;\n x11 ^= u<<7 | u>>>(32-7);\n u = x11 + x10 | 0;\n x8 ^= u<<9 | u>>>(32-9);\n u = x8 + x11 | 0;\n x9 ^= u<<13 | u>>>(32-13);\n u = x9 + x8 | 0;\n x10 ^= u<<18 | u>>>(32-18);\n\n u = x15 + x14 | 0;\n x12 ^= u<<7 | u>>>(32-7);\n u = x12 + x15 | 0;\n x13 ^= u<<9 | u>>>(32-9);\n u = x13 + x12 | 0;\n x14 ^= u<<13 | u>>>(32-13);\n u = x14 + x13 | 0;\n x15 ^= u<<18 | u>>>(32-18);\n }\n\n o[ 0] = x0 >>> 0 & 0xff;\n o[ 1] = x0 >>> 8 & 0xff;\n o[ 2] = x0 >>> 16 & 0xff;\n o[ 3] = x0 >>> 24 & 0xff;\n\n o[ 4] = x5 >>> 0 & 0xff;\n o[ 5] = x5 >>> 8 & 0xff;\n o[ 6] = x5 >>> 16 & 0xff;\n o[ 7] = x5 >>> 24 & 0xff;\n\n o[ 8] = x10 >>> 0 & 0xff;\n o[ 9] = x10 >>> 8 & 0xff;\n o[10] = x10 >>> 16 & 0xff;\n o[11] = x10 >>> 24 & 0xff;\n\n o[12] = x15 >>> 0 & 0xff;\n o[13] = x15 >>> 8 & 0xff;\n o[14] = x15 >>> 16 & 0xff;\n o[15] = x15 >>> 24 & 0xff;\n\n o[16] = x6 >>> 0 & 0xff;\n o[17] = x6 >>> 8 & 0xff;\n o[18] = x6 >>> 16 & 0xff;\n o[19] = x6 >>> 24 & 0xff;\n\n o[20] = x7 >>> 0 & 0xff;\n o[21] = x7 >>> 8 & 0xff;\n o[22] = x7 >>> 16 & 0xff;\n o[23] = x7 >>> 24 & 0xff;\n\n o[24] = x8 >>> 0 & 0xff;\n o[25] = x8 >>> 8 & 0xff;\n o[26] = x8 >>> 16 & 0xff;\n o[27] = x8 >>> 24 & 0xff;\n\n o[28] = x9 >>> 0 & 0xff;\n o[29] = x9 >>> 8 & 0xff;\n o[30] = x9 >>> 16 & 0xff;\n o[31] = x9 >>> 24 & 0xff;\n}\n\nfunction crypto_core_salsa20(out,inp,k,c) {\n core_salsa20(out,inp,k,c);\n}\n\nfunction crypto_core_hsalsa20(out,inp,k,c) {\n core_hsalsa20(out,inp,k,c);\n}\n\nvar sigma = new Uint8Array([101, 120, 112, 97, 110, 100, 32, 51, 50, 45, 98, 121, 116, 101, 32, 107]);\n // \"expand 32-byte k\"\n\nfunction crypto_stream_salsa20_xor(c,cpos,m,mpos,b,n,k) {\n var z = new Uint8Array(16), x = new Uint8Array(64);\n var u, i;\n for (i = 0; i < 16; i++) z[i] = 0;\n for (i = 0; i < 8; i++) z[i] = n[i];\n while (b >= 64) {\n crypto_core_salsa20(x,z,k,sigma);\n for (i = 0; i < 64; i++) c[cpos+i] = m[mpos+i] ^ x[i];\n u = 1;\n for (i = 8; i < 16; i++) {\n u = u + (z[i] & 0xff) | 0;\n z[i] = u & 0xff;\n u >>>= 8;\n }\n b -= 64;\n cpos += 64;\n mpos += 64;\n }\n if (b > 0) {\n crypto_core_salsa20(x,z,k,sigma);\n for (i = 0; i < b; i++) c[cpos+i] = m[mpos+i] ^ x[i];\n }\n return 0;\n}\n\nfunction crypto_stream_salsa20(c,cpos,b,n,k) {\n var z = new Uint8Array(16), x = new Uint8Array(64);\n var u, i;\n for (i = 0; i < 16; i++) z[i] = 0;\n for (i = 0; i < 8; i++) z[i] = n[i];\n while (b >= 64) {\n crypto_core_salsa20(x,z,k,sigma);\n for (i = 0; i < 64; i++) c[cpos+i] = x[i];\n u = 1;\n for (i = 8; i < 16; i++) {\n u = u + (z[i] & 0xff) | 0;\n z[i] = u & 0xff;\n u >>>= 8;\n }\n b -= 64;\n cpos += 64;\n }\n if (b > 0) {\n crypto_core_salsa20(x,z,k,sigma);\n for (i = 0; i < b; i++) c[cpos+i] = x[i];\n }\n return 0;\n}\n\nfunction crypto_stream(c,cpos,d,n,k) {\n var s = new Uint8Array(32);\n crypto_core_hsalsa20(s,n,k,sigma);\n var sn = new Uint8Array(8);\n for (var i = 0; i < 8; i++) sn[i] = n[i+16];\n return crypto_stream_salsa20(c,cpos,d,sn,s);\n}\n\nfunction crypto_stream_xor(c,cpos,m,mpos,d,n,k) {\n var s = new Uint8Array(32);\n crypto_core_hsalsa20(s,n,k,sigma);\n var sn = new Uint8Array(8);\n for (var i = 0; i < 8; i++) sn[i] = n[i+16];\n return crypto_stream_salsa20_xor(c,cpos,m,mpos,d,sn,s);\n}\n\n/*\n* Port of Andrew Moon's Poly1305-donna-16. Public domain.\n* https://github.com/floodyberry/poly1305-donna\n*/\n\nvar poly1305 = function(key) {\n this.buffer = new Uint8Array(16);\n this.r = new Uint16Array(10);\n this.h = new Uint16Array(10);\n this.pad = new Uint16Array(8);\n this.leftover = 0;\n this.fin = 0;\n\n var t0, t1, t2, t3, t4, t5, t6, t7;\n\n t0 = key[ 0] & 0xff | (key[ 1] & 0xff) << 8; this.r[0] = ( t0 ) & 0x1fff;\n t1 = key[ 2] & 0xff | (key[ 3] & 0xff) << 8; this.r[1] = ((t0 >>> 13) | (t1 << 3)) & 0x1fff;\n t2 = key[ 4] & 0xff | (key[ 5] & 0xff) << 8; this.r[2] = ((t1 >>> 10) | (t2 << 6)) & 0x1f03;\n t3 = key[ 6] & 0xff | (key[ 7] & 0xff) << 8; this.r[3] = ((t2 >>> 7) | (t3 << 9)) & 0x1fff;\n t4 = key[ 8] & 0xff | (key[ 9] & 0xff) << 8; this.r[4] = ((t3 >>> 4) | (t4 << 12)) & 0x00ff;\n this.r[5] = ((t4 >>> 1)) & 0x1ffe;\n t5 = key[10] & 0xff | (key[11] & 0xff) << 8; this.r[6] = ((t4 >>> 14) | (t5 << 2)) & 0x1fff;\n t6 = key[12] & 0xff | (key[13] & 0xff) << 8; this.r[7] = ((t5 >>> 11) | (t6 << 5)) & 0x1f81;\n t7 = key[14] & 0xff | (key[15] & 0xff) << 8; this.r[8] = ((t6 >>> 8) | (t7 << 8)) & 0x1fff;\n this.r[9] = ((t7 >>> 5)) & 0x007f;\n\n this.pad[0] = key[16] & 0xff | (key[17] & 0xff) << 8;\n this.pad[1] = key[18] & 0xff | (key[19] & 0xff) << 8;\n this.pad[2] = key[20] & 0xff | (key[21] & 0xff) << 8;\n this.pad[3] = key[22] & 0xff | (key[23] & 0xff) << 8;\n this.pad[4] = key[24] & 0xff | (key[25] & 0xff) << 8;\n this.pad[5] = key[26] & 0xff | (key[27] & 0xff) << 8;\n this.pad[6] = key[28] & 0xff | (key[29] & 0xff) << 8;\n this.pad[7] = key[30] & 0xff | (key[31] & 0xff) << 8;\n};\n\npoly1305.prototype.blocks = function(m, mpos, bytes) {\n var hibit = this.fin ? 0 : (1 << 11);\n var t0, t1, t2, t3, t4, t5, t6, t7, c;\n var d0, d1, d2, d3, d4, d5, d6, d7, d8, d9;\n\n var h0 = this.h[0],\n h1 = this.h[1],\n h2 = this.h[2],\n h3 = this.h[3],\n h4 = this.h[4],\n h5 = this.h[5],\n h6 = this.h[6],\n h7 = this.h[7],\n h8 = this.h[8],\n h9 = this.h[9];\n\n var r0 = this.r[0],\n r1 = this.r[1],\n r2 = this.r[2],\n r3 = this.r[3],\n r4 = this.r[4],\n r5 = this.r[5],\n r6 = this.r[6],\n r7 = this.r[7],\n r8 = this.r[8],\n r9 = this.r[9];\n\n while (bytes >= 16) {\n t0 = m[mpos+ 0] & 0xff | (m[mpos+ 1] & 0xff) << 8; h0 += ( t0 ) & 0x1fff;\n t1 = m[mpos+ 2] & 0xff | (m[mpos+ 3] & 0xff) << 8; h1 += ((t0 >>> 13) | (t1 << 3)) & 0x1fff;\n t2 = m[mpos+ 4] & 0xff | (m[mpos+ 5] & 0xff) << 8; h2 += ((t1 >>> 10) | (t2 << 6)) & 0x1fff;\n t3 = m[mpos+ 6] & 0xff | (m[mpos+ 7] & 0xff) << 8; h3 += ((t2 >>> 7) | (t3 << 9)) & 0x1fff;\n t4 = m[mpos+ 8] & 0xff | (m[mpos+ 9] & 0xff) << 8; h4 += ((t3 >>> 4) | (t4 << 12)) & 0x1fff;\n h5 += ((t4 >>> 1)) & 0x1fff;\n t5 = m[mpos+10] & 0xff | (m[mpos+11] & 0xff) << 8; h6 += ((t4 >>> 14) | (t5 << 2)) & 0x1fff;\n t6 = m[mpos+12] & 0xff | (m[mpos+13] & 0xff) << 8; h7 += ((t5 >>> 11) | (t6 << 5)) & 0x1fff;\n t7 = m[mpos+14] & 0xff | (m[mpos+15] & 0xff) << 8; h8 += ((t6 >>> 8) | (t7 << 8)) & 0x1fff;\n h9 += ((t7 >>> 5)) | hibit;\n\n c = 0;\n\n d0 = c;\n d0 += h0 * r0;\n d0 += h1 * (5 * r9);\n d0 += h2 * (5 * r8);\n d0 += h3 * (5 * r7);\n d0 += h4 * (5 * r6);\n c = (d0 >>> 13); d0 &= 0x1fff;\n d0 += h5 * (5 * r5);\n d0 += h6 * (5 * r4);\n d0 += h7 * (5 * r3);\n d0 += h8 * (5 * r2);\n d0 += h9 * (5 * r1);\n c += (d0 >>> 13); d0 &= 0x1fff;\n\n d1 = c;\n d1 += h0 * r1;\n d1 += h1 * r0;\n d1 += h2 * (5 * r9);\n d1 += h3 * (5 * r8);\n d1 += h4 * (5 * r7);\n c = (d1 >>> 13); d1 &= 0x1fff;\n d1 += h5 * (5 * r6);\n d1 += h6 * (5 * r5);\n d1 += h7 * (5 * r4);\n d1 += h8 * (5 * r3);\n d1 += h9 * (5 * r2);\n c += (d1 >>> 13); d1 &= 0x1fff;\n\n d2 = c;\n d2 += h0 * r2;\n d2 += h1 * r1;\n d2 += h2 * r0;\n d2 += h3 * (5 * r9);\n d2 += h4 * (5 * r8);\n c = (d2 >>> 13); d2 &= 0x1fff;\n d2 += h5 * (5 * r7);\n d2 += h6 * (5 * r6);\n d2 += h7 * (5 * r5);\n d2 += h8 * (5 * r4);\n d2 += h9 * (5 * r3);\n c += (d2 >>> 13); d2 &= 0x1fff;\n\n d3 = c;\n d3 += h0 * r3;\n d3 += h1 * r2;\n d3 += h2 * r1;\n d3 += h3 * r0;\n d3 += h4 * (5 * r9);\n c = (d3 >>> 13); d3 &= 0x1fff;\n d3 += h5 * (5 * r8);\n d3 += h6 * (5 * r7);\n d3 += h7 * (5 * r6);\n d3 += h8 * (5 * r5);\n d3 += h9 * (5 * r4);\n c += (d3 >>> 13); d3 &= 0x1fff;\n\n d4 = c;\n d4 += h0 * r4;\n d4 += h1 * r3;\n d4 += h2 * r2;\n d4 += h3 * r1;\n d4 += h4 * r0;\n c = (d4 >>> 13); d4 &= 0x1fff;\n d4 += h5 * (5 * r9);\n d4 += h6 * (5 * r8);\n d4 += h7 * (5 * r7);\n d4 += h8 * (5 * r6);\n d4 += h9 * (5 * r5);\n c += (d4 >>> 13); d4 &= 0x1fff;\n\n d5 = c;\n d5 += h0 * r5;\n d5 += h1 * r4;\n d5 += h2 * r3;\n d5 += h3 * r2;\n d5 += h4 * r1;\n c = (d5 >>> 13); d5 &= 0x1fff;\n d5 += h5 * r0;\n d5 += h6 * (5 * r9);\n d5 += h7 * (5 * r8);\n d5 += h8 * (5 * r7);\n d5 += h9 * (5 * r6);\n c += (d5 >>> 13); d5 &= 0x1fff;\n\n d6 = c;\n d6 += h0 * r6;\n d6 += h1 * r5;\n d6 += h2 * r4;\n d6 += h3 * r3;\n d6 += h4 * r2;\n c = (d6 >>> 13); d6 &= 0x1fff;\n d6 += h5 * r1;\n d6 += h6 * r0;\n d6 += h7 * (5 * r9);\n d6 += h8 * (5 * r8);\n d6 += h9 * (5 * r7);\n c += (d6 >>> 13); d6 &= 0x1fff;\n\n d7 = c;\n d7 += h0 * r7;\n d7 += h1 * r6;\n d7 += h2 * r5;\n d7 += h3 * r4;\n d7 += h4 * r3;\n c = (d7 >>> 13); d7 &= 0x1fff;\n d7 += h5 * r2;\n d7 += h6 * r1;\n d7 += h7 * r0;\n d7 += h8 * (5 * r9);\n d7 += h9 * (5 * r8);\n c += (d7 >>> 13); d7 &= 0x1fff;\n\n d8 = c;\n d8 += h0 * r8;\n d8 += h1 * r7;\n d8 += h2 * r6;\n d8 += h3 * r5;\n d8 += h4 * r4;\n c = (d8 >>> 13); d8 &= 0x1fff;\n d8 += h5 * r3;\n d8 += h6 * r2;\n d8 += h7 * r1;\n d8 += h8 * r0;\n d8 += h9 * (5 * r9);\n c += (d8 >>> 13); d8 &= 0x1fff;\n\n d9 = c;\n d9 += h0 * r9;\n d9 += h1 * r8;\n d9 += h2 * r7;\n d9 += h3 * r6;\n d9 += h4 * r5;\n c = (d9 >>> 13); d9 &= 0x1fff;\n d9 += h5 * r4;\n d9 += h6 * r3;\n d9 += h7 * r2;\n d9 += h8 * r1;\n d9 += h9 * r0;\n c += (d9 >>> 13); d9 &= 0x1fff;\n\n c = (((c << 2) + c)) | 0;\n c = (c + d0) | 0;\n d0 = c & 0x1fff;\n c = (c >>> 13);\n d1 += c;\n\n h0 = d0;\n h1 = d1;\n h2 = d2;\n h3 = d3;\n h4 = d4;\n h5 = d5;\n h6 = d6;\n h7 = d7;\n h8 = d8;\n h9 = d9;\n\n mpos += 16;\n bytes -= 16;\n }\n this.h[0] = h0;\n this.h[1] = h1;\n this.h[2] = h2;\n this.h[3] = h3;\n this.h[4] = h4;\n this.h[5] = h5;\n this.h[6] = h6;\n this.h[7] = h7;\n this.h[8] = h8;\n this.h[9] = h9;\n};\n\npoly1305.prototype.finish = function(mac, macpos) {\n var g = new Uint16Array(10);\n var c, mask, f, i;\n\n if (this.leftover) {\n i = this.leftover;\n this.buffer[i++] = 1;\n for (; i < 16; i++) this.buffer[i] = 0;\n this.fin = 1;\n this.blocks(this.buffer, 0, 16);\n }\n\n c = this.h[1] >>> 13;\n this.h[1] &= 0x1fff;\n for (i = 2; i < 10; i++) {\n this.h[i] += c;\n c = this.h[i] >>> 13;\n this.h[i] &= 0x1fff;\n }\n this.h[0] += (c * 5);\n c = this.h[0] >>> 13;\n this.h[0] &= 0x1fff;\n this.h[1] += c;\n c = this.h[1] >>> 13;\n this.h[1] &= 0x1fff;\n this.h[2] += c;\n\n g[0] = this.h[0] + 5;\n c = g[0] >>> 13;\n g[0] &= 0x1fff;\n for (i = 1; i < 10; i++) {\n g[i] = this.h[i] + c;\n c = g[i] >>> 13;\n g[i] &= 0x1fff;\n }\n g[9] -= (1 << 13);\n\n mask = (c ^ 1) - 1;\n for (i = 0; i < 10; i++) g[i] &= mask;\n mask = ~mask;\n for (i = 0; i < 10; i++) this.h[i] = (this.h[i] & mask) | g[i];\n\n this.h[0] = ((this.h[0] ) | (this.h[1] << 13) ) & 0xffff;\n this.h[1] = ((this.h[1] >>> 3) | (this.h[2] << 10) ) & 0xffff;\n this.h[2] = ((this.h[2] >>> 6) | (this.h[3] << 7) ) & 0xffff;\n this.h[3] = ((this.h[3] >>> 9) | (this.h[4] << 4) ) & 0xffff;\n this.h[4] = ((this.h[4] >>> 12) | (this.h[5] << 1) | (this.h[6] << 14)) & 0xffff;\n this.h[5] = ((this.h[6] >>> 2) | (this.h[7] << 11) ) & 0xffff;\n this.h[6] = ((this.h[7] >>> 5) | (this.h[8] << 8) ) & 0xffff;\n this.h[7] = ((this.h[8] >>> 8) | (this.h[9] << 5) ) & 0xffff;\n\n f = this.h[0] + this.pad[0];\n this.h[0] = f & 0xffff;\n for (i = 1; i < 8; i++) {\n f = (((this.h[i] + this.pad[i]) | 0) + (f >>> 16)) | 0;\n this.h[i] = f & 0xffff;\n }\n\n mac[macpos+ 0] = (this.h[0] >>> 0) & 0xff;\n mac[macpos+ 1] = (this.h[0] >>> 8) & 0xff;\n mac[macpos+ 2] = (this.h[1] >>> 0) & 0xff;\n mac[macpos+ 3] = (this.h[1] >>> 8) & 0xff;\n mac[macpos+ 4] = (this.h[2] >>> 0) & 0xff;\n mac[macpos+ 5] = (this.h[2] >>> 8) & 0xff;\n mac[macpos+ 6] = (this.h[3] >>> 0) & 0xff;\n mac[macpos+ 7] = (this.h[3] >>> 8) & 0xff;\n mac[macpos+ 8] = (this.h[4] >>> 0) & 0xff;\n mac[macpos+ 9] = (this.h[4] >>> 8) & 0xff;\n mac[macpos+10] = (this.h[5] >>> 0) & 0xff;\n mac[macpos+11] = (this.h[5] >>> 8) & 0xff;\n mac[macpos+12] = (this.h[6] >>> 0) & 0xff;\n mac[macpos+13] = (this.h[6] >>> 8) & 0xff;\n mac[macpos+14] = (this.h[7] >>> 0) & 0xff;\n mac[macpos+15] = (this.h[7] >>> 8) & 0xff;\n};\n\npoly1305.prototype.update = function(m, mpos, bytes) {\n var i, want;\n\n if (this.leftover) {\n want = (16 - this.leftover);\n if (want > bytes)\n want = bytes;\n for (i = 0; i < want; i++)\n this.buffer[this.leftover + i] = m[mpos+i];\n bytes -= want;\n mpos += want;\n this.leftover += want;\n if (this.leftover < 16)\n return;\n this.blocks(this.buffer, 0, 16);\n this.leftover = 0;\n }\n\n if (bytes >= 16) {\n want = bytes - (bytes % 16);\n this.blocks(m, mpos, want);\n mpos += want;\n bytes -= want;\n }\n\n if (bytes) {\n for (i = 0; i < bytes; i++)\n this.buffer[this.leftover + i] = m[mpos+i];\n this.leftover += bytes;\n }\n};\n\nfunction crypto_onetimeauth(out, outpos, m, mpos, n, k) {\n var s = new poly1305(k);\n s.update(m, mpos, n);\n s.finish(out, outpos);\n return 0;\n}\n\nfunction crypto_onetimeauth_verify(h, hpos, m, mpos, n, k) {\n var x = new Uint8Array(16);\n crypto_onetimeauth(x,0,m,mpos,n,k);\n return crypto_verify_16(h,hpos,x,0);\n}\n\nfunction crypto_secretbox(c,m,d,n,k) {\n var i;\n if (d < 32) return -1;\n crypto_stream_xor(c,0,m,0,d,n,k);\n crypto_onetimeauth(c, 16, c, 32, d - 32, c);\n for (i = 0; i < 16; i++) c[i] = 0;\n return 0;\n}\n\nfunction crypto_secretbox_open(m,c,d,n,k) {\n var i;\n var x = new Uint8Array(32);\n if (d < 32) return -1;\n crypto_stream(x,0,32,n,k);\n if (crypto_onetimeauth_verify(c, 16,c, 32,d - 32,x) !== 0) return -1;\n crypto_stream_xor(m,0,c,0,d,n,k);\n for (i = 0; i < 32; i++) m[i] = 0;\n return 0;\n}\n\nfunction set25519(r, a) {\n var i;\n for (i = 0; i < 16; i++) r[i] = a[i]|0;\n}\n\nfunction car25519(o) {\n var i, v, c = 1;\n for (i = 0; i < 16; i++) {\n v = o[i] + c + 65535;\n c = Math.floor(v / 65536);\n o[i] = v - c * 65536;\n }\n o[0] += c-1 + 37 * (c-1);\n}\n\nfunction sel25519(p, q, b) {\n var t, c = ~(b-1);\n for (var i = 0; i < 16; i++) {\n t = c & (p[i] ^ q[i]);\n p[i] ^= t;\n q[i] ^= t;\n }\n}\n\nfunction pack25519(o, n) {\n var i, j, b;\n var m = gf(), t = gf();\n for (i = 0; i < 16; i++) t[i] = n[i];\n car25519(t);\n car25519(t);\n car25519(t);\n for (j = 0; j < 2; j++) {\n m[0] = t[0] - 0xffed;\n for (i = 1; i < 15; i++) {\n m[i] = t[i] - 0xffff - ((m[i-1]>>16) & 1);\n m[i-1] &= 0xffff;\n }\n m[15] = t[15] - 0x7fff - ((m[14]>>16) & 1);\n b = (m[15]>>16) & 1;\n m[14] &= 0xffff;\n sel25519(t, m, 1-b);\n }\n for (i = 0; i < 16; i++) {\n o[2*i] = t[i] & 0xff;\n o[2*i+1] = t[i]>>8;\n }\n}\n\nfunction neq25519(a, b) {\n var c = new Uint8Array(32), d = new Uint8Array(32);\n pack25519(c, a);\n pack25519(d, b);\n return crypto_verify_32(c, 0, d, 0);\n}\n\nfunction par25519(a) {\n var d = new Uint8Array(32);\n pack25519(d, a);\n return d[0] & 1;\n}\n\nfunction unpack25519(o, n) {\n var i;\n for (i = 0; i < 16; i++) o[i] = n[2*i] + (n[2*i+1] << 8);\n o[15] &= 0x7fff;\n}\n\nfunction A(o, a, b) {\n for (var i = 0; i < 16; i++) o[i] = a[i] + b[i];\n}\n\nfunction Z(o, a, b) {\n for (var i = 0; i < 16; i++) o[i] = a[i] - b[i];\n}\n\nfunction M(o, a, b) {\n var v, c,\n t0 = 0, t1 = 0, t2 = 0, t3 = 0, t4 = 0, t5 = 0, t6 = 0, t7 = 0,\n t8 = 0, t9 = 0, t10 = 0, t11 = 0, t12 = 0, t13 = 0, t14 = 0, t15 = 0,\n t16 = 0, t17 = 0, t18 = 0, t19 = 0, t20 = 0, t21 = 0, t22 = 0, t23 = 0,\n t24 = 0, t25 = 0, t26 = 0, t27 = 0, t28 = 0, t29 = 0, t30 = 0,\n b0 = b[0],\n b1 = b[1],\n b2 = b[2],\n b3 = b[3],\n b4 = b[4],\n b5 = b[5],\n b6 = b[6],\n b7 = b[7],\n b8 = b[8],\n b9 = b[9],\n b10 = b[10],\n b11 = b[11],\n b12 = b[12],\n b13 = b[13],\n b14 = b[14],\n b15 = b[15];\n\n v = a[0];\n t0 += v * b0;\n t1 += v * b1;\n t2 += v * b2;\n t3 += v * b3;\n t4 += v * b4;\n t5 += v * b5;\n t6 += v * b6;\n t7 += v * b7;\n t8 += v * b8;\n t9 += v * b9;\n t10 += v * b10;\n t11 += v * b11;\n t12 += v * b12;\n t13 += v * b13;\n t14 += v * b14;\n t15 += v * b15;\n v = a[1];\n t1 += v * b0;\n t2 += v * b1;\n t3 += v * b2;\n t4 += v * b3;\n t5 += v * b4;\n t6 += v * b5;\n t7 += v * b6;\n t8 += v * b7;\n t9 += v * b8;\n t10 += v * b9;\n t11 += v * b10;\n t12 += v * b11;\n t13 += v * b12;\n t14 += v * b13;\n t15 += v * b14;\n t16 += v * b15;\n v = a[2];\n t2 += v * b0;\n t3 += v * b1;\n t4 += v * b2;\n t5 += v * b3;\n t6 += v * b4;\n t7 += v * b5;\n t8 += v * b6;\n t9 += v * b7;\n t10 += v * b8;\n t11 += v * b9;\n t12 += v * b10;\n t13 += v * b11;\n t14 += v * b12;\n t15 += v * b13;\n t16 += v * b14;\n t17 += v * b15;\n v = a[3];\n t3 += v * b0;\n t4 += v * b1;\n t5 += v * b2;\n t6 += v * b3;\n t7 += v * b4;\n t8 += v * b5;\n t9 += v * b6;\n t10 += v * b7;\n t11 += v * b8;\n t12 += v * b9;\n t13 += v * b10;\n t14 += v * b11;\n t15 += v * b12;\n t16 += v * b13;\n t17 += v * b14;\n t18 += v * b15;\n v = a[4];\n t4 += v * b0;\n t5 += v * b1;\n t6 += v * b2;\n t7 += v * b3;\n t8 += v * b4;\n t9 += v * b5;\n t10 += v * b6;\n t11 += v * b7;\n t12 += v * b8;\n t13 += v * b9;\n t14 += v * b10;\n t15 += v * b11;\n t16 += v * b12;\n t17 += v * b13;\n t18 += v * b14;\n t19 += v * b15;\n v = a[5];\n t5 += v * b0;\n t6 += v * b1;\n t7 += v * b2;\n t8 += v * b3;\n t9 += v * b4;\n t10 += v * b5;\n t11 += v * b6;\n t12 += v * b7;\n t13 += v * b8;\n t14 += v * b9;\n t15 += v * b10;\n t16 += v * b11;\n t17 += v * b12;\n t18 += v * b13;\n t19 += v * b14;\n t20 += v * b15;\n v = a[6];\n t6 += v * b0;\n t7 += v * b1;\n t8 += v * b2;\n t9 += v * b3;\n t10 += v * b4;\n t11 += v * b5;\n t12 += v * b6;\n t13 += v * b7;\n t14 += v * b8;\n t15 += v * b9;\n t16 += v * b10;\n t17 += v * b11;\n t18 += v * b12;\n t19 += v * b13;\n t20 += v * b14;\n t21 += v * b15;\n v = a[7];\n t7 += v * b0;\n t8 += v * b1;\n t9 += v * b2;\n t10 += v * b3;\n t11 += v * b4;\n t12 += v * b5;\n t13 += v * b6;\n t14 += v * b7;\n t15 += v * b8;\n t16 += v * b9;\n t17 += v * b10;\n t18 += v * b11;\n t19 += v * b12;\n t20 += v * b13;\n t21 += v * b14;\n t22 += v * b15;\n v = a[8];\n t8 += v * b0;\n t9 += v * b1;\n t10 += v * b2;\n t11 += v * b3;\n t12 += v * b4;\n t13 += v * b5;\n t14 += v * b6;\n t15 += v * b7;\n t16 += v * b8;\n t17 += v * b9;\n t18 += v * b10;\n t19 += v * b11;\n t20 += v * b12;\n t21 += v * b13;\n t22 += v * b14;\n t23 += v * b15;\n v = a[9];\n t9 += v * b0;\n t10 += v * b1;\n t11 += v * b2;\n t12 += v * b3;\n t13 += v * b4;\n t14 += v * b5;\n t15 += v * b6;\n t16 += v * b7;\n t17 += v * b8;\n t18 += v * b9;\n t19 += v * b10;\n t20 += v * b11;\n t21 += v * b12;\n t22 += v * b13;\n t23 += v * b14;\n t24 += v * b15;\n v = a[10];\n t10 += v * b0;\n t11 += v * b1;\n t12 += v * b2;\n t13 += v * b3;\n t14 += v * b4;\n t15 += v * b5;\n t16 += v * b6;\n t17 += v * b7;\n t18 += v * b8;\n t19 += v * b9;\n t20 += v * b10;\n t21 += v * b11;\n t22 += v * b12;\n t23 += v * b13;\n t24 += v * b14;\n t25 += v * b15;\n v = a[11];\n t11 += v * b0;\n t12 += v * b1;\n t13 += v * b2;\n t14 += v * b3;\n t15 += v * b4;\n t16 += v * b5;\n t17 += v * b6;\n t18 += v * b7;\n t19 += v * b8;\n t20 += v * b9;\n t21 += v * b10;\n t22 += v * b11;\n t23 += v * b12;\n t24 += v * b13;\n t25 += v * b14;\n t26 += v * b15;\n v = a[12];\n t12 += v * b0;\n t13 += v * b1;\n t14 += v * b2;\n t15 += v * b3;\n t16 += v * b4;\n t17 += v * b5;\n t18 += v * b6;\n t19 += v * b7;\n t20 += v * b8;\n t21 += v * b9;\n t22 += v * b10;\n t23 += v * b11;\n t24 += v * b12;\n t25 += v * b13;\n t26 += v * b14;\n t27 += v * b15;\n v = a[13];\n t13 += v * b0;\n t14 += v * b1;\n t15 += v * b2;\n t16 += v * b3;\n t17 += v * b4;\n t18 += v * b5;\n t19 += v * b6;\n t20 += v * b7;\n t21 += v * b8;\n t22 += v * b9;\n t23 += v * b10;\n t24 += v * b11;\n t25 += v * b12;\n t26 += v * b13;\n t27 += v * b14;\n t28 += v * b15;\n v = a[14];\n t14 += v * b0;\n t15 += v * b1;\n t16 += v * b2;\n t17 += v * b3;\n t18 += v * b4;\n t19 += v * b5;\n t20 += v * b6;\n t21 += v * b7;\n t22 += v * b8;\n t23 += v * b9;\n t24 += v * b10;\n t25 += v * b11;\n t26 += v * b12;\n t27 += v * b13;\n t28 += v * b14;\n t29 += v * b15;\n v = a[15];\n t15 += v * b0;\n t16 += v * b1;\n t17 += v * b2;\n t18 += v * b3;\n t19 += v * b4;\n t20 += v * b5;\n t21 += v * b6;\n t22 += v * b7;\n t23 += v * b8;\n t24 += v * b9;\n t25 += v * b10;\n t26 += v * b11;\n t27 += v * b12;\n t28 += v * b13;\n t29 += v * b14;\n t30 += v * b15;\n\n t0 += 38 * t16;\n t1 += 38 * t17;\n t2 += 38 * t18;\n t3 += 38 * t19;\n t4 += 38 * t20;\n t5 += 38 * t21;\n t6 += 38 * t22;\n t7 += 38 * t23;\n t8 += 38 * t24;\n t9 += 38 * t25;\n t10 += 38 * t26;\n t11 += 38 * t27;\n t12 += 38 * t28;\n t13 += 38 * t29;\n t14 += 38 * t30;\n // t15 left as is\n\n // first car\n c = 1;\n v = t0 + c + 65535; c = Math.floor(v / 65536); t0 = v - c * 65536;\n v = t1 + c + 65535; c = Math.floor(v / 65536); t1 = v - c * 65536;\n v = t2 + c + 65535; c = Math.floor(v / 65536); t2 = v - c * 65536;\n v = t3 + c + 65535; c = Math.floor(v / 65536); t3 = v - c * 65536;\n v = t4 + c + 65535; c = Math.floor(v / 65536); t4 = v - c * 65536;\n v = t5 + c + 65535; c = Math.floor(v / 65536); t5 = v - c * 65536;\n v = t6 + c + 65535; c = Math.floor(v / 65536); t6 = v - c * 65536;\n v = t7 + c + 65535; c = Math.floor(v / 65536); t7 = v - c * 65536;\n v = t8 + c + 65535; c = Math.floor(v / 65536); t8 = v - c * 65536;\n v = t9 + c + 65535; c = Math.floor(v / 65536); t9 = v - c * 65536;\n v = t10 + c + 65535; c = Math.floor(v / 65536); t10 = v - c * 65536;\n v = t11 + c + 65535; c = Math.floor(v / 65536); t11 = v - c * 65536;\n v = t12 + c + 65535; c = Math.floor(v / 65536); t12 = v - c * 65536;\n v = t13 + c + 65535; c = Math.floor(v / 65536); t13 = v - c * 65536;\n v = t14 + c + 65535; c = Math.floor(v / 65536); t14 = v - c * 65536;\n v = t15 + c + 65535; c = Math.floor(v / 65536); t15 = v - c * 65536;\n t0 += c-1 + 37 * (c-1);\n\n // second car\n c = 1;\n v = t0 + c + 65535; c = Math.floor(v / 65536); t0 = v - c * 65536;\n v = t1 + c + 65535; c = Math.floor(v / 65536); t1 = v - c * 65536;\n v = t2 + c + 65535; c = Math.floor(v / 65536); t2 = v - c * 65536;\n v = t3 + c + 65535; c = Math.floor(v / 65536); t3 = v - c * 65536;\n v = t4 + c + 65535; c = Math.floor(v / 65536); t4 = v - c * 65536;\n v = t5 + c + 65535; c = Math.floor(v / 65536); t5 = v - c * 65536;\n v = t6 + c + 65535; c = Math.floor(v / 65536); t6 = v - c * 65536;\n v = t7 + c + 65535; c = Math.floor(v / 65536); t7 = v - c * 65536;\n v = t8 + c + 65535; c = Math.floor(v / 65536); t8 = v - c * 65536;\n v = t9 + c + 65535; c = Math.floor(v / 65536); t9 = v - c * 65536;\n v = t10 + c + 65535; c = Math.floor(v / 65536); t10 = v - c * 65536;\n v = t11 + c + 65535; c = Math.floor(v / 65536); t11 = v - c * 65536;\n v = t12 + c + 65535; c = Math.floor(v / 65536); t12 = v - c * 65536;\n v = t13 + c + 65535; c = Math.floor(v / 65536); t13 = v - c * 65536;\n v = t14 + c + 65535; c = Math.floor(v / 65536); t14 = v - c * 65536;\n v = t15 + c + 65535; c = Math.floor(v / 65536); t15 = v - c * 65536;\n t0 += c-1 + 37 * (c-1);\n\n o[ 0] = t0;\n o[ 1] = t1;\n o[ 2] = t2;\n o[ 3] = t3;\n o[ 4] = t4;\n o[ 5] = t5;\n o[ 6] = t6;\n o[ 7] = t7;\n o[ 8] = t8;\n o[ 9] = t9;\n o[10] = t10;\n o[11] = t11;\n o[12] = t12;\n o[13] = t13;\n o[14] = t14;\n o[15] = t15;\n}\n\nfunction S(o, a) {\n M(o, a, a);\n}\n\nfunction inv25519(o, i) {\n var c = gf();\n var a;\n for (a = 0; a < 16; a++) c[a] = i[a];\n for (a = 253; a >= 0; a--) {\n S(c, c);\n if(a !== 2 && a !== 4) M(c, c, i);\n }\n for (a = 0; a < 16; a++) o[a] = c[a];\n}\n\nfunction pow2523(o, i) {\n var c = gf();\n var a;\n for (a = 0; a < 16; a++) c[a] = i[a];\n for (a = 250; a >= 0; a--) {\n S(c, c);\n if(a !== 1) M(c, c, i);\n }\n for (a = 0; a < 16; a++) o[a] = c[a];\n}\n\nfunction crypto_scalarmult(q, n, p) {\n var z = new Uint8Array(32);\n var x = new Float64Array(80), r, i;\n var a = gf(), b = gf(), c = gf(),\n d = gf(), e = gf(), f = gf();\n for (i = 0; i < 31; i++) z[i] = n[i];\n z[31]=(n[31]&127)|64;\n z[0]&=248;\n unpack25519(x,p);\n for (i = 0; i < 16; i++) {\n b[i]=x[i];\n d[i]=a[i]=c[i]=0;\n }\n a[0]=d[0]=1;\n for (i=254; i>=0; --i) {\n r=(z[i>>>3]>>>(i&7))&1;\n sel25519(a,b,r);\n sel25519(c,d,r);\n A(e,a,c);\n Z(a,a,c);\n A(c,b,d);\n Z(b,b,d);\n S(d,e);\n S(f,a);\n M(a,c,a);\n M(c,b,e);\n A(e,a,c);\n Z(a,a,c);\n S(b,a);\n Z(c,d,f);\n M(a,c,_121665);\n A(a,a,d);\n M(c,c,a);\n M(a,d,f);\n M(d,b,x);\n S(b,e);\n sel25519(a,b,r);\n sel25519(c,d,r);\n }\n for (i = 0; i < 16; i++) {\n x[i+16]=a[i];\n x[i+32]=c[i];\n x[i+48]=b[i];\n x[i+64]=d[i];\n }\n var x32 = x.subarray(32);\n var x16 = x.subarray(16);\n inv25519(x32,x32);\n M(x16,x16,x32);\n pack25519(q,x16);\n return 0;\n}\n\nfunction crypto_scalarmult_base(q, n) {\n return crypto_scalarmult(q, n, _9);\n}\n\nfunction crypto_box_keypair(y, x) {\n randombytes(x, 32);\n return crypto_scalarmult_base(y, x);\n}\n\nfunction crypto_box_beforenm(k, y, x) {\n var s = new Uint8Array(32);\n crypto_scalarmult(s, x, y);\n return crypto_core_hsalsa20(k, _0, s, sigma);\n}\n\nvar crypto_box_afternm = crypto_secretbox;\nvar crypto_box_open_afternm = crypto_secretbox_open;\n\nfunction crypto_box(c, m, d, n, y, x) {\n var k = new Uint8Array(32);\n crypto_box_beforenm(k, y, x);\n return crypto_box_afternm(c, m, d, n, k);\n}\n\nfunction crypto_box_open(m, c, d, n, y, x) {\n var k = new Uint8Array(32);\n crypto_box_beforenm(k, y, x);\n return crypto_box_open_afternm(m, c, d, n, k);\n}\n\nvar K = [\n 0x428a2f98, 0xd728ae22, 0x71374491, 0x23ef65cd,\n 0xb5c0fbcf, 0xec4d3b2f, 0xe9b5dba5, 0x8189dbbc,\n 0x3956c25b, 0xf348b538, 0x59f111f1, 0xb605d019,\n 0x923f82a4, 0xaf194f9b, 0xab1c5ed5, 0xda6d8118,\n 0xd807aa98, 0xa3030242, 0x12835b01, 0x45706fbe,\n 0x243185be, 0x4ee4b28c, 0x550c7dc3, 0xd5ffb4e2,\n 0x72be5d74, 0xf27b896f, 0x80deb1fe, 0x3b1696b1,\n 0x9bdc06a7, 0x25c71235, 0xc19bf174, 0xcf692694,\n 0xe49b69c1, 0x9ef14ad2, 0xefbe4786, 0x384f25e3,\n 0x0fc19dc6, 0x8b8cd5b5, 0x240ca1cc, 0x77ac9c65,\n 0x2de92c6f, 0x592b0275, 0x4a7484aa, 0x6ea6e483,\n 0x5cb0a9dc, 0xbd41fbd4, 0x76f988da, 0x831153b5,\n 0x983e5152, 0xee66dfab, 0xa831c66d, 0x2db43210,\n 0xb00327c8, 0x98fb213f, 0xbf597fc7, 0xbeef0ee4,\n 0xc6e00bf3, 0x3da88fc2, 0xd5a79147, 0x930aa725,\n 0x06ca6351, 0xe003826f, 0x14292967, 0x0a0e6e70,\n 0x27b70a85, 0x46d22ffc, 0x2e1b2138, 0x5c26c926,\n 0x4d2c6dfc, 0x5ac42aed, 0x53380d13, 0x9d95b3df,\n 0x650a7354, 0x8baf63de, 0x766a0abb, 0x3c77b2a8,\n 0x81c2c92e, 0x47edaee6, 0x92722c85, 0x1482353b,\n 0xa2bfe8a1, 0x4cf10364, 0xa81a664b, 0xbc423001,\n 0xc24b8b70, 0xd0f89791, 0xc76c51a3, 0x0654be30,\n 0xd192e819, 0xd6ef5218, 0xd6990624, 0x5565a910,\n 0xf40e3585, 0x5771202a, 0x106aa070, 0x32bbd1b8,\n 0x19a4c116, 0xb8d2d0c8, 0x1e376c08, 0x5141ab53,\n 0x2748774c, 0xdf8eeb99, 0x34b0bcb5, 0xe19b48a8,\n 0x391c0cb3, 0xc5c95a63, 0x4ed8aa4a, 0xe3418acb,\n 0x5b9cca4f, 0x7763e373, 0x682e6ff3, 0xd6b2b8a3,\n 0x748f82ee, 0x5defb2fc, 0x78a5636f, 0x43172f60,\n 0x84c87814, 0xa1f0ab72, 0x8cc70208, 0x1a6439ec,\n 0x90befffa, 0x23631e28, 0xa4506ceb, 0xde82bde9,\n 0xbef9a3f7, 0xb2c67915, 0xc67178f2, 0xe372532b,\n 0xca273ece, 0xea26619c, 0xd186b8c7, 0x21c0c207,\n 0xeada7dd6, 0xcde0eb1e, 0xf57d4f7f, 0xee6ed178,\n 0x06f067aa, 0x72176fba, 0x0a637dc5, 0xa2c898a6,\n 0x113f9804, 0xbef90dae, 0x1b710b35, 0x131c471b,\n 0x28db77f5, 0x23047d84, 0x32caab7b, 0x40c72493,\n 0x3c9ebe0a, 0x15c9bebc, 0x431d67c4, 0x9c100d4c,\n 0x4cc5d4be, 0xcb3e42b6, 0x597f299c, 0xfc657e2a,\n 0x5fcb6fab, 0x3ad6faec, 0x6c44198c, 0x4a475817\n];\n\nfunction crypto_hashblocks_hl(hh, hl, m, n) {\n var wh = new Int32Array(16), wl = new Int32Array(16),\n bh0, bh1, bh2, bh3, bh4, bh5, bh6, bh7,\n bl0, bl1, bl2, bl3, bl4, bl5, bl6, bl7,\n th, tl, i, j, h, l, a, b, c, d;\n\n var ah0 = hh[0],\n ah1 = hh[1],\n ah2 = hh[2],\n ah3 = hh[3],\n ah4 = hh[4],\n ah5 = hh[5],\n ah6 = hh[6],\n ah7 = hh[7],\n\n al0 = hl[0],\n al1 = hl[1],\n al2 = hl[2],\n al3 = hl[3],\n al4 = hl[4],\n al5 = hl[5],\n al6 = hl[6],\n al7 = hl[7];\n\n var pos = 0;\n while (n >= 128) {\n for (i = 0; i < 16; i++) {\n j = 8 * i + pos;\n wh[i] = (m[j+0] << 24) | (m[j+1] << 16) | (m[j+2] << 8) | m[j+3];\n wl[i] = (m[j+4] << 24) | (m[j+5] << 16) | (m[j+6] << 8) | m[j+7];\n }\n for (i = 0; i < 80; i++) {\n bh0 = ah0;\n bh1 = ah1;\n bh2 = ah2;\n bh3 = ah3;\n bh4 = ah4;\n bh5 = ah5;\n bh6 = ah6;\n bh7 = ah7;\n\n bl0 = al0;\n bl1 = al1;\n bl2 = al2;\n bl3 = al3;\n bl4 = al4;\n bl5 = al5;\n bl6 = al6;\n bl7 = al7;\n\n // add\n h = ah7;\n l = al7;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n // Sigma1\n h = ((ah4 >>> 14) | (al4 << (32-14))) ^ ((ah4 >>> 18) | (al4 << (32-18))) ^ ((al4 >>> (41-32)) | (ah4 << (32-(41-32))));\n l = ((al4 >>> 14) | (ah4 << (32-14))) ^ ((al4 >>> 18) | (ah4 << (32-18))) ^ ((ah4 >>> (41-32)) | (al4 << (32-(41-32))));\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // Ch\n h = (ah4 & ah5) ^ (~ah4 & ah6);\n l = (al4 & al5) ^ (~al4 & al6);\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // K\n h = K[i*2];\n l = K[i*2+1];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // w\n h = wh[i%16];\n l = wl[i%16];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n th = c & 0xffff | d << 16;\n tl = a & 0xffff | b << 16;\n\n // add\n h = th;\n l = tl;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n // Sigma0\n h = ((ah0 >>> 28) | (al0 << (32-28))) ^ ((al0 >>> (34-32)) | (ah0 << (32-(34-32)))) ^ ((al0 >>> (39-32)) | (ah0 << (32-(39-32))));\n l = ((al0 >>> 28) | (ah0 << (32-28))) ^ ((ah0 >>> (34-32)) | (al0 << (32-(34-32)))) ^ ((ah0 >>> (39-32)) | (al0 << (32-(39-32))));\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // Maj\n h = (ah0 & ah1) ^ (ah0 & ah2) ^ (ah1 & ah2);\n l = (al0 & al1) ^ (al0 & al2) ^ (al1 & al2);\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n bh7 = (c & 0xffff) | (d << 16);\n bl7 = (a & 0xffff) | (b << 16);\n\n // add\n h = bh3;\n l = bl3;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = th;\n l = tl;\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n bh3 = (c & 0xffff) | (d << 16);\n bl3 = (a & 0xffff) | (b << 16);\n\n ah1 = bh0;\n ah2 = bh1;\n ah3 = bh2;\n ah4 = bh3;\n ah5 = bh4;\n ah6 = bh5;\n ah7 = bh6;\n ah0 = bh7;\n\n al1 = bl0;\n al2 = bl1;\n al3 = bl2;\n al4 = bl3;\n al5 = bl4;\n al6 = bl5;\n al7 = bl6;\n al0 = bl7;\n\n if (i%16 === 15) {\n for (j = 0; j < 16; j++) {\n // add\n h = wh[j];\n l = wl[j];\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = wh[(j+9)%16];\n l = wl[(j+9)%16];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // sigma0\n th = wh[(j+1)%16];\n tl = wl[(j+1)%16];\n h = ((th >>> 1) | (tl << (32-1))) ^ ((th >>> 8) | (tl << (32-8))) ^ (th >>> 7);\n l = ((tl >>> 1) | (th << (32-1))) ^ ((tl >>> 8) | (th << (32-8))) ^ ((tl >>> 7) | (th << (32-7)));\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // sigma1\n th = wh[(j+14)%16];\n tl = wl[(j+14)%16];\n h = ((th >>> 19) | (tl << (32-19))) ^ ((tl >>> (61-32)) | (th << (32-(61-32)))) ^ (th >>> 6);\n l = ((tl >>> 19) | (th << (32-19))) ^ ((th >>> (61-32)) | (tl << (32-(61-32)))) ^ ((tl >>> 6) | (th << (32-6)));\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n wh[j] = (c & 0xffff) | (d << 16);\n wl[j] = (a & 0xffff) | (b << 16);\n }\n }\n }\n\n // add\n h = ah0;\n l = al0;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[0];\n l = hl[0];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[0] = ah0 = (c & 0xffff) | (d << 16);\n hl[0] = al0 = (a & 0xffff) | (b << 16);\n\n h = ah1;\n l = al1;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[1];\n l = hl[1];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[1] = ah1 = (c & 0xffff) | (d << 16);\n hl[1] = al1 = (a & 0xffff) | (b << 16);\n\n h = ah2;\n l = al2;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[2];\n l = hl[2];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[2] = ah2 = (c & 0xffff) | (d << 16);\n hl[2] = al2 = (a & 0xffff) | (b << 16);\n\n h = ah3;\n l = al3;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[3];\n l = hl[3];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[3] = ah3 = (c & 0xffff) | (d << 16);\n hl[3] = al3 = (a & 0xffff) | (b << 16);\n\n h = ah4;\n l = al4;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[4];\n l = hl[4];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[4] = ah4 = (c & 0xffff) | (d << 16);\n hl[4] = al4 = (a & 0xffff) | (b << 16);\n\n h = ah5;\n l = al5;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[5];\n l = hl[5];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[5] = ah5 = (c & 0xffff) | (d << 16);\n hl[5] = al5 = (a & 0xffff) | (b << 16);\n\n h = ah6;\n l = al6;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[6];\n l = hl[6];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[6] = ah6 = (c & 0xffff) | (d << 16);\n hl[6] = al6 = (a & 0xffff) | (b << 16);\n\n h = ah7;\n l = al7;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[7];\n l = hl[7];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[7] = ah7 = (c & 0xffff) | (d << 16);\n hl[7] = al7 = (a & 0xffff) | (b << 16);\n\n pos += 128;\n n -= 128;\n }\n\n return n;\n}\n\nfunction crypto_hash(out, m, n) {\n var hh = new Int32Array(8),\n hl = new Int32Array(8),\n x = new Uint8Array(256),\n i, b = n;\n\n hh[0] = 0x6a09e667;\n hh[1] = 0xbb67ae85;\n hh[2] = 0x3c6ef372;\n hh[3] = 0xa54ff53a;\n hh[4] = 0x510e527f;\n hh[5] = 0x9b05688c;\n hh[6] = 0x1f83d9ab;\n hh[7] = 0x5be0cd19;\n\n hl[0] = 0xf3bcc908;\n hl[1] = 0x84caa73b;\n hl[2] = 0xfe94f82b;\n hl[3] = 0x5f1d36f1;\n hl[4] = 0xade682d1;\n hl[5] = 0x2b3e6c1f;\n hl[6] = 0xfb41bd6b;\n hl[7] = 0x137e2179;\n\n crypto_hashblocks_hl(hh, hl, m, n);\n n %= 128;\n\n for (i = 0; i < n; i++) x[i] = m[b-n+i];\n x[n] = 128;\n\n n = 256-128*(n<112?1:0);\n x[n-9] = 0;\n ts64(x, n-8, (b / 0x20000000) | 0, b << 3);\n crypto_hashblocks_hl(hh, hl, x, n);\n\n for (i = 0; i < 8; i++) ts64(out, 8*i, hh[i], hl[i]);\n\n return 0;\n}\n\nfunction add(p, q) {\n var a = gf(), b = gf(), c = gf(),\n d = gf(), e = gf(), f = gf(),\n g = gf(), h = gf(), t = gf();\n\n Z(a, p[1], p[0]);\n Z(t, q[1], q[0]);\n M(a, a, t);\n A(b, p[0], p[1]);\n A(t, q[0], q[1]);\n M(b, b, t);\n M(c, p[3], q[3]);\n M(c, c, D2);\n M(d, p[2], q[2]);\n A(d, d, d);\n Z(e, b, a);\n Z(f, d, c);\n A(g, d, c);\n A(h, b, a);\n\n M(p[0], e, f);\n M(p[1], h, g);\n M(p[2], g, f);\n M(p[3], e, h);\n}\n\nfunction cswap(p, q, b) {\n var i;\n for (i = 0; i < 4; i++) {\n sel25519(p[i], q[i], b);\n }\n}\n\nfunction pack(r, p) {\n var tx = gf(), ty = gf(), zi = gf();\n inv25519(zi, p[2]);\n M(tx, p[0], zi);\n M(ty, p[1], zi);\n pack25519(r, ty);\n r[31] ^= par25519(tx) << 7;\n}\n\nfunction scalarmult(p, q, s) {\n var b, i;\n set25519(p[0], gf0);\n set25519(p[1], gf1);\n set25519(p[2], gf1);\n set25519(p[3], gf0);\n for (i = 255; i >= 0; --i) {\n b = (s[(i/8)|0] >> (i&7)) & 1;\n cswap(p, q, b);\n add(q, p);\n add(p, p);\n cswap(p, q, b);\n }\n}\n\nfunction scalarbase(p, s) {\n var q = [gf(), gf(), gf(), gf()];\n set25519(q[0], X);\n set25519(q[1], Y);\n set25519(q[2], gf1);\n M(q[3], X, Y);\n scalarmult(p, q, s);\n}\n\nfunction crypto_sign_keypair(pk, sk, seeded) {\n var d = new Uint8Array(64);\n var p = [gf(), gf(), gf(), gf()];\n var i;\n\n if (!seeded) randombytes(sk, 32);\n crypto_hash(d, sk, 32);\n d[0] &= 248;\n d[31] &= 127;\n d[31] |= 64;\n\n scalarbase(p, d);\n pack(pk, p);\n\n for (i = 0; i < 32; i++) sk[i+32] = pk[i];\n return 0;\n}\n\nvar L = new Float64Array([0xed, 0xd3, 0xf5, 0x5c, 0x1a, 0x63, 0x12, 0x58, 0xd6, 0x9c, 0xf7, 0xa2, 0xde, 0xf9, 0xde, 0x14, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x10]);\n\nfunction modL(r, x) {\n var carry, i, j, k;\n for (i = 63; i >= 32; --i) {\n carry = 0;\n for (j = i - 32, k = i - 12; j < k; ++j) {\n x[j] += carry - 16 * x[i] * L[j - (i - 32)];\n carry = Math.floor((x[j] + 128) / 256);\n x[j] -= carry * 256;\n }\n x[j] += carry;\n x[i] = 0;\n }\n carry = 0;\n for (j = 0; j < 32; j++) {\n x[j] += carry - (x[31] >> 4) * L[j];\n carry = x[j] >> 8;\n x[j] &= 255;\n }\n for (j = 0; j < 32; j++) x[j] -= carry * L[j];\n for (i = 0; i < 32; i++) {\n x[i+1] += x[i] >> 8;\n r[i] = x[i] & 255;\n }\n}\n\nfunction reduce(r) {\n var x = new Float64Array(64), i;\n for (i = 0; i < 64; i++) x[i] = r[i];\n for (i = 0; i < 64; i++) r[i] = 0;\n modL(r, x);\n}\n\n// Note: difference from C - smlen returned, not passed as argument.\nfunction crypto_sign(sm, m, n, sk) {\n var d = new Uint8Array(64), h = new Uint8Array(64), r = new Uint8Array(64);\n var i, j, x = new Float64Array(64);\n var p = [gf(), gf(), gf(), gf()];\n\n crypto_hash(d, sk, 32);\n d[0] &= 248;\n d[31] &= 127;\n d[31] |= 64;\n\n var smlen = n + 64;\n for (i = 0; i < n; i++) sm[64 + i] = m[i];\n for (i = 0; i < 32; i++) sm[32 + i] = d[32 + i];\n\n crypto_hash(r, sm.subarray(32), n+32);\n reduce(r);\n scalarbase(p, r);\n pack(sm, p);\n\n for (i = 32; i < 64; i++) sm[i] = sk[i];\n crypto_hash(h, sm, n + 64);\n reduce(h);\n\n for (i = 0; i < 64; i++) x[i] = 0;\n for (i = 0; i < 32; i++) x[i] = r[i];\n for (i = 0; i < 32; i++) {\n for (j = 0; j < 32; j++) {\n x[i+j] += h[i] * d[j];\n }\n }\n\n modL(sm.subarray(32), x);\n return smlen;\n}\n\nfunction unpackneg(r, p) {\n var t = gf(), chk = gf(), num = gf(),\n den = gf(), den2 = gf(), den4 = gf(),\n den6 = gf();\n\n set25519(r[2], gf1);\n unpack25519(r[1], p);\n S(num, r[1]);\n M(den, num, D);\n Z(num, num, r[2]);\n A(den, r[2], den);\n\n S(den2, den);\n S(den4, den2);\n M(den6, den4, den2);\n M(t, den6, num);\n M(t, t, den);\n\n pow2523(t, t);\n M(t, t, num);\n M(t, t, den);\n M(t, t, den);\n M(r[0], t, den);\n\n S(chk, r[0]);\n M(chk, chk, den);\n if (neq25519(chk, num)) M(r[0], r[0], I);\n\n S(chk, r[0]);\n M(chk, chk, den);\n if (neq25519(chk, num)) return -1;\n\n if (par25519(r[0]) === (p[31]>>7)) Z(r[0], gf0, r[0]);\n\n M(r[3], r[0], r[1]);\n return 0;\n}\n\nfunction crypto_sign_open(m, sm, n, pk) {\n var i;\n var t = new Uint8Array(32), h = new Uint8Array(64);\n var p = [gf(), gf(), gf(), gf()],\n q = [gf(), gf(), gf(), gf()];\n\n if (n < 64) return -1;\n\n if (unpackneg(q, pk)) return -1;\n\n for (i = 0; i < n; i++) m[i] = sm[i];\n for (i = 0; i < 32; i++) m[i+32] = pk[i];\n crypto_hash(h, m, n);\n reduce(h);\n scalarmult(p, q, h);\n\n scalarbase(q, sm.subarray(32));\n add(p, q);\n pack(t, p);\n\n n -= 64;\n if (crypto_verify_32(sm, 0, t, 0)) {\n for (i = 0; i < n; i++) m[i] = 0;\n return -1;\n }\n\n for (i = 0; i < n; i++) m[i] = sm[i + 64];\n return n;\n}\n\nvar crypto_secretbox_KEYBYTES = 32,\n crypto_secretbox_NONCEBYTES = 24,\n crypto_secretbox_ZEROBYTES = 32,\n crypto_secretbox_BOXZEROBYTES = 16,\n crypto_scalarmult_BYTES = 32,\n crypto_scalarmult_SCALARBYTES = 32,\n crypto_box_PUBLICKEYBYTES = 32,\n crypto_box_SECRETKEYBYTES = 32,\n crypto_box_BEFORENMBYTES = 32,\n crypto_box_NONCEBYTES = crypto_secretbox_NONCEBYTES,\n crypto_box_ZEROBYTES = crypto_secretbox_ZEROBYTES,\n crypto_box_BOXZEROBYTES = crypto_secretbox_BOXZEROBYTES,\n crypto_sign_BYTES = 64,\n crypto_sign_PUBLICKEYBYTES = 32,\n crypto_sign_SECRETKEYBYTES = 64,\n crypto_sign_SEEDBYTES = 32,\n crypto_hash_BYTES = 64;\n\nnacl.lowlevel = {\n crypto_core_hsalsa20: crypto_core_hsalsa20,\n crypto_stream_xor: crypto_stream_xor,\n crypto_stream: crypto_stream,\n crypto_stream_salsa20_xor: crypto_stream_salsa20_xor,\n crypto_stream_salsa20: crypto_stream_salsa20,\n crypto_onetimeauth: crypto_onetimeauth,\n crypto_onetimeauth_verify: crypto_onetimeauth_verify,\n crypto_verify_16: crypto_verify_16,\n crypto_verify_32: crypto_verify_32,\n crypto_secretbox: crypto_secretbox,\n crypto_secretbox_open: crypto_secretbox_open,\n crypto_scalarmult: crypto_scalarmult,\n crypto_scalarmult_base: crypto_scalarmult_base,\n crypto_box_beforenm: crypto_box_beforenm,\n crypto_box_afternm: crypto_box_afternm,\n crypto_box: crypto_box,\n crypto_box_open: crypto_box_open,\n crypto_box_keypair: crypto_box_keypair,\n crypto_hash: crypto_hash,\n crypto_sign: crypto_sign,\n crypto_sign_keypair: crypto_sign_keypair,\n crypto_sign_open: crypto_sign_open,\n\n crypto_secretbox_KEYBYTES: crypto_secretbox_KEYBYTES,\n crypto_secretbox_NONCEBYTES: crypto_secretbox_NONCEBYTES,\n crypto_secretbox_ZEROBYTES: crypto_secretbox_ZEROBYTES,\n crypto_secretbox_BOXZEROBYTES: crypto_secretbox_BOXZEROBYTES,\n crypto_scalarmult_BYTES: crypto_scalarmult_BYTES,\n crypto_scalarmult_SCALARBYTES: crypto_scalarmult_SCALARBYTES,\n crypto_box_PUBLICKEYBYTES: crypto_box_PUBLICKEYBYTES,\n crypto_box_SECRETKEYBYTES: crypto_box_SECRETKEYBYTES,\n crypto_box_BEFORENMBYTES: crypto_box_BEFORENMBYTES,\n crypto_box_NONCEBYTES: crypto_box_NONCEBYTES,\n crypto_box_ZEROBYTES: crypto_box_ZEROBYTES,\n crypto_box_BOXZEROBYTES: crypto_box_BOXZEROBYTES,\n crypto_sign_BYTES: crypto_sign_BYTES,\n crypto_sign_PUBLICKEYBYTES: crypto_sign_PUBLICKEYBYTES,\n crypto_sign_SECRETKEYBYTES: crypto_sign_SECRETKEYBYTES,\n crypto_sign_SEEDBYTES: crypto_sign_SEEDBYTES,\n crypto_hash_BYTES: crypto_hash_BYTES,\n\n gf: gf,\n D: D,\n L: L,\n pack25519: pack25519,\n unpack25519: unpack25519,\n M: M,\n A: A,\n S: S,\n Z: Z,\n pow2523: pow2523,\n add: add,\n set25519: set25519,\n modL: modL,\n scalarmult: scalarmult,\n scalarbase: scalarbase,\n};\n\n/* High-level API */\n\nfunction checkLengths(k, n) {\n if (k.length !== crypto_secretbox_KEYBYTES) throw new Error('bad key size');\n if (n.length !== crypto_secretbox_NONCEBYTES) throw new Error('bad nonce size');\n}\n\nfunction checkBoxLengths(pk, sk) {\n if (pk.length !== crypto_box_PUBLICKEYBYTES) throw new Error('bad public key size');\n if (sk.length !== crypto_box_SECRETKEYBYTES) throw new Error('bad secret key size');\n}\n\nfunction checkArrayTypes() {\n for (var i = 0; i < arguments.length; i++) {\n if (!(arguments[i] instanceof Uint8Array))\n throw new TypeError('unexpected type, use Uint8Array');\n }\n}\n\nfunction cleanup(arr) {\n for (var i = 0; i < arr.length; i++) arr[i] = 0;\n}\n\nnacl.randomBytes = function(n) {\n var b = new Uint8Array(n);\n randombytes(b, n);\n return b;\n};\n\nnacl.secretbox = function(msg, nonce, key) {\n checkArrayTypes(msg, nonce, key);\n checkLengths(key, nonce);\n var m = new Uint8Array(crypto_secretbox_ZEROBYTES + msg.length);\n var c = new Uint8Array(m.length);\n for (var i = 0; i < msg.length; i++) m[i+crypto_secretbox_ZEROBYTES] = msg[i];\n crypto_secretbox(c, m, m.length, nonce, key);\n return c.subarray(crypto_secretbox_BOXZEROBYTES);\n};\n\nnacl.secretbox.open = function(box, nonce, key) {\n checkArrayTypes(box, nonce, key);\n checkLengths(key, nonce);\n var c = new Uint8Array(crypto_secretbox_BOXZEROBYTES + box.length);\n var m = new Uint8Array(c.length);\n for (var i = 0; i < box.length; i++) c[i+crypto_secretbox_BOXZEROBYTES] = box[i];\n if (c.length < 32) return null;\n if (crypto_secretbox_open(m, c, c.length, nonce, key) !== 0) return null;\n return m.subarray(crypto_secretbox_ZEROBYTES);\n};\n\nnacl.secretbox.keyLength = crypto_secretbox_KEYBYTES;\nnacl.secretbox.nonceLength = crypto_secretbox_NONCEBYTES;\nnacl.secretbox.overheadLength = crypto_secretbox_BOXZEROBYTES;\n\nnacl.scalarMult = function(n, p) {\n checkArrayTypes(n, p);\n if (n.length !== crypto_scalarmult_SCALARBYTES) throw new Error('bad n size');\n if (p.length !== crypto_scalarmult_BYTES) throw new Error('bad p size');\n var q = new Uint8Array(crypto_scalarmult_BYTES);\n crypto_scalarmult(q, n, p);\n return q;\n};\n\nnacl.scalarMult.base = function(n) {\n checkArrayTypes(n);\n if (n.length !== crypto_scalarmult_SCALARBYTES) throw new Error('bad n size');\n var q = new Uint8Array(crypto_scalarmult_BYTES);\n crypto_scalarmult_base(q, n);\n return q;\n};\n\nnacl.scalarMult.scalarLength = crypto_scalarmult_SCALARBYTES;\nnacl.scalarMult.groupElementLength = crypto_scalarmult_BYTES;\n\nnacl.box = function(msg, nonce, publicKey, secretKey) {\n var k = nacl.box.before(publicKey, secretKey);\n return nacl.secretbox(msg, nonce, k);\n};\n\nnacl.box.before = function(publicKey, secretKey) {\n checkArrayTypes(publicKey, secretKey);\n checkBoxLengths(publicKey, secretKey);\n var k = new Uint8Array(crypto_box_BEFORENMBYTES);\n crypto_box_beforenm(k, publicKey, secretKey);\n return k;\n};\n\nnacl.box.after = nacl.secretbox;\n\nnacl.box.open = function(msg, nonce, publicKey, secretKey) {\n var k = nacl.box.before(publicKey, secretKey);\n return nacl.secretbox.open(msg, nonce, k);\n};\n\nnacl.box.open.after = nacl.secretbox.open;\n\nnacl.box.keyPair = function() {\n var pk = new Uint8Array(crypto_box_PUBLICKEYBYTES);\n var sk = new Uint8Array(crypto_box_SECRETKEYBYTES);\n crypto_box_keypair(pk, sk);\n return {publicKey: pk, secretKey: sk};\n};\n\nnacl.box.keyPair.fromSecretKey = function(secretKey) {\n checkArrayTypes(secretKey);\n if (secretKey.length !== crypto_box_SECRETKEYBYTES)\n throw new Error('bad secret key size');\n var pk = new Uint8Array(crypto_box_PUBLICKEYBYTES);\n crypto_scalarmult_base(pk, secretKey);\n return {publicKey: pk, secretKey: new Uint8Array(secretKey)};\n};\n\nnacl.box.publicKeyLength = crypto_box_PUBLICKEYBYTES;\nnacl.box.secretKeyLength = crypto_box_SECRETKEYBYTES;\nnacl.box.sharedKeyLength = crypto_box_BEFORENMBYTES;\nnacl.box.nonceLength = crypto_box_NONCEBYTES;\nnacl.box.overheadLength = nacl.secretbox.overheadLength;\n\nnacl.sign = function(msg, secretKey) {\n checkArrayTypes(msg, secretKey);\n if (secretKey.length !== crypto_sign_SECRETKEYBYTES)\n throw new Error('bad secret key size');\n var signedMsg = new Uint8Array(crypto_sign_BYTES+msg.length);\n crypto_sign(signedMsg, msg, msg.length, secretKey);\n return signedMsg;\n};\n\nnacl.sign.open = function(signedMsg, publicKey) {\n checkArrayTypes(signedMsg, publicKey);\n if (publicKey.length !== crypto_sign_PUBLICKEYBYTES)\n throw new Error('bad public key size');\n var tmp = new Uint8Array(signedMsg.length);\n var mlen = crypto_sign_open(tmp, signedMsg, signedMsg.length, publicKey);\n if (mlen < 0) return null;\n var m = new Uint8Array(mlen);\n for (var i = 0; i < m.length; i++) m[i] = tmp[i];\n return m;\n};\n\nnacl.sign.detached = function(msg, secretKey) {\n var signedMsg = nacl.sign(msg, secretKey);\n var sig = new Uint8Array(crypto_sign_BYTES);\n for (var i = 0; i < sig.length; i++) sig[i] = signedMsg[i];\n return sig;\n};\n\nnacl.sign.detached.verify = function(msg, sig, publicKey) {\n checkArrayTypes(msg, sig, publicKey);\n if (sig.length !== crypto_sign_BYTES)\n throw new Error('bad signature size');\n if (publicKey.length !== crypto_sign_PUBLICKEYBYTES)\n throw new Error('bad public key size');\n var sm = new Uint8Array(crypto_sign_BYTES + msg.length);\n var m = new Uint8Array(crypto_sign_BYTES + msg.length);\n var i;\n for (i = 0; i < crypto_sign_BYTES; i++) sm[i] = sig[i];\n for (i = 0; i < msg.length; i++) sm[i+crypto_sign_BYTES] = msg[i];\n return (crypto_sign_open(m, sm, sm.length, publicKey) >= 0);\n};\n\nnacl.sign.keyPair = function() {\n var pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);\n var sk = new Uint8Array(crypto_sign_SECRETKEYBYTES);\n crypto_sign_keypair(pk, sk);\n return {publicKey: pk, secretKey: sk};\n};\n\nnacl.sign.keyPair.fromSecretKey = function(secretKey) {\n checkArrayTypes(secretKey);\n if (secretKey.length !== crypto_sign_SECRETKEYBYTES)\n throw new Error('bad secret key size');\n var pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);\n for (var i = 0; i < pk.length; i++) pk[i] = secretKey[32+i];\n return {publicKey: pk, secretKey: new Uint8Array(secretKey)};\n};\n\nnacl.sign.keyPair.fromSeed = function(seed) {\n checkArrayTypes(seed);\n if (seed.length !== crypto_sign_SEEDBYTES)\n throw new Error('bad seed size');\n var pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);\n var sk = new Uint8Array(crypto_sign_SECRETKEYBYTES);\n for (var i = 0; i < 32; i++) sk[i] = seed[i];\n crypto_sign_keypair(pk, sk, true);\n return {publicKey: pk, secretKey: sk};\n};\n\nnacl.sign.publicKeyLength = crypto_sign_PUBLICKEYBYTES;\nnacl.sign.secretKeyLength = crypto_sign_SECRETKEYBYTES;\nnacl.sign.seedLength = crypto_sign_SEEDBYTES;\nnacl.sign.signatureLength = crypto_sign_BYTES;\n\nnacl.hash = function(msg) {\n checkArrayTypes(msg);\n var h = new Uint8Array(crypto_hash_BYTES);\n crypto_hash(h, msg, msg.length);\n return h;\n};\n\nnacl.hash.hashLength = crypto_hash_BYTES;\n\nnacl.verify = function(x, y) {\n checkArrayTypes(x, y);\n // Zero length arguments are considered not equal.\n if (x.length === 0 || y.length === 0) return false;\n if (x.length !== y.length) return false;\n return (vn(x, 0, y, 0, x.length) === 0) ? true : false;\n};\n\nnacl.setPRNG = function(fn) {\n randombytes = fn;\n};\n\n(function() {\n // Initialize PRNG if environment provides CSPRNG.\n // If not, methods calling randombytes will throw.\n var crypto = typeof self !== 'undefined' ? (self.crypto || self.msCrypto) : null;\n if (crypto && crypto.getRandomValues) {\n // Browsers.\n var QUOTA = 65536;\n nacl.setPRNG(function(x, n) {\n var i, v = new Uint8Array(n);\n for (i = 0; i < n; i += QUOTA) {\n crypto.getRandomValues(v.subarray(i, i + Math.min(n - i, QUOTA)));\n }\n for (i = 0; i < n; i++) x[i] = v[i];\n cleanup(v);\n });\n } else if (typeof require !== 'undefined') {\n // Node.js.\n crypto = require('crypto');\n if (crypto && crypto.randomBytes) {\n nacl.setPRNG(function(x, n) {\n var i, v = crypto.randomBytes(n);\n for (i = 0; i < n; i++) x[i] = v[i];\n cleanup(v);\n });\n }\n }\n})();\n\n})(typeof module !== 'undefined' && module.exports ? module.exports : (self.nacl = self.nacl || {}));\n","module.exports = require('./pusher-with-encryption').default;\n","export default function encode(s: any): string {\n return btoa(utob(s));\n}\n\nvar fromCharCode = String.fromCharCode;\n\nvar b64chars =\n 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';\nvar b64tab = {};\n\nfor (var i = 0, l = b64chars.length; i < l; i++) {\n b64tab[b64chars.charAt(i)] = i;\n}\n\nvar cb_utob = function(c) {\n var cc = c.charCodeAt(0);\n return cc < 0x80\n ? c\n : cc < 0x800\n ? fromCharCode(0xc0 | (cc >>> 6)) + fromCharCode(0x80 | (cc & 0x3f))\n : fromCharCode(0xe0 | ((cc >>> 12) & 0x0f)) +\n fromCharCode(0x80 | ((cc >>> 6) & 0x3f)) +\n fromCharCode(0x80 | (cc & 0x3f));\n};\n\nvar utob = function(u) {\n return u.replace(/[^\\x00-\\x7F]/g, cb_utob);\n};\n\nvar cb_encode = function(ccc) {\n var padlen = [0, 2, 1][ccc.length % 3];\n var ord =\n (ccc.charCodeAt(0) << 16) |\n ((ccc.length > 1 ? ccc.charCodeAt(1) : 0) << 8) |\n (ccc.length > 2 ? ccc.charCodeAt(2) : 0);\n var chars = [\n b64chars.charAt(ord >>> 18),\n b64chars.charAt((ord >>> 12) & 63),\n padlen >= 2 ? '=' : b64chars.charAt((ord >>> 6) & 63),\n padlen >= 1 ? '=' : b64chars.charAt(ord & 63)\n ];\n return chars.join('');\n};\n\nvar btoa =\n global.btoa ||\n function(b) {\n return b.replace(/[\\s\\S]{1,3}/g, cb_encode);\n };\n","import TimedCallback from './timed_callback';\nimport { Delay, Scheduler, Canceller } from './scheduling';\n\nabstract class Timer {\n protected clear: Canceller;\n protected timer: number | void;\n\n constructor(\n set: Scheduler,\n clear: Canceller,\n delay: Delay,\n callback: TimedCallback\n ) {\n this.clear = clear;\n this.timer = set(() => {\n if (this.timer) {\n this.timer = callback(this.timer);\n }\n }, delay);\n }\n\n /** Returns whether the timer is still running.\n *\n * @return {Boolean}\n */\n isRunning(): boolean {\n return this.timer !== null;\n }\n\n /** Aborts a timer when it's running. */\n ensureAborted() {\n if (this.timer) {\n this.clear(this.timer);\n this.timer = null;\n }\n }\n}\n\nexport default Timer;\n","import Timer from './abstract_timer';\nimport TimedCallback from './timed_callback';\nimport { Delay } from './scheduling';\n\n// We need to bind clear functions this way to avoid exceptions on IE8\nfunction clearTimeout(timer) {\n global.clearTimeout(timer);\n}\nfunction clearInterval(timer) {\n global.clearInterval(timer);\n}\n\n/** Cross-browser compatible one-off timer abstraction.\n *\n * @param {Number} delay\n * @param {Function} callback\n */\nexport class OneOffTimer extends Timer {\n constructor(delay: Delay, callback: TimedCallback) {\n super(setTimeout, clearTimeout, delay, function(timer) {\n callback();\n return null;\n });\n }\n}\n\n/** Cross-browser compatible periodic timer abstraction.\n *\n * @param {Number} delay\n * @param {Function} callback\n */\nexport class PeriodicTimer extends Timer {\n constructor(delay: Delay, callback: TimedCallback) {\n super(setInterval, clearInterval, delay, function(timer) {\n callback();\n return timer;\n });\n }\n}\n","import * as Collections from './utils/collections';\nimport TimedCallback from './utils/timers/timed_callback';\nimport { OneOffTimer, PeriodicTimer } from './utils/timers';\n\nvar Util = {\n now(): number {\n if (Date.now) {\n return Date.now();\n } else {\n return new Date().valueOf();\n }\n },\n\n defer(callback: TimedCallback): OneOffTimer {\n return new OneOffTimer(0, callback);\n },\n\n /** Builds a function that will proxy a method call to its first argument.\n *\n * Allows partial application of arguments, so additional arguments are\n * prepended to the argument list.\n *\n * @param {String} name method name\n * @return {Function} proxy function\n */\n method(name: string, ...args: any[]): Function {\n var boundArguments = Array.prototype.slice.call(arguments, 1);\n return function(object) {\n return object[name].apply(object, boundArguments.concat(arguments));\n };\n }\n};\n\nexport default Util;\n","import base64encode from '../base64';\nimport Util from '../util';\n\n/** Merges multiple objects into the target argument.\n *\n * For properties that are plain Objects, performs a deep-merge. For the\n * rest it just copies the value of the property.\n *\n * To extend prototypes use it as following:\n * Pusher.Util.extend(Target.prototype, Base.prototype)\n *\n * You can also use it to merge objects without altering them:\n * Pusher.Util.extend({}, object1, object2)\n *\n * @param {Object} target\n * @return {Object} the target argument\n */\nexport function extend(target: any, ...sources: any[]): T {\n for (var i = 0; i < sources.length; i++) {\n var extensions = sources[i];\n for (var property in extensions) {\n if (\n extensions[property] &&\n extensions[property].constructor &&\n extensions[property].constructor === Object\n ) {\n target[property] = extend(target[property] || {}, extensions[property]);\n } else {\n target[property] = extensions[property];\n }\n }\n }\n return target;\n}\n\nexport function stringify(): string {\n var m = ['Pusher'];\n for (var i = 0; i < arguments.length; i++) {\n if (typeof arguments[i] === 'string') {\n m.push(arguments[i]);\n } else {\n m.push(safeJSONStringify(arguments[i]));\n }\n }\n return m.join(' : ');\n}\n\nexport function arrayIndexOf(array: any[], item: any): number {\n // MSIE doesn't have array.indexOf\n var nativeIndexOf = Array.prototype.indexOf;\n if (array === null) {\n return -1;\n }\n if (nativeIndexOf && array.indexOf === nativeIndexOf) {\n return array.indexOf(item);\n }\n for (var i = 0, l = array.length; i < l; i++) {\n if (array[i] === item) {\n return i;\n }\n }\n return -1;\n}\n\n/** Applies a function f to all properties of an object.\n *\n * Function f gets 3 arguments passed:\n * - element from the object\n * - key of the element\n * - reference to the object\n *\n * @param {Object} object\n * @param {Function} f\n */\nexport function objectApply(object: any, f: Function) {\n for (var key in object) {\n if (Object.prototype.hasOwnProperty.call(object, key)) {\n f(object[key], key, object);\n }\n }\n}\n\n/** Return a list of objects own proerty keys\n *\n * @param {Object} object\n * @returns {Array}\n */\nexport function keys(object: any): string[] {\n var keys = [];\n objectApply(object, function(_, key) {\n keys.push(key);\n });\n return keys;\n}\n\n/** Return a list of object's own property values\n *\n * @param {Object} object\n * @returns {Array}\n */\nexport function values(object: any): any[] {\n var values = [];\n objectApply(object, function(value) {\n values.push(value);\n });\n return values;\n}\n\n/** Applies a function f to all elements of an array.\n *\n * Function f gets 3 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function apply(array: any[], f: Function, context?: any) {\n for (var i = 0; i < array.length; i++) {\n f.call(context || global, array[i], i, array);\n }\n}\n\n/** Maps all elements of the array and returns the result.\n *\n * Function f gets 4 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n * - reference to the destination array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function map(array: any[], f: Function): any[] {\n var result = [];\n for (var i = 0; i < array.length; i++) {\n result.push(f(array[i], i, array, result));\n }\n return result;\n}\n\n/** Maps all elements of the object and returns the result.\n *\n * Function f gets 4 arguments passed:\n * - element from the object\n * - key of the element\n * - reference to the source object\n * - reference to the destination object\n *\n * @param {Object} object\n * @param {Function} f\n */\nexport function mapObject(object: any, f: Function): any {\n var result = {};\n objectApply(object, function(value, key) {\n result[key] = f(value);\n });\n return result;\n}\n\n/** Filters elements of the array using a test function.\n *\n * Function test gets 4 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n * - reference to the destination array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function filter(array: any[], test: Function): any[] {\n test =\n test ||\n function(value) {\n return !!value;\n };\n\n var result = [];\n for (var i = 0; i < array.length; i++) {\n if (test(array[i], i, array, result)) {\n result.push(array[i]);\n }\n }\n return result;\n}\n\n/** Filters properties of the object using a test function.\n *\n * Function test gets 4 arguments passed:\n * - element from the object\n * - key of the element\n * - reference to the source object\n * - reference to the destination object\n *\n * @param {Object} object\n * @param {Function} f\n */\nexport function filterObject(object: Object, test: Function) {\n var result = {};\n objectApply(object, function(value, key) {\n if ((test && test(value, key, object, result)) || Boolean(value)) {\n result[key] = value;\n }\n });\n return result;\n}\n\n/** Flattens an object into a two-dimensional array.\n *\n * @param {Object} object\n * @return {Array} resulting array of [key, value] pairs\n */\nexport function flatten(object: Object): any[] {\n var result = [];\n objectApply(object, function(value, key) {\n result.push([key, value]);\n });\n return result;\n}\n\n/** Checks whether any element of the array passes the test.\n *\n * Function test gets 3 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function any(array: any[], test: Function): boolean {\n for (var i = 0; i < array.length; i++) {\n if (test(array[i], i, array)) {\n return true;\n }\n }\n return false;\n}\n\n/** Checks whether all elements of the array pass the test.\n *\n * Function test gets 3 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function all(array: any[], test: Function): boolean {\n for (var i = 0; i < array.length; i++) {\n if (!test(array[i], i, array)) {\n return false;\n }\n }\n return true;\n}\n\nexport function encodeParamsObject(data): string {\n return mapObject(data, function(value) {\n if (typeof value === 'object') {\n value = safeJSONStringify(value);\n }\n return encodeURIComponent(base64encode(value.toString()));\n });\n}\n\nexport function buildQueryString(data: any): string {\n var params = filterObject(data, function(value) {\n return value !== undefined;\n });\n\n var query = map(\n flatten(encodeParamsObject(params)),\n Util.method('join', '=')\n ).join('&');\n\n return query;\n}\n\n/**\n * See https://github.com/douglascrockford/JSON-js/blob/master/cycle.js\n *\n * Remove circular references from an object. Required for JSON.stringify in\n * React Native, which tends to blow up a lot.\n *\n * @param {any} object\n * @return {any} Decycled object\n */\nexport function decycleObject(object: any): any {\n var objects = [],\n paths = [];\n\n return (function derez(value, path) {\n var i, name, nu;\n\n switch (typeof value) {\n case 'object':\n if (!value) {\n return null;\n }\n for (i = 0; i < objects.length; i += 1) {\n if (objects[i] === value) {\n return { $ref: paths[i] };\n }\n }\n\n objects.push(value);\n paths.push(path);\n\n if (Object.prototype.toString.apply(value) === '[object Array]') {\n nu = [];\n for (i = 0; i < value.length; i += 1) {\n nu[i] = derez(value[i], path + '[' + i + ']');\n }\n } else {\n nu = {};\n for (name in value) {\n if (Object.prototype.hasOwnProperty.call(value, name)) {\n nu[name] = derez(\n value[name],\n path + '[' + JSON.stringify(name) + ']'\n );\n }\n }\n }\n return nu;\n case 'number':\n case 'string':\n case 'boolean':\n return value;\n }\n })(object, '$');\n}\n\n/**\n * Provides a cross-browser and cross-platform way to safely stringify objects\n * into JSON. This is particularly necessary for ReactNative, where circular JSON\n * structures throw an exception.\n *\n * @param {any} source The object to stringify\n * @return {string} The serialized output.\n */\nexport function safeJSONStringify(source: any): string {\n try {\n return JSON.stringify(source);\n } catch (e) {\n return JSON.stringify(decycleObject(source));\n }\n}\n","import {\n ChannelAuthorizationOptions,\n UserAuthenticationOptions\n} from './auth/options';\nimport { AuthTransport } from './config';\n\nexport interface DefaultConfig {\n VERSION: string;\n PROTOCOL: number;\n wsPort: number;\n wssPort: number;\n wsPath: string;\n httpHost: string;\n httpPort: number;\n httpsPort: number;\n httpPath: string;\n stats_host: string;\n authEndpoint: string;\n authTransport: AuthTransport;\n activityTimeout: number;\n pongTimeout: number;\n unavailableTimeout: number;\n userAuthentication: UserAuthenticationOptions;\n channelAuthorization: ChannelAuthorizationOptions;\n\n cdn_http?: string;\n cdn_https?: string;\n dependency_suffix?: string;\n}\n\nvar Defaults: DefaultConfig = {\n VERSION: VERSION,\n PROTOCOL: 7,\n\n wsPort: 80,\n wssPort: 443,\n wsPath: '',\n // DEPRECATED: SockJS fallback parameters\n httpHost: 'sockjs.pusher.com',\n httpPort: 80,\n httpsPort: 443,\n httpPath: '/pusher',\n // DEPRECATED: Stats\n stats_host: 'stats.pusher.com',\n // DEPRECATED: Other settings\n authEndpoint: '/pusher/auth',\n authTransport: 'ajax',\n activityTimeout: 120000,\n pongTimeout: 30000,\n unavailableTimeout: 10000,\n userAuthentication: {\n endpoint: '/pusher/user-auth',\n transport: 'ajax'\n },\n channelAuthorization: {\n endpoint: '/pusher/auth',\n transport: 'ajax'\n },\n\n // CDN configuration\n cdn_http: CDN_HTTP,\n cdn_https: CDN_HTTPS,\n dependency_suffix: DEPENDENCY_SUFFIX\n};\n\nexport default Defaults;\n","import Defaults from '../defaults';\nimport { default as URLScheme, URLSchemeParams } from './url_scheme';\n\nfunction getGenericURL(\n baseScheme: string,\n params: URLSchemeParams,\n path: string\n): string {\n var scheme = baseScheme + (params.useTLS ? 's' : '');\n var host = params.useTLS ? params.hostTLS : params.hostNonTLS;\n return scheme + '://' + host + path;\n}\n\nfunction getGenericPath(key: string, queryString?: string): string {\n var path = '/app/' + key;\n var query =\n '?protocol=' +\n Defaults.PROTOCOL +\n '&client=js' +\n '&version=' +\n Defaults.VERSION +\n (queryString ? '&' + queryString : '');\n return path + query;\n}\n\nexport var ws: URLScheme = {\n getInitial: function(key: string, params: URLSchemeParams): string {\n var path = (params.httpPath || '') + getGenericPath(key, 'flash=false');\n return getGenericURL('ws', params, path);\n }\n};\n\nexport var http: URLScheme = {\n getInitial: function(key: string, params: URLSchemeParams): string {\n var path = (params.httpPath || '/pusher') + getGenericPath(key);\n return getGenericURL('http', params, path);\n }\n};\n\nexport var sockjs: URLScheme = {\n getInitial: function(key: string, params: URLSchemeParams): string {\n return getGenericURL('http', params, params.httpPath || '/pusher');\n },\n getPath: function(key: string, params: URLSchemeParams): string {\n return getGenericPath(key);\n }\n};\n","import Callback from './callback';\nimport * as Collections from '../utils/collections';\nimport CallbackTable from './callback_table';\n\nexport default class CallbackRegistry {\n _callbacks: CallbackTable;\n\n constructor() {\n this._callbacks = {};\n }\n\n get(name: string): Callback[] {\n return this._callbacks[prefix(name)];\n }\n\n add(name: string, callback: Function, context: any) {\n var prefixedEventName = prefix(name);\n this._callbacks[prefixedEventName] =\n this._callbacks[prefixedEventName] || [];\n this._callbacks[prefixedEventName].push({\n fn: callback,\n context: context\n });\n }\n\n remove(name?: string, callback?: Function, context?: any) {\n if (!name && !callback && !context) {\n this._callbacks = {};\n return;\n }\n\n var names = name ? [prefix(name)] : Collections.keys(this._callbacks);\n\n if (callback || context) {\n this.removeCallback(names, callback, context);\n } else {\n this.removeAllCallbacks(names);\n }\n }\n\n private removeCallback(names: string[], callback: Function, context: any) {\n Collections.apply(\n names,\n function(name) {\n this._callbacks[name] = Collections.filter(\n this._callbacks[name] || [],\n function(binding) {\n return (\n (callback && callback !== binding.fn) ||\n (context && context !== binding.context)\n );\n }\n );\n if (this._callbacks[name].length === 0) {\n delete this._callbacks[name];\n }\n },\n this\n );\n }\n\n private removeAllCallbacks(names: string[]) {\n Collections.apply(\n names,\n function(name) {\n delete this._callbacks[name];\n },\n this\n );\n }\n}\n\nfunction prefix(name: string): string {\n return '_' + name;\n}\n","import * as Collections from '../utils/collections';\nimport Callback from './callback';\nimport Metadata from '../channels/metadata';\nimport CallbackRegistry from './callback_registry';\n\n/** Manages callback bindings and event emitting.\n *\n * @param Function failThrough called when no listeners are bound to an event\n */\nexport default class Dispatcher {\n callbacks: CallbackRegistry;\n global_callbacks: Function[];\n failThrough: Function;\n\n constructor(failThrough?: Function) {\n this.callbacks = new CallbackRegistry();\n this.global_callbacks = [];\n this.failThrough = failThrough;\n }\n\n bind(eventName: string, callback: Function, context?: any) {\n this.callbacks.add(eventName, callback, context);\n return this;\n }\n\n bind_global(callback: Function) {\n this.global_callbacks.push(callback);\n return this;\n }\n\n unbind(eventName?: string, callback?: Function, context?: any) {\n this.callbacks.remove(eventName, callback, context);\n return this;\n }\n\n unbind_global(callback?: Function) {\n if (!callback) {\n this.global_callbacks = [];\n return this;\n }\n\n this.global_callbacks = Collections.filter(\n this.global_callbacks || [],\n c => c !== callback\n );\n\n return this;\n }\n\n unbind_all() {\n this.unbind();\n this.unbind_global();\n return this;\n }\n\n emit(eventName: string, data?: any, metadata?: Metadata): Dispatcher {\n for (var i = 0; i < this.global_callbacks.length; i++) {\n this.global_callbacks[i](eventName, data);\n }\n\n var callbacks = this.callbacks.get(eventName);\n var args = [];\n\n if (metadata) {\n // if there's a metadata argument, we need to call the callback with both\n // data and metadata regardless of whether data is undefined\n args.push(data, metadata);\n } else if (data) {\n // metadata is undefined, so we only need to call the callback with data\n // if data exists\n args.push(data);\n }\n\n if (callbacks && callbacks.length > 0) {\n for (var i = 0; i < callbacks.length; i++) {\n callbacks[i].fn.apply(callbacks[i].context || global, args);\n }\n } else if (this.failThrough) {\n this.failThrough(eventName, data);\n }\n\n return this;\n }\n}\n","import { stringify } from './utils/collections';\nimport Pusher from './pusher';\n\nclass Logger {\n debug(...args: any[]) {\n this.log(this.globalLog, args);\n }\n\n warn(...args: any[]) {\n this.log(this.globalLogWarn, args);\n }\n\n error(...args: any[]) {\n this.log(this.globalLogError, args);\n }\n\n private globalLog = (message: string) => {\n if (global.console && global.console.log) {\n global.console.log(message);\n }\n };\n\n private globalLogWarn(message: string) {\n if (global.console && global.console.warn) {\n global.console.warn(message);\n } else {\n this.globalLog(message);\n }\n }\n\n private globalLogError(message: string) {\n if (global.console && global.console.error) {\n global.console.error(message);\n } else {\n this.globalLogWarn(message);\n }\n }\n\n private log(\n defaultLoggingFunction: (message: string) => void,\n ...args: any[]\n ) {\n var message = stringify.apply(this, arguments);\n if (Pusher.log) {\n Pusher.log(message);\n } else if (Pusher.logToConsole) {\n const log = defaultLoggingFunction.bind(this);\n log(message);\n }\n }\n}\n\nexport default new Logger();\n","import Util from '../util';\nimport * as Collections from '../utils/collections';\nimport { default as EventsDispatcher } from '../events/dispatcher';\nimport Logger from '../logger';\nimport TransportHooks from './transport_hooks';\nimport Socket from '../socket';\nimport Runtime from 'runtime';\nimport Timeline from '../timeline/timeline';\nimport TransportConnectionOptions from './transport_connection_options';\n\n/** Provides universal API for transport connections.\n *\n * Transport connection is a low-level object that wraps a connection method\n * and exposes a simple evented interface for the connection state and\n * messaging. It does not implement Pusher-specific WebSocket protocol.\n *\n * Additionally, it fetches resources needed for transport to work and exposes\n * an interface for querying transport features.\n *\n * States:\n * - new - initial state after constructing the object\n * - initializing - during initialization phase, usually fetching resources\n * - intialized - ready to establish a connection\n * - connection - when connection is being established\n * - open - when connection ready to be used\n * - closed - after connection was closed be either side\n *\n * Emits:\n * - error - after the connection raised an error\n *\n * Options:\n * - useTLS - whether connection should be over TLS\n * - hostTLS - host to connect to when connection is over TLS\n * - hostNonTLS - host to connect to when connection is over TLS\n *\n * @param {String} key application key\n * @param {Object} options\n */\nexport default class TransportConnection extends EventsDispatcher {\n hooks: TransportHooks;\n name: string;\n priority: number;\n key: string;\n options: TransportConnectionOptions;\n state: string;\n timeline: Timeline;\n activityTimeout: number;\n id: number;\n socket: Socket;\n beforeOpen: Function;\n initialize: Function;\n\n constructor(\n hooks: TransportHooks,\n name: string,\n priority: number,\n key: string,\n options: TransportConnectionOptions\n ) {\n super();\n this.initialize = Runtime.transportConnectionInitializer;\n this.hooks = hooks;\n this.name = name;\n this.priority = priority;\n this.key = key;\n this.options = options;\n\n this.state = 'new';\n this.timeline = options.timeline;\n this.activityTimeout = options.activityTimeout;\n this.id = this.timeline.generateUniqueID();\n }\n\n /** Checks whether the transport handles activity checks by itself.\n *\n * @return {Boolean}\n */\n handlesActivityChecks(): boolean {\n return Boolean(this.hooks.handlesActivityChecks);\n }\n\n /** Checks whether the transport supports the ping/pong API.\n *\n * @return {Boolean}\n */\n supportsPing(): boolean {\n return Boolean(this.hooks.supportsPing);\n }\n\n /** Tries to establish a connection.\n *\n * @returns {Boolean} false if transport is in invalid state\n */\n connect(): boolean {\n if (this.socket || this.state !== 'initialized') {\n return false;\n }\n\n var url = this.hooks.urls.getInitial(this.key, this.options);\n try {\n this.socket = this.hooks.getSocket(url, this.options);\n } catch (e) {\n Util.defer(() => {\n this.onError(e);\n this.changeState('closed');\n });\n return false;\n }\n\n this.bindListeners();\n\n Logger.debug('Connecting', { transport: this.name, url });\n this.changeState('connecting');\n return true;\n }\n\n /** Closes the connection.\n *\n * @return {Boolean} true if there was a connection to close\n */\n close(): boolean {\n if (this.socket) {\n this.socket.close();\n return true;\n } else {\n return false;\n }\n }\n\n /** Sends data over the open connection.\n *\n * @param {String} data\n * @return {Boolean} true only when in the \"open\" state\n */\n send(data: any): boolean {\n if (this.state === 'open') {\n // Workaround for MobileSafari bug (see https://gist.github.com/2052006)\n Util.defer(() => {\n if (this.socket) {\n this.socket.send(data);\n }\n });\n return true;\n } else {\n return false;\n }\n }\n\n /** Sends a ping if the connection is open and transport supports it. */\n ping() {\n if (this.state === 'open' && this.supportsPing()) {\n this.socket.ping();\n }\n }\n\n private onOpen() {\n if (this.hooks.beforeOpen) {\n this.hooks.beforeOpen(\n this.socket,\n this.hooks.urls.getPath(this.key, this.options)\n );\n }\n this.changeState('open');\n this.socket.onopen = undefined;\n }\n\n private onError(error) {\n this.emit('error', { type: 'WebSocketError', error: error });\n this.timeline.error(this.buildTimelineMessage({ error: error.toString() }));\n }\n\n private onClose(closeEvent?: any) {\n if (closeEvent) {\n this.changeState('closed', {\n code: closeEvent.code,\n reason: closeEvent.reason,\n wasClean: closeEvent.wasClean\n });\n } else {\n this.changeState('closed');\n }\n this.unbindListeners();\n this.socket = undefined;\n }\n\n private onMessage(message) {\n this.emit('message', message);\n }\n\n private onActivity() {\n this.emit('activity');\n }\n\n private bindListeners() {\n this.socket.onopen = () => {\n this.onOpen();\n };\n this.socket.onerror = error => {\n this.onError(error);\n };\n this.socket.onclose = closeEvent => {\n this.onClose(closeEvent);\n };\n this.socket.onmessage = message => {\n this.onMessage(message);\n };\n\n if (this.supportsPing()) {\n this.socket.onactivity = () => {\n this.onActivity();\n };\n }\n }\n\n private unbindListeners() {\n if (this.socket) {\n this.socket.onopen = undefined;\n this.socket.onerror = undefined;\n this.socket.onclose = undefined;\n this.socket.onmessage = undefined;\n if (this.supportsPing()) {\n this.socket.onactivity = undefined;\n }\n }\n }\n\n private changeState(state: string, params?: any) {\n this.state = state;\n this.timeline.info(\n this.buildTimelineMessage({\n state: state,\n params: params\n })\n );\n this.emit(state, params);\n }\n\n buildTimelineMessage(message): any {\n return Collections.extend({ cid: this.id }, message);\n }\n}\n","import Factory from '../utils/factory';\nimport TransportHooks from './transport_hooks';\nimport TransportConnection from './transport_connection';\nimport TransportConnectionOptions from './transport_connection_options';\n\n/** Provides interface for transport connection instantiation.\n *\n * Takes transport-specific hooks as the only argument, which allow checking\n * for transport support and creating its connections.\n *\n * Supported hooks: * - file - the name of the file to be fetched during initialization\n * - urls - URL scheme to be used by transport\n * - handlesActivityCheck - true when the transport handles activity checks\n * - supportsPing - true when the transport has a ping/activity API\n * - isSupported - tells whether the transport is supported in the environment\n * - getSocket - creates a WebSocket-compatible transport socket\n *\n * See transports.js for specific implementations.\n *\n * @param {Object} hooks object containing all needed transport hooks\n */\nexport default class Transport {\n hooks: TransportHooks;\n\n constructor(hooks: TransportHooks) {\n this.hooks = hooks;\n }\n\n /** Returns whether the transport is supported in the environment.\n *\n * @param {Object} envronment te environment details (encryption, settings)\n * @returns {Boolean} true when the transport is supported\n */\n isSupported(environment: any): boolean {\n return this.hooks.isSupported(environment);\n }\n\n /** Creates a transport connection.\n *\n * @param {String} name\n * @param {Number} priority\n * @param {String} key the application key\n * @param {Object} options\n * @returns {TransportConnection}\n */\n createConnection(\n name: string,\n priority: number,\n key: string,\n options: any\n ): TransportConnection {\n return new TransportConnection(this.hooks, name, priority, key, options);\n }\n}\n","import * as URLSchemes from 'core/transports/url_schemes';\nimport URLScheme from 'core/transports/url_scheme';\nimport Transport from 'core/transports/transport';\nimport Util from 'core/util';\nimport * as Collections from 'core/utils/collections';\nimport TransportHooks from 'core/transports/transport_hooks';\nimport TransportsTable from 'core/transports/transports_table';\nimport Runtime from 'runtime';\n\n/** WebSocket transport.\n *\n * Uses native WebSocket implementation, including MozWebSocket supported by\n * earlier Firefox versions.\n */\nvar WSTransport = new Transport({\n urls: URLSchemes.ws,\n handlesActivityChecks: false,\n supportsPing: false,\n\n isInitialized: function() {\n return Boolean(Runtime.getWebSocketAPI());\n },\n isSupported: function(): boolean {\n return Boolean(Runtime.getWebSocketAPI());\n },\n getSocket: function(url) {\n return Runtime.createWebSocket(url);\n }\n});\n\nvar httpConfiguration = {\n urls: URLSchemes.http,\n handlesActivityChecks: false,\n supportsPing: true,\n isInitialized: function() {\n return true;\n }\n};\n\nexport var streamingConfiguration = Collections.extend(\n {\n getSocket: function(url) {\n return Runtime.HTTPFactory.createStreamingSocket(url);\n }\n },\n httpConfiguration\n);\nexport var pollingConfiguration = Collections.extend(\n {\n getSocket: function(url) {\n return Runtime.HTTPFactory.createPollingSocket(url);\n }\n },\n httpConfiguration\n);\n\nvar xhrConfiguration = {\n isSupported: function(): boolean {\n return Runtime.isXHRSupported();\n }\n};\n\n/** HTTP streaming transport using CORS-enabled XMLHttpRequest. */\nvar XHRStreamingTransport = new Transport(\n (\n Collections.extend({}, streamingConfiguration, xhrConfiguration)\n )\n);\n\n/** HTTP long-polling transport using CORS-enabled XMLHttpRequest. */\nvar XHRPollingTransport = new Transport(\n Collections.extend({}, pollingConfiguration, xhrConfiguration)\n);\n\nvar Transports: TransportsTable = {\n ws: WSTransport,\n xhr_streaming: XHRStreamingTransport,\n xhr_polling: XHRPollingTransport\n};\n\nexport default Transports;\n","import Util from '../util';\nimport * as Collections from '../utils/collections';\nimport TransportManager from './transport_manager';\nimport TransportConnection from './transport_connection';\nimport Transport from './transport';\nimport PingDelayOptions from './ping_delay_options';\n\n/** Creates transport connections monitored by a transport manager.\n *\n * When a transport is closed, it might mean the environment does not support\n * it. It's possible that messages get stuck in an intermediate buffer or\n * proxies terminate inactive connections. To combat these problems,\n * assistants monitor the connection lifetime, report unclean exits and\n * adjust ping timeouts to keep the connection active. The decision to disable\n * a transport is the manager's responsibility.\n *\n * @param {TransportManager} manager\n * @param {TransportConnection} transport\n * @param {Object} options\n */\nexport default class AssistantToTheTransportManager {\n manager: TransportManager;\n transport: Transport;\n minPingDelay: number;\n maxPingDelay: number;\n pingDelay: number;\n\n constructor(\n manager: TransportManager,\n transport: Transport,\n options: PingDelayOptions\n ) {\n this.manager = manager;\n this.transport = transport;\n this.minPingDelay = options.minPingDelay;\n this.maxPingDelay = options.maxPingDelay;\n this.pingDelay = undefined;\n }\n\n /** Creates a transport connection.\n *\n * This function has the same API as Transport#createConnection.\n *\n * @param {String} name\n * @param {Number} priority\n * @param {String} key the application key\n * @param {Object} options\n * @returns {TransportConnection}\n */\n createConnection(\n name: string,\n priority: number,\n key: string,\n options: Object\n ): TransportConnection {\n options = Collections.extend({}, options, {\n activityTimeout: this.pingDelay\n });\n var connection = this.transport.createConnection(\n name,\n priority,\n key,\n options\n );\n\n var openTimestamp = null;\n\n var onOpen = function() {\n connection.unbind('open', onOpen);\n connection.bind('closed', onClosed);\n openTimestamp = Util.now();\n };\n var onClosed = closeEvent => {\n connection.unbind('closed', onClosed);\n\n if (closeEvent.code === 1002 || closeEvent.code === 1003) {\n // we don't want to use transports not obeying the protocol\n this.manager.reportDeath();\n } else if (!closeEvent.wasClean && openTimestamp) {\n // report deaths only for short-living transport\n var lifespan = Util.now() - openTimestamp;\n if (lifespan < 2 * this.maxPingDelay) {\n this.manager.reportDeath();\n this.pingDelay = Math.max(lifespan / 2, this.minPingDelay);\n }\n }\n };\n\n connection.bind('open', onOpen);\n return connection;\n }\n\n /** Returns whether the transport is supported in the environment.\n *\n * This function has the same API as Transport#isSupported. Might return false\n * when the manager decides to kill the transport.\n *\n * @param {Object} environment the environment details (encryption, settings)\n * @returns {Boolean} true when the transport is supported\n */\n isSupported(environment: string): boolean {\n return this.manager.isAlive() && this.transport.isSupported(environment);\n }\n}\n","import Action from './action';\nimport { PusherEvent } from './message-types';\n/**\n * Provides functions for handling Pusher protocol-specific messages.\n */\n\nconst Protocol = {\n /**\n * Decodes a message in a Pusher format.\n *\n * The MessageEvent we receive from the transport should contain a pusher event\n * (https://pusher.com/docs/pusher_protocol#events) serialized as JSON in the\n * data field\n *\n * The pusher event may contain a data field too, and it may also be\n * serialised as JSON\n *\n * Throws errors when messages are not parse'able.\n *\n * @param {MessageEvent} messageEvent\n * @return {PusherEvent}\n */\n decodeMessage: function(messageEvent: MessageEvent): PusherEvent {\n try {\n var messageData = JSON.parse(messageEvent.data);\n var pusherEventData = messageData.data;\n if (typeof pusherEventData === 'string') {\n try {\n pusherEventData = JSON.parse(messageData.data);\n } catch (e) {}\n }\n var pusherEvent: PusherEvent = {\n event: messageData.event,\n channel: messageData.channel,\n data: pusherEventData\n };\n if (messageData.user_id) {\n pusherEvent.user_id = messageData.user_id;\n }\n return pusherEvent;\n } catch (e) {\n throw { type: 'MessageParseError', error: e, data: messageEvent.data };\n }\n },\n\n /**\n * Encodes a message to be sent.\n *\n * @param {PusherEvent} event\n * @return {String}\n */\n encodeMessage: function(event: PusherEvent): string {\n return JSON.stringify(event);\n },\n\n /**\n * Processes a handshake message and returns appropriate actions.\n *\n * Returns an object with an 'action' and other action-specific properties.\n *\n * There are three outcomes when calling this function. First is a successful\n * connection attempt, when pusher:connection_established is received, which\n * results in a 'connected' action with an 'id' property. When passed a\n * pusher:error event, it returns a result with action appropriate to the\n * close code and an error. Otherwise, it raises an exception.\n *\n * @param {String} message\n * @result Object\n */\n processHandshake: function(messageEvent: MessageEvent): Action {\n var message = Protocol.decodeMessage(messageEvent);\n\n if (message.event === 'pusher:connection_established') {\n if (!message.data.activity_timeout) {\n throw 'No activity timeout specified in handshake';\n }\n return {\n action: 'connected',\n id: message.data.socket_id,\n activityTimeout: message.data.activity_timeout * 1000\n };\n } else if (message.event === 'pusher:error') {\n // From protocol 6 close codes are sent only once, so this only\n // happens when connection does not support close codes\n return {\n action: this.getCloseAction(message.data),\n error: this.getCloseError(message.data)\n };\n } else {\n throw 'Invalid handshake';\n }\n },\n\n /**\n * Dispatches the close event and returns an appropriate action name.\n *\n * See:\n * 1. https://developer.mozilla.org/en-US/docs/WebSockets/WebSockets_reference/CloseEvent\n * 2. http://pusher.com/docs/pusher_protocol\n *\n * @param {CloseEvent} closeEvent\n * @return {String} close action name\n */\n getCloseAction: function(closeEvent): string {\n if (closeEvent.code < 4000) {\n // ignore 1000 CLOSE_NORMAL, 1001 CLOSE_GOING_AWAY,\n // 1005 CLOSE_NO_STATUS, 1006 CLOSE_ABNORMAL\n // ignore 1007...3999\n // handle 1002 CLOSE_PROTOCOL_ERROR, 1003 CLOSE_UNSUPPORTED,\n // 1004 CLOSE_TOO_LARGE\n if (closeEvent.code >= 1002 && closeEvent.code <= 1004) {\n return 'backoff';\n } else {\n return null;\n }\n } else if (closeEvent.code === 4000) {\n return 'tls_only';\n } else if (closeEvent.code < 4100) {\n return 'refused';\n } else if (closeEvent.code < 4200) {\n return 'backoff';\n } else if (closeEvent.code < 4300) {\n return 'retry';\n } else {\n // unknown error\n return 'refused';\n }\n },\n\n /**\n * Returns an error or null basing on the close event.\n *\n * Null is returned when connection was closed cleanly. Otherwise, an object\n * with error details is returned.\n *\n * @param {CloseEvent} closeEvent\n * @return {Object} error object\n */\n getCloseError: function(closeEvent): any {\n if (closeEvent.code !== 1000 && closeEvent.code !== 1001) {\n return {\n type: 'PusherError',\n data: {\n code: closeEvent.code,\n message: closeEvent.reason || closeEvent.message\n }\n };\n } else {\n return null;\n }\n }\n};\n\nexport default Protocol;\n","import * as Collections from '../utils/collections';\nimport { default as EventsDispatcher } from '../events/dispatcher';\nimport Protocol from './protocol/protocol';\nimport { PusherEvent } from './protocol/message-types';\nimport Logger from '../logger';\nimport TransportConnection from '../transports/transport_connection';\nimport Socket from '../socket';\n/**\n * Provides Pusher protocol interface for transports.\n *\n * Emits following events:\n * - message - on received messages\n * - ping - on ping requests\n * - pong - on pong responses\n * - error - when the transport emits an error\n * - closed - after closing the transport\n *\n * It also emits more events when connection closes with a code.\n * See Protocol.getCloseAction to get more details.\n *\n * @param {Number} id\n * @param {AbstractTransport} transport\n */\nexport default class Connection extends EventsDispatcher implements Socket {\n id: string;\n transport: TransportConnection;\n activityTimeout: number;\n\n constructor(id: string, transport: TransportConnection) {\n super();\n this.id = id;\n this.transport = transport;\n this.activityTimeout = transport.activityTimeout;\n this.bindListeners();\n }\n\n /** Returns whether used transport handles activity checks by itself\n *\n * @returns {Boolean} true if activity checks are handled by the transport\n */\n handlesActivityChecks() {\n return this.transport.handlesActivityChecks();\n }\n\n /** Sends raw data.\n *\n * @param {String} data\n */\n send(data: any): boolean {\n return this.transport.send(data);\n }\n\n /** Sends an event.\n *\n * @param {String} name\n * @param {String} data\n * @param {String} [channel]\n * @returns {Boolean} whether message was sent or not\n */\n send_event(name: string, data: any, channel?: string): boolean {\n var event: PusherEvent = { event: name, data: data };\n if (channel) {\n event.channel = channel;\n }\n Logger.debug('Event sent', event);\n return this.send(Protocol.encodeMessage(event));\n }\n\n /** Sends a ping message to the server.\n *\n * Basing on the underlying transport, it might send either transport's\n * protocol-specific ping or pusher:ping event.\n */\n ping() {\n if (this.transport.supportsPing()) {\n this.transport.ping();\n } else {\n this.send_event('pusher:ping', {});\n }\n }\n\n /** Closes the connection. */\n close() {\n this.transport.close();\n }\n\n private bindListeners() {\n var listeners = {\n message: (messageEvent: MessageEvent) => {\n var pusherEvent;\n try {\n pusherEvent = Protocol.decodeMessage(messageEvent);\n } catch (e) {\n this.emit('error', {\n type: 'MessageParseError',\n error: e,\n data: messageEvent.data\n });\n }\n\n if (pusherEvent !== undefined) {\n Logger.debug('Event recd', pusherEvent);\n\n switch (pusherEvent.event) {\n case 'pusher:error':\n this.emit('error', {\n type: 'PusherError',\n data: pusherEvent.data\n });\n break;\n case 'pusher:ping':\n this.emit('ping');\n break;\n case 'pusher:pong':\n this.emit('pong');\n break;\n }\n this.emit('message', pusherEvent);\n }\n },\n activity: () => {\n this.emit('activity');\n },\n error: error => {\n this.emit('error', error);\n },\n closed: closeEvent => {\n unbindListeners();\n\n if (closeEvent && closeEvent.code) {\n this.handleCloseEvent(closeEvent);\n }\n\n this.transport = null;\n this.emit('closed');\n }\n };\n\n var unbindListeners = () => {\n Collections.objectApply(listeners, (listener, event) => {\n this.transport.unbind(event, listener);\n });\n };\n\n Collections.objectApply(listeners, (listener, event) => {\n this.transport.bind(event, listener);\n });\n }\n\n private handleCloseEvent(closeEvent: any) {\n var action = Protocol.getCloseAction(closeEvent);\n var error = Protocol.getCloseError(closeEvent);\n if (error) {\n this.emit('error', error);\n }\n if (action) {\n this.emit(action, { action: action, error: error });\n }\n }\n}\n","import Util from '../../util';\nimport * as Collections from '../../utils/collections';\nimport Protocol from '../protocol/protocol';\nimport Connection from '../connection';\nimport TransportConnection from '../../transports/transport_connection';\nimport HandshakePayload from './handshake_payload';\n\n/**\n * Handles Pusher protocol handshakes for transports.\n *\n * Calls back with a result object after handshake is completed. Results\n * always have two fields:\n * - action - string describing action to be taken after the handshake\n * - transport - the transport object passed to the constructor\n *\n * Different actions can set different additional properties on the result.\n * In the case of 'connected' action, there will be a 'connection' property\n * containing a Connection object for the transport. Other actions should\n * carry an 'error' property.\n *\n * @param {AbstractTransport} transport\n * @param {Function} callback\n */\nexport default class Handshake {\n transport: TransportConnection;\n callback: (HandshakePayload) => void;\n onMessage: Function;\n onClosed: Function;\n\n constructor(\n transport: TransportConnection,\n callback: (HandshakePayload) => void\n ) {\n this.transport = transport;\n this.callback = callback;\n this.bindListeners();\n }\n\n close() {\n this.unbindListeners();\n this.transport.close();\n }\n\n private bindListeners() {\n this.onMessage = m => {\n this.unbindListeners();\n\n var result;\n try {\n result = Protocol.processHandshake(m);\n } catch (e) {\n this.finish('error', { error: e });\n this.transport.close();\n return;\n }\n\n if (result.action === 'connected') {\n this.finish('connected', {\n connection: new Connection(result.id, this.transport),\n activityTimeout: result.activityTimeout\n });\n } else {\n this.finish(result.action, { error: result.error });\n this.transport.close();\n }\n };\n\n this.onClosed = closeEvent => {\n this.unbindListeners();\n\n var action = Protocol.getCloseAction(closeEvent) || 'backoff';\n var error = Protocol.getCloseError(closeEvent);\n this.finish(action, { error: error });\n };\n\n this.transport.bind('message', this.onMessage);\n this.transport.bind('closed', this.onClosed);\n }\n\n private unbindListeners() {\n this.transport.unbind('message', this.onMessage);\n this.transport.unbind('closed', this.onClosed);\n }\n\n private finish(action: string, params: any) {\n this.callback(\n Collections.extend({ transport: this.transport, action: action }, params)\n );\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport base64encode from '../base64';\nimport Timeline from './timeline';\nimport Runtime from 'runtime';\n\nexport interface TimelineSenderOptions {\n host?: string;\n port?: number;\n path?: string;\n}\n\nexport default class TimelineSender {\n timeline: Timeline;\n options: TimelineSenderOptions;\n host: string;\n\n constructor(timeline: Timeline, options: TimelineSenderOptions) {\n this.timeline = timeline;\n this.options = options || {};\n }\n\n send(useTLS: boolean, callback?: Function) {\n if (this.timeline.isEmpty()) {\n return;\n }\n\n this.timeline.send(\n Runtime.TimelineTransport.getAgent(this, useTLS),\n callback\n );\n }\n}\n","/** Error classes used throughout the library. */\n// https://github.com/Microsoft/TypeScript-wiki/blob/master/Breaking-Changes.md#extending-built-ins-like-error-array-and-map-may-no-longer-work\nexport class BadEventName extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\nexport class BadChannelName extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\nexport class RequestTimedOut extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class TransportPriorityTooLow extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class TransportClosed extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class UnsupportedFeature extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class UnsupportedTransport extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class UnsupportedStrategy extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class HTTPAuthError extends Error {\n status: number;\n constructor(status: number, msg?: string) {\n super(msg);\n this.status = status;\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n","/**\n * A place to store help URLs for error messages etc\n */\n\nconst urlStore = {\n baseUrl: 'https://pusher.com',\n urls: {\n authenticationEndpoint: {\n path: '/docs/channels/server_api/authenticating_users'\n },\n authorizationEndpoint: {\n path: '/docs/channels/server_api/authorizing-users/'\n },\n javascriptQuickStart: {\n path: '/docs/javascript_quick_start'\n },\n triggeringClientEvents: {\n path: '/docs/client_api_guide/client_events#trigger-events'\n },\n encryptedChannelSupport: {\n fullUrl:\n 'https://github.com/pusher/pusher-js/tree/cc491015371a4bde5743d1c87a0fbac0feb53195#encrypted-channel-support'\n }\n }\n};\n\n/** Builds a consistent string with links to pusher documentation\n *\n * @param {string} key - relevant key in the url_store.urls object\n * @return {string} suffix string to append to log message\n */\nconst buildLogSuffix = function(key: string): string {\n const urlPrefix = 'See:';\n const urlObj = urlStore.urls[key];\n if (!urlObj) return '';\n\n let url;\n if (urlObj.fullUrl) {\n url = urlObj.fullUrl;\n } else if (urlObj.path) {\n url = urlStore.baseUrl + urlObj.path;\n }\n\n if (!url) return '';\n return `${urlPrefix} ${url}`;\n};\n\nexport default { buildLogSuffix };\n","import { default as EventsDispatcher } from '../events/dispatcher';\nimport * as Errors from '../errors';\nimport Logger from '../logger';\nimport Pusher from '../pusher';\nimport { PusherEvent } from '../connection/protocol/message-types';\nimport Metadata from './metadata';\nimport UrlStore from '../utils/url_store';\nimport {\n ChannelAuthorizationData,\n ChannelAuthorizationCallback\n} from '../auth/options';\nimport { HTTPAuthError } from '../errors';\n\n/** Provides base public channel interface with an event emitter.\n *\n * Emits:\n * - pusher:subscription_succeeded - after subscribing successfully\n * - other non-internal events\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\nexport default class Channel extends EventsDispatcher {\n name: string;\n pusher: Pusher;\n subscribed: boolean;\n subscriptionPending: boolean;\n subscriptionCancelled: boolean;\n subscriptionCount: null;\n\n constructor(name: string, pusher: Pusher) {\n super(function(event, data) {\n Logger.debug('No callbacks on ' + name + ' for ' + event);\n });\n\n this.name = name;\n this.pusher = pusher;\n this.subscribed = false;\n this.subscriptionPending = false;\n this.subscriptionCancelled = false;\n }\n\n /** Skips authorization, since public channels don't require it.\n *\n * @param {Function} callback\n */\n authorize(socketId: string, callback: ChannelAuthorizationCallback) {\n return callback(null, { auth: '' });\n }\n\n /** Triggers an event */\n trigger(event: string, data: any) {\n if (event.indexOf('client-') !== 0) {\n throw new Errors.BadEventName(\n \"Event '\" + event + \"' does not start with 'client-'\"\n );\n }\n if (!this.subscribed) {\n var suffix = UrlStore.buildLogSuffix('triggeringClientEvents');\n Logger.warn(\n `Client event triggered before channel 'subscription_succeeded' event . ${suffix}`\n );\n }\n return this.pusher.send_event(event, data, this.name);\n }\n\n /** Signals disconnection to the channel. For internal use only. */\n disconnect() {\n this.subscribed = false;\n this.subscriptionPending = false;\n }\n\n /** Handles a PusherEvent. For internal use only.\n *\n * @param {PusherEvent} event\n */\n handleEvent(event: PusherEvent) {\n var eventName = event.event;\n var data = event.data;\n if (eventName === 'pusher_internal:subscription_succeeded') {\n this.handleSubscriptionSucceededEvent(event);\n } else if (eventName === 'pusher_internal:subscription_count') {\n this.handleSubscriptionCountEvent(event);\n } else if (eventName.indexOf('pusher_internal:') !== 0) {\n var metadata: Metadata = {};\n this.emit(eventName, data, metadata);\n }\n }\n\n handleSubscriptionSucceededEvent(event: PusherEvent) {\n this.subscriptionPending = false;\n this.subscribed = true;\n if (this.subscriptionCancelled) {\n this.pusher.unsubscribe(this.name);\n } else {\n this.emit('pusher:subscription_succeeded', event.data);\n }\n }\n\n handleSubscriptionCountEvent(event: PusherEvent) {\n if (event.data.subscription_count) {\n this.subscriptionCount = event.data.subscription_count;\n }\n\n this.emit('pusher:subscription_count', event.data);\n }\n\n /** Sends a subscription request. For internal use only. */\n subscribe() {\n if (this.subscribed) {\n return;\n }\n this.subscriptionPending = true;\n this.subscriptionCancelled = false;\n this.authorize(\n this.pusher.connection.socket_id,\n (error: Error | null, data: ChannelAuthorizationData) => {\n if (error) {\n this.subscriptionPending = false;\n // Why not bind to 'pusher:subscription_error' a level up, and log there?\n // Binding to this event would cause the warning about no callbacks being\n // bound (see constructor) to be suppressed, that's not what we want.\n Logger.error(error.toString());\n this.emit(\n 'pusher:subscription_error',\n Object.assign(\n {},\n {\n type: 'AuthError',\n error: error.message\n },\n error instanceof HTTPAuthError ? { status: error.status } : {}\n )\n );\n } else {\n this.pusher.send_event('pusher:subscribe', {\n auth: data.auth,\n channel_data: data.channel_data,\n channel: this.name\n });\n }\n }\n );\n }\n\n /** Sends an unsubscription request. For internal use only. */\n unsubscribe() {\n this.subscribed = false;\n this.pusher.send_event('pusher:unsubscribe', {\n channel: this.name\n });\n }\n\n /** Cancels an in progress subscription. For internal use only. */\n cancelSubscription() {\n this.subscriptionCancelled = true;\n }\n\n /** Reinstates an in progress subscripiton. For internal use only. */\n reinstateSubscription() {\n this.subscriptionCancelled = false;\n }\n}\n","import Factory from '../utils/factory';\nimport Channel from './channel';\nimport { ChannelAuthorizationCallback } from '../auth/options';\n\n/** Extends public channels to provide private channel interface.\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\nexport default class PrivateChannel extends Channel {\n /** Authorizes the connection to use the channel.\n *\n * @param {String} socketId\n * @param {Function} callback\n */\n authorize(socketId: string, callback: ChannelAuthorizationCallback) {\n return this.pusher.config.channelAuthorizer(\n {\n channelName: this.name,\n socketId: socketId\n },\n callback\n );\n }\n}\n","import * as Collections from '../utils/collections';\n\n/** Represents a collection of members of a presence channel. */\nexport default class Members {\n members: any;\n count: number;\n myID: any;\n me: any;\n\n constructor() {\n this.reset();\n }\n\n /** Returns member's info for given id.\n *\n * Resulting object containts two fields - id and info.\n *\n * @param {Number} id\n * @return {Object} member's info or null\n */\n get(id: string): any {\n if (Object.prototype.hasOwnProperty.call(this.members, id)) {\n return {\n id: id,\n info: this.members[id]\n };\n } else {\n return null;\n }\n }\n\n /** Calls back for each member in unspecified order.\n *\n * @param {Function} callback\n */\n each(callback: Function) {\n Collections.objectApply(this.members, (member, id) => {\n callback(this.get(id));\n });\n }\n\n /** Updates the id for connected member. For internal use only. */\n setMyID(id: string) {\n this.myID = id;\n }\n\n /** Handles subscription data. For internal use only. */\n onSubscription(subscriptionData: any) {\n this.members = subscriptionData.presence.hash;\n this.count = subscriptionData.presence.count;\n this.me = this.get(this.myID);\n }\n\n /** Adds a new member to the collection. For internal use only. */\n addMember(memberData: any) {\n if (this.get(memberData.user_id) === null) {\n this.count++;\n }\n this.members[memberData.user_id] = memberData.user_info;\n return this.get(memberData.user_id);\n }\n\n /** Adds a member from the collection. For internal use only. */\n removeMember(memberData: any) {\n var member = this.get(memberData.user_id);\n if (member) {\n delete this.members[memberData.user_id];\n this.count--;\n }\n return member;\n }\n\n /** Resets the collection to the initial state. For internal use only. */\n reset() {\n this.members = {};\n this.count = 0;\n this.myID = null;\n this.me = null;\n }\n}\n","import PrivateChannel from './private_channel';\nimport Logger from '../logger';\nimport Members from './members';\nimport Pusher from '../pusher';\nimport UrlStore from 'core/utils/url_store';\nimport { PusherEvent } from '../connection/protocol/message-types';\nimport Metadata from './metadata';\nimport { ChannelAuthorizationData } from '../auth/options';\n\nexport default class PresenceChannel extends PrivateChannel {\n members: Members;\n\n /** Adds presence channel functionality to private channels.\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\n constructor(name: string, pusher: Pusher) {\n super(name, pusher);\n this.members = new Members();\n }\n\n /** Authorizes the connection as a member of the channel.\n *\n * @param {String} socketId\n * @param {Function} callback\n */\n authorize(socketId: string, callback: Function) {\n super.authorize(socketId, async (error, authData) => {\n if (!error) {\n authData = authData as ChannelAuthorizationData;\n if (authData.channel_data != null) {\n var channelData = JSON.parse(authData.channel_data);\n this.members.setMyID(channelData.user_id);\n } else {\n await this.pusher.user.signinDonePromise;\n if (this.pusher.user.user_data != null) {\n // If the user is signed in, get the id of the authenticated user\n // and allow the presence authorization to continue.\n this.members.setMyID(this.pusher.user.user_data.id);\n } else {\n let suffix = UrlStore.buildLogSuffix('authorizationEndpoint');\n Logger.error(\n `Invalid auth response for channel '${this.name}', ` +\n `expected 'channel_data' field. ${suffix}, ` +\n `or the user should be signed in.`\n );\n callback('Invalid auth response');\n return;\n }\n }\n }\n callback(error, authData);\n });\n }\n\n /** Handles presence and subscription events. For internal use only.\n *\n * @param {PusherEvent} event\n */\n handleEvent(event: PusherEvent) {\n var eventName = event.event;\n if (eventName.indexOf('pusher_internal:') === 0) {\n this.handleInternalEvent(event);\n } else {\n var data = event.data;\n var metadata: Metadata = {};\n if (event.user_id) {\n metadata.user_id = event.user_id;\n }\n this.emit(eventName, data, metadata);\n }\n }\n handleInternalEvent(event: PusherEvent) {\n var eventName = event.event;\n var data = event.data;\n switch (eventName) {\n case 'pusher_internal:subscription_succeeded':\n this.handleSubscriptionSucceededEvent(event);\n break;\n case 'pusher_internal:subscription_count':\n this.handleSubscriptionCountEvent(event);\n break;\n case 'pusher_internal:member_added':\n var addedMember = this.members.addMember(data);\n this.emit('pusher:member_added', addedMember);\n break;\n case 'pusher_internal:member_removed':\n var removedMember = this.members.removeMember(data);\n if (removedMember) {\n this.emit('pusher:member_removed', removedMember);\n }\n break;\n }\n }\n\n handleSubscriptionSucceededEvent(event: PusherEvent) {\n this.subscriptionPending = false;\n this.subscribed = true;\n if (this.subscriptionCancelled) {\n this.pusher.unsubscribe(this.name);\n } else {\n this.members.onSubscription(event.data);\n this.emit('pusher:subscription_succeeded', this.members);\n }\n }\n\n /** Resets the channel state, including members map. For internal use only. */\n disconnect() {\n this.members.reset();\n super.disconnect();\n }\n}\n","import PrivateChannel from './private_channel';\nimport * as Errors from '../errors';\nimport Logger from '../logger';\nimport Pusher from '../pusher';\nimport { decode as encodeUTF8 } from '@stablelib/utf8';\nimport { decode as decodeBase64 } from '@stablelib/base64';\nimport Dispatcher from '../events/dispatcher';\nimport { PusherEvent } from '../connection/protocol/message-types';\nimport {\n ChannelAuthorizationData,\n ChannelAuthorizationCallback\n} from '../auth/options';\nimport * as nacl from 'tweetnacl';\n\n/** Extends private channels to provide encrypted channel interface.\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\nexport default class EncryptedChannel extends PrivateChannel {\n key: Uint8Array = null;\n nacl: nacl;\n\n constructor(name: string, pusher: Pusher, nacl: nacl) {\n super(name, pusher);\n this.nacl = nacl;\n }\n\n /** Authorizes the connection to use the channel.\n *\n * @param {String} socketId\n * @param {Function} callback\n */\n authorize(socketId: string, callback: ChannelAuthorizationCallback) {\n super.authorize(\n socketId,\n (error: Error | null, authData: ChannelAuthorizationData) => {\n if (error) {\n callback(error, authData);\n return;\n }\n let sharedSecret = authData['shared_secret'];\n if (!sharedSecret) {\n callback(\n new Error(\n `No shared_secret key in auth payload for encrypted channel: ${this.name}`\n ),\n null\n );\n return;\n }\n this.key = decodeBase64(sharedSecret);\n delete authData['shared_secret'];\n callback(null, authData);\n }\n );\n }\n\n trigger(event: string, data: any): boolean {\n throw new Errors.UnsupportedFeature(\n 'Client events are not currently supported for encrypted channels'\n );\n }\n\n /** Handles an event. For internal use only.\n *\n * @param {PusherEvent} event\n */\n handleEvent(event: PusherEvent) {\n var eventName = event.event;\n var data = event.data;\n if (\n eventName.indexOf('pusher_internal:') === 0 ||\n eventName.indexOf('pusher:') === 0\n ) {\n super.handleEvent(event);\n return;\n }\n this.handleEncryptedEvent(eventName, data);\n }\n\n private handleEncryptedEvent(event: string, data: any): void {\n if (!this.key) {\n Logger.debug(\n 'Received encrypted event before key has been retrieved from the authEndpoint'\n );\n return;\n }\n if (!data.ciphertext || !data.nonce) {\n Logger.error(\n 'Unexpected format for encrypted event, expected object with `ciphertext` and `nonce` fields, got: ' +\n data\n );\n return;\n }\n let cipherText = decodeBase64(data.ciphertext);\n if (cipherText.length < this.nacl.secretbox.overheadLength) {\n Logger.error(\n `Expected encrypted event ciphertext length to be ${this.nacl.secretbox.overheadLength}, got: ${cipherText.length}`\n );\n return;\n }\n let nonce = decodeBase64(data.nonce);\n if (nonce.length < this.nacl.secretbox.nonceLength) {\n Logger.error(\n `Expected encrypted event nonce length to be ${this.nacl.secretbox.nonceLength}, got: ${nonce.length}`\n );\n return;\n }\n\n let bytes = this.nacl.secretbox.open(cipherText, nonce, this.key);\n if (bytes === null) {\n Logger.debug(\n 'Failed to decrypt an event, probably because it was encrypted with a different key. Fetching a new key from the authEndpoint...'\n );\n // Try a single time to retrieve a new auth key and decrypt the event with it\n // If this fails, a new key will be requested when a new message is received\n this.authorize(this.pusher.connection.socket_id, (error, authData) => {\n if (error) {\n Logger.error(\n `Failed to make a request to the authEndpoint: ${authData}. Unable to fetch new key, so dropping encrypted event`\n );\n return;\n }\n bytes = this.nacl.secretbox.open(cipherText, nonce, this.key);\n if (bytes === null) {\n Logger.error(\n `Failed to decrypt event with new key. Dropping encrypted event`\n );\n return;\n }\n this.emit(event, this.getDataToEmit(bytes));\n return;\n });\n return;\n }\n this.emit(event, this.getDataToEmit(bytes));\n }\n\n // Try and parse the decrypted bytes as JSON. If we can't parse it, just\n // return the utf-8 string\n getDataToEmit(bytes: Uint8Array): string {\n let raw = encodeUTF8(bytes);\n try {\n return JSON.parse(raw);\n } catch {\n return raw;\n }\n }\n}\n","import { default as EventsDispatcher } from '../events/dispatcher';\nimport { OneOffTimer as Timer } from '../utils/timers';\nimport { Config } from '../config';\nimport Logger from '../logger';\nimport HandshakePayload from './handshake/handshake_payload';\nimport Connection from './connection';\nimport Strategy from '../strategies/strategy';\nimport StrategyRunner from '../strategies/strategy_runner';\nimport * as Collections from '../utils/collections';\nimport Timeline from '../timeline/timeline';\nimport ConnectionManagerOptions from './connection_manager_options';\nimport Runtime from 'runtime';\n\nimport {\n ErrorCallbacks,\n HandshakeCallbacks,\n ConnectionCallbacks\n} from './callbacks';\nimport Action from './protocol/action';\n\n/** Manages connection to Pusher.\n *\n * Uses a strategy (currently only default), timers and network availability\n * info to establish a connection and export its state. In case of failures,\n * manages reconnection attempts.\n *\n * Exports state changes as following events:\n * - \"state_change\", { previous: p, current: state }\n * - state\n *\n * States:\n * - initialized - initial state, never transitioned to\n * - connecting - connection is being established\n * - connected - connection has been fully established\n * - disconnected - on requested disconnection\n * - unavailable - after connection timeout or when there's no network\n * - failed - when the connection strategy is not supported\n *\n * Options:\n * - unavailableTimeout - time to transition to unavailable state\n * - activityTimeout - time after which ping message should be sent\n * - pongTimeout - time for Pusher to respond with pong before reconnecting\n *\n * @param {String} key application key\n * @param {Object} options\n */\nexport default class ConnectionManager extends EventsDispatcher {\n key: string;\n options: ConnectionManagerOptions;\n state: string;\n connection: Connection;\n usingTLS: boolean;\n timeline: Timeline;\n socket_id: string;\n unavailableTimer: Timer;\n activityTimer: Timer;\n retryTimer: Timer;\n activityTimeout: number;\n strategy: Strategy;\n runner: StrategyRunner;\n errorCallbacks: ErrorCallbacks;\n handshakeCallbacks: HandshakeCallbacks;\n connectionCallbacks: ConnectionCallbacks;\n\n constructor(key: string, options: ConnectionManagerOptions) {\n super();\n this.state = 'initialized';\n this.connection = null;\n\n this.key = key;\n this.options = options;\n this.timeline = this.options.timeline;\n this.usingTLS = this.options.useTLS;\n\n this.errorCallbacks = this.buildErrorCallbacks();\n this.connectionCallbacks = this.buildConnectionCallbacks(\n this.errorCallbacks\n );\n this.handshakeCallbacks = this.buildHandshakeCallbacks(this.errorCallbacks);\n\n var Network = Runtime.getNetwork();\n\n Network.bind('online', () => {\n this.timeline.info({ netinfo: 'online' });\n if (this.state === 'connecting' || this.state === 'unavailable') {\n this.retryIn(0);\n }\n });\n Network.bind('offline', () => {\n this.timeline.info({ netinfo: 'offline' });\n if (this.connection) {\n this.sendActivityCheck();\n }\n });\n\n this.updateStrategy();\n }\n\n switchCluster(key: string) {\n this.key = key;\n // This ensures that the new config coming from\n // pusher instance are taken into account\n // such as appKey and cluster\n this.updateStrategy();\n this.retryIn(0);\n }\n\n /** Establishes a connection to Pusher.\n *\n * Does nothing when connection is already established. See top-level doc\n * to find events emitted on connection attempts.\n */\n connect() {\n if (this.connection || this.runner) {\n return;\n }\n if (!this.strategy.isSupported()) {\n this.updateState('failed');\n return;\n }\n this.updateState('connecting');\n this.startConnecting();\n this.setUnavailableTimer();\n }\n\n /** Sends raw data.\n *\n * @param {String} data\n */\n send(data) {\n if (this.connection) {\n return this.connection.send(data);\n } else {\n return false;\n }\n }\n\n /** Sends an event.\n *\n * @param {String} name\n * @param {String} data\n * @param {String} [channel]\n * @returns {Boolean} whether message was sent or not\n */\n send_event(name: string, data: any, channel?: string) {\n if (this.connection) {\n return this.connection.send_event(name, data, channel);\n } else {\n return false;\n }\n }\n\n /** Closes the connection. */\n disconnect() {\n this.disconnectInternally();\n this.updateState('disconnected');\n }\n\n isUsingTLS() {\n return this.usingTLS;\n }\n\n private startConnecting() {\n var callback = (error, handshake) => {\n if (error) {\n this.runner = this.strategy.connect(0, callback);\n } else {\n if (handshake.action === 'error') {\n this.emit('error', {\n type: 'HandshakeError',\n error: handshake.error\n });\n this.timeline.error({ handshakeError: handshake.error });\n } else {\n this.abortConnecting(); // we don't support switching connections yet\n this.handshakeCallbacks[handshake.action](handshake);\n }\n }\n };\n this.runner = this.strategy.connect(0, callback);\n }\n\n private abortConnecting() {\n if (this.runner) {\n this.runner.abort();\n this.runner = null;\n }\n }\n\n private disconnectInternally() {\n this.abortConnecting();\n this.clearRetryTimer();\n this.clearUnavailableTimer();\n if (this.connection) {\n var connection = this.abandonConnection();\n connection.close();\n }\n }\n\n private updateStrategy() {\n this.strategy = this.options.getStrategy({\n key: this.key,\n timeline: this.timeline,\n useTLS: this.usingTLS\n });\n }\n\n private retryIn(delay) {\n this.timeline.info({ action: 'retry', delay: delay });\n if (delay > 0) {\n this.emit('connecting_in', Math.round(delay / 1000));\n }\n this.retryTimer = new Timer(delay || 0, () => {\n this.disconnectInternally();\n this.connect();\n });\n }\n\n private clearRetryTimer() {\n if (this.retryTimer) {\n this.retryTimer.ensureAborted();\n this.retryTimer = null;\n }\n }\n\n private setUnavailableTimer() {\n this.unavailableTimer = new Timer(this.options.unavailableTimeout, () => {\n this.updateState('unavailable');\n });\n }\n\n private clearUnavailableTimer() {\n if (this.unavailableTimer) {\n this.unavailableTimer.ensureAborted();\n }\n }\n\n private sendActivityCheck() {\n this.stopActivityCheck();\n this.connection.ping();\n // wait for pong response\n this.activityTimer = new Timer(this.options.pongTimeout, () => {\n this.timeline.error({ pong_timed_out: this.options.pongTimeout });\n this.retryIn(0);\n });\n }\n\n private resetActivityCheck() {\n this.stopActivityCheck();\n // send ping after inactivity\n if (this.connection && !this.connection.handlesActivityChecks()) {\n this.activityTimer = new Timer(this.activityTimeout, () => {\n this.sendActivityCheck();\n });\n }\n }\n\n private stopActivityCheck() {\n if (this.activityTimer) {\n this.activityTimer.ensureAborted();\n }\n }\n\n private buildConnectionCallbacks(\n errorCallbacks: ErrorCallbacks\n ): ConnectionCallbacks {\n return Collections.extend({}, errorCallbacks, {\n message: message => {\n // includes pong messages from server\n this.resetActivityCheck();\n this.emit('message', message);\n },\n ping: () => {\n this.send_event('pusher:pong', {});\n },\n activity: () => {\n this.resetActivityCheck();\n },\n error: error => {\n // just emit error to user - socket will already be closed by browser\n this.emit('error', error);\n },\n closed: () => {\n this.abandonConnection();\n if (this.shouldRetry()) {\n this.retryIn(1000);\n }\n }\n });\n }\n\n private buildHandshakeCallbacks(\n errorCallbacks: ErrorCallbacks\n ): HandshakeCallbacks {\n return Collections.extend({}, errorCallbacks, {\n connected: (handshake: HandshakePayload) => {\n this.activityTimeout = Math.min(\n this.options.activityTimeout,\n handshake.activityTimeout,\n handshake.connection.activityTimeout || Infinity\n );\n this.clearUnavailableTimer();\n this.setConnection(handshake.connection);\n this.socket_id = this.connection.id;\n this.updateState('connected', { socket_id: this.socket_id });\n }\n });\n }\n\n private buildErrorCallbacks(): ErrorCallbacks {\n let withErrorEmitted = callback => {\n return (result: Action | HandshakePayload) => {\n if (result.error) {\n this.emit('error', { type: 'WebSocketError', error: result.error });\n }\n callback(result);\n };\n };\n\n return {\n tls_only: withErrorEmitted(() => {\n this.usingTLS = true;\n this.updateStrategy();\n this.retryIn(0);\n }),\n refused: withErrorEmitted(() => {\n this.disconnect();\n }),\n backoff: withErrorEmitted(() => {\n this.retryIn(1000);\n }),\n retry: withErrorEmitted(() => {\n this.retryIn(0);\n })\n };\n }\n\n private setConnection(connection) {\n this.connection = connection;\n for (var event in this.connectionCallbacks) {\n this.connection.bind(event, this.connectionCallbacks[event]);\n }\n this.resetActivityCheck();\n }\n\n private abandonConnection() {\n if (!this.connection) {\n return;\n }\n this.stopActivityCheck();\n for (var event in this.connectionCallbacks) {\n this.connection.unbind(event, this.connectionCallbacks[event]);\n }\n var connection = this.connection;\n this.connection = null;\n return connection;\n }\n\n private updateState(newState: string, data?: any) {\n var previousState = this.state;\n this.state = newState;\n if (previousState !== newState) {\n var newStateDescription = newState;\n if (newStateDescription === 'connected') {\n newStateDescription += ' with new socket ID ' + data.socket_id;\n }\n Logger.debug(\n 'State changed',\n previousState + ' -> ' + newStateDescription\n );\n this.timeline.info({ state: newState, params: data });\n this.emit('state_change', { previous: previousState, current: newState });\n this.emit(newState, data);\n }\n }\n\n private shouldRetry(): boolean {\n return this.state === 'connecting' || this.state === 'connected';\n }\n}\n","import Channel from './channel';\nimport * as Collections from '../utils/collections';\nimport ChannelTable from './channel_table';\nimport Factory from '../utils/factory';\nimport Pusher from '../pusher';\nimport Logger from '../logger';\nimport * as Errors from '../errors';\nimport urlStore from '../utils/url_store';\n\n/** Handles a channel map. */\nexport default class Channels {\n channels: ChannelTable;\n\n constructor() {\n this.channels = {};\n }\n\n /** Creates or retrieves an existing channel by its name.\n *\n * @param {String} name\n * @param {Pusher} pusher\n * @return {Channel}\n */\n add(name: string, pusher: Pusher) {\n if (!this.channels[name]) {\n this.channels[name] = createChannel(name, pusher);\n }\n return this.channels[name];\n }\n\n /** Returns a list of all channels\n *\n * @return {Array}\n */\n all(): Channel[] {\n return Collections.values(this.channels);\n }\n\n /** Finds a channel by its name.\n *\n * @param {String} name\n * @return {Channel} channel or null if it doesn't exist\n */\n find(name: string) {\n return this.channels[name];\n }\n\n /** Removes a channel from the map.\n *\n * @param {String} name\n */\n remove(name: string) {\n var channel = this.channels[name];\n delete this.channels[name];\n return channel;\n }\n\n /** Proxies disconnection signal to all channels. */\n disconnect() {\n Collections.objectApply(this.channels, function(channel) {\n channel.disconnect();\n });\n }\n}\n\nfunction createChannel(name: string, pusher: Pusher): Channel {\n if (name.indexOf('private-encrypted-') === 0) {\n if (pusher.config.nacl) {\n return Factory.createEncryptedChannel(name, pusher, pusher.config.nacl);\n }\n let errMsg =\n 'Tried to subscribe to a private-encrypted- channel but no nacl implementation available';\n let suffix = urlStore.buildLogSuffix('encryptedChannelSupport');\n throw new Errors.UnsupportedFeature(`${errMsg}. ${suffix}`);\n } else if (name.indexOf('private-') === 0) {\n return Factory.createPrivateChannel(name, pusher);\n } else if (name.indexOf('presence-') === 0) {\n return Factory.createPresenceChannel(name, pusher);\n } else if (name.indexOf('#') === 0) {\n throw new Errors.BadChannelName(\n 'Cannot create a channel with name \"' + name + '\".'\n );\n } else {\n return Factory.createChannel(name, pusher);\n }\n}\n","import AssistantToTheTransportManager from '../transports/assistant_to_the_transport_manager';\nimport PingDelayOptions from '../transports/ping_delay_options';\nimport Transport from '../transports/transport';\nimport TransportManager from '../transports/transport_manager';\nimport Handshake from '../connection/handshake';\nimport TransportConnection from '../transports/transport_connection';\nimport SocketHooks from '../http/socket_hooks';\nimport HTTPSocket from '../http/http_socket';\n\nimport Timeline from '../timeline/timeline';\nimport {\n default as TimelineSender,\n TimelineSenderOptions\n} from '../timeline/timeline_sender';\nimport PresenceChannel from '../channels/presence_channel';\nimport PrivateChannel from '../channels/private_channel';\nimport EncryptedChannel from '../channels/encrypted_channel';\nimport Channel from '../channels/channel';\nimport ConnectionManager from '../connection/connection_manager';\nimport ConnectionManagerOptions from '../connection/connection_manager_options';\nimport Ajax from '../http/ajax';\nimport Channels from '../channels/channels';\nimport Pusher from '../pusher';\nimport { Config } from '../config';\nimport * as nacl from 'tweetnacl';\n\nvar Factory = {\n createChannels(): Channels {\n return new Channels();\n },\n\n createConnectionManager(\n key: string,\n options: ConnectionManagerOptions\n ): ConnectionManager {\n return new ConnectionManager(key, options);\n },\n\n createChannel(name: string, pusher: Pusher): Channel {\n return new Channel(name, pusher);\n },\n\n createPrivateChannel(name: string, pusher: Pusher): PrivateChannel {\n return new PrivateChannel(name, pusher);\n },\n\n createPresenceChannel(name: string, pusher: Pusher): PresenceChannel {\n return new PresenceChannel(name, pusher);\n },\n\n createEncryptedChannel(\n name: string,\n pusher: Pusher,\n nacl: nacl\n ): EncryptedChannel {\n return new EncryptedChannel(name, pusher, nacl);\n },\n\n createTimelineSender(timeline: Timeline, options: TimelineSenderOptions) {\n return new TimelineSender(timeline, options);\n },\n\n createHandshake(\n transport: TransportConnection,\n callback: (HandshakePayload) => void\n ): Handshake {\n return new Handshake(transport, callback);\n },\n\n createAssistantToTheTransportManager(\n manager: TransportManager,\n transport: Transport,\n options: PingDelayOptions\n ): AssistantToTheTransportManager {\n return new AssistantToTheTransportManager(manager, transport, options);\n }\n};\n\nexport default Factory;\n","import AssistantToTheTransportManager from './assistant_to_the_transport_manager';\nimport Transport from './transport';\nimport PingDelayOptions from './ping_delay_options';\nimport Factory from '../utils/factory';\n\nexport interface TransportManagerOptions extends PingDelayOptions {\n lives?: number;\n}\n\n/** Keeps track of the number of lives left for a transport.\n *\n * In the beginning of a session, transports may be assigned a number of\n * lives. When an AssistantToTheTransportManager instance reports a transport\n * connection closed uncleanly, the transport loses a life. When the number\n * of lives drops to zero, the transport gets disabled by its manager.\n *\n * @param {Object} options\n */\nexport default class TransportManager {\n options: TransportManagerOptions;\n livesLeft: number;\n\n constructor(options: TransportManagerOptions) {\n this.options = options || {};\n this.livesLeft = this.options.lives || Infinity;\n }\n\n /** Creates a assistant for the transport.\n *\n * @param {Transport} transport\n * @returns {AssistantToTheTransportManager}\n */\n getAssistant(transport: Transport): AssistantToTheTransportManager {\n return Factory.createAssistantToTheTransportManager(this, transport, {\n minPingDelay: this.options.minPingDelay,\n maxPingDelay: this.options.maxPingDelay\n });\n }\n\n /** Returns whether the transport has any lives left.\n *\n * @returns {Boolean}\n */\n isAlive(): boolean {\n return this.livesLeft > 0;\n }\n\n /** Takes one life from the transport. */\n reportDeath() {\n this.livesLeft -= 1;\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport { OneOffTimer as Timer } from '../utils/timers';\nimport Strategy from './strategy';\nimport StrategyOptions from './strategy_options';\n\n/** Loops through strategies with optional timeouts.\n *\n * Options:\n * - loop - whether it should loop through the substrategy list\n * - timeout - initial timeout for a single substrategy\n * - timeoutLimit - maximum timeout\n *\n * @param {Strategy[]} strategies\n * @param {Object} options\n */\nexport default class SequentialStrategy implements Strategy {\n strategies: Strategy[];\n loop: boolean;\n failFast: boolean;\n timeout: number;\n timeoutLimit: number;\n\n constructor(strategies: Strategy[], options: StrategyOptions) {\n this.strategies = strategies;\n this.loop = Boolean(options.loop);\n this.failFast = Boolean(options.failFast);\n this.timeout = options.timeout;\n this.timeoutLimit = options.timeoutLimit;\n }\n\n isSupported(): boolean {\n return Collections.any(this.strategies, Util.method('isSupported'));\n }\n\n connect(minPriority: number, callback: Function) {\n var strategies = this.strategies;\n var current = 0;\n var timeout = this.timeout;\n var runner = null;\n\n var tryNextStrategy = (error, handshake) => {\n if (handshake) {\n callback(null, handshake);\n } else {\n current = current + 1;\n if (this.loop) {\n current = current % strategies.length;\n }\n\n if (current < strategies.length) {\n if (timeout) {\n timeout = timeout * 2;\n if (this.timeoutLimit) {\n timeout = Math.min(timeout, this.timeoutLimit);\n }\n }\n runner = this.tryStrategy(\n strategies[current],\n minPriority,\n { timeout, failFast: this.failFast },\n tryNextStrategy\n );\n } else {\n callback(true);\n }\n }\n };\n\n runner = this.tryStrategy(\n strategies[current],\n minPriority,\n { timeout: timeout, failFast: this.failFast },\n tryNextStrategy\n );\n\n return {\n abort: function() {\n runner.abort();\n },\n forceMinPriority: function(p) {\n minPriority = p;\n if (runner) {\n runner.forceMinPriority(p);\n }\n }\n };\n }\n\n private tryStrategy(\n strategy: Strategy,\n minPriority: number,\n options: StrategyOptions,\n callback: Function\n ) {\n var timer = null;\n var runner = null;\n\n if (options.timeout > 0) {\n timer = new Timer(options.timeout, function() {\n runner.abort();\n callback(true);\n });\n }\n\n runner = strategy.connect(minPriority, function(error, handshake) {\n if (error && timer && timer.isRunning() && !options.failFast) {\n // advance to the next strategy after the timeout\n return;\n }\n if (timer) {\n timer.ensureAborted();\n }\n callback(error, handshake);\n });\n\n return {\n abort: function() {\n if (timer) {\n timer.ensureAborted();\n }\n runner.abort();\n },\n forceMinPriority: function(p) {\n runner.forceMinPriority(p);\n }\n };\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport Strategy from './strategy';\n\n/** Launches all substrategies and emits prioritized connected transports.\n *\n * @param {Array} strategies\n */\nexport default class BestConnectedEverStrategy implements Strategy {\n strategies: Strategy[];\n\n constructor(strategies: Strategy[]) {\n this.strategies = strategies;\n }\n\n isSupported(): boolean {\n return Collections.any(this.strategies, Util.method('isSupported'));\n }\n\n connect(minPriority: number, callback: Function) {\n return connect(this.strategies, minPriority, function(i, runners) {\n return function(error, handshake) {\n runners[i].error = error;\n if (error) {\n if (allRunnersFailed(runners)) {\n callback(true);\n }\n return;\n }\n Collections.apply(runners, function(runner) {\n runner.forceMinPriority(handshake.transport.priority);\n });\n callback(null, handshake);\n };\n });\n }\n}\n\n/** Connects to all strategies in parallel.\n *\n * Callback builder should be a function that takes two arguments: index\n * and a list of runners. It should return another function that will be\n * passed to the substrategy with given index. Runners can be aborted using\n * abortRunner(s) functions from this class.\n *\n * @param {Array} strategies\n * @param {Function} callbackBuilder\n * @return {Object} strategy runner\n */\nfunction connect(\n strategies: Strategy[],\n minPriority: number,\n callbackBuilder: Function\n) {\n var runners = Collections.map(strategies, function(strategy, i, _, rs) {\n return strategy.connect(minPriority, callbackBuilder(i, rs));\n });\n return {\n abort: function() {\n Collections.apply(runners, abortRunner);\n },\n forceMinPriority: function(p) {\n Collections.apply(runners, function(runner) {\n runner.forceMinPriority(p);\n });\n }\n };\n}\n\nfunction allRunnersFailed(runners): boolean {\n return Collections.all(runners, function(runner) {\n return Boolean(runner.error);\n });\n}\n\nfunction abortRunner(runner) {\n if (!runner.error && !runner.aborted) {\n runner.abort();\n runner.aborted = true;\n }\n}\n","import Util from '../util';\nimport Runtime from 'runtime';\nimport Strategy from './strategy';\nimport SequentialStrategy from './sequential_strategy';\nimport StrategyOptions from './strategy_options';\nimport TransportStrategy from './transport_strategy';\nimport Timeline from '../timeline/timeline';\nimport * as Collections from '../utils/collections';\n\nexport interface TransportStrategyDictionary {\n [key: string]: TransportStrategy;\n}\n\n/** Caches the last successful transport and, after the first few attempts,\n * uses the cached transport for subsequent attempts.\n *\n * @param {Strategy} strategy\n * @param {Object} transports\n * @param {Object} options\n */\nexport default class WebSocketPrioritizedCachedStrategy implements Strategy {\n strategy: Strategy;\n transports: TransportStrategyDictionary;\n ttl: number;\n usingTLS: boolean;\n timeline: Timeline;\n\n constructor(\n strategy: Strategy,\n transports: TransportStrategyDictionary,\n options: StrategyOptions\n ) {\n this.strategy = strategy;\n this.transports = transports;\n this.ttl = options.ttl || 1800 * 1000;\n this.usingTLS = options.useTLS;\n this.timeline = options.timeline;\n }\n\n isSupported(): boolean {\n return this.strategy.isSupported();\n }\n\n connect(minPriority: number, callback: Function) {\n var usingTLS = this.usingTLS;\n var info = fetchTransportCache(usingTLS);\n var cacheSkipCount = info && info.cacheSkipCount ? info.cacheSkipCount : 0;\n\n var strategies = [this.strategy];\n if (info && info.timestamp + this.ttl >= Util.now()) {\n var transport = this.transports[info.transport];\n if (transport) {\n if (['ws', 'wss'].includes(info.transport) || cacheSkipCount > 3) {\n this.timeline.info({\n cached: true,\n transport: info.transport,\n latency: info.latency\n });\n strategies.push(\n new SequentialStrategy([transport], {\n timeout: info.latency * 2 + 1000,\n failFast: true\n })\n );\n } else {\n cacheSkipCount++;\n }\n }\n }\n\n var startTimestamp = Util.now();\n var runner = strategies\n .pop()\n .connect(minPriority, function cb(error, handshake) {\n if (error) {\n flushTransportCache(usingTLS);\n if (strategies.length > 0) {\n startTimestamp = Util.now();\n runner = strategies.pop().connect(minPriority, cb);\n } else {\n callback(error);\n }\n } else {\n storeTransportCache(\n usingTLS,\n handshake.transport.name,\n Util.now() - startTimestamp,\n cacheSkipCount\n );\n callback(null, handshake);\n }\n });\n\n return {\n abort: function() {\n runner.abort();\n },\n forceMinPriority: function(p) {\n minPriority = p;\n if (runner) {\n runner.forceMinPriority(p);\n }\n }\n };\n }\n}\n\nfunction getTransportCacheKey(usingTLS: boolean): string {\n return 'pusherTransport' + (usingTLS ? 'TLS' : 'NonTLS');\n}\n\nfunction fetchTransportCache(usingTLS: boolean): any {\n var storage = Runtime.getLocalStorage();\n if (storage) {\n try {\n var serializedCache = storage[getTransportCacheKey(usingTLS)];\n if (serializedCache) {\n return JSON.parse(serializedCache);\n }\n } catch (e) {\n flushTransportCache(usingTLS);\n }\n }\n return null;\n}\n\nfunction storeTransportCache(\n usingTLS: boolean,\n transport: TransportStrategy,\n latency: number,\n cacheSkipCount: number\n) {\n var storage = Runtime.getLocalStorage();\n if (storage) {\n try {\n storage[getTransportCacheKey(usingTLS)] = Collections.safeJSONStringify({\n timestamp: Util.now(),\n transport: transport,\n latency: latency,\n cacheSkipCount: cacheSkipCount\n });\n } catch (e) {\n // catch over quota exceptions raised by localStorage\n }\n }\n}\n\nfunction flushTransportCache(usingTLS: boolean) {\n var storage = Runtime.getLocalStorage();\n if (storage) {\n try {\n delete storage[getTransportCacheKey(usingTLS)];\n } catch (e) {\n // catch exceptions raised by localStorage\n }\n }\n}\n","import { OneOffTimer as Timer } from '../utils/timers';\nimport Strategy from './strategy';\nimport StrategyOptions from './strategy_options';\n\n/** Runs substrategy after specified delay.\n *\n * Options:\n * - delay - time in miliseconds to delay the substrategy attempt\n *\n * @param {Strategy} strategy\n * @param {Object} options\n */\nexport default class DelayedStrategy implements Strategy {\n strategy: Strategy;\n options: { delay: number };\n\n constructor(strategy: Strategy, { delay: number }) {\n this.strategy = strategy;\n this.options = { delay: number };\n }\n\n isSupported(): boolean {\n return this.strategy.isSupported();\n }\n\n connect(minPriority: number, callback: Function) {\n var strategy = this.strategy;\n var runner;\n var timer = new Timer(this.options.delay, function() {\n runner = strategy.connect(minPriority, callback);\n });\n\n return {\n abort: function() {\n timer.ensureAborted();\n if (runner) {\n runner.abort();\n }\n },\n forceMinPriority: function(p) {\n minPriority = p;\n if (runner) {\n runner.forceMinPriority(p);\n }\n }\n };\n }\n}\n","import Strategy from './strategy';\nimport StrategyRunner from './strategy_runner';\n\n/** Proxies method calls to one of substrategies basing on the test function.\n *\n * @param {Function} test\n * @param {Strategy} trueBranch strategy used when test returns true\n * @param {Strategy} falseBranch strategy used when test returns false\n */\nexport default class IfStrategy implements Strategy {\n test: () => boolean;\n trueBranch: Strategy;\n falseBranch: Strategy;\n\n constructor(\n test: () => boolean,\n trueBranch: Strategy,\n falseBranch: Strategy\n ) {\n this.test = test;\n this.trueBranch = trueBranch;\n this.falseBranch = falseBranch;\n }\n\n isSupported(): boolean {\n var branch = this.test() ? this.trueBranch : this.falseBranch;\n return branch.isSupported();\n }\n\n connect(minPriority: number, callback: Function): StrategyRunner {\n var branch = this.test() ? this.trueBranch : this.falseBranch;\n return branch.connect(minPriority, callback);\n }\n}\n","import Strategy from './strategy';\nimport StrategyRunner from './strategy_runner';\n\n/** Launches the substrategy and terminates on the first open connection.\n *\n * @param {Strategy} strategy\n */\nexport default class FirstConnectedStrategy implements Strategy {\n strategy: Strategy;\n\n constructor(strategy: Strategy) {\n this.strategy = strategy;\n }\n\n isSupported(): boolean {\n return this.strategy.isSupported();\n }\n\n connect(minPriority: number, callback: Function): StrategyRunner {\n var runner = this.strategy.connect(minPriority, function(error, handshake) {\n if (handshake) {\n runner.abort();\n }\n callback(error, handshake);\n });\n return runner;\n }\n}\n","import * as Collections from 'core/utils/collections';\nimport TransportManager from 'core/transports/transport_manager';\nimport Strategy from 'core/strategies/strategy';\nimport SequentialStrategy from 'core/strategies/sequential_strategy';\nimport BestConnectedEverStrategy from 'core/strategies/best_connected_ever_strategy';\nimport WebSocketPrioritizedCachedStrategy, {\n TransportStrategyDictionary\n} from 'core/strategies/websocket_prioritized_cached_strategy';\nimport DelayedStrategy from 'core/strategies/delayed_strategy';\nimport IfStrategy from 'core/strategies/if_strategy';\nimport FirstConnectedStrategy from 'core/strategies/first_connected_strategy';\nimport { Config } from 'core/config';\nimport StrategyOptions from 'core/strategies/strategy_options';\n\nfunction testSupportsStrategy(strategy: Strategy) {\n return function() {\n return strategy.isSupported();\n };\n}\n\nvar getDefaultStrategy = function(\n config: Config,\n baseOptions: StrategyOptions,\n defineTransport: Function\n): Strategy {\n var definedTransports = {};\n\n function defineTransportStrategy(\n name: string,\n type: string,\n priority: number,\n options: StrategyOptions,\n manager?: TransportManager\n ) {\n var transport = defineTransport(\n config,\n name,\n type,\n priority,\n options,\n manager\n );\n\n definedTransports[name] = transport;\n\n return transport;\n }\n\n var ws_options: StrategyOptions = Object.assign({}, baseOptions, {\n hostNonTLS: config.wsHost + ':' + config.wsPort,\n hostTLS: config.wsHost + ':' + config.wssPort,\n httpPath: config.wsPath\n });\n var wss_options: StrategyOptions = Collections.extend({}, ws_options, {\n useTLS: true\n });\n var http_options: StrategyOptions = Object.assign({}, baseOptions, {\n hostNonTLS: config.httpHost + ':' + config.httpPort,\n hostTLS: config.httpHost + ':' + config.httpsPort,\n httpPath: config.httpPath\n });\n var timeouts = {\n loop: true,\n timeout: 15000,\n timeoutLimit: 60000\n };\n\n var ws_manager = new TransportManager({\n minPingDelay: 10000,\n maxPingDelay: config.activityTimeout\n });\n var streaming_manager = new TransportManager({\n lives: 2,\n minPingDelay: 10000,\n maxPingDelay: config.activityTimeout\n });\n\n var ws_transport = defineTransportStrategy(\n 'ws',\n 'ws',\n 3,\n ws_options,\n ws_manager\n );\n var wss_transport = defineTransportStrategy(\n 'wss',\n 'ws',\n 3,\n wss_options,\n ws_manager\n );\n var xhr_streaming_transport = defineTransportStrategy(\n 'xhr_streaming',\n 'xhr_streaming',\n 1,\n http_options,\n streaming_manager\n );\n var xhr_polling_transport = defineTransportStrategy(\n 'xhr_polling',\n 'xhr_polling',\n 1,\n http_options\n );\n\n var ws_loop = new SequentialStrategy([ws_transport], timeouts);\n var wss_loop = new SequentialStrategy([wss_transport], timeouts);\n var streaming_loop = new SequentialStrategy(\n [xhr_streaming_transport],\n timeouts\n );\n var polling_loop = new SequentialStrategy([xhr_polling_transport], timeouts);\n\n var http_loop = new SequentialStrategy(\n [\n new IfStrategy(\n testSupportsStrategy(streaming_loop),\n new BestConnectedEverStrategy([\n streaming_loop,\n new DelayedStrategy(polling_loop, { delay: 4000 })\n ]),\n polling_loop\n )\n ],\n timeouts\n );\n\n var wsStrategy;\n if (baseOptions.useTLS) {\n wsStrategy = new BestConnectedEverStrategy([\n ws_loop,\n new DelayedStrategy(http_loop, { delay: 2000 })\n ]);\n } else {\n wsStrategy = new BestConnectedEverStrategy([\n ws_loop,\n new DelayedStrategy(wss_loop, { delay: 2000 }),\n new DelayedStrategy(http_loop, { delay: 5000 })\n ]);\n }\n\n return new WebSocketPrioritizedCachedStrategy(\n new FirstConnectedStrategy(\n new IfStrategy(testSupportsStrategy(ws_transport), wsStrategy, http_loop)\n ),\n definedTransports,\n {\n ttl: 1800000,\n timeline: baseOptions.timeline,\n useTLS: baseOptions.useTLS\n }\n );\n};\n\nexport default getDefaultStrategy;\n","import Runtime from 'runtime';\nimport RequestHooks from './request_hooks';\nimport Ajax from './ajax';\nimport { default as EventsDispatcher } from '../events/dispatcher';\n\nconst MAX_BUFFER_LENGTH = 256 * 1024;\n\nexport default class HTTPRequest extends EventsDispatcher {\n hooks: RequestHooks;\n method: string;\n url: string;\n position: number;\n xhr: Ajax;\n unloader: Function;\n\n constructor(hooks: RequestHooks, method: string, url: string) {\n super();\n this.hooks = hooks;\n this.method = method;\n this.url = url;\n }\n\n start(payload?: any) {\n this.position = 0;\n this.xhr = this.hooks.getRequest(this);\n\n this.unloader = () => {\n this.close();\n };\n Runtime.addUnloadListener(this.unloader);\n\n this.xhr.open(this.method, this.url, true);\n\n if (this.xhr.setRequestHeader) {\n this.xhr.setRequestHeader('Content-Type', 'application/json'); // ReactNative doesn't set this header by default.\n }\n this.xhr.send(payload);\n }\n\n close() {\n if (this.unloader) {\n Runtime.removeUnloadListener(this.unloader);\n this.unloader = null;\n }\n if (this.xhr) {\n this.hooks.abortRequest(this.xhr);\n this.xhr = null;\n }\n }\n\n onChunk(status: number, data: any) {\n while (true) {\n var chunk = this.advanceBuffer(data);\n if (chunk) {\n this.emit('chunk', { status: status, data: chunk });\n } else {\n break;\n }\n }\n if (this.isBufferTooLong(data)) {\n this.emit('buffer_too_long');\n }\n }\n\n private advanceBuffer(buffer: any[]): any {\n var unreadData = buffer.slice(this.position);\n var endOfLinePosition = unreadData.indexOf('\\n');\n\n if (endOfLinePosition !== -1) {\n this.position += endOfLinePosition + 1;\n return unreadData.slice(0, endOfLinePosition);\n } else {\n // chunk is not finished yet, don't move the buffer pointer\n return null;\n }\n }\n\n private isBufferTooLong(buffer: any): boolean {\n return this.position === buffer.length && buffer.length > MAX_BUFFER_LENGTH;\n }\n}\n","enum State {\n CONNECTING = 0,\n OPEN = 1,\n CLOSED = 3\n}\n\nexport default State;\n","import URLLocation from './url_location';\nimport State from './state';\nimport Socket from '../socket';\nimport SocketHooks from './socket_hooks';\nimport Util from '../util';\nimport Ajax from './ajax';\nimport HTTPRequest from './http_request';\nimport Runtime from 'runtime';\n\nvar autoIncrement = 1;\n\nclass HTTPSocket implements Socket {\n hooks: SocketHooks;\n session: string;\n location: URLLocation;\n readyState: State;\n stream: HTTPRequest;\n\n onopen: () => void;\n onerror: (error: any) => void;\n onclose: (closeEvent: any) => void;\n onmessage: (message: any) => void;\n onactivity: () => void;\n\n constructor(hooks: SocketHooks, url: string) {\n this.hooks = hooks;\n this.session = randomNumber(1000) + '/' + randomString(8);\n this.location = getLocation(url);\n this.readyState = State.CONNECTING;\n this.openStream();\n }\n\n send(payload: any) {\n return this.sendRaw(JSON.stringify([payload]));\n }\n\n ping() {\n this.hooks.sendHeartbeat(this);\n }\n\n close(code: any, reason: any) {\n this.onClose(code, reason, true);\n }\n\n /** For internal use only */\n sendRaw(payload: any): boolean {\n if (this.readyState === State.OPEN) {\n try {\n Runtime.createSocketRequest(\n 'POST',\n getUniqueURL(getSendURL(this.location, this.session))\n ).start(payload);\n return true;\n } catch (e) {\n return false;\n }\n } else {\n return false;\n }\n }\n\n /** For internal use only */\n reconnect() {\n this.closeStream();\n this.openStream();\n }\n\n /** For internal use only */\n onClose(code, reason, wasClean) {\n this.closeStream();\n this.readyState = State.CLOSED;\n if (this.onclose) {\n this.onclose({\n code: code,\n reason: reason,\n wasClean: wasClean\n });\n }\n }\n\n private onChunk(chunk) {\n if (chunk.status !== 200) {\n return;\n }\n if (this.readyState === State.OPEN) {\n this.onActivity();\n }\n\n var payload;\n var type = chunk.data.slice(0, 1);\n switch (type) {\n case 'o':\n payload = JSON.parse(chunk.data.slice(1) || '{}');\n this.onOpen(payload);\n break;\n case 'a':\n payload = JSON.parse(chunk.data.slice(1) || '[]');\n for (var i = 0; i < payload.length; i++) {\n this.onEvent(payload[i]);\n }\n break;\n case 'm':\n payload = JSON.parse(chunk.data.slice(1) || 'null');\n this.onEvent(payload);\n break;\n case 'h':\n this.hooks.onHeartbeat(this);\n break;\n case 'c':\n payload = JSON.parse(chunk.data.slice(1) || '[]');\n this.onClose(payload[0], payload[1], true);\n break;\n }\n }\n\n private onOpen(options) {\n if (this.readyState === State.CONNECTING) {\n if (options && options.hostname) {\n this.location.base = replaceHost(this.location.base, options.hostname);\n }\n this.readyState = State.OPEN;\n\n if (this.onopen) {\n this.onopen();\n }\n } else {\n this.onClose(1006, 'Server lost session', true);\n }\n }\n\n private onEvent(event) {\n if (this.readyState === State.OPEN && this.onmessage) {\n this.onmessage({ data: event });\n }\n }\n\n private onActivity() {\n if (this.onactivity) {\n this.onactivity();\n }\n }\n\n private onError(error) {\n if (this.onerror) {\n this.onerror(error);\n }\n }\n\n private openStream() {\n this.stream = Runtime.createSocketRequest(\n 'POST',\n getUniqueURL(this.hooks.getReceiveURL(this.location, this.session))\n );\n\n this.stream.bind('chunk', chunk => {\n this.onChunk(chunk);\n });\n this.stream.bind('finished', status => {\n this.hooks.onFinished(this, status);\n });\n this.stream.bind('buffer_too_long', () => {\n this.reconnect();\n });\n\n try {\n this.stream.start();\n } catch (error) {\n Util.defer(() => {\n this.onError(error);\n this.onClose(1006, 'Could not start streaming', false);\n });\n }\n }\n\n private closeStream() {\n if (this.stream) {\n this.stream.unbind_all();\n this.stream.close();\n this.stream = null;\n }\n }\n}\n\nfunction getLocation(url): URLLocation {\n var parts = /([^\\?]*)\\/*(\\??.*)/.exec(url);\n return {\n base: parts[1],\n queryString: parts[2]\n };\n}\n\nfunction getSendURL(url: URLLocation, session: string): string {\n return url.base + '/' + session + '/xhr_send';\n}\n\nfunction getUniqueURL(url: string): string {\n var separator = url.indexOf('?') === -1 ? '?' : '&';\n return url + separator + 't=' + +new Date() + '&n=' + autoIncrement++;\n}\n\nfunction replaceHost(url: string, hostname: string): string {\n var urlParts = /(https?:\\/\\/)([^\\/:]+)((\\/|:)?.*)/.exec(url);\n return urlParts[1] + hostname + urlParts[3];\n}\n\nfunction randomNumber(max: number): number {\n return Runtime.randomInt(max);\n}\n\nfunction randomString(length: number): string {\n var result = [];\n\n for (var i = 0; i < length; i++) {\n result.push(randomNumber(32).toString(32));\n }\n\n return result.join('');\n}\n\nexport default HTTPSocket;\n","import SocketHooks from './socket_hooks';\nimport HTTPSocket from './http_socket';\n\nvar hooks: SocketHooks = {\n getReceiveURL: function(url, session) {\n return url.base + '/' + session + '/xhr_streaming' + url.queryString;\n },\n onHeartbeat: function(socket) {\n socket.sendRaw('[]');\n },\n sendHeartbeat: function(socket) {\n socket.sendRaw('[]');\n },\n onFinished: function(socket, status) {\n socket.onClose(1006, 'Connection interrupted (' + status + ')', false);\n }\n};\n\nexport default hooks;\n","import SocketHooks from './socket_hooks';\nimport URLLocation from './url_location';\nimport HTTPSocket from './http_socket';\n\nvar hooks: SocketHooks = {\n getReceiveURL: function(url: URLLocation, session: string): string {\n return url.base + '/' + session + '/xhr' + url.queryString;\n },\n onHeartbeat: function() {\n // next HTTP request will reset server's activity timer\n },\n sendHeartbeat: function(socket) {\n socket.sendRaw('[]');\n },\n onFinished: function(socket, status) {\n if (status === 200) {\n socket.reconnect();\n } else {\n socket.onClose(1006, 'Connection interrupted (' + status + ')', false);\n }\n }\n};\n\nexport default hooks;\n","import HTTPRequest from 'core/http/http_request';\nimport RequestHooks from 'core/http/request_hooks';\nimport Ajax from 'core/http/ajax';\nimport Runtime from 'runtime';\n\nvar hooks: RequestHooks = {\n getRequest: function(socket: HTTPRequest): Ajax {\n var Constructor = Runtime.getXHRAPI();\n var xhr = new Constructor();\n xhr.onreadystatechange = xhr.onprogress = function() {\n switch (xhr.readyState) {\n case 3:\n if (xhr.responseText && xhr.responseText.length > 0) {\n socket.onChunk(xhr.status, xhr.responseText);\n }\n break;\n case 4:\n // this happens only on errors, never after calling close\n if (xhr.responseText && xhr.responseText.length > 0) {\n socket.onChunk(xhr.status, xhr.responseText);\n }\n socket.emit('finished', xhr.status);\n socket.close();\n break;\n }\n };\n return xhr;\n },\n abortRequest: function(xhr: Ajax) {\n xhr.onreadystatechange = null;\n xhr.abort();\n }\n};\n\nexport default hooks;\n","import * as Collections from 'core/utils/collections';\nimport Transports from 'isomorphic/transports/transports';\nimport TimelineSender from 'core/timeline/timeline_sender';\nimport Ajax from 'core/http/ajax';\nimport getDefaultStrategy from './default_strategy';\nimport TransportsTable from 'core/transports/transports_table';\nimport transportConnectionInitializer from './transports/transport_connection_initializer';\nimport HTTPFactory from './http/http';\n\nvar Isomorphic: any = {\n getDefaultStrategy,\n Transports: Transports,\n transportConnectionInitializer,\n HTTPFactory,\n\n setup(PusherClass): void {\n PusherClass.ready();\n },\n\n getLocalStorage(): any {\n return undefined;\n },\n\n getClientFeatures(): any[] {\n return Collections.keys(\n Collections.filterObject({ ws: Transports.ws }, function(t) {\n return t.isSupported({});\n })\n );\n },\n\n getProtocol(): string {\n return 'http:';\n },\n\n isXHRSupported(): boolean {\n return true;\n },\n\n createSocketRequest(method: string, url: string) {\n if (this.isXHRSupported()) {\n return this.HTTPFactory.createXHR(method, url);\n } else {\n throw 'Cross-origin HTTP requests are not supported';\n }\n },\n\n createXHR(): Ajax {\n var Constructor = this.getXHRAPI();\n return new Constructor();\n },\n\n createWebSocket(url: string): any {\n var Constructor = this.getWebSocketAPI();\n return new Constructor(url);\n },\n\n addUnloadListener(listener: any) {},\n removeUnloadListener(listener: any) {}\n};\n\nexport default Isomorphic;\n","/** Initializes the transport.\n *\n * Fetches resources if needed and then transitions to initialized.\n */\nexport default function() {\n var self = this;\n\n self.timeline.info(\n self.buildTimelineMessage({\n transport: self.name + (self.options.useTLS ? 's' : '')\n })\n );\n\n if (self.hooks.isInitialized()) {\n self.changeState('initialized');\n } else {\n self.onClose();\n }\n}\n","import HTTPRequest from 'core/http/http_request';\nimport HTTPSocket from 'core/http/http_socket';\nimport SocketHooks from 'core/http/socket_hooks';\nimport RequestHooks from 'core/http/request_hooks';\nimport streamingHooks from 'core/http/http_streaming_socket';\nimport pollingHooks from 'core/http/http_polling_socket';\nimport xhrHooks from './http_xhr_request';\nimport HTTPFactory from 'core/http/http_factory';\n\nvar HTTP: HTTPFactory = {\n createStreamingSocket(url: string): HTTPSocket {\n return this.createSocket(streamingHooks, url);\n },\n\n createPollingSocket(url: string): HTTPSocket {\n return this.createSocket(pollingHooks, url);\n },\n\n createSocket(hooks: SocketHooks, url: string): HTTPSocket {\n return new HTTPSocket(hooks, url);\n },\n\n createXHR(method: string, url: string): HTTPRequest {\n return this.createRequest(xhrHooks, method, url);\n },\n\n createRequest(hooks: RequestHooks, method: string, url: string): HTTPRequest {\n return new HTTPRequest(hooks, method, url);\n }\n};\n\nexport default HTTP;\n","import { default as EventsDispatcher } from 'core/events/dispatcher';\nimport Reachability from 'core/reachability';\n\nexport class NetInfo extends EventsDispatcher implements Reachability {\n isOnline(): boolean {\n return true;\n }\n}\n\nexport var Network = new NetInfo();\n","import AbstractRuntime from 'runtimes/interface';\nimport { AuthTransport } from 'core/auth/auth_transports';\nimport {\n AuthRequestType,\n AuthTransportCallback,\n InternalAuthOptions\n} from 'core/auth/options';\nimport { HTTPAuthError } from 'core/errors';\n\nvar fetchAuth: AuthTransport = function(\n context: AbstractRuntime,\n query: string,\n authOptions: InternalAuthOptions,\n authRequestType: AuthRequestType,\n callback: AuthTransportCallback\n) {\n var headers = new Headers();\n headers.set('Content-Type', 'application/x-www-form-urlencoded');\n\n for (var headerName in authOptions.headers) {\n headers.set(headerName, authOptions.headers[headerName]);\n }\n\n if (authOptions.headersProvider != null) {\n const dynamicHeaders = authOptions.headersProvider();\n for (var headerName in dynamicHeaders) {\n headers.set(headerName, dynamicHeaders[headerName]);\n }\n }\n\n var body = query;\n var request = new Request(authOptions.endpoint, {\n headers,\n body,\n credentials: 'same-origin',\n method: 'POST'\n });\n\n return fetch(request)\n .then(response => {\n let { status } = response;\n if (status === 200) {\n // manually parse the json so we can provide a more helpful error in\n // failure case\n return response.text();\n }\n throw new HTTPAuthError(\n status,\n `Could not get ${authRequestType.toString()} info from your auth endpoint, status: ${status}`\n );\n })\n .then(data => {\n let parsedData;\n try {\n parsedData = JSON.parse(data);\n } catch (e) {\n throw new HTTPAuthError(\n 200,\n `JSON returned from ${authRequestType.toString()} endpoint was invalid, yet status code was 200. Data was: ${data}`\n );\n }\n callback(null, parsedData);\n })\n .catch(err => {\n callback(err, null);\n });\n};\n\nexport default fetchAuth;\n","import Logger from 'core/logger';\nimport TimelineSender from 'core/timeline/timeline_sender';\nimport * as Collections from 'core/utils/collections';\nimport Util from 'core/util';\nimport Runtime from 'runtime';\nimport TimelineTransport from 'core/timeline/timeline_transport';\n\nvar getAgent = function(sender: TimelineSender, useTLS: boolean) {\n return function(data: any, callback: Function) {\n var scheme = 'http' + (useTLS ? 's' : '') + '://';\n var url =\n scheme + (sender.host || sender.options.host) + sender.options.path;\n var query = Collections.buildQueryString(data);\n url += '/' + 2 + '?' + query;\n\n fetch(url)\n .then(response => {\n if (response.status !== 200) {\n throw `received ${response.status} from stats.pusher.com`;\n }\n return response.json();\n })\n .then(({ host }) => {\n if (host) {\n sender.host = host;\n }\n })\n .catch(err => {\n Logger.debug('TimelineSender Error: ', err);\n });\n };\n};\n\nvar fetchTimeline = {\n name: 'xhr',\n getAgent\n};\n\nexport default fetchTimeline;\n","import Isomorphic from 'isomorphic/runtime';\nimport Runtime from '../interface';\nimport { Network } from './net_info';\nimport fetchAuth from './auth/fetch_auth';\nimport { AuthTransports } from 'core/auth/auth_transports';\nimport fetchTimeline from './timeline/fetch_timeline';\n\n// Very verbose but until unavoidable until\n// TypeScript 2.1, when spread attributes will be\n// supported\nconst {\n getDefaultStrategy,\n Transports,\n setup,\n getProtocol,\n isXHRSupported,\n getLocalStorage,\n createXHR,\n createWebSocket,\n addUnloadListener,\n removeUnloadListener,\n transportConnectionInitializer,\n createSocketRequest,\n HTTPFactory\n} = Isomorphic;\n\nconst Worker: Runtime = {\n getDefaultStrategy,\n Transports,\n setup,\n getProtocol,\n isXHRSupported,\n getLocalStorage,\n createXHR,\n createWebSocket,\n addUnloadListener,\n removeUnloadListener,\n transportConnectionInitializer,\n createSocketRequest,\n HTTPFactory,\n\n TimelineTransport: fetchTimeline,\n\n getAuthorizers(): AuthTransports {\n return { ajax: fetchAuth };\n },\n\n getWebSocketAPI() {\n return WebSocket;\n },\n\n getXHRAPI() {\n return XMLHttpRequest;\n },\n\n getNetwork() {\n return Network;\n },\n\n randomInt(max: number): number {\n /**\n * Return values in the range of [0, 1[\n */\n const random = function() {\n const crypto = globalThis.crypto || globalThis['msCrypto'];\n const random = crypto.getRandomValues(new Uint32Array(1))[0];\n\n return random / 2 ** 32;\n };\n\n return Math.floor(random() * max);\n }\n};\n\nexport default Worker;\n","enum TimelineLevel {\n ERROR = 3,\n INFO = 6,\n DEBUG = 7\n}\n\nexport default TimelineLevel;\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport { default as Level } from './level';\n\nexport interface TimelineOptions {\n level?: Level;\n limit?: number;\n version?: string;\n cluster?: string;\n features?: string[];\n params?: any;\n}\n\nexport default class Timeline {\n key: string;\n session: number;\n events: any[];\n options: TimelineOptions;\n sent: number;\n uniqueID: number;\n\n constructor(key: string, session: number, options: TimelineOptions) {\n this.key = key;\n this.session = session;\n this.events = [];\n this.options = options || {};\n this.sent = 0;\n this.uniqueID = 0;\n }\n\n log(level, event) {\n if (level <= this.options.level) {\n this.events.push(\n Collections.extend({}, event, { timestamp: Util.now() })\n );\n if (this.options.limit && this.events.length > this.options.limit) {\n this.events.shift();\n }\n }\n }\n\n error(event) {\n this.log(Level.ERROR, event);\n }\n\n info(event) {\n this.log(Level.INFO, event);\n }\n\n debug(event) {\n this.log(Level.DEBUG, event);\n }\n\n isEmpty() {\n return this.events.length === 0;\n }\n\n send(sendfn, callback) {\n var data = Collections.extend(\n {\n session: this.session,\n bundle: this.sent + 1,\n key: this.key,\n lib: 'js',\n version: this.options.version,\n cluster: this.options.cluster,\n features: this.options.features,\n timeline: this.events\n },\n this.options.params\n );\n\n this.events = [];\n sendfn(data, (error, result) => {\n if (!error) {\n this.sent++;\n }\n if (callback) {\n callback(error, result);\n }\n });\n\n return true;\n }\n\n generateUniqueID(): number {\n this.uniqueID++;\n return this.uniqueID;\n }\n}\n","import Factory from '../utils/factory';\nimport Util from '../util';\nimport * as Errors from '../errors';\nimport * as Collections from '../utils/collections';\nimport Strategy from './strategy';\nimport Transport from '../transports/transport';\nimport StrategyOptions from './strategy_options';\nimport Handshake from '../connection/handshake';\n\n/** Provides a strategy interface for transports.\n *\n * @param {String} name\n * @param {Number} priority\n * @param {Class} transport\n * @param {Object} options\n */\nexport default class TransportStrategy implements Strategy {\n name: string;\n priority: number;\n transport: Transport;\n options: StrategyOptions;\n\n constructor(\n name: string,\n priority: number,\n transport: Transport,\n options: StrategyOptions\n ) {\n this.name = name;\n this.priority = priority;\n this.transport = transport;\n this.options = options || {};\n }\n\n /** Returns whether the transport is supported in the browser.\n *\n * @returns {Boolean}\n */\n isSupported(): boolean {\n return this.transport.isSupported({\n useTLS: this.options.useTLS\n });\n }\n\n /** Launches a connection attempt and returns a strategy runner.\n *\n * @param {Function} callback\n * @return {Object} strategy runner\n */\n connect(minPriority: number, callback: Function) {\n if (!this.isSupported()) {\n return failAttempt(new Errors.UnsupportedStrategy(), callback);\n } else if (this.priority < minPriority) {\n return failAttempt(new Errors.TransportPriorityTooLow(), callback);\n }\n\n var connected = false;\n var transport = this.transport.createConnection(\n this.name,\n this.priority,\n this.options.key,\n this.options\n );\n var handshake = null;\n\n var onInitialized = function() {\n transport.unbind('initialized', onInitialized);\n transport.connect();\n };\n var onOpen = function() {\n handshake = Factory.createHandshake(transport, function(result) {\n connected = true;\n unbindListeners();\n callback(null, result);\n });\n };\n var onError = function(error) {\n unbindListeners();\n callback(error);\n };\n var onClosed = function() {\n unbindListeners();\n var serializedTransport;\n\n // The reason for this try/catch block is that on React Native\n // the WebSocket object is circular. Therefore transport.socket will\n // throw errors upon stringification. Collections.safeJSONStringify\n // discards circular references when serializing.\n serializedTransport = Collections.safeJSONStringify(transport);\n callback(new Errors.TransportClosed(serializedTransport));\n };\n\n var unbindListeners = function() {\n transport.unbind('initialized', onInitialized);\n transport.unbind('open', onOpen);\n transport.unbind('error', onError);\n transport.unbind('closed', onClosed);\n };\n\n transport.bind('initialized', onInitialized);\n transport.bind('open', onOpen);\n transport.bind('error', onError);\n transport.bind('closed', onClosed);\n\n // connect will be called automatically after initialization\n transport.initialize();\n\n return {\n abort: () => {\n if (connected) {\n return;\n }\n unbindListeners();\n if (handshake) {\n handshake.close();\n } else {\n transport.close();\n }\n },\n forceMinPriority: p => {\n if (connected) {\n return;\n }\n if (this.priority < p) {\n if (handshake) {\n handshake.close();\n } else {\n transport.close();\n }\n }\n }\n };\n }\n}\n\nfunction failAttempt(error: Error, callback: Function) {\n Util.defer(function() {\n callback(error);\n });\n return {\n abort: function() {},\n forceMinPriority: function() {}\n };\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport TransportManager from '../transports/transport_manager';\nimport * as Errors from '../errors';\nimport Strategy from './strategy';\nimport TransportStrategy from './transport_strategy';\nimport StrategyOptions from '../strategies/strategy_options';\nimport { Config } from '../config';\nimport Runtime from 'runtime';\n\nconst { Transports } = Runtime;\n\nexport var defineTransport = function(\n config: Config,\n name: string,\n type: string,\n priority: number,\n options: StrategyOptions,\n manager?: TransportManager\n): Strategy {\n var transportClass = Transports[type];\n if (!transportClass) {\n throw new Errors.UnsupportedTransport(type);\n }\n\n var enabled =\n (!config.enabledTransports ||\n Collections.arrayIndexOf(config.enabledTransports, name) !== -1) &&\n (!config.disabledTransports ||\n Collections.arrayIndexOf(config.disabledTransports, name) === -1);\n\n var transport;\n if (enabled) {\n options = Object.assign(\n { ignoreNullOrigin: config.ignoreNullOrigin },\n options\n );\n\n transport = new TransportStrategy(\n name,\n priority,\n manager ? manager.getAssistant(transportClass) : transportClass,\n options\n );\n } else {\n transport = UnsupportedStrategy;\n }\n\n return transport;\n};\n\nvar UnsupportedStrategy: Strategy = {\n isSupported: function() {\n return false;\n },\n connect: function(_, callback) {\n var deferred = Util.defer(function() {\n callback(new Errors.UnsupportedStrategy());\n });\n return {\n abort: function() {\n deferred.ensureAborted();\n },\n forceMinPriority: function() {}\n };\n }\n};\n","export enum AuthRequestType {\n UserAuthentication = 'user-authentication',\n ChannelAuthorization = 'channel-authorization'\n}\n\nexport interface ChannelAuthorizationData {\n auth: string;\n channel_data?: string;\n shared_secret?: string;\n}\n\nexport type ChannelAuthorizationCallback = (\n error: Error | null,\n authData: ChannelAuthorizationData | null\n) => void;\n\nexport interface ChannelAuthorizationRequestParams {\n socketId: string;\n channelName: string;\n}\n\nexport interface ChannelAuthorizationHandler {\n (\n params: ChannelAuthorizationRequestParams,\n callback: ChannelAuthorizationCallback\n ): void;\n}\n\nexport interface UserAuthenticationData {\n auth: string;\n user_data: string;\n}\n\nexport type UserAuthenticationCallback = (\n error: Error | null,\n authData: UserAuthenticationData | null\n) => void;\n\nexport interface UserAuthenticationRequestParams {\n socketId: string;\n}\n\nexport interface UserAuthenticationHandler {\n (\n params: UserAuthenticationRequestParams,\n callback: UserAuthenticationCallback\n ): void;\n}\n\nexport type AuthTransportCallback =\n | ChannelAuthorizationCallback\n | UserAuthenticationCallback;\n\nexport interface AuthOptionsT {\n transport: 'ajax' | 'jsonp';\n endpoint: string;\n params?: any;\n headers?: any;\n paramsProvider?: () => any;\n headersProvider?: () => any;\n customHandler?: AuthHandler;\n}\n\nexport declare type UserAuthenticationOptions = AuthOptionsT<\n UserAuthenticationHandler\n>;\nexport declare type ChannelAuthorizationOptions = AuthOptionsT<\n ChannelAuthorizationHandler\n>;\n\nexport interface InternalAuthOptions {\n transport: 'ajax' | 'jsonp';\n endpoint: string;\n params?: any;\n headers?: any;\n paramsProvider?: () => any;\n headersProvider?: () => any;\n}\n","import ConnectionManager from './connection/connection_manager';\nimport {\n ChannelAuthorizationOptions,\n UserAuthenticationOptions\n} from './auth/options';\nimport {\n ChannelAuthorizerGenerator,\n DeprecatedAuthOptions\n} from './auth/deprecated_channel_authorizer';\nimport { AuthTransport, Transport } from './config';\nimport * as nacl from 'tweetnacl';\nimport Logger from './logger';\n\nexport interface Options {\n activityTimeout?: number;\n\n auth?: DeprecatedAuthOptions; // DEPRECATED use channelAuthorization instead\n authEndpoint?: string; // DEPRECATED use channelAuthorization instead\n authTransport?: AuthTransport; // DEPRECATED use channelAuthorization instead\n authorizer?: ChannelAuthorizerGenerator; // DEPRECATED use channelAuthorization instead\n\n channelAuthorization?: ChannelAuthorizationOptions;\n userAuthentication?: UserAuthenticationOptions;\n\n cluster: string;\n enableStats?: boolean;\n disableStats?: boolean;\n disabledTransports?: Transport[];\n enabledTransports?: Transport[];\n forceTLS?: boolean;\n httpHost?: string;\n httpPath?: string;\n httpPort?: number;\n httpsPort?: number;\n ignoreNullOrigin?: boolean;\n nacl?: nacl;\n pongTimeout?: number;\n statsHost?: string;\n timelineParams?: any;\n unavailableTimeout?: number;\n wsHost?: string;\n wsPath?: string;\n wsPort?: number;\n wssPort?: number;\n}\n\nexport interface ClusterOptions {\n appKey: string;\n cluster: string;\n}\n\nexport function validateOptions(options) {\n if (options == null) {\n throw 'You must pass an options object';\n }\n if (options.cluster == null) {\n throw 'Options object must provide a cluster';\n }\n if ('disableStats' in options) {\n Logger.warn(\n 'The disableStats option is deprecated in favor of enableStats'\n );\n }\n}\n","import {\n UserAuthenticationCallback,\n InternalAuthOptions,\n UserAuthenticationHandler,\n UserAuthenticationRequestParams,\n AuthRequestType\n} from './options';\n\nimport Runtime from 'runtime';\n\nconst composeChannelQuery = (\n params: UserAuthenticationRequestParams,\n authOptions: InternalAuthOptions\n) => {\n var query = 'socket_id=' + encodeURIComponent(params.socketId);\n\n for (var key in authOptions.params) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(authOptions.params[key]);\n }\n\n if (authOptions.paramsProvider != null) {\n let dynamicParams = authOptions.paramsProvider();\n for (var key in dynamicParams) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(dynamicParams[key]);\n }\n }\n\n return query;\n};\n\nconst UserAuthenticator = (\n authOptions: InternalAuthOptions\n): UserAuthenticationHandler => {\n if (typeof Runtime.getAuthorizers()[authOptions.transport] === 'undefined') {\n throw `'${authOptions.transport}' is not a recognized auth transport`;\n }\n\n return (\n params: UserAuthenticationRequestParams,\n callback: UserAuthenticationCallback\n ) => {\n const query = composeChannelQuery(params, authOptions);\n\n Runtime.getAuthorizers()[authOptions.transport](\n Runtime,\n query,\n authOptions,\n AuthRequestType.UserAuthentication,\n callback\n );\n };\n};\n\nexport default UserAuthenticator;\n","import {\n AuthRequestType,\n InternalAuthOptions,\n ChannelAuthorizationHandler,\n ChannelAuthorizationRequestParams,\n ChannelAuthorizationCallback\n} from './options';\n\nimport Runtime from 'runtime';\n\nconst composeChannelQuery = (\n params: ChannelAuthorizationRequestParams,\n authOptions: InternalAuthOptions\n) => {\n var query = 'socket_id=' + encodeURIComponent(params.socketId);\n\n query += '&channel_name=' + encodeURIComponent(params.channelName);\n\n for (var key in authOptions.params) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(authOptions.params[key]);\n }\n\n if (authOptions.paramsProvider != null) {\n let dynamicParams = authOptions.paramsProvider();\n for (var key in dynamicParams) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(dynamicParams[key]);\n }\n }\n\n return query;\n};\n\nconst ChannelAuthorizer = (\n authOptions: InternalAuthOptions\n): ChannelAuthorizationHandler => {\n if (typeof Runtime.getAuthorizers()[authOptions.transport] === 'undefined') {\n throw `'${authOptions.transport}' is not a recognized auth transport`;\n }\n\n return (\n params: ChannelAuthorizationRequestParams,\n callback: ChannelAuthorizationCallback\n ) => {\n const query = composeChannelQuery(params, authOptions);\n\n Runtime.getAuthorizers()[authOptions.transport](\n Runtime,\n query,\n authOptions,\n AuthRequestType.ChannelAuthorization,\n callback\n );\n };\n};\n\nexport default ChannelAuthorizer;\n","import { Options } from './options';\nimport Defaults from './defaults';\nimport {\n ChannelAuthorizationHandler,\n UserAuthenticationHandler,\n ChannelAuthorizationOptions\n} from './auth/options';\nimport UserAuthenticator from './auth/user_authenticator';\nimport ChannelAuthorizer from './auth/channel_authorizer';\nimport { ChannelAuthorizerProxy } from './auth/deprecated_channel_authorizer';\nimport Runtime from 'runtime';\nimport * as nacl from 'tweetnacl';\n\nexport type AuthTransport = 'ajax' | 'jsonp';\nexport type Transport =\n | 'ws'\n | 'wss'\n | 'xhr_streaming'\n | 'xhr_polling'\n | 'sockjs';\n\nexport interface Config {\n // these are all 'required' config parameters, it's not necessary for the user\n // to set them, but they have configured defaults.\n activityTimeout: number;\n enableStats: boolean;\n httpHost: string;\n httpPath: string;\n httpPort: number;\n httpsPort: number;\n pongTimeout: number;\n statsHost: string;\n unavailableTimeout: number;\n useTLS: boolean;\n wsHost: string;\n wsPath: string;\n wsPort: number;\n wssPort: number;\n userAuthenticator: UserAuthenticationHandler;\n channelAuthorizer: ChannelAuthorizationHandler;\n\n // these are all optional parameters or overrrides. The customer can set these\n // but it's not strictly necessary\n forceTLS?: boolean;\n cluster?: string;\n disabledTransports?: Transport[];\n enabledTransports?: Transport[];\n ignoreNullOrigin?: boolean;\n nacl?: nacl;\n timelineParams?: any;\n}\n\n// getConfig mainly sets the defaults for the options that are not provided\nexport function getConfig(opts: Options, pusher): Config {\n let config: Config = {\n activityTimeout: opts.activityTimeout || Defaults.activityTimeout,\n cluster: opts.cluster,\n httpPath: opts.httpPath || Defaults.httpPath,\n httpPort: opts.httpPort || Defaults.httpPort,\n httpsPort: opts.httpsPort || Defaults.httpsPort,\n pongTimeout: opts.pongTimeout || Defaults.pongTimeout,\n statsHost: opts.statsHost || Defaults.stats_host,\n unavailableTimeout: opts.unavailableTimeout || Defaults.unavailableTimeout,\n wsPath: opts.wsPath || Defaults.wsPath,\n wsPort: opts.wsPort || Defaults.wsPort,\n wssPort: opts.wssPort || Defaults.wssPort,\n\n enableStats: getEnableStatsConfig(opts),\n httpHost: getHttpHost(opts),\n useTLS: shouldUseTLS(opts),\n wsHost: getWebsocketHost(opts),\n\n userAuthenticator: buildUserAuthenticator(opts),\n channelAuthorizer: buildChannelAuthorizer(opts, pusher)\n };\n\n if ('disabledTransports' in opts)\n config.disabledTransports = opts.disabledTransports;\n if ('enabledTransports' in opts)\n config.enabledTransports = opts.enabledTransports;\n if ('ignoreNullOrigin' in opts)\n config.ignoreNullOrigin = opts.ignoreNullOrigin;\n if ('timelineParams' in opts) config.timelineParams = opts.timelineParams;\n if ('nacl' in opts) {\n config.nacl = opts.nacl;\n }\n\n return config;\n}\n\nfunction getHttpHost(opts: Options): string {\n if (opts.httpHost) {\n return opts.httpHost;\n }\n if (opts.cluster) {\n return `sockjs-${opts.cluster}.pusher.com`;\n }\n return Defaults.httpHost;\n}\n\nfunction getWebsocketHost(opts: Options): string {\n if (opts.wsHost) {\n return opts.wsHost;\n }\n return getWebsocketHostFromCluster(opts.cluster);\n}\n\nfunction getWebsocketHostFromCluster(cluster: string): string {\n return `ws-${cluster}.pusher.com`;\n}\n\nfunction shouldUseTLS(opts: Options): boolean {\n if (Runtime.getProtocol() === 'https:') {\n return true;\n } else if (opts.forceTLS === false) {\n return false;\n }\n return true;\n}\n\n// if enableStats is set take the value\n// if disableStats is set take the inverse\n// otherwise default to false\nfunction getEnableStatsConfig(opts: Options): boolean {\n if ('enableStats' in opts) {\n return opts.enableStats;\n }\n if ('disableStats' in opts) {\n return !opts.disableStats;\n }\n return false;\n}\n\nfunction buildUserAuthenticator(opts: Options): UserAuthenticationHandler {\n const userAuthentication = {\n ...Defaults.userAuthentication,\n ...opts.userAuthentication\n };\n if (\n 'customHandler' in userAuthentication &&\n userAuthentication['customHandler'] != null\n ) {\n return userAuthentication['customHandler'];\n }\n\n return UserAuthenticator(userAuthentication);\n}\n\nfunction buildChannelAuth(opts: Options, pusher): ChannelAuthorizationOptions {\n let channelAuthorization: ChannelAuthorizationOptions;\n if ('channelAuthorization' in opts) {\n channelAuthorization = {\n ...Defaults.channelAuthorization,\n ...opts.channelAuthorization\n };\n } else {\n channelAuthorization = {\n transport: opts.authTransport || Defaults.authTransport,\n endpoint: opts.authEndpoint || Defaults.authEndpoint\n };\n if ('auth' in opts) {\n if ('params' in opts.auth) channelAuthorization.params = opts.auth.params;\n if ('headers' in opts.auth)\n channelAuthorization.headers = opts.auth.headers;\n }\n if ('authorizer' in opts)\n channelAuthorization.customHandler = ChannelAuthorizerProxy(\n pusher,\n channelAuthorization,\n opts.authorizer\n );\n }\n return channelAuthorization;\n}\n\nfunction buildChannelAuthorizer(\n opts: Options,\n pusher\n): ChannelAuthorizationHandler {\n const channelAuthorization = buildChannelAuth(opts, pusher);\n if (\n 'customHandler' in channelAuthorization &&\n channelAuthorization['customHandler'] != null\n ) {\n return channelAuthorization['customHandler'];\n }\n\n return ChannelAuthorizer(channelAuthorization);\n}\n","import Channel from '../channels/channel';\nimport {\n ChannelAuthorizationCallback,\n ChannelAuthorizationHandler,\n ChannelAuthorizationRequestParams,\n InternalAuthOptions\n} from './options';\n\nexport interface DeprecatedChannelAuthorizer {\n authorize(socketId: string, callback: ChannelAuthorizationCallback): void;\n}\n\nexport interface ChannelAuthorizerGenerator {\n (\n channel: Channel,\n options: DeprecatedAuthorizerOptions\n ): DeprecatedChannelAuthorizer;\n}\n\nexport interface DeprecatedAuthOptions {\n params?: any;\n headers?: any;\n}\n\nexport interface DeprecatedAuthorizerOptions {\n authTransport: 'ajax' | 'jsonp';\n authEndpoint: string;\n auth?: DeprecatedAuthOptions;\n}\n\nexport const ChannelAuthorizerProxy = (\n pusher,\n authOptions: InternalAuthOptions,\n channelAuthorizerGenerator: ChannelAuthorizerGenerator\n): ChannelAuthorizationHandler => {\n const deprecatedAuthorizerOptions: DeprecatedAuthorizerOptions = {\n authTransport: authOptions.transport,\n authEndpoint: authOptions.endpoint,\n auth: {\n params: authOptions.params,\n headers: authOptions.headers\n }\n };\n return (\n params: ChannelAuthorizationRequestParams,\n callback: ChannelAuthorizationCallback\n ) => {\n const channel = pusher.channel(params.channelName);\n // This line creates a new channel authorizer every time.\n // In the past, this was only done once per channel and reused.\n // We can do that again if we want to keep this behavior intact.\n const channelAuthorizer: DeprecatedChannelAuthorizer = channelAuthorizerGenerator(\n channel,\n deprecatedAuthorizerOptions\n );\n channelAuthorizer.authorize(params.socketId, callback);\n };\n};\n","import Logger from './logger';\nimport Pusher from './pusher';\nimport EventsDispatcher from './events/dispatcher';\n\nexport default class WatchlistFacade extends EventsDispatcher {\n private pusher: Pusher;\n\n public constructor(pusher: Pusher) {\n super(function(eventName, data) {\n Logger.debug(`No callbacks on watchlist events for ${eventName}`);\n });\n\n this.pusher = pusher;\n this.bindWatchlistInternalEvent();\n }\n\n handleEvent(pusherEvent) {\n pusherEvent.data.events.forEach(watchlistEvent => {\n this.emit(watchlistEvent.name, watchlistEvent);\n });\n }\n\n private bindWatchlistInternalEvent() {\n this.pusher.connection.bind('message', pusherEvent => {\n var eventName = pusherEvent.event;\n if (eventName === 'pusher_internal:watchlist_events') {\n this.handleEvent(pusherEvent);\n }\n });\n }\n}\n","function flatPromise() {\n let resolve, reject;\n const promise = new Promise((res, rej) => {\n resolve = res;\n reject = rej;\n });\n return { promise, resolve, reject };\n}\n\nexport default flatPromise;\n","import Pusher from './pusher';\nimport Logger from './logger';\nimport {\n UserAuthenticationData,\n UserAuthenticationCallback\n} from './auth/options';\nimport Channel from './channels/channel';\nimport WatchlistFacade from './watchlist';\nimport EventsDispatcher from './events/dispatcher';\nimport flatPromise from './utils/flat_promise';\n\nexport default class UserFacade extends EventsDispatcher {\n pusher: Pusher;\n signin_requested: boolean = false;\n user_data: any = null;\n serverToUserChannel: Channel = null;\n signinDonePromise: Promise = null;\n watchlist: WatchlistFacade;\n private _signinDoneResolve: Function = null;\n\n public constructor(pusher: Pusher) {\n super(function(eventName, data) {\n Logger.debug('No callbacks on user for ' + eventName);\n });\n this.pusher = pusher;\n this.pusher.connection.bind('state_change', ({ previous, current }) => {\n if (previous !== 'connected' && current === 'connected') {\n this._signin();\n }\n if (previous === 'connected' && current !== 'connected') {\n this._cleanup();\n this._newSigninPromiseIfNeeded();\n }\n });\n\n this.watchlist = new WatchlistFacade(pusher);\n\n this.pusher.connection.bind('message', event => {\n var eventName = event.event;\n if (eventName === 'pusher:signin_success') {\n this._onSigninSuccess(event.data);\n }\n if (\n this.serverToUserChannel &&\n this.serverToUserChannel.name === event.channel\n ) {\n this.serverToUserChannel.handleEvent(event);\n }\n });\n }\n\n public signin() {\n if (this.signin_requested) {\n return;\n }\n\n this.signin_requested = true;\n this._signin();\n }\n\n private _signin() {\n if (!this.signin_requested) {\n return;\n }\n\n this._newSigninPromiseIfNeeded();\n\n if (this.pusher.connection.state !== 'connected') {\n // Signin will be attempted when the connection is connected\n return;\n }\n\n this.pusher.config.userAuthenticator(\n {\n socketId: this.pusher.connection.socket_id\n },\n this._onAuthorize\n );\n }\n\n private _onAuthorize: UserAuthenticationCallback = (\n err,\n authData: UserAuthenticationData\n ) => {\n if (err) {\n Logger.warn(`Error during signin: ${err}`);\n this._cleanup();\n return;\n }\n\n this.pusher.send_event('pusher:signin', {\n auth: authData.auth,\n user_data: authData.user_data\n });\n\n // Later when we get pusher:singin_success event, the user will be marked as signed in\n };\n\n private _onSigninSuccess(data: any) {\n try {\n this.user_data = JSON.parse(data.user_data);\n } catch (e) {\n Logger.error(`Failed parsing user data after signin: ${data.user_data}`);\n this._cleanup();\n return;\n }\n\n if (typeof this.user_data.id !== 'string' || this.user_data.id === '') {\n Logger.error(\n `user_data doesn't contain an id. user_data: ${this.user_data}`\n );\n this._cleanup();\n return;\n }\n\n // Signin succeeded\n this._signinDoneResolve();\n this._subscribeChannels();\n }\n\n private _subscribeChannels() {\n const ensure_subscribed = channel => {\n if (channel.subscriptionPending && channel.subscriptionCancelled) {\n channel.reinstateSubscription();\n } else if (\n !channel.subscriptionPending &&\n this.pusher.connection.state === 'connected'\n ) {\n channel.subscribe();\n }\n };\n\n this.serverToUserChannel = new Channel(\n `#server-to-user-${this.user_data.id}`,\n this.pusher\n );\n this.serverToUserChannel.bind_global((eventName, data) => {\n if (\n eventName.indexOf('pusher_internal:') === 0 ||\n eventName.indexOf('pusher:') === 0\n ) {\n // ignore internal events\n return;\n }\n this.emit(eventName, data);\n });\n ensure_subscribed(this.serverToUserChannel);\n }\n\n private _cleanup() {\n this.user_data = null;\n if (this.serverToUserChannel) {\n this.serverToUserChannel.unbind_all();\n this.serverToUserChannel.disconnect();\n this.serverToUserChannel = null;\n }\n\n if (this.signin_requested) {\n // If signin is in progress and cleanup is called,\n // Mark the current signin process as done.\n this._signinDoneResolve();\n }\n }\n\n private _newSigninPromiseIfNeeded() {\n if (!this.signin_requested) {\n return;\n }\n\n // If there is a promise and it is not resolved, return without creating a new one.\n if (this.signinDonePromise && !(this.signinDonePromise as any).done) {\n return;\n }\n\n // This promise is never rejected.\n // It gets resolved when the signin process is done whether it failed or succeeded\n const { promise, resolve, reject: _ } = flatPromise();\n (promise as any).done = false;\n const setDone = () => {\n (promise as any).done = true;\n };\n promise.then(setDone).catch(setDone);\n this.signinDonePromise = promise;\n this._signinDoneResolve = resolve;\n }\n}\n","import AbstractRuntime from '../runtimes/interface';\nimport Runtime from 'runtime';\nimport * as Collections from './utils/collections';\nimport Channels from './channels/channels';\nimport Channel from './channels/channel';\nimport { default as EventsDispatcher } from './events/dispatcher';\nimport Timeline from './timeline/timeline';\nimport TimelineSender from './timeline/timeline_sender';\nimport TimelineLevel from './timeline/level';\nimport { defineTransport } from './strategies/strategy_builder';\nimport ConnectionManager from './connection/connection_manager';\nimport { PeriodicTimer } from './utils/timers';\nimport Defaults from './defaults';\nimport Logger from './logger';\nimport Factory from './utils/factory';\nimport { Options, ClusterOptions, validateOptions } from './options';\nimport { Config, getConfig } from './config';\nimport StrategyOptions from './strategies/strategy_options';\nimport UserFacade from './user';\n\nexport default class Pusher {\n /* STATIC PROPERTIES */\n static instances: Pusher[] = [];\n static isReady: boolean = false;\n static logToConsole: boolean = false;\n\n // for jsonp\n static Runtime: AbstractRuntime = Runtime;\n static ScriptReceivers: any = (Runtime).ScriptReceivers;\n static DependenciesReceivers: any = (Runtime).DependenciesReceivers;\n static auth_callbacks: any = (Runtime).auth_callbacks;\n\n static ready() {\n Pusher.isReady = true;\n for (var i = 0, l = Pusher.instances.length; i < l; i++) {\n Pusher.instances[i].connect();\n }\n }\n\n static log: (message: any) => void;\n\n private static getClientFeatures(): string[] {\n return Collections.keys(\n Collections.filterObject({ ws: Runtime.Transports.ws }, function(t) {\n return t.isSupported({});\n })\n );\n }\n\n /* INSTANCE PROPERTIES */\n key: string;\n options: Options;\n config: Config;\n channels: Channels;\n global_emitter: EventsDispatcher;\n sessionID: number;\n timeline: Timeline;\n timelineSender: TimelineSender;\n connection: ConnectionManager;\n timelineSenderTimer: PeriodicTimer;\n user: UserFacade;\n constructor(app_key: string, options: Options) {\n checkAppKey(app_key);\n validateOptions(options);\n this.key = app_key;\n this.config = getConfig(options, this);\n\n this.channels = Factory.createChannels();\n this.global_emitter = new EventsDispatcher();\n this.sessionID = Runtime.randomInt(1000000000);\n\n this.timeline = new Timeline(this.key, this.sessionID, {\n cluster: this.config.cluster,\n features: Pusher.getClientFeatures(),\n params: this.config.timelineParams || {},\n limit: 50,\n level: TimelineLevel.INFO,\n version: Defaults.VERSION\n });\n if (this.config.enableStats) {\n this.timelineSender = Factory.createTimelineSender(this.timeline, {\n host: this.config.statsHost,\n path: '/timeline/v2/' + Runtime.TimelineTransport.name\n });\n }\n\n var getStrategy = (options: StrategyOptions) => {\n return Runtime.getDefaultStrategy(this.config, options, defineTransport);\n };\n\n this.connection = Factory.createConnectionManager(this.key, {\n getStrategy: getStrategy,\n timeline: this.timeline,\n activityTimeout: this.config.activityTimeout,\n pongTimeout: this.config.pongTimeout,\n unavailableTimeout: this.config.unavailableTimeout,\n useTLS: Boolean(this.config.useTLS)\n });\n\n this.connection.bind('connected', () => {\n this.subscribeAll();\n if (this.timelineSender) {\n this.timelineSender.send(this.connection.isUsingTLS());\n }\n });\n\n this.connection.bind('message', event => {\n var eventName = event.event;\n var internal = eventName.indexOf('pusher_internal:') === 0;\n if (event.channel) {\n var channel = this.channel(event.channel);\n if (channel) {\n channel.handleEvent(event);\n }\n }\n // Emit globally [deprecated]\n if (!internal) {\n this.global_emitter.emit(event.event, event.data);\n }\n });\n this.connection.bind('connecting', () => {\n this.channels.disconnect();\n });\n this.connection.bind('disconnected', () => {\n this.channels.disconnect();\n });\n this.connection.bind('error', err => {\n Logger.warn(err);\n });\n\n Pusher.instances.push(this);\n this.timeline.info({ instances: Pusher.instances.length });\n\n this.user = new UserFacade(this);\n\n if (Pusher.isReady) {\n this.connect();\n }\n }\n\n /**\n * Allows you to switch Pusher cluster without\n * losing all the channels/subscription binding\n * as this is internally managed by the SDK.\n */\n switchCluster(options: ClusterOptions) {\n const { appKey, cluster } = options;\n this.key = appKey;\n this.options = { ...this.options, cluster };\n this.config = getConfig(this.options, this);\n this.connection.switchCluster(this.key);\n }\n\n channel(name: string): Channel {\n return this.channels.find(name);\n }\n\n allChannels(): Channel[] {\n return this.channels.all();\n }\n\n connect() {\n this.connection.connect();\n\n if (this.timelineSender) {\n if (!this.timelineSenderTimer) {\n var usingTLS = this.connection.isUsingTLS();\n var timelineSender = this.timelineSender;\n this.timelineSenderTimer = new PeriodicTimer(60000, function() {\n timelineSender.send(usingTLS);\n });\n }\n }\n }\n\n disconnect() {\n this.connection.disconnect();\n\n if (this.timelineSenderTimer) {\n this.timelineSenderTimer.ensureAborted();\n this.timelineSenderTimer = null;\n }\n }\n\n bind(event_name: string, callback: Function, context?: any): Pusher {\n this.global_emitter.bind(event_name, callback, context);\n return this;\n }\n\n unbind(event_name?: string, callback?: Function, context?: any): Pusher {\n this.global_emitter.unbind(event_name, callback, context);\n return this;\n }\n\n bind_global(callback: Function): Pusher {\n this.global_emitter.bind_global(callback);\n return this;\n }\n\n unbind_global(callback?: Function): Pusher {\n this.global_emitter.unbind_global(callback);\n return this;\n }\n\n unbind_all(callback?: Function): Pusher {\n this.global_emitter.unbind_all();\n return this;\n }\n\n subscribeAll() {\n var channelName;\n for (channelName in this.channels.channels) {\n if (this.channels.channels.hasOwnProperty(channelName)) {\n this.subscribe(channelName);\n }\n }\n }\n\n subscribe(channel_name: string) {\n var channel = this.channels.add(channel_name, this);\n if (channel.subscriptionPending && channel.subscriptionCancelled) {\n channel.reinstateSubscription();\n } else if (\n !channel.subscriptionPending &&\n this.connection.state === 'connected'\n ) {\n channel.subscribe();\n }\n return channel;\n }\n\n unsubscribe(channel_name: string) {\n var channel = this.channels.find(channel_name);\n if (channel && channel.subscriptionPending) {\n channel.cancelSubscription();\n } else {\n channel = this.channels.remove(channel_name);\n if (channel && channel.subscribed) {\n channel.unsubscribe();\n }\n }\n }\n\n send_event(event_name: string, data: any, channel?: string) {\n return this.connection.send_event(event_name, data, channel);\n }\n\n shouldUseTLS(): boolean {\n return this.config.useTLS;\n }\n\n signin() {\n this.user.signin();\n }\n}\n\nfunction checkAppKey(key) {\n if (key === null || key === undefined) {\n throw 'You must pass your app key when you instantiate Pusher.';\n }\n}\n\nRuntime.setup(Pusher);\n","import Pusher from './pusher';\nimport { Options, validateOptions } from './options';\nimport * as nacl from 'tweetnacl';\n\nexport default class PusherWithEncryption extends Pusher {\n constructor(app_key: string, options: Options) {\n Pusher.logToConsole = PusherWithEncryption.logToConsole;\n Pusher.log = PusherWithEncryption.log;\n\n validateOptions(options);\n options.nacl = nacl;\n super(app_key, options);\n }\n}\n"],"sourceRoot":""} \ No newline at end of file diff --git a/dist/worker/pusher.worker.js b/dist/worker/pusher.worker.js index e1d9f6fe5..16aaac4af 100644 --- a/dist/worker/pusher.worker.js +++ b/dist/worker/pusher.worker.js @@ -1,5 +1,5 @@ /*! - * Pusher JavaScript Library v8.3.0 + * Pusher JavaScript Library v8.4.0 * https://pusher.com/ * * Copyright 2020, Pusher @@ -868,7 +868,7 @@ function safeJSONStringify(source) { // CONCATENATED MODULE: ./src/core/defaults.ts var Defaults = { - VERSION: "8.3.0", + VERSION: "8.4.0", PROTOCOL: 7, wsPort: 80, wssPort: 443, @@ -2110,6 +2110,11 @@ class connection_manager_ConnectionManager extends dispatcher_Dispatcher { }); this.updateStrategy(); } + switchCluster(key) { + this.key = key; + this.updateStrategy(); + this.retryIn(0); + } connect() { if (this.connection || this.runner) { return; @@ -4092,6 +4097,13 @@ class pusher_Pusher { this.connect(); } } + switchCluster(options) { + const { appKey, cluster } = options; + this.key = appKey; + this.options = Object.assign(Object.assign({}, this.options), { cluster }); + this.config = getConfig(this.options, this); + this.connection.switchCluster(this.key); + } channel(name) { return this.channels.find(name); } diff --git a/dist/worker/pusher.worker.js.map b/dist/worker/pusher.worker.js.map index 68a3bf366..326be4223 100644 --- a/dist/worker/pusher.worker.js.map +++ b/dist/worker/pusher.worker.js.map @@ -1 +1 @@ -{"version":3,"sources":["webpack://Pusher/webpack/universalModuleDefinition","webpack://Pusher/webpack/bootstrap","webpack://Pusher/./node_modules/@stablelib/base64/base64.ts","webpack://Pusher/./node_modules/@stablelib/utf8/utf8.ts","webpack://Pusher/./src/core/pusher.js","webpack://Pusher/./src/core/base64.ts","webpack://Pusher/./src/core/utils/timers/abstract_timer.ts","webpack://Pusher/./src/core/utils/timers/index.ts","webpack://Pusher/./src/core/util.ts","webpack://Pusher/./src/core/utils/collections.ts","webpack://Pusher/./src/core/defaults.ts","webpack://Pusher/./src/core/transports/url_schemes.ts","webpack://Pusher/./src/core/events/callback_registry.ts","webpack://Pusher/./src/core/events/dispatcher.ts","webpack://Pusher/./src/core/logger.ts","webpack://Pusher/./src/core/transports/transport_connection.ts","webpack://Pusher/./src/core/transports/transport.ts","webpack://Pusher/./src/runtimes/isomorphic/transports/transports.ts","webpack://Pusher/./src/core/transports/assistant_to_the_transport_manager.ts","webpack://Pusher/./src/core/connection/protocol/protocol.ts","webpack://Pusher/./src/core/connection/connection.ts","webpack://Pusher/./src/core/connection/handshake/index.ts","webpack://Pusher/./src/core/timeline/timeline_sender.ts","webpack://Pusher/./src/core/errors.ts","webpack://Pusher/./src/core/utils/url_store.ts","webpack://Pusher/./src/core/channels/channel.ts","webpack://Pusher/./src/core/channels/private_channel.ts","webpack://Pusher/./src/core/channels/members.ts","webpack://Pusher/./src/core/channels/presence_channel.ts","webpack://Pusher/./src/core/channels/encrypted_channel.ts","webpack://Pusher/./src/core/connection/connection_manager.ts","webpack://Pusher/./src/core/channels/channels.ts","webpack://Pusher/./src/core/utils/factory.ts","webpack://Pusher/./src/core/transports/transport_manager.ts","webpack://Pusher/./src/core/strategies/sequential_strategy.ts","webpack://Pusher/./src/core/strategies/best_connected_ever_strategy.ts","webpack://Pusher/./src/core/strategies/websocket_prioritized_cached_strategy.ts","webpack://Pusher/./src/core/strategies/delayed_strategy.ts","webpack://Pusher/./src/core/strategies/if_strategy.ts","webpack://Pusher/./src/core/strategies/first_connected_strategy.ts","webpack://Pusher/./src/runtimes/isomorphic/default_strategy.ts","webpack://Pusher/./src/runtimes/isomorphic/transports/transport_connection_initializer.ts","webpack://Pusher/./src/core/http/http_request.ts","webpack://Pusher/./src/core/http/state.ts","webpack://Pusher/./src/core/http/http_socket.ts","webpack://Pusher/./src/core/http/http_streaming_socket.ts","webpack://Pusher/./src/core/http/http_polling_socket.ts","webpack://Pusher/./src/runtimes/isomorphic/http/http_xhr_request.ts","webpack://Pusher/./src/runtimes/isomorphic/http/http.ts","webpack://Pusher/./src/runtimes/isomorphic/runtime.ts","webpack://Pusher/./src/runtimes/worker/net_info.ts","webpack://Pusher/./src/runtimes/worker/auth/fetch_auth.ts","webpack://Pusher/./src/runtimes/worker/timeline/fetch_timeline.ts","webpack://Pusher/./src/runtimes/worker/runtime.ts","webpack://Pusher/./src/core/timeline/level.ts","webpack://Pusher/./src/core/timeline/timeline.ts","webpack://Pusher/./src/core/strategies/transport_strategy.ts","webpack://Pusher/./src/core/strategies/strategy_builder.ts","webpack://Pusher/./src/core/options.ts","webpack://Pusher/./src/core/auth/options.ts","webpack://Pusher/./src/core/auth/user_authenticator.ts","webpack://Pusher/./src/core/auth/channel_authorizer.ts","webpack://Pusher/./src/core/auth/deprecated_channel_authorizer.ts","webpack://Pusher/./src/core/config.ts","webpack://Pusher/./src/core/watchlist.ts","webpack://Pusher/./src/core/utils/flat_promise.ts","webpack://Pusher/./src/core/user.ts","webpack://Pusher/./src/core/pusher.ts"],"names":[],"mappings":";;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AACD,O;QCV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qBAAqB,CAAC;AAClE,4BAAc,GAAc,cAAQ,CAAC,cAAc,CAAC;AAVxC,8FAAM;AA8N3B,SAAS,WAAW,CAAC,GAAG;IACtB,IAAI,GAAG,KAAK,IAAI,IAAI,GAAG,KAAK,SAAS,EAAE;QACrC,MAAM,yDAAyD,CAAC;KACjE;AACH,CAAC;AAED,cAAO,CAAC,KAAK,CAAC,aAAM,CAAC,CAAC","file":"pusher.worker.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"Pusher\"] = factory();\n\telse\n\t\troot[\"Pusher\"] = factory();\n})(this, function() {\nreturn "," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 2);\n","// Copyright (C) 2016 Dmitry Chestnykh\n// MIT License. See LICENSE file for details.\n\n/**\n * Package base64 implements Base64 encoding and decoding.\n */\n\n// Invalid character used in decoding to indicate\n// that the character to decode is out of range of\n// alphabet and cannot be decoded.\nconst INVALID_BYTE = 256;\n\n/**\n * Implements standard Base64 encoding.\n *\n * Operates in constant time.\n */\nexport class Coder {\n // TODO(dchest): methods to encode chunk-by-chunk.\n\n constructor(private _paddingCharacter = \"=\") { }\n\n encodedLength(length: number): number {\n if (!this._paddingCharacter) {\n return (length * 8 + 5) / 6 | 0;\n }\n return (length + 2) / 3 * 4 | 0;\n }\n\n encode(data: Uint8Array): string {\n let out = \"\";\n\n let i = 0;\n for (; i < data.length - 2; i += 3) {\n let c = (data[i] << 16) | (data[i + 1] << 8) | (data[i + 2]);\n out += this._encodeByte((c >>> 3 * 6) & 63);\n out += this._encodeByte((c >>> 2 * 6) & 63);\n out += this._encodeByte((c >>> 1 * 6) & 63);\n out += this._encodeByte((c >>> 0 * 6) & 63);\n }\n\n const left = data.length - i;\n if (left > 0) {\n let c = (data[i] << 16) | (left === 2 ? data[i + 1] << 8 : 0);\n out += this._encodeByte((c >>> 3 * 6) & 63);\n out += this._encodeByte((c >>> 2 * 6) & 63);\n if (left === 2) {\n out += this._encodeByte((c >>> 1 * 6) & 63);\n } else {\n out += this._paddingCharacter || \"\";\n }\n out += this._paddingCharacter || \"\";\n }\n\n return out;\n }\n\n maxDecodedLength(length: number): number {\n if (!this._paddingCharacter) {\n return (length * 6 + 7) / 8 | 0;\n }\n return length / 4 * 3 | 0;\n }\n\n decodedLength(s: string): number {\n return this.maxDecodedLength(s.length - this._getPaddingLength(s));\n }\n\n decode(s: string): Uint8Array {\n if (s.length === 0) {\n return new Uint8Array(0);\n }\n const paddingLength = this._getPaddingLength(s);\n const length = s.length - paddingLength;\n const out = new Uint8Array(this.maxDecodedLength(length));\n let op = 0;\n let i = 0;\n let haveBad = 0;\n let v0 = 0, v1 = 0, v2 = 0, v3 = 0;\n for (; i < length - 4; i += 4) {\n v0 = this._decodeChar(s.charCodeAt(i + 0));\n v1 = this._decodeChar(s.charCodeAt(i + 1));\n v2 = this._decodeChar(s.charCodeAt(i + 2));\n v3 = this._decodeChar(s.charCodeAt(i + 3));\n out[op++] = (v0 << 2) | (v1 >>> 4);\n out[op++] = (v1 << 4) | (v2 >>> 2);\n out[op++] = (v2 << 6) | v3;\n haveBad |= v0 & INVALID_BYTE;\n haveBad |= v1 & INVALID_BYTE;\n haveBad |= v2 & INVALID_BYTE;\n haveBad |= v3 & INVALID_BYTE;\n }\n if (i < length - 1) {\n v0 = this._decodeChar(s.charCodeAt(i));\n v1 = this._decodeChar(s.charCodeAt(i + 1));\n out[op++] = (v0 << 2) | (v1 >>> 4);\n haveBad |= v0 & INVALID_BYTE;\n haveBad |= v1 & INVALID_BYTE;\n }\n if (i < length - 2) {\n v2 = this._decodeChar(s.charCodeAt(i + 2));\n out[op++] = (v1 << 4) | (v2 >>> 2);\n haveBad |= v2 & INVALID_BYTE;\n }\n if (i < length - 3) {\n v3 = this._decodeChar(s.charCodeAt(i + 3));\n out[op++] = (v2 << 6) | v3;\n haveBad |= v3 & INVALID_BYTE;\n }\n if (haveBad !== 0) {\n throw new Error(\"Base64Coder: incorrect characters for decoding\");\n }\n return out;\n }\n\n // Standard encoding have the following encoded/decoded ranges,\n // which we need to convert between.\n //\n // ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 0123456789 + /\n // Index: 0 - 25 26 - 51 52 - 61 62 63\n // ASCII: 65 - 90 97 - 122 48 - 57 43 47\n //\n\n // Encode 6 bits in b into a new character.\n protected _encodeByte(b: number): string {\n // Encoding uses constant time operations as follows:\n //\n // 1. Define comparison of A with B using (A - B) >>> 8:\n // if A > B, then result is positive integer\n // if A <= B, then result is 0\n //\n // 2. Define selection of C or 0 using bitwise AND: X & C:\n // if X == 0, then result is 0\n // if X != 0, then result is C\n //\n // 3. Start with the smallest comparison (b >= 0), which is always\n // true, so set the result to the starting ASCII value (65).\n //\n // 4. Continue comparing b to higher ASCII values, and selecting\n // zero if comparison isn't true, otherwise selecting a value\n // to add to result, which:\n //\n // a) undoes the previous addition\n // b) provides new value to add\n //\n let result = b;\n // b >= 0\n result += 65;\n // b > 25\n result += ((25 - b) >>> 8) & ((0 - 65) - 26 + 97);\n // b > 51\n result += ((51 - b) >>> 8) & ((26 - 97) - 52 + 48);\n // b > 61\n result += ((61 - b) >>> 8) & ((52 - 48) - 62 + 43);\n // b > 62\n result += ((62 - b) >>> 8) & ((62 - 43) - 63 + 47);\n\n return String.fromCharCode(result);\n }\n\n // Decode a character code into a byte.\n // Must return 256 if character is out of alphabet range.\n protected _decodeChar(c: number): number {\n // Decoding works similar to encoding: using the same comparison\n // function, but now it works on ranges: result is always incremented\n // by value, but this value becomes zero if the range is not\n // satisfied.\n //\n // Decoding starts with invalid value, 256, which is then\n // subtracted when the range is satisfied. If none of the ranges\n // apply, the function returns 256, which is then checked by\n // the caller to throw error.\n let result = INVALID_BYTE; // start with invalid character\n\n // c == 43 (c > 42 and c < 44)\n result += (((42 - c) & (c - 44)) >>> 8) & (-INVALID_BYTE + c - 43 + 62);\n // c == 47 (c > 46 and c < 48)\n result += (((46 - c) & (c - 48)) >>> 8) & (-INVALID_BYTE + c - 47 + 63);\n // c > 47 and c < 58\n result += (((47 - c) & (c - 58)) >>> 8) & (-INVALID_BYTE + c - 48 + 52);\n // c > 64 and c < 91\n result += (((64 - c) & (c - 91)) >>> 8) & (-INVALID_BYTE + c - 65 + 0);\n // c > 96 and c < 123\n result += (((96 - c) & (c - 123)) >>> 8) & (-INVALID_BYTE + c - 97 + 26);\n\n return result;\n }\n\n private _getPaddingLength(s: string): number {\n let paddingLength = 0;\n if (this._paddingCharacter) {\n for (let i = s.length - 1; i >= 0; i--) {\n if (s[i] !== this._paddingCharacter) {\n break;\n }\n paddingLength++;\n }\n if (s.length < 4 || paddingLength > 2) {\n throw new Error(\"Base64Coder: incorrect padding\");\n }\n }\n return paddingLength;\n }\n\n}\n\nconst stdCoder = new Coder();\n\nexport function encode(data: Uint8Array): string {\n return stdCoder.encode(data);\n}\n\nexport function decode(s: string): Uint8Array {\n return stdCoder.decode(s);\n}\n\n/**\n * Implements URL-safe Base64 encoding.\n * (Same as Base64, but '+' is replaced with '-', and '/' with '_').\n *\n * Operates in constant time.\n */\nexport class URLSafeCoder extends Coder {\n // URL-safe encoding have the following encoded/decoded ranges:\n //\n // ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 0123456789 - _\n // Index: 0 - 25 26 - 51 52 - 61 62 63\n // ASCII: 65 - 90 97 - 122 48 - 57 45 95\n //\n\n protected _encodeByte(b: number): string {\n let result = b;\n // b >= 0\n result += 65;\n // b > 25\n result += ((25 - b) >>> 8) & ((0 - 65) - 26 + 97);\n // b > 51\n result += ((51 - b) >>> 8) & ((26 - 97) - 52 + 48);\n // b > 61\n result += ((61 - b) >>> 8) & ((52 - 48) - 62 + 45);\n // b > 62\n result += ((62 - b) >>> 8) & ((62 - 45) - 63 + 95);\n\n return String.fromCharCode(result);\n }\n\n protected _decodeChar(c: number): number {\n let result = INVALID_BYTE;\n\n // c == 45 (c > 44 and c < 46)\n result += (((44 - c) & (c - 46)) >>> 8) & (-INVALID_BYTE + c - 45 + 62);\n // c == 95 (c > 94 and c < 96)\n result += (((94 - c) & (c - 96)) >>> 8) & (-INVALID_BYTE + c - 95 + 63);\n // c > 47 and c < 58\n result += (((47 - c) & (c - 58)) >>> 8) & (-INVALID_BYTE + c - 48 + 52);\n // c > 64 and c < 91\n result += (((64 - c) & (c - 91)) >>> 8) & (-INVALID_BYTE + c - 65 + 0);\n // c > 96 and c < 123\n result += (((96 - c) & (c - 123)) >>> 8) & (-INVALID_BYTE + c - 97 + 26);\n\n return result;\n }\n}\n\nconst urlSafeCoder = new URLSafeCoder();\n\nexport function encodeURLSafe(data: Uint8Array): string {\n return urlSafeCoder.encode(data);\n}\n\nexport function decodeURLSafe(s: string): Uint8Array {\n return urlSafeCoder.decode(s);\n}\n\n\nexport const encodedLength = (length: number) =>\n stdCoder.encodedLength(length);\n\nexport const maxDecodedLength = (length: number) =>\n stdCoder.maxDecodedLength(length);\n\nexport const decodedLength = (s: string) =>\n stdCoder.decodedLength(s);\n","// Copyright (C) 2016 Dmitry Chestnykh\n// MIT License. See LICENSE file for details.\n\n/**\n * Package utf8 implements UTF-8 encoding and decoding.\n */\n\nconst INVALID_UTF16 = \"utf8: invalid string\";\nconst INVALID_UTF8 = \"utf8: invalid source encoding\";\n\n/**\n * Encodes the given string into UTF-8 byte array.\n * Throws if the source string has invalid UTF-16 encoding.\n */\nexport function encode(s: string): Uint8Array {\n // Calculate result length and allocate output array.\n // encodedLength() also validates string and throws errors,\n // so we don't need repeat validation here.\n const arr = new Uint8Array(encodedLength(s));\n\n let pos = 0;\n for (let i = 0; i < s.length; i++) {\n let c = s.charCodeAt(i);\n if (c < 0x80) {\n arr[pos++] = c;\n } else if (c < 0x800) {\n arr[pos++] = 0xc0 | c >> 6;\n arr[pos++] = 0x80 | c & 0x3f;\n } else if (c < 0xd800) {\n arr[pos++] = 0xe0 | c >> 12;\n arr[pos++] = 0x80 | (c >> 6) & 0x3f;\n arr[pos++] = 0x80 | c & 0x3f;\n } else {\n i++; // get one more character\n c = (c & 0x3ff) << 10;\n c |= s.charCodeAt(i) & 0x3ff;\n c += 0x10000;\n\n arr[pos++] = 0xf0 | c >> 18;\n arr[pos++] = 0x80 | (c >> 12) & 0x3f;\n arr[pos++] = 0x80 | (c >> 6) & 0x3f;\n arr[pos++] = 0x80 | c & 0x3f;\n }\n }\n return arr;\n}\n\n/**\n * Returns the number of bytes required to encode the given string into UTF-8.\n * Throws if the source string has invalid UTF-16 encoding.\n */\nexport function encodedLength(s: string): number {\n let result = 0;\n for (let i = 0; i < s.length; i++) {\n const c = s.charCodeAt(i);\n if (c < 0x80) {\n result += 1;\n } else if (c < 0x800) {\n result += 2;\n } else if (c < 0xd800) {\n result += 3;\n } else if (c <= 0xdfff) {\n if (i >= s.length - 1) {\n throw new Error(INVALID_UTF16);\n }\n i++; // \"eat\" next character\n result += 4;\n } else {\n throw new Error(INVALID_UTF16);\n }\n }\n return result;\n}\n\n/**\n * Decodes the given byte array from UTF-8 into a string.\n * Throws if encoding is invalid.\n */\nexport function decode(arr: Uint8Array): string {\n const chars: string[] = [];\n for (let i = 0; i < arr.length; i++) {\n let b = arr[i];\n\n if (b & 0x80) {\n let min;\n if (b < 0xe0) {\n // Need 1 more byte.\n if (i >= arr.length) {\n throw new Error(INVALID_UTF8);\n }\n const n1 = arr[++i];\n if ((n1 & 0xc0) !== 0x80) {\n throw new Error(INVALID_UTF8);\n }\n b = (b & 0x1f) << 6 | (n1 & 0x3f);\n min = 0x80;\n } else if (b < 0xf0) {\n // Need 2 more bytes.\n if (i >= arr.length - 1) {\n throw new Error(INVALID_UTF8);\n }\n const n1 = arr[++i];\n const n2 = arr[++i];\n if ((n1 & 0xc0) !== 0x80 || (n2 & 0xc0) !== 0x80) {\n throw new Error(INVALID_UTF8);\n }\n b = (b & 0x0f) << 12 | (n1 & 0x3f) << 6 | (n2 & 0x3f);\n min = 0x800;\n } else if (b < 0xf8) {\n // Need 3 more bytes.\n if (i >= arr.length - 2) {\n throw new Error(INVALID_UTF8);\n }\n const n1 = arr[++i];\n const n2 = arr[++i];\n const n3 = arr[++i];\n if ((n1 & 0xc0) !== 0x80 || (n2 & 0xc0) !== 0x80 || (n3 & 0xc0) !== 0x80) {\n throw new Error(INVALID_UTF8);\n }\n b = (b & 0x0f) << 18 | (n1 & 0x3f) << 12 | (n2 & 0x3f) << 6 | (n3 & 0x3f);\n min = 0x10000;\n } else {\n throw new Error(INVALID_UTF8);\n }\n\n if (b < min || (b >= 0xd800 && b <= 0xdfff)) {\n throw new Error(INVALID_UTF8);\n }\n\n if (b >= 0x10000) {\n // Surrogate pair.\n if (b > 0x10ffff) {\n throw new Error(INVALID_UTF8);\n }\n b -= 0x10000;\n chars.push(String.fromCharCode(0xd800 | (b >> 10)));\n b = 0xdc00 | (b & 0x3ff);\n }\n }\n\n chars.push(String.fromCharCode(b));\n }\n return chars.join(\"\");\n}\n","// required so we don't have to do require('pusher').default etc.\nmodule.exports = require('./pusher').default;\n","export default function encode(s: any): string {\n return btoa(utob(s));\n}\n\nvar fromCharCode = String.fromCharCode;\n\nvar b64chars =\n 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';\nvar b64tab = {};\n\nfor (var i = 0, l = b64chars.length; i < l; i++) {\n b64tab[b64chars.charAt(i)] = i;\n}\n\nvar cb_utob = function(c) {\n var cc = c.charCodeAt(0);\n return cc < 0x80\n ? c\n : cc < 0x800\n ? fromCharCode(0xc0 | (cc >>> 6)) + fromCharCode(0x80 | (cc & 0x3f))\n : fromCharCode(0xe0 | ((cc >>> 12) & 0x0f)) +\n fromCharCode(0x80 | ((cc >>> 6) & 0x3f)) +\n fromCharCode(0x80 | (cc & 0x3f));\n};\n\nvar utob = function(u) {\n return u.replace(/[^\\x00-\\x7F]/g, cb_utob);\n};\n\nvar cb_encode = function(ccc) {\n var padlen = [0, 2, 1][ccc.length % 3];\n var ord =\n (ccc.charCodeAt(0) << 16) |\n ((ccc.length > 1 ? ccc.charCodeAt(1) : 0) << 8) |\n (ccc.length > 2 ? ccc.charCodeAt(2) : 0);\n var chars = [\n b64chars.charAt(ord >>> 18),\n b64chars.charAt((ord >>> 12) & 63),\n padlen >= 2 ? '=' : b64chars.charAt((ord >>> 6) & 63),\n padlen >= 1 ? '=' : b64chars.charAt(ord & 63)\n ];\n return chars.join('');\n};\n\nvar btoa =\n global.btoa ||\n function(b) {\n return b.replace(/[\\s\\S]{1,3}/g, cb_encode);\n };\n","import TimedCallback from './timed_callback';\nimport { Delay, Scheduler, Canceller } from './scheduling';\n\nabstract class Timer {\n protected clear: Canceller;\n protected timer: number | void;\n\n constructor(\n set: Scheduler,\n clear: Canceller,\n delay: Delay,\n callback: TimedCallback\n ) {\n this.clear = clear;\n this.timer = set(() => {\n if (this.timer) {\n this.timer = callback(this.timer);\n }\n }, delay);\n }\n\n /** Returns whether the timer is still running.\n *\n * @return {Boolean}\n */\n isRunning(): boolean {\n return this.timer !== null;\n }\n\n /** Aborts a timer when it's running. */\n ensureAborted() {\n if (this.timer) {\n this.clear(this.timer);\n this.timer = null;\n }\n }\n}\n\nexport default Timer;\n","import Timer from './abstract_timer';\nimport TimedCallback from './timed_callback';\nimport { Delay } from './scheduling';\n\n// We need to bind clear functions this way to avoid exceptions on IE8\nfunction clearTimeout(timer) {\n global.clearTimeout(timer);\n}\nfunction clearInterval(timer) {\n global.clearInterval(timer);\n}\n\n/** Cross-browser compatible one-off timer abstraction.\n *\n * @param {Number} delay\n * @param {Function} callback\n */\nexport class OneOffTimer extends Timer {\n constructor(delay: Delay, callback: TimedCallback) {\n super(setTimeout, clearTimeout, delay, function(timer) {\n callback();\n return null;\n });\n }\n}\n\n/** Cross-browser compatible periodic timer abstraction.\n *\n * @param {Number} delay\n * @param {Function} callback\n */\nexport class PeriodicTimer extends Timer {\n constructor(delay: Delay, callback: TimedCallback) {\n super(setInterval, clearInterval, delay, function(timer) {\n callback();\n return timer;\n });\n }\n}\n","import * as Collections from './utils/collections';\nimport TimedCallback from './utils/timers/timed_callback';\nimport { OneOffTimer, PeriodicTimer } from './utils/timers';\n\nvar Util = {\n now(): number {\n if (Date.now) {\n return Date.now();\n } else {\n return new Date().valueOf();\n }\n },\n\n defer(callback: TimedCallback): OneOffTimer {\n return new OneOffTimer(0, callback);\n },\n\n /** Builds a function that will proxy a method call to its first argument.\n *\n * Allows partial application of arguments, so additional arguments are\n * prepended to the argument list.\n *\n * @param {String} name method name\n * @return {Function} proxy function\n */\n method(name: string, ...args: any[]): Function {\n var boundArguments = Array.prototype.slice.call(arguments, 1);\n return function(object) {\n return object[name].apply(object, boundArguments.concat(arguments));\n };\n }\n};\n\nexport default Util;\n","import base64encode from '../base64';\nimport Util from '../util';\n\n/** Merges multiple objects into the target argument.\n *\n * For properties that are plain Objects, performs a deep-merge. For the\n * rest it just copies the value of the property.\n *\n * To extend prototypes use it as following:\n * Pusher.Util.extend(Target.prototype, Base.prototype)\n *\n * You can also use it to merge objects without altering them:\n * Pusher.Util.extend({}, object1, object2)\n *\n * @param {Object} target\n * @return {Object} the target argument\n */\nexport function extend(target: any, ...sources: any[]): T {\n for (var i = 0; i < sources.length; i++) {\n var extensions = sources[i];\n for (var property in extensions) {\n if (\n extensions[property] &&\n extensions[property].constructor &&\n extensions[property].constructor === Object\n ) {\n target[property] = extend(target[property] || {}, extensions[property]);\n } else {\n target[property] = extensions[property];\n }\n }\n }\n return target;\n}\n\nexport function stringify(): string {\n var m = ['Pusher'];\n for (var i = 0; i < arguments.length; i++) {\n if (typeof arguments[i] === 'string') {\n m.push(arguments[i]);\n } else {\n m.push(safeJSONStringify(arguments[i]));\n }\n }\n return m.join(' : ');\n}\n\nexport function arrayIndexOf(array: any[], item: any): number {\n // MSIE doesn't have array.indexOf\n var nativeIndexOf = Array.prototype.indexOf;\n if (array === null) {\n return -1;\n }\n if (nativeIndexOf && array.indexOf === nativeIndexOf) {\n return array.indexOf(item);\n }\n for (var i = 0, l = array.length; i < l; i++) {\n if (array[i] === item) {\n return i;\n }\n }\n return -1;\n}\n\n/** Applies a function f to all properties of an object.\n *\n * Function f gets 3 arguments passed:\n * - element from the object\n * - key of the element\n * - reference to the object\n *\n * @param {Object} object\n * @param {Function} f\n */\nexport function objectApply(object: any, f: Function) {\n for (var key in object) {\n if (Object.prototype.hasOwnProperty.call(object, key)) {\n f(object[key], key, object);\n }\n }\n}\n\n/** Return a list of objects own proerty keys\n *\n * @param {Object} object\n * @returns {Array}\n */\nexport function keys(object: any): string[] {\n var keys = [];\n objectApply(object, function(_, key) {\n keys.push(key);\n });\n return keys;\n}\n\n/** Return a list of object's own property values\n *\n * @param {Object} object\n * @returns {Array}\n */\nexport function values(object: any): any[] {\n var values = [];\n objectApply(object, function(value) {\n values.push(value);\n });\n return values;\n}\n\n/** Applies a function f to all elements of an array.\n *\n * Function f gets 3 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function apply(array: any[], f: Function, context?: any) {\n for (var i = 0; i < array.length; i++) {\n f.call(context || global, array[i], i, array);\n }\n}\n\n/** Maps all elements of the array and returns the result.\n *\n * Function f gets 4 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n * - reference to the destination array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function map(array: any[], f: Function): any[] {\n var result = [];\n for (var i = 0; i < array.length; i++) {\n result.push(f(array[i], i, array, result));\n }\n return result;\n}\n\n/** Maps all elements of the object and returns the result.\n *\n * Function f gets 4 arguments passed:\n * - element from the object\n * - key of the element\n * - reference to the source object\n * - reference to the destination object\n *\n * @param {Object} object\n * @param {Function} f\n */\nexport function mapObject(object: any, f: Function): any {\n var result = {};\n objectApply(object, function(value, key) {\n result[key] = f(value);\n });\n return result;\n}\n\n/** Filters elements of the array using a test function.\n *\n * Function test gets 4 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n * - reference to the destination array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function filter(array: any[], test: Function): any[] {\n test =\n test ||\n function(value) {\n return !!value;\n };\n\n var result = [];\n for (var i = 0; i < array.length; i++) {\n if (test(array[i], i, array, result)) {\n result.push(array[i]);\n }\n }\n return result;\n}\n\n/** Filters properties of the object using a test function.\n *\n * Function test gets 4 arguments passed:\n * - element from the object\n * - key of the element\n * - reference to the source object\n * - reference to the destination object\n *\n * @param {Object} object\n * @param {Function} f\n */\nexport function filterObject(object: Object, test: Function) {\n var result = {};\n objectApply(object, function(value, key) {\n if ((test && test(value, key, object, result)) || Boolean(value)) {\n result[key] = value;\n }\n });\n return result;\n}\n\n/** Flattens an object into a two-dimensional array.\n *\n * @param {Object} object\n * @return {Array} resulting array of [key, value] pairs\n */\nexport function flatten(object: Object): any[] {\n var result = [];\n objectApply(object, function(value, key) {\n result.push([key, value]);\n });\n return result;\n}\n\n/** Checks whether any element of the array passes the test.\n *\n * Function test gets 3 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function any(array: any[], test: Function): boolean {\n for (var i = 0; i < array.length; i++) {\n if (test(array[i], i, array)) {\n return true;\n }\n }\n return false;\n}\n\n/** Checks whether all elements of the array pass the test.\n *\n * Function test gets 3 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function all(array: any[], test: Function): boolean {\n for (var i = 0; i < array.length; i++) {\n if (!test(array[i], i, array)) {\n return false;\n }\n }\n return true;\n}\n\nexport function encodeParamsObject(data): string {\n return mapObject(data, function(value) {\n if (typeof value === 'object') {\n value = safeJSONStringify(value);\n }\n return encodeURIComponent(base64encode(value.toString()));\n });\n}\n\nexport function buildQueryString(data: any): string {\n var params = filterObject(data, function(value) {\n return value !== undefined;\n });\n\n var query = map(\n flatten(encodeParamsObject(params)),\n Util.method('join', '=')\n ).join('&');\n\n return query;\n}\n\n/**\n * See https://github.com/douglascrockford/JSON-js/blob/master/cycle.js\n *\n * Remove circular references from an object. Required for JSON.stringify in\n * React Native, which tends to blow up a lot.\n *\n * @param {any} object\n * @return {any} Decycled object\n */\nexport function decycleObject(object: any): any {\n var objects = [],\n paths = [];\n\n return (function derez(value, path) {\n var i, name, nu;\n\n switch (typeof value) {\n case 'object':\n if (!value) {\n return null;\n }\n for (i = 0; i < objects.length; i += 1) {\n if (objects[i] === value) {\n return { $ref: paths[i] };\n }\n }\n\n objects.push(value);\n paths.push(path);\n\n if (Object.prototype.toString.apply(value) === '[object Array]') {\n nu = [];\n for (i = 0; i < value.length; i += 1) {\n nu[i] = derez(value[i], path + '[' + i + ']');\n }\n } else {\n nu = {};\n for (name in value) {\n if (Object.prototype.hasOwnProperty.call(value, name)) {\n nu[name] = derez(\n value[name],\n path + '[' + JSON.stringify(name) + ']'\n );\n }\n }\n }\n return nu;\n case 'number':\n case 'string':\n case 'boolean':\n return value;\n }\n })(object, '$');\n}\n\n/**\n * Provides a cross-browser and cross-platform way to safely stringify objects\n * into JSON. This is particularly necessary for ReactNative, where circular JSON\n * structures throw an exception.\n *\n * @param {any} source The object to stringify\n * @return {string} The serialized output.\n */\nexport function safeJSONStringify(source: any): string {\n try {\n return JSON.stringify(source);\n } catch (e) {\n return JSON.stringify(decycleObject(source));\n }\n}\n","import {\n ChannelAuthorizationOptions,\n UserAuthenticationOptions\n} from './auth/options';\nimport { AuthTransport } from './config';\n\nexport interface DefaultConfig {\n VERSION: string;\n PROTOCOL: number;\n wsPort: number;\n wssPort: number;\n wsPath: string;\n httpHost: string;\n httpPort: number;\n httpsPort: number;\n httpPath: string;\n stats_host: string;\n authEndpoint: string;\n authTransport: AuthTransport;\n activityTimeout: number;\n pongTimeout: number;\n unavailableTimeout: number;\n userAuthentication: UserAuthenticationOptions;\n channelAuthorization: ChannelAuthorizationOptions;\n\n cdn_http?: string;\n cdn_https?: string;\n dependency_suffix?: string;\n}\n\nvar Defaults: DefaultConfig = {\n VERSION: VERSION,\n PROTOCOL: 7,\n\n wsPort: 80,\n wssPort: 443,\n wsPath: '',\n // DEPRECATED: SockJS fallback parameters\n httpHost: 'sockjs.pusher.com',\n httpPort: 80,\n httpsPort: 443,\n httpPath: '/pusher',\n // DEPRECATED: Stats\n stats_host: 'stats.pusher.com',\n // DEPRECATED: Other settings\n authEndpoint: '/pusher/auth',\n authTransport: 'ajax',\n activityTimeout: 120000,\n pongTimeout: 30000,\n unavailableTimeout: 10000,\n userAuthentication: {\n endpoint: '/pusher/user-auth',\n transport: 'ajax'\n },\n channelAuthorization: {\n endpoint: '/pusher/auth',\n transport: 'ajax'\n },\n\n // CDN configuration\n cdn_http: CDN_HTTP,\n cdn_https: CDN_HTTPS,\n dependency_suffix: DEPENDENCY_SUFFIX\n};\n\nexport default Defaults;\n","import Defaults from '../defaults';\nimport { default as URLScheme, URLSchemeParams } from './url_scheme';\n\nfunction getGenericURL(\n baseScheme: string,\n params: URLSchemeParams,\n path: string\n): string {\n var scheme = baseScheme + (params.useTLS ? 's' : '');\n var host = params.useTLS ? params.hostTLS : params.hostNonTLS;\n return scheme + '://' + host + path;\n}\n\nfunction getGenericPath(key: string, queryString?: string): string {\n var path = '/app/' + key;\n var query =\n '?protocol=' +\n Defaults.PROTOCOL +\n '&client=js' +\n '&version=' +\n Defaults.VERSION +\n (queryString ? '&' + queryString : '');\n return path + query;\n}\n\nexport var ws: URLScheme = {\n getInitial: function(key: string, params: URLSchemeParams): string {\n var path = (params.httpPath || '') + getGenericPath(key, 'flash=false');\n return getGenericURL('ws', params, path);\n }\n};\n\nexport var http: URLScheme = {\n getInitial: function(key: string, params: URLSchemeParams): string {\n var path = (params.httpPath || '/pusher') + getGenericPath(key);\n return getGenericURL('http', params, path);\n }\n};\n\nexport var sockjs: URLScheme = {\n getInitial: function(key: string, params: URLSchemeParams): string {\n return getGenericURL('http', params, params.httpPath || '/pusher');\n },\n getPath: function(key: string, params: URLSchemeParams): string {\n return getGenericPath(key);\n }\n};\n","import Callback from './callback';\nimport * as Collections from '../utils/collections';\nimport CallbackTable from './callback_table';\n\nexport default class CallbackRegistry {\n _callbacks: CallbackTable;\n\n constructor() {\n this._callbacks = {};\n }\n\n get(name: string): Callback[] {\n return this._callbacks[prefix(name)];\n }\n\n add(name: string, callback: Function, context: any) {\n var prefixedEventName = prefix(name);\n this._callbacks[prefixedEventName] =\n this._callbacks[prefixedEventName] || [];\n this._callbacks[prefixedEventName].push({\n fn: callback,\n context: context\n });\n }\n\n remove(name?: string, callback?: Function, context?: any) {\n if (!name && !callback && !context) {\n this._callbacks = {};\n return;\n }\n\n var names = name ? [prefix(name)] : Collections.keys(this._callbacks);\n\n if (callback || context) {\n this.removeCallback(names, callback, context);\n } else {\n this.removeAllCallbacks(names);\n }\n }\n\n private removeCallback(names: string[], callback: Function, context: any) {\n Collections.apply(\n names,\n function(name) {\n this._callbacks[name] = Collections.filter(\n this._callbacks[name] || [],\n function(binding) {\n return (\n (callback && callback !== binding.fn) ||\n (context && context !== binding.context)\n );\n }\n );\n if (this._callbacks[name].length === 0) {\n delete this._callbacks[name];\n }\n },\n this\n );\n }\n\n private removeAllCallbacks(names: string[]) {\n Collections.apply(\n names,\n function(name) {\n delete this._callbacks[name];\n },\n this\n );\n }\n}\n\nfunction prefix(name: string): string {\n return '_' + name;\n}\n","import * as Collections from '../utils/collections';\nimport Callback from './callback';\nimport Metadata from '../channels/metadata';\nimport CallbackRegistry from './callback_registry';\n\n/** Manages callback bindings and event emitting.\n *\n * @param Function failThrough called when no listeners are bound to an event\n */\nexport default class Dispatcher {\n callbacks: CallbackRegistry;\n global_callbacks: Function[];\n failThrough: Function;\n\n constructor(failThrough?: Function) {\n this.callbacks = new CallbackRegistry();\n this.global_callbacks = [];\n this.failThrough = failThrough;\n }\n\n bind(eventName: string, callback: Function, context?: any) {\n this.callbacks.add(eventName, callback, context);\n return this;\n }\n\n bind_global(callback: Function) {\n this.global_callbacks.push(callback);\n return this;\n }\n\n unbind(eventName?: string, callback?: Function, context?: any) {\n this.callbacks.remove(eventName, callback, context);\n return this;\n }\n\n unbind_global(callback?: Function) {\n if (!callback) {\n this.global_callbacks = [];\n return this;\n }\n\n this.global_callbacks = Collections.filter(\n this.global_callbacks || [],\n c => c !== callback\n );\n\n return this;\n }\n\n unbind_all() {\n this.unbind();\n this.unbind_global();\n return this;\n }\n\n emit(eventName: string, data?: any, metadata?: Metadata): Dispatcher {\n for (var i = 0; i < this.global_callbacks.length; i++) {\n this.global_callbacks[i](eventName, data);\n }\n\n var callbacks = this.callbacks.get(eventName);\n var args = [];\n\n if (metadata) {\n // if there's a metadata argument, we need to call the callback with both\n // data and metadata regardless of whether data is undefined\n args.push(data, metadata);\n } else if (data) {\n // metadata is undefined, so we only need to call the callback with data\n // if data exists\n args.push(data);\n }\n\n if (callbacks && callbacks.length > 0) {\n for (var i = 0; i < callbacks.length; i++) {\n callbacks[i].fn.apply(callbacks[i].context || global, args);\n }\n } else if (this.failThrough) {\n this.failThrough(eventName, data);\n }\n\n return this;\n }\n}\n","import { stringify } from './utils/collections';\nimport Pusher from './pusher';\n\nclass Logger {\n debug(...args: any[]) {\n this.log(this.globalLog, args);\n }\n\n warn(...args: any[]) {\n this.log(this.globalLogWarn, args);\n }\n\n error(...args: any[]) {\n this.log(this.globalLogError, args);\n }\n\n private globalLog = (message: string) => {\n if (global.console && global.console.log) {\n global.console.log(message);\n }\n };\n\n private globalLogWarn(message: string) {\n if (global.console && global.console.warn) {\n global.console.warn(message);\n } else {\n this.globalLog(message);\n }\n }\n\n private globalLogError(message: string) {\n if (global.console && global.console.error) {\n global.console.error(message);\n } else {\n this.globalLogWarn(message);\n }\n }\n\n private log(\n defaultLoggingFunction: (message: string) => void,\n ...args: any[]\n ) {\n var message = stringify.apply(this, arguments);\n if (Pusher.log) {\n Pusher.log(message);\n } else if (Pusher.logToConsole) {\n const log = defaultLoggingFunction.bind(this);\n log(message);\n }\n }\n}\n\nexport default new Logger();\n","import Util from '../util';\nimport * as Collections from '../utils/collections';\nimport { default as EventsDispatcher } from '../events/dispatcher';\nimport Logger from '../logger';\nimport TransportHooks from './transport_hooks';\nimport Socket from '../socket';\nimport Runtime from 'runtime';\nimport Timeline from '../timeline/timeline';\nimport TransportConnectionOptions from './transport_connection_options';\n\n/** Provides universal API for transport connections.\n *\n * Transport connection is a low-level object that wraps a connection method\n * and exposes a simple evented interface for the connection state and\n * messaging. It does not implement Pusher-specific WebSocket protocol.\n *\n * Additionally, it fetches resources needed for transport to work and exposes\n * an interface for querying transport features.\n *\n * States:\n * - new - initial state after constructing the object\n * - initializing - during initialization phase, usually fetching resources\n * - intialized - ready to establish a connection\n * - connection - when connection is being established\n * - open - when connection ready to be used\n * - closed - after connection was closed be either side\n *\n * Emits:\n * - error - after the connection raised an error\n *\n * Options:\n * - useTLS - whether connection should be over TLS\n * - hostTLS - host to connect to when connection is over TLS\n * - hostNonTLS - host to connect to when connection is over TLS\n *\n * @param {String} key application key\n * @param {Object} options\n */\nexport default class TransportConnection extends EventsDispatcher {\n hooks: TransportHooks;\n name: string;\n priority: number;\n key: string;\n options: TransportConnectionOptions;\n state: string;\n timeline: Timeline;\n activityTimeout: number;\n id: number;\n socket: Socket;\n beforeOpen: Function;\n initialize: Function;\n\n constructor(\n hooks: TransportHooks,\n name: string,\n priority: number,\n key: string,\n options: TransportConnectionOptions\n ) {\n super();\n this.initialize = Runtime.transportConnectionInitializer;\n this.hooks = hooks;\n this.name = name;\n this.priority = priority;\n this.key = key;\n this.options = options;\n\n this.state = 'new';\n this.timeline = options.timeline;\n this.activityTimeout = options.activityTimeout;\n this.id = this.timeline.generateUniqueID();\n }\n\n /** Checks whether the transport handles activity checks by itself.\n *\n * @return {Boolean}\n */\n handlesActivityChecks(): boolean {\n return Boolean(this.hooks.handlesActivityChecks);\n }\n\n /** Checks whether the transport supports the ping/pong API.\n *\n * @return {Boolean}\n */\n supportsPing(): boolean {\n return Boolean(this.hooks.supportsPing);\n }\n\n /** Tries to establish a connection.\n *\n * @returns {Boolean} false if transport is in invalid state\n */\n connect(): boolean {\n if (this.socket || this.state !== 'initialized') {\n return false;\n }\n\n var url = this.hooks.urls.getInitial(this.key, this.options);\n try {\n this.socket = this.hooks.getSocket(url, this.options);\n } catch (e) {\n Util.defer(() => {\n this.onError(e);\n this.changeState('closed');\n });\n return false;\n }\n\n this.bindListeners();\n\n Logger.debug('Connecting', { transport: this.name, url });\n this.changeState('connecting');\n return true;\n }\n\n /** Closes the connection.\n *\n * @return {Boolean} true if there was a connection to close\n */\n close(): boolean {\n if (this.socket) {\n this.socket.close();\n return true;\n } else {\n return false;\n }\n }\n\n /** Sends data over the open connection.\n *\n * @param {String} data\n * @return {Boolean} true only when in the \"open\" state\n */\n send(data: any): boolean {\n if (this.state === 'open') {\n // Workaround for MobileSafari bug (see https://gist.github.com/2052006)\n Util.defer(() => {\n if (this.socket) {\n this.socket.send(data);\n }\n });\n return true;\n } else {\n return false;\n }\n }\n\n /** Sends a ping if the connection is open and transport supports it. */\n ping() {\n if (this.state === 'open' && this.supportsPing()) {\n this.socket.ping();\n }\n }\n\n private onOpen() {\n if (this.hooks.beforeOpen) {\n this.hooks.beforeOpen(\n this.socket,\n this.hooks.urls.getPath(this.key, this.options)\n );\n }\n this.changeState('open');\n this.socket.onopen = undefined;\n }\n\n private onError(error) {\n this.emit('error', { type: 'WebSocketError', error: error });\n this.timeline.error(this.buildTimelineMessage({ error: error.toString() }));\n }\n\n private onClose(closeEvent?: any) {\n if (closeEvent) {\n this.changeState('closed', {\n code: closeEvent.code,\n reason: closeEvent.reason,\n wasClean: closeEvent.wasClean\n });\n } else {\n this.changeState('closed');\n }\n this.unbindListeners();\n this.socket = undefined;\n }\n\n private onMessage(message) {\n this.emit('message', message);\n }\n\n private onActivity() {\n this.emit('activity');\n }\n\n private bindListeners() {\n this.socket.onopen = () => {\n this.onOpen();\n };\n this.socket.onerror = error => {\n this.onError(error);\n };\n this.socket.onclose = closeEvent => {\n this.onClose(closeEvent);\n };\n this.socket.onmessage = message => {\n this.onMessage(message);\n };\n\n if (this.supportsPing()) {\n this.socket.onactivity = () => {\n this.onActivity();\n };\n }\n }\n\n private unbindListeners() {\n if (this.socket) {\n this.socket.onopen = undefined;\n this.socket.onerror = undefined;\n this.socket.onclose = undefined;\n this.socket.onmessage = undefined;\n if (this.supportsPing()) {\n this.socket.onactivity = undefined;\n }\n }\n }\n\n private changeState(state: string, params?: any) {\n this.state = state;\n this.timeline.info(\n this.buildTimelineMessage({\n state: state,\n params: params\n })\n );\n this.emit(state, params);\n }\n\n buildTimelineMessage(message): any {\n return Collections.extend({ cid: this.id }, message);\n }\n}\n","import Factory from '../utils/factory';\nimport TransportHooks from './transport_hooks';\nimport TransportConnection from './transport_connection';\nimport TransportConnectionOptions from './transport_connection_options';\n\n/** Provides interface for transport connection instantiation.\n *\n * Takes transport-specific hooks as the only argument, which allow checking\n * for transport support and creating its connections.\n *\n * Supported hooks: * - file - the name of the file to be fetched during initialization\n * - urls - URL scheme to be used by transport\n * - handlesActivityCheck - true when the transport handles activity checks\n * - supportsPing - true when the transport has a ping/activity API\n * - isSupported - tells whether the transport is supported in the environment\n * - getSocket - creates a WebSocket-compatible transport socket\n *\n * See transports.js for specific implementations.\n *\n * @param {Object} hooks object containing all needed transport hooks\n */\nexport default class Transport {\n hooks: TransportHooks;\n\n constructor(hooks: TransportHooks) {\n this.hooks = hooks;\n }\n\n /** Returns whether the transport is supported in the environment.\n *\n * @param {Object} envronment te environment details (encryption, settings)\n * @returns {Boolean} true when the transport is supported\n */\n isSupported(environment: any): boolean {\n return this.hooks.isSupported(environment);\n }\n\n /** Creates a transport connection.\n *\n * @param {String} name\n * @param {Number} priority\n * @param {String} key the application key\n * @param {Object} options\n * @returns {TransportConnection}\n */\n createConnection(\n name: string,\n priority: number,\n key: string,\n options: any\n ): TransportConnection {\n return new TransportConnection(this.hooks, name, priority, key, options);\n }\n}\n","import * as URLSchemes from 'core/transports/url_schemes';\nimport URLScheme from 'core/transports/url_scheme';\nimport Transport from 'core/transports/transport';\nimport Util from 'core/util';\nimport * as Collections from 'core/utils/collections';\nimport TransportHooks from 'core/transports/transport_hooks';\nimport TransportsTable from 'core/transports/transports_table';\nimport Runtime from 'runtime';\n\n/** WebSocket transport.\n *\n * Uses native WebSocket implementation, including MozWebSocket supported by\n * earlier Firefox versions.\n */\nvar WSTransport = new Transport({\n urls: URLSchemes.ws,\n handlesActivityChecks: false,\n supportsPing: false,\n\n isInitialized: function() {\n return Boolean(Runtime.getWebSocketAPI());\n },\n isSupported: function(): boolean {\n return Boolean(Runtime.getWebSocketAPI());\n },\n getSocket: function(url) {\n return Runtime.createWebSocket(url);\n }\n});\n\nvar httpConfiguration = {\n urls: URLSchemes.http,\n handlesActivityChecks: false,\n supportsPing: true,\n isInitialized: function() {\n return true;\n }\n};\n\nexport var streamingConfiguration = Collections.extend(\n {\n getSocket: function(url) {\n return Runtime.HTTPFactory.createStreamingSocket(url);\n }\n },\n httpConfiguration\n);\nexport var pollingConfiguration = Collections.extend(\n {\n getSocket: function(url) {\n return Runtime.HTTPFactory.createPollingSocket(url);\n }\n },\n httpConfiguration\n);\n\nvar xhrConfiguration = {\n isSupported: function(): boolean {\n return Runtime.isXHRSupported();\n }\n};\n\n/** HTTP streaming transport using CORS-enabled XMLHttpRequest. */\nvar XHRStreamingTransport = new Transport(\n (\n Collections.extend({}, streamingConfiguration, xhrConfiguration)\n )\n);\n\n/** HTTP long-polling transport using CORS-enabled XMLHttpRequest. */\nvar XHRPollingTransport = new Transport(\n Collections.extend({}, pollingConfiguration, xhrConfiguration)\n);\n\nvar Transports: TransportsTable = {\n ws: WSTransport,\n xhr_streaming: XHRStreamingTransport,\n xhr_polling: XHRPollingTransport\n};\n\nexport default Transports;\n","import Util from '../util';\nimport * as Collections from '../utils/collections';\nimport TransportManager from './transport_manager';\nimport TransportConnection from './transport_connection';\nimport Transport from './transport';\nimport PingDelayOptions from './ping_delay_options';\n\n/** Creates transport connections monitored by a transport manager.\n *\n * When a transport is closed, it might mean the environment does not support\n * it. It's possible that messages get stuck in an intermediate buffer or\n * proxies terminate inactive connections. To combat these problems,\n * assistants monitor the connection lifetime, report unclean exits and\n * adjust ping timeouts to keep the connection active. The decision to disable\n * a transport is the manager's responsibility.\n *\n * @param {TransportManager} manager\n * @param {TransportConnection} transport\n * @param {Object} options\n */\nexport default class AssistantToTheTransportManager {\n manager: TransportManager;\n transport: Transport;\n minPingDelay: number;\n maxPingDelay: number;\n pingDelay: number;\n\n constructor(\n manager: TransportManager,\n transport: Transport,\n options: PingDelayOptions\n ) {\n this.manager = manager;\n this.transport = transport;\n this.minPingDelay = options.minPingDelay;\n this.maxPingDelay = options.maxPingDelay;\n this.pingDelay = undefined;\n }\n\n /** Creates a transport connection.\n *\n * This function has the same API as Transport#createConnection.\n *\n * @param {String} name\n * @param {Number} priority\n * @param {String} key the application key\n * @param {Object} options\n * @returns {TransportConnection}\n */\n createConnection(\n name: string,\n priority: number,\n key: string,\n options: Object\n ): TransportConnection {\n options = Collections.extend({}, options, {\n activityTimeout: this.pingDelay\n });\n var connection = this.transport.createConnection(\n name,\n priority,\n key,\n options\n );\n\n var openTimestamp = null;\n\n var onOpen = function() {\n connection.unbind('open', onOpen);\n connection.bind('closed', onClosed);\n openTimestamp = Util.now();\n };\n var onClosed = closeEvent => {\n connection.unbind('closed', onClosed);\n\n if (closeEvent.code === 1002 || closeEvent.code === 1003) {\n // we don't want to use transports not obeying the protocol\n this.manager.reportDeath();\n } else if (!closeEvent.wasClean && openTimestamp) {\n // report deaths only for short-living transport\n var lifespan = Util.now() - openTimestamp;\n if (lifespan < 2 * this.maxPingDelay) {\n this.manager.reportDeath();\n this.pingDelay = Math.max(lifespan / 2, this.minPingDelay);\n }\n }\n };\n\n connection.bind('open', onOpen);\n return connection;\n }\n\n /** Returns whether the transport is supported in the environment.\n *\n * This function has the same API as Transport#isSupported. Might return false\n * when the manager decides to kill the transport.\n *\n * @param {Object} environment the environment details (encryption, settings)\n * @returns {Boolean} true when the transport is supported\n */\n isSupported(environment: string): boolean {\n return this.manager.isAlive() && this.transport.isSupported(environment);\n }\n}\n","import Action from './action';\nimport { PusherEvent } from './message-types';\n/**\n * Provides functions for handling Pusher protocol-specific messages.\n */\n\nconst Protocol = {\n /**\n * Decodes a message in a Pusher format.\n *\n * The MessageEvent we receive from the transport should contain a pusher event\n * (https://pusher.com/docs/pusher_protocol#events) serialized as JSON in the\n * data field\n *\n * The pusher event may contain a data field too, and it may also be\n * serialised as JSON\n *\n * Throws errors when messages are not parse'able.\n *\n * @param {MessageEvent} messageEvent\n * @return {PusherEvent}\n */\n decodeMessage: function(messageEvent: MessageEvent): PusherEvent {\n try {\n var messageData = JSON.parse(messageEvent.data);\n var pusherEventData = messageData.data;\n if (typeof pusherEventData === 'string') {\n try {\n pusherEventData = JSON.parse(messageData.data);\n } catch (e) {}\n }\n var pusherEvent: PusherEvent = {\n event: messageData.event,\n channel: messageData.channel,\n data: pusherEventData\n };\n if (messageData.user_id) {\n pusherEvent.user_id = messageData.user_id;\n }\n return pusherEvent;\n } catch (e) {\n throw { type: 'MessageParseError', error: e, data: messageEvent.data };\n }\n },\n\n /**\n * Encodes a message to be sent.\n *\n * @param {PusherEvent} event\n * @return {String}\n */\n encodeMessage: function(event: PusherEvent): string {\n return JSON.stringify(event);\n },\n\n /**\n * Processes a handshake message and returns appropriate actions.\n *\n * Returns an object with an 'action' and other action-specific properties.\n *\n * There are three outcomes when calling this function. First is a successful\n * connection attempt, when pusher:connection_established is received, which\n * results in a 'connected' action with an 'id' property. When passed a\n * pusher:error event, it returns a result with action appropriate to the\n * close code and an error. Otherwise, it raises an exception.\n *\n * @param {String} message\n * @result Object\n */\n processHandshake: function(messageEvent: MessageEvent): Action {\n var message = Protocol.decodeMessage(messageEvent);\n\n if (message.event === 'pusher:connection_established') {\n if (!message.data.activity_timeout) {\n throw 'No activity timeout specified in handshake';\n }\n return {\n action: 'connected',\n id: message.data.socket_id,\n activityTimeout: message.data.activity_timeout * 1000\n };\n } else if (message.event === 'pusher:error') {\n // From protocol 6 close codes are sent only once, so this only\n // happens when connection does not support close codes\n return {\n action: this.getCloseAction(message.data),\n error: this.getCloseError(message.data)\n };\n } else {\n throw 'Invalid handshake';\n }\n },\n\n /**\n * Dispatches the close event and returns an appropriate action name.\n *\n * See:\n * 1. https://developer.mozilla.org/en-US/docs/WebSockets/WebSockets_reference/CloseEvent\n * 2. http://pusher.com/docs/pusher_protocol\n *\n * @param {CloseEvent} closeEvent\n * @return {String} close action name\n */\n getCloseAction: function(closeEvent): string {\n if (closeEvent.code < 4000) {\n // ignore 1000 CLOSE_NORMAL, 1001 CLOSE_GOING_AWAY,\n // 1005 CLOSE_NO_STATUS, 1006 CLOSE_ABNORMAL\n // ignore 1007...3999\n // handle 1002 CLOSE_PROTOCOL_ERROR, 1003 CLOSE_UNSUPPORTED,\n // 1004 CLOSE_TOO_LARGE\n if (closeEvent.code >= 1002 && closeEvent.code <= 1004) {\n return 'backoff';\n } else {\n return null;\n }\n } else if (closeEvent.code === 4000) {\n return 'tls_only';\n } else if (closeEvent.code < 4100) {\n return 'refused';\n } else if (closeEvent.code < 4200) {\n return 'backoff';\n } else if (closeEvent.code < 4300) {\n return 'retry';\n } else {\n // unknown error\n return 'refused';\n }\n },\n\n /**\n * Returns an error or null basing on the close event.\n *\n * Null is returned when connection was closed cleanly. Otherwise, an object\n * with error details is returned.\n *\n * @param {CloseEvent} closeEvent\n * @return {Object} error object\n */\n getCloseError: function(closeEvent): any {\n if (closeEvent.code !== 1000 && closeEvent.code !== 1001) {\n return {\n type: 'PusherError',\n data: {\n code: closeEvent.code,\n message: closeEvent.reason || closeEvent.message\n }\n };\n } else {\n return null;\n }\n }\n};\n\nexport default Protocol;\n","import * as Collections from '../utils/collections';\nimport { default as EventsDispatcher } from '../events/dispatcher';\nimport Protocol from './protocol/protocol';\nimport { PusherEvent } from './protocol/message-types';\nimport Logger from '../logger';\nimport TransportConnection from '../transports/transport_connection';\nimport Socket from '../socket';\n/**\n * Provides Pusher protocol interface for transports.\n *\n * Emits following events:\n * - message - on received messages\n * - ping - on ping requests\n * - pong - on pong responses\n * - error - when the transport emits an error\n * - closed - after closing the transport\n *\n * It also emits more events when connection closes with a code.\n * See Protocol.getCloseAction to get more details.\n *\n * @param {Number} id\n * @param {AbstractTransport} transport\n */\nexport default class Connection extends EventsDispatcher implements Socket {\n id: string;\n transport: TransportConnection;\n activityTimeout: number;\n\n constructor(id: string, transport: TransportConnection) {\n super();\n this.id = id;\n this.transport = transport;\n this.activityTimeout = transport.activityTimeout;\n this.bindListeners();\n }\n\n /** Returns whether used transport handles activity checks by itself\n *\n * @returns {Boolean} true if activity checks are handled by the transport\n */\n handlesActivityChecks() {\n return this.transport.handlesActivityChecks();\n }\n\n /** Sends raw data.\n *\n * @param {String} data\n */\n send(data: any): boolean {\n return this.transport.send(data);\n }\n\n /** Sends an event.\n *\n * @param {String} name\n * @param {String} data\n * @param {String} [channel]\n * @returns {Boolean} whether message was sent or not\n */\n send_event(name: string, data: any, channel?: string): boolean {\n var event: PusherEvent = { event: name, data: data };\n if (channel) {\n event.channel = channel;\n }\n Logger.debug('Event sent', event);\n return this.send(Protocol.encodeMessage(event));\n }\n\n /** Sends a ping message to the server.\n *\n * Basing on the underlying transport, it might send either transport's\n * protocol-specific ping or pusher:ping event.\n */\n ping() {\n if (this.transport.supportsPing()) {\n this.transport.ping();\n } else {\n this.send_event('pusher:ping', {});\n }\n }\n\n /** Closes the connection. */\n close() {\n this.transport.close();\n }\n\n private bindListeners() {\n var listeners = {\n message: (messageEvent: MessageEvent) => {\n var pusherEvent;\n try {\n pusherEvent = Protocol.decodeMessage(messageEvent);\n } catch (e) {\n this.emit('error', {\n type: 'MessageParseError',\n error: e,\n data: messageEvent.data\n });\n }\n\n if (pusherEvent !== undefined) {\n Logger.debug('Event recd', pusherEvent);\n\n switch (pusherEvent.event) {\n case 'pusher:error':\n this.emit('error', {\n type: 'PusherError',\n data: pusherEvent.data\n });\n break;\n case 'pusher:ping':\n this.emit('ping');\n break;\n case 'pusher:pong':\n this.emit('pong');\n break;\n }\n this.emit('message', pusherEvent);\n }\n },\n activity: () => {\n this.emit('activity');\n },\n error: error => {\n this.emit('error', error);\n },\n closed: closeEvent => {\n unbindListeners();\n\n if (closeEvent && closeEvent.code) {\n this.handleCloseEvent(closeEvent);\n }\n\n this.transport = null;\n this.emit('closed');\n }\n };\n\n var unbindListeners = () => {\n Collections.objectApply(listeners, (listener, event) => {\n this.transport.unbind(event, listener);\n });\n };\n\n Collections.objectApply(listeners, (listener, event) => {\n this.transport.bind(event, listener);\n });\n }\n\n private handleCloseEvent(closeEvent: any) {\n var action = Protocol.getCloseAction(closeEvent);\n var error = Protocol.getCloseError(closeEvent);\n if (error) {\n this.emit('error', error);\n }\n if (action) {\n this.emit(action, { action: action, error: error });\n }\n }\n}\n","import Util from '../../util';\nimport * as Collections from '../../utils/collections';\nimport Protocol from '../protocol/protocol';\nimport Connection from '../connection';\nimport TransportConnection from '../../transports/transport_connection';\nimport HandshakePayload from './handshake_payload';\n\n/**\n * Handles Pusher protocol handshakes for transports.\n *\n * Calls back with a result object after handshake is completed. Results\n * always have two fields:\n * - action - string describing action to be taken after the handshake\n * - transport - the transport object passed to the constructor\n *\n * Different actions can set different additional properties on the result.\n * In the case of 'connected' action, there will be a 'connection' property\n * containing a Connection object for the transport. Other actions should\n * carry an 'error' property.\n *\n * @param {AbstractTransport} transport\n * @param {Function} callback\n */\nexport default class Handshake {\n transport: TransportConnection;\n callback: (HandshakePayload) => void;\n onMessage: Function;\n onClosed: Function;\n\n constructor(\n transport: TransportConnection,\n callback: (HandshakePayload) => void\n ) {\n this.transport = transport;\n this.callback = callback;\n this.bindListeners();\n }\n\n close() {\n this.unbindListeners();\n this.transport.close();\n }\n\n private bindListeners() {\n this.onMessage = m => {\n this.unbindListeners();\n\n var result;\n try {\n result = Protocol.processHandshake(m);\n } catch (e) {\n this.finish('error', { error: e });\n this.transport.close();\n return;\n }\n\n if (result.action === 'connected') {\n this.finish('connected', {\n connection: new Connection(result.id, this.transport),\n activityTimeout: result.activityTimeout\n });\n } else {\n this.finish(result.action, { error: result.error });\n this.transport.close();\n }\n };\n\n this.onClosed = closeEvent => {\n this.unbindListeners();\n\n var action = Protocol.getCloseAction(closeEvent) || 'backoff';\n var error = Protocol.getCloseError(closeEvent);\n this.finish(action, { error: error });\n };\n\n this.transport.bind('message', this.onMessage);\n this.transport.bind('closed', this.onClosed);\n }\n\n private unbindListeners() {\n this.transport.unbind('message', this.onMessage);\n this.transport.unbind('closed', this.onClosed);\n }\n\n private finish(action: string, params: any) {\n this.callback(\n Collections.extend({ transport: this.transport, action: action }, params)\n );\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport base64encode from '../base64';\nimport Timeline from './timeline';\nimport Runtime from 'runtime';\n\nexport interface TimelineSenderOptions {\n host?: string;\n port?: number;\n path?: string;\n}\n\nexport default class TimelineSender {\n timeline: Timeline;\n options: TimelineSenderOptions;\n host: string;\n\n constructor(timeline: Timeline, options: TimelineSenderOptions) {\n this.timeline = timeline;\n this.options = options || {};\n }\n\n send(useTLS: boolean, callback?: Function) {\n if (this.timeline.isEmpty()) {\n return;\n }\n\n this.timeline.send(\n Runtime.TimelineTransport.getAgent(this, useTLS),\n callback\n );\n }\n}\n","/** Error classes used throughout the library. */\n// https://github.com/Microsoft/TypeScript-wiki/blob/master/Breaking-Changes.md#extending-built-ins-like-error-array-and-map-may-no-longer-work\nexport class BadEventName extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\nexport class BadChannelName extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\nexport class RequestTimedOut extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class TransportPriorityTooLow extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class TransportClosed extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class UnsupportedFeature extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class UnsupportedTransport extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class UnsupportedStrategy extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class HTTPAuthError extends Error {\n status: number;\n constructor(status: number, msg?: string) {\n super(msg);\n this.status = status;\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n","/**\n * A place to store help URLs for error messages etc\n */\n\nconst urlStore = {\n baseUrl: 'https://pusher.com',\n urls: {\n authenticationEndpoint: {\n path: '/docs/channels/server_api/authenticating_users'\n },\n authorizationEndpoint: {\n path: '/docs/channels/server_api/authorizing-users/'\n },\n javascriptQuickStart: {\n path: '/docs/javascript_quick_start'\n },\n triggeringClientEvents: {\n path: '/docs/client_api_guide/client_events#trigger-events'\n },\n encryptedChannelSupport: {\n fullUrl:\n 'https://github.com/pusher/pusher-js/tree/cc491015371a4bde5743d1c87a0fbac0feb53195#encrypted-channel-support'\n }\n }\n};\n\n/** Builds a consistent string with links to pusher documentation\n *\n * @param {string} key - relevant key in the url_store.urls object\n * @return {string} suffix string to append to log message\n */\nconst buildLogSuffix = function(key: string): string {\n const urlPrefix = 'See:';\n const urlObj = urlStore.urls[key];\n if (!urlObj) return '';\n\n let url;\n if (urlObj.fullUrl) {\n url = urlObj.fullUrl;\n } else if (urlObj.path) {\n url = urlStore.baseUrl + urlObj.path;\n }\n\n if (!url) return '';\n return `${urlPrefix} ${url}`;\n};\n\nexport default { buildLogSuffix };\n","import { default as EventsDispatcher } from '../events/dispatcher';\nimport * as Errors from '../errors';\nimport Logger from '../logger';\nimport Pusher from '../pusher';\nimport { PusherEvent } from '../connection/protocol/message-types';\nimport Metadata from './metadata';\nimport UrlStore from '../utils/url_store';\nimport {\n ChannelAuthorizationData,\n ChannelAuthorizationCallback\n} from '../auth/options';\nimport { HTTPAuthError } from '../errors';\n\n/** Provides base public channel interface with an event emitter.\n *\n * Emits:\n * - pusher:subscription_succeeded - after subscribing successfully\n * - other non-internal events\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\nexport default class Channel extends EventsDispatcher {\n name: string;\n pusher: Pusher;\n subscribed: boolean;\n subscriptionPending: boolean;\n subscriptionCancelled: boolean;\n subscriptionCount: null;\n\n constructor(name: string, pusher: Pusher) {\n super(function(event, data) {\n Logger.debug('No callbacks on ' + name + ' for ' + event);\n });\n\n this.name = name;\n this.pusher = pusher;\n this.subscribed = false;\n this.subscriptionPending = false;\n this.subscriptionCancelled = false;\n }\n\n /** Skips authorization, since public channels don't require it.\n *\n * @param {Function} callback\n */\n authorize(socketId: string, callback: ChannelAuthorizationCallback) {\n return callback(null, { auth: '' });\n }\n\n /** Triggers an event */\n trigger(event: string, data: any) {\n if (event.indexOf('client-') !== 0) {\n throw new Errors.BadEventName(\n \"Event '\" + event + \"' does not start with 'client-'\"\n );\n }\n if (!this.subscribed) {\n var suffix = UrlStore.buildLogSuffix('triggeringClientEvents');\n Logger.warn(\n `Client event triggered before channel 'subscription_succeeded' event . ${suffix}`\n );\n }\n return this.pusher.send_event(event, data, this.name);\n }\n\n /** Signals disconnection to the channel. For internal use only. */\n disconnect() {\n this.subscribed = false;\n this.subscriptionPending = false;\n }\n\n /** Handles a PusherEvent. For internal use only.\n *\n * @param {PusherEvent} event\n */\n handleEvent(event: PusherEvent) {\n var eventName = event.event;\n var data = event.data;\n if (eventName === 'pusher_internal:subscription_succeeded') {\n this.handleSubscriptionSucceededEvent(event);\n } else if (eventName === 'pusher_internal:subscription_count') {\n this.handleSubscriptionCountEvent(event);\n } else if (eventName.indexOf('pusher_internal:') !== 0) {\n var metadata: Metadata = {};\n this.emit(eventName, data, metadata);\n }\n }\n\n handleSubscriptionSucceededEvent(event: PusherEvent) {\n this.subscriptionPending = false;\n this.subscribed = true;\n if (this.subscriptionCancelled) {\n this.pusher.unsubscribe(this.name);\n } else {\n this.emit('pusher:subscription_succeeded', event.data);\n }\n }\n\n handleSubscriptionCountEvent(event: PusherEvent) {\n if (event.data.subscription_count) {\n this.subscriptionCount = event.data.subscription_count;\n }\n\n this.emit('pusher:subscription_count', event.data);\n }\n\n /** Sends a subscription request. For internal use only. */\n subscribe() {\n if (this.subscribed) {\n return;\n }\n this.subscriptionPending = true;\n this.subscriptionCancelled = false;\n this.authorize(\n this.pusher.connection.socket_id,\n (error: Error | null, data: ChannelAuthorizationData) => {\n if (error) {\n this.subscriptionPending = false;\n // Why not bind to 'pusher:subscription_error' a level up, and log there?\n // Binding to this event would cause the warning about no callbacks being\n // bound (see constructor) to be suppressed, that's not what we want.\n Logger.error(error.toString());\n this.emit(\n 'pusher:subscription_error',\n Object.assign(\n {},\n {\n type: 'AuthError',\n error: error.message\n },\n error instanceof HTTPAuthError ? { status: error.status } : {}\n )\n );\n } else {\n this.pusher.send_event('pusher:subscribe', {\n auth: data.auth,\n channel_data: data.channel_data,\n channel: this.name\n });\n }\n }\n );\n }\n\n /** Sends an unsubscription request. For internal use only. */\n unsubscribe() {\n this.subscribed = false;\n this.pusher.send_event('pusher:unsubscribe', {\n channel: this.name\n });\n }\n\n /** Cancels an in progress subscription. For internal use only. */\n cancelSubscription() {\n this.subscriptionCancelled = true;\n }\n\n /** Reinstates an in progress subscripiton. For internal use only. */\n reinstateSubscription() {\n this.subscriptionCancelled = false;\n }\n}\n","import Factory from '../utils/factory';\nimport Channel from './channel';\nimport { ChannelAuthorizationCallback } from '../auth/options';\n\n/** Extends public channels to provide private channel interface.\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\nexport default class PrivateChannel extends Channel {\n /** Authorizes the connection to use the channel.\n *\n * @param {String} socketId\n * @param {Function} callback\n */\n authorize(socketId: string, callback: ChannelAuthorizationCallback) {\n return this.pusher.config.channelAuthorizer(\n {\n channelName: this.name,\n socketId: socketId\n },\n callback\n );\n }\n}\n","import * as Collections from '../utils/collections';\n\n/** Represents a collection of members of a presence channel. */\nexport default class Members {\n members: any;\n count: number;\n myID: any;\n me: any;\n\n constructor() {\n this.reset();\n }\n\n /** Returns member's info for given id.\n *\n * Resulting object containts two fields - id and info.\n *\n * @param {Number} id\n * @return {Object} member's info or null\n */\n get(id: string): any {\n if (Object.prototype.hasOwnProperty.call(this.members, id)) {\n return {\n id: id,\n info: this.members[id]\n };\n } else {\n return null;\n }\n }\n\n /** Calls back for each member in unspecified order.\n *\n * @param {Function} callback\n */\n each(callback: Function) {\n Collections.objectApply(this.members, (member, id) => {\n callback(this.get(id));\n });\n }\n\n /** Updates the id for connected member. For internal use only. */\n setMyID(id: string) {\n this.myID = id;\n }\n\n /** Handles subscription data. For internal use only. */\n onSubscription(subscriptionData: any) {\n this.members = subscriptionData.presence.hash;\n this.count = subscriptionData.presence.count;\n this.me = this.get(this.myID);\n }\n\n /** Adds a new member to the collection. For internal use only. */\n addMember(memberData: any) {\n if (this.get(memberData.user_id) === null) {\n this.count++;\n }\n this.members[memberData.user_id] = memberData.user_info;\n return this.get(memberData.user_id);\n }\n\n /** Adds a member from the collection. For internal use only. */\n removeMember(memberData: any) {\n var member = this.get(memberData.user_id);\n if (member) {\n delete this.members[memberData.user_id];\n this.count--;\n }\n return member;\n }\n\n /** Resets the collection to the initial state. For internal use only. */\n reset() {\n this.members = {};\n this.count = 0;\n this.myID = null;\n this.me = null;\n }\n}\n","import PrivateChannel from './private_channel';\nimport Logger from '../logger';\nimport Members from './members';\nimport Pusher from '../pusher';\nimport UrlStore from 'core/utils/url_store';\nimport { PusherEvent } from '../connection/protocol/message-types';\nimport Metadata from './metadata';\nimport { ChannelAuthorizationData } from '../auth/options';\n\nexport default class PresenceChannel extends PrivateChannel {\n members: Members;\n\n /** Adds presence channel functionality to private channels.\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\n constructor(name: string, pusher: Pusher) {\n super(name, pusher);\n this.members = new Members();\n }\n\n /** Authorizes the connection as a member of the channel.\n *\n * @param {String} socketId\n * @param {Function} callback\n */\n authorize(socketId: string, callback: Function) {\n super.authorize(socketId, async (error, authData) => {\n if (!error) {\n authData = authData as ChannelAuthorizationData;\n if (authData.channel_data != null) {\n var channelData = JSON.parse(authData.channel_data);\n this.members.setMyID(channelData.user_id);\n } else {\n await this.pusher.user.signinDonePromise;\n if (this.pusher.user.user_data != null) {\n // If the user is signed in, get the id of the authenticated user\n // and allow the presence authorization to continue.\n this.members.setMyID(this.pusher.user.user_data.id);\n } else {\n let suffix = UrlStore.buildLogSuffix('authorizationEndpoint');\n Logger.error(\n `Invalid auth response for channel '${this.name}', ` +\n `expected 'channel_data' field. ${suffix}, ` +\n `or the user should be signed in.`\n );\n callback('Invalid auth response');\n return;\n }\n }\n }\n callback(error, authData);\n });\n }\n\n /** Handles presence and subscription events. For internal use only.\n *\n * @param {PusherEvent} event\n */\n handleEvent(event: PusherEvent) {\n var eventName = event.event;\n if (eventName.indexOf('pusher_internal:') === 0) {\n this.handleInternalEvent(event);\n } else {\n var data = event.data;\n var metadata: Metadata = {};\n if (event.user_id) {\n metadata.user_id = event.user_id;\n }\n this.emit(eventName, data, metadata);\n }\n }\n handleInternalEvent(event: PusherEvent) {\n var eventName = event.event;\n var data = event.data;\n switch (eventName) {\n case 'pusher_internal:subscription_succeeded':\n this.handleSubscriptionSucceededEvent(event);\n break;\n case 'pusher_internal:subscription_count':\n this.handleSubscriptionCountEvent(event);\n break;\n case 'pusher_internal:member_added':\n var addedMember = this.members.addMember(data);\n this.emit('pusher:member_added', addedMember);\n break;\n case 'pusher_internal:member_removed':\n var removedMember = this.members.removeMember(data);\n if (removedMember) {\n this.emit('pusher:member_removed', removedMember);\n }\n break;\n }\n }\n\n handleSubscriptionSucceededEvent(event: PusherEvent) {\n this.subscriptionPending = false;\n this.subscribed = true;\n if (this.subscriptionCancelled) {\n this.pusher.unsubscribe(this.name);\n } else {\n this.members.onSubscription(event.data);\n this.emit('pusher:subscription_succeeded', this.members);\n }\n }\n\n /** Resets the channel state, including members map. For internal use only. */\n disconnect() {\n this.members.reset();\n super.disconnect();\n }\n}\n","import PrivateChannel from './private_channel';\nimport * as Errors from '../errors';\nimport Logger from '../logger';\nimport Pusher from '../pusher';\nimport { decode as encodeUTF8 } from '@stablelib/utf8';\nimport { decode as decodeBase64 } from '@stablelib/base64';\nimport Dispatcher from '../events/dispatcher';\nimport { PusherEvent } from '../connection/protocol/message-types';\nimport {\n ChannelAuthorizationData,\n ChannelAuthorizationCallback\n} from '../auth/options';\nimport * as nacl from 'tweetnacl';\n\n/** Extends private channels to provide encrypted channel interface.\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\nexport default class EncryptedChannel extends PrivateChannel {\n key: Uint8Array = null;\n nacl: nacl;\n\n constructor(name: string, pusher: Pusher, nacl: nacl) {\n super(name, pusher);\n this.nacl = nacl;\n }\n\n /** Authorizes the connection to use the channel.\n *\n * @param {String} socketId\n * @param {Function} callback\n */\n authorize(socketId: string, callback: ChannelAuthorizationCallback) {\n super.authorize(\n socketId,\n (error: Error | null, authData: ChannelAuthorizationData) => {\n if (error) {\n callback(error, authData);\n return;\n }\n let sharedSecret = authData['shared_secret'];\n if (!sharedSecret) {\n callback(\n new Error(\n `No shared_secret key in auth payload for encrypted channel: ${this.name}`\n ),\n null\n );\n return;\n }\n this.key = decodeBase64(sharedSecret);\n delete authData['shared_secret'];\n callback(null, authData);\n }\n );\n }\n\n trigger(event: string, data: any): boolean {\n throw new Errors.UnsupportedFeature(\n 'Client events are not currently supported for encrypted channels'\n );\n }\n\n /** Handles an event. For internal use only.\n *\n * @param {PusherEvent} event\n */\n handleEvent(event: PusherEvent) {\n var eventName = event.event;\n var data = event.data;\n if (\n eventName.indexOf('pusher_internal:') === 0 ||\n eventName.indexOf('pusher:') === 0\n ) {\n super.handleEvent(event);\n return;\n }\n this.handleEncryptedEvent(eventName, data);\n }\n\n private handleEncryptedEvent(event: string, data: any): void {\n if (!this.key) {\n Logger.debug(\n 'Received encrypted event before key has been retrieved from the authEndpoint'\n );\n return;\n }\n if (!data.ciphertext || !data.nonce) {\n Logger.error(\n 'Unexpected format for encrypted event, expected object with `ciphertext` and `nonce` fields, got: ' +\n data\n );\n return;\n }\n let cipherText = decodeBase64(data.ciphertext);\n if (cipherText.length < this.nacl.secretbox.overheadLength) {\n Logger.error(\n `Expected encrypted event ciphertext length to be ${this.nacl.secretbox.overheadLength}, got: ${cipherText.length}`\n );\n return;\n }\n let nonce = decodeBase64(data.nonce);\n if (nonce.length < this.nacl.secretbox.nonceLength) {\n Logger.error(\n `Expected encrypted event nonce length to be ${this.nacl.secretbox.nonceLength}, got: ${nonce.length}`\n );\n return;\n }\n\n let bytes = this.nacl.secretbox.open(cipherText, nonce, this.key);\n if (bytes === null) {\n Logger.debug(\n 'Failed to decrypt an event, probably because it was encrypted with a different key. Fetching a new key from the authEndpoint...'\n );\n // Try a single time to retrieve a new auth key and decrypt the event with it\n // If this fails, a new key will be requested when a new message is received\n this.authorize(this.pusher.connection.socket_id, (error, authData) => {\n if (error) {\n Logger.error(\n `Failed to make a request to the authEndpoint: ${authData}. Unable to fetch new key, so dropping encrypted event`\n );\n return;\n }\n bytes = this.nacl.secretbox.open(cipherText, nonce, this.key);\n if (bytes === null) {\n Logger.error(\n `Failed to decrypt event with new key. Dropping encrypted event`\n );\n return;\n }\n this.emit(event, this.getDataToEmit(bytes));\n return;\n });\n return;\n }\n this.emit(event, this.getDataToEmit(bytes));\n }\n\n // Try and parse the decrypted bytes as JSON. If we can't parse it, just\n // return the utf-8 string\n getDataToEmit(bytes: Uint8Array): string {\n let raw = encodeUTF8(bytes);\n try {\n return JSON.parse(raw);\n } catch {\n return raw;\n }\n }\n}\n","import { default as EventsDispatcher } from '../events/dispatcher';\nimport { OneOffTimer as Timer } from '../utils/timers';\nimport { Config } from '../config';\nimport Logger from '../logger';\nimport HandshakePayload from './handshake/handshake_payload';\nimport Connection from './connection';\nimport Strategy from '../strategies/strategy';\nimport StrategyRunner from '../strategies/strategy_runner';\nimport * as Collections from '../utils/collections';\nimport Timeline from '../timeline/timeline';\nimport ConnectionManagerOptions from './connection_manager_options';\nimport Runtime from 'runtime';\n\nimport {\n ErrorCallbacks,\n HandshakeCallbacks,\n ConnectionCallbacks\n} from './callbacks';\nimport Action from './protocol/action';\n\n/** Manages connection to Pusher.\n *\n * Uses a strategy (currently only default), timers and network availability\n * info to establish a connection and export its state. In case of failures,\n * manages reconnection attempts.\n *\n * Exports state changes as following events:\n * - \"state_change\", { previous: p, current: state }\n * - state\n *\n * States:\n * - initialized - initial state, never transitioned to\n * - connecting - connection is being established\n * - connected - connection has been fully established\n * - disconnected - on requested disconnection\n * - unavailable - after connection timeout or when there's no network\n * - failed - when the connection strategy is not supported\n *\n * Options:\n * - unavailableTimeout - time to transition to unavailable state\n * - activityTimeout - time after which ping message should be sent\n * - pongTimeout - time for Pusher to respond with pong before reconnecting\n *\n * @param {String} key application key\n * @param {Object} options\n */\nexport default class ConnectionManager extends EventsDispatcher {\n key: string;\n options: ConnectionManagerOptions;\n state: string;\n connection: Connection;\n usingTLS: boolean;\n timeline: Timeline;\n socket_id: string;\n unavailableTimer: Timer;\n activityTimer: Timer;\n retryTimer: Timer;\n activityTimeout: number;\n strategy: Strategy;\n runner: StrategyRunner;\n errorCallbacks: ErrorCallbacks;\n handshakeCallbacks: HandshakeCallbacks;\n connectionCallbacks: ConnectionCallbacks;\n\n constructor(key: string, options: ConnectionManagerOptions) {\n super();\n this.state = 'initialized';\n this.connection = null;\n\n this.key = key;\n this.options = options;\n this.timeline = this.options.timeline;\n this.usingTLS = this.options.useTLS;\n\n this.errorCallbacks = this.buildErrorCallbacks();\n this.connectionCallbacks = this.buildConnectionCallbacks(\n this.errorCallbacks\n );\n this.handshakeCallbacks = this.buildHandshakeCallbacks(this.errorCallbacks);\n\n var Network = Runtime.getNetwork();\n\n Network.bind('online', () => {\n this.timeline.info({ netinfo: 'online' });\n if (this.state === 'connecting' || this.state === 'unavailable') {\n this.retryIn(0);\n }\n });\n Network.bind('offline', () => {\n this.timeline.info({ netinfo: 'offline' });\n if (this.connection) {\n this.sendActivityCheck();\n }\n });\n\n this.updateStrategy();\n }\n\n /** Establishes a connection to Pusher.\n *\n * Does nothing when connection is already established. See top-level doc\n * to find events emitted on connection attempts.\n */\n connect() {\n if (this.connection || this.runner) {\n return;\n }\n if (!this.strategy.isSupported()) {\n this.updateState('failed');\n return;\n }\n this.updateState('connecting');\n this.startConnecting();\n this.setUnavailableTimer();\n }\n\n /** Sends raw data.\n *\n * @param {String} data\n */\n send(data) {\n if (this.connection) {\n return this.connection.send(data);\n } else {\n return false;\n }\n }\n\n /** Sends an event.\n *\n * @param {String} name\n * @param {String} data\n * @param {String} [channel]\n * @returns {Boolean} whether message was sent or not\n */\n send_event(name: string, data: any, channel?: string) {\n if (this.connection) {\n return this.connection.send_event(name, data, channel);\n } else {\n return false;\n }\n }\n\n /** Closes the connection. */\n disconnect() {\n this.disconnectInternally();\n this.updateState('disconnected');\n }\n\n isUsingTLS() {\n return this.usingTLS;\n }\n\n private startConnecting() {\n var callback = (error, handshake) => {\n if (error) {\n this.runner = this.strategy.connect(0, callback);\n } else {\n if (handshake.action === 'error') {\n this.emit('error', {\n type: 'HandshakeError',\n error: handshake.error\n });\n this.timeline.error({ handshakeError: handshake.error });\n } else {\n this.abortConnecting(); // we don't support switching connections yet\n this.handshakeCallbacks[handshake.action](handshake);\n }\n }\n };\n this.runner = this.strategy.connect(0, callback);\n }\n\n private abortConnecting() {\n if (this.runner) {\n this.runner.abort();\n this.runner = null;\n }\n }\n\n private disconnectInternally() {\n this.abortConnecting();\n this.clearRetryTimer();\n this.clearUnavailableTimer();\n if (this.connection) {\n var connection = this.abandonConnection();\n connection.close();\n }\n }\n\n private updateStrategy() {\n this.strategy = this.options.getStrategy({\n key: this.key,\n timeline: this.timeline,\n useTLS: this.usingTLS\n });\n }\n\n private retryIn(delay) {\n this.timeline.info({ action: 'retry', delay: delay });\n if (delay > 0) {\n this.emit('connecting_in', Math.round(delay / 1000));\n }\n this.retryTimer = new Timer(delay || 0, () => {\n this.disconnectInternally();\n this.connect();\n });\n }\n\n private clearRetryTimer() {\n if (this.retryTimer) {\n this.retryTimer.ensureAborted();\n this.retryTimer = null;\n }\n }\n\n private setUnavailableTimer() {\n this.unavailableTimer = new Timer(this.options.unavailableTimeout, () => {\n this.updateState('unavailable');\n });\n }\n\n private clearUnavailableTimer() {\n if (this.unavailableTimer) {\n this.unavailableTimer.ensureAborted();\n }\n }\n\n private sendActivityCheck() {\n this.stopActivityCheck();\n this.connection.ping();\n // wait for pong response\n this.activityTimer = new Timer(this.options.pongTimeout, () => {\n this.timeline.error({ pong_timed_out: this.options.pongTimeout });\n this.retryIn(0);\n });\n }\n\n private resetActivityCheck() {\n this.stopActivityCheck();\n // send ping after inactivity\n if (this.connection && !this.connection.handlesActivityChecks()) {\n this.activityTimer = new Timer(this.activityTimeout, () => {\n this.sendActivityCheck();\n });\n }\n }\n\n private stopActivityCheck() {\n if (this.activityTimer) {\n this.activityTimer.ensureAborted();\n }\n }\n\n private buildConnectionCallbacks(\n errorCallbacks: ErrorCallbacks\n ): ConnectionCallbacks {\n return Collections.extend({}, errorCallbacks, {\n message: message => {\n // includes pong messages from server\n this.resetActivityCheck();\n this.emit('message', message);\n },\n ping: () => {\n this.send_event('pusher:pong', {});\n },\n activity: () => {\n this.resetActivityCheck();\n },\n error: error => {\n // just emit error to user - socket will already be closed by browser\n this.emit('error', error);\n },\n closed: () => {\n this.abandonConnection();\n if (this.shouldRetry()) {\n this.retryIn(1000);\n }\n }\n });\n }\n\n private buildHandshakeCallbacks(\n errorCallbacks: ErrorCallbacks\n ): HandshakeCallbacks {\n return Collections.extend({}, errorCallbacks, {\n connected: (handshake: HandshakePayload) => {\n this.activityTimeout = Math.min(\n this.options.activityTimeout,\n handshake.activityTimeout,\n handshake.connection.activityTimeout || Infinity\n );\n this.clearUnavailableTimer();\n this.setConnection(handshake.connection);\n this.socket_id = this.connection.id;\n this.updateState('connected', { socket_id: this.socket_id });\n }\n });\n }\n\n private buildErrorCallbacks(): ErrorCallbacks {\n let withErrorEmitted = callback => {\n return (result: Action | HandshakePayload) => {\n if (result.error) {\n this.emit('error', { type: 'WebSocketError', error: result.error });\n }\n callback(result);\n };\n };\n\n return {\n tls_only: withErrorEmitted(() => {\n this.usingTLS = true;\n this.updateStrategy();\n this.retryIn(0);\n }),\n refused: withErrorEmitted(() => {\n this.disconnect();\n }),\n backoff: withErrorEmitted(() => {\n this.retryIn(1000);\n }),\n retry: withErrorEmitted(() => {\n this.retryIn(0);\n })\n };\n }\n\n private setConnection(connection) {\n this.connection = connection;\n for (var event in this.connectionCallbacks) {\n this.connection.bind(event, this.connectionCallbacks[event]);\n }\n this.resetActivityCheck();\n }\n\n private abandonConnection() {\n if (!this.connection) {\n return;\n }\n this.stopActivityCheck();\n for (var event in this.connectionCallbacks) {\n this.connection.unbind(event, this.connectionCallbacks[event]);\n }\n var connection = this.connection;\n this.connection = null;\n return connection;\n }\n\n private updateState(newState: string, data?: any) {\n var previousState = this.state;\n this.state = newState;\n if (previousState !== newState) {\n var newStateDescription = newState;\n if (newStateDescription === 'connected') {\n newStateDescription += ' with new socket ID ' + data.socket_id;\n }\n Logger.debug(\n 'State changed',\n previousState + ' -> ' + newStateDescription\n );\n this.timeline.info({ state: newState, params: data });\n this.emit('state_change', { previous: previousState, current: newState });\n this.emit(newState, data);\n }\n }\n\n private shouldRetry(): boolean {\n return this.state === 'connecting' || this.state === 'connected';\n }\n}\n","import Channel from './channel';\nimport * as Collections from '../utils/collections';\nimport ChannelTable from './channel_table';\nimport Factory from '../utils/factory';\nimport Pusher from '../pusher';\nimport Logger from '../logger';\nimport * as Errors from '../errors';\nimport urlStore from '../utils/url_store';\n\n/** Handles a channel map. */\nexport default class Channels {\n channels: ChannelTable;\n\n constructor() {\n this.channels = {};\n }\n\n /** Creates or retrieves an existing channel by its name.\n *\n * @param {String} name\n * @param {Pusher} pusher\n * @return {Channel}\n */\n add(name: string, pusher: Pusher) {\n if (!this.channels[name]) {\n this.channels[name] = createChannel(name, pusher);\n }\n return this.channels[name];\n }\n\n /** Returns a list of all channels\n *\n * @return {Array}\n */\n all(): Channel[] {\n return Collections.values(this.channels);\n }\n\n /** Finds a channel by its name.\n *\n * @param {String} name\n * @return {Channel} channel or null if it doesn't exist\n */\n find(name: string) {\n return this.channels[name];\n }\n\n /** Removes a channel from the map.\n *\n * @param {String} name\n */\n remove(name: string) {\n var channel = this.channels[name];\n delete this.channels[name];\n return channel;\n }\n\n /** Proxies disconnection signal to all channels. */\n disconnect() {\n Collections.objectApply(this.channels, function(channel) {\n channel.disconnect();\n });\n }\n}\n\nfunction createChannel(name: string, pusher: Pusher): Channel {\n if (name.indexOf('private-encrypted-') === 0) {\n if (pusher.config.nacl) {\n return Factory.createEncryptedChannel(name, pusher, pusher.config.nacl);\n }\n let errMsg =\n 'Tried to subscribe to a private-encrypted- channel but no nacl implementation available';\n let suffix = urlStore.buildLogSuffix('encryptedChannelSupport');\n throw new Errors.UnsupportedFeature(`${errMsg}. ${suffix}`);\n } else if (name.indexOf('private-') === 0) {\n return Factory.createPrivateChannel(name, pusher);\n } else if (name.indexOf('presence-') === 0) {\n return Factory.createPresenceChannel(name, pusher);\n } else if (name.indexOf('#') === 0) {\n throw new Errors.BadChannelName(\n 'Cannot create a channel with name \"' + name + '\".'\n );\n } else {\n return Factory.createChannel(name, pusher);\n }\n}\n","import AssistantToTheTransportManager from '../transports/assistant_to_the_transport_manager';\nimport PingDelayOptions from '../transports/ping_delay_options';\nimport Transport from '../transports/transport';\nimport TransportManager from '../transports/transport_manager';\nimport Handshake from '../connection/handshake';\nimport TransportConnection from '../transports/transport_connection';\nimport SocketHooks from '../http/socket_hooks';\nimport HTTPSocket from '../http/http_socket';\n\nimport Timeline from '../timeline/timeline';\nimport {\n default as TimelineSender,\n TimelineSenderOptions\n} from '../timeline/timeline_sender';\nimport PresenceChannel from '../channels/presence_channel';\nimport PrivateChannel from '../channels/private_channel';\nimport EncryptedChannel from '../channels/encrypted_channel';\nimport Channel from '../channels/channel';\nimport ConnectionManager from '../connection/connection_manager';\nimport ConnectionManagerOptions from '../connection/connection_manager_options';\nimport Ajax from '../http/ajax';\nimport Channels from '../channels/channels';\nimport Pusher from '../pusher';\nimport { Config } from '../config';\nimport * as nacl from 'tweetnacl';\n\nvar Factory = {\n createChannels(): Channels {\n return new Channels();\n },\n\n createConnectionManager(\n key: string,\n options: ConnectionManagerOptions\n ): ConnectionManager {\n return new ConnectionManager(key, options);\n },\n\n createChannel(name: string, pusher: Pusher): Channel {\n return new Channel(name, pusher);\n },\n\n createPrivateChannel(name: string, pusher: Pusher): PrivateChannel {\n return new PrivateChannel(name, pusher);\n },\n\n createPresenceChannel(name: string, pusher: Pusher): PresenceChannel {\n return new PresenceChannel(name, pusher);\n },\n\n createEncryptedChannel(\n name: string,\n pusher: Pusher,\n nacl: nacl\n ): EncryptedChannel {\n return new EncryptedChannel(name, pusher, nacl);\n },\n\n createTimelineSender(timeline: Timeline, options: TimelineSenderOptions) {\n return new TimelineSender(timeline, options);\n },\n\n createHandshake(\n transport: TransportConnection,\n callback: (HandshakePayload) => void\n ): Handshake {\n return new Handshake(transport, callback);\n },\n\n createAssistantToTheTransportManager(\n manager: TransportManager,\n transport: Transport,\n options: PingDelayOptions\n ): AssistantToTheTransportManager {\n return new AssistantToTheTransportManager(manager, transport, options);\n }\n};\n\nexport default Factory;\n","import AssistantToTheTransportManager from './assistant_to_the_transport_manager';\nimport Transport from './transport';\nimport PingDelayOptions from './ping_delay_options';\nimport Factory from '../utils/factory';\n\nexport interface TransportManagerOptions extends PingDelayOptions {\n lives?: number;\n}\n\n/** Keeps track of the number of lives left for a transport.\n *\n * In the beginning of a session, transports may be assigned a number of\n * lives. When an AssistantToTheTransportManager instance reports a transport\n * connection closed uncleanly, the transport loses a life. When the number\n * of lives drops to zero, the transport gets disabled by its manager.\n *\n * @param {Object} options\n */\nexport default class TransportManager {\n options: TransportManagerOptions;\n livesLeft: number;\n\n constructor(options: TransportManagerOptions) {\n this.options = options || {};\n this.livesLeft = this.options.lives || Infinity;\n }\n\n /** Creates a assistant for the transport.\n *\n * @param {Transport} transport\n * @returns {AssistantToTheTransportManager}\n */\n getAssistant(transport: Transport): AssistantToTheTransportManager {\n return Factory.createAssistantToTheTransportManager(this, transport, {\n minPingDelay: this.options.minPingDelay,\n maxPingDelay: this.options.maxPingDelay\n });\n }\n\n /** Returns whether the transport has any lives left.\n *\n * @returns {Boolean}\n */\n isAlive(): boolean {\n return this.livesLeft > 0;\n }\n\n /** Takes one life from the transport. */\n reportDeath() {\n this.livesLeft -= 1;\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport { OneOffTimer as Timer } from '../utils/timers';\nimport Strategy from './strategy';\nimport StrategyOptions from './strategy_options';\n\n/** Loops through strategies with optional timeouts.\n *\n * Options:\n * - loop - whether it should loop through the substrategy list\n * - timeout - initial timeout for a single substrategy\n * - timeoutLimit - maximum timeout\n *\n * @param {Strategy[]} strategies\n * @param {Object} options\n */\nexport default class SequentialStrategy implements Strategy {\n strategies: Strategy[];\n loop: boolean;\n failFast: boolean;\n timeout: number;\n timeoutLimit: number;\n\n constructor(strategies: Strategy[], options: StrategyOptions) {\n this.strategies = strategies;\n this.loop = Boolean(options.loop);\n this.failFast = Boolean(options.failFast);\n this.timeout = options.timeout;\n this.timeoutLimit = options.timeoutLimit;\n }\n\n isSupported(): boolean {\n return Collections.any(this.strategies, Util.method('isSupported'));\n }\n\n connect(minPriority: number, callback: Function) {\n var strategies = this.strategies;\n var current = 0;\n var timeout = this.timeout;\n var runner = null;\n\n var tryNextStrategy = (error, handshake) => {\n if (handshake) {\n callback(null, handshake);\n } else {\n current = current + 1;\n if (this.loop) {\n current = current % strategies.length;\n }\n\n if (current < strategies.length) {\n if (timeout) {\n timeout = timeout * 2;\n if (this.timeoutLimit) {\n timeout = Math.min(timeout, this.timeoutLimit);\n }\n }\n runner = this.tryStrategy(\n strategies[current],\n minPriority,\n { timeout, failFast: this.failFast },\n tryNextStrategy\n );\n } else {\n callback(true);\n }\n }\n };\n\n runner = this.tryStrategy(\n strategies[current],\n minPriority,\n { timeout: timeout, failFast: this.failFast },\n tryNextStrategy\n );\n\n return {\n abort: function() {\n runner.abort();\n },\n forceMinPriority: function(p) {\n minPriority = p;\n if (runner) {\n runner.forceMinPriority(p);\n }\n }\n };\n }\n\n private tryStrategy(\n strategy: Strategy,\n minPriority: number,\n options: StrategyOptions,\n callback: Function\n ) {\n var timer = null;\n var runner = null;\n\n if (options.timeout > 0) {\n timer = new Timer(options.timeout, function() {\n runner.abort();\n callback(true);\n });\n }\n\n runner = strategy.connect(minPriority, function(error, handshake) {\n if (error && timer && timer.isRunning() && !options.failFast) {\n // advance to the next strategy after the timeout\n return;\n }\n if (timer) {\n timer.ensureAborted();\n }\n callback(error, handshake);\n });\n\n return {\n abort: function() {\n if (timer) {\n timer.ensureAborted();\n }\n runner.abort();\n },\n forceMinPriority: function(p) {\n runner.forceMinPriority(p);\n }\n };\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport Strategy from './strategy';\n\n/** Launches all substrategies and emits prioritized connected transports.\n *\n * @param {Array} strategies\n */\nexport default class BestConnectedEverStrategy implements Strategy {\n strategies: Strategy[];\n\n constructor(strategies: Strategy[]) {\n this.strategies = strategies;\n }\n\n isSupported(): boolean {\n return Collections.any(this.strategies, Util.method('isSupported'));\n }\n\n connect(minPriority: number, callback: Function) {\n return connect(this.strategies, minPriority, function(i, runners) {\n return function(error, handshake) {\n runners[i].error = error;\n if (error) {\n if (allRunnersFailed(runners)) {\n callback(true);\n }\n return;\n }\n Collections.apply(runners, function(runner) {\n runner.forceMinPriority(handshake.transport.priority);\n });\n callback(null, handshake);\n };\n });\n }\n}\n\n/** Connects to all strategies in parallel.\n *\n * Callback builder should be a function that takes two arguments: index\n * and a list of runners. It should return another function that will be\n * passed to the substrategy with given index. Runners can be aborted using\n * abortRunner(s) functions from this class.\n *\n * @param {Array} strategies\n * @param {Function} callbackBuilder\n * @return {Object} strategy runner\n */\nfunction connect(\n strategies: Strategy[],\n minPriority: number,\n callbackBuilder: Function\n) {\n var runners = Collections.map(strategies, function(strategy, i, _, rs) {\n return strategy.connect(minPriority, callbackBuilder(i, rs));\n });\n return {\n abort: function() {\n Collections.apply(runners, abortRunner);\n },\n forceMinPriority: function(p) {\n Collections.apply(runners, function(runner) {\n runner.forceMinPriority(p);\n });\n }\n };\n}\n\nfunction allRunnersFailed(runners): boolean {\n return Collections.all(runners, function(runner) {\n return Boolean(runner.error);\n });\n}\n\nfunction abortRunner(runner) {\n if (!runner.error && !runner.aborted) {\n runner.abort();\n runner.aborted = true;\n }\n}\n","import Util from '../util';\nimport Runtime from 'runtime';\nimport Strategy from './strategy';\nimport SequentialStrategy from './sequential_strategy';\nimport StrategyOptions from './strategy_options';\nimport TransportStrategy from './transport_strategy';\nimport Timeline from '../timeline/timeline';\nimport * as Collections from '../utils/collections';\n\nexport interface TransportStrategyDictionary {\n [key: string]: TransportStrategy;\n}\n\n/** Caches the last successful transport and, after the first few attempts,\n * uses the cached transport for subsequent attempts.\n *\n * @param {Strategy} strategy\n * @param {Object} transports\n * @param {Object} options\n */\nexport default class WebSocketPrioritizedCachedStrategy implements Strategy {\n strategy: Strategy;\n transports: TransportStrategyDictionary;\n ttl: number;\n usingTLS: boolean;\n timeline: Timeline;\n\n constructor(\n strategy: Strategy,\n transports: TransportStrategyDictionary,\n options: StrategyOptions\n ) {\n this.strategy = strategy;\n this.transports = transports;\n this.ttl = options.ttl || 1800 * 1000;\n this.usingTLS = options.useTLS;\n this.timeline = options.timeline;\n }\n\n isSupported(): boolean {\n return this.strategy.isSupported();\n }\n\n connect(minPriority: number, callback: Function) {\n var usingTLS = this.usingTLS;\n var info = fetchTransportCache(usingTLS);\n var cacheSkipCount = info && info.cacheSkipCount ? info.cacheSkipCount : 0;\n\n var strategies = [this.strategy];\n if (info && info.timestamp + this.ttl >= Util.now()) {\n var transport = this.transports[info.transport];\n if (transport) {\n if (['ws', 'wss'].includes(info.transport) || cacheSkipCount > 3) {\n this.timeline.info({\n cached: true,\n transport: info.transport,\n latency: info.latency\n });\n strategies.push(\n new SequentialStrategy([transport], {\n timeout: info.latency * 2 + 1000,\n failFast: true\n })\n );\n } else {\n cacheSkipCount++;\n }\n }\n }\n\n var startTimestamp = Util.now();\n var runner = strategies\n .pop()\n .connect(minPriority, function cb(error, handshake) {\n if (error) {\n flushTransportCache(usingTLS);\n if (strategies.length > 0) {\n startTimestamp = Util.now();\n runner = strategies.pop().connect(minPriority, cb);\n } else {\n callback(error);\n }\n } else {\n storeTransportCache(\n usingTLS,\n handshake.transport.name,\n Util.now() - startTimestamp,\n cacheSkipCount\n );\n callback(null, handshake);\n }\n });\n\n return {\n abort: function() {\n runner.abort();\n },\n forceMinPriority: function(p) {\n minPriority = p;\n if (runner) {\n runner.forceMinPriority(p);\n }\n }\n };\n }\n}\n\nfunction getTransportCacheKey(usingTLS: boolean): string {\n return 'pusherTransport' + (usingTLS ? 'TLS' : 'NonTLS');\n}\n\nfunction fetchTransportCache(usingTLS: boolean): any {\n var storage = Runtime.getLocalStorage();\n if (storage) {\n try {\n var serializedCache = storage[getTransportCacheKey(usingTLS)];\n if (serializedCache) {\n return JSON.parse(serializedCache);\n }\n } catch (e) {\n flushTransportCache(usingTLS);\n }\n }\n return null;\n}\n\nfunction storeTransportCache(\n usingTLS: boolean,\n transport: TransportStrategy,\n latency: number,\n cacheSkipCount: number\n) {\n var storage = Runtime.getLocalStorage();\n if (storage) {\n try {\n storage[getTransportCacheKey(usingTLS)] = Collections.safeJSONStringify({\n timestamp: Util.now(),\n transport: transport,\n latency: latency,\n cacheSkipCount: cacheSkipCount\n });\n } catch (e) {\n // catch over quota exceptions raised by localStorage\n }\n }\n}\n\nfunction flushTransportCache(usingTLS: boolean) {\n var storage = Runtime.getLocalStorage();\n if (storage) {\n try {\n delete storage[getTransportCacheKey(usingTLS)];\n } catch (e) {\n // catch exceptions raised by localStorage\n }\n }\n}\n","import { OneOffTimer as Timer } from '../utils/timers';\nimport Strategy from './strategy';\nimport StrategyOptions from './strategy_options';\n\n/** Runs substrategy after specified delay.\n *\n * Options:\n * - delay - time in miliseconds to delay the substrategy attempt\n *\n * @param {Strategy} strategy\n * @param {Object} options\n */\nexport default class DelayedStrategy implements Strategy {\n strategy: Strategy;\n options: { delay: number };\n\n constructor(strategy: Strategy, { delay: number }) {\n this.strategy = strategy;\n this.options = { delay: number };\n }\n\n isSupported(): boolean {\n return this.strategy.isSupported();\n }\n\n connect(minPriority: number, callback: Function) {\n var strategy = this.strategy;\n var runner;\n var timer = new Timer(this.options.delay, function() {\n runner = strategy.connect(minPriority, callback);\n });\n\n return {\n abort: function() {\n timer.ensureAborted();\n if (runner) {\n runner.abort();\n }\n },\n forceMinPriority: function(p) {\n minPriority = p;\n if (runner) {\n runner.forceMinPriority(p);\n }\n }\n };\n }\n}\n","import Strategy from './strategy';\nimport StrategyRunner from './strategy_runner';\n\n/** Proxies method calls to one of substrategies basing on the test function.\n *\n * @param {Function} test\n * @param {Strategy} trueBranch strategy used when test returns true\n * @param {Strategy} falseBranch strategy used when test returns false\n */\nexport default class IfStrategy implements Strategy {\n test: () => boolean;\n trueBranch: Strategy;\n falseBranch: Strategy;\n\n constructor(\n test: () => boolean,\n trueBranch: Strategy,\n falseBranch: Strategy\n ) {\n this.test = test;\n this.trueBranch = trueBranch;\n this.falseBranch = falseBranch;\n }\n\n isSupported(): boolean {\n var branch = this.test() ? this.trueBranch : this.falseBranch;\n return branch.isSupported();\n }\n\n connect(minPriority: number, callback: Function): StrategyRunner {\n var branch = this.test() ? this.trueBranch : this.falseBranch;\n return branch.connect(minPriority, callback);\n }\n}\n","import Strategy from './strategy';\nimport StrategyRunner from './strategy_runner';\n\n/** Launches the substrategy and terminates on the first open connection.\n *\n * @param {Strategy} strategy\n */\nexport default class FirstConnectedStrategy implements Strategy {\n strategy: Strategy;\n\n constructor(strategy: Strategy) {\n this.strategy = strategy;\n }\n\n isSupported(): boolean {\n return this.strategy.isSupported();\n }\n\n connect(minPriority: number, callback: Function): StrategyRunner {\n var runner = this.strategy.connect(minPriority, function(error, handshake) {\n if (handshake) {\n runner.abort();\n }\n callback(error, handshake);\n });\n return runner;\n }\n}\n","import * as Collections from 'core/utils/collections';\nimport TransportManager from 'core/transports/transport_manager';\nimport Strategy from 'core/strategies/strategy';\nimport SequentialStrategy from 'core/strategies/sequential_strategy';\nimport BestConnectedEverStrategy from 'core/strategies/best_connected_ever_strategy';\nimport WebSocketPrioritizedCachedStrategy, {\n TransportStrategyDictionary\n} from 'core/strategies/websocket_prioritized_cached_strategy';\nimport DelayedStrategy from 'core/strategies/delayed_strategy';\nimport IfStrategy from 'core/strategies/if_strategy';\nimport FirstConnectedStrategy from 'core/strategies/first_connected_strategy';\nimport { Config } from 'core/config';\nimport StrategyOptions from 'core/strategies/strategy_options';\n\nfunction testSupportsStrategy(strategy: Strategy) {\n return function() {\n return strategy.isSupported();\n };\n}\n\nvar getDefaultStrategy = function(\n config: Config,\n baseOptions: StrategyOptions,\n defineTransport: Function\n): Strategy {\n var definedTransports = {};\n\n function defineTransportStrategy(\n name: string,\n type: string,\n priority: number,\n options: StrategyOptions,\n manager?: TransportManager\n ) {\n var transport = defineTransport(\n config,\n name,\n type,\n priority,\n options,\n manager\n );\n\n definedTransports[name] = transport;\n\n return transport;\n }\n\n var ws_options: StrategyOptions = Object.assign({}, baseOptions, {\n hostNonTLS: config.wsHost + ':' + config.wsPort,\n hostTLS: config.wsHost + ':' + config.wssPort,\n httpPath: config.wsPath\n });\n var wss_options: StrategyOptions = Collections.extend({}, ws_options, {\n useTLS: true\n });\n var http_options: StrategyOptions = Object.assign({}, baseOptions, {\n hostNonTLS: config.httpHost + ':' + config.httpPort,\n hostTLS: config.httpHost + ':' + config.httpsPort,\n httpPath: config.httpPath\n });\n var timeouts = {\n loop: true,\n timeout: 15000,\n timeoutLimit: 60000\n };\n\n var ws_manager = new TransportManager({\n minPingDelay: 10000,\n maxPingDelay: config.activityTimeout\n });\n var streaming_manager = new TransportManager({\n lives: 2,\n minPingDelay: 10000,\n maxPingDelay: config.activityTimeout\n });\n\n var ws_transport = defineTransportStrategy(\n 'ws',\n 'ws',\n 3,\n ws_options,\n ws_manager\n );\n var wss_transport = defineTransportStrategy(\n 'wss',\n 'ws',\n 3,\n wss_options,\n ws_manager\n );\n var xhr_streaming_transport = defineTransportStrategy(\n 'xhr_streaming',\n 'xhr_streaming',\n 1,\n http_options,\n streaming_manager\n );\n var xhr_polling_transport = defineTransportStrategy(\n 'xhr_polling',\n 'xhr_polling',\n 1,\n http_options\n );\n\n var ws_loop = new SequentialStrategy([ws_transport], timeouts);\n var wss_loop = new SequentialStrategy([wss_transport], timeouts);\n var streaming_loop = new SequentialStrategy(\n [xhr_streaming_transport],\n timeouts\n );\n var polling_loop = new SequentialStrategy([xhr_polling_transport], timeouts);\n\n var http_loop = new SequentialStrategy(\n [\n new IfStrategy(\n testSupportsStrategy(streaming_loop),\n new BestConnectedEverStrategy([\n streaming_loop,\n new DelayedStrategy(polling_loop, { delay: 4000 })\n ]),\n polling_loop\n )\n ],\n timeouts\n );\n\n var wsStrategy;\n if (baseOptions.useTLS) {\n wsStrategy = new BestConnectedEverStrategy([\n ws_loop,\n new DelayedStrategy(http_loop, { delay: 2000 })\n ]);\n } else {\n wsStrategy = new BestConnectedEverStrategy([\n ws_loop,\n new DelayedStrategy(wss_loop, { delay: 2000 }),\n new DelayedStrategy(http_loop, { delay: 5000 })\n ]);\n }\n\n return new WebSocketPrioritizedCachedStrategy(\n new FirstConnectedStrategy(\n new IfStrategy(testSupportsStrategy(ws_transport), wsStrategy, http_loop)\n ),\n definedTransports,\n {\n ttl: 1800000,\n timeline: baseOptions.timeline,\n useTLS: baseOptions.useTLS\n }\n );\n};\n\nexport default getDefaultStrategy;\n","/** Initializes the transport.\n *\n * Fetches resources if needed and then transitions to initialized.\n */\nexport default function() {\n var self = this;\n\n self.timeline.info(\n self.buildTimelineMessage({\n transport: self.name + (self.options.useTLS ? 's' : '')\n })\n );\n\n if (self.hooks.isInitialized()) {\n self.changeState('initialized');\n } else {\n self.onClose();\n }\n}\n","import Runtime from 'runtime';\nimport RequestHooks from './request_hooks';\nimport Ajax from './ajax';\nimport { default as EventsDispatcher } from '../events/dispatcher';\n\nconst MAX_BUFFER_LENGTH = 256 * 1024;\n\nexport default class HTTPRequest extends EventsDispatcher {\n hooks: RequestHooks;\n method: string;\n url: string;\n position: number;\n xhr: Ajax;\n unloader: Function;\n\n constructor(hooks: RequestHooks, method: string, url: string) {\n super();\n this.hooks = hooks;\n this.method = method;\n this.url = url;\n }\n\n start(payload?: any) {\n this.position = 0;\n this.xhr = this.hooks.getRequest(this);\n\n this.unloader = () => {\n this.close();\n };\n Runtime.addUnloadListener(this.unloader);\n\n this.xhr.open(this.method, this.url, true);\n\n if (this.xhr.setRequestHeader) {\n this.xhr.setRequestHeader('Content-Type', 'application/json'); // ReactNative doesn't set this header by default.\n }\n this.xhr.send(payload);\n }\n\n close() {\n if (this.unloader) {\n Runtime.removeUnloadListener(this.unloader);\n this.unloader = null;\n }\n if (this.xhr) {\n this.hooks.abortRequest(this.xhr);\n this.xhr = null;\n }\n }\n\n onChunk(status: number, data: any) {\n while (true) {\n var chunk = this.advanceBuffer(data);\n if (chunk) {\n this.emit('chunk', { status: status, data: chunk });\n } else {\n break;\n }\n }\n if (this.isBufferTooLong(data)) {\n this.emit('buffer_too_long');\n }\n }\n\n private advanceBuffer(buffer: any[]): any {\n var unreadData = buffer.slice(this.position);\n var endOfLinePosition = unreadData.indexOf('\\n');\n\n if (endOfLinePosition !== -1) {\n this.position += endOfLinePosition + 1;\n return unreadData.slice(0, endOfLinePosition);\n } else {\n // chunk is not finished yet, don't move the buffer pointer\n return null;\n }\n }\n\n private isBufferTooLong(buffer: any): boolean {\n return this.position === buffer.length && buffer.length > MAX_BUFFER_LENGTH;\n }\n}\n","enum State {\n CONNECTING = 0,\n OPEN = 1,\n CLOSED = 3\n}\n\nexport default State;\n","import URLLocation from './url_location';\nimport State from './state';\nimport Socket from '../socket';\nimport SocketHooks from './socket_hooks';\nimport Util from '../util';\nimport Ajax from './ajax';\nimport HTTPRequest from './http_request';\nimport Runtime from 'runtime';\n\nvar autoIncrement = 1;\n\nclass HTTPSocket implements Socket {\n hooks: SocketHooks;\n session: string;\n location: URLLocation;\n readyState: State;\n stream: HTTPRequest;\n\n onopen: () => void;\n onerror: (error: any) => void;\n onclose: (closeEvent: any) => void;\n onmessage: (message: any) => void;\n onactivity: () => void;\n\n constructor(hooks: SocketHooks, url: string) {\n this.hooks = hooks;\n this.session = randomNumber(1000) + '/' + randomString(8);\n this.location = getLocation(url);\n this.readyState = State.CONNECTING;\n this.openStream();\n }\n\n send(payload: any) {\n return this.sendRaw(JSON.stringify([payload]));\n }\n\n ping() {\n this.hooks.sendHeartbeat(this);\n }\n\n close(code: any, reason: any) {\n this.onClose(code, reason, true);\n }\n\n /** For internal use only */\n sendRaw(payload: any): boolean {\n if (this.readyState === State.OPEN) {\n try {\n Runtime.createSocketRequest(\n 'POST',\n getUniqueURL(getSendURL(this.location, this.session))\n ).start(payload);\n return true;\n } catch (e) {\n return false;\n }\n } else {\n return false;\n }\n }\n\n /** For internal use only */\n reconnect() {\n this.closeStream();\n this.openStream();\n }\n\n /** For internal use only */\n onClose(code, reason, wasClean) {\n this.closeStream();\n this.readyState = State.CLOSED;\n if (this.onclose) {\n this.onclose({\n code: code,\n reason: reason,\n wasClean: wasClean\n });\n }\n }\n\n private onChunk(chunk) {\n if (chunk.status !== 200) {\n return;\n }\n if (this.readyState === State.OPEN) {\n this.onActivity();\n }\n\n var payload;\n var type = chunk.data.slice(0, 1);\n switch (type) {\n case 'o':\n payload = JSON.parse(chunk.data.slice(1) || '{}');\n this.onOpen(payload);\n break;\n case 'a':\n payload = JSON.parse(chunk.data.slice(1) || '[]');\n for (var i = 0; i < payload.length; i++) {\n this.onEvent(payload[i]);\n }\n break;\n case 'm':\n payload = JSON.parse(chunk.data.slice(1) || 'null');\n this.onEvent(payload);\n break;\n case 'h':\n this.hooks.onHeartbeat(this);\n break;\n case 'c':\n payload = JSON.parse(chunk.data.slice(1) || '[]');\n this.onClose(payload[0], payload[1], true);\n break;\n }\n }\n\n private onOpen(options) {\n if (this.readyState === State.CONNECTING) {\n if (options && options.hostname) {\n this.location.base = replaceHost(this.location.base, options.hostname);\n }\n this.readyState = State.OPEN;\n\n if (this.onopen) {\n this.onopen();\n }\n } else {\n this.onClose(1006, 'Server lost session', true);\n }\n }\n\n private onEvent(event) {\n if (this.readyState === State.OPEN && this.onmessage) {\n this.onmessage({ data: event });\n }\n }\n\n private onActivity() {\n if (this.onactivity) {\n this.onactivity();\n }\n }\n\n private onError(error) {\n if (this.onerror) {\n this.onerror(error);\n }\n }\n\n private openStream() {\n this.stream = Runtime.createSocketRequest(\n 'POST',\n getUniqueURL(this.hooks.getReceiveURL(this.location, this.session))\n );\n\n this.stream.bind('chunk', chunk => {\n this.onChunk(chunk);\n });\n this.stream.bind('finished', status => {\n this.hooks.onFinished(this, status);\n });\n this.stream.bind('buffer_too_long', () => {\n this.reconnect();\n });\n\n try {\n this.stream.start();\n } catch (error) {\n Util.defer(() => {\n this.onError(error);\n this.onClose(1006, 'Could not start streaming', false);\n });\n }\n }\n\n private closeStream() {\n if (this.stream) {\n this.stream.unbind_all();\n this.stream.close();\n this.stream = null;\n }\n }\n}\n\nfunction getLocation(url): URLLocation {\n var parts = /([^\\?]*)\\/*(\\??.*)/.exec(url);\n return {\n base: parts[1],\n queryString: parts[2]\n };\n}\n\nfunction getSendURL(url: URLLocation, session: string): string {\n return url.base + '/' + session + '/xhr_send';\n}\n\nfunction getUniqueURL(url: string): string {\n var separator = url.indexOf('?') === -1 ? '?' : '&';\n return url + separator + 't=' + +new Date() + '&n=' + autoIncrement++;\n}\n\nfunction replaceHost(url: string, hostname: string): string {\n var urlParts = /(https?:\\/\\/)([^\\/:]+)((\\/|:)?.*)/.exec(url);\n return urlParts[1] + hostname + urlParts[3];\n}\n\nfunction randomNumber(max: number): number {\n return Runtime.randomInt(max);\n}\n\nfunction randomString(length: number): string {\n var result = [];\n\n for (var i = 0; i < length; i++) {\n result.push(randomNumber(32).toString(32));\n }\n\n return result.join('');\n}\n\nexport default HTTPSocket;\n","import SocketHooks from './socket_hooks';\nimport HTTPSocket from './http_socket';\n\nvar hooks: SocketHooks = {\n getReceiveURL: function(url, session) {\n return url.base + '/' + session + '/xhr_streaming' + url.queryString;\n },\n onHeartbeat: function(socket) {\n socket.sendRaw('[]');\n },\n sendHeartbeat: function(socket) {\n socket.sendRaw('[]');\n },\n onFinished: function(socket, status) {\n socket.onClose(1006, 'Connection interrupted (' + status + ')', false);\n }\n};\n\nexport default hooks;\n","import SocketHooks from './socket_hooks';\nimport URLLocation from './url_location';\nimport HTTPSocket from './http_socket';\n\nvar hooks: SocketHooks = {\n getReceiveURL: function(url: URLLocation, session: string): string {\n return url.base + '/' + session + '/xhr' + url.queryString;\n },\n onHeartbeat: function() {\n // next HTTP request will reset server's activity timer\n },\n sendHeartbeat: function(socket) {\n socket.sendRaw('[]');\n },\n onFinished: function(socket, status) {\n if (status === 200) {\n socket.reconnect();\n } else {\n socket.onClose(1006, 'Connection interrupted (' + status + ')', false);\n }\n }\n};\n\nexport default hooks;\n","import HTTPRequest from 'core/http/http_request';\nimport RequestHooks from 'core/http/request_hooks';\nimport Ajax from 'core/http/ajax';\nimport Runtime from 'runtime';\n\nvar hooks: RequestHooks = {\n getRequest: function(socket: HTTPRequest): Ajax {\n var Constructor = Runtime.getXHRAPI();\n var xhr = new Constructor();\n xhr.onreadystatechange = xhr.onprogress = function() {\n switch (xhr.readyState) {\n case 3:\n if (xhr.responseText && xhr.responseText.length > 0) {\n socket.onChunk(xhr.status, xhr.responseText);\n }\n break;\n case 4:\n // this happens only on errors, never after calling close\n if (xhr.responseText && xhr.responseText.length > 0) {\n socket.onChunk(xhr.status, xhr.responseText);\n }\n socket.emit('finished', xhr.status);\n socket.close();\n break;\n }\n };\n return xhr;\n },\n abortRequest: function(xhr: Ajax) {\n xhr.onreadystatechange = null;\n xhr.abort();\n }\n};\n\nexport default hooks;\n","import HTTPRequest from 'core/http/http_request';\nimport HTTPSocket from 'core/http/http_socket';\nimport SocketHooks from 'core/http/socket_hooks';\nimport RequestHooks from 'core/http/request_hooks';\nimport streamingHooks from 'core/http/http_streaming_socket';\nimport pollingHooks from 'core/http/http_polling_socket';\nimport xhrHooks from './http_xhr_request';\nimport HTTPFactory from 'core/http/http_factory';\n\nvar HTTP: HTTPFactory = {\n createStreamingSocket(url: string): HTTPSocket {\n return this.createSocket(streamingHooks, url);\n },\n\n createPollingSocket(url: string): HTTPSocket {\n return this.createSocket(pollingHooks, url);\n },\n\n createSocket(hooks: SocketHooks, url: string): HTTPSocket {\n return new HTTPSocket(hooks, url);\n },\n\n createXHR(method: string, url: string): HTTPRequest {\n return this.createRequest(xhrHooks, method, url);\n },\n\n createRequest(hooks: RequestHooks, method: string, url: string): HTTPRequest {\n return new HTTPRequest(hooks, method, url);\n }\n};\n\nexport default HTTP;\n","import * as Collections from 'core/utils/collections';\nimport Transports from 'isomorphic/transports/transports';\nimport TimelineSender from 'core/timeline/timeline_sender';\nimport Ajax from 'core/http/ajax';\nimport getDefaultStrategy from './default_strategy';\nimport TransportsTable from 'core/transports/transports_table';\nimport transportConnectionInitializer from './transports/transport_connection_initializer';\nimport HTTPFactory from './http/http';\n\nvar Isomorphic: any = {\n getDefaultStrategy,\n Transports: Transports,\n transportConnectionInitializer,\n HTTPFactory,\n\n setup(PusherClass): void {\n PusherClass.ready();\n },\n\n getLocalStorage(): any {\n return undefined;\n },\n\n getClientFeatures(): any[] {\n return Collections.keys(\n Collections.filterObject({ ws: Transports.ws }, function(t) {\n return t.isSupported({});\n })\n );\n },\n\n getProtocol(): string {\n return 'http:';\n },\n\n isXHRSupported(): boolean {\n return true;\n },\n\n createSocketRequest(method: string, url: string) {\n if (this.isXHRSupported()) {\n return this.HTTPFactory.createXHR(method, url);\n } else {\n throw 'Cross-origin HTTP requests are not supported';\n }\n },\n\n createXHR(): Ajax {\n var Constructor = this.getXHRAPI();\n return new Constructor();\n },\n\n createWebSocket(url: string): any {\n var Constructor = this.getWebSocketAPI();\n return new Constructor(url);\n },\n\n addUnloadListener(listener: any) {},\n removeUnloadListener(listener: any) {}\n};\n\nexport default Isomorphic;\n","import { default as EventsDispatcher } from 'core/events/dispatcher';\nimport Reachability from 'core/reachability';\n\nexport class NetInfo extends EventsDispatcher implements Reachability {\n isOnline(): boolean {\n return true;\n }\n}\n\nexport var Network = new NetInfo();\n","import AbstractRuntime from 'runtimes/interface';\nimport { AuthTransport } from 'core/auth/auth_transports';\nimport {\n AuthRequestType,\n AuthTransportCallback,\n InternalAuthOptions\n} from 'core/auth/options';\nimport { HTTPAuthError } from 'core/errors';\n\nvar fetchAuth: AuthTransport = function(\n context: AbstractRuntime,\n query: string,\n authOptions: InternalAuthOptions,\n authRequestType: AuthRequestType,\n callback: AuthTransportCallback\n) {\n var headers = new Headers();\n headers.set('Content-Type', 'application/x-www-form-urlencoded');\n\n for (var headerName in authOptions.headers) {\n headers.set(headerName, authOptions.headers[headerName]);\n }\n\n if (authOptions.headersProvider != null) {\n const dynamicHeaders = authOptions.headersProvider();\n for (var headerName in dynamicHeaders) {\n headers.set(headerName, dynamicHeaders[headerName]);\n }\n }\n\n var body = query;\n var request = new Request(authOptions.endpoint, {\n headers,\n body,\n credentials: 'same-origin',\n method: 'POST'\n });\n\n return fetch(request)\n .then(response => {\n let { status } = response;\n if (status === 200) {\n // manually parse the json so we can provide a more helpful error in\n // failure case\n return response.text();\n }\n throw new HTTPAuthError(\n status,\n `Could not get ${authRequestType.toString()} info from your auth endpoint, status: ${status}`\n );\n })\n .then(data => {\n let parsedData;\n try {\n parsedData = JSON.parse(data);\n } catch (e) {\n throw new HTTPAuthError(\n 200,\n `JSON returned from ${authRequestType.toString()} endpoint was invalid, yet status code was 200. Data was: ${data}`\n );\n }\n callback(null, parsedData);\n })\n .catch(err => {\n callback(err, null);\n });\n};\n\nexport default fetchAuth;\n","import Logger from 'core/logger';\nimport TimelineSender from 'core/timeline/timeline_sender';\nimport * as Collections from 'core/utils/collections';\nimport Util from 'core/util';\nimport Runtime from 'runtime';\nimport TimelineTransport from 'core/timeline/timeline_transport';\n\nvar getAgent = function(sender: TimelineSender, useTLS: boolean) {\n return function(data: any, callback: Function) {\n var scheme = 'http' + (useTLS ? 's' : '') + '://';\n var url =\n scheme + (sender.host || sender.options.host) + sender.options.path;\n var query = Collections.buildQueryString(data);\n url += '/' + 2 + '?' + query;\n\n fetch(url)\n .then(response => {\n if (response.status !== 200) {\n throw `received ${response.status} from stats.pusher.com`;\n }\n return response.json();\n })\n .then(({ host }) => {\n if (host) {\n sender.host = host;\n }\n })\n .catch(err => {\n Logger.debug('TimelineSender Error: ', err);\n });\n };\n};\n\nvar fetchTimeline = {\n name: 'xhr',\n getAgent\n};\n\nexport default fetchTimeline;\n","import Isomorphic from 'isomorphic/runtime';\nimport Runtime from '../interface';\nimport { Network } from './net_info';\nimport fetchAuth from './auth/fetch_auth';\nimport { AuthTransports } from 'core/auth/auth_transports';\nimport fetchTimeline from './timeline/fetch_timeline';\n\n// Very verbose but until unavoidable until\n// TypeScript 2.1, when spread attributes will be\n// supported\nconst {\n getDefaultStrategy,\n Transports,\n setup,\n getProtocol,\n isXHRSupported,\n getLocalStorage,\n createXHR,\n createWebSocket,\n addUnloadListener,\n removeUnloadListener,\n transportConnectionInitializer,\n createSocketRequest,\n HTTPFactory\n} = Isomorphic;\n\nconst Worker: Runtime = {\n getDefaultStrategy,\n Transports,\n setup,\n getProtocol,\n isXHRSupported,\n getLocalStorage,\n createXHR,\n createWebSocket,\n addUnloadListener,\n removeUnloadListener,\n transportConnectionInitializer,\n createSocketRequest,\n HTTPFactory,\n\n TimelineTransport: fetchTimeline,\n\n getAuthorizers(): AuthTransports {\n return { ajax: fetchAuth };\n },\n\n getWebSocketAPI() {\n return WebSocket;\n },\n\n getXHRAPI() {\n return XMLHttpRequest;\n },\n\n getNetwork() {\n return Network;\n },\n\n randomInt(max: number): number {\n /**\n * Return values in the range of [0, 1[\n */\n const random = function() {\n const crypto = globalThis.crypto || globalThis['msCrypto'];\n const random = crypto.getRandomValues(new Uint32Array(1))[0];\n\n return random / 2 ** 32;\n };\n\n return Math.floor(random() * max);\n }\n};\n\nexport default Worker;\n","enum TimelineLevel {\n ERROR = 3,\n INFO = 6,\n DEBUG = 7\n}\n\nexport default TimelineLevel;\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport { default as Level } from './level';\n\nexport interface TimelineOptions {\n level?: Level;\n limit?: number;\n version?: string;\n cluster?: string;\n features?: string[];\n params?: any;\n}\n\nexport default class Timeline {\n key: string;\n session: number;\n events: any[];\n options: TimelineOptions;\n sent: number;\n uniqueID: number;\n\n constructor(key: string, session: number, options: TimelineOptions) {\n this.key = key;\n this.session = session;\n this.events = [];\n this.options = options || {};\n this.sent = 0;\n this.uniqueID = 0;\n }\n\n log(level, event) {\n if (level <= this.options.level) {\n this.events.push(\n Collections.extend({}, event, { timestamp: Util.now() })\n );\n if (this.options.limit && this.events.length > this.options.limit) {\n this.events.shift();\n }\n }\n }\n\n error(event) {\n this.log(Level.ERROR, event);\n }\n\n info(event) {\n this.log(Level.INFO, event);\n }\n\n debug(event) {\n this.log(Level.DEBUG, event);\n }\n\n isEmpty() {\n return this.events.length === 0;\n }\n\n send(sendfn, callback) {\n var data = Collections.extend(\n {\n session: this.session,\n bundle: this.sent + 1,\n key: this.key,\n lib: 'js',\n version: this.options.version,\n cluster: this.options.cluster,\n features: this.options.features,\n timeline: this.events\n },\n this.options.params\n );\n\n this.events = [];\n sendfn(data, (error, result) => {\n if (!error) {\n this.sent++;\n }\n if (callback) {\n callback(error, result);\n }\n });\n\n return true;\n }\n\n generateUniqueID(): number {\n this.uniqueID++;\n return this.uniqueID;\n }\n}\n","import Factory from '../utils/factory';\nimport Util from '../util';\nimport * as Errors from '../errors';\nimport * as Collections from '../utils/collections';\nimport Strategy from './strategy';\nimport Transport from '../transports/transport';\nimport StrategyOptions from './strategy_options';\nimport Handshake from '../connection/handshake';\n\n/** Provides a strategy interface for transports.\n *\n * @param {String} name\n * @param {Number} priority\n * @param {Class} transport\n * @param {Object} options\n */\nexport default class TransportStrategy implements Strategy {\n name: string;\n priority: number;\n transport: Transport;\n options: StrategyOptions;\n\n constructor(\n name: string,\n priority: number,\n transport: Transport,\n options: StrategyOptions\n ) {\n this.name = name;\n this.priority = priority;\n this.transport = transport;\n this.options = options || {};\n }\n\n /** Returns whether the transport is supported in the browser.\n *\n * @returns {Boolean}\n */\n isSupported(): boolean {\n return this.transport.isSupported({\n useTLS: this.options.useTLS\n });\n }\n\n /** Launches a connection attempt and returns a strategy runner.\n *\n * @param {Function} callback\n * @return {Object} strategy runner\n */\n connect(minPriority: number, callback: Function) {\n if (!this.isSupported()) {\n return failAttempt(new Errors.UnsupportedStrategy(), callback);\n } else if (this.priority < minPriority) {\n return failAttempt(new Errors.TransportPriorityTooLow(), callback);\n }\n\n var connected = false;\n var transport = this.transport.createConnection(\n this.name,\n this.priority,\n this.options.key,\n this.options\n );\n var handshake = null;\n\n var onInitialized = function() {\n transport.unbind('initialized', onInitialized);\n transport.connect();\n };\n var onOpen = function() {\n handshake = Factory.createHandshake(transport, function(result) {\n connected = true;\n unbindListeners();\n callback(null, result);\n });\n };\n var onError = function(error) {\n unbindListeners();\n callback(error);\n };\n var onClosed = function() {\n unbindListeners();\n var serializedTransport;\n\n // The reason for this try/catch block is that on React Native\n // the WebSocket object is circular. Therefore transport.socket will\n // throw errors upon stringification. Collections.safeJSONStringify\n // discards circular references when serializing.\n serializedTransport = Collections.safeJSONStringify(transport);\n callback(new Errors.TransportClosed(serializedTransport));\n };\n\n var unbindListeners = function() {\n transport.unbind('initialized', onInitialized);\n transport.unbind('open', onOpen);\n transport.unbind('error', onError);\n transport.unbind('closed', onClosed);\n };\n\n transport.bind('initialized', onInitialized);\n transport.bind('open', onOpen);\n transport.bind('error', onError);\n transport.bind('closed', onClosed);\n\n // connect will be called automatically after initialization\n transport.initialize();\n\n return {\n abort: () => {\n if (connected) {\n return;\n }\n unbindListeners();\n if (handshake) {\n handshake.close();\n } else {\n transport.close();\n }\n },\n forceMinPriority: p => {\n if (connected) {\n return;\n }\n if (this.priority < p) {\n if (handshake) {\n handshake.close();\n } else {\n transport.close();\n }\n }\n }\n };\n }\n}\n\nfunction failAttempt(error: Error, callback: Function) {\n Util.defer(function() {\n callback(error);\n });\n return {\n abort: function() {},\n forceMinPriority: function() {}\n };\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport TransportManager from '../transports/transport_manager';\nimport * as Errors from '../errors';\nimport Strategy from './strategy';\nimport TransportStrategy from './transport_strategy';\nimport StrategyOptions from '../strategies/strategy_options';\nimport { Config } from '../config';\nimport Runtime from 'runtime';\n\nconst { Transports } = Runtime;\n\nexport var defineTransport = function(\n config: Config,\n name: string,\n type: string,\n priority: number,\n options: StrategyOptions,\n manager?: TransportManager\n): Strategy {\n var transportClass = Transports[type];\n if (!transportClass) {\n throw new Errors.UnsupportedTransport(type);\n }\n\n var enabled =\n (!config.enabledTransports ||\n Collections.arrayIndexOf(config.enabledTransports, name) !== -1) &&\n (!config.disabledTransports ||\n Collections.arrayIndexOf(config.disabledTransports, name) === -1);\n\n var transport;\n if (enabled) {\n options = Object.assign(\n { ignoreNullOrigin: config.ignoreNullOrigin },\n options\n );\n\n transport = new TransportStrategy(\n name,\n priority,\n manager ? manager.getAssistant(transportClass) : transportClass,\n options\n );\n } else {\n transport = UnsupportedStrategy;\n }\n\n return transport;\n};\n\nvar UnsupportedStrategy: Strategy = {\n isSupported: function() {\n return false;\n },\n connect: function(_, callback) {\n var deferred = Util.defer(function() {\n callback(new Errors.UnsupportedStrategy());\n });\n return {\n abort: function() {\n deferred.ensureAborted();\n },\n forceMinPriority: function() {}\n };\n }\n};\n","import ConnectionManager from './connection/connection_manager';\nimport {\n ChannelAuthorizationOptions,\n UserAuthenticationOptions\n} from './auth/options';\nimport {\n ChannelAuthorizerGenerator,\n DeprecatedAuthOptions\n} from './auth/deprecated_channel_authorizer';\nimport { AuthTransport, Transport } from './config';\nimport * as nacl from 'tweetnacl';\nimport Logger from './logger';\n\nexport interface Options {\n activityTimeout?: number;\n\n auth?: DeprecatedAuthOptions; // DEPRECATED use channelAuthorization instead\n authEndpoint?: string; // DEPRECATED use channelAuthorization instead\n authTransport?: AuthTransport; // DEPRECATED use channelAuthorization instead\n authorizer?: ChannelAuthorizerGenerator; // DEPRECATED use channelAuthorization instead\n\n channelAuthorization?: ChannelAuthorizationOptions;\n userAuthentication?: UserAuthenticationOptions;\n\n cluster: string;\n enableStats?: boolean;\n disableStats?: boolean;\n disabledTransports?: Transport[];\n enabledTransports?: Transport[];\n forceTLS?: boolean;\n httpHost?: string;\n httpPath?: string;\n httpPort?: number;\n httpsPort?: number;\n ignoreNullOrigin?: boolean;\n nacl?: nacl;\n pongTimeout?: number;\n statsHost?: string;\n timelineParams?: any;\n unavailableTimeout?: number;\n wsHost?: string;\n wsPath?: string;\n wsPort?: number;\n wssPort?: number;\n}\n\nexport function validateOptions(options) {\n if (options == null) {\n throw 'You must pass an options object';\n }\n if (options.cluster == null) {\n throw 'Options object must provide a cluster';\n }\n if ('disableStats' in options) {\n Logger.warn(\n 'The disableStats option is deprecated in favor of enableStats'\n );\n }\n}\n","export enum AuthRequestType {\n UserAuthentication = 'user-authentication',\n ChannelAuthorization = 'channel-authorization'\n}\n\nexport interface ChannelAuthorizationData {\n auth: string;\n channel_data?: string;\n shared_secret?: string;\n}\n\nexport type ChannelAuthorizationCallback = (\n error: Error | null,\n authData: ChannelAuthorizationData | null\n) => void;\n\nexport interface ChannelAuthorizationRequestParams {\n socketId: string;\n channelName: string;\n}\n\nexport interface ChannelAuthorizationHandler {\n (\n params: ChannelAuthorizationRequestParams,\n callback: ChannelAuthorizationCallback\n ): void;\n}\n\nexport interface UserAuthenticationData {\n auth: string;\n user_data: string;\n}\n\nexport type UserAuthenticationCallback = (\n error: Error | null,\n authData: UserAuthenticationData | null\n) => void;\n\nexport interface UserAuthenticationRequestParams {\n socketId: string;\n}\n\nexport interface UserAuthenticationHandler {\n (\n params: UserAuthenticationRequestParams,\n callback: UserAuthenticationCallback\n ): void;\n}\n\nexport type AuthTransportCallback =\n | ChannelAuthorizationCallback\n | UserAuthenticationCallback;\n\nexport interface AuthOptionsT {\n transport: 'ajax' | 'jsonp';\n endpoint: string;\n params?: any;\n headers?: any;\n paramsProvider?: () => any;\n headersProvider?: () => any;\n customHandler?: AuthHandler;\n}\n\nexport declare type UserAuthenticationOptions = AuthOptionsT<\n UserAuthenticationHandler\n>;\nexport declare type ChannelAuthorizationOptions = AuthOptionsT<\n ChannelAuthorizationHandler\n>;\n\nexport interface InternalAuthOptions {\n transport: 'ajax' | 'jsonp';\n endpoint: string;\n params?: any;\n headers?: any;\n paramsProvider?: () => any;\n headersProvider?: () => any;\n}\n","import {\n UserAuthenticationCallback,\n InternalAuthOptions,\n UserAuthenticationHandler,\n UserAuthenticationRequestParams,\n AuthRequestType\n} from './options';\n\nimport Runtime from 'runtime';\n\nconst composeChannelQuery = (\n params: UserAuthenticationRequestParams,\n authOptions: InternalAuthOptions\n) => {\n var query = 'socket_id=' + encodeURIComponent(params.socketId);\n\n for (var key in authOptions.params) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(authOptions.params[key]);\n }\n\n if (authOptions.paramsProvider != null) {\n let dynamicParams = authOptions.paramsProvider();\n for (var key in dynamicParams) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(dynamicParams[key]);\n }\n }\n\n return query;\n};\n\nconst UserAuthenticator = (\n authOptions: InternalAuthOptions\n): UserAuthenticationHandler => {\n if (typeof Runtime.getAuthorizers()[authOptions.transport] === 'undefined') {\n throw `'${authOptions.transport}' is not a recognized auth transport`;\n }\n\n return (\n params: UserAuthenticationRequestParams,\n callback: UserAuthenticationCallback\n ) => {\n const query = composeChannelQuery(params, authOptions);\n\n Runtime.getAuthorizers()[authOptions.transport](\n Runtime,\n query,\n authOptions,\n AuthRequestType.UserAuthentication,\n callback\n );\n };\n};\n\nexport default UserAuthenticator;\n","import {\n AuthRequestType,\n InternalAuthOptions,\n ChannelAuthorizationHandler,\n ChannelAuthorizationRequestParams,\n ChannelAuthorizationCallback\n} from './options';\n\nimport Runtime from 'runtime';\n\nconst composeChannelQuery = (\n params: ChannelAuthorizationRequestParams,\n authOptions: InternalAuthOptions\n) => {\n var query = 'socket_id=' + encodeURIComponent(params.socketId);\n\n query += '&channel_name=' + encodeURIComponent(params.channelName);\n\n for (var key in authOptions.params) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(authOptions.params[key]);\n }\n\n if (authOptions.paramsProvider != null) {\n let dynamicParams = authOptions.paramsProvider();\n for (var key in dynamicParams) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(dynamicParams[key]);\n }\n }\n\n return query;\n};\n\nconst ChannelAuthorizer = (\n authOptions: InternalAuthOptions\n): ChannelAuthorizationHandler => {\n if (typeof Runtime.getAuthorizers()[authOptions.transport] === 'undefined') {\n throw `'${authOptions.transport}' is not a recognized auth transport`;\n }\n\n return (\n params: ChannelAuthorizationRequestParams,\n callback: ChannelAuthorizationCallback\n ) => {\n const query = composeChannelQuery(params, authOptions);\n\n Runtime.getAuthorizers()[authOptions.transport](\n Runtime,\n query,\n authOptions,\n AuthRequestType.ChannelAuthorization,\n callback\n );\n };\n};\n\nexport default ChannelAuthorizer;\n","import Channel from '../channels/channel';\nimport {\n ChannelAuthorizationCallback,\n ChannelAuthorizationHandler,\n ChannelAuthorizationRequestParams,\n InternalAuthOptions\n} from './options';\n\nexport interface DeprecatedChannelAuthorizer {\n authorize(socketId: string, callback: ChannelAuthorizationCallback): void;\n}\n\nexport interface ChannelAuthorizerGenerator {\n (\n channel: Channel,\n options: DeprecatedAuthorizerOptions\n ): DeprecatedChannelAuthorizer;\n}\n\nexport interface DeprecatedAuthOptions {\n params?: any;\n headers?: any;\n}\n\nexport interface DeprecatedAuthorizerOptions {\n authTransport: 'ajax' | 'jsonp';\n authEndpoint: string;\n auth?: DeprecatedAuthOptions;\n}\n\nexport const ChannelAuthorizerProxy = (\n pusher,\n authOptions: InternalAuthOptions,\n channelAuthorizerGenerator: ChannelAuthorizerGenerator\n): ChannelAuthorizationHandler => {\n const deprecatedAuthorizerOptions: DeprecatedAuthorizerOptions = {\n authTransport: authOptions.transport,\n authEndpoint: authOptions.endpoint,\n auth: {\n params: authOptions.params,\n headers: authOptions.headers\n }\n };\n return (\n params: ChannelAuthorizationRequestParams,\n callback: ChannelAuthorizationCallback\n ) => {\n const channel = pusher.channel(params.channelName);\n // This line creates a new channel authorizer every time.\n // In the past, this was only done once per channel and reused.\n // We can do that again if we want to keep this behavior intact.\n const channelAuthorizer: DeprecatedChannelAuthorizer = channelAuthorizerGenerator(\n channel,\n deprecatedAuthorizerOptions\n );\n channelAuthorizer.authorize(params.socketId, callback);\n };\n};\n","import { Options } from './options';\nimport Defaults from './defaults';\nimport {\n ChannelAuthorizationHandler,\n UserAuthenticationHandler,\n ChannelAuthorizationOptions\n} from './auth/options';\nimport UserAuthenticator from './auth/user_authenticator';\nimport ChannelAuthorizer from './auth/channel_authorizer';\nimport { ChannelAuthorizerProxy } from './auth/deprecated_channel_authorizer';\nimport Runtime from 'runtime';\nimport * as nacl from 'tweetnacl';\n\nexport type AuthTransport = 'ajax' | 'jsonp';\nexport type Transport =\n | 'ws'\n | 'wss'\n | 'xhr_streaming'\n | 'xhr_polling'\n | 'sockjs';\n\nexport interface Config {\n // these are all 'required' config parameters, it's not necessary for the user\n // to set them, but they have configured defaults.\n activityTimeout: number;\n enableStats: boolean;\n httpHost: string;\n httpPath: string;\n httpPort: number;\n httpsPort: number;\n pongTimeout: number;\n statsHost: string;\n unavailableTimeout: number;\n useTLS: boolean;\n wsHost: string;\n wsPath: string;\n wsPort: number;\n wssPort: number;\n userAuthenticator: UserAuthenticationHandler;\n channelAuthorizer: ChannelAuthorizationHandler;\n\n // these are all optional parameters or overrrides. The customer can set these\n // but it's not strictly necessary\n forceTLS?: boolean;\n cluster?: string;\n disabledTransports?: Transport[];\n enabledTransports?: Transport[];\n ignoreNullOrigin?: boolean;\n nacl?: nacl;\n timelineParams?: any;\n}\n\n// getConfig mainly sets the defaults for the options that are not provided\nexport function getConfig(opts: Options, pusher): Config {\n let config: Config = {\n activityTimeout: opts.activityTimeout || Defaults.activityTimeout,\n cluster: opts.cluster,\n httpPath: opts.httpPath || Defaults.httpPath,\n httpPort: opts.httpPort || Defaults.httpPort,\n httpsPort: opts.httpsPort || Defaults.httpsPort,\n pongTimeout: opts.pongTimeout || Defaults.pongTimeout,\n statsHost: opts.statsHost || Defaults.stats_host,\n unavailableTimeout: opts.unavailableTimeout || Defaults.unavailableTimeout,\n wsPath: opts.wsPath || Defaults.wsPath,\n wsPort: opts.wsPort || Defaults.wsPort,\n wssPort: opts.wssPort || Defaults.wssPort,\n\n enableStats: getEnableStatsConfig(opts),\n httpHost: getHttpHost(opts),\n useTLS: shouldUseTLS(opts),\n wsHost: getWebsocketHost(opts),\n\n userAuthenticator: buildUserAuthenticator(opts),\n channelAuthorizer: buildChannelAuthorizer(opts, pusher)\n };\n\n if ('disabledTransports' in opts)\n config.disabledTransports = opts.disabledTransports;\n if ('enabledTransports' in opts)\n config.enabledTransports = opts.enabledTransports;\n if ('ignoreNullOrigin' in opts)\n config.ignoreNullOrigin = opts.ignoreNullOrigin;\n if ('timelineParams' in opts) config.timelineParams = opts.timelineParams;\n if ('nacl' in opts) {\n config.nacl = opts.nacl;\n }\n\n return config;\n}\n\nfunction getHttpHost(opts: Options): string {\n if (opts.httpHost) {\n return opts.httpHost;\n }\n if (opts.cluster) {\n return `sockjs-${opts.cluster}.pusher.com`;\n }\n return Defaults.httpHost;\n}\n\nfunction getWebsocketHost(opts: Options): string {\n if (opts.wsHost) {\n return opts.wsHost;\n }\n return getWebsocketHostFromCluster(opts.cluster);\n}\n\nfunction getWebsocketHostFromCluster(cluster: string): string {\n return `ws-${cluster}.pusher.com`;\n}\n\nfunction shouldUseTLS(opts: Options): boolean {\n if (Runtime.getProtocol() === 'https:') {\n return true;\n } else if (opts.forceTLS === false) {\n return false;\n }\n return true;\n}\n\n// if enableStats is set take the value\n// if disableStats is set take the inverse\n// otherwise default to false\nfunction getEnableStatsConfig(opts: Options): boolean {\n if ('enableStats' in opts) {\n return opts.enableStats;\n }\n if ('disableStats' in opts) {\n return !opts.disableStats;\n }\n return false;\n}\n\nfunction buildUserAuthenticator(opts: Options): UserAuthenticationHandler {\n const userAuthentication = {\n ...Defaults.userAuthentication,\n ...opts.userAuthentication\n };\n if (\n 'customHandler' in userAuthentication &&\n userAuthentication['customHandler'] != null\n ) {\n return userAuthentication['customHandler'];\n }\n\n return UserAuthenticator(userAuthentication);\n}\n\nfunction buildChannelAuth(opts: Options, pusher): ChannelAuthorizationOptions {\n let channelAuthorization: ChannelAuthorizationOptions;\n if ('channelAuthorization' in opts) {\n channelAuthorization = {\n ...Defaults.channelAuthorization,\n ...opts.channelAuthorization\n };\n } else {\n channelAuthorization = {\n transport: opts.authTransport || Defaults.authTransport,\n endpoint: opts.authEndpoint || Defaults.authEndpoint\n };\n if ('auth' in opts) {\n if ('params' in opts.auth) channelAuthorization.params = opts.auth.params;\n if ('headers' in opts.auth)\n channelAuthorization.headers = opts.auth.headers;\n }\n if ('authorizer' in opts)\n channelAuthorization.customHandler = ChannelAuthorizerProxy(\n pusher,\n channelAuthorization,\n opts.authorizer\n );\n }\n return channelAuthorization;\n}\n\nfunction buildChannelAuthorizer(\n opts: Options,\n pusher\n): ChannelAuthorizationHandler {\n const channelAuthorization = buildChannelAuth(opts, pusher);\n if (\n 'customHandler' in channelAuthorization &&\n channelAuthorization['customHandler'] != null\n ) {\n return channelAuthorization['customHandler'];\n }\n\n return ChannelAuthorizer(channelAuthorization);\n}\n","import Logger from './logger';\nimport Pusher from './pusher';\nimport EventsDispatcher from './events/dispatcher';\n\nexport default class WatchlistFacade extends EventsDispatcher {\n private pusher: Pusher;\n\n public constructor(pusher: Pusher) {\n super(function(eventName, data) {\n Logger.debug(`No callbacks on watchlist events for ${eventName}`);\n });\n\n this.pusher = pusher;\n this.bindWatchlistInternalEvent();\n }\n\n handleEvent(pusherEvent) {\n pusherEvent.data.events.forEach(watchlistEvent => {\n this.emit(watchlistEvent.name, watchlistEvent);\n });\n }\n\n private bindWatchlistInternalEvent() {\n this.pusher.connection.bind('message', pusherEvent => {\n var eventName = pusherEvent.event;\n if (eventName === 'pusher_internal:watchlist_events') {\n this.handleEvent(pusherEvent);\n }\n });\n }\n}\n","function flatPromise() {\n let resolve, reject;\n const promise = new Promise((res, rej) => {\n resolve = res;\n reject = rej;\n });\n return { promise, resolve, reject };\n}\n\nexport default flatPromise;\n","import Pusher from './pusher';\nimport Logger from './logger';\nimport {\n UserAuthenticationData,\n UserAuthenticationCallback\n} from './auth/options';\nimport Channel from './channels/channel';\nimport WatchlistFacade from './watchlist';\nimport EventsDispatcher from './events/dispatcher';\nimport flatPromise from './utils/flat_promise';\n\nexport default class UserFacade extends EventsDispatcher {\n pusher: Pusher;\n signin_requested: boolean = false;\n user_data: any = null;\n serverToUserChannel: Channel = null;\n signinDonePromise: Promise = null;\n watchlist: WatchlistFacade;\n private _signinDoneResolve: Function = null;\n\n public constructor(pusher: Pusher) {\n super(function(eventName, data) {\n Logger.debug('No callbacks on user for ' + eventName);\n });\n this.pusher = pusher;\n this.pusher.connection.bind('state_change', ({ previous, current }) => {\n if (previous !== 'connected' && current === 'connected') {\n this._signin();\n }\n if (previous === 'connected' && current !== 'connected') {\n this._cleanup();\n this._newSigninPromiseIfNeeded();\n }\n });\n\n this.watchlist = new WatchlistFacade(pusher);\n\n this.pusher.connection.bind('message', event => {\n var eventName = event.event;\n if (eventName === 'pusher:signin_success') {\n this._onSigninSuccess(event.data);\n }\n if (\n this.serverToUserChannel &&\n this.serverToUserChannel.name === event.channel\n ) {\n this.serverToUserChannel.handleEvent(event);\n }\n });\n }\n\n public signin() {\n if (this.signin_requested) {\n return;\n }\n\n this.signin_requested = true;\n this._signin();\n }\n\n private _signin() {\n if (!this.signin_requested) {\n return;\n }\n\n this._newSigninPromiseIfNeeded();\n\n if (this.pusher.connection.state !== 'connected') {\n // Signin will be attempted when the connection is connected\n return;\n }\n\n this.pusher.config.userAuthenticator(\n {\n socketId: this.pusher.connection.socket_id\n },\n this._onAuthorize\n );\n }\n\n private _onAuthorize: UserAuthenticationCallback = (\n err,\n authData: UserAuthenticationData\n ) => {\n if (err) {\n Logger.warn(`Error during signin: ${err}`);\n this._cleanup();\n return;\n }\n\n this.pusher.send_event('pusher:signin', {\n auth: authData.auth,\n user_data: authData.user_data\n });\n\n // Later when we get pusher:singin_success event, the user will be marked as signed in\n };\n\n private _onSigninSuccess(data: any) {\n try {\n this.user_data = JSON.parse(data.user_data);\n } catch (e) {\n Logger.error(`Failed parsing user data after signin: ${data.user_data}`);\n this._cleanup();\n return;\n }\n\n if (typeof this.user_data.id !== 'string' || this.user_data.id === '') {\n Logger.error(\n `user_data doesn't contain an id. user_data: ${this.user_data}`\n );\n this._cleanup();\n return;\n }\n\n // Signin succeeded\n this._signinDoneResolve();\n this._subscribeChannels();\n }\n\n private _subscribeChannels() {\n const ensure_subscribed = channel => {\n if (channel.subscriptionPending && channel.subscriptionCancelled) {\n channel.reinstateSubscription();\n } else if (\n !channel.subscriptionPending &&\n this.pusher.connection.state === 'connected'\n ) {\n channel.subscribe();\n }\n };\n\n this.serverToUserChannel = new Channel(\n `#server-to-user-${this.user_data.id}`,\n this.pusher\n );\n this.serverToUserChannel.bind_global((eventName, data) => {\n if (\n eventName.indexOf('pusher_internal:') === 0 ||\n eventName.indexOf('pusher:') === 0\n ) {\n // ignore internal events\n return;\n }\n this.emit(eventName, data);\n });\n ensure_subscribed(this.serverToUserChannel);\n }\n\n private _cleanup() {\n this.user_data = null;\n if (this.serverToUserChannel) {\n this.serverToUserChannel.unbind_all();\n this.serverToUserChannel.disconnect();\n this.serverToUserChannel = null;\n }\n\n if (this.signin_requested) {\n // If signin is in progress and cleanup is called,\n // Mark the current signin process as done.\n this._signinDoneResolve();\n }\n }\n\n private _newSigninPromiseIfNeeded() {\n if (!this.signin_requested) {\n return;\n }\n\n // If there is a promise and it is not resolved, return without creating a new one.\n if (this.signinDonePromise && !(this.signinDonePromise as any).done) {\n return;\n }\n\n // This promise is never rejected.\n // It gets resolved when the signin process is done whether it failed or succeeded\n const { promise, resolve, reject: _ } = flatPromise();\n (promise as any).done = false;\n const setDone = () => {\n (promise as any).done = true;\n };\n promise.then(setDone).catch(setDone);\n this.signinDonePromise = promise;\n this._signinDoneResolve = resolve;\n }\n}\n","import AbstractRuntime from '../runtimes/interface';\nimport Runtime from 'runtime';\nimport Util from './util';\nimport * as Collections from './utils/collections';\nimport Channels from './channels/channels';\nimport Channel from './channels/channel';\nimport { default as EventsDispatcher } from './events/dispatcher';\nimport Timeline from './timeline/timeline';\nimport TimelineSender from './timeline/timeline_sender';\nimport TimelineLevel from './timeline/level';\nimport { defineTransport } from './strategies/strategy_builder';\nimport ConnectionManager from './connection/connection_manager';\nimport ConnectionManagerOptions from './connection/connection_manager_options';\nimport { PeriodicTimer } from './utils/timers';\nimport Defaults from './defaults';\nimport * as DefaultConfig from './config';\nimport Logger from './logger';\nimport Factory from './utils/factory';\nimport UrlStore from 'core/utils/url_store';\nimport { Options, validateOptions } from './options';\nimport { Config, getConfig } from './config';\nimport StrategyOptions from './strategies/strategy_options';\nimport UserFacade from './user';\n\nexport default class Pusher {\n /* STATIC PROPERTIES */\n static instances: Pusher[] = [];\n static isReady: boolean = false;\n static logToConsole: boolean = false;\n\n // for jsonp\n static Runtime: AbstractRuntime = Runtime;\n static ScriptReceivers: any = (Runtime).ScriptReceivers;\n static DependenciesReceivers: any = (Runtime).DependenciesReceivers;\n static auth_callbacks: any = (Runtime).auth_callbacks;\n\n static ready() {\n Pusher.isReady = true;\n for (var i = 0, l = Pusher.instances.length; i < l; i++) {\n Pusher.instances[i].connect();\n }\n }\n\n static log: (message: any) => void;\n\n private static getClientFeatures(): string[] {\n return Collections.keys(\n Collections.filterObject({ ws: Runtime.Transports.ws }, function(t) {\n return t.isSupported({});\n })\n );\n }\n\n /* INSTANCE PROPERTIES */\n key: string;\n config: Config;\n channels: Channels;\n global_emitter: EventsDispatcher;\n sessionID: number;\n timeline: Timeline;\n timelineSender: TimelineSender;\n connection: ConnectionManager;\n timelineSenderTimer: PeriodicTimer;\n user: UserFacade;\n constructor(app_key: string, options: Options) {\n checkAppKey(app_key);\n validateOptions(options);\n this.key = app_key;\n this.config = getConfig(options, this);\n\n this.channels = Factory.createChannels();\n this.global_emitter = new EventsDispatcher();\n this.sessionID = Runtime.randomInt(1000000000);\n\n this.timeline = new Timeline(this.key, this.sessionID, {\n cluster: this.config.cluster,\n features: Pusher.getClientFeatures(),\n params: this.config.timelineParams || {},\n limit: 50,\n level: TimelineLevel.INFO,\n version: Defaults.VERSION\n });\n if (this.config.enableStats) {\n this.timelineSender = Factory.createTimelineSender(this.timeline, {\n host: this.config.statsHost,\n path: '/timeline/v2/' + Runtime.TimelineTransport.name\n });\n }\n\n var getStrategy = (options: StrategyOptions) => {\n return Runtime.getDefaultStrategy(this.config, options, defineTransport);\n };\n\n this.connection = Factory.createConnectionManager(this.key, {\n getStrategy: getStrategy,\n timeline: this.timeline,\n activityTimeout: this.config.activityTimeout,\n pongTimeout: this.config.pongTimeout,\n unavailableTimeout: this.config.unavailableTimeout,\n useTLS: Boolean(this.config.useTLS)\n });\n\n this.connection.bind('connected', () => {\n this.subscribeAll();\n if (this.timelineSender) {\n this.timelineSender.send(this.connection.isUsingTLS());\n }\n });\n\n this.connection.bind('message', event => {\n var eventName = event.event;\n var internal = eventName.indexOf('pusher_internal:') === 0;\n if (event.channel) {\n var channel = this.channel(event.channel);\n if (channel) {\n channel.handleEvent(event);\n }\n }\n // Emit globally [deprecated]\n if (!internal) {\n this.global_emitter.emit(event.event, event.data);\n }\n });\n this.connection.bind('connecting', () => {\n this.channels.disconnect();\n });\n this.connection.bind('disconnected', () => {\n this.channels.disconnect();\n });\n this.connection.bind('error', err => {\n Logger.warn(err);\n });\n\n Pusher.instances.push(this);\n this.timeline.info({ instances: Pusher.instances.length });\n\n this.user = new UserFacade(this);\n\n if (Pusher.isReady) {\n this.connect();\n }\n }\n\n channel(name: string): Channel {\n return this.channels.find(name);\n }\n\n allChannels(): Channel[] {\n return this.channels.all();\n }\n\n connect() {\n this.connection.connect();\n\n if (this.timelineSender) {\n if (!this.timelineSenderTimer) {\n var usingTLS = this.connection.isUsingTLS();\n var timelineSender = this.timelineSender;\n this.timelineSenderTimer = new PeriodicTimer(60000, function() {\n timelineSender.send(usingTLS);\n });\n }\n }\n }\n\n disconnect() {\n this.connection.disconnect();\n\n if (this.timelineSenderTimer) {\n this.timelineSenderTimer.ensureAborted();\n this.timelineSenderTimer = null;\n }\n }\n\n bind(event_name: string, callback: Function, context?: any): Pusher {\n this.global_emitter.bind(event_name, callback, context);\n return this;\n }\n\n unbind(event_name?: string, callback?: Function, context?: any): Pusher {\n this.global_emitter.unbind(event_name, callback, context);\n return this;\n }\n\n bind_global(callback: Function): Pusher {\n this.global_emitter.bind_global(callback);\n return this;\n }\n\n unbind_global(callback?: Function): Pusher {\n this.global_emitter.unbind_global(callback);\n return this;\n }\n\n unbind_all(callback?: Function): Pusher {\n this.global_emitter.unbind_all();\n return this;\n }\n\n subscribeAll() {\n var channelName;\n for (channelName in this.channels.channels) {\n if (this.channels.channels.hasOwnProperty(channelName)) {\n this.subscribe(channelName);\n }\n }\n }\n\n subscribe(channel_name: string) {\n var channel = this.channels.add(channel_name, this);\n if (channel.subscriptionPending && channel.subscriptionCancelled) {\n channel.reinstateSubscription();\n } else if (\n !channel.subscriptionPending &&\n this.connection.state === 'connected'\n ) {\n channel.subscribe();\n }\n return channel;\n }\n\n unsubscribe(channel_name: string) {\n var channel = this.channels.find(channel_name);\n if (channel && channel.subscriptionPending) {\n channel.cancelSubscription();\n } else {\n channel = this.channels.remove(channel_name);\n if (channel && channel.subscribed) {\n channel.unsubscribe();\n }\n }\n }\n\n send_event(event_name: string, data: any, channel?: string) {\n return this.connection.send_event(event_name, data, channel);\n }\n\n shouldUseTLS(): boolean {\n return this.config.useTLS;\n }\n\n signin() {\n this.user.signin();\n }\n}\n\nfunction checkAppKey(key) {\n if (key === null || key === undefined) {\n throw 'You must pass your app key when you instantiate Pusher.';\n }\n}\n\nRuntime.setup(Pusher);\n"],"sourceRoot":""} \ No newline at end of file +{"version":3,"sources":["webpack://Pusher/webpack/universalModuleDefinition","webpack://Pusher/webpack/bootstrap","webpack://Pusher/./node_modules/@stablelib/base64/base64.ts","webpack://Pusher/./node_modules/@stablelib/utf8/utf8.ts","webpack://Pusher/./src/core/pusher.js","webpack://Pusher/./src/core/base64.ts","webpack://Pusher/./src/core/utils/timers/abstract_timer.ts","webpack://Pusher/./src/core/utils/timers/index.ts","webpack://Pusher/./src/core/util.ts","webpack://Pusher/./src/core/utils/collections.ts","webpack://Pusher/./src/core/defaults.ts","webpack://Pusher/./src/core/transports/url_schemes.ts","webpack://Pusher/./src/core/events/callback_registry.ts","webpack://Pusher/./src/core/events/dispatcher.ts","webpack://Pusher/./src/core/logger.ts","webpack://Pusher/./src/core/transports/transport_connection.ts","webpack://Pusher/./src/core/transports/transport.ts","webpack://Pusher/./src/runtimes/isomorphic/transports/transports.ts","webpack://Pusher/./src/core/transports/assistant_to_the_transport_manager.ts","webpack://Pusher/./src/core/connection/protocol/protocol.ts","webpack://Pusher/./src/core/connection/connection.ts","webpack://Pusher/./src/core/connection/handshake/index.ts","webpack://Pusher/./src/core/timeline/timeline_sender.ts","webpack://Pusher/./src/core/errors.ts","webpack://Pusher/./src/core/utils/url_store.ts","webpack://Pusher/./src/core/channels/channel.ts","webpack://Pusher/./src/core/channels/private_channel.ts","webpack://Pusher/./src/core/channels/members.ts","webpack://Pusher/./src/core/channels/presence_channel.ts","webpack://Pusher/./src/core/channels/encrypted_channel.ts","webpack://Pusher/./src/core/connection/connection_manager.ts","webpack://Pusher/./src/core/channels/channels.ts","webpack://Pusher/./src/core/utils/factory.ts","webpack://Pusher/./src/core/transports/transport_manager.ts","webpack://Pusher/./src/core/strategies/sequential_strategy.ts","webpack://Pusher/./src/core/strategies/best_connected_ever_strategy.ts","webpack://Pusher/./src/core/strategies/websocket_prioritized_cached_strategy.ts","webpack://Pusher/./src/core/strategies/delayed_strategy.ts","webpack://Pusher/./src/core/strategies/if_strategy.ts","webpack://Pusher/./src/core/strategies/first_connected_strategy.ts","webpack://Pusher/./src/runtimes/isomorphic/default_strategy.ts","webpack://Pusher/./src/runtimes/isomorphic/transports/transport_connection_initializer.ts","webpack://Pusher/./src/core/http/http_request.ts","webpack://Pusher/./src/core/http/state.ts","webpack://Pusher/./src/core/http/http_socket.ts","webpack://Pusher/./src/core/http/http_streaming_socket.ts","webpack://Pusher/./src/core/http/http_polling_socket.ts","webpack://Pusher/./src/runtimes/isomorphic/http/http_xhr_request.ts","webpack://Pusher/./src/runtimes/isomorphic/http/http.ts","webpack://Pusher/./src/runtimes/isomorphic/runtime.ts","webpack://Pusher/./src/runtimes/worker/net_info.ts","webpack://Pusher/./src/runtimes/worker/auth/fetch_auth.ts","webpack://Pusher/./src/runtimes/worker/timeline/fetch_timeline.ts","webpack://Pusher/./src/runtimes/worker/runtime.ts","webpack://Pusher/./src/core/timeline/level.ts","webpack://Pusher/./src/core/timeline/timeline.ts","webpack://Pusher/./src/core/strategies/transport_strategy.ts","webpack://Pusher/./src/core/strategies/strategy_builder.ts","webpack://Pusher/./src/core/options.ts","webpack://Pusher/./src/core/auth/options.ts","webpack://Pusher/./src/core/auth/user_authenticator.ts","webpack://Pusher/./src/core/auth/channel_authorizer.ts","webpack://Pusher/./src/core/auth/deprecated_channel_authorizer.ts","webpack://Pusher/./src/core/config.ts","webpack://Pusher/./src/core/watchlist.ts","webpack://Pusher/./src/core/utils/flat_promise.ts","webpack://Pusher/./src/core/user.ts","webpack://Pusher/./src/core/pusher.ts"],"names":[],"mappings":";;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AACD,O;QCVA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;;QAEA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;;;QAGA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;QACA,0CAA0C,gCAAgC;QAC1E;QACA;;QAEA;QACA;QACA;QACA,wDAAwD,kBAAkB;QAC1E;QACA,iDAAiD,cAAc;QAC/D;;QAEA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA,yCAAyC,iCAAiC;QAC1E,gHAAgH,mBAAmB,EAAE;QACrI;QACA;;QAEA;QACA;QACA;QACA,2BAA2B,0BAA0B,EAAE;QACvD,iCAAiC,eAAe;QAChD;QACA;QACA;;QAEA;QACA,sDAAsD,+DAA+D;;QAErH;QACA;;;QAGA;QACA;;;;;;;;;AClFA,sCAAsC;AACtC,6CAA6C;;;;;;;;;;;;;;;AAE7C;;GAEG;AAEH,iDAAiD;AACjD,kDAAkD;AAClD,kCAAkC;AAClC,IAAM,YAAY,GAAG,GAAG,CAAC;AAEzB;;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I,IAAI,GAAG,KAAK,SAAS,EAAE;QACrC,MAAM,yDAAyD,CAAC;KACjE;AACH,CAAC;AAED,cAAO,CAAC,KAAK,CAAC,aAAM,CAAC,CAAC","file":"pusher.worker.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"Pusher\"] = factory();\n\telse\n\t\troot[\"Pusher\"] = factory();\n})(this, function() {\nreturn "," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 2);\n","// Copyright (C) 2016 Dmitry Chestnykh\n// MIT License. See LICENSE file for details.\n\n/**\n * Package base64 implements Base64 encoding and decoding.\n */\n\n// Invalid character used in decoding to indicate\n// that the character to decode is out of range of\n// alphabet and cannot be decoded.\nconst INVALID_BYTE = 256;\n\n/**\n * Implements standard Base64 encoding.\n *\n * Operates in constant time.\n */\nexport class Coder {\n // TODO(dchest): methods to encode chunk-by-chunk.\n\n constructor(private _paddingCharacter = \"=\") { }\n\n encodedLength(length: number): number {\n if (!this._paddingCharacter) {\n return (length * 8 + 5) / 6 | 0;\n }\n return (length + 2) / 3 * 4 | 0;\n }\n\n encode(data: Uint8Array): string {\n let out = \"\";\n\n let i = 0;\n for (; i < data.length - 2; i += 3) {\n let c = (data[i] << 16) | (data[i + 1] << 8) | (data[i + 2]);\n out += this._encodeByte((c >>> 3 * 6) & 63);\n out += this._encodeByte((c >>> 2 * 6) & 63);\n out += this._encodeByte((c >>> 1 * 6) & 63);\n out += this._encodeByte((c >>> 0 * 6) & 63);\n }\n\n const left = data.length - i;\n if (left > 0) {\n let c = (data[i] << 16) | (left === 2 ? data[i + 1] << 8 : 0);\n out += this._encodeByte((c >>> 3 * 6) & 63);\n out += this._encodeByte((c >>> 2 * 6) & 63);\n if (left === 2) {\n out += this._encodeByte((c >>> 1 * 6) & 63);\n } else {\n out += this._paddingCharacter || \"\";\n }\n out += this._paddingCharacter || \"\";\n }\n\n return out;\n }\n\n maxDecodedLength(length: number): number {\n if (!this._paddingCharacter) {\n return (length * 6 + 7) / 8 | 0;\n }\n return length / 4 * 3 | 0;\n }\n\n decodedLength(s: string): number {\n return this.maxDecodedLength(s.length - this._getPaddingLength(s));\n }\n\n decode(s: string): Uint8Array {\n if (s.length === 0) {\n return new Uint8Array(0);\n }\n const paddingLength = this._getPaddingLength(s);\n const length = s.length - paddingLength;\n const out = new Uint8Array(this.maxDecodedLength(length));\n let op = 0;\n let i = 0;\n let haveBad = 0;\n let v0 = 0, v1 = 0, v2 = 0, v3 = 0;\n for (; i < length - 4; i += 4) {\n v0 = this._decodeChar(s.charCodeAt(i + 0));\n v1 = this._decodeChar(s.charCodeAt(i + 1));\n v2 = this._decodeChar(s.charCodeAt(i + 2));\n v3 = this._decodeChar(s.charCodeAt(i + 3));\n out[op++] = (v0 << 2) | (v1 >>> 4);\n out[op++] = (v1 << 4) | (v2 >>> 2);\n out[op++] = (v2 << 6) | v3;\n haveBad |= v0 & INVALID_BYTE;\n haveBad |= v1 & INVALID_BYTE;\n haveBad |= v2 & INVALID_BYTE;\n haveBad |= v3 & INVALID_BYTE;\n }\n if (i < length - 1) {\n v0 = this._decodeChar(s.charCodeAt(i));\n v1 = this._decodeChar(s.charCodeAt(i + 1));\n out[op++] = (v0 << 2) | (v1 >>> 4);\n haveBad |= v0 & INVALID_BYTE;\n haveBad |= v1 & INVALID_BYTE;\n }\n if (i < length - 2) {\n v2 = this._decodeChar(s.charCodeAt(i + 2));\n out[op++] = (v1 << 4) | (v2 >>> 2);\n haveBad |= v2 & INVALID_BYTE;\n }\n if (i < length - 3) {\n v3 = this._decodeChar(s.charCodeAt(i + 3));\n out[op++] = (v2 << 6) | v3;\n haveBad |= v3 & INVALID_BYTE;\n }\n if (haveBad !== 0) {\n throw new Error(\"Base64Coder: incorrect characters for decoding\");\n }\n return out;\n }\n\n // Standard encoding have the following encoded/decoded ranges,\n // which we need to convert between.\n //\n // ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 0123456789 + /\n // Index: 0 - 25 26 - 51 52 - 61 62 63\n // ASCII: 65 - 90 97 - 122 48 - 57 43 47\n //\n\n // Encode 6 bits in b into a new character.\n protected _encodeByte(b: number): string {\n // Encoding uses constant time operations as follows:\n //\n // 1. Define comparison of A with B using (A - B) >>> 8:\n // if A > B, then result is positive integer\n // if A <= B, then result is 0\n //\n // 2. Define selection of C or 0 using bitwise AND: X & C:\n // if X == 0, then result is 0\n // if X != 0, then result is C\n //\n // 3. Start with the smallest comparison (b >= 0), which is always\n // true, so set the result to the starting ASCII value (65).\n //\n // 4. Continue comparing b to higher ASCII values, and selecting\n // zero if comparison isn't true, otherwise selecting a value\n // to add to result, which:\n //\n // a) undoes the previous addition\n // b) provides new value to add\n //\n let result = b;\n // b >= 0\n result += 65;\n // b > 25\n result += ((25 - b) >>> 8) & ((0 - 65) - 26 + 97);\n // b > 51\n result += ((51 - b) >>> 8) & ((26 - 97) - 52 + 48);\n // b > 61\n result += ((61 - b) >>> 8) & ((52 - 48) - 62 + 43);\n // b > 62\n result += ((62 - b) >>> 8) & ((62 - 43) - 63 + 47);\n\n return String.fromCharCode(result);\n }\n\n // Decode a character code into a byte.\n // Must return 256 if character is out of alphabet range.\n protected _decodeChar(c: number): number {\n // Decoding works similar to encoding: using the same comparison\n // function, but now it works on ranges: result is always incremented\n // by value, but this value becomes zero if the range is not\n // satisfied.\n //\n // Decoding starts with invalid value, 256, which is then\n // subtracted when the range is satisfied. If none of the ranges\n // apply, the function returns 256, which is then checked by\n // the caller to throw error.\n let result = INVALID_BYTE; // start with invalid character\n\n // c == 43 (c > 42 and c < 44)\n result += (((42 - c) & (c - 44)) >>> 8) & (-INVALID_BYTE + c - 43 + 62);\n // c == 47 (c > 46 and c < 48)\n result += (((46 - c) & (c - 48)) >>> 8) & (-INVALID_BYTE + c - 47 + 63);\n // c > 47 and c < 58\n result += (((47 - c) & (c - 58)) >>> 8) & (-INVALID_BYTE + c - 48 + 52);\n // c > 64 and c < 91\n result += (((64 - c) & (c - 91)) >>> 8) & (-INVALID_BYTE + c - 65 + 0);\n // c > 96 and c < 123\n result += (((96 - c) & (c - 123)) >>> 8) & (-INVALID_BYTE + c - 97 + 26);\n\n return result;\n }\n\n private _getPaddingLength(s: string): number {\n let paddingLength = 0;\n if (this._paddingCharacter) {\n for (let i = s.length - 1; i >= 0; i--) {\n if (s[i] !== this._paddingCharacter) {\n break;\n }\n paddingLength++;\n }\n if (s.length < 4 || paddingLength > 2) {\n throw new Error(\"Base64Coder: incorrect padding\");\n }\n }\n return paddingLength;\n }\n\n}\n\nconst stdCoder = new Coder();\n\nexport function encode(data: Uint8Array): string {\n return stdCoder.encode(data);\n}\n\nexport function decode(s: string): Uint8Array {\n return stdCoder.decode(s);\n}\n\n/**\n * Implements URL-safe Base64 encoding.\n * (Same as Base64, but '+' is replaced with '-', and '/' with '_').\n *\n * Operates in constant time.\n */\nexport class URLSafeCoder extends Coder {\n // URL-safe encoding have the following encoded/decoded ranges:\n //\n // ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 0123456789 - _\n // Index: 0 - 25 26 - 51 52 - 61 62 63\n // ASCII: 65 - 90 97 - 122 48 - 57 45 95\n //\n\n protected _encodeByte(b: number): string {\n let result = b;\n // b >= 0\n result += 65;\n // b > 25\n result += ((25 - b) >>> 8) & ((0 - 65) - 26 + 97);\n // b > 51\n result += ((51 - b) >>> 8) & ((26 - 97) - 52 + 48);\n // b > 61\n result += ((61 - b) >>> 8) & ((52 - 48) - 62 + 45);\n // b > 62\n result += ((62 - b) >>> 8) & ((62 - 45) - 63 + 95);\n\n return String.fromCharCode(result);\n }\n\n protected _decodeChar(c: number): number {\n let result = INVALID_BYTE;\n\n // c == 45 (c > 44 and c < 46)\n result += (((44 - c) & (c - 46)) >>> 8) & (-INVALID_BYTE + c - 45 + 62);\n // c == 95 (c > 94 and c < 96)\n result += (((94 - c) & (c - 96)) >>> 8) & (-INVALID_BYTE + c - 95 + 63);\n // c > 47 and c < 58\n result += (((47 - c) & (c - 58)) >>> 8) & (-INVALID_BYTE + c - 48 + 52);\n // c > 64 and c < 91\n result += (((64 - c) & (c - 91)) >>> 8) & (-INVALID_BYTE + c - 65 + 0);\n // c > 96 and c < 123\n result += (((96 - c) & (c - 123)) >>> 8) & (-INVALID_BYTE + c - 97 + 26);\n\n return result;\n }\n}\n\nconst urlSafeCoder = new URLSafeCoder();\n\nexport function encodeURLSafe(data: Uint8Array): string {\n return urlSafeCoder.encode(data);\n}\n\nexport function decodeURLSafe(s: string): Uint8Array {\n return urlSafeCoder.decode(s);\n}\n\n\nexport const encodedLength = (length: number) =>\n stdCoder.encodedLength(length);\n\nexport const maxDecodedLength = (length: number) =>\n stdCoder.maxDecodedLength(length);\n\nexport const decodedLength = (s: string) =>\n stdCoder.decodedLength(s);\n","// Copyright (C) 2016 Dmitry Chestnykh\n// MIT License. See LICENSE file for details.\n\n/**\n * Package utf8 implements UTF-8 encoding and decoding.\n */\n\nconst INVALID_UTF16 = \"utf8: invalid string\";\nconst INVALID_UTF8 = \"utf8: invalid source encoding\";\n\n/**\n * Encodes the given string into UTF-8 byte array.\n * Throws if the source string has invalid UTF-16 encoding.\n */\nexport function encode(s: string): Uint8Array {\n // Calculate result length and allocate output array.\n // encodedLength() also validates string and throws errors,\n // so we don't need repeat validation here.\n const arr = new Uint8Array(encodedLength(s));\n\n let pos = 0;\n for (let i = 0; i < s.length; i++) {\n let c = s.charCodeAt(i);\n if (c < 0x80) {\n arr[pos++] = c;\n } else if (c < 0x800) {\n arr[pos++] = 0xc0 | c >> 6;\n arr[pos++] = 0x80 | c & 0x3f;\n } else if (c < 0xd800) {\n arr[pos++] = 0xe0 | c >> 12;\n arr[pos++] = 0x80 | (c >> 6) & 0x3f;\n arr[pos++] = 0x80 | c & 0x3f;\n } else {\n i++; // get one more character\n c = (c & 0x3ff) << 10;\n c |= s.charCodeAt(i) & 0x3ff;\n c += 0x10000;\n\n arr[pos++] = 0xf0 | c >> 18;\n arr[pos++] = 0x80 | (c >> 12) & 0x3f;\n arr[pos++] = 0x80 | (c >> 6) & 0x3f;\n arr[pos++] = 0x80 | c & 0x3f;\n }\n }\n return arr;\n}\n\n/**\n * Returns the number of bytes required to encode the given string into UTF-8.\n * Throws if the source string has invalid UTF-16 encoding.\n */\nexport function encodedLength(s: string): number {\n let result = 0;\n for (let i = 0; i < s.length; i++) {\n const c = s.charCodeAt(i);\n if (c < 0x80) {\n result += 1;\n } else if (c < 0x800) {\n result += 2;\n } else if (c < 0xd800) {\n result += 3;\n } else if (c <= 0xdfff) {\n if (i >= s.length - 1) {\n throw new Error(INVALID_UTF16);\n }\n i++; // \"eat\" next character\n result += 4;\n } else {\n throw new Error(INVALID_UTF16);\n }\n }\n return result;\n}\n\n/**\n * Decodes the given byte array from UTF-8 into a string.\n * Throws if encoding is invalid.\n */\nexport function decode(arr: Uint8Array): string {\n const chars: string[] = [];\n for (let i = 0; i < arr.length; i++) {\n let b = arr[i];\n\n if (b & 0x80) {\n let min;\n if (b < 0xe0) {\n // Need 1 more byte.\n if (i >= arr.length) {\n throw new Error(INVALID_UTF8);\n }\n const n1 = arr[++i];\n if ((n1 & 0xc0) !== 0x80) {\n throw new Error(INVALID_UTF8);\n }\n b = (b & 0x1f) << 6 | (n1 & 0x3f);\n min = 0x80;\n } else if (b < 0xf0) {\n // Need 2 more bytes.\n if (i >= arr.length - 1) {\n throw new Error(INVALID_UTF8);\n }\n const n1 = arr[++i];\n const n2 = arr[++i];\n if ((n1 & 0xc0) !== 0x80 || (n2 & 0xc0) !== 0x80) {\n throw new Error(INVALID_UTF8);\n }\n b = (b & 0x0f) << 12 | (n1 & 0x3f) << 6 | (n2 & 0x3f);\n min = 0x800;\n } else if (b < 0xf8) {\n // Need 3 more bytes.\n if (i >= arr.length - 2) {\n throw new Error(INVALID_UTF8);\n }\n const n1 = arr[++i];\n const n2 = arr[++i];\n const n3 = arr[++i];\n if ((n1 & 0xc0) !== 0x80 || (n2 & 0xc0) !== 0x80 || (n3 & 0xc0) !== 0x80) {\n throw new Error(INVALID_UTF8);\n }\n b = (b & 0x0f) << 18 | (n1 & 0x3f) << 12 | (n2 & 0x3f) << 6 | (n3 & 0x3f);\n min = 0x10000;\n } else {\n throw new Error(INVALID_UTF8);\n }\n\n if (b < min || (b >= 0xd800 && b <= 0xdfff)) {\n throw new Error(INVALID_UTF8);\n }\n\n if (b >= 0x10000) {\n // Surrogate pair.\n if (b > 0x10ffff) {\n throw new Error(INVALID_UTF8);\n }\n b -= 0x10000;\n chars.push(String.fromCharCode(0xd800 | (b >> 10)));\n b = 0xdc00 | (b & 0x3ff);\n }\n }\n\n chars.push(String.fromCharCode(b));\n }\n return chars.join(\"\");\n}\n","// required so we don't have to do require('pusher').default etc.\nmodule.exports = require('./pusher').default;\n","export default function encode(s: any): string {\n return btoa(utob(s));\n}\n\nvar fromCharCode = String.fromCharCode;\n\nvar b64chars =\n 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';\nvar b64tab = {};\n\nfor (var i = 0, l = b64chars.length; i < l; i++) {\n b64tab[b64chars.charAt(i)] = i;\n}\n\nvar cb_utob = function(c) {\n var cc = c.charCodeAt(0);\n return cc < 0x80\n ? c\n : cc < 0x800\n ? fromCharCode(0xc0 | (cc >>> 6)) + fromCharCode(0x80 | (cc & 0x3f))\n : fromCharCode(0xe0 | ((cc >>> 12) & 0x0f)) +\n fromCharCode(0x80 | ((cc >>> 6) & 0x3f)) +\n fromCharCode(0x80 | (cc & 0x3f));\n};\n\nvar utob = function(u) {\n return u.replace(/[^\\x00-\\x7F]/g, cb_utob);\n};\n\nvar cb_encode = function(ccc) {\n var padlen = [0, 2, 1][ccc.length % 3];\n var ord =\n (ccc.charCodeAt(0) << 16) |\n ((ccc.length > 1 ? ccc.charCodeAt(1) : 0) << 8) |\n (ccc.length > 2 ? ccc.charCodeAt(2) : 0);\n var chars = [\n b64chars.charAt(ord >>> 18),\n b64chars.charAt((ord >>> 12) & 63),\n padlen >= 2 ? '=' : b64chars.charAt((ord >>> 6) & 63),\n padlen >= 1 ? '=' : b64chars.charAt(ord & 63)\n ];\n return chars.join('');\n};\n\nvar btoa =\n global.btoa ||\n function(b) {\n return b.replace(/[\\s\\S]{1,3}/g, cb_encode);\n };\n","import TimedCallback from './timed_callback';\nimport { Delay, Scheduler, Canceller } from './scheduling';\n\nabstract class Timer {\n protected clear: Canceller;\n protected timer: number | void;\n\n constructor(\n set: Scheduler,\n clear: Canceller,\n delay: Delay,\n callback: TimedCallback\n ) {\n this.clear = clear;\n this.timer = set(() => {\n if (this.timer) {\n this.timer = callback(this.timer);\n }\n }, delay);\n }\n\n /** Returns whether the timer is still running.\n *\n * @return {Boolean}\n */\n isRunning(): boolean {\n return this.timer !== null;\n }\n\n /** Aborts a timer when it's running. */\n ensureAborted() {\n if (this.timer) {\n this.clear(this.timer);\n this.timer = null;\n }\n }\n}\n\nexport default Timer;\n","import Timer from './abstract_timer';\nimport TimedCallback from './timed_callback';\nimport { Delay } from './scheduling';\n\n// We need to bind clear functions this way to avoid exceptions on IE8\nfunction clearTimeout(timer) {\n global.clearTimeout(timer);\n}\nfunction clearInterval(timer) {\n global.clearInterval(timer);\n}\n\n/** Cross-browser compatible one-off timer abstraction.\n *\n * @param {Number} delay\n * @param {Function} callback\n */\nexport class OneOffTimer extends Timer {\n constructor(delay: Delay, callback: TimedCallback) {\n super(setTimeout, clearTimeout, delay, function(timer) {\n callback();\n return null;\n });\n }\n}\n\n/** Cross-browser compatible periodic timer abstraction.\n *\n * @param {Number} delay\n * @param {Function} callback\n */\nexport class PeriodicTimer extends Timer {\n constructor(delay: Delay, callback: TimedCallback) {\n super(setInterval, clearInterval, delay, function(timer) {\n callback();\n return timer;\n });\n }\n}\n","import * as Collections from './utils/collections';\nimport TimedCallback from './utils/timers/timed_callback';\nimport { OneOffTimer, PeriodicTimer } from './utils/timers';\n\nvar Util = {\n now(): number {\n if (Date.now) {\n return Date.now();\n } else {\n return new Date().valueOf();\n }\n },\n\n defer(callback: TimedCallback): OneOffTimer {\n return new OneOffTimer(0, callback);\n },\n\n /** Builds a function that will proxy a method call to its first argument.\n *\n * Allows partial application of arguments, so additional arguments are\n * prepended to the argument list.\n *\n * @param {String} name method name\n * @return {Function} proxy function\n */\n method(name: string, ...args: any[]): Function {\n var boundArguments = Array.prototype.slice.call(arguments, 1);\n return function(object) {\n return object[name].apply(object, boundArguments.concat(arguments));\n };\n }\n};\n\nexport default Util;\n","import base64encode from '../base64';\nimport Util from '../util';\n\n/** Merges multiple objects into the target argument.\n *\n * For properties that are plain Objects, performs a deep-merge. For the\n * rest it just copies the value of the property.\n *\n * To extend prototypes use it as following:\n * Pusher.Util.extend(Target.prototype, Base.prototype)\n *\n * You can also use it to merge objects without altering them:\n * Pusher.Util.extend({}, object1, object2)\n *\n * @param {Object} target\n * @return {Object} the target argument\n */\nexport function extend(target: any, ...sources: any[]): T {\n for (var i = 0; i < sources.length; i++) {\n var extensions = sources[i];\n for (var property in extensions) {\n if (\n extensions[property] &&\n extensions[property].constructor &&\n extensions[property].constructor === Object\n ) {\n target[property] = extend(target[property] || {}, extensions[property]);\n } else {\n target[property] = extensions[property];\n }\n }\n }\n return target;\n}\n\nexport function stringify(): string {\n var m = ['Pusher'];\n for (var i = 0; i < arguments.length; i++) {\n if (typeof arguments[i] === 'string') {\n m.push(arguments[i]);\n } else {\n m.push(safeJSONStringify(arguments[i]));\n }\n }\n return m.join(' : ');\n}\n\nexport function arrayIndexOf(array: any[], item: any): number {\n // MSIE doesn't have array.indexOf\n var nativeIndexOf = Array.prototype.indexOf;\n if (array === null) {\n return -1;\n }\n if (nativeIndexOf && array.indexOf === nativeIndexOf) {\n return array.indexOf(item);\n }\n for (var i = 0, l = array.length; i < l; i++) {\n if (array[i] === item) {\n return i;\n }\n }\n return -1;\n}\n\n/** Applies a function f to all properties of an object.\n *\n * Function f gets 3 arguments passed:\n * - element from the object\n * - key of the element\n * - reference to the object\n *\n * @param {Object} object\n * @param {Function} f\n */\nexport function objectApply(object: any, f: Function) {\n for (var key in object) {\n if (Object.prototype.hasOwnProperty.call(object, key)) {\n f(object[key], key, object);\n }\n }\n}\n\n/** Return a list of objects own proerty keys\n *\n * @param {Object} object\n * @returns {Array}\n */\nexport function keys(object: any): string[] {\n var keys = [];\n objectApply(object, function(_, key) {\n keys.push(key);\n });\n return keys;\n}\n\n/** Return a list of object's own property values\n *\n * @param {Object} object\n * @returns {Array}\n */\nexport function values(object: any): any[] {\n var values = [];\n objectApply(object, function(value) {\n values.push(value);\n });\n return values;\n}\n\n/** Applies a function f to all elements of an array.\n *\n * Function f gets 3 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function apply(array: any[], f: Function, context?: any) {\n for (var i = 0; i < array.length; i++) {\n f.call(context || global, array[i], i, array);\n }\n}\n\n/** Maps all elements of the array and returns the result.\n *\n * Function f gets 4 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n * - reference to the destination array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function map(array: any[], f: Function): any[] {\n var result = [];\n for (var i = 0; i < array.length; i++) {\n result.push(f(array[i], i, array, result));\n }\n return result;\n}\n\n/** Maps all elements of the object and returns the result.\n *\n * Function f gets 4 arguments passed:\n * - element from the object\n * - key of the element\n * - reference to the source object\n * - reference to the destination object\n *\n * @param {Object} object\n * @param {Function} f\n */\nexport function mapObject(object: any, f: Function): any {\n var result = {};\n objectApply(object, function(value, key) {\n result[key] = f(value);\n });\n return result;\n}\n\n/** Filters elements of the array using a test function.\n *\n * Function test gets 4 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n * - reference to the destination array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function filter(array: any[], test: Function): any[] {\n test =\n test ||\n function(value) {\n return !!value;\n };\n\n var result = [];\n for (var i = 0; i < array.length; i++) {\n if (test(array[i], i, array, result)) {\n result.push(array[i]);\n }\n }\n return result;\n}\n\n/** Filters properties of the object using a test function.\n *\n * Function test gets 4 arguments passed:\n * - element from the object\n * - key of the element\n * - reference to the source object\n * - reference to the destination object\n *\n * @param {Object} object\n * @param {Function} f\n */\nexport function filterObject(object: Object, test: Function) {\n var result = {};\n objectApply(object, function(value, key) {\n if ((test && test(value, key, object, result)) || Boolean(value)) {\n result[key] = value;\n }\n });\n return result;\n}\n\n/** Flattens an object into a two-dimensional array.\n *\n * @param {Object} object\n * @return {Array} resulting array of [key, value] pairs\n */\nexport function flatten(object: Object): any[] {\n var result = [];\n objectApply(object, function(value, key) {\n result.push([key, value]);\n });\n return result;\n}\n\n/** Checks whether any element of the array passes the test.\n *\n * Function test gets 3 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function any(array: any[], test: Function): boolean {\n for (var i = 0; i < array.length; i++) {\n if (test(array[i], i, array)) {\n return true;\n }\n }\n return false;\n}\n\n/** Checks whether all elements of the array pass the test.\n *\n * Function test gets 3 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function all(array: any[], test: Function): boolean {\n for (var i = 0; i < array.length; i++) {\n if (!test(array[i], i, array)) {\n return false;\n }\n }\n return true;\n}\n\nexport function encodeParamsObject(data): string {\n return mapObject(data, function(value) {\n if (typeof value === 'object') {\n value = safeJSONStringify(value);\n }\n return encodeURIComponent(base64encode(value.toString()));\n });\n}\n\nexport function buildQueryString(data: any): string {\n var params = filterObject(data, function(value) {\n return value !== undefined;\n });\n\n var query = map(\n flatten(encodeParamsObject(params)),\n Util.method('join', '=')\n ).join('&');\n\n return query;\n}\n\n/**\n * See https://github.com/douglascrockford/JSON-js/blob/master/cycle.js\n *\n * Remove circular references from an object. Required for JSON.stringify in\n * React Native, which tends to blow up a lot.\n *\n * @param {any} object\n * @return {any} Decycled object\n */\nexport function decycleObject(object: any): any {\n var objects = [],\n paths = [];\n\n return (function derez(value, path) {\n var i, name, nu;\n\n switch (typeof value) {\n case 'object':\n if (!value) {\n return null;\n }\n for (i = 0; i < objects.length; i += 1) {\n if (objects[i] === value) {\n return { $ref: paths[i] };\n }\n }\n\n objects.push(value);\n paths.push(path);\n\n if (Object.prototype.toString.apply(value) === '[object Array]') {\n nu = [];\n for (i = 0; i < value.length; i += 1) {\n nu[i] = derez(value[i], path + '[' + i + ']');\n }\n } else {\n nu = {};\n for (name in value) {\n if (Object.prototype.hasOwnProperty.call(value, name)) {\n nu[name] = derez(\n value[name],\n path + '[' + JSON.stringify(name) + ']'\n );\n }\n }\n }\n return nu;\n case 'number':\n case 'string':\n case 'boolean':\n return value;\n }\n })(object, '$');\n}\n\n/**\n * Provides a cross-browser and cross-platform way to safely stringify objects\n * into JSON. This is particularly necessary for ReactNative, where circular JSON\n * structures throw an exception.\n *\n * @param {any} source The object to stringify\n * @return {string} The serialized output.\n */\nexport function safeJSONStringify(source: any): string {\n try {\n return JSON.stringify(source);\n } catch (e) {\n return JSON.stringify(decycleObject(source));\n }\n}\n","import {\n ChannelAuthorizationOptions,\n UserAuthenticationOptions\n} from './auth/options';\nimport { AuthTransport } from './config';\n\nexport interface DefaultConfig {\n VERSION: string;\n PROTOCOL: number;\n wsPort: number;\n wssPort: number;\n wsPath: string;\n httpHost: string;\n httpPort: number;\n httpsPort: number;\n httpPath: string;\n stats_host: string;\n authEndpoint: string;\n authTransport: AuthTransport;\n activityTimeout: number;\n pongTimeout: number;\n unavailableTimeout: number;\n userAuthentication: UserAuthenticationOptions;\n channelAuthorization: ChannelAuthorizationOptions;\n\n cdn_http?: string;\n cdn_https?: string;\n dependency_suffix?: string;\n}\n\nvar Defaults: DefaultConfig = {\n VERSION: VERSION,\n PROTOCOL: 7,\n\n wsPort: 80,\n wssPort: 443,\n wsPath: '',\n // DEPRECATED: SockJS fallback parameters\n httpHost: 'sockjs.pusher.com',\n httpPort: 80,\n httpsPort: 443,\n httpPath: '/pusher',\n // DEPRECATED: Stats\n stats_host: 'stats.pusher.com',\n // DEPRECATED: Other settings\n authEndpoint: '/pusher/auth',\n authTransport: 'ajax',\n activityTimeout: 120000,\n pongTimeout: 30000,\n unavailableTimeout: 10000,\n userAuthentication: {\n endpoint: '/pusher/user-auth',\n transport: 'ajax'\n },\n channelAuthorization: {\n endpoint: '/pusher/auth',\n transport: 'ajax'\n },\n\n // CDN configuration\n cdn_http: CDN_HTTP,\n cdn_https: CDN_HTTPS,\n dependency_suffix: DEPENDENCY_SUFFIX\n};\n\nexport default Defaults;\n","import Defaults from '../defaults';\nimport { default as URLScheme, URLSchemeParams } from './url_scheme';\n\nfunction getGenericURL(\n baseScheme: string,\n params: URLSchemeParams,\n path: string\n): string {\n var scheme = baseScheme + (params.useTLS ? 's' : '');\n var host = params.useTLS ? params.hostTLS : params.hostNonTLS;\n return scheme + '://' + host + path;\n}\n\nfunction getGenericPath(key: string, queryString?: string): string {\n var path = '/app/' + key;\n var query =\n '?protocol=' +\n Defaults.PROTOCOL +\n '&client=js' +\n '&version=' +\n Defaults.VERSION +\n (queryString ? '&' + queryString : '');\n return path + query;\n}\n\nexport var ws: URLScheme = {\n getInitial: function(key: string, params: URLSchemeParams): string {\n var path = (params.httpPath || '') + getGenericPath(key, 'flash=false');\n return getGenericURL('ws', params, path);\n }\n};\n\nexport var http: URLScheme = {\n getInitial: function(key: string, params: URLSchemeParams): string {\n var path = (params.httpPath || '/pusher') + getGenericPath(key);\n return getGenericURL('http', params, path);\n }\n};\n\nexport var sockjs: URLScheme = {\n getInitial: function(key: string, params: URLSchemeParams): string {\n return getGenericURL('http', params, params.httpPath || '/pusher');\n },\n getPath: function(key: string, params: URLSchemeParams): string {\n return getGenericPath(key);\n }\n};\n","import Callback from './callback';\nimport * as Collections from '../utils/collections';\nimport CallbackTable from './callback_table';\n\nexport default class CallbackRegistry {\n _callbacks: CallbackTable;\n\n constructor() {\n this._callbacks = {};\n }\n\n get(name: string): Callback[] {\n return this._callbacks[prefix(name)];\n }\n\n add(name: string, callback: Function, context: any) {\n var prefixedEventName = prefix(name);\n this._callbacks[prefixedEventName] =\n this._callbacks[prefixedEventName] || [];\n this._callbacks[prefixedEventName].push({\n fn: callback,\n context: context\n });\n }\n\n remove(name?: string, callback?: Function, context?: any) {\n if (!name && !callback && !context) {\n this._callbacks = {};\n return;\n }\n\n var names = name ? [prefix(name)] : Collections.keys(this._callbacks);\n\n if (callback || context) {\n this.removeCallback(names, callback, context);\n } else {\n this.removeAllCallbacks(names);\n }\n }\n\n private removeCallback(names: string[], callback: Function, context: any) {\n Collections.apply(\n names,\n function(name) {\n this._callbacks[name] = Collections.filter(\n this._callbacks[name] || [],\n function(binding) {\n return (\n (callback && callback !== binding.fn) ||\n (context && context !== binding.context)\n );\n }\n );\n if (this._callbacks[name].length === 0) {\n delete this._callbacks[name];\n }\n },\n this\n );\n }\n\n private removeAllCallbacks(names: string[]) {\n Collections.apply(\n names,\n function(name) {\n delete this._callbacks[name];\n },\n this\n );\n }\n}\n\nfunction prefix(name: string): string {\n return '_' + name;\n}\n","import * as Collections from '../utils/collections';\nimport Callback from './callback';\nimport Metadata from '../channels/metadata';\nimport CallbackRegistry from './callback_registry';\n\n/** Manages callback bindings and event emitting.\n *\n * @param Function failThrough called when no listeners are bound to an event\n */\nexport default class Dispatcher {\n callbacks: CallbackRegistry;\n global_callbacks: Function[];\n failThrough: Function;\n\n constructor(failThrough?: Function) {\n this.callbacks = new CallbackRegistry();\n this.global_callbacks = [];\n this.failThrough = failThrough;\n }\n\n bind(eventName: string, callback: Function, context?: any) {\n this.callbacks.add(eventName, callback, context);\n return this;\n }\n\n bind_global(callback: Function) {\n this.global_callbacks.push(callback);\n return this;\n }\n\n unbind(eventName?: string, callback?: Function, context?: any) {\n this.callbacks.remove(eventName, callback, context);\n return this;\n }\n\n unbind_global(callback?: Function) {\n if (!callback) {\n this.global_callbacks = [];\n return this;\n }\n\n this.global_callbacks = Collections.filter(\n this.global_callbacks || [],\n c => c !== callback\n );\n\n return this;\n }\n\n unbind_all() {\n this.unbind();\n this.unbind_global();\n return this;\n }\n\n emit(eventName: string, data?: any, metadata?: Metadata): Dispatcher {\n for (var i = 0; i < this.global_callbacks.length; i++) {\n this.global_callbacks[i](eventName, data);\n }\n\n var callbacks = this.callbacks.get(eventName);\n var args = [];\n\n if (metadata) {\n // if there's a metadata argument, we need to call the callback with both\n // data and metadata regardless of whether data is undefined\n args.push(data, metadata);\n } else if (data) {\n // metadata is undefined, so we only need to call the callback with data\n // if data exists\n args.push(data);\n }\n\n if (callbacks && callbacks.length > 0) {\n for (var i = 0; i < callbacks.length; i++) {\n callbacks[i].fn.apply(callbacks[i].context || global, args);\n }\n } else if (this.failThrough) {\n this.failThrough(eventName, data);\n }\n\n return this;\n }\n}\n","import { stringify } from './utils/collections';\nimport Pusher from './pusher';\n\nclass Logger {\n debug(...args: any[]) {\n this.log(this.globalLog, args);\n }\n\n warn(...args: any[]) {\n this.log(this.globalLogWarn, args);\n }\n\n error(...args: any[]) {\n this.log(this.globalLogError, args);\n }\n\n private globalLog = (message: string) => {\n if (global.console && global.console.log) {\n global.console.log(message);\n }\n };\n\n private globalLogWarn(message: string) {\n if (global.console && global.console.warn) {\n global.console.warn(message);\n } else {\n this.globalLog(message);\n }\n }\n\n private globalLogError(message: string) {\n if (global.console && global.console.error) {\n global.console.error(message);\n } else {\n this.globalLogWarn(message);\n }\n }\n\n private log(\n defaultLoggingFunction: (message: string) => void,\n ...args: any[]\n ) {\n var message = stringify.apply(this, arguments);\n if (Pusher.log) {\n Pusher.log(message);\n } else if (Pusher.logToConsole) {\n const log = defaultLoggingFunction.bind(this);\n log(message);\n }\n }\n}\n\nexport default new Logger();\n","import Util from '../util';\nimport * as Collections from '../utils/collections';\nimport { default as EventsDispatcher } from '../events/dispatcher';\nimport Logger from '../logger';\nimport TransportHooks from './transport_hooks';\nimport Socket from '../socket';\nimport Runtime from 'runtime';\nimport Timeline from '../timeline/timeline';\nimport TransportConnectionOptions from './transport_connection_options';\n\n/** Provides universal API for transport connections.\n *\n * Transport connection is a low-level object that wraps a connection method\n * and exposes a simple evented interface for the connection state and\n * messaging. It does not implement Pusher-specific WebSocket protocol.\n *\n * Additionally, it fetches resources needed for transport to work and exposes\n * an interface for querying transport features.\n *\n * States:\n * - new - initial state after constructing the object\n * - initializing - during initialization phase, usually fetching resources\n * - intialized - ready to establish a connection\n * - connection - when connection is being established\n * - open - when connection ready to be used\n * - closed - after connection was closed be either side\n *\n * Emits:\n * - error - after the connection raised an error\n *\n * Options:\n * - useTLS - whether connection should be over TLS\n * - hostTLS - host to connect to when connection is over TLS\n * - hostNonTLS - host to connect to when connection is over TLS\n *\n * @param {String} key application key\n * @param {Object} options\n */\nexport default class TransportConnection extends EventsDispatcher {\n hooks: TransportHooks;\n name: string;\n priority: number;\n key: string;\n options: TransportConnectionOptions;\n state: string;\n timeline: Timeline;\n activityTimeout: number;\n id: number;\n socket: Socket;\n beforeOpen: Function;\n initialize: Function;\n\n constructor(\n hooks: TransportHooks,\n name: string,\n priority: number,\n key: string,\n options: TransportConnectionOptions\n ) {\n super();\n this.initialize = Runtime.transportConnectionInitializer;\n this.hooks = hooks;\n this.name = name;\n this.priority = priority;\n this.key = key;\n this.options = options;\n\n this.state = 'new';\n this.timeline = options.timeline;\n this.activityTimeout = options.activityTimeout;\n this.id = this.timeline.generateUniqueID();\n }\n\n /** Checks whether the transport handles activity checks by itself.\n *\n * @return {Boolean}\n */\n handlesActivityChecks(): boolean {\n return Boolean(this.hooks.handlesActivityChecks);\n }\n\n /** Checks whether the transport supports the ping/pong API.\n *\n * @return {Boolean}\n */\n supportsPing(): boolean {\n return Boolean(this.hooks.supportsPing);\n }\n\n /** Tries to establish a connection.\n *\n * @returns {Boolean} false if transport is in invalid state\n */\n connect(): boolean {\n if (this.socket || this.state !== 'initialized') {\n return false;\n }\n\n var url = this.hooks.urls.getInitial(this.key, this.options);\n try {\n this.socket = this.hooks.getSocket(url, this.options);\n } catch (e) {\n Util.defer(() => {\n this.onError(e);\n this.changeState('closed');\n });\n return false;\n }\n\n this.bindListeners();\n\n Logger.debug('Connecting', { transport: this.name, url });\n this.changeState('connecting');\n return true;\n }\n\n /** Closes the connection.\n *\n * @return {Boolean} true if there was a connection to close\n */\n close(): boolean {\n if (this.socket) {\n this.socket.close();\n return true;\n } else {\n return false;\n }\n }\n\n /** Sends data over the open connection.\n *\n * @param {String} data\n * @return {Boolean} true only when in the \"open\" state\n */\n send(data: any): boolean {\n if (this.state === 'open') {\n // Workaround for MobileSafari bug (see https://gist.github.com/2052006)\n Util.defer(() => {\n if (this.socket) {\n this.socket.send(data);\n }\n });\n return true;\n } else {\n return false;\n }\n }\n\n /** Sends a ping if the connection is open and transport supports it. */\n ping() {\n if (this.state === 'open' && this.supportsPing()) {\n this.socket.ping();\n }\n }\n\n private onOpen() {\n if (this.hooks.beforeOpen) {\n this.hooks.beforeOpen(\n this.socket,\n this.hooks.urls.getPath(this.key, this.options)\n );\n }\n this.changeState('open');\n this.socket.onopen = undefined;\n }\n\n private onError(error) {\n this.emit('error', { type: 'WebSocketError', error: error });\n this.timeline.error(this.buildTimelineMessage({ error: error.toString() }));\n }\n\n private onClose(closeEvent?: any) {\n if (closeEvent) {\n this.changeState('closed', {\n code: closeEvent.code,\n reason: closeEvent.reason,\n wasClean: closeEvent.wasClean\n });\n } else {\n this.changeState('closed');\n }\n this.unbindListeners();\n this.socket = undefined;\n }\n\n private onMessage(message) {\n this.emit('message', message);\n }\n\n private onActivity() {\n this.emit('activity');\n }\n\n private bindListeners() {\n this.socket.onopen = () => {\n this.onOpen();\n };\n this.socket.onerror = error => {\n this.onError(error);\n };\n this.socket.onclose = closeEvent => {\n this.onClose(closeEvent);\n };\n this.socket.onmessage = message => {\n this.onMessage(message);\n };\n\n if (this.supportsPing()) {\n this.socket.onactivity = () => {\n this.onActivity();\n };\n }\n }\n\n private unbindListeners() {\n if (this.socket) {\n this.socket.onopen = undefined;\n this.socket.onerror = undefined;\n this.socket.onclose = undefined;\n this.socket.onmessage = undefined;\n if (this.supportsPing()) {\n this.socket.onactivity = undefined;\n }\n }\n }\n\n private changeState(state: string, params?: any) {\n this.state = state;\n this.timeline.info(\n this.buildTimelineMessage({\n state: state,\n params: params\n })\n );\n this.emit(state, params);\n }\n\n buildTimelineMessage(message): any {\n return Collections.extend({ cid: this.id }, message);\n }\n}\n","import Factory from '../utils/factory';\nimport TransportHooks from './transport_hooks';\nimport TransportConnection from './transport_connection';\nimport TransportConnectionOptions from './transport_connection_options';\n\n/** Provides interface for transport connection instantiation.\n *\n * Takes transport-specific hooks as the only argument, which allow checking\n * for transport support and creating its connections.\n *\n * Supported hooks: * - file - the name of the file to be fetched during initialization\n * - urls - URL scheme to be used by transport\n * - handlesActivityCheck - true when the transport handles activity checks\n * - supportsPing - true when the transport has a ping/activity API\n * - isSupported - tells whether the transport is supported in the environment\n * - getSocket - creates a WebSocket-compatible transport socket\n *\n * See transports.js for specific implementations.\n *\n * @param {Object} hooks object containing all needed transport hooks\n */\nexport default class Transport {\n hooks: TransportHooks;\n\n constructor(hooks: TransportHooks) {\n this.hooks = hooks;\n }\n\n /** Returns whether the transport is supported in the environment.\n *\n * @param {Object} envronment te environment details (encryption, settings)\n * @returns {Boolean} true when the transport is supported\n */\n isSupported(environment: any): boolean {\n return this.hooks.isSupported(environment);\n }\n\n /** Creates a transport connection.\n *\n * @param {String} name\n * @param {Number} priority\n * @param {String} key the application key\n * @param {Object} options\n * @returns {TransportConnection}\n */\n createConnection(\n name: string,\n priority: number,\n key: string,\n options: any\n ): TransportConnection {\n return new TransportConnection(this.hooks, name, priority, key, options);\n }\n}\n","import * as URLSchemes from 'core/transports/url_schemes';\nimport URLScheme from 'core/transports/url_scheme';\nimport Transport from 'core/transports/transport';\nimport Util from 'core/util';\nimport * as Collections from 'core/utils/collections';\nimport TransportHooks from 'core/transports/transport_hooks';\nimport TransportsTable from 'core/transports/transports_table';\nimport Runtime from 'runtime';\n\n/** WebSocket transport.\n *\n * Uses native WebSocket implementation, including MozWebSocket supported by\n * earlier Firefox versions.\n */\nvar WSTransport = new Transport({\n urls: URLSchemes.ws,\n handlesActivityChecks: false,\n supportsPing: false,\n\n isInitialized: function() {\n return Boolean(Runtime.getWebSocketAPI());\n },\n isSupported: function(): boolean {\n return Boolean(Runtime.getWebSocketAPI());\n },\n getSocket: function(url) {\n return Runtime.createWebSocket(url);\n }\n});\n\nvar httpConfiguration = {\n urls: URLSchemes.http,\n handlesActivityChecks: false,\n supportsPing: true,\n isInitialized: function() {\n return true;\n }\n};\n\nexport var streamingConfiguration = Collections.extend(\n {\n getSocket: function(url) {\n return Runtime.HTTPFactory.createStreamingSocket(url);\n }\n },\n httpConfiguration\n);\nexport var pollingConfiguration = Collections.extend(\n {\n getSocket: function(url) {\n return Runtime.HTTPFactory.createPollingSocket(url);\n }\n },\n httpConfiguration\n);\n\nvar xhrConfiguration = {\n isSupported: function(): boolean {\n return Runtime.isXHRSupported();\n }\n};\n\n/** HTTP streaming transport using CORS-enabled XMLHttpRequest. */\nvar XHRStreamingTransport = new Transport(\n (\n Collections.extend({}, streamingConfiguration, xhrConfiguration)\n )\n);\n\n/** HTTP long-polling transport using CORS-enabled XMLHttpRequest. */\nvar XHRPollingTransport = new Transport(\n Collections.extend({}, pollingConfiguration, xhrConfiguration)\n);\n\nvar Transports: TransportsTable = {\n ws: WSTransport,\n xhr_streaming: XHRStreamingTransport,\n xhr_polling: XHRPollingTransport\n};\n\nexport default Transports;\n","import Util from '../util';\nimport * as Collections from '../utils/collections';\nimport TransportManager from './transport_manager';\nimport TransportConnection from './transport_connection';\nimport Transport from './transport';\nimport PingDelayOptions from './ping_delay_options';\n\n/** Creates transport connections monitored by a transport manager.\n *\n * When a transport is closed, it might mean the environment does not support\n * it. It's possible that messages get stuck in an intermediate buffer or\n * proxies terminate inactive connections. To combat these problems,\n * assistants monitor the connection lifetime, report unclean exits and\n * adjust ping timeouts to keep the connection active. The decision to disable\n * a transport is the manager's responsibility.\n *\n * @param {TransportManager} manager\n * @param {TransportConnection} transport\n * @param {Object} options\n */\nexport default class AssistantToTheTransportManager {\n manager: TransportManager;\n transport: Transport;\n minPingDelay: number;\n maxPingDelay: number;\n pingDelay: number;\n\n constructor(\n manager: TransportManager,\n transport: Transport,\n options: PingDelayOptions\n ) {\n this.manager = manager;\n this.transport = transport;\n this.minPingDelay = options.minPingDelay;\n this.maxPingDelay = options.maxPingDelay;\n this.pingDelay = undefined;\n }\n\n /** Creates a transport connection.\n *\n * This function has the same API as Transport#createConnection.\n *\n * @param {String} name\n * @param {Number} priority\n * @param {String} key the application key\n * @param {Object} options\n * @returns {TransportConnection}\n */\n createConnection(\n name: string,\n priority: number,\n key: string,\n options: Object\n ): TransportConnection {\n options = Collections.extend({}, options, {\n activityTimeout: this.pingDelay\n });\n var connection = this.transport.createConnection(\n name,\n priority,\n key,\n options\n );\n\n var openTimestamp = null;\n\n var onOpen = function() {\n connection.unbind('open', onOpen);\n connection.bind('closed', onClosed);\n openTimestamp = Util.now();\n };\n var onClosed = closeEvent => {\n connection.unbind('closed', onClosed);\n\n if (closeEvent.code === 1002 || closeEvent.code === 1003) {\n // we don't want to use transports not obeying the protocol\n this.manager.reportDeath();\n } else if (!closeEvent.wasClean && openTimestamp) {\n // report deaths only for short-living transport\n var lifespan = Util.now() - openTimestamp;\n if (lifespan < 2 * this.maxPingDelay) {\n this.manager.reportDeath();\n this.pingDelay = Math.max(lifespan / 2, this.minPingDelay);\n }\n }\n };\n\n connection.bind('open', onOpen);\n return connection;\n }\n\n /** Returns whether the transport is supported in the environment.\n *\n * This function has the same API as Transport#isSupported. Might return false\n * when the manager decides to kill the transport.\n *\n * @param {Object} environment the environment details (encryption, settings)\n * @returns {Boolean} true when the transport is supported\n */\n isSupported(environment: string): boolean {\n return this.manager.isAlive() && this.transport.isSupported(environment);\n }\n}\n","import Action from './action';\nimport { PusherEvent } from './message-types';\n/**\n * Provides functions for handling Pusher protocol-specific messages.\n */\n\nconst Protocol = {\n /**\n * Decodes a message in a Pusher format.\n *\n * The MessageEvent we receive from the transport should contain a pusher event\n * (https://pusher.com/docs/pusher_protocol#events) serialized as JSON in the\n * data field\n *\n * The pusher event may contain a data field too, and it may also be\n * serialised as JSON\n *\n * Throws errors when messages are not parse'able.\n *\n * @param {MessageEvent} messageEvent\n * @return {PusherEvent}\n */\n decodeMessage: function(messageEvent: MessageEvent): PusherEvent {\n try {\n var messageData = JSON.parse(messageEvent.data);\n var pusherEventData = messageData.data;\n if (typeof pusherEventData === 'string') {\n try {\n pusherEventData = JSON.parse(messageData.data);\n } catch (e) {}\n }\n var pusherEvent: PusherEvent = {\n event: messageData.event,\n channel: messageData.channel,\n data: pusherEventData\n };\n if (messageData.user_id) {\n pusherEvent.user_id = messageData.user_id;\n }\n return pusherEvent;\n } catch (e) {\n throw { type: 'MessageParseError', error: e, data: messageEvent.data };\n }\n },\n\n /**\n * Encodes a message to be sent.\n *\n * @param {PusherEvent} event\n * @return {String}\n */\n encodeMessage: function(event: PusherEvent): string {\n return JSON.stringify(event);\n },\n\n /**\n * Processes a handshake message and returns appropriate actions.\n *\n * Returns an object with an 'action' and other action-specific properties.\n *\n * There are three outcomes when calling this function. First is a successful\n * connection attempt, when pusher:connection_established is received, which\n * results in a 'connected' action with an 'id' property. When passed a\n * pusher:error event, it returns a result with action appropriate to the\n * close code and an error. Otherwise, it raises an exception.\n *\n * @param {String} message\n * @result Object\n */\n processHandshake: function(messageEvent: MessageEvent): Action {\n var message = Protocol.decodeMessage(messageEvent);\n\n if (message.event === 'pusher:connection_established') {\n if (!message.data.activity_timeout) {\n throw 'No activity timeout specified in handshake';\n }\n return {\n action: 'connected',\n id: message.data.socket_id,\n activityTimeout: message.data.activity_timeout * 1000\n };\n } else if (message.event === 'pusher:error') {\n // From protocol 6 close codes are sent only once, so this only\n // happens when connection does not support close codes\n return {\n action: this.getCloseAction(message.data),\n error: this.getCloseError(message.data)\n };\n } else {\n throw 'Invalid handshake';\n }\n },\n\n /**\n * Dispatches the close event and returns an appropriate action name.\n *\n * See:\n * 1. https://developer.mozilla.org/en-US/docs/WebSockets/WebSockets_reference/CloseEvent\n * 2. http://pusher.com/docs/pusher_protocol\n *\n * @param {CloseEvent} closeEvent\n * @return {String} close action name\n */\n getCloseAction: function(closeEvent): string {\n if (closeEvent.code < 4000) {\n // ignore 1000 CLOSE_NORMAL, 1001 CLOSE_GOING_AWAY,\n // 1005 CLOSE_NO_STATUS, 1006 CLOSE_ABNORMAL\n // ignore 1007...3999\n // handle 1002 CLOSE_PROTOCOL_ERROR, 1003 CLOSE_UNSUPPORTED,\n // 1004 CLOSE_TOO_LARGE\n if (closeEvent.code >= 1002 && closeEvent.code <= 1004) {\n return 'backoff';\n } else {\n return null;\n }\n } else if (closeEvent.code === 4000) {\n return 'tls_only';\n } else if (closeEvent.code < 4100) {\n return 'refused';\n } else if (closeEvent.code < 4200) {\n return 'backoff';\n } else if (closeEvent.code < 4300) {\n return 'retry';\n } else {\n // unknown error\n return 'refused';\n }\n },\n\n /**\n * Returns an error or null basing on the close event.\n *\n * Null is returned when connection was closed cleanly. Otherwise, an object\n * with error details is returned.\n *\n * @param {CloseEvent} closeEvent\n * @return {Object} error object\n */\n getCloseError: function(closeEvent): any {\n if (closeEvent.code !== 1000 && closeEvent.code !== 1001) {\n return {\n type: 'PusherError',\n data: {\n code: closeEvent.code,\n message: closeEvent.reason || closeEvent.message\n }\n };\n } else {\n return null;\n }\n }\n};\n\nexport default Protocol;\n","import * as Collections from '../utils/collections';\nimport { default as EventsDispatcher } from '../events/dispatcher';\nimport Protocol from './protocol/protocol';\nimport { PusherEvent } from './protocol/message-types';\nimport Logger from '../logger';\nimport TransportConnection from '../transports/transport_connection';\nimport Socket from '../socket';\n/**\n * Provides Pusher protocol interface for transports.\n *\n * Emits following events:\n * - message - on received messages\n * - ping - on ping requests\n * - pong - on pong responses\n * - error - when the transport emits an error\n * - closed - after closing the transport\n *\n * It also emits more events when connection closes with a code.\n * See Protocol.getCloseAction to get more details.\n *\n * @param {Number} id\n * @param {AbstractTransport} transport\n */\nexport default class Connection extends EventsDispatcher implements Socket {\n id: string;\n transport: TransportConnection;\n activityTimeout: number;\n\n constructor(id: string, transport: TransportConnection) {\n super();\n this.id = id;\n this.transport = transport;\n this.activityTimeout = transport.activityTimeout;\n this.bindListeners();\n }\n\n /** Returns whether used transport handles activity checks by itself\n *\n * @returns {Boolean} true if activity checks are handled by the transport\n */\n handlesActivityChecks() {\n return this.transport.handlesActivityChecks();\n }\n\n /** Sends raw data.\n *\n * @param {String} data\n */\n send(data: any): boolean {\n return this.transport.send(data);\n }\n\n /** Sends an event.\n *\n * @param {String} name\n * @param {String} data\n * @param {String} [channel]\n * @returns {Boolean} whether message was sent or not\n */\n send_event(name: string, data: any, channel?: string): boolean {\n var event: PusherEvent = { event: name, data: data };\n if (channel) {\n event.channel = channel;\n }\n Logger.debug('Event sent', event);\n return this.send(Protocol.encodeMessage(event));\n }\n\n /** Sends a ping message to the server.\n *\n * Basing on the underlying transport, it might send either transport's\n * protocol-specific ping or pusher:ping event.\n */\n ping() {\n if (this.transport.supportsPing()) {\n this.transport.ping();\n } else {\n this.send_event('pusher:ping', {});\n }\n }\n\n /** Closes the connection. */\n close() {\n this.transport.close();\n }\n\n private bindListeners() {\n var listeners = {\n message: (messageEvent: MessageEvent) => {\n var pusherEvent;\n try {\n pusherEvent = Protocol.decodeMessage(messageEvent);\n } catch (e) {\n this.emit('error', {\n type: 'MessageParseError',\n error: e,\n data: messageEvent.data\n });\n }\n\n if (pusherEvent !== undefined) {\n Logger.debug('Event recd', pusherEvent);\n\n switch (pusherEvent.event) {\n case 'pusher:error':\n this.emit('error', {\n type: 'PusherError',\n data: pusherEvent.data\n });\n break;\n case 'pusher:ping':\n this.emit('ping');\n break;\n case 'pusher:pong':\n this.emit('pong');\n break;\n }\n this.emit('message', pusherEvent);\n }\n },\n activity: () => {\n this.emit('activity');\n },\n error: error => {\n this.emit('error', error);\n },\n closed: closeEvent => {\n unbindListeners();\n\n if (closeEvent && closeEvent.code) {\n this.handleCloseEvent(closeEvent);\n }\n\n this.transport = null;\n this.emit('closed');\n }\n };\n\n var unbindListeners = () => {\n Collections.objectApply(listeners, (listener, event) => {\n this.transport.unbind(event, listener);\n });\n };\n\n Collections.objectApply(listeners, (listener, event) => {\n this.transport.bind(event, listener);\n });\n }\n\n private handleCloseEvent(closeEvent: any) {\n var action = Protocol.getCloseAction(closeEvent);\n var error = Protocol.getCloseError(closeEvent);\n if (error) {\n this.emit('error', error);\n }\n if (action) {\n this.emit(action, { action: action, error: error });\n }\n }\n}\n","import Util from '../../util';\nimport * as Collections from '../../utils/collections';\nimport Protocol from '../protocol/protocol';\nimport Connection from '../connection';\nimport TransportConnection from '../../transports/transport_connection';\nimport HandshakePayload from './handshake_payload';\n\n/**\n * Handles Pusher protocol handshakes for transports.\n *\n * Calls back with a result object after handshake is completed. Results\n * always have two fields:\n * - action - string describing action to be taken after the handshake\n * - transport - the transport object passed to the constructor\n *\n * Different actions can set different additional properties on the result.\n * In the case of 'connected' action, there will be a 'connection' property\n * containing a Connection object for the transport. Other actions should\n * carry an 'error' property.\n *\n * @param {AbstractTransport} transport\n * @param {Function} callback\n */\nexport default class Handshake {\n transport: TransportConnection;\n callback: (HandshakePayload) => void;\n onMessage: Function;\n onClosed: Function;\n\n constructor(\n transport: TransportConnection,\n callback: (HandshakePayload) => void\n ) {\n this.transport = transport;\n this.callback = callback;\n this.bindListeners();\n }\n\n close() {\n this.unbindListeners();\n this.transport.close();\n }\n\n private bindListeners() {\n this.onMessage = m => {\n this.unbindListeners();\n\n var result;\n try {\n result = Protocol.processHandshake(m);\n } catch (e) {\n this.finish('error', { error: e });\n this.transport.close();\n return;\n }\n\n if (result.action === 'connected') {\n this.finish('connected', {\n connection: new Connection(result.id, this.transport),\n activityTimeout: result.activityTimeout\n });\n } else {\n this.finish(result.action, { error: result.error });\n this.transport.close();\n }\n };\n\n this.onClosed = closeEvent => {\n this.unbindListeners();\n\n var action = Protocol.getCloseAction(closeEvent) || 'backoff';\n var error = Protocol.getCloseError(closeEvent);\n this.finish(action, { error: error });\n };\n\n this.transport.bind('message', this.onMessage);\n this.transport.bind('closed', this.onClosed);\n }\n\n private unbindListeners() {\n this.transport.unbind('message', this.onMessage);\n this.transport.unbind('closed', this.onClosed);\n }\n\n private finish(action: string, params: any) {\n this.callback(\n Collections.extend({ transport: this.transport, action: action }, params)\n );\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport base64encode from '../base64';\nimport Timeline from './timeline';\nimport Runtime from 'runtime';\n\nexport interface TimelineSenderOptions {\n host?: string;\n port?: number;\n path?: string;\n}\n\nexport default class TimelineSender {\n timeline: Timeline;\n options: TimelineSenderOptions;\n host: string;\n\n constructor(timeline: Timeline, options: TimelineSenderOptions) {\n this.timeline = timeline;\n this.options = options || {};\n }\n\n send(useTLS: boolean, callback?: Function) {\n if (this.timeline.isEmpty()) {\n return;\n }\n\n this.timeline.send(\n Runtime.TimelineTransport.getAgent(this, useTLS),\n callback\n );\n }\n}\n","/** Error classes used throughout the library. */\n// https://github.com/Microsoft/TypeScript-wiki/blob/master/Breaking-Changes.md#extending-built-ins-like-error-array-and-map-may-no-longer-work\nexport class BadEventName extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\nexport class BadChannelName extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\nexport class RequestTimedOut extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class TransportPriorityTooLow extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class TransportClosed extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class UnsupportedFeature extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class UnsupportedTransport extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class UnsupportedStrategy extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class HTTPAuthError extends Error {\n status: number;\n constructor(status: number, msg?: string) {\n super(msg);\n this.status = status;\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n","/**\n * A place to store help URLs for error messages etc\n */\n\nconst urlStore = {\n baseUrl: 'https://pusher.com',\n urls: {\n authenticationEndpoint: {\n path: '/docs/channels/server_api/authenticating_users'\n },\n authorizationEndpoint: {\n path: '/docs/channels/server_api/authorizing-users/'\n },\n javascriptQuickStart: {\n path: '/docs/javascript_quick_start'\n },\n triggeringClientEvents: {\n path: '/docs/client_api_guide/client_events#trigger-events'\n },\n encryptedChannelSupport: {\n fullUrl:\n 'https://github.com/pusher/pusher-js/tree/cc491015371a4bde5743d1c87a0fbac0feb53195#encrypted-channel-support'\n }\n }\n};\n\n/** Builds a consistent string with links to pusher documentation\n *\n * @param {string} key - relevant key in the url_store.urls object\n * @return {string} suffix string to append to log message\n */\nconst buildLogSuffix = function(key: string): string {\n const urlPrefix = 'See:';\n const urlObj = urlStore.urls[key];\n if (!urlObj) return '';\n\n let url;\n if (urlObj.fullUrl) {\n url = urlObj.fullUrl;\n } else if (urlObj.path) {\n url = urlStore.baseUrl + urlObj.path;\n }\n\n if (!url) return '';\n return `${urlPrefix} ${url}`;\n};\n\nexport default { buildLogSuffix };\n","import { default as EventsDispatcher } from '../events/dispatcher';\nimport * as Errors from '../errors';\nimport Logger from '../logger';\nimport Pusher from '../pusher';\nimport { PusherEvent } from '../connection/protocol/message-types';\nimport Metadata from './metadata';\nimport UrlStore from '../utils/url_store';\nimport {\n ChannelAuthorizationData,\n ChannelAuthorizationCallback\n} from '../auth/options';\nimport { HTTPAuthError } from '../errors';\n\n/** Provides base public channel interface with an event emitter.\n *\n * Emits:\n * - pusher:subscription_succeeded - after subscribing successfully\n * - other non-internal events\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\nexport default class Channel extends EventsDispatcher {\n name: string;\n pusher: Pusher;\n subscribed: boolean;\n subscriptionPending: boolean;\n subscriptionCancelled: boolean;\n subscriptionCount: null;\n\n constructor(name: string, pusher: Pusher) {\n super(function(event, data) {\n Logger.debug('No callbacks on ' + name + ' for ' + event);\n });\n\n this.name = name;\n this.pusher = pusher;\n this.subscribed = false;\n this.subscriptionPending = false;\n this.subscriptionCancelled = false;\n }\n\n /** Skips authorization, since public channels don't require it.\n *\n * @param {Function} callback\n */\n authorize(socketId: string, callback: ChannelAuthorizationCallback) {\n return callback(null, { auth: '' });\n }\n\n /** Triggers an event */\n trigger(event: string, data: any) {\n if (event.indexOf('client-') !== 0) {\n throw new Errors.BadEventName(\n \"Event '\" + event + \"' does not start with 'client-'\"\n );\n }\n if (!this.subscribed) {\n var suffix = UrlStore.buildLogSuffix('triggeringClientEvents');\n Logger.warn(\n `Client event triggered before channel 'subscription_succeeded' event . ${suffix}`\n );\n }\n return this.pusher.send_event(event, data, this.name);\n }\n\n /** Signals disconnection to the channel. For internal use only. */\n disconnect() {\n this.subscribed = false;\n this.subscriptionPending = false;\n }\n\n /** Handles a PusherEvent. For internal use only.\n *\n * @param {PusherEvent} event\n */\n handleEvent(event: PusherEvent) {\n var eventName = event.event;\n var data = event.data;\n if (eventName === 'pusher_internal:subscription_succeeded') {\n this.handleSubscriptionSucceededEvent(event);\n } else if (eventName === 'pusher_internal:subscription_count') {\n this.handleSubscriptionCountEvent(event);\n } else if (eventName.indexOf('pusher_internal:') !== 0) {\n var metadata: Metadata = {};\n this.emit(eventName, data, metadata);\n }\n }\n\n handleSubscriptionSucceededEvent(event: PusherEvent) {\n this.subscriptionPending = false;\n this.subscribed = true;\n if (this.subscriptionCancelled) {\n this.pusher.unsubscribe(this.name);\n } else {\n this.emit('pusher:subscription_succeeded', event.data);\n }\n }\n\n handleSubscriptionCountEvent(event: PusherEvent) {\n if (event.data.subscription_count) {\n this.subscriptionCount = event.data.subscription_count;\n }\n\n this.emit('pusher:subscription_count', event.data);\n }\n\n /** Sends a subscription request. For internal use only. */\n subscribe() {\n if (this.subscribed) {\n return;\n }\n this.subscriptionPending = true;\n this.subscriptionCancelled = false;\n this.authorize(\n this.pusher.connection.socket_id,\n (error: Error | null, data: ChannelAuthorizationData) => {\n if (error) {\n this.subscriptionPending = false;\n // Why not bind to 'pusher:subscription_error' a level up, and log there?\n // Binding to this event would cause the warning about no callbacks being\n // bound (see constructor) to be suppressed, that's not what we want.\n Logger.error(error.toString());\n this.emit(\n 'pusher:subscription_error',\n Object.assign(\n {},\n {\n type: 'AuthError',\n error: error.message\n },\n error instanceof HTTPAuthError ? { status: error.status } : {}\n )\n );\n } else {\n this.pusher.send_event('pusher:subscribe', {\n auth: data.auth,\n channel_data: data.channel_data,\n channel: this.name\n });\n }\n }\n );\n }\n\n /** Sends an unsubscription request. For internal use only. */\n unsubscribe() {\n this.subscribed = false;\n this.pusher.send_event('pusher:unsubscribe', {\n channel: this.name\n });\n }\n\n /** Cancels an in progress subscription. For internal use only. */\n cancelSubscription() {\n this.subscriptionCancelled = true;\n }\n\n /** Reinstates an in progress subscripiton. For internal use only. */\n reinstateSubscription() {\n this.subscriptionCancelled = false;\n }\n}\n","import Factory from '../utils/factory';\nimport Channel from './channel';\nimport { ChannelAuthorizationCallback } from '../auth/options';\n\n/** Extends public channels to provide private channel interface.\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\nexport default class PrivateChannel extends Channel {\n /** Authorizes the connection to use the channel.\n *\n * @param {String} socketId\n * @param {Function} callback\n */\n authorize(socketId: string, callback: ChannelAuthorizationCallback) {\n return this.pusher.config.channelAuthorizer(\n {\n channelName: this.name,\n socketId: socketId\n },\n callback\n );\n }\n}\n","import * as Collections from '../utils/collections';\n\n/** Represents a collection of members of a presence channel. */\nexport default class Members {\n members: any;\n count: number;\n myID: any;\n me: any;\n\n constructor() {\n this.reset();\n }\n\n /** Returns member's info for given id.\n *\n * Resulting object containts two fields - id and info.\n *\n * @param {Number} id\n * @return {Object} member's info or null\n */\n get(id: string): any {\n if (Object.prototype.hasOwnProperty.call(this.members, id)) {\n return {\n id: id,\n info: this.members[id]\n };\n } else {\n return null;\n }\n }\n\n /** Calls back for each member in unspecified order.\n *\n * @param {Function} callback\n */\n each(callback: Function) {\n Collections.objectApply(this.members, (member, id) => {\n callback(this.get(id));\n });\n }\n\n /** Updates the id for connected member. For internal use only. */\n setMyID(id: string) {\n this.myID = id;\n }\n\n /** Handles subscription data. For internal use only. */\n onSubscription(subscriptionData: any) {\n this.members = subscriptionData.presence.hash;\n this.count = subscriptionData.presence.count;\n this.me = this.get(this.myID);\n }\n\n /** Adds a new member to the collection. For internal use only. */\n addMember(memberData: any) {\n if (this.get(memberData.user_id) === null) {\n this.count++;\n }\n this.members[memberData.user_id] = memberData.user_info;\n return this.get(memberData.user_id);\n }\n\n /** Adds a member from the collection. For internal use only. */\n removeMember(memberData: any) {\n var member = this.get(memberData.user_id);\n if (member) {\n delete this.members[memberData.user_id];\n this.count--;\n }\n return member;\n }\n\n /** Resets the collection to the initial state. For internal use only. */\n reset() {\n this.members = {};\n this.count = 0;\n this.myID = null;\n this.me = null;\n }\n}\n","import PrivateChannel from './private_channel';\nimport Logger from '../logger';\nimport Members from './members';\nimport Pusher from '../pusher';\nimport UrlStore from 'core/utils/url_store';\nimport { PusherEvent } from '../connection/protocol/message-types';\nimport Metadata from './metadata';\nimport { ChannelAuthorizationData } from '../auth/options';\n\nexport default class PresenceChannel extends PrivateChannel {\n members: Members;\n\n /** Adds presence channel functionality to private channels.\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\n constructor(name: string, pusher: Pusher) {\n super(name, pusher);\n this.members = new Members();\n }\n\n /** Authorizes the connection as a member of the channel.\n *\n * @param {String} socketId\n * @param {Function} callback\n */\n authorize(socketId: string, callback: Function) {\n super.authorize(socketId, async (error, authData) => {\n if (!error) {\n authData = authData as ChannelAuthorizationData;\n if (authData.channel_data != null) {\n var channelData = JSON.parse(authData.channel_data);\n this.members.setMyID(channelData.user_id);\n } else {\n await this.pusher.user.signinDonePromise;\n if (this.pusher.user.user_data != null) {\n // If the user is signed in, get the id of the authenticated user\n // and allow the presence authorization to continue.\n this.members.setMyID(this.pusher.user.user_data.id);\n } else {\n let suffix = UrlStore.buildLogSuffix('authorizationEndpoint');\n Logger.error(\n `Invalid auth response for channel '${this.name}', ` +\n `expected 'channel_data' field. ${suffix}, ` +\n `or the user should be signed in.`\n );\n callback('Invalid auth response');\n return;\n }\n }\n }\n callback(error, authData);\n });\n }\n\n /** Handles presence and subscription events. For internal use only.\n *\n * @param {PusherEvent} event\n */\n handleEvent(event: PusherEvent) {\n var eventName = event.event;\n if (eventName.indexOf('pusher_internal:') === 0) {\n this.handleInternalEvent(event);\n } else {\n var data = event.data;\n var metadata: Metadata = {};\n if (event.user_id) {\n metadata.user_id = event.user_id;\n }\n this.emit(eventName, data, metadata);\n }\n }\n handleInternalEvent(event: PusherEvent) {\n var eventName = event.event;\n var data = event.data;\n switch (eventName) {\n case 'pusher_internal:subscription_succeeded':\n this.handleSubscriptionSucceededEvent(event);\n break;\n case 'pusher_internal:subscription_count':\n this.handleSubscriptionCountEvent(event);\n break;\n case 'pusher_internal:member_added':\n var addedMember = this.members.addMember(data);\n this.emit('pusher:member_added', addedMember);\n break;\n case 'pusher_internal:member_removed':\n var removedMember = this.members.removeMember(data);\n if (removedMember) {\n this.emit('pusher:member_removed', removedMember);\n }\n break;\n }\n }\n\n handleSubscriptionSucceededEvent(event: PusherEvent) {\n this.subscriptionPending = false;\n this.subscribed = true;\n if (this.subscriptionCancelled) {\n this.pusher.unsubscribe(this.name);\n } else {\n this.members.onSubscription(event.data);\n this.emit('pusher:subscription_succeeded', this.members);\n }\n }\n\n /** Resets the channel state, including members map. For internal use only. */\n disconnect() {\n this.members.reset();\n super.disconnect();\n }\n}\n","import PrivateChannel from './private_channel';\nimport * as Errors from '../errors';\nimport Logger from '../logger';\nimport Pusher from '../pusher';\nimport { decode as encodeUTF8 } from '@stablelib/utf8';\nimport { decode as decodeBase64 } from '@stablelib/base64';\nimport Dispatcher from '../events/dispatcher';\nimport { PusherEvent } from '../connection/protocol/message-types';\nimport {\n ChannelAuthorizationData,\n ChannelAuthorizationCallback\n} from '../auth/options';\nimport * as nacl from 'tweetnacl';\n\n/** Extends private channels to provide encrypted channel interface.\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\nexport default class EncryptedChannel extends PrivateChannel {\n key: Uint8Array = null;\n nacl: nacl;\n\n constructor(name: string, pusher: Pusher, nacl: nacl) {\n super(name, pusher);\n this.nacl = nacl;\n }\n\n /** Authorizes the connection to use the channel.\n *\n * @param {String} socketId\n * @param {Function} callback\n */\n authorize(socketId: string, callback: ChannelAuthorizationCallback) {\n super.authorize(\n socketId,\n (error: Error | null, authData: ChannelAuthorizationData) => {\n if (error) {\n callback(error, authData);\n return;\n }\n let sharedSecret = authData['shared_secret'];\n if (!sharedSecret) {\n callback(\n new Error(\n `No shared_secret key in auth payload for encrypted channel: ${this.name}`\n ),\n null\n );\n return;\n }\n this.key = decodeBase64(sharedSecret);\n delete authData['shared_secret'];\n callback(null, authData);\n }\n );\n }\n\n trigger(event: string, data: any): boolean {\n throw new Errors.UnsupportedFeature(\n 'Client events are not currently supported for encrypted channels'\n );\n }\n\n /** Handles an event. For internal use only.\n *\n * @param {PusherEvent} event\n */\n handleEvent(event: PusherEvent) {\n var eventName = event.event;\n var data = event.data;\n if (\n eventName.indexOf('pusher_internal:') === 0 ||\n eventName.indexOf('pusher:') === 0\n ) {\n super.handleEvent(event);\n return;\n }\n this.handleEncryptedEvent(eventName, data);\n }\n\n private handleEncryptedEvent(event: string, data: any): void {\n if (!this.key) {\n Logger.debug(\n 'Received encrypted event before key has been retrieved from the authEndpoint'\n );\n return;\n }\n if (!data.ciphertext || !data.nonce) {\n Logger.error(\n 'Unexpected format for encrypted event, expected object with `ciphertext` and `nonce` fields, got: ' +\n data\n );\n return;\n }\n let cipherText = decodeBase64(data.ciphertext);\n if (cipherText.length < this.nacl.secretbox.overheadLength) {\n Logger.error(\n `Expected encrypted event ciphertext length to be ${this.nacl.secretbox.overheadLength}, got: ${cipherText.length}`\n );\n return;\n }\n let nonce = decodeBase64(data.nonce);\n if (nonce.length < this.nacl.secretbox.nonceLength) {\n Logger.error(\n `Expected encrypted event nonce length to be ${this.nacl.secretbox.nonceLength}, got: ${nonce.length}`\n );\n return;\n }\n\n let bytes = this.nacl.secretbox.open(cipherText, nonce, this.key);\n if (bytes === null) {\n Logger.debug(\n 'Failed to decrypt an event, probably because it was encrypted with a different key. Fetching a new key from the authEndpoint...'\n );\n // Try a single time to retrieve a new auth key and decrypt the event with it\n // If this fails, a new key will be requested when a new message is received\n this.authorize(this.pusher.connection.socket_id, (error, authData) => {\n if (error) {\n Logger.error(\n `Failed to make a request to the authEndpoint: ${authData}. Unable to fetch new key, so dropping encrypted event`\n );\n return;\n }\n bytes = this.nacl.secretbox.open(cipherText, nonce, this.key);\n if (bytes === null) {\n Logger.error(\n `Failed to decrypt event with new key. Dropping encrypted event`\n );\n return;\n }\n this.emit(event, this.getDataToEmit(bytes));\n return;\n });\n return;\n }\n this.emit(event, this.getDataToEmit(bytes));\n }\n\n // Try and parse the decrypted bytes as JSON. If we can't parse it, just\n // return the utf-8 string\n getDataToEmit(bytes: Uint8Array): string {\n let raw = encodeUTF8(bytes);\n try {\n return JSON.parse(raw);\n } catch {\n return raw;\n }\n }\n}\n","import { default as EventsDispatcher } from '../events/dispatcher';\nimport { OneOffTimer as Timer } from '../utils/timers';\nimport { Config } from '../config';\nimport Logger from '../logger';\nimport HandshakePayload from './handshake/handshake_payload';\nimport Connection from './connection';\nimport Strategy from '../strategies/strategy';\nimport StrategyRunner from '../strategies/strategy_runner';\nimport * as Collections from '../utils/collections';\nimport Timeline from '../timeline/timeline';\nimport ConnectionManagerOptions from './connection_manager_options';\nimport Runtime from 'runtime';\n\nimport {\n ErrorCallbacks,\n HandshakeCallbacks,\n ConnectionCallbacks\n} from './callbacks';\nimport Action from './protocol/action';\n\n/** Manages connection to Pusher.\n *\n * Uses a strategy (currently only default), timers and network availability\n * info to establish a connection and export its state. In case of failures,\n * manages reconnection attempts.\n *\n * Exports state changes as following events:\n * - \"state_change\", { previous: p, current: state }\n * - state\n *\n * States:\n * - initialized - initial state, never transitioned to\n * - connecting - connection is being established\n * - connected - connection has been fully established\n * - disconnected - on requested disconnection\n * - unavailable - after connection timeout or when there's no network\n * - failed - when the connection strategy is not supported\n *\n * Options:\n * - unavailableTimeout - time to transition to unavailable state\n * - activityTimeout - time after which ping message should be sent\n * - pongTimeout - time for Pusher to respond with pong before reconnecting\n *\n * @param {String} key application key\n * @param {Object} options\n */\nexport default class ConnectionManager extends EventsDispatcher {\n key: string;\n options: ConnectionManagerOptions;\n state: string;\n connection: Connection;\n usingTLS: boolean;\n timeline: Timeline;\n socket_id: string;\n unavailableTimer: Timer;\n activityTimer: Timer;\n retryTimer: Timer;\n activityTimeout: number;\n strategy: Strategy;\n runner: StrategyRunner;\n errorCallbacks: ErrorCallbacks;\n handshakeCallbacks: HandshakeCallbacks;\n connectionCallbacks: ConnectionCallbacks;\n\n constructor(key: string, options: ConnectionManagerOptions) {\n super();\n this.state = 'initialized';\n this.connection = null;\n\n this.key = key;\n this.options = options;\n this.timeline = this.options.timeline;\n this.usingTLS = this.options.useTLS;\n\n this.errorCallbacks = this.buildErrorCallbacks();\n this.connectionCallbacks = this.buildConnectionCallbacks(\n this.errorCallbacks\n );\n this.handshakeCallbacks = this.buildHandshakeCallbacks(this.errorCallbacks);\n\n var Network = Runtime.getNetwork();\n\n Network.bind('online', () => {\n this.timeline.info({ netinfo: 'online' });\n if (this.state === 'connecting' || this.state === 'unavailable') {\n this.retryIn(0);\n }\n });\n Network.bind('offline', () => {\n this.timeline.info({ netinfo: 'offline' });\n if (this.connection) {\n this.sendActivityCheck();\n }\n });\n\n this.updateStrategy();\n }\n\n switchCluster(key: string) {\n this.key = key;\n // This ensures that the new config coming from\n // pusher instance are taken into account\n // such as appKey and cluster\n this.updateStrategy();\n this.retryIn(0);\n }\n\n /** Establishes a connection to Pusher.\n *\n * Does nothing when connection is already established. See top-level doc\n * to find events emitted on connection attempts.\n */\n connect() {\n if (this.connection || this.runner) {\n return;\n }\n if (!this.strategy.isSupported()) {\n this.updateState('failed');\n return;\n }\n this.updateState('connecting');\n this.startConnecting();\n this.setUnavailableTimer();\n }\n\n /** Sends raw data.\n *\n * @param {String} data\n */\n send(data) {\n if (this.connection) {\n return this.connection.send(data);\n } else {\n return false;\n }\n }\n\n /** Sends an event.\n *\n * @param {String} name\n * @param {String} data\n * @param {String} [channel]\n * @returns {Boolean} whether message was sent or not\n */\n send_event(name: string, data: any, channel?: string) {\n if (this.connection) {\n return this.connection.send_event(name, data, channel);\n } else {\n return false;\n }\n }\n\n /** Closes the connection. */\n disconnect() {\n this.disconnectInternally();\n this.updateState('disconnected');\n }\n\n isUsingTLS() {\n return this.usingTLS;\n }\n\n private startConnecting() {\n var callback = (error, handshake) => {\n if (error) {\n this.runner = this.strategy.connect(0, callback);\n } else {\n if (handshake.action === 'error') {\n this.emit('error', {\n type: 'HandshakeError',\n error: handshake.error\n });\n this.timeline.error({ handshakeError: handshake.error });\n } else {\n this.abortConnecting(); // we don't support switching connections yet\n this.handshakeCallbacks[handshake.action](handshake);\n }\n }\n };\n this.runner = this.strategy.connect(0, callback);\n }\n\n private abortConnecting() {\n if (this.runner) {\n this.runner.abort();\n this.runner = null;\n }\n }\n\n private disconnectInternally() {\n this.abortConnecting();\n this.clearRetryTimer();\n this.clearUnavailableTimer();\n if (this.connection) {\n var connection = this.abandonConnection();\n connection.close();\n }\n }\n\n private updateStrategy() {\n this.strategy = this.options.getStrategy({\n key: this.key,\n timeline: this.timeline,\n useTLS: this.usingTLS\n });\n }\n\n private retryIn(delay) {\n this.timeline.info({ action: 'retry', delay: delay });\n if (delay > 0) {\n this.emit('connecting_in', Math.round(delay / 1000));\n }\n this.retryTimer = new Timer(delay || 0, () => {\n this.disconnectInternally();\n this.connect();\n });\n }\n\n private clearRetryTimer() {\n if (this.retryTimer) {\n this.retryTimer.ensureAborted();\n this.retryTimer = null;\n }\n }\n\n private setUnavailableTimer() {\n this.unavailableTimer = new Timer(this.options.unavailableTimeout, () => {\n this.updateState('unavailable');\n });\n }\n\n private clearUnavailableTimer() {\n if (this.unavailableTimer) {\n this.unavailableTimer.ensureAborted();\n }\n }\n\n private sendActivityCheck() {\n this.stopActivityCheck();\n this.connection.ping();\n // wait for pong response\n this.activityTimer = new Timer(this.options.pongTimeout, () => {\n this.timeline.error({ pong_timed_out: this.options.pongTimeout });\n this.retryIn(0);\n });\n }\n\n private resetActivityCheck() {\n this.stopActivityCheck();\n // send ping after inactivity\n if (this.connection && !this.connection.handlesActivityChecks()) {\n this.activityTimer = new Timer(this.activityTimeout, () => {\n this.sendActivityCheck();\n });\n }\n }\n\n private stopActivityCheck() {\n if (this.activityTimer) {\n this.activityTimer.ensureAborted();\n }\n }\n\n private buildConnectionCallbacks(\n errorCallbacks: ErrorCallbacks\n ): ConnectionCallbacks {\n return Collections.extend({}, errorCallbacks, {\n message: message => {\n // includes pong messages from server\n this.resetActivityCheck();\n this.emit('message', message);\n },\n ping: () => {\n this.send_event('pusher:pong', {});\n },\n activity: () => {\n this.resetActivityCheck();\n },\n error: error => {\n // just emit error to user - socket will already be closed by browser\n this.emit('error', error);\n },\n closed: () => {\n this.abandonConnection();\n if (this.shouldRetry()) {\n this.retryIn(1000);\n }\n }\n });\n }\n\n private buildHandshakeCallbacks(\n errorCallbacks: ErrorCallbacks\n ): HandshakeCallbacks {\n return Collections.extend({}, errorCallbacks, {\n connected: (handshake: HandshakePayload) => {\n this.activityTimeout = Math.min(\n this.options.activityTimeout,\n handshake.activityTimeout,\n handshake.connection.activityTimeout || Infinity\n );\n this.clearUnavailableTimer();\n this.setConnection(handshake.connection);\n this.socket_id = this.connection.id;\n this.updateState('connected', { socket_id: this.socket_id });\n }\n });\n }\n\n private buildErrorCallbacks(): ErrorCallbacks {\n let withErrorEmitted = callback => {\n return (result: Action | HandshakePayload) => {\n if (result.error) {\n this.emit('error', { type: 'WebSocketError', error: result.error });\n }\n callback(result);\n };\n };\n\n return {\n tls_only: withErrorEmitted(() => {\n this.usingTLS = true;\n this.updateStrategy();\n this.retryIn(0);\n }),\n refused: withErrorEmitted(() => {\n this.disconnect();\n }),\n backoff: withErrorEmitted(() => {\n this.retryIn(1000);\n }),\n retry: withErrorEmitted(() => {\n this.retryIn(0);\n })\n };\n }\n\n private setConnection(connection) {\n this.connection = connection;\n for (var event in this.connectionCallbacks) {\n this.connection.bind(event, this.connectionCallbacks[event]);\n }\n this.resetActivityCheck();\n }\n\n private abandonConnection() {\n if (!this.connection) {\n return;\n }\n this.stopActivityCheck();\n for (var event in this.connectionCallbacks) {\n this.connection.unbind(event, this.connectionCallbacks[event]);\n }\n var connection = this.connection;\n this.connection = null;\n return connection;\n }\n\n private updateState(newState: string, data?: any) {\n var previousState = this.state;\n this.state = newState;\n if (previousState !== newState) {\n var newStateDescription = newState;\n if (newStateDescription === 'connected') {\n newStateDescription += ' with new socket ID ' + data.socket_id;\n }\n Logger.debug(\n 'State changed',\n previousState + ' -> ' + newStateDescription\n );\n this.timeline.info({ state: newState, params: data });\n this.emit('state_change', { previous: previousState, current: newState });\n this.emit(newState, data);\n }\n }\n\n private shouldRetry(): boolean {\n return this.state === 'connecting' || this.state === 'connected';\n }\n}\n","import Channel from './channel';\nimport * as Collections from '../utils/collections';\nimport ChannelTable from './channel_table';\nimport Factory from '../utils/factory';\nimport Pusher from '../pusher';\nimport Logger from '../logger';\nimport * as Errors from '../errors';\nimport urlStore from '../utils/url_store';\n\n/** Handles a channel map. */\nexport default class Channels {\n channels: ChannelTable;\n\n constructor() {\n this.channels = {};\n }\n\n /** Creates or retrieves an existing channel by its name.\n *\n * @param {String} name\n * @param {Pusher} pusher\n * @return {Channel}\n */\n add(name: string, pusher: Pusher) {\n if (!this.channels[name]) {\n this.channels[name] = createChannel(name, pusher);\n }\n return this.channels[name];\n }\n\n /** Returns a list of all channels\n *\n * @return {Array}\n */\n all(): Channel[] {\n return Collections.values(this.channels);\n }\n\n /** Finds a channel by its name.\n *\n * @param {String} name\n * @return {Channel} channel or null if it doesn't exist\n */\n find(name: string) {\n return this.channels[name];\n }\n\n /** Removes a channel from the map.\n *\n * @param {String} name\n */\n remove(name: string) {\n var channel = this.channels[name];\n delete this.channels[name];\n return channel;\n }\n\n /** Proxies disconnection signal to all channels. */\n disconnect() {\n Collections.objectApply(this.channels, function(channel) {\n channel.disconnect();\n });\n }\n}\n\nfunction createChannel(name: string, pusher: Pusher): Channel {\n if (name.indexOf('private-encrypted-') === 0) {\n if (pusher.config.nacl) {\n return Factory.createEncryptedChannel(name, pusher, pusher.config.nacl);\n }\n let errMsg =\n 'Tried to subscribe to a private-encrypted- channel but no nacl implementation available';\n let suffix = urlStore.buildLogSuffix('encryptedChannelSupport');\n throw new Errors.UnsupportedFeature(`${errMsg}. ${suffix}`);\n } else if (name.indexOf('private-') === 0) {\n return Factory.createPrivateChannel(name, pusher);\n } else if (name.indexOf('presence-') === 0) {\n return Factory.createPresenceChannel(name, pusher);\n } else if (name.indexOf('#') === 0) {\n throw new Errors.BadChannelName(\n 'Cannot create a channel with name \"' + name + '\".'\n );\n } else {\n return Factory.createChannel(name, pusher);\n }\n}\n","import AssistantToTheTransportManager from '../transports/assistant_to_the_transport_manager';\nimport PingDelayOptions from '../transports/ping_delay_options';\nimport Transport from '../transports/transport';\nimport TransportManager from '../transports/transport_manager';\nimport Handshake from '../connection/handshake';\nimport TransportConnection from '../transports/transport_connection';\nimport SocketHooks from '../http/socket_hooks';\nimport HTTPSocket from '../http/http_socket';\n\nimport Timeline from '../timeline/timeline';\nimport {\n default as TimelineSender,\n TimelineSenderOptions\n} from '../timeline/timeline_sender';\nimport PresenceChannel from '../channels/presence_channel';\nimport PrivateChannel from '../channels/private_channel';\nimport EncryptedChannel from '../channels/encrypted_channel';\nimport Channel from '../channels/channel';\nimport ConnectionManager from '../connection/connection_manager';\nimport ConnectionManagerOptions from '../connection/connection_manager_options';\nimport Ajax from '../http/ajax';\nimport Channels from '../channels/channels';\nimport Pusher from '../pusher';\nimport { Config } from '../config';\nimport * as nacl from 'tweetnacl';\n\nvar Factory = {\n createChannels(): Channels {\n return new Channels();\n },\n\n createConnectionManager(\n key: string,\n options: ConnectionManagerOptions\n ): ConnectionManager {\n return new ConnectionManager(key, options);\n },\n\n createChannel(name: string, pusher: Pusher): Channel {\n return new Channel(name, pusher);\n },\n\n createPrivateChannel(name: string, pusher: Pusher): PrivateChannel {\n return new PrivateChannel(name, pusher);\n },\n\n createPresenceChannel(name: string, pusher: Pusher): PresenceChannel {\n return new PresenceChannel(name, pusher);\n },\n\n createEncryptedChannel(\n name: string,\n pusher: Pusher,\n nacl: nacl\n ): EncryptedChannel {\n return new EncryptedChannel(name, pusher, nacl);\n },\n\n createTimelineSender(timeline: Timeline, options: TimelineSenderOptions) {\n return new TimelineSender(timeline, options);\n },\n\n createHandshake(\n transport: TransportConnection,\n callback: (HandshakePayload) => void\n ): Handshake {\n return new Handshake(transport, callback);\n },\n\n createAssistantToTheTransportManager(\n manager: TransportManager,\n transport: Transport,\n options: PingDelayOptions\n ): AssistantToTheTransportManager {\n return new AssistantToTheTransportManager(manager, transport, options);\n }\n};\n\nexport default Factory;\n","import AssistantToTheTransportManager from './assistant_to_the_transport_manager';\nimport Transport from './transport';\nimport PingDelayOptions from './ping_delay_options';\nimport Factory from '../utils/factory';\n\nexport interface TransportManagerOptions extends PingDelayOptions {\n lives?: number;\n}\n\n/** Keeps track of the number of lives left for a transport.\n *\n * In the beginning of a session, transports may be assigned a number of\n * lives. When an AssistantToTheTransportManager instance reports a transport\n * connection closed uncleanly, the transport loses a life. When the number\n * of lives drops to zero, the transport gets disabled by its manager.\n *\n * @param {Object} options\n */\nexport default class TransportManager {\n options: TransportManagerOptions;\n livesLeft: number;\n\n constructor(options: TransportManagerOptions) {\n this.options = options || {};\n this.livesLeft = this.options.lives || Infinity;\n }\n\n /** Creates a assistant for the transport.\n *\n * @param {Transport} transport\n * @returns {AssistantToTheTransportManager}\n */\n getAssistant(transport: Transport): AssistantToTheTransportManager {\n return Factory.createAssistantToTheTransportManager(this, transport, {\n minPingDelay: this.options.minPingDelay,\n maxPingDelay: this.options.maxPingDelay\n });\n }\n\n /** Returns whether the transport has any lives left.\n *\n * @returns {Boolean}\n */\n isAlive(): boolean {\n return this.livesLeft > 0;\n }\n\n /** Takes one life from the transport. */\n reportDeath() {\n this.livesLeft -= 1;\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport { OneOffTimer as Timer } from '../utils/timers';\nimport Strategy from './strategy';\nimport StrategyOptions from './strategy_options';\n\n/** Loops through strategies with optional timeouts.\n *\n * Options:\n * - loop - whether it should loop through the substrategy list\n * - timeout - initial timeout for a single substrategy\n * - timeoutLimit - maximum timeout\n *\n * @param {Strategy[]} strategies\n * @param {Object} options\n */\nexport default class SequentialStrategy implements Strategy {\n strategies: Strategy[];\n loop: boolean;\n failFast: boolean;\n timeout: number;\n timeoutLimit: number;\n\n constructor(strategies: Strategy[], options: StrategyOptions) {\n this.strategies = strategies;\n this.loop = Boolean(options.loop);\n this.failFast = Boolean(options.failFast);\n this.timeout = options.timeout;\n this.timeoutLimit = options.timeoutLimit;\n }\n\n isSupported(): boolean {\n return Collections.any(this.strategies, Util.method('isSupported'));\n }\n\n connect(minPriority: number, callback: Function) {\n var strategies = this.strategies;\n var current = 0;\n var timeout = this.timeout;\n var runner = null;\n\n var tryNextStrategy = (error, handshake) => {\n if (handshake) {\n callback(null, handshake);\n } else {\n current = current + 1;\n if (this.loop) {\n current = current % strategies.length;\n }\n\n if (current < strategies.length) {\n if (timeout) {\n timeout = timeout * 2;\n if (this.timeoutLimit) {\n timeout = Math.min(timeout, this.timeoutLimit);\n }\n }\n runner = this.tryStrategy(\n strategies[current],\n minPriority,\n { timeout, failFast: this.failFast },\n tryNextStrategy\n );\n } else {\n callback(true);\n }\n }\n };\n\n runner = this.tryStrategy(\n strategies[current],\n minPriority,\n { timeout: timeout, failFast: this.failFast },\n tryNextStrategy\n );\n\n return {\n abort: function() {\n runner.abort();\n },\n forceMinPriority: function(p) {\n minPriority = p;\n if (runner) {\n runner.forceMinPriority(p);\n }\n }\n };\n }\n\n private tryStrategy(\n strategy: Strategy,\n minPriority: number,\n options: StrategyOptions,\n callback: Function\n ) {\n var timer = null;\n var runner = null;\n\n if (options.timeout > 0) {\n timer = new Timer(options.timeout, function() {\n runner.abort();\n callback(true);\n });\n }\n\n runner = strategy.connect(minPriority, function(error, handshake) {\n if (error && timer && timer.isRunning() && !options.failFast) {\n // advance to the next strategy after the timeout\n return;\n }\n if (timer) {\n timer.ensureAborted();\n }\n callback(error, handshake);\n });\n\n return {\n abort: function() {\n if (timer) {\n timer.ensureAborted();\n }\n runner.abort();\n },\n forceMinPriority: function(p) {\n runner.forceMinPriority(p);\n }\n };\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport Strategy from './strategy';\n\n/** Launches all substrategies and emits prioritized connected transports.\n *\n * @param {Array} strategies\n */\nexport default class BestConnectedEverStrategy implements Strategy {\n strategies: Strategy[];\n\n constructor(strategies: Strategy[]) {\n this.strategies = strategies;\n }\n\n isSupported(): boolean {\n return Collections.any(this.strategies, Util.method('isSupported'));\n }\n\n connect(minPriority: number, callback: Function) {\n return connect(this.strategies, minPriority, function(i, runners) {\n return function(error, handshake) {\n runners[i].error = error;\n if (error) {\n if (allRunnersFailed(runners)) {\n callback(true);\n }\n return;\n }\n Collections.apply(runners, function(runner) {\n runner.forceMinPriority(handshake.transport.priority);\n });\n callback(null, handshake);\n };\n });\n }\n}\n\n/** Connects to all strategies in parallel.\n *\n * Callback builder should be a function that takes two arguments: index\n * and a list of runners. It should return another function that will be\n * passed to the substrategy with given index. Runners can be aborted using\n * abortRunner(s) functions from this class.\n *\n * @param {Array} strategies\n * @param {Function} callbackBuilder\n * @return {Object} strategy runner\n */\nfunction connect(\n strategies: Strategy[],\n minPriority: number,\n callbackBuilder: Function\n) {\n var runners = Collections.map(strategies, function(strategy, i, _, rs) {\n return strategy.connect(minPriority, callbackBuilder(i, rs));\n });\n return {\n abort: function() {\n Collections.apply(runners, abortRunner);\n },\n forceMinPriority: function(p) {\n Collections.apply(runners, function(runner) {\n runner.forceMinPriority(p);\n });\n }\n };\n}\n\nfunction allRunnersFailed(runners): boolean {\n return Collections.all(runners, function(runner) {\n return Boolean(runner.error);\n });\n}\n\nfunction abortRunner(runner) {\n if (!runner.error && !runner.aborted) {\n runner.abort();\n runner.aborted = true;\n }\n}\n","import Util from '../util';\nimport Runtime from 'runtime';\nimport Strategy from './strategy';\nimport SequentialStrategy from './sequential_strategy';\nimport StrategyOptions from './strategy_options';\nimport TransportStrategy from './transport_strategy';\nimport Timeline from '../timeline/timeline';\nimport * as Collections from '../utils/collections';\n\nexport interface TransportStrategyDictionary {\n [key: string]: TransportStrategy;\n}\n\n/** Caches the last successful transport and, after the first few attempts,\n * uses the cached transport for subsequent attempts.\n *\n * @param {Strategy} strategy\n * @param {Object} transports\n * @param {Object} options\n */\nexport default class WebSocketPrioritizedCachedStrategy implements Strategy {\n strategy: Strategy;\n transports: TransportStrategyDictionary;\n ttl: number;\n usingTLS: boolean;\n timeline: Timeline;\n\n constructor(\n strategy: Strategy,\n transports: TransportStrategyDictionary,\n options: StrategyOptions\n ) {\n this.strategy = strategy;\n this.transports = transports;\n this.ttl = options.ttl || 1800 * 1000;\n this.usingTLS = options.useTLS;\n this.timeline = options.timeline;\n }\n\n isSupported(): boolean {\n return this.strategy.isSupported();\n }\n\n connect(minPriority: number, callback: Function) {\n var usingTLS = this.usingTLS;\n var info = fetchTransportCache(usingTLS);\n var cacheSkipCount = info && info.cacheSkipCount ? info.cacheSkipCount : 0;\n\n var strategies = [this.strategy];\n if (info && info.timestamp + this.ttl >= Util.now()) {\n var transport = this.transports[info.transport];\n if (transport) {\n if (['ws', 'wss'].includes(info.transport) || cacheSkipCount > 3) {\n this.timeline.info({\n cached: true,\n transport: info.transport,\n latency: info.latency\n });\n strategies.push(\n new SequentialStrategy([transport], {\n timeout: info.latency * 2 + 1000,\n failFast: true\n })\n );\n } else {\n cacheSkipCount++;\n }\n }\n }\n\n var startTimestamp = Util.now();\n var runner = strategies\n .pop()\n .connect(minPriority, function cb(error, handshake) {\n if (error) {\n flushTransportCache(usingTLS);\n if (strategies.length > 0) {\n startTimestamp = Util.now();\n runner = strategies.pop().connect(minPriority, cb);\n } else {\n callback(error);\n }\n } else {\n storeTransportCache(\n usingTLS,\n handshake.transport.name,\n Util.now() - startTimestamp,\n cacheSkipCount\n );\n callback(null, handshake);\n }\n });\n\n return {\n abort: function() {\n runner.abort();\n },\n forceMinPriority: function(p) {\n minPriority = p;\n if (runner) {\n runner.forceMinPriority(p);\n }\n }\n };\n }\n}\n\nfunction getTransportCacheKey(usingTLS: boolean): string {\n return 'pusherTransport' + (usingTLS ? 'TLS' : 'NonTLS');\n}\n\nfunction fetchTransportCache(usingTLS: boolean): any {\n var storage = Runtime.getLocalStorage();\n if (storage) {\n try {\n var serializedCache = storage[getTransportCacheKey(usingTLS)];\n if (serializedCache) {\n return JSON.parse(serializedCache);\n }\n } catch (e) {\n flushTransportCache(usingTLS);\n }\n }\n return null;\n}\n\nfunction storeTransportCache(\n usingTLS: boolean,\n transport: TransportStrategy,\n latency: number,\n cacheSkipCount: number\n) {\n var storage = Runtime.getLocalStorage();\n if (storage) {\n try {\n storage[getTransportCacheKey(usingTLS)] = Collections.safeJSONStringify({\n timestamp: Util.now(),\n transport: transport,\n latency: latency,\n cacheSkipCount: cacheSkipCount\n });\n } catch (e) {\n // catch over quota exceptions raised by localStorage\n }\n }\n}\n\nfunction flushTransportCache(usingTLS: boolean) {\n var storage = Runtime.getLocalStorage();\n if (storage) {\n try {\n delete storage[getTransportCacheKey(usingTLS)];\n } catch (e) {\n // catch exceptions raised by localStorage\n }\n }\n}\n","import { OneOffTimer as Timer } from '../utils/timers';\nimport Strategy from './strategy';\nimport StrategyOptions from './strategy_options';\n\n/** Runs substrategy after specified delay.\n *\n * Options:\n * - delay - time in miliseconds to delay the substrategy attempt\n *\n * @param {Strategy} strategy\n * @param {Object} options\n */\nexport default class DelayedStrategy implements Strategy {\n strategy: Strategy;\n options: { delay: number };\n\n constructor(strategy: Strategy, { delay: number }) {\n this.strategy = strategy;\n this.options = { delay: number };\n }\n\n isSupported(): boolean {\n return this.strategy.isSupported();\n }\n\n connect(minPriority: number, callback: Function) {\n var strategy = this.strategy;\n var runner;\n var timer = new Timer(this.options.delay, function() {\n runner = strategy.connect(minPriority, callback);\n });\n\n return {\n abort: function() {\n timer.ensureAborted();\n if (runner) {\n runner.abort();\n }\n },\n forceMinPriority: function(p) {\n minPriority = p;\n if (runner) {\n runner.forceMinPriority(p);\n }\n }\n };\n }\n}\n","import Strategy from './strategy';\nimport StrategyRunner from './strategy_runner';\n\n/** Proxies method calls to one of substrategies basing on the test function.\n *\n * @param {Function} test\n * @param {Strategy} trueBranch strategy used when test returns true\n * @param {Strategy} falseBranch strategy used when test returns false\n */\nexport default class IfStrategy implements Strategy {\n test: () => boolean;\n trueBranch: Strategy;\n falseBranch: Strategy;\n\n constructor(\n test: () => boolean,\n trueBranch: Strategy,\n falseBranch: Strategy\n ) {\n this.test = test;\n this.trueBranch = trueBranch;\n this.falseBranch = falseBranch;\n }\n\n isSupported(): boolean {\n var branch = this.test() ? this.trueBranch : this.falseBranch;\n return branch.isSupported();\n }\n\n connect(minPriority: number, callback: Function): StrategyRunner {\n var branch = this.test() ? this.trueBranch : this.falseBranch;\n return branch.connect(minPriority, callback);\n }\n}\n","import Strategy from './strategy';\nimport StrategyRunner from './strategy_runner';\n\n/** Launches the substrategy and terminates on the first open connection.\n *\n * @param {Strategy} strategy\n */\nexport default class FirstConnectedStrategy implements Strategy {\n strategy: Strategy;\n\n constructor(strategy: Strategy) {\n this.strategy = strategy;\n }\n\n isSupported(): boolean {\n return this.strategy.isSupported();\n }\n\n connect(minPriority: number, callback: Function): StrategyRunner {\n var runner = this.strategy.connect(minPriority, function(error, handshake) {\n if (handshake) {\n runner.abort();\n }\n callback(error, handshake);\n });\n return runner;\n }\n}\n","import * as Collections from 'core/utils/collections';\nimport TransportManager from 'core/transports/transport_manager';\nimport Strategy from 'core/strategies/strategy';\nimport SequentialStrategy from 'core/strategies/sequential_strategy';\nimport BestConnectedEverStrategy from 'core/strategies/best_connected_ever_strategy';\nimport WebSocketPrioritizedCachedStrategy, {\n TransportStrategyDictionary\n} from 'core/strategies/websocket_prioritized_cached_strategy';\nimport DelayedStrategy from 'core/strategies/delayed_strategy';\nimport IfStrategy from 'core/strategies/if_strategy';\nimport FirstConnectedStrategy from 'core/strategies/first_connected_strategy';\nimport { Config } from 'core/config';\nimport StrategyOptions from 'core/strategies/strategy_options';\n\nfunction testSupportsStrategy(strategy: Strategy) {\n return function() {\n return strategy.isSupported();\n };\n}\n\nvar getDefaultStrategy = function(\n config: Config,\n baseOptions: StrategyOptions,\n defineTransport: Function\n): Strategy {\n var definedTransports = {};\n\n function defineTransportStrategy(\n name: string,\n type: string,\n priority: number,\n options: StrategyOptions,\n manager?: TransportManager\n ) {\n var transport = defineTransport(\n config,\n name,\n type,\n priority,\n options,\n manager\n );\n\n definedTransports[name] = transport;\n\n return transport;\n }\n\n var ws_options: StrategyOptions = Object.assign({}, baseOptions, {\n hostNonTLS: config.wsHost + ':' + config.wsPort,\n hostTLS: config.wsHost + ':' + config.wssPort,\n httpPath: config.wsPath\n });\n var wss_options: StrategyOptions = Collections.extend({}, ws_options, {\n useTLS: true\n });\n var http_options: StrategyOptions = Object.assign({}, baseOptions, {\n hostNonTLS: config.httpHost + ':' + config.httpPort,\n hostTLS: config.httpHost + ':' + config.httpsPort,\n httpPath: config.httpPath\n });\n var timeouts = {\n loop: true,\n timeout: 15000,\n timeoutLimit: 60000\n };\n\n var ws_manager = new TransportManager({\n minPingDelay: 10000,\n maxPingDelay: config.activityTimeout\n });\n var streaming_manager = new TransportManager({\n lives: 2,\n minPingDelay: 10000,\n maxPingDelay: config.activityTimeout\n });\n\n var ws_transport = defineTransportStrategy(\n 'ws',\n 'ws',\n 3,\n ws_options,\n ws_manager\n );\n var wss_transport = defineTransportStrategy(\n 'wss',\n 'ws',\n 3,\n wss_options,\n ws_manager\n );\n var xhr_streaming_transport = defineTransportStrategy(\n 'xhr_streaming',\n 'xhr_streaming',\n 1,\n http_options,\n streaming_manager\n );\n var xhr_polling_transport = defineTransportStrategy(\n 'xhr_polling',\n 'xhr_polling',\n 1,\n http_options\n );\n\n var ws_loop = new SequentialStrategy([ws_transport], timeouts);\n var wss_loop = new SequentialStrategy([wss_transport], timeouts);\n var streaming_loop = new SequentialStrategy(\n [xhr_streaming_transport],\n timeouts\n );\n var polling_loop = new SequentialStrategy([xhr_polling_transport], timeouts);\n\n var http_loop = new SequentialStrategy(\n [\n new IfStrategy(\n testSupportsStrategy(streaming_loop),\n new BestConnectedEverStrategy([\n streaming_loop,\n new DelayedStrategy(polling_loop, { delay: 4000 })\n ]),\n polling_loop\n )\n ],\n timeouts\n );\n\n var wsStrategy;\n if (baseOptions.useTLS) {\n wsStrategy = new BestConnectedEverStrategy([\n ws_loop,\n new DelayedStrategy(http_loop, { delay: 2000 })\n ]);\n } else {\n wsStrategy = new BestConnectedEverStrategy([\n ws_loop,\n new DelayedStrategy(wss_loop, { delay: 2000 }),\n new DelayedStrategy(http_loop, { delay: 5000 })\n ]);\n }\n\n return new WebSocketPrioritizedCachedStrategy(\n new FirstConnectedStrategy(\n new IfStrategy(testSupportsStrategy(ws_transport), wsStrategy, http_loop)\n ),\n definedTransports,\n {\n ttl: 1800000,\n timeline: baseOptions.timeline,\n useTLS: baseOptions.useTLS\n }\n );\n};\n\nexport default getDefaultStrategy;\n","/** Initializes the transport.\n *\n * Fetches resources if needed and then transitions to initialized.\n */\nexport default function() {\n var self = this;\n\n self.timeline.info(\n self.buildTimelineMessage({\n transport: self.name + (self.options.useTLS ? 's' : '')\n })\n );\n\n if (self.hooks.isInitialized()) {\n self.changeState('initialized');\n } else {\n self.onClose();\n }\n}\n","import Runtime from 'runtime';\nimport RequestHooks from './request_hooks';\nimport Ajax from './ajax';\nimport { default as EventsDispatcher } from '../events/dispatcher';\n\nconst MAX_BUFFER_LENGTH = 256 * 1024;\n\nexport default class HTTPRequest extends EventsDispatcher {\n hooks: RequestHooks;\n method: string;\n url: string;\n position: number;\n xhr: Ajax;\n unloader: Function;\n\n constructor(hooks: RequestHooks, method: string, url: string) {\n super();\n this.hooks = hooks;\n this.method = method;\n this.url = url;\n }\n\n start(payload?: any) {\n this.position = 0;\n this.xhr = this.hooks.getRequest(this);\n\n this.unloader = () => {\n this.close();\n };\n Runtime.addUnloadListener(this.unloader);\n\n this.xhr.open(this.method, this.url, true);\n\n if (this.xhr.setRequestHeader) {\n this.xhr.setRequestHeader('Content-Type', 'application/json'); // ReactNative doesn't set this header by default.\n }\n this.xhr.send(payload);\n }\n\n close() {\n if (this.unloader) {\n Runtime.removeUnloadListener(this.unloader);\n this.unloader = null;\n }\n if (this.xhr) {\n this.hooks.abortRequest(this.xhr);\n this.xhr = null;\n }\n }\n\n onChunk(status: number, data: any) {\n while (true) {\n var chunk = this.advanceBuffer(data);\n if (chunk) {\n this.emit('chunk', { status: status, data: chunk });\n } else {\n break;\n }\n }\n if (this.isBufferTooLong(data)) {\n this.emit('buffer_too_long');\n }\n }\n\n private advanceBuffer(buffer: any[]): any {\n var unreadData = buffer.slice(this.position);\n var endOfLinePosition = unreadData.indexOf('\\n');\n\n if (endOfLinePosition !== -1) {\n this.position += endOfLinePosition + 1;\n return unreadData.slice(0, endOfLinePosition);\n } else {\n // chunk is not finished yet, don't move the buffer pointer\n return null;\n }\n }\n\n private isBufferTooLong(buffer: any): boolean {\n return this.position === buffer.length && buffer.length > MAX_BUFFER_LENGTH;\n }\n}\n","enum State {\n CONNECTING = 0,\n OPEN = 1,\n CLOSED = 3\n}\n\nexport default State;\n","import URLLocation from './url_location';\nimport State from './state';\nimport Socket from '../socket';\nimport SocketHooks from './socket_hooks';\nimport Util from '../util';\nimport Ajax from './ajax';\nimport HTTPRequest from './http_request';\nimport Runtime from 'runtime';\n\nvar autoIncrement = 1;\n\nclass HTTPSocket implements Socket {\n hooks: SocketHooks;\n session: string;\n location: URLLocation;\n readyState: State;\n stream: HTTPRequest;\n\n onopen: () => void;\n onerror: (error: any) => void;\n onclose: (closeEvent: any) => void;\n onmessage: (message: any) => void;\n onactivity: () => void;\n\n constructor(hooks: SocketHooks, url: string) {\n this.hooks = hooks;\n this.session = randomNumber(1000) + '/' + randomString(8);\n this.location = getLocation(url);\n this.readyState = State.CONNECTING;\n this.openStream();\n }\n\n send(payload: any) {\n return this.sendRaw(JSON.stringify([payload]));\n }\n\n ping() {\n this.hooks.sendHeartbeat(this);\n }\n\n close(code: any, reason: any) {\n this.onClose(code, reason, true);\n }\n\n /** For internal use only */\n sendRaw(payload: any): boolean {\n if (this.readyState === State.OPEN) {\n try {\n Runtime.createSocketRequest(\n 'POST',\n getUniqueURL(getSendURL(this.location, this.session))\n ).start(payload);\n return true;\n } catch (e) {\n return false;\n }\n } else {\n return false;\n }\n }\n\n /** For internal use only */\n reconnect() {\n this.closeStream();\n this.openStream();\n }\n\n /** For internal use only */\n onClose(code, reason, wasClean) {\n this.closeStream();\n this.readyState = State.CLOSED;\n if (this.onclose) {\n this.onclose({\n code: code,\n reason: reason,\n wasClean: wasClean\n });\n }\n }\n\n private onChunk(chunk) {\n if (chunk.status !== 200) {\n return;\n }\n if (this.readyState === State.OPEN) {\n this.onActivity();\n }\n\n var payload;\n var type = chunk.data.slice(0, 1);\n switch (type) {\n case 'o':\n payload = JSON.parse(chunk.data.slice(1) || '{}');\n this.onOpen(payload);\n break;\n case 'a':\n payload = JSON.parse(chunk.data.slice(1) || '[]');\n for (var i = 0; i < payload.length; i++) {\n this.onEvent(payload[i]);\n }\n break;\n case 'm':\n payload = JSON.parse(chunk.data.slice(1) || 'null');\n this.onEvent(payload);\n break;\n case 'h':\n this.hooks.onHeartbeat(this);\n break;\n case 'c':\n payload = JSON.parse(chunk.data.slice(1) || '[]');\n this.onClose(payload[0], payload[1], true);\n break;\n }\n }\n\n private onOpen(options) {\n if (this.readyState === State.CONNECTING) {\n if (options && options.hostname) {\n this.location.base = replaceHost(this.location.base, options.hostname);\n }\n this.readyState = State.OPEN;\n\n if (this.onopen) {\n this.onopen();\n }\n } else {\n this.onClose(1006, 'Server lost session', true);\n }\n }\n\n private onEvent(event) {\n if (this.readyState === State.OPEN && this.onmessage) {\n this.onmessage({ data: event });\n }\n }\n\n private onActivity() {\n if (this.onactivity) {\n this.onactivity();\n }\n }\n\n private onError(error) {\n if (this.onerror) {\n this.onerror(error);\n }\n }\n\n private openStream() {\n this.stream = Runtime.createSocketRequest(\n 'POST',\n getUniqueURL(this.hooks.getReceiveURL(this.location, this.session))\n );\n\n this.stream.bind('chunk', chunk => {\n this.onChunk(chunk);\n });\n this.stream.bind('finished', status => {\n this.hooks.onFinished(this, status);\n });\n this.stream.bind('buffer_too_long', () => {\n this.reconnect();\n });\n\n try {\n this.stream.start();\n } catch (error) {\n Util.defer(() => {\n this.onError(error);\n this.onClose(1006, 'Could not start streaming', false);\n });\n }\n }\n\n private closeStream() {\n if (this.stream) {\n this.stream.unbind_all();\n this.stream.close();\n this.stream = null;\n }\n }\n}\n\nfunction getLocation(url): URLLocation {\n var parts = /([^\\?]*)\\/*(\\??.*)/.exec(url);\n return {\n base: parts[1],\n queryString: parts[2]\n };\n}\n\nfunction getSendURL(url: URLLocation, session: string): string {\n return url.base + '/' + session + '/xhr_send';\n}\n\nfunction getUniqueURL(url: string): string {\n var separator = url.indexOf('?') === -1 ? '?' : '&';\n return url + separator + 't=' + +new Date() + '&n=' + autoIncrement++;\n}\n\nfunction replaceHost(url: string, hostname: string): string {\n var urlParts = /(https?:\\/\\/)([^\\/:]+)((\\/|:)?.*)/.exec(url);\n return urlParts[1] + hostname + urlParts[3];\n}\n\nfunction randomNumber(max: number): number {\n return Runtime.randomInt(max);\n}\n\nfunction randomString(length: number): string {\n var result = [];\n\n for (var i = 0; i < length; i++) {\n result.push(randomNumber(32).toString(32));\n }\n\n return result.join('');\n}\n\nexport default HTTPSocket;\n","import SocketHooks from './socket_hooks';\nimport HTTPSocket from './http_socket';\n\nvar hooks: SocketHooks = {\n getReceiveURL: function(url, session) {\n return url.base + '/' + session + '/xhr_streaming' + url.queryString;\n },\n onHeartbeat: function(socket) {\n socket.sendRaw('[]');\n },\n sendHeartbeat: function(socket) {\n socket.sendRaw('[]');\n },\n onFinished: function(socket, status) {\n socket.onClose(1006, 'Connection interrupted (' + status + ')', false);\n }\n};\n\nexport default hooks;\n","import SocketHooks from './socket_hooks';\nimport URLLocation from './url_location';\nimport HTTPSocket from './http_socket';\n\nvar hooks: SocketHooks = {\n getReceiveURL: function(url: URLLocation, session: string): string {\n return url.base + '/' + session + '/xhr' + url.queryString;\n },\n onHeartbeat: function() {\n // next HTTP request will reset server's activity timer\n },\n sendHeartbeat: function(socket) {\n socket.sendRaw('[]');\n },\n onFinished: function(socket, status) {\n if (status === 200) {\n socket.reconnect();\n } else {\n socket.onClose(1006, 'Connection interrupted (' + status + ')', false);\n }\n }\n};\n\nexport default hooks;\n","import HTTPRequest from 'core/http/http_request';\nimport RequestHooks from 'core/http/request_hooks';\nimport Ajax from 'core/http/ajax';\nimport Runtime from 'runtime';\n\nvar hooks: RequestHooks = {\n getRequest: function(socket: HTTPRequest): Ajax {\n var Constructor = Runtime.getXHRAPI();\n var xhr = new Constructor();\n xhr.onreadystatechange = xhr.onprogress = function() {\n switch (xhr.readyState) {\n case 3:\n if (xhr.responseText && xhr.responseText.length > 0) {\n socket.onChunk(xhr.status, xhr.responseText);\n }\n break;\n case 4:\n // this happens only on errors, never after calling close\n if (xhr.responseText && xhr.responseText.length > 0) {\n socket.onChunk(xhr.status, xhr.responseText);\n }\n socket.emit('finished', xhr.status);\n socket.close();\n break;\n }\n };\n return xhr;\n },\n abortRequest: function(xhr: Ajax) {\n xhr.onreadystatechange = null;\n xhr.abort();\n }\n};\n\nexport default hooks;\n","import HTTPRequest from 'core/http/http_request';\nimport HTTPSocket from 'core/http/http_socket';\nimport SocketHooks from 'core/http/socket_hooks';\nimport RequestHooks from 'core/http/request_hooks';\nimport streamingHooks from 'core/http/http_streaming_socket';\nimport pollingHooks from 'core/http/http_polling_socket';\nimport xhrHooks from './http_xhr_request';\nimport HTTPFactory from 'core/http/http_factory';\n\nvar HTTP: HTTPFactory = {\n createStreamingSocket(url: string): HTTPSocket {\n return this.createSocket(streamingHooks, url);\n },\n\n createPollingSocket(url: string): HTTPSocket {\n return this.createSocket(pollingHooks, url);\n },\n\n createSocket(hooks: SocketHooks, url: string): HTTPSocket {\n return new HTTPSocket(hooks, url);\n },\n\n createXHR(method: string, url: string): HTTPRequest {\n return this.createRequest(xhrHooks, method, url);\n },\n\n createRequest(hooks: RequestHooks, method: string, url: string): HTTPRequest {\n return new HTTPRequest(hooks, method, url);\n }\n};\n\nexport default HTTP;\n","import * as Collections from 'core/utils/collections';\nimport Transports from 'isomorphic/transports/transports';\nimport TimelineSender from 'core/timeline/timeline_sender';\nimport Ajax from 'core/http/ajax';\nimport getDefaultStrategy from './default_strategy';\nimport TransportsTable from 'core/transports/transports_table';\nimport transportConnectionInitializer from './transports/transport_connection_initializer';\nimport HTTPFactory from './http/http';\n\nvar Isomorphic: any = {\n getDefaultStrategy,\n Transports: Transports,\n transportConnectionInitializer,\n HTTPFactory,\n\n setup(PusherClass): void {\n PusherClass.ready();\n },\n\n getLocalStorage(): any {\n return undefined;\n },\n\n getClientFeatures(): any[] {\n return Collections.keys(\n Collections.filterObject({ ws: Transports.ws }, function(t) {\n return t.isSupported({});\n })\n );\n },\n\n getProtocol(): string {\n return 'http:';\n },\n\n isXHRSupported(): boolean {\n return true;\n },\n\n createSocketRequest(method: string, url: string) {\n if (this.isXHRSupported()) {\n return this.HTTPFactory.createXHR(method, url);\n } else {\n throw 'Cross-origin HTTP requests are not supported';\n }\n },\n\n createXHR(): Ajax {\n var Constructor = this.getXHRAPI();\n return new Constructor();\n },\n\n createWebSocket(url: string): any {\n var Constructor = this.getWebSocketAPI();\n return new Constructor(url);\n },\n\n addUnloadListener(listener: any) {},\n removeUnloadListener(listener: any) {}\n};\n\nexport default Isomorphic;\n","import { default as EventsDispatcher } from 'core/events/dispatcher';\nimport Reachability from 'core/reachability';\n\nexport class NetInfo extends EventsDispatcher implements Reachability {\n isOnline(): boolean {\n return true;\n }\n}\n\nexport var Network = new NetInfo();\n","import AbstractRuntime from 'runtimes/interface';\nimport { AuthTransport } from 'core/auth/auth_transports';\nimport {\n AuthRequestType,\n AuthTransportCallback,\n InternalAuthOptions\n} from 'core/auth/options';\nimport { HTTPAuthError } from 'core/errors';\n\nvar fetchAuth: AuthTransport = function(\n context: AbstractRuntime,\n query: string,\n authOptions: InternalAuthOptions,\n authRequestType: AuthRequestType,\n callback: AuthTransportCallback\n) {\n var headers = new Headers();\n headers.set('Content-Type', 'application/x-www-form-urlencoded');\n\n for (var headerName in authOptions.headers) {\n headers.set(headerName, authOptions.headers[headerName]);\n }\n\n if (authOptions.headersProvider != null) {\n const dynamicHeaders = authOptions.headersProvider();\n for (var headerName in dynamicHeaders) {\n headers.set(headerName, dynamicHeaders[headerName]);\n }\n }\n\n var body = query;\n var request = new Request(authOptions.endpoint, {\n headers,\n body,\n credentials: 'same-origin',\n method: 'POST'\n });\n\n return fetch(request)\n .then(response => {\n let { status } = response;\n if (status === 200) {\n // manually parse the json so we can provide a more helpful error in\n // failure case\n return response.text();\n }\n throw new HTTPAuthError(\n status,\n `Could not get ${authRequestType.toString()} info from your auth endpoint, status: ${status}`\n );\n })\n .then(data => {\n let parsedData;\n try {\n parsedData = JSON.parse(data);\n } catch (e) {\n throw new HTTPAuthError(\n 200,\n `JSON returned from ${authRequestType.toString()} endpoint was invalid, yet status code was 200. Data was: ${data}`\n );\n }\n callback(null, parsedData);\n })\n .catch(err => {\n callback(err, null);\n });\n};\n\nexport default fetchAuth;\n","import Logger from 'core/logger';\nimport TimelineSender from 'core/timeline/timeline_sender';\nimport * as Collections from 'core/utils/collections';\nimport Util from 'core/util';\nimport Runtime from 'runtime';\nimport TimelineTransport from 'core/timeline/timeline_transport';\n\nvar getAgent = function(sender: TimelineSender, useTLS: boolean) {\n return function(data: any, callback: Function) {\n var scheme = 'http' + (useTLS ? 's' : '') + '://';\n var url =\n scheme + (sender.host || sender.options.host) + sender.options.path;\n var query = Collections.buildQueryString(data);\n url += '/' + 2 + '?' + query;\n\n fetch(url)\n .then(response => {\n if (response.status !== 200) {\n throw `received ${response.status} from stats.pusher.com`;\n }\n return response.json();\n })\n .then(({ host }) => {\n if (host) {\n sender.host = host;\n }\n })\n .catch(err => {\n Logger.debug('TimelineSender Error: ', err);\n });\n };\n};\n\nvar fetchTimeline = {\n name: 'xhr',\n getAgent\n};\n\nexport default fetchTimeline;\n","import Isomorphic from 'isomorphic/runtime';\nimport Runtime from '../interface';\nimport { Network } from './net_info';\nimport fetchAuth from './auth/fetch_auth';\nimport { AuthTransports } from 'core/auth/auth_transports';\nimport fetchTimeline from './timeline/fetch_timeline';\n\n// Very verbose but until unavoidable until\n// TypeScript 2.1, when spread attributes will be\n// supported\nconst {\n getDefaultStrategy,\n Transports,\n setup,\n getProtocol,\n isXHRSupported,\n getLocalStorage,\n createXHR,\n createWebSocket,\n addUnloadListener,\n removeUnloadListener,\n transportConnectionInitializer,\n createSocketRequest,\n HTTPFactory\n} = Isomorphic;\n\nconst Worker: Runtime = {\n getDefaultStrategy,\n Transports,\n setup,\n getProtocol,\n isXHRSupported,\n getLocalStorage,\n createXHR,\n createWebSocket,\n addUnloadListener,\n removeUnloadListener,\n transportConnectionInitializer,\n createSocketRequest,\n HTTPFactory,\n\n TimelineTransport: fetchTimeline,\n\n getAuthorizers(): AuthTransports {\n return { ajax: fetchAuth };\n },\n\n getWebSocketAPI() {\n return WebSocket;\n },\n\n getXHRAPI() {\n return XMLHttpRequest;\n },\n\n getNetwork() {\n return Network;\n },\n\n randomInt(max: number): number {\n /**\n * Return values in the range of [0, 1[\n */\n const random = function() {\n const crypto = globalThis.crypto || globalThis['msCrypto'];\n const random = crypto.getRandomValues(new Uint32Array(1))[0];\n\n return random / 2 ** 32;\n };\n\n return Math.floor(random() * max);\n }\n};\n\nexport default Worker;\n","enum TimelineLevel {\n ERROR = 3,\n INFO = 6,\n DEBUG = 7\n}\n\nexport default TimelineLevel;\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport { default as Level } from './level';\n\nexport interface TimelineOptions {\n level?: Level;\n limit?: number;\n version?: string;\n cluster?: string;\n features?: string[];\n params?: any;\n}\n\nexport default class Timeline {\n key: string;\n session: number;\n events: any[];\n options: TimelineOptions;\n sent: number;\n uniqueID: number;\n\n constructor(key: string, session: number, options: TimelineOptions) {\n this.key = key;\n this.session = session;\n this.events = [];\n this.options = options || {};\n this.sent = 0;\n this.uniqueID = 0;\n }\n\n log(level, event) {\n if (level <= this.options.level) {\n this.events.push(\n Collections.extend({}, event, { timestamp: Util.now() })\n );\n if (this.options.limit && this.events.length > this.options.limit) {\n this.events.shift();\n }\n }\n }\n\n error(event) {\n this.log(Level.ERROR, event);\n }\n\n info(event) {\n this.log(Level.INFO, event);\n }\n\n debug(event) {\n this.log(Level.DEBUG, event);\n }\n\n isEmpty() {\n return this.events.length === 0;\n }\n\n send(sendfn, callback) {\n var data = Collections.extend(\n {\n session: this.session,\n bundle: this.sent + 1,\n key: this.key,\n lib: 'js',\n version: this.options.version,\n cluster: this.options.cluster,\n features: this.options.features,\n timeline: this.events\n },\n this.options.params\n );\n\n this.events = [];\n sendfn(data, (error, result) => {\n if (!error) {\n this.sent++;\n }\n if (callback) {\n callback(error, result);\n }\n });\n\n return true;\n }\n\n generateUniqueID(): number {\n this.uniqueID++;\n return this.uniqueID;\n }\n}\n","import Factory from '../utils/factory';\nimport Util from '../util';\nimport * as Errors from '../errors';\nimport * as Collections from '../utils/collections';\nimport Strategy from './strategy';\nimport Transport from '../transports/transport';\nimport StrategyOptions from './strategy_options';\nimport Handshake from '../connection/handshake';\n\n/** Provides a strategy interface for transports.\n *\n * @param {String} name\n * @param {Number} priority\n * @param {Class} transport\n * @param {Object} options\n */\nexport default class TransportStrategy implements Strategy {\n name: string;\n priority: number;\n transport: Transport;\n options: StrategyOptions;\n\n constructor(\n name: string,\n priority: number,\n transport: Transport,\n options: StrategyOptions\n ) {\n this.name = name;\n this.priority = priority;\n this.transport = transport;\n this.options = options || {};\n }\n\n /** Returns whether the transport is supported in the browser.\n *\n * @returns {Boolean}\n */\n isSupported(): boolean {\n return this.transport.isSupported({\n useTLS: this.options.useTLS\n });\n }\n\n /** Launches a connection attempt and returns a strategy runner.\n *\n * @param {Function} callback\n * @return {Object} strategy runner\n */\n connect(minPriority: number, callback: Function) {\n if (!this.isSupported()) {\n return failAttempt(new Errors.UnsupportedStrategy(), callback);\n } else if (this.priority < minPriority) {\n return failAttempt(new Errors.TransportPriorityTooLow(), callback);\n }\n\n var connected = false;\n var transport = this.transport.createConnection(\n this.name,\n this.priority,\n this.options.key,\n this.options\n );\n var handshake = null;\n\n var onInitialized = function() {\n transport.unbind('initialized', onInitialized);\n transport.connect();\n };\n var onOpen = function() {\n handshake = Factory.createHandshake(transport, function(result) {\n connected = true;\n unbindListeners();\n callback(null, result);\n });\n };\n var onError = function(error) {\n unbindListeners();\n callback(error);\n };\n var onClosed = function() {\n unbindListeners();\n var serializedTransport;\n\n // The reason for this try/catch block is that on React Native\n // the WebSocket object is circular. Therefore transport.socket will\n // throw errors upon stringification. Collections.safeJSONStringify\n // discards circular references when serializing.\n serializedTransport = Collections.safeJSONStringify(transport);\n callback(new Errors.TransportClosed(serializedTransport));\n };\n\n var unbindListeners = function() {\n transport.unbind('initialized', onInitialized);\n transport.unbind('open', onOpen);\n transport.unbind('error', onError);\n transport.unbind('closed', onClosed);\n };\n\n transport.bind('initialized', onInitialized);\n transport.bind('open', onOpen);\n transport.bind('error', onError);\n transport.bind('closed', onClosed);\n\n // connect will be called automatically after initialization\n transport.initialize();\n\n return {\n abort: () => {\n if (connected) {\n return;\n }\n unbindListeners();\n if (handshake) {\n handshake.close();\n } else {\n transport.close();\n }\n },\n forceMinPriority: p => {\n if (connected) {\n return;\n }\n if (this.priority < p) {\n if (handshake) {\n handshake.close();\n } else {\n transport.close();\n }\n }\n }\n };\n }\n}\n\nfunction failAttempt(error: Error, callback: Function) {\n Util.defer(function() {\n callback(error);\n });\n return {\n abort: function() {},\n forceMinPriority: function() {}\n };\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport TransportManager from '../transports/transport_manager';\nimport * as Errors from '../errors';\nimport Strategy from './strategy';\nimport TransportStrategy from './transport_strategy';\nimport StrategyOptions from '../strategies/strategy_options';\nimport { Config } from '../config';\nimport Runtime from 'runtime';\n\nconst { Transports } = Runtime;\n\nexport var defineTransport = function(\n config: Config,\n name: string,\n type: string,\n priority: number,\n options: StrategyOptions,\n manager?: TransportManager\n): Strategy {\n var transportClass = Transports[type];\n if (!transportClass) {\n throw new Errors.UnsupportedTransport(type);\n }\n\n var enabled =\n (!config.enabledTransports ||\n Collections.arrayIndexOf(config.enabledTransports, name) !== -1) &&\n (!config.disabledTransports ||\n Collections.arrayIndexOf(config.disabledTransports, name) === -1);\n\n var transport;\n if (enabled) {\n options = Object.assign(\n { ignoreNullOrigin: config.ignoreNullOrigin },\n options\n );\n\n transport = new TransportStrategy(\n name,\n priority,\n manager ? manager.getAssistant(transportClass) : transportClass,\n options\n );\n } else {\n transport = UnsupportedStrategy;\n }\n\n return transport;\n};\n\nvar UnsupportedStrategy: Strategy = {\n isSupported: function() {\n return false;\n },\n connect: function(_, callback) {\n var deferred = Util.defer(function() {\n callback(new Errors.UnsupportedStrategy());\n });\n return {\n abort: function() {\n deferred.ensureAborted();\n },\n forceMinPriority: function() {}\n };\n }\n};\n","import ConnectionManager from './connection/connection_manager';\nimport {\n ChannelAuthorizationOptions,\n UserAuthenticationOptions\n} from './auth/options';\nimport {\n ChannelAuthorizerGenerator,\n DeprecatedAuthOptions\n} from './auth/deprecated_channel_authorizer';\nimport { AuthTransport, Transport } from './config';\nimport * as nacl from 'tweetnacl';\nimport Logger from './logger';\n\nexport interface Options {\n activityTimeout?: number;\n\n auth?: DeprecatedAuthOptions; // DEPRECATED use channelAuthorization instead\n authEndpoint?: string; // DEPRECATED use channelAuthorization instead\n authTransport?: AuthTransport; // DEPRECATED use channelAuthorization instead\n authorizer?: ChannelAuthorizerGenerator; // DEPRECATED use channelAuthorization instead\n\n channelAuthorization?: ChannelAuthorizationOptions;\n userAuthentication?: UserAuthenticationOptions;\n\n cluster: string;\n enableStats?: boolean;\n disableStats?: boolean;\n disabledTransports?: Transport[];\n enabledTransports?: Transport[];\n forceTLS?: boolean;\n httpHost?: string;\n httpPath?: string;\n httpPort?: number;\n httpsPort?: number;\n ignoreNullOrigin?: boolean;\n nacl?: nacl;\n pongTimeout?: number;\n statsHost?: string;\n timelineParams?: any;\n unavailableTimeout?: number;\n wsHost?: string;\n wsPath?: string;\n wsPort?: number;\n wssPort?: number;\n}\n\nexport interface ClusterOptions {\n appKey: string;\n cluster: string;\n}\n\nexport function validateOptions(options) {\n if (options == null) {\n throw 'You must pass an options object';\n }\n if (options.cluster == null) {\n throw 'Options object must provide a cluster';\n }\n if ('disableStats' in options) {\n Logger.warn(\n 'The disableStats option is deprecated in favor of enableStats'\n );\n }\n}\n","export enum AuthRequestType {\n UserAuthentication = 'user-authentication',\n ChannelAuthorization = 'channel-authorization'\n}\n\nexport interface ChannelAuthorizationData {\n auth: string;\n channel_data?: string;\n shared_secret?: string;\n}\n\nexport type ChannelAuthorizationCallback = (\n error: Error | null,\n authData: ChannelAuthorizationData | null\n) => void;\n\nexport interface ChannelAuthorizationRequestParams {\n socketId: string;\n channelName: string;\n}\n\nexport interface ChannelAuthorizationHandler {\n (\n params: ChannelAuthorizationRequestParams,\n callback: ChannelAuthorizationCallback\n ): void;\n}\n\nexport interface UserAuthenticationData {\n auth: string;\n user_data: string;\n}\n\nexport type UserAuthenticationCallback = (\n error: Error | null,\n authData: UserAuthenticationData | null\n) => void;\n\nexport interface UserAuthenticationRequestParams {\n socketId: string;\n}\n\nexport interface UserAuthenticationHandler {\n (\n params: UserAuthenticationRequestParams,\n callback: UserAuthenticationCallback\n ): void;\n}\n\nexport type AuthTransportCallback =\n | ChannelAuthorizationCallback\n | UserAuthenticationCallback;\n\nexport interface AuthOptionsT {\n transport: 'ajax' | 'jsonp';\n endpoint: string;\n params?: any;\n headers?: any;\n paramsProvider?: () => any;\n headersProvider?: () => any;\n customHandler?: AuthHandler;\n}\n\nexport declare type UserAuthenticationOptions = AuthOptionsT<\n UserAuthenticationHandler\n>;\nexport declare type ChannelAuthorizationOptions = AuthOptionsT<\n ChannelAuthorizationHandler\n>;\n\nexport interface InternalAuthOptions {\n transport: 'ajax' | 'jsonp';\n endpoint: string;\n params?: any;\n headers?: any;\n paramsProvider?: () => any;\n headersProvider?: () => any;\n}\n","import {\n UserAuthenticationCallback,\n InternalAuthOptions,\n UserAuthenticationHandler,\n UserAuthenticationRequestParams,\n AuthRequestType\n} from './options';\n\nimport Runtime from 'runtime';\n\nconst composeChannelQuery = (\n params: UserAuthenticationRequestParams,\n authOptions: InternalAuthOptions\n) => {\n var query = 'socket_id=' + encodeURIComponent(params.socketId);\n\n for (var key in authOptions.params) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(authOptions.params[key]);\n }\n\n if (authOptions.paramsProvider != null) {\n let dynamicParams = authOptions.paramsProvider();\n for (var key in dynamicParams) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(dynamicParams[key]);\n }\n }\n\n return query;\n};\n\nconst UserAuthenticator = (\n authOptions: InternalAuthOptions\n): UserAuthenticationHandler => {\n if (typeof Runtime.getAuthorizers()[authOptions.transport] === 'undefined') {\n throw `'${authOptions.transport}' is not a recognized auth transport`;\n }\n\n return (\n params: UserAuthenticationRequestParams,\n callback: UserAuthenticationCallback\n ) => {\n const query = composeChannelQuery(params, authOptions);\n\n Runtime.getAuthorizers()[authOptions.transport](\n Runtime,\n query,\n authOptions,\n AuthRequestType.UserAuthentication,\n callback\n );\n };\n};\n\nexport default UserAuthenticator;\n","import {\n AuthRequestType,\n InternalAuthOptions,\n ChannelAuthorizationHandler,\n ChannelAuthorizationRequestParams,\n ChannelAuthorizationCallback\n} from './options';\n\nimport Runtime from 'runtime';\n\nconst composeChannelQuery = (\n params: ChannelAuthorizationRequestParams,\n authOptions: InternalAuthOptions\n) => {\n var query = 'socket_id=' + encodeURIComponent(params.socketId);\n\n query += '&channel_name=' + encodeURIComponent(params.channelName);\n\n for (var key in authOptions.params) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(authOptions.params[key]);\n }\n\n if (authOptions.paramsProvider != null) {\n let dynamicParams = authOptions.paramsProvider();\n for (var key in dynamicParams) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(dynamicParams[key]);\n }\n }\n\n return query;\n};\n\nconst ChannelAuthorizer = (\n authOptions: InternalAuthOptions\n): ChannelAuthorizationHandler => {\n if (typeof Runtime.getAuthorizers()[authOptions.transport] === 'undefined') {\n throw `'${authOptions.transport}' is not a recognized auth transport`;\n }\n\n return (\n params: ChannelAuthorizationRequestParams,\n callback: ChannelAuthorizationCallback\n ) => {\n const query = composeChannelQuery(params, authOptions);\n\n Runtime.getAuthorizers()[authOptions.transport](\n Runtime,\n query,\n authOptions,\n AuthRequestType.ChannelAuthorization,\n callback\n );\n };\n};\n\nexport default ChannelAuthorizer;\n","import Channel from '../channels/channel';\nimport {\n ChannelAuthorizationCallback,\n ChannelAuthorizationHandler,\n ChannelAuthorizationRequestParams,\n InternalAuthOptions\n} from './options';\n\nexport interface DeprecatedChannelAuthorizer {\n authorize(socketId: string, callback: ChannelAuthorizationCallback): void;\n}\n\nexport interface ChannelAuthorizerGenerator {\n (\n channel: Channel,\n options: DeprecatedAuthorizerOptions\n ): DeprecatedChannelAuthorizer;\n}\n\nexport interface DeprecatedAuthOptions {\n params?: any;\n headers?: any;\n}\n\nexport interface DeprecatedAuthorizerOptions {\n authTransport: 'ajax' | 'jsonp';\n authEndpoint: string;\n auth?: DeprecatedAuthOptions;\n}\n\nexport const ChannelAuthorizerProxy = (\n pusher,\n authOptions: InternalAuthOptions,\n channelAuthorizerGenerator: ChannelAuthorizerGenerator\n): ChannelAuthorizationHandler => {\n const deprecatedAuthorizerOptions: DeprecatedAuthorizerOptions = {\n authTransport: authOptions.transport,\n authEndpoint: authOptions.endpoint,\n auth: {\n params: authOptions.params,\n headers: authOptions.headers\n }\n };\n return (\n params: ChannelAuthorizationRequestParams,\n callback: ChannelAuthorizationCallback\n ) => {\n const channel = pusher.channel(params.channelName);\n // This line creates a new channel authorizer every time.\n // In the past, this was only done once per channel and reused.\n // We can do that again if we want to keep this behavior intact.\n const channelAuthorizer: DeprecatedChannelAuthorizer = channelAuthorizerGenerator(\n channel,\n deprecatedAuthorizerOptions\n );\n channelAuthorizer.authorize(params.socketId, callback);\n };\n};\n","import { Options } from './options';\nimport Defaults from './defaults';\nimport {\n ChannelAuthorizationHandler,\n UserAuthenticationHandler,\n ChannelAuthorizationOptions\n} from './auth/options';\nimport UserAuthenticator from './auth/user_authenticator';\nimport ChannelAuthorizer from './auth/channel_authorizer';\nimport { ChannelAuthorizerProxy } from './auth/deprecated_channel_authorizer';\nimport Runtime from 'runtime';\nimport * as nacl from 'tweetnacl';\n\nexport type AuthTransport = 'ajax' | 'jsonp';\nexport type Transport =\n | 'ws'\n | 'wss'\n | 'xhr_streaming'\n | 'xhr_polling'\n | 'sockjs';\n\nexport interface Config {\n // these are all 'required' config parameters, it's not necessary for the user\n // to set them, but they have configured defaults.\n activityTimeout: number;\n enableStats: boolean;\n httpHost: string;\n httpPath: string;\n httpPort: number;\n httpsPort: number;\n pongTimeout: number;\n statsHost: string;\n unavailableTimeout: number;\n useTLS: boolean;\n wsHost: string;\n wsPath: string;\n wsPort: number;\n wssPort: number;\n userAuthenticator: UserAuthenticationHandler;\n channelAuthorizer: ChannelAuthorizationHandler;\n\n // these are all optional parameters or overrrides. The customer can set these\n // but it's not strictly necessary\n forceTLS?: boolean;\n cluster?: string;\n disabledTransports?: Transport[];\n enabledTransports?: Transport[];\n ignoreNullOrigin?: boolean;\n nacl?: nacl;\n timelineParams?: any;\n}\n\n// getConfig mainly sets the defaults for the options that are not provided\nexport function getConfig(opts: Options, pusher): Config {\n let config: Config = {\n activityTimeout: opts.activityTimeout || Defaults.activityTimeout,\n cluster: opts.cluster,\n httpPath: opts.httpPath || Defaults.httpPath,\n httpPort: opts.httpPort || Defaults.httpPort,\n httpsPort: opts.httpsPort || Defaults.httpsPort,\n pongTimeout: opts.pongTimeout || Defaults.pongTimeout,\n statsHost: opts.statsHost || Defaults.stats_host,\n unavailableTimeout: opts.unavailableTimeout || Defaults.unavailableTimeout,\n wsPath: opts.wsPath || Defaults.wsPath,\n wsPort: opts.wsPort || Defaults.wsPort,\n wssPort: opts.wssPort || Defaults.wssPort,\n\n enableStats: getEnableStatsConfig(opts),\n httpHost: getHttpHost(opts),\n useTLS: shouldUseTLS(opts),\n wsHost: getWebsocketHost(opts),\n\n userAuthenticator: buildUserAuthenticator(opts),\n channelAuthorizer: buildChannelAuthorizer(opts, pusher)\n };\n\n if ('disabledTransports' in opts)\n config.disabledTransports = opts.disabledTransports;\n if ('enabledTransports' in opts)\n config.enabledTransports = opts.enabledTransports;\n if ('ignoreNullOrigin' in opts)\n config.ignoreNullOrigin = opts.ignoreNullOrigin;\n if ('timelineParams' in opts) config.timelineParams = opts.timelineParams;\n if ('nacl' in opts) {\n config.nacl = opts.nacl;\n }\n\n return config;\n}\n\nfunction getHttpHost(opts: Options): string {\n if (opts.httpHost) {\n return opts.httpHost;\n }\n if (opts.cluster) {\n return `sockjs-${opts.cluster}.pusher.com`;\n }\n return Defaults.httpHost;\n}\n\nfunction getWebsocketHost(opts: Options): string {\n if (opts.wsHost) {\n return opts.wsHost;\n }\n return getWebsocketHostFromCluster(opts.cluster);\n}\n\nfunction getWebsocketHostFromCluster(cluster: string): string {\n return `ws-${cluster}.pusher.com`;\n}\n\nfunction shouldUseTLS(opts: Options): boolean {\n if (Runtime.getProtocol() === 'https:') {\n return true;\n } else if (opts.forceTLS === false) {\n return false;\n }\n return true;\n}\n\n// if enableStats is set take the value\n// if disableStats is set take the inverse\n// otherwise default to false\nfunction getEnableStatsConfig(opts: Options): boolean {\n if ('enableStats' in opts) {\n return opts.enableStats;\n }\n if ('disableStats' in opts) {\n return !opts.disableStats;\n }\n return false;\n}\n\nfunction buildUserAuthenticator(opts: Options): UserAuthenticationHandler {\n const userAuthentication = {\n ...Defaults.userAuthentication,\n ...opts.userAuthentication\n };\n if (\n 'customHandler' in userAuthentication &&\n userAuthentication['customHandler'] != null\n ) {\n return userAuthentication['customHandler'];\n }\n\n return UserAuthenticator(userAuthentication);\n}\n\nfunction buildChannelAuth(opts: Options, pusher): ChannelAuthorizationOptions {\n let channelAuthorization: ChannelAuthorizationOptions;\n if ('channelAuthorization' in opts) {\n channelAuthorization = {\n ...Defaults.channelAuthorization,\n ...opts.channelAuthorization\n };\n } else {\n channelAuthorization = {\n transport: opts.authTransport || Defaults.authTransport,\n endpoint: opts.authEndpoint || Defaults.authEndpoint\n };\n if ('auth' in opts) {\n if ('params' in opts.auth) channelAuthorization.params = opts.auth.params;\n if ('headers' in opts.auth)\n channelAuthorization.headers = opts.auth.headers;\n }\n if ('authorizer' in opts)\n channelAuthorization.customHandler = ChannelAuthorizerProxy(\n pusher,\n channelAuthorization,\n opts.authorizer\n );\n }\n return channelAuthorization;\n}\n\nfunction buildChannelAuthorizer(\n opts: Options,\n pusher\n): ChannelAuthorizationHandler {\n const channelAuthorization = buildChannelAuth(opts, pusher);\n if (\n 'customHandler' in channelAuthorization &&\n channelAuthorization['customHandler'] != null\n ) {\n return channelAuthorization['customHandler'];\n }\n\n return ChannelAuthorizer(channelAuthorization);\n}\n","import Logger from './logger';\nimport Pusher from './pusher';\nimport EventsDispatcher from './events/dispatcher';\n\nexport default class WatchlistFacade extends EventsDispatcher {\n private pusher: Pusher;\n\n public constructor(pusher: Pusher) {\n super(function(eventName, data) {\n Logger.debug(`No callbacks on watchlist events for ${eventName}`);\n });\n\n this.pusher = pusher;\n this.bindWatchlistInternalEvent();\n }\n\n handleEvent(pusherEvent) {\n pusherEvent.data.events.forEach(watchlistEvent => {\n this.emit(watchlistEvent.name, watchlistEvent);\n });\n }\n\n private bindWatchlistInternalEvent() {\n this.pusher.connection.bind('message', pusherEvent => {\n var eventName = pusherEvent.event;\n if (eventName === 'pusher_internal:watchlist_events') {\n this.handleEvent(pusherEvent);\n }\n });\n }\n}\n","function flatPromise() {\n let resolve, reject;\n const promise = new Promise((res, rej) => {\n resolve = res;\n reject = rej;\n });\n return { promise, resolve, reject };\n}\n\nexport default flatPromise;\n","import Pusher from './pusher';\nimport Logger from './logger';\nimport {\n UserAuthenticationData,\n UserAuthenticationCallback\n} from './auth/options';\nimport Channel from './channels/channel';\nimport WatchlistFacade from './watchlist';\nimport EventsDispatcher from './events/dispatcher';\nimport flatPromise from './utils/flat_promise';\n\nexport default class UserFacade extends EventsDispatcher {\n pusher: Pusher;\n signin_requested: boolean = false;\n user_data: any = null;\n serverToUserChannel: Channel = null;\n signinDonePromise: Promise = null;\n watchlist: WatchlistFacade;\n private _signinDoneResolve: Function = null;\n\n public constructor(pusher: Pusher) {\n super(function(eventName, data) {\n Logger.debug('No callbacks on user for ' + eventName);\n });\n this.pusher = pusher;\n this.pusher.connection.bind('state_change', ({ previous, current }) => {\n if (previous !== 'connected' && current === 'connected') {\n this._signin();\n }\n if (previous === 'connected' && current !== 'connected') {\n this._cleanup();\n this._newSigninPromiseIfNeeded();\n }\n });\n\n this.watchlist = new WatchlistFacade(pusher);\n\n this.pusher.connection.bind('message', event => {\n var eventName = event.event;\n if (eventName === 'pusher:signin_success') {\n this._onSigninSuccess(event.data);\n }\n if (\n this.serverToUserChannel &&\n this.serverToUserChannel.name === event.channel\n ) {\n this.serverToUserChannel.handleEvent(event);\n }\n });\n }\n\n public signin() {\n if (this.signin_requested) {\n return;\n }\n\n this.signin_requested = true;\n this._signin();\n }\n\n private _signin() {\n if (!this.signin_requested) {\n return;\n }\n\n this._newSigninPromiseIfNeeded();\n\n if (this.pusher.connection.state !== 'connected') {\n // Signin will be attempted when the connection is connected\n return;\n }\n\n this.pusher.config.userAuthenticator(\n {\n socketId: this.pusher.connection.socket_id\n },\n this._onAuthorize\n );\n }\n\n private _onAuthorize: UserAuthenticationCallback = (\n err,\n authData: UserAuthenticationData\n ) => {\n if (err) {\n Logger.warn(`Error during signin: ${err}`);\n this._cleanup();\n return;\n }\n\n this.pusher.send_event('pusher:signin', {\n auth: authData.auth,\n user_data: authData.user_data\n });\n\n // Later when we get pusher:singin_success event, the user will be marked as signed in\n };\n\n private _onSigninSuccess(data: any) {\n try {\n this.user_data = JSON.parse(data.user_data);\n } catch (e) {\n Logger.error(`Failed parsing user data after signin: ${data.user_data}`);\n this._cleanup();\n return;\n }\n\n if (typeof this.user_data.id !== 'string' || this.user_data.id === '') {\n Logger.error(\n `user_data doesn't contain an id. user_data: ${this.user_data}`\n );\n this._cleanup();\n return;\n }\n\n // Signin succeeded\n this._signinDoneResolve();\n this._subscribeChannels();\n }\n\n private _subscribeChannels() {\n const ensure_subscribed = channel => {\n if (channel.subscriptionPending && channel.subscriptionCancelled) {\n channel.reinstateSubscription();\n } else if (\n !channel.subscriptionPending &&\n this.pusher.connection.state === 'connected'\n ) {\n channel.subscribe();\n }\n };\n\n this.serverToUserChannel = new Channel(\n `#server-to-user-${this.user_data.id}`,\n this.pusher\n );\n this.serverToUserChannel.bind_global((eventName, data) => {\n if (\n eventName.indexOf('pusher_internal:') === 0 ||\n eventName.indexOf('pusher:') === 0\n ) {\n // ignore internal events\n return;\n }\n this.emit(eventName, data);\n });\n ensure_subscribed(this.serverToUserChannel);\n }\n\n private _cleanup() {\n this.user_data = null;\n if (this.serverToUserChannel) {\n this.serverToUserChannel.unbind_all();\n this.serverToUserChannel.disconnect();\n this.serverToUserChannel = null;\n }\n\n if (this.signin_requested) {\n // If signin is in progress and cleanup is called,\n // Mark the current signin process as done.\n this._signinDoneResolve();\n }\n }\n\n private _newSigninPromiseIfNeeded() {\n if (!this.signin_requested) {\n return;\n }\n\n // If there is a promise and it is not resolved, return without creating a new one.\n if (this.signinDonePromise && !(this.signinDonePromise as any).done) {\n return;\n }\n\n // This promise is never rejected.\n // It gets resolved when the signin process is done whether it failed or succeeded\n const { promise, resolve, reject: _ } = flatPromise();\n (promise as any).done = false;\n const setDone = () => {\n (promise as any).done = true;\n };\n promise.then(setDone).catch(setDone);\n this.signinDonePromise = promise;\n this._signinDoneResolve = resolve;\n }\n}\n","import AbstractRuntime from '../runtimes/interface';\nimport Runtime from 'runtime';\nimport * as Collections from './utils/collections';\nimport Channels from './channels/channels';\nimport Channel from './channels/channel';\nimport { default as EventsDispatcher } from './events/dispatcher';\nimport Timeline from './timeline/timeline';\nimport TimelineSender from './timeline/timeline_sender';\nimport TimelineLevel from './timeline/level';\nimport { defineTransport } from './strategies/strategy_builder';\nimport ConnectionManager from './connection/connection_manager';\nimport { PeriodicTimer } from './utils/timers';\nimport Defaults from './defaults';\nimport Logger from './logger';\nimport Factory from './utils/factory';\nimport { Options, ClusterOptions, validateOptions } from './options';\nimport { Config, getConfig } from './config';\nimport StrategyOptions from './strategies/strategy_options';\nimport UserFacade from './user';\n\nexport default class Pusher {\n /* STATIC PROPERTIES */\n static instances: Pusher[] = [];\n static isReady: boolean = false;\n static logToConsole: boolean = false;\n\n // for jsonp\n static Runtime: AbstractRuntime = Runtime;\n static ScriptReceivers: any = (Runtime).ScriptReceivers;\n static DependenciesReceivers: any = (Runtime).DependenciesReceivers;\n static auth_callbacks: any = (Runtime).auth_callbacks;\n\n static ready() {\n Pusher.isReady = true;\n for (var i = 0, l = Pusher.instances.length; i < l; i++) {\n Pusher.instances[i].connect();\n }\n }\n\n static log: (message: any) => void;\n\n private static getClientFeatures(): string[] {\n return Collections.keys(\n Collections.filterObject({ ws: Runtime.Transports.ws }, function(t) {\n return t.isSupported({});\n })\n );\n }\n\n /* INSTANCE PROPERTIES */\n key: string;\n options: Options;\n config: Config;\n channels: Channels;\n global_emitter: EventsDispatcher;\n sessionID: number;\n timeline: Timeline;\n timelineSender: TimelineSender;\n connection: ConnectionManager;\n timelineSenderTimer: PeriodicTimer;\n user: UserFacade;\n constructor(app_key: string, options: Options) {\n checkAppKey(app_key);\n validateOptions(options);\n this.key = app_key;\n this.config = getConfig(options, this);\n\n this.channels = Factory.createChannels();\n this.global_emitter = new EventsDispatcher();\n this.sessionID = Runtime.randomInt(1000000000);\n\n this.timeline = new Timeline(this.key, this.sessionID, {\n cluster: this.config.cluster,\n features: Pusher.getClientFeatures(),\n params: this.config.timelineParams || {},\n limit: 50,\n level: TimelineLevel.INFO,\n version: Defaults.VERSION\n });\n if (this.config.enableStats) {\n this.timelineSender = Factory.createTimelineSender(this.timeline, {\n host: this.config.statsHost,\n path: '/timeline/v2/' + Runtime.TimelineTransport.name\n });\n }\n\n var getStrategy = (options: StrategyOptions) => {\n return Runtime.getDefaultStrategy(this.config, options, defineTransport);\n };\n\n this.connection = Factory.createConnectionManager(this.key, {\n getStrategy: getStrategy,\n timeline: this.timeline,\n activityTimeout: this.config.activityTimeout,\n pongTimeout: this.config.pongTimeout,\n unavailableTimeout: this.config.unavailableTimeout,\n useTLS: Boolean(this.config.useTLS)\n });\n\n this.connection.bind('connected', () => {\n this.subscribeAll();\n if (this.timelineSender) {\n this.timelineSender.send(this.connection.isUsingTLS());\n }\n });\n\n this.connection.bind('message', event => {\n var eventName = event.event;\n var internal = eventName.indexOf('pusher_internal:') === 0;\n if (event.channel) {\n var channel = this.channel(event.channel);\n if (channel) {\n channel.handleEvent(event);\n }\n }\n // Emit globally [deprecated]\n if (!internal) {\n this.global_emitter.emit(event.event, event.data);\n }\n });\n this.connection.bind('connecting', () => {\n this.channels.disconnect();\n });\n this.connection.bind('disconnected', () => {\n this.channels.disconnect();\n });\n this.connection.bind('error', err => {\n Logger.warn(err);\n });\n\n Pusher.instances.push(this);\n this.timeline.info({ instances: Pusher.instances.length });\n\n this.user = new UserFacade(this);\n\n if (Pusher.isReady) {\n this.connect();\n }\n }\n\n /**\n * Allows you to switch Pusher cluster without\n * losing all the channels/subscription binding\n * as this is internally managed by the SDK.\n */\n switchCluster(options: ClusterOptions) {\n const { appKey, cluster } = options;\n this.key = appKey;\n this.options = { ...this.options, cluster };\n this.config = getConfig(this.options, this);\n this.connection.switchCluster(this.key);\n }\n\n channel(name: string): Channel {\n return this.channels.find(name);\n }\n\n allChannels(): Channel[] {\n return this.channels.all();\n }\n\n connect() {\n this.connection.connect();\n\n if (this.timelineSender) {\n if (!this.timelineSenderTimer) {\n var usingTLS = this.connection.isUsingTLS();\n var timelineSender = this.timelineSender;\n this.timelineSenderTimer = new PeriodicTimer(60000, function() {\n timelineSender.send(usingTLS);\n });\n }\n }\n }\n\n disconnect() {\n this.connection.disconnect();\n\n if (this.timelineSenderTimer) {\n this.timelineSenderTimer.ensureAborted();\n this.timelineSenderTimer = null;\n }\n }\n\n bind(event_name: string, callback: Function, context?: any): Pusher {\n this.global_emitter.bind(event_name, callback, context);\n return this;\n }\n\n unbind(event_name?: string, callback?: Function, context?: any): Pusher {\n this.global_emitter.unbind(event_name, callback, context);\n return this;\n }\n\n bind_global(callback: Function): Pusher {\n this.global_emitter.bind_global(callback);\n return this;\n }\n\n unbind_global(callback?: Function): Pusher {\n this.global_emitter.unbind_global(callback);\n return this;\n }\n\n unbind_all(callback?: Function): Pusher {\n this.global_emitter.unbind_all();\n return this;\n }\n\n subscribeAll() {\n var channelName;\n for (channelName in this.channels.channels) {\n if (this.channels.channels.hasOwnProperty(channelName)) {\n this.subscribe(channelName);\n }\n }\n }\n\n subscribe(channel_name: string) {\n var channel = this.channels.add(channel_name, this);\n if (channel.subscriptionPending && channel.subscriptionCancelled) {\n channel.reinstateSubscription();\n } else if (\n !channel.subscriptionPending &&\n this.connection.state === 'connected'\n ) {\n channel.subscribe();\n }\n return channel;\n }\n\n unsubscribe(channel_name: string) {\n var channel = this.channels.find(channel_name);\n if (channel && channel.subscriptionPending) {\n channel.cancelSubscription();\n } else {\n channel = this.channels.remove(channel_name);\n if (channel && channel.subscribed) {\n channel.unsubscribe();\n }\n }\n }\n\n send_event(event_name: string, data: any, channel?: string) {\n return this.connection.send_event(event_name, data, channel);\n }\n\n shouldUseTLS(): boolean {\n return this.config.useTLS;\n }\n\n signin() {\n this.user.signin();\n }\n}\n\nfunction checkAppKey(key) {\n if (key === null || key === undefined) {\n throw 'You must pass your app key when you instantiate Pusher.';\n }\n}\n\nRuntime.setup(Pusher);\n"],"sourceRoot":""} \ No newline at end of file diff --git a/dist/worker/pusher.worker.min.js b/dist/worker/pusher.worker.min.js index ef2452dc3..192d42c06 100644 --- a/dist/worker/pusher.worker.min.js +++ b/dist/worker/pusher.worker.min.js @@ -1,9 +1,9 @@ /*! - * Pusher JavaScript Library v8.3.0 + * Pusher JavaScript Library v8.4.0 * https://pusher.com/ * * Copyright 2020, Pusher * Released under the MIT licence. */ -!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.Pusher=e():t.Pusher=e()}(this,(function(){return function(t){var e={};function n(i){if(e[i])return e[i].exports;var s=e[i]={i:i,l:!1,exports:{}};return t[i].call(s.exports,s,s.exports,n),s.l=!0,s.exports}return n.m=t,n.c=e,n.d=function(t,e,i){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:i})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var i=Object.create(null);if(n.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var s in t)n.d(i,s,function(e){return t[e]}.bind(null,s));return i},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=2)}([function(t,e,n){"use strict";var i,s=this&&this.__extends||(i=function(t,e){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)},function(t,e){function n(){this.constructor=t}i(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)});Object.defineProperty(e,"__esModule",{value:!0});var r=function(){function t(t){void 0===t&&(t="="),this._paddingCharacter=t}return t.prototype.encodedLength=function(t){return this._paddingCharacter?(t+2)/3*4|0:(8*t+5)/6|0},t.prototype.encode=function(t){for(var e="",n=0;n>>18&63),e+=this._encodeByte(i>>>12&63),e+=this._encodeByte(i>>>6&63),e+=this._encodeByte(i>>>0&63)}var s=t.length-n;if(s>0){i=t[n]<<16|(2===s?t[n+1]<<8:0);e+=this._encodeByte(i>>>18&63),e+=this._encodeByte(i>>>12&63),e+=2===s?this._encodeByte(i>>>6&63):this._paddingCharacter||"",e+=this._paddingCharacter||""}return e},t.prototype.maxDecodedLength=function(t){return this._paddingCharacter?t/4*3|0:(6*t+7)/8|0},t.prototype.decodedLength=function(t){return this.maxDecodedLength(t.length-this._getPaddingLength(t))},t.prototype.decode=function(t){if(0===t.length)return new Uint8Array(0);for(var e=this._getPaddingLength(t),n=t.length-e,i=new Uint8Array(this.maxDecodedLength(n)),s=0,r=0,o=0,a=0,c=0,h=0,u=0;r>>4,i[s++]=c<<4|h>>>2,i[s++]=h<<6|u,o|=256&a,o|=256&c,o|=256&h,o|=256&u;if(r>>4,o|=256&a,o|=256&c),r>>2,o|=256&h),r>>8&6,e+=51-t>>>8&-75,e+=61-t>>>8&-15,e+=62-t>>>8&3,String.fromCharCode(e)},t.prototype._decodeChar=function(t){var e=256;return e+=(42-t&t-44)>>>8&-256+t-43+62,e+=(46-t&t-48)>>>8&-256+t-47+63,e+=(47-t&t-58)>>>8&-256+t-48+52,e+=(64-t&t-91)>>>8&-256+t-65+0,e+=(96-t&t-123)>>>8&-256+t-97+26},t.prototype._getPaddingLength=function(t){var e=0;if(this._paddingCharacter){for(var n=t.length-1;n>=0&&t[n]===this._paddingCharacter;n--)e++;if(t.length<4||e>2)throw new Error("Base64Coder: incorrect padding")}return e},t}();e.Coder=r;var o=new r;e.encode=function(t){return o.encode(t)},e.decode=function(t){return o.decode(t)};var a=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return s(e,t),e.prototype._encodeByte=function(t){var e=t;return e+=65,e+=25-t>>>8&6,e+=51-t>>>8&-75,e+=61-t>>>8&-13,e+=62-t>>>8&49,String.fromCharCode(e)},e.prototype._decodeChar=function(t){var e=256;return e+=(44-t&t-46)>>>8&-256+t-45+62,e+=(94-t&t-96)>>>8&-256+t-95+63,e+=(47-t&t-58)>>>8&-256+t-48+52,e+=(64-t&t-91)>>>8&-256+t-65+0,e+=(96-t&t-123)>>>8&-256+t-97+26},e}(r);e.URLSafeCoder=a;var c=new a;e.encodeURLSafe=function(t){return c.encode(t)},e.decodeURLSafe=function(t){return c.decode(t)},e.encodedLength=function(t){return o.encodedLength(t)},e.maxDecodedLength=function(t){return o.maxDecodedLength(t)},e.decodedLength=function(t){return o.decodedLength(t)}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i="utf8: invalid source encoding";function s(t){for(var e=0,n=0;n=t.length-1)throw new Error("utf8: invalid string");n++,e+=4}}return e}e.encode=function(t){for(var e=new Uint8Array(s(t)),n=0,i=0;i>6,e[n++]=128|63&r):r<55296?(e[n++]=224|r>>12,e[n++]=128|r>>6&63,e[n++]=128|63&r):(i++,r=(1023&r)<<10,r|=1023&t.charCodeAt(i),r+=65536,e[n++]=240|r>>18,e[n++]=128|r>>12&63,e[n++]=128|r>>6&63,e[n++]=128|63&r)}return e},e.encodedLength=s,e.decode=function(t){for(var e=[],n=0;n=t.length)throw new Error(i);if(128!=(192&(o=t[++n])))throw new Error(i);s=(31&s)<<6|63&o,r=128}else if(s<240){if(n>=t.length-1)throw new Error(i);var o=t[++n],a=t[++n];if(128!=(192&o)||128!=(192&a))throw new Error(i);s=(15&s)<<12|(63&o)<<6|63&a,r=2048}else{if(!(s<248))throw new Error(i);if(n>=t.length-2)throw new Error(i);o=t[++n],a=t[++n];var c=t[++n];if(128!=(192&o)||128!=(192&a)||128!=(192&c))throw new Error(i);s=(15&s)<<18|(63&o)<<12|(63&a)<<6|63&c,r=65536}if(s=55296&&s<=57343)throw new Error(i);if(s>=65536){if(s>1114111)throw new Error(i);s-=65536,e.push(String.fromCharCode(55296|s>>10)),s=56320|1023&s}}e.push(String.fromCharCode(s))}return e.join("")}},function(t,e,n){t.exports=n(3).default},function(t,e,n){"use strict";n.r(e);for(var i=String.fromCharCode,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",r={},o=0,a=s.length;o>>6)+i(128|63&e):i(224|e>>>12&15)+i(128|e>>>6&63)+i(128|63&e)},h=function(t){return t.replace(/[^\x00-\x7F]/g,c)},u=function(t){var e=[0,2,1][t.length%3],n=t.charCodeAt(0)<<16|(t.length>1?t.charCodeAt(1):0)<<8|(t.length>2?t.charCodeAt(2):0);return[s.charAt(n>>>18),s.charAt(n>>>12&63),e>=2?"=":s.charAt(n>>>6&63),e>=1?"=":s.charAt(63&n)].join("")},l=self.btoa||function(t){return t.replace(/[\s\S]{1,3}/g,u)};var d=class{constructor(t,e,n,i){this.clear=e,this.timer=t(()=>{this.timer&&(this.timer=i(this.timer))},n)}isRunning(){return null!==this.timer}ensureAborted(){this.timer&&(this.clear(this.timer),this.timer=null)}};function p(t){self.clearTimeout(t)}function f(t){self.clearInterval(t)}class g extends d{constructor(t,e){super(setTimeout,p,t,(function(t){return e(),null}))}}class b extends d{constructor(t,e){super(setInterval,f,t,(function(t){return e(),t}))}}var m={now:()=>Date.now?Date.now():(new Date).valueOf(),defer:t=>new g(0,t),method(t,...e){var n=Array.prototype.slice.call(arguments,1);return function(e){return e[t].apply(e,n.concat(arguments))}}};function v(t,...e){for(var n=0;ne!==t),this):(this.global_callbacks=[],this)}unbind_all(){return this.unbind(),this.unbind_global(),this}emit(t,e,n){for(var i=0;i0)for(i=0;i{self.console&&self.console.log&&self.console.log(t)}}debug(...t){this.log(this.globalLog,t)}warn(...t){this.log(this.globalLogWarn,t)}error(...t){this.log(this.globalLogError,t)}globalLogWarn(t){self.console&&self.console.warn?self.console.warn(t):this.globalLog(t)}globalLogError(t){self.console&&self.console.error?self.console.error(t):this.globalLogWarn(t)}log(t,...e){var n=y.apply(this,arguments);if(Ee.log)Ee.log(n);else if(Ee.logToConsole){t.bind(this)(n)}}};class z extends H{constructor(t,e,n,i,s){super(),this.initialize=ae.transportConnectionInitializer,this.hooks=t,this.name=e,this.priority=n,this.key=i,this.options=s,this.state="new",this.timeline=s.timeline,this.activityTimeout=s.activityTimeout,this.id=this.timeline.generateUniqueID()}handlesActivityChecks(){return Boolean(this.hooks.handlesActivityChecks)}supportsPing(){return Boolean(this.hooks.supportsPing)}connect(){if(this.socket||"initialized"!==this.state)return!1;var t=this.hooks.urls.getInitial(this.key,this.options);try{this.socket=this.hooks.getSocket(t,this.options)}catch(t){return m.defer(()=>{this.onError(t),this.changeState("closed")}),!1}return this.bindListeners(),M.debug("Connecting",{transport:this.name,url:t}),this.changeState("connecting"),!0}close(){return!!this.socket&&(this.socket.close(),!0)}send(t){return"open"===this.state&&(m.defer(()=>{this.socket&&this.socket.send(t)}),!0)}ping(){"open"===this.state&&this.supportsPing()&&this.socket.ping()}onOpen(){this.hooks.beforeOpen&&this.hooks.beforeOpen(this.socket,this.hooks.urls.getPath(this.key,this.options)),this.changeState("open"),this.socket.onopen=void 0}onError(t){this.emit("error",{type:"WebSocketError",error:t}),this.timeline.error(this.buildTimelineMessage({error:t.toString()}))}onClose(t){t?this.changeState("closed",{code:t.code,reason:t.reason,wasClean:t.wasClean}):this.changeState("closed"),this.unbindListeners(),this.socket=void 0}onMessage(t){this.emit("message",t)}onActivity(){this.emit("activity")}bindListeners(){this.socket.onopen=()=>{this.onOpen()},this.socket.onerror=t=>{this.onError(t)},this.socket.onclose=t=>{this.onClose(t)},this.socket.onmessage=t=>{this.onMessage(t)},this.supportsPing()&&(this.socket.onactivity=()=>{this.onActivity()})}unbindListeners(){this.socket&&(this.socket.onopen=void 0,this.socket.onerror=void 0,this.socket.onclose=void 0,this.socket.onmessage=void 0,this.supportsPing()&&(this.socket.onactivity=void 0))}changeState(t,e){this.state=t,this.timeline.info(this.buildTimelineMessage({state:t,params:e})),this.emit(t,e)}buildTimelineMessage(t){return v({cid:this.id},t)}}class B{constructor(t){this.hooks=t}isSupported(t){return this.hooks.isSupported(t)}createConnection(t,e,n,i){return new z(this.hooks,t,e,n,i)}}var q=new B({urls:D,handlesActivityChecks:!1,supportsPing:!1,isInitialized:function(){return Boolean(ae.getWebSocketAPI())},isSupported:function(){return Boolean(ae.getWebSocketAPI())},getSocket:function(t){return ae.createWebSocket(t)}}),F={urls:j,handlesActivityChecks:!1,supportsPing:!0,isInitialized:function(){return!0}},$=v({getSocket:function(t){return ae.HTTPFactory.createStreamingSocket(t)}},F),J=v({getSocket:function(t){return ae.HTTPFactory.createPollingSocket(t)}},F),W={isSupported:function(){return ae.isXHRSupported()}},X={ws:q,xhr_streaming:new B(v({},$,W)),xhr_polling:new B(v({},J,W))};class G{constructor(t,e,n){this.manager=t,this.transport=e,this.minPingDelay=n.minPingDelay,this.maxPingDelay=n.maxPingDelay,this.pingDelay=void 0}createConnection(t,e,n,i){i=v({},i,{activityTimeout:this.pingDelay});var s=this.transport.createConnection(t,e,n,i),r=null,o=function(){s.unbind("open",o),s.bind("closed",a),r=m.now()},a=t=>{if(s.unbind("closed",a),1002===t.code||1003===t.code)this.manager.reportDeath();else if(!t.wasClean&&r){var e=m.now()-r;e<2*this.maxPingDelay&&(this.manager.reportDeath(),this.pingDelay=Math.max(e/2,this.minPingDelay))}};return s.bind("open",o),s}isSupported(t){return this.manager.isAlive()&&this.transport.isSupported(t)}}const V={decodeMessage:function(t){try{var e=JSON.parse(t.data),n=e.data;if("string"==typeof n)try{n=JSON.parse(e.data)}catch(t){}var i={event:e.event,channel:e.channel,data:n};return e.user_id&&(i.user_id=e.user_id),i}catch(e){throw{type:"MessageParseError",error:e,data:t.data}}},encodeMessage:function(t){return JSON.stringify(t)},processHandshake:function(t){var e=V.decodeMessage(t);if("pusher:connection_established"===e.event){if(!e.data.activity_timeout)throw"No activity timeout specified in handshake";return{action:"connected",id:e.data.socket_id,activityTimeout:1e3*e.data.activity_timeout}}if("pusher:error"===e.event)return{action:this.getCloseAction(e.data),error:this.getCloseError(e.data)};throw"Invalid handshake"},getCloseAction:function(t){return t.code<4e3?t.code>=1002&&t.code<=1004?"backoff":null:4e3===t.code?"tls_only":t.code<4100?"refused":t.code<4200?"backoff":t.code<4300?"retry":"refused"},getCloseError:function(t){return 1e3!==t.code&&1001!==t.code?{type:"PusherError",data:{code:t.code,message:t.reason||t.message}}:null}};var Y=V;class Q extends H{constructor(t,e){super(),this.id=t,this.transport=e,this.activityTimeout=e.activityTimeout,this.bindListeners()}handlesActivityChecks(){return this.transport.handlesActivityChecks()}send(t){return this.transport.send(t)}send_event(t,e,n){var i={event:t,data:e};return n&&(i.channel=n),M.debug("Event sent",i),this.send(Y.encodeMessage(i))}ping(){this.transport.supportsPing()?this.transport.ping():this.send_event("pusher:ping",{})}close(){this.transport.close()}bindListeners(){var t={message:t=>{var e;try{e=Y.decodeMessage(t)}catch(e){this.emit("error",{type:"MessageParseError",error:e,data:t.data})}if(void 0!==e){switch(M.debug("Event recd",e),e.event){case"pusher:error":this.emit("error",{type:"PusherError",data:e.data});break;case"pusher:ping":this.emit("ping");break;case"pusher:pong":this.emit("pong")}this.emit("message",e)}},activity:()=>{this.emit("activity")},error:t=>{this.emit("error",t)},closed:t=>{e(),t&&t.code&&this.handleCloseEvent(t),this.transport=null,this.emit("closed")}},e=()=>{_(t,(t,e)=>{this.transport.unbind(e,t)})};_(t,(t,e)=>{this.transport.bind(e,t)})}handleCloseEvent(t){var e=Y.getCloseAction(t),n=Y.getCloseError(t);n&&this.emit("error",n),e&&this.emit(e,{action:e,error:n})}}class K{constructor(t,e){this.transport=t,this.callback=e,this.bindListeners()}close(){this.unbindListeners(),this.transport.close()}bindListeners(){this.onMessage=t=>{var e;this.unbindListeners();try{e=Y.processHandshake(t)}catch(t){return this.finish("error",{error:t}),void this.transport.close()}"connected"===e.action?this.finish("connected",{connection:new Q(e.id,this.transport),activityTimeout:e.activityTimeout}):(this.finish(e.action,{error:e.error}),this.transport.close())},this.onClosed=t=>{this.unbindListeners();var e=Y.getCloseAction(t)||"backoff",n=Y.getCloseError(t);this.finish(e,{error:n})},this.transport.bind("message",this.onMessage),this.transport.bind("closed",this.onClosed)}unbindListeners(){this.transport.unbind("message",this.onMessage),this.transport.unbind("closed",this.onClosed)}finish(t,e){this.callback(v({transport:this.transport,action:t},e))}}class Z{constructor(t,e){this.timeline=t,this.options=e||{}}send(t,e){this.timeline.isEmpty()||this.timeline.send(ae.TimelineTransport.getAgent(this,t),e)}}class tt extends Error{constructor(t){super(t),Object.setPrototypeOf(this,new.target.prototype)}}class et extends Error{constructor(t){super(t),Object.setPrototypeOf(this,new.target.prototype)}}Error;class nt extends Error{constructor(t){super(t),Object.setPrototypeOf(this,new.target.prototype)}}class it extends Error{constructor(t){super(t),Object.setPrototypeOf(this,new.target.prototype)}}class st extends Error{constructor(t){super(t),Object.setPrototypeOf(this,new.target.prototype)}}class rt extends Error{constructor(t){super(t),Object.setPrototypeOf(this,new.target.prototype)}}class ot extends Error{constructor(t){super(t),Object.setPrototypeOf(this,new.target.prototype)}}class at extends Error{constructor(t,e){super(e),this.status=t,Object.setPrototypeOf(this,new.target.prototype)}}const ct={baseUrl:"https://pusher.com",urls:{authenticationEndpoint:{path:"/docs/channels/server_api/authenticating_users"},authorizationEndpoint:{path:"/docs/channels/server_api/authorizing-users/"},javascriptQuickStart:{path:"/docs/javascript_quick_start"},triggeringClientEvents:{path:"/docs/client_api_guide/client_events#trigger-events"},encryptedChannelSupport:{fullUrl:"https://github.com/pusher/pusher-js/tree/cc491015371a4bde5743d1c87a0fbac0feb53195#encrypted-channel-support"}}};var ht=function(t){const e=ct.urls[t];if(!e)return"";let n;return e.fullUrl?n=e.fullUrl:e.path&&(n=ct.baseUrl+e.path),n?"See: "+n:""};class ut extends H{constructor(t,e){super((function(e,n){M.debug("No callbacks on "+t+" for "+e)})),this.name=t,this.pusher=e,this.subscribed=!1,this.subscriptionPending=!1,this.subscriptionCancelled=!1}authorize(t,e){return e(null,{auth:""})}trigger(t,e){if(0!==t.indexOf("client-"))throw new tt("Event '"+t+"' does not start with 'client-'");if(!this.subscribed){var n=ht("triggeringClientEvents");M.warn("Client event triggered before channel 'subscription_succeeded' event . "+n)}return this.pusher.send_event(t,e,this.name)}disconnect(){this.subscribed=!1,this.subscriptionPending=!1}handleEvent(t){var e=t.event,n=t.data;if("pusher_internal:subscription_succeeded"===e)this.handleSubscriptionSucceededEvent(t);else if("pusher_internal:subscription_count"===e)this.handleSubscriptionCountEvent(t);else if(0!==e.indexOf("pusher_internal:")){this.emit(e,n,{})}}handleSubscriptionSucceededEvent(t){this.subscriptionPending=!1,this.subscribed=!0,this.subscriptionCancelled?this.pusher.unsubscribe(this.name):this.emit("pusher:subscription_succeeded",t.data)}handleSubscriptionCountEvent(t){t.data.subscription_count&&(this.subscriptionCount=t.data.subscription_count),this.emit("pusher:subscription_count",t.data)}subscribe(){this.subscribed||(this.subscriptionPending=!0,this.subscriptionCancelled=!1,this.authorize(this.pusher.connection.socket_id,(t,e)=>{t?(this.subscriptionPending=!1,M.error(t.toString()),this.emit("pusher:subscription_error",Object.assign({},{type:"AuthError",error:t.message},t instanceof at?{status:t.status}:{}))):this.pusher.send_event("pusher:subscribe",{auth:e.auth,channel_data:e.channel_data,channel:this.name})}))}unsubscribe(){this.subscribed=!1,this.pusher.send_event("pusher:unsubscribe",{channel:this.name})}cancelSubscription(){this.subscriptionCancelled=!0}reinstateSubscription(){this.subscriptionCancelled=!1}}class lt extends ut{authorize(t,e){return this.pusher.config.channelAuthorizer({channelName:this.name,socketId:t},e)}}class dt{constructor(){this.reset()}get(t){return Object.prototype.hasOwnProperty.call(this.members,t)?{id:t,info:this.members[t]}:null}each(t){_(this.members,(e,n)=>{t(this.get(n))})}setMyID(t){this.myID=t}onSubscription(t){this.members=t.presence.hash,this.count=t.presence.count,this.me=this.get(this.myID)}addMember(t){return null===this.get(t.user_id)&&this.count++,this.members[t.user_id]=t.user_info,this.get(t.user_id)}removeMember(t){var e=this.get(t.user_id);return e&&(delete this.members[t.user_id],this.count--),e}reset(){this.members={},this.count=0,this.myID=null,this.me=null}}var pt=function(t,e,n,i){return new(n||(n=Promise))((function(s,r){function o(t){try{c(i.next(t))}catch(t){r(t)}}function a(t){try{c(i.throw(t))}catch(t){r(t)}}function c(t){var e;t.done?s(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(o,a)}c((i=i.apply(t,e||[])).next())}))};class ft extends lt{constructor(t,e){super(t,e),this.members=new dt}authorize(t,e){super.authorize(t,(t,n)=>pt(this,void 0,void 0,(function*(){if(!t)if(null!=(n=n).channel_data){var i=JSON.parse(n.channel_data);this.members.setMyID(i.user_id)}else{if(yield this.pusher.user.signinDonePromise,null==this.pusher.user.user_data){let t=ht("authorizationEndpoint");return M.error(`Invalid auth response for channel '${this.name}', expected 'channel_data' field. ${t}, or the user should be signed in.`),void e("Invalid auth response")}this.members.setMyID(this.pusher.user.user_data.id)}e(t,n)})))}handleEvent(t){var e=t.event;if(0===e.indexOf("pusher_internal:"))this.handleInternalEvent(t);else{var n=t.data,i={};t.user_id&&(i.user_id=t.user_id),this.emit(e,n,i)}}handleInternalEvent(t){var e=t.event,n=t.data;switch(e){case"pusher_internal:subscription_succeeded":this.handleSubscriptionSucceededEvent(t);break;case"pusher_internal:subscription_count":this.handleSubscriptionCountEvent(t);break;case"pusher_internal:member_added":var i=this.members.addMember(n);this.emit("pusher:member_added",i);break;case"pusher_internal:member_removed":var s=this.members.removeMember(n);s&&this.emit("pusher:member_removed",s)}}handleSubscriptionSucceededEvent(t){this.subscriptionPending=!1,this.subscribed=!0,this.subscriptionCancelled?this.pusher.unsubscribe(this.name):(this.members.onSubscription(t.data),this.emit("pusher:subscription_succeeded",this.members))}disconnect(){this.members.reset(),super.disconnect()}}var gt=n(1),bt=n(0);class mt extends lt{constructor(t,e,n){super(t,e),this.key=null,this.nacl=n}authorize(t,e){super.authorize(t,(t,n)=>{if(t)return void e(t,n);let i=n.shared_secret;i?(this.key=Object(bt.decode)(i),delete n.shared_secret,e(null,n)):e(new Error("No shared_secret key in auth payload for encrypted channel: "+this.name),null)})}trigger(t,e){throw new st("Client events are not currently supported for encrypted channels")}handleEvent(t){var e=t.event,n=t.data;0!==e.indexOf("pusher_internal:")&&0!==e.indexOf("pusher:")?this.handleEncryptedEvent(e,n):super.handleEvent(t)}handleEncryptedEvent(t,e){if(!this.key)return void M.debug("Received encrypted event before key has been retrieved from the authEndpoint");if(!e.ciphertext||!e.nonce)return void M.error("Unexpected format for encrypted event, expected object with `ciphertext` and `nonce` fields, got: "+e);let n=Object(bt.decode)(e.ciphertext);if(n.length{e?M.error(`Failed to make a request to the authEndpoint: ${r}. Unable to fetch new key, so dropping encrypted event`):(s=this.nacl.secretbox.open(n,i,this.key),null!==s?this.emit(t,this.getDataToEmit(s)):M.error("Failed to decrypt event with new key. Dropping encrypted event"))});this.emit(t,this.getDataToEmit(s))}getDataToEmit(t){let e=Object(gt.decode)(t);try{return JSON.parse(e)}catch(t){return e}}}class vt extends H{constructor(t,e){super(),this.state="initialized",this.connection=null,this.key=t,this.options=e,this.timeline=this.options.timeline,this.usingTLS=this.options.useTLS,this.errorCallbacks=this.buildErrorCallbacks(),this.connectionCallbacks=this.buildConnectionCallbacks(this.errorCallbacks),this.handshakeCallbacks=this.buildHandshakeCallbacks(this.errorCallbacks);var n=ae.getNetwork();n.bind("online",()=>{this.timeline.info({netinfo:"online"}),"connecting"!==this.state&&"unavailable"!==this.state||this.retryIn(0)}),n.bind("offline",()=>{this.timeline.info({netinfo:"offline"}),this.connection&&this.sendActivityCheck()}),this.updateStrategy()}connect(){this.connection||this.runner||(this.strategy.isSupported()?(this.updateState("connecting"),this.startConnecting(),this.setUnavailableTimer()):this.updateState("failed"))}send(t){return!!this.connection&&this.connection.send(t)}send_event(t,e,n){return!!this.connection&&this.connection.send_event(t,e,n)}disconnect(){this.disconnectInternally(),this.updateState("disconnected")}isUsingTLS(){return this.usingTLS}startConnecting(){var t=(e,n)=>{e?this.runner=this.strategy.connect(0,t):"error"===n.action?(this.emit("error",{type:"HandshakeError",error:n.error}),this.timeline.error({handshakeError:n.error})):(this.abortConnecting(),this.handshakeCallbacks[n.action](n))};this.runner=this.strategy.connect(0,t)}abortConnecting(){this.runner&&(this.runner.abort(),this.runner=null)}disconnectInternally(){(this.abortConnecting(),this.clearRetryTimer(),this.clearUnavailableTimer(),this.connection)&&this.abandonConnection().close()}updateStrategy(){this.strategy=this.options.getStrategy({key:this.key,timeline:this.timeline,useTLS:this.usingTLS})}retryIn(t){this.timeline.info({action:"retry",delay:t}),t>0&&this.emit("connecting_in",Math.round(t/1e3)),this.retryTimer=new g(t||0,()=>{this.disconnectInternally(),this.connect()})}clearRetryTimer(){this.retryTimer&&(this.retryTimer.ensureAborted(),this.retryTimer=null)}setUnavailableTimer(){this.unavailableTimer=new g(this.options.unavailableTimeout,()=>{this.updateState("unavailable")})}clearUnavailableTimer(){this.unavailableTimer&&this.unavailableTimer.ensureAborted()}sendActivityCheck(){this.stopActivityCheck(),this.connection.ping(),this.activityTimer=new g(this.options.pongTimeout,()=>{this.timeline.error({pong_timed_out:this.options.pongTimeout}),this.retryIn(0)})}resetActivityCheck(){this.stopActivityCheck(),this.connection&&!this.connection.handlesActivityChecks()&&(this.activityTimer=new g(this.activityTimeout,()=>{this.sendActivityCheck()}))}stopActivityCheck(){this.activityTimer&&this.activityTimer.ensureAborted()}buildConnectionCallbacks(t){return v({},t,{message:t=>{this.resetActivityCheck(),this.emit("message",t)},ping:()=>{this.send_event("pusher:pong",{})},activity:()=>{this.resetActivityCheck()},error:t=>{this.emit("error",t)},closed:()=>{this.abandonConnection(),this.shouldRetry()&&this.retryIn(1e3)}})}buildHandshakeCallbacks(t){return v({},t,{connected:t=>{this.activityTimeout=Math.min(this.options.activityTimeout,t.activityTimeout,t.connection.activityTimeout||1/0),this.clearUnavailableTimer(),this.setConnection(t.connection),this.socket_id=this.connection.id,this.updateState("connected",{socket_id:this.socket_id})}})}buildErrorCallbacks(){let t=t=>e=>{e.error&&this.emit("error",{type:"WebSocketError",error:e.error}),t(e)};return{tls_only:t(()=>{this.usingTLS=!0,this.updateStrategy(),this.retryIn(0)}),refused:t(()=>{this.disconnect()}),backoff:t(()=>{this.retryIn(1e3)}),retry:t(()=>{this.retryIn(0)})}}setConnection(t){for(var e in this.connection=t,this.connectionCallbacks)this.connection.bind(e,this.connectionCallbacks[e]);this.resetActivityCheck()}abandonConnection(){if(this.connection){for(var t in this.stopActivityCheck(),this.connectionCallbacks)this.connection.unbind(t,this.connectionCallbacks[t]);var e=this.connection;return this.connection=null,e}}updateState(t,e){var n=this.state;if(this.state=t,n!==t){var i=t;"connected"===i&&(i+=" with new socket ID "+e.socket_id),M.debug("State changed",n+" -> "+i),this.timeline.info({state:t,params:e}),this.emit("state_change",{previous:n,current:t}),this.emit(t,e)}}shouldRetry(){return"connecting"===this.state||"connected"===this.state}}class yt{constructor(){this.channels={}}add(t,e){return this.channels[t]||(this.channels[t]=function(t,e){if(0===t.indexOf("private-encrypted-")){if(e.config.nacl)return St.createEncryptedChannel(t,e,e.config.nacl);let n="Tried to subscribe to a private-encrypted- channel but no nacl implementation available",i=ht("encryptedChannelSupport");throw new st(`${n}. ${i}`)}if(0===t.indexOf("private-"))return St.createPrivateChannel(t,e);if(0===t.indexOf("presence-"))return St.createPresenceChannel(t,e);if(0===t.indexOf("#"))throw new et('Cannot create a channel with name "'+t+'".');return St.createChannel(t,e)}(t,e)),this.channels[t]}all(){return function(t){var e=[];return _(t,(function(t){e.push(t)})),e}(this.channels)}find(t){return this.channels[t]}remove(t){var e=this.channels[t];return delete this.channels[t],e}disconnect(){_(this.channels,(function(t){t.disconnect()}))}}var St={createChannels:()=>new yt,createConnectionManager:(t,e)=>new vt(t,e),createChannel:(t,e)=>new ut(t,e),createPrivateChannel:(t,e)=>new lt(t,e),createPresenceChannel:(t,e)=>new ft(t,e),createEncryptedChannel:(t,e,n)=>new mt(t,e,n),createTimelineSender:(t,e)=>new Z(t,e),createHandshake:(t,e)=>new K(t,e),createAssistantToTheTransportManager:(t,e,n)=>new G(t,e,n)};class _t{constructor(t){this.options=t||{},this.livesLeft=this.options.lives||1/0}getAssistant(t){return St.createAssistantToTheTransportManager(this,t,{minPingDelay:this.options.minPingDelay,maxPingDelay:this.options.maxPingDelay})}isAlive(){return this.livesLeft>0}reportDeath(){this.livesLeft-=1}}class wt{constructor(t,e){this.strategies=t,this.loop=Boolean(e.loop),this.failFast=Boolean(e.failFast),this.timeout=e.timeout,this.timeoutLimit=e.timeoutLimit}isSupported(){return O(this.strategies,m.method("isSupported"))}connect(t,e){var n=this.strategies,i=0,s=this.timeout,r=null,o=(a,c)=>{c?e(null,c):(i+=1,this.loop&&(i%=n.length),i0&&(s=new g(n.timeout,(function(){r.abort(),i(!0)}))),r=t.connect(e,(function(t,e){t&&s&&s.isRunning()&&!n.failFast||(s&&s.ensureAborted(),i(t,e))})),{abort:function(){s&&s.ensureAborted(),r.abort()},forceMinPriority:function(t){r.forceMinPriority(t)}}}}class Ct{constructor(t){this.strategies=t}isSupported(){return O(this.strategies,m.method("isSupported"))}connect(t,e){return function(t,e,n){var i=k(t,(function(t,i,s,r){return t.connect(e,n(i,r))}));return{abort:function(){C(i,kt)},forceMinPriority:function(t){C(i,(function(e){e.forceMinPriority(t)}))}}}(this.strategies,t,(function(t,n){return function(i,s){n[t].error=i,i?function(t){return function(t,e){for(var n=0;n=m.now()){var o=this.transports[i.transport];o&&(["ws","wss"].includes(i.transport)||s>3?(this.timeline.info({cached:!0,transport:i.transport,latency:i.latency}),r.push(new wt([o],{timeout:2*i.latency+1e3,failFast:!0}))):s++)}var a=m.now(),c=r.pop().connect(t,(function i(o,h){o?(Ot(n),r.length>0?(a=m.now(),c=r.pop().connect(t,i)):e(o)):(!function(t,e,n,i){var s=ae.getLocalStorage();if(s)try{s[Pt(t)]=L({timestamp:m.now(),transport:e,latency:n,cacheSkipCount:i})}catch(t){}}(n,h.transport.name,m.now()-a,s),e(null,h))}));return{abort:function(){c.abort()},forceMinPriority:function(e){t=e,c&&c.forceMinPriority(e)}}}}function Pt(t){return"pusherTransport"+(t?"TLS":"NonTLS")}function Ot(t){var e=ae.getLocalStorage();if(e)try{delete e[Pt(t)]}catch(t){}}class Et{constructor(t,{delay:e}){this.strategy=t,this.options={delay:e}}isSupported(){return this.strategy.isSupported()}connect(t,e){var n,i=this.strategy,s=new g(this.options.delay,(function(){n=i.connect(t,e)}));return{abort:function(){s.ensureAborted(),n&&n.abort()},forceMinPriority:function(e){t=e,n&&n.forceMinPriority(e)}}}}class xt{constructor(t,e,n){this.test=t,this.trueBranch=e,this.falseBranch=n}isSupported(){return(this.test()?this.trueBranch:this.falseBranch).isSupported()}connect(t,e){return(this.test()?this.trueBranch:this.falseBranch).connect(t,e)}}class Lt{constructor(t){this.strategy=t}isSupported(){return this.strategy.isSupported()}connect(t,e){var n=this.strategy.connect(t,(function(t,i){i&&n.abort(),e(t,i)}));return n}}function At(t){return function(){return t.isSupported()}}var Rt=function(t,e,n){var i={};function s(e,s,r,o,a){var c=n(t,e,s,r,o,a);return i[e]=c,c}var r,o=Object.assign({},e,{hostNonTLS:t.wsHost+":"+t.wsPort,hostTLS:t.wsHost+":"+t.wssPort,httpPath:t.wsPath}),a=v({},o,{useTLS:!0}),c=Object.assign({},e,{hostNonTLS:t.httpHost+":"+t.httpPort,hostTLS:t.httpHost+":"+t.httpsPort,httpPath:t.httpPath}),h={loop:!0,timeout:15e3,timeoutLimit:6e4},u=new _t({minPingDelay:1e4,maxPingDelay:t.activityTimeout}),l=new _t({lives:2,minPingDelay:1e4,maxPingDelay:t.activityTimeout}),d=s("ws","ws",3,o,u),p=s("wss","ws",3,a,u),f=s("xhr_streaming","xhr_streaming",1,c,l),g=s("xhr_polling","xhr_polling",1,c),b=new wt([d],h),m=new wt([p],h),y=new wt([f],h),S=new wt([g],h),_=new wt([new xt(At(y),new Ct([y,new Et(S,{delay:4e3})]),S)],h);return r=e.useTLS?new Ct([b,new Et(_,{delay:2e3})]):new Ct([b,new Et(m,{delay:2e3}),new Et(_,{delay:5e3})]),new Tt(new Lt(new xt(At(d),r,_)),i,{ttl:18e5,timeline:e.timeline,useTLS:e.useTLS})};class It extends H{constructor(t,e,n){super(),this.hooks=t,this.method=e,this.url=n}start(t){this.position=0,this.xhr=this.hooks.getRequest(this),this.unloader=()=>{this.close()},ae.addUnloadListener(this.unloader),this.xhr.open(this.method,this.url,!0),this.xhr.setRequestHeader&&this.xhr.setRequestHeader("Content-Type","application/json"),this.xhr.send(t)}close(){this.unloader&&(ae.removeUnloadListener(this.unloader),this.unloader=null),this.xhr&&(this.hooks.abortRequest(this.xhr),this.xhr=null)}onChunk(t,e){for(;;){var n=this.advanceBuffer(e);if(!n)break;this.emit("chunk",{status:t,data:n})}this.isBufferTooLong(e)&&this.emit("buffer_too_long")}advanceBuffer(t){var e=t.slice(this.position),n=e.indexOf("\n");return-1!==n?(this.position+=n+1,e.slice(0,n)):null}isBufferTooLong(t){return this.position===t.length&&t.length>262144}}var Dt;!function(t){t[t.CONNECTING=0]="CONNECTING",t[t.OPEN=1]="OPEN",t[t.CLOSED=3]="CLOSED"}(Dt||(Dt={}));var jt=Dt,Nt=1;function Ut(t){var e=-1===t.indexOf("?")?"?":"&";return t+e+"t="+ +new Date+"&n="+Nt++}function Ht(t){return ae.randomInt(t)}var Mt=class{constructor(t,e){this.hooks=t,this.session=Ht(1e3)+"/"+function(t){for(var e=[],n=0;n{this.onChunk(t)}),this.stream.bind("finished",t=>{this.hooks.onFinished(this,t)}),this.stream.bind("buffer_too_long",()=>{this.reconnect()});try{this.stream.start()}catch(t){m.defer(()=>{this.onError(t),this.onClose(1006,"Could not start streaming",!1)})}}closeStream(){this.stream&&(this.stream.unbind_all(),this.stream.close(),this.stream=null)}},zt={getReceiveURL:function(t,e){return t.base+"/"+e+"/xhr_streaming"+t.queryString},onHeartbeat:function(t){t.sendRaw("[]")},sendHeartbeat:function(t){t.sendRaw("[]")},onFinished:function(t,e){t.onClose(1006,"Connection interrupted ("+e+")",!1)}},Bt={getReceiveURL:function(t,e){return t.base+"/"+e+"/xhr"+t.queryString},onHeartbeat:function(){},sendHeartbeat:function(t){t.sendRaw("[]")},onFinished:function(t,e){200===e?t.reconnect():t.onClose(1006,"Connection interrupted ("+e+")",!1)}},qt={getRequest:function(t){var e=new(ae.getXHRAPI());return e.onreadystatechange=e.onprogress=function(){switch(e.readyState){case 3:e.responseText&&e.responseText.length>0&&t.onChunk(e.status,e.responseText);break;case 4:e.responseText&&e.responseText.length>0&&t.onChunk(e.status,e.responseText),t.emit("finished",e.status),t.close()}},e},abortRequest:function(t){t.onreadystatechange=null,t.abort()}},Ft={getDefaultStrategy:Rt,Transports:X,transportConnectionInitializer:function(){this.timeline.info(this.buildTimelineMessage({transport:this.name+(this.options.useTLS?"s":"")})),this.hooks.isInitialized()?this.changeState("initialized"):this.onClose()},HTTPFactory:{createStreamingSocket(t){return this.createSocket(zt,t)},createPollingSocket(t){return this.createSocket(Bt,t)},createSocket:(t,e)=>new Mt(t,e),createXHR(t,e){return this.createRequest(qt,t,e)},createRequest:(t,e,n)=>new It(t,e,n)},setup(t){t.ready()},getLocalStorage(){},getClientFeatures:()=>w(P({ws:X.ws},(function(t){return t.isSupported({})}))),getProtocol:()=>"http:",isXHRSupported:()=>!0,createSocketRequest(t,e){if(this.isXHRSupported())return this.HTTPFactory.createXHR(t,e);throw"Cross-origin HTTP requests are not supported"},createXHR(){return new(this.getXHRAPI())},createWebSocket(t){return new(this.getWebSocketAPI())(t)},addUnloadListener(t){},removeUnloadListener(t){}};var $t=new class extends H{isOnline(){return!0}},Jt=function(t,e,n,i,s){var r=new Headers;for(var o in r.set("Content-Type","application/x-www-form-urlencoded"),n.headers)r.set(o,n.headers[o]);if(null!=n.headersProvider){const t=n.headersProvider();for(var o in t)r.set(o,t[o])}var a=e,c=new Request(n.endpoint,{headers:r,body:a,credentials:"same-origin",method:"POST"});return fetch(c).then(t=>{let{status:e}=t;if(200===e)return t.text();throw new at(e,`Could not get ${i.toString()} info from your auth endpoint, status: ${e}`)}).then(t=>{let e;try{e=JSON.parse(t)}catch(e){throw new at(200,`JSON returned from ${i.toString()} endpoint was invalid, yet status code was 200. Data was: ${t}`)}s(null,e)}).catch(t=>{s(t,null)})},Wt={name:"xhr",getAgent:function(t,e){return function(n,i){var s="http"+(e?"s":"")+"://"+(t.host||t.options.host)+t.options.path,r=x(n);fetch(s+="/2?"+r).then(t=>{if(200!==t.status)throw`received ${t.status} from stats.pusher.com`;return t.json()}).then(({host:e})=>{e&&(t.host=e)}).catch(t=>{M.debug("TimelineSender Error: ",t)})}}};const{getDefaultStrategy:Xt,Transports:Gt,setup:Vt,getProtocol:Yt,isXHRSupported:Qt,getLocalStorage:Kt,createXHR:Zt,createWebSocket:te,addUnloadListener:ee,removeUnloadListener:ne,transportConnectionInitializer:ie,createSocketRequest:se,HTTPFactory:re}=Ft;var oe,ae={getDefaultStrategy:Xt,Transports:Gt,setup:Vt,getProtocol:Yt,isXHRSupported:Qt,getLocalStorage:Kt,createXHR:Zt,createWebSocket:te,addUnloadListener:ee,removeUnloadListener:ne,transportConnectionInitializer:ie,createSocketRequest:se,HTTPFactory:re,TimelineTransport:Wt,getAuthorizers:()=>({ajax:Jt}),getWebSocketAPI:()=>WebSocket,getXHRAPI:()=>XMLHttpRequest,getNetwork:()=>$t,randomInt:t=>Math.floor((globalThis.crypto||globalThis.msCrypto).getRandomValues(new Uint32Array(1))[0]/Math.pow(2,32)*t)};!function(t){t[t.ERROR=3]="ERROR",t[t.INFO=6]="INFO",t[t.DEBUG=7]="DEBUG"}(oe||(oe={}));var ce=oe;class he{constructor(t,e,n){this.key=t,this.session=e,this.events=[],this.options=n||{},this.sent=0,this.uniqueID=0}log(t,e){t<=this.options.level&&(this.events.push(v({},e,{timestamp:m.now()})),this.options.limit&&this.events.length>this.options.limit&&this.events.shift())}error(t){this.log(ce.ERROR,t)}info(t){this.log(ce.INFO,t)}debug(t){this.log(ce.DEBUG,t)}isEmpty(){return 0===this.events.length}send(t,e){var n=v({session:this.session,bundle:this.sent+1,key:this.key,lib:"js",version:this.options.version,cluster:this.options.cluster,features:this.options.features,timeline:this.events},this.options.params);return this.events=[],t(n,(t,n)=>{t||this.sent++,e&&e(t,n)}),!0}generateUniqueID(){return this.uniqueID++,this.uniqueID}}class ue{constructor(t,e,n,i){this.name=t,this.priority=e,this.transport=n,this.options=i||{}}isSupported(){return this.transport.isSupported({useTLS:this.options.useTLS})}connect(t,e){if(!this.isSupported())return le(new ot,e);if(this.priority{n||(h(),s?s.close():i.close())},forceMinPriority:t=>{n||this.priority{if(void 0===ae.getAuthorizers()[t.transport])throw`'${t.transport}' is not a recognized auth transport`;return(e,n)=>{const i=((t,e)=>{var n="socket_id="+encodeURIComponent(t.socketId);for(var i in e.params)n+="&"+encodeURIComponent(i)+"="+encodeURIComponent(e.params[i]);if(null!=e.paramsProvider){let t=e.paramsProvider();for(var i in t)n+="&"+encodeURIComponent(i)+"="+encodeURIComponent(t[i])}return n})(e,t);ae.getAuthorizers()[t.transport](ae,i,t,pe.UserAuthentication,n)}};var me=t=>{if(void 0===ae.getAuthorizers()[t.transport])throw`'${t.transport}' is not a recognized auth transport`;return(e,n)=>{const i=((t,e)=>{var n="socket_id="+encodeURIComponent(t.socketId);for(var i in n+="&channel_name="+encodeURIComponent(t.channelName),e.params)n+="&"+encodeURIComponent(i)+"="+encodeURIComponent(e.params[i]);if(null!=e.paramsProvider){let t=e.paramsProvider();for(var i in t)n+="&"+encodeURIComponent(i)+"="+encodeURIComponent(t[i])}return n})(e,t);ae.getAuthorizers()[t.transport](ae,i,t,pe.ChannelAuthorization,n)}};function ve(t){return t.httpHost?t.httpHost:t.cluster?`sockjs-${t.cluster}.pusher.com`:A.httpHost}function ye(t){return t.wsHost?t.wsHost:`ws-${t.cluster}.pusher.com`}function Se(t){return"https:"===ae.getProtocol()||!1!==t.forceTLS}function _e(t){return"enableStats"in t?t.enableStats:"disableStats"in t&&!t.disableStats}function we(t){const e=Object.assign(Object.assign({},A.userAuthentication),t.userAuthentication);return"customHandler"in e&&null!=e.customHandler?e.customHandler:be(e)}function Ce(t,e){const n=function(t,e){let n;return"channelAuthorization"in t?n=Object.assign(Object.assign({},A.channelAuthorization),t.channelAuthorization):(n={transport:t.authTransport||A.authTransport,endpoint:t.authEndpoint||A.authEndpoint},"auth"in t&&("params"in t.auth&&(n.params=t.auth.params),"headers"in t.auth&&(n.headers=t.auth.headers)),"authorizer"in t&&(n.customHandler=((t,e,n)=>{const i={authTransport:e.transport,authEndpoint:e.endpoint,auth:{params:e.params,headers:e.headers}};return(e,s)=>{const r=t.channel(e.channelName);n(r,i).authorize(e.socketId,s)}})(e,n,t.authorizer))),n}(t,e);return"customHandler"in n&&null!=n.customHandler?n.customHandler:me(n)}class ke extends H{constructor(t){super((function(t,e){M.debug("No callbacks on watchlist events for "+t)})),this.pusher=t,this.bindWatchlistInternalEvent()}handleEvent(t){t.data.events.forEach(t=>{this.emit(t.name,t)})}bindWatchlistInternalEvent(){this.pusher.connection.bind("message",t=>{"pusher_internal:watchlist_events"===t.event&&this.handleEvent(t)})}}var Te=function(){let t,e;return{promise:new Promise((n,i)=>{t=n,e=i}),resolve:t,reject:e}};class Pe extends H{constructor(t){super((function(t,e){M.debug("No callbacks on user for "+t)})),this.signin_requested=!1,this.user_data=null,this.serverToUserChannel=null,this.signinDonePromise=null,this._signinDoneResolve=null,this._onAuthorize=(t,e)=>{if(t)return M.warn("Error during signin: "+t),void this._cleanup();this.pusher.send_event("pusher:signin",{auth:e.auth,user_data:e.user_data})},this.pusher=t,this.pusher.connection.bind("state_change",({previous:t,current:e})=>{"connected"!==t&&"connected"===e&&this._signin(),"connected"===t&&"connected"!==e&&(this._cleanup(),this._newSigninPromiseIfNeeded())}),this.watchlist=new ke(t),this.pusher.connection.bind("message",t=>{"pusher:signin_success"===t.event&&this._onSigninSuccess(t.data),this.serverToUserChannel&&this.serverToUserChannel.name===t.channel&&this.serverToUserChannel.handleEvent(t)})}signin(){this.signin_requested||(this.signin_requested=!0,this._signin())}_signin(){this.signin_requested&&(this._newSigninPromiseIfNeeded(),"connected"===this.pusher.connection.state&&this.pusher.config.userAuthenticator({socketId:this.pusher.connection.socket_id},this._onAuthorize))}_onSigninSuccess(t){try{this.user_data=JSON.parse(t.user_data)}catch(e){return M.error("Failed parsing user data after signin: "+t.user_data),void this._cleanup()}if("string"!=typeof this.user_data.id||""===this.user_data.id)return M.error("user_data doesn't contain an id. user_data: "+this.user_data),void this._cleanup();this._signinDoneResolve(),this._subscribeChannels()}_subscribeChannels(){this.serverToUserChannel=new ut("#server-to-user-"+this.user_data.id,this.pusher),this.serverToUserChannel.bind_global((t,e)=>{0!==t.indexOf("pusher_internal:")&&0!==t.indexOf("pusher:")&&this.emit(t,e)}),(t=>{t.subscriptionPending&&t.subscriptionCancelled?t.reinstateSubscription():t.subscriptionPending||"connected"!==this.pusher.connection.state||t.subscribe()})(this.serverToUserChannel)}_cleanup(){this.user_data=null,this.serverToUserChannel&&(this.serverToUserChannel.unbind_all(),this.serverToUserChannel.disconnect(),this.serverToUserChannel=null),this.signin_requested&&this._signinDoneResolve()}_newSigninPromiseIfNeeded(){if(!this.signin_requested)return;if(this.signinDonePromise&&!this.signinDonePromise.done)return;const{promise:t,resolve:e,reject:n}=Te();t.done=!1;const i=()=>{t.done=!0};t.then(i).catch(i),this.signinDonePromise=t,this._signinDoneResolve=e}}class Oe{static ready(){Oe.isReady=!0;for(var t=0,e=Oe.instances.length;tae.getDefaultStrategy(this.config,t,fe),timeline:this.timeline,activityTimeout:this.config.activityTimeout,pongTimeout:this.config.pongTimeout,unavailableTimeout:this.config.unavailableTimeout,useTLS:Boolean(this.config.useTLS)}),this.connection.bind("connected",()=>{this.subscribeAll(),this.timelineSender&&this.timelineSender.send(this.connection.isUsingTLS())}),this.connection.bind("message",t=>{var e=0===t.event.indexOf("pusher_internal:");if(t.channel){var n=this.channel(t.channel);n&&n.handleEvent(t)}e||this.global_emitter.emit(t.event,t.data)}),this.connection.bind("connecting",()=>{this.channels.disconnect()}),this.connection.bind("disconnected",()=>{this.channels.disconnect()}),this.connection.bind("error",t=>{M.warn(t)}),Oe.instances.push(this),this.timeline.info({instances:Oe.instances.length}),this.user=new Pe(this),Oe.isReady&&this.connect()}channel(t){return this.channels.find(t)}allChannels(){return this.channels.all()}connect(){if(this.connection.connect(),this.timelineSender&&!this.timelineSenderTimer){var t=this.connection.isUsingTLS(),e=this.timelineSender;this.timelineSenderTimer=new b(6e4,(function(){e.send(t)}))}}disconnect(){this.connection.disconnect(),this.timelineSenderTimer&&(this.timelineSenderTimer.ensureAborted(),this.timelineSenderTimer=null)}bind(t,e,n){return this.global_emitter.bind(t,e,n),this}unbind(t,e,n){return this.global_emitter.unbind(t,e,n),this}bind_global(t){return this.global_emitter.bind_global(t),this}unbind_global(t){return this.global_emitter.unbind_global(t),this}unbind_all(t){return this.global_emitter.unbind_all(),this}subscribeAll(){var t;for(t in this.channels.channels)this.channels.channels.hasOwnProperty(t)&&this.subscribe(t)}subscribe(t){var e=this.channels.add(t,this);return e.subscriptionPending&&e.subscriptionCancelled?e.reinstateSubscription():e.subscriptionPending||"connected"!==this.connection.state||e.subscribe(),e}unsubscribe(t){var e=this.channels.find(t);e&&e.subscriptionPending?e.cancelSubscription():(e=this.channels.remove(t))&&e.subscribed&&e.unsubscribe()}send_event(t,e,n){return this.connection.send_event(t,e,n)}shouldUseTLS(){return this.config.useTLS}signin(){this.user.signin()}}Oe.instances=[],Oe.isReady=!1,Oe.logToConsole=!1,Oe.Runtime=ae,Oe.ScriptReceivers=ae.ScriptReceivers,Oe.DependenciesReceivers=ae.DependenciesReceivers,Oe.auth_callbacks=ae.auth_callbacks;var Ee=e.default=Oe;ae.setup(Oe)}])})); +!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.Pusher=e():t.Pusher=e()}(this,(function(){return function(t){var e={};function n(i){if(e[i])return e[i].exports;var s=e[i]={i:i,l:!1,exports:{}};return t[i].call(s.exports,s,s.exports,n),s.l=!0,s.exports}return n.m=t,n.c=e,n.d=function(t,e,i){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:i})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var i=Object.create(null);if(n.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var s in t)n.d(i,s,function(e){return t[e]}.bind(null,s));return i},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=2)}([function(t,e,n){"use strict";var i,s=this&&this.__extends||(i=function(t,e){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)},function(t,e){function n(){this.constructor=t}i(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)});Object.defineProperty(e,"__esModule",{value:!0});var r=function(){function t(t){void 0===t&&(t="="),this._paddingCharacter=t}return t.prototype.encodedLength=function(t){return this._paddingCharacter?(t+2)/3*4|0:(8*t+5)/6|0},t.prototype.encode=function(t){for(var e="",n=0;n>>18&63),e+=this._encodeByte(i>>>12&63),e+=this._encodeByte(i>>>6&63),e+=this._encodeByte(i>>>0&63)}var s=t.length-n;if(s>0){i=t[n]<<16|(2===s?t[n+1]<<8:0);e+=this._encodeByte(i>>>18&63),e+=this._encodeByte(i>>>12&63),e+=2===s?this._encodeByte(i>>>6&63):this._paddingCharacter||"",e+=this._paddingCharacter||""}return e},t.prototype.maxDecodedLength=function(t){return this._paddingCharacter?t/4*3|0:(6*t+7)/8|0},t.prototype.decodedLength=function(t){return this.maxDecodedLength(t.length-this._getPaddingLength(t))},t.prototype.decode=function(t){if(0===t.length)return new Uint8Array(0);for(var e=this._getPaddingLength(t),n=t.length-e,i=new Uint8Array(this.maxDecodedLength(n)),s=0,r=0,o=0,a=0,c=0,h=0,u=0;r>>4,i[s++]=c<<4|h>>>2,i[s++]=h<<6|u,o|=256&a,o|=256&c,o|=256&h,o|=256&u;if(r>>4,o|=256&a,o|=256&c),r>>2,o|=256&h),r>>8&6,e+=51-t>>>8&-75,e+=61-t>>>8&-15,e+=62-t>>>8&3,String.fromCharCode(e)},t.prototype._decodeChar=function(t){var e=256;return e+=(42-t&t-44)>>>8&-256+t-43+62,e+=(46-t&t-48)>>>8&-256+t-47+63,e+=(47-t&t-58)>>>8&-256+t-48+52,e+=(64-t&t-91)>>>8&-256+t-65+0,e+=(96-t&t-123)>>>8&-256+t-97+26},t.prototype._getPaddingLength=function(t){var e=0;if(this._paddingCharacter){for(var n=t.length-1;n>=0&&t[n]===this._paddingCharacter;n--)e++;if(t.length<4||e>2)throw new Error("Base64Coder: incorrect padding")}return e},t}();e.Coder=r;var o=new r;e.encode=function(t){return o.encode(t)},e.decode=function(t){return o.decode(t)};var a=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return s(e,t),e.prototype._encodeByte=function(t){var e=t;return e+=65,e+=25-t>>>8&6,e+=51-t>>>8&-75,e+=61-t>>>8&-13,e+=62-t>>>8&49,String.fromCharCode(e)},e.prototype._decodeChar=function(t){var e=256;return e+=(44-t&t-46)>>>8&-256+t-45+62,e+=(94-t&t-96)>>>8&-256+t-95+63,e+=(47-t&t-58)>>>8&-256+t-48+52,e+=(64-t&t-91)>>>8&-256+t-65+0,e+=(96-t&t-123)>>>8&-256+t-97+26},e}(r);e.URLSafeCoder=a;var c=new a;e.encodeURLSafe=function(t){return c.encode(t)},e.decodeURLSafe=function(t){return c.decode(t)},e.encodedLength=function(t){return o.encodedLength(t)},e.maxDecodedLength=function(t){return o.maxDecodedLength(t)},e.decodedLength=function(t){return o.decodedLength(t)}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i="utf8: invalid source encoding";function s(t){for(var e=0,n=0;n=t.length-1)throw new Error("utf8: invalid string");n++,e+=4}}return e}e.encode=function(t){for(var e=new Uint8Array(s(t)),n=0,i=0;i>6,e[n++]=128|63&r):r<55296?(e[n++]=224|r>>12,e[n++]=128|r>>6&63,e[n++]=128|63&r):(i++,r=(1023&r)<<10,r|=1023&t.charCodeAt(i),r+=65536,e[n++]=240|r>>18,e[n++]=128|r>>12&63,e[n++]=128|r>>6&63,e[n++]=128|63&r)}return e},e.encodedLength=s,e.decode=function(t){for(var e=[],n=0;n=t.length)throw new Error(i);if(128!=(192&(o=t[++n])))throw new Error(i);s=(31&s)<<6|63&o,r=128}else if(s<240){if(n>=t.length-1)throw new Error(i);var o=t[++n],a=t[++n];if(128!=(192&o)||128!=(192&a))throw new Error(i);s=(15&s)<<12|(63&o)<<6|63&a,r=2048}else{if(!(s<248))throw new Error(i);if(n>=t.length-2)throw new Error(i);o=t[++n],a=t[++n];var c=t[++n];if(128!=(192&o)||128!=(192&a)||128!=(192&c))throw new Error(i);s=(15&s)<<18|(63&o)<<12|(63&a)<<6|63&c,r=65536}if(s=55296&&s<=57343)throw new Error(i);if(s>=65536){if(s>1114111)throw new Error(i);s-=65536,e.push(String.fromCharCode(55296|s>>10)),s=56320|1023&s}}e.push(String.fromCharCode(s))}return e.join("")}},function(t,e,n){t.exports=n(3).default},function(t,e,n){"use strict";n.r(e);for(var i=String.fromCharCode,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",r={},o=0,a=s.length;o>>6)+i(128|63&e):i(224|e>>>12&15)+i(128|e>>>6&63)+i(128|63&e)},h=function(t){return t.replace(/[^\x00-\x7F]/g,c)},u=function(t){var e=[0,2,1][t.length%3],n=t.charCodeAt(0)<<16|(t.length>1?t.charCodeAt(1):0)<<8|(t.length>2?t.charCodeAt(2):0);return[s.charAt(n>>>18),s.charAt(n>>>12&63),e>=2?"=":s.charAt(n>>>6&63),e>=1?"=":s.charAt(63&n)].join("")},l=self.btoa||function(t){return t.replace(/[\s\S]{1,3}/g,u)};var d=class{constructor(t,e,n,i){this.clear=e,this.timer=t(()=>{this.timer&&(this.timer=i(this.timer))},n)}isRunning(){return null!==this.timer}ensureAborted(){this.timer&&(this.clear(this.timer),this.timer=null)}};function p(t){self.clearTimeout(t)}function f(t){self.clearInterval(t)}class g extends d{constructor(t,e){super(setTimeout,p,t,(function(t){return e(),null}))}}class b extends d{constructor(t,e){super(setInterval,f,t,(function(t){return e(),t}))}}var m={now:()=>Date.now?Date.now():(new Date).valueOf(),defer:t=>new g(0,t),method(t,...e){var n=Array.prototype.slice.call(arguments,1);return function(e){return e[t].apply(e,n.concat(arguments))}}};function v(t,...e){for(var n=0;ne!==t),this):(this.global_callbacks=[],this)}unbind_all(){return this.unbind(),this.unbind_global(),this}emit(t,e,n){for(var i=0;i0)for(i=0;i{self.console&&self.console.log&&self.console.log(t)}}debug(...t){this.log(this.globalLog,t)}warn(...t){this.log(this.globalLogWarn,t)}error(...t){this.log(this.globalLogError,t)}globalLogWarn(t){self.console&&self.console.warn?self.console.warn(t):this.globalLog(t)}globalLogError(t){self.console&&self.console.error?self.console.error(t):this.globalLogWarn(t)}log(t,...e){var n=y.apply(this,arguments);if(xe.log)xe.log(n);else if(xe.logToConsole){t.bind(this)(n)}}};class z extends H{constructor(t,e,n,i,s){super(),this.initialize=ae.transportConnectionInitializer,this.hooks=t,this.name=e,this.priority=n,this.key=i,this.options=s,this.state="new",this.timeline=s.timeline,this.activityTimeout=s.activityTimeout,this.id=this.timeline.generateUniqueID()}handlesActivityChecks(){return Boolean(this.hooks.handlesActivityChecks)}supportsPing(){return Boolean(this.hooks.supportsPing)}connect(){if(this.socket||"initialized"!==this.state)return!1;var t=this.hooks.urls.getInitial(this.key,this.options);try{this.socket=this.hooks.getSocket(t,this.options)}catch(t){return m.defer(()=>{this.onError(t),this.changeState("closed")}),!1}return this.bindListeners(),M.debug("Connecting",{transport:this.name,url:t}),this.changeState("connecting"),!0}close(){return!!this.socket&&(this.socket.close(),!0)}send(t){return"open"===this.state&&(m.defer(()=>{this.socket&&this.socket.send(t)}),!0)}ping(){"open"===this.state&&this.supportsPing()&&this.socket.ping()}onOpen(){this.hooks.beforeOpen&&this.hooks.beforeOpen(this.socket,this.hooks.urls.getPath(this.key,this.options)),this.changeState("open"),this.socket.onopen=void 0}onError(t){this.emit("error",{type:"WebSocketError",error:t}),this.timeline.error(this.buildTimelineMessage({error:t.toString()}))}onClose(t){t?this.changeState("closed",{code:t.code,reason:t.reason,wasClean:t.wasClean}):this.changeState("closed"),this.unbindListeners(),this.socket=void 0}onMessage(t){this.emit("message",t)}onActivity(){this.emit("activity")}bindListeners(){this.socket.onopen=()=>{this.onOpen()},this.socket.onerror=t=>{this.onError(t)},this.socket.onclose=t=>{this.onClose(t)},this.socket.onmessage=t=>{this.onMessage(t)},this.supportsPing()&&(this.socket.onactivity=()=>{this.onActivity()})}unbindListeners(){this.socket&&(this.socket.onopen=void 0,this.socket.onerror=void 0,this.socket.onclose=void 0,this.socket.onmessage=void 0,this.supportsPing()&&(this.socket.onactivity=void 0))}changeState(t,e){this.state=t,this.timeline.info(this.buildTimelineMessage({state:t,params:e})),this.emit(t,e)}buildTimelineMessage(t){return v({cid:this.id},t)}}class B{constructor(t){this.hooks=t}isSupported(t){return this.hooks.isSupported(t)}createConnection(t,e,n,i){return new z(this.hooks,t,e,n,i)}}var q=new B({urls:j,handlesActivityChecks:!1,supportsPing:!1,isInitialized:function(){return Boolean(ae.getWebSocketAPI())},isSupported:function(){return Boolean(ae.getWebSocketAPI())},getSocket:function(t){return ae.createWebSocket(t)}}),F={urls:D,handlesActivityChecks:!1,supportsPing:!0,isInitialized:function(){return!0}},$=v({getSocket:function(t){return ae.HTTPFactory.createStreamingSocket(t)}},F),J=v({getSocket:function(t){return ae.HTTPFactory.createPollingSocket(t)}},F),W={isSupported:function(){return ae.isXHRSupported()}},X={ws:q,xhr_streaming:new B(v({},$,W)),xhr_polling:new B(v({},J,W))};class G{constructor(t,e,n){this.manager=t,this.transport=e,this.minPingDelay=n.minPingDelay,this.maxPingDelay=n.maxPingDelay,this.pingDelay=void 0}createConnection(t,e,n,i){i=v({},i,{activityTimeout:this.pingDelay});var s=this.transport.createConnection(t,e,n,i),r=null,o=function(){s.unbind("open",o),s.bind("closed",a),r=m.now()},a=t=>{if(s.unbind("closed",a),1002===t.code||1003===t.code)this.manager.reportDeath();else if(!t.wasClean&&r){var e=m.now()-r;e<2*this.maxPingDelay&&(this.manager.reportDeath(),this.pingDelay=Math.max(e/2,this.minPingDelay))}};return s.bind("open",o),s}isSupported(t){return this.manager.isAlive()&&this.transport.isSupported(t)}}const V={decodeMessage:function(t){try{var e=JSON.parse(t.data),n=e.data;if("string"==typeof n)try{n=JSON.parse(e.data)}catch(t){}var i={event:e.event,channel:e.channel,data:n};return e.user_id&&(i.user_id=e.user_id),i}catch(e){throw{type:"MessageParseError",error:e,data:t.data}}},encodeMessage:function(t){return JSON.stringify(t)},processHandshake:function(t){var e=V.decodeMessage(t);if("pusher:connection_established"===e.event){if(!e.data.activity_timeout)throw"No activity timeout specified in handshake";return{action:"connected",id:e.data.socket_id,activityTimeout:1e3*e.data.activity_timeout}}if("pusher:error"===e.event)return{action:this.getCloseAction(e.data),error:this.getCloseError(e.data)};throw"Invalid handshake"},getCloseAction:function(t){return t.code<4e3?t.code>=1002&&t.code<=1004?"backoff":null:4e3===t.code?"tls_only":t.code<4100?"refused":t.code<4200?"backoff":t.code<4300?"retry":"refused"},getCloseError:function(t){return 1e3!==t.code&&1001!==t.code?{type:"PusherError",data:{code:t.code,message:t.reason||t.message}}:null}};var Y=V;class K extends H{constructor(t,e){super(),this.id=t,this.transport=e,this.activityTimeout=e.activityTimeout,this.bindListeners()}handlesActivityChecks(){return this.transport.handlesActivityChecks()}send(t){return this.transport.send(t)}send_event(t,e,n){var i={event:t,data:e};return n&&(i.channel=n),M.debug("Event sent",i),this.send(Y.encodeMessage(i))}ping(){this.transport.supportsPing()?this.transport.ping():this.send_event("pusher:ping",{})}close(){this.transport.close()}bindListeners(){var t={message:t=>{var e;try{e=Y.decodeMessage(t)}catch(e){this.emit("error",{type:"MessageParseError",error:e,data:t.data})}if(void 0!==e){switch(M.debug("Event recd",e),e.event){case"pusher:error":this.emit("error",{type:"PusherError",data:e.data});break;case"pusher:ping":this.emit("ping");break;case"pusher:pong":this.emit("pong")}this.emit("message",e)}},activity:()=>{this.emit("activity")},error:t=>{this.emit("error",t)},closed:t=>{e(),t&&t.code&&this.handleCloseEvent(t),this.transport=null,this.emit("closed")}},e=()=>{_(t,(t,e)=>{this.transport.unbind(e,t)})};_(t,(t,e)=>{this.transport.bind(e,t)})}handleCloseEvent(t){var e=Y.getCloseAction(t),n=Y.getCloseError(t);n&&this.emit("error",n),e&&this.emit(e,{action:e,error:n})}}class Q{constructor(t,e){this.transport=t,this.callback=e,this.bindListeners()}close(){this.unbindListeners(),this.transport.close()}bindListeners(){this.onMessage=t=>{var e;this.unbindListeners();try{e=Y.processHandshake(t)}catch(t){return this.finish("error",{error:t}),void this.transport.close()}"connected"===e.action?this.finish("connected",{connection:new K(e.id,this.transport),activityTimeout:e.activityTimeout}):(this.finish(e.action,{error:e.error}),this.transport.close())},this.onClosed=t=>{this.unbindListeners();var e=Y.getCloseAction(t)||"backoff",n=Y.getCloseError(t);this.finish(e,{error:n})},this.transport.bind("message",this.onMessage),this.transport.bind("closed",this.onClosed)}unbindListeners(){this.transport.unbind("message",this.onMessage),this.transport.unbind("closed",this.onClosed)}finish(t,e){this.callback(v({transport:this.transport,action:t},e))}}class Z{constructor(t,e){this.timeline=t,this.options=e||{}}send(t,e){this.timeline.isEmpty()||this.timeline.send(ae.TimelineTransport.getAgent(this,t),e)}}class tt extends Error{constructor(t){super(t),Object.setPrototypeOf(this,new.target.prototype)}}class et extends Error{constructor(t){super(t),Object.setPrototypeOf(this,new.target.prototype)}}Error;class nt extends Error{constructor(t){super(t),Object.setPrototypeOf(this,new.target.prototype)}}class it extends Error{constructor(t){super(t),Object.setPrototypeOf(this,new.target.prototype)}}class st extends Error{constructor(t){super(t),Object.setPrototypeOf(this,new.target.prototype)}}class rt extends Error{constructor(t){super(t),Object.setPrototypeOf(this,new.target.prototype)}}class ot extends Error{constructor(t){super(t),Object.setPrototypeOf(this,new.target.prototype)}}class at extends Error{constructor(t,e){super(e),this.status=t,Object.setPrototypeOf(this,new.target.prototype)}}const ct={baseUrl:"https://pusher.com",urls:{authenticationEndpoint:{path:"/docs/channels/server_api/authenticating_users"},authorizationEndpoint:{path:"/docs/channels/server_api/authorizing-users/"},javascriptQuickStart:{path:"/docs/javascript_quick_start"},triggeringClientEvents:{path:"/docs/client_api_guide/client_events#trigger-events"},encryptedChannelSupport:{fullUrl:"https://github.com/pusher/pusher-js/tree/cc491015371a4bde5743d1c87a0fbac0feb53195#encrypted-channel-support"}}};var ht=function(t){const e=ct.urls[t];if(!e)return"";let n;return e.fullUrl?n=e.fullUrl:e.path&&(n=ct.baseUrl+e.path),n?"See: "+n:""};class ut extends H{constructor(t,e){super((function(e,n){M.debug("No callbacks on "+t+" for "+e)})),this.name=t,this.pusher=e,this.subscribed=!1,this.subscriptionPending=!1,this.subscriptionCancelled=!1}authorize(t,e){return e(null,{auth:""})}trigger(t,e){if(0!==t.indexOf("client-"))throw new tt("Event '"+t+"' does not start with 'client-'");if(!this.subscribed){var n=ht("triggeringClientEvents");M.warn("Client event triggered before channel 'subscription_succeeded' event . "+n)}return this.pusher.send_event(t,e,this.name)}disconnect(){this.subscribed=!1,this.subscriptionPending=!1}handleEvent(t){var e=t.event,n=t.data;if("pusher_internal:subscription_succeeded"===e)this.handleSubscriptionSucceededEvent(t);else if("pusher_internal:subscription_count"===e)this.handleSubscriptionCountEvent(t);else if(0!==e.indexOf("pusher_internal:")){this.emit(e,n,{})}}handleSubscriptionSucceededEvent(t){this.subscriptionPending=!1,this.subscribed=!0,this.subscriptionCancelled?this.pusher.unsubscribe(this.name):this.emit("pusher:subscription_succeeded",t.data)}handleSubscriptionCountEvent(t){t.data.subscription_count&&(this.subscriptionCount=t.data.subscription_count),this.emit("pusher:subscription_count",t.data)}subscribe(){this.subscribed||(this.subscriptionPending=!0,this.subscriptionCancelled=!1,this.authorize(this.pusher.connection.socket_id,(t,e)=>{t?(this.subscriptionPending=!1,M.error(t.toString()),this.emit("pusher:subscription_error",Object.assign({},{type:"AuthError",error:t.message},t instanceof at?{status:t.status}:{}))):this.pusher.send_event("pusher:subscribe",{auth:e.auth,channel_data:e.channel_data,channel:this.name})}))}unsubscribe(){this.subscribed=!1,this.pusher.send_event("pusher:unsubscribe",{channel:this.name})}cancelSubscription(){this.subscriptionCancelled=!0}reinstateSubscription(){this.subscriptionCancelled=!1}}class lt extends ut{authorize(t,e){return this.pusher.config.channelAuthorizer({channelName:this.name,socketId:t},e)}}class dt{constructor(){this.reset()}get(t){return Object.prototype.hasOwnProperty.call(this.members,t)?{id:t,info:this.members[t]}:null}each(t){_(this.members,(e,n)=>{t(this.get(n))})}setMyID(t){this.myID=t}onSubscription(t){this.members=t.presence.hash,this.count=t.presence.count,this.me=this.get(this.myID)}addMember(t){return null===this.get(t.user_id)&&this.count++,this.members[t.user_id]=t.user_info,this.get(t.user_id)}removeMember(t){var e=this.get(t.user_id);return e&&(delete this.members[t.user_id],this.count--),e}reset(){this.members={},this.count=0,this.myID=null,this.me=null}}var pt=function(t,e,n,i){return new(n||(n=Promise))((function(s,r){function o(t){try{c(i.next(t))}catch(t){r(t)}}function a(t){try{c(i.throw(t))}catch(t){r(t)}}function c(t){var e;t.done?s(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(o,a)}c((i=i.apply(t,e||[])).next())}))};class ft extends lt{constructor(t,e){super(t,e),this.members=new dt}authorize(t,e){super.authorize(t,(t,n)=>pt(this,void 0,void 0,(function*(){if(!t)if(null!=(n=n).channel_data){var i=JSON.parse(n.channel_data);this.members.setMyID(i.user_id)}else{if(yield this.pusher.user.signinDonePromise,null==this.pusher.user.user_data){let t=ht("authorizationEndpoint");return M.error(`Invalid auth response for channel '${this.name}', expected 'channel_data' field. ${t}, or the user should be signed in.`),void e("Invalid auth response")}this.members.setMyID(this.pusher.user.user_data.id)}e(t,n)})))}handleEvent(t){var e=t.event;if(0===e.indexOf("pusher_internal:"))this.handleInternalEvent(t);else{var n=t.data,i={};t.user_id&&(i.user_id=t.user_id),this.emit(e,n,i)}}handleInternalEvent(t){var e=t.event,n=t.data;switch(e){case"pusher_internal:subscription_succeeded":this.handleSubscriptionSucceededEvent(t);break;case"pusher_internal:subscription_count":this.handleSubscriptionCountEvent(t);break;case"pusher_internal:member_added":var i=this.members.addMember(n);this.emit("pusher:member_added",i);break;case"pusher_internal:member_removed":var s=this.members.removeMember(n);s&&this.emit("pusher:member_removed",s)}}handleSubscriptionSucceededEvent(t){this.subscriptionPending=!1,this.subscribed=!0,this.subscriptionCancelled?this.pusher.unsubscribe(this.name):(this.members.onSubscription(t.data),this.emit("pusher:subscription_succeeded",this.members))}disconnect(){this.members.reset(),super.disconnect()}}var gt=n(1),bt=n(0);class mt extends lt{constructor(t,e,n){super(t,e),this.key=null,this.nacl=n}authorize(t,e){super.authorize(t,(t,n)=>{if(t)return void e(t,n);let i=n.shared_secret;i?(this.key=Object(bt.decode)(i),delete n.shared_secret,e(null,n)):e(new Error("No shared_secret key in auth payload for encrypted channel: "+this.name),null)})}trigger(t,e){throw new st("Client events are not currently supported for encrypted channels")}handleEvent(t){var e=t.event,n=t.data;0!==e.indexOf("pusher_internal:")&&0!==e.indexOf("pusher:")?this.handleEncryptedEvent(e,n):super.handleEvent(t)}handleEncryptedEvent(t,e){if(!this.key)return void M.debug("Received encrypted event before key has been retrieved from the authEndpoint");if(!e.ciphertext||!e.nonce)return void M.error("Unexpected format for encrypted event, expected object with `ciphertext` and `nonce` fields, got: "+e);let n=Object(bt.decode)(e.ciphertext);if(n.length{e?M.error(`Failed to make a request to the authEndpoint: ${r}. Unable to fetch new key, so dropping encrypted event`):(s=this.nacl.secretbox.open(n,i,this.key),null!==s?this.emit(t,this.getDataToEmit(s)):M.error("Failed to decrypt event with new key. Dropping encrypted event"))});this.emit(t,this.getDataToEmit(s))}getDataToEmit(t){let e=Object(gt.decode)(t);try{return JSON.parse(e)}catch(t){return e}}}class vt extends H{constructor(t,e){super(),this.state="initialized",this.connection=null,this.key=t,this.options=e,this.timeline=this.options.timeline,this.usingTLS=this.options.useTLS,this.errorCallbacks=this.buildErrorCallbacks(),this.connectionCallbacks=this.buildConnectionCallbacks(this.errorCallbacks),this.handshakeCallbacks=this.buildHandshakeCallbacks(this.errorCallbacks);var n=ae.getNetwork();n.bind("online",()=>{this.timeline.info({netinfo:"online"}),"connecting"!==this.state&&"unavailable"!==this.state||this.retryIn(0)}),n.bind("offline",()=>{this.timeline.info({netinfo:"offline"}),this.connection&&this.sendActivityCheck()}),this.updateStrategy()}switchCluster(t){this.key=t,this.updateStrategy(),this.retryIn(0)}connect(){this.connection||this.runner||(this.strategy.isSupported()?(this.updateState("connecting"),this.startConnecting(),this.setUnavailableTimer()):this.updateState("failed"))}send(t){return!!this.connection&&this.connection.send(t)}send_event(t,e,n){return!!this.connection&&this.connection.send_event(t,e,n)}disconnect(){this.disconnectInternally(),this.updateState("disconnected")}isUsingTLS(){return this.usingTLS}startConnecting(){var t=(e,n)=>{e?this.runner=this.strategy.connect(0,t):"error"===n.action?(this.emit("error",{type:"HandshakeError",error:n.error}),this.timeline.error({handshakeError:n.error})):(this.abortConnecting(),this.handshakeCallbacks[n.action](n))};this.runner=this.strategy.connect(0,t)}abortConnecting(){this.runner&&(this.runner.abort(),this.runner=null)}disconnectInternally(){(this.abortConnecting(),this.clearRetryTimer(),this.clearUnavailableTimer(),this.connection)&&this.abandonConnection().close()}updateStrategy(){this.strategy=this.options.getStrategy({key:this.key,timeline:this.timeline,useTLS:this.usingTLS})}retryIn(t){this.timeline.info({action:"retry",delay:t}),t>0&&this.emit("connecting_in",Math.round(t/1e3)),this.retryTimer=new g(t||0,()=>{this.disconnectInternally(),this.connect()})}clearRetryTimer(){this.retryTimer&&(this.retryTimer.ensureAborted(),this.retryTimer=null)}setUnavailableTimer(){this.unavailableTimer=new g(this.options.unavailableTimeout,()=>{this.updateState("unavailable")})}clearUnavailableTimer(){this.unavailableTimer&&this.unavailableTimer.ensureAborted()}sendActivityCheck(){this.stopActivityCheck(),this.connection.ping(),this.activityTimer=new g(this.options.pongTimeout,()=>{this.timeline.error({pong_timed_out:this.options.pongTimeout}),this.retryIn(0)})}resetActivityCheck(){this.stopActivityCheck(),this.connection&&!this.connection.handlesActivityChecks()&&(this.activityTimer=new g(this.activityTimeout,()=>{this.sendActivityCheck()}))}stopActivityCheck(){this.activityTimer&&this.activityTimer.ensureAborted()}buildConnectionCallbacks(t){return v({},t,{message:t=>{this.resetActivityCheck(),this.emit("message",t)},ping:()=>{this.send_event("pusher:pong",{})},activity:()=>{this.resetActivityCheck()},error:t=>{this.emit("error",t)},closed:()=>{this.abandonConnection(),this.shouldRetry()&&this.retryIn(1e3)}})}buildHandshakeCallbacks(t){return v({},t,{connected:t=>{this.activityTimeout=Math.min(this.options.activityTimeout,t.activityTimeout,t.connection.activityTimeout||1/0),this.clearUnavailableTimer(),this.setConnection(t.connection),this.socket_id=this.connection.id,this.updateState("connected",{socket_id:this.socket_id})}})}buildErrorCallbacks(){let t=t=>e=>{e.error&&this.emit("error",{type:"WebSocketError",error:e.error}),t(e)};return{tls_only:t(()=>{this.usingTLS=!0,this.updateStrategy(),this.retryIn(0)}),refused:t(()=>{this.disconnect()}),backoff:t(()=>{this.retryIn(1e3)}),retry:t(()=>{this.retryIn(0)})}}setConnection(t){for(var e in this.connection=t,this.connectionCallbacks)this.connection.bind(e,this.connectionCallbacks[e]);this.resetActivityCheck()}abandonConnection(){if(this.connection){for(var t in this.stopActivityCheck(),this.connectionCallbacks)this.connection.unbind(t,this.connectionCallbacks[t]);var e=this.connection;return this.connection=null,e}}updateState(t,e){var n=this.state;if(this.state=t,n!==t){var i=t;"connected"===i&&(i+=" with new socket ID "+e.socket_id),M.debug("State changed",n+" -> "+i),this.timeline.info({state:t,params:e}),this.emit("state_change",{previous:n,current:t}),this.emit(t,e)}}shouldRetry(){return"connecting"===this.state||"connected"===this.state}}class yt{constructor(){this.channels={}}add(t,e){return this.channels[t]||(this.channels[t]=function(t,e){if(0===t.indexOf("private-encrypted-")){if(e.config.nacl)return St.createEncryptedChannel(t,e,e.config.nacl);let n="Tried to subscribe to a private-encrypted- channel but no nacl implementation available",i=ht("encryptedChannelSupport");throw new st(`${n}. ${i}`)}if(0===t.indexOf("private-"))return St.createPrivateChannel(t,e);if(0===t.indexOf("presence-"))return St.createPresenceChannel(t,e);if(0===t.indexOf("#"))throw new et('Cannot create a channel with name "'+t+'".');return St.createChannel(t,e)}(t,e)),this.channels[t]}all(){return function(t){var e=[];return _(t,(function(t){e.push(t)})),e}(this.channels)}find(t){return this.channels[t]}remove(t){var e=this.channels[t];return delete this.channels[t],e}disconnect(){_(this.channels,(function(t){t.disconnect()}))}}var St={createChannels:()=>new yt,createConnectionManager:(t,e)=>new vt(t,e),createChannel:(t,e)=>new ut(t,e),createPrivateChannel:(t,e)=>new lt(t,e),createPresenceChannel:(t,e)=>new ft(t,e),createEncryptedChannel:(t,e,n)=>new mt(t,e,n),createTimelineSender:(t,e)=>new Z(t,e),createHandshake:(t,e)=>new Q(t,e),createAssistantToTheTransportManager:(t,e,n)=>new G(t,e,n)};class _t{constructor(t){this.options=t||{},this.livesLeft=this.options.lives||1/0}getAssistant(t){return St.createAssistantToTheTransportManager(this,t,{minPingDelay:this.options.minPingDelay,maxPingDelay:this.options.maxPingDelay})}isAlive(){return this.livesLeft>0}reportDeath(){this.livesLeft-=1}}class wt{constructor(t,e){this.strategies=t,this.loop=Boolean(e.loop),this.failFast=Boolean(e.failFast),this.timeout=e.timeout,this.timeoutLimit=e.timeoutLimit}isSupported(){return O(this.strategies,m.method("isSupported"))}connect(t,e){var n=this.strategies,i=0,s=this.timeout,r=null,o=(a,c)=>{c?e(null,c):(i+=1,this.loop&&(i%=n.length),i0&&(s=new g(n.timeout,(function(){r.abort(),i(!0)}))),r=t.connect(e,(function(t,e){t&&s&&s.isRunning()&&!n.failFast||(s&&s.ensureAborted(),i(t,e))})),{abort:function(){s&&s.ensureAborted(),r.abort()},forceMinPriority:function(t){r.forceMinPriority(t)}}}}class Ct{constructor(t){this.strategies=t}isSupported(){return O(this.strategies,m.method("isSupported"))}connect(t,e){return function(t,e,n){var i=k(t,(function(t,i,s,r){return t.connect(e,n(i,r))}));return{abort:function(){C(i,kt)},forceMinPriority:function(t){C(i,(function(e){e.forceMinPriority(t)}))}}}(this.strategies,t,(function(t,n){return function(i,s){n[t].error=i,i?function(t){return function(t,e){for(var n=0;n=m.now()){var o=this.transports[i.transport];o&&(["ws","wss"].includes(i.transport)||s>3?(this.timeline.info({cached:!0,transport:i.transport,latency:i.latency}),r.push(new wt([o],{timeout:2*i.latency+1e3,failFast:!0}))):s++)}var a=m.now(),c=r.pop().connect(t,(function i(o,h){o?(Ot(n),r.length>0?(a=m.now(),c=r.pop().connect(t,i)):e(o)):(!function(t,e,n,i){var s=ae.getLocalStorage();if(s)try{s[Pt(t)]=L({timestamp:m.now(),transport:e,latency:n,cacheSkipCount:i})}catch(t){}}(n,h.transport.name,m.now()-a,s),e(null,h))}));return{abort:function(){c.abort()},forceMinPriority:function(e){t=e,c&&c.forceMinPriority(e)}}}}function Pt(t){return"pusherTransport"+(t?"TLS":"NonTLS")}function Ot(t){var e=ae.getLocalStorage();if(e)try{delete e[Pt(t)]}catch(t){}}class Et{constructor(t,{delay:e}){this.strategy=t,this.options={delay:e}}isSupported(){return this.strategy.isSupported()}connect(t,e){var n,i=this.strategy,s=new g(this.options.delay,(function(){n=i.connect(t,e)}));return{abort:function(){s.ensureAborted(),n&&n.abort()},forceMinPriority:function(e){t=e,n&&n.forceMinPriority(e)}}}}class xt{constructor(t,e,n){this.test=t,this.trueBranch=e,this.falseBranch=n}isSupported(){return(this.test()?this.trueBranch:this.falseBranch).isSupported()}connect(t,e){return(this.test()?this.trueBranch:this.falseBranch).connect(t,e)}}class Lt{constructor(t){this.strategy=t}isSupported(){return this.strategy.isSupported()}connect(t,e){var n=this.strategy.connect(t,(function(t,i){i&&n.abort(),e(t,i)}));return n}}function At(t){return function(){return t.isSupported()}}var Rt=function(t,e,n){var i={};function s(e,s,r,o,a){var c=n(t,e,s,r,o,a);return i[e]=c,c}var r,o=Object.assign({},e,{hostNonTLS:t.wsHost+":"+t.wsPort,hostTLS:t.wsHost+":"+t.wssPort,httpPath:t.wsPath}),a=v({},o,{useTLS:!0}),c=Object.assign({},e,{hostNonTLS:t.httpHost+":"+t.httpPort,hostTLS:t.httpHost+":"+t.httpsPort,httpPath:t.httpPath}),h={loop:!0,timeout:15e3,timeoutLimit:6e4},u=new _t({minPingDelay:1e4,maxPingDelay:t.activityTimeout}),l=new _t({lives:2,minPingDelay:1e4,maxPingDelay:t.activityTimeout}),d=s("ws","ws",3,o,u),p=s("wss","ws",3,a,u),f=s("xhr_streaming","xhr_streaming",1,c,l),g=s("xhr_polling","xhr_polling",1,c),b=new wt([d],h),m=new wt([p],h),y=new wt([f],h),S=new wt([g],h),_=new wt([new xt(At(y),new Ct([y,new Et(S,{delay:4e3})]),S)],h);return r=e.useTLS?new Ct([b,new Et(_,{delay:2e3})]):new Ct([b,new Et(m,{delay:2e3}),new Et(_,{delay:5e3})]),new Tt(new Lt(new xt(At(d),r,_)),i,{ttl:18e5,timeline:e.timeline,useTLS:e.useTLS})};class It extends H{constructor(t,e,n){super(),this.hooks=t,this.method=e,this.url=n}start(t){this.position=0,this.xhr=this.hooks.getRequest(this),this.unloader=()=>{this.close()},ae.addUnloadListener(this.unloader),this.xhr.open(this.method,this.url,!0),this.xhr.setRequestHeader&&this.xhr.setRequestHeader("Content-Type","application/json"),this.xhr.send(t)}close(){this.unloader&&(ae.removeUnloadListener(this.unloader),this.unloader=null),this.xhr&&(this.hooks.abortRequest(this.xhr),this.xhr=null)}onChunk(t,e){for(;;){var n=this.advanceBuffer(e);if(!n)break;this.emit("chunk",{status:t,data:n})}this.isBufferTooLong(e)&&this.emit("buffer_too_long")}advanceBuffer(t){var e=t.slice(this.position),n=e.indexOf("\n");return-1!==n?(this.position+=n+1,e.slice(0,n)):null}isBufferTooLong(t){return this.position===t.length&&t.length>262144}}var jt;!function(t){t[t.CONNECTING=0]="CONNECTING",t[t.OPEN=1]="OPEN",t[t.CLOSED=3]="CLOSED"}(jt||(jt={}));var Dt=jt,Nt=1;function Ut(t){var e=-1===t.indexOf("?")?"?":"&";return t+e+"t="+ +new Date+"&n="+Nt++}function Ht(t){return ae.randomInt(t)}var Mt=class{constructor(t,e){this.hooks=t,this.session=Ht(1e3)+"/"+function(t){for(var e=[],n=0;n{this.onChunk(t)}),this.stream.bind("finished",t=>{this.hooks.onFinished(this,t)}),this.stream.bind("buffer_too_long",()=>{this.reconnect()});try{this.stream.start()}catch(t){m.defer(()=>{this.onError(t),this.onClose(1006,"Could not start streaming",!1)})}}closeStream(){this.stream&&(this.stream.unbind_all(),this.stream.close(),this.stream=null)}},zt={getReceiveURL:function(t,e){return t.base+"/"+e+"/xhr_streaming"+t.queryString},onHeartbeat:function(t){t.sendRaw("[]")},sendHeartbeat:function(t){t.sendRaw("[]")},onFinished:function(t,e){t.onClose(1006,"Connection interrupted ("+e+")",!1)}},Bt={getReceiveURL:function(t,e){return t.base+"/"+e+"/xhr"+t.queryString},onHeartbeat:function(){},sendHeartbeat:function(t){t.sendRaw("[]")},onFinished:function(t,e){200===e?t.reconnect():t.onClose(1006,"Connection interrupted ("+e+")",!1)}},qt={getRequest:function(t){var e=new(ae.getXHRAPI());return e.onreadystatechange=e.onprogress=function(){switch(e.readyState){case 3:e.responseText&&e.responseText.length>0&&t.onChunk(e.status,e.responseText);break;case 4:e.responseText&&e.responseText.length>0&&t.onChunk(e.status,e.responseText),t.emit("finished",e.status),t.close()}},e},abortRequest:function(t){t.onreadystatechange=null,t.abort()}},Ft={getDefaultStrategy:Rt,Transports:X,transportConnectionInitializer:function(){this.timeline.info(this.buildTimelineMessage({transport:this.name+(this.options.useTLS?"s":"")})),this.hooks.isInitialized()?this.changeState("initialized"):this.onClose()},HTTPFactory:{createStreamingSocket(t){return this.createSocket(zt,t)},createPollingSocket(t){return this.createSocket(Bt,t)},createSocket:(t,e)=>new Mt(t,e),createXHR(t,e){return this.createRequest(qt,t,e)},createRequest:(t,e,n)=>new It(t,e,n)},setup(t){t.ready()},getLocalStorage(){},getClientFeatures:()=>w(P({ws:X.ws},(function(t){return t.isSupported({})}))),getProtocol:()=>"http:",isXHRSupported:()=>!0,createSocketRequest(t,e){if(this.isXHRSupported())return this.HTTPFactory.createXHR(t,e);throw"Cross-origin HTTP requests are not supported"},createXHR(){return new(this.getXHRAPI())},createWebSocket(t){return new(this.getWebSocketAPI())(t)},addUnloadListener(t){},removeUnloadListener(t){}};var $t=new class extends H{isOnline(){return!0}},Jt=function(t,e,n,i,s){var r=new Headers;for(var o in r.set("Content-Type","application/x-www-form-urlencoded"),n.headers)r.set(o,n.headers[o]);if(null!=n.headersProvider){const t=n.headersProvider();for(var o in t)r.set(o,t[o])}var a=e,c=new Request(n.endpoint,{headers:r,body:a,credentials:"same-origin",method:"POST"});return fetch(c).then(t=>{let{status:e}=t;if(200===e)return t.text();throw new at(e,`Could not get ${i.toString()} info from your auth endpoint, status: ${e}`)}).then(t=>{let e;try{e=JSON.parse(t)}catch(e){throw new at(200,`JSON returned from ${i.toString()} endpoint was invalid, yet status code was 200. Data was: ${t}`)}s(null,e)}).catch(t=>{s(t,null)})},Wt={name:"xhr",getAgent:function(t,e){return function(n,i){var s="http"+(e?"s":"")+"://"+(t.host||t.options.host)+t.options.path,r=x(n);fetch(s+="/2?"+r).then(t=>{if(200!==t.status)throw`received ${t.status} from stats.pusher.com`;return t.json()}).then(({host:e})=>{e&&(t.host=e)}).catch(t=>{M.debug("TimelineSender Error: ",t)})}}};const{getDefaultStrategy:Xt,Transports:Gt,setup:Vt,getProtocol:Yt,isXHRSupported:Kt,getLocalStorage:Qt,createXHR:Zt,createWebSocket:te,addUnloadListener:ee,removeUnloadListener:ne,transportConnectionInitializer:ie,createSocketRequest:se,HTTPFactory:re}=Ft;var oe,ae={getDefaultStrategy:Xt,Transports:Gt,setup:Vt,getProtocol:Yt,isXHRSupported:Kt,getLocalStorage:Qt,createXHR:Zt,createWebSocket:te,addUnloadListener:ee,removeUnloadListener:ne,transportConnectionInitializer:ie,createSocketRequest:se,HTTPFactory:re,TimelineTransport:Wt,getAuthorizers:()=>({ajax:Jt}),getWebSocketAPI:()=>WebSocket,getXHRAPI:()=>XMLHttpRequest,getNetwork:()=>$t,randomInt:t=>Math.floor((globalThis.crypto||globalThis.msCrypto).getRandomValues(new Uint32Array(1))[0]/Math.pow(2,32)*t)};!function(t){t[t.ERROR=3]="ERROR",t[t.INFO=6]="INFO",t[t.DEBUG=7]="DEBUG"}(oe||(oe={}));var ce=oe;class he{constructor(t,e,n){this.key=t,this.session=e,this.events=[],this.options=n||{},this.sent=0,this.uniqueID=0}log(t,e){t<=this.options.level&&(this.events.push(v({},e,{timestamp:m.now()})),this.options.limit&&this.events.length>this.options.limit&&this.events.shift())}error(t){this.log(ce.ERROR,t)}info(t){this.log(ce.INFO,t)}debug(t){this.log(ce.DEBUG,t)}isEmpty(){return 0===this.events.length}send(t,e){var n=v({session:this.session,bundle:this.sent+1,key:this.key,lib:"js",version:this.options.version,cluster:this.options.cluster,features:this.options.features,timeline:this.events},this.options.params);return this.events=[],t(n,(t,n)=>{t||this.sent++,e&&e(t,n)}),!0}generateUniqueID(){return this.uniqueID++,this.uniqueID}}class ue{constructor(t,e,n,i){this.name=t,this.priority=e,this.transport=n,this.options=i||{}}isSupported(){return this.transport.isSupported({useTLS:this.options.useTLS})}connect(t,e){if(!this.isSupported())return le(new ot,e);if(this.priority{n||(h(),s?s.close():i.close())},forceMinPriority:t=>{n||this.priority{if(void 0===ae.getAuthorizers()[t.transport])throw`'${t.transport}' is not a recognized auth transport`;return(e,n)=>{const i=((t,e)=>{var n="socket_id="+encodeURIComponent(t.socketId);for(var i in e.params)n+="&"+encodeURIComponent(i)+"="+encodeURIComponent(e.params[i]);if(null!=e.paramsProvider){let t=e.paramsProvider();for(var i in t)n+="&"+encodeURIComponent(i)+"="+encodeURIComponent(t[i])}return n})(e,t);ae.getAuthorizers()[t.transport](ae,i,t,pe.UserAuthentication,n)}};var me=t=>{if(void 0===ae.getAuthorizers()[t.transport])throw`'${t.transport}' is not a recognized auth transport`;return(e,n)=>{const i=((t,e)=>{var n="socket_id="+encodeURIComponent(t.socketId);for(var i in n+="&channel_name="+encodeURIComponent(t.channelName),e.params)n+="&"+encodeURIComponent(i)+"="+encodeURIComponent(e.params[i]);if(null!=e.paramsProvider){let t=e.paramsProvider();for(var i in t)n+="&"+encodeURIComponent(i)+"="+encodeURIComponent(t[i])}return n})(e,t);ae.getAuthorizers()[t.transport](ae,i,t,pe.ChannelAuthorization,n)}};function ve(t,e){let n={activityTimeout:t.activityTimeout||A.activityTimeout,cluster:t.cluster,httpPath:t.httpPath||A.httpPath,httpPort:t.httpPort||A.httpPort,httpsPort:t.httpsPort||A.httpsPort,pongTimeout:t.pongTimeout||A.pongTimeout,statsHost:t.statsHost||A.stats_host,unavailableTimeout:t.unavailableTimeout||A.unavailableTimeout,wsPath:t.wsPath||A.wsPath,wsPort:t.wsPort||A.wsPort,wssPort:t.wssPort||A.wssPort,enableStats:we(t),httpHost:ye(t),useTLS:_e(t),wsHost:Se(t),userAuthenticator:Ce(t),channelAuthorizer:ke(t,e)};return"disabledTransports"in t&&(n.disabledTransports=t.disabledTransports),"enabledTransports"in t&&(n.enabledTransports=t.enabledTransports),"ignoreNullOrigin"in t&&(n.ignoreNullOrigin=t.ignoreNullOrigin),"timelineParams"in t&&(n.timelineParams=t.timelineParams),"nacl"in t&&(n.nacl=t.nacl),n}function ye(t){return t.httpHost?t.httpHost:t.cluster?`sockjs-${t.cluster}.pusher.com`:A.httpHost}function Se(t){return t.wsHost?t.wsHost:`ws-${t.cluster}.pusher.com`}function _e(t){return"https:"===ae.getProtocol()||!1!==t.forceTLS}function we(t){return"enableStats"in t?t.enableStats:"disableStats"in t&&!t.disableStats}function Ce(t){const e=Object.assign(Object.assign({},A.userAuthentication),t.userAuthentication);return"customHandler"in e&&null!=e.customHandler?e.customHandler:be(e)}function ke(t,e){const n=function(t,e){let n;return"channelAuthorization"in t?n=Object.assign(Object.assign({},A.channelAuthorization),t.channelAuthorization):(n={transport:t.authTransport||A.authTransport,endpoint:t.authEndpoint||A.authEndpoint},"auth"in t&&("params"in t.auth&&(n.params=t.auth.params),"headers"in t.auth&&(n.headers=t.auth.headers)),"authorizer"in t&&(n.customHandler=((t,e,n)=>{const i={authTransport:e.transport,authEndpoint:e.endpoint,auth:{params:e.params,headers:e.headers}};return(e,s)=>{const r=t.channel(e.channelName);n(r,i).authorize(e.socketId,s)}})(e,n,t.authorizer))),n}(t,e);return"customHandler"in n&&null!=n.customHandler?n.customHandler:me(n)}class Te extends H{constructor(t){super((function(t,e){M.debug("No callbacks on watchlist events for "+t)})),this.pusher=t,this.bindWatchlistInternalEvent()}handleEvent(t){t.data.events.forEach(t=>{this.emit(t.name,t)})}bindWatchlistInternalEvent(){this.pusher.connection.bind("message",t=>{"pusher_internal:watchlist_events"===t.event&&this.handleEvent(t)})}}var Pe=function(){let t,e;return{promise:new Promise((n,i)=>{t=n,e=i}),resolve:t,reject:e}};class Oe extends H{constructor(t){super((function(t,e){M.debug("No callbacks on user for "+t)})),this.signin_requested=!1,this.user_data=null,this.serverToUserChannel=null,this.signinDonePromise=null,this._signinDoneResolve=null,this._onAuthorize=(t,e)=>{if(t)return M.warn("Error during signin: "+t),void this._cleanup();this.pusher.send_event("pusher:signin",{auth:e.auth,user_data:e.user_data})},this.pusher=t,this.pusher.connection.bind("state_change",({previous:t,current:e})=>{"connected"!==t&&"connected"===e&&this._signin(),"connected"===t&&"connected"!==e&&(this._cleanup(),this._newSigninPromiseIfNeeded())}),this.watchlist=new Te(t),this.pusher.connection.bind("message",t=>{"pusher:signin_success"===t.event&&this._onSigninSuccess(t.data),this.serverToUserChannel&&this.serverToUserChannel.name===t.channel&&this.serverToUserChannel.handleEvent(t)})}signin(){this.signin_requested||(this.signin_requested=!0,this._signin())}_signin(){this.signin_requested&&(this._newSigninPromiseIfNeeded(),"connected"===this.pusher.connection.state&&this.pusher.config.userAuthenticator({socketId:this.pusher.connection.socket_id},this._onAuthorize))}_onSigninSuccess(t){try{this.user_data=JSON.parse(t.user_data)}catch(e){return M.error("Failed parsing user data after signin: "+t.user_data),void this._cleanup()}if("string"!=typeof this.user_data.id||""===this.user_data.id)return M.error("user_data doesn't contain an id. user_data: "+this.user_data),void this._cleanup();this._signinDoneResolve(),this._subscribeChannels()}_subscribeChannels(){this.serverToUserChannel=new ut("#server-to-user-"+this.user_data.id,this.pusher),this.serverToUserChannel.bind_global((t,e)=>{0!==t.indexOf("pusher_internal:")&&0!==t.indexOf("pusher:")&&this.emit(t,e)}),(t=>{t.subscriptionPending&&t.subscriptionCancelled?t.reinstateSubscription():t.subscriptionPending||"connected"!==this.pusher.connection.state||t.subscribe()})(this.serverToUserChannel)}_cleanup(){this.user_data=null,this.serverToUserChannel&&(this.serverToUserChannel.unbind_all(),this.serverToUserChannel.disconnect(),this.serverToUserChannel=null),this.signin_requested&&this._signinDoneResolve()}_newSigninPromiseIfNeeded(){if(!this.signin_requested)return;if(this.signinDonePromise&&!this.signinDonePromise.done)return;const{promise:t,resolve:e,reject:n}=Pe();t.done=!1;const i=()=>{t.done=!0};t.then(i).catch(i),this.signinDonePromise=t,this._signinDoneResolve=e}}class Ee{static ready(){Ee.isReady=!0;for(var t=0,e=Ee.instances.length;tae.getDefaultStrategy(this.config,t,fe),timeline:this.timeline,activityTimeout:this.config.activityTimeout,pongTimeout:this.config.pongTimeout,unavailableTimeout:this.config.unavailableTimeout,useTLS:Boolean(this.config.useTLS)}),this.connection.bind("connected",()=>{this.subscribeAll(),this.timelineSender&&this.timelineSender.send(this.connection.isUsingTLS())}),this.connection.bind("message",t=>{var e=0===t.event.indexOf("pusher_internal:");if(t.channel){var n=this.channel(t.channel);n&&n.handleEvent(t)}e||this.global_emitter.emit(t.event,t.data)}),this.connection.bind("connecting",()=>{this.channels.disconnect()}),this.connection.bind("disconnected",()=>{this.channels.disconnect()}),this.connection.bind("error",t=>{M.warn(t)}),Ee.instances.push(this),this.timeline.info({instances:Ee.instances.length}),this.user=new Oe(this),Ee.isReady&&this.connect()}switchCluster(t){const{appKey:e,cluster:n}=t;this.key=e,this.options=Object.assign(Object.assign({},this.options),{cluster:n}),this.config=ve(this.options,this),this.connection.switchCluster(this.key)}channel(t){return this.channels.find(t)}allChannels(){return this.channels.all()}connect(){if(this.connection.connect(),this.timelineSender&&!this.timelineSenderTimer){var t=this.connection.isUsingTLS(),e=this.timelineSender;this.timelineSenderTimer=new b(6e4,(function(){e.send(t)}))}}disconnect(){this.connection.disconnect(),this.timelineSenderTimer&&(this.timelineSenderTimer.ensureAborted(),this.timelineSenderTimer=null)}bind(t,e,n){return this.global_emitter.bind(t,e,n),this}unbind(t,e,n){return this.global_emitter.unbind(t,e,n),this}bind_global(t){return this.global_emitter.bind_global(t),this}unbind_global(t){return this.global_emitter.unbind_global(t),this}unbind_all(t){return this.global_emitter.unbind_all(),this}subscribeAll(){var t;for(t in this.channels.channels)this.channels.channels.hasOwnProperty(t)&&this.subscribe(t)}subscribe(t){var e=this.channels.add(t,this);return e.subscriptionPending&&e.subscriptionCancelled?e.reinstateSubscription():e.subscriptionPending||"connected"!==this.connection.state||e.subscribe(),e}unsubscribe(t){var e=this.channels.find(t);e&&e.subscriptionPending?e.cancelSubscription():(e=this.channels.remove(t))&&e.subscribed&&e.unsubscribe()}send_event(t,e,n){return this.connection.send_event(t,e,n)}shouldUseTLS(){return this.config.useTLS}signin(){this.user.signin()}}Ee.instances=[],Ee.isReady=!1,Ee.logToConsole=!1,Ee.Runtime=ae,Ee.ScriptReceivers=ae.ScriptReceivers,Ee.DependenciesReceivers=ae.DependenciesReceivers,Ee.auth_callbacks=ae.auth_callbacks;var xe=e.default=Ee;ae.setup(Ee)}])})); //# sourceMappingURL=pusher.worker.min.js.map \ No newline at end of file diff --git a/dist/worker/pusher.worker.min.js.map b/dist/worker/pusher.worker.min.js.map index 321349d75..23e573e31 100644 --- a/dist/worker/pusher.worker.min.js.map +++ b/dist/worker/pusher.worker.min.js.map @@ -1 +1 @@ -{"version":3,"sources":["webpack://Pusher/webpack/universalModuleDefinition","webpack://Pusher/webpack/bootstrap","webpack://Pusher/./node_modules/@stablelib/base64/base64.ts","webpack://Pusher/./node_modules/@stablelib/utf8/utf8.ts","webpack://Pusher/./src/core/pusher.js","webpack://Pusher/./src/core/base64.ts","webpack://Pusher/./src/core/utils/timers/abstract_timer.ts","webpack://Pusher/./src/core/utils/timers/index.ts","webpack://Pusher/./src/core/util.ts","webpack://Pusher/./src/core/utils/collections.ts","webpack://Pusher/./src/core/defaults.ts","webpack://Pusher/./src/core/transports/url_schemes.ts","webpack://Pusher/./src/core/events/callback_registry.ts","webpack://Pusher/./src/core/events/dispatcher.ts","webpack://Pusher/./src/core/logger.ts","webpack://Pusher/./src/core/transports/transport_connection.ts","webpack://Pusher/./src/core/transports/transport.ts","webpack://Pusher/./src/runtimes/isomorphic/transports/transports.ts","webpack://Pusher/./src/core/transports/assistant_to_the_transport_manager.ts","webpack://Pusher/./src/core/connection/protocol/protocol.ts","webpack://Pusher/./src/core/connection/connection.ts","webpack://Pusher/./src/core/connection/handshake/index.ts","webpack://Pusher/./src/core/timeline/timeline_sender.ts","webpack://Pusher/./src/core/errors.ts","webpack://Pusher/./src/core/utils/url_store.ts","webpack://Pusher/./src/core/channels/channel.ts","webpack://Pusher/./src/core/channels/private_channel.ts","webpack://Pusher/./src/core/channels/members.ts","webpack://Pusher/./src/core/channels/presence_channel.ts","webpack://Pusher/./src/core/channels/encrypted_channel.ts","webpack://Pusher/./src/core/connection/connection_manager.ts","webpack://Pusher/./src/core/channels/channels.ts","webpack://Pusher/./src/core/utils/factory.ts","webpack://Pusher/./src/core/transports/transport_manager.ts","webpack://Pusher/./src/core/strategies/sequential_strategy.ts","webpack://Pusher/./src/core/strategies/best_connected_ever_strategy.ts","webpack://Pusher/./src/core/strategies/websocket_prioritized_cached_strategy.ts","webpack://Pusher/./src/core/strategies/delayed_strategy.ts","webpack://Pusher/./src/core/strategies/if_strategy.ts","webpack://Pusher/./src/core/strategies/first_connected_strategy.ts","webpack://Pusher/./src/runtimes/isomorphic/default_strategy.ts","webpack://Pusher/./src/core/http/http_request.ts","webpack://Pusher/./src/core/http/state.ts","webpack://Pusher/./src/core/http/http_socket.ts","webpack://Pusher/./src/core/http/http_streaming_socket.ts","webpack://Pusher/./src/core/http/http_polling_socket.ts","webpack://Pusher/./src/runtimes/isomorphic/http/http_xhr_request.ts","webpack://Pusher/./src/runtimes/isomorphic/runtime.ts","webpack://Pusher/./src/runtimes/isomorphic/transports/transport_connection_initializer.ts","webpack://Pusher/./src/runtimes/isomorphic/http/http.ts","webpack://Pusher/./src/runtimes/worker/net_info.ts","webpack://Pusher/./src/runtimes/worker/auth/fetch_auth.ts","webpack://Pusher/./src/runtimes/worker/timeline/fetch_timeline.ts","webpack://Pusher/./src/runtimes/worker/runtime.ts","webpack://Pusher/./src/core/timeline/level.ts","webpack://Pusher/./src/core/timeline/timeline.ts","webpack://Pusher/./src/core/strategies/transport_strategy.ts","webpack://Pusher/./src/core/strategies/strategy_builder.ts","webpack://Pusher/./src/core/auth/options.ts","webpack://Pusher/./src/core/auth/user_authenticator.ts","webpack://Pusher/./src/core/auth/channel_authorizer.ts","webpack://Pusher/./src/core/config.ts","webpack://Pusher/./src/core/auth/deprecated_channel_authorizer.ts","webpack://Pusher/./src/core/watchlist.ts","webpack://Pusher/./src/core/utils/flat_promise.ts","webpack://Pusher/./src/core/user.ts","webpack://Pusher/./src/core/pusher.ts","webpack://Pusher/./src/core/options.ts"],"names":["root","factory","exports","module","define","amd","this","installedModules","__webpack_require__","moduleId","i","l","modules","call","m","c","d","name","getter","o","Object","defineProperty","enumerable","get","r","Symbol","toStringTag","value","t","mode","__esModule","ns","create","key","bind","n","object","property","prototype","hasOwnProperty","p","s","_paddingCharacter","encodedLength","length","encode","data","out","_encodeByte","left","maxDecodedLength","decodedLength","_getPaddingLength","decode","Uint8Array","paddingLength","op","haveBad","v0","v1","v2","v3","_decodeChar","charCodeAt","Error","b","result","String","fromCharCode","Coder","stdCoder","URLSafeCoder","urlSafeCoder","INVALID_UTF8","arr","pos","chars","min","n1","n2","n3","push","join","default","b64chars","b64tab","charAt","cb_utob","cc","utob","u","replace","cb_encode","ccc","padlen","ord","btoa","set","clear","delay","callback","timer","clearTimeout","clearInterval","super","setTimeout","setInterval","now","Date","valueOf","defer","args","boundArguments","Array","slice","arguments","apply","concat","extend","target","sources","extensions","constructor","stringify","safeJSONStringify","arrayIndexOf","array","item","nativeIndexOf","indexOf","objectApply","f","keys","_","context","map","filter","test","filterObject","Boolean","any","encodeParamsObject","encodeURIComponent","toString","buildQueryString","params","undefined","method","source","JSON","e","objects","paths","derez","path","nu","$ref","VERSION","PROTOCOL","wsPort","wssPort","wsPath","httpHost","httpPort","httpsPort","httpPath","stats_host","authEndpoint","authTransport","activityTimeout","pongTimeout","unavailableTimeout","userAuthentication","endpoint","transport","channelAuthorization","cdn_http","cdn_https","dependency_suffix","getGenericURL","baseScheme","useTLS","hostTLS","hostNonTLS","getGenericPath","queryString","ws","getInitial","http","_callbacks","prefix","prefixedEventName","fn","names","removeCallback","removeAllCallbacks","binding","failThrough","callbacks","global_callbacks","eventName","add","remove","unbind","unbind_global","metadata","globalLog","message","console","log","globalLogWarn","globalLogError","warn","error","defaultLoggingFunction","logToConsole","hooks","priority","options","initialize","transportConnectionInitializer","state","timeline","id","generateUniqueID","handlesActivityChecks","supportsPing","socket","url","urls","getSocket","onError","changeState","bindListeners","debug","close","send","ping","beforeOpen","getPath","onopen","emit","type","buildTimelineMessage","closeEvent","code","reason","wasClean","unbindListeners","onOpen","onerror","onclose","onClose","onmessage","onMessage","onactivity","onActivity","info","cid","environment","isSupported","WSTransport","isInitialized","getWebSocketAPI","createWebSocket","httpConfiguration","streamingConfiguration","HTTPFactory","createStreamingSocket","pollingConfiguration","createPollingSocket","xhrConfiguration","isXHRSupported","xhr_streaming","xhr_polling","manager","minPingDelay","maxPingDelay","pingDelay","connection","createConnection","openTimestamp","onClosed","reportDeath","lifespan","Math","max","isAlive","Protocol","decodeMessage","messageEvent","messageData","parse","pusherEventData","pusherEvent","event","channel","user_id","encodeMessage","processHandshake","activity_timeout","action","socket_id","getCloseAction","getCloseError","send_event","listeners","activity","closed","handleCloseEvent","listener","finish","isEmpty","TimelineTransport","getAgent","BadEventName","msg","setPrototypeOf","BadChannelName","TransportPriorityTooLow","TransportClosed","UnsupportedFeature","UnsupportedTransport","UnsupportedStrategy","HTTPAuthError","status","urlStore","baseUrl","authenticationEndpoint","authorizationEndpoint","javascriptQuickStart","triggeringClientEvents","encryptedChannelSupport","fullUrl","urlObj","pusher","subscribed","subscriptionPending","subscriptionCancelled","socketId","auth","suffix","handleSubscriptionSucceededEvent","handleSubscriptionCountEvent","unsubscribe","subscription_count","subscriptionCount","authorize","assign","channel_data","config","channelAuthorizer","channelName","reset","members","member","myID","subscriptionData","presence","hash","count","me","memberData","user_info","authData","channelData","setMyID","user","signinDonePromise","user_data","handleInternalEvent","addedMember","addMember","removedMember","removeMember","onSubscription","disconnect","nacl","sharedSecret","handleEncryptedEvent","handleEvent","ciphertext","nonce","cipherText","secretbox","overheadLength","nonceLength","bytes","open","getDataToEmit","raw","usingTLS","errorCallbacks","buildErrorCallbacks","connectionCallbacks","buildConnectionCallbacks","handshakeCallbacks","buildHandshakeCallbacks","Network","getNetwork","netinfo","retryIn","sendActivityCheck","updateStrategy","runner","strategy","updateState","startConnecting","setUnavailableTimer","disconnectInternally","handshake","connect","handshakeError","abortConnecting","abort","clearRetryTimer","clearUnavailableTimer","abandonConnection","getStrategy","round","retryTimer","ensureAborted","unavailableTimer","stopActivityCheck","activityTimer","pong_timed_out","resetActivityCheck","shouldRetry","connected","Infinity","setConnection","withErrorEmitted","tls_only","refused","backoff","retry","newState","previousState","newStateDescription","previous","current","channels","createEncryptedChannel","errMsg","createPrivateChannel","createPresenceChannel","createChannel","values","createChannels","createConnectionManager","createTimelineSender","createHandshake","createAssistantToTheTransportManager","livesLeft","lives","strategies","loop","failFast","timeout","timeoutLimit","minPriority","tryNextStrategy","tryStrategy","forceMinPriority","isRunning","callbackBuilder","runners","rs","abortRunner","allRunnersFailed","aborted","transports","ttl","storage","getLocalStorage","serializedCache","getTransportCacheKey","flushTransportCache","fetchTransportCache","cacheSkipCount","timestamp","includes","cached","latency","startTimestamp","pop","cb","storeTransportCache","number","IfStrategy","trueBranch","falseBranch","FirstConnectedStrategy","testSupportsStrategy","baseOptions","defineTransport","definedTransports","defineTransportStrategy","wsStrategy","ws_options","wsHost","wss_options","http_options","timeouts","ws_manager","streaming_manager","ws_transport","wss_transport","xhr_streaming_transport","xhr_polling_transport","ws_loop","wss_loop","streaming_loop","polling_loop","http_loop","payload","position","xhr","getRequest","unloader","addUnloadListener","setRequestHeader","removeUnloadListener","abortRequest","chunk","advanceBuffer","isBufferTooLong","buffer","unreadData","endOfLinePosition","State","autoIncrement","getUniqueURL","separator","randomNumber","randomInt","session","randomString","location","parts","exec","base","getLocation","readyState","CONNECTING","openStream","sendRaw","sendHeartbeat","OPEN","createSocketRequest","start","closeStream","CLOSED","onEvent","onHeartbeat","hostname","urlParts","stream","getReceiveURL","onChunk","onFinished","reconnect","unbind_all","getXHRAPI","onreadystatechange","onprogress","responseText","getDefaultStrategy","Transports","createSocket","createRequest","PusherClass","ready","getClientFeatures","getProtocol","createXHR","query","authOptions","authRequestType","headers","Headers","headerName","headersProvider","dynamicHeaders","body","request","Request","credentials","fetch","then","response","text","parsedData","catch","err","sender","host","json","setup","TimelineLevel","getAuthorizers","ajax","WebSocket","XMLHttpRequest","floor","globalThis","crypto","getRandomValues","Uint32Array","events","sent","uniqueID","level","limit","shift","ERROR","INFO","DEBUG","sendfn","bundle","lib","version","cluster","features","failAttempt","onInitialized","serializedTransport","AuthRequestType","transportClass","enabledTransports","disabledTransports","ignoreNullOrigin","getAssistant","deferred","paramsProvider","dynamicParams","composeChannelQuery","UserAuthentication","ChannelAuthorization","getHttpHost","opts","getWebsocketHost","shouldUseTLS","forceTLS","getEnableStatsConfig","enableStats","disableStats","buildUserAuthenticator","buildChannelAuthorizer","customHandler","channelAuthorizerGenerator","deprecatedAuthorizerOptions","ChannelAuthorizerProxy","authorizer","buildChannelAuth","bindWatchlistInternalEvent","forEach","watchlistEvent","resolve","reject","promise","Promise","res","rej","signin_requested","serverToUserChannel","_signinDoneResolve","_onAuthorize","_cleanup","_signin","_newSigninPromiseIfNeeded","watchlist","_onSigninSuccess","userAuthenticator","_subscribeChannels","bind_global","reinstateSubscription","subscribe","ensure_subscribed","done","setDone","isReady","instances","app_key","checkAppKey","validateOptions","statsHost","timelineParams","getConfig","global_emitter","sessionID","timelineSender","subscribeAll","isUsingTLS","internal","find","all","timelineSenderTimer","event_name","channel_name","cancelSubscription","signin","Runtime","ScriptReceivers","DependenciesReceivers","auth_callbacks"],"mappings":";;;;;;;CAAA,SAA2CA,EAAMC,GAC1B,iBAAZC,SAA0C,iBAAXC,OACxCA,OAAOD,QAAUD,IACQ,mBAAXG,QAAyBA,OAAOC,IAC9CD,OAAO,GAAIH,GACe,iBAAZC,QACdA,QAAgB,OAAID,IAEpBD,EAAa,OAAIC,IARnB,CASGK,MAAM,WACT,O,YCTE,IAAIC,EAAmB,GAGvB,SAASC,EAAoBC,GAG5B,GAAGF,EAAiBE,GACnB,OAAOF,EAAiBE,GAAUP,QAGnC,IAAIC,EAASI,EAAiBE,GAAY,CACzCC,EAAGD,EACHE,GAAG,EACHT,QAAS,IAUV,OANAU,EAAQH,GAAUI,KAAKV,EAAOD,QAASC,EAAQA,EAAOD,QAASM,GAG/DL,EAAOQ,GAAI,EAGJR,EAAOD,QA0Df,OArDAM,EAAoBM,EAAIF,EAGxBJ,EAAoBO,EAAIR,EAGxBC,EAAoBQ,EAAI,SAASd,EAASe,EAAMC,GAC3CV,EAAoBW,EAAEjB,EAASe,IAClCG,OAAOC,eAAenB,EAASe,EAAM,CAAEK,YAAY,EAAMC,IAAKL,KAKhEV,EA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iB,cAA1B3U,KAAKiR,WAAW1D,OAEhB2E,EAAQ6X,YAEH7X,EAGT,YAAYmZ,GACV,IAAInZ,EAAUlS,KAAKmb,SAAS8P,KAAKI,GAC7BnZ,GAAWA,EAAQyC,oBACrBzC,EAAQoZ,sBAERpZ,EAAUlS,KAAKmb,SAAS/O,OAAOif,KAChBnZ,EAAQwC,YACrBxC,EAAQgD,cAKd,WAAWkW,EAAoB5oB,EAAW0P,GACxC,OAAOlS,KAAKiR,WAAW0B,WAAWyY,EAAY5oB,EAAM0P,GAGtD,eACE,OAAOlS,KAAKwV,OAAOzK,OAGrB,SACE/K,KAAKyW,KAAK8U,UAxNL,GAAAnB,UAAsB,GACtB,GAAAD,SAAmB,EACnB,GAAAld,cAAwB,EAGxB,GAAAue,QAA2B,GAC3B,GAAAC,gBAA6B,GAASA,gBACtC,GAAAC,sBAAmC,GAASA,sBAC5C,GAAAC,eAA4B,GAASA,eAVzB,oBAoOrB,GAAQ3G,MAAM","file":"pusher.worker.min.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"Pusher\"] = factory();\n\telse\n\t\troot[\"Pusher\"] = factory();\n})(this, function() {\nreturn "," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 2);\n","// Copyright (C) 2016 Dmitry Chestnykh\n// MIT License. See LICENSE file for details.\n\n/**\n * Package base64 implements Base64 encoding and decoding.\n */\n\n// Invalid character used in decoding to indicate\n// that the character to decode is out of range of\n// alphabet and cannot be decoded.\nconst INVALID_BYTE = 256;\n\n/**\n * Implements standard Base64 encoding.\n *\n * Operates in constant time.\n */\nexport class Coder {\n // TODO(dchest): methods to encode chunk-by-chunk.\n\n constructor(private _paddingCharacter = \"=\") { }\n\n encodedLength(length: number): number {\n if (!this._paddingCharacter) {\n return (length * 8 + 5) / 6 | 0;\n }\n return (length + 2) / 3 * 4 | 0;\n }\n\n encode(data: Uint8Array): string {\n let out = \"\";\n\n let i = 0;\n for (; i < data.length - 2; i += 3) {\n let c = (data[i] << 16) | (data[i + 1] << 8) | (data[i + 2]);\n out += this._encodeByte((c >>> 3 * 6) & 63);\n out += this._encodeByte((c >>> 2 * 6) & 63);\n out += this._encodeByte((c >>> 1 * 6) & 63);\n out += this._encodeByte((c >>> 0 * 6) & 63);\n }\n\n const left = data.length - i;\n if (left > 0) {\n let c = (data[i] << 16) | (left === 2 ? data[i + 1] << 8 : 0);\n out += this._encodeByte((c >>> 3 * 6) & 63);\n out += this._encodeByte((c >>> 2 * 6) & 63);\n if (left === 2) {\n out += this._encodeByte((c >>> 1 * 6) & 63);\n } else {\n out += this._paddingCharacter || \"\";\n }\n out += this._paddingCharacter || \"\";\n }\n\n return out;\n }\n\n maxDecodedLength(length: number): number {\n if (!this._paddingCharacter) {\n return (length * 6 + 7) / 8 | 0;\n }\n return length / 4 * 3 | 0;\n }\n\n decodedLength(s: string): number {\n return this.maxDecodedLength(s.length - this._getPaddingLength(s));\n }\n\n decode(s: string): Uint8Array {\n if (s.length === 0) {\n return new Uint8Array(0);\n }\n const paddingLength = this._getPaddingLength(s);\n const length = s.length - paddingLength;\n const out = new Uint8Array(this.maxDecodedLength(length));\n let op = 0;\n let i = 0;\n let haveBad = 0;\n let v0 = 0, v1 = 0, v2 = 0, v3 = 0;\n for (; i < length - 4; i += 4) {\n v0 = this._decodeChar(s.charCodeAt(i + 0));\n v1 = this._decodeChar(s.charCodeAt(i + 1));\n v2 = this._decodeChar(s.charCodeAt(i + 2));\n v3 = this._decodeChar(s.charCodeAt(i + 3));\n out[op++] = (v0 << 2) | (v1 >>> 4);\n out[op++] = (v1 << 4) | (v2 >>> 2);\n out[op++] = (v2 << 6) | v3;\n haveBad |= v0 & INVALID_BYTE;\n haveBad |= v1 & INVALID_BYTE;\n haveBad |= v2 & INVALID_BYTE;\n haveBad |= v3 & INVALID_BYTE;\n }\n if (i < length - 1) {\n v0 = this._decodeChar(s.charCodeAt(i));\n v1 = this._decodeChar(s.charCodeAt(i + 1));\n out[op++] = (v0 << 2) | (v1 >>> 4);\n haveBad |= v0 & INVALID_BYTE;\n haveBad |= v1 & INVALID_BYTE;\n }\n if (i < length - 2) {\n v2 = this._decodeChar(s.charCodeAt(i + 2));\n out[op++] = (v1 << 4) | (v2 >>> 2);\n haveBad |= v2 & INVALID_BYTE;\n }\n if (i < length - 3) {\n v3 = this._decodeChar(s.charCodeAt(i + 3));\n out[op++] = (v2 << 6) | v3;\n haveBad |= v3 & INVALID_BYTE;\n }\n if (haveBad !== 0) {\n throw new Error(\"Base64Coder: incorrect characters for decoding\");\n }\n return out;\n }\n\n // Standard encoding have the following encoded/decoded ranges,\n // which we need to convert between.\n //\n // ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 0123456789 + /\n // Index: 0 - 25 26 - 51 52 - 61 62 63\n // ASCII: 65 - 90 97 - 122 48 - 57 43 47\n //\n\n // Encode 6 bits in b into a new character.\n protected _encodeByte(b: number): string {\n // Encoding uses constant time operations as follows:\n //\n // 1. Define comparison of A with B using (A - B) >>> 8:\n // if A > B, then result is positive integer\n // if A <= B, then result is 0\n //\n // 2. Define selection of C or 0 using bitwise AND: X & C:\n // if X == 0, then result is 0\n // if X != 0, then result is C\n //\n // 3. Start with the smallest comparison (b >= 0), which is always\n // true, so set the result to the starting ASCII value (65).\n //\n // 4. Continue comparing b to higher ASCII values, and selecting\n // zero if comparison isn't true, otherwise selecting a value\n // to add to result, which:\n //\n // a) undoes the previous addition\n // b) provides new value to add\n //\n let result = b;\n // b >= 0\n result += 65;\n // b > 25\n result += ((25 - b) >>> 8) & ((0 - 65) - 26 + 97);\n // b > 51\n result += ((51 - b) >>> 8) & ((26 - 97) - 52 + 48);\n // b > 61\n result += ((61 - b) >>> 8) & ((52 - 48) - 62 + 43);\n // b > 62\n result += ((62 - b) >>> 8) & ((62 - 43) - 63 + 47);\n\n return String.fromCharCode(result);\n }\n\n // Decode a character code into a byte.\n // Must return 256 if character is out of alphabet range.\n protected _decodeChar(c: number): number {\n // Decoding works similar to encoding: using the same comparison\n // function, but now it works on ranges: result is always incremented\n // by value, but this value becomes zero if the range is not\n // satisfied.\n //\n // Decoding starts with invalid value, 256, which is then\n // subtracted when the range is satisfied. If none of the ranges\n // apply, the function returns 256, which is then checked by\n // the caller to throw error.\n let result = INVALID_BYTE; // start with invalid character\n\n // c == 43 (c > 42 and c < 44)\n result += (((42 - c) & (c - 44)) >>> 8) & (-INVALID_BYTE + c - 43 + 62);\n // c == 47 (c > 46 and c < 48)\n result += (((46 - c) & (c - 48)) >>> 8) & (-INVALID_BYTE + c - 47 + 63);\n // c > 47 and c < 58\n result += (((47 - c) & (c - 58)) >>> 8) & (-INVALID_BYTE + c - 48 + 52);\n // c > 64 and c < 91\n result += (((64 - c) & (c - 91)) >>> 8) & (-INVALID_BYTE + c - 65 + 0);\n // c > 96 and c < 123\n result += (((96 - c) & (c - 123)) >>> 8) & (-INVALID_BYTE + c - 97 + 26);\n\n return result;\n }\n\n private _getPaddingLength(s: string): number {\n let paddingLength = 0;\n if (this._paddingCharacter) {\n for (let i = s.length - 1; i >= 0; i--) {\n if (s[i] !== this._paddingCharacter) {\n break;\n }\n paddingLength++;\n }\n if (s.length < 4 || paddingLength > 2) {\n throw new Error(\"Base64Coder: incorrect padding\");\n }\n }\n return paddingLength;\n }\n\n}\n\nconst stdCoder = new Coder();\n\nexport function encode(data: Uint8Array): string {\n return stdCoder.encode(data);\n}\n\nexport function decode(s: string): Uint8Array {\n return stdCoder.decode(s);\n}\n\n/**\n * Implements URL-safe Base64 encoding.\n * (Same as Base64, but '+' is replaced with '-', and '/' with '_').\n *\n * Operates in constant time.\n */\nexport class URLSafeCoder extends Coder {\n // URL-safe encoding have the following encoded/decoded ranges:\n //\n // ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 0123456789 - _\n // Index: 0 - 25 26 - 51 52 - 61 62 63\n // ASCII: 65 - 90 97 - 122 48 - 57 45 95\n //\n\n protected _encodeByte(b: number): string {\n let result = b;\n // b >= 0\n result += 65;\n // b > 25\n result += ((25 - b) >>> 8) & ((0 - 65) - 26 + 97);\n // b > 51\n result += ((51 - b) >>> 8) & ((26 - 97) - 52 + 48);\n // b > 61\n result += ((61 - b) >>> 8) & ((52 - 48) - 62 + 45);\n // b > 62\n result += ((62 - b) >>> 8) & ((62 - 45) - 63 + 95);\n\n return String.fromCharCode(result);\n }\n\n protected _decodeChar(c: number): number {\n let result = INVALID_BYTE;\n\n // c == 45 (c > 44 and c < 46)\n result += (((44 - c) & (c - 46)) >>> 8) & (-INVALID_BYTE + c - 45 + 62);\n // c == 95 (c > 94 and c < 96)\n result += (((94 - c) & (c - 96)) >>> 8) & (-INVALID_BYTE + c - 95 + 63);\n // c > 47 and c < 58\n result += (((47 - c) & (c - 58)) >>> 8) & (-INVALID_BYTE + c - 48 + 52);\n // c > 64 and c < 91\n result += (((64 - c) & (c - 91)) >>> 8) & (-INVALID_BYTE + c - 65 + 0);\n // c > 96 and c < 123\n result += (((96 - c) & (c - 123)) >>> 8) & (-INVALID_BYTE + c - 97 + 26);\n\n return result;\n }\n}\n\nconst urlSafeCoder = new URLSafeCoder();\n\nexport function encodeURLSafe(data: Uint8Array): string {\n return urlSafeCoder.encode(data);\n}\n\nexport function decodeURLSafe(s: string): Uint8Array {\n return urlSafeCoder.decode(s);\n}\n\n\nexport const encodedLength = (length: number) =>\n stdCoder.encodedLength(length);\n\nexport const maxDecodedLength = (length: number) =>\n stdCoder.maxDecodedLength(length);\n\nexport const decodedLength = (s: string) =>\n stdCoder.decodedLength(s);\n","// Copyright (C) 2016 Dmitry Chestnykh\n// MIT License. See LICENSE file for details.\n\n/**\n * Package utf8 implements UTF-8 encoding and decoding.\n */\n\nconst INVALID_UTF16 = \"utf8: invalid string\";\nconst INVALID_UTF8 = \"utf8: invalid source encoding\";\n\n/**\n * Encodes the given string into UTF-8 byte array.\n * Throws if the source string has invalid UTF-16 encoding.\n */\nexport function encode(s: string): Uint8Array {\n // Calculate result length and allocate output array.\n // encodedLength() also validates string and throws errors,\n // so we don't need repeat validation here.\n const arr = new Uint8Array(encodedLength(s));\n\n let pos = 0;\n for (let i = 0; i < s.length; i++) {\n let c = s.charCodeAt(i);\n if (c < 0x80) {\n arr[pos++] = c;\n } else if (c < 0x800) {\n arr[pos++] = 0xc0 | c >> 6;\n arr[pos++] = 0x80 | c & 0x3f;\n } else if (c < 0xd800) {\n arr[pos++] = 0xe0 | c >> 12;\n arr[pos++] = 0x80 | (c >> 6) & 0x3f;\n arr[pos++] = 0x80 | c & 0x3f;\n } else {\n i++; // get one more character\n c = (c & 0x3ff) << 10;\n c |= s.charCodeAt(i) & 0x3ff;\n c += 0x10000;\n\n arr[pos++] = 0xf0 | c >> 18;\n arr[pos++] = 0x80 | (c >> 12) & 0x3f;\n arr[pos++] = 0x80 | (c >> 6) & 0x3f;\n arr[pos++] = 0x80 | c & 0x3f;\n }\n }\n return arr;\n}\n\n/**\n * Returns the number of bytes required to encode the given string into UTF-8.\n * Throws if the source string has invalid UTF-16 encoding.\n */\nexport function encodedLength(s: string): number {\n let result = 0;\n for (let i = 0; i < s.length; i++) {\n const c = s.charCodeAt(i);\n if (c < 0x80) {\n result += 1;\n } else if (c < 0x800) {\n result += 2;\n } else if (c < 0xd800) {\n result += 3;\n } else if (c <= 0xdfff) {\n if (i >= s.length - 1) {\n throw new Error(INVALID_UTF16);\n }\n i++; // \"eat\" next character\n result += 4;\n } else {\n throw new Error(INVALID_UTF16);\n }\n }\n return result;\n}\n\n/**\n * Decodes the given byte array from UTF-8 into a string.\n * Throws if encoding is invalid.\n */\nexport function decode(arr: Uint8Array): string {\n const chars: string[] = [];\n for (let i = 0; i < arr.length; i++) {\n let b = arr[i];\n\n if (b & 0x80) {\n let min;\n if (b < 0xe0) {\n // Need 1 more byte.\n if (i >= arr.length) {\n throw new Error(INVALID_UTF8);\n }\n const n1 = arr[++i];\n if ((n1 & 0xc0) !== 0x80) {\n throw new Error(INVALID_UTF8);\n }\n b = (b & 0x1f) << 6 | (n1 & 0x3f);\n min = 0x80;\n } else if (b < 0xf0) {\n // Need 2 more bytes.\n if (i >= arr.length - 1) {\n throw new Error(INVALID_UTF8);\n }\n const n1 = arr[++i];\n const n2 = arr[++i];\n if ((n1 & 0xc0) !== 0x80 || (n2 & 0xc0) !== 0x80) {\n throw new Error(INVALID_UTF8);\n }\n b = (b & 0x0f) << 12 | (n1 & 0x3f) << 6 | (n2 & 0x3f);\n min = 0x800;\n } else if (b < 0xf8) {\n // Need 3 more bytes.\n if (i >= arr.length - 2) {\n throw new Error(INVALID_UTF8);\n }\n const n1 = arr[++i];\n const n2 = arr[++i];\n const n3 = arr[++i];\n if ((n1 & 0xc0) !== 0x80 || (n2 & 0xc0) !== 0x80 || (n3 & 0xc0) !== 0x80) {\n throw new Error(INVALID_UTF8);\n }\n b = (b & 0x0f) << 18 | (n1 & 0x3f) << 12 | (n2 & 0x3f) << 6 | (n3 & 0x3f);\n min = 0x10000;\n } else {\n throw new Error(INVALID_UTF8);\n }\n\n if (b < min || (b >= 0xd800 && b <= 0xdfff)) {\n throw new Error(INVALID_UTF8);\n }\n\n if (b >= 0x10000) {\n // Surrogate pair.\n if (b > 0x10ffff) {\n throw new Error(INVALID_UTF8);\n }\n b -= 0x10000;\n chars.push(String.fromCharCode(0xd800 | (b >> 10)));\n b = 0xdc00 | (b & 0x3ff);\n }\n }\n\n chars.push(String.fromCharCode(b));\n }\n return chars.join(\"\");\n}\n","// required so we don't have to do require('pusher').default etc.\nmodule.exports = require('./pusher').default;\n","export default function encode(s: any): string {\n return btoa(utob(s));\n}\n\nvar fromCharCode = String.fromCharCode;\n\nvar b64chars =\n 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';\nvar b64tab = {};\n\nfor (var i = 0, l = b64chars.length; i < l; i++) {\n b64tab[b64chars.charAt(i)] = i;\n}\n\nvar cb_utob = function(c) {\n var cc = c.charCodeAt(0);\n return cc < 0x80\n ? c\n : cc < 0x800\n ? fromCharCode(0xc0 | (cc >>> 6)) + fromCharCode(0x80 | (cc & 0x3f))\n : fromCharCode(0xe0 | ((cc >>> 12) & 0x0f)) +\n fromCharCode(0x80 | ((cc >>> 6) & 0x3f)) +\n fromCharCode(0x80 | (cc & 0x3f));\n};\n\nvar utob = function(u) {\n return u.replace(/[^\\x00-\\x7F]/g, cb_utob);\n};\n\nvar cb_encode = function(ccc) {\n var padlen = [0, 2, 1][ccc.length % 3];\n var ord =\n (ccc.charCodeAt(0) << 16) |\n ((ccc.length > 1 ? ccc.charCodeAt(1) : 0) << 8) |\n (ccc.length > 2 ? ccc.charCodeAt(2) : 0);\n var chars = [\n b64chars.charAt(ord >>> 18),\n b64chars.charAt((ord >>> 12) & 63),\n padlen >= 2 ? '=' : b64chars.charAt((ord >>> 6) & 63),\n padlen >= 1 ? '=' : b64chars.charAt(ord & 63)\n ];\n return chars.join('');\n};\n\nvar btoa =\n global.btoa ||\n function(b) {\n return b.replace(/[\\s\\S]{1,3}/g, cb_encode);\n };\n","import TimedCallback from './timed_callback';\nimport { Delay, Scheduler, Canceller } from './scheduling';\n\nabstract class Timer {\n protected clear: Canceller;\n protected timer: number | void;\n\n constructor(\n set: Scheduler,\n clear: Canceller,\n delay: Delay,\n callback: TimedCallback\n ) {\n this.clear = clear;\n this.timer = set(() => {\n if (this.timer) {\n this.timer = callback(this.timer);\n }\n }, delay);\n }\n\n /** Returns whether the timer is still running.\n *\n * @return {Boolean}\n */\n isRunning(): boolean {\n return this.timer !== null;\n }\n\n /** Aborts a timer when it's running. */\n ensureAborted() {\n if (this.timer) {\n this.clear(this.timer);\n this.timer = null;\n }\n }\n}\n\nexport default Timer;\n","import Timer from './abstract_timer';\nimport TimedCallback from './timed_callback';\nimport { Delay } from './scheduling';\n\n// We need to bind clear functions this way to avoid exceptions on IE8\nfunction clearTimeout(timer) {\n global.clearTimeout(timer);\n}\nfunction clearInterval(timer) {\n global.clearInterval(timer);\n}\n\n/** Cross-browser compatible one-off timer abstraction.\n *\n * @param {Number} delay\n * @param {Function} callback\n */\nexport class OneOffTimer extends Timer {\n constructor(delay: Delay, callback: TimedCallback) {\n super(setTimeout, clearTimeout, delay, function(timer) {\n callback();\n return null;\n });\n }\n}\n\n/** Cross-browser compatible periodic timer abstraction.\n *\n * @param {Number} delay\n * @param {Function} callback\n */\nexport class PeriodicTimer extends Timer {\n constructor(delay: Delay, callback: TimedCallback) {\n super(setInterval, clearInterval, delay, function(timer) {\n callback();\n return timer;\n });\n }\n}\n","import * as Collections from './utils/collections';\nimport TimedCallback from './utils/timers/timed_callback';\nimport { OneOffTimer, PeriodicTimer } from './utils/timers';\n\nvar Util = {\n now(): number {\n if (Date.now) {\n return Date.now();\n } else {\n return new Date().valueOf();\n }\n },\n\n defer(callback: TimedCallback): OneOffTimer {\n return new OneOffTimer(0, callback);\n },\n\n /** Builds a function that will proxy a method call to its first argument.\n *\n * Allows partial application of arguments, so additional arguments are\n * prepended to the argument list.\n *\n * @param {String} name method name\n * @return {Function} proxy function\n */\n method(name: string, ...args: any[]): Function {\n var boundArguments = Array.prototype.slice.call(arguments, 1);\n return function(object) {\n return object[name].apply(object, boundArguments.concat(arguments));\n };\n }\n};\n\nexport default Util;\n","import base64encode from '../base64';\nimport Util from '../util';\n\n/** Merges multiple objects into the target argument.\n *\n * For properties that are plain Objects, performs a deep-merge. For the\n * rest it just copies the value of the property.\n *\n * To extend prototypes use it as following:\n * Pusher.Util.extend(Target.prototype, Base.prototype)\n *\n * You can also use it to merge objects without altering them:\n * Pusher.Util.extend({}, object1, object2)\n *\n * @param {Object} target\n * @return {Object} the target argument\n */\nexport function extend(target: any, ...sources: any[]): T {\n for (var i = 0; i < sources.length; i++) {\n var extensions = sources[i];\n for (var property in extensions) {\n if (\n extensions[property] &&\n extensions[property].constructor &&\n extensions[property].constructor === Object\n ) {\n target[property] = extend(target[property] || {}, extensions[property]);\n } else {\n target[property] = extensions[property];\n }\n }\n }\n return target;\n}\n\nexport function stringify(): string {\n var m = ['Pusher'];\n for (var i = 0; i < arguments.length; i++) {\n if (typeof arguments[i] === 'string') {\n m.push(arguments[i]);\n } else {\n m.push(safeJSONStringify(arguments[i]));\n }\n }\n return m.join(' : ');\n}\n\nexport function arrayIndexOf(array: any[], item: any): number {\n // MSIE doesn't have array.indexOf\n var nativeIndexOf = Array.prototype.indexOf;\n if (array === null) {\n return -1;\n }\n if (nativeIndexOf && array.indexOf === nativeIndexOf) {\n return array.indexOf(item);\n }\n for (var i = 0, l = array.length; i < l; i++) {\n if (array[i] === item) {\n return i;\n }\n }\n return -1;\n}\n\n/** Applies a function f to all properties of an object.\n *\n * Function f gets 3 arguments passed:\n * - element from the object\n * - key of the element\n * - reference to the object\n *\n * @param {Object} object\n * @param {Function} f\n */\nexport function objectApply(object: any, f: Function) {\n for (var key in object) {\n if (Object.prototype.hasOwnProperty.call(object, key)) {\n f(object[key], key, object);\n }\n }\n}\n\n/** Return a list of objects own proerty keys\n *\n * @param {Object} object\n * @returns {Array}\n */\nexport function keys(object: any): string[] {\n var keys = [];\n objectApply(object, function(_, key) {\n keys.push(key);\n });\n return keys;\n}\n\n/** Return a list of object's own property values\n *\n * @param {Object} object\n * @returns {Array}\n */\nexport function values(object: any): any[] {\n var values = [];\n objectApply(object, function(value) {\n values.push(value);\n });\n return values;\n}\n\n/** Applies a function f to all elements of an array.\n *\n * Function f gets 3 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function apply(array: any[], f: Function, context?: any) {\n for (var i = 0; i < array.length; i++) {\n f.call(context || global, array[i], i, array);\n }\n}\n\n/** Maps all elements of the array and returns the result.\n *\n * Function f gets 4 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n * - reference to the destination array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function map(array: any[], f: Function): any[] {\n var result = [];\n for (var i = 0; i < array.length; i++) {\n result.push(f(array[i], i, array, result));\n }\n return result;\n}\n\n/** Maps all elements of the object and returns the result.\n *\n * Function f gets 4 arguments passed:\n * - element from the object\n * - key of the element\n * - reference to the source object\n * - reference to the destination object\n *\n * @param {Object} object\n * @param {Function} f\n */\nexport function mapObject(object: any, f: Function): any {\n var result = {};\n objectApply(object, function(value, key) {\n result[key] = f(value);\n });\n return result;\n}\n\n/** Filters elements of the array using a test function.\n *\n * Function test gets 4 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n * - reference to the destination array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function filter(array: any[], test: Function): any[] {\n test =\n test ||\n function(value) {\n return !!value;\n };\n\n var result = [];\n for (var i = 0; i < array.length; i++) {\n if (test(array[i], i, array, result)) {\n result.push(array[i]);\n }\n }\n return result;\n}\n\n/** Filters properties of the object using a test function.\n *\n * Function test gets 4 arguments passed:\n * - element from the object\n * - key of the element\n * - reference to the source object\n * - reference to the destination object\n *\n * @param {Object} object\n * @param {Function} f\n */\nexport function filterObject(object: Object, test: Function) {\n var result = {};\n objectApply(object, function(value, key) {\n if ((test && test(value, key, object, result)) || Boolean(value)) {\n result[key] = value;\n }\n });\n return result;\n}\n\n/** Flattens an object into a two-dimensional array.\n *\n * @param {Object} object\n * @return {Array} resulting array of [key, value] pairs\n */\nexport function flatten(object: Object): any[] {\n var result = [];\n objectApply(object, function(value, key) {\n result.push([key, value]);\n });\n return result;\n}\n\n/** Checks whether any element of the array passes the test.\n *\n * Function test gets 3 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function any(array: any[], test: Function): boolean {\n for (var i = 0; i < array.length; i++) {\n if (test(array[i], i, array)) {\n return true;\n }\n }\n return false;\n}\n\n/** Checks whether all elements of the array pass the test.\n *\n * Function test gets 3 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function all(array: any[], test: Function): boolean {\n for (var i = 0; i < array.length; i++) {\n if (!test(array[i], i, array)) {\n return false;\n }\n }\n return true;\n}\n\nexport function encodeParamsObject(data): string {\n return mapObject(data, function(value) {\n if (typeof value === 'object') {\n value = safeJSONStringify(value);\n }\n return encodeURIComponent(base64encode(value.toString()));\n });\n}\n\nexport function buildQueryString(data: any): string {\n var params = filterObject(data, function(value) {\n return value !== undefined;\n });\n\n var query = map(\n flatten(encodeParamsObject(params)),\n Util.method('join', '=')\n ).join('&');\n\n return query;\n}\n\n/**\n * See https://github.com/douglascrockford/JSON-js/blob/master/cycle.js\n *\n * Remove circular references from an object. Required for JSON.stringify in\n * React Native, which tends to blow up a lot.\n *\n * @param {any} object\n * @return {any} Decycled object\n */\nexport function decycleObject(object: any): any {\n var objects = [],\n paths = [];\n\n return (function derez(value, path) {\n var i, name, nu;\n\n switch (typeof value) {\n case 'object':\n if (!value) {\n return null;\n }\n for (i = 0; i < objects.length; i += 1) {\n if (objects[i] === value) {\n return { $ref: paths[i] };\n }\n }\n\n objects.push(value);\n paths.push(path);\n\n if (Object.prototype.toString.apply(value) === '[object Array]') {\n nu = [];\n for (i = 0; i < value.length; i += 1) {\n nu[i] = derez(value[i], path + '[' + i + ']');\n }\n } else {\n nu = {};\n for (name in value) {\n if (Object.prototype.hasOwnProperty.call(value, name)) {\n nu[name] = derez(\n value[name],\n path + '[' + JSON.stringify(name) + ']'\n );\n }\n }\n }\n return nu;\n case 'number':\n case 'string':\n case 'boolean':\n return value;\n }\n })(object, '$');\n}\n\n/**\n * Provides a cross-browser and cross-platform way to safely stringify objects\n * into JSON. This is particularly necessary for ReactNative, where circular JSON\n * structures throw an exception.\n *\n * @param {any} source The object to stringify\n * @return {string} The serialized output.\n */\nexport function safeJSONStringify(source: any): string {\n try {\n return JSON.stringify(source);\n } catch (e) {\n return JSON.stringify(decycleObject(source));\n }\n}\n","import {\n ChannelAuthorizationOptions,\n UserAuthenticationOptions\n} from './auth/options';\nimport { AuthTransport } from './config';\n\nexport interface DefaultConfig {\n VERSION: string;\n PROTOCOL: number;\n wsPort: number;\n wssPort: number;\n wsPath: string;\n httpHost: string;\n httpPort: number;\n httpsPort: number;\n httpPath: string;\n stats_host: string;\n authEndpoint: string;\n authTransport: AuthTransport;\n activityTimeout: number;\n pongTimeout: number;\n unavailableTimeout: number;\n userAuthentication: UserAuthenticationOptions;\n channelAuthorization: ChannelAuthorizationOptions;\n\n cdn_http?: string;\n cdn_https?: string;\n dependency_suffix?: string;\n}\n\nvar Defaults: DefaultConfig = {\n VERSION: VERSION,\n PROTOCOL: 7,\n\n wsPort: 80,\n wssPort: 443,\n wsPath: '',\n // DEPRECATED: SockJS fallback parameters\n httpHost: 'sockjs.pusher.com',\n httpPort: 80,\n httpsPort: 443,\n httpPath: '/pusher',\n // DEPRECATED: Stats\n stats_host: 'stats.pusher.com',\n // DEPRECATED: Other settings\n authEndpoint: '/pusher/auth',\n authTransport: 'ajax',\n activityTimeout: 120000,\n pongTimeout: 30000,\n unavailableTimeout: 10000,\n userAuthentication: {\n endpoint: '/pusher/user-auth',\n transport: 'ajax'\n },\n channelAuthorization: {\n endpoint: '/pusher/auth',\n transport: 'ajax'\n },\n\n // CDN configuration\n cdn_http: CDN_HTTP,\n cdn_https: CDN_HTTPS,\n dependency_suffix: DEPENDENCY_SUFFIX\n};\n\nexport default Defaults;\n","import Defaults from '../defaults';\nimport { default as URLScheme, URLSchemeParams } from './url_scheme';\n\nfunction getGenericURL(\n baseScheme: string,\n params: URLSchemeParams,\n path: string\n): string {\n var scheme = baseScheme + (params.useTLS ? 's' : '');\n var host = params.useTLS ? params.hostTLS : params.hostNonTLS;\n return scheme + '://' + host + path;\n}\n\nfunction getGenericPath(key: string, queryString?: string): string {\n var path = '/app/' + key;\n var query =\n '?protocol=' +\n Defaults.PROTOCOL +\n '&client=js' +\n '&version=' +\n Defaults.VERSION +\n (queryString ? '&' + queryString : '');\n return path + query;\n}\n\nexport var ws: URLScheme = {\n getInitial: function(key: string, params: URLSchemeParams): string {\n var path = (params.httpPath || '') + getGenericPath(key, 'flash=false');\n return getGenericURL('ws', params, path);\n }\n};\n\nexport var http: URLScheme = {\n getInitial: function(key: string, params: URLSchemeParams): string {\n var path = (params.httpPath || '/pusher') + getGenericPath(key);\n return getGenericURL('http', params, path);\n }\n};\n\nexport var sockjs: URLScheme = {\n getInitial: function(key: string, params: URLSchemeParams): string {\n return getGenericURL('http', params, params.httpPath || '/pusher');\n },\n getPath: function(key: string, params: URLSchemeParams): string {\n return getGenericPath(key);\n }\n};\n","import Callback from './callback';\nimport * as Collections from '../utils/collections';\nimport CallbackTable from './callback_table';\n\nexport default class CallbackRegistry {\n _callbacks: CallbackTable;\n\n constructor() {\n this._callbacks = {};\n }\n\n get(name: string): Callback[] {\n return this._callbacks[prefix(name)];\n }\n\n add(name: string, callback: Function, context: any) {\n var prefixedEventName = prefix(name);\n this._callbacks[prefixedEventName] =\n this._callbacks[prefixedEventName] || [];\n this._callbacks[prefixedEventName].push({\n fn: callback,\n context: context\n });\n }\n\n remove(name?: string, callback?: Function, context?: any) {\n if (!name && !callback && !context) {\n this._callbacks = {};\n return;\n }\n\n var names = name ? [prefix(name)] : Collections.keys(this._callbacks);\n\n if (callback || context) {\n this.removeCallback(names, callback, context);\n } else {\n this.removeAllCallbacks(names);\n }\n }\n\n private removeCallback(names: string[], callback: Function, context: any) {\n Collections.apply(\n names,\n function(name) {\n this._callbacks[name] = Collections.filter(\n this._callbacks[name] || [],\n function(binding) {\n return (\n (callback && callback !== binding.fn) ||\n (context && context !== binding.context)\n );\n }\n );\n if (this._callbacks[name].length === 0) {\n delete this._callbacks[name];\n }\n },\n this\n );\n }\n\n private removeAllCallbacks(names: string[]) {\n Collections.apply(\n names,\n function(name) {\n delete this._callbacks[name];\n },\n this\n );\n }\n}\n\nfunction prefix(name: string): string {\n return '_' + name;\n}\n","import * as Collections from '../utils/collections';\nimport Callback from './callback';\nimport Metadata from '../channels/metadata';\nimport CallbackRegistry from './callback_registry';\n\n/** Manages callback bindings and event emitting.\n *\n * @param Function failThrough called when no listeners are bound to an event\n */\nexport default class Dispatcher {\n callbacks: CallbackRegistry;\n global_callbacks: Function[];\n failThrough: Function;\n\n constructor(failThrough?: Function) {\n this.callbacks = new CallbackRegistry();\n this.global_callbacks = [];\n this.failThrough = failThrough;\n }\n\n bind(eventName: string, callback: Function, context?: any) {\n this.callbacks.add(eventName, callback, context);\n return this;\n }\n\n bind_global(callback: Function) {\n this.global_callbacks.push(callback);\n return this;\n }\n\n unbind(eventName?: string, callback?: Function, context?: any) {\n this.callbacks.remove(eventName, callback, context);\n return this;\n }\n\n unbind_global(callback?: Function) {\n if (!callback) {\n this.global_callbacks = [];\n return this;\n }\n\n this.global_callbacks = Collections.filter(\n this.global_callbacks || [],\n c => c !== callback\n );\n\n return this;\n }\n\n unbind_all() {\n this.unbind();\n this.unbind_global();\n return this;\n }\n\n emit(eventName: string, data?: any, metadata?: Metadata): Dispatcher {\n for (var i = 0; i < this.global_callbacks.length; i++) {\n this.global_callbacks[i](eventName, data);\n }\n\n var callbacks = this.callbacks.get(eventName);\n var args = [];\n\n if (metadata) {\n // if there's a metadata argument, we need to call the callback with both\n // data and metadata regardless of whether data is undefined\n args.push(data, metadata);\n } else if (data) {\n // metadata is undefined, so we only need to call the callback with data\n // if data exists\n args.push(data);\n }\n\n if (callbacks && callbacks.length > 0) {\n for (var i = 0; i < callbacks.length; i++) {\n callbacks[i].fn.apply(callbacks[i].context || global, args);\n }\n } else if (this.failThrough) {\n this.failThrough(eventName, data);\n }\n\n return this;\n }\n}\n","import { stringify } from './utils/collections';\nimport Pusher from './pusher';\n\nclass Logger {\n debug(...args: any[]) {\n this.log(this.globalLog, args);\n }\n\n warn(...args: any[]) {\n this.log(this.globalLogWarn, args);\n }\n\n error(...args: any[]) {\n this.log(this.globalLogError, args);\n }\n\n private globalLog = (message: string) => {\n if (global.console && global.console.log) {\n global.console.log(message);\n }\n };\n\n private globalLogWarn(message: string) {\n if (global.console && global.console.warn) {\n global.console.warn(message);\n } else {\n this.globalLog(message);\n }\n }\n\n private globalLogError(message: string) {\n if (global.console && global.console.error) {\n global.console.error(message);\n } else {\n this.globalLogWarn(message);\n }\n }\n\n private log(\n defaultLoggingFunction: (message: string) => void,\n ...args: any[]\n ) {\n var message = stringify.apply(this, arguments);\n if (Pusher.log) {\n Pusher.log(message);\n } else if (Pusher.logToConsole) {\n const log = defaultLoggingFunction.bind(this);\n log(message);\n }\n }\n}\n\nexport default new Logger();\n","import Util from '../util';\nimport * as Collections from '../utils/collections';\nimport { default as EventsDispatcher } from '../events/dispatcher';\nimport Logger from '../logger';\nimport TransportHooks from './transport_hooks';\nimport Socket from '../socket';\nimport Runtime from 'runtime';\nimport Timeline from '../timeline/timeline';\nimport TransportConnectionOptions from './transport_connection_options';\n\n/** Provides universal API for transport connections.\n *\n * Transport connection is a low-level object that wraps a connection method\n * and exposes a simple evented interface for the connection state and\n * messaging. It does not implement Pusher-specific WebSocket protocol.\n *\n * Additionally, it fetches resources needed for transport to work and exposes\n * an interface for querying transport features.\n *\n * States:\n * - new - initial state after constructing the object\n * - initializing - during initialization phase, usually fetching resources\n * - intialized - ready to establish a connection\n * - connection - when connection is being established\n * - open - when connection ready to be used\n * - closed - after connection was closed be either side\n *\n * Emits:\n * - error - after the connection raised an error\n *\n * Options:\n * - useTLS - whether connection should be over TLS\n * - hostTLS - host to connect to when connection is over TLS\n * - hostNonTLS - host to connect to when connection is over TLS\n *\n * @param {String} key application key\n * @param {Object} options\n */\nexport default class TransportConnection extends EventsDispatcher {\n hooks: TransportHooks;\n name: string;\n priority: number;\n key: string;\n options: TransportConnectionOptions;\n state: string;\n timeline: Timeline;\n activityTimeout: number;\n id: number;\n socket: Socket;\n beforeOpen: Function;\n initialize: Function;\n\n constructor(\n hooks: TransportHooks,\n name: string,\n priority: number,\n key: string,\n options: TransportConnectionOptions\n ) {\n super();\n this.initialize = Runtime.transportConnectionInitializer;\n this.hooks = hooks;\n this.name = name;\n this.priority = priority;\n this.key = key;\n this.options = options;\n\n this.state = 'new';\n this.timeline = options.timeline;\n this.activityTimeout = options.activityTimeout;\n this.id = this.timeline.generateUniqueID();\n }\n\n /** Checks whether the transport handles activity checks by itself.\n *\n * @return {Boolean}\n */\n handlesActivityChecks(): boolean {\n return Boolean(this.hooks.handlesActivityChecks);\n }\n\n /** Checks whether the transport supports the ping/pong API.\n *\n * @return {Boolean}\n */\n supportsPing(): boolean {\n return Boolean(this.hooks.supportsPing);\n }\n\n /** Tries to establish a connection.\n *\n * @returns {Boolean} false if transport is in invalid state\n */\n connect(): boolean {\n if (this.socket || this.state !== 'initialized') {\n return false;\n }\n\n var url = this.hooks.urls.getInitial(this.key, this.options);\n try {\n this.socket = this.hooks.getSocket(url, this.options);\n } catch (e) {\n Util.defer(() => {\n this.onError(e);\n this.changeState('closed');\n });\n return false;\n }\n\n this.bindListeners();\n\n Logger.debug('Connecting', { transport: this.name, url });\n this.changeState('connecting');\n return true;\n }\n\n /** Closes the connection.\n *\n * @return {Boolean} true if there was a connection to close\n */\n close(): boolean {\n if (this.socket) {\n this.socket.close();\n return true;\n } else {\n return false;\n }\n }\n\n /** Sends data over the open connection.\n *\n * @param {String} data\n * @return {Boolean} true only when in the \"open\" state\n */\n send(data: any): boolean {\n if (this.state === 'open') {\n // Workaround for MobileSafari bug (see https://gist.github.com/2052006)\n Util.defer(() => {\n if (this.socket) {\n this.socket.send(data);\n }\n });\n return true;\n } else {\n return false;\n }\n }\n\n /** Sends a ping if the connection is open and transport supports it. */\n ping() {\n if (this.state === 'open' && this.supportsPing()) {\n this.socket.ping();\n }\n }\n\n private onOpen() {\n if (this.hooks.beforeOpen) {\n this.hooks.beforeOpen(\n this.socket,\n this.hooks.urls.getPath(this.key, this.options)\n );\n }\n this.changeState('open');\n this.socket.onopen = undefined;\n }\n\n private onError(error) {\n this.emit('error', { type: 'WebSocketError', error: error });\n this.timeline.error(this.buildTimelineMessage({ error: error.toString() }));\n }\n\n private onClose(closeEvent?: any) {\n if (closeEvent) {\n this.changeState('closed', {\n code: closeEvent.code,\n reason: closeEvent.reason,\n wasClean: closeEvent.wasClean\n });\n } else {\n this.changeState('closed');\n }\n this.unbindListeners();\n this.socket = undefined;\n }\n\n private onMessage(message) {\n this.emit('message', message);\n }\n\n private onActivity() {\n this.emit('activity');\n }\n\n private bindListeners() {\n this.socket.onopen = () => {\n this.onOpen();\n };\n this.socket.onerror = error => {\n this.onError(error);\n };\n this.socket.onclose = closeEvent => {\n this.onClose(closeEvent);\n };\n this.socket.onmessage = message => {\n this.onMessage(message);\n };\n\n if (this.supportsPing()) {\n this.socket.onactivity = () => {\n this.onActivity();\n };\n }\n }\n\n private unbindListeners() {\n if (this.socket) {\n this.socket.onopen = undefined;\n this.socket.onerror = undefined;\n this.socket.onclose = undefined;\n this.socket.onmessage = undefined;\n if (this.supportsPing()) {\n this.socket.onactivity = undefined;\n }\n }\n }\n\n private changeState(state: string, params?: any) {\n this.state = state;\n this.timeline.info(\n this.buildTimelineMessage({\n state: state,\n params: params\n })\n );\n this.emit(state, params);\n }\n\n buildTimelineMessage(message): any {\n return Collections.extend({ cid: this.id }, message);\n }\n}\n","import Factory from '../utils/factory';\nimport TransportHooks from './transport_hooks';\nimport TransportConnection from './transport_connection';\nimport TransportConnectionOptions from './transport_connection_options';\n\n/** Provides interface for transport connection instantiation.\n *\n * Takes transport-specific hooks as the only argument, which allow checking\n * for transport support and creating its connections.\n *\n * Supported hooks: * - file - the name of the file to be fetched during initialization\n * - urls - URL scheme to be used by transport\n * - handlesActivityCheck - true when the transport handles activity checks\n * - supportsPing - true when the transport has a ping/activity API\n * - isSupported - tells whether the transport is supported in the environment\n * - getSocket - creates a WebSocket-compatible transport socket\n *\n * See transports.js for specific implementations.\n *\n * @param {Object} hooks object containing all needed transport hooks\n */\nexport default class Transport {\n hooks: TransportHooks;\n\n constructor(hooks: TransportHooks) {\n this.hooks = hooks;\n }\n\n /** Returns whether the transport is supported in the environment.\n *\n * @param {Object} envronment te environment details (encryption, settings)\n * @returns {Boolean} true when the transport is supported\n */\n isSupported(environment: any): boolean {\n return this.hooks.isSupported(environment);\n }\n\n /** Creates a transport connection.\n *\n * @param {String} name\n * @param {Number} priority\n * @param {String} key the application key\n * @param {Object} options\n * @returns {TransportConnection}\n */\n createConnection(\n name: string,\n priority: number,\n key: string,\n options: any\n ): TransportConnection {\n return new TransportConnection(this.hooks, name, priority, key, options);\n }\n}\n","import * as URLSchemes from 'core/transports/url_schemes';\nimport URLScheme from 'core/transports/url_scheme';\nimport Transport from 'core/transports/transport';\nimport Util from 'core/util';\nimport * as Collections from 'core/utils/collections';\nimport TransportHooks from 'core/transports/transport_hooks';\nimport TransportsTable from 'core/transports/transports_table';\nimport Runtime from 'runtime';\n\n/** WebSocket transport.\n *\n * Uses native WebSocket implementation, including MozWebSocket supported by\n * earlier Firefox versions.\n */\nvar WSTransport = new Transport({\n urls: URLSchemes.ws,\n handlesActivityChecks: false,\n supportsPing: false,\n\n isInitialized: function() {\n return Boolean(Runtime.getWebSocketAPI());\n },\n isSupported: function(): boolean {\n return Boolean(Runtime.getWebSocketAPI());\n },\n getSocket: function(url) {\n return Runtime.createWebSocket(url);\n }\n});\n\nvar httpConfiguration = {\n urls: URLSchemes.http,\n handlesActivityChecks: false,\n supportsPing: true,\n isInitialized: function() {\n return true;\n }\n};\n\nexport var streamingConfiguration = Collections.extend(\n {\n getSocket: function(url) {\n return Runtime.HTTPFactory.createStreamingSocket(url);\n }\n },\n httpConfiguration\n);\nexport var pollingConfiguration = Collections.extend(\n {\n getSocket: function(url) {\n return Runtime.HTTPFactory.createPollingSocket(url);\n }\n },\n httpConfiguration\n);\n\nvar xhrConfiguration = {\n isSupported: function(): boolean {\n return Runtime.isXHRSupported();\n }\n};\n\n/** HTTP streaming transport using CORS-enabled XMLHttpRequest. */\nvar XHRStreamingTransport = new Transport(\n (\n Collections.extend({}, streamingConfiguration, xhrConfiguration)\n )\n);\n\n/** HTTP long-polling transport using CORS-enabled XMLHttpRequest. */\nvar XHRPollingTransport = new Transport(\n Collections.extend({}, pollingConfiguration, xhrConfiguration)\n);\n\nvar Transports: TransportsTable = {\n ws: WSTransport,\n xhr_streaming: XHRStreamingTransport,\n xhr_polling: XHRPollingTransport\n};\n\nexport default Transports;\n","import Util from '../util';\nimport * as Collections from '../utils/collections';\nimport TransportManager from './transport_manager';\nimport TransportConnection from './transport_connection';\nimport Transport from './transport';\nimport PingDelayOptions from './ping_delay_options';\n\n/** Creates transport connections monitored by a transport manager.\n *\n * When a transport is closed, it might mean the environment does not support\n * it. It's possible that messages get stuck in an intermediate buffer or\n * proxies terminate inactive connections. To combat these problems,\n * assistants monitor the connection lifetime, report unclean exits and\n * adjust ping timeouts to keep the connection active. The decision to disable\n * a transport is the manager's responsibility.\n *\n * @param {TransportManager} manager\n * @param {TransportConnection} transport\n * @param {Object} options\n */\nexport default class AssistantToTheTransportManager {\n manager: TransportManager;\n transport: Transport;\n minPingDelay: number;\n maxPingDelay: number;\n pingDelay: number;\n\n constructor(\n manager: TransportManager,\n transport: Transport,\n options: PingDelayOptions\n ) {\n this.manager = manager;\n this.transport = transport;\n this.minPingDelay = options.minPingDelay;\n this.maxPingDelay = options.maxPingDelay;\n this.pingDelay = undefined;\n }\n\n /** Creates a transport connection.\n *\n * This function has the same API as Transport#createConnection.\n *\n * @param {String} name\n * @param {Number} priority\n * @param {String} key the application key\n * @param {Object} options\n * @returns {TransportConnection}\n */\n createConnection(\n name: string,\n priority: number,\n key: string,\n options: Object\n ): TransportConnection {\n options = Collections.extend({}, options, {\n activityTimeout: this.pingDelay\n });\n var connection = this.transport.createConnection(\n name,\n priority,\n key,\n options\n );\n\n var openTimestamp = null;\n\n var onOpen = function() {\n connection.unbind('open', onOpen);\n connection.bind('closed', onClosed);\n openTimestamp = Util.now();\n };\n var onClosed = closeEvent => {\n connection.unbind('closed', onClosed);\n\n if (closeEvent.code === 1002 || closeEvent.code === 1003) {\n // we don't want to use transports not obeying the protocol\n this.manager.reportDeath();\n } else if (!closeEvent.wasClean && openTimestamp) {\n // report deaths only for short-living transport\n var lifespan = Util.now() - openTimestamp;\n if (lifespan < 2 * this.maxPingDelay) {\n this.manager.reportDeath();\n this.pingDelay = Math.max(lifespan / 2, this.minPingDelay);\n }\n }\n };\n\n connection.bind('open', onOpen);\n return connection;\n }\n\n /** Returns whether the transport is supported in the environment.\n *\n * This function has the same API as Transport#isSupported. Might return false\n * when the manager decides to kill the transport.\n *\n * @param {Object} environment the environment details (encryption, settings)\n * @returns {Boolean} true when the transport is supported\n */\n isSupported(environment: string): boolean {\n return this.manager.isAlive() && this.transport.isSupported(environment);\n }\n}\n","import Action from './action';\nimport { PusherEvent } from './message-types';\n/**\n * Provides functions for handling Pusher protocol-specific messages.\n */\n\nconst Protocol = {\n /**\n * Decodes a message in a Pusher format.\n *\n * The MessageEvent we receive from the transport should contain a pusher event\n * (https://pusher.com/docs/pusher_protocol#events) serialized as JSON in the\n * data field\n *\n * The pusher event may contain a data field too, and it may also be\n * serialised as JSON\n *\n * Throws errors when messages are not parse'able.\n *\n * @param {MessageEvent} messageEvent\n * @return {PusherEvent}\n */\n decodeMessage: function(messageEvent: MessageEvent): PusherEvent {\n try {\n var messageData = JSON.parse(messageEvent.data);\n var pusherEventData = messageData.data;\n if (typeof pusherEventData === 'string') {\n try {\n pusherEventData = JSON.parse(messageData.data);\n } catch (e) {}\n }\n var pusherEvent: PusherEvent = {\n event: messageData.event,\n channel: messageData.channel,\n data: pusherEventData\n };\n if (messageData.user_id) {\n pusherEvent.user_id = messageData.user_id;\n }\n return pusherEvent;\n } catch (e) {\n throw { type: 'MessageParseError', error: e, data: messageEvent.data };\n }\n },\n\n /**\n * Encodes a message to be sent.\n *\n * @param {PusherEvent} event\n * @return {String}\n */\n encodeMessage: function(event: PusherEvent): string {\n return JSON.stringify(event);\n },\n\n /**\n * Processes a handshake message and returns appropriate actions.\n *\n * Returns an object with an 'action' and other action-specific properties.\n *\n * There are three outcomes when calling this function. First is a successful\n * connection attempt, when pusher:connection_established is received, which\n * results in a 'connected' action with an 'id' property. When passed a\n * pusher:error event, it returns a result with action appropriate to the\n * close code and an error. Otherwise, it raises an exception.\n *\n * @param {String} message\n * @result Object\n */\n processHandshake: function(messageEvent: MessageEvent): Action {\n var message = Protocol.decodeMessage(messageEvent);\n\n if (message.event === 'pusher:connection_established') {\n if (!message.data.activity_timeout) {\n throw 'No activity timeout specified in handshake';\n }\n return {\n action: 'connected',\n id: message.data.socket_id,\n activityTimeout: message.data.activity_timeout * 1000\n };\n } else if (message.event === 'pusher:error') {\n // From protocol 6 close codes are sent only once, so this only\n // happens when connection does not support close codes\n return {\n action: this.getCloseAction(message.data),\n error: this.getCloseError(message.data)\n };\n } else {\n throw 'Invalid handshake';\n }\n },\n\n /**\n * Dispatches the close event and returns an appropriate action name.\n *\n * See:\n * 1. https://developer.mozilla.org/en-US/docs/WebSockets/WebSockets_reference/CloseEvent\n * 2. http://pusher.com/docs/pusher_protocol\n *\n * @param {CloseEvent} closeEvent\n * @return {String} close action name\n */\n getCloseAction: function(closeEvent): string {\n if (closeEvent.code < 4000) {\n // ignore 1000 CLOSE_NORMAL, 1001 CLOSE_GOING_AWAY,\n // 1005 CLOSE_NO_STATUS, 1006 CLOSE_ABNORMAL\n // ignore 1007...3999\n // handle 1002 CLOSE_PROTOCOL_ERROR, 1003 CLOSE_UNSUPPORTED,\n // 1004 CLOSE_TOO_LARGE\n if (closeEvent.code >= 1002 && closeEvent.code <= 1004) {\n return 'backoff';\n } else {\n return null;\n }\n } else if (closeEvent.code === 4000) {\n return 'tls_only';\n } else if (closeEvent.code < 4100) {\n return 'refused';\n } else if (closeEvent.code < 4200) {\n return 'backoff';\n } else if (closeEvent.code < 4300) {\n return 'retry';\n } else {\n // unknown error\n return 'refused';\n }\n },\n\n /**\n * Returns an error or null basing on the close event.\n *\n * Null is returned when connection was closed cleanly. Otherwise, an object\n * with error details is returned.\n *\n * @param {CloseEvent} closeEvent\n * @return {Object} error object\n */\n getCloseError: function(closeEvent): any {\n if (closeEvent.code !== 1000 && closeEvent.code !== 1001) {\n return {\n type: 'PusherError',\n data: {\n code: closeEvent.code,\n message: closeEvent.reason || closeEvent.message\n }\n };\n } else {\n return null;\n }\n }\n};\n\nexport default Protocol;\n","import * as Collections from '../utils/collections';\nimport { default as EventsDispatcher } from '../events/dispatcher';\nimport Protocol from './protocol/protocol';\nimport { PusherEvent } from './protocol/message-types';\nimport Logger from '../logger';\nimport TransportConnection from '../transports/transport_connection';\nimport Socket from '../socket';\n/**\n * Provides Pusher protocol interface for transports.\n *\n * Emits following events:\n * - message - on received messages\n * - ping - on ping requests\n * - pong - on pong responses\n * - error - when the transport emits an error\n * - closed - after closing the transport\n *\n * It also emits more events when connection closes with a code.\n * See Protocol.getCloseAction to get more details.\n *\n * @param {Number} id\n * @param {AbstractTransport} transport\n */\nexport default class Connection extends EventsDispatcher implements Socket {\n id: string;\n transport: TransportConnection;\n activityTimeout: number;\n\n constructor(id: string, transport: TransportConnection) {\n super();\n this.id = id;\n this.transport = transport;\n this.activityTimeout = transport.activityTimeout;\n this.bindListeners();\n }\n\n /** Returns whether used transport handles activity checks by itself\n *\n * @returns {Boolean} true if activity checks are handled by the transport\n */\n handlesActivityChecks() {\n return this.transport.handlesActivityChecks();\n }\n\n /** Sends raw data.\n *\n * @param {String} data\n */\n send(data: any): boolean {\n return this.transport.send(data);\n }\n\n /** Sends an event.\n *\n * @param {String} name\n * @param {String} data\n * @param {String} [channel]\n * @returns {Boolean} whether message was sent or not\n */\n send_event(name: string, data: any, channel?: string): boolean {\n var event: PusherEvent = { event: name, data: data };\n if (channel) {\n event.channel = channel;\n }\n Logger.debug('Event sent', event);\n return this.send(Protocol.encodeMessage(event));\n }\n\n /** Sends a ping message to the server.\n *\n * Basing on the underlying transport, it might send either transport's\n * protocol-specific ping or pusher:ping event.\n */\n ping() {\n if (this.transport.supportsPing()) {\n this.transport.ping();\n } else {\n this.send_event('pusher:ping', {});\n }\n }\n\n /** Closes the connection. */\n close() {\n this.transport.close();\n }\n\n private bindListeners() {\n var listeners = {\n message: (messageEvent: MessageEvent) => {\n var pusherEvent;\n try {\n pusherEvent = Protocol.decodeMessage(messageEvent);\n } catch (e) {\n this.emit('error', {\n type: 'MessageParseError',\n error: e,\n data: messageEvent.data\n });\n }\n\n if (pusherEvent !== undefined) {\n Logger.debug('Event recd', pusherEvent);\n\n switch (pusherEvent.event) {\n case 'pusher:error':\n this.emit('error', {\n type: 'PusherError',\n data: pusherEvent.data\n });\n break;\n case 'pusher:ping':\n this.emit('ping');\n break;\n case 'pusher:pong':\n this.emit('pong');\n break;\n }\n this.emit('message', pusherEvent);\n }\n },\n activity: () => {\n this.emit('activity');\n },\n error: error => {\n this.emit('error', error);\n },\n closed: closeEvent => {\n unbindListeners();\n\n if (closeEvent && closeEvent.code) {\n this.handleCloseEvent(closeEvent);\n }\n\n this.transport = null;\n this.emit('closed');\n }\n };\n\n var unbindListeners = () => {\n Collections.objectApply(listeners, (listener, event) => {\n this.transport.unbind(event, listener);\n });\n };\n\n Collections.objectApply(listeners, (listener, event) => {\n this.transport.bind(event, listener);\n });\n }\n\n private handleCloseEvent(closeEvent: any) {\n var action = Protocol.getCloseAction(closeEvent);\n var error = Protocol.getCloseError(closeEvent);\n if (error) {\n this.emit('error', error);\n }\n if (action) {\n this.emit(action, { action: action, error: error });\n }\n }\n}\n","import Util from '../../util';\nimport * as Collections from '../../utils/collections';\nimport Protocol from '../protocol/protocol';\nimport Connection from '../connection';\nimport TransportConnection from '../../transports/transport_connection';\nimport HandshakePayload from './handshake_payload';\n\n/**\n * Handles Pusher protocol handshakes for transports.\n *\n * Calls back with a result object after handshake is completed. Results\n * always have two fields:\n * - action - string describing action to be taken after the handshake\n * - transport - the transport object passed to the constructor\n *\n * Different actions can set different additional properties on the result.\n * In the case of 'connected' action, there will be a 'connection' property\n * containing a Connection object for the transport. Other actions should\n * carry an 'error' property.\n *\n * @param {AbstractTransport} transport\n * @param {Function} callback\n */\nexport default class Handshake {\n transport: TransportConnection;\n callback: (HandshakePayload) => void;\n onMessage: Function;\n onClosed: Function;\n\n constructor(\n transport: TransportConnection,\n callback: (HandshakePayload) => void\n ) {\n this.transport = transport;\n this.callback = callback;\n this.bindListeners();\n }\n\n close() {\n this.unbindListeners();\n this.transport.close();\n }\n\n private bindListeners() {\n this.onMessage = m => {\n this.unbindListeners();\n\n var result;\n try {\n result = Protocol.processHandshake(m);\n } catch (e) {\n this.finish('error', { error: e });\n this.transport.close();\n return;\n }\n\n if (result.action === 'connected') {\n this.finish('connected', {\n connection: new Connection(result.id, this.transport),\n activityTimeout: result.activityTimeout\n });\n } else {\n this.finish(result.action, { error: result.error });\n this.transport.close();\n }\n };\n\n this.onClosed = closeEvent => {\n this.unbindListeners();\n\n var action = Protocol.getCloseAction(closeEvent) || 'backoff';\n var error = Protocol.getCloseError(closeEvent);\n this.finish(action, { error: error });\n };\n\n this.transport.bind('message', this.onMessage);\n this.transport.bind('closed', this.onClosed);\n }\n\n private unbindListeners() {\n this.transport.unbind('message', this.onMessage);\n this.transport.unbind('closed', this.onClosed);\n }\n\n private finish(action: string, params: any) {\n this.callback(\n Collections.extend({ transport: this.transport, action: action }, params)\n );\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport base64encode from '../base64';\nimport Timeline from './timeline';\nimport Runtime from 'runtime';\n\nexport interface TimelineSenderOptions {\n host?: string;\n port?: number;\n path?: string;\n}\n\nexport default class TimelineSender {\n timeline: Timeline;\n options: TimelineSenderOptions;\n host: string;\n\n constructor(timeline: Timeline, options: TimelineSenderOptions) {\n this.timeline = timeline;\n this.options = options || {};\n }\n\n send(useTLS: boolean, callback?: Function) {\n if (this.timeline.isEmpty()) {\n return;\n }\n\n this.timeline.send(\n Runtime.TimelineTransport.getAgent(this, useTLS),\n callback\n );\n }\n}\n","/** Error classes used throughout the library. */\n// https://github.com/Microsoft/TypeScript-wiki/blob/master/Breaking-Changes.md#extending-built-ins-like-error-array-and-map-may-no-longer-work\nexport class BadEventName extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\nexport class BadChannelName extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\nexport class RequestTimedOut extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class TransportPriorityTooLow extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class TransportClosed extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class UnsupportedFeature extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class UnsupportedTransport extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class UnsupportedStrategy extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class HTTPAuthError extends Error {\n status: number;\n constructor(status: number, msg?: string) {\n super(msg);\n this.status = status;\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n","/**\n * A place to store help URLs for error messages etc\n */\n\nconst urlStore = {\n baseUrl: 'https://pusher.com',\n urls: {\n authenticationEndpoint: {\n path: '/docs/channels/server_api/authenticating_users'\n },\n authorizationEndpoint: {\n path: '/docs/channels/server_api/authorizing-users/'\n },\n javascriptQuickStart: {\n path: '/docs/javascript_quick_start'\n },\n triggeringClientEvents: {\n path: '/docs/client_api_guide/client_events#trigger-events'\n },\n encryptedChannelSupport: {\n fullUrl:\n 'https://github.com/pusher/pusher-js/tree/cc491015371a4bde5743d1c87a0fbac0feb53195#encrypted-channel-support'\n }\n }\n};\n\n/** Builds a consistent string with links to pusher documentation\n *\n * @param {string} key - relevant key in the url_store.urls object\n * @return {string} suffix string to append to log message\n */\nconst buildLogSuffix = function(key: string): string {\n const urlPrefix = 'See:';\n const urlObj = urlStore.urls[key];\n if (!urlObj) return '';\n\n let url;\n if (urlObj.fullUrl) {\n url = urlObj.fullUrl;\n } else if (urlObj.path) {\n url = urlStore.baseUrl + urlObj.path;\n }\n\n if (!url) return '';\n return `${urlPrefix} ${url}`;\n};\n\nexport default { buildLogSuffix };\n","import { default as EventsDispatcher } from '../events/dispatcher';\nimport * as Errors from '../errors';\nimport Logger from '../logger';\nimport Pusher from '../pusher';\nimport { PusherEvent } from '../connection/protocol/message-types';\nimport Metadata from './metadata';\nimport UrlStore from '../utils/url_store';\nimport {\n ChannelAuthorizationData,\n ChannelAuthorizationCallback\n} from '../auth/options';\nimport { HTTPAuthError } from '../errors';\n\n/** Provides base public channel interface with an event emitter.\n *\n * Emits:\n * - pusher:subscription_succeeded - after subscribing successfully\n * - other non-internal events\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\nexport default class Channel extends EventsDispatcher {\n name: string;\n pusher: Pusher;\n subscribed: boolean;\n subscriptionPending: boolean;\n subscriptionCancelled: boolean;\n subscriptionCount: null;\n\n constructor(name: string, pusher: Pusher) {\n super(function(event, data) {\n Logger.debug('No callbacks on ' + name + ' for ' + event);\n });\n\n this.name = name;\n this.pusher = pusher;\n this.subscribed = false;\n this.subscriptionPending = false;\n this.subscriptionCancelled = false;\n }\n\n /** Skips authorization, since public channels don't require it.\n *\n * @param {Function} callback\n */\n authorize(socketId: string, callback: ChannelAuthorizationCallback) {\n return callback(null, { auth: '' });\n }\n\n /** Triggers an event */\n trigger(event: string, data: any) {\n if (event.indexOf('client-') !== 0) {\n throw new Errors.BadEventName(\n \"Event '\" + event + \"' does not start with 'client-'\"\n );\n }\n if (!this.subscribed) {\n var suffix = UrlStore.buildLogSuffix('triggeringClientEvents');\n Logger.warn(\n `Client event triggered before channel 'subscription_succeeded' event . ${suffix}`\n );\n }\n return this.pusher.send_event(event, data, this.name);\n }\n\n /** Signals disconnection to the channel. For internal use only. */\n disconnect() {\n this.subscribed = false;\n this.subscriptionPending = false;\n }\n\n /** Handles a PusherEvent. For internal use only.\n *\n * @param {PusherEvent} event\n */\n handleEvent(event: PusherEvent) {\n var eventName = event.event;\n var data = event.data;\n if (eventName === 'pusher_internal:subscription_succeeded') {\n this.handleSubscriptionSucceededEvent(event);\n } else if (eventName === 'pusher_internal:subscription_count') {\n this.handleSubscriptionCountEvent(event);\n } else if (eventName.indexOf('pusher_internal:') !== 0) {\n var metadata: Metadata = {};\n this.emit(eventName, data, metadata);\n }\n }\n\n handleSubscriptionSucceededEvent(event: PusherEvent) {\n this.subscriptionPending = false;\n this.subscribed = true;\n if (this.subscriptionCancelled) {\n this.pusher.unsubscribe(this.name);\n } else {\n this.emit('pusher:subscription_succeeded', event.data);\n }\n }\n\n handleSubscriptionCountEvent(event: PusherEvent) {\n if (event.data.subscription_count) {\n this.subscriptionCount = event.data.subscription_count;\n }\n\n this.emit('pusher:subscription_count', event.data);\n }\n\n /** Sends a subscription request. For internal use only. */\n subscribe() {\n if (this.subscribed) {\n return;\n }\n this.subscriptionPending = true;\n this.subscriptionCancelled = false;\n this.authorize(\n this.pusher.connection.socket_id,\n (error: Error | null, data: ChannelAuthorizationData) => {\n if (error) {\n this.subscriptionPending = false;\n // Why not bind to 'pusher:subscription_error' a level up, and log there?\n // Binding to this event would cause the warning about no callbacks being\n // bound (see constructor) to be suppressed, that's not what we want.\n Logger.error(error.toString());\n this.emit(\n 'pusher:subscription_error',\n Object.assign(\n {},\n {\n type: 'AuthError',\n error: error.message\n },\n error instanceof HTTPAuthError ? { status: error.status } : {}\n )\n );\n } else {\n this.pusher.send_event('pusher:subscribe', {\n auth: data.auth,\n channel_data: data.channel_data,\n channel: this.name\n });\n }\n }\n );\n }\n\n /** Sends an unsubscription request. For internal use only. */\n unsubscribe() {\n this.subscribed = false;\n this.pusher.send_event('pusher:unsubscribe', {\n channel: this.name\n });\n }\n\n /** Cancels an in progress subscription. For internal use only. */\n cancelSubscription() {\n this.subscriptionCancelled = true;\n }\n\n /** Reinstates an in progress subscripiton. For internal use only. */\n reinstateSubscription() {\n this.subscriptionCancelled = false;\n }\n}\n","import Factory from '../utils/factory';\nimport Channel from './channel';\nimport { ChannelAuthorizationCallback } from '../auth/options';\n\n/** Extends public channels to provide private channel interface.\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\nexport default class PrivateChannel extends Channel {\n /** Authorizes the connection to use the channel.\n *\n * @param {String} socketId\n * @param {Function} callback\n */\n authorize(socketId: string, callback: ChannelAuthorizationCallback) {\n return this.pusher.config.channelAuthorizer(\n {\n channelName: this.name,\n socketId: socketId\n },\n callback\n );\n }\n}\n","import * as Collections from '../utils/collections';\n\n/** Represents a collection of members of a presence channel. */\nexport default class Members {\n members: any;\n count: number;\n myID: any;\n me: any;\n\n constructor() {\n this.reset();\n }\n\n /** Returns member's info for given id.\n *\n * Resulting object containts two fields - id and info.\n *\n * @param {Number} id\n * @return {Object} member's info or null\n */\n get(id: string): any {\n if (Object.prototype.hasOwnProperty.call(this.members, id)) {\n return {\n id: id,\n info: this.members[id]\n };\n } else {\n return null;\n }\n }\n\n /** Calls back for each member in unspecified order.\n *\n * @param {Function} callback\n */\n each(callback: Function) {\n Collections.objectApply(this.members, (member, id) => {\n callback(this.get(id));\n });\n }\n\n /** Updates the id for connected member. For internal use only. */\n setMyID(id: string) {\n this.myID = id;\n }\n\n /** Handles subscription data. For internal use only. */\n onSubscription(subscriptionData: any) {\n this.members = subscriptionData.presence.hash;\n this.count = subscriptionData.presence.count;\n this.me = this.get(this.myID);\n }\n\n /** Adds a new member to the collection. For internal use only. */\n addMember(memberData: any) {\n if (this.get(memberData.user_id) === null) {\n this.count++;\n }\n this.members[memberData.user_id] = memberData.user_info;\n return this.get(memberData.user_id);\n }\n\n /** Adds a member from the collection. For internal use only. */\n removeMember(memberData: any) {\n var member = this.get(memberData.user_id);\n if (member) {\n delete this.members[memberData.user_id];\n this.count--;\n }\n return member;\n }\n\n /** Resets the collection to the initial state. For internal use only. */\n reset() {\n this.members = {};\n this.count = 0;\n this.myID = null;\n this.me = null;\n }\n}\n","import PrivateChannel from './private_channel';\nimport Logger from '../logger';\nimport Members from './members';\nimport Pusher from '../pusher';\nimport UrlStore from 'core/utils/url_store';\nimport { PusherEvent } from '../connection/protocol/message-types';\nimport Metadata from './metadata';\nimport { ChannelAuthorizationData } from '../auth/options';\n\nexport default class PresenceChannel extends PrivateChannel {\n members: Members;\n\n /** Adds presence channel functionality to private channels.\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\n constructor(name: string, pusher: Pusher) {\n super(name, pusher);\n this.members = new Members();\n }\n\n /** Authorizes the connection as a member of the channel.\n *\n * @param {String} socketId\n * @param {Function} callback\n */\n authorize(socketId: string, callback: Function) {\n super.authorize(socketId, async (error, authData) => {\n if (!error) {\n authData = authData as ChannelAuthorizationData;\n if (authData.channel_data != null) {\n var channelData = JSON.parse(authData.channel_data);\n this.members.setMyID(channelData.user_id);\n } else {\n await this.pusher.user.signinDonePromise;\n if (this.pusher.user.user_data != null) {\n // If the user is signed in, get the id of the authenticated user\n // and allow the presence authorization to continue.\n this.members.setMyID(this.pusher.user.user_data.id);\n } else {\n let suffix = UrlStore.buildLogSuffix('authorizationEndpoint');\n Logger.error(\n `Invalid auth response for channel '${this.name}', ` +\n `expected 'channel_data' field. ${suffix}, ` +\n `or the user should be signed in.`\n );\n callback('Invalid auth response');\n return;\n }\n }\n }\n callback(error, authData);\n });\n }\n\n /** Handles presence and subscription events. For internal use only.\n *\n * @param {PusherEvent} event\n */\n handleEvent(event: PusherEvent) {\n var eventName = event.event;\n if (eventName.indexOf('pusher_internal:') === 0) {\n this.handleInternalEvent(event);\n } else {\n var data = event.data;\n var metadata: Metadata = {};\n if (event.user_id) {\n metadata.user_id = event.user_id;\n }\n this.emit(eventName, data, metadata);\n }\n }\n handleInternalEvent(event: PusherEvent) {\n var eventName = event.event;\n var data = event.data;\n switch (eventName) {\n case 'pusher_internal:subscription_succeeded':\n this.handleSubscriptionSucceededEvent(event);\n break;\n case 'pusher_internal:subscription_count':\n this.handleSubscriptionCountEvent(event);\n break;\n case 'pusher_internal:member_added':\n var addedMember = this.members.addMember(data);\n this.emit('pusher:member_added', addedMember);\n break;\n case 'pusher_internal:member_removed':\n var removedMember = this.members.removeMember(data);\n if (removedMember) {\n this.emit('pusher:member_removed', removedMember);\n }\n break;\n }\n }\n\n handleSubscriptionSucceededEvent(event: PusherEvent) {\n this.subscriptionPending = false;\n this.subscribed = true;\n if (this.subscriptionCancelled) {\n this.pusher.unsubscribe(this.name);\n } else {\n this.members.onSubscription(event.data);\n this.emit('pusher:subscription_succeeded', this.members);\n }\n }\n\n /** Resets the channel state, including members map. For internal use only. */\n disconnect() {\n this.members.reset();\n super.disconnect();\n }\n}\n","import PrivateChannel from './private_channel';\nimport * as Errors from '../errors';\nimport Logger from '../logger';\nimport Pusher from '../pusher';\nimport { decode as encodeUTF8 } from '@stablelib/utf8';\nimport { decode as decodeBase64 } from '@stablelib/base64';\nimport Dispatcher from '../events/dispatcher';\nimport { PusherEvent } from '../connection/protocol/message-types';\nimport {\n ChannelAuthorizationData,\n ChannelAuthorizationCallback\n} from '../auth/options';\nimport * as nacl from 'tweetnacl';\n\n/** Extends private channels to provide encrypted channel interface.\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\nexport default class EncryptedChannel extends PrivateChannel {\n key: Uint8Array = null;\n nacl: nacl;\n\n constructor(name: string, pusher: Pusher, nacl: nacl) {\n super(name, pusher);\n this.nacl = nacl;\n }\n\n /** Authorizes the connection to use the channel.\n *\n * @param {String} socketId\n * @param {Function} callback\n */\n authorize(socketId: string, callback: ChannelAuthorizationCallback) {\n super.authorize(\n socketId,\n (error: Error | null, authData: ChannelAuthorizationData) => {\n if (error) {\n callback(error, authData);\n return;\n }\n let sharedSecret = authData['shared_secret'];\n if (!sharedSecret) {\n callback(\n new Error(\n `No shared_secret key in auth payload for encrypted channel: ${this.name}`\n ),\n null\n );\n return;\n }\n this.key = decodeBase64(sharedSecret);\n delete authData['shared_secret'];\n callback(null, authData);\n }\n );\n }\n\n trigger(event: string, data: any): boolean {\n throw new Errors.UnsupportedFeature(\n 'Client events are not currently supported for encrypted channels'\n );\n }\n\n /** Handles an event. For internal use only.\n *\n * @param {PusherEvent} event\n */\n handleEvent(event: PusherEvent) {\n var eventName = event.event;\n var data = event.data;\n if (\n eventName.indexOf('pusher_internal:') === 0 ||\n eventName.indexOf('pusher:') === 0\n ) {\n super.handleEvent(event);\n return;\n }\n this.handleEncryptedEvent(eventName, data);\n }\n\n private handleEncryptedEvent(event: string, data: any): void {\n if (!this.key) {\n Logger.debug(\n 'Received encrypted event before key has been retrieved from the authEndpoint'\n );\n return;\n }\n if (!data.ciphertext || !data.nonce) {\n Logger.error(\n 'Unexpected format for encrypted event, expected object with `ciphertext` and `nonce` fields, got: ' +\n data\n );\n return;\n }\n let cipherText = decodeBase64(data.ciphertext);\n if (cipherText.length < this.nacl.secretbox.overheadLength) {\n Logger.error(\n `Expected encrypted event ciphertext length to be ${this.nacl.secretbox.overheadLength}, got: ${cipherText.length}`\n );\n return;\n }\n let nonce = decodeBase64(data.nonce);\n if (nonce.length < this.nacl.secretbox.nonceLength) {\n Logger.error(\n `Expected encrypted event nonce length to be ${this.nacl.secretbox.nonceLength}, got: ${nonce.length}`\n );\n return;\n }\n\n let bytes = this.nacl.secretbox.open(cipherText, nonce, this.key);\n if (bytes === null) {\n Logger.debug(\n 'Failed to decrypt an event, probably because it was encrypted with a different key. Fetching a new key from the authEndpoint...'\n );\n // Try a single time to retrieve a new auth key and decrypt the event with it\n // If this fails, a new key will be requested when a new message is received\n this.authorize(this.pusher.connection.socket_id, (error, authData) => {\n if (error) {\n Logger.error(\n `Failed to make a request to the authEndpoint: ${authData}. Unable to fetch new key, so dropping encrypted event`\n );\n return;\n }\n bytes = this.nacl.secretbox.open(cipherText, nonce, this.key);\n if (bytes === null) {\n Logger.error(\n `Failed to decrypt event with new key. Dropping encrypted event`\n );\n return;\n }\n this.emit(event, this.getDataToEmit(bytes));\n return;\n });\n return;\n }\n this.emit(event, this.getDataToEmit(bytes));\n }\n\n // Try and parse the decrypted bytes as JSON. If we can't parse it, just\n // return the utf-8 string\n getDataToEmit(bytes: Uint8Array): string {\n let raw = encodeUTF8(bytes);\n try {\n return JSON.parse(raw);\n } catch {\n return raw;\n }\n }\n}\n","import { default as EventsDispatcher } from '../events/dispatcher';\nimport { OneOffTimer as Timer } from '../utils/timers';\nimport { Config } from '../config';\nimport Logger from '../logger';\nimport HandshakePayload from './handshake/handshake_payload';\nimport Connection from './connection';\nimport Strategy from '../strategies/strategy';\nimport StrategyRunner from '../strategies/strategy_runner';\nimport * as Collections from '../utils/collections';\nimport Timeline from '../timeline/timeline';\nimport ConnectionManagerOptions from './connection_manager_options';\nimport Runtime from 'runtime';\n\nimport {\n ErrorCallbacks,\n HandshakeCallbacks,\n ConnectionCallbacks\n} from './callbacks';\nimport Action from './protocol/action';\n\n/** Manages connection to Pusher.\n *\n * Uses a strategy (currently only default), timers and network availability\n * info to establish a connection and export its state. In case of failures,\n * manages reconnection attempts.\n *\n * Exports state changes as following events:\n * - \"state_change\", { previous: p, current: state }\n * - state\n *\n * States:\n * - initialized - initial state, never transitioned to\n * - connecting - connection is being established\n * - connected - connection has been fully established\n * - disconnected - on requested disconnection\n * - unavailable - after connection timeout or when there's no network\n * - failed - when the connection strategy is not supported\n *\n * Options:\n * - unavailableTimeout - time to transition to unavailable state\n * - activityTimeout - time after which ping message should be sent\n * - pongTimeout - time for Pusher to respond with pong before reconnecting\n *\n * @param {String} key application key\n * @param {Object} options\n */\nexport default class ConnectionManager extends EventsDispatcher {\n key: string;\n options: ConnectionManagerOptions;\n state: string;\n connection: Connection;\n usingTLS: boolean;\n timeline: Timeline;\n socket_id: string;\n unavailableTimer: Timer;\n activityTimer: Timer;\n retryTimer: Timer;\n activityTimeout: number;\n strategy: Strategy;\n runner: StrategyRunner;\n errorCallbacks: ErrorCallbacks;\n handshakeCallbacks: HandshakeCallbacks;\n connectionCallbacks: ConnectionCallbacks;\n\n constructor(key: string, options: ConnectionManagerOptions) {\n super();\n this.state = 'initialized';\n this.connection = null;\n\n this.key = key;\n this.options = options;\n this.timeline = this.options.timeline;\n this.usingTLS = this.options.useTLS;\n\n this.errorCallbacks = this.buildErrorCallbacks();\n this.connectionCallbacks = this.buildConnectionCallbacks(\n this.errorCallbacks\n );\n this.handshakeCallbacks = this.buildHandshakeCallbacks(this.errorCallbacks);\n\n var Network = Runtime.getNetwork();\n\n Network.bind('online', () => {\n this.timeline.info({ netinfo: 'online' });\n if (this.state === 'connecting' || this.state === 'unavailable') {\n this.retryIn(0);\n }\n });\n Network.bind('offline', () => {\n this.timeline.info({ netinfo: 'offline' });\n if (this.connection) {\n this.sendActivityCheck();\n }\n });\n\n this.updateStrategy();\n }\n\n /** Establishes a connection to Pusher.\n *\n * Does nothing when connection is already established. See top-level doc\n * to find events emitted on connection attempts.\n */\n connect() {\n if (this.connection || this.runner) {\n return;\n }\n if (!this.strategy.isSupported()) {\n this.updateState('failed');\n return;\n }\n this.updateState('connecting');\n this.startConnecting();\n this.setUnavailableTimer();\n }\n\n /** Sends raw data.\n *\n * @param {String} data\n */\n send(data) {\n if (this.connection) {\n return this.connection.send(data);\n } else {\n return false;\n }\n }\n\n /** Sends an event.\n *\n * @param {String} name\n * @param {String} data\n * @param {String} [channel]\n * @returns {Boolean} whether message was sent or not\n */\n send_event(name: string, data: any, channel?: string) {\n if (this.connection) {\n return this.connection.send_event(name, data, channel);\n } else {\n return false;\n }\n }\n\n /** Closes the connection. */\n disconnect() {\n this.disconnectInternally();\n this.updateState('disconnected');\n }\n\n isUsingTLS() {\n return this.usingTLS;\n }\n\n private startConnecting() {\n var callback = (error, handshake) => {\n if (error) {\n this.runner = this.strategy.connect(0, callback);\n } else {\n if (handshake.action === 'error') {\n this.emit('error', {\n type: 'HandshakeError',\n error: handshake.error\n });\n this.timeline.error({ handshakeError: handshake.error });\n } else {\n this.abortConnecting(); // we don't support switching connections yet\n this.handshakeCallbacks[handshake.action](handshake);\n }\n }\n };\n this.runner = this.strategy.connect(0, callback);\n }\n\n private abortConnecting() {\n if (this.runner) {\n this.runner.abort();\n this.runner = null;\n }\n }\n\n private disconnectInternally() {\n this.abortConnecting();\n this.clearRetryTimer();\n this.clearUnavailableTimer();\n if (this.connection) {\n var connection = this.abandonConnection();\n connection.close();\n }\n }\n\n private updateStrategy() {\n this.strategy = this.options.getStrategy({\n key: this.key,\n timeline: this.timeline,\n useTLS: this.usingTLS\n });\n }\n\n private retryIn(delay) {\n this.timeline.info({ action: 'retry', delay: delay });\n if (delay > 0) {\n this.emit('connecting_in', Math.round(delay / 1000));\n }\n this.retryTimer = new Timer(delay || 0, () => {\n this.disconnectInternally();\n this.connect();\n });\n }\n\n private clearRetryTimer() {\n if (this.retryTimer) {\n this.retryTimer.ensureAborted();\n this.retryTimer = null;\n }\n }\n\n private setUnavailableTimer() {\n this.unavailableTimer = new Timer(this.options.unavailableTimeout, () => {\n this.updateState('unavailable');\n });\n }\n\n private clearUnavailableTimer() {\n if (this.unavailableTimer) {\n this.unavailableTimer.ensureAborted();\n }\n }\n\n private sendActivityCheck() {\n this.stopActivityCheck();\n this.connection.ping();\n // wait for pong response\n this.activityTimer = new Timer(this.options.pongTimeout, () => {\n this.timeline.error({ pong_timed_out: this.options.pongTimeout });\n this.retryIn(0);\n });\n }\n\n private resetActivityCheck() {\n this.stopActivityCheck();\n // send ping after inactivity\n if (this.connection && !this.connection.handlesActivityChecks()) {\n this.activityTimer = new Timer(this.activityTimeout, () => {\n this.sendActivityCheck();\n });\n }\n }\n\n private stopActivityCheck() {\n if (this.activityTimer) {\n this.activityTimer.ensureAborted();\n }\n }\n\n private buildConnectionCallbacks(\n errorCallbacks: ErrorCallbacks\n ): ConnectionCallbacks {\n return Collections.extend({}, errorCallbacks, {\n message: message => {\n // includes pong messages from server\n this.resetActivityCheck();\n this.emit('message', message);\n },\n ping: () => {\n this.send_event('pusher:pong', {});\n },\n activity: () => {\n this.resetActivityCheck();\n },\n error: error => {\n // just emit error to user - socket will already be closed by browser\n this.emit('error', error);\n },\n closed: () => {\n this.abandonConnection();\n if (this.shouldRetry()) {\n this.retryIn(1000);\n }\n }\n });\n }\n\n private buildHandshakeCallbacks(\n errorCallbacks: ErrorCallbacks\n ): HandshakeCallbacks {\n return Collections.extend({}, errorCallbacks, {\n connected: (handshake: HandshakePayload) => {\n this.activityTimeout = Math.min(\n this.options.activityTimeout,\n handshake.activityTimeout,\n handshake.connection.activityTimeout || Infinity\n );\n this.clearUnavailableTimer();\n this.setConnection(handshake.connection);\n this.socket_id = this.connection.id;\n this.updateState('connected', { socket_id: this.socket_id });\n }\n });\n }\n\n private buildErrorCallbacks(): ErrorCallbacks {\n let withErrorEmitted = callback => {\n return (result: Action | HandshakePayload) => {\n if (result.error) {\n this.emit('error', { type: 'WebSocketError', error: result.error });\n }\n callback(result);\n };\n };\n\n return {\n tls_only: withErrorEmitted(() => {\n this.usingTLS = true;\n this.updateStrategy();\n this.retryIn(0);\n }),\n refused: withErrorEmitted(() => {\n this.disconnect();\n }),\n backoff: withErrorEmitted(() => {\n this.retryIn(1000);\n }),\n retry: withErrorEmitted(() => {\n this.retryIn(0);\n })\n };\n }\n\n private setConnection(connection) {\n this.connection = connection;\n for (var event in this.connectionCallbacks) {\n this.connection.bind(event, this.connectionCallbacks[event]);\n }\n this.resetActivityCheck();\n }\n\n private abandonConnection() {\n if (!this.connection) {\n return;\n }\n this.stopActivityCheck();\n for (var event in this.connectionCallbacks) {\n this.connection.unbind(event, this.connectionCallbacks[event]);\n }\n var connection = this.connection;\n this.connection = null;\n return connection;\n }\n\n private updateState(newState: string, data?: any) {\n var previousState = this.state;\n this.state = newState;\n if (previousState !== newState) {\n var newStateDescription = newState;\n if (newStateDescription === 'connected') {\n newStateDescription += ' with new socket ID ' + data.socket_id;\n }\n Logger.debug(\n 'State changed',\n previousState + ' -> ' + newStateDescription\n );\n this.timeline.info({ state: newState, params: data });\n this.emit('state_change', { previous: previousState, current: newState });\n this.emit(newState, data);\n }\n }\n\n private shouldRetry(): boolean {\n return this.state === 'connecting' || this.state === 'connected';\n }\n}\n","import Channel from './channel';\nimport * as Collections from '../utils/collections';\nimport ChannelTable from './channel_table';\nimport Factory from '../utils/factory';\nimport Pusher from '../pusher';\nimport Logger from '../logger';\nimport * as Errors from '../errors';\nimport urlStore from '../utils/url_store';\n\n/** Handles a channel map. */\nexport default class Channels {\n channels: ChannelTable;\n\n constructor() {\n this.channels = {};\n }\n\n /** Creates or retrieves an existing channel by its name.\n *\n * @param {String} name\n * @param {Pusher} pusher\n * @return {Channel}\n */\n add(name: string, pusher: Pusher) {\n if (!this.channels[name]) {\n this.channels[name] = createChannel(name, pusher);\n }\n return this.channels[name];\n }\n\n /** Returns a list of all channels\n *\n * @return {Array}\n */\n all(): Channel[] {\n return Collections.values(this.channels);\n }\n\n /** Finds a channel by its name.\n *\n * @param {String} name\n * @return {Channel} channel or null if it doesn't exist\n */\n find(name: string) {\n return this.channels[name];\n }\n\n /** Removes a channel from the map.\n *\n * @param {String} name\n */\n remove(name: string) {\n var channel = this.channels[name];\n delete this.channels[name];\n return channel;\n }\n\n /** Proxies disconnection signal to all channels. */\n disconnect() {\n Collections.objectApply(this.channels, function(channel) {\n channel.disconnect();\n });\n }\n}\n\nfunction createChannel(name: string, pusher: Pusher): Channel {\n if (name.indexOf('private-encrypted-') === 0) {\n if (pusher.config.nacl) {\n return Factory.createEncryptedChannel(name, pusher, pusher.config.nacl);\n }\n let errMsg =\n 'Tried to subscribe to a private-encrypted- channel but no nacl implementation available';\n let suffix = urlStore.buildLogSuffix('encryptedChannelSupport');\n throw new Errors.UnsupportedFeature(`${errMsg}. ${suffix}`);\n } else if (name.indexOf('private-') === 0) {\n return Factory.createPrivateChannel(name, pusher);\n } else if (name.indexOf('presence-') === 0) {\n return Factory.createPresenceChannel(name, pusher);\n } else if (name.indexOf('#') === 0) {\n throw new Errors.BadChannelName(\n 'Cannot create a channel with name \"' + name + '\".'\n );\n } else {\n return Factory.createChannel(name, pusher);\n }\n}\n","import AssistantToTheTransportManager from '../transports/assistant_to_the_transport_manager';\nimport PingDelayOptions from '../transports/ping_delay_options';\nimport Transport from '../transports/transport';\nimport TransportManager from '../transports/transport_manager';\nimport Handshake from '../connection/handshake';\nimport TransportConnection from '../transports/transport_connection';\nimport SocketHooks from '../http/socket_hooks';\nimport HTTPSocket from '../http/http_socket';\n\nimport Timeline from '../timeline/timeline';\nimport {\n default as TimelineSender,\n TimelineSenderOptions\n} from '../timeline/timeline_sender';\nimport PresenceChannel from '../channels/presence_channel';\nimport PrivateChannel from '../channels/private_channel';\nimport EncryptedChannel from '../channels/encrypted_channel';\nimport Channel from '../channels/channel';\nimport ConnectionManager from '../connection/connection_manager';\nimport ConnectionManagerOptions from '../connection/connection_manager_options';\nimport Ajax from '../http/ajax';\nimport Channels from '../channels/channels';\nimport Pusher from '../pusher';\nimport { Config } from '../config';\nimport * as nacl from 'tweetnacl';\n\nvar Factory = {\n createChannels(): Channels {\n return new Channels();\n },\n\n createConnectionManager(\n key: string,\n options: ConnectionManagerOptions\n ): ConnectionManager {\n return new ConnectionManager(key, options);\n },\n\n createChannel(name: string, pusher: Pusher): Channel {\n return new Channel(name, pusher);\n },\n\n createPrivateChannel(name: string, pusher: Pusher): PrivateChannel {\n return new PrivateChannel(name, pusher);\n },\n\n createPresenceChannel(name: string, pusher: Pusher): PresenceChannel {\n return new PresenceChannel(name, pusher);\n },\n\n createEncryptedChannel(\n name: string,\n pusher: Pusher,\n nacl: nacl\n ): EncryptedChannel {\n return new EncryptedChannel(name, pusher, nacl);\n },\n\n createTimelineSender(timeline: Timeline, options: TimelineSenderOptions) {\n return new TimelineSender(timeline, options);\n },\n\n createHandshake(\n transport: TransportConnection,\n callback: (HandshakePayload) => void\n ): Handshake {\n return new Handshake(transport, callback);\n },\n\n createAssistantToTheTransportManager(\n manager: TransportManager,\n transport: Transport,\n options: PingDelayOptions\n ): AssistantToTheTransportManager {\n return new AssistantToTheTransportManager(manager, transport, options);\n }\n};\n\nexport default Factory;\n","import AssistantToTheTransportManager from './assistant_to_the_transport_manager';\nimport Transport from './transport';\nimport PingDelayOptions from './ping_delay_options';\nimport Factory from '../utils/factory';\n\nexport interface TransportManagerOptions extends PingDelayOptions {\n lives?: number;\n}\n\n/** Keeps track of the number of lives left for a transport.\n *\n * In the beginning of a session, transports may be assigned a number of\n * lives. When an AssistantToTheTransportManager instance reports a transport\n * connection closed uncleanly, the transport loses a life. When the number\n * of lives drops to zero, the transport gets disabled by its manager.\n *\n * @param {Object} options\n */\nexport default class TransportManager {\n options: TransportManagerOptions;\n livesLeft: number;\n\n constructor(options: TransportManagerOptions) {\n this.options = options || {};\n this.livesLeft = this.options.lives || Infinity;\n }\n\n /** Creates a assistant for the transport.\n *\n * @param {Transport} transport\n * @returns {AssistantToTheTransportManager}\n */\n getAssistant(transport: Transport): AssistantToTheTransportManager {\n return Factory.createAssistantToTheTransportManager(this, transport, {\n minPingDelay: this.options.minPingDelay,\n maxPingDelay: this.options.maxPingDelay\n });\n }\n\n /** Returns whether the transport has any lives left.\n *\n * @returns {Boolean}\n */\n isAlive(): boolean {\n return this.livesLeft > 0;\n }\n\n /** Takes one life from the transport. */\n reportDeath() {\n this.livesLeft -= 1;\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport { OneOffTimer as Timer } from '../utils/timers';\nimport Strategy from './strategy';\nimport StrategyOptions from './strategy_options';\n\n/** Loops through strategies with optional timeouts.\n *\n * Options:\n * - loop - whether it should loop through the substrategy list\n * - timeout - initial timeout for a single substrategy\n * - timeoutLimit - maximum timeout\n *\n * @param {Strategy[]} strategies\n * @param {Object} options\n */\nexport default class SequentialStrategy implements Strategy {\n strategies: Strategy[];\n loop: boolean;\n failFast: boolean;\n timeout: number;\n timeoutLimit: number;\n\n constructor(strategies: Strategy[], options: StrategyOptions) {\n this.strategies = strategies;\n this.loop = Boolean(options.loop);\n this.failFast = Boolean(options.failFast);\n this.timeout = options.timeout;\n this.timeoutLimit = options.timeoutLimit;\n }\n\n isSupported(): boolean {\n return Collections.any(this.strategies, Util.method('isSupported'));\n }\n\n connect(minPriority: number, callback: Function) {\n var strategies = this.strategies;\n var current = 0;\n var timeout = this.timeout;\n var runner = null;\n\n var tryNextStrategy = (error, handshake) => {\n if (handshake) {\n callback(null, handshake);\n } else {\n current = current + 1;\n if (this.loop) {\n current = current % strategies.length;\n }\n\n if (current < strategies.length) {\n if (timeout) {\n timeout = timeout * 2;\n if (this.timeoutLimit) {\n timeout = Math.min(timeout, this.timeoutLimit);\n }\n }\n runner = this.tryStrategy(\n strategies[current],\n minPriority,\n { timeout, failFast: this.failFast },\n tryNextStrategy\n );\n } else {\n callback(true);\n }\n }\n };\n\n runner = this.tryStrategy(\n strategies[current],\n minPriority,\n { timeout: timeout, failFast: this.failFast },\n tryNextStrategy\n );\n\n return {\n abort: function() {\n runner.abort();\n },\n forceMinPriority: function(p) {\n minPriority = p;\n if (runner) {\n runner.forceMinPriority(p);\n }\n }\n };\n }\n\n private tryStrategy(\n strategy: Strategy,\n minPriority: number,\n options: StrategyOptions,\n callback: Function\n ) {\n var timer = null;\n var runner = null;\n\n if (options.timeout > 0) {\n timer = new Timer(options.timeout, function() {\n runner.abort();\n callback(true);\n });\n }\n\n runner = strategy.connect(minPriority, function(error, handshake) {\n if (error && timer && timer.isRunning() && !options.failFast) {\n // advance to the next strategy after the timeout\n return;\n }\n if (timer) {\n timer.ensureAborted();\n }\n callback(error, handshake);\n });\n\n return {\n abort: function() {\n if (timer) {\n timer.ensureAborted();\n }\n runner.abort();\n },\n forceMinPriority: function(p) {\n runner.forceMinPriority(p);\n }\n };\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport Strategy from './strategy';\n\n/** Launches all substrategies and emits prioritized connected transports.\n *\n * @param {Array} strategies\n */\nexport default class BestConnectedEverStrategy implements Strategy {\n strategies: Strategy[];\n\n constructor(strategies: Strategy[]) {\n this.strategies = strategies;\n }\n\n isSupported(): boolean {\n return Collections.any(this.strategies, Util.method('isSupported'));\n }\n\n connect(minPriority: number, callback: Function) {\n return connect(this.strategies, minPriority, function(i, runners) {\n return function(error, handshake) {\n runners[i].error = error;\n if (error) {\n if (allRunnersFailed(runners)) {\n callback(true);\n }\n return;\n }\n Collections.apply(runners, function(runner) {\n runner.forceMinPriority(handshake.transport.priority);\n });\n callback(null, handshake);\n };\n });\n }\n}\n\n/** Connects to all strategies in parallel.\n *\n * Callback builder should be a function that takes two arguments: index\n * and a list of runners. It should return another function that will be\n * passed to the substrategy with given index. Runners can be aborted using\n * abortRunner(s) functions from this class.\n *\n * @param {Array} strategies\n * @param {Function} callbackBuilder\n * @return {Object} strategy runner\n */\nfunction connect(\n strategies: Strategy[],\n minPriority: number,\n callbackBuilder: Function\n) {\n var runners = Collections.map(strategies, function(strategy, i, _, rs) {\n return strategy.connect(minPriority, callbackBuilder(i, rs));\n });\n return {\n abort: function() {\n Collections.apply(runners, abortRunner);\n },\n forceMinPriority: function(p) {\n Collections.apply(runners, function(runner) {\n runner.forceMinPriority(p);\n });\n }\n };\n}\n\nfunction allRunnersFailed(runners): boolean {\n return Collections.all(runners, function(runner) {\n return Boolean(runner.error);\n });\n}\n\nfunction abortRunner(runner) {\n if (!runner.error && !runner.aborted) {\n runner.abort();\n runner.aborted = true;\n }\n}\n","import Util from '../util';\nimport Runtime from 'runtime';\nimport Strategy from './strategy';\nimport SequentialStrategy from './sequential_strategy';\nimport StrategyOptions from './strategy_options';\nimport TransportStrategy from './transport_strategy';\nimport Timeline from '../timeline/timeline';\nimport * as Collections from '../utils/collections';\n\nexport interface TransportStrategyDictionary {\n [key: string]: TransportStrategy;\n}\n\n/** Caches the last successful transport and, after the first few attempts,\n * uses the cached transport for subsequent attempts.\n *\n * @param {Strategy} strategy\n * @param {Object} transports\n * @param {Object} options\n */\nexport default class WebSocketPrioritizedCachedStrategy implements Strategy {\n strategy: Strategy;\n transports: TransportStrategyDictionary;\n ttl: number;\n usingTLS: boolean;\n timeline: Timeline;\n\n constructor(\n strategy: Strategy,\n transports: TransportStrategyDictionary,\n options: StrategyOptions\n ) {\n this.strategy = strategy;\n this.transports = transports;\n this.ttl = options.ttl || 1800 * 1000;\n this.usingTLS = options.useTLS;\n this.timeline = options.timeline;\n }\n\n isSupported(): boolean {\n return this.strategy.isSupported();\n }\n\n connect(minPriority: number, callback: Function) {\n var usingTLS = this.usingTLS;\n var info = fetchTransportCache(usingTLS);\n var cacheSkipCount = info && info.cacheSkipCount ? info.cacheSkipCount : 0;\n\n var strategies = [this.strategy];\n if (info && info.timestamp + this.ttl >= Util.now()) {\n var transport = this.transports[info.transport];\n if (transport) {\n if (['ws', 'wss'].includes(info.transport) || cacheSkipCount > 3) {\n this.timeline.info({\n cached: true,\n transport: info.transport,\n latency: info.latency\n });\n strategies.push(\n new SequentialStrategy([transport], {\n timeout: info.latency * 2 + 1000,\n failFast: true\n })\n );\n } else {\n cacheSkipCount++;\n }\n }\n }\n\n var startTimestamp = Util.now();\n var runner = strategies\n .pop()\n .connect(minPriority, function cb(error, handshake) {\n if (error) {\n flushTransportCache(usingTLS);\n if (strategies.length > 0) {\n startTimestamp = Util.now();\n runner = strategies.pop().connect(minPriority, cb);\n } else {\n callback(error);\n }\n } else {\n storeTransportCache(\n usingTLS,\n handshake.transport.name,\n Util.now() - startTimestamp,\n cacheSkipCount\n );\n callback(null, handshake);\n }\n });\n\n return {\n abort: function() {\n runner.abort();\n },\n forceMinPriority: function(p) {\n minPriority = p;\n if (runner) {\n runner.forceMinPriority(p);\n }\n }\n };\n }\n}\n\nfunction getTransportCacheKey(usingTLS: boolean): string {\n return 'pusherTransport' + (usingTLS ? 'TLS' : 'NonTLS');\n}\n\nfunction fetchTransportCache(usingTLS: boolean): any {\n var storage = Runtime.getLocalStorage();\n if (storage) {\n try {\n var serializedCache = storage[getTransportCacheKey(usingTLS)];\n if (serializedCache) {\n return JSON.parse(serializedCache);\n }\n } catch (e) {\n flushTransportCache(usingTLS);\n }\n }\n return null;\n}\n\nfunction storeTransportCache(\n usingTLS: boolean,\n transport: TransportStrategy,\n latency: number,\n cacheSkipCount: number\n) {\n var storage = Runtime.getLocalStorage();\n if (storage) {\n try {\n storage[getTransportCacheKey(usingTLS)] = Collections.safeJSONStringify({\n timestamp: Util.now(),\n transport: transport,\n latency: latency,\n cacheSkipCount: cacheSkipCount\n });\n } catch (e) {\n // catch over quota exceptions raised by localStorage\n }\n }\n}\n\nfunction flushTransportCache(usingTLS: boolean) {\n var storage = Runtime.getLocalStorage();\n if (storage) {\n try {\n delete storage[getTransportCacheKey(usingTLS)];\n } catch (e) {\n // catch exceptions raised by localStorage\n }\n }\n}\n","import { OneOffTimer as Timer } from '../utils/timers';\nimport Strategy from './strategy';\nimport StrategyOptions from './strategy_options';\n\n/** Runs substrategy after specified delay.\n *\n * Options:\n * - delay - time in miliseconds to delay the substrategy attempt\n *\n * @param {Strategy} strategy\n * @param {Object} options\n */\nexport default class DelayedStrategy implements Strategy {\n strategy: Strategy;\n options: { delay: number };\n\n constructor(strategy: Strategy, { delay: number }) {\n this.strategy = strategy;\n this.options = { delay: number };\n }\n\n isSupported(): boolean {\n return this.strategy.isSupported();\n }\n\n connect(minPriority: number, callback: Function) {\n var strategy = this.strategy;\n var runner;\n var timer = new Timer(this.options.delay, function() {\n runner = strategy.connect(minPriority, callback);\n });\n\n return {\n abort: function() {\n timer.ensureAborted();\n if (runner) {\n runner.abort();\n }\n },\n forceMinPriority: function(p) {\n minPriority = p;\n if (runner) {\n runner.forceMinPriority(p);\n }\n }\n };\n }\n}\n","import Strategy from './strategy';\nimport StrategyRunner from './strategy_runner';\n\n/** Proxies method calls to one of substrategies basing on the test function.\n *\n * @param {Function} test\n * @param {Strategy} trueBranch strategy used when test returns true\n * @param {Strategy} falseBranch strategy used when test returns false\n */\nexport default class IfStrategy implements Strategy {\n test: () => boolean;\n trueBranch: Strategy;\n falseBranch: Strategy;\n\n constructor(\n test: () => boolean,\n trueBranch: Strategy,\n falseBranch: Strategy\n ) {\n this.test = test;\n this.trueBranch = trueBranch;\n this.falseBranch = falseBranch;\n }\n\n isSupported(): boolean {\n var branch = this.test() ? this.trueBranch : this.falseBranch;\n return branch.isSupported();\n }\n\n connect(minPriority: number, callback: Function): StrategyRunner {\n var branch = this.test() ? this.trueBranch : this.falseBranch;\n return branch.connect(minPriority, callback);\n }\n}\n","import Strategy from './strategy';\nimport StrategyRunner from './strategy_runner';\n\n/** Launches the substrategy and terminates on the first open connection.\n *\n * @param {Strategy} strategy\n */\nexport default class FirstConnectedStrategy implements Strategy {\n strategy: Strategy;\n\n constructor(strategy: Strategy) {\n this.strategy = strategy;\n }\n\n isSupported(): boolean {\n return this.strategy.isSupported();\n }\n\n connect(minPriority: number, callback: Function): StrategyRunner {\n var runner = this.strategy.connect(minPriority, function(error, handshake) {\n if (handshake) {\n runner.abort();\n }\n callback(error, handshake);\n });\n return runner;\n }\n}\n","import * as Collections from 'core/utils/collections';\nimport TransportManager from 'core/transports/transport_manager';\nimport Strategy from 'core/strategies/strategy';\nimport SequentialStrategy from 'core/strategies/sequential_strategy';\nimport BestConnectedEverStrategy from 'core/strategies/best_connected_ever_strategy';\nimport WebSocketPrioritizedCachedStrategy, {\n TransportStrategyDictionary\n} from 'core/strategies/websocket_prioritized_cached_strategy';\nimport DelayedStrategy from 'core/strategies/delayed_strategy';\nimport IfStrategy from 'core/strategies/if_strategy';\nimport FirstConnectedStrategy from 'core/strategies/first_connected_strategy';\nimport { Config } from 'core/config';\nimport StrategyOptions from 'core/strategies/strategy_options';\n\nfunction testSupportsStrategy(strategy: Strategy) {\n return function() {\n return strategy.isSupported();\n };\n}\n\nvar getDefaultStrategy = function(\n config: Config,\n baseOptions: StrategyOptions,\n defineTransport: Function\n): Strategy {\n var definedTransports = {};\n\n function defineTransportStrategy(\n name: string,\n type: string,\n priority: number,\n options: StrategyOptions,\n manager?: TransportManager\n ) {\n var transport = defineTransport(\n config,\n name,\n type,\n priority,\n options,\n manager\n );\n\n definedTransports[name] = transport;\n\n return transport;\n }\n\n var ws_options: StrategyOptions = Object.assign({}, baseOptions, {\n hostNonTLS: config.wsHost + ':' + config.wsPort,\n hostTLS: config.wsHost + ':' + config.wssPort,\n httpPath: config.wsPath\n });\n var wss_options: StrategyOptions = Collections.extend({}, ws_options, {\n useTLS: true\n });\n var http_options: StrategyOptions = Object.assign({}, baseOptions, {\n hostNonTLS: config.httpHost + ':' + config.httpPort,\n hostTLS: config.httpHost + ':' + config.httpsPort,\n httpPath: config.httpPath\n });\n var timeouts = {\n loop: true,\n timeout: 15000,\n timeoutLimit: 60000\n };\n\n var ws_manager = new TransportManager({\n minPingDelay: 10000,\n maxPingDelay: config.activityTimeout\n });\n var streaming_manager = new TransportManager({\n lives: 2,\n minPingDelay: 10000,\n maxPingDelay: config.activityTimeout\n });\n\n var ws_transport = defineTransportStrategy(\n 'ws',\n 'ws',\n 3,\n ws_options,\n ws_manager\n );\n var wss_transport = defineTransportStrategy(\n 'wss',\n 'ws',\n 3,\n wss_options,\n ws_manager\n );\n var xhr_streaming_transport = defineTransportStrategy(\n 'xhr_streaming',\n 'xhr_streaming',\n 1,\n http_options,\n streaming_manager\n );\n var xhr_polling_transport = defineTransportStrategy(\n 'xhr_polling',\n 'xhr_polling',\n 1,\n http_options\n );\n\n var ws_loop = new SequentialStrategy([ws_transport], timeouts);\n var wss_loop = new SequentialStrategy([wss_transport], timeouts);\n var streaming_loop = new SequentialStrategy(\n [xhr_streaming_transport],\n timeouts\n );\n var polling_loop = new SequentialStrategy([xhr_polling_transport], timeouts);\n\n var http_loop = new SequentialStrategy(\n [\n new IfStrategy(\n testSupportsStrategy(streaming_loop),\n new BestConnectedEverStrategy([\n streaming_loop,\n new DelayedStrategy(polling_loop, { delay: 4000 })\n ]),\n polling_loop\n )\n ],\n timeouts\n );\n\n var wsStrategy;\n if (baseOptions.useTLS) {\n wsStrategy = new BestConnectedEverStrategy([\n ws_loop,\n new DelayedStrategy(http_loop, { delay: 2000 })\n ]);\n } else {\n wsStrategy = new BestConnectedEverStrategy([\n ws_loop,\n new DelayedStrategy(wss_loop, { delay: 2000 }),\n new DelayedStrategy(http_loop, { delay: 5000 })\n ]);\n }\n\n return new WebSocketPrioritizedCachedStrategy(\n new FirstConnectedStrategy(\n new IfStrategy(testSupportsStrategy(ws_transport), wsStrategy, http_loop)\n ),\n definedTransports,\n {\n ttl: 1800000,\n timeline: baseOptions.timeline,\n useTLS: baseOptions.useTLS\n }\n );\n};\n\nexport default getDefaultStrategy;\n","import Runtime from 'runtime';\nimport RequestHooks from './request_hooks';\nimport Ajax from './ajax';\nimport { default as EventsDispatcher } from '../events/dispatcher';\n\nconst MAX_BUFFER_LENGTH = 256 * 1024;\n\nexport default class HTTPRequest extends EventsDispatcher {\n hooks: RequestHooks;\n method: string;\n url: string;\n position: number;\n xhr: Ajax;\n unloader: Function;\n\n constructor(hooks: RequestHooks, method: string, url: string) {\n super();\n this.hooks = hooks;\n this.method = method;\n this.url = url;\n }\n\n start(payload?: any) {\n this.position = 0;\n this.xhr = this.hooks.getRequest(this);\n\n this.unloader = () => {\n this.close();\n };\n Runtime.addUnloadListener(this.unloader);\n\n this.xhr.open(this.method, this.url, true);\n\n if (this.xhr.setRequestHeader) {\n this.xhr.setRequestHeader('Content-Type', 'application/json'); // ReactNative doesn't set this header by default.\n }\n this.xhr.send(payload);\n }\n\n close() {\n if (this.unloader) {\n Runtime.removeUnloadListener(this.unloader);\n this.unloader = null;\n }\n if (this.xhr) {\n this.hooks.abortRequest(this.xhr);\n this.xhr = null;\n }\n }\n\n onChunk(status: number, data: any) {\n while (true) {\n var chunk = this.advanceBuffer(data);\n if (chunk) {\n this.emit('chunk', { status: status, data: chunk });\n } else {\n break;\n }\n }\n if (this.isBufferTooLong(data)) {\n this.emit('buffer_too_long');\n }\n }\n\n private advanceBuffer(buffer: any[]): any {\n var unreadData = buffer.slice(this.position);\n var endOfLinePosition = unreadData.indexOf('\\n');\n\n if (endOfLinePosition !== -1) {\n this.position += endOfLinePosition + 1;\n return unreadData.slice(0, endOfLinePosition);\n } else {\n // chunk is not finished yet, don't move the buffer pointer\n return null;\n }\n }\n\n private isBufferTooLong(buffer: any): boolean {\n return this.position === buffer.length && buffer.length > MAX_BUFFER_LENGTH;\n }\n}\n","enum State {\n CONNECTING = 0,\n OPEN = 1,\n CLOSED = 3\n}\n\nexport default State;\n","import URLLocation from './url_location';\nimport State from './state';\nimport Socket from '../socket';\nimport SocketHooks from './socket_hooks';\nimport Util from '../util';\nimport Ajax from './ajax';\nimport HTTPRequest from './http_request';\nimport Runtime from 'runtime';\n\nvar autoIncrement = 1;\n\nclass HTTPSocket implements Socket {\n hooks: SocketHooks;\n session: string;\n location: URLLocation;\n readyState: State;\n stream: HTTPRequest;\n\n onopen: () => void;\n onerror: (error: any) => void;\n onclose: (closeEvent: any) => void;\n onmessage: (message: any) => void;\n onactivity: () => void;\n\n constructor(hooks: SocketHooks, url: string) {\n this.hooks = hooks;\n this.session = randomNumber(1000) + '/' + randomString(8);\n this.location = getLocation(url);\n this.readyState = State.CONNECTING;\n this.openStream();\n }\n\n send(payload: any) {\n return this.sendRaw(JSON.stringify([payload]));\n }\n\n ping() {\n this.hooks.sendHeartbeat(this);\n }\n\n close(code: any, reason: any) {\n this.onClose(code, reason, true);\n }\n\n /** For internal use only */\n sendRaw(payload: any): boolean {\n if (this.readyState === State.OPEN) {\n try {\n Runtime.createSocketRequest(\n 'POST',\n getUniqueURL(getSendURL(this.location, this.session))\n ).start(payload);\n return true;\n } catch (e) {\n return false;\n }\n } else {\n return false;\n }\n }\n\n /** For internal use only */\n reconnect() {\n this.closeStream();\n this.openStream();\n }\n\n /** For internal use only */\n onClose(code, reason, wasClean) {\n this.closeStream();\n this.readyState = State.CLOSED;\n if (this.onclose) {\n this.onclose({\n code: code,\n reason: reason,\n wasClean: wasClean\n });\n }\n }\n\n private onChunk(chunk) {\n if (chunk.status !== 200) {\n return;\n }\n if (this.readyState === State.OPEN) {\n this.onActivity();\n }\n\n var payload;\n var type = chunk.data.slice(0, 1);\n switch (type) {\n case 'o':\n payload = JSON.parse(chunk.data.slice(1) || '{}');\n this.onOpen(payload);\n break;\n case 'a':\n payload = JSON.parse(chunk.data.slice(1) || '[]');\n for (var i = 0; i < payload.length; i++) {\n this.onEvent(payload[i]);\n }\n break;\n case 'm':\n payload = JSON.parse(chunk.data.slice(1) || 'null');\n this.onEvent(payload);\n break;\n case 'h':\n this.hooks.onHeartbeat(this);\n break;\n case 'c':\n payload = JSON.parse(chunk.data.slice(1) || '[]');\n this.onClose(payload[0], payload[1], true);\n break;\n }\n }\n\n private onOpen(options) {\n if (this.readyState === State.CONNECTING) {\n if (options && options.hostname) {\n this.location.base = replaceHost(this.location.base, options.hostname);\n }\n this.readyState = State.OPEN;\n\n if (this.onopen) {\n this.onopen();\n }\n } else {\n this.onClose(1006, 'Server lost session', true);\n }\n }\n\n private onEvent(event) {\n if (this.readyState === State.OPEN && this.onmessage) {\n this.onmessage({ data: event });\n }\n }\n\n private onActivity() {\n if (this.onactivity) {\n this.onactivity();\n }\n }\n\n private onError(error) {\n if (this.onerror) {\n this.onerror(error);\n }\n }\n\n private openStream() {\n this.stream = Runtime.createSocketRequest(\n 'POST',\n getUniqueURL(this.hooks.getReceiveURL(this.location, this.session))\n );\n\n this.stream.bind('chunk', chunk => {\n this.onChunk(chunk);\n });\n this.stream.bind('finished', status => {\n this.hooks.onFinished(this, status);\n });\n this.stream.bind('buffer_too_long', () => {\n this.reconnect();\n });\n\n try {\n this.stream.start();\n } catch (error) {\n Util.defer(() => {\n this.onError(error);\n this.onClose(1006, 'Could not start streaming', false);\n });\n }\n }\n\n private closeStream() {\n if (this.stream) {\n this.stream.unbind_all();\n this.stream.close();\n this.stream = null;\n }\n }\n}\n\nfunction getLocation(url): URLLocation {\n var parts = /([^\\?]*)\\/*(\\??.*)/.exec(url);\n return {\n base: parts[1],\n queryString: parts[2]\n };\n}\n\nfunction getSendURL(url: URLLocation, session: string): string {\n return url.base + '/' + session + '/xhr_send';\n}\n\nfunction getUniqueURL(url: string): string {\n var separator = url.indexOf('?') === -1 ? '?' : '&';\n return url + separator + 't=' + +new Date() + '&n=' + autoIncrement++;\n}\n\nfunction replaceHost(url: string, hostname: string): string {\n var urlParts = /(https?:\\/\\/)([^\\/:]+)((\\/|:)?.*)/.exec(url);\n return urlParts[1] + hostname + urlParts[3];\n}\n\nfunction randomNumber(max: number): number {\n return Runtime.randomInt(max);\n}\n\nfunction randomString(length: number): string {\n var result = [];\n\n for (var i = 0; i < length; i++) {\n result.push(randomNumber(32).toString(32));\n }\n\n return result.join('');\n}\n\nexport default HTTPSocket;\n","import SocketHooks from './socket_hooks';\nimport HTTPSocket from './http_socket';\n\nvar hooks: SocketHooks = {\n getReceiveURL: function(url, session) {\n return url.base + '/' + session + '/xhr_streaming' + url.queryString;\n },\n onHeartbeat: function(socket) {\n socket.sendRaw('[]');\n },\n sendHeartbeat: function(socket) {\n socket.sendRaw('[]');\n },\n onFinished: function(socket, status) {\n socket.onClose(1006, 'Connection interrupted (' + status + ')', false);\n }\n};\n\nexport default hooks;\n","import SocketHooks from './socket_hooks';\nimport URLLocation from './url_location';\nimport HTTPSocket from './http_socket';\n\nvar hooks: SocketHooks = {\n getReceiveURL: function(url: URLLocation, session: string): string {\n return url.base + '/' + session + '/xhr' + url.queryString;\n },\n onHeartbeat: function() {\n // next HTTP request will reset server's activity timer\n },\n sendHeartbeat: function(socket) {\n socket.sendRaw('[]');\n },\n onFinished: function(socket, status) {\n if (status === 200) {\n socket.reconnect();\n } else {\n socket.onClose(1006, 'Connection interrupted (' + status + ')', false);\n }\n }\n};\n\nexport default hooks;\n","import HTTPRequest from 'core/http/http_request';\nimport RequestHooks from 'core/http/request_hooks';\nimport Ajax from 'core/http/ajax';\nimport Runtime from 'runtime';\n\nvar hooks: RequestHooks = {\n getRequest: function(socket: HTTPRequest): Ajax {\n var Constructor = Runtime.getXHRAPI();\n var xhr = new Constructor();\n xhr.onreadystatechange = xhr.onprogress = function() {\n switch (xhr.readyState) {\n case 3:\n if (xhr.responseText && xhr.responseText.length > 0) {\n socket.onChunk(xhr.status, xhr.responseText);\n }\n break;\n case 4:\n // this happens only on errors, never after calling close\n if (xhr.responseText && xhr.responseText.length > 0) {\n socket.onChunk(xhr.status, xhr.responseText);\n }\n socket.emit('finished', xhr.status);\n socket.close();\n break;\n }\n };\n return xhr;\n },\n abortRequest: function(xhr: Ajax) {\n xhr.onreadystatechange = null;\n xhr.abort();\n }\n};\n\nexport default hooks;\n","import * as Collections from 'core/utils/collections';\nimport Transports from 'isomorphic/transports/transports';\nimport TimelineSender from 'core/timeline/timeline_sender';\nimport Ajax from 'core/http/ajax';\nimport getDefaultStrategy from './default_strategy';\nimport TransportsTable from 'core/transports/transports_table';\nimport transportConnectionInitializer from './transports/transport_connection_initializer';\nimport HTTPFactory from './http/http';\n\nvar Isomorphic: any = {\n getDefaultStrategy,\n Transports: Transports,\n transportConnectionInitializer,\n HTTPFactory,\n\n setup(PusherClass): void {\n PusherClass.ready();\n },\n\n getLocalStorage(): any {\n return undefined;\n },\n\n getClientFeatures(): any[] {\n return Collections.keys(\n Collections.filterObject({ ws: Transports.ws }, function(t) {\n return t.isSupported({});\n })\n );\n },\n\n getProtocol(): string {\n return 'http:';\n },\n\n isXHRSupported(): boolean {\n return true;\n },\n\n createSocketRequest(method: string, url: string) {\n if (this.isXHRSupported()) {\n return this.HTTPFactory.createXHR(method, url);\n } else {\n throw 'Cross-origin HTTP requests are not supported';\n }\n },\n\n createXHR(): Ajax {\n var Constructor = this.getXHRAPI();\n return new Constructor();\n },\n\n createWebSocket(url: string): any {\n var Constructor = this.getWebSocketAPI();\n return new Constructor(url);\n },\n\n addUnloadListener(listener: any) {},\n removeUnloadListener(listener: any) {}\n};\n\nexport default Isomorphic;\n","/** Initializes the transport.\n *\n * Fetches resources if needed and then transitions to initialized.\n */\nexport default function() {\n var self = this;\n\n self.timeline.info(\n self.buildTimelineMessage({\n transport: self.name + (self.options.useTLS ? 's' : '')\n })\n );\n\n if (self.hooks.isInitialized()) {\n self.changeState('initialized');\n } else {\n self.onClose();\n }\n}\n","import HTTPRequest from 'core/http/http_request';\nimport HTTPSocket from 'core/http/http_socket';\nimport SocketHooks from 'core/http/socket_hooks';\nimport RequestHooks from 'core/http/request_hooks';\nimport streamingHooks from 'core/http/http_streaming_socket';\nimport pollingHooks from 'core/http/http_polling_socket';\nimport xhrHooks from './http_xhr_request';\nimport HTTPFactory from 'core/http/http_factory';\n\nvar HTTP: HTTPFactory = {\n createStreamingSocket(url: string): HTTPSocket {\n return this.createSocket(streamingHooks, url);\n },\n\n createPollingSocket(url: string): HTTPSocket {\n return this.createSocket(pollingHooks, url);\n },\n\n createSocket(hooks: SocketHooks, url: string): HTTPSocket {\n return new HTTPSocket(hooks, url);\n },\n\n createXHR(method: string, url: string): HTTPRequest {\n return this.createRequest(xhrHooks, method, url);\n },\n\n createRequest(hooks: RequestHooks, method: string, url: string): HTTPRequest {\n return new HTTPRequest(hooks, method, url);\n }\n};\n\nexport default HTTP;\n","import { default as EventsDispatcher } from 'core/events/dispatcher';\nimport Reachability from 'core/reachability';\n\nexport class NetInfo extends EventsDispatcher implements Reachability {\n isOnline(): boolean {\n return true;\n }\n}\n\nexport var Network = new NetInfo();\n","import AbstractRuntime from 'runtimes/interface';\nimport { AuthTransport } from 'core/auth/auth_transports';\nimport {\n AuthRequestType,\n AuthTransportCallback,\n InternalAuthOptions\n} from 'core/auth/options';\nimport { HTTPAuthError } from 'core/errors';\n\nvar fetchAuth: AuthTransport = function(\n context: AbstractRuntime,\n query: string,\n authOptions: InternalAuthOptions,\n authRequestType: AuthRequestType,\n callback: AuthTransportCallback\n) {\n var headers = new Headers();\n headers.set('Content-Type', 'application/x-www-form-urlencoded');\n\n for (var headerName in authOptions.headers) {\n headers.set(headerName, authOptions.headers[headerName]);\n }\n\n if (authOptions.headersProvider != null) {\n const dynamicHeaders = authOptions.headersProvider();\n for (var headerName in dynamicHeaders) {\n headers.set(headerName, dynamicHeaders[headerName]);\n }\n }\n\n var body = query;\n var request = new Request(authOptions.endpoint, {\n headers,\n body,\n credentials: 'same-origin',\n method: 'POST'\n });\n\n return fetch(request)\n .then(response => {\n let { status } = response;\n if (status === 200) {\n // manually parse the json so we can provide a more helpful error in\n // failure case\n return response.text();\n }\n throw new HTTPAuthError(\n status,\n `Could not get ${authRequestType.toString()} info from your auth endpoint, status: ${status}`\n );\n })\n .then(data => {\n let parsedData;\n try {\n parsedData = JSON.parse(data);\n } catch (e) {\n throw new HTTPAuthError(\n 200,\n `JSON returned from ${authRequestType.toString()} endpoint was invalid, yet status code was 200. Data was: ${data}`\n );\n }\n callback(null, parsedData);\n })\n .catch(err => {\n callback(err, null);\n });\n};\n\nexport default fetchAuth;\n","import Logger from 'core/logger';\nimport TimelineSender from 'core/timeline/timeline_sender';\nimport * as Collections from 'core/utils/collections';\nimport Util from 'core/util';\nimport Runtime from 'runtime';\nimport TimelineTransport from 'core/timeline/timeline_transport';\n\nvar getAgent = function(sender: TimelineSender, useTLS: boolean) {\n return function(data: any, callback: Function) {\n var scheme = 'http' + (useTLS ? 's' : '') + '://';\n var url =\n scheme + (sender.host || sender.options.host) + sender.options.path;\n var query = Collections.buildQueryString(data);\n url += '/' + 2 + '?' + query;\n\n fetch(url)\n .then(response => {\n if (response.status !== 200) {\n throw `received ${response.status} from stats.pusher.com`;\n }\n return response.json();\n })\n .then(({ host }) => {\n if (host) {\n sender.host = host;\n }\n })\n .catch(err => {\n Logger.debug('TimelineSender Error: ', err);\n });\n };\n};\n\nvar fetchTimeline = {\n name: 'xhr',\n getAgent\n};\n\nexport default fetchTimeline;\n","import Isomorphic from 'isomorphic/runtime';\nimport Runtime from '../interface';\nimport { Network } from './net_info';\nimport fetchAuth from './auth/fetch_auth';\nimport { AuthTransports } from 'core/auth/auth_transports';\nimport fetchTimeline from './timeline/fetch_timeline';\n\n// Very verbose but until unavoidable until\n// TypeScript 2.1, when spread attributes will be\n// supported\nconst {\n getDefaultStrategy,\n Transports,\n setup,\n getProtocol,\n isXHRSupported,\n getLocalStorage,\n createXHR,\n createWebSocket,\n addUnloadListener,\n removeUnloadListener,\n transportConnectionInitializer,\n createSocketRequest,\n HTTPFactory\n} = Isomorphic;\n\nconst Worker: Runtime = {\n getDefaultStrategy,\n Transports,\n setup,\n getProtocol,\n isXHRSupported,\n getLocalStorage,\n createXHR,\n createWebSocket,\n addUnloadListener,\n removeUnloadListener,\n transportConnectionInitializer,\n createSocketRequest,\n HTTPFactory,\n\n TimelineTransport: fetchTimeline,\n\n getAuthorizers(): AuthTransports {\n return { ajax: fetchAuth };\n },\n\n getWebSocketAPI() {\n return WebSocket;\n },\n\n getXHRAPI() {\n return XMLHttpRequest;\n },\n\n getNetwork() {\n return Network;\n },\n\n randomInt(max: number): number {\n /**\n * Return values in the range of [0, 1[\n */\n const random = function() {\n const crypto = globalThis.crypto || globalThis['msCrypto'];\n const random = crypto.getRandomValues(new Uint32Array(1))[0];\n\n return random / 2 ** 32;\n };\n\n return Math.floor(random() * max);\n }\n};\n\nexport default Worker;\n","enum TimelineLevel {\n ERROR = 3,\n INFO = 6,\n DEBUG = 7\n}\n\nexport default TimelineLevel;\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport { default as Level } from './level';\n\nexport interface TimelineOptions {\n level?: Level;\n limit?: number;\n version?: string;\n cluster?: string;\n features?: string[];\n params?: any;\n}\n\nexport default class Timeline {\n key: string;\n session: number;\n events: any[];\n options: TimelineOptions;\n sent: number;\n uniqueID: number;\n\n constructor(key: string, session: number, options: TimelineOptions) {\n this.key = key;\n this.session = session;\n this.events = [];\n this.options = options || {};\n this.sent = 0;\n this.uniqueID = 0;\n }\n\n log(level, event) {\n if (level <= this.options.level) {\n this.events.push(\n Collections.extend({}, event, { timestamp: Util.now() })\n );\n if (this.options.limit && this.events.length > this.options.limit) {\n this.events.shift();\n }\n }\n }\n\n error(event) {\n this.log(Level.ERROR, event);\n }\n\n info(event) {\n this.log(Level.INFO, event);\n }\n\n debug(event) {\n this.log(Level.DEBUG, event);\n }\n\n isEmpty() {\n return this.events.length === 0;\n }\n\n send(sendfn, callback) {\n var data = Collections.extend(\n {\n session: this.session,\n bundle: this.sent + 1,\n key: this.key,\n lib: 'js',\n version: this.options.version,\n cluster: this.options.cluster,\n features: this.options.features,\n timeline: this.events\n },\n this.options.params\n );\n\n this.events = [];\n sendfn(data, (error, result) => {\n if (!error) {\n this.sent++;\n }\n if (callback) {\n callback(error, result);\n }\n });\n\n return true;\n }\n\n generateUniqueID(): number {\n this.uniqueID++;\n return this.uniqueID;\n }\n}\n","import Factory from '../utils/factory';\nimport Util from '../util';\nimport * as Errors from '../errors';\nimport * as Collections from '../utils/collections';\nimport Strategy from './strategy';\nimport Transport from '../transports/transport';\nimport StrategyOptions from './strategy_options';\nimport Handshake from '../connection/handshake';\n\n/** Provides a strategy interface for transports.\n *\n * @param {String} name\n * @param {Number} priority\n * @param {Class} transport\n * @param {Object} options\n */\nexport default class TransportStrategy implements Strategy {\n name: string;\n priority: number;\n transport: Transport;\n options: StrategyOptions;\n\n constructor(\n name: string,\n priority: number,\n transport: Transport,\n options: StrategyOptions\n ) {\n this.name = name;\n this.priority = priority;\n this.transport = transport;\n this.options = options || {};\n }\n\n /** Returns whether the transport is supported in the browser.\n *\n * @returns {Boolean}\n */\n isSupported(): boolean {\n return this.transport.isSupported({\n useTLS: this.options.useTLS\n });\n }\n\n /** Launches a connection attempt and returns a strategy runner.\n *\n * @param {Function} callback\n * @return {Object} strategy runner\n */\n connect(minPriority: number, callback: Function) {\n if (!this.isSupported()) {\n return failAttempt(new Errors.UnsupportedStrategy(), callback);\n } else if (this.priority < minPriority) {\n return failAttempt(new Errors.TransportPriorityTooLow(), callback);\n }\n\n var connected = false;\n var transport = this.transport.createConnection(\n this.name,\n this.priority,\n this.options.key,\n this.options\n );\n var handshake = null;\n\n var onInitialized = function() {\n transport.unbind('initialized', onInitialized);\n transport.connect();\n };\n var onOpen = function() {\n handshake = Factory.createHandshake(transport, function(result) {\n connected = true;\n unbindListeners();\n callback(null, result);\n });\n };\n var onError = function(error) {\n unbindListeners();\n callback(error);\n };\n var onClosed = function() {\n unbindListeners();\n var serializedTransport;\n\n // The reason for this try/catch block is that on React Native\n // the WebSocket object is circular. Therefore transport.socket will\n // throw errors upon stringification. Collections.safeJSONStringify\n // discards circular references when serializing.\n serializedTransport = Collections.safeJSONStringify(transport);\n callback(new Errors.TransportClosed(serializedTransport));\n };\n\n var unbindListeners = function() {\n transport.unbind('initialized', onInitialized);\n transport.unbind('open', onOpen);\n transport.unbind('error', onError);\n transport.unbind('closed', onClosed);\n };\n\n transport.bind('initialized', onInitialized);\n transport.bind('open', onOpen);\n transport.bind('error', onError);\n transport.bind('closed', onClosed);\n\n // connect will be called automatically after initialization\n transport.initialize();\n\n return {\n abort: () => {\n if (connected) {\n return;\n }\n unbindListeners();\n if (handshake) {\n handshake.close();\n } else {\n transport.close();\n }\n },\n forceMinPriority: p => {\n if (connected) {\n return;\n }\n if (this.priority < p) {\n if (handshake) {\n handshake.close();\n } else {\n transport.close();\n }\n }\n }\n };\n }\n}\n\nfunction failAttempt(error: Error, callback: Function) {\n Util.defer(function() {\n callback(error);\n });\n return {\n abort: function() {},\n forceMinPriority: function() {}\n };\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport TransportManager from '../transports/transport_manager';\nimport * as Errors from '../errors';\nimport Strategy from './strategy';\nimport TransportStrategy from './transport_strategy';\nimport StrategyOptions from '../strategies/strategy_options';\nimport { Config } from '../config';\nimport Runtime from 'runtime';\n\nconst { Transports } = Runtime;\n\nexport var defineTransport = function(\n config: Config,\n name: string,\n type: string,\n priority: number,\n options: StrategyOptions,\n manager?: TransportManager\n): Strategy {\n var transportClass = Transports[type];\n if (!transportClass) {\n throw new Errors.UnsupportedTransport(type);\n }\n\n var enabled =\n (!config.enabledTransports ||\n Collections.arrayIndexOf(config.enabledTransports, name) !== -1) &&\n (!config.disabledTransports ||\n Collections.arrayIndexOf(config.disabledTransports, name) === -1);\n\n var transport;\n if (enabled) {\n options = Object.assign(\n { ignoreNullOrigin: config.ignoreNullOrigin },\n options\n );\n\n transport = new TransportStrategy(\n name,\n priority,\n manager ? manager.getAssistant(transportClass) : transportClass,\n options\n );\n } else {\n transport = UnsupportedStrategy;\n }\n\n return transport;\n};\n\nvar UnsupportedStrategy: Strategy = {\n isSupported: function() {\n return false;\n },\n connect: function(_, callback) {\n var deferred = Util.defer(function() {\n callback(new Errors.UnsupportedStrategy());\n });\n return {\n abort: function() {\n deferred.ensureAborted();\n },\n forceMinPriority: function() {}\n };\n }\n};\n","export enum AuthRequestType {\n UserAuthentication = 'user-authentication',\n ChannelAuthorization = 'channel-authorization'\n}\n\nexport interface ChannelAuthorizationData {\n auth: string;\n channel_data?: string;\n shared_secret?: string;\n}\n\nexport type ChannelAuthorizationCallback = (\n error: Error | null,\n authData: ChannelAuthorizationData | null\n) => void;\n\nexport interface ChannelAuthorizationRequestParams {\n socketId: string;\n channelName: string;\n}\n\nexport interface ChannelAuthorizationHandler {\n (\n params: ChannelAuthorizationRequestParams,\n callback: ChannelAuthorizationCallback\n ): void;\n}\n\nexport interface UserAuthenticationData {\n auth: string;\n user_data: string;\n}\n\nexport type UserAuthenticationCallback = (\n error: Error | null,\n authData: UserAuthenticationData | null\n) => void;\n\nexport interface UserAuthenticationRequestParams {\n socketId: string;\n}\n\nexport interface UserAuthenticationHandler {\n (\n params: UserAuthenticationRequestParams,\n callback: UserAuthenticationCallback\n ): void;\n}\n\nexport type AuthTransportCallback =\n | ChannelAuthorizationCallback\n | UserAuthenticationCallback;\n\nexport interface AuthOptionsT {\n transport: 'ajax' | 'jsonp';\n endpoint: string;\n params?: any;\n headers?: any;\n paramsProvider?: () => any;\n headersProvider?: () => any;\n customHandler?: AuthHandler;\n}\n\nexport declare type UserAuthenticationOptions = AuthOptionsT<\n UserAuthenticationHandler\n>;\nexport declare type ChannelAuthorizationOptions = AuthOptionsT<\n ChannelAuthorizationHandler\n>;\n\nexport interface InternalAuthOptions {\n transport: 'ajax' | 'jsonp';\n endpoint: string;\n params?: any;\n headers?: any;\n paramsProvider?: () => any;\n headersProvider?: () => any;\n}\n","import {\n UserAuthenticationCallback,\n InternalAuthOptions,\n UserAuthenticationHandler,\n UserAuthenticationRequestParams,\n AuthRequestType\n} from './options';\n\nimport Runtime from 'runtime';\n\nconst composeChannelQuery = (\n params: UserAuthenticationRequestParams,\n authOptions: InternalAuthOptions\n) => {\n var query = 'socket_id=' + encodeURIComponent(params.socketId);\n\n for (var key in authOptions.params) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(authOptions.params[key]);\n }\n\n if (authOptions.paramsProvider != null) {\n let dynamicParams = authOptions.paramsProvider();\n for (var key in dynamicParams) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(dynamicParams[key]);\n }\n }\n\n return query;\n};\n\nconst UserAuthenticator = (\n authOptions: InternalAuthOptions\n): UserAuthenticationHandler => {\n if (typeof Runtime.getAuthorizers()[authOptions.transport] === 'undefined') {\n throw `'${authOptions.transport}' is not a recognized auth transport`;\n }\n\n return (\n params: UserAuthenticationRequestParams,\n callback: UserAuthenticationCallback\n ) => {\n const query = composeChannelQuery(params, authOptions);\n\n Runtime.getAuthorizers()[authOptions.transport](\n Runtime,\n query,\n authOptions,\n AuthRequestType.UserAuthentication,\n callback\n );\n };\n};\n\nexport default UserAuthenticator;\n","import {\n AuthRequestType,\n InternalAuthOptions,\n ChannelAuthorizationHandler,\n ChannelAuthorizationRequestParams,\n ChannelAuthorizationCallback\n} from './options';\n\nimport Runtime from 'runtime';\n\nconst composeChannelQuery = (\n params: ChannelAuthorizationRequestParams,\n authOptions: InternalAuthOptions\n) => {\n var query = 'socket_id=' + encodeURIComponent(params.socketId);\n\n query += '&channel_name=' + encodeURIComponent(params.channelName);\n\n for (var key in authOptions.params) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(authOptions.params[key]);\n }\n\n if (authOptions.paramsProvider != null) {\n let dynamicParams = authOptions.paramsProvider();\n for (var key in dynamicParams) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(dynamicParams[key]);\n }\n }\n\n return query;\n};\n\nconst ChannelAuthorizer = (\n authOptions: InternalAuthOptions\n): ChannelAuthorizationHandler => {\n if (typeof Runtime.getAuthorizers()[authOptions.transport] === 'undefined') {\n throw `'${authOptions.transport}' is not a recognized auth transport`;\n }\n\n return (\n params: ChannelAuthorizationRequestParams,\n callback: ChannelAuthorizationCallback\n ) => {\n const query = composeChannelQuery(params, authOptions);\n\n Runtime.getAuthorizers()[authOptions.transport](\n Runtime,\n query,\n authOptions,\n AuthRequestType.ChannelAuthorization,\n callback\n );\n };\n};\n\nexport default ChannelAuthorizer;\n","import { Options } from './options';\nimport Defaults from './defaults';\nimport {\n ChannelAuthorizationHandler,\n UserAuthenticationHandler,\n ChannelAuthorizationOptions\n} from './auth/options';\nimport UserAuthenticator from './auth/user_authenticator';\nimport ChannelAuthorizer from './auth/channel_authorizer';\nimport { ChannelAuthorizerProxy } from './auth/deprecated_channel_authorizer';\nimport Runtime from 'runtime';\nimport * as nacl from 'tweetnacl';\n\nexport type AuthTransport = 'ajax' | 'jsonp';\nexport type Transport =\n | 'ws'\n | 'wss'\n | 'xhr_streaming'\n | 'xhr_polling'\n | 'sockjs';\n\nexport interface Config {\n // these are all 'required' config parameters, it's not necessary for the user\n // to set them, but they have configured defaults.\n activityTimeout: number;\n enableStats: boolean;\n httpHost: string;\n httpPath: string;\n httpPort: number;\n httpsPort: number;\n pongTimeout: number;\n statsHost: string;\n unavailableTimeout: number;\n useTLS: boolean;\n wsHost: string;\n wsPath: string;\n wsPort: number;\n wssPort: number;\n userAuthenticator: UserAuthenticationHandler;\n channelAuthorizer: ChannelAuthorizationHandler;\n\n // these are all optional parameters or overrrides. The customer can set these\n // but it's not strictly necessary\n forceTLS?: boolean;\n cluster?: string;\n disabledTransports?: Transport[];\n enabledTransports?: Transport[];\n ignoreNullOrigin?: boolean;\n nacl?: nacl;\n timelineParams?: any;\n}\n\n// getConfig mainly sets the defaults for the options that are not provided\nexport function getConfig(opts: Options, pusher): Config {\n let config: Config = {\n activityTimeout: opts.activityTimeout || Defaults.activityTimeout,\n cluster: opts.cluster,\n httpPath: opts.httpPath || Defaults.httpPath,\n httpPort: opts.httpPort || Defaults.httpPort,\n httpsPort: opts.httpsPort || Defaults.httpsPort,\n pongTimeout: opts.pongTimeout || Defaults.pongTimeout,\n statsHost: opts.statsHost || Defaults.stats_host,\n unavailableTimeout: opts.unavailableTimeout || Defaults.unavailableTimeout,\n wsPath: opts.wsPath || Defaults.wsPath,\n wsPort: opts.wsPort || Defaults.wsPort,\n wssPort: opts.wssPort || Defaults.wssPort,\n\n enableStats: getEnableStatsConfig(opts),\n httpHost: getHttpHost(opts),\n useTLS: shouldUseTLS(opts),\n wsHost: getWebsocketHost(opts),\n\n userAuthenticator: buildUserAuthenticator(opts),\n channelAuthorizer: buildChannelAuthorizer(opts, pusher)\n };\n\n if ('disabledTransports' in opts)\n config.disabledTransports = opts.disabledTransports;\n if ('enabledTransports' in opts)\n config.enabledTransports = opts.enabledTransports;\n if ('ignoreNullOrigin' in opts)\n config.ignoreNullOrigin = opts.ignoreNullOrigin;\n if ('timelineParams' in opts) config.timelineParams = opts.timelineParams;\n if ('nacl' in opts) {\n config.nacl = opts.nacl;\n }\n\n return config;\n}\n\nfunction getHttpHost(opts: Options): string {\n if (opts.httpHost) {\n return opts.httpHost;\n }\n if (opts.cluster) {\n return `sockjs-${opts.cluster}.pusher.com`;\n }\n return Defaults.httpHost;\n}\n\nfunction getWebsocketHost(opts: Options): string {\n if (opts.wsHost) {\n return opts.wsHost;\n }\n return getWebsocketHostFromCluster(opts.cluster);\n}\n\nfunction getWebsocketHostFromCluster(cluster: string): string {\n return `ws-${cluster}.pusher.com`;\n}\n\nfunction shouldUseTLS(opts: Options): boolean {\n if (Runtime.getProtocol() === 'https:') {\n return true;\n } else if (opts.forceTLS === false) {\n return false;\n }\n return true;\n}\n\n// if enableStats is set take the value\n// if disableStats is set take the inverse\n// otherwise default to false\nfunction getEnableStatsConfig(opts: Options): boolean {\n if ('enableStats' in opts) {\n return opts.enableStats;\n }\n if ('disableStats' in opts) {\n return !opts.disableStats;\n }\n return false;\n}\n\nfunction buildUserAuthenticator(opts: Options): UserAuthenticationHandler {\n const userAuthentication = {\n ...Defaults.userAuthentication,\n ...opts.userAuthentication\n };\n if (\n 'customHandler' in userAuthentication &&\n userAuthentication['customHandler'] != null\n ) {\n return userAuthentication['customHandler'];\n }\n\n return UserAuthenticator(userAuthentication);\n}\n\nfunction buildChannelAuth(opts: Options, pusher): ChannelAuthorizationOptions {\n let channelAuthorization: ChannelAuthorizationOptions;\n if ('channelAuthorization' in opts) {\n channelAuthorization = {\n ...Defaults.channelAuthorization,\n ...opts.channelAuthorization\n };\n } else {\n channelAuthorization = {\n transport: opts.authTransport || Defaults.authTransport,\n endpoint: opts.authEndpoint || Defaults.authEndpoint\n };\n if ('auth' in opts) {\n if ('params' in opts.auth) channelAuthorization.params = opts.auth.params;\n if ('headers' in opts.auth)\n channelAuthorization.headers = opts.auth.headers;\n }\n if ('authorizer' in opts)\n channelAuthorization.customHandler = ChannelAuthorizerProxy(\n pusher,\n channelAuthorization,\n opts.authorizer\n );\n }\n return channelAuthorization;\n}\n\nfunction buildChannelAuthorizer(\n opts: Options,\n pusher\n): ChannelAuthorizationHandler {\n const channelAuthorization = buildChannelAuth(opts, pusher);\n if (\n 'customHandler' in channelAuthorization &&\n channelAuthorization['customHandler'] != null\n ) {\n return channelAuthorization['customHandler'];\n }\n\n return ChannelAuthorizer(channelAuthorization);\n}\n","import Channel from '../channels/channel';\nimport {\n ChannelAuthorizationCallback,\n ChannelAuthorizationHandler,\n ChannelAuthorizationRequestParams,\n InternalAuthOptions\n} from './options';\n\nexport interface DeprecatedChannelAuthorizer {\n authorize(socketId: string, callback: ChannelAuthorizationCallback): void;\n}\n\nexport interface ChannelAuthorizerGenerator {\n (\n channel: Channel,\n options: DeprecatedAuthorizerOptions\n ): DeprecatedChannelAuthorizer;\n}\n\nexport interface DeprecatedAuthOptions {\n params?: any;\n headers?: any;\n}\n\nexport interface DeprecatedAuthorizerOptions {\n authTransport: 'ajax' | 'jsonp';\n authEndpoint: string;\n auth?: DeprecatedAuthOptions;\n}\n\nexport const ChannelAuthorizerProxy = (\n pusher,\n authOptions: InternalAuthOptions,\n channelAuthorizerGenerator: ChannelAuthorizerGenerator\n): ChannelAuthorizationHandler => {\n const deprecatedAuthorizerOptions: DeprecatedAuthorizerOptions = {\n authTransport: authOptions.transport,\n authEndpoint: authOptions.endpoint,\n auth: {\n params: authOptions.params,\n headers: authOptions.headers\n }\n };\n return (\n params: ChannelAuthorizationRequestParams,\n callback: ChannelAuthorizationCallback\n ) => {\n const channel = pusher.channel(params.channelName);\n // This line creates a new channel authorizer every time.\n // In the past, this was only done once per channel and reused.\n // We can do that again if we want to keep this behavior intact.\n const channelAuthorizer: DeprecatedChannelAuthorizer = channelAuthorizerGenerator(\n channel,\n deprecatedAuthorizerOptions\n );\n channelAuthorizer.authorize(params.socketId, callback);\n };\n};\n","import Logger from './logger';\nimport Pusher from './pusher';\nimport EventsDispatcher from './events/dispatcher';\n\nexport default class WatchlistFacade extends EventsDispatcher {\n private pusher: Pusher;\n\n public constructor(pusher: Pusher) {\n super(function(eventName, data) {\n Logger.debug(`No callbacks on watchlist events for ${eventName}`);\n });\n\n this.pusher = pusher;\n this.bindWatchlistInternalEvent();\n }\n\n handleEvent(pusherEvent) {\n pusherEvent.data.events.forEach(watchlistEvent => {\n this.emit(watchlistEvent.name, watchlistEvent);\n });\n }\n\n private bindWatchlistInternalEvent() {\n this.pusher.connection.bind('message', pusherEvent => {\n var eventName = pusherEvent.event;\n if (eventName === 'pusher_internal:watchlist_events') {\n this.handleEvent(pusherEvent);\n }\n });\n }\n}\n","function flatPromise() {\n let resolve, reject;\n const promise = new Promise((res, rej) => {\n resolve = res;\n reject = rej;\n });\n return { promise, resolve, reject };\n}\n\nexport default flatPromise;\n","import Pusher from './pusher';\nimport Logger from './logger';\nimport {\n UserAuthenticationData,\n UserAuthenticationCallback\n} from './auth/options';\nimport Channel from './channels/channel';\nimport WatchlistFacade from './watchlist';\nimport EventsDispatcher from './events/dispatcher';\nimport flatPromise from './utils/flat_promise';\n\nexport default class UserFacade extends EventsDispatcher {\n pusher: Pusher;\n signin_requested: boolean = false;\n user_data: any = null;\n serverToUserChannel: Channel = null;\n signinDonePromise: Promise = null;\n watchlist: WatchlistFacade;\n private _signinDoneResolve: Function = null;\n\n public constructor(pusher: Pusher) {\n super(function(eventName, data) {\n Logger.debug('No callbacks on user for ' + eventName);\n });\n this.pusher = pusher;\n this.pusher.connection.bind('state_change', ({ previous, current }) => {\n if (previous !== 'connected' && current === 'connected') {\n this._signin();\n }\n if (previous === 'connected' && current !== 'connected') {\n this._cleanup();\n this._newSigninPromiseIfNeeded();\n }\n });\n\n this.watchlist = new WatchlistFacade(pusher);\n\n this.pusher.connection.bind('message', event => {\n var eventName = event.event;\n if (eventName === 'pusher:signin_success') {\n this._onSigninSuccess(event.data);\n }\n if (\n this.serverToUserChannel &&\n this.serverToUserChannel.name === event.channel\n ) {\n this.serverToUserChannel.handleEvent(event);\n }\n });\n }\n\n public signin() {\n if (this.signin_requested) {\n return;\n }\n\n this.signin_requested = true;\n this._signin();\n }\n\n private _signin() {\n if (!this.signin_requested) {\n return;\n }\n\n this._newSigninPromiseIfNeeded();\n\n if (this.pusher.connection.state !== 'connected') {\n // Signin will be attempted when the connection is connected\n return;\n }\n\n this.pusher.config.userAuthenticator(\n {\n socketId: this.pusher.connection.socket_id\n },\n this._onAuthorize\n );\n }\n\n private _onAuthorize: UserAuthenticationCallback = (\n err,\n authData: UserAuthenticationData\n ) => {\n if (err) {\n Logger.warn(`Error during signin: ${err}`);\n this._cleanup();\n return;\n }\n\n this.pusher.send_event('pusher:signin', {\n auth: authData.auth,\n user_data: authData.user_data\n });\n\n // Later when we get pusher:singin_success event, the user will be marked as signed in\n };\n\n private _onSigninSuccess(data: any) {\n try {\n this.user_data = JSON.parse(data.user_data);\n } catch (e) {\n Logger.error(`Failed parsing user data after signin: ${data.user_data}`);\n this._cleanup();\n return;\n }\n\n if (typeof this.user_data.id !== 'string' || this.user_data.id === '') {\n Logger.error(\n `user_data doesn't contain an id. user_data: ${this.user_data}`\n );\n this._cleanup();\n return;\n }\n\n // Signin succeeded\n this._signinDoneResolve();\n this._subscribeChannels();\n }\n\n private _subscribeChannels() {\n const ensure_subscribed = channel => {\n if (channel.subscriptionPending && channel.subscriptionCancelled) {\n channel.reinstateSubscription();\n } else if (\n !channel.subscriptionPending &&\n this.pusher.connection.state === 'connected'\n ) {\n channel.subscribe();\n }\n };\n\n this.serverToUserChannel = new Channel(\n `#server-to-user-${this.user_data.id}`,\n this.pusher\n );\n this.serverToUserChannel.bind_global((eventName, data) => {\n if (\n eventName.indexOf('pusher_internal:') === 0 ||\n eventName.indexOf('pusher:') === 0\n ) {\n // ignore internal events\n return;\n }\n this.emit(eventName, data);\n });\n ensure_subscribed(this.serverToUserChannel);\n }\n\n private _cleanup() {\n this.user_data = null;\n if (this.serverToUserChannel) {\n this.serverToUserChannel.unbind_all();\n this.serverToUserChannel.disconnect();\n this.serverToUserChannel = null;\n }\n\n if (this.signin_requested) {\n // If signin is in progress and cleanup is called,\n // Mark the current signin process as done.\n this._signinDoneResolve();\n }\n }\n\n private _newSigninPromiseIfNeeded() {\n if (!this.signin_requested) {\n return;\n }\n\n // If there is a promise and it is not resolved, return without creating a new one.\n if (this.signinDonePromise && !(this.signinDonePromise as any).done) {\n return;\n }\n\n // This promise is never rejected.\n // It gets resolved when the signin process is done whether it failed or succeeded\n const { promise, resolve, reject: _ } = flatPromise();\n (promise as any).done = false;\n const setDone = () => {\n (promise as any).done = true;\n };\n promise.then(setDone).catch(setDone);\n this.signinDonePromise = promise;\n this._signinDoneResolve = resolve;\n }\n}\n","import AbstractRuntime from '../runtimes/interface';\nimport Runtime from 'runtime';\nimport Util from './util';\nimport * as Collections from './utils/collections';\nimport Channels from './channels/channels';\nimport Channel from './channels/channel';\nimport { default as EventsDispatcher } from './events/dispatcher';\nimport Timeline from './timeline/timeline';\nimport TimelineSender from './timeline/timeline_sender';\nimport TimelineLevel from './timeline/level';\nimport { defineTransport } from './strategies/strategy_builder';\nimport ConnectionManager from './connection/connection_manager';\nimport ConnectionManagerOptions from './connection/connection_manager_options';\nimport { PeriodicTimer } from './utils/timers';\nimport Defaults from './defaults';\nimport * as DefaultConfig from './config';\nimport Logger from './logger';\nimport Factory from './utils/factory';\nimport UrlStore from 'core/utils/url_store';\nimport { Options, validateOptions } from './options';\nimport { Config, getConfig } from './config';\nimport StrategyOptions from './strategies/strategy_options';\nimport UserFacade from './user';\n\nexport default class Pusher {\n /* STATIC PROPERTIES */\n static instances: Pusher[] = [];\n static isReady: boolean = false;\n static logToConsole: boolean = false;\n\n // for jsonp\n static Runtime: AbstractRuntime = Runtime;\n static ScriptReceivers: any = (Runtime).ScriptReceivers;\n static DependenciesReceivers: any = (Runtime).DependenciesReceivers;\n static auth_callbacks: any = (Runtime).auth_callbacks;\n\n static ready() {\n Pusher.isReady = true;\n for (var i = 0, l = Pusher.instances.length; i < l; i++) {\n Pusher.instances[i].connect();\n }\n }\n\n static log: (message: any) => void;\n\n private static getClientFeatures(): string[] {\n return Collections.keys(\n Collections.filterObject({ ws: Runtime.Transports.ws }, function(t) {\n return t.isSupported({});\n })\n );\n }\n\n /* INSTANCE PROPERTIES */\n key: string;\n config: Config;\n channels: Channels;\n global_emitter: EventsDispatcher;\n sessionID: number;\n timeline: Timeline;\n timelineSender: TimelineSender;\n connection: ConnectionManager;\n timelineSenderTimer: PeriodicTimer;\n user: UserFacade;\n constructor(app_key: string, options: Options) {\n checkAppKey(app_key);\n validateOptions(options);\n this.key = app_key;\n this.config = getConfig(options, this);\n\n this.channels = Factory.createChannels();\n this.global_emitter = new EventsDispatcher();\n this.sessionID = Runtime.randomInt(1000000000);\n\n this.timeline = new Timeline(this.key, this.sessionID, {\n cluster: this.config.cluster,\n features: Pusher.getClientFeatures(),\n params: this.config.timelineParams || {},\n limit: 50,\n level: TimelineLevel.INFO,\n version: Defaults.VERSION\n });\n if (this.config.enableStats) {\n this.timelineSender = Factory.createTimelineSender(this.timeline, {\n host: this.config.statsHost,\n path: '/timeline/v2/' + Runtime.TimelineTransport.name\n });\n }\n\n var getStrategy = (options: StrategyOptions) => {\n return Runtime.getDefaultStrategy(this.config, options, defineTransport);\n };\n\n this.connection = Factory.createConnectionManager(this.key, {\n getStrategy: getStrategy,\n timeline: this.timeline,\n activityTimeout: this.config.activityTimeout,\n pongTimeout: this.config.pongTimeout,\n unavailableTimeout: this.config.unavailableTimeout,\n useTLS: Boolean(this.config.useTLS)\n });\n\n this.connection.bind('connected', () => {\n this.subscribeAll();\n if (this.timelineSender) {\n this.timelineSender.send(this.connection.isUsingTLS());\n }\n });\n\n this.connection.bind('message', event => {\n var eventName = event.event;\n var internal = eventName.indexOf('pusher_internal:') === 0;\n if (event.channel) {\n var channel = this.channel(event.channel);\n if (channel) {\n channel.handleEvent(event);\n }\n }\n // Emit globally [deprecated]\n if (!internal) {\n this.global_emitter.emit(event.event, event.data);\n }\n });\n this.connection.bind('connecting', () => {\n this.channels.disconnect();\n });\n this.connection.bind('disconnected', () => {\n this.channels.disconnect();\n });\n this.connection.bind('error', err => {\n Logger.warn(err);\n });\n\n Pusher.instances.push(this);\n this.timeline.info({ instances: Pusher.instances.length });\n\n this.user = new UserFacade(this);\n\n if (Pusher.isReady) {\n this.connect();\n }\n }\n\n channel(name: string): Channel {\n return this.channels.find(name);\n }\n\n allChannels(): Channel[] {\n return this.channels.all();\n }\n\n connect() {\n this.connection.connect();\n\n if (this.timelineSender) {\n if (!this.timelineSenderTimer) {\n var usingTLS = this.connection.isUsingTLS();\n var timelineSender = this.timelineSender;\n this.timelineSenderTimer = new PeriodicTimer(60000, function() {\n timelineSender.send(usingTLS);\n });\n }\n }\n }\n\n disconnect() {\n this.connection.disconnect();\n\n if (this.timelineSenderTimer) {\n this.timelineSenderTimer.ensureAborted();\n this.timelineSenderTimer = null;\n }\n }\n\n bind(event_name: string, callback: Function, context?: any): Pusher {\n this.global_emitter.bind(event_name, callback, context);\n return this;\n }\n\n unbind(event_name?: string, callback?: Function, context?: any): Pusher {\n this.global_emitter.unbind(event_name, callback, context);\n return this;\n }\n\n bind_global(callback: Function): Pusher {\n this.global_emitter.bind_global(callback);\n return this;\n }\n\n unbind_global(callback?: Function): Pusher {\n this.global_emitter.unbind_global(callback);\n return this;\n }\n\n unbind_all(callback?: Function): Pusher {\n this.global_emitter.unbind_all();\n return this;\n }\n\n subscribeAll() {\n var channelName;\n for (channelName in this.channels.channels) {\n if (this.channels.channels.hasOwnProperty(channelName)) {\n this.subscribe(channelName);\n }\n }\n }\n\n subscribe(channel_name: string) {\n var channel = this.channels.add(channel_name, this);\n if (channel.subscriptionPending && channel.subscriptionCancelled) {\n channel.reinstateSubscription();\n } else if (\n !channel.subscriptionPending &&\n this.connection.state === 'connected'\n ) {\n channel.subscribe();\n }\n return channel;\n }\n\n unsubscribe(channel_name: string) {\n var channel = this.channels.find(channel_name);\n if (channel && channel.subscriptionPending) {\n channel.cancelSubscription();\n } else {\n channel = this.channels.remove(channel_name);\n if (channel && channel.subscribed) {\n channel.unsubscribe();\n }\n }\n }\n\n send_event(event_name: string, data: any, channel?: string) {\n return this.connection.send_event(event_name, data, channel);\n }\n\n shouldUseTLS(): boolean {\n return this.config.useTLS;\n }\n\n signin() {\n this.user.signin();\n }\n}\n\nfunction checkAppKey(key) {\n if (key === null || key === undefined) {\n throw 'You must pass your app key when you instantiate Pusher.';\n }\n}\n\nRuntime.setup(Pusher);\n","import ConnectionManager from './connection/connection_manager';\nimport {\n ChannelAuthorizationOptions,\n UserAuthenticationOptions\n} from './auth/options';\nimport {\n ChannelAuthorizerGenerator,\n DeprecatedAuthOptions\n} from './auth/deprecated_channel_authorizer';\nimport { AuthTransport, Transport } from './config';\nimport * as nacl from 'tweetnacl';\nimport Logger from './logger';\n\nexport interface Options {\n activityTimeout?: number;\n\n auth?: DeprecatedAuthOptions; // DEPRECATED use channelAuthorization instead\n authEndpoint?: string; // DEPRECATED use channelAuthorization instead\n authTransport?: AuthTransport; // DEPRECATED use channelAuthorization instead\n authorizer?: ChannelAuthorizerGenerator; // DEPRECATED use channelAuthorization instead\n\n channelAuthorization?: ChannelAuthorizationOptions;\n userAuthentication?: UserAuthenticationOptions;\n\n cluster: string;\n enableStats?: boolean;\n disableStats?: boolean;\n disabledTransports?: Transport[];\n enabledTransports?: Transport[];\n forceTLS?: boolean;\n httpHost?: string;\n httpPath?: string;\n httpPort?: number;\n httpsPort?: number;\n ignoreNullOrigin?: boolean;\n nacl?: nacl;\n pongTimeout?: number;\n statsHost?: string;\n timelineParams?: any;\n unavailableTimeout?: number;\n wsHost?: string;\n wsPath?: string;\n wsPort?: number;\n wssPort?: number;\n}\n\nexport function validateOptions(options) {\n if (options == null) {\n throw 'You must pass an options object';\n }\n if (options.cluster == null) {\n throw 'Options object must provide a cluster';\n }\n if ('disableStats' in options) {\n Logger.warn(\n 'The disableStats option is deprecated in favor of enableStats'\n );\n }\n}\n"],"sourceRoot":""} \ No newline at end of file +{"version":3,"sources":["webpack://Pusher/webpack/universalModuleDefinition","webpack://Pusher/webpack/bootstrap","webpack://Pusher/./node_modules/@stablelib/base64/base64.ts","webpack://Pusher/./node_modules/@stablelib/utf8/utf8.ts","webpack://Pusher/./src/core/pusher.js","webpack://Pusher/./src/core/base64.ts","webpack://Pusher/./src/core/utils/timers/abstract_timer.ts","webpack://Pusher/./src/core/utils/timers/index.ts","webpack://Pusher/./src/core/util.ts","webpack://Pusher/./src/core/utils/collections.ts","webpack://Pusher/./src/core/defaults.ts","webpack://Pusher/./src/core/transports/url_schemes.ts","webpack://Pusher/./src/core/events/callback_registry.ts","webpack://Pusher/./src/core/events/dispatcher.ts","webpack://Pusher/./src/core/logger.ts","webpack://Pusher/./src/core/transports/transport_connection.ts","webpack://Pusher/./src/core/transports/transport.ts","webpack://Pusher/./src/runtimes/isomorphic/transports/transports.ts","webpack://Pusher/./src/core/transports/assistant_to_the_transport_manager.ts","webpack://Pusher/./src/core/connection/protocol/protocol.ts","webpack://Pusher/./src/core/connection/connection.ts","webpack://Pusher/./src/core/connection/handshake/index.ts","webpack://Pusher/./src/core/timeline/timeline_sender.ts","webpack://Pusher/./src/core/errors.ts","webpack://Pusher/./src/core/utils/url_store.ts","webpack://Pusher/./src/core/channels/channel.ts","webpack://Pusher/./src/core/channels/private_channel.ts","webpack://Pusher/./src/core/channels/members.ts","webpack://Pusher/./src/core/channels/presence_channel.ts","webpack://Pusher/./src/core/channels/encrypted_channel.ts","webpack://Pusher/./src/core/connection/connection_manager.ts","webpack://Pusher/./src/core/channels/channels.ts","webpack://Pusher/./src/core/utils/factory.ts","webpack://Pusher/./src/core/transports/transport_manager.ts","webpack://Pusher/./src/core/strategies/sequential_strategy.ts","webpack://Pusher/./src/core/strategies/best_connected_ever_strategy.ts","webpack://Pusher/./src/core/strategies/websocket_prioritized_cached_strategy.ts","webpack://Pusher/./src/core/strategies/delayed_strategy.ts","webpack://Pusher/./src/core/strategies/if_strategy.ts","webpack://Pusher/./src/core/strategies/first_connected_strategy.ts","webpack://Pusher/./src/runtimes/isomorphic/default_strategy.ts","webpack://Pusher/./src/core/http/http_request.ts","webpack://Pusher/./src/core/http/state.ts","webpack://Pusher/./src/core/http/http_socket.ts","webpack://Pusher/./src/core/http/http_streaming_socket.ts","webpack://Pusher/./src/core/http/http_polling_socket.ts","webpack://Pusher/./src/runtimes/isomorphic/http/http_xhr_request.ts","webpack://Pusher/./src/runtimes/isomorphic/runtime.ts","webpack://Pusher/./src/runtimes/isomorphic/transports/transport_connection_initializer.ts","webpack://Pusher/./src/runtimes/isomorphic/http/http.ts","webpack://Pusher/./src/runtimes/worker/net_info.ts","webpack://Pusher/./src/runtimes/worker/auth/fetch_auth.ts","webpack://Pusher/./src/runtimes/worker/timeline/fetch_timeline.ts","webpack://Pusher/./src/runtimes/worker/runtime.ts","webpack://Pusher/./src/core/timeline/level.ts","webpack://Pusher/./src/core/timeline/timeline.ts","webpack://Pusher/./src/core/strategies/transport_strategy.ts","webpack://Pusher/./src/core/strategies/strategy_builder.ts","webpack://Pusher/./src/core/auth/options.ts","webpack://Pusher/./src/core/auth/user_authenticator.ts","webpack://Pusher/./src/core/auth/channel_authorizer.ts","webpack://Pusher/./src/core/config.ts","webpack://Pusher/./src/core/auth/deprecated_channel_authorizer.ts","webpack://Pusher/./src/core/watchlist.ts","webpack://Pusher/./src/core/utils/flat_promise.ts","webpack://Pusher/./src/core/user.ts","webpack://Pusher/./src/core/pusher.ts","webpack://Pusher/./src/core/options.ts"],"names":["root","factory","exports","module","define","amd","this","installedModules","__webpack_require__","moduleId","i","l","modules","call","m","c","d","name","getter","o","Object","defineProperty","enumerable","get","r","Symbol","toStringTag","value","t","mode","__esModule","ns","create","key","bind","n","object","property","prototype","hasOwnProperty","p","s","_paddingCharacter","encodedLength","length","encode","data","out","_encodeByte","left","maxDecodedLength","decodedLength","_getPaddingLength","decode","Uint8Array","paddingLength","op","haveBad","v0","v1","v2","v3","_decodeChar","charCodeAt","Error","b","result","String","fromCharCode","Coder","stdCoder","URLSafeCoder","urlSafeCoder","INVALID_UTF8","arr","pos","chars","min","n1","n2","n3","push","join","default","b64chars","b64tab","charAt","cb_utob","cc","utob","u","replace","cb_encode","ccc","padlen","ord","btoa","set","clear","delay","callback","timer","clearTimeout","clearInterval","super","setTimeout","setInterval","now","Date","valueOf","defer","args","boundArguments","Array","slice","arguments","apply","concat","extend","target","sources","extensions","constructor","stringify","safeJSONStringify","arrayIndexOf","array","item","nativeIndexOf","indexOf","objectApply","f","keys","_","context","map","filter","test","filterObject","Boolean","any","encodeParamsObject","encodeURIComponent","toString","buildQueryString","params","undefined","method","source","JSON","e","objects","paths","derez","path","nu","$ref","VERSION","PROTOCOL","wsPort","wssPort","wsPath","httpHost","httpPort","httpsPort","httpPath","stats_host","authEndpoint","authTransport","activityTimeout","pongTimeout","unavailableTimeout","userAuthentication","endpoint","transport","channelAuthorization","cdn_http","cdn_https","dependency_suffix","getGenericURL","baseScheme","useTLS","hostTLS","hostNonTLS","getGenericPath","queryString","ws","getInitial","http","_callbacks","prefix","prefixedEventName","fn","names","removeCallback","removeAllCallbacks","binding","failThrough","callbacks","global_callbacks","eventName","add","remove","unbind","unbind_global","metadata","globalLog","message","console","log","globalLogWarn","globalLogError","warn","error","defaultLoggingFunction","logToConsole","hooks","priority","options","initialize","transportConnectionInitializer","state","timeline","id","generateUniqueID","handlesActivityChecks","supportsPing","socket","url","urls","getSocket","onError","changeState","bindListeners","debug","close","send","ping","beforeOpen","getPath","onopen","emit","type","buildTimelineMessage","closeEvent","code","reason","wasClean","unbindListeners","onOpen","onerror","onclose","onClose","onmessage","onMessage","onactivity","onActivity","info","cid","environment","isSupported","WSTransport","isInitialized","getWebSocketAPI","createWebSocket","httpConfiguration","streamingConfiguration","HTTPFactory","createStreamingSocket","pollingConfiguration","createPollingSocket","xhrConfiguration","isXHRSupported","xhr_streaming","xhr_polling","manager","minPingDelay","maxPingDelay","pingDelay","connection","createConnection","openTimestamp","onClosed","reportDeath","lifespan","Math","max","isAlive","Protocol","decodeMessage","messageEvent","messageData","parse","pusherEventData","pusherEvent","event","channel","user_id","encodeMessage","processHandshake","activity_timeout","action","socket_id","getCloseAction","getCloseError","send_event","listeners","activity","closed","handleCloseEvent","listener","finish","isEmpty","TimelineTransport","getAgent","BadEventName","msg","setPrototypeOf","BadChannelName","TransportPriorityTooLow","TransportClosed","UnsupportedFeature","UnsupportedTransport","UnsupportedStrategy","HTTPAuthError","status","urlStore","baseUrl","authenticationEndpoint","authorizationEndpoint","javascriptQuickStart","triggeringClientEvents","encryptedChannelSupport","fullUrl","urlObj","pusher","subscribed","subscriptionPending","subscriptionCancelled","socketId","auth","suffix","handleSubscriptionSucceededEvent","handleSubscriptionCountEvent","unsubscribe","subscription_count","subscriptionCount","authorize","assign","channel_data","config","channelAuthorizer","channelName","reset","members","member","myID","subscriptionData","presence","hash","count","me","memberData","user_info","authData","channelData","setMyID","user","signinDonePromise","user_data","handleInternalEvent","addedMember","addMember","removedMember","removeMember","onSubscription","disconnect","nacl","sharedSecret","handleEncryptedEvent","handleEvent","ciphertext","nonce","cipherText","secretbox","overheadLength","nonceLength","bytes","open","getDataToEmit","raw","usingTLS","errorCallbacks","buildErrorCallbacks","connectionCallbacks","buildConnectionCallbacks","handshakeCallbacks","buildHandshakeCallbacks","Network","getNetwork","netinfo","retryIn","sendActivityCheck","updateStrategy","runner","strategy","updateState","startConnecting","setUnavailableTimer","disconnectInternally","handshake","connect","handshakeError","abortConnecting","abort","clearRetryTimer","clearUnavailableTimer","abandonConnection","getStrategy","round","retryTimer","ensureAborted","unavailableTimer","stopActivityCheck","activityTimer","pong_timed_out","resetActivityCheck","shouldRetry","connected","Infinity","setConnection","withErrorEmitted","tls_only","refused","backoff","retry","newState","previousState","newStateDescription","previous","current","channels","createEncryptedChannel","errMsg","createPrivateChannel","createPresenceChannel","createChannel","values","createChannels","createConnectionManager","createTimelineSender","createHandshake","createAssistantToTheTransportManager","livesLeft","lives","strategies","loop","failFast","timeout","timeoutLimit","minPriority","tryNextStrategy","tryStrategy","forceMinPriority","isRunning","callbackBuilder","runners","rs","abortRunner","allRunnersFailed","aborted","transports","ttl","storage","getLocalStorage","serializedCache","getTransportCacheKey","flushTransportCache","fetchTransportCache","cacheSkipCount","timestamp","includes","cached","latency","startTimestamp","pop","cb","storeTransportCache","number","IfStrategy","trueBranch","falseBranch","FirstConnectedStrategy","testSupportsStrategy","baseOptions","defineTransport","definedTransports","defineTransportStrategy","wsStrategy","ws_options","wsHost","wss_options","http_options","timeouts","ws_manager","streaming_manager","ws_transport","wss_transport","xhr_streaming_transport","xhr_polling_transport","ws_loop","wss_loop","streaming_loop","polling_loop","http_loop","payload","position","xhr","getRequest","unloader","addUnloadListener","setRequestHeader","removeUnloadListener","abortRequest","chunk","advanceBuffer","isBufferTooLong","buffer","unreadData","endOfLinePosition","State","autoIncrement","getUniqueURL","separator","randomNumber","randomInt","session","randomString","location","parts","exec","base","getLocation","readyState","CONNECTING","openStream","sendRaw","sendHeartbeat","OPEN","createSocketRequest","start","closeStream","CLOSED","onEvent","onHeartbeat","hostname","urlParts","stream","getReceiveURL","onChunk","onFinished","reconnect","unbind_all","getXHRAPI","onreadystatechange","onprogress","responseText","getDefaultStrategy","Transports","createSocket","createRequest","PusherClass","ready","getClientFeatures","getProtocol","createXHR","query","authOptions","authRequestType","headers","Headers","headerName","headersProvider","dynamicHeaders","body","request","Request","credentials","fetch","then","response","text","parsedData","catch","err","sender","host","json","setup","TimelineLevel","getAuthorizers","ajax","WebSocket","XMLHttpRequest","floor","globalThis","crypto","getRandomValues","Uint32Array","events","sent","uniqueID","level","limit","shift","ERROR","INFO","DEBUG","sendfn","bundle","lib","version","cluster","features","failAttempt","onInitialized","serializedTransport","AuthRequestType","transportClass","enabledTransports","disabledTransports","ignoreNullOrigin","getAssistant","deferred","paramsProvider","dynamicParams","composeChannelQuery","UserAuthentication","ChannelAuthorization","getConfig","opts","statsHost","enableStats","getEnableStatsConfig","getHttpHost","shouldUseTLS","getWebsocketHost","userAuthenticator","buildUserAuthenticator","buildChannelAuthorizer","timelineParams","forceTLS","disableStats","customHandler","channelAuthorizerGenerator","deprecatedAuthorizerOptions","ChannelAuthorizerProxy","authorizer","buildChannelAuth","bindWatchlistInternalEvent","forEach","watchlistEvent","resolve","reject","promise","Promise","res","rej","signin_requested","serverToUserChannel","_signinDoneResolve","_onAuthorize","_cleanup","_signin","_newSigninPromiseIfNeeded","watchlist","_onSigninSuccess","_subscribeChannels","bind_global","reinstateSubscription","subscribe","ensure_subscribed","done","setDone","isReady","instances","app_key","checkAppKey","validateOptions","global_emitter","sessionID","timelineSender","subscribeAll","isUsingTLS","internal","appKey","switchCluster","find","all","timelineSenderTimer","event_name","channel_name","cancelSubscription","signin","Runtime","ScriptReceivers","DependenciesReceivers","auth_callbacks"],"mappings":";;;;;;;CAAA,SAA2CA,EAAMC,GAC1B,iBAAZC,SAA0C,iBAAXC,OACxCA,OAAOD,QAAUD,IACQ,mBAAXG,QAAyBA,OAAOC,IAC9CD,OAAO,GAAIH,GACe,iBAAZC,QACdA,QAAgB,OAAID,IAEpBD,EAAa,OAAIC,IARnB,CASGK,MAAM,WACT,O,YCTE,IAAIC,EAAmB,GAGvB,SAASC,EAAoBC,GAG5B,GAAGF,EAAiBE,GACnB,OAAOF,EAAiBE,GAAUP,QAGnC,IAAIC,EAASI,EAAiBE,GAAY,CACzCC,EAAGD,EACHE,GAAG,EACHT,QAAS,IAUV,OANAU,EAAQH,GAAUI,KAAKV,EAAOD,QAASC,EAAQA,EAAOD,QAASM,GAG/DL,EAAOQ,GAAI,EAGJR,EAAOD,QA0Df,OArDAM,EAAoBM,EAAIF,EAGxBJ,EAAoBO,EAAIR,EAGxBC,EAAoBQ,EAAI,SAASd,EAASe,EAAMC,GAC3CV,EAAoBW,EAAEjB,EAASe,IAClCG,OAAOC,eAAenB,EAASe,EAAM,CAAEK,YAAY,EAAMC,IAAKL,KAKhEV,EAAoBgB,EAAI,SAAStB,GACX,oBAAXuB,QAA0BA,OAAOC,aAC1CN,OAAOC,eAAenB,EAASuB,OAAOC,YAAa,CAAEC,MAAO,WAE7DP,OAAOC,eAAenB,EAAS,aAAc,C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KrB,UAAU6V,GACR,IAAIrZ,EAAUlS,KAAKmb,SAAShP,IAAIof,EAAcvrB,MAS9C,OARIkS,EAAQyC,qBAAuBzC,EAAQ0C,sBACzC1C,EAAQ+X,wBAEP/X,EAAQyC,qBACiB,cAA1B3U,KAAKiR,WAAW1D,OAEhB2E,EAAQgY,YAEHhY,EAGT,YAAYqZ,GACV,IAAIrZ,EAAUlS,KAAKmb,SAASgQ,KAAKI,GAC7BrZ,GAAWA,EAAQyC,oBACrBzC,EAAQsZ,sBAERtZ,EAAUlS,KAAKmb,SAAS/O,OAAOmf,KAChBrZ,EAAQwC,YACrBxC,EAAQgD,cAKd,WAAWoW,EAAoB9oB,EAAW0P,GACxC,OAAOlS,KAAKiR,WAAW0B,WAAW2Y,EAAY9oB,EAAM0P,GAGtD,eACE,OAAOlS,KAAKwV,OAAOzK,OAGrB,SACE/K,KAAKyW,KAAKgV,UAtOL,GAAAlB,UAAsB,GACtB,GAAAD,SAAmB,EACnB,GAAArd,cAAwB,EAGxB,GAAAye,QAA2B,GAC3B,GAAAC,gBAA6B,GAASA,gBACtC,GAAAC,sBAAmC,GAASA,sBAC5C,GAAAC,eAA4B,GAASA,eAVzB,oBAkPrB,GAAQ7G,MAAM","file":"pusher.worker.min.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"Pusher\"] = factory();\n\telse\n\t\troot[\"Pusher\"] = factory();\n})(this, function() {\nreturn "," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 2);\n","// Copyright (C) 2016 Dmitry Chestnykh\n// MIT License. See LICENSE file for details.\n\n/**\n * Package base64 implements Base64 encoding and decoding.\n */\n\n// Invalid character used in decoding to indicate\n// that the character to decode is out of range of\n// alphabet and cannot be decoded.\nconst INVALID_BYTE = 256;\n\n/**\n * Implements standard Base64 encoding.\n *\n * Operates in constant time.\n */\nexport class Coder {\n // TODO(dchest): methods to encode chunk-by-chunk.\n\n constructor(private _paddingCharacter = \"=\") { }\n\n encodedLength(length: number): number {\n if (!this._paddingCharacter) {\n return (length * 8 + 5) / 6 | 0;\n }\n return (length + 2) / 3 * 4 | 0;\n }\n\n encode(data: Uint8Array): string {\n let out = \"\";\n\n let i = 0;\n for (; i < data.length - 2; i += 3) {\n let c = (data[i] << 16) | (data[i + 1] << 8) | (data[i + 2]);\n out += this._encodeByte((c >>> 3 * 6) & 63);\n out += this._encodeByte((c >>> 2 * 6) & 63);\n out += this._encodeByte((c >>> 1 * 6) & 63);\n out += this._encodeByte((c >>> 0 * 6) & 63);\n }\n\n const left = data.length - i;\n if (left > 0) {\n let c = (data[i] << 16) | (left === 2 ? data[i + 1] << 8 : 0);\n out += this._encodeByte((c >>> 3 * 6) & 63);\n out += this._encodeByte((c >>> 2 * 6) & 63);\n if (left === 2) {\n out += this._encodeByte((c >>> 1 * 6) & 63);\n } else {\n out += this._paddingCharacter || \"\";\n }\n out += this._paddingCharacter || \"\";\n }\n\n return out;\n }\n\n maxDecodedLength(length: number): number {\n if (!this._paddingCharacter) {\n return (length * 6 + 7) / 8 | 0;\n }\n return length / 4 * 3 | 0;\n }\n\n decodedLength(s: string): number {\n return this.maxDecodedLength(s.length - this._getPaddingLength(s));\n }\n\n decode(s: string): Uint8Array {\n if (s.length === 0) {\n return new Uint8Array(0);\n }\n const paddingLength = this._getPaddingLength(s);\n const length = s.length - paddingLength;\n const out = new Uint8Array(this.maxDecodedLength(length));\n let op = 0;\n let i = 0;\n let haveBad = 0;\n let v0 = 0, v1 = 0, v2 = 0, v3 = 0;\n for (; i < length - 4; i += 4) {\n v0 = this._decodeChar(s.charCodeAt(i + 0));\n v1 = this._decodeChar(s.charCodeAt(i + 1));\n v2 = this._decodeChar(s.charCodeAt(i + 2));\n v3 = this._decodeChar(s.charCodeAt(i + 3));\n out[op++] = (v0 << 2) | (v1 >>> 4);\n out[op++] = (v1 << 4) | (v2 >>> 2);\n out[op++] = (v2 << 6) | v3;\n haveBad |= v0 & INVALID_BYTE;\n haveBad |= v1 & INVALID_BYTE;\n haveBad |= v2 & INVALID_BYTE;\n haveBad |= v3 & INVALID_BYTE;\n }\n if (i < length - 1) {\n v0 = this._decodeChar(s.charCodeAt(i));\n v1 = this._decodeChar(s.charCodeAt(i + 1));\n out[op++] = (v0 << 2) | (v1 >>> 4);\n haveBad |= v0 & INVALID_BYTE;\n haveBad |= v1 & INVALID_BYTE;\n }\n if (i < length - 2) {\n v2 = this._decodeChar(s.charCodeAt(i + 2));\n out[op++] = (v1 << 4) | (v2 >>> 2);\n haveBad |= v2 & INVALID_BYTE;\n }\n if (i < length - 3) {\n v3 = this._decodeChar(s.charCodeAt(i + 3));\n out[op++] = (v2 << 6) | v3;\n haveBad |= v3 & INVALID_BYTE;\n }\n if (haveBad !== 0) {\n throw new Error(\"Base64Coder: incorrect characters for decoding\");\n }\n return out;\n }\n\n // Standard encoding have the following encoded/decoded ranges,\n // which we need to convert between.\n //\n // ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 0123456789 + /\n // Index: 0 - 25 26 - 51 52 - 61 62 63\n // ASCII: 65 - 90 97 - 122 48 - 57 43 47\n //\n\n // Encode 6 bits in b into a new character.\n protected _encodeByte(b: number): string {\n // Encoding uses constant time operations as follows:\n //\n // 1. Define comparison of A with B using (A - B) >>> 8:\n // if A > B, then result is positive integer\n // if A <= B, then result is 0\n //\n // 2. Define selection of C or 0 using bitwise AND: X & C:\n // if X == 0, then result is 0\n // if X != 0, then result is C\n //\n // 3. Start with the smallest comparison (b >= 0), which is always\n // true, so set the result to the starting ASCII value (65).\n //\n // 4. Continue comparing b to higher ASCII values, and selecting\n // zero if comparison isn't true, otherwise selecting a value\n // to add to result, which:\n //\n // a) undoes the previous addition\n // b) provides new value to add\n //\n let result = b;\n // b >= 0\n result += 65;\n // b > 25\n result += ((25 - b) >>> 8) & ((0 - 65) - 26 + 97);\n // b > 51\n result += ((51 - b) >>> 8) & ((26 - 97) - 52 + 48);\n // b > 61\n result += ((61 - b) >>> 8) & ((52 - 48) - 62 + 43);\n // b > 62\n result += ((62 - b) >>> 8) & ((62 - 43) - 63 + 47);\n\n return String.fromCharCode(result);\n }\n\n // Decode a character code into a byte.\n // Must return 256 if character is out of alphabet range.\n protected _decodeChar(c: number): number {\n // Decoding works similar to encoding: using the same comparison\n // function, but now it works on ranges: result is always incremented\n // by value, but this value becomes zero if the range is not\n // satisfied.\n //\n // Decoding starts with invalid value, 256, which is then\n // subtracted when the range is satisfied. If none of the ranges\n // apply, the function returns 256, which is then checked by\n // the caller to throw error.\n let result = INVALID_BYTE; // start with invalid character\n\n // c == 43 (c > 42 and c < 44)\n result += (((42 - c) & (c - 44)) >>> 8) & (-INVALID_BYTE + c - 43 + 62);\n // c == 47 (c > 46 and c < 48)\n result += (((46 - c) & (c - 48)) >>> 8) & (-INVALID_BYTE + c - 47 + 63);\n // c > 47 and c < 58\n result += (((47 - c) & (c - 58)) >>> 8) & (-INVALID_BYTE + c - 48 + 52);\n // c > 64 and c < 91\n result += (((64 - c) & (c - 91)) >>> 8) & (-INVALID_BYTE + c - 65 + 0);\n // c > 96 and c < 123\n result += (((96 - c) & (c - 123)) >>> 8) & (-INVALID_BYTE + c - 97 + 26);\n\n return result;\n }\n\n private _getPaddingLength(s: string): number {\n let paddingLength = 0;\n if (this._paddingCharacter) {\n for (let i = s.length - 1; i >= 0; i--) {\n if (s[i] !== this._paddingCharacter) {\n break;\n }\n paddingLength++;\n }\n if (s.length < 4 || paddingLength > 2) {\n throw new Error(\"Base64Coder: incorrect padding\");\n }\n }\n return paddingLength;\n }\n\n}\n\nconst stdCoder = new Coder();\n\nexport function encode(data: Uint8Array): string {\n return stdCoder.encode(data);\n}\n\nexport function decode(s: string): Uint8Array {\n return stdCoder.decode(s);\n}\n\n/**\n * Implements URL-safe Base64 encoding.\n * (Same as Base64, but '+' is replaced with '-', and '/' with '_').\n *\n * Operates in constant time.\n */\nexport class URLSafeCoder extends Coder {\n // URL-safe encoding have the following encoded/decoded ranges:\n //\n // ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 0123456789 - _\n // Index: 0 - 25 26 - 51 52 - 61 62 63\n // ASCII: 65 - 90 97 - 122 48 - 57 45 95\n //\n\n protected _encodeByte(b: number): string {\n let result = b;\n // b >= 0\n result += 65;\n // b > 25\n result += ((25 - b) >>> 8) & ((0 - 65) - 26 + 97);\n // b > 51\n result += ((51 - b) >>> 8) & ((26 - 97) - 52 + 48);\n // b > 61\n result += ((61 - b) >>> 8) & ((52 - 48) - 62 + 45);\n // b > 62\n result += ((62 - b) >>> 8) & ((62 - 45) - 63 + 95);\n\n return String.fromCharCode(result);\n }\n\n protected _decodeChar(c: number): number {\n let result = INVALID_BYTE;\n\n // c == 45 (c > 44 and c < 46)\n result += (((44 - c) & (c - 46)) >>> 8) & (-INVALID_BYTE + c - 45 + 62);\n // c == 95 (c > 94 and c < 96)\n result += (((94 - c) & (c - 96)) >>> 8) & (-INVALID_BYTE + c - 95 + 63);\n // c > 47 and c < 58\n result += (((47 - c) & (c - 58)) >>> 8) & (-INVALID_BYTE + c - 48 + 52);\n // c > 64 and c < 91\n result += (((64 - c) & (c - 91)) >>> 8) & (-INVALID_BYTE + c - 65 + 0);\n // c > 96 and c < 123\n result += (((96 - c) & (c - 123)) >>> 8) & (-INVALID_BYTE + c - 97 + 26);\n\n return result;\n }\n}\n\nconst urlSafeCoder = new URLSafeCoder();\n\nexport function encodeURLSafe(data: Uint8Array): string {\n return urlSafeCoder.encode(data);\n}\n\nexport function decodeURLSafe(s: string): Uint8Array {\n return urlSafeCoder.decode(s);\n}\n\n\nexport const encodedLength = (length: number) =>\n stdCoder.encodedLength(length);\n\nexport const maxDecodedLength = (length: number) =>\n stdCoder.maxDecodedLength(length);\n\nexport const decodedLength = (s: string) =>\n stdCoder.decodedLength(s);\n","// Copyright (C) 2016 Dmitry Chestnykh\n// MIT License. See LICENSE file for details.\n\n/**\n * Package utf8 implements UTF-8 encoding and decoding.\n */\n\nconst INVALID_UTF16 = \"utf8: invalid string\";\nconst INVALID_UTF8 = \"utf8: invalid source encoding\";\n\n/**\n * Encodes the given string into UTF-8 byte array.\n * Throws if the source string has invalid UTF-16 encoding.\n */\nexport function encode(s: string): Uint8Array {\n // Calculate result length and allocate output array.\n // encodedLength() also validates string and throws errors,\n // so we don't need repeat validation here.\n const arr = new Uint8Array(encodedLength(s));\n\n let pos = 0;\n for (let i = 0; i < s.length; i++) {\n let c = s.charCodeAt(i);\n if (c < 0x80) {\n arr[pos++] = c;\n } else if (c < 0x800) {\n arr[pos++] = 0xc0 | c >> 6;\n arr[pos++] = 0x80 | c & 0x3f;\n } else if (c < 0xd800) {\n arr[pos++] = 0xe0 | c >> 12;\n arr[pos++] = 0x80 | (c >> 6) & 0x3f;\n arr[pos++] = 0x80 | c & 0x3f;\n } else {\n i++; // get one more character\n c = (c & 0x3ff) << 10;\n c |= s.charCodeAt(i) & 0x3ff;\n c += 0x10000;\n\n arr[pos++] = 0xf0 | c >> 18;\n arr[pos++] = 0x80 | (c >> 12) & 0x3f;\n arr[pos++] = 0x80 | (c >> 6) & 0x3f;\n arr[pos++] = 0x80 | c & 0x3f;\n }\n }\n return arr;\n}\n\n/**\n * Returns the number of bytes required to encode the given string into UTF-8.\n * Throws if the source string has invalid UTF-16 encoding.\n */\nexport function encodedLength(s: string): number {\n let result = 0;\n for (let i = 0; i < s.length; i++) {\n const c = s.charCodeAt(i);\n if (c < 0x80) {\n result += 1;\n } else if (c < 0x800) {\n result += 2;\n } else if (c < 0xd800) {\n result += 3;\n } else if (c <= 0xdfff) {\n if (i >= s.length - 1) {\n throw new Error(INVALID_UTF16);\n }\n i++; // \"eat\" next character\n result += 4;\n } else {\n throw new Error(INVALID_UTF16);\n }\n }\n return result;\n}\n\n/**\n * Decodes the given byte array from UTF-8 into a string.\n * Throws if encoding is invalid.\n */\nexport function decode(arr: Uint8Array): string {\n const chars: string[] = [];\n for (let i = 0; i < arr.length; i++) {\n let b = arr[i];\n\n if (b & 0x80) {\n let min;\n if (b < 0xe0) {\n // Need 1 more byte.\n if (i >= arr.length) {\n throw new Error(INVALID_UTF8);\n }\n const n1 = arr[++i];\n if ((n1 & 0xc0) !== 0x80) {\n throw new Error(INVALID_UTF8);\n }\n b = (b & 0x1f) << 6 | (n1 & 0x3f);\n min = 0x80;\n } else if (b < 0xf0) {\n // Need 2 more bytes.\n if (i >= arr.length - 1) {\n throw new Error(INVALID_UTF8);\n }\n const n1 = arr[++i];\n const n2 = arr[++i];\n if ((n1 & 0xc0) !== 0x80 || (n2 & 0xc0) !== 0x80) {\n throw new Error(INVALID_UTF8);\n }\n b = (b & 0x0f) << 12 | (n1 & 0x3f) << 6 | (n2 & 0x3f);\n min = 0x800;\n } else if (b < 0xf8) {\n // Need 3 more bytes.\n if (i >= arr.length - 2) {\n throw new Error(INVALID_UTF8);\n }\n const n1 = arr[++i];\n const n2 = arr[++i];\n const n3 = arr[++i];\n if ((n1 & 0xc0) !== 0x80 || (n2 & 0xc0) !== 0x80 || (n3 & 0xc0) !== 0x80) {\n throw new Error(INVALID_UTF8);\n }\n b = (b & 0x0f) << 18 | (n1 & 0x3f) << 12 | (n2 & 0x3f) << 6 | (n3 & 0x3f);\n min = 0x10000;\n } else {\n throw new Error(INVALID_UTF8);\n }\n\n if (b < min || (b >= 0xd800 && b <= 0xdfff)) {\n throw new Error(INVALID_UTF8);\n }\n\n if (b >= 0x10000) {\n // Surrogate pair.\n if (b > 0x10ffff) {\n throw new Error(INVALID_UTF8);\n }\n b -= 0x10000;\n chars.push(String.fromCharCode(0xd800 | (b >> 10)));\n b = 0xdc00 | (b & 0x3ff);\n }\n }\n\n chars.push(String.fromCharCode(b));\n }\n return chars.join(\"\");\n}\n","// required so we don't have to do require('pusher').default etc.\nmodule.exports = require('./pusher').default;\n","export default function encode(s: any): string {\n return btoa(utob(s));\n}\n\nvar fromCharCode = String.fromCharCode;\n\nvar b64chars =\n 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';\nvar b64tab = {};\n\nfor (var i = 0, l = b64chars.length; i < l; i++) {\n b64tab[b64chars.charAt(i)] = i;\n}\n\nvar cb_utob = function(c) {\n var cc = c.charCodeAt(0);\n return cc < 0x80\n ? c\n : cc < 0x800\n ? fromCharCode(0xc0 | (cc >>> 6)) + fromCharCode(0x80 | (cc & 0x3f))\n : fromCharCode(0xe0 | ((cc >>> 12) & 0x0f)) +\n fromCharCode(0x80 | ((cc >>> 6) & 0x3f)) +\n fromCharCode(0x80 | (cc & 0x3f));\n};\n\nvar utob = function(u) {\n return u.replace(/[^\\x00-\\x7F]/g, cb_utob);\n};\n\nvar cb_encode = function(ccc) {\n var padlen = [0, 2, 1][ccc.length % 3];\n var ord =\n (ccc.charCodeAt(0) << 16) |\n ((ccc.length > 1 ? ccc.charCodeAt(1) : 0) << 8) |\n (ccc.length > 2 ? ccc.charCodeAt(2) : 0);\n var chars = [\n b64chars.charAt(ord >>> 18),\n b64chars.charAt((ord >>> 12) & 63),\n padlen >= 2 ? '=' : b64chars.charAt((ord >>> 6) & 63),\n padlen >= 1 ? '=' : b64chars.charAt(ord & 63)\n ];\n return chars.join('');\n};\n\nvar btoa =\n global.btoa ||\n function(b) {\n return b.replace(/[\\s\\S]{1,3}/g, cb_encode);\n };\n","import TimedCallback from './timed_callback';\nimport { Delay, Scheduler, Canceller } from './scheduling';\n\nabstract class Timer {\n protected clear: Canceller;\n protected timer: number | void;\n\n constructor(\n set: Scheduler,\n clear: Canceller,\n delay: Delay,\n callback: TimedCallback\n ) {\n this.clear = clear;\n this.timer = set(() => {\n if (this.timer) {\n this.timer = callback(this.timer);\n }\n }, delay);\n }\n\n /** Returns whether the timer is still running.\n *\n * @return {Boolean}\n */\n isRunning(): boolean {\n return this.timer !== null;\n }\n\n /** Aborts a timer when it's running. */\n ensureAborted() {\n if (this.timer) {\n this.clear(this.timer);\n this.timer = null;\n }\n }\n}\n\nexport default Timer;\n","import Timer from './abstract_timer';\nimport TimedCallback from './timed_callback';\nimport { Delay } from './scheduling';\n\n// We need to bind clear functions this way to avoid exceptions on IE8\nfunction clearTimeout(timer) {\n global.clearTimeout(timer);\n}\nfunction clearInterval(timer) {\n global.clearInterval(timer);\n}\n\n/** Cross-browser compatible one-off timer abstraction.\n *\n * @param {Number} delay\n * @param {Function} callback\n */\nexport class OneOffTimer extends Timer {\n constructor(delay: Delay, callback: TimedCallback) {\n super(setTimeout, clearTimeout, delay, function(timer) {\n callback();\n return null;\n });\n }\n}\n\n/** Cross-browser compatible periodic timer abstraction.\n *\n * @param {Number} delay\n * @param {Function} callback\n */\nexport class PeriodicTimer extends Timer {\n constructor(delay: Delay, callback: TimedCallback) {\n super(setInterval, clearInterval, delay, function(timer) {\n callback();\n return timer;\n });\n }\n}\n","import * as Collections from './utils/collections';\nimport TimedCallback from './utils/timers/timed_callback';\nimport { OneOffTimer, PeriodicTimer } from './utils/timers';\n\nvar Util = {\n now(): number {\n if (Date.now) {\n return Date.now();\n } else {\n return new Date().valueOf();\n }\n },\n\n defer(callback: TimedCallback): OneOffTimer {\n return new OneOffTimer(0, callback);\n },\n\n /** Builds a function that will proxy a method call to its first argument.\n *\n * Allows partial application of arguments, so additional arguments are\n * prepended to the argument list.\n *\n * @param {String} name method name\n * @return {Function} proxy function\n */\n method(name: string, ...args: any[]): Function {\n var boundArguments = Array.prototype.slice.call(arguments, 1);\n return function(object) {\n return object[name].apply(object, boundArguments.concat(arguments));\n };\n }\n};\n\nexport default Util;\n","import base64encode from '../base64';\nimport Util from '../util';\n\n/** Merges multiple objects into the target argument.\n *\n * For properties that are plain Objects, performs a deep-merge. For the\n * rest it just copies the value of the property.\n *\n * To extend prototypes use it as following:\n * Pusher.Util.extend(Target.prototype, Base.prototype)\n *\n * You can also use it to merge objects without altering them:\n * Pusher.Util.extend({}, object1, object2)\n *\n * @param {Object} target\n * @return {Object} the target argument\n */\nexport function extend(target: any, ...sources: any[]): T {\n for (var i = 0; i < sources.length; i++) {\n var extensions = sources[i];\n for (var property in extensions) {\n if (\n extensions[property] &&\n extensions[property].constructor &&\n extensions[property].constructor === Object\n ) {\n target[property] = extend(target[property] || {}, extensions[property]);\n } else {\n target[property] = extensions[property];\n }\n }\n }\n return target;\n}\n\nexport function stringify(): string {\n var m = ['Pusher'];\n for (var i = 0; i < arguments.length; i++) {\n if (typeof arguments[i] === 'string') {\n m.push(arguments[i]);\n } else {\n m.push(safeJSONStringify(arguments[i]));\n }\n }\n return m.join(' : ');\n}\n\nexport function arrayIndexOf(array: any[], item: any): number {\n // MSIE doesn't have array.indexOf\n var nativeIndexOf = Array.prototype.indexOf;\n if (array === null) {\n return -1;\n }\n if (nativeIndexOf && array.indexOf === nativeIndexOf) {\n return array.indexOf(item);\n }\n for (var i = 0, l = array.length; i < l; i++) {\n if (array[i] === item) {\n return i;\n }\n }\n return -1;\n}\n\n/** Applies a function f to all properties of an object.\n *\n * Function f gets 3 arguments passed:\n * - element from the object\n * - key of the element\n * - reference to the object\n *\n * @param {Object} object\n * @param {Function} f\n */\nexport function objectApply(object: any, f: Function) {\n for (var key in object) {\n if (Object.prototype.hasOwnProperty.call(object, key)) {\n f(object[key], key, object);\n }\n }\n}\n\n/** Return a list of objects own proerty keys\n *\n * @param {Object} object\n * @returns {Array}\n */\nexport function keys(object: any): string[] {\n var keys = [];\n objectApply(object, function(_, key) {\n keys.push(key);\n });\n return keys;\n}\n\n/** Return a list of object's own property values\n *\n * @param {Object} object\n * @returns {Array}\n */\nexport function values(object: any): any[] {\n var values = [];\n objectApply(object, function(value) {\n values.push(value);\n });\n return values;\n}\n\n/** Applies a function f to all elements of an array.\n *\n * Function f gets 3 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function apply(array: any[], f: Function, context?: any) {\n for (var i = 0; i < array.length; i++) {\n f.call(context || global, array[i], i, array);\n }\n}\n\n/** Maps all elements of the array and returns the result.\n *\n * Function f gets 4 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n * - reference to the destination array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function map(array: any[], f: Function): any[] {\n var result = [];\n for (var i = 0; i < array.length; i++) {\n result.push(f(array[i], i, array, result));\n }\n return result;\n}\n\n/** Maps all elements of the object and returns the result.\n *\n * Function f gets 4 arguments passed:\n * - element from the object\n * - key of the element\n * - reference to the source object\n * - reference to the destination object\n *\n * @param {Object} object\n * @param {Function} f\n */\nexport function mapObject(object: any, f: Function): any {\n var result = {};\n objectApply(object, function(value, key) {\n result[key] = f(value);\n });\n return result;\n}\n\n/** Filters elements of the array using a test function.\n *\n * Function test gets 4 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n * - reference to the destination array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function filter(array: any[], test: Function): any[] {\n test =\n test ||\n function(value) {\n return !!value;\n };\n\n var result = [];\n for (var i = 0; i < array.length; i++) {\n if (test(array[i], i, array, result)) {\n result.push(array[i]);\n }\n }\n return result;\n}\n\n/** Filters properties of the object using a test function.\n *\n * Function test gets 4 arguments passed:\n * - element from the object\n * - key of the element\n * - reference to the source object\n * - reference to the destination object\n *\n * @param {Object} object\n * @param {Function} f\n */\nexport function filterObject(object: Object, test: Function) {\n var result = {};\n objectApply(object, function(value, key) {\n if ((test && test(value, key, object, result)) || Boolean(value)) {\n result[key] = value;\n }\n });\n return result;\n}\n\n/** Flattens an object into a two-dimensional array.\n *\n * @param {Object} object\n * @return {Array} resulting array of [key, value] pairs\n */\nexport function flatten(object: Object): any[] {\n var result = [];\n objectApply(object, function(value, key) {\n result.push([key, value]);\n });\n return result;\n}\n\n/** Checks whether any element of the array passes the test.\n *\n * Function test gets 3 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function any(array: any[], test: Function): boolean {\n for (var i = 0; i < array.length; i++) {\n if (test(array[i], i, array)) {\n return true;\n }\n }\n return false;\n}\n\n/** Checks whether all elements of the array pass the test.\n *\n * Function test gets 3 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function all(array: any[], test: Function): boolean {\n for (var i = 0; i < array.length; i++) {\n if (!test(array[i], i, array)) {\n return false;\n }\n }\n return true;\n}\n\nexport function encodeParamsObject(data): string {\n return mapObject(data, function(value) {\n if (typeof value === 'object') {\n value = safeJSONStringify(value);\n }\n return encodeURIComponent(base64encode(value.toString()));\n });\n}\n\nexport function buildQueryString(data: any): string {\n var params = filterObject(data, function(value) {\n return value !== undefined;\n });\n\n var query = map(\n flatten(encodeParamsObject(params)),\n Util.method('join', '=')\n ).join('&');\n\n return query;\n}\n\n/**\n * See https://github.com/douglascrockford/JSON-js/blob/master/cycle.js\n *\n * Remove circular references from an object. Required for JSON.stringify in\n * React Native, which tends to blow up a lot.\n *\n * @param {any} object\n * @return {any} Decycled object\n */\nexport function decycleObject(object: any): any {\n var objects = [],\n paths = [];\n\n return (function derez(value, path) {\n var i, name, nu;\n\n switch (typeof value) {\n case 'object':\n if (!value) {\n return null;\n }\n for (i = 0; i < objects.length; i += 1) {\n if (objects[i] === value) {\n return { $ref: paths[i] };\n }\n }\n\n objects.push(value);\n paths.push(path);\n\n if (Object.prototype.toString.apply(value) === '[object Array]') {\n nu = [];\n for (i = 0; i < value.length; i += 1) {\n nu[i] = derez(value[i], path + '[' + i + ']');\n }\n } else {\n nu = {};\n for (name in value) {\n if (Object.prototype.hasOwnProperty.call(value, name)) {\n nu[name] = derez(\n value[name],\n path + '[' + JSON.stringify(name) + ']'\n );\n }\n }\n }\n return nu;\n case 'number':\n case 'string':\n case 'boolean':\n return value;\n }\n })(object, '$');\n}\n\n/**\n * Provides a cross-browser and cross-platform way to safely stringify objects\n * into JSON. This is particularly necessary for ReactNative, where circular JSON\n * structures throw an exception.\n *\n * @param {any} source The object to stringify\n * @return {string} The serialized output.\n */\nexport function safeJSONStringify(source: any): string {\n try {\n return JSON.stringify(source);\n } catch (e) {\n return JSON.stringify(decycleObject(source));\n }\n}\n","import {\n ChannelAuthorizationOptions,\n UserAuthenticationOptions\n} from './auth/options';\nimport { AuthTransport } from './config';\n\nexport interface DefaultConfig {\n VERSION: string;\n PROTOCOL: number;\n wsPort: number;\n wssPort: number;\n wsPath: string;\n httpHost: string;\n httpPort: number;\n httpsPort: number;\n httpPath: string;\n stats_host: string;\n authEndpoint: string;\n authTransport: AuthTransport;\n activityTimeout: number;\n pongTimeout: number;\n unavailableTimeout: number;\n userAuthentication: UserAuthenticationOptions;\n channelAuthorization: ChannelAuthorizationOptions;\n\n cdn_http?: string;\n cdn_https?: string;\n dependency_suffix?: string;\n}\n\nvar Defaults: DefaultConfig = {\n VERSION: VERSION,\n PROTOCOL: 7,\n\n wsPort: 80,\n wssPort: 443,\n wsPath: '',\n // DEPRECATED: SockJS fallback parameters\n httpHost: 'sockjs.pusher.com',\n httpPort: 80,\n httpsPort: 443,\n httpPath: '/pusher',\n // DEPRECATED: Stats\n stats_host: 'stats.pusher.com',\n // DEPRECATED: Other settings\n authEndpoint: '/pusher/auth',\n authTransport: 'ajax',\n activityTimeout: 120000,\n pongTimeout: 30000,\n unavailableTimeout: 10000,\n userAuthentication: {\n endpoint: '/pusher/user-auth',\n transport: 'ajax'\n },\n channelAuthorization: {\n endpoint: '/pusher/auth',\n transport: 'ajax'\n },\n\n // CDN configuration\n cdn_http: CDN_HTTP,\n cdn_https: CDN_HTTPS,\n dependency_suffix: DEPENDENCY_SUFFIX\n};\n\nexport default Defaults;\n","import Defaults from '../defaults';\nimport { default as URLScheme, URLSchemeParams } from './url_scheme';\n\nfunction getGenericURL(\n baseScheme: string,\n params: URLSchemeParams,\n path: string\n): string {\n var scheme = baseScheme + (params.useTLS ? 's' : '');\n var host = params.useTLS ? params.hostTLS : params.hostNonTLS;\n return scheme + '://' + host + path;\n}\n\nfunction getGenericPath(key: string, queryString?: string): string {\n var path = '/app/' + key;\n var query =\n '?protocol=' +\n Defaults.PROTOCOL +\n '&client=js' +\n '&version=' +\n Defaults.VERSION +\n (queryString ? '&' + queryString : '');\n return path + query;\n}\n\nexport var ws: URLScheme = {\n getInitial: function(key: string, params: URLSchemeParams): string {\n var path = (params.httpPath || '') + getGenericPath(key, 'flash=false');\n return getGenericURL('ws', params, path);\n }\n};\n\nexport var http: URLScheme = {\n getInitial: function(key: string, params: URLSchemeParams): string {\n var path = (params.httpPath || '/pusher') + getGenericPath(key);\n return getGenericURL('http', params, path);\n }\n};\n\nexport var sockjs: URLScheme = {\n getInitial: function(key: string, params: URLSchemeParams): string {\n return getGenericURL('http', params, params.httpPath || '/pusher');\n },\n getPath: function(key: string, params: URLSchemeParams): string {\n return getGenericPath(key);\n }\n};\n","import Callback from './callback';\nimport * as Collections from '../utils/collections';\nimport CallbackTable from './callback_table';\n\nexport default class CallbackRegistry {\n _callbacks: CallbackTable;\n\n constructor() {\n this._callbacks = {};\n }\n\n get(name: string): Callback[] {\n return this._callbacks[prefix(name)];\n }\n\n add(name: string, callback: Function, context: any) {\n var prefixedEventName = prefix(name);\n this._callbacks[prefixedEventName] =\n this._callbacks[prefixedEventName] || [];\n this._callbacks[prefixedEventName].push({\n fn: callback,\n context: context\n });\n }\n\n remove(name?: string, callback?: Function, context?: any) {\n if (!name && !callback && !context) {\n this._callbacks = {};\n return;\n }\n\n var names = name ? [prefix(name)] : Collections.keys(this._callbacks);\n\n if (callback || context) {\n this.removeCallback(names, callback, context);\n } else {\n this.removeAllCallbacks(names);\n }\n }\n\n private removeCallback(names: string[], callback: Function, context: any) {\n Collections.apply(\n names,\n function(name) {\n this._callbacks[name] = Collections.filter(\n this._callbacks[name] || [],\n function(binding) {\n return (\n (callback && callback !== binding.fn) ||\n (context && context !== binding.context)\n );\n }\n );\n if (this._callbacks[name].length === 0) {\n delete this._callbacks[name];\n }\n },\n this\n );\n }\n\n private removeAllCallbacks(names: string[]) {\n Collections.apply(\n names,\n function(name) {\n delete this._callbacks[name];\n },\n this\n );\n }\n}\n\nfunction prefix(name: string): string {\n return '_' + name;\n}\n","import * as Collections from '../utils/collections';\nimport Callback from './callback';\nimport Metadata from '../channels/metadata';\nimport CallbackRegistry from './callback_registry';\n\n/** Manages callback bindings and event emitting.\n *\n * @param Function failThrough called when no listeners are bound to an event\n */\nexport default class Dispatcher {\n callbacks: CallbackRegistry;\n global_callbacks: Function[];\n failThrough: Function;\n\n constructor(failThrough?: Function) {\n this.callbacks = new CallbackRegistry();\n this.global_callbacks = [];\n this.failThrough = failThrough;\n }\n\n bind(eventName: string, callback: Function, context?: any) {\n this.callbacks.add(eventName, callback, context);\n return this;\n }\n\n bind_global(callback: Function) {\n this.global_callbacks.push(callback);\n return this;\n }\n\n unbind(eventName?: string, callback?: Function, context?: any) {\n this.callbacks.remove(eventName, callback, context);\n return this;\n }\n\n unbind_global(callback?: Function) {\n if (!callback) {\n this.global_callbacks = [];\n return this;\n }\n\n this.global_callbacks = Collections.filter(\n this.global_callbacks || [],\n c => c !== callback\n );\n\n return this;\n }\n\n unbind_all() {\n this.unbind();\n this.unbind_global();\n return this;\n }\n\n emit(eventName: string, data?: any, metadata?: Metadata): Dispatcher {\n for (var i = 0; i < this.global_callbacks.length; i++) {\n this.global_callbacks[i](eventName, data);\n }\n\n var callbacks = this.callbacks.get(eventName);\n var args = [];\n\n if (metadata) {\n // if there's a metadata argument, we need to call the callback with both\n // data and metadata regardless of whether data is undefined\n args.push(data, metadata);\n } else if (data) {\n // metadata is undefined, so we only need to call the callback with data\n // if data exists\n args.push(data);\n }\n\n if (callbacks && callbacks.length > 0) {\n for (var i = 0; i < callbacks.length; i++) {\n callbacks[i].fn.apply(callbacks[i].context || global, args);\n }\n } else if (this.failThrough) {\n this.failThrough(eventName, data);\n }\n\n return this;\n }\n}\n","import { stringify } from './utils/collections';\nimport Pusher from './pusher';\n\nclass Logger {\n debug(...args: any[]) {\n this.log(this.globalLog, args);\n }\n\n warn(...args: any[]) {\n this.log(this.globalLogWarn, args);\n }\n\n error(...args: any[]) {\n this.log(this.globalLogError, args);\n }\n\n private globalLog = (message: string) => {\n if (global.console && global.console.log) {\n global.console.log(message);\n }\n };\n\n private globalLogWarn(message: string) {\n if (global.console && global.console.warn) {\n global.console.warn(message);\n } else {\n this.globalLog(message);\n }\n }\n\n private globalLogError(message: string) {\n if (global.console && global.console.error) {\n global.console.error(message);\n } else {\n this.globalLogWarn(message);\n }\n }\n\n private log(\n defaultLoggingFunction: (message: string) => void,\n ...args: any[]\n ) {\n var message = stringify.apply(this, arguments);\n if (Pusher.log) {\n Pusher.log(message);\n } else if (Pusher.logToConsole) {\n const log = defaultLoggingFunction.bind(this);\n log(message);\n }\n }\n}\n\nexport default new Logger();\n","import Util from '../util';\nimport * as Collections from '../utils/collections';\nimport { default as EventsDispatcher } from '../events/dispatcher';\nimport Logger from '../logger';\nimport TransportHooks from './transport_hooks';\nimport Socket from '../socket';\nimport Runtime from 'runtime';\nimport Timeline from '../timeline/timeline';\nimport TransportConnectionOptions from './transport_connection_options';\n\n/** Provides universal API for transport connections.\n *\n * Transport connection is a low-level object that wraps a connection method\n * and exposes a simple evented interface for the connection state and\n * messaging. It does not implement Pusher-specific WebSocket protocol.\n *\n * Additionally, it fetches resources needed for transport to work and exposes\n * an interface for querying transport features.\n *\n * States:\n * - new - initial state after constructing the object\n * - initializing - during initialization phase, usually fetching resources\n * - intialized - ready to establish a connection\n * - connection - when connection is being established\n * - open - when connection ready to be used\n * - closed - after connection was closed be either side\n *\n * Emits:\n * - error - after the connection raised an error\n *\n * Options:\n * - useTLS - whether connection should be over TLS\n * - hostTLS - host to connect to when connection is over TLS\n * - hostNonTLS - host to connect to when connection is over TLS\n *\n * @param {String} key application key\n * @param {Object} options\n */\nexport default class TransportConnection extends EventsDispatcher {\n hooks: TransportHooks;\n name: string;\n priority: number;\n key: string;\n options: TransportConnectionOptions;\n state: string;\n timeline: Timeline;\n activityTimeout: number;\n id: number;\n socket: Socket;\n beforeOpen: Function;\n initialize: Function;\n\n constructor(\n hooks: TransportHooks,\n name: string,\n priority: number,\n key: string,\n options: TransportConnectionOptions\n ) {\n super();\n this.initialize = Runtime.transportConnectionInitializer;\n this.hooks = hooks;\n this.name = name;\n this.priority = priority;\n this.key = key;\n this.options = options;\n\n this.state = 'new';\n this.timeline = options.timeline;\n this.activityTimeout = options.activityTimeout;\n this.id = this.timeline.generateUniqueID();\n }\n\n /** Checks whether the transport handles activity checks by itself.\n *\n * @return {Boolean}\n */\n handlesActivityChecks(): boolean {\n return Boolean(this.hooks.handlesActivityChecks);\n }\n\n /** Checks whether the transport supports the ping/pong API.\n *\n * @return {Boolean}\n */\n supportsPing(): boolean {\n return Boolean(this.hooks.supportsPing);\n }\n\n /** Tries to establish a connection.\n *\n * @returns {Boolean} false if transport is in invalid state\n */\n connect(): boolean {\n if (this.socket || this.state !== 'initialized') {\n return false;\n }\n\n var url = this.hooks.urls.getInitial(this.key, this.options);\n try {\n this.socket = this.hooks.getSocket(url, this.options);\n } catch (e) {\n Util.defer(() => {\n this.onError(e);\n this.changeState('closed');\n });\n return false;\n }\n\n this.bindListeners();\n\n Logger.debug('Connecting', { transport: this.name, url });\n this.changeState('connecting');\n return true;\n }\n\n /** Closes the connection.\n *\n * @return {Boolean} true if there was a connection to close\n */\n close(): boolean {\n if (this.socket) {\n this.socket.close();\n return true;\n } else {\n return false;\n }\n }\n\n /** Sends data over the open connection.\n *\n * @param {String} data\n * @return {Boolean} true only when in the \"open\" state\n */\n send(data: any): boolean {\n if (this.state === 'open') {\n // Workaround for MobileSafari bug (see https://gist.github.com/2052006)\n Util.defer(() => {\n if (this.socket) {\n this.socket.send(data);\n }\n });\n return true;\n } else {\n return false;\n }\n }\n\n /** Sends a ping if the connection is open and transport supports it. */\n ping() {\n if (this.state === 'open' && this.supportsPing()) {\n this.socket.ping();\n }\n }\n\n private onOpen() {\n if (this.hooks.beforeOpen) {\n this.hooks.beforeOpen(\n this.socket,\n this.hooks.urls.getPath(this.key, this.options)\n );\n }\n this.changeState('open');\n this.socket.onopen = undefined;\n }\n\n private onError(error) {\n this.emit('error', { type: 'WebSocketError', error: error });\n this.timeline.error(this.buildTimelineMessage({ error: error.toString() }));\n }\n\n private onClose(closeEvent?: any) {\n if (closeEvent) {\n this.changeState('closed', {\n code: closeEvent.code,\n reason: closeEvent.reason,\n wasClean: closeEvent.wasClean\n });\n } else {\n this.changeState('closed');\n }\n this.unbindListeners();\n this.socket = undefined;\n }\n\n private onMessage(message) {\n this.emit('message', message);\n }\n\n private onActivity() {\n this.emit('activity');\n }\n\n private bindListeners() {\n this.socket.onopen = () => {\n this.onOpen();\n };\n this.socket.onerror = error => {\n this.onError(error);\n };\n this.socket.onclose = closeEvent => {\n this.onClose(closeEvent);\n };\n this.socket.onmessage = message => {\n this.onMessage(message);\n };\n\n if (this.supportsPing()) {\n this.socket.onactivity = () => {\n this.onActivity();\n };\n }\n }\n\n private unbindListeners() {\n if (this.socket) {\n this.socket.onopen = undefined;\n this.socket.onerror = undefined;\n this.socket.onclose = undefined;\n this.socket.onmessage = undefined;\n if (this.supportsPing()) {\n this.socket.onactivity = undefined;\n }\n }\n }\n\n private changeState(state: string, params?: any) {\n this.state = state;\n this.timeline.info(\n this.buildTimelineMessage({\n state: state,\n params: params\n })\n );\n this.emit(state, params);\n }\n\n buildTimelineMessage(message): any {\n return Collections.extend({ cid: this.id }, message);\n }\n}\n","import Factory from '../utils/factory';\nimport TransportHooks from './transport_hooks';\nimport TransportConnection from './transport_connection';\nimport TransportConnectionOptions from './transport_connection_options';\n\n/** Provides interface for transport connection instantiation.\n *\n * Takes transport-specific hooks as the only argument, which allow checking\n * for transport support and creating its connections.\n *\n * Supported hooks: * - file - the name of the file to be fetched during initialization\n * - urls - URL scheme to be used by transport\n * - handlesActivityCheck - true when the transport handles activity checks\n * - supportsPing - true when the transport has a ping/activity API\n * - isSupported - tells whether the transport is supported in the environment\n * - getSocket - creates a WebSocket-compatible transport socket\n *\n * See transports.js for specific implementations.\n *\n * @param {Object} hooks object containing all needed transport hooks\n */\nexport default class Transport {\n hooks: TransportHooks;\n\n constructor(hooks: TransportHooks) {\n this.hooks = hooks;\n }\n\n /** Returns whether the transport is supported in the environment.\n *\n * @param {Object} envronment te environment details (encryption, settings)\n * @returns {Boolean} true when the transport is supported\n */\n isSupported(environment: any): boolean {\n return this.hooks.isSupported(environment);\n }\n\n /** Creates a transport connection.\n *\n * @param {String} name\n * @param {Number} priority\n * @param {String} key the application key\n * @param {Object} options\n * @returns {TransportConnection}\n */\n createConnection(\n name: string,\n priority: number,\n key: string,\n options: any\n ): TransportConnection {\n return new TransportConnection(this.hooks, name, priority, key, options);\n }\n}\n","import * as URLSchemes from 'core/transports/url_schemes';\nimport URLScheme from 'core/transports/url_scheme';\nimport Transport from 'core/transports/transport';\nimport Util from 'core/util';\nimport * as Collections from 'core/utils/collections';\nimport TransportHooks from 'core/transports/transport_hooks';\nimport TransportsTable from 'core/transports/transports_table';\nimport Runtime from 'runtime';\n\n/** WebSocket transport.\n *\n * Uses native WebSocket implementation, including MozWebSocket supported by\n * earlier Firefox versions.\n */\nvar WSTransport = new Transport({\n urls: URLSchemes.ws,\n handlesActivityChecks: false,\n supportsPing: false,\n\n isInitialized: function() {\n return Boolean(Runtime.getWebSocketAPI());\n },\n isSupported: function(): boolean {\n return Boolean(Runtime.getWebSocketAPI());\n },\n getSocket: function(url) {\n return Runtime.createWebSocket(url);\n }\n});\n\nvar httpConfiguration = {\n urls: URLSchemes.http,\n handlesActivityChecks: false,\n supportsPing: true,\n isInitialized: function() {\n return true;\n }\n};\n\nexport var streamingConfiguration = Collections.extend(\n {\n getSocket: function(url) {\n return Runtime.HTTPFactory.createStreamingSocket(url);\n }\n },\n httpConfiguration\n);\nexport var pollingConfiguration = Collections.extend(\n {\n getSocket: function(url) {\n return Runtime.HTTPFactory.createPollingSocket(url);\n }\n },\n httpConfiguration\n);\n\nvar xhrConfiguration = {\n isSupported: function(): boolean {\n return Runtime.isXHRSupported();\n }\n};\n\n/** HTTP streaming transport using CORS-enabled XMLHttpRequest. */\nvar XHRStreamingTransport = new Transport(\n (\n Collections.extend({}, streamingConfiguration, xhrConfiguration)\n )\n);\n\n/** HTTP long-polling transport using CORS-enabled XMLHttpRequest. */\nvar XHRPollingTransport = new Transport(\n Collections.extend({}, pollingConfiguration, xhrConfiguration)\n);\n\nvar Transports: TransportsTable = {\n ws: WSTransport,\n xhr_streaming: XHRStreamingTransport,\n xhr_polling: XHRPollingTransport\n};\n\nexport default Transports;\n","import Util from '../util';\nimport * as Collections from '../utils/collections';\nimport TransportManager from './transport_manager';\nimport TransportConnection from './transport_connection';\nimport Transport from './transport';\nimport PingDelayOptions from './ping_delay_options';\n\n/** Creates transport connections monitored by a transport manager.\n *\n * When a transport is closed, it might mean the environment does not support\n * it. It's possible that messages get stuck in an intermediate buffer or\n * proxies terminate inactive connections. To combat these problems,\n * assistants monitor the connection lifetime, report unclean exits and\n * adjust ping timeouts to keep the connection active. The decision to disable\n * a transport is the manager's responsibility.\n *\n * @param {TransportManager} manager\n * @param {TransportConnection} transport\n * @param {Object} options\n */\nexport default class AssistantToTheTransportManager {\n manager: TransportManager;\n transport: Transport;\n minPingDelay: number;\n maxPingDelay: number;\n pingDelay: number;\n\n constructor(\n manager: TransportManager,\n transport: Transport,\n options: PingDelayOptions\n ) {\n this.manager = manager;\n this.transport = transport;\n this.minPingDelay = options.minPingDelay;\n this.maxPingDelay = options.maxPingDelay;\n this.pingDelay = undefined;\n }\n\n /** Creates a transport connection.\n *\n * This function has the same API as Transport#createConnection.\n *\n * @param {String} name\n * @param {Number} priority\n * @param {String} key the application key\n * @param {Object} options\n * @returns {TransportConnection}\n */\n createConnection(\n name: string,\n priority: number,\n key: string,\n options: Object\n ): TransportConnection {\n options = Collections.extend({}, options, {\n activityTimeout: this.pingDelay\n });\n var connection = this.transport.createConnection(\n name,\n priority,\n key,\n options\n );\n\n var openTimestamp = null;\n\n var onOpen = function() {\n connection.unbind('open', onOpen);\n connection.bind('closed', onClosed);\n openTimestamp = Util.now();\n };\n var onClosed = closeEvent => {\n connection.unbind('closed', onClosed);\n\n if (closeEvent.code === 1002 || closeEvent.code === 1003) {\n // we don't want to use transports not obeying the protocol\n this.manager.reportDeath();\n } else if (!closeEvent.wasClean && openTimestamp) {\n // report deaths only for short-living transport\n var lifespan = Util.now() - openTimestamp;\n if (lifespan < 2 * this.maxPingDelay) {\n this.manager.reportDeath();\n this.pingDelay = Math.max(lifespan / 2, this.minPingDelay);\n }\n }\n };\n\n connection.bind('open', onOpen);\n return connection;\n }\n\n /** Returns whether the transport is supported in the environment.\n *\n * This function has the same API as Transport#isSupported. Might return false\n * when the manager decides to kill the transport.\n *\n * @param {Object} environment the environment details (encryption, settings)\n * @returns {Boolean} true when the transport is supported\n */\n isSupported(environment: string): boolean {\n return this.manager.isAlive() && this.transport.isSupported(environment);\n }\n}\n","import Action from './action';\nimport { PusherEvent } from './message-types';\n/**\n * Provides functions for handling Pusher protocol-specific messages.\n */\n\nconst Protocol = {\n /**\n * Decodes a message in a Pusher format.\n *\n * The MessageEvent we receive from the transport should contain a pusher event\n * (https://pusher.com/docs/pusher_protocol#events) serialized as JSON in the\n * data field\n *\n * The pusher event may contain a data field too, and it may also be\n * serialised as JSON\n *\n * Throws errors when messages are not parse'able.\n *\n * @param {MessageEvent} messageEvent\n * @return {PusherEvent}\n */\n decodeMessage: function(messageEvent: MessageEvent): PusherEvent {\n try {\n var messageData = JSON.parse(messageEvent.data);\n var pusherEventData = messageData.data;\n if (typeof pusherEventData === 'string') {\n try {\n pusherEventData = JSON.parse(messageData.data);\n } catch (e) {}\n }\n var pusherEvent: PusherEvent = {\n event: messageData.event,\n channel: messageData.channel,\n data: pusherEventData\n };\n if (messageData.user_id) {\n pusherEvent.user_id = messageData.user_id;\n }\n return pusherEvent;\n } catch (e) {\n throw { type: 'MessageParseError', error: e, data: messageEvent.data };\n }\n },\n\n /**\n * Encodes a message to be sent.\n *\n * @param {PusherEvent} event\n * @return {String}\n */\n encodeMessage: function(event: PusherEvent): string {\n return JSON.stringify(event);\n },\n\n /**\n * Processes a handshake message and returns appropriate actions.\n *\n * Returns an object with an 'action' and other action-specific properties.\n *\n * There are three outcomes when calling this function. First is a successful\n * connection attempt, when pusher:connection_established is received, which\n * results in a 'connected' action with an 'id' property. When passed a\n * pusher:error event, it returns a result with action appropriate to the\n * close code and an error. Otherwise, it raises an exception.\n *\n * @param {String} message\n * @result Object\n */\n processHandshake: function(messageEvent: MessageEvent): Action {\n var message = Protocol.decodeMessage(messageEvent);\n\n if (message.event === 'pusher:connection_established') {\n if (!message.data.activity_timeout) {\n throw 'No activity timeout specified in handshake';\n }\n return {\n action: 'connected',\n id: message.data.socket_id,\n activityTimeout: message.data.activity_timeout * 1000\n };\n } else if (message.event === 'pusher:error') {\n // From protocol 6 close codes are sent only once, so this only\n // happens when connection does not support close codes\n return {\n action: this.getCloseAction(message.data),\n error: this.getCloseError(message.data)\n };\n } else {\n throw 'Invalid handshake';\n }\n },\n\n /**\n * Dispatches the close event and returns an appropriate action name.\n *\n * See:\n * 1. https://developer.mozilla.org/en-US/docs/WebSockets/WebSockets_reference/CloseEvent\n * 2. http://pusher.com/docs/pusher_protocol\n *\n * @param {CloseEvent} closeEvent\n * @return {String} close action name\n */\n getCloseAction: function(closeEvent): string {\n if (closeEvent.code < 4000) {\n // ignore 1000 CLOSE_NORMAL, 1001 CLOSE_GOING_AWAY,\n // 1005 CLOSE_NO_STATUS, 1006 CLOSE_ABNORMAL\n // ignore 1007...3999\n // handle 1002 CLOSE_PROTOCOL_ERROR, 1003 CLOSE_UNSUPPORTED,\n // 1004 CLOSE_TOO_LARGE\n if (closeEvent.code >= 1002 && closeEvent.code <= 1004) {\n return 'backoff';\n } else {\n return null;\n }\n } else if (closeEvent.code === 4000) {\n return 'tls_only';\n } else if (closeEvent.code < 4100) {\n return 'refused';\n } else if (closeEvent.code < 4200) {\n return 'backoff';\n } else if (closeEvent.code < 4300) {\n return 'retry';\n } else {\n // unknown error\n return 'refused';\n }\n },\n\n /**\n * Returns an error or null basing on the close event.\n *\n * Null is returned when connection was closed cleanly. Otherwise, an object\n * with error details is returned.\n *\n * @param {CloseEvent} closeEvent\n * @return {Object} error object\n */\n getCloseError: function(closeEvent): any {\n if (closeEvent.code !== 1000 && closeEvent.code !== 1001) {\n return {\n type: 'PusherError',\n data: {\n code: closeEvent.code,\n message: closeEvent.reason || closeEvent.message\n }\n };\n } else {\n return null;\n }\n }\n};\n\nexport default Protocol;\n","import * as Collections from '../utils/collections';\nimport { default as EventsDispatcher } from '../events/dispatcher';\nimport Protocol from './protocol/protocol';\nimport { PusherEvent } from './protocol/message-types';\nimport Logger from '../logger';\nimport TransportConnection from '../transports/transport_connection';\nimport Socket from '../socket';\n/**\n * Provides Pusher protocol interface for transports.\n *\n * Emits following events:\n * - message - on received messages\n * - ping - on ping requests\n * - pong - on pong responses\n * - error - when the transport emits an error\n * - closed - after closing the transport\n *\n * It also emits more events when connection closes with a code.\n * See Protocol.getCloseAction to get more details.\n *\n * @param {Number} id\n * @param {AbstractTransport} transport\n */\nexport default class Connection extends EventsDispatcher implements Socket {\n id: string;\n transport: TransportConnection;\n activityTimeout: number;\n\n constructor(id: string, transport: TransportConnection) {\n super();\n this.id = id;\n this.transport = transport;\n this.activityTimeout = transport.activityTimeout;\n this.bindListeners();\n }\n\n /** Returns whether used transport handles activity checks by itself\n *\n * @returns {Boolean} true if activity checks are handled by the transport\n */\n handlesActivityChecks() {\n return this.transport.handlesActivityChecks();\n }\n\n /** Sends raw data.\n *\n * @param {String} data\n */\n send(data: any): boolean {\n return this.transport.send(data);\n }\n\n /** Sends an event.\n *\n * @param {String} name\n * @param {String} data\n * @param {String} [channel]\n * @returns {Boolean} whether message was sent or not\n */\n send_event(name: string, data: any, channel?: string): boolean {\n var event: PusherEvent = { event: name, data: data };\n if (channel) {\n event.channel = channel;\n }\n Logger.debug('Event sent', event);\n return this.send(Protocol.encodeMessage(event));\n }\n\n /** Sends a ping message to the server.\n *\n * Basing on the underlying transport, it might send either transport's\n * protocol-specific ping or pusher:ping event.\n */\n ping() {\n if (this.transport.supportsPing()) {\n this.transport.ping();\n } else {\n this.send_event('pusher:ping', {});\n }\n }\n\n /** Closes the connection. */\n close() {\n this.transport.close();\n }\n\n private bindListeners() {\n var listeners = {\n message: (messageEvent: MessageEvent) => {\n var pusherEvent;\n try {\n pusherEvent = Protocol.decodeMessage(messageEvent);\n } catch (e) {\n this.emit('error', {\n type: 'MessageParseError',\n error: e,\n data: messageEvent.data\n });\n }\n\n if (pusherEvent !== undefined) {\n Logger.debug('Event recd', pusherEvent);\n\n switch (pusherEvent.event) {\n case 'pusher:error':\n this.emit('error', {\n type: 'PusherError',\n data: pusherEvent.data\n });\n break;\n case 'pusher:ping':\n this.emit('ping');\n break;\n case 'pusher:pong':\n this.emit('pong');\n break;\n }\n this.emit('message', pusherEvent);\n }\n },\n activity: () => {\n this.emit('activity');\n },\n error: error => {\n this.emit('error', error);\n },\n closed: closeEvent => {\n unbindListeners();\n\n if (closeEvent && closeEvent.code) {\n this.handleCloseEvent(closeEvent);\n }\n\n this.transport = null;\n this.emit('closed');\n }\n };\n\n var unbindListeners = () => {\n Collections.objectApply(listeners, (listener, event) => {\n this.transport.unbind(event, listener);\n });\n };\n\n Collections.objectApply(listeners, (listener, event) => {\n this.transport.bind(event, listener);\n });\n }\n\n private handleCloseEvent(closeEvent: any) {\n var action = Protocol.getCloseAction(closeEvent);\n var error = Protocol.getCloseError(closeEvent);\n if (error) {\n this.emit('error', error);\n }\n if (action) {\n this.emit(action, { action: action, error: error });\n }\n }\n}\n","import Util from '../../util';\nimport * as Collections from '../../utils/collections';\nimport Protocol from '../protocol/protocol';\nimport Connection from '../connection';\nimport TransportConnection from '../../transports/transport_connection';\nimport HandshakePayload from './handshake_payload';\n\n/**\n * Handles Pusher protocol handshakes for transports.\n *\n * Calls back with a result object after handshake is completed. Results\n * always have two fields:\n * - action - string describing action to be taken after the handshake\n * - transport - the transport object passed to the constructor\n *\n * Different actions can set different additional properties on the result.\n * In the case of 'connected' action, there will be a 'connection' property\n * containing a Connection object for the transport. Other actions should\n * carry an 'error' property.\n *\n * @param {AbstractTransport} transport\n * @param {Function} callback\n */\nexport default class Handshake {\n transport: TransportConnection;\n callback: (HandshakePayload) => void;\n onMessage: Function;\n onClosed: Function;\n\n constructor(\n transport: TransportConnection,\n callback: (HandshakePayload) => void\n ) {\n this.transport = transport;\n this.callback = callback;\n this.bindListeners();\n }\n\n close() {\n this.unbindListeners();\n this.transport.close();\n }\n\n private bindListeners() {\n this.onMessage = m => {\n this.unbindListeners();\n\n var result;\n try {\n result = Protocol.processHandshake(m);\n } catch (e) {\n this.finish('error', { error: e });\n this.transport.close();\n return;\n }\n\n if (result.action === 'connected') {\n this.finish('connected', {\n connection: new Connection(result.id, this.transport),\n activityTimeout: result.activityTimeout\n });\n } else {\n this.finish(result.action, { error: result.error });\n this.transport.close();\n }\n };\n\n this.onClosed = closeEvent => {\n this.unbindListeners();\n\n var action = Protocol.getCloseAction(closeEvent) || 'backoff';\n var error = Protocol.getCloseError(closeEvent);\n this.finish(action, { error: error });\n };\n\n this.transport.bind('message', this.onMessage);\n this.transport.bind('closed', this.onClosed);\n }\n\n private unbindListeners() {\n this.transport.unbind('message', this.onMessage);\n this.transport.unbind('closed', this.onClosed);\n }\n\n private finish(action: string, params: any) {\n this.callback(\n Collections.extend({ transport: this.transport, action: action }, params)\n );\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport base64encode from '../base64';\nimport Timeline from './timeline';\nimport Runtime from 'runtime';\n\nexport interface TimelineSenderOptions {\n host?: string;\n port?: number;\n path?: string;\n}\n\nexport default class TimelineSender {\n timeline: Timeline;\n options: TimelineSenderOptions;\n host: string;\n\n constructor(timeline: Timeline, options: TimelineSenderOptions) {\n this.timeline = timeline;\n this.options = options || {};\n }\n\n send(useTLS: boolean, callback?: Function) {\n if (this.timeline.isEmpty()) {\n return;\n }\n\n this.timeline.send(\n Runtime.TimelineTransport.getAgent(this, useTLS),\n callback\n );\n }\n}\n","/** Error classes used throughout the library. */\n// https://github.com/Microsoft/TypeScript-wiki/blob/master/Breaking-Changes.md#extending-built-ins-like-error-array-and-map-may-no-longer-work\nexport class BadEventName extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\nexport class BadChannelName extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\nexport class RequestTimedOut extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class TransportPriorityTooLow extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class TransportClosed extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class UnsupportedFeature extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class UnsupportedTransport extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class UnsupportedStrategy extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class HTTPAuthError extends Error {\n status: number;\n constructor(status: number, msg?: string) {\n super(msg);\n this.status = status;\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n","/**\n * A place to store help URLs for error messages etc\n */\n\nconst urlStore = {\n baseUrl: 'https://pusher.com',\n urls: {\n authenticationEndpoint: {\n path: '/docs/channels/server_api/authenticating_users'\n },\n authorizationEndpoint: {\n path: '/docs/channels/server_api/authorizing-users/'\n },\n javascriptQuickStart: {\n path: '/docs/javascript_quick_start'\n },\n triggeringClientEvents: {\n path: '/docs/client_api_guide/client_events#trigger-events'\n },\n encryptedChannelSupport: {\n fullUrl:\n 'https://github.com/pusher/pusher-js/tree/cc491015371a4bde5743d1c87a0fbac0feb53195#encrypted-channel-support'\n }\n }\n};\n\n/** Builds a consistent string with links to pusher documentation\n *\n * @param {string} key - relevant key in the url_store.urls object\n * @return {string} suffix string to append to log message\n */\nconst buildLogSuffix = function(key: string): string {\n const urlPrefix = 'See:';\n const urlObj = urlStore.urls[key];\n if (!urlObj) return '';\n\n let url;\n if (urlObj.fullUrl) {\n url = urlObj.fullUrl;\n } else if (urlObj.path) {\n url = urlStore.baseUrl + urlObj.path;\n }\n\n if (!url) return '';\n return `${urlPrefix} ${url}`;\n};\n\nexport default { buildLogSuffix };\n","import { default as EventsDispatcher } from '../events/dispatcher';\nimport * as Errors from '../errors';\nimport Logger from '../logger';\nimport Pusher from '../pusher';\nimport { PusherEvent } from '../connection/protocol/message-types';\nimport Metadata from './metadata';\nimport UrlStore from '../utils/url_store';\nimport {\n ChannelAuthorizationData,\n ChannelAuthorizationCallback\n} from '../auth/options';\nimport { HTTPAuthError } from '../errors';\n\n/** Provides base public channel interface with an event emitter.\n *\n * Emits:\n * - pusher:subscription_succeeded - after subscribing successfully\n * - other non-internal events\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\nexport default class Channel extends EventsDispatcher {\n name: string;\n pusher: Pusher;\n subscribed: boolean;\n subscriptionPending: boolean;\n subscriptionCancelled: boolean;\n subscriptionCount: null;\n\n constructor(name: string, pusher: Pusher) {\n super(function(event, data) {\n Logger.debug('No callbacks on ' + name + ' for ' + event);\n });\n\n this.name = name;\n this.pusher = pusher;\n this.subscribed = false;\n this.subscriptionPending = false;\n this.subscriptionCancelled = false;\n }\n\n /** Skips authorization, since public channels don't require it.\n *\n * @param {Function} callback\n */\n authorize(socketId: string, callback: ChannelAuthorizationCallback) {\n return callback(null, { auth: '' });\n }\n\n /** Triggers an event */\n trigger(event: string, data: any) {\n if (event.indexOf('client-') !== 0) {\n throw new Errors.BadEventName(\n \"Event '\" + event + \"' does not start with 'client-'\"\n );\n }\n if (!this.subscribed) {\n var suffix = UrlStore.buildLogSuffix('triggeringClientEvents');\n Logger.warn(\n `Client event triggered before channel 'subscription_succeeded' event . ${suffix}`\n );\n }\n return this.pusher.send_event(event, data, this.name);\n }\n\n /** Signals disconnection to the channel. For internal use only. */\n disconnect() {\n this.subscribed = false;\n this.subscriptionPending = false;\n }\n\n /** Handles a PusherEvent. For internal use only.\n *\n * @param {PusherEvent} event\n */\n handleEvent(event: PusherEvent) {\n var eventName = event.event;\n var data = event.data;\n if (eventName === 'pusher_internal:subscription_succeeded') {\n this.handleSubscriptionSucceededEvent(event);\n } else if (eventName === 'pusher_internal:subscription_count') {\n this.handleSubscriptionCountEvent(event);\n } else if (eventName.indexOf('pusher_internal:') !== 0) {\n var metadata: Metadata = {};\n this.emit(eventName, data, metadata);\n }\n }\n\n handleSubscriptionSucceededEvent(event: PusherEvent) {\n this.subscriptionPending = false;\n this.subscribed = true;\n if (this.subscriptionCancelled) {\n this.pusher.unsubscribe(this.name);\n } else {\n this.emit('pusher:subscription_succeeded', event.data);\n }\n }\n\n handleSubscriptionCountEvent(event: PusherEvent) {\n if (event.data.subscription_count) {\n this.subscriptionCount = event.data.subscription_count;\n }\n\n this.emit('pusher:subscription_count', event.data);\n }\n\n /** Sends a subscription request. For internal use only. */\n subscribe() {\n if (this.subscribed) {\n return;\n }\n this.subscriptionPending = true;\n this.subscriptionCancelled = false;\n this.authorize(\n this.pusher.connection.socket_id,\n (error: Error | null, data: ChannelAuthorizationData) => {\n if (error) {\n this.subscriptionPending = false;\n // Why not bind to 'pusher:subscription_error' a level up, and log there?\n // Binding to this event would cause the warning about no callbacks being\n // bound (see constructor) to be suppressed, that's not what we want.\n Logger.error(error.toString());\n this.emit(\n 'pusher:subscription_error',\n Object.assign(\n {},\n {\n type: 'AuthError',\n error: error.message\n },\n error instanceof HTTPAuthError ? { status: error.status } : {}\n )\n );\n } else {\n this.pusher.send_event('pusher:subscribe', {\n auth: data.auth,\n channel_data: data.channel_data,\n channel: this.name\n });\n }\n }\n );\n }\n\n /** Sends an unsubscription request. For internal use only. */\n unsubscribe() {\n this.subscribed = false;\n this.pusher.send_event('pusher:unsubscribe', {\n channel: this.name\n });\n }\n\n /** Cancels an in progress subscription. For internal use only. */\n cancelSubscription() {\n this.subscriptionCancelled = true;\n }\n\n /** Reinstates an in progress subscripiton. For internal use only. */\n reinstateSubscription() {\n this.subscriptionCancelled = false;\n }\n}\n","import Factory from '../utils/factory';\nimport Channel from './channel';\nimport { ChannelAuthorizationCallback } from '../auth/options';\n\n/** Extends public channels to provide private channel interface.\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\nexport default class PrivateChannel extends Channel {\n /** Authorizes the connection to use the channel.\n *\n * @param {String} socketId\n * @param {Function} callback\n */\n authorize(socketId: string, callback: ChannelAuthorizationCallback) {\n return this.pusher.config.channelAuthorizer(\n {\n channelName: this.name,\n socketId: socketId\n },\n callback\n );\n }\n}\n","import * as Collections from '../utils/collections';\n\n/** Represents a collection of members of a presence channel. */\nexport default class Members {\n members: any;\n count: number;\n myID: any;\n me: any;\n\n constructor() {\n this.reset();\n }\n\n /** Returns member's info for given id.\n *\n * Resulting object containts two fields - id and info.\n *\n * @param {Number} id\n * @return {Object} member's info or null\n */\n get(id: string): any {\n if (Object.prototype.hasOwnProperty.call(this.members, id)) {\n return {\n id: id,\n info: this.members[id]\n };\n } else {\n return null;\n }\n }\n\n /** Calls back for each member in unspecified order.\n *\n * @param {Function} callback\n */\n each(callback: Function) {\n Collections.objectApply(this.members, (member, id) => {\n callback(this.get(id));\n });\n }\n\n /** Updates the id for connected member. For internal use only. */\n setMyID(id: string) {\n this.myID = id;\n }\n\n /** Handles subscription data. For internal use only. */\n onSubscription(subscriptionData: any) {\n this.members = subscriptionData.presence.hash;\n this.count = subscriptionData.presence.count;\n this.me = this.get(this.myID);\n }\n\n /** Adds a new member to the collection. For internal use only. */\n addMember(memberData: any) {\n if (this.get(memberData.user_id) === null) {\n this.count++;\n }\n this.members[memberData.user_id] = memberData.user_info;\n return this.get(memberData.user_id);\n }\n\n /** Adds a member from the collection. For internal use only. */\n removeMember(memberData: any) {\n var member = this.get(memberData.user_id);\n if (member) {\n delete this.members[memberData.user_id];\n this.count--;\n }\n return member;\n }\n\n /** Resets the collection to the initial state. For internal use only. */\n reset() {\n this.members = {};\n this.count = 0;\n this.myID = null;\n this.me = null;\n }\n}\n","import PrivateChannel from './private_channel';\nimport Logger from '../logger';\nimport Members from './members';\nimport Pusher from '../pusher';\nimport UrlStore from 'core/utils/url_store';\nimport { PusherEvent } from '../connection/protocol/message-types';\nimport Metadata from './metadata';\nimport { ChannelAuthorizationData } from '../auth/options';\n\nexport default class PresenceChannel extends PrivateChannel {\n members: Members;\n\n /** Adds presence channel functionality to private channels.\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\n constructor(name: string, pusher: Pusher) {\n super(name, pusher);\n this.members = new Members();\n }\n\n /** Authorizes the connection as a member of the channel.\n *\n * @param {String} socketId\n * @param {Function} callback\n */\n authorize(socketId: string, callback: Function) {\n super.authorize(socketId, async (error, authData) => {\n if (!error) {\n authData = authData as ChannelAuthorizationData;\n if (authData.channel_data != null) {\n var channelData = JSON.parse(authData.channel_data);\n this.members.setMyID(channelData.user_id);\n } else {\n await this.pusher.user.signinDonePromise;\n if (this.pusher.user.user_data != null) {\n // If the user is signed in, get the id of the authenticated user\n // and allow the presence authorization to continue.\n this.members.setMyID(this.pusher.user.user_data.id);\n } else {\n let suffix = UrlStore.buildLogSuffix('authorizationEndpoint');\n Logger.error(\n `Invalid auth response for channel '${this.name}', ` +\n `expected 'channel_data' field. ${suffix}, ` +\n `or the user should be signed in.`\n );\n callback('Invalid auth response');\n return;\n }\n }\n }\n callback(error, authData);\n });\n }\n\n /** Handles presence and subscription events. For internal use only.\n *\n * @param {PusherEvent} event\n */\n handleEvent(event: PusherEvent) {\n var eventName = event.event;\n if (eventName.indexOf('pusher_internal:') === 0) {\n this.handleInternalEvent(event);\n } else {\n var data = event.data;\n var metadata: Metadata = {};\n if (event.user_id) {\n metadata.user_id = event.user_id;\n }\n this.emit(eventName, data, metadata);\n }\n }\n handleInternalEvent(event: PusherEvent) {\n var eventName = event.event;\n var data = event.data;\n switch (eventName) {\n case 'pusher_internal:subscription_succeeded':\n this.handleSubscriptionSucceededEvent(event);\n break;\n case 'pusher_internal:subscription_count':\n this.handleSubscriptionCountEvent(event);\n break;\n case 'pusher_internal:member_added':\n var addedMember = this.members.addMember(data);\n this.emit('pusher:member_added', addedMember);\n break;\n case 'pusher_internal:member_removed':\n var removedMember = this.members.removeMember(data);\n if (removedMember) {\n this.emit('pusher:member_removed', removedMember);\n }\n break;\n }\n }\n\n handleSubscriptionSucceededEvent(event: PusherEvent) {\n this.subscriptionPending = false;\n this.subscribed = true;\n if (this.subscriptionCancelled) {\n this.pusher.unsubscribe(this.name);\n } else {\n this.members.onSubscription(event.data);\n this.emit('pusher:subscription_succeeded', this.members);\n }\n }\n\n /** Resets the channel state, including members map. For internal use only. */\n disconnect() {\n this.members.reset();\n super.disconnect();\n }\n}\n","import PrivateChannel from './private_channel';\nimport * as Errors from '../errors';\nimport Logger from '../logger';\nimport Pusher from '../pusher';\nimport { decode as encodeUTF8 } from '@stablelib/utf8';\nimport { decode as decodeBase64 } from '@stablelib/base64';\nimport Dispatcher from '../events/dispatcher';\nimport { PusherEvent } from '../connection/protocol/message-types';\nimport {\n ChannelAuthorizationData,\n ChannelAuthorizationCallback\n} from '../auth/options';\nimport * as nacl from 'tweetnacl';\n\n/** Extends private channels to provide encrypted channel interface.\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\nexport default class EncryptedChannel extends PrivateChannel {\n key: Uint8Array = null;\n nacl: nacl;\n\n constructor(name: string, pusher: Pusher, nacl: nacl) {\n super(name, pusher);\n this.nacl = nacl;\n }\n\n /** Authorizes the connection to use the channel.\n *\n * @param {String} socketId\n * @param {Function} callback\n */\n authorize(socketId: string, callback: ChannelAuthorizationCallback) {\n super.authorize(\n socketId,\n (error: Error | null, authData: ChannelAuthorizationData) => {\n if (error) {\n callback(error, authData);\n return;\n }\n let sharedSecret = authData['shared_secret'];\n if (!sharedSecret) {\n callback(\n new Error(\n `No shared_secret key in auth payload for encrypted channel: ${this.name}`\n ),\n null\n );\n return;\n }\n this.key = decodeBase64(sharedSecret);\n delete authData['shared_secret'];\n callback(null, authData);\n }\n );\n }\n\n trigger(event: string, data: any): boolean {\n throw new Errors.UnsupportedFeature(\n 'Client events are not currently supported for encrypted channels'\n );\n }\n\n /** Handles an event. For internal use only.\n *\n * @param {PusherEvent} event\n */\n handleEvent(event: PusherEvent) {\n var eventName = event.event;\n var data = event.data;\n if (\n eventName.indexOf('pusher_internal:') === 0 ||\n eventName.indexOf('pusher:') === 0\n ) {\n super.handleEvent(event);\n return;\n }\n this.handleEncryptedEvent(eventName, data);\n }\n\n private handleEncryptedEvent(event: string, data: any): void {\n if (!this.key) {\n Logger.debug(\n 'Received encrypted event before key has been retrieved from the authEndpoint'\n );\n return;\n }\n if (!data.ciphertext || !data.nonce) {\n Logger.error(\n 'Unexpected format for encrypted event, expected object with `ciphertext` and `nonce` fields, got: ' +\n data\n );\n return;\n }\n let cipherText = decodeBase64(data.ciphertext);\n if (cipherText.length < this.nacl.secretbox.overheadLength) {\n Logger.error(\n `Expected encrypted event ciphertext length to be ${this.nacl.secretbox.overheadLength}, got: ${cipherText.length}`\n );\n return;\n }\n let nonce = decodeBase64(data.nonce);\n if (nonce.length < this.nacl.secretbox.nonceLength) {\n Logger.error(\n `Expected encrypted event nonce length to be ${this.nacl.secretbox.nonceLength}, got: ${nonce.length}`\n );\n return;\n }\n\n let bytes = this.nacl.secretbox.open(cipherText, nonce, this.key);\n if (bytes === null) {\n Logger.debug(\n 'Failed to decrypt an event, probably because it was encrypted with a different key. Fetching a new key from the authEndpoint...'\n );\n // Try a single time to retrieve a new auth key and decrypt the event with it\n // If this fails, a new key will be requested when a new message is received\n this.authorize(this.pusher.connection.socket_id, (error, authData) => {\n if (error) {\n Logger.error(\n `Failed to make a request to the authEndpoint: ${authData}. Unable to fetch new key, so dropping encrypted event`\n );\n return;\n }\n bytes = this.nacl.secretbox.open(cipherText, nonce, this.key);\n if (bytes === null) {\n Logger.error(\n `Failed to decrypt event with new key. Dropping encrypted event`\n );\n return;\n }\n this.emit(event, this.getDataToEmit(bytes));\n return;\n });\n return;\n }\n this.emit(event, this.getDataToEmit(bytes));\n }\n\n // Try and parse the decrypted bytes as JSON. If we can't parse it, just\n // return the utf-8 string\n getDataToEmit(bytes: Uint8Array): string {\n let raw = encodeUTF8(bytes);\n try {\n return JSON.parse(raw);\n } catch {\n return raw;\n }\n }\n}\n","import { default as EventsDispatcher } from '../events/dispatcher';\nimport { OneOffTimer as Timer } from '../utils/timers';\nimport { Config } from '../config';\nimport Logger from '../logger';\nimport HandshakePayload from './handshake/handshake_payload';\nimport Connection from './connection';\nimport Strategy from '../strategies/strategy';\nimport StrategyRunner from '../strategies/strategy_runner';\nimport * as Collections from '../utils/collections';\nimport Timeline from '../timeline/timeline';\nimport ConnectionManagerOptions from './connection_manager_options';\nimport Runtime from 'runtime';\n\nimport {\n ErrorCallbacks,\n HandshakeCallbacks,\n ConnectionCallbacks\n} from './callbacks';\nimport Action from './protocol/action';\n\n/** Manages connection to Pusher.\n *\n * Uses a strategy (currently only default), timers and network availability\n * info to establish a connection and export its state. In case of failures,\n * manages reconnection attempts.\n *\n * Exports state changes as following events:\n * - \"state_change\", { previous: p, current: state }\n * - state\n *\n * States:\n * - initialized - initial state, never transitioned to\n * - connecting - connection is being established\n * - connected - connection has been fully established\n * - disconnected - on requested disconnection\n * - unavailable - after connection timeout or when there's no network\n * - failed - when the connection strategy is not supported\n *\n * Options:\n * - unavailableTimeout - time to transition to unavailable state\n * - activityTimeout - time after which ping message should be sent\n * - pongTimeout - time for Pusher to respond with pong before reconnecting\n *\n * @param {String} key application key\n * @param {Object} options\n */\nexport default class ConnectionManager extends EventsDispatcher {\n key: string;\n options: ConnectionManagerOptions;\n state: string;\n connection: Connection;\n usingTLS: boolean;\n timeline: Timeline;\n socket_id: string;\n unavailableTimer: Timer;\n activityTimer: Timer;\n retryTimer: Timer;\n activityTimeout: number;\n strategy: Strategy;\n runner: StrategyRunner;\n errorCallbacks: ErrorCallbacks;\n handshakeCallbacks: HandshakeCallbacks;\n connectionCallbacks: ConnectionCallbacks;\n\n constructor(key: string, options: ConnectionManagerOptions) {\n super();\n this.state = 'initialized';\n this.connection = null;\n\n this.key = key;\n this.options = options;\n this.timeline = this.options.timeline;\n this.usingTLS = this.options.useTLS;\n\n this.errorCallbacks = this.buildErrorCallbacks();\n this.connectionCallbacks = this.buildConnectionCallbacks(\n this.errorCallbacks\n );\n this.handshakeCallbacks = this.buildHandshakeCallbacks(this.errorCallbacks);\n\n var Network = Runtime.getNetwork();\n\n Network.bind('online', () => {\n this.timeline.info({ netinfo: 'online' });\n if (this.state === 'connecting' || this.state === 'unavailable') {\n this.retryIn(0);\n }\n });\n Network.bind('offline', () => {\n this.timeline.info({ netinfo: 'offline' });\n if (this.connection) {\n this.sendActivityCheck();\n }\n });\n\n this.updateStrategy();\n }\n\n switchCluster(key: string) {\n this.key = key;\n // This ensures that the new config coming from\n // pusher instance are taken into account\n // such as appKey and cluster\n this.updateStrategy();\n this.retryIn(0);\n }\n\n /** Establishes a connection to Pusher.\n *\n * Does nothing when connection is already established. See top-level doc\n * to find events emitted on connection attempts.\n */\n connect() {\n if (this.connection || this.runner) {\n return;\n }\n if (!this.strategy.isSupported()) {\n this.updateState('failed');\n return;\n }\n this.updateState('connecting');\n this.startConnecting();\n this.setUnavailableTimer();\n }\n\n /** Sends raw data.\n *\n * @param {String} data\n */\n send(data) {\n if (this.connection) {\n return this.connection.send(data);\n } else {\n return false;\n }\n }\n\n /** Sends an event.\n *\n * @param {String} name\n * @param {String} data\n * @param {String} [channel]\n * @returns {Boolean} whether message was sent or not\n */\n send_event(name: string, data: any, channel?: string) {\n if (this.connection) {\n return this.connection.send_event(name, data, channel);\n } else {\n return false;\n }\n }\n\n /** Closes the connection. */\n disconnect() {\n this.disconnectInternally();\n this.updateState('disconnected');\n }\n\n isUsingTLS() {\n return this.usingTLS;\n }\n\n private startConnecting() {\n var callback = (error, handshake) => {\n if (error) {\n this.runner = this.strategy.connect(0, callback);\n } else {\n if (handshake.action === 'error') {\n this.emit('error', {\n type: 'HandshakeError',\n error: handshake.error\n });\n this.timeline.error({ handshakeError: handshake.error });\n } else {\n this.abortConnecting(); // we don't support switching connections yet\n this.handshakeCallbacks[handshake.action](handshake);\n }\n }\n };\n this.runner = this.strategy.connect(0, callback);\n }\n\n private abortConnecting() {\n if (this.runner) {\n this.runner.abort();\n this.runner = null;\n }\n }\n\n private disconnectInternally() {\n this.abortConnecting();\n this.clearRetryTimer();\n this.clearUnavailableTimer();\n if (this.connection) {\n var connection = this.abandonConnection();\n connection.close();\n }\n }\n\n private updateStrategy() {\n this.strategy = this.options.getStrategy({\n key: this.key,\n timeline: this.timeline,\n useTLS: this.usingTLS\n });\n }\n\n private retryIn(delay) {\n this.timeline.info({ action: 'retry', delay: delay });\n if (delay > 0) {\n this.emit('connecting_in', Math.round(delay / 1000));\n }\n this.retryTimer = new Timer(delay || 0, () => {\n this.disconnectInternally();\n this.connect();\n });\n }\n\n private clearRetryTimer() {\n if (this.retryTimer) {\n this.retryTimer.ensureAborted();\n this.retryTimer = null;\n }\n }\n\n private setUnavailableTimer() {\n this.unavailableTimer = new Timer(this.options.unavailableTimeout, () => {\n this.updateState('unavailable');\n });\n }\n\n private clearUnavailableTimer() {\n if (this.unavailableTimer) {\n this.unavailableTimer.ensureAborted();\n }\n }\n\n private sendActivityCheck() {\n this.stopActivityCheck();\n this.connection.ping();\n // wait for pong response\n this.activityTimer = new Timer(this.options.pongTimeout, () => {\n this.timeline.error({ pong_timed_out: this.options.pongTimeout });\n this.retryIn(0);\n });\n }\n\n private resetActivityCheck() {\n this.stopActivityCheck();\n // send ping after inactivity\n if (this.connection && !this.connection.handlesActivityChecks()) {\n this.activityTimer = new Timer(this.activityTimeout, () => {\n this.sendActivityCheck();\n });\n }\n }\n\n private stopActivityCheck() {\n if (this.activityTimer) {\n this.activityTimer.ensureAborted();\n }\n }\n\n private buildConnectionCallbacks(\n errorCallbacks: ErrorCallbacks\n ): ConnectionCallbacks {\n return Collections.extend({}, errorCallbacks, {\n message: message => {\n // includes pong messages from server\n this.resetActivityCheck();\n this.emit('message', message);\n },\n ping: () => {\n this.send_event('pusher:pong', {});\n },\n activity: () => {\n this.resetActivityCheck();\n },\n error: error => {\n // just emit error to user - socket will already be closed by browser\n this.emit('error', error);\n },\n closed: () => {\n this.abandonConnection();\n if (this.shouldRetry()) {\n this.retryIn(1000);\n }\n }\n });\n }\n\n private buildHandshakeCallbacks(\n errorCallbacks: ErrorCallbacks\n ): HandshakeCallbacks {\n return Collections.extend({}, errorCallbacks, {\n connected: (handshake: HandshakePayload) => {\n this.activityTimeout = Math.min(\n this.options.activityTimeout,\n handshake.activityTimeout,\n handshake.connection.activityTimeout || Infinity\n );\n this.clearUnavailableTimer();\n this.setConnection(handshake.connection);\n this.socket_id = this.connection.id;\n this.updateState('connected', { socket_id: this.socket_id });\n }\n });\n }\n\n private buildErrorCallbacks(): ErrorCallbacks {\n let withErrorEmitted = callback => {\n return (result: Action | HandshakePayload) => {\n if (result.error) {\n this.emit('error', { type: 'WebSocketError', error: result.error });\n }\n callback(result);\n };\n };\n\n return {\n tls_only: withErrorEmitted(() => {\n this.usingTLS = true;\n this.updateStrategy();\n this.retryIn(0);\n }),\n refused: withErrorEmitted(() => {\n this.disconnect();\n }),\n backoff: withErrorEmitted(() => {\n this.retryIn(1000);\n }),\n retry: withErrorEmitted(() => {\n this.retryIn(0);\n })\n };\n }\n\n private setConnection(connection) {\n this.connection = connection;\n for (var event in this.connectionCallbacks) {\n this.connection.bind(event, this.connectionCallbacks[event]);\n }\n this.resetActivityCheck();\n }\n\n private abandonConnection() {\n if (!this.connection) {\n return;\n }\n this.stopActivityCheck();\n for (var event in this.connectionCallbacks) {\n this.connection.unbind(event, this.connectionCallbacks[event]);\n }\n var connection = this.connection;\n this.connection = null;\n return connection;\n }\n\n private updateState(newState: string, data?: any) {\n var previousState = this.state;\n this.state = newState;\n if (previousState !== newState) {\n var newStateDescription = newState;\n if (newStateDescription === 'connected') {\n newStateDescription += ' with new socket ID ' + data.socket_id;\n }\n Logger.debug(\n 'State changed',\n previousState + ' -> ' + newStateDescription\n );\n this.timeline.info({ state: newState, params: data });\n this.emit('state_change', { previous: previousState, current: newState });\n this.emit(newState, data);\n }\n }\n\n private shouldRetry(): boolean {\n return this.state === 'connecting' || this.state === 'connected';\n }\n}\n","import Channel from './channel';\nimport * as Collections from '../utils/collections';\nimport ChannelTable from './channel_table';\nimport Factory from '../utils/factory';\nimport Pusher from '../pusher';\nimport Logger from '../logger';\nimport * as Errors from '../errors';\nimport urlStore from '../utils/url_store';\n\n/** Handles a channel map. */\nexport default class Channels {\n channels: ChannelTable;\n\n constructor() {\n this.channels = {};\n }\n\n /** Creates or retrieves an existing channel by its name.\n *\n * @param {String} name\n * @param {Pusher} pusher\n * @return {Channel}\n */\n add(name: string, pusher: Pusher) {\n if (!this.channels[name]) {\n this.channels[name] = createChannel(name, pusher);\n }\n return this.channels[name];\n }\n\n /** Returns a list of all channels\n *\n * @return {Array}\n */\n all(): Channel[] {\n return Collections.values(this.channels);\n }\n\n /** Finds a channel by its name.\n *\n * @param {String} name\n * @return {Channel} channel or null if it doesn't exist\n */\n find(name: string) {\n return this.channels[name];\n }\n\n /** Removes a channel from the map.\n *\n * @param {String} name\n */\n remove(name: string) {\n var channel = this.channels[name];\n delete this.channels[name];\n return channel;\n }\n\n /** Proxies disconnection signal to all channels. */\n disconnect() {\n Collections.objectApply(this.channels, function(channel) {\n channel.disconnect();\n });\n }\n}\n\nfunction createChannel(name: string, pusher: Pusher): Channel {\n if (name.indexOf('private-encrypted-') === 0) {\n if (pusher.config.nacl) {\n return Factory.createEncryptedChannel(name, pusher, pusher.config.nacl);\n }\n let errMsg =\n 'Tried to subscribe to a private-encrypted- channel but no nacl implementation available';\n let suffix = urlStore.buildLogSuffix('encryptedChannelSupport');\n throw new Errors.UnsupportedFeature(`${errMsg}. ${suffix}`);\n } else if (name.indexOf('private-') === 0) {\n return Factory.createPrivateChannel(name, pusher);\n } else if (name.indexOf('presence-') === 0) {\n return Factory.createPresenceChannel(name, pusher);\n } else if (name.indexOf('#') === 0) {\n throw new Errors.BadChannelName(\n 'Cannot create a channel with name \"' + name + '\".'\n );\n } else {\n return Factory.createChannel(name, pusher);\n }\n}\n","import AssistantToTheTransportManager from '../transports/assistant_to_the_transport_manager';\nimport PingDelayOptions from '../transports/ping_delay_options';\nimport Transport from '../transports/transport';\nimport TransportManager from '../transports/transport_manager';\nimport Handshake from '../connection/handshake';\nimport TransportConnection from '../transports/transport_connection';\nimport SocketHooks from '../http/socket_hooks';\nimport HTTPSocket from '../http/http_socket';\n\nimport Timeline from '../timeline/timeline';\nimport {\n default as TimelineSender,\n TimelineSenderOptions\n} from '../timeline/timeline_sender';\nimport PresenceChannel from '../channels/presence_channel';\nimport PrivateChannel from '../channels/private_channel';\nimport EncryptedChannel from '../channels/encrypted_channel';\nimport Channel from '../channels/channel';\nimport ConnectionManager from '../connection/connection_manager';\nimport ConnectionManagerOptions from '../connection/connection_manager_options';\nimport Ajax from '../http/ajax';\nimport Channels from '../channels/channels';\nimport Pusher from '../pusher';\nimport { Config } from '../config';\nimport * as nacl from 'tweetnacl';\n\nvar Factory = {\n createChannels(): Channels {\n return new Channels();\n },\n\n createConnectionManager(\n key: string,\n options: ConnectionManagerOptions\n ): ConnectionManager {\n return new ConnectionManager(key, options);\n },\n\n createChannel(name: string, pusher: Pusher): Channel {\n return new Channel(name, pusher);\n },\n\n createPrivateChannel(name: string, pusher: Pusher): PrivateChannel {\n return new PrivateChannel(name, pusher);\n },\n\n createPresenceChannel(name: string, pusher: Pusher): PresenceChannel {\n return new PresenceChannel(name, pusher);\n },\n\n createEncryptedChannel(\n name: string,\n pusher: Pusher,\n nacl: nacl\n ): EncryptedChannel {\n return new EncryptedChannel(name, pusher, nacl);\n },\n\n createTimelineSender(timeline: Timeline, options: TimelineSenderOptions) {\n return new TimelineSender(timeline, options);\n },\n\n createHandshake(\n transport: TransportConnection,\n callback: (HandshakePayload) => void\n ): Handshake {\n return new Handshake(transport, callback);\n },\n\n createAssistantToTheTransportManager(\n manager: TransportManager,\n transport: Transport,\n options: PingDelayOptions\n ): AssistantToTheTransportManager {\n return new AssistantToTheTransportManager(manager, transport, options);\n }\n};\n\nexport default Factory;\n","import AssistantToTheTransportManager from './assistant_to_the_transport_manager';\nimport Transport from './transport';\nimport PingDelayOptions from './ping_delay_options';\nimport Factory from '../utils/factory';\n\nexport interface TransportManagerOptions extends PingDelayOptions {\n lives?: number;\n}\n\n/** Keeps track of the number of lives left for a transport.\n *\n * In the beginning of a session, transports may be assigned a number of\n * lives. When an AssistantToTheTransportManager instance reports a transport\n * connection closed uncleanly, the transport loses a life. When the number\n * of lives drops to zero, the transport gets disabled by its manager.\n *\n * @param {Object} options\n */\nexport default class TransportManager {\n options: TransportManagerOptions;\n livesLeft: number;\n\n constructor(options: TransportManagerOptions) {\n this.options = options || {};\n this.livesLeft = this.options.lives || Infinity;\n }\n\n /** Creates a assistant for the transport.\n *\n * @param {Transport} transport\n * @returns {AssistantToTheTransportManager}\n */\n getAssistant(transport: Transport): AssistantToTheTransportManager {\n return Factory.createAssistantToTheTransportManager(this, transport, {\n minPingDelay: this.options.minPingDelay,\n maxPingDelay: this.options.maxPingDelay\n });\n }\n\n /** Returns whether the transport has any lives left.\n *\n * @returns {Boolean}\n */\n isAlive(): boolean {\n return this.livesLeft > 0;\n }\n\n /** Takes one life from the transport. */\n reportDeath() {\n this.livesLeft -= 1;\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport { OneOffTimer as Timer } from '../utils/timers';\nimport Strategy from './strategy';\nimport StrategyOptions from './strategy_options';\n\n/** Loops through strategies with optional timeouts.\n *\n * Options:\n * - loop - whether it should loop through the substrategy list\n * - timeout - initial timeout for a single substrategy\n * - timeoutLimit - maximum timeout\n *\n * @param {Strategy[]} strategies\n * @param {Object} options\n */\nexport default class SequentialStrategy implements Strategy {\n strategies: Strategy[];\n loop: boolean;\n failFast: boolean;\n timeout: number;\n timeoutLimit: number;\n\n constructor(strategies: Strategy[], options: StrategyOptions) {\n this.strategies = strategies;\n this.loop = Boolean(options.loop);\n this.failFast = Boolean(options.failFast);\n this.timeout = options.timeout;\n this.timeoutLimit = options.timeoutLimit;\n }\n\n isSupported(): boolean {\n return Collections.any(this.strategies, Util.method('isSupported'));\n }\n\n connect(minPriority: number, callback: Function) {\n var strategies = this.strategies;\n var current = 0;\n var timeout = this.timeout;\n var runner = null;\n\n var tryNextStrategy = (error, handshake) => {\n if (handshake) {\n callback(null, handshake);\n } else {\n current = current + 1;\n if (this.loop) {\n current = current % strategies.length;\n }\n\n if (current < strategies.length) {\n if (timeout) {\n timeout = timeout * 2;\n if (this.timeoutLimit) {\n timeout = Math.min(timeout, this.timeoutLimit);\n }\n }\n runner = this.tryStrategy(\n strategies[current],\n minPriority,\n { timeout, failFast: this.failFast },\n tryNextStrategy\n );\n } else {\n callback(true);\n }\n }\n };\n\n runner = this.tryStrategy(\n strategies[current],\n minPriority,\n { timeout: timeout, failFast: this.failFast },\n tryNextStrategy\n );\n\n return {\n abort: function() {\n runner.abort();\n },\n forceMinPriority: function(p) {\n minPriority = p;\n if (runner) {\n runner.forceMinPriority(p);\n }\n }\n };\n }\n\n private tryStrategy(\n strategy: Strategy,\n minPriority: number,\n options: StrategyOptions,\n callback: Function\n ) {\n var timer = null;\n var runner = null;\n\n if (options.timeout > 0) {\n timer = new Timer(options.timeout, function() {\n runner.abort();\n callback(true);\n });\n }\n\n runner = strategy.connect(minPriority, function(error, handshake) {\n if (error && timer && timer.isRunning() && !options.failFast) {\n // advance to the next strategy after the timeout\n return;\n }\n if (timer) {\n timer.ensureAborted();\n }\n callback(error, handshake);\n });\n\n return {\n abort: function() {\n if (timer) {\n timer.ensureAborted();\n }\n runner.abort();\n },\n forceMinPriority: function(p) {\n runner.forceMinPriority(p);\n }\n };\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport Strategy from './strategy';\n\n/** Launches all substrategies and emits prioritized connected transports.\n *\n * @param {Array} strategies\n */\nexport default class BestConnectedEverStrategy implements Strategy {\n strategies: Strategy[];\n\n constructor(strategies: Strategy[]) {\n this.strategies = strategies;\n }\n\n isSupported(): boolean {\n return Collections.any(this.strategies, Util.method('isSupported'));\n }\n\n connect(minPriority: number, callback: Function) {\n return connect(this.strategies, minPriority, function(i, runners) {\n return function(error, handshake) {\n runners[i].error = error;\n if (error) {\n if (allRunnersFailed(runners)) {\n callback(true);\n }\n return;\n }\n Collections.apply(runners, function(runner) {\n runner.forceMinPriority(handshake.transport.priority);\n });\n callback(null, handshake);\n };\n });\n }\n}\n\n/** Connects to all strategies in parallel.\n *\n * Callback builder should be a function that takes two arguments: index\n * and a list of runners. It should return another function that will be\n * passed to the substrategy with given index. Runners can be aborted using\n * abortRunner(s) functions from this class.\n *\n * @param {Array} strategies\n * @param {Function} callbackBuilder\n * @return {Object} strategy runner\n */\nfunction connect(\n strategies: Strategy[],\n minPriority: number,\n callbackBuilder: Function\n) {\n var runners = Collections.map(strategies, function(strategy, i, _, rs) {\n return strategy.connect(minPriority, callbackBuilder(i, rs));\n });\n return {\n abort: function() {\n Collections.apply(runners, abortRunner);\n },\n forceMinPriority: function(p) {\n Collections.apply(runners, function(runner) {\n runner.forceMinPriority(p);\n });\n }\n };\n}\n\nfunction allRunnersFailed(runners): boolean {\n return Collections.all(runners, function(runner) {\n return Boolean(runner.error);\n });\n}\n\nfunction abortRunner(runner) {\n if (!runner.error && !runner.aborted) {\n runner.abort();\n runner.aborted = true;\n }\n}\n","import Util from '../util';\nimport Runtime from 'runtime';\nimport Strategy from './strategy';\nimport SequentialStrategy from './sequential_strategy';\nimport StrategyOptions from './strategy_options';\nimport TransportStrategy from './transport_strategy';\nimport Timeline from '../timeline/timeline';\nimport * as Collections from '../utils/collections';\n\nexport interface TransportStrategyDictionary {\n [key: string]: TransportStrategy;\n}\n\n/** Caches the last successful transport and, after the first few attempts,\n * uses the cached transport for subsequent attempts.\n *\n * @param {Strategy} strategy\n * @param {Object} transports\n * @param {Object} options\n */\nexport default class WebSocketPrioritizedCachedStrategy implements Strategy {\n strategy: Strategy;\n transports: TransportStrategyDictionary;\n ttl: number;\n usingTLS: boolean;\n timeline: Timeline;\n\n constructor(\n strategy: Strategy,\n transports: TransportStrategyDictionary,\n options: StrategyOptions\n ) {\n this.strategy = strategy;\n this.transports = transports;\n this.ttl = options.ttl || 1800 * 1000;\n this.usingTLS = options.useTLS;\n this.timeline = options.timeline;\n }\n\n isSupported(): boolean {\n return this.strategy.isSupported();\n }\n\n connect(minPriority: number, callback: Function) {\n var usingTLS = this.usingTLS;\n var info = fetchTransportCache(usingTLS);\n var cacheSkipCount = info && info.cacheSkipCount ? info.cacheSkipCount : 0;\n\n var strategies = [this.strategy];\n if (info && info.timestamp + this.ttl >= Util.now()) {\n var transport = this.transports[info.transport];\n if (transport) {\n if (['ws', 'wss'].includes(info.transport) || cacheSkipCount > 3) {\n this.timeline.info({\n cached: true,\n transport: info.transport,\n latency: info.latency\n });\n strategies.push(\n new SequentialStrategy([transport], {\n timeout: info.latency * 2 + 1000,\n failFast: true\n })\n );\n } else {\n cacheSkipCount++;\n }\n }\n }\n\n var startTimestamp = Util.now();\n var runner = strategies\n .pop()\n .connect(minPriority, function cb(error, handshake) {\n if (error) {\n flushTransportCache(usingTLS);\n if (strategies.length > 0) {\n startTimestamp = Util.now();\n runner = strategies.pop().connect(minPriority, cb);\n } else {\n callback(error);\n }\n } else {\n storeTransportCache(\n usingTLS,\n handshake.transport.name,\n Util.now() - startTimestamp,\n cacheSkipCount\n );\n callback(null, handshake);\n }\n });\n\n return {\n abort: function() {\n runner.abort();\n },\n forceMinPriority: function(p) {\n minPriority = p;\n if (runner) {\n runner.forceMinPriority(p);\n }\n }\n };\n }\n}\n\nfunction getTransportCacheKey(usingTLS: boolean): string {\n return 'pusherTransport' + (usingTLS ? 'TLS' : 'NonTLS');\n}\n\nfunction fetchTransportCache(usingTLS: boolean): any {\n var storage = Runtime.getLocalStorage();\n if (storage) {\n try {\n var serializedCache = storage[getTransportCacheKey(usingTLS)];\n if (serializedCache) {\n return JSON.parse(serializedCache);\n }\n } catch (e) {\n flushTransportCache(usingTLS);\n }\n }\n return null;\n}\n\nfunction storeTransportCache(\n usingTLS: boolean,\n transport: TransportStrategy,\n latency: number,\n cacheSkipCount: number\n) {\n var storage = Runtime.getLocalStorage();\n if (storage) {\n try {\n storage[getTransportCacheKey(usingTLS)] = Collections.safeJSONStringify({\n timestamp: Util.now(),\n transport: transport,\n latency: latency,\n cacheSkipCount: cacheSkipCount\n });\n } catch (e) {\n // catch over quota exceptions raised by localStorage\n }\n }\n}\n\nfunction flushTransportCache(usingTLS: boolean) {\n var storage = Runtime.getLocalStorage();\n if (storage) {\n try {\n delete storage[getTransportCacheKey(usingTLS)];\n } catch (e) {\n // catch exceptions raised by localStorage\n }\n }\n}\n","import { OneOffTimer as Timer } from '../utils/timers';\nimport Strategy from './strategy';\nimport StrategyOptions from './strategy_options';\n\n/** Runs substrategy after specified delay.\n *\n * Options:\n * - delay - time in miliseconds to delay the substrategy attempt\n *\n * @param {Strategy} strategy\n * @param {Object} options\n */\nexport default class DelayedStrategy implements Strategy {\n strategy: Strategy;\n options: { delay: number };\n\n constructor(strategy: Strategy, { delay: number }) {\n this.strategy = strategy;\n this.options = { delay: number };\n }\n\n isSupported(): boolean {\n return this.strategy.isSupported();\n }\n\n connect(minPriority: number, callback: Function) {\n var strategy = this.strategy;\n var runner;\n var timer = new Timer(this.options.delay, function() {\n runner = strategy.connect(minPriority, callback);\n });\n\n return {\n abort: function() {\n timer.ensureAborted();\n if (runner) {\n runner.abort();\n }\n },\n forceMinPriority: function(p) {\n minPriority = p;\n if (runner) {\n runner.forceMinPriority(p);\n }\n }\n };\n }\n}\n","import Strategy from './strategy';\nimport StrategyRunner from './strategy_runner';\n\n/** Proxies method calls to one of substrategies basing on the test function.\n *\n * @param {Function} test\n * @param {Strategy} trueBranch strategy used when test returns true\n * @param {Strategy} falseBranch strategy used when test returns false\n */\nexport default class IfStrategy implements Strategy {\n test: () => boolean;\n trueBranch: Strategy;\n falseBranch: Strategy;\n\n constructor(\n test: () => boolean,\n trueBranch: Strategy,\n falseBranch: Strategy\n ) {\n this.test = test;\n this.trueBranch = trueBranch;\n this.falseBranch = falseBranch;\n }\n\n isSupported(): boolean {\n var branch = this.test() ? this.trueBranch : this.falseBranch;\n return branch.isSupported();\n }\n\n connect(minPriority: number, callback: Function): StrategyRunner {\n var branch = this.test() ? this.trueBranch : this.falseBranch;\n return branch.connect(minPriority, callback);\n }\n}\n","import Strategy from './strategy';\nimport StrategyRunner from './strategy_runner';\n\n/** Launches the substrategy and terminates on the first open connection.\n *\n * @param {Strategy} strategy\n */\nexport default class FirstConnectedStrategy implements Strategy {\n strategy: Strategy;\n\n constructor(strategy: Strategy) {\n this.strategy = strategy;\n }\n\n isSupported(): boolean {\n return this.strategy.isSupported();\n }\n\n connect(minPriority: number, callback: Function): StrategyRunner {\n var runner = this.strategy.connect(minPriority, function(error, handshake) {\n if (handshake) {\n runner.abort();\n }\n callback(error, handshake);\n });\n return runner;\n }\n}\n","import * as Collections from 'core/utils/collections';\nimport TransportManager from 'core/transports/transport_manager';\nimport Strategy from 'core/strategies/strategy';\nimport SequentialStrategy from 'core/strategies/sequential_strategy';\nimport BestConnectedEverStrategy from 'core/strategies/best_connected_ever_strategy';\nimport WebSocketPrioritizedCachedStrategy, {\n TransportStrategyDictionary\n} from 'core/strategies/websocket_prioritized_cached_strategy';\nimport DelayedStrategy from 'core/strategies/delayed_strategy';\nimport IfStrategy from 'core/strategies/if_strategy';\nimport FirstConnectedStrategy from 'core/strategies/first_connected_strategy';\nimport { Config } from 'core/config';\nimport StrategyOptions from 'core/strategies/strategy_options';\n\nfunction testSupportsStrategy(strategy: Strategy) {\n return function() {\n return strategy.isSupported();\n };\n}\n\nvar getDefaultStrategy = function(\n config: Config,\n baseOptions: StrategyOptions,\n defineTransport: Function\n): Strategy {\n var definedTransports = {};\n\n function defineTransportStrategy(\n name: string,\n type: string,\n priority: number,\n options: StrategyOptions,\n manager?: TransportManager\n ) {\n var transport = defineTransport(\n config,\n name,\n type,\n priority,\n options,\n manager\n );\n\n definedTransports[name] = transport;\n\n return transport;\n }\n\n var ws_options: StrategyOptions = Object.assign({}, baseOptions, {\n hostNonTLS: config.wsHost + ':' + config.wsPort,\n hostTLS: config.wsHost + ':' + config.wssPort,\n httpPath: config.wsPath\n });\n var wss_options: StrategyOptions = Collections.extend({}, ws_options, {\n useTLS: true\n });\n var http_options: StrategyOptions = Object.assign({}, baseOptions, {\n hostNonTLS: config.httpHost + ':' + config.httpPort,\n hostTLS: config.httpHost + ':' + config.httpsPort,\n httpPath: config.httpPath\n });\n var timeouts = {\n loop: true,\n timeout: 15000,\n timeoutLimit: 60000\n };\n\n var ws_manager = new TransportManager({\n minPingDelay: 10000,\n maxPingDelay: config.activityTimeout\n });\n var streaming_manager = new TransportManager({\n lives: 2,\n minPingDelay: 10000,\n maxPingDelay: config.activityTimeout\n });\n\n var ws_transport = defineTransportStrategy(\n 'ws',\n 'ws',\n 3,\n ws_options,\n ws_manager\n );\n var wss_transport = defineTransportStrategy(\n 'wss',\n 'ws',\n 3,\n wss_options,\n ws_manager\n );\n var xhr_streaming_transport = defineTransportStrategy(\n 'xhr_streaming',\n 'xhr_streaming',\n 1,\n http_options,\n streaming_manager\n );\n var xhr_polling_transport = defineTransportStrategy(\n 'xhr_polling',\n 'xhr_polling',\n 1,\n http_options\n );\n\n var ws_loop = new SequentialStrategy([ws_transport], timeouts);\n var wss_loop = new SequentialStrategy([wss_transport], timeouts);\n var streaming_loop = new SequentialStrategy(\n [xhr_streaming_transport],\n timeouts\n );\n var polling_loop = new SequentialStrategy([xhr_polling_transport], timeouts);\n\n var http_loop = new SequentialStrategy(\n [\n new IfStrategy(\n testSupportsStrategy(streaming_loop),\n new BestConnectedEverStrategy([\n streaming_loop,\n new DelayedStrategy(polling_loop, { delay: 4000 })\n ]),\n polling_loop\n )\n ],\n timeouts\n );\n\n var wsStrategy;\n if (baseOptions.useTLS) {\n wsStrategy = new BestConnectedEverStrategy([\n ws_loop,\n new DelayedStrategy(http_loop, { delay: 2000 })\n ]);\n } else {\n wsStrategy = new BestConnectedEverStrategy([\n ws_loop,\n new DelayedStrategy(wss_loop, { delay: 2000 }),\n new DelayedStrategy(http_loop, { delay: 5000 })\n ]);\n }\n\n return new WebSocketPrioritizedCachedStrategy(\n new FirstConnectedStrategy(\n new IfStrategy(testSupportsStrategy(ws_transport), wsStrategy, http_loop)\n ),\n definedTransports,\n {\n ttl: 1800000,\n timeline: baseOptions.timeline,\n useTLS: baseOptions.useTLS\n }\n );\n};\n\nexport default getDefaultStrategy;\n","import Runtime from 'runtime';\nimport RequestHooks from './request_hooks';\nimport Ajax from './ajax';\nimport { default as EventsDispatcher } from '../events/dispatcher';\n\nconst MAX_BUFFER_LENGTH = 256 * 1024;\n\nexport default class HTTPRequest extends EventsDispatcher {\n hooks: RequestHooks;\n method: string;\n url: string;\n position: number;\n xhr: Ajax;\n unloader: Function;\n\n constructor(hooks: RequestHooks, method: string, url: string) {\n super();\n this.hooks = hooks;\n this.method = method;\n this.url = url;\n }\n\n start(payload?: any) {\n this.position = 0;\n this.xhr = this.hooks.getRequest(this);\n\n this.unloader = () => {\n this.close();\n };\n Runtime.addUnloadListener(this.unloader);\n\n this.xhr.open(this.method, this.url, true);\n\n if (this.xhr.setRequestHeader) {\n this.xhr.setRequestHeader('Content-Type', 'application/json'); // ReactNative doesn't set this header by default.\n }\n this.xhr.send(payload);\n }\n\n close() {\n if (this.unloader) {\n Runtime.removeUnloadListener(this.unloader);\n this.unloader = null;\n }\n if (this.xhr) {\n this.hooks.abortRequest(this.xhr);\n this.xhr = null;\n }\n }\n\n onChunk(status: number, data: any) {\n while (true) {\n var chunk = this.advanceBuffer(data);\n if (chunk) {\n this.emit('chunk', { status: status, data: chunk });\n } else {\n break;\n }\n }\n if (this.isBufferTooLong(data)) {\n this.emit('buffer_too_long');\n }\n }\n\n private advanceBuffer(buffer: any[]): any {\n var unreadData = buffer.slice(this.position);\n var endOfLinePosition = unreadData.indexOf('\\n');\n\n if (endOfLinePosition !== -1) {\n this.position += endOfLinePosition + 1;\n return unreadData.slice(0, endOfLinePosition);\n } else {\n // chunk is not finished yet, don't move the buffer pointer\n return null;\n }\n }\n\n private isBufferTooLong(buffer: any): boolean {\n return this.position === buffer.length && buffer.length > MAX_BUFFER_LENGTH;\n }\n}\n","enum State {\n CONNECTING = 0,\n OPEN = 1,\n CLOSED = 3\n}\n\nexport default State;\n","import URLLocation from './url_location';\nimport State from './state';\nimport Socket from '../socket';\nimport SocketHooks from './socket_hooks';\nimport Util from '../util';\nimport Ajax from './ajax';\nimport HTTPRequest from './http_request';\nimport Runtime from 'runtime';\n\nvar autoIncrement = 1;\n\nclass HTTPSocket implements Socket {\n hooks: SocketHooks;\n session: string;\n location: URLLocation;\n readyState: State;\n stream: HTTPRequest;\n\n onopen: () => void;\n onerror: (error: any) => void;\n onclose: (closeEvent: any) => void;\n onmessage: (message: any) => void;\n onactivity: () => void;\n\n constructor(hooks: SocketHooks, url: string) {\n this.hooks = hooks;\n this.session = randomNumber(1000) + '/' + randomString(8);\n this.location = getLocation(url);\n this.readyState = State.CONNECTING;\n this.openStream();\n }\n\n send(payload: any) {\n return this.sendRaw(JSON.stringify([payload]));\n }\n\n ping() {\n this.hooks.sendHeartbeat(this);\n }\n\n close(code: any, reason: any) {\n this.onClose(code, reason, true);\n }\n\n /** For internal use only */\n sendRaw(payload: any): boolean {\n if (this.readyState === State.OPEN) {\n try {\n Runtime.createSocketRequest(\n 'POST',\n getUniqueURL(getSendURL(this.location, this.session))\n ).start(payload);\n return true;\n } catch (e) {\n return false;\n }\n } else {\n return false;\n }\n }\n\n /** For internal use only */\n reconnect() {\n this.closeStream();\n this.openStream();\n }\n\n /** For internal use only */\n onClose(code, reason, wasClean) {\n this.closeStream();\n this.readyState = State.CLOSED;\n if (this.onclose) {\n this.onclose({\n code: code,\n reason: reason,\n wasClean: wasClean\n });\n }\n }\n\n private onChunk(chunk) {\n if (chunk.status !== 200) {\n return;\n }\n if (this.readyState === State.OPEN) {\n this.onActivity();\n }\n\n var payload;\n var type = chunk.data.slice(0, 1);\n switch (type) {\n case 'o':\n payload = JSON.parse(chunk.data.slice(1) || '{}');\n this.onOpen(payload);\n break;\n case 'a':\n payload = JSON.parse(chunk.data.slice(1) || '[]');\n for (var i = 0; i < payload.length; i++) {\n this.onEvent(payload[i]);\n }\n break;\n case 'm':\n payload = JSON.parse(chunk.data.slice(1) || 'null');\n this.onEvent(payload);\n break;\n case 'h':\n this.hooks.onHeartbeat(this);\n break;\n case 'c':\n payload = JSON.parse(chunk.data.slice(1) || '[]');\n this.onClose(payload[0], payload[1], true);\n break;\n }\n }\n\n private onOpen(options) {\n if (this.readyState === State.CONNECTING) {\n if (options && options.hostname) {\n this.location.base = replaceHost(this.location.base, options.hostname);\n }\n this.readyState = State.OPEN;\n\n if (this.onopen) {\n this.onopen();\n }\n } else {\n this.onClose(1006, 'Server lost session', true);\n }\n }\n\n private onEvent(event) {\n if (this.readyState === State.OPEN && this.onmessage) {\n this.onmessage({ data: event });\n }\n }\n\n private onActivity() {\n if (this.onactivity) {\n this.onactivity();\n }\n }\n\n private onError(error) {\n if (this.onerror) {\n this.onerror(error);\n }\n }\n\n private openStream() {\n this.stream = Runtime.createSocketRequest(\n 'POST',\n getUniqueURL(this.hooks.getReceiveURL(this.location, this.session))\n );\n\n this.stream.bind('chunk', chunk => {\n this.onChunk(chunk);\n });\n this.stream.bind('finished', status => {\n this.hooks.onFinished(this, status);\n });\n this.stream.bind('buffer_too_long', () => {\n this.reconnect();\n });\n\n try {\n this.stream.start();\n } catch (error) {\n Util.defer(() => {\n this.onError(error);\n this.onClose(1006, 'Could not start streaming', false);\n });\n }\n }\n\n private closeStream() {\n if (this.stream) {\n this.stream.unbind_all();\n this.stream.close();\n this.stream = null;\n }\n }\n}\n\nfunction getLocation(url): URLLocation {\n var parts = /([^\\?]*)\\/*(\\??.*)/.exec(url);\n return {\n base: parts[1],\n queryString: parts[2]\n };\n}\n\nfunction getSendURL(url: URLLocation, session: string): string {\n return url.base + '/' + session + '/xhr_send';\n}\n\nfunction getUniqueURL(url: string): string {\n var separator = url.indexOf('?') === -1 ? '?' : '&';\n return url + separator + 't=' + +new Date() + '&n=' + autoIncrement++;\n}\n\nfunction replaceHost(url: string, hostname: string): string {\n var urlParts = /(https?:\\/\\/)([^\\/:]+)((\\/|:)?.*)/.exec(url);\n return urlParts[1] + hostname + urlParts[3];\n}\n\nfunction randomNumber(max: number): number {\n return Runtime.randomInt(max);\n}\n\nfunction randomString(length: number): string {\n var result = [];\n\n for (var i = 0; i < length; i++) {\n result.push(randomNumber(32).toString(32));\n }\n\n return result.join('');\n}\n\nexport default HTTPSocket;\n","import SocketHooks from './socket_hooks';\nimport HTTPSocket from './http_socket';\n\nvar hooks: SocketHooks = {\n getReceiveURL: function(url, session) {\n return url.base + '/' + session + '/xhr_streaming' + url.queryString;\n },\n onHeartbeat: function(socket) {\n socket.sendRaw('[]');\n },\n sendHeartbeat: function(socket) {\n socket.sendRaw('[]');\n },\n onFinished: function(socket, status) {\n socket.onClose(1006, 'Connection interrupted (' + status + ')', false);\n }\n};\n\nexport default hooks;\n","import SocketHooks from './socket_hooks';\nimport URLLocation from './url_location';\nimport HTTPSocket from './http_socket';\n\nvar hooks: SocketHooks = {\n getReceiveURL: function(url: URLLocation, session: string): string {\n return url.base + '/' + session + '/xhr' + url.queryString;\n },\n onHeartbeat: function() {\n // next HTTP request will reset server's activity timer\n },\n sendHeartbeat: function(socket) {\n socket.sendRaw('[]');\n },\n onFinished: function(socket, status) {\n if (status === 200) {\n socket.reconnect();\n } else {\n socket.onClose(1006, 'Connection interrupted (' + status + ')', false);\n }\n }\n};\n\nexport default hooks;\n","import HTTPRequest from 'core/http/http_request';\nimport RequestHooks from 'core/http/request_hooks';\nimport Ajax from 'core/http/ajax';\nimport Runtime from 'runtime';\n\nvar hooks: RequestHooks = {\n getRequest: function(socket: HTTPRequest): Ajax {\n var Constructor = Runtime.getXHRAPI();\n var xhr = new Constructor();\n xhr.onreadystatechange = xhr.onprogress = function() {\n switch (xhr.readyState) {\n case 3:\n if (xhr.responseText && xhr.responseText.length > 0) {\n socket.onChunk(xhr.status, xhr.responseText);\n }\n break;\n case 4:\n // this happens only on errors, never after calling close\n if (xhr.responseText && xhr.responseText.length > 0) {\n socket.onChunk(xhr.status, xhr.responseText);\n }\n socket.emit('finished', xhr.status);\n socket.close();\n break;\n }\n };\n return xhr;\n },\n abortRequest: function(xhr: Ajax) {\n xhr.onreadystatechange = null;\n xhr.abort();\n }\n};\n\nexport default hooks;\n","import * as Collections from 'core/utils/collections';\nimport Transports from 'isomorphic/transports/transports';\nimport TimelineSender from 'core/timeline/timeline_sender';\nimport Ajax from 'core/http/ajax';\nimport getDefaultStrategy from './default_strategy';\nimport TransportsTable from 'core/transports/transports_table';\nimport transportConnectionInitializer from './transports/transport_connection_initializer';\nimport HTTPFactory from './http/http';\n\nvar Isomorphic: any = {\n getDefaultStrategy,\n Transports: Transports,\n transportConnectionInitializer,\n HTTPFactory,\n\n setup(PusherClass): void {\n PusherClass.ready();\n },\n\n getLocalStorage(): any {\n return undefined;\n },\n\n getClientFeatures(): any[] {\n return Collections.keys(\n Collections.filterObject({ ws: Transports.ws }, function(t) {\n return t.isSupported({});\n })\n );\n },\n\n getProtocol(): string {\n return 'http:';\n },\n\n isXHRSupported(): boolean {\n return true;\n },\n\n createSocketRequest(method: string, url: string) {\n if (this.isXHRSupported()) {\n return this.HTTPFactory.createXHR(method, url);\n } else {\n throw 'Cross-origin HTTP requests are not supported';\n }\n },\n\n createXHR(): Ajax {\n var Constructor = this.getXHRAPI();\n return new Constructor();\n },\n\n createWebSocket(url: string): any {\n var Constructor = this.getWebSocketAPI();\n return new Constructor(url);\n },\n\n addUnloadListener(listener: any) {},\n removeUnloadListener(listener: any) {}\n};\n\nexport default Isomorphic;\n","/** Initializes the transport.\n *\n * Fetches resources if needed and then transitions to initialized.\n */\nexport default function() {\n var self = this;\n\n self.timeline.info(\n self.buildTimelineMessage({\n transport: self.name + (self.options.useTLS ? 's' : '')\n })\n );\n\n if (self.hooks.isInitialized()) {\n self.changeState('initialized');\n } else {\n self.onClose();\n }\n}\n","import HTTPRequest from 'core/http/http_request';\nimport HTTPSocket from 'core/http/http_socket';\nimport SocketHooks from 'core/http/socket_hooks';\nimport RequestHooks from 'core/http/request_hooks';\nimport streamingHooks from 'core/http/http_streaming_socket';\nimport pollingHooks from 'core/http/http_polling_socket';\nimport xhrHooks from './http_xhr_request';\nimport HTTPFactory from 'core/http/http_factory';\n\nvar HTTP: HTTPFactory = {\n createStreamingSocket(url: string): HTTPSocket {\n return this.createSocket(streamingHooks, url);\n },\n\n createPollingSocket(url: string): HTTPSocket {\n return this.createSocket(pollingHooks, url);\n },\n\n createSocket(hooks: SocketHooks, url: string): HTTPSocket {\n return new HTTPSocket(hooks, url);\n },\n\n createXHR(method: string, url: string): HTTPRequest {\n return this.createRequest(xhrHooks, method, url);\n },\n\n createRequest(hooks: RequestHooks, method: string, url: string): HTTPRequest {\n return new HTTPRequest(hooks, method, url);\n }\n};\n\nexport default HTTP;\n","import { default as EventsDispatcher } from 'core/events/dispatcher';\nimport Reachability from 'core/reachability';\n\nexport class NetInfo extends EventsDispatcher implements Reachability {\n isOnline(): boolean {\n return true;\n }\n}\n\nexport var Network = new NetInfo();\n","import AbstractRuntime from 'runtimes/interface';\nimport { AuthTransport } from 'core/auth/auth_transports';\nimport {\n AuthRequestType,\n AuthTransportCallback,\n InternalAuthOptions\n} from 'core/auth/options';\nimport { HTTPAuthError } from 'core/errors';\n\nvar fetchAuth: AuthTransport = function(\n context: AbstractRuntime,\n query: string,\n authOptions: InternalAuthOptions,\n authRequestType: AuthRequestType,\n callback: AuthTransportCallback\n) {\n var headers = new Headers();\n headers.set('Content-Type', 'application/x-www-form-urlencoded');\n\n for (var headerName in authOptions.headers) {\n headers.set(headerName, authOptions.headers[headerName]);\n }\n\n if (authOptions.headersProvider != null) {\n const dynamicHeaders = authOptions.headersProvider();\n for (var headerName in dynamicHeaders) {\n headers.set(headerName, dynamicHeaders[headerName]);\n }\n }\n\n var body = query;\n var request = new Request(authOptions.endpoint, {\n headers,\n body,\n credentials: 'same-origin',\n method: 'POST'\n });\n\n return fetch(request)\n .then(response => {\n let { status } = response;\n if (status === 200) {\n // manually parse the json so we can provide a more helpful error in\n // failure case\n return response.text();\n }\n throw new HTTPAuthError(\n status,\n `Could not get ${authRequestType.toString()} info from your auth endpoint, status: ${status}`\n );\n })\n .then(data => {\n let parsedData;\n try {\n parsedData = JSON.parse(data);\n } catch (e) {\n throw new HTTPAuthError(\n 200,\n `JSON returned from ${authRequestType.toString()} endpoint was invalid, yet status code was 200. Data was: ${data}`\n );\n }\n callback(null, parsedData);\n })\n .catch(err => {\n callback(err, null);\n });\n};\n\nexport default fetchAuth;\n","import Logger from 'core/logger';\nimport TimelineSender from 'core/timeline/timeline_sender';\nimport * as Collections from 'core/utils/collections';\nimport Util from 'core/util';\nimport Runtime from 'runtime';\nimport TimelineTransport from 'core/timeline/timeline_transport';\n\nvar getAgent = function(sender: TimelineSender, useTLS: boolean) {\n return function(data: any, callback: Function) {\n var scheme = 'http' + (useTLS ? 's' : '') + '://';\n var url =\n scheme + (sender.host || sender.options.host) + sender.options.path;\n var query = Collections.buildQueryString(data);\n url += '/' + 2 + '?' + query;\n\n fetch(url)\n .then(response => {\n if (response.status !== 200) {\n throw `received ${response.status} from stats.pusher.com`;\n }\n return response.json();\n })\n .then(({ host }) => {\n if (host) {\n sender.host = host;\n }\n })\n .catch(err => {\n Logger.debug('TimelineSender Error: ', err);\n });\n };\n};\n\nvar fetchTimeline = {\n name: 'xhr',\n getAgent\n};\n\nexport default fetchTimeline;\n","import Isomorphic from 'isomorphic/runtime';\nimport Runtime from '../interface';\nimport { Network } from './net_info';\nimport fetchAuth from './auth/fetch_auth';\nimport { AuthTransports } from 'core/auth/auth_transports';\nimport fetchTimeline from './timeline/fetch_timeline';\n\n// Very verbose but until unavoidable until\n// TypeScript 2.1, when spread attributes will be\n// supported\nconst {\n getDefaultStrategy,\n Transports,\n setup,\n getProtocol,\n isXHRSupported,\n getLocalStorage,\n createXHR,\n createWebSocket,\n addUnloadListener,\n removeUnloadListener,\n transportConnectionInitializer,\n createSocketRequest,\n HTTPFactory\n} = Isomorphic;\n\nconst Worker: Runtime = {\n getDefaultStrategy,\n Transports,\n setup,\n getProtocol,\n isXHRSupported,\n getLocalStorage,\n createXHR,\n createWebSocket,\n addUnloadListener,\n removeUnloadListener,\n transportConnectionInitializer,\n createSocketRequest,\n HTTPFactory,\n\n TimelineTransport: fetchTimeline,\n\n getAuthorizers(): AuthTransports {\n return { ajax: fetchAuth };\n },\n\n getWebSocketAPI() {\n return WebSocket;\n },\n\n getXHRAPI() {\n return XMLHttpRequest;\n },\n\n getNetwork() {\n return Network;\n },\n\n randomInt(max: number): number {\n /**\n * Return values in the range of [0, 1[\n */\n const random = function() {\n const crypto = globalThis.crypto || globalThis['msCrypto'];\n const random = crypto.getRandomValues(new Uint32Array(1))[0];\n\n return random / 2 ** 32;\n };\n\n return Math.floor(random() * max);\n }\n};\n\nexport default Worker;\n","enum TimelineLevel {\n ERROR = 3,\n INFO = 6,\n DEBUG = 7\n}\n\nexport default TimelineLevel;\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport { default as Level } from './level';\n\nexport interface TimelineOptions {\n level?: Level;\n limit?: number;\n version?: string;\n cluster?: string;\n features?: string[];\n params?: any;\n}\n\nexport default class Timeline {\n key: string;\n session: number;\n events: any[];\n options: TimelineOptions;\n sent: number;\n uniqueID: number;\n\n constructor(key: string, session: number, options: TimelineOptions) {\n this.key = key;\n this.session = session;\n this.events = [];\n this.options = options || {};\n this.sent = 0;\n this.uniqueID = 0;\n }\n\n log(level, event) {\n if (level <= this.options.level) {\n this.events.push(\n Collections.extend({}, event, { timestamp: Util.now() })\n );\n if (this.options.limit && this.events.length > this.options.limit) {\n this.events.shift();\n }\n }\n }\n\n error(event) {\n this.log(Level.ERROR, event);\n }\n\n info(event) {\n this.log(Level.INFO, event);\n }\n\n debug(event) {\n this.log(Level.DEBUG, event);\n }\n\n isEmpty() {\n return this.events.length === 0;\n }\n\n send(sendfn, callback) {\n var data = Collections.extend(\n {\n session: this.session,\n bundle: this.sent + 1,\n key: this.key,\n lib: 'js',\n version: this.options.version,\n cluster: this.options.cluster,\n features: this.options.features,\n timeline: this.events\n },\n this.options.params\n );\n\n this.events = [];\n sendfn(data, (error, result) => {\n if (!error) {\n this.sent++;\n }\n if (callback) {\n callback(error, result);\n }\n });\n\n return true;\n }\n\n generateUniqueID(): number {\n this.uniqueID++;\n return this.uniqueID;\n }\n}\n","import Factory from '../utils/factory';\nimport Util from '../util';\nimport * as Errors from '../errors';\nimport * as Collections from '../utils/collections';\nimport Strategy from './strategy';\nimport Transport from '../transports/transport';\nimport StrategyOptions from './strategy_options';\nimport Handshake from '../connection/handshake';\n\n/** Provides a strategy interface for transports.\n *\n * @param {String} name\n * @param {Number} priority\n * @param {Class} transport\n * @param {Object} options\n */\nexport default class TransportStrategy implements Strategy {\n name: string;\n priority: number;\n transport: Transport;\n options: StrategyOptions;\n\n constructor(\n name: string,\n priority: number,\n transport: Transport,\n options: StrategyOptions\n ) {\n this.name = name;\n this.priority = priority;\n this.transport = transport;\n this.options = options || {};\n }\n\n /** Returns whether the transport is supported in the browser.\n *\n * @returns {Boolean}\n */\n isSupported(): boolean {\n return this.transport.isSupported({\n useTLS: this.options.useTLS\n });\n }\n\n /** Launches a connection attempt and returns a strategy runner.\n *\n * @param {Function} callback\n * @return {Object} strategy runner\n */\n connect(minPriority: number, callback: Function) {\n if (!this.isSupported()) {\n return failAttempt(new Errors.UnsupportedStrategy(), callback);\n } else if (this.priority < minPriority) {\n return failAttempt(new Errors.TransportPriorityTooLow(), callback);\n }\n\n var connected = false;\n var transport = this.transport.createConnection(\n this.name,\n this.priority,\n this.options.key,\n this.options\n );\n var handshake = null;\n\n var onInitialized = function() {\n transport.unbind('initialized', onInitialized);\n transport.connect();\n };\n var onOpen = function() {\n handshake = Factory.createHandshake(transport, function(result) {\n connected = true;\n unbindListeners();\n callback(null, result);\n });\n };\n var onError = function(error) {\n unbindListeners();\n callback(error);\n };\n var onClosed = function() {\n unbindListeners();\n var serializedTransport;\n\n // The reason for this try/catch block is that on React Native\n // the WebSocket object is circular. Therefore transport.socket will\n // throw errors upon stringification. Collections.safeJSONStringify\n // discards circular references when serializing.\n serializedTransport = Collections.safeJSONStringify(transport);\n callback(new Errors.TransportClosed(serializedTransport));\n };\n\n var unbindListeners = function() {\n transport.unbind('initialized', onInitialized);\n transport.unbind('open', onOpen);\n transport.unbind('error', onError);\n transport.unbind('closed', onClosed);\n };\n\n transport.bind('initialized', onInitialized);\n transport.bind('open', onOpen);\n transport.bind('error', onError);\n transport.bind('closed', onClosed);\n\n // connect will be called automatically after initialization\n transport.initialize();\n\n return {\n abort: () => {\n if (connected) {\n return;\n }\n unbindListeners();\n if (handshake) {\n handshake.close();\n } else {\n transport.close();\n }\n },\n forceMinPriority: p => {\n if (connected) {\n return;\n }\n if (this.priority < p) {\n if (handshake) {\n handshake.close();\n } else {\n transport.close();\n }\n }\n }\n };\n }\n}\n\nfunction failAttempt(error: Error, callback: Function) {\n Util.defer(function() {\n callback(error);\n });\n return {\n abort: function() {},\n forceMinPriority: function() {}\n };\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport TransportManager from '../transports/transport_manager';\nimport * as Errors from '../errors';\nimport Strategy from './strategy';\nimport TransportStrategy from './transport_strategy';\nimport StrategyOptions from '../strategies/strategy_options';\nimport { Config } from '../config';\nimport Runtime from 'runtime';\n\nconst { Transports } = Runtime;\n\nexport var defineTransport = function(\n config: Config,\n name: string,\n type: string,\n priority: number,\n options: StrategyOptions,\n manager?: TransportManager\n): Strategy {\n var transportClass = Transports[type];\n if (!transportClass) {\n throw new Errors.UnsupportedTransport(type);\n }\n\n var enabled =\n (!config.enabledTransports ||\n Collections.arrayIndexOf(config.enabledTransports, name) !== -1) &&\n (!config.disabledTransports ||\n Collections.arrayIndexOf(config.disabledTransports, name) === -1);\n\n var transport;\n if (enabled) {\n options = Object.assign(\n { ignoreNullOrigin: config.ignoreNullOrigin },\n options\n );\n\n transport = new TransportStrategy(\n name,\n priority,\n manager ? manager.getAssistant(transportClass) : transportClass,\n options\n );\n } else {\n transport = UnsupportedStrategy;\n }\n\n return transport;\n};\n\nvar UnsupportedStrategy: Strategy = {\n isSupported: function() {\n return false;\n },\n connect: function(_, callback) {\n var deferred = Util.defer(function() {\n callback(new Errors.UnsupportedStrategy());\n });\n return {\n abort: function() {\n deferred.ensureAborted();\n },\n forceMinPriority: function() {}\n };\n }\n};\n","export enum AuthRequestType {\n UserAuthentication = 'user-authentication',\n ChannelAuthorization = 'channel-authorization'\n}\n\nexport interface ChannelAuthorizationData {\n auth: string;\n channel_data?: string;\n shared_secret?: string;\n}\n\nexport type ChannelAuthorizationCallback = (\n error: Error | null,\n authData: ChannelAuthorizationData | null\n) => void;\n\nexport interface ChannelAuthorizationRequestParams {\n socketId: string;\n channelName: string;\n}\n\nexport interface ChannelAuthorizationHandler {\n (\n params: ChannelAuthorizationRequestParams,\n callback: ChannelAuthorizationCallback\n ): void;\n}\n\nexport interface UserAuthenticationData {\n auth: string;\n user_data: string;\n}\n\nexport type UserAuthenticationCallback = (\n error: Error | null,\n authData: UserAuthenticationData | null\n) => void;\n\nexport interface UserAuthenticationRequestParams {\n socketId: string;\n}\n\nexport interface UserAuthenticationHandler {\n (\n params: UserAuthenticationRequestParams,\n callback: UserAuthenticationCallback\n ): void;\n}\n\nexport type AuthTransportCallback =\n | ChannelAuthorizationCallback\n | UserAuthenticationCallback;\n\nexport interface AuthOptionsT {\n transport: 'ajax' | 'jsonp';\n endpoint: string;\n params?: any;\n headers?: any;\n paramsProvider?: () => any;\n headersProvider?: () => any;\n customHandler?: AuthHandler;\n}\n\nexport declare type UserAuthenticationOptions = AuthOptionsT<\n UserAuthenticationHandler\n>;\nexport declare type ChannelAuthorizationOptions = AuthOptionsT<\n ChannelAuthorizationHandler\n>;\n\nexport interface InternalAuthOptions {\n transport: 'ajax' | 'jsonp';\n endpoint: string;\n params?: any;\n headers?: any;\n paramsProvider?: () => any;\n headersProvider?: () => any;\n}\n","import {\n UserAuthenticationCallback,\n InternalAuthOptions,\n UserAuthenticationHandler,\n UserAuthenticationRequestParams,\n AuthRequestType\n} from './options';\n\nimport Runtime from 'runtime';\n\nconst composeChannelQuery = (\n params: UserAuthenticationRequestParams,\n authOptions: InternalAuthOptions\n) => {\n var query = 'socket_id=' + encodeURIComponent(params.socketId);\n\n for (var key in authOptions.params) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(authOptions.params[key]);\n }\n\n if (authOptions.paramsProvider != null) {\n let dynamicParams = authOptions.paramsProvider();\n for (var key in dynamicParams) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(dynamicParams[key]);\n }\n }\n\n return query;\n};\n\nconst UserAuthenticator = (\n authOptions: InternalAuthOptions\n): UserAuthenticationHandler => {\n if (typeof Runtime.getAuthorizers()[authOptions.transport] === 'undefined') {\n throw `'${authOptions.transport}' is not a recognized auth transport`;\n }\n\n return (\n params: UserAuthenticationRequestParams,\n callback: UserAuthenticationCallback\n ) => {\n const query = composeChannelQuery(params, authOptions);\n\n Runtime.getAuthorizers()[authOptions.transport](\n Runtime,\n query,\n authOptions,\n AuthRequestType.UserAuthentication,\n callback\n );\n };\n};\n\nexport default UserAuthenticator;\n","import {\n AuthRequestType,\n InternalAuthOptions,\n ChannelAuthorizationHandler,\n ChannelAuthorizationRequestParams,\n ChannelAuthorizationCallback\n} from './options';\n\nimport Runtime from 'runtime';\n\nconst composeChannelQuery = (\n params: ChannelAuthorizationRequestParams,\n authOptions: InternalAuthOptions\n) => {\n var query = 'socket_id=' + encodeURIComponent(params.socketId);\n\n query += '&channel_name=' + encodeURIComponent(params.channelName);\n\n for (var key in authOptions.params) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(authOptions.params[key]);\n }\n\n if (authOptions.paramsProvider != null) {\n let dynamicParams = authOptions.paramsProvider();\n for (var key in dynamicParams) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(dynamicParams[key]);\n }\n }\n\n return query;\n};\n\nconst ChannelAuthorizer = (\n authOptions: InternalAuthOptions\n): ChannelAuthorizationHandler => {\n if (typeof Runtime.getAuthorizers()[authOptions.transport] === 'undefined') {\n throw `'${authOptions.transport}' is not a recognized auth transport`;\n }\n\n return (\n params: ChannelAuthorizationRequestParams,\n callback: ChannelAuthorizationCallback\n ) => {\n const query = composeChannelQuery(params, authOptions);\n\n Runtime.getAuthorizers()[authOptions.transport](\n Runtime,\n query,\n authOptions,\n AuthRequestType.ChannelAuthorization,\n callback\n );\n };\n};\n\nexport default ChannelAuthorizer;\n","import { Options } from './options';\nimport Defaults from './defaults';\nimport {\n ChannelAuthorizationHandler,\n UserAuthenticationHandler,\n ChannelAuthorizationOptions\n} from './auth/options';\nimport UserAuthenticator from './auth/user_authenticator';\nimport ChannelAuthorizer from './auth/channel_authorizer';\nimport { ChannelAuthorizerProxy } from './auth/deprecated_channel_authorizer';\nimport Runtime from 'runtime';\nimport * as nacl from 'tweetnacl';\n\nexport type AuthTransport = 'ajax' | 'jsonp';\nexport type Transport =\n | 'ws'\n | 'wss'\n | 'xhr_streaming'\n | 'xhr_polling'\n | 'sockjs';\n\nexport interface Config {\n // these are all 'required' config parameters, it's not necessary for the user\n // to set them, but they have configured defaults.\n activityTimeout: number;\n enableStats: boolean;\n httpHost: string;\n httpPath: string;\n httpPort: number;\n httpsPort: number;\n pongTimeout: number;\n statsHost: string;\n unavailableTimeout: number;\n useTLS: boolean;\n wsHost: string;\n wsPath: string;\n wsPort: number;\n wssPort: number;\n userAuthenticator: UserAuthenticationHandler;\n channelAuthorizer: ChannelAuthorizationHandler;\n\n // these are all optional parameters or overrrides. The customer can set these\n // but it's not strictly necessary\n forceTLS?: boolean;\n cluster?: string;\n disabledTransports?: Transport[];\n enabledTransports?: Transport[];\n ignoreNullOrigin?: boolean;\n nacl?: nacl;\n timelineParams?: any;\n}\n\n// getConfig mainly sets the defaults for the options that are not provided\nexport function getConfig(opts: Options, pusher): Config {\n let config: Config = {\n activityTimeout: opts.activityTimeout || Defaults.activityTimeout,\n cluster: opts.cluster,\n httpPath: opts.httpPath || Defaults.httpPath,\n httpPort: opts.httpPort || Defaults.httpPort,\n httpsPort: opts.httpsPort || Defaults.httpsPort,\n pongTimeout: opts.pongTimeout || Defaults.pongTimeout,\n statsHost: opts.statsHost || Defaults.stats_host,\n unavailableTimeout: opts.unavailableTimeout || Defaults.unavailableTimeout,\n wsPath: opts.wsPath || Defaults.wsPath,\n wsPort: opts.wsPort || Defaults.wsPort,\n wssPort: opts.wssPort || Defaults.wssPort,\n\n enableStats: getEnableStatsConfig(opts),\n httpHost: getHttpHost(opts),\n useTLS: shouldUseTLS(opts),\n wsHost: getWebsocketHost(opts),\n\n userAuthenticator: buildUserAuthenticator(opts),\n channelAuthorizer: buildChannelAuthorizer(opts, pusher)\n };\n\n if ('disabledTransports' in opts)\n config.disabledTransports = opts.disabledTransports;\n if ('enabledTransports' in opts)\n config.enabledTransports = opts.enabledTransports;\n if ('ignoreNullOrigin' in opts)\n config.ignoreNullOrigin = opts.ignoreNullOrigin;\n if ('timelineParams' in opts) config.timelineParams = opts.timelineParams;\n if ('nacl' in opts) {\n config.nacl = opts.nacl;\n }\n\n return config;\n}\n\nfunction getHttpHost(opts: Options): string {\n if (opts.httpHost) {\n return opts.httpHost;\n }\n if (opts.cluster) {\n return `sockjs-${opts.cluster}.pusher.com`;\n }\n return Defaults.httpHost;\n}\n\nfunction getWebsocketHost(opts: Options): string {\n if (opts.wsHost) {\n return opts.wsHost;\n }\n return getWebsocketHostFromCluster(opts.cluster);\n}\n\nfunction getWebsocketHostFromCluster(cluster: string): string {\n return `ws-${cluster}.pusher.com`;\n}\n\nfunction shouldUseTLS(opts: Options): boolean {\n if (Runtime.getProtocol() === 'https:') {\n return true;\n } else if (opts.forceTLS === false) {\n return false;\n }\n return true;\n}\n\n// if enableStats is set take the value\n// if disableStats is set take the inverse\n// otherwise default to false\nfunction getEnableStatsConfig(opts: Options): boolean {\n if ('enableStats' in opts) {\n return opts.enableStats;\n }\n if ('disableStats' in opts) {\n return !opts.disableStats;\n }\n return false;\n}\n\nfunction buildUserAuthenticator(opts: Options): UserAuthenticationHandler {\n const userAuthentication = {\n ...Defaults.userAuthentication,\n ...opts.userAuthentication\n };\n if (\n 'customHandler' in userAuthentication &&\n userAuthentication['customHandler'] != null\n ) {\n return userAuthentication['customHandler'];\n }\n\n return UserAuthenticator(userAuthentication);\n}\n\nfunction buildChannelAuth(opts: Options, pusher): ChannelAuthorizationOptions {\n let channelAuthorization: ChannelAuthorizationOptions;\n if ('channelAuthorization' in opts) {\n channelAuthorization = {\n ...Defaults.channelAuthorization,\n ...opts.channelAuthorization\n };\n } else {\n channelAuthorization = {\n transport: opts.authTransport || Defaults.authTransport,\n endpoint: opts.authEndpoint || Defaults.authEndpoint\n };\n if ('auth' in opts) {\n if ('params' in opts.auth) channelAuthorization.params = opts.auth.params;\n if ('headers' in opts.auth)\n channelAuthorization.headers = opts.auth.headers;\n }\n if ('authorizer' in opts)\n channelAuthorization.customHandler = ChannelAuthorizerProxy(\n pusher,\n channelAuthorization,\n opts.authorizer\n );\n }\n return channelAuthorization;\n}\n\nfunction buildChannelAuthorizer(\n opts: Options,\n pusher\n): ChannelAuthorizationHandler {\n const channelAuthorization = buildChannelAuth(opts, pusher);\n if (\n 'customHandler' in channelAuthorization &&\n channelAuthorization['customHandler'] != null\n ) {\n return channelAuthorization['customHandler'];\n }\n\n return ChannelAuthorizer(channelAuthorization);\n}\n","import Channel from '../channels/channel';\nimport {\n ChannelAuthorizationCallback,\n ChannelAuthorizationHandler,\n ChannelAuthorizationRequestParams,\n InternalAuthOptions\n} from './options';\n\nexport interface DeprecatedChannelAuthorizer {\n authorize(socketId: string, callback: ChannelAuthorizationCallback): void;\n}\n\nexport interface ChannelAuthorizerGenerator {\n (\n channel: Channel,\n options: DeprecatedAuthorizerOptions\n ): DeprecatedChannelAuthorizer;\n}\n\nexport interface DeprecatedAuthOptions {\n params?: any;\n headers?: any;\n}\n\nexport interface DeprecatedAuthorizerOptions {\n authTransport: 'ajax' | 'jsonp';\n authEndpoint: string;\n auth?: DeprecatedAuthOptions;\n}\n\nexport const ChannelAuthorizerProxy = (\n pusher,\n authOptions: InternalAuthOptions,\n channelAuthorizerGenerator: ChannelAuthorizerGenerator\n): ChannelAuthorizationHandler => {\n const deprecatedAuthorizerOptions: DeprecatedAuthorizerOptions = {\n authTransport: authOptions.transport,\n authEndpoint: authOptions.endpoint,\n auth: {\n params: authOptions.params,\n headers: authOptions.headers\n }\n };\n return (\n params: ChannelAuthorizationRequestParams,\n callback: ChannelAuthorizationCallback\n ) => {\n const channel = pusher.channel(params.channelName);\n // This line creates a new channel authorizer every time.\n // In the past, this was only done once per channel and reused.\n // We can do that again if we want to keep this behavior intact.\n const channelAuthorizer: DeprecatedChannelAuthorizer = channelAuthorizerGenerator(\n channel,\n deprecatedAuthorizerOptions\n );\n channelAuthorizer.authorize(params.socketId, callback);\n };\n};\n","import Logger from './logger';\nimport Pusher from './pusher';\nimport EventsDispatcher from './events/dispatcher';\n\nexport default class WatchlistFacade extends EventsDispatcher {\n private pusher: Pusher;\n\n public constructor(pusher: Pusher) {\n super(function(eventName, data) {\n Logger.debug(`No callbacks on watchlist events for ${eventName}`);\n });\n\n this.pusher = pusher;\n this.bindWatchlistInternalEvent();\n }\n\n handleEvent(pusherEvent) {\n pusherEvent.data.events.forEach(watchlistEvent => {\n this.emit(watchlistEvent.name, watchlistEvent);\n });\n }\n\n private bindWatchlistInternalEvent() {\n this.pusher.connection.bind('message', pusherEvent => {\n var eventName = pusherEvent.event;\n if (eventName === 'pusher_internal:watchlist_events') {\n this.handleEvent(pusherEvent);\n }\n });\n }\n}\n","function flatPromise() {\n let resolve, reject;\n const promise = new Promise((res, rej) => {\n resolve = res;\n reject = rej;\n });\n return { promise, resolve, reject };\n}\n\nexport default flatPromise;\n","import Pusher from './pusher';\nimport Logger from './logger';\nimport {\n UserAuthenticationData,\n UserAuthenticationCallback\n} from './auth/options';\nimport Channel from './channels/channel';\nimport WatchlistFacade from './watchlist';\nimport EventsDispatcher from './events/dispatcher';\nimport flatPromise from './utils/flat_promise';\n\nexport default class UserFacade extends EventsDispatcher {\n pusher: Pusher;\n signin_requested: boolean = false;\n user_data: any = null;\n serverToUserChannel: Channel = null;\n signinDonePromise: Promise = null;\n watchlist: WatchlistFacade;\n private _signinDoneResolve: Function = null;\n\n public constructor(pusher: Pusher) {\n super(function(eventName, data) {\n Logger.debug('No callbacks on user for ' + eventName);\n });\n this.pusher = pusher;\n this.pusher.connection.bind('state_change', ({ previous, current }) => {\n if (previous !== 'connected' && current === 'connected') {\n this._signin();\n }\n if (previous === 'connected' && current !== 'connected') {\n this._cleanup();\n this._newSigninPromiseIfNeeded();\n }\n });\n\n this.watchlist = new WatchlistFacade(pusher);\n\n this.pusher.connection.bind('message', event => {\n var eventName = event.event;\n if (eventName === 'pusher:signin_success') {\n this._onSigninSuccess(event.data);\n }\n if (\n this.serverToUserChannel &&\n this.serverToUserChannel.name === event.channel\n ) {\n this.serverToUserChannel.handleEvent(event);\n }\n });\n }\n\n public signin() {\n if (this.signin_requested) {\n return;\n }\n\n this.signin_requested = true;\n this._signin();\n }\n\n private _signin() {\n if (!this.signin_requested) {\n return;\n }\n\n this._newSigninPromiseIfNeeded();\n\n if (this.pusher.connection.state !== 'connected') {\n // Signin will be attempted when the connection is connected\n return;\n }\n\n this.pusher.config.userAuthenticator(\n {\n socketId: this.pusher.connection.socket_id\n },\n this._onAuthorize\n );\n }\n\n private _onAuthorize: UserAuthenticationCallback = (\n err,\n authData: UserAuthenticationData\n ) => {\n if (err) {\n Logger.warn(`Error during signin: ${err}`);\n this._cleanup();\n return;\n }\n\n this.pusher.send_event('pusher:signin', {\n auth: authData.auth,\n user_data: authData.user_data\n });\n\n // Later when we get pusher:singin_success event, the user will be marked as signed in\n };\n\n private _onSigninSuccess(data: any) {\n try {\n this.user_data = JSON.parse(data.user_data);\n } catch (e) {\n Logger.error(`Failed parsing user data after signin: ${data.user_data}`);\n this._cleanup();\n return;\n }\n\n if (typeof this.user_data.id !== 'string' || this.user_data.id === '') {\n Logger.error(\n `user_data doesn't contain an id. user_data: ${this.user_data}`\n );\n this._cleanup();\n return;\n }\n\n // Signin succeeded\n this._signinDoneResolve();\n this._subscribeChannels();\n }\n\n private _subscribeChannels() {\n const ensure_subscribed = channel => {\n if (channel.subscriptionPending && channel.subscriptionCancelled) {\n channel.reinstateSubscription();\n } else if (\n !channel.subscriptionPending &&\n this.pusher.connection.state === 'connected'\n ) {\n channel.subscribe();\n }\n };\n\n this.serverToUserChannel = new Channel(\n `#server-to-user-${this.user_data.id}`,\n this.pusher\n );\n this.serverToUserChannel.bind_global((eventName, data) => {\n if (\n eventName.indexOf('pusher_internal:') === 0 ||\n eventName.indexOf('pusher:') === 0\n ) {\n // ignore internal events\n return;\n }\n this.emit(eventName, data);\n });\n ensure_subscribed(this.serverToUserChannel);\n }\n\n private _cleanup() {\n this.user_data = null;\n if (this.serverToUserChannel) {\n this.serverToUserChannel.unbind_all();\n this.serverToUserChannel.disconnect();\n this.serverToUserChannel = null;\n }\n\n if (this.signin_requested) {\n // If signin is in progress and cleanup is called,\n // Mark the current signin process as done.\n this._signinDoneResolve();\n }\n }\n\n private _newSigninPromiseIfNeeded() {\n if (!this.signin_requested) {\n return;\n }\n\n // If there is a promise and it is not resolved, return without creating a new one.\n if (this.signinDonePromise && !(this.signinDonePromise as any).done) {\n return;\n }\n\n // This promise is never rejected.\n // It gets resolved when the signin process is done whether it failed or succeeded\n const { promise, resolve, reject: _ } = flatPromise();\n (promise as any).done = false;\n const setDone = () => {\n (promise as any).done = true;\n };\n promise.then(setDone).catch(setDone);\n this.signinDonePromise = promise;\n this._signinDoneResolve = resolve;\n }\n}\n","import AbstractRuntime from '../runtimes/interface';\nimport Runtime from 'runtime';\nimport * as Collections from './utils/collections';\nimport Channels from './channels/channels';\nimport Channel from './channels/channel';\nimport { default as EventsDispatcher } from './events/dispatcher';\nimport Timeline from './timeline/timeline';\nimport TimelineSender from './timeline/timeline_sender';\nimport TimelineLevel from './timeline/level';\nimport { defineTransport } from './strategies/strategy_builder';\nimport ConnectionManager from './connection/connection_manager';\nimport { PeriodicTimer } from './utils/timers';\nimport Defaults from './defaults';\nimport Logger from './logger';\nimport Factory from './utils/factory';\nimport { Options, ClusterOptions, validateOptions } from './options';\nimport { Config, getConfig } from './config';\nimport StrategyOptions from './strategies/strategy_options';\nimport UserFacade from './user';\n\nexport default class Pusher {\n /* STATIC PROPERTIES */\n static instances: Pusher[] = [];\n static isReady: boolean = false;\n static logToConsole: boolean = false;\n\n // for jsonp\n static Runtime: AbstractRuntime = Runtime;\n static ScriptReceivers: any = (Runtime).ScriptReceivers;\n static DependenciesReceivers: any = (Runtime).DependenciesReceivers;\n static auth_callbacks: any = (Runtime).auth_callbacks;\n\n static ready() {\n Pusher.isReady = true;\n for (var i = 0, l = Pusher.instances.length; i < l; i++) {\n Pusher.instances[i].connect();\n }\n }\n\n static log: (message: any) => void;\n\n private static getClientFeatures(): string[] {\n return Collections.keys(\n Collections.filterObject({ ws: Runtime.Transports.ws }, function(t) {\n return t.isSupported({});\n })\n );\n }\n\n /* INSTANCE PROPERTIES */\n key: string;\n options: Options;\n config: Config;\n channels: Channels;\n global_emitter: EventsDispatcher;\n sessionID: number;\n timeline: Timeline;\n timelineSender: TimelineSender;\n connection: ConnectionManager;\n timelineSenderTimer: PeriodicTimer;\n user: UserFacade;\n constructor(app_key: string, options: Options) {\n checkAppKey(app_key);\n validateOptions(options);\n this.key = app_key;\n this.config = getConfig(options, this);\n\n this.channels = Factory.createChannels();\n this.global_emitter = new EventsDispatcher();\n this.sessionID = Runtime.randomInt(1000000000);\n\n this.timeline = new Timeline(this.key, this.sessionID, {\n cluster: this.config.cluster,\n features: Pusher.getClientFeatures(),\n params: this.config.timelineParams || {},\n limit: 50,\n level: TimelineLevel.INFO,\n version: Defaults.VERSION\n });\n if (this.config.enableStats) {\n this.timelineSender = Factory.createTimelineSender(this.timeline, {\n host: this.config.statsHost,\n path: '/timeline/v2/' + Runtime.TimelineTransport.name\n });\n }\n\n var getStrategy = (options: StrategyOptions) => {\n return Runtime.getDefaultStrategy(this.config, options, defineTransport);\n };\n\n this.connection = Factory.createConnectionManager(this.key, {\n getStrategy: getStrategy,\n timeline: this.timeline,\n activityTimeout: this.config.activityTimeout,\n pongTimeout: this.config.pongTimeout,\n unavailableTimeout: this.config.unavailableTimeout,\n useTLS: Boolean(this.config.useTLS)\n });\n\n this.connection.bind('connected', () => {\n this.subscribeAll();\n if (this.timelineSender) {\n this.timelineSender.send(this.connection.isUsingTLS());\n }\n });\n\n this.connection.bind('message', event => {\n var eventName = event.event;\n var internal = eventName.indexOf('pusher_internal:') === 0;\n if (event.channel) {\n var channel = this.channel(event.channel);\n if (channel) {\n channel.handleEvent(event);\n }\n }\n // Emit globally [deprecated]\n if (!internal) {\n this.global_emitter.emit(event.event, event.data);\n }\n });\n this.connection.bind('connecting', () => {\n this.channels.disconnect();\n });\n this.connection.bind('disconnected', () => {\n this.channels.disconnect();\n });\n this.connection.bind('error', err => {\n Logger.warn(err);\n });\n\n Pusher.instances.push(this);\n this.timeline.info({ instances: Pusher.instances.length });\n\n this.user = new UserFacade(this);\n\n if (Pusher.isReady) {\n this.connect();\n }\n }\n\n /**\n * Allows you to switch Pusher cluster without\n * losing all the channels/subscription binding\n * as this is internally managed by the SDK.\n */\n switchCluster(options: ClusterOptions) {\n const { appKey, cluster } = options;\n this.key = appKey;\n this.options = { ...this.options, cluster };\n this.config = getConfig(this.options, this);\n this.connection.switchCluster(this.key);\n }\n\n channel(name: string): Channel {\n return this.channels.find(name);\n }\n\n allChannels(): Channel[] {\n return this.channels.all();\n }\n\n connect() {\n this.connection.connect();\n\n if (this.timelineSender) {\n if (!this.timelineSenderTimer) {\n var usingTLS = this.connection.isUsingTLS();\n var timelineSender = this.timelineSender;\n this.timelineSenderTimer = new PeriodicTimer(60000, function() {\n timelineSender.send(usingTLS);\n });\n }\n }\n }\n\n disconnect() {\n this.connection.disconnect();\n\n if (this.timelineSenderTimer) {\n this.timelineSenderTimer.ensureAborted();\n this.timelineSenderTimer = null;\n }\n }\n\n bind(event_name: string, callback: Function, context?: any): Pusher {\n this.global_emitter.bind(event_name, callback, context);\n return this;\n }\n\n unbind(event_name?: string, callback?: Function, context?: any): Pusher {\n this.global_emitter.unbind(event_name, callback, context);\n return this;\n }\n\n bind_global(callback: Function): Pusher {\n this.global_emitter.bind_global(callback);\n return this;\n }\n\n unbind_global(callback?: Function): Pusher {\n this.global_emitter.unbind_global(callback);\n return this;\n }\n\n unbind_all(callback?: Function): Pusher {\n this.global_emitter.unbind_all();\n return this;\n }\n\n subscribeAll() {\n var channelName;\n for (channelName in this.channels.channels) {\n if (this.channels.channels.hasOwnProperty(channelName)) {\n this.subscribe(channelName);\n }\n }\n }\n\n subscribe(channel_name: string) {\n var channel = this.channels.add(channel_name, this);\n if (channel.subscriptionPending && channel.subscriptionCancelled) {\n channel.reinstateSubscription();\n } else if (\n !channel.subscriptionPending &&\n this.connection.state === 'connected'\n ) {\n channel.subscribe();\n }\n return channel;\n }\n\n unsubscribe(channel_name: string) {\n var channel = this.channels.find(channel_name);\n if (channel && channel.subscriptionPending) {\n channel.cancelSubscription();\n } else {\n channel = this.channels.remove(channel_name);\n if (channel && channel.subscribed) {\n channel.unsubscribe();\n }\n }\n }\n\n send_event(event_name: string, data: any, channel?: string) {\n return this.connection.send_event(event_name, data, channel);\n }\n\n shouldUseTLS(): boolean {\n return this.config.useTLS;\n }\n\n signin() {\n this.user.signin();\n }\n}\n\nfunction checkAppKey(key) {\n if (key === null || key === undefined) {\n throw 'You must pass your app key when you instantiate Pusher.';\n }\n}\n\nRuntime.setup(Pusher);\n","import ConnectionManager from './connection/connection_manager';\nimport {\n ChannelAuthorizationOptions,\n UserAuthenticationOptions\n} from './auth/options';\nimport {\n ChannelAuthorizerGenerator,\n DeprecatedAuthOptions\n} from './auth/deprecated_channel_authorizer';\nimport { AuthTransport, Transport } from './config';\nimport * as nacl from 'tweetnacl';\nimport Logger from './logger';\n\nexport interface Options {\n activityTimeout?: number;\n\n auth?: DeprecatedAuthOptions; // DEPRECATED use channelAuthorization instead\n authEndpoint?: string; // DEPRECATED use channelAuthorization instead\n authTransport?: AuthTransport; // DEPRECATED use channelAuthorization instead\n authorizer?: ChannelAuthorizerGenerator; // DEPRECATED use channelAuthorization instead\n\n channelAuthorization?: ChannelAuthorizationOptions;\n userAuthentication?: UserAuthenticationOptions;\n\n cluster: string;\n enableStats?: boolean;\n disableStats?: boolean;\n disabledTransports?: Transport[];\n enabledTransports?: Transport[];\n forceTLS?: boolean;\n httpHost?: string;\n httpPath?: string;\n httpPort?: number;\n httpsPort?: number;\n ignoreNullOrigin?: boolean;\n nacl?: nacl;\n pongTimeout?: number;\n statsHost?: string;\n timelineParams?: any;\n unavailableTimeout?: number;\n wsHost?: string;\n wsPath?: string;\n wsPort?: number;\n wssPort?: number;\n}\n\nexport interface ClusterOptions {\n appKey: string;\n cluster: string;\n}\n\nexport function validateOptions(options) {\n if (options == null) {\n throw 'You must pass an options object';\n }\n if (options.cluster == null) {\n throw 'Options object must provide a cluster';\n }\n if ('disableStats' in options) {\n Logger.warn(\n 'The disableStats option is deprecated in favor of enableStats'\n );\n }\n}\n"],"sourceRoot":""} \ No newline at end of file diff --git a/package.json b/package.json index 5df3e1bbf..1c3203033 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "pusher-js", - "version": "8.3.0", + "version": "8.4.0", "description": "Pusher Channels JavaScript library for browsers, React Native, NodeJS and web workers", "main": "dist/node/pusher.js", "browser": "dist/web/pusher.js", From 581748c291023eaaeb5926a58e1d056dc5dcd10d Mon Sep 17 00:00:00 2001 From: Meena Alfons Date: Wed, 29 Nov 2023 09:47:50 +0100 Subject: [PATCH 04/15] Build v8.4.0-rc1 --- dist/node/pusher.js | 4 ++-- dist/node/pusher.js.map | 2 +- dist/react-native/pusher.js | 4 ++-- dist/react-native/pusher.js.map | 2 +- dist/web/pusher-with-encryption.js | 4 ++-- dist/web/pusher-with-encryption.js.map | 2 +- dist/web/pusher-with-encryption.min.js | 4 ++-- dist/web/pusher-with-encryption.min.js.map | 2 +- dist/web/pusher.js | 4 ++-- dist/web/pusher.js.map | 2 +- dist/web/pusher.min.js | 4 ++-- dist/web/pusher.min.js.map | 2 +- dist/worker/pusher-with-encryption.worker.js | 4 ++-- dist/worker/pusher-with-encryption.worker.js.map | 2 +- dist/worker/pusher-with-encryption.worker.min.js | 4 ++-- dist/worker/pusher-with-encryption.worker.min.js.map | 2 +- dist/worker/pusher.worker.js | 4 ++-- dist/worker/pusher.worker.js.map | 2 +- dist/worker/pusher.worker.min.js | 4 ++-- dist/worker/pusher.worker.min.js.map | 2 +- package-lock.json | 4 ++-- package.json | 2 +- 22 files changed, 33 insertions(+), 33 deletions(-) diff --git a/dist/node/pusher.js b/dist/node/pusher.js index 1e84cb8a6..21d7bc74c 100644 --- a/dist/node/pusher.js +++ b/dist/node/pusher.js @@ -1,5 +1,5 @@ /*! - * Pusher JavaScript Library v8.4.0 + * Pusher JavaScript Library v8.4.0-rc1 * https://pusher.com/ * * Copyright 2020, Pusher @@ -7499,7 +7499,7 @@ function safeJSONStringify(source) { // CONCATENATED MODULE: ./src/core/defaults.ts var Defaults = { - VERSION: "8.4.0", + VERSION: "8.4.0-rc1", PROTOCOL: 7, wsPort: 80, wssPort: 443, diff --git a/dist/node/pusher.js.map b/dist/node/pusher.js.map index 215373adb..3402c0cc7 100644 --- a/dist/node/pusher.js.map +++ b/dist/node/pusher.js.map @@ -1 +1 @@ -{"version":3,"sources":["webpack://Pusher/webpack/bootstrap","webpack://Pusher/external \"util\"","webpack://Pusher/./node_modules/safe-buffer/index.js","webpack://Pusher/./node_modules/websocket-driver/lib/websocket/driver/base.js","webpack://Pusher/external \"crypto\"","webpack://Pusher/./node_modules/websocket-driver/lib/websocket/driver.js","webpack://Pusher/external \"stream\"","webpack://Pusher/external \"url\"","webpack://Pusher/./node_modules/faye-websocket/lib/faye/websocket/api/event.js","webpack://Pusher/./node_modules/@stablelib/base64/base64.ts","webpack://Pusher/./node_modules/websocket-driver/lib/websocket/driver/headers.js","webpack://Pusher/./node_modules/websocket-driver/lib/websocket/http_parser.js","webpack://Pusher/./node_modules/faye-websocket/lib/faye/websocket/api.js","webpack://Pusher/./node_modules/websocket-driver/lib/websocket/driver/hybi.js","webpack://Pusher/./node_modules/websocket-extensions/lib/pipeline/ring_buffer.js","webpack://Pusher/./node_modules/websocket-extensions/lib/pipeline/pledge.js","webpack://Pusher/./node_modules/websocket-driver/lib/websocket/driver/draft75.js","webpack://Pusher/./node_modules/faye-websocket/lib/faye/websocket/api/event_target.js","webpack://Pusher/./node_modules/@stablelib/utf8/utf8.ts","webpack://Pusher/./node_modules/faye-websocket/lib/faye/websocket.js","webpack://Pusher/./node_modules/xmlhttprequest/lib/XMLHttpRequest.js","webpack://Pusher/./node_modules/tweetnacl/nacl-fast.js","webpack://Pusher/./src/core/pusher-with-encryption.js","webpack://Pusher/external \"buffer\"","webpack://Pusher/external \"events\"","webpack://Pusher/./node_modules/websocket-driver/lib/websocket/streams.js","webpack://Pusher/./node_modules/websocket-driver/lib/websocket/driver/stream_reader.js","webpack://Pusher/./node_modules/websocket-driver/lib/websocket/driver/client.js","webpack://Pusher/./node_modules/http-parser-js/http-parser.js","webpack://Pusher/external \"assert\"","webpack://Pusher/./node_modules/websocket-extensions/lib/websocket_extensions.js","webpack://Pusher/./node_modules/websocket-extensions/lib/parser.js","webpack://Pusher/./node_modules/websocket-extensions/lib/pipeline/index.js","webpack://Pusher/./node_modules/websocket-extensions/lib/pipeline/cell.js","webpack://Pusher/./node_modules/websocket-extensions/lib/pipeline/functor.js","webpack://Pusher/./node_modules/websocket-driver/lib/websocket/driver/hybi/frame.js","webpack://Pusher/./node_modules/websocket-driver/lib/websocket/driver/hybi/message.js","webpack://Pusher/./node_modules/websocket-driver/lib/websocket/driver/proxy.js","webpack://Pusher/./node_modules/websocket-driver/lib/websocket/driver/server.js","webpack://Pusher/./node_modules/websocket-driver/lib/websocket/driver/draft76.js","webpack://Pusher/./node_modules/faye-websocket/lib/faye/websocket/client.js","webpack://Pusher/external \"net\"","webpack://Pusher/external \"tls\"","webpack://Pusher/./node_modules/faye-websocket/lib/faye/eventsource.js","webpack://Pusher/external \"child_process\"","webpack://Pusher/external \"fs\"","webpack://Pusher/external \"http\"","webpack://Pusher/external \"https\"","webpack://Pusher/./src/core/base64.ts","webpack://Pusher/./src/core/utils/timers/abstract_timer.ts","webpack://Pusher/./src/core/utils/timers/index.ts","webpack://Pusher/./src/core/util.ts","webpack://Pusher/./src/core/utils/collections.ts","webpack://Pusher/./src/core/defaults.ts","webpack://Pusher/./src/core/transports/url_schemes.ts","webpack://Pusher/./src/core/events/callback_registry.ts","webpack://Pusher/./src/core/events/dispatcher.ts","webpack://Pusher/./src/core/logger.ts","webpack://Pusher/./src/core/transports/transport_connection.ts","webpack://Pusher/./src/core/transports/transport.ts","webpack://Pusher/./src/runtimes/isomorphic/transports/transports.ts","webpack://Pusher/./src/core/transports/assistant_to_the_transport_manager.ts","webpack://Pusher/./src/core/connection/protocol/protocol.ts","webpack://Pusher/./src/core/connection/connection.ts","webpack://Pusher/./src/core/connection/handshake/index.ts","webpack://Pusher/./src/core/timeline/timeline_sender.ts","webpack://Pusher/./src/core/errors.ts","webpack://Pusher/./src/core/utils/url_store.ts","webpack://Pusher/./src/core/channels/channel.ts","webpack://Pusher/./src/core/channels/private_channel.ts","webpack://Pusher/./src/core/channels/members.ts","webpack://Pusher/./src/core/channels/presence_channel.ts","webpack://Pusher/./src/core/channels/encrypted_channel.ts","webpack://Pusher/./src/core/connection/connection_manager.ts","webpack://Pusher/./src/core/channels/channels.ts","webpack://Pusher/./src/core/utils/factory.ts","webpack://Pusher/./src/core/transports/transport_manager.ts","webpack://Pusher/./src/core/strategies/sequential_strategy.ts","webpack://Pusher/./src/core/strategies/best_connected_ever_strategy.ts","webpack://Pusher/./src/core/strategies/websocket_prioritized_cached_strategy.ts","webpack://Pusher/./src/core/strategies/delayed_strategy.ts","webpack://Pusher/./src/core/strategies/if_strategy.ts","webpack://Pusher/./src/core/strategies/first_connected_strategy.ts","webpack://Pusher/./src/runtimes/isomorphic/default_strategy.ts","webpack://Pusher/./src/runtimes/isomorphic/transports/transport_connection_initializer.ts","webpack://Pusher/./src/core/http/http_request.ts","webpack://Pusher/./src/core/http/state.ts","webpack://Pusher/./src/core/http/http_socket.ts","webpack://Pusher/./src/core/http/http_streaming_socket.ts","webpack://Pusher/./src/core/http/http_polling_socket.ts","webpack://Pusher/./src/runtimes/isomorphic/http/http_xhr_request.ts","webpack://Pusher/./src/runtimes/isomorphic/http/http.ts","webpack://Pusher/./src/runtimes/isomorphic/runtime.ts","webpack://Pusher/./src/runtimes/node/net_info.ts","webpack://Pusher/./src/core/auth/options.ts","webpack://Pusher/./src/runtimes/isomorphic/auth/xhr_auth.ts","webpack://Pusher/./src/runtimes/isomorphic/timeline/xhr_timeline.ts","webpack://Pusher/./src/runtimes/node/runtime.ts","webpack://Pusher/./src/core/timeline/level.ts","webpack://Pusher/./src/core/timeline/timeline.ts","webpack://Pusher/./src/core/strategies/transport_strategy.ts","webpack://Pusher/./src/core/strategies/strategy_builder.ts","webpack://Pusher/./src/core/options.ts","webpack://Pusher/./src/core/auth/user_authenticator.ts","webpack://Pusher/./src/core/auth/channel_authorizer.ts","webpack://Pusher/./src/core/auth/deprecated_channel_authorizer.ts","webpack://Pusher/./src/core/config.ts","webpack://Pusher/./src/core/watchlist.ts","webpack://Pusher/./src/core/utils/flat_promise.ts","webpack://Pusher/./src/core/user.ts","webpack://Pusher/./src/core/pusher.ts","webpack://Pusher/./src/core/pusher-with-encryption.ts"],"names":[],"mappings":";;;;;;;;;;QAAA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;;QAEA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;;;QAGA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;QACA,0CAA0C,gCAAgC;QAC1E;QACA;;QAEA;QACA;QACA;QACA,wDAAwD,kBAAkB;QAC1E;QACA,iDAAiD,cAAc;QAC/D;;QAEA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA,yCAAyC,iCAAiC;QAC1E,gHAAgH,mBAAmB,EAAE;QACrI;QACA;;QAEA;QACA;QACA;QACA,2BAA2B,0BAA0B,EAAE;QACvD,iCAAiC,eAAe;QAChD;QACA;QACA;;QAEA;QACA,sDAAsD,+DAA+D;;QAErH;QACA;;;QAGA;QACA;;;;;;;AClFA,iC;;;;;;ACAA;AACA,aAAa,mBAAO,CAAC,EAAQ;AAC7B;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AACD;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;;;;;;;AC7Da;;AAEb,cAAc,mBAAO,CAAC,CAAa;AACnC,cAAc,mBAAO,CAAC,EAAQ;AAC9B,cAAc,mBAAO,CAAC,CAAM;AAC5B,cAAc,mBAAO,CAAC,EAAY;AAClC,cAAc,mBAAO,CAAC,CAAW;AACjC,cAAc,mBAAO,CAAC,EAAiB;;AAEvC;AACA;AACA,oCAAoC;;AAEpC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA,2CAA2C;;AAE3C;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA,KAAK;AACL,GAAG;;AAEH;AACA;AACA,GAAG;;AAEH;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA;AACA,GAAG;;AAEH;AACA;;AAEA;AACA;;AAEA;;AAEA;AACA;AACA,KAAK;AACL;AACA;;AAEA;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA,GAAG;;AAEH;AACA;AACA,GAAG;;AAEH;AACA;AACA,GAAG;;AAEH;AACA;AACA,GAAG;;AAEH;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA,yCAAyC,+BAA+B;AACxE;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA,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EA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;;AAEA,mDAAmD,OAAO;AAC1D;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,sDAAsD,yBAAyB;AAC/E;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;;;;;;;;ACtIa;;AAEb,kBAAkB,mBAAO,CAAC,CAAQ;AAClC,kBAAkB,mBAAO,CAAC,CAAM;AAChC,kBAAkB,mBAAO,CAAC,CAAkB;AAC5C,kBAAkB,mBAAO,CAAC,EAAoB;AAC9C,kBAAkB,mBAAO,CAAC,CAAa;;AAEvC;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA,0CAA0C,eAAe;AACzD,0CAA0C,+BAA+B;AACzE,0CAA0C,qCAAqC;;AAE/E;AACA;AACA,GAAG;AACH,gCAAgC;;AAEhC;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA;AACA,KAAK;;AAEL;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA,GAAG;;AAEH;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA;AACA,GAAG;;AAEH;AACA;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A;AACA;;AAEA;AACA,8GAA8G,EAAE,uDAAuD,EAAE,wBAAwB,EAAE,4BAA4B,EAAE;;AAEjO;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA,yCAAyC,oCAAoC;AAC7E;AACA,KAAK;AACL;AACA;AACA,GAAG;;AAEH;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;;AAEA;AACA,GAAG;;AAEH;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,KAAK;AACL;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;AACA,GAAG;;AAEH;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA,GAAG;;AAEH;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL,GAAG;;AAEH;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA,KAAK;;AAEL;;AAEA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;;AAEA;AACA;AACA,GAAG;;AAEH;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA,GAAG;;AAEH;AACA;;AAEA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA,GAAG;;AAEH;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA,KAAK;AACL,GAAG;;AAEH;AACA;AACA;AACA;AACA,KAAK;AACL;AACA,GAAG;;AAEH;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;;;;;;;;AClea;;AAEb;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA,GAAG;AACH;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;;AAEA;;;;;;;;ACjEa;;AAEb,iBAAiB,mBAAO,CAAC,EAAe;;AAExC;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA,GAAG;AACH;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;;;;;;;;ACpCa;;AAEb,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K,CAAC,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC;KACtC;IACD,OAAO,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AAC1B,CAAC;AAjED,wBAiEC;;;;;;;;AC/ID;AACA;AACA;AACA;AACA;;AAEa;;AAEb,aAAa,mBAAO,CAAC,CAAM;AAC3B,aAAa,mBAAO,CAAC,CAAkB;AACvC,aAAa,mBAAO,CAAC,EAAiB;;AAEtC;AACA;;AAEA;AACA,uCAAuC,mDAAmD;;AAE1F;AACA;AACA;;AAEA,4BAA4B;AAC5B;;AAEA;;AAEA;AACA;AACA;AACA,GAAG;AACH;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA,wBAAwB,mBAAO,CAAC,EAAoB;AACpD,wBAAwB,mBAAO,CAAC,EAAe;;AAE/C;;;;;;;AC9CA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,UAAU,mBAAO,CAAC,CAAK;AACvB,YAAY,mBAAO,CAAC,EAAe;AACnC,SAAS,mBAAO,CAAC,EAAI;;AAErB;AACA;;AAEA;AACA;AACA;AACA;AACA,aAAa,mBAAO,CAAC,EAAM;AAC3B,cAAc,mBAAO,CAAC,EAAO;;AAE7B;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,WAAW;AACX;AACA;AACA;AACA;AACA,SAAS;AACT,OAAO;AACP;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,KAAK;AACL;;AAEA;AACA,8CAA8C;AAC9C;AACA,KAAK;AACL;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;;AAET;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;;AAET;AACA;AACA,SAAS;AACT;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;;AAEA;AACA,KAAK,OAAO;AACZ;AACA;AACA;AACA;AACA;AACA,iGAAiG;AACjG,gEAAgE;AAChE,yDAAyD;AACzD,iCAAiC;AACjC,4DAA4D;AAC5D,wCAAwC;AACxC,gDAAgD;AAChD,mCAAmC;AACnC,YAAY,EAAE;AACd,0CAA0C;AAC1C,mEAAmE,kBAAkB,gFAAgF,WAAW;AAChL,6CAA6C;AAC7C,YAAY,EAAE;AACd,iDAAiD;AACjD,mEAAmE,WAAW,WAAW;AACzF,6CAA6C;AAC7C,YAAY,EAAE;AACd,YAAY,+BAA+B;AAC3C,mEAAmE,WAAW,WAAW;AACzF,6CAA6C;AAC7C,YAAY,EAAE;AACd,8FAA8F;AAC9F,qBAAqB;AACrB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,OAAO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,oDAAoD,SAAS;AAC7D;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;AC3mBA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,uBAAuB,iBAAiB;AACxC;AACA;;AAEA;AACA,wCAAwC,4BAA4B;;AAEpE;AACA,4BAA4B;;AAE5B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa,OAAO;AACpB;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,aAAa,QAAQ;AACrB,aAAa,OAAO;AACpB;AACA;AACA,eAAe,QAAQ;AACvB;AACA,eAAe,QAAQ;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB;AACA;AACA;;AAEA;AACA;AACA;AACA,aAAa,QAAQ;AACrB,aAAa,OAAO;AACpB;AACA;AACA,eAAe,QAAQ;AACvB;AACA,eAAe,QAAQ;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,iBAAiB,OAAO;AACxB;AACA;;AAEA;AACA;AACA;AACA;AACA,iBAAiB,OAAO;AACxB;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA,8CAA8C;AAC9C,8CAA8C;AAC9C,8CAA8C;AAC9C,8CAA8C;AAC9C,8CAA8C;AAC9C;AACA,8CAA8C;AAC9C,8CAA8C;AAC9C,8CAA8C;AAC9C;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,sDAAsD;AACtD,sDAAsD;AACtD,sDAAsD;AACtD,sDAAsD;AACtD,sDAAsD;AACtD;AACA,sDAAsD;AACtD,sDAAsD;AACtD,sDAAsD;AACtD;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA,qBAAqB;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA,qBAAqB;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA,qBAAqB;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA,qBAAqB;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA,qBAAqB;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA,qBAAqB;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA,qBAAqB;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA,qBAAqB;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA,qBAAqB;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA,qBAAqB;;AAErB;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA,UAAU,QAAQ;AAClB;AACA;AACA;;AAEA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA;AACA;;AAEA;AACA,aAAa,QAAQ;AACrB;AACA,aAAa,QAAQ;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa,OAAO;AACpB;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,UAAU;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,eAAe,WAAW;AAC1B;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;;AAEA;AACA;AACA,aAAa,QAAQ;AACrB;;AAEA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA,aAAa,OAAO;AACpB;AACA,eAAe,QAAQ;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;;AAEA;AACA,iBAAiB,QAAQ;AACzB;;AAEA;AACA,iBAAiB,QAAQ;AACzB;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD;;AAEA;AACA;AACA,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA,aAAa,QAAQ;AACrB,eAAe,QAAQ;AACvB;AACA;AACA;AACA,aAAa,QAAQ;AACrB;;AAEA;AACA;AACA;AACA,aAAa,QAAQ;AACrB,eAAe,QAAQ;AACvB;AACA;AACA;AACA,aAAa,QAAQ;AACrB;;AAEA;AACA;AACA;AACA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA;AACA,aAAa,MAAM;AACnB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,eAAe,QAAQ;AACvB;AACA;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AoB;;AAEpB;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA,mBAAmB;AACnB,mBAAmB;;AAEnB;AACA;;AAEA,oBAAoB;AACpB,oBAAoB;;AAEpB;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA,mBAAmB;AACnB,mBAAmB;;AAEnB;AACA;;AAEA,oBAAoB;AACpB,oBAAoB;;AAEpB;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA,mBAAmB;AACnB,mBAAmB;;AAEnB;AACA;;AAEA,oBAAoB;AACpB,oBAAoB;;AAEpB;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA,mBAAmB;AACnB,mBAAmB;;AAEnB;AACA;;AAEA,oBAAoB;AACpB,oBAAoB;;AAEpB;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA,mBAAmB;AACnB,mBAAmB;;AAEnB;AACA;;AAEA,oBAAoB;AACpB,oBAAoB;;AAEpB;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA,mBAAmB;AACnB,mBAAmB;;AAEnB;AACA;;AAEA,oBAAoB;AACpB,oBAAoB;;AAEpB;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA,aAAa,OAAO;AACpB;;AAEA;AACA;AACA;AACA;;AAEA,aAAa,OAAO;;AAEpB;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa,OAAO;AACpB;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,QAAQ;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA,aAAa,QAAQ;AACrB;AACA;;AAEA;;AAEA;AACA;AACA,cAAc,SAAS;AACvB;AACA,gCAAgC,OAAO;AACvC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA;AACA,aAAa,QAAQ;AACrB,aAAa,QAAQ;AACrB;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa,QAAQ;AACrB,aAAa,QAAQ;AACrB;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA,aAAa,OAAO;AACpB,aAAa,QAAQ;;AAErB;AACA;AACA;AACA;;AAEA,cAAc,QAAQ;AACtB;AACA;;AAEA,aAAa,QAAQ;AACrB,aAAa,QAAQ;AACrB,aAAa,QAAQ;AACrB,eAAe,QAAQ;AACvB;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;;AAEA,aAAa,OAAO;AACpB,aAAa,QAAQ;AACrB;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA,eAAe,OAAO;AACtB;AACA;;AAEA,aAAa,OAAO;AACpB;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA,iBAAiB,sBAAsB;AACvC;AACA;AACA;AACA;;AAEA;AACA,iBAAiB,gBAAgB;AACjC;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,iBAAiB,gBAAgB;AACjC;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,iBAAiB,gBAAgB;AACjC;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA,UAAU;AACV;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,UAAU;AACV;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAiB,cAAc;AAC/B;AACA;;AAEA;AACA;AACA;AACA,iBAAiB,gBAAgB;AACjC;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa,uBAAuB;AACpC,aAAa,gBAAgB;AAC7B;AACA;;AAEA;AACA;AACA;AACA;AACA,UAAU;AACV;;AAEA;AACA;AACA;AACA;AACA;AACA,iBAAiB,eAAe;AAChC,UAAU;AACV;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAiB,QAAQ;AACzB;AACA,UAAU;AACV;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAiB,OAAO;AACxB;AACA;AACA,iBAAiB,OAAO;AACxB;AACA,KAAK;AACL,GAAG,UAAU,IAA8B;AAC3C;AACA,aAAa,mBAAO,CAAC,CAAQ;AAC7B;AACA;AACA;AACA,mBAAmB,OAAO;AAC1B;AACA,OAAO;AACP;AACA;AACA,CAAC;;AAED,CAAC,EAAE,KAA6B,kEAAkE;;;;;;;ACt1ElG,iBAAiB,mBAAO,CAAC,EAA0B;;;;;;;ACAnD,mC;;;;;;ACAA,mC;;;;;;;ACAa;;AAEb;;AAEA;AACA;;AAEA;AACA;;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AAGA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;;AAGA,aAAa,mBAAO,CAAC,CAAQ;AAC7B,aAAa,mBAAO,CAAC,CAAM;;;AAG3B;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;;AAGA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;;AAGA;AACA;;;;;;;;ACjJa;;AAEb,aAAa,mBAAO,CAAC,CAAa;;AAElC;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;;AAEA,mCAAmC,OAAO;AAC1C;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;;;;;;;ACpEa;;AAEb,iBAAiB,mBAAO,CAAC,CAAa;AACtC,iBAAiB,mBAAO,CAAC,CAAQ;AACjC,iBAAiB,mBAAO,CAAC,CAAK;AAC9B,iBAAiB,mBAAO,CAAC,CAAM;AAC/B,iBAAiB,mBAAO,CAAC,EAAgB;AACzC,iBAAiB,mBAAO,CAAC,CAAQ;AACjC,iBAAiB,mBAAO,CAAC,EAAQ;AACjC,iBAAiB,mBAAO,CAAC,EAAS;;AAElC;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA,GAAG;;AAEH;AACA;AACA;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;;AAEA;AACA;;AAEA;;;;;;;AC7IA;;AAEA,aAAa,mBAAO,CAAC,EAAQ;;AAE7B;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,sBAAsB;AACtB;AACA;AACA;AACA;;AAEA;AACA,qCAAqC;AACrC;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,8CAA8C,UAAU;;AAExD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,2BAA2B,SAAS;AACpC,4BAA4B;AAC5B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,UAAU;AACV;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,yCAAyC,EAAE;AAC3C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA,mDAAmD;AACnD;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA,mBAAmB,oBAAoB;AACvC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW;AACX;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA,KAAK;AACL;AACA;AACA,kCAAkC;AAClC;AACA,KAAK;AACL;AACA,KAAK;AACL;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH,CAAC;;AAED;AACA;AACA;AACA;AACA;;;;;;;AC9cA,mC;;;;;;;ACAa;;AAEb,eAAe,mBAAO,CAAC,EAAU;AACjC,eAAe,mBAAO,CAAC,EAAY;;AAEnC;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA,OAAO;AACP,KAAK;;AAEL;AACA;;AAEA;AACA,GAAG;;AAEH;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA,KAAK;;AAEL;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,KAAK;;AAEL;AACA;;AAEA;AACA,GAAG;;AAEH;AACA,mBAAmB,wCAAwC;AAC3D;;AAEA;AACA,gDAAgD,OAAO;AACvD;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA,GAAG;;AAEH;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;;;;;;;;ACjKa;;AAEb;AACA;AACA;AACA;AACA,gDAAgD;AAChD;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA,SAAS;AACT;AACA,SAAS;AACT;AACA;AACA;;AAEA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA,OAAO;AACP;AACA,KAAK;;AAEL;AACA,GAAG;;AAEH;AACA;;AAEA;AACA;AACA,mCAAmC,gBAAgB;AACnD,OAAO;AACP;AACA,OAAO;AACP;AACA,OAAO;AACP;AACA,OAAO;AACP;AACA;AACA;;AAEA;;AAEA,wCAAwC;AACxC;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA,sBAAsB,6BAA6B;AACnD;;AAEA;AACA;AACA,kCAAkC,OAAO;AACzC;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;;;;;;;;ACtGa;;AAEb,aAAa,mBAAO,CAAC,EAAQ;AAC7B,aAAa,mBAAO,CAAC,EAAU;;AAE/B;AACA,kDAAkD,2BAA2B;AAC7E,mBAAmB;AACnB;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA,mBAAmB;;AAEnB,4CAA4C,mBAAmB;AAC/D;AACA,wCAAwC,yBAAyB;AACjE;;AAEA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;;AAEA;;;;;;;;AC9Ca;;AAEb,cAAc,mBAAO,CAAC,EAAW;AACjC,cAAc,mBAAO,CAAC,EAAU;;AAEhC;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;;;;;;;;ACpDa;;AAEb,iBAAiB,mBAAO,CAAC,EAAe;;AAExC;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA,gBAAgB,oFAAoF;AACpG;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA,GAAG;AACH;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;;AAEA;;;;;;;;ACvEa;;AAEb;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;;;;;;;;ACpBa;;AAEb,aAAa,mBAAO,CAA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AE,OAAgB;QAC3C,WAAM,CAAC,YAAY,GAAG,2CAAoB,CAAC,YAAY,CAAC;QACxD,WAAM,CAAC,GAAG,GAAG,2CAAoB,CAAC,GAAG,CAAC;QAEtC,eAAe,CAAC,OAAO,CAAC,CAAC;QACzB,OAAO,CAAC,IAAI,GAAG,SAAI,CAAC;QACpB,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAC1B,CAAC;CACF","file":"pusher.js","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 21);\n","module.exports = require(\"util\");","/* eslint-disable node/no-deprecated-api */\nvar buffer = require('buffer')\nvar Buffer = buffer.Buffer\n\n// alternative to using Object.keys for old browsers\nfunction copyProps (src, dst) {\n for (var key in src) {\n dst[key] = src[key]\n }\n}\nif (Buffer.from && Buffer.alloc && Buffer.allocUnsafe && Buffer.allocUnsafeSlow) {\n module.exports = buffer\n} else {\n // Copy properties from require('buffer')\n copyProps(buffer, exports)\n exports.Buffer = SafeBuffer\n}\n\nfunction SafeBuffer (arg, encodingOrOffset, length) {\n return Buffer(arg, encodingOrOffset, length)\n}\n\n// Copy static methods from Buffer\ncopyProps(Buffer, SafeBuffer)\n\nSafeBuffer.from = function (arg, encodingOrOffset, length) {\n if (typeof arg === 'number') {\n throw new TypeError('Argument must not be a number')\n }\n return Buffer(arg, encodingOrOffset, length)\n}\n\nSafeBuffer.alloc = function (size, fill, encoding) {\n if (typeof size !== 'number') {\n throw new TypeError('Argument must be a number')\n }\n var buf = Buffer(size)\n if (fill !== undefined) {\n if (typeof encoding === 'string') {\n buf.fill(fill, encoding)\n } else {\n buf.fill(fill)\n }\n } else {\n buf.fill(0)\n }\n return buf\n}\n\nSafeBuffer.allocUnsafe = function (size) {\n if (typeof size !== 'number') {\n throw new TypeError('Argument must be a number')\n }\n return Buffer(size)\n}\n\nSafeBuffer.allocUnsafeSlow = function (size) {\n if (typeof size !== 'number') {\n throw new TypeError('Argument must be a number')\n }\n return buffer.SlowBuffer(size)\n}\n","'use strict';\n\nvar Buffer = require('safe-buffer').Buffer,\n Emitter = require('events').EventEmitter,\n util = require('util'),\n streams = require('../streams'),\n Headers = require('./headers'),\n Reader = require('./stream_reader');\n\nvar Base = function(request, url, options) {\n Emitter.call(this);\n Base.validateOptions(options || {}, ['maxLength', 'masking', 'requireMasking', 'protocols']);\n\n this._request = request;\n this._reader = new Reader();\n this._options = options || {};\n this._maxLength = this._options.maxLength || this.MAX_LENGTH;\n this._headers = new Headers();\n this.__queue = [];\n this.readyState = 0;\n this.url = url;\n\n this.io = new streams.IO(this);\n this.messages = new streams.Messages(this);\n this._bindEventListeners();\n};\nutil.inherits(Base, Emitter);\n\nBase.isWebSocket = function(request) {\n var connection = request.headers.connection || '',\n upgrade = request.headers.upgrade || '';\n\n return request.method === 'GET' &&\n connection.toLowerCase().split(/ *, */).indexOf('upgrade') >= 0 &&\n upgrade.toLowerCase() === 'websocket';\n};\n\nBase.validateOptions = function(options, validKeys) {\n for (var key in options) {\n if (validKeys.indexOf(key) < 0)\n throw new Error('Unrecognized option: ' + key);\n }\n};\n\nvar instance = {\n // This is 64MB, small enough for an average VPS to handle without\n // crashing from process out of memory\n MAX_LENGTH: 0x3ffffff,\n\n STATES: ['connecting', 'open', 'closing', 'closed'],\n\n _bindEventListeners: function() {\n var self = this;\n\n // Protocol errors are informational and do not have to be handled\n this.messages.on('error', function() {});\n\n this.on('message', function(event) {\n var messages = self.messages;\n if (messages.readable) messages.emit('data', event.data);\n });\n\n this.on('error', function(error) {\n var messages = self.messages;\n if (messages.readable) messages.emit('error', error);\n });\n\n this.on('close', function() {\n var messages = self.messages;\n if (!messages.readable) return;\n messages.readable = messages.writable = false;\n messages.emit('end');\n });\n },\n\n getState: function() {\n return this.STATES[this.readyState] || null;\n },\n\n addExtension: function(extension) {\n return false;\n },\n\n setHeader: function(name, value) {\n if (this.readyState > 0) return false;\n this._headers.set(name, value);\n return true;\n },\n\n start: function() {\n if (this.readyState !== 0) return false;\n\n if (!Base.isWebSocket(this._request))\n return this._failHandshake(new Error('Not a WebSocket request'));\n\n var response;\n\n try {\n response = this._handshakeResponse();\n } catch (error) {\n return this._failHandshake(error);\n }\n\n this._write(response);\n if (this._stage !== -1) this._open();\n return true;\n },\n\n _failHandshake: function(error) {\n var headers = new Headers();\n headers.set('Content-Type', 'text/plain');\n headers.set('Content-Length', Buffer.byteLength(error.message, 'utf8'));\n\n headers = ['HTTP/1.1 400 Bad Request', headers.toString(), error.message];\n this._write(Buffer.from(headers.join('\\r\\n'), 'utf8'));\n this._fail('protocol_error', error.message);\n\n return false;\n },\n\n text: function(message) {\n return this.frame(message);\n },\n\n binary: function(message) {\n return false;\n },\n\n ping: function() {\n return false;\n },\n\n pong: function() {\n return false;\n },\n\n close: function(reason, code) {\n if (this.readyState !== 1) return false;\n this.readyState = 3;\n this.emit('close', new Base.CloseEvent(null, null));\n return true;\n },\n\n _open: function() {\n this.readyState = 1;\n this.__queue.forEach(function(args) { this.frame.apply(this, args) }, this);\n this.__queue = [];\n this.emit('open', new Base.OpenEvent());\n },\n\n _queue: function(message) {\n this.__queue.push(message);\n return true;\n },\n\n _write: function(chunk) {\n var io = this.io;\n if (io.readable) io.emit('data', chunk);\n },\n\n _fail: function(type, message) {\n this.readyState = 2;\n this.emit('error', new Error(message));\n this.close();\n }\n};\n\nfor (var key in instance)\n Base.prototype[key] = instance[key];\n\n\nBase.ConnectEvent = function() {};\n\nBase.OpenEvent = function() {};\n\nBase.CloseEvent = function(code, reason) {\n this.code = code;\n this.reason = reason;\n};\n\nBase.MessageEvent = function(data) {\n this.data = data;\n};\n\nBase.PingEvent = function(data) {\n this.data = data;\n};\n\nBase.PongEvent = function(data) {\n this.data = data;\n};\n\nmodule.exports = Base;\n","module.exports = require(\"crypto\");","'use strict';\n\n// Protocol references:\n//\n// * http://tools.ietf.org/html/draft-hixie-thewebsocketprotocol-75\n// * http://tools.ietf.org/html/draft-hixie-thewebsocketprotocol-76\n// * http://tools.ietf.org/html/draft-ietf-hybi-thewebsocketprotocol-17\n\nvar Base = require('./driver/base'),\n Client = require('./driver/client'),\n Server = require('./driver/server');\n\nvar Driver = {\n client: function(url, options) {\n options = options || {};\n if (options.masking === undefined) options.masking = true;\n return new Client(url, options);\n },\n\n server: function(options) {\n options = options || {};\n if (options.requireMasking === undefined) options.requireMasking = true;\n return new Server(options);\n },\n\n http: function() {\n return Server.http.apply(Server, arguments);\n },\n\n isSecureRequest: function(request) {\n return Server.isSecureRequest(request);\n },\n\n isWebSocket: function(request) {\n return Base.isWebSocket(request);\n },\n\n validateOptions: function(options, validKeys) {\n Base.validateOptions(options, validKeys);\n }\n};\n\nmodule.exports = Driver;\n","module.exports = require(\"stream\");","module.exports = require(\"url\");","'use strict';\n\nvar Event = function(eventType, options) {\n this.type = eventType;\n for (var key in options)\n this[key] = options[key];\n};\n\nEvent.prototype.initEvent = function(eventType, canBubble, cancelable) {\n this.type = eventType;\n this.bubbles = canBubble;\n this.cancelable = cancelable;\n};\n\nEvent.prototype.stopPropagation = function() {};\nEvent.prototype.preventDefault = function() {};\n\nEvent.CAPTURING_PHASE = 1;\nEvent.AT_TARGET = 2;\nEvent.BUBBLING_PHASE = 3;\n\nmodule.exports = Event;\n","// Copyright (C) 2016 Dmitry Chestnykh\n// MIT License. See LICENSE file for details.\n\n/**\n * Package base64 implements Base64 encoding and decoding.\n */\n\n// Invalid character used in decoding to indicate\n// that the character to decode is out of range of\n// alphabet and cannot be decoded.\nconst INVALID_BYTE = 256;\n\n/**\n * Implements standard Base64 encoding.\n *\n * Operates in constant time.\n */\nexport class Coder {\n // TODO(dchest): methods to encode chunk-by-chunk.\n\n constructor(private _paddingCharacter = \"=\") { }\n\n encodedLength(length: number): number {\n if (!this._paddingCharacter) {\n return (length * 8 + 5) / 6 | 0;\n }\n return (length + 2) / 3 * 4 | 0;\n }\n\n encode(data: Uint8Array): string {\n let out = \"\";\n\n let i = 0;\n for (; i < data.length - 2; i += 3) {\n let c = (data[i] << 16) | (data[i + 1] << 8) | (data[i + 2]);\n out += this._encodeByte((c >>> 3 * 6) & 63);\n out += this._encodeByte((c >>> 2 * 6) & 63);\n out += this._encodeByte((c >>> 1 * 6) & 63);\n out += this._encodeByte((c >>> 0 * 6) & 63);\n }\n\n const left = data.length - i;\n if (left > 0) {\n let c = (data[i] << 16) | (left === 2 ? data[i + 1] << 8 : 0);\n out += this._encodeByte((c >>> 3 * 6) & 63);\n out += this._encodeByte((c >>> 2 * 6) & 63);\n if (left === 2) {\n out += this._encodeByte((c >>> 1 * 6) & 63);\n } else {\n out += this._paddingCharacter || \"\";\n }\n out += this._paddingCharacter || \"\";\n }\n\n return out;\n }\n\n maxDecodedLength(length: number): number {\n if (!this._paddingCharacter) {\n return (length * 6 + 7) / 8 | 0;\n }\n return length / 4 * 3 | 0;\n }\n\n decodedLength(s: string): number {\n return this.maxDecodedLength(s.length - this._getPaddingLength(s));\n }\n\n decode(s: string): Uint8Array {\n if (s.length === 0) {\n return new Uint8Array(0);\n }\n const paddingLength = this._getPaddingLength(s);\n const length = s.length - paddingLength;\n const out = new Uint8Array(this.maxDecodedLength(length));\n let op = 0;\n let i = 0;\n let haveBad = 0;\n let v0 = 0, v1 = 0, v2 = 0, v3 = 0;\n for (; i < length - 4; i += 4) {\n v0 = this._decodeChar(s.charCodeAt(i + 0));\n v1 = this._decodeChar(s.charCodeAt(i + 1));\n v2 = this._decodeChar(s.charCodeAt(i + 2));\n v3 = this._decodeChar(s.charCodeAt(i + 3));\n out[op++] = (v0 << 2) | (v1 >>> 4);\n out[op++] = (v1 << 4) | (v2 >>> 2);\n out[op++] = (v2 << 6) | v3;\n haveBad |= v0 & INVALID_BYTE;\n haveBad |= v1 & INVALID_BYTE;\n haveBad |= v2 & INVALID_BYTE;\n haveBad |= v3 & INVALID_BYTE;\n }\n if (i < length - 1) {\n v0 = this._decodeChar(s.charCodeAt(i));\n v1 = this._decodeChar(s.charCodeAt(i + 1));\n out[op++] = (v0 << 2) | (v1 >>> 4);\n haveBad |= v0 & INVALID_BYTE;\n haveBad |= v1 & INVALID_BYTE;\n }\n if (i < length - 2) {\n v2 = this._decodeChar(s.charCodeAt(i + 2));\n out[op++] = (v1 << 4) | (v2 >>> 2);\n haveBad |= v2 & INVALID_BYTE;\n }\n if (i < length - 3) {\n v3 = this._decodeChar(s.charCodeAt(i + 3));\n out[op++] = (v2 << 6) | v3;\n haveBad |= v3 & INVALID_BYTE;\n }\n if (haveBad !== 0) {\n throw new Error(\"Base64Coder: incorrect characters for decoding\");\n }\n return out;\n }\n\n // Standard encoding have the following encoded/decoded ranges,\n // which we need to convert between.\n //\n // ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 0123456789 + /\n // Index: 0 - 25 26 - 51 52 - 61 62 63\n // ASCII: 65 - 90 97 - 122 48 - 57 43 47\n //\n\n // Encode 6 bits in b into a new character.\n protected _encodeByte(b: number): string {\n // Encoding uses constant time operations as follows:\n //\n // 1. Define comparison of A with B using (A - B) >>> 8:\n // if A > B, then result is positive integer\n // if A <= B, then result is 0\n //\n // 2. Define selection of C or 0 using bitwise AND: X & C:\n // if X == 0, then result is 0\n // if X != 0, then result is C\n //\n // 3. Start with the smallest comparison (b >= 0), which is always\n // true, so set the result to the starting ASCII value (65).\n //\n // 4. Continue comparing b to higher ASCII values, and selecting\n // zero if comparison isn't true, otherwise selecting a value\n // to add to result, which:\n //\n // a) undoes the previous addition\n // b) provides new value to add\n //\n let result = b;\n // b >= 0\n result += 65;\n // b > 25\n result += ((25 - b) >>> 8) & ((0 - 65) - 26 + 97);\n // b > 51\n result += ((51 - b) >>> 8) & ((26 - 97) - 52 + 48);\n // b > 61\n result += ((61 - b) >>> 8) & ((52 - 48) - 62 + 43);\n // b > 62\n result += ((62 - b) >>> 8) & ((62 - 43) - 63 + 47);\n\n return String.fromCharCode(result);\n }\n\n // Decode a character code into a byte.\n // Must return 256 if character is out of alphabet range.\n protected _decodeChar(c: number): number {\n // Decoding works similar to encoding: using the same comparison\n // function, but now it works on ranges: result is always incremented\n // by value, but this value becomes zero if the range is not\n // satisfied.\n //\n // Decoding starts with invalid value, 256, which is then\n // subtracted when the range is satisfied. If none of the ranges\n // apply, the function returns 256, which is then checked by\n // the caller to throw error.\n let result = INVALID_BYTE; // start with invalid character\n\n // c == 43 (c > 42 and c < 44)\n result += (((42 - c) & (c - 44)) >>> 8) & (-INVALID_BYTE + c - 43 + 62);\n // c == 47 (c > 46 and c < 48)\n result += (((46 - c) & (c - 48)) >>> 8) & (-INVALID_BYTE + c - 47 + 63);\n // c > 47 and c < 58\n result += (((47 - c) & (c - 58)) >>> 8) & (-INVALID_BYTE + c - 48 + 52);\n // c > 64 and c < 91\n result += (((64 - c) & (c - 91)) >>> 8) & (-INVALID_BYTE + c - 65 + 0);\n // c > 96 and c < 123\n result += (((96 - c) & (c - 123)) >>> 8) & (-INVALID_BYTE + c - 97 + 26);\n\n return result;\n }\n\n private _getPaddingLength(s: string): number {\n let paddingLength = 0;\n if (this._paddingCharacter) {\n for (let i = s.length - 1; i >= 0; i--) {\n if (s[i] !== this._paddingCharacter) {\n break;\n }\n paddingLength++;\n }\n if (s.length < 4 || paddingLength > 2) {\n throw new Error(\"Base64Coder: incorrect padding\");\n }\n }\n return paddingLength;\n }\n\n}\n\nconst stdCoder = new Coder();\n\nexport function encode(data: Uint8Array): string {\n return stdCoder.encode(data);\n}\n\nexport function decode(s: string): Uint8Array {\n return stdCoder.decode(s);\n}\n\n/**\n * Implements URL-safe Base64 encoding.\n * (Same as Base64, but '+' is replaced with '-', and '/' with '_').\n *\n * Operates in constant time.\n */\nexport class URLSafeCoder extends Coder {\n // URL-safe encoding have the following encoded/decoded ranges:\n //\n // ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 0123456789 - _\n // Index: 0 - 25 26 - 51 52 - 61 62 63\n // ASCII: 65 - 90 97 - 122 48 - 57 45 95\n //\n\n protected _encodeByte(b: number): string {\n let result = b;\n // b >= 0\n result += 65;\n // b > 25\n result += ((25 - b) >>> 8) & ((0 - 65) - 26 + 97);\n // b > 51\n result += ((51 - b) >>> 8) & ((26 - 97) - 52 + 48);\n // b > 61\n result += ((61 - b) >>> 8) & ((52 - 48) - 62 + 45);\n // b > 62\n result += ((62 - b) >>> 8) & ((62 - 45) - 63 + 95);\n\n return String.fromCharCode(result);\n }\n\n protected _decodeChar(c: number): number {\n let result = INVALID_BYTE;\n\n // c == 45 (c > 44 and c < 46)\n result += (((44 - c) & (c - 46)) >>> 8) & (-INVALID_BYTE + c - 45 + 62);\n // c == 95 (c > 94 and c < 96)\n result += (((94 - c) & (c - 96)) >>> 8) & (-INVALID_BYTE + c - 95 + 63);\n // c > 47 and c < 58\n result += (((47 - c) & (c - 58)) >>> 8) & (-INVALID_BYTE + c - 48 + 52);\n // c > 64 and c < 91\n result += (((64 - c) & (c - 91)) >>> 8) & (-INVALID_BYTE + c - 65 + 0);\n // c > 96 and c < 123\n result += (((96 - c) & (c - 123)) >>> 8) & (-INVALID_BYTE + c - 97 + 26);\n\n return result;\n }\n}\n\nconst urlSafeCoder = new URLSafeCoder();\n\nexport function encodeURLSafe(data: Uint8Array): string {\n return urlSafeCoder.encode(data);\n}\n\nexport function decodeURLSafe(s: string): Uint8Array {\n return urlSafeCoder.decode(s);\n}\n\n\nexport const encodedLength = (length: number) =>\n stdCoder.encodedLength(length);\n\nexport const maxDecodedLength = (length: number) =>\n stdCoder.maxDecodedLength(length);\n\nexport const decodedLength = (s: string) =>\n stdCoder.decodedLength(s);\n","'use strict';\n\nvar Headers = function() {\n this.clear();\n};\n\nHeaders.prototype.ALLOWED_DUPLICATES = ['set-cookie', 'set-cookie2', 'warning', 'www-authenticate'];\n\nHeaders.prototype.clear = function() {\n this._sent = {};\n this._lines = [];\n};\n\nHeaders.prototype.set = function(name, value) {\n if (value === undefined) return;\n\n name = this._strip(name);\n value = this._strip(value);\n\n var key = name.toLowerCase();\n if (!this._sent.hasOwnProperty(key) || this.ALLOWED_DUPLICATES.indexOf(key) >= 0) {\n this._sent[key] = true;\n this._lines.push(name + ': ' + value + '\\r\\n');\n }\n};\n\nHeaders.prototype.toString = function() {\n return this._lines.join('');\n};\n\nHeaders.prototype._strip = function(string) {\n return string.toString().replace(/^ */, '').replace(/ *$/, '');\n};\n\nmodule.exports = Headers;\n","'use strict';\n\nvar NodeHTTPParser = require('http-parser-js').HTTPParser,\n Buffer = require('safe-buffer').Buffer;\n\nvar TYPES = {\n request: NodeHTTPParser.REQUEST || 'request',\n response: NodeHTTPParser.RESPONSE || 'response'\n};\n\nvar HttpParser = function(type) {\n this._type = type;\n this._parser = new NodeHTTPParser(TYPES[type]);\n this._complete = false;\n this.headers = {};\n\n var current = null,\n self = this;\n\n this._parser.onHeaderField = function(b, start, length) {\n current = b.toString('utf8', start, start + length).toLowerCase();\n };\n\n this._parser.onHeaderValue = function(b, start, length) {\n var value = b.toString('utf8', start, start + length);\n\n if (self.headers.hasOwnProperty(current))\n self.headers[current] += ', ' + value;\n else\n self.headers[current] = value;\n };\n\n this._parser.onHeadersComplete = this._parser[NodeHTTPParser.kOnHeadersComplete] =\n function(majorVersion, minorVersion, headers, method, pathname, statusCode) {\n var info = arguments[0];\n\n if (typeof info === 'object') {\n method = info.method;\n pathname = info.url;\n statusCode = info.statusCode;\n headers = info.headers;\n }\n\n self.method = (typeof method === 'number') ? HttpParser.METHODS[method] : method;\n self.statusCode = statusCode;\n self.url = pathname;\n\n if (!headers) return;\n\n for (var i = 0, n = headers.length, key, value; i < n; i += 2) {\n key = headers[i].toLowerCase();\n value = headers[i+1];\n if (self.headers.hasOwnProperty(key))\n self.headers[key] += ', ' + value;\n else\n self.headers[key] = value;\n }\n\n self._complete = true;\n };\n};\n\nHttpParser.METHODS = {\n 0: 'DELETE',\n 1: 'GET',\n 2: 'HEAD',\n 3: 'POST',\n 4: 'PUT',\n 5: 'CONNECT',\n 6: 'OPTIONS',\n 7: 'TRACE',\n 8: 'COPY',\n 9: 'LOCK',\n 10: 'MKCOL',\n 11: 'MOVE',\n 12: 'PROPFIND',\n 13: 'PROPPATCH',\n 14: 'SEARCH',\n 15: 'UNLOCK',\n 16: 'BIND',\n 17: 'REBIND',\n 18: 'UNBIND',\n 19: 'ACL',\n 20: 'REPORT',\n 21: 'MKACTIVITY',\n 22: 'CHECKOUT',\n 23: 'MERGE',\n 24: 'M-SEARCH',\n 25: 'NOTIFY',\n 26: 'SUBSCRIBE',\n 27: 'UNSUBSCRIBE',\n 28: 'PATCH',\n 29: 'PURGE',\n 30: 'MKCALENDAR',\n 31: 'LINK',\n 32: 'UNLINK'\n};\n\nvar VERSION = process.version\n ? process.version.match(/[0-9]+/g).map(function(n) { return parseInt(n, 10) })\n : [];\n\nif (VERSION[0] === 0 && VERSION[1] === 12) {\n HttpParser.METHODS[16] = 'REPORT';\n HttpParser.METHODS[17] = 'MKACTIVITY';\n HttpParser.METHODS[18] = 'CHECKOUT';\n HttpParser.METHODS[19] = 'MERGE';\n HttpParser.METHODS[20] = 'M-SEARCH';\n HttpParser.METHODS[21] = 'NOTIFY';\n HttpParser.METHODS[22] = 'SUBSCRIBE';\n HttpParser.METHODS[23] = 'UNSUBSCRIBE';\n HttpParser.METHODS[24] = 'PATCH';\n HttpParser.METHODS[25] = 'PURGE';\n}\n\nHttpParser.prototype.isComplete = function() {\n return this._complete;\n};\n\nHttpParser.prototype.parse = function(chunk) {\n var consumed = this._parser.execute(chunk, 0, chunk.length);\n\n if (typeof consumed !== 'number') {\n this.error = consumed;\n this._complete = true;\n return;\n }\n\n if (this._complete)\n this.body = (consumed < chunk.length)\n ? chunk.slice(consumed)\n : Buffer.alloc(0);\n};\n\nmodule.exports = HttpParser;\n","'use strict';\n\nvar Stream = require('stream').Stream,\n util = require('util'),\n driver = require('websocket-driver'),\n EventTarget = require('./api/event_target'),\n Event = require('./api/event');\n\nvar API = function(options) {\n options = options || {};\n driver.validateOptions(options, ['headers', 'extensions', 'maxLength', 'ping', 'proxy', 'tls', 'ca']);\n\n this.readable = this.writable = true;\n\n var headers = options.headers;\n if (headers) {\n for (var name in headers) this._driver.setHeader(name, headers[name]);\n }\n\n var extensions = options.extensions;\n if (extensions) {\n [].concat(extensions).forEach(this._driver.addExtension, this._driver);\n }\n\n this._ping = options.ping;\n this._pingId = 0;\n this.readyState = API.CONNECTING;\n this.bufferedAmount = 0;\n this.protocol = '';\n this.url = this._driver.url;\n this.version = this._driver.version;\n\n var self = this;\n\n this._driver.on('open', function(e) { self._open() });\n this._driver.on('message', function(e) { self._receiveMessage(e.data) });\n this._driver.on('close', function(e) { self._beginClose(e.reason, e.code) });\n\n this._driver.on('error', function(error) {\n self._emitError(error.message);\n });\n this.on('error', function() {});\n\n this._driver.messages.on('drain', function() {\n self.emit('drain');\n });\n\n if (this._ping)\n this._pingTimer = setInterval(function() {\n self._pingId += 1;\n self.ping(self._pingId.toString());\n }, this._ping * 1000);\n\n this._configureStream();\n\n if (!this._proxy) {\n this._stream.pipe(this._driver.io);\n this._driver.io.pipe(this._stream);\n }\n};\nutil.inherits(API, Stream);\n\nAPI.CONNECTING = 0;\nAPI.OPEN = 1;\nAPI.CLOSING = 2;\nAPI.CLOSED = 3;\n\nAPI.CLOSE_TIMEOUT = 30000;\n\nvar instance = {\n write: function(data) {\n return this.send(data);\n },\n\n end: function(data) {\n if (data !== undefined) this.send(data);\n this.close();\n },\n\n pause: function() {\n return this._driver.messages.pause();\n },\n\n resume: function() {\n return this._driver.messages.resume();\n },\n\n send: function(data) {\n if (this.readyState > API.OPEN) return false;\n if (!(data instanceof Buffer)) data = String(data);\n return this._driver.messages.write(data);\n },\n\n ping: function(message, callback) {\n if (this.readyState > API.OPEN) return false;\n return this._driver.ping(message, callback);\n },\n\n close: function(code, reason) {\n if (code === undefined) code = 1000;\n if (reason === undefined) reason = '';\n\n if (code !== 1000 && (code < 3000 || code > 4999))\n throw new Error(\"Failed to execute 'close' on WebSocket: \" +\n \"The code must be either 1000, or between 3000 and 4999. \" +\n code + \" is neither.\");\n\n if (this.readyState !== API.CLOSED) this.readyState = API.CLOSING;\n var self = this;\n\n this._closeTimer = setTimeout(function() {\n self._beginClose('', 1006);\n }, API.CLOSE_TIMEOUT);\n\n this._driver.close(reason, code);\n },\n\n _configureStream: function() {\n var self = this;\n\n this._stream.setTimeout(0);\n this._stream.setNoDelay(true);\n\n ['close', 'end'].forEach(function(event) {\n this._stream.on(event, function() { self._finalizeClose() });\n }, this);\n\n this._stream.on('error', function(error) {\n self._emitError('Network error: ' + self.url + ': ' + error.message);\n self._finalizeClose();\n });\n },\n\n _open: function() {\n if (this.readyState !== API.CONNECTING) return;\n\n this.readyState = API.OPEN;\n this.protocol = this._driver.protocol || '';\n\n var event = new Event('open');\n event.initEvent('open', false, false);\n this.dispatchEvent(event);\n },\n\n _receiveMessage: function(data) {\n if (this.readyState > API.OPEN) return false;\n\n if (this.readable) this.emit('data', data);\n\n var event = new Event('message', {data: data});\n event.initEvent('message', false, false);\n this.dispatchEvent(event);\n },\n\n _emitError: function(message) {\n if (this.readyState >= API.CLOSING) return;\n\n var event = new Event('error', {message: message});\n event.initEvent('error', false, false);\n this.dispatchEvent(event);\n },\n\n _beginClose: function(reason, code) {\n if (this.readyState === API.CLOSED) return;\n this.readyState = API.CLOSING;\n this._closeParams = [reason, code];\n\n if (this._stream) {\n this._stream.destroy();\n if (!this._stream.readable) this._finalizeClose();\n }\n },\n\n _finalizeClose: function() {\n if (this.readyState === API.CLOSED) return;\n this.readyState = API.CLOSED;\n\n if (this._closeTimer) clearTimeout(this._closeTimer);\n if (this._pingTimer) clearInterval(this._pingTimer);\n if (this._stream) this._stream.end();\n\n if (this.readable) this.emit('end');\n this.readable = this.writable = false;\n\n var reason = this._closeParams ? this._closeParams[0] : '',\n code = this._closeParams ? this._closeParams[1] : 1006;\n\n var event = new Event('close', {code: code, reason: reason});\n event.initEvent('close', false, false);\n this.dispatchEvent(event);\n }\n};\n\nfor (var method in instance) API.prototype[method] = instance[method];\nfor (var key in EventTarget) API.prototype[key] = EventTarget[key];\n\nmodule.exports = API;\n","'use strict';\n\nvar Buffer = require('safe-buffer').Buffer,\n crypto = require('crypto'),\n util = require('util'),\n Extensions = require('websocket-extensions'),\n Base = require('./base'),\n Frame = require('./hybi/frame'),\n Message = require('./hybi/message');\n\nvar Hybi = function(request, url, options) {\n Base.apply(this, arguments);\n\n this._extensions = new Extensions();\n this._stage = 0;\n this._masking = this._options.masking;\n this._protocols = this._options.protocols || [];\n this._requireMasking = this._options.requireMasking;\n this._pingCallbacks = {};\n\n if (typeof this._protocols === 'string')\n this._protocols = this._protocols.split(/ *, */);\n\n if (!this._request) return;\n\n var protos = this._request.headers['sec-websocket-protocol'],\n supported = this._protocols;\n\n if (protos !== undefined) {\n if (typeof protos === 'string') protos = protos.split(/ *, */);\n this.protocol = protos.filter(function(p) { return supported.indexOf(p) >= 0 })[0];\n }\n\n this.version = 'hybi-' + Hybi.VERSION;\n};\nutil.inherits(Hybi, Base);\n\nHybi.VERSION = '13';\n\nHybi.mask = function(payload, mask, offset) {\n if (!mask || mask.length === 0) return payload;\n offset = offset || 0;\n\n for (var i = 0, n = payload.length - offset; i < n; i++) {\n payload[offset + i] = payload[offset + i] ^ mask[i % 4];\n }\n return payload;\n};\n\nHybi.generateAccept = function(key) {\n var sha1 = crypto.createHash('sha1');\n sha1.update(key + Hybi.GUID);\n return sha1.digest('base64');\n};\n\nHybi.GUID = '258EAFA5-E914-47DA-95CA-C5AB0DC85B11';\n\nvar instance = {\n FIN: 0x80,\n MASK: 0x80,\n RSV1: 0x40,\n RSV2: 0x20,\n RSV3: 0x10,\n OPCODE: 0x0F,\n LENGTH: 0x7F,\n\n OPCODES: {\n continuation: 0,\n text: 1,\n binary: 2,\n close: 8,\n ping: 9,\n pong: 10\n },\n\n OPCODE_CODES: [0, 1, 2, 8, 9, 10],\n MESSAGE_OPCODES: [0, 1, 2],\n OPENING_OPCODES: [1, 2],\n\n ERRORS: {\n normal_closure: 1000,\n going_away: 1001,\n protocol_error: 1002,\n unacceptable: 1003,\n encoding_error: 1007,\n policy_violation: 1008,\n too_large: 1009,\n extension_error: 1010,\n unexpected_condition: 1011\n },\n\n ERROR_CODES: [1000, 1001, 1002, 1003, 1007, 1008, 1009, 1010, 1011],\n DEFAULT_ERROR_CODE: 1000,\n MIN_RESERVED_ERROR: 3000,\n MAX_RESERVED_ERROR: 4999,\n\n // http://www.w3.org/International/questions/qa-forms-utf-8.en.php\n UTF8_MATCH: /^([\\x00-\\x7F]|[\\xC2-\\xDF][\\x80-\\xBF]|\\xE0[\\xA0-\\xBF][\\x80-\\xBF]|[\\xE1-\\xEC\\xEE\\xEF][\\x80-\\xBF]{2}|\\xED[\\x80-\\x9F][\\x80-\\xBF]|\\xF0[\\x90-\\xBF][\\x80-\\xBF]{2}|[\\xF1-\\xF3][\\x80-\\xBF]{3}|\\xF4[\\x80-\\x8F][\\x80-\\xBF]{2})*$/,\n\n addExtension: function(extension) {\n this._extensions.add(extension);\n return true;\n },\n\n parse: function(chunk) {\n this._reader.put(chunk);\n var buffer = true;\n while (buffer) {\n switch (this._stage) {\n case 0:\n buffer = this._reader.read(1);\n if (buffer) this._parseOpcode(buffer[0]);\n break;\n\n case 1:\n buffer = this._reader.read(1);\n if (buffer) this._parseLength(buffer[0]);\n break;\n\n case 2:\n buffer = this._reader.read(this._frame.lengthBytes);\n if (buffer) this._parseExtendedLength(buffer);\n break;\n\n case 3:\n buffer = this._reader.read(4);\n if (buffer) {\n this._stage = 4;\n this._frame.maskingKey = buffer;\n }\n break;\n\n case 4:\n buffer = this._reader.read(this._frame.length);\n if (buffer) {\n this._stage = 0;\n this._emitFrame(buffer);\n }\n break;\n\n default:\n buffer = null;\n }\n }\n },\n\n text: function(message) {\n if (this.readyState > 1) return false;\n return this.frame(message, 'text');\n },\n\n binary: function(message) {\n if (this.readyState > 1) return false;\n return this.frame(message, 'binary');\n },\n\n ping: function(message, callback) {\n if (this.readyState > 1) return false;\n message = message || '';\n if (callback) this._pingCallbacks[message] = callback;\n return this.frame(message, 'ping');\n },\n\n pong: function(message) {\n if (this.readyState > 1) return false;\n message = message ||'';\n return this.frame(message, 'pong');\n },\n\n close: function(reason, code) {\n reason = reason || '';\n code = code || this.ERRORS.normal_closure;\n\n if (this.readyState <= 0) {\n this.readyState = 3;\n this.emit('close', new Base.CloseEvent(code, reason));\n return true;\n } else if (this.readyState === 1) {\n this.readyState = 2;\n this._extensions.close(function() { this.frame(reason, 'close', code) }, this);\n return true;\n } else {\n return false;\n }\n },\n\n frame: function(buffer, type, code) {\n if (this.readyState <= 0) return this._queue([buffer, type, code]);\n if (this.readyState > 2) return false;\n\n if (buffer instanceof Array) buffer = Buffer.from(buffer);\n if (typeof buffer === 'number') buffer = buffer.toString();\n\n var message = new Message(),\n isText = (typeof buffer === 'string'),\n payload, copy;\n\n message.rsv1 = message.rsv2 = message.rsv3 = false;\n message.opcode = this.OPCODES[type || (isText ? 'text' : 'binary')];\n\n payload = isText ? Buffer.from(buffer, 'utf8') : buffer;\n\n if (code) {\n copy = payload;\n payload = Buffer.allocUnsafe(2 + copy.length);\n payload.writeUInt16BE(code, 0);\n copy.copy(payload, 2);\n }\n message.data = payload;\n\n var onMessageReady = function(message) {\n var frame = new Frame();\n\n frame.final = true;\n frame.rsv1 = message.rsv1;\n frame.rsv2 = message.rsv2;\n frame.rsv3 = message.rsv3;\n frame.opcode = message.opcode;\n frame.masked = !!this._masking;\n frame.length = message.data.length;\n frame.payload = message.data;\n\n if (frame.masked) frame.maskingKey = crypto.randomBytes(4);\n\n this._sendFrame(frame);\n };\n\n if (this.MESSAGE_OPCODES.indexOf(message.opcode) >= 0)\n this._extensions.processOutgoingMessage(message, function(error, message) {\n if (error) return this._fail('extension_error', error.message);\n onMessageReady.call(this, message);\n }, this);\n else\n onMessageReady.call(this, message);\n\n return true;\n },\n\n _sendFrame: function(frame) {\n var length = frame.length,\n header = (length <= 125) ? 2 : (length <= 65535 ? 4 : 10),\n offset = header + (frame.masked ? 4 : 0),\n buffer = Buffer.allocUnsafe(offset + length),\n masked = frame.masked ? this.MASK : 0;\n\n buffer[0] = (frame.final ? this.FIN : 0) |\n (frame.rsv1 ? this.RSV1 : 0) |\n (frame.rsv2 ? this.RSV2 : 0) |\n (frame.rsv3 ? this.RSV3 : 0) |\n frame.opcode;\n\n if (length <= 125) {\n buffer[1] = masked | length;\n } else if (length <= 65535) {\n buffer[1] = masked | 126;\n buffer.writeUInt16BE(length, 2);\n } else {\n buffer[1] = masked | 127;\n buffer.writeUInt32BE(Math.floor(length / 0x100000000), 2);\n buffer.writeUInt32BE(length % 0x100000000, 6);\n }\n\n frame.payload.copy(buffer, offset);\n\n if (frame.masked) {\n frame.maskingKey.copy(buffer, header);\n Hybi.mask(buffer, frame.maskingKey, offset);\n }\n\n this._write(buffer);\n },\n\n _handshakeResponse: function() {\n var secKey = this._request.headers['sec-websocket-key'],\n version = this._request.headers['sec-websocket-version'];\n\n if (version !== Hybi.VERSION)\n throw new Error('Unsupported WebSocket version: ' + version);\n\n if (typeof secKey !== 'string')\n throw new Error('Missing handshake request header: Sec-WebSocket-Key');\n\n this._headers.set('Upgrade', 'websocket');\n this._headers.set('Connection', 'Upgrade');\n this._headers.set('Sec-WebSocket-Accept', Hybi.generateAccept(secKey));\n\n if (this.protocol) this._headers.set('Sec-WebSocket-Protocol', this.protocol);\n\n var extensions = this._extensions.generateResponse(this._request.headers['sec-websocket-extensions']);\n if (extensions) this._headers.set('Sec-WebSocket-Extensions', extensions);\n\n var start = 'HTTP/1.1 101 Switching Protocols',\n headers = [start, this._headers.toString(), ''];\n\n return Buffer.from(headers.join('\\r\\n'), 'utf8');\n },\n\n _shutdown: function(code, reason, error) {\n delete this._frame;\n delete this._message;\n this._stage = 5;\n\n var sendCloseFrame = (this.readyState === 1);\n this.readyState = 2;\n\n this._extensions.close(function() {\n if (sendCloseFrame) this.frame(reason, 'close', code);\n this.readyState = 3;\n if (error) this.emit('error', new Error(reason));\n this.emit('close', new Base.CloseEvent(code, reason));\n }, this);\n },\n\n _fail: function(type, message) {\n if (this.readyState > 1) return;\n this._shutdown(this.ERRORS[type], message, true);\n },\n\n _parseOpcode: function(octet) {\n var rsvs = [this.RSV1, this.RSV2, this.RSV3].map(function(rsv) {\n return (octet & rsv) === rsv;\n });\n\n var frame = this._frame = new Frame();\n\n frame.final = (octet & this.FIN) === this.FIN;\n frame.rsv1 = rsvs[0];\n frame.rsv2 = rsvs[1];\n frame.rsv3 = rsvs[2];\n frame.opcode = (octet & this.OPCODE);\n\n this._stage = 1;\n\n if (!this._extensions.validFrameRsv(frame))\n return this._fail('protocol_error',\n 'One or more reserved bits are on: reserved1 = ' + (frame.rsv1 ? 1 : 0) +\n ', reserved2 = ' + (frame.rsv2 ? 1 : 0) +\n ', reserved3 = ' + (frame.rsv3 ? 1 : 0));\n\n if (this.OPCODE_CODES.indexOf(frame.opcode) < 0)\n return this._fail('protocol_error', 'Unrecognized frame opcode: ' + frame.opcode);\n\n if (this.MESSAGE_OPCODES.indexOf(frame.opcode) < 0 && !frame.final)\n return this._fail('protocol_error', 'Received fragmented control frame: opcode = ' + frame.opcode);\n\n if (this._message && this.OPENING_OPCODES.indexOf(frame.opcode) >= 0)\n return this._fail('protocol_error', 'Received new data frame but previous continuous frame is unfinished');\n },\n\n _parseLength: function(octet) {\n var frame = this._frame;\n frame.masked = (octet & this.MASK) === this.MASK;\n frame.length = (octet & this.LENGTH);\n\n if (frame.length >= 0 && frame.length <= 125) {\n this._stage = frame.masked ? 3 : 4;\n if (!this._checkFrameLength()) return;\n } else {\n this._stage = 2;\n frame.lengthBytes = (frame.length === 126 ? 2 : 8);\n }\n\n if (this._requireMasking && !frame.masked)\n return this._fail('unacceptable', 'Received unmasked frame but masking is required');\n },\n\n _parseExtendedLength: function(buffer) {\n var frame = this._frame;\n frame.length = this._readUInt(buffer);\n\n this._stage = frame.masked ? 3 : 4;\n\n if (this.MESSAGE_OPCODES.indexOf(frame.opcode) < 0 && frame.length > 125)\n return this._fail('protocol_error', 'Received control frame having too long payload: ' + frame.length);\n\n if (!this._checkFrameLength()) return;\n },\n\n _checkFrameLength: function() {\n var length = this._message ? this._message.length : 0;\n\n if (length + this._frame.length > this._maxLength) {\n this._fail('too_large', 'WebSocket frame length too large');\n return false;\n } else {\n return true;\n }\n },\n\n _emitFrame: function(buffer) {\n var frame = this._frame,\n payload = frame.payload = Hybi.mask(buffer, frame.maskingKey),\n opcode = frame.opcode,\n message,\n code, reason,\n callbacks, callback;\n\n delete this._frame;\n\n if (opcode === this.OPCODES.continuation) {\n if (!this._message) return this._fail('protocol_error', 'Received unexpected continuation frame');\n this._message.pushFrame(frame);\n }\n\n if (opcode === this.OPCODES.text || opcode === this.OPCODES.binary) {\n this._message = new Message();\n this._message.pushFrame(frame);\n }\n\n if (frame.final && this.MESSAGE_OPCODES.indexOf(opcode) >= 0)\n return this._emitMessage(this._message);\n\n if (opcode === this.OPCODES.close) {\n code = (payload.length >= 2) ? payload.readUInt16BE(0) : null;\n reason = (payload.length > 2) ? this._encode(payload.slice(2)) : null;\n\n if (!(payload.length === 0) &&\n !(code !== null && code >= this.MIN_RESERVED_ERROR && code <= this.MAX_RESERVED_ERROR) &&\n this.ERROR_CODES.indexOf(code) < 0)\n code = this.ERRORS.protocol_error;\n\n if (payload.length > 125 || (payload.length > 2 && !reason))\n code = this.ERRORS.protocol_error;\n\n this._shutdown(code || this.DEFAULT_ERROR_CODE, reason || '');\n }\n\n if (opcode === this.OPCODES.ping) {\n this.frame(payload, 'pong');\n this.emit('ping', new Base.PingEvent(payload.toString()))\n }\n\n if (opcode === this.OPCODES.pong) {\n callbacks = this._pingCallbacks;\n message = this._encode(payload);\n callback = callbacks[message];\n\n delete callbacks[message];\n if (callback) callback()\n\n this.emit('pong', new Base.PongEvent(payload.toString()))\n }\n },\n\n _emitMessage: function(message) {\n var message = this._message;\n message.read();\n\n delete this._message;\n\n this._extensions.processIncomingMessage(message, function(error, message) {\n if (error) return this._fail('extension_error', error.message);\n\n var payload = message.data;\n if (message.opcode === this.OPCODES.text) payload = this._encode(payload);\n\n if (payload === null)\n return this._fail('encoding_error', 'Could not decode a text frame as UTF-8');\n else\n this.emit('message', new Base.MessageEvent(payload));\n }, this);\n },\n\n _encode: function(buffer) {\n try {\n var string = buffer.toString('binary', 0, buffer.length);\n if (!this.UTF8_MATCH.test(string)) return null;\n } catch (e) {}\n return buffer.toString('utf8', 0, buffer.length);\n },\n\n _readUInt: function(buffer) {\n if (buffer.length === 2) return buffer.readUInt16BE(0);\n\n return buffer.readUInt32BE(0) * 0x100000000 +\n buffer.readUInt32BE(4);\n }\n};\n\nfor (var key in instance)\n Hybi.prototype[key] = instance[key];\n\nmodule.exports = Hybi;\n","'use strict';\n\nvar RingBuffer = function(bufferSize) {\n this._bufferSize = bufferSize;\n this.clear();\n};\n\nRingBuffer.prototype.clear = function() {\n this._buffer = new Array(this._bufferSize);\n this._ringOffset = 0;\n this._ringSize = this._bufferSize;\n this._head = 0;\n this._tail = 0;\n this.length = 0;\n};\n\nRingBuffer.prototype.push = function(value) {\n var expandBuffer = false,\n expandRing = false;\n\n if (this._ringSize < this._bufferSize) {\n expandBuffer = (this._tail === 0);\n } else if (this._ringOffset === this._ringSize) {\n expandBuffer = true;\n expandRing = (this._tail === 0);\n }\n\n if (expandBuffer) {\n this._tail = this._bufferSize;\n this._buffer = this._buffer.concat(new Array(this._bufferSize));\n this._bufferSize = this._buffer.length;\n\n if (expandRing)\n this._ringSize = this._bufferSize;\n }\n\n this._buffer[this._tail] = value;\n this.length += 1;\n if (this._tail < this._ringSize) this._ringOffset += 1;\n this._tail = (this._tail + 1) % this._bufferSize;\n};\n\nRingBuffer.prototype.peek = function() {\n if (this.length === 0) return void 0;\n return this._buffer[this._head];\n};\n\nRingBuffer.prototype.shift = function() {\n if (this.length === 0) return void 0;\n\n var value = this._buffer[this._head];\n this._buffer[this._head] = void 0;\n this.length -= 1;\n this._ringOffset -= 1;\n\n if (this._ringOffset === 0 && this.length > 0) {\n this._head = this._ringSize;\n this._ringOffset = this.length;\n this._ringSize = this._bufferSize;\n } else {\n this._head = (this._head + 1) % this._ringSize;\n }\n return value;\n};\n\nmodule.exports = RingBuffer;\n","'use strict';\n\nvar RingBuffer = require('./ring_buffer');\n\nvar Pledge = function() {\n this._complete = false;\n this._callbacks = new RingBuffer(Pledge.QUEUE_SIZE);\n};\n\nPledge.QUEUE_SIZE = 4;\n\nPledge.all = function(list) {\n var pledge = new Pledge(),\n pending = list.length,\n n = pending;\n\n if (pending === 0) pledge.done();\n\n while (n--) list[n].then(function() {\n pending -= 1;\n if (pending === 0) pledge.done();\n });\n return pledge;\n};\n\nPledge.prototype.then = function(callback) {\n if (this._complete) callback();\n else this._callbacks.push(callback);\n};\n\nPledge.prototype.done = function() {\n this._complete = true;\n var callbacks = this._callbacks, callback;\n while (callback = callbacks.shift()) callback();\n};\n\nmodule.exports = Pledge;\n","'use strict';\n\nvar Buffer = require('safe-buffer').Buffer,\n Base = require('./base'),\n util = require('util');\n\nvar Draft75 = function(request, url, options) {\n Base.apply(this, arguments);\n this._stage = 0;\n this.version = 'hixie-75';\n\n this._headers.set('Upgrade', 'WebSocket');\n this._headers.set('Connection', 'Upgrade');\n this._headers.set('WebSocket-Origin', this._request.headers.origin);\n this._headers.set('WebSocket-Location', this.url);\n};\nutil.inherits(Draft75, Base);\n\nvar instance = {\n close: function() {\n if (this.readyState === 3) return false;\n this.readyState = 3;\n this.emit('close', new Base.CloseEvent(null, null));\n return true;\n },\n\n parse: function(chunk) {\n if (this.readyState > 1) return;\n\n this._reader.put(chunk);\n\n this._reader.eachByte(function(octet) {\n var message;\n\n switch (this._stage) {\n case -1:\n this._body.push(octet);\n this._sendHandshakeBody();\n break;\n\n case 0:\n this._parseLeadingByte(octet);\n break;\n\n case 1:\n this._length = (octet & 0x7F) + 128 * this._length;\n\n if (this._closing && this._length === 0) {\n return this.close();\n }\n else if ((octet & 0x80) !== 0x80) {\n if (this._length === 0) {\n this._stage = 0;\n }\n else {\n this._skipped = 0;\n this._stage = 2;\n }\n }\n break;\n\n case 2:\n if (octet === 0xFF) {\n this._stage = 0;\n message = Buffer.from(this._buffer).toString('utf8', 0, this._buffer.length);\n this.emit('message', new Base.MessageEvent(message));\n }\n else {\n if (this._length) {\n this._skipped += 1;\n if (this._skipped === this._length)\n this._stage = 0;\n } else {\n this._buffer.push(octet);\n if (this._buffer.length > this._maxLength) return this.close();\n }\n }\n break;\n }\n }, this);\n },\n\n frame: function(buffer) {\n if (this.readyState === 0) return this._queue([buffer]);\n if (this.readyState > 1) return false;\n\n if (typeof buffer !== 'string') buffer = buffer.toString();\n\n var length = Buffer.byteLength(buffer),\n frame = Buffer.allocUnsafe(length + 2);\n\n frame[0] = 0x00;\n frame.write(buffer, 1);\n frame[frame.length - 1] = 0xFF;\n\n this._write(frame);\n return true;\n },\n\n _handshakeResponse: function() {\n var start = 'HTTP/1.1 101 Web Socket Protocol Handshake',\n headers = [start, this._headers.toString(), ''];\n\n return Buffer.from(headers.join('\\r\\n'), 'utf8');\n },\n\n _parseLeadingByte: function(octet) {\n if ((octet & 0x80) === 0x80) {\n this._length = 0;\n this._stage = 1;\n } else {\n delete this._length;\n delete this._skipped;\n this._buffer = [];\n this._stage = 2;\n }\n }\n};\n\nfor (var key in instance)\n Draft75.prototype[key] = instance[key];\n\nmodule.exports = Draft75;\n","'use strict';\n\nvar Event = require('./event');\n\nvar EventTarget = {\n onopen: null,\n onmessage: null,\n onerror: null,\n onclose: null,\n\n addEventListener: function(eventType, listener, useCapture) {\n this.on(eventType, listener);\n },\n\n removeEventListener: function(eventType, listener, useCapture) {\n this.removeListener(eventType, listener);\n },\n\n dispatchEvent: function(event) {\n event.target = event.currentTarget = this;\n event.eventPhase = Event.AT_TARGET;\n\n if (this['on' + event.type])\n this['on' + event.type](event);\n\n this.emit(event.type, event);\n }\n};\n\nmodule.exports = EventTarget;\n","// Copyright (C) 2016 Dmitry Chestnykh\n// MIT License. See LICENSE file for details.\n\n/**\n * Package utf8 implements UTF-8 encoding and decoding.\n */\n\nconst INVALID_UTF16 = \"utf8: invalid string\";\nconst INVALID_UTF8 = \"utf8: invalid source encoding\";\n\n/**\n * Encodes the given string into UTF-8 byte array.\n * Throws if the source string has invalid UTF-16 encoding.\n */\nexport function encode(s: string): Uint8Array {\n // Calculate result length and allocate output array.\n // encodedLength() also validates string and throws errors,\n // so we don't need repeat validation here.\n const arr = new Uint8Array(encodedLength(s));\n\n let pos = 0;\n for (let i = 0; i < s.length; i++) {\n let c = s.charCodeAt(i);\n if (c < 0x80) {\n arr[pos++] = c;\n } else if (c < 0x800) {\n arr[pos++] = 0xc0 | c >> 6;\n arr[pos++] = 0x80 | c & 0x3f;\n } else if (c < 0xd800) {\n arr[pos++] = 0xe0 | c >> 12;\n arr[pos++] = 0x80 | (c >> 6) & 0x3f;\n arr[pos++] = 0x80 | c & 0x3f;\n } else {\n i++; // get one more character\n c = (c & 0x3ff) << 10;\n c |= s.charCodeAt(i) & 0x3ff;\n c += 0x10000;\n\n arr[pos++] = 0xf0 | c >> 18;\n arr[pos++] = 0x80 | (c >> 12) & 0x3f;\n arr[pos++] = 0x80 | (c >> 6) & 0x3f;\n arr[pos++] = 0x80 | c & 0x3f;\n }\n }\n return arr;\n}\n\n/**\n * Returns the number of bytes required to encode the given string into UTF-8.\n * Throws if the source string has invalid UTF-16 encoding.\n */\nexport function encodedLength(s: string): number {\n let result = 0;\n for (let i = 0; i < s.length; i++) {\n const c = s.charCodeAt(i);\n if (c < 0x80) {\n result += 1;\n } else if (c < 0x800) {\n result += 2;\n } else if (c < 0xd800) {\n result += 3;\n } else if (c <= 0xdfff) {\n if (i >= s.length - 1) {\n throw new Error(INVALID_UTF16);\n }\n i++; // \"eat\" next character\n result += 4;\n } else {\n throw new Error(INVALID_UTF16);\n }\n }\n return result;\n}\n\n/**\n * Decodes the given byte array from UTF-8 into a string.\n * Throws if encoding is invalid.\n */\nexport function decode(arr: Uint8Array): string {\n const chars: string[] = [];\n for (let i = 0; i < arr.length; i++) {\n let b = arr[i];\n\n if (b & 0x80) {\n let min;\n if (b < 0xe0) {\n // Need 1 more byte.\n if (i >= arr.length) {\n throw new Error(INVALID_UTF8);\n }\n const n1 = arr[++i];\n if ((n1 & 0xc0) !== 0x80) {\n throw new Error(INVALID_UTF8);\n }\n b = (b & 0x1f) << 6 | (n1 & 0x3f);\n min = 0x80;\n } else if (b < 0xf0) {\n // Need 2 more bytes.\n if (i >= arr.length - 1) {\n throw new Error(INVALID_UTF8);\n }\n const n1 = arr[++i];\n const n2 = arr[++i];\n if ((n1 & 0xc0) !== 0x80 || (n2 & 0xc0) !== 0x80) {\n throw new Error(INVALID_UTF8);\n }\n b = (b & 0x0f) << 12 | (n1 & 0x3f) << 6 | (n2 & 0x3f);\n min = 0x800;\n } else if (b < 0xf8) {\n // Need 3 more bytes.\n if (i >= arr.length - 2) {\n throw new Error(INVALID_UTF8);\n }\n const n1 = arr[++i];\n const n2 = arr[++i];\n const n3 = arr[++i];\n if ((n1 & 0xc0) !== 0x80 || (n2 & 0xc0) !== 0x80 || (n3 & 0xc0) !== 0x80) {\n throw new Error(INVALID_UTF8);\n }\n b = (b & 0x0f) << 18 | (n1 & 0x3f) << 12 | (n2 & 0x3f) << 6 | (n3 & 0x3f);\n min = 0x10000;\n } else {\n throw new Error(INVALID_UTF8);\n }\n\n if (b < min || (b >= 0xd800 && b <= 0xdfff)) {\n throw new Error(INVALID_UTF8);\n }\n\n if (b >= 0x10000) {\n // Surrogate pair.\n if (b > 0x10ffff) {\n throw new Error(INVALID_UTF8);\n }\n b -= 0x10000;\n chars.push(String.fromCharCode(0xd800 | (b >> 10)));\n b = 0xdc00 | (b & 0x3ff);\n }\n }\n\n chars.push(String.fromCharCode(b));\n }\n return chars.join(\"\");\n}\n","// API references:\n//\n// * https://html.spec.whatwg.org/multipage/comms.html#network\n// * https://dom.spec.whatwg.org/#interface-eventtarget\n// * https://dom.spec.whatwg.org/#interface-event\n\n'use strict';\n\nvar util = require('util'),\n driver = require('websocket-driver'),\n API = require('./websocket/api');\n\nvar WebSocket = function(request, socket, body, protocols, options) {\n options = options || {};\n\n this._stream = socket;\n this._driver = driver.http(request, {maxLength: options.maxLength, protocols: protocols});\n\n var self = this;\n if (!this._stream || !this._stream.writable) return;\n if (!this._stream.readable) return this._stream.end();\n\n var catchup = function() { self._stream.removeListener('data', catchup) };\n this._stream.on('data', catchup);\n\n API.call(this, options);\n\n process.nextTick(function() {\n self._driver.start();\n self._driver.io.write(body);\n });\n};\nutil.inherits(WebSocket, API);\n\nWebSocket.isWebSocket = function(request) {\n return driver.isWebSocket(request);\n};\n\nWebSocket.validateOptions = function(options, validKeys) {\n driver.validateOptions(options, validKeys);\n};\n\nWebSocket.WebSocket = WebSocket;\nWebSocket.Client = require('./websocket/client');\nWebSocket.EventSource = require('./eventsource');\n\nmodule.exports = WebSocket;\n","/**\n * Wrapper for built-in http.js to emulate the browser XMLHttpRequest object.\n *\n * This can be used with JS designed for browsers to improve reuse of code and\n * allow the use of existing libraries.\n *\n * Usage: include(\"XMLHttpRequest.js\") and use XMLHttpRequest per W3C specs.\n *\n * @author Dan DeFelippi \n * @contributor David Ellis \n * @license MIT\n */\n\nvar Url = require(\"url\");\nvar spawn = require(\"child_process\").spawn;\nvar fs = require(\"fs\");\n\nexports.XMLHttpRequest = function() {\n \"use strict\";\n\n /**\n * Private variables\n */\n var self = this;\n var http = require(\"http\");\n var https = require(\"https\");\n\n // Holds http.js objects\n var request;\n var response;\n\n // Request settings\n var settings = {};\n\n // Disable header blacklist.\n // Not part of XHR specs.\n var disableHeaderCheck = false;\n\n // Set some default headers\n var defaultHeaders = {\n \"User-Agent\": \"node-XMLHttpRequest\",\n \"Accept\": \"*/*\",\n };\n\n var headers = {};\n var headersCase = {};\n\n // These headers are not user setable.\n // The following are allowed but banned in the spec:\n // * user-agent\n var forbiddenRequestHeaders = [\n \"accept-charset\",\n \"accept-encoding\",\n \"access-control-request-headers\",\n \"access-control-request-method\",\n \"connection\",\n \"content-length\",\n \"content-transfer-encoding\",\n \"cookie\",\n \"cookie2\",\n \"date\",\n \"expect\",\n \"host\",\n \"keep-alive\",\n \"origin\",\n \"referer\",\n \"te\",\n \"trailer\",\n \"transfer-encoding\",\n \"upgrade\",\n \"via\"\n ];\n\n // These request methods are not allowed\n var forbiddenRequestMethods = [\n \"TRACE\",\n \"TRACK\",\n \"CONNECT\"\n ];\n\n // Send flag\n var sendFlag = false;\n // Error flag, used when errors occur or abort is called\n var errorFlag = false;\n\n // Event listeners\n var listeners = {};\n\n /**\n * Constants\n */\n\n this.UNSENT = 0;\n this.OPENED = 1;\n this.HEADERS_RECEIVED = 2;\n this.LOADING = 3;\n this.DONE = 4;\n\n /**\n * Public vars\n */\n\n // Current state\n this.readyState = this.UNSENT;\n\n // default ready state change handler in case one is not set or is set late\n this.onreadystatechange = null;\n\n // Result & response\n this.responseText = \"\";\n this.responseXML = \"\";\n this.status = null;\n this.statusText = null;\n \n // Whether cross-site Access-Control requests should be made using\n // credentials such as cookies or authorization headers\n this.withCredentials = false;\n\n /**\n * Private methods\n */\n\n /**\n * Check if the specified header is allowed.\n *\n * @param string header Header to validate\n * @return boolean False if not allowed, otherwise true\n */\n var isAllowedHttpHeader = function(header) {\n return disableHeaderCheck || (header && forbiddenRequestHeaders.indexOf(header.toLowerCase()) === -1);\n };\n\n /**\n * Check if the specified method is allowed.\n *\n * @param string method Request method to validate\n * @return boolean False if not allowed, otherwise true\n */\n var isAllowedHttpMethod = function(method) {\n return (method && forbiddenRequestMethods.indexOf(method) === -1);\n };\n\n /**\n * Public methods\n */\n\n /**\n * Open the connection. Currently supports local server requests.\n *\n * @param string method Connection method (eg GET, POST)\n * @param string url URL for the connection.\n * @param boolean async Asynchronous connection. Default is true.\n * @param string user Username for basic authentication (optional)\n * @param string password Password for basic authentication (optional)\n */\n this.open = function(method, url, async, user, password) {\n this.abort();\n errorFlag = false;\n\n // Check for valid request method\n if (!isAllowedHttpMethod(method)) {\n throw new Error(\"SecurityError: Request method not allowed\");\n }\n\n settings = {\n \"method\": method,\n \"url\": url.toString(),\n \"async\": (typeof async !== \"boolean\" ? true : async),\n \"user\": user || null,\n \"password\": password || null\n };\n\n setState(this.OPENED);\n };\n\n /**\n * Disables or enables isAllowedHttpHeader() check the request. Enabled by default.\n * This does not conform to the W3C spec.\n *\n * @param boolean state Enable or disable header checking.\n */\n this.setDisableHeaderCheck = function(state) {\n disableHeaderCheck = state;\n };\n\n /**\n * Sets a header for the request or appends the value if one is already set.\n *\n * @param string header Header name\n * @param string value Header value\n */\n this.setRequestHeader = function(header, value) {\n if (this.readyState !== this.OPENED) {\n throw new Error(\"INVALID_STATE_ERR: setRequestHeader can only be called when state is OPEN\");\n }\n if (!isAllowedHttpHeader(header)) {\n console.warn(\"Refused to set unsafe header \\\"\" + header + \"\\\"\");\n return;\n }\n if (sendFlag) {\n throw new Error(\"INVALID_STATE_ERR: send flag is true\");\n }\n header = headersCase[header.toLowerCase()] || header;\n headersCase[header.toLowerCase()] = header;\n headers[header] = headers[header] ? headers[header] + ', ' + value : value;\n };\n\n /**\n * Gets a header from the server response.\n *\n * @param string header Name of header to get.\n * @return string Text of the header or null if it doesn't exist.\n */\n this.getResponseHeader = function(header) {\n if (typeof header === \"string\"\n && this.readyState > this.OPENED\n && response\n && response.headers\n && response.headers[header.toLowerCase()]\n && !errorFlag\n ) {\n return response.headers[header.toLowerCase()];\n }\n\n return null;\n };\n\n /**\n * Gets all the response headers.\n *\n * @return string A string with all response headers separated by CR+LF\n */\n this.getAllResponseHeaders = function() {\n if (this.readyState < this.HEADERS_RECEIVED || errorFlag) {\n return \"\";\n }\n var result = \"\";\n\n for (var i in response.headers) {\n // Cookie headers are excluded\n if (i !== \"set-cookie\" && i !== \"set-cookie2\") {\n result += i + \": \" + response.headers[i] + \"\\r\\n\";\n }\n }\n return result.substr(0, result.length - 2);\n };\n\n /**\n * Gets a request header\n *\n * @param string name Name of header to get\n * @return string Returns the request header or empty string if not set\n */\n this.getRequestHeader = function(name) {\n if (typeof name === \"string\" && headersCase[name.toLowerCase()]) {\n return headers[headersCase[name.toLowerCase()]];\n }\n\n return \"\";\n };\n\n /**\n * Sends the request to the server.\n *\n * @param string data Optional data to send as request body.\n */\n this.send = function(data) {\n if (this.readyState !== this.OPENED) {\n throw new Error(\"INVALID_STATE_ERR: connection must be opened before send() is called\");\n }\n\n if (sendFlag) {\n throw new Error(\"INVALID_STATE_ERR: send has already been called\");\n }\n\n var ssl = false, local = false;\n var url = Url.parse(settings.url);\n var host;\n // Determine the server\n switch (url.protocol) {\n case \"https:\":\n ssl = true;\n // SSL & non-SSL both need host, no break here.\n case \"http:\":\n host = url.hostname;\n break;\n\n case \"file:\":\n local = true;\n break;\n\n case undefined:\n case null:\n case \"\":\n host = \"localhost\";\n break;\n\n default:\n throw new Error(\"Protocol not supported.\");\n }\n\n // Load files off the local filesystem (file://)\n if (local) {\n if (settings.method !== \"GET\") {\n throw new Error(\"XMLHttpRequest: Only GET method is supported\");\n }\n\n if (settings.async) {\n fs.readFile(url.pathname, \"utf8\", function(error, data) {\n if (error) {\n self.handleError(error);\n } else {\n self.status = 200;\n self.responseText = data;\n setState(self.DONE);\n }\n });\n } else {\n try {\n this.responseText = fs.readFileSync(url.pathname, \"utf8\");\n this.status = 200;\n setState(self.DONE);\n } catch(e) {\n this.handleError(e);\n }\n }\n\n return;\n }\n\n // Default to port 80. If accessing localhost on another port be sure\n // to use http://localhost:port/path\n var port = url.port || (ssl ? 443 : 80);\n // Add query string if one is used\n var uri = url.pathname + (url.search ? url.search : \"\");\n\n // Set the defaults if they haven't been set\n for (var name in defaultHeaders) {\n if (!headersCase[name.toLowerCase()]) {\n headers[name] = defaultHeaders[name];\n }\n }\n\n // Set the Host header or the server may reject the request\n headers.Host = host;\n if (!((ssl && port === 443) || port === 80)) {\n headers.Host += \":\" + url.port;\n }\n\n // Set Basic Auth if necessary\n if (settings.user) {\n if (typeof settings.password === \"undefined\") {\n settings.password = \"\";\n }\n var authBuf = new Buffer(settings.user + \":\" + settings.password);\n headers.Authorization = \"Basic \" + authBuf.toString(\"base64\");\n }\n\n // Set content length header\n if (settings.method === \"GET\" || settings.method === \"HEAD\") {\n data = null;\n } else if (data) {\n headers[\"Content-Length\"] = Buffer.isBuffer(data) ? data.length : Buffer.byteLength(data);\n\n if (!headers[\"Content-Type\"]) {\n headers[\"Content-Type\"] = \"text/plain;charset=UTF-8\";\n }\n } else if (settings.method === \"POST\") {\n // For a post with no data set Content-Length: 0.\n // This is required by buggy servers that don't meet the specs.\n headers[\"Content-Length\"] = 0;\n }\n\n var options = {\n host: host,\n port: port,\n path: uri,\n method: settings.method,\n headers: headers,\n agent: false,\n withCredentials: self.withCredentials\n };\n\n // Reset error flag\n errorFlag = false;\n\n // Handle async requests\n if (settings.async) {\n // Use the proper protocol\n var doRequest = ssl ? https.request : http.request;\n\n // Request is being sent, set send flag\n sendFlag = true;\n\n // As per spec, this is called here for historical reasons.\n self.dispatchEvent(\"readystatechange\");\n\n // Handler for the response\n var responseHandler = function responseHandler(resp) {\n // Set response var to the response we got back\n // This is so it remains accessable outside this scope\n response = resp;\n // Check for redirect\n // @TODO Prevent looped redirects\n if (response.statusCode === 301 || response.statusCode === 302 || response.statusCode === 303 || response.statusCode === 307) {\n // Change URL to the redirect location\n settings.url = response.headers.location;\n var url = Url.parse(settings.url);\n // Set host var in case it's used later\n host = url.hostname;\n // Options for the new request\n var newOptions = {\n hostname: url.hostname,\n port: url.port,\n path: url.path,\n method: response.statusCode === 303 ? \"GET\" : settings.method,\n headers: headers,\n withCredentials: self.withCredentials\n };\n\n // Issue the new request\n request = doRequest(newOptions, responseHandler).on(\"error\", errorHandler);\n request.end();\n // @TODO Check if an XHR event needs to be fired here\n return;\n }\n\n response.setEncoding(\"utf8\");\n\n setState(self.HEADERS_RECEIVED);\n self.status = response.statusCode;\n\n response.on(\"data\", function(chunk) {\n // Make sure there's some data\n if (chunk) {\n self.responseText += chunk;\n }\n // Don't emit state changes if the connection has been aborted.\n if (sendFlag) {\n setState(self.LOADING);\n }\n });\n\n response.on(\"end\", function() {\n if (sendFlag) {\n // Discard the end event if the connection has been aborted\n setState(self.DONE);\n sendFlag = false;\n }\n });\n\n response.on(\"error\", function(error) {\n self.handleError(error);\n });\n };\n\n // Error handler for the request\n var errorHandler = function errorHandler(error) {\n self.handleError(error);\n };\n\n // Create the request\n request = doRequest(options, responseHandler).on(\"error\", errorHandler);\n\n // Node 0.4 and later won't accept empty data. Make sure it's needed.\n if (data) {\n request.write(data);\n }\n\n request.end();\n\n self.dispatchEvent(\"loadstart\");\n } else { // Synchronous\n // Create a temporary file for communication with the other Node process\n var contentFile = \".node-xmlhttprequest-content-\" + process.pid;\n var syncFile = \".node-xmlhttprequest-sync-\" + process.pid;\n fs.writeFileSync(syncFile, \"\", \"utf8\");\n // The async request the other Node process executes\n var execString = \"var http = require('http'), https = require('https'), fs = require('fs');\"\n + \"var doRequest = http\" + (ssl ? \"s\" : \"\") + \".request;\"\n + \"var options = \" + JSON.stringify(options) + \";\"\n + \"var responseText = '';\"\n + \"var req = doRequest(options, function(response) {\"\n + \"response.setEncoding('utf8');\"\n + \"response.on('data', function(chunk) {\"\n + \" responseText += chunk;\"\n + \"});\"\n + \"response.on('end', function() {\"\n + \"fs.writeFileSync('\" + contentFile + \"', JSON.stringify({err: null, data: {statusCode: response.statusCode, headers: response.headers, text: responseText}}), 'utf8');\"\n + \"fs.unlinkSync('\" + syncFile + \"');\"\n + \"});\"\n + \"response.on('error', function(error) {\"\n + \"fs.writeFileSync('\" + contentFile + \"', JSON.stringify({err: error}), 'utf8');\"\n + \"fs.unlinkSync('\" + syncFile + \"');\"\n + \"});\"\n + \"}).on('error', function(error) {\"\n + \"fs.writeFileSync('\" + contentFile + \"', JSON.stringify({err: error}), 'utf8');\"\n + \"fs.unlinkSync('\" + syncFile + \"');\"\n + \"});\"\n + (data ? \"req.write('\" + JSON.stringify(data).slice(1,-1).replace(/'/g, \"\\\\'\") + \"');\":\"\")\n + \"req.end();\";\n // Start the other Node Process, executing this string\n var syncProc = spawn(process.argv[0], [\"-e\", execString]);\n while(fs.existsSync(syncFile)) {\n // Wait while the sync file is empty\n }\n var resp = JSON.parse(fs.readFileSync(contentFile, 'utf8'));\n // Kill the child process once the file has data\n syncProc.stdin.end();\n // Remove the temporary file\n fs.unlinkSync(contentFile);\n\n if (resp.err) {\n self.handleError(resp.err);\n } else {\n response = resp.data;\n self.status = resp.data.statusCode;\n self.responseText = resp.data.text;\n setState(self.DONE);\n }\n }\n };\n\n /**\n * Called when an error is encountered to deal with it.\n */\n this.handleError = function(error) {\n this.status = 0;\n this.statusText = error;\n this.responseText = error.stack;\n errorFlag = true;\n setState(this.DONE);\n this.dispatchEvent('error');\n };\n\n /**\n * Aborts a request.\n */\n this.abort = function() {\n if (request) {\n request.abort();\n request = null;\n }\n\n headers = defaultHeaders;\n this.status = 0;\n this.responseText = \"\";\n this.responseXML = \"\";\n\n errorFlag = true;\n\n if (this.readyState !== this.UNSENT\n && (this.readyState !== this.OPENED || sendFlag)\n && this.readyState !== this.DONE) {\n sendFlag = false;\n setState(this.DONE);\n }\n this.readyState = this.UNSENT;\n this.dispatchEvent('abort');\n };\n\n /**\n * Adds an event listener. Preferred method of binding to events.\n */\n this.addEventListener = function(event, callback) {\n if (!(event in listeners)) {\n listeners[event] = [];\n }\n // Currently allows duplicate callbacks. Should it?\n listeners[event].push(callback);\n };\n\n /**\n * Remove an event callback that has already been bound.\n * Only works on the matching funciton, cannot be a copy.\n */\n this.removeEventListener = function(event, callback) {\n if (event in listeners) {\n // Filter will return a new array with the callback removed\n listeners[event] = listeners[event].filter(function(ev) {\n return ev !== callback;\n });\n }\n };\n\n /**\n * Dispatch any events, including both \"on\" methods and events attached using addEventListener.\n */\n this.dispatchEvent = function(event) {\n if (typeof self[\"on\" + event] === \"function\") {\n self[\"on\" + event]();\n }\n if (event in listeners) {\n for (var i = 0, len = listeners[event].length; i < len; i++) {\n listeners[event][i].call(self);\n }\n }\n };\n\n /**\n * Changes readyState and calls onreadystatechange.\n *\n * @param int state New state\n */\n var setState = function(state) {\n if (state == self.LOADING || self.readyState !== state) {\n self.readyState = state;\n\n if (settings.async || self.readyState < self.OPENED || self.readyState === self.DONE) {\n self.dispatchEvent(\"readystatechange\");\n }\n\n if (self.readyState === self.DONE && !errorFlag) {\n self.dispatchEvent(\"load\");\n // @TODO figure out InspectorInstrumentation::didLoadXHR(cookie)\n self.dispatchEvent(\"loadend\");\n }\n }\n };\n};\n","(function(nacl) {\n'use strict';\n\n// Ported in 2014 by Dmitry Chestnykh and Devi Mandiri.\n// Public domain.\n//\n// Implementation derived from TweetNaCl version 20140427.\n// See for details: http://tweetnacl.cr.yp.to/\n\nvar gf = function(init) {\n var i, r = new Float64Array(16);\n if (init) for (i = 0; i < init.length; i++) r[i] = init[i];\n return r;\n};\n\n// Pluggable, initialized in high-level API below.\nvar randombytes = function(/* x, n */) { throw new Error('no PRNG'); };\n\nvar _0 = new Uint8Array(16);\nvar _9 = new Uint8Array(32); _9[0] = 9;\n\nvar gf0 = gf(),\n gf1 = gf([1]),\n _121665 = gf([0xdb41, 1]),\n D = gf([0x78a3, 0x1359, 0x4dca, 0x75eb, 0xd8ab, 0x4141, 0x0a4d, 0x0070, 0xe898, 0x7779, 0x4079, 0x8cc7, 0xfe73, 0x2b6f, 0x6cee, 0x5203]),\n D2 = gf([0xf159, 0x26b2, 0x9b94, 0xebd6, 0xb156, 0x8283, 0x149a, 0x00e0, 0xd130, 0xeef3, 0x80f2, 0x198e, 0xfce7, 0x56df, 0xd9dc, 0x2406]),\n X = gf([0xd51a, 0x8f25, 0x2d60, 0xc956, 0xa7b2, 0x9525, 0xc760, 0x692c, 0xdc5c, 0xfdd6, 0xe231, 0xc0a4, 0x53fe, 0xcd6e, 0x36d3, 0x2169]),\n Y = gf([0x6658, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666]),\n I = gf([0xa0b0, 0x4a0e, 0x1b27, 0xc4ee, 0xe478, 0xad2f, 0x1806, 0x2f43, 0xd7a7, 0x3dfb, 0x0099, 0x2b4d, 0xdf0b, 0x4fc1, 0x2480, 0x2b83]);\n\nfunction ts64(x, i, h, l) {\n x[i] = (h >> 24) & 0xff;\n x[i+1] = (h >> 16) & 0xff;\n x[i+2] = (h >> 8) & 0xff;\n x[i+3] = h & 0xff;\n x[i+4] = (l >> 24) & 0xff;\n x[i+5] = (l >> 16) & 0xff;\n x[i+6] = (l >> 8) & 0xff;\n x[i+7] = l & 0xff;\n}\n\nfunction vn(x, xi, y, yi, n) {\n var i,d = 0;\n for (i = 0; i < n; i++) d |= x[xi+i]^y[yi+i];\n return (1 & ((d - 1) >>> 8)) - 1;\n}\n\nfunction crypto_verify_16(x, xi, y, yi) {\n return vn(x,xi,y,yi,16);\n}\n\nfunction crypto_verify_32(x, xi, y, yi) {\n return vn(x,xi,y,yi,32);\n}\n\nfunction core_salsa20(o, p, k, c) {\n var j0 = c[ 0] & 0xff | (c[ 1] & 0xff)<<8 | (c[ 2] & 0xff)<<16 | (c[ 3] & 0xff)<<24,\n j1 = k[ 0] & 0xff | (k[ 1] & 0xff)<<8 | (k[ 2] & 0xff)<<16 | (k[ 3] & 0xff)<<24,\n j2 = k[ 4] & 0xff | (k[ 5] & 0xff)<<8 | (k[ 6] & 0xff)<<16 | (k[ 7] & 0xff)<<24,\n j3 = k[ 8] & 0xff | (k[ 9] & 0xff)<<8 | (k[10] & 0xff)<<16 | (k[11] & 0xff)<<24,\n j4 = k[12] & 0xff | (k[13] & 0xff)<<8 | (k[14] & 0xff)<<16 | (k[15] & 0xff)<<24,\n j5 = c[ 4] & 0xff | (c[ 5] & 0xff)<<8 | (c[ 6] & 0xff)<<16 | (c[ 7] & 0xff)<<24,\n j6 = p[ 0] & 0xff | (p[ 1] & 0xff)<<8 | (p[ 2] & 0xff)<<16 | (p[ 3] & 0xff)<<24,\n j7 = p[ 4] & 0xff | (p[ 5] & 0xff)<<8 | (p[ 6] & 0xff)<<16 | (p[ 7] & 0xff)<<24,\n j8 = p[ 8] & 0xff | (p[ 9] & 0xff)<<8 | (p[10] & 0xff)<<16 | (p[11] & 0xff)<<24,\n j9 = p[12] & 0xff | (p[13] & 0xff)<<8 | (p[14] & 0xff)<<16 | (p[15] & 0xff)<<24,\n j10 = c[ 8] & 0xff | (c[ 9] & 0xff)<<8 | (c[10] & 0xff)<<16 | (c[11] & 0xff)<<24,\n j11 = k[16] & 0xff | (k[17] & 0xff)<<8 | (k[18] & 0xff)<<16 | (k[19] & 0xff)<<24,\n j12 = k[20] & 0xff | (k[21] & 0xff)<<8 | (k[22] & 0xff)<<16 | (k[23] & 0xff)<<24,\n j13 = k[24] & 0xff | (k[25] & 0xff)<<8 | (k[26] & 0xff)<<16 | (k[27] & 0xff)<<24,\n j14 = k[28] & 0xff | (k[29] & 0xff)<<8 | (k[30] & 0xff)<<16 | (k[31] & 0xff)<<24,\n j15 = c[12] & 0xff | (c[13] & 0xff)<<8 | (c[14] & 0xff)<<16 | (c[15] & 0xff)<<24;\n\n var x0 = j0, x1 = j1, x2 = j2, x3 = j3, x4 = j4, x5 = j5, x6 = j6, x7 = j7,\n x8 = j8, x9 = j9, x10 = j10, x11 = j11, x12 = j12, x13 = j13, x14 = j14,\n x15 = j15, u;\n\n for (var i = 0; i < 20; i += 2) {\n u = x0 + x12 | 0;\n x4 ^= u<<7 | u>>>(32-7);\n u = x4 + x0 | 0;\n x8 ^= u<<9 | u>>>(32-9);\n u = x8 + x4 | 0;\n x12 ^= u<<13 | u>>>(32-13);\n u = x12 + x8 | 0;\n x0 ^= u<<18 | u>>>(32-18);\n\n u = x5 + x1 | 0;\n x9 ^= u<<7 | u>>>(32-7);\n u = x9 + x5 | 0;\n x13 ^= u<<9 | u>>>(32-9);\n u = x13 + x9 | 0;\n x1 ^= u<<13 | u>>>(32-13);\n u = x1 + x13 | 0;\n x5 ^= u<<18 | u>>>(32-18);\n\n u = x10 + x6 | 0;\n x14 ^= u<<7 | u>>>(32-7);\n u = x14 + x10 | 0;\n x2 ^= u<<9 | u>>>(32-9);\n u = x2 + x14 | 0;\n x6 ^= u<<13 | u>>>(32-13);\n u = x6 + x2 | 0;\n x10 ^= u<<18 | u>>>(32-18);\n\n u = x15 + x11 | 0;\n x3 ^= u<<7 | u>>>(32-7);\n u = x3 + x15 | 0;\n x7 ^= u<<9 | u>>>(32-9);\n u = x7 + x3 | 0;\n x11 ^= u<<13 | u>>>(32-13);\n u = x11 + x7 | 0;\n x15 ^= u<<18 | u>>>(32-18);\n\n u = x0 + x3 | 0;\n x1 ^= u<<7 | u>>>(32-7);\n u = x1 + x0 | 0;\n x2 ^= u<<9 | u>>>(32-9);\n u = x2 + x1 | 0;\n x3 ^= u<<13 | u>>>(32-13);\n u = x3 + x2 | 0;\n x0 ^= u<<18 | u>>>(32-18);\n\n u = x5 + x4 | 0;\n x6 ^= u<<7 | u>>>(32-7);\n u = x6 + x5 | 0;\n x7 ^= u<<9 | u>>>(32-9);\n u = x7 + x6 | 0;\n x4 ^= u<<13 | u>>>(32-13);\n u = x4 + x7 | 0;\n x5 ^= u<<18 | u>>>(32-18);\n\n u = x10 + x9 | 0;\n x11 ^= u<<7 | u>>>(32-7);\n u = x11 + x10 | 0;\n x8 ^= u<<9 | u>>>(32-9);\n u = x8 + x11 | 0;\n x9 ^= u<<13 | u>>>(32-13);\n u = x9 + x8 | 0;\n x10 ^= u<<18 | u>>>(32-18);\n\n u = x15 + x14 | 0;\n x12 ^= u<<7 | u>>>(32-7);\n u = x12 + x15 | 0;\n x13 ^= u<<9 | u>>>(32-9);\n u = x13 + x12 | 0;\n x14 ^= u<<13 | u>>>(32-13);\n u = x14 + x13 | 0;\n x15 ^= u<<18 | u>>>(32-18);\n }\n x0 = x0 + j0 | 0;\n x1 = x1 + j1 | 0;\n x2 = x2 + j2 | 0;\n x3 = x3 + j3 | 0;\n x4 = x4 + j4 | 0;\n x5 = x5 + j5 | 0;\n x6 = x6 + j6 | 0;\n x7 = x7 + j7 | 0;\n x8 = x8 + j8 | 0;\n x9 = x9 + j9 | 0;\n x10 = x10 + j10 | 0;\n x11 = x11 + j11 | 0;\n x12 = x12 + j12 | 0;\n x13 = x13 + j13 | 0;\n x14 = x14 + j14 | 0;\n x15 = x15 + j15 | 0;\n\n o[ 0] = x0 >>> 0 & 0xff;\n o[ 1] = x0 >>> 8 & 0xff;\n o[ 2] = x0 >>> 16 & 0xff;\n o[ 3] = x0 >>> 24 & 0xff;\n\n o[ 4] = x1 >>> 0 & 0xff;\n o[ 5] = x1 >>> 8 & 0xff;\n o[ 6] = x1 >>> 16 & 0xff;\n o[ 7] = x1 >>> 24 & 0xff;\n\n o[ 8] = x2 >>> 0 & 0xff;\n o[ 9] = x2 >>> 8 & 0xff;\n o[10] = x2 >>> 16 & 0xff;\n o[11] = x2 >>> 24 & 0xff;\n\n o[12] = x3 >>> 0 & 0xff;\n o[13] = x3 >>> 8 & 0xff;\n o[14] = x3 >>> 16 & 0xff;\n o[15] = x3 >>> 24 & 0xff;\n\n o[16] = x4 >>> 0 & 0xff;\n o[17] = x4 >>> 8 & 0xff;\n o[18] = x4 >>> 16 & 0xff;\n o[19] = x4 >>> 24 & 0xff;\n\n o[20] = x5 >>> 0 & 0xff;\n o[21] = x5 >>> 8 & 0xff;\n o[22] = x5 >>> 16 & 0xff;\n o[23] = x5 >>> 24 & 0xff;\n\n o[24] = x6 >>> 0 & 0xff;\n o[25] = x6 >>> 8 & 0xff;\n o[26] = x6 >>> 16 & 0xff;\n o[27] = x6 >>> 24 & 0xff;\n\n o[28] = x7 >>> 0 & 0xff;\n o[29] = x7 >>> 8 & 0xff;\n o[30] = x7 >>> 16 & 0xff;\n o[31] = x7 >>> 24 & 0xff;\n\n o[32] = x8 >>> 0 & 0xff;\n o[33] = x8 >>> 8 & 0xff;\n o[34] = x8 >>> 16 & 0xff;\n o[35] = x8 >>> 24 & 0xff;\n\n o[36] = x9 >>> 0 & 0xff;\n o[37] = x9 >>> 8 & 0xff;\n o[38] = x9 >>> 16 & 0xff;\n o[39] = x9 >>> 24 & 0xff;\n\n o[40] = x10 >>> 0 & 0xff;\n o[41] = x10 >>> 8 & 0xff;\n o[42] = x10 >>> 16 & 0xff;\n o[43] = x10 >>> 24 & 0xff;\n\n o[44] = x11 >>> 0 & 0xff;\n o[45] = x11 >>> 8 & 0xff;\n o[46] = x11 >>> 16 & 0xff;\n o[47] = x11 >>> 24 & 0xff;\n\n o[48] = x12 >>> 0 & 0xff;\n o[49] = x12 >>> 8 & 0xff;\n o[50] = x12 >>> 16 & 0xff;\n o[51] = x12 >>> 24 & 0xff;\n\n o[52] = x13 >>> 0 & 0xff;\n o[53] = x13 >>> 8 & 0xff;\n o[54] = x13 >>> 16 & 0xff;\n o[55] = x13 >>> 24 & 0xff;\n\n o[56] = x14 >>> 0 & 0xff;\n o[57] = x14 >>> 8 & 0xff;\n o[58] = x14 >>> 16 & 0xff;\n o[59] = x14 >>> 24 & 0xff;\n\n o[60] = x15 >>> 0 & 0xff;\n o[61] = x15 >>> 8 & 0xff;\n o[62] = x15 >>> 16 & 0xff;\n o[63] = x15 >>> 24 & 0xff;\n}\n\nfunction core_hsalsa20(o,p,k,c) {\n var j0 = c[ 0] & 0xff | (c[ 1] & 0xff)<<8 | (c[ 2] & 0xff)<<16 | (c[ 3] & 0xff)<<24,\n j1 = k[ 0] & 0xff | (k[ 1] & 0xff)<<8 | (k[ 2] & 0xff)<<16 | (k[ 3] & 0xff)<<24,\n j2 = k[ 4] & 0xff | (k[ 5] & 0xff)<<8 | (k[ 6] & 0xff)<<16 | (k[ 7] & 0xff)<<24,\n j3 = k[ 8] & 0xff | (k[ 9] & 0xff)<<8 | (k[10] & 0xff)<<16 | (k[11] & 0xff)<<24,\n j4 = k[12] & 0xff | (k[13] & 0xff)<<8 | (k[14] & 0xff)<<16 | (k[15] & 0xff)<<24,\n j5 = c[ 4] & 0xff | (c[ 5] & 0xff)<<8 | (c[ 6] & 0xff)<<16 | (c[ 7] & 0xff)<<24,\n j6 = p[ 0] & 0xff | (p[ 1] & 0xff)<<8 | (p[ 2] & 0xff)<<16 | (p[ 3] & 0xff)<<24,\n j7 = p[ 4] & 0xff | (p[ 5] & 0xff)<<8 | (p[ 6] & 0xff)<<16 | (p[ 7] & 0xff)<<24,\n j8 = p[ 8] & 0xff | (p[ 9] & 0xff)<<8 | (p[10] & 0xff)<<16 | (p[11] & 0xff)<<24,\n j9 = p[12] & 0xff | (p[13] & 0xff)<<8 | (p[14] & 0xff)<<16 | (p[15] & 0xff)<<24,\n j10 = c[ 8] & 0xff | (c[ 9] & 0xff)<<8 | (c[10] & 0xff)<<16 | (c[11] & 0xff)<<24,\n j11 = k[16] & 0xff | (k[17] & 0xff)<<8 | (k[18] & 0xff)<<16 | (k[19] & 0xff)<<24,\n j12 = k[20] & 0xff | (k[21] & 0xff)<<8 | (k[22] & 0xff)<<16 | (k[23] & 0xff)<<24,\n j13 = k[24] & 0xff | (k[25] & 0xff)<<8 | (k[26] & 0xff)<<16 | (k[27] & 0xff)<<24,\n j14 = k[28] & 0xff | (k[29] & 0xff)<<8 | (k[30] & 0xff)<<16 | (k[31] & 0xff)<<24,\n j15 = c[12] & 0xff | (c[13] & 0xff)<<8 | (c[14] & 0xff)<<16 | (c[15] & 0xff)<<24;\n\n var x0 = j0, x1 = j1, x2 = j2, x3 = j3, x4 = j4, x5 = j5, x6 = j6, x7 = j7,\n x8 = j8, x9 = j9, x10 = j10, x11 = j11, x12 = j12, x13 = j13, x14 = j14,\n x15 = j15, u;\n\n for (var i = 0; i < 20; i += 2) {\n u = x0 + x12 | 0;\n x4 ^= u<<7 | u>>>(32-7);\n u = x4 + x0 | 0;\n x8 ^= u<<9 | u>>>(32-9);\n u = x8 + x4 | 0;\n x12 ^= u<<13 | u>>>(32-13);\n u = x12 + x8 | 0;\n x0 ^= u<<18 | u>>>(32-18);\n\n u = x5 + x1 | 0;\n x9 ^= u<<7 | u>>>(32-7);\n u = x9 + x5 | 0;\n x13 ^= u<<9 | u>>>(32-9);\n u = x13 + x9 | 0;\n x1 ^= u<<13 | u>>>(32-13);\n u = x1 + x13 | 0;\n x5 ^= u<<18 | u>>>(32-18);\n\n u = x10 + x6 | 0;\n x14 ^= u<<7 | u>>>(32-7);\n u = x14 + x10 | 0;\n x2 ^= u<<9 | u>>>(32-9);\n u = x2 + x14 | 0;\n x6 ^= u<<13 | u>>>(32-13);\n u = x6 + x2 | 0;\n x10 ^= u<<18 | u>>>(32-18);\n\n u = x15 + x11 | 0;\n x3 ^= u<<7 | u>>>(32-7);\n u = x3 + x15 | 0;\n x7 ^= u<<9 | u>>>(32-9);\n u = x7 + x3 | 0;\n x11 ^= u<<13 | u>>>(32-13);\n u = x11 + x7 | 0;\n x15 ^= u<<18 | u>>>(32-18);\n\n u = x0 + x3 | 0;\n x1 ^= u<<7 | u>>>(32-7);\n u = x1 + x0 | 0;\n x2 ^= u<<9 | u>>>(32-9);\n u = x2 + x1 | 0;\n x3 ^= u<<13 | u>>>(32-13);\n u = x3 + x2 | 0;\n x0 ^= u<<18 | u>>>(32-18);\n\n u = x5 + x4 | 0;\n x6 ^= u<<7 | u>>>(32-7);\n u = x6 + x5 | 0;\n x7 ^= u<<9 | u>>>(32-9);\n u = x7 + x6 | 0;\n x4 ^= u<<13 | u>>>(32-13);\n u = x4 + x7 | 0;\n x5 ^= u<<18 | u>>>(32-18);\n\n u = x10 + x9 | 0;\n x11 ^= u<<7 | u>>>(32-7);\n u = x11 + x10 | 0;\n x8 ^= u<<9 | u>>>(32-9);\n u = x8 + x11 | 0;\n x9 ^= u<<13 | u>>>(32-13);\n u = x9 + x8 | 0;\n x10 ^= u<<18 | u>>>(32-18);\n\n u = x15 + x14 | 0;\n x12 ^= u<<7 | u>>>(32-7);\n u = x12 + x15 | 0;\n x13 ^= u<<9 | u>>>(32-9);\n u = x13 + x12 | 0;\n x14 ^= u<<13 | u>>>(32-13);\n u = x14 + x13 | 0;\n x15 ^= u<<18 | u>>>(32-18);\n }\n\n o[ 0] = x0 >>> 0 & 0xff;\n o[ 1] = x0 >>> 8 & 0xff;\n o[ 2] = x0 >>> 16 & 0xff;\n o[ 3] = x0 >>> 24 & 0xff;\n\n o[ 4] = x5 >>> 0 & 0xff;\n o[ 5] = x5 >>> 8 & 0xff;\n o[ 6] = x5 >>> 16 & 0xff;\n o[ 7] = x5 >>> 24 & 0xff;\n\n o[ 8] = x10 >>> 0 & 0xff;\n o[ 9] = x10 >>> 8 & 0xff;\n o[10] = x10 >>> 16 & 0xff;\n o[11] = x10 >>> 24 & 0xff;\n\n o[12] = x15 >>> 0 & 0xff;\n o[13] = x15 >>> 8 & 0xff;\n o[14] = x15 >>> 16 & 0xff;\n o[15] = x15 >>> 24 & 0xff;\n\n o[16] = x6 >>> 0 & 0xff;\n o[17] = x6 >>> 8 & 0xff;\n o[18] = x6 >>> 16 & 0xff;\n o[19] = x6 >>> 24 & 0xff;\n\n o[20] = x7 >>> 0 & 0xff;\n o[21] = x7 >>> 8 & 0xff;\n o[22] = x7 >>> 16 & 0xff;\n o[23] = x7 >>> 24 & 0xff;\n\n o[24] = x8 >>> 0 & 0xff;\n o[25] = x8 >>> 8 & 0xff;\n o[26] = x8 >>> 16 & 0xff;\n o[27] = x8 >>> 24 & 0xff;\n\n o[28] = x9 >>> 0 & 0xff;\n o[29] = x9 >>> 8 & 0xff;\n o[30] = x9 >>> 16 & 0xff;\n o[31] = x9 >>> 24 & 0xff;\n}\n\nfunction crypto_core_salsa20(out,inp,k,c) {\n core_salsa20(out,inp,k,c);\n}\n\nfunction crypto_core_hsalsa20(out,inp,k,c) {\n core_hsalsa20(out,inp,k,c);\n}\n\nvar sigma = new Uint8Array([101, 120, 112, 97, 110, 100, 32, 51, 50, 45, 98, 121, 116, 101, 32, 107]);\n // \"expand 32-byte k\"\n\nfunction crypto_stream_salsa20_xor(c,cpos,m,mpos,b,n,k) {\n var z = new Uint8Array(16), x = new Uint8Array(64);\n var u, i;\n for (i = 0; i < 16; i++) z[i] = 0;\n for (i = 0; i < 8; i++) z[i] = n[i];\n while (b >= 64) {\n crypto_core_salsa20(x,z,k,sigma);\n for (i = 0; i < 64; i++) c[cpos+i] = m[mpos+i] ^ x[i];\n u = 1;\n for (i = 8; i < 16; i++) {\n u = u + (z[i] & 0xff) | 0;\n z[i] = u & 0xff;\n u >>>= 8;\n }\n b -= 64;\n cpos += 64;\n mpos += 64;\n }\n if (b > 0) {\n crypto_core_salsa20(x,z,k,sigma);\n for (i = 0; i < b; i++) c[cpos+i] = m[mpos+i] ^ x[i];\n }\n return 0;\n}\n\nfunction crypto_stream_salsa20(c,cpos,b,n,k) {\n var z = new Uint8Array(16), x = new Uint8Array(64);\n var u, i;\n for (i = 0; i < 16; i++) z[i] = 0;\n for (i = 0; i < 8; i++) z[i] = n[i];\n while (b >= 64) {\n crypto_core_salsa20(x,z,k,sigma);\n for (i = 0; i < 64; i++) c[cpos+i] = x[i];\n u = 1;\n for (i = 8; i < 16; i++) {\n u = u + (z[i] & 0xff) | 0;\n z[i] = u & 0xff;\n u >>>= 8;\n }\n b -= 64;\n cpos += 64;\n }\n if (b > 0) {\n crypto_core_salsa20(x,z,k,sigma);\n for (i = 0; i < b; i++) c[cpos+i] = x[i];\n }\n return 0;\n}\n\nfunction crypto_stream(c,cpos,d,n,k) {\n var s = new Uint8Array(32);\n crypto_core_hsalsa20(s,n,k,sigma);\n var sn = new Uint8Array(8);\n for (var i = 0; i < 8; i++) sn[i] = n[i+16];\n return crypto_stream_salsa20(c,cpos,d,sn,s);\n}\n\nfunction crypto_stream_xor(c,cpos,m,mpos,d,n,k) {\n var s = new Uint8Array(32);\n crypto_core_hsalsa20(s,n,k,sigma);\n var sn = new Uint8Array(8);\n for (var i = 0; i < 8; i++) sn[i] = n[i+16];\n return crypto_stream_salsa20_xor(c,cpos,m,mpos,d,sn,s);\n}\n\n/*\n* Port of Andrew Moon's Poly1305-donna-16. Public domain.\n* https://github.com/floodyberry/poly1305-donna\n*/\n\nvar poly1305 = function(key) {\n this.buffer = new Uint8Array(16);\n this.r = new Uint16Array(10);\n this.h = new Uint16Array(10);\n this.pad = new Uint16Array(8);\n this.leftover = 0;\n this.fin = 0;\n\n var t0, t1, t2, t3, t4, t5, t6, t7;\n\n t0 = key[ 0] & 0xff | (key[ 1] & 0xff) << 8; this.r[0] = ( t0 ) & 0x1fff;\n t1 = key[ 2] & 0xff | (key[ 3] & 0xff) << 8; this.r[1] = ((t0 >>> 13) | (t1 << 3)) & 0x1fff;\n t2 = key[ 4] & 0xff | (key[ 5] & 0xff) << 8; this.r[2] = ((t1 >>> 10) | (t2 << 6)) & 0x1f03;\n t3 = key[ 6] & 0xff | (key[ 7] & 0xff) << 8; this.r[3] = ((t2 >>> 7) | (t3 << 9)) & 0x1fff;\n t4 = key[ 8] & 0xff | (key[ 9] & 0xff) << 8; this.r[4] = ((t3 >>> 4) | (t4 << 12)) & 0x00ff;\n this.r[5] = ((t4 >>> 1)) & 0x1ffe;\n t5 = key[10] & 0xff | (key[11] & 0xff) << 8; this.r[6] = ((t4 >>> 14) | (t5 << 2)) & 0x1fff;\n t6 = key[12] & 0xff | (key[13] & 0xff) << 8; this.r[7] = ((t5 >>> 11) | (t6 << 5)) & 0x1f81;\n t7 = key[14] & 0xff | (key[15] & 0xff) << 8; this.r[8] = ((t6 >>> 8) | (t7 << 8)) & 0x1fff;\n this.r[9] = ((t7 >>> 5)) & 0x007f;\n\n this.pad[0] = key[16] & 0xff | (key[17] & 0xff) << 8;\n this.pad[1] = key[18] & 0xff | (key[19] & 0xff) << 8;\n this.pad[2] = key[20] & 0xff | (key[21] & 0xff) << 8;\n this.pad[3] = key[22] & 0xff | (key[23] & 0xff) << 8;\n this.pad[4] = key[24] & 0xff | (key[25] & 0xff) << 8;\n this.pad[5] = key[26] & 0xff | (key[27] & 0xff) << 8;\n this.pad[6] = key[28] & 0xff | (key[29] & 0xff) << 8;\n this.pad[7] = key[30] & 0xff | (key[31] & 0xff) << 8;\n};\n\npoly1305.prototype.blocks = function(m, mpos, bytes) {\n var hibit = this.fin ? 0 : (1 << 11);\n var t0, t1, t2, t3, t4, t5, t6, t7, c;\n var d0, d1, d2, d3, d4, d5, d6, d7, d8, d9;\n\n var h0 = this.h[0],\n h1 = this.h[1],\n h2 = this.h[2],\n h3 = this.h[3],\n h4 = this.h[4],\n h5 = this.h[5],\n h6 = this.h[6],\n h7 = this.h[7],\n h8 = this.h[8],\n h9 = this.h[9];\n\n var r0 = this.r[0],\n r1 = this.r[1],\n r2 = this.r[2],\n r3 = this.r[3],\n r4 = this.r[4],\n r5 = this.r[5],\n r6 = this.r[6],\n r7 = this.r[7],\n r8 = this.r[8],\n r9 = this.r[9];\n\n while (bytes >= 16) {\n t0 = m[mpos+ 0] & 0xff | (m[mpos+ 1] & 0xff) << 8; h0 += ( t0 ) & 0x1fff;\n t1 = m[mpos+ 2] & 0xff | (m[mpos+ 3] & 0xff) << 8; h1 += ((t0 >>> 13) | (t1 << 3)) & 0x1fff;\n t2 = m[mpos+ 4] & 0xff | (m[mpos+ 5] & 0xff) << 8; h2 += ((t1 >>> 10) | (t2 << 6)) & 0x1fff;\n t3 = m[mpos+ 6] & 0xff | (m[mpos+ 7] & 0xff) << 8; h3 += ((t2 >>> 7) | (t3 << 9)) & 0x1fff;\n t4 = m[mpos+ 8] & 0xff | (m[mpos+ 9] & 0xff) << 8; h4 += ((t3 >>> 4) | (t4 << 12)) & 0x1fff;\n h5 += ((t4 >>> 1)) & 0x1fff;\n t5 = m[mpos+10] & 0xff | (m[mpos+11] & 0xff) << 8; h6 += ((t4 >>> 14) | (t5 << 2)) & 0x1fff;\n t6 = m[mpos+12] & 0xff | (m[mpos+13] & 0xff) << 8; h7 += ((t5 >>> 11) | (t6 << 5)) & 0x1fff;\n t7 = m[mpos+14] & 0xff | (m[mpos+15] & 0xff) << 8; h8 += ((t6 >>> 8) | (t7 << 8)) & 0x1fff;\n h9 += ((t7 >>> 5)) | hibit;\n\n c = 0;\n\n d0 = c;\n d0 += h0 * r0;\n d0 += h1 * (5 * r9);\n d0 += h2 * (5 * r8);\n d0 += h3 * (5 * r7);\n d0 += h4 * (5 * r6);\n c = (d0 >>> 13); d0 &= 0x1fff;\n d0 += h5 * (5 * r5);\n d0 += h6 * (5 * r4);\n d0 += h7 * (5 * r3);\n d0 += h8 * (5 * r2);\n d0 += h9 * (5 * r1);\n c += (d0 >>> 13); d0 &= 0x1fff;\n\n d1 = c;\n d1 += h0 * r1;\n d1 += h1 * r0;\n d1 += h2 * (5 * r9);\n d1 += h3 * (5 * r8);\n d1 += h4 * (5 * r7);\n c = (d1 >>> 13); d1 &= 0x1fff;\n d1 += h5 * (5 * r6);\n d1 += h6 * (5 * r5);\n d1 += h7 * (5 * r4);\n d1 += h8 * (5 * r3);\n d1 += h9 * (5 * r2);\n c += (d1 >>> 13); d1 &= 0x1fff;\n\n d2 = c;\n d2 += h0 * r2;\n d2 += h1 * r1;\n d2 += h2 * r0;\n d2 += h3 * (5 * r9);\n d2 += h4 * (5 * r8);\n c = (d2 >>> 13); d2 &= 0x1fff;\n d2 += h5 * (5 * r7);\n d2 += h6 * (5 * r6);\n d2 += h7 * (5 * r5);\n d2 += h8 * (5 * r4);\n d2 += h9 * (5 * r3);\n c += (d2 >>> 13); d2 &= 0x1fff;\n\n d3 = c;\n d3 += h0 * r3;\n d3 += h1 * r2;\n d3 += h2 * r1;\n d3 += h3 * r0;\n d3 += h4 * (5 * r9);\n c = (d3 >>> 13); d3 &= 0x1fff;\n d3 += h5 * (5 * r8);\n d3 += h6 * (5 * r7);\n d3 += h7 * (5 * r6);\n d3 += h8 * (5 * r5);\n d3 += h9 * (5 * r4);\n c += (d3 >>> 13); d3 &= 0x1fff;\n\n d4 = c;\n d4 += h0 * r4;\n d4 += h1 * r3;\n d4 += h2 * r2;\n d4 += h3 * r1;\n d4 += h4 * r0;\n c = (d4 >>> 13); d4 &= 0x1fff;\n d4 += h5 * (5 * r9);\n d4 += h6 * (5 * r8);\n d4 += h7 * (5 * r7);\n d4 += h8 * (5 * r6);\n d4 += h9 * (5 * r5);\n c += (d4 >>> 13); d4 &= 0x1fff;\n\n d5 = c;\n d5 += h0 * r5;\n d5 += h1 * r4;\n d5 += h2 * r3;\n d5 += h3 * r2;\n d5 += h4 * r1;\n c = (d5 >>> 13); d5 &= 0x1fff;\n d5 += h5 * r0;\n d5 += h6 * (5 * r9);\n d5 += h7 * (5 * r8);\n d5 += h8 * (5 * r7);\n d5 += h9 * (5 * r6);\n c += (d5 >>> 13); d5 &= 0x1fff;\n\n d6 = c;\n d6 += h0 * r6;\n d6 += h1 * r5;\n d6 += h2 * r4;\n d6 += h3 * r3;\n d6 += h4 * r2;\n c = (d6 >>> 13); d6 &= 0x1fff;\n d6 += h5 * r1;\n d6 += h6 * r0;\n d6 += h7 * (5 * r9);\n d6 += h8 * (5 * r8);\n d6 += h9 * (5 * r7);\n c += (d6 >>> 13); d6 &= 0x1fff;\n\n d7 = c;\n d7 += h0 * r7;\n d7 += h1 * r6;\n d7 += h2 * r5;\n d7 += h3 * r4;\n d7 += h4 * r3;\n c = (d7 >>> 13); d7 &= 0x1fff;\n d7 += h5 * r2;\n d7 += h6 * r1;\n d7 += h7 * r0;\n d7 += h8 * (5 * r9);\n d7 += h9 * (5 * r8);\n c += (d7 >>> 13); d7 &= 0x1fff;\n\n d8 = c;\n d8 += h0 * r8;\n d8 += h1 * r7;\n d8 += h2 * r6;\n d8 += h3 * r5;\n d8 += h4 * r4;\n c = (d8 >>> 13); d8 &= 0x1fff;\n d8 += h5 * r3;\n d8 += h6 * r2;\n d8 += h7 * r1;\n d8 += h8 * r0;\n d8 += h9 * (5 * r9);\n c += (d8 >>> 13); d8 &= 0x1fff;\n\n d9 = c;\n d9 += h0 * r9;\n d9 += h1 * r8;\n d9 += h2 * r7;\n d9 += h3 * r6;\n d9 += h4 * r5;\n c = (d9 >>> 13); d9 &= 0x1fff;\n d9 += h5 * r4;\n d9 += h6 * r3;\n d9 += h7 * r2;\n d9 += h8 * r1;\n d9 += h9 * r0;\n c += (d9 >>> 13); d9 &= 0x1fff;\n\n c = (((c << 2) + c)) | 0;\n c = (c + d0) | 0;\n d0 = c & 0x1fff;\n c = (c >>> 13);\n d1 += c;\n\n h0 = d0;\n h1 = d1;\n h2 = d2;\n h3 = d3;\n h4 = d4;\n h5 = d5;\n h6 = d6;\n h7 = d7;\n h8 = d8;\n h9 = d9;\n\n mpos += 16;\n bytes -= 16;\n }\n this.h[0] = h0;\n this.h[1] = h1;\n this.h[2] = h2;\n this.h[3] = h3;\n this.h[4] = h4;\n this.h[5] = h5;\n this.h[6] = h6;\n this.h[7] = h7;\n this.h[8] = h8;\n this.h[9] = h9;\n};\n\npoly1305.prototype.finish = function(mac, macpos) {\n var g = new Uint16Array(10);\n var c, mask, f, i;\n\n if (this.leftover) {\n i = this.leftover;\n this.buffer[i++] = 1;\n for (; i < 16; i++) this.buffer[i] = 0;\n this.fin = 1;\n this.blocks(this.buffer, 0, 16);\n }\n\n c = this.h[1] >>> 13;\n this.h[1] &= 0x1fff;\n for (i = 2; i < 10; i++) {\n this.h[i] += c;\n c = this.h[i] >>> 13;\n this.h[i] &= 0x1fff;\n }\n this.h[0] += (c * 5);\n c = this.h[0] >>> 13;\n this.h[0] &= 0x1fff;\n this.h[1] += c;\n c = this.h[1] >>> 13;\n this.h[1] &= 0x1fff;\n this.h[2] += c;\n\n g[0] = this.h[0] + 5;\n c = g[0] >>> 13;\n g[0] &= 0x1fff;\n for (i = 1; i < 10; i++) {\n g[i] = this.h[i] + c;\n c = g[i] >>> 13;\n g[i] &= 0x1fff;\n }\n g[9] -= (1 << 13);\n\n mask = (c ^ 1) - 1;\n for (i = 0; i < 10; i++) g[i] &= mask;\n mask = ~mask;\n for (i = 0; i < 10; i++) this.h[i] = (this.h[i] & mask) | g[i];\n\n this.h[0] = ((this.h[0] ) | (this.h[1] << 13) ) & 0xffff;\n this.h[1] = ((this.h[1] >>> 3) | (this.h[2] << 10) ) & 0xffff;\n this.h[2] = ((this.h[2] >>> 6) | (this.h[3] << 7) ) & 0xffff;\n this.h[3] = ((this.h[3] >>> 9) | (this.h[4] << 4) ) & 0xffff;\n this.h[4] = ((this.h[4] >>> 12) | (this.h[5] << 1) | (this.h[6] << 14)) & 0xffff;\n this.h[5] = ((this.h[6] >>> 2) | (this.h[7] << 11) ) & 0xffff;\n this.h[6] = ((this.h[7] >>> 5) | (this.h[8] << 8) ) & 0xffff;\n this.h[7] = ((this.h[8] >>> 8) | (this.h[9] << 5) ) & 0xffff;\n\n f = this.h[0] + this.pad[0];\n this.h[0] = f & 0xffff;\n for (i = 1; i < 8; i++) {\n f = (((this.h[i] + this.pad[i]) | 0) + (f >>> 16)) | 0;\n this.h[i] = f & 0xffff;\n }\n\n mac[macpos+ 0] = (this.h[0] >>> 0) & 0xff;\n mac[macpos+ 1] = (this.h[0] >>> 8) & 0xff;\n mac[macpos+ 2] = (this.h[1] >>> 0) & 0xff;\n mac[macpos+ 3] = (this.h[1] >>> 8) & 0xff;\n mac[macpos+ 4] = (this.h[2] >>> 0) & 0xff;\n mac[macpos+ 5] = (this.h[2] >>> 8) & 0xff;\n mac[macpos+ 6] = (this.h[3] >>> 0) & 0xff;\n mac[macpos+ 7] = (this.h[3] >>> 8) & 0xff;\n mac[macpos+ 8] = (this.h[4] >>> 0) & 0xff;\n mac[macpos+ 9] = (this.h[4] >>> 8) & 0xff;\n mac[macpos+10] = (this.h[5] >>> 0) & 0xff;\n mac[macpos+11] = (this.h[5] >>> 8) & 0xff;\n mac[macpos+12] = (this.h[6] >>> 0) & 0xff;\n mac[macpos+13] = (this.h[6] >>> 8) & 0xff;\n mac[macpos+14] = (this.h[7] >>> 0) & 0xff;\n mac[macpos+15] = (this.h[7] >>> 8) & 0xff;\n};\n\npoly1305.prototype.update = function(m, mpos, bytes) {\n var i, want;\n\n if (this.leftover) {\n want = (16 - this.leftover);\n if (want > bytes)\n want = bytes;\n for (i = 0; i < want; i++)\n this.buffer[this.leftover + i] = m[mpos+i];\n bytes -= want;\n mpos += want;\n this.leftover += want;\n if (this.leftover < 16)\n return;\n this.blocks(this.buffer, 0, 16);\n this.leftover = 0;\n }\n\n if (bytes >= 16) {\n want = bytes - (bytes % 16);\n this.blocks(m, mpos, want);\n mpos += want;\n bytes -= want;\n }\n\n if (bytes) {\n for (i = 0; i < bytes; i++)\n this.buffer[this.leftover + i] = m[mpos+i];\n this.leftover += bytes;\n }\n};\n\nfunction crypto_onetimeauth(out, outpos, m, mpos, n, k) {\n var s = new poly1305(k);\n s.update(m, mpos, n);\n s.finish(out, outpos);\n return 0;\n}\n\nfunction crypto_onetimeauth_verify(h, hpos, m, mpos, n, k) {\n var x = new Uint8Array(16);\n crypto_onetimeauth(x,0,m,mpos,n,k);\n return crypto_verify_16(h,hpos,x,0);\n}\n\nfunction crypto_secretbox(c,m,d,n,k) {\n var i;\n if (d < 32) return -1;\n crypto_stream_xor(c,0,m,0,d,n,k);\n crypto_onetimeauth(c, 16, c, 32, d - 32, c);\n for (i = 0; i < 16; i++) c[i] = 0;\n return 0;\n}\n\nfunction crypto_secretbox_open(m,c,d,n,k) {\n var i;\n var x = new Uint8Array(32);\n if (d < 32) return -1;\n crypto_stream(x,0,32,n,k);\n if (crypto_onetimeauth_verify(c, 16,c, 32,d - 32,x) !== 0) return -1;\n crypto_stream_xor(m,0,c,0,d,n,k);\n for (i = 0; i < 32; i++) m[i] = 0;\n return 0;\n}\n\nfunction set25519(r, a) {\n var i;\n for (i = 0; i < 16; i++) r[i] = a[i]|0;\n}\n\nfunction car25519(o) {\n var i, v, c = 1;\n for (i = 0; i < 16; i++) {\n v = o[i] + c + 65535;\n c = Math.floor(v / 65536);\n o[i] = v - c * 65536;\n }\n o[0] += c-1 + 37 * (c-1);\n}\n\nfunction sel25519(p, q, b) {\n var t, c = ~(b-1);\n for (var i = 0; i < 16; i++) {\n t = c & (p[i] ^ q[i]);\n p[i] ^= t;\n q[i] ^= t;\n }\n}\n\nfunction pack25519(o, n) {\n var i, j, b;\n var m = gf(), t = gf();\n for (i = 0; i < 16; i++) t[i] = n[i];\n car25519(t);\n car25519(t);\n car25519(t);\n for (j = 0; j < 2; j++) {\n m[0] = t[0] - 0xffed;\n for (i = 1; i < 15; i++) {\n m[i] = t[i] - 0xffff - ((m[i-1]>>16) & 1);\n m[i-1] &= 0xffff;\n }\n m[15] = t[15] - 0x7fff - ((m[14]>>16) & 1);\n b = (m[15]>>16) & 1;\n m[14] &= 0xffff;\n sel25519(t, m, 1-b);\n }\n for (i = 0; i < 16; i++) {\n o[2*i] = t[i] & 0xff;\n o[2*i+1] = t[i]>>8;\n }\n}\n\nfunction neq25519(a, b) {\n var c = new Uint8Array(32), d = new Uint8Array(32);\n pack25519(c, a);\n pack25519(d, b);\n return crypto_verify_32(c, 0, d, 0);\n}\n\nfunction par25519(a) {\n var d = new Uint8Array(32);\n pack25519(d, a);\n return d[0] & 1;\n}\n\nfunction unpack25519(o, n) {\n var i;\n for (i = 0; i < 16; i++) o[i] = n[2*i] + (n[2*i+1] << 8);\n o[15] &= 0x7fff;\n}\n\nfunction A(o, a, b) {\n for (var i = 0; i < 16; i++) o[i] = a[i] + b[i];\n}\n\nfunction Z(o, a, b) {\n for (var i = 0; i < 16; i++) o[i] = a[i] - b[i];\n}\n\nfunction M(o, a, b) {\n var v, c,\n t0 = 0, t1 = 0, t2 = 0, t3 = 0, t4 = 0, t5 = 0, t6 = 0, t7 = 0,\n t8 = 0, t9 = 0, t10 = 0, t11 = 0, t12 = 0, t13 = 0, t14 = 0, t15 = 0,\n t16 = 0, t17 = 0, t18 = 0, t19 = 0, t20 = 0, t21 = 0, t22 = 0, t23 = 0,\n t24 = 0, t25 = 0, t26 = 0, t27 = 0, t28 = 0, t29 = 0, t30 = 0,\n b0 = b[0],\n b1 = b[1],\n b2 = b[2],\n b3 = b[3],\n b4 = b[4],\n b5 = b[5],\n b6 = b[6],\n b7 = b[7],\n b8 = b[8],\n b9 = b[9],\n b10 = b[10],\n b11 = b[11],\n b12 = b[12],\n b13 = b[13],\n b14 = b[14],\n b15 = b[15];\n\n v = a[0];\n t0 += v * b0;\n t1 += v * b1;\n t2 += v * b2;\n t3 += v * b3;\n t4 += v * b4;\n t5 += v * b5;\n t6 += v * b6;\n t7 += v * b7;\n t8 += v * b8;\n t9 += v * b9;\n t10 += v * b10;\n t11 += v * b11;\n t12 += v * b12;\n t13 += v * b13;\n t14 += v * b14;\n t15 += v * b15;\n v = a[1];\n t1 += v * b0;\n t2 += v * b1;\n t3 += v * b2;\n t4 += v * b3;\n t5 += v * b4;\n t6 += v * b5;\n t7 += v * b6;\n t8 += v * b7;\n t9 += v * b8;\n t10 += v * b9;\n t11 += v * b10;\n t12 += v * b11;\n t13 += v * b12;\n t14 += v * b13;\n t15 += v * b14;\n t16 += v * b15;\n v = a[2];\n t2 += v * b0;\n t3 += v * b1;\n t4 += v * b2;\n t5 += v * b3;\n t6 += v * b4;\n t7 += v * b5;\n t8 += v * b6;\n t9 += v * b7;\n t10 += v * b8;\n t11 += v * b9;\n t12 += v * b10;\n t13 += v * b11;\n t14 += v * b12;\n t15 += v * b13;\n t16 += v * b14;\n t17 += v * b15;\n v = a[3];\n t3 += v * b0;\n t4 += v * b1;\n t5 += v * b2;\n t6 += v * b3;\n t7 += v * b4;\n t8 += v * b5;\n t9 += v * b6;\n t10 += v * b7;\n t11 += v * b8;\n t12 += v * b9;\n t13 += v * b10;\n t14 += v * b11;\n t15 += v * b12;\n t16 += v * b13;\n t17 += v * b14;\n t18 += v * b15;\n v = a[4];\n t4 += v * b0;\n t5 += v * b1;\n t6 += v * b2;\n t7 += v * b3;\n t8 += v * b4;\n t9 += v * b5;\n t10 += v * b6;\n t11 += v * b7;\n t12 += v * b8;\n t13 += v * b9;\n t14 += v * b10;\n t15 += v * b11;\n t16 += v * b12;\n t17 += v * b13;\n t18 += v * b14;\n t19 += v * b15;\n v = a[5];\n t5 += v * b0;\n t6 += v * b1;\n t7 += v * b2;\n t8 += v * b3;\n t9 += v * b4;\n t10 += v * b5;\n t11 += v * b6;\n t12 += v * b7;\n t13 += v * b8;\n t14 += v * b9;\n t15 += v * b10;\n t16 += v * b11;\n t17 += v * b12;\n t18 += v * b13;\n t19 += v * b14;\n t20 += v * b15;\n v = a[6];\n t6 += v * b0;\n t7 += v * b1;\n t8 += v * b2;\n t9 += v * b3;\n t10 += v * b4;\n t11 += v * b5;\n t12 += v * b6;\n t13 += v * b7;\n t14 += v * b8;\n t15 += v * b9;\n t16 += v * b10;\n t17 += v * b11;\n t18 += v * b12;\n t19 += v * b13;\n t20 += v * b14;\n t21 += v * b15;\n v = a[7];\n t7 += v * b0;\n t8 += v * b1;\n t9 += v * b2;\n t10 += v * b3;\n t11 += v * b4;\n t12 += v * b5;\n t13 += v * b6;\n t14 += v * b7;\n t15 += v * b8;\n t16 += v * b9;\n t17 += v * b10;\n t18 += v * b11;\n t19 += v * b12;\n t20 += v * b13;\n t21 += v * b14;\n t22 += v * b15;\n v = a[8];\n t8 += v * b0;\n t9 += v * b1;\n t10 += v * b2;\n t11 += v * b3;\n t12 += v * b4;\n t13 += v * b5;\n t14 += v * b6;\n t15 += v * b7;\n t16 += v * b8;\n t17 += v * b9;\n t18 += v * b10;\n t19 += v * b11;\n t20 += v * b12;\n t21 += v * b13;\n t22 += v * b14;\n t23 += v * b15;\n v = a[9];\n t9 += v * b0;\n t10 += v * b1;\n t11 += v * b2;\n t12 += v * b3;\n t13 += v * b4;\n t14 += v * b5;\n t15 += v * b6;\n t16 += v * b7;\n t17 += v * b8;\n t18 += v * b9;\n t19 += v * b10;\n t20 += v * b11;\n t21 += v * b12;\n t22 += v * b13;\n t23 += v * b14;\n t24 += v * b15;\n v = a[10];\n t10 += v * b0;\n t11 += v * b1;\n t12 += v * b2;\n t13 += v * b3;\n t14 += v * b4;\n t15 += v * b5;\n t16 += v * b6;\n t17 += v * b7;\n t18 += v * b8;\n t19 += v * b9;\n t20 += v * b10;\n t21 += v * b11;\n t22 += v * b12;\n t23 += v * b13;\n t24 += v * b14;\n t25 += v * b15;\n v = a[11];\n t11 += v * b0;\n t12 += v * b1;\n t13 += v * b2;\n t14 += v * b3;\n t15 += v * b4;\n t16 += v * b5;\n t17 += v * b6;\n t18 += v * b7;\n t19 += v * b8;\n t20 += v * b9;\n t21 += v * b10;\n t22 += v * b11;\n t23 += v * b12;\n t24 += v * b13;\n t25 += v * b14;\n t26 += v * b15;\n v = a[12];\n t12 += v * b0;\n t13 += v * b1;\n t14 += v * b2;\n t15 += v * b3;\n t16 += v * b4;\n t17 += v * b5;\n t18 += v * b6;\n t19 += v * b7;\n t20 += v * b8;\n t21 += v * b9;\n t22 += v * b10;\n t23 += v * b11;\n t24 += v * b12;\n t25 += v * b13;\n t26 += v * b14;\n t27 += v * b15;\n v = a[13];\n t13 += v * b0;\n t14 += v * b1;\n t15 += v * b2;\n t16 += v * b3;\n t17 += v * b4;\n t18 += v * b5;\n t19 += v * b6;\n t20 += v * b7;\n t21 += v * b8;\n t22 += v * b9;\n t23 += v * b10;\n t24 += v * b11;\n t25 += v * b12;\n t26 += v * b13;\n t27 += v * b14;\n t28 += v * b15;\n v = a[14];\n t14 += v * b0;\n t15 += v * b1;\n t16 += v * b2;\n t17 += v * b3;\n t18 += v * b4;\n t19 += v * b5;\n t20 += v * b6;\n t21 += v * b7;\n t22 += v * b8;\n t23 += v * b9;\n t24 += v * b10;\n t25 += v * b11;\n t26 += v * b12;\n t27 += v * b13;\n t28 += v * b14;\n t29 += v * b15;\n v = a[15];\n t15 += v * b0;\n t16 += v * b1;\n t17 += v * b2;\n t18 += v * b3;\n t19 += v * b4;\n t20 += v * b5;\n t21 += v * b6;\n t22 += v * b7;\n t23 += v * b8;\n t24 += v * b9;\n t25 += v * b10;\n t26 += v * b11;\n t27 += v * b12;\n t28 += v * b13;\n t29 += v * b14;\n t30 += v * b15;\n\n t0 += 38 * t16;\n t1 += 38 * t17;\n t2 += 38 * t18;\n t3 += 38 * t19;\n t4 += 38 * t20;\n t5 += 38 * t21;\n t6 += 38 * t22;\n t7 += 38 * t23;\n t8 += 38 * t24;\n t9 += 38 * t25;\n t10 += 38 * t26;\n t11 += 38 * t27;\n t12 += 38 * t28;\n t13 += 38 * t29;\n t14 += 38 * t30;\n // t15 left as is\n\n // first car\n c = 1;\n v = t0 + c + 65535; c = Math.floor(v / 65536); t0 = v - c * 65536;\n v = t1 + c + 65535; c = Math.floor(v / 65536); t1 = v - c * 65536;\n v = t2 + c + 65535; c = Math.floor(v / 65536); t2 = v - c * 65536;\n v = t3 + c + 65535; c = Math.floor(v / 65536); t3 = v - c * 65536;\n v = t4 + c + 65535; c = Math.floor(v / 65536); t4 = v - c * 65536;\n v = t5 + c + 65535; c = Math.floor(v / 65536); t5 = v - c * 65536;\n v = t6 + c + 65535; c = Math.floor(v / 65536); t6 = v - c * 65536;\n v = t7 + c + 65535; c = Math.floor(v / 65536); t7 = v - c * 65536;\n v = t8 + c + 65535; c = Math.floor(v / 65536); t8 = v - c * 65536;\n v = t9 + c + 65535; c = Math.floor(v / 65536); t9 = v - c * 65536;\n v = t10 + c + 65535; c = Math.floor(v / 65536); t10 = v - c * 65536;\n v = t11 + c + 65535; c = Math.floor(v / 65536); t11 = v - c * 65536;\n v = t12 + c + 65535; c = Math.floor(v / 65536); t12 = v - c * 65536;\n v = t13 + c + 65535; c = Math.floor(v / 65536); t13 = v - c * 65536;\n v = t14 + c + 65535; c = Math.floor(v / 65536); t14 = v - c * 65536;\n v = t15 + c + 65535; c = Math.floor(v / 65536); t15 = v - c * 65536;\n t0 += c-1 + 37 * (c-1);\n\n // second car\n c = 1;\n v = t0 + c + 65535; c = Math.floor(v / 65536); t0 = v - c * 65536;\n v = t1 + c + 65535; c = Math.floor(v / 65536); t1 = v - c * 65536;\n v = t2 + c + 65535; c = Math.floor(v / 65536); t2 = v - c * 65536;\n v = t3 + c + 65535; c = Math.floor(v / 65536); t3 = v - c * 65536;\n v = t4 + c + 65535; c = Math.floor(v / 65536); t4 = v - c * 65536;\n v = t5 + c + 65535; c = Math.floor(v / 65536); t5 = v - c * 65536;\n v = t6 + c + 65535; c = Math.floor(v / 65536); t6 = v - c * 65536;\n v = t7 + c + 65535; c = Math.floor(v / 65536); t7 = v - c * 65536;\n v = t8 + c + 65535; c = Math.floor(v / 65536); t8 = v - c * 65536;\n v = t9 + c + 65535; c = Math.floor(v / 65536); t9 = v - c * 65536;\n v = t10 + c + 65535; c = Math.floor(v / 65536); t10 = v - c * 65536;\n v = t11 + c + 65535; c = Math.floor(v / 65536); t11 = v - c * 65536;\n v = t12 + c + 65535; c = Math.floor(v / 65536); t12 = v - c * 65536;\n v = t13 + c + 65535; c = Math.floor(v / 65536); t13 = v - c * 65536;\n v = t14 + c + 65535; c = Math.floor(v / 65536); t14 = v - c * 65536;\n v = t15 + c + 65535; c = Math.floor(v / 65536); t15 = v - c * 65536;\n t0 += c-1 + 37 * (c-1);\n\n o[ 0] = t0;\n o[ 1] = t1;\n o[ 2] = t2;\n o[ 3] = t3;\n o[ 4] = t4;\n o[ 5] = t5;\n o[ 6] = t6;\n o[ 7] = t7;\n o[ 8] = t8;\n o[ 9] = t9;\n o[10] = t10;\n o[11] = t11;\n o[12] = t12;\n o[13] = t13;\n o[14] = t14;\n o[15] = t15;\n}\n\nfunction S(o, a) {\n M(o, a, a);\n}\n\nfunction inv25519(o, i) {\n var c = gf();\n var a;\n for (a = 0; a < 16; a++) c[a] = i[a];\n for (a = 253; a >= 0; a--) {\n S(c, c);\n if(a !== 2 && a !== 4) M(c, c, i);\n }\n for (a = 0; a < 16; a++) o[a] = c[a];\n}\n\nfunction pow2523(o, i) {\n var c = gf();\n var a;\n for (a = 0; a < 16; a++) c[a] = i[a];\n for (a = 250; a >= 0; a--) {\n S(c, c);\n if(a !== 1) M(c, c, i);\n }\n for (a = 0; a < 16; a++) o[a] = c[a];\n}\n\nfunction crypto_scalarmult(q, n, p) {\n var z = new Uint8Array(32);\n var x = new Float64Array(80), r, i;\n var a = gf(), b = gf(), c = gf(),\n d = gf(), e = gf(), f = gf();\n for (i = 0; i < 31; i++) z[i] = n[i];\n z[31]=(n[31]&127)|64;\n z[0]&=248;\n unpack25519(x,p);\n for (i = 0; i < 16; i++) {\n b[i]=x[i];\n d[i]=a[i]=c[i]=0;\n }\n a[0]=d[0]=1;\n for (i=254; i>=0; --i) {\n r=(z[i>>>3]>>>(i&7))&1;\n sel25519(a,b,r);\n sel25519(c,d,r);\n A(e,a,c);\n Z(a,a,c);\n A(c,b,d);\n Z(b,b,d);\n S(d,e);\n S(f,a);\n M(a,c,a);\n M(c,b,e);\n A(e,a,c);\n Z(a,a,c);\n S(b,a);\n Z(c,d,f);\n M(a,c,_121665);\n A(a,a,d);\n M(c,c,a);\n M(a,d,f);\n M(d,b,x);\n S(b,e);\n sel25519(a,b,r);\n sel25519(c,d,r);\n }\n for (i = 0; i < 16; i++) {\n x[i+16]=a[i];\n x[i+32]=c[i];\n x[i+48]=b[i];\n x[i+64]=d[i];\n }\n var x32 = x.subarray(32);\n var x16 = x.subarray(16);\n inv25519(x32,x32);\n M(x16,x16,x32);\n pack25519(q,x16);\n return 0;\n}\n\nfunction crypto_scalarmult_base(q, n) {\n return crypto_scalarmult(q, n, _9);\n}\n\nfunction crypto_box_keypair(y, x) {\n randombytes(x, 32);\n return crypto_scalarmult_base(y, x);\n}\n\nfunction crypto_box_beforenm(k, y, x) {\n var s = new Uint8Array(32);\n crypto_scalarmult(s, x, y);\n return crypto_core_hsalsa20(k, _0, s, sigma);\n}\n\nvar crypto_box_afternm = crypto_secretbox;\nvar crypto_box_open_afternm = crypto_secretbox_open;\n\nfunction crypto_box(c, m, d, n, y, x) {\n var k = new Uint8Array(32);\n crypto_box_beforenm(k, y, x);\n return crypto_box_afternm(c, m, d, n, k);\n}\n\nfunction crypto_box_open(m, c, d, n, y, x) {\n var k = new Uint8Array(32);\n crypto_box_beforenm(k, y, x);\n return crypto_box_open_afternm(m, c, d, n, k);\n}\n\nvar K = [\n 0x428a2f98, 0xd728ae22, 0x71374491, 0x23ef65cd,\n 0xb5c0fbcf, 0xec4d3b2f, 0xe9b5dba5, 0x8189dbbc,\n 0x3956c25b, 0xf348b538, 0x59f111f1, 0xb605d019,\n 0x923f82a4, 0xaf194f9b, 0xab1c5ed5, 0xda6d8118,\n 0xd807aa98, 0xa3030242, 0x12835b01, 0x45706fbe,\n 0x243185be, 0x4ee4b28c, 0x550c7dc3, 0xd5ffb4e2,\n 0x72be5d74, 0xf27b896f, 0x80deb1fe, 0x3b1696b1,\n 0x9bdc06a7, 0x25c71235, 0xc19bf174, 0xcf692694,\n 0xe49b69c1, 0x9ef14ad2, 0xefbe4786, 0x384f25e3,\n 0x0fc19dc6, 0x8b8cd5b5, 0x240ca1cc, 0x77ac9c65,\n 0x2de92c6f, 0x592b0275, 0x4a7484aa, 0x6ea6e483,\n 0x5cb0a9dc, 0xbd41fbd4, 0x76f988da, 0x831153b5,\n 0x983e5152, 0xee66dfab, 0xa831c66d, 0x2db43210,\n 0xb00327c8, 0x98fb213f, 0xbf597fc7, 0xbeef0ee4,\n 0xc6e00bf3, 0x3da88fc2, 0xd5a79147, 0x930aa725,\n 0x06ca6351, 0xe003826f, 0x14292967, 0x0a0e6e70,\n 0x27b70a85, 0x46d22ffc, 0x2e1b2138, 0x5c26c926,\n 0x4d2c6dfc, 0x5ac42aed, 0x53380d13, 0x9d95b3df,\n 0x650a7354, 0x8baf63de, 0x766a0abb, 0x3c77b2a8,\n 0x81c2c92e, 0x47edaee6, 0x92722c85, 0x1482353b,\n 0xa2bfe8a1, 0x4cf10364, 0xa81a664b, 0xbc423001,\n 0xc24b8b70, 0xd0f89791, 0xc76c51a3, 0x0654be30,\n 0xd192e819, 0xd6ef5218, 0xd6990624, 0x5565a910,\n 0xf40e3585, 0x5771202a, 0x106aa070, 0x32bbd1b8,\n 0x19a4c116, 0xb8d2d0c8, 0x1e376c08, 0x5141ab53,\n 0x2748774c, 0xdf8eeb99, 0x34b0bcb5, 0xe19b48a8,\n 0x391c0cb3, 0xc5c95a63, 0x4ed8aa4a, 0xe3418acb,\n 0x5b9cca4f, 0x7763e373, 0x682e6ff3, 0xd6b2b8a3,\n 0x748f82ee, 0x5defb2fc, 0x78a5636f, 0x43172f60,\n 0x84c87814, 0xa1f0ab72, 0x8cc70208, 0x1a6439ec,\n 0x90befffa, 0x23631e28, 0xa4506ceb, 0xde82bde9,\n 0xbef9a3f7, 0xb2c67915, 0xc67178f2, 0xe372532b,\n 0xca273ece, 0xea26619c, 0xd186b8c7, 0x21c0c207,\n 0xeada7dd6, 0xcde0eb1e, 0xf57d4f7f, 0xee6ed178,\n 0x06f067aa, 0x72176fba, 0x0a637dc5, 0xa2c898a6,\n 0x113f9804, 0xbef90dae, 0x1b710b35, 0x131c471b,\n 0x28db77f5, 0x23047d84, 0x32caab7b, 0x40c72493,\n 0x3c9ebe0a, 0x15c9bebc, 0x431d67c4, 0x9c100d4c,\n 0x4cc5d4be, 0xcb3e42b6, 0x597f299c, 0xfc657e2a,\n 0x5fcb6fab, 0x3ad6faec, 0x6c44198c, 0x4a475817\n];\n\nfunction crypto_hashblocks_hl(hh, hl, m, n) {\n var wh = new Int32Array(16), wl = new Int32Array(16),\n bh0, bh1, bh2, bh3, bh4, bh5, bh6, bh7,\n bl0, bl1, bl2, bl3, bl4, bl5, bl6, bl7,\n th, tl, i, j, h, l, a, b, c, d;\n\n var ah0 = hh[0],\n ah1 = hh[1],\n ah2 = hh[2],\n ah3 = hh[3],\n ah4 = hh[4],\n ah5 = hh[5],\n ah6 = hh[6],\n ah7 = hh[7],\n\n al0 = hl[0],\n al1 = hl[1],\n al2 = hl[2],\n al3 = hl[3],\n al4 = hl[4],\n al5 = hl[5],\n al6 = hl[6],\n al7 = hl[7];\n\n var pos = 0;\n while (n >= 128) {\n for (i = 0; i < 16; i++) {\n j = 8 * i + pos;\n wh[i] = (m[j+0] << 24) | (m[j+1] << 16) | (m[j+2] << 8) | m[j+3];\n wl[i] = (m[j+4] << 24) | (m[j+5] << 16) | (m[j+6] << 8) | m[j+7];\n }\n for (i = 0; i < 80; i++) {\n bh0 = ah0;\n bh1 = ah1;\n bh2 = ah2;\n bh3 = ah3;\n bh4 = ah4;\n bh5 = ah5;\n bh6 = ah6;\n bh7 = ah7;\n\n bl0 = al0;\n bl1 = al1;\n bl2 = al2;\n bl3 = al3;\n bl4 = al4;\n bl5 = al5;\n bl6 = al6;\n bl7 = al7;\n\n // add\n h = ah7;\n l = al7;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n // Sigma1\n h = ((ah4 >>> 14) | (al4 << (32-14))) ^ ((ah4 >>> 18) | (al4 << (32-18))) ^ ((al4 >>> (41-32)) | (ah4 << (32-(41-32))));\n l = ((al4 >>> 14) | (ah4 << (32-14))) ^ ((al4 >>> 18) | (ah4 << (32-18))) ^ ((ah4 >>> (41-32)) | (al4 << (32-(41-32))));\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // Ch\n h = (ah4 & ah5) ^ (~ah4 & ah6);\n l = (al4 & al5) ^ (~al4 & al6);\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // K\n h = K[i*2];\n l = K[i*2+1];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // w\n h = wh[i%16];\n l = wl[i%16];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n th = c & 0xffff | d << 16;\n tl = a & 0xffff | b << 16;\n\n // add\n h = th;\n l = tl;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n // Sigma0\n h = ((ah0 >>> 28) | (al0 << (32-28))) ^ ((al0 >>> (34-32)) | (ah0 << (32-(34-32)))) ^ ((al0 >>> (39-32)) | (ah0 << (32-(39-32))));\n l = ((al0 >>> 28) | (ah0 << (32-28))) ^ ((ah0 >>> (34-32)) | (al0 << (32-(34-32)))) ^ ((ah0 >>> (39-32)) | (al0 << (32-(39-32))));\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // Maj\n h = (ah0 & ah1) ^ (ah0 & ah2) ^ (ah1 & ah2);\n l = (al0 & al1) ^ (al0 & al2) ^ (al1 & al2);\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n bh7 = (c & 0xffff) | (d << 16);\n bl7 = (a & 0xffff) | (b << 16);\n\n // add\n h = bh3;\n l = bl3;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = th;\n l = tl;\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n bh3 = (c & 0xffff) | (d << 16);\n bl3 = (a & 0xffff) | (b << 16);\n\n ah1 = bh0;\n ah2 = bh1;\n ah3 = bh2;\n ah4 = bh3;\n ah5 = bh4;\n ah6 = bh5;\n ah7 = bh6;\n ah0 = bh7;\n\n al1 = bl0;\n al2 = bl1;\n al3 = bl2;\n al4 = bl3;\n al5 = bl4;\n al6 = bl5;\n al7 = bl6;\n al0 = bl7;\n\n if (i%16 === 15) {\n for (j = 0; j < 16; j++) {\n // add\n h = wh[j];\n l = wl[j];\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = wh[(j+9)%16];\n l = wl[(j+9)%16];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // sigma0\n th = wh[(j+1)%16];\n tl = wl[(j+1)%16];\n h = ((th >>> 1) | (tl << (32-1))) ^ ((th >>> 8) | (tl << (32-8))) ^ (th >>> 7);\n l = ((tl >>> 1) | (th << (32-1))) ^ ((tl >>> 8) | (th << (32-8))) ^ ((tl >>> 7) | (th << (32-7)));\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // sigma1\n th = wh[(j+14)%16];\n tl = wl[(j+14)%16];\n h = ((th >>> 19) | (tl << (32-19))) ^ ((tl >>> (61-32)) | (th << (32-(61-32)))) ^ (th >>> 6);\n l = ((tl >>> 19) | (th << (32-19))) ^ ((th >>> (61-32)) | (tl << (32-(61-32)))) ^ ((tl >>> 6) | (th << (32-6)));\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n wh[j] = (c & 0xffff) | (d << 16);\n wl[j] = (a & 0xffff) | (b << 16);\n }\n }\n }\n\n // add\n h = ah0;\n l = al0;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[0];\n l = hl[0];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[0] = ah0 = (c & 0xffff) | (d << 16);\n hl[0] = al0 = (a & 0xffff) | (b << 16);\n\n h = ah1;\n l = al1;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[1];\n l = hl[1];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[1] = ah1 = (c & 0xffff) | (d << 16);\n hl[1] = al1 = (a & 0xffff) | (b << 16);\n\n h = ah2;\n l = al2;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[2];\n l = hl[2];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[2] = ah2 = (c & 0xffff) | (d << 16);\n hl[2] = al2 = (a & 0xffff) | (b << 16);\n\n h = ah3;\n l = al3;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[3];\n l = hl[3];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[3] = ah3 = (c & 0xffff) | (d << 16);\n hl[3] = al3 = (a & 0xffff) | (b << 16);\n\n h = ah4;\n l = al4;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[4];\n l = hl[4];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[4] = ah4 = (c & 0xffff) | (d << 16);\n hl[4] = al4 = (a & 0xffff) | (b << 16);\n\n h = ah5;\n l = al5;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[5];\n l = hl[5];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[5] = ah5 = (c & 0xffff) | (d << 16);\n hl[5] = al5 = (a & 0xffff) | (b << 16);\n\n h = ah6;\n l = al6;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[6];\n l = hl[6];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[6] = ah6 = (c & 0xffff) | (d << 16);\n hl[6] = al6 = (a & 0xffff) | (b << 16);\n\n h = ah7;\n l = al7;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[7];\n l = hl[7];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[7] = ah7 = (c & 0xffff) | (d << 16);\n hl[7] = al7 = (a & 0xffff) | (b << 16);\n\n pos += 128;\n n -= 128;\n }\n\n return n;\n}\n\nfunction crypto_hash(out, m, n) {\n var hh = new Int32Array(8),\n hl = new Int32Array(8),\n x = new Uint8Array(256),\n i, b = n;\n\n hh[0] = 0x6a09e667;\n hh[1] = 0xbb67ae85;\n hh[2] = 0x3c6ef372;\n hh[3] = 0xa54ff53a;\n hh[4] = 0x510e527f;\n hh[5] = 0x9b05688c;\n hh[6] = 0x1f83d9ab;\n hh[7] = 0x5be0cd19;\n\n hl[0] = 0xf3bcc908;\n hl[1] = 0x84caa73b;\n hl[2] = 0xfe94f82b;\n hl[3] = 0x5f1d36f1;\n hl[4] = 0xade682d1;\n hl[5] = 0x2b3e6c1f;\n hl[6] = 0xfb41bd6b;\n hl[7] = 0x137e2179;\n\n crypto_hashblocks_hl(hh, hl, m, n);\n n %= 128;\n\n for (i = 0; i < n; i++) x[i] = m[b-n+i];\n x[n] = 128;\n\n n = 256-128*(n<112?1:0);\n x[n-9] = 0;\n ts64(x, n-8, (b / 0x20000000) | 0, b << 3);\n crypto_hashblocks_hl(hh, hl, x, n);\n\n for (i = 0; i < 8; i++) ts64(out, 8*i, hh[i], hl[i]);\n\n return 0;\n}\n\nfunction add(p, q) {\n var a = gf(), b = gf(), c = gf(),\n d = gf(), e = gf(), f = gf(),\n g = gf(), h = gf(), t = gf();\n\n Z(a, p[1], p[0]);\n Z(t, q[1], q[0]);\n M(a, a, t);\n A(b, p[0], p[1]);\n A(t, q[0], q[1]);\n M(b, b, t);\n M(c, p[3], q[3]);\n M(c, c, D2);\n M(d, p[2], q[2]);\n A(d, d, d);\n Z(e, b, a);\n Z(f, d, c);\n A(g, d, c);\n A(h, b, a);\n\n M(p[0], e, f);\n M(p[1], h, g);\n M(p[2], g, f);\n M(p[3], e, h);\n}\n\nfunction cswap(p, q, b) {\n var i;\n for (i = 0; i < 4; i++) {\n sel25519(p[i], q[i], b);\n }\n}\n\nfunction pack(r, p) {\n var tx = gf(), ty = gf(), zi = gf();\n inv25519(zi, p[2]);\n M(tx, p[0], zi);\n M(ty, p[1], zi);\n pack25519(r, ty);\n r[31] ^= par25519(tx) << 7;\n}\n\nfunction scalarmult(p, q, s) {\n var b, i;\n set25519(p[0], gf0);\n set25519(p[1], gf1);\n set25519(p[2], gf1);\n set25519(p[3], gf0);\n for (i = 255; i >= 0; --i) {\n b = (s[(i/8)|0] >> (i&7)) & 1;\n cswap(p, q, b);\n add(q, p);\n add(p, p);\n cswap(p, q, b);\n }\n}\n\nfunction scalarbase(p, s) {\n var q = [gf(), gf(), gf(), gf()];\n set25519(q[0], X);\n set25519(q[1], Y);\n set25519(q[2], gf1);\n M(q[3], X, Y);\n scalarmult(p, q, s);\n}\n\nfunction crypto_sign_keypair(pk, sk, seeded) {\n var d = new Uint8Array(64);\n var p = [gf(), gf(), gf(), gf()];\n var i;\n\n if (!seeded) randombytes(sk, 32);\n crypto_hash(d, sk, 32);\n d[0] &= 248;\n d[31] &= 127;\n d[31] |= 64;\n\n scalarbase(p, d);\n pack(pk, p);\n\n for (i = 0; i < 32; i++) sk[i+32] = pk[i];\n return 0;\n}\n\nvar L = new Float64Array([0xed, 0xd3, 0xf5, 0x5c, 0x1a, 0x63, 0x12, 0x58, 0xd6, 0x9c, 0xf7, 0xa2, 0xde, 0xf9, 0xde, 0x14, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x10]);\n\nfunction modL(r, x) {\n var carry, i, j, k;\n for (i = 63; i >= 32; --i) {\n carry = 0;\n for (j = i - 32, k = i - 12; j < k; ++j) {\n x[j] += carry - 16 * x[i] * L[j - (i - 32)];\n carry = Math.floor((x[j] + 128) / 256);\n x[j] -= carry * 256;\n }\n x[j] += carry;\n x[i] = 0;\n }\n carry = 0;\n for (j = 0; j < 32; j++) {\n x[j] += carry - (x[31] >> 4) * L[j];\n carry = x[j] >> 8;\n x[j] &= 255;\n }\n for (j = 0; j < 32; j++) x[j] -= carry * L[j];\n for (i = 0; i < 32; i++) {\n x[i+1] += x[i] >> 8;\n r[i] = x[i] & 255;\n }\n}\n\nfunction reduce(r) {\n var x = new Float64Array(64), i;\n for (i = 0; i < 64; i++) x[i] = r[i];\n for (i = 0; i < 64; i++) r[i] = 0;\n modL(r, x);\n}\n\n// Note: difference from C - smlen returned, not passed as argument.\nfunction crypto_sign(sm, m, n, sk) {\n var d = new Uint8Array(64), h = new Uint8Array(64), r = new Uint8Array(64);\n var i, j, x = new Float64Array(64);\n var p = [gf(), gf(), gf(), gf()];\n\n crypto_hash(d, sk, 32);\n d[0] &= 248;\n d[31] &= 127;\n d[31] |= 64;\n\n var smlen = n + 64;\n for (i = 0; i < n; i++) sm[64 + i] = m[i];\n for (i = 0; i < 32; i++) sm[32 + i] = d[32 + i];\n\n crypto_hash(r, sm.subarray(32), n+32);\n reduce(r);\n scalarbase(p, r);\n pack(sm, p);\n\n for (i = 32; i < 64; i++) sm[i] = sk[i];\n crypto_hash(h, sm, n + 64);\n reduce(h);\n\n for (i = 0; i < 64; i++) x[i] = 0;\n for (i = 0; i < 32; i++) x[i] = r[i];\n for (i = 0; i < 32; i++) {\n for (j = 0; j < 32; j++) {\n x[i+j] += h[i] * d[j];\n }\n }\n\n modL(sm.subarray(32), x);\n return smlen;\n}\n\nfunction unpackneg(r, p) {\n var t = gf(), chk = gf(), num = gf(),\n den = gf(), den2 = gf(), den4 = gf(),\n den6 = gf();\n\n set25519(r[2], gf1);\n unpack25519(r[1], p);\n S(num, r[1]);\n M(den, num, D);\n Z(num, num, r[2]);\n A(den, r[2], den);\n\n S(den2, den);\n S(den4, den2);\n M(den6, den4, den2);\n M(t, den6, num);\n M(t, t, den);\n\n pow2523(t, t);\n M(t, t, num);\n M(t, t, den);\n M(t, t, den);\n M(r[0], t, den);\n\n S(chk, r[0]);\n M(chk, chk, den);\n if (neq25519(chk, num)) M(r[0], r[0], I);\n\n S(chk, r[0]);\n M(chk, chk, den);\n if (neq25519(chk, num)) return -1;\n\n if (par25519(r[0]) === (p[31]>>7)) Z(r[0], gf0, r[0]);\n\n M(r[3], r[0], r[1]);\n return 0;\n}\n\nfunction crypto_sign_open(m, sm, n, pk) {\n var i;\n var t = new Uint8Array(32), h = new Uint8Array(64);\n var p = [gf(), gf(), gf(), gf()],\n q = [gf(), gf(), gf(), gf()];\n\n if (n < 64) return -1;\n\n if (unpackneg(q, pk)) return -1;\n\n for (i = 0; i < n; i++) m[i] = sm[i];\n for (i = 0; i < 32; i++) m[i+32] = pk[i];\n crypto_hash(h, m, n);\n reduce(h);\n scalarmult(p, q, h);\n\n scalarbase(q, sm.subarray(32));\n add(p, q);\n pack(t, p);\n\n n -= 64;\n if (crypto_verify_32(sm, 0, t, 0)) {\n for (i = 0; i < n; i++) m[i] = 0;\n return -1;\n }\n\n for (i = 0; i < n; i++) m[i] = sm[i + 64];\n return n;\n}\n\nvar crypto_secretbox_KEYBYTES = 32,\n crypto_secretbox_NONCEBYTES = 24,\n crypto_secretbox_ZEROBYTES = 32,\n crypto_secretbox_BOXZEROBYTES = 16,\n crypto_scalarmult_BYTES = 32,\n crypto_scalarmult_SCALARBYTES = 32,\n crypto_box_PUBLICKEYBYTES = 32,\n crypto_box_SECRETKEYBYTES = 32,\n crypto_box_BEFORENMBYTES = 32,\n crypto_box_NONCEBYTES = crypto_secretbox_NONCEBYTES,\n crypto_box_ZEROBYTES = crypto_secretbox_ZEROBYTES,\n crypto_box_BOXZEROBYTES = crypto_secretbox_BOXZEROBYTES,\n crypto_sign_BYTES = 64,\n crypto_sign_PUBLICKEYBYTES = 32,\n crypto_sign_SECRETKEYBYTES = 64,\n crypto_sign_SEEDBYTES = 32,\n crypto_hash_BYTES = 64;\n\nnacl.lowlevel = {\n crypto_core_hsalsa20: crypto_core_hsalsa20,\n crypto_stream_xor: crypto_stream_xor,\n crypto_stream: crypto_stream,\n crypto_stream_salsa20_xor: crypto_stream_salsa20_xor,\n crypto_stream_salsa20: crypto_stream_salsa20,\n crypto_onetimeauth: crypto_onetimeauth,\n crypto_onetimeauth_verify: crypto_onetimeauth_verify,\n crypto_verify_16: crypto_verify_16,\n crypto_verify_32: crypto_verify_32,\n crypto_secretbox: crypto_secretbox,\n crypto_secretbox_open: crypto_secretbox_open,\n crypto_scalarmult: crypto_scalarmult,\n crypto_scalarmult_base: crypto_scalarmult_base,\n crypto_box_beforenm: crypto_box_beforenm,\n crypto_box_afternm: crypto_box_afternm,\n crypto_box: crypto_box,\n crypto_box_open: crypto_box_open,\n crypto_box_keypair: crypto_box_keypair,\n crypto_hash: crypto_hash,\n crypto_sign: crypto_sign,\n crypto_sign_keypair: crypto_sign_keypair,\n crypto_sign_open: crypto_sign_open,\n\n crypto_secretbox_KEYBYTES: crypto_secretbox_KEYBYTES,\n crypto_secretbox_NONCEBYTES: crypto_secretbox_NONCEBYTES,\n crypto_secretbox_ZEROBYTES: crypto_secretbox_ZEROBYTES,\n crypto_secretbox_BOXZEROBYTES: crypto_secretbox_BOXZEROBYTES,\n crypto_scalarmult_BYTES: crypto_scalarmult_BYTES,\n crypto_scalarmult_SCALARBYTES: crypto_scalarmult_SCALARBYTES,\n crypto_box_PUBLICKEYBYTES: crypto_box_PUBLICKEYBYTES,\n crypto_box_SECRETKEYBYTES: crypto_box_SECRETKEYBYTES,\n crypto_box_BEFORENMBYTES: crypto_box_BEFORENMBYTES,\n crypto_box_NONCEBYTES: crypto_box_NONCEBYTES,\n crypto_box_ZEROBYTES: crypto_box_ZEROBYTES,\n crypto_box_BOXZEROBYTES: crypto_box_BOXZEROBYTES,\n crypto_sign_BYTES: crypto_sign_BYTES,\n crypto_sign_PUBLICKEYBYTES: crypto_sign_PUBLICKEYBYTES,\n crypto_sign_SECRETKEYBYTES: crypto_sign_SECRETKEYBYTES,\n crypto_sign_SEEDBYTES: crypto_sign_SEEDBYTES,\n crypto_hash_BYTES: crypto_hash_BYTES,\n\n gf: gf,\n D: D,\n L: L,\n pack25519: pack25519,\n unpack25519: unpack25519,\n M: M,\n A: A,\n S: S,\n Z: Z,\n pow2523: pow2523,\n add: add,\n set25519: set25519,\n modL: modL,\n scalarmult: scalarmult,\n scalarbase: scalarbase,\n};\n\n/* High-level API */\n\nfunction checkLengths(k, n) {\n if (k.length !== crypto_secretbox_KEYBYTES) throw new Error('bad key size');\n if (n.length !== crypto_secretbox_NONCEBYTES) throw new Error('bad nonce size');\n}\n\nfunction checkBoxLengths(pk, sk) {\n if (pk.length !== crypto_box_PUBLICKEYBYTES) throw new Error('bad public key size');\n if (sk.length !== crypto_box_SECRETKEYBYTES) throw new Error('bad secret key size');\n}\n\nfunction checkArrayTypes() {\n for (var i = 0; i < arguments.length; i++) {\n if (!(arguments[i] instanceof Uint8Array))\n throw new TypeError('unexpected type, use Uint8Array');\n }\n}\n\nfunction cleanup(arr) {\n for (var i = 0; i < arr.length; i++) arr[i] = 0;\n}\n\nnacl.randomBytes = function(n) {\n var b = new Uint8Array(n);\n randombytes(b, n);\n return b;\n};\n\nnacl.secretbox = function(msg, nonce, key) {\n checkArrayTypes(msg, nonce, key);\n checkLengths(key, nonce);\n var m = new Uint8Array(crypto_secretbox_ZEROBYTES + msg.length);\n var c = new Uint8Array(m.length);\n for (var i = 0; i < msg.length; i++) m[i+crypto_secretbox_ZEROBYTES] = msg[i];\n crypto_secretbox(c, m, m.length, nonce, key);\n return c.subarray(crypto_secretbox_BOXZEROBYTES);\n};\n\nnacl.secretbox.open = function(box, nonce, key) {\n checkArrayTypes(box, nonce, key);\n checkLengths(key, nonce);\n var c = new Uint8Array(crypto_secretbox_BOXZEROBYTES + box.length);\n var m = new Uint8Array(c.length);\n for (var i = 0; i < box.length; i++) c[i+crypto_secretbox_BOXZEROBYTES] = box[i];\n if (c.length < 32) return null;\n if (crypto_secretbox_open(m, c, c.length, nonce, key) !== 0) return null;\n return m.subarray(crypto_secretbox_ZEROBYTES);\n};\n\nnacl.secretbox.keyLength = crypto_secretbox_KEYBYTES;\nnacl.secretbox.nonceLength = crypto_secretbox_NONCEBYTES;\nnacl.secretbox.overheadLength = crypto_secretbox_BOXZEROBYTES;\n\nnacl.scalarMult = function(n, p) {\n checkArrayTypes(n, p);\n if (n.length !== crypto_scalarmult_SCALARBYTES) throw new Error('bad n size');\n if (p.length !== crypto_scalarmult_BYTES) throw new Error('bad p size');\n var q = new Uint8Array(crypto_scalarmult_BYTES);\n crypto_scalarmult(q, n, p);\n return q;\n};\n\nnacl.scalarMult.base = function(n) {\n checkArrayTypes(n);\n if (n.length !== crypto_scalarmult_SCALARBYTES) throw new Error('bad n size');\n var q = new Uint8Array(crypto_scalarmult_BYTES);\n crypto_scalarmult_base(q, n);\n return q;\n};\n\nnacl.scalarMult.scalarLength = crypto_scalarmult_SCALARBYTES;\nnacl.scalarMult.groupElementLength = crypto_scalarmult_BYTES;\n\nnacl.box = function(msg, nonce, publicKey, secretKey) {\n var k = nacl.box.before(publicKey, secretKey);\n return nacl.secretbox(msg, nonce, k);\n};\n\nnacl.box.before = function(publicKey, secretKey) {\n checkArrayTypes(publicKey, secretKey);\n checkBoxLengths(publicKey, secretKey);\n var k = new Uint8Array(crypto_box_BEFORENMBYTES);\n crypto_box_beforenm(k, publicKey, secretKey);\n return k;\n};\n\nnacl.box.after = nacl.secretbox;\n\nnacl.box.open = function(msg, nonce, publicKey, secretKey) {\n var k = nacl.box.before(publicKey, secretKey);\n return nacl.secretbox.open(msg, nonce, k);\n};\n\nnacl.box.open.after = nacl.secretbox.open;\n\nnacl.box.keyPair = function() {\n var pk = new Uint8Array(crypto_box_PUBLICKEYBYTES);\n var sk = new Uint8Array(crypto_box_SECRETKEYBYTES);\n crypto_box_keypair(pk, sk);\n return {publicKey: pk, secretKey: sk};\n};\n\nnacl.box.keyPair.fromSecretKey = function(secretKey) {\n checkArrayTypes(secretKey);\n if (secretKey.length !== crypto_box_SECRETKEYBYTES)\n throw new Error('bad secret key size');\n var pk = new Uint8Array(crypto_box_PUBLICKEYBYTES);\n crypto_scalarmult_base(pk, secretKey);\n return {publicKey: pk, secretKey: new Uint8Array(secretKey)};\n};\n\nnacl.box.publicKeyLength = crypto_box_PUBLICKEYBYTES;\nnacl.box.secretKeyLength = crypto_box_SECRETKEYBYTES;\nnacl.box.sharedKeyLength = crypto_box_BEFORENMBYTES;\nnacl.box.nonceLength = crypto_box_NONCEBYTES;\nnacl.box.overheadLength = nacl.secretbox.overheadLength;\n\nnacl.sign = function(msg, secretKey) {\n checkArrayTypes(msg, secretKey);\n if (secretKey.length !== crypto_sign_SECRETKEYBYTES)\n throw new Error('bad secret key size');\n var signedMsg = new Uint8Array(crypto_sign_BYTES+msg.length);\n crypto_sign(signedMsg, msg, msg.length, secretKey);\n return signedMsg;\n};\n\nnacl.sign.open = function(signedMsg, publicKey) {\n checkArrayTypes(signedMsg, publicKey);\n if (publicKey.length !== crypto_sign_PUBLICKEYBYTES)\n throw new Error('bad public key size');\n var tmp = new Uint8Array(signedMsg.length);\n var mlen = crypto_sign_open(tmp, signedMsg, signedMsg.length, publicKey);\n if (mlen < 0) return null;\n var m = new Uint8Array(mlen);\n for (var i = 0; i < m.length; i++) m[i] = tmp[i];\n return m;\n};\n\nnacl.sign.detached = function(msg, secretKey) {\n var signedMsg = nacl.sign(msg, secretKey);\n var sig = new Uint8Array(crypto_sign_BYTES);\n for (var i = 0; i < sig.length; i++) sig[i] = signedMsg[i];\n return sig;\n};\n\nnacl.sign.detached.verify = function(msg, sig, publicKey) {\n checkArrayTypes(msg, sig, publicKey);\n if (sig.length !== crypto_sign_BYTES)\n throw new Error('bad signature size');\n if (publicKey.length !== crypto_sign_PUBLICKEYBYTES)\n throw new Error('bad public key size');\n var sm = new Uint8Array(crypto_sign_BYTES + msg.length);\n var m = new Uint8Array(crypto_sign_BYTES + msg.length);\n var i;\n for (i = 0; i < crypto_sign_BYTES; i++) sm[i] = sig[i];\n for (i = 0; i < msg.length; i++) sm[i+crypto_sign_BYTES] = msg[i];\n return (crypto_sign_open(m, sm, sm.length, publicKey) >= 0);\n};\n\nnacl.sign.keyPair = function() {\n var pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);\n var sk = new Uint8Array(crypto_sign_SECRETKEYBYTES);\n crypto_sign_keypair(pk, sk);\n return {publicKey: pk, secretKey: sk};\n};\n\nnacl.sign.keyPair.fromSecretKey = function(secretKey) {\n checkArrayTypes(secretKey);\n if (secretKey.length !== crypto_sign_SECRETKEYBYTES)\n throw new Error('bad secret key size');\n var pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);\n for (var i = 0; i < pk.length; i++) pk[i] = secretKey[32+i];\n return {publicKey: pk, secretKey: new Uint8Array(secretKey)};\n};\n\nnacl.sign.keyPair.fromSeed = function(seed) {\n checkArrayTypes(seed);\n if (seed.length !== crypto_sign_SEEDBYTES)\n throw new Error('bad seed size');\n var pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);\n var sk = new Uint8Array(crypto_sign_SECRETKEYBYTES);\n for (var i = 0; i < 32; i++) sk[i] = seed[i];\n crypto_sign_keypair(pk, sk, true);\n return {publicKey: pk, secretKey: sk};\n};\n\nnacl.sign.publicKeyLength = crypto_sign_PUBLICKEYBYTES;\nnacl.sign.secretKeyLength = crypto_sign_SECRETKEYBYTES;\nnacl.sign.seedLength = crypto_sign_SEEDBYTES;\nnacl.sign.signatureLength = crypto_sign_BYTES;\n\nnacl.hash = function(msg) {\n checkArrayTypes(msg);\n var h = new Uint8Array(crypto_hash_BYTES);\n crypto_hash(h, msg, msg.length);\n return h;\n};\n\nnacl.hash.hashLength = crypto_hash_BYTES;\n\nnacl.verify = function(x, y) {\n checkArrayTypes(x, y);\n // Zero length arguments are considered not equal.\n if (x.length === 0 || y.length === 0) return false;\n if (x.length !== y.length) return false;\n return (vn(x, 0, y, 0, x.length) === 0) ? true : false;\n};\n\nnacl.setPRNG = function(fn) {\n randombytes = fn;\n};\n\n(function() {\n // Initialize PRNG if environment provides CSPRNG.\n // If not, methods calling randombytes will throw.\n var crypto = typeof self !== 'undefined' ? (self.crypto || self.msCrypto) : null;\n if (crypto && crypto.getRandomValues) {\n // Browsers.\n var QUOTA = 65536;\n nacl.setPRNG(function(x, n) {\n var i, v = new Uint8Array(n);\n for (i = 0; i < n; i += QUOTA) {\n crypto.getRandomValues(v.subarray(i, i + Math.min(n - i, QUOTA)));\n }\n for (i = 0; i < n; i++) x[i] = v[i];\n cleanup(v);\n });\n } else if (typeof require !== 'undefined') {\n // Node.js.\n crypto = require('crypto');\n if (crypto && crypto.randomBytes) {\n nacl.setPRNG(function(x, n) {\n var i, v = crypto.randomBytes(n);\n for (i = 0; i < n; i++) x[i] = v[i];\n cleanup(v);\n });\n }\n }\n})();\n\n})(typeof module !== 'undefined' && module.exports ? module.exports : (self.nacl = self.nacl || {}));\n","module.exports = require('./pusher-with-encryption').default;\n","module.exports = require(\"buffer\");","module.exports = require(\"events\");","'use strict';\n\n/**\n\nStreams in a WebSocket connection\n---------------------------------\n\nWe model a WebSocket as two duplex streams: one stream is for the wire protocol\nover an I/O socket, and the other is for incoming/outgoing messages.\n\n\n +----------+ +---------+ +----------+\n [1] write(chunk) -->| ~~~~~~~~ +----->| parse() +----->| ~~~~~~~~ +--> emit('data') [2]\n | | +----+----+ | |\n | | | | |\n | IO | | [5] | Messages |\n | | V | |\n | | +---------+ | |\n [4] emit('data') <--+ ~~~~~~~~ |<-----+ frame() |<-----+ ~~~~~~~~ |<-- write(chunk) [3]\n +----------+ +---------+ +----------+\n\n\nMessage transfer in each direction is simple: IO receives a byte stream [1] and\nsends this stream for parsing. The parser will periodically emit a complete\nmessage text on the Messages stream [2]. Similarly, when messages are written\nto the Messages stream [3], they are framed using the WebSocket wire format and\nemitted via IO [4].\n\nThere is a feedback loop via [5] since some input from [1] will be things like\nping, pong and close frames. In these cases the protocol responds by emitting\nresponses directly back to [4] rather than emitting messages via [2].\n\nFor the purposes of flow control, we consider the sources of each Readable\nstream to be as follows:\n\n* [2] receives input from [1]\n* [4] receives input from [1] and [3]\n\nThe classes below express the relationships described above without prescribing\nanything about how parse() and frame() work, other than assuming they emit\n'data' events to the IO and Messages streams. They will work with any protocol\ndriver having these two methods.\n**/\n\n\nvar Stream = require('stream').Stream,\n util = require('util');\n\n\nvar IO = function(driver) {\n this.readable = this.writable = true;\n this._paused = false;\n this._driver = driver;\n};\nutil.inherits(IO, Stream);\n\n// The IO pause() and resume() methods will be called when the socket we are\n// piping to gets backed up and drains. Since IO output [4] comes from IO input\n// [1] and Messages input [3], we need to tell both of those to return false\n// from write() when this stream is paused.\n\nIO.prototype.pause = function() {\n this._paused = true;\n this._driver.messages._paused = true;\n};\n\nIO.prototype.resume = function() {\n this._paused = false;\n this.emit('drain');\n\n var messages = this._driver.messages;\n messages._paused = false;\n messages.emit('drain');\n};\n\n// When we receive input from a socket, send it to the parser and tell the\n// source whether to back off.\nIO.prototype.write = function(chunk) {\n if (!this.writable) return false;\n this._driver.parse(chunk);\n return !this._paused;\n};\n\n// The IO end() method will be called when the socket piping into it emits\n// 'close' or 'end', i.e. the socket is closed. In this situation the Messages\n// stream will not emit any more data so we emit 'end'.\nIO.prototype.end = function(chunk) {\n if (!this.writable) return;\n if (chunk !== undefined) this.write(chunk);\n this.writable = false;\n\n var messages = this._driver.messages;\n if (messages.readable) {\n messages.readable = messages.writable = false;\n messages.emit('end');\n }\n};\n\nIO.prototype.destroy = function() {\n this.end();\n};\n\n\nvar Messages = function(driver) {\n this.readable = this.writable = true;\n this._paused = false;\n this._driver = driver;\n};\nutil.inherits(Messages, Stream);\n\n// The Messages pause() and resume() methods will be called when the app that's\n// processing the messages gets backed up and drains. If we're emitting\n// messages too fast we should tell the source to slow down. Message output [2]\n// comes from IO input [1].\n\nMessages.prototype.pause = function() {\n this._driver.io._paused = true;\n};\n\nMessages.prototype.resume = function() {\n this._driver.io._paused = false;\n this._driver.io.emit('drain');\n};\n\n// When we receive messages from the user, send them to the formatter and tell\n// the source whether to back off.\nMessages.prototype.write = function(message) {\n if (!this.writable) return false;\n if (typeof message === 'string') this._driver.text(message);\n else this._driver.binary(message);\n return !this._paused;\n};\n\n// The Messages end() method will be called when a stream piping into it emits\n// 'end'. Many streams may be piped into the WebSocket and one of them ending\n// does not mean the whole socket is done, so just process the input and move\n// on leaving the socket open.\nMessages.prototype.end = function(message) {\n if (message !== undefined) this.write(message);\n};\n\nMessages.prototype.destroy = function() {};\n\n\nexports.IO = IO;\nexports.Messages = Messages;\n","'use strict';\n\nvar Buffer = require('safe-buffer').Buffer;\n\nvar StreamReader = function() {\n this._queue = [];\n this._queueSize = 0;\n this._offset = 0;\n};\n\nStreamReader.prototype.put = function(buffer) {\n if (!buffer || buffer.length === 0) return;\n if (!Buffer.isBuffer(buffer)) buffer = Buffer.from(buffer);\n this._queue.push(buffer);\n this._queueSize += buffer.length;\n};\n\nStreamReader.prototype.read = function(length) {\n if (length > this._queueSize) return null;\n if (length === 0) return Buffer.alloc(0);\n\n this._queueSize -= length;\n\n var queue = this._queue,\n remain = length,\n first = queue[0],\n buffers, buffer;\n\n if (first.length >= length) {\n if (first.length === length) {\n return queue.shift();\n } else {\n buffer = first.slice(0, length);\n queue[0] = first.slice(length);\n return buffer;\n }\n }\n\n for (var i = 0, n = queue.length; i < n; i++) {\n if (remain < queue[i].length) break;\n remain -= queue[i].length;\n }\n buffers = queue.splice(0, i);\n\n if (remain > 0 && queue.length > 0) {\n buffers.push(queue[0].slice(0, remain));\n queue[0] = queue[0].slice(remain);\n }\n return Buffer.concat(buffers, length);\n};\n\nStreamReader.prototype.eachByte = function(callback, context) {\n var buffer, n, index;\n\n while (this._queue.length > 0) {\n buffer = this._queue[0];\n n = buffer.length;\n\n while (this._offset < n) {\n index = this._offset;\n this._offset += 1;\n callback.call(context, buffer[index]);\n }\n this._offset = 0;\n this._queue.shift();\n }\n};\n\nmodule.exports = StreamReader;\n","'use strict';\n\nvar Buffer = require('safe-buffer').Buffer,\n crypto = require('crypto'),\n url = require('url'),\n util = require('util'),\n HttpParser = require('../http_parser'),\n Base = require('./base'),\n Hybi = require('./hybi'),\n Proxy = require('./proxy');\n\nvar Client = function(_url, options) {\n this.version = 'hybi-' + Hybi.VERSION;\n Hybi.call(this, null, _url, options);\n\n this.readyState = -1;\n this._key = Client.generateKey();\n this._accept = Hybi.generateAccept(this._key);\n this._http = new HttpParser('response');\n\n var uri = url.parse(this.url),\n auth = uri.auth && Buffer.from(uri.auth, 'utf8').toString('base64');\n\n if (this.VALID_PROTOCOLS.indexOf(uri.protocol) < 0)\n throw new Error(this.url + ' is not a valid WebSocket URL');\n\n this._pathname = (uri.pathname || '/') + (uri.search || '');\n\n this._headers.set('Host', uri.host);\n this._headers.set('Upgrade', 'websocket');\n this._headers.set('Connection', 'Upgrade');\n this._headers.set('Sec-WebSocket-Key', this._key);\n this._headers.set('Sec-WebSocket-Version', Hybi.VERSION);\n\n if (this._protocols.length > 0)\n this._headers.set('Sec-WebSocket-Protocol', this._protocols.join(', '));\n\n if (auth)\n this._headers.set('Authorization', 'Basic ' + auth);\n};\nutil.inherits(Client, Hybi);\n\nClient.generateKey = function() {\n return crypto.randomBytes(16).toString('base64');\n};\n\nvar instance = {\n VALID_PROTOCOLS: ['ws:', 'wss:'],\n\n proxy: function(origin, options) {\n return new Proxy(this, origin, options);\n },\n\n start: function() {\n if (this.readyState !== -1) return false;\n this._write(this._handshakeRequest());\n this.readyState = 0;\n return true;\n },\n\n parse: function(chunk) {\n if (this.readyState === 3) return;\n if (this.readyState > 0) return Hybi.prototype.parse.call(this, chunk);\n\n this._http.parse(chunk);\n if (!this._http.isComplete()) return;\n\n this._validateHandshake();\n if (this.readyState === 3) return;\n\n this._open();\n this.parse(this._http.body);\n },\n\n _handshakeRequest: function() {\n var extensions = this._extensions.generateOffer();\n if (extensions)\n this._headers.set('Sec-WebSocket-Extensions', extensions);\n\n var start = 'GET ' + this._pathname + ' HTTP/1.1',\n headers = [start, this._headers.toString(), ''];\n\n return Buffer.from(headers.join('\\r\\n'), 'utf8');\n },\n\n _failHandshake: function(message) {\n message = 'Error during WebSocket handshake: ' + message;\n this.readyState = 3;\n this.emit('error', new Error(message));\n this.emit('close', new Base.CloseEvent(this.ERRORS.protocol_error, message));\n },\n\n _validateHandshake: function() {\n this.statusCode = this._http.statusCode;\n this.headers = this._http.headers;\n\n if (this._http.error)\n return this._failHandshake(this._http.error.message);\n\n if (this._http.statusCode !== 101)\n return this._failHandshake('Unexpected response code: ' + this._http.statusCode);\n\n var headers = this._http.headers,\n upgrade = headers['upgrade'] || '',\n connection = headers['connection'] || '',\n accept = headers['sec-websocket-accept'] || '',\n protocol = headers['sec-websocket-protocol'] || '';\n\n if (upgrade === '')\n return this._failHandshake(\"'Upgrade' header is missing\");\n if (upgrade.toLowerCase() !== 'websocket')\n return this._failHandshake(\"'Upgrade' header value is not 'WebSocket'\");\n\n if (connection === '')\n return this._failHandshake(\"'Connection' header is missing\");\n if (connection.toLowerCase() !== 'upgrade')\n return this._failHandshake(\"'Connection' header value is not 'Upgrade'\");\n\n if (accept !== this._accept)\n return this._failHandshake('Sec-WebSocket-Accept mismatch');\n\n this.protocol = null;\n\n if (protocol !== '') {\n if (this._protocols.indexOf(protocol) < 0)\n return this._failHandshake('Sec-WebSocket-Protocol mismatch');\n else\n this.protocol = protocol;\n }\n\n try {\n this._extensions.activate(this.headers['sec-websocket-extensions']);\n } catch (e) {\n return this._failHandshake(e.message);\n }\n }\n};\n\nfor (var key in instance)\n Client.prototype[key] = instance[key];\n\nmodule.exports = Client;\n","/*jshint node:true */\n\nvar assert = require('assert');\n\nexports.HTTPParser = HTTPParser;\nfunction HTTPParser(type) {\n assert.ok(type === HTTPParser.REQUEST || type === HTTPParser.RESPONSE || type === undefined);\n if (type === undefined) {\n // Node v12+\n } else {\n this.initialize(type);\n }\n this.maxHeaderSize=HTTPParser.maxHeaderSize\n}\nHTTPParser.prototype.initialize = function (type, async_resource) {\n assert.ok(type === HTTPParser.REQUEST || type === HTTPParser.RESPONSE);\n this.type = type;\n this.state = type + '_LINE';\n this.info = {\n headers: [],\n upgrade: false\n };\n this.trailers = [];\n this.line = '';\n this.isChunked = false;\n this.connection = '';\n this.headerSize = 0; // for preventing too big headers\n this.body_bytes = null;\n this.isUserCall = false;\n this.hadError = false;\n};\n\nHTTPParser.encoding = 'ascii';\nHTTPParser.maxHeaderSize = 80 * 1024; // maxHeaderSize (in bytes) is configurable, but 80kb by default;\nHTTPParser.REQUEST = 'REQUEST';\nHTTPParser.RESPONSE = 'RESPONSE';\n\n// Note: *not* starting with kOnHeaders=0 line the Node parser, because any\n// newly added constants (kOnTimeout in Node v12.19.0) will overwrite 0!\nvar kOnHeaders = HTTPParser.kOnHeaders = 1;\nvar kOnHeadersComplete = HTTPParser.kOnHeadersComplete = 2;\nvar kOnBody = HTTPParser.kOnBody = 3;\nvar kOnMessageComplete = HTTPParser.kOnMessageComplete = 4;\n\n// Some handler stubs, needed for compatibility\nHTTPParser.prototype[kOnHeaders] =\nHTTPParser.prototype[kOnHeadersComplete] =\nHTTPParser.prototype[kOnBody] =\nHTTPParser.prototype[kOnMessageComplete] = function () {};\n\nvar compatMode0_12 = true;\nObject.defineProperty(HTTPParser, 'kOnExecute', {\n get: function () {\n // hack for backward compatibility\n compatMode0_12 = false;\n return 99;\n }\n });\n\nvar methods = exports.methods = HTTPParser.methods = [\n 'DELETE',\n 'GET',\n 'HEAD',\n 'POST',\n 'PUT',\n 'CONNECT',\n 'OPTIONS',\n 'TRACE',\n 'COPY',\n 'LOCK',\n 'MKCOL',\n 'MOVE',\n 'PROPFIND',\n 'PROPPATCH',\n 'SEARCH',\n 'UNLOCK',\n 'BIND',\n 'REBIND',\n 'UNBIND',\n 'ACL',\n 'REPORT',\n 'MKACTIVITY',\n 'CHECKOUT',\n 'MERGE',\n 'M-SEARCH',\n 'NOTIFY',\n 'SUBSCRIBE',\n 'UNSUBSCRIBE',\n 'PATCH',\n 'PURGE',\n 'MKCALENDAR',\n 'LINK',\n 'UNLINK',\n 'SOURCE',\n];\nvar method_connect = methods.indexOf('CONNECT');\nHTTPParser.prototype.reinitialize = HTTPParser;\nHTTPParser.prototype.close =\nHTTPParser.prototype.pause =\nHTTPParser.prototype.resume =\nHTTPParser.prototype.free = function () {};\nHTTPParser.prototype._compatMode0_11 = false;\nHTTPParser.prototype.getAsyncId = function() { return 0; };\n\nvar headerState = {\n REQUEST_LINE: true,\n RESPONSE_LINE: true,\n HEADER: true\n};\nHTTPParser.prototype.execute = function (chunk, start, length) {\n if (!(this instanceof HTTPParser)) {\n throw new TypeError('not a HTTPParser');\n }\n\n // backward compat to node < 0.11.4\n // Note: the start and length params were removed in newer version\n start = start || 0;\n length = typeof length === 'number' ? length : chunk.length;\n\n this.chunk = chunk;\n this.offset = start;\n var end = this.end = start + length;\n try {\n while (this.offset < end) {\n if (this[this.state]()) {\n break;\n }\n }\n } catch (err) {\n if (this.isUserCall) {\n throw err;\n }\n this.hadError = true;\n return err;\n }\n this.chunk = null;\n length = this.offset - start;\n if (headerState[this.state]) {\n this.headerSize += length;\n if (this.headerSize > (this.maxHeaderSize||HTTPParser.maxHeaderSize)) {\n return new Error('max header size exceeded');\n }\n }\n return length;\n};\n\nvar stateFinishAllowed = {\n REQUEST_LINE: true,\n RESPONSE_LINE: true,\n BODY_RAW: true\n};\nHTTPParser.prototype.finish = function () {\n if (this.hadError) {\n return;\n }\n if (!stateFinishAllowed[this.state]) {\n return new Error('invalid state for EOF');\n }\n if (this.state === 'BODY_RAW') {\n this.userCall()(this[kOnMessageComplete]());\n }\n};\n\n// These three methods are used for an internal speed optimization, and it also\n// works if theses are noops. Basically consume() asks us to read the bytes\n// ourselves, but if we don't do it we get them through execute().\nHTTPParser.prototype.consume =\nHTTPParser.prototype.unconsume =\nHTTPParser.prototype.getCurrentBuffer = function () {};\n\n//For correct error handling - see HTTPParser#execute\n//Usage: this.userCall()(userFunction('arg'));\nHTTPParser.prototype.userCall = function () {\n this.isUserCall = true;\n var self = this;\n return function (ret) {\n self.isUserCall = false;\n return ret;\n };\n};\n\nHTTPParser.prototype.nextRequest = function () {\n this.userCall()(this[kOnMessageComplete]());\n this.reinitialize(this.type);\n};\n\nHTTPParser.prototype.consumeLine = function () {\n var end = this.end,\n chunk = this.chunk;\n for (var i = this.offset; i < end; i++) {\n if (chunk[i] === 0x0a) { // \\n\n var line = this.line + chunk.toString(HTTPParser.encoding, this.offset, i);\n if (line.charAt(line.length - 1) === '\\r') {\n line = line.substr(0, line.length - 1);\n }\n this.line = '';\n this.offset = i + 1;\n return line;\n }\n }\n //line split over multiple chunks\n this.line += chunk.toString(HTTPParser.encoding, this.offset, this.end);\n this.offset = this.end;\n};\n\nvar headerExp = /^([^: \\t]+):[ \\t]*((?:.*[^ \\t])|)/;\nvar headerContinueExp = /^[ \\t]+(.*[^ \\t])/;\nHTTPParser.prototype.parseHeader = function (line, headers) {\n if (line.indexOf('\\r') !== -1) {\n throw parseErrorCode('HPE_LF_EXPECTED');\n }\n\n var match = headerExp.exec(line);\n var k = match && match[1];\n if (k) { // skip empty string (malformed header)\n headers.push(k);\n headers.push(match[2]);\n } else {\n var matchContinue = headerContinueExp.exec(line);\n if (matchContinue && headers.length) {\n if (headers[headers.length - 1]) {\n headers[headers.length - 1] += ' ';\n }\n headers[headers.length - 1] += matchContinue[1];\n }\n }\n};\n\nvar requestExp = /^([A-Z-]+) ([^ ]+) HTTP\\/(\\d)\\.(\\d)$/;\nHTTPParser.prototype.REQUEST_LINE = function () {\n var line = this.consumeLine();\n if (!line) {\n return;\n }\n var match = requestExp.exec(line);\n if (match === null) {\n throw parseErrorCode('HPE_INVALID_CONSTANT');\n }\n this.info.method = this._compatMode0_11 ? match[1] : methods.indexOf(match[1]);\n if (this.info.method === -1) {\n throw new Error('invalid request method');\n }\n this.info.url = match[2];\n this.info.versionMajor = +match[3];\n this.info.versionMinor = +match[4];\n this.body_bytes = 0;\n this.state = 'HEADER';\n};\n\nvar responseExp = /^HTTP\\/(\\d)\\.(\\d) (\\d{3}) ?(.*)$/;\nHTTPParser.prototype.RESPONSE_LINE = function () {\n var line = this.consumeLine();\n if (!line) {\n return;\n }\n var match = responseExp.exec(line);\n if (match === null) {\n throw parseErrorCode('HPE_INVALID_CONSTANT');\n }\n this.info.versionMajor = +match[1];\n this.info.versionMinor = +match[2];\n var statusCode = this.info.statusCode = +match[3];\n this.info.statusMessage = match[4];\n // Implied zero length.\n if ((statusCode / 100 | 0) === 1 || statusCode === 204 || statusCode === 304) {\n this.body_bytes = 0;\n }\n this.state = 'HEADER';\n};\n\nHTTPParser.prototype.shouldKeepAlive = function () {\n if (this.info.versionMajor > 0 && this.info.versionMinor > 0) {\n if (this.connection.indexOf('close') !== -1) {\n return false;\n }\n } else if (this.connection.indexOf('keep-alive') === -1) {\n return false;\n }\n if (this.body_bytes !== null || this.isChunked) { // || skipBody\n return true;\n }\n return false;\n};\n\nHTTPParser.prototype.HEADER = function () {\n var line = this.consumeLine();\n if (line === undefined) {\n return;\n }\n var info = this.info;\n if (line) {\n this.parseHeader(line, info.headers);\n } else {\n var headers = info.headers;\n var hasContentLength = false;\n var currentContentLengthValue;\n var hasUpgradeHeader = false;\n for (var i = 0; i < headers.length; i += 2) {\n switch (headers[i].toLowerCase()) {\n case 'transfer-encoding':\n this.isChunked = headers[i + 1].toLowerCase() === 'chunked';\n break;\n case 'content-length':\n currentContentLengthValue = +headers[i + 1];\n if (hasContentLength) {\n // Fix duplicate Content-Length header with same values.\n // Throw error only if values are different.\n // Known issues:\n // https://github.com/request/request/issues/2091#issuecomment-328715113\n // https://github.com/nodejs/node/issues/6517#issuecomment-216263771\n if (currentContentLengthValue !== this.body_bytes) {\n throw parseErrorCode('HPE_UNEXPECTED_CONTENT_LENGTH');\n }\n } else {\n hasContentLength = true;\n this.body_bytes = currentContentLengthValue;\n }\n break;\n case 'connection':\n this.connection += headers[i + 1].toLowerCase();\n break;\n case 'upgrade':\n hasUpgradeHeader = true;\n break;\n }\n }\n\n // if both isChunked and hasContentLength, isChunked wins\n // This is required so the body is parsed using the chunked method, and matches\n // Chrome's behavior. We could, maybe, ignore them both (would get chunked\n // encoding into the body), and/or disable shouldKeepAlive to be more\n // resilient.\n if (this.isChunked && hasContentLength) {\n hasContentLength = false;\n this.body_bytes = null;\n }\n\n // Logic from https://github.com/nodejs/http-parser/blob/921d5585515a153fa00e411cf144280c59b41f90/http_parser.c#L1727-L1737\n // \"For responses, \"Upgrade: foo\" and \"Connection: upgrade\" are\n // mandatory only when it is a 101 Switching Protocols response,\n // otherwise it is purely informational, to announce support.\n if (hasUpgradeHeader && this.connection.indexOf('upgrade') != -1) {\n info.upgrade = this.type === HTTPParser.REQUEST || info.statusCode === 101;\n } else {\n info.upgrade = info.method === method_connect;\n }\n\n if (this.isChunked && info.upgrade) {\n this.isChunked = false;\n }\n\n info.shouldKeepAlive = this.shouldKeepAlive();\n //problem which also exists in original node: we should know skipBody before calling onHeadersComplete\n var skipBody;\n if (compatMode0_12) {\n skipBody = this.userCall()(this[kOnHeadersComplete](info));\n } else {\n skipBody = this.userCall()(this[kOnHeadersComplete](info.versionMajor,\n info.versionMinor, info.headers, info.method, info.url, info.statusCode,\n info.statusMessage, info.upgrade, info.shouldKeepAlive));\n }\n if (skipBody === 2) {\n this.nextRequest();\n return true;\n } else if (this.isChunked && !skipBody) {\n this.state = 'BODY_CHUNKHEAD';\n } else if (skipBody || this.body_bytes === 0) {\n this.nextRequest();\n // For older versions of node (v6.x and older?), that return skipBody=1 or skipBody=true,\n // need this \"return true;\" if it's an upgrade request.\n return info.upgrade;\n } else if (this.body_bytes === null) {\n this.state = 'BODY_RAW';\n } else {\n this.state = 'BODY_SIZED';\n }\n }\n};\n\nHTTPParser.prototype.BODY_CHUNKHEAD = function () {\n var line = this.consumeLine();\n if (line === undefined) {\n return;\n }\n this.body_bytes = parseInt(line, 16);\n if (!this.body_bytes) {\n this.state = 'BODY_CHUNKTRAILERS';\n } else {\n this.state = 'BODY_CHUNK';\n }\n};\n\nHTTPParser.prototype.BODY_CHUNK = function () {\n var length = Math.min(this.end - this.offset, this.body_bytes);\n this.userCall()(this[kOnBody](this.chunk, this.offset, length));\n this.offset += length;\n this.body_bytes -= length;\n if (!this.body_bytes) {\n this.state = 'BODY_CHUNKEMPTYLINE';\n }\n};\n\nHTTPParser.prototype.BODY_CHUNKEMPTYLINE = function () {\n var line = this.consumeLine();\n if (line === undefined) {\n return;\n }\n assert.equal(line, '');\n this.state = 'BODY_CHUNKHEAD';\n};\n\nHTTPParser.prototype.BODY_CHUNKTRAILERS = function () {\n var line = this.consumeLine();\n if (line === undefined) {\n return;\n }\n if (line) {\n this.parseHeader(line, this.trailers);\n } else {\n if (this.trailers.length) {\n this.userCall()(this[kOnHeaders](this.trailers, ''));\n }\n this.nextRequest();\n }\n};\n\nHTTPParser.prototype.BODY_RAW = function () {\n var length = this.end - this.offset;\n this.userCall()(this[kOnBody](this.chunk, this.offset, length));\n this.offset = this.end;\n};\n\nHTTPParser.prototype.BODY_SIZED = function () {\n var length = Math.min(this.end - this.offset, this.body_bytes);\n this.userCall()(this[kOnBody](this.chunk, this.offset, length));\n this.offset += length;\n this.body_bytes -= length;\n if (!this.body_bytes) {\n this.nextRequest();\n }\n};\n\n// backward compat to node < 0.11.6\n['Headers', 'HeadersComplete', 'Body', 'MessageComplete'].forEach(function (name) {\n var k = HTTPParser['kOn' + name];\n Object.defineProperty(HTTPParser.prototype, 'on' + name, {\n get: function () {\n return this[k];\n },\n set: function (to) {\n // hack for backward compatibility\n this._compatMode0_11 = true;\n method_connect = 'CONNECT';\n return (this[k] = to);\n }\n });\n});\n\nfunction parseErrorCode(code) {\n var err = new Error('Parse Error');\n err.code = code;\n return err;\n}\n","module.exports = require(\"assert\");","'use strict';\n\nvar Parser = require('./parser'),\n Pipeline = require('./pipeline');\n\nvar Extensions = function() {\n this._rsv1 = this._rsv2 = this._rsv3 = null;\n\n this._byName = {};\n this._inOrder = [];\n this._sessions = [];\n this._index = {};\n};\n\nExtensions.MESSAGE_OPCODES = [1, 2];\n\nvar instance = {\n add: function(ext) {\n if (typeof ext.name !== 'string') throw new TypeError('extension.name must be a string');\n if (ext.type !== 'permessage') throw new TypeError('extension.type must be \"permessage\"');\n\n if (typeof ext.rsv1 !== 'boolean') throw new TypeError('extension.rsv1 must be true or false');\n if (typeof ext.rsv2 !== 'boolean') throw new TypeError('extension.rsv2 must be true or false');\n if (typeof ext.rsv3 !== 'boolean') throw new TypeError('extension.rsv3 must be true or false');\n\n if (this._byName.hasOwnProperty(ext.name))\n throw new TypeError('An extension with name \"' + ext.name + '\" is already registered');\n\n this._byName[ext.name] = ext;\n this._inOrder.push(ext);\n },\n\n generateOffer: function() {\n var sessions = [],\n offer = [],\n index = {};\n\n this._inOrder.forEach(function(ext) {\n var session = ext.createClientSession();\n if (!session) return;\n\n var record = [ext, session];\n sessions.push(record);\n index[ext.name] = record;\n\n var offers = session.generateOffer();\n offers = offers ? [].concat(offers) : [];\n\n offers.forEach(function(off) {\n offer.push(Parser.serializeParams(ext.name, off));\n }, this);\n }, this);\n\n this._sessions = sessions;\n this._index = index;\n\n return offer.length > 0 ? offer.join(', ') : null;\n },\n\n activate: function(header) {\n var responses = Parser.parseHeader(header),\n sessions = [];\n\n responses.eachOffer(function(name, params) {\n var record = this._index[name];\n\n if (!record)\n throw new Error('Server sent an extension response for unknown extension \"' + name + '\"');\n\n var ext = record[0],\n session = record[1],\n reserved = this._reserved(ext);\n\n if (reserved)\n throw new Error('Server sent two extension responses that use the RSV' +\n reserved[0] + ' bit: \"' +\n reserved[1] + '\" and \"' + ext.name + '\"');\n\n if (session.activate(params) !== true)\n throw new Error('Server sent unacceptable extension parameters: ' +\n Parser.serializeParams(name, params));\n\n this._reserve(ext);\n sessions.push(record);\n }, this);\n\n this._sessions = sessions;\n this._pipeline = new Pipeline(sessions);\n },\n\n generateResponse: function(header) {\n var sessions = [],\n response = [],\n offers = Parser.parseHeader(header);\n\n this._inOrder.forEach(function(ext) {\n var offer = offers.byName(ext.name);\n if (offer.length === 0 || this._reserved(ext)) return;\n\n var session = ext.createServerSession(offer);\n if (!session) return;\n\n this._reserve(ext);\n sessions.push([ext, session]);\n response.push(Parser.serializeParams(ext.name, session.generateResponse()));\n }, this);\n\n this._sessions = sessions;\n this._pipeline = new Pipeline(sessions);\n\n return response.length > 0 ? response.join(', ') : null;\n },\n\n validFrameRsv: function(frame) {\n var allowed = { rsv1: false, rsv2: false, rsv3: false },\n ext;\n\n if (Extensions.MESSAGE_OPCODES.indexOf(frame.opcode) >= 0) {\n for (var i = 0, n = this._sessions.length; i < n; i++) {\n ext = this._sessions[i][0];\n allowed.rsv1 = allowed.rsv1 || ext.rsv1;\n allowed.rsv2 = allowed.rsv2 || ext.rsv2;\n allowed.rsv3 = allowed.rsv3 || ext.rsv3;\n }\n }\n\n return (allowed.rsv1 || !frame.rsv1) &&\n (allowed.rsv2 || !frame.rsv2) &&\n (allowed.rsv3 || !frame.rsv3);\n },\n\n processIncomingMessage: function(message, callback, context) {\n this._pipeline.processIncomingMessage(message, callback, context);\n },\n\n processOutgoingMessage: function(message, callback, context) {\n this._pipeline.processOutgoingMessage(message, callback, context);\n },\n\n close: function(callback, context) {\n if (!this._pipeline) return callback.call(context);\n this._pipeline.close(callback, context);\n },\n\n _reserve: function(ext) {\n this._rsv1 = this._rsv1 || (ext.rsv1 && ext.name);\n this._rsv2 = this._rsv2 || (ext.rsv2 && ext.name);\n this._rsv3 = this._rsv3 || (ext.rsv3 && ext.name);\n },\n\n _reserved: function(ext) {\n if (this._rsv1 && ext.rsv1) return [1, this._rsv1];\n if (this._rsv2 && ext.rsv2) return [2, this._rsv2];\n if (this._rsv3 && ext.rsv3) return [3, this._rsv3];\n return false;\n }\n};\n\nfor (var key in instance)\n Extensions.prototype[key] = instance[key];\n\nmodule.exports = Extensions;\n","'use strict';\n\nvar TOKEN = /([!#\\$%&'\\*\\+\\-\\.\\^_`\\|~0-9A-Za-z]+)/,\n NOTOKEN = /([^!#\\$%&'\\*\\+\\-\\.\\^_`\\|~0-9A-Za-z])/g,\n QUOTED = /\"((?:\\\\[\\x00-\\x7f]|[^\\x00-\\x08\\x0a-\\x1f\\x7f\"\\\\])*)\"/,\n PARAM = new RegExp(TOKEN.source + '(?:=(?:' + TOKEN.source + '|' + QUOTED.source + '))?'),\n EXT = new RegExp(TOKEN.source + '(?: *; *' + PARAM.source + ')*', 'g'),\n EXT_LIST = new RegExp('^' + EXT.source + '(?: *, *' + EXT.source + ')*$'),\n NUMBER = /^-?(0|[1-9][0-9]*)(\\.[0-9]+)?$/;\n\nvar hasOwnProperty = Object.prototype.hasOwnProperty;\n\nvar Parser = {\n parseHeader: function(header) {\n var offers = new Offers();\n if (header === '' || header === undefined) return offers;\n\n if (!EXT_LIST.test(header))\n throw new SyntaxError('Invalid Sec-WebSocket-Extensions header: ' + header);\n\n var values = header.match(EXT);\n\n values.forEach(function(value) {\n var params = value.match(new RegExp(PARAM.source, 'g')),\n name = params.shift(),\n offer = {};\n\n params.forEach(function(param) {\n var args = param.match(PARAM), key = args[1], data;\n\n if (args[2] !== undefined) {\n data = args[2];\n } else if (args[3] !== undefined) {\n data = args[3].replace(/\\\\/g, '');\n } else {\n data = true;\n }\n if (NUMBER.test(data)) data = parseFloat(data);\n\n if (hasOwnProperty.call(offer, key)) {\n offer[key] = [].concat(offer[key]);\n offer[key].push(data);\n } else {\n offer[key] = data;\n }\n }, this);\n offers.push(name, offer);\n }, this);\n\n return offers;\n },\n\n serializeParams: function(name, params) {\n var values = [];\n\n var print = function(key, value) {\n if (value instanceof Array) {\n value.forEach(function(v) { print(key, v) });\n } else if (value === true) {\n values.push(key);\n } else if (typeof value === 'number') {\n values.push(key + '=' + value);\n } else if (NOTOKEN.test(value)) {\n values.push(key + '=\"' + value.replace(/\"/g, '\\\\\"') + '\"');\n } else {\n values.push(key + '=' + value);\n }\n };\n\n for (var key in params) print(key, params[key]);\n\n return [name].concat(values).join('; ');\n }\n};\n\nvar Offers = function() {\n this._byName = {};\n this._inOrder = [];\n};\n\nOffers.prototype.push = function(name, params) {\n if (!hasOwnProperty.call(this._byName, name))\n this._byName[name] = [];\n\n this._byName[name].push(params);\n this._inOrder.push({ name: name, params: params });\n};\n\nOffers.prototype.eachOffer = function(callback, context) {\n var list = this._inOrder;\n for (var i = 0, n = list.length; i < n; i++)\n callback.call(context, list[i].name, list[i].params);\n};\n\nOffers.prototype.byName = function(name) {\n return this._byName[name] || [];\n};\n\nOffers.prototype.toArray = function() {\n return this._inOrder.slice();\n};\n\nmodule.exports = Parser;\n","'use strict';\n\nvar Cell = require('./cell'),\n Pledge = require('./pledge');\n\nvar Pipeline = function(sessions) {\n this._cells = sessions.map(function(session) { return new Cell(session) });\n this._stopped = { incoming: false, outgoing: false };\n};\n\nPipeline.prototype.processIncomingMessage = function(message, callback, context) {\n if (this._stopped.incoming) return;\n this._loop('incoming', this._cells.length - 1, -1, -1, message, callback, context);\n};\n\nPipeline.prototype.processOutgoingMessage = function(message, callback, context) {\n if (this._stopped.outgoing) return;\n this._loop('outgoing', 0, this._cells.length, 1, message, callback, context);\n};\n\nPipeline.prototype.close = function(callback, context) {\n this._stopped = { incoming: true, outgoing: true };\n\n var closed = this._cells.map(function(a) { return a.close() });\n if (callback)\n Pledge.all(closed).then(function() { callback.call(context) });\n};\n\nPipeline.prototype._loop = function(direction, start, end, step, message, callback, context) {\n var cells = this._cells,\n n = cells.length,\n self = this;\n\n while (n--) cells[n].pending(direction);\n\n var pipe = function(index, error, msg) {\n if (index === end) return callback.call(context, error, msg);\n\n cells[index][direction](error, msg, function(err, m) {\n if (err) self._stopped[direction] = true;\n pipe(index + step, err, m);\n });\n };\n pipe(start, null, message);\n};\n\nmodule.exports = Pipeline;\n","'use strict';\n\nvar Functor = require('./functor'),\n Pledge = require('./pledge');\n\nvar Cell = function(tuple) {\n this._ext = tuple[0];\n this._session = tuple[1];\n\n this._functors = {\n incoming: new Functor(this._session, 'processIncomingMessage'),\n outgoing: new Functor(this._session, 'processOutgoingMessage')\n };\n};\n\nCell.prototype.pending = function(direction) {\n var functor = this._functors[direction];\n if (!functor._stopped) functor.pending += 1;\n};\n\nCell.prototype.incoming = function(error, message, callback, context) {\n this._exec('incoming', error, message, callback, context);\n};\n\nCell.prototype.outgoing = function(error, message, callback, context) {\n this._exec('outgoing', error, message, callback, context);\n};\n\nCell.prototype.close = function() {\n this._closed = this._closed || new Pledge();\n this._doClose();\n return this._closed;\n};\n\nCell.prototype._exec = function(direction, error, message, callback, context) {\n this._functors[direction].call(error, message, function(err, msg) {\n if (err) err.message = this._ext.name + ': ' + err.message;\n callback.call(context, err, msg);\n this._doClose();\n }, this);\n};\n\nCell.prototype._doClose = function() {\n var fin = this._functors.incoming,\n fout = this._functors.outgoing;\n\n if (!this._closed || fin.pending + fout.pending !== 0) return;\n if (this._session) this._session.close();\n this._session = null;\n this._closed.done();\n};\n\nmodule.exports = Cell;\n","'use strict';\n\nvar RingBuffer = require('./ring_buffer');\n\nvar Functor = function(session, method) {\n this._session = session;\n this._method = method;\n this._queue = new RingBuffer(Functor.QUEUE_SIZE);\n this._stopped = false;\n this.pending = 0;\n};\n\nFunctor.QUEUE_SIZE = 8;\n\nFunctor.prototype.call = function(error, message, callback, context) {\n if (this._stopped) return;\n\n var record = { error: error, message: message, callback: callback, context: context, done: false },\n called = false,\n self = this;\n\n this._queue.push(record);\n\n if (record.error) {\n record.done = true;\n this._stop();\n return this._flushQueue();\n }\n\n var handler = function(err, msg) {\n if (!(called ^ (called = true))) return;\n\n if (err) {\n self._stop();\n record.error = err;\n record.message = null;\n } else {\n record.message = msg;\n }\n\n record.done = true;\n self._flushQueue();\n };\n\n try {\n this._session[this._method](message, handler);\n } catch (err) {\n handler(err);\n }\n};\n\nFunctor.prototype._stop = function() {\n this.pending = this._queue.length;\n this._stopped = true;\n};\n\nFunctor.prototype._flushQueue = function() {\n var queue = this._queue, record;\n\n while (queue.length > 0 && queue.peek().done) {\n record = queue.shift();\n if (record.error) {\n this.pending = 0;\n queue.clear();\n } else {\n this.pending -= 1;\n }\n record.callback.call(record.context, record.error, record.message);\n }\n};\n\nmodule.exports = Functor;\n","'use strict';\n\nvar Frame = function() {};\n\nvar instance = {\n final: false,\n rsv1: false,\n rsv2: false,\n rsv3: false,\n opcode: null,\n masked: false,\n maskingKey: null,\n lengthBytes: 1,\n length: 0,\n payload: null\n};\n\nfor (var key in instance)\n Frame.prototype[key] = instance[key];\n\nmodule.exports = Frame;\n","'use strict';\n\nvar Buffer = require('safe-buffer').Buffer;\n\nvar Message = function() {\n this.rsv1 = false;\n this.rsv2 = false;\n this.rsv3 = false;\n this.opcode = null;\n this.length = 0;\n this._chunks = [];\n};\n\nvar instance = {\n read: function() {\n return this.data = this.data || Buffer.concat(this._chunks, this.length);\n },\n\n pushFrame: function(frame) {\n this.rsv1 = this.rsv1 || frame.rsv1;\n this.rsv2 = this.rsv2 || frame.rsv2;\n this.rsv3 = this.rsv3 || frame.rsv3;\n\n if (this.opcode === null) this.opcode = frame.opcode;\n\n this._chunks.push(frame.payload);\n this.length += frame.length;\n }\n};\n\nfor (var key in instance)\n Message.prototype[key] = instance[key];\n\nmodule.exports = Message;\n","'use strict';\n\nvar Buffer = require('safe-buffer').Buffer,\n Stream = require('stream').Stream,\n url = require('url'),\n util = require('util'),\n Base = require('./base'),\n Headers = require('./headers'),\n HttpParser = require('../http_parser');\n\nvar PORTS = { 'ws:': 80, 'wss:': 443 };\n\nvar Proxy = function(client, origin, options) {\n this._client = client;\n this._http = new HttpParser('response');\n this._origin = (typeof client.url === 'object') ? client.url : url.parse(client.url);\n this._url = (typeof origin === 'object') ? origin : url.parse(origin);\n this._options = options || {};\n this._state = 0;\n\n this.readable = this.writable = true;\n this._paused = false;\n\n this._headers = new Headers();\n this._headers.set('Host', this._origin.host);\n this._headers.set('Connection', 'keep-alive');\n this._headers.set('Proxy-Connection', 'keep-alive');\n\n var auth = this._url.auth && Buffer.from(this._url.auth, 'utf8').toString('base64');\n if (auth) this._headers.set('Proxy-Authorization', 'Basic ' + auth);\n};\nutil.inherits(Proxy, Stream);\n\nvar instance = {\n setHeader: function(name, value) {\n if (this._state !== 0) return false;\n this._headers.set(name, value);\n return true;\n },\n\n start: function() {\n if (this._state !== 0) return false;\n this._state = 1;\n\n var origin = this._origin,\n port = origin.port || PORTS[origin.protocol],\n start = 'CONNECT ' + origin.hostname + ':' + port + ' HTTP/1.1';\n\n var headers = [start, this._headers.toString(), ''];\n\n this.emit('data', Buffer.from(headers.join('\\r\\n'), 'utf8'));\n return true;\n },\n\n pause: function() {\n this._paused = true;\n },\n\n resume: function() {\n this._paused = false;\n this.emit('drain');\n },\n\n write: function(chunk) {\n if (!this.writable) return false;\n\n this._http.parse(chunk);\n if (!this._http.isComplete()) return !this._paused;\n\n this.statusCode = this._http.statusCode;\n this.headers = this._http.headers;\n\n if (this.statusCode === 200) {\n this.emit('connect', new Base.ConnectEvent());\n } else {\n var message = \"Can't establish a connection to the server at \" + this._origin.href;\n this.emit('error', new Error(message));\n }\n this.end();\n return !this._paused;\n },\n\n end: function(chunk) {\n if (!this.writable) return;\n if (chunk !== undefined) this.write(chunk);\n this.readable = this.writable = false;\n this.emit('close');\n this.emit('end');\n },\n\n destroy: function() {\n this.end();\n }\n};\n\nfor (var key in instance)\n Proxy.prototype[key] = instance[key];\n\nmodule.exports = Proxy;\n","'use strict';\n\nvar util = require('util'),\n HttpParser = require('../http_parser'),\n Base = require('./base'),\n Draft75 = require('./draft75'),\n Draft76 = require('./draft76'),\n Hybi = require('./hybi');\n\nvar Server = function(options) {\n Base.call(this, null, null, options);\n this._http = new HttpParser('request');\n};\nutil.inherits(Server, Base);\n\nvar instance = {\n EVENTS: ['open', 'message', 'error', 'close', 'ping', 'pong'],\n\n _bindEventListeners: function() {\n this.messages.on('error', function() {});\n this.on('error', function() {});\n },\n\n parse: function(chunk) {\n if (this._delegate) return this._delegate.parse(chunk);\n\n this._http.parse(chunk);\n if (!this._http.isComplete()) return;\n\n this.method = this._http.method;\n this.url = this._http.url;\n this.headers = this._http.headers;\n this.body = this._http.body;\n\n var self = this;\n this._delegate = Server.http(this, this._options);\n this._delegate.messages = this.messages;\n this._delegate.io = this.io;\n this._open();\n\n this.EVENTS.forEach(function(event) {\n this._delegate.on(event, function(e) { self.emit(event, e) });\n }, this);\n\n this.protocol = this._delegate.protocol;\n this.version = this._delegate.version;\n\n this.parse(this._http.body);\n this.emit('connect', new Base.ConnectEvent());\n },\n\n _open: function() {\n this.__queue.forEach(function(msg) {\n this._delegate[msg[0]].apply(this._delegate, msg[1]);\n }, this);\n this.__queue = [];\n }\n};\n\n['addExtension', 'setHeader', 'start', 'frame', 'text', 'binary', 'ping', 'close'].forEach(function(method) {\n instance[method] = function() {\n if (this._delegate) {\n return this._delegate[method].apply(this._delegate, arguments);\n } else {\n this.__queue.push([method, arguments]);\n return true;\n }\n };\n});\n\nfor (var key in instance)\n Server.prototype[key] = instance[key];\n\nServer.isSecureRequest = function(request) {\n if (request.connection && request.connection.authorized !== undefined) return true;\n if (request.socket && request.socket.secure) return true;\n\n var headers = request.headers;\n if (!headers) return false;\n if (headers['https'] === 'on') return true;\n if (headers['x-forwarded-ssl'] === 'on') return true;\n if (headers['x-forwarded-scheme'] === 'https') return true;\n if (headers['x-forwarded-proto'] === 'https') return true;\n\n return false;\n};\n\nServer.determineUrl = function(request) {\n var scheme = this.isSecureRequest(request) ? 'wss:' : 'ws:';\n return scheme + '//' + request.headers.host + request.url;\n};\n\nServer.http = function(request, options) {\n options = options || {};\n if (options.requireMasking === undefined) options.requireMasking = true;\n\n var headers = request.headers,\n version = headers['sec-websocket-version'],\n key = headers['sec-websocket-key'],\n key1 = headers['sec-websocket-key1'],\n key2 = headers['sec-websocket-key2'],\n url = this.determineUrl(request);\n\n if (version || key)\n return new Hybi(request, url, options);\n else if (key1 || key2)\n return new Draft76(request, url, options);\n else\n return new Draft75(request, url, options);\n};\n\nmodule.exports = Server;\n","'use strict';\n\nvar Buffer = require('safe-buffer').Buffer,\n Base = require('./base'),\n Draft75 = require('./draft75'),\n crypto = require('crypto'),\n util = require('util');\n\n\nvar numberFromKey = function(key) {\n return parseInt((key.match(/[0-9]/g) || []).join(''), 10);\n};\n\nvar spacesInKey = function(key) {\n return (key.match(/ /g) || []).length;\n};\n\n\nvar Draft76 = function(request, url, options) {\n Draft75.apply(this, arguments);\n this._stage = -1;\n this._body = [];\n this.version = 'hixie-76';\n\n this._headers.clear();\n\n this._headers.set('Upgrade', 'WebSocket');\n this._headers.set('Connection', 'Upgrade');\n this._headers.set('Sec-WebSocket-Origin', this._request.headers.origin);\n this._headers.set('Sec-WebSocket-Location', this.url);\n};\nutil.inherits(Draft76, Draft75);\n\nvar instance = {\n BODY_SIZE: 8,\n\n start: function() {\n if (!Draft75.prototype.start.call(this)) return false;\n this._started = true;\n this._sendHandshakeBody();\n return true;\n },\n\n close: function() {\n if (this.readyState === 3) return false;\n if (this.readyState === 1) this._write(Buffer.from([0xFF, 0x00]));\n this.readyState = 3;\n this.emit('close', new Base.CloseEvent(null, null));\n return true;\n },\n\n _handshakeResponse: function() {\n var headers = this._request.headers,\n key1 = headers['sec-websocket-key1'],\n key2 = headers['sec-websocket-key2'];\n\n if (!key1) throw new Error('Missing required header: Sec-WebSocket-Key1');\n if (!key2) throw new Error('Missing required header: Sec-WebSocket-Key2');\n\n var number1 = numberFromKey(key1),\n spaces1 = spacesInKey(key1),\n\n number2 = numberFromKey(key2),\n spaces2 = spacesInKey(key2);\n\n if (number1 % spaces1 !== 0 || number2 % spaces2 !== 0)\n throw new Error('Client sent invalid Sec-WebSocket-Key headers');\n\n this._keyValues = [number1 / spaces1, number2 / spaces2];\n\n var start = 'HTTP/1.1 101 WebSocket Protocol Handshake',\n headers = [start, this._headers.toString(), ''];\n\n return Buffer.from(headers.join('\\r\\n'), 'binary');\n },\n\n _handshakeSignature: function() {\n if (this._body.length < this.BODY_SIZE) return null;\n\n var md5 = crypto.createHash('md5'),\n buffer = Buffer.allocUnsafe(8 + this.BODY_SIZE);\n\n buffer.writeUInt32BE(this._keyValues[0], 0);\n buffer.writeUInt32BE(this._keyValues[1], 4);\n Buffer.from(this._body).copy(buffer, 8, 0, this.BODY_SIZE);\n\n md5.update(buffer);\n return Buffer.from(md5.digest('binary'), 'binary');\n },\n\n _sendHandshakeBody: function() {\n if (!this._started) return;\n var signature = this._handshakeSignature();\n if (!signature) return;\n\n this._write(signature);\n this._stage = 0;\n this._open();\n\n if (this._body.length > this.BODY_SIZE)\n this.parse(this._body.slice(this.BODY_SIZE));\n },\n\n _parseLeadingByte: function(octet) {\n if (octet !== 0xFF)\n return Draft75.prototype._parseLeadingByte.call(this, octet);\n\n this._closing = true;\n this._length = 0;\n this._stage = 1;\n }\n};\n\nfor (var key in instance)\n Draft76.prototype[key] = instance[key];\n\nmodule.exports = Draft76;\n","'use strict';\n\nvar util = require('util'),\n net = require('net'),\n tls = require('tls'),\n url = require('url'),\n driver = require('websocket-driver'),\n API = require('./api'),\n Event = require('./api/event');\n\nvar DEFAULT_PORTS = {'http:': 80, 'https:': 443, 'ws:':80, 'wss:': 443},\n SECURE_PROTOCOLS = ['https:', 'wss:'];\n\nvar Client = function(_url, protocols, options) {\n options = options || {};\n\n this.url = _url;\n this._driver = driver.client(this.url, {maxLength: options.maxLength, protocols: protocols});\n\n ['open', 'error'].forEach(function(event) {\n this._driver.on(event, function() {\n self.headers = self._driver.headers;\n self.statusCode = self._driver.statusCode;\n });\n }, this);\n\n var proxy = options.proxy || {},\n endpoint = url.parse(proxy.origin || this.url),\n port = endpoint.port || DEFAULT_PORTS[endpoint.protocol],\n secure = SECURE_PROTOCOLS.indexOf(endpoint.protocol) >= 0,\n onConnect = function() { self._onConnect() },\n netOptions = options.net || {},\n originTLS = options.tls || {},\n socketTLS = proxy.origin ? (proxy.tls || {}) : originTLS,\n self = this;\n\n netOptions.host = socketTLS.host = endpoint.hostname;\n netOptions.port = socketTLS.port = port;\n\n originTLS.ca = originTLS.ca || options.ca;\n socketTLS.servername = socketTLS.servername || endpoint.hostname;\n\n this._stream = secure\n ? tls.connect(socketTLS, onConnect)\n : net.connect(netOptions, onConnect);\n\n if (proxy.origin) this._configureProxy(proxy, originTLS);\n\n API.call(this, options);\n};\nutil.inherits(Client, API);\n\nClient.prototype._onConnect = function() {\n var worker = this._proxy || this._driver;\n worker.start();\n};\n\nClient.prototype._configureProxy = function(proxy, originTLS) {\n var uri = url.parse(this.url),\n secure = SECURE_PROTOCOLS.indexOf(uri.protocol) >= 0,\n self = this,\n name;\n\n this._proxy = this._driver.proxy(proxy.origin);\n\n if (proxy.headers) {\n for (name in proxy.headers) this._proxy.setHeader(name, proxy.headers[name]);\n }\n\n this._proxy.pipe(this._stream, {end: false});\n this._stream.pipe(this._proxy);\n\n this._proxy.on('connect', function() {\n if (secure) {\n var options = {socket: self._stream, servername: uri.hostname};\n for (name in originTLS) options[name] = originTLS[name];\n self._stream = tls.connect(options);\n self._configureStream();\n }\n self._driver.io.pipe(self._stream);\n self._stream.pipe(self._driver.io);\n self._driver.start();\n });\n\n this._proxy.on('error', function(error) {\n self._driver.emit('error', error);\n });\n};\n\nmodule.exports = Client;\n","module.exports = require(\"net\");","module.exports = require(\"tls\");","'use strict';\n\nvar Stream = require('stream').Stream,\n util = require('util'),\n driver = require('websocket-driver'),\n Headers = require('websocket-driver/lib/websocket/driver/headers'),\n API = require('./websocket/api'),\n EventTarget = require('./websocket/api/event_target'),\n Event = require('./websocket/api/event');\n\nvar EventSource = function(request, response, options) {\n this.writable = true;\n options = options || {};\n\n this._stream = response.socket;\n this._ping = options.ping || this.DEFAULT_PING;\n this._retry = options.retry || this.DEFAULT_RETRY;\n\n var scheme = driver.isSecureRequest(request) ? 'https:' : 'http:';\n this.url = scheme + '//' + request.headers.host + request.url;\n this.lastEventId = request.headers['last-event-id'] || '';\n this.readyState = API.CONNECTING;\n\n var headers = new Headers(),\n self = this;\n\n if (options.headers) {\n for (var key in options.headers) headers.set(key, options.headers[key]);\n }\n\n if (!this._stream || !this._stream.writable) return;\n process.nextTick(function() { self._open() });\n\n this._stream.setTimeout(0);\n this._stream.setNoDelay(true);\n\n var handshake = 'HTTP/1.1 200 OK\\r\\n' +\n 'Content-Type: text/event-stream\\r\\n' +\n 'Cache-Control: no-cache, no-store\\r\\n' +\n 'Connection: close\\r\\n' +\n headers.toString() +\n '\\r\\n' +\n 'retry: ' + Math.floor(this._retry * 1000) + '\\r\\n\\r\\n';\n\n this._write(handshake);\n\n this._stream.on('drain', function() { self.emit('drain') });\n\n if (this._ping)\n this._pingTimer = setInterval(function() { self.ping() }, this._ping * 1000);\n\n ['error', 'end'].forEach(function(event) {\n self._stream.on(event, function() { self.close() });\n });\n};\nutil.inherits(EventSource, Stream);\n\nEventSource.isEventSource = function(request) {\n if (request.method !== 'GET') return false;\n var accept = (request.headers.accept || '').split(/\\s*,\\s*/);\n return accept.indexOf('text/event-stream') >= 0;\n};\n\nvar instance = {\n DEFAULT_PING: 10,\n DEFAULT_RETRY: 5,\n\n _write: function(chunk) {\n if (!this.writable) return false;\n try {\n return this._stream.write(chunk, 'utf8');\n } catch (e) {\n return false;\n }\n },\n\n _open: function() {\n if (this.readyState !== API.CONNECTING) return;\n\n this.readyState = API.OPEN;\n\n var event = new Event('open');\n event.initEvent('open', false, false);\n this.dispatchEvent(event);\n },\n\n write: function(message) {\n return this.send(message);\n },\n\n end: function(message) {\n if (message !== undefined) this.write(message);\n this.close();\n },\n\n send: function(message, options) {\n if (this.readyState > API.OPEN) return false;\n\n message = String(message).replace(/(\\r\\n|\\r|\\n)/g, '$1data: ');\n options = options || {};\n\n var frame = '';\n if (options.event) frame += 'event: ' + options.event + '\\r\\n';\n if (options.id) frame += 'id: ' + options.id + '\\r\\n';\n frame += 'data: ' + message + '\\r\\n\\r\\n';\n\n return this._write(frame);\n },\n\n ping: function() {\n return this._write(':\\r\\n\\r\\n');\n },\n\n close: function() {\n if (this.readyState > API.OPEN) return false;\n\n this.readyState = API.CLOSED;\n this.writable = false;\n if (this._pingTimer) clearInterval(this._pingTimer);\n if (this._stream) this._stream.end();\n\n var event = new Event('close');\n event.initEvent('close', false, false);\n this.dispatchEvent(event);\n\n return true;\n }\n};\n\nfor (var method in instance) EventSource.prototype[method] = instance[method];\nfor (var key in EventTarget) EventSource.prototype[key] = EventTarget[key];\n\nmodule.exports = EventSource;\n","module.exports = require(\"child_process\");","module.exports = require(\"fs\");","module.exports = require(\"http\");","module.exports = require(\"https\");","export default function encode(s: any): string {\n return btoa(utob(s));\n}\n\nvar fromCharCode = String.fromCharCode;\n\nvar b64chars =\n 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';\nvar b64tab = {};\n\nfor (var i = 0, l = b64chars.length; i < l; i++) {\n b64tab[b64chars.charAt(i)] = i;\n}\n\nvar cb_utob = function(c) {\n var cc = c.charCodeAt(0);\n return cc < 0x80\n ? c\n : cc < 0x800\n ? fromCharCode(0xc0 | (cc >>> 6)) + fromCharCode(0x80 | (cc & 0x3f))\n : fromCharCode(0xe0 | ((cc >>> 12) & 0x0f)) +\n fromCharCode(0x80 | ((cc >>> 6) & 0x3f)) +\n fromCharCode(0x80 | (cc & 0x3f));\n};\n\nvar utob = function(u) {\n return u.replace(/[^\\x00-\\x7F]/g, cb_utob);\n};\n\nvar cb_encode = function(ccc) {\n var padlen = [0, 2, 1][ccc.length % 3];\n var ord =\n (ccc.charCodeAt(0) << 16) |\n ((ccc.length > 1 ? ccc.charCodeAt(1) : 0) << 8) |\n (ccc.length > 2 ? ccc.charCodeAt(2) : 0);\n var chars = [\n b64chars.charAt(ord >>> 18),\n b64chars.charAt((ord >>> 12) & 63),\n padlen >= 2 ? '=' : b64chars.charAt((ord >>> 6) & 63),\n padlen >= 1 ? '=' : b64chars.charAt(ord & 63)\n ];\n return chars.join('');\n};\n\nvar btoa =\n global.btoa ||\n function(b) {\n return b.replace(/[\\s\\S]{1,3}/g, cb_encode);\n };\n","import TimedCallback from './timed_callback';\nimport { Delay, Scheduler, Canceller } from './scheduling';\n\nabstract class Timer {\n protected clear: Canceller;\n protected timer: number | void;\n\n constructor(\n set: Scheduler,\n clear: Canceller,\n delay: Delay,\n callback: TimedCallback\n ) {\n this.clear = clear;\n this.timer = set(() => {\n if (this.timer) {\n this.timer = callback(this.timer);\n }\n }, delay);\n }\n\n /** Returns whether the timer is still running.\n *\n * @return {Boolean}\n */\n isRunning(): boolean {\n return this.timer !== null;\n }\n\n /** Aborts a timer when it's running. */\n ensureAborted() {\n if (this.timer) {\n this.clear(this.timer);\n this.timer = null;\n }\n }\n}\n\nexport default Timer;\n","import Timer from './abstract_timer';\nimport TimedCallback from './timed_callback';\nimport { Delay } from './scheduling';\n\n// We need to bind clear functions this way to avoid exceptions on IE8\nfunction clearTimeout(timer) {\n global.clearTimeout(timer);\n}\nfunction clearInterval(timer) {\n global.clearInterval(timer);\n}\n\n/** Cross-browser compatible one-off timer abstraction.\n *\n * @param {Number} delay\n * @param {Function} callback\n */\nexport class OneOffTimer extends Timer {\n constructor(delay: Delay, callback: TimedCallback) {\n super(setTimeout, clearTimeout, delay, function(timer) {\n callback();\n return null;\n });\n }\n}\n\n/** Cross-browser compatible periodic timer abstraction.\n *\n * @param {Number} delay\n * @param {Function} callback\n */\nexport class PeriodicTimer extends Timer {\n constructor(delay: Delay, callback: TimedCallback) {\n super(setInterval, clearInterval, delay, function(timer) {\n callback();\n return timer;\n });\n }\n}\n","import * as Collections from './utils/collections';\nimport TimedCallback from './utils/timers/timed_callback';\nimport { OneOffTimer, PeriodicTimer } from './utils/timers';\n\nvar Util = {\n now(): number {\n if (Date.now) {\n return Date.now();\n } else {\n return new Date().valueOf();\n }\n },\n\n defer(callback: TimedCallback): OneOffTimer {\n return new OneOffTimer(0, callback);\n },\n\n /** Builds a function that will proxy a method call to its first argument.\n *\n * Allows partial application of arguments, so additional arguments are\n * prepended to the argument list.\n *\n * @param {String} name method name\n * @return {Function} proxy function\n */\n method(name: string, ...args: any[]): Function {\n var boundArguments = Array.prototype.slice.call(arguments, 1);\n return function(object) {\n return object[name].apply(object, boundArguments.concat(arguments));\n };\n }\n};\n\nexport default Util;\n","import base64encode from '../base64';\nimport Util from '../util';\n\n/** Merges multiple objects into the target argument.\n *\n * For properties that are plain Objects, performs a deep-merge. For the\n * rest it just copies the value of the property.\n *\n * To extend prototypes use it as following:\n * Pusher.Util.extend(Target.prototype, Base.prototype)\n *\n * You can also use it to merge objects without altering them:\n * Pusher.Util.extend({}, object1, object2)\n *\n * @param {Object} target\n * @return {Object} the target argument\n */\nexport function extend(target: any, ...sources: any[]): T {\n for (var i = 0; i < sources.length; i++) {\n var extensions = sources[i];\n for (var property in extensions) {\n if (\n extensions[property] &&\n extensions[property].constructor &&\n extensions[property].constructor === Object\n ) {\n target[property] = extend(target[property] || {}, extensions[property]);\n } else {\n target[property] = extensions[property];\n }\n }\n }\n return target;\n}\n\nexport function stringify(): string {\n var m = ['Pusher'];\n for (var i = 0; i < arguments.length; i++) {\n if (typeof arguments[i] === 'string') {\n m.push(arguments[i]);\n } else {\n m.push(safeJSONStringify(arguments[i]));\n }\n }\n return m.join(' : ');\n}\n\nexport function arrayIndexOf(array: any[], item: any): number {\n // MSIE doesn't have array.indexOf\n var nativeIndexOf = Array.prototype.indexOf;\n if (array === null) {\n return -1;\n }\n if (nativeIndexOf && array.indexOf === nativeIndexOf) {\n return array.indexOf(item);\n }\n for (var i = 0, l = array.length; i < l; i++) {\n if (array[i] === item) {\n return i;\n }\n }\n return -1;\n}\n\n/** Applies a function f to all properties of an object.\n *\n * Function f gets 3 arguments passed:\n * - element from the object\n * - key of the element\n * - reference to the object\n *\n * @param {Object} object\n * @param {Function} f\n */\nexport function objectApply(object: any, f: Function) {\n for (var key in object) {\n if (Object.prototype.hasOwnProperty.call(object, key)) {\n f(object[key], key, object);\n }\n }\n}\n\n/** Return a list of objects own proerty keys\n *\n * @param {Object} object\n * @returns {Array}\n */\nexport function keys(object: any): string[] {\n var keys = [];\n objectApply(object, function(_, key) {\n keys.push(key);\n });\n return keys;\n}\n\n/** Return a list of object's own property values\n *\n * @param {Object} object\n * @returns {Array}\n */\nexport function values(object: any): any[] {\n var values = [];\n objectApply(object, function(value) {\n values.push(value);\n });\n return values;\n}\n\n/** Applies a function f to all elements of an array.\n *\n * Function f gets 3 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function apply(array: any[], f: Function, context?: any) {\n for (var i = 0; i < array.length; i++) {\n f.call(context || global, array[i], i, array);\n }\n}\n\n/** Maps all elements of the array and returns the result.\n *\n * Function f gets 4 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n * - reference to the destination array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function map(array: any[], f: Function): any[] {\n var result = [];\n for (var i = 0; i < array.length; i++) {\n result.push(f(array[i], i, array, result));\n }\n return result;\n}\n\n/** Maps all elements of the object and returns the result.\n *\n * Function f gets 4 arguments passed:\n * - element from the object\n * - key of the element\n * - reference to the source object\n * - reference to the destination object\n *\n * @param {Object} object\n * @param {Function} f\n */\nexport function mapObject(object: any, f: Function): any {\n var result = {};\n objectApply(object, function(value, key) {\n result[key] = f(value);\n });\n return result;\n}\n\n/** Filters elements of the array using a test function.\n *\n * Function test gets 4 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n * - reference to the destination array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function filter(array: any[], test: Function): any[] {\n test =\n test ||\n function(value) {\n return !!value;\n };\n\n var result = [];\n for (var i = 0; i < array.length; i++) {\n if (test(array[i], i, array, result)) {\n result.push(array[i]);\n }\n }\n return result;\n}\n\n/** Filters properties of the object using a test function.\n *\n * Function test gets 4 arguments passed:\n * - element from the object\n * - key of the element\n * - reference to the source object\n * - reference to the destination object\n *\n * @param {Object} object\n * @param {Function} f\n */\nexport function filterObject(object: Object, test: Function) {\n var result = {};\n objectApply(object, function(value, key) {\n if ((test && test(value, key, object, result)) || Boolean(value)) {\n result[key] = value;\n }\n });\n return result;\n}\n\n/** Flattens an object into a two-dimensional array.\n *\n * @param {Object} object\n * @return {Array} resulting array of [key, value] pairs\n */\nexport function flatten(object: Object): any[] {\n var result = [];\n objectApply(object, function(value, key) {\n result.push([key, value]);\n });\n return result;\n}\n\n/** Checks whether any element of the array passes the test.\n *\n * Function test gets 3 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function any(array: any[], test: Function): boolean {\n for (var i = 0; i < array.length; i++) {\n if (test(array[i], i, array)) {\n return true;\n }\n }\n return false;\n}\n\n/** Checks whether all elements of the array pass the test.\n *\n * Function test gets 3 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function all(array: any[], test: Function): boolean {\n for (var i = 0; i < array.length; i++) {\n if (!test(array[i], i, array)) {\n return false;\n }\n }\n return true;\n}\n\nexport function encodeParamsObject(data): string {\n return mapObject(data, function(value) {\n if (typeof value === 'object') {\n value = safeJSONStringify(value);\n }\n return encodeURIComponent(base64encode(value.toString()));\n });\n}\n\nexport function buildQueryString(data: any): string {\n var params = filterObject(data, function(value) {\n return value !== undefined;\n });\n\n var query = map(\n flatten(encodeParamsObject(params)),\n Util.method('join', '=')\n ).join('&');\n\n return query;\n}\n\n/**\n * See https://github.com/douglascrockford/JSON-js/blob/master/cycle.js\n *\n * Remove circular references from an object. Required for JSON.stringify in\n * React Native, which tends to blow up a lot.\n *\n * @param {any} object\n * @return {any} Decycled object\n */\nexport function decycleObject(object: any): any {\n var objects = [],\n paths = [];\n\n return (function derez(value, path) {\n var i, name, nu;\n\n switch (typeof value) {\n case 'object':\n if (!value) {\n return null;\n }\n for (i = 0; i < objects.length; i += 1) {\n if (objects[i] === value) {\n return { $ref: paths[i] };\n }\n }\n\n objects.push(value);\n paths.push(path);\n\n if (Object.prototype.toString.apply(value) === '[object Array]') {\n nu = [];\n for (i = 0; i < value.length; i += 1) {\n nu[i] = derez(value[i], path + '[' + i + ']');\n }\n } else {\n nu = {};\n for (name in value) {\n if (Object.prototype.hasOwnProperty.call(value, name)) {\n nu[name] = derez(\n value[name],\n path + '[' + JSON.stringify(name) + ']'\n );\n }\n }\n }\n return nu;\n case 'number':\n case 'string':\n case 'boolean':\n return value;\n }\n })(object, '$');\n}\n\n/**\n * Provides a cross-browser and cross-platform way to safely stringify objects\n * into JSON. This is particularly necessary for ReactNative, where circular JSON\n * structures throw an exception.\n *\n * @param {any} source The object to stringify\n * @return {string} The serialized output.\n */\nexport function safeJSONStringify(source: any): string {\n try {\n return JSON.stringify(source);\n } catch (e) {\n return JSON.stringify(decycleObject(source));\n }\n}\n","import {\n ChannelAuthorizationOptions,\n UserAuthenticationOptions\n} from './auth/options';\nimport { AuthTransport } from './config';\n\nexport interface DefaultConfig {\n VERSION: string;\n PROTOCOL: number;\n wsPort: number;\n wssPort: number;\n wsPath: string;\n httpHost: string;\n httpPort: number;\n httpsPort: number;\n httpPath: string;\n stats_host: string;\n authEndpoint: string;\n authTransport: AuthTransport;\n activityTimeout: number;\n pongTimeout: number;\n unavailableTimeout: number;\n userAuthentication: UserAuthenticationOptions;\n channelAuthorization: ChannelAuthorizationOptions;\n\n cdn_http?: string;\n cdn_https?: string;\n dependency_suffix?: string;\n}\n\nvar Defaults: DefaultConfig = {\n VERSION: VERSION,\n PROTOCOL: 7,\n\n wsPort: 80,\n wssPort: 443,\n wsPath: '',\n // DEPRECATED: SockJS fallback parameters\n httpHost: 'sockjs.pusher.com',\n httpPort: 80,\n httpsPort: 443,\n httpPath: '/pusher',\n // DEPRECATED: Stats\n stats_host: 'stats.pusher.com',\n // DEPRECATED: Other settings\n authEndpoint: '/pusher/auth',\n authTransport: 'ajax',\n activityTimeout: 120000,\n pongTimeout: 30000,\n unavailableTimeout: 10000,\n userAuthentication: {\n endpoint: '/pusher/user-auth',\n transport: 'ajax'\n },\n channelAuthorization: {\n endpoint: '/pusher/auth',\n transport: 'ajax'\n },\n\n // CDN configuration\n cdn_http: CDN_HTTP,\n cdn_https: CDN_HTTPS,\n dependency_suffix: DEPENDENCY_SUFFIX\n};\n\nexport default Defaults;\n","import Defaults from '../defaults';\nimport { default as URLScheme, URLSchemeParams } from './url_scheme';\n\nfunction getGenericURL(\n baseScheme: string,\n params: URLSchemeParams,\n path: string\n): string {\n var scheme = baseScheme + (params.useTLS ? 's' : '');\n var host = params.useTLS ? params.hostTLS : params.hostNonTLS;\n return scheme + '://' + host + path;\n}\n\nfunction getGenericPath(key: string, queryString?: string): string {\n var path = '/app/' + key;\n var query =\n '?protocol=' +\n Defaults.PROTOCOL +\n '&client=js' +\n '&version=' +\n Defaults.VERSION +\n (queryString ? '&' + queryString : '');\n return path + query;\n}\n\nexport var ws: URLScheme = {\n getInitial: function(key: string, params: URLSchemeParams): string {\n var path = (params.httpPath || '') + getGenericPath(key, 'flash=false');\n return getGenericURL('ws', params, path);\n }\n};\n\nexport var http: URLScheme = {\n getInitial: function(key: string, params: URLSchemeParams): string {\n var path = (params.httpPath || '/pusher') + getGenericPath(key);\n return getGenericURL('http', params, path);\n }\n};\n\nexport var sockjs: URLScheme = {\n getInitial: function(key: string, params: URLSchemeParams): string {\n return getGenericURL('http', params, params.httpPath || '/pusher');\n },\n getPath: function(key: string, params: URLSchemeParams): string {\n return getGenericPath(key);\n }\n};\n","import Callback from './callback';\nimport * as Collections from '../utils/collections';\nimport CallbackTable from './callback_table';\n\nexport default class CallbackRegistry {\n _callbacks: CallbackTable;\n\n constructor() {\n this._callbacks = {};\n }\n\n get(name: string): Callback[] {\n return this._callbacks[prefix(name)];\n }\n\n add(name: string, callback: Function, context: any) {\n var prefixedEventName = prefix(name);\n this._callbacks[prefixedEventName] =\n this._callbacks[prefixedEventName] || [];\n this._callbacks[prefixedEventName].push({\n fn: callback,\n context: context\n });\n }\n\n remove(name?: string, callback?: Function, context?: any) {\n if (!name && !callback && !context) {\n this._callbacks = {};\n return;\n }\n\n var names = name ? [prefix(name)] : Collections.keys(this._callbacks);\n\n if (callback || context) {\n this.removeCallback(names, callback, context);\n } else {\n this.removeAllCallbacks(names);\n }\n }\n\n private removeCallback(names: string[], callback: Function, context: any) {\n Collections.apply(\n names,\n function(name) {\n this._callbacks[name] = Collections.filter(\n this._callbacks[name] || [],\n function(binding) {\n return (\n (callback && callback !== binding.fn) ||\n (context && context !== binding.context)\n );\n }\n );\n if (this._callbacks[name].length === 0) {\n delete this._callbacks[name];\n }\n },\n this\n );\n }\n\n private removeAllCallbacks(names: string[]) {\n Collections.apply(\n names,\n function(name) {\n delete this._callbacks[name];\n },\n this\n );\n }\n}\n\nfunction prefix(name: string): string {\n return '_' + name;\n}\n","import * as Collections from '../utils/collections';\nimport Callback from './callback';\nimport Metadata from '../channels/metadata';\nimport CallbackRegistry from './callback_registry';\n\n/** Manages callback bindings and event emitting.\n *\n * @param Function failThrough called when no listeners are bound to an event\n */\nexport default class Dispatcher {\n callbacks: CallbackRegistry;\n global_callbacks: Function[];\n failThrough: Function;\n\n constructor(failThrough?: Function) {\n this.callbacks = new CallbackRegistry();\n this.global_callbacks = [];\n this.failThrough = failThrough;\n }\n\n bind(eventName: string, callback: Function, context?: any) {\n this.callbacks.add(eventName, callback, context);\n return this;\n }\n\n bind_global(callback: Function) {\n this.global_callbacks.push(callback);\n return this;\n }\n\n unbind(eventName?: string, callback?: Function, context?: any) {\n this.callbacks.remove(eventName, callback, context);\n return this;\n }\n\n unbind_global(callback?: Function) {\n if (!callback) {\n this.global_callbacks = [];\n return this;\n }\n\n this.global_callbacks = Collections.filter(\n this.global_callbacks || [],\n c => c !== callback\n );\n\n return this;\n }\n\n unbind_all() {\n this.unbind();\n this.unbind_global();\n return this;\n }\n\n emit(eventName: string, data?: any, metadata?: Metadata): Dispatcher {\n for (var i = 0; i < this.global_callbacks.length; i++) {\n this.global_callbacks[i](eventName, data);\n }\n\n var callbacks = this.callbacks.get(eventName);\n var args = [];\n\n if (metadata) {\n // if there's a metadata argument, we need to call the callback with both\n // data and metadata regardless of whether data is undefined\n args.push(data, metadata);\n } else if (data) {\n // metadata is undefined, so we only need to call the callback with data\n // if data exists\n args.push(data);\n }\n\n if (callbacks && callbacks.length > 0) {\n for (var i = 0; i < callbacks.length; i++) {\n callbacks[i].fn.apply(callbacks[i].context || global, args);\n }\n } else if (this.failThrough) {\n this.failThrough(eventName, data);\n }\n\n return this;\n }\n}\n","import { stringify } from './utils/collections';\nimport Pusher from './pusher';\n\nclass Logger {\n debug(...args: any[]) {\n this.log(this.globalLog, args);\n }\n\n warn(...args: any[]) {\n this.log(this.globalLogWarn, args);\n }\n\n error(...args: any[]) {\n this.log(this.globalLogError, args);\n }\n\n private globalLog = (message: string) => {\n if (global.console && global.console.log) {\n global.console.log(message);\n }\n };\n\n private globalLogWarn(message: string) {\n if (global.console && global.console.warn) {\n global.console.warn(message);\n } else {\n this.globalLog(message);\n }\n }\n\n private globalLogError(message: string) {\n if (global.console && global.console.error) {\n global.console.error(message);\n } else {\n this.globalLogWarn(message);\n }\n }\n\n private log(\n defaultLoggingFunction: (message: string) => void,\n ...args: any[]\n ) {\n var message = stringify.apply(this, arguments);\n if (Pusher.log) {\n Pusher.log(message);\n } else if (Pusher.logToConsole) {\n const log = defaultLoggingFunction.bind(this);\n log(message);\n }\n }\n}\n\nexport default new Logger();\n","import Util from '../util';\nimport * as Collections from '../utils/collections';\nimport { default as EventsDispatcher } from '../events/dispatcher';\nimport Logger from '../logger';\nimport TransportHooks from './transport_hooks';\nimport Socket from '../socket';\nimport Runtime from 'runtime';\nimport Timeline from '../timeline/timeline';\nimport TransportConnectionOptions from './transport_connection_options';\n\n/** Provides universal API for transport connections.\n *\n * Transport connection is a low-level object that wraps a connection method\n * and exposes a simple evented interface for the connection state and\n * messaging. It does not implement Pusher-specific WebSocket protocol.\n *\n * Additionally, it fetches resources needed for transport to work and exposes\n * an interface for querying transport features.\n *\n * States:\n * - new - initial state after constructing the object\n * - initializing - during initialization phase, usually fetching resources\n * - intialized - ready to establish a connection\n * - connection - when connection is being established\n * - open - when connection ready to be used\n * - closed - after connection was closed be either side\n *\n * Emits:\n * - error - after the connection raised an error\n *\n * Options:\n * - useTLS - whether connection should be over TLS\n * - hostTLS - host to connect to when connection is over TLS\n * - hostNonTLS - host to connect to when connection is over TLS\n *\n * @param {String} key application key\n * @param {Object} options\n */\nexport default class TransportConnection extends EventsDispatcher {\n hooks: TransportHooks;\n name: string;\n priority: number;\n key: string;\n options: TransportConnectionOptions;\n state: string;\n timeline: Timeline;\n activityTimeout: number;\n id: number;\n socket: Socket;\n beforeOpen: Function;\n initialize: Function;\n\n constructor(\n hooks: TransportHooks,\n name: string,\n priority: number,\n key: string,\n options: TransportConnectionOptions\n ) {\n super();\n this.initialize = Runtime.transportConnectionInitializer;\n this.hooks = hooks;\n this.name = name;\n this.priority = priority;\n this.key = key;\n this.options = options;\n\n this.state = 'new';\n this.timeline = options.timeline;\n this.activityTimeout = options.activityTimeout;\n this.id = this.timeline.generateUniqueID();\n }\n\n /** Checks whether the transport handles activity checks by itself.\n *\n * @return {Boolean}\n */\n handlesActivityChecks(): boolean {\n return Boolean(this.hooks.handlesActivityChecks);\n }\n\n /** Checks whether the transport supports the ping/pong API.\n *\n * @return {Boolean}\n */\n supportsPing(): boolean {\n return Boolean(this.hooks.supportsPing);\n }\n\n /** Tries to establish a connection.\n *\n * @returns {Boolean} false if transport is in invalid state\n */\n connect(): boolean {\n if (this.socket || this.state !== 'initialized') {\n return false;\n }\n\n var url = this.hooks.urls.getInitial(this.key, this.options);\n try {\n this.socket = this.hooks.getSocket(url, this.options);\n } catch (e) {\n Util.defer(() => {\n this.onError(e);\n this.changeState('closed');\n });\n return false;\n }\n\n this.bindListeners();\n\n Logger.debug('Connecting', { transport: this.name, url });\n this.changeState('connecting');\n return true;\n }\n\n /** Closes the connection.\n *\n * @return {Boolean} true if there was a connection to close\n */\n close(): boolean {\n if (this.socket) {\n this.socket.close();\n return true;\n } else {\n return false;\n }\n }\n\n /** Sends data over the open connection.\n *\n * @param {String} data\n * @return {Boolean} true only when in the \"open\" state\n */\n send(data: any): boolean {\n if (this.state === 'open') {\n // Workaround for MobileSafari bug (see https://gist.github.com/2052006)\n Util.defer(() => {\n if (this.socket) {\n this.socket.send(data);\n }\n });\n return true;\n } else {\n return false;\n }\n }\n\n /** Sends a ping if the connection is open and transport supports it. */\n ping() {\n if (this.state === 'open' && this.supportsPing()) {\n this.socket.ping();\n }\n }\n\n private onOpen() {\n if (this.hooks.beforeOpen) {\n this.hooks.beforeOpen(\n this.socket,\n this.hooks.urls.getPath(this.key, this.options)\n );\n }\n this.changeState('open');\n this.socket.onopen = undefined;\n }\n\n private onError(error) {\n this.emit('error', { type: 'WebSocketError', error: error });\n this.timeline.error(this.buildTimelineMessage({ error: error.toString() }));\n }\n\n private onClose(closeEvent?: any) {\n if (closeEvent) {\n this.changeState('closed', {\n code: closeEvent.code,\n reason: closeEvent.reason,\n wasClean: closeEvent.wasClean\n });\n } else {\n this.changeState('closed');\n }\n this.unbindListeners();\n this.socket = undefined;\n }\n\n private onMessage(message) {\n this.emit('message', message);\n }\n\n private onActivity() {\n this.emit('activity');\n }\n\n private bindListeners() {\n this.socket.onopen = () => {\n this.onOpen();\n };\n this.socket.onerror = error => {\n this.onError(error);\n };\n this.socket.onclose = closeEvent => {\n this.onClose(closeEvent);\n };\n this.socket.onmessage = message => {\n this.onMessage(message);\n };\n\n if (this.supportsPing()) {\n this.socket.onactivity = () => {\n this.onActivity();\n };\n }\n }\n\n private unbindListeners() {\n if (this.socket) {\n this.socket.onopen = undefined;\n this.socket.onerror = undefined;\n this.socket.onclose = undefined;\n this.socket.onmessage = undefined;\n if (this.supportsPing()) {\n this.socket.onactivity = undefined;\n }\n }\n }\n\n private changeState(state: string, params?: any) {\n this.state = state;\n this.timeline.info(\n this.buildTimelineMessage({\n state: state,\n params: params\n })\n );\n this.emit(state, params);\n }\n\n buildTimelineMessage(message): any {\n return Collections.extend({ cid: this.id }, message);\n }\n}\n","import Factory from '../utils/factory';\nimport TransportHooks from './transport_hooks';\nimport TransportConnection from './transport_connection';\nimport TransportConnectionOptions from './transport_connection_options';\n\n/** Provides interface for transport connection instantiation.\n *\n * Takes transport-specific hooks as the only argument, which allow checking\n * for transport support and creating its connections.\n *\n * Supported hooks: * - file - the name of the file to be fetched during initialization\n * - urls - URL scheme to be used by transport\n * - handlesActivityCheck - true when the transport handles activity checks\n * - supportsPing - true when the transport has a ping/activity API\n * - isSupported - tells whether the transport is supported in the environment\n * - getSocket - creates a WebSocket-compatible transport socket\n *\n * See transports.js for specific implementations.\n *\n * @param {Object} hooks object containing all needed transport hooks\n */\nexport default class Transport {\n hooks: TransportHooks;\n\n constructor(hooks: TransportHooks) {\n this.hooks = hooks;\n }\n\n /** Returns whether the transport is supported in the environment.\n *\n * @param {Object} envronment te environment details (encryption, settings)\n * @returns {Boolean} true when the transport is supported\n */\n isSupported(environment: any): boolean {\n return this.hooks.isSupported(environment);\n }\n\n /** Creates a transport connection.\n *\n * @param {String} name\n * @param {Number} priority\n * @param {String} key the application key\n * @param {Object} options\n * @returns {TransportConnection}\n */\n createConnection(\n name: string,\n priority: number,\n key: string,\n options: any\n ): TransportConnection {\n return new TransportConnection(this.hooks, name, priority, key, options);\n }\n}\n","import * as URLSchemes from 'core/transports/url_schemes';\nimport URLScheme from 'core/transports/url_scheme';\nimport Transport from 'core/transports/transport';\nimport Util from 'core/util';\nimport * as Collections from 'core/utils/collections';\nimport TransportHooks from 'core/transports/transport_hooks';\nimport TransportsTable from 'core/transports/transports_table';\nimport Runtime from 'runtime';\n\n/** WebSocket transport.\n *\n * Uses native WebSocket implementation, including MozWebSocket supported by\n * earlier Firefox versions.\n */\nvar WSTransport = new Transport({\n urls: URLSchemes.ws,\n handlesActivityChecks: false,\n supportsPing: false,\n\n isInitialized: function() {\n return Boolean(Runtime.getWebSocketAPI());\n },\n isSupported: function(): boolean {\n return Boolean(Runtime.getWebSocketAPI());\n },\n getSocket: function(url) {\n return Runtime.createWebSocket(url);\n }\n});\n\nvar httpConfiguration = {\n urls: URLSchemes.http,\n handlesActivityChecks: false,\n supportsPing: true,\n isInitialized: function() {\n return true;\n }\n};\n\nexport var streamingConfiguration = Collections.extend(\n {\n getSocket: function(url) {\n return Runtime.HTTPFactory.createStreamingSocket(url);\n }\n },\n httpConfiguration\n);\nexport var pollingConfiguration = Collections.extend(\n {\n getSocket: function(url) {\n return Runtime.HTTPFactory.createPollingSocket(url);\n }\n },\n httpConfiguration\n);\n\nvar xhrConfiguration = {\n isSupported: function(): boolean {\n return Runtime.isXHRSupported();\n }\n};\n\n/** HTTP streaming transport using CORS-enabled XMLHttpRequest. */\nvar XHRStreamingTransport = new Transport(\n (\n Collections.extend({}, streamingConfiguration, xhrConfiguration)\n )\n);\n\n/** HTTP long-polling transport using CORS-enabled XMLHttpRequest. */\nvar XHRPollingTransport = new Transport(\n Collections.extend({}, pollingConfiguration, xhrConfiguration)\n);\n\nvar Transports: TransportsTable = {\n ws: WSTransport,\n xhr_streaming: XHRStreamingTransport,\n xhr_polling: XHRPollingTransport\n};\n\nexport default Transports;\n","import Util from '../util';\nimport * as Collections from '../utils/collections';\nimport TransportManager from './transport_manager';\nimport TransportConnection from './transport_connection';\nimport Transport from './transport';\nimport PingDelayOptions from './ping_delay_options';\n\n/** Creates transport connections monitored by a transport manager.\n *\n * When a transport is closed, it might mean the environment does not support\n * it. It's possible that messages get stuck in an intermediate buffer or\n * proxies terminate inactive connections. To combat these problems,\n * assistants monitor the connection lifetime, report unclean exits and\n * adjust ping timeouts to keep the connection active. The decision to disable\n * a transport is the manager's responsibility.\n *\n * @param {TransportManager} manager\n * @param {TransportConnection} transport\n * @param {Object} options\n */\nexport default class AssistantToTheTransportManager {\n manager: TransportManager;\n transport: Transport;\n minPingDelay: number;\n maxPingDelay: number;\n pingDelay: number;\n\n constructor(\n manager: TransportManager,\n transport: Transport,\n options: PingDelayOptions\n ) {\n this.manager = manager;\n this.transport = transport;\n this.minPingDelay = options.minPingDelay;\n this.maxPingDelay = options.maxPingDelay;\n this.pingDelay = undefined;\n }\n\n /** Creates a transport connection.\n *\n * This function has the same API as Transport#createConnection.\n *\n * @param {String} name\n * @param {Number} priority\n * @param {String} key the application key\n * @param {Object} options\n * @returns {TransportConnection}\n */\n createConnection(\n name: string,\n priority: number,\n key: string,\n options: Object\n ): TransportConnection {\n options = Collections.extend({}, options, {\n activityTimeout: this.pingDelay\n });\n var connection = this.transport.createConnection(\n name,\n priority,\n key,\n options\n );\n\n var openTimestamp = null;\n\n var onOpen = function() {\n connection.unbind('open', onOpen);\n connection.bind('closed', onClosed);\n openTimestamp = Util.now();\n };\n var onClosed = closeEvent => {\n connection.unbind('closed', onClosed);\n\n if (closeEvent.code === 1002 || closeEvent.code === 1003) {\n // we don't want to use transports not obeying the protocol\n this.manager.reportDeath();\n } else if (!closeEvent.wasClean && openTimestamp) {\n // report deaths only for short-living transport\n var lifespan = Util.now() - openTimestamp;\n if (lifespan < 2 * this.maxPingDelay) {\n this.manager.reportDeath();\n this.pingDelay = Math.max(lifespan / 2, this.minPingDelay);\n }\n }\n };\n\n connection.bind('open', onOpen);\n return connection;\n }\n\n /** Returns whether the transport is supported in the environment.\n *\n * This function has the same API as Transport#isSupported. Might return false\n * when the manager decides to kill the transport.\n *\n * @param {Object} environment the environment details (encryption, settings)\n * @returns {Boolean} true when the transport is supported\n */\n isSupported(environment: string): boolean {\n return this.manager.isAlive() && this.transport.isSupported(environment);\n }\n}\n","import Action from './action';\nimport { PusherEvent } from './message-types';\n/**\n * Provides functions for handling Pusher protocol-specific messages.\n */\n\nconst Protocol = {\n /**\n * Decodes a message in a Pusher format.\n *\n * The MessageEvent we receive from the transport should contain a pusher event\n * (https://pusher.com/docs/pusher_protocol#events) serialized as JSON in the\n * data field\n *\n * The pusher event may contain a data field too, and it may also be\n * serialised as JSON\n *\n * Throws errors when messages are not parse'able.\n *\n * @param {MessageEvent} messageEvent\n * @return {PusherEvent}\n */\n decodeMessage: function(messageEvent: MessageEvent): PusherEvent {\n try {\n var messageData = JSON.parse(messageEvent.data);\n var pusherEventData = messageData.data;\n if (typeof pusherEventData === 'string') {\n try {\n pusherEventData = JSON.parse(messageData.data);\n } catch (e) {}\n }\n var pusherEvent: PusherEvent = {\n event: messageData.event,\n channel: messageData.channel,\n data: pusherEventData\n };\n if (messageData.user_id) {\n pusherEvent.user_id = messageData.user_id;\n }\n return pusherEvent;\n } catch (e) {\n throw { type: 'MessageParseError', error: e, data: messageEvent.data };\n }\n },\n\n /**\n * Encodes a message to be sent.\n *\n * @param {PusherEvent} event\n * @return {String}\n */\n encodeMessage: function(event: PusherEvent): string {\n return JSON.stringify(event);\n },\n\n /**\n * Processes a handshake message and returns appropriate actions.\n *\n * Returns an object with an 'action' and other action-specific properties.\n *\n * There are three outcomes when calling this function. First is a successful\n * connection attempt, when pusher:connection_established is received, which\n * results in a 'connected' action with an 'id' property. When passed a\n * pusher:error event, it returns a result with action appropriate to the\n * close code and an error. Otherwise, it raises an exception.\n *\n * @param {String} message\n * @result Object\n */\n processHandshake: function(messageEvent: MessageEvent): Action {\n var message = Protocol.decodeMessage(messageEvent);\n\n if (message.event === 'pusher:connection_established') {\n if (!message.data.activity_timeout) {\n throw 'No activity timeout specified in handshake';\n }\n return {\n action: 'connected',\n id: message.data.socket_id,\n activityTimeout: message.data.activity_timeout * 1000\n };\n } else if (message.event === 'pusher:error') {\n // From protocol 6 close codes are sent only once, so this only\n // happens when connection does not support close codes\n return {\n action: this.getCloseAction(message.data),\n error: this.getCloseError(message.data)\n };\n } else {\n throw 'Invalid handshake';\n }\n },\n\n /**\n * Dispatches the close event and returns an appropriate action name.\n *\n * See:\n * 1. https://developer.mozilla.org/en-US/docs/WebSockets/WebSockets_reference/CloseEvent\n * 2. http://pusher.com/docs/pusher_protocol\n *\n * @param {CloseEvent} closeEvent\n * @return {String} close action name\n */\n getCloseAction: function(closeEvent): string {\n if (closeEvent.code < 4000) {\n // ignore 1000 CLOSE_NORMAL, 1001 CLOSE_GOING_AWAY,\n // 1005 CLOSE_NO_STATUS, 1006 CLOSE_ABNORMAL\n // ignore 1007...3999\n // handle 1002 CLOSE_PROTOCOL_ERROR, 1003 CLOSE_UNSUPPORTED,\n // 1004 CLOSE_TOO_LARGE\n if (closeEvent.code >= 1002 && closeEvent.code <= 1004) {\n return 'backoff';\n } else {\n return null;\n }\n } else if (closeEvent.code === 4000) {\n return 'tls_only';\n } else if (closeEvent.code < 4100) {\n return 'refused';\n } else if (closeEvent.code < 4200) {\n return 'backoff';\n } else if (closeEvent.code < 4300) {\n return 'retry';\n } else {\n // unknown error\n return 'refused';\n }\n },\n\n /**\n * Returns an error or null basing on the close event.\n *\n * Null is returned when connection was closed cleanly. Otherwise, an object\n * with error details is returned.\n *\n * @param {CloseEvent} closeEvent\n * @return {Object} error object\n */\n getCloseError: function(closeEvent): any {\n if (closeEvent.code !== 1000 && closeEvent.code !== 1001) {\n return {\n type: 'PusherError',\n data: {\n code: closeEvent.code,\n message: closeEvent.reason || closeEvent.message\n }\n };\n } else {\n return null;\n }\n }\n};\n\nexport default Protocol;\n","import * as Collections from '../utils/collections';\nimport { default as EventsDispatcher } from '../events/dispatcher';\nimport Protocol from './protocol/protocol';\nimport { PusherEvent } from './protocol/message-types';\nimport Logger from '../logger';\nimport TransportConnection from '../transports/transport_connection';\nimport Socket from '../socket';\n/**\n * Provides Pusher protocol interface for transports.\n *\n * Emits following events:\n * - message - on received messages\n * - ping - on ping requests\n * - pong - on pong responses\n * - error - when the transport emits an error\n * - closed - after closing the transport\n *\n * It also emits more events when connection closes with a code.\n * See Protocol.getCloseAction to get more details.\n *\n * @param {Number} id\n * @param {AbstractTransport} transport\n */\nexport default class Connection extends EventsDispatcher implements Socket {\n id: string;\n transport: TransportConnection;\n activityTimeout: number;\n\n constructor(id: string, transport: TransportConnection) {\n super();\n this.id = id;\n this.transport = transport;\n this.activityTimeout = transport.activityTimeout;\n this.bindListeners();\n }\n\n /** Returns whether used transport handles activity checks by itself\n *\n * @returns {Boolean} true if activity checks are handled by the transport\n */\n handlesActivityChecks() {\n return this.transport.handlesActivityChecks();\n }\n\n /** Sends raw data.\n *\n * @param {String} data\n */\n send(data: any): boolean {\n return this.transport.send(data);\n }\n\n /** Sends an event.\n *\n * @param {String} name\n * @param {String} data\n * @param {String} [channel]\n * @returns {Boolean} whether message was sent or not\n */\n send_event(name: string, data: any, channel?: string): boolean {\n var event: PusherEvent = { event: name, data: data };\n if (channel) {\n event.channel = channel;\n }\n Logger.debug('Event sent', event);\n return this.send(Protocol.encodeMessage(event));\n }\n\n /** Sends a ping message to the server.\n *\n * Basing on the underlying transport, it might send either transport's\n * protocol-specific ping or pusher:ping event.\n */\n ping() {\n if (this.transport.supportsPing()) {\n this.transport.ping();\n } else {\n this.send_event('pusher:ping', {});\n }\n }\n\n /** Closes the connection. */\n close() {\n this.transport.close();\n }\n\n private bindListeners() {\n var listeners = {\n message: (messageEvent: MessageEvent) => {\n var pusherEvent;\n try {\n pusherEvent = Protocol.decodeMessage(messageEvent);\n } catch (e) {\n this.emit('error', {\n type: 'MessageParseError',\n error: e,\n data: messageEvent.data\n });\n }\n\n if (pusherEvent !== undefined) {\n Logger.debug('Event recd', pusherEvent);\n\n switch (pusherEvent.event) {\n case 'pusher:error':\n this.emit('error', {\n type: 'PusherError',\n data: pusherEvent.data\n });\n break;\n case 'pusher:ping':\n this.emit('ping');\n break;\n case 'pusher:pong':\n this.emit('pong');\n break;\n }\n this.emit('message', pusherEvent);\n }\n },\n activity: () => {\n this.emit('activity');\n },\n error: error => {\n this.emit('error', error);\n },\n closed: closeEvent => {\n unbindListeners();\n\n if (closeEvent && closeEvent.code) {\n this.handleCloseEvent(closeEvent);\n }\n\n this.transport = null;\n this.emit('closed');\n }\n };\n\n var unbindListeners = () => {\n Collections.objectApply(listeners, (listener, event) => {\n this.transport.unbind(event, listener);\n });\n };\n\n Collections.objectApply(listeners, (listener, event) => {\n this.transport.bind(event, listener);\n });\n }\n\n private handleCloseEvent(closeEvent: any) {\n var action = Protocol.getCloseAction(closeEvent);\n var error = Protocol.getCloseError(closeEvent);\n if (error) {\n this.emit('error', error);\n }\n if (action) {\n this.emit(action, { action: action, error: error });\n }\n }\n}\n","import Util from '../../util';\nimport * as Collections from '../../utils/collections';\nimport Protocol from '../protocol/protocol';\nimport Connection from '../connection';\nimport TransportConnection from '../../transports/transport_connection';\nimport HandshakePayload from './handshake_payload';\n\n/**\n * Handles Pusher protocol handshakes for transports.\n *\n * Calls back with a result object after handshake is completed. Results\n * always have two fields:\n * - action - string describing action to be taken after the handshake\n * - transport - the transport object passed to the constructor\n *\n * Different actions can set different additional properties on the result.\n * In the case of 'connected' action, there will be a 'connection' property\n * containing a Connection object for the transport. Other actions should\n * carry an 'error' property.\n *\n * @param {AbstractTransport} transport\n * @param {Function} callback\n */\nexport default class Handshake {\n transport: TransportConnection;\n callback: (HandshakePayload) => void;\n onMessage: Function;\n onClosed: Function;\n\n constructor(\n transport: TransportConnection,\n callback: (HandshakePayload) => void\n ) {\n this.transport = transport;\n this.callback = callback;\n this.bindListeners();\n }\n\n close() {\n this.unbindListeners();\n this.transport.close();\n }\n\n private bindListeners() {\n this.onMessage = m => {\n this.unbindListeners();\n\n var result;\n try {\n result = Protocol.processHandshake(m);\n } catch (e) {\n this.finish('error', { error: e });\n this.transport.close();\n return;\n }\n\n if (result.action === 'connected') {\n this.finish('connected', {\n connection: new Connection(result.id, this.transport),\n activityTimeout: result.activityTimeout\n });\n } else {\n this.finish(result.action, { error: result.error });\n this.transport.close();\n }\n };\n\n this.onClosed = closeEvent => {\n this.unbindListeners();\n\n var action = Protocol.getCloseAction(closeEvent) || 'backoff';\n var error = Protocol.getCloseError(closeEvent);\n this.finish(action, { error: error });\n };\n\n this.transport.bind('message', this.onMessage);\n this.transport.bind('closed', this.onClosed);\n }\n\n private unbindListeners() {\n this.transport.unbind('message', this.onMessage);\n this.transport.unbind('closed', this.onClosed);\n }\n\n private finish(action: string, params: any) {\n this.callback(\n Collections.extend({ transport: this.transport, action: action }, params)\n );\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport base64encode from '../base64';\nimport Timeline from './timeline';\nimport Runtime from 'runtime';\n\nexport interface TimelineSenderOptions {\n host?: string;\n port?: number;\n path?: string;\n}\n\nexport default class TimelineSender {\n timeline: Timeline;\n options: TimelineSenderOptions;\n host: string;\n\n constructor(timeline: Timeline, options: TimelineSenderOptions) {\n this.timeline = timeline;\n this.options = options || {};\n }\n\n send(useTLS: boolean, callback?: Function) {\n if (this.timeline.isEmpty()) {\n return;\n }\n\n this.timeline.send(\n Runtime.TimelineTransport.getAgent(this, useTLS),\n callback\n );\n }\n}\n","/** Error classes used throughout the library. */\n// https://github.com/Microsoft/TypeScript-wiki/blob/master/Breaking-Changes.md#extending-built-ins-like-error-array-and-map-may-no-longer-work\nexport class BadEventName extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\nexport class BadChannelName extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\nexport class RequestTimedOut extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class TransportPriorityTooLow extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class TransportClosed extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class UnsupportedFeature extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class UnsupportedTransport extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class UnsupportedStrategy extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class HTTPAuthError extends Error {\n status: number;\n constructor(status: number, msg?: string) {\n super(msg);\n this.status = status;\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n","/**\n * A place to store help URLs for error messages etc\n */\n\nconst urlStore = {\n baseUrl: 'https://pusher.com',\n urls: {\n authenticationEndpoint: {\n path: '/docs/channels/server_api/authenticating_users'\n },\n authorizationEndpoint: {\n path: '/docs/channels/server_api/authorizing-users/'\n },\n javascriptQuickStart: {\n path: '/docs/javascript_quick_start'\n },\n triggeringClientEvents: {\n path: '/docs/client_api_guide/client_events#trigger-events'\n },\n encryptedChannelSupport: {\n fullUrl:\n 'https://github.com/pusher/pusher-js/tree/cc491015371a4bde5743d1c87a0fbac0feb53195#encrypted-channel-support'\n }\n }\n};\n\n/** Builds a consistent string with links to pusher documentation\n *\n * @param {string} key - relevant key in the url_store.urls object\n * @return {string} suffix string to append to log message\n */\nconst buildLogSuffix = function(key: string): string {\n const urlPrefix = 'See:';\n const urlObj = urlStore.urls[key];\n if (!urlObj) return '';\n\n let url;\n if (urlObj.fullUrl) {\n url = urlObj.fullUrl;\n } else if (urlObj.path) {\n url = urlStore.baseUrl + urlObj.path;\n }\n\n if (!url) return '';\n return `${urlPrefix} ${url}`;\n};\n\nexport default { buildLogSuffix };\n","import { default as EventsDispatcher } from '../events/dispatcher';\nimport * as Errors from '../errors';\nimport Logger from '../logger';\nimport Pusher from '../pusher';\nimport { PusherEvent } from '../connection/protocol/message-types';\nimport Metadata from './metadata';\nimport UrlStore from '../utils/url_store';\nimport {\n ChannelAuthorizationData,\n ChannelAuthorizationCallback\n} from '../auth/options';\nimport { HTTPAuthError } from '../errors';\n\n/** Provides base public channel interface with an event emitter.\n *\n * Emits:\n * - pusher:subscription_succeeded - after subscribing successfully\n * - other non-internal events\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\nexport default class Channel extends EventsDispatcher {\n name: string;\n pusher: Pusher;\n subscribed: boolean;\n subscriptionPending: boolean;\n subscriptionCancelled: boolean;\n subscriptionCount: null;\n\n constructor(name: string, pusher: Pusher) {\n super(function(event, data) {\n Logger.debug('No callbacks on ' + name + ' for ' + event);\n });\n\n this.name = name;\n this.pusher = pusher;\n this.subscribed = false;\n this.subscriptionPending = false;\n this.subscriptionCancelled = false;\n }\n\n /** Skips authorization, since public channels don't require it.\n *\n * @param {Function} callback\n */\n authorize(socketId: string, callback: ChannelAuthorizationCallback) {\n return callback(null, { auth: '' });\n }\n\n /** Triggers an event */\n trigger(event: string, data: any) {\n if (event.indexOf('client-') !== 0) {\n throw new Errors.BadEventName(\n \"Event '\" + event + \"' does not start with 'client-'\"\n );\n }\n if (!this.subscribed) {\n var suffix = UrlStore.buildLogSuffix('triggeringClientEvents');\n Logger.warn(\n `Client event triggered before channel 'subscription_succeeded' event . ${suffix}`\n );\n }\n return this.pusher.send_event(event, data, this.name);\n }\n\n /** Signals disconnection to the channel. For internal use only. */\n disconnect() {\n this.subscribed = false;\n this.subscriptionPending = false;\n }\n\n /** Handles a PusherEvent. For internal use only.\n *\n * @param {PusherEvent} event\n */\n handleEvent(event: PusherEvent) {\n var eventName = event.event;\n var data = event.data;\n if (eventName === 'pusher_internal:subscription_succeeded') {\n this.handleSubscriptionSucceededEvent(event);\n } else if (eventName === 'pusher_internal:subscription_count') {\n this.handleSubscriptionCountEvent(event);\n } else if (eventName.indexOf('pusher_internal:') !== 0) {\n var metadata: Metadata = {};\n this.emit(eventName, data, metadata);\n }\n }\n\n handleSubscriptionSucceededEvent(event: PusherEvent) {\n this.subscriptionPending = false;\n this.subscribed = true;\n if (this.subscriptionCancelled) {\n this.pusher.unsubscribe(this.name);\n } else {\n this.emit('pusher:subscription_succeeded', event.data);\n }\n }\n\n handleSubscriptionCountEvent(event: PusherEvent) {\n if (event.data.subscription_count) {\n this.subscriptionCount = event.data.subscription_count;\n }\n\n this.emit('pusher:subscription_count', event.data);\n }\n\n /** Sends a subscription request. For internal use only. */\n subscribe() {\n if (this.subscribed) {\n return;\n }\n this.subscriptionPending = true;\n this.subscriptionCancelled = false;\n this.authorize(\n this.pusher.connection.socket_id,\n (error: Error | null, data: ChannelAuthorizationData) => {\n if (error) {\n this.subscriptionPending = false;\n // Why not bind to 'pusher:subscription_error' a level up, and log there?\n // Binding to this event would cause the warning about no callbacks being\n // bound (see constructor) to be suppressed, that's not what we want.\n Logger.error(error.toString());\n this.emit(\n 'pusher:subscription_error',\n Object.assign(\n {},\n {\n type: 'AuthError',\n error: error.message\n },\n error instanceof HTTPAuthError ? { status: error.status } : {}\n )\n );\n } else {\n this.pusher.send_event('pusher:subscribe', {\n auth: data.auth,\n channel_data: data.channel_data,\n channel: this.name\n });\n }\n }\n );\n }\n\n /** Sends an unsubscription request. For internal use only. */\n unsubscribe() {\n this.subscribed = false;\n this.pusher.send_event('pusher:unsubscribe', {\n channel: this.name\n });\n }\n\n /** Cancels an in progress subscription. For internal use only. */\n cancelSubscription() {\n this.subscriptionCancelled = true;\n }\n\n /** Reinstates an in progress subscripiton. For internal use only. */\n reinstateSubscription() {\n this.subscriptionCancelled = false;\n }\n}\n","import Factory from '../utils/factory';\nimport Channel from './channel';\nimport { ChannelAuthorizationCallback } from '../auth/options';\n\n/** Extends public channels to provide private channel interface.\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\nexport default class PrivateChannel extends Channel {\n /** Authorizes the connection to use the channel.\n *\n * @param {String} socketId\n * @param {Function} callback\n */\n authorize(socketId: string, callback: ChannelAuthorizationCallback) {\n return this.pusher.config.channelAuthorizer(\n {\n channelName: this.name,\n socketId: socketId\n },\n callback\n );\n }\n}\n","import * as Collections from '../utils/collections';\n\n/** Represents a collection of members of a presence channel. */\nexport default class Members {\n members: any;\n count: number;\n myID: any;\n me: any;\n\n constructor() {\n this.reset();\n }\n\n /** Returns member's info for given id.\n *\n * Resulting object containts two fields - id and info.\n *\n * @param {Number} id\n * @return {Object} member's info or null\n */\n get(id: string): any {\n if (Object.prototype.hasOwnProperty.call(this.members, id)) {\n return {\n id: id,\n info: this.members[id]\n };\n } else {\n return null;\n }\n }\n\n /** Calls back for each member in unspecified order.\n *\n * @param {Function} callback\n */\n each(callback: Function) {\n Collections.objectApply(this.members, (member, id) => {\n callback(this.get(id));\n });\n }\n\n /** Updates the id for connected member. For internal use only. */\n setMyID(id: string) {\n this.myID = id;\n }\n\n /** Handles subscription data. For internal use only. */\n onSubscription(subscriptionData: any) {\n this.members = subscriptionData.presence.hash;\n this.count = subscriptionData.presence.count;\n this.me = this.get(this.myID);\n }\n\n /** Adds a new member to the collection. For internal use only. */\n addMember(memberData: any) {\n if (this.get(memberData.user_id) === null) {\n this.count++;\n }\n this.members[memberData.user_id] = memberData.user_info;\n return this.get(memberData.user_id);\n }\n\n /** Adds a member from the collection. For internal use only. */\n removeMember(memberData: any) {\n var member = this.get(memberData.user_id);\n if (member) {\n delete this.members[memberData.user_id];\n this.count--;\n }\n return member;\n }\n\n /** Resets the collection to the initial state. For internal use only. */\n reset() {\n this.members = {};\n this.count = 0;\n this.myID = null;\n this.me = null;\n }\n}\n","import PrivateChannel from './private_channel';\nimport Logger from '../logger';\nimport Members from './members';\nimport Pusher from '../pusher';\nimport UrlStore from 'core/utils/url_store';\nimport { PusherEvent } from '../connection/protocol/message-types';\nimport Metadata from './metadata';\nimport { ChannelAuthorizationData } from '../auth/options';\n\nexport default class PresenceChannel extends PrivateChannel {\n members: Members;\n\n /** Adds presence channel functionality to private channels.\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\n constructor(name: string, pusher: Pusher) {\n super(name, pusher);\n this.members = new Members();\n }\n\n /** Authorizes the connection as a member of the channel.\n *\n * @param {String} socketId\n * @param {Function} callback\n */\n authorize(socketId: string, callback: Function) {\n super.authorize(socketId, async (error, authData) => {\n if (!error) {\n authData = authData as ChannelAuthorizationData;\n if (authData.channel_data != null) {\n var channelData = JSON.parse(authData.channel_data);\n this.members.setMyID(channelData.user_id);\n } else {\n await this.pusher.user.signinDonePromise;\n if (this.pusher.user.user_data != null) {\n // If the user is signed in, get the id of the authenticated user\n // and allow the presence authorization to continue.\n this.members.setMyID(this.pusher.user.user_data.id);\n } else {\n let suffix = UrlStore.buildLogSuffix('authorizationEndpoint');\n Logger.error(\n `Invalid auth response for channel '${this.name}', ` +\n `expected 'channel_data' field. ${suffix}, ` +\n `or the user should be signed in.`\n );\n callback('Invalid auth response');\n return;\n }\n }\n }\n callback(error, authData);\n });\n }\n\n /** Handles presence and subscription events. For internal use only.\n *\n * @param {PusherEvent} event\n */\n handleEvent(event: PusherEvent) {\n var eventName = event.event;\n if (eventName.indexOf('pusher_internal:') === 0) {\n this.handleInternalEvent(event);\n } else {\n var data = event.data;\n var metadata: Metadata = {};\n if (event.user_id) {\n metadata.user_id = event.user_id;\n }\n this.emit(eventName, data, metadata);\n }\n }\n handleInternalEvent(event: PusherEvent) {\n var eventName = event.event;\n var data = event.data;\n switch (eventName) {\n case 'pusher_internal:subscription_succeeded':\n this.handleSubscriptionSucceededEvent(event);\n break;\n case 'pusher_internal:subscription_count':\n this.handleSubscriptionCountEvent(event);\n break;\n case 'pusher_internal:member_added':\n var addedMember = this.members.addMember(data);\n this.emit('pusher:member_added', addedMember);\n break;\n case 'pusher_internal:member_removed':\n var removedMember = this.members.removeMember(data);\n if (removedMember) {\n this.emit('pusher:member_removed', removedMember);\n }\n break;\n }\n }\n\n handleSubscriptionSucceededEvent(event: PusherEvent) {\n this.subscriptionPending = false;\n this.subscribed = true;\n if (this.subscriptionCancelled) {\n this.pusher.unsubscribe(this.name);\n } else {\n this.members.onSubscription(event.data);\n this.emit('pusher:subscription_succeeded', this.members);\n }\n }\n\n /** Resets the channel state, including members map. For internal use only. */\n disconnect() {\n this.members.reset();\n super.disconnect();\n }\n}\n","import PrivateChannel from './private_channel';\nimport * as Errors from '../errors';\nimport Logger from '../logger';\nimport Pusher from '../pusher';\nimport { decode as encodeUTF8 } from '@stablelib/utf8';\nimport { decode as decodeBase64 } from '@stablelib/base64';\nimport Dispatcher from '../events/dispatcher';\nimport { PusherEvent } from '../connection/protocol/message-types';\nimport {\n ChannelAuthorizationData,\n ChannelAuthorizationCallback\n} from '../auth/options';\nimport * as nacl from 'tweetnacl';\n\n/** Extends private channels to provide encrypted channel interface.\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\nexport default class EncryptedChannel extends PrivateChannel {\n key: Uint8Array = null;\n nacl: nacl;\n\n constructor(name: string, pusher: Pusher, nacl: nacl) {\n super(name, pusher);\n this.nacl = nacl;\n }\n\n /** Authorizes the connection to use the channel.\n *\n * @param {String} socketId\n * @param {Function} callback\n */\n authorize(socketId: string, callback: ChannelAuthorizationCallback) {\n super.authorize(\n socketId,\n (error: Error | null, authData: ChannelAuthorizationData) => {\n if (error) {\n callback(error, authData);\n return;\n }\n let sharedSecret = authData['shared_secret'];\n if (!sharedSecret) {\n callback(\n new Error(\n `No shared_secret key in auth payload for encrypted channel: ${this.name}`\n ),\n null\n );\n return;\n }\n this.key = decodeBase64(sharedSecret);\n delete authData['shared_secret'];\n callback(null, authData);\n }\n );\n }\n\n trigger(event: string, data: any): boolean {\n throw new Errors.UnsupportedFeature(\n 'Client events are not currently supported for encrypted channels'\n );\n }\n\n /** Handles an event. For internal use only.\n *\n * @param {PusherEvent} event\n */\n handleEvent(event: PusherEvent) {\n var eventName = event.event;\n var data = event.data;\n if (\n eventName.indexOf('pusher_internal:') === 0 ||\n eventName.indexOf('pusher:') === 0\n ) {\n super.handleEvent(event);\n return;\n }\n this.handleEncryptedEvent(eventName, data);\n }\n\n private handleEncryptedEvent(event: string, data: any): void {\n if (!this.key) {\n Logger.debug(\n 'Received encrypted event before key has been retrieved from the authEndpoint'\n );\n return;\n }\n if (!data.ciphertext || !data.nonce) {\n Logger.error(\n 'Unexpected format for encrypted event, expected object with `ciphertext` and `nonce` fields, got: ' +\n data\n );\n return;\n }\n let cipherText = decodeBase64(data.ciphertext);\n if (cipherText.length < this.nacl.secretbox.overheadLength) {\n Logger.error(\n `Expected encrypted event ciphertext length to be ${this.nacl.secretbox.overheadLength}, got: ${cipherText.length}`\n );\n return;\n }\n let nonce = decodeBase64(data.nonce);\n if (nonce.length < this.nacl.secretbox.nonceLength) {\n Logger.error(\n `Expected encrypted event nonce length to be ${this.nacl.secretbox.nonceLength}, got: ${nonce.length}`\n );\n return;\n }\n\n let bytes = this.nacl.secretbox.open(cipherText, nonce, this.key);\n if (bytes === null) {\n Logger.debug(\n 'Failed to decrypt an event, probably because it was encrypted with a different key. Fetching a new key from the authEndpoint...'\n );\n // Try a single time to retrieve a new auth key and decrypt the event with it\n // If this fails, a new key will be requested when a new message is received\n this.authorize(this.pusher.connection.socket_id, (error, authData) => {\n if (error) {\n Logger.error(\n `Failed to make a request to the authEndpoint: ${authData}. Unable to fetch new key, so dropping encrypted event`\n );\n return;\n }\n bytes = this.nacl.secretbox.open(cipherText, nonce, this.key);\n if (bytes === null) {\n Logger.error(\n `Failed to decrypt event with new key. Dropping encrypted event`\n );\n return;\n }\n this.emit(event, this.getDataToEmit(bytes));\n return;\n });\n return;\n }\n this.emit(event, this.getDataToEmit(bytes));\n }\n\n // Try and parse the decrypted bytes as JSON. If we can't parse it, just\n // return the utf-8 string\n getDataToEmit(bytes: Uint8Array): string {\n let raw = encodeUTF8(bytes);\n try {\n return JSON.parse(raw);\n } catch {\n return raw;\n }\n }\n}\n","import { default as EventsDispatcher } from '../events/dispatcher';\nimport { OneOffTimer as Timer } from '../utils/timers';\nimport { Config } from '../config';\nimport Logger from '../logger';\nimport HandshakePayload from './handshake/handshake_payload';\nimport Connection from './connection';\nimport Strategy from '../strategies/strategy';\nimport StrategyRunner from '../strategies/strategy_runner';\nimport * as Collections from '../utils/collections';\nimport Timeline from '../timeline/timeline';\nimport ConnectionManagerOptions from './connection_manager_options';\nimport Runtime from 'runtime';\n\nimport {\n ErrorCallbacks,\n HandshakeCallbacks,\n ConnectionCallbacks\n} from './callbacks';\nimport Action from './protocol/action';\n\n/** Manages connection to Pusher.\n *\n * Uses a strategy (currently only default), timers and network availability\n * info to establish a connection and export its state. In case of failures,\n * manages reconnection attempts.\n *\n * Exports state changes as following events:\n * - \"state_change\", { previous: p, current: state }\n * - state\n *\n * States:\n * - initialized - initial state, never transitioned to\n * - connecting - connection is being established\n * - connected - connection has been fully established\n * - disconnected - on requested disconnection\n * - unavailable - after connection timeout or when there's no network\n * - failed - when the connection strategy is not supported\n *\n * Options:\n * - unavailableTimeout - time to transition to unavailable state\n * - activityTimeout - time after which ping message should be sent\n * - pongTimeout - time for Pusher to respond with pong before reconnecting\n *\n * @param {String} key application key\n * @param {Object} options\n */\nexport default class ConnectionManager extends EventsDispatcher {\n key: string;\n options: ConnectionManagerOptions;\n state: string;\n connection: Connection;\n usingTLS: boolean;\n timeline: Timeline;\n socket_id: string;\n unavailableTimer: Timer;\n activityTimer: Timer;\n retryTimer: Timer;\n activityTimeout: number;\n strategy: Strategy;\n runner: StrategyRunner;\n errorCallbacks: ErrorCallbacks;\n handshakeCallbacks: HandshakeCallbacks;\n connectionCallbacks: ConnectionCallbacks;\n\n constructor(key: string, options: ConnectionManagerOptions) {\n super();\n this.state = 'initialized';\n this.connection = null;\n\n this.key = key;\n this.options = options;\n this.timeline = this.options.timeline;\n this.usingTLS = this.options.useTLS;\n\n this.errorCallbacks = this.buildErrorCallbacks();\n this.connectionCallbacks = this.buildConnectionCallbacks(\n this.errorCallbacks\n );\n this.handshakeCallbacks = this.buildHandshakeCallbacks(this.errorCallbacks);\n\n var Network = Runtime.getNetwork();\n\n Network.bind('online', () => {\n this.timeline.info({ netinfo: 'online' });\n if (this.state === 'connecting' || this.state === 'unavailable') {\n this.retryIn(0);\n }\n });\n Network.bind('offline', () => {\n this.timeline.info({ netinfo: 'offline' });\n if (this.connection) {\n this.sendActivityCheck();\n }\n });\n\n this.updateStrategy();\n }\n\n switchCluster(key: string) {\n this.key = key;\n // This ensures that the new config coming from\n // pusher instance are taken into account\n // such as appKey and cluster\n this.updateStrategy();\n this.retryIn(0);\n }\n\n /** Establishes a connection to Pusher.\n *\n * Does nothing when connection is already established. See top-level doc\n * to find events emitted on connection attempts.\n */\n connect() {\n if (this.connection || this.runner) {\n return;\n }\n if (!this.strategy.isSupported()) {\n this.updateState('failed');\n return;\n }\n this.updateState('connecting');\n this.startConnecting();\n this.setUnavailableTimer();\n }\n\n /** Sends raw data.\n *\n * @param {String} data\n */\n send(data) {\n if (this.connection) {\n return this.connection.send(data);\n } else {\n return false;\n }\n }\n\n /** Sends an event.\n *\n * @param {String} name\n * @param {String} data\n * @param {String} [channel]\n * @returns {Boolean} whether message was sent or not\n */\n send_event(name: string, data: any, channel?: string) {\n if (this.connection) {\n return this.connection.send_event(name, data, channel);\n } else {\n return false;\n }\n }\n\n /** Closes the connection. */\n disconnect() {\n this.disconnectInternally();\n this.updateState('disconnected');\n }\n\n isUsingTLS() {\n return this.usingTLS;\n }\n\n private startConnecting() {\n var callback = (error, handshake) => {\n if (error) {\n this.runner = this.strategy.connect(0, callback);\n } else {\n if (handshake.action === 'error') {\n this.emit('error', {\n type: 'HandshakeError',\n error: handshake.error\n });\n this.timeline.error({ handshakeError: handshake.error });\n } else {\n this.abortConnecting(); // we don't support switching connections yet\n this.handshakeCallbacks[handshake.action](handshake);\n }\n }\n };\n this.runner = this.strategy.connect(0, callback);\n }\n\n private abortConnecting() {\n if (this.runner) {\n this.runner.abort();\n this.runner = null;\n }\n }\n\n private disconnectInternally() {\n this.abortConnecting();\n this.clearRetryTimer();\n this.clearUnavailableTimer();\n if (this.connection) {\n var connection = this.abandonConnection();\n connection.close();\n }\n }\n\n private updateStrategy() {\n this.strategy = this.options.getStrategy({\n key: this.key,\n timeline: this.timeline,\n useTLS: this.usingTLS\n });\n }\n\n private retryIn(delay) {\n this.timeline.info({ action: 'retry', delay: delay });\n if (delay > 0) {\n this.emit('connecting_in', Math.round(delay / 1000));\n }\n this.retryTimer = new Timer(delay || 0, () => {\n this.disconnectInternally();\n this.connect();\n });\n }\n\n private clearRetryTimer() {\n if (this.retryTimer) {\n this.retryTimer.ensureAborted();\n this.retryTimer = null;\n }\n }\n\n private setUnavailableTimer() {\n this.unavailableTimer = new Timer(this.options.unavailableTimeout, () => {\n this.updateState('unavailable');\n });\n }\n\n private clearUnavailableTimer() {\n if (this.unavailableTimer) {\n this.unavailableTimer.ensureAborted();\n }\n }\n\n private sendActivityCheck() {\n this.stopActivityCheck();\n this.connection.ping();\n // wait for pong response\n this.activityTimer = new Timer(this.options.pongTimeout, () => {\n this.timeline.error({ pong_timed_out: this.options.pongTimeout });\n this.retryIn(0);\n });\n }\n\n private resetActivityCheck() {\n this.stopActivityCheck();\n // send ping after inactivity\n if (this.connection && !this.connection.handlesActivityChecks()) {\n this.activityTimer = new Timer(this.activityTimeout, () => {\n this.sendActivityCheck();\n });\n }\n }\n\n private stopActivityCheck() {\n if (this.activityTimer) {\n this.activityTimer.ensureAborted();\n }\n }\n\n private buildConnectionCallbacks(\n errorCallbacks: ErrorCallbacks\n ): ConnectionCallbacks {\n return Collections.extend({}, errorCallbacks, {\n message: message => {\n // includes pong messages from server\n this.resetActivityCheck();\n this.emit('message', message);\n },\n ping: () => {\n this.send_event('pusher:pong', {});\n },\n activity: () => {\n this.resetActivityCheck();\n },\n error: error => {\n // just emit error to user - socket will already be closed by browser\n this.emit('error', error);\n },\n closed: () => {\n this.abandonConnection();\n if (this.shouldRetry()) {\n this.retryIn(1000);\n }\n }\n });\n }\n\n private buildHandshakeCallbacks(\n errorCallbacks: ErrorCallbacks\n ): HandshakeCallbacks {\n return Collections.extend({}, errorCallbacks, {\n connected: (handshake: HandshakePayload) => {\n this.activityTimeout = Math.min(\n this.options.activityTimeout,\n handshake.activityTimeout,\n handshake.connection.activityTimeout || Infinity\n );\n this.clearUnavailableTimer();\n this.setConnection(handshake.connection);\n this.socket_id = this.connection.id;\n this.updateState('connected', { socket_id: this.socket_id });\n }\n });\n }\n\n private buildErrorCallbacks(): ErrorCallbacks {\n let withErrorEmitted = callback => {\n return (result: Action | HandshakePayload) => {\n if (result.error) {\n this.emit('error', { type: 'WebSocketError', error: result.error });\n }\n callback(result);\n };\n };\n\n return {\n tls_only: withErrorEmitted(() => {\n this.usingTLS = true;\n this.updateStrategy();\n this.retryIn(0);\n }),\n refused: withErrorEmitted(() => {\n this.disconnect();\n }),\n backoff: withErrorEmitted(() => {\n this.retryIn(1000);\n }),\n retry: withErrorEmitted(() => {\n this.retryIn(0);\n })\n };\n }\n\n private setConnection(connection) {\n this.connection = connection;\n for (var event in this.connectionCallbacks) {\n this.connection.bind(event, this.connectionCallbacks[event]);\n }\n this.resetActivityCheck();\n }\n\n private abandonConnection() {\n if (!this.connection) {\n return;\n }\n this.stopActivityCheck();\n for (var event in this.connectionCallbacks) {\n this.connection.unbind(event, this.connectionCallbacks[event]);\n }\n var connection = this.connection;\n this.connection = null;\n return connection;\n }\n\n private updateState(newState: string, data?: any) {\n var previousState = this.state;\n this.state = newState;\n if (previousState !== newState) {\n var newStateDescription = newState;\n if (newStateDescription === 'connected') {\n newStateDescription += ' with new socket ID ' + data.socket_id;\n }\n Logger.debug(\n 'State changed',\n previousState + ' -> ' + newStateDescription\n );\n this.timeline.info({ state: newState, params: data });\n this.emit('state_change', { previous: previousState, current: newState });\n this.emit(newState, data);\n }\n }\n\n private shouldRetry(): boolean {\n return this.state === 'connecting' || this.state === 'connected';\n }\n}\n","import Channel from './channel';\nimport * as Collections from '../utils/collections';\nimport ChannelTable from './channel_table';\nimport Factory from '../utils/factory';\nimport Pusher from '../pusher';\nimport Logger from '../logger';\nimport * as Errors from '../errors';\nimport urlStore from '../utils/url_store';\n\n/** Handles a channel map. */\nexport default class Channels {\n channels: ChannelTable;\n\n constructor() {\n this.channels = {};\n }\n\n /** Creates or retrieves an existing channel by its name.\n *\n * @param {String} name\n * @param {Pusher} pusher\n * @return {Channel}\n */\n add(name: string, pusher: Pusher) {\n if (!this.channels[name]) {\n this.channels[name] = createChannel(name, pusher);\n }\n return this.channels[name];\n }\n\n /** Returns a list of all channels\n *\n * @return {Array}\n */\n all(): Channel[] {\n return Collections.values(this.channels);\n }\n\n /** Finds a channel by its name.\n *\n * @param {String} name\n * @return {Channel} channel or null if it doesn't exist\n */\n find(name: string) {\n return this.channels[name];\n }\n\n /** Removes a channel from the map.\n *\n * @param {String} name\n */\n remove(name: string) {\n var channel = this.channels[name];\n delete this.channels[name];\n return channel;\n }\n\n /** Proxies disconnection signal to all channels. */\n disconnect() {\n Collections.objectApply(this.channels, function(channel) {\n channel.disconnect();\n });\n }\n}\n\nfunction createChannel(name: string, pusher: Pusher): Channel {\n if (name.indexOf('private-encrypted-') === 0) {\n if (pusher.config.nacl) {\n return Factory.createEncryptedChannel(name, pusher, pusher.config.nacl);\n }\n let errMsg =\n 'Tried to subscribe to a private-encrypted- channel but no nacl implementation available';\n let suffix = urlStore.buildLogSuffix('encryptedChannelSupport');\n throw new Errors.UnsupportedFeature(`${errMsg}. ${suffix}`);\n } else if (name.indexOf('private-') === 0) {\n return Factory.createPrivateChannel(name, pusher);\n } else if (name.indexOf('presence-') === 0) {\n return Factory.createPresenceChannel(name, pusher);\n } else if (name.indexOf('#') === 0) {\n throw new Errors.BadChannelName(\n 'Cannot create a channel with name \"' + name + '\".'\n );\n } else {\n return Factory.createChannel(name, pusher);\n }\n}\n","import AssistantToTheTransportManager from '../transports/assistant_to_the_transport_manager';\nimport PingDelayOptions from '../transports/ping_delay_options';\nimport Transport from '../transports/transport';\nimport TransportManager from '../transports/transport_manager';\nimport Handshake from '../connection/handshake';\nimport TransportConnection from '../transports/transport_connection';\nimport SocketHooks from '../http/socket_hooks';\nimport HTTPSocket from '../http/http_socket';\n\nimport Timeline from '../timeline/timeline';\nimport {\n default as TimelineSender,\n TimelineSenderOptions\n} from '../timeline/timeline_sender';\nimport PresenceChannel from '../channels/presence_channel';\nimport PrivateChannel from '../channels/private_channel';\nimport EncryptedChannel from '../channels/encrypted_channel';\nimport Channel from '../channels/channel';\nimport ConnectionManager from '../connection/connection_manager';\nimport ConnectionManagerOptions from '../connection/connection_manager_options';\nimport Ajax from '../http/ajax';\nimport Channels from '../channels/channels';\nimport Pusher from '../pusher';\nimport { Config } from '../config';\nimport * as nacl from 'tweetnacl';\n\nvar Factory = {\n createChannels(): Channels {\n return new Channels();\n },\n\n createConnectionManager(\n key: string,\n options: ConnectionManagerOptions\n ): ConnectionManager {\n return new ConnectionManager(key, options);\n },\n\n createChannel(name: string, pusher: Pusher): Channel {\n return new Channel(name, pusher);\n },\n\n createPrivateChannel(name: string, pusher: Pusher): PrivateChannel {\n return new PrivateChannel(name, pusher);\n },\n\n createPresenceChannel(name: string, pusher: Pusher): PresenceChannel {\n return new PresenceChannel(name, pusher);\n },\n\n createEncryptedChannel(\n name: string,\n pusher: Pusher,\n nacl: nacl\n ): EncryptedChannel {\n return new EncryptedChannel(name, pusher, nacl);\n },\n\n createTimelineSender(timeline: Timeline, options: TimelineSenderOptions) {\n return new TimelineSender(timeline, options);\n },\n\n createHandshake(\n transport: TransportConnection,\n callback: (HandshakePayload) => void\n ): Handshake {\n return new Handshake(transport, callback);\n },\n\n createAssistantToTheTransportManager(\n manager: TransportManager,\n transport: Transport,\n options: PingDelayOptions\n ): AssistantToTheTransportManager {\n return new AssistantToTheTransportManager(manager, transport, options);\n }\n};\n\nexport default Factory;\n","import AssistantToTheTransportManager from './assistant_to_the_transport_manager';\nimport Transport from './transport';\nimport PingDelayOptions from './ping_delay_options';\nimport Factory from '../utils/factory';\n\nexport interface TransportManagerOptions extends PingDelayOptions {\n lives?: number;\n}\n\n/** Keeps track of the number of lives left for a transport.\n *\n * In the beginning of a session, transports may be assigned a number of\n * lives. When an AssistantToTheTransportManager instance reports a transport\n * connection closed uncleanly, the transport loses a life. When the number\n * of lives drops to zero, the transport gets disabled by its manager.\n *\n * @param {Object} options\n */\nexport default class TransportManager {\n options: TransportManagerOptions;\n livesLeft: number;\n\n constructor(options: TransportManagerOptions) {\n this.options = options || {};\n this.livesLeft = this.options.lives || Infinity;\n }\n\n /** Creates a assistant for the transport.\n *\n * @param {Transport} transport\n * @returns {AssistantToTheTransportManager}\n */\n getAssistant(transport: Transport): AssistantToTheTransportManager {\n return Factory.createAssistantToTheTransportManager(this, transport, {\n minPingDelay: this.options.minPingDelay,\n maxPingDelay: this.options.maxPingDelay\n });\n }\n\n /** Returns whether the transport has any lives left.\n *\n * @returns {Boolean}\n */\n isAlive(): boolean {\n return this.livesLeft > 0;\n }\n\n /** Takes one life from the transport. */\n reportDeath() {\n this.livesLeft -= 1;\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport { OneOffTimer as Timer } from '../utils/timers';\nimport Strategy from './strategy';\nimport StrategyOptions from './strategy_options';\n\n/** Loops through strategies with optional timeouts.\n *\n * Options:\n * - loop - whether it should loop through the substrategy list\n * - timeout - initial timeout for a single substrategy\n * - timeoutLimit - maximum timeout\n *\n * @param {Strategy[]} strategies\n * @param {Object} options\n */\nexport default class SequentialStrategy implements Strategy {\n strategies: Strategy[];\n loop: boolean;\n failFast: boolean;\n timeout: number;\n timeoutLimit: number;\n\n constructor(strategies: Strategy[], options: StrategyOptions) {\n this.strategies = strategies;\n this.loop = Boolean(options.loop);\n this.failFast = Boolean(options.failFast);\n this.timeout = options.timeout;\n this.timeoutLimit = options.timeoutLimit;\n }\n\n isSupported(): boolean {\n return Collections.any(this.strategies, Util.method('isSupported'));\n }\n\n connect(minPriority: number, callback: Function) {\n var strategies = this.strategies;\n var current = 0;\n var timeout = this.timeout;\n var runner = null;\n\n var tryNextStrategy = (error, handshake) => {\n if (handshake) {\n callback(null, handshake);\n } else {\n current = current + 1;\n if (this.loop) {\n current = current % strategies.length;\n }\n\n if (current < strategies.length) {\n if (timeout) {\n timeout = timeout * 2;\n if (this.timeoutLimit) {\n timeout = Math.min(timeout, this.timeoutLimit);\n }\n }\n runner = this.tryStrategy(\n strategies[current],\n minPriority,\n { timeout, failFast: this.failFast },\n tryNextStrategy\n );\n } else {\n callback(true);\n }\n }\n };\n\n runner = this.tryStrategy(\n strategies[current],\n minPriority,\n { timeout: timeout, failFast: this.failFast },\n tryNextStrategy\n );\n\n return {\n abort: function() {\n runner.abort();\n },\n forceMinPriority: function(p) {\n minPriority = p;\n if (runner) {\n runner.forceMinPriority(p);\n }\n }\n };\n }\n\n private tryStrategy(\n strategy: Strategy,\n minPriority: number,\n options: StrategyOptions,\n callback: Function\n ) {\n var timer = null;\n var runner = null;\n\n if (options.timeout > 0) {\n timer = new Timer(options.timeout, function() {\n runner.abort();\n callback(true);\n });\n }\n\n runner = strategy.connect(minPriority, function(error, handshake) {\n if (error && timer && timer.isRunning() && !options.failFast) {\n // advance to the next strategy after the timeout\n return;\n }\n if (timer) {\n timer.ensureAborted();\n }\n callback(error, handshake);\n });\n\n return {\n abort: function() {\n if (timer) {\n timer.ensureAborted();\n }\n runner.abort();\n },\n forceMinPriority: function(p) {\n runner.forceMinPriority(p);\n }\n };\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport Strategy from './strategy';\n\n/** Launches all substrategies and emits prioritized connected transports.\n *\n * @param {Array} strategies\n */\nexport default class BestConnectedEverStrategy implements Strategy {\n strategies: Strategy[];\n\n constructor(strategies: Strategy[]) {\n this.strategies = strategies;\n }\n\n isSupported(): boolean {\n return Collections.any(this.strategies, Util.method('isSupported'));\n }\n\n connect(minPriority: number, callback: Function) {\n return connect(this.strategies, minPriority, function(i, runners) {\n return function(error, handshake) {\n runners[i].error = error;\n if (error) {\n if (allRunnersFailed(runners)) {\n callback(true);\n }\n return;\n }\n Collections.apply(runners, function(runner) {\n runner.forceMinPriority(handshake.transport.priority);\n });\n callback(null, handshake);\n };\n });\n }\n}\n\n/** Connects to all strategies in parallel.\n *\n * Callback builder should be a function that takes two arguments: index\n * and a list of runners. It should return another function that will be\n * passed to the substrategy with given index. Runners can be aborted using\n * abortRunner(s) functions from this class.\n *\n * @param {Array} strategies\n * @param {Function} callbackBuilder\n * @return {Object} strategy runner\n */\nfunction connect(\n strategies: Strategy[],\n minPriority: number,\n callbackBuilder: Function\n) {\n var runners = Collections.map(strategies, function(strategy, i, _, rs) {\n return strategy.connect(minPriority, callbackBuilder(i, rs));\n });\n return {\n abort: function() {\n Collections.apply(runners, abortRunner);\n },\n forceMinPriority: function(p) {\n Collections.apply(runners, function(runner) {\n runner.forceMinPriority(p);\n });\n }\n };\n}\n\nfunction allRunnersFailed(runners): boolean {\n return Collections.all(runners, function(runner) {\n return Boolean(runner.error);\n });\n}\n\nfunction abortRunner(runner) {\n if (!runner.error && !runner.aborted) {\n runner.abort();\n runner.aborted = true;\n }\n}\n","import Util from '../util';\nimport Runtime from 'runtime';\nimport Strategy from './strategy';\nimport SequentialStrategy from './sequential_strategy';\nimport StrategyOptions from './strategy_options';\nimport TransportStrategy from './transport_strategy';\nimport Timeline from '../timeline/timeline';\nimport * as Collections from '../utils/collections';\n\nexport interface TransportStrategyDictionary {\n [key: string]: TransportStrategy;\n}\n\n/** Caches the last successful transport and, after the first few attempts,\n * uses the cached transport for subsequent attempts.\n *\n * @param {Strategy} strategy\n * @param {Object} transports\n * @param {Object} options\n */\nexport default class WebSocketPrioritizedCachedStrategy implements Strategy {\n strategy: Strategy;\n transports: TransportStrategyDictionary;\n ttl: number;\n usingTLS: boolean;\n timeline: Timeline;\n\n constructor(\n strategy: Strategy,\n transports: TransportStrategyDictionary,\n options: StrategyOptions\n ) {\n this.strategy = strategy;\n this.transports = transports;\n this.ttl = options.ttl || 1800 * 1000;\n this.usingTLS = options.useTLS;\n this.timeline = options.timeline;\n }\n\n isSupported(): boolean {\n return this.strategy.isSupported();\n }\n\n connect(minPriority: number, callback: Function) {\n var usingTLS = this.usingTLS;\n var info = fetchTransportCache(usingTLS);\n var cacheSkipCount = info && info.cacheSkipCount ? info.cacheSkipCount : 0;\n\n var strategies = [this.strategy];\n if (info && info.timestamp + this.ttl >= Util.now()) {\n var transport = this.transports[info.transport];\n if (transport) {\n if (['ws', 'wss'].includes(info.transport) || cacheSkipCount > 3) {\n this.timeline.info({\n cached: true,\n transport: info.transport,\n latency: info.latency\n });\n strategies.push(\n new SequentialStrategy([transport], {\n timeout: info.latency * 2 + 1000,\n failFast: true\n })\n );\n } else {\n cacheSkipCount++;\n }\n }\n }\n\n var startTimestamp = Util.now();\n var runner = strategies\n .pop()\n .connect(minPriority, function cb(error, handshake) {\n if (error) {\n flushTransportCache(usingTLS);\n if (strategies.length > 0) {\n startTimestamp = Util.now();\n runner = strategies.pop().connect(minPriority, cb);\n } else {\n callback(error);\n }\n } else {\n storeTransportCache(\n usingTLS,\n handshake.transport.name,\n Util.now() - startTimestamp,\n cacheSkipCount\n );\n callback(null, handshake);\n }\n });\n\n return {\n abort: function() {\n runner.abort();\n },\n forceMinPriority: function(p) {\n minPriority = p;\n if (runner) {\n runner.forceMinPriority(p);\n }\n }\n };\n }\n}\n\nfunction getTransportCacheKey(usingTLS: boolean): string {\n return 'pusherTransport' + (usingTLS ? 'TLS' : 'NonTLS');\n}\n\nfunction fetchTransportCache(usingTLS: boolean): any {\n var storage = Runtime.getLocalStorage();\n if (storage) {\n try {\n var serializedCache = storage[getTransportCacheKey(usingTLS)];\n if (serializedCache) {\n return JSON.parse(serializedCache);\n }\n } catch (e) {\n flushTransportCache(usingTLS);\n }\n }\n return null;\n}\n\nfunction storeTransportCache(\n usingTLS: boolean,\n transport: TransportStrategy,\n latency: number,\n cacheSkipCount: number\n) {\n var storage = Runtime.getLocalStorage();\n if (storage) {\n try {\n storage[getTransportCacheKey(usingTLS)] = Collections.safeJSONStringify({\n timestamp: Util.now(),\n transport: transport,\n latency: latency,\n cacheSkipCount: cacheSkipCount\n });\n } catch (e) {\n // catch over quota exceptions raised by localStorage\n }\n }\n}\n\nfunction flushTransportCache(usingTLS: boolean) {\n var storage = Runtime.getLocalStorage();\n if (storage) {\n try {\n delete storage[getTransportCacheKey(usingTLS)];\n } catch (e) {\n // catch exceptions raised by localStorage\n }\n }\n}\n","import { OneOffTimer as Timer } from '../utils/timers';\nimport Strategy from './strategy';\nimport StrategyOptions from './strategy_options';\n\n/** Runs substrategy after specified delay.\n *\n * Options:\n * - delay - time in miliseconds to delay the substrategy attempt\n *\n * @param {Strategy} strategy\n * @param {Object} options\n */\nexport default class DelayedStrategy implements Strategy {\n strategy: Strategy;\n options: { delay: number };\n\n constructor(strategy: Strategy, { delay: number }) {\n this.strategy = strategy;\n this.options = { delay: number };\n }\n\n isSupported(): boolean {\n return this.strategy.isSupported();\n }\n\n connect(minPriority: number, callback: Function) {\n var strategy = this.strategy;\n var runner;\n var timer = new Timer(this.options.delay, function() {\n runner = strategy.connect(minPriority, callback);\n });\n\n return {\n abort: function() {\n timer.ensureAborted();\n if (runner) {\n runner.abort();\n }\n },\n forceMinPriority: function(p) {\n minPriority = p;\n if (runner) {\n runner.forceMinPriority(p);\n }\n }\n };\n }\n}\n","import Strategy from './strategy';\nimport StrategyRunner from './strategy_runner';\n\n/** Proxies method calls to one of substrategies basing on the test function.\n *\n * @param {Function} test\n * @param {Strategy} trueBranch strategy used when test returns true\n * @param {Strategy} falseBranch strategy used when test returns false\n */\nexport default class IfStrategy implements Strategy {\n test: () => boolean;\n trueBranch: Strategy;\n falseBranch: Strategy;\n\n constructor(\n test: () => boolean,\n trueBranch: Strategy,\n falseBranch: Strategy\n ) {\n this.test = test;\n this.trueBranch = trueBranch;\n this.falseBranch = falseBranch;\n }\n\n isSupported(): boolean {\n var branch = this.test() ? this.trueBranch : this.falseBranch;\n return branch.isSupported();\n }\n\n connect(minPriority: number, callback: Function): StrategyRunner {\n var branch = this.test() ? this.trueBranch : this.falseBranch;\n return branch.connect(minPriority, callback);\n }\n}\n","import Strategy from './strategy';\nimport StrategyRunner from './strategy_runner';\n\n/** Launches the substrategy and terminates on the first open connection.\n *\n * @param {Strategy} strategy\n */\nexport default class FirstConnectedStrategy implements Strategy {\n strategy: Strategy;\n\n constructor(strategy: Strategy) {\n this.strategy = strategy;\n }\n\n isSupported(): boolean {\n return this.strategy.isSupported();\n }\n\n connect(minPriority: number, callback: Function): StrategyRunner {\n var runner = this.strategy.connect(minPriority, function(error, handshake) {\n if (handshake) {\n runner.abort();\n }\n callback(error, handshake);\n });\n return runner;\n }\n}\n","import * as Collections from 'core/utils/collections';\nimport TransportManager from 'core/transports/transport_manager';\nimport Strategy from 'core/strategies/strategy';\nimport SequentialStrategy from 'core/strategies/sequential_strategy';\nimport BestConnectedEverStrategy from 'core/strategies/best_connected_ever_strategy';\nimport WebSocketPrioritizedCachedStrategy, {\n TransportStrategyDictionary\n} from 'core/strategies/websocket_prioritized_cached_strategy';\nimport DelayedStrategy from 'core/strategies/delayed_strategy';\nimport IfStrategy from 'core/strategies/if_strategy';\nimport FirstConnectedStrategy from 'core/strategies/first_connected_strategy';\nimport { Config } from 'core/config';\nimport StrategyOptions from 'core/strategies/strategy_options';\n\nfunction testSupportsStrategy(strategy: Strategy) {\n return function() {\n return strategy.isSupported();\n };\n}\n\nvar getDefaultStrategy = function(\n config: Config,\n baseOptions: StrategyOptions,\n defineTransport: Function\n): Strategy {\n var definedTransports = {};\n\n function defineTransportStrategy(\n name: string,\n type: string,\n priority: number,\n options: StrategyOptions,\n manager?: TransportManager\n ) {\n var transport = defineTransport(\n config,\n name,\n type,\n priority,\n options,\n manager\n );\n\n definedTransports[name] = transport;\n\n return transport;\n }\n\n var ws_options: StrategyOptions = Object.assign({}, baseOptions, {\n hostNonTLS: config.wsHost + ':' + config.wsPort,\n hostTLS: config.wsHost + ':' + config.wssPort,\n httpPath: config.wsPath\n });\n var wss_options: StrategyOptions = Collections.extend({}, ws_options, {\n useTLS: true\n });\n var http_options: StrategyOptions = Object.assign({}, baseOptions, {\n hostNonTLS: config.httpHost + ':' + config.httpPort,\n hostTLS: config.httpHost + ':' + config.httpsPort,\n httpPath: config.httpPath\n });\n var timeouts = {\n loop: true,\n timeout: 15000,\n timeoutLimit: 60000\n };\n\n var ws_manager = new TransportManager({\n minPingDelay: 10000,\n maxPingDelay: config.activityTimeout\n });\n var streaming_manager = new TransportManager({\n lives: 2,\n minPingDelay: 10000,\n maxPingDelay: config.activityTimeout\n });\n\n var ws_transport = defineTransportStrategy(\n 'ws',\n 'ws',\n 3,\n ws_options,\n ws_manager\n );\n var wss_transport = defineTransportStrategy(\n 'wss',\n 'ws',\n 3,\n wss_options,\n ws_manager\n );\n var xhr_streaming_transport = defineTransportStrategy(\n 'xhr_streaming',\n 'xhr_streaming',\n 1,\n http_options,\n streaming_manager\n );\n var xhr_polling_transport = defineTransportStrategy(\n 'xhr_polling',\n 'xhr_polling',\n 1,\n http_options\n );\n\n var ws_loop = new SequentialStrategy([ws_transport], timeouts);\n var wss_loop = new SequentialStrategy([wss_transport], timeouts);\n var streaming_loop = new SequentialStrategy(\n [xhr_streaming_transport],\n timeouts\n );\n var polling_loop = new SequentialStrategy([xhr_polling_transport], timeouts);\n\n var http_loop = new SequentialStrategy(\n [\n new IfStrategy(\n testSupportsStrategy(streaming_loop),\n new BestConnectedEverStrategy([\n streaming_loop,\n new DelayedStrategy(polling_loop, { delay: 4000 })\n ]),\n polling_loop\n )\n ],\n timeouts\n );\n\n var wsStrategy;\n if (baseOptions.useTLS) {\n wsStrategy = new BestConnectedEverStrategy([\n ws_loop,\n new DelayedStrategy(http_loop, { delay: 2000 })\n ]);\n } else {\n wsStrategy = new BestConnectedEverStrategy([\n ws_loop,\n new DelayedStrategy(wss_loop, { delay: 2000 }),\n new DelayedStrategy(http_loop, { delay: 5000 })\n ]);\n }\n\n return new WebSocketPrioritizedCachedStrategy(\n new FirstConnectedStrategy(\n new IfStrategy(testSupportsStrategy(ws_transport), wsStrategy, http_loop)\n ),\n definedTransports,\n {\n ttl: 1800000,\n timeline: baseOptions.timeline,\n useTLS: baseOptions.useTLS\n }\n );\n};\n\nexport default getDefaultStrategy;\n","/** Initializes the transport.\n *\n * Fetches resources if needed and then transitions to initialized.\n */\nexport default function() {\n var self = this;\n\n self.timeline.info(\n self.buildTimelineMessage({\n transport: self.name + (self.options.useTLS ? 's' : '')\n })\n );\n\n if (self.hooks.isInitialized()) {\n self.changeState('initialized');\n } else {\n self.onClose();\n }\n}\n","import Runtime from 'runtime';\nimport RequestHooks from './request_hooks';\nimport Ajax from './ajax';\nimport { default as EventsDispatcher } from '../events/dispatcher';\n\nconst MAX_BUFFER_LENGTH = 256 * 1024;\n\nexport default class HTTPRequest extends EventsDispatcher {\n hooks: RequestHooks;\n method: string;\n url: string;\n position: number;\n xhr: Ajax;\n unloader: Function;\n\n constructor(hooks: RequestHooks, method: string, url: string) {\n super();\n this.hooks = hooks;\n this.method = method;\n this.url = url;\n }\n\n start(payload?: any) {\n this.position = 0;\n this.xhr = this.hooks.getRequest(this);\n\n this.unloader = () => {\n this.close();\n };\n Runtime.addUnloadListener(this.unloader);\n\n this.xhr.open(this.method, this.url, true);\n\n if (this.xhr.setRequestHeader) {\n this.xhr.setRequestHeader('Content-Type', 'application/json'); // ReactNative doesn't set this header by default.\n }\n this.xhr.send(payload);\n }\n\n close() {\n if (this.unloader) {\n Runtime.removeUnloadListener(this.unloader);\n this.unloader = null;\n }\n if (this.xhr) {\n this.hooks.abortRequest(this.xhr);\n this.xhr = null;\n }\n }\n\n onChunk(status: number, data: any) {\n while (true) {\n var chunk = this.advanceBuffer(data);\n if (chunk) {\n this.emit('chunk', { status: status, data: chunk });\n } else {\n break;\n }\n }\n if (this.isBufferTooLong(data)) {\n this.emit('buffer_too_long');\n }\n }\n\n private advanceBuffer(buffer: any[]): any {\n var unreadData = buffer.slice(this.position);\n var endOfLinePosition = unreadData.indexOf('\\n');\n\n if (endOfLinePosition !== -1) {\n this.position += endOfLinePosition + 1;\n return unreadData.slice(0, endOfLinePosition);\n } else {\n // chunk is not finished yet, don't move the buffer pointer\n return null;\n }\n }\n\n private isBufferTooLong(buffer: any): boolean {\n return this.position === buffer.length && buffer.length > MAX_BUFFER_LENGTH;\n }\n}\n","enum State {\n CONNECTING = 0,\n OPEN = 1,\n CLOSED = 3\n}\n\nexport default State;\n","import URLLocation from './url_location';\nimport State from './state';\nimport Socket from '../socket';\nimport SocketHooks from './socket_hooks';\nimport Util from '../util';\nimport Ajax from './ajax';\nimport HTTPRequest from './http_request';\nimport Runtime from 'runtime';\n\nvar autoIncrement = 1;\n\nclass HTTPSocket implements Socket {\n hooks: SocketHooks;\n session: string;\n location: URLLocation;\n readyState: State;\n stream: HTTPRequest;\n\n onopen: () => void;\n onerror: (error: any) => void;\n onclose: (closeEvent: any) => void;\n onmessage: (message: any) => void;\n onactivity: () => void;\n\n constructor(hooks: SocketHooks, url: string) {\n this.hooks = hooks;\n this.session = randomNumber(1000) + '/' + randomString(8);\n this.location = getLocation(url);\n this.readyState = State.CONNECTING;\n this.openStream();\n }\n\n send(payload: any) {\n return this.sendRaw(JSON.stringify([payload]));\n }\n\n ping() {\n this.hooks.sendHeartbeat(this);\n }\n\n close(code: any, reason: any) {\n this.onClose(code, reason, true);\n }\n\n /** For internal use only */\n sendRaw(payload: any): boolean {\n if (this.readyState === State.OPEN) {\n try {\n Runtime.createSocketRequest(\n 'POST',\n getUniqueURL(getSendURL(this.location, this.session))\n ).start(payload);\n return true;\n } catch (e) {\n return false;\n }\n } else {\n return false;\n }\n }\n\n /** For internal use only */\n reconnect() {\n this.closeStream();\n this.openStream();\n }\n\n /** For internal use only */\n onClose(code, reason, wasClean) {\n this.closeStream();\n this.readyState = State.CLOSED;\n if (this.onclose) {\n this.onclose({\n code: code,\n reason: reason,\n wasClean: wasClean\n });\n }\n }\n\n private onChunk(chunk) {\n if (chunk.status !== 200) {\n return;\n }\n if (this.readyState === State.OPEN) {\n this.onActivity();\n }\n\n var payload;\n var type = chunk.data.slice(0, 1);\n switch (type) {\n case 'o':\n payload = JSON.parse(chunk.data.slice(1) || '{}');\n this.onOpen(payload);\n break;\n case 'a':\n payload = JSON.parse(chunk.data.slice(1) || '[]');\n for (var i = 0; i < payload.length; i++) {\n this.onEvent(payload[i]);\n }\n break;\n case 'm':\n payload = JSON.parse(chunk.data.slice(1) || 'null');\n this.onEvent(payload);\n break;\n case 'h':\n this.hooks.onHeartbeat(this);\n break;\n case 'c':\n payload = JSON.parse(chunk.data.slice(1) || '[]');\n this.onClose(payload[0], payload[1], true);\n break;\n }\n }\n\n private onOpen(options) {\n if (this.readyState === State.CONNECTING) {\n if (options && options.hostname) {\n this.location.base = replaceHost(this.location.base, options.hostname);\n }\n this.readyState = State.OPEN;\n\n if (this.onopen) {\n this.onopen();\n }\n } else {\n this.onClose(1006, 'Server lost session', true);\n }\n }\n\n private onEvent(event) {\n if (this.readyState === State.OPEN && this.onmessage) {\n this.onmessage({ data: event });\n }\n }\n\n private onActivity() {\n if (this.onactivity) {\n this.onactivity();\n }\n }\n\n private onError(error) {\n if (this.onerror) {\n this.onerror(error);\n }\n }\n\n private openStream() {\n this.stream = Runtime.createSocketRequest(\n 'POST',\n getUniqueURL(this.hooks.getReceiveURL(this.location, this.session))\n );\n\n this.stream.bind('chunk', chunk => {\n this.onChunk(chunk);\n });\n this.stream.bind('finished', status => {\n this.hooks.onFinished(this, status);\n });\n this.stream.bind('buffer_too_long', () => {\n this.reconnect();\n });\n\n try {\n this.stream.start();\n } catch (error) {\n Util.defer(() => {\n this.onError(error);\n this.onClose(1006, 'Could not start streaming', false);\n });\n }\n }\n\n private closeStream() {\n if (this.stream) {\n this.stream.unbind_all();\n this.stream.close();\n this.stream = null;\n }\n }\n}\n\nfunction getLocation(url): URLLocation {\n var parts = /([^\\?]*)\\/*(\\??.*)/.exec(url);\n return {\n base: parts[1],\n queryString: parts[2]\n };\n}\n\nfunction getSendURL(url: URLLocation, session: string): string {\n return url.base + '/' + session + '/xhr_send';\n}\n\nfunction getUniqueURL(url: string): string {\n var separator = url.indexOf('?') === -1 ? '?' : '&';\n return url + separator + 't=' + +new Date() + '&n=' + autoIncrement++;\n}\n\nfunction replaceHost(url: string, hostname: string): string {\n var urlParts = /(https?:\\/\\/)([^\\/:]+)((\\/|:)?.*)/.exec(url);\n return urlParts[1] + hostname + urlParts[3];\n}\n\nfunction randomNumber(max: number): number {\n return Runtime.randomInt(max);\n}\n\nfunction randomString(length: number): string {\n var result = [];\n\n for (var i = 0; i < length; i++) {\n result.push(randomNumber(32).toString(32));\n }\n\n return result.join('');\n}\n\nexport default HTTPSocket;\n","import SocketHooks from './socket_hooks';\nimport HTTPSocket from './http_socket';\n\nvar hooks: SocketHooks = {\n getReceiveURL: function(url, session) {\n return url.base + '/' + session + '/xhr_streaming' + url.queryString;\n },\n onHeartbeat: function(socket) {\n socket.sendRaw('[]');\n },\n sendHeartbeat: function(socket) {\n socket.sendRaw('[]');\n },\n onFinished: function(socket, status) {\n socket.onClose(1006, 'Connection interrupted (' + status + ')', false);\n }\n};\n\nexport default hooks;\n","import SocketHooks from './socket_hooks';\nimport URLLocation from './url_location';\nimport HTTPSocket from './http_socket';\n\nvar hooks: SocketHooks = {\n getReceiveURL: function(url: URLLocation, session: string): string {\n return url.base + '/' + session + '/xhr' + url.queryString;\n },\n onHeartbeat: function() {\n // next HTTP request will reset server's activity timer\n },\n sendHeartbeat: function(socket) {\n socket.sendRaw('[]');\n },\n onFinished: function(socket, status) {\n if (status === 200) {\n socket.reconnect();\n } else {\n socket.onClose(1006, 'Connection interrupted (' + status + ')', false);\n }\n }\n};\n\nexport default hooks;\n","import HTTPRequest from 'core/http/http_request';\nimport RequestHooks from 'core/http/request_hooks';\nimport Ajax from 'core/http/ajax';\nimport Runtime from 'runtime';\n\nvar hooks: RequestHooks = {\n getRequest: function(socket: HTTPRequest): Ajax {\n var Constructor = Runtime.getXHRAPI();\n var xhr = new Constructor();\n xhr.onreadystatechange = xhr.onprogress = function() {\n switch (xhr.readyState) {\n case 3:\n if (xhr.responseText && xhr.responseText.length > 0) {\n socket.onChunk(xhr.status, xhr.responseText);\n }\n break;\n case 4:\n // this happens only on errors, never after calling close\n if (xhr.responseText && xhr.responseText.length > 0) {\n socket.onChunk(xhr.status, xhr.responseText);\n }\n socket.emit('finished', xhr.status);\n socket.close();\n break;\n }\n };\n return xhr;\n },\n abortRequest: function(xhr: Ajax) {\n xhr.onreadystatechange = null;\n xhr.abort();\n }\n};\n\nexport default hooks;\n","import HTTPRequest from 'core/http/http_request';\nimport HTTPSocket from 'core/http/http_socket';\nimport SocketHooks from 'core/http/socket_hooks';\nimport RequestHooks from 'core/http/request_hooks';\nimport streamingHooks from 'core/http/http_streaming_socket';\nimport pollingHooks from 'core/http/http_polling_socket';\nimport xhrHooks from './http_xhr_request';\nimport HTTPFactory from 'core/http/http_factory';\n\nvar HTTP: HTTPFactory = {\n createStreamingSocket(url: string): HTTPSocket {\n return this.createSocket(streamingHooks, url);\n },\n\n createPollingSocket(url: string): HTTPSocket {\n return this.createSocket(pollingHooks, url);\n },\n\n createSocket(hooks: SocketHooks, url: string): HTTPSocket {\n return new HTTPSocket(hooks, url);\n },\n\n createXHR(method: string, url: string): HTTPRequest {\n return this.createRequest(xhrHooks, method, url);\n },\n\n createRequest(hooks: RequestHooks, method: string, url: string): HTTPRequest {\n return new HTTPRequest(hooks, method, url);\n }\n};\n\nexport default HTTP;\n","import * as Collections from 'core/utils/collections';\nimport Transports from 'isomorphic/transports/transports';\nimport TimelineSender from 'core/timeline/timeline_sender';\nimport Ajax from 'core/http/ajax';\nimport getDefaultStrategy from './default_strategy';\nimport TransportsTable from 'core/transports/transports_table';\nimport transportConnectionInitializer from './transports/transport_connection_initializer';\nimport HTTPFactory from './http/http';\n\nvar Isomorphic: any = {\n getDefaultStrategy,\n Transports: Transports,\n transportConnectionInitializer,\n HTTPFactory,\n\n setup(PusherClass): void {\n PusherClass.ready();\n },\n\n getLocalStorage(): any {\n return undefined;\n },\n\n getClientFeatures(): any[] {\n return Collections.keys(\n Collections.filterObject({ ws: Transports.ws }, function(t) {\n return t.isSupported({});\n })\n );\n },\n\n getProtocol(): string {\n return 'http:';\n },\n\n isXHRSupported(): boolean {\n return true;\n },\n\n createSocketRequest(method: string, url: string) {\n if (this.isXHRSupported()) {\n return this.HTTPFactory.createXHR(method, url);\n } else {\n throw 'Cross-origin HTTP requests are not supported';\n }\n },\n\n createXHR(): Ajax {\n var Constructor = this.getXHRAPI();\n return new Constructor();\n },\n\n createWebSocket(url: string): any {\n var Constructor = this.getWebSocketAPI();\n return new Constructor(url);\n },\n\n addUnloadListener(listener: any) {},\n removeUnloadListener(listener: any) {}\n};\n\nexport default Isomorphic;\n","import { default as EventsDispatcher } from 'core/events/dispatcher';\nimport Reachability from 'core/reachability';\n\nexport class NetInfo extends EventsDispatcher implements Reachability {\n isOnline(): boolean {\n return true;\n }\n}\n\nexport var Network = new NetInfo();\n","export enum AuthRequestType {\n UserAuthentication = 'user-authentication',\n ChannelAuthorization = 'channel-authorization'\n}\n\nexport interface ChannelAuthorizationData {\n auth: string;\n channel_data?: string;\n shared_secret?: string;\n}\n\nexport type ChannelAuthorizationCallback = (\n error: Error | null,\n authData: ChannelAuthorizationData | null\n) => void;\n\nexport interface ChannelAuthorizationRequestParams {\n socketId: string;\n channelName: string;\n}\n\nexport interface ChannelAuthorizationHandler {\n (\n params: ChannelAuthorizationRequestParams,\n callback: ChannelAuthorizationCallback\n ): void;\n}\n\nexport interface UserAuthenticationData {\n auth: string;\n user_data: string;\n}\n\nexport type UserAuthenticationCallback = (\n error: Error | null,\n authData: UserAuthenticationData | null\n) => void;\n\nexport interface UserAuthenticationRequestParams {\n socketId: string;\n}\n\nexport interface UserAuthenticationHandler {\n (\n params: UserAuthenticationRequestParams,\n callback: UserAuthenticationCallback\n ): void;\n}\n\nexport type AuthTransportCallback =\n | ChannelAuthorizationCallback\n | UserAuthenticationCallback;\n\nexport interface AuthOptionsT {\n transport: 'ajax' | 'jsonp';\n endpoint: string;\n params?: any;\n headers?: any;\n paramsProvider?: () => any;\n headersProvider?: () => any;\n customHandler?: AuthHandler;\n}\n\nexport declare type UserAuthenticationOptions = AuthOptionsT<\n UserAuthenticationHandler\n>;\nexport declare type ChannelAuthorizationOptions = AuthOptionsT<\n ChannelAuthorizationHandler\n>;\n\nexport interface InternalAuthOptions {\n transport: 'ajax' | 'jsonp';\n endpoint: string;\n params?: any;\n headers?: any;\n paramsProvider?: () => any;\n headersProvider?: () => any;\n}\n","import TimelineSender from 'core/timeline/timeline_sender';\nimport * as Collections from 'core/utils/collections';\nimport Util from 'core/util';\nimport Runtime from 'runtime';\nimport { AuthTransport } from 'core/auth/auth_transports';\nimport AbstractRuntime from 'runtimes/interface';\nimport UrlStore from 'core/utils/url_store';\nimport {\n AuthRequestType,\n AuthTransportCallback,\n InternalAuthOptions\n} from 'core/auth/options';\nimport { HTTPAuthError } from 'core/errors';\n\nconst ajax: AuthTransport = function(\n context: AbstractRuntime,\n query: string,\n authOptions: InternalAuthOptions,\n authRequestType: AuthRequestType,\n callback: AuthTransportCallback\n) {\n const xhr = Runtime.createXHR();\n xhr.open('POST', authOptions.endpoint, true);\n\n // add request headers\n xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');\n for (var headerName in authOptions.headers) {\n xhr.setRequestHeader(headerName, authOptions.headers[headerName]);\n }\n if (authOptions.headersProvider != null) {\n let dynamicHeaders = authOptions.headersProvider();\n for (var headerName in dynamicHeaders) {\n xhr.setRequestHeader(headerName, dynamicHeaders[headerName]);\n }\n }\n\n xhr.onreadystatechange = function() {\n if (xhr.readyState === 4) {\n if (xhr.status === 200) {\n let data;\n let parsed = false;\n\n try {\n data = JSON.parse(xhr.responseText);\n parsed = true;\n } catch (e) {\n callback(\n new HTTPAuthError(\n 200,\n `JSON returned from ${authRequestType.toString()} endpoint was invalid, yet status code was 200. Data was: ${\n xhr.responseText\n }`\n ),\n null\n );\n }\n\n if (parsed) {\n // prevents double execution.\n callback(null, data);\n }\n } else {\n let suffix = '';\n switch (authRequestType) {\n case AuthRequestType.UserAuthentication:\n suffix = UrlStore.buildLogSuffix('authenticationEndpoint');\n break;\n case AuthRequestType.ChannelAuthorization:\n suffix = `Clients must be authorized to join private or presence channels. ${UrlStore.buildLogSuffix(\n 'authorizationEndpoint'\n )}`;\n break;\n }\n callback(\n new HTTPAuthError(\n xhr.status,\n `Unable to retrieve auth string from ${authRequestType.toString()} endpoint - ` +\n `received status: ${xhr.status} from ${authOptions.endpoint}. ${suffix}`\n ),\n null\n );\n }\n }\n };\n\n xhr.send(query);\n return xhr;\n};\n\nexport default ajax;\n","import Logger from 'core/logger';\nimport TimelineSender from 'core/timeline/timeline_sender';\nimport * as Collections from 'core/utils/collections';\nimport Util from 'core/util';\nimport Runtime from 'runtime';\nimport TimelineTransport from 'core/timeline/timeline_transport';\n\nvar getAgent = function(sender: TimelineSender, useTLS: boolean) {\n return function(data: any, callback: Function) {\n var scheme = 'http' + (useTLS ? 's' : '') + '://';\n var url =\n scheme + (sender.host || sender.options.host) + sender.options.path;\n var query = Collections.buildQueryString(data);\n\n url += '/' + 2 + '?' + query;\n\n var xhr = Runtime.createXHR();\n xhr.open('GET', url, true);\n\n xhr.onreadystatechange = function() {\n if (xhr.readyState === 4) {\n let { status, responseText } = xhr;\n if (status !== 200) {\n Logger.debug(\n `TimelineSender Error: received ${status} from stats.pusher.com`\n );\n return;\n }\n\n try {\n var { host } = JSON.parse(responseText);\n } catch (e) {\n Logger.debug(`TimelineSenderError: invalid response ${responseText}`);\n }\n if (host) {\n sender.host = host;\n }\n }\n };\n\n xhr.send();\n };\n};\n\nvar xhr = {\n name: 'xhr',\n getAgent\n};\n\nexport default xhr;\n","import Isomorphic from 'isomorphic/runtime';\nimport { Client as WebSocket } from 'faye-websocket';\nimport { XMLHttpRequest } from 'xmlhttprequest';\nimport Runtime from '../interface';\nimport { Network } from './net_info';\nimport xhrAuth from 'isomorphic/auth/xhr_auth';\nimport { AuthTransports } from 'core/auth/auth_transports';\nimport xhrTimeline from 'isomorphic/timeline/xhr_timeline';\nimport { randomInt } from 'crypto';\n\n// Very verbose but until unavoidable until\n// TypeScript 2.1, when spread attributes will be\n// supported\nconst {\n getDefaultStrategy,\n Transports,\n setup,\n getProtocol,\n isXHRSupported,\n getLocalStorage,\n createXHR,\n createWebSocket,\n addUnloadListener,\n removeUnloadListener,\n transportConnectionInitializer,\n createSocketRequest,\n HTTPFactory\n} = Isomorphic;\n\nconst NodeJS: Runtime = {\n getDefaultStrategy,\n Transports,\n setup,\n getProtocol,\n isXHRSupported,\n createSocketRequest,\n getLocalStorage,\n createXHR,\n createWebSocket,\n addUnloadListener,\n removeUnloadListener,\n transportConnectionInitializer,\n HTTPFactory,\n\n TimelineTransport: xhrTimeline,\n\n getAuthorizers(): AuthTransports {\n return { ajax: xhrAuth };\n },\n\n getWebSocketAPI() {\n return WebSocket;\n },\n\n getXHRAPI() {\n return XMLHttpRequest;\n },\n\n getNetwork() {\n return Network;\n },\n\n randomInt(max: number): number {\n return randomInt(max);\n }\n};\n\nexport default NodeJS;\n","enum TimelineLevel {\n ERROR = 3,\n INFO = 6,\n DEBUG = 7\n}\n\nexport default TimelineLevel;\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport { default as Level } from './level';\n\nexport interface TimelineOptions {\n level?: Level;\n limit?: number;\n version?: string;\n cluster?: string;\n features?: string[];\n params?: any;\n}\n\nexport default class Timeline {\n key: string;\n session: number;\n events: any[];\n options: TimelineOptions;\n sent: number;\n uniqueID: number;\n\n constructor(key: string, session: number, options: TimelineOptions) {\n this.key = key;\n this.session = session;\n this.events = [];\n this.options = options || {};\n this.sent = 0;\n this.uniqueID = 0;\n }\n\n log(level, event) {\n if (level <= this.options.level) {\n this.events.push(\n Collections.extend({}, event, { timestamp: Util.now() })\n );\n if (this.options.limit && this.events.length > this.options.limit) {\n this.events.shift();\n }\n }\n }\n\n error(event) {\n this.log(Level.ERROR, event);\n }\n\n info(event) {\n this.log(Level.INFO, event);\n }\n\n debug(event) {\n this.log(Level.DEBUG, event);\n }\n\n isEmpty() {\n return this.events.length === 0;\n }\n\n send(sendfn, callback) {\n var data = Collections.extend(\n {\n session: this.session,\n bundle: this.sent + 1,\n key: this.key,\n lib: 'js',\n version: this.options.version,\n cluster: this.options.cluster,\n features: this.options.features,\n timeline: this.events\n },\n this.options.params\n );\n\n this.events = [];\n sendfn(data, (error, result) => {\n if (!error) {\n this.sent++;\n }\n if (callback) {\n callback(error, result);\n }\n });\n\n return true;\n }\n\n generateUniqueID(): number {\n this.uniqueID++;\n return this.uniqueID;\n }\n}\n","import Factory from '../utils/factory';\nimport Util from '../util';\nimport * as Errors from '../errors';\nimport * as Collections from '../utils/collections';\nimport Strategy from './strategy';\nimport Transport from '../transports/transport';\nimport StrategyOptions from './strategy_options';\nimport Handshake from '../connection/handshake';\n\n/** Provides a strategy interface for transports.\n *\n * @param {String} name\n * @param {Number} priority\n * @param {Class} transport\n * @param {Object} options\n */\nexport default class TransportStrategy implements Strategy {\n name: string;\n priority: number;\n transport: Transport;\n options: StrategyOptions;\n\n constructor(\n name: string,\n priority: number,\n transport: Transport,\n options: StrategyOptions\n ) {\n this.name = name;\n this.priority = priority;\n this.transport = transport;\n this.options = options || {};\n }\n\n /** Returns whether the transport is supported in the browser.\n *\n * @returns {Boolean}\n */\n isSupported(): boolean {\n return this.transport.isSupported({\n useTLS: this.options.useTLS\n });\n }\n\n /** Launches a connection attempt and returns a strategy runner.\n *\n * @param {Function} callback\n * @return {Object} strategy runner\n */\n connect(minPriority: number, callback: Function) {\n if (!this.isSupported()) {\n return failAttempt(new Errors.UnsupportedStrategy(), callback);\n } else if (this.priority < minPriority) {\n return failAttempt(new Errors.TransportPriorityTooLow(), callback);\n }\n\n var connected = false;\n var transport = this.transport.createConnection(\n this.name,\n this.priority,\n this.options.key,\n this.options\n );\n var handshake = null;\n\n var onInitialized = function() {\n transport.unbind('initialized', onInitialized);\n transport.connect();\n };\n var onOpen = function() {\n handshake = Factory.createHandshake(transport, function(result) {\n connected = true;\n unbindListeners();\n callback(null, result);\n });\n };\n var onError = function(error) {\n unbindListeners();\n callback(error);\n };\n var onClosed = function() {\n unbindListeners();\n var serializedTransport;\n\n // The reason for this try/catch block is that on React Native\n // the WebSocket object is circular. Therefore transport.socket will\n // throw errors upon stringification. Collections.safeJSONStringify\n // discards circular references when serializing.\n serializedTransport = Collections.safeJSONStringify(transport);\n callback(new Errors.TransportClosed(serializedTransport));\n };\n\n var unbindListeners = function() {\n transport.unbind('initialized', onInitialized);\n transport.unbind('open', onOpen);\n transport.unbind('error', onError);\n transport.unbind('closed', onClosed);\n };\n\n transport.bind('initialized', onInitialized);\n transport.bind('open', onOpen);\n transport.bind('error', onError);\n transport.bind('closed', onClosed);\n\n // connect will be called automatically after initialization\n transport.initialize();\n\n return {\n abort: () => {\n if (connected) {\n return;\n }\n unbindListeners();\n if (handshake) {\n handshake.close();\n } else {\n transport.close();\n }\n },\n forceMinPriority: p => {\n if (connected) {\n return;\n }\n if (this.priority < p) {\n if (handshake) {\n handshake.close();\n } else {\n transport.close();\n }\n }\n }\n };\n }\n}\n\nfunction failAttempt(error: Error, callback: Function) {\n Util.defer(function() {\n callback(error);\n });\n return {\n abort: function() {},\n forceMinPriority: function() {}\n };\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport TransportManager from '../transports/transport_manager';\nimport * as Errors from '../errors';\nimport Strategy from './strategy';\nimport TransportStrategy from './transport_strategy';\nimport StrategyOptions from '../strategies/strategy_options';\nimport { Config } from '../config';\nimport Runtime from 'runtime';\n\nconst { Transports } = Runtime;\n\nexport var defineTransport = function(\n config: Config,\n name: string,\n type: string,\n priority: number,\n options: StrategyOptions,\n manager?: TransportManager\n): Strategy {\n var transportClass = Transports[type];\n if (!transportClass) {\n throw new Errors.UnsupportedTransport(type);\n }\n\n var enabled =\n (!config.enabledTransports ||\n Collections.arrayIndexOf(config.enabledTransports, name) !== -1) &&\n (!config.disabledTransports ||\n Collections.arrayIndexOf(config.disabledTransports, name) === -1);\n\n var transport;\n if (enabled) {\n options = Object.assign(\n { ignoreNullOrigin: config.ignoreNullOrigin },\n options\n );\n\n transport = new TransportStrategy(\n name,\n priority,\n manager ? manager.getAssistant(transportClass) : transportClass,\n options\n );\n } else {\n transport = UnsupportedStrategy;\n }\n\n return transport;\n};\n\nvar UnsupportedStrategy: Strategy = {\n isSupported: function() {\n return false;\n },\n connect: function(_, callback) {\n var deferred = Util.defer(function() {\n callback(new Errors.UnsupportedStrategy());\n });\n return {\n abort: function() {\n deferred.ensureAborted();\n },\n forceMinPriority: function() {}\n };\n }\n};\n","import ConnectionManager from './connection/connection_manager';\nimport {\n ChannelAuthorizationOptions,\n UserAuthenticationOptions\n} from './auth/options';\nimport {\n ChannelAuthorizerGenerator,\n DeprecatedAuthOptions\n} from './auth/deprecated_channel_authorizer';\nimport { AuthTransport, Transport } from './config';\nimport * as nacl from 'tweetnacl';\nimport Logger from './logger';\n\nexport interface Options {\n activityTimeout?: number;\n\n auth?: DeprecatedAuthOptions; // DEPRECATED use channelAuthorization instead\n authEndpoint?: string; // DEPRECATED use channelAuthorization instead\n authTransport?: AuthTransport; // DEPRECATED use channelAuthorization instead\n authorizer?: ChannelAuthorizerGenerator; // DEPRECATED use channelAuthorization instead\n\n channelAuthorization?: ChannelAuthorizationOptions;\n userAuthentication?: UserAuthenticationOptions;\n\n cluster: string;\n enableStats?: boolean;\n disableStats?: boolean;\n disabledTransports?: Transport[];\n enabledTransports?: Transport[];\n forceTLS?: boolean;\n httpHost?: string;\n httpPath?: string;\n httpPort?: number;\n httpsPort?: number;\n ignoreNullOrigin?: boolean;\n nacl?: nacl;\n pongTimeout?: number;\n statsHost?: string;\n timelineParams?: any;\n unavailableTimeout?: number;\n wsHost?: string;\n wsPath?: string;\n wsPort?: number;\n wssPort?: number;\n}\n\nexport interface ClusterOptions {\n appKey: string;\n cluster: string;\n}\n\nexport function validateOptions(options) {\n if (options == null) {\n throw 'You must pass an options object';\n }\n if (options.cluster == null) {\n throw 'Options object must provide a cluster';\n }\n if ('disableStats' in options) {\n Logger.warn(\n 'The disableStats option is deprecated in favor of enableStats'\n );\n }\n}\n","import {\n UserAuthenticationCallback,\n InternalAuthOptions,\n UserAuthenticationHandler,\n UserAuthenticationRequestParams,\n AuthRequestType\n} from './options';\n\nimport Runtime from 'runtime';\n\nconst composeChannelQuery = (\n params: UserAuthenticationRequestParams,\n authOptions: InternalAuthOptions\n) => {\n var query = 'socket_id=' + encodeURIComponent(params.socketId);\n\n for (var key in authOptions.params) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(authOptions.params[key]);\n }\n\n if (authOptions.paramsProvider != null) {\n let dynamicParams = authOptions.paramsProvider();\n for (var key in dynamicParams) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(dynamicParams[key]);\n }\n }\n\n return query;\n};\n\nconst UserAuthenticator = (\n authOptions: InternalAuthOptions\n): UserAuthenticationHandler => {\n if (typeof Runtime.getAuthorizers()[authOptions.transport] === 'undefined') {\n throw `'${authOptions.transport}' is not a recognized auth transport`;\n }\n\n return (\n params: UserAuthenticationRequestParams,\n callback: UserAuthenticationCallback\n ) => {\n const query = composeChannelQuery(params, authOptions);\n\n Runtime.getAuthorizers()[authOptions.transport](\n Runtime,\n query,\n authOptions,\n AuthRequestType.UserAuthentication,\n callback\n );\n };\n};\n\nexport default UserAuthenticator;\n","import {\n AuthRequestType,\n InternalAuthOptions,\n ChannelAuthorizationHandler,\n ChannelAuthorizationRequestParams,\n ChannelAuthorizationCallback\n} from './options';\n\nimport Runtime from 'runtime';\n\nconst composeChannelQuery = (\n params: ChannelAuthorizationRequestParams,\n authOptions: InternalAuthOptions\n) => {\n var query = 'socket_id=' + encodeURIComponent(params.socketId);\n\n query += '&channel_name=' + encodeURIComponent(params.channelName);\n\n for (var key in authOptions.params) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(authOptions.params[key]);\n }\n\n if (authOptions.paramsProvider != null) {\n let dynamicParams = authOptions.paramsProvider();\n for (var key in dynamicParams) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(dynamicParams[key]);\n }\n }\n\n return query;\n};\n\nconst ChannelAuthorizer = (\n authOptions: InternalAuthOptions\n): ChannelAuthorizationHandler => {\n if (typeof Runtime.getAuthorizers()[authOptions.transport] === 'undefined') {\n throw `'${authOptions.transport}' is not a recognized auth transport`;\n }\n\n return (\n params: ChannelAuthorizationRequestParams,\n callback: ChannelAuthorizationCallback\n ) => {\n const query = composeChannelQuery(params, authOptions);\n\n Runtime.getAuthorizers()[authOptions.transport](\n Runtime,\n query,\n authOptions,\n AuthRequestType.ChannelAuthorization,\n callback\n );\n };\n};\n\nexport default ChannelAuthorizer;\n","import Channel from '../channels/channel';\nimport {\n ChannelAuthorizationCallback,\n ChannelAuthorizationHandler,\n ChannelAuthorizationRequestParams,\n InternalAuthOptions\n} from './options';\n\nexport interface DeprecatedChannelAuthorizer {\n authorize(socketId: string, callback: ChannelAuthorizationCallback): void;\n}\n\nexport interface ChannelAuthorizerGenerator {\n (\n channel: Channel,\n options: DeprecatedAuthorizerOptions\n ): DeprecatedChannelAuthorizer;\n}\n\nexport interface DeprecatedAuthOptions {\n params?: any;\n headers?: any;\n}\n\nexport interface DeprecatedAuthorizerOptions {\n authTransport: 'ajax' | 'jsonp';\n authEndpoint: string;\n auth?: DeprecatedAuthOptions;\n}\n\nexport const ChannelAuthorizerProxy = (\n pusher,\n authOptions: InternalAuthOptions,\n channelAuthorizerGenerator: ChannelAuthorizerGenerator\n): ChannelAuthorizationHandler => {\n const deprecatedAuthorizerOptions: DeprecatedAuthorizerOptions = {\n authTransport: authOptions.transport,\n authEndpoint: authOptions.endpoint,\n auth: {\n params: authOptions.params,\n headers: authOptions.headers\n }\n };\n return (\n params: ChannelAuthorizationRequestParams,\n callback: ChannelAuthorizationCallback\n ) => {\n const channel = pusher.channel(params.channelName);\n // This line creates a new channel authorizer every time.\n // In the past, this was only done once per channel and reused.\n // We can do that again if we want to keep this behavior intact.\n const channelAuthorizer: DeprecatedChannelAuthorizer = channelAuthorizerGenerator(\n channel,\n deprecatedAuthorizerOptions\n );\n channelAuthorizer.authorize(params.socketId, callback);\n };\n};\n","import { Options } from './options';\nimport Defaults from './defaults';\nimport {\n ChannelAuthorizationHandler,\n UserAuthenticationHandler,\n ChannelAuthorizationOptions\n} from './auth/options';\nimport UserAuthenticator from './auth/user_authenticator';\nimport ChannelAuthorizer from './auth/channel_authorizer';\nimport { ChannelAuthorizerProxy } from './auth/deprecated_channel_authorizer';\nimport Runtime from 'runtime';\nimport * as nacl from 'tweetnacl';\n\nexport type AuthTransport = 'ajax' | 'jsonp';\nexport type Transport =\n | 'ws'\n | 'wss'\n | 'xhr_streaming'\n | 'xhr_polling'\n | 'sockjs';\n\nexport interface Config {\n // these are all 'required' config parameters, it's not necessary for the user\n // to set them, but they have configured defaults.\n activityTimeout: number;\n enableStats: boolean;\n httpHost: string;\n httpPath: string;\n httpPort: number;\n httpsPort: number;\n pongTimeout: number;\n statsHost: string;\n unavailableTimeout: number;\n useTLS: boolean;\n wsHost: string;\n wsPath: string;\n wsPort: number;\n wssPort: number;\n userAuthenticator: UserAuthenticationHandler;\n channelAuthorizer: ChannelAuthorizationHandler;\n\n // these are all optional parameters or overrrides. The customer can set these\n // but it's not strictly necessary\n forceTLS?: boolean;\n cluster?: string;\n disabledTransports?: Transport[];\n enabledTransports?: Transport[];\n ignoreNullOrigin?: boolean;\n nacl?: nacl;\n timelineParams?: any;\n}\n\n// getConfig mainly sets the defaults for the options that are not provided\nexport function getConfig(opts: Options, pusher): Config {\n let config: Config = {\n activityTimeout: opts.activityTimeout || Defaults.activityTimeout,\n cluster: opts.cluster,\n httpPath: opts.httpPath || Defaults.httpPath,\n httpPort: opts.httpPort || Defaults.httpPort,\n httpsPort: opts.httpsPort || Defaults.httpsPort,\n pongTimeout: opts.pongTimeout || Defaults.pongTimeout,\n statsHost: opts.statsHost || Defaults.stats_host,\n unavailableTimeout: opts.unavailableTimeout || Defaults.unavailableTimeout,\n wsPath: opts.wsPath || Defaults.wsPath,\n wsPort: opts.wsPort || Defaults.wsPort,\n wssPort: opts.wssPort || Defaults.wssPort,\n\n enableStats: getEnableStatsConfig(opts),\n httpHost: getHttpHost(opts),\n useTLS: shouldUseTLS(opts),\n wsHost: getWebsocketHost(opts),\n\n userAuthenticator: buildUserAuthenticator(opts),\n channelAuthorizer: buildChannelAuthorizer(opts, pusher)\n };\n\n if ('disabledTransports' in opts)\n config.disabledTransports = opts.disabledTransports;\n if ('enabledTransports' in opts)\n config.enabledTransports = opts.enabledTransports;\n if ('ignoreNullOrigin' in opts)\n config.ignoreNullOrigin = opts.ignoreNullOrigin;\n if ('timelineParams' in opts) config.timelineParams = opts.timelineParams;\n if ('nacl' in opts) {\n config.nacl = opts.nacl;\n }\n\n return config;\n}\n\nfunction getHttpHost(opts: Options): string {\n if (opts.httpHost) {\n return opts.httpHost;\n }\n if (opts.cluster) {\n return `sockjs-${opts.cluster}.pusher.com`;\n }\n return Defaults.httpHost;\n}\n\nfunction getWebsocketHost(opts: Options): string {\n if (opts.wsHost) {\n return opts.wsHost;\n }\n return getWebsocketHostFromCluster(opts.cluster);\n}\n\nfunction getWebsocketHostFromCluster(cluster: string): string {\n return `ws-${cluster}.pusher.com`;\n}\n\nfunction shouldUseTLS(opts: Options): boolean {\n if (Runtime.getProtocol() === 'https:') {\n return true;\n } else if (opts.forceTLS === false) {\n return false;\n }\n return true;\n}\n\n// if enableStats is set take the value\n// if disableStats is set take the inverse\n// otherwise default to false\nfunction getEnableStatsConfig(opts: Options): boolean {\n if ('enableStats' in opts) {\n return opts.enableStats;\n }\n if ('disableStats' in opts) {\n return !opts.disableStats;\n }\n return false;\n}\n\nfunction buildUserAuthenticator(opts: Options): UserAuthenticationHandler {\n const userAuthentication = {\n ...Defaults.userAuthentication,\n ...opts.userAuthentication\n };\n if (\n 'customHandler' in userAuthentication &&\n userAuthentication['customHandler'] != null\n ) {\n return userAuthentication['customHandler'];\n }\n\n return UserAuthenticator(userAuthentication);\n}\n\nfunction buildChannelAuth(opts: Options, pusher): ChannelAuthorizationOptions {\n let channelAuthorization: ChannelAuthorizationOptions;\n if ('channelAuthorization' in opts) {\n channelAuthorization = {\n ...Defaults.channelAuthorization,\n ...opts.channelAuthorization\n };\n } else {\n channelAuthorization = {\n transport: opts.authTransport || Defaults.authTransport,\n endpoint: opts.authEndpoint || Defaults.authEndpoint\n };\n if ('auth' in opts) {\n if ('params' in opts.auth) channelAuthorization.params = opts.auth.params;\n if ('headers' in opts.auth)\n channelAuthorization.headers = opts.auth.headers;\n }\n if ('authorizer' in opts)\n channelAuthorization.customHandler = ChannelAuthorizerProxy(\n pusher,\n channelAuthorization,\n opts.authorizer\n );\n }\n return channelAuthorization;\n}\n\nfunction buildChannelAuthorizer(\n opts: Options,\n pusher\n): ChannelAuthorizationHandler {\n const channelAuthorization = buildChannelAuth(opts, pusher);\n if (\n 'customHandler' in channelAuthorization &&\n channelAuthorization['customHandler'] != null\n ) {\n return channelAuthorization['customHandler'];\n }\n\n return ChannelAuthorizer(channelAuthorization);\n}\n","import Logger from './logger';\nimport Pusher from './pusher';\nimport EventsDispatcher from './events/dispatcher';\n\nexport default class WatchlistFacade extends EventsDispatcher {\n private pusher: Pusher;\n\n public constructor(pusher: Pusher) {\n super(function(eventName, data) {\n Logger.debug(`No callbacks on watchlist events for ${eventName}`);\n });\n\n this.pusher = pusher;\n this.bindWatchlistInternalEvent();\n }\n\n handleEvent(pusherEvent) {\n pusherEvent.data.events.forEach(watchlistEvent => {\n this.emit(watchlistEvent.name, watchlistEvent);\n });\n }\n\n private bindWatchlistInternalEvent() {\n this.pusher.connection.bind('message', pusherEvent => {\n var eventName = pusherEvent.event;\n if (eventName === 'pusher_internal:watchlist_events') {\n this.handleEvent(pusherEvent);\n }\n });\n }\n}\n","function flatPromise() {\n let resolve, reject;\n const promise = new Promise((res, rej) => {\n resolve = res;\n reject = rej;\n });\n return { promise, resolve, reject };\n}\n\nexport default flatPromise;\n","import Pusher from './pusher';\nimport Logger from './logger';\nimport {\n UserAuthenticationData,\n UserAuthenticationCallback\n} from './auth/options';\nimport Channel from './channels/channel';\nimport WatchlistFacade from './watchlist';\nimport EventsDispatcher from './events/dispatcher';\nimport flatPromise from './utils/flat_promise';\n\nexport default class UserFacade extends EventsDispatcher {\n pusher: Pusher;\n signin_requested: boolean = false;\n user_data: any = null;\n serverToUserChannel: Channel = null;\n signinDonePromise: Promise = null;\n watchlist: WatchlistFacade;\n private _signinDoneResolve: Function = null;\n\n public constructor(pusher: Pusher) {\n super(function(eventName, data) {\n Logger.debug('No callbacks on user for ' + eventName);\n });\n this.pusher = pusher;\n this.pusher.connection.bind('state_change', ({ previous, current }) => {\n if (previous !== 'connected' && current === 'connected') {\n this._signin();\n }\n if (previous === 'connected' && current !== 'connected') {\n this._cleanup();\n this._newSigninPromiseIfNeeded();\n }\n });\n\n this.watchlist = new WatchlistFacade(pusher);\n\n this.pusher.connection.bind('message', event => {\n var eventName = event.event;\n if (eventName === 'pusher:signin_success') {\n this._onSigninSuccess(event.data);\n }\n if (\n this.serverToUserChannel &&\n this.serverToUserChannel.name === event.channel\n ) {\n this.serverToUserChannel.handleEvent(event);\n }\n });\n }\n\n public signin() {\n if (this.signin_requested) {\n return;\n }\n\n this.signin_requested = true;\n this._signin();\n }\n\n private _signin() {\n if (!this.signin_requested) {\n return;\n }\n\n this._newSigninPromiseIfNeeded();\n\n if (this.pusher.connection.state !== 'connected') {\n // Signin will be attempted when the connection is connected\n return;\n }\n\n this.pusher.config.userAuthenticator(\n {\n socketId: this.pusher.connection.socket_id\n },\n this._onAuthorize\n );\n }\n\n private _onAuthorize: UserAuthenticationCallback = (\n err,\n authData: UserAuthenticationData\n ) => {\n if (err) {\n Logger.warn(`Error during signin: ${err}`);\n this._cleanup();\n return;\n }\n\n this.pusher.send_event('pusher:signin', {\n auth: authData.auth,\n user_data: authData.user_data\n });\n\n // Later when we get pusher:singin_success event, the user will be marked as signed in\n };\n\n private _onSigninSuccess(data: any) {\n try {\n this.user_data = JSON.parse(data.user_data);\n } catch (e) {\n Logger.error(`Failed parsing user data after signin: ${data.user_data}`);\n this._cleanup();\n return;\n }\n\n if (typeof this.user_data.id !== 'string' || this.user_data.id === '') {\n Logger.error(\n `user_data doesn't contain an id. user_data: ${this.user_data}`\n );\n this._cleanup();\n return;\n }\n\n // Signin succeeded\n this._signinDoneResolve();\n this._subscribeChannels();\n }\n\n private _subscribeChannels() {\n const ensure_subscribed = channel => {\n if (channel.subscriptionPending && channel.subscriptionCancelled) {\n channel.reinstateSubscription();\n } else if (\n !channel.subscriptionPending &&\n this.pusher.connection.state === 'connected'\n ) {\n channel.subscribe();\n }\n };\n\n this.serverToUserChannel = new Channel(\n `#server-to-user-${this.user_data.id}`,\n this.pusher\n );\n this.serverToUserChannel.bind_global((eventName, data) => {\n if (\n eventName.indexOf('pusher_internal:') === 0 ||\n eventName.indexOf('pusher:') === 0\n ) {\n // ignore internal events\n return;\n }\n this.emit(eventName, data);\n });\n ensure_subscribed(this.serverToUserChannel);\n }\n\n private _cleanup() {\n this.user_data = null;\n if (this.serverToUserChannel) {\n this.serverToUserChannel.unbind_all();\n this.serverToUserChannel.disconnect();\n this.serverToUserChannel = null;\n }\n\n if (this.signin_requested) {\n // If signin is in progress and cleanup is called,\n // Mark the current signin process as done.\n this._signinDoneResolve();\n }\n }\n\n private _newSigninPromiseIfNeeded() {\n if (!this.signin_requested) {\n return;\n }\n\n // If there is a promise and it is not resolved, return without creating a new one.\n if (this.signinDonePromise && !(this.signinDonePromise as any).done) {\n return;\n }\n\n // This promise is never rejected.\n // It gets resolved when the signin process is done whether it failed or succeeded\n const { promise, resolve, reject: _ } = flatPromise();\n (promise as any).done = false;\n const setDone = () => {\n (promise as any).done = true;\n };\n promise.then(setDone).catch(setDone);\n this.signinDonePromise = promise;\n this._signinDoneResolve = resolve;\n }\n}\n","import AbstractRuntime from '../runtimes/interface';\nimport Runtime from 'runtime';\nimport * as Collections from './utils/collections';\nimport Channels from './channels/channels';\nimport Channel from './channels/channel';\nimport { default as EventsDispatcher } from './events/dispatcher';\nimport Timeline from './timeline/timeline';\nimport TimelineSender from './timeline/timeline_sender';\nimport TimelineLevel from './timeline/level';\nimport { defineTransport } from './strategies/strategy_builder';\nimport ConnectionManager from './connection/connection_manager';\nimport { PeriodicTimer } from './utils/timers';\nimport Defaults from './defaults';\nimport Logger from './logger';\nimport Factory from './utils/factory';\nimport { Options, ClusterOptions, validateOptions } from './options';\nimport { Config, getConfig } from './config';\nimport StrategyOptions from './strategies/strategy_options';\nimport UserFacade from './user';\n\nexport default class Pusher {\n /* STATIC PROPERTIES */\n static instances: Pusher[] = [];\n static isReady: boolean = false;\n static logToConsole: boolean = false;\n\n // for jsonp\n static Runtime: AbstractRuntime = Runtime;\n static ScriptReceivers: any = (Runtime).ScriptReceivers;\n static DependenciesReceivers: any = (Runtime).DependenciesReceivers;\n static auth_callbacks: any = (Runtime).auth_callbacks;\n\n static ready() {\n Pusher.isReady = true;\n for (var i = 0, l = Pusher.instances.length; i < l; i++) {\n Pusher.instances[i].connect();\n }\n }\n\n static log: (message: any) => void;\n\n private static getClientFeatures(): string[] {\n return Collections.keys(\n Collections.filterObject({ ws: Runtime.Transports.ws }, function(t) {\n return t.isSupported({});\n })\n );\n }\n\n /* INSTANCE PROPERTIES */\n key: string;\n options: Options;\n config: Config;\n channels: Channels;\n global_emitter: EventsDispatcher;\n sessionID: number;\n timeline: Timeline;\n timelineSender: TimelineSender;\n connection: ConnectionManager;\n timelineSenderTimer: PeriodicTimer;\n user: UserFacade;\n constructor(app_key: string, options: Options) {\n checkAppKey(app_key);\n validateOptions(options);\n this.key = app_key;\n this.config = getConfig(options, this);\n\n this.channels = Factory.createChannels();\n this.global_emitter = new EventsDispatcher();\n this.sessionID = Runtime.randomInt(1000000000);\n\n this.timeline = new Timeline(this.key, this.sessionID, {\n cluster: this.config.cluster,\n features: Pusher.getClientFeatures(),\n params: this.config.timelineParams || {},\n limit: 50,\n level: TimelineLevel.INFO,\n version: Defaults.VERSION\n });\n if (this.config.enableStats) {\n this.timelineSender = Factory.createTimelineSender(this.timeline, {\n host: this.config.statsHost,\n path: '/timeline/v2/' + Runtime.TimelineTransport.name\n });\n }\n\n var getStrategy = (options: StrategyOptions) => {\n return Runtime.getDefaultStrategy(this.config, options, defineTransport);\n };\n\n this.connection = Factory.createConnectionManager(this.key, {\n getStrategy: getStrategy,\n timeline: this.timeline,\n activityTimeout: this.config.activityTimeout,\n pongTimeout: this.config.pongTimeout,\n unavailableTimeout: this.config.unavailableTimeout,\n useTLS: Boolean(this.config.useTLS)\n });\n\n this.connection.bind('connected', () => {\n this.subscribeAll();\n if (this.timelineSender) {\n this.timelineSender.send(this.connection.isUsingTLS());\n }\n });\n\n this.connection.bind('message', event => {\n var eventName = event.event;\n var internal = eventName.indexOf('pusher_internal:') === 0;\n if (event.channel) {\n var channel = this.channel(event.channel);\n if (channel) {\n channel.handleEvent(event);\n }\n }\n // Emit globally [deprecated]\n if (!internal) {\n this.global_emitter.emit(event.event, event.data);\n }\n });\n this.connection.bind('connecting', () => {\n this.channels.disconnect();\n });\n this.connection.bind('disconnected', () => {\n this.channels.disconnect();\n });\n this.connection.bind('error', err => {\n Logger.warn(err);\n });\n\n Pusher.instances.push(this);\n this.timeline.info({ instances: Pusher.instances.length });\n\n this.user = new UserFacade(this);\n\n if (Pusher.isReady) {\n this.connect();\n }\n }\n\n /**\n * Allows you to switch Pusher cluster without\n * losing all the channels/subscription binding\n * as this is internally managed by the SDK.\n */\n switchCluster(options: ClusterOptions) {\n const { appKey, cluster } = options;\n this.key = appKey;\n this.options = { ...this.options, cluster };\n this.config = getConfig(this.options, this);\n this.connection.switchCluster(this.key);\n }\n\n channel(name: string): Channel {\n return this.channels.find(name);\n }\n\n allChannels(): Channel[] {\n return this.channels.all();\n }\n\n connect() {\n this.connection.connect();\n\n if (this.timelineSender) {\n if (!this.timelineSenderTimer) {\n var usingTLS = this.connection.isUsingTLS();\n var timelineSender = this.timelineSender;\n this.timelineSenderTimer = new PeriodicTimer(60000, function() {\n timelineSender.send(usingTLS);\n });\n }\n }\n }\n\n disconnect() {\n this.connection.disconnect();\n\n if (this.timelineSenderTimer) {\n this.timelineSenderTimer.ensureAborted();\n this.timelineSenderTimer = null;\n }\n }\n\n bind(event_name: string, callback: Function, context?: any): Pusher {\n this.global_emitter.bind(event_name, callback, context);\n return this;\n }\n\n unbind(event_name?: string, callback?: Function, context?: any): Pusher {\n this.global_emitter.unbind(event_name, callback, context);\n return this;\n }\n\n bind_global(callback: Function): Pusher {\n this.global_emitter.bind_global(callback);\n return this;\n }\n\n unbind_global(callback?: Function): Pusher {\n this.global_emitter.unbind_global(callback);\n return this;\n }\n\n unbind_all(callback?: Function): Pusher {\n this.global_emitter.unbind_all();\n return this;\n }\n\n subscribeAll() {\n var channelName;\n for (channelName in this.channels.channels) {\n if (this.channels.channels.hasOwnProperty(channelName)) {\n this.subscribe(channelName);\n }\n }\n }\n\n subscribe(channel_name: string) {\n var channel = this.channels.add(channel_name, this);\n if (channel.subscriptionPending && channel.subscriptionCancelled) {\n channel.reinstateSubscription();\n } else if (\n !channel.subscriptionPending &&\n this.connection.state === 'connected'\n ) {\n channel.subscribe();\n }\n return channel;\n }\n\n unsubscribe(channel_name: string) {\n var channel = this.channels.find(channel_name);\n if (channel && channel.subscriptionPending) {\n channel.cancelSubscription();\n } else {\n channel = this.channels.remove(channel_name);\n if (channel && channel.subscribed) {\n channel.unsubscribe();\n }\n }\n }\n\n send_event(event_name: string, data: any, channel?: string) {\n return this.connection.send_event(event_name, data, channel);\n }\n\n shouldUseTLS(): boolean {\n return this.config.useTLS;\n }\n\n signin() {\n this.user.signin();\n }\n}\n\nfunction checkAppKey(key) {\n if (key === null || key === undefined) {\n throw 'You must pass your app key when you instantiate Pusher.';\n }\n}\n\nRuntime.setup(Pusher);\n","import Pusher from './pusher';\nimport { Options, validateOptions } from './options';\nimport * as nacl from 'tweetnacl';\n\nexport default class PusherWithEncryption extends Pusher {\n constructor(app_key: string, options: Options) {\n Pusher.logToConsole = PusherWithEncryption.logToConsole;\n Pusher.log = PusherWithEncryption.log;\n\n validateOptions(options);\n options.nacl = nacl;\n super(app_key, options);\n }\n}\n"],"sourceRoot":""} \ No newline at end of file +{"version":3,"sources":["webpack://Pusher/webpack/bootstrap","webpack://Pusher/external \"util\"","webpack://Pusher/./node_modules/safe-buffer/index.js","webpack://Pusher/./node_modules/websocket-driver/lib/websocket/driver/base.js","webpack://Pusher/external \"crypto\"","webpack://Pusher/./node_modules/websocket-driver/lib/websocket/driver.js","webpack://Pusher/external \"stream\"","webpack://Pusher/external \"url\"","webpack://Pusher/./node_modules/faye-websocket/lib/faye/websocket/api/event.js","webpack://Pusher/./node_modules/@stablelib/base64/base64.ts","webpack://Pusher/./node_modules/websocket-driver/lib/websocket/driver/headers.js","webpack://Pusher/./node_modules/websocket-driver/lib/websocket/http_parser.js","webpack://Pusher/./node_modules/faye-websocket/lib/faye/websocket/api.js","webpack://Pusher/./node_modules/websocket-driver/lib/websocket/driver/hybi.js","webpack://Pusher/./node_modules/websocket-extensions/lib/pipeline/ring_buffer.js","webpack://Pusher/./node_modules/websocket-extensions/lib/pipeline/pledge.js","webpack://Pusher/./node_modules/websocket-driver/lib/websocket/driver/draft75.js","webpack://Pusher/./node_modules/faye-websocket/lib/faye/websocket/api/event_target.js","webpack://Pusher/./node_modules/@stablelib/utf8/utf8.ts","webpack://Pusher/./node_modules/faye-websocket/lib/faye/websocket.js","webpack://Pusher/./node_modules/xmlhttprequest/lib/XMLHttpRequest.js","webpack://Pusher/./node_modules/tweetnacl/nacl-fast.js","webpack://Pusher/./src/core/pusher-with-encryption.js","webpack://Pusher/external \"buffer\"","webpack://Pusher/external \"events\"","webpack://Pusher/./node_modules/websocket-driver/lib/websocket/streams.js","webpack://Pusher/./node_modules/websocket-driver/lib/websocket/driver/stream_reader.js","webpack://Pusher/./node_modules/websocket-driver/lib/websocket/driver/client.js","webpack://Pusher/./node_modules/http-parser-js/http-parser.js","webpack://Pusher/external \"assert\"","webpack://Pusher/./node_modules/websocket-extensions/lib/websocket_extensions.js","webpack://Pusher/./node_modules/websocket-extensions/lib/parser.js","webpack://Pusher/./node_modules/websocket-extensions/lib/pipeline/index.js","webpack://Pusher/./node_modules/websocket-extensions/lib/pipeline/cell.js","webpack://Pusher/./node_modules/websocket-extensions/lib/pipeline/functor.js","webpack://Pusher/./node_modules/websocket-driver/lib/websocket/driver/hybi/frame.js","webpack://Pusher/./node_modules/websocket-driver/lib/websocket/driver/hybi/message.js","webpack://Pusher/./node_modules/websocket-driver/lib/websocket/driver/proxy.js","webpack://Pusher/./node_modules/websocket-driver/lib/websocket/driver/server.js","webpack://Pusher/./node_modules/websocket-driver/lib/websocket/driver/draft76.js","webpack://Pusher/./node_modules/faye-websocket/lib/faye/websocket/client.js","webpack://Pusher/external \"net\"","webpack://Pusher/external \"tls\"","webpack://Pusher/./node_modules/faye-websocket/lib/faye/eventsource.js","webpack://Pusher/external \"child_process\"","webpack://Pusher/external \"fs\"","webpack://Pusher/external \"http\"","webpack://Pusher/external \"https\"","webpack://Pusher/./src/core/base64.ts","webpack://Pusher/./src/core/utils/timers/abstract_timer.ts","webpack://Pusher/./src/core/utils/timers/index.ts","webpack://Pusher/./src/core/util.ts","webpack://Pusher/./src/core/utils/collections.ts","webpack://Pusher/./src/core/defaults.ts","webpack://Pusher/./src/core/transports/url_schemes.ts","webpack://Pusher/./src/core/events/callback_registry.ts","webpack://Pusher/./src/core/events/dispatcher.ts","webpack://Pusher/./src/core/logger.ts","webpack://Pusher/./src/core/transports/transport_connection.ts","webpack://Pusher/./src/core/transports/transport.ts","webpack://Pusher/./src/runtimes/isomorphic/transports/transports.ts","webpack://Pusher/./src/core/transports/assistant_to_the_transport_manager.ts","webpack://Pusher/./src/core/connection/protocol/protocol.ts","webpack://Pusher/./src/core/connection/connection.ts","webpack://Pusher/./src/core/connection/handshake/index.ts","webpack://Pusher/./src/core/timeline/timeline_sender.ts","webpack://Pusher/./src/core/errors.ts","webpack://Pusher/./src/core/utils/url_store.ts","webpack://Pusher/./src/core/channels/channel.ts","webpack://Pusher/./src/core/channels/private_channel.ts","webpack://Pusher/./src/core/channels/members.ts","webpack://Pusher/./src/core/channels/presence_channel.ts","webpack://Pusher/./src/core/channels/encrypted_channel.ts","webpack://Pusher/./src/core/connection/connection_manager.ts","webpack://Pusher/./src/core/channels/channels.ts","webpack://Pusher/./src/core/utils/factory.ts","webpack://Pusher/./src/core/transports/transport_manager.ts","webpack://Pusher/./src/core/strategies/sequential_strategy.ts","webpack://Pusher/./src/core/strategies/best_connected_ever_strategy.ts","webpack://Pusher/./src/core/strategies/websocket_prioritized_cached_strategy.ts","webpack://Pusher/./src/core/strategies/delayed_strategy.ts","webpack://Pusher/./src/core/strategies/if_strategy.ts","webpack://Pusher/./src/core/strategies/first_connected_strategy.ts","webpack://Pusher/./src/runtimes/isomorphic/default_strategy.ts","webpack://Pusher/./src/runtimes/isomorphic/transports/transport_connection_initializer.ts","webpack://Pusher/./src/core/http/http_request.ts","webpack://Pusher/./src/core/http/state.ts","webpack://Pusher/./src/core/http/http_socket.ts","webpack://Pusher/./src/core/http/http_streaming_socket.ts","webpack://Pusher/./src/core/http/http_polling_socket.ts","webpack://Pusher/./src/runtimes/isomorphic/http/http_xhr_request.ts","webpack://Pusher/./src/runtimes/isomorphic/http/http.ts","webpack://Pusher/./src/runtimes/isomorphic/runtime.ts","webpack://Pusher/./src/runtimes/node/net_info.ts","webpack://Pusher/./src/core/auth/options.ts","webpack://Pusher/./src/runtimes/isomorphic/auth/xhr_auth.ts","webpack://Pusher/./src/runtimes/isomorphic/timeline/xhr_timeline.ts","webpack://Pusher/./src/runtimes/node/runtime.ts","webpack://Pusher/./src/core/timeline/level.ts","webpack://Pusher/./src/core/timeline/timeline.ts","webpack://Pusher/./src/core/strategies/transport_strategy.ts","webpack://Pusher/./src/core/strategies/strategy_builder.ts","webpack://Pusher/./src/core/options.ts","webpack://Pusher/./src/core/auth/user_authenticator.ts","webpack://Pusher/./src/core/auth/channel_authorizer.ts","webpack://Pusher/./src/core/auth/deprecated_channel_authorizer.ts","webpack://Pusher/./src/core/config.ts","webpack://Pusher/./src/core/watchlist.ts","webpack://Pusher/./src/core/utils/flat_promise.ts","webpack://Pusher/./src/core/user.ts","webpack://Pusher/./src/core/pusher.ts","webpack://Pusher/./src/core/pusher-with-encryption.ts"],"names":[],"mappings":";;;;;;;;;;QAAA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;;QAEA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;;;QAGA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;QACA,0CAA0C,gCAAgC;QAC1E;QACA;;QAEA;QACA;QACA;QACA,wDAAwD,kBAAkB;QAC1E;QACA,iDAAiD,cAAc;QAC/D;;QAEA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA,yCAAyC,iCAAiC;QAC1E,gHAAgH,mBAAmB,EAAE;QACrI;QACA;;QAEA;QACA;QACA;QACA,2BAA2B,0BAA0B,EAAE;QACvD,iCAAiC,eAAe;QAChD;QACA;QACA;;QAEA;QACA,sDAAsD,+DAA+D;;QAErH;QACA;;;QAGA;QACA;;;;;;;AClFA,iC;;;;;;ACAA;AACA,aAAa,mBAAO,CAAC,EAAQ;AAC7B;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AACD;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;;;;;;;AC7Da;;AAEb,cAAc,mBAAO,CAAC,CAAa;AACnC,cAAc,mBAAO,CAAC,EAAQ;AAC9B,cAAc,mBAAO,CAAC,CAAM;AAC5B,cAAc,mBAAO,CAAC,EAAY;AAClC,cAAc,mBAAO,CAAC,CAAW;AACjC,cAAc,mBAAO,CAAC,EAAiB;;AAEvC;AACA;AACA,oCAAoC;;AAEpC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA,2CAA2C;;AAE3C;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA,KAAK;AACL,GAAG;;AAEH;AACA;AACA,GAAG;;AAEH;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA;AACA,GAAG;;AAEH;AACA;;AAEA;AACA;;AAEA;;AAEA;AACA;AACA,KAAK;AACL;AACA;;AAEA;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA,GAAG;;AAEH;AACA;AACA,GAAG;;AAEH;AACA;AACA,GAAG;;AAEH;AACA;AACA,GAAG;;AAEH;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA,yCAAyC,+BAA+B;AACxE;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;;AAGA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;;;;;;;AChMA,mC;;;;;;;ACAa;;AAEb;AACA;AACA;AACA;AACA;;AAEA,aAAa,mBAAO,CAAC,CAAe;AACpC,aAAa,mBAAO,CAAC,EAAiB;AACtC,aAAa,mBAAO,CAAC,EAAiB;;AAEtC;AACA;AACA;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA,GAAG;;AAEH;AACA;AACA,GAAG;;AAEH;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA;;AAEA;;;;;;;AC1CA,mC;;;;;;ACAA,gC;;;;;;;ACAa;;AAEb;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;;;;;;;;;ACrBA,sCAAsC;AACtC,6CAA6C;;;;;;;;;;;;;;;AAE7C;;GAEG;AAEH,iDAAiD;AACjD,kDAAkD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AC;AAA9B,CAA8B,CAAC;AAEtB,wBAAgB,GAAG,UAAC,MAAc;IAC3C,eAAQ,CAAC,gBAAgB,CAAC,MAAM,CAAC;AAAjC,CAAiC,CAAC;AAEzB,qBAAa,GAAG,UAAC,CAAS;IACnC,eAAQ,CAAC,aAAa,CAAC,CAAC,CAAC;AAAzB,CAAyB,CAAC;;;;;;;;AC1RjB;;AAEb;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;;;;;;;;AClCa;;AAEb,qBAAqB,mBAAO,CAAC,EAAgB;AAC7C,qBAAqB,mBAAO,CAAC,CAAa;;AAE1C;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;;AAEA,mDAAmD,OAAO;AAC1D;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,sDAAsD,yBAAyB;AAC/E;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;;;;;;;;ACtIa;;AAEb,kBAAkB,mBAAO,CAAC,CAAQ;AAClC,kBAAkB,mBAAO,CAAC,CAAM;AAChC,kBAAkB,mBAAO,CAAC,CAAkB;AAC5C,kBAAkB,mBAAO,CAA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CAAC,EAAsB;AAC/C,iBAAiB,mBAAO,CAAC,CAAQ;AACjC,iBAAiB,mBAAO,CAAC,EAAc;AACvC,iBAAiB,mBAAO,CAAC,EAAgB;;AAEzC;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA;AACA,+CAA+C,mCAAmC;AAClF;;AAEA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;;AAEA,8CAA8C,OAAO;AACrD;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA;;AAEA;AACA,8GAA8G,EAAE,uDAAuD,EAAE,wBAAwB,EAAE,4BAA4B,EAAE;;AAEjO;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA,yCAAyC,oCAAoC;AAC7E;AACA,KAAK;AACL;AACA;AACA,GAAG;;AAEH;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;;AAEA;AACA,GAAG;;AAEH;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,KAAK;AACL;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;AACA,GAAG;;AAEH;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA,GAAG;;AAEH;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL,GAAG;;AAEH;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA,KAAK;;AAEL;;AAEA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;;AAEA;AACA;AACA,GAAG;;AAEH;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA,GAAG;;AAEH;AACA;;AAEA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA,GAAG;;AAEH;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA,KAAK;AACL,GAAG;;AAEH;AACA;AACA;AACA;AACA,KAAK;AACL;AACA,GAAG;;AAEH;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;;;;;;;;AClea;;AAEb;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA,GAAG;AACH;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;;AAEA;;;;;;;;ACjEa;;AAEb,iBAAiB,mBAAO,CAAC,EAAe;;AAExC;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA,GAAG;AACH;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;;;;;;;;ACpCa;;AAEb,aAAa,mBAAO,CAAC,CAAa;AAClC,aAAa,mBAAO,CAAC,CAAQ;AAC7B,aAAa,mBAAO,CAAC,CAAM;;AAE3B;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;;AAEH;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa;AACb;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL,GAAG;;AAEH;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA,GAAG;;AAEH;AACA;AACA;;AAEA;AACA,GAAG;;AAEH;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;;;;;;;;AC1Ha;;AAEb,YAAY,mBAAO,CAAC,CAAS;;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;;AAErB;AACA;;AAEA;AACA;AACA;AACA;AACA,aAAa,mBAAO,CAAC,EAAM;AAC3B,cAAc,mBAAO,CAAC,EAAO;;AAE7B;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,WAAW;AACX;AACA;AACA;AACA;AACA,SAAS;AACT,OAAO;AACP;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,KAAK;AACL;;AAEA;AACA,8CAA8C;AAC9C;AACA,KAAK;AACL;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;;AAET;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;;AAET;AACA;AACA,SAAS;AACT;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;;AAEA;AACA,KAAK,OAAO;AACZ;AACA;AACA;AACA;AACA;AACA,iGAAiG;AACjG,gEAAgE;AAChE,yDAAyD;AACzD,iCAAiC;AACjC,4DAA4D;AAC5D,wCAAwC;AACxC,gDAAgD;AAChD,mCAAmC;AACnC,YAAY,EAAE;AACd,0CAA0C;AAC1C,mEAAmE,kBAAkB,gFAAgF,WAAW;AAChL,6CAA6C;AAC7C,YAAY,EAAE;AACd,iDAAiD;AACjD,mEAAmE,WAAW,WAAW;AACzF,6CAA6C;AAC7C,YAAY,EAAE;AACd,YAAY,+BAA+B;AAC3C,mEAAmE,WAAW,WAAW;AACzF,6CAA6C;AAC7C,YAAY,EAAE;AACd,8FAA8F;AAC9F,qBAAqB;AACrB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,OAAO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,oDAAoD,SAAS;AAC7D;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;AC3mBA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,uBAAuB,iBAAiB;AACxC;AACA;;AAEA;AACA,wCAAwC,4BAA4B;;AAEpE;AACA,4BAA4B;;AAE5B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa,OAAO;AACpB;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,aAAa,QAAQ;AACrB,aAAa,OAAO;AACpB;AACA;AACA,eAAe,QAAQ;AACvB;AACA,eAAe,QAAQ;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB;AACA;AACA;;AAEA;AACA;AACA;AACA,aAAa,QAAQ;AACrB,aAAa,OAAO;AACpB;AACA;AACA,eAAe,QAAQ;AACvB;AACA,eAAe,QAAQ;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,iBAAiB,OAAO;AACxB;AACA;;AAEA;AACA;AACA;AACA;AACA,iBAAiB,OAAO;AACxB;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA,8CAA8C;AAC9C,8CAA8C;AAC9C,8CAA8C;AAC9C,8CAA8C;AAC9C,8CAA8C;AAC9C;AACA,8CAA8C;AAC9C,8CAA8C;AAC9C,8CAA8C;AAC9C;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,sDAAsD;AACtD,sDAAsD;AACtD,sDAAsD;AACtD,sDAAsD;AACtD,sDAAsD;AACtD;AACA,sDAAsD;AACtD,sDAAsD;AACtD,sDAAsD;AACtD;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA,qBAAqB;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA,qBAAqB;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA,qBAAqB;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA,qBAAqB;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA,qBAAqB;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA,qBAAqB;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA,qBAAqB;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA,qBAAqB;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA,qBAAqB;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA,qBAAqB;;AAErB;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA,UAAU,QAAQ;AAClB;AACA;AACA;;AAEA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA;AACA;;AAEA;AACA,aAAa,QAAQ;AACrB;AACA,aAAa,QAAQ;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa,OAAO;AACpB;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,UAAU;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,eAAe,WAAW;AAC1B;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;;AAEA;AACA;AACA,aAAa,QAAQ;AACrB;;AAEA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA,aAAa,OAAO;AACpB;AACA,eAAe,QAAQ;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;;AAEA;AACA,iBAAiB,QAAQ;AACzB;;AAEA;AACA,iBAAiB,QAAQ;AACzB;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD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ACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,eAAe,QAAQ;AACvB;AACA;AACA;AACA;AACA,eAAe,QAAQ;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA,qBAAqB;AACrB,qBAAqB;;AAErB;AACA;AACA;;AAEA,sBAAsB;AACtB,sBAAsB;;AAEtB;AACA;AACA;;AAEA,sBAAsB;AACtB,sBAAsB;;AAEtB;AACA;AACA;;AAEA,sBAAsB;AACtB,sBAAsB;;AAEtB;AACA;AACA;;AAEA,sBAAsB;AACtB,sBAAsB;;AAEtB;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA,qBAAqB;AACrB,qBAAqB;;AAErB;AACA;AACA;;AAEA,sBAAsB;AACtB,sBAAsB;;AAEtB;AACA;AACA;;AAEA,sBAAsB;AACtB,sBAAsB;;AAEtB;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA,qBAAqB;AACrB,qBAAqB;;AAErB;AACA;;AAEA,sBAAsB;AACtB,sBAAsB;;AAEtB;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AAC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EpB;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA,aAAa,OAAO;AACpB;;AAEA;AACA;AACA;AACA;;AAEA,aAAa,OAAO;;AAEpB;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa,OAAO;AACpB;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,QAAQ;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA,aAAa,QAAQ;AACrB;AACA;;AAEA;;AAEA;AACA;AACA,cAAc,SAAS;AACvB;AACA,gCAAgC,OAAO;AACvC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA;AACA,aAAa,QAAQ;AACrB,aAAa,QAAQ;AACrB;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa,QAAQ;AACrB,aAAa,QAAQ;AACrB;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA,aAAa,OAAO;AACpB,aAAa,QAAQ;;AAErB;AACA;AACA;AACA;;AAEA,cAAc,QAAQ;AACtB;AACA;;AAEA,aAAa,QAAQ;AACrB,aAAa,QAAQ;AACrB,aAAa,QAAQ;AACrB,eAAe,QAAQ;AACvB;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;;AAEA,aAAa,OAAO;AACpB,aAAa,QAAQ;AACrB;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA,eAAe,OAAO;AACtB;AACA;;AAEA,aAAa,OAAO;AACpB;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA,iBAAiB,sBAAsB;AACvC;AACA;AACA;AACA;;AAEA;AACA,iBAAiB,gBAAgB;AACjC;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,iBAAiB,gBAAgB;AACjC;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,iBAAiB,gBAAgB;AACjC;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA,UAAU;AACV;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,UAAU;AACV;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAiB,cAAc;AAC/B;AACA;;AAEA;AACA;AACA;AACA,iBAAiB,gBAAgB;AACjC;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa,uBAAuB;AACpC,aAAa,gBAAgB;AAC7B;AACA;;AAEA;AACA;AACA;AACA;AACA,UAAU;AACV;;AAEA;AACA;AACA;AACA;AACA;AACA,iBAAiB,eAAe;AAChC,UAAU;AACV;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAiB,QAAQ;AACzB;AACA,UAAU;AACV;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAiB,OAAO;AACxB;AACA;AACA,iBAAiB,OAAO;AACxB;AACA,KAAK;AACL,GAAG,UAAU,IAA8B;AAC3C;AACA,aAAa,mBAAO,CAAC,CAAQ;AAC7B;AACA;AACA;AACA,mBAAmB,OAAO;AAC1B;AACA,OAAO;AACP;AACA;AACA,CAAC;;AAED,CAAC,EAAE,KAA6B,kEAAkE;;;;;;;ACt1ElG,iBAAiB,mBAAO,CAAC,EAA0B;;;;;;;ACAnD,mC;;;;;;ACAA,mC;;;;;;;ACAa;;AAEb;;AAEA;AACA;;AAEA;AACA;;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AAGA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;;AAGA,aAAa,mBAAO,CAAC,CAAQ;AAC7B,aAAa,mBAAO,CAAC,CAAM;;;AAG3B;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;;AAGA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;;AAGA;AACA;;;;;;;;ACjJa;;AAEb,aAAa,mBAAO,CAAC,CAAa;;AAElC;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;;AAEA,mCAAmC,OAAO;AAC1C;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;;;;;;;ACpEa;;AAEb,iBAAiB,mBAAO,CAAC,CAAa;AACtC,iBAAiB,mBAAO,CAAC,CAAQ;AACjC,iBAAiB,mBAAO,CAAC,CAAK;AAC9B,iBAAiB,mBAAO,CAAC,CAAM;AAC/B,iBAAiB,mBAAO,CAAC,EAAgB;AACzC,iBAAiB,mBAAO,CAAC,CAAQ;AACjC,iBAAiB,mBAAO,CAAC,EAAQ;AACjC,iBAAiB,mBAAO,CAAC,EAAS;;AAElC;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA,GAAG;;AAEH;AACA;AACA;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;;AAEA;AACA;;AAEA;;;;;;;AC7IA;;AAEA,aAAa,mBAAO,CAAC,EAAQ;;AAE7B;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,sBAAsB;AACtB;AACA;AACA;AACA;;AAEA;AACA,qCAAqC;AACrC;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,8CAA8C,UAAU;;AAExD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,2BAA2B,SAAS;AACpC,4BAA4B;AAC5B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,UAAU;AACV;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,yCAAyC,EAAE;AAC3C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA,mDAAmD;AACnD;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA,mBAAmB,oBAAoB;AACvC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW;AACX;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA,KAAK;AACL;AACA;AACA,kCAAkC;AAClC;AACA,KAAK;AACL;AACA,KAAK;AACL;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH,CAAC;;AAED;AACA;AACA;AACA;AACA;;;;;;;AC9cA,mC;;;;;;;ACAa;;AAEb,eAAe,mBAAO,CAAC,EAAU;AACjC,eAAe,mBAAO,CAAC,EAAY;;AAEnC;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA,OAAO;AACP,KAAK;;AAEL;AACA;;AAEA;AACA,GAAG;;AAEH;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA,KAAK;;AAEL;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,KAAK;;AAEL;AACA;;AAEA;AACA,GAAG;;AAEH;AACA,mBAAmB,wCAAwC;AAC3D;;AAEA;AACA,gDAAgD,OAAO;AACvD;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA,GAAG;;AAEH;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;;;;;;;;ACjKa;;AAEb;AACA;AACA;AACA;AACA,gDAAgD;AAChD;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA,SAAS;AACT;AACA,SAAS;AACT;AACA;AACA;;AAEA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA,OAAO;AACP;AACA,KAAK;;AAEL;AACA,GAAG;;AAEH;AACA;;AAEA;AACA;AACA,mCAAmC,gBAAgB;AACnD,OAAO;AACP;AACA,OAAO;AACP;AACA,OAAO;AACP;AACA,OAAO;AACP;AACA;AACA;;AAEA;;AAEA,wCAAwC;AACxC;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA,sBAAsB,6BAA6B;AACnD;;AAEA;AACA;AACA,kCAAkC,OAAO;AACzC;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;;;;;;;;ACtGa;;AAEb,aAAa,mBAAO,CAAC,EAAQ;AAC7B,aAAa,mBAAO,CAAC,EAAU;;AAE/B;AACA,kDAAkD,2BAA2B;AAC7E,mBAAmB;AACnB;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA,mBAAmB;;AAEnB,4CAA4C,mBAAmB;AAC/D;AACA,wCAAwC,yBAAyB;AACjE;;AAEA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;;AAEA;;;;;;;;AC9Ca;;AAEb,cAAc,mBAAO,CAAC,EAAW;AACjC,cAAc,mBAAO,CAAC,EAAU;;AAEhC;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;;;;;;;;ACpDa;;AAEb,iBAAiB,mBAAO,CAAC,EAAe;;AAExC;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA,gBAAgB,oFAAoF;AACpG;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA,GAAG;AACH;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;;AAEA;;;;;;;;ACvEa;;AAEb;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;;;;;;;;ACpBa;;AAEb,aAAa,mBAAO,CAAC,CAAa;;AAElC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;;;;;;;;ACjCa;;AAEb,iBAAiB,mBAAO,CAAC,CAAa;AACtC,iBAAiB,mBAAO,CAAC,CAAQ;AACjC,iBAAiB,mBAAO,CAAC,CAAK;AAC9B,iBAAiB,mBAAO,CAAC,CAAM;AAC/B,iBAAiB,mBAAO,CAAC,CAAQ;AACjC,iBAAiB,mBAAO,CAAC,CAAW;AACpC,iBAAiB,mBAAO,CAAC,EAAgB;;AAEzC,aAAa;;AAEb;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;;AAEA;AACA;AACA;;AAEA;;AAEA;AACA;AACA,GAAG;;AAEH;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA,GAAG;;AAEH;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA;;AAEA;AACA;;AAEA;;;;;;;;AClGa;;AAEb,iBAAiB,mBAAO,CAAC,CAAM;AAC/B,iBAAiB,mBAAO,CAAC,EAAgB;AACzC,iBAAiB,mBAAO,CAAC,CAAQ;AACjC,iBAAiB,mBAAO,CAAC,EAAW;AACpC,iBAAiB,mBAAO,CAAC,EAAW;AACpC,iBAAiB,mBAAO,CAAC,EAAQ;;AAEjC;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA,2CAA2C;AAC3C,kCAAkC;AAClC,GAAG;;AAEH;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA,4CAA4C,sBAAsB;AAClE,KAAK;;AAEL;AACA;;AAEA;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA,CAAC;;AAED;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;;;;;;;AC/Ga;;AAEb,cAAc,mBAAO,CAAC,CAAa;AACnC,cAAc,mBAAO,CAAC,CAAQ;AAC9B,cAAc,mBAAO,CAAC,EAAW;AACjC,cAAc,mBAAO,CAAC,CAAQ;AAC9B,cAAc,mBAAO,CAAC,CAAM;;;AAG5B;AACA;AACA;;AAEA;AACA;AACA;;;AAGA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA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GAAa,EAAE,CAAC;AACzB,qBAAO,GAAY,KAAK,CAAC;AACzB,0BAAY,GAAY,KAAK,CAAC;AAG9B,qBAAO,GAAoB,YAAO,CAAC;AACnC,6BAAe,GAAc,YAAQ,CAAC,eAAe,CAAC;AACtD,mCAAqB,GAAc,YAAQ,CAAC,qBAAqB,CAAC;AAClE,4BAAc,GAAc,YAAQ,CAAC,cAAc,CAAC;AAVxC,6DAAM;AA4O3B,SAAS,WAAW,CAAC,GAAG;IACtB,IAAI,GAAG,KAAK,IAAI,IAAI,GAAG,KAAK,SAAS,EAAE;QACrC,MAAM,yDAAyD,CAAC;KACjE;AACH,CAAC;AAED,YAAO,CAAC,KAAK,CAAC,aAAM,CAAC,CAAC;;;;;;ACtQQ;AACuB;AACnB;AAEnB,MAAM,2CAAqB,SAAQ,WAAM;IACtD,YAAY,OAAe,EAAE,OAAgB;QAC3C,WAAM,CAAC,YAAY,GAAG,2CAAoB,CAAC,YAAY,CAAC;QACxD,WAAM,CAAC,GAAG,GAAG,2CAAoB,CAAC,GAAG,CAAC;QAEtC,eAAe,CAAC,OAAO,CAAC,CAAC;QACzB,OAAO,CAAC,IAAI,GAAG,SAAI,CAAC;QACpB,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAC1B,CAAC;CACF","file":"pusher.js","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 21);\n","module.exports = require(\"util\");","/* eslint-disable node/no-deprecated-api */\nvar buffer = require('buffer')\nvar Buffer = buffer.Buffer\n\n// alternative to using Object.keys for old browsers\nfunction copyProps (src, dst) {\n for (var key in src) {\n dst[key] = src[key]\n }\n}\nif (Buffer.from && Buffer.alloc && Buffer.allocUnsafe && Buffer.allocUnsafeSlow) {\n module.exports = buffer\n} else {\n // Copy properties from require('buffer')\n copyProps(buffer, exports)\n exports.Buffer = SafeBuffer\n}\n\nfunction SafeBuffer (arg, encodingOrOffset, length) {\n return Buffer(arg, encodingOrOffset, length)\n}\n\n// Copy static methods from Buffer\ncopyProps(Buffer, SafeBuffer)\n\nSafeBuffer.from = function (arg, encodingOrOffset, length) {\n if (typeof arg === 'number') {\n throw new TypeError('Argument must not be a number')\n }\n return Buffer(arg, encodingOrOffset, length)\n}\n\nSafeBuffer.alloc = function (size, fill, encoding) {\n if (typeof size !== 'number') {\n throw new TypeError('Argument must be a number')\n }\n var buf = Buffer(size)\n if (fill !== undefined) {\n if (typeof encoding === 'string') {\n buf.fill(fill, encoding)\n } else {\n buf.fill(fill)\n }\n } else {\n buf.fill(0)\n }\n return buf\n}\n\nSafeBuffer.allocUnsafe = function (size) {\n if (typeof size !== 'number') {\n throw new TypeError('Argument must be a number')\n }\n return Buffer(size)\n}\n\nSafeBuffer.allocUnsafeSlow = function (size) {\n if (typeof size !== 'number') {\n throw new TypeError('Argument must be a number')\n }\n return buffer.SlowBuffer(size)\n}\n","'use strict';\n\nvar Buffer = require('safe-buffer').Buffer,\n Emitter = require('events').EventEmitter,\n util = require('util'),\n streams = require('../streams'),\n Headers = require('./headers'),\n Reader = require('./stream_reader');\n\nvar Base = function(request, url, options) {\n Emitter.call(this);\n Base.validateOptions(options || {}, ['maxLength', 'masking', 'requireMasking', 'protocols']);\n\n this._request = request;\n this._reader = new Reader();\n this._options = options || {};\n this._maxLength = this._options.maxLength || this.MAX_LENGTH;\n this._headers = new Headers();\n this.__queue = [];\n this.readyState = 0;\n this.url = url;\n\n this.io = new streams.IO(this);\n this.messages = new streams.Messages(this);\n this._bindEventListeners();\n};\nutil.inherits(Base, Emitter);\n\nBase.isWebSocket = function(request) {\n var connection = request.headers.connection || '',\n upgrade = request.headers.upgrade || '';\n\n return request.method === 'GET' &&\n connection.toLowerCase().split(/ *, */).indexOf('upgrade') >= 0 &&\n upgrade.toLowerCase() === 'websocket';\n};\n\nBase.validateOptions = function(options, validKeys) {\n for (var key in options) {\n if (validKeys.indexOf(key) < 0)\n throw new Error('Unrecognized option: ' + key);\n }\n};\n\nvar instance = {\n // This is 64MB, small enough for an average VPS to handle without\n // crashing from process out of memory\n MAX_LENGTH: 0x3ffffff,\n\n STATES: ['connecting', 'open', 'closing', 'closed'],\n\n _bindEventListeners: function() {\n var self = this;\n\n // Protocol errors are informational and do not have to be handled\n this.messages.on('error', function() {});\n\n this.on('message', function(event) {\n var messages = self.messages;\n if (messages.readable) messages.emit('data', event.data);\n });\n\n this.on('error', function(error) {\n var messages = self.messages;\n if (messages.readable) messages.emit('error', error);\n });\n\n this.on('close', function() {\n var messages = self.messages;\n if (!messages.readable) return;\n messages.readable = messages.writable = false;\n messages.emit('end');\n });\n },\n\n getState: function() {\n return this.STATES[this.readyState] || null;\n },\n\n addExtension: function(extension) {\n return false;\n },\n\n setHeader: function(name, value) {\n if (this.readyState > 0) return false;\n this._headers.set(name, value);\n return true;\n },\n\n start: function() {\n if (this.readyState !== 0) return false;\n\n if (!Base.isWebSocket(this._request))\n return this._failHandshake(new Error('Not a WebSocket request'));\n\n var response;\n\n try {\n response = this._handshakeResponse();\n } catch (error) {\n return this._failHandshake(error);\n }\n\n this._write(response);\n if (this._stage !== -1) this._open();\n return true;\n },\n\n _failHandshake: function(error) {\n var headers = new Headers();\n headers.set('Content-Type', 'text/plain');\n headers.set('Content-Length', Buffer.byteLength(error.message, 'utf8'));\n\n headers = ['HTTP/1.1 400 Bad Request', headers.toString(), error.message];\n this._write(Buffer.from(headers.join('\\r\\n'), 'utf8'));\n this._fail('protocol_error', error.message);\n\n return false;\n },\n\n text: function(message) {\n return this.frame(message);\n },\n\n binary: function(message) {\n return false;\n },\n\n ping: function() {\n return false;\n },\n\n pong: function() {\n return false;\n },\n\n close: function(reason, code) {\n if (this.readyState !== 1) return false;\n this.readyState = 3;\n this.emit('close', new Base.CloseEvent(null, null));\n return true;\n },\n\n _open: function() {\n this.readyState = 1;\n this.__queue.forEach(function(args) { this.frame.apply(this, args) }, this);\n this.__queue = [];\n this.emit('open', new Base.OpenEvent());\n },\n\n _queue: function(message) {\n this.__queue.push(message);\n return true;\n },\n\n _write: function(chunk) {\n var io = this.io;\n if (io.readable) io.emit('data', chunk);\n },\n\n _fail: function(type, message) {\n this.readyState = 2;\n this.emit('error', new Error(message));\n this.close();\n }\n};\n\nfor (var key in instance)\n Base.prototype[key] = instance[key];\n\n\nBase.ConnectEvent = function() {};\n\nBase.OpenEvent = function() {};\n\nBase.CloseEvent = function(code, reason) {\n this.code = code;\n this.reason = reason;\n};\n\nBase.MessageEvent = function(data) {\n this.data = data;\n};\n\nBase.PingEvent = function(data) {\n this.data = data;\n};\n\nBase.PongEvent = function(data) {\n this.data = data;\n};\n\nmodule.exports = Base;\n","module.exports = require(\"crypto\");","'use strict';\n\n// Protocol references:\n//\n// * http://tools.ietf.org/html/draft-hixie-thewebsocketprotocol-75\n// * http://tools.ietf.org/html/draft-hixie-thewebsocketprotocol-76\n// * http://tools.ietf.org/html/draft-ietf-hybi-thewebsocketprotocol-17\n\nvar Base = require('./driver/base'),\n Client = require('./driver/client'),\n Server = require('./driver/server');\n\nvar Driver = {\n client: function(url, options) {\n options = options || {};\n if (options.masking === undefined) options.masking = true;\n return new Client(url, options);\n },\n\n server: function(options) {\n options = options || {};\n if (options.requireMasking === undefined) options.requireMasking = true;\n return new Server(options);\n },\n\n http: function() {\n return Server.http.apply(Server, arguments);\n },\n\n isSecureRequest: function(request) {\n return Server.isSecureRequest(request);\n },\n\n isWebSocket: function(request) {\n return Base.isWebSocket(request);\n },\n\n validateOptions: function(options, validKeys) {\n Base.validateOptions(options, validKeys);\n }\n};\n\nmodule.exports = Driver;\n","module.exports = require(\"stream\");","module.exports = require(\"url\");","'use strict';\n\nvar Event = function(eventType, options) {\n this.type = eventType;\n for (var key in options)\n this[key] = options[key];\n};\n\nEvent.prototype.initEvent = function(eventType, canBubble, cancelable) {\n this.type = eventType;\n this.bubbles = canBubble;\n this.cancelable = cancelable;\n};\n\nEvent.prototype.stopPropagation = function() {};\nEvent.prototype.preventDefault = function() {};\n\nEvent.CAPTURING_PHASE = 1;\nEvent.AT_TARGET = 2;\nEvent.BUBBLING_PHASE = 3;\n\nmodule.exports = Event;\n","// Copyright (C) 2016 Dmitry Chestnykh\n// MIT License. See LICENSE file for details.\n\n/**\n * Package base64 implements Base64 encoding and decoding.\n */\n\n// Invalid character used in decoding to indicate\n// that the character to decode is out of range of\n// alphabet and cannot be decoded.\nconst INVALID_BYTE = 256;\n\n/**\n * Implements standard Base64 encoding.\n *\n * Operates in constant time.\n */\nexport class Coder {\n // TODO(dchest): methods to encode chunk-by-chunk.\n\n constructor(private _paddingCharacter = \"=\") { }\n\n encodedLength(length: number): number {\n if (!this._paddingCharacter) {\n return (length * 8 + 5) / 6 | 0;\n }\n return (length + 2) / 3 * 4 | 0;\n }\n\n encode(data: Uint8Array): string {\n let out = \"\";\n\n let i = 0;\n for (; i < data.length - 2; i += 3) {\n let c = (data[i] << 16) | (data[i + 1] << 8) | (data[i + 2]);\n out += this._encodeByte((c >>> 3 * 6) & 63);\n out += this._encodeByte((c >>> 2 * 6) & 63);\n out += this._encodeByte((c >>> 1 * 6) & 63);\n out += this._encodeByte((c >>> 0 * 6) & 63);\n }\n\n const left = data.length - i;\n if (left > 0) {\n let c = (data[i] << 16) | (left === 2 ? data[i + 1] << 8 : 0);\n out += this._encodeByte((c >>> 3 * 6) & 63);\n out += this._encodeByte((c >>> 2 * 6) & 63);\n if (left === 2) {\n out += this._encodeByte((c >>> 1 * 6) & 63);\n } else {\n out += this._paddingCharacter || \"\";\n }\n out += this._paddingCharacter || \"\";\n }\n\n return out;\n }\n\n maxDecodedLength(length: number): number {\n if (!this._paddingCharacter) {\n return (length * 6 + 7) / 8 | 0;\n }\n return length / 4 * 3 | 0;\n }\n\n decodedLength(s: string): number {\n return this.maxDecodedLength(s.length - this._getPaddingLength(s));\n }\n\n decode(s: string): Uint8Array {\n if (s.length === 0) {\n return new Uint8Array(0);\n }\n const paddingLength = this._getPaddingLength(s);\n const length = s.length - paddingLength;\n const out = new Uint8Array(this.maxDecodedLength(length));\n let op = 0;\n let i = 0;\n let haveBad = 0;\n let v0 = 0, v1 = 0, v2 = 0, v3 = 0;\n for (; i < length - 4; i += 4) {\n v0 = this._decodeChar(s.charCodeAt(i + 0));\n v1 = this._decodeChar(s.charCodeAt(i + 1));\n v2 = this._decodeChar(s.charCodeAt(i + 2));\n v3 = this._decodeChar(s.charCodeAt(i + 3));\n out[op++] = (v0 << 2) | (v1 >>> 4);\n out[op++] = (v1 << 4) | (v2 >>> 2);\n out[op++] = (v2 << 6) | v3;\n haveBad |= v0 & INVALID_BYTE;\n haveBad |= v1 & INVALID_BYTE;\n haveBad |= v2 & INVALID_BYTE;\n haveBad |= v3 & INVALID_BYTE;\n }\n if (i < length - 1) {\n v0 = this._decodeChar(s.charCodeAt(i));\n v1 = this._decodeChar(s.charCodeAt(i + 1));\n out[op++] = (v0 << 2) | (v1 >>> 4);\n haveBad |= v0 & INVALID_BYTE;\n haveBad |= v1 & INVALID_BYTE;\n }\n if (i < length - 2) {\n v2 = this._decodeChar(s.charCodeAt(i + 2));\n out[op++] = (v1 << 4) | (v2 >>> 2);\n haveBad |= v2 & INVALID_BYTE;\n }\n if (i < length - 3) {\n v3 = this._decodeChar(s.charCodeAt(i + 3));\n out[op++] = (v2 << 6) | v3;\n haveBad |= v3 & INVALID_BYTE;\n }\n if (haveBad !== 0) {\n throw new Error(\"Base64Coder: incorrect characters for decoding\");\n }\n return out;\n }\n\n // Standard encoding have the following encoded/decoded ranges,\n // which we need to convert between.\n //\n // ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 0123456789 + /\n // Index: 0 - 25 26 - 51 52 - 61 62 63\n // ASCII: 65 - 90 97 - 122 48 - 57 43 47\n //\n\n // Encode 6 bits in b into a new character.\n protected _encodeByte(b: number): string {\n // Encoding uses constant time operations as follows:\n //\n // 1. Define comparison of A with B using (A - B) >>> 8:\n // if A > B, then result is positive integer\n // if A <= B, then result is 0\n //\n // 2. Define selection of C or 0 using bitwise AND: X & C:\n // if X == 0, then result is 0\n // if X != 0, then result is C\n //\n // 3. Start with the smallest comparison (b >= 0), which is always\n // true, so set the result to the starting ASCII value (65).\n //\n // 4. Continue comparing b to higher ASCII values, and selecting\n // zero if comparison isn't true, otherwise selecting a value\n // to add to result, which:\n //\n // a) undoes the previous addition\n // b) provides new value to add\n //\n let result = b;\n // b >= 0\n result += 65;\n // b > 25\n result += ((25 - b) >>> 8) & ((0 - 65) - 26 + 97);\n // b > 51\n result += ((51 - b) >>> 8) & ((26 - 97) - 52 + 48);\n // b > 61\n result += ((61 - b) >>> 8) & ((52 - 48) - 62 + 43);\n // b > 62\n result += ((62 - b) >>> 8) & ((62 - 43) - 63 + 47);\n\n return String.fromCharCode(result);\n }\n\n // Decode a character code into a byte.\n // Must return 256 if character is out of alphabet range.\n protected _decodeChar(c: number): number {\n // Decoding works similar to encoding: using the same comparison\n // function, but now it works on ranges: result is always incremented\n // by value, but this value becomes zero if the range is not\n // satisfied.\n //\n // Decoding starts with invalid value, 256, which is then\n // subtracted when the range is satisfied. If none of the ranges\n // apply, the function returns 256, which is then checked by\n // the caller to throw error.\n let result = INVALID_BYTE; // start with invalid character\n\n // c == 43 (c > 42 and c < 44)\n result += (((42 - c) & (c - 44)) >>> 8) & (-INVALID_BYTE + c - 43 + 62);\n // c == 47 (c > 46 and c < 48)\n result += (((46 - c) & (c - 48)) >>> 8) & (-INVALID_BYTE + c - 47 + 63);\n // c > 47 and c < 58\n result += (((47 - c) & (c - 58)) >>> 8) & (-INVALID_BYTE + c - 48 + 52);\n // c > 64 and c < 91\n result += (((64 - c) & (c - 91)) >>> 8) & (-INVALID_BYTE + c - 65 + 0);\n // c > 96 and c < 123\n result += (((96 - c) & (c - 123)) >>> 8) & (-INVALID_BYTE + c - 97 + 26);\n\n return result;\n }\n\n private _getPaddingLength(s: string): number {\n let paddingLength = 0;\n if (this._paddingCharacter) {\n for (let i = s.length - 1; i >= 0; i--) {\n if (s[i] !== this._paddingCharacter) {\n break;\n }\n paddingLength++;\n }\n if (s.length < 4 || paddingLength > 2) {\n throw new Error(\"Base64Coder: incorrect padding\");\n }\n }\n return paddingLength;\n }\n\n}\n\nconst stdCoder = new Coder();\n\nexport function encode(data: Uint8Array): string {\n return stdCoder.encode(data);\n}\n\nexport function decode(s: string): Uint8Array {\n return stdCoder.decode(s);\n}\n\n/**\n * Implements URL-safe Base64 encoding.\n * (Same as Base64, but '+' is replaced with '-', and '/' with '_').\n *\n * Operates in constant time.\n */\nexport class URLSafeCoder extends Coder {\n // URL-safe encoding have the following encoded/decoded ranges:\n //\n // ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 0123456789 - _\n // Index: 0 - 25 26 - 51 52 - 61 62 63\n // ASCII: 65 - 90 97 - 122 48 - 57 45 95\n //\n\n protected _encodeByte(b: number): string {\n let result = b;\n // b >= 0\n result += 65;\n // b > 25\n result += ((25 - b) >>> 8) & ((0 - 65) - 26 + 97);\n // b > 51\n result += ((51 - b) >>> 8) & ((26 - 97) - 52 + 48);\n // b > 61\n result += ((61 - b) >>> 8) & ((52 - 48) - 62 + 45);\n // b > 62\n result += ((62 - b) >>> 8) & ((62 - 45) - 63 + 95);\n\n return String.fromCharCode(result);\n }\n\n protected _decodeChar(c: number): number {\n let result = INVALID_BYTE;\n\n // c == 45 (c > 44 and c < 46)\n result += (((44 - c) & (c - 46)) >>> 8) & (-INVALID_BYTE + c - 45 + 62);\n // c == 95 (c > 94 and c < 96)\n result += (((94 - c) & (c - 96)) >>> 8) & (-INVALID_BYTE + c - 95 + 63);\n // c > 47 and c < 58\n result += (((47 - c) & (c - 58)) >>> 8) & (-INVALID_BYTE + c - 48 + 52);\n // c > 64 and c < 91\n result += (((64 - c) & (c - 91)) >>> 8) & (-INVALID_BYTE + c - 65 + 0);\n // c > 96 and c < 123\n result += (((96 - c) & (c - 123)) >>> 8) & (-INVALID_BYTE + c - 97 + 26);\n\n return result;\n }\n}\n\nconst urlSafeCoder = new URLSafeCoder();\n\nexport function encodeURLSafe(data: Uint8Array): string {\n return urlSafeCoder.encode(data);\n}\n\nexport function decodeURLSafe(s: string): Uint8Array {\n return urlSafeCoder.decode(s);\n}\n\n\nexport const encodedLength = (length: number) =>\n stdCoder.encodedLength(length);\n\nexport const maxDecodedLength = (length: number) =>\n stdCoder.maxDecodedLength(length);\n\nexport const decodedLength = (s: string) =>\n stdCoder.decodedLength(s);\n","'use strict';\n\nvar Headers = function() {\n this.clear();\n};\n\nHeaders.prototype.ALLOWED_DUPLICATES = ['set-cookie', 'set-cookie2', 'warning', 'www-authenticate'];\n\nHeaders.prototype.clear = function() {\n this._sent = {};\n this._lines = [];\n};\n\nHeaders.prototype.set = function(name, value) {\n if (value === undefined) return;\n\n name = this._strip(name);\n value = this._strip(value);\n\n var key = name.toLowerCase();\n if (!this._sent.hasOwnProperty(key) || this.ALLOWED_DUPLICATES.indexOf(key) >= 0) {\n this._sent[key] = true;\n this._lines.push(name + ': ' + value + '\\r\\n');\n }\n};\n\nHeaders.prototype.toString = function() {\n return this._lines.join('');\n};\n\nHeaders.prototype._strip = function(string) {\n return string.toString().replace(/^ */, '').replace(/ *$/, '');\n};\n\nmodule.exports = Headers;\n","'use strict';\n\nvar NodeHTTPParser = require('http-parser-js').HTTPParser,\n Buffer = require('safe-buffer').Buffer;\n\nvar TYPES = {\n request: NodeHTTPParser.REQUEST || 'request',\n response: NodeHTTPParser.RESPONSE || 'response'\n};\n\nvar HttpParser = function(type) {\n this._type = type;\n this._parser = new NodeHTTPParser(TYPES[type]);\n this._complete = false;\n this.headers = {};\n\n var current = null,\n self = this;\n\n this._parser.onHeaderField = function(b, start, length) {\n current = b.toString('utf8', start, start + length).toLowerCase();\n };\n\n this._parser.onHeaderValue = function(b, start, length) {\n var value = b.toString('utf8', start, start + length);\n\n if (self.headers.hasOwnProperty(current))\n self.headers[current] += ', ' + value;\n else\n self.headers[current] = value;\n };\n\n this._parser.onHeadersComplete = this._parser[NodeHTTPParser.kOnHeadersComplete] =\n function(majorVersion, minorVersion, headers, method, pathname, statusCode) {\n var info = arguments[0];\n\n if (typeof info === 'object') {\n method = info.method;\n pathname = info.url;\n statusCode = info.statusCode;\n headers = info.headers;\n }\n\n self.method = (typeof method === 'number') ? HttpParser.METHODS[method] : method;\n self.statusCode = statusCode;\n self.url = pathname;\n\n if (!headers) return;\n\n for (var i = 0, n = headers.length, key, value; i < n; i += 2) {\n key = headers[i].toLowerCase();\n value = headers[i+1];\n if (self.headers.hasOwnProperty(key))\n self.headers[key] += ', ' + value;\n else\n self.headers[key] = value;\n }\n\n self._complete = true;\n };\n};\n\nHttpParser.METHODS = {\n 0: 'DELETE',\n 1: 'GET',\n 2: 'HEAD',\n 3: 'POST',\n 4: 'PUT',\n 5: 'CONNECT',\n 6: 'OPTIONS',\n 7: 'TRACE',\n 8: 'COPY',\n 9: 'LOCK',\n 10: 'MKCOL',\n 11: 'MOVE',\n 12: 'PROPFIND',\n 13: 'PROPPATCH',\n 14: 'SEARCH',\n 15: 'UNLOCK',\n 16: 'BIND',\n 17: 'REBIND',\n 18: 'UNBIND',\n 19: 'ACL',\n 20: 'REPORT',\n 21: 'MKACTIVITY',\n 22: 'CHECKOUT',\n 23: 'MERGE',\n 24: 'M-SEARCH',\n 25: 'NOTIFY',\n 26: 'SUBSCRIBE',\n 27: 'UNSUBSCRIBE',\n 28: 'PATCH',\n 29: 'PURGE',\n 30: 'MKCALENDAR',\n 31: 'LINK',\n 32: 'UNLINK'\n};\n\nvar VERSION = process.version\n ? process.version.match(/[0-9]+/g).map(function(n) { return parseInt(n, 10) })\n : [];\n\nif (VERSION[0] === 0 && VERSION[1] === 12) {\n HttpParser.METHODS[16] = 'REPORT';\n HttpParser.METHODS[17] = 'MKACTIVITY';\n HttpParser.METHODS[18] = 'CHECKOUT';\n HttpParser.METHODS[19] = 'MERGE';\n HttpParser.METHODS[20] = 'M-SEARCH';\n HttpParser.METHODS[21] = 'NOTIFY';\n HttpParser.METHODS[22] = 'SUBSCRIBE';\n HttpParser.METHODS[23] = 'UNSUBSCRIBE';\n HttpParser.METHODS[24] = 'PATCH';\n HttpParser.METHODS[25] = 'PURGE';\n}\n\nHttpParser.prototype.isComplete = function() {\n return this._complete;\n};\n\nHttpParser.prototype.parse = function(chunk) {\n var consumed = this._parser.execute(chunk, 0, chunk.length);\n\n if (typeof consumed !== 'number') {\n this.error = consumed;\n this._complete = true;\n return;\n }\n\n if (this._complete)\n this.body = (consumed < chunk.length)\n ? chunk.slice(consumed)\n : Buffer.alloc(0);\n};\n\nmodule.exports = HttpParser;\n","'use strict';\n\nvar Stream = require('stream').Stream,\n util = require('util'),\n driver = require('websocket-driver'),\n EventTarget = require('./api/event_target'),\n Event = require('./api/event');\n\nvar API = function(options) {\n options = options || {};\n driver.validateOptions(options, ['headers', 'extensions', 'maxLength', 'ping', 'proxy', 'tls', 'ca']);\n\n this.readable = this.writable = true;\n\n var headers = options.headers;\n if (headers) {\n for (var name in headers) this._driver.setHeader(name, headers[name]);\n }\n\n var extensions = options.extensions;\n if (extensions) {\n [].concat(extensions).forEach(this._driver.addExtension, this._driver);\n }\n\n this._ping = options.ping;\n this._pingId = 0;\n this.readyState = API.CONNECTING;\n this.bufferedAmount = 0;\n this.protocol = '';\n this.url = this._driver.url;\n this.version = this._driver.version;\n\n var self = this;\n\n this._driver.on('open', function(e) { self._open() });\n this._driver.on('message', function(e) { self._receiveMessage(e.data) });\n this._driver.on('close', function(e) { self._beginClose(e.reason, e.code) });\n\n this._driver.on('error', function(error) {\n self._emitError(error.message);\n });\n this.on('error', function() {});\n\n this._driver.messages.on('drain', function() {\n self.emit('drain');\n });\n\n if (this._ping)\n this._pingTimer = setInterval(function() {\n self._pingId += 1;\n self.ping(self._pingId.toString());\n }, this._ping * 1000);\n\n this._configureStream();\n\n if (!this._proxy) {\n this._stream.pipe(this._driver.io);\n this._driver.io.pipe(this._stream);\n }\n};\nutil.inherits(API, Stream);\n\nAPI.CONNECTING = 0;\nAPI.OPEN = 1;\nAPI.CLOSING = 2;\nAPI.CLOSED = 3;\n\nAPI.CLOSE_TIMEOUT = 30000;\n\nvar instance = {\n write: function(data) {\n return this.send(data);\n },\n\n end: function(data) {\n if (data !== undefined) this.send(data);\n this.close();\n },\n\n pause: function() {\n return this._driver.messages.pause();\n },\n\n resume: function() {\n return this._driver.messages.resume();\n },\n\n send: function(data) {\n if (this.readyState > API.OPEN) return false;\n if (!(data instanceof Buffer)) data = String(data);\n return this._driver.messages.write(data);\n },\n\n ping: function(message, callback) {\n if (this.readyState > API.OPEN) return false;\n return this._driver.ping(message, callback);\n },\n\n close: function(code, reason) {\n if (code === undefined) code = 1000;\n if (reason === undefined) reason = '';\n\n if (code !== 1000 && (code < 3000 || code > 4999))\n throw new Error(\"Failed to execute 'close' on WebSocket: \" +\n \"The code must be either 1000, or between 3000 and 4999. \" +\n code + \" is neither.\");\n\n if (this.readyState !== API.CLOSED) this.readyState = API.CLOSING;\n var self = this;\n\n this._closeTimer = setTimeout(function() {\n self._beginClose('', 1006);\n }, API.CLOSE_TIMEOUT);\n\n this._driver.close(reason, code);\n },\n\n _configureStream: function() {\n var self = this;\n\n this._stream.setTimeout(0);\n this._stream.setNoDelay(true);\n\n ['close', 'end'].forEach(function(event) {\n this._stream.on(event, function() { self._finalizeClose() });\n }, this);\n\n this._stream.on('error', function(error) {\n self._emitError('Network error: ' + self.url + ': ' + error.message);\n self._finalizeClose();\n });\n },\n\n _open: function() {\n if (this.readyState !== API.CONNECTING) return;\n\n this.readyState = API.OPEN;\n this.protocol = this._driver.protocol || '';\n\n var event = new Event('open');\n event.initEvent('open', false, false);\n this.dispatchEvent(event);\n },\n\n _receiveMessage: function(data) {\n if (this.readyState > API.OPEN) return false;\n\n if (this.readable) this.emit('data', data);\n\n var event = new Event('message', {data: data});\n event.initEvent('message', false, false);\n this.dispatchEvent(event);\n },\n\n _emitError: function(message) {\n if (this.readyState >= API.CLOSING) return;\n\n var event = new Event('error', {message: message});\n event.initEvent('error', false, false);\n this.dispatchEvent(event);\n },\n\n _beginClose: function(reason, code) {\n if (this.readyState === API.CLOSED) return;\n this.readyState = API.CLOSING;\n this._closeParams = [reason, code];\n\n if (this._stream) {\n this._stream.destroy();\n if (!this._stream.readable) this._finalizeClose();\n }\n },\n\n _finalizeClose: function() {\n if (this.readyState === API.CLOSED) return;\n this.readyState = API.CLOSED;\n\n if (this._closeTimer) clearTimeout(this._closeTimer);\n if (this._pingTimer) clearInterval(this._pingTimer);\n if (this._stream) this._stream.end();\n\n if (this.readable) this.emit('end');\n this.readable = this.writable = false;\n\n var reason = this._closeParams ? this._closeParams[0] : '',\n code = this._closeParams ? this._closeParams[1] : 1006;\n\n var event = new Event('close', {code: code, reason: reason});\n event.initEvent('close', false, false);\n this.dispatchEvent(event);\n }\n};\n\nfor (var method in instance) API.prototype[method] = instance[method];\nfor (var key in EventTarget) API.prototype[key] = EventTarget[key];\n\nmodule.exports = API;\n","'use strict';\n\nvar Buffer = require('safe-buffer').Buffer,\n crypto = require('crypto'),\n util = require('util'),\n Extensions = require('websocket-extensions'),\n Base = require('./base'),\n Frame = require('./hybi/frame'),\n Message = require('./hybi/message');\n\nvar Hybi = function(request, url, options) {\n Base.apply(this, arguments);\n\n this._extensions = new Extensions();\n this._stage = 0;\n this._masking = this._options.masking;\n this._protocols = this._options.protocols || [];\n this._requireMasking = this._options.requireMasking;\n this._pingCallbacks = {};\n\n if (typeof this._protocols === 'string')\n this._protocols = this._protocols.split(/ *, */);\n\n if (!this._request) return;\n\n var protos = this._request.headers['sec-websocket-protocol'],\n supported = this._protocols;\n\n if (protos !== undefined) {\n if (typeof protos === 'string') protos = protos.split(/ *, */);\n this.protocol = protos.filter(function(p) { return supported.indexOf(p) >= 0 })[0];\n }\n\n this.version = 'hybi-' + Hybi.VERSION;\n};\nutil.inherits(Hybi, Base);\n\nHybi.VERSION = '13';\n\nHybi.mask = function(payload, mask, offset) {\n if (!mask || mask.length === 0) return payload;\n offset = offset || 0;\n\n for (var i = 0, n = payload.length - offset; i < n; i++) {\n payload[offset + i] = payload[offset + i] ^ mask[i % 4];\n }\n return payload;\n};\n\nHybi.generateAccept = function(key) {\n var sha1 = crypto.createHash('sha1');\n sha1.update(key + Hybi.GUID);\n return sha1.digest('base64');\n};\n\nHybi.GUID = '258EAFA5-E914-47DA-95CA-C5AB0DC85B11';\n\nvar instance = {\n FIN: 0x80,\n MASK: 0x80,\n RSV1: 0x40,\n RSV2: 0x20,\n RSV3: 0x10,\n OPCODE: 0x0F,\n LENGTH: 0x7F,\n\n OPCODES: {\n continuation: 0,\n text: 1,\n binary: 2,\n close: 8,\n ping: 9,\n pong: 10\n },\n\n OPCODE_CODES: [0, 1, 2, 8, 9, 10],\n MESSAGE_OPCODES: [0, 1, 2],\n OPENING_OPCODES: [1, 2],\n\n ERRORS: {\n normal_closure: 1000,\n going_away: 1001,\n protocol_error: 1002,\n unacceptable: 1003,\n encoding_error: 1007,\n policy_violation: 1008,\n too_large: 1009,\n extension_error: 1010,\n unexpected_condition: 1011\n },\n\n ERROR_CODES: [1000, 1001, 1002, 1003, 1007, 1008, 1009, 1010, 1011],\n DEFAULT_ERROR_CODE: 1000,\n MIN_RESERVED_ERROR: 3000,\n MAX_RESERVED_ERROR: 4999,\n\n // http://www.w3.org/International/questions/qa-forms-utf-8.en.php\n UTF8_MATCH: /^([\\x00-\\x7F]|[\\xC2-\\xDF][\\x80-\\xBF]|\\xE0[\\xA0-\\xBF][\\x80-\\xBF]|[\\xE1-\\xEC\\xEE\\xEF][\\x80-\\xBF]{2}|\\xED[\\x80-\\x9F][\\x80-\\xBF]|\\xF0[\\x90-\\xBF][\\x80-\\xBF]{2}|[\\xF1-\\xF3][\\x80-\\xBF]{3}|\\xF4[\\x80-\\x8F][\\x80-\\xBF]{2})*$/,\n\n addExtension: function(extension) {\n this._extensions.add(extension);\n return true;\n },\n\n parse: function(chunk) {\n this._reader.put(chunk);\n var buffer = true;\n while (buffer) {\n switch (this._stage) {\n case 0:\n buffer = this._reader.read(1);\n if (buffer) this._parseOpcode(buffer[0]);\n break;\n\n case 1:\n buffer = this._reader.read(1);\n if (buffer) this._parseLength(buffer[0]);\n break;\n\n case 2:\n buffer = this._reader.read(this._frame.lengthBytes);\n if (buffer) this._parseExtendedLength(buffer);\n break;\n\n case 3:\n buffer = this._reader.read(4);\n if (buffer) {\n this._stage = 4;\n this._frame.maskingKey = buffer;\n }\n break;\n\n case 4:\n buffer = this._reader.read(this._frame.length);\n if (buffer) {\n this._stage = 0;\n this._emitFrame(buffer);\n }\n break;\n\n default:\n buffer = null;\n }\n }\n },\n\n text: function(message) {\n if (this.readyState > 1) return false;\n return this.frame(message, 'text');\n },\n\n binary: function(message) {\n if (this.readyState > 1) return false;\n return this.frame(message, 'binary');\n },\n\n ping: function(message, callback) {\n if (this.readyState > 1) return false;\n message = message || '';\n if (callback) this._pingCallbacks[message] = callback;\n return this.frame(message, 'ping');\n },\n\n pong: function(message) {\n if (this.readyState > 1) return false;\n message = message ||'';\n return this.frame(message, 'pong');\n },\n\n close: function(reason, code) {\n reason = reason || '';\n code = code || this.ERRORS.normal_closure;\n\n if (this.readyState <= 0) {\n this.readyState = 3;\n this.emit('close', new Base.CloseEvent(code, reason));\n return true;\n } else if (this.readyState === 1) {\n this.readyState = 2;\n this._extensions.close(function() { this.frame(reason, 'close', code) }, this);\n return true;\n } else {\n return false;\n }\n },\n\n frame: function(buffer, type, code) {\n if (this.readyState <= 0) return this._queue([buffer, type, code]);\n if (this.readyState > 2) return false;\n\n if (buffer instanceof Array) buffer = Buffer.from(buffer);\n if (typeof buffer === 'number') buffer = buffer.toString();\n\n var message = new Message(),\n isText = (typeof buffer === 'string'),\n payload, copy;\n\n message.rsv1 = message.rsv2 = message.rsv3 = false;\n message.opcode = this.OPCODES[type || (isText ? 'text' : 'binary')];\n\n payload = isText ? Buffer.from(buffer, 'utf8') : buffer;\n\n if (code) {\n copy = payload;\n payload = Buffer.allocUnsafe(2 + copy.length);\n payload.writeUInt16BE(code, 0);\n copy.copy(payload, 2);\n }\n message.data = payload;\n\n var onMessageReady = function(message) {\n var frame = new Frame();\n\n frame.final = true;\n frame.rsv1 = message.rsv1;\n frame.rsv2 = message.rsv2;\n frame.rsv3 = message.rsv3;\n frame.opcode = message.opcode;\n frame.masked = !!this._masking;\n frame.length = message.data.length;\n frame.payload = message.data;\n\n if (frame.masked) frame.maskingKey = crypto.randomBytes(4);\n\n this._sendFrame(frame);\n };\n\n if (this.MESSAGE_OPCODES.indexOf(message.opcode) >= 0)\n this._extensions.processOutgoingMessage(message, function(error, message) {\n if (error) return this._fail('extension_error', error.message);\n onMessageReady.call(this, message);\n }, this);\n else\n onMessageReady.call(this, message);\n\n return true;\n },\n\n _sendFrame: function(frame) {\n var length = frame.length,\n header = (length <= 125) ? 2 : (length <= 65535 ? 4 : 10),\n offset = header + (frame.masked ? 4 : 0),\n buffer = Buffer.allocUnsafe(offset + length),\n masked = frame.masked ? this.MASK : 0;\n\n buffer[0] = (frame.final ? this.FIN : 0) |\n (frame.rsv1 ? this.RSV1 : 0) |\n (frame.rsv2 ? this.RSV2 : 0) |\n (frame.rsv3 ? this.RSV3 : 0) |\n frame.opcode;\n\n if (length <= 125) {\n buffer[1] = masked | length;\n } else if (length <= 65535) {\n buffer[1] = masked | 126;\n buffer.writeUInt16BE(length, 2);\n } else {\n buffer[1] = masked | 127;\n buffer.writeUInt32BE(Math.floor(length / 0x100000000), 2);\n buffer.writeUInt32BE(length % 0x100000000, 6);\n }\n\n frame.payload.copy(buffer, offset);\n\n if (frame.masked) {\n frame.maskingKey.copy(buffer, header);\n Hybi.mask(buffer, frame.maskingKey, offset);\n }\n\n this._write(buffer);\n },\n\n _handshakeResponse: function() {\n var secKey = this._request.headers['sec-websocket-key'],\n version = this._request.headers['sec-websocket-version'];\n\n if (version !== Hybi.VERSION)\n throw new Error('Unsupported WebSocket version: ' + version);\n\n if (typeof secKey !== 'string')\n throw new Error('Missing handshake request header: Sec-WebSocket-Key');\n\n this._headers.set('Upgrade', 'websocket');\n this._headers.set('Connection', 'Upgrade');\n this._headers.set('Sec-WebSocket-Accept', Hybi.generateAccept(secKey));\n\n if (this.protocol) this._headers.set('Sec-WebSocket-Protocol', this.protocol);\n\n var extensions = this._extensions.generateResponse(this._request.headers['sec-websocket-extensions']);\n if (extensions) this._headers.set('Sec-WebSocket-Extensions', extensions);\n\n var start = 'HTTP/1.1 101 Switching Protocols',\n headers = [start, this._headers.toString(), ''];\n\n return Buffer.from(headers.join('\\r\\n'), 'utf8');\n },\n\n _shutdown: function(code, reason, error) {\n delete this._frame;\n delete this._message;\n this._stage = 5;\n\n var sendCloseFrame = (this.readyState === 1);\n this.readyState = 2;\n\n this._extensions.close(function() {\n if (sendCloseFrame) this.frame(reason, 'close', code);\n this.readyState = 3;\n if (error) this.emit('error', new Error(reason));\n this.emit('close', new Base.CloseEvent(code, reason));\n }, this);\n },\n\n _fail: function(type, message) {\n if (this.readyState > 1) return;\n this._shutdown(this.ERRORS[type], message, true);\n },\n\n _parseOpcode: function(octet) {\n var rsvs = [this.RSV1, this.RSV2, this.RSV3].map(function(rsv) {\n return (octet & rsv) === rsv;\n });\n\n var frame = this._frame = new Frame();\n\n frame.final = (octet & this.FIN) === this.FIN;\n frame.rsv1 = rsvs[0];\n frame.rsv2 = rsvs[1];\n frame.rsv3 = rsvs[2];\n frame.opcode = (octet & this.OPCODE);\n\n this._stage = 1;\n\n if (!this._extensions.validFrameRsv(frame))\n return this._fail('protocol_error',\n 'One or more reserved bits are on: reserved1 = ' + (frame.rsv1 ? 1 : 0) +\n ', reserved2 = ' + (frame.rsv2 ? 1 : 0) +\n ', reserved3 = ' + (frame.rsv3 ? 1 : 0));\n\n if (this.OPCODE_CODES.indexOf(frame.opcode) < 0)\n return this._fail('protocol_error', 'Unrecognized frame opcode: ' + frame.opcode);\n\n if (this.MESSAGE_OPCODES.indexOf(frame.opcode) < 0 && !frame.final)\n return this._fail('protocol_error', 'Received fragmented control frame: opcode = ' + frame.opcode);\n\n if (this._message && this.OPENING_OPCODES.indexOf(frame.opcode) >= 0)\n return this._fail('protocol_error', 'Received new data frame but previous continuous frame is unfinished');\n },\n\n _parseLength: function(octet) {\n var frame = this._frame;\n frame.masked = (octet & this.MASK) === this.MASK;\n frame.length = (octet & this.LENGTH);\n\n if (frame.length >= 0 && frame.length <= 125) {\n this._stage = frame.masked ? 3 : 4;\n if (!this._checkFrameLength()) return;\n } else {\n this._stage = 2;\n frame.lengthBytes = (frame.length === 126 ? 2 : 8);\n }\n\n if (this._requireMasking && !frame.masked)\n return this._fail('unacceptable', 'Received unmasked frame but masking is required');\n },\n\n _parseExtendedLength: function(buffer) {\n var frame = this._frame;\n frame.length = this._readUInt(buffer);\n\n this._stage = frame.masked ? 3 : 4;\n\n if (this.MESSAGE_OPCODES.indexOf(frame.opcode) < 0 && frame.length > 125)\n return this._fail('protocol_error', 'Received control frame having too long payload: ' + frame.length);\n\n if (!this._checkFrameLength()) return;\n },\n\n _checkFrameLength: function() {\n var length = this._message ? this._message.length : 0;\n\n if (length + this._frame.length > this._maxLength) {\n this._fail('too_large', 'WebSocket frame length too large');\n return false;\n } else {\n return true;\n }\n },\n\n _emitFrame: function(buffer) {\n var frame = this._frame,\n payload = frame.payload = Hybi.mask(buffer, frame.maskingKey),\n opcode = frame.opcode,\n message,\n code, reason,\n callbacks, callback;\n\n delete this._frame;\n\n if (opcode === this.OPCODES.continuation) {\n if (!this._message) return this._fail('protocol_error', 'Received unexpected continuation frame');\n this._message.pushFrame(frame);\n }\n\n if (opcode === this.OPCODES.text || opcode === this.OPCODES.binary) {\n this._message = new Message();\n this._message.pushFrame(frame);\n }\n\n if (frame.final && this.MESSAGE_OPCODES.indexOf(opcode) >= 0)\n return this._emitMessage(this._message);\n\n if (opcode === this.OPCODES.close) {\n code = (payload.length >= 2) ? payload.readUInt16BE(0) : null;\n reason = (payload.length > 2) ? this._encode(payload.slice(2)) : null;\n\n if (!(payload.length === 0) &&\n !(code !== null && code >= this.MIN_RESERVED_ERROR && code <= this.MAX_RESERVED_ERROR) &&\n this.ERROR_CODES.indexOf(code) < 0)\n code = this.ERRORS.protocol_error;\n\n if (payload.length > 125 || (payload.length > 2 && !reason))\n code = this.ERRORS.protocol_error;\n\n this._shutdown(code || this.DEFAULT_ERROR_CODE, reason || '');\n }\n\n if (opcode === this.OPCODES.ping) {\n this.frame(payload, 'pong');\n this.emit('ping', new Base.PingEvent(payload.toString()))\n }\n\n if (opcode === this.OPCODES.pong) {\n callbacks = this._pingCallbacks;\n message = this._encode(payload);\n callback = callbacks[message];\n\n delete callbacks[message];\n if (callback) callback()\n\n this.emit('pong', new Base.PongEvent(payload.toString()))\n }\n },\n\n _emitMessage: function(message) {\n var message = this._message;\n message.read();\n\n delete this._message;\n\n this._extensions.processIncomingMessage(message, function(error, message) {\n if (error) return this._fail('extension_error', error.message);\n\n var payload = message.data;\n if (message.opcode === this.OPCODES.text) payload = this._encode(payload);\n\n if (payload === null)\n return this._fail('encoding_error', 'Could not decode a text frame as UTF-8');\n else\n this.emit('message', new Base.MessageEvent(payload));\n }, this);\n },\n\n _encode: function(buffer) {\n try {\n var string = buffer.toString('binary', 0, buffer.length);\n if (!this.UTF8_MATCH.test(string)) return null;\n } catch (e) {}\n return buffer.toString('utf8', 0, buffer.length);\n },\n\n _readUInt: function(buffer) {\n if (buffer.length === 2) return buffer.readUInt16BE(0);\n\n return buffer.readUInt32BE(0) * 0x100000000 +\n buffer.readUInt32BE(4);\n }\n};\n\nfor (var key in instance)\n Hybi.prototype[key] = instance[key];\n\nmodule.exports = Hybi;\n","'use strict';\n\nvar RingBuffer = function(bufferSize) {\n this._bufferSize = bufferSize;\n this.clear();\n};\n\nRingBuffer.prototype.clear = function() {\n this._buffer = new Array(this._bufferSize);\n this._ringOffset = 0;\n this._ringSize = this._bufferSize;\n this._head = 0;\n this._tail = 0;\n this.length = 0;\n};\n\nRingBuffer.prototype.push = function(value) {\n var expandBuffer = false,\n expandRing = false;\n\n if (this._ringSize < this._bufferSize) {\n expandBuffer = (this._tail === 0);\n } else if (this._ringOffset === this._ringSize) {\n expandBuffer = true;\n expandRing = (this._tail === 0);\n }\n\n if (expandBuffer) {\n this._tail = this._bufferSize;\n this._buffer = this._buffer.concat(new Array(this._bufferSize));\n this._bufferSize = this._buffer.length;\n\n if (expandRing)\n this._ringSize = this._bufferSize;\n }\n\n this._buffer[this._tail] = value;\n this.length += 1;\n if (this._tail < this._ringSize) this._ringOffset += 1;\n this._tail = (this._tail + 1) % this._bufferSize;\n};\n\nRingBuffer.prototype.peek = function() {\n if (this.length === 0) return void 0;\n return this._buffer[this._head];\n};\n\nRingBuffer.prototype.shift = function() {\n if (this.length === 0) return void 0;\n\n var value = this._buffer[this._head];\n this._buffer[this._head] = void 0;\n this.length -= 1;\n this._ringOffset -= 1;\n\n if (this._ringOffset === 0 && this.length > 0) {\n this._head = this._ringSize;\n this._ringOffset = this.length;\n this._ringSize = this._bufferSize;\n } else {\n this._head = (this._head + 1) % this._ringSize;\n }\n return value;\n};\n\nmodule.exports = RingBuffer;\n","'use strict';\n\nvar RingBuffer = require('./ring_buffer');\n\nvar Pledge = function() {\n this._complete = false;\n this._callbacks = new RingBuffer(Pledge.QUEUE_SIZE);\n};\n\nPledge.QUEUE_SIZE = 4;\n\nPledge.all = function(list) {\n var pledge = new Pledge(),\n pending = list.length,\n n = pending;\n\n if (pending === 0) pledge.done();\n\n while (n--) list[n].then(function() {\n pending -= 1;\n if (pending === 0) pledge.done();\n });\n return pledge;\n};\n\nPledge.prototype.then = function(callback) {\n if (this._complete) callback();\n else this._callbacks.push(callback);\n};\n\nPledge.prototype.done = function() {\n this._complete = true;\n var callbacks = this._callbacks, callback;\n while (callback = callbacks.shift()) callback();\n};\n\nmodule.exports = Pledge;\n","'use strict';\n\nvar Buffer = require('safe-buffer').Buffer,\n Base = require('./base'),\n util = require('util');\n\nvar Draft75 = function(request, url, options) {\n Base.apply(this, arguments);\n this._stage = 0;\n this.version = 'hixie-75';\n\n this._headers.set('Upgrade', 'WebSocket');\n this._headers.set('Connection', 'Upgrade');\n this._headers.set('WebSocket-Origin', this._request.headers.origin);\n this._headers.set('WebSocket-Location', this.url);\n};\nutil.inherits(Draft75, Base);\n\nvar instance = {\n close: function() {\n if (this.readyState === 3) return false;\n this.readyState = 3;\n this.emit('close', new Base.CloseEvent(null, null));\n return true;\n },\n\n parse: function(chunk) {\n if (this.readyState > 1) return;\n\n this._reader.put(chunk);\n\n this._reader.eachByte(function(octet) {\n var message;\n\n switch (this._stage) {\n case -1:\n this._body.push(octet);\n this._sendHandshakeBody();\n break;\n\n case 0:\n this._parseLeadingByte(octet);\n break;\n\n case 1:\n this._length = (octet & 0x7F) + 128 * this._length;\n\n if (this._closing && this._length === 0) {\n return this.close();\n }\n else if ((octet & 0x80) !== 0x80) {\n if (this._length === 0) {\n this._stage = 0;\n }\n else {\n this._skipped = 0;\n this._stage = 2;\n }\n }\n break;\n\n case 2:\n if (octet === 0xFF) {\n this._stage = 0;\n message = Buffer.from(this._buffer).toString('utf8', 0, this._buffer.length);\n this.emit('message', new Base.MessageEvent(message));\n }\n else {\n if (this._length) {\n this._skipped += 1;\n if (this._skipped === this._length)\n this._stage = 0;\n } else {\n this._buffer.push(octet);\n if (this._buffer.length > this._maxLength) return this.close();\n }\n }\n break;\n }\n }, this);\n },\n\n frame: function(buffer) {\n if (this.readyState === 0) return this._queue([buffer]);\n if (this.readyState > 1) return false;\n\n if (typeof buffer !== 'string') buffer = buffer.toString();\n\n var length = Buffer.byteLength(buffer),\n frame = Buffer.allocUnsafe(length + 2);\n\n frame[0] = 0x00;\n frame.write(buffer, 1);\n frame[frame.length - 1] = 0xFF;\n\n this._write(frame);\n return true;\n },\n\n _handshakeResponse: function() {\n var start = 'HTTP/1.1 101 Web Socket Protocol Handshake',\n headers = [start, this._headers.toString(), ''];\n\n return Buffer.from(headers.join('\\r\\n'), 'utf8');\n },\n\n _parseLeadingByte: function(octet) {\n if ((octet & 0x80) === 0x80) {\n this._length = 0;\n this._stage = 1;\n } else {\n delete this._length;\n delete this._skipped;\n this._buffer = [];\n this._stage = 2;\n }\n }\n};\n\nfor (var key in instance)\n Draft75.prototype[key] = instance[key];\n\nmodule.exports = Draft75;\n","'use strict';\n\nvar Event = require('./event');\n\nvar EventTarget = {\n onopen: null,\n onmessage: null,\n onerror: null,\n onclose: null,\n\n addEventListener: function(eventType, listener, useCapture) {\n this.on(eventType, listener);\n },\n\n removeEventListener: function(eventType, listener, useCapture) {\n this.removeListener(eventType, listener);\n },\n\n dispatchEvent: function(event) {\n event.target = event.currentTarget = this;\n event.eventPhase = Event.AT_TARGET;\n\n if (this['on' + event.type])\n this['on' + event.type](event);\n\n this.emit(event.type, event);\n }\n};\n\nmodule.exports = EventTarget;\n","// Copyright (C) 2016 Dmitry Chestnykh\n// MIT License. See LICENSE file for details.\n\n/**\n * Package utf8 implements UTF-8 encoding and decoding.\n */\n\nconst INVALID_UTF16 = \"utf8: invalid string\";\nconst INVALID_UTF8 = \"utf8: invalid source encoding\";\n\n/**\n * Encodes the given string into UTF-8 byte array.\n * Throws if the source string has invalid UTF-16 encoding.\n */\nexport function encode(s: string): Uint8Array {\n // Calculate result length and allocate output array.\n // encodedLength() also validates string and throws errors,\n // so we don't need repeat validation here.\n const arr = new Uint8Array(encodedLength(s));\n\n let pos = 0;\n for (let i = 0; i < s.length; i++) {\n let c = s.charCodeAt(i);\n if (c < 0x80) {\n arr[pos++] = c;\n } else if (c < 0x800) {\n arr[pos++] = 0xc0 | c >> 6;\n arr[pos++] = 0x80 | c & 0x3f;\n } else if (c < 0xd800) {\n arr[pos++] = 0xe0 | c >> 12;\n arr[pos++] = 0x80 | (c >> 6) & 0x3f;\n arr[pos++] = 0x80 | c & 0x3f;\n } else {\n i++; // get one more character\n c = (c & 0x3ff) << 10;\n c |= s.charCodeAt(i) & 0x3ff;\n c += 0x10000;\n\n arr[pos++] = 0xf0 | c >> 18;\n arr[pos++] = 0x80 | (c >> 12) & 0x3f;\n arr[pos++] = 0x80 | (c >> 6) & 0x3f;\n arr[pos++] = 0x80 | c & 0x3f;\n }\n }\n return arr;\n}\n\n/**\n * Returns the number of bytes required to encode the given string into UTF-8.\n * Throws if the source string has invalid UTF-16 encoding.\n */\nexport function encodedLength(s: string): number {\n let result = 0;\n for (let i = 0; i < s.length; i++) {\n const c = s.charCodeAt(i);\n if (c < 0x80) {\n result += 1;\n } else if (c < 0x800) {\n result += 2;\n } else if (c < 0xd800) {\n result += 3;\n } else if (c <= 0xdfff) {\n if (i >= s.length - 1) {\n throw new Error(INVALID_UTF16);\n }\n i++; // \"eat\" next character\n result += 4;\n } else {\n throw new Error(INVALID_UTF16);\n }\n }\n return result;\n}\n\n/**\n * Decodes the given byte array from UTF-8 into a string.\n * Throws if encoding is invalid.\n */\nexport function decode(arr: Uint8Array): string {\n const chars: string[] = [];\n for (let i = 0; i < arr.length; i++) {\n let b = arr[i];\n\n if (b & 0x80) {\n let min;\n if (b < 0xe0) {\n // Need 1 more byte.\n if (i >= arr.length) {\n throw new Error(INVALID_UTF8);\n }\n const n1 = arr[++i];\n if ((n1 & 0xc0) !== 0x80) {\n throw new Error(INVALID_UTF8);\n }\n b = (b & 0x1f) << 6 | (n1 & 0x3f);\n min = 0x80;\n } else if (b < 0xf0) {\n // Need 2 more bytes.\n if (i >= arr.length - 1) {\n throw new Error(INVALID_UTF8);\n }\n const n1 = arr[++i];\n const n2 = arr[++i];\n if ((n1 & 0xc0) !== 0x80 || (n2 & 0xc0) !== 0x80) {\n throw new Error(INVALID_UTF8);\n }\n b = (b & 0x0f) << 12 | (n1 & 0x3f) << 6 | (n2 & 0x3f);\n min = 0x800;\n } else if (b < 0xf8) {\n // Need 3 more bytes.\n if (i >= arr.length - 2) {\n throw new Error(INVALID_UTF8);\n }\n const n1 = arr[++i];\n const n2 = arr[++i];\n const n3 = arr[++i];\n if ((n1 & 0xc0) !== 0x80 || (n2 & 0xc0) !== 0x80 || (n3 & 0xc0) !== 0x80) {\n throw new Error(INVALID_UTF8);\n }\n b = (b & 0x0f) << 18 | (n1 & 0x3f) << 12 | (n2 & 0x3f) << 6 | (n3 & 0x3f);\n min = 0x10000;\n } else {\n throw new Error(INVALID_UTF8);\n }\n\n if (b < min || (b >= 0xd800 && b <= 0xdfff)) {\n throw new Error(INVALID_UTF8);\n }\n\n if (b >= 0x10000) {\n // Surrogate pair.\n if (b > 0x10ffff) {\n throw new Error(INVALID_UTF8);\n }\n b -= 0x10000;\n chars.push(String.fromCharCode(0xd800 | (b >> 10)));\n b = 0xdc00 | (b & 0x3ff);\n }\n }\n\n chars.push(String.fromCharCode(b));\n }\n return chars.join(\"\");\n}\n","// API references:\n//\n// * https://html.spec.whatwg.org/multipage/comms.html#network\n// * https://dom.spec.whatwg.org/#interface-eventtarget\n// * https://dom.spec.whatwg.org/#interface-event\n\n'use strict';\n\nvar util = require('util'),\n driver = require('websocket-driver'),\n API = require('./websocket/api');\n\nvar WebSocket = function(request, socket, body, protocols, options) {\n options = options || {};\n\n this._stream = socket;\n this._driver = driver.http(request, {maxLength: options.maxLength, protocols: protocols});\n\n var self = this;\n if (!this._stream || !this._stream.writable) return;\n if (!this._stream.readable) return this._stream.end();\n\n var catchup = function() { self._stream.removeListener('data', catchup) };\n this._stream.on('data', catchup);\n\n API.call(this, options);\n\n process.nextTick(function() {\n self._driver.start();\n self._driver.io.write(body);\n });\n};\nutil.inherits(WebSocket, API);\n\nWebSocket.isWebSocket = function(request) {\n return driver.isWebSocket(request);\n};\n\nWebSocket.validateOptions = function(options, validKeys) {\n driver.validateOptions(options, validKeys);\n};\n\nWebSocket.WebSocket = WebSocket;\nWebSocket.Client = require('./websocket/client');\nWebSocket.EventSource = require('./eventsource');\n\nmodule.exports = WebSocket;\n","/**\n * Wrapper for built-in http.js to emulate the browser XMLHttpRequest object.\n *\n * This can be used with JS designed for browsers to improve reuse of code and\n * allow the use of existing libraries.\n *\n * Usage: include(\"XMLHttpRequest.js\") and use XMLHttpRequest per W3C specs.\n *\n * @author Dan DeFelippi \n * @contributor David Ellis \n * @license MIT\n */\n\nvar Url = require(\"url\");\nvar spawn = require(\"child_process\").spawn;\nvar fs = require(\"fs\");\n\nexports.XMLHttpRequest = function() {\n \"use strict\";\n\n /**\n * Private variables\n */\n var self = this;\n var http = require(\"http\");\n var https = require(\"https\");\n\n // Holds http.js objects\n var request;\n var response;\n\n // Request settings\n var settings = {};\n\n // Disable header blacklist.\n // Not part of XHR specs.\n var disableHeaderCheck = false;\n\n // Set some default headers\n var defaultHeaders = {\n \"User-Agent\": \"node-XMLHttpRequest\",\n \"Accept\": \"*/*\",\n };\n\n var headers = {};\n var headersCase = {};\n\n // These headers are not user setable.\n // The following are allowed but banned in the spec:\n // * user-agent\n var forbiddenRequestHeaders = [\n \"accept-charset\",\n \"accept-encoding\",\n \"access-control-request-headers\",\n \"access-control-request-method\",\n \"connection\",\n \"content-length\",\n \"content-transfer-encoding\",\n \"cookie\",\n \"cookie2\",\n \"date\",\n \"expect\",\n \"host\",\n \"keep-alive\",\n \"origin\",\n \"referer\",\n \"te\",\n \"trailer\",\n \"transfer-encoding\",\n \"upgrade\",\n \"via\"\n ];\n\n // These request methods are not allowed\n var forbiddenRequestMethods = [\n \"TRACE\",\n \"TRACK\",\n \"CONNECT\"\n ];\n\n // Send flag\n var sendFlag = false;\n // Error flag, used when errors occur or abort is called\n var errorFlag = false;\n\n // Event listeners\n var listeners = {};\n\n /**\n * Constants\n */\n\n this.UNSENT = 0;\n this.OPENED = 1;\n this.HEADERS_RECEIVED = 2;\n this.LOADING = 3;\n this.DONE = 4;\n\n /**\n * Public vars\n */\n\n // Current state\n this.readyState = this.UNSENT;\n\n // default ready state change handler in case one is not set or is set late\n this.onreadystatechange = null;\n\n // Result & response\n this.responseText = \"\";\n this.responseXML = \"\";\n this.status = null;\n this.statusText = null;\n \n // Whether cross-site Access-Control requests should be made using\n // credentials such as cookies or authorization headers\n this.withCredentials = false;\n\n /**\n * Private methods\n */\n\n /**\n * Check if the specified header is allowed.\n *\n * @param string header Header to validate\n * @return boolean False if not allowed, otherwise true\n */\n var isAllowedHttpHeader = function(header) {\n return disableHeaderCheck || (header && forbiddenRequestHeaders.indexOf(header.toLowerCase()) === -1);\n };\n\n /**\n * Check if the specified method is allowed.\n *\n * @param string method Request method to validate\n * @return boolean False if not allowed, otherwise true\n */\n var isAllowedHttpMethod = function(method) {\n return (method && forbiddenRequestMethods.indexOf(method) === -1);\n };\n\n /**\n * Public methods\n */\n\n /**\n * Open the connection. Currently supports local server requests.\n *\n * @param string method Connection method (eg GET, POST)\n * @param string url URL for the connection.\n * @param boolean async Asynchronous connection. Default is true.\n * @param string user Username for basic authentication (optional)\n * @param string password Password for basic authentication (optional)\n */\n this.open = function(method, url, async, user, password) {\n this.abort();\n errorFlag = false;\n\n // Check for valid request method\n if (!isAllowedHttpMethod(method)) {\n throw new Error(\"SecurityError: Request method not allowed\");\n }\n\n settings = {\n \"method\": method,\n \"url\": url.toString(),\n \"async\": (typeof async !== \"boolean\" ? true : async),\n \"user\": user || null,\n \"password\": password || null\n };\n\n setState(this.OPENED);\n };\n\n /**\n * Disables or enables isAllowedHttpHeader() check the request. Enabled by default.\n * This does not conform to the W3C spec.\n *\n * @param boolean state Enable or disable header checking.\n */\n this.setDisableHeaderCheck = function(state) {\n disableHeaderCheck = state;\n };\n\n /**\n * Sets a header for the request or appends the value if one is already set.\n *\n * @param string header Header name\n * @param string value Header value\n */\n this.setRequestHeader = function(header, value) {\n if (this.readyState !== this.OPENED) {\n throw new Error(\"INVALID_STATE_ERR: setRequestHeader can only be called when state is OPEN\");\n }\n if (!isAllowedHttpHeader(header)) {\n console.warn(\"Refused to set unsafe header \\\"\" + header + \"\\\"\");\n return;\n }\n if (sendFlag) {\n throw new Error(\"INVALID_STATE_ERR: send flag is true\");\n }\n header = headersCase[header.toLowerCase()] || header;\n headersCase[header.toLowerCase()] = header;\n headers[header] = headers[header] ? headers[header] + ', ' + value : value;\n };\n\n /**\n * Gets a header from the server response.\n *\n * @param string header Name of header to get.\n * @return string Text of the header or null if it doesn't exist.\n */\n this.getResponseHeader = function(header) {\n if (typeof header === \"string\"\n && this.readyState > this.OPENED\n && response\n && response.headers\n && response.headers[header.toLowerCase()]\n && !errorFlag\n ) {\n return response.headers[header.toLowerCase()];\n }\n\n return null;\n };\n\n /**\n * Gets all the response headers.\n *\n * @return string A string with all response headers separated by CR+LF\n */\n this.getAllResponseHeaders = function() {\n if (this.readyState < this.HEADERS_RECEIVED || errorFlag) {\n return \"\";\n }\n var result = \"\";\n\n for (var i in response.headers) {\n // Cookie headers are excluded\n if (i !== \"set-cookie\" && i !== \"set-cookie2\") {\n result += i + \": \" + response.headers[i] + \"\\r\\n\";\n }\n }\n return result.substr(0, result.length - 2);\n };\n\n /**\n * Gets a request header\n *\n * @param string name Name of header to get\n * @return string Returns the request header or empty string if not set\n */\n this.getRequestHeader = function(name) {\n if (typeof name === \"string\" && headersCase[name.toLowerCase()]) {\n return headers[headersCase[name.toLowerCase()]];\n }\n\n return \"\";\n };\n\n /**\n * Sends the request to the server.\n *\n * @param string data Optional data to send as request body.\n */\n this.send = function(data) {\n if (this.readyState !== this.OPENED) {\n throw new Error(\"INVALID_STATE_ERR: connection must be opened before send() is called\");\n }\n\n if (sendFlag) {\n throw new Error(\"INVALID_STATE_ERR: send has already been called\");\n }\n\n var ssl = false, local = false;\n var url = Url.parse(settings.url);\n var host;\n // Determine the server\n switch (url.protocol) {\n case \"https:\":\n ssl = true;\n // SSL & non-SSL both need host, no break here.\n case \"http:\":\n host = url.hostname;\n break;\n\n case \"file:\":\n local = true;\n break;\n\n case undefined:\n case null:\n case \"\":\n host = \"localhost\";\n break;\n\n default:\n throw new Error(\"Protocol not supported.\");\n }\n\n // Load files off the local filesystem (file://)\n if (local) {\n if (settings.method !== \"GET\") {\n throw new Error(\"XMLHttpRequest: Only GET method is supported\");\n }\n\n if (settings.async) {\n fs.readFile(url.pathname, \"utf8\", function(error, data) {\n if (error) {\n self.handleError(error);\n } else {\n self.status = 200;\n self.responseText = data;\n setState(self.DONE);\n }\n });\n } else {\n try {\n this.responseText = fs.readFileSync(url.pathname, \"utf8\");\n this.status = 200;\n setState(self.DONE);\n } catch(e) {\n this.handleError(e);\n }\n }\n\n return;\n }\n\n // Default to port 80. If accessing localhost on another port be sure\n // to use http://localhost:port/path\n var port = url.port || (ssl ? 443 : 80);\n // Add query string if one is used\n var uri = url.pathname + (url.search ? url.search : \"\");\n\n // Set the defaults if they haven't been set\n for (var name in defaultHeaders) {\n if (!headersCase[name.toLowerCase()]) {\n headers[name] = defaultHeaders[name];\n }\n }\n\n // Set the Host header or the server may reject the request\n headers.Host = host;\n if (!((ssl && port === 443) || port === 80)) {\n headers.Host += \":\" + url.port;\n }\n\n // Set Basic Auth if necessary\n if (settings.user) {\n if (typeof settings.password === \"undefined\") {\n settings.password = \"\";\n }\n var authBuf = new Buffer(settings.user + \":\" + settings.password);\n headers.Authorization = \"Basic \" + authBuf.toString(\"base64\");\n }\n\n // Set content length header\n if (settings.method === \"GET\" || settings.method === \"HEAD\") {\n data = null;\n } else if (data) {\n headers[\"Content-Length\"] = Buffer.isBuffer(data) ? data.length : Buffer.byteLength(data);\n\n if (!headers[\"Content-Type\"]) {\n headers[\"Content-Type\"] = \"text/plain;charset=UTF-8\";\n }\n } else if (settings.method === \"POST\") {\n // For a post with no data set Content-Length: 0.\n // This is required by buggy servers that don't meet the specs.\n headers[\"Content-Length\"] = 0;\n }\n\n var options = {\n host: host,\n port: port,\n path: uri,\n method: settings.method,\n headers: headers,\n agent: false,\n withCredentials: self.withCredentials\n };\n\n // Reset error flag\n errorFlag = false;\n\n // Handle async requests\n if (settings.async) {\n // Use the proper protocol\n var doRequest = ssl ? https.request : http.request;\n\n // Request is being sent, set send flag\n sendFlag = true;\n\n // As per spec, this is called here for historical reasons.\n self.dispatchEvent(\"readystatechange\");\n\n // Handler for the response\n var responseHandler = function responseHandler(resp) {\n // Set response var to the response we got back\n // This is so it remains accessable outside this scope\n response = resp;\n // Check for redirect\n // @TODO Prevent looped redirects\n if (response.statusCode === 301 || response.statusCode === 302 || response.statusCode === 303 || response.statusCode === 307) {\n // Change URL to the redirect location\n settings.url = response.headers.location;\n var url = Url.parse(settings.url);\n // Set host var in case it's used later\n host = url.hostname;\n // Options for the new request\n var newOptions = {\n hostname: url.hostname,\n port: url.port,\n path: url.path,\n method: response.statusCode === 303 ? \"GET\" : settings.method,\n headers: headers,\n withCredentials: self.withCredentials\n };\n\n // Issue the new request\n request = doRequest(newOptions, responseHandler).on(\"error\", errorHandler);\n request.end();\n // @TODO Check if an XHR event needs to be fired here\n return;\n }\n\n response.setEncoding(\"utf8\");\n\n setState(self.HEADERS_RECEIVED);\n self.status = response.statusCode;\n\n response.on(\"data\", function(chunk) {\n // Make sure there's some data\n if (chunk) {\n self.responseText += chunk;\n }\n // Don't emit state changes if the connection has been aborted.\n if (sendFlag) {\n setState(self.LOADING);\n }\n });\n\n response.on(\"end\", function() {\n if (sendFlag) {\n // Discard the end event if the connection has been aborted\n setState(self.DONE);\n sendFlag = false;\n }\n });\n\n response.on(\"error\", function(error) {\n self.handleError(error);\n });\n };\n\n // Error handler for the request\n var errorHandler = function errorHandler(error) {\n self.handleError(error);\n };\n\n // Create the request\n request = doRequest(options, responseHandler).on(\"error\", errorHandler);\n\n // Node 0.4 and later won't accept empty data. Make sure it's needed.\n if (data) {\n request.write(data);\n }\n\n request.end();\n\n self.dispatchEvent(\"loadstart\");\n } else { // Synchronous\n // Create a temporary file for communication with the other Node process\n var contentFile = \".node-xmlhttprequest-content-\" + process.pid;\n var syncFile = \".node-xmlhttprequest-sync-\" + process.pid;\n fs.writeFileSync(syncFile, \"\", \"utf8\");\n // The async request the other Node process executes\n var execString = \"var http = require('http'), https = require('https'), fs = require('fs');\"\n + \"var doRequest = http\" + (ssl ? \"s\" : \"\") + \".request;\"\n + \"var options = \" + JSON.stringify(options) + \";\"\n + \"var responseText = '';\"\n + \"var req = doRequest(options, function(response) {\"\n + \"response.setEncoding('utf8');\"\n + \"response.on('data', function(chunk) {\"\n + \" responseText += chunk;\"\n + \"});\"\n + \"response.on('end', function() {\"\n + \"fs.writeFileSync('\" + contentFile + \"', JSON.stringify({err: null, data: {statusCode: response.statusCode, headers: response.headers, text: responseText}}), 'utf8');\"\n + \"fs.unlinkSync('\" + syncFile + \"');\"\n + \"});\"\n + \"response.on('error', function(error) {\"\n + \"fs.writeFileSync('\" + contentFile + \"', JSON.stringify({err: error}), 'utf8');\"\n + \"fs.unlinkSync('\" + syncFile + \"');\"\n + \"});\"\n + \"}).on('error', function(error) {\"\n + \"fs.writeFileSync('\" + contentFile + \"', JSON.stringify({err: error}), 'utf8');\"\n + \"fs.unlinkSync('\" + syncFile + \"');\"\n + \"});\"\n + (data ? \"req.write('\" + JSON.stringify(data).slice(1,-1).replace(/'/g, \"\\\\'\") + \"');\":\"\")\n + \"req.end();\";\n // Start the other Node Process, executing this string\n var syncProc = spawn(process.argv[0], [\"-e\", execString]);\n while(fs.existsSync(syncFile)) {\n // Wait while the sync file is empty\n }\n var resp = JSON.parse(fs.readFileSync(contentFile, 'utf8'));\n // Kill the child process once the file has data\n syncProc.stdin.end();\n // Remove the temporary file\n fs.unlinkSync(contentFile);\n\n if (resp.err) {\n self.handleError(resp.err);\n } else {\n response = resp.data;\n self.status = resp.data.statusCode;\n self.responseText = resp.data.text;\n setState(self.DONE);\n }\n }\n };\n\n /**\n * Called when an error is encountered to deal with it.\n */\n this.handleError = function(error) {\n this.status = 0;\n this.statusText = error;\n this.responseText = error.stack;\n errorFlag = true;\n setState(this.DONE);\n this.dispatchEvent('error');\n };\n\n /**\n * Aborts a request.\n */\n this.abort = function() {\n if (request) {\n request.abort();\n request = null;\n }\n\n headers = defaultHeaders;\n this.status = 0;\n this.responseText = \"\";\n this.responseXML = \"\";\n\n errorFlag = true;\n\n if (this.readyState !== this.UNSENT\n && (this.readyState !== this.OPENED || sendFlag)\n && this.readyState !== this.DONE) {\n sendFlag = false;\n setState(this.DONE);\n }\n this.readyState = this.UNSENT;\n this.dispatchEvent('abort');\n };\n\n /**\n * Adds an event listener. Preferred method of binding to events.\n */\n this.addEventListener = function(event, callback) {\n if (!(event in listeners)) {\n listeners[event] = [];\n }\n // Currently allows duplicate callbacks. Should it?\n listeners[event].push(callback);\n };\n\n /**\n * Remove an event callback that has already been bound.\n * Only works on the matching funciton, cannot be a copy.\n */\n this.removeEventListener = function(event, callback) {\n if (event in listeners) {\n // Filter will return a new array with the callback removed\n listeners[event] = listeners[event].filter(function(ev) {\n return ev !== callback;\n });\n }\n };\n\n /**\n * Dispatch any events, including both \"on\" methods and events attached using addEventListener.\n */\n this.dispatchEvent = function(event) {\n if (typeof self[\"on\" + event] === \"function\") {\n self[\"on\" + event]();\n }\n if (event in listeners) {\n for (var i = 0, len = listeners[event].length; i < len; i++) {\n listeners[event][i].call(self);\n }\n }\n };\n\n /**\n * Changes readyState and calls onreadystatechange.\n *\n * @param int state New state\n */\n var setState = function(state) {\n if (state == self.LOADING || self.readyState !== state) {\n self.readyState = state;\n\n if (settings.async || self.readyState < self.OPENED || self.readyState === self.DONE) {\n self.dispatchEvent(\"readystatechange\");\n }\n\n if (self.readyState === self.DONE && !errorFlag) {\n self.dispatchEvent(\"load\");\n // @TODO figure out InspectorInstrumentation::didLoadXHR(cookie)\n self.dispatchEvent(\"loadend\");\n }\n }\n };\n};\n","(function(nacl) {\n'use strict';\n\n// Ported in 2014 by Dmitry Chestnykh and Devi Mandiri.\n// Public domain.\n//\n// Implementation derived from TweetNaCl version 20140427.\n// See for details: http://tweetnacl.cr.yp.to/\n\nvar gf = function(init) {\n var i, r = new Float64Array(16);\n if (init) for (i = 0; i < init.length; i++) r[i] = init[i];\n return r;\n};\n\n// Pluggable, initialized in high-level API below.\nvar randombytes = function(/* x, n */) { throw new Error('no PRNG'); };\n\nvar _0 = new Uint8Array(16);\nvar _9 = new Uint8Array(32); _9[0] = 9;\n\nvar gf0 = gf(),\n gf1 = gf([1]),\n _121665 = gf([0xdb41, 1]),\n D = gf([0x78a3, 0x1359, 0x4dca, 0x75eb, 0xd8ab, 0x4141, 0x0a4d, 0x0070, 0xe898, 0x7779, 0x4079, 0x8cc7, 0xfe73, 0x2b6f, 0x6cee, 0x5203]),\n D2 = gf([0xf159, 0x26b2, 0x9b94, 0xebd6, 0xb156, 0x8283, 0x149a, 0x00e0, 0xd130, 0xeef3, 0x80f2, 0x198e, 0xfce7, 0x56df, 0xd9dc, 0x2406]),\n X = gf([0xd51a, 0x8f25, 0x2d60, 0xc956, 0xa7b2, 0x9525, 0xc760, 0x692c, 0xdc5c, 0xfdd6, 0xe231, 0xc0a4, 0x53fe, 0xcd6e, 0x36d3, 0x2169]),\n Y = gf([0x6658, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666]),\n I = gf([0xa0b0, 0x4a0e, 0x1b27, 0xc4ee, 0xe478, 0xad2f, 0x1806, 0x2f43, 0xd7a7, 0x3dfb, 0x0099, 0x2b4d, 0xdf0b, 0x4fc1, 0x2480, 0x2b83]);\n\nfunction ts64(x, i, h, l) {\n x[i] = (h >> 24) & 0xff;\n x[i+1] = (h >> 16) & 0xff;\n x[i+2] = (h >> 8) & 0xff;\n x[i+3] = h & 0xff;\n x[i+4] = (l >> 24) & 0xff;\n x[i+5] = (l >> 16) & 0xff;\n x[i+6] = (l >> 8) & 0xff;\n x[i+7] = l & 0xff;\n}\n\nfunction vn(x, xi, y, yi, n) {\n var i,d = 0;\n for (i = 0; i < n; i++) d |= x[xi+i]^y[yi+i];\n return (1 & ((d - 1) >>> 8)) - 1;\n}\n\nfunction crypto_verify_16(x, xi, y, yi) {\n return vn(x,xi,y,yi,16);\n}\n\nfunction crypto_verify_32(x, xi, y, yi) {\n return vn(x,xi,y,yi,32);\n}\n\nfunction core_salsa20(o, p, k, c) {\n var j0 = c[ 0] & 0xff | (c[ 1] & 0xff)<<8 | (c[ 2] & 0xff)<<16 | (c[ 3] & 0xff)<<24,\n j1 = k[ 0] & 0xff | (k[ 1] & 0xff)<<8 | (k[ 2] & 0xff)<<16 | (k[ 3] & 0xff)<<24,\n j2 = k[ 4] & 0xff | (k[ 5] & 0xff)<<8 | (k[ 6] & 0xff)<<16 | (k[ 7] & 0xff)<<24,\n j3 = k[ 8] & 0xff | (k[ 9] & 0xff)<<8 | (k[10] & 0xff)<<16 | (k[11] & 0xff)<<24,\n j4 = k[12] & 0xff | (k[13] & 0xff)<<8 | (k[14] & 0xff)<<16 | (k[15] & 0xff)<<24,\n j5 = c[ 4] & 0xff | (c[ 5] & 0xff)<<8 | (c[ 6] & 0xff)<<16 | (c[ 7] & 0xff)<<24,\n j6 = p[ 0] & 0xff | (p[ 1] & 0xff)<<8 | (p[ 2] & 0xff)<<16 | (p[ 3] & 0xff)<<24,\n j7 = p[ 4] & 0xff | (p[ 5] & 0xff)<<8 | (p[ 6] & 0xff)<<16 | (p[ 7] & 0xff)<<24,\n j8 = p[ 8] & 0xff | (p[ 9] & 0xff)<<8 | (p[10] & 0xff)<<16 | (p[11] & 0xff)<<24,\n j9 = p[12] & 0xff | (p[13] & 0xff)<<8 | (p[14] & 0xff)<<16 | (p[15] & 0xff)<<24,\n j10 = c[ 8] & 0xff | (c[ 9] & 0xff)<<8 | (c[10] & 0xff)<<16 | (c[11] & 0xff)<<24,\n j11 = k[16] & 0xff | (k[17] & 0xff)<<8 | (k[18] & 0xff)<<16 | (k[19] & 0xff)<<24,\n j12 = k[20] & 0xff | (k[21] & 0xff)<<8 | (k[22] & 0xff)<<16 | (k[23] & 0xff)<<24,\n j13 = k[24] & 0xff | (k[25] & 0xff)<<8 | (k[26] & 0xff)<<16 | (k[27] & 0xff)<<24,\n j14 = k[28] & 0xff | (k[29] & 0xff)<<8 | (k[30] & 0xff)<<16 | (k[31] & 0xff)<<24,\n j15 = c[12] & 0xff | (c[13] & 0xff)<<8 | (c[14] & 0xff)<<16 | (c[15] & 0xff)<<24;\n\n var x0 = j0, x1 = j1, x2 = j2, x3 = j3, x4 = j4, x5 = j5, x6 = j6, x7 = j7,\n x8 = j8, x9 = j9, x10 = j10, x11 = j11, x12 = j12, x13 = j13, x14 = j14,\n x15 = j15, u;\n\n for (var i = 0; i < 20; i += 2) {\n u = x0 + x12 | 0;\n x4 ^= u<<7 | u>>>(32-7);\n u = x4 + x0 | 0;\n x8 ^= u<<9 | u>>>(32-9);\n u = x8 + x4 | 0;\n x12 ^= u<<13 | u>>>(32-13);\n u = x12 + x8 | 0;\n x0 ^= u<<18 | u>>>(32-18);\n\n u = x5 + x1 | 0;\n x9 ^= u<<7 | u>>>(32-7);\n u = x9 + x5 | 0;\n x13 ^= u<<9 | u>>>(32-9);\n u = x13 + x9 | 0;\n x1 ^= u<<13 | u>>>(32-13);\n u = x1 + x13 | 0;\n x5 ^= u<<18 | u>>>(32-18);\n\n u = x10 + x6 | 0;\n x14 ^= u<<7 | u>>>(32-7);\n u = x14 + x10 | 0;\n x2 ^= u<<9 | u>>>(32-9);\n u = x2 + x14 | 0;\n x6 ^= u<<13 | u>>>(32-13);\n u = x6 + x2 | 0;\n x10 ^= u<<18 | u>>>(32-18);\n\n u = x15 + x11 | 0;\n x3 ^= u<<7 | u>>>(32-7);\n u = x3 + x15 | 0;\n x7 ^= u<<9 | u>>>(32-9);\n u = x7 + x3 | 0;\n x11 ^= u<<13 | u>>>(32-13);\n u = x11 + x7 | 0;\n x15 ^= u<<18 | u>>>(32-18);\n\n u = x0 + x3 | 0;\n x1 ^= u<<7 | u>>>(32-7);\n u = x1 + x0 | 0;\n x2 ^= u<<9 | u>>>(32-9);\n u = x2 + x1 | 0;\n x3 ^= u<<13 | u>>>(32-13);\n u = x3 + x2 | 0;\n x0 ^= u<<18 | u>>>(32-18);\n\n u = x5 + x4 | 0;\n x6 ^= u<<7 | u>>>(32-7);\n u = x6 + x5 | 0;\n x7 ^= u<<9 | u>>>(32-9);\n u = x7 + x6 | 0;\n x4 ^= u<<13 | u>>>(32-13);\n u = x4 + x7 | 0;\n x5 ^= u<<18 | u>>>(32-18);\n\n u = x10 + x9 | 0;\n x11 ^= u<<7 | u>>>(32-7);\n u = x11 + x10 | 0;\n x8 ^= u<<9 | u>>>(32-9);\n u = x8 + x11 | 0;\n x9 ^= u<<13 | u>>>(32-13);\n u = x9 + x8 | 0;\n x10 ^= u<<18 | u>>>(32-18);\n\n u = x15 + x14 | 0;\n x12 ^= u<<7 | u>>>(32-7);\n u = x12 + x15 | 0;\n x13 ^= u<<9 | u>>>(32-9);\n u = x13 + x12 | 0;\n x14 ^= u<<13 | u>>>(32-13);\n u = x14 + x13 | 0;\n x15 ^= u<<18 | u>>>(32-18);\n }\n x0 = x0 + j0 | 0;\n x1 = x1 + j1 | 0;\n x2 = x2 + j2 | 0;\n x3 = x3 + j3 | 0;\n x4 = x4 + j4 | 0;\n x5 = x5 + j5 | 0;\n x6 = x6 + j6 | 0;\n x7 = x7 + j7 | 0;\n x8 = x8 + j8 | 0;\n x9 = x9 + j9 | 0;\n x10 = x10 + j10 | 0;\n x11 = x11 + j11 | 0;\n x12 = x12 + j12 | 0;\n x13 = x13 + j13 | 0;\n x14 = x14 + j14 | 0;\n x15 = x15 + j15 | 0;\n\n o[ 0] = x0 >>> 0 & 0xff;\n o[ 1] = x0 >>> 8 & 0xff;\n o[ 2] = x0 >>> 16 & 0xff;\n o[ 3] = x0 >>> 24 & 0xff;\n\n o[ 4] = x1 >>> 0 & 0xff;\n o[ 5] = x1 >>> 8 & 0xff;\n o[ 6] = x1 >>> 16 & 0xff;\n o[ 7] = x1 >>> 24 & 0xff;\n\n o[ 8] = x2 >>> 0 & 0xff;\n o[ 9] = x2 >>> 8 & 0xff;\n o[10] = x2 >>> 16 & 0xff;\n o[11] = x2 >>> 24 & 0xff;\n\n o[12] = x3 >>> 0 & 0xff;\n o[13] = x3 >>> 8 & 0xff;\n o[14] = x3 >>> 16 & 0xff;\n o[15] = x3 >>> 24 & 0xff;\n\n o[16] = x4 >>> 0 & 0xff;\n o[17] = x4 >>> 8 & 0xff;\n o[18] = x4 >>> 16 & 0xff;\n o[19] = x4 >>> 24 & 0xff;\n\n o[20] = x5 >>> 0 & 0xff;\n o[21] = x5 >>> 8 & 0xff;\n o[22] = x5 >>> 16 & 0xff;\n o[23] = x5 >>> 24 & 0xff;\n\n o[24] = x6 >>> 0 & 0xff;\n o[25] = x6 >>> 8 & 0xff;\n o[26] = x6 >>> 16 & 0xff;\n o[27] = x6 >>> 24 & 0xff;\n\n o[28] = x7 >>> 0 & 0xff;\n o[29] = x7 >>> 8 & 0xff;\n o[30] = x7 >>> 16 & 0xff;\n o[31] = x7 >>> 24 & 0xff;\n\n o[32] = x8 >>> 0 & 0xff;\n o[33] = x8 >>> 8 & 0xff;\n o[34] = x8 >>> 16 & 0xff;\n o[35] = x8 >>> 24 & 0xff;\n\n o[36] = x9 >>> 0 & 0xff;\n o[37] = x9 >>> 8 & 0xff;\n o[38] = x9 >>> 16 & 0xff;\n o[39] = x9 >>> 24 & 0xff;\n\n o[40] = x10 >>> 0 & 0xff;\n o[41] = x10 >>> 8 & 0xff;\n o[42] = x10 >>> 16 & 0xff;\n o[43] = x10 >>> 24 & 0xff;\n\n o[44] = x11 >>> 0 & 0xff;\n o[45] = x11 >>> 8 & 0xff;\n o[46] = x11 >>> 16 & 0xff;\n o[47] = x11 >>> 24 & 0xff;\n\n o[48] = x12 >>> 0 & 0xff;\n o[49] = x12 >>> 8 & 0xff;\n o[50] = x12 >>> 16 & 0xff;\n o[51] = x12 >>> 24 & 0xff;\n\n o[52] = x13 >>> 0 & 0xff;\n o[53] = x13 >>> 8 & 0xff;\n o[54] = x13 >>> 16 & 0xff;\n o[55] = x13 >>> 24 & 0xff;\n\n o[56] = x14 >>> 0 & 0xff;\n o[57] = x14 >>> 8 & 0xff;\n o[58] = x14 >>> 16 & 0xff;\n o[59] = x14 >>> 24 & 0xff;\n\n o[60] = x15 >>> 0 & 0xff;\n o[61] = x15 >>> 8 & 0xff;\n o[62] = x15 >>> 16 & 0xff;\n o[63] = x15 >>> 24 & 0xff;\n}\n\nfunction core_hsalsa20(o,p,k,c) {\n var j0 = c[ 0] & 0xff | (c[ 1] & 0xff)<<8 | (c[ 2] & 0xff)<<16 | (c[ 3] & 0xff)<<24,\n j1 = k[ 0] & 0xff | (k[ 1] & 0xff)<<8 | (k[ 2] & 0xff)<<16 | (k[ 3] & 0xff)<<24,\n j2 = k[ 4] & 0xff | (k[ 5] & 0xff)<<8 | (k[ 6] & 0xff)<<16 | (k[ 7] & 0xff)<<24,\n j3 = k[ 8] & 0xff | (k[ 9] & 0xff)<<8 | (k[10] & 0xff)<<16 | (k[11] & 0xff)<<24,\n j4 = k[12] & 0xff | (k[13] & 0xff)<<8 | (k[14] & 0xff)<<16 | (k[15] & 0xff)<<24,\n j5 = c[ 4] & 0xff | (c[ 5] & 0xff)<<8 | (c[ 6] & 0xff)<<16 | (c[ 7] & 0xff)<<24,\n j6 = p[ 0] & 0xff | (p[ 1] & 0xff)<<8 | (p[ 2] & 0xff)<<16 | (p[ 3] & 0xff)<<24,\n j7 = p[ 4] & 0xff | (p[ 5] & 0xff)<<8 | (p[ 6] & 0xff)<<16 | (p[ 7] & 0xff)<<24,\n j8 = p[ 8] & 0xff | (p[ 9] & 0xff)<<8 | (p[10] & 0xff)<<16 | (p[11] & 0xff)<<24,\n j9 = p[12] & 0xff | (p[13] & 0xff)<<8 | (p[14] & 0xff)<<16 | (p[15] & 0xff)<<24,\n j10 = c[ 8] & 0xff | (c[ 9] & 0xff)<<8 | (c[10] & 0xff)<<16 | (c[11] & 0xff)<<24,\n j11 = k[16] & 0xff | (k[17] & 0xff)<<8 | (k[18] & 0xff)<<16 | (k[19] & 0xff)<<24,\n j12 = k[20] & 0xff | (k[21] & 0xff)<<8 | (k[22] & 0xff)<<16 | (k[23] & 0xff)<<24,\n j13 = k[24] & 0xff | (k[25] & 0xff)<<8 | (k[26] & 0xff)<<16 | (k[27] & 0xff)<<24,\n j14 = k[28] & 0xff | (k[29] & 0xff)<<8 | (k[30] & 0xff)<<16 | (k[31] & 0xff)<<24,\n j15 = c[12] & 0xff | (c[13] & 0xff)<<8 | (c[14] & 0xff)<<16 | (c[15] & 0xff)<<24;\n\n var x0 = j0, x1 = j1, x2 = j2, x3 = j3, x4 = j4, x5 = j5, x6 = j6, x7 = j7,\n x8 = j8, x9 = j9, x10 = j10, x11 = j11, x12 = j12, x13 = j13, x14 = j14,\n x15 = j15, u;\n\n for (var i = 0; i < 20; i += 2) {\n u = x0 + x12 | 0;\n x4 ^= u<<7 | u>>>(32-7);\n u = x4 + x0 | 0;\n x8 ^= u<<9 | u>>>(32-9);\n u = x8 + x4 | 0;\n x12 ^= u<<13 | u>>>(32-13);\n u = x12 + x8 | 0;\n x0 ^= u<<18 | u>>>(32-18);\n\n u = x5 + x1 | 0;\n x9 ^= u<<7 | u>>>(32-7);\n u = x9 + x5 | 0;\n x13 ^= u<<9 | u>>>(32-9);\n u = x13 + x9 | 0;\n x1 ^= u<<13 | u>>>(32-13);\n u = x1 + x13 | 0;\n x5 ^= u<<18 | u>>>(32-18);\n\n u = x10 + x6 | 0;\n x14 ^= u<<7 | u>>>(32-7);\n u = x14 + x10 | 0;\n x2 ^= u<<9 | u>>>(32-9);\n u = x2 + x14 | 0;\n x6 ^= u<<13 | u>>>(32-13);\n u = x6 + x2 | 0;\n x10 ^= u<<18 | u>>>(32-18);\n\n u = x15 + x11 | 0;\n x3 ^= u<<7 | u>>>(32-7);\n u = x3 + x15 | 0;\n x7 ^= u<<9 | u>>>(32-9);\n u = x7 + x3 | 0;\n x11 ^= u<<13 | u>>>(32-13);\n u = x11 + x7 | 0;\n x15 ^= u<<18 | u>>>(32-18);\n\n u = x0 + x3 | 0;\n x1 ^= u<<7 | u>>>(32-7);\n u = x1 + x0 | 0;\n x2 ^= u<<9 | u>>>(32-9);\n u = x2 + x1 | 0;\n x3 ^= u<<13 | u>>>(32-13);\n u = x3 + x2 | 0;\n x0 ^= u<<18 | u>>>(32-18);\n\n u = x5 + x4 | 0;\n x6 ^= u<<7 | u>>>(32-7);\n u = x6 + x5 | 0;\n x7 ^= u<<9 | u>>>(32-9);\n u = x7 + x6 | 0;\n x4 ^= u<<13 | u>>>(32-13);\n u = x4 + x7 | 0;\n x5 ^= u<<18 | u>>>(32-18);\n\n u = x10 + x9 | 0;\n x11 ^= u<<7 | u>>>(32-7);\n u = x11 + x10 | 0;\n x8 ^= u<<9 | u>>>(32-9);\n u = x8 + x11 | 0;\n x9 ^= u<<13 | u>>>(32-13);\n u = x9 + x8 | 0;\n x10 ^= u<<18 | u>>>(32-18);\n\n u = x15 + x14 | 0;\n x12 ^= u<<7 | u>>>(32-7);\n u = x12 + x15 | 0;\n x13 ^= u<<9 | u>>>(32-9);\n u = x13 + x12 | 0;\n x14 ^= u<<13 | u>>>(32-13);\n u = x14 + x13 | 0;\n x15 ^= u<<18 | u>>>(32-18);\n }\n\n o[ 0] = x0 >>> 0 & 0xff;\n o[ 1] = x0 >>> 8 & 0xff;\n o[ 2] = x0 >>> 16 & 0xff;\n o[ 3] = x0 >>> 24 & 0xff;\n\n o[ 4] = x5 >>> 0 & 0xff;\n o[ 5] = x5 >>> 8 & 0xff;\n o[ 6] = x5 >>> 16 & 0xff;\n o[ 7] = x5 >>> 24 & 0xff;\n\n o[ 8] = x10 >>> 0 & 0xff;\n o[ 9] = x10 >>> 8 & 0xff;\n o[10] = x10 >>> 16 & 0xff;\n o[11] = x10 >>> 24 & 0xff;\n\n o[12] = x15 >>> 0 & 0xff;\n o[13] = x15 >>> 8 & 0xff;\n o[14] = x15 >>> 16 & 0xff;\n o[15] = x15 >>> 24 & 0xff;\n\n o[16] = x6 >>> 0 & 0xff;\n o[17] = x6 >>> 8 & 0xff;\n o[18] = x6 >>> 16 & 0xff;\n o[19] = x6 >>> 24 & 0xff;\n\n o[20] = x7 >>> 0 & 0xff;\n o[21] = x7 >>> 8 & 0xff;\n o[22] = x7 >>> 16 & 0xff;\n o[23] = x7 >>> 24 & 0xff;\n\n o[24] = x8 >>> 0 & 0xff;\n o[25] = x8 >>> 8 & 0xff;\n o[26] = x8 >>> 16 & 0xff;\n o[27] = x8 >>> 24 & 0xff;\n\n o[28] = x9 >>> 0 & 0xff;\n o[29] = x9 >>> 8 & 0xff;\n o[30] = x9 >>> 16 & 0xff;\n o[31] = x9 >>> 24 & 0xff;\n}\n\nfunction crypto_core_salsa20(out,inp,k,c) {\n core_salsa20(out,inp,k,c);\n}\n\nfunction crypto_core_hsalsa20(out,inp,k,c) {\n core_hsalsa20(out,inp,k,c);\n}\n\nvar sigma = new Uint8Array([101, 120, 112, 97, 110, 100, 32, 51, 50, 45, 98, 121, 116, 101, 32, 107]);\n // \"expand 32-byte k\"\n\nfunction crypto_stream_salsa20_xor(c,cpos,m,mpos,b,n,k) {\n var z = new Uint8Array(16), x = new Uint8Array(64);\n var u, i;\n for (i = 0; i < 16; i++) z[i] = 0;\n for (i = 0; i < 8; i++) z[i] = n[i];\n while (b >= 64) {\n crypto_core_salsa20(x,z,k,sigma);\n for (i = 0; i < 64; i++) c[cpos+i] = m[mpos+i] ^ x[i];\n u = 1;\n for (i = 8; i < 16; i++) {\n u = u + (z[i] & 0xff) | 0;\n z[i] = u & 0xff;\n u >>>= 8;\n }\n b -= 64;\n cpos += 64;\n mpos += 64;\n }\n if (b > 0) {\n crypto_core_salsa20(x,z,k,sigma);\n for (i = 0; i < b; i++) c[cpos+i] = m[mpos+i] ^ x[i];\n }\n return 0;\n}\n\nfunction crypto_stream_salsa20(c,cpos,b,n,k) {\n var z = new Uint8Array(16), x = new Uint8Array(64);\n var u, i;\n for (i = 0; i < 16; i++) z[i] = 0;\n for (i = 0; i < 8; i++) z[i] = n[i];\n while (b >= 64) {\n crypto_core_salsa20(x,z,k,sigma);\n for (i = 0; i < 64; i++) c[cpos+i] = x[i];\n u = 1;\n for (i = 8; i < 16; i++) {\n u = u + (z[i] & 0xff) | 0;\n z[i] = u & 0xff;\n u >>>= 8;\n }\n b -= 64;\n cpos += 64;\n }\n if (b > 0) {\n crypto_core_salsa20(x,z,k,sigma);\n for (i = 0; i < b; i++) c[cpos+i] = x[i];\n }\n return 0;\n}\n\nfunction crypto_stream(c,cpos,d,n,k) {\n var s = new Uint8Array(32);\n crypto_core_hsalsa20(s,n,k,sigma);\n var sn = new Uint8Array(8);\n for (var i = 0; i < 8; i++) sn[i] = n[i+16];\n return crypto_stream_salsa20(c,cpos,d,sn,s);\n}\n\nfunction crypto_stream_xor(c,cpos,m,mpos,d,n,k) {\n var s = new Uint8Array(32);\n crypto_core_hsalsa20(s,n,k,sigma);\n var sn = new Uint8Array(8);\n for (var i = 0; i < 8; i++) sn[i] = n[i+16];\n return crypto_stream_salsa20_xor(c,cpos,m,mpos,d,sn,s);\n}\n\n/*\n* Port of Andrew Moon's Poly1305-donna-16. Public domain.\n* https://github.com/floodyberry/poly1305-donna\n*/\n\nvar poly1305 = function(key) {\n this.buffer = new Uint8Array(16);\n this.r = new Uint16Array(10);\n this.h = new Uint16Array(10);\n this.pad = new Uint16Array(8);\n this.leftover = 0;\n this.fin = 0;\n\n var t0, t1, t2, t3, t4, t5, t6, t7;\n\n t0 = key[ 0] & 0xff | (key[ 1] & 0xff) << 8; this.r[0] = ( t0 ) & 0x1fff;\n t1 = key[ 2] & 0xff | (key[ 3] & 0xff) << 8; this.r[1] = ((t0 >>> 13) | (t1 << 3)) & 0x1fff;\n t2 = key[ 4] & 0xff | (key[ 5] & 0xff) << 8; this.r[2] = ((t1 >>> 10) | (t2 << 6)) & 0x1f03;\n t3 = key[ 6] & 0xff | (key[ 7] & 0xff) << 8; this.r[3] = ((t2 >>> 7) | (t3 << 9)) & 0x1fff;\n t4 = key[ 8] & 0xff | (key[ 9] & 0xff) << 8; this.r[4] = ((t3 >>> 4) | (t4 << 12)) & 0x00ff;\n this.r[5] = ((t4 >>> 1)) & 0x1ffe;\n t5 = key[10] & 0xff | (key[11] & 0xff) << 8; this.r[6] = ((t4 >>> 14) | (t5 << 2)) & 0x1fff;\n t6 = key[12] & 0xff | (key[13] & 0xff) << 8; this.r[7] = ((t5 >>> 11) | (t6 << 5)) & 0x1f81;\n t7 = key[14] & 0xff | (key[15] & 0xff) << 8; this.r[8] = ((t6 >>> 8) | (t7 << 8)) & 0x1fff;\n this.r[9] = ((t7 >>> 5)) & 0x007f;\n\n this.pad[0] = key[16] & 0xff | (key[17] & 0xff) << 8;\n this.pad[1] = key[18] & 0xff | (key[19] & 0xff) << 8;\n this.pad[2] = key[20] & 0xff | (key[21] & 0xff) << 8;\n this.pad[3] = key[22] & 0xff | (key[23] & 0xff) << 8;\n this.pad[4] = key[24] & 0xff | (key[25] & 0xff) << 8;\n this.pad[5] = key[26] & 0xff | (key[27] & 0xff) << 8;\n this.pad[6] = key[28] & 0xff | (key[29] & 0xff) << 8;\n this.pad[7] = key[30] & 0xff | (key[31] & 0xff) << 8;\n};\n\npoly1305.prototype.blocks = function(m, mpos, bytes) {\n var hibit = this.fin ? 0 : (1 << 11);\n var t0, t1, t2, t3, t4, t5, t6, t7, c;\n var d0, d1, d2, d3, d4, d5, d6, d7, d8, d9;\n\n var h0 = this.h[0],\n h1 = this.h[1],\n h2 = this.h[2],\n h3 = this.h[3],\n h4 = this.h[4],\n h5 = this.h[5],\n h6 = this.h[6],\n h7 = this.h[7],\n h8 = this.h[8],\n h9 = this.h[9];\n\n var r0 = this.r[0],\n r1 = this.r[1],\n r2 = this.r[2],\n r3 = this.r[3],\n r4 = this.r[4],\n r5 = this.r[5],\n r6 = this.r[6],\n r7 = this.r[7],\n r8 = this.r[8],\n r9 = this.r[9];\n\n while (bytes >= 16) {\n t0 = m[mpos+ 0] & 0xff | (m[mpos+ 1] & 0xff) << 8; h0 += ( t0 ) & 0x1fff;\n t1 = m[mpos+ 2] & 0xff | (m[mpos+ 3] & 0xff) << 8; h1 += ((t0 >>> 13) | (t1 << 3)) & 0x1fff;\n t2 = m[mpos+ 4] & 0xff | (m[mpos+ 5] & 0xff) << 8; h2 += ((t1 >>> 10) | (t2 << 6)) & 0x1fff;\n t3 = m[mpos+ 6] & 0xff | (m[mpos+ 7] & 0xff) << 8; h3 += ((t2 >>> 7) | (t3 << 9)) & 0x1fff;\n t4 = m[mpos+ 8] & 0xff | (m[mpos+ 9] & 0xff) << 8; h4 += ((t3 >>> 4) | (t4 << 12)) & 0x1fff;\n h5 += ((t4 >>> 1)) & 0x1fff;\n t5 = m[mpos+10] & 0xff | (m[mpos+11] & 0xff) << 8; h6 += ((t4 >>> 14) | (t5 << 2)) & 0x1fff;\n t6 = m[mpos+12] & 0xff | (m[mpos+13] & 0xff) << 8; h7 += ((t5 >>> 11) | (t6 << 5)) & 0x1fff;\n t7 = m[mpos+14] & 0xff | (m[mpos+15] & 0xff) << 8; h8 += ((t6 >>> 8) | (t7 << 8)) & 0x1fff;\n h9 += ((t7 >>> 5)) | hibit;\n\n c = 0;\n\n d0 = c;\n d0 += h0 * r0;\n d0 += h1 * (5 * r9);\n d0 += h2 * (5 * r8);\n d0 += h3 * (5 * r7);\n d0 += h4 * (5 * r6);\n c = (d0 >>> 13); d0 &= 0x1fff;\n d0 += h5 * (5 * r5);\n d0 += h6 * (5 * r4);\n d0 += h7 * (5 * r3);\n d0 += h8 * (5 * r2);\n d0 += h9 * (5 * r1);\n c += (d0 >>> 13); d0 &= 0x1fff;\n\n d1 = c;\n d1 += h0 * r1;\n d1 += h1 * r0;\n d1 += h2 * (5 * r9);\n d1 += h3 * (5 * r8);\n d1 += h4 * (5 * r7);\n c = (d1 >>> 13); d1 &= 0x1fff;\n d1 += h5 * (5 * r6);\n d1 += h6 * (5 * r5);\n d1 += h7 * (5 * r4);\n d1 += h8 * (5 * r3);\n d1 += h9 * (5 * r2);\n c += (d1 >>> 13); d1 &= 0x1fff;\n\n d2 = c;\n d2 += h0 * r2;\n d2 += h1 * r1;\n d2 += h2 * r0;\n d2 += h3 * (5 * r9);\n d2 += h4 * (5 * r8);\n c = (d2 >>> 13); d2 &= 0x1fff;\n d2 += h5 * (5 * r7);\n d2 += h6 * (5 * r6);\n d2 += h7 * (5 * r5);\n d2 += h8 * (5 * r4);\n d2 += h9 * (5 * r3);\n c += (d2 >>> 13); d2 &= 0x1fff;\n\n d3 = c;\n d3 += h0 * r3;\n d3 += h1 * r2;\n d3 += h2 * r1;\n d3 += h3 * r0;\n d3 += h4 * (5 * r9);\n c = (d3 >>> 13); d3 &= 0x1fff;\n d3 += h5 * (5 * r8);\n d3 += h6 * (5 * r7);\n d3 += h7 * (5 * r6);\n d3 += h8 * (5 * r5);\n d3 += h9 * (5 * r4);\n c += (d3 >>> 13); d3 &= 0x1fff;\n\n d4 = c;\n d4 += h0 * r4;\n d4 += h1 * r3;\n d4 += h2 * r2;\n d4 += h3 * r1;\n d4 += h4 * r0;\n c = (d4 >>> 13); d4 &= 0x1fff;\n d4 += h5 * (5 * r9);\n d4 += h6 * (5 * r8);\n d4 += h7 * (5 * r7);\n d4 += h8 * (5 * r6);\n d4 += h9 * (5 * r5);\n c += (d4 >>> 13); d4 &= 0x1fff;\n\n d5 = c;\n d5 += h0 * r5;\n d5 += h1 * r4;\n d5 += h2 * r3;\n d5 += h3 * r2;\n d5 += h4 * r1;\n c = (d5 >>> 13); d5 &= 0x1fff;\n d5 += h5 * r0;\n d5 += h6 * (5 * r9);\n d5 += h7 * (5 * r8);\n d5 += h8 * (5 * r7);\n d5 += h9 * (5 * r6);\n c += (d5 >>> 13); d5 &= 0x1fff;\n\n d6 = c;\n d6 += h0 * r6;\n d6 += h1 * r5;\n d6 += h2 * r4;\n d6 += h3 * r3;\n d6 += h4 * r2;\n c = (d6 >>> 13); d6 &= 0x1fff;\n d6 += h5 * r1;\n d6 += h6 * r0;\n d6 += h7 * (5 * r9);\n d6 += h8 * (5 * r8);\n d6 += h9 * (5 * r7);\n c += (d6 >>> 13); d6 &= 0x1fff;\n\n d7 = c;\n d7 += h0 * r7;\n d7 += h1 * r6;\n d7 += h2 * r5;\n d7 += h3 * r4;\n d7 += h4 * r3;\n c = (d7 >>> 13); d7 &= 0x1fff;\n d7 += h5 * r2;\n d7 += h6 * r1;\n d7 += h7 * r0;\n d7 += h8 * (5 * r9);\n d7 += h9 * (5 * r8);\n c += (d7 >>> 13); d7 &= 0x1fff;\n\n d8 = c;\n d8 += h0 * r8;\n d8 += h1 * r7;\n d8 += h2 * r6;\n d8 += h3 * r5;\n d8 += h4 * r4;\n c = (d8 >>> 13); d8 &= 0x1fff;\n d8 += h5 * r3;\n d8 += h6 * r2;\n d8 += h7 * r1;\n d8 += h8 * r0;\n d8 += h9 * (5 * r9);\n c += (d8 >>> 13); d8 &= 0x1fff;\n\n d9 = c;\n d9 += h0 * r9;\n d9 += h1 * r8;\n d9 += h2 * r7;\n d9 += h3 * r6;\n d9 += h4 * r5;\n c = (d9 >>> 13); d9 &= 0x1fff;\n d9 += h5 * r4;\n d9 += h6 * r3;\n d9 += h7 * r2;\n d9 += h8 * r1;\n d9 += h9 * r0;\n c += (d9 >>> 13); d9 &= 0x1fff;\n\n c = (((c << 2) + c)) | 0;\n c = (c + d0) | 0;\n d0 = c & 0x1fff;\n c = (c >>> 13);\n d1 += c;\n\n h0 = d0;\n h1 = d1;\n h2 = d2;\n h3 = d3;\n h4 = d4;\n h5 = d5;\n h6 = d6;\n h7 = d7;\n h8 = d8;\n h9 = d9;\n\n mpos += 16;\n bytes -= 16;\n }\n this.h[0] = h0;\n this.h[1] = h1;\n this.h[2] = h2;\n this.h[3] = h3;\n this.h[4] = h4;\n this.h[5] = h5;\n this.h[6] = h6;\n this.h[7] = h7;\n this.h[8] = h8;\n this.h[9] = h9;\n};\n\npoly1305.prototype.finish = function(mac, macpos) {\n var g = new Uint16Array(10);\n var c, mask, f, i;\n\n if (this.leftover) {\n i = this.leftover;\n this.buffer[i++] = 1;\n for (; i < 16; i++) this.buffer[i] = 0;\n this.fin = 1;\n this.blocks(this.buffer, 0, 16);\n }\n\n c = this.h[1] >>> 13;\n this.h[1] &= 0x1fff;\n for (i = 2; i < 10; i++) {\n this.h[i] += c;\n c = this.h[i] >>> 13;\n this.h[i] &= 0x1fff;\n }\n this.h[0] += (c * 5);\n c = this.h[0] >>> 13;\n this.h[0] &= 0x1fff;\n this.h[1] += c;\n c = this.h[1] >>> 13;\n this.h[1] &= 0x1fff;\n this.h[2] += c;\n\n g[0] = this.h[0] + 5;\n c = g[0] >>> 13;\n g[0] &= 0x1fff;\n for (i = 1; i < 10; i++) {\n g[i] = this.h[i] + c;\n c = g[i] >>> 13;\n g[i] &= 0x1fff;\n }\n g[9] -= (1 << 13);\n\n mask = (c ^ 1) - 1;\n for (i = 0; i < 10; i++) g[i] &= mask;\n mask = ~mask;\n for (i = 0; i < 10; i++) this.h[i] = (this.h[i] & mask) | g[i];\n\n this.h[0] = ((this.h[0] ) | (this.h[1] << 13) ) & 0xffff;\n this.h[1] = ((this.h[1] >>> 3) | (this.h[2] << 10) ) & 0xffff;\n this.h[2] = ((this.h[2] >>> 6) | (this.h[3] << 7) ) & 0xffff;\n this.h[3] = ((this.h[3] >>> 9) | (this.h[4] << 4) ) & 0xffff;\n this.h[4] = ((this.h[4] >>> 12) | (this.h[5] << 1) | (this.h[6] << 14)) & 0xffff;\n this.h[5] = ((this.h[6] >>> 2) | (this.h[7] << 11) ) & 0xffff;\n this.h[6] = ((this.h[7] >>> 5) | (this.h[8] << 8) ) & 0xffff;\n this.h[7] = ((this.h[8] >>> 8) | (this.h[9] << 5) ) & 0xffff;\n\n f = this.h[0] + this.pad[0];\n this.h[0] = f & 0xffff;\n for (i = 1; i < 8; i++) {\n f = (((this.h[i] + this.pad[i]) | 0) + (f >>> 16)) | 0;\n this.h[i] = f & 0xffff;\n }\n\n mac[macpos+ 0] = (this.h[0] >>> 0) & 0xff;\n mac[macpos+ 1] = (this.h[0] >>> 8) & 0xff;\n mac[macpos+ 2] = (this.h[1] >>> 0) & 0xff;\n mac[macpos+ 3] = (this.h[1] >>> 8) & 0xff;\n mac[macpos+ 4] = (this.h[2] >>> 0) & 0xff;\n mac[macpos+ 5] = (this.h[2] >>> 8) & 0xff;\n mac[macpos+ 6] = (this.h[3] >>> 0) & 0xff;\n mac[macpos+ 7] = (this.h[3] >>> 8) & 0xff;\n mac[macpos+ 8] = (this.h[4] >>> 0) & 0xff;\n mac[macpos+ 9] = (this.h[4] >>> 8) & 0xff;\n mac[macpos+10] = (this.h[5] >>> 0) & 0xff;\n mac[macpos+11] = (this.h[5] >>> 8) & 0xff;\n mac[macpos+12] = (this.h[6] >>> 0) & 0xff;\n mac[macpos+13] = (this.h[6] >>> 8) & 0xff;\n mac[macpos+14] = (this.h[7] >>> 0) & 0xff;\n mac[macpos+15] = (this.h[7] >>> 8) & 0xff;\n};\n\npoly1305.prototype.update = function(m, mpos, bytes) {\n var i, want;\n\n if (this.leftover) {\n want = (16 - this.leftover);\n if (want > bytes)\n want = bytes;\n for (i = 0; i < want; i++)\n this.buffer[this.leftover + i] = m[mpos+i];\n bytes -= want;\n mpos += want;\n this.leftover += want;\n if (this.leftover < 16)\n return;\n this.blocks(this.buffer, 0, 16);\n this.leftover = 0;\n }\n\n if (bytes >= 16) {\n want = bytes - (bytes % 16);\n this.blocks(m, mpos, want);\n mpos += want;\n bytes -= want;\n }\n\n if (bytes) {\n for (i = 0; i < bytes; i++)\n this.buffer[this.leftover + i] = m[mpos+i];\n this.leftover += bytes;\n }\n};\n\nfunction crypto_onetimeauth(out, outpos, m, mpos, n, k) {\n var s = new poly1305(k);\n s.update(m, mpos, n);\n s.finish(out, outpos);\n return 0;\n}\n\nfunction crypto_onetimeauth_verify(h, hpos, m, mpos, n, k) {\n var x = new Uint8Array(16);\n crypto_onetimeauth(x,0,m,mpos,n,k);\n return crypto_verify_16(h,hpos,x,0);\n}\n\nfunction crypto_secretbox(c,m,d,n,k) {\n var i;\n if (d < 32) return -1;\n crypto_stream_xor(c,0,m,0,d,n,k);\n crypto_onetimeauth(c, 16, c, 32, d - 32, c);\n for (i = 0; i < 16; i++) c[i] = 0;\n return 0;\n}\n\nfunction crypto_secretbox_open(m,c,d,n,k) {\n var i;\n var x = new Uint8Array(32);\n if (d < 32) return -1;\n crypto_stream(x,0,32,n,k);\n if (crypto_onetimeauth_verify(c, 16,c, 32,d - 32,x) !== 0) return -1;\n crypto_stream_xor(m,0,c,0,d,n,k);\n for (i = 0; i < 32; i++) m[i] = 0;\n return 0;\n}\n\nfunction set25519(r, a) {\n var i;\n for (i = 0; i < 16; i++) r[i] = a[i]|0;\n}\n\nfunction car25519(o) {\n var i, v, c = 1;\n for (i = 0; i < 16; i++) {\n v = o[i] + c + 65535;\n c = Math.floor(v / 65536);\n o[i] = v - c * 65536;\n }\n o[0] += c-1 + 37 * (c-1);\n}\n\nfunction sel25519(p, q, b) {\n var t, c = ~(b-1);\n for (var i = 0; i < 16; i++) {\n t = c & (p[i] ^ q[i]);\n p[i] ^= t;\n q[i] ^= t;\n }\n}\n\nfunction pack25519(o, n) {\n var i, j, b;\n var m = gf(), t = gf();\n for (i = 0; i < 16; i++) t[i] = n[i];\n car25519(t);\n car25519(t);\n car25519(t);\n for (j = 0; j < 2; j++) {\n m[0] = t[0] - 0xffed;\n for (i = 1; i < 15; i++) {\n m[i] = t[i] - 0xffff - ((m[i-1]>>16) & 1);\n m[i-1] &= 0xffff;\n }\n m[15] = t[15] - 0x7fff - ((m[14]>>16) & 1);\n b = (m[15]>>16) & 1;\n m[14] &= 0xffff;\n sel25519(t, m, 1-b);\n }\n for (i = 0; i < 16; i++) {\n o[2*i] = t[i] & 0xff;\n o[2*i+1] = t[i]>>8;\n }\n}\n\nfunction neq25519(a, b) {\n var c = new Uint8Array(32), d = new Uint8Array(32);\n pack25519(c, a);\n pack25519(d, b);\n return crypto_verify_32(c, 0, d, 0);\n}\n\nfunction par25519(a) {\n var d = new Uint8Array(32);\n pack25519(d, a);\n return d[0] & 1;\n}\n\nfunction unpack25519(o, n) {\n var i;\n for (i = 0; i < 16; i++) o[i] = n[2*i] + (n[2*i+1] << 8);\n o[15] &= 0x7fff;\n}\n\nfunction A(o, a, b) {\n for (var i = 0; i < 16; i++) o[i] = a[i] + b[i];\n}\n\nfunction Z(o, a, b) {\n for (var i = 0; i < 16; i++) o[i] = a[i] - b[i];\n}\n\nfunction M(o, a, b) {\n var v, c,\n t0 = 0, t1 = 0, t2 = 0, t3 = 0, t4 = 0, t5 = 0, t6 = 0, t7 = 0,\n t8 = 0, t9 = 0, t10 = 0, t11 = 0, t12 = 0, t13 = 0, t14 = 0, t15 = 0,\n t16 = 0, t17 = 0, t18 = 0, t19 = 0, t20 = 0, t21 = 0, t22 = 0, t23 = 0,\n t24 = 0, t25 = 0, t26 = 0, t27 = 0, t28 = 0, t29 = 0, t30 = 0,\n b0 = b[0],\n b1 = b[1],\n b2 = b[2],\n b3 = b[3],\n b4 = b[4],\n b5 = b[5],\n b6 = b[6],\n b7 = b[7],\n b8 = b[8],\n b9 = b[9],\n b10 = b[10],\n b11 = b[11],\n b12 = b[12],\n b13 = b[13],\n b14 = b[14],\n b15 = b[15];\n\n v = a[0];\n t0 += v * b0;\n t1 += v * b1;\n t2 += v * b2;\n t3 += v * b3;\n t4 += v * b4;\n t5 += v * b5;\n t6 += v * b6;\n t7 += v * b7;\n t8 += v * b8;\n t9 += v * b9;\n t10 += v * b10;\n t11 += v * b11;\n t12 += v * b12;\n t13 += v * b13;\n t14 += v * b14;\n t15 += v * b15;\n v = a[1];\n t1 += v * b0;\n t2 += v * b1;\n t3 += v * b2;\n t4 += v * b3;\n t5 += v * b4;\n t6 += v * b5;\n t7 += v * b6;\n t8 += v * b7;\n t9 += v * b8;\n t10 += v * b9;\n t11 += v * b10;\n t12 += v * b11;\n t13 += v * b12;\n t14 += v * b13;\n t15 += v * b14;\n t16 += v * b15;\n v = a[2];\n t2 += v * b0;\n t3 += v * b1;\n t4 += v * b2;\n t5 += v * b3;\n t6 += v * b4;\n t7 += v * b5;\n t8 += v * b6;\n t9 += v * b7;\n t10 += v * b8;\n t11 += v * b9;\n t12 += v * b10;\n t13 += v * b11;\n t14 += v * b12;\n t15 += v * b13;\n t16 += v * b14;\n t17 += v * b15;\n v = a[3];\n t3 += v * b0;\n t4 += v * b1;\n t5 += v * b2;\n t6 += v * b3;\n t7 += v * b4;\n t8 += v * b5;\n t9 += v * b6;\n t10 += v * b7;\n t11 += v * b8;\n t12 += v * b9;\n t13 += v * b10;\n t14 += v * b11;\n t15 += v * b12;\n t16 += v * b13;\n t17 += v * b14;\n t18 += v * b15;\n v = a[4];\n t4 += v * b0;\n t5 += v * b1;\n t6 += v * b2;\n t7 += v * b3;\n t8 += v * b4;\n t9 += v * b5;\n t10 += v * b6;\n t11 += v * b7;\n t12 += v * b8;\n t13 += v * b9;\n t14 += v * b10;\n t15 += v * b11;\n t16 += v * b12;\n t17 += v * b13;\n t18 += v * b14;\n t19 += v * b15;\n v = a[5];\n t5 += v * b0;\n t6 += v * b1;\n t7 += v * b2;\n t8 += v * b3;\n t9 += v * b4;\n t10 += v * b5;\n t11 += v * b6;\n t12 += v * b7;\n t13 += v * b8;\n t14 += v * b9;\n t15 += v * b10;\n t16 += v * b11;\n t17 += v * b12;\n t18 += v * b13;\n t19 += v * b14;\n t20 += v * b15;\n v = a[6];\n t6 += v * b0;\n t7 += v * b1;\n t8 += v * b2;\n t9 += v * b3;\n t10 += v * b4;\n t11 += v * b5;\n t12 += v * b6;\n t13 += v * b7;\n t14 += v * b8;\n t15 += v * b9;\n t16 += v * b10;\n t17 += v * b11;\n t18 += v * b12;\n t19 += v * b13;\n t20 += v * b14;\n t21 += v * b15;\n v = a[7];\n t7 += v * b0;\n t8 += v * b1;\n t9 += v * b2;\n t10 += v * b3;\n t11 += v * b4;\n t12 += v * b5;\n t13 += v * b6;\n t14 += v * b7;\n t15 += v * b8;\n t16 += v * b9;\n t17 += v * b10;\n t18 += v * b11;\n t19 += v * b12;\n t20 += v * b13;\n t21 += v * b14;\n t22 += v * b15;\n v = a[8];\n t8 += v * b0;\n t9 += v * b1;\n t10 += v * b2;\n t11 += v * b3;\n t12 += v * b4;\n t13 += v * b5;\n t14 += v * b6;\n t15 += v * b7;\n t16 += v * b8;\n t17 += v * b9;\n t18 += v * b10;\n t19 += v * b11;\n t20 += v * b12;\n t21 += v * b13;\n t22 += v * b14;\n t23 += v * b15;\n v = a[9];\n t9 += v * b0;\n t10 += v * b1;\n t11 += v * b2;\n t12 += v * b3;\n t13 += v * b4;\n t14 += v * b5;\n t15 += v * b6;\n t16 += v * b7;\n t17 += v * b8;\n t18 += v * b9;\n t19 += v * b10;\n t20 += v * b11;\n t21 += v * b12;\n t22 += v * b13;\n t23 += v * b14;\n t24 += v * b15;\n v = a[10];\n t10 += v * b0;\n t11 += v * b1;\n t12 += v * b2;\n t13 += v * b3;\n t14 += v * b4;\n t15 += v * b5;\n t16 += v * b6;\n t17 += v * b7;\n t18 += v * b8;\n t19 += v * b9;\n t20 += v * b10;\n t21 += v * b11;\n t22 += v * b12;\n t23 += v * b13;\n t24 += v * b14;\n t25 += v * b15;\n v = a[11];\n t11 += v * b0;\n t12 += v * b1;\n t13 += v * b2;\n t14 += v * b3;\n t15 += v * b4;\n t16 += v * b5;\n t17 += v * b6;\n t18 += v * b7;\n t19 += v * b8;\n t20 += v * b9;\n t21 += v * b10;\n t22 += v * b11;\n t23 += v * b12;\n t24 += v * b13;\n t25 += v * b14;\n t26 += v * b15;\n v = a[12];\n t12 += v * b0;\n t13 += v * b1;\n t14 += v * b2;\n t15 += v * b3;\n t16 += v * b4;\n t17 += v * b5;\n t18 += v * b6;\n t19 += v * b7;\n t20 += v * b8;\n t21 += v * b9;\n t22 += v * b10;\n t23 += v * b11;\n t24 += v * b12;\n t25 += v * b13;\n t26 += v * b14;\n t27 += v * b15;\n v = a[13];\n t13 += v * b0;\n t14 += v * b1;\n t15 += v * b2;\n t16 += v * b3;\n t17 += v * b4;\n t18 += v * b5;\n t19 += v * b6;\n t20 += v * b7;\n t21 += v * b8;\n t22 += v * b9;\n t23 += v * b10;\n t24 += v * b11;\n t25 += v * b12;\n t26 += v * b13;\n t27 += v * b14;\n t28 += v * b15;\n v = a[14];\n t14 += v * b0;\n t15 += v * b1;\n t16 += v * b2;\n t17 += v * b3;\n t18 += v * b4;\n t19 += v * b5;\n t20 += v * b6;\n t21 += v * b7;\n t22 += v * b8;\n t23 += v * b9;\n t24 += v * b10;\n t25 += v * b11;\n t26 += v * b12;\n t27 += v * b13;\n t28 += v * b14;\n t29 += v * b15;\n v = a[15];\n t15 += v * b0;\n t16 += v * b1;\n t17 += v * b2;\n t18 += v * b3;\n t19 += v * b4;\n t20 += v * b5;\n t21 += v * b6;\n t22 += v * b7;\n t23 += v * b8;\n t24 += v * b9;\n t25 += v * b10;\n t26 += v * b11;\n t27 += v * b12;\n t28 += v * b13;\n t29 += v * b14;\n t30 += v * b15;\n\n t0 += 38 * t16;\n t1 += 38 * t17;\n t2 += 38 * t18;\n t3 += 38 * t19;\n t4 += 38 * t20;\n t5 += 38 * t21;\n t6 += 38 * t22;\n t7 += 38 * t23;\n t8 += 38 * t24;\n t9 += 38 * t25;\n t10 += 38 * t26;\n t11 += 38 * t27;\n t12 += 38 * t28;\n t13 += 38 * t29;\n t14 += 38 * t30;\n // t15 left as is\n\n // first car\n c = 1;\n v = t0 + c + 65535; c = Math.floor(v / 65536); t0 = v - c * 65536;\n v = t1 + c + 65535; c = Math.floor(v / 65536); t1 = v - c * 65536;\n v = t2 + c + 65535; c = Math.floor(v / 65536); t2 = v - c * 65536;\n v = t3 + c + 65535; c = Math.floor(v / 65536); t3 = v - c * 65536;\n v = t4 + c + 65535; c = Math.floor(v / 65536); t4 = v - c * 65536;\n v = t5 + c + 65535; c = Math.floor(v / 65536); t5 = v - c * 65536;\n v = t6 + c + 65535; c = Math.floor(v / 65536); t6 = v - c * 65536;\n v = t7 + c + 65535; c = Math.floor(v / 65536); t7 = v - c * 65536;\n v = t8 + c + 65535; c = Math.floor(v / 65536); t8 = v - c * 65536;\n v = t9 + c + 65535; c = Math.floor(v / 65536); t9 = v - c * 65536;\n v = t10 + c + 65535; c = Math.floor(v / 65536); t10 = v - c * 65536;\n v = t11 + c + 65535; c = Math.floor(v / 65536); t11 = v - c * 65536;\n v = t12 + c + 65535; c = Math.floor(v / 65536); t12 = v - c * 65536;\n v = t13 + c + 65535; c = Math.floor(v / 65536); t13 = v - c * 65536;\n v = t14 + c + 65535; c = Math.floor(v / 65536); t14 = v - c * 65536;\n v = t15 + c + 65535; c = Math.floor(v / 65536); t15 = v - c * 65536;\n t0 += c-1 + 37 * (c-1);\n\n // second car\n c = 1;\n v = t0 + c + 65535; c = Math.floor(v / 65536); t0 = v - c * 65536;\n v = t1 + c + 65535; c = Math.floor(v / 65536); t1 = v - c * 65536;\n v = t2 + c + 65535; c = Math.floor(v / 65536); t2 = v - c * 65536;\n v = t3 + c + 65535; c = Math.floor(v / 65536); t3 = v - c * 65536;\n v = t4 + c + 65535; c = Math.floor(v / 65536); t4 = v - c * 65536;\n v = t5 + c + 65535; c = Math.floor(v / 65536); t5 = v - c * 65536;\n v = t6 + c + 65535; c = Math.floor(v / 65536); t6 = v - c * 65536;\n v = t7 + c + 65535; c = Math.floor(v / 65536); t7 = v - c * 65536;\n v = t8 + c + 65535; c = Math.floor(v / 65536); t8 = v - c * 65536;\n v = t9 + c + 65535; c = Math.floor(v / 65536); t9 = v - c * 65536;\n v = t10 + c + 65535; c = Math.floor(v / 65536); t10 = v - c * 65536;\n v = t11 + c + 65535; c = Math.floor(v / 65536); t11 = v - c * 65536;\n v = t12 + c + 65535; c = Math.floor(v / 65536); t12 = v - c * 65536;\n v = t13 + c + 65535; c = Math.floor(v / 65536); t13 = v - c * 65536;\n v = t14 + c + 65535; c = Math.floor(v / 65536); t14 = v - c * 65536;\n v = t15 + c + 65535; c = Math.floor(v / 65536); t15 = v - c * 65536;\n t0 += c-1 + 37 * (c-1);\n\n o[ 0] = t0;\n o[ 1] = t1;\n o[ 2] = t2;\n o[ 3] = t3;\n o[ 4] = t4;\n o[ 5] = t5;\n o[ 6] = t6;\n o[ 7] = t7;\n o[ 8] = t8;\n o[ 9] = t9;\n o[10] = t10;\n o[11] = t11;\n o[12] = t12;\n o[13] = t13;\n o[14] = t14;\n o[15] = t15;\n}\n\nfunction S(o, a) {\n M(o, a, a);\n}\n\nfunction inv25519(o, i) {\n var c = gf();\n var a;\n for (a = 0; a < 16; a++) c[a] = i[a];\n for (a = 253; a >= 0; a--) {\n S(c, c);\n if(a !== 2 && a !== 4) M(c, c, i);\n }\n for (a = 0; a < 16; a++) o[a] = c[a];\n}\n\nfunction pow2523(o, i) {\n var c = gf();\n var a;\n for (a = 0; a < 16; a++) c[a] = i[a];\n for (a = 250; a >= 0; a--) {\n S(c, c);\n if(a !== 1) M(c, c, i);\n }\n for (a = 0; a < 16; a++) o[a] = c[a];\n}\n\nfunction crypto_scalarmult(q, n, p) {\n var z = new Uint8Array(32);\n var x = new Float64Array(80), r, i;\n var a = gf(), b = gf(), c = gf(),\n d = gf(), e = gf(), f = gf();\n for (i = 0; i < 31; i++) z[i] = n[i];\n z[31]=(n[31]&127)|64;\n z[0]&=248;\n unpack25519(x,p);\n for (i = 0; i < 16; i++) {\n b[i]=x[i];\n d[i]=a[i]=c[i]=0;\n }\n a[0]=d[0]=1;\n for (i=254; i>=0; --i) {\n r=(z[i>>>3]>>>(i&7))&1;\n sel25519(a,b,r);\n sel25519(c,d,r);\n A(e,a,c);\n Z(a,a,c);\n A(c,b,d);\n Z(b,b,d);\n S(d,e);\n S(f,a);\n M(a,c,a);\n M(c,b,e);\n A(e,a,c);\n Z(a,a,c);\n S(b,a);\n Z(c,d,f);\n M(a,c,_121665);\n A(a,a,d);\n M(c,c,a);\n M(a,d,f);\n M(d,b,x);\n S(b,e);\n sel25519(a,b,r);\n sel25519(c,d,r);\n }\n for (i = 0; i < 16; i++) {\n x[i+16]=a[i];\n x[i+32]=c[i];\n x[i+48]=b[i];\n x[i+64]=d[i];\n }\n var x32 = x.subarray(32);\n var x16 = x.subarray(16);\n inv25519(x32,x32);\n M(x16,x16,x32);\n pack25519(q,x16);\n return 0;\n}\n\nfunction crypto_scalarmult_base(q, n) {\n return crypto_scalarmult(q, n, _9);\n}\n\nfunction crypto_box_keypair(y, x) {\n randombytes(x, 32);\n return crypto_scalarmult_base(y, x);\n}\n\nfunction crypto_box_beforenm(k, y, x) {\n var s = new Uint8Array(32);\n crypto_scalarmult(s, x, y);\n return crypto_core_hsalsa20(k, _0, s, sigma);\n}\n\nvar crypto_box_afternm = crypto_secretbox;\nvar crypto_box_open_afternm = crypto_secretbox_open;\n\nfunction crypto_box(c, m, d, n, y, x) {\n var k = new Uint8Array(32);\n crypto_box_beforenm(k, y, x);\n return crypto_box_afternm(c, m, d, n, k);\n}\n\nfunction crypto_box_open(m, c, d, n, y, x) {\n var k = new Uint8Array(32);\n crypto_box_beforenm(k, y, x);\n return crypto_box_open_afternm(m, c, d, n, k);\n}\n\nvar K = [\n 0x428a2f98, 0xd728ae22, 0x71374491, 0x23ef65cd,\n 0xb5c0fbcf, 0xec4d3b2f, 0xe9b5dba5, 0x8189dbbc,\n 0x3956c25b, 0xf348b538, 0x59f111f1, 0xb605d019,\n 0x923f82a4, 0xaf194f9b, 0xab1c5ed5, 0xda6d8118,\n 0xd807aa98, 0xa3030242, 0x12835b01, 0x45706fbe,\n 0x243185be, 0x4ee4b28c, 0x550c7dc3, 0xd5ffb4e2,\n 0x72be5d74, 0xf27b896f, 0x80deb1fe, 0x3b1696b1,\n 0x9bdc06a7, 0x25c71235, 0xc19bf174, 0xcf692694,\n 0xe49b69c1, 0x9ef14ad2, 0xefbe4786, 0x384f25e3,\n 0x0fc19dc6, 0x8b8cd5b5, 0x240ca1cc, 0x77ac9c65,\n 0x2de92c6f, 0x592b0275, 0x4a7484aa, 0x6ea6e483,\n 0x5cb0a9dc, 0xbd41fbd4, 0x76f988da, 0x831153b5,\n 0x983e5152, 0xee66dfab, 0xa831c66d, 0x2db43210,\n 0xb00327c8, 0x98fb213f, 0xbf597fc7, 0xbeef0ee4,\n 0xc6e00bf3, 0x3da88fc2, 0xd5a79147, 0x930aa725,\n 0x06ca6351, 0xe003826f, 0x14292967, 0x0a0e6e70,\n 0x27b70a85, 0x46d22ffc, 0x2e1b2138, 0x5c26c926,\n 0x4d2c6dfc, 0x5ac42aed, 0x53380d13, 0x9d95b3df,\n 0x650a7354, 0x8baf63de, 0x766a0abb, 0x3c77b2a8,\n 0x81c2c92e, 0x47edaee6, 0x92722c85, 0x1482353b,\n 0xa2bfe8a1, 0x4cf10364, 0xa81a664b, 0xbc423001,\n 0xc24b8b70, 0xd0f89791, 0xc76c51a3, 0x0654be30,\n 0xd192e819, 0xd6ef5218, 0xd6990624, 0x5565a910,\n 0xf40e3585, 0x5771202a, 0x106aa070, 0x32bbd1b8,\n 0x19a4c116, 0xb8d2d0c8, 0x1e376c08, 0x5141ab53,\n 0x2748774c, 0xdf8eeb99, 0x34b0bcb5, 0xe19b48a8,\n 0x391c0cb3, 0xc5c95a63, 0x4ed8aa4a, 0xe3418acb,\n 0x5b9cca4f, 0x7763e373, 0x682e6ff3, 0xd6b2b8a3,\n 0x748f82ee, 0x5defb2fc, 0x78a5636f, 0x43172f60,\n 0x84c87814, 0xa1f0ab72, 0x8cc70208, 0x1a6439ec,\n 0x90befffa, 0x23631e28, 0xa4506ceb, 0xde82bde9,\n 0xbef9a3f7, 0xb2c67915, 0xc67178f2, 0xe372532b,\n 0xca273ece, 0xea26619c, 0xd186b8c7, 0x21c0c207,\n 0xeada7dd6, 0xcde0eb1e, 0xf57d4f7f, 0xee6ed178,\n 0x06f067aa, 0x72176fba, 0x0a637dc5, 0xa2c898a6,\n 0x113f9804, 0xbef90dae, 0x1b710b35, 0x131c471b,\n 0x28db77f5, 0x23047d84, 0x32caab7b, 0x40c72493,\n 0x3c9ebe0a, 0x15c9bebc, 0x431d67c4, 0x9c100d4c,\n 0x4cc5d4be, 0xcb3e42b6, 0x597f299c, 0xfc657e2a,\n 0x5fcb6fab, 0x3ad6faec, 0x6c44198c, 0x4a475817\n];\n\nfunction crypto_hashblocks_hl(hh, hl, m, n) {\n var wh = new Int32Array(16), wl = new Int32Array(16),\n bh0, bh1, bh2, bh3, bh4, bh5, bh6, bh7,\n bl0, bl1, bl2, bl3, bl4, bl5, bl6, bl7,\n th, tl, i, j, h, l, a, b, c, d;\n\n var ah0 = hh[0],\n ah1 = hh[1],\n ah2 = hh[2],\n ah3 = hh[3],\n ah4 = hh[4],\n ah5 = hh[5],\n ah6 = hh[6],\n ah7 = hh[7],\n\n al0 = hl[0],\n al1 = hl[1],\n al2 = hl[2],\n al3 = hl[3],\n al4 = hl[4],\n al5 = hl[5],\n al6 = hl[6],\n al7 = hl[7];\n\n var pos = 0;\n while (n >= 128) {\n for (i = 0; i < 16; i++) {\n j = 8 * i + pos;\n wh[i] = (m[j+0] << 24) | (m[j+1] << 16) | (m[j+2] << 8) | m[j+3];\n wl[i] = (m[j+4] << 24) | (m[j+5] << 16) | (m[j+6] << 8) | m[j+7];\n }\n for (i = 0; i < 80; i++) {\n bh0 = ah0;\n bh1 = ah1;\n bh2 = ah2;\n bh3 = ah3;\n bh4 = ah4;\n bh5 = ah5;\n bh6 = ah6;\n bh7 = ah7;\n\n bl0 = al0;\n bl1 = al1;\n bl2 = al2;\n bl3 = al3;\n bl4 = al4;\n bl5 = al5;\n bl6 = al6;\n bl7 = al7;\n\n // add\n h = ah7;\n l = al7;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n // Sigma1\n h = ((ah4 >>> 14) | (al4 << (32-14))) ^ ((ah4 >>> 18) | (al4 << (32-18))) ^ ((al4 >>> (41-32)) | (ah4 << (32-(41-32))));\n l = ((al4 >>> 14) | (ah4 << (32-14))) ^ ((al4 >>> 18) | (ah4 << (32-18))) ^ ((ah4 >>> (41-32)) | (al4 << (32-(41-32))));\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // Ch\n h = (ah4 & ah5) ^ (~ah4 & ah6);\n l = (al4 & al5) ^ (~al4 & al6);\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // K\n h = K[i*2];\n l = K[i*2+1];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // w\n h = wh[i%16];\n l = wl[i%16];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n th = c & 0xffff | d << 16;\n tl = a & 0xffff | b << 16;\n\n // add\n h = th;\n l = tl;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n // Sigma0\n h = ((ah0 >>> 28) | (al0 << (32-28))) ^ ((al0 >>> (34-32)) | (ah0 << (32-(34-32)))) ^ ((al0 >>> (39-32)) | (ah0 << (32-(39-32))));\n l = ((al0 >>> 28) | (ah0 << (32-28))) ^ ((ah0 >>> (34-32)) | (al0 << (32-(34-32)))) ^ ((ah0 >>> (39-32)) | (al0 << (32-(39-32))));\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // Maj\n h = (ah0 & ah1) ^ (ah0 & ah2) ^ (ah1 & ah2);\n l = (al0 & al1) ^ (al0 & al2) ^ (al1 & al2);\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n bh7 = (c & 0xffff) | (d << 16);\n bl7 = (a & 0xffff) | (b << 16);\n\n // add\n h = bh3;\n l = bl3;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = th;\n l = tl;\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n bh3 = (c & 0xffff) | (d << 16);\n bl3 = (a & 0xffff) | (b << 16);\n\n ah1 = bh0;\n ah2 = bh1;\n ah3 = bh2;\n ah4 = bh3;\n ah5 = bh4;\n ah6 = bh5;\n ah7 = bh6;\n ah0 = bh7;\n\n al1 = bl0;\n al2 = bl1;\n al3 = bl2;\n al4 = bl3;\n al5 = bl4;\n al6 = bl5;\n al7 = bl6;\n al0 = bl7;\n\n if (i%16 === 15) {\n for (j = 0; j < 16; j++) {\n // add\n h = wh[j];\n l = wl[j];\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = wh[(j+9)%16];\n l = wl[(j+9)%16];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // sigma0\n th = wh[(j+1)%16];\n tl = wl[(j+1)%16];\n h = ((th >>> 1) | (tl << (32-1))) ^ ((th >>> 8) | (tl << (32-8))) ^ (th >>> 7);\n l = ((tl >>> 1) | (th << (32-1))) ^ ((tl >>> 8) | (th << (32-8))) ^ ((tl >>> 7) | (th << (32-7)));\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // sigma1\n th = wh[(j+14)%16];\n tl = wl[(j+14)%16];\n h = ((th >>> 19) | (tl << (32-19))) ^ ((tl >>> (61-32)) | (th << (32-(61-32)))) ^ (th >>> 6);\n l = ((tl >>> 19) | (th << (32-19))) ^ ((th >>> (61-32)) | (tl << (32-(61-32)))) ^ ((tl >>> 6) | (th << (32-6)));\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n wh[j] = (c & 0xffff) | (d << 16);\n wl[j] = (a & 0xffff) | (b << 16);\n }\n }\n }\n\n // add\n h = ah0;\n l = al0;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[0];\n l = hl[0];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[0] = ah0 = (c & 0xffff) | (d << 16);\n hl[0] = al0 = (a & 0xffff) | (b << 16);\n\n h = ah1;\n l = al1;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[1];\n l = hl[1];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[1] = ah1 = (c & 0xffff) | (d << 16);\n hl[1] = al1 = (a & 0xffff) | (b << 16);\n\n h = ah2;\n l = al2;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[2];\n l = hl[2];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[2] = ah2 = (c & 0xffff) | (d << 16);\n hl[2] = al2 = (a & 0xffff) | (b << 16);\n\n h = ah3;\n l = al3;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[3];\n l = hl[3];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[3] = ah3 = (c & 0xffff) | (d << 16);\n hl[3] = al3 = (a & 0xffff) | (b << 16);\n\n h = ah4;\n l = al4;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[4];\n l = hl[4];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[4] = ah4 = (c & 0xffff) | (d << 16);\n hl[4] = al4 = (a & 0xffff) | (b << 16);\n\n h = ah5;\n l = al5;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[5];\n l = hl[5];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[5] = ah5 = (c & 0xffff) | (d << 16);\n hl[5] = al5 = (a & 0xffff) | (b << 16);\n\n h = ah6;\n l = al6;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[6];\n l = hl[6];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[6] = ah6 = (c & 0xffff) | (d << 16);\n hl[6] = al6 = (a & 0xffff) | (b << 16);\n\n h = ah7;\n l = al7;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[7];\n l = hl[7];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[7] = ah7 = (c & 0xffff) | (d << 16);\n hl[7] = al7 = (a & 0xffff) | (b << 16);\n\n pos += 128;\n n -= 128;\n }\n\n return n;\n}\n\nfunction crypto_hash(out, m, n) {\n var hh = new Int32Array(8),\n hl = new Int32Array(8),\n x = new Uint8Array(256),\n i, b = n;\n\n hh[0] = 0x6a09e667;\n hh[1] = 0xbb67ae85;\n hh[2] = 0x3c6ef372;\n hh[3] = 0xa54ff53a;\n hh[4] = 0x510e527f;\n hh[5] = 0x9b05688c;\n hh[6] = 0x1f83d9ab;\n hh[7] = 0x5be0cd19;\n\n hl[0] = 0xf3bcc908;\n hl[1] = 0x84caa73b;\n hl[2] = 0xfe94f82b;\n hl[3] = 0x5f1d36f1;\n hl[4] = 0xade682d1;\n hl[5] = 0x2b3e6c1f;\n hl[6] = 0xfb41bd6b;\n hl[7] = 0x137e2179;\n\n crypto_hashblocks_hl(hh, hl, m, n);\n n %= 128;\n\n for (i = 0; i < n; i++) x[i] = m[b-n+i];\n x[n] = 128;\n\n n = 256-128*(n<112?1:0);\n x[n-9] = 0;\n ts64(x, n-8, (b / 0x20000000) | 0, b << 3);\n crypto_hashblocks_hl(hh, hl, x, n);\n\n for (i = 0; i < 8; i++) ts64(out, 8*i, hh[i], hl[i]);\n\n return 0;\n}\n\nfunction add(p, q) {\n var a = gf(), b = gf(), c = gf(),\n d = gf(), e = gf(), f = gf(),\n g = gf(), h = gf(), t = gf();\n\n Z(a, p[1], p[0]);\n Z(t, q[1], q[0]);\n M(a, a, t);\n A(b, p[0], p[1]);\n A(t, q[0], q[1]);\n M(b, b, t);\n M(c, p[3], q[3]);\n M(c, c, D2);\n M(d, p[2], q[2]);\n A(d, d, d);\n Z(e, b, a);\n Z(f, d, c);\n A(g, d, c);\n A(h, b, a);\n\n M(p[0], e, f);\n M(p[1], h, g);\n M(p[2], g, f);\n M(p[3], e, h);\n}\n\nfunction cswap(p, q, b) {\n var i;\n for (i = 0; i < 4; i++) {\n sel25519(p[i], q[i], b);\n }\n}\n\nfunction pack(r, p) {\n var tx = gf(), ty = gf(), zi = gf();\n inv25519(zi, p[2]);\n M(tx, p[0], zi);\n M(ty, p[1], zi);\n pack25519(r, ty);\n r[31] ^= par25519(tx) << 7;\n}\n\nfunction scalarmult(p, q, s) {\n var b, i;\n set25519(p[0], gf0);\n set25519(p[1], gf1);\n set25519(p[2], gf1);\n set25519(p[3], gf0);\n for (i = 255; i >= 0; --i) {\n b = (s[(i/8)|0] >> (i&7)) & 1;\n cswap(p, q, b);\n add(q, p);\n add(p, p);\n cswap(p, q, b);\n }\n}\n\nfunction scalarbase(p, s) {\n var q = [gf(), gf(), gf(), gf()];\n set25519(q[0], X);\n set25519(q[1], Y);\n set25519(q[2], gf1);\n M(q[3], X, Y);\n scalarmult(p, q, s);\n}\n\nfunction crypto_sign_keypair(pk, sk, seeded) {\n var d = new Uint8Array(64);\n var p = [gf(), gf(), gf(), gf()];\n var i;\n\n if (!seeded) randombytes(sk, 32);\n crypto_hash(d, sk, 32);\n d[0] &= 248;\n d[31] &= 127;\n d[31] |= 64;\n\n scalarbase(p, d);\n pack(pk, p);\n\n for (i = 0; i < 32; i++) sk[i+32] = pk[i];\n return 0;\n}\n\nvar L = new Float64Array([0xed, 0xd3, 0xf5, 0x5c, 0x1a, 0x63, 0x12, 0x58, 0xd6, 0x9c, 0xf7, 0xa2, 0xde, 0xf9, 0xde, 0x14, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x10]);\n\nfunction modL(r, x) {\n var carry, i, j, k;\n for (i = 63; i >= 32; --i) {\n carry = 0;\n for (j = i - 32, k = i - 12; j < k; ++j) {\n x[j] += carry - 16 * x[i] * L[j - (i - 32)];\n carry = Math.floor((x[j] + 128) / 256);\n x[j] -= carry * 256;\n }\n x[j] += carry;\n x[i] = 0;\n }\n carry = 0;\n for (j = 0; j < 32; j++) {\n x[j] += carry - (x[31] >> 4) * L[j];\n carry = x[j] >> 8;\n x[j] &= 255;\n }\n for (j = 0; j < 32; j++) x[j] -= carry * L[j];\n for (i = 0; i < 32; i++) {\n x[i+1] += x[i] >> 8;\n r[i] = x[i] & 255;\n }\n}\n\nfunction reduce(r) {\n var x = new Float64Array(64), i;\n for (i = 0; i < 64; i++) x[i] = r[i];\n for (i = 0; i < 64; i++) r[i] = 0;\n modL(r, x);\n}\n\n// Note: difference from C - smlen returned, not passed as argument.\nfunction crypto_sign(sm, m, n, sk) {\n var d = new Uint8Array(64), h = new Uint8Array(64), r = new Uint8Array(64);\n var i, j, x = new Float64Array(64);\n var p = [gf(), gf(), gf(), gf()];\n\n crypto_hash(d, sk, 32);\n d[0] &= 248;\n d[31] &= 127;\n d[31] |= 64;\n\n var smlen = n + 64;\n for (i = 0; i < n; i++) sm[64 + i] = m[i];\n for (i = 0; i < 32; i++) sm[32 + i] = d[32 + i];\n\n crypto_hash(r, sm.subarray(32), n+32);\n reduce(r);\n scalarbase(p, r);\n pack(sm, p);\n\n for (i = 32; i < 64; i++) sm[i] = sk[i];\n crypto_hash(h, sm, n + 64);\n reduce(h);\n\n for (i = 0; i < 64; i++) x[i] = 0;\n for (i = 0; i < 32; i++) x[i] = r[i];\n for (i = 0; i < 32; i++) {\n for (j = 0; j < 32; j++) {\n x[i+j] += h[i] * d[j];\n }\n }\n\n modL(sm.subarray(32), x);\n return smlen;\n}\n\nfunction unpackneg(r, p) {\n var t = gf(), chk = gf(), num = gf(),\n den = gf(), den2 = gf(), den4 = gf(),\n den6 = gf();\n\n set25519(r[2], gf1);\n unpack25519(r[1], p);\n S(num, r[1]);\n M(den, num, D);\n Z(num, num, r[2]);\n A(den, r[2], den);\n\n S(den2, den);\n S(den4, den2);\n M(den6, den4, den2);\n M(t, den6, num);\n M(t, t, den);\n\n pow2523(t, t);\n M(t, t, num);\n M(t, t, den);\n M(t, t, den);\n M(r[0], t, den);\n\n S(chk, r[0]);\n M(chk, chk, den);\n if (neq25519(chk, num)) M(r[0], r[0], I);\n\n S(chk, r[0]);\n M(chk, chk, den);\n if (neq25519(chk, num)) return -1;\n\n if (par25519(r[0]) === (p[31]>>7)) Z(r[0], gf0, r[0]);\n\n M(r[3], r[0], r[1]);\n return 0;\n}\n\nfunction crypto_sign_open(m, sm, n, pk) {\n var i;\n var t = new Uint8Array(32), h = new Uint8Array(64);\n var p = [gf(), gf(), gf(), gf()],\n q = [gf(), gf(), gf(), gf()];\n\n if (n < 64) return -1;\n\n if (unpackneg(q, pk)) return -1;\n\n for (i = 0; i < n; i++) m[i] = sm[i];\n for (i = 0; i < 32; i++) m[i+32] = pk[i];\n crypto_hash(h, m, n);\n reduce(h);\n scalarmult(p, q, h);\n\n scalarbase(q, sm.subarray(32));\n add(p, q);\n pack(t, p);\n\n n -= 64;\n if (crypto_verify_32(sm, 0, t, 0)) {\n for (i = 0; i < n; i++) m[i] = 0;\n return -1;\n }\n\n for (i = 0; i < n; i++) m[i] = sm[i + 64];\n return n;\n}\n\nvar crypto_secretbox_KEYBYTES = 32,\n crypto_secretbox_NONCEBYTES = 24,\n crypto_secretbox_ZEROBYTES = 32,\n crypto_secretbox_BOXZEROBYTES = 16,\n crypto_scalarmult_BYTES = 32,\n crypto_scalarmult_SCALARBYTES = 32,\n crypto_box_PUBLICKEYBYTES = 32,\n crypto_box_SECRETKEYBYTES = 32,\n crypto_box_BEFORENMBYTES = 32,\n crypto_box_NONCEBYTES = crypto_secretbox_NONCEBYTES,\n crypto_box_ZEROBYTES = crypto_secretbox_ZEROBYTES,\n crypto_box_BOXZEROBYTES = crypto_secretbox_BOXZEROBYTES,\n crypto_sign_BYTES = 64,\n crypto_sign_PUBLICKEYBYTES = 32,\n crypto_sign_SECRETKEYBYTES = 64,\n crypto_sign_SEEDBYTES = 32,\n crypto_hash_BYTES = 64;\n\nnacl.lowlevel = {\n crypto_core_hsalsa20: crypto_core_hsalsa20,\n crypto_stream_xor: crypto_stream_xor,\n crypto_stream: crypto_stream,\n crypto_stream_salsa20_xor: crypto_stream_salsa20_xor,\n crypto_stream_salsa20: crypto_stream_salsa20,\n crypto_onetimeauth: crypto_onetimeauth,\n crypto_onetimeauth_verify: crypto_onetimeauth_verify,\n crypto_verify_16: crypto_verify_16,\n crypto_verify_32: crypto_verify_32,\n crypto_secretbox: crypto_secretbox,\n crypto_secretbox_open: crypto_secretbox_open,\n crypto_scalarmult: crypto_scalarmult,\n crypto_scalarmult_base: crypto_scalarmult_base,\n crypto_box_beforenm: crypto_box_beforenm,\n crypto_box_afternm: crypto_box_afternm,\n crypto_box: crypto_box,\n crypto_box_open: crypto_box_open,\n crypto_box_keypair: crypto_box_keypair,\n crypto_hash: crypto_hash,\n crypto_sign: crypto_sign,\n crypto_sign_keypair: crypto_sign_keypair,\n crypto_sign_open: crypto_sign_open,\n\n crypto_secretbox_KEYBYTES: crypto_secretbox_KEYBYTES,\n crypto_secretbox_NONCEBYTES: crypto_secretbox_NONCEBYTES,\n crypto_secretbox_ZEROBYTES: crypto_secretbox_ZEROBYTES,\n crypto_secretbox_BOXZEROBYTES: crypto_secretbox_BOXZEROBYTES,\n crypto_scalarmult_BYTES: crypto_scalarmult_BYTES,\n crypto_scalarmult_SCALARBYTES: crypto_scalarmult_SCALARBYTES,\n crypto_box_PUBLICKEYBYTES: crypto_box_PUBLICKEYBYTES,\n crypto_box_SECRETKEYBYTES: crypto_box_SECRETKEYBYTES,\n crypto_box_BEFORENMBYTES: crypto_box_BEFORENMBYTES,\n crypto_box_NONCEBYTES: crypto_box_NONCEBYTES,\n crypto_box_ZEROBYTES: crypto_box_ZEROBYTES,\n crypto_box_BOXZEROBYTES: crypto_box_BOXZEROBYTES,\n crypto_sign_BYTES: crypto_sign_BYTES,\n crypto_sign_PUBLICKEYBYTES: crypto_sign_PUBLICKEYBYTES,\n crypto_sign_SECRETKEYBYTES: crypto_sign_SECRETKEYBYTES,\n crypto_sign_SEEDBYTES: crypto_sign_SEEDBYTES,\n crypto_hash_BYTES: crypto_hash_BYTES,\n\n gf: gf,\n D: D,\n L: L,\n pack25519: pack25519,\n unpack25519: unpack25519,\n M: M,\n A: A,\n S: S,\n Z: Z,\n pow2523: pow2523,\n add: add,\n set25519: set25519,\n modL: modL,\n scalarmult: scalarmult,\n scalarbase: scalarbase,\n};\n\n/* High-level API */\n\nfunction checkLengths(k, n) {\n if (k.length !== crypto_secretbox_KEYBYTES) throw new Error('bad key size');\n if (n.length !== crypto_secretbox_NONCEBYTES) throw new Error('bad nonce size');\n}\n\nfunction checkBoxLengths(pk, sk) {\n if (pk.length !== crypto_box_PUBLICKEYBYTES) throw new Error('bad public key size');\n if (sk.length !== crypto_box_SECRETKEYBYTES) throw new Error('bad secret key size');\n}\n\nfunction checkArrayTypes() {\n for (var i = 0; i < arguments.length; i++) {\n if (!(arguments[i] instanceof Uint8Array))\n throw new TypeError('unexpected type, use Uint8Array');\n }\n}\n\nfunction cleanup(arr) {\n for (var i = 0; i < arr.length; i++) arr[i] = 0;\n}\n\nnacl.randomBytes = function(n) {\n var b = new Uint8Array(n);\n randombytes(b, n);\n return b;\n};\n\nnacl.secretbox = function(msg, nonce, key) {\n checkArrayTypes(msg, nonce, key);\n checkLengths(key, nonce);\n var m = new Uint8Array(crypto_secretbox_ZEROBYTES + msg.length);\n var c = new Uint8Array(m.length);\n for (var i = 0; i < msg.length; i++) m[i+crypto_secretbox_ZEROBYTES] = msg[i];\n crypto_secretbox(c, m, m.length, nonce, key);\n return c.subarray(crypto_secretbox_BOXZEROBYTES);\n};\n\nnacl.secretbox.open = function(box, nonce, key) {\n checkArrayTypes(box, nonce, key);\n checkLengths(key, nonce);\n var c = new Uint8Array(crypto_secretbox_BOXZEROBYTES + box.length);\n var m = new Uint8Array(c.length);\n for (var i = 0; i < box.length; i++) c[i+crypto_secretbox_BOXZEROBYTES] = box[i];\n if (c.length < 32) return null;\n if (crypto_secretbox_open(m, c, c.length, nonce, key) !== 0) return null;\n return m.subarray(crypto_secretbox_ZEROBYTES);\n};\n\nnacl.secretbox.keyLength = crypto_secretbox_KEYBYTES;\nnacl.secretbox.nonceLength = crypto_secretbox_NONCEBYTES;\nnacl.secretbox.overheadLength = crypto_secretbox_BOXZEROBYTES;\n\nnacl.scalarMult = function(n, p) {\n checkArrayTypes(n, p);\n if (n.length !== crypto_scalarmult_SCALARBYTES) throw new Error('bad n size');\n if (p.length !== crypto_scalarmult_BYTES) throw new Error('bad p size');\n var q = new Uint8Array(crypto_scalarmult_BYTES);\n crypto_scalarmult(q, n, p);\n return q;\n};\n\nnacl.scalarMult.base = function(n) {\n checkArrayTypes(n);\n if (n.length !== crypto_scalarmult_SCALARBYTES) throw new Error('bad n size');\n var q = new Uint8Array(crypto_scalarmult_BYTES);\n crypto_scalarmult_base(q, n);\n return q;\n};\n\nnacl.scalarMult.scalarLength = crypto_scalarmult_SCALARBYTES;\nnacl.scalarMult.groupElementLength = crypto_scalarmult_BYTES;\n\nnacl.box = function(msg, nonce, publicKey, secretKey) {\n var k = nacl.box.before(publicKey, secretKey);\n return nacl.secretbox(msg, nonce, k);\n};\n\nnacl.box.before = function(publicKey, secretKey) {\n checkArrayTypes(publicKey, secretKey);\n checkBoxLengths(publicKey, secretKey);\n var k = new Uint8Array(crypto_box_BEFORENMBYTES);\n crypto_box_beforenm(k, publicKey, secretKey);\n return k;\n};\n\nnacl.box.after = nacl.secretbox;\n\nnacl.box.open = function(msg, nonce, publicKey, secretKey) {\n var k = nacl.box.before(publicKey, secretKey);\n return nacl.secretbox.open(msg, nonce, k);\n};\n\nnacl.box.open.after = nacl.secretbox.open;\n\nnacl.box.keyPair = function() {\n var pk = new Uint8Array(crypto_box_PUBLICKEYBYTES);\n var sk = new Uint8Array(crypto_box_SECRETKEYBYTES);\n crypto_box_keypair(pk, sk);\n return {publicKey: pk, secretKey: sk};\n};\n\nnacl.box.keyPair.fromSecretKey = function(secretKey) {\n checkArrayTypes(secretKey);\n if (secretKey.length !== crypto_box_SECRETKEYBYTES)\n throw new Error('bad secret key size');\n var pk = new Uint8Array(crypto_box_PUBLICKEYBYTES);\n crypto_scalarmult_base(pk, secretKey);\n return {publicKey: pk, secretKey: new Uint8Array(secretKey)};\n};\n\nnacl.box.publicKeyLength = crypto_box_PUBLICKEYBYTES;\nnacl.box.secretKeyLength = crypto_box_SECRETKEYBYTES;\nnacl.box.sharedKeyLength = crypto_box_BEFORENMBYTES;\nnacl.box.nonceLength = crypto_box_NONCEBYTES;\nnacl.box.overheadLength = nacl.secretbox.overheadLength;\n\nnacl.sign = function(msg, secretKey) {\n checkArrayTypes(msg, secretKey);\n if (secretKey.length !== crypto_sign_SECRETKEYBYTES)\n throw new Error('bad secret key size');\n var signedMsg = new Uint8Array(crypto_sign_BYTES+msg.length);\n crypto_sign(signedMsg, msg, msg.length, secretKey);\n return signedMsg;\n};\n\nnacl.sign.open = function(signedMsg, publicKey) {\n checkArrayTypes(signedMsg, publicKey);\n if (publicKey.length !== crypto_sign_PUBLICKEYBYTES)\n throw new Error('bad public key size');\n var tmp = new Uint8Array(signedMsg.length);\n var mlen = crypto_sign_open(tmp, signedMsg, signedMsg.length, publicKey);\n if (mlen < 0) return null;\n var m = new Uint8Array(mlen);\n for (var i = 0; i < m.length; i++) m[i] = tmp[i];\n return m;\n};\n\nnacl.sign.detached = function(msg, secretKey) {\n var signedMsg = nacl.sign(msg, secretKey);\n var sig = new Uint8Array(crypto_sign_BYTES);\n for (var i = 0; i < sig.length; i++) sig[i] = signedMsg[i];\n return sig;\n};\n\nnacl.sign.detached.verify = function(msg, sig, publicKey) {\n checkArrayTypes(msg, sig, publicKey);\n if (sig.length !== crypto_sign_BYTES)\n throw new Error('bad signature size');\n if (publicKey.length !== crypto_sign_PUBLICKEYBYTES)\n throw new Error('bad public key size');\n var sm = new Uint8Array(crypto_sign_BYTES + msg.length);\n var m = new Uint8Array(crypto_sign_BYTES + msg.length);\n var i;\n for (i = 0; i < crypto_sign_BYTES; i++) sm[i] = sig[i];\n for (i = 0; i < msg.length; i++) sm[i+crypto_sign_BYTES] = msg[i];\n return (crypto_sign_open(m, sm, sm.length, publicKey) >= 0);\n};\n\nnacl.sign.keyPair = function() {\n var pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);\n var sk = new Uint8Array(crypto_sign_SECRETKEYBYTES);\n crypto_sign_keypair(pk, sk);\n return {publicKey: pk, secretKey: sk};\n};\n\nnacl.sign.keyPair.fromSecretKey = function(secretKey) {\n checkArrayTypes(secretKey);\n if (secretKey.length !== crypto_sign_SECRETKEYBYTES)\n throw new Error('bad secret key size');\n var pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);\n for (var i = 0; i < pk.length; i++) pk[i] = secretKey[32+i];\n return {publicKey: pk, secretKey: new Uint8Array(secretKey)};\n};\n\nnacl.sign.keyPair.fromSeed = function(seed) {\n checkArrayTypes(seed);\n if (seed.length !== crypto_sign_SEEDBYTES)\n throw new Error('bad seed size');\n var pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);\n var sk = new Uint8Array(crypto_sign_SECRETKEYBYTES);\n for (var i = 0; i < 32; i++) sk[i] = seed[i];\n crypto_sign_keypair(pk, sk, true);\n return {publicKey: pk, secretKey: sk};\n};\n\nnacl.sign.publicKeyLength = crypto_sign_PUBLICKEYBYTES;\nnacl.sign.secretKeyLength = crypto_sign_SECRETKEYBYTES;\nnacl.sign.seedLength = crypto_sign_SEEDBYTES;\nnacl.sign.signatureLength = crypto_sign_BYTES;\n\nnacl.hash = function(msg) {\n checkArrayTypes(msg);\n var h = new Uint8Array(crypto_hash_BYTES);\n crypto_hash(h, msg, msg.length);\n return h;\n};\n\nnacl.hash.hashLength = crypto_hash_BYTES;\n\nnacl.verify = function(x, y) {\n checkArrayTypes(x, y);\n // Zero length arguments are considered not equal.\n if (x.length === 0 || y.length === 0) return false;\n if (x.length !== y.length) return false;\n return (vn(x, 0, y, 0, x.length) === 0) ? true : false;\n};\n\nnacl.setPRNG = function(fn) {\n randombytes = fn;\n};\n\n(function() {\n // Initialize PRNG if environment provides CSPRNG.\n // If not, methods calling randombytes will throw.\n var crypto = typeof self !== 'undefined' ? (self.crypto || self.msCrypto) : null;\n if (crypto && crypto.getRandomValues) {\n // Browsers.\n var QUOTA = 65536;\n nacl.setPRNG(function(x, n) {\n var i, v = new Uint8Array(n);\n for (i = 0; i < n; i += QUOTA) {\n crypto.getRandomValues(v.subarray(i, i + Math.min(n - i, QUOTA)));\n }\n for (i = 0; i < n; i++) x[i] = v[i];\n cleanup(v);\n });\n } else if (typeof require !== 'undefined') {\n // Node.js.\n crypto = require('crypto');\n if (crypto && crypto.randomBytes) {\n nacl.setPRNG(function(x, n) {\n var i, v = crypto.randomBytes(n);\n for (i = 0; i < n; i++) x[i] = v[i];\n cleanup(v);\n });\n }\n }\n})();\n\n})(typeof module !== 'undefined' && module.exports ? module.exports : (self.nacl = self.nacl || {}));\n","module.exports = require('./pusher-with-encryption').default;\n","module.exports = require(\"buffer\");","module.exports = require(\"events\");","'use strict';\n\n/**\n\nStreams in a WebSocket connection\n---------------------------------\n\nWe model a WebSocket as two duplex streams: one stream is for the wire protocol\nover an I/O socket, and the other is for incoming/outgoing messages.\n\n\n +----------+ +---------+ +----------+\n [1] write(chunk) -->| ~~~~~~~~ +----->| parse() +----->| ~~~~~~~~ +--> emit('data') [2]\n | | +----+----+ | |\n | | | | |\n | IO | | [5] | Messages |\n | | V | |\n | | +---------+ | |\n [4] emit('data') <--+ ~~~~~~~~ |<-----+ frame() |<-----+ ~~~~~~~~ |<-- write(chunk) [3]\n +----------+ +---------+ +----------+\n\n\nMessage transfer in each direction is simple: IO receives a byte stream [1] and\nsends this stream for parsing. The parser will periodically emit a complete\nmessage text on the Messages stream [2]. Similarly, when messages are written\nto the Messages stream [3], they are framed using the WebSocket wire format and\nemitted via IO [4].\n\nThere is a feedback loop via [5] since some input from [1] will be things like\nping, pong and close frames. In these cases the protocol responds by emitting\nresponses directly back to [4] rather than emitting messages via [2].\n\nFor the purposes of flow control, we consider the sources of each Readable\nstream to be as follows:\n\n* [2] receives input from [1]\n* [4] receives input from [1] and [3]\n\nThe classes below express the relationships described above without prescribing\nanything about how parse() and frame() work, other than assuming they emit\n'data' events to the IO and Messages streams. They will work with any protocol\ndriver having these two methods.\n**/\n\n\nvar Stream = require('stream').Stream,\n util = require('util');\n\n\nvar IO = function(driver) {\n this.readable = this.writable = true;\n this._paused = false;\n this._driver = driver;\n};\nutil.inherits(IO, Stream);\n\n// The IO pause() and resume() methods will be called when the socket we are\n// piping to gets backed up and drains. Since IO output [4] comes from IO input\n// [1] and Messages input [3], we need to tell both of those to return false\n// from write() when this stream is paused.\n\nIO.prototype.pause = function() {\n this._paused = true;\n this._driver.messages._paused = true;\n};\n\nIO.prototype.resume = function() {\n this._paused = false;\n this.emit('drain');\n\n var messages = this._driver.messages;\n messages._paused = false;\n messages.emit('drain');\n};\n\n// When we receive input from a socket, send it to the parser and tell the\n// source whether to back off.\nIO.prototype.write = function(chunk) {\n if (!this.writable) return false;\n this._driver.parse(chunk);\n return !this._paused;\n};\n\n// The IO end() method will be called when the socket piping into it emits\n// 'close' or 'end', i.e. the socket is closed. In this situation the Messages\n// stream will not emit any more data so we emit 'end'.\nIO.prototype.end = function(chunk) {\n if (!this.writable) return;\n if (chunk !== undefined) this.write(chunk);\n this.writable = false;\n\n var messages = this._driver.messages;\n if (messages.readable) {\n messages.readable = messages.writable = false;\n messages.emit('end');\n }\n};\n\nIO.prototype.destroy = function() {\n this.end();\n};\n\n\nvar Messages = function(driver) {\n this.readable = this.writable = true;\n this._paused = false;\n this._driver = driver;\n};\nutil.inherits(Messages, Stream);\n\n// The Messages pause() and resume() methods will be called when the app that's\n// processing the messages gets backed up and drains. If we're emitting\n// messages too fast we should tell the source to slow down. Message output [2]\n// comes from IO input [1].\n\nMessages.prototype.pause = function() {\n this._driver.io._paused = true;\n};\n\nMessages.prototype.resume = function() {\n this._driver.io._paused = false;\n this._driver.io.emit('drain');\n};\n\n// When we receive messages from the user, send them to the formatter and tell\n// the source whether to back off.\nMessages.prototype.write = function(message) {\n if (!this.writable) return false;\n if (typeof message === 'string') this._driver.text(message);\n else this._driver.binary(message);\n return !this._paused;\n};\n\n// The Messages end() method will be called when a stream piping into it emits\n// 'end'. Many streams may be piped into the WebSocket and one of them ending\n// does not mean the whole socket is done, so just process the input and move\n// on leaving the socket open.\nMessages.prototype.end = function(message) {\n if (message !== undefined) this.write(message);\n};\n\nMessages.prototype.destroy = function() {};\n\n\nexports.IO = IO;\nexports.Messages = Messages;\n","'use strict';\n\nvar Buffer = require('safe-buffer').Buffer;\n\nvar StreamReader = function() {\n this._queue = [];\n this._queueSize = 0;\n this._offset = 0;\n};\n\nStreamReader.prototype.put = function(buffer) {\n if (!buffer || buffer.length === 0) return;\n if (!Buffer.isBuffer(buffer)) buffer = Buffer.from(buffer);\n this._queue.push(buffer);\n this._queueSize += buffer.length;\n};\n\nStreamReader.prototype.read = function(length) {\n if (length > this._queueSize) return null;\n if (length === 0) return Buffer.alloc(0);\n\n this._queueSize -= length;\n\n var queue = this._queue,\n remain = length,\n first = queue[0],\n buffers, buffer;\n\n if (first.length >= length) {\n if (first.length === length) {\n return queue.shift();\n } else {\n buffer = first.slice(0, length);\n queue[0] = first.slice(length);\n return buffer;\n }\n }\n\n for (var i = 0, n = queue.length; i < n; i++) {\n if (remain < queue[i].length) break;\n remain -= queue[i].length;\n }\n buffers = queue.splice(0, i);\n\n if (remain > 0 && queue.length > 0) {\n buffers.push(queue[0].slice(0, remain));\n queue[0] = queue[0].slice(remain);\n }\n return Buffer.concat(buffers, length);\n};\n\nStreamReader.prototype.eachByte = function(callback, context) {\n var buffer, n, index;\n\n while (this._queue.length > 0) {\n buffer = this._queue[0];\n n = buffer.length;\n\n while (this._offset < n) {\n index = this._offset;\n this._offset += 1;\n callback.call(context, buffer[index]);\n }\n this._offset = 0;\n this._queue.shift();\n }\n};\n\nmodule.exports = StreamReader;\n","'use strict';\n\nvar Buffer = require('safe-buffer').Buffer,\n crypto = require('crypto'),\n url = require('url'),\n util = require('util'),\n HttpParser = require('../http_parser'),\n Base = require('./base'),\n Hybi = require('./hybi'),\n Proxy = require('./proxy');\n\nvar Client = function(_url, options) {\n this.version = 'hybi-' + Hybi.VERSION;\n Hybi.call(this, null, _url, options);\n\n this.readyState = -1;\n this._key = Client.generateKey();\n this._accept = Hybi.generateAccept(this._key);\n this._http = new HttpParser('response');\n\n var uri = url.parse(this.url),\n auth = uri.auth && Buffer.from(uri.auth, 'utf8').toString('base64');\n\n if (this.VALID_PROTOCOLS.indexOf(uri.protocol) < 0)\n throw new Error(this.url + ' is not a valid WebSocket URL');\n\n this._pathname = (uri.pathname || '/') + (uri.search || '');\n\n this._headers.set('Host', uri.host);\n this._headers.set('Upgrade', 'websocket');\n this._headers.set('Connection', 'Upgrade');\n this._headers.set('Sec-WebSocket-Key', this._key);\n this._headers.set('Sec-WebSocket-Version', Hybi.VERSION);\n\n if (this._protocols.length > 0)\n this._headers.set('Sec-WebSocket-Protocol', this._protocols.join(', '));\n\n if (auth)\n this._headers.set('Authorization', 'Basic ' + auth);\n};\nutil.inherits(Client, Hybi);\n\nClient.generateKey = function() {\n return crypto.randomBytes(16).toString('base64');\n};\n\nvar instance = {\n VALID_PROTOCOLS: ['ws:', 'wss:'],\n\n proxy: function(origin, options) {\n return new Proxy(this, origin, options);\n },\n\n start: function() {\n if (this.readyState !== -1) return false;\n this._write(this._handshakeRequest());\n this.readyState = 0;\n return true;\n },\n\n parse: function(chunk) {\n if (this.readyState === 3) return;\n if (this.readyState > 0) return Hybi.prototype.parse.call(this, chunk);\n\n this._http.parse(chunk);\n if (!this._http.isComplete()) return;\n\n this._validateHandshake();\n if (this.readyState === 3) return;\n\n this._open();\n this.parse(this._http.body);\n },\n\n _handshakeRequest: function() {\n var extensions = this._extensions.generateOffer();\n if (extensions)\n this._headers.set('Sec-WebSocket-Extensions', extensions);\n\n var start = 'GET ' + this._pathname + ' HTTP/1.1',\n headers = [start, this._headers.toString(), ''];\n\n return Buffer.from(headers.join('\\r\\n'), 'utf8');\n },\n\n _failHandshake: function(message) {\n message = 'Error during WebSocket handshake: ' + message;\n this.readyState = 3;\n this.emit('error', new Error(message));\n this.emit('close', new Base.CloseEvent(this.ERRORS.protocol_error, message));\n },\n\n _validateHandshake: function() {\n this.statusCode = this._http.statusCode;\n this.headers = this._http.headers;\n\n if (this._http.error)\n return this._failHandshake(this._http.error.message);\n\n if (this._http.statusCode !== 101)\n return this._failHandshake('Unexpected response code: ' + this._http.statusCode);\n\n var headers = this._http.headers,\n upgrade = headers['upgrade'] || '',\n connection = headers['connection'] || '',\n accept = headers['sec-websocket-accept'] || '',\n protocol = headers['sec-websocket-protocol'] || '';\n\n if (upgrade === '')\n return this._failHandshake(\"'Upgrade' header is missing\");\n if (upgrade.toLowerCase() !== 'websocket')\n return this._failHandshake(\"'Upgrade' header value is not 'WebSocket'\");\n\n if (connection === '')\n return this._failHandshake(\"'Connection' header is missing\");\n if (connection.toLowerCase() !== 'upgrade')\n return this._failHandshake(\"'Connection' header value is not 'Upgrade'\");\n\n if (accept !== this._accept)\n return this._failHandshake('Sec-WebSocket-Accept mismatch');\n\n this.protocol = null;\n\n if (protocol !== '') {\n if (this._protocols.indexOf(protocol) < 0)\n return this._failHandshake('Sec-WebSocket-Protocol mismatch');\n else\n this.protocol = protocol;\n }\n\n try {\n this._extensions.activate(this.headers['sec-websocket-extensions']);\n } catch (e) {\n return this._failHandshake(e.message);\n }\n }\n};\n\nfor (var key in instance)\n Client.prototype[key] = instance[key];\n\nmodule.exports = Client;\n","/*jshint node:true */\n\nvar assert = require('assert');\n\nexports.HTTPParser = HTTPParser;\nfunction HTTPParser(type) {\n assert.ok(type === HTTPParser.REQUEST || type === HTTPParser.RESPONSE || type === undefined);\n if (type === undefined) {\n // Node v12+\n } else {\n this.initialize(type);\n }\n this.maxHeaderSize=HTTPParser.maxHeaderSize\n}\nHTTPParser.prototype.initialize = function (type, async_resource) {\n assert.ok(type === HTTPParser.REQUEST || type === HTTPParser.RESPONSE);\n this.type = type;\n this.state = type + '_LINE';\n this.info = {\n headers: [],\n upgrade: false\n };\n this.trailers = [];\n this.line = '';\n this.isChunked = false;\n this.connection = '';\n this.headerSize = 0; // for preventing too big headers\n this.body_bytes = null;\n this.isUserCall = false;\n this.hadError = false;\n};\n\nHTTPParser.encoding = 'ascii';\nHTTPParser.maxHeaderSize = 80 * 1024; // maxHeaderSize (in bytes) is configurable, but 80kb by default;\nHTTPParser.REQUEST = 'REQUEST';\nHTTPParser.RESPONSE = 'RESPONSE';\n\n// Note: *not* starting with kOnHeaders=0 line the Node parser, because any\n// newly added constants (kOnTimeout in Node v12.19.0) will overwrite 0!\nvar kOnHeaders = HTTPParser.kOnHeaders = 1;\nvar kOnHeadersComplete = HTTPParser.kOnHeadersComplete = 2;\nvar kOnBody = HTTPParser.kOnBody = 3;\nvar kOnMessageComplete = HTTPParser.kOnMessageComplete = 4;\n\n// Some handler stubs, needed for compatibility\nHTTPParser.prototype[kOnHeaders] =\nHTTPParser.prototype[kOnHeadersComplete] =\nHTTPParser.prototype[kOnBody] =\nHTTPParser.prototype[kOnMessageComplete] = function () {};\n\nvar compatMode0_12 = true;\nObject.defineProperty(HTTPParser, 'kOnExecute', {\n get: function () {\n // hack for backward compatibility\n compatMode0_12 = false;\n return 99;\n }\n });\n\nvar methods = exports.methods = HTTPParser.methods = [\n 'DELETE',\n 'GET',\n 'HEAD',\n 'POST',\n 'PUT',\n 'CONNECT',\n 'OPTIONS',\n 'TRACE',\n 'COPY',\n 'LOCK',\n 'MKCOL',\n 'MOVE',\n 'PROPFIND',\n 'PROPPATCH',\n 'SEARCH',\n 'UNLOCK',\n 'BIND',\n 'REBIND',\n 'UNBIND',\n 'ACL',\n 'REPORT',\n 'MKACTIVITY',\n 'CHECKOUT',\n 'MERGE',\n 'M-SEARCH',\n 'NOTIFY',\n 'SUBSCRIBE',\n 'UNSUBSCRIBE',\n 'PATCH',\n 'PURGE',\n 'MKCALENDAR',\n 'LINK',\n 'UNLINK',\n 'SOURCE',\n];\nvar method_connect = methods.indexOf('CONNECT');\nHTTPParser.prototype.reinitialize = HTTPParser;\nHTTPParser.prototype.close =\nHTTPParser.prototype.pause =\nHTTPParser.prototype.resume =\nHTTPParser.prototype.free = function () {};\nHTTPParser.prototype._compatMode0_11 = false;\nHTTPParser.prototype.getAsyncId = function() { return 0; };\n\nvar headerState = {\n REQUEST_LINE: true,\n RESPONSE_LINE: true,\n HEADER: true\n};\nHTTPParser.prototype.execute = function (chunk, start, length) {\n if (!(this instanceof HTTPParser)) {\n throw new TypeError('not a HTTPParser');\n }\n\n // backward compat to node < 0.11.4\n // Note: the start and length params were removed in newer version\n start = start || 0;\n length = typeof length === 'number' ? length : chunk.length;\n\n this.chunk = chunk;\n this.offset = start;\n var end = this.end = start + length;\n try {\n while (this.offset < end) {\n if (this[this.state]()) {\n break;\n }\n }\n } catch (err) {\n if (this.isUserCall) {\n throw err;\n }\n this.hadError = true;\n return err;\n }\n this.chunk = null;\n length = this.offset - start;\n if (headerState[this.state]) {\n this.headerSize += length;\n if (this.headerSize > (this.maxHeaderSize||HTTPParser.maxHeaderSize)) {\n return new Error('max header size exceeded');\n }\n }\n return length;\n};\n\nvar stateFinishAllowed = {\n REQUEST_LINE: true,\n RESPONSE_LINE: true,\n BODY_RAW: true\n};\nHTTPParser.prototype.finish = function () {\n if (this.hadError) {\n return;\n }\n if (!stateFinishAllowed[this.state]) {\n return new Error('invalid state for EOF');\n }\n if (this.state === 'BODY_RAW') {\n this.userCall()(this[kOnMessageComplete]());\n }\n};\n\n// These three methods are used for an internal speed optimization, and it also\n// works if theses are noops. Basically consume() asks us to read the bytes\n// ourselves, but if we don't do it we get them through execute().\nHTTPParser.prototype.consume =\nHTTPParser.prototype.unconsume =\nHTTPParser.prototype.getCurrentBuffer = function () {};\n\n//For correct error handling - see HTTPParser#execute\n//Usage: this.userCall()(userFunction('arg'));\nHTTPParser.prototype.userCall = function () {\n this.isUserCall = true;\n var self = this;\n return function (ret) {\n self.isUserCall = false;\n return ret;\n };\n};\n\nHTTPParser.prototype.nextRequest = function () {\n this.userCall()(this[kOnMessageComplete]());\n this.reinitialize(this.type);\n};\n\nHTTPParser.prototype.consumeLine = function () {\n var end = this.end,\n chunk = this.chunk;\n for (var i = this.offset; i < end; i++) {\n if (chunk[i] === 0x0a) { // \\n\n var line = this.line + chunk.toString(HTTPParser.encoding, this.offset, i);\n if (line.charAt(line.length - 1) === '\\r') {\n line = line.substr(0, line.length - 1);\n }\n this.line = '';\n this.offset = i + 1;\n return line;\n }\n }\n //line split over multiple chunks\n this.line += chunk.toString(HTTPParser.encoding, this.offset, this.end);\n this.offset = this.end;\n};\n\nvar headerExp = /^([^: \\t]+):[ \\t]*((?:.*[^ \\t])|)/;\nvar headerContinueExp = /^[ \\t]+(.*[^ \\t])/;\nHTTPParser.prototype.parseHeader = function (line, headers) {\n if (line.indexOf('\\r') !== -1) {\n throw parseErrorCode('HPE_LF_EXPECTED');\n }\n\n var match = headerExp.exec(line);\n var k = match && match[1];\n if (k) { // skip empty string (malformed header)\n headers.push(k);\n headers.push(match[2]);\n } else {\n var matchContinue = headerContinueExp.exec(line);\n if (matchContinue && headers.length) {\n if (headers[headers.length - 1]) {\n headers[headers.length - 1] += ' ';\n }\n headers[headers.length - 1] += matchContinue[1];\n }\n }\n};\n\nvar requestExp = /^([A-Z-]+) ([^ ]+) HTTP\\/(\\d)\\.(\\d)$/;\nHTTPParser.prototype.REQUEST_LINE = function () {\n var line = this.consumeLine();\n if (!line) {\n return;\n }\n var match = requestExp.exec(line);\n if (match === null) {\n throw parseErrorCode('HPE_INVALID_CONSTANT');\n }\n this.info.method = this._compatMode0_11 ? match[1] : methods.indexOf(match[1]);\n if (this.info.method === -1) {\n throw new Error('invalid request method');\n }\n this.info.url = match[2];\n this.info.versionMajor = +match[3];\n this.info.versionMinor = +match[4];\n this.body_bytes = 0;\n this.state = 'HEADER';\n};\n\nvar responseExp = /^HTTP\\/(\\d)\\.(\\d) (\\d{3}) ?(.*)$/;\nHTTPParser.prototype.RESPONSE_LINE = function () {\n var line = this.consumeLine();\n if (!line) {\n return;\n }\n var match = responseExp.exec(line);\n if (match === null) {\n throw parseErrorCode('HPE_INVALID_CONSTANT');\n }\n this.info.versionMajor = +match[1];\n this.info.versionMinor = +match[2];\n var statusCode = this.info.statusCode = +match[3];\n this.info.statusMessage = match[4];\n // Implied zero length.\n if ((statusCode / 100 | 0) === 1 || statusCode === 204 || statusCode === 304) {\n this.body_bytes = 0;\n }\n this.state = 'HEADER';\n};\n\nHTTPParser.prototype.shouldKeepAlive = function () {\n if (this.info.versionMajor > 0 && this.info.versionMinor > 0) {\n if (this.connection.indexOf('close') !== -1) {\n return false;\n }\n } else if (this.connection.indexOf('keep-alive') === -1) {\n return false;\n }\n if (this.body_bytes !== null || this.isChunked) { // || skipBody\n return true;\n }\n return false;\n};\n\nHTTPParser.prototype.HEADER = function () {\n var line = this.consumeLine();\n if (line === undefined) {\n return;\n }\n var info = this.info;\n if (line) {\n this.parseHeader(line, info.headers);\n } else {\n var headers = info.headers;\n var hasContentLength = false;\n var currentContentLengthValue;\n var hasUpgradeHeader = false;\n for (var i = 0; i < headers.length; i += 2) {\n switch (headers[i].toLowerCase()) {\n case 'transfer-encoding':\n this.isChunked = headers[i + 1].toLowerCase() === 'chunked';\n break;\n case 'content-length':\n currentContentLengthValue = +headers[i + 1];\n if (hasContentLength) {\n // Fix duplicate Content-Length header with same values.\n // Throw error only if values are different.\n // Known issues:\n // https://github.com/request/request/issues/2091#issuecomment-328715113\n // https://github.com/nodejs/node/issues/6517#issuecomment-216263771\n if (currentContentLengthValue !== this.body_bytes) {\n throw parseErrorCode('HPE_UNEXPECTED_CONTENT_LENGTH');\n }\n } else {\n hasContentLength = true;\n this.body_bytes = currentContentLengthValue;\n }\n break;\n case 'connection':\n this.connection += headers[i + 1].toLowerCase();\n break;\n case 'upgrade':\n hasUpgradeHeader = true;\n break;\n }\n }\n\n // if both isChunked and hasContentLength, isChunked wins\n // This is required so the body is parsed using the chunked method, and matches\n // Chrome's behavior. We could, maybe, ignore them both (would get chunked\n // encoding into the body), and/or disable shouldKeepAlive to be more\n // resilient.\n if (this.isChunked && hasContentLength) {\n hasContentLength = false;\n this.body_bytes = null;\n }\n\n // Logic from https://github.com/nodejs/http-parser/blob/921d5585515a153fa00e411cf144280c59b41f90/http_parser.c#L1727-L1737\n // \"For responses, \"Upgrade: foo\" and \"Connection: upgrade\" are\n // mandatory only when it is a 101 Switching Protocols response,\n // otherwise it is purely informational, to announce support.\n if (hasUpgradeHeader && this.connection.indexOf('upgrade') != -1) {\n info.upgrade = this.type === HTTPParser.REQUEST || info.statusCode === 101;\n } else {\n info.upgrade = info.method === method_connect;\n }\n\n if (this.isChunked && info.upgrade) {\n this.isChunked = false;\n }\n\n info.shouldKeepAlive = this.shouldKeepAlive();\n //problem which also exists in original node: we should know skipBody before calling onHeadersComplete\n var skipBody;\n if (compatMode0_12) {\n skipBody = this.userCall()(this[kOnHeadersComplete](info));\n } else {\n skipBody = this.userCall()(this[kOnHeadersComplete](info.versionMajor,\n info.versionMinor, info.headers, info.method, info.url, info.statusCode,\n info.statusMessage, info.upgrade, info.shouldKeepAlive));\n }\n if (skipBody === 2) {\n this.nextRequest();\n return true;\n } else if (this.isChunked && !skipBody) {\n this.state = 'BODY_CHUNKHEAD';\n } else if (skipBody || this.body_bytes === 0) {\n this.nextRequest();\n // For older versions of node (v6.x and older?), that return skipBody=1 or skipBody=true,\n // need this \"return true;\" if it's an upgrade request.\n return info.upgrade;\n } else if (this.body_bytes === null) {\n this.state = 'BODY_RAW';\n } else {\n this.state = 'BODY_SIZED';\n }\n }\n};\n\nHTTPParser.prototype.BODY_CHUNKHEAD = function () {\n var line = this.consumeLine();\n if (line === undefined) {\n return;\n }\n this.body_bytes = parseInt(line, 16);\n if (!this.body_bytes) {\n this.state = 'BODY_CHUNKTRAILERS';\n } else {\n this.state = 'BODY_CHUNK';\n }\n};\n\nHTTPParser.prototype.BODY_CHUNK = function () {\n var length = Math.min(this.end - this.offset, this.body_bytes);\n this.userCall()(this[kOnBody](this.chunk, this.offset, length));\n this.offset += length;\n this.body_bytes -= length;\n if (!this.body_bytes) {\n this.state = 'BODY_CHUNKEMPTYLINE';\n }\n};\n\nHTTPParser.prototype.BODY_CHUNKEMPTYLINE = function () {\n var line = this.consumeLine();\n if (line === undefined) {\n return;\n }\n assert.equal(line, '');\n this.state = 'BODY_CHUNKHEAD';\n};\n\nHTTPParser.prototype.BODY_CHUNKTRAILERS = function () {\n var line = this.consumeLine();\n if (line === undefined) {\n return;\n }\n if (line) {\n this.parseHeader(line, this.trailers);\n } else {\n if (this.trailers.length) {\n this.userCall()(this[kOnHeaders](this.trailers, ''));\n }\n this.nextRequest();\n }\n};\n\nHTTPParser.prototype.BODY_RAW = function () {\n var length = this.end - this.offset;\n this.userCall()(this[kOnBody](this.chunk, this.offset, length));\n this.offset = this.end;\n};\n\nHTTPParser.prototype.BODY_SIZED = function () {\n var length = Math.min(this.end - this.offset, this.body_bytes);\n this.userCall()(this[kOnBody](this.chunk, this.offset, length));\n this.offset += length;\n this.body_bytes -= length;\n if (!this.body_bytes) {\n this.nextRequest();\n }\n};\n\n// backward compat to node < 0.11.6\n['Headers', 'HeadersComplete', 'Body', 'MessageComplete'].forEach(function (name) {\n var k = HTTPParser['kOn' + name];\n Object.defineProperty(HTTPParser.prototype, 'on' + name, {\n get: function () {\n return this[k];\n },\n set: function (to) {\n // hack for backward compatibility\n this._compatMode0_11 = true;\n method_connect = 'CONNECT';\n return (this[k] = to);\n }\n });\n});\n\nfunction parseErrorCode(code) {\n var err = new Error('Parse Error');\n err.code = code;\n return err;\n}\n","module.exports = require(\"assert\");","'use strict';\n\nvar Parser = require('./parser'),\n Pipeline = require('./pipeline');\n\nvar Extensions = function() {\n this._rsv1 = this._rsv2 = this._rsv3 = null;\n\n this._byName = {};\n this._inOrder = [];\n this._sessions = [];\n this._index = {};\n};\n\nExtensions.MESSAGE_OPCODES = [1, 2];\n\nvar instance = {\n add: function(ext) {\n if (typeof ext.name !== 'string') throw new TypeError('extension.name must be a string');\n if (ext.type !== 'permessage') throw new TypeError('extension.type must be \"permessage\"');\n\n if (typeof ext.rsv1 !== 'boolean') throw new TypeError('extension.rsv1 must be true or false');\n if (typeof ext.rsv2 !== 'boolean') throw new TypeError('extension.rsv2 must be true or false');\n if (typeof ext.rsv3 !== 'boolean') throw new TypeError('extension.rsv3 must be true or false');\n\n if (this._byName.hasOwnProperty(ext.name))\n throw new TypeError('An extension with name \"' + ext.name + '\" is already registered');\n\n this._byName[ext.name] = ext;\n this._inOrder.push(ext);\n },\n\n generateOffer: function() {\n var sessions = [],\n offer = [],\n index = {};\n\n this._inOrder.forEach(function(ext) {\n var session = ext.createClientSession();\n if (!session) return;\n\n var record = [ext, session];\n sessions.push(record);\n index[ext.name] = record;\n\n var offers = session.generateOffer();\n offers = offers ? [].concat(offers) : [];\n\n offers.forEach(function(off) {\n offer.push(Parser.serializeParams(ext.name, off));\n }, this);\n }, this);\n\n this._sessions = sessions;\n this._index = index;\n\n return offer.length > 0 ? offer.join(', ') : null;\n },\n\n activate: function(header) {\n var responses = Parser.parseHeader(header),\n sessions = [];\n\n responses.eachOffer(function(name, params) {\n var record = this._index[name];\n\n if (!record)\n throw new Error('Server sent an extension response for unknown extension \"' + name + '\"');\n\n var ext = record[0],\n session = record[1],\n reserved = this._reserved(ext);\n\n if (reserved)\n throw new Error('Server sent two extension responses that use the RSV' +\n reserved[0] + ' bit: \"' +\n reserved[1] + '\" and \"' + ext.name + '\"');\n\n if (session.activate(params) !== true)\n throw new Error('Server sent unacceptable extension parameters: ' +\n Parser.serializeParams(name, params));\n\n this._reserve(ext);\n sessions.push(record);\n }, this);\n\n this._sessions = sessions;\n this._pipeline = new Pipeline(sessions);\n },\n\n generateResponse: function(header) {\n var sessions = [],\n response = [],\n offers = Parser.parseHeader(header);\n\n this._inOrder.forEach(function(ext) {\n var offer = offers.byName(ext.name);\n if (offer.length === 0 || this._reserved(ext)) return;\n\n var session = ext.createServerSession(offer);\n if (!session) return;\n\n this._reserve(ext);\n sessions.push([ext, session]);\n response.push(Parser.serializeParams(ext.name, session.generateResponse()));\n }, this);\n\n this._sessions = sessions;\n this._pipeline = new Pipeline(sessions);\n\n return response.length > 0 ? response.join(', ') : null;\n },\n\n validFrameRsv: function(frame) {\n var allowed = { rsv1: false, rsv2: false, rsv3: false },\n ext;\n\n if (Extensions.MESSAGE_OPCODES.indexOf(frame.opcode) >= 0) {\n for (var i = 0, n = this._sessions.length; i < n; i++) {\n ext = this._sessions[i][0];\n allowed.rsv1 = allowed.rsv1 || ext.rsv1;\n allowed.rsv2 = allowed.rsv2 || ext.rsv2;\n allowed.rsv3 = allowed.rsv3 || ext.rsv3;\n }\n }\n\n return (allowed.rsv1 || !frame.rsv1) &&\n (allowed.rsv2 || !frame.rsv2) &&\n (allowed.rsv3 || !frame.rsv3);\n },\n\n processIncomingMessage: function(message, callback, context) {\n this._pipeline.processIncomingMessage(message, callback, context);\n },\n\n processOutgoingMessage: function(message, callback, context) {\n this._pipeline.processOutgoingMessage(message, callback, context);\n },\n\n close: function(callback, context) {\n if (!this._pipeline) return callback.call(context);\n this._pipeline.close(callback, context);\n },\n\n _reserve: function(ext) {\n this._rsv1 = this._rsv1 || (ext.rsv1 && ext.name);\n this._rsv2 = this._rsv2 || (ext.rsv2 && ext.name);\n this._rsv3 = this._rsv3 || (ext.rsv3 && ext.name);\n },\n\n _reserved: function(ext) {\n if (this._rsv1 && ext.rsv1) return [1, this._rsv1];\n if (this._rsv2 && ext.rsv2) return [2, this._rsv2];\n if (this._rsv3 && ext.rsv3) return [3, this._rsv3];\n return false;\n }\n};\n\nfor (var key in instance)\n Extensions.prototype[key] = instance[key];\n\nmodule.exports = Extensions;\n","'use strict';\n\nvar TOKEN = /([!#\\$%&'\\*\\+\\-\\.\\^_`\\|~0-9A-Za-z]+)/,\n NOTOKEN = /([^!#\\$%&'\\*\\+\\-\\.\\^_`\\|~0-9A-Za-z])/g,\n QUOTED = /\"((?:\\\\[\\x00-\\x7f]|[^\\x00-\\x08\\x0a-\\x1f\\x7f\"\\\\])*)\"/,\n PARAM = new RegExp(TOKEN.source + '(?:=(?:' + TOKEN.source + '|' + QUOTED.source + '))?'),\n EXT = new RegExp(TOKEN.source + '(?: *; *' + PARAM.source + ')*', 'g'),\n EXT_LIST = new RegExp('^' + EXT.source + '(?: *, *' + EXT.source + ')*$'),\n NUMBER = /^-?(0|[1-9][0-9]*)(\\.[0-9]+)?$/;\n\nvar hasOwnProperty = Object.prototype.hasOwnProperty;\n\nvar Parser = {\n parseHeader: function(header) {\n var offers = new Offers();\n if (header === '' || header === undefined) return offers;\n\n if (!EXT_LIST.test(header))\n throw new SyntaxError('Invalid Sec-WebSocket-Extensions header: ' + header);\n\n var values = header.match(EXT);\n\n values.forEach(function(value) {\n var params = value.match(new RegExp(PARAM.source, 'g')),\n name = params.shift(),\n offer = {};\n\n params.forEach(function(param) {\n var args = param.match(PARAM), key = args[1], data;\n\n if (args[2] !== undefined) {\n data = args[2];\n } else if (args[3] !== undefined) {\n data = args[3].replace(/\\\\/g, '');\n } else {\n data = true;\n }\n if (NUMBER.test(data)) data = parseFloat(data);\n\n if (hasOwnProperty.call(offer, key)) {\n offer[key] = [].concat(offer[key]);\n offer[key].push(data);\n } else {\n offer[key] = data;\n }\n }, this);\n offers.push(name, offer);\n }, this);\n\n return offers;\n },\n\n serializeParams: function(name, params) {\n var values = [];\n\n var print = function(key, value) {\n if (value instanceof Array) {\n value.forEach(function(v) { print(key, v) });\n } else if (value === true) {\n values.push(key);\n } else if (typeof value === 'number') {\n values.push(key + '=' + value);\n } else if (NOTOKEN.test(value)) {\n values.push(key + '=\"' + value.replace(/\"/g, '\\\\\"') + '\"');\n } else {\n values.push(key + '=' + value);\n }\n };\n\n for (var key in params) print(key, params[key]);\n\n return [name].concat(values).join('; ');\n }\n};\n\nvar Offers = function() {\n this._byName = {};\n this._inOrder = [];\n};\n\nOffers.prototype.push = function(name, params) {\n if (!hasOwnProperty.call(this._byName, name))\n this._byName[name] = [];\n\n this._byName[name].push(params);\n this._inOrder.push({ name: name, params: params });\n};\n\nOffers.prototype.eachOffer = function(callback, context) {\n var list = this._inOrder;\n for (var i = 0, n = list.length; i < n; i++)\n callback.call(context, list[i].name, list[i].params);\n};\n\nOffers.prototype.byName = function(name) {\n return this._byName[name] || [];\n};\n\nOffers.prototype.toArray = function() {\n return this._inOrder.slice();\n};\n\nmodule.exports = Parser;\n","'use strict';\n\nvar Cell = require('./cell'),\n Pledge = require('./pledge');\n\nvar Pipeline = function(sessions) {\n this._cells = sessions.map(function(session) { return new Cell(session) });\n this._stopped = { incoming: false, outgoing: false };\n};\n\nPipeline.prototype.processIncomingMessage = function(message, callback, context) {\n if (this._stopped.incoming) return;\n this._loop('incoming', this._cells.length - 1, -1, -1, message, callback, context);\n};\n\nPipeline.prototype.processOutgoingMessage = function(message, callback, context) {\n if (this._stopped.outgoing) return;\n this._loop('outgoing', 0, this._cells.length, 1, message, callback, context);\n};\n\nPipeline.prototype.close = function(callback, context) {\n this._stopped = { incoming: true, outgoing: true };\n\n var closed = this._cells.map(function(a) { return a.close() });\n if (callback)\n Pledge.all(closed).then(function() { callback.call(context) });\n};\n\nPipeline.prototype._loop = function(direction, start, end, step, message, callback, context) {\n var cells = this._cells,\n n = cells.length,\n self = this;\n\n while (n--) cells[n].pending(direction);\n\n var pipe = function(index, error, msg) {\n if (index === end) return callback.call(context, error, msg);\n\n cells[index][direction](error, msg, function(err, m) {\n if (err) self._stopped[direction] = true;\n pipe(index + step, err, m);\n });\n };\n pipe(start, null, message);\n};\n\nmodule.exports = Pipeline;\n","'use strict';\n\nvar Functor = require('./functor'),\n Pledge = require('./pledge');\n\nvar Cell = function(tuple) {\n this._ext = tuple[0];\n this._session = tuple[1];\n\n this._functors = {\n incoming: new Functor(this._session, 'processIncomingMessage'),\n outgoing: new Functor(this._session, 'processOutgoingMessage')\n };\n};\n\nCell.prototype.pending = function(direction) {\n var functor = this._functors[direction];\n if (!functor._stopped) functor.pending += 1;\n};\n\nCell.prototype.incoming = function(error, message, callback, context) {\n this._exec('incoming', error, message, callback, context);\n};\n\nCell.prototype.outgoing = function(error, message, callback, context) {\n this._exec('outgoing', error, message, callback, context);\n};\n\nCell.prototype.close = function() {\n this._closed = this._closed || new Pledge();\n this._doClose();\n return this._closed;\n};\n\nCell.prototype._exec = function(direction, error, message, callback, context) {\n this._functors[direction].call(error, message, function(err, msg) {\n if (err) err.message = this._ext.name + ': ' + err.message;\n callback.call(context, err, msg);\n this._doClose();\n }, this);\n};\n\nCell.prototype._doClose = function() {\n var fin = this._functors.incoming,\n fout = this._functors.outgoing;\n\n if (!this._closed || fin.pending + fout.pending !== 0) return;\n if (this._session) this._session.close();\n this._session = null;\n this._closed.done();\n};\n\nmodule.exports = Cell;\n","'use strict';\n\nvar RingBuffer = require('./ring_buffer');\n\nvar Functor = function(session, method) {\n this._session = session;\n this._method = method;\n this._queue = new RingBuffer(Functor.QUEUE_SIZE);\n this._stopped = false;\n this.pending = 0;\n};\n\nFunctor.QUEUE_SIZE = 8;\n\nFunctor.prototype.call = function(error, message, callback, context) {\n if (this._stopped) return;\n\n var record = { error: error, message: message, callback: callback, context: context, done: false },\n called = false,\n self = this;\n\n this._queue.push(record);\n\n if (record.error) {\n record.done = true;\n this._stop();\n return this._flushQueue();\n }\n\n var handler = function(err, msg) {\n if (!(called ^ (called = true))) return;\n\n if (err) {\n self._stop();\n record.error = err;\n record.message = null;\n } else {\n record.message = msg;\n }\n\n record.done = true;\n self._flushQueue();\n };\n\n try {\n this._session[this._method](message, handler);\n } catch (err) {\n handler(err);\n }\n};\n\nFunctor.prototype._stop = function() {\n this.pending = this._queue.length;\n this._stopped = true;\n};\n\nFunctor.prototype._flushQueue = function() {\n var queue = this._queue, record;\n\n while (queue.length > 0 && queue.peek().done) {\n record = queue.shift();\n if (record.error) {\n this.pending = 0;\n queue.clear();\n } else {\n this.pending -= 1;\n }\n record.callback.call(record.context, record.error, record.message);\n }\n};\n\nmodule.exports = Functor;\n","'use strict';\n\nvar Frame = function() {};\n\nvar instance = {\n final: false,\n rsv1: false,\n rsv2: false,\n rsv3: false,\n opcode: null,\n masked: false,\n maskingKey: null,\n lengthBytes: 1,\n length: 0,\n payload: null\n};\n\nfor (var key in instance)\n Frame.prototype[key] = instance[key];\n\nmodule.exports = Frame;\n","'use strict';\n\nvar Buffer = require('safe-buffer').Buffer;\n\nvar Message = function() {\n this.rsv1 = false;\n this.rsv2 = false;\n this.rsv3 = false;\n this.opcode = null;\n this.length = 0;\n this._chunks = [];\n};\n\nvar instance = {\n read: function() {\n return this.data = this.data || Buffer.concat(this._chunks, this.length);\n },\n\n pushFrame: function(frame) {\n this.rsv1 = this.rsv1 || frame.rsv1;\n this.rsv2 = this.rsv2 || frame.rsv2;\n this.rsv3 = this.rsv3 || frame.rsv3;\n\n if (this.opcode === null) this.opcode = frame.opcode;\n\n this._chunks.push(frame.payload);\n this.length += frame.length;\n }\n};\n\nfor (var key in instance)\n Message.prototype[key] = instance[key];\n\nmodule.exports = Message;\n","'use strict';\n\nvar Buffer = require('safe-buffer').Buffer,\n Stream = require('stream').Stream,\n url = require('url'),\n util = require('util'),\n Base = require('./base'),\n Headers = require('./headers'),\n HttpParser = require('../http_parser');\n\nvar PORTS = { 'ws:': 80, 'wss:': 443 };\n\nvar Proxy = function(client, origin, options) {\n this._client = client;\n this._http = new HttpParser('response');\n this._origin = (typeof client.url === 'object') ? client.url : url.parse(client.url);\n this._url = (typeof origin === 'object') ? origin : url.parse(origin);\n this._options = options || {};\n this._state = 0;\n\n this.readable = this.writable = true;\n this._paused = false;\n\n this._headers = new Headers();\n this._headers.set('Host', this._origin.host);\n this._headers.set('Connection', 'keep-alive');\n this._headers.set('Proxy-Connection', 'keep-alive');\n\n var auth = this._url.auth && Buffer.from(this._url.auth, 'utf8').toString('base64');\n if (auth) this._headers.set('Proxy-Authorization', 'Basic ' + auth);\n};\nutil.inherits(Proxy, Stream);\n\nvar instance = {\n setHeader: function(name, value) {\n if (this._state !== 0) return false;\n this._headers.set(name, value);\n return true;\n },\n\n start: function() {\n if (this._state !== 0) return false;\n this._state = 1;\n\n var origin = this._origin,\n port = origin.port || PORTS[origin.protocol],\n start = 'CONNECT ' + origin.hostname + ':' + port + ' HTTP/1.1';\n\n var headers = [start, this._headers.toString(), ''];\n\n this.emit('data', Buffer.from(headers.join('\\r\\n'), 'utf8'));\n return true;\n },\n\n pause: function() {\n this._paused = true;\n },\n\n resume: function() {\n this._paused = false;\n this.emit('drain');\n },\n\n write: function(chunk) {\n if (!this.writable) return false;\n\n this._http.parse(chunk);\n if (!this._http.isComplete()) return !this._paused;\n\n this.statusCode = this._http.statusCode;\n this.headers = this._http.headers;\n\n if (this.statusCode === 200) {\n this.emit('connect', new Base.ConnectEvent());\n } else {\n var message = \"Can't establish a connection to the server at \" + this._origin.href;\n this.emit('error', new Error(message));\n }\n this.end();\n return !this._paused;\n },\n\n end: function(chunk) {\n if (!this.writable) return;\n if (chunk !== undefined) this.write(chunk);\n this.readable = this.writable = false;\n this.emit('close');\n this.emit('end');\n },\n\n destroy: function() {\n this.end();\n }\n};\n\nfor (var key in instance)\n Proxy.prototype[key] = instance[key];\n\nmodule.exports = Proxy;\n","'use strict';\n\nvar util = require('util'),\n HttpParser = require('../http_parser'),\n Base = require('./base'),\n Draft75 = require('./draft75'),\n Draft76 = require('./draft76'),\n Hybi = require('./hybi');\n\nvar Server = function(options) {\n Base.call(this, null, null, options);\n this._http = new HttpParser('request');\n};\nutil.inherits(Server, Base);\n\nvar instance = {\n EVENTS: ['open', 'message', 'error', 'close', 'ping', 'pong'],\n\n _bindEventListeners: function() {\n this.messages.on('error', function() {});\n this.on('error', function() {});\n },\n\n parse: function(chunk) {\n if (this._delegate) return this._delegate.parse(chunk);\n\n this._http.parse(chunk);\n if (!this._http.isComplete()) return;\n\n this.method = this._http.method;\n this.url = this._http.url;\n this.headers = this._http.headers;\n this.body = this._http.body;\n\n var self = this;\n this._delegate = Server.http(this, this._options);\n this._delegate.messages = this.messages;\n this._delegate.io = this.io;\n this._open();\n\n this.EVENTS.forEach(function(event) {\n this._delegate.on(event, function(e) { self.emit(event, e) });\n }, this);\n\n this.protocol = this._delegate.protocol;\n this.version = this._delegate.version;\n\n this.parse(this._http.body);\n this.emit('connect', new Base.ConnectEvent());\n },\n\n _open: function() {\n this.__queue.forEach(function(msg) {\n this._delegate[msg[0]].apply(this._delegate, msg[1]);\n }, this);\n this.__queue = [];\n }\n};\n\n['addExtension', 'setHeader', 'start', 'frame', 'text', 'binary', 'ping', 'close'].forEach(function(method) {\n instance[method] = function() {\n if (this._delegate) {\n return this._delegate[method].apply(this._delegate, arguments);\n } else {\n this.__queue.push([method, arguments]);\n return true;\n }\n };\n});\n\nfor (var key in instance)\n Server.prototype[key] = instance[key];\n\nServer.isSecureRequest = function(request) {\n if (request.connection && request.connection.authorized !== undefined) return true;\n if (request.socket && request.socket.secure) return true;\n\n var headers = request.headers;\n if (!headers) return false;\n if (headers['https'] === 'on') return true;\n if (headers['x-forwarded-ssl'] === 'on') return true;\n if (headers['x-forwarded-scheme'] === 'https') return true;\n if (headers['x-forwarded-proto'] === 'https') return true;\n\n return false;\n};\n\nServer.determineUrl = function(request) {\n var scheme = this.isSecureRequest(request) ? 'wss:' : 'ws:';\n return scheme + '//' + request.headers.host + request.url;\n};\n\nServer.http = function(request, options) {\n options = options || {};\n if (options.requireMasking === undefined) options.requireMasking = true;\n\n var headers = request.headers,\n version = headers['sec-websocket-version'],\n key = headers['sec-websocket-key'],\n key1 = headers['sec-websocket-key1'],\n key2 = headers['sec-websocket-key2'],\n url = this.determineUrl(request);\n\n if (version || key)\n return new Hybi(request, url, options);\n else if (key1 || key2)\n return new Draft76(request, url, options);\n else\n return new Draft75(request, url, options);\n};\n\nmodule.exports = Server;\n","'use strict';\n\nvar Buffer = require('safe-buffer').Buffer,\n Base = require('./base'),\n Draft75 = require('./draft75'),\n crypto = require('crypto'),\n util = require('util');\n\n\nvar numberFromKey = function(key) {\n return parseInt((key.match(/[0-9]/g) || []).join(''), 10);\n};\n\nvar spacesInKey = function(key) {\n return (key.match(/ /g) || []).length;\n};\n\n\nvar Draft76 = function(request, url, options) {\n Draft75.apply(this, arguments);\n this._stage = -1;\n this._body = [];\n this.version = 'hixie-76';\n\n this._headers.clear();\n\n this._headers.set('Upgrade', 'WebSocket');\n this._headers.set('Connection', 'Upgrade');\n this._headers.set('Sec-WebSocket-Origin', this._request.headers.origin);\n this._headers.set('Sec-WebSocket-Location', this.url);\n};\nutil.inherits(Draft76, Draft75);\n\nvar instance = {\n BODY_SIZE: 8,\n\n start: function() {\n if (!Draft75.prototype.start.call(this)) return false;\n this._started = true;\n this._sendHandshakeBody();\n return true;\n },\n\n close: function() {\n if (this.readyState === 3) return false;\n if (this.readyState === 1) this._write(Buffer.from([0xFF, 0x00]));\n this.readyState = 3;\n this.emit('close', new Base.CloseEvent(null, null));\n return true;\n },\n\n _handshakeResponse: function() {\n var headers = this._request.headers,\n key1 = headers['sec-websocket-key1'],\n key2 = headers['sec-websocket-key2'];\n\n if (!key1) throw new Error('Missing required header: Sec-WebSocket-Key1');\n if (!key2) throw new Error('Missing required header: Sec-WebSocket-Key2');\n\n var number1 = numberFromKey(key1),\n spaces1 = spacesInKey(key1),\n\n number2 = numberFromKey(key2),\n spaces2 = spacesInKey(key2);\n\n if (number1 % spaces1 !== 0 || number2 % spaces2 !== 0)\n throw new Error('Client sent invalid Sec-WebSocket-Key headers');\n\n this._keyValues = [number1 / spaces1, number2 / spaces2];\n\n var start = 'HTTP/1.1 101 WebSocket Protocol Handshake',\n headers = [start, this._headers.toString(), ''];\n\n return Buffer.from(headers.join('\\r\\n'), 'binary');\n },\n\n _handshakeSignature: function() {\n if (this._body.length < this.BODY_SIZE) return null;\n\n var md5 = crypto.createHash('md5'),\n buffer = Buffer.allocUnsafe(8 + this.BODY_SIZE);\n\n buffer.writeUInt32BE(this._keyValues[0], 0);\n buffer.writeUInt32BE(this._keyValues[1], 4);\n Buffer.from(this._body).copy(buffer, 8, 0, this.BODY_SIZE);\n\n md5.update(buffer);\n return Buffer.from(md5.digest('binary'), 'binary');\n },\n\n _sendHandshakeBody: function() {\n if (!this._started) return;\n var signature = this._handshakeSignature();\n if (!signature) return;\n\n this._write(signature);\n this._stage = 0;\n this._open();\n\n if (this._body.length > this.BODY_SIZE)\n this.parse(this._body.slice(this.BODY_SIZE));\n },\n\n _parseLeadingByte: function(octet) {\n if (octet !== 0xFF)\n return Draft75.prototype._parseLeadingByte.call(this, octet);\n\n this._closing = true;\n this._length = 0;\n this._stage = 1;\n }\n};\n\nfor (var key in instance)\n Draft76.prototype[key] = instance[key];\n\nmodule.exports = Draft76;\n","'use strict';\n\nvar util = require('util'),\n net = require('net'),\n tls = require('tls'),\n url = require('url'),\n driver = require('websocket-driver'),\n API = require('./api'),\n Event = require('./api/event');\n\nvar DEFAULT_PORTS = {'http:': 80, 'https:': 443, 'ws:':80, 'wss:': 443},\n SECURE_PROTOCOLS = ['https:', 'wss:'];\n\nvar Client = function(_url, protocols, options) {\n options = options || {};\n\n this.url = _url;\n this._driver = driver.client(this.url, {maxLength: options.maxLength, protocols: protocols});\n\n ['open', 'error'].forEach(function(event) {\n this._driver.on(event, function() {\n self.headers = self._driver.headers;\n self.statusCode = self._driver.statusCode;\n });\n }, this);\n\n var proxy = options.proxy || {},\n endpoint = url.parse(proxy.origin || this.url),\n port = endpoint.port || DEFAULT_PORTS[endpoint.protocol],\n secure = SECURE_PROTOCOLS.indexOf(endpoint.protocol) >= 0,\n onConnect = function() { self._onConnect() },\n netOptions = options.net || {},\n originTLS = options.tls || {},\n socketTLS = proxy.origin ? (proxy.tls || {}) : originTLS,\n self = this;\n\n netOptions.host = socketTLS.host = endpoint.hostname;\n netOptions.port = socketTLS.port = port;\n\n originTLS.ca = originTLS.ca || options.ca;\n socketTLS.servername = socketTLS.servername || endpoint.hostname;\n\n this._stream = secure\n ? tls.connect(socketTLS, onConnect)\n : net.connect(netOptions, onConnect);\n\n if (proxy.origin) this._configureProxy(proxy, originTLS);\n\n API.call(this, options);\n};\nutil.inherits(Client, API);\n\nClient.prototype._onConnect = function() {\n var worker = this._proxy || this._driver;\n worker.start();\n};\n\nClient.prototype._configureProxy = function(proxy, originTLS) {\n var uri = url.parse(this.url),\n secure = SECURE_PROTOCOLS.indexOf(uri.protocol) >= 0,\n self = this,\n name;\n\n this._proxy = this._driver.proxy(proxy.origin);\n\n if (proxy.headers) {\n for (name in proxy.headers) this._proxy.setHeader(name, proxy.headers[name]);\n }\n\n this._proxy.pipe(this._stream, {end: false});\n this._stream.pipe(this._proxy);\n\n this._proxy.on('connect', function() {\n if (secure) {\n var options = {socket: self._stream, servername: uri.hostname};\n for (name in originTLS) options[name] = originTLS[name];\n self._stream = tls.connect(options);\n self._configureStream();\n }\n self._driver.io.pipe(self._stream);\n self._stream.pipe(self._driver.io);\n self._driver.start();\n });\n\n this._proxy.on('error', function(error) {\n self._driver.emit('error', error);\n });\n};\n\nmodule.exports = Client;\n","module.exports = require(\"net\");","module.exports = require(\"tls\");","'use strict';\n\nvar Stream = require('stream').Stream,\n util = require('util'),\n driver = require('websocket-driver'),\n Headers = require('websocket-driver/lib/websocket/driver/headers'),\n API = require('./websocket/api'),\n EventTarget = require('./websocket/api/event_target'),\n Event = require('./websocket/api/event');\n\nvar EventSource = function(request, response, options) {\n this.writable = true;\n options = options || {};\n\n this._stream = response.socket;\n this._ping = options.ping || this.DEFAULT_PING;\n this._retry = options.retry || this.DEFAULT_RETRY;\n\n var scheme = driver.isSecureRequest(request) ? 'https:' : 'http:';\n this.url = scheme + '//' + request.headers.host + request.url;\n this.lastEventId = request.headers['last-event-id'] || '';\n this.readyState = API.CONNECTING;\n\n var headers = new Headers(),\n self = this;\n\n if (options.headers) {\n for (var key in options.headers) headers.set(key, options.headers[key]);\n }\n\n if (!this._stream || !this._stream.writable) return;\n process.nextTick(function() { self._open() });\n\n this._stream.setTimeout(0);\n this._stream.setNoDelay(true);\n\n var handshake = 'HTTP/1.1 200 OK\\r\\n' +\n 'Content-Type: text/event-stream\\r\\n' +\n 'Cache-Control: no-cache, no-store\\r\\n' +\n 'Connection: close\\r\\n' +\n headers.toString() +\n '\\r\\n' +\n 'retry: ' + Math.floor(this._retry * 1000) + '\\r\\n\\r\\n';\n\n this._write(handshake);\n\n this._stream.on('drain', function() { self.emit('drain') });\n\n if (this._ping)\n this._pingTimer = setInterval(function() { self.ping() }, this._ping * 1000);\n\n ['error', 'end'].forEach(function(event) {\n self._stream.on(event, function() { self.close() });\n });\n};\nutil.inherits(EventSource, Stream);\n\nEventSource.isEventSource = function(request) {\n if (request.method !== 'GET') return false;\n var accept = (request.headers.accept || '').split(/\\s*,\\s*/);\n return accept.indexOf('text/event-stream') >= 0;\n};\n\nvar instance = {\n DEFAULT_PING: 10,\n DEFAULT_RETRY: 5,\n\n _write: function(chunk) {\n if (!this.writable) return false;\n try {\n return this._stream.write(chunk, 'utf8');\n } catch (e) {\n return false;\n }\n },\n\n _open: function() {\n if (this.readyState !== API.CONNECTING) return;\n\n this.readyState = API.OPEN;\n\n var event = new Event('open');\n event.initEvent('open', false, false);\n this.dispatchEvent(event);\n },\n\n write: function(message) {\n return this.send(message);\n },\n\n end: function(message) {\n if (message !== undefined) this.write(message);\n this.close();\n },\n\n send: function(message, options) {\n if (this.readyState > API.OPEN) return false;\n\n message = String(message).replace(/(\\r\\n|\\r|\\n)/g, '$1data: ');\n options = options || {};\n\n var frame = '';\n if (options.event) frame += 'event: ' + options.event + '\\r\\n';\n if (options.id) frame += 'id: ' + options.id + '\\r\\n';\n frame += 'data: ' + message + '\\r\\n\\r\\n';\n\n return this._write(frame);\n },\n\n ping: function() {\n return this._write(':\\r\\n\\r\\n');\n },\n\n close: function() {\n if (this.readyState > API.OPEN) return false;\n\n this.readyState = API.CLOSED;\n this.writable = false;\n if (this._pingTimer) clearInterval(this._pingTimer);\n if (this._stream) this._stream.end();\n\n var event = new Event('close');\n event.initEvent('close', false, false);\n this.dispatchEvent(event);\n\n return true;\n }\n};\n\nfor (var method in instance) EventSource.prototype[method] = instance[method];\nfor (var key in EventTarget) EventSource.prototype[key] = EventTarget[key];\n\nmodule.exports = EventSource;\n","module.exports = require(\"child_process\");","module.exports = require(\"fs\");","module.exports = require(\"http\");","module.exports = require(\"https\");","export default function encode(s: any): string {\n return btoa(utob(s));\n}\n\nvar fromCharCode = String.fromCharCode;\n\nvar b64chars =\n 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';\nvar b64tab = {};\n\nfor (var i = 0, l = b64chars.length; i < l; i++) {\n b64tab[b64chars.charAt(i)] = i;\n}\n\nvar cb_utob = function(c) {\n var cc = c.charCodeAt(0);\n return cc < 0x80\n ? c\n : cc < 0x800\n ? fromCharCode(0xc0 | (cc >>> 6)) + fromCharCode(0x80 | (cc & 0x3f))\n : fromCharCode(0xe0 | ((cc >>> 12) & 0x0f)) +\n fromCharCode(0x80 | ((cc >>> 6) & 0x3f)) +\n fromCharCode(0x80 | (cc & 0x3f));\n};\n\nvar utob = function(u) {\n return u.replace(/[^\\x00-\\x7F]/g, cb_utob);\n};\n\nvar cb_encode = function(ccc) {\n var padlen = [0, 2, 1][ccc.length % 3];\n var ord =\n (ccc.charCodeAt(0) << 16) |\n ((ccc.length > 1 ? ccc.charCodeAt(1) : 0) << 8) |\n (ccc.length > 2 ? ccc.charCodeAt(2) : 0);\n var chars = [\n b64chars.charAt(ord >>> 18),\n b64chars.charAt((ord >>> 12) & 63),\n padlen >= 2 ? '=' : b64chars.charAt((ord >>> 6) & 63),\n padlen >= 1 ? '=' : b64chars.charAt(ord & 63)\n ];\n return chars.join('');\n};\n\nvar btoa =\n global.btoa ||\n function(b) {\n return b.replace(/[\\s\\S]{1,3}/g, cb_encode);\n };\n","import TimedCallback from './timed_callback';\nimport { Delay, Scheduler, Canceller } from './scheduling';\n\nabstract class Timer {\n protected clear: Canceller;\n protected timer: number | void;\n\n constructor(\n set: Scheduler,\n clear: Canceller,\n delay: Delay,\n callback: TimedCallback\n ) {\n this.clear = clear;\n this.timer = set(() => {\n if (this.timer) {\n this.timer = callback(this.timer);\n }\n }, delay);\n }\n\n /** Returns whether the timer is still running.\n *\n * @return {Boolean}\n */\n isRunning(): boolean {\n return this.timer !== null;\n }\n\n /** Aborts a timer when it's running. */\n ensureAborted() {\n if (this.timer) {\n this.clear(this.timer);\n this.timer = null;\n }\n }\n}\n\nexport default Timer;\n","import Timer from './abstract_timer';\nimport TimedCallback from './timed_callback';\nimport { Delay } from './scheduling';\n\n// We need to bind clear functions this way to avoid exceptions on IE8\nfunction clearTimeout(timer) {\n global.clearTimeout(timer);\n}\nfunction clearInterval(timer) {\n global.clearInterval(timer);\n}\n\n/** Cross-browser compatible one-off timer abstraction.\n *\n * @param {Number} delay\n * @param {Function} callback\n */\nexport class OneOffTimer extends Timer {\n constructor(delay: Delay, callback: TimedCallback) {\n super(setTimeout, clearTimeout, delay, function(timer) {\n callback();\n return null;\n });\n }\n}\n\n/** Cross-browser compatible periodic timer abstraction.\n *\n * @param {Number} delay\n * @param {Function} callback\n */\nexport class PeriodicTimer extends Timer {\n constructor(delay: Delay, callback: TimedCallback) {\n super(setInterval, clearInterval, delay, function(timer) {\n callback();\n return timer;\n });\n }\n}\n","import * as Collections from './utils/collections';\nimport TimedCallback from './utils/timers/timed_callback';\nimport { OneOffTimer, PeriodicTimer } from './utils/timers';\n\nvar Util = {\n now(): number {\n if (Date.now) {\n return Date.now();\n } else {\n return new Date().valueOf();\n }\n },\n\n defer(callback: TimedCallback): OneOffTimer {\n return new OneOffTimer(0, callback);\n },\n\n /** Builds a function that will proxy a method call to its first argument.\n *\n * Allows partial application of arguments, so additional arguments are\n * prepended to the argument list.\n *\n * @param {String} name method name\n * @return {Function} proxy function\n */\n method(name: string, ...args: any[]): Function {\n var boundArguments = Array.prototype.slice.call(arguments, 1);\n return function(object) {\n return object[name].apply(object, boundArguments.concat(arguments));\n };\n }\n};\n\nexport default Util;\n","import base64encode from '../base64';\nimport Util from '../util';\n\n/** Merges multiple objects into the target argument.\n *\n * For properties that are plain Objects, performs a deep-merge. For the\n * rest it just copies the value of the property.\n *\n * To extend prototypes use it as following:\n * Pusher.Util.extend(Target.prototype, Base.prototype)\n *\n * You can also use it to merge objects without altering them:\n * Pusher.Util.extend({}, object1, object2)\n *\n * @param {Object} target\n * @return {Object} the target argument\n */\nexport function extend(target: any, ...sources: any[]): T {\n for (var i = 0; i < sources.length; i++) {\n var extensions = sources[i];\n for (var property in extensions) {\n if (\n extensions[property] &&\n extensions[property].constructor &&\n extensions[property].constructor === Object\n ) {\n target[property] = extend(target[property] || {}, extensions[property]);\n } else {\n target[property] = extensions[property];\n }\n }\n }\n return target;\n}\n\nexport function stringify(): string {\n var m = ['Pusher'];\n for (var i = 0; i < arguments.length; i++) {\n if (typeof arguments[i] === 'string') {\n m.push(arguments[i]);\n } else {\n m.push(safeJSONStringify(arguments[i]));\n }\n }\n return m.join(' : ');\n}\n\nexport function arrayIndexOf(array: any[], item: any): number {\n // MSIE doesn't have array.indexOf\n var nativeIndexOf = Array.prototype.indexOf;\n if (array === null) {\n return -1;\n }\n if (nativeIndexOf && array.indexOf === nativeIndexOf) {\n return array.indexOf(item);\n }\n for (var i = 0, l = array.length; i < l; i++) {\n if (array[i] === item) {\n return i;\n }\n }\n return -1;\n}\n\n/** Applies a function f to all properties of an object.\n *\n * Function f gets 3 arguments passed:\n * - element from the object\n * - key of the element\n * - reference to the object\n *\n * @param {Object} object\n * @param {Function} f\n */\nexport function objectApply(object: any, f: Function) {\n for (var key in object) {\n if (Object.prototype.hasOwnProperty.call(object, key)) {\n f(object[key], key, object);\n }\n }\n}\n\n/** Return a list of objects own proerty keys\n *\n * @param {Object} object\n * @returns {Array}\n */\nexport function keys(object: any): string[] {\n var keys = [];\n objectApply(object, function(_, key) {\n keys.push(key);\n });\n return keys;\n}\n\n/** Return a list of object's own property values\n *\n * @param {Object} object\n * @returns {Array}\n */\nexport function values(object: any): any[] {\n var values = [];\n objectApply(object, function(value) {\n values.push(value);\n });\n return values;\n}\n\n/** Applies a function f to all elements of an array.\n *\n * Function f gets 3 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function apply(array: any[], f: Function, context?: any) {\n for (var i = 0; i < array.length; i++) {\n f.call(context || global, array[i], i, array);\n }\n}\n\n/** Maps all elements of the array and returns the result.\n *\n * Function f gets 4 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n * - reference to the destination array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function map(array: any[], f: Function): any[] {\n var result = [];\n for (var i = 0; i < array.length; i++) {\n result.push(f(array[i], i, array, result));\n }\n return result;\n}\n\n/** Maps all elements of the object and returns the result.\n *\n * Function f gets 4 arguments passed:\n * - element from the object\n * - key of the element\n * - reference to the source object\n * - reference to the destination object\n *\n * @param {Object} object\n * @param {Function} f\n */\nexport function mapObject(object: any, f: Function): any {\n var result = {};\n objectApply(object, function(value, key) {\n result[key] = f(value);\n });\n return result;\n}\n\n/** Filters elements of the array using a test function.\n *\n * Function test gets 4 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n * - reference to the destination array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function filter(array: any[], test: Function): any[] {\n test =\n test ||\n function(value) {\n return !!value;\n };\n\n var result = [];\n for (var i = 0; i < array.length; i++) {\n if (test(array[i], i, array, result)) {\n result.push(array[i]);\n }\n }\n return result;\n}\n\n/** Filters properties of the object using a test function.\n *\n * Function test gets 4 arguments passed:\n * - element from the object\n * - key of the element\n * - reference to the source object\n * - reference to the destination object\n *\n * @param {Object} object\n * @param {Function} f\n */\nexport function filterObject(object: Object, test: Function) {\n var result = {};\n objectApply(object, function(value, key) {\n if ((test && test(value, key, object, result)) || Boolean(value)) {\n result[key] = value;\n }\n });\n return result;\n}\n\n/** Flattens an object into a two-dimensional array.\n *\n * @param {Object} object\n * @return {Array} resulting array of [key, value] pairs\n */\nexport function flatten(object: Object): any[] {\n var result = [];\n objectApply(object, function(value, key) {\n result.push([key, value]);\n });\n return result;\n}\n\n/** Checks whether any element of the array passes the test.\n *\n * Function test gets 3 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function any(array: any[], test: Function): boolean {\n for (var i = 0; i < array.length; i++) {\n if (test(array[i], i, array)) {\n return true;\n }\n }\n return false;\n}\n\n/** Checks whether all elements of the array pass the test.\n *\n * Function test gets 3 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function all(array: any[], test: Function): boolean {\n for (var i = 0; i < array.length; i++) {\n if (!test(array[i], i, array)) {\n return false;\n }\n }\n return true;\n}\n\nexport function encodeParamsObject(data): string {\n return mapObject(data, function(value) {\n if (typeof value === 'object') {\n value = safeJSONStringify(value);\n }\n return encodeURIComponent(base64encode(value.toString()));\n });\n}\n\nexport function buildQueryString(data: any): string {\n var params = filterObject(data, function(value) {\n return value !== undefined;\n });\n\n var query = map(\n flatten(encodeParamsObject(params)),\n Util.method('join', '=')\n ).join('&');\n\n return query;\n}\n\n/**\n * See https://github.com/douglascrockford/JSON-js/blob/master/cycle.js\n *\n * Remove circular references from an object. Required for JSON.stringify in\n * React Native, which tends to blow up a lot.\n *\n * @param {any} object\n * @return {any} Decycled object\n */\nexport function decycleObject(object: any): any {\n var objects = [],\n paths = [];\n\n return (function derez(value, path) {\n var i, name, nu;\n\n switch (typeof value) {\n case 'object':\n if (!value) {\n return null;\n }\n for (i = 0; i < objects.length; i += 1) {\n if (objects[i] === value) {\n return { $ref: paths[i] };\n }\n }\n\n objects.push(value);\n paths.push(path);\n\n if (Object.prototype.toString.apply(value) === '[object Array]') {\n nu = [];\n for (i = 0; i < value.length; i += 1) {\n nu[i] = derez(value[i], path + '[' + i + ']');\n }\n } else {\n nu = {};\n for (name in value) {\n if (Object.prototype.hasOwnProperty.call(value, name)) {\n nu[name] = derez(\n value[name],\n path + '[' + JSON.stringify(name) + ']'\n );\n }\n }\n }\n return nu;\n case 'number':\n case 'string':\n case 'boolean':\n return value;\n }\n })(object, '$');\n}\n\n/**\n * Provides a cross-browser and cross-platform way to safely stringify objects\n * into JSON. This is particularly necessary for ReactNative, where circular JSON\n * structures throw an exception.\n *\n * @param {any} source The object to stringify\n * @return {string} The serialized output.\n */\nexport function safeJSONStringify(source: any): string {\n try {\n return JSON.stringify(source);\n } catch (e) {\n return JSON.stringify(decycleObject(source));\n }\n}\n","import {\n ChannelAuthorizationOptions,\n UserAuthenticationOptions\n} from './auth/options';\nimport { AuthTransport } from './config';\n\nexport interface DefaultConfig {\n VERSION: string;\n PROTOCOL: number;\n wsPort: number;\n wssPort: number;\n wsPath: string;\n httpHost: string;\n httpPort: number;\n httpsPort: number;\n httpPath: string;\n stats_host: string;\n authEndpoint: string;\n authTransport: AuthTransport;\n activityTimeout: number;\n pongTimeout: number;\n unavailableTimeout: number;\n userAuthentication: UserAuthenticationOptions;\n channelAuthorization: ChannelAuthorizationOptions;\n\n cdn_http?: string;\n cdn_https?: string;\n dependency_suffix?: string;\n}\n\nvar Defaults: DefaultConfig = {\n VERSION: VERSION,\n PROTOCOL: 7,\n\n wsPort: 80,\n wssPort: 443,\n wsPath: '',\n // DEPRECATED: SockJS fallback parameters\n httpHost: 'sockjs.pusher.com',\n httpPort: 80,\n httpsPort: 443,\n httpPath: '/pusher',\n // DEPRECATED: Stats\n stats_host: 'stats.pusher.com',\n // DEPRECATED: Other settings\n authEndpoint: '/pusher/auth',\n authTransport: 'ajax',\n activityTimeout: 120000,\n pongTimeout: 30000,\n unavailableTimeout: 10000,\n userAuthentication: {\n endpoint: '/pusher/user-auth',\n transport: 'ajax'\n },\n channelAuthorization: {\n endpoint: '/pusher/auth',\n transport: 'ajax'\n },\n\n // CDN configuration\n cdn_http: CDN_HTTP,\n cdn_https: CDN_HTTPS,\n dependency_suffix: DEPENDENCY_SUFFIX\n};\n\nexport default Defaults;\n","import Defaults from '../defaults';\nimport { default as URLScheme, URLSchemeParams } from './url_scheme';\n\nfunction getGenericURL(\n baseScheme: string,\n params: URLSchemeParams,\n path: string\n): string {\n var scheme = baseScheme + (params.useTLS ? 's' : '');\n var host = params.useTLS ? params.hostTLS : params.hostNonTLS;\n return scheme + '://' + host + path;\n}\n\nfunction getGenericPath(key: string, queryString?: string): string {\n var path = '/app/' + key;\n var query =\n '?protocol=' +\n Defaults.PROTOCOL +\n '&client=js' +\n '&version=' +\n Defaults.VERSION +\n (queryString ? '&' + queryString : '');\n return path + query;\n}\n\nexport var ws: URLScheme = {\n getInitial: function(key: string, params: URLSchemeParams): string {\n var path = (params.httpPath || '') + getGenericPath(key, 'flash=false');\n return getGenericURL('ws', params, path);\n }\n};\n\nexport var http: URLScheme = {\n getInitial: function(key: string, params: URLSchemeParams): string {\n var path = (params.httpPath || '/pusher') + getGenericPath(key);\n return getGenericURL('http', params, path);\n }\n};\n\nexport var sockjs: URLScheme = {\n getInitial: function(key: string, params: URLSchemeParams): string {\n return getGenericURL('http', params, params.httpPath || '/pusher');\n },\n getPath: function(key: string, params: URLSchemeParams): string {\n return getGenericPath(key);\n }\n};\n","import Callback from './callback';\nimport * as Collections from '../utils/collections';\nimport CallbackTable from './callback_table';\n\nexport default class CallbackRegistry {\n _callbacks: CallbackTable;\n\n constructor() {\n this._callbacks = {};\n }\n\n get(name: string): Callback[] {\n return this._callbacks[prefix(name)];\n }\n\n add(name: string, callback: Function, context: any) {\n var prefixedEventName = prefix(name);\n this._callbacks[prefixedEventName] =\n this._callbacks[prefixedEventName] || [];\n this._callbacks[prefixedEventName].push({\n fn: callback,\n context: context\n });\n }\n\n remove(name?: string, callback?: Function, context?: any) {\n if (!name && !callback && !context) {\n this._callbacks = {};\n return;\n }\n\n var names = name ? [prefix(name)] : Collections.keys(this._callbacks);\n\n if (callback || context) {\n this.removeCallback(names, callback, context);\n } else {\n this.removeAllCallbacks(names);\n }\n }\n\n private removeCallback(names: string[], callback: Function, context: any) {\n Collections.apply(\n names,\n function(name) {\n this._callbacks[name] = Collections.filter(\n this._callbacks[name] || [],\n function(binding) {\n return (\n (callback && callback !== binding.fn) ||\n (context && context !== binding.context)\n );\n }\n );\n if (this._callbacks[name].length === 0) {\n delete this._callbacks[name];\n }\n },\n this\n );\n }\n\n private removeAllCallbacks(names: string[]) {\n Collections.apply(\n names,\n function(name) {\n delete this._callbacks[name];\n },\n this\n );\n }\n}\n\nfunction prefix(name: string): string {\n return '_' + name;\n}\n","import * as Collections from '../utils/collections';\nimport Callback from './callback';\nimport Metadata from '../channels/metadata';\nimport CallbackRegistry from './callback_registry';\n\n/** Manages callback bindings and event emitting.\n *\n * @param Function failThrough called when no listeners are bound to an event\n */\nexport default class Dispatcher {\n callbacks: CallbackRegistry;\n global_callbacks: Function[];\n failThrough: Function;\n\n constructor(failThrough?: Function) {\n this.callbacks = new CallbackRegistry();\n this.global_callbacks = [];\n this.failThrough = failThrough;\n }\n\n bind(eventName: string, callback: Function, context?: any) {\n this.callbacks.add(eventName, callback, context);\n return this;\n }\n\n bind_global(callback: Function) {\n this.global_callbacks.push(callback);\n return this;\n }\n\n unbind(eventName?: string, callback?: Function, context?: any) {\n this.callbacks.remove(eventName, callback, context);\n return this;\n }\n\n unbind_global(callback?: Function) {\n if (!callback) {\n this.global_callbacks = [];\n return this;\n }\n\n this.global_callbacks = Collections.filter(\n this.global_callbacks || [],\n c => c !== callback\n );\n\n return this;\n }\n\n unbind_all() {\n this.unbind();\n this.unbind_global();\n return this;\n }\n\n emit(eventName: string, data?: any, metadata?: Metadata): Dispatcher {\n for (var i = 0; i < this.global_callbacks.length; i++) {\n this.global_callbacks[i](eventName, data);\n }\n\n var callbacks = this.callbacks.get(eventName);\n var args = [];\n\n if (metadata) {\n // if there's a metadata argument, we need to call the callback with both\n // data and metadata regardless of whether data is undefined\n args.push(data, metadata);\n } else if (data) {\n // metadata is undefined, so we only need to call the callback with data\n // if data exists\n args.push(data);\n }\n\n if (callbacks && callbacks.length > 0) {\n for (var i = 0; i < callbacks.length; i++) {\n callbacks[i].fn.apply(callbacks[i].context || global, args);\n }\n } else if (this.failThrough) {\n this.failThrough(eventName, data);\n }\n\n return this;\n }\n}\n","import { stringify } from './utils/collections';\nimport Pusher from './pusher';\n\nclass Logger {\n debug(...args: any[]) {\n this.log(this.globalLog, args);\n }\n\n warn(...args: any[]) {\n this.log(this.globalLogWarn, args);\n }\n\n error(...args: any[]) {\n this.log(this.globalLogError, args);\n }\n\n private globalLog = (message: string) => {\n if (global.console && global.console.log) {\n global.console.log(message);\n }\n };\n\n private globalLogWarn(message: string) {\n if (global.console && global.console.warn) {\n global.console.warn(message);\n } else {\n this.globalLog(message);\n }\n }\n\n private globalLogError(message: string) {\n if (global.console && global.console.error) {\n global.console.error(message);\n } else {\n this.globalLogWarn(message);\n }\n }\n\n private log(\n defaultLoggingFunction: (message: string) => void,\n ...args: any[]\n ) {\n var message = stringify.apply(this, arguments);\n if (Pusher.log) {\n Pusher.log(message);\n } else if (Pusher.logToConsole) {\n const log = defaultLoggingFunction.bind(this);\n log(message);\n }\n }\n}\n\nexport default new Logger();\n","import Util from '../util';\nimport * as Collections from '../utils/collections';\nimport { default as EventsDispatcher } from '../events/dispatcher';\nimport Logger from '../logger';\nimport TransportHooks from './transport_hooks';\nimport Socket from '../socket';\nimport Runtime from 'runtime';\nimport Timeline from '../timeline/timeline';\nimport TransportConnectionOptions from './transport_connection_options';\n\n/** Provides universal API for transport connections.\n *\n * Transport connection is a low-level object that wraps a connection method\n * and exposes a simple evented interface for the connection state and\n * messaging. It does not implement Pusher-specific WebSocket protocol.\n *\n * Additionally, it fetches resources needed for transport to work and exposes\n * an interface for querying transport features.\n *\n * States:\n * - new - initial state after constructing the object\n * - initializing - during initialization phase, usually fetching resources\n * - intialized - ready to establish a connection\n * - connection - when connection is being established\n * - open - when connection ready to be used\n * - closed - after connection was closed be either side\n *\n * Emits:\n * - error - after the connection raised an error\n *\n * Options:\n * - useTLS - whether connection should be over TLS\n * - hostTLS - host to connect to when connection is over TLS\n * - hostNonTLS - host to connect to when connection is over TLS\n *\n * @param {String} key application key\n * @param {Object} options\n */\nexport default class TransportConnection extends EventsDispatcher {\n hooks: TransportHooks;\n name: string;\n priority: number;\n key: string;\n options: TransportConnectionOptions;\n state: string;\n timeline: Timeline;\n activityTimeout: number;\n id: number;\n socket: Socket;\n beforeOpen: Function;\n initialize: Function;\n\n constructor(\n hooks: TransportHooks,\n name: string,\n priority: number,\n key: string,\n options: TransportConnectionOptions\n ) {\n super();\n this.initialize = Runtime.transportConnectionInitializer;\n this.hooks = hooks;\n this.name = name;\n this.priority = priority;\n this.key = key;\n this.options = options;\n\n this.state = 'new';\n this.timeline = options.timeline;\n this.activityTimeout = options.activityTimeout;\n this.id = this.timeline.generateUniqueID();\n }\n\n /** Checks whether the transport handles activity checks by itself.\n *\n * @return {Boolean}\n */\n handlesActivityChecks(): boolean {\n return Boolean(this.hooks.handlesActivityChecks);\n }\n\n /** Checks whether the transport supports the ping/pong API.\n *\n * @return {Boolean}\n */\n supportsPing(): boolean {\n return Boolean(this.hooks.supportsPing);\n }\n\n /** Tries to establish a connection.\n *\n * @returns {Boolean} false if transport is in invalid state\n */\n connect(): boolean {\n if (this.socket || this.state !== 'initialized') {\n return false;\n }\n\n var url = this.hooks.urls.getInitial(this.key, this.options);\n try {\n this.socket = this.hooks.getSocket(url, this.options);\n } catch (e) {\n Util.defer(() => {\n this.onError(e);\n this.changeState('closed');\n });\n return false;\n }\n\n this.bindListeners();\n\n Logger.debug('Connecting', { transport: this.name, url });\n this.changeState('connecting');\n return true;\n }\n\n /** Closes the connection.\n *\n * @return {Boolean} true if there was a connection to close\n */\n close(): boolean {\n if (this.socket) {\n this.socket.close();\n return true;\n } else {\n return false;\n }\n }\n\n /** Sends data over the open connection.\n *\n * @param {String} data\n * @return {Boolean} true only when in the \"open\" state\n */\n send(data: any): boolean {\n if (this.state === 'open') {\n // Workaround for MobileSafari bug (see https://gist.github.com/2052006)\n Util.defer(() => {\n if (this.socket) {\n this.socket.send(data);\n }\n });\n return true;\n } else {\n return false;\n }\n }\n\n /** Sends a ping if the connection is open and transport supports it. */\n ping() {\n if (this.state === 'open' && this.supportsPing()) {\n this.socket.ping();\n }\n }\n\n private onOpen() {\n if (this.hooks.beforeOpen) {\n this.hooks.beforeOpen(\n this.socket,\n this.hooks.urls.getPath(this.key, this.options)\n );\n }\n this.changeState('open');\n this.socket.onopen = undefined;\n }\n\n private onError(error) {\n this.emit('error', { type: 'WebSocketError', error: error });\n this.timeline.error(this.buildTimelineMessage({ error: error.toString() }));\n }\n\n private onClose(closeEvent?: any) {\n if (closeEvent) {\n this.changeState('closed', {\n code: closeEvent.code,\n reason: closeEvent.reason,\n wasClean: closeEvent.wasClean\n });\n } else {\n this.changeState('closed');\n }\n this.unbindListeners();\n this.socket = undefined;\n }\n\n private onMessage(message) {\n this.emit('message', message);\n }\n\n private onActivity() {\n this.emit('activity');\n }\n\n private bindListeners() {\n this.socket.onopen = () => {\n this.onOpen();\n };\n this.socket.onerror = error => {\n this.onError(error);\n };\n this.socket.onclose = closeEvent => {\n this.onClose(closeEvent);\n };\n this.socket.onmessage = message => {\n this.onMessage(message);\n };\n\n if (this.supportsPing()) {\n this.socket.onactivity = () => {\n this.onActivity();\n };\n }\n }\n\n private unbindListeners() {\n if (this.socket) {\n this.socket.onopen = undefined;\n this.socket.onerror = undefined;\n this.socket.onclose = undefined;\n this.socket.onmessage = undefined;\n if (this.supportsPing()) {\n this.socket.onactivity = undefined;\n }\n }\n }\n\n private changeState(state: string, params?: any) {\n this.state = state;\n this.timeline.info(\n this.buildTimelineMessage({\n state: state,\n params: params\n })\n );\n this.emit(state, params);\n }\n\n buildTimelineMessage(message): any {\n return Collections.extend({ cid: this.id }, message);\n }\n}\n","import Factory from '../utils/factory';\nimport TransportHooks from './transport_hooks';\nimport TransportConnection from './transport_connection';\nimport TransportConnectionOptions from './transport_connection_options';\n\n/** Provides interface for transport connection instantiation.\n *\n * Takes transport-specific hooks as the only argument, which allow checking\n * for transport support and creating its connections.\n *\n * Supported hooks: * - file - the name of the file to be fetched during initialization\n * - urls - URL scheme to be used by transport\n * - handlesActivityCheck - true when the transport handles activity checks\n * - supportsPing - true when the transport has a ping/activity API\n * - isSupported - tells whether the transport is supported in the environment\n * - getSocket - creates a WebSocket-compatible transport socket\n *\n * See transports.js for specific implementations.\n *\n * @param {Object} hooks object containing all needed transport hooks\n */\nexport default class Transport {\n hooks: TransportHooks;\n\n constructor(hooks: TransportHooks) {\n this.hooks = hooks;\n }\n\n /** Returns whether the transport is supported in the environment.\n *\n * @param {Object} envronment te environment details (encryption, settings)\n * @returns {Boolean} true when the transport is supported\n */\n isSupported(environment: any): boolean {\n return this.hooks.isSupported(environment);\n }\n\n /** Creates a transport connection.\n *\n * @param {String} name\n * @param {Number} priority\n * @param {String} key the application key\n * @param {Object} options\n * @returns {TransportConnection}\n */\n createConnection(\n name: string,\n priority: number,\n key: string,\n options: any\n ): TransportConnection {\n return new TransportConnection(this.hooks, name, priority, key, options);\n }\n}\n","import * as URLSchemes from 'core/transports/url_schemes';\nimport URLScheme from 'core/transports/url_scheme';\nimport Transport from 'core/transports/transport';\nimport Util from 'core/util';\nimport * as Collections from 'core/utils/collections';\nimport TransportHooks from 'core/transports/transport_hooks';\nimport TransportsTable from 'core/transports/transports_table';\nimport Runtime from 'runtime';\n\n/** WebSocket transport.\n *\n * Uses native WebSocket implementation, including MozWebSocket supported by\n * earlier Firefox versions.\n */\nvar WSTransport = new Transport({\n urls: URLSchemes.ws,\n handlesActivityChecks: false,\n supportsPing: false,\n\n isInitialized: function() {\n return Boolean(Runtime.getWebSocketAPI());\n },\n isSupported: function(): boolean {\n return Boolean(Runtime.getWebSocketAPI());\n },\n getSocket: function(url) {\n return Runtime.createWebSocket(url);\n }\n});\n\nvar httpConfiguration = {\n urls: URLSchemes.http,\n handlesActivityChecks: false,\n supportsPing: true,\n isInitialized: function() {\n return true;\n }\n};\n\nexport var streamingConfiguration = Collections.extend(\n {\n getSocket: function(url) {\n return Runtime.HTTPFactory.createStreamingSocket(url);\n }\n },\n httpConfiguration\n);\nexport var pollingConfiguration = Collections.extend(\n {\n getSocket: function(url) {\n return Runtime.HTTPFactory.createPollingSocket(url);\n }\n },\n httpConfiguration\n);\n\nvar xhrConfiguration = {\n isSupported: function(): boolean {\n return Runtime.isXHRSupported();\n }\n};\n\n/** HTTP streaming transport using CORS-enabled XMLHttpRequest. */\nvar XHRStreamingTransport = new Transport(\n (\n Collections.extend({}, streamingConfiguration, xhrConfiguration)\n )\n);\n\n/** HTTP long-polling transport using CORS-enabled XMLHttpRequest. */\nvar XHRPollingTransport = new Transport(\n Collections.extend({}, pollingConfiguration, xhrConfiguration)\n);\n\nvar Transports: TransportsTable = {\n ws: WSTransport,\n xhr_streaming: XHRStreamingTransport,\n xhr_polling: XHRPollingTransport\n};\n\nexport default Transports;\n","import Util from '../util';\nimport * as Collections from '../utils/collections';\nimport TransportManager from './transport_manager';\nimport TransportConnection from './transport_connection';\nimport Transport from './transport';\nimport PingDelayOptions from './ping_delay_options';\n\n/** Creates transport connections monitored by a transport manager.\n *\n * When a transport is closed, it might mean the environment does not support\n * it. It's possible that messages get stuck in an intermediate buffer or\n * proxies terminate inactive connections. To combat these problems,\n * assistants monitor the connection lifetime, report unclean exits and\n * adjust ping timeouts to keep the connection active. The decision to disable\n * a transport is the manager's responsibility.\n *\n * @param {TransportManager} manager\n * @param {TransportConnection} transport\n * @param {Object} options\n */\nexport default class AssistantToTheTransportManager {\n manager: TransportManager;\n transport: Transport;\n minPingDelay: number;\n maxPingDelay: number;\n pingDelay: number;\n\n constructor(\n manager: TransportManager,\n transport: Transport,\n options: PingDelayOptions\n ) {\n this.manager = manager;\n this.transport = transport;\n this.minPingDelay = options.minPingDelay;\n this.maxPingDelay = options.maxPingDelay;\n this.pingDelay = undefined;\n }\n\n /** Creates a transport connection.\n *\n * This function has the same API as Transport#createConnection.\n *\n * @param {String} name\n * @param {Number} priority\n * @param {String} key the application key\n * @param {Object} options\n * @returns {TransportConnection}\n */\n createConnection(\n name: string,\n priority: number,\n key: string,\n options: Object\n ): TransportConnection {\n options = Collections.extend({}, options, {\n activityTimeout: this.pingDelay\n });\n var connection = this.transport.createConnection(\n name,\n priority,\n key,\n options\n );\n\n var openTimestamp = null;\n\n var onOpen = function() {\n connection.unbind('open', onOpen);\n connection.bind('closed', onClosed);\n openTimestamp = Util.now();\n };\n var onClosed = closeEvent => {\n connection.unbind('closed', onClosed);\n\n if (closeEvent.code === 1002 || closeEvent.code === 1003) {\n // we don't want to use transports not obeying the protocol\n this.manager.reportDeath();\n } else if (!closeEvent.wasClean && openTimestamp) {\n // report deaths only for short-living transport\n var lifespan = Util.now() - openTimestamp;\n if (lifespan < 2 * this.maxPingDelay) {\n this.manager.reportDeath();\n this.pingDelay = Math.max(lifespan / 2, this.minPingDelay);\n }\n }\n };\n\n connection.bind('open', onOpen);\n return connection;\n }\n\n /** Returns whether the transport is supported in the environment.\n *\n * This function has the same API as Transport#isSupported. Might return false\n * when the manager decides to kill the transport.\n *\n * @param {Object} environment the environment details (encryption, settings)\n * @returns {Boolean} true when the transport is supported\n */\n isSupported(environment: string): boolean {\n return this.manager.isAlive() && this.transport.isSupported(environment);\n }\n}\n","import Action from './action';\nimport { PusherEvent } from './message-types';\n/**\n * Provides functions for handling Pusher protocol-specific messages.\n */\n\nconst Protocol = {\n /**\n * Decodes a message in a Pusher format.\n *\n * The MessageEvent we receive from the transport should contain a pusher event\n * (https://pusher.com/docs/pusher_protocol#events) serialized as JSON in the\n * data field\n *\n * The pusher event may contain a data field too, and it may also be\n * serialised as JSON\n *\n * Throws errors when messages are not parse'able.\n *\n * @param {MessageEvent} messageEvent\n * @return {PusherEvent}\n */\n decodeMessage: function(messageEvent: MessageEvent): PusherEvent {\n try {\n var messageData = JSON.parse(messageEvent.data);\n var pusherEventData = messageData.data;\n if (typeof pusherEventData === 'string') {\n try {\n pusherEventData = JSON.parse(messageData.data);\n } catch (e) {}\n }\n var pusherEvent: PusherEvent = {\n event: messageData.event,\n channel: messageData.channel,\n data: pusherEventData\n };\n if (messageData.user_id) {\n pusherEvent.user_id = messageData.user_id;\n }\n return pusherEvent;\n } catch (e) {\n throw { type: 'MessageParseError', error: e, data: messageEvent.data };\n }\n },\n\n /**\n * Encodes a message to be sent.\n *\n * @param {PusherEvent} event\n * @return {String}\n */\n encodeMessage: function(event: PusherEvent): string {\n return JSON.stringify(event);\n },\n\n /**\n * Processes a handshake message and returns appropriate actions.\n *\n * Returns an object with an 'action' and other action-specific properties.\n *\n * There are three outcomes when calling this function. First is a successful\n * connection attempt, when pusher:connection_established is received, which\n * results in a 'connected' action with an 'id' property. When passed a\n * pusher:error event, it returns a result with action appropriate to the\n * close code and an error. Otherwise, it raises an exception.\n *\n * @param {String} message\n * @result Object\n */\n processHandshake: function(messageEvent: MessageEvent): Action {\n var message = Protocol.decodeMessage(messageEvent);\n\n if (message.event === 'pusher:connection_established') {\n if (!message.data.activity_timeout) {\n throw 'No activity timeout specified in handshake';\n }\n return {\n action: 'connected',\n id: message.data.socket_id,\n activityTimeout: message.data.activity_timeout * 1000\n };\n } else if (message.event === 'pusher:error') {\n // From protocol 6 close codes are sent only once, so this only\n // happens when connection does not support close codes\n return {\n action: this.getCloseAction(message.data),\n error: this.getCloseError(message.data)\n };\n } else {\n throw 'Invalid handshake';\n }\n },\n\n /**\n * Dispatches the close event and returns an appropriate action name.\n *\n * See:\n * 1. https://developer.mozilla.org/en-US/docs/WebSockets/WebSockets_reference/CloseEvent\n * 2. http://pusher.com/docs/pusher_protocol\n *\n * @param {CloseEvent} closeEvent\n * @return {String} close action name\n */\n getCloseAction: function(closeEvent): string {\n if (closeEvent.code < 4000) {\n // ignore 1000 CLOSE_NORMAL, 1001 CLOSE_GOING_AWAY,\n // 1005 CLOSE_NO_STATUS, 1006 CLOSE_ABNORMAL\n // ignore 1007...3999\n // handle 1002 CLOSE_PROTOCOL_ERROR, 1003 CLOSE_UNSUPPORTED,\n // 1004 CLOSE_TOO_LARGE\n if (closeEvent.code >= 1002 && closeEvent.code <= 1004) {\n return 'backoff';\n } else {\n return null;\n }\n } else if (closeEvent.code === 4000) {\n return 'tls_only';\n } else if (closeEvent.code < 4100) {\n return 'refused';\n } else if (closeEvent.code < 4200) {\n return 'backoff';\n } else if (closeEvent.code < 4300) {\n return 'retry';\n } else {\n // unknown error\n return 'refused';\n }\n },\n\n /**\n * Returns an error or null basing on the close event.\n *\n * Null is returned when connection was closed cleanly. Otherwise, an object\n * with error details is returned.\n *\n * @param {CloseEvent} closeEvent\n * @return {Object} error object\n */\n getCloseError: function(closeEvent): any {\n if (closeEvent.code !== 1000 && closeEvent.code !== 1001) {\n return {\n type: 'PusherError',\n data: {\n code: closeEvent.code,\n message: closeEvent.reason || closeEvent.message\n }\n };\n } else {\n return null;\n }\n }\n};\n\nexport default Protocol;\n","import * as Collections from '../utils/collections';\nimport { default as EventsDispatcher } from '../events/dispatcher';\nimport Protocol from './protocol/protocol';\nimport { PusherEvent } from './protocol/message-types';\nimport Logger from '../logger';\nimport TransportConnection from '../transports/transport_connection';\nimport Socket from '../socket';\n/**\n * Provides Pusher protocol interface for transports.\n *\n * Emits following events:\n * - message - on received messages\n * - ping - on ping requests\n * - pong - on pong responses\n * - error - when the transport emits an error\n * - closed - after closing the transport\n *\n * It also emits more events when connection closes with a code.\n * See Protocol.getCloseAction to get more details.\n *\n * @param {Number} id\n * @param {AbstractTransport} transport\n */\nexport default class Connection extends EventsDispatcher implements Socket {\n id: string;\n transport: TransportConnection;\n activityTimeout: number;\n\n constructor(id: string, transport: TransportConnection) {\n super();\n this.id = id;\n this.transport = transport;\n this.activityTimeout = transport.activityTimeout;\n this.bindListeners();\n }\n\n /** Returns whether used transport handles activity checks by itself\n *\n * @returns {Boolean} true if activity checks are handled by the transport\n */\n handlesActivityChecks() {\n return this.transport.handlesActivityChecks();\n }\n\n /** Sends raw data.\n *\n * @param {String} data\n */\n send(data: any): boolean {\n return this.transport.send(data);\n }\n\n /** Sends an event.\n *\n * @param {String} name\n * @param {String} data\n * @param {String} [channel]\n * @returns {Boolean} whether message was sent or not\n */\n send_event(name: string, data: any, channel?: string): boolean {\n var event: PusherEvent = { event: name, data: data };\n if (channel) {\n event.channel = channel;\n }\n Logger.debug('Event sent', event);\n return this.send(Protocol.encodeMessage(event));\n }\n\n /** Sends a ping message to the server.\n *\n * Basing on the underlying transport, it might send either transport's\n * protocol-specific ping or pusher:ping event.\n */\n ping() {\n if (this.transport.supportsPing()) {\n this.transport.ping();\n } else {\n this.send_event('pusher:ping', {});\n }\n }\n\n /** Closes the connection. */\n close() {\n this.transport.close();\n }\n\n private bindListeners() {\n var listeners = {\n message: (messageEvent: MessageEvent) => {\n var pusherEvent;\n try {\n pusherEvent = Protocol.decodeMessage(messageEvent);\n } catch (e) {\n this.emit('error', {\n type: 'MessageParseError',\n error: e,\n data: messageEvent.data\n });\n }\n\n if (pusherEvent !== undefined) {\n Logger.debug('Event recd', pusherEvent);\n\n switch (pusherEvent.event) {\n case 'pusher:error':\n this.emit('error', {\n type: 'PusherError',\n data: pusherEvent.data\n });\n break;\n case 'pusher:ping':\n this.emit('ping');\n break;\n case 'pusher:pong':\n this.emit('pong');\n break;\n }\n this.emit('message', pusherEvent);\n }\n },\n activity: () => {\n this.emit('activity');\n },\n error: error => {\n this.emit('error', error);\n },\n closed: closeEvent => {\n unbindListeners();\n\n if (closeEvent && closeEvent.code) {\n this.handleCloseEvent(closeEvent);\n }\n\n this.transport = null;\n this.emit('closed');\n }\n };\n\n var unbindListeners = () => {\n Collections.objectApply(listeners, (listener, event) => {\n this.transport.unbind(event, listener);\n });\n };\n\n Collections.objectApply(listeners, (listener, event) => {\n this.transport.bind(event, listener);\n });\n }\n\n private handleCloseEvent(closeEvent: any) {\n var action = Protocol.getCloseAction(closeEvent);\n var error = Protocol.getCloseError(closeEvent);\n if (error) {\n this.emit('error', error);\n }\n if (action) {\n this.emit(action, { action: action, error: error });\n }\n }\n}\n","import Util from '../../util';\nimport * as Collections from '../../utils/collections';\nimport Protocol from '../protocol/protocol';\nimport Connection from '../connection';\nimport TransportConnection from '../../transports/transport_connection';\nimport HandshakePayload from './handshake_payload';\n\n/**\n * Handles Pusher protocol handshakes for transports.\n *\n * Calls back with a result object after handshake is completed. Results\n * always have two fields:\n * - action - string describing action to be taken after the handshake\n * - transport - the transport object passed to the constructor\n *\n * Different actions can set different additional properties on the result.\n * In the case of 'connected' action, there will be a 'connection' property\n * containing a Connection object for the transport. Other actions should\n * carry an 'error' property.\n *\n * @param {AbstractTransport} transport\n * @param {Function} callback\n */\nexport default class Handshake {\n transport: TransportConnection;\n callback: (HandshakePayload) => void;\n onMessage: Function;\n onClosed: Function;\n\n constructor(\n transport: TransportConnection,\n callback: (HandshakePayload) => void\n ) {\n this.transport = transport;\n this.callback = callback;\n this.bindListeners();\n }\n\n close() {\n this.unbindListeners();\n this.transport.close();\n }\n\n private bindListeners() {\n this.onMessage = m => {\n this.unbindListeners();\n\n var result;\n try {\n result = Protocol.processHandshake(m);\n } catch (e) {\n this.finish('error', { error: e });\n this.transport.close();\n return;\n }\n\n if (result.action === 'connected') {\n this.finish('connected', {\n connection: new Connection(result.id, this.transport),\n activityTimeout: result.activityTimeout\n });\n } else {\n this.finish(result.action, { error: result.error });\n this.transport.close();\n }\n };\n\n this.onClosed = closeEvent => {\n this.unbindListeners();\n\n var action = Protocol.getCloseAction(closeEvent) || 'backoff';\n var error = Protocol.getCloseError(closeEvent);\n this.finish(action, { error: error });\n };\n\n this.transport.bind('message', this.onMessage);\n this.transport.bind('closed', this.onClosed);\n }\n\n private unbindListeners() {\n this.transport.unbind('message', this.onMessage);\n this.transport.unbind('closed', this.onClosed);\n }\n\n private finish(action: string, params: any) {\n this.callback(\n Collections.extend({ transport: this.transport, action: action }, params)\n );\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport base64encode from '../base64';\nimport Timeline from './timeline';\nimport Runtime from 'runtime';\n\nexport interface TimelineSenderOptions {\n host?: string;\n port?: number;\n path?: string;\n}\n\nexport default class TimelineSender {\n timeline: Timeline;\n options: TimelineSenderOptions;\n host: string;\n\n constructor(timeline: Timeline, options: TimelineSenderOptions) {\n this.timeline = timeline;\n this.options = options || {};\n }\n\n send(useTLS: boolean, callback?: Function) {\n if (this.timeline.isEmpty()) {\n return;\n }\n\n this.timeline.send(\n Runtime.TimelineTransport.getAgent(this, useTLS),\n callback\n );\n }\n}\n","/** Error classes used throughout the library. */\n// https://github.com/Microsoft/TypeScript-wiki/blob/master/Breaking-Changes.md#extending-built-ins-like-error-array-and-map-may-no-longer-work\nexport class BadEventName extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\nexport class BadChannelName extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\nexport class RequestTimedOut extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class TransportPriorityTooLow extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class TransportClosed extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class UnsupportedFeature extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class UnsupportedTransport extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class UnsupportedStrategy extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class HTTPAuthError extends Error {\n status: number;\n constructor(status: number, msg?: string) {\n super(msg);\n this.status = status;\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n","/**\n * A place to store help URLs for error messages etc\n */\n\nconst urlStore = {\n baseUrl: 'https://pusher.com',\n urls: {\n authenticationEndpoint: {\n path: '/docs/channels/server_api/authenticating_users'\n },\n authorizationEndpoint: {\n path: '/docs/channels/server_api/authorizing-users/'\n },\n javascriptQuickStart: {\n path: '/docs/javascript_quick_start'\n },\n triggeringClientEvents: {\n path: '/docs/client_api_guide/client_events#trigger-events'\n },\n encryptedChannelSupport: {\n fullUrl:\n 'https://github.com/pusher/pusher-js/tree/cc491015371a4bde5743d1c87a0fbac0feb53195#encrypted-channel-support'\n }\n }\n};\n\n/** Builds a consistent string with links to pusher documentation\n *\n * @param {string} key - relevant key in the url_store.urls object\n * @return {string} suffix string to append to log message\n */\nconst buildLogSuffix = function(key: string): string {\n const urlPrefix = 'See:';\n const urlObj = urlStore.urls[key];\n if (!urlObj) return '';\n\n let url;\n if (urlObj.fullUrl) {\n url = urlObj.fullUrl;\n } else if (urlObj.path) {\n url = urlStore.baseUrl + urlObj.path;\n }\n\n if (!url) return '';\n return `${urlPrefix} ${url}`;\n};\n\nexport default { buildLogSuffix };\n","import { default as EventsDispatcher } from '../events/dispatcher';\nimport * as Errors from '../errors';\nimport Logger from '../logger';\nimport Pusher from '../pusher';\nimport { PusherEvent } from '../connection/protocol/message-types';\nimport Metadata from './metadata';\nimport UrlStore from '../utils/url_store';\nimport {\n ChannelAuthorizationData,\n ChannelAuthorizationCallback\n} from '../auth/options';\nimport { HTTPAuthError } from '../errors';\n\n/** Provides base public channel interface with an event emitter.\n *\n * Emits:\n * - pusher:subscription_succeeded - after subscribing successfully\n * - other non-internal events\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\nexport default class Channel extends EventsDispatcher {\n name: string;\n pusher: Pusher;\n subscribed: boolean;\n subscriptionPending: boolean;\n subscriptionCancelled: boolean;\n subscriptionCount: null;\n\n constructor(name: string, pusher: Pusher) {\n super(function(event, data) {\n Logger.debug('No callbacks on ' + name + ' for ' + event);\n });\n\n this.name = name;\n this.pusher = pusher;\n this.subscribed = false;\n this.subscriptionPending = false;\n this.subscriptionCancelled = false;\n }\n\n /** Skips authorization, since public channels don't require it.\n *\n * @param {Function} callback\n */\n authorize(socketId: string, callback: ChannelAuthorizationCallback) {\n return callback(null, { auth: '' });\n }\n\n /** Triggers an event */\n trigger(event: string, data: any) {\n if (event.indexOf('client-') !== 0) {\n throw new Errors.BadEventName(\n \"Event '\" + event + \"' does not start with 'client-'\"\n );\n }\n if (!this.subscribed) {\n var suffix = UrlStore.buildLogSuffix('triggeringClientEvents');\n Logger.warn(\n `Client event triggered before channel 'subscription_succeeded' event . ${suffix}`\n );\n }\n return this.pusher.send_event(event, data, this.name);\n }\n\n /** Signals disconnection to the channel. For internal use only. */\n disconnect() {\n this.subscribed = false;\n this.subscriptionPending = false;\n }\n\n /** Handles a PusherEvent. For internal use only.\n *\n * @param {PusherEvent} event\n */\n handleEvent(event: PusherEvent) {\n var eventName = event.event;\n var data = event.data;\n if (eventName === 'pusher_internal:subscription_succeeded') {\n this.handleSubscriptionSucceededEvent(event);\n } else if (eventName === 'pusher_internal:subscription_count') {\n this.handleSubscriptionCountEvent(event);\n } else if (eventName.indexOf('pusher_internal:') !== 0) {\n var metadata: Metadata = {};\n this.emit(eventName, data, metadata);\n }\n }\n\n handleSubscriptionSucceededEvent(event: PusherEvent) {\n this.subscriptionPending = false;\n this.subscribed = true;\n if (this.subscriptionCancelled) {\n this.pusher.unsubscribe(this.name);\n } else {\n this.emit('pusher:subscription_succeeded', event.data);\n }\n }\n\n handleSubscriptionCountEvent(event: PusherEvent) {\n if (event.data.subscription_count) {\n this.subscriptionCount = event.data.subscription_count;\n }\n\n this.emit('pusher:subscription_count', event.data);\n }\n\n /** Sends a subscription request. For internal use only. */\n subscribe() {\n if (this.subscribed) {\n return;\n }\n this.subscriptionPending = true;\n this.subscriptionCancelled = false;\n this.authorize(\n this.pusher.connection.socket_id,\n (error: Error | null, data: ChannelAuthorizationData) => {\n if (error) {\n this.subscriptionPending = false;\n // Why not bind to 'pusher:subscription_error' a level up, and log there?\n // Binding to this event would cause the warning about no callbacks being\n // bound (see constructor) to be suppressed, that's not what we want.\n Logger.error(error.toString());\n this.emit(\n 'pusher:subscription_error',\n Object.assign(\n {},\n {\n type: 'AuthError',\n error: error.message\n },\n error instanceof HTTPAuthError ? { status: error.status } : {}\n )\n );\n } else {\n this.pusher.send_event('pusher:subscribe', {\n auth: data.auth,\n channel_data: data.channel_data,\n channel: this.name\n });\n }\n }\n );\n }\n\n /** Sends an unsubscription request. For internal use only. */\n unsubscribe() {\n this.subscribed = false;\n this.pusher.send_event('pusher:unsubscribe', {\n channel: this.name\n });\n }\n\n /** Cancels an in progress subscription. For internal use only. */\n cancelSubscription() {\n this.subscriptionCancelled = true;\n }\n\n /** Reinstates an in progress subscripiton. For internal use only. */\n reinstateSubscription() {\n this.subscriptionCancelled = false;\n }\n}\n","import Factory from '../utils/factory';\nimport Channel from './channel';\nimport { ChannelAuthorizationCallback } from '../auth/options';\n\n/** Extends public channels to provide private channel interface.\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\nexport default class PrivateChannel extends Channel {\n /** Authorizes the connection to use the channel.\n *\n * @param {String} socketId\n * @param {Function} callback\n */\n authorize(socketId: string, callback: ChannelAuthorizationCallback) {\n return this.pusher.config.channelAuthorizer(\n {\n channelName: this.name,\n socketId: socketId\n },\n callback\n );\n }\n}\n","import * as Collections from '../utils/collections';\n\n/** Represents a collection of members of a presence channel. */\nexport default class Members {\n members: any;\n count: number;\n myID: any;\n me: any;\n\n constructor() {\n this.reset();\n }\n\n /** Returns member's info for given id.\n *\n * Resulting object containts two fields - id and info.\n *\n * @param {Number} id\n * @return {Object} member's info or null\n */\n get(id: string): any {\n if (Object.prototype.hasOwnProperty.call(this.members, id)) {\n return {\n id: id,\n info: this.members[id]\n };\n } else {\n return null;\n }\n }\n\n /** Calls back for each member in unspecified order.\n *\n * @param {Function} callback\n */\n each(callback: Function) {\n Collections.objectApply(this.members, (member, id) => {\n callback(this.get(id));\n });\n }\n\n /** Updates the id for connected member. For internal use only. */\n setMyID(id: string) {\n this.myID = id;\n }\n\n /** Handles subscription data. For internal use only. */\n onSubscription(subscriptionData: any) {\n this.members = subscriptionData.presence.hash;\n this.count = subscriptionData.presence.count;\n this.me = this.get(this.myID);\n }\n\n /** Adds a new member to the collection. For internal use only. */\n addMember(memberData: any) {\n if (this.get(memberData.user_id) === null) {\n this.count++;\n }\n this.members[memberData.user_id] = memberData.user_info;\n return this.get(memberData.user_id);\n }\n\n /** Adds a member from the collection. For internal use only. */\n removeMember(memberData: any) {\n var member = this.get(memberData.user_id);\n if (member) {\n delete this.members[memberData.user_id];\n this.count--;\n }\n return member;\n }\n\n /** Resets the collection to the initial state. For internal use only. */\n reset() {\n this.members = {};\n this.count = 0;\n this.myID = null;\n this.me = null;\n }\n}\n","import PrivateChannel from './private_channel';\nimport Logger from '../logger';\nimport Members from './members';\nimport Pusher from '../pusher';\nimport UrlStore from 'core/utils/url_store';\nimport { PusherEvent } from '../connection/protocol/message-types';\nimport Metadata from './metadata';\nimport { ChannelAuthorizationData } from '../auth/options';\n\nexport default class PresenceChannel extends PrivateChannel {\n members: Members;\n\n /** Adds presence channel functionality to private channels.\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\n constructor(name: string, pusher: Pusher) {\n super(name, pusher);\n this.members = new Members();\n }\n\n /** Authorizes the connection as a member of the channel.\n *\n * @param {String} socketId\n * @param {Function} callback\n */\n authorize(socketId: string, callback: Function) {\n super.authorize(socketId, async (error, authData) => {\n if (!error) {\n authData = authData as ChannelAuthorizationData;\n if (authData.channel_data != null) {\n var channelData = JSON.parse(authData.channel_data);\n this.members.setMyID(channelData.user_id);\n } else {\n await this.pusher.user.signinDonePromise;\n if (this.pusher.user.user_data != null) {\n // If the user is signed in, get the id of the authenticated user\n // and allow the presence authorization to continue.\n this.members.setMyID(this.pusher.user.user_data.id);\n } else {\n let suffix = UrlStore.buildLogSuffix('authorizationEndpoint');\n Logger.error(\n `Invalid auth response for channel '${this.name}', ` +\n `expected 'channel_data' field. ${suffix}, ` +\n `or the user should be signed in.`\n );\n callback('Invalid auth response');\n return;\n }\n }\n }\n callback(error, authData);\n });\n }\n\n /** Handles presence and subscription events. For internal use only.\n *\n * @param {PusherEvent} event\n */\n handleEvent(event: PusherEvent) {\n var eventName = event.event;\n if (eventName.indexOf('pusher_internal:') === 0) {\n this.handleInternalEvent(event);\n } else {\n var data = event.data;\n var metadata: Metadata = {};\n if (event.user_id) {\n metadata.user_id = event.user_id;\n }\n this.emit(eventName, data, metadata);\n }\n }\n handleInternalEvent(event: PusherEvent) {\n var eventName = event.event;\n var data = event.data;\n switch (eventName) {\n case 'pusher_internal:subscription_succeeded':\n this.handleSubscriptionSucceededEvent(event);\n break;\n case 'pusher_internal:subscription_count':\n this.handleSubscriptionCountEvent(event);\n break;\n case 'pusher_internal:member_added':\n var addedMember = this.members.addMember(data);\n this.emit('pusher:member_added', addedMember);\n break;\n case 'pusher_internal:member_removed':\n var removedMember = this.members.removeMember(data);\n if (removedMember) {\n this.emit('pusher:member_removed', removedMember);\n }\n break;\n }\n }\n\n handleSubscriptionSucceededEvent(event: PusherEvent) {\n this.subscriptionPending = false;\n this.subscribed = true;\n if (this.subscriptionCancelled) {\n this.pusher.unsubscribe(this.name);\n } else {\n this.members.onSubscription(event.data);\n this.emit('pusher:subscription_succeeded', this.members);\n }\n }\n\n /** Resets the channel state, including members map. For internal use only. */\n disconnect() {\n this.members.reset();\n super.disconnect();\n }\n}\n","import PrivateChannel from './private_channel';\nimport * as Errors from '../errors';\nimport Logger from '../logger';\nimport Pusher from '../pusher';\nimport { decode as encodeUTF8 } from '@stablelib/utf8';\nimport { decode as decodeBase64 } from '@stablelib/base64';\nimport Dispatcher from '../events/dispatcher';\nimport { PusherEvent } from '../connection/protocol/message-types';\nimport {\n ChannelAuthorizationData,\n ChannelAuthorizationCallback\n} from '../auth/options';\nimport * as nacl from 'tweetnacl';\n\n/** Extends private channels to provide encrypted channel interface.\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\nexport default class EncryptedChannel extends PrivateChannel {\n key: Uint8Array = null;\n nacl: nacl;\n\n constructor(name: string, pusher: Pusher, nacl: nacl) {\n super(name, pusher);\n this.nacl = nacl;\n }\n\n /** Authorizes the connection to use the channel.\n *\n * @param {String} socketId\n * @param {Function} callback\n */\n authorize(socketId: string, callback: ChannelAuthorizationCallback) {\n super.authorize(\n socketId,\n (error: Error | null, authData: ChannelAuthorizationData) => {\n if (error) {\n callback(error, authData);\n return;\n }\n let sharedSecret = authData['shared_secret'];\n if (!sharedSecret) {\n callback(\n new Error(\n `No shared_secret key in auth payload for encrypted channel: ${this.name}`\n ),\n null\n );\n return;\n }\n this.key = decodeBase64(sharedSecret);\n delete authData['shared_secret'];\n callback(null, authData);\n }\n );\n }\n\n trigger(event: string, data: any): boolean {\n throw new Errors.UnsupportedFeature(\n 'Client events are not currently supported for encrypted channels'\n );\n }\n\n /** Handles an event. For internal use only.\n *\n * @param {PusherEvent} event\n */\n handleEvent(event: PusherEvent) {\n var eventName = event.event;\n var data = event.data;\n if (\n eventName.indexOf('pusher_internal:') === 0 ||\n eventName.indexOf('pusher:') === 0\n ) {\n super.handleEvent(event);\n return;\n }\n this.handleEncryptedEvent(eventName, data);\n }\n\n private handleEncryptedEvent(event: string, data: any): void {\n if (!this.key) {\n Logger.debug(\n 'Received encrypted event before key has been retrieved from the authEndpoint'\n );\n return;\n }\n if (!data.ciphertext || !data.nonce) {\n Logger.error(\n 'Unexpected format for encrypted event, expected object with `ciphertext` and `nonce` fields, got: ' +\n data\n );\n return;\n }\n let cipherText = decodeBase64(data.ciphertext);\n if (cipherText.length < this.nacl.secretbox.overheadLength) {\n Logger.error(\n `Expected encrypted event ciphertext length to be ${this.nacl.secretbox.overheadLength}, got: ${cipherText.length}`\n );\n return;\n }\n let nonce = decodeBase64(data.nonce);\n if (nonce.length < this.nacl.secretbox.nonceLength) {\n Logger.error(\n `Expected encrypted event nonce length to be ${this.nacl.secretbox.nonceLength}, got: ${nonce.length}`\n );\n return;\n }\n\n let bytes = this.nacl.secretbox.open(cipherText, nonce, this.key);\n if (bytes === null) {\n Logger.debug(\n 'Failed to decrypt an event, probably because it was encrypted with a different key. Fetching a new key from the authEndpoint...'\n );\n // Try a single time to retrieve a new auth key and decrypt the event with it\n // If this fails, a new key will be requested when a new message is received\n this.authorize(this.pusher.connection.socket_id, (error, authData) => {\n if (error) {\n Logger.error(\n `Failed to make a request to the authEndpoint: ${authData}. Unable to fetch new key, so dropping encrypted event`\n );\n return;\n }\n bytes = this.nacl.secretbox.open(cipherText, nonce, this.key);\n if (bytes === null) {\n Logger.error(\n `Failed to decrypt event with new key. Dropping encrypted event`\n );\n return;\n }\n this.emit(event, this.getDataToEmit(bytes));\n return;\n });\n return;\n }\n this.emit(event, this.getDataToEmit(bytes));\n }\n\n // Try and parse the decrypted bytes as JSON. If we can't parse it, just\n // return the utf-8 string\n getDataToEmit(bytes: Uint8Array): string {\n let raw = encodeUTF8(bytes);\n try {\n return JSON.parse(raw);\n } catch {\n return raw;\n }\n }\n}\n","import { default as EventsDispatcher } from '../events/dispatcher';\nimport { OneOffTimer as Timer } from '../utils/timers';\nimport { Config } from '../config';\nimport Logger from '../logger';\nimport HandshakePayload from './handshake/handshake_payload';\nimport Connection from './connection';\nimport Strategy from '../strategies/strategy';\nimport StrategyRunner from '../strategies/strategy_runner';\nimport * as Collections from '../utils/collections';\nimport Timeline from '../timeline/timeline';\nimport ConnectionManagerOptions from './connection_manager_options';\nimport Runtime from 'runtime';\n\nimport {\n ErrorCallbacks,\n HandshakeCallbacks,\n ConnectionCallbacks\n} from './callbacks';\nimport Action from './protocol/action';\n\n/** Manages connection to Pusher.\n *\n * Uses a strategy (currently only default), timers and network availability\n * info to establish a connection and export its state. In case of failures,\n * manages reconnection attempts.\n *\n * Exports state changes as following events:\n * - \"state_change\", { previous: p, current: state }\n * - state\n *\n * States:\n * - initialized - initial state, never transitioned to\n * - connecting - connection is being established\n * - connected - connection has been fully established\n * - disconnected - on requested disconnection\n * - unavailable - after connection timeout or when there's no network\n * - failed - when the connection strategy is not supported\n *\n * Options:\n * - unavailableTimeout - time to transition to unavailable state\n * - activityTimeout - time after which ping message should be sent\n * - pongTimeout - time for Pusher to respond with pong before reconnecting\n *\n * @param {String} key application key\n * @param {Object} options\n */\nexport default class ConnectionManager extends EventsDispatcher {\n key: string;\n options: ConnectionManagerOptions;\n state: string;\n connection: Connection;\n usingTLS: boolean;\n timeline: Timeline;\n socket_id: string;\n unavailableTimer: Timer;\n activityTimer: Timer;\n retryTimer: Timer;\n activityTimeout: number;\n strategy: Strategy;\n runner: StrategyRunner;\n errorCallbacks: ErrorCallbacks;\n handshakeCallbacks: HandshakeCallbacks;\n connectionCallbacks: ConnectionCallbacks;\n\n constructor(key: string, options: ConnectionManagerOptions) {\n super();\n this.state = 'initialized';\n this.connection = null;\n\n this.key = key;\n this.options = options;\n this.timeline = this.options.timeline;\n this.usingTLS = this.options.useTLS;\n\n this.errorCallbacks = this.buildErrorCallbacks();\n this.connectionCallbacks = this.buildConnectionCallbacks(\n this.errorCallbacks\n );\n this.handshakeCallbacks = this.buildHandshakeCallbacks(this.errorCallbacks);\n\n var Network = Runtime.getNetwork();\n\n Network.bind('online', () => {\n this.timeline.info({ netinfo: 'online' });\n if (this.state === 'connecting' || this.state === 'unavailable') {\n this.retryIn(0);\n }\n });\n Network.bind('offline', () => {\n this.timeline.info({ netinfo: 'offline' });\n if (this.connection) {\n this.sendActivityCheck();\n }\n });\n\n this.updateStrategy();\n }\n\n switchCluster(key: string) {\n this.key = key;\n // This ensures that the new config coming from\n // pusher instance are taken into account\n // such as appKey and cluster\n this.updateStrategy();\n this.retryIn(0);\n }\n\n /** Establishes a connection to Pusher.\n *\n * Does nothing when connection is already established. See top-level doc\n * to find events emitted on connection attempts.\n */\n connect() {\n if (this.connection || this.runner) {\n return;\n }\n if (!this.strategy.isSupported()) {\n this.updateState('failed');\n return;\n }\n this.updateState('connecting');\n this.startConnecting();\n this.setUnavailableTimer();\n }\n\n /** Sends raw data.\n *\n * @param {String} data\n */\n send(data) {\n if (this.connection) {\n return this.connection.send(data);\n } else {\n return false;\n }\n }\n\n /** Sends an event.\n *\n * @param {String} name\n * @param {String} data\n * @param {String} [channel]\n * @returns {Boolean} whether message was sent or not\n */\n send_event(name: string, data: any, channel?: string) {\n if (this.connection) {\n return this.connection.send_event(name, data, channel);\n } else {\n return false;\n }\n }\n\n /** Closes the connection. */\n disconnect() {\n this.disconnectInternally();\n this.updateState('disconnected');\n }\n\n isUsingTLS() {\n return this.usingTLS;\n }\n\n private startConnecting() {\n var callback = (error, handshake) => {\n if (error) {\n this.runner = this.strategy.connect(0, callback);\n } else {\n if (handshake.action === 'error') {\n this.emit('error', {\n type: 'HandshakeError',\n error: handshake.error\n });\n this.timeline.error({ handshakeError: handshake.error });\n } else {\n this.abortConnecting(); // we don't support switching connections yet\n this.handshakeCallbacks[handshake.action](handshake);\n }\n }\n };\n this.runner = this.strategy.connect(0, callback);\n }\n\n private abortConnecting() {\n if (this.runner) {\n this.runner.abort();\n this.runner = null;\n }\n }\n\n private disconnectInternally() {\n this.abortConnecting();\n this.clearRetryTimer();\n this.clearUnavailableTimer();\n if (this.connection) {\n var connection = this.abandonConnection();\n connection.close();\n }\n }\n\n private updateStrategy() {\n this.strategy = this.options.getStrategy({\n key: this.key,\n timeline: this.timeline,\n useTLS: this.usingTLS\n });\n }\n\n private retryIn(delay) {\n this.timeline.info({ action: 'retry', delay: delay });\n if (delay > 0) {\n this.emit('connecting_in', Math.round(delay / 1000));\n }\n this.retryTimer = new Timer(delay || 0, () => {\n this.disconnectInternally();\n this.connect();\n });\n }\n\n private clearRetryTimer() {\n if (this.retryTimer) {\n this.retryTimer.ensureAborted();\n this.retryTimer = null;\n }\n }\n\n private setUnavailableTimer() {\n this.unavailableTimer = new Timer(this.options.unavailableTimeout, () => {\n this.updateState('unavailable');\n });\n }\n\n private clearUnavailableTimer() {\n if (this.unavailableTimer) {\n this.unavailableTimer.ensureAborted();\n }\n }\n\n private sendActivityCheck() {\n this.stopActivityCheck();\n this.connection.ping();\n // wait for pong response\n this.activityTimer = new Timer(this.options.pongTimeout, () => {\n this.timeline.error({ pong_timed_out: this.options.pongTimeout });\n this.retryIn(0);\n });\n }\n\n private resetActivityCheck() {\n this.stopActivityCheck();\n // send ping after inactivity\n if (this.connection && !this.connection.handlesActivityChecks()) {\n this.activityTimer = new Timer(this.activityTimeout, () => {\n this.sendActivityCheck();\n });\n }\n }\n\n private stopActivityCheck() {\n if (this.activityTimer) {\n this.activityTimer.ensureAborted();\n }\n }\n\n private buildConnectionCallbacks(\n errorCallbacks: ErrorCallbacks\n ): ConnectionCallbacks {\n return Collections.extend({}, errorCallbacks, {\n message: message => {\n // includes pong messages from server\n this.resetActivityCheck();\n this.emit('message', message);\n },\n ping: () => {\n this.send_event('pusher:pong', {});\n },\n activity: () => {\n this.resetActivityCheck();\n },\n error: error => {\n // just emit error to user - socket will already be closed by browser\n this.emit('error', error);\n },\n closed: () => {\n this.abandonConnection();\n if (this.shouldRetry()) {\n this.retryIn(1000);\n }\n }\n });\n }\n\n private buildHandshakeCallbacks(\n errorCallbacks: ErrorCallbacks\n ): HandshakeCallbacks {\n return Collections.extend({}, errorCallbacks, {\n connected: (handshake: HandshakePayload) => {\n this.activityTimeout = Math.min(\n this.options.activityTimeout,\n handshake.activityTimeout,\n handshake.connection.activityTimeout || Infinity\n );\n this.clearUnavailableTimer();\n this.setConnection(handshake.connection);\n this.socket_id = this.connection.id;\n this.updateState('connected', { socket_id: this.socket_id });\n }\n });\n }\n\n private buildErrorCallbacks(): ErrorCallbacks {\n let withErrorEmitted = callback => {\n return (result: Action | HandshakePayload) => {\n if (result.error) {\n this.emit('error', { type: 'WebSocketError', error: result.error });\n }\n callback(result);\n };\n };\n\n return {\n tls_only: withErrorEmitted(() => {\n this.usingTLS = true;\n this.updateStrategy();\n this.retryIn(0);\n }),\n refused: withErrorEmitted(() => {\n this.disconnect();\n }),\n backoff: withErrorEmitted(() => {\n this.retryIn(1000);\n }),\n retry: withErrorEmitted(() => {\n this.retryIn(0);\n })\n };\n }\n\n private setConnection(connection) {\n this.connection = connection;\n for (var event in this.connectionCallbacks) {\n this.connection.bind(event, this.connectionCallbacks[event]);\n }\n this.resetActivityCheck();\n }\n\n private abandonConnection() {\n if (!this.connection) {\n return;\n }\n this.stopActivityCheck();\n for (var event in this.connectionCallbacks) {\n this.connection.unbind(event, this.connectionCallbacks[event]);\n }\n var connection = this.connection;\n this.connection = null;\n return connection;\n }\n\n private updateState(newState: string, data?: any) {\n var previousState = this.state;\n this.state = newState;\n if (previousState !== newState) {\n var newStateDescription = newState;\n if (newStateDescription === 'connected') {\n newStateDescription += ' with new socket ID ' + data.socket_id;\n }\n Logger.debug(\n 'State changed',\n previousState + ' -> ' + newStateDescription\n );\n this.timeline.info({ state: newState, params: data });\n this.emit('state_change', { previous: previousState, current: newState });\n this.emit(newState, data);\n }\n }\n\n private shouldRetry(): boolean {\n return this.state === 'connecting' || this.state === 'connected';\n }\n}\n","import Channel from './channel';\nimport * as Collections from '../utils/collections';\nimport ChannelTable from './channel_table';\nimport Factory from '../utils/factory';\nimport Pusher from '../pusher';\nimport Logger from '../logger';\nimport * as Errors from '../errors';\nimport urlStore from '../utils/url_store';\n\n/** Handles a channel map. */\nexport default class Channels {\n channels: ChannelTable;\n\n constructor() {\n this.channels = {};\n }\n\n /** Creates or retrieves an existing channel by its name.\n *\n * @param {String} name\n * @param {Pusher} pusher\n * @return {Channel}\n */\n add(name: string, pusher: Pusher) {\n if (!this.channels[name]) {\n this.channels[name] = createChannel(name, pusher);\n }\n return this.channels[name];\n }\n\n /** Returns a list of all channels\n *\n * @return {Array}\n */\n all(): Channel[] {\n return Collections.values(this.channels);\n }\n\n /** Finds a channel by its name.\n *\n * @param {String} name\n * @return {Channel} channel or null if it doesn't exist\n */\n find(name: string) {\n return this.channels[name];\n }\n\n /** Removes a channel from the map.\n *\n * @param {String} name\n */\n remove(name: string) {\n var channel = this.channels[name];\n delete this.channels[name];\n return channel;\n }\n\n /** Proxies disconnection signal to all channels. */\n disconnect() {\n Collections.objectApply(this.channels, function(channel) {\n channel.disconnect();\n });\n }\n}\n\nfunction createChannel(name: string, pusher: Pusher): Channel {\n if (name.indexOf('private-encrypted-') === 0) {\n if (pusher.config.nacl) {\n return Factory.createEncryptedChannel(name, pusher, pusher.config.nacl);\n }\n let errMsg =\n 'Tried to subscribe to a private-encrypted- channel but no nacl implementation available';\n let suffix = urlStore.buildLogSuffix('encryptedChannelSupport');\n throw new Errors.UnsupportedFeature(`${errMsg}. ${suffix}`);\n } else if (name.indexOf('private-') === 0) {\n return Factory.createPrivateChannel(name, pusher);\n } else if (name.indexOf('presence-') === 0) {\n return Factory.createPresenceChannel(name, pusher);\n } else if (name.indexOf('#') === 0) {\n throw new Errors.BadChannelName(\n 'Cannot create a channel with name \"' + name + '\".'\n );\n } else {\n return Factory.createChannel(name, pusher);\n }\n}\n","import AssistantToTheTransportManager from '../transports/assistant_to_the_transport_manager';\nimport PingDelayOptions from '../transports/ping_delay_options';\nimport Transport from '../transports/transport';\nimport TransportManager from '../transports/transport_manager';\nimport Handshake from '../connection/handshake';\nimport TransportConnection from '../transports/transport_connection';\nimport SocketHooks from '../http/socket_hooks';\nimport HTTPSocket from '../http/http_socket';\n\nimport Timeline from '../timeline/timeline';\nimport {\n default as TimelineSender,\n TimelineSenderOptions\n} from '../timeline/timeline_sender';\nimport PresenceChannel from '../channels/presence_channel';\nimport PrivateChannel from '../channels/private_channel';\nimport EncryptedChannel from '../channels/encrypted_channel';\nimport Channel from '../channels/channel';\nimport ConnectionManager from '../connection/connection_manager';\nimport ConnectionManagerOptions from '../connection/connection_manager_options';\nimport Ajax from '../http/ajax';\nimport Channels from '../channels/channels';\nimport Pusher from '../pusher';\nimport { Config } from '../config';\nimport * as nacl from 'tweetnacl';\n\nvar Factory = {\n createChannels(): Channels {\n return new Channels();\n },\n\n createConnectionManager(\n key: string,\n options: ConnectionManagerOptions\n ): ConnectionManager {\n return new ConnectionManager(key, options);\n },\n\n createChannel(name: string, pusher: Pusher): Channel {\n return new Channel(name, pusher);\n },\n\n createPrivateChannel(name: string, pusher: Pusher): PrivateChannel {\n return new PrivateChannel(name, pusher);\n },\n\n createPresenceChannel(name: string, pusher: Pusher): PresenceChannel {\n return new PresenceChannel(name, pusher);\n },\n\n createEncryptedChannel(\n name: string,\n pusher: Pusher,\n nacl: nacl\n ): EncryptedChannel {\n return new EncryptedChannel(name, pusher, nacl);\n },\n\n createTimelineSender(timeline: Timeline, options: TimelineSenderOptions) {\n return new TimelineSender(timeline, options);\n },\n\n createHandshake(\n transport: TransportConnection,\n callback: (HandshakePayload) => void\n ): Handshake {\n return new Handshake(transport, callback);\n },\n\n createAssistantToTheTransportManager(\n manager: TransportManager,\n transport: Transport,\n options: PingDelayOptions\n ): AssistantToTheTransportManager {\n return new AssistantToTheTransportManager(manager, transport, options);\n }\n};\n\nexport default Factory;\n","import AssistantToTheTransportManager from './assistant_to_the_transport_manager';\nimport Transport from './transport';\nimport PingDelayOptions from './ping_delay_options';\nimport Factory from '../utils/factory';\n\nexport interface TransportManagerOptions extends PingDelayOptions {\n lives?: number;\n}\n\n/** Keeps track of the number of lives left for a transport.\n *\n * In the beginning of a session, transports may be assigned a number of\n * lives. When an AssistantToTheTransportManager instance reports a transport\n * connection closed uncleanly, the transport loses a life. When the number\n * of lives drops to zero, the transport gets disabled by its manager.\n *\n * @param {Object} options\n */\nexport default class TransportManager {\n options: TransportManagerOptions;\n livesLeft: number;\n\n constructor(options: TransportManagerOptions) {\n this.options = options || {};\n this.livesLeft = this.options.lives || Infinity;\n }\n\n /** Creates a assistant for the transport.\n *\n * @param {Transport} transport\n * @returns {AssistantToTheTransportManager}\n */\n getAssistant(transport: Transport): AssistantToTheTransportManager {\n return Factory.createAssistantToTheTransportManager(this, transport, {\n minPingDelay: this.options.minPingDelay,\n maxPingDelay: this.options.maxPingDelay\n });\n }\n\n /** Returns whether the transport has any lives left.\n *\n * @returns {Boolean}\n */\n isAlive(): boolean {\n return this.livesLeft > 0;\n }\n\n /** Takes one life from the transport. */\n reportDeath() {\n this.livesLeft -= 1;\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport { OneOffTimer as Timer } from '../utils/timers';\nimport Strategy from './strategy';\nimport StrategyOptions from './strategy_options';\n\n/** Loops through strategies with optional timeouts.\n *\n * Options:\n * - loop - whether it should loop through the substrategy list\n * - timeout - initial timeout for a single substrategy\n * - timeoutLimit - maximum timeout\n *\n * @param {Strategy[]} strategies\n * @param {Object} options\n */\nexport default class SequentialStrategy implements Strategy {\n strategies: Strategy[];\n loop: boolean;\n failFast: boolean;\n timeout: number;\n timeoutLimit: number;\n\n constructor(strategies: Strategy[], options: StrategyOptions) {\n this.strategies = strategies;\n this.loop = Boolean(options.loop);\n this.failFast = Boolean(options.failFast);\n this.timeout = options.timeout;\n this.timeoutLimit = options.timeoutLimit;\n }\n\n isSupported(): boolean {\n return Collections.any(this.strategies, Util.method('isSupported'));\n }\n\n connect(minPriority: number, callback: Function) {\n var strategies = this.strategies;\n var current = 0;\n var timeout = this.timeout;\n var runner = null;\n\n var tryNextStrategy = (error, handshake) => {\n if (handshake) {\n callback(null, handshake);\n } else {\n current = current + 1;\n if (this.loop) {\n current = current % strategies.length;\n }\n\n if (current < strategies.length) {\n if (timeout) {\n timeout = timeout * 2;\n if (this.timeoutLimit) {\n timeout = Math.min(timeout, this.timeoutLimit);\n }\n }\n runner = this.tryStrategy(\n strategies[current],\n minPriority,\n { timeout, failFast: this.failFast },\n tryNextStrategy\n );\n } else {\n callback(true);\n }\n }\n };\n\n runner = this.tryStrategy(\n strategies[current],\n minPriority,\n { timeout: timeout, failFast: this.failFast },\n tryNextStrategy\n );\n\n return {\n abort: function() {\n runner.abort();\n },\n forceMinPriority: function(p) {\n minPriority = p;\n if (runner) {\n runner.forceMinPriority(p);\n }\n }\n };\n }\n\n private tryStrategy(\n strategy: Strategy,\n minPriority: number,\n options: StrategyOptions,\n callback: Function\n ) {\n var timer = null;\n var runner = null;\n\n if (options.timeout > 0) {\n timer = new Timer(options.timeout, function() {\n runner.abort();\n callback(true);\n });\n }\n\n runner = strategy.connect(minPriority, function(error, handshake) {\n if (error && timer && timer.isRunning() && !options.failFast) {\n // advance to the next strategy after the timeout\n return;\n }\n if (timer) {\n timer.ensureAborted();\n }\n callback(error, handshake);\n });\n\n return {\n abort: function() {\n if (timer) {\n timer.ensureAborted();\n }\n runner.abort();\n },\n forceMinPriority: function(p) {\n runner.forceMinPriority(p);\n }\n };\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport Strategy from './strategy';\n\n/** Launches all substrategies and emits prioritized connected transports.\n *\n * @param {Array} strategies\n */\nexport default class BestConnectedEverStrategy implements Strategy {\n strategies: Strategy[];\n\n constructor(strategies: Strategy[]) {\n this.strategies = strategies;\n }\n\n isSupported(): boolean {\n return Collections.any(this.strategies, Util.method('isSupported'));\n }\n\n connect(minPriority: number, callback: Function) {\n return connect(this.strategies, minPriority, function(i, runners) {\n return function(error, handshake) {\n runners[i].error = error;\n if (error) {\n if (allRunnersFailed(runners)) {\n callback(true);\n }\n return;\n }\n Collections.apply(runners, function(runner) {\n runner.forceMinPriority(handshake.transport.priority);\n });\n callback(null, handshake);\n };\n });\n }\n}\n\n/** Connects to all strategies in parallel.\n *\n * Callback builder should be a function that takes two arguments: index\n * and a list of runners. It should return another function that will be\n * passed to the substrategy with given index. Runners can be aborted using\n * abortRunner(s) functions from this class.\n *\n * @param {Array} strategies\n * @param {Function} callbackBuilder\n * @return {Object} strategy runner\n */\nfunction connect(\n strategies: Strategy[],\n minPriority: number,\n callbackBuilder: Function\n) {\n var runners = Collections.map(strategies, function(strategy, i, _, rs) {\n return strategy.connect(minPriority, callbackBuilder(i, rs));\n });\n return {\n abort: function() {\n Collections.apply(runners, abortRunner);\n },\n forceMinPriority: function(p) {\n Collections.apply(runners, function(runner) {\n runner.forceMinPriority(p);\n });\n }\n };\n}\n\nfunction allRunnersFailed(runners): boolean {\n return Collections.all(runners, function(runner) {\n return Boolean(runner.error);\n });\n}\n\nfunction abortRunner(runner) {\n if (!runner.error && !runner.aborted) {\n runner.abort();\n runner.aborted = true;\n }\n}\n","import Util from '../util';\nimport Runtime from 'runtime';\nimport Strategy from './strategy';\nimport SequentialStrategy from './sequential_strategy';\nimport StrategyOptions from './strategy_options';\nimport TransportStrategy from './transport_strategy';\nimport Timeline from '../timeline/timeline';\nimport * as Collections from '../utils/collections';\n\nexport interface TransportStrategyDictionary {\n [key: string]: TransportStrategy;\n}\n\n/** Caches the last successful transport and, after the first few attempts,\n * uses the cached transport for subsequent attempts.\n *\n * @param {Strategy} strategy\n * @param {Object} transports\n * @param {Object} options\n */\nexport default class WebSocketPrioritizedCachedStrategy implements Strategy {\n strategy: Strategy;\n transports: TransportStrategyDictionary;\n ttl: number;\n usingTLS: boolean;\n timeline: Timeline;\n\n constructor(\n strategy: Strategy,\n transports: TransportStrategyDictionary,\n options: StrategyOptions\n ) {\n this.strategy = strategy;\n this.transports = transports;\n this.ttl = options.ttl || 1800 * 1000;\n this.usingTLS = options.useTLS;\n this.timeline = options.timeline;\n }\n\n isSupported(): boolean {\n return this.strategy.isSupported();\n }\n\n connect(minPriority: number, callback: Function) {\n var usingTLS = this.usingTLS;\n var info = fetchTransportCache(usingTLS);\n var cacheSkipCount = info && info.cacheSkipCount ? info.cacheSkipCount : 0;\n\n var strategies = [this.strategy];\n if (info && info.timestamp + this.ttl >= Util.now()) {\n var transport = this.transports[info.transport];\n if (transport) {\n if (['ws', 'wss'].includes(info.transport) || cacheSkipCount > 3) {\n this.timeline.info({\n cached: true,\n transport: info.transport,\n latency: info.latency\n });\n strategies.push(\n new SequentialStrategy([transport], {\n timeout: info.latency * 2 + 1000,\n failFast: true\n })\n );\n } else {\n cacheSkipCount++;\n }\n }\n }\n\n var startTimestamp = Util.now();\n var runner = strategies\n .pop()\n .connect(minPriority, function cb(error, handshake) {\n if (error) {\n flushTransportCache(usingTLS);\n if (strategies.length > 0) {\n startTimestamp = Util.now();\n runner = strategies.pop().connect(minPriority, cb);\n } else {\n callback(error);\n }\n } else {\n storeTransportCache(\n usingTLS,\n handshake.transport.name,\n Util.now() - startTimestamp,\n cacheSkipCount\n );\n callback(null, handshake);\n }\n });\n\n return {\n abort: function() {\n runner.abort();\n },\n forceMinPriority: function(p) {\n minPriority = p;\n if (runner) {\n runner.forceMinPriority(p);\n }\n }\n };\n }\n}\n\nfunction getTransportCacheKey(usingTLS: boolean): string {\n return 'pusherTransport' + (usingTLS ? 'TLS' : 'NonTLS');\n}\n\nfunction fetchTransportCache(usingTLS: boolean): any {\n var storage = Runtime.getLocalStorage();\n if (storage) {\n try {\n var serializedCache = storage[getTransportCacheKey(usingTLS)];\n if (serializedCache) {\n return JSON.parse(serializedCache);\n }\n } catch (e) {\n flushTransportCache(usingTLS);\n }\n }\n return null;\n}\n\nfunction storeTransportCache(\n usingTLS: boolean,\n transport: TransportStrategy,\n latency: number,\n cacheSkipCount: number\n) {\n var storage = Runtime.getLocalStorage();\n if (storage) {\n try {\n storage[getTransportCacheKey(usingTLS)] = Collections.safeJSONStringify({\n timestamp: Util.now(),\n transport: transport,\n latency: latency,\n cacheSkipCount: cacheSkipCount\n });\n } catch (e) {\n // catch over quota exceptions raised by localStorage\n }\n }\n}\n\nfunction flushTransportCache(usingTLS: boolean) {\n var storage = Runtime.getLocalStorage();\n if (storage) {\n try {\n delete storage[getTransportCacheKey(usingTLS)];\n } catch (e) {\n // catch exceptions raised by localStorage\n }\n }\n}\n","import { OneOffTimer as Timer } from '../utils/timers';\nimport Strategy from './strategy';\nimport StrategyOptions from './strategy_options';\n\n/** Runs substrategy after specified delay.\n *\n * Options:\n * - delay - time in miliseconds to delay the substrategy attempt\n *\n * @param {Strategy} strategy\n * @param {Object} options\n */\nexport default class DelayedStrategy implements Strategy {\n strategy: Strategy;\n options: { delay: number };\n\n constructor(strategy: Strategy, { delay: number }) {\n this.strategy = strategy;\n this.options = { delay: number };\n }\n\n isSupported(): boolean {\n return this.strategy.isSupported();\n }\n\n connect(minPriority: number, callback: Function) {\n var strategy = this.strategy;\n var runner;\n var timer = new Timer(this.options.delay, function() {\n runner = strategy.connect(minPriority, callback);\n });\n\n return {\n abort: function() {\n timer.ensureAborted();\n if (runner) {\n runner.abort();\n }\n },\n forceMinPriority: function(p) {\n minPriority = p;\n if (runner) {\n runner.forceMinPriority(p);\n }\n }\n };\n }\n}\n","import Strategy from './strategy';\nimport StrategyRunner from './strategy_runner';\n\n/** Proxies method calls to one of substrategies basing on the test function.\n *\n * @param {Function} test\n * @param {Strategy} trueBranch strategy used when test returns true\n * @param {Strategy} falseBranch strategy used when test returns false\n */\nexport default class IfStrategy implements Strategy {\n test: () => boolean;\n trueBranch: Strategy;\n falseBranch: Strategy;\n\n constructor(\n test: () => boolean,\n trueBranch: Strategy,\n falseBranch: Strategy\n ) {\n this.test = test;\n this.trueBranch = trueBranch;\n this.falseBranch = falseBranch;\n }\n\n isSupported(): boolean {\n var branch = this.test() ? this.trueBranch : this.falseBranch;\n return branch.isSupported();\n }\n\n connect(minPriority: number, callback: Function): StrategyRunner {\n var branch = this.test() ? this.trueBranch : this.falseBranch;\n return branch.connect(minPriority, callback);\n }\n}\n","import Strategy from './strategy';\nimport StrategyRunner from './strategy_runner';\n\n/** Launches the substrategy and terminates on the first open connection.\n *\n * @param {Strategy} strategy\n */\nexport default class FirstConnectedStrategy implements Strategy {\n strategy: Strategy;\n\n constructor(strategy: Strategy) {\n this.strategy = strategy;\n }\n\n isSupported(): boolean {\n return this.strategy.isSupported();\n }\n\n connect(minPriority: number, callback: Function): StrategyRunner {\n var runner = this.strategy.connect(minPriority, function(error, handshake) {\n if (handshake) {\n runner.abort();\n }\n callback(error, handshake);\n });\n return runner;\n }\n}\n","import * as Collections from 'core/utils/collections';\nimport TransportManager from 'core/transports/transport_manager';\nimport Strategy from 'core/strategies/strategy';\nimport SequentialStrategy from 'core/strategies/sequential_strategy';\nimport BestConnectedEverStrategy from 'core/strategies/best_connected_ever_strategy';\nimport WebSocketPrioritizedCachedStrategy, {\n TransportStrategyDictionary\n} from 'core/strategies/websocket_prioritized_cached_strategy';\nimport DelayedStrategy from 'core/strategies/delayed_strategy';\nimport IfStrategy from 'core/strategies/if_strategy';\nimport FirstConnectedStrategy from 'core/strategies/first_connected_strategy';\nimport { Config } from 'core/config';\nimport StrategyOptions from 'core/strategies/strategy_options';\n\nfunction testSupportsStrategy(strategy: Strategy) {\n return function() {\n return strategy.isSupported();\n };\n}\n\nvar getDefaultStrategy = function(\n config: Config,\n baseOptions: StrategyOptions,\n defineTransport: Function\n): Strategy {\n var definedTransports = {};\n\n function defineTransportStrategy(\n name: string,\n type: string,\n priority: number,\n options: StrategyOptions,\n manager?: TransportManager\n ) {\n var transport = defineTransport(\n config,\n name,\n type,\n priority,\n options,\n manager\n );\n\n definedTransports[name] = transport;\n\n return transport;\n }\n\n var ws_options: StrategyOptions = Object.assign({}, baseOptions, {\n hostNonTLS: config.wsHost + ':' + config.wsPort,\n hostTLS: config.wsHost + ':' + config.wssPort,\n httpPath: config.wsPath\n });\n var wss_options: StrategyOptions = Collections.extend({}, ws_options, {\n useTLS: true\n });\n var http_options: StrategyOptions = Object.assign({}, baseOptions, {\n hostNonTLS: config.httpHost + ':' + config.httpPort,\n hostTLS: config.httpHost + ':' + config.httpsPort,\n httpPath: config.httpPath\n });\n var timeouts = {\n loop: true,\n timeout: 15000,\n timeoutLimit: 60000\n };\n\n var ws_manager = new TransportManager({\n minPingDelay: 10000,\n maxPingDelay: config.activityTimeout\n });\n var streaming_manager = new TransportManager({\n lives: 2,\n minPingDelay: 10000,\n maxPingDelay: config.activityTimeout\n });\n\n var ws_transport = defineTransportStrategy(\n 'ws',\n 'ws',\n 3,\n ws_options,\n ws_manager\n );\n var wss_transport = defineTransportStrategy(\n 'wss',\n 'ws',\n 3,\n wss_options,\n ws_manager\n );\n var xhr_streaming_transport = defineTransportStrategy(\n 'xhr_streaming',\n 'xhr_streaming',\n 1,\n http_options,\n streaming_manager\n );\n var xhr_polling_transport = defineTransportStrategy(\n 'xhr_polling',\n 'xhr_polling',\n 1,\n http_options\n );\n\n var ws_loop = new SequentialStrategy([ws_transport], timeouts);\n var wss_loop = new SequentialStrategy([wss_transport], timeouts);\n var streaming_loop = new SequentialStrategy(\n [xhr_streaming_transport],\n timeouts\n );\n var polling_loop = new SequentialStrategy([xhr_polling_transport], timeouts);\n\n var http_loop = new SequentialStrategy(\n [\n new IfStrategy(\n testSupportsStrategy(streaming_loop),\n new BestConnectedEverStrategy([\n streaming_loop,\n new DelayedStrategy(polling_loop, { delay: 4000 })\n ]),\n polling_loop\n )\n ],\n timeouts\n );\n\n var wsStrategy;\n if (baseOptions.useTLS) {\n wsStrategy = new BestConnectedEverStrategy([\n ws_loop,\n new DelayedStrategy(http_loop, { delay: 2000 })\n ]);\n } else {\n wsStrategy = new BestConnectedEverStrategy([\n ws_loop,\n new DelayedStrategy(wss_loop, { delay: 2000 }),\n new DelayedStrategy(http_loop, { delay: 5000 })\n ]);\n }\n\n return new WebSocketPrioritizedCachedStrategy(\n new FirstConnectedStrategy(\n new IfStrategy(testSupportsStrategy(ws_transport), wsStrategy, http_loop)\n ),\n definedTransports,\n {\n ttl: 1800000,\n timeline: baseOptions.timeline,\n useTLS: baseOptions.useTLS\n }\n );\n};\n\nexport default getDefaultStrategy;\n","/** Initializes the transport.\n *\n * Fetches resources if needed and then transitions to initialized.\n */\nexport default function() {\n var self = this;\n\n self.timeline.info(\n self.buildTimelineMessage({\n transport: self.name + (self.options.useTLS ? 's' : '')\n })\n );\n\n if (self.hooks.isInitialized()) {\n self.changeState('initialized');\n } else {\n self.onClose();\n }\n}\n","import Runtime from 'runtime';\nimport RequestHooks from './request_hooks';\nimport Ajax from './ajax';\nimport { default as EventsDispatcher } from '../events/dispatcher';\n\nconst MAX_BUFFER_LENGTH = 256 * 1024;\n\nexport default class HTTPRequest extends EventsDispatcher {\n hooks: RequestHooks;\n method: string;\n url: string;\n position: number;\n xhr: Ajax;\n unloader: Function;\n\n constructor(hooks: RequestHooks, method: string, url: string) {\n super();\n this.hooks = hooks;\n this.method = method;\n this.url = url;\n }\n\n start(payload?: any) {\n this.position = 0;\n this.xhr = this.hooks.getRequest(this);\n\n this.unloader = () => {\n this.close();\n };\n Runtime.addUnloadListener(this.unloader);\n\n this.xhr.open(this.method, this.url, true);\n\n if (this.xhr.setRequestHeader) {\n this.xhr.setRequestHeader('Content-Type', 'application/json'); // ReactNative doesn't set this header by default.\n }\n this.xhr.send(payload);\n }\n\n close() {\n if (this.unloader) {\n Runtime.removeUnloadListener(this.unloader);\n this.unloader = null;\n }\n if (this.xhr) {\n this.hooks.abortRequest(this.xhr);\n this.xhr = null;\n }\n }\n\n onChunk(status: number, data: any) {\n while (true) {\n var chunk = this.advanceBuffer(data);\n if (chunk) {\n this.emit('chunk', { status: status, data: chunk });\n } else {\n break;\n }\n }\n if (this.isBufferTooLong(data)) {\n this.emit('buffer_too_long');\n }\n }\n\n private advanceBuffer(buffer: any[]): any {\n var unreadData = buffer.slice(this.position);\n var endOfLinePosition = unreadData.indexOf('\\n');\n\n if (endOfLinePosition !== -1) {\n this.position += endOfLinePosition + 1;\n return unreadData.slice(0, endOfLinePosition);\n } else {\n // chunk is not finished yet, don't move the buffer pointer\n return null;\n }\n }\n\n private isBufferTooLong(buffer: any): boolean {\n return this.position === buffer.length && buffer.length > MAX_BUFFER_LENGTH;\n }\n}\n","enum State {\n CONNECTING = 0,\n OPEN = 1,\n CLOSED = 3\n}\n\nexport default State;\n","import URLLocation from './url_location';\nimport State from './state';\nimport Socket from '../socket';\nimport SocketHooks from './socket_hooks';\nimport Util from '../util';\nimport Ajax from './ajax';\nimport HTTPRequest from './http_request';\nimport Runtime from 'runtime';\n\nvar autoIncrement = 1;\n\nclass HTTPSocket implements Socket {\n hooks: SocketHooks;\n session: string;\n location: URLLocation;\n readyState: State;\n stream: HTTPRequest;\n\n onopen: () => void;\n onerror: (error: any) => void;\n onclose: (closeEvent: any) => void;\n onmessage: (message: any) => void;\n onactivity: () => void;\n\n constructor(hooks: SocketHooks, url: string) {\n this.hooks = hooks;\n this.session = randomNumber(1000) + '/' + randomString(8);\n this.location = getLocation(url);\n this.readyState = State.CONNECTING;\n this.openStream();\n }\n\n send(payload: any) {\n return this.sendRaw(JSON.stringify([payload]));\n }\n\n ping() {\n this.hooks.sendHeartbeat(this);\n }\n\n close(code: any, reason: any) {\n this.onClose(code, reason, true);\n }\n\n /** For internal use only */\n sendRaw(payload: any): boolean {\n if (this.readyState === State.OPEN) {\n try {\n Runtime.createSocketRequest(\n 'POST',\n getUniqueURL(getSendURL(this.location, this.session))\n ).start(payload);\n return true;\n } catch (e) {\n return false;\n }\n } else {\n return false;\n }\n }\n\n /** For internal use only */\n reconnect() {\n this.closeStream();\n this.openStream();\n }\n\n /** For internal use only */\n onClose(code, reason, wasClean) {\n this.closeStream();\n this.readyState = State.CLOSED;\n if (this.onclose) {\n this.onclose({\n code: code,\n reason: reason,\n wasClean: wasClean\n });\n }\n }\n\n private onChunk(chunk) {\n if (chunk.status !== 200) {\n return;\n }\n if (this.readyState === State.OPEN) {\n this.onActivity();\n }\n\n var payload;\n var type = chunk.data.slice(0, 1);\n switch (type) {\n case 'o':\n payload = JSON.parse(chunk.data.slice(1) || '{}');\n this.onOpen(payload);\n break;\n case 'a':\n payload = JSON.parse(chunk.data.slice(1) || '[]');\n for (var i = 0; i < payload.length; i++) {\n this.onEvent(payload[i]);\n }\n break;\n case 'm':\n payload = JSON.parse(chunk.data.slice(1) || 'null');\n this.onEvent(payload);\n break;\n case 'h':\n this.hooks.onHeartbeat(this);\n break;\n case 'c':\n payload = JSON.parse(chunk.data.slice(1) || '[]');\n this.onClose(payload[0], payload[1], true);\n break;\n }\n }\n\n private onOpen(options) {\n if (this.readyState === State.CONNECTING) {\n if (options && options.hostname) {\n this.location.base = replaceHost(this.location.base, options.hostname);\n }\n this.readyState = State.OPEN;\n\n if (this.onopen) {\n this.onopen();\n }\n } else {\n this.onClose(1006, 'Server lost session', true);\n }\n }\n\n private onEvent(event) {\n if (this.readyState === State.OPEN && this.onmessage) {\n this.onmessage({ data: event });\n }\n }\n\n private onActivity() {\n if (this.onactivity) {\n this.onactivity();\n }\n }\n\n private onError(error) {\n if (this.onerror) {\n this.onerror(error);\n }\n }\n\n private openStream() {\n this.stream = Runtime.createSocketRequest(\n 'POST',\n getUniqueURL(this.hooks.getReceiveURL(this.location, this.session))\n );\n\n this.stream.bind('chunk', chunk => {\n this.onChunk(chunk);\n });\n this.stream.bind('finished', status => {\n this.hooks.onFinished(this, status);\n });\n this.stream.bind('buffer_too_long', () => {\n this.reconnect();\n });\n\n try {\n this.stream.start();\n } catch (error) {\n Util.defer(() => {\n this.onError(error);\n this.onClose(1006, 'Could not start streaming', false);\n });\n }\n }\n\n private closeStream() {\n if (this.stream) {\n this.stream.unbind_all();\n this.stream.close();\n this.stream = null;\n }\n }\n}\n\nfunction getLocation(url): URLLocation {\n var parts = /([^\\?]*)\\/*(\\??.*)/.exec(url);\n return {\n base: parts[1],\n queryString: parts[2]\n };\n}\n\nfunction getSendURL(url: URLLocation, session: string): string {\n return url.base + '/' + session + '/xhr_send';\n}\n\nfunction getUniqueURL(url: string): string {\n var separator = url.indexOf('?') === -1 ? '?' : '&';\n return url + separator + 't=' + +new Date() + '&n=' + autoIncrement++;\n}\n\nfunction replaceHost(url: string, hostname: string): string {\n var urlParts = /(https?:\\/\\/)([^\\/:]+)((\\/|:)?.*)/.exec(url);\n return urlParts[1] + hostname + urlParts[3];\n}\n\nfunction randomNumber(max: number): number {\n return Runtime.randomInt(max);\n}\n\nfunction randomString(length: number): string {\n var result = [];\n\n for (var i = 0; i < length; i++) {\n result.push(randomNumber(32).toString(32));\n }\n\n return result.join('');\n}\n\nexport default HTTPSocket;\n","import SocketHooks from './socket_hooks';\nimport HTTPSocket from './http_socket';\n\nvar hooks: SocketHooks = {\n getReceiveURL: function(url, session) {\n return url.base + '/' + session + '/xhr_streaming' + url.queryString;\n },\n onHeartbeat: function(socket) {\n socket.sendRaw('[]');\n },\n sendHeartbeat: function(socket) {\n socket.sendRaw('[]');\n },\n onFinished: function(socket, status) {\n socket.onClose(1006, 'Connection interrupted (' + status + ')', false);\n }\n};\n\nexport default hooks;\n","import SocketHooks from './socket_hooks';\nimport URLLocation from './url_location';\nimport HTTPSocket from './http_socket';\n\nvar hooks: SocketHooks = {\n getReceiveURL: function(url: URLLocation, session: string): string {\n return url.base + '/' + session + '/xhr' + url.queryString;\n },\n onHeartbeat: function() {\n // next HTTP request will reset server's activity timer\n },\n sendHeartbeat: function(socket) {\n socket.sendRaw('[]');\n },\n onFinished: function(socket, status) {\n if (status === 200) {\n socket.reconnect();\n } else {\n socket.onClose(1006, 'Connection interrupted (' + status + ')', false);\n }\n }\n};\n\nexport default hooks;\n","import HTTPRequest from 'core/http/http_request';\nimport RequestHooks from 'core/http/request_hooks';\nimport Ajax from 'core/http/ajax';\nimport Runtime from 'runtime';\n\nvar hooks: RequestHooks = {\n getRequest: function(socket: HTTPRequest): Ajax {\n var Constructor = Runtime.getXHRAPI();\n var xhr = new Constructor();\n xhr.onreadystatechange = xhr.onprogress = function() {\n switch (xhr.readyState) {\n case 3:\n if (xhr.responseText && xhr.responseText.length > 0) {\n socket.onChunk(xhr.status, xhr.responseText);\n }\n break;\n case 4:\n // this happens only on errors, never after calling close\n if (xhr.responseText && xhr.responseText.length > 0) {\n socket.onChunk(xhr.status, xhr.responseText);\n }\n socket.emit('finished', xhr.status);\n socket.close();\n break;\n }\n };\n return xhr;\n },\n abortRequest: function(xhr: Ajax) {\n xhr.onreadystatechange = null;\n xhr.abort();\n }\n};\n\nexport default hooks;\n","import HTTPRequest from 'core/http/http_request';\nimport HTTPSocket from 'core/http/http_socket';\nimport SocketHooks from 'core/http/socket_hooks';\nimport RequestHooks from 'core/http/request_hooks';\nimport streamingHooks from 'core/http/http_streaming_socket';\nimport pollingHooks from 'core/http/http_polling_socket';\nimport xhrHooks from './http_xhr_request';\nimport HTTPFactory from 'core/http/http_factory';\n\nvar HTTP: HTTPFactory = {\n createStreamingSocket(url: string): HTTPSocket {\n return this.createSocket(streamingHooks, url);\n },\n\n createPollingSocket(url: string): HTTPSocket {\n return this.createSocket(pollingHooks, url);\n },\n\n createSocket(hooks: SocketHooks, url: string): HTTPSocket {\n return new HTTPSocket(hooks, url);\n },\n\n createXHR(method: string, url: string): HTTPRequest {\n return this.createRequest(xhrHooks, method, url);\n },\n\n createRequest(hooks: RequestHooks, method: string, url: string): HTTPRequest {\n return new HTTPRequest(hooks, method, url);\n }\n};\n\nexport default HTTP;\n","import * as Collections from 'core/utils/collections';\nimport Transports from 'isomorphic/transports/transports';\nimport TimelineSender from 'core/timeline/timeline_sender';\nimport Ajax from 'core/http/ajax';\nimport getDefaultStrategy from './default_strategy';\nimport TransportsTable from 'core/transports/transports_table';\nimport transportConnectionInitializer from './transports/transport_connection_initializer';\nimport HTTPFactory from './http/http';\n\nvar Isomorphic: any = {\n getDefaultStrategy,\n Transports: Transports,\n transportConnectionInitializer,\n HTTPFactory,\n\n setup(PusherClass): void {\n PusherClass.ready();\n },\n\n getLocalStorage(): any {\n return undefined;\n },\n\n getClientFeatures(): any[] {\n return Collections.keys(\n Collections.filterObject({ ws: Transports.ws }, function(t) {\n return t.isSupported({});\n })\n );\n },\n\n getProtocol(): string {\n return 'http:';\n },\n\n isXHRSupported(): boolean {\n return true;\n },\n\n createSocketRequest(method: string, url: string) {\n if (this.isXHRSupported()) {\n return this.HTTPFactory.createXHR(method, url);\n } else {\n throw 'Cross-origin HTTP requests are not supported';\n }\n },\n\n createXHR(): Ajax {\n var Constructor = this.getXHRAPI();\n return new Constructor();\n },\n\n createWebSocket(url: string): any {\n var Constructor = this.getWebSocketAPI();\n return new Constructor(url);\n },\n\n addUnloadListener(listener: any) {},\n removeUnloadListener(listener: any) {}\n};\n\nexport default Isomorphic;\n","import { default as EventsDispatcher } from 'core/events/dispatcher';\nimport Reachability from 'core/reachability';\n\nexport class NetInfo extends EventsDispatcher implements Reachability {\n isOnline(): boolean {\n return true;\n }\n}\n\nexport var Network = new NetInfo();\n","export enum AuthRequestType {\n UserAuthentication = 'user-authentication',\n ChannelAuthorization = 'channel-authorization'\n}\n\nexport interface ChannelAuthorizationData {\n auth: string;\n channel_data?: string;\n shared_secret?: string;\n}\n\nexport type ChannelAuthorizationCallback = (\n error: Error | null,\n authData: ChannelAuthorizationData | null\n) => void;\n\nexport interface ChannelAuthorizationRequestParams {\n socketId: string;\n channelName: string;\n}\n\nexport interface ChannelAuthorizationHandler {\n (\n params: ChannelAuthorizationRequestParams,\n callback: ChannelAuthorizationCallback\n ): void;\n}\n\nexport interface UserAuthenticationData {\n auth: string;\n user_data: string;\n}\n\nexport type UserAuthenticationCallback = (\n error: Error | null,\n authData: UserAuthenticationData | null\n) => void;\n\nexport interface UserAuthenticationRequestParams {\n socketId: string;\n}\n\nexport interface UserAuthenticationHandler {\n (\n params: UserAuthenticationRequestParams,\n callback: UserAuthenticationCallback\n ): void;\n}\n\nexport type AuthTransportCallback =\n | ChannelAuthorizationCallback\n | UserAuthenticationCallback;\n\nexport interface AuthOptionsT {\n transport: 'ajax' | 'jsonp';\n endpoint: string;\n params?: any;\n headers?: any;\n paramsProvider?: () => any;\n headersProvider?: () => any;\n customHandler?: AuthHandler;\n}\n\nexport declare type UserAuthenticationOptions = AuthOptionsT<\n UserAuthenticationHandler\n>;\nexport declare type ChannelAuthorizationOptions = AuthOptionsT<\n ChannelAuthorizationHandler\n>;\n\nexport interface InternalAuthOptions {\n transport: 'ajax' | 'jsonp';\n endpoint: string;\n params?: any;\n headers?: any;\n paramsProvider?: () => any;\n headersProvider?: () => any;\n}\n","import TimelineSender from 'core/timeline/timeline_sender';\nimport * as Collections from 'core/utils/collections';\nimport Util from 'core/util';\nimport Runtime from 'runtime';\nimport { AuthTransport } from 'core/auth/auth_transports';\nimport AbstractRuntime from 'runtimes/interface';\nimport UrlStore from 'core/utils/url_store';\nimport {\n AuthRequestType,\n AuthTransportCallback,\n InternalAuthOptions\n} from 'core/auth/options';\nimport { HTTPAuthError } from 'core/errors';\n\nconst ajax: AuthTransport = function(\n context: AbstractRuntime,\n query: string,\n authOptions: InternalAuthOptions,\n authRequestType: AuthRequestType,\n callback: AuthTransportCallback\n) {\n const xhr = Runtime.createXHR();\n xhr.open('POST', authOptions.endpoint, true);\n\n // add request headers\n xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');\n for (var headerName in authOptions.headers) {\n xhr.setRequestHeader(headerName, authOptions.headers[headerName]);\n }\n if (authOptions.headersProvider != null) {\n let dynamicHeaders = authOptions.headersProvider();\n for (var headerName in dynamicHeaders) {\n xhr.setRequestHeader(headerName, dynamicHeaders[headerName]);\n }\n }\n\n xhr.onreadystatechange = function() {\n if (xhr.readyState === 4) {\n if (xhr.status === 200) {\n let data;\n let parsed = false;\n\n try {\n data = JSON.parse(xhr.responseText);\n parsed = true;\n } catch (e) {\n callback(\n new HTTPAuthError(\n 200,\n `JSON returned from ${authRequestType.toString()} endpoint was invalid, yet status code was 200. Data was: ${\n xhr.responseText\n }`\n ),\n null\n );\n }\n\n if (parsed) {\n // prevents double execution.\n callback(null, data);\n }\n } else {\n let suffix = '';\n switch (authRequestType) {\n case AuthRequestType.UserAuthentication:\n suffix = UrlStore.buildLogSuffix('authenticationEndpoint');\n break;\n case AuthRequestType.ChannelAuthorization:\n suffix = `Clients must be authorized to join private or presence channels. ${UrlStore.buildLogSuffix(\n 'authorizationEndpoint'\n )}`;\n break;\n }\n callback(\n new HTTPAuthError(\n xhr.status,\n `Unable to retrieve auth string from ${authRequestType.toString()} endpoint - ` +\n `received status: ${xhr.status} from ${authOptions.endpoint}. ${suffix}`\n ),\n null\n );\n }\n }\n };\n\n xhr.send(query);\n return xhr;\n};\n\nexport default ajax;\n","import Logger from 'core/logger';\nimport TimelineSender from 'core/timeline/timeline_sender';\nimport * as Collections from 'core/utils/collections';\nimport Util from 'core/util';\nimport Runtime from 'runtime';\nimport TimelineTransport from 'core/timeline/timeline_transport';\n\nvar getAgent = function(sender: TimelineSender, useTLS: boolean) {\n return function(data: any, callback: Function) {\n var scheme = 'http' + (useTLS ? 's' : '') + '://';\n var url =\n scheme + (sender.host || sender.options.host) + sender.options.path;\n var query = Collections.buildQueryString(data);\n\n url += '/' + 2 + '?' + query;\n\n var xhr = Runtime.createXHR();\n xhr.open('GET', url, true);\n\n xhr.onreadystatechange = function() {\n if (xhr.readyState === 4) {\n let { status, responseText } = xhr;\n if (status !== 200) {\n Logger.debug(\n `TimelineSender Error: received ${status} from stats.pusher.com`\n );\n return;\n }\n\n try {\n var { host } = JSON.parse(responseText);\n } catch (e) {\n Logger.debug(`TimelineSenderError: invalid response ${responseText}`);\n }\n if (host) {\n sender.host = host;\n }\n }\n };\n\n xhr.send();\n };\n};\n\nvar xhr = {\n name: 'xhr',\n getAgent\n};\n\nexport default xhr;\n","import Isomorphic from 'isomorphic/runtime';\nimport { Client as WebSocket } from 'faye-websocket';\nimport { XMLHttpRequest } from 'xmlhttprequest';\nimport Runtime from '../interface';\nimport { Network } from './net_info';\nimport xhrAuth from 'isomorphic/auth/xhr_auth';\nimport { AuthTransports } from 'core/auth/auth_transports';\nimport xhrTimeline from 'isomorphic/timeline/xhr_timeline';\nimport { randomInt } from 'crypto';\n\n// Very verbose but until unavoidable until\n// TypeScript 2.1, when spread attributes will be\n// supported\nconst {\n getDefaultStrategy,\n Transports,\n setup,\n getProtocol,\n isXHRSupported,\n getLocalStorage,\n createXHR,\n createWebSocket,\n addUnloadListener,\n removeUnloadListener,\n transportConnectionInitializer,\n createSocketRequest,\n HTTPFactory\n} = Isomorphic;\n\nconst NodeJS: Runtime = {\n getDefaultStrategy,\n Transports,\n setup,\n getProtocol,\n isXHRSupported,\n createSocketRequest,\n getLocalStorage,\n createXHR,\n createWebSocket,\n addUnloadListener,\n removeUnloadListener,\n transportConnectionInitializer,\n HTTPFactory,\n\n TimelineTransport: xhrTimeline,\n\n getAuthorizers(): AuthTransports {\n return { ajax: xhrAuth };\n },\n\n getWebSocketAPI() {\n return WebSocket;\n },\n\n getXHRAPI() {\n return XMLHttpRequest;\n },\n\n getNetwork() {\n return Network;\n },\n\n randomInt(max: number): number {\n return randomInt(max);\n }\n};\n\nexport default NodeJS;\n","enum TimelineLevel {\n ERROR = 3,\n INFO = 6,\n DEBUG = 7\n}\n\nexport default TimelineLevel;\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport { default as Level } from './level';\n\nexport interface TimelineOptions {\n level?: Level;\n limit?: number;\n version?: string;\n cluster?: string;\n features?: string[];\n params?: any;\n}\n\nexport default class Timeline {\n key: string;\n session: number;\n events: any[];\n options: TimelineOptions;\n sent: number;\n uniqueID: number;\n\n constructor(key: string, session: number, options: TimelineOptions) {\n this.key = key;\n this.session = session;\n this.events = [];\n this.options = options || {};\n this.sent = 0;\n this.uniqueID = 0;\n }\n\n log(level, event) {\n if (level <= this.options.level) {\n this.events.push(\n Collections.extend({}, event, { timestamp: Util.now() })\n );\n if (this.options.limit && this.events.length > this.options.limit) {\n this.events.shift();\n }\n }\n }\n\n error(event) {\n this.log(Level.ERROR, event);\n }\n\n info(event) {\n this.log(Level.INFO, event);\n }\n\n debug(event) {\n this.log(Level.DEBUG, event);\n }\n\n isEmpty() {\n return this.events.length === 0;\n }\n\n send(sendfn, callback) {\n var data = Collections.extend(\n {\n session: this.session,\n bundle: this.sent + 1,\n key: this.key,\n lib: 'js',\n version: this.options.version,\n cluster: this.options.cluster,\n features: this.options.features,\n timeline: this.events\n },\n this.options.params\n );\n\n this.events = [];\n sendfn(data, (error, result) => {\n if (!error) {\n this.sent++;\n }\n if (callback) {\n callback(error, result);\n }\n });\n\n return true;\n }\n\n generateUniqueID(): number {\n this.uniqueID++;\n return this.uniqueID;\n }\n}\n","import Factory from '../utils/factory';\nimport Util from '../util';\nimport * as Errors from '../errors';\nimport * as Collections from '../utils/collections';\nimport Strategy from './strategy';\nimport Transport from '../transports/transport';\nimport StrategyOptions from './strategy_options';\nimport Handshake from '../connection/handshake';\n\n/** Provides a strategy interface for transports.\n *\n * @param {String} name\n * @param {Number} priority\n * @param {Class} transport\n * @param {Object} options\n */\nexport default class TransportStrategy implements Strategy {\n name: string;\n priority: number;\n transport: Transport;\n options: StrategyOptions;\n\n constructor(\n name: string,\n priority: number,\n transport: Transport,\n options: StrategyOptions\n ) {\n this.name = name;\n this.priority = priority;\n this.transport = transport;\n this.options = options || {};\n }\n\n /** Returns whether the transport is supported in the browser.\n *\n * @returns {Boolean}\n */\n isSupported(): boolean {\n return this.transport.isSupported({\n useTLS: this.options.useTLS\n });\n }\n\n /** Launches a connection attempt and returns a strategy runner.\n *\n * @param {Function} callback\n * @return {Object} strategy runner\n */\n connect(minPriority: number, callback: Function) {\n if (!this.isSupported()) {\n return failAttempt(new Errors.UnsupportedStrategy(), callback);\n } else if (this.priority < minPriority) {\n return failAttempt(new Errors.TransportPriorityTooLow(), callback);\n }\n\n var connected = false;\n var transport = this.transport.createConnection(\n this.name,\n this.priority,\n this.options.key,\n this.options\n );\n var handshake = null;\n\n var onInitialized = function() {\n transport.unbind('initialized', onInitialized);\n transport.connect();\n };\n var onOpen = function() {\n handshake = Factory.createHandshake(transport, function(result) {\n connected = true;\n unbindListeners();\n callback(null, result);\n });\n };\n var onError = function(error) {\n unbindListeners();\n callback(error);\n };\n var onClosed = function() {\n unbindListeners();\n var serializedTransport;\n\n // The reason for this try/catch block is that on React Native\n // the WebSocket object is circular. Therefore transport.socket will\n // throw errors upon stringification. Collections.safeJSONStringify\n // discards circular references when serializing.\n serializedTransport = Collections.safeJSONStringify(transport);\n callback(new Errors.TransportClosed(serializedTransport));\n };\n\n var unbindListeners = function() {\n transport.unbind('initialized', onInitialized);\n transport.unbind('open', onOpen);\n transport.unbind('error', onError);\n transport.unbind('closed', onClosed);\n };\n\n transport.bind('initialized', onInitialized);\n transport.bind('open', onOpen);\n transport.bind('error', onError);\n transport.bind('closed', onClosed);\n\n // connect will be called automatically after initialization\n transport.initialize();\n\n return {\n abort: () => {\n if (connected) {\n return;\n }\n unbindListeners();\n if (handshake) {\n handshake.close();\n } else {\n transport.close();\n }\n },\n forceMinPriority: p => {\n if (connected) {\n return;\n }\n if (this.priority < p) {\n if (handshake) {\n handshake.close();\n } else {\n transport.close();\n }\n }\n }\n };\n }\n}\n\nfunction failAttempt(error: Error, callback: Function) {\n Util.defer(function() {\n callback(error);\n });\n return {\n abort: function() {},\n forceMinPriority: function() {}\n };\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport TransportManager from '../transports/transport_manager';\nimport * as Errors from '../errors';\nimport Strategy from './strategy';\nimport TransportStrategy from './transport_strategy';\nimport StrategyOptions from '../strategies/strategy_options';\nimport { Config } from '../config';\nimport Runtime from 'runtime';\n\nconst { Transports } = Runtime;\n\nexport var defineTransport = function(\n config: Config,\n name: string,\n type: string,\n priority: number,\n options: StrategyOptions,\n manager?: TransportManager\n): Strategy {\n var transportClass = Transports[type];\n if (!transportClass) {\n throw new Errors.UnsupportedTransport(type);\n }\n\n var enabled =\n (!config.enabledTransports ||\n Collections.arrayIndexOf(config.enabledTransports, name) !== -1) &&\n (!config.disabledTransports ||\n Collections.arrayIndexOf(config.disabledTransports, name) === -1);\n\n var transport;\n if (enabled) {\n options = Object.assign(\n { ignoreNullOrigin: config.ignoreNullOrigin },\n options\n );\n\n transport = new TransportStrategy(\n name,\n priority,\n manager ? manager.getAssistant(transportClass) : transportClass,\n options\n );\n } else {\n transport = UnsupportedStrategy;\n }\n\n return transport;\n};\n\nvar UnsupportedStrategy: Strategy = {\n isSupported: function() {\n return false;\n },\n connect: function(_, callback) {\n var deferred = Util.defer(function() {\n callback(new Errors.UnsupportedStrategy());\n });\n return {\n abort: function() {\n deferred.ensureAborted();\n },\n forceMinPriority: function() {}\n };\n }\n};\n","import ConnectionManager from './connection/connection_manager';\nimport {\n ChannelAuthorizationOptions,\n UserAuthenticationOptions\n} from './auth/options';\nimport {\n ChannelAuthorizerGenerator,\n DeprecatedAuthOptions\n} from './auth/deprecated_channel_authorizer';\nimport { AuthTransport, Transport } from './config';\nimport * as nacl from 'tweetnacl';\nimport Logger from './logger';\n\nexport interface Options {\n activityTimeout?: number;\n\n auth?: DeprecatedAuthOptions; // DEPRECATED use channelAuthorization instead\n authEndpoint?: string; // DEPRECATED use channelAuthorization instead\n authTransport?: AuthTransport; // DEPRECATED use channelAuthorization instead\n authorizer?: ChannelAuthorizerGenerator; // DEPRECATED use channelAuthorization instead\n\n channelAuthorization?: ChannelAuthorizationOptions;\n userAuthentication?: UserAuthenticationOptions;\n\n cluster: string;\n enableStats?: boolean;\n disableStats?: boolean;\n disabledTransports?: Transport[];\n enabledTransports?: Transport[];\n forceTLS?: boolean;\n httpHost?: string;\n httpPath?: string;\n httpPort?: number;\n httpsPort?: number;\n ignoreNullOrigin?: boolean;\n nacl?: nacl;\n pongTimeout?: number;\n statsHost?: string;\n timelineParams?: any;\n unavailableTimeout?: number;\n wsHost?: string;\n wsPath?: string;\n wsPort?: number;\n wssPort?: number;\n}\n\nexport interface ClusterOptions {\n appKey: string;\n cluster: string;\n}\n\nexport function validateOptions(options) {\n if (options == null) {\n throw 'You must pass an options object';\n }\n if (options.cluster == null) {\n throw 'Options object must provide a cluster';\n }\n if ('disableStats' in options) {\n Logger.warn(\n 'The disableStats option is deprecated in favor of enableStats'\n );\n }\n}\n","import {\n UserAuthenticationCallback,\n InternalAuthOptions,\n UserAuthenticationHandler,\n UserAuthenticationRequestParams,\n AuthRequestType\n} from './options';\n\nimport Runtime from 'runtime';\n\nconst composeChannelQuery = (\n params: UserAuthenticationRequestParams,\n authOptions: InternalAuthOptions\n) => {\n var query = 'socket_id=' + encodeURIComponent(params.socketId);\n\n for (var key in authOptions.params) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(authOptions.params[key]);\n }\n\n if (authOptions.paramsProvider != null) {\n let dynamicParams = authOptions.paramsProvider();\n for (var key in dynamicParams) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(dynamicParams[key]);\n }\n }\n\n return query;\n};\n\nconst UserAuthenticator = (\n authOptions: InternalAuthOptions\n): UserAuthenticationHandler => {\n if (typeof Runtime.getAuthorizers()[authOptions.transport] === 'undefined') {\n throw `'${authOptions.transport}' is not a recognized auth transport`;\n }\n\n return (\n params: UserAuthenticationRequestParams,\n callback: UserAuthenticationCallback\n ) => {\n const query = composeChannelQuery(params, authOptions);\n\n Runtime.getAuthorizers()[authOptions.transport](\n Runtime,\n query,\n authOptions,\n AuthRequestType.UserAuthentication,\n callback\n );\n };\n};\n\nexport default UserAuthenticator;\n","import {\n AuthRequestType,\n InternalAuthOptions,\n ChannelAuthorizationHandler,\n ChannelAuthorizationRequestParams,\n ChannelAuthorizationCallback\n} from './options';\n\nimport Runtime from 'runtime';\n\nconst composeChannelQuery = (\n params: ChannelAuthorizationRequestParams,\n authOptions: InternalAuthOptions\n) => {\n var query = 'socket_id=' + encodeURIComponent(params.socketId);\n\n query += '&channel_name=' + encodeURIComponent(params.channelName);\n\n for (var key in authOptions.params) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(authOptions.params[key]);\n }\n\n if (authOptions.paramsProvider != null) {\n let dynamicParams = authOptions.paramsProvider();\n for (var key in dynamicParams) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(dynamicParams[key]);\n }\n }\n\n return query;\n};\n\nconst ChannelAuthorizer = (\n authOptions: InternalAuthOptions\n): ChannelAuthorizationHandler => {\n if (typeof Runtime.getAuthorizers()[authOptions.transport] === 'undefined') {\n throw `'${authOptions.transport}' is not a recognized auth transport`;\n }\n\n return (\n params: ChannelAuthorizationRequestParams,\n callback: ChannelAuthorizationCallback\n ) => {\n const query = composeChannelQuery(params, authOptions);\n\n Runtime.getAuthorizers()[authOptions.transport](\n Runtime,\n query,\n authOptions,\n AuthRequestType.ChannelAuthorization,\n callback\n );\n };\n};\n\nexport default ChannelAuthorizer;\n","import Channel from '../channels/channel';\nimport {\n ChannelAuthorizationCallback,\n ChannelAuthorizationHandler,\n ChannelAuthorizationRequestParams,\n InternalAuthOptions\n} from './options';\n\nexport interface DeprecatedChannelAuthorizer {\n authorize(socketId: string, callback: ChannelAuthorizationCallback): void;\n}\n\nexport interface ChannelAuthorizerGenerator {\n (\n channel: Channel,\n options: DeprecatedAuthorizerOptions\n ): DeprecatedChannelAuthorizer;\n}\n\nexport interface DeprecatedAuthOptions {\n params?: any;\n headers?: any;\n}\n\nexport interface DeprecatedAuthorizerOptions {\n authTransport: 'ajax' | 'jsonp';\n authEndpoint: string;\n auth?: DeprecatedAuthOptions;\n}\n\nexport const ChannelAuthorizerProxy = (\n pusher,\n authOptions: InternalAuthOptions,\n channelAuthorizerGenerator: ChannelAuthorizerGenerator\n): ChannelAuthorizationHandler => {\n const deprecatedAuthorizerOptions: DeprecatedAuthorizerOptions = {\n authTransport: authOptions.transport,\n authEndpoint: authOptions.endpoint,\n auth: {\n params: authOptions.params,\n headers: authOptions.headers\n }\n };\n return (\n params: ChannelAuthorizationRequestParams,\n callback: ChannelAuthorizationCallback\n ) => {\n const channel = pusher.channel(params.channelName);\n // This line creates a new channel authorizer every time.\n // In the past, this was only done once per channel and reused.\n // We can do that again if we want to keep this behavior intact.\n const channelAuthorizer: DeprecatedChannelAuthorizer = channelAuthorizerGenerator(\n channel,\n deprecatedAuthorizerOptions\n );\n channelAuthorizer.authorize(params.socketId, callback);\n };\n};\n","import { Options } from './options';\nimport Defaults from './defaults';\nimport {\n ChannelAuthorizationHandler,\n UserAuthenticationHandler,\n ChannelAuthorizationOptions\n} from './auth/options';\nimport UserAuthenticator from './auth/user_authenticator';\nimport ChannelAuthorizer from './auth/channel_authorizer';\nimport { ChannelAuthorizerProxy } from './auth/deprecated_channel_authorizer';\nimport Runtime from 'runtime';\nimport * as nacl from 'tweetnacl';\n\nexport type AuthTransport = 'ajax' | 'jsonp';\nexport type Transport =\n | 'ws'\n | 'wss'\n | 'xhr_streaming'\n | 'xhr_polling'\n | 'sockjs';\n\nexport interface Config {\n // these are all 'required' config parameters, it's not necessary for the user\n // to set them, but they have configured defaults.\n activityTimeout: number;\n enableStats: boolean;\n httpHost: string;\n httpPath: string;\n httpPort: number;\n httpsPort: number;\n pongTimeout: number;\n statsHost: string;\n unavailableTimeout: number;\n useTLS: boolean;\n wsHost: string;\n wsPath: string;\n wsPort: number;\n wssPort: number;\n userAuthenticator: UserAuthenticationHandler;\n channelAuthorizer: ChannelAuthorizationHandler;\n\n // these are all optional parameters or overrrides. The customer can set these\n // but it's not strictly necessary\n forceTLS?: boolean;\n cluster?: string;\n disabledTransports?: Transport[];\n enabledTransports?: Transport[];\n ignoreNullOrigin?: boolean;\n nacl?: nacl;\n timelineParams?: any;\n}\n\n// getConfig mainly sets the defaults for the options that are not provided\nexport function getConfig(opts: Options, pusher): Config {\n let config: Config = {\n activityTimeout: opts.activityTimeout || Defaults.activityTimeout,\n cluster: opts.cluster,\n httpPath: opts.httpPath || Defaults.httpPath,\n httpPort: opts.httpPort || Defaults.httpPort,\n httpsPort: opts.httpsPort || Defaults.httpsPort,\n pongTimeout: opts.pongTimeout || Defaults.pongTimeout,\n statsHost: opts.statsHost || Defaults.stats_host,\n unavailableTimeout: opts.unavailableTimeout || Defaults.unavailableTimeout,\n wsPath: opts.wsPath || Defaults.wsPath,\n wsPort: opts.wsPort || Defaults.wsPort,\n wssPort: opts.wssPort || Defaults.wssPort,\n\n enableStats: getEnableStatsConfig(opts),\n httpHost: getHttpHost(opts),\n useTLS: shouldUseTLS(opts),\n wsHost: getWebsocketHost(opts),\n\n userAuthenticator: buildUserAuthenticator(opts),\n channelAuthorizer: buildChannelAuthorizer(opts, pusher)\n };\n\n if ('disabledTransports' in opts)\n config.disabledTransports = opts.disabledTransports;\n if ('enabledTransports' in opts)\n config.enabledTransports = opts.enabledTransports;\n if ('ignoreNullOrigin' in opts)\n config.ignoreNullOrigin = opts.ignoreNullOrigin;\n if ('timelineParams' in opts) config.timelineParams = opts.timelineParams;\n if ('nacl' in opts) {\n config.nacl = opts.nacl;\n }\n\n return config;\n}\n\nfunction getHttpHost(opts: Options): string {\n if (opts.httpHost) {\n return opts.httpHost;\n }\n if (opts.cluster) {\n return `sockjs-${opts.cluster}.pusher.com`;\n }\n return Defaults.httpHost;\n}\n\nfunction getWebsocketHost(opts: Options): string {\n if (opts.wsHost) {\n return opts.wsHost;\n }\n return getWebsocketHostFromCluster(opts.cluster);\n}\n\nfunction getWebsocketHostFromCluster(cluster: string): string {\n return `ws-${cluster}.pusher.com`;\n}\n\nfunction shouldUseTLS(opts: Options): boolean {\n if (Runtime.getProtocol() === 'https:') {\n return true;\n } else if (opts.forceTLS === false) {\n return false;\n }\n return true;\n}\n\n// if enableStats is set take the value\n// if disableStats is set take the inverse\n// otherwise default to false\nfunction getEnableStatsConfig(opts: Options): boolean {\n if ('enableStats' in opts) {\n return opts.enableStats;\n }\n if ('disableStats' in opts) {\n return !opts.disableStats;\n }\n return false;\n}\n\nfunction buildUserAuthenticator(opts: Options): UserAuthenticationHandler {\n const userAuthentication = {\n ...Defaults.userAuthentication,\n ...opts.userAuthentication\n };\n if (\n 'customHandler' in userAuthentication &&\n userAuthentication['customHandler'] != null\n ) {\n return userAuthentication['customHandler'];\n }\n\n return UserAuthenticator(userAuthentication);\n}\n\nfunction buildChannelAuth(opts: Options, pusher): ChannelAuthorizationOptions {\n let channelAuthorization: ChannelAuthorizationOptions;\n if ('channelAuthorization' in opts) {\n channelAuthorization = {\n ...Defaults.channelAuthorization,\n ...opts.channelAuthorization\n };\n } else {\n channelAuthorization = {\n transport: opts.authTransport || Defaults.authTransport,\n endpoint: opts.authEndpoint || Defaults.authEndpoint\n };\n if ('auth' in opts) {\n if ('params' in opts.auth) channelAuthorization.params = opts.auth.params;\n if ('headers' in opts.auth)\n channelAuthorization.headers = opts.auth.headers;\n }\n if ('authorizer' in opts)\n channelAuthorization.customHandler = ChannelAuthorizerProxy(\n pusher,\n channelAuthorization,\n opts.authorizer\n );\n }\n return channelAuthorization;\n}\n\nfunction buildChannelAuthorizer(\n opts: Options,\n pusher\n): ChannelAuthorizationHandler {\n const channelAuthorization = buildChannelAuth(opts, pusher);\n if (\n 'customHandler' in channelAuthorization &&\n channelAuthorization['customHandler'] != null\n ) {\n return channelAuthorization['customHandler'];\n }\n\n return ChannelAuthorizer(channelAuthorization);\n}\n","import Logger from './logger';\nimport Pusher from './pusher';\nimport EventsDispatcher from './events/dispatcher';\n\nexport default class WatchlistFacade extends EventsDispatcher {\n private pusher: Pusher;\n\n public constructor(pusher: Pusher) {\n super(function(eventName, data) {\n Logger.debug(`No callbacks on watchlist events for ${eventName}`);\n });\n\n this.pusher = pusher;\n this.bindWatchlistInternalEvent();\n }\n\n handleEvent(pusherEvent) {\n pusherEvent.data.events.forEach(watchlistEvent => {\n this.emit(watchlistEvent.name, watchlistEvent);\n });\n }\n\n private bindWatchlistInternalEvent() {\n this.pusher.connection.bind('message', pusherEvent => {\n var eventName = pusherEvent.event;\n if (eventName === 'pusher_internal:watchlist_events') {\n this.handleEvent(pusherEvent);\n }\n });\n }\n}\n","function flatPromise() {\n let resolve, reject;\n const promise = new Promise((res, rej) => {\n resolve = res;\n reject = rej;\n });\n return { promise, resolve, reject };\n}\n\nexport default flatPromise;\n","import Pusher from './pusher';\nimport Logger from './logger';\nimport {\n UserAuthenticationData,\n UserAuthenticationCallback\n} from './auth/options';\nimport Channel from './channels/channel';\nimport WatchlistFacade from './watchlist';\nimport EventsDispatcher from './events/dispatcher';\nimport flatPromise from './utils/flat_promise';\n\nexport default class UserFacade extends EventsDispatcher {\n pusher: Pusher;\n signin_requested: boolean = false;\n user_data: any = null;\n serverToUserChannel: Channel = null;\n signinDonePromise: Promise = null;\n watchlist: WatchlistFacade;\n private _signinDoneResolve: Function = null;\n\n public constructor(pusher: Pusher) {\n super(function(eventName, data) {\n Logger.debug('No callbacks on user for ' + eventName);\n });\n this.pusher = pusher;\n this.pusher.connection.bind('state_change', ({ previous, current }) => {\n if (previous !== 'connected' && current === 'connected') {\n this._signin();\n }\n if (previous === 'connected' && current !== 'connected') {\n this._cleanup();\n this._newSigninPromiseIfNeeded();\n }\n });\n\n this.watchlist = new WatchlistFacade(pusher);\n\n this.pusher.connection.bind('message', event => {\n var eventName = event.event;\n if (eventName === 'pusher:signin_success') {\n this._onSigninSuccess(event.data);\n }\n if (\n this.serverToUserChannel &&\n this.serverToUserChannel.name === event.channel\n ) {\n this.serverToUserChannel.handleEvent(event);\n }\n });\n }\n\n public signin() {\n if (this.signin_requested) {\n return;\n }\n\n this.signin_requested = true;\n this._signin();\n }\n\n private _signin() {\n if (!this.signin_requested) {\n return;\n }\n\n this._newSigninPromiseIfNeeded();\n\n if (this.pusher.connection.state !== 'connected') {\n // Signin will be attempted when the connection is connected\n return;\n }\n\n this.pusher.config.userAuthenticator(\n {\n socketId: this.pusher.connection.socket_id\n },\n this._onAuthorize\n );\n }\n\n private _onAuthorize: UserAuthenticationCallback = (\n err,\n authData: UserAuthenticationData\n ) => {\n if (err) {\n Logger.warn(`Error during signin: ${err}`);\n this._cleanup();\n return;\n }\n\n this.pusher.send_event('pusher:signin', {\n auth: authData.auth,\n user_data: authData.user_data\n });\n\n // Later when we get pusher:singin_success event, the user will be marked as signed in\n };\n\n private _onSigninSuccess(data: any) {\n try {\n this.user_data = JSON.parse(data.user_data);\n } catch (e) {\n Logger.error(`Failed parsing user data after signin: ${data.user_data}`);\n this._cleanup();\n return;\n }\n\n if (typeof this.user_data.id !== 'string' || this.user_data.id === '') {\n Logger.error(\n `user_data doesn't contain an id. user_data: ${this.user_data}`\n );\n this._cleanup();\n return;\n }\n\n // Signin succeeded\n this._signinDoneResolve();\n this._subscribeChannels();\n }\n\n private _subscribeChannels() {\n const ensure_subscribed = channel => {\n if (channel.subscriptionPending && channel.subscriptionCancelled) {\n channel.reinstateSubscription();\n } else if (\n !channel.subscriptionPending &&\n this.pusher.connection.state === 'connected'\n ) {\n channel.subscribe();\n }\n };\n\n this.serverToUserChannel = new Channel(\n `#server-to-user-${this.user_data.id}`,\n this.pusher\n );\n this.serverToUserChannel.bind_global((eventName, data) => {\n if (\n eventName.indexOf('pusher_internal:') === 0 ||\n eventName.indexOf('pusher:') === 0\n ) {\n // ignore internal events\n return;\n }\n this.emit(eventName, data);\n });\n ensure_subscribed(this.serverToUserChannel);\n }\n\n private _cleanup() {\n this.user_data = null;\n if (this.serverToUserChannel) {\n this.serverToUserChannel.unbind_all();\n this.serverToUserChannel.disconnect();\n this.serverToUserChannel = null;\n }\n\n if (this.signin_requested) {\n // If signin is in progress and cleanup is called,\n // Mark the current signin process as done.\n this._signinDoneResolve();\n }\n }\n\n private _newSigninPromiseIfNeeded() {\n if (!this.signin_requested) {\n return;\n }\n\n // If there is a promise and it is not resolved, return without creating a new one.\n if (this.signinDonePromise && !(this.signinDonePromise as any).done) {\n return;\n }\n\n // This promise is never rejected.\n // It gets resolved when the signin process is done whether it failed or succeeded\n const { promise, resolve, reject: _ } = flatPromise();\n (promise as any).done = false;\n const setDone = () => {\n (promise as any).done = true;\n };\n promise.then(setDone).catch(setDone);\n this.signinDonePromise = promise;\n this._signinDoneResolve = resolve;\n }\n}\n","import AbstractRuntime from '../runtimes/interface';\nimport Runtime from 'runtime';\nimport * as Collections from './utils/collections';\nimport Channels from './channels/channels';\nimport Channel from './channels/channel';\nimport { default as EventsDispatcher } from './events/dispatcher';\nimport Timeline from './timeline/timeline';\nimport TimelineSender from './timeline/timeline_sender';\nimport TimelineLevel from './timeline/level';\nimport { defineTransport } from './strategies/strategy_builder';\nimport ConnectionManager from './connection/connection_manager';\nimport { PeriodicTimer } from './utils/timers';\nimport Defaults from './defaults';\nimport Logger from './logger';\nimport Factory from './utils/factory';\nimport { Options, ClusterOptions, validateOptions } from './options';\nimport { Config, getConfig } from './config';\nimport StrategyOptions from './strategies/strategy_options';\nimport UserFacade from './user';\n\nexport default class Pusher {\n /* STATIC PROPERTIES */\n static instances: Pusher[] = [];\n static isReady: boolean = false;\n static logToConsole: boolean = false;\n\n // for jsonp\n static Runtime: AbstractRuntime = Runtime;\n static ScriptReceivers: any = (Runtime).ScriptReceivers;\n static DependenciesReceivers: any = (Runtime).DependenciesReceivers;\n static auth_callbacks: any = (Runtime).auth_callbacks;\n\n static ready() {\n Pusher.isReady = true;\n for (var i = 0, l = Pusher.instances.length; i < l; i++) {\n Pusher.instances[i].connect();\n }\n }\n\n static log: (message: any) => void;\n\n private static getClientFeatures(): string[] {\n return Collections.keys(\n Collections.filterObject({ ws: Runtime.Transports.ws }, function(t) {\n return t.isSupported({});\n })\n );\n }\n\n /* INSTANCE PROPERTIES */\n key: string;\n options: Options;\n config: Config;\n channels: Channels;\n global_emitter: EventsDispatcher;\n sessionID: number;\n timeline: Timeline;\n timelineSender: TimelineSender;\n connection: ConnectionManager;\n timelineSenderTimer: PeriodicTimer;\n user: UserFacade;\n constructor(app_key: string, options: Options) {\n checkAppKey(app_key);\n validateOptions(options);\n this.key = app_key;\n this.config = getConfig(options, this);\n\n this.channels = Factory.createChannels();\n this.global_emitter = new EventsDispatcher();\n this.sessionID = Runtime.randomInt(1000000000);\n\n this.timeline = new Timeline(this.key, this.sessionID, {\n cluster: this.config.cluster,\n features: Pusher.getClientFeatures(),\n params: this.config.timelineParams || {},\n limit: 50,\n level: TimelineLevel.INFO,\n version: Defaults.VERSION\n });\n if (this.config.enableStats) {\n this.timelineSender = Factory.createTimelineSender(this.timeline, {\n host: this.config.statsHost,\n path: '/timeline/v2/' + Runtime.TimelineTransport.name\n });\n }\n\n var getStrategy = (options: StrategyOptions) => {\n return Runtime.getDefaultStrategy(this.config, options, defineTransport);\n };\n\n this.connection = Factory.createConnectionManager(this.key, {\n getStrategy: getStrategy,\n timeline: this.timeline,\n activityTimeout: this.config.activityTimeout,\n pongTimeout: this.config.pongTimeout,\n unavailableTimeout: this.config.unavailableTimeout,\n useTLS: Boolean(this.config.useTLS)\n });\n\n this.connection.bind('connected', () => {\n this.subscribeAll();\n if (this.timelineSender) {\n this.timelineSender.send(this.connection.isUsingTLS());\n }\n });\n\n this.connection.bind('message', event => {\n var eventName = event.event;\n var internal = eventName.indexOf('pusher_internal:') === 0;\n if (event.channel) {\n var channel = this.channel(event.channel);\n if (channel) {\n channel.handleEvent(event);\n }\n }\n // Emit globally [deprecated]\n if (!internal) {\n this.global_emitter.emit(event.event, event.data);\n }\n });\n this.connection.bind('connecting', () => {\n this.channels.disconnect();\n });\n this.connection.bind('disconnected', () => {\n this.channels.disconnect();\n });\n this.connection.bind('error', err => {\n Logger.warn(err);\n });\n\n Pusher.instances.push(this);\n this.timeline.info({ instances: Pusher.instances.length });\n\n this.user = new UserFacade(this);\n\n if (Pusher.isReady) {\n this.connect();\n }\n }\n\n /**\n * Allows you to switch Pusher cluster without\n * losing all the channels/subscription binding\n * as this is internally managed by the SDK.\n */\n switchCluster(options: ClusterOptions) {\n const { appKey, cluster } = options;\n this.key = appKey;\n this.options = { ...this.options, cluster };\n this.config = getConfig(this.options, this);\n this.connection.switchCluster(this.key);\n }\n\n channel(name: string): Channel {\n return this.channels.find(name);\n }\n\n allChannels(): Channel[] {\n return this.channels.all();\n }\n\n connect() {\n this.connection.connect();\n\n if (this.timelineSender) {\n if (!this.timelineSenderTimer) {\n var usingTLS = this.connection.isUsingTLS();\n var timelineSender = this.timelineSender;\n this.timelineSenderTimer = new PeriodicTimer(60000, function() {\n timelineSender.send(usingTLS);\n });\n }\n }\n }\n\n disconnect() {\n this.connection.disconnect();\n\n if (this.timelineSenderTimer) {\n this.timelineSenderTimer.ensureAborted();\n this.timelineSenderTimer = null;\n }\n }\n\n bind(event_name: string, callback: Function, context?: any): Pusher {\n this.global_emitter.bind(event_name, callback, context);\n return this;\n }\n\n unbind(event_name?: string, callback?: Function, context?: any): Pusher {\n this.global_emitter.unbind(event_name, callback, context);\n return this;\n }\n\n bind_global(callback: Function): Pusher {\n this.global_emitter.bind_global(callback);\n return this;\n }\n\n unbind_global(callback?: Function): Pusher {\n this.global_emitter.unbind_global(callback);\n return this;\n }\n\n unbind_all(callback?: Function): Pusher {\n this.global_emitter.unbind_all();\n return this;\n }\n\n subscribeAll() {\n var channelName;\n for (channelName in this.channels.channels) {\n if (this.channels.channels.hasOwnProperty(channelName)) {\n this.subscribe(channelName);\n }\n }\n }\n\n subscribe(channel_name: string) {\n var channel = this.channels.add(channel_name, this);\n if (channel.subscriptionPending && channel.subscriptionCancelled) {\n channel.reinstateSubscription();\n } else if (\n !channel.subscriptionPending &&\n this.connection.state === 'connected'\n ) {\n channel.subscribe();\n }\n return channel;\n }\n\n unsubscribe(channel_name: string) {\n var channel = this.channels.find(channel_name);\n if (channel && channel.subscriptionPending) {\n channel.cancelSubscription();\n } else {\n channel = this.channels.remove(channel_name);\n if (channel && channel.subscribed) {\n channel.unsubscribe();\n }\n }\n }\n\n send_event(event_name: string, data: any, channel?: string) {\n return this.connection.send_event(event_name, data, channel);\n }\n\n shouldUseTLS(): boolean {\n return this.config.useTLS;\n }\n\n signin() {\n this.user.signin();\n }\n}\n\nfunction checkAppKey(key) {\n if (key === null || key === undefined) {\n throw 'You must pass your app key when you instantiate Pusher.';\n }\n}\n\nRuntime.setup(Pusher);\n","import Pusher from './pusher';\nimport { Options, validateOptions } from './options';\nimport * as nacl from 'tweetnacl';\n\nexport default class PusherWithEncryption extends Pusher {\n constructor(app_key: string, options: Options) {\n Pusher.logToConsole = PusherWithEncryption.logToConsole;\n Pusher.log = PusherWithEncryption.log;\n\n validateOptions(options);\n options.nacl = nacl;\n super(app_key, options);\n }\n}\n"],"sourceRoot":""} \ No newline at end of file diff --git a/dist/react-native/pusher.js b/dist/react-native/pusher.js index a2bef6c82..8aa114231 100644 --- a/dist/react-native/pusher.js +++ b/dist/react-native/pusher.js @@ -1,9 +1,9 @@ /*! - * Pusher JavaScript Library v8.4.0 + * Pusher JavaScript Library v8.4.0-rc1 * https://pusher.com/ * * Copyright 2020, Pusher * Released under the MIT licence. */ -module.exports=function(t){var e={};function n(r){if(e[r])return e[r].exports;var i=e[r]={i:r,l:!1,exports:{}};return t[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)n.d(r,i,function(e){return t[e]}.bind(null,i));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=15)}([function(t,e,n){"use strict";(function(t){n.d(e,"f",(function(){return s})),n.d(e,"m",(function(){return o})),n.d(e,"d",(function(){return a})),n.d(e,"k",(function(){return h})),n.d(e,"i",(function(){return c})),n.d(e,"n",(function(){return u})),n.d(e,"c",(function(){return l})),n.d(e,"j",(function(){return d})),n.d(e,"g",(function(){return f})),n.d(e,"h",(function(){return p})),n.d(e,"b",(function(){return g})),n.d(e,"a",(function(){return b})),n.d(e,"e",(function(){return y})),n.d(e,"l",(function(){return m}));var r=n(11),i=n(2);function s(t,...e){for(var n=0;n{t.console&&t.console.log&&t.console.log(e)}}debug(...t){this.log(this.globalLog,t)}warn(...t){this.log(this.globalLogWarn,t)}error(...t){this.log(this.globalLogError,t)}globalLogWarn(e){t.console&&t.console.warn?t.console.warn(e):this.globalLog(e)}globalLogError(e){t.console&&t.console.error?t.console.error(e):this.globalLogWarn(e)}log(t,...e){var n=r.m.apply(this,arguments);if(i.a.log)i.a.log(n);else if(i.a.logToConsole){t.bind(this)(n)}}}}).call(this,n(6))},function(t,e,n){"use strict";var r=n(4),i={now:()=>Date.now?Date.now():(new Date).valueOf(),defer:t=>new r.a(0,t),method(t,...e){var n=Array.prototype.slice.call(arguments,1);return function(e){return e[t].apply(e,n.concat(arguments))}}};e.a=i},function(t,e,n){"use strict";(function(t){n.d(e,"a",(function(){return s}));var r=n(0),i=n(12);class s{constructor(t){this.callbacks=new i.a,this.global_callbacks=[],this.failThrough=t}bind(t,e,n){return this.callbacks.add(t,e,n),this}bind_global(t){return this.global_callbacks.push(t),this}unbind(t,e,n){return this.callbacks.remove(t,e,n),this}unbind_global(t){return t?(this.global_callbacks=r.g(this.global_callbacks||[],e=>e!==t),this):(this.global_callbacks=[],this)}unbind_all(){return this.unbind(),this.unbind_global(),this}emit(e,n,r){for(var i=0;i0)for(i=0;i{this.onError(t),this.changeState("closed")}),!1}return this.bindListeners(),l.a.debug("Connecting",{transport:this.name,url:t}),this.changeState("connecting"),!0}close(){return!!this.socket&&(this.socket.close(),!0)}send(t){return"open"===this.state&&(c.a.defer(()=>{this.socket&&this.socket.send(t)}),!0)}ping(){"open"===this.state&&this.supportsPing()&&this.socket.ping()}onOpen(){this.hooks.beforeOpen&&this.hooks.beforeOpen(this.socket,this.hooks.urls.getPath(this.key,this.options)),this.changeState("open"),this.socket.onopen=void 0}onError(t){this.emit("error",{type:"WebSocketError",error:t}),this.timeline.error(this.buildTimelineMessage({error:t.toString()}))}onClose(t){t?this.changeState("closed",{code:t.code,reason:t.reason,wasClean:t.wasClean}):this.changeState("closed"),this.unbindListeners(),this.socket=void 0}onMessage(t){this.emit("message",t)}onActivity(){this.emit("activity")}bindListeners(){this.socket.onopen=()=>{this.onOpen()},this.socket.onerror=t=>{this.onError(t)},this.socket.onclose=t=>{this.onClose(t)},this.socket.onmessage=t=>{this.onMessage(t)},this.supportsPing()&&(this.socket.onactivity=()=>{this.onActivity()})}unbindListeners(){this.socket&&(this.socket.onopen=void 0,this.socket.onerror=void 0,this.socket.onclose=void 0,this.socket.onmessage=void 0,this.supportsPing()&&(this.socket.onactivity=void 0))}changeState(t,e){this.state=t,this.timeline.info(this.buildTimelineMessage({state:t,params:e})),this.emit(t,e)}buildTimelineMessage(t){return r.f({cid:this.id},t)}}class f{constructor(t){this.hooks=t}isSupported(t){return this.hooks.isSupported(t)}createConnection(t,e,n,r){return new d(this.hooks,t,e,n,r)}}var p=new f({urls:a,handlesActivityChecks:!1,supportsPing:!1,isInitialized:function(){return Boolean(zt.getWebSocketAPI())},isSupported:function(){return Boolean(zt.getWebSocketAPI())},getSocket:function(t){return zt.createWebSocket(t)}}),g={urls:h,handlesActivityChecks:!1,supportsPing:!0,isInitialized:function(){return!0}},b=r.f({getSocket:function(t){return zt.HTTPFactory.createStreamingSocket(t)}},g),v=r.f({getSocket:function(t){return zt.HTTPFactory.createPollingSocket(t)}},g),y={isSupported:function(){return zt.isXHRSupported()}},m={ws:p,xhr_streaming:new f(r.f({},b,y)),xhr_polling:new f(r.f({},v,y))};class w{constructor(t,e,n){this.manager=t,this.transport=e,this.minPingDelay=n.minPingDelay,this.maxPingDelay=n.maxPingDelay,this.pingDelay=void 0}createConnection(t,e,n,i){i=r.f({},i,{activityTimeout:this.pingDelay});var s=this.transport.createConnection(t,e,n,i),o=null,a=function(){s.unbind("open",a),s.bind("closed",h),o=c.a.now()},h=t=>{if(s.unbind("closed",h),1002===t.code||1003===t.code)this.manager.reportDeath();else if(!t.wasClean&&o){var e=c.a.now()-o;e<2*this.maxPingDelay&&(this.manager.reportDeath(),this.pingDelay=Math.max(e/2,this.minPingDelay))}};return s.bind("open",a),s}isSupported(t){return this.manager.isAlive()&&this.transport.isSupported(t)}}const _={decodeMessage:function(t){try{var e=JSON.parse(t.data),n=e.data;if("string"==typeof n)try{n=JSON.parse(e.data)}catch(t){}var r={event:e.event,channel:e.channel,data:n};return e.user_id&&(r.user_id=e.user_id),r}catch(e){throw{type:"MessageParseError",error:e,data:t.data}}},encodeMessage:function(t){return JSON.stringify(t)},processHandshake:function(t){var e=_.decodeMessage(t);if("pusher:connection_established"===e.event){if(!e.data.activity_timeout)throw"No activity timeout specified in handshake";return{action:"connected",id:e.data.socket_id,activityTimeout:1e3*e.data.activity_timeout}}if("pusher:error"===e.event)return{action:this.getCloseAction(e.data),error:this.getCloseError(e.data)};throw"Invalid handshake"},getCloseAction:function(t){return t.code<4e3?t.code>=1002&&t.code<=1004?"backoff":null:4e3===t.code?"tls_only":t.code<4100?"refused":t.code<4200?"backoff":t.code<4300?"retry":"refused"},getCloseError:function(t){return 1e3!==t.code&&1001!==t.code?{type:"PusherError",data:{code:t.code,message:t.reason||t.message}}:null}};var S=_;class k extends u.a{constructor(t,e){super(),this.id=t,this.transport=e,this.activityTimeout=e.activityTimeout,this.bindListeners()}handlesActivityChecks(){return this.transport.handlesActivityChecks()}send(t){return this.transport.send(t)}send_event(t,e,n){var r={event:t,data:e};return n&&(r.channel=n),l.a.debug("Event sent",r),this.send(S.encodeMessage(r))}ping(){this.transport.supportsPing()?this.transport.ping():this.send_event("pusher:ping",{})}close(){this.transport.close()}bindListeners(){var t={message:t=>{var e;try{e=S.decodeMessage(t)}catch(e){this.emit("error",{type:"MessageParseError",error:e,data:t.data})}if(void 0!==e){switch(l.a.debug("Event recd",e),e.event){case"pusher:error":this.emit("error",{type:"PusherError",data:e.data});break;case"pusher:ping":this.emit("ping");break;case"pusher:pong":this.emit("pong")}this.emit("message",e)}},activity:()=>{this.emit("activity")},error:t=>{this.emit("error",t)},closed:t=>{e(),t&&t.code&&this.handleCloseEvent(t),this.transport=null,this.emit("closed")}},e=()=>{r.k(t,(t,e)=>{this.transport.unbind(e,t)})};r.k(t,(t,e)=>{this.transport.bind(e,t)})}handleCloseEvent(t){var e=S.getCloseAction(t),n=S.getCloseError(t);n&&this.emit("error",n),e&&this.emit(e,{action:e,error:n})}}class C{constructor(t,e){this.transport=t,this.callback=e,this.bindListeners()}close(){this.unbindListeners(),this.transport.close()}bindListeners(){this.onMessage=t=>{var e;this.unbindListeners();try{e=S.processHandshake(t)}catch(t){return this.finish("error",{error:t}),void this.transport.close()}"connected"===e.action?this.finish("connected",{connection:new k(e.id,this.transport),activityTimeout:e.activityTimeout}):(this.finish(e.action,{error:e.error}),this.transport.close())},this.onClosed=t=>{this.unbindListeners();var e=S.getCloseAction(t)||"backoff",n=S.getCloseError(t);this.finish(e,{error:n})},this.transport.bind("message",this.onMessage),this.transport.bind("closed",this.onClosed)}unbindListeners(){this.transport.unbind("message",this.onMessage),this.transport.unbind("closed",this.onClosed)}finish(t,e){this.callback(r.f({transport:this.transport,action:t},e))}}class T{constructor(t,e){this.timeline=t,this.options=e||{}}send(t,e){this.timeline.isEmpty()||this.timeline.send(zt.TimelineTransport.getAgent(this,t),e)}}class E extends Error{constructor(t){super(t),Object.setPrototypeOf(this,new.target.prototype)}}class A extends Error{constructor(t){super(t),Object.setPrototypeOf(this,new.target.prototype)}}Error;class P extends Error{constructor(t){super(t),Object.setPrototypeOf(this,new.target.prototype)}}class x extends Error{constructor(t){super(t),Object.setPrototypeOf(this,new.target.prototype)}}class O extends Error{constructor(t){super(t),Object.setPrototypeOf(this,new.target.prototype)}}class L extends Error{constructor(t){super(t),Object.setPrototypeOf(this,new.target.prototype)}}class U extends Error{constructor(t){super(t),Object.setPrototypeOf(this,new.target.prototype)}}class R extends Error{constructor(t,e){super(e),this.status=t,Object.setPrototypeOf(this,new.target.prototype)}}const M={baseUrl:"https://pusher.com",urls:{authenticationEndpoint:{path:"/docs/channels/server_api/authenticating_users"},authorizationEndpoint:{path:"/docs/channels/server_api/authorizing-users/"},javascriptQuickStart:{path:"/docs/javascript_quick_start"},triggeringClientEvents:{path:"/docs/client_api_guide/client_events#trigger-events"},encryptedChannelSupport:{fullUrl:"https://github.com/pusher/pusher-js/tree/cc491015371a4bde5743d1c87a0fbac0feb53195#encrypted-channel-support"}}};var I=function(t){const e=M.urls[t];if(!e)return"";let n;return e.fullUrl?n=e.fullUrl:e.path&&(n=M.baseUrl+e.path),n?"See: "+n:""};class N extends u.a{constructor(t,e){super((function(e,n){l.a.debug("No callbacks on "+t+" for "+e)})),this.name=t,this.pusher=e,this.subscribed=!1,this.subscriptionPending=!1,this.subscriptionCancelled=!1}authorize(t,e){return e(null,{auth:""})}trigger(t,e){if(0!==t.indexOf("client-"))throw new E("Event '"+t+"' does not start with 'client-'");if(!this.subscribed){var n=I("triggeringClientEvents");l.a.warn("Client event triggered before channel 'subscription_succeeded' event . "+n)}return this.pusher.send_event(t,e,this.name)}disconnect(){this.subscribed=!1,this.subscriptionPending=!1}handleEvent(t){var e=t.event,n=t.data;if("pusher_internal:subscription_succeeded"===e)this.handleSubscriptionSucceededEvent(t);else if("pusher_internal:subscription_count"===e)this.handleSubscriptionCountEvent(t);else if(0!==e.indexOf("pusher_internal:")){this.emit(e,n,{})}}handleSubscriptionSucceededEvent(t){this.subscriptionPending=!1,this.subscribed=!0,this.subscriptionCancelled?this.pusher.unsubscribe(this.name):this.emit("pusher:subscription_succeeded",t.data)}handleSubscriptionCountEvent(t){t.data.subscription_count&&(this.subscriptionCount=t.data.subscription_count),this.emit("pusher:subscription_count",t.data)}subscribe(){this.subscribed||(this.subscriptionPending=!0,this.subscriptionCancelled=!1,this.authorize(this.pusher.connection.socket_id,(t,e)=>{t?(this.subscriptionPending=!1,l.a.error(t.toString()),this.emit("pusher:subscription_error",Object.assign({},{type:"AuthError",error:t.message},t instanceof R?{status:t.status}:{}))):this.pusher.send_event("pusher:subscribe",{auth:e.auth,channel_data:e.channel_data,channel:this.name})}))}unsubscribe(){this.subscribed=!1,this.pusher.send_event("pusher:unsubscribe",{channel:this.name})}cancelSubscription(){this.subscriptionCancelled=!0}reinstateSubscription(){this.subscriptionCancelled=!1}}class j extends N{authorize(t,e){return this.pusher.config.channelAuthorizer({channelName:this.name,socketId:t},e)}}class D{constructor(){this.reset()}get(t){return Object.prototype.hasOwnProperty.call(this.members,t)?{id:t,info:this.members[t]}:null}each(t){r.k(this.members,(e,n)=>{t(this.get(n))})}setMyID(t){this.myID=t}onSubscription(t){this.members=t.presence.hash,this.count=t.presence.count,this.me=this.get(this.myID)}addMember(t){return null===this.get(t.user_id)&&this.count++,this.members[t.user_id]=t.user_info,this.get(t.user_id)}removeMember(t){var e=this.get(t.user_id);return e&&(delete this.members[t.user_id],this.count--),e}reset(){this.members={},this.count=0,this.myID=null,this.me=null}}var z=function(t,e,n,r){return new(n||(n=Promise))((function(i,s){function o(t){try{h(r.next(t))}catch(t){s(t)}}function a(t){try{h(r.throw(t))}catch(t){s(t)}}function h(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(o,a)}h((r=r.apply(t,e||[])).next())}))};class H extends j{constructor(t,e){super(t,e),this.members=new D}authorize(t,e){super.authorize(t,(t,n)=>z(this,void 0,void 0,(function*(){if(!t)if(null!=(n=n).channel_data){var r=JSON.parse(n.channel_data);this.members.setMyID(r.user_id)}else{if(yield this.pusher.user.signinDonePromise,null==this.pusher.user.user_data){let t=I("authorizationEndpoint");return l.a.error(`Invalid auth response for channel '${this.name}', expected 'channel_data' field. ${t}, or the user should be signed in.`),void e("Invalid auth response")}this.members.setMyID(this.pusher.user.user_data.id)}e(t,n)})))}handleEvent(t){var e=t.event;if(0===e.indexOf("pusher_internal:"))this.handleInternalEvent(t);else{var n=t.data,r={};t.user_id&&(r.user_id=t.user_id),this.emit(e,n,r)}}handleInternalEvent(t){var e=t.event,n=t.data;switch(e){case"pusher_internal:subscription_succeeded":this.handleSubscriptionSucceededEvent(t);break;case"pusher_internal:subscription_count":this.handleSubscriptionCountEvent(t);break;case"pusher_internal:member_added":var r=this.members.addMember(n);this.emit("pusher:member_added",r);break;case"pusher_internal:member_removed":var i=this.members.removeMember(n);i&&this.emit("pusher:member_removed",i)}}handleSubscriptionSucceededEvent(t){this.subscriptionPending=!1,this.subscribed=!0,this.subscriptionCancelled?this.pusher.unsubscribe(this.name):(this.members.onSubscription(t.data),this.emit("pusher:subscription_succeeded",this.members))}disconnect(){this.members.reset(),super.disconnect()}}var B=n(13),F=n(8);class q extends j{constructor(t,e,n){super(t,e),this.key=null,this.nacl=n}authorize(t,e){super.authorize(t,(t,n)=>{if(t)return void e(t,n);let r=n.shared_secret;r?(this.key=Object(F.decode)(r),delete n.shared_secret,e(null,n)):e(new Error("No shared_secret key in auth payload for encrypted channel: "+this.name),null)})}trigger(t,e){throw new O("Client events are not currently supported for encrypted channels")}handleEvent(t){var e=t.event,n=t.data;0!==e.indexOf("pusher_internal:")&&0!==e.indexOf("pusher:")?this.handleEncryptedEvent(e,n):super.handleEvent(t)}handleEncryptedEvent(t,e){if(!this.key)return void l.a.debug("Received encrypted event before key has been retrieved from the authEndpoint");if(!e.ciphertext||!e.nonce)return void l.a.error("Unexpected format for encrypted event, expected object with `ciphertext` and `nonce` fields, got: "+e);let n=Object(F.decode)(e.ciphertext);if(n.length{e?l.a.error(`Failed to make a request to the authEndpoint: ${s}. Unable to fetch new key, so dropping encrypted event`):(i=this.nacl.secretbox.open(n,r,this.key),null!==i?this.emit(t,this.getDataToEmit(i)):l.a.error("Failed to decrypt event with new key. Dropping encrypted event"))});this.emit(t,this.getDataToEmit(i))}getDataToEmit(t){let e=Object(B.decode)(t);try{return JSON.parse(e)}catch(t){return e}}}var Y=n(4);class K extends u.a{constructor(t,e){super(),this.state="initialized",this.connection=null,this.key=t,this.options=e,this.timeline=this.options.timeline,this.usingTLS=this.options.useTLS,this.errorCallbacks=this.buildErrorCallbacks(),this.connectionCallbacks=this.buildConnectionCallbacks(this.errorCallbacks),this.handshakeCallbacks=this.buildHandshakeCallbacks(this.errorCallbacks);var n=zt.getNetwork();n.bind("online",()=>{this.timeline.info({netinfo:"online"}),"connecting"!==this.state&&"unavailable"!==this.state||this.retryIn(0)}),n.bind("offline",()=>{this.timeline.info({netinfo:"offline"}),this.connection&&this.sendActivityCheck()}),this.updateStrategy()}switchCluster(t){this.key=t,this.updateStrategy(),this.retryIn(0)}connect(){this.connection||this.runner||(this.strategy.isSupported()?(this.updateState("connecting"),this.startConnecting(),this.setUnavailableTimer()):this.updateState("failed"))}send(t){return!!this.connection&&this.connection.send(t)}send_event(t,e,n){return!!this.connection&&this.connection.send_event(t,e,n)}disconnect(){this.disconnectInternally(),this.updateState("disconnected")}isUsingTLS(){return this.usingTLS}startConnecting(){var t=(e,n)=>{e?this.runner=this.strategy.connect(0,t):"error"===n.action?(this.emit("error",{type:"HandshakeError",error:n.error}),this.timeline.error({handshakeError:n.error})):(this.abortConnecting(),this.handshakeCallbacks[n.action](n))};this.runner=this.strategy.connect(0,t)}abortConnecting(){this.runner&&(this.runner.abort(),this.runner=null)}disconnectInternally(){(this.abortConnecting(),this.clearRetryTimer(),this.clearUnavailableTimer(),this.connection)&&this.abandonConnection().close()}updateStrategy(){this.strategy=this.options.getStrategy({key:this.key,timeline:this.timeline,useTLS:this.usingTLS})}retryIn(t){this.timeline.info({action:"retry",delay:t}),t>0&&this.emit("connecting_in",Math.round(t/1e3)),this.retryTimer=new Y.a(t||0,()=>{this.disconnectInternally(),this.connect()})}clearRetryTimer(){this.retryTimer&&(this.retryTimer.ensureAborted(),this.retryTimer=null)}setUnavailableTimer(){this.unavailableTimer=new Y.a(this.options.unavailableTimeout,()=>{this.updateState("unavailable")})}clearUnavailableTimer(){this.unavailableTimer&&this.unavailableTimer.ensureAborted()}sendActivityCheck(){this.stopActivityCheck(),this.connection.ping(),this.activityTimer=new Y.a(this.options.pongTimeout,()=>{this.timeline.error({pong_timed_out:this.options.pongTimeout}),this.retryIn(0)})}resetActivityCheck(){this.stopActivityCheck(),this.connection&&!this.connection.handlesActivityChecks()&&(this.activityTimer=new Y.a(this.activityTimeout,()=>{this.sendActivityCheck()}))}stopActivityCheck(){this.activityTimer&&this.activityTimer.ensureAborted()}buildConnectionCallbacks(t){return r.f({},t,{message:t=>{this.resetActivityCheck(),this.emit("message",t)},ping:()=>{this.send_event("pusher:pong",{})},activity:()=>{this.resetActivityCheck()},error:t=>{this.emit("error",t)},closed:()=>{this.abandonConnection(),this.shouldRetry()&&this.retryIn(1e3)}})}buildHandshakeCallbacks(t){return r.f({},t,{connected:t=>{this.activityTimeout=Math.min(this.options.activityTimeout,t.activityTimeout,t.connection.activityTimeout||1/0),this.clearUnavailableTimer(),this.setConnection(t.connection),this.socket_id=this.connection.id,this.updateState("connected",{socket_id:this.socket_id})}})}buildErrorCallbacks(){let t=t=>e=>{e.error&&this.emit("error",{type:"WebSocketError",error:e.error}),t(e)};return{tls_only:t(()=>{this.usingTLS=!0,this.updateStrategy(),this.retryIn(0)}),refused:t(()=>{this.disconnect()}),backoff:t(()=>{this.retryIn(1e3)}),retry:t(()=>{this.retryIn(0)})}}setConnection(t){for(var e in this.connection=t,this.connectionCallbacks)this.connection.bind(e,this.connectionCallbacks[e]);this.resetActivityCheck()}abandonConnection(){if(this.connection){for(var t in this.stopActivityCheck(),this.connectionCallbacks)this.connection.unbind(t,this.connectionCallbacks[t]);var e=this.connection;return this.connection=null,e}}updateState(t,e){var n=this.state;if(this.state=t,n!==t){var r=t;"connected"===r&&(r+=" with new socket ID "+e.socket_id),l.a.debug("State changed",n+" -> "+r),this.timeline.info({state:t,params:e}),this.emit("state_change",{previous:n,current:t}),this.emit(t,e)}}shouldRetry(){return"connecting"===this.state||"connected"===this.state}}class ${constructor(){this.channels={}}add(t,e){return this.channels[t]||(this.channels[t]=function(t,e){if(0===t.indexOf("private-encrypted-")){if(e.config.nacl)return J.createEncryptedChannel(t,e,e.config.nacl);let n="Tried to subscribe to a private-encrypted- channel but no nacl implementation available",r=I("encryptedChannelSupport");throw new O(`${n}. ${r}`)}if(0===t.indexOf("private-"))return J.createPrivateChannel(t,e);if(0===t.indexOf("presence-"))return J.createPresenceChannel(t,e);if(0===t.indexOf("#"))throw new A('Cannot create a channel with name "'+t+'".');return J.createChannel(t,e)}(t,e)),this.channels[t]}all(){return r.n(this.channels)}find(t){return this.channels[t]}remove(t){var e=this.channels[t];return delete this.channels[t],e}disconnect(){r.k(this.channels,(function(t){t.disconnect()}))}}var J={createChannels:()=>new $,createConnectionManager:(t,e)=>new K(t,e),createChannel:(t,e)=>new N(t,e),createPrivateChannel:(t,e)=>new j(t,e),createPresenceChannel:(t,e)=>new H(t,e),createEncryptedChannel:(t,e,n)=>new q(t,e,n),createTimelineSender:(t,e)=>new T(t,e),createHandshake:(t,e)=>new C(t,e),createAssistantToTheTransportManager:(t,e,n)=>new w(t,e,n)};class X{constructor(t){this.options=t||{},this.livesLeft=this.options.lives||1/0}getAssistant(t){return J.createAssistantToTheTransportManager(this,t,{minPingDelay:this.options.minPingDelay,maxPingDelay:this.options.maxPingDelay})}isAlive(){return this.livesLeft>0}reportDeath(){this.livesLeft-=1}}class W{constructor(t,e){this.strategies=t,this.loop=Boolean(e.loop),this.failFast=Boolean(e.failFast),this.timeout=e.timeout,this.timeoutLimit=e.timeoutLimit}isSupported(){return r.b(this.strategies,c.a.method("isSupported"))}connect(t,e){var n=this.strategies,r=0,i=this.timeout,s=null,o=(a,h)=>{h?e(null,h):(r+=1,this.loop&&(r%=n.length),r0&&(i=new Y.a(n.timeout,(function(){s.abort(),r(!0)}))),s=t.connect(e,(function(t,e){t&&i&&i.isRunning()&&!n.failFast||(i&&i.ensureAborted(),r(t,e))})),{abort:function(){i&&i.ensureAborted(),s.abort()},forceMinPriority:function(t){s.forceMinPriority(t)}}}}class G{constructor(t){this.strategies=t}isSupported(){return r.b(this.strategies,c.a.method("isSupported"))}connect(t,e){return function(t,e,n){var i=r.j(t,(function(t,r,i,s){return t.connect(e,n(r,s))}));return{abort:function(){r.c(i,V)},forceMinPriority:function(t){r.c(i,(function(e){e.forceMinPriority(t)}))}}}(this.strategies,t,(function(t,n){return function(i,s){n[t].error=i,i?function(t){return r.a(t,(function(t){return Boolean(t.error)}))}(n)&&e(!0):(r.c(n,(function(t){t.forceMinPriority(s.transport.priority)})),e(null,s))}}))}}function V(t){t.error||t.aborted||(t.abort(),t.aborted=!0)}class Z{constructor(t,e,n){this.strategy=t,this.transports=e,this.ttl=n.ttl||18e5,this.usingTLS=n.useTLS,this.timeline=n.timeline}isSupported(){return this.strategy.isSupported()}connect(t,e){var n=this.usingTLS,i=function(t){var e=zt.getLocalStorage();if(e)try{var n=e[Q(t)];if(n)return JSON.parse(n)}catch(e){tt(t)}return null}(n),s=i&&i.cacheSkipCount?i.cacheSkipCount:0,o=[this.strategy];if(i&&i.timestamp+this.ttl>=c.a.now()){var a=this.transports[i.transport];a&&(["ws","wss"].includes(i.transport)||s>3?(this.timeline.info({cached:!0,transport:i.transport,latency:i.latency}),o.push(new W([a],{timeout:2*i.latency+1e3,failFast:!0}))):s++)}var h=c.a.now(),u=o.pop().connect(t,(function i(a,l){a?(tt(n),o.length>0?(h=c.a.now(),u=o.pop().connect(t,i)):e(a)):(!function(t,e,n,i){var s=zt.getLocalStorage();if(s)try{s[Q(t)]=r.l({timestamp:c.a.now(),transport:e,latency:n,cacheSkipCount:i})}catch(t){}}(n,l.transport.name,c.a.now()-h,s),e(null,l))}));return{abort:function(){u.abort()},forceMinPriority:function(e){t=e,u&&u.forceMinPriority(e)}}}}function Q(t){return"pusherTransport"+(t?"TLS":"NonTLS")}function tt(t){var e=zt.getLocalStorage();if(e)try{delete e[Q(t)]}catch(t){}}class et{constructor(t,{delay:e}){this.strategy=t,this.options={delay:e}}isSupported(){return this.strategy.isSupported()}connect(t,e){var n,r=this.strategy,i=new Y.a(this.options.delay,(function(){n=r.connect(t,e)}));return{abort:function(){i.ensureAborted(),n&&n.abort()},forceMinPriority:function(e){t=e,n&&n.forceMinPriority(e)}}}}class nt{constructor(t,e,n){this.test=t,this.trueBranch=e,this.falseBranch=n}isSupported(){return(this.test()?this.trueBranch:this.falseBranch).isSupported()}connect(t,e){return(this.test()?this.trueBranch:this.falseBranch).connect(t,e)}}class rt{constructor(t){this.strategy=t}isSupported(){return this.strategy.isSupported()}connect(t,e){var n=this.strategy.connect(t,(function(t,r){r&&n.abort(),e(t,r)}));return n}}function it(t){return function(){return t.isSupported()}}var st=function(t,e,n){var i={};function s(e,r,s,o,a){var h=n(t,e,r,s,o,a);return i[e]=h,h}var o,a=Object.assign({},e,{hostNonTLS:t.wsHost+":"+t.wsPort,hostTLS:t.wsHost+":"+t.wssPort,httpPath:t.wsPath}),h=r.f({},a,{useTLS:!0}),c=Object.assign({},e,{hostNonTLS:t.httpHost+":"+t.httpPort,hostTLS:t.httpHost+":"+t.httpsPort,httpPath:t.httpPath}),u={loop:!0,timeout:15e3,timeoutLimit:6e4},l=new X({minPingDelay:1e4,maxPingDelay:t.activityTimeout}),d=new X({lives:2,minPingDelay:1e4,maxPingDelay:t.activityTimeout}),f=s("ws","ws",3,a,l),p=s("wss","ws",3,h,l),g=s("xhr_streaming","xhr_streaming",1,c,d),b=s("xhr_polling","xhr_polling",1,c),v=new W([f],u),y=new W([p],u),m=new W([g],u),w=new W([b],u),_=new W([new nt(it(m),new G([m,new et(w,{delay:4e3})]),w)],u);return o=e.useTLS?new G([v,new et(_,{delay:2e3})]):new G([v,new et(y,{delay:2e3}),new et(_,{delay:5e3})]),new Z(new rt(new nt(it(f),o,_)),i,{ttl:18e5,timeline:e.timeline,useTLS:e.useTLS})};class ot extends u.a{constructor(t,e,n){super(),this.hooks=t,this.method=e,this.url=n}start(t){this.position=0,this.xhr=this.hooks.getRequest(this),this.unloader=()=>{this.close()},zt.addUnloadListener(this.unloader),this.xhr.open(this.method,this.url,!0),this.xhr.setRequestHeader&&this.xhr.setRequestHeader("Content-Type","application/json"),this.xhr.send(t)}close(){this.unloader&&(zt.removeUnloadListener(this.unloader),this.unloader=null),this.xhr&&(this.hooks.abortRequest(this.xhr),this.xhr=null)}onChunk(t,e){for(;;){var n=this.advanceBuffer(e);if(!n)break;this.emit("chunk",{status:t,data:n})}this.isBufferTooLong(e)&&this.emit("buffer_too_long")}advanceBuffer(t){var e=t.slice(this.position),n=e.indexOf("\n");return-1!==n?(this.position+=n+1,e.slice(0,n)):null}isBufferTooLong(t){return this.position===t.length&&t.length>262144}}var at;!function(t){t[t.CONNECTING=0]="CONNECTING",t[t.OPEN=1]="OPEN",t[t.CLOSED=3]="CLOSED"}(at||(at={}));var ht=at,ct=1;function ut(t){var e=-1===t.indexOf("?")?"?":"&";return t+e+"t="+ +new Date+"&n="+ct++}function lt(t){return zt.randomInt(t)}var dt=class{constructor(t,e){this.hooks=t,this.session=lt(1e3)+"/"+function(t){for(var e=[],n=0;n{this.onChunk(t)}),this.stream.bind("finished",t=>{this.hooks.onFinished(this,t)}),this.stream.bind("buffer_too_long",()=>{this.reconnect()});try{this.stream.start()}catch(t){c.a.defer(()=>{this.onError(t),this.onClose(1006,"Could not start streaming",!1)})}}closeStream(){this.stream&&(this.stream.unbind_all(),this.stream.close(),this.stream=null)}},ft={getReceiveURL:function(t,e){return t.base+"/"+e+"/xhr_streaming"+t.queryString},onHeartbeat:function(t){t.sendRaw("[]")},sendHeartbeat:function(t){t.sendRaw("[]")},onFinished:function(t,e){t.onClose(1006,"Connection interrupted ("+e+")",!1)}},pt={getReceiveURL:function(t,e){return t.base+"/"+e+"/xhr"+t.queryString},onHeartbeat:function(){},sendHeartbeat:function(t){t.sendRaw("[]")},onFinished:function(t,e){200===e?t.reconnect():t.onClose(1006,"Connection interrupted ("+e+")",!1)}},gt={getRequest:function(t){var e=new(zt.getXHRAPI());return e.onreadystatechange=e.onprogress=function(){switch(e.readyState){case 3:e.responseText&&e.responseText.length>0&&t.onChunk(e.status,e.responseText);break;case 4:e.responseText&&e.responseText.length>0&&t.onChunk(e.status,e.responseText),t.emit("finished",e.status),t.close()}},e},abortRequest:function(t){t.onreadystatechange=null,t.abort()}},bt={getDefaultStrategy:st,Transports:m,transportConnectionInitializer:function(){this.timeline.info(this.buildTimelineMessage({transport:this.name+(this.options.useTLS?"s":"")})),this.hooks.isInitialized()?this.changeState("initialized"):this.onClose()},HTTPFactory:{createStreamingSocket(t){return this.createSocket(ft,t)},createPollingSocket(t){return this.createSocket(pt,t)},createSocket:(t,e)=>new dt(t,e),createXHR(t,e){return this.createRequest(gt,t,e)},createRequest:(t,e,n)=>new ot(t,e,n)},setup(t){t.ready()},getLocalStorage(){},getClientFeatures:()=>r.i(r.h({ws:m.ws},(function(t){return t.isSupported({})}))),getProtocol:()=>"http:",isXHRSupported:()=>!0,createSocketRequest(t,e){if(this.isXHRSupported())return this.HTTPFactory.createXHR(t,e);throw"Cross-origin HTTP requests are not supported"},createXHR(){return new(this.getXHRAPI())},createWebSocket(t){return new(this.getWebSocketAPI())(t)},addUnloadListener(t){},removeUnloadListener(t){}},vt=n(10),yt=n.n(vt);function mt(t){return"none"!==t.type.toLowerCase()}class wt extends u.a{constructor(){super(),this.online=!0,yt.a.fetch().then(t=>{this.online=mt(t)}),yt.a.addEventListener(t=>{var e=mt(t);this.online!==e&&(this.online=e,this.online?this.emit("online"):this.emit("offline"))})}isOnline(){return this.online}}var _t,St=new wt;!function(t){t.UserAuthentication="user-authentication",t.ChannelAuthorization="channel-authorization"}(_t||(_t={}));var kt=function(t,e,n,r,i){const s=zt.createXHR();for(var o in s.open("POST",n.endpoint,!0),s.setRequestHeader("Content-Type","application/x-www-form-urlencoded"),n.headers)s.setRequestHeader(o,n.headers[o]);if(null!=n.headersProvider){let t=n.headersProvider();for(var o in t)s.setRequestHeader(o,t[o])}return s.onreadystatechange=function(){if(4===s.readyState)if(200===s.status){let t,e=!1;try{t=JSON.parse(s.responseText),e=!0}catch(t){i(new R(200,`JSON returned from ${r.toString()} endpoint was invalid, yet status code was 200. Data was: ${s.responseText}`),null)}e&&i(null,t)}else{let t="";switch(r){case _t.UserAuthentication:t=I("authenticationEndpoint");break;case _t.ChannelAuthorization:t="Clients must be authorized to join private or presence channels. "+I("authorizationEndpoint")}i(new R(s.status,`Unable to retrieve auth string from ${r.toString()} endpoint - received status: ${s.status} from ${n.endpoint}. ${t}`),null)}},s.send(e),s},Ct={name:"xhr",getAgent:function(t,e){return function(n,i){var s="http"+(e?"s":"")+"://"+(t.host||t.options.host)+t.options.path;s+="/2?"+r.e(n);var o=zt.createXHR();o.open("GET",s,!0),o.onreadystatechange=function(){if(4===o.readyState){let{status:n,responseText:r}=o;if(200!==n)return void l.a.debug(`TimelineSender Error: received ${n} from stats.pusher.com`);try{var{host:e}=JSON.parse(r)}catch(t){l.a.debug("TimelineSenderError: invalid response "+r)}e&&(t.host=e)}},o.send()}}};const{getDefaultStrategy:Tt,Transports:Et,setup:At,getProtocol:Pt,isXHRSupported:xt,getLocalStorage:Ot,createXHR:Lt,createWebSocket:Ut,addUnloadListener:Rt,removeUnloadListener:Mt,transportConnectionInitializer:It,createSocketRequest:Nt,HTTPFactory:jt}=bt;var Dt,zt={getDefaultStrategy:Tt,Transports:Et,setup:At,getProtocol:Pt,isXHRSupported:xt,getLocalStorage:Ot,createXHR:Lt,createWebSocket:Ut,addUnloadListener:Rt,removeUnloadListener:Mt,transportConnectionInitializer:It,createSocketRequest:Nt,HTTPFactory:jt,TimelineTransport:Ct,getAuthorizers:()=>({ajax:kt}),getWebSocketAPI:()=>WebSocket,getXHRAPI:()=>XMLHttpRequest,getNetwork:()=>St,randomInt:t=>Math.floor(Math.random()*t)};!function(t){t[t.ERROR=3]="ERROR",t[t.INFO=6]="INFO",t[t.DEBUG=7]="DEBUG"}(Dt||(Dt={}));var Ht=Dt;class Bt{constructor(t,e,n){this.key=t,this.session=e,this.events=[],this.options=n||{},this.sent=0,this.uniqueID=0}log(t,e){t<=this.options.level&&(this.events.push(r.f({},e,{timestamp:c.a.now()})),this.options.limit&&this.events.length>this.options.limit&&this.events.shift())}error(t){this.log(Ht.ERROR,t)}info(t){this.log(Ht.INFO,t)}debug(t){this.log(Ht.DEBUG,t)}isEmpty(){return 0===this.events.length}send(t,e){var n=r.f({session:this.session,bundle:this.sent+1,key:this.key,lib:"js",version:this.options.version,cluster:this.options.cluster,features:this.options.features,timeline:this.events},this.options.params);return this.events=[],t(n,(t,n)=>{t||this.sent++,e&&e(t,n)}),!0}generateUniqueID(){return this.uniqueID++,this.uniqueID}}class Ft{constructor(t,e,n,r){this.name=t,this.priority=e,this.transport=n,this.options=r||{}}isSupported(){return this.transport.isSupported({useTLS:this.options.useTLS})}connect(t,e){if(!this.isSupported())return qt(new U,e);if(this.priority{n||(u(),s?s.close():i.close())},forceMinPriority:t=>{n||this.priority{if(void 0===zt.getAuthorizers()[t.transport])throw`'${t.transport}' is not a recognized auth transport`;return(e,n)=>{const r=((t,e)=>{var n="socket_id="+encodeURIComponent(t.socketId);for(var r in e.params)n+="&"+encodeURIComponent(r)+"="+encodeURIComponent(e.params[r]);if(null!=e.paramsProvider){let t=e.paramsProvider();for(var r in t)n+="&"+encodeURIComponent(r)+"="+encodeURIComponent(t[r])}return n})(e,t);zt.getAuthorizers()[t.transport](zt,r,t,_t.UserAuthentication,n)}};var Wt=t=>{if(void 0===zt.getAuthorizers()[t.transport])throw`'${t.transport}' is not a recognized auth transport`;return(e,n)=>{const r=((t,e)=>{var n="socket_id="+encodeURIComponent(t.socketId);for(var r in n+="&channel_name="+encodeURIComponent(t.channelName),e.params)n+="&"+encodeURIComponent(r)+"="+encodeURIComponent(e.params[r]);if(null!=e.paramsProvider){let t=e.paramsProvider();for(var r in t)n+="&"+encodeURIComponent(r)+"="+encodeURIComponent(t[r])}return n})(e,t);zt.getAuthorizers()[t.transport](zt,r,t,_t.ChannelAuthorization,n)}};function Gt(t,e){let n={activityTimeout:t.activityTimeout||i.activityTimeout,cluster:t.cluster,httpPath:t.httpPath||i.httpPath,httpPort:t.httpPort||i.httpPort,httpsPort:t.httpsPort||i.httpsPort,pongTimeout:t.pongTimeout||i.pongTimeout,statsHost:t.statsHost||i.stats_host,unavailableTimeout:t.unavailableTimeout||i.unavailableTimeout,wsPath:t.wsPath||i.wsPath,wsPort:t.wsPort||i.wsPort,wssPort:t.wssPort||i.wssPort,enableStats:te(t),httpHost:Vt(t),useTLS:Qt(t),wsHost:Zt(t),userAuthenticator:ee(t),channelAuthorizer:ne(t,e)};return"disabledTransports"in t&&(n.disabledTransports=t.disabledTransports),"enabledTransports"in t&&(n.enabledTransports=t.enabledTransports),"ignoreNullOrigin"in t&&(n.ignoreNullOrigin=t.ignoreNullOrigin),"timelineParams"in t&&(n.timelineParams=t.timelineParams),"nacl"in t&&(n.nacl=t.nacl),n}function Vt(t){return t.httpHost?t.httpHost:t.cluster?`sockjs-${t.cluster}.pusher.com`:i.httpHost}function Zt(t){return t.wsHost?t.wsHost:`ws-${t.cluster}.pusher.com`}function Qt(t){return"https:"===zt.getProtocol()||!1!==t.forceTLS}function te(t){return"enableStats"in t?t.enableStats:"disableStats"in t&&!t.disableStats}function ee(t){const e=Object.assign(Object.assign({},i.userAuthentication),t.userAuthentication);return"customHandler"in e&&null!=e.customHandler?e.customHandler:Xt(e)}function ne(t,e){const n=function(t,e){let n;return"channelAuthorization"in t?n=Object.assign(Object.assign({},i.channelAuthorization),t.channelAuthorization):(n={transport:t.authTransport||i.authTransport,endpoint:t.authEndpoint||i.authEndpoint},"auth"in t&&("params"in t.auth&&(n.params=t.auth.params),"headers"in t.auth&&(n.headers=t.auth.headers)),"authorizer"in t&&(n.customHandler=((t,e,n)=>{const r={authTransport:e.transport,authEndpoint:e.endpoint,auth:{params:e.params,headers:e.headers}};return(e,i)=>{const s=t.channel(e.channelName);n(s,r).authorize(e.socketId,i)}})(e,n,t.authorizer))),n}(t,e);return"customHandler"in n&&null!=n.customHandler?n.customHandler:Wt(n)}class re extends u.a{constructor(t){super((function(t,e){l.a.debug("No callbacks on watchlist events for "+t)})),this.pusher=t,this.bindWatchlistInternalEvent()}handleEvent(t){t.data.events.forEach(t=>{this.emit(t.name,t)})}bindWatchlistInternalEvent(){this.pusher.connection.bind("message",t=>{"pusher_internal:watchlist_events"===t.event&&this.handleEvent(t)})}}var ie=function(){let t,e;return{promise:new Promise((n,r)=>{t=n,e=r}),resolve:t,reject:e}};class se extends u.a{constructor(t){super((function(t,e){l.a.debug("No callbacks on user for "+t)})),this.signin_requested=!1,this.user_data=null,this.serverToUserChannel=null,this.signinDonePromise=null,this._signinDoneResolve=null,this._onAuthorize=(t,e)=>{if(t)return l.a.warn("Error during signin: "+t),void this._cleanup();this.pusher.send_event("pusher:signin",{auth:e.auth,user_data:e.user_data})},this.pusher=t,this.pusher.connection.bind("state_change",({previous:t,current:e})=>{"connected"!==t&&"connected"===e&&this._signin(),"connected"===t&&"connected"!==e&&(this._cleanup(),this._newSigninPromiseIfNeeded())}),this.watchlist=new re(t),this.pusher.connection.bind("message",t=>{"pusher:signin_success"===t.event&&this._onSigninSuccess(t.data),this.serverToUserChannel&&this.serverToUserChannel.name===t.channel&&this.serverToUserChannel.handleEvent(t)})}signin(){this.signin_requested||(this.signin_requested=!0,this._signin())}_signin(){this.signin_requested&&(this._newSigninPromiseIfNeeded(),"connected"===this.pusher.connection.state&&this.pusher.config.userAuthenticator({socketId:this.pusher.connection.socket_id},this._onAuthorize))}_onSigninSuccess(t){try{this.user_data=JSON.parse(t.user_data)}catch(e){return l.a.error("Failed parsing user data after signin: "+t.user_data),void this._cleanup()}if("string"!=typeof this.user_data.id||""===this.user_data.id)return l.a.error("user_data doesn't contain an id. user_data: "+this.user_data),void this._cleanup();this._signinDoneResolve(),this._subscribeChannels()}_subscribeChannels(){this.serverToUserChannel=new N("#server-to-user-"+this.user_data.id,this.pusher),this.serverToUserChannel.bind_global((t,e)=>{0!==t.indexOf("pusher_internal:")&&0!==t.indexOf("pusher:")&&this.emit(t,e)}),(t=>{t.subscriptionPending&&t.subscriptionCancelled?t.reinstateSubscription():t.subscriptionPending||"connected"!==this.pusher.connection.state||t.subscribe()})(this.serverToUserChannel)}_cleanup(){this.user_data=null,this.serverToUserChannel&&(this.serverToUserChannel.unbind_all(),this.serverToUserChannel.disconnect(),this.serverToUserChannel=null),this.signin_requested&&this._signinDoneResolve()}_newSigninPromiseIfNeeded(){if(!this.signin_requested)return;if(this.signinDonePromise&&!this.signinDonePromise.done)return;const{promise:t,resolve:e,reject:n}=ie();t.done=!1;const r=()=>{t.done=!0};t.then(r).catch(r),this.signinDonePromise=t,this._signinDoneResolve=e}}class oe{static ready(){oe.isReady=!0;for(var t=0,e=oe.instances.length;tzt.getDefaultStrategy(this.config,t,Kt),timeline:this.timeline,activityTimeout:this.config.activityTimeout,pongTimeout:this.config.pongTimeout,unavailableTimeout:this.config.unavailableTimeout,useTLS:Boolean(this.config.useTLS)}),this.connection.bind("connected",()=>{this.subscribeAll(),this.timelineSender&&this.timelineSender.send(this.connection.isUsingTLS())}),this.connection.bind("message",t=>{var e=0===t.event.indexOf("pusher_internal:");if(t.channel){var n=this.channel(t.channel);n&&n.handleEvent(t)}e||this.global_emitter.emit(t.event,t.data)}),this.connection.bind("connecting",()=>{this.channels.disconnect()}),this.connection.bind("disconnected",()=>{this.channels.disconnect()}),this.connection.bind("error",t=>{l.a.warn(t)}),oe.instances.push(this),this.timeline.info({instances:oe.instances.length}),this.user=new se(this),oe.isReady&&this.connect()}switchCluster(t){const{appKey:e,cluster:n}=t;this.key=e,this.options=Object.assign(Object.assign({},this.options),{cluster:n}),this.config=Gt(this.options,this),this.connection.switchCluster(this.key)}channel(t){return this.channels.find(t)}allChannels(){return this.channels.all()}connect(){if(this.connection.connect(),this.timelineSender&&!this.timelineSenderTimer){var t=this.connection.isUsingTLS(),e=this.timelineSender;this.timelineSenderTimer=new Y.b(6e4,(function(){e.send(t)}))}}disconnect(){this.connection.disconnect(),this.timelineSenderTimer&&(this.timelineSenderTimer.ensureAborted(),this.timelineSenderTimer=null)}bind(t,e,n){return this.global_emitter.bind(t,e,n),this}unbind(t,e,n){return this.global_emitter.unbind(t,e,n),this}bind_global(t){return this.global_emitter.bind_global(t),this}unbind_global(t){return this.global_emitter.unbind_global(t),this}unbind_all(t){return this.global_emitter.unbind_all(),this}subscribeAll(){var t;for(t in this.channels.channels)this.channels.channels.hasOwnProperty(t)&&this.subscribe(t)}subscribe(t){var e=this.channels.add(t,this);return e.subscriptionPending&&e.subscriptionCancelled?e.reinstateSubscription():e.subscriptionPending||"connected"!==this.connection.state||e.subscribe(),e}unsubscribe(t){var e=this.channels.find(t);e&&e.subscriptionPending?e.cancelSubscription():(e=this.channels.remove(t))&&e.subscribed&&e.unsubscribe()}send_event(t,e,n){return this.connection.send_event(t,e,n)}shouldUseTLS(){return this.config.useTLS}signin(){this.user.signin()}}oe.instances=[],oe.isReady=!1,oe.logToConsole=!1,oe.Runtime=zt,oe.ScriptReceivers=zt.ScriptReceivers,oe.DependenciesReceivers=zt.DependenciesReceivers,oe.auth_callbacks=zt.auth_callbacks;e.a=oe;zt.setup(oe)},function(t,e){var n;n=function(){return this}();try{n=n||new Function("return this")()}catch(t){"object"==typeof window&&(n=window)}t.exports=n},function(t,e,n){"use strict";n.d(e,"a",(function(){return i}));var r=n(1);function i(t){if(null==t)throw"You must pass an options object";if(null==t.cluster)throw"Options object must provide a cluster";"disableStats"in t&&r.a.warn("The disableStats option is deprecated in favor of enableStats")}},function(t,e,n){"use strict";var r,i=this&&this.__extends||(r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)},function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)});Object.defineProperty(e,"__esModule",{value:!0});var s=function(){function t(t){void 0===t&&(t="="),this._paddingCharacter=t}return t.prototype.encodedLength=function(t){return this._paddingCharacter?(t+2)/3*4|0:(8*t+5)/6|0},t.prototype.encode=function(t){for(var e="",n=0;n>>18&63),e+=this._encodeByte(r>>>12&63),e+=this._encodeByte(r>>>6&63),e+=this._encodeByte(r>>>0&63)}var i=t.length-n;if(i>0){r=t[n]<<16|(2===i?t[n+1]<<8:0);e+=this._encodeByte(r>>>18&63),e+=this._encodeByte(r>>>12&63),e+=2===i?this._encodeByte(r>>>6&63):this._paddingCharacter||"",e+=this._paddingCharacter||""}return e},t.prototype.maxDecodedLength=function(t){return this._paddingCharacter?t/4*3|0:(6*t+7)/8|0},t.prototype.decodedLength=function(t){return this.maxDecodedLength(t.length-this._getPaddingLength(t))},t.prototype.decode=function(t){if(0===t.length)return new Uint8Array(0);for(var e=this._getPaddingLength(t),n=t.length-e,r=new Uint8Array(this.maxDecodedLength(n)),i=0,s=0,o=0,a=0,h=0,c=0,u=0;s>>4,r[i++]=h<<4|c>>>2,r[i++]=c<<6|u,o|=256&a,o|=256&h,o|=256&c,o|=256&u;if(s>>4,o|=256&a,o|=256&h),s>>2,o|=256&c),s>>8&6,e+=51-t>>>8&-75,e+=61-t>>>8&-15,e+=62-t>>>8&3,String.fromCharCode(e)},t.prototype._decodeChar=function(t){var e=256;return e+=(42-t&t-44)>>>8&-256+t-43+62,e+=(46-t&t-48)>>>8&-256+t-47+63,e+=(47-t&t-58)>>>8&-256+t-48+52,e+=(64-t&t-91)>>>8&-256+t-65+0,e+=(96-t&t-123)>>>8&-256+t-97+26},t.prototype._getPaddingLength=function(t){var e=0;if(this._paddingCharacter){for(var n=t.length-1;n>=0&&t[n]===this._paddingCharacter;n--)e++;if(t.length<4||e>2)throw new Error("Base64Coder: incorrect padding")}return e},t}();e.Coder=s;var o=new s;e.encode=function(t){return o.encode(t)},e.decode=function(t){return o.decode(t)};var a=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return i(e,t),e.prototype._encodeByte=function(t){var e=t;return e+=65,e+=25-t>>>8&6,e+=51-t>>>8&-75,e+=61-t>>>8&-13,e+=62-t>>>8&49,String.fromCharCode(e)},e.prototype._decodeChar=function(t){var e=256;return e+=(44-t&t-46)>>>8&-256+t-45+62,e+=(94-t&t-96)>>>8&-256+t-95+63,e+=(47-t&t-58)>>>8&-256+t-48+52,e+=(64-t&t-91)>>>8&-256+t-65+0,e+=(96-t&t-123)>>>8&-256+t-97+26},e}(s);e.URLSafeCoder=a;var h=new a;e.encodeURLSafe=function(t){return h.encode(t)},e.decodeURLSafe=function(t){return h.decode(t)},e.encodedLength=function(t){return o.encodedLength(t)},e.maxDecodedLength=function(t){return o.maxDecodedLength(t)},e.decodedLength=function(t){return o.decodedLength(t)}},function(t,e,n){"use strict";e.a=class{constructor(t,e,n,r){this.clear=e,this.timer=t(()=>{this.timer&&(this.timer=r(this.timer))},n)}isRunning(){return null!==this.timer}ensureAborted(){this.timer&&(this.clear(this.timer),this.timer=null)}}},function(t,e){t.exports=require("@react-native-community/netinfo")},function(t,e,n){"use strict";(function(t){function r(t){return d(u(t))}n.d(e,"a",(function(){return r}));for(var i=String.fromCharCode,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",o={},a=0,h=s.length;a>>6)+i(128|63&e):i(224|e>>>12&15)+i(128|e>>>6&63)+i(128|63&e)},u=function(t){return t.replace(/[^\x00-\x7F]/g,c)},l=function(t){var e=[0,2,1][t.length%3],n=t.charCodeAt(0)<<16|(t.length>1?t.charCodeAt(1):0)<<8|(t.length>2?t.charCodeAt(2):0);return[s.charAt(n>>>18),s.charAt(n>>>12&63),e>=2?"=":s.charAt(n>>>6&63),e>=1?"=":s.charAt(63&n)].join("")},d=t.btoa||function(t){return t.replace(/[\s\S]{1,3}/g,l)}}).call(this,n(6))},function(t,e,n){"use strict";n.d(e,"a",(function(){return i}));var r=n(0);class i{constructor(){this._callbacks={}}get(t){return this._callbacks[s(t)]}add(t,e,n){var r=s(t);this._callbacks[r]=this._callbacks[r]||[],this._callbacks[r].push({fn:e,context:n})}remove(t,e,n){if(t||e||n){var i=t?[s(t)]:r.i(this._callbacks);e||n?this.removeCallback(i,e,n):this.removeAllCallbacks(i)}else this._callbacks={}}removeCallback(t,e,n){r.c(t,(function(t){this._callbacks[t]=r.g(this._callbacks[t]||[],(function(t){return e&&e!==t.fn||n&&n!==t.context})),0===this._callbacks[t].length&&delete this._callbacks[t]}),this)}removeAllCallbacks(t){r.c(t,(function(t){delete this._callbacks[t]}),this)}}function s(t){return"_"+t}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r="utf8: invalid source encoding";function i(t){for(var e=0,n=0;n=t.length-1)throw new Error("utf8: invalid string");n++,e+=4}}return e}e.encode=function(t){for(var e=new Uint8Array(i(t)),n=0,r=0;r>6,e[n++]=128|63&s):s<55296?(e[n++]=224|s>>12,e[n++]=128|s>>6&63,e[n++]=128|63&s):(r++,s=(1023&s)<<10,s|=1023&t.charCodeAt(r),s+=65536,e[n++]=240|s>>18,e[n++]=128|s>>12&63,e[n++]=128|s>>6&63,e[n++]=128|63&s)}return e},e.encodedLength=i,e.decode=function(t){for(var e=[],n=0;n=t.length)throw new Error(r);if(128!=(192&(o=t[++n])))throw new Error(r);i=(31&i)<<6|63&o,s=128}else if(i<240){if(n>=t.length-1)throw new Error(r);var o=t[++n],a=t[++n];if(128!=(192&o)||128!=(192&a))throw new Error(r);i=(15&i)<<12|(63&o)<<6|63&a,s=2048}else{if(!(i<248))throw new Error(r);if(n>=t.length-2)throw new Error(r);o=t[++n],a=t[++n];var h=t[++n];if(128!=(192&o)||128!=(192&a)||128!=(192&h))throw new Error(r);i=(15&i)<<18|(63&o)<<12|(63&a)<<6|63&h,s=65536}if(i=55296&&i<=57343)throw new Error(r);if(i>=65536){if(i>1114111)throw new Error(r);i-=65536,e.push(String.fromCharCode(55296|i>>10)),i=56320|1023&i}}e.push(String.fromCharCode(i))}return e.join("")}},function(t,e,n){!function(t){"use strict";var e=function(t){var e,n=new Float64Array(16);if(t)for(e=0;e>24&255,t[e+1]=n>>16&255,t[e+2]=n>>8&255,t[e+3]=255&n,t[e+4]=r>>24&255,t[e+5]=r>>16&255,t[e+6]=r>>8&255,t[e+7]=255&r}function g(t,e,n,r,i){var s,o=0;for(s=0;s>>8)-1}function b(t,e,n,r){return g(t,e,n,r,16)}function v(t,e,n,r){return g(t,e,n,r,32)}function y(t,e,n,r){!function(t,e,n,r){for(var i,s=255&r[0]|(255&r[1])<<8|(255&r[2])<<16|(255&r[3])<<24,o=255&n[0]|(255&n[1])<<8|(255&n[2])<<16|(255&n[3])<<24,a=255&n[4]|(255&n[5])<<8|(255&n[6])<<16|(255&n[7])<<24,h=255&n[8]|(255&n[9])<<8|(255&n[10])<<16|(255&n[11])<<24,c=255&n[12]|(255&n[13])<<8|(255&n[14])<<16|(255&n[15])<<24,u=255&r[4]|(255&r[5])<<8|(255&r[6])<<16|(255&r[7])<<24,l=255&e[0]|(255&e[1])<<8|(255&e[2])<<16|(255&e[3])<<24,d=255&e[4]|(255&e[5])<<8|(255&e[6])<<16|(255&e[7])<<24,f=255&e[8]|(255&e[9])<<8|(255&e[10])<<16|(255&e[11])<<24,p=255&e[12]|(255&e[13])<<8|(255&e[14])<<16|(255&e[15])<<24,g=255&r[8]|(255&r[9])<<8|(255&r[10])<<16|(255&r[11])<<24,b=255&n[16]|(255&n[17])<<8|(255&n[18])<<16|(255&n[19])<<24,v=255&n[20]|(255&n[21])<<8|(255&n[22])<<16|(255&n[23])<<24,y=255&n[24]|(255&n[25])<<8|(255&n[26])<<16|(255&n[27])<<24,m=255&n[28]|(255&n[29])<<8|(255&n[30])<<16|(255&n[31])<<24,w=255&r[12]|(255&r[13])<<8|(255&r[14])<<16|(255&r[15])<<24,_=s,S=o,k=a,C=h,T=c,E=u,A=l,P=d,x=f,O=p,L=g,U=b,R=v,M=y,I=m,N=w,j=0;j<20;j+=2)_^=(i=(R^=(i=(x^=(i=(T^=(i=_+R|0)<<7|i>>>25)+_|0)<<9|i>>>23)+T|0)<<13|i>>>19)+x|0)<<18|i>>>14,E^=(i=(S^=(i=(M^=(i=(O^=(i=E+S|0)<<7|i>>>25)+E|0)<<9|i>>>23)+O|0)<<13|i>>>19)+M|0)<<18|i>>>14,L^=(i=(A^=(i=(k^=(i=(I^=(i=L+A|0)<<7|i>>>25)+L|0)<<9|i>>>23)+I|0)<<13|i>>>19)+k|0)<<18|i>>>14,N^=(i=(U^=(i=(P^=(i=(C^=(i=N+U|0)<<7|i>>>25)+N|0)<<9|i>>>23)+C|0)<<13|i>>>19)+P|0)<<18|i>>>14,_^=(i=(C^=(i=(k^=(i=(S^=(i=_+C|0)<<7|i>>>25)+_|0)<<9|i>>>23)+S|0)<<13|i>>>19)+k|0)<<18|i>>>14,E^=(i=(T^=(i=(P^=(i=(A^=(i=E+T|0)<<7|i>>>25)+E|0)<<9|i>>>23)+A|0)<<13|i>>>19)+P|0)<<18|i>>>14,L^=(i=(O^=(i=(x^=(i=(U^=(i=L+O|0)<<7|i>>>25)+L|0)<<9|i>>>23)+U|0)<<13|i>>>19)+x|0)<<18|i>>>14,N^=(i=(I^=(i=(M^=(i=(R^=(i=N+I|0)<<7|i>>>25)+N|0)<<9|i>>>23)+R|0)<<13|i>>>19)+M|0)<<18|i>>>14;_=_+s|0,S=S+o|0,k=k+a|0,C=C+h|0,T=T+c|0,E=E+u|0,A=A+l|0,P=P+d|0,x=x+f|0,O=O+p|0,L=L+g|0,U=U+b|0,R=R+v|0,M=M+y|0,I=I+m|0,N=N+w|0,t[0]=_>>>0&255,t[1]=_>>>8&255,t[2]=_>>>16&255,t[3]=_>>>24&255,t[4]=S>>>0&255,t[5]=S>>>8&255,t[6]=S>>>16&255,t[7]=S>>>24&255,t[8]=k>>>0&255,t[9]=k>>>8&255,t[10]=k>>>16&255,t[11]=k>>>24&255,t[12]=C>>>0&255,t[13]=C>>>8&255,t[14]=C>>>16&255,t[15]=C>>>24&255,t[16]=T>>>0&255,t[17]=T>>>8&255,t[18]=T>>>16&255,t[19]=T>>>24&255,t[20]=E>>>0&255,t[21]=E>>>8&255,t[22]=E>>>16&255,t[23]=E>>>24&255,t[24]=A>>>0&255,t[25]=A>>>8&255,t[26]=A>>>16&255,t[27]=A>>>24&255,t[28]=P>>>0&255,t[29]=P>>>8&255,t[30]=P>>>16&255,t[31]=P>>>24&255,t[32]=x>>>0&255,t[33]=x>>>8&255,t[34]=x>>>16&255,t[35]=x>>>24&255,t[36]=O>>>0&255,t[37]=O>>>8&255,t[38]=O>>>16&255,t[39]=O>>>24&255,t[40]=L>>>0&255,t[41]=L>>>8&255,t[42]=L>>>16&255,t[43]=L>>>24&255,t[44]=U>>>0&255,t[45]=U>>>8&255,t[46]=U>>>16&255,t[47]=U>>>24&255,t[48]=R>>>0&255,t[49]=R>>>8&255,t[50]=R>>>16&255,t[51]=R>>>24&255,t[52]=M>>>0&255,t[53]=M>>>8&255,t[54]=M>>>16&255,t[55]=M>>>24&255,t[56]=I>>>0&255,t[57]=I>>>8&255,t[58]=I>>>16&255,t[59]=I>>>24&255,t[60]=N>>>0&255,t[61]=N>>>8&255,t[62]=N>>>16&255,t[63]=N>>>24&255}(t,e,n,r)}function m(t,e,n,r){!function(t,e,n,r){for(var i,s=255&r[0]|(255&r[1])<<8|(255&r[2])<<16|(255&r[3])<<24,o=255&n[0]|(255&n[1])<<8|(255&n[2])<<16|(255&n[3])<<24,a=255&n[4]|(255&n[5])<<8|(255&n[6])<<16|(255&n[7])<<24,h=255&n[8]|(255&n[9])<<8|(255&n[10])<<16|(255&n[11])<<24,c=255&n[12]|(255&n[13])<<8|(255&n[14])<<16|(255&n[15])<<24,u=255&r[4]|(255&r[5])<<8|(255&r[6])<<16|(255&r[7])<<24,l=255&e[0]|(255&e[1])<<8|(255&e[2])<<16|(255&e[3])<<24,d=255&e[4]|(255&e[5])<<8|(255&e[6])<<16|(255&e[7])<<24,f=255&e[8]|(255&e[9])<<8|(255&e[10])<<16|(255&e[11])<<24,p=255&e[12]|(255&e[13])<<8|(255&e[14])<<16|(255&e[15])<<24,g=255&r[8]|(255&r[9])<<8|(255&r[10])<<16|(255&r[11])<<24,b=255&n[16]|(255&n[17])<<8|(255&n[18])<<16|(255&n[19])<<24,v=255&n[20]|(255&n[21])<<8|(255&n[22])<<16|(255&n[23])<<24,y=255&n[24]|(255&n[25])<<8|(255&n[26])<<16|(255&n[27])<<24,m=255&n[28]|(255&n[29])<<8|(255&n[30])<<16|(255&n[31])<<24,w=255&r[12]|(255&r[13])<<8|(255&r[14])<<16|(255&r[15])<<24,_=0;_<20;_+=2)s^=(i=(v^=(i=(f^=(i=(c^=(i=s+v|0)<<7|i>>>25)+s|0)<<9|i>>>23)+c|0)<<13|i>>>19)+f|0)<<18|i>>>14,u^=(i=(o^=(i=(y^=(i=(p^=(i=u+o|0)<<7|i>>>25)+u|0)<<9|i>>>23)+p|0)<<13|i>>>19)+y|0)<<18|i>>>14,g^=(i=(l^=(i=(a^=(i=(m^=(i=g+l|0)<<7|i>>>25)+g|0)<<9|i>>>23)+m|0)<<13|i>>>19)+a|0)<<18|i>>>14,w^=(i=(b^=(i=(d^=(i=(h^=(i=w+b|0)<<7|i>>>25)+w|0)<<9|i>>>23)+h|0)<<13|i>>>19)+d|0)<<18|i>>>14,s^=(i=(h^=(i=(a^=(i=(o^=(i=s+h|0)<<7|i>>>25)+s|0)<<9|i>>>23)+o|0)<<13|i>>>19)+a|0)<<18|i>>>14,u^=(i=(c^=(i=(d^=(i=(l^=(i=u+c|0)<<7|i>>>25)+u|0)<<9|i>>>23)+l|0)<<13|i>>>19)+d|0)<<18|i>>>14,g^=(i=(p^=(i=(f^=(i=(b^=(i=g+p|0)<<7|i>>>25)+g|0)<<9|i>>>23)+b|0)<<13|i>>>19)+f|0)<<18|i>>>14,w^=(i=(m^=(i=(y^=(i=(v^=(i=w+m|0)<<7|i>>>25)+w|0)<<9|i>>>23)+v|0)<<13|i>>>19)+y|0)<<18|i>>>14;t[0]=s>>>0&255,t[1]=s>>>8&255,t[2]=s>>>16&255,t[3]=s>>>24&255,t[4]=u>>>0&255,t[5]=u>>>8&255,t[6]=u>>>16&255,t[7]=u>>>24&255,t[8]=g>>>0&255,t[9]=g>>>8&255,t[10]=g>>>16&255,t[11]=g>>>24&255,t[12]=w>>>0&255,t[13]=w>>>8&255,t[14]=w>>>16&255,t[15]=w>>>24&255,t[16]=l>>>0&255,t[17]=l>>>8&255,t[18]=l>>>16&255,t[19]=l>>>24&255,t[20]=d>>>0&255,t[21]=d>>>8&255,t[22]=d>>>16&255,t[23]=d>>>24&255,t[24]=f>>>0&255,t[25]=f>>>8&255,t[26]=f>>>16&255,t[27]=f>>>24&255,t[28]=p>>>0&255,t[29]=p>>>8&255,t[30]=p>>>16&255,t[31]=p>>>24&255}(t,e,n,r)}var w=new Uint8Array([101,120,112,97,110,100,32,51,50,45,98,121,116,101,32,107]);function _(t,e,n,r,i,s,o){var a,h,c=new Uint8Array(16),u=new Uint8Array(64);for(h=0;h<16;h++)c[h]=0;for(h=0;h<8;h++)c[h]=s[h];for(;i>=64;){for(y(u,c,o,w),h=0;h<64;h++)t[e+h]=n[r+h]^u[h];for(a=1,h=8;h<16;h++)a=a+(255&c[h])|0,c[h]=255&a,a>>>=8;i-=64,e+=64,r+=64}if(i>0)for(y(u,c,o,w),h=0;h=64;){for(y(h,a,i,w),o=0;o<64;o++)t[e+o]=h[o];for(s=1,o=8;o<16;o++)s=s+(255&a[o])|0,a[o]=255&s,s>>>=8;n-=64,e+=64}if(n>0)for(y(h,a,i,w),o=0;o>>13|n<<3),r=255&t[4]|(255&t[5])<<8,this.r[2]=7939&(n>>>10|r<<6),i=255&t[6]|(255&t[7])<<8,this.r[3]=8191&(r>>>7|i<<9),s=255&t[8]|(255&t[9])<<8,this.r[4]=255&(i>>>4|s<<12),this.r[5]=s>>>1&8190,o=255&t[10]|(255&t[11])<<8,this.r[6]=8191&(s>>>14|o<<2),a=255&t[12]|(255&t[13])<<8,this.r[7]=8065&(o>>>11|a<<5),h=255&t[14]|(255&t[15])<<8,this.r[8]=8191&(a>>>8|h<<8),this.r[9]=h>>>5&127,this.pad[0]=255&t[16]|(255&t[17])<<8,this.pad[1]=255&t[18]|(255&t[19])<<8,this.pad[2]=255&t[20]|(255&t[21])<<8,this.pad[3]=255&t[22]|(255&t[23])<<8,this.pad[4]=255&t[24]|(255&t[25])<<8,this.pad[5]=255&t[26]|(255&t[27])<<8,this.pad[6]=255&t[28]|(255&t[29])<<8,this.pad[7]=255&t[30]|(255&t[31])<<8};function E(t,e,n,r,i,s){var o=new T(s);return o.update(n,r,i),o.finish(t,e),0}function A(t,e,n,r,i,s){var o=new Uint8Array(16);return E(o,0,n,r,i,s),b(t,e,o,0)}function P(t,e,n,r,i){var s;if(n<32)return-1;for(C(t,0,e,0,n,r,i),E(t,16,t,32,n-32,t),s=0;s<16;s++)t[s]=0;return 0}function x(t,e,n,r,i){var s,o=new Uint8Array(32);if(n<32)return-1;if(k(o,0,32,r,i),0!==A(e,16,e,32,n-32,o))return-1;for(C(t,0,e,0,n,r,i),s=0;s<32;s++)t[s]=0;return 0}function O(t,e){var n;for(n=0;n<16;n++)t[n]=0|e[n]}function L(t){var e,n,r=1;for(e=0;e<16;e++)n=t[e]+r+65535,r=Math.floor(n/65536),t[e]=n-65536*r;t[0]+=r-1+37*(r-1)}function U(t,e,n){for(var r,i=~(n-1),s=0;s<16;s++)r=i&(t[s]^e[s]),t[s]^=r,e[s]^=r}function R(t,n){var r,i,s,o=e(),a=e();for(r=0;r<16;r++)a[r]=n[r];for(L(a),L(a),L(a),i=0;i<2;i++){for(o[0]=a[0]-65517,r=1;r<15;r++)o[r]=a[r]-65535-(o[r-1]>>16&1),o[r-1]&=65535;o[15]=a[15]-32767-(o[14]>>16&1),s=o[15]>>16&1,o[14]&=65535,U(a,o,1-s)}for(r=0;r<16;r++)t[2*r]=255&a[r],t[2*r+1]=a[r]>>8}function M(t,e){var n=new Uint8Array(32),r=new Uint8Array(32);return R(n,t),R(r,e),v(n,0,r,0)}function I(t){var e=new Uint8Array(32);return R(e,t),1&e[0]}function N(t,e){var n;for(n=0;n<16;n++)t[n]=e[2*n]+(e[2*n+1]<<8);t[15]&=32767}function j(t,e,n){for(var r=0;r<16;r++)t[r]=e[r]+n[r]}function D(t,e,n){for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w+=(r=e[15])*N,o+=38*(S+=r*D),a+=38*(k+=r*z),h+=38*(C+=r*H),c+=38*(T+=r*B),u+=38*(E+=r*F),l+=38*(A+=r*q),d+=38*(P+=r*Y),f+=38*(x+=r*K),p+=38*(O+=r*$),g+=38*(L+=r*J),b+=38*(U+=r*X),v+=38*(R+=r*W),y+=38*(M+=r*G),m+=38*(I+=r*V),s=(r=(s+=38*(_+=r*j))+(i=1)+65535)-65536*(i=Math.floor(r/65536)),o=(r=o+i+65535)-65536*(i=Math.floor(r/65536)),a=(r=a+i+65535)-65536*(i=Math.floor(r/65536)),h=(r=h+i+65535)-65536*(i=Math.floor(r/65536)),c=(r=c+i+65535)-65536*(i=Math.floor(r/65536)),u=(r=u+i+65535)-65536*(i=Math.floor(r/65536)),l=(r=l+i+65535)-65536*(i=Math.floor(r/65536)),d=(r=d+i+65535)-65536*(i=Math.floor(r/65536)),f=(r=f+i+65535)-65536*(i=Math.floor(r/65536)),p=(r=p+i+65535)-65536*(i=Math.floor(r/65536)),g=(r=g+i+65535)-65536*(i=Math.floor(r/65536)),b=(r=b+i+65535)-65536*(i=Math.floor(r/65536)),v=(r=v+i+65535)-65536*(i=Math.floor(r/65536)),y=(r=y+i+65535)-65536*(i=Math.floor(r/65536)),m=(r=m+i+65535)-65536*(i=Math.floor(r/65536)),w=(r=w+i+65535)-65536*(i=Math.floor(r/65536)),s=(r=(s+=i-1+37*(i-1))+(i=1)+65535)-65536*(i=Math.floor(r/65536)),o=(r=o+i+65535)-65536*(i=Math.floor(r/65536)),a=(r=a+i+65535)-65536*(i=Math.floor(r/65536)),h=(r=h+i+65535)-65536*(i=Math.floor(r/65536)),c=(r=c+i+65535)-65536*(i=Math.floor(r/65536)),u=(r=u+i+65535)-65536*(i=Math.floor(r/65536)),l=(r=l+i+65535)-65536*(i=Math.floor(r/65536)),d=(r=d+i+65535)-65536*(i=Math.floor(r/65536)),f=(r=f+i+65535)-65536*(i=Math.floor(r/65536)),p=(r=p+i+65535)-65536*(i=Math.floor(r/65536)),g=(r=g+i+65535)-65536*(i=Math.floor(r/65536)),b=(r=b+i+65535)-65536*(i=Math.floor(r/65536)),v=(r=v+i+65535)-65536*(i=Math.floor(r/65536)),y=(r=y+i+65535)-65536*(i=Math.floor(r/65536)),m=(r=m+i+65535)-65536*(i=Math.floor(r/65536)),w=(r=w+i+65535)-65536*(i=Math.floor(r/65536)),s+=i-1+37*(i-1),t[0]=s,t[1]=o,t[2]=a,t[3]=h,t[4]=c,t[5]=u,t[6]=l,t[7]=d,t[8]=f,t[9]=p,t[10]=g,t[11]=b,t[12]=v,t[13]=y,t[14]=m,t[15]=w}function H(t,e){z(t,e,e)}function B(t,n){var r,i=e();for(r=0;r<16;r++)i[r]=n[r];for(r=253;r>=0;r--)H(i,i),2!==r&&4!==r&&z(i,i,n);for(r=0;r<16;r++)t[r]=i[r]}function F(t,n){var r,i=e();for(r=0;r<16;r++)i[r]=n[r];for(r=250;r>=0;r--)H(i,i),1!==r&&z(i,i,n);for(r=0;r<16;r++)t[r]=i[r]}function q(t,n,r){var i,s,o=new Uint8Array(32),a=new Float64Array(80),c=e(),u=e(),l=e(),d=e(),f=e(),p=e();for(s=0;s<31;s++)o[s]=n[s];for(o[31]=127&n[31]|64,o[0]&=248,N(a,r),s=0;s<16;s++)u[s]=a[s],d[s]=c[s]=l[s]=0;for(c[0]=d[0]=1,s=254;s>=0;--s)U(c,u,i=o[s>>>3]>>>(7&s)&1),U(l,d,i),j(f,c,l),D(c,c,l),j(l,u,d),D(u,u,d),H(d,f),H(p,c),z(c,l,c),z(l,u,f),j(f,c,l),D(c,c,l),H(u,c),D(l,d,p),z(c,l,h),j(c,c,d),z(l,l,c),z(c,d,p),z(d,u,a),H(u,f),U(c,u,i),U(l,d,i);for(s=0;s<16;s++)a[s+16]=c[s],a[s+32]=l[s],a[s+48]=u[s],a[s+64]=d[s];var g=a.subarray(32),b=a.subarray(16);return B(g,g),z(b,b,g),R(t,b),0}function Y(t,e){return q(t,e,s)}function K(t,e){return r(e,32),Y(t,e)}function $(t,e,n){var r=new Uint8Array(32);return q(r,n,e),m(t,i,r,w)}T.prototype.blocks=function(t,e,n){for(var r,i,s,o,a,h,c,u,l,d,f,p,g,b,v,y,m,w,_,S=this.fin?0:2048,k=this.h[0],C=this.h[1],T=this.h[2],E=this.h[3],A=this.h[4],P=this.h[5],x=this.h[6],O=this.h[7],L=this.h[8],U=this.h[9],R=this.r[0],M=this.r[1],I=this.r[2],N=this.r[3],j=this.r[4],D=this.r[5],z=this.r[6],H=this.r[7],B=this.r[8],F=this.r[9];n>=16;)d=l=0,d+=(k+=8191&(r=255&t[e+0]|(255&t[e+1])<<8))*R,d+=(C+=8191&(r>>>13|(i=255&t[e+2]|(255&t[e+3])<<8)<<3))*(5*F),d+=(T+=8191&(i>>>10|(s=255&t[e+4]|(255&t[e+5])<<8)<<6))*(5*B),d+=(E+=8191&(s>>>7|(o=255&t[e+6]|(255&t[e+7])<<8)<<9))*(5*H),l=(d+=(A+=8191&(o>>>4|(a=255&t[e+8]|(255&t[e+9])<<8)<<12))*(5*z))>>>13,d&=8191,d+=(P+=a>>>1&8191)*(5*D),d+=(x+=8191&(a>>>14|(h=255&t[e+10]|(255&t[e+11])<<8)<<2))*(5*j),d+=(O+=8191&(h>>>11|(c=255&t[e+12]|(255&t[e+13])<<8)<<5))*(5*N),d+=(L+=8191&(c>>>8|(u=255&t[e+14]|(255&t[e+15])<<8)<<8))*(5*I),f=l+=(d+=(U+=u>>>5|S)*(5*M))>>>13,f+=k*M,f+=C*R,f+=T*(5*F),f+=E*(5*B),l=(f+=A*(5*H))>>>13,f&=8191,f+=P*(5*z),f+=x*(5*D),f+=O*(5*j),f+=L*(5*N),l+=(f+=U*(5*I))>>>13,f&=8191,p=l,p+=k*I,p+=C*M,p+=T*R,p+=E*(5*F),l=(p+=A*(5*B))>>>13,p&=8191,p+=P*(5*H),p+=x*(5*z),p+=O*(5*D),p+=L*(5*j),g=l+=(p+=U*(5*N))>>>13,g+=k*N,g+=C*I,g+=T*M,g+=E*R,l=(g+=A*(5*F))>>>13,g&=8191,g+=P*(5*B),g+=x*(5*H),g+=O*(5*z),g+=L*(5*D),b=l+=(g+=U*(5*j))>>>13,b+=k*j,b+=C*N,b+=T*I,b+=E*M,l=(b+=A*R)>>>13,b&=8191,b+=P*(5*F),b+=x*(5*B),b+=O*(5*H),b+=L*(5*z),v=l+=(b+=U*(5*D))>>>13,v+=k*D,v+=C*j,v+=T*N,v+=E*I,l=(v+=A*M)>>>13,v&=8191,v+=P*R,v+=x*(5*F),v+=O*(5*B),v+=L*(5*H),y=l+=(v+=U*(5*z))>>>13,y+=k*z,y+=C*D,y+=T*j,y+=E*N,l=(y+=A*I)>>>13,y&=8191,y+=P*M,y+=x*R,y+=O*(5*F),y+=L*(5*B),m=l+=(y+=U*(5*H))>>>13,m+=k*H,m+=C*z,m+=T*D,m+=E*j,l=(m+=A*N)>>>13,m&=8191,m+=P*I,m+=x*M,m+=O*R,m+=L*(5*F),w=l+=(m+=U*(5*B))>>>13,w+=k*B,w+=C*H,w+=T*z,w+=E*D,l=(w+=A*j)>>>13,w&=8191,w+=P*N,w+=x*I,w+=O*M,w+=L*R,_=l+=(w+=U*(5*F))>>>13,_+=k*F,_+=C*B,_+=T*H,_+=E*z,l=(_+=A*D)>>>13,_&=8191,_+=P*j,_+=x*N,_+=O*I,_+=L*M,k=d=8191&(l=(l=((l+=(_+=U*R)>>>13)<<2)+l|0)+(d&=8191)|0),C=f+=l>>>=13,T=p&=8191,E=g&=8191,A=b&=8191,P=v&=8191,x=y&=8191,O=m&=8191,L=w&=8191,U=_&=8191,e+=16,n-=16;this.h[0]=k,this.h[1]=C,this.h[2]=T,this.h[3]=E,this.h[4]=A,this.h[5]=P,this.h[6]=x,this.h[7]=O,this.h[8]=L,this.h[9]=U},T.prototype.finish=function(t,e){var n,r,i,s,o=new Uint16Array(10);if(this.leftover){for(s=this.leftover,this.buffer[s++]=1;s<16;s++)this.buffer[s]=0;this.fin=1,this.blocks(this.buffer,0,16)}for(n=this.h[1]>>>13,this.h[1]&=8191,s=2;s<10;s++)this.h[s]+=n,n=this.h[s]>>>13,this.h[s]&=8191;for(this.h[0]+=5*n,n=this.h[0]>>>13,this.h[0]&=8191,this.h[1]+=n,n=this.h[1]>>>13,this.h[1]&=8191,this.h[2]+=n,o[0]=this.h[0]+5,n=o[0]>>>13,o[0]&=8191,s=1;s<10;s++)o[s]=this.h[s]+n,n=o[s]>>>13,o[s]&=8191;for(o[9]-=8192,r=(1^n)-1,s=0;s<10;s++)o[s]&=r;for(r=~r,s=0;s<10;s++)this.h[s]=this.h[s]&r|o[s];for(this.h[0]=65535&(this.h[0]|this.h[1]<<13),this.h[1]=65535&(this.h[1]>>>3|this.h[2]<<10),this.h[2]=65535&(this.h[2]>>>6|this.h[3]<<7),this.h[3]=65535&(this.h[3]>>>9|this.h[4]<<4),this.h[4]=65535&(this.h[4]>>>12|this.h[5]<<1|this.h[6]<<14),this.h[5]=65535&(this.h[6]>>>2|this.h[7]<<11),this.h[6]=65535&(this.h[7]>>>5|this.h[8]<<8),this.h[7]=65535&(this.h[8]>>>8|this.h[9]<<5),i=this.h[0]+this.pad[0],this.h[0]=65535&i,s=1;s<8;s++)i=(this.h[s]+this.pad[s]|0)+(i>>>16)|0,this.h[s]=65535&i;t[e+0]=this.h[0]>>>0&255,t[e+1]=this.h[0]>>>8&255,t[e+2]=this.h[1]>>>0&255,t[e+3]=this.h[1]>>>8&255,t[e+4]=this.h[2]>>>0&255,t[e+5]=this.h[2]>>>8&255,t[e+6]=this.h[3]>>>0&255,t[e+7]=this.h[3]>>>8&255,t[e+8]=this.h[4]>>>0&255,t[e+9]=this.h[4]>>>8&255,t[e+10]=this.h[5]>>>0&255,t[e+11]=this.h[5]>>>8&255,t[e+12]=this.h[6]>>>0&255,t[e+13]=this.h[6]>>>8&255,t[e+14]=this.h[7]>>>0&255,t[e+15]=this.h[7]>>>8&255},T.prototype.update=function(t,e,n){var r,i;if(this.leftover){for((i=16-this.leftover)>n&&(i=n),r=0;r=16&&(i=n-n%16,this.blocks(t,e,i),e+=i,n-=i),n){for(r=0;r=128;){for(S=0;S<16;S++)k=8*S+X,O[S]=n[k+0]<<24|n[k+1]<<16|n[k+2]<<8|n[k+3],L[S]=n[k+4]<<24|n[k+5]<<16|n[k+6]<<8|n[k+7];for(S=0;S<80;S++)if(i=U,s=R,o=M,a=I,h=N,c=j,u=D,z,d=H,f=B,p=F,g=q,b=Y,v=K,y=$,J,E=65535&(T=J),A=T>>>16,P=65535&(C=z),x=C>>>16,E+=65535&(T=(Y>>>14|N<<18)^(Y>>>18|N<<14)^(N>>>9|Y<<23)),A+=T>>>16,P+=65535&(C=(N>>>14|Y<<18)^(N>>>18|Y<<14)^(Y>>>9|N<<23)),x+=C>>>16,E+=65535&(T=Y&K^~Y&$),A+=T>>>16,P+=65535&(C=N&j^~N&D),x+=C>>>16,E+=65535&(T=W[2*S+1]),A+=T>>>16,P+=65535&(C=W[2*S]),x+=C>>>16,C=O[S%16],A+=(T=L[S%16])>>>16,P+=65535&C,x+=C>>>16,P+=(A+=(E+=65535&T)>>>16)>>>16,E=65535&(T=_=65535&E|A<<16),A=T>>>16,P=65535&(C=w=65535&P|(x+=P>>>16)<<16),x=C>>>16,E+=65535&(T=(H>>>28|U<<4)^(U>>>2|H<<30)^(U>>>7|H<<25)),A+=T>>>16,P+=65535&(C=(U>>>28|H<<4)^(H>>>2|U<<30)^(H>>>7|U<<25)),x+=C>>>16,A+=(T=H&B^H&F^B&F)>>>16,P+=65535&(C=U&R^U&M^R&M),x+=C>>>16,l=65535&(P+=(A+=(E+=65535&T)>>>16)>>>16)|(x+=P>>>16)<<16,m=65535&E|A<<16,E=65535&(T=g),A=T>>>16,P=65535&(C=a),x=C>>>16,A+=(T=_)>>>16,P+=65535&(C=w),x+=C>>>16,R=i,M=s,I=o,N=a=65535&(P+=(A+=(E+=65535&T)>>>16)>>>16)|(x+=P>>>16)<<16,j=h,D=c,z=u,U=l,B=d,F=f,q=p,Y=g=65535&E|A<<16,K=b,$=v,J=y,H=m,S%16==15)for(k=0;k<16;k++)C=O[k],E=65535&(T=L[k]),A=T>>>16,P=65535&C,x=C>>>16,C=O[(k+9)%16],E+=65535&(T=L[(k+9)%16]),A+=T>>>16,P+=65535&C,x+=C>>>16,w=O[(k+1)%16],E+=65535&(T=((_=L[(k+1)%16])>>>1|w<<31)^(_>>>8|w<<24)^(_>>>7|w<<25)),A+=T>>>16,P+=65535&(C=(w>>>1|_<<31)^(w>>>8|_<<24)^w>>>7),x+=C>>>16,w=O[(k+14)%16],A+=(T=((_=L[(k+14)%16])>>>19|w<<13)^(w>>>29|_<<3)^(_>>>6|w<<26))>>>16,P+=65535&(C=(w>>>19|_<<13)^(_>>>29|w<<3)^w>>>6),x+=C>>>16,x+=(P+=(A+=(E+=65535&T)>>>16)>>>16)>>>16,O[k]=65535&P|x<<16,L[k]=65535&E|A<<16;E=65535&(T=H),A=T>>>16,P=65535&(C=U),x=C>>>16,C=t[0],A+=(T=e[0])>>>16,P+=65535&C,x+=C>>>16,x+=(P+=(A+=(E+=65535&T)>>>16)>>>16)>>>16,t[0]=U=65535&P|x<<16,e[0]=H=65535&E|A<<16,E=65535&(T=B),A=T>>>16,P=65535&(C=R),x=C>>>16,C=t[1],A+=(T=e[1])>>>16,P+=65535&C,x+=C>>>16,x+=(P+=(A+=(E+=65535&T)>>>16)>>>16)>>>16,t[1]=R=65535&P|x<<16,e[1]=B=65535&E|A<<16,E=65535&(T=F),A=T>>>16,P=65535&(C=M),x=C>>>16,C=t[2],A+=(T=e[2])>>>16,P+=65535&C,x+=C>>>16,x+=(P+=(A+=(E+=65535&T)>>>16)>>>16)>>>16,t[2]=M=65535&P|x<<16,e[2]=F=65535&E|A<<16,E=65535&(T=q),A=T>>>16,P=65535&(C=I),x=C>>>16,C=t[3],A+=(T=e[3])>>>16,P+=65535&C,x+=C>>>16,x+=(P+=(A+=(E+=65535&T)>>>16)>>>16)>>>16,t[3]=I=65535&P|x<<16,e[3]=q=65535&E|A<<16,E=65535&(T=Y),A=T>>>16,P=65535&(C=N),x=C>>>16,C=t[4],A+=(T=e[4])>>>16,P+=65535&C,x+=C>>>16,x+=(P+=(A+=(E+=65535&T)>>>16)>>>16)>>>16,t[4]=N=65535&P|x<<16,e[4]=Y=65535&E|A<<16,E=65535&(T=K),A=T>>>16,P=65535&(C=j),x=C>>>16,C=t[5],A+=(T=e[5])>>>16,P+=65535&C,x+=C>>>16,x+=(P+=(A+=(E+=65535&T)>>>16)>>>16)>>>16,t[5]=j=65535&P|x<<16,e[5]=K=65535&E|A<<16,E=65535&(T=$),A=T>>>16,P=65535&(C=D),x=C>>>16,C=t[6],A+=(T=e[6])>>>16,P+=65535&C,x+=C>>>16,x+=(P+=(A+=(E+=65535&T)>>>16)>>>16)>>>16,t[6]=D=65535&P|x<<16,e[6]=$=65535&E|A<<16,E=65535&(T=J),A=T>>>16,P=65535&(C=z),x=C>>>16,C=t[7],A+=(T=e[7])>>>16,P+=65535&C,x+=C>>>16,x+=(P+=(A+=(E+=65535&T)>>>16)>>>16)>>>16,t[7]=z=65535&P|x<<16,e[7]=J=65535&E|A<<16,X+=128,r-=128}return r}function V(t,e,n){var r,i=new Int32Array(8),s=new Int32Array(8),o=new Uint8Array(256),a=n;for(i[0]=1779033703,i[1]=3144134277,i[2]=1013904242,i[3]=2773480762,i[4]=1359893119,i[5]=2600822924,i[6]=528734635,i[7]=1541459225,s[0]=4089235720,s[1]=2227873595,s[2]=4271175723,s[3]=1595750129,s[4]=2917565137,s[5]=725511199,s[6]=4215389547,s[7]=327033209,G(i,s,e,n),n%=128,r=0;r=0;--i)Q(t,e,r=n[i/8|0]>>(7&i)&1),Z(e,t),Z(t,t),Q(t,e,r)}function nt(t,n){var r=[e(),e(),e(),e()];O(r[0],l),O(r[1],d),O(r[2],a),z(r[3],l,d),et(t,r,n)}function rt(t,n,i){var s,o=new Uint8Array(64),a=[e(),e(),e(),e()];for(i||r(n,32),V(o,n,32),o[0]&=248,o[31]&=127,o[31]|=64,nt(a,o),tt(t,a),s=0;s<32;s++)n[s+32]=t[s];return 0}var it=new Float64Array([237,211,245,92,26,99,18,88,214,156,247,162,222,249,222,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16]);function st(t,e){var n,r,i,s;for(r=63;r>=32;--r){for(n=0,i=r-32,s=r-12;i>4)*it[i],n=e[i]>>8,e[i]&=255;for(i=0;i<32;i++)e[i]-=n*it[i];for(r=0;r<32;r++)e[r+1]+=e[r]>>8,t[r]=255&e[r]}function ot(t){var e,n=new Float64Array(64);for(e=0;e<64;e++)n[e]=t[e];for(e=0;e<64;e++)t[e]=0;st(t,n)}function at(t,n,r,i){var s,o,a=new Uint8Array(64),h=new Uint8Array(64),c=new Uint8Array(64),u=new Float64Array(64),l=[e(),e(),e(),e()];V(a,i,32),a[0]&=248,a[31]&=127,a[31]|=64;var d=r+64;for(s=0;s>7&&D(t[0],o,t[0]),z(t[3],t[0],t[1]),0)}(d,i))return-1;for(s=0;s=0},t.sign.keyPair=function(){var t=new Uint8Array(32),e=new Uint8Array(64);return rt(t,e),{publicKey:t,secretKey:e}},t.sign.keyPair.fromSecretKey=function(t){if(ut(t),64!==t.length)throw new Error("bad secret key size");for(var e=new Uint8Array(32),n=0;n{t.console&&t.console.log&&t.console.log(e)}}debug(...t){this.log(this.globalLog,t)}warn(...t){this.log(this.globalLogWarn,t)}error(...t){this.log(this.globalLogError,t)}globalLogWarn(e){t.console&&t.console.warn?t.console.warn(e):this.globalLog(e)}globalLogError(e){t.console&&t.console.error?t.console.error(e):this.globalLogWarn(e)}log(t,...e){var n=r.m.apply(this,arguments);if(i.a.log)i.a.log(n);else if(i.a.logToConsole){t.bind(this)(n)}}}}).call(this,n(6))},function(t,e,n){"use strict";var r=n(4),i={now:()=>Date.now?Date.now():(new Date).valueOf(),defer:t=>new r.a(0,t),method(t,...e){var n=Array.prototype.slice.call(arguments,1);return function(e){return e[t].apply(e,n.concat(arguments))}}};e.a=i},function(t,e,n){"use strict";(function(t){n.d(e,"a",(function(){return s}));var r=n(0),i=n(12);class s{constructor(t){this.callbacks=new i.a,this.global_callbacks=[],this.failThrough=t}bind(t,e,n){return this.callbacks.add(t,e,n),this}bind_global(t){return this.global_callbacks.push(t),this}unbind(t,e,n){return this.callbacks.remove(t,e,n),this}unbind_global(t){return t?(this.global_callbacks=r.g(this.global_callbacks||[],e=>e!==t),this):(this.global_callbacks=[],this)}unbind_all(){return this.unbind(),this.unbind_global(),this}emit(e,n,r){for(var i=0;i0)for(i=0;i{this.onError(t),this.changeState("closed")}),!1}return this.bindListeners(),l.a.debug("Connecting",{transport:this.name,url:t}),this.changeState("connecting"),!0}close(){return!!this.socket&&(this.socket.close(),!0)}send(t){return"open"===this.state&&(c.a.defer(()=>{this.socket&&this.socket.send(t)}),!0)}ping(){"open"===this.state&&this.supportsPing()&&this.socket.ping()}onOpen(){this.hooks.beforeOpen&&this.hooks.beforeOpen(this.socket,this.hooks.urls.getPath(this.key,this.options)),this.changeState("open"),this.socket.onopen=void 0}onError(t){this.emit("error",{type:"WebSocketError",error:t}),this.timeline.error(this.buildTimelineMessage({error:t.toString()}))}onClose(t){t?this.changeState("closed",{code:t.code,reason:t.reason,wasClean:t.wasClean}):this.changeState("closed"),this.unbindListeners(),this.socket=void 0}onMessage(t){this.emit("message",t)}onActivity(){this.emit("activity")}bindListeners(){this.socket.onopen=()=>{this.onOpen()},this.socket.onerror=t=>{this.onError(t)},this.socket.onclose=t=>{this.onClose(t)},this.socket.onmessage=t=>{this.onMessage(t)},this.supportsPing()&&(this.socket.onactivity=()=>{this.onActivity()})}unbindListeners(){this.socket&&(this.socket.onopen=void 0,this.socket.onerror=void 0,this.socket.onclose=void 0,this.socket.onmessage=void 0,this.supportsPing()&&(this.socket.onactivity=void 0))}changeState(t,e){this.state=t,this.timeline.info(this.buildTimelineMessage({state:t,params:e})),this.emit(t,e)}buildTimelineMessage(t){return r.f({cid:this.id},t)}}class f{constructor(t){this.hooks=t}isSupported(t){return this.hooks.isSupported(t)}createConnection(t,e,n,r){return new d(this.hooks,t,e,n,r)}}var p=new f({urls:a,handlesActivityChecks:!1,supportsPing:!1,isInitialized:function(){return Boolean(zt.getWebSocketAPI())},isSupported:function(){return Boolean(zt.getWebSocketAPI())},getSocket:function(t){return zt.createWebSocket(t)}}),g={urls:h,handlesActivityChecks:!1,supportsPing:!0,isInitialized:function(){return!0}},b=r.f({getSocket:function(t){return zt.HTTPFactory.createStreamingSocket(t)}},g),v=r.f({getSocket:function(t){return zt.HTTPFactory.createPollingSocket(t)}},g),y={isSupported:function(){return zt.isXHRSupported()}},m={ws:p,xhr_streaming:new f(r.f({},b,y)),xhr_polling:new f(r.f({},v,y))};class w{constructor(t,e,n){this.manager=t,this.transport=e,this.minPingDelay=n.minPingDelay,this.maxPingDelay=n.maxPingDelay,this.pingDelay=void 0}createConnection(t,e,n,i){i=r.f({},i,{activityTimeout:this.pingDelay});var s=this.transport.createConnection(t,e,n,i),o=null,a=function(){s.unbind("open",a),s.bind("closed",h),o=c.a.now()},h=t=>{if(s.unbind("closed",h),1002===t.code||1003===t.code)this.manager.reportDeath();else if(!t.wasClean&&o){var e=c.a.now()-o;e<2*this.maxPingDelay&&(this.manager.reportDeath(),this.pingDelay=Math.max(e/2,this.minPingDelay))}};return s.bind("open",a),s}isSupported(t){return this.manager.isAlive()&&this.transport.isSupported(t)}}const _={decodeMessage:function(t){try{var e=JSON.parse(t.data),n=e.data;if("string"==typeof n)try{n=JSON.parse(e.data)}catch(t){}var r={event:e.event,channel:e.channel,data:n};return e.user_id&&(r.user_id=e.user_id),r}catch(e){throw{type:"MessageParseError",error:e,data:t.data}}},encodeMessage:function(t){return JSON.stringify(t)},processHandshake:function(t){var e=_.decodeMessage(t);if("pusher:connection_established"===e.event){if(!e.data.activity_timeout)throw"No activity timeout specified in handshake";return{action:"connected",id:e.data.socket_id,activityTimeout:1e3*e.data.activity_timeout}}if("pusher:error"===e.event)return{action:this.getCloseAction(e.data),error:this.getCloseError(e.data)};throw"Invalid handshake"},getCloseAction:function(t){return t.code<4e3?t.code>=1002&&t.code<=1004?"backoff":null:4e3===t.code?"tls_only":t.code<4100?"refused":t.code<4200?"backoff":t.code<4300?"retry":"refused"},getCloseError:function(t){return 1e3!==t.code&&1001!==t.code?{type:"PusherError",data:{code:t.code,message:t.reason||t.message}}:null}};var S=_;class k extends u.a{constructor(t,e){super(),this.id=t,this.transport=e,this.activityTimeout=e.activityTimeout,this.bindListeners()}handlesActivityChecks(){return this.transport.handlesActivityChecks()}send(t){return this.transport.send(t)}send_event(t,e,n){var r={event:t,data:e};return n&&(r.channel=n),l.a.debug("Event sent",r),this.send(S.encodeMessage(r))}ping(){this.transport.supportsPing()?this.transport.ping():this.send_event("pusher:ping",{})}close(){this.transport.close()}bindListeners(){var t={message:t=>{var e;try{e=S.decodeMessage(t)}catch(e){this.emit("error",{type:"MessageParseError",error:e,data:t.data})}if(void 0!==e){switch(l.a.debug("Event recd",e),e.event){case"pusher:error":this.emit("error",{type:"PusherError",data:e.data});break;case"pusher:ping":this.emit("ping");break;case"pusher:pong":this.emit("pong")}this.emit("message",e)}},activity:()=>{this.emit("activity")},error:t=>{this.emit("error",t)},closed:t=>{e(),t&&t.code&&this.handleCloseEvent(t),this.transport=null,this.emit("closed")}},e=()=>{r.k(t,(t,e)=>{this.transport.unbind(e,t)})};r.k(t,(t,e)=>{this.transport.bind(e,t)})}handleCloseEvent(t){var e=S.getCloseAction(t),n=S.getCloseError(t);n&&this.emit("error",n),e&&this.emit(e,{action:e,error:n})}}class C{constructor(t,e){this.transport=t,this.callback=e,this.bindListeners()}close(){this.unbindListeners(),this.transport.close()}bindListeners(){this.onMessage=t=>{var e;this.unbindListeners();try{e=S.processHandshake(t)}catch(t){return this.finish("error",{error:t}),void this.transport.close()}"connected"===e.action?this.finish("connected",{connection:new k(e.id,this.transport),activityTimeout:e.activityTimeout}):(this.finish(e.action,{error:e.error}),this.transport.close())},this.onClosed=t=>{this.unbindListeners();var e=S.getCloseAction(t)||"backoff",n=S.getCloseError(t);this.finish(e,{error:n})},this.transport.bind("message",this.onMessage),this.transport.bind("closed",this.onClosed)}unbindListeners(){this.transport.unbind("message",this.onMessage),this.transport.unbind("closed",this.onClosed)}finish(t,e){this.callback(r.f({transport:this.transport,action:t},e))}}class T{constructor(t,e){this.timeline=t,this.options=e||{}}send(t,e){this.timeline.isEmpty()||this.timeline.send(zt.TimelineTransport.getAgent(this,t),e)}}class E extends Error{constructor(t){super(t),Object.setPrototypeOf(this,new.target.prototype)}}class A extends Error{constructor(t){super(t),Object.setPrototypeOf(this,new.target.prototype)}}Error;class P extends Error{constructor(t){super(t),Object.setPrototypeOf(this,new.target.prototype)}}class x extends Error{constructor(t){super(t),Object.setPrototypeOf(this,new.target.prototype)}}class O extends Error{constructor(t){super(t),Object.setPrototypeOf(this,new.target.prototype)}}class L extends Error{constructor(t){super(t),Object.setPrototypeOf(this,new.target.prototype)}}class U extends Error{constructor(t){super(t),Object.setPrototypeOf(this,new.target.prototype)}}class R extends Error{constructor(t,e){super(e),this.status=t,Object.setPrototypeOf(this,new.target.prototype)}}const M={baseUrl:"https://pusher.com",urls:{authenticationEndpoint:{path:"/docs/channels/server_api/authenticating_users"},authorizationEndpoint:{path:"/docs/channels/server_api/authorizing-users/"},javascriptQuickStart:{path:"/docs/javascript_quick_start"},triggeringClientEvents:{path:"/docs/client_api_guide/client_events#trigger-events"},encryptedChannelSupport:{fullUrl:"https://github.com/pusher/pusher-js/tree/cc491015371a4bde5743d1c87a0fbac0feb53195#encrypted-channel-support"}}};var I=function(t){const e=M.urls[t];if(!e)return"";let n;return e.fullUrl?n=e.fullUrl:e.path&&(n=M.baseUrl+e.path),n?"See: "+n:""};class N extends u.a{constructor(t,e){super((function(e,n){l.a.debug("No callbacks on "+t+" for "+e)})),this.name=t,this.pusher=e,this.subscribed=!1,this.subscriptionPending=!1,this.subscriptionCancelled=!1}authorize(t,e){return e(null,{auth:""})}trigger(t,e){if(0!==t.indexOf("client-"))throw new E("Event '"+t+"' does not start with 'client-'");if(!this.subscribed){var n=I("triggeringClientEvents");l.a.warn("Client event triggered before channel 'subscription_succeeded' event . "+n)}return this.pusher.send_event(t,e,this.name)}disconnect(){this.subscribed=!1,this.subscriptionPending=!1}handleEvent(t){var e=t.event,n=t.data;if("pusher_internal:subscription_succeeded"===e)this.handleSubscriptionSucceededEvent(t);else if("pusher_internal:subscription_count"===e)this.handleSubscriptionCountEvent(t);else if(0!==e.indexOf("pusher_internal:")){this.emit(e,n,{})}}handleSubscriptionSucceededEvent(t){this.subscriptionPending=!1,this.subscribed=!0,this.subscriptionCancelled?this.pusher.unsubscribe(this.name):this.emit("pusher:subscription_succeeded",t.data)}handleSubscriptionCountEvent(t){t.data.subscription_count&&(this.subscriptionCount=t.data.subscription_count),this.emit("pusher:subscription_count",t.data)}subscribe(){this.subscribed||(this.subscriptionPending=!0,this.subscriptionCancelled=!1,this.authorize(this.pusher.connection.socket_id,(t,e)=>{t?(this.subscriptionPending=!1,l.a.error(t.toString()),this.emit("pusher:subscription_error",Object.assign({},{type:"AuthError",error:t.message},t instanceof R?{status:t.status}:{}))):this.pusher.send_event("pusher:subscribe",{auth:e.auth,channel_data:e.channel_data,channel:this.name})}))}unsubscribe(){this.subscribed=!1,this.pusher.send_event("pusher:unsubscribe",{channel:this.name})}cancelSubscription(){this.subscriptionCancelled=!0}reinstateSubscription(){this.subscriptionCancelled=!1}}class j extends N{authorize(t,e){return this.pusher.config.channelAuthorizer({channelName:this.name,socketId:t},e)}}class D{constructor(){this.reset()}get(t){return Object.prototype.hasOwnProperty.call(this.members,t)?{id:t,info:this.members[t]}:null}each(t){r.k(this.members,(e,n)=>{t(this.get(n))})}setMyID(t){this.myID=t}onSubscription(t){this.members=t.presence.hash,this.count=t.presence.count,this.me=this.get(this.myID)}addMember(t){return null===this.get(t.user_id)&&this.count++,this.members[t.user_id]=t.user_info,this.get(t.user_id)}removeMember(t){var e=this.get(t.user_id);return e&&(delete this.members[t.user_id],this.count--),e}reset(){this.members={},this.count=0,this.myID=null,this.me=null}}var z=function(t,e,n,r){return new(n||(n=Promise))((function(i,s){function o(t){try{h(r.next(t))}catch(t){s(t)}}function a(t){try{h(r.throw(t))}catch(t){s(t)}}function h(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(o,a)}h((r=r.apply(t,e||[])).next())}))};class H extends j{constructor(t,e){super(t,e),this.members=new D}authorize(t,e){super.authorize(t,(t,n)=>z(this,void 0,void 0,(function*(){if(!t)if(null!=(n=n).channel_data){var r=JSON.parse(n.channel_data);this.members.setMyID(r.user_id)}else{if(yield this.pusher.user.signinDonePromise,null==this.pusher.user.user_data){let t=I("authorizationEndpoint");return l.a.error(`Invalid auth response for channel '${this.name}', expected 'channel_data' field. ${t}, or the user should be signed in.`),void e("Invalid auth response")}this.members.setMyID(this.pusher.user.user_data.id)}e(t,n)})))}handleEvent(t){var e=t.event;if(0===e.indexOf("pusher_internal:"))this.handleInternalEvent(t);else{var n=t.data,r={};t.user_id&&(r.user_id=t.user_id),this.emit(e,n,r)}}handleInternalEvent(t){var e=t.event,n=t.data;switch(e){case"pusher_internal:subscription_succeeded":this.handleSubscriptionSucceededEvent(t);break;case"pusher_internal:subscription_count":this.handleSubscriptionCountEvent(t);break;case"pusher_internal:member_added":var r=this.members.addMember(n);this.emit("pusher:member_added",r);break;case"pusher_internal:member_removed":var i=this.members.removeMember(n);i&&this.emit("pusher:member_removed",i)}}handleSubscriptionSucceededEvent(t){this.subscriptionPending=!1,this.subscribed=!0,this.subscriptionCancelled?this.pusher.unsubscribe(this.name):(this.members.onSubscription(t.data),this.emit("pusher:subscription_succeeded",this.members))}disconnect(){this.members.reset(),super.disconnect()}}var B=n(13),F=n(8);class q extends j{constructor(t,e,n){super(t,e),this.key=null,this.nacl=n}authorize(t,e){super.authorize(t,(t,n)=>{if(t)return void e(t,n);let r=n.shared_secret;r?(this.key=Object(F.decode)(r),delete n.shared_secret,e(null,n)):e(new Error("No shared_secret key in auth payload for encrypted channel: "+this.name),null)})}trigger(t,e){throw new O("Client events are not currently supported for encrypted channels")}handleEvent(t){var e=t.event,n=t.data;0!==e.indexOf("pusher_internal:")&&0!==e.indexOf("pusher:")?this.handleEncryptedEvent(e,n):super.handleEvent(t)}handleEncryptedEvent(t,e){if(!this.key)return void l.a.debug("Received encrypted event before key has been retrieved from the authEndpoint");if(!e.ciphertext||!e.nonce)return void l.a.error("Unexpected format for encrypted event, expected object with `ciphertext` and `nonce` fields, got: "+e);let n=Object(F.decode)(e.ciphertext);if(n.length{e?l.a.error(`Failed to make a request to the authEndpoint: ${s}. Unable to fetch new key, so dropping encrypted event`):(i=this.nacl.secretbox.open(n,r,this.key),null!==i?this.emit(t,this.getDataToEmit(i)):l.a.error("Failed to decrypt event with new key. Dropping encrypted event"))});this.emit(t,this.getDataToEmit(i))}getDataToEmit(t){let e=Object(B.decode)(t);try{return JSON.parse(e)}catch(t){return e}}}var Y=n(4);class K extends u.a{constructor(t,e){super(),this.state="initialized",this.connection=null,this.key=t,this.options=e,this.timeline=this.options.timeline,this.usingTLS=this.options.useTLS,this.errorCallbacks=this.buildErrorCallbacks(),this.connectionCallbacks=this.buildConnectionCallbacks(this.errorCallbacks),this.handshakeCallbacks=this.buildHandshakeCallbacks(this.errorCallbacks);var n=zt.getNetwork();n.bind("online",()=>{this.timeline.info({netinfo:"online"}),"connecting"!==this.state&&"unavailable"!==this.state||this.retryIn(0)}),n.bind("offline",()=>{this.timeline.info({netinfo:"offline"}),this.connection&&this.sendActivityCheck()}),this.updateStrategy()}switchCluster(t){this.key=t,this.updateStrategy(),this.retryIn(0)}connect(){this.connection||this.runner||(this.strategy.isSupported()?(this.updateState("connecting"),this.startConnecting(),this.setUnavailableTimer()):this.updateState("failed"))}send(t){return!!this.connection&&this.connection.send(t)}send_event(t,e,n){return!!this.connection&&this.connection.send_event(t,e,n)}disconnect(){this.disconnectInternally(),this.updateState("disconnected")}isUsingTLS(){return this.usingTLS}startConnecting(){var t=(e,n)=>{e?this.runner=this.strategy.connect(0,t):"error"===n.action?(this.emit("error",{type:"HandshakeError",error:n.error}),this.timeline.error({handshakeError:n.error})):(this.abortConnecting(),this.handshakeCallbacks[n.action](n))};this.runner=this.strategy.connect(0,t)}abortConnecting(){this.runner&&(this.runner.abort(),this.runner=null)}disconnectInternally(){(this.abortConnecting(),this.clearRetryTimer(),this.clearUnavailableTimer(),this.connection)&&this.abandonConnection().close()}updateStrategy(){this.strategy=this.options.getStrategy({key:this.key,timeline:this.timeline,useTLS:this.usingTLS})}retryIn(t){this.timeline.info({action:"retry",delay:t}),t>0&&this.emit("connecting_in",Math.round(t/1e3)),this.retryTimer=new Y.a(t||0,()=>{this.disconnectInternally(),this.connect()})}clearRetryTimer(){this.retryTimer&&(this.retryTimer.ensureAborted(),this.retryTimer=null)}setUnavailableTimer(){this.unavailableTimer=new Y.a(this.options.unavailableTimeout,()=>{this.updateState("unavailable")})}clearUnavailableTimer(){this.unavailableTimer&&this.unavailableTimer.ensureAborted()}sendActivityCheck(){this.stopActivityCheck(),this.connection.ping(),this.activityTimer=new Y.a(this.options.pongTimeout,()=>{this.timeline.error({pong_timed_out:this.options.pongTimeout}),this.retryIn(0)})}resetActivityCheck(){this.stopActivityCheck(),this.connection&&!this.connection.handlesActivityChecks()&&(this.activityTimer=new Y.a(this.activityTimeout,()=>{this.sendActivityCheck()}))}stopActivityCheck(){this.activityTimer&&this.activityTimer.ensureAborted()}buildConnectionCallbacks(t){return r.f({},t,{message:t=>{this.resetActivityCheck(),this.emit("message",t)},ping:()=>{this.send_event("pusher:pong",{})},activity:()=>{this.resetActivityCheck()},error:t=>{this.emit("error",t)},closed:()=>{this.abandonConnection(),this.shouldRetry()&&this.retryIn(1e3)}})}buildHandshakeCallbacks(t){return r.f({},t,{connected:t=>{this.activityTimeout=Math.min(this.options.activityTimeout,t.activityTimeout,t.connection.activityTimeout||1/0),this.clearUnavailableTimer(),this.setConnection(t.connection),this.socket_id=this.connection.id,this.updateState("connected",{socket_id:this.socket_id})}})}buildErrorCallbacks(){let t=t=>e=>{e.error&&this.emit("error",{type:"WebSocketError",error:e.error}),t(e)};return{tls_only:t(()=>{this.usingTLS=!0,this.updateStrategy(),this.retryIn(0)}),refused:t(()=>{this.disconnect()}),backoff:t(()=>{this.retryIn(1e3)}),retry:t(()=>{this.retryIn(0)})}}setConnection(t){for(var e in this.connection=t,this.connectionCallbacks)this.connection.bind(e,this.connectionCallbacks[e]);this.resetActivityCheck()}abandonConnection(){if(this.connection){for(var t in this.stopActivityCheck(),this.connectionCallbacks)this.connection.unbind(t,this.connectionCallbacks[t]);var e=this.connection;return this.connection=null,e}}updateState(t,e){var n=this.state;if(this.state=t,n!==t){var r=t;"connected"===r&&(r+=" with new socket ID "+e.socket_id),l.a.debug("State changed",n+" -> "+r),this.timeline.info({state:t,params:e}),this.emit("state_change",{previous:n,current:t}),this.emit(t,e)}}shouldRetry(){return"connecting"===this.state||"connected"===this.state}}class ${constructor(){this.channels={}}add(t,e){return this.channels[t]||(this.channels[t]=function(t,e){if(0===t.indexOf("private-encrypted-")){if(e.config.nacl)return J.createEncryptedChannel(t,e,e.config.nacl);let n="Tried to subscribe to a private-encrypted- channel but no nacl implementation available",r=I("encryptedChannelSupport");throw new O(`${n}. ${r}`)}if(0===t.indexOf("private-"))return J.createPrivateChannel(t,e);if(0===t.indexOf("presence-"))return J.createPresenceChannel(t,e);if(0===t.indexOf("#"))throw new A('Cannot create a channel with name "'+t+'".');return J.createChannel(t,e)}(t,e)),this.channels[t]}all(){return r.n(this.channels)}find(t){return this.channels[t]}remove(t){var e=this.channels[t];return delete this.channels[t],e}disconnect(){r.k(this.channels,(function(t){t.disconnect()}))}}var J={createChannels:()=>new $,createConnectionManager:(t,e)=>new K(t,e),createChannel:(t,e)=>new N(t,e),createPrivateChannel:(t,e)=>new j(t,e),createPresenceChannel:(t,e)=>new H(t,e),createEncryptedChannel:(t,e,n)=>new q(t,e,n),createTimelineSender:(t,e)=>new T(t,e),createHandshake:(t,e)=>new C(t,e),createAssistantToTheTransportManager:(t,e,n)=>new w(t,e,n)};class X{constructor(t){this.options=t||{},this.livesLeft=this.options.lives||1/0}getAssistant(t){return J.createAssistantToTheTransportManager(this,t,{minPingDelay:this.options.minPingDelay,maxPingDelay:this.options.maxPingDelay})}isAlive(){return this.livesLeft>0}reportDeath(){this.livesLeft-=1}}class W{constructor(t,e){this.strategies=t,this.loop=Boolean(e.loop),this.failFast=Boolean(e.failFast),this.timeout=e.timeout,this.timeoutLimit=e.timeoutLimit}isSupported(){return r.b(this.strategies,c.a.method("isSupported"))}connect(t,e){var n=this.strategies,r=0,i=this.timeout,s=null,o=(a,h)=>{h?e(null,h):(r+=1,this.loop&&(r%=n.length),r0&&(i=new Y.a(n.timeout,(function(){s.abort(),r(!0)}))),s=t.connect(e,(function(t,e){t&&i&&i.isRunning()&&!n.failFast||(i&&i.ensureAborted(),r(t,e))})),{abort:function(){i&&i.ensureAborted(),s.abort()},forceMinPriority:function(t){s.forceMinPriority(t)}}}}class G{constructor(t){this.strategies=t}isSupported(){return r.b(this.strategies,c.a.method("isSupported"))}connect(t,e){return function(t,e,n){var i=r.j(t,(function(t,r,i,s){return t.connect(e,n(r,s))}));return{abort:function(){r.c(i,V)},forceMinPriority:function(t){r.c(i,(function(e){e.forceMinPriority(t)}))}}}(this.strategies,t,(function(t,n){return function(i,s){n[t].error=i,i?function(t){return r.a(t,(function(t){return Boolean(t.error)}))}(n)&&e(!0):(r.c(n,(function(t){t.forceMinPriority(s.transport.priority)})),e(null,s))}}))}}function V(t){t.error||t.aborted||(t.abort(),t.aborted=!0)}class Z{constructor(t,e,n){this.strategy=t,this.transports=e,this.ttl=n.ttl||18e5,this.usingTLS=n.useTLS,this.timeline=n.timeline}isSupported(){return this.strategy.isSupported()}connect(t,e){var n=this.usingTLS,i=function(t){var e=zt.getLocalStorage();if(e)try{var n=e[Q(t)];if(n)return JSON.parse(n)}catch(e){tt(t)}return null}(n),s=i&&i.cacheSkipCount?i.cacheSkipCount:0,o=[this.strategy];if(i&&i.timestamp+this.ttl>=c.a.now()){var a=this.transports[i.transport];a&&(["ws","wss"].includes(i.transport)||s>3?(this.timeline.info({cached:!0,transport:i.transport,latency:i.latency}),o.push(new W([a],{timeout:2*i.latency+1e3,failFast:!0}))):s++)}var h=c.a.now(),u=o.pop().connect(t,(function i(a,l){a?(tt(n),o.length>0?(h=c.a.now(),u=o.pop().connect(t,i)):e(a)):(!function(t,e,n,i){var s=zt.getLocalStorage();if(s)try{s[Q(t)]=r.l({timestamp:c.a.now(),transport:e,latency:n,cacheSkipCount:i})}catch(t){}}(n,l.transport.name,c.a.now()-h,s),e(null,l))}));return{abort:function(){u.abort()},forceMinPriority:function(e){t=e,u&&u.forceMinPriority(e)}}}}function Q(t){return"pusherTransport"+(t?"TLS":"NonTLS")}function tt(t){var e=zt.getLocalStorage();if(e)try{delete e[Q(t)]}catch(t){}}class et{constructor(t,{delay:e}){this.strategy=t,this.options={delay:e}}isSupported(){return this.strategy.isSupported()}connect(t,e){var n,r=this.strategy,i=new Y.a(this.options.delay,(function(){n=r.connect(t,e)}));return{abort:function(){i.ensureAborted(),n&&n.abort()},forceMinPriority:function(e){t=e,n&&n.forceMinPriority(e)}}}}class nt{constructor(t,e,n){this.test=t,this.trueBranch=e,this.falseBranch=n}isSupported(){return(this.test()?this.trueBranch:this.falseBranch).isSupported()}connect(t,e){return(this.test()?this.trueBranch:this.falseBranch).connect(t,e)}}class rt{constructor(t){this.strategy=t}isSupported(){return this.strategy.isSupported()}connect(t,e){var n=this.strategy.connect(t,(function(t,r){r&&n.abort(),e(t,r)}));return n}}function it(t){return function(){return t.isSupported()}}var st=function(t,e,n){var i={};function s(e,r,s,o,a){var h=n(t,e,r,s,o,a);return i[e]=h,h}var o,a=Object.assign({},e,{hostNonTLS:t.wsHost+":"+t.wsPort,hostTLS:t.wsHost+":"+t.wssPort,httpPath:t.wsPath}),h=r.f({},a,{useTLS:!0}),c=Object.assign({},e,{hostNonTLS:t.httpHost+":"+t.httpPort,hostTLS:t.httpHost+":"+t.httpsPort,httpPath:t.httpPath}),u={loop:!0,timeout:15e3,timeoutLimit:6e4},l=new X({minPingDelay:1e4,maxPingDelay:t.activityTimeout}),d=new X({lives:2,minPingDelay:1e4,maxPingDelay:t.activityTimeout}),f=s("ws","ws",3,a,l),p=s("wss","ws",3,h,l),g=s("xhr_streaming","xhr_streaming",1,c,d),b=s("xhr_polling","xhr_polling",1,c),v=new W([f],u),y=new W([p],u),m=new W([g],u),w=new W([b],u),_=new W([new nt(it(m),new G([m,new et(w,{delay:4e3})]),w)],u);return o=e.useTLS?new G([v,new et(_,{delay:2e3})]):new G([v,new et(y,{delay:2e3}),new et(_,{delay:5e3})]),new Z(new rt(new nt(it(f),o,_)),i,{ttl:18e5,timeline:e.timeline,useTLS:e.useTLS})};class ot extends u.a{constructor(t,e,n){super(),this.hooks=t,this.method=e,this.url=n}start(t){this.position=0,this.xhr=this.hooks.getRequest(this),this.unloader=()=>{this.close()},zt.addUnloadListener(this.unloader),this.xhr.open(this.method,this.url,!0),this.xhr.setRequestHeader&&this.xhr.setRequestHeader("Content-Type","application/json"),this.xhr.send(t)}close(){this.unloader&&(zt.removeUnloadListener(this.unloader),this.unloader=null),this.xhr&&(this.hooks.abortRequest(this.xhr),this.xhr=null)}onChunk(t,e){for(;;){var n=this.advanceBuffer(e);if(!n)break;this.emit("chunk",{status:t,data:n})}this.isBufferTooLong(e)&&this.emit("buffer_too_long")}advanceBuffer(t){var e=t.slice(this.position),n=e.indexOf("\n");return-1!==n?(this.position+=n+1,e.slice(0,n)):null}isBufferTooLong(t){return this.position===t.length&&t.length>262144}}var at;!function(t){t[t.CONNECTING=0]="CONNECTING",t[t.OPEN=1]="OPEN",t[t.CLOSED=3]="CLOSED"}(at||(at={}));var ht=at,ct=1;function ut(t){var e=-1===t.indexOf("?")?"?":"&";return t+e+"t="+ +new Date+"&n="+ct++}function lt(t){return zt.randomInt(t)}var dt=class{constructor(t,e){this.hooks=t,this.session=lt(1e3)+"/"+function(t){for(var e=[],n=0;n{this.onChunk(t)}),this.stream.bind("finished",t=>{this.hooks.onFinished(this,t)}),this.stream.bind("buffer_too_long",()=>{this.reconnect()});try{this.stream.start()}catch(t){c.a.defer(()=>{this.onError(t),this.onClose(1006,"Could not start streaming",!1)})}}closeStream(){this.stream&&(this.stream.unbind_all(),this.stream.close(),this.stream=null)}},ft={getReceiveURL:function(t,e){return t.base+"/"+e+"/xhr_streaming"+t.queryString},onHeartbeat:function(t){t.sendRaw("[]")},sendHeartbeat:function(t){t.sendRaw("[]")},onFinished:function(t,e){t.onClose(1006,"Connection interrupted ("+e+")",!1)}},pt={getReceiveURL:function(t,e){return t.base+"/"+e+"/xhr"+t.queryString},onHeartbeat:function(){},sendHeartbeat:function(t){t.sendRaw("[]")},onFinished:function(t,e){200===e?t.reconnect():t.onClose(1006,"Connection interrupted ("+e+")",!1)}},gt={getRequest:function(t){var e=new(zt.getXHRAPI());return e.onreadystatechange=e.onprogress=function(){switch(e.readyState){case 3:e.responseText&&e.responseText.length>0&&t.onChunk(e.status,e.responseText);break;case 4:e.responseText&&e.responseText.length>0&&t.onChunk(e.status,e.responseText),t.emit("finished",e.status),t.close()}},e},abortRequest:function(t){t.onreadystatechange=null,t.abort()}},bt={getDefaultStrategy:st,Transports:m,transportConnectionInitializer:function(){this.timeline.info(this.buildTimelineMessage({transport:this.name+(this.options.useTLS?"s":"")})),this.hooks.isInitialized()?this.changeState("initialized"):this.onClose()},HTTPFactory:{createStreamingSocket(t){return this.createSocket(ft,t)},createPollingSocket(t){return this.createSocket(pt,t)},createSocket:(t,e)=>new dt(t,e),createXHR(t,e){return this.createRequest(gt,t,e)},createRequest:(t,e,n)=>new ot(t,e,n)},setup(t){t.ready()},getLocalStorage(){},getClientFeatures:()=>r.i(r.h({ws:m.ws},(function(t){return t.isSupported({})}))),getProtocol:()=>"http:",isXHRSupported:()=>!0,createSocketRequest(t,e){if(this.isXHRSupported())return this.HTTPFactory.createXHR(t,e);throw"Cross-origin HTTP requests are not supported"},createXHR(){return new(this.getXHRAPI())},createWebSocket(t){return new(this.getWebSocketAPI())(t)},addUnloadListener(t){},removeUnloadListener(t){}},vt=n(10),yt=n.n(vt);function mt(t){return"none"!==t.type.toLowerCase()}class wt extends u.a{constructor(){super(),this.online=!0,yt.a.fetch().then(t=>{this.online=mt(t)}),yt.a.addEventListener(t=>{var e=mt(t);this.online!==e&&(this.online=e,this.online?this.emit("online"):this.emit("offline"))})}isOnline(){return this.online}}var _t,St=new wt;!function(t){t.UserAuthentication="user-authentication",t.ChannelAuthorization="channel-authorization"}(_t||(_t={}));var kt=function(t,e,n,r,i){const s=zt.createXHR();for(var o in s.open("POST",n.endpoint,!0),s.setRequestHeader("Content-Type","application/x-www-form-urlencoded"),n.headers)s.setRequestHeader(o,n.headers[o]);if(null!=n.headersProvider){let t=n.headersProvider();for(var o in t)s.setRequestHeader(o,t[o])}return s.onreadystatechange=function(){if(4===s.readyState)if(200===s.status){let t,e=!1;try{t=JSON.parse(s.responseText),e=!0}catch(t){i(new R(200,`JSON returned from ${r.toString()} endpoint was invalid, yet status code was 200. Data was: ${s.responseText}`),null)}e&&i(null,t)}else{let t="";switch(r){case _t.UserAuthentication:t=I("authenticationEndpoint");break;case _t.ChannelAuthorization:t="Clients must be authorized to join private or presence channels. "+I("authorizationEndpoint")}i(new R(s.status,`Unable to retrieve auth string from ${r.toString()} endpoint - received status: ${s.status} from ${n.endpoint}. ${t}`),null)}},s.send(e),s},Ct={name:"xhr",getAgent:function(t,e){return function(n,i){var s="http"+(e?"s":"")+"://"+(t.host||t.options.host)+t.options.path;s+="/2?"+r.e(n);var o=zt.createXHR();o.open("GET",s,!0),o.onreadystatechange=function(){if(4===o.readyState){let{status:n,responseText:r}=o;if(200!==n)return void l.a.debug(`TimelineSender Error: received ${n} from stats.pusher.com`);try{var{host:e}=JSON.parse(r)}catch(t){l.a.debug("TimelineSenderError: invalid response "+r)}e&&(t.host=e)}},o.send()}}};const{getDefaultStrategy:Tt,Transports:Et,setup:At,getProtocol:Pt,isXHRSupported:xt,getLocalStorage:Ot,createXHR:Lt,createWebSocket:Ut,addUnloadListener:Rt,removeUnloadListener:Mt,transportConnectionInitializer:It,createSocketRequest:Nt,HTTPFactory:jt}=bt;var Dt,zt={getDefaultStrategy:Tt,Transports:Et,setup:At,getProtocol:Pt,isXHRSupported:xt,getLocalStorage:Ot,createXHR:Lt,createWebSocket:Ut,addUnloadListener:Rt,removeUnloadListener:Mt,transportConnectionInitializer:It,createSocketRequest:Nt,HTTPFactory:jt,TimelineTransport:Ct,getAuthorizers:()=>({ajax:kt}),getWebSocketAPI:()=>WebSocket,getXHRAPI:()=>XMLHttpRequest,getNetwork:()=>St,randomInt:t=>Math.floor(Math.random()*t)};!function(t){t[t.ERROR=3]="ERROR",t[t.INFO=6]="INFO",t[t.DEBUG=7]="DEBUG"}(Dt||(Dt={}));var Ht=Dt;class Bt{constructor(t,e,n){this.key=t,this.session=e,this.events=[],this.options=n||{},this.sent=0,this.uniqueID=0}log(t,e){t<=this.options.level&&(this.events.push(r.f({},e,{timestamp:c.a.now()})),this.options.limit&&this.events.length>this.options.limit&&this.events.shift())}error(t){this.log(Ht.ERROR,t)}info(t){this.log(Ht.INFO,t)}debug(t){this.log(Ht.DEBUG,t)}isEmpty(){return 0===this.events.length}send(t,e){var n=r.f({session:this.session,bundle:this.sent+1,key:this.key,lib:"js",version:this.options.version,cluster:this.options.cluster,features:this.options.features,timeline:this.events},this.options.params);return this.events=[],t(n,(t,n)=>{t||this.sent++,e&&e(t,n)}),!0}generateUniqueID(){return this.uniqueID++,this.uniqueID}}class Ft{constructor(t,e,n,r){this.name=t,this.priority=e,this.transport=n,this.options=r||{}}isSupported(){return this.transport.isSupported({useTLS:this.options.useTLS})}connect(t,e){if(!this.isSupported())return qt(new U,e);if(this.priority{n||(u(),s?s.close():i.close())},forceMinPriority:t=>{n||this.priority{if(void 0===zt.getAuthorizers()[t.transport])throw`'${t.transport}' is not a recognized auth transport`;return(e,n)=>{const r=((t,e)=>{var n="socket_id="+encodeURIComponent(t.socketId);for(var r in e.params)n+="&"+encodeURIComponent(r)+"="+encodeURIComponent(e.params[r]);if(null!=e.paramsProvider){let t=e.paramsProvider();for(var r in t)n+="&"+encodeURIComponent(r)+"="+encodeURIComponent(t[r])}return n})(e,t);zt.getAuthorizers()[t.transport](zt,r,t,_t.UserAuthentication,n)}};var Wt=t=>{if(void 0===zt.getAuthorizers()[t.transport])throw`'${t.transport}' is not a recognized auth transport`;return(e,n)=>{const r=((t,e)=>{var n="socket_id="+encodeURIComponent(t.socketId);for(var r in n+="&channel_name="+encodeURIComponent(t.channelName),e.params)n+="&"+encodeURIComponent(r)+"="+encodeURIComponent(e.params[r]);if(null!=e.paramsProvider){let t=e.paramsProvider();for(var r in t)n+="&"+encodeURIComponent(r)+"="+encodeURIComponent(t[r])}return n})(e,t);zt.getAuthorizers()[t.transport](zt,r,t,_t.ChannelAuthorization,n)}};function Gt(t,e){let n={activityTimeout:t.activityTimeout||i.activityTimeout,cluster:t.cluster,httpPath:t.httpPath||i.httpPath,httpPort:t.httpPort||i.httpPort,httpsPort:t.httpsPort||i.httpsPort,pongTimeout:t.pongTimeout||i.pongTimeout,statsHost:t.statsHost||i.stats_host,unavailableTimeout:t.unavailableTimeout||i.unavailableTimeout,wsPath:t.wsPath||i.wsPath,wsPort:t.wsPort||i.wsPort,wssPort:t.wssPort||i.wssPort,enableStats:te(t),httpHost:Vt(t),useTLS:Qt(t),wsHost:Zt(t),userAuthenticator:ee(t),channelAuthorizer:ne(t,e)};return"disabledTransports"in t&&(n.disabledTransports=t.disabledTransports),"enabledTransports"in t&&(n.enabledTransports=t.enabledTransports),"ignoreNullOrigin"in t&&(n.ignoreNullOrigin=t.ignoreNullOrigin),"timelineParams"in t&&(n.timelineParams=t.timelineParams),"nacl"in t&&(n.nacl=t.nacl),n}function Vt(t){return t.httpHost?t.httpHost:t.cluster?`sockjs-${t.cluster}.pusher.com`:i.httpHost}function Zt(t){return t.wsHost?t.wsHost:`ws-${t.cluster}.pusher.com`}function Qt(t){return"https:"===zt.getProtocol()||!1!==t.forceTLS}function te(t){return"enableStats"in t?t.enableStats:"disableStats"in t&&!t.disableStats}function ee(t){const e=Object.assign(Object.assign({},i.userAuthentication),t.userAuthentication);return"customHandler"in e&&null!=e.customHandler?e.customHandler:Xt(e)}function ne(t,e){const n=function(t,e){let n;return"channelAuthorization"in t?n=Object.assign(Object.assign({},i.channelAuthorization),t.channelAuthorization):(n={transport:t.authTransport||i.authTransport,endpoint:t.authEndpoint||i.authEndpoint},"auth"in t&&("params"in t.auth&&(n.params=t.auth.params),"headers"in t.auth&&(n.headers=t.auth.headers)),"authorizer"in t&&(n.customHandler=((t,e,n)=>{const r={authTransport:e.transport,authEndpoint:e.endpoint,auth:{params:e.params,headers:e.headers}};return(e,i)=>{const s=t.channel(e.channelName);n(s,r).authorize(e.socketId,i)}})(e,n,t.authorizer))),n}(t,e);return"customHandler"in n&&null!=n.customHandler?n.customHandler:Wt(n)}class re extends u.a{constructor(t){super((function(t,e){l.a.debug("No callbacks on watchlist events for "+t)})),this.pusher=t,this.bindWatchlistInternalEvent()}handleEvent(t){t.data.events.forEach(t=>{this.emit(t.name,t)})}bindWatchlistInternalEvent(){this.pusher.connection.bind("message",t=>{"pusher_internal:watchlist_events"===t.event&&this.handleEvent(t)})}}var ie=function(){let t,e;return{promise:new Promise((n,r)=>{t=n,e=r}),resolve:t,reject:e}};class se extends u.a{constructor(t){super((function(t,e){l.a.debug("No callbacks on user for "+t)})),this.signin_requested=!1,this.user_data=null,this.serverToUserChannel=null,this.signinDonePromise=null,this._signinDoneResolve=null,this._onAuthorize=(t,e)=>{if(t)return l.a.warn("Error during signin: "+t),void this._cleanup();this.pusher.send_event("pusher:signin",{auth:e.auth,user_data:e.user_data})},this.pusher=t,this.pusher.connection.bind("state_change",({previous:t,current:e})=>{"connected"!==t&&"connected"===e&&this._signin(),"connected"===t&&"connected"!==e&&(this._cleanup(),this._newSigninPromiseIfNeeded())}),this.watchlist=new re(t),this.pusher.connection.bind("message",t=>{"pusher:signin_success"===t.event&&this._onSigninSuccess(t.data),this.serverToUserChannel&&this.serverToUserChannel.name===t.channel&&this.serverToUserChannel.handleEvent(t)})}signin(){this.signin_requested||(this.signin_requested=!0,this._signin())}_signin(){this.signin_requested&&(this._newSigninPromiseIfNeeded(),"connected"===this.pusher.connection.state&&this.pusher.config.userAuthenticator({socketId:this.pusher.connection.socket_id},this._onAuthorize))}_onSigninSuccess(t){try{this.user_data=JSON.parse(t.user_data)}catch(e){return l.a.error("Failed parsing user data after signin: "+t.user_data),void this._cleanup()}if("string"!=typeof this.user_data.id||""===this.user_data.id)return l.a.error("user_data doesn't contain an id. user_data: "+this.user_data),void this._cleanup();this._signinDoneResolve(),this._subscribeChannels()}_subscribeChannels(){this.serverToUserChannel=new N("#server-to-user-"+this.user_data.id,this.pusher),this.serverToUserChannel.bind_global((t,e)=>{0!==t.indexOf("pusher_internal:")&&0!==t.indexOf("pusher:")&&this.emit(t,e)}),(t=>{t.subscriptionPending&&t.subscriptionCancelled?t.reinstateSubscription():t.subscriptionPending||"connected"!==this.pusher.connection.state||t.subscribe()})(this.serverToUserChannel)}_cleanup(){this.user_data=null,this.serverToUserChannel&&(this.serverToUserChannel.unbind_all(),this.serverToUserChannel.disconnect(),this.serverToUserChannel=null),this.signin_requested&&this._signinDoneResolve()}_newSigninPromiseIfNeeded(){if(!this.signin_requested)return;if(this.signinDonePromise&&!this.signinDonePromise.done)return;const{promise:t,resolve:e,reject:n}=ie();t.done=!1;const r=()=>{t.done=!0};t.then(r).catch(r),this.signinDonePromise=t,this._signinDoneResolve=e}}class oe{static ready(){oe.isReady=!0;for(var t=0,e=oe.instances.length;tzt.getDefaultStrategy(this.config,t,Kt),timeline:this.timeline,activityTimeout:this.config.activityTimeout,pongTimeout:this.config.pongTimeout,unavailableTimeout:this.config.unavailableTimeout,useTLS:Boolean(this.config.useTLS)}),this.connection.bind("connected",()=>{this.subscribeAll(),this.timelineSender&&this.timelineSender.send(this.connection.isUsingTLS())}),this.connection.bind("message",t=>{var e=0===t.event.indexOf("pusher_internal:");if(t.channel){var n=this.channel(t.channel);n&&n.handleEvent(t)}e||this.global_emitter.emit(t.event,t.data)}),this.connection.bind("connecting",()=>{this.channels.disconnect()}),this.connection.bind("disconnected",()=>{this.channels.disconnect()}),this.connection.bind("error",t=>{l.a.warn(t)}),oe.instances.push(this),this.timeline.info({instances:oe.instances.length}),this.user=new se(this),oe.isReady&&this.connect()}switchCluster(t){const{appKey:e,cluster:n}=t;this.key=e,this.options=Object.assign(Object.assign({},this.options),{cluster:n}),this.config=Gt(this.options,this),this.connection.switchCluster(this.key)}channel(t){return this.channels.find(t)}allChannels(){return this.channels.all()}connect(){if(this.connection.connect(),this.timelineSender&&!this.timelineSenderTimer){var t=this.connection.isUsingTLS(),e=this.timelineSender;this.timelineSenderTimer=new Y.b(6e4,(function(){e.send(t)}))}}disconnect(){this.connection.disconnect(),this.timelineSenderTimer&&(this.timelineSenderTimer.ensureAborted(),this.timelineSenderTimer=null)}bind(t,e,n){return this.global_emitter.bind(t,e,n),this}unbind(t,e,n){return this.global_emitter.unbind(t,e,n),this}bind_global(t){return this.global_emitter.bind_global(t),this}unbind_global(t){return this.global_emitter.unbind_global(t),this}unbind_all(t){return this.global_emitter.unbind_all(),this}subscribeAll(){var t;for(t in this.channels.channels)this.channels.channels.hasOwnProperty(t)&&this.subscribe(t)}subscribe(t){var e=this.channels.add(t,this);return e.subscriptionPending&&e.subscriptionCancelled?e.reinstateSubscription():e.subscriptionPending||"connected"!==this.connection.state||e.subscribe(),e}unsubscribe(t){var e=this.channels.find(t);e&&e.subscriptionPending?e.cancelSubscription():(e=this.channels.remove(t))&&e.subscribed&&e.unsubscribe()}send_event(t,e,n){return this.connection.send_event(t,e,n)}shouldUseTLS(){return this.config.useTLS}signin(){this.user.signin()}}oe.instances=[],oe.isReady=!1,oe.logToConsole=!1,oe.Runtime=zt,oe.ScriptReceivers=zt.ScriptReceivers,oe.DependenciesReceivers=zt.DependenciesReceivers,oe.auth_callbacks=zt.auth_callbacks;e.a=oe;zt.setup(oe)},function(t,e){var n;n=function(){return this}();try{n=n||new Function("return this")()}catch(t){"object"==typeof window&&(n=window)}t.exports=n},function(t,e,n){"use strict";n.d(e,"a",(function(){return i}));var r=n(1);function i(t){if(null==t)throw"You must pass an options object";if(null==t.cluster)throw"Options object must provide a cluster";"disableStats"in t&&r.a.warn("The disableStats option is deprecated in favor of enableStats")}},function(t,e,n){"use strict";var r,i=this&&this.__extends||(r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)},function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)});Object.defineProperty(e,"__esModule",{value:!0});var s=function(){function t(t){void 0===t&&(t="="),this._paddingCharacter=t}return t.prototype.encodedLength=function(t){return this._paddingCharacter?(t+2)/3*4|0:(8*t+5)/6|0},t.prototype.encode=function(t){for(var e="",n=0;n>>18&63),e+=this._encodeByte(r>>>12&63),e+=this._encodeByte(r>>>6&63),e+=this._encodeByte(r>>>0&63)}var i=t.length-n;if(i>0){r=t[n]<<16|(2===i?t[n+1]<<8:0);e+=this._encodeByte(r>>>18&63),e+=this._encodeByte(r>>>12&63),e+=2===i?this._encodeByte(r>>>6&63):this._paddingCharacter||"",e+=this._paddingCharacter||""}return e},t.prototype.maxDecodedLength=function(t){return this._paddingCharacter?t/4*3|0:(6*t+7)/8|0},t.prototype.decodedLength=function(t){return this.maxDecodedLength(t.length-this._getPaddingLength(t))},t.prototype.decode=function(t){if(0===t.length)return new Uint8Array(0);for(var e=this._getPaddingLength(t),n=t.length-e,r=new Uint8Array(this.maxDecodedLength(n)),i=0,s=0,o=0,a=0,h=0,c=0,u=0;s>>4,r[i++]=h<<4|c>>>2,r[i++]=c<<6|u,o|=256&a,o|=256&h,o|=256&c,o|=256&u;if(s>>4,o|=256&a,o|=256&h),s>>2,o|=256&c),s>>8&6,e+=51-t>>>8&-75,e+=61-t>>>8&-15,e+=62-t>>>8&3,String.fromCharCode(e)},t.prototype._decodeChar=function(t){var e=256;return e+=(42-t&t-44)>>>8&-256+t-43+62,e+=(46-t&t-48)>>>8&-256+t-47+63,e+=(47-t&t-58)>>>8&-256+t-48+52,e+=(64-t&t-91)>>>8&-256+t-65+0,e+=(96-t&t-123)>>>8&-256+t-97+26},t.prototype._getPaddingLength=function(t){var e=0;if(this._paddingCharacter){for(var n=t.length-1;n>=0&&t[n]===this._paddingCharacter;n--)e++;if(t.length<4||e>2)throw new Error("Base64Coder: incorrect padding")}return e},t}();e.Coder=s;var o=new s;e.encode=function(t){return o.encode(t)},e.decode=function(t){return o.decode(t)};var a=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return i(e,t),e.prototype._encodeByte=function(t){var e=t;return e+=65,e+=25-t>>>8&6,e+=51-t>>>8&-75,e+=61-t>>>8&-13,e+=62-t>>>8&49,String.fromCharCode(e)},e.prototype._decodeChar=function(t){var e=256;return e+=(44-t&t-46)>>>8&-256+t-45+62,e+=(94-t&t-96)>>>8&-256+t-95+63,e+=(47-t&t-58)>>>8&-256+t-48+52,e+=(64-t&t-91)>>>8&-256+t-65+0,e+=(96-t&t-123)>>>8&-256+t-97+26},e}(s);e.URLSafeCoder=a;var h=new a;e.encodeURLSafe=function(t){return h.encode(t)},e.decodeURLSafe=function(t){return h.decode(t)},e.encodedLength=function(t){return o.encodedLength(t)},e.maxDecodedLength=function(t){return o.maxDecodedLength(t)},e.decodedLength=function(t){return o.decodedLength(t)}},function(t,e,n){"use strict";e.a=class{constructor(t,e,n,r){this.clear=e,this.timer=t(()=>{this.timer&&(this.timer=r(this.timer))},n)}isRunning(){return null!==this.timer}ensureAborted(){this.timer&&(this.clear(this.timer),this.timer=null)}}},function(t,e){t.exports=require("@react-native-community/netinfo")},function(t,e,n){"use strict";(function(t){function r(t){return d(u(t))}n.d(e,"a",(function(){return r}));for(var i=String.fromCharCode,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",o={},a=0,h=s.length;a>>6)+i(128|63&e):i(224|e>>>12&15)+i(128|e>>>6&63)+i(128|63&e)},u=function(t){return t.replace(/[^\x00-\x7F]/g,c)},l=function(t){var e=[0,2,1][t.length%3],n=t.charCodeAt(0)<<16|(t.length>1?t.charCodeAt(1):0)<<8|(t.length>2?t.charCodeAt(2):0);return[s.charAt(n>>>18),s.charAt(n>>>12&63),e>=2?"=":s.charAt(n>>>6&63),e>=1?"=":s.charAt(63&n)].join("")},d=t.btoa||function(t){return t.replace(/[\s\S]{1,3}/g,l)}}).call(this,n(6))},function(t,e,n){"use strict";n.d(e,"a",(function(){return i}));var r=n(0);class i{constructor(){this._callbacks={}}get(t){return this._callbacks[s(t)]}add(t,e,n){var r=s(t);this._callbacks[r]=this._callbacks[r]||[],this._callbacks[r].push({fn:e,context:n})}remove(t,e,n){if(t||e||n){var i=t?[s(t)]:r.i(this._callbacks);e||n?this.removeCallback(i,e,n):this.removeAllCallbacks(i)}else this._callbacks={}}removeCallback(t,e,n){r.c(t,(function(t){this._callbacks[t]=r.g(this._callbacks[t]||[],(function(t){return e&&e!==t.fn||n&&n!==t.context})),0===this._callbacks[t].length&&delete this._callbacks[t]}),this)}removeAllCallbacks(t){r.c(t,(function(t){delete this._callbacks[t]}),this)}}function s(t){return"_"+t}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r="utf8: invalid source encoding";function i(t){for(var e=0,n=0;n=t.length-1)throw new Error("utf8: invalid string");n++,e+=4}}return e}e.encode=function(t){for(var e=new Uint8Array(i(t)),n=0,r=0;r>6,e[n++]=128|63&s):s<55296?(e[n++]=224|s>>12,e[n++]=128|s>>6&63,e[n++]=128|63&s):(r++,s=(1023&s)<<10,s|=1023&t.charCodeAt(r),s+=65536,e[n++]=240|s>>18,e[n++]=128|s>>12&63,e[n++]=128|s>>6&63,e[n++]=128|63&s)}return e},e.encodedLength=i,e.decode=function(t){for(var e=[],n=0;n=t.length)throw new Error(r);if(128!=(192&(o=t[++n])))throw new Error(r);i=(31&i)<<6|63&o,s=128}else if(i<240){if(n>=t.length-1)throw new Error(r);var o=t[++n],a=t[++n];if(128!=(192&o)||128!=(192&a))throw new Error(r);i=(15&i)<<12|(63&o)<<6|63&a,s=2048}else{if(!(i<248))throw new Error(r);if(n>=t.length-2)throw new Error(r);o=t[++n],a=t[++n];var h=t[++n];if(128!=(192&o)||128!=(192&a)||128!=(192&h))throw new Error(r);i=(15&i)<<18|(63&o)<<12|(63&a)<<6|63&h,s=65536}if(i=55296&&i<=57343)throw new Error(r);if(i>=65536){if(i>1114111)throw new Error(r);i-=65536,e.push(String.fromCharCode(55296|i>>10)),i=56320|1023&i}}e.push(String.fromCharCode(i))}return e.join("")}},function(t,e,n){!function(t){"use strict";var e=function(t){var e,n=new Float64Array(16);if(t)for(e=0;e>24&255,t[e+1]=n>>16&255,t[e+2]=n>>8&255,t[e+3]=255&n,t[e+4]=r>>24&255,t[e+5]=r>>16&255,t[e+6]=r>>8&255,t[e+7]=255&r}function g(t,e,n,r,i){var s,o=0;for(s=0;s>>8)-1}function b(t,e,n,r){return g(t,e,n,r,16)}function v(t,e,n,r){return g(t,e,n,r,32)}function y(t,e,n,r){!function(t,e,n,r){for(var i,s=255&r[0]|(255&r[1])<<8|(255&r[2])<<16|(255&r[3])<<24,o=255&n[0]|(255&n[1])<<8|(255&n[2])<<16|(255&n[3])<<24,a=255&n[4]|(255&n[5])<<8|(255&n[6])<<16|(255&n[7])<<24,h=255&n[8]|(255&n[9])<<8|(255&n[10])<<16|(255&n[11])<<24,c=255&n[12]|(255&n[13])<<8|(255&n[14])<<16|(255&n[15])<<24,u=255&r[4]|(255&r[5])<<8|(255&r[6])<<16|(255&r[7])<<24,l=255&e[0]|(255&e[1])<<8|(255&e[2])<<16|(255&e[3])<<24,d=255&e[4]|(255&e[5])<<8|(255&e[6])<<16|(255&e[7])<<24,f=255&e[8]|(255&e[9])<<8|(255&e[10])<<16|(255&e[11])<<24,p=255&e[12]|(255&e[13])<<8|(255&e[14])<<16|(255&e[15])<<24,g=255&r[8]|(255&r[9])<<8|(255&r[10])<<16|(255&r[11])<<24,b=255&n[16]|(255&n[17])<<8|(255&n[18])<<16|(255&n[19])<<24,v=255&n[20]|(255&n[21])<<8|(255&n[22])<<16|(255&n[23])<<24,y=255&n[24]|(255&n[25])<<8|(255&n[26])<<16|(255&n[27])<<24,m=255&n[28]|(255&n[29])<<8|(255&n[30])<<16|(255&n[31])<<24,w=255&r[12]|(255&r[13])<<8|(255&r[14])<<16|(255&r[15])<<24,_=s,S=o,k=a,C=h,T=c,E=u,A=l,P=d,x=f,O=p,L=g,U=b,R=v,M=y,I=m,N=w,j=0;j<20;j+=2)_^=(i=(R^=(i=(x^=(i=(T^=(i=_+R|0)<<7|i>>>25)+_|0)<<9|i>>>23)+T|0)<<13|i>>>19)+x|0)<<18|i>>>14,E^=(i=(S^=(i=(M^=(i=(O^=(i=E+S|0)<<7|i>>>25)+E|0)<<9|i>>>23)+O|0)<<13|i>>>19)+M|0)<<18|i>>>14,L^=(i=(A^=(i=(k^=(i=(I^=(i=L+A|0)<<7|i>>>25)+L|0)<<9|i>>>23)+I|0)<<13|i>>>19)+k|0)<<18|i>>>14,N^=(i=(U^=(i=(P^=(i=(C^=(i=N+U|0)<<7|i>>>25)+N|0)<<9|i>>>23)+C|0)<<13|i>>>19)+P|0)<<18|i>>>14,_^=(i=(C^=(i=(k^=(i=(S^=(i=_+C|0)<<7|i>>>25)+_|0)<<9|i>>>23)+S|0)<<13|i>>>19)+k|0)<<18|i>>>14,E^=(i=(T^=(i=(P^=(i=(A^=(i=E+T|0)<<7|i>>>25)+E|0)<<9|i>>>23)+A|0)<<13|i>>>19)+P|0)<<18|i>>>14,L^=(i=(O^=(i=(x^=(i=(U^=(i=L+O|0)<<7|i>>>25)+L|0)<<9|i>>>23)+U|0)<<13|i>>>19)+x|0)<<18|i>>>14,N^=(i=(I^=(i=(M^=(i=(R^=(i=N+I|0)<<7|i>>>25)+N|0)<<9|i>>>23)+R|0)<<13|i>>>19)+M|0)<<18|i>>>14;_=_+s|0,S=S+o|0,k=k+a|0,C=C+h|0,T=T+c|0,E=E+u|0,A=A+l|0,P=P+d|0,x=x+f|0,O=O+p|0,L=L+g|0,U=U+b|0,R=R+v|0,M=M+y|0,I=I+m|0,N=N+w|0,t[0]=_>>>0&255,t[1]=_>>>8&255,t[2]=_>>>16&255,t[3]=_>>>24&255,t[4]=S>>>0&255,t[5]=S>>>8&255,t[6]=S>>>16&255,t[7]=S>>>24&255,t[8]=k>>>0&255,t[9]=k>>>8&255,t[10]=k>>>16&255,t[11]=k>>>24&255,t[12]=C>>>0&255,t[13]=C>>>8&255,t[14]=C>>>16&255,t[15]=C>>>24&255,t[16]=T>>>0&255,t[17]=T>>>8&255,t[18]=T>>>16&255,t[19]=T>>>24&255,t[20]=E>>>0&255,t[21]=E>>>8&255,t[22]=E>>>16&255,t[23]=E>>>24&255,t[24]=A>>>0&255,t[25]=A>>>8&255,t[26]=A>>>16&255,t[27]=A>>>24&255,t[28]=P>>>0&255,t[29]=P>>>8&255,t[30]=P>>>16&255,t[31]=P>>>24&255,t[32]=x>>>0&255,t[33]=x>>>8&255,t[34]=x>>>16&255,t[35]=x>>>24&255,t[36]=O>>>0&255,t[37]=O>>>8&255,t[38]=O>>>16&255,t[39]=O>>>24&255,t[40]=L>>>0&255,t[41]=L>>>8&255,t[42]=L>>>16&255,t[43]=L>>>24&255,t[44]=U>>>0&255,t[45]=U>>>8&255,t[46]=U>>>16&255,t[47]=U>>>24&255,t[48]=R>>>0&255,t[49]=R>>>8&255,t[50]=R>>>16&255,t[51]=R>>>24&255,t[52]=M>>>0&255,t[53]=M>>>8&255,t[54]=M>>>16&255,t[55]=M>>>24&255,t[56]=I>>>0&255,t[57]=I>>>8&255,t[58]=I>>>16&255,t[59]=I>>>24&255,t[60]=N>>>0&255,t[61]=N>>>8&255,t[62]=N>>>16&255,t[63]=N>>>24&255}(t,e,n,r)}function m(t,e,n,r){!function(t,e,n,r){for(var i,s=255&r[0]|(255&r[1])<<8|(255&r[2])<<16|(255&r[3])<<24,o=255&n[0]|(255&n[1])<<8|(255&n[2])<<16|(255&n[3])<<24,a=255&n[4]|(255&n[5])<<8|(255&n[6])<<16|(255&n[7])<<24,h=255&n[8]|(255&n[9])<<8|(255&n[10])<<16|(255&n[11])<<24,c=255&n[12]|(255&n[13])<<8|(255&n[14])<<16|(255&n[15])<<24,u=255&r[4]|(255&r[5])<<8|(255&r[6])<<16|(255&r[7])<<24,l=255&e[0]|(255&e[1])<<8|(255&e[2])<<16|(255&e[3])<<24,d=255&e[4]|(255&e[5])<<8|(255&e[6])<<16|(255&e[7])<<24,f=255&e[8]|(255&e[9])<<8|(255&e[10])<<16|(255&e[11])<<24,p=255&e[12]|(255&e[13])<<8|(255&e[14])<<16|(255&e[15])<<24,g=255&r[8]|(255&r[9])<<8|(255&r[10])<<16|(255&r[11])<<24,b=255&n[16]|(255&n[17])<<8|(255&n[18])<<16|(255&n[19])<<24,v=255&n[20]|(255&n[21])<<8|(255&n[22])<<16|(255&n[23])<<24,y=255&n[24]|(255&n[25])<<8|(255&n[26])<<16|(255&n[27])<<24,m=255&n[28]|(255&n[29])<<8|(255&n[30])<<16|(255&n[31])<<24,w=255&r[12]|(255&r[13])<<8|(255&r[14])<<16|(255&r[15])<<24,_=0;_<20;_+=2)s^=(i=(v^=(i=(f^=(i=(c^=(i=s+v|0)<<7|i>>>25)+s|0)<<9|i>>>23)+c|0)<<13|i>>>19)+f|0)<<18|i>>>14,u^=(i=(o^=(i=(y^=(i=(p^=(i=u+o|0)<<7|i>>>25)+u|0)<<9|i>>>23)+p|0)<<13|i>>>19)+y|0)<<18|i>>>14,g^=(i=(l^=(i=(a^=(i=(m^=(i=g+l|0)<<7|i>>>25)+g|0)<<9|i>>>23)+m|0)<<13|i>>>19)+a|0)<<18|i>>>14,w^=(i=(b^=(i=(d^=(i=(h^=(i=w+b|0)<<7|i>>>25)+w|0)<<9|i>>>23)+h|0)<<13|i>>>19)+d|0)<<18|i>>>14,s^=(i=(h^=(i=(a^=(i=(o^=(i=s+h|0)<<7|i>>>25)+s|0)<<9|i>>>23)+o|0)<<13|i>>>19)+a|0)<<18|i>>>14,u^=(i=(c^=(i=(d^=(i=(l^=(i=u+c|0)<<7|i>>>25)+u|0)<<9|i>>>23)+l|0)<<13|i>>>19)+d|0)<<18|i>>>14,g^=(i=(p^=(i=(f^=(i=(b^=(i=g+p|0)<<7|i>>>25)+g|0)<<9|i>>>23)+b|0)<<13|i>>>19)+f|0)<<18|i>>>14,w^=(i=(m^=(i=(y^=(i=(v^=(i=w+m|0)<<7|i>>>25)+w|0)<<9|i>>>23)+v|0)<<13|i>>>19)+y|0)<<18|i>>>14;t[0]=s>>>0&255,t[1]=s>>>8&255,t[2]=s>>>16&255,t[3]=s>>>24&255,t[4]=u>>>0&255,t[5]=u>>>8&255,t[6]=u>>>16&255,t[7]=u>>>24&255,t[8]=g>>>0&255,t[9]=g>>>8&255,t[10]=g>>>16&255,t[11]=g>>>24&255,t[12]=w>>>0&255,t[13]=w>>>8&255,t[14]=w>>>16&255,t[15]=w>>>24&255,t[16]=l>>>0&255,t[17]=l>>>8&255,t[18]=l>>>16&255,t[19]=l>>>24&255,t[20]=d>>>0&255,t[21]=d>>>8&255,t[22]=d>>>16&255,t[23]=d>>>24&255,t[24]=f>>>0&255,t[25]=f>>>8&255,t[26]=f>>>16&255,t[27]=f>>>24&255,t[28]=p>>>0&255,t[29]=p>>>8&255,t[30]=p>>>16&255,t[31]=p>>>24&255}(t,e,n,r)}var w=new Uint8Array([101,120,112,97,110,100,32,51,50,45,98,121,116,101,32,107]);function _(t,e,n,r,i,s,o){var a,h,c=new Uint8Array(16),u=new Uint8Array(64);for(h=0;h<16;h++)c[h]=0;for(h=0;h<8;h++)c[h]=s[h];for(;i>=64;){for(y(u,c,o,w),h=0;h<64;h++)t[e+h]=n[r+h]^u[h];for(a=1,h=8;h<16;h++)a=a+(255&c[h])|0,c[h]=255&a,a>>>=8;i-=64,e+=64,r+=64}if(i>0)for(y(u,c,o,w),h=0;h=64;){for(y(h,a,i,w),o=0;o<64;o++)t[e+o]=h[o];for(s=1,o=8;o<16;o++)s=s+(255&a[o])|0,a[o]=255&s,s>>>=8;n-=64,e+=64}if(n>0)for(y(h,a,i,w),o=0;o>>13|n<<3),r=255&t[4]|(255&t[5])<<8,this.r[2]=7939&(n>>>10|r<<6),i=255&t[6]|(255&t[7])<<8,this.r[3]=8191&(r>>>7|i<<9),s=255&t[8]|(255&t[9])<<8,this.r[4]=255&(i>>>4|s<<12),this.r[5]=s>>>1&8190,o=255&t[10]|(255&t[11])<<8,this.r[6]=8191&(s>>>14|o<<2),a=255&t[12]|(255&t[13])<<8,this.r[7]=8065&(o>>>11|a<<5),h=255&t[14]|(255&t[15])<<8,this.r[8]=8191&(a>>>8|h<<8),this.r[9]=h>>>5&127,this.pad[0]=255&t[16]|(255&t[17])<<8,this.pad[1]=255&t[18]|(255&t[19])<<8,this.pad[2]=255&t[20]|(255&t[21])<<8,this.pad[3]=255&t[22]|(255&t[23])<<8,this.pad[4]=255&t[24]|(255&t[25])<<8,this.pad[5]=255&t[26]|(255&t[27])<<8,this.pad[6]=255&t[28]|(255&t[29])<<8,this.pad[7]=255&t[30]|(255&t[31])<<8};function E(t,e,n,r,i,s){var o=new T(s);return o.update(n,r,i),o.finish(t,e),0}function A(t,e,n,r,i,s){var o=new Uint8Array(16);return E(o,0,n,r,i,s),b(t,e,o,0)}function P(t,e,n,r,i){var s;if(n<32)return-1;for(C(t,0,e,0,n,r,i),E(t,16,t,32,n-32,t),s=0;s<16;s++)t[s]=0;return 0}function x(t,e,n,r,i){var s,o=new Uint8Array(32);if(n<32)return-1;if(k(o,0,32,r,i),0!==A(e,16,e,32,n-32,o))return-1;for(C(t,0,e,0,n,r,i),s=0;s<32;s++)t[s]=0;return 0}function O(t,e){var n;for(n=0;n<16;n++)t[n]=0|e[n]}function L(t){var e,n,r=1;for(e=0;e<16;e++)n=t[e]+r+65535,r=Math.floor(n/65536),t[e]=n-65536*r;t[0]+=r-1+37*(r-1)}function U(t,e,n){for(var r,i=~(n-1),s=0;s<16;s++)r=i&(t[s]^e[s]),t[s]^=r,e[s]^=r}function R(t,n){var r,i,s,o=e(),a=e();for(r=0;r<16;r++)a[r]=n[r];for(L(a),L(a),L(a),i=0;i<2;i++){for(o[0]=a[0]-65517,r=1;r<15;r++)o[r]=a[r]-65535-(o[r-1]>>16&1),o[r-1]&=65535;o[15]=a[15]-32767-(o[14]>>16&1),s=o[15]>>16&1,o[14]&=65535,U(a,o,1-s)}for(r=0;r<16;r++)t[2*r]=255&a[r],t[2*r+1]=a[r]>>8}function M(t,e){var n=new Uint8Array(32),r=new Uint8Array(32);return R(n,t),R(r,e),v(n,0,r,0)}function I(t){var e=new Uint8Array(32);return R(e,t),1&e[0]}function N(t,e){var n;for(n=0;n<16;n++)t[n]=e[2*n]+(e[2*n+1]<<8);t[15]&=32767}function j(t,e,n){for(var r=0;r<16;r++)t[r]=e[r]+n[r]}function D(t,e,n){for(var r=0;r<16;r++)t[r]=e[r]-n[r]}function z(t,e,n){var r,i,s=0,o=0,a=0,h=0,c=0,u=0,l=0,d=0,f=0,p=0,g=0,b=0,v=0,y=0,m=0,w=0,_=0,S=0,k=0,C=0,T=0,E=0,A=0,P=0,x=0,O=0,L=0,U=0,R=0,M=0,I=0,N=n[0],j=n[1],D=n[2],z=n[3],H=n[4],B=n[5],F=n[6],q=n[7],Y=n[8],K=n[9],$=n[10],J=n[11],X=n[12],W=n[13],G=n[14],V=n[15];s+=(r=e[0])*N,o+=r*j,a+=r*D,h+=r*z,c+=r*H,u+=r*B,l+=r*F,d+=r*q,f+=r*Y,p+=r*K,g+=r*$,b+=r*J,v+=r*X,y+=r*W,m+=r*G,w+=r*V,o+=(r=e[1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*$,T+=r*J,E+=r*X,A+=r*W,P+=r*G,x+=r*V,g+=(r=e[10])*N,b+=r*j,v+=r*D,y+=r*z,m+=r*H,w+=r*B,_+=r*F,S+=r*q,k+=r*Y,C+=r*K,T+=r*$,E+=r*J,A+=r*X,P+=r*W,x+=r*G,O+=r*V,b+=(r=e[11])*N,v+=r*j,y+=r*D,m+=r*z,w+=r*H,_+=r*B,S+=r*F,k+=r*q,C+=r*Y,T+=r*K,E+=r*$,A+=r*J,P+=r*X,x+=r*W,O+=r*G,L+=r*V,v+=(r=e[12])*N,y+=r*j,m+=r*D,w+=r*z,_+=r*H,S+=r*B,k+=r*F,C+=r*q,T+=r*Y,E+=r*K,A+=r*$,P+=r*J,x+=r*X,O+=r*W,L+=r*G,U+=r*V,y+=(r=e[13])*N,m+=r*j,w+=r*D,_+=r*z,S+=r*H,k+=r*B,C+=r*F,T+=r*q,E+=r*Y,A+=r*K,P+=r*$,x+=r*J,O+=r*X,L+=r*W,U+=r*G,R+=r*V,m+=(r=e[14])*N,w+=r*j,_+=r*D,S+=r*z,k+=r*H,C+=r*B,T+=r*F,E+=r*q,A+=r*Y,P+=r*K,x+=r*$,O+=r*J,L+=r*X,U+=r*W,R+=r*G,M+=r*V,w+=(r=e[15])*N,o+=38*(S+=r*D),a+=38*(k+=r*z),h+=38*(C+=r*H),c+=38*(T+=r*B),u+=38*(E+=r*F),l+=38*(A+=r*q),d+=38*(P+=r*Y),f+=38*(x+=r*K),p+=38*(O+=r*$),g+=38*(L+=r*J),b+=38*(U+=r*X),v+=38*(R+=r*W),y+=38*(M+=r*G),m+=38*(I+=r*V),s=(r=(s+=38*(_+=r*j))+(i=1)+65535)-65536*(i=Math.floor(r/65536)),o=(r=o+i+65535)-65536*(i=Math.floor(r/65536)),a=(r=a+i+65535)-65536*(i=Math.floor(r/65536)),h=(r=h+i+65535)-65536*(i=Math.floor(r/65536)),c=(r=c+i+65535)-65536*(i=Math.floor(r/65536)),u=(r=u+i+65535)-65536*(i=Math.floor(r/65536)),l=(r=l+i+65535)-65536*(i=Math.floor(r/65536)),d=(r=d+i+65535)-65536*(i=Math.floor(r/65536)),f=(r=f+i+65535)-65536*(i=Math.floor(r/65536)),p=(r=p+i+65535)-65536*(i=Math.floor(r/65536)),g=(r=g+i+65535)-65536*(i=Math.floor(r/65536)),b=(r=b+i+65535)-65536*(i=Math.floor(r/65536)),v=(r=v+i+65535)-65536*(i=Math.floor(r/65536)),y=(r=y+i+65535)-65536*(i=Math.floor(r/65536)),m=(r=m+i+65535)-65536*(i=Math.floor(r/65536)),w=(r=w+i+65535)-65536*(i=Math.floor(r/65536)),s=(r=(s+=i-1+37*(i-1))+(i=1)+65535)-65536*(i=Math.floor(r/65536)),o=(r=o+i+65535)-65536*(i=Math.floor(r/65536)),a=(r=a+i+65535)-65536*(i=Math.floor(r/65536)),h=(r=h+i+65535)-65536*(i=Math.floor(r/65536)),c=(r=c+i+65535)-65536*(i=Math.floor(r/65536)),u=(r=u+i+65535)-65536*(i=Math.floor(r/65536)),l=(r=l+i+65535)-65536*(i=Math.floor(r/65536)),d=(r=d+i+65535)-65536*(i=Math.floor(r/65536)),f=(r=f+i+65535)-65536*(i=Math.floor(r/65536)),p=(r=p+i+65535)-65536*(i=Math.floor(r/65536)),g=(r=g+i+65535)-65536*(i=Math.floor(r/65536)),b=(r=b+i+65535)-65536*(i=Math.floor(r/65536)),v=(r=v+i+65535)-65536*(i=Math.floor(r/65536)),y=(r=y+i+65535)-65536*(i=Math.floor(r/65536)),m=(r=m+i+65535)-65536*(i=Math.floor(r/65536)),w=(r=w+i+65535)-65536*(i=Math.floor(r/65536)),s+=i-1+37*(i-1),t[0]=s,t[1]=o,t[2]=a,t[3]=h,t[4]=c,t[5]=u,t[6]=l,t[7]=d,t[8]=f,t[9]=p,t[10]=g,t[11]=b,t[12]=v,t[13]=y,t[14]=m,t[15]=w}function H(t,e){z(t,e,e)}function B(t,n){var r,i=e();for(r=0;r<16;r++)i[r]=n[r];for(r=253;r>=0;r--)H(i,i),2!==r&&4!==r&&z(i,i,n);for(r=0;r<16;r++)t[r]=i[r]}function F(t,n){var r,i=e();for(r=0;r<16;r++)i[r]=n[r];for(r=250;r>=0;r--)H(i,i),1!==r&&z(i,i,n);for(r=0;r<16;r++)t[r]=i[r]}function q(t,n,r){var i,s,o=new Uint8Array(32),a=new Float64Array(80),c=e(),u=e(),l=e(),d=e(),f=e(),p=e();for(s=0;s<31;s++)o[s]=n[s];for(o[31]=127&n[31]|64,o[0]&=248,N(a,r),s=0;s<16;s++)u[s]=a[s],d[s]=c[s]=l[s]=0;for(c[0]=d[0]=1,s=254;s>=0;--s)U(c,u,i=o[s>>>3]>>>(7&s)&1),U(l,d,i),j(f,c,l),D(c,c,l),j(l,u,d),D(u,u,d),H(d,f),H(p,c),z(c,l,c),z(l,u,f),j(f,c,l),D(c,c,l),H(u,c),D(l,d,p),z(c,l,h),j(c,c,d),z(l,l,c),z(c,d,p),z(d,u,a),H(u,f),U(c,u,i),U(l,d,i);for(s=0;s<16;s++)a[s+16]=c[s],a[s+32]=l[s],a[s+48]=u[s],a[s+64]=d[s];var g=a.subarray(32),b=a.subarray(16);return B(g,g),z(b,b,g),R(t,b),0}function Y(t,e){return q(t,e,s)}function K(t,e){return r(e,32),Y(t,e)}function $(t,e,n){var r=new Uint8Array(32);return q(r,n,e),m(t,i,r,w)}T.prototype.blocks=function(t,e,n){for(var r,i,s,o,a,h,c,u,l,d,f,p,g,b,v,y,m,w,_,S=this.fin?0:2048,k=this.h[0],C=this.h[1],T=this.h[2],E=this.h[3],A=this.h[4],P=this.h[5],x=this.h[6],O=this.h[7],L=this.h[8],U=this.h[9],R=this.r[0],M=this.r[1],I=this.r[2],N=this.r[3],j=this.r[4],D=this.r[5],z=this.r[6],H=this.r[7],B=this.r[8],F=this.r[9];n>=16;)d=l=0,d+=(k+=8191&(r=255&t[e+0]|(255&t[e+1])<<8))*R,d+=(C+=8191&(r>>>13|(i=255&t[e+2]|(255&t[e+3])<<8)<<3))*(5*F),d+=(T+=8191&(i>>>10|(s=255&t[e+4]|(255&t[e+5])<<8)<<6))*(5*B),d+=(E+=8191&(s>>>7|(o=255&t[e+6]|(255&t[e+7])<<8)<<9))*(5*H),l=(d+=(A+=8191&(o>>>4|(a=255&t[e+8]|(255&t[e+9])<<8)<<12))*(5*z))>>>13,d&=8191,d+=(P+=a>>>1&8191)*(5*D),d+=(x+=8191&(a>>>14|(h=255&t[e+10]|(255&t[e+11])<<8)<<2))*(5*j),d+=(O+=8191&(h>>>11|(c=255&t[e+12]|(255&t[e+13])<<8)<<5))*(5*N),d+=(L+=8191&(c>>>8|(u=255&t[e+14]|(255&t[e+15])<<8)<<8))*(5*I),f=l+=(d+=(U+=u>>>5|S)*(5*M))>>>13,f+=k*M,f+=C*R,f+=T*(5*F),f+=E*(5*B),l=(f+=A*(5*H))>>>13,f&=8191,f+=P*(5*z),f+=x*(5*D),f+=O*(5*j),f+=L*(5*N),l+=(f+=U*(5*I))>>>13,f&=8191,p=l,p+=k*I,p+=C*M,p+=T*R,p+=E*(5*F),l=(p+=A*(5*B))>>>13,p&=8191,p+=P*(5*H),p+=x*(5*z),p+=O*(5*D),p+=L*(5*j),g=l+=(p+=U*(5*N))>>>13,g+=k*N,g+=C*I,g+=T*M,g+=E*R,l=(g+=A*(5*F))>>>13,g&=8191,g+=P*(5*B),g+=x*(5*H),g+=O*(5*z),g+=L*(5*D),b=l+=(g+=U*(5*j))>>>13,b+=k*j,b+=C*N,b+=T*I,b+=E*M,l=(b+=A*R)>>>13,b&=8191,b+=P*(5*F),b+=x*(5*B),b+=O*(5*H),b+=L*(5*z),v=l+=(b+=U*(5*D))>>>13,v+=k*D,v+=C*j,v+=T*N,v+=E*I,l=(v+=A*M)>>>13,v&=8191,v+=P*R,v+=x*(5*F),v+=O*(5*B),v+=L*(5*H),y=l+=(v+=U*(5*z))>>>13,y+=k*z,y+=C*D,y+=T*j,y+=E*N,l=(y+=A*I)>>>13,y&=8191,y+=P*M,y+=x*R,y+=O*(5*F),y+=L*(5*B),m=l+=(y+=U*(5*H))>>>13,m+=k*H,m+=C*z,m+=T*D,m+=E*j,l=(m+=A*N)>>>13,m&=8191,m+=P*I,m+=x*M,m+=O*R,m+=L*(5*F),w=l+=(m+=U*(5*B))>>>13,w+=k*B,w+=C*H,w+=T*z,w+=E*D,l=(w+=A*j)>>>13,w&=8191,w+=P*N,w+=x*I,w+=O*M,w+=L*R,_=l+=(w+=U*(5*F))>>>13,_+=k*F,_+=C*B,_+=T*H,_+=E*z,l=(_+=A*D)>>>13,_&=8191,_+=P*j,_+=x*N,_+=O*I,_+=L*M,k=d=8191&(l=(l=((l+=(_+=U*R)>>>13)<<2)+l|0)+(d&=8191)|0),C=f+=l>>>=13,T=p&=8191,E=g&=8191,A=b&=8191,P=v&=8191,x=y&=8191,O=m&=8191,L=w&=8191,U=_&=8191,e+=16,n-=16;this.h[0]=k,this.h[1]=C,this.h[2]=T,this.h[3]=E,this.h[4]=A,this.h[5]=P,this.h[6]=x,this.h[7]=O,this.h[8]=L,this.h[9]=U},T.prototype.finish=function(t,e){var n,r,i,s,o=new Uint16Array(10);if(this.leftover){for(s=this.leftover,this.buffer[s++]=1;s<16;s++)this.buffer[s]=0;this.fin=1,this.blocks(this.buffer,0,16)}for(n=this.h[1]>>>13,this.h[1]&=8191,s=2;s<10;s++)this.h[s]+=n,n=this.h[s]>>>13,this.h[s]&=8191;for(this.h[0]+=5*n,n=this.h[0]>>>13,this.h[0]&=8191,this.h[1]+=n,n=this.h[1]>>>13,this.h[1]&=8191,this.h[2]+=n,o[0]=this.h[0]+5,n=o[0]>>>13,o[0]&=8191,s=1;s<10;s++)o[s]=this.h[s]+n,n=o[s]>>>13,o[s]&=8191;for(o[9]-=8192,r=(1^n)-1,s=0;s<10;s++)o[s]&=r;for(r=~r,s=0;s<10;s++)this.h[s]=this.h[s]&r|o[s];for(this.h[0]=65535&(this.h[0]|this.h[1]<<13),this.h[1]=65535&(this.h[1]>>>3|this.h[2]<<10),this.h[2]=65535&(this.h[2]>>>6|this.h[3]<<7),this.h[3]=65535&(this.h[3]>>>9|this.h[4]<<4),this.h[4]=65535&(this.h[4]>>>12|this.h[5]<<1|this.h[6]<<14),this.h[5]=65535&(this.h[6]>>>2|this.h[7]<<11),this.h[6]=65535&(this.h[7]>>>5|this.h[8]<<8),this.h[7]=65535&(this.h[8]>>>8|this.h[9]<<5),i=this.h[0]+this.pad[0],this.h[0]=65535&i,s=1;s<8;s++)i=(this.h[s]+this.pad[s]|0)+(i>>>16)|0,this.h[s]=65535&i;t[e+0]=this.h[0]>>>0&255,t[e+1]=this.h[0]>>>8&255,t[e+2]=this.h[1]>>>0&255,t[e+3]=this.h[1]>>>8&255,t[e+4]=this.h[2]>>>0&255,t[e+5]=this.h[2]>>>8&255,t[e+6]=this.h[3]>>>0&255,t[e+7]=this.h[3]>>>8&255,t[e+8]=this.h[4]>>>0&255,t[e+9]=this.h[4]>>>8&255,t[e+10]=this.h[5]>>>0&255,t[e+11]=this.h[5]>>>8&255,t[e+12]=this.h[6]>>>0&255,t[e+13]=this.h[6]>>>8&255,t[e+14]=this.h[7]>>>0&255,t[e+15]=this.h[7]>>>8&255},T.prototype.update=function(t,e,n){var r,i;if(this.leftover){for((i=16-this.leftover)>n&&(i=n),r=0;r=16&&(i=n-n%16,this.blocks(t,e,i),e+=i,n-=i),n){for(r=0;r=128;){for(S=0;S<16;S++)k=8*S+X,O[S]=n[k+0]<<24|n[k+1]<<16|n[k+2]<<8|n[k+3],L[S]=n[k+4]<<24|n[k+5]<<16|n[k+6]<<8|n[k+7];for(S=0;S<80;S++)if(i=U,s=R,o=M,a=I,h=N,c=j,u=D,z,d=H,f=B,p=F,g=q,b=Y,v=K,y=$,J,E=65535&(T=J),A=T>>>16,P=65535&(C=z),x=C>>>16,E+=65535&(T=(Y>>>14|N<<18)^(Y>>>18|N<<14)^(N>>>9|Y<<23)),A+=T>>>16,P+=65535&(C=(N>>>14|Y<<18)^(N>>>18|Y<<14)^(Y>>>9|N<<23)),x+=C>>>16,E+=65535&(T=Y&K^~Y&$),A+=T>>>16,P+=65535&(C=N&j^~N&D),x+=C>>>16,E+=65535&(T=W[2*S+1]),A+=T>>>16,P+=65535&(C=W[2*S]),x+=C>>>16,C=O[S%16],A+=(T=L[S%16])>>>16,P+=65535&C,x+=C>>>16,P+=(A+=(E+=65535&T)>>>16)>>>16,E=65535&(T=_=65535&E|A<<16),A=T>>>16,P=65535&(C=w=65535&P|(x+=P>>>16)<<16),x=C>>>16,E+=65535&(T=(H>>>28|U<<4)^(U>>>2|H<<30)^(U>>>7|H<<25)),A+=T>>>16,P+=65535&(C=(U>>>28|H<<4)^(H>>>2|U<<30)^(H>>>7|U<<25)),x+=C>>>16,A+=(T=H&B^H&F^B&F)>>>16,P+=65535&(C=U&R^U&M^R&M),x+=C>>>16,l=65535&(P+=(A+=(E+=65535&T)>>>16)>>>16)|(x+=P>>>16)<<16,m=65535&E|A<<16,E=65535&(T=g),A=T>>>16,P=65535&(C=a),x=C>>>16,A+=(T=_)>>>16,P+=65535&(C=w),x+=C>>>16,R=i,M=s,I=o,N=a=65535&(P+=(A+=(E+=65535&T)>>>16)>>>16)|(x+=P>>>16)<<16,j=h,D=c,z=u,U=l,B=d,F=f,q=p,Y=g=65535&E|A<<16,K=b,$=v,J=y,H=m,S%16==15)for(k=0;k<16;k++)C=O[k],E=65535&(T=L[k]),A=T>>>16,P=65535&C,x=C>>>16,C=O[(k+9)%16],E+=65535&(T=L[(k+9)%16]),A+=T>>>16,P+=65535&C,x+=C>>>16,w=O[(k+1)%16],E+=65535&(T=((_=L[(k+1)%16])>>>1|w<<31)^(_>>>8|w<<24)^(_>>>7|w<<25)),A+=T>>>16,P+=65535&(C=(w>>>1|_<<31)^(w>>>8|_<<24)^w>>>7),x+=C>>>16,w=O[(k+14)%16],A+=(T=((_=L[(k+14)%16])>>>19|w<<13)^(w>>>29|_<<3)^(_>>>6|w<<26))>>>16,P+=65535&(C=(w>>>19|_<<13)^(_>>>29|w<<3)^w>>>6),x+=C>>>16,x+=(P+=(A+=(E+=65535&T)>>>16)>>>16)>>>16,O[k]=65535&P|x<<16,L[k]=65535&E|A<<16;E=65535&(T=H),A=T>>>16,P=65535&(C=U),x=C>>>16,C=t[0],A+=(T=e[0])>>>16,P+=65535&C,x+=C>>>16,x+=(P+=(A+=(E+=65535&T)>>>16)>>>16)>>>16,t[0]=U=65535&P|x<<16,e[0]=H=65535&E|A<<16,E=65535&(T=B),A=T>>>16,P=65535&(C=R),x=C>>>16,C=t[1],A+=(T=e[1])>>>16,P+=65535&C,x+=C>>>16,x+=(P+=(A+=(E+=65535&T)>>>16)>>>16)>>>16,t[1]=R=65535&P|x<<16,e[1]=B=65535&E|A<<16,E=65535&(T=F),A=T>>>16,P=65535&(C=M),x=C>>>16,C=t[2],A+=(T=e[2])>>>16,P+=65535&C,x+=C>>>16,x+=(P+=(A+=(E+=65535&T)>>>16)>>>16)>>>16,t[2]=M=65535&P|x<<16,e[2]=F=65535&E|A<<16,E=65535&(T=q),A=T>>>16,P=65535&(C=I),x=C>>>16,C=t[3],A+=(T=e[3])>>>16,P+=65535&C,x+=C>>>16,x+=(P+=(A+=(E+=65535&T)>>>16)>>>16)>>>16,t[3]=I=65535&P|x<<16,e[3]=q=65535&E|A<<16,E=65535&(T=Y),A=T>>>16,P=65535&(C=N),x=C>>>16,C=t[4],A+=(T=e[4])>>>16,P+=65535&C,x+=C>>>16,x+=(P+=(A+=(E+=65535&T)>>>16)>>>16)>>>16,t[4]=N=65535&P|x<<16,e[4]=Y=65535&E|A<<16,E=65535&(T=K),A=T>>>16,P=65535&(C=j),x=C>>>16,C=t[5],A+=(T=e[5])>>>16,P+=65535&C,x+=C>>>16,x+=(P+=(A+=(E+=65535&T)>>>16)>>>16)>>>16,t[5]=j=65535&P|x<<16,e[5]=K=65535&E|A<<16,E=65535&(T=$),A=T>>>16,P=65535&(C=D),x=C>>>16,C=t[6],A+=(T=e[6])>>>16,P+=65535&C,x+=C>>>16,x+=(P+=(A+=(E+=65535&T)>>>16)>>>16)>>>16,t[6]=D=65535&P|x<<16,e[6]=$=65535&E|A<<16,E=65535&(T=J),A=T>>>16,P=65535&(C=z),x=C>>>16,C=t[7],A+=(T=e[7])>>>16,P+=65535&C,x+=C>>>16,x+=(P+=(A+=(E+=65535&T)>>>16)>>>16)>>>16,t[7]=z=65535&P|x<<16,e[7]=J=65535&E|A<<16,X+=128,r-=128}return r}function V(t,e,n){var r,i=new Int32Array(8),s=new Int32Array(8),o=new Uint8Array(256),a=n;for(i[0]=1779033703,i[1]=3144134277,i[2]=1013904242,i[3]=2773480762,i[4]=1359893119,i[5]=2600822924,i[6]=528734635,i[7]=1541459225,s[0]=4089235720,s[1]=2227873595,s[2]=4271175723,s[3]=1595750129,s[4]=2917565137,s[5]=725511199,s[6]=4215389547,s[7]=327033209,G(i,s,e,n),n%=128,r=0;r=0;--i)Q(t,e,r=n[i/8|0]>>(7&i)&1),Z(e,t),Z(t,t),Q(t,e,r)}function nt(t,n){var r=[e(),e(),e(),e()];O(r[0],l),O(r[1],d),O(r[2],a),z(r[3],l,d),et(t,r,n)}function rt(t,n,i){var s,o=new Uint8Array(64),a=[e(),e(),e(),e()];for(i||r(n,32),V(o,n,32),o[0]&=248,o[31]&=127,o[31]|=64,nt(a,o),tt(t,a),s=0;s<32;s++)n[s+32]=t[s];return 0}var it=new Float64Array([237,211,245,92,26,99,18,88,214,156,247,162,222,249,222,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16]);function st(t,e){var n,r,i,s;for(r=63;r>=32;--r){for(n=0,i=r-32,s=r-12;i>4)*it[i],n=e[i]>>8,e[i]&=255;for(i=0;i<32;i++)e[i]-=n*it[i];for(r=0;r<32;r++)e[r+1]+=e[r]>>8,t[r]=255&e[r]}function ot(t){var e,n=new Float64Array(64);for(e=0;e<64;e++)n[e]=t[e];for(e=0;e<64;e++)t[e]=0;st(t,n)}function at(t,n,r,i){var s,o,a=new Uint8Array(64),h=new Uint8Array(64),c=new Uint8Array(64),u=new Float64Array(64),l=[e(),e(),e(),e()];V(a,i,32),a[0]&=248,a[31]&=127,a[31]|=64;var d=r+64;for(s=0;s>7&&D(t[0],o,t[0]),z(t[3],t[0],t[1]),0)}(d,i))return-1;for(s=0;s=0},t.sign.keyPair=function(){var t=new Uint8Array(32),e=new Uint8Array(64);return rt(t,e),{publicKey:t,secretKey:e}},t.sign.keyPair.fromSecretKey=function(t){if(ut(t),64!==t.length)throw new Error("bad secret key size");for(var e=new Uint8Array(32),n=0;n(target: any, ...sources: any[]): T {\n for (var i = 0; i < sources.length; i++) {\n var extensions = sources[i];\n for (var property in extensions) {\n if (\n extensions[property] &&\n extensions[property].constructor &&\n extensions[property].constructor === Object\n ) {\n target[property] = extend(target[property] || {}, extensions[property]);\n } else {\n target[property] = extensions[property];\n }\n }\n }\n return target;\n}\n\nexport function stringify(): string {\n var m = ['Pusher'];\n for (var i = 0; i < arguments.length; i++) {\n if (typeof arguments[i] === 'string') {\n m.push(arguments[i]);\n } else {\n m.push(safeJSONStringify(arguments[i]));\n }\n }\n return m.join(' : ');\n}\n\nexport function arrayIndexOf(array: any[], item: any): number {\n // MSIE doesn't have array.indexOf\n var nativeIndexOf = Array.prototype.indexOf;\n if (array === null) {\n return -1;\n }\n if (nativeIndexOf && array.indexOf === nativeIndexOf) {\n return array.indexOf(item);\n }\n for (var i = 0, l = array.length; i < l; i++) {\n if (array[i] === item) {\n return i;\n }\n }\n return -1;\n}\n\n/** Applies a function f to all properties of an object.\n *\n * Function f gets 3 arguments passed:\n * - element from the object\n * - key of the element\n * - reference to the object\n *\n * @param {Object} object\n * @param {Function} f\n */\nexport function objectApply(object: any, f: Function) {\n for (var key in object) {\n if (Object.prototype.hasOwnProperty.call(object, key)) {\n f(object[key], key, object);\n }\n }\n}\n\n/** Return a list of objects own proerty keys\n *\n * @param {Object} object\n * @returns {Array}\n */\nexport function keys(object: any): string[] {\n var keys = [];\n objectApply(object, function(_, key) {\n keys.push(key);\n });\n return keys;\n}\n\n/** Return a list of object's own property values\n *\n * @param {Object} object\n * @returns {Array}\n */\nexport function values(object: any): any[] {\n var values = [];\n objectApply(object, function(value) {\n values.push(value);\n });\n return values;\n}\n\n/** Applies a function f to all elements of an array.\n *\n * Function f gets 3 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function apply(array: any[], f: Function, context?: any) {\n for (var i = 0; i < array.length; i++) {\n f.call(context || global, array[i], i, array);\n }\n}\n\n/** Maps all elements of the array and returns the result.\n *\n * Function f gets 4 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n * - reference to the destination array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function map(array: any[], f: Function): any[] {\n var result = [];\n for (var i = 0; i < array.length; i++) {\n result.push(f(array[i], i, array, result));\n }\n return result;\n}\n\n/** Maps all elements of the object and returns the result.\n *\n * Function f gets 4 arguments passed:\n * - element from the object\n * - key of the element\n * - reference to the source object\n * - reference to the destination object\n *\n * @param {Object} object\n * @param {Function} f\n */\nexport function mapObject(object: any, f: Function): any {\n var result = {};\n objectApply(object, function(value, key) {\n result[key] = f(value);\n });\n return result;\n}\n\n/** Filters elements of the array using a test function.\n *\n * Function test gets 4 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n * - reference to the destination array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function filter(array: any[], test: Function): any[] {\n test =\n test ||\n function(value) {\n return !!value;\n };\n\n var result = [];\n for (var i = 0; i < array.length; i++) {\n if (test(array[i], i, array, result)) {\n result.push(array[i]);\n }\n }\n return result;\n}\n\n/** Filters properties of the object using a test function.\n *\n * Function test gets 4 arguments passed:\n * - element from the object\n * - key of the element\n * - reference to the source object\n * - reference to the destination object\n *\n * @param {Object} object\n * @param {Function} f\n */\nexport function filterObject(object: Object, test: Function) {\n var result = {};\n objectApply(object, function(value, key) {\n if ((test && test(value, key, object, result)) || Boolean(value)) {\n result[key] = value;\n }\n });\n return result;\n}\n\n/** Flattens an object into a two-dimensional array.\n *\n * @param {Object} object\n * @return {Array} resulting array of [key, value] pairs\n */\nexport function flatten(object: Object): any[] {\n var result = [];\n objectApply(object, function(value, key) {\n result.push([key, value]);\n });\n return result;\n}\n\n/** Checks whether any element of the array passes the test.\n *\n * Function test gets 3 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function any(array: any[], test: Function): boolean {\n for (var i = 0; i < array.length; i++) {\n if (test(array[i], i, array)) {\n return true;\n }\n }\n return false;\n}\n\n/** Checks whether all elements of the array pass the test.\n *\n * Function test gets 3 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function all(array: any[], test: Function): boolean {\n for (var i = 0; i < array.length; i++) {\n if (!test(array[i], i, array)) {\n return false;\n }\n }\n return true;\n}\n\nexport function encodeParamsObject(data): string {\n return mapObject(data, function(value) {\n if (typeof value === 'object') {\n value = safeJSONStringify(value);\n }\n return encodeURIComponent(base64encode(value.toString()));\n });\n}\n\nexport function buildQueryString(data: any): string {\n var params = filterObject(data, function(value) {\n return value !== undefined;\n });\n\n var query = map(\n flatten(encodeParamsObject(params)),\n Util.method('join', '=')\n ).join('&');\n\n return query;\n}\n\n/**\n * See https://github.com/douglascrockford/JSON-js/blob/master/cycle.js\n *\n * Remove circular references from an object. Required for JSON.stringify in\n * React Native, which tends to blow up a lot.\n *\n * @param {any} object\n * @return {any} Decycled object\n */\nexport function decycleObject(object: any): any {\n var objects = [],\n paths = [];\n\n return (function derez(value, path) {\n var i, name, nu;\n\n switch (typeof value) {\n case 'object':\n if (!value) {\n return null;\n }\n for (i = 0; i < objects.length; i += 1) {\n if (objects[i] === value) {\n return { $ref: paths[i] };\n }\n }\n\n objects.push(value);\n paths.push(path);\n\n if (Object.prototype.toString.apply(value) === '[object Array]') {\n nu = [];\n for (i = 0; i < value.length; i += 1) {\n nu[i] = derez(value[i], path + '[' + i + ']');\n }\n } else {\n nu = {};\n for (name in value) {\n if (Object.prototype.hasOwnProperty.call(value, name)) {\n nu[name] = derez(\n value[name],\n path + '[' + JSON.stringify(name) + ']'\n );\n }\n }\n }\n return nu;\n case 'number':\n case 'string':\n case 'boolean':\n return value;\n }\n })(object, '$');\n}\n\n/**\n * Provides a cross-browser and cross-platform way to safely stringify objects\n * into JSON. This is particularly necessary for ReactNative, where circular JSON\n * structures throw an exception.\n *\n * @param {any} source The object to stringify\n * @return {string} The serialized output.\n */\nexport function safeJSONStringify(source: any): string {\n try {\n return JSON.stringify(source);\n } catch (e) {\n return JSON.stringify(decycleObject(source));\n }\n}\n","import { stringify } from './utils/collections';\nimport Pusher from './pusher';\n\nclass Logger {\n debug(...args: any[]) {\n this.log(this.globalLog, args);\n }\n\n warn(...args: any[]) {\n this.log(this.globalLogWarn, args);\n }\n\n error(...args: any[]) {\n this.log(this.globalLogError, args);\n }\n\n private globalLog = (message: string) => {\n if (global.console && global.console.log) {\n global.console.log(message);\n }\n };\n\n private globalLogWarn(message: string) {\n if (global.console && global.console.warn) {\n global.console.warn(message);\n } else {\n this.globalLog(message);\n }\n }\n\n private globalLogError(message: string) {\n if (global.console && global.console.error) {\n global.console.error(message);\n } else {\n this.globalLogWarn(message);\n }\n }\n\n private log(\n defaultLoggingFunction: (message: string) => void,\n ...args: any[]\n ) {\n var message = stringify.apply(this, arguments);\n if (Pusher.log) {\n Pusher.log(message);\n } else if (Pusher.logToConsole) {\n const log = defaultLoggingFunction.bind(this);\n log(message);\n }\n }\n}\n\nexport default new Logger();\n","import * as Collections from './utils/collections';\nimport TimedCallback from './utils/timers/timed_callback';\nimport { OneOffTimer, PeriodicTimer } from './utils/timers';\n\nvar Util = {\n now(): number {\n if (Date.now) {\n return Date.now();\n } else {\n return new Date().valueOf();\n }\n },\n\n defer(callback: TimedCallback): OneOffTimer {\n return new OneOffTimer(0, callback);\n },\n\n /** Builds a function that will proxy a method call to its first argument.\n *\n * Allows partial application of arguments, so additional arguments are\n * prepended to the argument list.\n *\n * @param {String} name method name\n * @return {Function} proxy function\n */\n method(name: string, ...args: any[]): Function {\n var boundArguments = Array.prototype.slice.call(arguments, 1);\n return function(object) {\n return object[name].apply(object, boundArguments.concat(arguments));\n };\n }\n};\n\nexport default Util;\n","import * as Collections from '../utils/collections';\nimport Callback from './callback';\nimport Metadata from '../channels/metadata';\nimport CallbackRegistry from './callback_registry';\n\n/** Manages callback bindings and event emitting.\n *\n * @param Function failThrough called when no listeners are bound to an event\n */\nexport default class Dispatcher {\n callbacks: CallbackRegistry;\n global_callbacks: Function[];\n failThrough: Function;\n\n constructor(failThrough?: Function) {\n this.callbacks = new CallbackRegistry();\n this.global_callbacks = [];\n this.failThrough = failThrough;\n }\n\n bind(eventName: string, callback: Function, context?: any) {\n this.callbacks.add(eventName, callback, context);\n return this;\n }\n\n bind_global(callback: Function) {\n this.global_callbacks.push(callback);\n return this;\n }\n\n unbind(eventName?: string, callback?: Function, context?: any) {\n this.callbacks.remove(eventName, callback, context);\n return this;\n }\n\n unbind_global(callback?: Function) {\n if (!callback) {\n this.global_callbacks = [];\n return this;\n }\n\n this.global_callbacks = Collections.filter(\n this.global_callbacks || [],\n c => c !== callback\n );\n\n return this;\n }\n\n unbind_all() {\n this.unbind();\n this.unbind_global();\n return this;\n }\n\n emit(eventName: string, data?: any, metadata?: Metadata): Dispatcher {\n for (var i = 0; i < this.global_callbacks.length; i++) {\n this.global_callbacks[i](eventName, data);\n }\n\n var callbacks = this.callbacks.get(eventName);\n var args = [];\n\n if (metadata) {\n // if there's a metadata argument, we need to call the callback with both\n // data and metadata regardless of whether data is undefined\n args.push(data, metadata);\n } else if (data) {\n // metadata is undefined, so we only need to call the callback with data\n // if data exists\n args.push(data);\n }\n\n if (callbacks && callbacks.length > 0) {\n for (var i = 0; i < callbacks.length; i++) {\n callbacks[i].fn.apply(callbacks[i].context || global, args);\n }\n } else if (this.failThrough) {\n this.failThrough(eventName, data);\n }\n\n return this;\n }\n}\n","import Timer from './abstract_timer';\nimport TimedCallback from './timed_callback';\nimport { Delay } from './scheduling';\n\n// We need to bind clear functions this way to avoid exceptions on IE8\nfunction clearTimeout(timer) {\n global.clearTimeout(timer);\n}\nfunction clearInterval(timer) {\n global.clearInterval(timer);\n}\n\n/** Cross-browser compatible one-off timer abstraction.\n *\n * @param {Number} delay\n * @param {Function} callback\n */\nexport class OneOffTimer extends Timer {\n constructor(delay: Delay, callback: TimedCallback) {\n super(setTimeout, clearTimeout, delay, function(timer) {\n callback();\n return null;\n });\n }\n}\n\n/** Cross-browser compatible periodic timer abstraction.\n *\n * @param {Number} delay\n * @param {Function} callback\n */\nexport class PeriodicTimer extends Timer {\n constructor(delay: Delay, callback: TimedCallback) {\n super(setInterval, clearInterval, delay, function(timer) {\n callback();\n return timer;\n });\n }\n}\n","import {\n ChannelAuthorizationOptions,\n UserAuthenticationOptions\n} from './auth/options';\nimport { AuthTransport } from './config';\n\nexport interface DefaultConfig {\n VERSION: string;\n PROTOCOL: number;\n wsPort: number;\n wssPort: number;\n wsPath: string;\n httpHost: string;\n httpPort: number;\n httpsPort: number;\n httpPath: string;\n stats_host: string;\n authEndpoint: string;\n authTransport: AuthTransport;\n activityTimeout: number;\n pongTimeout: number;\n unavailableTimeout: number;\n userAuthentication: UserAuthenticationOptions;\n channelAuthorization: ChannelAuthorizationOptions;\n\n cdn_http?: string;\n cdn_https?: string;\n dependency_suffix?: string;\n}\n\nvar Defaults: DefaultConfig = {\n VERSION: VERSION,\n PROTOCOL: 7,\n\n wsPort: 80,\n wssPort: 443,\n wsPath: '',\n // DEPRECATED: SockJS fallback parameters\n httpHost: 'sockjs.pusher.com',\n httpPort: 80,\n httpsPort: 443,\n httpPath: '/pusher',\n // DEPRECATED: Stats\n stats_host: 'stats.pusher.com',\n // DEPRECATED: Other settings\n authEndpoint: '/pusher/auth',\n authTransport: 'ajax',\n activityTimeout: 120000,\n pongTimeout: 30000,\n unavailableTimeout: 10000,\n userAuthentication: {\n endpoint: '/pusher/user-auth',\n transport: 'ajax'\n },\n channelAuthorization: {\n endpoint: '/pusher/auth',\n transport: 'ajax'\n },\n\n // CDN configuration\n cdn_http: CDN_HTTP,\n cdn_https: CDN_HTTPS,\n dependency_suffix: DEPENDENCY_SUFFIX\n};\n\nexport default Defaults;\n","import Defaults from '../defaults';\nimport { default as URLScheme, URLSchemeParams } from './url_scheme';\n\nfunction getGenericURL(\n baseScheme: string,\n params: URLSchemeParams,\n path: string\n): string {\n var scheme = baseScheme + (params.useTLS ? 's' : '');\n var host = params.useTLS ? params.hostTLS : params.hostNonTLS;\n return scheme + '://' + host + path;\n}\n\nfunction getGenericPath(key: string, queryString?: string): string {\n var path = '/app/' + key;\n var query =\n '?protocol=' +\n Defaults.PROTOCOL +\n '&client=js' +\n '&version=' +\n Defaults.VERSION +\n (queryString ? '&' + queryString : '');\n return path + query;\n}\n\nexport var ws: URLScheme = {\n getInitial: function(key: string, params: URLSchemeParams): string {\n var path = (params.httpPath || '') + getGenericPath(key, 'flash=false');\n return getGenericURL('ws', params, path);\n }\n};\n\nexport var http: URLScheme = {\n getInitial: function(key: string, params: URLSchemeParams): string {\n var path = (params.httpPath || '/pusher') + getGenericPath(key);\n return getGenericURL('http', params, path);\n }\n};\n\nexport var sockjs: URLScheme = {\n getInitial: function(key: string, params: URLSchemeParams): string {\n return getGenericURL('http', params, params.httpPath || '/pusher');\n },\n getPath: function(key: string, params: URLSchemeParams): string {\n return getGenericPath(key);\n }\n};\n","import Util from '../util';\nimport * as Collections from '../utils/collections';\nimport { default as EventsDispatcher } from '../events/dispatcher';\nimport Logger from '../logger';\nimport TransportHooks from './transport_hooks';\nimport Socket from '../socket';\nimport Runtime from 'runtime';\nimport Timeline from '../timeline/timeline';\nimport TransportConnectionOptions from './transport_connection_options';\n\n/** Provides universal API for transport connections.\n *\n * Transport connection is a low-level object that wraps a connection method\n * and exposes a simple evented interface for the connection state and\n * messaging. It does not implement Pusher-specific WebSocket protocol.\n *\n * Additionally, it fetches resources needed for transport to work and exposes\n * an interface for querying transport features.\n *\n * States:\n * - new - initial state after constructing the object\n * - initializing - during initialization phase, usually fetching resources\n * - intialized - ready to establish a connection\n * - connection - when connection is being established\n * - open - when connection ready to be used\n * - closed - after connection was closed be either side\n *\n * Emits:\n * - error - after the connection raised an error\n *\n * Options:\n * - useTLS - whether connection should be over TLS\n * - hostTLS - host to connect to when connection is over TLS\n * - hostNonTLS - host to connect to when connection is over TLS\n *\n * @param {String} key application key\n * @param {Object} options\n */\nexport default class TransportConnection extends EventsDispatcher {\n hooks: TransportHooks;\n name: string;\n priority: number;\n key: string;\n options: TransportConnectionOptions;\n state: string;\n timeline: Timeline;\n activityTimeout: number;\n id: number;\n socket: Socket;\n beforeOpen: Function;\n initialize: Function;\n\n constructor(\n hooks: TransportHooks,\n name: string,\n priority: number,\n key: string,\n options: TransportConnectionOptions\n ) {\n super();\n this.initialize = Runtime.transportConnectionInitializer;\n this.hooks = hooks;\n this.name = name;\n this.priority = priority;\n this.key = key;\n this.options = options;\n\n this.state = 'new';\n this.timeline = options.timeline;\n this.activityTimeout = options.activityTimeout;\n this.id = this.timeline.generateUniqueID();\n }\n\n /** Checks whether the transport handles activity checks by itself.\n *\n * @return {Boolean}\n */\n handlesActivityChecks(): boolean {\n return Boolean(this.hooks.handlesActivityChecks);\n }\n\n /** Checks whether the transport supports the ping/pong API.\n *\n * @return {Boolean}\n */\n supportsPing(): boolean {\n return Boolean(this.hooks.supportsPing);\n }\n\n /** Tries to establish a connection.\n *\n * @returns {Boolean} false if transport is in invalid state\n */\n connect(): boolean {\n if (this.socket || this.state !== 'initialized') {\n return false;\n }\n\n var url = this.hooks.urls.getInitial(this.key, this.options);\n try {\n this.socket = this.hooks.getSocket(url, this.options);\n } catch (e) {\n Util.defer(() => {\n this.onError(e);\n this.changeState('closed');\n });\n return false;\n }\n\n this.bindListeners();\n\n Logger.debug('Connecting', { transport: this.name, url });\n this.changeState('connecting');\n return true;\n }\n\n /** Closes the connection.\n *\n * @return {Boolean} true if there was a connection to close\n */\n close(): boolean {\n if (this.socket) {\n this.socket.close();\n return true;\n } else {\n return false;\n }\n }\n\n /** Sends data over the open connection.\n *\n * @param {String} data\n * @return {Boolean} true only when in the \"open\" state\n */\n send(data: any): boolean {\n if (this.state === 'open') {\n // Workaround for MobileSafari bug (see https://gist.github.com/2052006)\n Util.defer(() => {\n if (this.socket) {\n this.socket.send(data);\n }\n });\n return true;\n } else {\n return false;\n }\n }\n\n /** Sends a ping if the connection is open and transport supports it. */\n ping() {\n if (this.state === 'open' && this.supportsPing()) {\n this.socket.ping();\n }\n }\n\n private onOpen() {\n if (this.hooks.beforeOpen) {\n this.hooks.beforeOpen(\n this.socket,\n this.hooks.urls.getPath(this.key, this.options)\n );\n }\n this.changeState('open');\n this.socket.onopen = undefined;\n }\n\n private onError(error) {\n this.emit('error', { type: 'WebSocketError', error: error });\n this.timeline.error(this.buildTimelineMessage({ error: error.toString() }));\n }\n\n private onClose(closeEvent?: any) {\n if (closeEvent) {\n this.changeState('closed', {\n code: closeEvent.code,\n reason: closeEvent.reason,\n wasClean: closeEvent.wasClean\n });\n } else {\n this.changeState('closed');\n }\n this.unbindListeners();\n this.socket = undefined;\n }\n\n private onMessage(message) {\n this.emit('message', message);\n }\n\n private onActivity() {\n this.emit('activity');\n }\n\n private bindListeners() {\n this.socket.onopen = () => {\n this.onOpen();\n };\n this.socket.onerror = error => {\n this.onError(error);\n };\n this.socket.onclose = closeEvent => {\n this.onClose(closeEvent);\n };\n this.socket.onmessage = message => {\n this.onMessage(message);\n };\n\n if (this.supportsPing()) {\n this.socket.onactivity = () => {\n this.onActivity();\n };\n }\n }\n\n private unbindListeners() {\n if (this.socket) {\n this.socket.onopen = undefined;\n this.socket.onerror = undefined;\n this.socket.onclose = undefined;\n this.socket.onmessage = undefined;\n if (this.supportsPing()) {\n this.socket.onactivity = undefined;\n }\n }\n }\n\n private changeState(state: string, params?: any) {\n this.state = state;\n this.timeline.info(\n this.buildTimelineMessage({\n state: state,\n params: params\n })\n );\n this.emit(state, params);\n }\n\n buildTimelineMessage(message): any {\n return Collections.extend({ cid: this.id }, message);\n }\n}\n","import Factory from '../utils/factory';\nimport TransportHooks from './transport_hooks';\nimport TransportConnection from './transport_connection';\nimport TransportConnectionOptions from './transport_connection_options';\n\n/** Provides interface for transport connection instantiation.\n *\n * Takes transport-specific hooks as the only argument, which allow checking\n * for transport support and creating its connections.\n *\n * Supported hooks: * - file - the name of the file to be fetched during initialization\n * - urls - URL scheme to be used by transport\n * - handlesActivityCheck - true when the transport handles activity checks\n * - supportsPing - true when the transport has a ping/activity API\n * - isSupported - tells whether the transport is supported in the environment\n * - getSocket - creates a WebSocket-compatible transport socket\n *\n * See transports.js for specific implementations.\n *\n * @param {Object} hooks object containing all needed transport hooks\n */\nexport default class Transport {\n hooks: TransportHooks;\n\n constructor(hooks: TransportHooks) {\n this.hooks = hooks;\n }\n\n /** Returns whether the transport is supported in the environment.\n *\n * @param {Object} envronment te environment details (encryption, settings)\n * @returns {Boolean} true when the transport is supported\n */\n isSupported(environment: any): boolean {\n return this.hooks.isSupported(environment);\n }\n\n /** Creates a transport connection.\n *\n * @param {String} name\n * @param {Number} priority\n * @param {String} key the application key\n * @param {Object} options\n * @returns {TransportConnection}\n */\n createConnection(\n name: string,\n priority: number,\n key: string,\n options: any\n ): TransportConnection {\n return new TransportConnection(this.hooks, name, priority, key, options);\n }\n}\n","import * as URLSchemes from 'core/transports/url_schemes';\nimport URLScheme from 'core/transports/url_scheme';\nimport Transport from 'core/transports/transport';\nimport Util from 'core/util';\nimport * as Collections from 'core/utils/collections';\nimport TransportHooks from 'core/transports/transport_hooks';\nimport TransportsTable from 'core/transports/transports_table';\nimport Runtime from 'runtime';\n\n/** WebSocket transport.\n *\n * Uses native WebSocket implementation, including MozWebSocket supported by\n * earlier Firefox versions.\n */\nvar WSTransport = new Transport({\n urls: URLSchemes.ws,\n handlesActivityChecks: false,\n supportsPing: false,\n\n isInitialized: function() {\n return Boolean(Runtime.getWebSocketAPI());\n },\n isSupported: function(): boolean {\n return Boolean(Runtime.getWebSocketAPI());\n },\n getSocket: function(url) {\n return Runtime.createWebSocket(url);\n }\n});\n\nvar httpConfiguration = {\n urls: URLSchemes.http,\n handlesActivityChecks: false,\n supportsPing: true,\n isInitialized: function() {\n return true;\n }\n};\n\nexport var streamingConfiguration = Collections.extend(\n {\n getSocket: function(url) {\n return Runtime.HTTPFactory.createStreamingSocket(url);\n }\n },\n httpConfiguration\n);\nexport var pollingConfiguration = Collections.extend(\n {\n getSocket: function(url) {\n return Runtime.HTTPFactory.createPollingSocket(url);\n }\n },\n httpConfiguration\n);\n\nvar xhrConfiguration = {\n isSupported: function(): boolean {\n return Runtime.isXHRSupported();\n }\n};\n\n/** HTTP streaming transport using CORS-enabled XMLHttpRequest. */\nvar XHRStreamingTransport = new Transport(\n (\n Collections.extend({}, streamingConfiguration, xhrConfiguration)\n )\n);\n\n/** HTTP long-polling transport using CORS-enabled XMLHttpRequest. */\nvar XHRPollingTransport = new Transport(\n Collections.extend({}, pollingConfiguration, xhrConfiguration)\n);\n\nvar Transports: TransportsTable = {\n ws: WSTransport,\n xhr_streaming: XHRStreamingTransport,\n xhr_polling: XHRPollingTransport\n};\n\nexport default Transports;\n","import Util from '../util';\nimport * as Collections from '../utils/collections';\nimport TransportManager from './transport_manager';\nimport TransportConnection from './transport_connection';\nimport Transport from './transport';\nimport PingDelayOptions from './ping_delay_options';\n\n/** Creates transport connections monitored by a transport manager.\n *\n * When a transport is closed, it might mean the environment does not support\n * it. It's possible that messages get stuck in an intermediate buffer or\n * proxies terminate inactive connections. To combat these problems,\n * assistants monitor the connection lifetime, report unclean exits and\n * adjust ping timeouts to keep the connection active. The decision to disable\n * a transport is the manager's responsibility.\n *\n * @param {TransportManager} manager\n * @param {TransportConnection} transport\n * @param {Object} options\n */\nexport default class AssistantToTheTransportManager {\n manager: TransportManager;\n transport: Transport;\n minPingDelay: number;\n maxPingDelay: number;\n pingDelay: number;\n\n constructor(\n manager: TransportManager,\n transport: Transport,\n options: PingDelayOptions\n ) {\n this.manager = manager;\n this.transport = transport;\n this.minPingDelay = options.minPingDelay;\n this.maxPingDelay = options.maxPingDelay;\n this.pingDelay = undefined;\n }\n\n /** Creates a transport connection.\n *\n * This function has the same API as Transport#createConnection.\n *\n * @param {String} name\n * @param {Number} priority\n * @param {String} key the application key\n * @param {Object} options\n * @returns {TransportConnection}\n */\n createConnection(\n name: string,\n priority: number,\n key: string,\n options: Object\n ): TransportConnection {\n options = Collections.extend({}, options, {\n activityTimeout: this.pingDelay\n });\n var connection = this.transport.createConnection(\n name,\n priority,\n key,\n options\n );\n\n var openTimestamp = null;\n\n var onOpen = function() {\n connection.unbind('open', onOpen);\n connection.bind('closed', onClosed);\n openTimestamp = Util.now();\n };\n var onClosed = closeEvent => {\n connection.unbind('closed', onClosed);\n\n if (closeEvent.code === 1002 || closeEvent.code === 1003) {\n // we don't want to use transports not obeying the protocol\n this.manager.reportDeath();\n } else if (!closeEvent.wasClean && openTimestamp) {\n // report deaths only for short-living transport\n var lifespan = Util.now() - openTimestamp;\n if (lifespan < 2 * this.maxPingDelay) {\n this.manager.reportDeath();\n this.pingDelay = Math.max(lifespan / 2, this.minPingDelay);\n }\n }\n };\n\n connection.bind('open', onOpen);\n return connection;\n }\n\n /** Returns whether the transport is supported in the environment.\n *\n * This function has the same API as Transport#isSupported. Might return false\n * when the manager decides to kill the transport.\n *\n * @param {Object} environment the environment details (encryption, settings)\n * @returns {Boolean} true when the transport is supported\n */\n isSupported(environment: string): boolean {\n return this.manager.isAlive() && this.transport.isSupported(environment);\n }\n}\n","import Action from './action';\nimport { PusherEvent } from './message-types';\n/**\n * Provides functions for handling Pusher protocol-specific messages.\n */\n\nconst Protocol = {\n /**\n * Decodes a message in a Pusher format.\n *\n * The MessageEvent we receive from the transport should contain a pusher event\n * (https://pusher.com/docs/pusher_protocol#events) serialized as JSON in the\n * data field\n *\n * The pusher event may contain a data field too, and it may also be\n * serialised as JSON\n *\n * Throws errors when messages are not parse'able.\n *\n * @param {MessageEvent} messageEvent\n * @return {PusherEvent}\n */\n decodeMessage: function(messageEvent: MessageEvent): PusherEvent {\n try {\n var messageData = JSON.parse(messageEvent.data);\n var pusherEventData = messageData.data;\n if (typeof pusherEventData === 'string') {\n try {\n pusherEventData = JSON.parse(messageData.data);\n } catch (e) {}\n }\n var pusherEvent: PusherEvent = {\n event: messageData.event,\n channel: messageData.channel,\n data: pusherEventData\n };\n if (messageData.user_id) {\n pusherEvent.user_id = messageData.user_id;\n }\n return pusherEvent;\n } catch (e) {\n throw { type: 'MessageParseError', error: e, data: messageEvent.data };\n }\n },\n\n /**\n * Encodes a message to be sent.\n *\n * @param {PusherEvent} event\n * @return {String}\n */\n encodeMessage: function(event: PusherEvent): string {\n return JSON.stringify(event);\n },\n\n /**\n * Processes a handshake message and returns appropriate actions.\n *\n * Returns an object with an 'action' and other action-specific properties.\n *\n * There are three outcomes when calling this function. First is a successful\n * connection attempt, when pusher:connection_established is received, which\n * results in a 'connected' action with an 'id' property. When passed a\n * pusher:error event, it returns a result with action appropriate to the\n * close code and an error. Otherwise, it raises an exception.\n *\n * @param {String} message\n * @result Object\n */\n processHandshake: function(messageEvent: MessageEvent): Action {\n var message = Protocol.decodeMessage(messageEvent);\n\n if (message.event === 'pusher:connection_established') {\n if (!message.data.activity_timeout) {\n throw 'No activity timeout specified in handshake';\n }\n return {\n action: 'connected',\n id: message.data.socket_id,\n activityTimeout: message.data.activity_timeout * 1000\n };\n } else if (message.event === 'pusher:error') {\n // From protocol 6 close codes are sent only once, so this only\n // happens when connection does not support close codes\n return {\n action: this.getCloseAction(message.data),\n error: this.getCloseError(message.data)\n };\n } else {\n throw 'Invalid handshake';\n }\n },\n\n /**\n * Dispatches the close event and returns an appropriate action name.\n *\n * See:\n * 1. https://developer.mozilla.org/en-US/docs/WebSockets/WebSockets_reference/CloseEvent\n * 2. http://pusher.com/docs/pusher_protocol\n *\n * @param {CloseEvent} closeEvent\n * @return {String} close action name\n */\n getCloseAction: function(closeEvent): string {\n if (closeEvent.code < 4000) {\n // ignore 1000 CLOSE_NORMAL, 1001 CLOSE_GOING_AWAY,\n // 1005 CLOSE_NO_STATUS, 1006 CLOSE_ABNORMAL\n // ignore 1007...3999\n // handle 1002 CLOSE_PROTOCOL_ERROR, 1003 CLOSE_UNSUPPORTED,\n // 1004 CLOSE_TOO_LARGE\n if (closeEvent.code >= 1002 && closeEvent.code <= 1004) {\n return 'backoff';\n } else {\n return null;\n }\n } else if (closeEvent.code === 4000) {\n return 'tls_only';\n } else if (closeEvent.code < 4100) {\n return 'refused';\n } else if (closeEvent.code < 4200) {\n return 'backoff';\n } else if (closeEvent.code < 4300) {\n return 'retry';\n } else {\n // unknown error\n return 'refused';\n }\n },\n\n /**\n * Returns an error or null basing on the close event.\n *\n * Null is returned when connection was closed cleanly. Otherwise, an object\n * with error details is returned.\n *\n * @param {CloseEvent} closeEvent\n * @return {Object} error object\n */\n getCloseError: function(closeEvent): any {\n if (closeEvent.code !== 1000 && closeEvent.code !== 1001) {\n return {\n type: 'PusherError',\n data: {\n code: closeEvent.code,\n message: closeEvent.reason || closeEvent.message\n }\n };\n } else {\n return null;\n }\n }\n};\n\nexport default Protocol;\n","import * as Collections from '../utils/collections';\nimport { default as EventsDispatcher } from '../events/dispatcher';\nimport Protocol from './protocol/protocol';\nimport { PusherEvent } from './protocol/message-types';\nimport Logger from '../logger';\nimport TransportConnection from '../transports/transport_connection';\nimport Socket from '../socket';\n/**\n * Provides Pusher protocol interface for transports.\n *\n * Emits following events:\n * - message - on received messages\n * - ping - on ping requests\n * - pong - on pong responses\n * - error - when the transport emits an error\n * - closed - after closing the transport\n *\n * It also emits more events when connection closes with a code.\n * See Protocol.getCloseAction to get more details.\n *\n * @param {Number} id\n * @param {AbstractTransport} transport\n */\nexport default class Connection extends EventsDispatcher implements Socket {\n id: string;\n transport: TransportConnection;\n activityTimeout: number;\n\n constructor(id: string, transport: TransportConnection) {\n super();\n this.id = id;\n this.transport = transport;\n this.activityTimeout = transport.activityTimeout;\n this.bindListeners();\n }\n\n /** Returns whether used transport handles activity checks by itself\n *\n * @returns {Boolean} true if activity checks are handled by the transport\n */\n handlesActivityChecks() {\n return this.transport.handlesActivityChecks();\n }\n\n /** Sends raw data.\n *\n * @param {String} data\n */\n send(data: any): boolean {\n return this.transport.send(data);\n }\n\n /** Sends an event.\n *\n * @param {String} name\n * @param {String} data\n * @param {String} [channel]\n * @returns {Boolean} whether message was sent or not\n */\n send_event(name: string, data: any, channel?: string): boolean {\n var event: PusherEvent = { event: name, data: data };\n if (channel) {\n event.channel = channel;\n }\n Logger.debug('Event sent', event);\n return this.send(Protocol.encodeMessage(event));\n }\n\n /** Sends a ping message to the server.\n *\n * Basing on the underlying transport, it might send either transport's\n * protocol-specific ping or pusher:ping event.\n */\n ping() {\n if (this.transport.supportsPing()) {\n this.transport.ping();\n } else {\n this.send_event('pusher:ping', {});\n }\n }\n\n /** Closes the connection. */\n close() {\n this.transport.close();\n }\n\n private bindListeners() {\n var listeners = {\n message: (messageEvent: MessageEvent) => {\n var pusherEvent;\n try {\n pusherEvent = Protocol.decodeMessage(messageEvent);\n } catch (e) {\n this.emit('error', {\n type: 'MessageParseError',\n error: e,\n data: messageEvent.data\n });\n }\n\n if (pusherEvent !== undefined) {\n Logger.debug('Event recd', pusherEvent);\n\n switch (pusherEvent.event) {\n case 'pusher:error':\n this.emit('error', {\n type: 'PusherError',\n data: pusherEvent.data\n });\n break;\n case 'pusher:ping':\n this.emit('ping');\n break;\n case 'pusher:pong':\n this.emit('pong');\n break;\n }\n this.emit('message', pusherEvent);\n }\n },\n activity: () => {\n this.emit('activity');\n },\n error: error => {\n this.emit('error', error);\n },\n closed: closeEvent => {\n unbindListeners();\n\n if (closeEvent && closeEvent.code) {\n this.handleCloseEvent(closeEvent);\n }\n\n this.transport = null;\n this.emit('closed');\n }\n };\n\n var unbindListeners = () => {\n Collections.objectApply(listeners, (listener, event) => {\n this.transport.unbind(event, listener);\n });\n };\n\n Collections.objectApply(listeners, (listener, event) => {\n this.transport.bind(event, listener);\n });\n }\n\n private handleCloseEvent(closeEvent: any) {\n var action = Protocol.getCloseAction(closeEvent);\n var error = Protocol.getCloseError(closeEvent);\n if (error) {\n this.emit('error', error);\n }\n if (action) {\n this.emit(action, { action: action, error: error });\n }\n }\n}\n","import Util from '../../util';\nimport * as Collections from '../../utils/collections';\nimport Protocol from '../protocol/protocol';\nimport Connection from '../connection';\nimport TransportConnection from '../../transports/transport_connection';\nimport HandshakePayload from './handshake_payload';\n\n/**\n * Handles Pusher protocol handshakes for transports.\n *\n * Calls back with a result object after handshake is completed. Results\n * always have two fields:\n * - action - string describing action to be taken after the handshake\n * - transport - the transport object passed to the constructor\n *\n * Different actions can set different additional properties on the result.\n * In the case of 'connected' action, there will be a 'connection' property\n * containing a Connection object for the transport. Other actions should\n * carry an 'error' property.\n *\n * @param {AbstractTransport} transport\n * @param {Function} callback\n */\nexport default class Handshake {\n transport: TransportConnection;\n callback: (HandshakePayload) => void;\n onMessage: Function;\n onClosed: Function;\n\n constructor(\n transport: TransportConnection,\n callback: (HandshakePayload) => void\n ) {\n this.transport = transport;\n this.callback = callback;\n this.bindListeners();\n }\n\n close() {\n this.unbindListeners();\n this.transport.close();\n }\n\n private bindListeners() {\n this.onMessage = m => {\n this.unbindListeners();\n\n var result;\n try {\n result = Protocol.processHandshake(m);\n } catch (e) {\n this.finish('error', { error: e });\n this.transport.close();\n return;\n }\n\n if (result.action === 'connected') {\n this.finish('connected', {\n connection: new Connection(result.id, this.transport),\n activityTimeout: result.activityTimeout\n });\n } else {\n this.finish(result.action, { error: result.error });\n this.transport.close();\n }\n };\n\n this.onClosed = closeEvent => {\n this.unbindListeners();\n\n var action = Protocol.getCloseAction(closeEvent) || 'backoff';\n var error = Protocol.getCloseError(closeEvent);\n this.finish(action, { error: error });\n };\n\n this.transport.bind('message', this.onMessage);\n this.transport.bind('closed', this.onClosed);\n }\n\n private unbindListeners() {\n this.transport.unbind('message', this.onMessage);\n this.transport.unbind('closed', this.onClosed);\n }\n\n private finish(action: string, params: any) {\n this.callback(\n Collections.extend({ transport: this.transport, action: action }, params)\n );\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport base64encode from '../base64';\nimport Timeline from './timeline';\nimport Runtime from 'runtime';\n\nexport interface TimelineSenderOptions {\n host?: string;\n port?: number;\n path?: string;\n}\n\nexport default class TimelineSender {\n timeline: Timeline;\n options: TimelineSenderOptions;\n host: string;\n\n constructor(timeline: Timeline, options: TimelineSenderOptions) {\n this.timeline = timeline;\n this.options = options || {};\n }\n\n send(useTLS: boolean, callback?: Function) {\n if (this.timeline.isEmpty()) {\n return;\n }\n\n this.timeline.send(\n Runtime.TimelineTransport.getAgent(this, useTLS),\n callback\n );\n }\n}\n","/** Error classes used throughout the library. */\n// https://github.com/Microsoft/TypeScript-wiki/blob/master/Breaking-Changes.md#extending-built-ins-like-error-array-and-map-may-no-longer-work\nexport class BadEventName extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\nexport class BadChannelName extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\nexport class RequestTimedOut extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class TransportPriorityTooLow extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class TransportClosed extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class UnsupportedFeature extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class UnsupportedTransport extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class UnsupportedStrategy extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class HTTPAuthError extends Error {\n status: number;\n constructor(status: number, msg?: string) {\n super(msg);\n this.status = status;\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n","/**\n * A place to store help URLs for error messages etc\n */\n\nconst urlStore = {\n baseUrl: 'https://pusher.com',\n urls: {\n authenticationEndpoint: {\n path: '/docs/channels/server_api/authenticating_users'\n },\n authorizationEndpoint: {\n path: '/docs/channels/server_api/authorizing-users/'\n },\n javascriptQuickStart: {\n path: '/docs/javascript_quick_start'\n },\n triggeringClientEvents: {\n path: '/docs/client_api_guide/client_events#trigger-events'\n },\n encryptedChannelSupport: {\n fullUrl:\n 'https://github.com/pusher/pusher-js/tree/cc491015371a4bde5743d1c87a0fbac0feb53195#encrypted-channel-support'\n }\n }\n};\n\n/** Builds a consistent string with links to pusher documentation\n *\n * @param {string} key - relevant key in the url_store.urls object\n * @return {string} suffix string to append to log message\n */\nconst buildLogSuffix = function(key: string): string {\n const urlPrefix = 'See:';\n const urlObj = urlStore.urls[key];\n if (!urlObj) return '';\n\n let url;\n if (urlObj.fullUrl) {\n url = urlObj.fullUrl;\n } else if (urlObj.path) {\n url = urlStore.baseUrl + urlObj.path;\n }\n\n if (!url) return '';\n return `${urlPrefix} ${url}`;\n};\n\nexport default { buildLogSuffix };\n","import { default as EventsDispatcher } from '../events/dispatcher';\nimport * as Errors from '../errors';\nimport Logger from '../logger';\nimport Pusher from '../pusher';\nimport { PusherEvent } from '../connection/protocol/message-types';\nimport Metadata from './metadata';\nimport UrlStore from '../utils/url_store';\nimport {\n ChannelAuthorizationData,\n ChannelAuthorizationCallback\n} from '../auth/options';\nimport { HTTPAuthError } from '../errors';\n\n/** Provides base public channel interface with an event emitter.\n *\n * Emits:\n * - pusher:subscription_succeeded - after subscribing successfully\n * - other non-internal events\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\nexport default class Channel extends EventsDispatcher {\n name: string;\n pusher: Pusher;\n subscribed: boolean;\n subscriptionPending: boolean;\n subscriptionCancelled: boolean;\n subscriptionCount: null;\n\n constructor(name: string, pusher: Pusher) {\n super(function(event, data) {\n Logger.debug('No callbacks on ' + name + ' for ' + event);\n });\n\n this.name = name;\n this.pusher = pusher;\n this.subscribed = false;\n this.subscriptionPending = false;\n this.subscriptionCancelled = false;\n }\n\n /** Skips authorization, since public channels don't require it.\n *\n * @param {Function} callback\n */\n authorize(socketId: string, callback: ChannelAuthorizationCallback) {\n return callback(null, { auth: '' });\n }\n\n /** Triggers an event */\n trigger(event: string, data: any) {\n if (event.indexOf('client-') !== 0) {\n throw new Errors.BadEventName(\n \"Event '\" + event + \"' does not start with 'client-'\"\n );\n }\n if (!this.subscribed) {\n var suffix = UrlStore.buildLogSuffix('triggeringClientEvents');\n Logger.warn(\n `Client event triggered before channel 'subscription_succeeded' event . ${suffix}`\n );\n }\n return this.pusher.send_event(event, data, this.name);\n }\n\n /** Signals disconnection to the channel. For internal use only. */\n disconnect() {\n this.subscribed = false;\n this.subscriptionPending = false;\n }\n\n /** Handles a PusherEvent. For internal use only.\n *\n * @param {PusherEvent} event\n */\n handleEvent(event: PusherEvent) {\n var eventName = event.event;\n var data = event.data;\n if (eventName === 'pusher_internal:subscription_succeeded') {\n this.handleSubscriptionSucceededEvent(event);\n } else if (eventName === 'pusher_internal:subscription_count') {\n this.handleSubscriptionCountEvent(event);\n } else if (eventName.indexOf('pusher_internal:') !== 0) {\n var metadata: Metadata = {};\n this.emit(eventName, data, metadata);\n }\n }\n\n handleSubscriptionSucceededEvent(event: PusherEvent) {\n this.subscriptionPending = false;\n this.subscribed = true;\n if (this.subscriptionCancelled) {\n this.pusher.unsubscribe(this.name);\n } else {\n this.emit('pusher:subscription_succeeded', event.data);\n }\n }\n\n handleSubscriptionCountEvent(event: PusherEvent) {\n if (event.data.subscription_count) {\n this.subscriptionCount = event.data.subscription_count;\n }\n\n this.emit('pusher:subscription_count', event.data);\n }\n\n /** Sends a subscription request. For internal use only. */\n subscribe() {\n if (this.subscribed) {\n return;\n }\n this.subscriptionPending = true;\n this.subscriptionCancelled = false;\n this.authorize(\n this.pusher.connection.socket_id,\n (error: Error | null, data: ChannelAuthorizationData) => {\n if (error) {\n this.subscriptionPending = false;\n // Why not bind to 'pusher:subscription_error' a level up, and log there?\n // Binding to this event would cause the warning about no callbacks being\n // bound (see constructor) to be suppressed, that's not what we want.\n Logger.error(error.toString());\n this.emit(\n 'pusher:subscription_error',\n Object.assign(\n {},\n {\n type: 'AuthError',\n error: error.message\n },\n error instanceof HTTPAuthError ? { status: error.status } : {}\n )\n );\n } else {\n this.pusher.send_event('pusher:subscribe', {\n auth: data.auth,\n channel_data: data.channel_data,\n channel: this.name\n });\n }\n }\n );\n }\n\n /** Sends an unsubscription request. For internal use only. */\n unsubscribe() {\n this.subscribed = false;\n this.pusher.send_event('pusher:unsubscribe', {\n channel: this.name\n });\n }\n\n /** Cancels an in progress subscription. For internal use only. */\n cancelSubscription() {\n this.subscriptionCancelled = true;\n }\n\n /** Reinstates an in progress subscripiton. For internal use only. */\n reinstateSubscription() {\n this.subscriptionCancelled = false;\n }\n}\n","import Factory from '../utils/factory';\nimport Channel from './channel';\nimport { ChannelAuthorizationCallback } from '../auth/options';\n\n/** Extends public channels to provide private channel interface.\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\nexport default class PrivateChannel extends Channel {\n /** Authorizes the connection to use the channel.\n *\n * @param {String} socketId\n * @param {Function} callback\n */\n authorize(socketId: string, callback: ChannelAuthorizationCallback) {\n return this.pusher.config.channelAuthorizer(\n {\n channelName: this.name,\n socketId: socketId\n },\n callback\n );\n }\n}\n","import * as Collections from '../utils/collections';\n\n/** Represents a collection of members of a presence channel. */\nexport default class Members {\n members: any;\n count: number;\n myID: any;\n me: any;\n\n constructor() {\n this.reset();\n }\n\n /** Returns member's info for given id.\n *\n * Resulting object containts two fields - id and info.\n *\n * @param {Number} id\n * @return {Object} member's info or null\n */\n get(id: string): any {\n if (Object.prototype.hasOwnProperty.call(this.members, id)) {\n return {\n id: id,\n info: this.members[id]\n };\n } else {\n return null;\n }\n }\n\n /** Calls back for each member in unspecified order.\n *\n * @param {Function} callback\n */\n each(callback: Function) {\n Collections.objectApply(this.members, (member, id) => {\n callback(this.get(id));\n });\n }\n\n /** Updates the id for connected member. For internal use only. */\n setMyID(id: string) {\n this.myID = id;\n }\n\n /** Handles subscription data. For internal use only. */\n onSubscription(subscriptionData: any) {\n this.members = subscriptionData.presence.hash;\n this.count = subscriptionData.presence.count;\n this.me = this.get(this.myID);\n }\n\n /** Adds a new member to the collection. For internal use only. */\n addMember(memberData: any) {\n if (this.get(memberData.user_id) === null) {\n this.count++;\n }\n this.members[memberData.user_id] = memberData.user_info;\n return this.get(memberData.user_id);\n }\n\n /** Adds a member from the collection. For internal use only. */\n removeMember(memberData: any) {\n var member = this.get(memberData.user_id);\n if (member) {\n delete this.members[memberData.user_id];\n this.count--;\n }\n return member;\n }\n\n /** Resets the collection to the initial state. For internal use only. */\n reset() {\n this.members = {};\n this.count = 0;\n this.myID = null;\n this.me = null;\n }\n}\n","import PrivateChannel from './private_channel';\nimport Logger from '../logger';\nimport Members from './members';\nimport Pusher from '../pusher';\nimport UrlStore from 'core/utils/url_store';\nimport { PusherEvent } from '../connection/protocol/message-types';\nimport Metadata from './metadata';\nimport { ChannelAuthorizationData } from '../auth/options';\n\nexport default class PresenceChannel extends PrivateChannel {\n members: Members;\n\n /** Adds presence channel functionality to private channels.\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\n constructor(name: string, pusher: Pusher) {\n super(name, pusher);\n this.members = new Members();\n }\n\n /** Authorizes the connection as a member of the channel.\n *\n * @param {String} socketId\n * @param {Function} callback\n */\n authorize(socketId: string, callback: Function) {\n super.authorize(socketId, async (error, authData) => {\n if (!error) {\n authData = authData as ChannelAuthorizationData;\n if (authData.channel_data != null) {\n var channelData = JSON.parse(authData.channel_data);\n this.members.setMyID(channelData.user_id);\n } else {\n await this.pusher.user.signinDonePromise;\n if (this.pusher.user.user_data != null) {\n // If the user is signed in, get the id of the authenticated user\n // and allow the presence authorization to continue.\n this.members.setMyID(this.pusher.user.user_data.id);\n } else {\n let suffix = UrlStore.buildLogSuffix('authorizationEndpoint');\n Logger.error(\n `Invalid auth response for channel '${this.name}', ` +\n `expected 'channel_data' field. ${suffix}, ` +\n `or the user should be signed in.`\n );\n callback('Invalid auth response');\n return;\n }\n }\n }\n callback(error, authData);\n });\n }\n\n /** Handles presence and subscription events. For internal use only.\n *\n * @param {PusherEvent} event\n */\n handleEvent(event: PusherEvent) {\n var eventName = event.event;\n if (eventName.indexOf('pusher_internal:') === 0) {\n this.handleInternalEvent(event);\n } else {\n var data = event.data;\n var metadata: Metadata = {};\n if (event.user_id) {\n metadata.user_id = event.user_id;\n }\n this.emit(eventName, data, metadata);\n }\n }\n handleInternalEvent(event: PusherEvent) {\n var eventName = event.event;\n var data = event.data;\n switch (eventName) {\n case 'pusher_internal:subscription_succeeded':\n this.handleSubscriptionSucceededEvent(event);\n break;\n case 'pusher_internal:subscription_count':\n this.handleSubscriptionCountEvent(event);\n break;\n case 'pusher_internal:member_added':\n var addedMember = this.members.addMember(data);\n this.emit('pusher:member_added', addedMember);\n break;\n case 'pusher_internal:member_removed':\n var removedMember = this.members.removeMember(data);\n if (removedMember) {\n this.emit('pusher:member_removed', removedMember);\n }\n break;\n }\n }\n\n handleSubscriptionSucceededEvent(event: PusherEvent) {\n this.subscriptionPending = false;\n this.subscribed = true;\n if (this.subscriptionCancelled) {\n this.pusher.unsubscribe(this.name);\n } else {\n this.members.onSubscription(event.data);\n this.emit('pusher:subscription_succeeded', this.members);\n }\n }\n\n /** Resets the channel state, including members map. For internal use only. */\n disconnect() {\n this.members.reset();\n super.disconnect();\n }\n}\n","import PrivateChannel from './private_channel';\nimport * as Errors from '../errors';\nimport Logger from '../logger';\nimport Pusher from '../pusher';\nimport { decode as encodeUTF8 } from '@stablelib/utf8';\nimport { decode as decodeBase64 } from '@stablelib/base64';\nimport Dispatcher from '../events/dispatcher';\nimport { PusherEvent } from '../connection/protocol/message-types';\nimport {\n ChannelAuthorizationData,\n ChannelAuthorizationCallback\n} from '../auth/options';\nimport * as nacl from 'tweetnacl';\n\n/** Extends private channels to provide encrypted channel interface.\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\nexport default class EncryptedChannel extends PrivateChannel {\n key: Uint8Array = null;\n nacl: nacl;\n\n constructor(name: string, pusher: Pusher, nacl: nacl) {\n super(name, pusher);\n this.nacl = nacl;\n }\n\n /** Authorizes the connection to use the channel.\n *\n * @param {String} socketId\n * @param {Function} callback\n */\n authorize(socketId: string, callback: ChannelAuthorizationCallback) {\n super.authorize(\n socketId,\n (error: Error | null, authData: ChannelAuthorizationData) => {\n if (error) {\n callback(error, authData);\n return;\n }\n let sharedSecret = authData['shared_secret'];\n if (!sharedSecret) {\n callback(\n new Error(\n `No shared_secret key in auth payload for encrypted channel: ${this.name}`\n ),\n null\n );\n return;\n }\n this.key = decodeBase64(sharedSecret);\n delete authData['shared_secret'];\n callback(null, authData);\n }\n );\n }\n\n trigger(event: string, data: any): boolean {\n throw new Errors.UnsupportedFeature(\n 'Client events are not currently supported for encrypted channels'\n );\n }\n\n /** Handles an event. For internal use only.\n *\n * @param {PusherEvent} event\n */\n handleEvent(event: PusherEvent) {\n var eventName = event.event;\n var data = event.data;\n if (\n eventName.indexOf('pusher_internal:') === 0 ||\n eventName.indexOf('pusher:') === 0\n ) {\n super.handleEvent(event);\n return;\n }\n this.handleEncryptedEvent(eventName, data);\n }\n\n private handleEncryptedEvent(event: string, data: any): void {\n if (!this.key) {\n Logger.debug(\n 'Received encrypted event before key has been retrieved from the authEndpoint'\n );\n return;\n }\n if (!data.ciphertext || !data.nonce) {\n Logger.error(\n 'Unexpected format for encrypted event, expected object with `ciphertext` and `nonce` fields, got: ' +\n data\n );\n return;\n }\n let cipherText = decodeBase64(data.ciphertext);\n if (cipherText.length < this.nacl.secretbox.overheadLength) {\n Logger.error(\n `Expected encrypted event ciphertext length to be ${this.nacl.secretbox.overheadLength}, got: ${cipherText.length}`\n );\n return;\n }\n let nonce = decodeBase64(data.nonce);\n if (nonce.length < this.nacl.secretbox.nonceLength) {\n Logger.error(\n `Expected encrypted event nonce length to be ${this.nacl.secretbox.nonceLength}, got: ${nonce.length}`\n );\n return;\n }\n\n let bytes = this.nacl.secretbox.open(cipherText, nonce, this.key);\n if (bytes === null) {\n Logger.debug(\n 'Failed to decrypt an event, probably because it was encrypted with a different key. Fetching a new key from the authEndpoint...'\n );\n // Try a single time to retrieve a new auth key and decrypt the event with it\n // If this fails, a new key will be requested when a new message is received\n this.authorize(this.pusher.connection.socket_id, (error, authData) => {\n if (error) {\n Logger.error(\n `Failed to make a request to the authEndpoint: ${authData}. Unable to fetch new key, so dropping encrypted event`\n );\n return;\n }\n bytes = this.nacl.secretbox.open(cipherText, nonce, this.key);\n if (bytes === null) {\n Logger.error(\n `Failed to decrypt event with new key. Dropping encrypted event`\n );\n return;\n }\n this.emit(event, this.getDataToEmit(bytes));\n return;\n });\n return;\n }\n this.emit(event, this.getDataToEmit(bytes));\n }\n\n // Try and parse the decrypted bytes as JSON. If we can't parse it, just\n // return the utf-8 string\n getDataToEmit(bytes: Uint8Array): string {\n let raw = encodeUTF8(bytes);\n try {\n return JSON.parse(raw);\n } catch {\n return raw;\n }\n }\n}\n","import { default as EventsDispatcher } from '../events/dispatcher';\nimport { OneOffTimer as Timer } from '../utils/timers';\nimport { Config } from '../config';\nimport Logger from '../logger';\nimport HandshakePayload from './handshake/handshake_payload';\nimport Connection from './connection';\nimport Strategy from '../strategies/strategy';\nimport StrategyRunner from '../strategies/strategy_runner';\nimport * as Collections from '../utils/collections';\nimport Timeline from '../timeline/timeline';\nimport ConnectionManagerOptions from './connection_manager_options';\nimport Runtime from 'runtime';\n\nimport {\n ErrorCallbacks,\n HandshakeCallbacks,\n ConnectionCallbacks\n} from './callbacks';\nimport Action from './protocol/action';\n\n/** Manages connection to Pusher.\n *\n * Uses a strategy (currently only default), timers and network availability\n * info to establish a connection and export its state. In case of failures,\n * manages reconnection attempts.\n *\n * Exports state changes as following events:\n * - \"state_change\", { previous: p, current: state }\n * - state\n *\n * States:\n * - initialized - initial state, never transitioned to\n * - connecting - connection is being established\n * - connected - connection has been fully established\n * - disconnected - on requested disconnection\n * - unavailable - after connection timeout or when there's no network\n * - failed - when the connection strategy is not supported\n *\n * Options:\n * - unavailableTimeout - time to transition to unavailable state\n * - activityTimeout - time after which ping message should be sent\n * - pongTimeout - time for Pusher to respond with pong before reconnecting\n *\n * @param {String} key application key\n * @param {Object} options\n */\nexport default class ConnectionManager extends EventsDispatcher {\n key: string;\n options: ConnectionManagerOptions;\n state: string;\n connection: Connection;\n usingTLS: boolean;\n timeline: Timeline;\n socket_id: string;\n unavailableTimer: Timer;\n activityTimer: Timer;\n retryTimer: Timer;\n activityTimeout: number;\n strategy: Strategy;\n runner: StrategyRunner;\n errorCallbacks: ErrorCallbacks;\n handshakeCallbacks: HandshakeCallbacks;\n connectionCallbacks: ConnectionCallbacks;\n\n constructor(key: string, options: ConnectionManagerOptions) {\n super();\n this.state = 'initialized';\n this.connection = null;\n\n this.key = key;\n this.options = options;\n this.timeline = this.options.timeline;\n this.usingTLS = this.options.useTLS;\n\n this.errorCallbacks = this.buildErrorCallbacks();\n this.connectionCallbacks = this.buildConnectionCallbacks(\n this.errorCallbacks\n );\n this.handshakeCallbacks = this.buildHandshakeCallbacks(this.errorCallbacks);\n\n var Network = Runtime.getNetwork();\n\n Network.bind('online', () => {\n this.timeline.info({ netinfo: 'online' });\n if (this.state === 'connecting' || this.state === 'unavailable') {\n this.retryIn(0);\n }\n });\n Network.bind('offline', () => {\n this.timeline.info({ netinfo: 'offline' });\n if (this.connection) {\n this.sendActivityCheck();\n }\n });\n\n this.updateStrategy();\n }\n\n switchCluster(key: string) {\n this.key = key;\n // This ensures that the new config coming from\n // pusher instance are taken into account\n // such as appKey and cluster\n this.updateStrategy();\n this.retryIn(0);\n }\n\n /** Establishes a connection to Pusher.\n *\n * Does nothing when connection is already established. See top-level doc\n * to find events emitted on connection attempts.\n */\n connect() {\n if (this.connection || this.runner) {\n return;\n }\n if (!this.strategy.isSupported()) {\n this.updateState('failed');\n return;\n }\n this.updateState('connecting');\n this.startConnecting();\n this.setUnavailableTimer();\n }\n\n /** Sends raw data.\n *\n * @param {String} data\n */\n send(data) {\n if (this.connection) {\n return this.connection.send(data);\n } else {\n return false;\n }\n }\n\n /** Sends an event.\n *\n * @param {String} name\n * @param {String} data\n * @param {String} [channel]\n * @returns {Boolean} whether message was sent or not\n */\n send_event(name: string, data: any, channel?: string) {\n if (this.connection) {\n return this.connection.send_event(name, data, channel);\n } else {\n return false;\n }\n }\n\n /** Closes the connection. */\n disconnect() {\n this.disconnectInternally();\n this.updateState('disconnected');\n }\n\n isUsingTLS() {\n return this.usingTLS;\n }\n\n private startConnecting() {\n var callback = (error, handshake) => {\n if (error) {\n this.runner = this.strategy.connect(0, callback);\n } else {\n if (handshake.action === 'error') {\n this.emit('error', {\n type: 'HandshakeError',\n error: handshake.error\n });\n this.timeline.error({ handshakeError: handshake.error });\n } else {\n this.abortConnecting(); // we don't support switching connections yet\n this.handshakeCallbacks[handshake.action](handshake);\n }\n }\n };\n this.runner = this.strategy.connect(0, callback);\n }\n\n private abortConnecting() {\n if (this.runner) {\n this.runner.abort();\n this.runner = null;\n }\n }\n\n private disconnectInternally() {\n this.abortConnecting();\n this.clearRetryTimer();\n this.clearUnavailableTimer();\n if (this.connection) {\n var connection = this.abandonConnection();\n connection.close();\n }\n }\n\n private updateStrategy() {\n this.strategy = this.options.getStrategy({\n key: this.key,\n timeline: this.timeline,\n useTLS: this.usingTLS\n });\n }\n\n private retryIn(delay) {\n this.timeline.info({ action: 'retry', delay: delay });\n if (delay > 0) {\n this.emit('connecting_in', Math.round(delay / 1000));\n }\n this.retryTimer = new Timer(delay || 0, () => {\n this.disconnectInternally();\n this.connect();\n });\n }\n\n private clearRetryTimer() {\n if (this.retryTimer) {\n this.retryTimer.ensureAborted();\n this.retryTimer = null;\n }\n }\n\n private setUnavailableTimer() {\n this.unavailableTimer = new Timer(this.options.unavailableTimeout, () => {\n this.updateState('unavailable');\n });\n }\n\n private clearUnavailableTimer() {\n if (this.unavailableTimer) {\n this.unavailableTimer.ensureAborted();\n }\n }\n\n private sendActivityCheck() {\n this.stopActivityCheck();\n this.connection.ping();\n // wait for pong response\n this.activityTimer = new Timer(this.options.pongTimeout, () => {\n this.timeline.error({ pong_timed_out: this.options.pongTimeout });\n this.retryIn(0);\n });\n }\n\n private resetActivityCheck() {\n this.stopActivityCheck();\n // send ping after inactivity\n if (this.connection && !this.connection.handlesActivityChecks()) {\n this.activityTimer = new Timer(this.activityTimeout, () => {\n this.sendActivityCheck();\n });\n }\n }\n\n private stopActivityCheck() {\n if (this.activityTimer) {\n this.activityTimer.ensureAborted();\n }\n }\n\n private buildConnectionCallbacks(\n errorCallbacks: ErrorCallbacks\n ): ConnectionCallbacks {\n return Collections.extend({}, errorCallbacks, {\n message: message => {\n // includes pong messages from server\n this.resetActivityCheck();\n this.emit('message', message);\n },\n ping: () => {\n this.send_event('pusher:pong', {});\n },\n activity: () => {\n this.resetActivityCheck();\n },\n error: error => {\n // just emit error to user - socket will already be closed by browser\n this.emit('error', error);\n },\n closed: () => {\n this.abandonConnection();\n if (this.shouldRetry()) {\n this.retryIn(1000);\n }\n }\n });\n }\n\n private buildHandshakeCallbacks(\n errorCallbacks: ErrorCallbacks\n ): HandshakeCallbacks {\n return Collections.extend({}, errorCallbacks, {\n connected: (handshake: HandshakePayload) => {\n this.activityTimeout = Math.min(\n this.options.activityTimeout,\n handshake.activityTimeout,\n handshake.connection.activityTimeout || Infinity\n );\n this.clearUnavailableTimer();\n this.setConnection(handshake.connection);\n this.socket_id = this.connection.id;\n this.updateState('connected', { socket_id: this.socket_id });\n }\n });\n }\n\n private buildErrorCallbacks(): ErrorCallbacks {\n let withErrorEmitted = callback => {\n return (result: Action | HandshakePayload) => {\n if (result.error) {\n this.emit('error', { type: 'WebSocketError', error: result.error });\n }\n callback(result);\n };\n };\n\n return {\n tls_only: withErrorEmitted(() => {\n this.usingTLS = true;\n this.updateStrategy();\n this.retryIn(0);\n }),\n refused: withErrorEmitted(() => {\n this.disconnect();\n }),\n backoff: withErrorEmitted(() => {\n this.retryIn(1000);\n }),\n retry: withErrorEmitted(() => {\n this.retryIn(0);\n })\n };\n }\n\n private setConnection(connection) {\n this.connection = connection;\n for (var event in this.connectionCallbacks) {\n this.connection.bind(event, this.connectionCallbacks[event]);\n }\n this.resetActivityCheck();\n }\n\n private abandonConnection() {\n if (!this.connection) {\n return;\n }\n this.stopActivityCheck();\n for (var event in this.connectionCallbacks) {\n this.connection.unbind(event, this.connectionCallbacks[event]);\n }\n var connection = this.connection;\n this.connection = null;\n return connection;\n }\n\n private updateState(newState: string, data?: any) {\n var previousState = this.state;\n this.state = newState;\n if (previousState !== newState) {\n var newStateDescription = newState;\n if (newStateDescription === 'connected') {\n newStateDescription += ' with new socket ID ' + data.socket_id;\n }\n Logger.debug(\n 'State changed',\n previousState + ' -> ' + newStateDescription\n );\n this.timeline.info({ state: newState, params: data });\n this.emit('state_change', { previous: previousState, current: newState });\n this.emit(newState, data);\n }\n }\n\n private shouldRetry(): boolean {\n return this.state === 'connecting' || this.state === 'connected';\n }\n}\n","import Channel from './channel';\nimport * as Collections from '../utils/collections';\nimport ChannelTable from './channel_table';\nimport Factory from '../utils/factory';\nimport Pusher from '../pusher';\nimport Logger from '../logger';\nimport * as Errors from '../errors';\nimport urlStore from '../utils/url_store';\n\n/** Handles a channel map. */\nexport default class Channels {\n channels: ChannelTable;\n\n constructor() {\n this.channels = {};\n }\n\n /** Creates or retrieves an existing channel by its name.\n *\n * @param {String} name\n * @param {Pusher} pusher\n * @return {Channel}\n */\n add(name: string, pusher: Pusher) {\n if (!this.channels[name]) {\n this.channels[name] = createChannel(name, pusher);\n }\n return this.channels[name];\n }\n\n /** Returns a list of all channels\n *\n * @return {Array}\n */\n all(): Channel[] {\n return Collections.values(this.channels);\n }\n\n /** Finds a channel by its name.\n *\n * @param {String} name\n * @return {Channel} channel or null if it doesn't exist\n */\n find(name: string) {\n return this.channels[name];\n }\n\n /** Removes a channel from the map.\n *\n * @param {String} name\n */\n remove(name: string) {\n var channel = this.channels[name];\n delete this.channels[name];\n return channel;\n }\n\n /** Proxies disconnection signal to all channels. */\n disconnect() {\n Collections.objectApply(this.channels, function(channel) {\n channel.disconnect();\n });\n }\n}\n\nfunction createChannel(name: string, pusher: Pusher): Channel {\n if (name.indexOf('private-encrypted-') === 0) {\n if (pusher.config.nacl) {\n return Factory.createEncryptedChannel(name, pusher, pusher.config.nacl);\n }\n let errMsg =\n 'Tried to subscribe to a private-encrypted- channel but no nacl implementation available';\n let suffix = urlStore.buildLogSuffix('encryptedChannelSupport');\n throw new Errors.UnsupportedFeature(`${errMsg}. ${suffix}`);\n } else if (name.indexOf('private-') === 0) {\n return Factory.createPrivateChannel(name, pusher);\n } else if (name.indexOf('presence-') === 0) {\n return Factory.createPresenceChannel(name, pusher);\n } else if (name.indexOf('#') === 0) {\n throw new Errors.BadChannelName(\n 'Cannot create a channel with name \"' + name + '\".'\n );\n } else {\n return Factory.createChannel(name, pusher);\n }\n}\n","import AssistantToTheTransportManager from '../transports/assistant_to_the_transport_manager';\nimport PingDelayOptions from '../transports/ping_delay_options';\nimport Transport from '../transports/transport';\nimport TransportManager from '../transports/transport_manager';\nimport Handshake from '../connection/handshake';\nimport TransportConnection from '../transports/transport_connection';\nimport SocketHooks from '../http/socket_hooks';\nimport HTTPSocket from '../http/http_socket';\n\nimport Timeline from '../timeline/timeline';\nimport {\n default as TimelineSender,\n TimelineSenderOptions\n} from '../timeline/timeline_sender';\nimport PresenceChannel from '../channels/presence_channel';\nimport PrivateChannel from '../channels/private_channel';\nimport EncryptedChannel from '../channels/encrypted_channel';\nimport Channel from '../channels/channel';\nimport ConnectionManager from '../connection/connection_manager';\nimport ConnectionManagerOptions from '../connection/connection_manager_options';\nimport Ajax from '../http/ajax';\nimport Channels from '../channels/channels';\nimport Pusher from '../pusher';\nimport { Config } from '../config';\nimport * as nacl from 'tweetnacl';\n\nvar Factory = {\n createChannels(): Channels {\n return new Channels();\n },\n\n createConnectionManager(\n key: string,\n options: ConnectionManagerOptions\n ): ConnectionManager {\n return new ConnectionManager(key, options);\n },\n\n createChannel(name: string, pusher: Pusher): Channel {\n return new Channel(name, pusher);\n },\n\n createPrivateChannel(name: string, pusher: Pusher): PrivateChannel {\n return new PrivateChannel(name, pusher);\n },\n\n createPresenceChannel(name: string, pusher: Pusher): PresenceChannel {\n return new PresenceChannel(name, pusher);\n },\n\n createEncryptedChannel(\n name: string,\n pusher: Pusher,\n nacl: nacl\n ): EncryptedChannel {\n return new EncryptedChannel(name, pusher, nacl);\n },\n\n createTimelineSender(timeline: Timeline, options: TimelineSenderOptions) {\n return new TimelineSender(timeline, options);\n },\n\n createHandshake(\n transport: TransportConnection,\n callback: (HandshakePayload) => void\n ): Handshake {\n return new Handshake(transport, callback);\n },\n\n createAssistantToTheTransportManager(\n manager: TransportManager,\n transport: Transport,\n options: PingDelayOptions\n ): AssistantToTheTransportManager {\n return new AssistantToTheTransportManager(manager, transport, options);\n }\n};\n\nexport default Factory;\n","import AssistantToTheTransportManager from './assistant_to_the_transport_manager';\nimport Transport from './transport';\nimport PingDelayOptions from './ping_delay_options';\nimport Factory from '../utils/factory';\n\nexport interface TransportManagerOptions extends PingDelayOptions {\n lives?: number;\n}\n\n/** Keeps track of the number of lives left for a transport.\n *\n * In the beginning of a session, transports may be assigned a number of\n * lives. When an AssistantToTheTransportManager instance reports a transport\n * connection closed uncleanly, the transport loses a life. When the number\n * of lives drops to zero, the transport gets disabled by its manager.\n *\n * @param {Object} options\n */\nexport default class TransportManager {\n options: TransportManagerOptions;\n livesLeft: number;\n\n constructor(options: TransportManagerOptions) {\n this.options = options || {};\n this.livesLeft = this.options.lives || Infinity;\n }\n\n /** Creates a assistant for the transport.\n *\n * @param {Transport} transport\n * @returns {AssistantToTheTransportManager}\n */\n getAssistant(transport: Transport): AssistantToTheTransportManager {\n return Factory.createAssistantToTheTransportManager(this, transport, {\n minPingDelay: this.options.minPingDelay,\n maxPingDelay: this.options.maxPingDelay\n });\n }\n\n /** Returns whether the transport has any lives left.\n *\n * @returns {Boolean}\n */\n isAlive(): boolean {\n return this.livesLeft > 0;\n }\n\n /** Takes one life from the transport. */\n reportDeath() {\n this.livesLeft -= 1;\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport { OneOffTimer as Timer } from '../utils/timers';\nimport Strategy from './strategy';\nimport StrategyOptions from './strategy_options';\n\n/** Loops through strategies with optional timeouts.\n *\n * Options:\n * - loop - whether it should loop through the substrategy list\n * - timeout - initial timeout for a single substrategy\n * - timeoutLimit - maximum timeout\n *\n * @param {Strategy[]} strategies\n * @param {Object} options\n */\nexport default class SequentialStrategy implements Strategy {\n strategies: Strategy[];\n loop: boolean;\n failFast: boolean;\n timeout: number;\n timeoutLimit: number;\n\n constructor(strategies: Strategy[], options: StrategyOptions) {\n this.strategies = strategies;\n this.loop = Boolean(options.loop);\n this.failFast = Boolean(options.failFast);\n this.timeout = options.timeout;\n this.timeoutLimit = options.timeoutLimit;\n }\n\n isSupported(): boolean {\n return Collections.any(this.strategies, Util.method('isSupported'));\n }\n\n connect(minPriority: number, callback: Function) {\n var strategies = this.strategies;\n var current = 0;\n var timeout = this.timeout;\n var runner = null;\n\n var tryNextStrategy = (error, handshake) => {\n if (handshake) {\n callback(null, handshake);\n } else {\n current = current + 1;\n if (this.loop) {\n current = current % strategies.length;\n }\n\n if (current < strategies.length) {\n if (timeout) {\n timeout = timeout * 2;\n if (this.timeoutLimit) {\n timeout = Math.min(timeout, this.timeoutLimit);\n }\n }\n runner = this.tryStrategy(\n strategies[current],\n minPriority,\n { timeout, failFast: this.failFast },\n tryNextStrategy\n );\n } else {\n callback(true);\n }\n }\n };\n\n runner = this.tryStrategy(\n strategies[current],\n minPriority,\n { timeout: timeout, failFast: this.failFast },\n tryNextStrategy\n );\n\n return {\n abort: function() {\n runner.abort();\n },\n forceMinPriority: function(p) {\n minPriority = p;\n if (runner) {\n runner.forceMinPriority(p);\n }\n }\n };\n }\n\n private tryStrategy(\n strategy: Strategy,\n minPriority: number,\n options: StrategyOptions,\n callback: Function\n ) {\n var timer = null;\n var runner = null;\n\n if (options.timeout > 0) {\n timer = new Timer(options.timeout, function() {\n runner.abort();\n callback(true);\n });\n }\n\n runner = strategy.connect(minPriority, function(error, handshake) {\n if (error && timer && timer.isRunning() && !options.failFast) {\n // advance to the next strategy after the timeout\n return;\n }\n if (timer) {\n timer.ensureAborted();\n }\n callback(error, handshake);\n });\n\n return {\n abort: function() {\n if (timer) {\n timer.ensureAborted();\n }\n runner.abort();\n },\n forceMinPriority: function(p) {\n runner.forceMinPriority(p);\n }\n };\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport Strategy from './strategy';\n\n/** Launches all substrategies and emits prioritized connected transports.\n *\n * @param {Array} strategies\n */\nexport default class BestConnectedEverStrategy implements Strategy {\n strategies: Strategy[];\n\n constructor(strategies: Strategy[]) {\n this.strategies = strategies;\n }\n\n isSupported(): boolean {\n return Collections.any(this.strategies, Util.method('isSupported'));\n }\n\n connect(minPriority: number, callback: Function) {\n return connect(this.strategies, minPriority, function(i, runners) {\n return function(error, handshake) {\n runners[i].error = error;\n if (error) {\n if (allRunnersFailed(runners)) {\n callback(true);\n }\n return;\n }\n Collections.apply(runners, function(runner) {\n runner.forceMinPriority(handshake.transport.priority);\n });\n callback(null, handshake);\n };\n });\n }\n}\n\n/** Connects to all strategies in parallel.\n *\n * Callback builder should be a function that takes two arguments: index\n * and a list of runners. It should return another function that will be\n * passed to the substrategy with given index. Runners can be aborted using\n * abortRunner(s) functions from this class.\n *\n * @param {Array} strategies\n * @param {Function} callbackBuilder\n * @return {Object} strategy runner\n */\nfunction connect(\n strategies: Strategy[],\n minPriority: number,\n callbackBuilder: Function\n) {\n var runners = Collections.map(strategies, function(strategy, i, _, rs) {\n return strategy.connect(minPriority, callbackBuilder(i, rs));\n });\n return {\n abort: function() {\n Collections.apply(runners, abortRunner);\n },\n forceMinPriority: function(p) {\n Collections.apply(runners, function(runner) {\n runner.forceMinPriority(p);\n });\n }\n };\n}\n\nfunction allRunnersFailed(runners): boolean {\n return Collections.all(runners, function(runner) {\n return Boolean(runner.error);\n });\n}\n\nfunction abortRunner(runner) {\n if (!runner.error && !runner.aborted) {\n runner.abort();\n runner.aborted = true;\n }\n}\n","import Util from '../util';\nimport Runtime from 'runtime';\nimport Strategy from './strategy';\nimport SequentialStrategy from './sequential_strategy';\nimport StrategyOptions from './strategy_options';\nimport TransportStrategy from './transport_strategy';\nimport Timeline from '../timeline/timeline';\nimport * as Collections from '../utils/collections';\n\nexport interface TransportStrategyDictionary {\n [key: string]: TransportStrategy;\n}\n\n/** Caches the last successful transport and, after the first few attempts,\n * uses the cached transport for subsequent attempts.\n *\n * @param {Strategy} strategy\n * @param {Object} transports\n * @param {Object} options\n */\nexport default class WebSocketPrioritizedCachedStrategy implements Strategy {\n strategy: Strategy;\n transports: TransportStrategyDictionary;\n ttl: number;\n usingTLS: boolean;\n timeline: Timeline;\n\n constructor(\n strategy: Strategy,\n transports: TransportStrategyDictionary,\n options: StrategyOptions\n ) {\n this.strategy = strategy;\n this.transports = transports;\n this.ttl = options.ttl || 1800 * 1000;\n this.usingTLS = options.useTLS;\n this.timeline = options.timeline;\n }\n\n isSupported(): boolean {\n return this.strategy.isSupported();\n }\n\n connect(minPriority: number, callback: Function) {\n var usingTLS = this.usingTLS;\n var info = fetchTransportCache(usingTLS);\n var cacheSkipCount = info && info.cacheSkipCount ? info.cacheSkipCount : 0;\n\n var strategies = [this.strategy];\n if (info && info.timestamp + this.ttl >= Util.now()) {\n var transport = this.transports[info.transport];\n if (transport) {\n if (['ws', 'wss'].includes(info.transport) || cacheSkipCount > 3) {\n this.timeline.info({\n cached: true,\n transport: info.transport,\n latency: info.latency\n });\n strategies.push(\n new SequentialStrategy([transport], {\n timeout: info.latency * 2 + 1000,\n failFast: true\n })\n );\n } else {\n cacheSkipCount++;\n }\n }\n }\n\n var startTimestamp = Util.now();\n var runner = strategies\n .pop()\n .connect(minPriority, function cb(error, handshake) {\n if (error) {\n flushTransportCache(usingTLS);\n if (strategies.length > 0) {\n startTimestamp = Util.now();\n runner = strategies.pop().connect(minPriority, cb);\n } else {\n callback(error);\n }\n } else {\n storeTransportCache(\n usingTLS,\n handshake.transport.name,\n Util.now() - startTimestamp,\n cacheSkipCount\n );\n callback(null, handshake);\n }\n });\n\n return {\n abort: function() {\n runner.abort();\n },\n forceMinPriority: function(p) {\n minPriority = p;\n if (runner) {\n runner.forceMinPriority(p);\n }\n }\n };\n }\n}\n\nfunction getTransportCacheKey(usingTLS: boolean): string {\n return 'pusherTransport' + (usingTLS ? 'TLS' : 'NonTLS');\n}\n\nfunction fetchTransportCache(usingTLS: boolean): any {\n var storage = Runtime.getLocalStorage();\n if (storage) {\n try {\n var serializedCache = storage[getTransportCacheKey(usingTLS)];\n if (serializedCache) {\n return JSON.parse(serializedCache);\n }\n } catch (e) {\n flushTransportCache(usingTLS);\n }\n }\n return null;\n}\n\nfunction storeTransportCache(\n usingTLS: boolean,\n transport: TransportStrategy,\n latency: number,\n cacheSkipCount: number\n) {\n var storage = Runtime.getLocalStorage();\n if (storage) {\n try {\n storage[getTransportCacheKey(usingTLS)] = Collections.safeJSONStringify({\n timestamp: Util.now(),\n transport: transport,\n latency: latency,\n cacheSkipCount: cacheSkipCount\n });\n } catch (e) {\n // catch over quota exceptions raised by localStorage\n }\n }\n}\n\nfunction flushTransportCache(usingTLS: boolean) {\n var storage = Runtime.getLocalStorage();\n if (storage) {\n try {\n delete storage[getTransportCacheKey(usingTLS)];\n } catch (e) {\n // catch exceptions raised by localStorage\n }\n }\n}\n","import { OneOffTimer as Timer } from '../utils/timers';\nimport Strategy from './strategy';\nimport StrategyOptions from './strategy_options';\n\n/** Runs substrategy after specified delay.\n *\n * Options:\n * - delay - time in miliseconds to delay the substrategy attempt\n *\n * @param {Strategy} strategy\n * @param {Object} options\n */\nexport default class DelayedStrategy implements Strategy {\n strategy: Strategy;\n options: { delay: number };\n\n constructor(strategy: Strategy, { delay: number }) {\n this.strategy = strategy;\n this.options = { delay: number };\n }\n\n isSupported(): boolean {\n return this.strategy.isSupported();\n }\n\n connect(minPriority: number, callback: Function) {\n var strategy = this.strategy;\n var runner;\n var timer = new Timer(this.options.delay, function() {\n runner = strategy.connect(minPriority, callback);\n });\n\n return {\n abort: function() {\n timer.ensureAborted();\n if (runner) {\n runner.abort();\n }\n },\n forceMinPriority: function(p) {\n minPriority = p;\n if (runner) {\n runner.forceMinPriority(p);\n }\n }\n };\n }\n}\n","import Strategy from './strategy';\nimport StrategyRunner from './strategy_runner';\n\n/** Proxies method calls to one of substrategies basing on the test function.\n *\n * @param {Function} test\n * @param {Strategy} trueBranch strategy used when test returns true\n * @param {Strategy} falseBranch strategy used when test returns false\n */\nexport default class IfStrategy implements Strategy {\n test: () => boolean;\n trueBranch: Strategy;\n falseBranch: Strategy;\n\n constructor(\n test: () => boolean,\n trueBranch: Strategy,\n falseBranch: Strategy\n ) {\n this.test = test;\n this.trueBranch = trueBranch;\n this.falseBranch = falseBranch;\n }\n\n isSupported(): boolean {\n var branch = this.test() ? this.trueBranch : this.falseBranch;\n return branch.isSupported();\n }\n\n connect(minPriority: number, callback: Function): StrategyRunner {\n var branch = this.test() ? this.trueBranch : this.falseBranch;\n return branch.connect(minPriority, callback);\n }\n}\n","import Strategy from './strategy';\nimport StrategyRunner from './strategy_runner';\n\n/** Launches the substrategy and terminates on the first open connection.\n *\n * @param {Strategy} strategy\n */\nexport default class FirstConnectedStrategy implements Strategy {\n strategy: Strategy;\n\n constructor(strategy: Strategy) {\n this.strategy = strategy;\n }\n\n isSupported(): boolean {\n return this.strategy.isSupported();\n }\n\n connect(minPriority: number, callback: Function): StrategyRunner {\n var runner = this.strategy.connect(minPriority, function(error, handshake) {\n if (handshake) {\n runner.abort();\n }\n callback(error, handshake);\n });\n return runner;\n }\n}\n","import * as Collections from 'core/utils/collections';\nimport TransportManager from 'core/transports/transport_manager';\nimport Strategy from 'core/strategies/strategy';\nimport SequentialStrategy from 'core/strategies/sequential_strategy';\nimport BestConnectedEverStrategy from 'core/strategies/best_connected_ever_strategy';\nimport WebSocketPrioritizedCachedStrategy, {\n TransportStrategyDictionary\n} from 'core/strategies/websocket_prioritized_cached_strategy';\nimport DelayedStrategy from 'core/strategies/delayed_strategy';\nimport IfStrategy from 'core/strategies/if_strategy';\nimport FirstConnectedStrategy from 'core/strategies/first_connected_strategy';\nimport { Config } from 'core/config';\nimport StrategyOptions from 'core/strategies/strategy_options';\n\nfunction testSupportsStrategy(strategy: Strategy) {\n return function() {\n return strategy.isSupported();\n };\n}\n\nvar getDefaultStrategy = function(\n config: Config,\n baseOptions: StrategyOptions,\n defineTransport: Function\n): Strategy {\n var definedTransports = {};\n\n function defineTransportStrategy(\n name: string,\n type: string,\n priority: number,\n options: StrategyOptions,\n manager?: TransportManager\n ) {\n var transport = defineTransport(\n config,\n name,\n type,\n priority,\n options,\n manager\n );\n\n definedTransports[name] = transport;\n\n return transport;\n }\n\n var ws_options: StrategyOptions = Object.assign({}, baseOptions, {\n hostNonTLS: config.wsHost + ':' + config.wsPort,\n hostTLS: config.wsHost + ':' + config.wssPort,\n httpPath: config.wsPath\n });\n var wss_options: StrategyOptions = Collections.extend({}, ws_options, {\n useTLS: true\n });\n var http_options: StrategyOptions = Object.assign({}, baseOptions, {\n hostNonTLS: config.httpHost + ':' + config.httpPort,\n hostTLS: config.httpHost + ':' + config.httpsPort,\n httpPath: config.httpPath\n });\n var timeouts = {\n loop: true,\n timeout: 15000,\n timeoutLimit: 60000\n };\n\n var ws_manager = new TransportManager({\n minPingDelay: 10000,\n maxPingDelay: config.activityTimeout\n });\n var streaming_manager = new TransportManager({\n lives: 2,\n minPingDelay: 10000,\n maxPingDelay: config.activityTimeout\n });\n\n var ws_transport = defineTransportStrategy(\n 'ws',\n 'ws',\n 3,\n ws_options,\n ws_manager\n );\n var wss_transport = defineTransportStrategy(\n 'wss',\n 'ws',\n 3,\n wss_options,\n ws_manager\n );\n var xhr_streaming_transport = defineTransportStrategy(\n 'xhr_streaming',\n 'xhr_streaming',\n 1,\n http_options,\n streaming_manager\n );\n var xhr_polling_transport = defineTransportStrategy(\n 'xhr_polling',\n 'xhr_polling',\n 1,\n http_options\n );\n\n var ws_loop = new SequentialStrategy([ws_transport], timeouts);\n var wss_loop = new SequentialStrategy([wss_transport], timeouts);\n var streaming_loop = new SequentialStrategy(\n [xhr_streaming_transport],\n timeouts\n );\n var polling_loop = new SequentialStrategy([xhr_polling_transport], timeouts);\n\n var http_loop = new SequentialStrategy(\n [\n new IfStrategy(\n testSupportsStrategy(streaming_loop),\n new BestConnectedEverStrategy([\n streaming_loop,\n new DelayedStrategy(polling_loop, { delay: 4000 })\n ]),\n polling_loop\n )\n ],\n timeouts\n );\n\n var wsStrategy;\n if (baseOptions.useTLS) {\n wsStrategy = new BestConnectedEverStrategy([\n ws_loop,\n new DelayedStrategy(http_loop, { delay: 2000 })\n ]);\n } else {\n wsStrategy = new BestConnectedEverStrategy([\n ws_loop,\n new DelayedStrategy(wss_loop, { delay: 2000 }),\n new DelayedStrategy(http_loop, { delay: 5000 })\n ]);\n }\n\n return new WebSocketPrioritizedCachedStrategy(\n new FirstConnectedStrategy(\n new IfStrategy(testSupportsStrategy(ws_transport), wsStrategy, http_loop)\n ),\n definedTransports,\n {\n ttl: 1800000,\n timeline: baseOptions.timeline,\n useTLS: baseOptions.useTLS\n }\n );\n};\n\nexport default getDefaultStrategy;\n","import Runtime from 'runtime';\nimport RequestHooks from './request_hooks';\nimport Ajax from './ajax';\nimport { default as EventsDispatcher } from '../events/dispatcher';\n\nconst MAX_BUFFER_LENGTH = 256 * 1024;\n\nexport default class HTTPRequest extends EventsDispatcher {\n hooks: RequestHooks;\n method: string;\n url: string;\n position: number;\n xhr: Ajax;\n unloader: Function;\n\n constructor(hooks: RequestHooks, method: string, url: string) {\n super();\n this.hooks = hooks;\n this.method = method;\n this.url = url;\n }\n\n start(payload?: any) {\n this.position = 0;\n this.xhr = this.hooks.getRequest(this);\n\n this.unloader = () => {\n this.close();\n };\n Runtime.addUnloadListener(this.unloader);\n\n this.xhr.open(this.method, this.url, true);\n\n if (this.xhr.setRequestHeader) {\n this.xhr.setRequestHeader('Content-Type', 'application/json'); // ReactNative doesn't set this header by default.\n }\n this.xhr.send(payload);\n }\n\n close() {\n if (this.unloader) {\n Runtime.removeUnloadListener(this.unloader);\n this.unloader = null;\n }\n if (this.xhr) {\n this.hooks.abortRequest(this.xhr);\n this.xhr = null;\n }\n }\n\n onChunk(status: number, data: any) {\n while (true) {\n var chunk = this.advanceBuffer(data);\n if (chunk) {\n this.emit('chunk', { status: status, data: chunk });\n } else {\n break;\n }\n }\n if (this.isBufferTooLong(data)) {\n this.emit('buffer_too_long');\n }\n }\n\n private advanceBuffer(buffer: any[]): any {\n var unreadData = buffer.slice(this.position);\n var endOfLinePosition = unreadData.indexOf('\\n');\n\n if (endOfLinePosition !== -1) {\n this.position += endOfLinePosition + 1;\n return unreadData.slice(0, endOfLinePosition);\n } else {\n // chunk is not finished yet, don't move the buffer pointer\n return null;\n }\n }\n\n private isBufferTooLong(buffer: any): boolean {\n return this.position === buffer.length && buffer.length > MAX_BUFFER_LENGTH;\n }\n}\n","enum State {\n CONNECTING = 0,\n OPEN = 1,\n CLOSED = 3\n}\n\nexport default State;\n","import URLLocation from './url_location';\nimport State from './state';\nimport Socket from '../socket';\nimport SocketHooks from './socket_hooks';\nimport Util from '../util';\nimport Ajax from './ajax';\nimport HTTPRequest from './http_request';\nimport Runtime from 'runtime';\n\nvar autoIncrement = 1;\n\nclass HTTPSocket implements Socket {\n hooks: SocketHooks;\n session: string;\n location: URLLocation;\n readyState: State;\n stream: HTTPRequest;\n\n onopen: () => void;\n onerror: (error: any) => void;\n onclose: (closeEvent: any) => void;\n onmessage: (message: any) => void;\n onactivity: () => void;\n\n constructor(hooks: SocketHooks, url: string) {\n this.hooks = hooks;\n this.session = randomNumber(1000) + '/' + randomString(8);\n this.location = getLocation(url);\n this.readyState = State.CONNECTING;\n this.openStream();\n }\n\n send(payload: any) {\n return this.sendRaw(JSON.stringify([payload]));\n }\n\n ping() {\n this.hooks.sendHeartbeat(this);\n }\n\n close(code: any, reason: any) {\n this.onClose(code, reason, true);\n }\n\n /** For internal use only */\n sendRaw(payload: any): boolean {\n if (this.readyState === State.OPEN) {\n try {\n Runtime.createSocketRequest(\n 'POST',\n getUniqueURL(getSendURL(this.location, this.session))\n ).start(payload);\n return true;\n } catch (e) {\n return false;\n }\n } else {\n return false;\n }\n }\n\n /** For internal use only */\n reconnect() {\n this.closeStream();\n this.openStream();\n }\n\n /** For internal use only */\n onClose(code, reason, wasClean) {\n this.closeStream();\n this.readyState = State.CLOSED;\n if (this.onclose) {\n this.onclose({\n code: code,\n reason: reason,\n wasClean: wasClean\n });\n }\n }\n\n private onChunk(chunk) {\n if (chunk.status !== 200) {\n return;\n }\n if (this.readyState === State.OPEN) {\n this.onActivity();\n }\n\n var payload;\n var type = chunk.data.slice(0, 1);\n switch (type) {\n case 'o':\n payload = JSON.parse(chunk.data.slice(1) || '{}');\n this.onOpen(payload);\n break;\n case 'a':\n payload = JSON.parse(chunk.data.slice(1) || '[]');\n for (var i = 0; i < payload.length; i++) {\n this.onEvent(payload[i]);\n }\n break;\n case 'm':\n payload = JSON.parse(chunk.data.slice(1) || 'null');\n this.onEvent(payload);\n break;\n case 'h':\n this.hooks.onHeartbeat(this);\n break;\n case 'c':\n payload = JSON.parse(chunk.data.slice(1) || '[]');\n this.onClose(payload[0], payload[1], true);\n break;\n }\n }\n\n private onOpen(options) {\n if (this.readyState === State.CONNECTING) {\n if (options && options.hostname) {\n this.location.base = replaceHost(this.location.base, options.hostname);\n }\n this.readyState = State.OPEN;\n\n if (this.onopen) {\n this.onopen();\n }\n } else {\n this.onClose(1006, 'Server lost session', true);\n }\n }\n\n private onEvent(event) {\n if (this.readyState === State.OPEN && this.onmessage) {\n this.onmessage({ data: event });\n }\n }\n\n private onActivity() {\n if (this.onactivity) {\n this.onactivity();\n }\n }\n\n private onError(error) {\n if (this.onerror) {\n this.onerror(error);\n }\n }\n\n private openStream() {\n this.stream = Runtime.createSocketRequest(\n 'POST',\n getUniqueURL(this.hooks.getReceiveURL(this.location, this.session))\n );\n\n this.stream.bind('chunk', chunk => {\n this.onChunk(chunk);\n });\n this.stream.bind('finished', status => {\n this.hooks.onFinished(this, status);\n });\n this.stream.bind('buffer_too_long', () => {\n this.reconnect();\n });\n\n try {\n this.stream.start();\n } catch (error) {\n Util.defer(() => {\n this.onError(error);\n this.onClose(1006, 'Could not start streaming', false);\n });\n }\n }\n\n private closeStream() {\n if (this.stream) {\n this.stream.unbind_all();\n this.stream.close();\n this.stream = null;\n }\n }\n}\n\nfunction getLocation(url): URLLocation {\n var parts = /([^\\?]*)\\/*(\\??.*)/.exec(url);\n return {\n base: parts[1],\n queryString: parts[2]\n };\n}\n\nfunction getSendURL(url: URLLocation, session: string): string {\n return url.base + '/' + session + '/xhr_send';\n}\n\nfunction getUniqueURL(url: string): string {\n var separator = url.indexOf('?') === -1 ? '?' : '&';\n return url + separator + 't=' + +new Date() + '&n=' + autoIncrement++;\n}\n\nfunction replaceHost(url: string, hostname: string): string {\n var urlParts = /(https?:\\/\\/)([^\\/:]+)((\\/|:)?.*)/.exec(url);\n return urlParts[1] + hostname + urlParts[3];\n}\n\nfunction randomNumber(max: number): number {\n return Runtime.randomInt(max);\n}\n\nfunction randomString(length: number): string {\n var result = [];\n\n for (var i = 0; i < length; i++) {\n result.push(randomNumber(32).toString(32));\n }\n\n return result.join('');\n}\n\nexport default HTTPSocket;\n","import SocketHooks from './socket_hooks';\nimport HTTPSocket from './http_socket';\n\nvar hooks: SocketHooks = {\n getReceiveURL: function(url, session) {\n return url.base + '/' + session + '/xhr_streaming' + url.queryString;\n },\n onHeartbeat: function(socket) {\n socket.sendRaw('[]');\n },\n sendHeartbeat: function(socket) {\n socket.sendRaw('[]');\n },\n onFinished: function(socket, status) {\n socket.onClose(1006, 'Connection interrupted (' + status + ')', false);\n }\n};\n\nexport default hooks;\n","import SocketHooks from './socket_hooks';\nimport URLLocation from './url_location';\nimport HTTPSocket from './http_socket';\n\nvar hooks: SocketHooks = {\n getReceiveURL: function(url: URLLocation, session: string): string {\n return url.base + '/' + session + '/xhr' + url.queryString;\n },\n onHeartbeat: function() {\n // next HTTP request will reset server's activity timer\n },\n sendHeartbeat: function(socket) {\n socket.sendRaw('[]');\n },\n onFinished: function(socket, status) {\n if (status === 200) {\n socket.reconnect();\n } else {\n socket.onClose(1006, 'Connection interrupted (' + status + ')', false);\n }\n }\n};\n\nexport default hooks;\n","import HTTPRequest from 'core/http/http_request';\nimport RequestHooks from 'core/http/request_hooks';\nimport Ajax from 'core/http/ajax';\nimport Runtime from 'runtime';\n\nvar hooks: RequestHooks = {\n getRequest: function(socket: HTTPRequest): Ajax {\n var Constructor = Runtime.getXHRAPI();\n var xhr = new Constructor();\n xhr.onreadystatechange = xhr.onprogress = function() {\n switch (xhr.readyState) {\n case 3:\n if (xhr.responseText && xhr.responseText.length > 0) {\n socket.onChunk(xhr.status, xhr.responseText);\n }\n break;\n case 4:\n // this happens only on errors, never after calling close\n if (xhr.responseText && xhr.responseText.length > 0) {\n socket.onChunk(xhr.status, xhr.responseText);\n }\n socket.emit('finished', xhr.status);\n socket.close();\n break;\n }\n };\n return xhr;\n },\n abortRequest: function(xhr: Ajax) {\n xhr.onreadystatechange = null;\n xhr.abort();\n }\n};\n\nexport default hooks;\n","import * as Collections from 'core/utils/collections';\nimport Transports from 'isomorphic/transports/transports';\nimport TimelineSender from 'core/timeline/timeline_sender';\nimport Ajax from 'core/http/ajax';\nimport getDefaultStrategy from './default_strategy';\nimport TransportsTable from 'core/transports/transports_table';\nimport transportConnectionInitializer from './transports/transport_connection_initializer';\nimport HTTPFactory from './http/http';\n\nvar Isomorphic: any = {\n getDefaultStrategy,\n Transports: Transports,\n transportConnectionInitializer,\n HTTPFactory,\n\n setup(PusherClass): void {\n PusherClass.ready();\n },\n\n getLocalStorage(): any {\n return undefined;\n },\n\n getClientFeatures(): any[] {\n return Collections.keys(\n Collections.filterObject({ ws: Transports.ws }, function(t) {\n return t.isSupported({});\n })\n );\n },\n\n getProtocol(): string {\n return 'http:';\n },\n\n isXHRSupported(): boolean {\n return true;\n },\n\n createSocketRequest(method: string, url: string) {\n if (this.isXHRSupported()) {\n return this.HTTPFactory.createXHR(method, url);\n } else {\n throw 'Cross-origin HTTP requests are not supported';\n }\n },\n\n createXHR(): Ajax {\n var Constructor = this.getXHRAPI();\n return new Constructor();\n },\n\n createWebSocket(url: string): any {\n var Constructor = this.getWebSocketAPI();\n return new Constructor(url);\n },\n\n addUnloadListener(listener: any) {},\n removeUnloadListener(listener: any) {}\n};\n\nexport default Isomorphic;\n","/** Initializes the transport.\n *\n * Fetches resources if needed and then transitions to initialized.\n */\nexport default function() {\n var self = this;\n\n self.timeline.info(\n self.buildTimelineMessage({\n transport: self.name + (self.options.useTLS ? 's' : '')\n })\n );\n\n if (self.hooks.isInitialized()) {\n self.changeState('initialized');\n } else {\n self.onClose();\n }\n}\n","import HTTPRequest from 'core/http/http_request';\nimport HTTPSocket from 'core/http/http_socket';\nimport SocketHooks from 'core/http/socket_hooks';\nimport RequestHooks from 'core/http/request_hooks';\nimport streamingHooks from 'core/http/http_streaming_socket';\nimport pollingHooks from 'core/http/http_polling_socket';\nimport xhrHooks from './http_xhr_request';\nimport HTTPFactory from 'core/http/http_factory';\n\nvar HTTP: HTTPFactory = {\n createStreamingSocket(url: string): HTTPSocket {\n return this.createSocket(streamingHooks, url);\n },\n\n createPollingSocket(url: string): HTTPSocket {\n return this.createSocket(pollingHooks, url);\n },\n\n createSocket(hooks: SocketHooks, url: string): HTTPSocket {\n return new HTTPSocket(hooks, url);\n },\n\n createXHR(method: string, url: string): HTTPRequest {\n return this.createRequest(xhrHooks, method, url);\n },\n\n createRequest(hooks: RequestHooks, method: string, url: string): HTTPRequest {\n return new HTTPRequest(hooks, method, url);\n }\n};\n\nexport default HTTP;\n","import { default as NativeNetInfo } from '@react-native-community/netinfo';\nimport EventsDispatcher from 'core/events/dispatcher';\nimport Util from 'core/util';\nimport Reachability from 'core/reachability';\n\nfunction hasOnlineConnectionState(connectionState): boolean {\n return connectionState.type.toLowerCase() !== 'none';\n}\n\nexport class NetInfo extends EventsDispatcher implements Reachability {\n online: boolean;\n\n constructor() {\n super();\n this.online = true;\n\n NativeNetInfo.fetch().then(connectionState => {\n this.online = hasOnlineConnectionState(connectionState);\n });\n\n NativeNetInfo.addEventListener(connectionState => {\n var isNowOnline = hasOnlineConnectionState(connectionState);\n\n // React Native counts the switch from Wi-Fi to Cellular\n // as a state change. Return if current and previous states\n // are both online/offline\n if (this.online === isNowOnline) return;\n this.online = isNowOnline;\n if (this.online) {\n this.emit('online');\n } else {\n this.emit('offline');\n }\n });\n }\n\n isOnline(): boolean {\n return this.online;\n }\n}\n\nexport var Network = new NetInfo();\n","export enum AuthRequestType {\n UserAuthentication = 'user-authentication',\n ChannelAuthorization = 'channel-authorization'\n}\n\nexport interface ChannelAuthorizationData {\n auth: string;\n channel_data?: string;\n shared_secret?: string;\n}\n\nexport type ChannelAuthorizationCallback = (\n error: Error | null,\n authData: ChannelAuthorizationData | null\n) => void;\n\nexport interface ChannelAuthorizationRequestParams {\n socketId: string;\n channelName: string;\n}\n\nexport interface ChannelAuthorizationHandler {\n (\n params: ChannelAuthorizationRequestParams,\n callback: ChannelAuthorizationCallback\n ): void;\n}\n\nexport interface UserAuthenticationData {\n auth: string;\n user_data: string;\n}\n\nexport type UserAuthenticationCallback = (\n error: Error | null,\n authData: UserAuthenticationData | null\n) => void;\n\nexport interface UserAuthenticationRequestParams {\n socketId: string;\n}\n\nexport interface UserAuthenticationHandler {\n (\n params: UserAuthenticationRequestParams,\n callback: UserAuthenticationCallback\n ): void;\n}\n\nexport type AuthTransportCallback =\n | ChannelAuthorizationCallback\n | UserAuthenticationCallback;\n\nexport interface AuthOptionsT {\n transport: 'ajax' | 'jsonp';\n endpoint: string;\n params?: any;\n headers?: any;\n paramsProvider?: () => any;\n headersProvider?: () => any;\n customHandler?: AuthHandler;\n}\n\nexport declare type UserAuthenticationOptions = AuthOptionsT<\n UserAuthenticationHandler\n>;\nexport declare type ChannelAuthorizationOptions = AuthOptionsT<\n ChannelAuthorizationHandler\n>;\n\nexport interface InternalAuthOptions {\n transport: 'ajax' | 'jsonp';\n endpoint: string;\n params?: any;\n headers?: any;\n paramsProvider?: () => any;\n headersProvider?: () => any;\n}\n","import TimelineSender from 'core/timeline/timeline_sender';\nimport * as Collections from 'core/utils/collections';\nimport Util from 'core/util';\nimport Runtime from 'runtime';\nimport { AuthTransport } from 'core/auth/auth_transports';\nimport AbstractRuntime from 'runtimes/interface';\nimport UrlStore from 'core/utils/url_store';\nimport {\n AuthRequestType,\n AuthTransportCallback,\n InternalAuthOptions\n} from 'core/auth/options';\nimport { HTTPAuthError } from 'core/errors';\n\nconst ajax: AuthTransport = function(\n context: AbstractRuntime,\n query: string,\n authOptions: InternalAuthOptions,\n authRequestType: AuthRequestType,\n callback: AuthTransportCallback\n) {\n const xhr = Runtime.createXHR();\n xhr.open('POST', authOptions.endpoint, true);\n\n // add request headers\n xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');\n for (var headerName in authOptions.headers) {\n xhr.setRequestHeader(headerName, authOptions.headers[headerName]);\n }\n if (authOptions.headersProvider != null) {\n let dynamicHeaders = authOptions.headersProvider();\n for (var headerName in dynamicHeaders) {\n xhr.setRequestHeader(headerName, dynamicHeaders[headerName]);\n }\n }\n\n xhr.onreadystatechange = function() {\n if (xhr.readyState === 4) {\n if (xhr.status === 200) {\n let data;\n let parsed = false;\n\n try {\n data = JSON.parse(xhr.responseText);\n parsed = true;\n } catch (e) {\n callback(\n new HTTPAuthError(\n 200,\n `JSON returned from ${authRequestType.toString()} endpoint was invalid, yet status code was 200. Data was: ${\n xhr.responseText\n }`\n ),\n null\n );\n }\n\n if (parsed) {\n // prevents double execution.\n callback(null, data);\n }\n } else {\n let suffix = '';\n switch (authRequestType) {\n case AuthRequestType.UserAuthentication:\n suffix = UrlStore.buildLogSuffix('authenticationEndpoint');\n break;\n case AuthRequestType.ChannelAuthorization:\n suffix = `Clients must be authorized to join private or presence channels. ${UrlStore.buildLogSuffix(\n 'authorizationEndpoint'\n )}`;\n break;\n }\n callback(\n new HTTPAuthError(\n xhr.status,\n `Unable to retrieve auth string from ${authRequestType.toString()} endpoint - ` +\n `received status: ${xhr.status} from ${authOptions.endpoint}. ${suffix}`\n ),\n null\n );\n }\n }\n };\n\n xhr.send(query);\n return xhr;\n};\n\nexport default ajax;\n","import Logger from 'core/logger';\nimport TimelineSender from 'core/timeline/timeline_sender';\nimport * as Collections from 'core/utils/collections';\nimport Util from 'core/util';\nimport Runtime from 'runtime';\nimport TimelineTransport from 'core/timeline/timeline_transport';\n\nvar getAgent = function(sender: TimelineSender, useTLS: boolean) {\n return function(data: any, callback: Function) {\n var scheme = 'http' + (useTLS ? 's' : '') + '://';\n var url =\n scheme + (sender.host || sender.options.host) + sender.options.path;\n var query = Collections.buildQueryString(data);\n\n url += '/' + 2 + '?' + query;\n\n var xhr = Runtime.createXHR();\n xhr.open('GET', url, true);\n\n xhr.onreadystatechange = function() {\n if (xhr.readyState === 4) {\n let { status, responseText } = xhr;\n if (status !== 200) {\n Logger.debug(\n `TimelineSender Error: received ${status} from stats.pusher.com`\n );\n return;\n }\n\n try {\n var { host } = JSON.parse(responseText);\n } catch (e) {\n Logger.debug(`TimelineSenderError: invalid response ${responseText}`);\n }\n if (host) {\n sender.host = host;\n }\n }\n };\n\n xhr.send();\n };\n};\n\nvar xhr = {\n name: 'xhr',\n getAgent\n};\n\nexport default xhr;\n","import Isomorphic from 'isomorphic/runtime';\nimport Runtime from '../interface';\nimport { Network } from './net_info';\nimport xhrAuth from 'isomorphic/auth/xhr_auth';\nimport { AuthTransports } from 'core/auth/auth_transports';\nimport xhrTimeline from 'isomorphic/timeline/xhr_timeline';\n\n// Very verbose but until unavoidable until\n// TypeScript 2.1, when spread attributes will be\n// supported\nconst {\n getDefaultStrategy,\n Transports,\n setup,\n getProtocol,\n isXHRSupported,\n getLocalStorage,\n createXHR,\n createWebSocket,\n addUnloadListener,\n removeUnloadListener,\n transportConnectionInitializer,\n createSocketRequest,\n HTTPFactory\n} = Isomorphic;\n\nconst ReactNative: Runtime = {\n getDefaultStrategy,\n Transports,\n setup,\n getProtocol,\n isXHRSupported,\n getLocalStorage,\n createXHR,\n createWebSocket,\n addUnloadListener,\n removeUnloadListener,\n transportConnectionInitializer,\n createSocketRequest,\n HTTPFactory,\n\n TimelineTransport: xhrTimeline,\n\n getAuthorizers(): AuthTransports {\n return { ajax: xhrAuth };\n },\n\n getWebSocketAPI() {\n return WebSocket;\n },\n\n getXHRAPI() {\n return XMLHttpRequest;\n },\n\n getNetwork() {\n return Network;\n },\n\n randomInt(max: number): number {\n return Math.floor(Math.random() * max);\n }\n};\n\nexport default ReactNative;\n","enum TimelineLevel {\n ERROR = 3,\n INFO = 6,\n DEBUG = 7\n}\n\nexport default TimelineLevel;\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport { default as Level } from './level';\n\nexport interface TimelineOptions {\n level?: Level;\n limit?: number;\n version?: string;\n cluster?: string;\n features?: string[];\n params?: any;\n}\n\nexport default class Timeline {\n key: string;\n session: number;\n events: any[];\n options: TimelineOptions;\n sent: number;\n uniqueID: number;\n\n constructor(key: string, session: number, options: TimelineOptions) {\n this.key = key;\n this.session = session;\n this.events = [];\n this.options = options || {};\n this.sent = 0;\n this.uniqueID = 0;\n }\n\n log(level, event) {\n if (level <= this.options.level) {\n this.events.push(\n Collections.extend({}, event, { timestamp: Util.now() })\n );\n if (this.options.limit && this.events.length > this.options.limit) {\n this.events.shift();\n }\n }\n }\n\n error(event) {\n this.log(Level.ERROR, event);\n }\n\n info(event) {\n this.log(Level.INFO, event);\n }\n\n debug(event) {\n this.log(Level.DEBUG, event);\n }\n\n isEmpty() {\n return this.events.length === 0;\n }\n\n send(sendfn, callback) {\n var data = Collections.extend(\n {\n session: this.session,\n bundle: this.sent + 1,\n key: this.key,\n lib: 'js',\n version: this.options.version,\n cluster: this.options.cluster,\n features: this.options.features,\n timeline: this.events\n },\n this.options.params\n );\n\n this.events = [];\n sendfn(data, (error, result) => {\n if (!error) {\n this.sent++;\n }\n if (callback) {\n callback(error, result);\n }\n });\n\n return true;\n }\n\n generateUniqueID(): number {\n this.uniqueID++;\n return this.uniqueID;\n }\n}\n","import Factory from '../utils/factory';\nimport Util from '../util';\nimport * as Errors from '../errors';\nimport * as Collections from '../utils/collections';\nimport Strategy from './strategy';\nimport Transport from '../transports/transport';\nimport StrategyOptions from './strategy_options';\nimport Handshake from '../connection/handshake';\n\n/** Provides a strategy interface for transports.\n *\n * @param {String} name\n * @param {Number} priority\n * @param {Class} transport\n * @param {Object} options\n */\nexport default class TransportStrategy implements Strategy {\n name: string;\n priority: number;\n transport: Transport;\n options: StrategyOptions;\n\n constructor(\n name: string,\n priority: number,\n transport: Transport,\n options: StrategyOptions\n ) {\n this.name = name;\n this.priority = priority;\n this.transport = transport;\n this.options = options || {};\n }\n\n /** Returns whether the transport is supported in the browser.\n *\n * @returns {Boolean}\n */\n isSupported(): boolean {\n return this.transport.isSupported({\n useTLS: this.options.useTLS\n });\n }\n\n /** Launches a connection attempt and returns a strategy runner.\n *\n * @param {Function} callback\n * @return {Object} strategy runner\n */\n connect(minPriority: number, callback: Function) {\n if (!this.isSupported()) {\n return failAttempt(new Errors.UnsupportedStrategy(), callback);\n } else if (this.priority < minPriority) {\n return failAttempt(new Errors.TransportPriorityTooLow(), callback);\n }\n\n var connected = false;\n var transport = this.transport.createConnection(\n this.name,\n this.priority,\n this.options.key,\n this.options\n );\n var handshake = null;\n\n var onInitialized = function() {\n transport.unbind('initialized', onInitialized);\n transport.connect();\n };\n var onOpen = function() {\n handshake = Factory.createHandshake(transport, function(result) {\n connected = true;\n unbindListeners();\n callback(null, result);\n });\n };\n var onError = function(error) {\n unbindListeners();\n callback(error);\n };\n var onClosed = function() {\n unbindListeners();\n var serializedTransport;\n\n // The reason for this try/catch block is that on React Native\n // the WebSocket object is circular. Therefore transport.socket will\n // throw errors upon stringification. Collections.safeJSONStringify\n // discards circular references when serializing.\n serializedTransport = Collections.safeJSONStringify(transport);\n callback(new Errors.TransportClosed(serializedTransport));\n };\n\n var unbindListeners = function() {\n transport.unbind('initialized', onInitialized);\n transport.unbind('open', onOpen);\n transport.unbind('error', onError);\n transport.unbind('closed', onClosed);\n };\n\n transport.bind('initialized', onInitialized);\n transport.bind('open', onOpen);\n transport.bind('error', onError);\n transport.bind('closed', onClosed);\n\n // connect will be called automatically after initialization\n transport.initialize();\n\n return {\n abort: () => {\n if (connected) {\n return;\n }\n unbindListeners();\n if (handshake) {\n handshake.close();\n } else {\n transport.close();\n }\n },\n forceMinPriority: p => {\n if (connected) {\n return;\n }\n if (this.priority < p) {\n if (handshake) {\n handshake.close();\n } else {\n transport.close();\n }\n }\n }\n };\n }\n}\n\nfunction failAttempt(error: Error, callback: Function) {\n Util.defer(function() {\n callback(error);\n });\n return {\n abort: function() {},\n forceMinPriority: function() {}\n };\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport TransportManager from '../transports/transport_manager';\nimport * as Errors from '../errors';\nimport Strategy from './strategy';\nimport TransportStrategy from './transport_strategy';\nimport StrategyOptions from '../strategies/strategy_options';\nimport { Config } from '../config';\nimport Runtime from 'runtime';\n\nconst { Transports } = Runtime;\n\nexport var defineTransport = function(\n config: Config,\n name: string,\n type: string,\n priority: number,\n options: StrategyOptions,\n manager?: TransportManager\n): Strategy {\n var transportClass = Transports[type];\n if (!transportClass) {\n throw new Errors.UnsupportedTransport(type);\n }\n\n var enabled =\n (!config.enabledTransports ||\n Collections.arrayIndexOf(config.enabledTransports, name) !== -1) &&\n (!config.disabledTransports ||\n Collections.arrayIndexOf(config.disabledTransports, name) === -1);\n\n var transport;\n if (enabled) {\n options = Object.assign(\n { ignoreNullOrigin: config.ignoreNullOrigin },\n options\n );\n\n transport = new TransportStrategy(\n name,\n priority,\n manager ? manager.getAssistant(transportClass) : transportClass,\n options\n );\n } else {\n transport = UnsupportedStrategy;\n }\n\n return transport;\n};\n\nvar UnsupportedStrategy: Strategy = {\n isSupported: function() {\n return false;\n },\n connect: function(_, callback) {\n var deferred = Util.defer(function() {\n callback(new Errors.UnsupportedStrategy());\n });\n return {\n abort: function() {\n deferred.ensureAborted();\n },\n forceMinPriority: function() {}\n };\n }\n};\n","import {\n UserAuthenticationCallback,\n InternalAuthOptions,\n UserAuthenticationHandler,\n UserAuthenticationRequestParams,\n AuthRequestType\n} from './options';\n\nimport Runtime from 'runtime';\n\nconst composeChannelQuery = (\n params: UserAuthenticationRequestParams,\n authOptions: InternalAuthOptions\n) => {\n var query = 'socket_id=' + encodeURIComponent(params.socketId);\n\n for (var key in authOptions.params) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(authOptions.params[key]);\n }\n\n if (authOptions.paramsProvider != null) {\n let dynamicParams = authOptions.paramsProvider();\n for (var key in dynamicParams) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(dynamicParams[key]);\n }\n }\n\n return query;\n};\n\nconst UserAuthenticator = (\n authOptions: InternalAuthOptions\n): UserAuthenticationHandler => {\n if (typeof Runtime.getAuthorizers()[authOptions.transport] === 'undefined') {\n throw `'${authOptions.transport}' is not a recognized auth transport`;\n }\n\n return (\n params: UserAuthenticationRequestParams,\n callback: UserAuthenticationCallback\n ) => {\n const query = composeChannelQuery(params, authOptions);\n\n Runtime.getAuthorizers()[authOptions.transport](\n Runtime,\n query,\n authOptions,\n AuthRequestType.UserAuthentication,\n callback\n );\n };\n};\n\nexport default UserAuthenticator;\n","import {\n AuthRequestType,\n InternalAuthOptions,\n ChannelAuthorizationHandler,\n ChannelAuthorizationRequestParams,\n ChannelAuthorizationCallback\n} from './options';\n\nimport Runtime from 'runtime';\n\nconst composeChannelQuery = (\n params: ChannelAuthorizationRequestParams,\n authOptions: InternalAuthOptions\n) => {\n var query = 'socket_id=' + encodeURIComponent(params.socketId);\n\n query += '&channel_name=' + encodeURIComponent(params.channelName);\n\n for (var key in authOptions.params) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(authOptions.params[key]);\n }\n\n if (authOptions.paramsProvider != null) {\n let dynamicParams = authOptions.paramsProvider();\n for (var key in dynamicParams) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(dynamicParams[key]);\n }\n }\n\n return query;\n};\n\nconst ChannelAuthorizer = (\n authOptions: InternalAuthOptions\n): ChannelAuthorizationHandler => {\n if (typeof Runtime.getAuthorizers()[authOptions.transport] === 'undefined') {\n throw `'${authOptions.transport}' is not a recognized auth transport`;\n }\n\n return (\n params: ChannelAuthorizationRequestParams,\n callback: ChannelAuthorizationCallback\n ) => {\n const query = composeChannelQuery(params, authOptions);\n\n Runtime.getAuthorizers()[authOptions.transport](\n Runtime,\n query,\n authOptions,\n AuthRequestType.ChannelAuthorization,\n callback\n );\n };\n};\n\nexport default ChannelAuthorizer;\n","import { Options } from './options';\nimport Defaults from './defaults';\nimport {\n ChannelAuthorizationHandler,\n UserAuthenticationHandler,\n ChannelAuthorizationOptions\n} from './auth/options';\nimport UserAuthenticator from './auth/user_authenticator';\nimport ChannelAuthorizer from './auth/channel_authorizer';\nimport { ChannelAuthorizerProxy } from './auth/deprecated_channel_authorizer';\nimport Runtime from 'runtime';\nimport * as nacl from 'tweetnacl';\n\nexport type AuthTransport = 'ajax' | 'jsonp';\nexport type Transport =\n | 'ws'\n | 'wss'\n | 'xhr_streaming'\n | 'xhr_polling'\n | 'sockjs';\n\nexport interface Config {\n // these are all 'required' config parameters, it's not necessary for the user\n // to set them, but they have configured defaults.\n activityTimeout: number;\n enableStats: boolean;\n httpHost: string;\n httpPath: string;\n httpPort: number;\n httpsPort: number;\n pongTimeout: number;\n statsHost: string;\n unavailableTimeout: number;\n useTLS: boolean;\n wsHost: string;\n wsPath: string;\n wsPort: number;\n wssPort: number;\n userAuthenticator: UserAuthenticationHandler;\n channelAuthorizer: ChannelAuthorizationHandler;\n\n // these are all optional parameters or overrrides. The customer can set these\n // but it's not strictly necessary\n forceTLS?: boolean;\n cluster?: string;\n disabledTransports?: Transport[];\n enabledTransports?: Transport[];\n ignoreNullOrigin?: boolean;\n nacl?: nacl;\n timelineParams?: any;\n}\n\n// getConfig mainly sets the defaults for the options that are not provided\nexport function getConfig(opts: Options, pusher): Config {\n let config: Config = {\n activityTimeout: opts.activityTimeout || Defaults.activityTimeout,\n cluster: opts.cluster,\n httpPath: opts.httpPath || Defaults.httpPath,\n httpPort: opts.httpPort || Defaults.httpPort,\n httpsPort: opts.httpsPort || Defaults.httpsPort,\n pongTimeout: opts.pongTimeout || Defaults.pongTimeout,\n statsHost: opts.statsHost || Defaults.stats_host,\n unavailableTimeout: opts.unavailableTimeout || Defaults.unavailableTimeout,\n wsPath: opts.wsPath || Defaults.wsPath,\n wsPort: opts.wsPort || Defaults.wsPort,\n wssPort: opts.wssPort || Defaults.wssPort,\n\n enableStats: getEnableStatsConfig(opts),\n httpHost: getHttpHost(opts),\n useTLS: shouldUseTLS(opts),\n wsHost: getWebsocketHost(opts),\n\n userAuthenticator: buildUserAuthenticator(opts),\n channelAuthorizer: buildChannelAuthorizer(opts, pusher)\n };\n\n if ('disabledTransports' in opts)\n config.disabledTransports = opts.disabledTransports;\n if ('enabledTransports' in opts)\n config.enabledTransports = opts.enabledTransports;\n if ('ignoreNullOrigin' in opts)\n config.ignoreNullOrigin = opts.ignoreNullOrigin;\n if ('timelineParams' in opts) config.timelineParams = opts.timelineParams;\n if ('nacl' in opts) {\n config.nacl = opts.nacl;\n }\n\n return config;\n}\n\nfunction getHttpHost(opts: Options): string {\n if (opts.httpHost) {\n return opts.httpHost;\n }\n if (opts.cluster) {\n return `sockjs-${opts.cluster}.pusher.com`;\n }\n return Defaults.httpHost;\n}\n\nfunction getWebsocketHost(opts: Options): string {\n if (opts.wsHost) {\n return opts.wsHost;\n }\n return getWebsocketHostFromCluster(opts.cluster);\n}\n\nfunction getWebsocketHostFromCluster(cluster: string): string {\n return `ws-${cluster}.pusher.com`;\n}\n\nfunction shouldUseTLS(opts: Options): boolean {\n if (Runtime.getProtocol() === 'https:') {\n return true;\n } else if (opts.forceTLS === false) {\n return false;\n }\n return true;\n}\n\n// if enableStats is set take the value\n// if disableStats is set take the inverse\n// otherwise default to false\nfunction getEnableStatsConfig(opts: Options): boolean {\n if ('enableStats' in opts) {\n return opts.enableStats;\n }\n if ('disableStats' in opts) {\n return !opts.disableStats;\n }\n return false;\n}\n\nfunction buildUserAuthenticator(opts: Options): UserAuthenticationHandler {\n const userAuthentication = {\n ...Defaults.userAuthentication,\n ...opts.userAuthentication\n };\n if (\n 'customHandler' in userAuthentication &&\n userAuthentication['customHandler'] != null\n ) {\n return userAuthentication['customHandler'];\n }\n\n return UserAuthenticator(userAuthentication);\n}\n\nfunction buildChannelAuth(opts: Options, pusher): ChannelAuthorizationOptions {\n let channelAuthorization: ChannelAuthorizationOptions;\n if ('channelAuthorization' in opts) {\n channelAuthorization = {\n ...Defaults.channelAuthorization,\n ...opts.channelAuthorization\n };\n } else {\n channelAuthorization = {\n transport: opts.authTransport || Defaults.authTransport,\n endpoint: opts.authEndpoint || Defaults.authEndpoint\n };\n if ('auth' in opts) {\n if ('params' in opts.auth) channelAuthorization.params = opts.auth.params;\n if ('headers' in opts.auth)\n channelAuthorization.headers = opts.auth.headers;\n }\n if ('authorizer' in opts)\n channelAuthorization.customHandler = ChannelAuthorizerProxy(\n pusher,\n channelAuthorization,\n opts.authorizer\n );\n }\n return channelAuthorization;\n}\n\nfunction buildChannelAuthorizer(\n opts: Options,\n pusher\n): ChannelAuthorizationHandler {\n const channelAuthorization = buildChannelAuth(opts, pusher);\n if (\n 'customHandler' in channelAuthorization &&\n channelAuthorization['customHandler'] != null\n ) {\n return channelAuthorization['customHandler'];\n }\n\n return ChannelAuthorizer(channelAuthorization);\n}\n","import Channel from '../channels/channel';\nimport {\n ChannelAuthorizationCallback,\n ChannelAuthorizationHandler,\n ChannelAuthorizationRequestParams,\n InternalAuthOptions\n} from './options';\n\nexport interface DeprecatedChannelAuthorizer {\n authorize(socketId: string, callback: ChannelAuthorizationCallback): void;\n}\n\nexport interface ChannelAuthorizerGenerator {\n (\n channel: Channel,\n options: DeprecatedAuthorizerOptions\n ): DeprecatedChannelAuthorizer;\n}\n\nexport interface DeprecatedAuthOptions {\n params?: any;\n headers?: any;\n}\n\nexport interface DeprecatedAuthorizerOptions {\n authTransport: 'ajax' | 'jsonp';\n authEndpoint: string;\n auth?: DeprecatedAuthOptions;\n}\n\nexport const ChannelAuthorizerProxy = (\n pusher,\n authOptions: InternalAuthOptions,\n channelAuthorizerGenerator: ChannelAuthorizerGenerator\n): ChannelAuthorizationHandler => {\n const deprecatedAuthorizerOptions: DeprecatedAuthorizerOptions = {\n authTransport: authOptions.transport,\n authEndpoint: authOptions.endpoint,\n auth: {\n params: authOptions.params,\n headers: authOptions.headers\n }\n };\n return (\n params: ChannelAuthorizationRequestParams,\n callback: ChannelAuthorizationCallback\n ) => {\n const channel = pusher.channel(params.channelName);\n // This line creates a new channel authorizer every time.\n // In the past, this was only done once per channel and reused.\n // We can do that again if we want to keep this behavior intact.\n const channelAuthorizer: DeprecatedChannelAuthorizer = channelAuthorizerGenerator(\n channel,\n deprecatedAuthorizerOptions\n );\n channelAuthorizer.authorize(params.socketId, callback);\n };\n};\n","import Logger from './logger';\nimport Pusher from './pusher';\nimport EventsDispatcher from './events/dispatcher';\n\nexport default class WatchlistFacade extends EventsDispatcher {\n private pusher: Pusher;\n\n public constructor(pusher: Pusher) {\n super(function(eventName, data) {\n Logger.debug(`No callbacks on watchlist events for ${eventName}`);\n });\n\n this.pusher = pusher;\n this.bindWatchlistInternalEvent();\n }\n\n handleEvent(pusherEvent) {\n pusherEvent.data.events.forEach(watchlistEvent => {\n this.emit(watchlistEvent.name, watchlistEvent);\n });\n }\n\n private bindWatchlistInternalEvent() {\n this.pusher.connection.bind('message', pusherEvent => {\n var eventName = pusherEvent.event;\n if (eventName === 'pusher_internal:watchlist_events') {\n this.handleEvent(pusherEvent);\n }\n });\n }\n}\n","function flatPromise() {\n let resolve, reject;\n const promise = new Promise((res, rej) => {\n resolve = res;\n reject = rej;\n });\n return { promise, resolve, reject };\n}\n\nexport default flatPromise;\n","import Pusher from './pusher';\nimport Logger from './logger';\nimport {\n UserAuthenticationData,\n UserAuthenticationCallback\n} from './auth/options';\nimport Channel from './channels/channel';\nimport WatchlistFacade from './watchlist';\nimport EventsDispatcher from './events/dispatcher';\nimport flatPromise from './utils/flat_promise';\n\nexport default class UserFacade extends EventsDispatcher {\n pusher: Pusher;\n signin_requested: boolean = false;\n user_data: any = null;\n serverToUserChannel: Channel = null;\n signinDonePromise: Promise = null;\n watchlist: WatchlistFacade;\n private _signinDoneResolve: Function = null;\n\n public constructor(pusher: Pusher) {\n super(function(eventName, data) {\n Logger.debug('No callbacks on user for ' + eventName);\n });\n this.pusher = pusher;\n this.pusher.connection.bind('state_change', ({ previous, current }) => {\n if (previous !== 'connected' && current === 'connected') {\n this._signin();\n }\n if (previous === 'connected' && current !== 'connected') {\n this._cleanup();\n this._newSigninPromiseIfNeeded();\n }\n });\n\n this.watchlist = new WatchlistFacade(pusher);\n\n this.pusher.connection.bind('message', event => {\n var eventName = event.event;\n if (eventName === 'pusher:signin_success') {\n this._onSigninSuccess(event.data);\n }\n if (\n this.serverToUserChannel &&\n this.serverToUserChannel.name === event.channel\n ) {\n this.serverToUserChannel.handleEvent(event);\n }\n });\n }\n\n public signin() {\n if (this.signin_requested) {\n return;\n }\n\n this.signin_requested = true;\n this._signin();\n }\n\n private _signin() {\n if (!this.signin_requested) {\n return;\n }\n\n this._newSigninPromiseIfNeeded();\n\n if (this.pusher.connection.state !== 'connected') {\n // Signin will be attempted when the connection is connected\n return;\n }\n\n this.pusher.config.userAuthenticator(\n {\n socketId: this.pusher.connection.socket_id\n },\n this._onAuthorize\n );\n }\n\n private _onAuthorize: UserAuthenticationCallback = (\n err,\n authData: UserAuthenticationData\n ) => {\n if (err) {\n Logger.warn(`Error during signin: ${err}`);\n this._cleanup();\n return;\n }\n\n this.pusher.send_event('pusher:signin', {\n auth: authData.auth,\n user_data: authData.user_data\n });\n\n // Later when we get pusher:singin_success event, the user will be marked as signed in\n };\n\n private _onSigninSuccess(data: any) {\n try {\n this.user_data = JSON.parse(data.user_data);\n } catch (e) {\n Logger.error(`Failed parsing user data after signin: ${data.user_data}`);\n this._cleanup();\n return;\n }\n\n if (typeof this.user_data.id !== 'string' || this.user_data.id === '') {\n Logger.error(\n `user_data doesn't contain an id. user_data: ${this.user_data}`\n );\n this._cleanup();\n return;\n }\n\n // Signin succeeded\n this._signinDoneResolve();\n this._subscribeChannels();\n }\n\n private _subscribeChannels() {\n const ensure_subscribed = channel => {\n if (channel.subscriptionPending && channel.subscriptionCancelled) {\n channel.reinstateSubscription();\n } else if (\n !channel.subscriptionPending &&\n this.pusher.connection.state === 'connected'\n ) {\n channel.subscribe();\n }\n };\n\n this.serverToUserChannel = new Channel(\n `#server-to-user-${this.user_data.id}`,\n this.pusher\n );\n this.serverToUserChannel.bind_global((eventName, data) => {\n if (\n eventName.indexOf('pusher_internal:') === 0 ||\n eventName.indexOf('pusher:') === 0\n ) {\n // ignore internal events\n return;\n }\n this.emit(eventName, data);\n });\n ensure_subscribed(this.serverToUserChannel);\n }\n\n private _cleanup() {\n this.user_data = null;\n if (this.serverToUserChannel) {\n this.serverToUserChannel.unbind_all();\n this.serverToUserChannel.disconnect();\n this.serverToUserChannel = null;\n }\n\n if (this.signin_requested) {\n // If signin is in progress and cleanup is called,\n // Mark the current signin process as done.\n this._signinDoneResolve();\n }\n }\n\n private _newSigninPromiseIfNeeded() {\n if (!this.signin_requested) {\n return;\n }\n\n // If there is a promise and it is not resolved, return without creating a new one.\n if (this.signinDonePromise && !(this.signinDonePromise as any).done) {\n return;\n }\n\n // This promise is never rejected.\n // It gets resolved when the signin process is done whether it failed or succeeded\n const { promise, resolve, reject: _ } = flatPromise();\n (promise as any).done = false;\n const setDone = () => {\n (promise as any).done = true;\n };\n promise.then(setDone).catch(setDone);\n this.signinDonePromise = promise;\n this._signinDoneResolve = resolve;\n }\n}\n","import AbstractRuntime from '../runtimes/interface';\nimport Runtime from 'runtime';\nimport * as Collections from './utils/collections';\nimport Channels from './channels/channels';\nimport Channel from './channels/channel';\nimport { default as EventsDispatcher } from './events/dispatcher';\nimport Timeline from './timeline/timeline';\nimport TimelineSender from './timeline/timeline_sender';\nimport TimelineLevel from './timeline/level';\nimport { defineTransport } from './strategies/strategy_builder';\nimport ConnectionManager from './connection/connection_manager';\nimport { PeriodicTimer } from './utils/timers';\nimport Defaults from './defaults';\nimport Logger from './logger';\nimport Factory from './utils/factory';\nimport { Options, ClusterOptions, validateOptions } from './options';\nimport { Config, getConfig } from './config';\nimport StrategyOptions from './strategies/strategy_options';\nimport UserFacade from './user';\n\nexport default class Pusher {\n /* STATIC PROPERTIES */\n static instances: Pusher[] = [];\n static isReady: boolean = false;\n static logToConsole: boolean = false;\n\n // for jsonp\n static Runtime: AbstractRuntime = Runtime;\n static ScriptReceivers: any = (Runtime).ScriptReceivers;\n static DependenciesReceivers: any = (Runtime).DependenciesReceivers;\n static auth_callbacks: any = (Runtime).auth_callbacks;\n\n static ready() {\n Pusher.isReady = true;\n for (var i = 0, l = Pusher.instances.length; i < l; i++) {\n Pusher.instances[i].connect();\n }\n }\n\n static log: (message: any) => void;\n\n private static getClientFeatures(): string[] {\n return Collections.keys(\n Collections.filterObject({ ws: Runtime.Transports.ws }, function(t) {\n return t.isSupported({});\n })\n );\n }\n\n /* INSTANCE PROPERTIES */\n key: string;\n options: Options;\n config: Config;\n channels: Channels;\n global_emitter: EventsDispatcher;\n sessionID: number;\n timeline: Timeline;\n timelineSender: TimelineSender;\n connection: ConnectionManager;\n timelineSenderTimer: PeriodicTimer;\n user: UserFacade;\n constructor(app_key: string, options: Options) {\n checkAppKey(app_key);\n validateOptions(options);\n this.key = app_key;\n this.config = getConfig(options, this);\n\n this.channels = Factory.createChannels();\n this.global_emitter = new EventsDispatcher();\n this.sessionID = Runtime.randomInt(1000000000);\n\n this.timeline = new Timeline(this.key, this.sessionID, {\n cluster: this.config.cluster,\n features: Pusher.getClientFeatures(),\n params: this.config.timelineParams || {},\n limit: 50,\n level: TimelineLevel.INFO,\n version: Defaults.VERSION\n });\n if (this.config.enableStats) {\n this.timelineSender = Factory.createTimelineSender(this.timeline, {\n host: this.config.statsHost,\n path: '/timeline/v2/' + Runtime.TimelineTransport.name\n });\n }\n\n var getStrategy = (options: StrategyOptions) => {\n return Runtime.getDefaultStrategy(this.config, options, defineTransport);\n };\n\n this.connection = Factory.createConnectionManager(this.key, {\n getStrategy: getStrategy,\n timeline: this.timeline,\n activityTimeout: this.config.activityTimeout,\n pongTimeout: this.config.pongTimeout,\n unavailableTimeout: this.config.unavailableTimeout,\n useTLS: Boolean(this.config.useTLS)\n });\n\n this.connection.bind('connected', () => {\n this.subscribeAll();\n if (this.timelineSender) {\n this.timelineSender.send(this.connection.isUsingTLS());\n }\n });\n\n this.connection.bind('message', event => {\n var eventName = event.event;\n var internal = eventName.indexOf('pusher_internal:') === 0;\n if (event.channel) {\n var channel = this.channel(event.channel);\n if (channel) {\n channel.handleEvent(event);\n }\n }\n // Emit globally [deprecated]\n if (!internal) {\n this.global_emitter.emit(event.event, event.data);\n }\n });\n this.connection.bind('connecting', () => {\n this.channels.disconnect();\n });\n this.connection.bind('disconnected', () => {\n this.channels.disconnect();\n });\n this.connection.bind('error', err => {\n Logger.warn(err);\n });\n\n Pusher.instances.push(this);\n this.timeline.info({ instances: Pusher.instances.length });\n\n this.user = new UserFacade(this);\n\n if (Pusher.isReady) {\n this.connect();\n }\n }\n\n /**\n * Allows you to switch Pusher cluster without\n * losing all the channels/subscription binding\n * as this is internally managed by the SDK.\n */\n switchCluster(options: ClusterOptions) {\n const { appKey, cluster } = options;\n this.key = appKey;\n this.options = { ...this.options, cluster };\n this.config = getConfig(this.options, this);\n this.connection.switchCluster(this.key);\n }\n\n channel(name: string): Channel {\n return this.channels.find(name);\n }\n\n allChannels(): Channel[] {\n return this.channels.all();\n }\n\n connect() {\n this.connection.connect();\n\n if (this.timelineSender) {\n if (!this.timelineSenderTimer) {\n var usingTLS = this.connection.isUsingTLS();\n var timelineSender = this.timelineSender;\n this.timelineSenderTimer = new PeriodicTimer(60000, function() {\n timelineSender.send(usingTLS);\n });\n }\n }\n }\n\n disconnect() {\n this.connection.disconnect();\n\n if (this.timelineSenderTimer) {\n this.timelineSenderTimer.ensureAborted();\n this.timelineSenderTimer = null;\n }\n }\n\n bind(event_name: string, callback: Function, context?: any): Pusher {\n this.global_emitter.bind(event_name, callback, context);\n return this;\n }\n\n unbind(event_name?: string, callback?: Function, context?: any): Pusher {\n this.global_emitter.unbind(event_name, callback, context);\n return this;\n }\n\n bind_global(callback: Function): Pusher {\n this.global_emitter.bind_global(callback);\n return this;\n }\n\n unbind_global(callback?: Function): Pusher {\n this.global_emitter.unbind_global(callback);\n return this;\n }\n\n unbind_all(callback?: Function): Pusher {\n this.global_emitter.unbind_all();\n return this;\n }\n\n subscribeAll() {\n var channelName;\n for (channelName in this.channels.channels) {\n if (this.channels.channels.hasOwnProperty(channelName)) {\n this.subscribe(channelName);\n }\n }\n }\n\n subscribe(channel_name: string) {\n var channel = this.channels.add(channel_name, this);\n if (channel.subscriptionPending && channel.subscriptionCancelled) {\n channel.reinstateSubscription();\n } else if (\n !channel.subscriptionPending &&\n this.connection.state === 'connected'\n ) {\n channel.subscribe();\n }\n return channel;\n }\n\n unsubscribe(channel_name: string) {\n var channel = this.channels.find(channel_name);\n if (channel && channel.subscriptionPending) {\n channel.cancelSubscription();\n } else {\n channel = this.channels.remove(channel_name);\n if (channel && channel.subscribed) {\n channel.unsubscribe();\n }\n }\n }\n\n send_event(event_name: string, data: any, channel?: string) {\n return this.connection.send_event(event_name, data, channel);\n }\n\n shouldUseTLS(): boolean {\n return this.config.useTLS;\n }\n\n signin() {\n this.user.signin();\n }\n}\n\nfunction checkAppKey(key) {\n if (key === null || key === undefined) {\n throw 'You must pass your app key when you instantiate Pusher.';\n }\n}\n\nRuntime.setup(Pusher);\n","var g;\n\n// This works in non-strict mode\ng = (function() {\n\treturn this;\n})();\n\ntry {\n\t// This works if eval is allowed (see CSP)\n\tg = g || new Function(\"return this\")();\n} catch (e) {\n\t// This works if the window reference is available\n\tif (typeof window === \"object\") g = window;\n}\n\n// g can still be undefined, but nothing to do about it...\n// We return undefined, instead of nothing here, so it's\n// easier to handle this case. if(!global) { ...}\n\nmodule.exports = g;\n","import ConnectionManager from './connection/connection_manager';\nimport {\n ChannelAuthorizationOptions,\n UserAuthenticationOptions\n} from './auth/options';\nimport {\n ChannelAuthorizerGenerator,\n DeprecatedAuthOptions\n} from './auth/deprecated_channel_authorizer';\nimport { AuthTransport, Transport } from './config';\nimport * as nacl from 'tweetnacl';\nimport Logger from './logger';\n\nexport interface Options {\n activityTimeout?: number;\n\n auth?: DeprecatedAuthOptions; // DEPRECATED use channelAuthorization instead\n authEndpoint?: string; // DEPRECATED use channelAuthorization instead\n authTransport?: AuthTransport; // DEPRECATED use channelAuthorization instead\n authorizer?: ChannelAuthorizerGenerator; // DEPRECATED use channelAuthorization instead\n\n channelAuthorization?: ChannelAuthorizationOptions;\n userAuthentication?: UserAuthenticationOptions;\n\n cluster: string;\n enableStats?: boolean;\n disableStats?: boolean;\n disabledTransports?: Transport[];\n enabledTransports?: Transport[];\n forceTLS?: boolean;\n httpHost?: string;\n httpPath?: string;\n httpPort?: number;\n httpsPort?: number;\n ignoreNullOrigin?: boolean;\n nacl?: nacl;\n pongTimeout?: number;\n statsHost?: string;\n timelineParams?: any;\n unavailableTimeout?: number;\n wsHost?: string;\n wsPath?: string;\n wsPort?: number;\n wssPort?: number;\n}\n\nexport interface ClusterOptions {\n appKey: string;\n cluster: string;\n}\n\nexport function validateOptions(options) {\n if (options == null) {\n throw 'You must pass an options object';\n }\n if (options.cluster == null) {\n throw 'Options object must provide a cluster';\n }\n if ('disableStats' in options) {\n Logger.warn(\n 'The disableStats option is deprecated in favor of enableStats'\n );\n }\n}\n","// Copyright (C) 2016 Dmitry Chestnykh\n// MIT License. See LICENSE file for details.\n\n/**\n * Package base64 implements Base64 encoding and decoding.\n */\n\n// Invalid character used in decoding to indicate\n// that the character to decode is out of range of\n// alphabet and cannot be decoded.\nconst INVALID_BYTE = 256;\n\n/**\n * Implements standard Base64 encoding.\n *\n * Operates in constant time.\n */\nexport class Coder {\n // TODO(dchest): methods to encode chunk-by-chunk.\n\n constructor(private _paddingCharacter = \"=\") { }\n\n encodedLength(length: number): number {\n if (!this._paddingCharacter) {\n return (length * 8 + 5) / 6 | 0;\n }\n return (length + 2) / 3 * 4 | 0;\n }\n\n encode(data: Uint8Array): string {\n let out = \"\";\n\n let i = 0;\n for (; i < data.length - 2; i += 3) {\n let c = (data[i] << 16) | (data[i + 1] << 8) | (data[i + 2]);\n out += this._encodeByte((c >>> 3 * 6) & 63);\n out += this._encodeByte((c >>> 2 * 6) & 63);\n out += this._encodeByte((c >>> 1 * 6) & 63);\n out += this._encodeByte((c >>> 0 * 6) & 63);\n }\n\n const left = data.length - i;\n if (left > 0) {\n let c = (data[i] << 16) | (left === 2 ? data[i + 1] << 8 : 0);\n out += this._encodeByte((c >>> 3 * 6) & 63);\n out += this._encodeByte((c >>> 2 * 6) & 63);\n if (left === 2) {\n out += this._encodeByte((c >>> 1 * 6) & 63);\n } else {\n out += this._paddingCharacter || \"\";\n }\n out += this._paddingCharacter || \"\";\n }\n\n return out;\n }\n\n maxDecodedLength(length: number): number {\n if (!this._paddingCharacter) {\n return (length * 6 + 7) / 8 | 0;\n }\n return length / 4 * 3 | 0;\n }\n\n decodedLength(s: string): number {\n return this.maxDecodedLength(s.length - this._getPaddingLength(s));\n }\n\n decode(s: string): Uint8Array {\n if (s.length === 0) {\n return new Uint8Array(0);\n }\n const paddingLength = this._getPaddingLength(s);\n const length = s.length - paddingLength;\n const out = new Uint8Array(this.maxDecodedLength(length));\n let op = 0;\n let i = 0;\n let haveBad = 0;\n let v0 = 0, v1 = 0, v2 = 0, v3 = 0;\n for (; i < length - 4; i += 4) {\n v0 = this._decodeChar(s.charCodeAt(i + 0));\n v1 = this._decodeChar(s.charCodeAt(i + 1));\n v2 = this._decodeChar(s.charCodeAt(i + 2));\n v3 = this._decodeChar(s.charCodeAt(i + 3));\n out[op++] = (v0 << 2) | (v1 >>> 4);\n out[op++] = (v1 << 4) | (v2 >>> 2);\n out[op++] = (v2 << 6) | v3;\n haveBad |= v0 & INVALID_BYTE;\n haveBad |= v1 & INVALID_BYTE;\n haveBad |= v2 & INVALID_BYTE;\n haveBad |= v3 & INVALID_BYTE;\n }\n if (i < length - 1) {\n v0 = this._decodeChar(s.charCodeAt(i));\n v1 = this._decodeChar(s.charCodeAt(i + 1));\n out[op++] = (v0 << 2) | (v1 >>> 4);\n haveBad |= v0 & INVALID_BYTE;\n haveBad |= v1 & INVALID_BYTE;\n }\n if (i < length - 2) {\n v2 = this._decodeChar(s.charCodeAt(i + 2));\n out[op++] = (v1 << 4) | (v2 >>> 2);\n haveBad |= v2 & INVALID_BYTE;\n }\n if (i < length - 3) {\n v3 = this._decodeChar(s.charCodeAt(i + 3));\n out[op++] = (v2 << 6) | v3;\n haveBad |= v3 & INVALID_BYTE;\n }\n if (haveBad !== 0) {\n throw new Error(\"Base64Coder: incorrect characters for decoding\");\n }\n return out;\n }\n\n // Standard encoding have the following encoded/decoded ranges,\n // which we need to convert between.\n //\n // ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 0123456789 + /\n // Index: 0 - 25 26 - 51 52 - 61 62 63\n // ASCII: 65 - 90 97 - 122 48 - 57 43 47\n //\n\n // Encode 6 bits in b into a new character.\n protected _encodeByte(b: number): string {\n // Encoding uses constant time operations as follows:\n //\n // 1. Define comparison of A with B using (A - B) >>> 8:\n // if A > B, then result is positive integer\n // if A <= B, then result is 0\n //\n // 2. Define selection of C or 0 using bitwise AND: X & C:\n // if X == 0, then result is 0\n // if X != 0, then result is C\n //\n // 3. Start with the smallest comparison (b >= 0), which is always\n // true, so set the result to the starting ASCII value (65).\n //\n // 4. Continue comparing b to higher ASCII values, and selecting\n // zero if comparison isn't true, otherwise selecting a value\n // to add to result, which:\n //\n // a) undoes the previous addition\n // b) provides new value to add\n //\n let result = b;\n // b >= 0\n result += 65;\n // b > 25\n result += ((25 - b) >>> 8) & ((0 - 65) - 26 + 97);\n // b > 51\n result += ((51 - b) >>> 8) & ((26 - 97) - 52 + 48);\n // b > 61\n result += ((61 - b) >>> 8) & ((52 - 48) - 62 + 43);\n // b > 62\n result += ((62 - b) >>> 8) & ((62 - 43) - 63 + 47);\n\n return String.fromCharCode(result);\n }\n\n // Decode a character code into a byte.\n // Must return 256 if character is out of alphabet range.\n protected _decodeChar(c: number): number {\n // Decoding works similar to encoding: using the same comparison\n // function, but now it works on ranges: result is always incremented\n // by value, but this value becomes zero if the range is not\n // satisfied.\n //\n // Decoding starts with invalid value, 256, which is then\n // subtracted when the range is satisfied. If none of the ranges\n // apply, the function returns 256, which is then checked by\n // the caller to throw error.\n let result = INVALID_BYTE; // start with invalid character\n\n // c == 43 (c > 42 and c < 44)\n result += (((42 - c) & (c - 44)) >>> 8) & (-INVALID_BYTE + c - 43 + 62);\n // c == 47 (c > 46 and c < 48)\n result += (((46 - c) & (c - 48)) >>> 8) & (-INVALID_BYTE + c - 47 + 63);\n // c > 47 and c < 58\n result += (((47 - c) & (c - 58)) >>> 8) & (-INVALID_BYTE + c - 48 + 52);\n // c > 64 and c < 91\n result += (((64 - c) & (c - 91)) >>> 8) & (-INVALID_BYTE + c - 65 + 0);\n // c > 96 and c < 123\n result += (((96 - c) & (c - 123)) >>> 8) & (-INVALID_BYTE + c - 97 + 26);\n\n return result;\n }\n\n private _getPaddingLength(s: string): number {\n let paddingLength = 0;\n if (this._paddingCharacter) {\n for (let i = s.length - 1; i >= 0; i--) {\n if (s[i] !== this._paddingCharacter) {\n break;\n }\n paddingLength++;\n }\n if (s.length < 4 || paddingLength > 2) {\n throw new Error(\"Base64Coder: incorrect padding\");\n }\n }\n return paddingLength;\n }\n\n}\n\nconst stdCoder = new Coder();\n\nexport function encode(data: Uint8Array): string {\n return stdCoder.encode(data);\n}\n\nexport function decode(s: string): Uint8Array {\n return stdCoder.decode(s);\n}\n\n/**\n * Implements URL-safe Base64 encoding.\n * (Same as Base64, but '+' is replaced with '-', and '/' with '_').\n *\n * Operates in constant time.\n */\nexport class URLSafeCoder extends Coder {\n // URL-safe encoding have the following encoded/decoded ranges:\n //\n // ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 0123456789 - _\n // Index: 0 - 25 26 - 51 52 - 61 62 63\n // ASCII: 65 - 90 97 - 122 48 - 57 45 95\n //\n\n protected _encodeByte(b: number): string {\n let result = b;\n // b >= 0\n result += 65;\n // b > 25\n result += ((25 - b) >>> 8) & ((0 - 65) - 26 + 97);\n // b > 51\n result += ((51 - b) >>> 8) & ((26 - 97) - 52 + 48);\n // b > 61\n result += ((61 - b) >>> 8) & ((52 - 48) - 62 + 45);\n // b > 62\n result += ((62 - b) >>> 8) & ((62 - 45) - 63 + 95);\n\n return String.fromCharCode(result);\n }\n\n protected _decodeChar(c: number): number {\n let result = INVALID_BYTE;\n\n // c == 45 (c > 44 and c < 46)\n result += (((44 - c) & (c - 46)) >>> 8) & (-INVALID_BYTE + c - 45 + 62);\n // c == 95 (c > 94 and c < 96)\n result += (((94 - c) & (c - 96)) >>> 8) & (-INVALID_BYTE + c - 95 + 63);\n // c > 47 and c < 58\n result += (((47 - c) & (c - 58)) >>> 8) & (-INVALID_BYTE + c - 48 + 52);\n // c > 64 and c < 91\n result += (((64 - c) & (c - 91)) >>> 8) & (-INVALID_BYTE + c - 65 + 0);\n // c > 96 and c < 123\n result += (((96 - c) & (c - 123)) >>> 8) & (-INVALID_BYTE + c - 97 + 26);\n\n return result;\n }\n}\n\nconst urlSafeCoder = new URLSafeCoder();\n\nexport function encodeURLSafe(data: Uint8Array): string {\n return urlSafeCoder.encode(data);\n}\n\nexport function decodeURLSafe(s: string): Uint8Array {\n return urlSafeCoder.decode(s);\n}\n\n\nexport const encodedLength = (length: number) =>\n stdCoder.encodedLength(length);\n\nexport const maxDecodedLength = (length: number) =>\n stdCoder.maxDecodedLength(length);\n\nexport const decodedLength = (s: string) =>\n stdCoder.decodedLength(s);\n","import TimedCallback from './timed_callback';\nimport { Delay, Scheduler, Canceller } from './scheduling';\n\nabstract class Timer {\n protected clear: Canceller;\n protected timer: number | void;\n\n constructor(\n set: Scheduler,\n clear: Canceller,\n delay: Delay,\n callback: TimedCallback\n ) {\n this.clear = clear;\n this.timer = set(() => {\n if (this.timer) {\n this.timer = callback(this.timer);\n }\n }, delay);\n }\n\n /** Returns whether the timer is still running.\n *\n * @return {Boolean}\n */\n isRunning(): boolean {\n return this.timer !== null;\n }\n\n /** Aborts a timer when it's running. */\n ensureAborted() {\n if (this.timer) {\n this.clear(this.timer);\n this.timer = null;\n }\n }\n}\n\nexport default Timer;\n","module.exports = require(\"@react-native-community/netinfo\");","export default function encode(s: any): string {\n return btoa(utob(s));\n}\n\nvar fromCharCode = String.fromCharCode;\n\nvar b64chars =\n 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';\nvar b64tab = {};\n\nfor (var i = 0, l = b64chars.length; i < l; i++) {\n b64tab[b64chars.charAt(i)] = i;\n}\n\nvar cb_utob = function(c) {\n var cc = c.charCodeAt(0);\n return cc < 0x80\n ? c\n : cc < 0x800\n ? fromCharCode(0xc0 | (cc >>> 6)) + fromCharCode(0x80 | (cc & 0x3f))\n : fromCharCode(0xe0 | ((cc >>> 12) & 0x0f)) +\n fromCharCode(0x80 | ((cc >>> 6) & 0x3f)) +\n fromCharCode(0x80 | (cc & 0x3f));\n};\n\nvar utob = function(u) {\n return u.replace(/[^\\x00-\\x7F]/g, cb_utob);\n};\n\nvar cb_encode = function(ccc) {\n var padlen = [0, 2, 1][ccc.length % 3];\n var ord =\n (ccc.charCodeAt(0) << 16) |\n ((ccc.length > 1 ? ccc.charCodeAt(1) : 0) << 8) |\n (ccc.length > 2 ? ccc.charCodeAt(2) : 0);\n var chars = [\n b64chars.charAt(ord >>> 18),\n b64chars.charAt((ord >>> 12) & 63),\n padlen >= 2 ? '=' : b64chars.charAt((ord >>> 6) & 63),\n padlen >= 1 ? '=' : b64chars.charAt(ord & 63)\n ];\n return chars.join('');\n};\n\nvar btoa =\n global.btoa ||\n function(b) {\n return b.replace(/[\\s\\S]{1,3}/g, cb_encode);\n };\n","import Callback from './callback';\nimport * as Collections from '../utils/collections';\nimport CallbackTable from './callback_table';\n\nexport default class CallbackRegistry {\n _callbacks: CallbackTable;\n\n constructor() {\n this._callbacks = {};\n }\n\n get(name: string): Callback[] {\n return this._callbacks[prefix(name)];\n }\n\n add(name: string, callback: Function, context: any) {\n var prefixedEventName = prefix(name);\n this._callbacks[prefixedEventName] =\n this._callbacks[prefixedEventName] || [];\n this._callbacks[prefixedEventName].push({\n fn: callback,\n context: context\n });\n }\n\n remove(name?: string, callback?: Function, context?: any) {\n if (!name && !callback && !context) {\n this._callbacks = {};\n return;\n }\n\n var names = name ? [prefix(name)] : Collections.keys(this._callbacks);\n\n if (callback || context) {\n this.removeCallback(names, callback, context);\n } else {\n this.removeAllCallbacks(names);\n }\n }\n\n private removeCallback(names: string[], callback: Function, context: any) {\n Collections.apply(\n names,\n function(name) {\n this._callbacks[name] = Collections.filter(\n this._callbacks[name] || [],\n function(binding) {\n return (\n (callback && callback !== binding.fn) ||\n (context && context !== binding.context)\n );\n }\n );\n if (this._callbacks[name].length === 0) {\n delete this._callbacks[name];\n }\n },\n this\n );\n }\n\n private removeAllCallbacks(names: string[]) {\n Collections.apply(\n names,\n function(name) {\n delete this._callbacks[name];\n },\n this\n );\n }\n}\n\nfunction prefix(name: string): string {\n return '_' + name;\n}\n","// Copyright (C) 2016 Dmitry Chestnykh\n// MIT License. See LICENSE file for details.\n\n/**\n * Package utf8 implements UTF-8 encoding and decoding.\n */\n\nconst INVALID_UTF16 = \"utf8: invalid string\";\nconst INVALID_UTF8 = \"utf8: invalid source encoding\";\n\n/**\n * Encodes the given string into UTF-8 byte array.\n * Throws if the source string has invalid UTF-16 encoding.\n */\nexport function encode(s: string): Uint8Array {\n // Calculate result length and allocate output array.\n // encodedLength() also validates string and throws errors,\n // so we don't need repeat validation here.\n const arr = new Uint8Array(encodedLength(s));\n\n let pos = 0;\n for (let i = 0; i < s.length; i++) {\n let c = s.charCodeAt(i);\n if (c < 0x80) {\n arr[pos++] = c;\n } else if (c < 0x800) {\n arr[pos++] = 0xc0 | c >> 6;\n arr[pos++] = 0x80 | c & 0x3f;\n } else if (c < 0xd800) {\n arr[pos++] = 0xe0 | c >> 12;\n arr[pos++] = 0x80 | (c >> 6) & 0x3f;\n arr[pos++] = 0x80 | c & 0x3f;\n } else {\n i++; // get one more character\n c = (c & 0x3ff) << 10;\n c |= s.charCodeAt(i) & 0x3ff;\n c += 0x10000;\n\n arr[pos++] = 0xf0 | c >> 18;\n arr[pos++] = 0x80 | (c >> 12) & 0x3f;\n arr[pos++] = 0x80 | (c >> 6) & 0x3f;\n arr[pos++] = 0x80 | c & 0x3f;\n }\n }\n return arr;\n}\n\n/**\n * Returns the number of bytes required to encode the given string into UTF-8.\n * Throws if the source string has invalid UTF-16 encoding.\n */\nexport function encodedLength(s: string): number {\n let result = 0;\n for (let i = 0; i < s.length; i++) {\n const c = s.charCodeAt(i);\n if (c < 0x80) {\n result += 1;\n } else if (c < 0x800) {\n result += 2;\n } else if (c < 0xd800) {\n result += 3;\n } else if (c <= 0xdfff) {\n if (i >= s.length - 1) {\n throw new Error(INVALID_UTF16);\n }\n i++; // \"eat\" next character\n result += 4;\n } else {\n throw new Error(INVALID_UTF16);\n }\n }\n return result;\n}\n\n/**\n * Decodes the given byte array from UTF-8 into a string.\n * Throws if encoding is invalid.\n */\nexport function decode(arr: Uint8Array): string {\n const chars: string[] = [];\n for (let i = 0; i < arr.length; i++) {\n let b = arr[i];\n\n if (b & 0x80) {\n let min;\n if (b < 0xe0) {\n // Need 1 more byte.\n if (i >= arr.length) {\n throw new Error(INVALID_UTF8);\n }\n const n1 = arr[++i];\n if ((n1 & 0xc0) !== 0x80) {\n throw new Error(INVALID_UTF8);\n }\n b = (b & 0x1f) << 6 | (n1 & 0x3f);\n min = 0x80;\n } else if (b < 0xf0) {\n // Need 2 more bytes.\n if (i >= arr.length - 1) {\n throw new Error(INVALID_UTF8);\n }\n const n1 = arr[++i];\n const n2 = arr[++i];\n if ((n1 & 0xc0) !== 0x80 || (n2 & 0xc0) !== 0x80) {\n throw new Error(INVALID_UTF8);\n }\n b = (b & 0x0f) << 12 | (n1 & 0x3f) << 6 | (n2 & 0x3f);\n min = 0x800;\n } else if (b < 0xf8) {\n // Need 3 more bytes.\n if (i >= arr.length - 2) {\n throw new Error(INVALID_UTF8);\n }\n const n1 = arr[++i];\n const n2 = arr[++i];\n const n3 = arr[++i];\n if ((n1 & 0xc0) !== 0x80 || (n2 & 0xc0) !== 0x80 || (n3 & 0xc0) !== 0x80) {\n throw new Error(INVALID_UTF8);\n }\n b = (b & 0x0f) << 18 | (n1 & 0x3f) << 12 | (n2 & 0x3f) << 6 | (n3 & 0x3f);\n min = 0x10000;\n } else {\n throw new Error(INVALID_UTF8);\n }\n\n if (b < min || (b >= 0xd800 && b <= 0xdfff)) {\n throw new Error(INVALID_UTF8);\n }\n\n if (b >= 0x10000) {\n // Surrogate pair.\n if (b > 0x10ffff) {\n throw new Error(INVALID_UTF8);\n }\n b -= 0x10000;\n chars.push(String.fromCharCode(0xd800 | (b >> 10)));\n b = 0xdc00 | (b & 0x3ff);\n }\n }\n\n chars.push(String.fromCharCode(b));\n }\n return chars.join(\"\");\n}\n","(function(nacl) {\n'use strict';\n\n// Ported in 2014 by Dmitry Chestnykh and Devi Mandiri.\n// Public domain.\n//\n// Implementation derived from TweetNaCl version 20140427.\n// See for details: http://tweetnacl.cr.yp.to/\n\nvar gf = function(init) {\n var i, r = new Float64Array(16);\n if (init) for (i = 0; i < init.length; i++) r[i] = init[i];\n return r;\n};\n\n// Pluggable, initialized in high-level API below.\nvar randombytes = function(/* x, n */) { throw new Error('no PRNG'); };\n\nvar _0 = new Uint8Array(16);\nvar _9 = new Uint8Array(32); _9[0] = 9;\n\nvar gf0 = gf(),\n gf1 = gf([1]),\n _121665 = gf([0xdb41, 1]),\n D = gf([0x78a3, 0x1359, 0x4dca, 0x75eb, 0xd8ab, 0x4141, 0x0a4d, 0x0070, 0xe898, 0x7779, 0x4079, 0x8cc7, 0xfe73, 0x2b6f, 0x6cee, 0x5203]),\n D2 = gf([0xf159, 0x26b2, 0x9b94, 0xebd6, 0xb156, 0x8283, 0x149a, 0x00e0, 0xd130, 0xeef3, 0x80f2, 0x198e, 0xfce7, 0x56df, 0xd9dc, 0x2406]),\n X = gf([0xd51a, 0x8f25, 0x2d60, 0xc956, 0xa7b2, 0x9525, 0xc760, 0x692c, 0xdc5c, 0xfdd6, 0xe231, 0xc0a4, 0x53fe, 0xcd6e, 0x36d3, 0x2169]),\n Y = gf([0x6658, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666]),\n I = gf([0xa0b0, 0x4a0e, 0x1b27, 0xc4ee, 0xe478, 0xad2f, 0x1806, 0x2f43, 0xd7a7, 0x3dfb, 0x0099, 0x2b4d, 0xdf0b, 0x4fc1, 0x2480, 0x2b83]);\n\nfunction ts64(x, i, h, l) {\n x[i] = (h >> 24) & 0xff;\n x[i+1] = (h >> 16) & 0xff;\n x[i+2] = (h >> 8) & 0xff;\n x[i+3] = h & 0xff;\n x[i+4] = (l >> 24) & 0xff;\n x[i+5] = (l >> 16) & 0xff;\n x[i+6] = (l >> 8) & 0xff;\n x[i+7] = l & 0xff;\n}\n\nfunction vn(x, xi, y, yi, n) {\n var i,d = 0;\n for (i = 0; i < n; i++) d |= x[xi+i]^y[yi+i];\n return (1 & ((d - 1) >>> 8)) - 1;\n}\n\nfunction crypto_verify_16(x, xi, y, yi) {\n return vn(x,xi,y,yi,16);\n}\n\nfunction crypto_verify_32(x, xi, y, yi) {\n return vn(x,xi,y,yi,32);\n}\n\nfunction core_salsa20(o, p, k, c) {\n var j0 = c[ 0] & 0xff | (c[ 1] & 0xff)<<8 | (c[ 2] & 0xff)<<16 | (c[ 3] & 0xff)<<24,\n j1 = k[ 0] & 0xff | (k[ 1] & 0xff)<<8 | (k[ 2] & 0xff)<<16 | (k[ 3] & 0xff)<<24,\n j2 = k[ 4] & 0xff | (k[ 5] & 0xff)<<8 | (k[ 6] & 0xff)<<16 | (k[ 7] & 0xff)<<24,\n j3 = k[ 8] & 0xff | (k[ 9] & 0xff)<<8 | (k[10] & 0xff)<<16 | (k[11] & 0xff)<<24,\n j4 = k[12] & 0xff | (k[13] & 0xff)<<8 | (k[14] & 0xff)<<16 | (k[15] & 0xff)<<24,\n j5 = c[ 4] & 0xff | (c[ 5] & 0xff)<<8 | (c[ 6] & 0xff)<<16 | (c[ 7] & 0xff)<<24,\n j6 = p[ 0] & 0xff | (p[ 1] & 0xff)<<8 | (p[ 2] & 0xff)<<16 | (p[ 3] & 0xff)<<24,\n j7 = p[ 4] & 0xff | (p[ 5] & 0xff)<<8 | (p[ 6] & 0xff)<<16 | (p[ 7] & 0xff)<<24,\n j8 = p[ 8] & 0xff | (p[ 9] & 0xff)<<8 | (p[10] & 0xff)<<16 | (p[11] & 0xff)<<24,\n j9 = p[12] & 0xff | (p[13] & 0xff)<<8 | (p[14] & 0xff)<<16 | (p[15] & 0xff)<<24,\n j10 = c[ 8] & 0xff | (c[ 9] & 0xff)<<8 | (c[10] & 0xff)<<16 | (c[11] & 0xff)<<24,\n j11 = k[16] & 0xff | (k[17] & 0xff)<<8 | (k[18] & 0xff)<<16 | (k[19] & 0xff)<<24,\n j12 = k[20] & 0xff | (k[21] & 0xff)<<8 | (k[22] & 0xff)<<16 | (k[23] & 0xff)<<24,\n j13 = k[24] & 0xff | (k[25] & 0xff)<<8 | (k[26] & 0xff)<<16 | (k[27] & 0xff)<<24,\n j14 = k[28] & 0xff | (k[29] & 0xff)<<8 | (k[30] & 0xff)<<16 | (k[31] & 0xff)<<24,\n j15 = c[12] & 0xff | (c[13] & 0xff)<<8 | (c[14] & 0xff)<<16 | (c[15] & 0xff)<<24;\n\n var x0 = j0, x1 = j1, x2 = j2, x3 = j3, x4 = j4, x5 = j5, x6 = j6, x7 = j7,\n x8 = j8, x9 = j9, x10 = j10, x11 = j11, x12 = j12, x13 = j13, x14 = j14,\n x15 = j15, u;\n\n for (var i = 0; i < 20; i += 2) {\n u = x0 + x12 | 0;\n x4 ^= u<<7 | u>>>(32-7);\n u = x4 + x0 | 0;\n x8 ^= u<<9 | u>>>(32-9);\n u = x8 + x4 | 0;\n x12 ^= u<<13 | u>>>(32-13);\n u = x12 + x8 | 0;\n x0 ^= u<<18 | u>>>(32-18);\n\n u = x5 + x1 | 0;\n x9 ^= u<<7 | u>>>(32-7);\n u = x9 + x5 | 0;\n x13 ^= u<<9 | u>>>(32-9);\n u = x13 + x9 | 0;\n x1 ^= u<<13 | u>>>(32-13);\n u = x1 + x13 | 0;\n x5 ^= u<<18 | u>>>(32-18);\n\n u = x10 + x6 | 0;\n x14 ^= u<<7 | u>>>(32-7);\n u = x14 + x10 | 0;\n x2 ^= u<<9 | u>>>(32-9);\n u = x2 + x14 | 0;\n x6 ^= u<<13 | u>>>(32-13);\n u = x6 + x2 | 0;\n x10 ^= u<<18 | u>>>(32-18);\n\n u = x15 + x11 | 0;\n x3 ^= u<<7 | u>>>(32-7);\n u = x3 + x15 | 0;\n x7 ^= u<<9 | u>>>(32-9);\n u = x7 + x3 | 0;\n x11 ^= u<<13 | u>>>(32-13);\n u = x11 + x7 | 0;\n x15 ^= u<<18 | u>>>(32-18);\n\n u = x0 + x3 | 0;\n x1 ^= u<<7 | u>>>(32-7);\n u = x1 + x0 | 0;\n x2 ^= u<<9 | u>>>(32-9);\n u = x2 + x1 | 0;\n x3 ^= u<<13 | u>>>(32-13);\n u = x3 + x2 | 0;\n x0 ^= u<<18 | u>>>(32-18);\n\n u = x5 + x4 | 0;\n x6 ^= u<<7 | u>>>(32-7);\n u = x6 + x5 | 0;\n x7 ^= u<<9 | u>>>(32-9);\n u = x7 + x6 | 0;\n x4 ^= u<<13 | u>>>(32-13);\n u = x4 + x7 | 0;\n x5 ^= u<<18 | u>>>(32-18);\n\n u = x10 + x9 | 0;\n x11 ^= u<<7 | u>>>(32-7);\n u = x11 + x10 | 0;\n x8 ^= u<<9 | u>>>(32-9);\n u = x8 + x11 | 0;\n x9 ^= u<<13 | u>>>(32-13);\n u = x9 + x8 | 0;\n x10 ^= u<<18 | u>>>(32-18);\n\n u = x15 + x14 | 0;\n x12 ^= u<<7 | u>>>(32-7);\n u = x12 + x15 | 0;\n x13 ^= u<<9 | u>>>(32-9);\n u = x13 + x12 | 0;\n x14 ^= u<<13 | u>>>(32-13);\n u = x14 + x13 | 0;\n x15 ^= u<<18 | u>>>(32-18);\n }\n x0 = x0 + j0 | 0;\n x1 = x1 + j1 | 0;\n x2 = x2 + j2 | 0;\n x3 = x3 + j3 | 0;\n x4 = x4 + j4 | 0;\n x5 = x5 + j5 | 0;\n x6 = x6 + j6 | 0;\n x7 = x7 + j7 | 0;\n x8 = x8 + j8 | 0;\n x9 = x9 + j9 | 0;\n x10 = x10 + j10 | 0;\n x11 = x11 + j11 | 0;\n x12 = x12 + j12 | 0;\n x13 = x13 + j13 | 0;\n x14 = x14 + j14 | 0;\n x15 = x15 + j15 | 0;\n\n o[ 0] = x0 >>> 0 & 0xff;\n o[ 1] = x0 >>> 8 & 0xff;\n o[ 2] = x0 >>> 16 & 0xff;\n o[ 3] = x0 >>> 24 & 0xff;\n\n o[ 4] = x1 >>> 0 & 0xff;\n o[ 5] = x1 >>> 8 & 0xff;\n o[ 6] = x1 >>> 16 & 0xff;\n o[ 7] = x1 >>> 24 & 0xff;\n\n o[ 8] = x2 >>> 0 & 0xff;\n o[ 9] = x2 >>> 8 & 0xff;\n o[10] = x2 >>> 16 & 0xff;\n o[11] = x2 >>> 24 & 0xff;\n\n o[12] = x3 >>> 0 & 0xff;\n o[13] = x3 >>> 8 & 0xff;\n o[14] = x3 >>> 16 & 0xff;\n o[15] = x3 >>> 24 & 0xff;\n\n o[16] = x4 >>> 0 & 0xff;\n o[17] = x4 >>> 8 & 0xff;\n o[18] = x4 >>> 16 & 0xff;\n o[19] = x4 >>> 24 & 0xff;\n\n o[20] = x5 >>> 0 & 0xff;\n o[21] = x5 >>> 8 & 0xff;\n o[22] = x5 >>> 16 & 0xff;\n o[23] = x5 >>> 24 & 0xff;\n\n o[24] = x6 >>> 0 & 0xff;\n o[25] = x6 >>> 8 & 0xff;\n o[26] = x6 >>> 16 & 0xff;\n o[27] = x6 >>> 24 & 0xff;\n\n o[28] = x7 >>> 0 & 0xff;\n o[29] = x7 >>> 8 & 0xff;\n o[30] = x7 >>> 16 & 0xff;\n o[31] = x7 >>> 24 & 0xff;\n\n o[32] = x8 >>> 0 & 0xff;\n o[33] = x8 >>> 8 & 0xff;\n o[34] = x8 >>> 16 & 0xff;\n o[35] = x8 >>> 24 & 0xff;\n\n o[36] = x9 >>> 0 & 0xff;\n o[37] = x9 >>> 8 & 0xff;\n o[38] = x9 >>> 16 & 0xff;\n o[39] = x9 >>> 24 & 0xff;\n\n o[40] = x10 >>> 0 & 0xff;\n o[41] = x10 >>> 8 & 0xff;\n o[42] = x10 >>> 16 & 0xff;\n o[43] = x10 >>> 24 & 0xff;\n\n o[44] = x11 >>> 0 & 0xff;\n o[45] = x11 >>> 8 & 0xff;\n o[46] = x11 >>> 16 & 0xff;\n o[47] = x11 >>> 24 & 0xff;\n\n o[48] = x12 >>> 0 & 0xff;\n o[49] = x12 >>> 8 & 0xff;\n o[50] = x12 >>> 16 & 0xff;\n o[51] = x12 >>> 24 & 0xff;\n\n o[52] = x13 >>> 0 & 0xff;\n o[53] = x13 >>> 8 & 0xff;\n o[54] = x13 >>> 16 & 0xff;\n o[55] = x13 >>> 24 & 0xff;\n\n o[56] = x14 >>> 0 & 0xff;\n o[57] = x14 >>> 8 & 0xff;\n o[58] = x14 >>> 16 & 0xff;\n o[59] = x14 >>> 24 & 0xff;\n\n o[60] = x15 >>> 0 & 0xff;\n o[61] = x15 >>> 8 & 0xff;\n o[62] = x15 >>> 16 & 0xff;\n o[63] = x15 >>> 24 & 0xff;\n}\n\nfunction core_hsalsa20(o,p,k,c) {\n var j0 = c[ 0] & 0xff | (c[ 1] & 0xff)<<8 | (c[ 2] & 0xff)<<16 | (c[ 3] & 0xff)<<24,\n j1 = k[ 0] & 0xff | (k[ 1] & 0xff)<<8 | (k[ 2] & 0xff)<<16 | (k[ 3] & 0xff)<<24,\n j2 = k[ 4] & 0xff | (k[ 5] & 0xff)<<8 | (k[ 6] & 0xff)<<16 | (k[ 7] & 0xff)<<24,\n j3 = k[ 8] & 0xff | (k[ 9] & 0xff)<<8 | (k[10] & 0xff)<<16 | (k[11] & 0xff)<<24,\n j4 = k[12] & 0xff | (k[13] & 0xff)<<8 | (k[14] & 0xff)<<16 | (k[15] & 0xff)<<24,\n j5 = c[ 4] & 0xff | (c[ 5] & 0xff)<<8 | (c[ 6] & 0xff)<<16 | (c[ 7] & 0xff)<<24,\n j6 = p[ 0] & 0xff | (p[ 1] & 0xff)<<8 | (p[ 2] & 0xff)<<16 | (p[ 3] & 0xff)<<24,\n j7 = p[ 4] & 0xff | (p[ 5] & 0xff)<<8 | (p[ 6] & 0xff)<<16 | (p[ 7] & 0xff)<<24,\n j8 = p[ 8] & 0xff | (p[ 9] & 0xff)<<8 | (p[10] & 0xff)<<16 | (p[11] & 0xff)<<24,\n j9 = p[12] & 0xff | (p[13] & 0xff)<<8 | (p[14] & 0xff)<<16 | (p[15] & 0xff)<<24,\n j10 = c[ 8] & 0xff | (c[ 9] & 0xff)<<8 | (c[10] & 0xff)<<16 | (c[11] & 0xff)<<24,\n j11 = k[16] & 0xff | (k[17] & 0xff)<<8 | (k[18] & 0xff)<<16 | (k[19] & 0xff)<<24,\n j12 = k[20] & 0xff | (k[21] & 0xff)<<8 | (k[22] & 0xff)<<16 | (k[23] & 0xff)<<24,\n j13 = k[24] & 0xff | (k[25] & 0xff)<<8 | (k[26] & 0xff)<<16 | (k[27] & 0xff)<<24,\n j14 = k[28] & 0xff | (k[29] & 0xff)<<8 | (k[30] & 0xff)<<16 | (k[31] & 0xff)<<24,\n j15 = c[12] & 0xff | (c[13] & 0xff)<<8 | (c[14] & 0xff)<<16 | (c[15] & 0xff)<<24;\n\n var x0 = j0, x1 = j1, x2 = j2, x3 = j3, x4 = j4, x5 = j5, x6 = j6, x7 = j7,\n x8 = j8, x9 = j9, x10 = j10, x11 = j11, x12 = j12, x13 = j13, x14 = j14,\n x15 = j15, u;\n\n for (var i = 0; i < 20; i += 2) {\n u = x0 + x12 | 0;\n x4 ^= u<<7 | u>>>(32-7);\n u = x4 + x0 | 0;\n x8 ^= u<<9 | u>>>(32-9);\n u = x8 + x4 | 0;\n x12 ^= u<<13 | u>>>(32-13);\n u = x12 + x8 | 0;\n x0 ^= u<<18 | u>>>(32-18);\n\n u = x5 + x1 | 0;\n x9 ^= u<<7 | u>>>(32-7);\n u = x9 + x5 | 0;\n x13 ^= u<<9 | u>>>(32-9);\n u = x13 + x9 | 0;\n x1 ^= u<<13 | u>>>(32-13);\n u = x1 + x13 | 0;\n x5 ^= u<<18 | u>>>(32-18);\n\n u = x10 + x6 | 0;\n x14 ^= u<<7 | u>>>(32-7);\n u = x14 + x10 | 0;\n x2 ^= u<<9 | u>>>(32-9);\n u = x2 + x14 | 0;\n x6 ^= u<<13 | u>>>(32-13);\n u = x6 + x2 | 0;\n x10 ^= u<<18 | u>>>(32-18);\n\n u = x15 + x11 | 0;\n x3 ^= u<<7 | u>>>(32-7);\n u = x3 + x15 | 0;\n x7 ^= u<<9 | u>>>(32-9);\n u = x7 + x3 | 0;\n x11 ^= u<<13 | u>>>(32-13);\n u = x11 + x7 | 0;\n x15 ^= u<<18 | u>>>(32-18);\n\n u = x0 + x3 | 0;\n x1 ^= u<<7 | u>>>(32-7);\n u = x1 + x0 | 0;\n x2 ^= u<<9 | u>>>(32-9);\n u = x2 + x1 | 0;\n x3 ^= u<<13 | u>>>(32-13);\n u = x3 + x2 | 0;\n x0 ^= u<<18 | u>>>(32-18);\n\n u = x5 + x4 | 0;\n x6 ^= u<<7 | u>>>(32-7);\n u = x6 + x5 | 0;\n x7 ^= u<<9 | u>>>(32-9);\n u = x7 + x6 | 0;\n x4 ^= u<<13 | u>>>(32-13);\n u = x4 + x7 | 0;\n x5 ^= u<<18 | u>>>(32-18);\n\n u = x10 + x9 | 0;\n x11 ^= u<<7 | u>>>(32-7);\n u = x11 + x10 | 0;\n x8 ^= u<<9 | u>>>(32-9);\n u = x8 + x11 | 0;\n x9 ^= u<<13 | u>>>(32-13);\n u = x9 + x8 | 0;\n x10 ^= u<<18 | u>>>(32-18);\n\n u = x15 + x14 | 0;\n x12 ^= u<<7 | u>>>(32-7);\n u = x12 + x15 | 0;\n x13 ^= u<<9 | u>>>(32-9);\n u = x13 + x12 | 0;\n x14 ^= u<<13 | u>>>(32-13);\n u = x14 + x13 | 0;\n x15 ^= u<<18 | u>>>(32-18);\n }\n\n o[ 0] = x0 >>> 0 & 0xff;\n o[ 1] = x0 >>> 8 & 0xff;\n o[ 2] = x0 >>> 16 & 0xff;\n o[ 3] = x0 >>> 24 & 0xff;\n\n o[ 4] = x5 >>> 0 & 0xff;\n o[ 5] = x5 >>> 8 & 0xff;\n o[ 6] = x5 >>> 16 & 0xff;\n o[ 7] = x5 >>> 24 & 0xff;\n\n o[ 8] = x10 >>> 0 & 0xff;\n o[ 9] = x10 >>> 8 & 0xff;\n o[10] = x10 >>> 16 & 0xff;\n o[11] = x10 >>> 24 & 0xff;\n\n o[12] = x15 >>> 0 & 0xff;\n o[13] = x15 >>> 8 & 0xff;\n o[14] = x15 >>> 16 & 0xff;\n o[15] = x15 >>> 24 & 0xff;\n\n o[16] = x6 >>> 0 & 0xff;\n o[17] = x6 >>> 8 & 0xff;\n o[18] = x6 >>> 16 & 0xff;\n o[19] = x6 >>> 24 & 0xff;\n\n o[20] = x7 >>> 0 & 0xff;\n o[21] = x7 >>> 8 & 0xff;\n o[22] = x7 >>> 16 & 0xff;\n o[23] = x7 >>> 24 & 0xff;\n\n o[24] = x8 >>> 0 & 0xff;\n o[25] = x8 >>> 8 & 0xff;\n o[26] = x8 >>> 16 & 0xff;\n o[27] = x8 >>> 24 & 0xff;\n\n o[28] = x9 >>> 0 & 0xff;\n o[29] = x9 >>> 8 & 0xff;\n o[30] = x9 >>> 16 & 0xff;\n o[31] = x9 >>> 24 & 0xff;\n}\n\nfunction crypto_core_salsa20(out,inp,k,c) {\n core_salsa20(out,inp,k,c);\n}\n\nfunction crypto_core_hsalsa20(out,inp,k,c) {\n core_hsalsa20(out,inp,k,c);\n}\n\nvar sigma = new Uint8Array([101, 120, 112, 97, 110, 100, 32, 51, 50, 45, 98, 121, 116, 101, 32, 107]);\n // \"expand 32-byte k\"\n\nfunction crypto_stream_salsa20_xor(c,cpos,m,mpos,b,n,k) {\n var z = new Uint8Array(16), x = new Uint8Array(64);\n var u, i;\n for (i = 0; i < 16; i++) z[i] = 0;\n for (i = 0; i < 8; i++) z[i] = n[i];\n while (b >= 64) {\n crypto_core_salsa20(x,z,k,sigma);\n for (i = 0; i < 64; i++) c[cpos+i] = m[mpos+i] ^ x[i];\n u = 1;\n for (i = 8; i < 16; i++) {\n u = u + (z[i] & 0xff) | 0;\n z[i] = u & 0xff;\n u >>>= 8;\n }\n b -= 64;\n cpos += 64;\n mpos += 64;\n }\n if (b > 0) {\n crypto_core_salsa20(x,z,k,sigma);\n for (i = 0; i < b; i++) c[cpos+i] = m[mpos+i] ^ x[i];\n }\n return 0;\n}\n\nfunction crypto_stream_salsa20(c,cpos,b,n,k) {\n var z = new Uint8Array(16), x = new Uint8Array(64);\n var u, i;\n for (i = 0; i < 16; i++) z[i] = 0;\n for (i = 0; i < 8; i++) z[i] = n[i];\n while (b >= 64) {\n crypto_core_salsa20(x,z,k,sigma);\n for (i = 0; i < 64; i++) c[cpos+i] = x[i];\n u = 1;\n for (i = 8; i < 16; i++) {\n u = u + (z[i] & 0xff) | 0;\n z[i] = u & 0xff;\n u >>>= 8;\n }\n b -= 64;\n cpos += 64;\n }\n if (b > 0) {\n crypto_core_salsa20(x,z,k,sigma);\n for (i = 0; i < b; i++) c[cpos+i] = x[i];\n }\n return 0;\n}\n\nfunction crypto_stream(c,cpos,d,n,k) {\n var s = new Uint8Array(32);\n crypto_core_hsalsa20(s,n,k,sigma);\n var sn = new Uint8Array(8);\n for (var i = 0; i < 8; i++) sn[i] = n[i+16];\n return crypto_stream_salsa20(c,cpos,d,sn,s);\n}\n\nfunction crypto_stream_xor(c,cpos,m,mpos,d,n,k) {\n var s = new Uint8Array(32);\n crypto_core_hsalsa20(s,n,k,sigma);\n var sn = new Uint8Array(8);\n for (var i = 0; i < 8; i++) sn[i] = n[i+16];\n return crypto_stream_salsa20_xor(c,cpos,m,mpos,d,sn,s);\n}\n\n/*\n* Port of Andrew Moon's Poly1305-donna-16. Public domain.\n* https://github.com/floodyberry/poly1305-donna\n*/\n\nvar poly1305 = function(key) {\n this.buffer = new Uint8Array(16);\n this.r = new Uint16Array(10);\n this.h = new Uint16Array(10);\n this.pad = new Uint16Array(8);\n this.leftover = 0;\n this.fin = 0;\n\n var t0, t1, t2, t3, t4, t5, t6, t7;\n\n t0 = key[ 0] & 0xff | (key[ 1] & 0xff) << 8; this.r[0] = ( t0 ) & 0x1fff;\n t1 = key[ 2] & 0xff | (key[ 3] & 0xff) << 8; this.r[1] = ((t0 >>> 13) | (t1 << 3)) & 0x1fff;\n t2 = key[ 4] & 0xff | (key[ 5] & 0xff) << 8; this.r[2] = ((t1 >>> 10) | (t2 << 6)) & 0x1f03;\n t3 = key[ 6] & 0xff | (key[ 7] & 0xff) << 8; this.r[3] = ((t2 >>> 7) | (t3 << 9)) & 0x1fff;\n t4 = key[ 8] & 0xff | (key[ 9] & 0xff) << 8; this.r[4] = ((t3 >>> 4) | (t4 << 12)) & 0x00ff;\n this.r[5] = ((t4 >>> 1)) & 0x1ffe;\n t5 = key[10] & 0xff | (key[11] & 0xff) << 8; this.r[6] = ((t4 >>> 14) | (t5 << 2)) & 0x1fff;\n t6 = key[12] & 0xff | (key[13] & 0xff) << 8; this.r[7] = ((t5 >>> 11) | (t6 << 5)) & 0x1f81;\n t7 = key[14] & 0xff | (key[15] & 0xff) << 8; this.r[8] = ((t6 >>> 8) | (t7 << 8)) & 0x1fff;\n this.r[9] = ((t7 >>> 5)) & 0x007f;\n\n this.pad[0] = key[16] & 0xff | (key[17] & 0xff) << 8;\n this.pad[1] = key[18] & 0xff | (key[19] & 0xff) << 8;\n this.pad[2] = key[20] & 0xff | (key[21] & 0xff) << 8;\n this.pad[3] = key[22] & 0xff | (key[23] & 0xff) << 8;\n this.pad[4] = key[24] & 0xff | (key[25] & 0xff) << 8;\n this.pad[5] = key[26] & 0xff | (key[27] & 0xff) << 8;\n this.pad[6] = key[28] & 0xff | (key[29] & 0xff) << 8;\n this.pad[7] = key[30] & 0xff | (key[31] & 0xff) << 8;\n};\n\npoly1305.prototype.blocks = function(m, mpos, bytes) {\n var hibit = this.fin ? 0 : (1 << 11);\n var t0, t1, t2, t3, t4, t5, t6, t7, c;\n var d0, d1, d2, d3, d4, d5, d6, d7, d8, d9;\n\n var h0 = this.h[0],\n h1 = this.h[1],\n h2 = this.h[2],\n h3 = this.h[3],\n h4 = this.h[4],\n h5 = this.h[5],\n h6 = this.h[6],\n h7 = this.h[7],\n h8 = this.h[8],\n h9 = this.h[9];\n\n var r0 = this.r[0],\n r1 = this.r[1],\n r2 = this.r[2],\n r3 = this.r[3],\n r4 = this.r[4],\n r5 = this.r[5],\n r6 = this.r[6],\n r7 = this.r[7],\n r8 = this.r[8],\n r9 = this.r[9];\n\n while (bytes >= 16) {\n t0 = m[mpos+ 0] & 0xff | (m[mpos+ 1] & 0xff) << 8; h0 += ( t0 ) & 0x1fff;\n t1 = m[mpos+ 2] & 0xff | (m[mpos+ 3] & 0xff) << 8; h1 += ((t0 >>> 13) | (t1 << 3)) & 0x1fff;\n t2 = m[mpos+ 4] & 0xff | (m[mpos+ 5] & 0xff) << 8; h2 += ((t1 >>> 10) | (t2 << 6)) & 0x1fff;\n t3 = m[mpos+ 6] & 0xff | (m[mpos+ 7] & 0xff) << 8; h3 += ((t2 >>> 7) | (t3 << 9)) & 0x1fff;\n t4 = m[mpos+ 8] & 0xff | (m[mpos+ 9] & 0xff) << 8; h4 += ((t3 >>> 4) | (t4 << 12)) & 0x1fff;\n h5 += ((t4 >>> 1)) & 0x1fff;\n t5 = m[mpos+10] & 0xff | (m[mpos+11] & 0xff) << 8; h6 += ((t4 >>> 14) | (t5 << 2)) & 0x1fff;\n t6 = m[mpos+12] & 0xff | (m[mpos+13] & 0xff) << 8; h7 += ((t5 >>> 11) | (t6 << 5)) & 0x1fff;\n t7 = m[mpos+14] & 0xff | (m[mpos+15] & 0xff) << 8; h8 += ((t6 >>> 8) | (t7 << 8)) & 0x1fff;\n h9 += ((t7 >>> 5)) | hibit;\n\n c = 0;\n\n d0 = c;\n d0 += h0 * r0;\n d0 += h1 * (5 * r9);\n d0 += h2 * (5 * r8);\n d0 += h3 * (5 * r7);\n d0 += h4 * (5 * r6);\n c = (d0 >>> 13); d0 &= 0x1fff;\n d0 += h5 * (5 * r5);\n d0 += h6 * (5 * r4);\n d0 += h7 * (5 * r3);\n d0 += h8 * (5 * r2);\n d0 += h9 * (5 * r1);\n c += (d0 >>> 13); d0 &= 0x1fff;\n\n d1 = c;\n d1 += h0 * r1;\n d1 += h1 * r0;\n d1 += h2 * (5 * r9);\n d1 += h3 * (5 * r8);\n d1 += h4 * (5 * r7);\n c = (d1 >>> 13); d1 &= 0x1fff;\n d1 += h5 * (5 * r6);\n d1 += h6 * (5 * r5);\n d1 += h7 * (5 * r4);\n d1 += h8 * (5 * r3);\n d1 += h9 * (5 * r2);\n c += (d1 >>> 13); d1 &= 0x1fff;\n\n d2 = c;\n d2 += h0 * r2;\n d2 += h1 * r1;\n d2 += h2 * r0;\n d2 += h3 * (5 * r9);\n d2 += h4 * (5 * r8);\n c = (d2 >>> 13); d2 &= 0x1fff;\n d2 += h5 * (5 * r7);\n d2 += h6 * (5 * r6);\n d2 += h7 * (5 * r5);\n d2 += h8 * (5 * r4);\n d2 += h9 * (5 * r3);\n c += (d2 >>> 13); d2 &= 0x1fff;\n\n d3 = c;\n d3 += h0 * r3;\n d3 += h1 * r2;\n d3 += h2 * r1;\n d3 += h3 * r0;\n d3 += h4 * (5 * r9);\n c = (d3 >>> 13); d3 &= 0x1fff;\n d3 += h5 * (5 * r8);\n d3 += h6 * (5 * r7);\n d3 += h7 * (5 * r6);\n d3 += h8 * (5 * r5);\n d3 += h9 * (5 * r4);\n c += (d3 >>> 13); d3 &= 0x1fff;\n\n d4 = c;\n d4 += h0 * r4;\n d4 += h1 * r3;\n d4 += h2 * r2;\n d4 += h3 * r1;\n d4 += h4 * r0;\n c = (d4 >>> 13); d4 &= 0x1fff;\n d4 += h5 * (5 * r9);\n d4 += h6 * (5 * r8);\n d4 += h7 * (5 * r7);\n d4 += h8 * (5 * r6);\n d4 += h9 * (5 * r5);\n c += (d4 >>> 13); d4 &= 0x1fff;\n\n d5 = c;\n d5 += h0 * r5;\n d5 += h1 * r4;\n d5 += h2 * r3;\n d5 += h3 * r2;\n d5 += h4 * r1;\n c = (d5 >>> 13); d5 &= 0x1fff;\n d5 += h5 * r0;\n d5 += h6 * (5 * r9);\n d5 += h7 * (5 * r8);\n d5 += h8 * (5 * r7);\n d5 += h9 * (5 * r6);\n c += (d5 >>> 13); d5 &= 0x1fff;\n\n d6 = c;\n d6 += h0 * r6;\n d6 += h1 * r5;\n d6 += h2 * r4;\n d6 += h3 * r3;\n d6 += h4 * r2;\n c = (d6 >>> 13); d6 &= 0x1fff;\n d6 += h5 * r1;\n d6 += h6 * r0;\n d6 += h7 * (5 * r9);\n d6 += h8 * (5 * r8);\n d6 += h9 * (5 * r7);\n c += (d6 >>> 13); d6 &= 0x1fff;\n\n d7 = c;\n d7 += h0 * r7;\n d7 += h1 * r6;\n d7 += h2 * r5;\n d7 += h3 * r4;\n d7 += h4 * r3;\n c = (d7 >>> 13); d7 &= 0x1fff;\n d7 += h5 * r2;\n d7 += h6 * r1;\n d7 += h7 * r0;\n d7 += h8 * (5 * r9);\n d7 += h9 * (5 * r8);\n c += (d7 >>> 13); d7 &= 0x1fff;\n\n d8 = c;\n d8 += h0 * r8;\n d8 += h1 * r7;\n d8 += h2 * r6;\n d8 += h3 * r5;\n d8 += h4 * r4;\n c = (d8 >>> 13); d8 &= 0x1fff;\n d8 += h5 * r3;\n d8 += h6 * r2;\n d8 += h7 * r1;\n d8 += h8 * r0;\n d8 += h9 * (5 * r9);\n c += (d8 >>> 13); d8 &= 0x1fff;\n\n d9 = c;\n d9 += h0 * r9;\n d9 += h1 * r8;\n d9 += h2 * r7;\n d9 += h3 * r6;\n d9 += h4 * r5;\n c = (d9 >>> 13); d9 &= 0x1fff;\n d9 += h5 * r4;\n d9 += h6 * r3;\n d9 += h7 * r2;\n d9 += h8 * r1;\n d9 += h9 * r0;\n c += (d9 >>> 13); d9 &= 0x1fff;\n\n c = (((c << 2) + c)) | 0;\n c = (c + d0) | 0;\n d0 = c & 0x1fff;\n c = (c >>> 13);\n d1 += c;\n\n h0 = d0;\n h1 = d1;\n h2 = d2;\n h3 = d3;\n h4 = d4;\n h5 = d5;\n h6 = d6;\n h7 = d7;\n h8 = d8;\n h9 = d9;\n\n mpos += 16;\n bytes -= 16;\n }\n this.h[0] = h0;\n this.h[1] = h1;\n this.h[2] = h2;\n this.h[3] = h3;\n this.h[4] = h4;\n this.h[5] = h5;\n this.h[6] = h6;\n this.h[7] = h7;\n this.h[8] = h8;\n this.h[9] = h9;\n};\n\npoly1305.prototype.finish = function(mac, macpos) {\n var g = new Uint16Array(10);\n var c, mask, f, i;\n\n if (this.leftover) {\n i = this.leftover;\n this.buffer[i++] = 1;\n for (; i < 16; i++) this.buffer[i] = 0;\n this.fin = 1;\n this.blocks(this.buffer, 0, 16);\n }\n\n c = this.h[1] >>> 13;\n this.h[1] &= 0x1fff;\n for (i = 2; i < 10; i++) {\n this.h[i] += c;\n c = this.h[i] >>> 13;\n this.h[i] &= 0x1fff;\n }\n this.h[0] += (c * 5);\n c = this.h[0] >>> 13;\n this.h[0] &= 0x1fff;\n this.h[1] += c;\n c = this.h[1] >>> 13;\n this.h[1] &= 0x1fff;\n this.h[2] += c;\n\n g[0] = this.h[0] + 5;\n c = g[0] >>> 13;\n g[0] &= 0x1fff;\n for (i = 1; i < 10; i++) {\n g[i] = this.h[i] + c;\n c = g[i] >>> 13;\n g[i] &= 0x1fff;\n }\n g[9] -= (1 << 13);\n\n mask = (c ^ 1) - 1;\n for (i = 0; i < 10; i++) g[i] &= mask;\n mask = ~mask;\n for (i = 0; i < 10; i++) this.h[i] = (this.h[i] & mask) | g[i];\n\n this.h[0] = ((this.h[0] ) | (this.h[1] << 13) ) & 0xffff;\n this.h[1] = ((this.h[1] >>> 3) | (this.h[2] << 10) ) & 0xffff;\n this.h[2] = ((this.h[2] >>> 6) | (this.h[3] << 7) ) & 0xffff;\n this.h[3] = ((this.h[3] >>> 9) | (this.h[4] << 4) ) & 0xffff;\n this.h[4] = ((this.h[4] >>> 12) | (this.h[5] << 1) | (this.h[6] << 14)) & 0xffff;\n this.h[5] = ((this.h[6] >>> 2) | (this.h[7] << 11) ) & 0xffff;\n this.h[6] = ((this.h[7] >>> 5) | (this.h[8] << 8) ) & 0xffff;\n this.h[7] = ((this.h[8] >>> 8) | (this.h[9] << 5) ) & 0xffff;\n\n f = this.h[0] + this.pad[0];\n this.h[0] = f & 0xffff;\n for (i = 1; i < 8; i++) {\n f = (((this.h[i] + this.pad[i]) | 0) + (f >>> 16)) | 0;\n this.h[i] = f & 0xffff;\n }\n\n mac[macpos+ 0] = (this.h[0] >>> 0) & 0xff;\n mac[macpos+ 1] = (this.h[0] >>> 8) & 0xff;\n mac[macpos+ 2] = (this.h[1] >>> 0) & 0xff;\n mac[macpos+ 3] = (this.h[1] >>> 8) & 0xff;\n mac[macpos+ 4] = (this.h[2] >>> 0) & 0xff;\n mac[macpos+ 5] = (this.h[2] >>> 8) & 0xff;\n mac[macpos+ 6] = (this.h[3] >>> 0) & 0xff;\n mac[macpos+ 7] = (this.h[3] >>> 8) & 0xff;\n mac[macpos+ 8] = (this.h[4] >>> 0) & 0xff;\n mac[macpos+ 9] = (this.h[4] >>> 8) & 0xff;\n mac[macpos+10] = (this.h[5] >>> 0) & 0xff;\n mac[macpos+11] = (this.h[5] >>> 8) & 0xff;\n mac[macpos+12] = (this.h[6] >>> 0) & 0xff;\n mac[macpos+13] = (this.h[6] >>> 8) & 0xff;\n mac[macpos+14] = (this.h[7] >>> 0) & 0xff;\n mac[macpos+15] = (this.h[7] >>> 8) & 0xff;\n};\n\npoly1305.prototype.update = function(m, mpos, bytes) {\n var i, want;\n\n if (this.leftover) {\n want = (16 - this.leftover);\n if (want > bytes)\n want = bytes;\n for (i = 0; i < want; i++)\n this.buffer[this.leftover + i] = m[mpos+i];\n bytes -= want;\n mpos += want;\n this.leftover += want;\n if (this.leftover < 16)\n return;\n this.blocks(this.buffer, 0, 16);\n this.leftover = 0;\n }\n\n if (bytes >= 16) {\n want = bytes - (bytes % 16);\n this.blocks(m, mpos, want);\n mpos += want;\n bytes -= want;\n }\n\n if (bytes) {\n for (i = 0; i < bytes; i++)\n this.buffer[this.leftover + i] = m[mpos+i];\n this.leftover += bytes;\n }\n};\n\nfunction crypto_onetimeauth(out, outpos, m, mpos, n, k) {\n var s = new poly1305(k);\n s.update(m, mpos, n);\n s.finish(out, outpos);\n return 0;\n}\n\nfunction crypto_onetimeauth_verify(h, hpos, m, mpos, n, k) {\n var x = new Uint8Array(16);\n crypto_onetimeauth(x,0,m,mpos,n,k);\n return crypto_verify_16(h,hpos,x,0);\n}\n\nfunction crypto_secretbox(c,m,d,n,k) {\n var i;\n if (d < 32) return -1;\n crypto_stream_xor(c,0,m,0,d,n,k);\n crypto_onetimeauth(c, 16, c, 32, d - 32, c);\n for (i = 0; i < 16; i++) c[i] = 0;\n return 0;\n}\n\nfunction crypto_secretbox_open(m,c,d,n,k) {\n var i;\n var x = new Uint8Array(32);\n if (d < 32) return -1;\n crypto_stream(x,0,32,n,k);\n if (crypto_onetimeauth_verify(c, 16,c, 32,d - 32,x) !== 0) return -1;\n crypto_stream_xor(m,0,c,0,d,n,k);\n for (i = 0; i < 32; i++) m[i] = 0;\n return 0;\n}\n\nfunction set25519(r, a) {\n var i;\n for (i = 0; i < 16; i++) r[i] = a[i]|0;\n}\n\nfunction car25519(o) {\n var i, v, c = 1;\n for (i = 0; i < 16; i++) {\n v = o[i] + c + 65535;\n c = Math.floor(v / 65536);\n o[i] = v - c * 65536;\n }\n o[0] += c-1 + 37 * (c-1);\n}\n\nfunction sel25519(p, q, b) {\n var t, c = ~(b-1);\n for (var i = 0; i < 16; i++) {\n t = c & (p[i] ^ q[i]);\n p[i] ^= t;\n q[i] ^= t;\n }\n}\n\nfunction pack25519(o, n) {\n var i, j, b;\n var m = gf(), t = gf();\n for (i = 0; i < 16; i++) t[i] = n[i];\n car25519(t);\n car25519(t);\n car25519(t);\n for (j = 0; j < 2; j++) {\n m[0] = t[0] - 0xffed;\n for (i = 1; i < 15; i++) {\n m[i] = t[i] - 0xffff - ((m[i-1]>>16) & 1);\n m[i-1] &= 0xffff;\n }\n m[15] = t[15] - 0x7fff - ((m[14]>>16) & 1);\n b = (m[15]>>16) & 1;\n m[14] &= 0xffff;\n sel25519(t, m, 1-b);\n }\n for (i = 0; i < 16; i++) {\n o[2*i] = t[i] & 0xff;\n o[2*i+1] = t[i]>>8;\n }\n}\n\nfunction neq25519(a, b) {\n var c = new Uint8Array(32), d = new Uint8Array(32);\n pack25519(c, a);\n pack25519(d, b);\n return crypto_verify_32(c, 0, d, 0);\n}\n\nfunction par25519(a) {\n var d = new Uint8Array(32);\n pack25519(d, a);\n return d[0] & 1;\n}\n\nfunction unpack25519(o, n) {\n var i;\n for (i = 0; i < 16; i++) o[i] = n[2*i] + (n[2*i+1] << 8);\n o[15] &= 0x7fff;\n}\n\nfunction A(o, a, b) {\n for (var i = 0; i < 16; i++) o[i] = a[i] + b[i];\n}\n\nfunction Z(o, a, b) {\n for (var i = 0; i < 16; i++) o[i] = a[i] - b[i];\n}\n\nfunction M(o, a, b) {\n var v, c,\n t0 = 0, t1 = 0, t2 = 0, t3 = 0, t4 = 0, t5 = 0, t6 = 0, t7 = 0,\n t8 = 0, t9 = 0, t10 = 0, t11 = 0, t12 = 0, t13 = 0, t14 = 0, t15 = 0,\n t16 = 0, t17 = 0, t18 = 0, t19 = 0, t20 = 0, t21 = 0, t22 = 0, t23 = 0,\n t24 = 0, t25 = 0, t26 = 0, t27 = 0, t28 = 0, t29 = 0, t30 = 0,\n b0 = b[0],\n b1 = b[1],\n b2 = b[2],\n b3 = b[3],\n b4 = b[4],\n b5 = b[5],\n b6 = b[6],\n b7 = b[7],\n b8 = b[8],\n b9 = b[9],\n b10 = b[10],\n b11 = b[11],\n b12 = b[12],\n b13 = b[13],\n b14 = b[14],\n b15 = b[15];\n\n v = a[0];\n t0 += v * b0;\n t1 += v * b1;\n t2 += v * b2;\n t3 += v * b3;\n t4 += v * b4;\n t5 += v * b5;\n t6 += v * b6;\n t7 += v * b7;\n t8 += v * b8;\n t9 += v * b9;\n t10 += v * b10;\n t11 += v * b11;\n t12 += v * b12;\n t13 += v * b13;\n t14 += v * b14;\n t15 += v * b15;\n v = a[1];\n t1 += v * b0;\n t2 += v * b1;\n t3 += v * b2;\n t4 += v * b3;\n t5 += v * b4;\n t6 += v * b5;\n t7 += v * b6;\n t8 += v * b7;\n t9 += v * b8;\n t10 += v * b9;\n t11 += v * b10;\n t12 += v * b11;\n t13 += v * b12;\n t14 += v * b13;\n t15 += v * b14;\n t16 += v * b15;\n v = a[2];\n t2 += v * b0;\n t3 += v * b1;\n t4 += v * b2;\n t5 += v * b3;\n t6 += v * b4;\n t7 += v * b5;\n t8 += v * b6;\n t9 += v * b7;\n t10 += v * b8;\n t11 += v * b9;\n t12 += v * b10;\n t13 += v * b11;\n t14 += v * b12;\n t15 += v * b13;\n t16 += v * b14;\n t17 += v * b15;\n v = a[3];\n t3 += v * b0;\n t4 += v * b1;\n t5 += v * b2;\n t6 += v * b3;\n t7 += v * b4;\n t8 += v * b5;\n t9 += v * b6;\n t10 += v * b7;\n t11 += v * b8;\n t12 += v * b9;\n t13 += v * b10;\n t14 += v * b11;\n t15 += v * b12;\n t16 += v * b13;\n t17 += v * b14;\n t18 += v * b15;\n v = a[4];\n t4 += v * b0;\n t5 += v * b1;\n t6 += v * b2;\n t7 += v * b3;\n t8 += v * b4;\n t9 += v * b5;\n t10 += v * b6;\n t11 += v * b7;\n t12 += v * b8;\n t13 += v * b9;\n t14 += v * b10;\n t15 += v * b11;\n t16 += v * b12;\n t17 += v * b13;\n t18 += v * b14;\n t19 += v * b15;\n v = a[5];\n t5 += v * b0;\n t6 += v * b1;\n t7 += v * b2;\n t8 += v * b3;\n t9 += v * b4;\n t10 += v * b5;\n t11 += v * b6;\n t12 += v * b7;\n t13 += v * b8;\n t14 += v * b9;\n t15 += v * b10;\n t16 += v * b11;\n t17 += v * b12;\n t18 += v * b13;\n t19 += v * b14;\n t20 += v * b15;\n v = a[6];\n t6 += v * b0;\n t7 += v * b1;\n t8 += v * b2;\n t9 += v * b3;\n t10 += v * b4;\n t11 += v * b5;\n t12 += v * b6;\n t13 += v * b7;\n t14 += v * b8;\n t15 += v * b9;\n t16 += v * b10;\n t17 += v * b11;\n t18 += v * b12;\n t19 += v * b13;\n t20 += v * b14;\n t21 += v * b15;\n v = a[7];\n t7 += v * b0;\n t8 += v * b1;\n t9 += v * b2;\n t10 += v * b3;\n t11 += v * b4;\n t12 += v * b5;\n t13 += v * b6;\n t14 += v * b7;\n t15 += v * b8;\n t16 += v * b9;\n t17 += v * b10;\n t18 += v * b11;\n t19 += v * b12;\n t20 += v * b13;\n t21 += v * b14;\n t22 += v * b15;\n v = a[8];\n t8 += v * b0;\n t9 += v * b1;\n t10 += v * b2;\n t11 += v * b3;\n t12 += v * b4;\n t13 += v * b5;\n t14 += v * b6;\n t15 += v * b7;\n t16 += v * b8;\n t17 += v * b9;\n t18 += v * b10;\n t19 += v * b11;\n t20 += v * b12;\n t21 += v * b13;\n t22 += v * b14;\n t23 += v * b15;\n v = a[9];\n t9 += v * b0;\n t10 += v * b1;\n t11 += v * b2;\n t12 += v * b3;\n t13 += v * b4;\n t14 += v * b5;\n t15 += v * b6;\n t16 += v * b7;\n t17 += v * b8;\n t18 += v * b9;\n t19 += v * b10;\n t20 += v * b11;\n t21 += v * b12;\n t22 += v * b13;\n t23 += v * b14;\n t24 += v * b15;\n v = a[10];\n t10 += v * b0;\n t11 += v * b1;\n t12 += v * b2;\n t13 += v * b3;\n t14 += v * b4;\n t15 += v * b5;\n t16 += v * b6;\n t17 += v * b7;\n t18 += v * b8;\n t19 += v * b9;\n t20 += v * b10;\n t21 += v * b11;\n t22 += v * b12;\n t23 += v * b13;\n t24 += v * b14;\n t25 += v * b15;\n v = a[11];\n t11 += v * b0;\n t12 += v * b1;\n t13 += v * b2;\n t14 += v * b3;\n t15 += v * b4;\n t16 += v * b5;\n t17 += v * b6;\n t18 += v * b7;\n t19 += v * b8;\n t20 += v * b9;\n t21 += v * b10;\n t22 += v * b11;\n t23 += v * b12;\n t24 += v * b13;\n t25 += v * b14;\n t26 += v * b15;\n v = a[12];\n t12 += v * b0;\n t13 += v * b1;\n t14 += v * b2;\n t15 += v * b3;\n t16 += v * b4;\n t17 += v * b5;\n t18 += v * b6;\n t19 += v * b7;\n t20 += v * b8;\n t21 += v * b9;\n t22 += v * b10;\n t23 += v * b11;\n t24 += v * b12;\n t25 += v * b13;\n t26 += v * b14;\n t27 += v * b15;\n v = a[13];\n t13 += v * b0;\n t14 += v * b1;\n t15 += v * b2;\n t16 += v * b3;\n t17 += v * b4;\n t18 += v * b5;\n t19 += v * b6;\n t20 += v * b7;\n t21 += v * b8;\n t22 += v * b9;\n t23 += v * b10;\n t24 += v * b11;\n t25 += v * b12;\n t26 += v * b13;\n t27 += v * b14;\n t28 += v * b15;\n v = a[14];\n t14 += v * b0;\n t15 += v * b1;\n t16 += v * b2;\n t17 += v * b3;\n t18 += v * b4;\n t19 += v * b5;\n t20 += v * b6;\n t21 += v * b7;\n t22 += v * b8;\n t23 += v * b9;\n t24 += v * b10;\n t25 += v * b11;\n t26 += v * b12;\n t27 += v * b13;\n t28 += v * b14;\n t29 += v * b15;\n v = a[15];\n t15 += v * b0;\n t16 += v * b1;\n t17 += v * b2;\n t18 += v * b3;\n t19 += v * b4;\n t20 += v * b5;\n t21 += v * b6;\n t22 += v * b7;\n t23 += v * b8;\n t24 += v * b9;\n t25 += v * b10;\n t26 += v * b11;\n t27 += v * b12;\n t28 += v * b13;\n t29 += v * b14;\n t30 += v * b15;\n\n t0 += 38 * t16;\n t1 += 38 * t17;\n t2 += 38 * t18;\n t3 += 38 * t19;\n t4 += 38 * t20;\n t5 += 38 * t21;\n t6 += 38 * t22;\n t7 += 38 * t23;\n t8 += 38 * t24;\n t9 += 38 * t25;\n t10 += 38 * t26;\n t11 += 38 * t27;\n t12 += 38 * t28;\n t13 += 38 * t29;\n t14 += 38 * t30;\n // t15 left as is\n\n // first car\n c = 1;\n v = t0 + c + 65535; c = Math.floor(v / 65536); t0 = v - c * 65536;\n v = t1 + c + 65535; c = Math.floor(v / 65536); t1 = v - c * 65536;\n v = t2 + c + 65535; c = Math.floor(v / 65536); t2 = v - c * 65536;\n v = t3 + c + 65535; c = Math.floor(v / 65536); t3 = v - c * 65536;\n v = t4 + c + 65535; c = Math.floor(v / 65536); t4 = v - c * 65536;\n v = t5 + c + 65535; c = Math.floor(v / 65536); t5 = v - c * 65536;\n v = t6 + c + 65535; c = Math.floor(v / 65536); t6 = v - c * 65536;\n v = t7 + c + 65535; c = Math.floor(v / 65536); t7 = v - c * 65536;\n v = t8 + c + 65535; c = Math.floor(v / 65536); t8 = v - c * 65536;\n v = t9 + c + 65535; c = Math.floor(v / 65536); t9 = v - c * 65536;\n v = t10 + c + 65535; c = Math.floor(v / 65536); t10 = v - c * 65536;\n v = t11 + c + 65535; c = Math.floor(v / 65536); t11 = v - c * 65536;\n v = t12 + c + 65535; c = Math.floor(v / 65536); t12 = v - c * 65536;\n v = t13 + c + 65535; c = Math.floor(v / 65536); t13 = v - c * 65536;\n v = t14 + c + 65535; c = Math.floor(v / 65536); t14 = v - c * 65536;\n v = t15 + c + 65535; c = Math.floor(v / 65536); t15 = v - c * 65536;\n t0 += c-1 + 37 * (c-1);\n\n // second car\n c = 1;\n v = t0 + c + 65535; c = Math.floor(v / 65536); t0 = v - c * 65536;\n v = t1 + c + 65535; c = Math.floor(v / 65536); t1 = v - c * 65536;\n v = t2 + c + 65535; c = Math.floor(v / 65536); t2 = v - c * 65536;\n v = t3 + c + 65535; c = Math.floor(v / 65536); t3 = v - c * 65536;\n v = t4 + c + 65535; c = Math.floor(v / 65536); t4 = v - c * 65536;\n v = t5 + c + 65535; c = Math.floor(v / 65536); t5 = v - c * 65536;\n v = t6 + c + 65535; c = Math.floor(v / 65536); t6 = v - c * 65536;\n v = t7 + c + 65535; c = Math.floor(v / 65536); t7 = v - c * 65536;\n v = t8 + c + 65535; c = Math.floor(v / 65536); t8 = v - c * 65536;\n v = t9 + c + 65535; c = Math.floor(v / 65536); t9 = v - c * 65536;\n v = t10 + c + 65535; c = Math.floor(v / 65536); t10 = v - c * 65536;\n v = t11 + c + 65535; c = Math.floor(v / 65536); t11 = v - c * 65536;\n v = t12 + c + 65535; c = Math.floor(v / 65536); t12 = v - c * 65536;\n v = t13 + c + 65535; c = Math.floor(v / 65536); t13 = v - c * 65536;\n v = t14 + c + 65535; c = Math.floor(v / 65536); t14 = v - c * 65536;\n v = t15 + c + 65535; c = Math.floor(v / 65536); t15 = v - c * 65536;\n t0 += c-1 + 37 * (c-1);\n\n o[ 0] = t0;\n o[ 1] = t1;\n o[ 2] = t2;\n o[ 3] = t3;\n o[ 4] = t4;\n o[ 5] = t5;\n o[ 6] = t6;\n o[ 7] = t7;\n o[ 8] = t8;\n o[ 9] = t9;\n o[10] = t10;\n o[11] = t11;\n o[12] = t12;\n o[13] = t13;\n o[14] = t14;\n o[15] = t15;\n}\n\nfunction S(o, a) {\n M(o, a, a);\n}\n\nfunction inv25519(o, i) {\n var c = gf();\n var a;\n for (a = 0; a < 16; a++) c[a] = i[a];\n for (a = 253; a >= 0; a--) {\n S(c, c);\n if(a !== 2 && a !== 4) M(c, c, i);\n }\n for (a = 0; a < 16; a++) o[a] = c[a];\n}\n\nfunction pow2523(o, i) {\n var c = gf();\n var a;\n for (a = 0; a < 16; a++) c[a] = i[a];\n for (a = 250; a >= 0; a--) {\n S(c, c);\n if(a !== 1) M(c, c, i);\n }\n for (a = 0; a < 16; a++) o[a] = c[a];\n}\n\nfunction crypto_scalarmult(q, n, p) {\n var z = new Uint8Array(32);\n var x = new Float64Array(80), r, i;\n var a = gf(), b = gf(), c = gf(),\n d = gf(), e = gf(), f = gf();\n for (i = 0; i < 31; i++) z[i] = n[i];\n z[31]=(n[31]&127)|64;\n z[0]&=248;\n unpack25519(x,p);\n for (i = 0; i < 16; i++) {\n b[i]=x[i];\n d[i]=a[i]=c[i]=0;\n }\n a[0]=d[0]=1;\n for (i=254; i>=0; --i) {\n r=(z[i>>>3]>>>(i&7))&1;\n sel25519(a,b,r);\n sel25519(c,d,r);\n A(e,a,c);\n Z(a,a,c);\n A(c,b,d);\n Z(b,b,d);\n S(d,e);\n S(f,a);\n M(a,c,a);\n M(c,b,e);\n A(e,a,c);\n Z(a,a,c);\n S(b,a);\n Z(c,d,f);\n M(a,c,_121665);\n A(a,a,d);\n M(c,c,a);\n M(a,d,f);\n M(d,b,x);\n S(b,e);\n sel25519(a,b,r);\n sel25519(c,d,r);\n }\n for (i = 0; i < 16; i++) {\n x[i+16]=a[i];\n x[i+32]=c[i];\n x[i+48]=b[i];\n x[i+64]=d[i];\n }\n var x32 = x.subarray(32);\n var x16 = x.subarray(16);\n inv25519(x32,x32);\n M(x16,x16,x32);\n pack25519(q,x16);\n return 0;\n}\n\nfunction crypto_scalarmult_base(q, n) {\n return crypto_scalarmult(q, n, _9);\n}\n\nfunction crypto_box_keypair(y, x) {\n randombytes(x, 32);\n return crypto_scalarmult_base(y, x);\n}\n\nfunction crypto_box_beforenm(k, y, x) {\n var s = new Uint8Array(32);\n crypto_scalarmult(s, x, y);\n return crypto_core_hsalsa20(k, _0, s, sigma);\n}\n\nvar crypto_box_afternm = crypto_secretbox;\nvar crypto_box_open_afternm = crypto_secretbox_open;\n\nfunction crypto_box(c, m, d, n, y, x) {\n var k = new Uint8Array(32);\n crypto_box_beforenm(k, y, x);\n return crypto_box_afternm(c, m, d, n, k);\n}\n\nfunction crypto_box_open(m, c, d, n, y, x) {\n var k = new Uint8Array(32);\n crypto_box_beforenm(k, y, x);\n return crypto_box_open_afternm(m, c, d, n, k);\n}\n\nvar K = [\n 0x428a2f98, 0xd728ae22, 0x71374491, 0x23ef65cd,\n 0xb5c0fbcf, 0xec4d3b2f, 0xe9b5dba5, 0x8189dbbc,\n 0x3956c25b, 0xf348b538, 0x59f111f1, 0xb605d019,\n 0x923f82a4, 0xaf194f9b, 0xab1c5ed5, 0xda6d8118,\n 0xd807aa98, 0xa3030242, 0x12835b01, 0x45706fbe,\n 0x243185be, 0x4ee4b28c, 0x550c7dc3, 0xd5ffb4e2,\n 0x72be5d74, 0xf27b896f, 0x80deb1fe, 0x3b1696b1,\n 0x9bdc06a7, 0x25c71235, 0xc19bf174, 0xcf692694,\n 0xe49b69c1, 0x9ef14ad2, 0xefbe4786, 0x384f25e3,\n 0x0fc19dc6, 0x8b8cd5b5, 0x240ca1cc, 0x77ac9c65,\n 0x2de92c6f, 0x592b0275, 0x4a7484aa, 0x6ea6e483,\n 0x5cb0a9dc, 0xbd41fbd4, 0x76f988da, 0x831153b5,\n 0x983e5152, 0xee66dfab, 0xa831c66d, 0x2db43210,\n 0xb00327c8, 0x98fb213f, 0xbf597fc7, 0xbeef0ee4,\n 0xc6e00bf3, 0x3da88fc2, 0xd5a79147, 0x930aa725,\n 0x06ca6351, 0xe003826f, 0x14292967, 0x0a0e6e70,\n 0x27b70a85, 0x46d22ffc, 0x2e1b2138, 0x5c26c926,\n 0x4d2c6dfc, 0x5ac42aed, 0x53380d13, 0x9d95b3df,\n 0x650a7354, 0x8baf63de, 0x766a0abb, 0x3c77b2a8,\n 0x81c2c92e, 0x47edaee6, 0x92722c85, 0x1482353b,\n 0xa2bfe8a1, 0x4cf10364, 0xa81a664b, 0xbc423001,\n 0xc24b8b70, 0xd0f89791, 0xc76c51a3, 0x0654be30,\n 0xd192e819, 0xd6ef5218, 0xd6990624, 0x5565a910,\n 0xf40e3585, 0x5771202a, 0x106aa070, 0x32bbd1b8,\n 0x19a4c116, 0xb8d2d0c8, 0x1e376c08, 0x5141ab53,\n 0x2748774c, 0xdf8eeb99, 0x34b0bcb5, 0xe19b48a8,\n 0x391c0cb3, 0xc5c95a63, 0x4ed8aa4a, 0xe3418acb,\n 0x5b9cca4f, 0x7763e373, 0x682e6ff3, 0xd6b2b8a3,\n 0x748f82ee, 0x5defb2fc, 0x78a5636f, 0x43172f60,\n 0x84c87814, 0xa1f0ab72, 0x8cc70208, 0x1a6439ec,\n 0x90befffa, 0x23631e28, 0xa4506ceb, 0xde82bde9,\n 0xbef9a3f7, 0xb2c67915, 0xc67178f2, 0xe372532b,\n 0xca273ece, 0xea26619c, 0xd186b8c7, 0x21c0c207,\n 0xeada7dd6, 0xcde0eb1e, 0xf57d4f7f, 0xee6ed178,\n 0x06f067aa, 0x72176fba, 0x0a637dc5, 0xa2c898a6,\n 0x113f9804, 0xbef90dae, 0x1b710b35, 0x131c471b,\n 0x28db77f5, 0x23047d84, 0x32caab7b, 0x40c72493,\n 0x3c9ebe0a, 0x15c9bebc, 0x431d67c4, 0x9c100d4c,\n 0x4cc5d4be, 0xcb3e42b6, 0x597f299c, 0xfc657e2a,\n 0x5fcb6fab, 0x3ad6faec, 0x6c44198c, 0x4a475817\n];\n\nfunction crypto_hashblocks_hl(hh, hl, m, n) {\n var wh = new Int32Array(16), wl = new Int32Array(16),\n bh0, bh1, bh2, bh3, bh4, bh5, bh6, bh7,\n bl0, bl1, bl2, bl3, bl4, bl5, bl6, bl7,\n th, tl, i, j, h, l, a, b, c, d;\n\n var ah0 = hh[0],\n ah1 = hh[1],\n ah2 = hh[2],\n ah3 = hh[3],\n ah4 = hh[4],\n ah5 = hh[5],\n ah6 = hh[6],\n ah7 = hh[7],\n\n al0 = hl[0],\n al1 = hl[1],\n al2 = hl[2],\n al3 = hl[3],\n al4 = hl[4],\n al5 = hl[5],\n al6 = hl[6],\n al7 = hl[7];\n\n var pos = 0;\n while (n >= 128) {\n for (i = 0; i < 16; i++) {\n j = 8 * i + pos;\n wh[i] = (m[j+0] << 24) | (m[j+1] << 16) | (m[j+2] << 8) | m[j+3];\n wl[i] = (m[j+4] << 24) | (m[j+5] << 16) | (m[j+6] << 8) | m[j+7];\n }\n for (i = 0; i < 80; i++) {\n bh0 = ah0;\n bh1 = ah1;\n bh2 = ah2;\n bh3 = ah3;\n bh4 = ah4;\n bh5 = ah5;\n bh6 = ah6;\n bh7 = ah7;\n\n bl0 = al0;\n bl1 = al1;\n bl2 = al2;\n bl3 = al3;\n bl4 = al4;\n bl5 = al5;\n bl6 = al6;\n bl7 = al7;\n\n // add\n h = ah7;\n l = al7;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n // Sigma1\n h = ((ah4 >>> 14) | (al4 << (32-14))) ^ ((ah4 >>> 18) | (al4 << (32-18))) ^ ((al4 >>> (41-32)) | (ah4 << (32-(41-32))));\n l = ((al4 >>> 14) | (ah4 << (32-14))) ^ ((al4 >>> 18) | (ah4 << (32-18))) ^ ((ah4 >>> (41-32)) | (al4 << (32-(41-32))));\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // Ch\n h = (ah4 & ah5) ^ (~ah4 & ah6);\n l = (al4 & al5) ^ (~al4 & al6);\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // K\n h = K[i*2];\n l = K[i*2+1];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // w\n h = wh[i%16];\n l = wl[i%16];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n th = c & 0xffff | d << 16;\n tl = a & 0xffff | b << 16;\n\n // add\n h = th;\n l = tl;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n // Sigma0\n h = ((ah0 >>> 28) | (al0 << (32-28))) ^ ((al0 >>> (34-32)) | (ah0 << (32-(34-32)))) ^ ((al0 >>> (39-32)) | (ah0 << (32-(39-32))));\n l = ((al0 >>> 28) | (ah0 << (32-28))) ^ ((ah0 >>> (34-32)) | (al0 << (32-(34-32)))) ^ ((ah0 >>> (39-32)) | (al0 << (32-(39-32))));\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // Maj\n h = (ah0 & ah1) ^ (ah0 & ah2) ^ (ah1 & ah2);\n l = (al0 & al1) ^ (al0 & al2) ^ (al1 & al2);\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n bh7 = (c & 0xffff) | (d << 16);\n bl7 = (a & 0xffff) | (b << 16);\n\n // add\n h = bh3;\n l = bl3;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = th;\n l = tl;\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n bh3 = (c & 0xffff) | (d << 16);\n bl3 = (a & 0xffff) | (b << 16);\n\n ah1 = bh0;\n ah2 = bh1;\n ah3 = bh2;\n ah4 = bh3;\n ah5 = bh4;\n ah6 = bh5;\n ah7 = bh6;\n ah0 = bh7;\n\n al1 = bl0;\n al2 = bl1;\n al3 = bl2;\n al4 = bl3;\n al5 = bl4;\n al6 = bl5;\n al7 = bl6;\n al0 = bl7;\n\n if (i%16 === 15) {\n for (j = 0; j < 16; j++) {\n // add\n h = wh[j];\n l = wl[j];\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = wh[(j+9)%16];\n l = wl[(j+9)%16];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // sigma0\n th = wh[(j+1)%16];\n tl = wl[(j+1)%16];\n h = ((th >>> 1) | (tl << (32-1))) ^ ((th >>> 8) | (tl << (32-8))) ^ (th >>> 7);\n l = ((tl >>> 1) | (th << (32-1))) ^ ((tl >>> 8) | (th << (32-8))) ^ ((tl >>> 7) | (th << (32-7)));\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // sigma1\n th = wh[(j+14)%16];\n tl = wl[(j+14)%16];\n h = ((th >>> 19) | (tl << (32-19))) ^ ((tl >>> (61-32)) | (th << (32-(61-32)))) ^ (th >>> 6);\n l = ((tl >>> 19) | (th << (32-19))) ^ ((th >>> (61-32)) | (tl << (32-(61-32)))) ^ ((tl >>> 6) | (th << (32-6)));\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n wh[j] = (c & 0xffff) | (d << 16);\n wl[j] = (a & 0xffff) | (b << 16);\n }\n }\n }\n\n // add\n h = ah0;\n l = al0;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[0];\n l = hl[0];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[0] = ah0 = (c & 0xffff) | (d << 16);\n hl[0] = al0 = (a & 0xffff) | (b << 16);\n\n h = ah1;\n l = al1;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[1];\n l = hl[1];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[1] = ah1 = (c & 0xffff) | (d << 16);\n hl[1] = al1 = (a & 0xffff) | (b << 16);\n\n h = ah2;\n l = al2;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[2];\n l = hl[2];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[2] = ah2 = (c & 0xffff) | (d << 16);\n hl[2] = al2 = (a & 0xffff) | (b << 16);\n\n h = ah3;\n l = al3;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[3];\n l = hl[3];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[3] = ah3 = (c & 0xffff) | (d << 16);\n hl[3] = al3 = (a & 0xffff) | (b << 16);\n\n h = ah4;\n l = al4;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[4];\n l = hl[4];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[4] = ah4 = (c & 0xffff) | (d << 16);\n hl[4] = al4 = (a & 0xffff) | (b << 16);\n\n h = ah5;\n l = al5;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[5];\n l = hl[5];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[5] = ah5 = (c & 0xffff) | (d << 16);\n hl[5] = al5 = (a & 0xffff) | (b << 16);\n\n h = ah6;\n l = al6;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[6];\n l = hl[6];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[6] = ah6 = (c & 0xffff) | (d << 16);\n hl[6] = al6 = (a & 0xffff) | (b << 16);\n\n h = ah7;\n l = al7;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[7];\n l = hl[7];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[7] = ah7 = (c & 0xffff) | (d << 16);\n hl[7] = al7 = (a & 0xffff) | (b << 16);\n\n pos += 128;\n n -= 128;\n }\n\n return n;\n}\n\nfunction crypto_hash(out, m, n) {\n var hh = new Int32Array(8),\n hl = new Int32Array(8),\n x = new Uint8Array(256),\n i, b = n;\n\n hh[0] = 0x6a09e667;\n hh[1] = 0xbb67ae85;\n hh[2] = 0x3c6ef372;\n hh[3] = 0xa54ff53a;\n hh[4] = 0x510e527f;\n hh[5] = 0x9b05688c;\n hh[6] = 0x1f83d9ab;\n hh[7] = 0x5be0cd19;\n\n hl[0] = 0xf3bcc908;\n hl[1] = 0x84caa73b;\n hl[2] = 0xfe94f82b;\n hl[3] = 0x5f1d36f1;\n hl[4] = 0xade682d1;\n hl[5] = 0x2b3e6c1f;\n hl[6] = 0xfb41bd6b;\n hl[7] = 0x137e2179;\n\n crypto_hashblocks_hl(hh, hl, m, n);\n n %= 128;\n\n for (i = 0; i < n; i++) x[i] = m[b-n+i];\n x[n] = 128;\n\n n = 256-128*(n<112?1:0);\n x[n-9] = 0;\n ts64(x, n-8, (b / 0x20000000) | 0, b << 3);\n crypto_hashblocks_hl(hh, hl, x, n);\n\n for (i = 0; i < 8; i++) ts64(out, 8*i, hh[i], hl[i]);\n\n return 0;\n}\n\nfunction add(p, q) {\n var a = gf(), b = gf(), c = gf(),\n d = gf(), e = gf(), f = gf(),\n g = gf(), h = gf(), t = gf();\n\n Z(a, p[1], p[0]);\n Z(t, q[1], q[0]);\n M(a, a, t);\n A(b, p[0], p[1]);\n A(t, q[0], q[1]);\n M(b, b, t);\n M(c, p[3], q[3]);\n M(c, c, D2);\n M(d, p[2], q[2]);\n A(d, d, d);\n Z(e, b, a);\n Z(f, d, c);\n A(g, d, c);\n A(h, b, a);\n\n M(p[0], e, f);\n M(p[1], h, g);\n M(p[2], g, f);\n M(p[3], e, h);\n}\n\nfunction cswap(p, q, b) {\n var i;\n for (i = 0; i < 4; i++) {\n sel25519(p[i], q[i], b);\n }\n}\n\nfunction pack(r, p) {\n var tx = gf(), ty = gf(), zi = gf();\n inv25519(zi, p[2]);\n M(tx, p[0], zi);\n M(ty, p[1], zi);\n pack25519(r, ty);\n r[31] ^= par25519(tx) << 7;\n}\n\nfunction scalarmult(p, q, s) {\n var b, i;\n set25519(p[0], gf0);\n set25519(p[1], gf1);\n set25519(p[2], gf1);\n set25519(p[3], gf0);\n for (i = 255; i >= 0; --i) {\n b = (s[(i/8)|0] >> (i&7)) & 1;\n cswap(p, q, b);\n add(q, p);\n add(p, p);\n cswap(p, q, b);\n }\n}\n\nfunction scalarbase(p, s) {\n var q = [gf(), gf(), gf(), gf()];\n set25519(q[0], X);\n set25519(q[1], Y);\n set25519(q[2], gf1);\n M(q[3], X, Y);\n scalarmult(p, q, s);\n}\n\nfunction crypto_sign_keypair(pk, sk, seeded) {\n var d = new Uint8Array(64);\n var p = [gf(), gf(), gf(), gf()];\n var i;\n\n if (!seeded) randombytes(sk, 32);\n crypto_hash(d, sk, 32);\n d[0] &= 248;\n d[31] &= 127;\n d[31] |= 64;\n\n scalarbase(p, d);\n pack(pk, p);\n\n for (i = 0; i < 32; i++) sk[i+32] = pk[i];\n return 0;\n}\n\nvar L = new Float64Array([0xed, 0xd3, 0xf5, 0x5c, 0x1a, 0x63, 0x12, 0x58, 0xd6, 0x9c, 0xf7, 0xa2, 0xde, 0xf9, 0xde, 0x14, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x10]);\n\nfunction modL(r, x) {\n var carry, i, j, k;\n for (i = 63; i >= 32; --i) {\n carry = 0;\n for (j = i - 32, k = i - 12; j < k; ++j) {\n x[j] += carry - 16 * x[i] * L[j - (i - 32)];\n carry = Math.floor((x[j] + 128) / 256);\n x[j] -= carry * 256;\n }\n x[j] += carry;\n x[i] = 0;\n }\n carry = 0;\n for (j = 0; j < 32; j++) {\n x[j] += carry - (x[31] >> 4) * L[j];\n carry = x[j] >> 8;\n x[j] &= 255;\n }\n for (j = 0; j < 32; j++) x[j] -= carry * L[j];\n for (i = 0; i < 32; i++) {\n x[i+1] += x[i] >> 8;\n r[i] = x[i] & 255;\n }\n}\n\nfunction reduce(r) {\n var x = new Float64Array(64), i;\n for (i = 0; i < 64; i++) x[i] = r[i];\n for (i = 0; i < 64; i++) r[i] = 0;\n modL(r, x);\n}\n\n// Note: difference from C - smlen returned, not passed as argument.\nfunction crypto_sign(sm, m, n, sk) {\n var d = new Uint8Array(64), h = new Uint8Array(64), r = new Uint8Array(64);\n var i, j, x = new Float64Array(64);\n var p = [gf(), gf(), gf(), gf()];\n\n crypto_hash(d, sk, 32);\n d[0] &= 248;\n d[31] &= 127;\n d[31] |= 64;\n\n var smlen = n + 64;\n for (i = 0; i < n; i++) sm[64 + i] = m[i];\n for (i = 0; i < 32; i++) sm[32 + i] = d[32 + i];\n\n crypto_hash(r, sm.subarray(32), n+32);\n reduce(r);\n scalarbase(p, r);\n pack(sm, p);\n\n for (i = 32; i < 64; i++) sm[i] = sk[i];\n crypto_hash(h, sm, n + 64);\n reduce(h);\n\n for (i = 0; i < 64; i++) x[i] = 0;\n for (i = 0; i < 32; i++) x[i] = r[i];\n for (i = 0; i < 32; i++) {\n for (j = 0; j < 32; j++) {\n x[i+j] += h[i] * d[j];\n }\n }\n\n modL(sm.subarray(32), x);\n return smlen;\n}\n\nfunction unpackneg(r, p) {\n var t = gf(), chk = gf(), num = gf(),\n den = gf(), den2 = gf(), den4 = gf(),\n den6 = gf();\n\n set25519(r[2], gf1);\n unpack25519(r[1], p);\n S(num, r[1]);\n M(den, num, D);\n Z(num, num, r[2]);\n A(den, r[2], den);\n\n S(den2, den);\n S(den4, den2);\n M(den6, den4, den2);\n M(t, den6, num);\n M(t, t, den);\n\n pow2523(t, t);\n M(t, t, num);\n M(t, t, den);\n M(t, t, den);\n M(r[0], t, den);\n\n S(chk, r[0]);\n M(chk, chk, den);\n if (neq25519(chk, num)) M(r[0], r[0], I);\n\n S(chk, r[0]);\n M(chk, chk, den);\n if (neq25519(chk, num)) return -1;\n\n if (par25519(r[0]) === (p[31]>>7)) Z(r[0], gf0, r[0]);\n\n M(r[3], r[0], r[1]);\n return 0;\n}\n\nfunction crypto_sign_open(m, sm, n, pk) {\n var i;\n var t = new Uint8Array(32), h = new Uint8Array(64);\n var p = [gf(), gf(), gf(), gf()],\n q = [gf(), gf(), gf(), gf()];\n\n if (n < 64) return -1;\n\n if (unpackneg(q, pk)) return -1;\n\n for (i = 0; i < n; i++) m[i] = sm[i];\n for (i = 0; i < 32; i++) m[i+32] = pk[i];\n crypto_hash(h, m, n);\n reduce(h);\n scalarmult(p, q, h);\n\n scalarbase(q, sm.subarray(32));\n add(p, q);\n pack(t, p);\n\n n -= 64;\n if (crypto_verify_32(sm, 0, t, 0)) {\n for (i = 0; i < n; i++) m[i] = 0;\n return -1;\n }\n\n for (i = 0; i < n; i++) m[i] = sm[i + 64];\n return n;\n}\n\nvar crypto_secretbox_KEYBYTES = 32,\n crypto_secretbox_NONCEBYTES = 24,\n crypto_secretbox_ZEROBYTES = 32,\n crypto_secretbox_BOXZEROBYTES = 16,\n crypto_scalarmult_BYTES = 32,\n crypto_scalarmult_SCALARBYTES = 32,\n crypto_box_PUBLICKEYBYTES = 32,\n crypto_box_SECRETKEYBYTES = 32,\n crypto_box_BEFORENMBYTES = 32,\n crypto_box_NONCEBYTES = crypto_secretbox_NONCEBYTES,\n crypto_box_ZEROBYTES = crypto_secretbox_ZEROBYTES,\n crypto_box_BOXZEROBYTES = crypto_secretbox_BOXZEROBYTES,\n crypto_sign_BYTES = 64,\n crypto_sign_PUBLICKEYBYTES = 32,\n crypto_sign_SECRETKEYBYTES = 64,\n crypto_sign_SEEDBYTES = 32,\n crypto_hash_BYTES = 64;\n\nnacl.lowlevel = {\n crypto_core_hsalsa20: crypto_core_hsalsa20,\n crypto_stream_xor: crypto_stream_xor,\n crypto_stream: crypto_stream,\n crypto_stream_salsa20_xor: crypto_stream_salsa20_xor,\n crypto_stream_salsa20: crypto_stream_salsa20,\n crypto_onetimeauth: crypto_onetimeauth,\n crypto_onetimeauth_verify: crypto_onetimeauth_verify,\n crypto_verify_16: crypto_verify_16,\n crypto_verify_32: crypto_verify_32,\n crypto_secretbox: crypto_secretbox,\n crypto_secretbox_open: crypto_secretbox_open,\n crypto_scalarmult: crypto_scalarmult,\n crypto_scalarmult_base: crypto_scalarmult_base,\n crypto_box_beforenm: crypto_box_beforenm,\n crypto_box_afternm: crypto_box_afternm,\n crypto_box: crypto_box,\n crypto_box_open: crypto_box_open,\n crypto_box_keypair: crypto_box_keypair,\n crypto_hash: crypto_hash,\n crypto_sign: crypto_sign,\n crypto_sign_keypair: crypto_sign_keypair,\n crypto_sign_open: crypto_sign_open,\n\n crypto_secretbox_KEYBYTES: crypto_secretbox_KEYBYTES,\n crypto_secretbox_NONCEBYTES: crypto_secretbox_NONCEBYTES,\n crypto_secretbox_ZEROBYTES: crypto_secretbox_ZEROBYTES,\n crypto_secretbox_BOXZEROBYTES: crypto_secretbox_BOXZEROBYTES,\n crypto_scalarmult_BYTES: crypto_scalarmult_BYTES,\n crypto_scalarmult_SCALARBYTES: crypto_scalarmult_SCALARBYTES,\n crypto_box_PUBLICKEYBYTES: crypto_box_PUBLICKEYBYTES,\n crypto_box_SECRETKEYBYTES: crypto_box_SECRETKEYBYTES,\n crypto_box_BEFORENMBYTES: crypto_box_BEFORENMBYTES,\n crypto_box_NONCEBYTES: crypto_box_NONCEBYTES,\n crypto_box_ZEROBYTES: crypto_box_ZEROBYTES,\n crypto_box_BOXZEROBYTES: crypto_box_BOXZEROBYTES,\n crypto_sign_BYTES: crypto_sign_BYTES,\n crypto_sign_PUBLICKEYBYTES: crypto_sign_PUBLICKEYBYTES,\n crypto_sign_SECRETKEYBYTES: crypto_sign_SECRETKEYBYTES,\n crypto_sign_SEEDBYTES: crypto_sign_SEEDBYTES,\n crypto_hash_BYTES: crypto_hash_BYTES,\n\n gf: gf,\n D: D,\n L: L,\n pack25519: pack25519,\n unpack25519: unpack25519,\n M: M,\n A: A,\n S: S,\n Z: Z,\n pow2523: pow2523,\n add: add,\n set25519: set25519,\n modL: modL,\n scalarmult: scalarmult,\n scalarbase: scalarbase,\n};\n\n/* High-level API */\n\nfunction checkLengths(k, n) {\n if (k.length !== crypto_secretbox_KEYBYTES) throw new Error('bad key size');\n if (n.length !== crypto_secretbox_NONCEBYTES) throw new Error('bad nonce size');\n}\n\nfunction checkBoxLengths(pk, sk) {\n if (pk.length !== crypto_box_PUBLICKEYBYTES) throw new Error('bad public key size');\n if (sk.length !== crypto_box_SECRETKEYBYTES) throw new Error('bad secret key size');\n}\n\nfunction checkArrayTypes() {\n for (var i = 0; i < arguments.length; i++) {\n if (!(arguments[i] instanceof Uint8Array))\n throw new TypeError('unexpected type, use Uint8Array');\n }\n}\n\nfunction cleanup(arr) {\n for (var i = 0; i < arr.length; i++) arr[i] = 0;\n}\n\nnacl.randomBytes = function(n) {\n var b = new Uint8Array(n);\n randombytes(b, n);\n return b;\n};\n\nnacl.secretbox = function(msg, nonce, key) {\n checkArrayTypes(msg, nonce, key);\n checkLengths(key, nonce);\n var m = new Uint8Array(crypto_secretbox_ZEROBYTES + msg.length);\n var c = new Uint8Array(m.length);\n for (var i = 0; i < msg.length; i++) m[i+crypto_secretbox_ZEROBYTES] = msg[i];\n crypto_secretbox(c, m, m.length, nonce, key);\n return c.subarray(crypto_secretbox_BOXZEROBYTES);\n};\n\nnacl.secretbox.open = function(box, nonce, key) {\n checkArrayTypes(box, nonce, key);\n checkLengths(key, nonce);\n var c = new Uint8Array(crypto_secretbox_BOXZEROBYTES + box.length);\n var m = new Uint8Array(c.length);\n for (var i = 0; i < box.length; i++) c[i+crypto_secretbox_BOXZEROBYTES] = box[i];\n if (c.length < 32) return null;\n if (crypto_secretbox_open(m, c, c.length, nonce, key) !== 0) return null;\n return m.subarray(crypto_secretbox_ZEROBYTES);\n};\n\nnacl.secretbox.keyLength = crypto_secretbox_KEYBYTES;\nnacl.secretbox.nonceLength = crypto_secretbox_NONCEBYTES;\nnacl.secretbox.overheadLength = crypto_secretbox_BOXZEROBYTES;\n\nnacl.scalarMult = function(n, p) {\n checkArrayTypes(n, p);\n if (n.length !== crypto_scalarmult_SCALARBYTES) throw new Error('bad n size');\n if (p.length !== crypto_scalarmult_BYTES) throw new Error('bad p size');\n var q = new Uint8Array(crypto_scalarmult_BYTES);\n crypto_scalarmult(q, n, p);\n return q;\n};\n\nnacl.scalarMult.base = function(n) {\n checkArrayTypes(n);\n if (n.length !== crypto_scalarmult_SCALARBYTES) throw new Error('bad n size');\n var q = new Uint8Array(crypto_scalarmult_BYTES);\n crypto_scalarmult_base(q, n);\n return q;\n};\n\nnacl.scalarMult.scalarLength = crypto_scalarmult_SCALARBYTES;\nnacl.scalarMult.groupElementLength = crypto_scalarmult_BYTES;\n\nnacl.box = function(msg, nonce, publicKey, secretKey) {\n var k = nacl.box.before(publicKey, secretKey);\n return nacl.secretbox(msg, nonce, k);\n};\n\nnacl.box.before = function(publicKey, secretKey) {\n checkArrayTypes(publicKey, secretKey);\n checkBoxLengths(publicKey, secretKey);\n var k = new Uint8Array(crypto_box_BEFORENMBYTES);\n crypto_box_beforenm(k, publicKey, secretKey);\n return k;\n};\n\nnacl.box.after = nacl.secretbox;\n\nnacl.box.open = function(msg, nonce, publicKey, secretKey) {\n var k = nacl.box.before(publicKey, secretKey);\n return nacl.secretbox.open(msg, nonce, k);\n};\n\nnacl.box.open.after = nacl.secretbox.open;\n\nnacl.box.keyPair = function() {\n var pk = new Uint8Array(crypto_box_PUBLICKEYBYTES);\n var sk = new Uint8Array(crypto_box_SECRETKEYBYTES);\n crypto_box_keypair(pk, sk);\n return {publicKey: pk, secretKey: sk};\n};\n\nnacl.box.keyPair.fromSecretKey = function(secretKey) {\n checkArrayTypes(secretKey);\n if (secretKey.length !== crypto_box_SECRETKEYBYTES)\n throw new Error('bad secret key size');\n var pk = new Uint8Array(crypto_box_PUBLICKEYBYTES);\n crypto_scalarmult_base(pk, secretKey);\n return {publicKey: pk, secretKey: new Uint8Array(secretKey)};\n};\n\nnacl.box.publicKeyLength = crypto_box_PUBLICKEYBYTES;\nnacl.box.secretKeyLength = crypto_box_SECRETKEYBYTES;\nnacl.box.sharedKeyLength = crypto_box_BEFORENMBYTES;\nnacl.box.nonceLength = crypto_box_NONCEBYTES;\nnacl.box.overheadLength = nacl.secretbox.overheadLength;\n\nnacl.sign = function(msg, secretKey) {\n checkArrayTypes(msg, secretKey);\n if (secretKey.length !== crypto_sign_SECRETKEYBYTES)\n throw new Error('bad secret key size');\n var signedMsg = new Uint8Array(crypto_sign_BYTES+msg.length);\n crypto_sign(signedMsg, msg, msg.length, secretKey);\n return signedMsg;\n};\n\nnacl.sign.open = function(signedMsg, publicKey) {\n checkArrayTypes(signedMsg, publicKey);\n if (publicKey.length !== crypto_sign_PUBLICKEYBYTES)\n throw new Error('bad public key size');\n var tmp = new Uint8Array(signedMsg.length);\n var mlen = crypto_sign_open(tmp, signedMsg, signedMsg.length, publicKey);\n if (mlen < 0) return null;\n var m = new Uint8Array(mlen);\n for (var i = 0; i < m.length; i++) m[i] = tmp[i];\n return m;\n};\n\nnacl.sign.detached = function(msg, secretKey) {\n var signedMsg = nacl.sign(msg, secretKey);\n var sig = new Uint8Array(crypto_sign_BYTES);\n for (var i = 0; i < sig.length; i++) sig[i] = signedMsg[i];\n return sig;\n};\n\nnacl.sign.detached.verify = function(msg, sig, publicKey) {\n checkArrayTypes(msg, sig, publicKey);\n if (sig.length !== crypto_sign_BYTES)\n throw new Error('bad signature size');\n if (publicKey.length !== crypto_sign_PUBLICKEYBYTES)\n throw new Error('bad public key size');\n var sm = new Uint8Array(crypto_sign_BYTES + msg.length);\n var m = new Uint8Array(crypto_sign_BYTES + msg.length);\n var i;\n for (i = 0; i < crypto_sign_BYTES; i++) sm[i] = sig[i];\n for (i = 0; i < msg.length; i++) sm[i+crypto_sign_BYTES] = msg[i];\n return (crypto_sign_open(m, sm, sm.length, publicKey) >= 0);\n};\n\nnacl.sign.keyPair = function() {\n var pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);\n var sk = new Uint8Array(crypto_sign_SECRETKEYBYTES);\n crypto_sign_keypair(pk, sk);\n return {publicKey: pk, secretKey: sk};\n};\n\nnacl.sign.keyPair.fromSecretKey = function(secretKey) {\n checkArrayTypes(secretKey);\n if (secretKey.length !== crypto_sign_SECRETKEYBYTES)\n throw new Error('bad secret key size');\n var pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);\n for (var i = 0; i < pk.length; i++) pk[i] = secretKey[32+i];\n return {publicKey: pk, secretKey: new Uint8Array(secretKey)};\n};\n\nnacl.sign.keyPair.fromSeed = function(seed) {\n checkArrayTypes(seed);\n if (seed.length !== crypto_sign_SEEDBYTES)\n throw new Error('bad seed size');\n var pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);\n var sk = new Uint8Array(crypto_sign_SECRETKEYBYTES);\n for (var i = 0; i < 32; i++) sk[i] = seed[i];\n crypto_sign_keypair(pk, sk, true);\n return {publicKey: pk, secretKey: sk};\n};\n\nnacl.sign.publicKeyLength = crypto_sign_PUBLICKEYBYTES;\nnacl.sign.secretKeyLength = crypto_sign_SECRETKEYBYTES;\nnacl.sign.seedLength = crypto_sign_SEEDBYTES;\nnacl.sign.signatureLength = crypto_sign_BYTES;\n\nnacl.hash = function(msg) {\n checkArrayTypes(msg);\n var h = new Uint8Array(crypto_hash_BYTES);\n crypto_hash(h, msg, msg.length);\n return h;\n};\n\nnacl.hash.hashLength = crypto_hash_BYTES;\n\nnacl.verify = function(x, y) {\n checkArrayTypes(x, y);\n // Zero length arguments are considered not equal.\n if (x.length === 0 || y.length === 0) return false;\n if (x.length !== y.length) return false;\n return (vn(x, 0, y, 0, x.length) === 0) ? true : false;\n};\n\nnacl.setPRNG = function(fn) {\n randombytes = fn;\n};\n\n(function() {\n // Initialize PRNG if environment provides CSPRNG.\n // If not, methods calling randombytes will throw.\n var crypto = typeof self !== 'undefined' ? (self.crypto || self.msCrypto) : null;\n if (crypto && crypto.getRandomValues) {\n // Browsers.\n var QUOTA = 65536;\n nacl.setPRNG(function(x, n) {\n var i, v = new Uint8Array(n);\n for (i = 0; i < n; i += QUOTA) {\n crypto.getRandomValues(v.subarray(i, i + Math.min(n - i, QUOTA)));\n }\n for (i = 0; i < n; i++) x[i] = v[i];\n cleanup(v);\n });\n } else if (typeof require !== 'undefined') {\n // Node.js.\n crypto = require('crypto');\n if (crypto && crypto.randomBytes) {\n nacl.setPRNG(function(x, n) {\n var i, v = crypto.randomBytes(n);\n for (i = 0; i < n; i++) x[i] = v[i];\n cleanup(v);\n });\n }\n }\n})();\n\n})(typeof module !== 'undefined' && module.exports ? module.exports : (self.nacl = self.nacl || {}));\n","module.exports = require('./pusher-with-encryption').default;\n","import Pusher from './pusher';\nimport { Options, validateOptions } from './options';\nimport * as nacl from 'tweetnacl';\n\nexport default class PusherWithEncryption extends Pusher {\n constructor(app_key: string, options: Options) {\n Pusher.logToConsole = PusherWithEncryption.logToConsole;\n Pusher.log = PusherWithEncryption.log;\n\n validateOptions(options);\n options.nacl = nacl;\n super(app_key, options);\n }\n}\n"],"sourceRoot":""} \ No newline at end of file +{"version":3,"sources":["webpack://Pusher/webpack/bootstrap","webpack://Pusher/./src/core/utils/collections.ts","webpack://Pusher/./src/core/logger.ts","webpack://Pusher/./src/core/util.ts","webpack://Pusher/./src/core/events/dispatcher.ts","webpack://Pusher/./src/core/utils/timers/index.ts","webpack://Pusher/./src/core/defaults.ts","webpack://Pusher/./src/core/transports/url_schemes.ts","webpack://Pusher/./src/core/transports/transport_connection.ts","webpack://Pusher/./src/core/transports/transport.ts","webpack://Pusher/./src/runtimes/isomorphic/transports/transports.ts","webpack://Pusher/./src/core/transports/assistant_to_the_transport_manager.ts","webpack://Pusher/./src/core/connection/protocol/protocol.ts","webpack://Pusher/./src/core/connection/connection.ts","webpack://Pusher/./src/core/connection/handshake/index.ts","webpack://Pusher/./src/core/timeline/timeline_sender.ts","webpack://Pusher/./src/core/errors.ts","webpack://Pusher/./src/core/utils/url_store.ts","webpack://Pusher/./src/core/channels/channel.ts","webpack://Pusher/./src/core/channels/private_channel.ts","webpack://Pusher/./src/core/channels/members.ts","webpack://Pusher/./src/core/channels/presence_channel.ts","webpack://Pusher/./src/core/channels/encrypted_channel.ts","webpack://Pusher/./src/core/connection/connection_manager.ts","webpack://Pusher/./src/core/channels/channels.ts","webpack://Pusher/./src/core/utils/factory.ts","webpack://Pusher/./src/core/transports/transport_manager.ts","webpack://Pusher/./src/core/strategies/sequential_strategy.ts","webpack://Pusher/./src/core/strategies/best_connected_ever_strategy.ts","webpack://Pusher/./src/core/strategies/websocket_prioritized_cached_strategy.ts","webpack://Pusher/./src/core/strategies/delayed_strategy.ts","webpack://Pusher/./src/core/strategies/if_strategy.ts","webpack://Pusher/./src/core/strategies/first_connected_strategy.ts","webpack://Pusher/./src/runtimes/isomorphic/default_strategy.ts","webpack://Pusher/./src/core/http/http_request.ts","webpack://Pusher/./src/core/http/state.ts","webpack://Pusher/./src/core/http/http_socket.ts","webpack://Pusher/./src/core/http/http_streaming_socket.ts","webpack://Pusher/./src/core/http/http_polling_socket.ts","webpack://Pusher/./src/runtimes/isomorphic/http/http_xhr_request.ts","webpack://Pusher/./src/runtimes/isomorphic/runtime.ts","webpack://Pusher/./src/runtimes/isomorphic/transports/transport_connection_initializer.ts","webpack://Pusher/./src/runtimes/isomorphic/http/http.ts","webpack://Pusher/./src/runtimes/react-native/net_info.ts","webpack://Pusher/./src/core/auth/options.ts","webpack://Pusher/./src/runtimes/isomorphic/auth/xhr_auth.ts","webpack://Pusher/./src/runtimes/isomorphic/timeline/xhr_timeline.ts","webpack://Pusher/./src/runtimes/react-native/runtime.ts","webpack://Pusher/./src/core/timeline/level.ts","webpack://Pusher/./src/core/timeline/timeline.ts","webpack://Pusher/./src/core/strategies/transport_strategy.ts","webpack://Pusher/./src/core/strategies/strategy_builder.ts","webpack://Pusher/./src/core/auth/user_authenticator.ts","webpack://Pusher/./src/core/auth/channel_authorizer.ts","webpack://Pusher/./src/core/config.ts","webpack://Pusher/./src/core/auth/deprecated_channel_authorizer.ts","webpack://Pusher/./src/core/watchlist.ts","webpack://Pusher/./src/core/utils/flat_promise.ts","webpack://Pusher/./src/core/user.ts","webpack://Pusher/./src/core/pusher.ts","webpack://Pusher/(webpack)/buildin/global.js","webpack://Pusher/./src/core/options.ts","webpack://Pusher/./node_modules/@stablelib/base64/base64.ts","webpack://Pusher/./src/core/utils/timers/abstract_timer.ts","webpack://Pusher/external \"@react-native-community/netinfo\"","webpack://Pusher/./src/core/base64.ts","webpack://Pusher/./src/core/events/callback_registry.ts","webpack://Pusher/./node_modules/@stablelib/utf8/utf8.ts","webpack://Pusher/./node_modules/tweetnacl/nacl-fast.js","webpack://Pusher/./src/core/pusher-with-encryption.js","webpack://Pusher/./src/core/pusher-with-encryption.ts"],"names":["installedModules","__webpack_require__","moduleId","exports","module","i","l","modules","call","m","c","d","name","getter","o","Object","defineProperty","enumerable","get","r","Symbol","toStringTag","value","t","mode","__esModule","ns","create","key","bind","n","object","property","prototype","hasOwnProperty","p","s","extend","target","sources","length","extensions","constructor","stringify","arguments","push","safeJSONStringify","join","arrayIndexOf","array","item","nativeIndexOf","Array","indexOf","objectApply","f","keys","_","values","apply","context","global","map","result","filter","test","filterObject","Boolean","any","all","encodeParamsObject","data","encodeURIComponent","toString","buildQueryString","params","undefined","method","source","JSON","e","objects","paths","derez","path","nu","$ref","globalLog","message","console","log","args","this","globalLogWarn","globalLogError","warn","error","defaultLoggingFunction","logToConsole","Util","now","Date","valueOf","defer","callback","boundArguments","slice","concat","Dispatcher","failThrough","callbacks","global_callbacks","eventName","add","remove","unbind","unbind_global","metadata","fn","clearTimeout","timer","clearInterval","OneOffTimer","delay","super","setTimeout","PeriodicTimer","setInterval","VERSION","PROTOCOL","wsPort","wssPort","wsPath","httpHost","httpPort","httpsPort","httpPath","stats_host","authEndpoint","authTransport","activityTimeout","pongTimeout","unavailableTimeout","userAuthentication","endpoint","transport","channelAuthorization","cdn_http","cdn_https","dependency_suffix","getGenericURL","baseScheme","useTLS","hostTLS","hostNonTLS","getGenericPath","queryString","ws","getInitial","http","hooks","priority","options","initialize","transportConnectionInitializer","state","timeline","id","generateUniqueID","handlesActivityChecks","supportsPing","socket","url","urls","getSocket","onError","changeState","bindListeners","debug","close","send","ping","beforeOpen","getPath","onopen","emit","type","buildTimelineMessage","closeEvent","code","reason","wasClean","unbindListeners","onOpen","onerror","onclose","onClose","onmessage","onMessage","onactivity","onActivity","info","cid","environment","isSupported","WSTransport","isInitialized","getWebSocketAPI","createWebSocket","httpConfiguration","streamingConfiguration","HTTPFactory","createStreamingSocket","pollingConfiguration","createPollingSocket","xhrConfiguration","isXHRSupported","xhr_streaming","xhr_polling","manager","minPingDelay","maxPingDelay","pingDelay","connection","createConnection","openTimestamp","onClosed","reportDeath","lifespan","Math","max","isAlive","Protocol","decodeMessage","messageEvent","messageData","parse","pusherEventData","pusherEvent","event","channel","user_id","encodeMessage","processHandshake","activity_timeout","action","socket_id","getCloseAction","getCloseError","send_event","listeners","activity","closed","handleCloseEvent","listener","finish","isEmpty","TimelineTransport","getAgent","BadEventName","Error","msg","setPrototypeOf","BadChannelName","TransportPriorityTooLow","TransportClosed","UnsupportedFeature","UnsupportedTransport","UnsupportedStrategy","HTTPAuthError","status","urlStore","baseUrl","authenticationEndpoint","authorizationEndpoint","javascriptQuickStart","triggeringClientEvents","encryptedChannelSupport","fullUrl","urlObj","pusher","subscribed","subscriptionPending","subscriptionCancelled","socketId","auth","suffix","handleSubscriptionSucceededEvent","handleSubscriptionCountEvent","unsubscribe","subscription_count","subscriptionCount","authorize","assign","channel_data","config","channelAuthorizer","channelName","reset","members","member","myID","subscriptionData","presence","hash","count","me","memberData","user_info","authData","channelData","setMyID","user","signinDonePromise","user_data","handleInternalEvent","addedMember","addMember","removedMember","removeMember","onSubscription","disconnect","nacl","sharedSecret","handleEncryptedEvent","handleEvent","ciphertext","nonce","cipherText","secretbox","overheadLength","nonceLength","bytes","open","getDataToEmit","raw","usingTLS","errorCallbacks","buildErrorCallbacks","connectionCallbacks","buildConnectionCallbacks","handshakeCallbacks","buildHandshakeCallbacks","Network","getNetwork","netinfo","retryIn","sendActivityCheck","updateStrategy","runner","strategy","updateState","startConnecting","setUnavailableTimer","disconnectInternally","handshake","connect","handshakeError","abortConnecting","abort","clearRetryTimer","clearUnavailableTimer","abandonConnection","getStrategy","round","retryTimer","ensureAborted","unavailableTimer","stopActivityCheck","activityTimer","pong_timed_out","resetActivityCheck","shouldRetry","connected","min","Infinity","setConnection","withErrorEmitted","tls_only","refused","backoff","retry","newState","previousState","newStateDescription","previous","current","channels","createEncryptedChannel","errMsg","createPrivateChannel","createPresenceChannel","createChannel","createChannels","createConnectionManager","createTimelineSender","createHandshake","createAssistantToTheTransportManager","livesLeft","lives","strategies","loop","failFast","timeout","timeoutLimit","minPriority","tryNextStrategy","tryStrategy","forceMinPriority","isRunning","callbackBuilder","runners","rs","abortRunner","allRunnersFailed","aborted","transports","ttl","storage","getLocalStorage","serializedCache","getTransportCacheKey","flushTransportCache","fetchTransportCache","cacheSkipCount","timestamp","includes","cached","latency","startTimestamp","pop","cb","storeTransportCache","number","IfStrategy","trueBranch","falseBranch","FirstConnectedStrategy","testSupportsStrategy","baseOptions","defineTransport","definedTransports","defineTransportStrategy","wsStrategy","ws_options","wsHost","wss_options","http_options","timeouts","ws_manager","streaming_manager","ws_transport","wss_transport","xhr_streaming_transport","xhr_polling_transport","ws_loop","wss_loop","streaming_loop","polling_loop","http_loop","payload","position","xhr","getRequest","unloader","addUnloadListener","setRequestHeader","removeUnloadListener","abortRequest","chunk","advanceBuffer","isBufferTooLong","buffer","unreadData","endOfLinePosition","State","autoIncrement","getUniqueURL","separator","randomNumber","randomInt","session","randomString","location","parts","exec","base","getLocation","readyState","CONNECTING","openStream","sendRaw","sendHeartbeat","OPEN","createSocketRequest","start","closeStream","CLOSED","onEvent","onHeartbeat","hostname","urlParts","stream","getReceiveURL","onChunk","onFinished","reconnect","unbind_all","getXHRAPI","onreadystatechange","onprogress","responseText","getDefaultStrategy","Transports","createSocket","createRequest","PusherClass","ready","getClientFeatures","getProtocol","createXHR","hasOnlineConnectionState","connectionState","toLowerCase","online","fetch","then","addEventListener","isNowOnline","AuthRequestType","query","authOptions","authRequestType","headerName","headers","headersProvider","dynamicHeaders","parsed","UserAuthentication","ChannelAuthorization","sender","host","setup","TimelineLevel","getAuthorizers","ajax","WebSocket","XMLHttpRequest","floor","random","events","sent","uniqueID","level","limit","shift","ERROR","INFO","DEBUG","sendfn","bundle","lib","version","cluster","features","failAttempt","onInitialized","serializedTransport","transportClass","enabledTransports","disabledTransports","ignoreNullOrigin","getAssistant","deferred","paramsProvider","dynamicParams","composeChannelQuery","getConfig","opts","statsHost","enableStats","getEnableStatsConfig","getHttpHost","shouldUseTLS","getWebsocketHost","userAuthenticator","buildUserAuthenticator","buildChannelAuthorizer","timelineParams","forceTLS","disableStats","customHandler","channelAuthorizerGenerator","deprecatedAuthorizerOptions","ChannelAuthorizerProxy","authorizer","buildChannelAuth","bindWatchlistInternalEvent","forEach","watchlistEvent","resolve","reject","promise","Promise","res","rej","signin_requested","serverToUserChannel","_signinDoneResolve","_onAuthorize","err","_cleanup","_signin","_newSigninPromiseIfNeeded","watchlist","_onSigninSuccess","_subscribeChannels","bind_global","reinstateSubscription","subscribe","ensure_subscribed","done","setDone","catch","isReady","instances","app_key","checkAppKey","global_emitter","sessionID","timelineSender","subscribeAll","isUsingTLS","internal","appKey","switchCluster","find","timelineSenderTimer","event_name","channel_name","cancelSubscription","signin","Runtime","ScriptReceivers","DependenciesReceivers","auth_callbacks","g","Function","window","validateOptions","_paddingCharacter","encodedLength","encode","out","_encodeByte","left","maxDecodedLength","decodedLength","_getPaddingLength","decode","Uint8Array","paddingLength","op","haveBad","v0","v1","v2","v3","_decodeChar","charCodeAt","b","String","fromCharCode","Coder","stdCoder","URLSafeCoder","urlSafeCoder","set","clear","require","btoa","utob","b64chars","b64tab","charAt","cb_utob","cc","u","replace","cb_encode","ccc","padlen","ord","CallbackRegistry","_callbacks","prefix","prefixedEventName","names","removeCallback","removeAllCallbacks","binding","INVALID_UTF8","arr","pos","chars","n1","n2","n3","gf","init","Float64Array","randombytes","_0","_9","gf0","gf1","_121665","D","D2","X","Y","I","ts64","x","h","vn","xi","y","yi","crypto_verify_16","crypto_verify_32","crypto_core_salsa20","inp","k","j0","j1","j2","j3","j4","j5","j6","j7","j8","j9","j10","j11","j12","j13","j14","j15","x0","x1","x2","x3","x4","x5","x6","x7","x8","x9","x10","x11","x12","x13","x14","x15","core_salsa20","crypto_core_hsalsa20","core_hsalsa20","sigma","crypto_stream_salsa20_xor","cpos","mpos","z","crypto_stream_salsa20","crypto_stream","sn","crypto_stream_xor","poly1305","t0","t1","t2","t3","t4","t5","t6","t7","Uint16Array","pad","leftover","fin","crypto_onetimeauth","outpos","update","crypto_onetimeauth_verify","hpos","crypto_secretbox","crypto_secretbox_open","set25519","a","car25519","v","sel25519","q","pack25519","j","neq25519","par25519","unpack25519","A","Z","M","t8","t9","t10","t11","t12","t13","t14","t15","t16","t17","t18","t19","t20","t21","t22","t23","t24","t25","t26","t27","t28","t29","t30","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","b10","b11","b12","b13","b14","b15","S","inv25519","pow2523","crypto_scalarmult","x32","subarray","x16","crypto_scalarmult_base","crypto_box_keypair","crypto_box_beforenm","blocks","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","hibit","h0","h1","h2","h3","h4","h5","h6","h7","h8","h9","r0","r1","r2","r3","r4","r5","r6","r7","r8","r9","mac","macpos","mask","want","crypto_box_afternm","crypto_box_open_afternm","K","crypto_hashblocks_hl","hh","hl","bh0","bh1","bh2","bh3","bh4","bh5","bh6","bh7","bl0","bl1","bl2","bl3","bl4","bl5","bl6","bl7","th","tl","wh","Int32Array","wl","ah0","ah1","ah2","ah3","ah4","ah5","ah6","ah7","al0","al1","al2","al3","al4","al5","al6","al7","crypto_hash","cswap","pack","tx","ty","zi","scalarmult","scalarbase","crypto_sign_keypair","pk","sk","seeded","L","modL","carry","reduce","crypto_sign","sm","smlen","crypto_sign_open","chk","num","den","den2","den4","den6","unpackneg","checkLengths","checkArrayTypes","TypeError","cleanup","lowlevel","crypto_box","crypto_box_open","crypto_secretbox_KEYBYTES","crypto_secretbox_NONCEBYTES","crypto_secretbox_ZEROBYTES","crypto_secretbox_BOXZEROBYTES","crypto_scalarmult_BYTES","crypto_scalarmult_SCALARBYTES","crypto_box_PUBLICKEYBYTES","crypto_box_SECRETKEYBYTES","crypto_box_BEFORENMBYTES","crypto_box_NONCEBYTES","crypto_box_ZEROBYTES","crypto_box_BOXZEROBYTES","crypto_sign_BYTES","crypto_sign_PUBLICKEYBYTES","crypto_sign_SECRETKEYBYTES","crypto_sign_SEEDBYTES","crypto_hash_BYTES","randomBytes","box","keyLength","scalarMult","scalarLength","groupElementLength","publicKey","secretKey","before","checkBoxLengths","after","keyPair","fromSecretKey","publicKeyLength","secretKeyLength","sharedKeyLength","sign","signedMsg","tmp","mlen","detached","sig","verify","fromSeed","seed","seedLength","signatureLength","hashLength","setPRNG","crypto","self","msCrypto","getRandomValues","default","PusherWithEncryption"],"mappings":";;;;;;;2BACE,IAAIA,EAAmB,GAGvB,SAASC,EAAoBC,GAG5B,GAAGF,EAAiBE,GACnB,OAAOF,EAAiBE,GAAUC,QAGnC,IAAIC,EAASJ,EAAiBE,GAAY,CACzCG,EAAGH,EACHI,GAAG,EACHH,QAAS,IAUV,OANAI,EAAQL,GAAUM,KAAKJ,EAAOD,QAASC,EAAQA,EAAOD,QAASF,GAG/DG,EAAOE,GAAI,EAGJF,EAAOD,QA0Df,OArDAF,EAAoBQ,EAAIF,EAGxBN,EAAoBS,EAAIV,EAGxBC,EAAoBU,EAAI,SAASR,EAASS,EAAMC,GAC3CZ,EAAoBa,EAAEX,EAASS,IAClCG,OAAOC,eAAeb,EAASS,EAAM,CAAEK,YAAY,EAAMC,IAAKL,KAKhEZ,EAAoBkB,EAAI,SAAShB,GACX,oBAAXiB,QAA0BA,OAAOC,aAC1CN,OAAOC,eAAeb,EAASiB,OAAOC,YAAa,CAAEC,MAAO,WAE7DP,OAAOC,eAAeb,EAAS,aAAc,CAAEmB,OAAO,KAQvDrB,EAAoBsB,EAAI,SAASD,EAAOE,GAEvC,GADU,EAAPA,IAAUF,EAAQrB,EAAoBqB,IAC/B,EAAPE,EAAU,OAAOF,E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IzB,EAAG4xB,EAAI,IAAI7I,WAAWtnB,GAC1B,IAAKzB,EAAI,EAAGA,EAAIyB,EAAGzB,GAHT,MAIRu/B,EAAOG,gBAAgB9N,EAAEuD,SAASn1B,EAAGA,EAAIgO,KAAKiJ,IAAIxV,EAAIzB,EAJ9C,SAMV,IAAKA,EAAI,EAAGA,EAAIyB,EAAGzB,IAAK8sB,EAAE9sB,GAAK4xB,EAAE5xB,GACjCq8B,GAAQzK,WAIV2N,EAAS,EAAQ,MACHA,EAAO7B,aACnB7pB,EAAKyrB,SAAQ,SAASxS,EAAGrrB,GACvB,IAAIzB,EAAG4xB,EAAI2N,EAAO7B,YAAYj8B,GAC9B,IAAKzB,EAAI,EAAGA,EAAIyB,EAAGzB,IAAK8sB,EAAE9sB,GAAK4xB,EAAE5xB,GACjCq8B,GAAQzK,MAtBhB,GA1zEA,CAs1EoC7xB,EAAOD,QAAUC,EAAOD,QAAW0/B,KAAK3rB,KAAO2rB,KAAK3rB,MAAQ,K,gBCt1EhG9T,EAAOD,QAAU,EAAQ,IAA4B6/B,S,6BCArD,yEAIe,MAAMC,UAA6B,IAChD,YAAY/Y,EAAiBhd,GAC3B,IAAOhE,aAAe+5B,EAAqB/5B,aAC3C,IAAOR,IAAMu6B,EAAqBv6B,IAElC,YAAgBwE,GAChBA,EAAQgK,KAAO,EACftM,MAAMsf,EAAShd,M","file":"pusher.js","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 15);\n","import base64encode from '../base64';\nimport Util from '../util';\n\n/** Merges multiple objects into the target argument.\n *\n * For properties that are plain Objects, performs a deep-merge. For the\n * rest it just copies the value of the property.\n *\n * To extend prototypes use it as following:\n * Pusher.Util.extend(Target.prototype, Base.prototype)\n *\n * You can also use it to merge objects without altering them:\n * Pusher.Util.extend({}, object1, object2)\n *\n * @param {Object} target\n * @return {Object} the target argument\n */\nexport function extend(target: any, ...sources: any[]): T {\n for (var i = 0; i < sources.length; i++) {\n var extensions = sources[i];\n for (var property in extensions) {\n if (\n extensions[property] &&\n extensions[property].constructor &&\n extensions[property].constructor === Object\n ) {\n target[property] = extend(target[property] || {}, extensions[property]);\n } else {\n target[property] = extensions[property];\n }\n }\n }\n return target;\n}\n\nexport function stringify(): string {\n var m = ['Pusher'];\n for (var i = 0; i < arguments.length; i++) {\n if (typeof arguments[i] === 'string') {\n m.push(arguments[i]);\n } else {\n m.push(safeJSONStringify(arguments[i]));\n }\n }\n return m.join(' : ');\n}\n\nexport function arrayIndexOf(array: any[], item: any): number {\n // MSIE doesn't have array.indexOf\n var nativeIndexOf = Array.prototype.indexOf;\n if (array === null) {\n return -1;\n }\n if (nativeIndexOf && array.indexOf === nativeIndexOf) {\n return array.indexOf(item);\n }\n for (var i = 0, l = array.length; i < l; i++) {\n if (array[i] === item) {\n return i;\n }\n }\n return -1;\n}\n\n/** Applies a function f to all properties of an object.\n *\n * Function f gets 3 arguments passed:\n * - element from the object\n * - key of the element\n * - reference to the object\n *\n * @param {Object} object\n * @param {Function} f\n */\nexport function objectApply(object: any, f: Function) {\n for (var key in object) {\n if (Object.prototype.hasOwnProperty.call(object, key)) {\n f(object[key], key, object);\n }\n }\n}\n\n/** Return a list of objects own proerty keys\n *\n * @param {Object} object\n * @returns {Array}\n */\nexport function keys(object: any): string[] {\n var keys = [];\n objectApply(object, function(_, key) {\n keys.push(key);\n });\n return keys;\n}\n\n/** Return a list of object's own property values\n *\n * @param {Object} object\n * @returns {Array}\n */\nexport function values(object: any): any[] {\n var values = [];\n objectApply(object, function(value) {\n values.push(value);\n });\n return values;\n}\n\n/** Applies a function f to all elements of an array.\n *\n * Function f gets 3 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function apply(array: any[], f: Function, context?: any) {\n for (var i = 0; i < array.length; i++) {\n f.call(context || global, array[i], i, array);\n }\n}\n\n/** Maps all elements of the array and returns the result.\n *\n * Function f gets 4 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n * - reference to the destination array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function map(array: any[], f: Function): any[] {\n var result = [];\n for (var i = 0; i < array.length; i++) {\n result.push(f(array[i], i, array, result));\n }\n return result;\n}\n\n/** Maps all elements of the object and returns the result.\n *\n * Function f gets 4 arguments passed:\n * - element from the object\n * - key of the element\n * - reference to the source object\n * - reference to the destination object\n *\n * @param {Object} object\n * @param {Function} f\n */\nexport function mapObject(object: any, f: Function): any {\n var result = {};\n objectApply(object, function(value, key) {\n result[key] = f(value);\n });\n return result;\n}\n\n/** Filters elements of the array using a test function.\n *\n * Function test gets 4 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n * - reference to the destination array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function filter(array: any[], test: Function): any[] {\n test =\n test ||\n function(value) {\n return !!value;\n };\n\n var result = [];\n for (var i = 0; i < array.length; i++) {\n if (test(array[i], i, array, result)) {\n result.push(array[i]);\n }\n }\n return result;\n}\n\n/** Filters properties of the object using a test function.\n *\n * Function test gets 4 arguments passed:\n * - element from the object\n * - key of the element\n * - reference to the source object\n * - reference to the destination object\n *\n * @param {Object} object\n * @param {Function} f\n */\nexport function filterObject(object: Object, test: Function) {\n var result = {};\n objectApply(object, function(value, key) {\n if ((test && test(value, key, object, result)) || Boolean(value)) {\n result[key] = value;\n }\n });\n return result;\n}\n\n/** Flattens an object into a two-dimensional array.\n *\n * @param {Object} object\n * @return {Array} resulting array of [key, value] pairs\n */\nexport function flatten(object: Object): any[] {\n var result = [];\n objectApply(object, function(value, key) {\n result.push([key, value]);\n });\n return result;\n}\n\n/** Checks whether any element of the array passes the test.\n *\n * Function test gets 3 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function any(array: any[], test: Function): boolean {\n for (var i = 0; i < array.length; i++) {\n if (test(array[i], i, array)) {\n return true;\n }\n }\n return false;\n}\n\n/** Checks whether all elements of the array pass the test.\n *\n * Function test gets 3 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function all(array: any[], test: Function): boolean {\n for (var i = 0; i < array.length; i++) {\n if (!test(array[i], i, array)) {\n return false;\n }\n }\n return true;\n}\n\nexport function encodeParamsObject(data): string {\n return mapObject(data, function(value) {\n if (typeof value === 'object') {\n value = safeJSONStringify(value);\n }\n return encodeURIComponent(base64encode(value.toString()));\n });\n}\n\nexport function buildQueryString(data: any): string {\n var params = filterObject(data, function(value) {\n return value !== undefined;\n });\n\n var query = map(\n flatten(encodeParamsObject(params)),\n Util.method('join', '=')\n ).join('&');\n\n return query;\n}\n\n/**\n * See https://github.com/douglascrockford/JSON-js/blob/master/cycle.js\n *\n * Remove circular references from an object. Required for JSON.stringify in\n * React Native, which tends to blow up a lot.\n *\n * @param {any} object\n * @return {any} Decycled object\n */\nexport function decycleObject(object: any): any {\n var objects = [],\n paths = [];\n\n return (function derez(value, path) {\n var i, name, nu;\n\n switch (typeof value) {\n case 'object':\n if (!value) {\n return null;\n }\n for (i = 0; i < objects.length; i += 1) {\n if (objects[i] === value) {\n return { $ref: paths[i] };\n }\n }\n\n objects.push(value);\n paths.push(path);\n\n if (Object.prototype.toString.apply(value) === '[object Array]') {\n nu = [];\n for (i = 0; i < value.length; i += 1) {\n nu[i] = derez(value[i], path + '[' + i + ']');\n }\n } else {\n nu = {};\n for (name in value) {\n if (Object.prototype.hasOwnProperty.call(value, name)) {\n nu[name] = derez(\n value[name],\n path + '[' + JSON.stringify(name) + ']'\n );\n }\n }\n }\n return nu;\n case 'number':\n case 'string':\n case 'boolean':\n return value;\n }\n })(object, '$');\n}\n\n/**\n * Provides a cross-browser and cross-platform way to safely stringify objects\n * into JSON. This is particularly necessary for ReactNative, where circular JSON\n * structures throw an exception.\n *\n * @param {any} source The object to stringify\n * @return {string} The serialized output.\n */\nexport function safeJSONStringify(source: any): string {\n try {\n return JSON.stringify(source);\n } catch (e) {\n return JSON.stringify(decycleObject(source));\n }\n}\n","import { stringify } from './utils/collections';\nimport Pusher from './pusher';\n\nclass Logger {\n debug(...args: any[]) {\n this.log(this.globalLog, args);\n }\n\n warn(...args: any[]) {\n this.log(this.globalLogWarn, args);\n }\n\n error(...args: any[]) {\n this.log(this.globalLogError, args);\n }\n\n private globalLog = (message: string) => {\n if (global.console && global.console.log) {\n global.console.log(message);\n }\n };\n\n private globalLogWarn(message: string) {\n if (global.console && global.console.warn) {\n global.console.warn(message);\n } else {\n this.globalLog(message);\n }\n }\n\n private globalLogError(message: string) {\n if (global.console && global.console.error) {\n global.console.error(message);\n } else {\n this.globalLogWarn(message);\n }\n }\n\n private log(\n defaultLoggingFunction: (message: string) => void,\n ...args: any[]\n ) {\n var message = stringify.apply(this, arguments);\n if (Pusher.log) {\n Pusher.log(message);\n } else if (Pusher.logToConsole) {\n const log = defaultLoggingFunction.bind(this);\n log(message);\n }\n }\n}\n\nexport default new Logger();\n","import * as Collections from './utils/collections';\nimport TimedCallback from './utils/timers/timed_callback';\nimport { OneOffTimer, PeriodicTimer } from './utils/timers';\n\nvar Util = {\n now(): number {\n if (Date.now) {\n return Date.now();\n } else {\n return new Date().valueOf();\n }\n },\n\n defer(callback: TimedCallback): OneOffTimer {\n return new OneOffTimer(0, callback);\n },\n\n /** Builds a function that will proxy a method call to its first argument.\n *\n * Allows partial application of arguments, so additional arguments are\n * prepended to the argument list.\n *\n * @param {String} name method name\n * @return {Function} proxy function\n */\n method(name: string, ...args: any[]): Function {\n var boundArguments = Array.prototype.slice.call(arguments, 1);\n return function(object) {\n return object[name].apply(object, boundArguments.concat(arguments));\n };\n }\n};\n\nexport default Util;\n","import * as Collections from '../utils/collections';\nimport Callback from './callback';\nimport Metadata from '../channels/metadata';\nimport CallbackRegistry from './callback_registry';\n\n/** Manages callback bindings and event emitting.\n *\n * @param Function failThrough called when no listeners are bound to an event\n */\nexport default class Dispatcher {\n callbacks: CallbackRegistry;\n global_callbacks: Function[];\n failThrough: Function;\n\n constructor(failThrough?: Function) {\n this.callbacks = new CallbackRegistry();\n this.global_callbacks = [];\n this.failThrough = failThrough;\n }\n\n bind(eventName: string, callback: Function, context?: any) {\n this.callbacks.add(eventName, callback, context);\n return this;\n }\n\n bind_global(callback: Function) {\n this.global_callbacks.push(callback);\n return this;\n }\n\n unbind(eventName?: string, callback?: Function, context?: any) {\n this.callbacks.remove(eventName, callback, context);\n return this;\n }\n\n unbind_global(callback?: Function) {\n if (!callback) {\n this.global_callbacks = [];\n return this;\n }\n\n this.global_callbacks = Collections.filter(\n this.global_callbacks || [],\n c => c !== callback\n );\n\n return this;\n }\n\n unbind_all() {\n this.unbind();\n this.unbind_global();\n return this;\n }\n\n emit(eventName: string, data?: any, metadata?: Metadata): Dispatcher {\n for (var i = 0; i < this.global_callbacks.length; i++) {\n this.global_callbacks[i](eventName, data);\n }\n\n var callbacks = this.callbacks.get(eventName);\n var args = [];\n\n if (metadata) {\n // if there's a metadata argument, we need to call the callback with both\n // data and metadata regardless of whether data is undefined\n args.push(data, metadata);\n } else if (data) {\n // metadata is undefined, so we only need to call the callback with data\n // if data exists\n args.push(data);\n }\n\n if (callbacks && callbacks.length > 0) {\n for (var i = 0; i < callbacks.length; i++) {\n callbacks[i].fn.apply(callbacks[i].context || global, args);\n }\n } else if (this.failThrough) {\n this.failThrough(eventName, data);\n }\n\n return this;\n }\n}\n","import Timer from './abstract_timer';\nimport TimedCallback from './timed_callback';\nimport { Delay } from './scheduling';\n\n// We need to bind clear functions this way to avoid exceptions on IE8\nfunction clearTimeout(timer) {\n global.clearTimeout(timer);\n}\nfunction clearInterval(timer) {\n global.clearInterval(timer);\n}\n\n/** Cross-browser compatible one-off timer abstraction.\n *\n * @param {Number} delay\n * @param {Function} callback\n */\nexport class OneOffTimer extends Timer {\n constructor(delay: Delay, callback: TimedCallback) {\n super(setTimeout, clearTimeout, delay, function(timer) {\n callback();\n return null;\n });\n }\n}\n\n/** Cross-browser compatible periodic timer abstraction.\n *\n * @param {Number} delay\n * @param {Function} callback\n */\nexport class PeriodicTimer extends Timer {\n constructor(delay: Delay, callback: TimedCallback) {\n super(setInterval, clearInterval, delay, function(timer) {\n callback();\n return timer;\n });\n }\n}\n","import {\n ChannelAuthorizationOptions,\n UserAuthenticationOptions\n} from './auth/options';\nimport { AuthTransport } from './config';\n\nexport interface DefaultConfig {\n VERSION: string;\n PROTOCOL: number;\n wsPort: number;\n wssPort: number;\n wsPath: string;\n httpHost: string;\n httpPort: number;\n httpsPort: number;\n httpPath: string;\n stats_host: string;\n authEndpoint: string;\n authTransport: AuthTransport;\n activityTimeout: number;\n pongTimeout: number;\n unavailableTimeout: number;\n userAuthentication: UserAuthenticationOptions;\n channelAuthorization: ChannelAuthorizationOptions;\n\n cdn_http?: string;\n cdn_https?: string;\n dependency_suffix?: string;\n}\n\nvar Defaults: DefaultConfig = {\n VERSION: VERSION,\n PROTOCOL: 7,\n\n wsPort: 80,\n wssPort: 443,\n wsPath: '',\n // DEPRECATED: SockJS fallback parameters\n httpHost: 'sockjs.pusher.com',\n httpPort: 80,\n httpsPort: 443,\n httpPath: '/pusher',\n // DEPRECATED: Stats\n stats_host: 'stats.pusher.com',\n // DEPRECATED: Other settings\n authEndpoint: '/pusher/auth',\n authTransport: 'ajax',\n activityTimeout: 120000,\n pongTimeout: 30000,\n unavailableTimeout: 10000,\n userAuthentication: {\n endpoint: '/pusher/user-auth',\n transport: 'ajax'\n },\n channelAuthorization: {\n endpoint: '/pusher/auth',\n transport: 'ajax'\n },\n\n // CDN configuration\n cdn_http: CDN_HTTP,\n cdn_https: CDN_HTTPS,\n dependency_suffix: DEPENDENCY_SUFFIX\n};\n\nexport default Defaults;\n","import Defaults from '../defaults';\nimport { default as URLScheme, URLSchemeParams } from './url_scheme';\n\nfunction getGenericURL(\n baseScheme: string,\n params: URLSchemeParams,\n path: string\n): string {\n var scheme = baseScheme + (params.useTLS ? 's' : '');\n var host = params.useTLS ? params.hostTLS : params.hostNonTLS;\n return scheme + '://' + host + path;\n}\n\nfunction getGenericPath(key: string, queryString?: string): string {\n var path = '/app/' + key;\n var query =\n '?protocol=' +\n Defaults.PROTOCOL +\n '&client=js' +\n '&version=' +\n Defaults.VERSION +\n (queryString ? '&' + queryString : '');\n return path + query;\n}\n\nexport var ws: URLScheme = {\n getInitial: function(key: string, params: URLSchemeParams): string {\n var path = (params.httpPath || '') + getGenericPath(key, 'flash=false');\n return getGenericURL('ws', params, path);\n }\n};\n\nexport var http: URLScheme = {\n getInitial: function(key: string, params: URLSchemeParams): string {\n var path = (params.httpPath || '/pusher') + getGenericPath(key);\n return getGenericURL('http', params, path);\n }\n};\n\nexport var sockjs: URLScheme = {\n getInitial: function(key: string, params: URLSchemeParams): string {\n return getGenericURL('http', params, params.httpPath || '/pusher');\n },\n getPath: function(key: string, params: URLSchemeParams): string {\n return getGenericPath(key);\n }\n};\n","import Util from '../util';\nimport * as Collections from '../utils/collections';\nimport { default as EventsDispatcher } from '../events/dispatcher';\nimport Logger from '../logger';\nimport TransportHooks from './transport_hooks';\nimport Socket from '../socket';\nimport Runtime from 'runtime';\nimport Timeline from '../timeline/timeline';\nimport TransportConnectionOptions from './transport_connection_options';\n\n/** Provides universal API for transport connections.\n *\n * Transport connection is a low-level object that wraps a connection method\n * and exposes a simple evented interface for the connection state and\n * messaging. It does not implement Pusher-specific WebSocket protocol.\n *\n * Additionally, it fetches resources needed for transport to work and exposes\n * an interface for querying transport features.\n *\n * States:\n * - new - initial state after constructing the object\n * - initializing - during initialization phase, usually fetching resources\n * - intialized - ready to establish a connection\n * - connection - when connection is being established\n * - open - when connection ready to be used\n * - closed - after connection was closed be either side\n *\n * Emits:\n * - error - after the connection raised an error\n *\n * Options:\n * - useTLS - whether connection should be over TLS\n * - hostTLS - host to connect to when connection is over TLS\n * - hostNonTLS - host to connect to when connection is over TLS\n *\n * @param {String} key application key\n * @param {Object} options\n */\nexport default class TransportConnection extends EventsDispatcher {\n hooks: TransportHooks;\n name: string;\n priority: number;\n key: string;\n options: TransportConnectionOptions;\n state: string;\n timeline: Timeline;\n activityTimeout: number;\n id: number;\n socket: Socket;\n beforeOpen: Function;\n initialize: Function;\n\n constructor(\n hooks: TransportHooks,\n name: string,\n priority: number,\n key: string,\n options: TransportConnectionOptions\n ) {\n super();\n this.initialize = Runtime.transportConnectionInitializer;\n this.hooks = hooks;\n this.name = name;\n this.priority = priority;\n this.key = key;\n this.options = options;\n\n this.state = 'new';\n this.timeline = options.timeline;\n this.activityTimeout = options.activityTimeout;\n this.id = this.timeline.generateUniqueID();\n }\n\n /** Checks whether the transport handles activity checks by itself.\n *\n * @return {Boolean}\n */\n handlesActivityChecks(): boolean {\n return Boolean(this.hooks.handlesActivityChecks);\n }\n\n /** Checks whether the transport supports the ping/pong API.\n *\n * @return {Boolean}\n */\n supportsPing(): boolean {\n return Boolean(this.hooks.supportsPing);\n }\n\n /** Tries to establish a connection.\n *\n * @returns {Boolean} false if transport is in invalid state\n */\n connect(): boolean {\n if (this.socket || this.state !== 'initialized') {\n return false;\n }\n\n var url = this.hooks.urls.getInitial(this.key, this.options);\n try {\n this.socket = this.hooks.getSocket(url, this.options);\n } catch (e) {\n Util.defer(() => {\n this.onError(e);\n this.changeState('closed');\n });\n return false;\n }\n\n this.bindListeners();\n\n Logger.debug('Connecting', { transport: this.name, url });\n this.changeState('connecting');\n return true;\n }\n\n /** Closes the connection.\n *\n * @return {Boolean} true if there was a connection to close\n */\n close(): boolean {\n if (this.socket) {\n this.socket.close();\n return true;\n } else {\n return false;\n }\n }\n\n /** Sends data over the open connection.\n *\n * @param {String} data\n * @return {Boolean} true only when in the \"open\" state\n */\n send(data: any): boolean {\n if (this.state === 'open') {\n // Workaround for MobileSafari bug (see https://gist.github.com/2052006)\n Util.defer(() => {\n if (this.socket) {\n this.socket.send(data);\n }\n });\n return true;\n } else {\n return false;\n }\n }\n\n /** Sends a ping if the connection is open and transport supports it. */\n ping() {\n if (this.state === 'open' && this.supportsPing()) {\n this.socket.ping();\n }\n }\n\n private onOpen() {\n if (this.hooks.beforeOpen) {\n this.hooks.beforeOpen(\n this.socket,\n this.hooks.urls.getPath(this.key, this.options)\n );\n }\n this.changeState('open');\n this.socket.onopen = undefined;\n }\n\n private onError(error) {\n this.emit('error', { type: 'WebSocketError', error: error });\n this.timeline.error(this.buildTimelineMessage({ error: error.toString() }));\n }\n\n private onClose(closeEvent?: any) {\n if (closeEvent) {\n this.changeState('closed', {\n code: closeEvent.code,\n reason: closeEvent.reason,\n wasClean: closeEvent.wasClean\n });\n } else {\n this.changeState('closed');\n }\n this.unbindListeners();\n this.socket = undefined;\n }\n\n private onMessage(message) {\n this.emit('message', message);\n }\n\n private onActivity() {\n this.emit('activity');\n }\n\n private bindListeners() {\n this.socket.onopen = () => {\n this.onOpen();\n };\n this.socket.onerror = error => {\n this.onError(error);\n };\n this.socket.onclose = closeEvent => {\n this.onClose(closeEvent);\n };\n this.socket.onmessage = message => {\n this.onMessage(message);\n };\n\n if (this.supportsPing()) {\n this.socket.onactivity = () => {\n this.onActivity();\n };\n }\n }\n\n private unbindListeners() {\n if (this.socket) {\n this.socket.onopen = undefined;\n this.socket.onerror = undefined;\n this.socket.onclose = undefined;\n this.socket.onmessage = undefined;\n if (this.supportsPing()) {\n this.socket.onactivity = undefined;\n }\n }\n }\n\n private changeState(state: string, params?: any) {\n this.state = state;\n this.timeline.info(\n this.buildTimelineMessage({\n state: state,\n params: params\n })\n );\n this.emit(state, params);\n }\n\n buildTimelineMessage(message): any {\n return Collections.extend({ cid: this.id }, message);\n }\n}\n","import Factory from '../utils/factory';\nimport TransportHooks from './transport_hooks';\nimport TransportConnection from './transport_connection';\nimport TransportConnectionOptions from './transport_connection_options';\n\n/** Provides interface for transport connection instantiation.\n *\n * Takes transport-specific hooks as the only argument, which allow checking\n * for transport support and creating its connections.\n *\n * Supported hooks: * - file - the name of the file to be fetched during initialization\n * - urls - URL scheme to be used by transport\n * - handlesActivityCheck - true when the transport handles activity checks\n * - supportsPing - true when the transport has a ping/activity API\n * - isSupported - tells whether the transport is supported in the environment\n * - getSocket - creates a WebSocket-compatible transport socket\n *\n * See transports.js for specific implementations.\n *\n * @param {Object} hooks object containing all needed transport hooks\n */\nexport default class Transport {\n hooks: TransportHooks;\n\n constructor(hooks: TransportHooks) {\n this.hooks = hooks;\n }\n\n /** Returns whether the transport is supported in the environment.\n *\n * @param {Object} envronment te environment details (encryption, settings)\n * @returns {Boolean} true when the transport is supported\n */\n isSupported(environment: any): boolean {\n return this.hooks.isSupported(environment);\n }\n\n /** Creates a transport connection.\n *\n * @param {String} name\n * @param {Number} priority\n * @param {String} key the application key\n * @param {Object} options\n * @returns {TransportConnection}\n */\n createConnection(\n name: string,\n priority: number,\n key: string,\n options: any\n ): TransportConnection {\n return new TransportConnection(this.hooks, name, priority, key, options);\n }\n}\n","import * as URLSchemes from 'core/transports/url_schemes';\nimport URLScheme from 'core/transports/url_scheme';\nimport Transport from 'core/transports/transport';\nimport Util from 'core/util';\nimport * as Collections from 'core/utils/collections';\nimport TransportHooks from 'core/transports/transport_hooks';\nimport TransportsTable from 'core/transports/transports_table';\nimport Runtime from 'runtime';\n\n/** WebSocket transport.\n *\n * Uses native WebSocket implementation, including MozWebSocket supported by\n * earlier Firefox versions.\n */\nvar WSTransport = new Transport({\n urls: URLSchemes.ws,\n handlesActivityChecks: false,\n supportsPing: false,\n\n isInitialized: function() {\n return Boolean(Runtime.getWebSocketAPI());\n },\n isSupported: function(): boolean {\n return Boolean(Runtime.getWebSocketAPI());\n },\n getSocket: function(url) {\n return Runtime.createWebSocket(url);\n }\n});\n\nvar httpConfiguration = {\n urls: URLSchemes.http,\n handlesActivityChecks: false,\n supportsPing: true,\n isInitialized: function() {\n return true;\n }\n};\n\nexport var streamingConfiguration = Collections.extend(\n {\n getSocket: function(url) {\n return Runtime.HTTPFactory.createStreamingSocket(url);\n }\n },\n httpConfiguration\n);\nexport var pollingConfiguration = Collections.extend(\n {\n getSocket: function(url) {\n return Runtime.HTTPFactory.createPollingSocket(url);\n }\n },\n httpConfiguration\n);\n\nvar xhrConfiguration = {\n isSupported: function(): boolean {\n return Runtime.isXHRSupported();\n }\n};\n\n/** HTTP streaming transport using CORS-enabled XMLHttpRequest. */\nvar XHRStreamingTransport = new Transport(\n (\n Collections.extend({}, streamingConfiguration, xhrConfiguration)\n )\n);\n\n/** HTTP long-polling transport using CORS-enabled XMLHttpRequest. */\nvar XHRPollingTransport = new Transport(\n Collections.extend({}, pollingConfiguration, xhrConfiguration)\n);\n\nvar Transports: TransportsTable = {\n ws: WSTransport,\n xhr_streaming: XHRStreamingTransport,\n xhr_polling: XHRPollingTransport\n};\n\nexport default Transports;\n","import Util from '../util';\nimport * as Collections from '../utils/collections';\nimport TransportManager from './transport_manager';\nimport TransportConnection from './transport_connection';\nimport Transport from './transport';\nimport PingDelayOptions from './ping_delay_options';\n\n/** Creates transport connections monitored by a transport manager.\n *\n * When a transport is closed, it might mean the environment does not support\n * it. It's possible that messages get stuck in an intermediate buffer or\n * proxies terminate inactive connections. To combat these problems,\n * assistants monitor the connection lifetime, report unclean exits and\n * adjust ping timeouts to keep the connection active. The decision to disable\n * a transport is the manager's responsibility.\n *\n * @param {TransportManager} manager\n * @param {TransportConnection} transport\n * @param {Object} options\n */\nexport default class AssistantToTheTransportManager {\n manager: TransportManager;\n transport: Transport;\n minPingDelay: number;\n maxPingDelay: number;\n pingDelay: number;\n\n constructor(\n manager: TransportManager,\n transport: Transport,\n options: PingDelayOptions\n ) {\n this.manager = manager;\n this.transport = transport;\n this.minPingDelay = options.minPingDelay;\n this.maxPingDelay = options.maxPingDelay;\n this.pingDelay = undefined;\n }\n\n /** Creates a transport connection.\n *\n * This function has the same API as Transport#createConnection.\n *\n * @param {String} name\n * @param {Number} priority\n * @param {String} key the application key\n * @param {Object} options\n * @returns {TransportConnection}\n */\n createConnection(\n name: string,\n priority: number,\n key: string,\n options: Object\n ): TransportConnection {\n options = Collections.extend({}, options, {\n activityTimeout: this.pingDelay\n });\n var connection = this.transport.createConnection(\n name,\n priority,\n key,\n options\n );\n\n var openTimestamp = null;\n\n var onOpen = function() {\n connection.unbind('open', onOpen);\n connection.bind('closed', onClosed);\n openTimestamp = Util.now();\n };\n var onClosed = closeEvent => {\n connection.unbind('closed', onClosed);\n\n if (closeEvent.code === 1002 || closeEvent.code === 1003) {\n // we don't want to use transports not obeying the protocol\n this.manager.reportDeath();\n } else if (!closeEvent.wasClean && openTimestamp) {\n // report deaths only for short-living transport\n var lifespan = Util.now() - openTimestamp;\n if (lifespan < 2 * this.maxPingDelay) {\n this.manager.reportDeath();\n this.pingDelay = Math.max(lifespan / 2, this.minPingDelay);\n }\n }\n };\n\n connection.bind('open', onOpen);\n return connection;\n }\n\n /** Returns whether the transport is supported in the environment.\n *\n * This function has the same API as Transport#isSupported. Might return false\n * when the manager decides to kill the transport.\n *\n * @param {Object} environment the environment details (encryption, settings)\n * @returns {Boolean} true when the transport is supported\n */\n isSupported(environment: string): boolean {\n return this.manager.isAlive() && this.transport.isSupported(environment);\n }\n}\n","import Action from './action';\nimport { PusherEvent } from './message-types';\n/**\n * Provides functions for handling Pusher protocol-specific messages.\n */\n\nconst Protocol = {\n /**\n * Decodes a message in a Pusher format.\n *\n * The MessageEvent we receive from the transport should contain a pusher event\n * (https://pusher.com/docs/pusher_protocol#events) serialized as JSON in the\n * data field\n *\n * The pusher event may contain a data field too, and it may also be\n * serialised as JSON\n *\n * Throws errors when messages are not parse'able.\n *\n * @param {MessageEvent} messageEvent\n * @return {PusherEvent}\n */\n decodeMessage: function(messageEvent: MessageEvent): PusherEvent {\n try {\n var messageData = JSON.parse(messageEvent.data);\n var pusherEventData = messageData.data;\n if (typeof pusherEventData === 'string') {\n try {\n pusherEventData = JSON.parse(messageData.data);\n } catch (e) {}\n }\n var pusherEvent: PusherEvent = {\n event: messageData.event,\n channel: messageData.channel,\n data: pusherEventData\n };\n if (messageData.user_id) {\n pusherEvent.user_id = messageData.user_id;\n }\n return pusherEvent;\n } catch (e) {\n throw { type: 'MessageParseError', error: e, data: messageEvent.data };\n }\n },\n\n /**\n * Encodes a message to be sent.\n *\n * @param {PusherEvent} event\n * @return {String}\n */\n encodeMessage: function(event: PusherEvent): string {\n return JSON.stringify(event);\n },\n\n /**\n * Processes a handshake message and returns appropriate actions.\n *\n * Returns an object with an 'action' and other action-specific properties.\n *\n * There are three outcomes when calling this function. First is a successful\n * connection attempt, when pusher:connection_established is received, which\n * results in a 'connected' action with an 'id' property. When passed a\n * pusher:error event, it returns a result with action appropriate to the\n * close code and an error. Otherwise, it raises an exception.\n *\n * @param {String} message\n * @result Object\n */\n processHandshake: function(messageEvent: MessageEvent): Action {\n var message = Protocol.decodeMessage(messageEvent);\n\n if (message.event === 'pusher:connection_established') {\n if (!message.data.activity_timeout) {\n throw 'No activity timeout specified in handshake';\n }\n return {\n action: 'connected',\n id: message.data.socket_id,\n activityTimeout: message.data.activity_timeout * 1000\n };\n } else if (message.event === 'pusher:error') {\n // From protocol 6 close codes are sent only once, so this only\n // happens when connection does not support close codes\n return {\n action: this.getCloseAction(message.data),\n error: this.getCloseError(message.data)\n };\n } else {\n throw 'Invalid handshake';\n }\n },\n\n /**\n * Dispatches the close event and returns an appropriate action name.\n *\n * See:\n * 1. https://developer.mozilla.org/en-US/docs/WebSockets/WebSockets_reference/CloseEvent\n * 2. http://pusher.com/docs/pusher_protocol\n *\n * @param {CloseEvent} closeEvent\n * @return {String} close action name\n */\n getCloseAction: function(closeEvent): string {\n if (closeEvent.code < 4000) {\n // ignore 1000 CLOSE_NORMAL, 1001 CLOSE_GOING_AWAY,\n // 1005 CLOSE_NO_STATUS, 1006 CLOSE_ABNORMAL\n // ignore 1007...3999\n // handle 1002 CLOSE_PROTOCOL_ERROR, 1003 CLOSE_UNSUPPORTED,\n // 1004 CLOSE_TOO_LARGE\n if (closeEvent.code >= 1002 && closeEvent.code <= 1004) {\n return 'backoff';\n } else {\n return null;\n }\n } else if (closeEvent.code === 4000) {\n return 'tls_only';\n } else if (closeEvent.code < 4100) {\n return 'refused';\n } else if (closeEvent.code < 4200) {\n return 'backoff';\n } else if (closeEvent.code < 4300) {\n return 'retry';\n } else {\n // unknown error\n return 'refused';\n }\n },\n\n /**\n * Returns an error or null basing on the close event.\n *\n * Null is returned when connection was closed cleanly. Otherwise, an object\n * with error details is returned.\n *\n * @param {CloseEvent} closeEvent\n * @return {Object} error object\n */\n getCloseError: function(closeEvent): any {\n if (closeEvent.code !== 1000 && closeEvent.code !== 1001) {\n return {\n type: 'PusherError',\n data: {\n code: closeEvent.code,\n message: closeEvent.reason || closeEvent.message\n }\n };\n } else {\n return null;\n }\n }\n};\n\nexport default Protocol;\n","import * as Collections from '../utils/collections';\nimport { default as EventsDispatcher } from '../events/dispatcher';\nimport Protocol from './protocol/protocol';\nimport { PusherEvent } from './protocol/message-types';\nimport Logger from '../logger';\nimport TransportConnection from '../transports/transport_connection';\nimport Socket from '../socket';\n/**\n * Provides Pusher protocol interface for transports.\n *\n * Emits following events:\n * - message - on received messages\n * - ping - on ping requests\n * - pong - on pong responses\n * - error - when the transport emits an error\n * - closed - after closing the transport\n *\n * It also emits more events when connection closes with a code.\n * See Protocol.getCloseAction to get more details.\n *\n * @param {Number} id\n * @param {AbstractTransport} transport\n */\nexport default class Connection extends EventsDispatcher implements Socket {\n id: string;\n transport: TransportConnection;\n activityTimeout: number;\n\n constructor(id: string, transport: TransportConnection) {\n super();\n this.id = id;\n this.transport = transport;\n this.activityTimeout = transport.activityTimeout;\n this.bindListeners();\n }\n\n /** Returns whether used transport handles activity checks by itself\n *\n * @returns {Boolean} true if activity checks are handled by the transport\n */\n handlesActivityChecks() {\n return this.transport.handlesActivityChecks();\n }\n\n /** Sends raw data.\n *\n * @param {String} data\n */\n send(data: any): boolean {\n return this.transport.send(data);\n }\n\n /** Sends an event.\n *\n * @param {String} name\n * @param {String} data\n * @param {String} [channel]\n * @returns {Boolean} whether message was sent or not\n */\n send_event(name: string, data: any, channel?: string): boolean {\n var event: PusherEvent = { event: name, data: data };\n if (channel) {\n event.channel = channel;\n }\n Logger.debug('Event sent', event);\n return this.send(Protocol.encodeMessage(event));\n }\n\n /** Sends a ping message to the server.\n *\n * Basing on the underlying transport, it might send either transport's\n * protocol-specific ping or pusher:ping event.\n */\n ping() {\n if (this.transport.supportsPing()) {\n this.transport.ping();\n } else {\n this.send_event('pusher:ping', {});\n }\n }\n\n /** Closes the connection. */\n close() {\n this.transport.close();\n }\n\n private bindListeners() {\n var listeners = {\n message: (messageEvent: MessageEvent) => {\n var pusherEvent;\n try {\n pusherEvent = Protocol.decodeMessage(messageEvent);\n } catch (e) {\n this.emit('error', {\n type: 'MessageParseError',\n error: e,\n data: messageEvent.data\n });\n }\n\n if (pusherEvent !== undefined) {\n Logger.debug('Event recd', pusherEvent);\n\n switch (pusherEvent.event) {\n case 'pusher:error':\n this.emit('error', {\n type: 'PusherError',\n data: pusherEvent.data\n });\n break;\n case 'pusher:ping':\n this.emit('ping');\n break;\n case 'pusher:pong':\n this.emit('pong');\n break;\n }\n this.emit('message', pusherEvent);\n }\n },\n activity: () => {\n this.emit('activity');\n },\n error: error => {\n this.emit('error', error);\n },\n closed: closeEvent => {\n unbindListeners();\n\n if (closeEvent && closeEvent.code) {\n this.handleCloseEvent(closeEvent);\n }\n\n this.transport = null;\n this.emit('closed');\n }\n };\n\n var unbindListeners = () => {\n Collections.objectApply(listeners, (listener, event) => {\n this.transport.unbind(event, listener);\n });\n };\n\n Collections.objectApply(listeners, (listener, event) => {\n this.transport.bind(event, listener);\n });\n }\n\n private handleCloseEvent(closeEvent: any) {\n var action = Protocol.getCloseAction(closeEvent);\n var error = Protocol.getCloseError(closeEvent);\n if (error) {\n this.emit('error', error);\n }\n if (action) {\n this.emit(action, { action: action, error: error });\n }\n }\n}\n","import Util from '../../util';\nimport * as Collections from '../../utils/collections';\nimport Protocol from '../protocol/protocol';\nimport Connection from '../connection';\nimport TransportConnection from '../../transports/transport_connection';\nimport HandshakePayload from './handshake_payload';\n\n/**\n * Handles Pusher protocol handshakes for transports.\n *\n * Calls back with a result object after handshake is completed. Results\n * always have two fields:\n * - action - string describing action to be taken after the handshake\n * - transport - the transport object passed to the constructor\n *\n * Different actions can set different additional properties on the result.\n * In the case of 'connected' action, there will be a 'connection' property\n * containing a Connection object for the transport. Other actions should\n * carry an 'error' property.\n *\n * @param {AbstractTransport} transport\n * @param {Function} callback\n */\nexport default class Handshake {\n transport: TransportConnection;\n callback: (HandshakePayload) => void;\n onMessage: Function;\n onClosed: Function;\n\n constructor(\n transport: TransportConnection,\n callback: (HandshakePayload) => void\n ) {\n this.transport = transport;\n this.callback = callback;\n this.bindListeners();\n }\n\n close() {\n this.unbindListeners();\n this.transport.close();\n }\n\n private bindListeners() {\n this.onMessage = m => {\n this.unbindListeners();\n\n var result;\n try {\n result = Protocol.processHandshake(m);\n } catch (e) {\n this.finish('error', { error: e });\n this.transport.close();\n return;\n }\n\n if (result.action === 'connected') {\n this.finish('connected', {\n connection: new Connection(result.id, this.transport),\n activityTimeout: result.activityTimeout\n });\n } else {\n this.finish(result.action, { error: result.error });\n this.transport.close();\n }\n };\n\n this.onClosed = closeEvent => {\n this.unbindListeners();\n\n var action = Protocol.getCloseAction(closeEvent) || 'backoff';\n var error = Protocol.getCloseError(closeEvent);\n this.finish(action, { error: error });\n };\n\n this.transport.bind('message', this.onMessage);\n this.transport.bind('closed', this.onClosed);\n }\n\n private unbindListeners() {\n this.transport.unbind('message', this.onMessage);\n this.transport.unbind('closed', this.onClosed);\n }\n\n private finish(action: string, params: any) {\n this.callback(\n Collections.extend({ transport: this.transport, action: action }, params)\n );\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport base64encode from '../base64';\nimport Timeline from './timeline';\nimport Runtime from 'runtime';\n\nexport interface TimelineSenderOptions {\n host?: string;\n port?: number;\n path?: string;\n}\n\nexport default class TimelineSender {\n timeline: Timeline;\n options: TimelineSenderOptions;\n host: string;\n\n constructor(timeline: Timeline, options: TimelineSenderOptions) {\n this.timeline = timeline;\n this.options = options || {};\n }\n\n send(useTLS: boolean, callback?: Function) {\n if (this.timeline.isEmpty()) {\n return;\n }\n\n this.timeline.send(\n Runtime.TimelineTransport.getAgent(this, useTLS),\n callback\n );\n }\n}\n","/** Error classes used throughout the library. */\n// https://github.com/Microsoft/TypeScript-wiki/blob/master/Breaking-Changes.md#extending-built-ins-like-error-array-and-map-may-no-longer-work\nexport class BadEventName extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\nexport class BadChannelName extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\nexport class RequestTimedOut extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class TransportPriorityTooLow extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class TransportClosed extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class UnsupportedFeature extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class UnsupportedTransport extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class UnsupportedStrategy extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class HTTPAuthError extends Error {\n status: number;\n constructor(status: number, msg?: string) {\n super(msg);\n this.status = status;\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n","/**\n * A place to store help URLs for error messages etc\n */\n\nconst urlStore = {\n baseUrl: 'https://pusher.com',\n urls: {\n authenticationEndpoint: {\n path: '/docs/channels/server_api/authenticating_users'\n },\n authorizationEndpoint: {\n path: '/docs/channels/server_api/authorizing-users/'\n },\n javascriptQuickStart: {\n path: '/docs/javascript_quick_start'\n },\n triggeringClientEvents: {\n path: '/docs/client_api_guide/client_events#trigger-events'\n },\n encryptedChannelSupport: {\n fullUrl:\n 'https://github.com/pusher/pusher-js/tree/cc491015371a4bde5743d1c87a0fbac0feb53195#encrypted-channel-support'\n }\n }\n};\n\n/** Builds a consistent string with links to pusher documentation\n *\n * @param {string} key - relevant key in the url_store.urls object\n * @return {string} suffix string to append to log message\n */\nconst buildLogSuffix = function(key: string): string {\n const urlPrefix = 'See:';\n const urlObj = urlStore.urls[key];\n if (!urlObj) return '';\n\n let url;\n if (urlObj.fullUrl) {\n url = urlObj.fullUrl;\n } else if (urlObj.path) {\n url = urlStore.baseUrl + urlObj.path;\n }\n\n if (!url) return '';\n return `${urlPrefix} ${url}`;\n};\n\nexport default { buildLogSuffix };\n","import { default as EventsDispatcher } from '../events/dispatcher';\nimport * as Errors from '../errors';\nimport Logger from '../logger';\nimport Pusher from '../pusher';\nimport { PusherEvent } from '../connection/protocol/message-types';\nimport Metadata from './metadata';\nimport UrlStore from '../utils/url_store';\nimport {\n ChannelAuthorizationData,\n ChannelAuthorizationCallback\n} from '../auth/options';\nimport { HTTPAuthError } from '../errors';\n\n/** Provides base public channel interface with an event emitter.\n *\n * Emits:\n * - pusher:subscription_succeeded - after subscribing successfully\n * - other non-internal events\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\nexport default class Channel extends EventsDispatcher {\n name: string;\n pusher: Pusher;\n subscribed: boolean;\n subscriptionPending: boolean;\n subscriptionCancelled: boolean;\n subscriptionCount: null;\n\n constructor(name: string, pusher: Pusher) {\n super(function(event, data) {\n Logger.debug('No callbacks on ' + name + ' for ' + event);\n });\n\n this.name = name;\n this.pusher = pusher;\n this.subscribed = false;\n this.subscriptionPending = false;\n this.subscriptionCancelled = false;\n }\n\n /** Skips authorization, since public channels don't require it.\n *\n * @param {Function} callback\n */\n authorize(socketId: string, callback: ChannelAuthorizationCallback) {\n return callback(null, { auth: '' });\n }\n\n /** Triggers an event */\n trigger(event: string, data: any) {\n if (event.indexOf('client-') !== 0) {\n throw new Errors.BadEventName(\n \"Event '\" + event + \"' does not start with 'client-'\"\n );\n }\n if (!this.subscribed) {\n var suffix = UrlStore.buildLogSuffix('triggeringClientEvents');\n Logger.warn(\n `Client event triggered before channel 'subscription_succeeded' event . ${suffix}`\n );\n }\n return this.pusher.send_event(event, data, this.name);\n }\n\n /** Signals disconnection to the channel. For internal use only. */\n disconnect() {\n this.subscribed = false;\n this.subscriptionPending = false;\n }\n\n /** Handles a PusherEvent. For internal use only.\n *\n * @param {PusherEvent} event\n */\n handleEvent(event: PusherEvent) {\n var eventName = event.event;\n var data = event.data;\n if (eventName === 'pusher_internal:subscription_succeeded') {\n this.handleSubscriptionSucceededEvent(event);\n } else if (eventName === 'pusher_internal:subscription_count') {\n this.handleSubscriptionCountEvent(event);\n } else if (eventName.indexOf('pusher_internal:') !== 0) {\n var metadata: Metadata = {};\n this.emit(eventName, data, metadata);\n }\n }\n\n handleSubscriptionSucceededEvent(event: PusherEvent) {\n this.subscriptionPending = false;\n this.subscribed = true;\n if (this.subscriptionCancelled) {\n this.pusher.unsubscribe(this.name);\n } else {\n this.emit('pusher:subscription_succeeded', event.data);\n }\n }\n\n handleSubscriptionCountEvent(event: PusherEvent) {\n if (event.data.subscription_count) {\n this.subscriptionCount = event.data.subscription_count;\n }\n\n this.emit('pusher:subscription_count', event.data);\n }\n\n /** Sends a subscription request. For internal use only. */\n subscribe() {\n if (this.subscribed) {\n return;\n }\n this.subscriptionPending = true;\n this.subscriptionCancelled = false;\n this.authorize(\n this.pusher.connection.socket_id,\n (error: Error | null, data: ChannelAuthorizationData) => {\n if (error) {\n this.subscriptionPending = false;\n // Why not bind to 'pusher:subscription_error' a level up, and log there?\n // Binding to this event would cause the warning about no callbacks being\n // bound (see constructor) to be suppressed, that's not what we want.\n Logger.error(error.toString());\n this.emit(\n 'pusher:subscription_error',\n Object.assign(\n {},\n {\n type: 'AuthError',\n error: error.message\n },\n error instanceof HTTPAuthError ? { status: error.status } : {}\n )\n );\n } else {\n this.pusher.send_event('pusher:subscribe', {\n auth: data.auth,\n channel_data: data.channel_data,\n channel: this.name\n });\n }\n }\n );\n }\n\n /** Sends an unsubscription request. For internal use only. */\n unsubscribe() {\n this.subscribed = false;\n this.pusher.send_event('pusher:unsubscribe', {\n channel: this.name\n });\n }\n\n /** Cancels an in progress subscription. For internal use only. */\n cancelSubscription() {\n this.subscriptionCancelled = true;\n }\n\n /** Reinstates an in progress subscripiton. For internal use only. */\n reinstateSubscription() {\n this.subscriptionCancelled = false;\n }\n}\n","import Factory from '../utils/factory';\nimport Channel from './channel';\nimport { ChannelAuthorizationCallback } from '../auth/options';\n\n/** Extends public channels to provide private channel interface.\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\nexport default class PrivateChannel extends Channel {\n /** Authorizes the connection to use the channel.\n *\n * @param {String} socketId\n * @param {Function} callback\n */\n authorize(socketId: string, callback: ChannelAuthorizationCallback) {\n return this.pusher.config.channelAuthorizer(\n {\n channelName: this.name,\n socketId: socketId\n },\n callback\n );\n }\n}\n","import * as Collections from '../utils/collections';\n\n/** Represents a collection of members of a presence channel. */\nexport default class Members {\n members: any;\n count: number;\n myID: any;\n me: any;\n\n constructor() {\n this.reset();\n }\n\n /** Returns member's info for given id.\n *\n * Resulting object containts two fields - id and info.\n *\n * @param {Number} id\n * @return {Object} member's info or null\n */\n get(id: string): any {\n if (Object.prototype.hasOwnProperty.call(this.members, id)) {\n return {\n id: id,\n info: this.members[id]\n };\n } else {\n return null;\n }\n }\n\n /** Calls back for each member in unspecified order.\n *\n * @param {Function} callback\n */\n each(callback: Function) {\n Collections.objectApply(this.members, (member, id) => {\n callback(this.get(id));\n });\n }\n\n /** Updates the id for connected member. For internal use only. */\n setMyID(id: string) {\n this.myID = id;\n }\n\n /** Handles subscription data. For internal use only. */\n onSubscription(subscriptionData: any) {\n this.members = subscriptionData.presence.hash;\n this.count = subscriptionData.presence.count;\n this.me = this.get(this.myID);\n }\n\n /** Adds a new member to the collection. For internal use only. */\n addMember(memberData: any) {\n if (this.get(memberData.user_id) === null) {\n this.count++;\n }\n this.members[memberData.user_id] = memberData.user_info;\n return this.get(memberData.user_id);\n }\n\n /** Adds a member from the collection. For internal use only. */\n removeMember(memberData: any) {\n var member = this.get(memberData.user_id);\n if (member) {\n delete this.members[memberData.user_id];\n this.count--;\n }\n return member;\n }\n\n /** Resets the collection to the initial state. For internal use only. */\n reset() {\n this.members = {};\n this.count = 0;\n this.myID = null;\n this.me = null;\n }\n}\n","import PrivateChannel from './private_channel';\nimport Logger from '../logger';\nimport Members from './members';\nimport Pusher from '../pusher';\nimport UrlStore from 'core/utils/url_store';\nimport { PusherEvent } from '../connection/protocol/message-types';\nimport Metadata from './metadata';\nimport { ChannelAuthorizationData } from '../auth/options';\n\nexport default class PresenceChannel extends PrivateChannel {\n members: Members;\n\n /** Adds presence channel functionality to private channels.\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\n constructor(name: string, pusher: Pusher) {\n super(name, pusher);\n this.members = new Members();\n }\n\n /** Authorizes the connection as a member of the channel.\n *\n * @param {String} socketId\n * @param {Function} callback\n */\n authorize(socketId: string, callback: Function) {\n super.authorize(socketId, async (error, authData) => {\n if (!error) {\n authData = authData as ChannelAuthorizationData;\n if (authData.channel_data != null) {\n var channelData = JSON.parse(authData.channel_data);\n this.members.setMyID(channelData.user_id);\n } else {\n await this.pusher.user.signinDonePromise;\n if (this.pusher.user.user_data != null) {\n // If the user is signed in, get the id of the authenticated user\n // and allow the presence authorization to continue.\n this.members.setMyID(this.pusher.user.user_data.id);\n } else {\n let suffix = UrlStore.buildLogSuffix('authorizationEndpoint');\n Logger.error(\n `Invalid auth response for channel '${this.name}', ` +\n `expected 'channel_data' field. ${suffix}, ` +\n `or the user should be signed in.`\n );\n callback('Invalid auth response');\n return;\n }\n }\n }\n callback(error, authData);\n });\n }\n\n /** Handles presence and subscription events. For internal use only.\n *\n * @param {PusherEvent} event\n */\n handleEvent(event: PusherEvent) {\n var eventName = event.event;\n if (eventName.indexOf('pusher_internal:') === 0) {\n this.handleInternalEvent(event);\n } else {\n var data = event.data;\n var metadata: Metadata = {};\n if (event.user_id) {\n metadata.user_id = event.user_id;\n }\n this.emit(eventName, data, metadata);\n }\n }\n handleInternalEvent(event: PusherEvent) {\n var eventName = event.event;\n var data = event.data;\n switch (eventName) {\n case 'pusher_internal:subscription_succeeded':\n this.handleSubscriptionSucceededEvent(event);\n break;\n case 'pusher_internal:subscription_count':\n this.handleSubscriptionCountEvent(event);\n break;\n case 'pusher_internal:member_added':\n var addedMember = this.members.addMember(data);\n this.emit('pusher:member_added', addedMember);\n break;\n case 'pusher_internal:member_removed':\n var removedMember = this.members.removeMember(data);\n if (removedMember) {\n this.emit('pusher:member_removed', removedMember);\n }\n break;\n }\n }\n\n handleSubscriptionSucceededEvent(event: PusherEvent) {\n this.subscriptionPending = false;\n this.subscribed = true;\n if (this.subscriptionCancelled) {\n this.pusher.unsubscribe(this.name);\n } else {\n this.members.onSubscription(event.data);\n this.emit('pusher:subscription_succeeded', this.members);\n }\n }\n\n /** Resets the channel state, including members map. For internal use only. */\n disconnect() {\n this.members.reset();\n super.disconnect();\n }\n}\n","import PrivateChannel from './private_channel';\nimport * as Errors from '../errors';\nimport Logger from '../logger';\nimport Pusher from '../pusher';\nimport { decode as encodeUTF8 } from '@stablelib/utf8';\nimport { decode as decodeBase64 } from '@stablelib/base64';\nimport Dispatcher from '../events/dispatcher';\nimport { PusherEvent } from '../connection/protocol/message-types';\nimport {\n ChannelAuthorizationData,\n ChannelAuthorizationCallback\n} from '../auth/options';\nimport * as nacl from 'tweetnacl';\n\n/** Extends private channels to provide encrypted channel interface.\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\nexport default class EncryptedChannel extends PrivateChannel {\n key: Uint8Array = null;\n nacl: nacl;\n\n constructor(name: string, pusher: Pusher, nacl: nacl) {\n super(name, pusher);\n this.nacl = nacl;\n }\n\n /** Authorizes the connection to use the channel.\n *\n * @param {String} socketId\n * @param {Function} callback\n */\n authorize(socketId: string, callback: ChannelAuthorizationCallback) {\n super.authorize(\n socketId,\n (error: Error | null, authData: ChannelAuthorizationData) => {\n if (error) {\n callback(error, authData);\n return;\n }\n let sharedSecret = authData['shared_secret'];\n if (!sharedSecret) {\n callback(\n new Error(\n `No shared_secret key in auth payload for encrypted channel: ${this.name}`\n ),\n null\n );\n return;\n }\n this.key = decodeBase64(sharedSecret);\n delete authData['shared_secret'];\n callback(null, authData);\n }\n );\n }\n\n trigger(event: string, data: any): boolean {\n throw new Errors.UnsupportedFeature(\n 'Client events are not currently supported for encrypted channels'\n );\n }\n\n /** Handles an event. For internal use only.\n *\n * @param {PusherEvent} event\n */\n handleEvent(event: PusherEvent) {\n var eventName = event.event;\n var data = event.data;\n if (\n eventName.indexOf('pusher_internal:') === 0 ||\n eventName.indexOf('pusher:') === 0\n ) {\n super.handleEvent(event);\n return;\n }\n this.handleEncryptedEvent(eventName, data);\n }\n\n private handleEncryptedEvent(event: string, data: any): void {\n if (!this.key) {\n Logger.debug(\n 'Received encrypted event before key has been retrieved from the authEndpoint'\n );\n return;\n }\n if (!data.ciphertext || !data.nonce) {\n Logger.error(\n 'Unexpected format for encrypted event, expected object with `ciphertext` and `nonce` fields, got: ' +\n data\n );\n return;\n }\n let cipherText = decodeBase64(data.ciphertext);\n if (cipherText.length < this.nacl.secretbox.overheadLength) {\n Logger.error(\n `Expected encrypted event ciphertext length to be ${this.nacl.secretbox.overheadLength}, got: ${cipherText.length}`\n );\n return;\n }\n let nonce = decodeBase64(data.nonce);\n if (nonce.length < this.nacl.secretbox.nonceLength) {\n Logger.error(\n `Expected encrypted event nonce length to be ${this.nacl.secretbox.nonceLength}, got: ${nonce.length}`\n );\n return;\n }\n\n let bytes = this.nacl.secretbox.open(cipherText, nonce, this.key);\n if (bytes === null) {\n Logger.debug(\n 'Failed to decrypt an event, probably because it was encrypted with a different key. Fetching a new key from the authEndpoint...'\n );\n // Try a single time to retrieve a new auth key and decrypt the event with it\n // If this fails, a new key will be requested when a new message is received\n this.authorize(this.pusher.connection.socket_id, (error, authData) => {\n if (error) {\n Logger.error(\n `Failed to make a request to the authEndpoint: ${authData}. Unable to fetch new key, so dropping encrypted event`\n );\n return;\n }\n bytes = this.nacl.secretbox.open(cipherText, nonce, this.key);\n if (bytes === null) {\n Logger.error(\n `Failed to decrypt event with new key. Dropping encrypted event`\n );\n return;\n }\n this.emit(event, this.getDataToEmit(bytes));\n return;\n });\n return;\n }\n this.emit(event, this.getDataToEmit(bytes));\n }\n\n // Try and parse the decrypted bytes as JSON. If we can't parse it, just\n // return the utf-8 string\n getDataToEmit(bytes: Uint8Array): string {\n let raw = encodeUTF8(bytes);\n try {\n return JSON.parse(raw);\n } catch {\n return raw;\n }\n }\n}\n","import { default as EventsDispatcher } from '../events/dispatcher';\nimport { OneOffTimer as Timer } from '../utils/timers';\nimport { Config } from '../config';\nimport Logger from '../logger';\nimport HandshakePayload from './handshake/handshake_payload';\nimport Connection from './connection';\nimport Strategy from '../strategies/strategy';\nimport StrategyRunner from '../strategies/strategy_runner';\nimport * as Collections from '../utils/collections';\nimport Timeline from '../timeline/timeline';\nimport ConnectionManagerOptions from './connection_manager_options';\nimport Runtime from 'runtime';\n\nimport {\n ErrorCallbacks,\n HandshakeCallbacks,\n ConnectionCallbacks\n} from './callbacks';\nimport Action from './protocol/action';\n\n/** Manages connection to Pusher.\n *\n * Uses a strategy (currently only default), timers and network availability\n * info to establish a connection and export its state. In case of failures,\n * manages reconnection attempts.\n *\n * Exports state changes as following events:\n * - \"state_change\", { previous: p, current: state }\n * - state\n *\n * States:\n * - initialized - initial state, never transitioned to\n * - connecting - connection is being established\n * - connected - connection has been fully established\n * - disconnected - on requested disconnection\n * - unavailable - after connection timeout or when there's no network\n * - failed - when the connection strategy is not supported\n *\n * Options:\n * - unavailableTimeout - time to transition to unavailable state\n * - activityTimeout - time after which ping message should be sent\n * - pongTimeout - time for Pusher to respond with pong before reconnecting\n *\n * @param {String} key application key\n * @param {Object} options\n */\nexport default class ConnectionManager extends EventsDispatcher {\n key: string;\n options: ConnectionManagerOptions;\n state: string;\n connection: Connection;\n usingTLS: boolean;\n timeline: Timeline;\n socket_id: string;\n unavailableTimer: Timer;\n activityTimer: Timer;\n retryTimer: Timer;\n activityTimeout: number;\n strategy: Strategy;\n runner: StrategyRunner;\n errorCallbacks: ErrorCallbacks;\n handshakeCallbacks: HandshakeCallbacks;\n connectionCallbacks: ConnectionCallbacks;\n\n constructor(key: string, options: ConnectionManagerOptions) {\n super();\n this.state = 'initialized';\n this.connection = null;\n\n this.key = key;\n this.options = options;\n this.timeline = this.options.timeline;\n this.usingTLS = this.options.useTLS;\n\n this.errorCallbacks = this.buildErrorCallbacks();\n this.connectionCallbacks = this.buildConnectionCallbacks(\n this.errorCallbacks\n );\n this.handshakeCallbacks = this.buildHandshakeCallbacks(this.errorCallbacks);\n\n var Network = Runtime.getNetwork();\n\n Network.bind('online', () => {\n this.timeline.info({ netinfo: 'online' });\n if (this.state === 'connecting' || this.state === 'unavailable') {\n this.retryIn(0);\n }\n });\n Network.bind('offline', () => {\n this.timeline.info({ netinfo: 'offline' });\n if (this.connection) {\n this.sendActivityCheck();\n }\n });\n\n this.updateStrategy();\n }\n\n switchCluster(key: string) {\n this.key = key;\n // This ensures that the new config coming from\n // pusher instance are taken into account\n // such as appKey and cluster\n this.updateStrategy();\n this.retryIn(0);\n }\n\n /** Establishes a connection to Pusher.\n *\n * Does nothing when connection is already established. See top-level doc\n * to find events emitted on connection attempts.\n */\n connect() {\n if (this.connection || this.runner) {\n return;\n }\n if (!this.strategy.isSupported()) {\n this.updateState('failed');\n return;\n }\n this.updateState('connecting');\n this.startConnecting();\n this.setUnavailableTimer();\n }\n\n /** Sends raw data.\n *\n * @param {String} data\n */\n send(data) {\n if (this.connection) {\n return this.connection.send(data);\n } else {\n return false;\n }\n }\n\n /** Sends an event.\n *\n * @param {String} name\n * @param {String} data\n * @param {String} [channel]\n * @returns {Boolean} whether message was sent or not\n */\n send_event(name: string, data: any, channel?: string) {\n if (this.connection) {\n return this.connection.send_event(name, data, channel);\n } else {\n return false;\n }\n }\n\n /** Closes the connection. */\n disconnect() {\n this.disconnectInternally();\n this.updateState('disconnected');\n }\n\n isUsingTLS() {\n return this.usingTLS;\n }\n\n private startConnecting() {\n var callback = (error, handshake) => {\n if (error) {\n this.runner = this.strategy.connect(0, callback);\n } else {\n if (handshake.action === 'error') {\n this.emit('error', {\n type: 'HandshakeError',\n error: handshake.error\n });\n this.timeline.error({ handshakeError: handshake.error });\n } else {\n this.abortConnecting(); // we don't support switching connections yet\n this.handshakeCallbacks[handshake.action](handshake);\n }\n }\n };\n this.runner = this.strategy.connect(0, callback);\n }\n\n private abortConnecting() {\n if (this.runner) {\n this.runner.abort();\n this.runner = null;\n }\n }\n\n private disconnectInternally() {\n this.abortConnecting();\n this.clearRetryTimer();\n this.clearUnavailableTimer();\n if (this.connection) {\n var connection = this.abandonConnection();\n connection.close();\n }\n }\n\n private updateStrategy() {\n this.strategy = this.options.getStrategy({\n key: this.key,\n timeline: this.timeline,\n useTLS: this.usingTLS\n });\n }\n\n private retryIn(delay) {\n this.timeline.info({ action: 'retry', delay: delay });\n if (delay > 0) {\n this.emit('connecting_in', Math.round(delay / 1000));\n }\n this.retryTimer = new Timer(delay || 0, () => {\n this.disconnectInternally();\n this.connect();\n });\n }\n\n private clearRetryTimer() {\n if (this.retryTimer) {\n this.retryTimer.ensureAborted();\n this.retryTimer = null;\n }\n }\n\n private setUnavailableTimer() {\n this.unavailableTimer = new Timer(this.options.unavailableTimeout, () => {\n this.updateState('unavailable');\n });\n }\n\n private clearUnavailableTimer() {\n if (this.unavailableTimer) {\n this.unavailableTimer.ensureAborted();\n }\n }\n\n private sendActivityCheck() {\n this.stopActivityCheck();\n this.connection.ping();\n // wait for pong response\n this.activityTimer = new Timer(this.options.pongTimeout, () => {\n this.timeline.error({ pong_timed_out: this.options.pongTimeout });\n this.retryIn(0);\n });\n }\n\n private resetActivityCheck() {\n this.stopActivityCheck();\n // send ping after inactivity\n if (this.connection && !this.connection.handlesActivityChecks()) {\n this.activityTimer = new Timer(this.activityTimeout, () => {\n this.sendActivityCheck();\n });\n }\n }\n\n private stopActivityCheck() {\n if (this.activityTimer) {\n this.activityTimer.ensureAborted();\n }\n }\n\n private buildConnectionCallbacks(\n errorCallbacks: ErrorCallbacks\n ): ConnectionCallbacks {\n return Collections.extend({}, errorCallbacks, {\n message: message => {\n // includes pong messages from server\n this.resetActivityCheck();\n this.emit('message', message);\n },\n ping: () => {\n this.send_event('pusher:pong', {});\n },\n activity: () => {\n this.resetActivityCheck();\n },\n error: error => {\n // just emit error to user - socket will already be closed by browser\n this.emit('error', error);\n },\n closed: () => {\n this.abandonConnection();\n if (this.shouldRetry()) {\n this.retryIn(1000);\n }\n }\n });\n }\n\n private buildHandshakeCallbacks(\n errorCallbacks: ErrorCallbacks\n ): HandshakeCallbacks {\n return Collections.extend({}, errorCallbacks, {\n connected: (handshake: HandshakePayload) => {\n this.activityTimeout = Math.min(\n this.options.activityTimeout,\n handshake.activityTimeout,\n handshake.connection.activityTimeout || Infinity\n );\n this.clearUnavailableTimer();\n this.setConnection(handshake.connection);\n this.socket_id = this.connection.id;\n this.updateState('connected', { socket_id: this.socket_id });\n }\n });\n }\n\n private buildErrorCallbacks(): ErrorCallbacks {\n let withErrorEmitted = callback => {\n return (result: Action | HandshakePayload) => {\n if (result.error) {\n this.emit('error', { type: 'WebSocketError', error: result.error });\n }\n callback(result);\n };\n };\n\n return {\n tls_only: withErrorEmitted(() => {\n this.usingTLS = true;\n this.updateStrategy();\n this.retryIn(0);\n }),\n refused: withErrorEmitted(() => {\n this.disconnect();\n }),\n backoff: withErrorEmitted(() => {\n this.retryIn(1000);\n }),\n retry: withErrorEmitted(() => {\n this.retryIn(0);\n })\n };\n }\n\n private setConnection(connection) {\n this.connection = connection;\n for (var event in this.connectionCallbacks) {\n this.connection.bind(event, this.connectionCallbacks[event]);\n }\n this.resetActivityCheck();\n }\n\n private abandonConnection() {\n if (!this.connection) {\n return;\n }\n this.stopActivityCheck();\n for (var event in this.connectionCallbacks) {\n this.connection.unbind(event, this.connectionCallbacks[event]);\n }\n var connection = this.connection;\n this.connection = null;\n return connection;\n }\n\n private updateState(newState: string, data?: any) {\n var previousState = this.state;\n this.state = newState;\n if (previousState !== newState) {\n var newStateDescription = newState;\n if (newStateDescription === 'connected') {\n newStateDescription += ' with new socket ID ' + data.socket_id;\n }\n Logger.debug(\n 'State changed',\n previousState + ' -> ' + newStateDescription\n );\n this.timeline.info({ state: newState, params: data });\n this.emit('state_change', { previous: previousState, current: newState });\n this.emit(newState, data);\n }\n }\n\n private shouldRetry(): boolean {\n return this.state === 'connecting' || this.state === 'connected';\n }\n}\n","import Channel from './channel';\nimport * as Collections from '../utils/collections';\nimport ChannelTable from './channel_table';\nimport Factory from '../utils/factory';\nimport Pusher from '../pusher';\nimport Logger from '../logger';\nimport * as Errors from '../errors';\nimport urlStore from '../utils/url_store';\n\n/** Handles a channel map. */\nexport default class Channels {\n channels: ChannelTable;\n\n constructor() {\n this.channels = {};\n }\n\n /** Creates or retrieves an existing channel by its name.\n *\n * @param {String} name\n * @param {Pusher} pusher\n * @return {Channel}\n */\n add(name: string, pusher: Pusher) {\n if (!this.channels[name]) {\n this.channels[name] = createChannel(name, pusher);\n }\n return this.channels[name];\n }\n\n /** Returns a list of all channels\n *\n * @return {Array}\n */\n all(): Channel[] {\n return Collections.values(this.channels);\n }\n\n /** Finds a channel by its name.\n *\n * @param {String} name\n * @return {Channel} channel or null if it doesn't exist\n */\n find(name: string) {\n return this.channels[name];\n }\n\n /** Removes a channel from the map.\n *\n * @param {String} name\n */\n remove(name: string) {\n var channel = this.channels[name];\n delete this.channels[name];\n return channel;\n }\n\n /** Proxies disconnection signal to all channels. */\n disconnect() {\n Collections.objectApply(this.channels, function(channel) {\n channel.disconnect();\n });\n }\n}\n\nfunction createChannel(name: string, pusher: Pusher): Channel {\n if (name.indexOf('private-encrypted-') === 0) {\n if (pusher.config.nacl) {\n return Factory.createEncryptedChannel(name, pusher, pusher.config.nacl);\n }\n let errMsg =\n 'Tried to subscribe to a private-encrypted- channel but no nacl implementation available';\n let suffix = urlStore.buildLogSuffix('encryptedChannelSupport');\n throw new Errors.UnsupportedFeature(`${errMsg}. ${suffix}`);\n } else if (name.indexOf('private-') === 0) {\n return Factory.createPrivateChannel(name, pusher);\n } else if (name.indexOf('presence-') === 0) {\n return Factory.createPresenceChannel(name, pusher);\n } else if (name.indexOf('#') === 0) {\n throw new Errors.BadChannelName(\n 'Cannot create a channel with name \"' + name + '\".'\n );\n } else {\n return Factory.createChannel(name, pusher);\n }\n}\n","import AssistantToTheTransportManager from '../transports/assistant_to_the_transport_manager';\nimport PingDelayOptions from '../transports/ping_delay_options';\nimport Transport from '../transports/transport';\nimport TransportManager from '../transports/transport_manager';\nimport Handshake from '../connection/handshake';\nimport TransportConnection from '../transports/transport_connection';\nimport SocketHooks from '../http/socket_hooks';\nimport HTTPSocket from '../http/http_socket';\n\nimport Timeline from '../timeline/timeline';\nimport {\n default as TimelineSender,\n TimelineSenderOptions\n} from '../timeline/timeline_sender';\nimport PresenceChannel from '../channels/presence_channel';\nimport PrivateChannel from '../channels/private_channel';\nimport EncryptedChannel from '../channels/encrypted_channel';\nimport Channel from '../channels/channel';\nimport ConnectionManager from '../connection/connection_manager';\nimport ConnectionManagerOptions from '../connection/connection_manager_options';\nimport Ajax from '../http/ajax';\nimport Channels from '../channels/channels';\nimport Pusher from '../pusher';\nimport { Config } from '../config';\nimport * as nacl from 'tweetnacl';\n\nvar Factory = {\n createChannels(): Channels {\n return new Channels();\n },\n\n createConnectionManager(\n key: string,\n options: ConnectionManagerOptions\n ): ConnectionManager {\n return new ConnectionManager(key, options);\n },\n\n createChannel(name: string, pusher: Pusher): Channel {\n return new Channel(name, pusher);\n },\n\n createPrivateChannel(name: string, pusher: Pusher): PrivateChannel {\n return new PrivateChannel(name, pusher);\n },\n\n createPresenceChannel(name: string, pusher: Pusher): PresenceChannel {\n return new PresenceChannel(name, pusher);\n },\n\n createEncryptedChannel(\n name: string,\n pusher: Pusher,\n nacl: nacl\n ): EncryptedChannel {\n return new EncryptedChannel(name, pusher, nacl);\n },\n\n createTimelineSender(timeline: Timeline, options: TimelineSenderOptions) {\n return new TimelineSender(timeline, options);\n },\n\n createHandshake(\n transport: TransportConnection,\n callback: (HandshakePayload) => void\n ): Handshake {\n return new Handshake(transport, callback);\n },\n\n createAssistantToTheTransportManager(\n manager: TransportManager,\n transport: Transport,\n options: PingDelayOptions\n ): AssistantToTheTransportManager {\n return new AssistantToTheTransportManager(manager, transport, options);\n }\n};\n\nexport default Factory;\n","import AssistantToTheTransportManager from './assistant_to_the_transport_manager';\nimport Transport from './transport';\nimport PingDelayOptions from './ping_delay_options';\nimport Factory from '../utils/factory';\n\nexport interface TransportManagerOptions extends PingDelayOptions {\n lives?: number;\n}\n\n/** Keeps track of the number of lives left for a transport.\n *\n * In the beginning of a session, transports may be assigned a number of\n * lives. When an AssistantToTheTransportManager instance reports a transport\n * connection closed uncleanly, the transport loses a life. When the number\n * of lives drops to zero, the transport gets disabled by its manager.\n *\n * @param {Object} options\n */\nexport default class TransportManager {\n options: TransportManagerOptions;\n livesLeft: number;\n\n constructor(options: TransportManagerOptions) {\n this.options = options || {};\n this.livesLeft = this.options.lives || Infinity;\n }\n\n /** Creates a assistant for the transport.\n *\n * @param {Transport} transport\n * @returns {AssistantToTheTransportManager}\n */\n getAssistant(transport: Transport): AssistantToTheTransportManager {\n return Factory.createAssistantToTheTransportManager(this, transport, {\n minPingDelay: this.options.minPingDelay,\n maxPingDelay: this.options.maxPingDelay\n });\n }\n\n /** Returns whether the transport has any lives left.\n *\n * @returns {Boolean}\n */\n isAlive(): boolean {\n return this.livesLeft > 0;\n }\n\n /** Takes one life from the transport. */\n reportDeath() {\n this.livesLeft -= 1;\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport { OneOffTimer as Timer } from '../utils/timers';\nimport Strategy from './strategy';\nimport StrategyOptions from './strategy_options';\n\n/** Loops through strategies with optional timeouts.\n *\n * Options:\n * - loop - whether it should loop through the substrategy list\n * - timeout - initial timeout for a single substrategy\n * - timeoutLimit - maximum timeout\n *\n * @param {Strategy[]} strategies\n * @param {Object} options\n */\nexport default class SequentialStrategy implements Strategy {\n strategies: Strategy[];\n loop: boolean;\n failFast: boolean;\n timeout: number;\n timeoutLimit: number;\n\n constructor(strategies: Strategy[], options: StrategyOptions) {\n this.strategies = strategies;\n this.loop = Boolean(options.loop);\n this.failFast = Boolean(options.failFast);\n this.timeout = options.timeout;\n this.timeoutLimit = options.timeoutLimit;\n }\n\n isSupported(): boolean {\n return Collections.any(this.strategies, Util.method('isSupported'));\n }\n\n connect(minPriority: number, callback: Function) {\n var strategies = this.strategies;\n var current = 0;\n var timeout = this.timeout;\n var runner = null;\n\n var tryNextStrategy = (error, handshake) => {\n if (handshake) {\n callback(null, handshake);\n } else {\n current = current + 1;\n if (this.loop) {\n current = current % strategies.length;\n }\n\n if (current < strategies.length) {\n if (timeout) {\n timeout = timeout * 2;\n if (this.timeoutLimit) {\n timeout = Math.min(timeout, this.timeoutLimit);\n }\n }\n runner = this.tryStrategy(\n strategies[current],\n minPriority,\n { timeout, failFast: this.failFast },\n tryNextStrategy\n );\n } else {\n callback(true);\n }\n }\n };\n\n runner = this.tryStrategy(\n strategies[current],\n minPriority,\n { timeout: timeout, failFast: this.failFast },\n tryNextStrategy\n );\n\n return {\n abort: function() {\n runner.abort();\n },\n forceMinPriority: function(p) {\n minPriority = p;\n if (runner) {\n runner.forceMinPriority(p);\n }\n }\n };\n }\n\n private tryStrategy(\n strategy: Strategy,\n minPriority: number,\n options: StrategyOptions,\n callback: Function\n ) {\n var timer = null;\n var runner = null;\n\n if (options.timeout > 0) {\n timer = new Timer(options.timeout, function() {\n runner.abort();\n callback(true);\n });\n }\n\n runner = strategy.connect(minPriority, function(error, handshake) {\n if (error && timer && timer.isRunning() && !options.failFast) {\n // advance to the next strategy after the timeout\n return;\n }\n if (timer) {\n timer.ensureAborted();\n }\n callback(error, handshake);\n });\n\n return {\n abort: function() {\n if (timer) {\n timer.ensureAborted();\n }\n runner.abort();\n },\n forceMinPriority: function(p) {\n runner.forceMinPriority(p);\n }\n };\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport Strategy from './strategy';\n\n/** Launches all substrategies and emits prioritized connected transports.\n *\n * @param {Array} strategies\n */\nexport default class BestConnectedEverStrategy implements Strategy {\n strategies: Strategy[];\n\n constructor(strategies: Strategy[]) {\n this.strategies = strategies;\n }\n\n isSupported(): boolean {\n return Collections.any(this.strategies, Util.method('isSupported'));\n }\n\n connect(minPriority: number, callback: Function) {\n return connect(this.strategies, minPriority, function(i, runners) {\n return function(error, handshake) {\n runners[i].error = error;\n if (error) {\n if (allRunnersFailed(runners)) {\n callback(true);\n }\n return;\n }\n Collections.apply(runners, function(runner) {\n runner.forceMinPriority(handshake.transport.priority);\n });\n callback(null, handshake);\n };\n });\n }\n}\n\n/** Connects to all strategies in parallel.\n *\n * Callback builder should be a function that takes two arguments: index\n * and a list of runners. It should return another function that will be\n * passed to the substrategy with given index. Runners can be aborted using\n * abortRunner(s) functions from this class.\n *\n * @param {Array} strategies\n * @param {Function} callbackBuilder\n * @return {Object} strategy runner\n */\nfunction connect(\n strategies: Strategy[],\n minPriority: number,\n callbackBuilder: Function\n) {\n var runners = Collections.map(strategies, function(strategy, i, _, rs) {\n return strategy.connect(minPriority, callbackBuilder(i, rs));\n });\n return {\n abort: function() {\n Collections.apply(runners, abortRunner);\n },\n forceMinPriority: function(p) {\n Collections.apply(runners, function(runner) {\n runner.forceMinPriority(p);\n });\n }\n };\n}\n\nfunction allRunnersFailed(runners): boolean {\n return Collections.all(runners, function(runner) {\n return Boolean(runner.error);\n });\n}\n\nfunction abortRunner(runner) {\n if (!runner.error && !runner.aborted) {\n runner.abort();\n runner.aborted = true;\n }\n}\n","import Util from '../util';\nimport Runtime from 'runtime';\nimport Strategy from './strategy';\nimport SequentialStrategy from './sequential_strategy';\nimport StrategyOptions from './strategy_options';\nimport TransportStrategy from './transport_strategy';\nimport Timeline from '../timeline/timeline';\nimport * as Collections from '../utils/collections';\n\nexport interface TransportStrategyDictionary {\n [key: string]: TransportStrategy;\n}\n\n/** Caches the last successful transport and, after the first few attempts,\n * uses the cached transport for subsequent attempts.\n *\n * @param {Strategy} strategy\n * @param {Object} transports\n * @param {Object} options\n */\nexport default class WebSocketPrioritizedCachedStrategy implements Strategy {\n strategy: Strategy;\n transports: TransportStrategyDictionary;\n ttl: number;\n usingTLS: boolean;\n timeline: Timeline;\n\n constructor(\n strategy: Strategy,\n transports: TransportStrategyDictionary,\n options: StrategyOptions\n ) {\n this.strategy = strategy;\n this.transports = transports;\n this.ttl = options.ttl || 1800 * 1000;\n this.usingTLS = options.useTLS;\n this.timeline = options.timeline;\n }\n\n isSupported(): boolean {\n return this.strategy.isSupported();\n }\n\n connect(minPriority: number, callback: Function) {\n var usingTLS = this.usingTLS;\n var info = fetchTransportCache(usingTLS);\n var cacheSkipCount = info && info.cacheSkipCount ? info.cacheSkipCount : 0;\n\n var strategies = [this.strategy];\n if (info && info.timestamp + this.ttl >= Util.now()) {\n var transport = this.transports[info.transport];\n if (transport) {\n if (['ws', 'wss'].includes(info.transport) || cacheSkipCount > 3) {\n this.timeline.info({\n cached: true,\n transport: info.transport,\n latency: info.latency\n });\n strategies.push(\n new SequentialStrategy([transport], {\n timeout: info.latency * 2 + 1000,\n failFast: true\n })\n );\n } else {\n cacheSkipCount++;\n }\n }\n }\n\n var startTimestamp = Util.now();\n var runner = strategies\n .pop()\n .connect(minPriority, function cb(error, handshake) {\n if (error) {\n flushTransportCache(usingTLS);\n if (strategies.length > 0) {\n startTimestamp = Util.now();\n runner = strategies.pop().connect(minPriority, cb);\n } else {\n callback(error);\n }\n } else {\n storeTransportCache(\n usingTLS,\n handshake.transport.name,\n Util.now() - startTimestamp,\n cacheSkipCount\n );\n callback(null, handshake);\n }\n });\n\n return {\n abort: function() {\n runner.abort();\n },\n forceMinPriority: function(p) {\n minPriority = p;\n if (runner) {\n runner.forceMinPriority(p);\n }\n }\n };\n }\n}\n\nfunction getTransportCacheKey(usingTLS: boolean): string {\n return 'pusherTransport' + (usingTLS ? 'TLS' : 'NonTLS');\n}\n\nfunction fetchTransportCache(usingTLS: boolean): any {\n var storage = Runtime.getLocalStorage();\n if (storage) {\n try {\n var serializedCache = storage[getTransportCacheKey(usingTLS)];\n if (serializedCache) {\n return JSON.parse(serializedCache);\n }\n } catch (e) {\n flushTransportCache(usingTLS);\n }\n }\n return null;\n}\n\nfunction storeTransportCache(\n usingTLS: boolean,\n transport: TransportStrategy,\n latency: number,\n cacheSkipCount: number\n) {\n var storage = Runtime.getLocalStorage();\n if (storage) {\n try {\n storage[getTransportCacheKey(usingTLS)] = Collections.safeJSONStringify({\n timestamp: Util.now(),\n transport: transport,\n latency: latency,\n cacheSkipCount: cacheSkipCount\n });\n } catch (e) {\n // catch over quota exceptions raised by localStorage\n }\n }\n}\n\nfunction flushTransportCache(usingTLS: boolean) {\n var storage = Runtime.getLocalStorage();\n if (storage) {\n try {\n delete storage[getTransportCacheKey(usingTLS)];\n } catch (e) {\n // catch exceptions raised by localStorage\n }\n }\n}\n","import { OneOffTimer as Timer } from '../utils/timers';\nimport Strategy from './strategy';\nimport StrategyOptions from './strategy_options';\n\n/** Runs substrategy after specified delay.\n *\n * Options:\n * - delay - time in miliseconds to delay the substrategy attempt\n *\n * @param {Strategy} strategy\n * @param {Object} options\n */\nexport default class DelayedStrategy implements Strategy {\n strategy: Strategy;\n options: { delay: number };\n\n constructor(strategy: Strategy, { delay: number }) {\n this.strategy = strategy;\n this.options = { delay: number };\n }\n\n isSupported(): boolean {\n return this.strategy.isSupported();\n }\n\n connect(minPriority: number, callback: Function) {\n var strategy = this.strategy;\n var runner;\n var timer = new Timer(this.options.delay, function() {\n runner = strategy.connect(minPriority, callback);\n });\n\n return {\n abort: function() {\n timer.ensureAborted();\n if (runner) {\n runner.abort();\n }\n },\n forceMinPriority: function(p) {\n minPriority = p;\n if (runner) {\n runner.forceMinPriority(p);\n }\n }\n };\n }\n}\n","import Strategy from './strategy';\nimport StrategyRunner from './strategy_runner';\n\n/** Proxies method calls to one of substrategies basing on the test function.\n *\n * @param {Function} test\n * @param {Strategy} trueBranch strategy used when test returns true\n * @param {Strategy} falseBranch strategy used when test returns false\n */\nexport default class IfStrategy implements Strategy {\n test: () => boolean;\n trueBranch: Strategy;\n falseBranch: Strategy;\n\n constructor(\n test: () => boolean,\n trueBranch: Strategy,\n falseBranch: Strategy\n ) {\n this.test = test;\n this.trueBranch = trueBranch;\n this.falseBranch = falseBranch;\n }\n\n isSupported(): boolean {\n var branch = this.test() ? this.trueBranch : this.falseBranch;\n return branch.isSupported();\n }\n\n connect(minPriority: number, callback: Function): StrategyRunner {\n var branch = this.test() ? this.trueBranch : this.falseBranch;\n return branch.connect(minPriority, callback);\n }\n}\n","import Strategy from './strategy';\nimport StrategyRunner from './strategy_runner';\n\n/** Launches the substrategy and terminates on the first open connection.\n *\n * @param {Strategy} strategy\n */\nexport default class FirstConnectedStrategy implements Strategy {\n strategy: Strategy;\n\n constructor(strategy: Strategy) {\n this.strategy = strategy;\n }\n\n isSupported(): boolean {\n return this.strategy.isSupported();\n }\n\n connect(minPriority: number, callback: Function): StrategyRunner {\n var runner = this.strategy.connect(minPriority, function(error, handshake) {\n if (handshake) {\n runner.abort();\n }\n callback(error, handshake);\n });\n return runner;\n }\n}\n","import * as Collections from 'core/utils/collections';\nimport TransportManager from 'core/transports/transport_manager';\nimport Strategy from 'core/strategies/strategy';\nimport SequentialStrategy from 'core/strategies/sequential_strategy';\nimport BestConnectedEverStrategy from 'core/strategies/best_connected_ever_strategy';\nimport WebSocketPrioritizedCachedStrategy, {\n TransportStrategyDictionary\n} from 'core/strategies/websocket_prioritized_cached_strategy';\nimport DelayedStrategy from 'core/strategies/delayed_strategy';\nimport IfStrategy from 'core/strategies/if_strategy';\nimport FirstConnectedStrategy from 'core/strategies/first_connected_strategy';\nimport { Config } from 'core/config';\nimport StrategyOptions from 'core/strategies/strategy_options';\n\nfunction testSupportsStrategy(strategy: Strategy) {\n return function() {\n return strategy.isSupported();\n };\n}\n\nvar getDefaultStrategy = function(\n config: Config,\n baseOptions: StrategyOptions,\n defineTransport: Function\n): Strategy {\n var definedTransports = {};\n\n function defineTransportStrategy(\n name: string,\n type: string,\n priority: number,\n options: StrategyOptions,\n manager?: TransportManager\n ) {\n var transport = defineTransport(\n config,\n name,\n type,\n priority,\n options,\n manager\n );\n\n definedTransports[name] = transport;\n\n return transport;\n }\n\n var ws_options: StrategyOptions = Object.assign({}, baseOptions, {\n hostNonTLS: config.wsHost + ':' + config.wsPort,\n hostTLS: config.wsHost + ':' + config.wssPort,\n httpPath: config.wsPath\n });\n var wss_options: StrategyOptions = Collections.extend({}, ws_options, {\n useTLS: true\n });\n var http_options: StrategyOptions = Object.assign({}, baseOptions, {\n hostNonTLS: config.httpHost + ':' + config.httpPort,\n hostTLS: config.httpHost + ':' + config.httpsPort,\n httpPath: config.httpPath\n });\n var timeouts = {\n loop: true,\n timeout: 15000,\n timeoutLimit: 60000\n };\n\n var ws_manager = new TransportManager({\n minPingDelay: 10000,\n maxPingDelay: config.activityTimeout\n });\n var streaming_manager = new TransportManager({\n lives: 2,\n minPingDelay: 10000,\n maxPingDelay: config.activityTimeout\n });\n\n var ws_transport = defineTransportStrategy(\n 'ws',\n 'ws',\n 3,\n ws_options,\n ws_manager\n );\n var wss_transport = defineTransportStrategy(\n 'wss',\n 'ws',\n 3,\n wss_options,\n ws_manager\n );\n var xhr_streaming_transport = defineTransportStrategy(\n 'xhr_streaming',\n 'xhr_streaming',\n 1,\n http_options,\n streaming_manager\n );\n var xhr_polling_transport = defineTransportStrategy(\n 'xhr_polling',\n 'xhr_polling',\n 1,\n http_options\n );\n\n var ws_loop = new SequentialStrategy([ws_transport], timeouts);\n var wss_loop = new SequentialStrategy([wss_transport], timeouts);\n var streaming_loop = new SequentialStrategy(\n [xhr_streaming_transport],\n timeouts\n );\n var polling_loop = new SequentialStrategy([xhr_polling_transport], timeouts);\n\n var http_loop = new SequentialStrategy(\n [\n new IfStrategy(\n testSupportsStrategy(streaming_loop),\n new BestConnectedEverStrategy([\n streaming_loop,\n new DelayedStrategy(polling_loop, { delay: 4000 })\n ]),\n polling_loop\n )\n ],\n timeouts\n );\n\n var wsStrategy;\n if (baseOptions.useTLS) {\n wsStrategy = new BestConnectedEverStrategy([\n ws_loop,\n new DelayedStrategy(http_loop, { delay: 2000 })\n ]);\n } else {\n wsStrategy = new BestConnectedEverStrategy([\n ws_loop,\n new DelayedStrategy(wss_loop, { delay: 2000 }),\n new DelayedStrategy(http_loop, { delay: 5000 })\n ]);\n }\n\n return new WebSocketPrioritizedCachedStrategy(\n new FirstConnectedStrategy(\n new IfStrategy(testSupportsStrategy(ws_transport), wsStrategy, http_loop)\n ),\n definedTransports,\n {\n ttl: 1800000,\n timeline: baseOptions.timeline,\n useTLS: baseOptions.useTLS\n }\n );\n};\n\nexport default getDefaultStrategy;\n","import Runtime from 'runtime';\nimport RequestHooks from './request_hooks';\nimport Ajax from './ajax';\nimport { default as EventsDispatcher } from '../events/dispatcher';\n\nconst MAX_BUFFER_LENGTH = 256 * 1024;\n\nexport default class HTTPRequest extends EventsDispatcher {\n hooks: RequestHooks;\n method: string;\n url: string;\n position: number;\n xhr: Ajax;\n unloader: Function;\n\n constructor(hooks: RequestHooks, method: string, url: string) {\n super();\n this.hooks = hooks;\n this.method = method;\n this.url = url;\n }\n\n start(payload?: any) {\n this.position = 0;\n this.xhr = this.hooks.getRequest(this);\n\n this.unloader = () => {\n this.close();\n };\n Runtime.addUnloadListener(this.unloader);\n\n this.xhr.open(this.method, this.url, true);\n\n if (this.xhr.setRequestHeader) {\n this.xhr.setRequestHeader('Content-Type', 'application/json'); // ReactNative doesn't set this header by default.\n }\n this.xhr.send(payload);\n }\n\n close() {\n if (this.unloader) {\n Runtime.removeUnloadListener(this.unloader);\n this.unloader = null;\n }\n if (this.xhr) {\n this.hooks.abortRequest(this.xhr);\n this.xhr = null;\n }\n }\n\n onChunk(status: number, data: any) {\n while (true) {\n var chunk = this.advanceBuffer(data);\n if (chunk) {\n this.emit('chunk', { status: status, data: chunk });\n } else {\n break;\n }\n }\n if (this.isBufferTooLong(data)) {\n this.emit('buffer_too_long');\n }\n }\n\n private advanceBuffer(buffer: any[]): any {\n var unreadData = buffer.slice(this.position);\n var endOfLinePosition = unreadData.indexOf('\\n');\n\n if (endOfLinePosition !== -1) {\n this.position += endOfLinePosition + 1;\n return unreadData.slice(0, endOfLinePosition);\n } else {\n // chunk is not finished yet, don't move the buffer pointer\n return null;\n }\n }\n\n private isBufferTooLong(buffer: any): boolean {\n return this.position === buffer.length && buffer.length > MAX_BUFFER_LENGTH;\n }\n}\n","enum State {\n CONNECTING = 0,\n OPEN = 1,\n CLOSED = 3\n}\n\nexport default State;\n","import URLLocation from './url_location';\nimport State from './state';\nimport Socket from '../socket';\nimport SocketHooks from './socket_hooks';\nimport Util from '../util';\nimport Ajax from './ajax';\nimport HTTPRequest from './http_request';\nimport Runtime from 'runtime';\n\nvar autoIncrement = 1;\n\nclass HTTPSocket implements Socket {\n hooks: SocketHooks;\n session: string;\n location: URLLocation;\n readyState: State;\n stream: HTTPRequest;\n\n onopen: () => void;\n onerror: (error: any) => void;\n onclose: (closeEvent: any) => void;\n onmessage: (message: any) => void;\n onactivity: () => void;\n\n constructor(hooks: SocketHooks, url: string) {\n this.hooks = hooks;\n this.session = randomNumber(1000) + '/' + randomString(8);\n this.location = getLocation(url);\n this.readyState = State.CONNECTING;\n this.openStream();\n }\n\n send(payload: any) {\n return this.sendRaw(JSON.stringify([payload]));\n }\n\n ping() {\n this.hooks.sendHeartbeat(this);\n }\n\n close(code: any, reason: any) {\n this.onClose(code, reason, true);\n }\n\n /** For internal use only */\n sendRaw(payload: any): boolean {\n if (this.readyState === State.OPEN) {\n try {\n Runtime.createSocketRequest(\n 'POST',\n getUniqueURL(getSendURL(this.location, this.session))\n ).start(payload);\n return true;\n } catch (e) {\n return false;\n }\n } else {\n return false;\n }\n }\n\n /** For internal use only */\n reconnect() {\n this.closeStream();\n this.openStream();\n }\n\n /** For internal use only */\n onClose(code, reason, wasClean) {\n this.closeStream();\n this.readyState = State.CLOSED;\n if (this.onclose) {\n this.onclose({\n code: code,\n reason: reason,\n wasClean: wasClean\n });\n }\n }\n\n private onChunk(chunk) {\n if (chunk.status !== 200) {\n return;\n }\n if (this.readyState === State.OPEN) {\n this.onActivity();\n }\n\n var payload;\n var type = chunk.data.slice(0, 1);\n switch (type) {\n case 'o':\n payload = JSON.parse(chunk.data.slice(1) || '{}');\n this.onOpen(payload);\n break;\n case 'a':\n payload = JSON.parse(chunk.data.slice(1) || '[]');\n for (var i = 0; i < payload.length; i++) {\n this.onEvent(payload[i]);\n }\n break;\n case 'm':\n payload = JSON.parse(chunk.data.slice(1) || 'null');\n this.onEvent(payload);\n break;\n case 'h':\n this.hooks.onHeartbeat(this);\n break;\n case 'c':\n payload = JSON.parse(chunk.data.slice(1) || '[]');\n this.onClose(payload[0], payload[1], true);\n break;\n }\n }\n\n private onOpen(options) {\n if (this.readyState === State.CONNECTING) {\n if (options && options.hostname) {\n this.location.base = replaceHost(this.location.base, options.hostname);\n }\n this.readyState = State.OPEN;\n\n if (this.onopen) {\n this.onopen();\n }\n } else {\n this.onClose(1006, 'Server lost session', true);\n }\n }\n\n private onEvent(event) {\n if (this.readyState === State.OPEN && this.onmessage) {\n this.onmessage({ data: event });\n }\n }\n\n private onActivity() {\n if (this.onactivity) {\n this.onactivity();\n }\n }\n\n private onError(error) {\n if (this.onerror) {\n this.onerror(error);\n }\n }\n\n private openStream() {\n this.stream = Runtime.createSocketRequest(\n 'POST',\n getUniqueURL(this.hooks.getReceiveURL(this.location, this.session))\n );\n\n this.stream.bind('chunk', chunk => {\n this.onChunk(chunk);\n });\n this.stream.bind('finished', status => {\n this.hooks.onFinished(this, status);\n });\n this.stream.bind('buffer_too_long', () => {\n this.reconnect();\n });\n\n try {\n this.stream.start();\n } catch (error) {\n Util.defer(() => {\n this.onError(error);\n this.onClose(1006, 'Could not start streaming', false);\n });\n }\n }\n\n private closeStream() {\n if (this.stream) {\n this.stream.unbind_all();\n this.stream.close();\n this.stream = null;\n }\n }\n}\n\nfunction getLocation(url): URLLocation {\n var parts = /([^\\?]*)\\/*(\\??.*)/.exec(url);\n return {\n base: parts[1],\n queryString: parts[2]\n };\n}\n\nfunction getSendURL(url: URLLocation, session: string): string {\n return url.base + '/' + session + '/xhr_send';\n}\n\nfunction getUniqueURL(url: string): string {\n var separator = url.indexOf('?') === -1 ? '?' : '&';\n return url + separator + 't=' + +new Date() + '&n=' + autoIncrement++;\n}\n\nfunction replaceHost(url: string, hostname: string): string {\n var urlParts = /(https?:\\/\\/)([^\\/:]+)((\\/|:)?.*)/.exec(url);\n return urlParts[1] + hostname + urlParts[3];\n}\n\nfunction randomNumber(max: number): number {\n return Runtime.randomInt(max);\n}\n\nfunction randomString(length: number): string {\n var result = [];\n\n for (var i = 0; i < length; i++) {\n result.push(randomNumber(32).toString(32));\n }\n\n return result.join('');\n}\n\nexport default HTTPSocket;\n","import SocketHooks from './socket_hooks';\nimport HTTPSocket from './http_socket';\n\nvar hooks: SocketHooks = {\n getReceiveURL: function(url, session) {\n return url.base + '/' + session + '/xhr_streaming' + url.queryString;\n },\n onHeartbeat: function(socket) {\n socket.sendRaw('[]');\n },\n sendHeartbeat: function(socket) {\n socket.sendRaw('[]');\n },\n onFinished: function(socket, status) {\n socket.onClose(1006, 'Connection interrupted (' + status + ')', false);\n }\n};\n\nexport default hooks;\n","import SocketHooks from './socket_hooks';\nimport URLLocation from './url_location';\nimport HTTPSocket from './http_socket';\n\nvar hooks: SocketHooks = {\n getReceiveURL: function(url: URLLocation, session: string): string {\n return url.base + '/' + session + '/xhr' + url.queryString;\n },\n onHeartbeat: function() {\n // next HTTP request will reset server's activity timer\n },\n sendHeartbeat: function(socket) {\n socket.sendRaw('[]');\n },\n onFinished: function(socket, status) {\n if (status === 200) {\n socket.reconnect();\n } else {\n socket.onClose(1006, 'Connection interrupted (' + status + ')', false);\n }\n }\n};\n\nexport default hooks;\n","import HTTPRequest from 'core/http/http_request';\nimport RequestHooks from 'core/http/request_hooks';\nimport Ajax from 'core/http/ajax';\nimport Runtime from 'runtime';\n\nvar hooks: RequestHooks = {\n getRequest: function(socket: HTTPRequest): Ajax {\n var Constructor = Runtime.getXHRAPI();\n var xhr = new Constructor();\n xhr.onreadystatechange = xhr.onprogress = function() {\n switch (xhr.readyState) {\n case 3:\n if (xhr.responseText && xhr.responseText.length > 0) {\n socket.onChunk(xhr.status, xhr.responseText);\n }\n break;\n case 4:\n // this happens only on errors, never after calling close\n if (xhr.responseText && xhr.responseText.length > 0) {\n socket.onChunk(xhr.status, xhr.responseText);\n }\n socket.emit('finished', xhr.status);\n socket.close();\n break;\n }\n };\n return xhr;\n },\n abortRequest: function(xhr: Ajax) {\n xhr.onreadystatechange = null;\n xhr.abort();\n }\n};\n\nexport default hooks;\n","import * as Collections from 'core/utils/collections';\nimport Transports from 'isomorphic/transports/transports';\nimport TimelineSender from 'core/timeline/timeline_sender';\nimport Ajax from 'core/http/ajax';\nimport getDefaultStrategy from './default_strategy';\nimport TransportsTable from 'core/transports/transports_table';\nimport transportConnectionInitializer from './transports/transport_connection_initializer';\nimport HTTPFactory from './http/http';\n\nvar Isomorphic: any = {\n getDefaultStrategy,\n Transports: Transports,\n transportConnectionInitializer,\n HTTPFactory,\n\n setup(PusherClass): void {\n PusherClass.ready();\n },\n\n getLocalStorage(): any {\n return undefined;\n },\n\n getClientFeatures(): any[] {\n return Collections.keys(\n Collections.filterObject({ ws: Transports.ws }, function(t) {\n return t.isSupported({});\n })\n );\n },\n\n getProtocol(): string {\n return 'http:';\n },\n\n isXHRSupported(): boolean {\n return true;\n },\n\n createSocketRequest(method: string, url: string) {\n if (this.isXHRSupported()) {\n return this.HTTPFactory.createXHR(method, url);\n } else {\n throw 'Cross-origin HTTP requests are not supported';\n }\n },\n\n createXHR(): Ajax {\n var Constructor = this.getXHRAPI();\n return new Constructor();\n },\n\n createWebSocket(url: string): any {\n var Constructor = this.getWebSocketAPI();\n return new Constructor(url);\n },\n\n addUnloadListener(listener: any) {},\n removeUnloadListener(listener: any) {}\n};\n\nexport default Isomorphic;\n","/** Initializes the transport.\n *\n * Fetches resources if needed and then transitions to initialized.\n */\nexport default function() {\n var self = this;\n\n self.timeline.info(\n self.buildTimelineMessage({\n transport: self.name + (self.options.useTLS ? 's' : '')\n })\n );\n\n if (self.hooks.isInitialized()) {\n self.changeState('initialized');\n } else {\n self.onClose();\n }\n}\n","import HTTPRequest from 'core/http/http_request';\nimport HTTPSocket from 'core/http/http_socket';\nimport SocketHooks from 'core/http/socket_hooks';\nimport RequestHooks from 'core/http/request_hooks';\nimport streamingHooks from 'core/http/http_streaming_socket';\nimport pollingHooks from 'core/http/http_polling_socket';\nimport xhrHooks from './http_xhr_request';\nimport HTTPFactory from 'core/http/http_factory';\n\nvar HTTP: HTTPFactory = {\n createStreamingSocket(url: string): HTTPSocket {\n return this.createSocket(streamingHooks, url);\n },\n\n createPollingSocket(url: string): HTTPSocket {\n return this.createSocket(pollingHooks, url);\n },\n\n createSocket(hooks: SocketHooks, url: string): HTTPSocket {\n return new HTTPSocket(hooks, url);\n },\n\n createXHR(method: string, url: string): HTTPRequest {\n return this.createRequest(xhrHooks, method, url);\n },\n\n createRequest(hooks: RequestHooks, method: string, url: string): HTTPRequest {\n return new HTTPRequest(hooks, method, url);\n }\n};\n\nexport default HTTP;\n","import { default as NativeNetInfo } from '@react-native-community/netinfo';\nimport EventsDispatcher from 'core/events/dispatcher';\nimport Util from 'core/util';\nimport Reachability from 'core/reachability';\n\nfunction hasOnlineConnectionState(connectionState): boolean {\n return connectionState.type.toLowerCase() !== 'none';\n}\n\nexport class NetInfo extends EventsDispatcher implements Reachability {\n online: boolean;\n\n constructor() {\n super();\n this.online = true;\n\n NativeNetInfo.fetch().then(connectionState => {\n this.online = hasOnlineConnectionState(connectionState);\n });\n\n NativeNetInfo.addEventListener(connectionState => {\n var isNowOnline = hasOnlineConnectionState(connectionState);\n\n // React Native counts the switch from Wi-Fi to Cellular\n // as a state change. Return if current and previous states\n // are both online/offline\n if (this.online === isNowOnline) return;\n this.online = isNowOnline;\n if (this.online) {\n this.emit('online');\n } else {\n this.emit('offline');\n }\n });\n }\n\n isOnline(): boolean {\n return this.online;\n }\n}\n\nexport var Network = new NetInfo();\n","export enum AuthRequestType {\n UserAuthentication = 'user-authentication',\n ChannelAuthorization = 'channel-authorization'\n}\n\nexport interface ChannelAuthorizationData {\n auth: string;\n channel_data?: string;\n shared_secret?: string;\n}\n\nexport type ChannelAuthorizationCallback = (\n error: Error | null,\n authData: ChannelAuthorizationData | null\n) => void;\n\nexport interface ChannelAuthorizationRequestParams {\n socketId: string;\n channelName: string;\n}\n\nexport interface ChannelAuthorizationHandler {\n (\n params: ChannelAuthorizationRequestParams,\n callback: ChannelAuthorizationCallback\n ): void;\n}\n\nexport interface UserAuthenticationData {\n auth: string;\n user_data: string;\n}\n\nexport type UserAuthenticationCallback = (\n error: Error | null,\n authData: UserAuthenticationData | null\n) => void;\n\nexport interface UserAuthenticationRequestParams {\n socketId: string;\n}\n\nexport interface UserAuthenticationHandler {\n (\n params: UserAuthenticationRequestParams,\n callback: UserAuthenticationCallback\n ): void;\n}\n\nexport type AuthTransportCallback =\n | ChannelAuthorizationCallback\n | UserAuthenticationCallback;\n\nexport interface AuthOptionsT {\n transport: 'ajax' | 'jsonp';\n endpoint: string;\n params?: any;\n headers?: any;\n paramsProvider?: () => any;\n headersProvider?: () => any;\n customHandler?: AuthHandler;\n}\n\nexport declare type UserAuthenticationOptions = AuthOptionsT<\n UserAuthenticationHandler\n>;\nexport declare type ChannelAuthorizationOptions = AuthOptionsT<\n ChannelAuthorizationHandler\n>;\n\nexport interface InternalAuthOptions {\n transport: 'ajax' | 'jsonp';\n endpoint: string;\n params?: any;\n headers?: any;\n paramsProvider?: () => any;\n headersProvider?: () => any;\n}\n","import TimelineSender from 'core/timeline/timeline_sender';\nimport * as Collections from 'core/utils/collections';\nimport Util from 'core/util';\nimport Runtime from 'runtime';\nimport { AuthTransport } from 'core/auth/auth_transports';\nimport AbstractRuntime from 'runtimes/interface';\nimport UrlStore from 'core/utils/url_store';\nimport {\n AuthRequestType,\n AuthTransportCallback,\n InternalAuthOptions\n} from 'core/auth/options';\nimport { HTTPAuthError } from 'core/errors';\n\nconst ajax: AuthTransport = function(\n context: AbstractRuntime,\n query: string,\n authOptions: InternalAuthOptions,\n authRequestType: AuthRequestType,\n callback: AuthTransportCallback\n) {\n const xhr = Runtime.createXHR();\n xhr.open('POST', authOptions.endpoint, true);\n\n // add request headers\n xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');\n for (var headerName in authOptions.headers) {\n xhr.setRequestHeader(headerName, authOptions.headers[headerName]);\n }\n if (authOptions.headersProvider != null) {\n let dynamicHeaders = authOptions.headersProvider();\n for (var headerName in dynamicHeaders) {\n xhr.setRequestHeader(headerName, dynamicHeaders[headerName]);\n }\n }\n\n xhr.onreadystatechange = function() {\n if (xhr.readyState === 4) {\n if (xhr.status === 200) {\n let data;\n let parsed = false;\n\n try {\n data = JSON.parse(xhr.responseText);\n parsed = true;\n } catch (e) {\n callback(\n new HTTPAuthError(\n 200,\n `JSON returned from ${authRequestType.toString()} endpoint was invalid, yet status code was 200. Data was: ${\n xhr.responseText\n }`\n ),\n null\n );\n }\n\n if (parsed) {\n // prevents double execution.\n callback(null, data);\n }\n } else {\n let suffix = '';\n switch (authRequestType) {\n case AuthRequestType.UserAuthentication:\n suffix = UrlStore.buildLogSuffix('authenticationEndpoint');\n break;\n case AuthRequestType.ChannelAuthorization:\n suffix = `Clients must be authorized to join private or presence channels. ${UrlStore.buildLogSuffix(\n 'authorizationEndpoint'\n )}`;\n break;\n }\n callback(\n new HTTPAuthError(\n xhr.status,\n `Unable to retrieve auth string from ${authRequestType.toString()} endpoint - ` +\n `received status: ${xhr.status} from ${authOptions.endpoint}. ${suffix}`\n ),\n null\n );\n }\n }\n };\n\n xhr.send(query);\n return xhr;\n};\n\nexport default ajax;\n","import Logger from 'core/logger';\nimport TimelineSender from 'core/timeline/timeline_sender';\nimport * as Collections from 'core/utils/collections';\nimport Util from 'core/util';\nimport Runtime from 'runtime';\nimport TimelineTransport from 'core/timeline/timeline_transport';\n\nvar getAgent = function(sender: TimelineSender, useTLS: boolean) {\n return function(data: any, callback: Function) {\n var scheme = 'http' + (useTLS ? 's' : '') + '://';\n var url =\n scheme + (sender.host || sender.options.host) + sender.options.path;\n var query = Collections.buildQueryString(data);\n\n url += '/' + 2 + '?' + query;\n\n var xhr = Runtime.createXHR();\n xhr.open('GET', url, true);\n\n xhr.onreadystatechange = function() {\n if (xhr.readyState === 4) {\n let { status, responseText } = xhr;\n if (status !== 200) {\n Logger.debug(\n `TimelineSender Error: received ${status} from stats.pusher.com`\n );\n return;\n }\n\n try {\n var { host } = JSON.parse(responseText);\n } catch (e) {\n Logger.debug(`TimelineSenderError: invalid response ${responseText}`);\n }\n if (host) {\n sender.host = host;\n }\n }\n };\n\n xhr.send();\n };\n};\n\nvar xhr = {\n name: 'xhr',\n getAgent\n};\n\nexport default xhr;\n","import Isomorphic from 'isomorphic/runtime';\nimport Runtime from '../interface';\nimport { Network } from './net_info';\nimport xhrAuth from 'isomorphic/auth/xhr_auth';\nimport { AuthTransports } from 'core/auth/auth_transports';\nimport xhrTimeline from 'isomorphic/timeline/xhr_timeline';\n\n// Very verbose but until unavoidable until\n// TypeScript 2.1, when spread attributes will be\n// supported\nconst {\n getDefaultStrategy,\n Transports,\n setup,\n getProtocol,\n isXHRSupported,\n getLocalStorage,\n createXHR,\n createWebSocket,\n addUnloadListener,\n removeUnloadListener,\n transportConnectionInitializer,\n createSocketRequest,\n HTTPFactory\n} = Isomorphic;\n\nconst ReactNative: Runtime = {\n getDefaultStrategy,\n Transports,\n setup,\n getProtocol,\n isXHRSupported,\n getLocalStorage,\n createXHR,\n createWebSocket,\n addUnloadListener,\n removeUnloadListener,\n transportConnectionInitializer,\n createSocketRequest,\n HTTPFactory,\n\n TimelineTransport: xhrTimeline,\n\n getAuthorizers(): AuthTransports {\n return { ajax: xhrAuth };\n },\n\n getWebSocketAPI() {\n return WebSocket;\n },\n\n getXHRAPI() {\n return XMLHttpRequest;\n },\n\n getNetwork() {\n return Network;\n },\n\n randomInt(max: number): number {\n return Math.floor(Math.random() * max);\n }\n};\n\nexport default ReactNative;\n","enum TimelineLevel {\n ERROR = 3,\n INFO = 6,\n DEBUG = 7\n}\n\nexport default TimelineLevel;\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport { default as Level } from './level';\n\nexport interface TimelineOptions {\n level?: Level;\n limit?: number;\n version?: string;\n cluster?: string;\n features?: string[];\n params?: any;\n}\n\nexport default class Timeline {\n key: string;\n session: number;\n events: any[];\n options: TimelineOptions;\n sent: number;\n uniqueID: number;\n\n constructor(key: string, session: number, options: TimelineOptions) {\n this.key = key;\n this.session = session;\n this.events = [];\n this.options = options || {};\n this.sent = 0;\n this.uniqueID = 0;\n }\n\n log(level, event) {\n if (level <= this.options.level) {\n this.events.push(\n Collections.extend({}, event, { timestamp: Util.now() })\n );\n if (this.options.limit && this.events.length > this.options.limit) {\n this.events.shift();\n }\n }\n }\n\n error(event) {\n this.log(Level.ERROR, event);\n }\n\n info(event) {\n this.log(Level.INFO, event);\n }\n\n debug(event) {\n this.log(Level.DEBUG, event);\n }\n\n isEmpty() {\n return this.events.length === 0;\n }\n\n send(sendfn, callback) {\n var data = Collections.extend(\n {\n session: this.session,\n bundle: this.sent + 1,\n key: this.key,\n lib: 'js',\n version: this.options.version,\n cluster: this.options.cluster,\n features: this.options.features,\n timeline: this.events\n },\n this.options.params\n );\n\n this.events = [];\n sendfn(data, (error, result) => {\n if (!error) {\n this.sent++;\n }\n if (callback) {\n callback(error, result);\n }\n });\n\n return true;\n }\n\n generateUniqueID(): number {\n this.uniqueID++;\n return this.uniqueID;\n }\n}\n","import Factory from '../utils/factory';\nimport Util from '../util';\nimport * as Errors from '../errors';\nimport * as Collections from '../utils/collections';\nimport Strategy from './strategy';\nimport Transport from '../transports/transport';\nimport StrategyOptions from './strategy_options';\nimport Handshake from '../connection/handshake';\n\n/** Provides a strategy interface for transports.\n *\n * @param {String} name\n * @param {Number} priority\n * @param {Class} transport\n * @param {Object} options\n */\nexport default class TransportStrategy implements Strategy {\n name: string;\n priority: number;\n transport: Transport;\n options: StrategyOptions;\n\n constructor(\n name: string,\n priority: number,\n transport: Transport,\n options: StrategyOptions\n ) {\n this.name = name;\n this.priority = priority;\n this.transport = transport;\n this.options = options || {};\n }\n\n /** Returns whether the transport is supported in the browser.\n *\n * @returns {Boolean}\n */\n isSupported(): boolean {\n return this.transport.isSupported({\n useTLS: this.options.useTLS\n });\n }\n\n /** Launches a connection attempt and returns a strategy runner.\n *\n * @param {Function} callback\n * @return {Object} strategy runner\n */\n connect(minPriority: number, callback: Function) {\n if (!this.isSupported()) {\n return failAttempt(new Errors.UnsupportedStrategy(), callback);\n } else if (this.priority < minPriority) {\n return failAttempt(new Errors.TransportPriorityTooLow(), callback);\n }\n\n var connected = false;\n var transport = this.transport.createConnection(\n this.name,\n this.priority,\n this.options.key,\n this.options\n );\n var handshake = null;\n\n var onInitialized = function() {\n transport.unbind('initialized', onInitialized);\n transport.connect();\n };\n var onOpen = function() {\n handshake = Factory.createHandshake(transport, function(result) {\n connected = true;\n unbindListeners();\n callback(null, result);\n });\n };\n var onError = function(error) {\n unbindListeners();\n callback(error);\n };\n var onClosed = function() {\n unbindListeners();\n var serializedTransport;\n\n // The reason for this try/catch block is that on React Native\n // the WebSocket object is circular. Therefore transport.socket will\n // throw errors upon stringification. Collections.safeJSONStringify\n // discards circular references when serializing.\n serializedTransport = Collections.safeJSONStringify(transport);\n callback(new Errors.TransportClosed(serializedTransport));\n };\n\n var unbindListeners = function() {\n transport.unbind('initialized', onInitialized);\n transport.unbind('open', onOpen);\n transport.unbind('error', onError);\n transport.unbind('closed', onClosed);\n };\n\n transport.bind('initialized', onInitialized);\n transport.bind('open', onOpen);\n transport.bind('error', onError);\n transport.bind('closed', onClosed);\n\n // connect will be called automatically after initialization\n transport.initialize();\n\n return {\n abort: () => {\n if (connected) {\n return;\n }\n unbindListeners();\n if (handshake) {\n handshake.close();\n } else {\n transport.close();\n }\n },\n forceMinPriority: p => {\n if (connected) {\n return;\n }\n if (this.priority < p) {\n if (handshake) {\n handshake.close();\n } else {\n transport.close();\n }\n }\n }\n };\n }\n}\n\nfunction failAttempt(error: Error, callback: Function) {\n Util.defer(function() {\n callback(error);\n });\n return {\n abort: function() {},\n forceMinPriority: function() {}\n };\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport TransportManager from '../transports/transport_manager';\nimport * as Errors from '../errors';\nimport Strategy from './strategy';\nimport TransportStrategy from './transport_strategy';\nimport StrategyOptions from '../strategies/strategy_options';\nimport { Config } from '../config';\nimport Runtime from 'runtime';\n\nconst { Transports } = Runtime;\n\nexport var defineTransport = function(\n config: Config,\n name: string,\n type: string,\n priority: number,\n options: StrategyOptions,\n manager?: TransportManager\n): Strategy {\n var transportClass = Transports[type];\n if (!transportClass) {\n throw new Errors.UnsupportedTransport(type);\n }\n\n var enabled =\n (!config.enabledTransports ||\n Collections.arrayIndexOf(config.enabledTransports, name) !== -1) &&\n (!config.disabledTransports ||\n Collections.arrayIndexOf(config.disabledTransports, name) === -1);\n\n var transport;\n if (enabled) {\n options = Object.assign(\n { ignoreNullOrigin: config.ignoreNullOrigin },\n options\n );\n\n transport = new TransportStrategy(\n name,\n priority,\n manager ? manager.getAssistant(transportClass) : transportClass,\n options\n );\n } else {\n transport = UnsupportedStrategy;\n }\n\n return transport;\n};\n\nvar UnsupportedStrategy: Strategy = {\n isSupported: function() {\n return false;\n },\n connect: function(_, callback) {\n var deferred = Util.defer(function() {\n callback(new Errors.UnsupportedStrategy());\n });\n return {\n abort: function() {\n deferred.ensureAborted();\n },\n forceMinPriority: function() {}\n };\n }\n};\n","import {\n UserAuthenticationCallback,\n InternalAuthOptions,\n UserAuthenticationHandler,\n UserAuthenticationRequestParams,\n AuthRequestType\n} from './options';\n\nimport Runtime from 'runtime';\n\nconst composeChannelQuery = (\n params: UserAuthenticationRequestParams,\n authOptions: InternalAuthOptions\n) => {\n var query = 'socket_id=' + encodeURIComponent(params.socketId);\n\n for (var key in authOptions.params) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(authOptions.params[key]);\n }\n\n if (authOptions.paramsProvider != null) {\n let dynamicParams = authOptions.paramsProvider();\n for (var key in dynamicParams) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(dynamicParams[key]);\n }\n }\n\n return query;\n};\n\nconst UserAuthenticator = (\n authOptions: InternalAuthOptions\n): UserAuthenticationHandler => {\n if (typeof Runtime.getAuthorizers()[authOptions.transport] === 'undefined') {\n throw `'${authOptions.transport}' is not a recognized auth transport`;\n }\n\n return (\n params: UserAuthenticationRequestParams,\n callback: UserAuthenticationCallback\n ) => {\n const query = composeChannelQuery(params, authOptions);\n\n Runtime.getAuthorizers()[authOptions.transport](\n Runtime,\n query,\n authOptions,\n AuthRequestType.UserAuthentication,\n callback\n );\n };\n};\n\nexport default UserAuthenticator;\n","import {\n AuthRequestType,\n InternalAuthOptions,\n ChannelAuthorizationHandler,\n ChannelAuthorizationRequestParams,\n ChannelAuthorizationCallback\n} from './options';\n\nimport Runtime from 'runtime';\n\nconst composeChannelQuery = (\n params: ChannelAuthorizationRequestParams,\n authOptions: InternalAuthOptions\n) => {\n var query = 'socket_id=' + encodeURIComponent(params.socketId);\n\n query += '&channel_name=' + encodeURIComponent(params.channelName);\n\n for (var key in authOptions.params) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(authOptions.params[key]);\n }\n\n if (authOptions.paramsProvider != null) {\n let dynamicParams = authOptions.paramsProvider();\n for (var key in dynamicParams) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(dynamicParams[key]);\n }\n }\n\n return query;\n};\n\nconst ChannelAuthorizer = (\n authOptions: InternalAuthOptions\n): ChannelAuthorizationHandler => {\n if (typeof Runtime.getAuthorizers()[authOptions.transport] === 'undefined') {\n throw `'${authOptions.transport}' is not a recognized auth transport`;\n }\n\n return (\n params: ChannelAuthorizationRequestParams,\n callback: ChannelAuthorizationCallback\n ) => {\n const query = composeChannelQuery(params, authOptions);\n\n Runtime.getAuthorizers()[authOptions.transport](\n Runtime,\n query,\n authOptions,\n AuthRequestType.ChannelAuthorization,\n callback\n );\n };\n};\n\nexport default ChannelAuthorizer;\n","import { Options } from './options';\nimport Defaults from './defaults';\nimport {\n ChannelAuthorizationHandler,\n UserAuthenticationHandler,\n ChannelAuthorizationOptions\n} from './auth/options';\nimport UserAuthenticator from './auth/user_authenticator';\nimport ChannelAuthorizer from './auth/channel_authorizer';\nimport { ChannelAuthorizerProxy } from './auth/deprecated_channel_authorizer';\nimport Runtime from 'runtime';\nimport * as nacl from 'tweetnacl';\n\nexport type AuthTransport = 'ajax' | 'jsonp';\nexport type Transport =\n | 'ws'\n | 'wss'\n | 'xhr_streaming'\n | 'xhr_polling'\n | 'sockjs';\n\nexport interface Config {\n // these are all 'required' config parameters, it's not necessary for the user\n // to set them, but they have configured defaults.\n activityTimeout: number;\n enableStats: boolean;\n httpHost: string;\n httpPath: string;\n httpPort: number;\n httpsPort: number;\n pongTimeout: number;\n statsHost: string;\n unavailableTimeout: number;\n useTLS: boolean;\n wsHost: string;\n wsPath: string;\n wsPort: number;\n wssPort: number;\n userAuthenticator: UserAuthenticationHandler;\n channelAuthorizer: ChannelAuthorizationHandler;\n\n // these are all optional parameters or overrrides. The customer can set these\n // but it's not strictly necessary\n forceTLS?: boolean;\n cluster?: string;\n disabledTransports?: Transport[];\n enabledTransports?: Transport[];\n ignoreNullOrigin?: boolean;\n nacl?: nacl;\n timelineParams?: any;\n}\n\n// getConfig mainly sets the defaults for the options that are not provided\nexport function getConfig(opts: Options, pusher): Config {\n let config: Config = {\n activityTimeout: opts.activityTimeout || Defaults.activityTimeout,\n cluster: opts.cluster,\n httpPath: opts.httpPath || Defaults.httpPath,\n httpPort: opts.httpPort || Defaults.httpPort,\n httpsPort: opts.httpsPort || Defaults.httpsPort,\n pongTimeout: opts.pongTimeout || Defaults.pongTimeout,\n statsHost: opts.statsHost || Defaults.stats_host,\n unavailableTimeout: opts.unavailableTimeout || Defaults.unavailableTimeout,\n wsPath: opts.wsPath || Defaults.wsPath,\n wsPort: opts.wsPort || Defaults.wsPort,\n wssPort: opts.wssPort || Defaults.wssPort,\n\n enableStats: getEnableStatsConfig(opts),\n httpHost: getHttpHost(opts),\n useTLS: shouldUseTLS(opts),\n wsHost: getWebsocketHost(opts),\n\n userAuthenticator: buildUserAuthenticator(opts),\n channelAuthorizer: buildChannelAuthorizer(opts, pusher)\n };\n\n if ('disabledTransports' in opts)\n config.disabledTransports = opts.disabledTransports;\n if ('enabledTransports' in opts)\n config.enabledTransports = opts.enabledTransports;\n if ('ignoreNullOrigin' in opts)\n config.ignoreNullOrigin = opts.ignoreNullOrigin;\n if ('timelineParams' in opts) config.timelineParams = opts.timelineParams;\n if ('nacl' in opts) {\n config.nacl = opts.nacl;\n }\n\n return config;\n}\n\nfunction getHttpHost(opts: Options): string {\n if (opts.httpHost) {\n return opts.httpHost;\n }\n if (opts.cluster) {\n return `sockjs-${opts.cluster}.pusher.com`;\n }\n return Defaults.httpHost;\n}\n\nfunction getWebsocketHost(opts: Options): string {\n if (opts.wsHost) {\n return opts.wsHost;\n }\n return getWebsocketHostFromCluster(opts.cluster);\n}\n\nfunction getWebsocketHostFromCluster(cluster: string): string {\n return `ws-${cluster}.pusher.com`;\n}\n\nfunction shouldUseTLS(opts: Options): boolean {\n if (Runtime.getProtocol() === 'https:') {\n return true;\n } else if (opts.forceTLS === false) {\n return false;\n }\n return true;\n}\n\n// if enableStats is set take the value\n// if disableStats is set take the inverse\n// otherwise default to false\nfunction getEnableStatsConfig(opts: Options): boolean {\n if ('enableStats' in opts) {\n return opts.enableStats;\n }\n if ('disableStats' in opts) {\n return !opts.disableStats;\n }\n return false;\n}\n\nfunction buildUserAuthenticator(opts: Options): UserAuthenticationHandler {\n const userAuthentication = {\n ...Defaults.userAuthentication,\n ...opts.userAuthentication\n };\n if (\n 'customHandler' in userAuthentication &&\n userAuthentication['customHandler'] != null\n ) {\n return userAuthentication['customHandler'];\n }\n\n return UserAuthenticator(userAuthentication);\n}\n\nfunction buildChannelAuth(opts: Options, pusher): ChannelAuthorizationOptions {\n let channelAuthorization: ChannelAuthorizationOptions;\n if ('channelAuthorization' in opts) {\n channelAuthorization = {\n ...Defaults.channelAuthorization,\n ...opts.channelAuthorization\n };\n } else {\n channelAuthorization = {\n transport: opts.authTransport || Defaults.authTransport,\n endpoint: opts.authEndpoint || Defaults.authEndpoint\n };\n if ('auth' in opts) {\n if ('params' in opts.auth) channelAuthorization.params = opts.auth.params;\n if ('headers' in opts.auth)\n channelAuthorization.headers = opts.auth.headers;\n }\n if ('authorizer' in opts)\n channelAuthorization.customHandler = ChannelAuthorizerProxy(\n pusher,\n channelAuthorization,\n opts.authorizer\n );\n }\n return channelAuthorization;\n}\n\nfunction buildChannelAuthorizer(\n opts: Options,\n pusher\n): ChannelAuthorizationHandler {\n const channelAuthorization = buildChannelAuth(opts, pusher);\n if (\n 'customHandler' in channelAuthorization &&\n channelAuthorization['customHandler'] != null\n ) {\n return channelAuthorization['customHandler'];\n }\n\n return ChannelAuthorizer(channelAuthorization);\n}\n","import Channel from '../channels/channel';\nimport {\n ChannelAuthorizationCallback,\n ChannelAuthorizationHandler,\n ChannelAuthorizationRequestParams,\n InternalAuthOptions\n} from './options';\n\nexport interface DeprecatedChannelAuthorizer {\n authorize(socketId: string, callback: ChannelAuthorizationCallback): void;\n}\n\nexport interface ChannelAuthorizerGenerator {\n (\n channel: Channel,\n options: DeprecatedAuthorizerOptions\n ): DeprecatedChannelAuthorizer;\n}\n\nexport interface DeprecatedAuthOptions {\n params?: any;\n headers?: any;\n}\n\nexport interface DeprecatedAuthorizerOptions {\n authTransport: 'ajax' | 'jsonp';\n authEndpoint: string;\n auth?: DeprecatedAuthOptions;\n}\n\nexport const ChannelAuthorizerProxy = (\n pusher,\n authOptions: InternalAuthOptions,\n channelAuthorizerGenerator: ChannelAuthorizerGenerator\n): ChannelAuthorizationHandler => {\n const deprecatedAuthorizerOptions: DeprecatedAuthorizerOptions = {\n authTransport: authOptions.transport,\n authEndpoint: authOptions.endpoint,\n auth: {\n params: authOptions.params,\n headers: authOptions.headers\n }\n };\n return (\n params: ChannelAuthorizationRequestParams,\n callback: ChannelAuthorizationCallback\n ) => {\n const channel = pusher.channel(params.channelName);\n // This line creates a new channel authorizer every time.\n // In the past, this was only done once per channel and reused.\n // We can do that again if we want to keep this behavior intact.\n const channelAuthorizer: DeprecatedChannelAuthorizer = channelAuthorizerGenerator(\n channel,\n deprecatedAuthorizerOptions\n );\n channelAuthorizer.authorize(params.socketId, callback);\n };\n};\n","import Logger from './logger';\nimport Pusher from './pusher';\nimport EventsDispatcher from './events/dispatcher';\n\nexport default class WatchlistFacade extends EventsDispatcher {\n private pusher: Pusher;\n\n public constructor(pusher: Pusher) {\n super(function(eventName, data) {\n Logger.debug(`No callbacks on watchlist events for ${eventName}`);\n });\n\n this.pusher = pusher;\n this.bindWatchlistInternalEvent();\n }\n\n handleEvent(pusherEvent) {\n pusherEvent.data.events.forEach(watchlistEvent => {\n this.emit(watchlistEvent.name, watchlistEvent);\n });\n }\n\n private bindWatchlistInternalEvent() {\n this.pusher.connection.bind('message', pusherEvent => {\n var eventName = pusherEvent.event;\n if (eventName === 'pusher_internal:watchlist_events') {\n this.handleEvent(pusherEvent);\n }\n });\n }\n}\n","function flatPromise() {\n let resolve, reject;\n const promise = new Promise((res, rej) => {\n resolve = res;\n reject = rej;\n });\n return { promise, resolve, reject };\n}\n\nexport default flatPromise;\n","import Pusher from './pusher';\nimport Logger from './logger';\nimport {\n UserAuthenticationData,\n UserAuthenticationCallback\n} from './auth/options';\nimport Channel from './channels/channel';\nimport WatchlistFacade from './watchlist';\nimport EventsDispatcher from './events/dispatcher';\nimport flatPromise from './utils/flat_promise';\n\nexport default class UserFacade extends EventsDispatcher {\n pusher: Pusher;\n signin_requested: boolean = false;\n user_data: any = null;\n serverToUserChannel: Channel = null;\n signinDonePromise: Promise = null;\n watchlist: WatchlistFacade;\n private _signinDoneResolve: Function = null;\n\n public constructor(pusher: Pusher) {\n super(function(eventName, data) {\n Logger.debug('No callbacks on user for ' + eventName);\n });\n this.pusher = pusher;\n this.pusher.connection.bind('state_change', ({ previous, current }) => {\n if (previous !== 'connected' && current === 'connected') {\n this._signin();\n }\n if (previous === 'connected' && current !== 'connected') {\n this._cleanup();\n this._newSigninPromiseIfNeeded();\n }\n });\n\n this.watchlist = new WatchlistFacade(pusher);\n\n this.pusher.connection.bind('message', event => {\n var eventName = event.event;\n if (eventName === 'pusher:signin_success') {\n this._onSigninSuccess(event.data);\n }\n if (\n this.serverToUserChannel &&\n this.serverToUserChannel.name === event.channel\n ) {\n this.serverToUserChannel.handleEvent(event);\n }\n });\n }\n\n public signin() {\n if (this.signin_requested) {\n return;\n }\n\n this.signin_requested = true;\n this._signin();\n }\n\n private _signin() {\n if (!this.signin_requested) {\n return;\n }\n\n this._newSigninPromiseIfNeeded();\n\n if (this.pusher.connection.state !== 'connected') {\n // Signin will be attempted when the connection is connected\n return;\n }\n\n this.pusher.config.userAuthenticator(\n {\n socketId: this.pusher.connection.socket_id\n },\n this._onAuthorize\n );\n }\n\n private _onAuthorize: UserAuthenticationCallback = (\n err,\n authData: UserAuthenticationData\n ) => {\n if (err) {\n Logger.warn(`Error during signin: ${err}`);\n this._cleanup();\n return;\n }\n\n this.pusher.send_event('pusher:signin', {\n auth: authData.auth,\n user_data: authData.user_data\n });\n\n // Later when we get pusher:singin_success event, the user will be marked as signed in\n };\n\n private _onSigninSuccess(data: any) {\n try {\n this.user_data = JSON.parse(data.user_data);\n } catch (e) {\n Logger.error(`Failed parsing user data after signin: ${data.user_data}`);\n this._cleanup();\n return;\n }\n\n if (typeof this.user_data.id !== 'string' || this.user_data.id === '') {\n Logger.error(\n `user_data doesn't contain an id. user_data: ${this.user_data}`\n );\n this._cleanup();\n return;\n }\n\n // Signin succeeded\n this._signinDoneResolve();\n this._subscribeChannels();\n }\n\n private _subscribeChannels() {\n const ensure_subscribed = channel => {\n if (channel.subscriptionPending && channel.subscriptionCancelled) {\n channel.reinstateSubscription();\n } else if (\n !channel.subscriptionPending &&\n this.pusher.connection.state === 'connected'\n ) {\n channel.subscribe();\n }\n };\n\n this.serverToUserChannel = new Channel(\n `#server-to-user-${this.user_data.id}`,\n this.pusher\n );\n this.serverToUserChannel.bind_global((eventName, data) => {\n if (\n eventName.indexOf('pusher_internal:') === 0 ||\n eventName.indexOf('pusher:') === 0\n ) {\n // ignore internal events\n return;\n }\n this.emit(eventName, data);\n });\n ensure_subscribed(this.serverToUserChannel);\n }\n\n private _cleanup() {\n this.user_data = null;\n if (this.serverToUserChannel) {\n this.serverToUserChannel.unbind_all();\n this.serverToUserChannel.disconnect();\n this.serverToUserChannel = null;\n }\n\n if (this.signin_requested) {\n // If signin is in progress and cleanup is called,\n // Mark the current signin process as done.\n this._signinDoneResolve();\n }\n }\n\n private _newSigninPromiseIfNeeded() {\n if (!this.signin_requested) {\n return;\n }\n\n // If there is a promise and it is not resolved, return without creating a new one.\n if (this.signinDonePromise && !(this.signinDonePromise as any).done) {\n return;\n }\n\n // This promise is never rejected.\n // It gets resolved when the signin process is done whether it failed or succeeded\n const { promise, resolve, reject: _ } = flatPromise();\n (promise as any).done = false;\n const setDone = () => {\n (promise as any).done = true;\n };\n promise.then(setDone).catch(setDone);\n this.signinDonePromise = promise;\n this._signinDoneResolve = resolve;\n }\n}\n","import AbstractRuntime from '../runtimes/interface';\nimport Runtime from 'runtime';\nimport * as Collections from './utils/collections';\nimport Channels from './channels/channels';\nimport Channel from './channels/channel';\nimport { default as EventsDispatcher } from './events/dispatcher';\nimport Timeline from './timeline/timeline';\nimport TimelineSender from './timeline/timeline_sender';\nimport TimelineLevel from './timeline/level';\nimport { defineTransport } from './strategies/strategy_builder';\nimport ConnectionManager from './connection/connection_manager';\nimport { PeriodicTimer } from './utils/timers';\nimport Defaults from './defaults';\nimport Logger from './logger';\nimport Factory from './utils/factory';\nimport { Options, ClusterOptions, validateOptions } from './options';\nimport { Config, getConfig } from './config';\nimport StrategyOptions from './strategies/strategy_options';\nimport UserFacade from './user';\n\nexport default class Pusher {\n /* STATIC PROPERTIES */\n static instances: Pusher[] = [];\n static isReady: boolean = false;\n static logToConsole: boolean = false;\n\n // for jsonp\n static Runtime: AbstractRuntime = Runtime;\n static ScriptReceivers: any = (Runtime).ScriptReceivers;\n static DependenciesReceivers: any = (Runtime).DependenciesReceivers;\n static auth_callbacks: any = (Runtime).auth_callbacks;\n\n static ready() {\n Pusher.isReady = true;\n for (var i = 0, l = Pusher.instances.length; i < l; i++) {\n Pusher.instances[i].connect();\n }\n }\n\n static log: (message: any) => void;\n\n private static getClientFeatures(): string[] {\n return Collections.keys(\n Collections.filterObject({ ws: Runtime.Transports.ws }, function(t) {\n return t.isSupported({});\n })\n );\n }\n\n /* INSTANCE PROPERTIES */\n key: string;\n options: Options;\n config: Config;\n channels: Channels;\n global_emitter: EventsDispatcher;\n sessionID: number;\n timeline: Timeline;\n timelineSender: TimelineSender;\n connection: ConnectionManager;\n timelineSenderTimer: PeriodicTimer;\n user: UserFacade;\n constructor(app_key: string, options: Options) {\n checkAppKey(app_key);\n validateOptions(options);\n this.key = app_key;\n this.config = getConfig(options, this);\n\n this.channels = Factory.createChannels();\n this.global_emitter = new EventsDispatcher();\n this.sessionID = Runtime.randomInt(1000000000);\n\n this.timeline = new Timeline(this.key, this.sessionID, {\n cluster: this.config.cluster,\n features: Pusher.getClientFeatures(),\n params: this.config.timelineParams || {},\n limit: 50,\n level: TimelineLevel.INFO,\n version: Defaults.VERSION\n });\n if (this.config.enableStats) {\n this.timelineSender = Factory.createTimelineSender(this.timeline, {\n host: this.config.statsHost,\n path: '/timeline/v2/' + Runtime.TimelineTransport.name\n });\n }\n\n var getStrategy = (options: StrategyOptions) => {\n return Runtime.getDefaultStrategy(this.config, options, defineTransport);\n };\n\n this.connection = Factory.createConnectionManager(this.key, {\n getStrategy: getStrategy,\n timeline: this.timeline,\n activityTimeout: this.config.activityTimeout,\n pongTimeout: this.config.pongTimeout,\n unavailableTimeout: this.config.unavailableTimeout,\n useTLS: Boolean(this.config.useTLS)\n });\n\n this.connection.bind('connected', () => {\n this.subscribeAll();\n if (this.timelineSender) {\n this.timelineSender.send(this.connection.isUsingTLS());\n }\n });\n\n this.connection.bind('message', event => {\n var eventName = event.event;\n var internal = eventName.indexOf('pusher_internal:') === 0;\n if (event.channel) {\n var channel = this.channel(event.channel);\n if (channel) {\n channel.handleEvent(event);\n }\n }\n // Emit globally [deprecated]\n if (!internal) {\n this.global_emitter.emit(event.event, event.data);\n }\n });\n this.connection.bind('connecting', () => {\n this.channels.disconnect();\n });\n this.connection.bind('disconnected', () => {\n this.channels.disconnect();\n });\n this.connection.bind('error', err => {\n Logger.warn(err);\n });\n\n Pusher.instances.push(this);\n this.timeline.info({ instances: Pusher.instances.length });\n\n this.user = new UserFacade(this);\n\n if (Pusher.isReady) {\n this.connect();\n }\n }\n\n /**\n * Allows you to switch Pusher cluster without\n * losing all the channels/subscription binding\n * as this is internally managed by the SDK.\n */\n switchCluster(options: ClusterOptions) {\n const { appKey, cluster } = options;\n this.key = appKey;\n this.options = { ...this.options, cluster };\n this.config = getConfig(this.options, this);\n this.connection.switchCluster(this.key);\n }\n\n channel(name: string): Channel {\n return this.channels.find(name);\n }\n\n allChannels(): Channel[] {\n return this.channels.all();\n }\n\n connect() {\n this.connection.connect();\n\n if (this.timelineSender) {\n if (!this.timelineSenderTimer) {\n var usingTLS = this.connection.isUsingTLS();\n var timelineSender = this.timelineSender;\n this.timelineSenderTimer = new PeriodicTimer(60000, function() {\n timelineSender.send(usingTLS);\n });\n }\n }\n }\n\n disconnect() {\n this.connection.disconnect();\n\n if (this.timelineSenderTimer) {\n this.timelineSenderTimer.ensureAborted();\n this.timelineSenderTimer = null;\n }\n }\n\n bind(event_name: string, callback: Function, context?: any): Pusher {\n this.global_emitter.bind(event_name, callback, context);\n return this;\n }\n\n unbind(event_name?: string, callback?: Function, context?: any): Pusher {\n this.global_emitter.unbind(event_name, callback, context);\n return this;\n }\n\n bind_global(callback: Function): Pusher {\n this.global_emitter.bind_global(callback);\n return this;\n }\n\n unbind_global(callback?: Function): Pusher {\n this.global_emitter.unbind_global(callback);\n return this;\n }\n\n unbind_all(callback?: Function): Pusher {\n this.global_emitter.unbind_all();\n return this;\n }\n\n subscribeAll() {\n var channelName;\n for (channelName in this.channels.channels) {\n if (this.channels.channels.hasOwnProperty(channelName)) {\n this.subscribe(channelName);\n }\n }\n }\n\n subscribe(channel_name: string) {\n var channel = this.channels.add(channel_name, this);\n if (channel.subscriptionPending && channel.subscriptionCancelled) {\n channel.reinstateSubscription();\n } else if (\n !channel.subscriptionPending &&\n this.connection.state === 'connected'\n ) {\n channel.subscribe();\n }\n return channel;\n }\n\n unsubscribe(channel_name: string) {\n var channel = this.channels.find(channel_name);\n if (channel && channel.subscriptionPending) {\n channel.cancelSubscription();\n } else {\n channel = this.channels.remove(channel_name);\n if (channel && channel.subscribed) {\n channel.unsubscribe();\n }\n }\n }\n\n send_event(event_name: string, data: any, channel?: string) {\n return this.connection.send_event(event_name, data, channel);\n }\n\n shouldUseTLS(): boolean {\n return this.config.useTLS;\n }\n\n signin() {\n this.user.signin();\n }\n}\n\nfunction checkAppKey(key) {\n if (key === null || key === undefined) {\n throw 'You must pass your app key when you instantiate Pusher.';\n }\n}\n\nRuntime.setup(Pusher);\n","var g;\n\n// This works in non-strict mode\ng = (function() {\n\treturn this;\n})();\n\ntry {\n\t// This works if eval is allowed (see CSP)\n\tg = g || new Function(\"return this\")();\n} catch (e) {\n\t// This works if the window reference is available\n\tif (typeof window === \"object\") g = window;\n}\n\n// g can still be undefined, but nothing to do about it...\n// We return undefined, instead of nothing here, so it's\n// easier to handle this case. if(!global) { ...}\n\nmodule.exports = g;\n","import ConnectionManager from './connection/connection_manager';\nimport {\n ChannelAuthorizationOptions,\n UserAuthenticationOptions\n} from './auth/options';\nimport {\n ChannelAuthorizerGenerator,\n DeprecatedAuthOptions\n} from './auth/deprecated_channel_authorizer';\nimport { AuthTransport, Transport } from './config';\nimport * as nacl from 'tweetnacl';\nimport Logger from './logger';\n\nexport interface Options {\n activityTimeout?: number;\n\n auth?: DeprecatedAuthOptions; // DEPRECATED use channelAuthorization instead\n authEndpoint?: string; // DEPRECATED use channelAuthorization instead\n authTransport?: AuthTransport; // DEPRECATED use channelAuthorization instead\n authorizer?: ChannelAuthorizerGenerator; // DEPRECATED use channelAuthorization instead\n\n channelAuthorization?: ChannelAuthorizationOptions;\n userAuthentication?: UserAuthenticationOptions;\n\n cluster: string;\n enableStats?: boolean;\n disableStats?: boolean;\n disabledTransports?: Transport[];\n enabledTransports?: Transport[];\n forceTLS?: boolean;\n httpHost?: string;\n httpPath?: string;\n httpPort?: number;\n httpsPort?: number;\n ignoreNullOrigin?: boolean;\n nacl?: nacl;\n pongTimeout?: number;\n statsHost?: string;\n timelineParams?: any;\n unavailableTimeout?: number;\n wsHost?: string;\n wsPath?: string;\n wsPort?: number;\n wssPort?: number;\n}\n\nexport interface ClusterOptions {\n appKey: string;\n cluster: string;\n}\n\nexport function validateOptions(options) {\n if (options == null) {\n throw 'You must pass an options object';\n }\n if (options.cluster == null) {\n throw 'Options object must provide a cluster';\n }\n if ('disableStats' in options) {\n Logger.warn(\n 'The disableStats option is deprecated in favor of enableStats'\n );\n }\n}\n","// Copyright (C) 2016 Dmitry Chestnykh\n// MIT License. See LICENSE file for details.\n\n/**\n * Package base64 implements Base64 encoding and decoding.\n */\n\n// Invalid character used in decoding to indicate\n// that the character to decode is out of range of\n// alphabet and cannot be decoded.\nconst INVALID_BYTE = 256;\n\n/**\n * Implements standard Base64 encoding.\n *\n * Operates in constant time.\n */\nexport class Coder {\n // TODO(dchest): methods to encode chunk-by-chunk.\n\n constructor(private _paddingCharacter = \"=\") { }\n\n encodedLength(length: number): number {\n if (!this._paddingCharacter) {\n return (length * 8 + 5) / 6 | 0;\n }\n return (length + 2) / 3 * 4 | 0;\n }\n\n encode(data: Uint8Array): string {\n let out = \"\";\n\n let i = 0;\n for (; i < data.length - 2; i += 3) {\n let c = (data[i] << 16) | (data[i + 1] << 8) | (data[i + 2]);\n out += this._encodeByte((c >>> 3 * 6) & 63);\n out += this._encodeByte((c >>> 2 * 6) & 63);\n out += this._encodeByte((c >>> 1 * 6) & 63);\n out += this._encodeByte((c >>> 0 * 6) & 63);\n }\n\n const left = data.length - i;\n if (left > 0) {\n let c = (data[i] << 16) | (left === 2 ? data[i + 1] << 8 : 0);\n out += this._encodeByte((c >>> 3 * 6) & 63);\n out += this._encodeByte((c >>> 2 * 6) & 63);\n if (left === 2) {\n out += this._encodeByte((c >>> 1 * 6) & 63);\n } else {\n out += this._paddingCharacter || \"\";\n }\n out += this._paddingCharacter || \"\";\n }\n\n return out;\n }\n\n maxDecodedLength(length: number): number {\n if (!this._paddingCharacter) {\n return (length * 6 + 7) / 8 | 0;\n }\n return length / 4 * 3 | 0;\n }\n\n decodedLength(s: string): number {\n return this.maxDecodedLength(s.length - this._getPaddingLength(s));\n }\n\n decode(s: string): Uint8Array {\n if (s.length === 0) {\n return new Uint8Array(0);\n }\n const paddingLength = this._getPaddingLength(s);\n const length = s.length - paddingLength;\n const out = new Uint8Array(this.maxDecodedLength(length));\n let op = 0;\n let i = 0;\n let haveBad = 0;\n let v0 = 0, v1 = 0, v2 = 0, v3 = 0;\n for (; i < length - 4; i += 4) {\n v0 = this._decodeChar(s.charCodeAt(i + 0));\n v1 = this._decodeChar(s.charCodeAt(i + 1));\n v2 = this._decodeChar(s.charCodeAt(i + 2));\n v3 = this._decodeChar(s.charCodeAt(i + 3));\n out[op++] = (v0 << 2) | (v1 >>> 4);\n out[op++] = (v1 << 4) | (v2 >>> 2);\n out[op++] = (v2 << 6) | v3;\n haveBad |= v0 & INVALID_BYTE;\n haveBad |= v1 & INVALID_BYTE;\n haveBad |= v2 & INVALID_BYTE;\n haveBad |= v3 & INVALID_BYTE;\n }\n if (i < length - 1) {\n v0 = this._decodeChar(s.charCodeAt(i));\n v1 = this._decodeChar(s.charCodeAt(i + 1));\n out[op++] = (v0 << 2) | (v1 >>> 4);\n haveBad |= v0 & INVALID_BYTE;\n haveBad |= v1 & INVALID_BYTE;\n }\n if (i < length - 2) {\n v2 = this._decodeChar(s.charCodeAt(i + 2));\n out[op++] = (v1 << 4) | (v2 >>> 2);\n haveBad |= v2 & INVALID_BYTE;\n }\n if (i < length - 3) {\n v3 = this._decodeChar(s.charCodeAt(i + 3));\n out[op++] = (v2 << 6) | v3;\n haveBad |= v3 & INVALID_BYTE;\n }\n if (haveBad !== 0) {\n throw new Error(\"Base64Coder: incorrect characters for decoding\");\n }\n return out;\n }\n\n // Standard encoding have the following encoded/decoded ranges,\n // which we need to convert between.\n //\n // ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 0123456789 + /\n // Index: 0 - 25 26 - 51 52 - 61 62 63\n // ASCII: 65 - 90 97 - 122 48 - 57 43 47\n //\n\n // Encode 6 bits in b into a new character.\n protected _encodeByte(b: number): string {\n // Encoding uses constant time operations as follows:\n //\n // 1. Define comparison of A with B using (A - B) >>> 8:\n // if A > B, then result is positive integer\n // if A <= B, then result is 0\n //\n // 2. Define selection of C or 0 using bitwise AND: X & C:\n // if X == 0, then result is 0\n // if X != 0, then result is C\n //\n // 3. Start with the smallest comparison (b >= 0), which is always\n // true, so set the result to the starting ASCII value (65).\n //\n // 4. Continue comparing b to higher ASCII values, and selecting\n // zero if comparison isn't true, otherwise selecting a value\n // to add to result, which:\n //\n // a) undoes the previous addition\n // b) provides new value to add\n //\n let result = b;\n // b >= 0\n result += 65;\n // b > 25\n result += ((25 - b) >>> 8) & ((0 - 65) - 26 + 97);\n // b > 51\n result += ((51 - b) >>> 8) & ((26 - 97) - 52 + 48);\n // b > 61\n result += ((61 - b) >>> 8) & ((52 - 48) - 62 + 43);\n // b > 62\n result += ((62 - b) >>> 8) & ((62 - 43) - 63 + 47);\n\n return String.fromCharCode(result);\n }\n\n // Decode a character code into a byte.\n // Must return 256 if character is out of alphabet range.\n protected _decodeChar(c: number): number {\n // Decoding works similar to encoding: using the same comparison\n // function, but now it works on ranges: result is always incremented\n // by value, but this value becomes zero if the range is not\n // satisfied.\n //\n // Decoding starts with invalid value, 256, which is then\n // subtracted when the range is satisfied. If none of the ranges\n // apply, the function returns 256, which is then checked by\n // the caller to throw error.\n let result = INVALID_BYTE; // start with invalid character\n\n // c == 43 (c > 42 and c < 44)\n result += (((42 - c) & (c - 44)) >>> 8) & (-INVALID_BYTE + c - 43 + 62);\n // c == 47 (c > 46 and c < 48)\n result += (((46 - c) & (c - 48)) >>> 8) & (-INVALID_BYTE + c - 47 + 63);\n // c > 47 and c < 58\n result += (((47 - c) & (c - 58)) >>> 8) & (-INVALID_BYTE + c - 48 + 52);\n // c > 64 and c < 91\n result += (((64 - c) & (c - 91)) >>> 8) & (-INVALID_BYTE + c - 65 + 0);\n // c > 96 and c < 123\n result += (((96 - c) & (c - 123)) >>> 8) & (-INVALID_BYTE + c - 97 + 26);\n\n return result;\n }\n\n private _getPaddingLength(s: string): number {\n let paddingLength = 0;\n if (this._paddingCharacter) {\n for (let i = s.length - 1; i >= 0; i--) {\n if (s[i] !== this._paddingCharacter) {\n break;\n }\n paddingLength++;\n }\n if (s.length < 4 || paddingLength > 2) {\n throw new Error(\"Base64Coder: incorrect padding\");\n }\n }\n return paddingLength;\n }\n\n}\n\nconst stdCoder = new Coder();\n\nexport function encode(data: Uint8Array): string {\n return stdCoder.encode(data);\n}\n\nexport function decode(s: string): Uint8Array {\n return stdCoder.decode(s);\n}\n\n/**\n * Implements URL-safe Base64 encoding.\n * (Same as Base64, but '+' is replaced with '-', and '/' with '_').\n *\n * Operates in constant time.\n */\nexport class URLSafeCoder extends Coder {\n // URL-safe encoding have the following encoded/decoded ranges:\n //\n // ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 0123456789 - _\n // Index: 0 - 25 26 - 51 52 - 61 62 63\n // ASCII: 65 - 90 97 - 122 48 - 57 45 95\n //\n\n protected _encodeByte(b: number): string {\n let result = b;\n // b >= 0\n result += 65;\n // b > 25\n result += ((25 - b) >>> 8) & ((0 - 65) - 26 + 97);\n // b > 51\n result += ((51 - b) >>> 8) & ((26 - 97) - 52 + 48);\n // b > 61\n result += ((61 - b) >>> 8) & ((52 - 48) - 62 + 45);\n // b > 62\n result += ((62 - b) >>> 8) & ((62 - 45) - 63 + 95);\n\n return String.fromCharCode(result);\n }\n\n protected _decodeChar(c: number): number {\n let result = INVALID_BYTE;\n\n // c == 45 (c > 44 and c < 46)\n result += (((44 - c) & (c - 46)) >>> 8) & (-INVALID_BYTE + c - 45 + 62);\n // c == 95 (c > 94 and c < 96)\n result += (((94 - c) & (c - 96)) >>> 8) & (-INVALID_BYTE + c - 95 + 63);\n // c > 47 and c < 58\n result += (((47 - c) & (c - 58)) >>> 8) & (-INVALID_BYTE + c - 48 + 52);\n // c > 64 and c < 91\n result += (((64 - c) & (c - 91)) >>> 8) & (-INVALID_BYTE + c - 65 + 0);\n // c > 96 and c < 123\n result += (((96 - c) & (c - 123)) >>> 8) & (-INVALID_BYTE + c - 97 + 26);\n\n return result;\n }\n}\n\nconst urlSafeCoder = new URLSafeCoder();\n\nexport function encodeURLSafe(data: Uint8Array): string {\n return urlSafeCoder.encode(data);\n}\n\nexport function decodeURLSafe(s: string): Uint8Array {\n return urlSafeCoder.decode(s);\n}\n\n\nexport const encodedLength = (length: number) =>\n stdCoder.encodedLength(length);\n\nexport const maxDecodedLength = (length: number) =>\n stdCoder.maxDecodedLength(length);\n\nexport const decodedLength = (s: string) =>\n stdCoder.decodedLength(s);\n","import TimedCallback from './timed_callback';\nimport { Delay, Scheduler, Canceller } from './scheduling';\n\nabstract class Timer {\n protected clear: Canceller;\n protected timer: number | void;\n\n constructor(\n set: Scheduler,\n clear: Canceller,\n delay: Delay,\n callback: TimedCallback\n ) {\n this.clear = clear;\n this.timer = set(() => {\n if (this.timer) {\n this.timer = callback(this.timer);\n }\n }, delay);\n }\n\n /** Returns whether the timer is still running.\n *\n * @return {Boolean}\n */\n isRunning(): boolean {\n return this.timer !== null;\n }\n\n /** Aborts a timer when it's running. */\n ensureAborted() {\n if (this.timer) {\n this.clear(this.timer);\n this.timer = null;\n }\n }\n}\n\nexport default Timer;\n","module.exports = require(\"@react-native-community/netinfo\");","export default function encode(s: any): string {\n return btoa(utob(s));\n}\n\nvar fromCharCode = String.fromCharCode;\n\nvar b64chars =\n 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';\nvar b64tab = {};\n\nfor (var i = 0, l = b64chars.length; i < l; i++) {\n b64tab[b64chars.charAt(i)] = i;\n}\n\nvar cb_utob = function(c) {\n var cc = c.charCodeAt(0);\n return cc < 0x80\n ? c\n : cc < 0x800\n ? fromCharCode(0xc0 | (cc >>> 6)) + fromCharCode(0x80 | (cc & 0x3f))\n : fromCharCode(0xe0 | ((cc >>> 12) & 0x0f)) +\n fromCharCode(0x80 | ((cc >>> 6) & 0x3f)) +\n fromCharCode(0x80 | (cc & 0x3f));\n};\n\nvar utob = function(u) {\n return u.replace(/[^\\x00-\\x7F]/g, cb_utob);\n};\n\nvar cb_encode = function(ccc) {\n var padlen = [0, 2, 1][ccc.length % 3];\n var ord =\n (ccc.charCodeAt(0) << 16) |\n ((ccc.length > 1 ? ccc.charCodeAt(1) : 0) << 8) |\n (ccc.length > 2 ? ccc.charCodeAt(2) : 0);\n var chars = [\n b64chars.charAt(ord >>> 18),\n b64chars.charAt((ord >>> 12) & 63),\n padlen >= 2 ? '=' : b64chars.charAt((ord >>> 6) & 63),\n padlen >= 1 ? '=' : b64chars.charAt(ord & 63)\n ];\n return chars.join('');\n};\n\nvar btoa =\n global.btoa ||\n function(b) {\n return b.replace(/[\\s\\S]{1,3}/g, cb_encode);\n };\n","import Callback from './callback';\nimport * as Collections from '../utils/collections';\nimport CallbackTable from './callback_table';\n\nexport default class CallbackRegistry {\n _callbacks: CallbackTable;\n\n constructor() {\n this._callbacks = {};\n }\n\n get(name: string): Callback[] {\n return this._callbacks[prefix(name)];\n }\n\n add(name: string, callback: Function, context: any) {\n var prefixedEventName = prefix(name);\n this._callbacks[prefixedEventName] =\n this._callbacks[prefixedEventName] || [];\n this._callbacks[prefixedEventName].push({\n fn: callback,\n context: context\n });\n }\n\n remove(name?: string, callback?: Function, context?: any) {\n if (!name && !callback && !context) {\n this._callbacks = {};\n return;\n }\n\n var names = name ? [prefix(name)] : Collections.keys(this._callbacks);\n\n if (callback || context) {\n this.removeCallback(names, callback, context);\n } else {\n this.removeAllCallbacks(names);\n }\n }\n\n private removeCallback(names: string[], callback: Function, context: any) {\n Collections.apply(\n names,\n function(name) {\n this._callbacks[name] = Collections.filter(\n this._callbacks[name] || [],\n function(binding) {\n return (\n (callback && callback !== binding.fn) ||\n (context && context !== binding.context)\n );\n }\n );\n if (this._callbacks[name].length === 0) {\n delete this._callbacks[name];\n }\n },\n this\n );\n }\n\n private removeAllCallbacks(names: string[]) {\n Collections.apply(\n names,\n function(name) {\n delete this._callbacks[name];\n },\n this\n );\n }\n}\n\nfunction prefix(name: string): string {\n return '_' + name;\n}\n","// Copyright (C) 2016 Dmitry Chestnykh\n// MIT License. See LICENSE file for details.\n\n/**\n * Package utf8 implements UTF-8 encoding and decoding.\n */\n\nconst INVALID_UTF16 = \"utf8: invalid string\";\nconst INVALID_UTF8 = \"utf8: invalid source encoding\";\n\n/**\n * Encodes the given string into UTF-8 byte array.\n * Throws if the source string has invalid UTF-16 encoding.\n */\nexport function encode(s: string): Uint8Array {\n // Calculate result length and allocate output array.\n // encodedLength() also validates string and throws errors,\n // so we don't need repeat validation here.\n const arr = new Uint8Array(encodedLength(s));\n\n let pos = 0;\n for (let i = 0; i < s.length; i++) {\n let c = s.charCodeAt(i);\n if (c < 0x80) {\n arr[pos++] = c;\n } else if (c < 0x800) {\n arr[pos++] = 0xc0 | c >> 6;\n arr[pos++] = 0x80 | c & 0x3f;\n } else if (c < 0xd800) {\n arr[pos++] = 0xe0 | c >> 12;\n arr[pos++] = 0x80 | (c >> 6) & 0x3f;\n arr[pos++] = 0x80 | c & 0x3f;\n } else {\n i++; // get one more character\n c = (c & 0x3ff) << 10;\n c |= s.charCodeAt(i) & 0x3ff;\n c += 0x10000;\n\n arr[pos++] = 0xf0 | c >> 18;\n arr[pos++] = 0x80 | (c >> 12) & 0x3f;\n arr[pos++] = 0x80 | (c >> 6) & 0x3f;\n arr[pos++] = 0x80 | c & 0x3f;\n }\n }\n return arr;\n}\n\n/**\n * Returns the number of bytes required to encode the given string into UTF-8.\n * Throws if the source string has invalid UTF-16 encoding.\n */\nexport function encodedLength(s: string): number {\n let result = 0;\n for (let i = 0; i < s.length; i++) {\n const c = s.charCodeAt(i);\n if (c < 0x80) {\n result += 1;\n } else if (c < 0x800) {\n result += 2;\n } else if (c < 0xd800) {\n result += 3;\n } else if (c <= 0xdfff) {\n if (i >= s.length - 1) {\n throw new Error(INVALID_UTF16);\n }\n i++; // \"eat\" next character\n result += 4;\n } else {\n throw new Error(INVALID_UTF16);\n }\n }\n return result;\n}\n\n/**\n * Decodes the given byte array from UTF-8 into a string.\n * Throws if encoding is invalid.\n */\nexport function decode(arr: Uint8Array): string {\n const chars: string[] = [];\n for (let i = 0; i < arr.length; i++) {\n let b = arr[i];\n\n if (b & 0x80) {\n let min;\n if (b < 0xe0) {\n // Need 1 more byte.\n if (i >= arr.length) {\n throw new Error(INVALID_UTF8);\n }\n const n1 = arr[++i];\n if ((n1 & 0xc0) !== 0x80) {\n throw new Error(INVALID_UTF8);\n }\n b = (b & 0x1f) << 6 | (n1 & 0x3f);\n min = 0x80;\n } else if (b < 0xf0) {\n // Need 2 more bytes.\n if (i >= arr.length - 1) {\n throw new Error(INVALID_UTF8);\n }\n const n1 = arr[++i];\n const n2 = arr[++i];\n if ((n1 & 0xc0) !== 0x80 || (n2 & 0xc0) !== 0x80) {\n throw new Error(INVALID_UTF8);\n }\n b = (b & 0x0f) << 12 | (n1 & 0x3f) << 6 | (n2 & 0x3f);\n min = 0x800;\n } else if (b < 0xf8) {\n // Need 3 more bytes.\n if (i >= arr.length - 2) {\n throw new Error(INVALID_UTF8);\n }\n const n1 = arr[++i];\n const n2 = arr[++i];\n const n3 = arr[++i];\n if ((n1 & 0xc0) !== 0x80 || (n2 & 0xc0) !== 0x80 || (n3 & 0xc0) !== 0x80) {\n throw new Error(INVALID_UTF8);\n }\n b = (b & 0x0f) << 18 | (n1 & 0x3f) << 12 | (n2 & 0x3f) << 6 | (n3 & 0x3f);\n min = 0x10000;\n } else {\n throw new Error(INVALID_UTF8);\n }\n\n if (b < min || (b >= 0xd800 && b <= 0xdfff)) {\n throw new Error(INVALID_UTF8);\n }\n\n if (b >= 0x10000) {\n // Surrogate pair.\n if (b > 0x10ffff) {\n throw new Error(INVALID_UTF8);\n }\n b -= 0x10000;\n chars.push(String.fromCharCode(0xd800 | (b >> 10)));\n b = 0xdc00 | (b & 0x3ff);\n }\n }\n\n chars.push(String.fromCharCode(b));\n }\n return chars.join(\"\");\n}\n","(function(nacl) {\n'use strict';\n\n// Ported in 2014 by Dmitry Chestnykh and Devi Mandiri.\n// Public domain.\n//\n// Implementation derived from TweetNaCl version 20140427.\n// See for details: http://tweetnacl.cr.yp.to/\n\nvar gf = function(init) {\n var i, r = new Float64Array(16);\n if (init) for (i = 0; i < init.length; i++) r[i] = init[i];\n return r;\n};\n\n// Pluggable, initialized in high-level API below.\nvar randombytes = function(/* x, n */) { throw new Error('no PRNG'); };\n\nvar _0 = new Uint8Array(16);\nvar _9 = new Uint8Array(32); _9[0] = 9;\n\nvar gf0 = gf(),\n gf1 = gf([1]),\n _121665 = gf([0xdb41, 1]),\n D = gf([0x78a3, 0x1359, 0x4dca, 0x75eb, 0xd8ab, 0x4141, 0x0a4d, 0x0070, 0xe898, 0x7779, 0x4079, 0x8cc7, 0xfe73, 0x2b6f, 0x6cee, 0x5203]),\n D2 = gf([0xf159, 0x26b2, 0x9b94, 0xebd6, 0xb156, 0x8283, 0x149a, 0x00e0, 0xd130, 0xeef3, 0x80f2, 0x198e, 0xfce7, 0x56df, 0xd9dc, 0x2406]),\n X = gf([0xd51a, 0x8f25, 0x2d60, 0xc956, 0xa7b2, 0x9525, 0xc760, 0x692c, 0xdc5c, 0xfdd6, 0xe231, 0xc0a4, 0x53fe, 0xcd6e, 0x36d3, 0x2169]),\n Y = gf([0x6658, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666]),\n I = gf([0xa0b0, 0x4a0e, 0x1b27, 0xc4ee, 0xe478, 0xad2f, 0x1806, 0x2f43, 0xd7a7, 0x3dfb, 0x0099, 0x2b4d, 0xdf0b, 0x4fc1, 0x2480, 0x2b83]);\n\nfunction ts64(x, i, h, l) {\n x[i] = (h >> 24) & 0xff;\n x[i+1] = (h >> 16) & 0xff;\n x[i+2] = (h >> 8) & 0xff;\n x[i+3] = h & 0xff;\n x[i+4] = (l >> 24) & 0xff;\n x[i+5] = (l >> 16) & 0xff;\n x[i+6] = (l >> 8) & 0xff;\n x[i+7] = l & 0xff;\n}\n\nfunction vn(x, xi, y, yi, n) {\n var i,d = 0;\n for (i = 0; i < n; i++) d |= x[xi+i]^y[yi+i];\n return (1 & ((d - 1) >>> 8)) - 1;\n}\n\nfunction crypto_verify_16(x, xi, y, yi) {\n return vn(x,xi,y,yi,16);\n}\n\nfunction crypto_verify_32(x, xi, y, yi) {\n return vn(x,xi,y,yi,32);\n}\n\nfunction core_salsa20(o, p, k, c) {\n var j0 = c[ 0] & 0xff | (c[ 1] & 0xff)<<8 | (c[ 2] & 0xff)<<16 | (c[ 3] & 0xff)<<24,\n j1 = k[ 0] & 0xff | (k[ 1] & 0xff)<<8 | (k[ 2] & 0xff)<<16 | (k[ 3] & 0xff)<<24,\n j2 = k[ 4] & 0xff | (k[ 5] & 0xff)<<8 | (k[ 6] & 0xff)<<16 | (k[ 7] & 0xff)<<24,\n j3 = k[ 8] & 0xff | (k[ 9] & 0xff)<<8 | (k[10] & 0xff)<<16 | (k[11] & 0xff)<<24,\n j4 = k[12] & 0xff | (k[13] & 0xff)<<8 | (k[14] & 0xff)<<16 | (k[15] & 0xff)<<24,\n j5 = c[ 4] & 0xff | (c[ 5] & 0xff)<<8 | (c[ 6] & 0xff)<<16 | (c[ 7] & 0xff)<<24,\n j6 = p[ 0] & 0xff | (p[ 1] & 0xff)<<8 | (p[ 2] & 0xff)<<16 | (p[ 3] & 0xff)<<24,\n j7 = p[ 4] & 0xff | (p[ 5] & 0xff)<<8 | (p[ 6] & 0xff)<<16 | (p[ 7] & 0xff)<<24,\n j8 = p[ 8] & 0xff | (p[ 9] & 0xff)<<8 | (p[10] & 0xff)<<16 | (p[11] & 0xff)<<24,\n j9 = p[12] & 0xff | (p[13] & 0xff)<<8 | (p[14] & 0xff)<<16 | (p[15] & 0xff)<<24,\n j10 = c[ 8] & 0xff | (c[ 9] & 0xff)<<8 | (c[10] & 0xff)<<16 | (c[11] & 0xff)<<24,\n j11 = k[16] & 0xff | (k[17] & 0xff)<<8 | (k[18] & 0xff)<<16 | (k[19] & 0xff)<<24,\n j12 = k[20] & 0xff | (k[21] & 0xff)<<8 | (k[22] & 0xff)<<16 | (k[23] & 0xff)<<24,\n j13 = k[24] & 0xff | (k[25] & 0xff)<<8 | (k[26] & 0xff)<<16 | (k[27] & 0xff)<<24,\n j14 = k[28] & 0xff | (k[29] & 0xff)<<8 | (k[30] & 0xff)<<16 | (k[31] & 0xff)<<24,\n j15 = c[12] & 0xff | (c[13] & 0xff)<<8 | (c[14] & 0xff)<<16 | (c[15] & 0xff)<<24;\n\n var x0 = j0, x1 = j1, x2 = j2, x3 = j3, x4 = j4, x5 = j5, x6 = j6, x7 = j7,\n x8 = j8, x9 = j9, x10 = j10, x11 = j11, x12 = j12, x13 = j13, x14 = j14,\n x15 = j15, u;\n\n for (var i = 0; i < 20; i += 2) {\n u = x0 + x12 | 0;\n x4 ^= u<<7 | u>>>(32-7);\n u = x4 + x0 | 0;\n x8 ^= u<<9 | u>>>(32-9);\n u = x8 + x4 | 0;\n x12 ^= u<<13 | u>>>(32-13);\n u = x12 + x8 | 0;\n x0 ^= u<<18 | u>>>(32-18);\n\n u = x5 + x1 | 0;\n x9 ^= u<<7 | u>>>(32-7);\n u = x9 + x5 | 0;\n x13 ^= u<<9 | u>>>(32-9);\n u = x13 + x9 | 0;\n x1 ^= u<<13 | u>>>(32-13);\n u = x1 + x13 | 0;\n x5 ^= u<<18 | u>>>(32-18);\n\n u = x10 + x6 | 0;\n x14 ^= u<<7 | u>>>(32-7);\n u = x14 + x10 | 0;\n x2 ^= u<<9 | u>>>(32-9);\n u = x2 + x14 | 0;\n x6 ^= u<<13 | u>>>(32-13);\n u = x6 + x2 | 0;\n x10 ^= u<<18 | u>>>(32-18);\n\n u = x15 + x11 | 0;\n x3 ^= u<<7 | u>>>(32-7);\n u = x3 + x15 | 0;\n x7 ^= u<<9 | u>>>(32-9);\n u = x7 + x3 | 0;\n x11 ^= u<<13 | u>>>(32-13);\n u = x11 + x7 | 0;\n x15 ^= u<<18 | u>>>(32-18);\n\n u = x0 + x3 | 0;\n x1 ^= u<<7 | u>>>(32-7);\n u = x1 + x0 | 0;\n x2 ^= u<<9 | u>>>(32-9);\n u = x2 + x1 | 0;\n x3 ^= u<<13 | u>>>(32-13);\n u = x3 + x2 | 0;\n x0 ^= u<<18 | u>>>(32-18);\n\n u = x5 + x4 | 0;\n x6 ^= u<<7 | u>>>(32-7);\n u = x6 + x5 | 0;\n x7 ^= u<<9 | u>>>(32-9);\n u = x7 + x6 | 0;\n x4 ^= u<<13 | u>>>(32-13);\n u = x4 + x7 | 0;\n x5 ^= u<<18 | u>>>(32-18);\n\n u = x10 + x9 | 0;\n x11 ^= u<<7 | u>>>(32-7);\n u = x11 + x10 | 0;\n x8 ^= u<<9 | u>>>(32-9);\n u = x8 + x11 | 0;\n x9 ^= u<<13 | u>>>(32-13);\n u = x9 + x8 | 0;\n x10 ^= u<<18 | u>>>(32-18);\n\n u = x15 + x14 | 0;\n x12 ^= u<<7 | u>>>(32-7);\n u = x12 + x15 | 0;\n x13 ^= u<<9 | u>>>(32-9);\n u = x13 + x12 | 0;\n x14 ^= u<<13 | u>>>(32-13);\n u = x14 + x13 | 0;\n x15 ^= u<<18 | u>>>(32-18);\n }\n x0 = x0 + j0 | 0;\n x1 = x1 + j1 | 0;\n x2 = x2 + j2 | 0;\n x3 = x3 + j3 | 0;\n x4 = x4 + j4 | 0;\n x5 = x5 + j5 | 0;\n x6 = x6 + j6 | 0;\n x7 = x7 + j7 | 0;\n x8 = x8 + j8 | 0;\n x9 = x9 + j9 | 0;\n x10 = x10 + j10 | 0;\n x11 = x11 + j11 | 0;\n x12 = x12 + j12 | 0;\n x13 = x13 + j13 | 0;\n x14 = x14 + j14 | 0;\n x15 = x15 + j15 | 0;\n\n o[ 0] = x0 >>> 0 & 0xff;\n o[ 1] = x0 >>> 8 & 0xff;\n o[ 2] = x0 >>> 16 & 0xff;\n o[ 3] = x0 >>> 24 & 0xff;\n\n o[ 4] = x1 >>> 0 & 0xff;\n o[ 5] = x1 >>> 8 & 0xff;\n o[ 6] = x1 >>> 16 & 0xff;\n o[ 7] = x1 >>> 24 & 0xff;\n\n o[ 8] = x2 >>> 0 & 0xff;\n o[ 9] = x2 >>> 8 & 0xff;\n o[10] = x2 >>> 16 & 0xff;\n o[11] = x2 >>> 24 & 0xff;\n\n o[12] = x3 >>> 0 & 0xff;\n o[13] = x3 >>> 8 & 0xff;\n o[14] = x3 >>> 16 & 0xff;\n o[15] = x3 >>> 24 & 0xff;\n\n o[16] = x4 >>> 0 & 0xff;\n o[17] = x4 >>> 8 & 0xff;\n o[18] = x4 >>> 16 & 0xff;\n o[19] = x4 >>> 24 & 0xff;\n\n o[20] = x5 >>> 0 & 0xff;\n o[21] = x5 >>> 8 & 0xff;\n o[22] = x5 >>> 16 & 0xff;\n o[23] = x5 >>> 24 & 0xff;\n\n o[24] = x6 >>> 0 & 0xff;\n o[25] = x6 >>> 8 & 0xff;\n o[26] = x6 >>> 16 & 0xff;\n o[27] = x6 >>> 24 & 0xff;\n\n o[28] = x7 >>> 0 & 0xff;\n o[29] = x7 >>> 8 & 0xff;\n o[30] = x7 >>> 16 & 0xff;\n o[31] = x7 >>> 24 & 0xff;\n\n o[32] = x8 >>> 0 & 0xff;\n o[33] = x8 >>> 8 & 0xff;\n o[34] = x8 >>> 16 & 0xff;\n o[35] = x8 >>> 24 & 0xff;\n\n o[36] = x9 >>> 0 & 0xff;\n o[37] = x9 >>> 8 & 0xff;\n o[38] = x9 >>> 16 & 0xff;\n o[39] = x9 >>> 24 & 0xff;\n\n o[40] = x10 >>> 0 & 0xff;\n o[41] = x10 >>> 8 & 0xff;\n o[42] = x10 >>> 16 & 0xff;\n o[43] = x10 >>> 24 & 0xff;\n\n o[44] = x11 >>> 0 & 0xff;\n o[45] = x11 >>> 8 & 0xff;\n o[46] = x11 >>> 16 & 0xff;\n o[47] = x11 >>> 24 & 0xff;\n\n o[48] = x12 >>> 0 & 0xff;\n o[49] = x12 >>> 8 & 0xff;\n o[50] = x12 >>> 16 & 0xff;\n o[51] = x12 >>> 24 & 0xff;\n\n o[52] = x13 >>> 0 & 0xff;\n o[53] = x13 >>> 8 & 0xff;\n o[54] = x13 >>> 16 & 0xff;\n o[55] = x13 >>> 24 & 0xff;\n\n o[56] = x14 >>> 0 & 0xff;\n o[57] = x14 >>> 8 & 0xff;\n o[58] = x14 >>> 16 & 0xff;\n o[59] = x14 >>> 24 & 0xff;\n\n o[60] = x15 >>> 0 & 0xff;\n o[61] = x15 >>> 8 & 0xff;\n o[62] = x15 >>> 16 & 0xff;\n o[63] = x15 >>> 24 & 0xff;\n}\n\nfunction core_hsalsa20(o,p,k,c) {\n var j0 = c[ 0] & 0xff | (c[ 1] & 0xff)<<8 | (c[ 2] & 0xff)<<16 | (c[ 3] & 0xff)<<24,\n j1 = k[ 0] & 0xff | (k[ 1] & 0xff)<<8 | (k[ 2] & 0xff)<<16 | (k[ 3] & 0xff)<<24,\n j2 = k[ 4] & 0xff | (k[ 5] & 0xff)<<8 | (k[ 6] & 0xff)<<16 | (k[ 7] & 0xff)<<24,\n j3 = k[ 8] & 0xff | (k[ 9] & 0xff)<<8 | (k[10] & 0xff)<<16 | (k[11] & 0xff)<<24,\n j4 = k[12] & 0xff | (k[13] & 0xff)<<8 | (k[14] & 0xff)<<16 | (k[15] & 0xff)<<24,\n j5 = c[ 4] & 0xff | (c[ 5] & 0xff)<<8 | (c[ 6] & 0xff)<<16 | (c[ 7] & 0xff)<<24,\n j6 = p[ 0] & 0xff | (p[ 1] & 0xff)<<8 | (p[ 2] & 0xff)<<16 | (p[ 3] & 0xff)<<24,\n j7 = p[ 4] & 0xff | (p[ 5] & 0xff)<<8 | (p[ 6] & 0xff)<<16 | (p[ 7] & 0xff)<<24,\n j8 = p[ 8] & 0xff | (p[ 9] & 0xff)<<8 | (p[10] & 0xff)<<16 | (p[11] & 0xff)<<24,\n j9 = p[12] & 0xff | (p[13] & 0xff)<<8 | (p[14] & 0xff)<<16 | (p[15] & 0xff)<<24,\n j10 = c[ 8] & 0xff | (c[ 9] & 0xff)<<8 | (c[10] & 0xff)<<16 | (c[11] & 0xff)<<24,\n j11 = k[16] & 0xff | (k[17] & 0xff)<<8 | (k[18] & 0xff)<<16 | (k[19] & 0xff)<<24,\n j12 = k[20] & 0xff | (k[21] & 0xff)<<8 | (k[22] & 0xff)<<16 | (k[23] & 0xff)<<24,\n j13 = k[24] & 0xff | (k[25] & 0xff)<<8 | (k[26] & 0xff)<<16 | (k[27] & 0xff)<<24,\n j14 = k[28] & 0xff | (k[29] & 0xff)<<8 | (k[30] & 0xff)<<16 | (k[31] & 0xff)<<24,\n j15 = c[12] & 0xff | (c[13] & 0xff)<<8 | (c[14] & 0xff)<<16 | (c[15] & 0xff)<<24;\n\n var x0 = j0, x1 = j1, x2 = j2, x3 = j3, x4 = j4, x5 = j5, x6 = j6, x7 = j7,\n x8 = j8, x9 = j9, x10 = j10, x11 = j11, x12 = j12, x13 = j13, x14 = j14,\n x15 = j15, u;\n\n for (var i = 0; i < 20; i += 2) {\n u = x0 + x12 | 0;\n x4 ^= u<<7 | u>>>(32-7);\n u = x4 + x0 | 0;\n x8 ^= u<<9 | u>>>(32-9);\n u = x8 + x4 | 0;\n x12 ^= u<<13 | u>>>(32-13);\n u = x12 + x8 | 0;\n x0 ^= u<<18 | u>>>(32-18);\n\n u = x5 + x1 | 0;\n x9 ^= u<<7 | u>>>(32-7);\n u = x9 + x5 | 0;\n x13 ^= u<<9 | u>>>(32-9);\n u = x13 + x9 | 0;\n x1 ^= u<<13 | u>>>(32-13);\n u = x1 + x13 | 0;\n x5 ^= u<<18 | u>>>(32-18);\n\n u = x10 + x6 | 0;\n x14 ^= u<<7 | u>>>(32-7);\n u = x14 + x10 | 0;\n x2 ^= u<<9 | u>>>(32-9);\n u = x2 + x14 | 0;\n x6 ^= u<<13 | u>>>(32-13);\n u = x6 + x2 | 0;\n x10 ^= u<<18 | u>>>(32-18);\n\n u = x15 + x11 | 0;\n x3 ^= u<<7 | u>>>(32-7);\n u = x3 + x15 | 0;\n x7 ^= u<<9 | u>>>(32-9);\n u = x7 + x3 | 0;\n x11 ^= u<<13 | u>>>(32-13);\n u = x11 + x7 | 0;\n x15 ^= u<<18 | u>>>(32-18);\n\n u = x0 + x3 | 0;\n x1 ^= u<<7 | u>>>(32-7);\n u = x1 + x0 | 0;\n x2 ^= u<<9 | u>>>(32-9);\n u = x2 + x1 | 0;\n x3 ^= u<<13 | u>>>(32-13);\n u = x3 + x2 | 0;\n x0 ^= u<<18 | u>>>(32-18);\n\n u = x5 + x4 | 0;\n x6 ^= u<<7 | u>>>(32-7);\n u = x6 + x5 | 0;\n x7 ^= u<<9 | u>>>(32-9);\n u = x7 + x6 | 0;\n x4 ^= u<<13 | u>>>(32-13);\n u = x4 + x7 | 0;\n x5 ^= u<<18 | u>>>(32-18);\n\n u = x10 + x9 | 0;\n x11 ^= u<<7 | u>>>(32-7);\n u = x11 + x10 | 0;\n x8 ^= u<<9 | u>>>(32-9);\n u = x8 + x11 | 0;\n x9 ^= u<<13 | u>>>(32-13);\n u = x9 + x8 | 0;\n x10 ^= u<<18 | u>>>(32-18);\n\n u = x15 + x14 | 0;\n x12 ^= u<<7 | u>>>(32-7);\n u = x12 + x15 | 0;\n x13 ^= u<<9 | u>>>(32-9);\n u = x13 + x12 | 0;\n x14 ^= u<<13 | u>>>(32-13);\n u = x14 + x13 | 0;\n x15 ^= u<<18 | u>>>(32-18);\n }\n\n o[ 0] = x0 >>> 0 & 0xff;\n o[ 1] = x0 >>> 8 & 0xff;\n o[ 2] = x0 >>> 16 & 0xff;\n o[ 3] = x0 >>> 24 & 0xff;\n\n o[ 4] = x5 >>> 0 & 0xff;\n o[ 5] = x5 >>> 8 & 0xff;\n o[ 6] = x5 >>> 16 & 0xff;\n o[ 7] = x5 >>> 24 & 0xff;\n\n o[ 8] = x10 >>> 0 & 0xff;\n o[ 9] = x10 >>> 8 & 0xff;\n o[10] = x10 >>> 16 & 0xff;\n o[11] = x10 >>> 24 & 0xff;\n\n o[12] = x15 >>> 0 & 0xff;\n o[13] = x15 >>> 8 & 0xff;\n o[14] = x15 >>> 16 & 0xff;\n o[15] = x15 >>> 24 & 0xff;\n\n o[16] = x6 >>> 0 & 0xff;\n o[17] = x6 >>> 8 & 0xff;\n o[18] = x6 >>> 16 & 0xff;\n o[19] = x6 >>> 24 & 0xff;\n\n o[20] = x7 >>> 0 & 0xff;\n o[21] = x7 >>> 8 & 0xff;\n o[22] = x7 >>> 16 & 0xff;\n o[23] = x7 >>> 24 & 0xff;\n\n o[24] = x8 >>> 0 & 0xff;\n o[25] = x8 >>> 8 & 0xff;\n o[26] = x8 >>> 16 & 0xff;\n o[27] = x8 >>> 24 & 0xff;\n\n o[28] = x9 >>> 0 & 0xff;\n o[29] = x9 >>> 8 & 0xff;\n o[30] = x9 >>> 16 & 0xff;\n o[31] = x9 >>> 24 & 0xff;\n}\n\nfunction crypto_core_salsa20(out,inp,k,c) {\n core_salsa20(out,inp,k,c);\n}\n\nfunction crypto_core_hsalsa20(out,inp,k,c) {\n core_hsalsa20(out,inp,k,c);\n}\n\nvar sigma = new Uint8Array([101, 120, 112, 97, 110, 100, 32, 51, 50, 45, 98, 121, 116, 101, 32, 107]);\n // \"expand 32-byte k\"\n\nfunction crypto_stream_salsa20_xor(c,cpos,m,mpos,b,n,k) {\n var z = new Uint8Array(16), x = new Uint8Array(64);\n var u, i;\n for (i = 0; i < 16; i++) z[i] = 0;\n for (i = 0; i < 8; i++) z[i] = n[i];\n while (b >= 64) {\n crypto_core_salsa20(x,z,k,sigma);\n for (i = 0; i < 64; i++) c[cpos+i] = m[mpos+i] ^ x[i];\n u = 1;\n for (i = 8; i < 16; i++) {\n u = u + (z[i] & 0xff) | 0;\n z[i] = u & 0xff;\n u >>>= 8;\n }\n b -= 64;\n cpos += 64;\n mpos += 64;\n }\n if (b > 0) {\n crypto_core_salsa20(x,z,k,sigma);\n for (i = 0; i < b; i++) c[cpos+i] = m[mpos+i] ^ x[i];\n }\n return 0;\n}\n\nfunction crypto_stream_salsa20(c,cpos,b,n,k) {\n var z = new Uint8Array(16), x = new Uint8Array(64);\n var u, i;\n for (i = 0; i < 16; i++) z[i] = 0;\n for (i = 0; i < 8; i++) z[i] = n[i];\n while (b >= 64) {\n crypto_core_salsa20(x,z,k,sigma);\n for (i = 0; i < 64; i++) c[cpos+i] = x[i];\n u = 1;\n for (i = 8; i < 16; i++) {\n u = u + (z[i] & 0xff) | 0;\n z[i] = u & 0xff;\n u >>>= 8;\n }\n b -= 64;\n cpos += 64;\n }\n if (b > 0) {\n crypto_core_salsa20(x,z,k,sigma);\n for (i = 0; i < b; i++) c[cpos+i] = x[i];\n }\n return 0;\n}\n\nfunction crypto_stream(c,cpos,d,n,k) {\n var s = new Uint8Array(32);\n crypto_core_hsalsa20(s,n,k,sigma);\n var sn = new Uint8Array(8);\n for (var i = 0; i < 8; i++) sn[i] = n[i+16];\n return crypto_stream_salsa20(c,cpos,d,sn,s);\n}\n\nfunction crypto_stream_xor(c,cpos,m,mpos,d,n,k) {\n var s = new Uint8Array(32);\n crypto_core_hsalsa20(s,n,k,sigma);\n var sn = new Uint8Array(8);\n for (var i = 0; i < 8; i++) sn[i] = n[i+16];\n return crypto_stream_salsa20_xor(c,cpos,m,mpos,d,sn,s);\n}\n\n/*\n* Port of Andrew Moon's Poly1305-donna-16. Public domain.\n* https://github.com/floodyberry/poly1305-donna\n*/\n\nvar poly1305 = function(key) {\n this.buffer = new Uint8Array(16);\n this.r = new Uint16Array(10);\n this.h = new Uint16Array(10);\n this.pad = new Uint16Array(8);\n this.leftover = 0;\n this.fin = 0;\n\n var t0, t1, t2, t3, t4, t5, t6, t7;\n\n t0 = key[ 0] & 0xff | (key[ 1] & 0xff) << 8; this.r[0] = ( t0 ) & 0x1fff;\n t1 = key[ 2] & 0xff | (key[ 3] & 0xff) << 8; this.r[1] = ((t0 >>> 13) | (t1 << 3)) & 0x1fff;\n t2 = key[ 4] & 0xff | (key[ 5] & 0xff) << 8; this.r[2] = ((t1 >>> 10) | (t2 << 6)) & 0x1f03;\n t3 = key[ 6] & 0xff | (key[ 7] & 0xff) << 8; this.r[3] = ((t2 >>> 7) | (t3 << 9)) & 0x1fff;\n t4 = key[ 8] & 0xff | (key[ 9] & 0xff) << 8; this.r[4] = ((t3 >>> 4) | (t4 << 12)) & 0x00ff;\n this.r[5] = ((t4 >>> 1)) & 0x1ffe;\n t5 = key[10] & 0xff | (key[11] & 0xff) << 8; this.r[6] = ((t4 >>> 14) | (t5 << 2)) & 0x1fff;\n t6 = key[12] & 0xff | (key[13] & 0xff) << 8; this.r[7] = ((t5 >>> 11) | (t6 << 5)) & 0x1f81;\n t7 = key[14] & 0xff | (key[15] & 0xff) << 8; this.r[8] = ((t6 >>> 8) | (t7 << 8)) & 0x1fff;\n this.r[9] = ((t7 >>> 5)) & 0x007f;\n\n this.pad[0] = key[16] & 0xff | (key[17] & 0xff) << 8;\n this.pad[1] = key[18] & 0xff | (key[19] & 0xff) << 8;\n this.pad[2] = key[20] & 0xff | (key[21] & 0xff) << 8;\n this.pad[3] = key[22] & 0xff | (key[23] & 0xff) << 8;\n this.pad[4] = key[24] & 0xff | (key[25] & 0xff) << 8;\n this.pad[5] = key[26] & 0xff | (key[27] & 0xff) << 8;\n this.pad[6] = key[28] & 0xff | (key[29] & 0xff) << 8;\n this.pad[7] = key[30] & 0xff | (key[31] & 0xff) << 8;\n};\n\npoly1305.prototype.blocks = function(m, mpos, bytes) {\n var hibit = this.fin ? 0 : (1 << 11);\n var t0, t1, t2, t3, t4, t5, t6, t7, c;\n var d0, d1, d2, d3, d4, d5, d6, d7, d8, d9;\n\n var h0 = this.h[0],\n h1 = this.h[1],\n h2 = this.h[2],\n h3 = this.h[3],\n h4 = this.h[4],\n h5 = this.h[5],\n h6 = this.h[6],\n h7 = this.h[7],\n h8 = this.h[8],\n h9 = this.h[9];\n\n var r0 = this.r[0],\n r1 = this.r[1],\n r2 = this.r[2],\n r3 = this.r[3],\n r4 = this.r[4],\n r5 = this.r[5],\n r6 = this.r[6],\n r7 = this.r[7],\n r8 = this.r[8],\n r9 = this.r[9];\n\n while (bytes >= 16) {\n t0 = m[mpos+ 0] & 0xff | (m[mpos+ 1] & 0xff) << 8; h0 += ( t0 ) & 0x1fff;\n t1 = m[mpos+ 2] & 0xff | (m[mpos+ 3] & 0xff) << 8; h1 += ((t0 >>> 13) | (t1 << 3)) & 0x1fff;\n t2 = m[mpos+ 4] & 0xff | (m[mpos+ 5] & 0xff) << 8; h2 += ((t1 >>> 10) | (t2 << 6)) & 0x1fff;\n t3 = m[mpos+ 6] & 0xff | (m[mpos+ 7] & 0xff) << 8; h3 += ((t2 >>> 7) | (t3 << 9)) & 0x1fff;\n t4 = m[mpos+ 8] & 0xff | (m[mpos+ 9] & 0xff) << 8; h4 += ((t3 >>> 4) | (t4 << 12)) & 0x1fff;\n h5 += ((t4 >>> 1)) & 0x1fff;\n t5 = m[mpos+10] & 0xff | (m[mpos+11] & 0xff) << 8; h6 += ((t4 >>> 14) | (t5 << 2)) & 0x1fff;\n t6 = m[mpos+12] & 0xff | (m[mpos+13] & 0xff) << 8; h7 += ((t5 >>> 11) | (t6 << 5)) & 0x1fff;\n t7 = m[mpos+14] & 0xff | (m[mpos+15] & 0xff) << 8; h8 += ((t6 >>> 8) | (t7 << 8)) & 0x1fff;\n h9 += ((t7 >>> 5)) | hibit;\n\n c = 0;\n\n d0 = c;\n d0 += h0 * r0;\n d0 += h1 * (5 * r9);\n d0 += h2 * (5 * r8);\n d0 += h3 * (5 * r7);\n d0 += h4 * (5 * r6);\n c = (d0 >>> 13); d0 &= 0x1fff;\n d0 += h5 * (5 * r5);\n d0 += h6 * (5 * r4);\n d0 += h7 * (5 * r3);\n d0 += h8 * (5 * r2);\n d0 += h9 * (5 * r1);\n c += (d0 >>> 13); d0 &= 0x1fff;\n\n d1 = c;\n d1 += h0 * r1;\n d1 += h1 * r0;\n d1 += h2 * (5 * r9);\n d1 += h3 * (5 * r8);\n d1 += h4 * (5 * r7);\n c = (d1 >>> 13); d1 &= 0x1fff;\n d1 += h5 * (5 * r6);\n d1 += h6 * (5 * r5);\n d1 += h7 * (5 * r4);\n d1 += h8 * (5 * r3);\n d1 += h9 * (5 * r2);\n c += (d1 >>> 13); d1 &= 0x1fff;\n\n d2 = c;\n d2 += h0 * r2;\n d2 += h1 * r1;\n d2 += h2 * r0;\n d2 += h3 * (5 * r9);\n d2 += h4 * (5 * r8);\n c = (d2 >>> 13); d2 &= 0x1fff;\n d2 += h5 * (5 * r7);\n d2 += h6 * (5 * r6);\n d2 += h7 * (5 * r5);\n d2 += h8 * (5 * r4);\n d2 += h9 * (5 * r3);\n c += (d2 >>> 13); d2 &= 0x1fff;\n\n d3 = c;\n d3 += h0 * r3;\n d3 += h1 * r2;\n d3 += h2 * r1;\n d3 += h3 * r0;\n d3 += h4 * (5 * r9);\n c = (d3 >>> 13); d3 &= 0x1fff;\n d3 += h5 * (5 * r8);\n d3 += h6 * (5 * r7);\n d3 += h7 * (5 * r6);\n d3 += h8 * (5 * r5);\n d3 += h9 * (5 * r4);\n c += (d3 >>> 13); d3 &= 0x1fff;\n\n d4 = c;\n d4 += h0 * r4;\n d4 += h1 * r3;\n d4 += h2 * r2;\n d4 += h3 * r1;\n d4 += h4 * r0;\n c = (d4 >>> 13); d4 &= 0x1fff;\n d4 += h5 * (5 * r9);\n d4 += h6 * (5 * r8);\n d4 += h7 * (5 * r7);\n d4 += h8 * (5 * r6);\n d4 += h9 * (5 * r5);\n c += (d4 >>> 13); d4 &= 0x1fff;\n\n d5 = c;\n d5 += h0 * r5;\n d5 += h1 * r4;\n d5 += h2 * r3;\n d5 += h3 * r2;\n d5 += h4 * r1;\n c = (d5 >>> 13); d5 &= 0x1fff;\n d5 += h5 * r0;\n d5 += h6 * (5 * r9);\n d5 += h7 * (5 * r8);\n d5 += h8 * (5 * r7);\n d5 += h9 * (5 * r6);\n c += (d5 >>> 13); d5 &= 0x1fff;\n\n d6 = c;\n d6 += h0 * r6;\n d6 += h1 * r5;\n d6 += h2 * r4;\n d6 += h3 * r3;\n d6 += h4 * r2;\n c = (d6 >>> 13); d6 &= 0x1fff;\n d6 += h5 * r1;\n d6 += h6 * r0;\n d6 += h7 * (5 * r9);\n d6 += h8 * (5 * r8);\n d6 += h9 * (5 * r7);\n c += (d6 >>> 13); d6 &= 0x1fff;\n\n d7 = c;\n d7 += h0 * r7;\n d7 += h1 * r6;\n d7 += h2 * r5;\n d7 += h3 * r4;\n d7 += h4 * r3;\n c = (d7 >>> 13); d7 &= 0x1fff;\n d7 += h5 * r2;\n d7 += h6 * r1;\n d7 += h7 * r0;\n d7 += h8 * (5 * r9);\n d7 += h9 * (5 * r8);\n c += (d7 >>> 13); d7 &= 0x1fff;\n\n d8 = c;\n d8 += h0 * r8;\n d8 += h1 * r7;\n d8 += h2 * r6;\n d8 += h3 * r5;\n d8 += h4 * r4;\n c = (d8 >>> 13); d8 &= 0x1fff;\n d8 += h5 * r3;\n d8 += h6 * r2;\n d8 += h7 * r1;\n d8 += h8 * r0;\n d8 += h9 * (5 * r9);\n c += (d8 >>> 13); d8 &= 0x1fff;\n\n d9 = c;\n d9 += h0 * r9;\n d9 += h1 * r8;\n d9 += h2 * r7;\n d9 += h3 * r6;\n d9 += h4 * r5;\n c = (d9 >>> 13); d9 &= 0x1fff;\n d9 += h5 * r4;\n d9 += h6 * r3;\n d9 += h7 * r2;\n d9 += h8 * r1;\n d9 += h9 * r0;\n c += (d9 >>> 13); d9 &= 0x1fff;\n\n c = (((c << 2) + c)) | 0;\n c = (c + d0) | 0;\n d0 = c & 0x1fff;\n c = (c >>> 13);\n d1 += c;\n\n h0 = d0;\n h1 = d1;\n h2 = d2;\n h3 = d3;\n h4 = d4;\n h5 = d5;\n h6 = d6;\n h7 = d7;\n h8 = d8;\n h9 = d9;\n\n mpos += 16;\n bytes -= 16;\n }\n this.h[0] = h0;\n this.h[1] = h1;\n this.h[2] = h2;\n this.h[3] = h3;\n this.h[4] = h4;\n this.h[5] = h5;\n this.h[6] = h6;\n this.h[7] = h7;\n this.h[8] = h8;\n this.h[9] = h9;\n};\n\npoly1305.prototype.finish = function(mac, macpos) {\n var g = new Uint16Array(10);\n var c, mask, f, i;\n\n if (this.leftover) {\n i = this.leftover;\n this.buffer[i++] = 1;\n for (; i < 16; i++) this.buffer[i] = 0;\n this.fin = 1;\n this.blocks(this.buffer, 0, 16);\n }\n\n c = this.h[1] >>> 13;\n this.h[1] &= 0x1fff;\n for (i = 2; i < 10; i++) {\n this.h[i] += c;\n c = this.h[i] >>> 13;\n this.h[i] &= 0x1fff;\n }\n this.h[0] += (c * 5);\n c = this.h[0] >>> 13;\n this.h[0] &= 0x1fff;\n this.h[1] += c;\n c = this.h[1] >>> 13;\n this.h[1] &= 0x1fff;\n this.h[2] += c;\n\n g[0] = this.h[0] + 5;\n c = g[0] >>> 13;\n g[0] &= 0x1fff;\n for (i = 1; i < 10; i++) {\n g[i] = this.h[i] + c;\n c = g[i] >>> 13;\n g[i] &= 0x1fff;\n }\n g[9] -= (1 << 13);\n\n mask = (c ^ 1) - 1;\n for (i = 0; i < 10; i++) g[i] &= mask;\n mask = ~mask;\n for (i = 0; i < 10; i++) this.h[i] = (this.h[i] & mask) | g[i];\n\n this.h[0] = ((this.h[0] ) | (this.h[1] << 13) ) & 0xffff;\n this.h[1] = ((this.h[1] >>> 3) | (this.h[2] << 10) ) & 0xffff;\n this.h[2] = ((this.h[2] >>> 6) | (this.h[3] << 7) ) & 0xffff;\n this.h[3] = ((this.h[3] >>> 9) | (this.h[4] << 4) ) & 0xffff;\n this.h[4] = ((this.h[4] >>> 12) | (this.h[5] << 1) | (this.h[6] << 14)) & 0xffff;\n this.h[5] = ((this.h[6] >>> 2) | (this.h[7] << 11) ) & 0xffff;\n this.h[6] = ((this.h[7] >>> 5) | (this.h[8] << 8) ) & 0xffff;\n this.h[7] = ((this.h[8] >>> 8) | (this.h[9] << 5) ) & 0xffff;\n\n f = this.h[0] + this.pad[0];\n this.h[0] = f & 0xffff;\n for (i = 1; i < 8; i++) {\n f = (((this.h[i] + this.pad[i]) | 0) + (f >>> 16)) | 0;\n this.h[i] = f & 0xffff;\n }\n\n mac[macpos+ 0] = (this.h[0] >>> 0) & 0xff;\n mac[macpos+ 1] = (this.h[0] >>> 8) & 0xff;\n mac[macpos+ 2] = (this.h[1] >>> 0) & 0xff;\n mac[macpos+ 3] = (this.h[1] >>> 8) & 0xff;\n mac[macpos+ 4] = (this.h[2] >>> 0) & 0xff;\n mac[macpos+ 5] = (this.h[2] >>> 8) & 0xff;\n mac[macpos+ 6] = (this.h[3] >>> 0) & 0xff;\n mac[macpos+ 7] = (this.h[3] >>> 8) & 0xff;\n mac[macpos+ 8] = (this.h[4] >>> 0) & 0xff;\n mac[macpos+ 9] = (this.h[4] >>> 8) & 0xff;\n mac[macpos+10] = (this.h[5] >>> 0) & 0xff;\n mac[macpos+11] = (this.h[5] >>> 8) & 0xff;\n mac[macpos+12] = (this.h[6] >>> 0) & 0xff;\n mac[macpos+13] = (this.h[6] >>> 8) & 0xff;\n mac[macpos+14] = (this.h[7] >>> 0) & 0xff;\n mac[macpos+15] = (this.h[7] >>> 8) & 0xff;\n};\n\npoly1305.prototype.update = function(m, mpos, bytes) {\n var i, want;\n\n if (this.leftover) {\n want = (16 - this.leftover);\n if (want > bytes)\n want = bytes;\n for (i = 0; i < want; i++)\n this.buffer[this.leftover + i] = m[mpos+i];\n bytes -= want;\n mpos += want;\n this.leftover += want;\n if (this.leftover < 16)\n return;\n this.blocks(this.buffer, 0, 16);\n this.leftover = 0;\n }\n\n if (bytes >= 16) {\n want = bytes - (bytes % 16);\n this.blocks(m, mpos, want);\n mpos += want;\n bytes -= want;\n }\n\n if (bytes) {\n for (i = 0; i < bytes; i++)\n this.buffer[this.leftover + i] = m[mpos+i];\n this.leftover += bytes;\n }\n};\n\nfunction crypto_onetimeauth(out, outpos, m, mpos, n, k) {\n var s = new poly1305(k);\n s.update(m, mpos, n);\n s.finish(out, outpos);\n return 0;\n}\n\nfunction crypto_onetimeauth_verify(h, hpos, m, mpos, n, k) {\n var x = new Uint8Array(16);\n crypto_onetimeauth(x,0,m,mpos,n,k);\n return crypto_verify_16(h,hpos,x,0);\n}\n\nfunction crypto_secretbox(c,m,d,n,k) {\n var i;\n if (d < 32) return -1;\n crypto_stream_xor(c,0,m,0,d,n,k);\n crypto_onetimeauth(c, 16, c, 32, d - 32, c);\n for (i = 0; i < 16; i++) c[i] = 0;\n return 0;\n}\n\nfunction crypto_secretbox_open(m,c,d,n,k) {\n var i;\n var x = new Uint8Array(32);\n if (d < 32) return -1;\n crypto_stream(x,0,32,n,k);\n if (crypto_onetimeauth_verify(c, 16,c, 32,d - 32,x) !== 0) return -1;\n crypto_stream_xor(m,0,c,0,d,n,k);\n for (i = 0; i < 32; i++) m[i] = 0;\n return 0;\n}\n\nfunction set25519(r, a) {\n var i;\n for (i = 0; i < 16; i++) r[i] = a[i]|0;\n}\n\nfunction car25519(o) {\n var i, v, c = 1;\n for (i = 0; i < 16; i++) {\n v = o[i] + c + 65535;\n c = Math.floor(v / 65536);\n o[i] = v - c * 65536;\n }\n o[0] += c-1 + 37 * (c-1);\n}\n\nfunction sel25519(p, q, b) {\n var t, c = ~(b-1);\n for (var i = 0; i < 16; i++) {\n t = c & (p[i] ^ q[i]);\n p[i] ^= t;\n q[i] ^= t;\n }\n}\n\nfunction pack25519(o, n) {\n var i, j, b;\n var m = gf(), t = gf();\n for (i = 0; i < 16; i++) t[i] = n[i];\n car25519(t);\n car25519(t);\n car25519(t);\n for (j = 0; j < 2; j++) {\n m[0] = t[0] - 0xffed;\n for (i = 1; i < 15; i++) {\n m[i] = t[i] - 0xffff - ((m[i-1]>>16) & 1);\n m[i-1] &= 0xffff;\n }\n m[15] = t[15] - 0x7fff - ((m[14]>>16) & 1);\n b = (m[15]>>16) & 1;\n m[14] &= 0xffff;\n sel25519(t, m, 1-b);\n }\n for (i = 0; i < 16; i++) {\n o[2*i] = t[i] & 0xff;\n o[2*i+1] = t[i]>>8;\n }\n}\n\nfunction neq25519(a, b) {\n var c = new Uint8Array(32), d = new Uint8Array(32);\n pack25519(c, a);\n pack25519(d, b);\n return crypto_verify_32(c, 0, d, 0);\n}\n\nfunction par25519(a) {\n var d = new Uint8Array(32);\n pack25519(d, a);\n return d[0] & 1;\n}\n\nfunction unpack25519(o, n) {\n var i;\n for (i = 0; i < 16; i++) o[i] = n[2*i] + (n[2*i+1] << 8);\n o[15] &= 0x7fff;\n}\n\nfunction A(o, a, b) {\n for (var i = 0; i < 16; i++) o[i] = a[i] + b[i];\n}\n\nfunction Z(o, a, b) {\n for (var i = 0; i < 16; i++) o[i] = a[i] - b[i];\n}\n\nfunction M(o, a, b) {\n var v, c,\n t0 = 0, t1 = 0, t2 = 0, t3 = 0, t4 = 0, t5 = 0, t6 = 0, t7 = 0,\n t8 = 0, t9 = 0, t10 = 0, t11 = 0, t12 = 0, t13 = 0, t14 = 0, t15 = 0,\n t16 = 0, t17 = 0, t18 = 0, t19 = 0, t20 = 0, t21 = 0, t22 = 0, t23 = 0,\n t24 = 0, t25 = 0, t26 = 0, t27 = 0, t28 = 0, t29 = 0, t30 = 0,\n b0 = b[0],\n b1 = b[1],\n b2 = b[2],\n b3 = b[3],\n b4 = b[4],\n b5 = b[5],\n b6 = b[6],\n b7 = b[7],\n b8 = b[8],\n b9 = b[9],\n b10 = b[10],\n b11 = b[11],\n b12 = b[12],\n b13 = b[13],\n b14 = b[14],\n b15 = b[15];\n\n v = a[0];\n t0 += v * b0;\n t1 += v * b1;\n t2 += v * b2;\n t3 += v * b3;\n t4 += v * b4;\n t5 += v * b5;\n t6 += v * b6;\n t7 += v * b7;\n t8 += v * b8;\n t9 += v * b9;\n t10 += v * b10;\n t11 += v * b11;\n t12 += v * b12;\n t13 += v * b13;\n t14 += v * b14;\n t15 += v * b15;\n v = a[1];\n t1 += v * b0;\n t2 += v * b1;\n t3 += v * b2;\n t4 += v * b3;\n t5 += v * b4;\n t6 += v * b5;\n t7 += v * b6;\n t8 += v * b7;\n t9 += v * b8;\n t10 += v * b9;\n t11 += v * b10;\n t12 += v * b11;\n t13 += v * b12;\n t14 += v * b13;\n t15 += v * b14;\n t16 += v * b15;\n v = a[2];\n t2 += v * b0;\n t3 += v * b1;\n t4 += v * b2;\n t5 += v * b3;\n t6 += v * b4;\n t7 += v * b5;\n t8 += v * b6;\n t9 += v * b7;\n t10 += v * b8;\n t11 += v * b9;\n t12 += v * b10;\n t13 += v * b11;\n t14 += v * b12;\n t15 += v * b13;\n t16 += v * b14;\n t17 += v * b15;\n v = a[3];\n t3 += v * b0;\n t4 += v * b1;\n t5 += v * b2;\n t6 += v * b3;\n t7 += v * b4;\n t8 += v * b5;\n t9 += v * b6;\n t10 += v * b7;\n t11 += v * b8;\n t12 += v * b9;\n t13 += v * b10;\n t14 += v * b11;\n t15 += v * b12;\n t16 += v * b13;\n t17 += v * b14;\n t18 += v * b15;\n v = a[4];\n t4 += v * b0;\n t5 += v * b1;\n t6 += v * b2;\n t7 += v * b3;\n t8 += v * b4;\n t9 += v * b5;\n t10 += v * b6;\n t11 += v * b7;\n t12 += v * b8;\n t13 += v * b9;\n t14 += v * b10;\n t15 += v * b11;\n t16 += v * b12;\n t17 += v * b13;\n t18 += v * b14;\n t19 += v * b15;\n v = a[5];\n t5 += v * b0;\n t6 += v * b1;\n t7 += v * b2;\n t8 += v * b3;\n t9 += v * b4;\n t10 += v * b5;\n t11 += v * b6;\n t12 += v * b7;\n t13 += v * b8;\n t14 += v * b9;\n t15 += v * b10;\n t16 += v * b11;\n t17 += v * b12;\n t18 += v * b13;\n t19 += v * b14;\n t20 += v * b15;\n v = a[6];\n t6 += v * b0;\n t7 += v * b1;\n t8 += v * b2;\n t9 += v * b3;\n t10 += v * b4;\n t11 += v * b5;\n t12 += v * b6;\n t13 += v * b7;\n t14 += v * b8;\n t15 += v * b9;\n t16 += v * b10;\n t17 += v * b11;\n t18 += v * b12;\n t19 += v * b13;\n t20 += v * b14;\n t21 += v * b15;\n v = a[7];\n t7 += v * b0;\n t8 += v * b1;\n t9 += v * b2;\n t10 += v * b3;\n t11 += v * b4;\n t12 += v * b5;\n t13 += v * b6;\n t14 += v * b7;\n t15 += v * b8;\n t16 += v * b9;\n t17 += v * b10;\n t18 += v * b11;\n t19 += v * b12;\n t20 += v * b13;\n t21 += v * b14;\n t22 += v * b15;\n v = a[8];\n t8 += v * b0;\n t9 += v * b1;\n t10 += v * b2;\n t11 += v * b3;\n t12 += v * b4;\n t13 += v * b5;\n t14 += v * b6;\n t15 += v * b7;\n t16 += v * b8;\n t17 += v * b9;\n t18 += v * b10;\n t19 += v * b11;\n t20 += v * b12;\n t21 += v * b13;\n t22 += v * b14;\n t23 += v * b15;\n v = a[9];\n t9 += v * b0;\n t10 += v * b1;\n t11 += v * b2;\n t12 += v * b3;\n t13 += v * b4;\n t14 += v * b5;\n t15 += v * b6;\n t16 += v * b7;\n t17 += v * b8;\n t18 += v * b9;\n t19 += v * b10;\n t20 += v * b11;\n t21 += v * b12;\n t22 += v * b13;\n t23 += v * b14;\n t24 += v * b15;\n v = a[10];\n t10 += v * b0;\n t11 += v * b1;\n t12 += v * b2;\n t13 += v * b3;\n t14 += v * b4;\n t15 += v * b5;\n t16 += v * b6;\n t17 += v * b7;\n t18 += v * b8;\n t19 += v * b9;\n t20 += v * b10;\n t21 += v * b11;\n t22 += v * b12;\n t23 += v * b13;\n t24 += v * b14;\n t25 += v * b15;\n v = a[11];\n t11 += v * b0;\n t12 += v * b1;\n t13 += v * b2;\n t14 += v * b3;\n t15 += v * b4;\n t16 += v * b5;\n t17 += v * b6;\n t18 += v * b7;\n t19 += v * b8;\n t20 += v * b9;\n t21 += v * b10;\n t22 += v * b11;\n t23 += v * b12;\n t24 += v * b13;\n t25 += v * b14;\n t26 += v * b15;\n v = a[12];\n t12 += v * b0;\n t13 += v * b1;\n t14 += v * b2;\n t15 += v * b3;\n t16 += v * b4;\n t17 += v * b5;\n t18 += v * b6;\n t19 += v * b7;\n t20 += v * b8;\n t21 += v * b9;\n t22 += v * b10;\n t23 += v * b11;\n t24 += v * b12;\n t25 += v * b13;\n t26 += v * b14;\n t27 += v * b15;\n v = a[13];\n t13 += v * b0;\n t14 += v * b1;\n t15 += v * b2;\n t16 += v * b3;\n t17 += v * b4;\n t18 += v * b5;\n t19 += v * b6;\n t20 += v * b7;\n t21 += v * b8;\n t22 += v * b9;\n t23 += v * b10;\n t24 += v * b11;\n t25 += v * b12;\n t26 += v * b13;\n t27 += v * b14;\n t28 += v * b15;\n v = a[14];\n t14 += v * b0;\n t15 += v * b1;\n t16 += v * b2;\n t17 += v * b3;\n t18 += v * b4;\n t19 += v * b5;\n t20 += v * b6;\n t21 += v * b7;\n t22 += v * b8;\n t23 += v * b9;\n t24 += v * b10;\n t25 += v * b11;\n t26 += v * b12;\n t27 += v * b13;\n t28 += v * b14;\n t29 += v * b15;\n v = a[15];\n t15 += v * b0;\n t16 += v * b1;\n t17 += v * b2;\n t18 += v * b3;\n t19 += v * b4;\n t20 += v * b5;\n t21 += v * b6;\n t22 += v * b7;\n t23 += v * b8;\n t24 += v * b9;\n t25 += v * b10;\n t26 += v * b11;\n t27 += v * b12;\n t28 += v * b13;\n t29 += v * b14;\n t30 += v * b15;\n\n t0 += 38 * t16;\n t1 += 38 * t17;\n t2 += 38 * t18;\n t3 += 38 * t19;\n t4 += 38 * t20;\n t5 += 38 * t21;\n t6 += 38 * t22;\n t7 += 38 * t23;\n t8 += 38 * t24;\n t9 += 38 * t25;\n t10 += 38 * t26;\n t11 += 38 * t27;\n t12 += 38 * t28;\n t13 += 38 * t29;\n t14 += 38 * t30;\n // t15 left as is\n\n // first car\n c = 1;\n v = t0 + c + 65535; c = Math.floor(v / 65536); t0 = v - c * 65536;\n v = t1 + c + 65535; c = Math.floor(v / 65536); t1 = v - c * 65536;\n v = t2 + c + 65535; c = Math.floor(v / 65536); t2 = v - c * 65536;\n v = t3 + c + 65535; c = Math.floor(v / 65536); t3 = v - c * 65536;\n v = t4 + c + 65535; c = Math.floor(v / 65536); t4 = v - c * 65536;\n v = t5 + c + 65535; c = Math.floor(v / 65536); t5 = v - c * 65536;\n v = t6 + c + 65535; c = Math.floor(v / 65536); t6 = v - c * 65536;\n v = t7 + c + 65535; c = Math.floor(v / 65536); t7 = v - c * 65536;\n v = t8 + c + 65535; c = Math.floor(v / 65536); t8 = v - c * 65536;\n v = t9 + c + 65535; c = Math.floor(v / 65536); t9 = v - c * 65536;\n v = t10 + c + 65535; c = Math.floor(v / 65536); t10 = v - c * 65536;\n v = t11 + c + 65535; c = Math.floor(v / 65536); t11 = v - c * 65536;\n v = t12 + c + 65535; c = Math.floor(v / 65536); t12 = v - c * 65536;\n v = t13 + c + 65535; c = Math.floor(v / 65536); t13 = v - c * 65536;\n v = t14 + c + 65535; c = Math.floor(v / 65536); t14 = v - c * 65536;\n v = t15 + c + 65535; c = Math.floor(v / 65536); t15 = v - c * 65536;\n t0 += c-1 + 37 * (c-1);\n\n // second car\n c = 1;\n v = t0 + c + 65535; c = Math.floor(v / 65536); t0 = v - c * 65536;\n v = t1 + c + 65535; c = Math.floor(v / 65536); t1 = v - c * 65536;\n v = t2 + c + 65535; c = Math.floor(v / 65536); t2 = v - c * 65536;\n v = t3 + c + 65535; c = Math.floor(v / 65536); t3 = v - c * 65536;\n v = t4 + c + 65535; c = Math.floor(v / 65536); t4 = v - c * 65536;\n v = t5 + c + 65535; c = Math.floor(v / 65536); t5 = v - c * 65536;\n v = t6 + c + 65535; c = Math.floor(v / 65536); t6 = v - c * 65536;\n v = t7 + c + 65535; c = Math.floor(v / 65536); t7 = v - c * 65536;\n v = t8 + c + 65535; c = Math.floor(v / 65536); t8 = v - c * 65536;\n v = t9 + c + 65535; c = Math.floor(v / 65536); t9 = v - c * 65536;\n v = t10 + c + 65535; c = Math.floor(v / 65536); t10 = v - c * 65536;\n v = t11 + c + 65535; c = Math.floor(v / 65536); t11 = v - c * 65536;\n v = t12 + c + 65535; c = Math.floor(v / 65536); t12 = v - c * 65536;\n v = t13 + c + 65535; c = Math.floor(v / 65536); t13 = v - c * 65536;\n v = t14 + c + 65535; c = Math.floor(v / 65536); t14 = v - c * 65536;\n v = t15 + c + 65535; c = Math.floor(v / 65536); t15 = v - c * 65536;\n t0 += c-1 + 37 * (c-1);\n\n o[ 0] = t0;\n o[ 1] = t1;\n o[ 2] = t2;\n o[ 3] = t3;\n o[ 4] = t4;\n o[ 5] = t5;\n o[ 6] = t6;\n o[ 7] = t7;\n o[ 8] = t8;\n o[ 9] = t9;\n o[10] = t10;\n o[11] = t11;\n o[12] = t12;\n o[13] = t13;\n o[14] = t14;\n o[15] = t15;\n}\n\nfunction S(o, a) {\n M(o, a, a);\n}\n\nfunction inv25519(o, i) {\n var c = gf();\n var a;\n for (a = 0; a < 16; a++) c[a] = i[a];\n for (a = 253; a >= 0; a--) {\n S(c, c);\n if(a !== 2 && a !== 4) M(c, c, i);\n }\n for (a = 0; a < 16; a++) o[a] = c[a];\n}\n\nfunction pow2523(o, i) {\n var c = gf();\n var a;\n for (a = 0; a < 16; a++) c[a] = i[a];\n for (a = 250; a >= 0; a--) {\n S(c, c);\n if(a !== 1) M(c, c, i);\n }\n for (a = 0; a < 16; a++) o[a] = c[a];\n}\n\nfunction crypto_scalarmult(q, n, p) {\n var z = new Uint8Array(32);\n var x = new Float64Array(80), r, i;\n var a = gf(), b = gf(), c = gf(),\n d = gf(), e = gf(), f = gf();\n for (i = 0; i < 31; i++) z[i] = n[i];\n z[31]=(n[31]&127)|64;\n z[0]&=248;\n unpack25519(x,p);\n for (i = 0; i < 16; i++) {\n b[i]=x[i];\n d[i]=a[i]=c[i]=0;\n }\n a[0]=d[0]=1;\n for (i=254; i>=0; --i) {\n r=(z[i>>>3]>>>(i&7))&1;\n sel25519(a,b,r);\n sel25519(c,d,r);\n A(e,a,c);\n Z(a,a,c);\n A(c,b,d);\n Z(b,b,d);\n S(d,e);\n S(f,a);\n M(a,c,a);\n M(c,b,e);\n A(e,a,c);\n Z(a,a,c);\n S(b,a);\n Z(c,d,f);\n M(a,c,_121665);\n A(a,a,d);\n M(c,c,a);\n M(a,d,f);\n M(d,b,x);\n S(b,e);\n sel25519(a,b,r);\n sel25519(c,d,r);\n }\n for (i = 0; i < 16; i++) {\n x[i+16]=a[i];\n x[i+32]=c[i];\n x[i+48]=b[i];\n x[i+64]=d[i];\n }\n var x32 = x.subarray(32);\n var x16 = x.subarray(16);\n inv25519(x32,x32);\n M(x16,x16,x32);\n pack25519(q,x16);\n return 0;\n}\n\nfunction crypto_scalarmult_base(q, n) {\n return crypto_scalarmult(q, n, _9);\n}\n\nfunction crypto_box_keypair(y, x) {\n randombytes(x, 32);\n return crypto_scalarmult_base(y, x);\n}\n\nfunction crypto_box_beforenm(k, y, x) {\n var s = new Uint8Array(32);\n crypto_scalarmult(s, x, y);\n return crypto_core_hsalsa20(k, _0, s, sigma);\n}\n\nvar crypto_box_afternm = crypto_secretbox;\nvar crypto_box_open_afternm = crypto_secretbox_open;\n\nfunction crypto_box(c, m, d, n, y, x) {\n var k = new Uint8Array(32);\n crypto_box_beforenm(k, y, x);\n return crypto_box_afternm(c, m, d, n, k);\n}\n\nfunction crypto_box_open(m, c, d, n, y, x) {\n var k = new Uint8Array(32);\n crypto_box_beforenm(k, y, x);\n return crypto_box_open_afternm(m, c, d, n, k);\n}\n\nvar K = [\n 0x428a2f98, 0xd728ae22, 0x71374491, 0x23ef65cd,\n 0xb5c0fbcf, 0xec4d3b2f, 0xe9b5dba5, 0x8189dbbc,\n 0x3956c25b, 0xf348b538, 0x59f111f1, 0xb605d019,\n 0x923f82a4, 0xaf194f9b, 0xab1c5ed5, 0xda6d8118,\n 0xd807aa98, 0xa3030242, 0x12835b01, 0x45706fbe,\n 0x243185be, 0x4ee4b28c, 0x550c7dc3, 0xd5ffb4e2,\n 0x72be5d74, 0xf27b896f, 0x80deb1fe, 0x3b1696b1,\n 0x9bdc06a7, 0x25c71235, 0xc19bf174, 0xcf692694,\n 0xe49b69c1, 0x9ef14ad2, 0xefbe4786, 0x384f25e3,\n 0x0fc19dc6, 0x8b8cd5b5, 0x240ca1cc, 0x77ac9c65,\n 0x2de92c6f, 0x592b0275, 0x4a7484aa, 0x6ea6e483,\n 0x5cb0a9dc, 0xbd41fbd4, 0x76f988da, 0x831153b5,\n 0x983e5152, 0xee66dfab, 0xa831c66d, 0x2db43210,\n 0xb00327c8, 0x98fb213f, 0xbf597fc7, 0xbeef0ee4,\n 0xc6e00bf3, 0x3da88fc2, 0xd5a79147, 0x930aa725,\n 0x06ca6351, 0xe003826f, 0x14292967, 0x0a0e6e70,\n 0x27b70a85, 0x46d22ffc, 0x2e1b2138, 0x5c26c926,\n 0x4d2c6dfc, 0x5ac42aed, 0x53380d13, 0x9d95b3df,\n 0x650a7354, 0x8baf63de, 0x766a0abb, 0x3c77b2a8,\n 0x81c2c92e, 0x47edaee6, 0x92722c85, 0x1482353b,\n 0xa2bfe8a1, 0x4cf10364, 0xa81a664b, 0xbc423001,\n 0xc24b8b70, 0xd0f89791, 0xc76c51a3, 0x0654be30,\n 0xd192e819, 0xd6ef5218, 0xd6990624, 0x5565a910,\n 0xf40e3585, 0x5771202a, 0x106aa070, 0x32bbd1b8,\n 0x19a4c116, 0xb8d2d0c8, 0x1e376c08, 0x5141ab53,\n 0x2748774c, 0xdf8eeb99, 0x34b0bcb5, 0xe19b48a8,\n 0x391c0cb3, 0xc5c95a63, 0x4ed8aa4a, 0xe3418acb,\n 0x5b9cca4f, 0x7763e373, 0x682e6ff3, 0xd6b2b8a3,\n 0x748f82ee, 0x5defb2fc, 0x78a5636f, 0x43172f60,\n 0x84c87814, 0xa1f0ab72, 0x8cc70208, 0x1a6439ec,\n 0x90befffa, 0x23631e28, 0xa4506ceb, 0xde82bde9,\n 0xbef9a3f7, 0xb2c67915, 0xc67178f2, 0xe372532b,\n 0xca273ece, 0xea26619c, 0xd186b8c7, 0x21c0c207,\n 0xeada7dd6, 0xcde0eb1e, 0xf57d4f7f, 0xee6ed178,\n 0x06f067aa, 0x72176fba, 0x0a637dc5, 0xa2c898a6,\n 0x113f9804, 0xbef90dae, 0x1b710b35, 0x131c471b,\n 0x28db77f5, 0x23047d84, 0x32caab7b, 0x40c72493,\n 0x3c9ebe0a, 0x15c9bebc, 0x431d67c4, 0x9c100d4c,\n 0x4cc5d4be, 0xcb3e42b6, 0x597f299c, 0xfc657e2a,\n 0x5fcb6fab, 0x3ad6faec, 0x6c44198c, 0x4a475817\n];\n\nfunction crypto_hashblocks_hl(hh, hl, m, n) {\n var wh = new Int32Array(16), wl = new Int32Array(16),\n bh0, bh1, bh2, bh3, bh4, bh5, bh6, bh7,\n bl0, bl1, bl2, bl3, bl4, bl5, bl6, bl7,\n th, tl, i, j, h, l, a, b, c, d;\n\n var ah0 = hh[0],\n ah1 = hh[1],\n ah2 = hh[2],\n ah3 = hh[3],\n ah4 = hh[4],\n ah5 = hh[5],\n ah6 = hh[6],\n ah7 = hh[7],\n\n al0 = hl[0],\n al1 = hl[1],\n al2 = hl[2],\n al3 = hl[3],\n al4 = hl[4],\n al5 = hl[5],\n al6 = hl[6],\n al7 = hl[7];\n\n var pos = 0;\n while (n >= 128) {\n for (i = 0; i < 16; i++) {\n j = 8 * i + pos;\n wh[i] = (m[j+0] << 24) | (m[j+1] << 16) | (m[j+2] << 8) | m[j+3];\n wl[i] = (m[j+4] << 24) | (m[j+5] << 16) | (m[j+6] << 8) | m[j+7];\n }\n for (i = 0; i < 80; i++) {\n bh0 = ah0;\n bh1 = ah1;\n bh2 = ah2;\n bh3 = ah3;\n bh4 = ah4;\n bh5 = ah5;\n bh6 = ah6;\n bh7 = ah7;\n\n bl0 = al0;\n bl1 = al1;\n bl2 = al2;\n bl3 = al3;\n bl4 = al4;\n bl5 = al5;\n bl6 = al6;\n bl7 = al7;\n\n // add\n h = ah7;\n l = al7;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n // Sigma1\n h = ((ah4 >>> 14) | (al4 << (32-14))) ^ ((ah4 >>> 18) | (al4 << (32-18))) ^ ((al4 >>> (41-32)) | (ah4 << (32-(41-32))));\n l = ((al4 >>> 14) | (ah4 << (32-14))) ^ ((al4 >>> 18) | (ah4 << (32-18))) ^ ((ah4 >>> (41-32)) | (al4 << (32-(41-32))));\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // Ch\n h = (ah4 & ah5) ^ (~ah4 & ah6);\n l = (al4 & al5) ^ (~al4 & al6);\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // K\n h = K[i*2];\n l = K[i*2+1];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // w\n h = wh[i%16];\n l = wl[i%16];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n th = c & 0xffff | d << 16;\n tl = a & 0xffff | b << 16;\n\n // add\n h = th;\n l = tl;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n // Sigma0\n h = ((ah0 >>> 28) | (al0 << (32-28))) ^ ((al0 >>> (34-32)) | (ah0 << (32-(34-32)))) ^ ((al0 >>> (39-32)) | (ah0 << (32-(39-32))));\n l = ((al0 >>> 28) | (ah0 << (32-28))) ^ ((ah0 >>> (34-32)) | (al0 << (32-(34-32)))) ^ ((ah0 >>> (39-32)) | (al0 << (32-(39-32))));\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // Maj\n h = (ah0 & ah1) ^ (ah0 & ah2) ^ (ah1 & ah2);\n l = (al0 & al1) ^ (al0 & al2) ^ (al1 & al2);\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n bh7 = (c & 0xffff) | (d << 16);\n bl7 = (a & 0xffff) | (b << 16);\n\n // add\n h = bh3;\n l = bl3;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = th;\n l = tl;\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n bh3 = (c & 0xffff) | (d << 16);\n bl3 = (a & 0xffff) | (b << 16);\n\n ah1 = bh0;\n ah2 = bh1;\n ah3 = bh2;\n ah4 = bh3;\n ah5 = bh4;\n ah6 = bh5;\n ah7 = bh6;\n ah0 = bh7;\n\n al1 = bl0;\n al2 = bl1;\n al3 = bl2;\n al4 = bl3;\n al5 = bl4;\n al6 = bl5;\n al7 = bl6;\n al0 = bl7;\n\n if (i%16 === 15) {\n for (j = 0; j < 16; j++) {\n // add\n h = wh[j];\n l = wl[j];\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = wh[(j+9)%16];\n l = wl[(j+9)%16];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // sigma0\n th = wh[(j+1)%16];\n tl = wl[(j+1)%16];\n h = ((th >>> 1) | (tl << (32-1))) ^ ((th >>> 8) | (tl << (32-8))) ^ (th >>> 7);\n l = ((tl >>> 1) | (th << (32-1))) ^ ((tl >>> 8) | (th << (32-8))) ^ ((tl >>> 7) | (th << (32-7)));\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // sigma1\n th = wh[(j+14)%16];\n tl = wl[(j+14)%16];\n h = ((th >>> 19) | (tl << (32-19))) ^ ((tl >>> (61-32)) | (th << (32-(61-32)))) ^ (th >>> 6);\n l = ((tl >>> 19) | (th << (32-19))) ^ ((th >>> (61-32)) | (tl << (32-(61-32)))) ^ ((tl >>> 6) | (th << (32-6)));\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n wh[j] = (c & 0xffff) | (d << 16);\n wl[j] = (a & 0xffff) | (b << 16);\n }\n }\n }\n\n // add\n h = ah0;\n l = al0;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[0];\n l = hl[0];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[0] = ah0 = (c & 0xffff) | (d << 16);\n hl[0] = al0 = (a & 0xffff) | (b << 16);\n\n h = ah1;\n l = al1;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[1];\n l = hl[1];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[1] = ah1 = (c & 0xffff) | (d << 16);\n hl[1] = al1 = (a & 0xffff) | (b << 16);\n\n h = ah2;\n l = al2;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[2];\n l = hl[2];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[2] = ah2 = (c & 0xffff) | (d << 16);\n hl[2] = al2 = (a & 0xffff) | (b << 16);\n\n h = ah3;\n l = al3;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[3];\n l = hl[3];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[3] = ah3 = (c & 0xffff) | (d << 16);\n hl[3] = al3 = (a & 0xffff) | (b << 16);\n\n h = ah4;\n l = al4;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[4];\n l = hl[4];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[4] = ah4 = (c & 0xffff) | (d << 16);\n hl[4] = al4 = (a & 0xffff) | (b << 16);\n\n h = ah5;\n l = al5;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[5];\n l = hl[5];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[5] = ah5 = (c & 0xffff) | (d << 16);\n hl[5] = al5 = (a & 0xffff) | (b << 16);\n\n h = ah6;\n l = al6;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[6];\n l = hl[6];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[6] = ah6 = (c & 0xffff) | (d << 16);\n hl[6] = al6 = (a & 0xffff) | (b << 16);\n\n h = ah7;\n l = al7;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[7];\n l = hl[7];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[7] = ah7 = (c & 0xffff) | (d << 16);\n hl[7] = al7 = (a & 0xffff) | (b << 16);\n\n pos += 128;\n n -= 128;\n }\n\n return n;\n}\n\nfunction crypto_hash(out, m, n) {\n var hh = new Int32Array(8),\n hl = new Int32Array(8),\n x = new Uint8Array(256),\n i, b = n;\n\n hh[0] = 0x6a09e667;\n hh[1] = 0xbb67ae85;\n hh[2] = 0x3c6ef372;\n hh[3] = 0xa54ff53a;\n hh[4] = 0x510e527f;\n hh[5] = 0x9b05688c;\n hh[6] = 0x1f83d9ab;\n hh[7] = 0x5be0cd19;\n\n hl[0] = 0xf3bcc908;\n hl[1] = 0x84caa73b;\n hl[2] = 0xfe94f82b;\n hl[3] = 0x5f1d36f1;\n hl[4] = 0xade682d1;\n hl[5] = 0x2b3e6c1f;\n hl[6] = 0xfb41bd6b;\n hl[7] = 0x137e2179;\n\n crypto_hashblocks_hl(hh, hl, m, n);\n n %= 128;\n\n for (i = 0; i < n; i++) x[i] = m[b-n+i];\n x[n] = 128;\n\n n = 256-128*(n<112?1:0);\n x[n-9] = 0;\n ts64(x, n-8, (b / 0x20000000) | 0, b << 3);\n crypto_hashblocks_hl(hh, hl, x, n);\n\n for (i = 0; i < 8; i++) ts64(out, 8*i, hh[i], hl[i]);\n\n return 0;\n}\n\nfunction add(p, q) {\n var a = gf(), b = gf(), c = gf(),\n d = gf(), e = gf(), f = gf(),\n g = gf(), h = gf(), t = gf();\n\n Z(a, p[1], p[0]);\n Z(t, q[1], q[0]);\n M(a, a, t);\n A(b, p[0], p[1]);\n A(t, q[0], q[1]);\n M(b, b, t);\n M(c, p[3], q[3]);\n M(c, c, D2);\n M(d, p[2], q[2]);\n A(d, d, d);\n Z(e, b, a);\n Z(f, d, c);\n A(g, d, c);\n A(h, b, a);\n\n M(p[0], e, f);\n M(p[1], h, g);\n M(p[2], g, f);\n M(p[3], e, h);\n}\n\nfunction cswap(p, q, b) {\n var i;\n for (i = 0; i < 4; i++) {\n sel25519(p[i], q[i], b);\n }\n}\n\nfunction pack(r, p) {\n var tx = gf(), ty = gf(), zi = gf();\n inv25519(zi, p[2]);\n M(tx, p[0], zi);\n M(ty, p[1], zi);\n pack25519(r, ty);\n r[31] ^= par25519(tx) << 7;\n}\n\nfunction scalarmult(p, q, s) {\n var b, i;\n set25519(p[0], gf0);\n set25519(p[1], gf1);\n set25519(p[2], gf1);\n set25519(p[3], gf0);\n for (i = 255; i >= 0; --i) {\n b = (s[(i/8)|0] >> (i&7)) & 1;\n cswap(p, q, b);\n add(q, p);\n add(p, p);\n cswap(p, q, b);\n }\n}\n\nfunction scalarbase(p, s) {\n var q = [gf(), gf(), gf(), gf()];\n set25519(q[0], X);\n set25519(q[1], Y);\n set25519(q[2], gf1);\n M(q[3], X, Y);\n scalarmult(p, q, s);\n}\n\nfunction crypto_sign_keypair(pk, sk, seeded) {\n var d = new Uint8Array(64);\n var p = [gf(), gf(), gf(), gf()];\n var i;\n\n if (!seeded) randombytes(sk, 32);\n crypto_hash(d, sk, 32);\n d[0] &= 248;\n d[31] &= 127;\n d[31] |= 64;\n\n scalarbase(p, d);\n pack(pk, p);\n\n for (i = 0; i < 32; i++) sk[i+32] = pk[i];\n return 0;\n}\n\nvar L = new Float64Array([0xed, 0xd3, 0xf5, 0x5c, 0x1a, 0x63, 0x12, 0x58, 0xd6, 0x9c, 0xf7, 0xa2, 0xde, 0xf9, 0xde, 0x14, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x10]);\n\nfunction modL(r, x) {\n var carry, i, j, k;\n for (i = 63; i >= 32; --i) {\n carry = 0;\n for (j = i - 32, k = i - 12; j < k; ++j) {\n x[j] += carry - 16 * x[i] * L[j - (i - 32)];\n carry = Math.floor((x[j] + 128) / 256);\n x[j] -= carry * 256;\n }\n x[j] += carry;\n x[i] = 0;\n }\n carry = 0;\n for (j = 0; j < 32; j++) {\n x[j] += carry - (x[31] >> 4) * L[j];\n carry = x[j] >> 8;\n x[j] &= 255;\n }\n for (j = 0; j < 32; j++) x[j] -= carry * L[j];\n for (i = 0; i < 32; i++) {\n x[i+1] += x[i] >> 8;\n r[i] = x[i] & 255;\n }\n}\n\nfunction reduce(r) {\n var x = new Float64Array(64), i;\n for (i = 0; i < 64; i++) x[i] = r[i];\n for (i = 0; i < 64; i++) r[i] = 0;\n modL(r, x);\n}\n\n// Note: difference from C - smlen returned, not passed as argument.\nfunction crypto_sign(sm, m, n, sk) {\n var d = new Uint8Array(64), h = new Uint8Array(64), r = new Uint8Array(64);\n var i, j, x = new Float64Array(64);\n var p = [gf(), gf(), gf(), gf()];\n\n crypto_hash(d, sk, 32);\n d[0] &= 248;\n d[31] &= 127;\n d[31] |= 64;\n\n var smlen = n + 64;\n for (i = 0; i < n; i++) sm[64 + i] = m[i];\n for (i = 0; i < 32; i++) sm[32 + i] = d[32 + i];\n\n crypto_hash(r, sm.subarray(32), n+32);\n reduce(r);\n scalarbase(p, r);\n pack(sm, p);\n\n for (i = 32; i < 64; i++) sm[i] = sk[i];\n crypto_hash(h, sm, n + 64);\n reduce(h);\n\n for (i = 0; i < 64; i++) x[i] = 0;\n for (i = 0; i < 32; i++) x[i] = r[i];\n for (i = 0; i < 32; i++) {\n for (j = 0; j < 32; j++) {\n x[i+j] += h[i] * d[j];\n }\n }\n\n modL(sm.subarray(32), x);\n return smlen;\n}\n\nfunction unpackneg(r, p) {\n var t = gf(), chk = gf(), num = gf(),\n den = gf(), den2 = gf(), den4 = gf(),\n den6 = gf();\n\n set25519(r[2], gf1);\n unpack25519(r[1], p);\n S(num, r[1]);\n M(den, num, D);\n Z(num, num, r[2]);\n A(den, r[2], den);\n\n S(den2, den);\n S(den4, den2);\n M(den6, den4, den2);\n M(t, den6, num);\n M(t, t, den);\n\n pow2523(t, t);\n M(t, t, num);\n M(t, t, den);\n M(t, t, den);\n M(r[0], t, den);\n\n S(chk, r[0]);\n M(chk, chk, den);\n if (neq25519(chk, num)) M(r[0], r[0], I);\n\n S(chk, r[0]);\n M(chk, chk, den);\n if (neq25519(chk, num)) return -1;\n\n if (par25519(r[0]) === (p[31]>>7)) Z(r[0], gf0, r[0]);\n\n M(r[3], r[0], r[1]);\n return 0;\n}\n\nfunction crypto_sign_open(m, sm, n, pk) {\n var i;\n var t = new Uint8Array(32), h = new Uint8Array(64);\n var p = [gf(), gf(), gf(), gf()],\n q = [gf(), gf(), gf(), gf()];\n\n if (n < 64) return -1;\n\n if (unpackneg(q, pk)) return -1;\n\n for (i = 0; i < n; i++) m[i] = sm[i];\n for (i = 0; i < 32; i++) m[i+32] = pk[i];\n crypto_hash(h, m, n);\n reduce(h);\n scalarmult(p, q, h);\n\n scalarbase(q, sm.subarray(32));\n add(p, q);\n pack(t, p);\n\n n -= 64;\n if (crypto_verify_32(sm, 0, t, 0)) {\n for (i = 0; i < n; i++) m[i] = 0;\n return -1;\n }\n\n for (i = 0; i < n; i++) m[i] = sm[i + 64];\n return n;\n}\n\nvar crypto_secretbox_KEYBYTES = 32,\n crypto_secretbox_NONCEBYTES = 24,\n crypto_secretbox_ZEROBYTES = 32,\n crypto_secretbox_BOXZEROBYTES = 16,\n crypto_scalarmult_BYTES = 32,\n crypto_scalarmult_SCALARBYTES = 32,\n crypto_box_PUBLICKEYBYTES = 32,\n crypto_box_SECRETKEYBYTES = 32,\n crypto_box_BEFORENMBYTES = 32,\n crypto_box_NONCEBYTES = crypto_secretbox_NONCEBYTES,\n crypto_box_ZEROBYTES = crypto_secretbox_ZEROBYTES,\n crypto_box_BOXZEROBYTES = crypto_secretbox_BOXZEROBYTES,\n crypto_sign_BYTES = 64,\n crypto_sign_PUBLICKEYBYTES = 32,\n crypto_sign_SECRETKEYBYTES = 64,\n crypto_sign_SEEDBYTES = 32,\n crypto_hash_BYTES = 64;\n\nnacl.lowlevel = {\n crypto_core_hsalsa20: crypto_core_hsalsa20,\n crypto_stream_xor: crypto_stream_xor,\n crypto_stream: crypto_stream,\n crypto_stream_salsa20_xor: crypto_stream_salsa20_xor,\n crypto_stream_salsa20: crypto_stream_salsa20,\n crypto_onetimeauth: crypto_onetimeauth,\n crypto_onetimeauth_verify: crypto_onetimeauth_verify,\n crypto_verify_16: crypto_verify_16,\n crypto_verify_32: crypto_verify_32,\n crypto_secretbox: crypto_secretbox,\n crypto_secretbox_open: crypto_secretbox_open,\n crypto_scalarmult: crypto_scalarmult,\n crypto_scalarmult_base: crypto_scalarmult_base,\n crypto_box_beforenm: crypto_box_beforenm,\n crypto_box_afternm: crypto_box_afternm,\n crypto_box: crypto_box,\n crypto_box_open: crypto_box_open,\n crypto_box_keypair: crypto_box_keypair,\n crypto_hash: crypto_hash,\n crypto_sign: crypto_sign,\n crypto_sign_keypair: crypto_sign_keypair,\n crypto_sign_open: crypto_sign_open,\n\n crypto_secretbox_KEYBYTES: crypto_secretbox_KEYBYTES,\n crypto_secretbox_NONCEBYTES: crypto_secretbox_NONCEBYTES,\n crypto_secretbox_ZEROBYTES: crypto_secretbox_ZEROBYTES,\n crypto_secretbox_BOXZEROBYTES: crypto_secretbox_BOXZEROBYTES,\n crypto_scalarmult_BYTES: crypto_scalarmult_BYTES,\n crypto_scalarmult_SCALARBYTES: crypto_scalarmult_SCALARBYTES,\n crypto_box_PUBLICKEYBYTES: crypto_box_PUBLICKEYBYTES,\n crypto_box_SECRETKEYBYTES: crypto_box_SECRETKEYBYTES,\n crypto_box_BEFORENMBYTES: crypto_box_BEFORENMBYTES,\n crypto_box_NONCEBYTES: crypto_box_NONCEBYTES,\n crypto_box_ZEROBYTES: crypto_box_ZEROBYTES,\n crypto_box_BOXZEROBYTES: crypto_box_BOXZEROBYTES,\n crypto_sign_BYTES: crypto_sign_BYTES,\n crypto_sign_PUBLICKEYBYTES: crypto_sign_PUBLICKEYBYTES,\n crypto_sign_SECRETKEYBYTES: crypto_sign_SECRETKEYBYTES,\n crypto_sign_SEEDBYTES: crypto_sign_SEEDBYTES,\n crypto_hash_BYTES: crypto_hash_BYTES,\n\n gf: gf,\n D: D,\n L: L,\n pack25519: pack25519,\n unpack25519: unpack25519,\n M: M,\n A: A,\n S: S,\n Z: Z,\n pow2523: pow2523,\n add: add,\n set25519: set25519,\n modL: modL,\n scalarmult: scalarmult,\n scalarbase: scalarbase,\n};\n\n/* High-level API */\n\nfunction checkLengths(k, n) {\n if (k.length !== crypto_secretbox_KEYBYTES) throw new Error('bad key size');\n if (n.length !== crypto_secretbox_NONCEBYTES) throw new Error('bad nonce size');\n}\n\nfunction checkBoxLengths(pk, sk) {\n if (pk.length !== crypto_box_PUBLICKEYBYTES) throw new Error('bad public key size');\n if (sk.length !== crypto_box_SECRETKEYBYTES) throw new Error('bad secret key size');\n}\n\nfunction checkArrayTypes() {\n for (var i = 0; i < arguments.length; i++) {\n if (!(arguments[i] instanceof Uint8Array))\n throw new TypeError('unexpected type, use Uint8Array');\n }\n}\n\nfunction cleanup(arr) {\n for (var i = 0; i < arr.length; i++) arr[i] = 0;\n}\n\nnacl.randomBytes = function(n) {\n var b = new Uint8Array(n);\n randombytes(b, n);\n return b;\n};\n\nnacl.secretbox = function(msg, nonce, key) {\n checkArrayTypes(msg, nonce, key);\n checkLengths(key, nonce);\n var m = new Uint8Array(crypto_secretbox_ZEROBYTES + msg.length);\n var c = new Uint8Array(m.length);\n for (var i = 0; i < msg.length; i++) m[i+crypto_secretbox_ZEROBYTES] = msg[i];\n crypto_secretbox(c, m, m.length, nonce, key);\n return c.subarray(crypto_secretbox_BOXZEROBYTES);\n};\n\nnacl.secretbox.open = function(box, nonce, key) {\n checkArrayTypes(box, nonce, key);\n checkLengths(key, nonce);\n var c = new Uint8Array(crypto_secretbox_BOXZEROBYTES + box.length);\n var m = new Uint8Array(c.length);\n for (var i = 0; i < box.length; i++) c[i+crypto_secretbox_BOXZEROBYTES] = box[i];\n if (c.length < 32) return null;\n if (crypto_secretbox_open(m, c, c.length, nonce, key) !== 0) return null;\n return m.subarray(crypto_secretbox_ZEROBYTES);\n};\n\nnacl.secretbox.keyLength = crypto_secretbox_KEYBYTES;\nnacl.secretbox.nonceLength = crypto_secretbox_NONCEBYTES;\nnacl.secretbox.overheadLength = crypto_secretbox_BOXZEROBYTES;\n\nnacl.scalarMult = function(n, p) {\n checkArrayTypes(n, p);\n if (n.length !== crypto_scalarmult_SCALARBYTES) throw new Error('bad n size');\n if (p.length !== crypto_scalarmult_BYTES) throw new Error('bad p size');\n var q = new Uint8Array(crypto_scalarmult_BYTES);\n crypto_scalarmult(q, n, p);\n return q;\n};\n\nnacl.scalarMult.base = function(n) {\n checkArrayTypes(n);\n if (n.length !== crypto_scalarmult_SCALARBYTES) throw new Error('bad n size');\n var q = new Uint8Array(crypto_scalarmult_BYTES);\n crypto_scalarmult_base(q, n);\n return q;\n};\n\nnacl.scalarMult.scalarLength = crypto_scalarmult_SCALARBYTES;\nnacl.scalarMult.groupElementLength = crypto_scalarmult_BYTES;\n\nnacl.box = function(msg, nonce, publicKey, secretKey) {\n var k = nacl.box.before(publicKey, secretKey);\n return nacl.secretbox(msg, nonce, k);\n};\n\nnacl.box.before = function(publicKey, secretKey) {\n checkArrayTypes(publicKey, secretKey);\n checkBoxLengths(publicKey, secretKey);\n var k = new Uint8Array(crypto_box_BEFORENMBYTES);\n crypto_box_beforenm(k, publicKey, secretKey);\n return k;\n};\n\nnacl.box.after = nacl.secretbox;\n\nnacl.box.open = function(msg, nonce, publicKey, secretKey) {\n var k = nacl.box.before(publicKey, secretKey);\n return nacl.secretbox.open(msg, nonce, k);\n};\n\nnacl.box.open.after = nacl.secretbox.open;\n\nnacl.box.keyPair = function() {\n var pk = new Uint8Array(crypto_box_PUBLICKEYBYTES);\n var sk = new Uint8Array(crypto_box_SECRETKEYBYTES);\n crypto_box_keypair(pk, sk);\n return {publicKey: pk, secretKey: sk};\n};\n\nnacl.box.keyPair.fromSecretKey = function(secretKey) {\n checkArrayTypes(secretKey);\n if (secretKey.length !== crypto_box_SECRETKEYBYTES)\n throw new Error('bad secret key size');\n var pk = new Uint8Array(crypto_box_PUBLICKEYBYTES);\n crypto_scalarmult_base(pk, secretKey);\n return {publicKey: pk, secretKey: new Uint8Array(secretKey)};\n};\n\nnacl.box.publicKeyLength = crypto_box_PUBLICKEYBYTES;\nnacl.box.secretKeyLength = crypto_box_SECRETKEYBYTES;\nnacl.box.sharedKeyLength = crypto_box_BEFORENMBYTES;\nnacl.box.nonceLength = crypto_box_NONCEBYTES;\nnacl.box.overheadLength = nacl.secretbox.overheadLength;\n\nnacl.sign = function(msg, secretKey) {\n checkArrayTypes(msg, secretKey);\n if (secretKey.length !== crypto_sign_SECRETKEYBYTES)\n throw new Error('bad secret key size');\n var signedMsg = new Uint8Array(crypto_sign_BYTES+msg.length);\n crypto_sign(signedMsg, msg, msg.length, secretKey);\n return signedMsg;\n};\n\nnacl.sign.open = function(signedMsg, publicKey) {\n checkArrayTypes(signedMsg, publicKey);\n if (publicKey.length !== crypto_sign_PUBLICKEYBYTES)\n throw new Error('bad public key size');\n var tmp = new Uint8Array(signedMsg.length);\n var mlen = crypto_sign_open(tmp, signedMsg, signedMsg.length, publicKey);\n if (mlen < 0) return null;\n var m = new Uint8Array(mlen);\n for (var i = 0; i < m.length; i++) m[i] = tmp[i];\n return m;\n};\n\nnacl.sign.detached = function(msg, secretKey) {\n var signedMsg = nacl.sign(msg, secretKey);\n var sig = new Uint8Array(crypto_sign_BYTES);\n for (var i = 0; i < sig.length; i++) sig[i] = signedMsg[i];\n return sig;\n};\n\nnacl.sign.detached.verify = function(msg, sig, publicKey) {\n checkArrayTypes(msg, sig, publicKey);\n if (sig.length !== crypto_sign_BYTES)\n throw new Error('bad signature size');\n if (publicKey.length !== crypto_sign_PUBLICKEYBYTES)\n throw new Error('bad public key size');\n var sm = new Uint8Array(crypto_sign_BYTES + msg.length);\n var m = new Uint8Array(crypto_sign_BYTES + msg.length);\n var i;\n for (i = 0; i < crypto_sign_BYTES; i++) sm[i] = sig[i];\n for (i = 0; i < msg.length; i++) sm[i+crypto_sign_BYTES] = msg[i];\n return (crypto_sign_open(m, sm, sm.length, publicKey) >= 0);\n};\n\nnacl.sign.keyPair = function() {\n var pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);\n var sk = new Uint8Array(crypto_sign_SECRETKEYBYTES);\n crypto_sign_keypair(pk, sk);\n return {publicKey: pk, secretKey: sk};\n};\n\nnacl.sign.keyPair.fromSecretKey = function(secretKey) {\n checkArrayTypes(secretKey);\n if (secretKey.length !== crypto_sign_SECRETKEYBYTES)\n throw new Error('bad secret key size');\n var pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);\n for (var i = 0; i < pk.length; i++) pk[i] = secretKey[32+i];\n return {publicKey: pk, secretKey: new Uint8Array(secretKey)};\n};\n\nnacl.sign.keyPair.fromSeed = function(seed) {\n checkArrayTypes(seed);\n if (seed.length !== crypto_sign_SEEDBYTES)\n throw new Error('bad seed size');\n var pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);\n var sk = new Uint8Array(crypto_sign_SECRETKEYBYTES);\n for (var i = 0; i < 32; i++) sk[i] = seed[i];\n crypto_sign_keypair(pk, sk, true);\n return {publicKey: pk, secretKey: sk};\n};\n\nnacl.sign.publicKeyLength = crypto_sign_PUBLICKEYBYTES;\nnacl.sign.secretKeyLength = crypto_sign_SECRETKEYBYTES;\nnacl.sign.seedLength = crypto_sign_SEEDBYTES;\nnacl.sign.signatureLength = crypto_sign_BYTES;\n\nnacl.hash = function(msg) {\n checkArrayTypes(msg);\n var h = new Uint8Array(crypto_hash_BYTES);\n crypto_hash(h, msg, msg.length);\n return h;\n};\n\nnacl.hash.hashLength = crypto_hash_BYTES;\n\nnacl.verify = function(x, y) {\n checkArrayTypes(x, y);\n // Zero length arguments are considered not equal.\n if (x.length === 0 || y.length === 0) return false;\n if (x.length !== y.length) return false;\n return (vn(x, 0, y, 0, x.length) === 0) ? true : false;\n};\n\nnacl.setPRNG = function(fn) {\n randombytes = fn;\n};\n\n(function() {\n // Initialize PRNG if environment provides CSPRNG.\n // If not, methods calling randombytes will throw.\n var crypto = typeof self !== 'undefined' ? (self.crypto || self.msCrypto) : null;\n if (crypto && crypto.getRandomValues) {\n // Browsers.\n var QUOTA = 65536;\n nacl.setPRNG(function(x, n) {\n var i, v = new Uint8Array(n);\n for (i = 0; i < n; i += QUOTA) {\n crypto.getRandomValues(v.subarray(i, i + Math.min(n - i, QUOTA)));\n }\n for (i = 0; i < n; i++) x[i] = v[i];\n cleanup(v);\n });\n } else if (typeof require !== 'undefined') {\n // Node.js.\n crypto = require('crypto');\n if (crypto && crypto.randomBytes) {\n nacl.setPRNG(function(x, n) {\n var i, v = crypto.randomBytes(n);\n for (i = 0; i < n; i++) x[i] = v[i];\n cleanup(v);\n });\n }\n }\n})();\n\n})(typeof module !== 'undefined' && module.exports ? module.exports : (self.nacl = self.nacl || {}));\n","module.exports = require('./pusher-with-encryption').default;\n","import Pusher from './pusher';\nimport { Options, validateOptions } from './options';\nimport * as nacl from 'tweetnacl';\n\nexport default class PusherWithEncryption extends Pusher {\n constructor(app_key: string, options: Options) {\n Pusher.logToConsole = PusherWithEncryption.logToConsole;\n Pusher.log = PusherWithEncryption.log;\n\n validateOptions(options);\n options.nacl = nacl;\n super(app_key, options);\n }\n}\n"],"sourceRoot":""} \ No newline at end of file diff --git a/dist/web/pusher-with-encryption.js b/dist/web/pusher-with-encryption.js index f3e72840a..af3ecae21 100644 --- a/dist/web/pusher-with-encryption.js +++ b/dist/web/pusher-with-encryption.js @@ -1,5 +1,5 @@ /*! - * Pusher JavaScript Library v8.4.0 + * Pusher JavaScript Library v8.4.0-rc1 * https://pusher.com/ * * Copyright 2020, Pusher @@ -2996,7 +2996,7 @@ var ScriptReceivers = new ScriptReceiverFactory('_pusher_script_', 'Pusher.Scrip // CONCATENATED MODULE: ./src/core/defaults.ts var Defaults = { - VERSION: "8.4.0", + VERSION: "8.4.0-rc1", PROTOCOL: 7, wsPort: 80, wssPort: 443, diff --git a/dist/web/pusher-with-encryption.js.map b/dist/web/pusher-with-encryption.js.map index 6670b0477..7e94ecc07 100644 --- a/dist/web/pusher-with-encryption.js.map +++ b/dist/web/pusher-with-encryption.js.map @@ -1 +1 @@ -{"version":3,"sources":["webpack://Pusher/webpack/universalModuleDefinition","webpack://Pusher/webpack/bootstrap","webpack://Pusher/./node_modules/@stablelib/base64/base64.ts","webpack://Pusher/./node_modules/@stablelib/utf8/utf8.ts","webpack://Pusher/./node_modules/tweetnacl/nacl-fast.js","webpack://Pusher/./src/core/pusher-with-encryption.js","webpack://Pusher/crypto (ignored)","webpack://Pusher/./src/runtimes/web/dom/script_receiver_factory.ts","webpack://Pusher/./src/core/defaults.ts","webpack://Pusher/./src/runtimes/web/dom/dependency_loader.ts","webpack://Pusher/./src/runtimes/web/dom/dependencies.ts","webpack://Pusher/./src/core/utils/url_store.ts","webpack://Pusher/./src/core/auth/options.ts","webpack://Pusher/./src/core/errors.ts","webpack://Pusher/./src/runtimes/isomorphic/auth/xhr_auth.ts","webpack://Pusher/./src/core/base64.ts","webpack://Pusher/./src/core/utils/timers/abstract_timer.ts","webpack://Pusher/./src/core/utils/timers/index.ts","webpack://Pusher/./src/core/util.ts","webpack://Pusher/./src/core/utils/collections.ts","webpack://Pusher/./src/core/logger.ts","webpack://Pusher/./src/runtimes/web/auth/jsonp_auth.ts","webpack://Pusher/./src/runtimes/web/dom/script_request.ts","webpack://Pusher/./src/runtimes/web/dom/jsonp_request.ts","webpack://Pusher/./src/runtimes/web/timeline/jsonp_timeline.ts","webpack://Pusher/./src/core/transports/url_schemes.ts","webpack://Pusher/./src/core/events/callback_registry.ts","webpack://Pusher/./src/core/events/dispatcher.ts","webpack://Pusher/./src/core/transports/transport_connection.ts","webpack://Pusher/./src/core/transports/transport.ts","webpack://Pusher/./src/runtimes/isomorphic/transports/transports.ts","webpack://Pusher/./src/runtimes/web/transports/transports.ts","webpack://Pusher/./src/runtimes/web/net_info.ts","webpack://Pusher/./src/core/transports/assistant_to_the_transport_manager.ts","webpack://Pusher/./src/core/connection/protocol/protocol.ts","webpack://Pusher/./src/core/connection/connection.ts","webpack://Pusher/./src/core/connection/handshake/index.ts","webpack://Pusher/./src/core/timeline/timeline_sender.ts","webpack://Pusher/./src/core/channels/channel.ts","webpack://Pusher/./src/core/channels/private_channel.ts","webpack://Pusher/./src/core/channels/members.ts","webpack://Pusher/./src/core/channels/presence_channel.ts","webpack://Pusher/./src/core/channels/encrypted_channel.ts","webpack://Pusher/./src/core/connection/connection_manager.ts","webpack://Pusher/./src/core/channels/channels.ts","webpack://Pusher/./src/core/utils/factory.ts","webpack://Pusher/./src/core/transports/transport_manager.ts","webpack://Pusher/./src/core/strategies/sequential_strategy.ts","webpack://Pusher/./src/core/strategies/best_connected_ever_strategy.ts","webpack://Pusher/./src/core/strategies/websocket_prioritized_cached_strategy.ts","webpack://Pusher/./src/core/strategies/delayed_strategy.ts","webpack://Pusher/./src/core/strategies/if_strategy.ts","webpack://Pusher/./src/core/strategies/first_connected_strategy.ts","webpack://Pusher/./src/runtimes/web/default_strategy.ts","webpack://Pusher/./src/runtimes/web/transports/transport_connection_initializer.ts","webpack://Pusher/./src/runtimes/web/http/http_xdomain_request.ts","webpack://Pusher/./src/core/http/http_request.ts","webpack://Pusher/./src/core/http/state.ts","webpack://Pusher/./src/core/http/http_socket.ts","webpack://Pusher/./src/core/http/http_streaming_socket.ts","webpack://Pusher/./src/core/http/http_polling_socket.ts","webpack://Pusher/./src/runtimes/isomorphic/http/http_xhr_request.ts","webpack://Pusher/./src/runtimes/isomorphic/http/http.ts","webpack://Pusher/./src/runtimes/web/http/http.ts","webpack://Pusher/./src/runtimes/web/runtime.ts","webpack://Pusher/./src/core/timeline/level.ts","webpack://Pusher/./src/core/timeline/timeline.ts","webpack://Pusher/./src/core/strategies/transport_strategy.ts","webpack://Pusher/./src/core/strategies/strategy_builder.ts","webpack://Pusher/./src/core/options.ts","webpack://Pusher/./src/core/auth/user_authenticator.ts","webpack://Pusher/./src/core/auth/channel_authorizer.ts","webpack://Pusher/./src/core/auth/deprecated_channel_authorizer.ts","webpack://Pusher/./src/core/config.ts","webpack://Pusher/./src/core/watchlist.ts","webpack://Pusher/./src/core/utils/flat_promise.ts","webpack://Pusher/./src/core/user.ts","webpack://Pusher/./src/core/pusher.ts","webpack://Pusher/./src/core/pusher-with-encryption.ts"],"names":[],"mappings":";;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AACD,O;QCVA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;;QAEA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;;;QAGA;QACA;;QAE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AC;AAC1B,CAAC;AAjED,wBAiEC;;;;;;;AC/ID;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,uBAAuB,iBAAiB;AACxC;AACA;;AAEA;AACA,wCAAwC,4BAA4B;;AAEpE;AACA,4BAA4B;;AAE5B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa,OAAO;AACpB;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,aAAa,QAAQ;AACrB,aAAa,OAAO;AACpB;AACA;AACA,eAAe,QAAQ;AACvB;AACA,eAAe,QAAQ;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB;AACA;AACA;;AAEA;AACA;AACA;AACA,aAAa,QAAQ;AACrB,aAAa,OAAO;AACpB;AACA;AACA,eAAe,QAAQ;AACvB;AACA,eAAe,QAAQ;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,iBAAiB,OAAO;AACxB;AACA;;AAEA;AACA;AACA;AACA;AACA,iBAAiB,OAAO;AACxB;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA,8CAA8C;AAC9C,8CAA8C;AAC9C,8CAA8C;AAC9C,8CAA8C;AAC9C,8CAA8C;AAC9C;AACA,8CAA8C;AAC9C,8CAA8C;AAC9C,8CAA8C;AAC9C;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,sDAAsD;AACtD,sDAAsD;AACtD,sDAAsD;AACtD,sDAAsD;AACtD,sDAAsD;AACtD;AACA,sDAAsD;AACtD,sDAAsD;AACtD,sDAAsD;AACtD;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA,qBAAqB;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA,qBAAqB;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA,qBAAqB;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA,qBAAqB;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA,qBAAqB;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA,qBAAqB;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA,qBAAqB;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA,qBAAqB;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA,qBAAqB;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA,qBAAqB;;AAErB;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA,UAAU,QAAQ;AAClB;AACA;AACA;;AAEA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA;AACA;;AAEA;AACA,aAAa,QAAQ;AACrB;AACA,aAAa,QAAQ;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa,OAAO;AACpB;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,UAAU;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,eAAe,WAAW;AAC1B;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;;AAEA;AACA;AACA,aAAa,QAAQ;AACrB;;AAEA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA,aAAa,OAAO;AACpB;AACA,eAAe,QAAQ;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;;AAEA;AACA,iBAAiB,QAAQ;AACzB;;AAEA;AACA,iBAAiB,QAAQ;AACzB;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD;;AAEA;AACA;AACA,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA,aAAa,QAAQ;AACrB,eAAe,QAAQ;AACvB;AACA;AACA;AACA,aAAa,QAAQ;AACrB;;AAEA;AACA;AACA;AACA,aAAa,QAAQ;AACrB,eAAe,QAAQ;AACvB;AACA;AACA;AACA,aAAa,QAAQ;AACrB;;AAEA;AACA;AACA;AACA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA;AACA,aAAa,MAAM;AACnB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,eAAe,QAAQ;AACvB;AACA;AACA;AACA;AACA,eAAe,QAAQ;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA,qBAAqB;AACrB,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ACA;;AAEA;AACA;;AAEA,mBAAmB;AACnB,mBAAmB;;AAEnB;AACA;;AAEA,oBAAoB;AACpB,oBAAoB;;AAEpB;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA,mBAAmB;AACnB,mBAAmB;;AAEnB;AACA;;AAEA,oBAAoB;AACpB,oBAAoB;;AAEpB;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA,mBAAmB;AACnB,mBAAmB;;AAEnB;AACA;;AAEA,oBAAoB;AACpB,oBAAoB;;AAEpB;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA,mBAAmB;AACnB,mBAAmB;;AAEnB;AACA;;AAEA,oBAAoB;AACpB,oBAAoB;;AAEpB;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA,mBAAmB;AACnB,mBAAmB;;AAEnB;AACA;;AAEA,oBAAoB;AACpB,oBAAoB;;AAEpB;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA,aAAa,OAAO;AACpB;;AAEA;AACA;AACA;AACA;;AAEA,aAAa,OAAO;;AAEpB;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa,OAAO;AACpB;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,QAAQ;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA,aAAa,QAAQ;AACrB;AACA;;AAEA;;AAEA;AACA;AACA,cAAc,SAAS;AACvB;AACA,gCAAgC,OAAO;AACvC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA;AACA,aAAa,QAAQ;AACrB,aAAa,QAAQ;AACrB;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa,QAAQ;AACrB,aAAa,QAAQ;AACrB;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA,aAAa,OAAO;AACpB,aAAa,QAAQ;;AAErB;AACA;AACA;AACA;;AAEA,cAAc,QAAQ;AACtB;AACA;;AAEA,aAAa,QAAQ;AACrB,aAAa,QAAQ;AACrB,aAAa,QAAQ;AACrB,eAAe,QAAQ;AACvB;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;;AAEA,aAAa,OAAO;AACpB,aAAa,QAAQ;AACrB;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA,eAAe,OAAO;AACtB;AACA;;AAEA,aAAa,OAAO;AACpB;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA,iBAAiB,sBAAsB;AACvC;AACA;AACA;AACA;;AAEA;AACA,iBAAiB,gBAAgB;AACjC;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,iBAAiB,gBAAgB;AACjC;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,iBAAiB,gBAAgB;AACjC;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA,UAAU;AACV;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,UAAU;AACV;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAiB,cAAc;AAC/B;AACA;;AAEA;AACA;AACA;AACA,iBAAiB,gBAAgB;AACjC;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa,uBAAuB;AACpC,aAAa,gBAAgB;AAC7B;AACA;;AAEA;AACA;AACA;AACA;AACA,UAAU;AACV;;AAEA;AACA;AACA;AACA;AACA;AACA,iBAAiB,eAAe;AAChC,UAAU;AACV;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAiB,QAAQ;AACzB;AACA,UAAU;AACV;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAiB,OAAO;AACxB;AACA;AACA,iBAAiB,OAAO;AAC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AAClE,4BAAc,GAAc,OAAQ,CAAC,cAAc,CAAC;AAVxC,6DAAM;AA4O3B,SAAS,WAAW,CAAC,GAAG;IACtB,IAAI,GAAG,KAAK,IAAI,IAAI,GAAG,KAAK,SAAS,EAAE;QACrC,MAAM,yDAAyD,CAAC;KACjE;AACH,CAAC;AAED,OAAO,CAAC,KAAK,CAAC,aAAM,CAAC,CAAC;;;;;;ACtQQ;AACuB;AACnB;AAEnB,MAAM,2CAAqB,SAAQ,WAAM;IACtD,YAAY,OAAe,EAAE,OAAgB;QAC3C,WAAM,CAAC,YAAY,GAAG,2CAAoB,CAAC,YAAY,CAAC;QACxD,WAAM,CAAC,GAAG,GAAG,2CAAoB,CAAC,GAAG,CAAC;QAEtC,eAAe,CAAC,OAAO,CAAC,CAAC;QACzB,OAAO,CAAC,IAAI,GAAG,SAAI,CAAC;QACpB,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAC1B,CAAC;CACF","file":"pusher-with-encryption.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"Pusher\"] = factory();\n\telse\n\t\troot[\"Pusher\"] = factory();\n})(window, function() {\nreturn "," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 3);\n","// Copyright (C) 2016 Dmitry Chestnykh\n// MIT License. See LICENSE file for details.\n\n/**\n * Package base64 implements Base64 encoding and decoding.\n */\n\n// Invalid character used in decoding to indicate\n// that the character to decode is out of range of\n// alphabet and cannot be decoded.\nconst INVALID_BYTE = 256;\n\n/**\n * Implements standard Base64 encoding.\n *\n * Operates in constant time.\n */\nexport class Coder {\n // TODO(dchest): methods to encode chunk-by-chunk.\n\n constructor(private _paddingCharacter = \"=\") { }\n\n encodedLength(length: number): number {\n if (!this._paddingCharacter) {\n return (length * 8 + 5) / 6 | 0;\n }\n return (length + 2) / 3 * 4 | 0;\n }\n\n encode(data: Uint8Array): string {\n let out = \"\";\n\n let i = 0;\n for (; i < data.length - 2; i += 3) {\n let c = (data[i] << 16) | (data[i + 1] << 8) | (data[i + 2]);\n out += this._encodeByte((c >>> 3 * 6) & 63);\n out += this._encodeByte((c >>> 2 * 6) & 63);\n out += this._encodeByte((c >>> 1 * 6) & 63);\n out += this._encodeByte((c >>> 0 * 6) & 63);\n }\n\n const left = data.length - i;\n if (left > 0) {\n let c = (data[i] << 16) | (left === 2 ? data[i + 1] << 8 : 0);\n out += this._encodeByte((c >>> 3 * 6) & 63);\n out += this._encodeByte((c >>> 2 * 6) & 63);\n if (left === 2) {\n out += this._encodeByte((c >>> 1 * 6) & 63);\n } else {\n out += this._paddingCharacter || \"\";\n }\n out += this._paddingCharacter || \"\";\n }\n\n return out;\n }\n\n maxDecodedLength(length: number): number {\n if (!this._paddingCharacter) {\n return (length * 6 + 7) / 8 | 0;\n }\n return length / 4 * 3 | 0;\n }\n\n decodedLength(s: string): number {\n return this.maxDecodedLength(s.length - this._getPaddingLength(s));\n }\n\n decode(s: string): Uint8Array {\n if (s.length === 0) {\n return new Uint8Array(0);\n }\n const paddingLength = this._getPaddingLength(s);\n const length = s.length - paddingLength;\n const out = new Uint8Array(this.maxDecodedLength(length));\n let op = 0;\n let i = 0;\n let haveBad = 0;\n let v0 = 0, v1 = 0, v2 = 0, v3 = 0;\n for (; i < length - 4; i += 4) {\n v0 = this._decodeChar(s.charCodeAt(i + 0));\n v1 = this._decodeChar(s.charCodeAt(i + 1));\n v2 = this._decodeChar(s.charCodeAt(i + 2));\n v3 = this._decodeChar(s.charCodeAt(i + 3));\n out[op++] = (v0 << 2) | (v1 >>> 4);\n out[op++] = (v1 << 4) | (v2 >>> 2);\n out[op++] = (v2 << 6) | v3;\n haveBad |= v0 & INVALID_BYTE;\n haveBad |= v1 & INVALID_BYTE;\n haveBad |= v2 & INVALID_BYTE;\n haveBad |= v3 & INVALID_BYTE;\n }\n if (i < length - 1) {\n v0 = this._decodeChar(s.charCodeAt(i));\n v1 = this._decodeChar(s.charCodeAt(i + 1));\n out[op++] = (v0 << 2) | (v1 >>> 4);\n haveBad |= v0 & INVALID_BYTE;\n haveBad |= v1 & INVALID_BYTE;\n }\n if (i < length - 2) {\n v2 = this._decodeChar(s.charCodeAt(i + 2));\n out[op++] = (v1 << 4) | (v2 >>> 2);\n haveBad |= v2 & INVALID_BYTE;\n }\n if (i < length - 3) {\n v3 = this._decodeChar(s.charCodeAt(i + 3));\n out[op++] = (v2 << 6) | v3;\n haveBad |= v3 & INVALID_BYTE;\n }\n if (haveBad !== 0) {\n throw new Error(\"Base64Coder: incorrect characters for decoding\");\n }\n return out;\n }\n\n // Standard encoding have the following encoded/decoded ranges,\n // which we need to convert between.\n //\n // ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 0123456789 + /\n // Index: 0 - 25 26 - 51 52 - 61 62 63\n // ASCII: 65 - 90 97 - 122 48 - 57 43 47\n //\n\n // Encode 6 bits in b into a new character.\n protected _encodeByte(b: number): string {\n // Encoding uses constant time operations as follows:\n //\n // 1. Define comparison of A with B using (A - B) >>> 8:\n // if A > B, then result is positive integer\n // if A <= B, then result is 0\n //\n // 2. Define selection of C or 0 using bitwise AND: X & C:\n // if X == 0, then result is 0\n // if X != 0, then result is C\n //\n // 3. Start with the smallest comparison (b >= 0), which is always\n // true, so set the result to the starting ASCII value (65).\n //\n // 4. Continue comparing b to higher ASCII values, and selecting\n // zero if comparison isn't true, otherwise selecting a value\n // to add to result, which:\n //\n // a) undoes the previous addition\n // b) provides new value to add\n //\n let result = b;\n // b >= 0\n result += 65;\n // b > 25\n result += ((25 - b) >>> 8) & ((0 - 65) - 26 + 97);\n // b > 51\n result += ((51 - b) >>> 8) & ((26 - 97) - 52 + 48);\n // b > 61\n result += ((61 - b) >>> 8) & ((52 - 48) - 62 + 43);\n // b > 62\n result += ((62 - b) >>> 8) & ((62 - 43) - 63 + 47);\n\n return String.fromCharCode(result);\n }\n\n // Decode a character code into a byte.\n // Must return 256 if character is out of alphabet range.\n protected _decodeChar(c: number): number {\n // Decoding works similar to encoding: using the same comparison\n // function, but now it works on ranges: result is always incremented\n // by value, but this value becomes zero if the range is not\n // satisfied.\n //\n // Decoding starts with invalid value, 256, which is then\n // subtracted when the range is satisfied. If none of the ranges\n // apply, the function returns 256, which is then checked by\n // the caller to throw error.\n let result = INVALID_BYTE; // start with invalid character\n\n // c == 43 (c > 42 and c < 44)\n result += (((42 - c) & (c - 44)) >>> 8) & (-INVALID_BYTE + c - 43 + 62);\n // c == 47 (c > 46 and c < 48)\n result += (((46 - c) & (c - 48)) >>> 8) & (-INVALID_BYTE + c - 47 + 63);\n // c > 47 and c < 58\n result += (((47 - c) & (c - 58)) >>> 8) & (-INVALID_BYTE + c - 48 + 52);\n // c > 64 and c < 91\n result += (((64 - c) & (c - 91)) >>> 8) & (-INVALID_BYTE + c - 65 + 0);\n // c > 96 and c < 123\n result += (((96 - c) & (c - 123)) >>> 8) & (-INVALID_BYTE + c - 97 + 26);\n\n return result;\n }\n\n private _getPaddingLength(s: string): number {\n let paddingLength = 0;\n if (this._paddingCharacter) {\n for (let i = s.length - 1; i >= 0; i--) {\n if (s[i] !== this._paddingCharacter) {\n break;\n }\n paddingLength++;\n }\n if (s.length < 4 || paddingLength > 2) {\n throw new Error(\"Base64Coder: incorrect padding\");\n }\n }\n return paddingLength;\n }\n\n}\n\nconst stdCoder = new Coder();\n\nexport function encode(data: Uint8Array): string {\n return stdCoder.encode(data);\n}\n\nexport function decode(s: string): Uint8Array {\n return stdCoder.decode(s);\n}\n\n/**\n * Implements URL-safe Base64 encoding.\n * (Same as Base64, but '+' is replaced with '-', and '/' with '_').\n *\n * Operates in constant time.\n */\nexport class URLSafeCoder extends Coder {\n // URL-safe encoding have the following encoded/decoded ranges:\n //\n // ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 0123456789 - _\n // Index: 0 - 25 26 - 51 52 - 61 62 63\n // ASCII: 65 - 90 97 - 122 48 - 57 45 95\n //\n\n protected _encodeByte(b: number): string {\n let result = b;\n // b >= 0\n result += 65;\n // b > 25\n result += ((25 - b) >>> 8) & ((0 - 65) - 26 + 97);\n // b > 51\n result += ((51 - b) >>> 8) & ((26 - 97) - 52 + 48);\n // b > 61\n result += ((61 - b) >>> 8) & ((52 - 48) - 62 + 45);\n // b > 62\n result += ((62 - b) >>> 8) & ((62 - 45) - 63 + 95);\n\n return String.fromCharCode(result);\n }\n\n protected _decodeChar(c: number): number {\n let result = INVALID_BYTE;\n\n // c == 45 (c > 44 and c < 46)\n result += (((44 - c) & (c - 46)) >>> 8) & (-INVALID_BYTE + c - 45 + 62);\n // c == 95 (c > 94 and c < 96)\n result += (((94 - c) & (c - 96)) >>> 8) & (-INVALID_BYTE + c - 95 + 63);\n // c > 47 and c < 58\n result += (((47 - c) & (c - 58)) >>> 8) & (-INVALID_BYTE + c - 48 + 52);\n // c > 64 and c < 91\n result += (((64 - c) & (c - 91)) >>> 8) & (-INVALID_BYTE + c - 65 + 0);\n // c > 96 and c < 123\n result += (((96 - c) & (c - 123)) >>> 8) & (-INVALID_BYTE + c - 97 + 26);\n\n return result;\n }\n}\n\nconst urlSafeCoder = new URLSafeCoder();\n\nexport function encodeURLSafe(data: Uint8Array): string {\n return urlSafeCoder.encode(data);\n}\n\nexport function decodeURLSafe(s: string): Uint8Array {\n return urlSafeCoder.decode(s);\n}\n\n\nexport const encodedLength = (length: number) =>\n stdCoder.encodedLength(length);\n\nexport const maxDecodedLength = (length: number) =>\n stdCoder.maxDecodedLength(length);\n\nexport const decodedLength = (s: string) =>\n stdCoder.decodedLength(s);\n","// Copyright (C) 2016 Dmitry Chestnykh\n// MIT License. See LICENSE file for details.\n\n/**\n * Package utf8 implements UTF-8 encoding and decoding.\n */\n\nconst INVALID_UTF16 = \"utf8: invalid string\";\nconst INVALID_UTF8 = \"utf8: invalid source encoding\";\n\n/**\n * Encodes the given string into UTF-8 byte array.\n * Throws if the source string has invalid UTF-16 encoding.\n */\nexport function encode(s: string): Uint8Array {\n // Calculate result length and allocate output array.\n // encodedLength() also validates string and throws errors,\n // so we don't need repeat validation here.\n const arr = new Uint8Array(encodedLength(s));\n\n let pos = 0;\n for (let i = 0; i < s.length; i++) {\n let c = s.charCodeAt(i);\n if (c < 0x80) {\n arr[pos++] = c;\n } else if (c < 0x800) {\n arr[pos++] = 0xc0 | c >> 6;\n arr[pos++] = 0x80 | c & 0x3f;\n } else if (c < 0xd800) {\n arr[pos++] = 0xe0 | c >> 12;\n arr[pos++] = 0x80 | (c >> 6) & 0x3f;\n arr[pos++] = 0x80 | c & 0x3f;\n } else {\n i++; // get one more character\n c = (c & 0x3ff) << 10;\n c |= s.charCodeAt(i) & 0x3ff;\n c += 0x10000;\n\n arr[pos++] = 0xf0 | c >> 18;\n arr[pos++] = 0x80 | (c >> 12) & 0x3f;\n arr[pos++] = 0x80 | (c >> 6) & 0x3f;\n arr[pos++] = 0x80 | c & 0x3f;\n }\n }\n return arr;\n}\n\n/**\n * Returns the number of bytes required to encode the given string into UTF-8.\n * Throws if the source string has invalid UTF-16 encoding.\n */\nexport function encodedLength(s: string): number {\n let result = 0;\n for (let i = 0; i < s.length; i++) {\n const c = s.charCodeAt(i);\n if (c < 0x80) {\n result += 1;\n } else if (c < 0x800) {\n result += 2;\n } else if (c < 0xd800) {\n result += 3;\n } else if (c <= 0xdfff) {\n if (i >= s.length - 1) {\n throw new Error(INVALID_UTF16);\n }\n i++; // \"eat\" next character\n result += 4;\n } else {\n throw new Error(INVALID_UTF16);\n }\n }\n return result;\n}\n\n/**\n * Decodes the given byte array from UTF-8 into a string.\n * Throws if encoding is invalid.\n */\nexport function decode(arr: Uint8Array): string {\n const chars: string[] = [];\n for (let i = 0; i < arr.length; i++) {\n let b = arr[i];\n\n if (b & 0x80) {\n let min;\n if (b < 0xe0) {\n // Need 1 more byte.\n if (i >= arr.length) {\n throw new Error(INVALID_UTF8);\n }\n const n1 = arr[++i];\n if ((n1 & 0xc0) !== 0x80) {\n throw new Error(INVALID_UTF8);\n }\n b = (b & 0x1f) << 6 | (n1 & 0x3f);\n min = 0x80;\n } else if (b < 0xf0) {\n // Need 2 more bytes.\n if (i >= arr.length - 1) {\n throw new Error(INVALID_UTF8);\n }\n const n1 = arr[++i];\n const n2 = arr[++i];\n if ((n1 & 0xc0) !== 0x80 || (n2 & 0xc0) !== 0x80) {\n throw new Error(INVALID_UTF8);\n }\n b = (b & 0x0f) << 12 | (n1 & 0x3f) << 6 | (n2 & 0x3f);\n min = 0x800;\n } else if (b < 0xf8) {\n // Need 3 more bytes.\n if (i >= arr.length - 2) {\n throw new Error(INVALID_UTF8);\n }\n const n1 = arr[++i];\n const n2 = arr[++i];\n const n3 = arr[++i];\n if ((n1 & 0xc0) !== 0x80 || (n2 & 0xc0) !== 0x80 || (n3 & 0xc0) !== 0x80) {\n throw new Error(INVALID_UTF8);\n }\n b = (b & 0x0f) << 18 | (n1 & 0x3f) << 12 | (n2 & 0x3f) << 6 | (n3 & 0x3f);\n min = 0x10000;\n } else {\n throw new Error(INVALID_UTF8);\n }\n\n if (b < min || (b >= 0xd800 && b <= 0xdfff)) {\n throw new Error(INVALID_UTF8);\n }\n\n if (b >= 0x10000) {\n // Surrogate pair.\n if (b > 0x10ffff) {\n throw new Error(INVALID_UTF8);\n }\n b -= 0x10000;\n chars.push(String.fromCharCode(0xd800 | (b >> 10)));\n b = 0xdc00 | (b & 0x3ff);\n }\n }\n\n chars.push(String.fromCharCode(b));\n }\n return chars.join(\"\");\n}\n","(function(nacl) {\n'use strict';\n\n// Ported in 2014 by Dmitry Chestnykh and Devi Mandiri.\n// Public domain.\n//\n// Implementation derived from TweetNaCl version 20140427.\n// See for details: http://tweetnacl.cr.yp.to/\n\nvar gf = function(init) {\n var i, r = new Float64Array(16);\n if (init) for (i = 0; i < init.length; i++) r[i] = init[i];\n return r;\n};\n\n// Pluggable, initialized in high-level API below.\nvar randombytes = function(/* x, n */) { throw new Error('no PRNG'); };\n\nvar _0 = new Uint8Array(16);\nvar _9 = new Uint8Array(32); _9[0] = 9;\n\nvar gf0 = gf(),\n gf1 = gf([1]),\n _121665 = gf([0xdb41, 1]),\n D = gf([0x78a3, 0x1359, 0x4dca, 0x75eb, 0xd8ab, 0x4141, 0x0a4d, 0x0070, 0xe898, 0x7779, 0x4079, 0x8cc7, 0xfe73, 0x2b6f, 0x6cee, 0x5203]),\n D2 = gf([0xf159, 0x26b2, 0x9b94, 0xebd6, 0xb156, 0x8283, 0x149a, 0x00e0, 0xd130, 0xeef3, 0x80f2, 0x198e, 0xfce7, 0x56df, 0xd9dc, 0x2406]),\n X = gf([0xd51a, 0x8f25, 0x2d60, 0xc956, 0xa7b2, 0x9525, 0xc760, 0x692c, 0xdc5c, 0xfdd6, 0xe231, 0xc0a4, 0x53fe, 0xcd6e, 0x36d3, 0x2169]),\n Y = gf([0x6658, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666]),\n I = gf([0xa0b0, 0x4a0e, 0x1b27, 0xc4ee, 0xe478, 0xad2f, 0x1806, 0x2f43, 0xd7a7, 0x3dfb, 0x0099, 0x2b4d, 0xdf0b, 0x4fc1, 0x2480, 0x2b83]);\n\nfunction ts64(x, i, h, l) {\n x[i] = (h >> 24) & 0xff;\n x[i+1] = (h >> 16) & 0xff;\n x[i+2] = (h >> 8) & 0xff;\n x[i+3] = h & 0xff;\n x[i+4] = (l >> 24) & 0xff;\n x[i+5] = (l >> 16) & 0xff;\n x[i+6] = (l >> 8) & 0xff;\n x[i+7] = l & 0xff;\n}\n\nfunction vn(x, xi, y, yi, n) {\n var i,d = 0;\n for (i = 0; i < n; i++) d |= x[xi+i]^y[yi+i];\n return (1 & ((d - 1) >>> 8)) - 1;\n}\n\nfunction crypto_verify_16(x, xi, y, yi) {\n return vn(x,xi,y,yi,16);\n}\n\nfunction crypto_verify_32(x, xi, y, yi) {\n return vn(x,xi,y,yi,32);\n}\n\nfunction core_salsa20(o, p, k, c) {\n var j0 = c[ 0] & 0xff | (c[ 1] & 0xff)<<8 | (c[ 2] & 0xff)<<16 | (c[ 3] & 0xff)<<24,\n j1 = k[ 0] & 0xff | (k[ 1] & 0xff)<<8 | (k[ 2] & 0xff)<<16 | (k[ 3] & 0xff)<<24,\n j2 = k[ 4] & 0xff | (k[ 5] & 0xff)<<8 | (k[ 6] & 0xff)<<16 | (k[ 7] & 0xff)<<24,\n j3 = k[ 8] & 0xff | (k[ 9] & 0xff)<<8 | (k[10] & 0xff)<<16 | (k[11] & 0xff)<<24,\n j4 = k[12] & 0xff | (k[13] & 0xff)<<8 | (k[14] & 0xff)<<16 | (k[15] & 0xff)<<24,\n j5 = c[ 4] & 0xff | (c[ 5] & 0xff)<<8 | (c[ 6] & 0xff)<<16 | (c[ 7] & 0xff)<<24,\n j6 = p[ 0] & 0xff | (p[ 1] & 0xff)<<8 | (p[ 2] & 0xff)<<16 | (p[ 3] & 0xff)<<24,\n j7 = p[ 4] & 0xff | (p[ 5] & 0xff)<<8 | (p[ 6] & 0xff)<<16 | (p[ 7] & 0xff)<<24,\n j8 = p[ 8] & 0xff | (p[ 9] & 0xff)<<8 | (p[10] & 0xff)<<16 | (p[11] & 0xff)<<24,\n j9 = p[12] & 0xff | (p[13] & 0xff)<<8 | (p[14] & 0xff)<<16 | (p[15] & 0xff)<<24,\n j10 = c[ 8] & 0xff | (c[ 9] & 0xff)<<8 | (c[10] & 0xff)<<16 | (c[11] & 0xff)<<24,\n j11 = k[16] & 0xff | (k[17] & 0xff)<<8 | (k[18] & 0xff)<<16 | (k[19] & 0xff)<<24,\n j12 = k[20] & 0xff | (k[21] & 0xff)<<8 | (k[22] & 0xff)<<16 | (k[23] & 0xff)<<24,\n j13 = k[24] & 0xff | (k[25] & 0xff)<<8 | (k[26] & 0xff)<<16 | (k[27] & 0xff)<<24,\n j14 = k[28] & 0xff | (k[29] & 0xff)<<8 | (k[30] & 0xff)<<16 | (k[31] & 0xff)<<24,\n j15 = c[12] & 0xff | (c[13] & 0xff)<<8 | (c[14] & 0xff)<<16 | (c[15] & 0xff)<<24;\n\n var x0 = j0, x1 = j1, x2 = j2, x3 = j3, x4 = j4, x5 = j5, x6 = j6, x7 = j7,\n x8 = j8, x9 = j9, x10 = j10, x11 = j11, x12 = j12, x13 = j13, x14 = j14,\n x15 = j15, u;\n\n for (var i = 0; i < 20; i += 2) {\n u = x0 + x12 | 0;\n x4 ^= u<<7 | u>>>(32-7);\n u = x4 + x0 | 0;\n x8 ^= u<<9 | u>>>(32-9);\n u = x8 + x4 | 0;\n x12 ^= u<<13 | u>>>(32-13);\n u = x12 + x8 | 0;\n x0 ^= u<<18 | u>>>(32-18);\n\n u = x5 + x1 | 0;\n x9 ^= u<<7 | u>>>(32-7);\n u = x9 + x5 | 0;\n x13 ^= u<<9 | u>>>(32-9);\n u = x13 + x9 | 0;\n x1 ^= u<<13 | u>>>(32-13);\n u = x1 + x13 | 0;\n x5 ^= u<<18 | u>>>(32-18);\n\n u = x10 + x6 | 0;\n x14 ^= u<<7 | u>>>(32-7);\n u = x14 + x10 | 0;\n x2 ^= u<<9 | u>>>(32-9);\n u = x2 + x14 | 0;\n x6 ^= u<<13 | u>>>(32-13);\n u = x6 + x2 | 0;\n x10 ^= u<<18 | u>>>(32-18);\n\n u = x15 + x11 | 0;\n x3 ^= u<<7 | u>>>(32-7);\n u = x3 + x15 | 0;\n x7 ^= u<<9 | u>>>(32-9);\n u = x7 + x3 | 0;\n x11 ^= u<<13 | u>>>(32-13);\n u = x11 + x7 | 0;\n x15 ^= u<<18 | u>>>(32-18);\n\n u = x0 + x3 | 0;\n x1 ^= u<<7 | u>>>(32-7);\n u = x1 + x0 | 0;\n x2 ^= u<<9 | u>>>(32-9);\n u = x2 + x1 | 0;\n x3 ^= u<<13 | u>>>(32-13);\n u = x3 + x2 | 0;\n x0 ^= u<<18 | u>>>(32-18);\n\n u = x5 + x4 | 0;\n x6 ^= u<<7 | u>>>(32-7);\n u = x6 + x5 | 0;\n x7 ^= u<<9 | u>>>(32-9);\n u = x7 + x6 | 0;\n x4 ^= u<<13 | u>>>(32-13);\n u = x4 + x7 | 0;\n x5 ^= u<<18 | u>>>(32-18);\n\n u = x10 + x9 | 0;\n x11 ^= u<<7 | u>>>(32-7);\n u = x11 + x10 | 0;\n x8 ^= u<<9 | u>>>(32-9);\n u = x8 + x11 | 0;\n x9 ^= u<<13 | u>>>(32-13);\n u = x9 + x8 | 0;\n x10 ^= u<<18 | u>>>(32-18);\n\n u = x15 + x14 | 0;\n x12 ^= u<<7 | u>>>(32-7);\n u = x12 + x15 | 0;\n x13 ^= u<<9 | u>>>(32-9);\n u = x13 + x12 | 0;\n x14 ^= u<<13 | u>>>(32-13);\n u = x14 + x13 | 0;\n x15 ^= u<<18 | u>>>(32-18);\n }\n x0 = x0 + j0 | 0;\n x1 = x1 + j1 | 0;\n x2 = x2 + j2 | 0;\n x3 = x3 + j3 | 0;\n x4 = x4 + j4 | 0;\n x5 = x5 + j5 | 0;\n x6 = x6 + j6 | 0;\n x7 = x7 + j7 | 0;\n x8 = x8 + j8 | 0;\n x9 = x9 + j9 | 0;\n x10 = x10 + j10 | 0;\n x11 = x11 + j11 | 0;\n x12 = x12 + j12 | 0;\n x13 = x13 + j13 | 0;\n x14 = x14 + j14 | 0;\n x15 = x15 + j15 | 0;\n\n o[ 0] = x0 >>> 0 & 0xff;\n o[ 1] = x0 >>> 8 & 0xff;\n o[ 2] = x0 >>> 16 & 0xff;\n o[ 3] = x0 >>> 24 & 0xff;\n\n o[ 4] = x1 >>> 0 & 0xff;\n o[ 5] = x1 >>> 8 & 0xff;\n o[ 6] = x1 >>> 16 & 0xff;\n o[ 7] = x1 >>> 24 & 0xff;\n\n o[ 8] = x2 >>> 0 & 0xff;\n o[ 9] = x2 >>> 8 & 0xff;\n o[10] = x2 >>> 16 & 0xff;\n o[11] = x2 >>> 24 & 0xff;\n\n o[12] = x3 >>> 0 & 0xff;\n o[13] = x3 >>> 8 & 0xff;\n o[14] = x3 >>> 16 & 0xff;\n o[15] = x3 >>> 24 & 0xff;\n\n o[16] = x4 >>> 0 & 0xff;\n o[17] = x4 >>> 8 & 0xff;\n o[18] = x4 >>> 16 & 0xff;\n o[19] = x4 >>> 24 & 0xff;\n\n o[20] = x5 >>> 0 & 0xff;\n o[21] = x5 >>> 8 & 0xff;\n o[22] = x5 >>> 16 & 0xff;\n o[23] = x5 >>> 24 & 0xff;\n\n o[24] = x6 >>> 0 & 0xff;\n o[25] = x6 >>> 8 & 0xff;\n o[26] = x6 >>> 16 & 0xff;\n o[27] = x6 >>> 24 & 0xff;\n\n o[28] = x7 >>> 0 & 0xff;\n o[29] = x7 >>> 8 & 0xff;\n o[30] = x7 >>> 16 & 0xff;\n o[31] = x7 >>> 24 & 0xff;\n\n o[32] = x8 >>> 0 & 0xff;\n o[33] = x8 >>> 8 & 0xff;\n o[34] = x8 >>> 16 & 0xff;\n o[35] = x8 >>> 24 & 0xff;\n\n o[36] = x9 >>> 0 & 0xff;\n o[37] = x9 >>> 8 & 0xff;\n o[38] = x9 >>> 16 & 0xff;\n o[39] = x9 >>> 24 & 0xff;\n\n o[40] = x10 >>> 0 & 0xff;\n o[41] = x10 >>> 8 & 0xff;\n o[42] = x10 >>> 16 & 0xff;\n o[43] = x10 >>> 24 & 0xff;\n\n o[44] = x11 >>> 0 & 0xff;\n o[45] = x11 >>> 8 & 0xff;\n o[46] = x11 >>> 16 & 0xff;\n o[47] = x11 >>> 24 & 0xff;\n\n o[48] = x12 >>> 0 & 0xff;\n o[49] = x12 >>> 8 & 0xff;\n o[50] = x12 >>> 16 & 0xff;\n o[51] = x12 >>> 24 & 0xff;\n\n o[52] = x13 >>> 0 & 0xff;\n o[53] = x13 >>> 8 & 0xff;\n o[54] = x13 >>> 16 & 0xff;\n o[55] = x13 >>> 24 & 0xff;\n\n o[56] = x14 >>> 0 & 0xff;\n o[57] = x14 >>> 8 & 0xff;\n o[58] = x14 >>> 16 & 0xff;\n o[59] = x14 >>> 24 & 0xff;\n\n o[60] = x15 >>> 0 & 0xff;\n o[61] = x15 >>> 8 & 0xff;\n o[62] = x15 >>> 16 & 0xff;\n o[63] = x15 >>> 24 & 0xff;\n}\n\nfunction core_hsalsa20(o,p,k,c) {\n var j0 = c[ 0] & 0xff | (c[ 1] & 0xff)<<8 | (c[ 2] & 0xff)<<16 | (c[ 3] & 0xff)<<24,\n j1 = k[ 0] & 0xff | (k[ 1] & 0xff)<<8 | (k[ 2] & 0xff)<<16 | (k[ 3] & 0xff)<<24,\n j2 = k[ 4] & 0xff | (k[ 5] & 0xff)<<8 | (k[ 6] & 0xff)<<16 | (k[ 7] & 0xff)<<24,\n j3 = k[ 8] & 0xff | (k[ 9] & 0xff)<<8 | (k[10] & 0xff)<<16 | (k[11] & 0xff)<<24,\n j4 = k[12] & 0xff | (k[13] & 0xff)<<8 | (k[14] & 0xff)<<16 | (k[15] & 0xff)<<24,\n j5 = c[ 4] & 0xff | (c[ 5] & 0xff)<<8 | (c[ 6] & 0xff)<<16 | (c[ 7] & 0xff)<<24,\n j6 = p[ 0] & 0xff | (p[ 1] & 0xff)<<8 | (p[ 2] & 0xff)<<16 | (p[ 3] & 0xff)<<24,\n j7 = p[ 4] & 0xff | (p[ 5] & 0xff)<<8 | (p[ 6] & 0xff)<<16 | (p[ 7] & 0xff)<<24,\n j8 = p[ 8] & 0xff | (p[ 9] & 0xff)<<8 | (p[10] & 0xff)<<16 | (p[11] & 0xff)<<24,\n j9 = p[12] & 0xff | (p[13] & 0xff)<<8 | (p[14] & 0xff)<<16 | (p[15] & 0xff)<<24,\n j10 = c[ 8] & 0xff | (c[ 9] & 0xff)<<8 | (c[10] & 0xff)<<16 | (c[11] & 0xff)<<24,\n j11 = k[16] & 0xff | (k[17] & 0xff)<<8 | (k[18] & 0xff)<<16 | (k[19] & 0xff)<<24,\n j12 = k[20] & 0xff | (k[21] & 0xff)<<8 | (k[22] & 0xff)<<16 | (k[23] & 0xff)<<24,\n j13 = k[24] & 0xff | (k[25] & 0xff)<<8 | (k[26] & 0xff)<<16 | (k[27] & 0xff)<<24,\n j14 = k[28] & 0xff | (k[29] & 0xff)<<8 | (k[30] & 0xff)<<16 | (k[31] & 0xff)<<24,\n j15 = c[12] & 0xff | (c[13] & 0xff)<<8 | (c[14] & 0xff)<<16 | (c[15] & 0xff)<<24;\n\n var x0 = j0, x1 = j1, x2 = j2, x3 = j3, x4 = j4, x5 = j5, x6 = j6, x7 = j7,\n x8 = j8, x9 = j9, x10 = j10, x11 = j11, x12 = j12, x13 = j13, x14 = j14,\n x15 = j15, u;\n\n for (var i = 0; i < 20; i += 2) {\n u = x0 + x12 | 0;\n x4 ^= u<<7 | u>>>(32-7);\n u = x4 + x0 | 0;\n x8 ^= u<<9 | u>>>(32-9);\n u = x8 + x4 | 0;\n x12 ^= u<<13 | u>>>(32-13);\n u = x12 + x8 | 0;\n x0 ^= u<<18 | u>>>(32-18);\n\n u = x5 + x1 | 0;\n x9 ^= u<<7 | u>>>(32-7);\n u = x9 + x5 | 0;\n x13 ^= u<<9 | u>>>(32-9);\n u = x13 + x9 | 0;\n x1 ^= u<<13 | u>>>(32-13);\n u = x1 + x13 | 0;\n x5 ^= u<<18 | u>>>(32-18);\n\n u = x10 + x6 | 0;\n x14 ^= u<<7 | u>>>(32-7);\n u = x14 + x10 | 0;\n x2 ^= u<<9 | u>>>(32-9);\n u = x2 + x14 | 0;\n x6 ^= u<<13 | u>>>(32-13);\n u = x6 + x2 | 0;\n x10 ^= u<<18 | u>>>(32-18);\n\n u = x15 + x11 | 0;\n x3 ^= u<<7 | u>>>(32-7);\n u = x3 + x15 | 0;\n x7 ^= u<<9 | u>>>(32-9);\n u = x7 + x3 | 0;\n x11 ^= u<<13 | u>>>(32-13);\n u = x11 + x7 | 0;\n x15 ^= u<<18 | u>>>(32-18);\n\n u = x0 + x3 | 0;\n x1 ^= u<<7 | u>>>(32-7);\n u = x1 + x0 | 0;\n x2 ^= u<<9 | u>>>(32-9);\n u = x2 + x1 | 0;\n x3 ^= u<<13 | u>>>(32-13);\n u = x3 + x2 | 0;\n x0 ^= u<<18 | u>>>(32-18);\n\n u = x5 + x4 | 0;\n x6 ^= u<<7 | u>>>(32-7);\n u = x6 + x5 | 0;\n x7 ^= u<<9 | u>>>(32-9);\n u = x7 + x6 | 0;\n x4 ^= u<<13 | u>>>(32-13);\n u = x4 + x7 | 0;\n x5 ^= u<<18 | u>>>(32-18);\n\n u = x10 + x9 | 0;\n x11 ^= u<<7 | u>>>(32-7);\n u = x11 + x10 | 0;\n x8 ^= u<<9 | u>>>(32-9);\n u = x8 + x11 | 0;\n x9 ^= u<<13 | u>>>(32-13);\n u = x9 + x8 | 0;\n x10 ^= u<<18 | u>>>(32-18);\n\n u = x15 + x14 | 0;\n x12 ^= u<<7 | u>>>(32-7);\n u = x12 + x15 | 0;\n x13 ^= u<<9 | u>>>(32-9);\n u = x13 + x12 | 0;\n x14 ^= u<<13 | u>>>(32-13);\n u = x14 + x13 | 0;\n x15 ^= u<<18 | u>>>(32-18);\n }\n\n o[ 0] = x0 >>> 0 & 0xff;\n o[ 1] = x0 >>> 8 & 0xff;\n o[ 2] = x0 >>> 16 & 0xff;\n o[ 3] = x0 >>> 24 & 0xff;\n\n o[ 4] = x5 >>> 0 & 0xff;\n o[ 5] = x5 >>> 8 & 0xff;\n o[ 6] = x5 >>> 16 & 0xff;\n o[ 7] = x5 >>> 24 & 0xff;\n\n o[ 8] = x10 >>> 0 & 0xff;\n o[ 9] = x10 >>> 8 & 0xff;\n o[10] = x10 >>> 16 & 0xff;\n o[11] = x10 >>> 24 & 0xff;\n\n o[12] = x15 >>> 0 & 0xff;\n o[13] = x15 >>> 8 & 0xff;\n o[14] = x15 >>> 16 & 0xff;\n o[15] = x15 >>> 24 & 0xff;\n\n o[16] = x6 >>> 0 & 0xff;\n o[17] = x6 >>> 8 & 0xff;\n o[18] = x6 >>> 16 & 0xff;\n o[19] = x6 >>> 24 & 0xff;\n\n o[20] = x7 >>> 0 & 0xff;\n o[21] = x7 >>> 8 & 0xff;\n o[22] = x7 >>> 16 & 0xff;\n o[23] = x7 >>> 24 & 0xff;\n\n o[24] = x8 >>> 0 & 0xff;\n o[25] = x8 >>> 8 & 0xff;\n o[26] = x8 >>> 16 & 0xff;\n o[27] = x8 >>> 24 & 0xff;\n\n o[28] = x9 >>> 0 & 0xff;\n o[29] = x9 >>> 8 & 0xff;\n o[30] = x9 >>> 16 & 0xff;\n o[31] = x9 >>> 24 & 0xff;\n}\n\nfunction crypto_core_salsa20(out,inp,k,c) {\n core_salsa20(out,inp,k,c);\n}\n\nfunction crypto_core_hsalsa20(out,inp,k,c) {\n core_hsalsa20(out,inp,k,c);\n}\n\nvar sigma = new Uint8Array([101, 120, 112, 97, 110, 100, 32, 51, 50, 45, 98, 121, 116, 101, 32, 107]);\n // \"expand 32-byte k\"\n\nfunction crypto_stream_salsa20_xor(c,cpos,m,mpos,b,n,k) {\n var z = new Uint8Array(16), x = new Uint8Array(64);\n var u, i;\n for (i = 0; i < 16; i++) z[i] = 0;\n for (i = 0; i < 8; i++) z[i] = n[i];\n while (b >= 64) {\n crypto_core_salsa20(x,z,k,sigma);\n for (i = 0; i < 64; i++) c[cpos+i] = m[mpos+i] ^ x[i];\n u = 1;\n for (i = 8; i < 16; i++) {\n u = u + (z[i] & 0xff) | 0;\n z[i] = u & 0xff;\n u >>>= 8;\n }\n b -= 64;\n cpos += 64;\n mpos += 64;\n }\n if (b > 0) {\n crypto_core_salsa20(x,z,k,sigma);\n for (i = 0; i < b; i++) c[cpos+i] = m[mpos+i] ^ x[i];\n }\n return 0;\n}\n\nfunction crypto_stream_salsa20(c,cpos,b,n,k) {\n var z = new Uint8Array(16), x = new Uint8Array(64);\n var u, i;\n for (i = 0; i < 16; i++) z[i] = 0;\n for (i = 0; i < 8; i++) z[i] = n[i];\n while (b >= 64) {\n crypto_core_salsa20(x,z,k,sigma);\n for (i = 0; i < 64; i++) c[cpos+i] = x[i];\n u = 1;\n for (i = 8; i < 16; i++) {\n u = u + (z[i] & 0xff) | 0;\n z[i] = u & 0xff;\n u >>>= 8;\n }\n b -= 64;\n cpos += 64;\n }\n if (b > 0) {\n crypto_core_salsa20(x,z,k,sigma);\n for (i = 0; i < b; i++) c[cpos+i] = x[i];\n }\n return 0;\n}\n\nfunction crypto_stream(c,cpos,d,n,k) {\n var s = new Uint8Array(32);\n crypto_core_hsalsa20(s,n,k,sigma);\n var sn = new Uint8Array(8);\n for (var i = 0; i < 8; i++) sn[i] = n[i+16];\n return crypto_stream_salsa20(c,cpos,d,sn,s);\n}\n\nfunction crypto_stream_xor(c,cpos,m,mpos,d,n,k) {\n var s = new Uint8Array(32);\n crypto_core_hsalsa20(s,n,k,sigma);\n var sn = new Uint8Array(8);\n for (var i = 0; i < 8; i++) sn[i] = n[i+16];\n return crypto_stream_salsa20_xor(c,cpos,m,mpos,d,sn,s);\n}\n\n/*\n* Port of Andrew Moon's Poly1305-donna-16. Public domain.\n* https://github.com/floodyberry/poly1305-donna\n*/\n\nvar poly1305 = function(key) {\n this.buffer = new Uint8Array(16);\n this.r = new Uint16Array(10);\n this.h = new Uint16Array(10);\n this.pad = new Uint16Array(8);\n this.leftover = 0;\n this.fin = 0;\n\n var t0, t1, t2, t3, t4, t5, t6, t7;\n\n t0 = key[ 0] & 0xff | (key[ 1] & 0xff) << 8; this.r[0] = ( t0 ) & 0x1fff;\n t1 = key[ 2] & 0xff | (key[ 3] & 0xff) << 8; this.r[1] = ((t0 >>> 13) | (t1 << 3)) & 0x1fff;\n t2 = key[ 4] & 0xff | (key[ 5] & 0xff) << 8; this.r[2] = ((t1 >>> 10) | (t2 << 6)) & 0x1f03;\n t3 = key[ 6] & 0xff | (key[ 7] & 0xff) << 8; this.r[3] = ((t2 >>> 7) | (t3 << 9)) & 0x1fff;\n t4 = key[ 8] & 0xff | (key[ 9] & 0xff) << 8; this.r[4] = ((t3 >>> 4) | (t4 << 12)) & 0x00ff;\n this.r[5] = ((t4 >>> 1)) & 0x1ffe;\n t5 = key[10] & 0xff | (key[11] & 0xff) << 8; this.r[6] = ((t4 >>> 14) | (t5 << 2)) & 0x1fff;\n t6 = key[12] & 0xff | (key[13] & 0xff) << 8; this.r[7] = ((t5 >>> 11) | (t6 << 5)) & 0x1f81;\n t7 = key[14] & 0xff | (key[15] & 0xff) << 8; this.r[8] = ((t6 >>> 8) | (t7 << 8)) & 0x1fff;\n this.r[9] = ((t7 >>> 5)) & 0x007f;\n\n this.pad[0] = key[16] & 0xff | (key[17] & 0xff) << 8;\n this.pad[1] = key[18] & 0xff | (key[19] & 0xff) << 8;\n this.pad[2] = key[20] & 0xff | (key[21] & 0xff) << 8;\n this.pad[3] = key[22] & 0xff | (key[23] & 0xff) << 8;\n this.pad[4] = key[24] & 0xff | (key[25] & 0xff) << 8;\n this.pad[5] = key[26] & 0xff | (key[27] & 0xff) << 8;\n this.pad[6] = key[28] & 0xff | (key[29] & 0xff) << 8;\n this.pad[7] = key[30] & 0xff | (key[31] & 0xff) << 8;\n};\n\npoly1305.prototype.blocks = function(m, mpos, bytes) {\n var hibit = this.fin ? 0 : (1 << 11);\n var t0, t1, t2, t3, t4, t5, t6, t7, c;\n var d0, d1, d2, d3, d4, d5, d6, d7, d8, d9;\n\n var h0 = this.h[0],\n h1 = this.h[1],\n h2 = this.h[2],\n h3 = this.h[3],\n h4 = this.h[4],\n h5 = this.h[5],\n h6 = this.h[6],\n h7 = this.h[7],\n h8 = this.h[8],\n h9 = this.h[9];\n\n var r0 = this.r[0],\n r1 = this.r[1],\n r2 = this.r[2],\n r3 = this.r[3],\n r4 = this.r[4],\n r5 = this.r[5],\n r6 = this.r[6],\n r7 = this.r[7],\n r8 = this.r[8],\n r9 = this.r[9];\n\n while (bytes >= 16) {\n t0 = m[mpos+ 0] & 0xff | (m[mpos+ 1] & 0xff) << 8; h0 += ( t0 ) & 0x1fff;\n t1 = m[mpos+ 2] & 0xff | (m[mpos+ 3] & 0xff) << 8; h1 += ((t0 >>> 13) | (t1 << 3)) & 0x1fff;\n t2 = m[mpos+ 4] & 0xff | (m[mpos+ 5] & 0xff) << 8; h2 += ((t1 >>> 10) | (t2 << 6)) & 0x1fff;\n t3 = m[mpos+ 6] & 0xff | (m[mpos+ 7] & 0xff) << 8; h3 += ((t2 >>> 7) | (t3 << 9)) & 0x1fff;\n t4 = m[mpos+ 8] & 0xff | (m[mpos+ 9] & 0xff) << 8; h4 += ((t3 >>> 4) | (t4 << 12)) & 0x1fff;\n h5 += ((t4 >>> 1)) & 0x1fff;\n t5 = m[mpos+10] & 0xff | (m[mpos+11] & 0xff) << 8; h6 += ((t4 >>> 14) | (t5 << 2)) & 0x1fff;\n t6 = m[mpos+12] & 0xff | (m[mpos+13] & 0xff) << 8; h7 += ((t5 >>> 11) | (t6 << 5)) & 0x1fff;\n t7 = m[mpos+14] & 0xff | (m[mpos+15] & 0xff) << 8; h8 += ((t6 >>> 8) | (t7 << 8)) & 0x1fff;\n h9 += ((t7 >>> 5)) | hibit;\n\n c = 0;\n\n d0 = c;\n d0 += h0 * r0;\n d0 += h1 * (5 * r9);\n d0 += h2 * (5 * r8);\n d0 += h3 * (5 * r7);\n d0 += h4 * (5 * r6);\n c = (d0 >>> 13); d0 &= 0x1fff;\n d0 += h5 * (5 * r5);\n d0 += h6 * (5 * r4);\n d0 += h7 * (5 * r3);\n d0 += h8 * (5 * r2);\n d0 += h9 * (5 * r1);\n c += (d0 >>> 13); d0 &= 0x1fff;\n\n d1 = c;\n d1 += h0 * r1;\n d1 += h1 * r0;\n d1 += h2 * (5 * r9);\n d1 += h3 * (5 * r8);\n d1 += h4 * (5 * r7);\n c = (d1 >>> 13); d1 &= 0x1fff;\n d1 += h5 * (5 * r6);\n d1 += h6 * (5 * r5);\n d1 += h7 * (5 * r4);\n d1 += h8 * (5 * r3);\n d1 += h9 * (5 * r2);\n c += (d1 >>> 13); d1 &= 0x1fff;\n\n d2 = c;\n d2 += h0 * r2;\n d2 += h1 * r1;\n d2 += h2 * r0;\n d2 += h3 * (5 * r9);\n d2 += h4 * (5 * r8);\n c = (d2 >>> 13); d2 &= 0x1fff;\n d2 += h5 * (5 * r7);\n d2 += h6 * (5 * r6);\n d2 += h7 * (5 * r5);\n d2 += h8 * (5 * r4);\n d2 += h9 * (5 * r3);\n c += (d2 >>> 13); d2 &= 0x1fff;\n\n d3 = c;\n d3 += h0 * r3;\n d3 += h1 * r2;\n d3 += h2 * r1;\n d3 += h3 * r0;\n d3 += h4 * (5 * r9);\n c = (d3 >>> 13); d3 &= 0x1fff;\n d3 += h5 * (5 * r8);\n d3 += h6 * (5 * r7);\n d3 += h7 * (5 * r6);\n d3 += h8 * (5 * r5);\n d3 += h9 * (5 * r4);\n c += (d3 >>> 13); d3 &= 0x1fff;\n\n d4 = c;\n d4 += h0 * r4;\n d4 += h1 * r3;\n d4 += h2 * r2;\n d4 += h3 * r1;\n d4 += h4 * r0;\n c = (d4 >>> 13); d4 &= 0x1fff;\n d4 += h5 * (5 * r9);\n d4 += h6 * (5 * r8);\n d4 += h7 * (5 * r7);\n d4 += h8 * (5 * r6);\n d4 += h9 * (5 * r5);\n c += (d4 >>> 13); d4 &= 0x1fff;\n\n d5 = c;\n d5 += h0 * r5;\n d5 += h1 * r4;\n d5 += h2 * r3;\n d5 += h3 * r2;\n d5 += h4 * r1;\n c = (d5 >>> 13); d5 &= 0x1fff;\n d5 += h5 * r0;\n d5 += h6 * (5 * r9);\n d5 += h7 * (5 * r8);\n d5 += h8 * (5 * r7);\n d5 += h9 * (5 * r6);\n c += (d5 >>> 13); d5 &= 0x1fff;\n\n d6 = c;\n d6 += h0 * r6;\n d6 += h1 * r5;\n d6 += h2 * r4;\n d6 += h3 * r3;\n d6 += h4 * r2;\n c = (d6 >>> 13); d6 &= 0x1fff;\n d6 += h5 * r1;\n d6 += h6 * r0;\n d6 += h7 * (5 * r9);\n d6 += h8 * (5 * r8);\n d6 += h9 * (5 * r7);\n c += (d6 >>> 13); d6 &= 0x1fff;\n\n d7 = c;\n d7 += h0 * r7;\n d7 += h1 * r6;\n d7 += h2 * r5;\n d7 += h3 * r4;\n d7 += h4 * r3;\n c = (d7 >>> 13); d7 &= 0x1fff;\n d7 += h5 * r2;\n d7 += h6 * r1;\n d7 += h7 * r0;\n d7 += h8 * (5 * r9);\n d7 += h9 * (5 * r8);\n c += (d7 >>> 13); d7 &= 0x1fff;\n\n d8 = c;\n d8 += h0 * r8;\n d8 += h1 * r7;\n d8 += h2 * r6;\n d8 += h3 * r5;\n d8 += h4 * r4;\n c = (d8 >>> 13); d8 &= 0x1fff;\n d8 += h5 * r3;\n d8 += h6 * r2;\n d8 += h7 * r1;\n d8 += h8 * r0;\n d8 += h9 * (5 * r9);\n c += (d8 >>> 13); d8 &= 0x1fff;\n\n d9 = c;\n d9 += h0 * r9;\n d9 += h1 * r8;\n d9 += h2 * r7;\n d9 += h3 * r6;\n d9 += h4 * r5;\n c = (d9 >>> 13); d9 &= 0x1fff;\n d9 += h5 * r4;\n d9 += h6 * r3;\n d9 += h7 * r2;\n d9 += h8 * r1;\n d9 += h9 * r0;\n c += (d9 >>> 13); d9 &= 0x1fff;\n\n c = (((c << 2) + c)) | 0;\n c = (c + d0) | 0;\n d0 = c & 0x1fff;\n c = (c >>> 13);\n d1 += c;\n\n h0 = d0;\n h1 = d1;\n h2 = d2;\n h3 = d3;\n h4 = d4;\n h5 = d5;\n h6 = d6;\n h7 = d7;\n h8 = d8;\n h9 = d9;\n\n mpos += 16;\n bytes -= 16;\n }\n this.h[0] = h0;\n this.h[1] = h1;\n this.h[2] = h2;\n this.h[3] = h3;\n this.h[4] = h4;\n this.h[5] = h5;\n this.h[6] = h6;\n this.h[7] = h7;\n this.h[8] = h8;\n this.h[9] = h9;\n};\n\npoly1305.prototype.finish = function(mac, macpos) {\n var g = new Uint16Array(10);\n var c, mask, f, i;\n\n if (this.leftover) {\n i = this.leftover;\n this.buffer[i++] = 1;\n for (; i < 16; i++) this.buffer[i] = 0;\n this.fin = 1;\n this.blocks(this.buffer, 0, 16);\n }\n\n c = this.h[1] >>> 13;\n this.h[1] &= 0x1fff;\n for (i = 2; i < 10; i++) {\n this.h[i] += c;\n c = this.h[i] >>> 13;\n this.h[i] &= 0x1fff;\n }\n this.h[0] += (c * 5);\n c = this.h[0] >>> 13;\n this.h[0] &= 0x1fff;\n this.h[1] += c;\n c = this.h[1] >>> 13;\n this.h[1] &= 0x1fff;\n this.h[2] += c;\n\n g[0] = this.h[0] + 5;\n c = g[0] >>> 13;\n g[0] &= 0x1fff;\n for (i = 1; i < 10; i++) {\n g[i] = this.h[i] + c;\n c = g[i] >>> 13;\n g[i] &= 0x1fff;\n }\n g[9] -= (1 << 13);\n\n mask = (c ^ 1) - 1;\n for (i = 0; i < 10; i++) g[i] &= mask;\n mask = ~mask;\n for (i = 0; i < 10; i++) this.h[i] = (this.h[i] & mask) | g[i];\n\n this.h[0] = ((this.h[0] ) | (this.h[1] << 13) ) & 0xffff;\n this.h[1] = ((this.h[1] >>> 3) | (this.h[2] << 10) ) & 0xffff;\n this.h[2] = ((this.h[2] >>> 6) | (this.h[3] << 7) ) & 0xffff;\n this.h[3] = ((this.h[3] >>> 9) | (this.h[4] << 4) ) & 0xffff;\n this.h[4] = ((this.h[4] >>> 12) | (this.h[5] << 1) | (this.h[6] << 14)) & 0xffff;\n this.h[5] = ((this.h[6] >>> 2) | (this.h[7] << 11) ) & 0xffff;\n this.h[6] = ((this.h[7] >>> 5) | (this.h[8] << 8) ) & 0xffff;\n this.h[7] = ((this.h[8] >>> 8) | (this.h[9] << 5) ) & 0xffff;\n\n f = this.h[0] + this.pad[0];\n this.h[0] = f & 0xffff;\n for (i = 1; i < 8; i++) {\n f = (((this.h[i] + this.pad[i]) | 0) + (f >>> 16)) | 0;\n this.h[i] = f & 0xffff;\n }\n\n mac[macpos+ 0] = (this.h[0] >>> 0) & 0xff;\n mac[macpos+ 1] = (this.h[0] >>> 8) & 0xff;\n mac[macpos+ 2] = (this.h[1] >>> 0) & 0xff;\n mac[macpos+ 3] = (this.h[1] >>> 8) & 0xff;\n mac[macpos+ 4] = (this.h[2] >>> 0) & 0xff;\n mac[macpos+ 5] = (this.h[2] >>> 8) & 0xff;\n mac[macpos+ 6] = (this.h[3] >>> 0) & 0xff;\n mac[macpos+ 7] = (this.h[3] >>> 8) & 0xff;\n mac[macpos+ 8] = (this.h[4] >>> 0) & 0xff;\n mac[macpos+ 9] = (this.h[4] >>> 8) & 0xff;\n mac[macpos+10] = (this.h[5] >>> 0) & 0xff;\n mac[macpos+11] = (this.h[5] >>> 8) & 0xff;\n mac[macpos+12] = (this.h[6] >>> 0) & 0xff;\n mac[macpos+13] = (this.h[6] >>> 8) & 0xff;\n mac[macpos+14] = (this.h[7] >>> 0) & 0xff;\n mac[macpos+15] = (this.h[7] >>> 8) & 0xff;\n};\n\npoly1305.prototype.update = function(m, mpos, bytes) {\n var i, want;\n\n if (this.leftover) {\n want = (16 - this.leftover);\n if (want > bytes)\n want = bytes;\n for (i = 0; i < want; i++)\n this.buffer[this.leftover + i] = m[mpos+i];\n bytes -= want;\n mpos += want;\n this.leftover += want;\n if (this.leftover < 16)\n return;\n this.blocks(this.buffer, 0, 16);\n this.leftover = 0;\n }\n\n if (bytes >= 16) {\n want = bytes - (bytes % 16);\n this.blocks(m, mpos, want);\n mpos += want;\n bytes -= want;\n }\n\n if (bytes) {\n for (i = 0; i < bytes; i++)\n this.buffer[this.leftover + i] = m[mpos+i];\n this.leftover += bytes;\n }\n};\n\nfunction crypto_onetimeauth(out, outpos, m, mpos, n, k) {\n var s = new poly1305(k);\n s.update(m, mpos, n);\n s.finish(out, outpos);\n return 0;\n}\n\nfunction crypto_onetimeauth_verify(h, hpos, m, mpos, n, k) {\n var x = new Uint8Array(16);\n crypto_onetimeauth(x,0,m,mpos,n,k);\n return crypto_verify_16(h,hpos,x,0);\n}\n\nfunction crypto_secretbox(c,m,d,n,k) {\n var i;\n if (d < 32) return -1;\n crypto_stream_xor(c,0,m,0,d,n,k);\n crypto_onetimeauth(c, 16, c, 32, d - 32, c);\n for (i = 0; i < 16; i++) c[i] = 0;\n return 0;\n}\n\nfunction crypto_secretbox_open(m,c,d,n,k) {\n var i;\n var x = new Uint8Array(32);\n if (d < 32) return -1;\n crypto_stream(x,0,32,n,k);\n if (crypto_onetimeauth_verify(c, 16,c, 32,d - 32,x) !== 0) return -1;\n crypto_stream_xor(m,0,c,0,d,n,k);\n for (i = 0; i < 32; i++) m[i] = 0;\n return 0;\n}\n\nfunction set25519(r, a) {\n var i;\n for (i = 0; i < 16; i++) r[i] = a[i]|0;\n}\n\nfunction car25519(o) {\n var i, v, c = 1;\n for (i = 0; i < 16; i++) {\n v = o[i] + c + 65535;\n c = Math.floor(v / 65536);\n o[i] = v - c * 65536;\n }\n o[0] += c-1 + 37 * (c-1);\n}\n\nfunction sel25519(p, q, b) {\n var t, c = ~(b-1);\n for (var i = 0; i < 16; i++) {\n t = c & (p[i] ^ q[i]);\n p[i] ^= t;\n q[i] ^= t;\n }\n}\n\nfunction pack25519(o, n) {\n var i, j, b;\n var m = gf(), t = gf();\n for (i = 0; i < 16; i++) t[i] = n[i];\n car25519(t);\n car25519(t);\n car25519(t);\n for (j = 0; j < 2; j++) {\n m[0] = t[0] - 0xffed;\n for (i = 1; i < 15; i++) {\n m[i] = t[i] - 0xffff - ((m[i-1]>>16) & 1);\n m[i-1] &= 0xffff;\n }\n m[15] = t[15] - 0x7fff - ((m[14]>>16) & 1);\n b = (m[15]>>16) & 1;\n m[14] &= 0xffff;\n sel25519(t, m, 1-b);\n }\n for (i = 0; i < 16; i++) {\n o[2*i] = t[i] & 0xff;\n o[2*i+1] = t[i]>>8;\n }\n}\n\nfunction neq25519(a, b) {\n var c = new Uint8Array(32), d = new Uint8Array(32);\n pack25519(c, a);\n pack25519(d, b);\n return crypto_verify_32(c, 0, d, 0);\n}\n\nfunction par25519(a) {\n var d = new Uint8Array(32);\n pack25519(d, a);\n return d[0] & 1;\n}\n\nfunction unpack25519(o, n) {\n var i;\n for (i = 0; i < 16; i++) o[i] = n[2*i] + (n[2*i+1] << 8);\n o[15] &= 0x7fff;\n}\n\nfunction A(o, a, b) {\n for (var i = 0; i < 16; i++) o[i] = a[i] + b[i];\n}\n\nfunction Z(o, a, b) {\n for (var i = 0; i < 16; i++) o[i] = a[i] - b[i];\n}\n\nfunction M(o, a, b) {\n var v, c,\n t0 = 0, t1 = 0, t2 = 0, t3 = 0, t4 = 0, t5 = 0, t6 = 0, t7 = 0,\n t8 = 0, t9 = 0, t10 = 0, t11 = 0, t12 = 0, t13 = 0, t14 = 0, t15 = 0,\n t16 = 0, t17 = 0, t18 = 0, t19 = 0, t20 = 0, t21 = 0, t22 = 0, t23 = 0,\n t24 = 0, t25 = 0, t26 = 0, t27 = 0, t28 = 0, t29 = 0, t30 = 0,\n b0 = b[0],\n b1 = b[1],\n b2 = b[2],\n b3 = b[3],\n b4 = b[4],\n b5 = b[5],\n b6 = b[6],\n b7 = b[7],\n b8 = b[8],\n b9 = b[9],\n b10 = b[10],\n b11 = b[11],\n b12 = b[12],\n b13 = b[13],\n b14 = b[14],\n b15 = b[15];\n\n v = a[0];\n t0 += v * b0;\n t1 += v * b1;\n t2 += v * b2;\n t3 += v * b3;\n t4 += v * b4;\n t5 += v * b5;\n t6 += v * b6;\n t7 += v * b7;\n t8 += v * b8;\n t9 += v * b9;\n t10 += v * b10;\n t11 += v * b11;\n t12 += v * b12;\n t13 += v * b13;\n t14 += v * b14;\n t15 += v * b15;\n v = a[1];\n t1 += v * b0;\n t2 += v * b1;\n t3 += v * b2;\n t4 += v * b3;\n t5 += v * b4;\n t6 += v * b5;\n t7 += v * b6;\n t8 += v * b7;\n t9 += v * b8;\n t10 += v * b9;\n t11 += v * b10;\n t12 += v * b11;\n t13 += v * b12;\n t14 += v * b13;\n t15 += v * b14;\n t16 += v * b15;\n v = a[2];\n t2 += v * b0;\n t3 += v * b1;\n t4 += v * b2;\n t5 += v * b3;\n t6 += v * b4;\n t7 += v * b5;\n t8 += v * b6;\n t9 += v * b7;\n t10 += v * b8;\n t11 += v * b9;\n t12 += v * b10;\n t13 += v * b11;\n t14 += v * b12;\n t15 += v * b13;\n t16 += v * b14;\n t17 += v * b15;\n v = a[3];\n t3 += v * b0;\n t4 += v * b1;\n t5 += v * b2;\n t6 += v * b3;\n t7 += v * b4;\n t8 += v * b5;\n t9 += v * b6;\n t10 += v * b7;\n t11 += v * b8;\n t12 += v * b9;\n t13 += v * b10;\n t14 += v * b11;\n t15 += v * b12;\n t16 += v * b13;\n t17 += v * b14;\n t18 += v * b15;\n v = a[4];\n t4 += v * b0;\n t5 += v * b1;\n t6 += v * b2;\n t7 += v * b3;\n t8 += v * b4;\n t9 += v * b5;\n t10 += v * b6;\n t11 += v * b7;\n t12 += v * b8;\n t13 += v * b9;\n t14 += v * b10;\n t15 += v * b11;\n t16 += v * b12;\n t17 += v * b13;\n t18 += v * b14;\n t19 += v * b15;\n v = a[5];\n t5 += v * b0;\n t6 += v * b1;\n t7 += v * b2;\n t8 += v * b3;\n t9 += v * b4;\n t10 += v * b5;\n t11 += v * b6;\n t12 += v * b7;\n t13 += v * b8;\n t14 += v * b9;\n t15 += v * b10;\n t16 += v * b11;\n t17 += v * b12;\n t18 += v * b13;\n t19 += v * b14;\n t20 += v * b15;\n v = a[6];\n t6 += v * b0;\n t7 += v * b1;\n t8 += v * b2;\n t9 += v * b3;\n t10 += v * b4;\n t11 += v * b5;\n t12 += v * b6;\n t13 += v * b7;\n t14 += v * b8;\n t15 += v * b9;\n t16 += v * b10;\n t17 += v * b11;\n t18 += v * b12;\n t19 += v * b13;\n t20 += v * b14;\n t21 += v * b15;\n v = a[7];\n t7 += v * b0;\n t8 += v * b1;\n t9 += v * b2;\n t10 += v * b3;\n t11 += v * b4;\n t12 += v * b5;\n t13 += v * b6;\n t14 += v * b7;\n t15 += v * b8;\n t16 += v * b9;\n t17 += v * b10;\n t18 += v * b11;\n t19 += v * b12;\n t20 += v * b13;\n t21 += v * b14;\n t22 += v * b15;\n v = a[8];\n t8 += v * b0;\n t9 += v * b1;\n t10 += v * b2;\n t11 += v * b3;\n t12 += v * b4;\n t13 += v * b5;\n t14 += v * b6;\n t15 += v * b7;\n t16 += v * b8;\n t17 += v * b9;\n t18 += v * b10;\n t19 += v * b11;\n t20 += v * b12;\n t21 += v * b13;\n t22 += v * b14;\n t23 += v * b15;\n v = a[9];\n t9 += v * b0;\n t10 += v * b1;\n t11 += v * b2;\n t12 += v * b3;\n t13 += v * b4;\n t14 += v * b5;\n t15 += v * b6;\n t16 += v * b7;\n t17 += v * b8;\n t18 += v * b9;\n t19 += v * b10;\n t20 += v * b11;\n t21 += v * b12;\n t22 += v * b13;\n t23 += v * b14;\n t24 += v * b15;\n v = a[10];\n t10 += v * b0;\n t11 += v * b1;\n t12 += v * b2;\n t13 += v * b3;\n t14 += v * b4;\n t15 += v * b5;\n t16 += v * b6;\n t17 += v * b7;\n t18 += v * b8;\n t19 += v * b9;\n t20 += v * b10;\n t21 += v * b11;\n t22 += v * b12;\n t23 += v * b13;\n t24 += v * b14;\n t25 += v * b15;\n v = a[11];\n t11 += v * b0;\n t12 += v * b1;\n t13 += v * b2;\n t14 += v * b3;\n t15 += v * b4;\n t16 += v * b5;\n t17 += v * b6;\n t18 += v * b7;\n t19 += v * b8;\n t20 += v * b9;\n t21 += v * b10;\n t22 += v * b11;\n t23 += v * b12;\n t24 += v * b13;\n t25 += v * b14;\n t26 += v * b15;\n v = a[12];\n t12 += v * b0;\n t13 += v * b1;\n t14 += v * b2;\n t15 += v * b3;\n t16 += v * b4;\n t17 += v * b5;\n t18 += v * b6;\n t19 += v * b7;\n t20 += v * b8;\n t21 += v * b9;\n t22 += v * b10;\n t23 += v * b11;\n t24 += v * b12;\n t25 += v * b13;\n t26 += v * b14;\n t27 += v * b15;\n v = a[13];\n t13 += v * b0;\n t14 += v * b1;\n t15 += v * b2;\n t16 += v * b3;\n t17 += v * b4;\n t18 += v * b5;\n t19 += v * b6;\n t20 += v * b7;\n t21 += v * b8;\n t22 += v * b9;\n t23 += v * b10;\n t24 += v * b11;\n t25 += v * b12;\n t26 += v * b13;\n t27 += v * b14;\n t28 += v * b15;\n v = a[14];\n t14 += v * b0;\n t15 += v * b1;\n t16 += v * b2;\n t17 += v * b3;\n t18 += v * b4;\n t19 += v * b5;\n t20 += v * b6;\n t21 += v * b7;\n t22 += v * b8;\n t23 += v * b9;\n t24 += v * b10;\n t25 += v * b11;\n t26 += v * b12;\n t27 += v * b13;\n t28 += v * b14;\n t29 += v * b15;\n v = a[15];\n t15 += v * b0;\n t16 += v * b1;\n t17 += v * b2;\n t18 += v * b3;\n t19 += v * b4;\n t20 += v * b5;\n t21 += v * b6;\n t22 += v * b7;\n t23 += v * b8;\n t24 += v * b9;\n t25 += v * b10;\n t26 += v * b11;\n t27 += v * b12;\n t28 += v * b13;\n t29 += v * b14;\n t30 += v * b15;\n\n t0 += 38 * t16;\n t1 += 38 * t17;\n t2 += 38 * t18;\n t3 += 38 * t19;\n t4 += 38 * t20;\n t5 += 38 * t21;\n t6 += 38 * t22;\n t7 += 38 * t23;\n t8 += 38 * t24;\n t9 += 38 * t25;\n t10 += 38 * t26;\n t11 += 38 * t27;\n t12 += 38 * t28;\n t13 += 38 * t29;\n t14 += 38 * t30;\n // t15 left as is\n\n // first car\n c = 1;\n v = t0 + c + 65535; c = Math.floor(v / 65536); t0 = v - c * 65536;\n v = t1 + c + 65535; c = Math.floor(v / 65536); t1 = v - c * 65536;\n v = t2 + c + 65535; c = Math.floor(v / 65536); t2 = v - c * 65536;\n v = t3 + c + 65535; c = Math.floor(v / 65536); t3 = v - c * 65536;\n v = t4 + c + 65535; c = Math.floor(v / 65536); t4 = v - c * 65536;\n v = t5 + c + 65535; c = Math.floor(v / 65536); t5 = v - c * 65536;\n v = t6 + c + 65535; c = Math.floor(v / 65536); t6 = v - c * 65536;\n v = t7 + c + 65535; c = Math.floor(v / 65536); t7 = v - c * 65536;\n v = t8 + c + 65535; c = Math.floor(v / 65536); t8 = v - c * 65536;\n v = t9 + c + 65535; c = Math.floor(v / 65536); t9 = v - c * 65536;\n v = t10 + c + 65535; c = Math.floor(v / 65536); t10 = v - c * 65536;\n v = t11 + c + 65535; c = Math.floor(v / 65536); t11 = v - c * 65536;\n v = t12 + c + 65535; c = Math.floor(v / 65536); t12 = v - c * 65536;\n v = t13 + c + 65535; c = Math.floor(v / 65536); t13 = v - c * 65536;\n v = t14 + c + 65535; c = Math.floor(v / 65536); t14 = v - c * 65536;\n v = t15 + c + 65535; c = Math.floor(v / 65536); t15 = v - c * 65536;\n t0 += c-1 + 37 * (c-1);\n\n // second car\n c = 1;\n v = t0 + c + 65535; c = Math.floor(v / 65536); t0 = v - c * 65536;\n v = t1 + c + 65535; c = Math.floor(v / 65536); t1 = v - c * 65536;\n v = t2 + c + 65535; c = Math.floor(v / 65536); t2 = v - c * 65536;\n v = t3 + c + 65535; c = Math.floor(v / 65536); t3 = v - c * 65536;\n v = t4 + c + 65535; c = Math.floor(v / 65536); t4 = v - c * 65536;\n v = t5 + c + 65535; c = Math.floor(v / 65536); t5 = v - c * 65536;\n v = t6 + c + 65535; c = Math.floor(v / 65536); t6 = v - c * 65536;\n v = t7 + c + 65535; c = Math.floor(v / 65536); t7 = v - c * 65536;\n v = t8 + c + 65535; c = Math.floor(v / 65536); t8 = v - c * 65536;\n v = t9 + c + 65535; c = Math.floor(v / 65536); t9 = v - c * 65536;\n v = t10 + c + 65535; c = Math.floor(v / 65536); t10 = v - c * 65536;\n v = t11 + c + 65535; c = Math.floor(v / 65536); t11 = v - c * 65536;\n v = t12 + c + 65535; c = Math.floor(v / 65536); t12 = v - c * 65536;\n v = t13 + c + 65535; c = Math.floor(v / 65536); t13 = v - c * 65536;\n v = t14 + c + 65535; c = Math.floor(v / 65536); t14 = v - c * 65536;\n v = t15 + c + 65535; c = Math.floor(v / 65536); t15 = v - c * 65536;\n t0 += c-1 + 37 * (c-1);\n\n o[ 0] = t0;\n o[ 1] = t1;\n o[ 2] = t2;\n o[ 3] = t3;\n o[ 4] = t4;\n o[ 5] = t5;\n o[ 6] = t6;\n o[ 7] = t7;\n o[ 8] = t8;\n o[ 9] = t9;\n o[10] = t10;\n o[11] = t11;\n o[12] = t12;\n o[13] = t13;\n o[14] = t14;\n o[15] = t15;\n}\n\nfunction S(o, a) {\n M(o, a, a);\n}\n\nfunction inv25519(o, i) {\n var c = gf();\n var a;\n for (a = 0; a < 16; a++) c[a] = i[a];\n for (a = 253; a >= 0; a--) {\n S(c, c);\n if(a !== 2 && a !== 4) M(c, c, i);\n }\n for (a = 0; a < 16; a++) o[a] = c[a];\n}\n\nfunction pow2523(o, i) {\n var c = gf();\n var a;\n for (a = 0; a < 16; a++) c[a] = i[a];\n for (a = 250; a >= 0; a--) {\n S(c, c);\n if(a !== 1) M(c, c, i);\n }\n for (a = 0; a < 16; a++) o[a] = c[a];\n}\n\nfunction crypto_scalarmult(q, n, p) {\n var z = new Uint8Array(32);\n var x = new Float64Array(80), r, i;\n var a = gf(), b = gf(), c = gf(),\n d = gf(), e = gf(), f = gf();\n for (i = 0; i < 31; i++) z[i] = n[i];\n z[31]=(n[31]&127)|64;\n z[0]&=248;\n unpack25519(x,p);\n for (i = 0; i < 16; i++) {\n b[i]=x[i];\n d[i]=a[i]=c[i]=0;\n }\n a[0]=d[0]=1;\n for (i=254; i>=0; --i) {\n r=(z[i>>>3]>>>(i&7))&1;\n sel25519(a,b,r);\n sel25519(c,d,r);\n A(e,a,c);\n Z(a,a,c);\n A(c,b,d);\n Z(b,b,d);\n S(d,e);\n S(f,a);\n M(a,c,a);\n M(c,b,e);\n A(e,a,c);\n Z(a,a,c);\n S(b,a);\n Z(c,d,f);\n M(a,c,_121665);\n A(a,a,d);\n M(c,c,a);\n M(a,d,f);\n M(d,b,x);\n S(b,e);\n sel25519(a,b,r);\n sel25519(c,d,r);\n }\n for (i = 0; i < 16; i++) {\n x[i+16]=a[i];\n x[i+32]=c[i];\n x[i+48]=b[i];\n x[i+64]=d[i];\n }\n var x32 = x.subarray(32);\n var x16 = x.subarray(16);\n inv25519(x32,x32);\n M(x16,x16,x32);\n pack25519(q,x16);\n return 0;\n}\n\nfunction crypto_scalarmult_base(q, n) {\n return crypto_scalarmult(q, n, _9);\n}\n\nfunction crypto_box_keypair(y, x) {\n randombytes(x, 32);\n return crypto_scalarmult_base(y, x);\n}\n\nfunction crypto_box_beforenm(k, y, x) {\n var s = new Uint8Array(32);\n crypto_scalarmult(s, x, y);\n return crypto_core_hsalsa20(k, _0, s, sigma);\n}\n\nvar crypto_box_afternm = crypto_secretbox;\nvar crypto_box_open_afternm = crypto_secretbox_open;\n\nfunction crypto_box(c, m, d, n, y, x) {\n var k = new Uint8Array(32);\n crypto_box_beforenm(k, y, x);\n return crypto_box_afternm(c, m, d, n, k);\n}\n\nfunction crypto_box_open(m, c, d, n, y, x) {\n var k = new Uint8Array(32);\n crypto_box_beforenm(k, y, x);\n return crypto_box_open_afternm(m, c, d, n, k);\n}\n\nvar K = [\n 0x428a2f98, 0xd728ae22, 0x71374491, 0x23ef65cd,\n 0xb5c0fbcf, 0xec4d3b2f, 0xe9b5dba5, 0x8189dbbc,\n 0x3956c25b, 0xf348b538, 0x59f111f1, 0xb605d019,\n 0x923f82a4, 0xaf194f9b, 0xab1c5ed5, 0xda6d8118,\n 0xd807aa98, 0xa3030242, 0x12835b01, 0x45706fbe,\n 0x243185be, 0x4ee4b28c, 0x550c7dc3, 0xd5ffb4e2,\n 0x72be5d74, 0xf27b896f, 0x80deb1fe, 0x3b1696b1,\n 0x9bdc06a7, 0x25c71235, 0xc19bf174, 0xcf692694,\n 0xe49b69c1, 0x9ef14ad2, 0xefbe4786, 0x384f25e3,\n 0x0fc19dc6, 0x8b8cd5b5, 0x240ca1cc, 0x77ac9c65,\n 0x2de92c6f, 0x592b0275, 0x4a7484aa, 0x6ea6e483,\n 0x5cb0a9dc, 0xbd41fbd4, 0x76f988da, 0x831153b5,\n 0x983e5152, 0xee66dfab, 0xa831c66d, 0x2db43210,\n 0xb00327c8, 0x98fb213f, 0xbf597fc7, 0xbeef0ee4,\n 0xc6e00bf3, 0x3da88fc2, 0xd5a79147, 0x930aa725,\n 0x06ca6351, 0xe003826f, 0x14292967, 0x0a0e6e70,\n 0x27b70a85, 0x46d22ffc, 0x2e1b2138, 0x5c26c926,\n 0x4d2c6dfc, 0x5ac42aed, 0x53380d13, 0x9d95b3df,\n 0x650a7354, 0x8baf63de, 0x766a0abb, 0x3c77b2a8,\n 0x81c2c92e, 0x47edaee6, 0x92722c85, 0x1482353b,\n 0xa2bfe8a1, 0x4cf10364, 0xa81a664b, 0xbc423001,\n 0xc24b8b70, 0xd0f89791, 0xc76c51a3, 0x0654be30,\n 0xd192e819, 0xd6ef5218, 0xd6990624, 0x5565a910,\n 0xf40e3585, 0x5771202a, 0x106aa070, 0x32bbd1b8,\n 0x19a4c116, 0xb8d2d0c8, 0x1e376c08, 0x5141ab53,\n 0x2748774c, 0xdf8eeb99, 0x34b0bcb5, 0xe19b48a8,\n 0x391c0cb3, 0xc5c95a63, 0x4ed8aa4a, 0xe3418acb,\n 0x5b9cca4f, 0x7763e373, 0x682e6ff3, 0xd6b2b8a3,\n 0x748f82ee, 0x5defb2fc, 0x78a5636f, 0x43172f60,\n 0x84c87814, 0xa1f0ab72, 0x8cc70208, 0x1a6439ec,\n 0x90befffa, 0x23631e28, 0xa4506ceb, 0xde82bde9,\n 0xbef9a3f7, 0xb2c67915, 0xc67178f2, 0xe372532b,\n 0xca273ece, 0xea26619c, 0xd186b8c7, 0x21c0c207,\n 0xeada7dd6, 0xcde0eb1e, 0xf57d4f7f, 0xee6ed178,\n 0x06f067aa, 0x72176fba, 0x0a637dc5, 0xa2c898a6,\n 0x113f9804, 0xbef90dae, 0x1b710b35, 0x131c471b,\n 0x28db77f5, 0x23047d84, 0x32caab7b, 0x40c72493,\n 0x3c9ebe0a, 0x15c9bebc, 0x431d67c4, 0x9c100d4c,\n 0x4cc5d4be, 0xcb3e42b6, 0x597f299c, 0xfc657e2a,\n 0x5fcb6fab, 0x3ad6faec, 0x6c44198c, 0x4a475817\n];\n\nfunction crypto_hashblocks_hl(hh, hl, m, n) {\n var wh = new Int32Array(16), wl = new Int32Array(16),\n bh0, bh1, bh2, bh3, bh4, bh5, bh6, bh7,\n bl0, bl1, bl2, bl3, bl4, bl5, bl6, bl7,\n th, tl, i, j, h, l, a, b, c, d;\n\n var ah0 = hh[0],\n ah1 = hh[1],\n ah2 = hh[2],\n ah3 = hh[3],\n ah4 = hh[4],\n ah5 = hh[5],\n ah6 = hh[6],\n ah7 = hh[7],\n\n al0 = hl[0],\n al1 = hl[1],\n al2 = hl[2],\n al3 = hl[3],\n al4 = hl[4],\n al5 = hl[5],\n al6 = hl[6],\n al7 = hl[7];\n\n var pos = 0;\n while (n >= 128) {\n for (i = 0; i < 16; i++) {\n j = 8 * i + pos;\n wh[i] = (m[j+0] << 24) | (m[j+1] << 16) | (m[j+2] << 8) | m[j+3];\n wl[i] = (m[j+4] << 24) | (m[j+5] << 16) | (m[j+6] << 8) | m[j+7];\n }\n for (i = 0; i < 80; i++) {\n bh0 = ah0;\n bh1 = ah1;\n bh2 = ah2;\n bh3 = ah3;\n bh4 = ah4;\n bh5 = ah5;\n bh6 = ah6;\n bh7 = ah7;\n\n bl0 = al0;\n bl1 = al1;\n bl2 = al2;\n bl3 = al3;\n bl4 = al4;\n bl5 = al5;\n bl6 = al6;\n bl7 = al7;\n\n // add\n h = ah7;\n l = al7;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n // Sigma1\n h = ((ah4 >>> 14) | (al4 << (32-14))) ^ ((ah4 >>> 18) | (al4 << (32-18))) ^ ((al4 >>> (41-32)) | (ah4 << (32-(41-32))));\n l = ((al4 >>> 14) | (ah4 << (32-14))) ^ ((al4 >>> 18) | (ah4 << (32-18))) ^ ((ah4 >>> (41-32)) | (al4 << (32-(41-32))));\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // Ch\n h = (ah4 & ah5) ^ (~ah4 & ah6);\n l = (al4 & al5) ^ (~al4 & al6);\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // K\n h = K[i*2];\n l = K[i*2+1];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // w\n h = wh[i%16];\n l = wl[i%16];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n th = c & 0xffff | d << 16;\n tl = a & 0xffff | b << 16;\n\n // add\n h = th;\n l = tl;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n // Sigma0\n h = ((ah0 >>> 28) | (al0 << (32-28))) ^ ((al0 >>> (34-32)) | (ah0 << (32-(34-32)))) ^ ((al0 >>> (39-32)) | (ah0 << (32-(39-32))));\n l = ((al0 >>> 28) | (ah0 << (32-28))) ^ ((ah0 >>> (34-32)) | (al0 << (32-(34-32)))) ^ ((ah0 >>> (39-32)) | (al0 << (32-(39-32))));\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // Maj\n h = (ah0 & ah1) ^ (ah0 & ah2) ^ (ah1 & ah2);\n l = (al0 & al1) ^ (al0 & al2) ^ (al1 & al2);\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n bh7 = (c & 0xffff) | (d << 16);\n bl7 = (a & 0xffff) | (b << 16);\n\n // add\n h = bh3;\n l = bl3;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = th;\n l = tl;\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n bh3 = (c & 0xffff) | (d << 16);\n bl3 = (a & 0xffff) | (b << 16);\n\n ah1 = bh0;\n ah2 = bh1;\n ah3 = bh2;\n ah4 = bh3;\n ah5 = bh4;\n ah6 = bh5;\n ah7 = bh6;\n ah0 = bh7;\n\n al1 = bl0;\n al2 = bl1;\n al3 = bl2;\n al4 = bl3;\n al5 = bl4;\n al6 = bl5;\n al7 = bl6;\n al0 = bl7;\n\n if (i%16 === 15) {\n for (j = 0; j < 16; j++) {\n // add\n h = wh[j];\n l = wl[j];\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = wh[(j+9)%16];\n l = wl[(j+9)%16];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // sigma0\n th = wh[(j+1)%16];\n tl = wl[(j+1)%16];\n h = ((th >>> 1) | (tl << (32-1))) ^ ((th >>> 8) | (tl << (32-8))) ^ (th >>> 7);\n l = ((tl >>> 1) | (th << (32-1))) ^ ((tl >>> 8) | (th << (32-8))) ^ ((tl >>> 7) | (th << (32-7)));\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // sigma1\n th = wh[(j+14)%16];\n tl = wl[(j+14)%16];\n h = ((th >>> 19) | (tl << (32-19))) ^ ((tl >>> (61-32)) | (th << (32-(61-32)))) ^ (th >>> 6);\n l = ((tl >>> 19) | (th << (32-19))) ^ ((th >>> (61-32)) | (tl << (32-(61-32)))) ^ ((tl >>> 6) | (th << (32-6)));\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n wh[j] = (c & 0xffff) | (d << 16);\n wl[j] = (a & 0xffff) | (b << 16);\n }\n }\n }\n\n // add\n h = ah0;\n l = al0;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[0];\n l = hl[0];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[0] = ah0 = (c & 0xffff) | (d << 16);\n hl[0] = al0 = (a & 0xffff) | (b << 16);\n\n h = ah1;\n l = al1;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[1];\n l = hl[1];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[1] = ah1 = (c & 0xffff) | (d << 16);\n hl[1] = al1 = (a & 0xffff) | (b << 16);\n\n h = ah2;\n l = al2;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[2];\n l = hl[2];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[2] = ah2 = (c & 0xffff) | (d << 16);\n hl[2] = al2 = (a & 0xffff) | (b << 16);\n\n h = ah3;\n l = al3;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[3];\n l = hl[3];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[3] = ah3 = (c & 0xffff) | (d << 16);\n hl[3] = al3 = (a & 0xffff) | (b << 16);\n\n h = ah4;\n l = al4;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[4];\n l = hl[4];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[4] = ah4 = (c & 0xffff) | (d << 16);\n hl[4] = al4 = (a & 0xffff) | (b << 16);\n\n h = ah5;\n l = al5;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[5];\n l = hl[5];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[5] = ah5 = (c & 0xffff) | (d << 16);\n hl[5] = al5 = (a & 0xffff) | (b << 16);\n\n h = ah6;\n l = al6;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[6];\n l = hl[6];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[6] = ah6 = (c & 0xffff) | (d << 16);\n hl[6] = al6 = (a & 0xffff) | (b << 16);\n\n h = ah7;\n l = al7;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[7];\n l = hl[7];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[7] = ah7 = (c & 0xffff) | (d << 16);\n hl[7] = al7 = (a & 0xffff) | (b << 16);\n\n pos += 128;\n n -= 128;\n }\n\n return n;\n}\n\nfunction crypto_hash(out, m, n) {\n var hh = new Int32Array(8),\n hl = new Int32Array(8),\n x = new Uint8Array(256),\n i, b = n;\n\n hh[0] = 0x6a09e667;\n hh[1] = 0xbb67ae85;\n hh[2] = 0x3c6ef372;\n hh[3] = 0xa54ff53a;\n hh[4] = 0x510e527f;\n hh[5] = 0x9b05688c;\n hh[6] = 0x1f83d9ab;\n hh[7] = 0x5be0cd19;\n\n hl[0] = 0xf3bcc908;\n hl[1] = 0x84caa73b;\n hl[2] = 0xfe94f82b;\n hl[3] = 0x5f1d36f1;\n hl[4] = 0xade682d1;\n hl[5] = 0x2b3e6c1f;\n hl[6] = 0xfb41bd6b;\n hl[7] = 0x137e2179;\n\n crypto_hashblocks_hl(hh, hl, m, n);\n n %= 128;\n\n for (i = 0; i < n; i++) x[i] = m[b-n+i];\n x[n] = 128;\n\n n = 256-128*(n<112?1:0);\n x[n-9] = 0;\n ts64(x, n-8, (b / 0x20000000) | 0, b << 3);\n crypto_hashblocks_hl(hh, hl, x, n);\n\n for (i = 0; i < 8; i++) ts64(out, 8*i, hh[i], hl[i]);\n\n return 0;\n}\n\nfunction add(p, q) {\n var a = gf(), b = gf(), c = gf(),\n d = gf(), e = gf(), f = gf(),\n g = gf(), h = gf(), t = gf();\n\n Z(a, p[1], p[0]);\n Z(t, q[1], q[0]);\n M(a, a, t);\n A(b, p[0], p[1]);\n A(t, q[0], q[1]);\n M(b, b, t);\n M(c, p[3], q[3]);\n M(c, c, D2);\n M(d, p[2], q[2]);\n A(d, d, d);\n Z(e, b, a);\n Z(f, d, c);\n A(g, d, c);\n A(h, b, a);\n\n M(p[0], e, f);\n M(p[1], h, g);\n M(p[2], g, f);\n M(p[3], e, h);\n}\n\nfunction cswap(p, q, b) {\n var i;\n for (i = 0; i < 4; i++) {\n sel25519(p[i], q[i], b);\n }\n}\n\nfunction pack(r, p) {\n var tx = gf(), ty = gf(), zi = gf();\n inv25519(zi, p[2]);\n M(tx, p[0], zi);\n M(ty, p[1], zi);\n pack25519(r, ty);\n r[31] ^= par25519(tx) << 7;\n}\n\nfunction scalarmult(p, q, s) {\n var b, i;\n set25519(p[0], gf0);\n set25519(p[1], gf1);\n set25519(p[2], gf1);\n set25519(p[3], gf0);\n for (i = 255; i >= 0; --i) {\n b = (s[(i/8)|0] >> (i&7)) & 1;\n cswap(p, q, b);\n add(q, p);\n add(p, p);\n cswap(p, q, b);\n }\n}\n\nfunction scalarbase(p, s) {\n var q = [gf(), gf(), gf(), gf()];\n set25519(q[0], X);\n set25519(q[1], Y);\n set25519(q[2], gf1);\n M(q[3], X, Y);\n scalarmult(p, q, s);\n}\n\nfunction crypto_sign_keypair(pk, sk, seeded) {\n var d = new Uint8Array(64);\n var p = [gf(), gf(), gf(), gf()];\n var i;\n\n if (!seeded) randombytes(sk, 32);\n crypto_hash(d, sk, 32);\n d[0] &= 248;\n d[31] &= 127;\n d[31] |= 64;\n\n scalarbase(p, d);\n pack(pk, p);\n\n for (i = 0; i < 32; i++) sk[i+32] = pk[i];\n return 0;\n}\n\nvar L = new Float64Array([0xed, 0xd3, 0xf5, 0x5c, 0x1a, 0x63, 0x12, 0x58, 0xd6, 0x9c, 0xf7, 0xa2, 0xde, 0xf9, 0xde, 0x14, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x10]);\n\nfunction modL(r, x) {\n var carry, i, j, k;\n for (i = 63; i >= 32; --i) {\n carry = 0;\n for (j = i - 32, k = i - 12; j < k; ++j) {\n x[j] += carry - 16 * x[i] * L[j - (i - 32)];\n carry = Math.floor((x[j] + 128) / 256);\n x[j] -= carry * 256;\n }\n x[j] += carry;\n x[i] = 0;\n }\n carry = 0;\n for (j = 0; j < 32; j++) {\n x[j] += carry - (x[31] >> 4) * L[j];\n carry = x[j] >> 8;\n x[j] &= 255;\n }\n for (j = 0; j < 32; j++) x[j] -= carry * L[j];\n for (i = 0; i < 32; i++) {\n x[i+1] += x[i] >> 8;\n r[i] = x[i] & 255;\n }\n}\n\nfunction reduce(r) {\n var x = new Float64Array(64), i;\n for (i = 0; i < 64; i++) x[i] = r[i];\n for (i = 0; i < 64; i++) r[i] = 0;\n modL(r, x);\n}\n\n// Note: difference from C - smlen returned, not passed as argument.\nfunction crypto_sign(sm, m, n, sk) {\n var d = new Uint8Array(64), h = new Uint8Array(64), r = new Uint8Array(64);\n var i, j, x = new Float64Array(64);\n var p = [gf(), gf(), gf(), gf()];\n\n crypto_hash(d, sk, 32);\n d[0] &= 248;\n d[31] &= 127;\n d[31] |= 64;\n\n var smlen = n + 64;\n for (i = 0; i < n; i++) sm[64 + i] = m[i];\n for (i = 0; i < 32; i++) sm[32 + i] = d[32 + i];\n\n crypto_hash(r, sm.subarray(32), n+32);\n reduce(r);\n scalarbase(p, r);\n pack(sm, p);\n\n for (i = 32; i < 64; i++) sm[i] = sk[i];\n crypto_hash(h, sm, n + 64);\n reduce(h);\n\n for (i = 0; i < 64; i++) x[i] = 0;\n for (i = 0; i < 32; i++) x[i] = r[i];\n for (i = 0; i < 32; i++) {\n for (j = 0; j < 32; j++) {\n x[i+j] += h[i] * d[j];\n }\n }\n\n modL(sm.subarray(32), x);\n return smlen;\n}\n\nfunction unpackneg(r, p) {\n var t = gf(), chk = gf(), num = gf(),\n den = gf(), den2 = gf(), den4 = gf(),\n den6 = gf();\n\n set25519(r[2], gf1);\n unpack25519(r[1], p);\n S(num, r[1]);\n M(den, num, D);\n Z(num, num, r[2]);\n A(den, r[2], den);\n\n S(den2, den);\n S(den4, den2);\n M(den6, den4, den2);\n M(t, den6, num);\n M(t, t, den);\n\n pow2523(t, t);\n M(t, t, num);\n M(t, t, den);\n M(t, t, den);\n M(r[0], t, den);\n\n S(chk, r[0]);\n M(chk, chk, den);\n if (neq25519(chk, num)) M(r[0], r[0], I);\n\n S(chk, r[0]);\n M(chk, chk, den);\n if (neq25519(chk, num)) return -1;\n\n if (par25519(r[0]) === (p[31]>>7)) Z(r[0], gf0, r[0]);\n\n M(r[3], r[0], r[1]);\n return 0;\n}\n\nfunction crypto_sign_open(m, sm, n, pk) {\n var i;\n var t = new Uint8Array(32), h = new Uint8Array(64);\n var p = [gf(), gf(), gf(), gf()],\n q = [gf(), gf(), gf(), gf()];\n\n if (n < 64) return -1;\n\n if (unpackneg(q, pk)) return -1;\n\n for (i = 0; i < n; i++) m[i] = sm[i];\n for (i = 0; i < 32; i++) m[i+32] = pk[i];\n crypto_hash(h, m, n);\n reduce(h);\n scalarmult(p, q, h);\n\n scalarbase(q, sm.subarray(32));\n add(p, q);\n pack(t, p);\n\n n -= 64;\n if (crypto_verify_32(sm, 0, t, 0)) {\n for (i = 0; i < n; i++) m[i] = 0;\n return -1;\n }\n\n for (i = 0; i < n; i++) m[i] = sm[i + 64];\n return n;\n}\n\nvar crypto_secretbox_KEYBYTES = 32,\n crypto_secretbox_NONCEBYTES = 24,\n crypto_secretbox_ZEROBYTES = 32,\n crypto_secretbox_BOXZEROBYTES = 16,\n crypto_scalarmult_BYTES = 32,\n crypto_scalarmult_SCALARBYTES = 32,\n crypto_box_PUBLICKEYBYTES = 32,\n crypto_box_SECRETKEYBYTES = 32,\n crypto_box_BEFORENMBYTES = 32,\n crypto_box_NONCEBYTES = crypto_secretbox_NONCEBYTES,\n crypto_box_ZEROBYTES = crypto_secretbox_ZEROBYTES,\n crypto_box_BOXZEROBYTES = crypto_secretbox_BOXZEROBYTES,\n crypto_sign_BYTES = 64,\n crypto_sign_PUBLICKEYBYTES = 32,\n crypto_sign_SECRETKEYBYTES = 64,\n crypto_sign_SEEDBYTES = 32,\n crypto_hash_BYTES = 64;\n\nnacl.lowlevel = {\n crypto_core_hsalsa20: crypto_core_hsalsa20,\n crypto_stream_xor: crypto_stream_xor,\n crypto_stream: crypto_stream,\n crypto_stream_salsa20_xor: crypto_stream_salsa20_xor,\n crypto_stream_salsa20: crypto_stream_salsa20,\n crypto_onetimeauth: crypto_onetimeauth,\n crypto_onetimeauth_verify: crypto_onetimeauth_verify,\n crypto_verify_16: crypto_verify_16,\n crypto_verify_32: crypto_verify_32,\n crypto_secretbox: crypto_secretbox,\n crypto_secretbox_open: crypto_secretbox_open,\n crypto_scalarmult: crypto_scalarmult,\n crypto_scalarmult_base: crypto_scalarmult_base,\n crypto_box_beforenm: crypto_box_beforenm,\n crypto_box_afternm: crypto_box_afternm,\n crypto_box: crypto_box,\n crypto_box_open: crypto_box_open,\n crypto_box_keypair: crypto_box_keypair,\n crypto_hash: crypto_hash,\n crypto_sign: crypto_sign,\n crypto_sign_keypair: crypto_sign_keypair,\n crypto_sign_open: crypto_sign_open,\n\n crypto_secretbox_KEYBYTES: crypto_secretbox_KEYBYTES,\n crypto_secretbox_NONCEBYTES: crypto_secretbox_NONCEBYTES,\n crypto_secretbox_ZEROBYTES: crypto_secretbox_ZEROBYTES,\n crypto_secretbox_BOXZEROBYTES: crypto_secretbox_BOXZEROBYTES,\n crypto_scalarmult_BYTES: crypto_scalarmult_BYTES,\n crypto_scalarmult_SCALARBYTES: crypto_scalarmult_SCALARBYTES,\n crypto_box_PUBLICKEYBYTES: crypto_box_PUBLICKEYBYTES,\n crypto_box_SECRETKEYBYTES: crypto_box_SECRETKEYBYTES,\n crypto_box_BEFORENMBYTES: crypto_box_BEFORENMBYTES,\n crypto_box_NONCEBYTES: crypto_box_NONCEBYTES,\n crypto_box_ZEROBYTES: crypto_box_ZEROBYTES,\n crypto_box_BOXZEROBYTES: crypto_box_BOXZEROBYTES,\n crypto_sign_BYTES: crypto_sign_BYTES,\n crypto_sign_PUBLICKEYBYTES: crypto_sign_PUBLICKEYBYTES,\n crypto_sign_SECRETKEYBYTES: crypto_sign_SECRETKEYBYTES,\n crypto_sign_SEEDBYTES: crypto_sign_SEEDBYTES,\n crypto_hash_BYTES: crypto_hash_BYTES,\n\n gf: gf,\n D: D,\n L: L,\n pack25519: pack25519,\n unpack25519: unpack25519,\n M: M,\n A: A,\n S: S,\n Z: Z,\n pow2523: pow2523,\n add: add,\n set25519: set25519,\n modL: modL,\n scalarmult: scalarmult,\n scalarbase: scalarbase,\n};\n\n/* High-level API */\n\nfunction checkLengths(k, n) {\n if (k.length !== crypto_secretbox_KEYBYTES) throw new Error('bad key size');\n if (n.length !== crypto_secretbox_NONCEBYTES) throw new Error('bad nonce size');\n}\n\nfunction checkBoxLengths(pk, sk) {\n if (pk.length !== crypto_box_PUBLICKEYBYTES) throw new Error('bad public key size');\n if (sk.length !== crypto_box_SECRETKEYBYTES) throw new Error('bad secret key size');\n}\n\nfunction checkArrayTypes() {\n for (var i = 0; i < arguments.length; i++) {\n if (!(arguments[i] instanceof Uint8Array))\n throw new TypeError('unexpected type, use Uint8Array');\n }\n}\n\nfunction cleanup(arr) {\n for (var i = 0; i < arr.length; i++) arr[i] = 0;\n}\n\nnacl.randomBytes = function(n) {\n var b = new Uint8Array(n);\n randombytes(b, n);\n return b;\n};\n\nnacl.secretbox = function(msg, nonce, key) {\n checkArrayTypes(msg, nonce, key);\n checkLengths(key, nonce);\n var m = new Uint8Array(crypto_secretbox_ZEROBYTES + msg.length);\n var c = new Uint8Array(m.length);\n for (var i = 0; i < msg.length; i++) m[i+crypto_secretbox_ZEROBYTES] = msg[i];\n crypto_secretbox(c, m, m.length, nonce, key);\n return c.subarray(crypto_secretbox_BOXZEROBYTES);\n};\n\nnacl.secretbox.open = function(box, nonce, key) {\n checkArrayTypes(box, nonce, key);\n checkLengths(key, nonce);\n var c = new Uint8Array(crypto_secretbox_BOXZEROBYTES + box.length);\n var m = new Uint8Array(c.length);\n for (var i = 0; i < box.length; i++) c[i+crypto_secretbox_BOXZEROBYTES] = box[i];\n if (c.length < 32) return null;\n if (crypto_secretbox_open(m, c, c.length, nonce, key) !== 0) return null;\n return m.subarray(crypto_secretbox_ZEROBYTES);\n};\n\nnacl.secretbox.keyLength = crypto_secretbox_KEYBYTES;\nnacl.secretbox.nonceLength = crypto_secretbox_NONCEBYTES;\nnacl.secretbox.overheadLength = crypto_secretbox_BOXZEROBYTES;\n\nnacl.scalarMult = function(n, p) {\n checkArrayTypes(n, p);\n if (n.length !== crypto_scalarmult_SCALARBYTES) throw new Error('bad n size');\n if (p.length !== crypto_scalarmult_BYTES) throw new Error('bad p size');\n var q = new Uint8Array(crypto_scalarmult_BYTES);\n crypto_scalarmult(q, n, p);\n return q;\n};\n\nnacl.scalarMult.base = function(n) {\n checkArrayTypes(n);\n if (n.length !== crypto_scalarmult_SCALARBYTES) throw new Error('bad n size');\n var q = new Uint8Array(crypto_scalarmult_BYTES);\n crypto_scalarmult_base(q, n);\n return q;\n};\n\nnacl.scalarMult.scalarLength = crypto_scalarmult_SCALARBYTES;\nnacl.scalarMult.groupElementLength = crypto_scalarmult_BYTES;\n\nnacl.box = function(msg, nonce, publicKey, secretKey) {\n var k = nacl.box.before(publicKey, secretKey);\n return nacl.secretbox(msg, nonce, k);\n};\n\nnacl.box.before = function(publicKey, secretKey) {\n checkArrayTypes(publicKey, secretKey);\n checkBoxLengths(publicKey, secretKey);\n var k = new Uint8Array(crypto_box_BEFORENMBYTES);\n crypto_box_beforenm(k, publicKey, secretKey);\n return k;\n};\n\nnacl.box.after = nacl.secretbox;\n\nnacl.box.open = function(msg, nonce, publicKey, secretKey) {\n var k = nacl.box.before(publicKey, secretKey);\n return nacl.secretbox.open(msg, nonce, k);\n};\n\nnacl.box.open.after = nacl.secretbox.open;\n\nnacl.box.keyPair = function() {\n var pk = new Uint8Array(crypto_box_PUBLICKEYBYTES);\n var sk = new Uint8Array(crypto_box_SECRETKEYBYTES);\n crypto_box_keypair(pk, sk);\n return {publicKey: pk, secretKey: sk};\n};\n\nnacl.box.keyPair.fromSecretKey = function(secretKey) {\n checkArrayTypes(secretKey);\n if (secretKey.length !== crypto_box_SECRETKEYBYTES)\n throw new Error('bad secret key size');\n var pk = new Uint8Array(crypto_box_PUBLICKEYBYTES);\n crypto_scalarmult_base(pk, secretKey);\n return {publicKey: pk, secretKey: new Uint8Array(secretKey)};\n};\n\nnacl.box.publicKeyLength = crypto_box_PUBLICKEYBYTES;\nnacl.box.secretKeyLength = crypto_box_SECRETKEYBYTES;\nnacl.box.sharedKeyLength = crypto_box_BEFORENMBYTES;\nnacl.box.nonceLength = crypto_box_NONCEBYTES;\nnacl.box.overheadLength = nacl.secretbox.overheadLength;\n\nnacl.sign = function(msg, secretKey) {\n checkArrayTypes(msg, secretKey);\n if (secretKey.length !== crypto_sign_SECRETKEYBYTES)\n throw new Error('bad secret key size');\n var signedMsg = new Uint8Array(crypto_sign_BYTES+msg.length);\n crypto_sign(signedMsg, msg, msg.length, secretKey);\n return signedMsg;\n};\n\nnacl.sign.open = function(signedMsg, publicKey) {\n checkArrayTypes(signedMsg, publicKey);\n if (publicKey.length !== crypto_sign_PUBLICKEYBYTES)\n throw new Error('bad public key size');\n var tmp = new Uint8Array(signedMsg.length);\n var mlen = crypto_sign_open(tmp, signedMsg, signedMsg.length, publicKey);\n if (mlen < 0) return null;\n var m = new Uint8Array(mlen);\n for (var i = 0; i < m.length; i++) m[i] = tmp[i];\n return m;\n};\n\nnacl.sign.detached = function(msg, secretKey) {\n var signedMsg = nacl.sign(msg, secretKey);\n var sig = new Uint8Array(crypto_sign_BYTES);\n for (var i = 0; i < sig.length; i++) sig[i] = signedMsg[i];\n return sig;\n};\n\nnacl.sign.detached.verify = function(msg, sig, publicKey) {\n checkArrayTypes(msg, sig, publicKey);\n if (sig.length !== crypto_sign_BYTES)\n throw new Error('bad signature size');\n if (publicKey.length !== crypto_sign_PUBLICKEYBYTES)\n throw new Error('bad public key size');\n var sm = new Uint8Array(crypto_sign_BYTES + msg.length);\n var m = new Uint8Array(crypto_sign_BYTES + msg.length);\n var i;\n for (i = 0; i < crypto_sign_BYTES; i++) sm[i] = sig[i];\n for (i = 0; i < msg.length; i++) sm[i+crypto_sign_BYTES] = msg[i];\n return (crypto_sign_open(m, sm, sm.length, publicKey) >= 0);\n};\n\nnacl.sign.keyPair = function() {\n var pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);\n var sk = new Uint8Array(crypto_sign_SECRETKEYBYTES);\n crypto_sign_keypair(pk, sk);\n return {publicKey: pk, secretKey: sk};\n};\n\nnacl.sign.keyPair.fromSecretKey = function(secretKey) {\n checkArrayTypes(secretKey);\n if (secretKey.length !== crypto_sign_SECRETKEYBYTES)\n throw new Error('bad secret key size');\n var pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);\n for (var i = 0; i < pk.length; i++) pk[i] = secretKey[32+i];\n return {publicKey: pk, secretKey: new Uint8Array(secretKey)};\n};\n\nnacl.sign.keyPair.fromSeed = function(seed) {\n checkArrayTypes(seed);\n if (seed.length !== crypto_sign_SEEDBYTES)\n throw new Error('bad seed size');\n var pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);\n var sk = new Uint8Array(crypto_sign_SECRETKEYBYTES);\n for (var i = 0; i < 32; i++) sk[i] = seed[i];\n crypto_sign_keypair(pk, sk, true);\n return {publicKey: pk, secretKey: sk};\n};\n\nnacl.sign.publicKeyLength = crypto_sign_PUBLICKEYBYTES;\nnacl.sign.secretKeyLength = crypto_sign_SECRETKEYBYTES;\nnacl.sign.seedLength = crypto_sign_SEEDBYTES;\nnacl.sign.signatureLength = crypto_sign_BYTES;\n\nnacl.hash = function(msg) {\n checkArrayTypes(msg);\n var h = new Uint8Array(crypto_hash_BYTES);\n crypto_hash(h, msg, msg.length);\n return h;\n};\n\nnacl.hash.hashLength = crypto_hash_BYTES;\n\nnacl.verify = function(x, y) {\n checkArrayTypes(x, y);\n // Zero length arguments are considered not equal.\n if (x.length === 0 || y.length === 0) return false;\n if (x.length !== y.length) return false;\n return (vn(x, 0, y, 0, x.length) === 0) ? true : false;\n};\n\nnacl.setPRNG = function(fn) {\n randombytes = fn;\n};\n\n(function() {\n // Initialize PRNG if environment provides CSPRNG.\n // If not, methods calling randombytes will throw.\n var crypto = typeof self !== 'undefined' ? (self.crypto || self.msCrypto) : null;\n if (crypto && crypto.getRandomValues) {\n // Browsers.\n var QUOTA = 65536;\n nacl.setPRNG(function(x, n) {\n var i, v = new Uint8Array(n);\n for (i = 0; i < n; i += QUOTA) {\n crypto.getRandomValues(v.subarray(i, i + Math.min(n - i, QUOTA)));\n }\n for (i = 0; i < n; i++) x[i] = v[i];\n cleanup(v);\n });\n } else if (typeof require !== 'undefined') {\n // Node.js.\n crypto = require('crypto');\n if (crypto && crypto.randomBytes) {\n nacl.setPRNG(function(x, n) {\n var i, v = crypto.randomBytes(n);\n for (i = 0; i < n; i++) x[i] = v[i];\n cleanup(v);\n });\n }\n }\n})();\n\n})(typeof module !== 'undefined' && module.exports ? module.exports : (self.nacl = self.nacl || {}));\n","module.exports = require('./pusher-with-encryption').default;\n","/* (ignored) */","import ScriptReceiver from './script_receiver';\n\n/** Builds receivers for JSONP and Script requests.\n *\n * Each receiver is an object with following fields:\n * - number - unique (for the factory instance), numerical id of the receiver\n * - id - a string ID that can be used in DOM attributes\n * - name - name of the function triggering the receiver\n * - callback - callback function\n *\n * Receivers are triggered only once, on the first callback call.\n *\n * Receivers can be called by their name or by accessing factory object\n * by the number key.\n *\n * @param {String} prefix the prefix used in ids\n * @param {String} name the name of the object\n */\nexport class ScriptReceiverFactory {\n lastId: number;\n prefix: string;\n name: string;\n\n constructor(prefix: string, name: string) {\n this.lastId = 0;\n this.prefix = prefix;\n this.name = name;\n }\n\n create(callback: Function): ScriptReceiver {\n this.lastId++;\n\n var number = this.lastId;\n var id = this.prefix + number;\n var name = this.name + '[' + number + ']';\n\n var called = false;\n var callbackWrapper = function() {\n if (!called) {\n callback.apply(null, arguments);\n called = true;\n }\n };\n\n this[number] = callbackWrapper;\n return { number: number, id: id, name: name, callback: callbackWrapper };\n }\n\n remove(receiver: ScriptReceiver) {\n delete this[receiver.number];\n }\n}\n\nexport var ScriptReceivers = new ScriptReceiverFactory(\n '_pusher_script_',\n 'Pusher.ScriptReceivers'\n);\n","import {\n ChannelAuthorizationOptions,\n UserAuthenticationOptions\n} from './auth/options';\nimport { AuthTransport } from './config';\n\nexport interface DefaultConfig {\n VERSION: string;\n PROTOCOL: number;\n wsPort: number;\n wssPort: number;\n wsPath: string;\n httpHost: string;\n httpPort: number;\n httpsPort: number;\n httpPath: string;\n stats_host: string;\n authEndpoint: string;\n authTransport: AuthTransport;\n activityTimeout: number;\n pongTimeout: number;\n unavailableTimeout: number;\n userAuthentication: UserAuthenticationOptions;\n channelAuthorization: ChannelAuthorizationOptions;\n\n cdn_http?: string;\n cdn_https?: string;\n dependency_suffix?: string;\n}\n\nvar Defaults: DefaultConfig = {\n VERSION: VERSION,\n PROTOCOL: 7,\n\n wsPort: 80,\n wssPort: 443,\n wsPath: '',\n // DEPRECATED: SockJS fallback parameters\n httpHost: 'sockjs.pusher.com',\n httpPort: 80,\n httpsPort: 443,\n httpPath: '/pusher',\n // DEPRECATED: Stats\n stats_host: 'stats.pusher.com',\n // DEPRECATED: Other settings\n authEndpoint: '/pusher/auth',\n authTransport: 'ajax',\n activityTimeout: 120000,\n pongTimeout: 30000,\n unavailableTimeout: 10000,\n userAuthentication: {\n endpoint: '/pusher/user-auth',\n transport: 'ajax'\n },\n channelAuthorization: {\n endpoint: '/pusher/auth',\n transport: 'ajax'\n },\n\n // CDN configuration\n cdn_http: CDN_HTTP,\n cdn_https: CDN_HTTPS,\n dependency_suffix: DEPENDENCY_SUFFIX\n};\n\nexport default Defaults;\n","import {\n ScriptReceivers,\n ScriptReceiverFactory\n} from './script_receiver_factory';\nimport Runtime from 'runtime';\nimport ScriptRequest from './script_request';\n\n/** Handles loading dependency files.\n *\n * Dependency loaders don't remember whether a resource has been loaded or\n * not. It is caller's responsibility to make sure the resource is not loaded\n * twice. This is because it's impossible to detect resource loading status\n * without knowing its content.\n *\n * Options:\n * - cdn_http - url to HTTP CND\n * - cdn_https - url to HTTPS CDN\n * - version - version of pusher-js\n * - suffix - suffix appended to all names of dependency files\n *\n * @param {Object} options\n */\nexport default class DependencyLoader {\n options: any;\n receivers: ScriptReceiverFactory;\n loading: any;\n\n constructor(options: any) {\n this.options = options;\n this.receivers = options.receivers || ScriptReceivers;\n this.loading = {};\n }\n\n /** Loads the dependency from CDN.\n *\n * @param {String} name\n * @param {Function} callback\n */\n load(name: string, options: any, callback: Function) {\n var self = this;\n\n if (self.loading[name] && self.loading[name].length > 0) {\n self.loading[name].push(callback);\n } else {\n self.loading[name] = [callback];\n\n var request = Runtime.createScriptRequest(self.getPath(name, options));\n var receiver = self.receivers.create(function(error) {\n self.receivers.remove(receiver);\n\n if (self.loading[name]) {\n var callbacks = self.loading[name];\n delete self.loading[name];\n\n var successCallback = function(wasSuccessful) {\n if (!wasSuccessful) {\n request.cleanup();\n }\n };\n for (var i = 0; i < callbacks.length; i++) {\n callbacks[i](error, successCallback);\n }\n }\n });\n request.send(receiver);\n }\n }\n\n /** Returns a root URL for pusher-js CDN.\n *\n * @returns {String}\n */\n getRoot(options: any): string {\n var cdn;\n var protocol = Runtime.getDocument().location.protocol;\n if ((options && options.useTLS) || protocol === 'https:') {\n cdn = this.options.cdn_https;\n } else {\n cdn = this.options.cdn_http;\n }\n // make sure there are no double slashes\n return cdn.replace(/\\/*$/, '') + '/' + this.options.version;\n }\n\n /** Returns a full path to a dependency file.\n *\n * @param {String} name\n * @returns {String}\n */\n getPath(name: string, options: any): string {\n return this.getRoot(options) + '/' + name + this.options.suffix + '.js';\n }\n}\n","import { ScriptReceiverFactory } from './script_receiver_factory';\nimport Defaults from 'core/defaults';\nimport DependencyLoader from './dependency_loader';\n\nexport var DependenciesReceivers = new ScriptReceiverFactory(\n '_pusher_dependencies',\n 'Pusher.DependenciesReceivers'\n);\n\nexport var Dependencies = new DependencyLoader({\n cdn_http: Defaults.cdn_http,\n cdn_https: Defaults.cdn_https,\n version: Defaults.VERSION,\n suffix: Defaults.dependency_suffix,\n receivers: DependenciesReceivers\n});\n","/**\n * A place to store help URLs for error messages etc\n */\n\nconst urlStore = {\n baseUrl: 'https://pusher.com',\n urls: {\n authenticationEndpoint: {\n path: '/docs/channels/server_api/authenticating_users'\n },\n authorizationEndpoint: {\n path: '/docs/channels/server_api/authorizing-users/'\n },\n javascriptQuickStart: {\n path: '/docs/javascript_quick_start'\n },\n triggeringClientEvents: {\n path: '/docs/client_api_guide/client_events#trigger-events'\n },\n encryptedChannelSupport: {\n fullUrl:\n 'https://github.com/pusher/pusher-js/tree/cc491015371a4bde5743d1c87a0fbac0feb53195#encrypted-channel-support'\n }\n }\n};\n\n/** Builds a consistent string with links to pusher documentation\n *\n * @param {string} key - relevant key in the url_store.urls object\n * @return {string} suffix string to append to log message\n */\nconst buildLogSuffix = function(key: string): string {\n const urlPrefix = 'See:';\n const urlObj = urlStore.urls[key];\n if (!urlObj) return '';\n\n let url;\n if (urlObj.fullUrl) {\n url = urlObj.fullUrl;\n } else if (urlObj.path) {\n url = urlStore.baseUrl + urlObj.path;\n }\n\n if (!url) return '';\n return `${urlPrefix} ${url}`;\n};\n\nexport default { buildLogSuffix };\n","export enum AuthRequestType {\n UserAuthentication = 'user-authentication',\n ChannelAuthorization = 'channel-authorization'\n}\n\nexport interface ChannelAuthorizationData {\n auth: string;\n channel_data?: string;\n shared_secret?: string;\n}\n\nexport type ChannelAuthorizationCallback = (\n error: Error | null,\n authData: ChannelAuthorizationData | null\n) => void;\n\nexport interface ChannelAuthorizationRequestParams {\n socketId: string;\n channelName: string;\n}\n\nexport interface ChannelAuthorizationHandler {\n (\n params: ChannelAuthorizationRequestParams,\n callback: ChannelAuthorizationCallback\n ): void;\n}\n\nexport interface UserAuthenticationData {\n auth: string;\n user_data: string;\n}\n\nexport type UserAuthenticationCallback = (\n error: Error | null,\n authData: UserAuthenticationData | null\n) => void;\n\nexport interface UserAuthenticationRequestParams {\n socketId: string;\n}\n\nexport interface UserAuthenticationHandler {\n (\n params: UserAuthenticationRequestParams,\n callback: UserAuthenticationCallback\n ): void;\n}\n\nexport type AuthTransportCallback =\n | ChannelAuthorizationCallback\n | UserAuthenticationCallback;\n\nexport interface AuthOptionsT {\n transport: 'ajax' | 'jsonp';\n endpoint: string;\n params?: any;\n headers?: any;\n paramsProvider?: () => any;\n headersProvider?: () => any;\n customHandler?: AuthHandler;\n}\n\nexport declare type UserAuthenticationOptions = AuthOptionsT<\n UserAuthenticationHandler\n>;\nexport declare type ChannelAuthorizationOptions = AuthOptionsT<\n ChannelAuthorizationHandler\n>;\n\nexport interface InternalAuthOptions {\n transport: 'ajax' | 'jsonp';\n endpoint: string;\n params?: any;\n headers?: any;\n paramsProvider?: () => any;\n headersProvider?: () => any;\n}\n","/** Error classes used throughout the library. */\n// https://github.com/Microsoft/TypeScript-wiki/blob/master/Breaking-Changes.md#extending-built-ins-like-error-array-and-map-may-no-longer-work\nexport class BadEventName extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\nexport class BadChannelName extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\nexport class RequestTimedOut extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class TransportPriorityTooLow extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class TransportClosed extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class UnsupportedFeature extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class UnsupportedTransport extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class UnsupportedStrategy extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class HTTPAuthError extends Error {\n status: number;\n constructor(status: number, msg?: string) {\n super(msg);\n this.status = status;\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n","import TimelineSender from 'core/timeline/timeline_sender';\nimport * as Collections from 'core/utils/collections';\nimport Util from 'core/util';\nimport Runtime from 'runtime';\nimport { AuthTransport } from 'core/auth/auth_transports';\nimport AbstractRuntime from 'runtimes/interface';\nimport UrlStore from 'core/utils/url_store';\nimport {\n AuthRequestType,\n AuthTransportCallback,\n InternalAuthOptions\n} from 'core/auth/options';\nimport { HTTPAuthError } from 'core/errors';\n\nconst ajax: AuthTransport = function(\n context: AbstractRuntime,\n query: string,\n authOptions: InternalAuthOptions,\n authRequestType: AuthRequestType,\n callback: AuthTransportCallback\n) {\n const xhr = Runtime.createXHR();\n xhr.open('POST', authOptions.endpoint, true);\n\n // add request headers\n xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');\n for (var headerName in authOptions.headers) {\n xhr.setRequestHeader(headerName, authOptions.headers[headerName]);\n }\n if (authOptions.headersProvider != null) {\n let dynamicHeaders = authOptions.headersProvider();\n for (var headerName in dynamicHeaders) {\n xhr.setRequestHeader(headerName, dynamicHeaders[headerName]);\n }\n }\n\n xhr.onreadystatechange = function() {\n if (xhr.readyState === 4) {\n if (xhr.status === 200) {\n let data;\n let parsed = false;\n\n try {\n data = JSON.parse(xhr.responseText);\n parsed = true;\n } catch (e) {\n callback(\n new HTTPAuthError(\n 200,\n `JSON returned from ${authRequestType.toString()} endpoint was invalid, yet status code was 200. Data was: ${\n xhr.responseText\n }`\n ),\n null\n );\n }\n\n if (parsed) {\n // prevents double execution.\n callback(null, data);\n }\n } else {\n let suffix = '';\n switch (authRequestType) {\n case AuthRequestType.UserAuthentication:\n suffix = UrlStore.buildLogSuffix('authenticationEndpoint');\n break;\n case AuthRequestType.ChannelAuthorization:\n suffix = `Clients must be authorized to join private or presence channels. ${UrlStore.buildLogSuffix(\n 'authorizationEndpoint'\n )}`;\n break;\n }\n callback(\n new HTTPAuthError(\n xhr.status,\n `Unable to retrieve auth string from ${authRequestType.toString()} endpoint - ` +\n `received status: ${xhr.status} from ${authOptions.endpoint}. ${suffix}`\n ),\n null\n );\n }\n }\n };\n\n xhr.send(query);\n return xhr;\n};\n\nexport default ajax;\n","export default function encode(s: any): string {\n return btoa(utob(s));\n}\n\nvar fromCharCode = String.fromCharCode;\n\nvar b64chars =\n 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';\nvar b64tab = {};\n\nfor (var i = 0, l = b64chars.length; i < l; i++) {\n b64tab[b64chars.charAt(i)] = i;\n}\n\nvar cb_utob = function(c) {\n var cc = c.charCodeAt(0);\n return cc < 0x80\n ? c\n : cc < 0x800\n ? fromCharCode(0xc0 | (cc >>> 6)) + fromCharCode(0x80 | (cc & 0x3f))\n : fromCharCode(0xe0 | ((cc >>> 12) & 0x0f)) +\n fromCharCode(0x80 | ((cc >>> 6) & 0x3f)) +\n fromCharCode(0x80 | (cc & 0x3f));\n};\n\nvar utob = function(u) {\n return u.replace(/[^\\x00-\\x7F]/g, cb_utob);\n};\n\nvar cb_encode = function(ccc) {\n var padlen = [0, 2, 1][ccc.length % 3];\n var ord =\n (ccc.charCodeAt(0) << 16) |\n ((ccc.length > 1 ? ccc.charCodeAt(1) : 0) << 8) |\n (ccc.length > 2 ? ccc.charCodeAt(2) : 0);\n var chars = [\n b64chars.charAt(ord >>> 18),\n b64chars.charAt((ord >>> 12) & 63),\n padlen >= 2 ? '=' : b64chars.charAt((ord >>> 6) & 63),\n padlen >= 1 ? '=' : b64chars.charAt(ord & 63)\n ];\n return chars.join('');\n};\n\nvar btoa =\n global.btoa ||\n function(b) {\n return b.replace(/[\\s\\S]{1,3}/g, cb_encode);\n };\n","import TimedCallback from './timed_callback';\nimport { Delay, Scheduler, Canceller } from './scheduling';\n\nabstract class Timer {\n protected clear: Canceller;\n protected timer: number | void;\n\n constructor(\n set: Scheduler,\n clear: Canceller,\n delay: Delay,\n callback: TimedCallback\n ) {\n this.clear = clear;\n this.timer = set(() => {\n if (this.timer) {\n this.timer = callback(this.timer);\n }\n }, delay);\n }\n\n /** Returns whether the timer is still running.\n *\n * @return {Boolean}\n */\n isRunning(): boolean {\n return this.timer !== null;\n }\n\n /** Aborts a timer when it's running. */\n ensureAborted() {\n if (this.timer) {\n this.clear(this.timer);\n this.timer = null;\n }\n }\n}\n\nexport default Timer;\n","import Timer from './abstract_timer';\nimport TimedCallback from './timed_callback';\nimport { Delay } from './scheduling';\n\n// We need to bind clear functions this way to avoid exceptions on IE8\nfunction clearTimeout(timer) {\n global.clearTimeout(timer);\n}\nfunction clearInterval(timer) {\n global.clearInterval(timer);\n}\n\n/** Cross-browser compatible one-off timer abstraction.\n *\n * @param {Number} delay\n * @param {Function} callback\n */\nexport class OneOffTimer extends Timer {\n constructor(delay: Delay, callback: TimedCallback) {\n super(setTimeout, clearTimeout, delay, function(timer) {\n callback();\n return null;\n });\n }\n}\n\n/** Cross-browser compatible periodic timer abstraction.\n *\n * @param {Number} delay\n * @param {Function} callback\n */\nexport class PeriodicTimer extends Timer {\n constructor(delay: Delay, callback: TimedCallback) {\n super(setInterval, clearInterval, delay, function(timer) {\n callback();\n return timer;\n });\n }\n}\n","import * as Collections from './utils/collections';\nimport TimedCallback from './utils/timers/timed_callback';\nimport { OneOffTimer, PeriodicTimer } from './utils/timers';\n\nvar Util = {\n now(): number {\n if (Date.now) {\n return Date.now();\n } else {\n return new Date().valueOf();\n }\n },\n\n defer(callback: TimedCallback): OneOffTimer {\n return new OneOffTimer(0, callback);\n },\n\n /** Builds a function that will proxy a method call to its first argument.\n *\n * Allows partial application of arguments, so additional arguments are\n * prepended to the argument list.\n *\n * @param {String} name method name\n * @return {Function} proxy function\n */\n method(name: string, ...args: any[]): Function {\n var boundArguments = Array.prototype.slice.call(arguments, 1);\n return function(object) {\n return object[name].apply(object, boundArguments.concat(arguments));\n };\n }\n};\n\nexport default Util;\n","import base64encode from '../base64';\nimport Util from '../util';\n\n/** Merges multiple objects into the target argument.\n *\n * For properties that are plain Objects, performs a deep-merge. For the\n * rest it just copies the value of the property.\n *\n * To extend prototypes use it as following:\n * Pusher.Util.extend(Target.prototype, Base.prototype)\n *\n * You can also use it to merge objects without altering them:\n * Pusher.Util.extend({}, object1, object2)\n *\n * @param {Object} target\n * @return {Object} the target argument\n */\nexport function extend(target: any, ...sources: any[]): T {\n for (var i = 0; i < sources.length; i++) {\n var extensions = sources[i];\n for (var property in extensions) {\n if (\n extensions[property] &&\n extensions[property].constructor &&\n extensions[property].constructor === Object\n ) {\n target[property] = extend(target[property] || {}, extensions[property]);\n } else {\n target[property] = extensions[property];\n }\n }\n }\n return target;\n}\n\nexport function stringify(): string {\n var m = ['Pusher'];\n for (var i = 0; i < arguments.length; i++) {\n if (typeof arguments[i] === 'string') {\n m.push(arguments[i]);\n } else {\n m.push(safeJSONStringify(arguments[i]));\n }\n }\n return m.join(' : ');\n}\n\nexport function arrayIndexOf(array: any[], item: any): number {\n // MSIE doesn't have array.indexOf\n var nativeIndexOf = Array.prototype.indexOf;\n if (array === null) {\n return -1;\n }\n if (nativeIndexOf && array.indexOf === nativeIndexOf) {\n return array.indexOf(item);\n }\n for (var i = 0, l = array.length; i < l; i++) {\n if (array[i] === item) {\n return i;\n }\n }\n return -1;\n}\n\n/** Applies a function f to all properties of an object.\n *\n * Function f gets 3 arguments passed:\n * - element from the object\n * - key of the element\n * - reference to the object\n *\n * @param {Object} object\n * @param {Function} f\n */\nexport function objectApply(object: any, f: Function) {\n for (var key in object) {\n if (Object.prototype.hasOwnProperty.call(object, key)) {\n f(object[key], key, object);\n }\n }\n}\n\n/** Return a list of objects own proerty keys\n *\n * @param {Object} object\n * @returns {Array}\n */\nexport function keys(object: any): string[] {\n var keys = [];\n objectApply(object, function(_, key) {\n keys.push(key);\n });\n return keys;\n}\n\n/** Return a list of object's own property values\n *\n * @param {Object} object\n * @returns {Array}\n */\nexport function values(object: any): any[] {\n var values = [];\n objectApply(object, function(value) {\n values.push(value);\n });\n return values;\n}\n\n/** Applies a function f to all elements of an array.\n *\n * Function f gets 3 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function apply(array: any[], f: Function, context?: any) {\n for (var i = 0; i < array.length; i++) {\n f.call(context || global, array[i], i, array);\n }\n}\n\n/** Maps all elements of the array and returns the result.\n *\n * Function f gets 4 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n * - reference to the destination array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function map(array: any[], f: Function): any[] {\n var result = [];\n for (var i = 0; i < array.length; i++) {\n result.push(f(array[i], i, array, result));\n }\n return result;\n}\n\n/** Maps all elements of the object and returns the result.\n *\n * Function f gets 4 arguments passed:\n * - element from the object\n * - key of the element\n * - reference to the source object\n * - reference to the destination object\n *\n * @param {Object} object\n * @param {Function} f\n */\nexport function mapObject(object: any, f: Function): any {\n var result = {};\n objectApply(object, function(value, key) {\n result[key] = f(value);\n });\n return result;\n}\n\n/** Filters elements of the array using a test function.\n *\n * Function test gets 4 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n * - reference to the destination array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function filter(array: any[], test: Function): any[] {\n test =\n test ||\n function(value) {\n return !!value;\n };\n\n var result = [];\n for (var i = 0; i < array.length; i++) {\n if (test(array[i], i, array, result)) {\n result.push(array[i]);\n }\n }\n return result;\n}\n\n/** Filters properties of the object using a test function.\n *\n * Function test gets 4 arguments passed:\n * - element from the object\n * - key of the element\n * - reference to the source object\n * - reference to the destination object\n *\n * @param {Object} object\n * @param {Function} f\n */\nexport function filterObject(object: Object, test: Function) {\n var result = {};\n objectApply(object, function(value, key) {\n if ((test && test(value, key, object, result)) || Boolean(value)) {\n result[key] = value;\n }\n });\n return result;\n}\n\n/** Flattens an object into a two-dimensional array.\n *\n * @param {Object} object\n * @return {Array} resulting array of [key, value] pairs\n */\nexport function flatten(object: Object): any[] {\n var result = [];\n objectApply(object, function(value, key) {\n result.push([key, value]);\n });\n return result;\n}\n\n/** Checks whether any element of the array passes the test.\n *\n * Function test gets 3 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function any(array: any[], test: Function): boolean {\n for (var i = 0; i < array.length; i++) {\n if (test(array[i], i, array)) {\n return true;\n }\n }\n return false;\n}\n\n/** Checks whether all elements of the array pass the test.\n *\n * Function test gets 3 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function all(array: any[], test: Function): boolean {\n for (var i = 0; i < array.length; i++) {\n if (!test(array[i], i, array)) {\n return false;\n }\n }\n return true;\n}\n\nexport function encodeParamsObject(data): string {\n return mapObject(data, function(value) {\n if (typeof value === 'object') {\n value = safeJSONStringify(value);\n }\n return encodeURIComponent(base64encode(value.toString()));\n });\n}\n\nexport function buildQueryString(data: any): string {\n var params = filterObject(data, function(value) {\n return value !== undefined;\n });\n\n var query = map(\n flatten(encodeParamsObject(params)),\n Util.method('join', '=')\n ).join('&');\n\n return query;\n}\n\n/**\n * See https://github.com/douglascrockford/JSON-js/blob/master/cycle.js\n *\n * Remove circular references from an object. Required for JSON.stringify in\n * React Native, which tends to blow up a lot.\n *\n * @param {any} object\n * @return {any} Decycled object\n */\nexport function decycleObject(object: any): any {\n var objects = [],\n paths = [];\n\n return (function derez(value, path) {\n var i, name, nu;\n\n switch (typeof value) {\n case 'object':\n if (!value) {\n return null;\n }\n for (i = 0; i < objects.length; i += 1) {\n if (objects[i] === value) {\n return { $ref: paths[i] };\n }\n }\n\n objects.push(value);\n paths.push(path);\n\n if (Object.prototype.toString.apply(value) === '[object Array]') {\n nu = [];\n for (i = 0; i < value.length; i += 1) {\n nu[i] = derez(value[i], path + '[' + i + ']');\n }\n } else {\n nu = {};\n for (name in value) {\n if (Object.prototype.hasOwnProperty.call(value, name)) {\n nu[name] = derez(\n value[name],\n path + '[' + JSON.stringify(name) + ']'\n );\n }\n }\n }\n return nu;\n case 'number':\n case 'string':\n case 'boolean':\n return value;\n }\n })(object, '$');\n}\n\n/**\n * Provides a cross-browser and cross-platform way to safely stringify objects\n * into JSON. This is particularly necessary for ReactNative, where circular JSON\n * structures throw an exception.\n *\n * @param {any} source The object to stringify\n * @return {string} The serialized output.\n */\nexport function safeJSONStringify(source: any): string {\n try {\n return JSON.stringify(source);\n } catch (e) {\n return JSON.stringify(decycleObject(source));\n }\n}\n","import { stringify } from './utils/collections';\nimport Pusher from './pusher';\n\nclass Logger {\n debug(...args: any[]) {\n this.log(this.globalLog, args);\n }\n\n warn(...args: any[]) {\n this.log(this.globalLogWarn, args);\n }\n\n error(...args: any[]) {\n this.log(this.globalLogError, args);\n }\n\n private globalLog = (message: string) => {\n if (global.console && global.console.log) {\n global.console.log(message);\n }\n };\n\n private globalLogWarn(message: string) {\n if (global.console && global.console.warn) {\n global.console.warn(message);\n } else {\n this.globalLog(message);\n }\n }\n\n private globalLogError(message: string) {\n if (global.console && global.console.error) {\n global.console.error(message);\n } else {\n this.globalLogWarn(message);\n }\n }\n\n private log(\n defaultLoggingFunction: (message: string) => void,\n ...args: any[]\n ) {\n var message = stringify.apply(this, arguments);\n if (Pusher.log) {\n Pusher.log(message);\n } else if (Pusher.logToConsole) {\n const log = defaultLoggingFunction.bind(this);\n log(message);\n }\n }\n}\n\nexport default new Logger();\n","import Browser from '../browser';\nimport Logger from 'core/logger';\nimport JSONPRequest from '../dom/jsonp_request';\nimport { ScriptReceivers } from '../dom/script_receiver_factory';\nimport { AuthTransport } from 'core/auth/auth_transports';\nimport {\n AuthRequestType,\n AuthTransportCallback,\n InternalAuthOptions\n} from 'core/auth/options';\n\nvar jsonp: AuthTransport = function(\n context: Browser,\n query: string,\n authOptions: InternalAuthOptions,\n authRequestType: AuthRequestType,\n callback: AuthTransportCallback\n) {\n if (\n authOptions.headers !== undefined ||\n authOptions.headersProvider != null\n ) {\n Logger.warn(\n `To send headers with the ${authRequestType.toString()} request, you must use AJAX, rather than JSONP.`\n );\n }\n\n var callbackName = context.nextAuthCallbackID.toString();\n context.nextAuthCallbackID++;\n\n var document = context.getDocument();\n var script = document.createElement('script');\n // Hacked wrapper.\n context.auth_callbacks[callbackName] = function(data) {\n callback(null, data);\n };\n\n var callback_name = \"Pusher.auth_callbacks['\" + callbackName + \"']\";\n script.src =\n authOptions.endpoint +\n '?callback=' +\n encodeURIComponent(callback_name) +\n '&' +\n query;\n\n var head =\n document.getElementsByTagName('head')[0] || document.documentElement;\n head.insertBefore(script, head.firstChild);\n};\n\nexport default jsonp;\n","import ScriptReceiver from './script_receiver';\n\n/** Sends a generic HTTP GET request using a script tag.\n *\n * By constructing URL in a specific way, it can be used for loading\n * JavaScript resources or JSONP requests. It can notify about errors, but\n * only in certain environments. Please take care of monitoring the state of\n * the request yourself.\n *\n * @param {String} src\n */\nexport default class ScriptRequest {\n src: string;\n script: any;\n errorScript: any;\n\n constructor(src: string) {\n this.src = src;\n }\n\n send(receiver: ScriptReceiver) {\n var self = this;\n var errorString = 'Error loading ' + self.src;\n\n self.script = document.createElement('script');\n self.script.id = receiver.id;\n self.script.src = self.src;\n self.script.type = 'text/javascript';\n self.script.charset = 'UTF-8';\n\n if (self.script.addEventListener) {\n self.script.onerror = function() {\n receiver.callback(errorString);\n };\n self.script.onload = function() {\n receiver.callback(null);\n };\n } else {\n self.script.onreadystatechange = function() {\n if (\n self.script.readyState === 'loaded' ||\n self.script.readyState === 'complete'\n ) {\n receiver.callback(null);\n }\n };\n }\n\n // Opera<11.6 hack for missing onerror callback\n if (\n self.script.async === undefined &&\n (document).attachEvent &&\n /opera/i.test(navigator.userAgent)\n ) {\n self.errorScript = document.createElement('script');\n self.errorScript.id = receiver.id + '_error';\n self.errorScript.text = receiver.name + \"('\" + errorString + \"');\";\n self.script.async = self.errorScript.async = false;\n } else {\n self.script.async = true;\n }\n\n var head = document.getElementsByTagName('head')[0];\n head.insertBefore(self.script, head.firstChild);\n if (self.errorScript) {\n head.insertBefore(self.errorScript, self.script.nextSibling);\n }\n }\n\n /** Cleans up the DOM remains of the script request. */\n cleanup() {\n if (this.script) {\n this.script.onload = this.script.onerror = null;\n this.script.onreadystatechange = null;\n }\n if (this.script && this.script.parentNode) {\n this.script.parentNode.removeChild(this.script);\n }\n if (this.errorScript && this.errorScript.parentNode) {\n this.errorScript.parentNode.removeChild(this.errorScript);\n }\n this.script = null;\n this.errorScript = null;\n }\n}\n","import ScriptReceiver from './script_receiver';\nimport ScriptRequest from './script_request';\nimport * as Collections from 'core/utils/collections';\nimport Util from 'core/util';\nimport Runtime from '../runtime';\n\n/** Sends data via JSONP.\n *\n * Data is a key-value map. Its values are JSON-encoded and then passed\n * through base64. Finally, keys and encoded values are appended to the query\n * string.\n *\n * The class itself does not guarantee raising errors on failures, as it's not\n * possible to support such feature on all browsers. Instead, JSONP endpoint\n * should call back in a way that's easy to distinguish from browser calls,\n * for example by passing a second argument to the receiver.\n *\n * @param {String} url\n * @param {Object} data key-value map of data to be submitted\n */\nexport default class JSONPRequest {\n url: string;\n data: any;\n request: ScriptRequest;\n\n constructor(url: string, data: any) {\n this.url = url;\n this.data = data;\n }\n\n /** Sends the actual JSONP request.\n *\n * @param {ScriptReceiver} receiver\n */\n send(receiver: ScriptReceiver) {\n if (this.request) {\n return;\n }\n\n var query = Collections.buildQueryString(this.data);\n var url = this.url + '/' + receiver.number + '?' + query;\n this.request = Runtime.createScriptRequest(url);\n this.request.send(receiver);\n }\n\n /** Cleans up the DOM remains of the JSONP request. */\n cleanup() {\n if (this.request) {\n this.request.cleanup();\n }\n }\n}\n","import TimelineSender from 'core/timeline/timeline_sender';\nimport TimelineTransport from 'core/timeline/timeline_transport';\nimport Browser from 'runtime';\nimport { AuthTransport } from 'core/auth/auth_transports';\nimport { ScriptReceivers } from '../dom/script_receiver_factory';\n\nvar getAgent = function(sender: TimelineSender, useTLS: boolean) {\n return function(data: any, callback: Function) {\n var scheme = 'http' + (useTLS ? 's' : '') + '://';\n var url =\n scheme + (sender.host || sender.options.host) + sender.options.path;\n var request = Browser.createJSONPRequest(url, data);\n\n var receiver = Browser.ScriptReceivers.create(function(error, result) {\n ScriptReceivers.remove(receiver);\n request.cleanup();\n\n if (result && result.host) {\n sender.host = result.host;\n }\n if (callback) {\n callback(error, result);\n }\n });\n request.send(receiver);\n };\n};\n\nvar jsonp = {\n name: 'jsonp',\n getAgent\n};\n\nexport default jsonp;\n","import Defaults from '../defaults';\nimport { default as URLScheme, URLSchemeParams } from './url_scheme';\n\nfunction getGenericURL(\n baseScheme: string,\n params: URLSchemeParams,\n path: string\n): string {\n var scheme = baseScheme + (params.useTLS ? 's' : '');\n var host = params.useTLS ? params.hostTLS : params.hostNonTLS;\n return scheme + '://' + host + path;\n}\n\nfunction getGenericPath(key: string, queryString?: string): string {\n var path = '/app/' + key;\n var query =\n '?protocol=' +\n Defaults.PROTOCOL +\n '&client=js' +\n '&version=' +\n Defaults.VERSION +\n (queryString ? '&' + queryString : '');\n return path + query;\n}\n\nexport var ws: URLScheme = {\n getInitial: function(key: string, params: URLSchemeParams): string {\n var path = (params.httpPath || '') + getGenericPath(key, 'flash=false');\n return getGenericURL('ws', params, path);\n }\n};\n\nexport var http: URLScheme = {\n getInitial: function(key: string, params: URLSchemeParams): string {\n var path = (params.httpPath || '/pusher') + getGenericPath(key);\n return getGenericURL('http', params, path);\n }\n};\n\nexport var sockjs: URLScheme = {\n getInitial: function(key: string, params: URLSchemeParams): string {\n return getGenericURL('http', params, params.httpPath || '/pusher');\n },\n getPath: function(key: string, params: URLSchemeParams): string {\n return getGenericPath(key);\n }\n};\n","import Callback from './callback';\nimport * as Collections from '../utils/collections';\nimport CallbackTable from './callback_table';\n\nexport default class CallbackRegistry {\n _callbacks: CallbackTable;\n\n constructor() {\n this._callbacks = {};\n }\n\n get(name: string): Callback[] {\n return this._callbacks[prefix(name)];\n }\n\n add(name: string, callback: Function, context: any) {\n var prefixedEventName = prefix(name);\n this._callbacks[prefixedEventName] =\n this._callbacks[prefixedEventName] || [];\n this._callbacks[prefixedEventName].push({\n fn: callback,\n context: context\n });\n }\n\n remove(name?: string, callback?: Function, context?: any) {\n if (!name && !callback && !context) {\n this._callbacks = {};\n return;\n }\n\n var names = name ? [prefix(name)] : Collections.keys(this._callbacks);\n\n if (callback || context) {\n this.removeCallback(names, callback, context);\n } else {\n this.removeAllCallbacks(names);\n }\n }\n\n private removeCallback(names: string[], callback: Function, context: any) {\n Collections.apply(\n names,\n function(name) {\n this._callbacks[name] = Collections.filter(\n this._callbacks[name] || [],\n function(binding) {\n return (\n (callback && callback !== binding.fn) ||\n (context && context !== binding.context)\n );\n }\n );\n if (this._callbacks[name].length === 0) {\n delete this._callbacks[name];\n }\n },\n this\n );\n }\n\n private removeAllCallbacks(names: string[]) {\n Collections.apply(\n names,\n function(name) {\n delete this._callbacks[name];\n },\n this\n );\n }\n}\n\nfunction prefix(name: string): string {\n return '_' + name;\n}\n","import * as Collections from '../utils/collections';\nimport Callback from './callback';\nimport Metadata from '../channels/metadata';\nimport CallbackRegistry from './callback_registry';\n\n/** Manages callback bindings and event emitting.\n *\n * @param Function failThrough called when no listeners are bound to an event\n */\nexport default class Dispatcher {\n callbacks: CallbackRegistry;\n global_callbacks: Function[];\n failThrough: Function;\n\n constructor(failThrough?: Function) {\n this.callbacks = new CallbackRegistry();\n this.global_callbacks = [];\n this.failThrough = failThrough;\n }\n\n bind(eventName: string, callback: Function, context?: any) {\n this.callbacks.add(eventName, callback, context);\n return this;\n }\n\n bind_global(callback: Function) {\n this.global_callbacks.push(callback);\n return this;\n }\n\n unbind(eventName?: string, callback?: Function, context?: any) {\n this.callbacks.remove(eventName, callback, context);\n return this;\n }\n\n unbind_global(callback?: Function) {\n if (!callback) {\n this.global_callbacks = [];\n return this;\n }\n\n this.global_callbacks = Collections.filter(\n this.global_callbacks || [],\n c => c !== callback\n );\n\n return this;\n }\n\n unbind_all() {\n this.unbind();\n this.unbind_global();\n return this;\n }\n\n emit(eventName: string, data?: any, metadata?: Metadata): Dispatcher {\n for (var i = 0; i < this.global_callbacks.length; i++) {\n this.global_callbacks[i](eventName, data);\n }\n\n var callbacks = this.callbacks.get(eventName);\n var args = [];\n\n if (metadata) {\n // if there's a metadata argument, we need to call the callback with both\n // data and metadata regardless of whether data is undefined\n args.push(data, metadata);\n } else if (data) {\n // metadata is undefined, so we only need to call the callback with data\n // if data exists\n args.push(data);\n }\n\n if (callbacks && callbacks.length > 0) {\n for (var i = 0; i < callbacks.length; i++) {\n callbacks[i].fn.apply(callbacks[i].context || global, args);\n }\n } else if (this.failThrough) {\n this.failThrough(eventName, data);\n }\n\n return this;\n }\n}\n","import Util from '../util';\nimport * as Collections from '../utils/collections';\nimport { default as EventsDispatcher } from '../events/dispatcher';\nimport Logger from '../logger';\nimport TransportHooks from './transport_hooks';\nimport Socket from '../socket';\nimport Runtime from 'runtime';\nimport Timeline from '../timeline/timeline';\nimport TransportConnectionOptions from './transport_connection_options';\n\n/** Provides universal API for transport connections.\n *\n * Transport connection is a low-level object that wraps a connection method\n * and exposes a simple evented interface for the connection state and\n * messaging. It does not implement Pusher-specific WebSocket protocol.\n *\n * Additionally, it fetches resources needed for transport to work and exposes\n * an interface for querying transport features.\n *\n * States:\n * - new - initial state after constructing the object\n * - initializing - during initialization phase, usually fetching resources\n * - intialized - ready to establish a connection\n * - connection - when connection is being established\n * - open - when connection ready to be used\n * - closed - after connection was closed be either side\n *\n * Emits:\n * - error - after the connection raised an error\n *\n * Options:\n * - useTLS - whether connection should be over TLS\n * - hostTLS - host to connect to when connection is over TLS\n * - hostNonTLS - host to connect to when connection is over TLS\n *\n * @param {String} key application key\n * @param {Object} options\n */\nexport default class TransportConnection extends EventsDispatcher {\n hooks: TransportHooks;\n name: string;\n priority: number;\n key: string;\n options: TransportConnectionOptions;\n state: string;\n timeline: Timeline;\n activityTimeout: number;\n id: number;\n socket: Socket;\n beforeOpen: Function;\n initialize: Function;\n\n constructor(\n hooks: TransportHooks,\n name: string,\n priority: number,\n key: string,\n options: TransportConnectionOptions\n ) {\n super();\n this.initialize = Runtime.transportConnectionInitializer;\n this.hooks = hooks;\n this.name = name;\n this.priority = priority;\n this.key = key;\n this.options = options;\n\n this.state = 'new';\n this.timeline = options.timeline;\n this.activityTimeout = options.activityTimeout;\n this.id = this.timeline.generateUniqueID();\n }\n\n /** Checks whether the transport handles activity checks by itself.\n *\n * @return {Boolean}\n */\n handlesActivityChecks(): boolean {\n return Boolean(this.hooks.handlesActivityChecks);\n }\n\n /** Checks whether the transport supports the ping/pong API.\n *\n * @return {Boolean}\n */\n supportsPing(): boolean {\n return Boolean(this.hooks.supportsPing);\n }\n\n /** Tries to establish a connection.\n *\n * @returns {Boolean} false if transport is in invalid state\n */\n connect(): boolean {\n if (this.socket || this.state !== 'initialized') {\n return false;\n }\n\n var url = this.hooks.urls.getInitial(this.key, this.options);\n try {\n this.socket = this.hooks.getSocket(url, this.options);\n } catch (e) {\n Util.defer(() => {\n this.onError(e);\n this.changeState('closed');\n });\n return false;\n }\n\n this.bindListeners();\n\n Logger.debug('Connecting', { transport: this.name, url });\n this.changeState('connecting');\n return true;\n }\n\n /** Closes the connection.\n *\n * @return {Boolean} true if there was a connection to close\n */\n close(): boolean {\n if (this.socket) {\n this.socket.close();\n return true;\n } else {\n return false;\n }\n }\n\n /** Sends data over the open connection.\n *\n * @param {String} data\n * @return {Boolean} true only when in the \"open\" state\n */\n send(data: any): boolean {\n if (this.state === 'open') {\n // Workaround for MobileSafari bug (see https://gist.github.com/2052006)\n Util.defer(() => {\n if (this.socket) {\n this.socket.send(data);\n }\n });\n return true;\n } else {\n return false;\n }\n }\n\n /** Sends a ping if the connection is open and transport supports it. */\n ping() {\n if (this.state === 'open' && this.supportsPing()) {\n this.socket.ping();\n }\n }\n\n private onOpen() {\n if (this.hooks.beforeOpen) {\n this.hooks.beforeOpen(\n this.socket,\n this.hooks.urls.getPath(this.key, this.options)\n );\n }\n this.changeState('open');\n this.socket.onopen = undefined;\n }\n\n private onError(error) {\n this.emit('error', { type: 'WebSocketError', error: error });\n this.timeline.error(this.buildTimelineMessage({ error: error.toString() }));\n }\n\n private onClose(closeEvent?: any) {\n if (closeEvent) {\n this.changeState('closed', {\n code: closeEvent.code,\n reason: closeEvent.reason,\n wasClean: closeEvent.wasClean\n });\n } else {\n this.changeState('closed');\n }\n this.unbindListeners();\n this.socket = undefined;\n }\n\n private onMessage(message) {\n this.emit('message', message);\n }\n\n private onActivity() {\n this.emit('activity');\n }\n\n private bindListeners() {\n this.socket.onopen = () => {\n this.onOpen();\n };\n this.socket.onerror = error => {\n this.onError(error);\n };\n this.socket.onclose = closeEvent => {\n this.onClose(closeEvent);\n };\n this.socket.onmessage = message => {\n this.onMessage(message);\n };\n\n if (this.supportsPing()) {\n this.socket.onactivity = () => {\n this.onActivity();\n };\n }\n }\n\n private unbindListeners() {\n if (this.socket) {\n this.socket.onopen = undefined;\n this.socket.onerror = undefined;\n this.socket.onclose = undefined;\n this.socket.onmessage = undefined;\n if (this.supportsPing()) {\n this.socket.onactivity = undefined;\n }\n }\n }\n\n private changeState(state: string, params?: any) {\n this.state = state;\n this.timeline.info(\n this.buildTimelineMessage({\n state: state,\n params: params\n })\n );\n this.emit(state, params);\n }\n\n buildTimelineMessage(message): any {\n return Collections.extend({ cid: this.id }, message);\n }\n}\n","import Factory from '../utils/factory';\nimport TransportHooks from './transport_hooks';\nimport TransportConnection from './transport_connection';\nimport TransportConnectionOptions from './transport_connection_options';\n\n/** Provides interface for transport connection instantiation.\n *\n * Takes transport-specific hooks as the only argument, which allow checking\n * for transport support and creating its connections.\n *\n * Supported hooks: * - file - the name of the file to be fetched during initialization\n * - urls - URL scheme to be used by transport\n * - handlesActivityCheck - true when the transport handles activity checks\n * - supportsPing - true when the transport has a ping/activity API\n * - isSupported - tells whether the transport is supported in the environment\n * - getSocket - creates a WebSocket-compatible transport socket\n *\n * See transports.js for specific implementations.\n *\n * @param {Object} hooks object containing all needed transport hooks\n */\nexport default class Transport {\n hooks: TransportHooks;\n\n constructor(hooks: TransportHooks) {\n this.hooks = hooks;\n }\n\n /** Returns whether the transport is supported in the environment.\n *\n * @param {Object} envronment te environment details (encryption, settings)\n * @returns {Boolean} true when the transport is supported\n */\n isSupported(environment: any): boolean {\n return this.hooks.isSupported(environment);\n }\n\n /** Creates a transport connection.\n *\n * @param {String} name\n * @param {Number} priority\n * @param {String} key the application key\n * @param {Object} options\n * @returns {TransportConnection}\n */\n createConnection(\n name: string,\n priority: number,\n key: string,\n options: any\n ): TransportConnection {\n return new TransportConnection(this.hooks, name, priority, key, options);\n }\n}\n","import * as URLSchemes from 'core/transports/url_schemes';\nimport URLScheme from 'core/transports/url_scheme';\nimport Transport from 'core/transports/transport';\nimport Util from 'core/util';\nimport * as Collections from 'core/utils/collections';\nimport TransportHooks from 'core/transports/transport_hooks';\nimport TransportsTable from 'core/transports/transports_table';\nimport Runtime from 'runtime';\n\n/** WebSocket transport.\n *\n * Uses native WebSocket implementation, including MozWebSocket supported by\n * earlier Firefox versions.\n */\nvar WSTransport = new Transport({\n urls: URLSchemes.ws,\n handlesActivityChecks: false,\n supportsPing: false,\n\n isInitialized: function() {\n return Boolean(Runtime.getWebSocketAPI());\n },\n isSupported: function(): boolean {\n return Boolean(Runtime.getWebSocketAPI());\n },\n getSocket: function(url) {\n return Runtime.createWebSocket(url);\n }\n});\n\nvar httpConfiguration = {\n urls: URLSchemes.http,\n handlesActivityChecks: false,\n supportsPing: true,\n isInitialized: function() {\n return true;\n }\n};\n\nexport var streamingConfiguration = Collections.extend(\n {\n getSocket: function(url) {\n return Runtime.HTTPFactory.createStreamingSocket(url);\n }\n },\n httpConfiguration\n);\nexport var pollingConfiguration = Collections.extend(\n {\n getSocket: function(url) {\n return Runtime.HTTPFactory.createPollingSocket(url);\n }\n },\n httpConfiguration\n);\n\nvar xhrConfiguration = {\n isSupported: function(): boolean {\n return Runtime.isXHRSupported();\n }\n};\n\n/** HTTP streaming transport using CORS-enabled XMLHttpRequest. */\nvar XHRStreamingTransport = new Transport(\n (\n Collections.extend({}, streamingConfiguration, xhrConfiguration)\n )\n);\n\n/** HTTP long-polling transport using CORS-enabled XMLHttpRequest. */\nvar XHRPollingTransport = new Transport(\n Collections.extend({}, pollingConfiguration, xhrConfiguration)\n);\n\nvar Transports: TransportsTable = {\n ws: WSTransport,\n xhr_streaming: XHRStreamingTransport,\n xhr_polling: XHRPollingTransport\n};\n\nexport default Transports;\n","import {\n default as Transports,\n streamingConfiguration,\n pollingConfiguration\n} from 'isomorphic/transports/transports';\nimport Transport from 'core/transports/transport';\nimport TransportHooks from 'core/transports/transport_hooks';\nimport * as URLSchemes from 'core/transports/url_schemes';\nimport Runtime from 'runtime';\nimport { Dependencies } from '../dom/dependencies';\nimport * as Collections from 'core/utils/collections';\n\nvar SockJSTransport = new Transport({\n file: 'sockjs',\n urls: URLSchemes.sockjs,\n handlesActivityChecks: true,\n supportsPing: false,\n\n isSupported: function() {\n return true;\n },\n isInitialized: function() {\n return window.SockJS !== undefined;\n },\n getSocket: function(url, options) {\n return new window.SockJS(url, null, {\n js_path: Dependencies.getPath('sockjs', {\n useTLS: options.useTLS\n }),\n ignore_null_origin: options.ignoreNullOrigin\n });\n },\n beforeOpen: function(socket, path) {\n socket.send(\n JSON.stringify({\n path: path\n })\n );\n }\n});\n\nvar xdrConfiguration = {\n isSupported: function(environment): boolean {\n var yes = Runtime.isXDRSupported(environment.useTLS);\n return yes;\n }\n};\n\n/** HTTP streaming transport using XDomainRequest (IE 8,9). */\nvar XDRStreamingTransport = new Transport(\n (\n Collections.extend({}, streamingConfiguration, xdrConfiguration)\n )\n);\n\n/** HTTP long-polling transport using XDomainRequest (IE 8,9). */\nvar XDRPollingTransport = new Transport(\n Collections.extend({}, pollingConfiguration, xdrConfiguration)\n);\n\nTransports.xdr_streaming = XDRStreamingTransport;\nTransports.xdr_polling = XDRPollingTransport;\nTransports.sockjs = SockJSTransport;\n\nexport default Transports;\n","import Reachability from 'core/reachability';\nimport { default as EventsDispatcher } from 'core/events/dispatcher';\n\n/** Really basic interface providing network availability info.\n *\n * Emits:\n * - online - when browser goes online\n * - offline - when browser goes offline\n */\nexport class NetInfo extends EventsDispatcher implements Reachability {\n constructor() {\n super();\n var self = this;\n // This is okay, as IE doesn't support this stuff anyway.\n if (window.addEventListener !== undefined) {\n window.addEventListener(\n 'online',\n function() {\n self.emit('online');\n },\n false\n );\n window.addEventListener(\n 'offline',\n function() {\n self.emit('offline');\n },\n false\n );\n }\n }\n\n /** Returns whether browser is online or not\n *\n * Offline means definitely offline (no connection to router).\n * Inverse does NOT mean definitely online (only currently supported in Safari\n * and even there only means the device has a connection to the router).\n *\n * @return {Boolean}\n */\n isOnline(): boolean {\n if (window.navigator.onLine === undefined) {\n return true;\n } else {\n return window.navigator.onLine;\n }\n }\n}\n\nexport var Network = new NetInfo();\n","import Util from '../util';\nimport * as Collections from '../utils/collections';\nimport TransportManager from './transport_manager';\nimport TransportConnection from './transport_connection';\nimport Transport from './transport';\nimport PingDelayOptions from './ping_delay_options';\n\n/** Creates transport connections monitored by a transport manager.\n *\n * When a transport is closed, it might mean the environment does not support\n * it. It's possible that messages get stuck in an intermediate buffer or\n * proxies terminate inactive connections. To combat these problems,\n * assistants monitor the connection lifetime, report unclean exits and\n * adjust ping timeouts to keep the connection active. The decision to disable\n * a transport is the manager's responsibility.\n *\n * @param {TransportManager} manager\n * @param {TransportConnection} transport\n * @param {Object} options\n */\nexport default class AssistantToTheTransportManager {\n manager: TransportManager;\n transport: Transport;\n minPingDelay: number;\n maxPingDelay: number;\n pingDelay: number;\n\n constructor(\n manager: TransportManager,\n transport: Transport,\n options: PingDelayOptions\n ) {\n this.manager = manager;\n this.transport = transport;\n this.minPingDelay = options.minPingDelay;\n this.maxPingDelay = options.maxPingDelay;\n this.pingDelay = undefined;\n }\n\n /** Creates a transport connection.\n *\n * This function has the same API as Transport#createConnection.\n *\n * @param {String} name\n * @param {Number} priority\n * @param {String} key the application key\n * @param {Object} options\n * @returns {TransportConnection}\n */\n createConnection(\n name: string,\n priority: number,\n key: string,\n options: Object\n ): TransportConnection {\n options = Collections.extend({}, options, {\n activityTimeout: this.pingDelay\n });\n var connection = this.transport.createConnection(\n name,\n priority,\n key,\n options\n );\n\n var openTimestamp = null;\n\n var onOpen = function() {\n connection.unbind('open', onOpen);\n connection.bind('closed', onClosed);\n openTimestamp = Util.now();\n };\n var onClosed = closeEvent => {\n connection.unbind('closed', onClosed);\n\n if (closeEvent.code === 1002 || closeEvent.code === 1003) {\n // we don't want to use transports not obeying the protocol\n this.manager.reportDeath();\n } else if (!closeEvent.wasClean && openTimestamp) {\n // report deaths only for short-living transport\n var lifespan = Util.now() - openTimestamp;\n if (lifespan < 2 * this.maxPingDelay) {\n this.manager.reportDeath();\n this.pingDelay = Math.max(lifespan / 2, this.minPingDelay);\n }\n }\n };\n\n connection.bind('open', onOpen);\n return connection;\n }\n\n /** Returns whether the transport is supported in the environment.\n *\n * This function has the same API as Transport#isSupported. Might return false\n * when the manager decides to kill the transport.\n *\n * @param {Object} environment the environment details (encryption, settings)\n * @returns {Boolean} true when the transport is supported\n */\n isSupported(environment: string): boolean {\n return this.manager.isAlive() && this.transport.isSupported(environment);\n }\n}\n","import Action from './action';\nimport { PusherEvent } from './message-types';\n/**\n * Provides functions for handling Pusher protocol-specific messages.\n */\n\nconst Protocol = {\n /**\n * Decodes a message in a Pusher format.\n *\n * The MessageEvent we receive from the transport should contain a pusher event\n * (https://pusher.com/docs/pusher_protocol#events) serialized as JSON in the\n * data field\n *\n * The pusher event may contain a data field too, and it may also be\n * serialised as JSON\n *\n * Throws errors when messages are not parse'able.\n *\n * @param {MessageEvent} messageEvent\n * @return {PusherEvent}\n */\n decodeMessage: function(messageEvent: MessageEvent): PusherEvent {\n try {\n var messageData = JSON.parse(messageEvent.data);\n var pusherEventData = messageData.data;\n if (typeof pusherEventData === 'string') {\n try {\n pusherEventData = JSON.parse(messageData.data);\n } catch (e) {}\n }\n var pusherEvent: PusherEvent = {\n event: messageData.event,\n channel: messageData.channel,\n data: pusherEventData\n };\n if (messageData.user_id) {\n pusherEvent.user_id = messageData.user_id;\n }\n return pusherEvent;\n } catch (e) {\n throw { type: 'MessageParseError', error: e, data: messageEvent.data };\n }\n },\n\n /**\n * Encodes a message to be sent.\n *\n * @param {PusherEvent} event\n * @return {String}\n */\n encodeMessage: function(event: PusherEvent): string {\n return JSON.stringify(event);\n },\n\n /**\n * Processes a handshake message and returns appropriate actions.\n *\n * Returns an object with an 'action' and other action-specific properties.\n *\n * There are three outcomes when calling this function. First is a successful\n * connection attempt, when pusher:connection_established is received, which\n * results in a 'connected' action with an 'id' property. When passed a\n * pusher:error event, it returns a result with action appropriate to the\n * close code and an error. Otherwise, it raises an exception.\n *\n * @param {String} message\n * @result Object\n */\n processHandshake: function(messageEvent: MessageEvent): Action {\n var message = Protocol.decodeMessage(messageEvent);\n\n if (message.event === 'pusher:connection_established') {\n if (!message.data.activity_timeout) {\n throw 'No activity timeout specified in handshake';\n }\n return {\n action: 'connected',\n id: message.data.socket_id,\n activityTimeout: message.data.activity_timeout * 1000\n };\n } else if (message.event === 'pusher:error') {\n // From protocol 6 close codes are sent only once, so this only\n // happens when connection does not support close codes\n return {\n action: this.getCloseAction(message.data),\n error: this.getCloseError(message.data)\n };\n } else {\n throw 'Invalid handshake';\n }\n },\n\n /**\n * Dispatches the close event and returns an appropriate action name.\n *\n * See:\n * 1. https://developer.mozilla.org/en-US/docs/WebSockets/WebSockets_reference/CloseEvent\n * 2. http://pusher.com/docs/pusher_protocol\n *\n * @param {CloseEvent} closeEvent\n * @return {String} close action name\n */\n getCloseAction: function(closeEvent): string {\n if (closeEvent.code < 4000) {\n // ignore 1000 CLOSE_NORMAL, 1001 CLOSE_GOING_AWAY,\n // 1005 CLOSE_NO_STATUS, 1006 CLOSE_ABNORMAL\n // ignore 1007...3999\n // handle 1002 CLOSE_PROTOCOL_ERROR, 1003 CLOSE_UNSUPPORTED,\n // 1004 CLOSE_TOO_LARGE\n if (closeEvent.code >= 1002 && closeEvent.code <= 1004) {\n return 'backoff';\n } else {\n return null;\n }\n } else if (closeEvent.code === 4000) {\n return 'tls_only';\n } else if (closeEvent.code < 4100) {\n return 'refused';\n } else if (closeEvent.code < 4200) {\n return 'backoff';\n } else if (closeEvent.code < 4300) {\n return 'retry';\n } else {\n // unknown error\n return 'refused';\n }\n },\n\n /**\n * Returns an error or null basing on the close event.\n *\n * Null is returned when connection was closed cleanly. Otherwise, an object\n * with error details is returned.\n *\n * @param {CloseEvent} closeEvent\n * @return {Object} error object\n */\n getCloseError: function(closeEvent): any {\n if (closeEvent.code !== 1000 && closeEvent.code !== 1001) {\n return {\n type: 'PusherError',\n data: {\n code: closeEvent.code,\n message: closeEvent.reason || closeEvent.message\n }\n };\n } else {\n return null;\n }\n }\n};\n\nexport default Protocol;\n","import * as Collections from '../utils/collections';\nimport { default as EventsDispatcher } from '../events/dispatcher';\nimport Protocol from './protocol/protocol';\nimport { PusherEvent } from './protocol/message-types';\nimport Logger from '../logger';\nimport TransportConnection from '../transports/transport_connection';\nimport Socket from '../socket';\n/**\n * Provides Pusher protocol interface for transports.\n *\n * Emits following events:\n * - message - on received messages\n * - ping - on ping requests\n * - pong - on pong responses\n * - error - when the transport emits an error\n * - closed - after closing the transport\n *\n * It also emits more events when connection closes with a code.\n * See Protocol.getCloseAction to get more details.\n *\n * @param {Number} id\n * @param {AbstractTransport} transport\n */\nexport default class Connection extends EventsDispatcher implements Socket {\n id: string;\n transport: TransportConnection;\n activityTimeout: number;\n\n constructor(id: string, transport: TransportConnection) {\n super();\n this.id = id;\n this.transport = transport;\n this.activityTimeout = transport.activityTimeout;\n this.bindListeners();\n }\n\n /** Returns whether used transport handles activity checks by itself\n *\n * @returns {Boolean} true if activity checks are handled by the transport\n */\n handlesActivityChecks() {\n return this.transport.handlesActivityChecks();\n }\n\n /** Sends raw data.\n *\n * @param {String} data\n */\n send(data: any): boolean {\n return this.transport.send(data);\n }\n\n /** Sends an event.\n *\n * @param {String} name\n * @param {String} data\n * @param {String} [channel]\n * @returns {Boolean} whether message was sent or not\n */\n send_event(name: string, data: any, channel?: string): boolean {\n var event: PusherEvent = { event: name, data: data };\n if (channel) {\n event.channel = channel;\n }\n Logger.debug('Event sent', event);\n return this.send(Protocol.encodeMessage(event));\n }\n\n /** Sends a ping message to the server.\n *\n * Basing on the underlying transport, it might send either transport's\n * protocol-specific ping or pusher:ping event.\n */\n ping() {\n if (this.transport.supportsPing()) {\n this.transport.ping();\n } else {\n this.send_event('pusher:ping', {});\n }\n }\n\n /** Closes the connection. */\n close() {\n this.transport.close();\n }\n\n private bindListeners() {\n var listeners = {\n message: (messageEvent: MessageEvent) => {\n var pusherEvent;\n try {\n pusherEvent = Protocol.decodeMessage(messageEvent);\n } catch (e) {\n this.emit('error', {\n type: 'MessageParseError',\n error: e,\n data: messageEvent.data\n });\n }\n\n if (pusherEvent !== undefined) {\n Logger.debug('Event recd', pusherEvent);\n\n switch (pusherEvent.event) {\n case 'pusher:error':\n this.emit('error', {\n type: 'PusherError',\n data: pusherEvent.data\n });\n break;\n case 'pusher:ping':\n this.emit('ping');\n break;\n case 'pusher:pong':\n this.emit('pong');\n break;\n }\n this.emit('message', pusherEvent);\n }\n },\n activity: () => {\n this.emit('activity');\n },\n error: error => {\n this.emit('error', error);\n },\n closed: closeEvent => {\n unbindListeners();\n\n if (closeEvent && closeEvent.code) {\n this.handleCloseEvent(closeEvent);\n }\n\n this.transport = null;\n this.emit('closed');\n }\n };\n\n var unbindListeners = () => {\n Collections.objectApply(listeners, (listener, event) => {\n this.transport.unbind(event, listener);\n });\n };\n\n Collections.objectApply(listeners, (listener, event) => {\n this.transport.bind(event, listener);\n });\n }\n\n private handleCloseEvent(closeEvent: any) {\n var action = Protocol.getCloseAction(closeEvent);\n var error = Protocol.getCloseError(closeEvent);\n if (error) {\n this.emit('error', error);\n }\n if (action) {\n this.emit(action, { action: action, error: error });\n }\n }\n}\n","import Util from '../../util';\nimport * as Collections from '../../utils/collections';\nimport Protocol from '../protocol/protocol';\nimport Connection from '../connection';\nimport TransportConnection from '../../transports/transport_connection';\nimport HandshakePayload from './handshake_payload';\n\n/**\n * Handles Pusher protocol handshakes for transports.\n *\n * Calls back with a result object after handshake is completed. Results\n * always have two fields:\n * - action - string describing action to be taken after the handshake\n * - transport - the transport object passed to the constructor\n *\n * Different actions can set different additional properties on the result.\n * In the case of 'connected' action, there will be a 'connection' property\n * containing a Connection object for the transport. Other actions should\n * carry an 'error' property.\n *\n * @param {AbstractTransport} transport\n * @param {Function} callback\n */\nexport default class Handshake {\n transport: TransportConnection;\n callback: (HandshakePayload) => void;\n onMessage: Function;\n onClosed: Function;\n\n constructor(\n transport: TransportConnection,\n callback: (HandshakePayload) => void\n ) {\n this.transport = transport;\n this.callback = callback;\n this.bindListeners();\n }\n\n close() {\n this.unbindListeners();\n this.transport.close();\n }\n\n private bindListeners() {\n this.onMessage = m => {\n this.unbindListeners();\n\n var result;\n try {\n result = Protocol.processHandshake(m);\n } catch (e) {\n this.finish('error', { error: e });\n this.transport.close();\n return;\n }\n\n if (result.action === 'connected') {\n this.finish('connected', {\n connection: new Connection(result.id, this.transport),\n activityTimeout: result.activityTimeout\n });\n } else {\n this.finish(result.action, { error: result.error });\n this.transport.close();\n }\n };\n\n this.onClosed = closeEvent => {\n this.unbindListeners();\n\n var action = Protocol.getCloseAction(closeEvent) || 'backoff';\n var error = Protocol.getCloseError(closeEvent);\n this.finish(action, { error: error });\n };\n\n this.transport.bind('message', this.onMessage);\n this.transport.bind('closed', this.onClosed);\n }\n\n private unbindListeners() {\n this.transport.unbind('message', this.onMessage);\n this.transport.unbind('closed', this.onClosed);\n }\n\n private finish(action: string, params: any) {\n this.callback(\n Collections.extend({ transport: this.transport, action: action }, params)\n );\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport base64encode from '../base64';\nimport Timeline from './timeline';\nimport Runtime from 'runtime';\n\nexport interface TimelineSenderOptions {\n host?: string;\n port?: number;\n path?: string;\n}\n\nexport default class TimelineSender {\n timeline: Timeline;\n options: TimelineSenderOptions;\n host: string;\n\n constructor(timeline: Timeline, options: TimelineSenderOptions) {\n this.timeline = timeline;\n this.options = options || {};\n }\n\n send(useTLS: boolean, callback?: Function) {\n if (this.timeline.isEmpty()) {\n return;\n }\n\n this.timeline.send(\n Runtime.TimelineTransport.getAgent(this, useTLS),\n callback\n );\n }\n}\n","import { default as EventsDispatcher } from '../events/dispatcher';\nimport * as Errors from '../errors';\nimport Logger from '../logger';\nimport Pusher from '../pusher';\nimport { PusherEvent } from '../connection/protocol/message-types';\nimport Metadata from './metadata';\nimport UrlStore from '../utils/url_store';\nimport {\n ChannelAuthorizationData,\n ChannelAuthorizationCallback\n} from '../auth/options';\nimport { HTTPAuthError } from '../errors';\n\n/** Provides base public channel interface with an event emitter.\n *\n * Emits:\n * - pusher:subscription_succeeded - after subscribing successfully\n * - other non-internal events\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\nexport default class Channel extends EventsDispatcher {\n name: string;\n pusher: Pusher;\n subscribed: boolean;\n subscriptionPending: boolean;\n subscriptionCancelled: boolean;\n subscriptionCount: null;\n\n constructor(name: string, pusher: Pusher) {\n super(function(event, data) {\n Logger.debug('No callbacks on ' + name + ' for ' + event);\n });\n\n this.name = name;\n this.pusher = pusher;\n this.subscribed = false;\n this.subscriptionPending = false;\n this.subscriptionCancelled = false;\n }\n\n /** Skips authorization, since public channels don't require it.\n *\n * @param {Function} callback\n */\n authorize(socketId: string, callback: ChannelAuthorizationCallback) {\n return callback(null, { auth: '' });\n }\n\n /** Triggers an event */\n trigger(event: string, data: any) {\n if (event.indexOf('client-') !== 0) {\n throw new Errors.BadEventName(\n \"Event '\" + event + \"' does not start with 'client-'\"\n );\n }\n if (!this.subscribed) {\n var suffix = UrlStore.buildLogSuffix('triggeringClientEvents');\n Logger.warn(\n `Client event triggered before channel 'subscription_succeeded' event . ${suffix}`\n );\n }\n return this.pusher.send_event(event, data, this.name);\n }\n\n /** Signals disconnection to the channel. For internal use only. */\n disconnect() {\n this.subscribed = false;\n this.subscriptionPending = false;\n }\n\n /** Handles a PusherEvent. For internal use only.\n *\n * @param {PusherEvent} event\n */\n handleEvent(event: PusherEvent) {\n var eventName = event.event;\n var data = event.data;\n if (eventName === 'pusher_internal:subscription_succeeded') {\n this.handleSubscriptionSucceededEvent(event);\n } else if (eventName === 'pusher_internal:subscription_count') {\n this.handleSubscriptionCountEvent(event);\n } else if (eventName.indexOf('pusher_internal:') !== 0) {\n var metadata: Metadata = {};\n this.emit(eventName, data, metadata);\n }\n }\n\n handleSubscriptionSucceededEvent(event: PusherEvent) {\n this.subscriptionPending = false;\n this.subscribed = true;\n if (this.subscriptionCancelled) {\n this.pusher.unsubscribe(this.name);\n } else {\n this.emit('pusher:subscription_succeeded', event.data);\n }\n }\n\n handleSubscriptionCountEvent(event: PusherEvent) {\n if (event.data.subscription_count) {\n this.subscriptionCount = event.data.subscription_count;\n }\n\n this.emit('pusher:subscription_count', event.data);\n }\n\n /** Sends a subscription request. For internal use only. */\n subscribe() {\n if (this.subscribed) {\n return;\n }\n this.subscriptionPending = true;\n this.subscriptionCancelled = false;\n this.authorize(\n this.pusher.connection.socket_id,\n (error: Error | null, data: ChannelAuthorizationData) => {\n if (error) {\n this.subscriptionPending = false;\n // Why not bind to 'pusher:subscription_error' a level up, and log there?\n // Binding to this event would cause the warning about no callbacks being\n // bound (see constructor) to be suppressed, that's not what we want.\n Logger.error(error.toString());\n this.emit(\n 'pusher:subscription_error',\n Object.assign(\n {},\n {\n type: 'AuthError',\n error: error.message\n },\n error instanceof HTTPAuthError ? { status: error.status } : {}\n )\n );\n } else {\n this.pusher.send_event('pusher:subscribe', {\n auth: data.auth,\n channel_data: data.channel_data,\n channel: this.name\n });\n }\n }\n );\n }\n\n /** Sends an unsubscription request. For internal use only. */\n unsubscribe() {\n this.subscribed = false;\n this.pusher.send_event('pusher:unsubscribe', {\n channel: this.name\n });\n }\n\n /** Cancels an in progress subscription. For internal use only. */\n cancelSubscription() {\n this.subscriptionCancelled = true;\n }\n\n /** Reinstates an in progress subscripiton. For internal use only. */\n reinstateSubscription() {\n this.subscriptionCancelled = false;\n }\n}\n","import Factory from '../utils/factory';\nimport Channel from './channel';\nimport { ChannelAuthorizationCallback } from '../auth/options';\n\n/** Extends public channels to provide private channel interface.\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\nexport default class PrivateChannel extends Channel {\n /** Authorizes the connection to use the channel.\n *\n * @param {String} socketId\n * @param {Function} callback\n */\n authorize(socketId: string, callback: ChannelAuthorizationCallback) {\n return this.pusher.config.channelAuthorizer(\n {\n channelName: this.name,\n socketId: socketId\n },\n callback\n );\n }\n}\n","import * as Collections from '../utils/collections';\n\n/** Represents a collection of members of a presence channel. */\nexport default class Members {\n members: any;\n count: number;\n myID: any;\n me: any;\n\n constructor() {\n this.reset();\n }\n\n /** Returns member's info for given id.\n *\n * Resulting object containts two fields - id and info.\n *\n * @param {Number} id\n * @return {Object} member's info or null\n */\n get(id: string): any {\n if (Object.prototype.hasOwnProperty.call(this.members, id)) {\n return {\n id: id,\n info: this.members[id]\n };\n } else {\n return null;\n }\n }\n\n /** Calls back for each member in unspecified order.\n *\n * @param {Function} callback\n */\n each(callback: Function) {\n Collections.objectApply(this.members, (member, id) => {\n callback(this.get(id));\n });\n }\n\n /** Updates the id for connected member. For internal use only. */\n setMyID(id: string) {\n this.myID = id;\n }\n\n /** Handles subscription data. For internal use only. */\n onSubscription(subscriptionData: any) {\n this.members = subscriptionData.presence.hash;\n this.count = subscriptionData.presence.count;\n this.me = this.get(this.myID);\n }\n\n /** Adds a new member to the collection. For internal use only. */\n addMember(memberData: any) {\n if (this.get(memberData.user_id) === null) {\n this.count++;\n }\n this.members[memberData.user_id] = memberData.user_info;\n return this.get(memberData.user_id);\n }\n\n /** Adds a member from the collection. For internal use only. */\n removeMember(memberData: any) {\n var member = this.get(memberData.user_id);\n if (member) {\n delete this.members[memberData.user_id];\n this.count--;\n }\n return member;\n }\n\n /** Resets the collection to the initial state. For internal use only. */\n reset() {\n this.members = {};\n this.count = 0;\n this.myID = null;\n this.me = null;\n }\n}\n","import PrivateChannel from './private_channel';\nimport Logger from '../logger';\nimport Members from './members';\nimport Pusher from '../pusher';\nimport UrlStore from 'core/utils/url_store';\nimport { PusherEvent } from '../connection/protocol/message-types';\nimport Metadata from './metadata';\nimport { ChannelAuthorizationData } from '../auth/options';\n\nexport default class PresenceChannel extends PrivateChannel {\n members: Members;\n\n /** Adds presence channel functionality to private channels.\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\n constructor(name: string, pusher: Pusher) {\n super(name, pusher);\n this.members = new Members();\n }\n\n /** Authorizes the connection as a member of the channel.\n *\n * @param {String} socketId\n * @param {Function} callback\n */\n authorize(socketId: string, callback: Function) {\n super.authorize(socketId, async (error, authData) => {\n if (!error) {\n authData = authData as ChannelAuthorizationData;\n if (authData.channel_data != null) {\n var channelData = JSON.parse(authData.channel_data);\n this.members.setMyID(channelData.user_id);\n } else {\n await this.pusher.user.signinDonePromise;\n if (this.pusher.user.user_data != null) {\n // If the user is signed in, get the id of the authenticated user\n // and allow the presence authorization to continue.\n this.members.setMyID(this.pusher.user.user_data.id);\n } else {\n let suffix = UrlStore.buildLogSuffix('authorizationEndpoint');\n Logger.error(\n `Invalid auth response for channel '${this.name}', ` +\n `expected 'channel_data' field. ${suffix}, ` +\n `or the user should be signed in.`\n );\n callback('Invalid auth response');\n return;\n }\n }\n }\n callback(error, authData);\n });\n }\n\n /** Handles presence and subscription events. For internal use only.\n *\n * @param {PusherEvent} event\n */\n handleEvent(event: PusherEvent) {\n var eventName = event.event;\n if (eventName.indexOf('pusher_internal:') === 0) {\n this.handleInternalEvent(event);\n } else {\n var data = event.data;\n var metadata: Metadata = {};\n if (event.user_id) {\n metadata.user_id = event.user_id;\n }\n this.emit(eventName, data, metadata);\n }\n }\n handleInternalEvent(event: PusherEvent) {\n var eventName = event.event;\n var data = event.data;\n switch (eventName) {\n case 'pusher_internal:subscription_succeeded':\n this.handleSubscriptionSucceededEvent(event);\n break;\n case 'pusher_internal:subscription_count':\n this.handleSubscriptionCountEvent(event);\n break;\n case 'pusher_internal:member_added':\n var addedMember = this.members.addMember(data);\n this.emit('pusher:member_added', addedMember);\n break;\n case 'pusher_internal:member_removed':\n var removedMember = this.members.removeMember(data);\n if (removedMember) {\n this.emit('pusher:member_removed', removedMember);\n }\n break;\n }\n }\n\n handleSubscriptionSucceededEvent(event: PusherEvent) {\n this.subscriptionPending = false;\n this.subscribed = true;\n if (this.subscriptionCancelled) {\n this.pusher.unsubscribe(this.name);\n } else {\n this.members.onSubscription(event.data);\n this.emit('pusher:subscription_succeeded', this.members);\n }\n }\n\n /** Resets the channel state, including members map. For internal use only. */\n disconnect() {\n this.members.reset();\n super.disconnect();\n }\n}\n","import PrivateChannel from './private_channel';\nimport * as Errors from '../errors';\nimport Logger from '../logger';\nimport Pusher from '../pusher';\nimport { decode as encodeUTF8 } from '@stablelib/utf8';\nimport { decode as decodeBase64 } from '@stablelib/base64';\nimport Dispatcher from '../events/dispatcher';\nimport { PusherEvent } from '../connection/protocol/message-types';\nimport {\n ChannelAuthorizationData,\n ChannelAuthorizationCallback\n} from '../auth/options';\nimport * as nacl from 'tweetnacl';\n\n/** Extends private channels to provide encrypted channel interface.\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\nexport default class EncryptedChannel extends PrivateChannel {\n key: Uint8Array = null;\n nacl: nacl;\n\n constructor(name: string, pusher: Pusher, nacl: nacl) {\n super(name, pusher);\n this.nacl = nacl;\n }\n\n /** Authorizes the connection to use the channel.\n *\n * @param {String} socketId\n * @param {Function} callback\n */\n authorize(socketId: string, callback: ChannelAuthorizationCallback) {\n super.authorize(\n socketId,\n (error: Error | null, authData: ChannelAuthorizationData) => {\n if (error) {\n callback(error, authData);\n return;\n }\n let sharedSecret = authData['shared_secret'];\n if (!sharedSecret) {\n callback(\n new Error(\n `No shared_secret key in auth payload for encrypted channel: ${this.name}`\n ),\n null\n );\n return;\n }\n this.key = decodeBase64(sharedSecret);\n delete authData['shared_secret'];\n callback(null, authData);\n }\n );\n }\n\n trigger(event: string, data: any): boolean {\n throw new Errors.UnsupportedFeature(\n 'Client events are not currently supported for encrypted channels'\n );\n }\n\n /** Handles an event. For internal use only.\n *\n * @param {PusherEvent} event\n */\n handleEvent(event: PusherEvent) {\n var eventName = event.event;\n var data = event.data;\n if (\n eventName.indexOf('pusher_internal:') === 0 ||\n eventName.indexOf('pusher:') === 0\n ) {\n super.handleEvent(event);\n return;\n }\n this.handleEncryptedEvent(eventName, data);\n }\n\n private handleEncryptedEvent(event: string, data: any): void {\n if (!this.key) {\n Logger.debug(\n 'Received encrypted event before key has been retrieved from the authEndpoint'\n );\n return;\n }\n if (!data.ciphertext || !data.nonce) {\n Logger.error(\n 'Unexpected format for encrypted event, expected object with `ciphertext` and `nonce` fields, got: ' +\n data\n );\n return;\n }\n let cipherText = decodeBase64(data.ciphertext);\n if (cipherText.length < this.nacl.secretbox.overheadLength) {\n Logger.error(\n `Expected encrypted event ciphertext length to be ${this.nacl.secretbox.overheadLength}, got: ${cipherText.length}`\n );\n return;\n }\n let nonce = decodeBase64(data.nonce);\n if (nonce.length < this.nacl.secretbox.nonceLength) {\n Logger.error(\n `Expected encrypted event nonce length to be ${this.nacl.secretbox.nonceLength}, got: ${nonce.length}`\n );\n return;\n }\n\n let bytes = this.nacl.secretbox.open(cipherText, nonce, this.key);\n if (bytes === null) {\n Logger.debug(\n 'Failed to decrypt an event, probably because it was encrypted with a different key. Fetching a new key from the authEndpoint...'\n );\n // Try a single time to retrieve a new auth key and decrypt the event with it\n // If this fails, a new key will be requested when a new message is received\n this.authorize(this.pusher.connection.socket_id, (error, authData) => {\n if (error) {\n Logger.error(\n `Failed to make a request to the authEndpoint: ${authData}. Unable to fetch new key, so dropping encrypted event`\n );\n return;\n }\n bytes = this.nacl.secretbox.open(cipherText, nonce, this.key);\n if (bytes === null) {\n Logger.error(\n `Failed to decrypt event with new key. Dropping encrypted event`\n );\n return;\n }\n this.emit(event, this.getDataToEmit(bytes));\n return;\n });\n return;\n }\n this.emit(event, this.getDataToEmit(bytes));\n }\n\n // Try and parse the decrypted bytes as JSON. If we can't parse it, just\n // return the utf-8 string\n getDataToEmit(bytes: Uint8Array): string {\n let raw = encodeUTF8(bytes);\n try {\n return JSON.parse(raw);\n } catch {\n return raw;\n }\n }\n}\n","import { default as EventsDispatcher } from '../events/dispatcher';\nimport { OneOffTimer as Timer } from '../utils/timers';\nimport { Config } from '../config';\nimport Logger from '../logger';\nimport HandshakePayload from './handshake/handshake_payload';\nimport Connection from './connection';\nimport Strategy from '../strategies/strategy';\nimport StrategyRunner from '../strategies/strategy_runner';\nimport * as Collections from '../utils/collections';\nimport Timeline from '../timeline/timeline';\nimport ConnectionManagerOptions from './connection_manager_options';\nimport Runtime from 'runtime';\n\nimport {\n ErrorCallbacks,\n HandshakeCallbacks,\n ConnectionCallbacks\n} from './callbacks';\nimport Action from './protocol/action';\n\n/** Manages connection to Pusher.\n *\n * Uses a strategy (currently only default), timers and network availability\n * info to establish a connection and export its state. In case of failures,\n * manages reconnection attempts.\n *\n * Exports state changes as following events:\n * - \"state_change\", { previous: p, current: state }\n * - state\n *\n * States:\n * - initialized - initial state, never transitioned to\n * - connecting - connection is being established\n * - connected - connection has been fully established\n * - disconnected - on requested disconnection\n * - unavailable - after connection timeout or when there's no network\n * - failed - when the connection strategy is not supported\n *\n * Options:\n * - unavailableTimeout - time to transition to unavailable state\n * - activityTimeout - time after which ping message should be sent\n * - pongTimeout - time for Pusher to respond with pong before reconnecting\n *\n * @param {String} key application key\n * @param {Object} options\n */\nexport default class ConnectionManager extends EventsDispatcher {\n key: string;\n options: ConnectionManagerOptions;\n state: string;\n connection: Connection;\n usingTLS: boolean;\n timeline: Timeline;\n socket_id: string;\n unavailableTimer: Timer;\n activityTimer: Timer;\n retryTimer: Timer;\n activityTimeout: number;\n strategy: Strategy;\n runner: StrategyRunner;\n errorCallbacks: ErrorCallbacks;\n handshakeCallbacks: HandshakeCallbacks;\n connectionCallbacks: ConnectionCallbacks;\n\n constructor(key: string, options: ConnectionManagerOptions) {\n super();\n this.state = 'initialized';\n this.connection = null;\n\n this.key = key;\n this.options = options;\n this.timeline = this.options.timeline;\n this.usingTLS = this.options.useTLS;\n\n this.errorCallbacks = this.buildErrorCallbacks();\n this.connectionCallbacks = this.buildConnectionCallbacks(\n this.errorCallbacks\n );\n this.handshakeCallbacks = this.buildHandshakeCallbacks(this.errorCallbacks);\n\n var Network = Runtime.getNetwork();\n\n Network.bind('online', () => {\n this.timeline.info({ netinfo: 'online' });\n if (this.state === 'connecting' || this.state === 'unavailable') {\n this.retryIn(0);\n }\n });\n Network.bind('offline', () => {\n this.timeline.info({ netinfo: 'offline' });\n if (this.connection) {\n this.sendActivityCheck();\n }\n });\n\n this.updateStrategy();\n }\n\n switchCluster(key: string) {\n this.key = key;\n // This ensures that the new config coming from\n // pusher instance are taken into account\n // such as appKey and cluster\n this.updateStrategy();\n this.retryIn(0);\n }\n\n /** Establishes a connection to Pusher.\n *\n * Does nothing when connection is already established. See top-level doc\n * to find events emitted on connection attempts.\n */\n connect() {\n if (this.connection || this.runner) {\n return;\n }\n if (!this.strategy.isSupported()) {\n this.updateState('failed');\n return;\n }\n this.updateState('connecting');\n this.startConnecting();\n this.setUnavailableTimer();\n }\n\n /** Sends raw data.\n *\n * @param {String} data\n */\n send(data) {\n if (this.connection) {\n return this.connection.send(data);\n } else {\n return false;\n }\n }\n\n /** Sends an event.\n *\n * @param {String} name\n * @param {String} data\n * @param {String} [channel]\n * @returns {Boolean} whether message was sent or not\n */\n send_event(name: string, data: any, channel?: string) {\n if (this.connection) {\n return this.connection.send_event(name, data, channel);\n } else {\n return false;\n }\n }\n\n /** Closes the connection. */\n disconnect() {\n this.disconnectInternally();\n this.updateState('disconnected');\n }\n\n isUsingTLS() {\n return this.usingTLS;\n }\n\n private startConnecting() {\n var callback = (error, handshake) => {\n if (error) {\n this.runner = this.strategy.connect(0, callback);\n } else {\n if (handshake.action === 'error') {\n this.emit('error', {\n type: 'HandshakeError',\n error: handshake.error\n });\n this.timeline.error({ handshakeError: handshake.error });\n } else {\n this.abortConnecting(); // we don't support switching connections yet\n this.handshakeCallbacks[handshake.action](handshake);\n }\n }\n };\n this.runner = this.strategy.connect(0, callback);\n }\n\n private abortConnecting() {\n if (this.runner) {\n this.runner.abort();\n this.runner = null;\n }\n }\n\n private disconnectInternally() {\n this.abortConnecting();\n this.clearRetryTimer();\n this.clearUnavailableTimer();\n if (this.connection) {\n var connection = this.abandonConnection();\n connection.close();\n }\n }\n\n private updateStrategy() {\n this.strategy = this.options.getStrategy({\n key: this.key,\n timeline: this.timeline,\n useTLS: this.usingTLS\n });\n }\n\n private retryIn(delay) {\n this.timeline.info({ action: 'retry', delay: delay });\n if (delay > 0) {\n this.emit('connecting_in', Math.round(delay / 1000));\n }\n this.retryTimer = new Timer(delay || 0, () => {\n this.disconnectInternally();\n this.connect();\n });\n }\n\n private clearRetryTimer() {\n if (this.retryTimer) {\n this.retryTimer.ensureAborted();\n this.retryTimer = null;\n }\n }\n\n private setUnavailableTimer() {\n this.unavailableTimer = new Timer(this.options.unavailableTimeout, () => {\n this.updateState('unavailable');\n });\n }\n\n private clearUnavailableTimer() {\n if (this.unavailableTimer) {\n this.unavailableTimer.ensureAborted();\n }\n }\n\n private sendActivityCheck() {\n this.stopActivityCheck();\n this.connection.ping();\n // wait for pong response\n this.activityTimer = new Timer(this.options.pongTimeout, () => {\n this.timeline.error({ pong_timed_out: this.options.pongTimeout });\n this.retryIn(0);\n });\n }\n\n private resetActivityCheck() {\n this.stopActivityCheck();\n // send ping after inactivity\n if (this.connection && !this.connection.handlesActivityChecks()) {\n this.activityTimer = new Timer(this.activityTimeout, () => {\n this.sendActivityCheck();\n });\n }\n }\n\n private stopActivityCheck() {\n if (this.activityTimer) {\n this.activityTimer.ensureAborted();\n }\n }\n\n private buildConnectionCallbacks(\n errorCallbacks: ErrorCallbacks\n ): ConnectionCallbacks {\n return Collections.extend({}, errorCallbacks, {\n message: message => {\n // includes pong messages from server\n this.resetActivityCheck();\n this.emit('message', message);\n },\n ping: () => {\n this.send_event('pusher:pong', {});\n },\n activity: () => {\n this.resetActivityCheck();\n },\n error: error => {\n // just emit error to user - socket will already be closed by browser\n this.emit('error', error);\n },\n closed: () => {\n this.abandonConnection();\n if (this.shouldRetry()) {\n this.retryIn(1000);\n }\n }\n });\n }\n\n private buildHandshakeCallbacks(\n errorCallbacks: ErrorCallbacks\n ): HandshakeCallbacks {\n return Collections.extend({}, errorCallbacks, {\n connected: (handshake: HandshakePayload) => {\n this.activityTimeout = Math.min(\n this.options.activityTimeout,\n handshake.activityTimeout,\n handshake.connection.activityTimeout || Infinity\n );\n this.clearUnavailableTimer();\n this.setConnection(handshake.connection);\n this.socket_id = this.connection.id;\n this.updateState('connected', { socket_id: this.socket_id });\n }\n });\n }\n\n private buildErrorCallbacks(): ErrorCallbacks {\n let withErrorEmitted = callback => {\n return (result: Action | HandshakePayload) => {\n if (result.error) {\n this.emit('error', { type: 'WebSocketError', error: result.error });\n }\n callback(result);\n };\n };\n\n return {\n tls_only: withErrorEmitted(() => {\n this.usingTLS = true;\n this.updateStrategy();\n this.retryIn(0);\n }),\n refused: withErrorEmitted(() => {\n this.disconnect();\n }),\n backoff: withErrorEmitted(() => {\n this.retryIn(1000);\n }),\n retry: withErrorEmitted(() => {\n this.retryIn(0);\n })\n };\n }\n\n private setConnection(connection) {\n this.connection = connection;\n for (var event in this.connectionCallbacks) {\n this.connection.bind(event, this.connectionCallbacks[event]);\n }\n this.resetActivityCheck();\n }\n\n private abandonConnection() {\n if (!this.connection) {\n return;\n }\n this.stopActivityCheck();\n for (var event in this.connectionCallbacks) {\n this.connection.unbind(event, this.connectionCallbacks[event]);\n }\n var connection = this.connection;\n this.connection = null;\n return connection;\n }\n\n private updateState(newState: string, data?: any) {\n var previousState = this.state;\n this.state = newState;\n if (previousState !== newState) {\n var newStateDescription = newState;\n if (newStateDescription === 'connected') {\n newStateDescription += ' with new socket ID ' + data.socket_id;\n }\n Logger.debug(\n 'State changed',\n previousState + ' -> ' + newStateDescription\n );\n this.timeline.info({ state: newState, params: data });\n this.emit('state_change', { previous: previousState, current: newState });\n this.emit(newState, data);\n }\n }\n\n private shouldRetry(): boolean {\n return this.state === 'connecting' || this.state === 'connected';\n }\n}\n","import Channel from './channel';\nimport * as Collections from '../utils/collections';\nimport ChannelTable from './channel_table';\nimport Factory from '../utils/factory';\nimport Pusher from '../pusher';\nimport Logger from '../logger';\nimport * as Errors from '../errors';\nimport urlStore from '../utils/url_store';\n\n/** Handles a channel map. */\nexport default class Channels {\n channels: ChannelTable;\n\n constructor() {\n this.channels = {};\n }\n\n /** Creates or retrieves an existing channel by its name.\n *\n * @param {String} name\n * @param {Pusher} pusher\n * @return {Channel}\n */\n add(name: string, pusher: Pusher) {\n if (!this.channels[name]) {\n this.channels[name] = createChannel(name, pusher);\n }\n return this.channels[name];\n }\n\n /** Returns a list of all channels\n *\n * @return {Array}\n */\n all(): Channel[] {\n return Collections.values(this.channels);\n }\n\n /** Finds a channel by its name.\n *\n * @param {String} name\n * @return {Channel} channel or null if it doesn't exist\n */\n find(name: string) {\n return this.channels[name];\n }\n\n /** Removes a channel from the map.\n *\n * @param {String} name\n */\n remove(name: string) {\n var channel = this.channels[name];\n delete this.channels[name];\n return channel;\n }\n\n /** Proxies disconnection signal to all channels. */\n disconnect() {\n Collections.objectApply(this.channels, function(channel) {\n channel.disconnect();\n });\n }\n}\n\nfunction createChannel(name: string, pusher: Pusher): Channel {\n if (name.indexOf('private-encrypted-') === 0) {\n if (pusher.config.nacl) {\n return Factory.createEncryptedChannel(name, pusher, pusher.config.nacl);\n }\n let errMsg =\n 'Tried to subscribe to a private-encrypted- channel but no nacl implementation available';\n let suffix = urlStore.buildLogSuffix('encryptedChannelSupport');\n throw new Errors.UnsupportedFeature(`${errMsg}. ${suffix}`);\n } else if (name.indexOf('private-') === 0) {\n return Factory.createPrivateChannel(name, pusher);\n } else if (name.indexOf('presence-') === 0) {\n return Factory.createPresenceChannel(name, pusher);\n } else if (name.indexOf('#') === 0) {\n throw new Errors.BadChannelName(\n 'Cannot create a channel with name \"' + name + '\".'\n );\n } else {\n return Factory.createChannel(name, pusher);\n }\n}\n","import AssistantToTheTransportManager from '../transports/assistant_to_the_transport_manager';\nimport PingDelayOptions from '../transports/ping_delay_options';\nimport Transport from '../transports/transport';\nimport TransportManager from '../transports/transport_manager';\nimport Handshake from '../connection/handshake';\nimport TransportConnection from '../transports/transport_connection';\nimport SocketHooks from '../http/socket_hooks';\nimport HTTPSocket from '../http/http_socket';\n\nimport Timeline from '../timeline/timeline';\nimport {\n default as TimelineSender,\n TimelineSenderOptions\n} from '../timeline/timeline_sender';\nimport PresenceChannel from '../channels/presence_channel';\nimport PrivateChannel from '../channels/private_channel';\nimport EncryptedChannel from '../channels/encrypted_channel';\nimport Channel from '../channels/channel';\nimport ConnectionManager from '../connection/connection_manager';\nimport ConnectionManagerOptions from '../connection/connection_manager_options';\nimport Ajax from '../http/ajax';\nimport Channels from '../channels/channels';\nimport Pusher from '../pusher';\nimport { Config } from '../config';\nimport * as nacl from 'tweetnacl';\n\nvar Factory = {\n createChannels(): Channels {\n return new Channels();\n },\n\n createConnectionManager(\n key: string,\n options: ConnectionManagerOptions\n ): ConnectionManager {\n return new ConnectionManager(key, options);\n },\n\n createChannel(name: string, pusher: Pusher): Channel {\n return new Channel(name, pusher);\n },\n\n createPrivateChannel(name: string, pusher: Pusher): PrivateChannel {\n return new PrivateChannel(name, pusher);\n },\n\n createPresenceChannel(name: string, pusher: Pusher): PresenceChannel {\n return new PresenceChannel(name, pusher);\n },\n\n createEncryptedChannel(\n name: string,\n pusher: Pusher,\n nacl: nacl\n ): EncryptedChannel {\n return new EncryptedChannel(name, pusher, nacl);\n },\n\n createTimelineSender(timeline: Timeline, options: TimelineSenderOptions) {\n return new TimelineSender(timeline, options);\n },\n\n createHandshake(\n transport: TransportConnection,\n callback: (HandshakePayload) => void\n ): Handshake {\n return new Handshake(transport, callback);\n },\n\n createAssistantToTheTransportManager(\n manager: TransportManager,\n transport: Transport,\n options: PingDelayOptions\n ): AssistantToTheTransportManager {\n return new AssistantToTheTransportManager(manager, transport, options);\n }\n};\n\nexport default Factory;\n","import AssistantToTheTransportManager from './assistant_to_the_transport_manager';\nimport Transport from './transport';\nimport PingDelayOptions from './ping_delay_options';\nimport Factory from '../utils/factory';\n\nexport interface TransportManagerOptions extends PingDelayOptions {\n lives?: number;\n}\n\n/** Keeps track of the number of lives left for a transport.\n *\n * In the beginning of a session, transports may be assigned a number of\n * lives. When an AssistantToTheTransportManager instance reports a transport\n * connection closed uncleanly, the transport loses a life. When the number\n * of lives drops to zero, the transport gets disabled by its manager.\n *\n * @param {Object} options\n */\nexport default class TransportManager {\n options: TransportManagerOptions;\n livesLeft: number;\n\n constructor(options: TransportManagerOptions) {\n this.options = options || {};\n this.livesLeft = this.options.lives || Infinity;\n }\n\n /** Creates a assistant for the transport.\n *\n * @param {Transport} transport\n * @returns {AssistantToTheTransportManager}\n */\n getAssistant(transport: Transport): AssistantToTheTransportManager {\n return Factory.createAssistantToTheTransportManager(this, transport, {\n minPingDelay: this.options.minPingDelay,\n maxPingDelay: this.options.maxPingDelay\n });\n }\n\n /** Returns whether the transport has any lives left.\n *\n * @returns {Boolean}\n */\n isAlive(): boolean {\n return this.livesLeft > 0;\n }\n\n /** Takes one life from the transport. */\n reportDeath() {\n this.livesLeft -= 1;\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport { OneOffTimer as Timer } from '../utils/timers';\nimport Strategy from './strategy';\nimport StrategyOptions from './strategy_options';\n\n/** Loops through strategies with optional timeouts.\n *\n * Options:\n * - loop - whether it should loop through the substrategy list\n * - timeout - initial timeout for a single substrategy\n * - timeoutLimit - maximum timeout\n *\n * @param {Strategy[]} strategies\n * @param {Object} options\n */\nexport default class SequentialStrategy implements Strategy {\n strategies: Strategy[];\n loop: boolean;\n failFast: boolean;\n timeout: number;\n timeoutLimit: number;\n\n constructor(strategies: Strategy[], options: StrategyOptions) {\n this.strategies = strategies;\n this.loop = Boolean(options.loop);\n this.failFast = Boolean(options.failFast);\n this.timeout = options.timeout;\n this.timeoutLimit = options.timeoutLimit;\n }\n\n isSupported(): boolean {\n return Collections.any(this.strategies, Util.method('isSupported'));\n }\n\n connect(minPriority: number, callback: Function) {\n var strategies = this.strategies;\n var current = 0;\n var timeout = this.timeout;\n var runner = null;\n\n var tryNextStrategy = (error, handshake) => {\n if (handshake) {\n callback(null, handshake);\n } else {\n current = current + 1;\n if (this.loop) {\n current = current % strategies.length;\n }\n\n if (current < strategies.length) {\n if (timeout) {\n timeout = timeout * 2;\n if (this.timeoutLimit) {\n timeout = Math.min(timeout, this.timeoutLimit);\n }\n }\n runner = this.tryStrategy(\n strategies[current],\n minPriority,\n { timeout, failFast: this.failFast },\n tryNextStrategy\n );\n } else {\n callback(true);\n }\n }\n };\n\n runner = this.tryStrategy(\n strategies[current],\n minPriority,\n { timeout: timeout, failFast: this.failFast },\n tryNextStrategy\n );\n\n return {\n abort: function() {\n runner.abort();\n },\n forceMinPriority: function(p) {\n minPriority = p;\n if (runner) {\n runner.forceMinPriority(p);\n }\n }\n };\n }\n\n private tryStrategy(\n strategy: Strategy,\n minPriority: number,\n options: StrategyOptions,\n callback: Function\n ) {\n var timer = null;\n var runner = null;\n\n if (options.timeout > 0) {\n timer = new Timer(options.timeout, function() {\n runner.abort();\n callback(true);\n });\n }\n\n runner = strategy.connect(minPriority, function(error, handshake) {\n if (error && timer && timer.isRunning() && !options.failFast) {\n // advance to the next strategy after the timeout\n return;\n }\n if (timer) {\n timer.ensureAborted();\n }\n callback(error, handshake);\n });\n\n return {\n abort: function() {\n if (timer) {\n timer.ensureAborted();\n }\n runner.abort();\n },\n forceMinPriority: function(p) {\n runner.forceMinPriority(p);\n }\n };\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport Strategy from './strategy';\n\n/** Launches all substrategies and emits prioritized connected transports.\n *\n * @param {Array} strategies\n */\nexport default class BestConnectedEverStrategy implements Strategy {\n strategies: Strategy[];\n\n constructor(strategies: Strategy[]) {\n this.strategies = strategies;\n }\n\n isSupported(): boolean {\n return Collections.any(this.strategies, Util.method('isSupported'));\n }\n\n connect(minPriority: number, callback: Function) {\n return connect(this.strategies, minPriority, function(i, runners) {\n return function(error, handshake) {\n runners[i].error = error;\n if (error) {\n if (allRunnersFailed(runners)) {\n callback(true);\n }\n return;\n }\n Collections.apply(runners, function(runner) {\n runner.forceMinPriority(handshake.transport.priority);\n });\n callback(null, handshake);\n };\n });\n }\n}\n\n/** Connects to all strategies in parallel.\n *\n * Callback builder should be a function that takes two arguments: index\n * and a list of runners. It should return another function that will be\n * passed to the substrategy with given index. Runners can be aborted using\n * abortRunner(s) functions from this class.\n *\n * @param {Array} strategies\n * @param {Function} callbackBuilder\n * @return {Object} strategy runner\n */\nfunction connect(\n strategies: Strategy[],\n minPriority: number,\n callbackBuilder: Function\n) {\n var runners = Collections.map(strategies, function(strategy, i, _, rs) {\n return strategy.connect(minPriority, callbackBuilder(i, rs));\n });\n return {\n abort: function() {\n Collections.apply(runners, abortRunner);\n },\n forceMinPriority: function(p) {\n Collections.apply(runners, function(runner) {\n runner.forceMinPriority(p);\n });\n }\n };\n}\n\nfunction allRunnersFailed(runners): boolean {\n return Collections.all(runners, function(runner) {\n return Boolean(runner.error);\n });\n}\n\nfunction abortRunner(runner) {\n if (!runner.error && !runner.aborted) {\n runner.abort();\n runner.aborted = true;\n }\n}\n","import Util from '../util';\nimport Runtime from 'runtime';\nimport Strategy from './strategy';\nimport SequentialStrategy from './sequential_strategy';\nimport StrategyOptions from './strategy_options';\nimport TransportStrategy from './transport_strategy';\nimport Timeline from '../timeline/timeline';\nimport * as Collections from '../utils/collections';\n\nexport interface TransportStrategyDictionary {\n [key: string]: TransportStrategy;\n}\n\n/** Caches the last successful transport and, after the first few attempts,\n * uses the cached transport for subsequent attempts.\n *\n * @param {Strategy} strategy\n * @param {Object} transports\n * @param {Object} options\n */\nexport default class WebSocketPrioritizedCachedStrategy implements Strategy {\n strategy: Strategy;\n transports: TransportStrategyDictionary;\n ttl: number;\n usingTLS: boolean;\n timeline: Timeline;\n\n constructor(\n strategy: Strategy,\n transports: TransportStrategyDictionary,\n options: StrategyOptions\n ) {\n this.strategy = strategy;\n this.transports = transports;\n this.ttl = options.ttl || 1800 * 1000;\n this.usingTLS = options.useTLS;\n this.timeline = options.timeline;\n }\n\n isSupported(): boolean {\n return this.strategy.isSupported();\n }\n\n connect(minPriority: number, callback: Function) {\n var usingTLS = this.usingTLS;\n var info = fetchTransportCache(usingTLS);\n var cacheSkipCount = info && info.cacheSkipCount ? info.cacheSkipCount : 0;\n\n var strategies = [this.strategy];\n if (info && info.timestamp + this.ttl >= Util.now()) {\n var transport = this.transports[info.transport];\n if (transport) {\n if (['ws', 'wss'].includes(info.transport) || cacheSkipCount > 3) {\n this.timeline.info({\n cached: true,\n transport: info.transport,\n latency: info.latency\n });\n strategies.push(\n new SequentialStrategy([transport], {\n timeout: info.latency * 2 + 1000,\n failFast: true\n })\n );\n } else {\n cacheSkipCount++;\n }\n }\n }\n\n var startTimestamp = Util.now();\n var runner = strategies\n .pop()\n .connect(minPriority, function cb(error, handshake) {\n if (error) {\n flushTransportCache(usingTLS);\n if (strategies.length > 0) {\n startTimestamp = Util.now();\n runner = strategies.pop().connect(minPriority, cb);\n } else {\n callback(error);\n }\n } else {\n storeTransportCache(\n usingTLS,\n handshake.transport.name,\n Util.now() - startTimestamp,\n cacheSkipCount\n );\n callback(null, handshake);\n }\n });\n\n return {\n abort: function() {\n runner.abort();\n },\n forceMinPriority: function(p) {\n minPriority = p;\n if (runner) {\n runner.forceMinPriority(p);\n }\n }\n };\n }\n}\n\nfunction getTransportCacheKey(usingTLS: boolean): string {\n return 'pusherTransport' + (usingTLS ? 'TLS' : 'NonTLS');\n}\n\nfunction fetchTransportCache(usingTLS: boolean): any {\n var storage = Runtime.getLocalStorage();\n if (storage) {\n try {\n var serializedCache = storage[getTransportCacheKey(usingTLS)];\n if (serializedCache) {\n return JSON.parse(serializedCache);\n }\n } catch (e) {\n flushTransportCache(usingTLS);\n }\n }\n return null;\n}\n\nfunction storeTransportCache(\n usingTLS: boolean,\n transport: TransportStrategy,\n latency: number,\n cacheSkipCount: number\n) {\n var storage = Runtime.getLocalStorage();\n if (storage) {\n try {\n storage[getTransportCacheKey(usingTLS)] = Collections.safeJSONStringify({\n timestamp: Util.now(),\n transport: transport,\n latency: latency,\n cacheSkipCount: cacheSkipCount\n });\n } catch (e) {\n // catch over quota exceptions raised by localStorage\n }\n }\n}\n\nfunction flushTransportCache(usingTLS: boolean) {\n var storage = Runtime.getLocalStorage();\n if (storage) {\n try {\n delete storage[getTransportCacheKey(usingTLS)];\n } catch (e) {\n // catch exceptions raised by localStorage\n }\n }\n}\n","import { OneOffTimer as Timer } from '../utils/timers';\nimport Strategy from './strategy';\nimport StrategyOptions from './strategy_options';\n\n/** Runs substrategy after specified delay.\n *\n * Options:\n * - delay - time in miliseconds to delay the substrategy attempt\n *\n * @param {Strategy} strategy\n * @param {Object} options\n */\nexport default class DelayedStrategy implements Strategy {\n strategy: Strategy;\n options: { delay: number };\n\n constructor(strategy: Strategy, { delay: number }) {\n this.strategy = strategy;\n this.options = { delay: number };\n }\n\n isSupported(): boolean {\n return this.strategy.isSupported();\n }\n\n connect(minPriority: number, callback: Function) {\n var strategy = this.strategy;\n var runner;\n var timer = new Timer(this.options.delay, function() {\n runner = strategy.connect(minPriority, callback);\n });\n\n return {\n abort: function() {\n timer.ensureAborted();\n if (runner) {\n runner.abort();\n }\n },\n forceMinPriority: function(p) {\n minPriority = p;\n if (runner) {\n runner.forceMinPriority(p);\n }\n }\n };\n }\n}\n","import Strategy from './strategy';\nimport StrategyRunner from './strategy_runner';\n\n/** Proxies method calls to one of substrategies basing on the test function.\n *\n * @param {Function} test\n * @param {Strategy} trueBranch strategy used when test returns true\n * @param {Strategy} falseBranch strategy used when test returns false\n */\nexport default class IfStrategy implements Strategy {\n test: () => boolean;\n trueBranch: Strategy;\n falseBranch: Strategy;\n\n constructor(\n test: () => boolean,\n trueBranch: Strategy,\n falseBranch: Strategy\n ) {\n this.test = test;\n this.trueBranch = trueBranch;\n this.falseBranch = falseBranch;\n }\n\n isSupported(): boolean {\n var branch = this.test() ? this.trueBranch : this.falseBranch;\n return branch.isSupported();\n }\n\n connect(minPriority: number, callback: Function): StrategyRunner {\n var branch = this.test() ? this.trueBranch : this.falseBranch;\n return branch.connect(minPriority, callback);\n }\n}\n","import Strategy from './strategy';\nimport StrategyRunner from './strategy_runner';\n\n/** Launches the substrategy and terminates on the first open connection.\n *\n * @param {Strategy} strategy\n */\nexport default class FirstConnectedStrategy implements Strategy {\n strategy: Strategy;\n\n constructor(strategy: Strategy) {\n this.strategy = strategy;\n }\n\n isSupported(): boolean {\n return this.strategy.isSupported();\n }\n\n connect(minPriority: number, callback: Function): StrategyRunner {\n var runner = this.strategy.connect(minPriority, function(error, handshake) {\n if (handshake) {\n runner.abort();\n }\n callback(error, handshake);\n });\n return runner;\n }\n}\n","import * as Collections from 'core/utils/collections';\nimport TransportManager from 'core/transports/transport_manager';\nimport Strategy from 'core/strategies/strategy';\nimport StrategyOptions from 'core/strategies/strategy_options';\nimport SequentialStrategy from 'core/strategies/sequential_strategy';\nimport BestConnectedEverStrategy from 'core/strategies/best_connected_ever_strategy';\nimport WebSocketPrioritizedCachedStrategy, {\n TransportStrategyDictionary\n} from 'core/strategies/websocket_prioritized_cached_strategy';\nimport DelayedStrategy from 'core/strategies/delayed_strategy';\nimport IfStrategy from 'core/strategies/if_strategy';\nimport FirstConnectedStrategy from 'core/strategies/first_connected_strategy';\nimport { Config } from 'core/config';\n\nfunction testSupportsStrategy(strategy: Strategy) {\n return function() {\n return strategy.isSupported();\n };\n}\n\nvar getDefaultStrategy = function(\n config: Config,\n baseOptions: StrategyOptions,\n defineTransport: Function\n): Strategy {\n var definedTransports = {};\n\n function defineTransportStrategy(\n name: string,\n type: string,\n priority: number,\n options: StrategyOptions,\n manager?: TransportManager\n ) {\n var transport = defineTransport(\n config,\n name,\n type,\n priority,\n options,\n manager\n );\n\n definedTransports[name] = transport;\n\n return transport;\n }\n\n var ws_options: StrategyOptions = Object.assign({}, baseOptions, {\n hostNonTLS: config.wsHost + ':' + config.wsPort,\n hostTLS: config.wsHost + ':' + config.wssPort,\n httpPath: config.wsPath\n });\n var wss_options: StrategyOptions = Object.assign({}, ws_options, {\n useTLS: true\n });\n var sockjs_options: StrategyOptions = Object.assign({}, baseOptions, {\n hostNonTLS: config.httpHost + ':' + config.httpPort,\n hostTLS: config.httpHost + ':' + config.httpsPort,\n httpPath: config.httpPath\n });\n\n var timeouts = {\n loop: true,\n timeout: 15000,\n timeoutLimit: 60000\n };\n\n var ws_manager = new TransportManager({\n minPingDelay: 10000,\n maxPingDelay: config.activityTimeout\n });\n var streaming_manager = new TransportManager({\n lives: 2,\n minPingDelay: 10000,\n maxPingDelay: config.activityTimeout\n });\n\n var ws_transport = defineTransportStrategy(\n 'ws',\n 'ws',\n 3,\n ws_options,\n ws_manager\n );\n var wss_transport = defineTransportStrategy(\n 'wss',\n 'ws',\n 3,\n wss_options,\n ws_manager\n );\n var sockjs_transport = defineTransportStrategy(\n 'sockjs',\n 'sockjs',\n 1,\n sockjs_options\n );\n var xhr_streaming_transport = defineTransportStrategy(\n 'xhr_streaming',\n 'xhr_streaming',\n 1,\n sockjs_options,\n streaming_manager\n );\n var xdr_streaming_transport = defineTransportStrategy(\n 'xdr_streaming',\n 'xdr_streaming',\n 1,\n sockjs_options,\n streaming_manager\n );\n var xhr_polling_transport = defineTransportStrategy(\n 'xhr_polling',\n 'xhr_polling',\n 1,\n sockjs_options\n );\n var xdr_polling_transport = defineTransportStrategy(\n 'xdr_polling',\n 'xdr_polling',\n 1,\n sockjs_options\n );\n\n var ws_loop = new SequentialStrategy([ws_transport], timeouts);\n var wss_loop = new SequentialStrategy([wss_transport], timeouts);\n var sockjs_loop = new SequentialStrategy([sockjs_transport], timeouts);\n var streaming_loop = new SequentialStrategy(\n [\n new IfStrategy(\n testSupportsStrategy(xhr_streaming_transport),\n xhr_streaming_transport,\n xdr_streaming_transport\n )\n ],\n timeouts\n );\n var polling_loop = new SequentialStrategy(\n [\n new IfStrategy(\n testSupportsStrategy(xhr_polling_transport),\n xhr_polling_transport,\n xdr_polling_transport\n )\n ],\n timeouts\n );\n\n var http_loop = new SequentialStrategy(\n [\n new IfStrategy(\n testSupportsStrategy(streaming_loop),\n new BestConnectedEverStrategy([\n streaming_loop,\n new DelayedStrategy(polling_loop, { delay: 4000 })\n ]),\n polling_loop\n )\n ],\n timeouts\n );\n\n var http_fallback_loop = new IfStrategy(\n testSupportsStrategy(http_loop),\n http_loop,\n sockjs_loop\n );\n\n var wsStrategy;\n if (baseOptions.useTLS) {\n wsStrategy = new BestConnectedEverStrategy([\n ws_loop,\n new DelayedStrategy(http_fallback_loop, { delay: 2000 })\n ]);\n } else {\n wsStrategy = new BestConnectedEverStrategy([\n ws_loop,\n new DelayedStrategy(wss_loop, { delay: 2000 }),\n new DelayedStrategy(http_fallback_loop, { delay: 5000 })\n ]);\n }\n\n return new WebSocketPrioritizedCachedStrategy(\n new FirstConnectedStrategy(\n new IfStrategy(\n testSupportsStrategy(ws_transport),\n wsStrategy,\n http_fallback_loop\n )\n ),\n definedTransports,\n {\n ttl: 1800000,\n timeline: baseOptions.timeline,\n useTLS: baseOptions.useTLS\n }\n );\n};\n\nexport default getDefaultStrategy;\n","import { Dependencies } from '../dom/dependencies';\n\n/** Initializes the transport.\n *\n * Fetches resources if needed and then transitions to initialized.\n */\nexport default function() {\n var self = this;\n\n self.timeline.info(\n self.buildTimelineMessage({\n transport: self.name + (self.options.useTLS ? 's' : '')\n })\n );\n\n if (self.hooks.isInitialized()) {\n self.changeState('initialized');\n } else if (self.hooks.file) {\n self.changeState('initializing');\n Dependencies.load(\n self.hooks.file,\n { useTLS: self.options.useTLS },\n function(error, callback) {\n if (self.hooks.isInitialized()) {\n self.changeState('initialized');\n callback(true);\n } else {\n if (error) {\n self.onError(error);\n }\n self.onClose();\n callback(false);\n }\n }\n );\n } else {\n self.onClose();\n }\n}\n","import HTTPRequest from 'core/http/http_request';\nimport RequestHooks from 'core/http/request_hooks';\nimport Ajax from 'core/http/ajax';\nimport * as Errors from 'core/errors';\n\nvar hooks: RequestHooks = {\n getRequest: function(socket: HTTPRequest): Ajax {\n var xdr = new (window).XDomainRequest();\n xdr.ontimeout = function() {\n socket.emit('error', new Errors.RequestTimedOut());\n socket.close();\n };\n xdr.onerror = function(e) {\n socket.emit('error', e);\n socket.close();\n };\n xdr.onprogress = function() {\n if (xdr.responseText && xdr.responseText.length > 0) {\n socket.onChunk(200, xdr.responseText);\n }\n };\n xdr.onload = function() {\n if (xdr.responseText && xdr.responseText.length > 0) {\n socket.onChunk(200, xdr.responseText);\n }\n socket.emit('finished', 200);\n socket.close();\n };\n return xdr;\n },\n abortRequest: function(xdr: Ajax) {\n xdr.ontimeout = xdr.onerror = xdr.onprogress = xdr.onload = null;\n xdr.abort();\n }\n};\n\nexport default hooks;\n","import Runtime from 'runtime';\nimport RequestHooks from './request_hooks';\nimport Ajax from './ajax';\nimport { default as EventsDispatcher } from '../events/dispatcher';\n\nconst MAX_BUFFER_LENGTH = 256 * 1024;\n\nexport default class HTTPRequest extends EventsDispatcher {\n hooks: RequestHooks;\n method: string;\n url: string;\n position: number;\n xhr: Ajax;\n unloader: Function;\n\n constructor(hooks: RequestHooks, method: string, url: string) {\n super();\n this.hooks = hooks;\n this.method = method;\n this.url = url;\n }\n\n start(payload?: any) {\n this.position = 0;\n this.xhr = this.hooks.getRequest(this);\n\n this.unloader = () => {\n this.close();\n };\n Runtime.addUnloadListener(this.unloader);\n\n this.xhr.open(this.method, this.url, true);\n\n if (this.xhr.setRequestHeader) {\n this.xhr.setRequestHeader('Content-Type', 'application/json'); // ReactNative doesn't set this header by default.\n }\n this.xhr.send(payload);\n }\n\n close() {\n if (this.unloader) {\n Runtime.removeUnloadListener(this.unloader);\n this.unloader = null;\n }\n if (this.xhr) {\n this.hooks.abortRequest(this.xhr);\n this.xhr = null;\n }\n }\n\n onChunk(status: number, data: any) {\n while (true) {\n var chunk = this.advanceBuffer(data);\n if (chunk) {\n this.emit('chunk', { status: status, data: chunk });\n } else {\n break;\n }\n }\n if (this.isBufferTooLong(data)) {\n this.emit('buffer_too_long');\n }\n }\n\n private advanceBuffer(buffer: any[]): any {\n var unreadData = buffer.slice(this.position);\n var endOfLinePosition = unreadData.indexOf('\\n');\n\n if (endOfLinePosition !== -1) {\n this.position += endOfLinePosition + 1;\n return unreadData.slice(0, endOfLinePosition);\n } else {\n // chunk is not finished yet, don't move the buffer pointer\n return null;\n }\n }\n\n private isBufferTooLong(buffer: any): boolean {\n return this.position === buffer.length && buffer.length > MAX_BUFFER_LENGTH;\n }\n}\n","enum State {\n CONNECTING = 0,\n OPEN = 1,\n CLOSED = 3\n}\n\nexport default State;\n","import URLLocation from './url_location';\nimport State from './state';\nimport Socket from '../socket';\nimport SocketHooks from './socket_hooks';\nimport Util from '../util';\nimport Ajax from './ajax';\nimport HTTPRequest from './http_request';\nimport Runtime from 'runtime';\n\nvar autoIncrement = 1;\n\nclass HTTPSocket implements Socket {\n hooks: SocketHooks;\n session: string;\n location: URLLocation;\n readyState: State;\n stream: HTTPRequest;\n\n onopen: () => void;\n onerror: (error: any) => void;\n onclose: (closeEvent: any) => void;\n onmessage: (message: any) => void;\n onactivity: () => void;\n\n constructor(hooks: SocketHooks, url: string) {\n this.hooks = hooks;\n this.session = randomNumber(1000) + '/' + randomString(8);\n this.location = getLocation(url);\n this.readyState = State.CONNECTING;\n this.openStream();\n }\n\n send(payload: any) {\n return this.sendRaw(JSON.stringify([payload]));\n }\n\n ping() {\n this.hooks.sendHeartbeat(this);\n }\n\n close(code: any, reason: any) {\n this.onClose(code, reason, true);\n }\n\n /** For internal use only */\n sendRaw(payload: any): boolean {\n if (this.readyState === State.OPEN) {\n try {\n Runtime.createSocketRequest(\n 'POST',\n getUniqueURL(getSendURL(this.location, this.session))\n ).start(payload);\n return true;\n } catch (e) {\n return false;\n }\n } else {\n return false;\n }\n }\n\n /** For internal use only */\n reconnect() {\n this.closeStream();\n this.openStream();\n }\n\n /** For internal use only */\n onClose(code, reason, wasClean) {\n this.closeStream();\n this.readyState = State.CLOSED;\n if (this.onclose) {\n this.onclose({\n code: code,\n reason: reason,\n wasClean: wasClean\n });\n }\n }\n\n private onChunk(chunk) {\n if (chunk.status !== 200) {\n return;\n }\n if (this.readyState === State.OPEN) {\n this.onActivity();\n }\n\n var payload;\n var type = chunk.data.slice(0, 1);\n switch (type) {\n case 'o':\n payload = JSON.parse(chunk.data.slice(1) || '{}');\n this.onOpen(payload);\n break;\n case 'a':\n payload = JSON.parse(chunk.data.slice(1) || '[]');\n for (var i = 0; i < payload.length; i++) {\n this.onEvent(payload[i]);\n }\n break;\n case 'm':\n payload = JSON.parse(chunk.data.slice(1) || 'null');\n this.onEvent(payload);\n break;\n case 'h':\n this.hooks.onHeartbeat(this);\n break;\n case 'c':\n payload = JSON.parse(chunk.data.slice(1) || '[]');\n this.onClose(payload[0], payload[1], true);\n break;\n }\n }\n\n private onOpen(options) {\n if (this.readyState === State.CONNECTING) {\n if (options && options.hostname) {\n this.location.base = replaceHost(this.location.base, options.hostname);\n }\n this.readyState = State.OPEN;\n\n if (this.onopen) {\n this.onopen();\n }\n } else {\n this.onClose(1006, 'Server lost session', true);\n }\n }\n\n private onEvent(event) {\n if (this.readyState === State.OPEN && this.onmessage) {\n this.onmessage({ data: event });\n }\n }\n\n private onActivity() {\n if (this.onactivity) {\n this.onactivity();\n }\n }\n\n private onError(error) {\n if (this.onerror) {\n this.onerror(error);\n }\n }\n\n private openStream() {\n this.stream = Runtime.createSocketRequest(\n 'POST',\n getUniqueURL(this.hooks.getReceiveURL(this.location, this.session))\n );\n\n this.stream.bind('chunk', chunk => {\n this.onChunk(chunk);\n });\n this.stream.bind('finished', status => {\n this.hooks.onFinished(this, status);\n });\n this.stream.bind('buffer_too_long', () => {\n this.reconnect();\n });\n\n try {\n this.stream.start();\n } catch (error) {\n Util.defer(() => {\n this.onError(error);\n this.onClose(1006, 'Could not start streaming', false);\n });\n }\n }\n\n private closeStream() {\n if (this.stream) {\n this.stream.unbind_all();\n this.stream.close();\n this.stream = null;\n }\n }\n}\n\nfunction getLocation(url): URLLocation {\n var parts = /([^\\?]*)\\/*(\\??.*)/.exec(url);\n return {\n base: parts[1],\n queryString: parts[2]\n };\n}\n\nfunction getSendURL(url: URLLocation, session: string): string {\n return url.base + '/' + session + '/xhr_send';\n}\n\nfunction getUniqueURL(url: string): string {\n var separator = url.indexOf('?') === -1 ? '?' : '&';\n return url + separator + 't=' + +new Date() + '&n=' + autoIncrement++;\n}\n\nfunction replaceHost(url: string, hostname: string): string {\n var urlParts = /(https?:\\/\\/)([^\\/:]+)((\\/|:)?.*)/.exec(url);\n return urlParts[1] + hostname + urlParts[3];\n}\n\nfunction randomNumber(max: number): number {\n return Runtime.randomInt(max);\n}\n\nfunction randomString(length: number): string {\n var result = [];\n\n for (var i = 0; i < length; i++) {\n result.push(randomNumber(32).toString(32));\n }\n\n return result.join('');\n}\n\nexport default HTTPSocket;\n","import SocketHooks from './socket_hooks';\nimport HTTPSocket from './http_socket';\n\nvar hooks: SocketHooks = {\n getReceiveURL: function(url, session) {\n return url.base + '/' + session + '/xhr_streaming' + url.queryString;\n },\n onHeartbeat: function(socket) {\n socket.sendRaw('[]');\n },\n sendHeartbeat: function(socket) {\n socket.sendRaw('[]');\n },\n onFinished: function(socket, status) {\n socket.onClose(1006, 'Connection interrupted (' + status + ')', false);\n }\n};\n\nexport default hooks;\n","import SocketHooks from './socket_hooks';\nimport URLLocation from './url_location';\nimport HTTPSocket from './http_socket';\n\nvar hooks: SocketHooks = {\n getReceiveURL: function(url: URLLocation, session: string): string {\n return url.base + '/' + session + '/xhr' + url.queryString;\n },\n onHeartbeat: function() {\n // next HTTP request will reset server's activity timer\n },\n sendHeartbeat: function(socket) {\n socket.sendRaw('[]');\n },\n onFinished: function(socket, status) {\n if (status === 200) {\n socket.reconnect();\n } else {\n socket.onClose(1006, 'Connection interrupted (' + status + ')', false);\n }\n }\n};\n\nexport default hooks;\n","import HTTPRequest from 'core/http/http_request';\nimport RequestHooks from 'core/http/request_hooks';\nimport Ajax from 'core/http/ajax';\nimport Runtime from 'runtime';\n\nvar hooks: RequestHooks = {\n getRequest: function(socket: HTTPRequest): Ajax {\n var Constructor = Runtime.getXHRAPI();\n var xhr = new Constructor();\n xhr.onreadystatechange = xhr.onprogress = function() {\n switch (xhr.readyState) {\n case 3:\n if (xhr.responseText && xhr.responseText.length > 0) {\n socket.onChunk(xhr.status, xhr.responseText);\n }\n break;\n case 4:\n // this happens only on errors, never after calling close\n if (xhr.responseText && xhr.responseText.length > 0) {\n socket.onChunk(xhr.status, xhr.responseText);\n }\n socket.emit('finished', xhr.status);\n socket.close();\n break;\n }\n };\n return xhr;\n },\n abortRequest: function(xhr: Ajax) {\n xhr.onreadystatechange = null;\n xhr.abort();\n }\n};\n\nexport default hooks;\n","import HTTPRequest from 'core/http/http_request';\nimport HTTPSocket from 'core/http/http_socket';\nimport SocketHooks from 'core/http/socket_hooks';\nimport RequestHooks from 'core/http/request_hooks';\nimport streamingHooks from 'core/http/http_streaming_socket';\nimport pollingHooks from 'core/http/http_polling_socket';\nimport xhrHooks from './http_xhr_request';\nimport HTTPFactory from 'core/http/http_factory';\n\nvar HTTP: HTTPFactory = {\n createStreamingSocket(url: string): HTTPSocket {\n return this.createSocket(streamingHooks, url);\n },\n\n createPollingSocket(url: string): HTTPSocket {\n return this.createSocket(pollingHooks, url);\n },\n\n createSocket(hooks: SocketHooks, url: string): HTTPSocket {\n return new HTTPSocket(hooks, url);\n },\n\n createXHR(method: string, url: string): HTTPRequest {\n return this.createRequest(xhrHooks, method, url);\n },\n\n createRequest(hooks: RequestHooks, method: string, url: string): HTTPRequest {\n return new HTTPRequest(hooks, method, url);\n }\n};\n\nexport default HTTP;\n","import xdrHooks from './http_xdomain_request';\nimport HTTP from 'isomorphic/http/http';\n\nHTTP.createXDR = function(method, url) {\n return this.createRequest(xdrHooks, method, url);\n};\n\nexport default HTTP;\n","import Browser from './browser';\nimport { Dependencies, DependenciesReceivers } from './dom/dependencies';\nimport { AuthTransport, AuthTransports } from 'core/auth/auth_transports';\nimport xhrAuth from 'isomorphic/auth/xhr_auth';\nimport jsonpAuth from './auth/jsonp_auth';\nimport TimelineTransport from 'core/timeline/timeline_transport';\nimport TimelineSender from 'core/timeline/timeline_sender';\nimport ScriptRequest from './dom/script_request';\nimport JSONPRequest from './dom/jsonp_request';\nimport * as Collections from 'core/utils/collections';\nimport { ScriptReceivers } from './dom/script_receiver_factory';\nimport jsonpTimeline from './timeline/jsonp_timeline';\nimport Transports from './transports/transports';\nimport Ajax from 'core/http/ajax';\nimport { Network } from './net_info';\nimport getDefaultStrategy from './default_strategy';\nimport transportConnectionInitializer from './transports/transport_connection_initializer';\nimport HTTPFactory from './http/http';\nimport HTTPRequest from 'core/http/http_request';\n\nvar Runtime: Browser = {\n // for jsonp auth\n nextAuthCallbackID: 1,\n auth_callbacks: {},\n ScriptReceivers,\n DependenciesReceivers,\n getDefaultStrategy,\n Transports,\n transportConnectionInitializer,\n HTTPFactory,\n\n TimelineTransport: jsonpTimeline,\n\n getXHRAPI() {\n return window.XMLHttpRequest;\n },\n\n getWebSocketAPI() {\n return window.WebSocket || window.MozWebSocket;\n },\n\n setup(PusherClass): void {\n (window).Pusher = PusherClass; // JSONp requires Pusher to be in the global scope.\n var initializeOnDocumentBody = () => {\n this.onDocumentBody(PusherClass.ready);\n };\n if (!(window).JSON) {\n Dependencies.load('json2', {}, initializeOnDocumentBody);\n } else {\n initializeOnDocumentBody();\n }\n },\n\n getDocument(): Document {\n return document;\n },\n\n getProtocol(): string {\n return this.getDocument().location.protocol;\n },\n\n getAuthorizers(): AuthTransports {\n return { ajax: xhrAuth, jsonp: jsonpAuth };\n },\n\n onDocumentBody(callback: Function) {\n if (document.body) {\n callback();\n } else {\n setTimeout(() => {\n this.onDocumentBody(callback);\n }, 0);\n }\n },\n\n createJSONPRequest(url: string, data: any): JSONPRequest {\n return new JSONPRequest(url, data);\n },\n\n createScriptRequest(src: string): ScriptRequest {\n return new ScriptRequest(src);\n },\n\n getLocalStorage() {\n try {\n return window.localStorage;\n } catch (e) {\n return undefined;\n }\n },\n\n createXHR(): Ajax {\n if (this.getXHRAPI()) {\n return this.createXMLHttpRequest();\n } else {\n return this.createMicrosoftXHR();\n }\n },\n\n createXMLHttpRequest(): Ajax {\n var Constructor = this.getXHRAPI();\n return new Constructor();\n },\n\n createMicrosoftXHR(): Ajax {\n return new ActiveXObject('Microsoft.XMLHTTP');\n },\n\n getNetwork() {\n return Network;\n },\n\n createWebSocket(url: string): any {\n var Constructor = this.getWebSocketAPI();\n return new Constructor(url);\n },\n\n createSocketRequest(method: string, url: string): HTTPRequest {\n if (this.isXHRSupported()) {\n return this.HTTPFactory.createXHR(method, url);\n } else if (this.isXDRSupported(url.indexOf('https:') === 0)) {\n return this.HTTPFactory.createXDR(method, url);\n } else {\n throw 'Cross-origin HTTP requests are not supported';\n }\n },\n\n isXHRSupported(): boolean {\n var Constructor = this.getXHRAPI();\n return (\n Boolean(Constructor) && new Constructor().withCredentials !== undefined\n );\n },\n\n isXDRSupported(useTLS?: boolean): boolean {\n var protocol = useTLS ? 'https:' : 'http:';\n var documentProtocol = this.getProtocol();\n return (\n Boolean(window['XDomainRequest']) && documentProtocol === protocol\n );\n },\n\n addUnloadListener(listener: any) {\n if (window.addEventListener !== undefined) {\n window.addEventListener('unload', listener, false);\n } else if (window.attachEvent !== undefined) {\n window.attachEvent('onunload', listener);\n }\n },\n\n removeUnloadListener(listener: any) {\n if (window.addEventListener !== undefined) {\n window.removeEventListener('unload', listener, false);\n } else if (window.detachEvent !== undefined) {\n window.detachEvent('onunload', listener);\n }\n },\n\n randomInt(max: number): number {\n /**\n * Return values in the range of [0, 1[\n */\n const random = function() {\n const crypto = window.crypto || window['msCrypto'];\n const random = crypto.getRandomValues(new Uint32Array(1))[0];\n\n return random / 2 ** 32;\n };\n\n return Math.floor(random() * max);\n }\n};\n\nexport default Runtime;\n","enum TimelineLevel {\n ERROR = 3,\n INFO = 6,\n DEBUG = 7\n}\n\nexport default TimelineLevel;\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport { default as Level } from './level';\n\nexport interface TimelineOptions {\n level?: Level;\n limit?: number;\n version?: string;\n cluster?: string;\n features?: string[];\n params?: any;\n}\n\nexport default class Timeline {\n key: string;\n session: number;\n events: any[];\n options: TimelineOptions;\n sent: number;\n uniqueID: number;\n\n constructor(key: string, session: number, options: TimelineOptions) {\n this.key = key;\n this.session = session;\n this.events = [];\n this.options = options || {};\n this.sent = 0;\n this.uniqueID = 0;\n }\n\n log(level, event) {\n if (level <= this.options.level) {\n this.events.push(\n Collections.extend({}, event, { timestamp: Util.now() })\n );\n if (this.options.limit && this.events.length > this.options.limit) {\n this.events.shift();\n }\n }\n }\n\n error(event) {\n this.log(Level.ERROR, event);\n }\n\n info(event) {\n this.log(Level.INFO, event);\n }\n\n debug(event) {\n this.log(Level.DEBUG, event);\n }\n\n isEmpty() {\n return this.events.length === 0;\n }\n\n send(sendfn, callback) {\n var data = Collections.extend(\n {\n session: this.session,\n bundle: this.sent + 1,\n key: this.key,\n lib: 'js',\n version: this.options.version,\n cluster: this.options.cluster,\n features: this.options.features,\n timeline: this.events\n },\n this.options.params\n );\n\n this.events = [];\n sendfn(data, (error, result) => {\n if (!error) {\n this.sent++;\n }\n if (callback) {\n callback(error, result);\n }\n });\n\n return true;\n }\n\n generateUniqueID(): number {\n this.uniqueID++;\n return this.uniqueID;\n }\n}\n","import Factory from '../utils/factory';\nimport Util from '../util';\nimport * as Errors from '../errors';\nimport * as Collections from '../utils/collections';\nimport Strategy from './strategy';\nimport Transport from '../transports/transport';\nimport StrategyOptions from './strategy_options';\nimport Handshake from '../connection/handshake';\n\n/** Provides a strategy interface for transports.\n *\n * @param {String} name\n * @param {Number} priority\n * @param {Class} transport\n * @param {Object} options\n */\nexport default class TransportStrategy implements Strategy {\n name: string;\n priority: number;\n transport: Transport;\n options: StrategyOptions;\n\n constructor(\n name: string,\n priority: number,\n transport: Transport,\n options: StrategyOptions\n ) {\n this.name = name;\n this.priority = priority;\n this.transport = transport;\n this.options = options || {};\n }\n\n /** Returns whether the transport is supported in the browser.\n *\n * @returns {Boolean}\n */\n isSupported(): boolean {\n return this.transport.isSupported({\n useTLS: this.options.useTLS\n });\n }\n\n /** Launches a connection attempt and returns a strategy runner.\n *\n * @param {Function} callback\n * @return {Object} strategy runner\n */\n connect(minPriority: number, callback: Function) {\n if (!this.isSupported()) {\n return failAttempt(new Errors.UnsupportedStrategy(), callback);\n } else if (this.priority < minPriority) {\n return failAttempt(new Errors.TransportPriorityTooLow(), callback);\n }\n\n var connected = false;\n var transport = this.transport.createConnection(\n this.name,\n this.priority,\n this.options.key,\n this.options\n );\n var handshake = null;\n\n var onInitialized = function() {\n transport.unbind('initialized', onInitialized);\n transport.connect();\n };\n var onOpen = function() {\n handshake = Factory.createHandshake(transport, function(result) {\n connected = true;\n unbindListeners();\n callback(null, result);\n });\n };\n var onError = function(error) {\n unbindListeners();\n callback(error);\n };\n var onClosed = function() {\n unbindListeners();\n var serializedTransport;\n\n // The reason for this try/catch block is that on React Native\n // the WebSocket object is circular. Therefore transport.socket will\n // throw errors upon stringification. Collections.safeJSONStringify\n // discards circular references when serializing.\n serializedTransport = Collections.safeJSONStringify(transport);\n callback(new Errors.TransportClosed(serializedTransport));\n };\n\n var unbindListeners = function() {\n transport.unbind('initialized', onInitialized);\n transport.unbind('open', onOpen);\n transport.unbind('error', onError);\n transport.unbind('closed', onClosed);\n };\n\n transport.bind('initialized', onInitialized);\n transport.bind('open', onOpen);\n transport.bind('error', onError);\n transport.bind('closed', onClosed);\n\n // connect will be called automatically after initialization\n transport.initialize();\n\n return {\n abort: () => {\n if (connected) {\n return;\n }\n unbindListeners();\n if (handshake) {\n handshake.close();\n } else {\n transport.close();\n }\n },\n forceMinPriority: p => {\n if (connected) {\n return;\n }\n if (this.priority < p) {\n if (handshake) {\n handshake.close();\n } else {\n transport.close();\n }\n }\n }\n };\n }\n}\n\nfunction failAttempt(error: Error, callback: Function) {\n Util.defer(function() {\n callback(error);\n });\n return {\n abort: function() {},\n forceMinPriority: function() {}\n };\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport TransportManager from '../transports/transport_manager';\nimport * as Errors from '../errors';\nimport Strategy from './strategy';\nimport TransportStrategy from './transport_strategy';\nimport StrategyOptions from '../strategies/strategy_options';\nimport { Config } from '../config';\nimport Runtime from 'runtime';\n\nconst { Transports } = Runtime;\n\nexport var defineTransport = function(\n config: Config,\n name: string,\n type: string,\n priority: number,\n options: StrategyOptions,\n manager?: TransportManager\n): Strategy {\n var transportClass = Transports[type];\n if (!transportClass) {\n throw new Errors.UnsupportedTransport(type);\n }\n\n var enabled =\n (!config.enabledTransports ||\n Collections.arrayIndexOf(config.enabledTransports, name) !== -1) &&\n (!config.disabledTransports ||\n Collections.arrayIndexOf(config.disabledTransports, name) === -1);\n\n var transport;\n if (enabled) {\n options = Object.assign(\n { ignoreNullOrigin: config.ignoreNullOrigin },\n options\n );\n\n transport = new TransportStrategy(\n name,\n priority,\n manager ? manager.getAssistant(transportClass) : transportClass,\n options\n );\n } else {\n transport = UnsupportedStrategy;\n }\n\n return transport;\n};\n\nvar UnsupportedStrategy: Strategy = {\n isSupported: function() {\n return false;\n },\n connect: function(_, callback) {\n var deferred = Util.defer(function() {\n callback(new Errors.UnsupportedStrategy());\n });\n return {\n abort: function() {\n deferred.ensureAborted();\n },\n forceMinPriority: function() {}\n };\n }\n};\n","import ConnectionManager from './connection/connection_manager';\nimport {\n ChannelAuthorizationOptions,\n UserAuthenticationOptions\n} from './auth/options';\nimport {\n ChannelAuthorizerGenerator,\n DeprecatedAuthOptions\n} from './auth/deprecated_channel_authorizer';\nimport { AuthTransport, Transport } from './config';\nimport * as nacl from 'tweetnacl';\nimport Logger from './logger';\n\nexport interface Options {\n activityTimeout?: number;\n\n auth?: DeprecatedAuthOptions; // DEPRECATED use channelAuthorization instead\n authEndpoint?: string; // DEPRECATED use channelAuthorization instead\n authTransport?: AuthTransport; // DEPRECATED use channelAuthorization instead\n authorizer?: ChannelAuthorizerGenerator; // DEPRECATED use channelAuthorization instead\n\n channelAuthorization?: ChannelAuthorizationOptions;\n userAuthentication?: UserAuthenticationOptions;\n\n cluster: string;\n enableStats?: boolean;\n disableStats?: boolean;\n disabledTransports?: Transport[];\n enabledTransports?: Transport[];\n forceTLS?: boolean;\n httpHost?: string;\n httpPath?: string;\n httpPort?: number;\n httpsPort?: number;\n ignoreNullOrigin?: boolean;\n nacl?: nacl;\n pongTimeout?: number;\n statsHost?: string;\n timelineParams?: any;\n unavailableTimeout?: number;\n wsHost?: string;\n wsPath?: string;\n wsPort?: number;\n wssPort?: number;\n}\n\nexport interface ClusterOptions {\n appKey: string;\n cluster: string;\n}\n\nexport function validateOptions(options) {\n if (options == null) {\n throw 'You must pass an options object';\n }\n if (options.cluster == null) {\n throw 'Options object must provide a cluster';\n }\n if ('disableStats' in options) {\n Logger.warn(\n 'The disableStats option is deprecated in favor of enableStats'\n );\n }\n}\n","import {\n UserAuthenticationCallback,\n InternalAuthOptions,\n UserAuthenticationHandler,\n UserAuthenticationRequestParams,\n AuthRequestType\n} from './options';\n\nimport Runtime from 'runtime';\n\nconst composeChannelQuery = (\n params: UserAuthenticationRequestParams,\n authOptions: InternalAuthOptions\n) => {\n var query = 'socket_id=' + encodeURIComponent(params.socketId);\n\n for (var key in authOptions.params) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(authOptions.params[key]);\n }\n\n if (authOptions.paramsProvider != null) {\n let dynamicParams = authOptions.paramsProvider();\n for (var key in dynamicParams) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(dynamicParams[key]);\n }\n }\n\n return query;\n};\n\nconst UserAuthenticator = (\n authOptions: InternalAuthOptions\n): UserAuthenticationHandler => {\n if (typeof Runtime.getAuthorizers()[authOptions.transport] === 'undefined') {\n throw `'${authOptions.transport}' is not a recognized auth transport`;\n }\n\n return (\n params: UserAuthenticationRequestParams,\n callback: UserAuthenticationCallback\n ) => {\n const query = composeChannelQuery(params, authOptions);\n\n Runtime.getAuthorizers()[authOptions.transport](\n Runtime,\n query,\n authOptions,\n AuthRequestType.UserAuthentication,\n callback\n );\n };\n};\n\nexport default UserAuthenticator;\n","import {\n AuthRequestType,\n InternalAuthOptions,\n ChannelAuthorizationHandler,\n ChannelAuthorizationRequestParams,\n ChannelAuthorizationCallback\n} from './options';\n\nimport Runtime from 'runtime';\n\nconst composeChannelQuery = (\n params: ChannelAuthorizationRequestParams,\n authOptions: InternalAuthOptions\n) => {\n var query = 'socket_id=' + encodeURIComponent(params.socketId);\n\n query += '&channel_name=' + encodeURIComponent(params.channelName);\n\n for (var key in authOptions.params) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(authOptions.params[key]);\n }\n\n if (authOptions.paramsProvider != null) {\n let dynamicParams = authOptions.paramsProvider();\n for (var key in dynamicParams) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(dynamicParams[key]);\n }\n }\n\n return query;\n};\n\nconst ChannelAuthorizer = (\n authOptions: InternalAuthOptions\n): ChannelAuthorizationHandler => {\n if (typeof Runtime.getAuthorizers()[authOptions.transport] === 'undefined') {\n throw `'${authOptions.transport}' is not a recognized auth transport`;\n }\n\n return (\n params: ChannelAuthorizationRequestParams,\n callback: ChannelAuthorizationCallback\n ) => {\n const query = composeChannelQuery(params, authOptions);\n\n Runtime.getAuthorizers()[authOptions.transport](\n Runtime,\n query,\n authOptions,\n AuthRequestType.ChannelAuthorization,\n callback\n );\n };\n};\n\nexport default ChannelAuthorizer;\n","import Channel from '../channels/channel';\nimport {\n ChannelAuthorizationCallback,\n ChannelAuthorizationHandler,\n ChannelAuthorizationRequestParams,\n InternalAuthOptions\n} from './options';\n\nexport interface DeprecatedChannelAuthorizer {\n authorize(socketId: string, callback: ChannelAuthorizationCallback): void;\n}\n\nexport interface ChannelAuthorizerGenerator {\n (\n channel: Channel,\n options: DeprecatedAuthorizerOptions\n ): DeprecatedChannelAuthorizer;\n}\n\nexport interface DeprecatedAuthOptions {\n params?: any;\n headers?: any;\n}\n\nexport interface DeprecatedAuthorizerOptions {\n authTransport: 'ajax' | 'jsonp';\n authEndpoint: string;\n auth?: DeprecatedAuthOptions;\n}\n\nexport const ChannelAuthorizerProxy = (\n pusher,\n authOptions: InternalAuthOptions,\n channelAuthorizerGenerator: ChannelAuthorizerGenerator\n): ChannelAuthorizationHandler => {\n const deprecatedAuthorizerOptions: DeprecatedAuthorizerOptions = {\n authTransport: authOptions.transport,\n authEndpoint: authOptions.endpoint,\n auth: {\n params: authOptions.params,\n headers: authOptions.headers\n }\n };\n return (\n params: ChannelAuthorizationRequestParams,\n callback: ChannelAuthorizationCallback\n ) => {\n const channel = pusher.channel(params.channelName);\n // This line creates a new channel authorizer every time.\n // In the past, this was only done once per channel and reused.\n // We can do that again if we want to keep this behavior intact.\n const channelAuthorizer: DeprecatedChannelAuthorizer = channelAuthorizerGenerator(\n channel,\n deprecatedAuthorizerOptions\n );\n channelAuthorizer.authorize(params.socketId, callback);\n };\n};\n","import { Options } from './options';\nimport Defaults from './defaults';\nimport {\n ChannelAuthorizationHandler,\n UserAuthenticationHandler,\n ChannelAuthorizationOptions\n} from './auth/options';\nimport UserAuthenticator from './auth/user_authenticator';\nimport ChannelAuthorizer from './auth/channel_authorizer';\nimport { ChannelAuthorizerProxy } from './auth/deprecated_channel_authorizer';\nimport Runtime from 'runtime';\nimport * as nacl from 'tweetnacl';\n\nexport type AuthTransport = 'ajax' | 'jsonp';\nexport type Transport =\n | 'ws'\n | 'wss'\n | 'xhr_streaming'\n | 'xhr_polling'\n | 'sockjs';\n\nexport interface Config {\n // these are all 'required' config parameters, it's not necessary for the user\n // to set them, but they have configured defaults.\n activityTimeout: number;\n enableStats: boolean;\n httpHost: string;\n httpPath: string;\n httpPort: number;\n httpsPort: number;\n pongTimeout: number;\n statsHost: string;\n unavailableTimeout: number;\n useTLS: boolean;\n wsHost: string;\n wsPath: string;\n wsPort: number;\n wssPort: number;\n userAuthenticator: UserAuthenticationHandler;\n channelAuthorizer: ChannelAuthorizationHandler;\n\n // these are all optional parameters or overrrides. The customer can set these\n // but it's not strictly necessary\n forceTLS?: boolean;\n cluster?: string;\n disabledTransports?: Transport[];\n enabledTransports?: Transport[];\n ignoreNullOrigin?: boolean;\n nacl?: nacl;\n timelineParams?: any;\n}\n\n// getConfig mainly sets the defaults for the options that are not provided\nexport function getConfig(opts: Options, pusher): Config {\n let config: Config = {\n activityTimeout: opts.activityTimeout || Defaults.activityTimeout,\n cluster: opts.cluster,\n httpPath: opts.httpPath || Defaults.httpPath,\n httpPort: opts.httpPort || Defaults.httpPort,\n httpsPort: opts.httpsPort || Defaults.httpsPort,\n pongTimeout: opts.pongTimeout || Defaults.pongTimeout,\n statsHost: opts.statsHost || Defaults.stats_host,\n unavailableTimeout: opts.unavailableTimeout || Defaults.unavailableTimeout,\n wsPath: opts.wsPath || Defaults.wsPath,\n wsPort: opts.wsPort || Defaults.wsPort,\n wssPort: opts.wssPort || Defaults.wssPort,\n\n enableStats: getEnableStatsConfig(opts),\n httpHost: getHttpHost(opts),\n useTLS: shouldUseTLS(opts),\n wsHost: getWebsocketHost(opts),\n\n userAuthenticator: buildUserAuthenticator(opts),\n channelAuthorizer: buildChannelAuthorizer(opts, pusher)\n };\n\n if ('disabledTransports' in opts)\n config.disabledTransports = opts.disabledTransports;\n if ('enabledTransports' in opts)\n config.enabledTransports = opts.enabledTransports;\n if ('ignoreNullOrigin' in opts)\n config.ignoreNullOrigin = opts.ignoreNullOrigin;\n if ('timelineParams' in opts) config.timelineParams = opts.timelineParams;\n if ('nacl' in opts) {\n config.nacl = opts.nacl;\n }\n\n return config;\n}\n\nfunction getHttpHost(opts: Options): string {\n if (opts.httpHost) {\n return opts.httpHost;\n }\n if (opts.cluster) {\n return `sockjs-${opts.cluster}.pusher.com`;\n }\n return Defaults.httpHost;\n}\n\nfunction getWebsocketHost(opts: Options): string {\n if (opts.wsHost) {\n return opts.wsHost;\n }\n return getWebsocketHostFromCluster(opts.cluster);\n}\n\nfunction getWebsocketHostFromCluster(cluster: string): string {\n return `ws-${cluster}.pusher.com`;\n}\n\nfunction shouldUseTLS(opts: Options): boolean {\n if (Runtime.getProtocol() === 'https:') {\n return true;\n } else if (opts.forceTLS === false) {\n return false;\n }\n return true;\n}\n\n// if enableStats is set take the value\n// if disableStats is set take the inverse\n// otherwise default to false\nfunction getEnableStatsConfig(opts: Options): boolean {\n if ('enableStats' in opts) {\n return opts.enableStats;\n }\n if ('disableStats' in opts) {\n return !opts.disableStats;\n }\n return false;\n}\n\nfunction buildUserAuthenticator(opts: Options): UserAuthenticationHandler {\n const userAuthentication = {\n ...Defaults.userAuthentication,\n ...opts.userAuthentication\n };\n if (\n 'customHandler' in userAuthentication &&\n userAuthentication['customHandler'] != null\n ) {\n return userAuthentication['customHandler'];\n }\n\n return UserAuthenticator(userAuthentication);\n}\n\nfunction buildChannelAuth(opts: Options, pusher): ChannelAuthorizationOptions {\n let channelAuthorization: ChannelAuthorizationOptions;\n if ('channelAuthorization' in opts) {\n channelAuthorization = {\n ...Defaults.channelAuthorization,\n ...opts.channelAuthorization\n };\n } else {\n channelAuthorization = {\n transport: opts.authTransport || Defaults.authTransport,\n endpoint: opts.authEndpoint || Defaults.authEndpoint\n };\n if ('auth' in opts) {\n if ('params' in opts.auth) channelAuthorization.params = opts.auth.params;\n if ('headers' in opts.auth)\n channelAuthorization.headers = opts.auth.headers;\n }\n if ('authorizer' in opts)\n channelAuthorization.customHandler = ChannelAuthorizerProxy(\n pusher,\n channelAuthorization,\n opts.authorizer\n );\n }\n return channelAuthorization;\n}\n\nfunction buildChannelAuthorizer(\n opts: Options,\n pusher\n): ChannelAuthorizationHandler {\n const channelAuthorization = buildChannelAuth(opts, pusher);\n if (\n 'customHandler' in channelAuthorization &&\n channelAuthorization['customHandler'] != null\n ) {\n return channelAuthorization['customHandler'];\n }\n\n return ChannelAuthorizer(channelAuthorization);\n}\n","import Logger from './logger';\nimport Pusher from './pusher';\nimport EventsDispatcher from './events/dispatcher';\n\nexport default class WatchlistFacade extends EventsDispatcher {\n private pusher: Pusher;\n\n public constructor(pusher: Pusher) {\n super(function(eventName, data) {\n Logger.debug(`No callbacks on watchlist events for ${eventName}`);\n });\n\n this.pusher = pusher;\n this.bindWatchlistInternalEvent();\n }\n\n handleEvent(pusherEvent) {\n pusherEvent.data.events.forEach(watchlistEvent => {\n this.emit(watchlistEvent.name, watchlistEvent);\n });\n }\n\n private bindWatchlistInternalEvent() {\n this.pusher.connection.bind('message', pusherEvent => {\n var eventName = pusherEvent.event;\n if (eventName === 'pusher_internal:watchlist_events') {\n this.handleEvent(pusherEvent);\n }\n });\n }\n}\n","function flatPromise() {\n let resolve, reject;\n const promise = new Promise((res, rej) => {\n resolve = res;\n reject = rej;\n });\n return { promise, resolve, reject };\n}\n\nexport default flatPromise;\n","import Pusher from './pusher';\nimport Logger from './logger';\nimport {\n UserAuthenticationData,\n UserAuthenticationCallback\n} from './auth/options';\nimport Channel from './channels/channel';\nimport WatchlistFacade from './watchlist';\nimport EventsDispatcher from './events/dispatcher';\nimport flatPromise from './utils/flat_promise';\n\nexport default class UserFacade extends EventsDispatcher {\n pusher: Pusher;\n signin_requested: boolean = false;\n user_data: any = null;\n serverToUserChannel: Channel = null;\n signinDonePromise: Promise = null;\n watchlist: WatchlistFacade;\n private _signinDoneResolve: Function = null;\n\n public constructor(pusher: Pusher) {\n super(function(eventName, data) {\n Logger.debug('No callbacks on user for ' + eventName);\n });\n this.pusher = pusher;\n this.pusher.connection.bind('state_change', ({ previous, current }) => {\n if (previous !== 'connected' && current === 'connected') {\n this._signin();\n }\n if (previous === 'connected' && current !== 'connected') {\n this._cleanup();\n this._newSigninPromiseIfNeeded();\n }\n });\n\n this.watchlist = new WatchlistFacade(pusher);\n\n this.pusher.connection.bind('message', event => {\n var eventName = event.event;\n if (eventName === 'pusher:signin_success') {\n this._onSigninSuccess(event.data);\n }\n if (\n this.serverToUserChannel &&\n this.serverToUserChannel.name === event.channel\n ) {\n this.serverToUserChannel.handleEvent(event);\n }\n });\n }\n\n public signin() {\n if (this.signin_requested) {\n return;\n }\n\n this.signin_requested = true;\n this._signin();\n }\n\n private _signin() {\n if (!this.signin_requested) {\n return;\n }\n\n this._newSigninPromiseIfNeeded();\n\n if (this.pusher.connection.state !== 'connected') {\n // Signin will be attempted when the connection is connected\n return;\n }\n\n this.pusher.config.userAuthenticator(\n {\n socketId: this.pusher.connection.socket_id\n },\n this._onAuthorize\n );\n }\n\n private _onAuthorize: UserAuthenticationCallback = (\n err,\n authData: UserAuthenticationData\n ) => {\n if (err) {\n Logger.warn(`Error during signin: ${err}`);\n this._cleanup();\n return;\n }\n\n this.pusher.send_event('pusher:signin', {\n auth: authData.auth,\n user_data: authData.user_data\n });\n\n // Later when we get pusher:singin_success event, the user will be marked as signed in\n };\n\n private _onSigninSuccess(data: any) {\n try {\n this.user_data = JSON.parse(data.user_data);\n } catch (e) {\n Logger.error(`Failed parsing user data after signin: ${data.user_data}`);\n this._cleanup();\n return;\n }\n\n if (typeof this.user_data.id !== 'string' || this.user_data.id === '') {\n Logger.error(\n `user_data doesn't contain an id. user_data: ${this.user_data}`\n );\n this._cleanup();\n return;\n }\n\n // Signin succeeded\n this._signinDoneResolve();\n this._subscribeChannels();\n }\n\n private _subscribeChannels() {\n const ensure_subscribed = channel => {\n if (channel.subscriptionPending && channel.subscriptionCancelled) {\n channel.reinstateSubscription();\n } else if (\n !channel.subscriptionPending &&\n this.pusher.connection.state === 'connected'\n ) {\n channel.subscribe();\n }\n };\n\n this.serverToUserChannel = new Channel(\n `#server-to-user-${this.user_data.id}`,\n this.pusher\n );\n this.serverToUserChannel.bind_global((eventName, data) => {\n if (\n eventName.indexOf('pusher_internal:') === 0 ||\n eventName.indexOf('pusher:') === 0\n ) {\n // ignore internal events\n return;\n }\n this.emit(eventName, data);\n });\n ensure_subscribed(this.serverToUserChannel);\n }\n\n private _cleanup() {\n this.user_data = null;\n if (this.serverToUserChannel) {\n this.serverToUserChannel.unbind_all();\n this.serverToUserChannel.disconnect();\n this.serverToUserChannel = null;\n }\n\n if (this.signin_requested) {\n // If signin is in progress and cleanup is called,\n // Mark the current signin process as done.\n this._signinDoneResolve();\n }\n }\n\n private _newSigninPromiseIfNeeded() {\n if (!this.signin_requested) {\n return;\n }\n\n // If there is a promise and it is not resolved, return without creating a new one.\n if (this.signinDonePromise && !(this.signinDonePromise as any).done) {\n return;\n }\n\n // This promise is never rejected.\n // It gets resolved when the signin process is done whether it failed or succeeded\n const { promise, resolve, reject: _ } = flatPromise();\n (promise as any).done = false;\n const setDone = () => {\n (promise as any).done = true;\n };\n promise.then(setDone).catch(setDone);\n this.signinDonePromise = promise;\n this._signinDoneResolve = resolve;\n }\n}\n","import AbstractRuntime from '../runtimes/interface';\nimport Runtime from 'runtime';\nimport * as Collections from './utils/collections';\nimport Channels from './channels/channels';\nimport Channel from './channels/channel';\nimport { default as EventsDispatcher } from './events/dispatcher';\nimport Timeline from './timeline/timeline';\nimport TimelineSender from './timeline/timeline_sender';\nimport TimelineLevel from './timeline/level';\nimport { defineTransport } from './strategies/strategy_builder';\nimport ConnectionManager from './connection/connection_manager';\nimport { PeriodicTimer } from './utils/timers';\nimport Defaults from './defaults';\nimport Logger from './logger';\nimport Factory from './utils/factory';\nimport { Options, ClusterOptions, validateOptions } from './options';\nimport { Config, getConfig } from './config';\nimport StrategyOptions from './strategies/strategy_options';\nimport UserFacade from './user';\n\nexport default class Pusher {\n /* STATIC PROPERTIES */\n static instances: Pusher[] = [];\n static isReady: boolean = false;\n static logToConsole: boolean = false;\n\n // for jsonp\n static Runtime: AbstractRuntime = Runtime;\n static ScriptReceivers: any = (Runtime).ScriptReceivers;\n static DependenciesReceivers: any = (Runtime).DependenciesReceivers;\n static auth_callbacks: any = (Runtime).auth_callbacks;\n\n static ready() {\n Pusher.isReady = true;\n for (var i = 0, l = Pusher.instances.length; i < l; i++) {\n Pusher.instances[i].connect();\n }\n }\n\n static log: (message: any) => void;\n\n private static getClientFeatures(): string[] {\n return Collections.keys(\n Collections.filterObject({ ws: Runtime.Transports.ws }, function(t) {\n return t.isSupported({});\n })\n );\n }\n\n /* INSTANCE PROPERTIES */\n key: string;\n options: Options;\n config: Config;\n channels: Channels;\n global_emitter: EventsDispatcher;\n sessionID: number;\n timeline: Timeline;\n timelineSender: TimelineSender;\n connection: ConnectionManager;\n timelineSenderTimer: PeriodicTimer;\n user: UserFacade;\n constructor(app_key: string, options: Options) {\n checkAppKey(app_key);\n validateOptions(options);\n this.key = app_key;\n this.config = getConfig(options, this);\n\n this.channels = Factory.createChannels();\n this.global_emitter = new EventsDispatcher();\n this.sessionID = Runtime.randomInt(1000000000);\n\n this.timeline = new Timeline(this.key, this.sessionID, {\n cluster: this.config.cluster,\n features: Pusher.getClientFeatures(),\n params: this.config.timelineParams || {},\n limit: 50,\n level: TimelineLevel.INFO,\n version: Defaults.VERSION\n });\n if (this.config.enableStats) {\n this.timelineSender = Factory.createTimelineSender(this.timeline, {\n host: this.config.statsHost,\n path: '/timeline/v2/' + Runtime.TimelineTransport.name\n });\n }\n\n var getStrategy = (options: StrategyOptions) => {\n return Runtime.getDefaultStrategy(this.config, options, defineTransport);\n };\n\n this.connection = Factory.createConnectionManager(this.key, {\n getStrategy: getStrategy,\n timeline: this.timeline,\n activityTimeout: this.config.activityTimeout,\n pongTimeout: this.config.pongTimeout,\n unavailableTimeout: this.config.unavailableTimeout,\n useTLS: Boolean(this.config.useTLS)\n });\n\n this.connection.bind('connected', () => {\n this.subscribeAll();\n if (this.timelineSender) {\n this.timelineSender.send(this.connection.isUsingTLS());\n }\n });\n\n this.connection.bind('message', event => {\n var eventName = event.event;\n var internal = eventName.indexOf('pusher_internal:') === 0;\n if (event.channel) {\n var channel = this.channel(event.channel);\n if (channel) {\n channel.handleEvent(event);\n }\n }\n // Emit globally [deprecated]\n if (!internal) {\n this.global_emitter.emit(event.event, event.data);\n }\n });\n this.connection.bind('connecting', () => {\n this.channels.disconnect();\n });\n this.connection.bind('disconnected', () => {\n this.channels.disconnect();\n });\n this.connection.bind('error', err => {\n Logger.warn(err);\n });\n\n Pusher.instances.push(this);\n this.timeline.info({ instances: Pusher.instances.length });\n\n this.user = new UserFacade(this);\n\n if (Pusher.isReady) {\n this.connect();\n }\n }\n\n /**\n * Allows you to switch Pusher cluster without\n * losing all the channels/subscription binding\n * as this is internally managed by the SDK.\n */\n switchCluster(options: ClusterOptions) {\n const { appKey, cluster } = options;\n this.key = appKey;\n this.options = { ...this.options, cluster };\n this.config = getConfig(this.options, this);\n this.connection.switchCluster(this.key);\n }\n\n channel(name: string): Channel {\n return this.channels.find(name);\n }\n\n allChannels(): Channel[] {\n return this.channels.all();\n }\n\n connect() {\n this.connection.connect();\n\n if (this.timelineSender) {\n if (!this.timelineSenderTimer) {\n var usingTLS = this.connection.isUsingTLS();\n var timelineSender = this.timelineSender;\n this.timelineSenderTimer = new PeriodicTimer(60000, function() {\n timelineSender.send(usingTLS);\n });\n }\n }\n }\n\n disconnect() {\n this.connection.disconnect();\n\n if (this.timelineSenderTimer) {\n this.timelineSenderTimer.ensureAborted();\n this.timelineSenderTimer = null;\n }\n }\n\n bind(event_name: string, callback: Function, context?: any): Pusher {\n this.global_emitter.bind(event_name, callback, context);\n return this;\n }\n\n unbind(event_name?: string, callback?: Function, context?: any): Pusher {\n this.global_emitter.unbind(event_name, callback, context);\n return this;\n }\n\n bind_global(callback: Function): Pusher {\n this.global_emitter.bind_global(callback);\n return this;\n }\n\n unbind_global(callback?: Function): Pusher {\n this.global_emitter.unbind_global(callback);\n return this;\n }\n\n unbind_all(callback?: Function): Pusher {\n this.global_emitter.unbind_all();\n return this;\n }\n\n subscribeAll() {\n var channelName;\n for (channelName in this.channels.channels) {\n if (this.channels.channels.hasOwnProperty(channelName)) {\n this.subscribe(channelName);\n }\n }\n }\n\n subscribe(channel_name: string) {\n var channel = this.channels.add(channel_name, this);\n if (channel.subscriptionPending && channel.subscriptionCancelled) {\n channel.reinstateSubscription();\n } else if (\n !channel.subscriptionPending &&\n this.connection.state === 'connected'\n ) {\n channel.subscribe();\n }\n return channel;\n }\n\n unsubscribe(channel_name: string) {\n var channel = this.channels.find(channel_name);\n if (channel && channel.subscriptionPending) {\n channel.cancelSubscription();\n } else {\n channel = this.channels.remove(channel_name);\n if (channel && channel.subscribed) {\n channel.unsubscribe();\n }\n }\n }\n\n send_event(event_name: string, data: any, channel?: string) {\n return this.connection.send_event(event_name, data, channel);\n }\n\n shouldUseTLS(): boolean {\n return this.config.useTLS;\n }\n\n signin() {\n this.user.signin();\n }\n}\n\nfunction checkAppKey(key) {\n if (key === null || key === undefined) {\n throw 'You must pass your app key when you instantiate Pusher.';\n }\n}\n\nRuntime.setup(Pusher);\n","import Pusher from './pusher';\nimport { Options, validateOptions } from './options';\nimport * as nacl from 'tweetnacl';\n\nexport default class PusherWithEncryption extends Pusher {\n constructor(app_key: string, options: Options) {\n Pusher.logToConsole = PusherWithEncryption.logToConsole;\n Pusher.log = PusherWithEncryption.log;\n\n validateOptions(options);\n options.nacl = nacl;\n super(app_key, options);\n }\n}\n"],"sourceRoot":""} \ No newline at end of file +{"version":3,"sources":["webpack://Pusher/webpack/universalModuleDefinition","webpack://Pusher/webpack/bootstrap","webpack://Pusher/./node_modules/@stablelib/base64/base64.ts","webpack://Pusher/./node_modules/@stablelib/utf8/utf8.ts","webpack://Pusher/./node_modules/tweetnacl/nacl-fast.js","webpack://Pusher/./src/core/pusher-with-encryption.js","webpack://Pusher/crypto (ignored)","webpack://Pusher/./src/runtimes/web/dom/script_receiver_factory.ts","webpack://Pusher/./src/core/defaults.ts","webpack://Pusher/./src/runtimes/web/dom/dependency_loader.ts","webpack://Pusher/./src/runtimes/web/dom/dependencies.ts","webpack://Pusher/./src/core/utils/url_store.ts","webpack://Pusher/./src/core/auth/options.ts","webpack://Pusher/./src/core/errors.ts","webpack://Pusher/./src/runtimes/isomorphic/auth/xhr_auth.ts","webpack://Pusher/./src/core/base64.ts","webpack://Pusher/./src/core/utils/timers/abstract_timer.ts","webpack://Pusher/./src/core/utils/timers/index.ts","webpack://Pusher/./src/core/util.ts","webpack://Pusher/./src/core/utils/collections.ts","webpack://Pusher/./src/core/logger.ts","webpack://Pusher/./src/runtimes/web/auth/jsonp_auth.ts","webpack://Pusher/./src/runtimes/web/dom/script_request.ts","webpack://Pusher/./src/runtimes/web/dom/jsonp_request.ts","webpack://Pusher/./src/runtimes/web/timeline/jsonp_timeline.ts","webpack://Pusher/./src/core/transports/url_schemes.ts","webpack://Pusher/./src/core/events/callback_registry.ts","webpack://Pusher/./src/core/events/dispatcher.ts","webpack://Pusher/./src/core/transports/transport_connection.ts","webpack://Pusher/./src/core/transports/transport.ts","webpack://Pusher/./src/runtimes/isomorphic/transports/transports.ts","webpack://Pusher/./src/runtimes/web/transports/transports.ts","webpack://Pusher/./src/runtimes/web/net_info.ts","webpack://Pusher/./src/core/transports/assistant_to_the_transport_manager.ts","webpack://Pusher/./src/core/connection/protocol/protocol.ts","webpack://Pusher/./src/core/connection/connection.ts","webpack://Pusher/./src/core/connection/handshake/index.ts","webpack://Pusher/./src/core/timeline/timeline_sender.ts","webpack://Pusher/./src/core/channels/channel.ts","webpack://Pusher/./src/core/channels/private_channel.ts","webpack://Pusher/./src/core/channels/members.ts","webpack://Pusher/./src/core/channels/presence_channel.ts","webpack://Pusher/./src/core/channels/encrypted_channel.ts","webpack://Pusher/./src/core/connection/connection_manager.ts","webpack://Pusher/./src/core/channels/channels.ts","webpack://Pusher/./src/core/utils/factory.ts","webpack://Pusher/./src/core/transports/transport_manager.ts","webpack://Pusher/./src/core/strategies/sequential_strategy.ts","webpack://Pusher/./src/core/strategies/best_connected_ever_strategy.ts","webpack://Pusher/./src/core/strategies/websocket_prioritized_cached_strategy.ts","webpack://Pusher/./src/core/strategies/delayed_strategy.ts","webpack://Pusher/./src/core/strategies/if_strategy.ts","webpack://Pusher/./src/core/strategies/first_connected_strategy.ts","webpack://Pusher/./src/runtimes/web/default_strategy.ts","webpack://Pusher/./src/runtimes/web/transports/transport_connection_initializer.ts","webpack://Pusher/./src/runtimes/web/http/http_xdomain_request.ts","webpack://Pusher/./src/core/http/http_request.ts","webpack://Pusher/./src/core/http/state.ts","webpack://Pusher/./src/core/http/http_socket.ts","webpack://Pusher/./src/core/http/http_streaming_socket.ts","webpack://Pusher/./src/core/http/http_polling_socket.ts","webpack://Pusher/./src/runtimes/isomorphic/http/http_xhr_request.ts","webpack://Pusher/./src/runtimes/isomorphic/http/http.ts","webpack://Pusher/./src/runtimes/web/http/http.ts","webpack://Pusher/./src/runtimes/web/runtime.ts","webpack://Pusher/./src/core/timeline/level.ts","webpack://Pusher/./src/core/timeline/timeline.ts","webpack://Pusher/./src/core/strategies/transport_strategy.ts","webpack://Pusher/./src/core/strategies/strategy_builder.ts","webpack://Pusher/./src/core/options.ts","webpack://Pusher/./src/core/auth/user_authenticator.ts","webpack://Pusher/./src/core/auth/channel_authorizer.ts","webpack://Pusher/./src/core/auth/deprecated_channel_authorizer.ts","webpack://Pusher/./src/core/config.ts","webpack://Pusher/./src/core/watchlist.ts","webpack://Pusher/./src/core/utils/flat_promise.ts","webpack://Pusher/./src/core/user.ts","webpack://Pusher/./src/core/pusher.ts","webpack://Pusher/./src/core/pusher-with-encryption.ts"],"names":[],"mappings":";;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AACD,O;QCVA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;;QAEA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;;;QAGA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;QACA,0CAA0C,gCAAgC;QAC1E;QACA;;QAEA;QACA;QACA;QACA,wDAAwD,kBAAkB;QAC1E;QACA,iDAAiD,cAAc;QAC/D;;QAEA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA,yCAAyC,iCAAiC;QAC1E,gHAAgH,mBAAmB,EAAE;QACrI;QACA;;QAEA;QACA;QACA;QACA,2BAA2B,0BAA0B,EAAE;QACvD,iCAAiC,eAAe;QAChD;QACA;QACA;;QAEA;QACA,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AEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,aAAa,QAAQ;AACrB,aAAa,OAAO;AACpB;AACA;AACA,eAAe,QAAQ;AACvB;AACA,eAAe,QAAQ;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB;AACA;AACA;;AAEA;AACA;AACA;AACA,aAAa,QAAQ;AACrB,aAAa,OAAO;AACpB;AACA;AACA,eAAe,QAAQ;AACvB;AACA,eAAe,QAAQ;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,iBAAiB,OAAO;AACxB;AACA;;AAEA;AACA;AACA;AACA;AACA,iBAAiB,OAAO;AACxB;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA,8CAA8C;AAC9C,8CAA8C;AAC9C,8CAA8C;AAC9C,8CAA8C;AAC9C,8CAA8C;AAC9C;AACA,8CAA8C;AAC9C,8CAA8C;AAC9C,8CAA8C;AAC9C;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,sDAAsD;AACtD,sDAAsD;AACtD,sDAAsD;AACtD,sDAAsD;AACtD,sDAAsD;AACtD;AACA,sDAAsD;AACtD,sDAAsD;AACtD,sDAAsD;AACtD;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA,qBAAqB;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA,qBAAqB;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA,qBAAqB;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA,qBAAqB;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA,qBAAqB;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA,qBAAqB;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA,qBAAqB;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA,qBAAqB;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA,qBAAqB;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA,qBAAqB;;AAErB;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA,UAAU,QAAQ;AAClB;AACA;AACA;;AAEA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA;AACA;;AAEA;AACA,aAAa,QAAQ;AACrB;AACA,aAAa,QAAQ;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa,OAAO;AACpB;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,UAAU;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,eAAe,WAAW;AAC1B;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;;AAEA;AACA;AACA,aAAa,QAAQ;AACrB;;AAEA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA,aAAa,OAAO;AACpB;AACA,eAAe,QAAQ;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;;AAEA;AACA,iBAAiB,QAAQ;AACzB;;AAEA;AACA,iBAAiB,QAAQ;AACzB;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAC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B;AACA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA;AACA,aAAa,MAAM;AACnB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,eAAe,QAAQ;AACvB;AACA;AACA;AACA;AACA,eAAe,QAAQ;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA,qBAAqB;AACrB,qBAAqB;;AAErB;AACA;AACA;;AAEA,sBAAsB;AACtB,sBAAsB;;AAEtB;AACA;AACA;;AAEA,sBAAsB;AACtB,sBAAsB;;AAEtB;AACA;AACA;;AAEA,sBAAsB;AACtB,sBAAsB;;AAEtB;AACA;AACA;;AAEA,sBAAsB;AACtB,sBAAsB;;AAEtB;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA,qBAAqB;AACrB,qBAAqB;;AAErB;AACA;AACA;;AAEA,sBAAsB;AACtB,sBAAsB;;AAEtB;AACA;AACA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AEA;AACA;;AAEA;AACA;;AAEA,mBAAmB;AACnB,mBAAmB;;AAEnB;AACA;;AAEA,oBAAoB;AACpB,oBAAoB;;AAEpB;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA,mBAAmB;AACnB,mBAAmB;;AAEnB;AACA;;AAEA,oBAAoB;AACpB,oBAAoB;;AAEpB;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA,aAAa,OAAO;AACpB;;AAEA;AACA;AACA;AACA;;AAEA,aAAa,OAAO;;AAEpB;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa,OAAO;AACpB;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,QAAQ;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA,aAAa,QAAQ;AACrB;AACA;;AAEA;;AAEA;AACA;AACA,cAAc,SAAS;AACvB;AACA,gCAAgC,OAAO;AACvC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA;AACA,aAAa,QAAQ;AACrB,aAAa,QAAQ;AACrB;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa,QAAQ;AACrB,aAAa,QAAQ;AACrB;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA,aAAa,OAAO;AACpB,aAAa,QAAQ;;AAErB;AACA;AACA;AACA;;AAEA,cAAc,QAAQ;AACtB;AACA;;AAEA,aAAa,QAAQ;AACrB,aAAa,QAAQ;AACrB,aAAa,QAAQ;AACrB,eAAe,QAAQ;AACvB;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;;AAEA,aAAa,OAAO;AACpB,aAAa,QAAQ;AACrB;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA,eAAe,OAAO;AACtB;AACA;;AAEA,aAAa,OAAO;AACpB;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA,iBAAiB,sBAAsB;AACvC;AACA;AACA;AACA;;AAEA;AACA,iBAAiB,gBAAgB;AACjC;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,iBAAiB,gBAAgB;AACjC;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,iBAAiB,gBAAgB;AACjC;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA,UAAU;AACV;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,UAAU;AACV;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAiB,cAAc;AAC/B;AACA;;AAEA;AACA;AACA;AACA,iBAAiB,gBAAgB;AACjC;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa,uBAAuB;AACpC,aAAa,gBAAgB;AAC7B;AACA;;AAEA;AACA;AACA;AACA;AACA,UAAU;AACV;;AAEA;AACA;AACA;AACA;AACA;AACA,iBAAiB,eAAe;AAChC,UAAU;AACV;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAiB,QAAQ;AACzB;AACA,UAAU;AACV;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAiB,OAAO;AACxB;AACA;AACA,iBAAiB,OAAO;AACxB;AACA,KAAK;AACL,GAAG,UAAU,IAA8B;AAC3C;AACA,aAAa,mBAAO,CAAC,CAAQ;AAC7B;AACA;AACA;AACA,mBAAmB,OAAO;AAC1B;AACA,OAAO;AACP;AACA;AACA,CAAC;;AAED,CAAC,EAAE,KAA6B,kEAAkE;;;;;;;ACt1ElG,iBAAiB,mBAAO,CAAC,CAA0B;;;;;;;ACAnD,e;;;;;;;;;;;;;;ACkBO,MAAM,qBAAqB;IAKhC,YAAY,MAAc,EAAE,IAAY;QACtC,IAAI,CAAC,MAAM,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,WAAM,CAAC,YAAY,GAAG,2CAAoB,CAAC,YAAY,CAAC;QACxD,WAAM,CAAC,GAAG,GAAG,2CAAoB,CAAC,GAAG,CAAC;QAEtC,eAAe,CAAC,OAAO,CAAC,CAAC;QACzB,OAAO,CAAC,IAAI,GAAG,SAAI,CAAC;QACpB,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAC1B,CAAC;CACF","file":"pusher-with-encryption.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"Pusher\"] = factory();\n\telse\n\t\troot[\"Pusher\"] = factory();\n})(window, function() {\nreturn "," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 3);\n","// Copyright (C) 2016 Dmitry Chestnykh\n// MIT License. See LICENSE file for details.\n\n/**\n * Package base64 implements Base64 encoding and decoding.\n */\n\n// Invalid character used in decoding to indicate\n// that the character to decode is out of range of\n// alphabet and cannot be decoded.\nconst INVALID_BYTE = 256;\n\n/**\n * Implements standard Base64 encoding.\n *\n * Operates in constant time.\n */\nexport class Coder {\n // TODO(dchest): methods to encode chunk-by-chunk.\n\n constructor(private _paddingCharacter = \"=\") { }\n\n encodedLength(length: number): number {\n if (!this._paddingCharacter) {\n return (length * 8 + 5) / 6 | 0;\n }\n return (length + 2) / 3 * 4 | 0;\n }\n\n encode(data: Uint8Array): string {\n let out = \"\";\n\n let i = 0;\n for (; i < data.length - 2; i += 3) {\n let c = (data[i] << 16) | (data[i + 1] << 8) | (data[i + 2]);\n out += this._encodeByte((c >>> 3 * 6) & 63);\n out += this._encodeByte((c >>> 2 * 6) & 63);\n out += this._encodeByte((c >>> 1 * 6) & 63);\n out += this._encodeByte((c >>> 0 * 6) & 63);\n }\n\n const left = data.length - i;\n if (left > 0) {\n let c = (data[i] << 16) | (left === 2 ? data[i + 1] << 8 : 0);\n out += this._encodeByte((c >>> 3 * 6) & 63);\n out += this._encodeByte((c >>> 2 * 6) & 63);\n if (left === 2) {\n out += this._encodeByte((c >>> 1 * 6) & 63);\n } else {\n out += this._paddingCharacter || \"\";\n }\n out += this._paddingCharacter || \"\";\n }\n\n return out;\n }\n\n maxDecodedLength(length: number): number {\n if (!this._paddingCharacter) {\n return (length * 6 + 7) / 8 | 0;\n }\n return length / 4 * 3 | 0;\n }\n\n decodedLength(s: string): number {\n return this.maxDecodedLength(s.length - this._getPaddingLength(s));\n }\n\n decode(s: string): Uint8Array {\n if (s.length === 0) {\n return new Uint8Array(0);\n }\n const paddingLength = this._getPaddingLength(s);\n const length = s.length - paddingLength;\n const out = new Uint8Array(this.maxDecodedLength(length));\n let op = 0;\n let i = 0;\n let haveBad = 0;\n let v0 = 0, v1 = 0, v2 = 0, v3 = 0;\n for (; i < length - 4; i += 4) {\n v0 = this._decodeChar(s.charCodeAt(i + 0));\n v1 = this._decodeChar(s.charCodeAt(i + 1));\n v2 = this._decodeChar(s.charCodeAt(i + 2));\n v3 = this._decodeChar(s.charCodeAt(i + 3));\n out[op++] = (v0 << 2) | (v1 >>> 4);\n out[op++] = (v1 << 4) | (v2 >>> 2);\n out[op++] = (v2 << 6) | v3;\n haveBad |= v0 & INVALID_BYTE;\n haveBad |= v1 & INVALID_BYTE;\n haveBad |= v2 & INVALID_BYTE;\n haveBad |= v3 & INVALID_BYTE;\n }\n if (i < length - 1) {\n v0 = this._decodeChar(s.charCodeAt(i));\n v1 = this._decodeChar(s.charCodeAt(i + 1));\n out[op++] = (v0 << 2) | (v1 >>> 4);\n haveBad |= v0 & INVALID_BYTE;\n haveBad |= v1 & INVALID_BYTE;\n }\n if (i < length - 2) {\n v2 = this._decodeChar(s.charCodeAt(i + 2));\n out[op++] = (v1 << 4) | (v2 >>> 2);\n haveBad |= v2 & INVALID_BYTE;\n }\n if (i < length - 3) {\n v3 = this._decodeChar(s.charCodeAt(i + 3));\n out[op++] = (v2 << 6) | v3;\n haveBad |= v3 & INVALID_BYTE;\n }\n if (haveBad !== 0) {\n throw new Error(\"Base64Coder: incorrect characters for decoding\");\n }\n return out;\n }\n\n // Standard encoding have the following encoded/decoded ranges,\n // which we need to convert between.\n //\n // ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 0123456789 + /\n // Index: 0 - 25 26 - 51 52 - 61 62 63\n // ASCII: 65 - 90 97 - 122 48 - 57 43 47\n //\n\n // Encode 6 bits in b into a new character.\n protected _encodeByte(b: number): string {\n // Encoding uses constant time operations as follows:\n //\n // 1. Define comparison of A with B using (A - B) >>> 8:\n // if A > B, then result is positive integer\n // if A <= B, then result is 0\n //\n // 2. Define selection of C or 0 using bitwise AND: X & C:\n // if X == 0, then result is 0\n // if X != 0, then result is C\n //\n // 3. Start with the smallest comparison (b >= 0), which is always\n // true, so set the result to the starting ASCII value (65).\n //\n // 4. Continue comparing b to higher ASCII values, and selecting\n // zero if comparison isn't true, otherwise selecting a value\n // to add to result, which:\n //\n // a) undoes the previous addition\n // b) provides new value to add\n //\n let result = b;\n // b >= 0\n result += 65;\n // b > 25\n result += ((25 - b) >>> 8) & ((0 - 65) - 26 + 97);\n // b > 51\n result += ((51 - b) >>> 8) & ((26 - 97) - 52 + 48);\n // b > 61\n result += ((61 - b) >>> 8) & ((52 - 48) - 62 + 43);\n // b > 62\n result += ((62 - b) >>> 8) & ((62 - 43) - 63 + 47);\n\n return String.fromCharCode(result);\n }\n\n // Decode a character code into a byte.\n // Must return 256 if character is out of alphabet range.\n protected _decodeChar(c: number): number {\n // Decoding works similar to encoding: using the same comparison\n // function, but now it works on ranges: result is always incremented\n // by value, but this value becomes zero if the range is not\n // satisfied.\n //\n // Decoding starts with invalid value, 256, which is then\n // subtracted when the range is satisfied. If none of the ranges\n // apply, the function returns 256, which is then checked by\n // the caller to throw error.\n let result = INVALID_BYTE; // start with invalid character\n\n // c == 43 (c > 42 and c < 44)\n result += (((42 - c) & (c - 44)) >>> 8) & (-INVALID_BYTE + c - 43 + 62);\n // c == 47 (c > 46 and c < 48)\n result += (((46 - c) & (c - 48)) >>> 8) & (-INVALID_BYTE + c - 47 + 63);\n // c > 47 and c < 58\n result += (((47 - c) & (c - 58)) >>> 8) & (-INVALID_BYTE + c - 48 + 52);\n // c > 64 and c < 91\n result += (((64 - c) & (c - 91)) >>> 8) & (-INVALID_BYTE + c - 65 + 0);\n // c > 96 and c < 123\n result += (((96 - c) & (c - 123)) >>> 8) & (-INVALID_BYTE + c - 97 + 26);\n\n return result;\n }\n\n private _getPaddingLength(s: string): number {\n let paddingLength = 0;\n if (this._paddingCharacter) {\n for (let i = s.length - 1; i >= 0; i--) {\n if (s[i] !== this._paddingCharacter) {\n break;\n }\n paddingLength++;\n }\n if (s.length < 4 || paddingLength > 2) {\n throw new Error(\"Base64Coder: incorrect padding\");\n }\n }\n return paddingLength;\n }\n\n}\n\nconst stdCoder = new Coder();\n\nexport function encode(data: Uint8Array): string {\n return stdCoder.encode(data);\n}\n\nexport function decode(s: string): Uint8Array {\n return stdCoder.decode(s);\n}\n\n/**\n * Implements URL-safe Base64 encoding.\n * (Same as Base64, but '+' is replaced with '-', and '/' with '_').\n *\n * Operates in constant time.\n */\nexport class URLSafeCoder extends Coder {\n // URL-safe encoding have the following encoded/decoded ranges:\n //\n // ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 0123456789 - _\n // Index: 0 - 25 26 - 51 52 - 61 62 63\n // ASCII: 65 - 90 97 - 122 48 - 57 45 95\n //\n\n protected _encodeByte(b: number): string {\n let result = b;\n // b >= 0\n result += 65;\n // b > 25\n result += ((25 - b) >>> 8) & ((0 - 65) - 26 + 97);\n // b > 51\n result += ((51 - b) >>> 8) & ((26 - 97) - 52 + 48);\n // b > 61\n result += ((61 - b) >>> 8) & ((52 - 48) - 62 + 45);\n // b > 62\n result += ((62 - b) >>> 8) & ((62 - 45) - 63 + 95);\n\n return String.fromCharCode(result);\n }\n\n protected _decodeChar(c: number): number {\n let result = INVALID_BYTE;\n\n // c == 45 (c > 44 and c < 46)\n result += (((44 - c) & (c - 46)) >>> 8) & (-INVALID_BYTE + c - 45 + 62);\n // c == 95 (c > 94 and c < 96)\n result += (((94 - c) & (c - 96)) >>> 8) & (-INVALID_BYTE + c - 95 + 63);\n // c > 47 and c < 58\n result += (((47 - c) & (c - 58)) >>> 8) & (-INVALID_BYTE + c - 48 + 52);\n // c > 64 and c < 91\n result += (((64 - c) & (c - 91)) >>> 8) & (-INVALID_BYTE + c - 65 + 0);\n // c > 96 and c < 123\n result += (((96 - c) & (c - 123)) >>> 8) & (-INVALID_BYTE + c - 97 + 26);\n\n return result;\n }\n}\n\nconst urlSafeCoder = new URLSafeCoder();\n\nexport function encodeURLSafe(data: Uint8Array): string {\n return urlSafeCoder.encode(data);\n}\n\nexport function decodeURLSafe(s: string): Uint8Array {\n return urlSafeCoder.decode(s);\n}\n\n\nexport const encodedLength = (length: number) =>\n stdCoder.encodedLength(length);\n\nexport const maxDecodedLength = (length: number) =>\n stdCoder.maxDecodedLength(length);\n\nexport const decodedLength = (s: string) =>\n stdCoder.decodedLength(s);\n","// Copyright (C) 2016 Dmitry Chestnykh\n// MIT License. See LICENSE file for details.\n\n/**\n * Package utf8 implements UTF-8 encoding and decoding.\n */\n\nconst INVALID_UTF16 = \"utf8: invalid string\";\nconst INVALID_UTF8 = \"utf8: invalid source encoding\";\n\n/**\n * Encodes the given string into UTF-8 byte array.\n * Throws if the source string has invalid UTF-16 encoding.\n */\nexport function encode(s: string): Uint8Array {\n // Calculate result length and allocate output array.\n // encodedLength() also validates string and throws errors,\n // so we don't need repeat validation here.\n const arr = new Uint8Array(encodedLength(s));\n\n let pos = 0;\n for (let i = 0; i < s.length; i++) {\n let c = s.charCodeAt(i);\n if (c < 0x80) {\n arr[pos++] = c;\n } else if (c < 0x800) {\n arr[pos++] = 0xc0 | c >> 6;\n arr[pos++] = 0x80 | c & 0x3f;\n } else if (c < 0xd800) {\n arr[pos++] = 0xe0 | c >> 12;\n arr[pos++] = 0x80 | (c >> 6) & 0x3f;\n arr[pos++] = 0x80 | c & 0x3f;\n } else {\n i++; // get one more character\n c = (c & 0x3ff) << 10;\n c |= s.charCodeAt(i) & 0x3ff;\n c += 0x10000;\n\n arr[pos++] = 0xf0 | c >> 18;\n arr[pos++] = 0x80 | (c >> 12) & 0x3f;\n arr[pos++] = 0x80 | (c >> 6) & 0x3f;\n arr[pos++] = 0x80 | c & 0x3f;\n }\n }\n return arr;\n}\n\n/**\n * Returns the number of bytes required to encode the given string into UTF-8.\n * Throws if the source string has invalid UTF-16 encoding.\n */\nexport function encodedLength(s: string): number {\n let result = 0;\n for (let i = 0; i < s.length; i++) {\n const c = s.charCodeAt(i);\n if (c < 0x80) {\n result += 1;\n } else if (c < 0x800) {\n result += 2;\n } else if (c < 0xd800) {\n result += 3;\n } else if (c <= 0xdfff) {\n if (i >= s.length - 1) {\n throw new Error(INVALID_UTF16);\n }\n i++; // \"eat\" next character\n result += 4;\n } else {\n throw new Error(INVALID_UTF16);\n }\n }\n return result;\n}\n\n/**\n * Decodes the given byte array from UTF-8 into a string.\n * Throws if encoding is invalid.\n */\nexport function decode(arr: Uint8Array): string {\n const chars: string[] = [];\n for (let i = 0; i < arr.length; i++) {\n let b = arr[i];\n\n if (b & 0x80) {\n let min;\n if (b < 0xe0) {\n // Need 1 more byte.\n if (i >= arr.length) {\n throw new Error(INVALID_UTF8);\n }\n const n1 = arr[++i];\n if ((n1 & 0xc0) !== 0x80) {\n throw new Error(INVALID_UTF8);\n }\n b = (b & 0x1f) << 6 | (n1 & 0x3f);\n min = 0x80;\n } else if (b < 0xf0) {\n // Need 2 more bytes.\n if (i >= arr.length - 1) {\n throw new Error(INVALID_UTF8);\n }\n const n1 = arr[++i];\n const n2 = arr[++i];\n if ((n1 & 0xc0) !== 0x80 || (n2 & 0xc0) !== 0x80) {\n throw new Error(INVALID_UTF8);\n }\n b = (b & 0x0f) << 12 | (n1 & 0x3f) << 6 | (n2 & 0x3f);\n min = 0x800;\n } else if (b < 0xf8) {\n // Need 3 more bytes.\n if (i >= arr.length - 2) {\n throw new Error(INVALID_UTF8);\n }\n const n1 = arr[++i];\n const n2 = arr[++i];\n const n3 = arr[++i];\n if ((n1 & 0xc0) !== 0x80 || (n2 & 0xc0) !== 0x80 || (n3 & 0xc0) !== 0x80) {\n throw new Error(INVALID_UTF8);\n }\n b = (b & 0x0f) << 18 | (n1 & 0x3f) << 12 | (n2 & 0x3f) << 6 | (n3 & 0x3f);\n min = 0x10000;\n } else {\n throw new Error(INVALID_UTF8);\n }\n\n if (b < min || (b >= 0xd800 && b <= 0xdfff)) {\n throw new Error(INVALID_UTF8);\n }\n\n if (b >= 0x10000) {\n // Surrogate pair.\n if (b > 0x10ffff) {\n throw new Error(INVALID_UTF8);\n }\n b -= 0x10000;\n chars.push(String.fromCharCode(0xd800 | (b >> 10)));\n b = 0xdc00 | (b & 0x3ff);\n }\n }\n\n chars.push(String.fromCharCode(b));\n }\n return chars.join(\"\");\n}\n","(function(nacl) {\n'use strict';\n\n// Ported in 2014 by Dmitry Chestnykh and Devi Mandiri.\n// Public domain.\n//\n// Implementation derived from TweetNaCl version 20140427.\n// See for details: http://tweetnacl.cr.yp.to/\n\nvar gf = function(init) {\n var i, r = new Float64Array(16);\n if (init) for (i = 0; i < init.length; i++) r[i] = init[i];\n return r;\n};\n\n// Pluggable, initialized in high-level API below.\nvar randombytes = function(/* x, n */) { throw new Error('no PRNG'); };\n\nvar _0 = new Uint8Array(16);\nvar _9 = new Uint8Array(32); _9[0] = 9;\n\nvar gf0 = gf(),\n gf1 = gf([1]),\n _121665 = gf([0xdb41, 1]),\n D = gf([0x78a3, 0x1359, 0x4dca, 0x75eb, 0xd8ab, 0x4141, 0x0a4d, 0x0070, 0xe898, 0x7779, 0x4079, 0x8cc7, 0xfe73, 0x2b6f, 0x6cee, 0x5203]),\n D2 = gf([0xf159, 0x26b2, 0x9b94, 0xebd6, 0xb156, 0x8283, 0x149a, 0x00e0, 0xd130, 0xeef3, 0x80f2, 0x198e, 0xfce7, 0x56df, 0xd9dc, 0x2406]),\n X = gf([0xd51a, 0x8f25, 0x2d60, 0xc956, 0xa7b2, 0x9525, 0xc760, 0x692c, 0xdc5c, 0xfdd6, 0xe231, 0xc0a4, 0x53fe, 0xcd6e, 0x36d3, 0x2169]),\n Y = gf([0x6658, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666]),\n I = gf([0xa0b0, 0x4a0e, 0x1b27, 0xc4ee, 0xe478, 0xad2f, 0x1806, 0x2f43, 0xd7a7, 0x3dfb, 0x0099, 0x2b4d, 0xdf0b, 0x4fc1, 0x2480, 0x2b83]);\n\nfunction ts64(x, i, h, l) {\n x[i] = (h >> 24) & 0xff;\n x[i+1] = (h >> 16) & 0xff;\n x[i+2] = (h >> 8) & 0xff;\n x[i+3] = h & 0xff;\n x[i+4] = (l >> 24) & 0xff;\n x[i+5] = (l >> 16) & 0xff;\n x[i+6] = (l >> 8) & 0xff;\n x[i+7] = l & 0xff;\n}\n\nfunction vn(x, xi, y, yi, n) {\n var i,d = 0;\n for (i = 0; i < n; i++) d |= x[xi+i]^y[yi+i];\n return (1 & ((d - 1) >>> 8)) - 1;\n}\n\nfunction crypto_verify_16(x, xi, y, yi) {\n return vn(x,xi,y,yi,16);\n}\n\nfunction crypto_verify_32(x, xi, y, yi) {\n return vn(x,xi,y,yi,32);\n}\n\nfunction core_salsa20(o, p, k, c) {\n var j0 = c[ 0] & 0xff | (c[ 1] & 0xff)<<8 | (c[ 2] & 0xff)<<16 | (c[ 3] & 0xff)<<24,\n j1 = k[ 0] & 0xff | (k[ 1] & 0xff)<<8 | (k[ 2] & 0xff)<<16 | (k[ 3] & 0xff)<<24,\n j2 = k[ 4] & 0xff | (k[ 5] & 0xff)<<8 | (k[ 6] & 0xff)<<16 | (k[ 7] & 0xff)<<24,\n j3 = k[ 8] & 0xff | (k[ 9] & 0xff)<<8 | (k[10] & 0xff)<<16 | (k[11] & 0xff)<<24,\n j4 = k[12] & 0xff | (k[13] & 0xff)<<8 | (k[14] & 0xff)<<16 | (k[15] & 0xff)<<24,\n j5 = c[ 4] & 0xff | (c[ 5] & 0xff)<<8 | (c[ 6] & 0xff)<<16 | (c[ 7] & 0xff)<<24,\n j6 = p[ 0] & 0xff | (p[ 1] & 0xff)<<8 | (p[ 2] & 0xff)<<16 | (p[ 3] & 0xff)<<24,\n j7 = p[ 4] & 0xff | (p[ 5] & 0xff)<<8 | (p[ 6] & 0xff)<<16 | (p[ 7] & 0xff)<<24,\n j8 = p[ 8] & 0xff | (p[ 9] & 0xff)<<8 | (p[10] & 0xff)<<16 | (p[11] & 0xff)<<24,\n j9 = p[12] & 0xff | (p[13] & 0xff)<<8 | (p[14] & 0xff)<<16 | (p[15] & 0xff)<<24,\n j10 = c[ 8] & 0xff | (c[ 9] & 0xff)<<8 | (c[10] & 0xff)<<16 | (c[11] & 0xff)<<24,\n j11 = k[16] & 0xff | (k[17] & 0xff)<<8 | (k[18] & 0xff)<<16 | (k[19] & 0xff)<<24,\n j12 = k[20] & 0xff | (k[21] & 0xff)<<8 | (k[22] & 0xff)<<16 | (k[23] & 0xff)<<24,\n j13 = k[24] & 0xff | (k[25] & 0xff)<<8 | (k[26] & 0xff)<<16 | (k[27] & 0xff)<<24,\n j14 = k[28] & 0xff | (k[29] & 0xff)<<8 | (k[30] & 0xff)<<16 | (k[31] & 0xff)<<24,\n j15 = c[12] & 0xff | (c[13] & 0xff)<<8 | (c[14] & 0xff)<<16 | (c[15] & 0xff)<<24;\n\n var x0 = j0, x1 = j1, x2 = j2, x3 = j3, x4 = j4, x5 = j5, x6 = j6, x7 = j7,\n x8 = j8, x9 = j9, x10 = j10, x11 = j11, x12 = j12, x13 = j13, x14 = j14,\n x15 = j15, u;\n\n for (var i = 0; i < 20; i += 2) {\n u = x0 + x12 | 0;\n x4 ^= u<<7 | u>>>(32-7);\n u = x4 + x0 | 0;\n x8 ^= u<<9 | u>>>(32-9);\n u = x8 + x4 | 0;\n x12 ^= u<<13 | u>>>(32-13);\n u = x12 + x8 | 0;\n x0 ^= u<<18 | u>>>(32-18);\n\n u = x5 + x1 | 0;\n x9 ^= u<<7 | u>>>(32-7);\n u = x9 + x5 | 0;\n x13 ^= u<<9 | u>>>(32-9);\n u = x13 + x9 | 0;\n x1 ^= u<<13 | u>>>(32-13);\n u = x1 + x13 | 0;\n x5 ^= u<<18 | u>>>(32-18);\n\n u = x10 + x6 | 0;\n x14 ^= u<<7 | u>>>(32-7);\n u = x14 + x10 | 0;\n x2 ^= u<<9 | u>>>(32-9);\n u = x2 + x14 | 0;\n x6 ^= u<<13 | u>>>(32-13);\n u = x6 + x2 | 0;\n x10 ^= u<<18 | u>>>(32-18);\n\n u = x15 + x11 | 0;\n x3 ^= u<<7 | u>>>(32-7);\n u = x3 + x15 | 0;\n x7 ^= u<<9 | u>>>(32-9);\n u = x7 + x3 | 0;\n x11 ^= u<<13 | u>>>(32-13);\n u = x11 + x7 | 0;\n x15 ^= u<<18 | u>>>(32-18);\n\n u = x0 + x3 | 0;\n x1 ^= u<<7 | u>>>(32-7);\n u = x1 + x0 | 0;\n x2 ^= u<<9 | u>>>(32-9);\n u = x2 + x1 | 0;\n x3 ^= u<<13 | u>>>(32-13);\n u = x3 + x2 | 0;\n x0 ^= u<<18 | u>>>(32-18);\n\n u = x5 + x4 | 0;\n x6 ^= u<<7 | u>>>(32-7);\n u = x6 + x5 | 0;\n x7 ^= u<<9 | u>>>(32-9);\n u = x7 + x6 | 0;\n x4 ^= u<<13 | u>>>(32-13);\n u = x4 + x7 | 0;\n x5 ^= u<<18 | u>>>(32-18);\n\n u = x10 + x9 | 0;\n x11 ^= u<<7 | u>>>(32-7);\n u = x11 + x10 | 0;\n x8 ^= u<<9 | u>>>(32-9);\n u = x8 + x11 | 0;\n x9 ^= u<<13 | u>>>(32-13);\n u = x9 + x8 | 0;\n x10 ^= u<<18 | u>>>(32-18);\n\n u = x15 + x14 | 0;\n x12 ^= u<<7 | u>>>(32-7);\n u = x12 + x15 | 0;\n x13 ^= u<<9 | u>>>(32-9);\n u = x13 + x12 | 0;\n x14 ^= u<<13 | u>>>(32-13);\n u = x14 + x13 | 0;\n x15 ^= u<<18 | u>>>(32-18);\n }\n x0 = x0 + j0 | 0;\n x1 = x1 + j1 | 0;\n x2 = x2 + j2 | 0;\n x3 = x3 + j3 | 0;\n x4 = x4 + j4 | 0;\n x5 = x5 + j5 | 0;\n x6 = x6 + j6 | 0;\n x7 = x7 + j7 | 0;\n x8 = x8 + j8 | 0;\n x9 = x9 + j9 | 0;\n x10 = x10 + j10 | 0;\n x11 = x11 + j11 | 0;\n x12 = x12 + j12 | 0;\n x13 = x13 + j13 | 0;\n x14 = x14 + j14 | 0;\n x15 = x15 + j15 | 0;\n\n o[ 0] = x0 >>> 0 & 0xff;\n o[ 1] = x0 >>> 8 & 0xff;\n o[ 2] = x0 >>> 16 & 0xff;\n o[ 3] = x0 >>> 24 & 0xff;\n\n o[ 4] = x1 >>> 0 & 0xff;\n o[ 5] = x1 >>> 8 & 0xff;\n o[ 6] = x1 >>> 16 & 0xff;\n o[ 7] = x1 >>> 24 & 0xff;\n\n o[ 8] = x2 >>> 0 & 0xff;\n o[ 9] = x2 >>> 8 & 0xff;\n o[10] = x2 >>> 16 & 0xff;\n o[11] = x2 >>> 24 & 0xff;\n\n o[12] = x3 >>> 0 & 0xff;\n o[13] = x3 >>> 8 & 0xff;\n o[14] = x3 >>> 16 & 0xff;\n o[15] = x3 >>> 24 & 0xff;\n\n o[16] = x4 >>> 0 & 0xff;\n o[17] = x4 >>> 8 & 0xff;\n o[18] = x4 >>> 16 & 0xff;\n o[19] = x4 >>> 24 & 0xff;\n\n o[20] = x5 >>> 0 & 0xff;\n o[21] = x5 >>> 8 & 0xff;\n o[22] = x5 >>> 16 & 0xff;\n o[23] = x5 >>> 24 & 0xff;\n\n o[24] = x6 >>> 0 & 0xff;\n o[25] = x6 >>> 8 & 0xff;\n o[26] = x6 >>> 16 & 0xff;\n o[27] = x6 >>> 24 & 0xff;\n\n o[28] = x7 >>> 0 & 0xff;\n o[29] = x7 >>> 8 & 0xff;\n o[30] = x7 >>> 16 & 0xff;\n o[31] = x7 >>> 24 & 0xff;\n\n o[32] = x8 >>> 0 & 0xff;\n o[33] = x8 >>> 8 & 0xff;\n o[34] = x8 >>> 16 & 0xff;\n o[35] = x8 >>> 24 & 0xff;\n\n o[36] = x9 >>> 0 & 0xff;\n o[37] = x9 >>> 8 & 0xff;\n o[38] = x9 >>> 16 & 0xff;\n o[39] = x9 >>> 24 & 0xff;\n\n o[40] = x10 >>> 0 & 0xff;\n o[41] = x10 >>> 8 & 0xff;\n o[42] = x10 >>> 16 & 0xff;\n o[43] = x10 >>> 24 & 0xff;\n\n o[44] = x11 >>> 0 & 0xff;\n o[45] = x11 >>> 8 & 0xff;\n o[46] = x11 >>> 16 & 0xff;\n o[47] = x11 >>> 24 & 0xff;\n\n o[48] = x12 >>> 0 & 0xff;\n o[49] = x12 >>> 8 & 0xff;\n o[50] = x12 >>> 16 & 0xff;\n o[51] = x12 >>> 24 & 0xff;\n\n o[52] = x13 >>> 0 & 0xff;\n o[53] = x13 >>> 8 & 0xff;\n o[54] = x13 >>> 16 & 0xff;\n o[55] = x13 >>> 24 & 0xff;\n\n o[56] = x14 >>> 0 & 0xff;\n o[57] = x14 >>> 8 & 0xff;\n o[58] = x14 >>> 16 & 0xff;\n o[59] = x14 >>> 24 & 0xff;\n\n o[60] = x15 >>> 0 & 0xff;\n o[61] = x15 >>> 8 & 0xff;\n o[62] = x15 >>> 16 & 0xff;\n o[63] = x15 >>> 24 & 0xff;\n}\n\nfunction core_hsalsa20(o,p,k,c) {\n var j0 = c[ 0] & 0xff | (c[ 1] & 0xff)<<8 | (c[ 2] & 0xff)<<16 | (c[ 3] & 0xff)<<24,\n j1 = k[ 0] & 0xff | (k[ 1] & 0xff)<<8 | (k[ 2] & 0xff)<<16 | (k[ 3] & 0xff)<<24,\n j2 = k[ 4] & 0xff | (k[ 5] & 0xff)<<8 | (k[ 6] & 0xff)<<16 | (k[ 7] & 0xff)<<24,\n j3 = k[ 8] & 0xff | (k[ 9] & 0xff)<<8 | (k[10] & 0xff)<<16 | (k[11] & 0xff)<<24,\n j4 = k[12] & 0xff | (k[13] & 0xff)<<8 | (k[14] & 0xff)<<16 | (k[15] & 0xff)<<24,\n j5 = c[ 4] & 0xff | (c[ 5] & 0xff)<<8 | (c[ 6] & 0xff)<<16 | (c[ 7] & 0xff)<<24,\n j6 = p[ 0] & 0xff | (p[ 1] & 0xff)<<8 | (p[ 2] & 0xff)<<16 | (p[ 3] & 0xff)<<24,\n j7 = p[ 4] & 0xff | (p[ 5] & 0xff)<<8 | (p[ 6] & 0xff)<<16 | (p[ 7] & 0xff)<<24,\n j8 = p[ 8] & 0xff | (p[ 9] & 0xff)<<8 | (p[10] & 0xff)<<16 | (p[11] & 0xff)<<24,\n j9 = p[12] & 0xff | (p[13] & 0xff)<<8 | (p[14] & 0xff)<<16 | (p[15] & 0xff)<<24,\n j10 = c[ 8] & 0xff | (c[ 9] & 0xff)<<8 | (c[10] & 0xff)<<16 | (c[11] & 0xff)<<24,\n j11 = k[16] & 0xff | (k[17] & 0xff)<<8 | (k[18] & 0xff)<<16 | (k[19] & 0xff)<<24,\n j12 = k[20] & 0xff | (k[21] & 0xff)<<8 | (k[22] & 0xff)<<16 | (k[23] & 0xff)<<24,\n j13 = k[24] & 0xff | (k[25] & 0xff)<<8 | (k[26] & 0xff)<<16 | (k[27] & 0xff)<<24,\n j14 = k[28] & 0xff | (k[29] & 0xff)<<8 | (k[30] & 0xff)<<16 | (k[31] & 0xff)<<24,\n j15 = c[12] & 0xff | (c[13] & 0xff)<<8 | (c[14] & 0xff)<<16 | (c[15] & 0xff)<<24;\n\n var x0 = j0, x1 = j1, x2 = j2, x3 = j3, x4 = j4, x5 = j5, x6 = j6, x7 = j7,\n x8 = j8, x9 = j9, x10 = j10, x11 = j11, x12 = j12, x13 = j13, x14 = j14,\n x15 = j15, u;\n\n for (var i = 0; i < 20; i += 2) {\n u = x0 + x12 | 0;\n x4 ^= u<<7 | u>>>(32-7);\n u = x4 + x0 | 0;\n x8 ^= u<<9 | u>>>(32-9);\n u = x8 + x4 | 0;\n x12 ^= u<<13 | u>>>(32-13);\n u = x12 + x8 | 0;\n x0 ^= u<<18 | u>>>(32-18);\n\n u = x5 + x1 | 0;\n x9 ^= u<<7 | u>>>(32-7);\n u = x9 + x5 | 0;\n x13 ^= u<<9 | u>>>(32-9);\n u = x13 + x9 | 0;\n x1 ^= u<<13 | u>>>(32-13);\n u = x1 + x13 | 0;\n x5 ^= u<<18 | u>>>(32-18);\n\n u = x10 + x6 | 0;\n x14 ^= u<<7 | u>>>(32-7);\n u = x14 + x10 | 0;\n x2 ^= u<<9 | u>>>(32-9);\n u = x2 + x14 | 0;\n x6 ^= u<<13 | u>>>(32-13);\n u = x6 + x2 | 0;\n x10 ^= u<<18 | u>>>(32-18);\n\n u = x15 + x11 | 0;\n x3 ^= u<<7 | u>>>(32-7);\n u = x3 + x15 | 0;\n x7 ^= u<<9 | u>>>(32-9);\n u = x7 + x3 | 0;\n x11 ^= u<<13 | u>>>(32-13);\n u = x11 + x7 | 0;\n x15 ^= u<<18 | u>>>(32-18);\n\n u = x0 + x3 | 0;\n x1 ^= u<<7 | u>>>(32-7);\n u = x1 + x0 | 0;\n x2 ^= u<<9 | u>>>(32-9);\n u = x2 + x1 | 0;\n x3 ^= u<<13 | u>>>(32-13);\n u = x3 + x2 | 0;\n x0 ^= u<<18 | u>>>(32-18);\n\n u = x5 + x4 | 0;\n x6 ^= u<<7 | u>>>(32-7);\n u = x6 + x5 | 0;\n x7 ^= u<<9 | u>>>(32-9);\n u = x7 + x6 | 0;\n x4 ^= u<<13 | u>>>(32-13);\n u = x4 + x7 | 0;\n x5 ^= u<<18 | u>>>(32-18);\n\n u = x10 + x9 | 0;\n x11 ^= u<<7 | u>>>(32-7);\n u = x11 + x10 | 0;\n x8 ^= u<<9 | u>>>(32-9);\n u = x8 + x11 | 0;\n x9 ^= u<<13 | u>>>(32-13);\n u = x9 + x8 | 0;\n x10 ^= u<<18 | u>>>(32-18);\n\n u = x15 + x14 | 0;\n x12 ^= u<<7 | u>>>(32-7);\n u = x12 + x15 | 0;\n x13 ^= u<<9 | u>>>(32-9);\n u = x13 + x12 | 0;\n x14 ^= u<<13 | u>>>(32-13);\n u = x14 + x13 | 0;\n x15 ^= u<<18 | u>>>(32-18);\n }\n\n o[ 0] = x0 >>> 0 & 0xff;\n o[ 1] = x0 >>> 8 & 0xff;\n o[ 2] = x0 >>> 16 & 0xff;\n o[ 3] = x0 >>> 24 & 0xff;\n\n o[ 4] = x5 >>> 0 & 0xff;\n o[ 5] = x5 >>> 8 & 0xff;\n o[ 6] = x5 >>> 16 & 0xff;\n o[ 7] = x5 >>> 24 & 0xff;\n\n o[ 8] = x10 >>> 0 & 0xff;\n o[ 9] = x10 >>> 8 & 0xff;\n o[10] = x10 >>> 16 & 0xff;\n o[11] = x10 >>> 24 & 0xff;\n\n o[12] = x15 >>> 0 & 0xff;\n o[13] = x15 >>> 8 & 0xff;\n o[14] = x15 >>> 16 & 0xff;\n o[15] = x15 >>> 24 & 0xff;\n\n o[16] = x6 >>> 0 & 0xff;\n o[17] = x6 >>> 8 & 0xff;\n o[18] = x6 >>> 16 & 0xff;\n o[19] = x6 >>> 24 & 0xff;\n\n o[20] = x7 >>> 0 & 0xff;\n o[21] = x7 >>> 8 & 0xff;\n o[22] = x7 >>> 16 & 0xff;\n o[23] = x7 >>> 24 & 0xff;\n\n o[24] = x8 >>> 0 & 0xff;\n o[25] = x8 >>> 8 & 0xff;\n o[26] = x8 >>> 16 & 0xff;\n o[27] = x8 >>> 24 & 0xff;\n\n o[28] = x9 >>> 0 & 0xff;\n o[29] = x9 >>> 8 & 0xff;\n o[30] = x9 >>> 16 & 0xff;\n o[31] = x9 >>> 24 & 0xff;\n}\n\nfunction crypto_core_salsa20(out,inp,k,c) {\n core_salsa20(out,inp,k,c);\n}\n\nfunction crypto_core_hsalsa20(out,inp,k,c) {\n core_hsalsa20(out,inp,k,c);\n}\n\nvar sigma = new Uint8Array([101, 120, 112, 97, 110, 100, 32, 51, 50, 45, 98, 121, 116, 101, 32, 107]);\n // \"expand 32-byte k\"\n\nfunction crypto_stream_salsa20_xor(c,cpos,m,mpos,b,n,k) {\n var z = new Uint8Array(16), x = new Uint8Array(64);\n var u, i;\n for (i = 0; i < 16; i++) z[i] = 0;\n for (i = 0; i < 8; i++) z[i] = n[i];\n while (b >= 64) {\n crypto_core_salsa20(x,z,k,sigma);\n for (i = 0; i < 64; i++) c[cpos+i] = m[mpos+i] ^ x[i];\n u = 1;\n for (i = 8; i < 16; i++) {\n u = u + (z[i] & 0xff) | 0;\n z[i] = u & 0xff;\n u >>>= 8;\n }\n b -= 64;\n cpos += 64;\n mpos += 64;\n }\n if (b > 0) {\n crypto_core_salsa20(x,z,k,sigma);\n for (i = 0; i < b; i++) c[cpos+i] = m[mpos+i] ^ x[i];\n }\n return 0;\n}\n\nfunction crypto_stream_salsa20(c,cpos,b,n,k) {\n var z = new Uint8Array(16), x = new Uint8Array(64);\n var u, i;\n for (i = 0; i < 16; i++) z[i] = 0;\n for (i = 0; i < 8; i++) z[i] = n[i];\n while (b >= 64) {\n crypto_core_salsa20(x,z,k,sigma);\n for (i = 0; i < 64; i++) c[cpos+i] = x[i];\n u = 1;\n for (i = 8; i < 16; i++) {\n u = u + (z[i] & 0xff) | 0;\n z[i] = u & 0xff;\n u >>>= 8;\n }\n b -= 64;\n cpos += 64;\n }\n if (b > 0) {\n crypto_core_salsa20(x,z,k,sigma);\n for (i = 0; i < b; i++) c[cpos+i] = x[i];\n }\n return 0;\n}\n\nfunction crypto_stream(c,cpos,d,n,k) {\n var s = new Uint8Array(32);\n crypto_core_hsalsa20(s,n,k,sigma);\n var sn = new Uint8Array(8);\n for (var i = 0; i < 8; i++) sn[i] = n[i+16];\n return crypto_stream_salsa20(c,cpos,d,sn,s);\n}\n\nfunction crypto_stream_xor(c,cpos,m,mpos,d,n,k) {\n var s = new Uint8Array(32);\n crypto_core_hsalsa20(s,n,k,sigma);\n var sn = new Uint8Array(8);\n for (var i = 0; i < 8; i++) sn[i] = n[i+16];\n return crypto_stream_salsa20_xor(c,cpos,m,mpos,d,sn,s);\n}\n\n/*\n* Port of Andrew Moon's Poly1305-donna-16. Public domain.\n* https://github.com/floodyberry/poly1305-donna\n*/\n\nvar poly1305 = function(key) {\n this.buffer = new Uint8Array(16);\n this.r = new Uint16Array(10);\n this.h = new Uint16Array(10);\n this.pad = new Uint16Array(8);\n this.leftover = 0;\n this.fin = 0;\n\n var t0, t1, t2, t3, t4, t5, t6, t7;\n\n t0 = key[ 0] & 0xff | (key[ 1] & 0xff) << 8; this.r[0] = ( t0 ) & 0x1fff;\n t1 = key[ 2] & 0xff | (key[ 3] & 0xff) << 8; this.r[1] = ((t0 >>> 13) | (t1 << 3)) & 0x1fff;\n t2 = key[ 4] & 0xff | (key[ 5] & 0xff) << 8; this.r[2] = ((t1 >>> 10) | (t2 << 6)) & 0x1f03;\n t3 = key[ 6] & 0xff | (key[ 7] & 0xff) << 8; this.r[3] = ((t2 >>> 7) | (t3 << 9)) & 0x1fff;\n t4 = key[ 8] & 0xff | (key[ 9] & 0xff) << 8; this.r[4] = ((t3 >>> 4) | (t4 << 12)) & 0x00ff;\n this.r[5] = ((t4 >>> 1)) & 0x1ffe;\n t5 = key[10] & 0xff | (key[11] & 0xff) << 8; this.r[6] = ((t4 >>> 14) | (t5 << 2)) & 0x1fff;\n t6 = key[12] & 0xff | (key[13] & 0xff) << 8; this.r[7] = ((t5 >>> 11) | (t6 << 5)) & 0x1f81;\n t7 = key[14] & 0xff | (key[15] & 0xff) << 8; this.r[8] = ((t6 >>> 8) | (t7 << 8)) & 0x1fff;\n this.r[9] = ((t7 >>> 5)) & 0x007f;\n\n this.pad[0] = key[16] & 0xff | (key[17] & 0xff) << 8;\n this.pad[1] = key[18] & 0xff | (key[19] & 0xff) << 8;\n this.pad[2] = key[20] & 0xff | (key[21] & 0xff) << 8;\n this.pad[3] = key[22] & 0xff | (key[23] & 0xff) << 8;\n this.pad[4] = key[24] & 0xff | (key[25] & 0xff) << 8;\n this.pad[5] = key[26] & 0xff | (key[27] & 0xff) << 8;\n this.pad[6] = key[28] & 0xff | (key[29] & 0xff) << 8;\n this.pad[7] = key[30] & 0xff | (key[31] & 0xff) << 8;\n};\n\npoly1305.prototype.blocks = function(m, mpos, bytes) {\n var hibit = this.fin ? 0 : (1 << 11);\n var t0, t1, t2, t3, t4, t5, t6, t7, c;\n var d0, d1, d2, d3, d4, d5, d6, d7, d8, d9;\n\n var h0 = this.h[0],\n h1 = this.h[1],\n h2 = this.h[2],\n h3 = this.h[3],\n h4 = this.h[4],\n h5 = this.h[5],\n h6 = this.h[6],\n h7 = this.h[7],\n h8 = this.h[8],\n h9 = this.h[9];\n\n var r0 = this.r[0],\n r1 = this.r[1],\n r2 = this.r[2],\n r3 = this.r[3],\n r4 = this.r[4],\n r5 = this.r[5],\n r6 = this.r[6],\n r7 = this.r[7],\n r8 = this.r[8],\n r9 = this.r[9];\n\n while (bytes >= 16) {\n t0 = m[mpos+ 0] & 0xff | (m[mpos+ 1] & 0xff) << 8; h0 += ( t0 ) & 0x1fff;\n t1 = m[mpos+ 2] & 0xff | (m[mpos+ 3] & 0xff) << 8; h1 += ((t0 >>> 13) | (t1 << 3)) & 0x1fff;\n t2 = m[mpos+ 4] & 0xff | (m[mpos+ 5] & 0xff) << 8; h2 += ((t1 >>> 10) | (t2 << 6)) & 0x1fff;\n t3 = m[mpos+ 6] & 0xff | (m[mpos+ 7] & 0xff) << 8; h3 += ((t2 >>> 7) | (t3 << 9)) & 0x1fff;\n t4 = m[mpos+ 8] & 0xff | (m[mpos+ 9] & 0xff) << 8; h4 += ((t3 >>> 4) | (t4 << 12)) & 0x1fff;\n h5 += ((t4 >>> 1)) & 0x1fff;\n t5 = m[mpos+10] & 0xff | (m[mpos+11] & 0xff) << 8; h6 += ((t4 >>> 14) | (t5 << 2)) & 0x1fff;\n t6 = m[mpos+12] & 0xff | (m[mpos+13] & 0xff) << 8; h7 += ((t5 >>> 11) | (t6 << 5)) & 0x1fff;\n t7 = m[mpos+14] & 0xff | (m[mpos+15] & 0xff) << 8; h8 += ((t6 >>> 8) | (t7 << 8)) & 0x1fff;\n h9 += ((t7 >>> 5)) | hibit;\n\n c = 0;\n\n d0 = c;\n d0 += h0 * r0;\n d0 += h1 * (5 * r9);\n d0 += h2 * (5 * r8);\n d0 += h3 * (5 * r7);\n d0 += h4 * (5 * r6);\n c = (d0 >>> 13); d0 &= 0x1fff;\n d0 += h5 * (5 * r5);\n d0 += h6 * (5 * r4);\n d0 += h7 * (5 * r3);\n d0 += h8 * (5 * r2);\n d0 += h9 * (5 * r1);\n c += (d0 >>> 13); d0 &= 0x1fff;\n\n d1 = c;\n d1 += h0 * r1;\n d1 += h1 * r0;\n d1 += h2 * (5 * r9);\n d1 += h3 * (5 * r8);\n d1 += h4 * (5 * r7);\n c = (d1 >>> 13); d1 &= 0x1fff;\n d1 += h5 * (5 * r6);\n d1 += h6 * (5 * r5);\n d1 += h7 * (5 * r4);\n d1 += h8 * (5 * r3);\n d1 += h9 * (5 * r2);\n c += (d1 >>> 13); d1 &= 0x1fff;\n\n d2 = c;\n d2 += h0 * r2;\n d2 += h1 * r1;\n d2 += h2 * r0;\n d2 += h3 * (5 * r9);\n d2 += h4 * (5 * r8);\n c = (d2 >>> 13); d2 &= 0x1fff;\n d2 += h5 * (5 * r7);\n d2 += h6 * (5 * r6);\n d2 += h7 * (5 * r5);\n d2 += h8 * (5 * r4);\n d2 += h9 * (5 * r3);\n c += (d2 >>> 13); d2 &= 0x1fff;\n\n d3 = c;\n d3 += h0 * r3;\n d3 += h1 * r2;\n d3 += h2 * r1;\n d3 += h3 * r0;\n d3 += h4 * (5 * r9);\n c = (d3 >>> 13); d3 &= 0x1fff;\n d3 += h5 * (5 * r8);\n d3 += h6 * (5 * r7);\n d3 += h7 * (5 * r6);\n d3 += h8 * (5 * r5);\n d3 += h9 * (5 * r4);\n c += (d3 >>> 13); d3 &= 0x1fff;\n\n d4 = c;\n d4 += h0 * r4;\n d4 += h1 * r3;\n d4 += h2 * r2;\n d4 += h3 * r1;\n d4 += h4 * r0;\n c = (d4 >>> 13); d4 &= 0x1fff;\n d4 += h5 * (5 * r9);\n d4 += h6 * (5 * r8);\n d4 += h7 * (5 * r7);\n d4 += h8 * (5 * r6);\n d4 += h9 * (5 * r5);\n c += (d4 >>> 13); d4 &= 0x1fff;\n\n d5 = c;\n d5 += h0 * r5;\n d5 += h1 * r4;\n d5 += h2 * r3;\n d5 += h3 * r2;\n d5 += h4 * r1;\n c = (d5 >>> 13); d5 &= 0x1fff;\n d5 += h5 * r0;\n d5 += h6 * (5 * r9);\n d5 += h7 * (5 * r8);\n d5 += h8 * (5 * r7);\n d5 += h9 * (5 * r6);\n c += (d5 >>> 13); d5 &= 0x1fff;\n\n d6 = c;\n d6 += h0 * r6;\n d6 += h1 * r5;\n d6 += h2 * r4;\n d6 += h3 * r3;\n d6 += h4 * r2;\n c = (d6 >>> 13); d6 &= 0x1fff;\n d6 += h5 * r1;\n d6 += h6 * r0;\n d6 += h7 * (5 * r9);\n d6 += h8 * (5 * r8);\n d6 += h9 * (5 * r7);\n c += (d6 >>> 13); d6 &= 0x1fff;\n\n d7 = c;\n d7 += h0 * r7;\n d7 += h1 * r6;\n d7 += h2 * r5;\n d7 += h3 * r4;\n d7 += h4 * r3;\n c = (d7 >>> 13); d7 &= 0x1fff;\n d7 += h5 * r2;\n d7 += h6 * r1;\n d7 += h7 * r0;\n d7 += h8 * (5 * r9);\n d7 += h9 * (5 * r8);\n c += (d7 >>> 13); d7 &= 0x1fff;\n\n d8 = c;\n d8 += h0 * r8;\n d8 += h1 * r7;\n d8 += h2 * r6;\n d8 += h3 * r5;\n d8 += h4 * r4;\n c = (d8 >>> 13); d8 &= 0x1fff;\n d8 += h5 * r3;\n d8 += h6 * r2;\n d8 += h7 * r1;\n d8 += h8 * r0;\n d8 += h9 * (5 * r9);\n c += (d8 >>> 13); d8 &= 0x1fff;\n\n d9 = c;\n d9 += h0 * r9;\n d9 += h1 * r8;\n d9 += h2 * r7;\n d9 += h3 * r6;\n d9 += h4 * r5;\n c = (d9 >>> 13); d9 &= 0x1fff;\n d9 += h5 * r4;\n d9 += h6 * r3;\n d9 += h7 * r2;\n d9 += h8 * r1;\n d9 += h9 * r0;\n c += (d9 >>> 13); d9 &= 0x1fff;\n\n c = (((c << 2) + c)) | 0;\n c = (c + d0) | 0;\n d0 = c & 0x1fff;\n c = (c >>> 13);\n d1 += c;\n\n h0 = d0;\n h1 = d1;\n h2 = d2;\n h3 = d3;\n h4 = d4;\n h5 = d5;\n h6 = d6;\n h7 = d7;\n h8 = d8;\n h9 = d9;\n\n mpos += 16;\n bytes -= 16;\n }\n this.h[0] = h0;\n this.h[1] = h1;\n this.h[2] = h2;\n this.h[3] = h3;\n this.h[4] = h4;\n this.h[5] = h5;\n this.h[6] = h6;\n this.h[7] = h7;\n this.h[8] = h8;\n this.h[9] = h9;\n};\n\npoly1305.prototype.finish = function(mac, macpos) {\n var g = new Uint16Array(10);\n var c, mask, f, i;\n\n if (this.leftover) {\n i = this.leftover;\n this.buffer[i++] = 1;\n for (; i < 16; i++) this.buffer[i] = 0;\n this.fin = 1;\n this.blocks(this.buffer, 0, 16);\n }\n\n c = this.h[1] >>> 13;\n this.h[1] &= 0x1fff;\n for (i = 2; i < 10; i++) {\n this.h[i] += c;\n c = this.h[i] >>> 13;\n this.h[i] &= 0x1fff;\n }\n this.h[0] += (c * 5);\n c = this.h[0] >>> 13;\n this.h[0] &= 0x1fff;\n this.h[1] += c;\n c = this.h[1] >>> 13;\n this.h[1] &= 0x1fff;\n this.h[2] += c;\n\n g[0] = this.h[0] + 5;\n c = g[0] >>> 13;\n g[0] &= 0x1fff;\n for (i = 1; i < 10; i++) {\n g[i] = this.h[i] + c;\n c = g[i] >>> 13;\n g[i] &= 0x1fff;\n }\n g[9] -= (1 << 13);\n\n mask = (c ^ 1) - 1;\n for (i = 0; i < 10; i++) g[i] &= mask;\n mask = ~mask;\n for (i = 0; i < 10; i++) this.h[i] = (this.h[i] & mask) | g[i];\n\n this.h[0] = ((this.h[0] ) | (this.h[1] << 13) ) & 0xffff;\n this.h[1] = ((this.h[1] >>> 3) | (this.h[2] << 10) ) & 0xffff;\n this.h[2] = ((this.h[2] >>> 6) | (this.h[3] << 7) ) & 0xffff;\n this.h[3] = ((this.h[3] >>> 9) | (this.h[4] << 4) ) & 0xffff;\n this.h[4] = ((this.h[4] >>> 12) | (this.h[5] << 1) | (this.h[6] << 14)) & 0xffff;\n this.h[5] = ((this.h[6] >>> 2) | (this.h[7] << 11) ) & 0xffff;\n this.h[6] = ((this.h[7] >>> 5) | (this.h[8] << 8) ) & 0xffff;\n this.h[7] = ((this.h[8] >>> 8) | (this.h[9] << 5) ) & 0xffff;\n\n f = this.h[0] + this.pad[0];\n this.h[0] = f & 0xffff;\n for (i = 1; i < 8; i++) {\n f = (((this.h[i] + this.pad[i]) | 0) + (f >>> 16)) | 0;\n this.h[i] = f & 0xffff;\n }\n\n mac[macpos+ 0] = (this.h[0] >>> 0) & 0xff;\n mac[macpos+ 1] = (this.h[0] >>> 8) & 0xff;\n mac[macpos+ 2] = (this.h[1] >>> 0) & 0xff;\n mac[macpos+ 3] = (this.h[1] >>> 8) & 0xff;\n mac[macpos+ 4] = (this.h[2] >>> 0) & 0xff;\n mac[macpos+ 5] = (this.h[2] >>> 8) & 0xff;\n mac[macpos+ 6] = (this.h[3] >>> 0) & 0xff;\n mac[macpos+ 7] = (this.h[3] >>> 8) & 0xff;\n mac[macpos+ 8] = (this.h[4] >>> 0) & 0xff;\n mac[macpos+ 9] = (this.h[4] >>> 8) & 0xff;\n mac[macpos+10] = (this.h[5] >>> 0) & 0xff;\n mac[macpos+11] = (this.h[5] >>> 8) & 0xff;\n mac[macpos+12] = (this.h[6] >>> 0) & 0xff;\n mac[macpos+13] = (this.h[6] >>> 8) & 0xff;\n mac[macpos+14] = (this.h[7] >>> 0) & 0xff;\n mac[macpos+15] = (this.h[7] >>> 8) & 0xff;\n};\n\npoly1305.prototype.update = function(m, mpos, bytes) {\n var i, want;\n\n if (this.leftover) {\n want = (16 - this.leftover);\n if (want > bytes)\n want = bytes;\n for (i = 0; i < want; i++)\n this.buffer[this.leftover + i] = m[mpos+i];\n bytes -= want;\n mpos += want;\n this.leftover += want;\n if (this.leftover < 16)\n return;\n this.blocks(this.buffer, 0, 16);\n this.leftover = 0;\n }\n\n if (bytes >= 16) {\n want = bytes - (bytes % 16);\n this.blocks(m, mpos, want);\n mpos += want;\n bytes -= want;\n }\n\n if (bytes) {\n for (i = 0; i < bytes; i++)\n this.buffer[this.leftover + i] = m[mpos+i];\n this.leftover += bytes;\n }\n};\n\nfunction crypto_onetimeauth(out, outpos, m, mpos, n, k) {\n var s = new poly1305(k);\n s.update(m, mpos, n);\n s.finish(out, outpos);\n return 0;\n}\n\nfunction crypto_onetimeauth_verify(h, hpos, m, mpos, n, k) {\n var x = new Uint8Array(16);\n crypto_onetimeauth(x,0,m,mpos,n,k);\n return crypto_verify_16(h,hpos,x,0);\n}\n\nfunction crypto_secretbox(c,m,d,n,k) {\n var i;\n if (d < 32) return -1;\n crypto_stream_xor(c,0,m,0,d,n,k);\n crypto_onetimeauth(c, 16, c, 32, d - 32, c);\n for (i = 0; i < 16; i++) c[i] = 0;\n return 0;\n}\n\nfunction crypto_secretbox_open(m,c,d,n,k) {\n var i;\n var x = new Uint8Array(32);\n if (d < 32) return -1;\n crypto_stream(x,0,32,n,k);\n if (crypto_onetimeauth_verify(c, 16,c, 32,d - 32,x) !== 0) return -1;\n crypto_stream_xor(m,0,c,0,d,n,k);\n for (i = 0; i < 32; i++) m[i] = 0;\n return 0;\n}\n\nfunction set25519(r, a) {\n var i;\n for (i = 0; i < 16; i++) r[i] = a[i]|0;\n}\n\nfunction car25519(o) {\n var i, v, c = 1;\n for (i = 0; i < 16; i++) {\n v = o[i] + c + 65535;\n c = Math.floor(v / 65536);\n o[i] = v - c * 65536;\n }\n o[0] += c-1 + 37 * (c-1);\n}\n\nfunction sel25519(p, q, b) {\n var t, c = ~(b-1);\n for (var i = 0; i < 16; i++) {\n t = c & (p[i] ^ q[i]);\n p[i] ^= t;\n q[i] ^= t;\n }\n}\n\nfunction pack25519(o, n) {\n var i, j, b;\n var m = gf(), t = gf();\n for (i = 0; i < 16; i++) t[i] = n[i];\n car25519(t);\n car25519(t);\n car25519(t);\n for (j = 0; j < 2; j++) {\n m[0] = t[0] - 0xffed;\n for (i = 1; i < 15; i++) {\n m[i] = t[i] - 0xffff - ((m[i-1]>>16) & 1);\n m[i-1] &= 0xffff;\n }\n m[15] = t[15] - 0x7fff - ((m[14]>>16) & 1);\n b = (m[15]>>16) & 1;\n m[14] &= 0xffff;\n sel25519(t, m, 1-b);\n }\n for (i = 0; i < 16; i++) {\n o[2*i] = t[i] & 0xff;\n o[2*i+1] = t[i]>>8;\n }\n}\n\nfunction neq25519(a, b) {\n var c = new Uint8Array(32), d = new Uint8Array(32);\n pack25519(c, a);\n pack25519(d, b);\n return crypto_verify_32(c, 0, d, 0);\n}\n\nfunction par25519(a) {\n var d = new Uint8Array(32);\n pack25519(d, a);\n return d[0] & 1;\n}\n\nfunction unpack25519(o, n) {\n var i;\n for (i = 0; i < 16; i++) o[i] = n[2*i] + (n[2*i+1] << 8);\n o[15] &= 0x7fff;\n}\n\nfunction A(o, a, b) {\n for (var i = 0; i < 16; i++) o[i] = a[i] + b[i];\n}\n\nfunction Z(o, a, b) {\n for (var i = 0; i < 16; i++) o[i] = a[i] - b[i];\n}\n\nfunction M(o, a, b) {\n var v, c,\n t0 = 0, t1 = 0, t2 = 0, t3 = 0, t4 = 0, t5 = 0, t6 = 0, t7 = 0,\n t8 = 0, t9 = 0, t10 = 0, t11 = 0, t12 = 0, t13 = 0, t14 = 0, t15 = 0,\n t16 = 0, t17 = 0, t18 = 0, t19 = 0, t20 = 0, t21 = 0, t22 = 0, t23 = 0,\n t24 = 0, t25 = 0, t26 = 0, t27 = 0, t28 = 0, t29 = 0, t30 = 0,\n b0 = b[0],\n b1 = b[1],\n b2 = b[2],\n b3 = b[3],\n b4 = b[4],\n b5 = b[5],\n b6 = b[6],\n b7 = b[7],\n b8 = b[8],\n b9 = b[9],\n b10 = b[10],\n b11 = b[11],\n b12 = b[12],\n b13 = b[13],\n b14 = b[14],\n b15 = b[15];\n\n v = a[0];\n t0 += v * b0;\n t1 += v * b1;\n t2 += v * b2;\n t3 += v * b3;\n t4 += v * b4;\n t5 += v * b5;\n t6 += v * b6;\n t7 += v * b7;\n t8 += v * b8;\n t9 += v * b9;\n t10 += v * b10;\n t11 += v * b11;\n t12 += v * b12;\n t13 += v * b13;\n t14 += v * b14;\n t15 += v * b15;\n v = a[1];\n t1 += v * b0;\n t2 += v * b1;\n t3 += v * b2;\n t4 += v * b3;\n t5 += v * b4;\n t6 += v * b5;\n t7 += v * b6;\n t8 += v * b7;\n t9 += v * b8;\n t10 += v * b9;\n t11 += v * b10;\n t12 += v * b11;\n t13 += v * b12;\n t14 += v * b13;\n t15 += v * b14;\n t16 += v * b15;\n v = a[2];\n t2 += v * b0;\n t3 += v * b1;\n t4 += v * b2;\n t5 += v * b3;\n t6 += v * b4;\n t7 += v * b5;\n t8 += v * b6;\n t9 += v * b7;\n t10 += v * b8;\n t11 += v * b9;\n t12 += v * b10;\n t13 += v * b11;\n t14 += v * b12;\n t15 += v * b13;\n t16 += v * b14;\n t17 += v * b15;\n v = a[3];\n t3 += v * b0;\n t4 += v * b1;\n t5 += v * b2;\n t6 += v * b3;\n t7 += v * b4;\n t8 += v * b5;\n t9 += v * b6;\n t10 += v * b7;\n t11 += v * b8;\n t12 += v * b9;\n t13 += v * b10;\n t14 += v * b11;\n t15 += v * b12;\n t16 += v * b13;\n t17 += v * b14;\n t18 += v * b15;\n v = a[4];\n t4 += v * b0;\n t5 += v * b1;\n t6 += v * b2;\n t7 += v * b3;\n t8 += v * b4;\n t9 += v * b5;\n t10 += v * b6;\n t11 += v * b7;\n t12 += v * b8;\n t13 += v * b9;\n t14 += v * b10;\n t15 += v * b11;\n t16 += v * b12;\n t17 += v * b13;\n t18 += v * b14;\n t19 += v * b15;\n v = a[5];\n t5 += v * b0;\n t6 += v * b1;\n t7 += v * b2;\n t8 += v * b3;\n t9 += v * b4;\n t10 += v * b5;\n t11 += v * b6;\n t12 += v * b7;\n t13 += v * b8;\n t14 += v * b9;\n t15 += v * b10;\n t16 += v * b11;\n t17 += v * b12;\n t18 += v * b13;\n t19 += v * b14;\n t20 += v * b15;\n v = a[6];\n t6 += v * b0;\n t7 += v * b1;\n t8 += v * b2;\n t9 += v * b3;\n t10 += v * b4;\n t11 += v * b5;\n t12 += v * b6;\n t13 += v * b7;\n t14 += v * b8;\n t15 += v * b9;\n t16 += v * b10;\n t17 += v * b11;\n t18 += v * b12;\n t19 += v * b13;\n t20 += v * b14;\n t21 += v * b15;\n v = a[7];\n t7 += v * b0;\n t8 += v * b1;\n t9 += v * b2;\n t10 += v * b3;\n t11 += v * b4;\n t12 += v * b5;\n t13 += v * b6;\n t14 += v * b7;\n t15 += v * b8;\n t16 += v * b9;\n t17 += v * b10;\n t18 += v * b11;\n t19 += v * b12;\n t20 += v * b13;\n t21 += v * b14;\n t22 += v * b15;\n v = a[8];\n t8 += v * b0;\n t9 += v * b1;\n t10 += v * b2;\n t11 += v * b3;\n t12 += v * b4;\n t13 += v * b5;\n t14 += v * b6;\n t15 += v * b7;\n t16 += v * b8;\n t17 += v * b9;\n t18 += v * b10;\n t19 += v * b11;\n t20 += v * b12;\n t21 += v * b13;\n t22 += v * b14;\n t23 += v * b15;\n v = a[9];\n t9 += v * b0;\n t10 += v * b1;\n t11 += v * b2;\n t12 += v * b3;\n t13 += v * b4;\n t14 += v * b5;\n t15 += v * b6;\n t16 += v * b7;\n t17 += v * b8;\n t18 += v * b9;\n t19 += v * b10;\n t20 += v * b11;\n t21 += v * b12;\n t22 += v * b13;\n t23 += v * b14;\n t24 += v * b15;\n v = a[10];\n t10 += v * b0;\n t11 += v * b1;\n t12 += v * b2;\n t13 += v * b3;\n t14 += v * b4;\n t15 += v * b5;\n t16 += v * b6;\n t17 += v * b7;\n t18 += v * b8;\n t19 += v * b9;\n t20 += v * b10;\n t21 += v * b11;\n t22 += v * b12;\n t23 += v * b13;\n t24 += v * b14;\n t25 += v * b15;\n v = a[11];\n t11 += v * b0;\n t12 += v * b1;\n t13 += v * b2;\n t14 += v * b3;\n t15 += v * b4;\n t16 += v * b5;\n t17 += v * b6;\n t18 += v * b7;\n t19 += v * b8;\n t20 += v * b9;\n t21 += v * b10;\n t22 += v * b11;\n t23 += v * b12;\n t24 += v * b13;\n t25 += v * b14;\n t26 += v * b15;\n v = a[12];\n t12 += v * b0;\n t13 += v * b1;\n t14 += v * b2;\n t15 += v * b3;\n t16 += v * b4;\n t17 += v * b5;\n t18 += v * b6;\n t19 += v * b7;\n t20 += v * b8;\n t21 += v * b9;\n t22 += v * b10;\n t23 += v * b11;\n t24 += v * b12;\n t25 += v * b13;\n t26 += v * b14;\n t27 += v * b15;\n v = a[13];\n t13 += v * b0;\n t14 += v * b1;\n t15 += v * b2;\n t16 += v * b3;\n t17 += v * b4;\n t18 += v * b5;\n t19 += v * b6;\n t20 += v * b7;\n t21 += v * b8;\n t22 += v * b9;\n t23 += v * b10;\n t24 += v * b11;\n t25 += v * b12;\n t26 += v * b13;\n t27 += v * b14;\n t28 += v * b15;\n v = a[14];\n t14 += v * b0;\n t15 += v * b1;\n t16 += v * b2;\n t17 += v * b3;\n t18 += v * b4;\n t19 += v * b5;\n t20 += v * b6;\n t21 += v * b7;\n t22 += v * b8;\n t23 += v * b9;\n t24 += v * b10;\n t25 += v * b11;\n t26 += v * b12;\n t27 += v * b13;\n t28 += v * b14;\n t29 += v * b15;\n v = a[15];\n t15 += v * b0;\n t16 += v * b1;\n t17 += v * b2;\n t18 += v * b3;\n t19 += v * b4;\n t20 += v * b5;\n t21 += v * b6;\n t22 += v * b7;\n t23 += v * b8;\n t24 += v * b9;\n t25 += v * b10;\n t26 += v * b11;\n t27 += v * b12;\n t28 += v * b13;\n t29 += v * b14;\n t30 += v * b15;\n\n t0 += 38 * t16;\n t1 += 38 * t17;\n t2 += 38 * t18;\n t3 += 38 * t19;\n t4 += 38 * t20;\n t5 += 38 * t21;\n t6 += 38 * t22;\n t7 += 38 * t23;\n t8 += 38 * t24;\n t9 += 38 * t25;\n t10 += 38 * t26;\n t11 += 38 * t27;\n t12 += 38 * t28;\n t13 += 38 * t29;\n t14 += 38 * t30;\n // t15 left as is\n\n // first car\n c = 1;\n v = t0 + c + 65535; c = Math.floor(v / 65536); t0 = v - c * 65536;\n v = t1 + c + 65535; c = Math.floor(v / 65536); t1 = v - c * 65536;\n v = t2 + c + 65535; c = Math.floor(v / 65536); t2 = v - c * 65536;\n v = t3 + c + 65535; c = Math.floor(v / 65536); t3 = v - c * 65536;\n v = t4 + c + 65535; c = Math.floor(v / 65536); t4 = v - c * 65536;\n v = t5 + c + 65535; c = Math.floor(v / 65536); t5 = v - c * 65536;\n v = t6 + c + 65535; c = Math.floor(v / 65536); t6 = v - c * 65536;\n v = t7 + c + 65535; c = Math.floor(v / 65536); t7 = v - c * 65536;\n v = t8 + c + 65535; c = Math.floor(v / 65536); t8 = v - c * 65536;\n v = t9 + c + 65535; c = Math.floor(v / 65536); t9 = v - c * 65536;\n v = t10 + c + 65535; c = Math.floor(v / 65536); t10 = v - c * 65536;\n v = t11 + c + 65535; c = Math.floor(v / 65536); t11 = v - c * 65536;\n v = t12 + c + 65535; c = Math.floor(v / 65536); t12 = v - c * 65536;\n v = t13 + c + 65535; c = Math.floor(v / 65536); t13 = v - c * 65536;\n v = t14 + c + 65535; c = Math.floor(v / 65536); t14 = v - c * 65536;\n v = t15 + c + 65535; c = Math.floor(v / 65536); t15 = v - c * 65536;\n t0 += c-1 + 37 * (c-1);\n\n // second car\n c = 1;\n v = t0 + c + 65535; c = Math.floor(v / 65536); t0 = v - c * 65536;\n v = t1 + c + 65535; c = Math.floor(v / 65536); t1 = v - c * 65536;\n v = t2 + c + 65535; c = Math.floor(v / 65536); t2 = v - c * 65536;\n v = t3 + c + 65535; c = Math.floor(v / 65536); t3 = v - c * 65536;\n v = t4 + c + 65535; c = Math.floor(v / 65536); t4 = v - c * 65536;\n v = t5 + c + 65535; c = Math.floor(v / 65536); t5 = v - c * 65536;\n v = t6 + c + 65535; c = Math.floor(v / 65536); t6 = v - c * 65536;\n v = t7 + c + 65535; c = Math.floor(v / 65536); t7 = v - c * 65536;\n v = t8 + c + 65535; c = Math.floor(v / 65536); t8 = v - c * 65536;\n v = t9 + c + 65535; c = Math.floor(v / 65536); t9 = v - c * 65536;\n v = t10 + c + 65535; c = Math.floor(v / 65536); t10 = v - c * 65536;\n v = t11 + c + 65535; c = Math.floor(v / 65536); t11 = v - c * 65536;\n v = t12 + c + 65535; c = Math.floor(v / 65536); t12 = v - c * 65536;\n v = t13 + c + 65535; c = Math.floor(v / 65536); t13 = v - c * 65536;\n v = t14 + c + 65535; c = Math.floor(v / 65536); t14 = v - c * 65536;\n v = t15 + c + 65535; c = Math.floor(v / 65536); t15 = v - c * 65536;\n t0 += c-1 + 37 * (c-1);\n\n o[ 0] = t0;\n o[ 1] = t1;\n o[ 2] = t2;\n o[ 3] = t3;\n o[ 4] = t4;\n o[ 5] = t5;\n o[ 6] = t6;\n o[ 7] = t7;\n o[ 8] = t8;\n o[ 9] = t9;\n o[10] = t10;\n o[11] = t11;\n o[12] = t12;\n o[13] = t13;\n o[14] = t14;\n o[15] = t15;\n}\n\nfunction S(o, a) {\n M(o, a, a);\n}\n\nfunction inv25519(o, i) {\n var c = gf();\n var a;\n for (a = 0; a < 16; a++) c[a] = i[a];\n for (a = 253; a >= 0; a--) {\n S(c, c);\n if(a !== 2 && a !== 4) M(c, c, i);\n }\n for (a = 0; a < 16; a++) o[a] = c[a];\n}\n\nfunction pow2523(o, i) {\n var c = gf();\n var a;\n for (a = 0; a < 16; a++) c[a] = i[a];\n for (a = 250; a >= 0; a--) {\n S(c, c);\n if(a !== 1) M(c, c, i);\n }\n for (a = 0; a < 16; a++) o[a] = c[a];\n}\n\nfunction crypto_scalarmult(q, n, p) {\n var z = new Uint8Array(32);\n var x = new Float64Array(80), r, i;\n var a = gf(), b = gf(), c = gf(),\n d = gf(), e = gf(), f = gf();\n for (i = 0; i < 31; i++) z[i] = n[i];\n z[31]=(n[31]&127)|64;\n z[0]&=248;\n unpack25519(x,p);\n for (i = 0; i < 16; i++) {\n b[i]=x[i];\n d[i]=a[i]=c[i]=0;\n }\n a[0]=d[0]=1;\n for (i=254; i>=0; --i) {\n r=(z[i>>>3]>>>(i&7))&1;\n sel25519(a,b,r);\n sel25519(c,d,r);\n A(e,a,c);\n Z(a,a,c);\n A(c,b,d);\n Z(b,b,d);\n S(d,e);\n S(f,a);\n M(a,c,a);\n M(c,b,e);\n A(e,a,c);\n Z(a,a,c);\n S(b,a);\n Z(c,d,f);\n M(a,c,_121665);\n A(a,a,d);\n M(c,c,a);\n M(a,d,f);\n M(d,b,x);\n S(b,e);\n sel25519(a,b,r);\n sel25519(c,d,r);\n }\n for (i = 0; i < 16; i++) {\n x[i+16]=a[i];\n x[i+32]=c[i];\n x[i+48]=b[i];\n x[i+64]=d[i];\n }\n var x32 = x.subarray(32);\n var x16 = x.subarray(16);\n inv25519(x32,x32);\n M(x16,x16,x32);\n pack25519(q,x16);\n return 0;\n}\n\nfunction crypto_scalarmult_base(q, n) {\n return crypto_scalarmult(q, n, _9);\n}\n\nfunction crypto_box_keypair(y, x) {\n randombytes(x, 32);\n return crypto_scalarmult_base(y, x);\n}\n\nfunction crypto_box_beforenm(k, y, x) {\n var s = new Uint8Array(32);\n crypto_scalarmult(s, x, y);\n return crypto_core_hsalsa20(k, _0, s, sigma);\n}\n\nvar crypto_box_afternm = crypto_secretbox;\nvar crypto_box_open_afternm = crypto_secretbox_open;\n\nfunction crypto_box(c, m, d, n, y, x) {\n var k = new Uint8Array(32);\n crypto_box_beforenm(k, y, x);\n return crypto_box_afternm(c, m, d, n, k);\n}\n\nfunction crypto_box_open(m, c, d, n, y, x) {\n var k = new Uint8Array(32);\n crypto_box_beforenm(k, y, x);\n return crypto_box_open_afternm(m, c, d, n, k);\n}\n\nvar K = [\n 0x428a2f98, 0xd728ae22, 0x71374491, 0x23ef65cd,\n 0xb5c0fbcf, 0xec4d3b2f, 0xe9b5dba5, 0x8189dbbc,\n 0x3956c25b, 0xf348b538, 0x59f111f1, 0xb605d019,\n 0x923f82a4, 0xaf194f9b, 0xab1c5ed5, 0xda6d8118,\n 0xd807aa98, 0xa3030242, 0x12835b01, 0x45706fbe,\n 0x243185be, 0x4ee4b28c, 0x550c7dc3, 0xd5ffb4e2,\n 0x72be5d74, 0xf27b896f, 0x80deb1fe, 0x3b1696b1,\n 0x9bdc06a7, 0x25c71235, 0xc19bf174, 0xcf692694,\n 0xe49b69c1, 0x9ef14ad2, 0xefbe4786, 0x384f25e3,\n 0x0fc19dc6, 0x8b8cd5b5, 0x240ca1cc, 0x77ac9c65,\n 0x2de92c6f, 0x592b0275, 0x4a7484aa, 0x6ea6e483,\n 0x5cb0a9dc, 0xbd41fbd4, 0x76f988da, 0x831153b5,\n 0x983e5152, 0xee66dfab, 0xa831c66d, 0x2db43210,\n 0xb00327c8, 0x98fb213f, 0xbf597fc7, 0xbeef0ee4,\n 0xc6e00bf3, 0x3da88fc2, 0xd5a79147, 0x930aa725,\n 0x06ca6351, 0xe003826f, 0x14292967, 0x0a0e6e70,\n 0x27b70a85, 0x46d22ffc, 0x2e1b2138, 0x5c26c926,\n 0x4d2c6dfc, 0x5ac42aed, 0x53380d13, 0x9d95b3df,\n 0x650a7354, 0x8baf63de, 0x766a0abb, 0x3c77b2a8,\n 0x81c2c92e, 0x47edaee6, 0x92722c85, 0x1482353b,\n 0xa2bfe8a1, 0x4cf10364, 0xa81a664b, 0xbc423001,\n 0xc24b8b70, 0xd0f89791, 0xc76c51a3, 0x0654be30,\n 0xd192e819, 0xd6ef5218, 0xd6990624, 0x5565a910,\n 0xf40e3585, 0x5771202a, 0x106aa070, 0x32bbd1b8,\n 0x19a4c116, 0xb8d2d0c8, 0x1e376c08, 0x5141ab53,\n 0x2748774c, 0xdf8eeb99, 0x34b0bcb5, 0xe19b48a8,\n 0x391c0cb3, 0xc5c95a63, 0x4ed8aa4a, 0xe3418acb,\n 0x5b9cca4f, 0x7763e373, 0x682e6ff3, 0xd6b2b8a3,\n 0x748f82ee, 0x5defb2fc, 0x78a5636f, 0x43172f60,\n 0x84c87814, 0xa1f0ab72, 0x8cc70208, 0x1a6439ec,\n 0x90befffa, 0x23631e28, 0xa4506ceb, 0xde82bde9,\n 0xbef9a3f7, 0xb2c67915, 0xc67178f2, 0xe372532b,\n 0xca273ece, 0xea26619c, 0xd186b8c7, 0x21c0c207,\n 0xeada7dd6, 0xcde0eb1e, 0xf57d4f7f, 0xee6ed178,\n 0x06f067aa, 0x72176fba, 0x0a637dc5, 0xa2c898a6,\n 0x113f9804, 0xbef90dae, 0x1b710b35, 0x131c471b,\n 0x28db77f5, 0x23047d84, 0x32caab7b, 0x40c72493,\n 0x3c9ebe0a, 0x15c9bebc, 0x431d67c4, 0x9c100d4c,\n 0x4cc5d4be, 0xcb3e42b6, 0x597f299c, 0xfc657e2a,\n 0x5fcb6fab, 0x3ad6faec, 0x6c44198c, 0x4a475817\n];\n\nfunction crypto_hashblocks_hl(hh, hl, m, n) {\n var wh = new Int32Array(16), wl = new Int32Array(16),\n bh0, bh1, bh2, bh3, bh4, bh5, bh6, bh7,\n bl0, bl1, bl2, bl3, bl4, bl5, bl6, bl7,\n th, tl, i, j, h, l, a, b, c, d;\n\n var ah0 = hh[0],\n ah1 = hh[1],\n ah2 = hh[2],\n ah3 = hh[3],\n ah4 = hh[4],\n ah5 = hh[5],\n ah6 = hh[6],\n ah7 = hh[7],\n\n al0 = hl[0],\n al1 = hl[1],\n al2 = hl[2],\n al3 = hl[3],\n al4 = hl[4],\n al5 = hl[5],\n al6 = hl[6],\n al7 = hl[7];\n\n var pos = 0;\n while (n >= 128) {\n for (i = 0; i < 16; i++) {\n j = 8 * i + pos;\n wh[i] = (m[j+0] << 24) | (m[j+1] << 16) | (m[j+2] << 8) | m[j+3];\n wl[i] = (m[j+4] << 24) | (m[j+5] << 16) | (m[j+6] << 8) | m[j+7];\n }\n for (i = 0; i < 80; i++) {\n bh0 = ah0;\n bh1 = ah1;\n bh2 = ah2;\n bh3 = ah3;\n bh4 = ah4;\n bh5 = ah5;\n bh6 = ah6;\n bh7 = ah7;\n\n bl0 = al0;\n bl1 = al1;\n bl2 = al2;\n bl3 = al3;\n bl4 = al4;\n bl5 = al5;\n bl6 = al6;\n bl7 = al7;\n\n // add\n h = ah7;\n l = al7;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n // Sigma1\n h = ((ah4 >>> 14) | (al4 << (32-14))) ^ ((ah4 >>> 18) | (al4 << (32-18))) ^ ((al4 >>> (41-32)) | (ah4 << (32-(41-32))));\n l = ((al4 >>> 14) | (ah4 << (32-14))) ^ ((al4 >>> 18) | (ah4 << (32-18))) ^ ((ah4 >>> (41-32)) | (al4 << (32-(41-32))));\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // Ch\n h = (ah4 & ah5) ^ (~ah4 & ah6);\n l = (al4 & al5) ^ (~al4 & al6);\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // K\n h = K[i*2];\n l = K[i*2+1];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // w\n h = wh[i%16];\n l = wl[i%16];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n th = c & 0xffff | d << 16;\n tl = a & 0xffff | b << 16;\n\n // add\n h = th;\n l = tl;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n // Sigma0\n h = ((ah0 >>> 28) | (al0 << (32-28))) ^ ((al0 >>> (34-32)) | (ah0 << (32-(34-32)))) ^ ((al0 >>> (39-32)) | (ah0 << (32-(39-32))));\n l = ((al0 >>> 28) | (ah0 << (32-28))) ^ ((ah0 >>> (34-32)) | (al0 << (32-(34-32)))) ^ ((ah0 >>> (39-32)) | (al0 << (32-(39-32))));\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // Maj\n h = (ah0 & ah1) ^ (ah0 & ah2) ^ (ah1 & ah2);\n l = (al0 & al1) ^ (al0 & al2) ^ (al1 & al2);\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n bh7 = (c & 0xffff) | (d << 16);\n bl7 = (a & 0xffff) | (b << 16);\n\n // add\n h = bh3;\n l = bl3;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = th;\n l = tl;\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n bh3 = (c & 0xffff) | (d << 16);\n bl3 = (a & 0xffff) | (b << 16);\n\n ah1 = bh0;\n ah2 = bh1;\n ah3 = bh2;\n ah4 = bh3;\n ah5 = bh4;\n ah6 = bh5;\n ah7 = bh6;\n ah0 = bh7;\n\n al1 = bl0;\n al2 = bl1;\n al3 = bl2;\n al4 = bl3;\n al5 = bl4;\n al6 = bl5;\n al7 = bl6;\n al0 = bl7;\n\n if (i%16 === 15) {\n for (j = 0; j < 16; j++) {\n // add\n h = wh[j];\n l = wl[j];\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = wh[(j+9)%16];\n l = wl[(j+9)%16];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // sigma0\n th = wh[(j+1)%16];\n tl = wl[(j+1)%16];\n h = ((th >>> 1) | (tl << (32-1))) ^ ((th >>> 8) | (tl << (32-8))) ^ (th >>> 7);\n l = ((tl >>> 1) | (th << (32-1))) ^ ((tl >>> 8) | (th << (32-8))) ^ ((tl >>> 7) | (th << (32-7)));\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // sigma1\n th = wh[(j+14)%16];\n tl = wl[(j+14)%16];\n h = ((th >>> 19) | (tl << (32-19))) ^ ((tl >>> (61-32)) | (th << (32-(61-32)))) ^ (th >>> 6);\n l = ((tl >>> 19) | (th << (32-19))) ^ ((th >>> (61-32)) | (tl << (32-(61-32)))) ^ ((tl >>> 6) | (th << (32-6)));\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n wh[j] = (c & 0xffff) | (d << 16);\n wl[j] = (a & 0xffff) | (b << 16);\n }\n }\n }\n\n // add\n h = ah0;\n l = al0;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[0];\n l = hl[0];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[0] = ah0 = (c & 0xffff) | (d << 16);\n hl[0] = al0 = (a & 0xffff) | (b << 16);\n\n h = ah1;\n l = al1;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[1];\n l = hl[1];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[1] = ah1 = (c & 0xffff) | (d << 16);\n hl[1] = al1 = (a & 0xffff) | (b << 16);\n\n h = ah2;\n l = al2;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[2];\n l = hl[2];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[2] = ah2 = (c & 0xffff) | (d << 16);\n hl[2] = al2 = (a & 0xffff) | (b << 16);\n\n h = ah3;\n l = al3;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[3];\n l = hl[3];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[3] = ah3 = (c & 0xffff) | (d << 16);\n hl[3] = al3 = (a & 0xffff) | (b << 16);\n\n h = ah4;\n l = al4;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[4];\n l = hl[4];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[4] = ah4 = (c & 0xffff) | (d << 16);\n hl[4] = al4 = (a & 0xffff) | (b << 16);\n\n h = ah5;\n l = al5;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[5];\n l = hl[5];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[5] = ah5 = (c & 0xffff) | (d << 16);\n hl[5] = al5 = (a & 0xffff) | (b << 16);\n\n h = ah6;\n l = al6;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[6];\n l = hl[6];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[6] = ah6 = (c & 0xffff) | (d << 16);\n hl[6] = al6 = (a & 0xffff) | (b << 16);\n\n h = ah7;\n l = al7;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[7];\n l = hl[7];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[7] = ah7 = (c & 0xffff) | (d << 16);\n hl[7] = al7 = (a & 0xffff) | (b << 16);\n\n pos += 128;\n n -= 128;\n }\n\n return n;\n}\n\nfunction crypto_hash(out, m, n) {\n var hh = new Int32Array(8),\n hl = new Int32Array(8),\n x = new Uint8Array(256),\n i, b = n;\n\n hh[0] = 0x6a09e667;\n hh[1] = 0xbb67ae85;\n hh[2] = 0x3c6ef372;\n hh[3] = 0xa54ff53a;\n hh[4] = 0x510e527f;\n hh[5] = 0x9b05688c;\n hh[6] = 0x1f83d9ab;\n hh[7] = 0x5be0cd19;\n\n hl[0] = 0xf3bcc908;\n hl[1] = 0x84caa73b;\n hl[2] = 0xfe94f82b;\n hl[3] = 0x5f1d36f1;\n hl[4] = 0xade682d1;\n hl[5] = 0x2b3e6c1f;\n hl[6] = 0xfb41bd6b;\n hl[7] = 0x137e2179;\n\n crypto_hashblocks_hl(hh, hl, m, n);\n n %= 128;\n\n for (i = 0; i < n; i++) x[i] = m[b-n+i];\n x[n] = 128;\n\n n = 256-128*(n<112?1:0);\n x[n-9] = 0;\n ts64(x, n-8, (b / 0x20000000) | 0, b << 3);\n crypto_hashblocks_hl(hh, hl, x, n);\n\n for (i = 0; i < 8; i++) ts64(out, 8*i, hh[i], hl[i]);\n\n return 0;\n}\n\nfunction add(p, q) {\n var a = gf(), b = gf(), c = gf(),\n d = gf(), e = gf(), f = gf(),\n g = gf(), h = gf(), t = gf();\n\n Z(a, p[1], p[0]);\n Z(t, q[1], q[0]);\n M(a, a, t);\n A(b, p[0], p[1]);\n A(t, q[0], q[1]);\n M(b, b, t);\n M(c, p[3], q[3]);\n M(c, c, D2);\n M(d, p[2], q[2]);\n A(d, d, d);\n Z(e, b, a);\n Z(f, d, c);\n A(g, d, c);\n A(h, b, a);\n\n M(p[0], e, f);\n M(p[1], h, g);\n M(p[2], g, f);\n M(p[3], e, h);\n}\n\nfunction cswap(p, q, b) {\n var i;\n for (i = 0; i < 4; i++) {\n sel25519(p[i], q[i], b);\n }\n}\n\nfunction pack(r, p) {\n var tx = gf(), ty = gf(), zi = gf();\n inv25519(zi, p[2]);\n M(tx, p[0], zi);\n M(ty, p[1], zi);\n pack25519(r, ty);\n r[31] ^= par25519(tx) << 7;\n}\n\nfunction scalarmult(p, q, s) {\n var b, i;\n set25519(p[0], gf0);\n set25519(p[1], gf1);\n set25519(p[2], gf1);\n set25519(p[3], gf0);\n for (i = 255; i >= 0; --i) {\n b = (s[(i/8)|0] >> (i&7)) & 1;\n cswap(p, q, b);\n add(q, p);\n add(p, p);\n cswap(p, q, b);\n }\n}\n\nfunction scalarbase(p, s) {\n var q = [gf(), gf(), gf(), gf()];\n set25519(q[0], X);\n set25519(q[1], Y);\n set25519(q[2], gf1);\n M(q[3], X, Y);\n scalarmult(p, q, s);\n}\n\nfunction crypto_sign_keypair(pk, sk, seeded) {\n var d = new Uint8Array(64);\n var p = [gf(), gf(), gf(), gf()];\n var i;\n\n if (!seeded) randombytes(sk, 32);\n crypto_hash(d, sk, 32);\n d[0] &= 248;\n d[31] &= 127;\n d[31] |= 64;\n\n scalarbase(p, d);\n pack(pk, p);\n\n for (i = 0; i < 32; i++) sk[i+32] = pk[i];\n return 0;\n}\n\nvar L = new Float64Array([0xed, 0xd3, 0xf5, 0x5c, 0x1a, 0x63, 0x12, 0x58, 0xd6, 0x9c, 0xf7, 0xa2, 0xde, 0xf9, 0xde, 0x14, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x10]);\n\nfunction modL(r, x) {\n var carry, i, j, k;\n for (i = 63; i >= 32; --i) {\n carry = 0;\n for (j = i - 32, k = i - 12; j < k; ++j) {\n x[j] += carry - 16 * x[i] * L[j - (i - 32)];\n carry = Math.floor((x[j] + 128) / 256);\n x[j] -= carry * 256;\n }\n x[j] += carry;\n x[i] = 0;\n }\n carry = 0;\n for (j = 0; j < 32; j++) {\n x[j] += carry - (x[31] >> 4) * L[j];\n carry = x[j] >> 8;\n x[j] &= 255;\n }\n for (j = 0; j < 32; j++) x[j] -= carry * L[j];\n for (i = 0; i < 32; i++) {\n x[i+1] += x[i] >> 8;\n r[i] = x[i] & 255;\n }\n}\n\nfunction reduce(r) {\n var x = new Float64Array(64), i;\n for (i = 0; i < 64; i++) x[i] = r[i];\n for (i = 0; i < 64; i++) r[i] = 0;\n modL(r, x);\n}\n\n// Note: difference from C - smlen returned, not passed as argument.\nfunction crypto_sign(sm, m, n, sk) {\n var d = new Uint8Array(64), h = new Uint8Array(64), r = new Uint8Array(64);\n var i, j, x = new Float64Array(64);\n var p = [gf(), gf(), gf(), gf()];\n\n crypto_hash(d, sk, 32);\n d[0] &= 248;\n d[31] &= 127;\n d[31] |= 64;\n\n var smlen = n + 64;\n for (i = 0; i < n; i++) sm[64 + i] = m[i];\n for (i = 0; i < 32; i++) sm[32 + i] = d[32 + i];\n\n crypto_hash(r, sm.subarray(32), n+32);\n reduce(r);\n scalarbase(p, r);\n pack(sm, p);\n\n for (i = 32; i < 64; i++) sm[i] = sk[i];\n crypto_hash(h, sm, n + 64);\n reduce(h);\n\n for (i = 0; i < 64; i++) x[i] = 0;\n for (i = 0; i < 32; i++) x[i] = r[i];\n for (i = 0; i < 32; i++) {\n for (j = 0; j < 32; j++) {\n x[i+j] += h[i] * d[j];\n }\n }\n\n modL(sm.subarray(32), x);\n return smlen;\n}\n\nfunction unpackneg(r, p) {\n var t = gf(), chk = gf(), num = gf(),\n den = gf(), den2 = gf(), den4 = gf(),\n den6 = gf();\n\n set25519(r[2], gf1);\n unpack25519(r[1], p);\n S(num, r[1]);\n M(den, num, D);\n Z(num, num, r[2]);\n A(den, r[2], den);\n\n S(den2, den);\n S(den4, den2);\n M(den6, den4, den2);\n M(t, den6, num);\n M(t, t, den);\n\n pow2523(t, t);\n M(t, t, num);\n M(t, t, den);\n M(t, t, den);\n M(r[0], t, den);\n\n S(chk, r[0]);\n M(chk, chk, den);\n if (neq25519(chk, num)) M(r[0], r[0], I);\n\n S(chk, r[0]);\n M(chk, chk, den);\n if (neq25519(chk, num)) return -1;\n\n if (par25519(r[0]) === (p[31]>>7)) Z(r[0], gf0, r[0]);\n\n M(r[3], r[0], r[1]);\n return 0;\n}\n\nfunction crypto_sign_open(m, sm, n, pk) {\n var i;\n var t = new Uint8Array(32), h = new Uint8Array(64);\n var p = [gf(), gf(), gf(), gf()],\n q = [gf(), gf(), gf(), gf()];\n\n if (n < 64) return -1;\n\n if (unpackneg(q, pk)) return -1;\n\n for (i = 0; i < n; i++) m[i] = sm[i];\n for (i = 0; i < 32; i++) m[i+32] = pk[i];\n crypto_hash(h, m, n);\n reduce(h);\n scalarmult(p, q, h);\n\n scalarbase(q, sm.subarray(32));\n add(p, q);\n pack(t, p);\n\n n -= 64;\n if (crypto_verify_32(sm, 0, t, 0)) {\n for (i = 0; i < n; i++) m[i] = 0;\n return -1;\n }\n\n for (i = 0; i < n; i++) m[i] = sm[i + 64];\n return n;\n}\n\nvar crypto_secretbox_KEYBYTES = 32,\n crypto_secretbox_NONCEBYTES = 24,\n crypto_secretbox_ZEROBYTES = 32,\n crypto_secretbox_BOXZEROBYTES = 16,\n crypto_scalarmult_BYTES = 32,\n crypto_scalarmult_SCALARBYTES = 32,\n crypto_box_PUBLICKEYBYTES = 32,\n crypto_box_SECRETKEYBYTES = 32,\n crypto_box_BEFORENMBYTES = 32,\n crypto_box_NONCEBYTES = crypto_secretbox_NONCEBYTES,\n crypto_box_ZEROBYTES = crypto_secretbox_ZEROBYTES,\n crypto_box_BOXZEROBYTES = crypto_secretbox_BOXZEROBYTES,\n crypto_sign_BYTES = 64,\n crypto_sign_PUBLICKEYBYTES = 32,\n crypto_sign_SECRETKEYBYTES = 64,\n crypto_sign_SEEDBYTES = 32,\n crypto_hash_BYTES = 64;\n\nnacl.lowlevel = {\n crypto_core_hsalsa20: crypto_core_hsalsa20,\n crypto_stream_xor: crypto_stream_xor,\n crypto_stream: crypto_stream,\n crypto_stream_salsa20_xor: crypto_stream_salsa20_xor,\n crypto_stream_salsa20: crypto_stream_salsa20,\n crypto_onetimeauth: crypto_onetimeauth,\n crypto_onetimeauth_verify: crypto_onetimeauth_verify,\n crypto_verify_16: crypto_verify_16,\n crypto_verify_32: crypto_verify_32,\n crypto_secretbox: crypto_secretbox,\n crypto_secretbox_open: crypto_secretbox_open,\n crypto_scalarmult: crypto_scalarmult,\n crypto_scalarmult_base: crypto_scalarmult_base,\n crypto_box_beforenm: crypto_box_beforenm,\n crypto_box_afternm: crypto_box_afternm,\n crypto_box: crypto_box,\n crypto_box_open: crypto_box_open,\n crypto_box_keypair: crypto_box_keypair,\n crypto_hash: crypto_hash,\n crypto_sign: crypto_sign,\n crypto_sign_keypair: crypto_sign_keypair,\n crypto_sign_open: crypto_sign_open,\n\n crypto_secretbox_KEYBYTES: crypto_secretbox_KEYBYTES,\n crypto_secretbox_NONCEBYTES: crypto_secretbox_NONCEBYTES,\n crypto_secretbox_ZEROBYTES: crypto_secretbox_ZEROBYTES,\n crypto_secretbox_BOXZEROBYTES: crypto_secretbox_BOXZEROBYTES,\n crypto_scalarmult_BYTES: crypto_scalarmult_BYTES,\n crypto_scalarmult_SCALARBYTES: crypto_scalarmult_SCALARBYTES,\n crypto_box_PUBLICKEYBYTES: crypto_box_PUBLICKEYBYTES,\n crypto_box_SECRETKEYBYTES: crypto_box_SECRETKEYBYTES,\n crypto_box_BEFORENMBYTES: crypto_box_BEFORENMBYTES,\n crypto_box_NONCEBYTES: crypto_box_NONCEBYTES,\n crypto_box_ZEROBYTES: crypto_box_ZEROBYTES,\n crypto_box_BOXZEROBYTES: crypto_box_BOXZEROBYTES,\n crypto_sign_BYTES: crypto_sign_BYTES,\n crypto_sign_PUBLICKEYBYTES: crypto_sign_PUBLICKEYBYTES,\n crypto_sign_SECRETKEYBYTES: crypto_sign_SECRETKEYBYTES,\n crypto_sign_SEEDBYTES: crypto_sign_SEEDBYTES,\n crypto_hash_BYTES: crypto_hash_BYTES,\n\n gf: gf,\n D: D,\n L: L,\n pack25519: pack25519,\n unpack25519: unpack25519,\n M: M,\n A: A,\n S: S,\n Z: Z,\n pow2523: pow2523,\n add: add,\n set25519: set25519,\n modL: modL,\n scalarmult: scalarmult,\n scalarbase: scalarbase,\n};\n\n/* High-level API */\n\nfunction checkLengths(k, n) {\n if (k.length !== crypto_secretbox_KEYBYTES) throw new Error('bad key size');\n if (n.length !== crypto_secretbox_NONCEBYTES) throw new Error('bad nonce size');\n}\n\nfunction checkBoxLengths(pk, sk) {\n if (pk.length !== crypto_box_PUBLICKEYBYTES) throw new Error('bad public key size');\n if (sk.length !== crypto_box_SECRETKEYBYTES) throw new Error('bad secret key size');\n}\n\nfunction checkArrayTypes() {\n for (var i = 0; i < arguments.length; i++) {\n if (!(arguments[i] instanceof Uint8Array))\n throw new TypeError('unexpected type, use Uint8Array');\n }\n}\n\nfunction cleanup(arr) {\n for (var i = 0; i < arr.length; i++) arr[i] = 0;\n}\n\nnacl.randomBytes = function(n) {\n var b = new Uint8Array(n);\n randombytes(b, n);\n return b;\n};\n\nnacl.secretbox = function(msg, nonce, key) {\n checkArrayTypes(msg, nonce, key);\n checkLengths(key, nonce);\n var m = new Uint8Array(crypto_secretbox_ZEROBYTES + msg.length);\n var c = new Uint8Array(m.length);\n for (var i = 0; i < msg.length; i++) m[i+crypto_secretbox_ZEROBYTES] = msg[i];\n crypto_secretbox(c, m, m.length, nonce, key);\n return c.subarray(crypto_secretbox_BOXZEROBYTES);\n};\n\nnacl.secretbox.open = function(box, nonce, key) {\n checkArrayTypes(box, nonce, key);\n checkLengths(key, nonce);\n var c = new Uint8Array(crypto_secretbox_BOXZEROBYTES + box.length);\n var m = new Uint8Array(c.length);\n for (var i = 0; i < box.length; i++) c[i+crypto_secretbox_BOXZEROBYTES] = box[i];\n if (c.length < 32) return null;\n if (crypto_secretbox_open(m, c, c.length, nonce, key) !== 0) return null;\n return m.subarray(crypto_secretbox_ZEROBYTES);\n};\n\nnacl.secretbox.keyLength = crypto_secretbox_KEYBYTES;\nnacl.secretbox.nonceLength = crypto_secretbox_NONCEBYTES;\nnacl.secretbox.overheadLength = crypto_secretbox_BOXZEROBYTES;\n\nnacl.scalarMult = function(n, p) {\n checkArrayTypes(n, p);\n if (n.length !== crypto_scalarmult_SCALARBYTES) throw new Error('bad n size');\n if (p.length !== crypto_scalarmult_BYTES) throw new Error('bad p size');\n var q = new Uint8Array(crypto_scalarmult_BYTES);\n crypto_scalarmult(q, n, p);\n return q;\n};\n\nnacl.scalarMult.base = function(n) {\n checkArrayTypes(n);\n if (n.length !== crypto_scalarmult_SCALARBYTES) throw new Error('bad n size');\n var q = new Uint8Array(crypto_scalarmult_BYTES);\n crypto_scalarmult_base(q, n);\n return q;\n};\n\nnacl.scalarMult.scalarLength = crypto_scalarmult_SCALARBYTES;\nnacl.scalarMult.groupElementLength = crypto_scalarmult_BYTES;\n\nnacl.box = function(msg, nonce, publicKey, secretKey) {\n var k = nacl.box.before(publicKey, secretKey);\n return nacl.secretbox(msg, nonce, k);\n};\n\nnacl.box.before = function(publicKey, secretKey) {\n checkArrayTypes(publicKey, secretKey);\n checkBoxLengths(publicKey, secretKey);\n var k = new Uint8Array(crypto_box_BEFORENMBYTES);\n crypto_box_beforenm(k, publicKey, secretKey);\n return k;\n};\n\nnacl.box.after = nacl.secretbox;\n\nnacl.box.open = function(msg, nonce, publicKey, secretKey) {\n var k = nacl.box.before(publicKey, secretKey);\n return nacl.secretbox.open(msg, nonce, k);\n};\n\nnacl.box.open.after = nacl.secretbox.open;\n\nnacl.box.keyPair = function() {\n var pk = new Uint8Array(crypto_box_PUBLICKEYBYTES);\n var sk = new Uint8Array(crypto_box_SECRETKEYBYTES);\n crypto_box_keypair(pk, sk);\n return {publicKey: pk, secretKey: sk};\n};\n\nnacl.box.keyPair.fromSecretKey = function(secretKey) {\n checkArrayTypes(secretKey);\n if (secretKey.length !== crypto_box_SECRETKEYBYTES)\n throw new Error('bad secret key size');\n var pk = new Uint8Array(crypto_box_PUBLICKEYBYTES);\n crypto_scalarmult_base(pk, secretKey);\n return {publicKey: pk, secretKey: new Uint8Array(secretKey)};\n};\n\nnacl.box.publicKeyLength = crypto_box_PUBLICKEYBYTES;\nnacl.box.secretKeyLength = crypto_box_SECRETKEYBYTES;\nnacl.box.sharedKeyLength = crypto_box_BEFORENMBYTES;\nnacl.box.nonceLength = crypto_box_NONCEBYTES;\nnacl.box.overheadLength = nacl.secretbox.overheadLength;\n\nnacl.sign = function(msg, secretKey) {\n checkArrayTypes(msg, secretKey);\n if (secretKey.length !== crypto_sign_SECRETKEYBYTES)\n throw new Error('bad secret key size');\n var signedMsg = new Uint8Array(crypto_sign_BYTES+msg.length);\n crypto_sign(signedMsg, msg, msg.length, secretKey);\n return signedMsg;\n};\n\nnacl.sign.open = function(signedMsg, publicKey) {\n checkArrayTypes(signedMsg, publicKey);\n if (publicKey.length !== crypto_sign_PUBLICKEYBYTES)\n throw new Error('bad public key size');\n var tmp = new Uint8Array(signedMsg.length);\n var mlen = crypto_sign_open(tmp, signedMsg, signedMsg.length, publicKey);\n if (mlen < 0) return null;\n var m = new Uint8Array(mlen);\n for (var i = 0; i < m.length; i++) m[i] = tmp[i];\n return m;\n};\n\nnacl.sign.detached = function(msg, secretKey) {\n var signedMsg = nacl.sign(msg, secretKey);\n var sig = new Uint8Array(crypto_sign_BYTES);\n for (var i = 0; i < sig.length; i++) sig[i] = signedMsg[i];\n return sig;\n};\n\nnacl.sign.detached.verify = function(msg, sig, publicKey) {\n checkArrayTypes(msg, sig, publicKey);\n if (sig.length !== crypto_sign_BYTES)\n throw new Error('bad signature size');\n if (publicKey.length !== crypto_sign_PUBLICKEYBYTES)\n throw new Error('bad public key size');\n var sm = new Uint8Array(crypto_sign_BYTES + msg.length);\n var m = new Uint8Array(crypto_sign_BYTES + msg.length);\n var i;\n for (i = 0; i < crypto_sign_BYTES; i++) sm[i] = sig[i];\n for (i = 0; i < msg.length; i++) sm[i+crypto_sign_BYTES] = msg[i];\n return (crypto_sign_open(m, sm, sm.length, publicKey) >= 0);\n};\n\nnacl.sign.keyPair = function() {\n var pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);\n var sk = new Uint8Array(crypto_sign_SECRETKEYBYTES);\n crypto_sign_keypair(pk, sk);\n return {publicKey: pk, secretKey: sk};\n};\n\nnacl.sign.keyPair.fromSecretKey = function(secretKey) {\n checkArrayTypes(secretKey);\n if (secretKey.length !== crypto_sign_SECRETKEYBYTES)\n throw new Error('bad secret key size');\n var pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);\n for (var i = 0; i < pk.length; i++) pk[i] = secretKey[32+i];\n return {publicKey: pk, secretKey: new Uint8Array(secretKey)};\n};\n\nnacl.sign.keyPair.fromSeed = function(seed) {\n checkArrayTypes(seed);\n if (seed.length !== crypto_sign_SEEDBYTES)\n throw new Error('bad seed size');\n var pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);\n var sk = new Uint8Array(crypto_sign_SECRETKEYBYTES);\n for (var i = 0; i < 32; i++) sk[i] = seed[i];\n crypto_sign_keypair(pk, sk, true);\n return {publicKey: pk, secretKey: sk};\n};\n\nnacl.sign.publicKeyLength = crypto_sign_PUBLICKEYBYTES;\nnacl.sign.secretKeyLength = crypto_sign_SECRETKEYBYTES;\nnacl.sign.seedLength = crypto_sign_SEEDBYTES;\nnacl.sign.signatureLength = crypto_sign_BYTES;\n\nnacl.hash = function(msg) {\n checkArrayTypes(msg);\n var h = new Uint8Array(crypto_hash_BYTES);\n crypto_hash(h, msg, msg.length);\n return h;\n};\n\nnacl.hash.hashLength = crypto_hash_BYTES;\n\nnacl.verify = function(x, y) {\n checkArrayTypes(x, y);\n // Zero length arguments are considered not equal.\n if (x.length === 0 || y.length === 0) return false;\n if (x.length !== y.length) return false;\n return (vn(x, 0, y, 0, x.length) === 0) ? true : false;\n};\n\nnacl.setPRNG = function(fn) {\n randombytes = fn;\n};\n\n(function() {\n // Initialize PRNG if environment provides CSPRNG.\n // If not, methods calling randombytes will throw.\n var crypto = typeof self !== 'undefined' ? (self.crypto || self.msCrypto) : null;\n if (crypto && crypto.getRandomValues) {\n // Browsers.\n var QUOTA = 65536;\n nacl.setPRNG(function(x, n) {\n var i, v = new Uint8Array(n);\n for (i = 0; i < n; i += QUOTA) {\n crypto.getRandomValues(v.subarray(i, i + Math.min(n - i, QUOTA)));\n }\n for (i = 0; i < n; i++) x[i] = v[i];\n cleanup(v);\n });\n } else if (typeof require !== 'undefined') {\n // Node.js.\n crypto = require('crypto');\n if (crypto && crypto.randomBytes) {\n nacl.setPRNG(function(x, n) {\n var i, v = crypto.randomBytes(n);\n for (i = 0; i < n; i++) x[i] = v[i];\n cleanup(v);\n });\n }\n }\n})();\n\n})(typeof module !== 'undefined' && module.exports ? module.exports : (self.nacl = self.nacl || {}));\n","module.exports = require('./pusher-with-encryption').default;\n","/* (ignored) */","import ScriptReceiver from './script_receiver';\n\n/** Builds receivers for JSONP and Script requests.\n *\n * Each receiver is an object with following fields:\n * - number - unique (for the factory instance), numerical id of the receiver\n * - id - a string ID that can be used in DOM attributes\n * - name - name of the function triggering the receiver\n * - callback - callback function\n *\n * Receivers are triggered only once, on the first callback call.\n *\n * Receivers can be called by their name or by accessing factory object\n * by the number key.\n *\n * @param {String} prefix the prefix used in ids\n * @param {String} name the name of the object\n */\nexport class ScriptReceiverFactory {\n lastId: number;\n prefix: string;\n name: string;\n\n constructor(prefix: string, name: string) {\n this.lastId = 0;\n this.prefix = prefix;\n this.name = name;\n }\n\n create(callback: Function): ScriptReceiver {\n this.lastId++;\n\n var number = this.lastId;\n var id = this.prefix + number;\n var name = this.name + '[' + number + ']';\n\n var called = false;\n var callbackWrapper = function() {\n if (!called) {\n callback.apply(null, arguments);\n called = true;\n }\n };\n\n this[number] = callbackWrapper;\n return { number: number, id: id, name: name, callback: callbackWrapper };\n }\n\n remove(receiver: ScriptReceiver) {\n delete this[receiver.number];\n }\n}\n\nexport var ScriptReceivers = new ScriptReceiverFactory(\n '_pusher_script_',\n 'Pusher.ScriptReceivers'\n);\n","import {\n ChannelAuthorizationOptions,\n UserAuthenticationOptions\n} from './auth/options';\nimport { AuthTransport } from './config';\n\nexport interface DefaultConfig {\n VERSION: string;\n PROTOCOL: number;\n wsPort: number;\n wssPort: number;\n wsPath: string;\n httpHost: string;\n httpPort: number;\n httpsPort: number;\n httpPath: string;\n stats_host: string;\n authEndpoint: string;\n authTransport: AuthTransport;\n activityTimeout: number;\n pongTimeout: number;\n unavailableTimeout: number;\n userAuthentication: UserAuthenticationOptions;\n channelAuthorization: ChannelAuthorizationOptions;\n\n cdn_http?: string;\n cdn_https?: string;\n dependency_suffix?: string;\n}\n\nvar Defaults: DefaultConfig = {\n VERSION: VERSION,\n PROTOCOL: 7,\n\n wsPort: 80,\n wssPort: 443,\n wsPath: '',\n // DEPRECATED: SockJS fallback parameters\n httpHost: 'sockjs.pusher.com',\n httpPort: 80,\n httpsPort: 443,\n httpPath: '/pusher',\n // DEPRECATED: Stats\n stats_host: 'stats.pusher.com',\n // DEPRECATED: Other settings\n authEndpoint: '/pusher/auth',\n authTransport: 'ajax',\n activityTimeout: 120000,\n pongTimeout: 30000,\n unavailableTimeout: 10000,\n userAuthentication: {\n endpoint: '/pusher/user-auth',\n transport: 'ajax'\n },\n channelAuthorization: {\n endpoint: '/pusher/auth',\n transport: 'ajax'\n },\n\n // CDN configuration\n cdn_http: CDN_HTTP,\n cdn_https: CDN_HTTPS,\n dependency_suffix: DEPENDENCY_SUFFIX\n};\n\nexport default Defaults;\n","import {\n ScriptReceivers,\n ScriptReceiverFactory\n} from './script_receiver_factory';\nimport Runtime from 'runtime';\nimport ScriptRequest from './script_request';\n\n/** Handles loading dependency files.\n *\n * Dependency loaders don't remember whether a resource has been loaded or\n * not. It is caller's responsibility to make sure the resource is not loaded\n * twice. This is because it's impossible to detect resource loading status\n * without knowing its content.\n *\n * Options:\n * - cdn_http - url to HTTP CND\n * - cdn_https - url to HTTPS CDN\n * - version - version of pusher-js\n * - suffix - suffix appended to all names of dependency files\n *\n * @param {Object} options\n */\nexport default class DependencyLoader {\n options: any;\n receivers: ScriptReceiverFactory;\n loading: any;\n\n constructor(options: any) {\n this.options = options;\n this.receivers = options.receivers || ScriptReceivers;\n this.loading = {};\n }\n\n /** Loads the dependency from CDN.\n *\n * @param {String} name\n * @param {Function} callback\n */\n load(name: string, options: any, callback: Function) {\n var self = this;\n\n if (self.loading[name] && self.loading[name].length > 0) {\n self.loading[name].push(callback);\n } else {\n self.loading[name] = [callback];\n\n var request = Runtime.createScriptRequest(self.getPath(name, options));\n var receiver = self.receivers.create(function(error) {\n self.receivers.remove(receiver);\n\n if (self.loading[name]) {\n var callbacks = self.loading[name];\n delete self.loading[name];\n\n var successCallback = function(wasSuccessful) {\n if (!wasSuccessful) {\n request.cleanup();\n }\n };\n for (var i = 0; i < callbacks.length; i++) {\n callbacks[i](error, successCallback);\n }\n }\n });\n request.send(receiver);\n }\n }\n\n /** Returns a root URL for pusher-js CDN.\n *\n * @returns {String}\n */\n getRoot(options: any): string {\n var cdn;\n var protocol = Runtime.getDocument().location.protocol;\n if ((options && options.useTLS) || protocol === 'https:') {\n cdn = this.options.cdn_https;\n } else {\n cdn = this.options.cdn_http;\n }\n // make sure there are no double slashes\n return cdn.replace(/\\/*$/, '') + '/' + this.options.version;\n }\n\n /** Returns a full path to a dependency file.\n *\n * @param {String} name\n * @returns {String}\n */\n getPath(name: string, options: any): string {\n return this.getRoot(options) + '/' + name + this.options.suffix + '.js';\n }\n}\n","import { ScriptReceiverFactory } from './script_receiver_factory';\nimport Defaults from 'core/defaults';\nimport DependencyLoader from './dependency_loader';\n\nexport var DependenciesReceivers = new ScriptReceiverFactory(\n '_pusher_dependencies',\n 'Pusher.DependenciesReceivers'\n);\n\nexport var Dependencies = new DependencyLoader({\n cdn_http: Defaults.cdn_http,\n cdn_https: Defaults.cdn_https,\n version: Defaults.VERSION,\n suffix: Defaults.dependency_suffix,\n receivers: DependenciesReceivers\n});\n","/**\n * A place to store help URLs for error messages etc\n */\n\nconst urlStore = {\n baseUrl: 'https://pusher.com',\n urls: {\n authenticationEndpoint: {\n path: '/docs/channels/server_api/authenticating_users'\n },\n authorizationEndpoint: {\n path: '/docs/channels/server_api/authorizing-users/'\n },\n javascriptQuickStart: {\n path: '/docs/javascript_quick_start'\n },\n triggeringClientEvents: {\n path: '/docs/client_api_guide/client_events#trigger-events'\n },\n encryptedChannelSupport: {\n fullUrl:\n 'https://github.com/pusher/pusher-js/tree/cc491015371a4bde5743d1c87a0fbac0feb53195#encrypted-channel-support'\n }\n }\n};\n\n/** Builds a consistent string with links to pusher documentation\n *\n * @param {string} key - relevant key in the url_store.urls object\n * @return {string} suffix string to append to log message\n */\nconst buildLogSuffix = function(key: string): string {\n const urlPrefix = 'See:';\n const urlObj = urlStore.urls[key];\n if (!urlObj) return '';\n\n let url;\n if (urlObj.fullUrl) {\n url = urlObj.fullUrl;\n } else if (urlObj.path) {\n url = urlStore.baseUrl + urlObj.path;\n }\n\n if (!url) return '';\n return `${urlPrefix} ${url}`;\n};\n\nexport default { buildLogSuffix };\n","export enum AuthRequestType {\n UserAuthentication = 'user-authentication',\n ChannelAuthorization = 'channel-authorization'\n}\n\nexport interface ChannelAuthorizationData {\n auth: string;\n channel_data?: string;\n shared_secret?: string;\n}\n\nexport type ChannelAuthorizationCallback = (\n error: Error | null,\n authData: ChannelAuthorizationData | null\n) => void;\n\nexport interface ChannelAuthorizationRequestParams {\n socketId: string;\n channelName: string;\n}\n\nexport interface ChannelAuthorizationHandler {\n (\n params: ChannelAuthorizationRequestParams,\n callback: ChannelAuthorizationCallback\n ): void;\n}\n\nexport interface UserAuthenticationData {\n auth: string;\n user_data: string;\n}\n\nexport type UserAuthenticationCallback = (\n error: Error | null,\n authData: UserAuthenticationData | null\n) => void;\n\nexport interface UserAuthenticationRequestParams {\n socketId: string;\n}\n\nexport interface UserAuthenticationHandler {\n (\n params: UserAuthenticationRequestParams,\n callback: UserAuthenticationCallback\n ): void;\n}\n\nexport type AuthTransportCallback =\n | ChannelAuthorizationCallback\n | UserAuthenticationCallback;\n\nexport interface AuthOptionsT {\n transport: 'ajax' | 'jsonp';\n endpoint: string;\n params?: any;\n headers?: any;\n paramsProvider?: () => any;\n headersProvider?: () => any;\n customHandler?: AuthHandler;\n}\n\nexport declare type UserAuthenticationOptions = AuthOptionsT<\n UserAuthenticationHandler\n>;\nexport declare type ChannelAuthorizationOptions = AuthOptionsT<\n ChannelAuthorizationHandler\n>;\n\nexport interface InternalAuthOptions {\n transport: 'ajax' | 'jsonp';\n endpoint: string;\n params?: any;\n headers?: any;\n paramsProvider?: () => any;\n headersProvider?: () => any;\n}\n","/** Error classes used throughout the library. */\n// https://github.com/Microsoft/TypeScript-wiki/blob/master/Breaking-Changes.md#extending-built-ins-like-error-array-and-map-may-no-longer-work\nexport class BadEventName extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\nexport class BadChannelName extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\nexport class RequestTimedOut extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class TransportPriorityTooLow extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class TransportClosed extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class UnsupportedFeature extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class UnsupportedTransport extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class UnsupportedStrategy extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class HTTPAuthError extends Error {\n status: number;\n constructor(status: number, msg?: string) {\n super(msg);\n this.status = status;\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n","import TimelineSender from 'core/timeline/timeline_sender';\nimport * as Collections from 'core/utils/collections';\nimport Util from 'core/util';\nimport Runtime from 'runtime';\nimport { AuthTransport } from 'core/auth/auth_transports';\nimport AbstractRuntime from 'runtimes/interface';\nimport UrlStore from 'core/utils/url_store';\nimport {\n AuthRequestType,\n AuthTransportCallback,\n InternalAuthOptions\n} from 'core/auth/options';\nimport { HTTPAuthError } from 'core/errors';\n\nconst ajax: AuthTransport = function(\n context: AbstractRuntime,\n query: string,\n authOptions: InternalAuthOptions,\n authRequestType: AuthRequestType,\n callback: AuthTransportCallback\n) {\n const xhr = Runtime.createXHR();\n xhr.open('POST', authOptions.endpoint, true);\n\n // add request headers\n xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');\n for (var headerName in authOptions.headers) {\n xhr.setRequestHeader(headerName, authOptions.headers[headerName]);\n }\n if (authOptions.headersProvider != null) {\n let dynamicHeaders = authOptions.headersProvider();\n for (var headerName in dynamicHeaders) {\n xhr.setRequestHeader(headerName, dynamicHeaders[headerName]);\n }\n }\n\n xhr.onreadystatechange = function() {\n if (xhr.readyState === 4) {\n if (xhr.status === 200) {\n let data;\n let parsed = false;\n\n try {\n data = JSON.parse(xhr.responseText);\n parsed = true;\n } catch (e) {\n callback(\n new HTTPAuthError(\n 200,\n `JSON returned from ${authRequestType.toString()} endpoint was invalid, yet status code was 200. Data was: ${\n xhr.responseText\n }`\n ),\n null\n );\n }\n\n if (parsed) {\n // prevents double execution.\n callback(null, data);\n }\n } else {\n let suffix = '';\n switch (authRequestType) {\n case AuthRequestType.UserAuthentication:\n suffix = UrlStore.buildLogSuffix('authenticationEndpoint');\n break;\n case AuthRequestType.ChannelAuthorization:\n suffix = `Clients must be authorized to join private or presence channels. ${UrlStore.buildLogSuffix(\n 'authorizationEndpoint'\n )}`;\n break;\n }\n callback(\n new HTTPAuthError(\n xhr.status,\n `Unable to retrieve auth string from ${authRequestType.toString()} endpoint - ` +\n `received status: ${xhr.status} from ${authOptions.endpoint}. ${suffix}`\n ),\n null\n );\n }\n }\n };\n\n xhr.send(query);\n return xhr;\n};\n\nexport default ajax;\n","export default function encode(s: any): string {\n return btoa(utob(s));\n}\n\nvar fromCharCode = String.fromCharCode;\n\nvar b64chars =\n 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';\nvar b64tab = {};\n\nfor (var i = 0, l = b64chars.length; i < l; i++) {\n b64tab[b64chars.charAt(i)] = i;\n}\n\nvar cb_utob = function(c) {\n var cc = c.charCodeAt(0);\n return cc < 0x80\n ? c\n : cc < 0x800\n ? fromCharCode(0xc0 | (cc >>> 6)) + fromCharCode(0x80 | (cc & 0x3f))\n : fromCharCode(0xe0 | ((cc >>> 12) & 0x0f)) +\n fromCharCode(0x80 | ((cc >>> 6) & 0x3f)) +\n fromCharCode(0x80 | (cc & 0x3f));\n};\n\nvar utob = function(u) {\n return u.replace(/[^\\x00-\\x7F]/g, cb_utob);\n};\n\nvar cb_encode = function(ccc) {\n var padlen = [0, 2, 1][ccc.length % 3];\n var ord =\n (ccc.charCodeAt(0) << 16) |\n ((ccc.length > 1 ? ccc.charCodeAt(1) : 0) << 8) |\n (ccc.length > 2 ? ccc.charCodeAt(2) : 0);\n var chars = [\n b64chars.charAt(ord >>> 18),\n b64chars.charAt((ord >>> 12) & 63),\n padlen >= 2 ? '=' : b64chars.charAt((ord >>> 6) & 63),\n padlen >= 1 ? '=' : b64chars.charAt(ord & 63)\n ];\n return chars.join('');\n};\n\nvar btoa =\n global.btoa ||\n function(b) {\n return b.replace(/[\\s\\S]{1,3}/g, cb_encode);\n };\n","import TimedCallback from './timed_callback';\nimport { Delay, Scheduler, Canceller } from './scheduling';\n\nabstract class Timer {\n protected clear: Canceller;\n protected timer: number | void;\n\n constructor(\n set: Scheduler,\n clear: Canceller,\n delay: Delay,\n callback: TimedCallback\n ) {\n this.clear = clear;\n this.timer = set(() => {\n if (this.timer) {\n this.timer = callback(this.timer);\n }\n }, delay);\n }\n\n /** Returns whether the timer is still running.\n *\n * @return {Boolean}\n */\n isRunning(): boolean {\n return this.timer !== null;\n }\n\n /** Aborts a timer when it's running. */\n ensureAborted() {\n if (this.timer) {\n this.clear(this.timer);\n this.timer = null;\n }\n }\n}\n\nexport default Timer;\n","import Timer from './abstract_timer';\nimport TimedCallback from './timed_callback';\nimport { Delay } from './scheduling';\n\n// We need to bind clear functions this way to avoid exceptions on IE8\nfunction clearTimeout(timer) {\n global.clearTimeout(timer);\n}\nfunction clearInterval(timer) {\n global.clearInterval(timer);\n}\n\n/** Cross-browser compatible one-off timer abstraction.\n *\n * @param {Number} delay\n * @param {Function} callback\n */\nexport class OneOffTimer extends Timer {\n constructor(delay: Delay, callback: TimedCallback) {\n super(setTimeout, clearTimeout, delay, function(timer) {\n callback();\n return null;\n });\n }\n}\n\n/** Cross-browser compatible periodic timer abstraction.\n *\n * @param {Number} delay\n * @param {Function} callback\n */\nexport class PeriodicTimer extends Timer {\n constructor(delay: Delay, callback: TimedCallback) {\n super(setInterval, clearInterval, delay, function(timer) {\n callback();\n return timer;\n });\n }\n}\n","import * as Collections from './utils/collections';\nimport TimedCallback from './utils/timers/timed_callback';\nimport { OneOffTimer, PeriodicTimer } from './utils/timers';\n\nvar Util = {\n now(): number {\n if (Date.now) {\n return Date.now();\n } else {\n return new Date().valueOf();\n }\n },\n\n defer(callback: TimedCallback): OneOffTimer {\n return new OneOffTimer(0, callback);\n },\n\n /** Builds a function that will proxy a method call to its first argument.\n *\n * Allows partial application of arguments, so additional arguments are\n * prepended to the argument list.\n *\n * @param {String} name method name\n * @return {Function} proxy function\n */\n method(name: string, ...args: any[]): Function {\n var boundArguments = Array.prototype.slice.call(arguments, 1);\n return function(object) {\n return object[name].apply(object, boundArguments.concat(arguments));\n };\n }\n};\n\nexport default Util;\n","import base64encode from '../base64';\nimport Util from '../util';\n\n/** Merges multiple objects into the target argument.\n *\n * For properties that are plain Objects, performs a deep-merge. For the\n * rest it just copies the value of the property.\n *\n * To extend prototypes use it as following:\n * Pusher.Util.extend(Target.prototype, Base.prototype)\n *\n * You can also use it to merge objects without altering them:\n * Pusher.Util.extend({}, object1, object2)\n *\n * @param {Object} target\n * @return {Object} the target argument\n */\nexport function extend(target: any, ...sources: any[]): T {\n for (var i = 0; i < sources.length; i++) {\n var extensions = sources[i];\n for (var property in extensions) {\n if (\n extensions[property] &&\n extensions[property].constructor &&\n extensions[property].constructor === Object\n ) {\n target[property] = extend(target[property] || {}, extensions[property]);\n } else {\n target[property] = extensions[property];\n }\n }\n }\n return target;\n}\n\nexport function stringify(): string {\n var m = ['Pusher'];\n for (var i = 0; i < arguments.length; i++) {\n if (typeof arguments[i] === 'string') {\n m.push(arguments[i]);\n } else {\n m.push(safeJSONStringify(arguments[i]));\n }\n }\n return m.join(' : ');\n}\n\nexport function arrayIndexOf(array: any[], item: any): number {\n // MSIE doesn't have array.indexOf\n var nativeIndexOf = Array.prototype.indexOf;\n if (array === null) {\n return -1;\n }\n if (nativeIndexOf && array.indexOf === nativeIndexOf) {\n return array.indexOf(item);\n }\n for (var i = 0, l = array.length; i < l; i++) {\n if (array[i] === item) {\n return i;\n }\n }\n return -1;\n}\n\n/** Applies a function f to all properties of an object.\n *\n * Function f gets 3 arguments passed:\n * - element from the object\n * - key of the element\n * - reference to the object\n *\n * @param {Object} object\n * @param {Function} f\n */\nexport function objectApply(object: any, f: Function) {\n for (var key in object) {\n if (Object.prototype.hasOwnProperty.call(object, key)) {\n f(object[key], key, object);\n }\n }\n}\n\n/** Return a list of objects own proerty keys\n *\n * @param {Object} object\n * @returns {Array}\n */\nexport function keys(object: any): string[] {\n var keys = [];\n objectApply(object, function(_, key) {\n keys.push(key);\n });\n return keys;\n}\n\n/** Return a list of object's own property values\n *\n * @param {Object} object\n * @returns {Array}\n */\nexport function values(object: any): any[] {\n var values = [];\n objectApply(object, function(value) {\n values.push(value);\n });\n return values;\n}\n\n/** Applies a function f to all elements of an array.\n *\n * Function f gets 3 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function apply(array: any[], f: Function, context?: any) {\n for (var i = 0; i < array.length; i++) {\n f.call(context || global, array[i], i, array);\n }\n}\n\n/** Maps all elements of the array and returns the result.\n *\n * Function f gets 4 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n * - reference to the destination array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function map(array: any[], f: Function): any[] {\n var result = [];\n for (var i = 0; i < array.length; i++) {\n result.push(f(array[i], i, array, result));\n }\n return result;\n}\n\n/** Maps all elements of the object and returns the result.\n *\n * Function f gets 4 arguments passed:\n * - element from the object\n * - key of the element\n * - reference to the source object\n * - reference to the destination object\n *\n * @param {Object} object\n * @param {Function} f\n */\nexport function mapObject(object: any, f: Function): any {\n var result = {};\n objectApply(object, function(value, key) {\n result[key] = f(value);\n });\n return result;\n}\n\n/** Filters elements of the array using a test function.\n *\n * Function test gets 4 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n * - reference to the destination array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function filter(array: any[], test: Function): any[] {\n test =\n test ||\n function(value) {\n return !!value;\n };\n\n var result = [];\n for (var i = 0; i < array.length; i++) {\n if (test(array[i], i, array, result)) {\n result.push(array[i]);\n }\n }\n return result;\n}\n\n/** Filters properties of the object using a test function.\n *\n * Function test gets 4 arguments passed:\n * - element from the object\n * - key of the element\n * - reference to the source object\n * - reference to the destination object\n *\n * @param {Object} object\n * @param {Function} f\n */\nexport function filterObject(object: Object, test: Function) {\n var result = {};\n objectApply(object, function(value, key) {\n if ((test && test(value, key, object, result)) || Boolean(value)) {\n result[key] = value;\n }\n });\n return result;\n}\n\n/** Flattens an object into a two-dimensional array.\n *\n * @param {Object} object\n * @return {Array} resulting array of [key, value] pairs\n */\nexport function flatten(object: Object): any[] {\n var result = [];\n objectApply(object, function(value, key) {\n result.push([key, value]);\n });\n return result;\n}\n\n/** Checks whether any element of the array passes the test.\n *\n * Function test gets 3 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function any(array: any[], test: Function): boolean {\n for (var i = 0; i < array.length; i++) {\n if (test(array[i], i, array)) {\n return true;\n }\n }\n return false;\n}\n\n/** Checks whether all elements of the array pass the test.\n *\n * Function test gets 3 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function all(array: any[], test: Function): boolean {\n for (var i = 0; i < array.length; i++) {\n if (!test(array[i], i, array)) {\n return false;\n }\n }\n return true;\n}\n\nexport function encodeParamsObject(data): string {\n return mapObject(data, function(value) {\n if (typeof value === 'object') {\n value = safeJSONStringify(value);\n }\n return encodeURIComponent(base64encode(value.toString()));\n });\n}\n\nexport function buildQueryString(data: any): string {\n var params = filterObject(data, function(value) {\n return value !== undefined;\n });\n\n var query = map(\n flatten(encodeParamsObject(params)),\n Util.method('join', '=')\n ).join('&');\n\n return query;\n}\n\n/**\n * See https://github.com/douglascrockford/JSON-js/blob/master/cycle.js\n *\n * Remove circular references from an object. Required for JSON.stringify in\n * React Native, which tends to blow up a lot.\n *\n * @param {any} object\n * @return {any} Decycled object\n */\nexport function decycleObject(object: any): any {\n var objects = [],\n paths = [];\n\n return (function derez(value, path) {\n var i, name, nu;\n\n switch (typeof value) {\n case 'object':\n if (!value) {\n return null;\n }\n for (i = 0; i < objects.length; i += 1) {\n if (objects[i] === value) {\n return { $ref: paths[i] };\n }\n }\n\n objects.push(value);\n paths.push(path);\n\n if (Object.prototype.toString.apply(value) === '[object Array]') {\n nu = [];\n for (i = 0; i < value.length; i += 1) {\n nu[i] = derez(value[i], path + '[' + i + ']');\n }\n } else {\n nu = {};\n for (name in value) {\n if (Object.prototype.hasOwnProperty.call(value, name)) {\n nu[name] = derez(\n value[name],\n path + '[' + JSON.stringify(name) + ']'\n );\n }\n }\n }\n return nu;\n case 'number':\n case 'string':\n case 'boolean':\n return value;\n }\n })(object, '$');\n}\n\n/**\n * Provides a cross-browser and cross-platform way to safely stringify objects\n * into JSON. This is particularly necessary for ReactNative, where circular JSON\n * structures throw an exception.\n *\n * @param {any} source The object to stringify\n * @return {string} The serialized output.\n */\nexport function safeJSONStringify(source: any): string {\n try {\n return JSON.stringify(source);\n } catch (e) {\n return JSON.stringify(decycleObject(source));\n }\n}\n","import { stringify } from './utils/collections';\nimport Pusher from './pusher';\n\nclass Logger {\n debug(...args: any[]) {\n this.log(this.globalLog, args);\n }\n\n warn(...args: any[]) {\n this.log(this.globalLogWarn, args);\n }\n\n error(...args: any[]) {\n this.log(this.globalLogError, args);\n }\n\n private globalLog = (message: string) => {\n if (global.console && global.console.log) {\n global.console.log(message);\n }\n };\n\n private globalLogWarn(message: string) {\n if (global.console && global.console.warn) {\n global.console.warn(message);\n } else {\n this.globalLog(message);\n }\n }\n\n private globalLogError(message: string) {\n if (global.console && global.console.error) {\n global.console.error(message);\n } else {\n this.globalLogWarn(message);\n }\n }\n\n private log(\n defaultLoggingFunction: (message: string) => void,\n ...args: any[]\n ) {\n var message = stringify.apply(this, arguments);\n if (Pusher.log) {\n Pusher.log(message);\n } else if (Pusher.logToConsole) {\n const log = defaultLoggingFunction.bind(this);\n log(message);\n }\n }\n}\n\nexport default new Logger();\n","import Browser from '../browser';\nimport Logger from 'core/logger';\nimport JSONPRequest from '../dom/jsonp_request';\nimport { ScriptReceivers } from '../dom/script_receiver_factory';\nimport { AuthTransport } from 'core/auth/auth_transports';\nimport {\n AuthRequestType,\n AuthTransportCallback,\n InternalAuthOptions\n} from 'core/auth/options';\n\nvar jsonp: AuthTransport = function(\n context: Browser,\n query: string,\n authOptions: InternalAuthOptions,\n authRequestType: AuthRequestType,\n callback: AuthTransportCallback\n) {\n if (\n authOptions.headers !== undefined ||\n authOptions.headersProvider != null\n ) {\n Logger.warn(\n `To send headers with the ${authRequestType.toString()} request, you must use AJAX, rather than JSONP.`\n );\n }\n\n var callbackName = context.nextAuthCallbackID.toString();\n context.nextAuthCallbackID++;\n\n var document = context.getDocument();\n var script = document.createElement('script');\n // Hacked wrapper.\n context.auth_callbacks[callbackName] = function(data) {\n callback(null, data);\n };\n\n var callback_name = \"Pusher.auth_callbacks['\" + callbackName + \"']\";\n script.src =\n authOptions.endpoint +\n '?callback=' +\n encodeURIComponent(callback_name) +\n '&' +\n query;\n\n var head =\n document.getElementsByTagName('head')[0] || document.documentElement;\n head.insertBefore(script, head.firstChild);\n};\n\nexport default jsonp;\n","import ScriptReceiver from './script_receiver';\n\n/** Sends a generic HTTP GET request using a script tag.\n *\n * By constructing URL in a specific way, it can be used for loading\n * JavaScript resources or JSONP requests. It can notify about errors, but\n * only in certain environments. Please take care of monitoring the state of\n * the request yourself.\n *\n * @param {String} src\n */\nexport default class ScriptRequest {\n src: string;\n script: any;\n errorScript: any;\n\n constructor(src: string) {\n this.src = src;\n }\n\n send(receiver: ScriptReceiver) {\n var self = this;\n var errorString = 'Error loading ' + self.src;\n\n self.script = document.createElement('script');\n self.script.id = receiver.id;\n self.script.src = self.src;\n self.script.type = 'text/javascript';\n self.script.charset = 'UTF-8';\n\n if (self.script.addEventListener) {\n self.script.onerror = function() {\n receiver.callback(errorString);\n };\n self.script.onload = function() {\n receiver.callback(null);\n };\n } else {\n self.script.onreadystatechange = function() {\n if (\n self.script.readyState === 'loaded' ||\n self.script.readyState === 'complete'\n ) {\n receiver.callback(null);\n }\n };\n }\n\n // Opera<11.6 hack for missing onerror callback\n if (\n self.script.async === undefined &&\n (document).attachEvent &&\n /opera/i.test(navigator.userAgent)\n ) {\n self.errorScript = document.createElement('script');\n self.errorScript.id = receiver.id + '_error';\n self.errorScript.text = receiver.name + \"('\" + errorString + \"');\";\n self.script.async = self.errorScript.async = false;\n } else {\n self.script.async = true;\n }\n\n var head = document.getElementsByTagName('head')[0];\n head.insertBefore(self.script, head.firstChild);\n if (self.errorScript) {\n head.insertBefore(self.errorScript, self.script.nextSibling);\n }\n }\n\n /** Cleans up the DOM remains of the script request. */\n cleanup() {\n if (this.script) {\n this.script.onload = this.script.onerror = null;\n this.script.onreadystatechange = null;\n }\n if (this.script && this.script.parentNode) {\n this.script.parentNode.removeChild(this.script);\n }\n if (this.errorScript && this.errorScript.parentNode) {\n this.errorScript.parentNode.removeChild(this.errorScript);\n }\n this.script = null;\n this.errorScript = null;\n }\n}\n","import ScriptReceiver from './script_receiver';\nimport ScriptRequest from './script_request';\nimport * as Collections from 'core/utils/collections';\nimport Util from 'core/util';\nimport Runtime from '../runtime';\n\n/** Sends data via JSONP.\n *\n * Data is a key-value map. Its values are JSON-encoded and then passed\n * through base64. Finally, keys and encoded values are appended to the query\n * string.\n *\n * The class itself does not guarantee raising errors on failures, as it's not\n * possible to support such feature on all browsers. Instead, JSONP endpoint\n * should call back in a way that's easy to distinguish from browser calls,\n * for example by passing a second argument to the receiver.\n *\n * @param {String} url\n * @param {Object} data key-value map of data to be submitted\n */\nexport default class JSONPRequest {\n url: string;\n data: any;\n request: ScriptRequest;\n\n constructor(url: string, data: any) {\n this.url = url;\n this.data = data;\n }\n\n /** Sends the actual JSONP request.\n *\n * @param {ScriptReceiver} receiver\n */\n send(receiver: ScriptReceiver) {\n if (this.request) {\n return;\n }\n\n var query = Collections.buildQueryString(this.data);\n var url = this.url + '/' + receiver.number + '?' + query;\n this.request = Runtime.createScriptRequest(url);\n this.request.send(receiver);\n }\n\n /** Cleans up the DOM remains of the JSONP request. */\n cleanup() {\n if (this.request) {\n this.request.cleanup();\n }\n }\n}\n","import TimelineSender from 'core/timeline/timeline_sender';\nimport TimelineTransport from 'core/timeline/timeline_transport';\nimport Browser from 'runtime';\nimport { AuthTransport } from 'core/auth/auth_transports';\nimport { ScriptReceivers } from '../dom/script_receiver_factory';\n\nvar getAgent = function(sender: TimelineSender, useTLS: boolean) {\n return function(data: any, callback: Function) {\n var scheme = 'http' + (useTLS ? 's' : '') + '://';\n var url =\n scheme + (sender.host || sender.options.host) + sender.options.path;\n var request = Browser.createJSONPRequest(url, data);\n\n var receiver = Browser.ScriptReceivers.create(function(error, result) {\n ScriptReceivers.remove(receiver);\n request.cleanup();\n\n if (result && result.host) {\n sender.host = result.host;\n }\n if (callback) {\n callback(error, result);\n }\n });\n request.send(receiver);\n };\n};\n\nvar jsonp = {\n name: 'jsonp',\n getAgent\n};\n\nexport default jsonp;\n","import Defaults from '../defaults';\nimport { default as URLScheme, URLSchemeParams } from './url_scheme';\n\nfunction getGenericURL(\n baseScheme: string,\n params: URLSchemeParams,\n path: string\n): string {\n var scheme = baseScheme + (params.useTLS ? 's' : '');\n var host = params.useTLS ? params.hostTLS : params.hostNonTLS;\n return scheme + '://' + host + path;\n}\n\nfunction getGenericPath(key: string, queryString?: string): string {\n var path = '/app/' + key;\n var query =\n '?protocol=' +\n Defaults.PROTOCOL +\n '&client=js' +\n '&version=' +\n Defaults.VERSION +\n (queryString ? '&' + queryString : '');\n return path + query;\n}\n\nexport var ws: URLScheme = {\n getInitial: function(key: string, params: URLSchemeParams): string {\n var path = (params.httpPath || '') + getGenericPath(key, 'flash=false');\n return getGenericURL('ws', params, path);\n }\n};\n\nexport var http: URLScheme = {\n getInitial: function(key: string, params: URLSchemeParams): string {\n var path = (params.httpPath || '/pusher') + getGenericPath(key);\n return getGenericURL('http', params, path);\n }\n};\n\nexport var sockjs: URLScheme = {\n getInitial: function(key: string, params: URLSchemeParams): string {\n return getGenericURL('http', params, params.httpPath || '/pusher');\n },\n getPath: function(key: string, params: URLSchemeParams): string {\n return getGenericPath(key);\n }\n};\n","import Callback from './callback';\nimport * as Collections from '../utils/collections';\nimport CallbackTable from './callback_table';\n\nexport default class CallbackRegistry {\n _callbacks: CallbackTable;\n\n constructor() {\n this._callbacks = {};\n }\n\n get(name: string): Callback[] {\n return this._callbacks[prefix(name)];\n }\n\n add(name: string, callback: Function, context: any) {\n var prefixedEventName = prefix(name);\n this._callbacks[prefixedEventName] =\n this._callbacks[prefixedEventName] || [];\n this._callbacks[prefixedEventName].push({\n fn: callback,\n context: context\n });\n }\n\n remove(name?: string, callback?: Function, context?: any) {\n if (!name && !callback && !context) {\n this._callbacks = {};\n return;\n }\n\n var names = name ? [prefix(name)] : Collections.keys(this._callbacks);\n\n if (callback || context) {\n this.removeCallback(names, callback, context);\n } else {\n this.removeAllCallbacks(names);\n }\n }\n\n private removeCallback(names: string[], callback: Function, context: any) {\n Collections.apply(\n names,\n function(name) {\n this._callbacks[name] = Collections.filter(\n this._callbacks[name] || [],\n function(binding) {\n return (\n (callback && callback !== binding.fn) ||\n (context && context !== binding.context)\n );\n }\n );\n if (this._callbacks[name].length === 0) {\n delete this._callbacks[name];\n }\n },\n this\n );\n }\n\n private removeAllCallbacks(names: string[]) {\n Collections.apply(\n names,\n function(name) {\n delete this._callbacks[name];\n },\n this\n );\n }\n}\n\nfunction prefix(name: string): string {\n return '_' + name;\n}\n","import * as Collections from '../utils/collections';\nimport Callback from './callback';\nimport Metadata from '../channels/metadata';\nimport CallbackRegistry from './callback_registry';\n\n/** Manages callback bindings and event emitting.\n *\n * @param Function failThrough called when no listeners are bound to an event\n */\nexport default class Dispatcher {\n callbacks: CallbackRegistry;\n global_callbacks: Function[];\n failThrough: Function;\n\n constructor(failThrough?: Function) {\n this.callbacks = new CallbackRegistry();\n this.global_callbacks = [];\n this.failThrough = failThrough;\n }\n\n bind(eventName: string, callback: Function, context?: any) {\n this.callbacks.add(eventName, callback, context);\n return this;\n }\n\n bind_global(callback: Function) {\n this.global_callbacks.push(callback);\n return this;\n }\n\n unbind(eventName?: string, callback?: Function, context?: any) {\n this.callbacks.remove(eventName, callback, context);\n return this;\n }\n\n unbind_global(callback?: Function) {\n if (!callback) {\n this.global_callbacks = [];\n return this;\n }\n\n this.global_callbacks = Collections.filter(\n this.global_callbacks || [],\n c => c !== callback\n );\n\n return this;\n }\n\n unbind_all() {\n this.unbind();\n this.unbind_global();\n return this;\n }\n\n emit(eventName: string, data?: any, metadata?: Metadata): Dispatcher {\n for (var i = 0; i < this.global_callbacks.length; i++) {\n this.global_callbacks[i](eventName, data);\n }\n\n var callbacks = this.callbacks.get(eventName);\n var args = [];\n\n if (metadata) {\n // if there's a metadata argument, we need to call the callback with both\n // data and metadata regardless of whether data is undefined\n args.push(data, metadata);\n } else if (data) {\n // metadata is undefined, so we only need to call the callback with data\n // if data exists\n args.push(data);\n }\n\n if (callbacks && callbacks.length > 0) {\n for (var i = 0; i < callbacks.length; i++) {\n callbacks[i].fn.apply(callbacks[i].context || global, args);\n }\n } else if (this.failThrough) {\n this.failThrough(eventName, data);\n }\n\n return this;\n }\n}\n","import Util from '../util';\nimport * as Collections from '../utils/collections';\nimport { default as EventsDispatcher } from '../events/dispatcher';\nimport Logger from '../logger';\nimport TransportHooks from './transport_hooks';\nimport Socket from '../socket';\nimport Runtime from 'runtime';\nimport Timeline from '../timeline/timeline';\nimport TransportConnectionOptions from './transport_connection_options';\n\n/** Provides universal API for transport connections.\n *\n * Transport connection is a low-level object that wraps a connection method\n * and exposes a simple evented interface for the connection state and\n * messaging. It does not implement Pusher-specific WebSocket protocol.\n *\n * Additionally, it fetches resources needed for transport to work and exposes\n * an interface for querying transport features.\n *\n * States:\n * - new - initial state after constructing the object\n * - initializing - during initialization phase, usually fetching resources\n * - intialized - ready to establish a connection\n * - connection - when connection is being established\n * - open - when connection ready to be used\n * - closed - after connection was closed be either side\n *\n * Emits:\n * - error - after the connection raised an error\n *\n * Options:\n * - useTLS - whether connection should be over TLS\n * - hostTLS - host to connect to when connection is over TLS\n * - hostNonTLS - host to connect to when connection is over TLS\n *\n * @param {String} key application key\n * @param {Object} options\n */\nexport default class TransportConnection extends EventsDispatcher {\n hooks: TransportHooks;\n name: string;\n priority: number;\n key: string;\n options: TransportConnectionOptions;\n state: string;\n timeline: Timeline;\n activityTimeout: number;\n id: number;\n socket: Socket;\n beforeOpen: Function;\n initialize: Function;\n\n constructor(\n hooks: TransportHooks,\n name: string,\n priority: number,\n key: string,\n options: TransportConnectionOptions\n ) {\n super();\n this.initialize = Runtime.transportConnectionInitializer;\n this.hooks = hooks;\n this.name = name;\n this.priority = priority;\n this.key = key;\n this.options = options;\n\n this.state = 'new';\n this.timeline = options.timeline;\n this.activityTimeout = options.activityTimeout;\n this.id = this.timeline.generateUniqueID();\n }\n\n /** Checks whether the transport handles activity checks by itself.\n *\n * @return {Boolean}\n */\n handlesActivityChecks(): boolean {\n return Boolean(this.hooks.handlesActivityChecks);\n }\n\n /** Checks whether the transport supports the ping/pong API.\n *\n * @return {Boolean}\n */\n supportsPing(): boolean {\n return Boolean(this.hooks.supportsPing);\n }\n\n /** Tries to establish a connection.\n *\n * @returns {Boolean} false if transport is in invalid state\n */\n connect(): boolean {\n if (this.socket || this.state !== 'initialized') {\n return false;\n }\n\n var url = this.hooks.urls.getInitial(this.key, this.options);\n try {\n this.socket = this.hooks.getSocket(url, this.options);\n } catch (e) {\n Util.defer(() => {\n this.onError(e);\n this.changeState('closed');\n });\n return false;\n }\n\n this.bindListeners();\n\n Logger.debug('Connecting', { transport: this.name, url });\n this.changeState('connecting');\n return true;\n }\n\n /** Closes the connection.\n *\n * @return {Boolean} true if there was a connection to close\n */\n close(): boolean {\n if (this.socket) {\n this.socket.close();\n return true;\n } else {\n return false;\n }\n }\n\n /** Sends data over the open connection.\n *\n * @param {String} data\n * @return {Boolean} true only when in the \"open\" state\n */\n send(data: any): boolean {\n if (this.state === 'open') {\n // Workaround for MobileSafari bug (see https://gist.github.com/2052006)\n Util.defer(() => {\n if (this.socket) {\n this.socket.send(data);\n }\n });\n return true;\n } else {\n return false;\n }\n }\n\n /** Sends a ping if the connection is open and transport supports it. */\n ping() {\n if (this.state === 'open' && this.supportsPing()) {\n this.socket.ping();\n }\n }\n\n private onOpen() {\n if (this.hooks.beforeOpen) {\n this.hooks.beforeOpen(\n this.socket,\n this.hooks.urls.getPath(this.key, this.options)\n );\n }\n this.changeState('open');\n this.socket.onopen = undefined;\n }\n\n private onError(error) {\n this.emit('error', { type: 'WebSocketError', error: error });\n this.timeline.error(this.buildTimelineMessage({ error: error.toString() }));\n }\n\n private onClose(closeEvent?: any) {\n if (closeEvent) {\n this.changeState('closed', {\n code: closeEvent.code,\n reason: closeEvent.reason,\n wasClean: closeEvent.wasClean\n });\n } else {\n this.changeState('closed');\n }\n this.unbindListeners();\n this.socket = undefined;\n }\n\n private onMessage(message) {\n this.emit('message', message);\n }\n\n private onActivity() {\n this.emit('activity');\n }\n\n private bindListeners() {\n this.socket.onopen = () => {\n this.onOpen();\n };\n this.socket.onerror = error => {\n this.onError(error);\n };\n this.socket.onclose = closeEvent => {\n this.onClose(closeEvent);\n };\n this.socket.onmessage = message => {\n this.onMessage(message);\n };\n\n if (this.supportsPing()) {\n this.socket.onactivity = () => {\n this.onActivity();\n };\n }\n }\n\n private unbindListeners() {\n if (this.socket) {\n this.socket.onopen = undefined;\n this.socket.onerror = undefined;\n this.socket.onclose = undefined;\n this.socket.onmessage = undefined;\n if (this.supportsPing()) {\n this.socket.onactivity = undefined;\n }\n }\n }\n\n private changeState(state: string, params?: any) {\n this.state = state;\n this.timeline.info(\n this.buildTimelineMessage({\n state: state,\n params: params\n })\n );\n this.emit(state, params);\n }\n\n buildTimelineMessage(message): any {\n return Collections.extend({ cid: this.id }, message);\n }\n}\n","import Factory from '../utils/factory';\nimport TransportHooks from './transport_hooks';\nimport TransportConnection from './transport_connection';\nimport TransportConnectionOptions from './transport_connection_options';\n\n/** Provides interface for transport connection instantiation.\n *\n * Takes transport-specific hooks as the only argument, which allow checking\n * for transport support and creating its connections.\n *\n * Supported hooks: * - file - the name of the file to be fetched during initialization\n * - urls - URL scheme to be used by transport\n * - handlesActivityCheck - true when the transport handles activity checks\n * - supportsPing - true when the transport has a ping/activity API\n * - isSupported - tells whether the transport is supported in the environment\n * - getSocket - creates a WebSocket-compatible transport socket\n *\n * See transports.js for specific implementations.\n *\n * @param {Object} hooks object containing all needed transport hooks\n */\nexport default class Transport {\n hooks: TransportHooks;\n\n constructor(hooks: TransportHooks) {\n this.hooks = hooks;\n }\n\n /** Returns whether the transport is supported in the environment.\n *\n * @param {Object} envronment te environment details (encryption, settings)\n * @returns {Boolean} true when the transport is supported\n */\n isSupported(environment: any): boolean {\n return this.hooks.isSupported(environment);\n }\n\n /** Creates a transport connection.\n *\n * @param {String} name\n * @param {Number} priority\n * @param {String} key the application key\n * @param {Object} options\n * @returns {TransportConnection}\n */\n createConnection(\n name: string,\n priority: number,\n key: string,\n options: any\n ): TransportConnection {\n return new TransportConnection(this.hooks, name, priority, key, options);\n }\n}\n","import * as URLSchemes from 'core/transports/url_schemes';\nimport URLScheme from 'core/transports/url_scheme';\nimport Transport from 'core/transports/transport';\nimport Util from 'core/util';\nimport * as Collections from 'core/utils/collections';\nimport TransportHooks from 'core/transports/transport_hooks';\nimport TransportsTable from 'core/transports/transports_table';\nimport Runtime from 'runtime';\n\n/** WebSocket transport.\n *\n * Uses native WebSocket implementation, including MozWebSocket supported by\n * earlier Firefox versions.\n */\nvar WSTransport = new Transport({\n urls: URLSchemes.ws,\n handlesActivityChecks: false,\n supportsPing: false,\n\n isInitialized: function() {\n return Boolean(Runtime.getWebSocketAPI());\n },\n isSupported: function(): boolean {\n return Boolean(Runtime.getWebSocketAPI());\n },\n getSocket: function(url) {\n return Runtime.createWebSocket(url);\n }\n});\n\nvar httpConfiguration = {\n urls: URLSchemes.http,\n handlesActivityChecks: false,\n supportsPing: true,\n isInitialized: function() {\n return true;\n }\n};\n\nexport var streamingConfiguration = Collections.extend(\n {\n getSocket: function(url) {\n return Runtime.HTTPFactory.createStreamingSocket(url);\n }\n },\n httpConfiguration\n);\nexport var pollingConfiguration = Collections.extend(\n {\n getSocket: function(url) {\n return Runtime.HTTPFactory.createPollingSocket(url);\n }\n },\n httpConfiguration\n);\n\nvar xhrConfiguration = {\n isSupported: function(): boolean {\n return Runtime.isXHRSupported();\n }\n};\n\n/** HTTP streaming transport using CORS-enabled XMLHttpRequest. */\nvar XHRStreamingTransport = new Transport(\n (\n Collections.extend({}, streamingConfiguration, xhrConfiguration)\n )\n);\n\n/** HTTP long-polling transport using CORS-enabled XMLHttpRequest. */\nvar XHRPollingTransport = new Transport(\n Collections.extend({}, pollingConfiguration, xhrConfiguration)\n);\n\nvar Transports: TransportsTable = {\n ws: WSTransport,\n xhr_streaming: XHRStreamingTransport,\n xhr_polling: XHRPollingTransport\n};\n\nexport default Transports;\n","import {\n default as Transports,\n streamingConfiguration,\n pollingConfiguration\n} from 'isomorphic/transports/transports';\nimport Transport from 'core/transports/transport';\nimport TransportHooks from 'core/transports/transport_hooks';\nimport * as URLSchemes from 'core/transports/url_schemes';\nimport Runtime from 'runtime';\nimport { Dependencies } from '../dom/dependencies';\nimport * as Collections from 'core/utils/collections';\n\nvar SockJSTransport = new Transport({\n file: 'sockjs',\n urls: URLSchemes.sockjs,\n handlesActivityChecks: true,\n supportsPing: false,\n\n isSupported: function() {\n return true;\n },\n isInitialized: function() {\n return window.SockJS !== undefined;\n },\n getSocket: function(url, options) {\n return new window.SockJS(url, null, {\n js_path: Dependencies.getPath('sockjs', {\n useTLS: options.useTLS\n }),\n ignore_null_origin: options.ignoreNullOrigin\n });\n },\n beforeOpen: function(socket, path) {\n socket.send(\n JSON.stringify({\n path: path\n })\n );\n }\n});\n\nvar xdrConfiguration = {\n isSupported: function(environment): boolean {\n var yes = Runtime.isXDRSupported(environment.useTLS);\n return yes;\n }\n};\n\n/** HTTP streaming transport using XDomainRequest (IE 8,9). */\nvar XDRStreamingTransport = new Transport(\n (\n Collections.extend({}, streamingConfiguration, xdrConfiguration)\n )\n);\n\n/** HTTP long-polling transport using XDomainRequest (IE 8,9). */\nvar XDRPollingTransport = new Transport(\n Collections.extend({}, pollingConfiguration, xdrConfiguration)\n);\n\nTransports.xdr_streaming = XDRStreamingTransport;\nTransports.xdr_polling = XDRPollingTransport;\nTransports.sockjs = SockJSTransport;\n\nexport default Transports;\n","import Reachability from 'core/reachability';\nimport { default as EventsDispatcher } from 'core/events/dispatcher';\n\n/** Really basic interface providing network availability info.\n *\n * Emits:\n * - online - when browser goes online\n * - offline - when browser goes offline\n */\nexport class NetInfo extends EventsDispatcher implements Reachability {\n constructor() {\n super();\n var self = this;\n // This is okay, as IE doesn't support this stuff anyway.\n if (window.addEventListener !== undefined) {\n window.addEventListener(\n 'online',\n function() {\n self.emit('online');\n },\n false\n );\n window.addEventListener(\n 'offline',\n function() {\n self.emit('offline');\n },\n false\n );\n }\n }\n\n /** Returns whether browser is online or not\n *\n * Offline means definitely offline (no connection to router).\n * Inverse does NOT mean definitely online (only currently supported in Safari\n * and even there only means the device has a connection to the router).\n *\n * @return {Boolean}\n */\n isOnline(): boolean {\n if (window.navigator.onLine === undefined) {\n return true;\n } else {\n return window.navigator.onLine;\n }\n }\n}\n\nexport var Network = new NetInfo();\n","import Util from '../util';\nimport * as Collections from '../utils/collections';\nimport TransportManager from './transport_manager';\nimport TransportConnection from './transport_connection';\nimport Transport from './transport';\nimport PingDelayOptions from './ping_delay_options';\n\n/** Creates transport connections monitored by a transport manager.\n *\n * When a transport is closed, it might mean the environment does not support\n * it. It's possible that messages get stuck in an intermediate buffer or\n * proxies terminate inactive connections. To combat these problems,\n * assistants monitor the connection lifetime, report unclean exits and\n * adjust ping timeouts to keep the connection active. The decision to disable\n * a transport is the manager's responsibility.\n *\n * @param {TransportManager} manager\n * @param {TransportConnection} transport\n * @param {Object} options\n */\nexport default class AssistantToTheTransportManager {\n manager: TransportManager;\n transport: Transport;\n minPingDelay: number;\n maxPingDelay: number;\n pingDelay: number;\n\n constructor(\n manager: TransportManager,\n transport: Transport,\n options: PingDelayOptions\n ) {\n this.manager = manager;\n this.transport = transport;\n this.minPingDelay = options.minPingDelay;\n this.maxPingDelay = options.maxPingDelay;\n this.pingDelay = undefined;\n }\n\n /** Creates a transport connection.\n *\n * This function has the same API as Transport#createConnection.\n *\n * @param {String} name\n * @param {Number} priority\n * @param {String} key the application key\n * @param {Object} options\n * @returns {TransportConnection}\n */\n createConnection(\n name: string,\n priority: number,\n key: string,\n options: Object\n ): TransportConnection {\n options = Collections.extend({}, options, {\n activityTimeout: this.pingDelay\n });\n var connection = this.transport.createConnection(\n name,\n priority,\n key,\n options\n );\n\n var openTimestamp = null;\n\n var onOpen = function() {\n connection.unbind('open', onOpen);\n connection.bind('closed', onClosed);\n openTimestamp = Util.now();\n };\n var onClosed = closeEvent => {\n connection.unbind('closed', onClosed);\n\n if (closeEvent.code === 1002 || closeEvent.code === 1003) {\n // we don't want to use transports not obeying the protocol\n this.manager.reportDeath();\n } else if (!closeEvent.wasClean && openTimestamp) {\n // report deaths only for short-living transport\n var lifespan = Util.now() - openTimestamp;\n if (lifespan < 2 * this.maxPingDelay) {\n this.manager.reportDeath();\n this.pingDelay = Math.max(lifespan / 2, this.minPingDelay);\n }\n }\n };\n\n connection.bind('open', onOpen);\n return connection;\n }\n\n /** Returns whether the transport is supported in the environment.\n *\n * This function has the same API as Transport#isSupported. Might return false\n * when the manager decides to kill the transport.\n *\n * @param {Object} environment the environment details (encryption, settings)\n * @returns {Boolean} true when the transport is supported\n */\n isSupported(environment: string): boolean {\n return this.manager.isAlive() && this.transport.isSupported(environment);\n }\n}\n","import Action from './action';\nimport { PusherEvent } from './message-types';\n/**\n * Provides functions for handling Pusher protocol-specific messages.\n */\n\nconst Protocol = {\n /**\n * Decodes a message in a Pusher format.\n *\n * The MessageEvent we receive from the transport should contain a pusher event\n * (https://pusher.com/docs/pusher_protocol#events) serialized as JSON in the\n * data field\n *\n * The pusher event may contain a data field too, and it may also be\n * serialised as JSON\n *\n * Throws errors when messages are not parse'able.\n *\n * @param {MessageEvent} messageEvent\n * @return {PusherEvent}\n */\n decodeMessage: function(messageEvent: MessageEvent): PusherEvent {\n try {\n var messageData = JSON.parse(messageEvent.data);\n var pusherEventData = messageData.data;\n if (typeof pusherEventData === 'string') {\n try {\n pusherEventData = JSON.parse(messageData.data);\n } catch (e) {}\n }\n var pusherEvent: PusherEvent = {\n event: messageData.event,\n channel: messageData.channel,\n data: pusherEventData\n };\n if (messageData.user_id) {\n pusherEvent.user_id = messageData.user_id;\n }\n return pusherEvent;\n } catch (e) {\n throw { type: 'MessageParseError', error: e, data: messageEvent.data };\n }\n },\n\n /**\n * Encodes a message to be sent.\n *\n * @param {PusherEvent} event\n * @return {String}\n */\n encodeMessage: function(event: PusherEvent): string {\n return JSON.stringify(event);\n },\n\n /**\n * Processes a handshake message and returns appropriate actions.\n *\n * Returns an object with an 'action' and other action-specific properties.\n *\n * There are three outcomes when calling this function. First is a successful\n * connection attempt, when pusher:connection_established is received, which\n * results in a 'connected' action with an 'id' property. When passed a\n * pusher:error event, it returns a result with action appropriate to the\n * close code and an error. Otherwise, it raises an exception.\n *\n * @param {String} message\n * @result Object\n */\n processHandshake: function(messageEvent: MessageEvent): Action {\n var message = Protocol.decodeMessage(messageEvent);\n\n if (message.event === 'pusher:connection_established') {\n if (!message.data.activity_timeout) {\n throw 'No activity timeout specified in handshake';\n }\n return {\n action: 'connected',\n id: message.data.socket_id,\n activityTimeout: message.data.activity_timeout * 1000\n };\n } else if (message.event === 'pusher:error') {\n // From protocol 6 close codes are sent only once, so this only\n // happens when connection does not support close codes\n return {\n action: this.getCloseAction(message.data),\n error: this.getCloseError(message.data)\n };\n } else {\n throw 'Invalid handshake';\n }\n },\n\n /**\n * Dispatches the close event and returns an appropriate action name.\n *\n * See:\n * 1. https://developer.mozilla.org/en-US/docs/WebSockets/WebSockets_reference/CloseEvent\n * 2. http://pusher.com/docs/pusher_protocol\n *\n * @param {CloseEvent} closeEvent\n * @return {String} close action name\n */\n getCloseAction: function(closeEvent): string {\n if (closeEvent.code < 4000) {\n // ignore 1000 CLOSE_NORMAL, 1001 CLOSE_GOING_AWAY,\n // 1005 CLOSE_NO_STATUS, 1006 CLOSE_ABNORMAL\n // ignore 1007...3999\n // handle 1002 CLOSE_PROTOCOL_ERROR, 1003 CLOSE_UNSUPPORTED,\n // 1004 CLOSE_TOO_LARGE\n if (closeEvent.code >= 1002 && closeEvent.code <= 1004) {\n return 'backoff';\n } else {\n return null;\n }\n } else if (closeEvent.code === 4000) {\n return 'tls_only';\n } else if (closeEvent.code < 4100) {\n return 'refused';\n } else if (closeEvent.code < 4200) {\n return 'backoff';\n } else if (closeEvent.code < 4300) {\n return 'retry';\n } else {\n // unknown error\n return 'refused';\n }\n },\n\n /**\n * Returns an error or null basing on the close event.\n *\n * Null is returned when connection was closed cleanly. Otherwise, an object\n * with error details is returned.\n *\n * @param {CloseEvent} closeEvent\n * @return {Object} error object\n */\n getCloseError: function(closeEvent): any {\n if (closeEvent.code !== 1000 && closeEvent.code !== 1001) {\n return {\n type: 'PusherError',\n data: {\n code: closeEvent.code,\n message: closeEvent.reason || closeEvent.message\n }\n };\n } else {\n return null;\n }\n }\n};\n\nexport default Protocol;\n","import * as Collections from '../utils/collections';\nimport { default as EventsDispatcher } from '../events/dispatcher';\nimport Protocol from './protocol/protocol';\nimport { PusherEvent } from './protocol/message-types';\nimport Logger from '../logger';\nimport TransportConnection from '../transports/transport_connection';\nimport Socket from '../socket';\n/**\n * Provides Pusher protocol interface for transports.\n *\n * Emits following events:\n * - message - on received messages\n * - ping - on ping requests\n * - pong - on pong responses\n * - error - when the transport emits an error\n * - closed - after closing the transport\n *\n * It also emits more events when connection closes with a code.\n * See Protocol.getCloseAction to get more details.\n *\n * @param {Number} id\n * @param {AbstractTransport} transport\n */\nexport default class Connection extends EventsDispatcher implements Socket {\n id: string;\n transport: TransportConnection;\n activityTimeout: number;\n\n constructor(id: string, transport: TransportConnection) {\n super();\n this.id = id;\n this.transport = transport;\n this.activityTimeout = transport.activityTimeout;\n this.bindListeners();\n }\n\n /** Returns whether used transport handles activity checks by itself\n *\n * @returns {Boolean} true if activity checks are handled by the transport\n */\n handlesActivityChecks() {\n return this.transport.handlesActivityChecks();\n }\n\n /** Sends raw data.\n *\n * @param {String} data\n */\n send(data: any): boolean {\n return this.transport.send(data);\n }\n\n /** Sends an event.\n *\n * @param {String} name\n * @param {String} data\n * @param {String} [channel]\n * @returns {Boolean} whether message was sent or not\n */\n send_event(name: string, data: any, channel?: string): boolean {\n var event: PusherEvent = { event: name, data: data };\n if (channel) {\n event.channel = channel;\n }\n Logger.debug('Event sent', event);\n return this.send(Protocol.encodeMessage(event));\n }\n\n /** Sends a ping message to the server.\n *\n * Basing on the underlying transport, it might send either transport's\n * protocol-specific ping or pusher:ping event.\n */\n ping() {\n if (this.transport.supportsPing()) {\n this.transport.ping();\n } else {\n this.send_event('pusher:ping', {});\n }\n }\n\n /** Closes the connection. */\n close() {\n this.transport.close();\n }\n\n private bindListeners() {\n var listeners = {\n message: (messageEvent: MessageEvent) => {\n var pusherEvent;\n try {\n pusherEvent = Protocol.decodeMessage(messageEvent);\n } catch (e) {\n this.emit('error', {\n type: 'MessageParseError',\n error: e,\n data: messageEvent.data\n });\n }\n\n if (pusherEvent !== undefined) {\n Logger.debug('Event recd', pusherEvent);\n\n switch (pusherEvent.event) {\n case 'pusher:error':\n this.emit('error', {\n type: 'PusherError',\n data: pusherEvent.data\n });\n break;\n case 'pusher:ping':\n this.emit('ping');\n break;\n case 'pusher:pong':\n this.emit('pong');\n break;\n }\n this.emit('message', pusherEvent);\n }\n },\n activity: () => {\n this.emit('activity');\n },\n error: error => {\n this.emit('error', error);\n },\n closed: closeEvent => {\n unbindListeners();\n\n if (closeEvent && closeEvent.code) {\n this.handleCloseEvent(closeEvent);\n }\n\n this.transport = null;\n this.emit('closed');\n }\n };\n\n var unbindListeners = () => {\n Collections.objectApply(listeners, (listener, event) => {\n this.transport.unbind(event, listener);\n });\n };\n\n Collections.objectApply(listeners, (listener, event) => {\n this.transport.bind(event, listener);\n });\n }\n\n private handleCloseEvent(closeEvent: any) {\n var action = Protocol.getCloseAction(closeEvent);\n var error = Protocol.getCloseError(closeEvent);\n if (error) {\n this.emit('error', error);\n }\n if (action) {\n this.emit(action, { action: action, error: error });\n }\n }\n}\n","import Util from '../../util';\nimport * as Collections from '../../utils/collections';\nimport Protocol from '../protocol/protocol';\nimport Connection from '../connection';\nimport TransportConnection from '../../transports/transport_connection';\nimport HandshakePayload from './handshake_payload';\n\n/**\n * Handles Pusher protocol handshakes for transports.\n *\n * Calls back with a result object after handshake is completed. Results\n * always have two fields:\n * - action - string describing action to be taken after the handshake\n * - transport - the transport object passed to the constructor\n *\n * Different actions can set different additional properties on the result.\n * In the case of 'connected' action, there will be a 'connection' property\n * containing a Connection object for the transport. Other actions should\n * carry an 'error' property.\n *\n * @param {AbstractTransport} transport\n * @param {Function} callback\n */\nexport default class Handshake {\n transport: TransportConnection;\n callback: (HandshakePayload) => void;\n onMessage: Function;\n onClosed: Function;\n\n constructor(\n transport: TransportConnection,\n callback: (HandshakePayload) => void\n ) {\n this.transport = transport;\n this.callback = callback;\n this.bindListeners();\n }\n\n close() {\n this.unbindListeners();\n this.transport.close();\n }\n\n private bindListeners() {\n this.onMessage = m => {\n this.unbindListeners();\n\n var result;\n try {\n result = Protocol.processHandshake(m);\n } catch (e) {\n this.finish('error', { error: e });\n this.transport.close();\n return;\n }\n\n if (result.action === 'connected') {\n this.finish('connected', {\n connection: new Connection(result.id, this.transport),\n activityTimeout: result.activityTimeout\n });\n } else {\n this.finish(result.action, { error: result.error });\n this.transport.close();\n }\n };\n\n this.onClosed = closeEvent => {\n this.unbindListeners();\n\n var action = Protocol.getCloseAction(closeEvent) || 'backoff';\n var error = Protocol.getCloseError(closeEvent);\n this.finish(action, { error: error });\n };\n\n this.transport.bind('message', this.onMessage);\n this.transport.bind('closed', this.onClosed);\n }\n\n private unbindListeners() {\n this.transport.unbind('message', this.onMessage);\n this.transport.unbind('closed', this.onClosed);\n }\n\n private finish(action: string, params: any) {\n this.callback(\n Collections.extend({ transport: this.transport, action: action }, params)\n );\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport base64encode from '../base64';\nimport Timeline from './timeline';\nimport Runtime from 'runtime';\n\nexport interface TimelineSenderOptions {\n host?: string;\n port?: number;\n path?: string;\n}\n\nexport default class TimelineSender {\n timeline: Timeline;\n options: TimelineSenderOptions;\n host: string;\n\n constructor(timeline: Timeline, options: TimelineSenderOptions) {\n this.timeline = timeline;\n this.options = options || {};\n }\n\n send(useTLS: boolean, callback?: Function) {\n if (this.timeline.isEmpty()) {\n return;\n }\n\n this.timeline.send(\n Runtime.TimelineTransport.getAgent(this, useTLS),\n callback\n );\n }\n}\n","import { default as EventsDispatcher } from '../events/dispatcher';\nimport * as Errors from '../errors';\nimport Logger from '../logger';\nimport Pusher from '../pusher';\nimport { PusherEvent } from '../connection/protocol/message-types';\nimport Metadata from './metadata';\nimport UrlStore from '../utils/url_store';\nimport {\n ChannelAuthorizationData,\n ChannelAuthorizationCallback\n} from '../auth/options';\nimport { HTTPAuthError } from '../errors';\n\n/** Provides base public channel interface with an event emitter.\n *\n * Emits:\n * - pusher:subscription_succeeded - after subscribing successfully\n * - other non-internal events\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\nexport default class Channel extends EventsDispatcher {\n name: string;\n pusher: Pusher;\n subscribed: boolean;\n subscriptionPending: boolean;\n subscriptionCancelled: boolean;\n subscriptionCount: null;\n\n constructor(name: string, pusher: Pusher) {\n super(function(event, data) {\n Logger.debug('No callbacks on ' + name + ' for ' + event);\n });\n\n this.name = name;\n this.pusher = pusher;\n this.subscribed = false;\n this.subscriptionPending = false;\n this.subscriptionCancelled = false;\n }\n\n /** Skips authorization, since public channels don't require it.\n *\n * @param {Function} callback\n */\n authorize(socketId: string, callback: ChannelAuthorizationCallback) {\n return callback(null, { auth: '' });\n }\n\n /** Triggers an event */\n trigger(event: string, data: any) {\n if (event.indexOf('client-') !== 0) {\n throw new Errors.BadEventName(\n \"Event '\" + event + \"' does not start with 'client-'\"\n );\n }\n if (!this.subscribed) {\n var suffix = UrlStore.buildLogSuffix('triggeringClientEvents');\n Logger.warn(\n `Client event triggered before channel 'subscription_succeeded' event . ${suffix}`\n );\n }\n return this.pusher.send_event(event, data, this.name);\n }\n\n /** Signals disconnection to the channel. For internal use only. */\n disconnect() {\n this.subscribed = false;\n this.subscriptionPending = false;\n }\n\n /** Handles a PusherEvent. For internal use only.\n *\n * @param {PusherEvent} event\n */\n handleEvent(event: PusherEvent) {\n var eventName = event.event;\n var data = event.data;\n if (eventName === 'pusher_internal:subscription_succeeded') {\n this.handleSubscriptionSucceededEvent(event);\n } else if (eventName === 'pusher_internal:subscription_count') {\n this.handleSubscriptionCountEvent(event);\n } else if (eventName.indexOf('pusher_internal:') !== 0) {\n var metadata: Metadata = {};\n this.emit(eventName, data, metadata);\n }\n }\n\n handleSubscriptionSucceededEvent(event: PusherEvent) {\n this.subscriptionPending = false;\n this.subscribed = true;\n if (this.subscriptionCancelled) {\n this.pusher.unsubscribe(this.name);\n } else {\n this.emit('pusher:subscription_succeeded', event.data);\n }\n }\n\n handleSubscriptionCountEvent(event: PusherEvent) {\n if (event.data.subscription_count) {\n this.subscriptionCount = event.data.subscription_count;\n }\n\n this.emit('pusher:subscription_count', event.data);\n }\n\n /** Sends a subscription request. For internal use only. */\n subscribe() {\n if (this.subscribed) {\n return;\n }\n this.subscriptionPending = true;\n this.subscriptionCancelled = false;\n this.authorize(\n this.pusher.connection.socket_id,\n (error: Error | null, data: ChannelAuthorizationData) => {\n if (error) {\n this.subscriptionPending = false;\n // Why not bind to 'pusher:subscription_error' a level up, and log there?\n // Binding to this event would cause the warning about no callbacks being\n // bound (see constructor) to be suppressed, that's not what we want.\n Logger.error(error.toString());\n this.emit(\n 'pusher:subscription_error',\n Object.assign(\n {},\n {\n type: 'AuthError',\n error: error.message\n },\n error instanceof HTTPAuthError ? { status: error.status } : {}\n )\n );\n } else {\n this.pusher.send_event('pusher:subscribe', {\n auth: data.auth,\n channel_data: data.channel_data,\n channel: this.name\n });\n }\n }\n );\n }\n\n /** Sends an unsubscription request. For internal use only. */\n unsubscribe() {\n this.subscribed = false;\n this.pusher.send_event('pusher:unsubscribe', {\n channel: this.name\n });\n }\n\n /** Cancels an in progress subscription. For internal use only. */\n cancelSubscription() {\n this.subscriptionCancelled = true;\n }\n\n /** Reinstates an in progress subscripiton. For internal use only. */\n reinstateSubscription() {\n this.subscriptionCancelled = false;\n }\n}\n","import Factory from '../utils/factory';\nimport Channel from './channel';\nimport { ChannelAuthorizationCallback } from '../auth/options';\n\n/** Extends public channels to provide private channel interface.\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\nexport default class PrivateChannel extends Channel {\n /** Authorizes the connection to use the channel.\n *\n * @param {String} socketId\n * @param {Function} callback\n */\n authorize(socketId: string, callback: ChannelAuthorizationCallback) {\n return this.pusher.config.channelAuthorizer(\n {\n channelName: this.name,\n socketId: socketId\n },\n callback\n );\n }\n}\n","import * as Collections from '../utils/collections';\n\n/** Represents a collection of members of a presence channel. */\nexport default class Members {\n members: any;\n count: number;\n myID: any;\n me: any;\n\n constructor() {\n this.reset();\n }\n\n /** Returns member's info for given id.\n *\n * Resulting object containts two fields - id and info.\n *\n * @param {Number} id\n * @return {Object} member's info or null\n */\n get(id: string): any {\n if (Object.prototype.hasOwnProperty.call(this.members, id)) {\n return {\n id: id,\n info: this.members[id]\n };\n } else {\n return null;\n }\n }\n\n /** Calls back for each member in unspecified order.\n *\n * @param {Function} callback\n */\n each(callback: Function) {\n Collections.objectApply(this.members, (member, id) => {\n callback(this.get(id));\n });\n }\n\n /** Updates the id for connected member. For internal use only. */\n setMyID(id: string) {\n this.myID = id;\n }\n\n /** Handles subscription data. For internal use only. */\n onSubscription(subscriptionData: any) {\n this.members = subscriptionData.presence.hash;\n this.count = subscriptionData.presence.count;\n this.me = this.get(this.myID);\n }\n\n /** Adds a new member to the collection. For internal use only. */\n addMember(memberData: any) {\n if (this.get(memberData.user_id) === null) {\n this.count++;\n }\n this.members[memberData.user_id] = memberData.user_info;\n return this.get(memberData.user_id);\n }\n\n /** Adds a member from the collection. For internal use only. */\n removeMember(memberData: any) {\n var member = this.get(memberData.user_id);\n if (member) {\n delete this.members[memberData.user_id];\n this.count--;\n }\n return member;\n }\n\n /** Resets the collection to the initial state. For internal use only. */\n reset() {\n this.members = {};\n this.count = 0;\n this.myID = null;\n this.me = null;\n }\n}\n","import PrivateChannel from './private_channel';\nimport Logger from '../logger';\nimport Members from './members';\nimport Pusher from '../pusher';\nimport UrlStore from 'core/utils/url_store';\nimport { PusherEvent } from '../connection/protocol/message-types';\nimport Metadata from './metadata';\nimport { ChannelAuthorizationData } from '../auth/options';\n\nexport default class PresenceChannel extends PrivateChannel {\n members: Members;\n\n /** Adds presence channel functionality to private channels.\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\n constructor(name: string, pusher: Pusher) {\n super(name, pusher);\n this.members = new Members();\n }\n\n /** Authorizes the connection as a member of the channel.\n *\n * @param {String} socketId\n * @param {Function} callback\n */\n authorize(socketId: string, callback: Function) {\n super.authorize(socketId, async (error, authData) => {\n if (!error) {\n authData = authData as ChannelAuthorizationData;\n if (authData.channel_data != null) {\n var channelData = JSON.parse(authData.channel_data);\n this.members.setMyID(channelData.user_id);\n } else {\n await this.pusher.user.signinDonePromise;\n if (this.pusher.user.user_data != null) {\n // If the user is signed in, get the id of the authenticated user\n // and allow the presence authorization to continue.\n this.members.setMyID(this.pusher.user.user_data.id);\n } else {\n let suffix = UrlStore.buildLogSuffix('authorizationEndpoint');\n Logger.error(\n `Invalid auth response for channel '${this.name}', ` +\n `expected 'channel_data' field. ${suffix}, ` +\n `or the user should be signed in.`\n );\n callback('Invalid auth response');\n return;\n }\n }\n }\n callback(error, authData);\n });\n }\n\n /** Handles presence and subscription events. For internal use only.\n *\n * @param {PusherEvent} event\n */\n handleEvent(event: PusherEvent) {\n var eventName = event.event;\n if (eventName.indexOf('pusher_internal:') === 0) {\n this.handleInternalEvent(event);\n } else {\n var data = event.data;\n var metadata: Metadata = {};\n if (event.user_id) {\n metadata.user_id = event.user_id;\n }\n this.emit(eventName, data, metadata);\n }\n }\n handleInternalEvent(event: PusherEvent) {\n var eventName = event.event;\n var data = event.data;\n switch (eventName) {\n case 'pusher_internal:subscription_succeeded':\n this.handleSubscriptionSucceededEvent(event);\n break;\n case 'pusher_internal:subscription_count':\n this.handleSubscriptionCountEvent(event);\n break;\n case 'pusher_internal:member_added':\n var addedMember = this.members.addMember(data);\n this.emit('pusher:member_added', addedMember);\n break;\n case 'pusher_internal:member_removed':\n var removedMember = this.members.removeMember(data);\n if (removedMember) {\n this.emit('pusher:member_removed', removedMember);\n }\n break;\n }\n }\n\n handleSubscriptionSucceededEvent(event: PusherEvent) {\n this.subscriptionPending = false;\n this.subscribed = true;\n if (this.subscriptionCancelled) {\n this.pusher.unsubscribe(this.name);\n } else {\n this.members.onSubscription(event.data);\n this.emit('pusher:subscription_succeeded', this.members);\n }\n }\n\n /** Resets the channel state, including members map. For internal use only. */\n disconnect() {\n this.members.reset();\n super.disconnect();\n }\n}\n","import PrivateChannel from './private_channel';\nimport * as Errors from '../errors';\nimport Logger from '../logger';\nimport Pusher from '../pusher';\nimport { decode as encodeUTF8 } from '@stablelib/utf8';\nimport { decode as decodeBase64 } from '@stablelib/base64';\nimport Dispatcher from '../events/dispatcher';\nimport { PusherEvent } from '../connection/protocol/message-types';\nimport {\n ChannelAuthorizationData,\n ChannelAuthorizationCallback\n} from '../auth/options';\nimport * as nacl from 'tweetnacl';\n\n/** Extends private channels to provide encrypted channel interface.\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\nexport default class EncryptedChannel extends PrivateChannel {\n key: Uint8Array = null;\n nacl: nacl;\n\n constructor(name: string, pusher: Pusher, nacl: nacl) {\n super(name, pusher);\n this.nacl = nacl;\n }\n\n /** Authorizes the connection to use the channel.\n *\n * @param {String} socketId\n * @param {Function} callback\n */\n authorize(socketId: string, callback: ChannelAuthorizationCallback) {\n super.authorize(\n socketId,\n (error: Error | null, authData: ChannelAuthorizationData) => {\n if (error) {\n callback(error, authData);\n return;\n }\n let sharedSecret = authData['shared_secret'];\n if (!sharedSecret) {\n callback(\n new Error(\n `No shared_secret key in auth payload for encrypted channel: ${this.name}`\n ),\n null\n );\n return;\n }\n this.key = decodeBase64(sharedSecret);\n delete authData['shared_secret'];\n callback(null, authData);\n }\n );\n }\n\n trigger(event: string, data: any): boolean {\n throw new Errors.UnsupportedFeature(\n 'Client events are not currently supported for encrypted channels'\n );\n }\n\n /** Handles an event. For internal use only.\n *\n * @param {PusherEvent} event\n */\n handleEvent(event: PusherEvent) {\n var eventName = event.event;\n var data = event.data;\n if (\n eventName.indexOf('pusher_internal:') === 0 ||\n eventName.indexOf('pusher:') === 0\n ) {\n super.handleEvent(event);\n return;\n }\n this.handleEncryptedEvent(eventName, data);\n }\n\n private handleEncryptedEvent(event: string, data: any): void {\n if (!this.key) {\n Logger.debug(\n 'Received encrypted event before key has been retrieved from the authEndpoint'\n );\n return;\n }\n if (!data.ciphertext || !data.nonce) {\n Logger.error(\n 'Unexpected format for encrypted event, expected object with `ciphertext` and `nonce` fields, got: ' +\n data\n );\n return;\n }\n let cipherText = decodeBase64(data.ciphertext);\n if (cipherText.length < this.nacl.secretbox.overheadLength) {\n Logger.error(\n `Expected encrypted event ciphertext length to be ${this.nacl.secretbox.overheadLength}, got: ${cipherText.length}`\n );\n return;\n }\n let nonce = decodeBase64(data.nonce);\n if (nonce.length < this.nacl.secretbox.nonceLength) {\n Logger.error(\n `Expected encrypted event nonce length to be ${this.nacl.secretbox.nonceLength}, got: ${nonce.length}`\n );\n return;\n }\n\n let bytes = this.nacl.secretbox.open(cipherText, nonce, this.key);\n if (bytes === null) {\n Logger.debug(\n 'Failed to decrypt an event, probably because it was encrypted with a different key. Fetching a new key from the authEndpoint...'\n );\n // Try a single time to retrieve a new auth key and decrypt the event with it\n // If this fails, a new key will be requested when a new message is received\n this.authorize(this.pusher.connection.socket_id, (error, authData) => {\n if (error) {\n Logger.error(\n `Failed to make a request to the authEndpoint: ${authData}. Unable to fetch new key, so dropping encrypted event`\n );\n return;\n }\n bytes = this.nacl.secretbox.open(cipherText, nonce, this.key);\n if (bytes === null) {\n Logger.error(\n `Failed to decrypt event with new key. Dropping encrypted event`\n );\n return;\n }\n this.emit(event, this.getDataToEmit(bytes));\n return;\n });\n return;\n }\n this.emit(event, this.getDataToEmit(bytes));\n }\n\n // Try and parse the decrypted bytes as JSON. If we can't parse it, just\n // return the utf-8 string\n getDataToEmit(bytes: Uint8Array): string {\n let raw = encodeUTF8(bytes);\n try {\n return JSON.parse(raw);\n } catch {\n return raw;\n }\n }\n}\n","import { default as EventsDispatcher } from '../events/dispatcher';\nimport { OneOffTimer as Timer } from '../utils/timers';\nimport { Config } from '../config';\nimport Logger from '../logger';\nimport HandshakePayload from './handshake/handshake_payload';\nimport Connection from './connection';\nimport Strategy from '../strategies/strategy';\nimport StrategyRunner from '../strategies/strategy_runner';\nimport * as Collections from '../utils/collections';\nimport Timeline from '../timeline/timeline';\nimport ConnectionManagerOptions from './connection_manager_options';\nimport Runtime from 'runtime';\n\nimport {\n ErrorCallbacks,\n HandshakeCallbacks,\n ConnectionCallbacks\n} from './callbacks';\nimport Action from './protocol/action';\n\n/** Manages connection to Pusher.\n *\n * Uses a strategy (currently only default), timers and network availability\n * info to establish a connection and export its state. In case of failures,\n * manages reconnection attempts.\n *\n * Exports state changes as following events:\n * - \"state_change\", { previous: p, current: state }\n * - state\n *\n * States:\n * - initialized - initial state, never transitioned to\n * - connecting - connection is being established\n * - connected - connection has been fully established\n * - disconnected - on requested disconnection\n * - unavailable - after connection timeout or when there's no network\n * - failed - when the connection strategy is not supported\n *\n * Options:\n * - unavailableTimeout - time to transition to unavailable state\n * - activityTimeout - time after which ping message should be sent\n * - pongTimeout - time for Pusher to respond with pong before reconnecting\n *\n * @param {String} key application key\n * @param {Object} options\n */\nexport default class ConnectionManager extends EventsDispatcher {\n key: string;\n options: ConnectionManagerOptions;\n state: string;\n connection: Connection;\n usingTLS: boolean;\n timeline: Timeline;\n socket_id: string;\n unavailableTimer: Timer;\n activityTimer: Timer;\n retryTimer: Timer;\n activityTimeout: number;\n strategy: Strategy;\n runner: StrategyRunner;\n errorCallbacks: ErrorCallbacks;\n handshakeCallbacks: HandshakeCallbacks;\n connectionCallbacks: ConnectionCallbacks;\n\n constructor(key: string, options: ConnectionManagerOptions) {\n super();\n this.state = 'initialized';\n this.connection = null;\n\n this.key = key;\n this.options = options;\n this.timeline = this.options.timeline;\n this.usingTLS = this.options.useTLS;\n\n this.errorCallbacks = this.buildErrorCallbacks();\n this.connectionCallbacks = this.buildConnectionCallbacks(\n this.errorCallbacks\n );\n this.handshakeCallbacks = this.buildHandshakeCallbacks(this.errorCallbacks);\n\n var Network = Runtime.getNetwork();\n\n Network.bind('online', () => {\n this.timeline.info({ netinfo: 'online' });\n if (this.state === 'connecting' || this.state === 'unavailable') {\n this.retryIn(0);\n }\n });\n Network.bind('offline', () => {\n this.timeline.info({ netinfo: 'offline' });\n if (this.connection) {\n this.sendActivityCheck();\n }\n });\n\n this.updateStrategy();\n }\n\n switchCluster(key: string) {\n this.key = key;\n // This ensures that the new config coming from\n // pusher instance are taken into account\n // such as appKey and cluster\n this.updateStrategy();\n this.retryIn(0);\n }\n\n /** Establishes a connection to Pusher.\n *\n * Does nothing when connection is already established. See top-level doc\n * to find events emitted on connection attempts.\n */\n connect() {\n if (this.connection || this.runner) {\n return;\n }\n if (!this.strategy.isSupported()) {\n this.updateState('failed');\n return;\n }\n this.updateState('connecting');\n this.startConnecting();\n this.setUnavailableTimer();\n }\n\n /** Sends raw data.\n *\n * @param {String} data\n */\n send(data) {\n if (this.connection) {\n return this.connection.send(data);\n } else {\n return false;\n }\n }\n\n /** Sends an event.\n *\n * @param {String} name\n * @param {String} data\n * @param {String} [channel]\n * @returns {Boolean} whether message was sent or not\n */\n send_event(name: string, data: any, channel?: string) {\n if (this.connection) {\n return this.connection.send_event(name, data, channel);\n } else {\n return false;\n }\n }\n\n /** Closes the connection. */\n disconnect() {\n this.disconnectInternally();\n this.updateState('disconnected');\n }\n\n isUsingTLS() {\n return this.usingTLS;\n }\n\n private startConnecting() {\n var callback = (error, handshake) => {\n if (error) {\n this.runner = this.strategy.connect(0, callback);\n } else {\n if (handshake.action === 'error') {\n this.emit('error', {\n type: 'HandshakeError',\n error: handshake.error\n });\n this.timeline.error({ handshakeError: handshake.error });\n } else {\n this.abortConnecting(); // we don't support switching connections yet\n this.handshakeCallbacks[handshake.action](handshake);\n }\n }\n };\n this.runner = this.strategy.connect(0, callback);\n }\n\n private abortConnecting() {\n if (this.runner) {\n this.runner.abort();\n this.runner = null;\n }\n }\n\n private disconnectInternally() {\n this.abortConnecting();\n this.clearRetryTimer();\n this.clearUnavailableTimer();\n if (this.connection) {\n var connection = this.abandonConnection();\n connection.close();\n }\n }\n\n private updateStrategy() {\n this.strategy = this.options.getStrategy({\n key: this.key,\n timeline: this.timeline,\n useTLS: this.usingTLS\n });\n }\n\n private retryIn(delay) {\n this.timeline.info({ action: 'retry', delay: delay });\n if (delay > 0) {\n this.emit('connecting_in', Math.round(delay / 1000));\n }\n this.retryTimer = new Timer(delay || 0, () => {\n this.disconnectInternally();\n this.connect();\n });\n }\n\n private clearRetryTimer() {\n if (this.retryTimer) {\n this.retryTimer.ensureAborted();\n this.retryTimer = null;\n }\n }\n\n private setUnavailableTimer() {\n this.unavailableTimer = new Timer(this.options.unavailableTimeout, () => {\n this.updateState('unavailable');\n });\n }\n\n private clearUnavailableTimer() {\n if (this.unavailableTimer) {\n this.unavailableTimer.ensureAborted();\n }\n }\n\n private sendActivityCheck() {\n this.stopActivityCheck();\n this.connection.ping();\n // wait for pong response\n this.activityTimer = new Timer(this.options.pongTimeout, () => {\n this.timeline.error({ pong_timed_out: this.options.pongTimeout });\n this.retryIn(0);\n });\n }\n\n private resetActivityCheck() {\n this.stopActivityCheck();\n // send ping after inactivity\n if (this.connection && !this.connection.handlesActivityChecks()) {\n this.activityTimer = new Timer(this.activityTimeout, () => {\n this.sendActivityCheck();\n });\n }\n }\n\n private stopActivityCheck() {\n if (this.activityTimer) {\n this.activityTimer.ensureAborted();\n }\n }\n\n private buildConnectionCallbacks(\n errorCallbacks: ErrorCallbacks\n ): ConnectionCallbacks {\n return Collections.extend({}, errorCallbacks, {\n message: message => {\n // includes pong messages from server\n this.resetActivityCheck();\n this.emit('message', message);\n },\n ping: () => {\n this.send_event('pusher:pong', {});\n },\n activity: () => {\n this.resetActivityCheck();\n },\n error: error => {\n // just emit error to user - socket will already be closed by browser\n this.emit('error', error);\n },\n closed: () => {\n this.abandonConnection();\n if (this.shouldRetry()) {\n this.retryIn(1000);\n }\n }\n });\n }\n\n private buildHandshakeCallbacks(\n errorCallbacks: ErrorCallbacks\n ): HandshakeCallbacks {\n return Collections.extend({}, errorCallbacks, {\n connected: (handshake: HandshakePayload) => {\n this.activityTimeout = Math.min(\n this.options.activityTimeout,\n handshake.activityTimeout,\n handshake.connection.activityTimeout || Infinity\n );\n this.clearUnavailableTimer();\n this.setConnection(handshake.connection);\n this.socket_id = this.connection.id;\n this.updateState('connected', { socket_id: this.socket_id });\n }\n });\n }\n\n private buildErrorCallbacks(): ErrorCallbacks {\n let withErrorEmitted = callback => {\n return (result: Action | HandshakePayload) => {\n if (result.error) {\n this.emit('error', { type: 'WebSocketError', error: result.error });\n }\n callback(result);\n };\n };\n\n return {\n tls_only: withErrorEmitted(() => {\n this.usingTLS = true;\n this.updateStrategy();\n this.retryIn(0);\n }),\n refused: withErrorEmitted(() => {\n this.disconnect();\n }),\n backoff: withErrorEmitted(() => {\n this.retryIn(1000);\n }),\n retry: withErrorEmitted(() => {\n this.retryIn(0);\n })\n };\n }\n\n private setConnection(connection) {\n this.connection = connection;\n for (var event in this.connectionCallbacks) {\n this.connection.bind(event, this.connectionCallbacks[event]);\n }\n this.resetActivityCheck();\n }\n\n private abandonConnection() {\n if (!this.connection) {\n return;\n }\n this.stopActivityCheck();\n for (var event in this.connectionCallbacks) {\n this.connection.unbind(event, this.connectionCallbacks[event]);\n }\n var connection = this.connection;\n this.connection = null;\n return connection;\n }\n\n private updateState(newState: string, data?: any) {\n var previousState = this.state;\n this.state = newState;\n if (previousState !== newState) {\n var newStateDescription = newState;\n if (newStateDescription === 'connected') {\n newStateDescription += ' with new socket ID ' + data.socket_id;\n }\n Logger.debug(\n 'State changed',\n previousState + ' -> ' + newStateDescription\n );\n this.timeline.info({ state: newState, params: data });\n this.emit('state_change', { previous: previousState, current: newState });\n this.emit(newState, data);\n }\n }\n\n private shouldRetry(): boolean {\n return this.state === 'connecting' || this.state === 'connected';\n }\n}\n","import Channel from './channel';\nimport * as Collections from '../utils/collections';\nimport ChannelTable from './channel_table';\nimport Factory from '../utils/factory';\nimport Pusher from '../pusher';\nimport Logger from '../logger';\nimport * as Errors from '../errors';\nimport urlStore from '../utils/url_store';\n\n/** Handles a channel map. */\nexport default class Channels {\n channels: ChannelTable;\n\n constructor() {\n this.channels = {};\n }\n\n /** Creates or retrieves an existing channel by its name.\n *\n * @param {String} name\n * @param {Pusher} pusher\n * @return {Channel}\n */\n add(name: string, pusher: Pusher) {\n if (!this.channels[name]) {\n this.channels[name] = createChannel(name, pusher);\n }\n return this.channels[name];\n }\n\n /** Returns a list of all channels\n *\n * @return {Array}\n */\n all(): Channel[] {\n return Collections.values(this.channels);\n }\n\n /** Finds a channel by its name.\n *\n * @param {String} name\n * @return {Channel} channel or null if it doesn't exist\n */\n find(name: string) {\n return this.channels[name];\n }\n\n /** Removes a channel from the map.\n *\n * @param {String} name\n */\n remove(name: string) {\n var channel = this.channels[name];\n delete this.channels[name];\n return channel;\n }\n\n /** Proxies disconnection signal to all channels. */\n disconnect() {\n Collections.objectApply(this.channels, function(channel) {\n channel.disconnect();\n });\n }\n}\n\nfunction createChannel(name: string, pusher: Pusher): Channel {\n if (name.indexOf('private-encrypted-') === 0) {\n if (pusher.config.nacl) {\n return Factory.createEncryptedChannel(name, pusher, pusher.config.nacl);\n }\n let errMsg =\n 'Tried to subscribe to a private-encrypted- channel but no nacl implementation available';\n let suffix = urlStore.buildLogSuffix('encryptedChannelSupport');\n throw new Errors.UnsupportedFeature(`${errMsg}. ${suffix}`);\n } else if (name.indexOf('private-') === 0) {\n return Factory.createPrivateChannel(name, pusher);\n } else if (name.indexOf('presence-') === 0) {\n return Factory.createPresenceChannel(name, pusher);\n } else if (name.indexOf('#') === 0) {\n throw new Errors.BadChannelName(\n 'Cannot create a channel with name \"' + name + '\".'\n );\n } else {\n return Factory.createChannel(name, pusher);\n }\n}\n","import AssistantToTheTransportManager from '../transports/assistant_to_the_transport_manager';\nimport PingDelayOptions from '../transports/ping_delay_options';\nimport Transport from '../transports/transport';\nimport TransportManager from '../transports/transport_manager';\nimport Handshake from '../connection/handshake';\nimport TransportConnection from '../transports/transport_connection';\nimport SocketHooks from '../http/socket_hooks';\nimport HTTPSocket from '../http/http_socket';\n\nimport Timeline from '../timeline/timeline';\nimport {\n default as TimelineSender,\n TimelineSenderOptions\n} from '../timeline/timeline_sender';\nimport PresenceChannel from '../channels/presence_channel';\nimport PrivateChannel from '../channels/private_channel';\nimport EncryptedChannel from '../channels/encrypted_channel';\nimport Channel from '../channels/channel';\nimport ConnectionManager from '../connection/connection_manager';\nimport ConnectionManagerOptions from '../connection/connection_manager_options';\nimport Ajax from '../http/ajax';\nimport Channels from '../channels/channels';\nimport Pusher from '../pusher';\nimport { Config } from '../config';\nimport * as nacl from 'tweetnacl';\n\nvar Factory = {\n createChannels(): Channels {\n return new Channels();\n },\n\n createConnectionManager(\n key: string,\n options: ConnectionManagerOptions\n ): ConnectionManager {\n return new ConnectionManager(key, options);\n },\n\n createChannel(name: string, pusher: Pusher): Channel {\n return new Channel(name, pusher);\n },\n\n createPrivateChannel(name: string, pusher: Pusher): PrivateChannel {\n return new PrivateChannel(name, pusher);\n },\n\n createPresenceChannel(name: string, pusher: Pusher): PresenceChannel {\n return new PresenceChannel(name, pusher);\n },\n\n createEncryptedChannel(\n name: string,\n pusher: Pusher,\n nacl: nacl\n ): EncryptedChannel {\n return new EncryptedChannel(name, pusher, nacl);\n },\n\n createTimelineSender(timeline: Timeline, options: TimelineSenderOptions) {\n return new TimelineSender(timeline, options);\n },\n\n createHandshake(\n transport: TransportConnection,\n callback: (HandshakePayload) => void\n ): Handshake {\n return new Handshake(transport, callback);\n },\n\n createAssistantToTheTransportManager(\n manager: TransportManager,\n transport: Transport,\n options: PingDelayOptions\n ): AssistantToTheTransportManager {\n return new AssistantToTheTransportManager(manager, transport, options);\n }\n};\n\nexport default Factory;\n","import AssistantToTheTransportManager from './assistant_to_the_transport_manager';\nimport Transport from './transport';\nimport PingDelayOptions from './ping_delay_options';\nimport Factory from '../utils/factory';\n\nexport interface TransportManagerOptions extends PingDelayOptions {\n lives?: number;\n}\n\n/** Keeps track of the number of lives left for a transport.\n *\n * In the beginning of a session, transports may be assigned a number of\n * lives. When an AssistantToTheTransportManager instance reports a transport\n * connection closed uncleanly, the transport loses a life. When the number\n * of lives drops to zero, the transport gets disabled by its manager.\n *\n * @param {Object} options\n */\nexport default class TransportManager {\n options: TransportManagerOptions;\n livesLeft: number;\n\n constructor(options: TransportManagerOptions) {\n this.options = options || {};\n this.livesLeft = this.options.lives || Infinity;\n }\n\n /** Creates a assistant for the transport.\n *\n * @param {Transport} transport\n * @returns {AssistantToTheTransportManager}\n */\n getAssistant(transport: Transport): AssistantToTheTransportManager {\n return Factory.createAssistantToTheTransportManager(this, transport, {\n minPingDelay: this.options.minPingDelay,\n maxPingDelay: this.options.maxPingDelay\n });\n }\n\n /** Returns whether the transport has any lives left.\n *\n * @returns {Boolean}\n */\n isAlive(): boolean {\n return this.livesLeft > 0;\n }\n\n /** Takes one life from the transport. */\n reportDeath() {\n this.livesLeft -= 1;\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport { OneOffTimer as Timer } from '../utils/timers';\nimport Strategy from './strategy';\nimport StrategyOptions from './strategy_options';\n\n/** Loops through strategies with optional timeouts.\n *\n * Options:\n * - loop - whether it should loop through the substrategy list\n * - timeout - initial timeout for a single substrategy\n * - timeoutLimit - maximum timeout\n *\n * @param {Strategy[]} strategies\n * @param {Object} options\n */\nexport default class SequentialStrategy implements Strategy {\n strategies: Strategy[];\n loop: boolean;\n failFast: boolean;\n timeout: number;\n timeoutLimit: number;\n\n constructor(strategies: Strategy[], options: StrategyOptions) {\n this.strategies = strategies;\n this.loop = Boolean(options.loop);\n this.failFast = Boolean(options.failFast);\n this.timeout = options.timeout;\n this.timeoutLimit = options.timeoutLimit;\n }\n\n isSupported(): boolean {\n return Collections.any(this.strategies, Util.method('isSupported'));\n }\n\n connect(minPriority: number, callback: Function) {\n var strategies = this.strategies;\n var current = 0;\n var timeout = this.timeout;\n var runner = null;\n\n var tryNextStrategy = (error, handshake) => {\n if (handshake) {\n callback(null, handshake);\n } else {\n current = current + 1;\n if (this.loop) {\n current = current % strategies.length;\n }\n\n if (current < strategies.length) {\n if (timeout) {\n timeout = timeout * 2;\n if (this.timeoutLimit) {\n timeout = Math.min(timeout, this.timeoutLimit);\n }\n }\n runner = this.tryStrategy(\n strategies[current],\n minPriority,\n { timeout, failFast: this.failFast },\n tryNextStrategy\n );\n } else {\n callback(true);\n }\n }\n };\n\n runner = this.tryStrategy(\n strategies[current],\n minPriority,\n { timeout: timeout, failFast: this.failFast },\n tryNextStrategy\n );\n\n return {\n abort: function() {\n runner.abort();\n },\n forceMinPriority: function(p) {\n minPriority = p;\n if (runner) {\n runner.forceMinPriority(p);\n }\n }\n };\n }\n\n private tryStrategy(\n strategy: Strategy,\n minPriority: number,\n options: StrategyOptions,\n callback: Function\n ) {\n var timer = null;\n var runner = null;\n\n if (options.timeout > 0) {\n timer = new Timer(options.timeout, function() {\n runner.abort();\n callback(true);\n });\n }\n\n runner = strategy.connect(minPriority, function(error, handshake) {\n if (error && timer && timer.isRunning() && !options.failFast) {\n // advance to the next strategy after the timeout\n return;\n }\n if (timer) {\n timer.ensureAborted();\n }\n callback(error, handshake);\n });\n\n return {\n abort: function() {\n if (timer) {\n timer.ensureAborted();\n }\n runner.abort();\n },\n forceMinPriority: function(p) {\n runner.forceMinPriority(p);\n }\n };\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport Strategy from './strategy';\n\n/** Launches all substrategies and emits prioritized connected transports.\n *\n * @param {Array} strategies\n */\nexport default class BestConnectedEverStrategy implements Strategy {\n strategies: Strategy[];\n\n constructor(strategies: Strategy[]) {\n this.strategies = strategies;\n }\n\n isSupported(): boolean {\n return Collections.any(this.strategies, Util.method('isSupported'));\n }\n\n connect(minPriority: number, callback: Function) {\n return connect(this.strategies, minPriority, function(i, runners) {\n return function(error, handshake) {\n runners[i].error = error;\n if (error) {\n if (allRunnersFailed(runners)) {\n callback(true);\n }\n return;\n }\n Collections.apply(runners, function(runner) {\n runner.forceMinPriority(handshake.transport.priority);\n });\n callback(null, handshake);\n };\n });\n }\n}\n\n/** Connects to all strategies in parallel.\n *\n * Callback builder should be a function that takes two arguments: index\n * and a list of runners. It should return another function that will be\n * passed to the substrategy with given index. Runners can be aborted using\n * abortRunner(s) functions from this class.\n *\n * @param {Array} strategies\n * @param {Function} callbackBuilder\n * @return {Object} strategy runner\n */\nfunction connect(\n strategies: Strategy[],\n minPriority: number,\n callbackBuilder: Function\n) {\n var runners = Collections.map(strategies, function(strategy, i, _, rs) {\n return strategy.connect(minPriority, callbackBuilder(i, rs));\n });\n return {\n abort: function() {\n Collections.apply(runners, abortRunner);\n },\n forceMinPriority: function(p) {\n Collections.apply(runners, function(runner) {\n runner.forceMinPriority(p);\n });\n }\n };\n}\n\nfunction allRunnersFailed(runners): boolean {\n return Collections.all(runners, function(runner) {\n return Boolean(runner.error);\n });\n}\n\nfunction abortRunner(runner) {\n if (!runner.error && !runner.aborted) {\n runner.abort();\n runner.aborted = true;\n }\n}\n","import Util from '../util';\nimport Runtime from 'runtime';\nimport Strategy from './strategy';\nimport SequentialStrategy from './sequential_strategy';\nimport StrategyOptions from './strategy_options';\nimport TransportStrategy from './transport_strategy';\nimport Timeline from '../timeline/timeline';\nimport * as Collections from '../utils/collections';\n\nexport interface TransportStrategyDictionary {\n [key: string]: TransportStrategy;\n}\n\n/** Caches the last successful transport and, after the first few attempts,\n * uses the cached transport for subsequent attempts.\n *\n * @param {Strategy} strategy\n * @param {Object} transports\n * @param {Object} options\n */\nexport default class WebSocketPrioritizedCachedStrategy implements Strategy {\n strategy: Strategy;\n transports: TransportStrategyDictionary;\n ttl: number;\n usingTLS: boolean;\n timeline: Timeline;\n\n constructor(\n strategy: Strategy,\n transports: TransportStrategyDictionary,\n options: StrategyOptions\n ) {\n this.strategy = strategy;\n this.transports = transports;\n this.ttl = options.ttl || 1800 * 1000;\n this.usingTLS = options.useTLS;\n this.timeline = options.timeline;\n }\n\n isSupported(): boolean {\n return this.strategy.isSupported();\n }\n\n connect(minPriority: number, callback: Function) {\n var usingTLS = this.usingTLS;\n var info = fetchTransportCache(usingTLS);\n var cacheSkipCount = info && info.cacheSkipCount ? info.cacheSkipCount : 0;\n\n var strategies = [this.strategy];\n if (info && info.timestamp + this.ttl >= Util.now()) {\n var transport = this.transports[info.transport];\n if (transport) {\n if (['ws', 'wss'].includes(info.transport) || cacheSkipCount > 3) {\n this.timeline.info({\n cached: true,\n transport: info.transport,\n latency: info.latency\n });\n strategies.push(\n new SequentialStrategy([transport], {\n timeout: info.latency * 2 + 1000,\n failFast: true\n })\n );\n } else {\n cacheSkipCount++;\n }\n }\n }\n\n var startTimestamp = Util.now();\n var runner = strategies\n .pop()\n .connect(minPriority, function cb(error, handshake) {\n if (error) {\n flushTransportCache(usingTLS);\n if (strategies.length > 0) {\n startTimestamp = Util.now();\n runner = strategies.pop().connect(minPriority, cb);\n } else {\n callback(error);\n }\n } else {\n storeTransportCache(\n usingTLS,\n handshake.transport.name,\n Util.now() - startTimestamp,\n cacheSkipCount\n );\n callback(null, handshake);\n }\n });\n\n return {\n abort: function() {\n runner.abort();\n },\n forceMinPriority: function(p) {\n minPriority = p;\n if (runner) {\n runner.forceMinPriority(p);\n }\n }\n };\n }\n}\n\nfunction getTransportCacheKey(usingTLS: boolean): string {\n return 'pusherTransport' + (usingTLS ? 'TLS' : 'NonTLS');\n}\n\nfunction fetchTransportCache(usingTLS: boolean): any {\n var storage = Runtime.getLocalStorage();\n if (storage) {\n try {\n var serializedCache = storage[getTransportCacheKey(usingTLS)];\n if (serializedCache) {\n return JSON.parse(serializedCache);\n }\n } catch (e) {\n flushTransportCache(usingTLS);\n }\n }\n return null;\n}\n\nfunction storeTransportCache(\n usingTLS: boolean,\n transport: TransportStrategy,\n latency: number,\n cacheSkipCount: number\n) {\n var storage = Runtime.getLocalStorage();\n if (storage) {\n try {\n storage[getTransportCacheKey(usingTLS)] = Collections.safeJSONStringify({\n timestamp: Util.now(),\n transport: transport,\n latency: latency,\n cacheSkipCount: cacheSkipCount\n });\n } catch (e) {\n // catch over quota exceptions raised by localStorage\n }\n }\n}\n\nfunction flushTransportCache(usingTLS: boolean) {\n var storage = Runtime.getLocalStorage();\n if (storage) {\n try {\n delete storage[getTransportCacheKey(usingTLS)];\n } catch (e) {\n // catch exceptions raised by localStorage\n }\n }\n}\n","import { OneOffTimer as Timer } from '../utils/timers';\nimport Strategy from './strategy';\nimport StrategyOptions from './strategy_options';\n\n/** Runs substrategy after specified delay.\n *\n * Options:\n * - delay - time in miliseconds to delay the substrategy attempt\n *\n * @param {Strategy} strategy\n * @param {Object} options\n */\nexport default class DelayedStrategy implements Strategy {\n strategy: Strategy;\n options: { delay: number };\n\n constructor(strategy: Strategy, { delay: number }) {\n this.strategy = strategy;\n this.options = { delay: number };\n }\n\n isSupported(): boolean {\n return this.strategy.isSupported();\n }\n\n connect(minPriority: number, callback: Function) {\n var strategy = this.strategy;\n var runner;\n var timer = new Timer(this.options.delay, function() {\n runner = strategy.connect(minPriority, callback);\n });\n\n return {\n abort: function() {\n timer.ensureAborted();\n if (runner) {\n runner.abort();\n }\n },\n forceMinPriority: function(p) {\n minPriority = p;\n if (runner) {\n runner.forceMinPriority(p);\n }\n }\n };\n }\n}\n","import Strategy from './strategy';\nimport StrategyRunner from './strategy_runner';\n\n/** Proxies method calls to one of substrategies basing on the test function.\n *\n * @param {Function} test\n * @param {Strategy} trueBranch strategy used when test returns true\n * @param {Strategy} falseBranch strategy used when test returns false\n */\nexport default class IfStrategy implements Strategy {\n test: () => boolean;\n trueBranch: Strategy;\n falseBranch: Strategy;\n\n constructor(\n test: () => boolean,\n trueBranch: Strategy,\n falseBranch: Strategy\n ) {\n this.test = test;\n this.trueBranch = trueBranch;\n this.falseBranch = falseBranch;\n }\n\n isSupported(): boolean {\n var branch = this.test() ? this.trueBranch : this.falseBranch;\n return branch.isSupported();\n }\n\n connect(minPriority: number, callback: Function): StrategyRunner {\n var branch = this.test() ? this.trueBranch : this.falseBranch;\n return branch.connect(minPriority, callback);\n }\n}\n","import Strategy from './strategy';\nimport StrategyRunner from './strategy_runner';\n\n/** Launches the substrategy and terminates on the first open connection.\n *\n * @param {Strategy} strategy\n */\nexport default class FirstConnectedStrategy implements Strategy {\n strategy: Strategy;\n\n constructor(strategy: Strategy) {\n this.strategy = strategy;\n }\n\n isSupported(): boolean {\n return this.strategy.isSupported();\n }\n\n connect(minPriority: number, callback: Function): StrategyRunner {\n var runner = this.strategy.connect(minPriority, function(error, handshake) {\n if (handshake) {\n runner.abort();\n }\n callback(error, handshake);\n });\n return runner;\n }\n}\n","import * as Collections from 'core/utils/collections';\nimport TransportManager from 'core/transports/transport_manager';\nimport Strategy from 'core/strategies/strategy';\nimport StrategyOptions from 'core/strategies/strategy_options';\nimport SequentialStrategy from 'core/strategies/sequential_strategy';\nimport BestConnectedEverStrategy from 'core/strategies/best_connected_ever_strategy';\nimport WebSocketPrioritizedCachedStrategy, {\n TransportStrategyDictionary\n} from 'core/strategies/websocket_prioritized_cached_strategy';\nimport DelayedStrategy from 'core/strategies/delayed_strategy';\nimport IfStrategy from 'core/strategies/if_strategy';\nimport FirstConnectedStrategy from 'core/strategies/first_connected_strategy';\nimport { Config } from 'core/config';\n\nfunction testSupportsStrategy(strategy: Strategy) {\n return function() {\n return strategy.isSupported();\n };\n}\n\nvar getDefaultStrategy = function(\n config: Config,\n baseOptions: StrategyOptions,\n defineTransport: Function\n): Strategy {\n var definedTransports = {};\n\n function defineTransportStrategy(\n name: string,\n type: string,\n priority: number,\n options: StrategyOptions,\n manager?: TransportManager\n ) {\n var transport = defineTransport(\n config,\n name,\n type,\n priority,\n options,\n manager\n );\n\n definedTransports[name] = transport;\n\n return transport;\n }\n\n var ws_options: StrategyOptions = Object.assign({}, baseOptions, {\n hostNonTLS: config.wsHost + ':' + config.wsPort,\n hostTLS: config.wsHost + ':' + config.wssPort,\n httpPath: config.wsPath\n });\n var wss_options: StrategyOptions = Object.assign({}, ws_options, {\n useTLS: true\n });\n var sockjs_options: StrategyOptions = Object.assign({}, baseOptions, {\n hostNonTLS: config.httpHost + ':' + config.httpPort,\n hostTLS: config.httpHost + ':' + config.httpsPort,\n httpPath: config.httpPath\n });\n\n var timeouts = {\n loop: true,\n timeout: 15000,\n timeoutLimit: 60000\n };\n\n var ws_manager = new TransportManager({\n minPingDelay: 10000,\n maxPingDelay: config.activityTimeout\n });\n var streaming_manager = new TransportManager({\n lives: 2,\n minPingDelay: 10000,\n maxPingDelay: config.activityTimeout\n });\n\n var ws_transport = defineTransportStrategy(\n 'ws',\n 'ws',\n 3,\n ws_options,\n ws_manager\n );\n var wss_transport = defineTransportStrategy(\n 'wss',\n 'ws',\n 3,\n wss_options,\n ws_manager\n );\n var sockjs_transport = defineTransportStrategy(\n 'sockjs',\n 'sockjs',\n 1,\n sockjs_options\n );\n var xhr_streaming_transport = defineTransportStrategy(\n 'xhr_streaming',\n 'xhr_streaming',\n 1,\n sockjs_options,\n streaming_manager\n );\n var xdr_streaming_transport = defineTransportStrategy(\n 'xdr_streaming',\n 'xdr_streaming',\n 1,\n sockjs_options,\n streaming_manager\n );\n var xhr_polling_transport = defineTransportStrategy(\n 'xhr_polling',\n 'xhr_polling',\n 1,\n sockjs_options\n );\n var xdr_polling_transport = defineTransportStrategy(\n 'xdr_polling',\n 'xdr_polling',\n 1,\n sockjs_options\n );\n\n var ws_loop = new SequentialStrategy([ws_transport], timeouts);\n var wss_loop = new SequentialStrategy([wss_transport], timeouts);\n var sockjs_loop = new SequentialStrategy([sockjs_transport], timeouts);\n var streaming_loop = new SequentialStrategy(\n [\n new IfStrategy(\n testSupportsStrategy(xhr_streaming_transport),\n xhr_streaming_transport,\n xdr_streaming_transport\n )\n ],\n timeouts\n );\n var polling_loop = new SequentialStrategy(\n [\n new IfStrategy(\n testSupportsStrategy(xhr_polling_transport),\n xhr_polling_transport,\n xdr_polling_transport\n )\n ],\n timeouts\n );\n\n var http_loop = new SequentialStrategy(\n [\n new IfStrategy(\n testSupportsStrategy(streaming_loop),\n new BestConnectedEverStrategy([\n streaming_loop,\n new DelayedStrategy(polling_loop, { delay: 4000 })\n ]),\n polling_loop\n )\n ],\n timeouts\n );\n\n var http_fallback_loop = new IfStrategy(\n testSupportsStrategy(http_loop),\n http_loop,\n sockjs_loop\n );\n\n var wsStrategy;\n if (baseOptions.useTLS) {\n wsStrategy = new BestConnectedEverStrategy([\n ws_loop,\n new DelayedStrategy(http_fallback_loop, { delay: 2000 })\n ]);\n } else {\n wsStrategy = new BestConnectedEverStrategy([\n ws_loop,\n new DelayedStrategy(wss_loop, { delay: 2000 }),\n new DelayedStrategy(http_fallback_loop, { delay: 5000 })\n ]);\n }\n\n return new WebSocketPrioritizedCachedStrategy(\n new FirstConnectedStrategy(\n new IfStrategy(\n testSupportsStrategy(ws_transport),\n wsStrategy,\n http_fallback_loop\n )\n ),\n definedTransports,\n {\n ttl: 1800000,\n timeline: baseOptions.timeline,\n useTLS: baseOptions.useTLS\n }\n );\n};\n\nexport default getDefaultStrategy;\n","import { Dependencies } from '../dom/dependencies';\n\n/** Initializes the transport.\n *\n * Fetches resources if needed and then transitions to initialized.\n */\nexport default function() {\n var self = this;\n\n self.timeline.info(\n self.buildTimelineMessage({\n transport: self.name + (self.options.useTLS ? 's' : '')\n })\n );\n\n if (self.hooks.isInitialized()) {\n self.changeState('initialized');\n } else if (self.hooks.file) {\n self.changeState('initializing');\n Dependencies.load(\n self.hooks.file,\n { useTLS: self.options.useTLS },\n function(error, callback) {\n if (self.hooks.isInitialized()) {\n self.changeState('initialized');\n callback(true);\n } else {\n if (error) {\n self.onError(error);\n }\n self.onClose();\n callback(false);\n }\n }\n );\n } else {\n self.onClose();\n }\n}\n","import HTTPRequest from 'core/http/http_request';\nimport RequestHooks from 'core/http/request_hooks';\nimport Ajax from 'core/http/ajax';\nimport * as Errors from 'core/errors';\n\nvar hooks: RequestHooks = {\n getRequest: function(socket: HTTPRequest): Ajax {\n var xdr = new (window).XDomainRequest();\n xdr.ontimeout = function() {\n socket.emit('error', new Errors.RequestTimedOut());\n socket.close();\n };\n xdr.onerror = function(e) {\n socket.emit('error', e);\n socket.close();\n };\n xdr.onprogress = function() {\n if (xdr.responseText && xdr.responseText.length > 0) {\n socket.onChunk(200, xdr.responseText);\n }\n };\n xdr.onload = function() {\n if (xdr.responseText && xdr.responseText.length > 0) {\n socket.onChunk(200, xdr.responseText);\n }\n socket.emit('finished', 200);\n socket.close();\n };\n return xdr;\n },\n abortRequest: function(xdr: Ajax) {\n xdr.ontimeout = xdr.onerror = xdr.onprogress = xdr.onload = null;\n xdr.abort();\n }\n};\n\nexport default hooks;\n","import Runtime from 'runtime';\nimport RequestHooks from './request_hooks';\nimport Ajax from './ajax';\nimport { default as EventsDispatcher } from '../events/dispatcher';\n\nconst MAX_BUFFER_LENGTH = 256 * 1024;\n\nexport default class HTTPRequest extends EventsDispatcher {\n hooks: RequestHooks;\n method: string;\n url: string;\n position: number;\n xhr: Ajax;\n unloader: Function;\n\n constructor(hooks: RequestHooks, method: string, url: string) {\n super();\n this.hooks = hooks;\n this.method = method;\n this.url = url;\n }\n\n start(payload?: any) {\n this.position = 0;\n this.xhr = this.hooks.getRequest(this);\n\n this.unloader = () => {\n this.close();\n };\n Runtime.addUnloadListener(this.unloader);\n\n this.xhr.open(this.method, this.url, true);\n\n if (this.xhr.setRequestHeader) {\n this.xhr.setRequestHeader('Content-Type', 'application/json'); // ReactNative doesn't set this header by default.\n }\n this.xhr.send(payload);\n }\n\n close() {\n if (this.unloader) {\n Runtime.removeUnloadListener(this.unloader);\n this.unloader = null;\n }\n if (this.xhr) {\n this.hooks.abortRequest(this.xhr);\n this.xhr = null;\n }\n }\n\n onChunk(status: number, data: any) {\n while (true) {\n var chunk = this.advanceBuffer(data);\n if (chunk) {\n this.emit('chunk', { status: status, data: chunk });\n } else {\n break;\n }\n }\n if (this.isBufferTooLong(data)) {\n this.emit('buffer_too_long');\n }\n }\n\n private advanceBuffer(buffer: any[]): any {\n var unreadData = buffer.slice(this.position);\n var endOfLinePosition = unreadData.indexOf('\\n');\n\n if (endOfLinePosition !== -1) {\n this.position += endOfLinePosition + 1;\n return unreadData.slice(0, endOfLinePosition);\n } else {\n // chunk is not finished yet, don't move the buffer pointer\n return null;\n }\n }\n\n private isBufferTooLong(buffer: any): boolean {\n return this.position === buffer.length && buffer.length > MAX_BUFFER_LENGTH;\n }\n}\n","enum State {\n CONNECTING = 0,\n OPEN = 1,\n CLOSED = 3\n}\n\nexport default State;\n","import URLLocation from './url_location';\nimport State from './state';\nimport Socket from '../socket';\nimport SocketHooks from './socket_hooks';\nimport Util from '../util';\nimport Ajax from './ajax';\nimport HTTPRequest from './http_request';\nimport Runtime from 'runtime';\n\nvar autoIncrement = 1;\n\nclass HTTPSocket implements Socket {\n hooks: SocketHooks;\n session: string;\n location: URLLocation;\n readyState: State;\n stream: HTTPRequest;\n\n onopen: () => void;\n onerror: (error: any) => void;\n onclose: (closeEvent: any) => void;\n onmessage: (message: any) => void;\n onactivity: () => void;\n\n constructor(hooks: SocketHooks, url: string) {\n this.hooks = hooks;\n this.session = randomNumber(1000) + '/' + randomString(8);\n this.location = getLocation(url);\n this.readyState = State.CONNECTING;\n this.openStream();\n }\n\n send(payload: any) {\n return this.sendRaw(JSON.stringify([payload]));\n }\n\n ping() {\n this.hooks.sendHeartbeat(this);\n }\n\n close(code: any, reason: any) {\n this.onClose(code, reason, true);\n }\n\n /** For internal use only */\n sendRaw(payload: any): boolean {\n if (this.readyState === State.OPEN) {\n try {\n Runtime.createSocketRequest(\n 'POST',\n getUniqueURL(getSendURL(this.location, this.session))\n ).start(payload);\n return true;\n } catch (e) {\n return false;\n }\n } else {\n return false;\n }\n }\n\n /** For internal use only */\n reconnect() {\n this.closeStream();\n this.openStream();\n }\n\n /** For internal use only */\n onClose(code, reason, wasClean) {\n this.closeStream();\n this.readyState = State.CLOSED;\n if (this.onclose) {\n this.onclose({\n code: code,\n reason: reason,\n wasClean: wasClean\n });\n }\n }\n\n private onChunk(chunk) {\n if (chunk.status !== 200) {\n return;\n }\n if (this.readyState === State.OPEN) {\n this.onActivity();\n }\n\n var payload;\n var type = chunk.data.slice(0, 1);\n switch (type) {\n case 'o':\n payload = JSON.parse(chunk.data.slice(1) || '{}');\n this.onOpen(payload);\n break;\n case 'a':\n payload = JSON.parse(chunk.data.slice(1) || '[]');\n for (var i = 0; i < payload.length; i++) {\n this.onEvent(payload[i]);\n }\n break;\n case 'm':\n payload = JSON.parse(chunk.data.slice(1) || 'null');\n this.onEvent(payload);\n break;\n case 'h':\n this.hooks.onHeartbeat(this);\n break;\n case 'c':\n payload = JSON.parse(chunk.data.slice(1) || '[]');\n this.onClose(payload[0], payload[1], true);\n break;\n }\n }\n\n private onOpen(options) {\n if (this.readyState === State.CONNECTING) {\n if (options && options.hostname) {\n this.location.base = replaceHost(this.location.base, options.hostname);\n }\n this.readyState = State.OPEN;\n\n if (this.onopen) {\n this.onopen();\n }\n } else {\n this.onClose(1006, 'Server lost session', true);\n }\n }\n\n private onEvent(event) {\n if (this.readyState === State.OPEN && this.onmessage) {\n this.onmessage({ data: event });\n }\n }\n\n private onActivity() {\n if (this.onactivity) {\n this.onactivity();\n }\n }\n\n private onError(error) {\n if (this.onerror) {\n this.onerror(error);\n }\n }\n\n private openStream() {\n this.stream = Runtime.createSocketRequest(\n 'POST',\n getUniqueURL(this.hooks.getReceiveURL(this.location, this.session))\n );\n\n this.stream.bind('chunk', chunk => {\n this.onChunk(chunk);\n });\n this.stream.bind('finished', status => {\n this.hooks.onFinished(this, status);\n });\n this.stream.bind('buffer_too_long', () => {\n this.reconnect();\n });\n\n try {\n this.stream.start();\n } catch (error) {\n Util.defer(() => {\n this.onError(error);\n this.onClose(1006, 'Could not start streaming', false);\n });\n }\n }\n\n private closeStream() {\n if (this.stream) {\n this.stream.unbind_all();\n this.stream.close();\n this.stream = null;\n }\n }\n}\n\nfunction getLocation(url): URLLocation {\n var parts = /([^\\?]*)\\/*(\\??.*)/.exec(url);\n return {\n base: parts[1],\n queryString: parts[2]\n };\n}\n\nfunction getSendURL(url: URLLocation, session: string): string {\n return url.base + '/' + session + '/xhr_send';\n}\n\nfunction getUniqueURL(url: string): string {\n var separator = url.indexOf('?') === -1 ? '?' : '&';\n return url + separator + 't=' + +new Date() + '&n=' + autoIncrement++;\n}\n\nfunction replaceHost(url: string, hostname: string): string {\n var urlParts = /(https?:\\/\\/)([^\\/:]+)((\\/|:)?.*)/.exec(url);\n return urlParts[1] + hostname + urlParts[3];\n}\n\nfunction randomNumber(max: number): number {\n return Runtime.randomInt(max);\n}\n\nfunction randomString(length: number): string {\n var result = [];\n\n for (var i = 0; i < length; i++) {\n result.push(randomNumber(32).toString(32));\n }\n\n return result.join('');\n}\n\nexport default HTTPSocket;\n","import SocketHooks from './socket_hooks';\nimport HTTPSocket from './http_socket';\n\nvar hooks: SocketHooks = {\n getReceiveURL: function(url, session) {\n return url.base + '/' + session + '/xhr_streaming' + url.queryString;\n },\n onHeartbeat: function(socket) {\n socket.sendRaw('[]');\n },\n sendHeartbeat: function(socket) {\n socket.sendRaw('[]');\n },\n onFinished: function(socket, status) {\n socket.onClose(1006, 'Connection interrupted (' + status + ')', false);\n }\n};\n\nexport default hooks;\n","import SocketHooks from './socket_hooks';\nimport URLLocation from './url_location';\nimport HTTPSocket from './http_socket';\n\nvar hooks: SocketHooks = {\n getReceiveURL: function(url: URLLocation, session: string): string {\n return url.base + '/' + session + '/xhr' + url.queryString;\n },\n onHeartbeat: function() {\n // next HTTP request will reset server's activity timer\n },\n sendHeartbeat: function(socket) {\n socket.sendRaw('[]');\n },\n onFinished: function(socket, status) {\n if (status === 200) {\n socket.reconnect();\n } else {\n socket.onClose(1006, 'Connection interrupted (' + status + ')', false);\n }\n }\n};\n\nexport default hooks;\n","import HTTPRequest from 'core/http/http_request';\nimport RequestHooks from 'core/http/request_hooks';\nimport Ajax from 'core/http/ajax';\nimport Runtime from 'runtime';\n\nvar hooks: RequestHooks = {\n getRequest: function(socket: HTTPRequest): Ajax {\n var Constructor = Runtime.getXHRAPI();\n var xhr = new Constructor();\n xhr.onreadystatechange = xhr.onprogress = function() {\n switch (xhr.readyState) {\n case 3:\n if (xhr.responseText && xhr.responseText.length > 0) {\n socket.onChunk(xhr.status, xhr.responseText);\n }\n break;\n case 4:\n // this happens only on errors, never after calling close\n if (xhr.responseText && xhr.responseText.length > 0) {\n socket.onChunk(xhr.status, xhr.responseText);\n }\n socket.emit('finished', xhr.status);\n socket.close();\n break;\n }\n };\n return xhr;\n },\n abortRequest: function(xhr: Ajax) {\n xhr.onreadystatechange = null;\n xhr.abort();\n }\n};\n\nexport default hooks;\n","import HTTPRequest from 'core/http/http_request';\nimport HTTPSocket from 'core/http/http_socket';\nimport SocketHooks from 'core/http/socket_hooks';\nimport RequestHooks from 'core/http/request_hooks';\nimport streamingHooks from 'core/http/http_streaming_socket';\nimport pollingHooks from 'core/http/http_polling_socket';\nimport xhrHooks from './http_xhr_request';\nimport HTTPFactory from 'core/http/http_factory';\n\nvar HTTP: HTTPFactory = {\n createStreamingSocket(url: string): HTTPSocket {\n return this.createSocket(streamingHooks, url);\n },\n\n createPollingSocket(url: string): HTTPSocket {\n return this.createSocket(pollingHooks, url);\n },\n\n createSocket(hooks: SocketHooks, url: string): HTTPSocket {\n return new HTTPSocket(hooks, url);\n },\n\n createXHR(method: string, url: string): HTTPRequest {\n return this.createRequest(xhrHooks, method, url);\n },\n\n createRequest(hooks: RequestHooks, method: string, url: string): HTTPRequest {\n return new HTTPRequest(hooks, method, url);\n }\n};\n\nexport default HTTP;\n","import xdrHooks from './http_xdomain_request';\nimport HTTP from 'isomorphic/http/http';\n\nHTTP.createXDR = function(method, url) {\n return this.createRequest(xdrHooks, method, url);\n};\n\nexport default HTTP;\n","import Browser from './browser';\nimport { Dependencies, DependenciesReceivers } from './dom/dependencies';\nimport { AuthTransport, AuthTransports } from 'core/auth/auth_transports';\nimport xhrAuth from 'isomorphic/auth/xhr_auth';\nimport jsonpAuth from './auth/jsonp_auth';\nimport TimelineTransport from 'core/timeline/timeline_transport';\nimport TimelineSender from 'core/timeline/timeline_sender';\nimport ScriptRequest from './dom/script_request';\nimport JSONPRequest from './dom/jsonp_request';\nimport * as Collections from 'core/utils/collections';\nimport { ScriptReceivers } from './dom/script_receiver_factory';\nimport jsonpTimeline from './timeline/jsonp_timeline';\nimport Transports from './transports/transports';\nimport Ajax from 'core/http/ajax';\nimport { Network } from './net_info';\nimport getDefaultStrategy from './default_strategy';\nimport transportConnectionInitializer from './transports/transport_connection_initializer';\nimport HTTPFactory from './http/http';\nimport HTTPRequest from 'core/http/http_request';\n\nvar Runtime: Browser = {\n // for jsonp auth\n nextAuthCallbackID: 1,\n auth_callbacks: {},\n ScriptReceivers,\n DependenciesReceivers,\n getDefaultStrategy,\n Transports,\n transportConnectionInitializer,\n HTTPFactory,\n\n TimelineTransport: jsonpTimeline,\n\n getXHRAPI() {\n return window.XMLHttpRequest;\n },\n\n getWebSocketAPI() {\n return window.WebSocket || window.MozWebSocket;\n },\n\n setup(PusherClass): void {\n (window).Pusher = PusherClass; // JSONp requires Pusher to be in the global scope.\n var initializeOnDocumentBody = () => {\n this.onDocumentBody(PusherClass.ready);\n };\n if (!(window).JSON) {\n Dependencies.load('json2', {}, initializeOnDocumentBody);\n } else {\n initializeOnDocumentBody();\n }\n },\n\n getDocument(): Document {\n return document;\n },\n\n getProtocol(): string {\n return this.getDocument().location.protocol;\n },\n\n getAuthorizers(): AuthTransports {\n return { ajax: xhrAuth, jsonp: jsonpAuth };\n },\n\n onDocumentBody(callback: Function) {\n if (document.body) {\n callback();\n } else {\n setTimeout(() => {\n this.onDocumentBody(callback);\n }, 0);\n }\n },\n\n createJSONPRequest(url: string, data: any): JSONPRequest {\n return new JSONPRequest(url, data);\n },\n\n createScriptRequest(src: string): ScriptRequest {\n return new ScriptRequest(src);\n },\n\n getLocalStorage() {\n try {\n return window.localStorage;\n } catch (e) {\n return undefined;\n }\n },\n\n createXHR(): Ajax {\n if (this.getXHRAPI()) {\n return this.createXMLHttpRequest();\n } else {\n return this.createMicrosoftXHR();\n }\n },\n\n createXMLHttpRequest(): Ajax {\n var Constructor = this.getXHRAPI();\n return new Constructor();\n },\n\n createMicrosoftXHR(): Ajax {\n return new ActiveXObject('Microsoft.XMLHTTP');\n },\n\n getNetwork() {\n return Network;\n },\n\n createWebSocket(url: string): any {\n var Constructor = this.getWebSocketAPI();\n return new Constructor(url);\n },\n\n createSocketRequest(method: string, url: string): HTTPRequest {\n if (this.isXHRSupported()) {\n return this.HTTPFactory.createXHR(method, url);\n } else if (this.isXDRSupported(url.indexOf('https:') === 0)) {\n return this.HTTPFactory.createXDR(method, url);\n } else {\n throw 'Cross-origin HTTP requests are not supported';\n }\n },\n\n isXHRSupported(): boolean {\n var Constructor = this.getXHRAPI();\n return (\n Boolean(Constructor) && new Constructor().withCredentials !== undefined\n );\n },\n\n isXDRSupported(useTLS?: boolean): boolean {\n var protocol = useTLS ? 'https:' : 'http:';\n var documentProtocol = this.getProtocol();\n return (\n Boolean(window['XDomainRequest']) && documentProtocol === protocol\n );\n },\n\n addUnloadListener(listener: any) {\n if (window.addEventListener !== undefined) {\n window.addEventListener('unload', listener, false);\n } else if (window.attachEvent !== undefined) {\n window.attachEvent('onunload', listener);\n }\n },\n\n removeUnloadListener(listener: any) {\n if (window.addEventListener !== undefined) {\n window.removeEventListener('unload', listener, false);\n } else if (window.detachEvent !== undefined) {\n window.detachEvent('onunload', listener);\n }\n },\n\n randomInt(max: number): number {\n /**\n * Return values in the range of [0, 1[\n */\n const random = function() {\n const crypto = window.crypto || window['msCrypto'];\n const random = crypto.getRandomValues(new Uint32Array(1))[0];\n\n return random / 2 ** 32;\n };\n\n return Math.floor(random() * max);\n }\n};\n\nexport default Runtime;\n","enum TimelineLevel {\n ERROR = 3,\n INFO = 6,\n DEBUG = 7\n}\n\nexport default TimelineLevel;\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport { default as Level } from './level';\n\nexport interface TimelineOptions {\n level?: Level;\n limit?: number;\n version?: string;\n cluster?: string;\n features?: string[];\n params?: any;\n}\n\nexport default class Timeline {\n key: string;\n session: number;\n events: any[];\n options: TimelineOptions;\n sent: number;\n uniqueID: number;\n\n constructor(key: string, session: number, options: TimelineOptions) {\n this.key = key;\n this.session = session;\n this.events = [];\n this.options = options || {};\n this.sent = 0;\n this.uniqueID = 0;\n }\n\n log(level, event) {\n if (level <= this.options.level) {\n this.events.push(\n Collections.extend({}, event, { timestamp: Util.now() })\n );\n if (this.options.limit && this.events.length > this.options.limit) {\n this.events.shift();\n }\n }\n }\n\n error(event) {\n this.log(Level.ERROR, event);\n }\n\n info(event) {\n this.log(Level.INFO, event);\n }\n\n debug(event) {\n this.log(Level.DEBUG, event);\n }\n\n isEmpty() {\n return this.events.length === 0;\n }\n\n send(sendfn, callback) {\n var data = Collections.extend(\n {\n session: this.session,\n bundle: this.sent + 1,\n key: this.key,\n lib: 'js',\n version: this.options.version,\n cluster: this.options.cluster,\n features: this.options.features,\n timeline: this.events\n },\n this.options.params\n );\n\n this.events = [];\n sendfn(data, (error, result) => {\n if (!error) {\n this.sent++;\n }\n if (callback) {\n callback(error, result);\n }\n });\n\n return true;\n }\n\n generateUniqueID(): number {\n this.uniqueID++;\n return this.uniqueID;\n }\n}\n","import Factory from '../utils/factory';\nimport Util from '../util';\nimport * as Errors from '../errors';\nimport * as Collections from '../utils/collections';\nimport Strategy from './strategy';\nimport Transport from '../transports/transport';\nimport StrategyOptions from './strategy_options';\nimport Handshake from '../connection/handshake';\n\n/** Provides a strategy interface for transports.\n *\n * @param {String} name\n * @param {Number} priority\n * @param {Class} transport\n * @param {Object} options\n */\nexport default class TransportStrategy implements Strategy {\n name: string;\n priority: number;\n transport: Transport;\n options: StrategyOptions;\n\n constructor(\n name: string,\n priority: number,\n transport: Transport,\n options: StrategyOptions\n ) {\n this.name = name;\n this.priority = priority;\n this.transport = transport;\n this.options = options || {};\n }\n\n /** Returns whether the transport is supported in the browser.\n *\n * @returns {Boolean}\n */\n isSupported(): boolean {\n return this.transport.isSupported({\n useTLS: this.options.useTLS\n });\n }\n\n /** Launches a connection attempt and returns a strategy runner.\n *\n * @param {Function} callback\n * @return {Object} strategy runner\n */\n connect(minPriority: number, callback: Function) {\n if (!this.isSupported()) {\n return failAttempt(new Errors.UnsupportedStrategy(), callback);\n } else if (this.priority < minPriority) {\n return failAttempt(new Errors.TransportPriorityTooLow(), callback);\n }\n\n var connected = false;\n var transport = this.transport.createConnection(\n this.name,\n this.priority,\n this.options.key,\n this.options\n );\n var handshake = null;\n\n var onInitialized = function() {\n transport.unbind('initialized', onInitialized);\n transport.connect();\n };\n var onOpen = function() {\n handshake = Factory.createHandshake(transport, function(result) {\n connected = true;\n unbindListeners();\n callback(null, result);\n });\n };\n var onError = function(error) {\n unbindListeners();\n callback(error);\n };\n var onClosed = function() {\n unbindListeners();\n var serializedTransport;\n\n // The reason for this try/catch block is that on React Native\n // the WebSocket object is circular. Therefore transport.socket will\n // throw errors upon stringification. Collections.safeJSONStringify\n // discards circular references when serializing.\n serializedTransport = Collections.safeJSONStringify(transport);\n callback(new Errors.TransportClosed(serializedTransport));\n };\n\n var unbindListeners = function() {\n transport.unbind('initialized', onInitialized);\n transport.unbind('open', onOpen);\n transport.unbind('error', onError);\n transport.unbind('closed', onClosed);\n };\n\n transport.bind('initialized', onInitialized);\n transport.bind('open', onOpen);\n transport.bind('error', onError);\n transport.bind('closed', onClosed);\n\n // connect will be called automatically after initialization\n transport.initialize();\n\n return {\n abort: () => {\n if (connected) {\n return;\n }\n unbindListeners();\n if (handshake) {\n handshake.close();\n } else {\n transport.close();\n }\n },\n forceMinPriority: p => {\n if (connected) {\n return;\n }\n if (this.priority < p) {\n if (handshake) {\n handshake.close();\n } else {\n transport.close();\n }\n }\n }\n };\n }\n}\n\nfunction failAttempt(error: Error, callback: Function) {\n Util.defer(function() {\n callback(error);\n });\n return {\n abort: function() {},\n forceMinPriority: function() {}\n };\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport TransportManager from '../transports/transport_manager';\nimport * as Errors from '../errors';\nimport Strategy from './strategy';\nimport TransportStrategy from './transport_strategy';\nimport StrategyOptions from '../strategies/strategy_options';\nimport { Config } from '../config';\nimport Runtime from 'runtime';\n\nconst { Transports } = Runtime;\n\nexport var defineTransport = function(\n config: Config,\n name: string,\n type: string,\n priority: number,\n options: StrategyOptions,\n manager?: TransportManager\n): Strategy {\n var transportClass = Transports[type];\n if (!transportClass) {\n throw new Errors.UnsupportedTransport(type);\n }\n\n var enabled =\n (!config.enabledTransports ||\n Collections.arrayIndexOf(config.enabledTransports, name) !== -1) &&\n (!config.disabledTransports ||\n Collections.arrayIndexOf(config.disabledTransports, name) === -1);\n\n var transport;\n if (enabled) {\n options = Object.assign(\n { ignoreNullOrigin: config.ignoreNullOrigin },\n options\n );\n\n transport = new TransportStrategy(\n name,\n priority,\n manager ? manager.getAssistant(transportClass) : transportClass,\n options\n );\n } else {\n transport = UnsupportedStrategy;\n }\n\n return transport;\n};\n\nvar UnsupportedStrategy: Strategy = {\n isSupported: function() {\n return false;\n },\n connect: function(_, callback) {\n var deferred = Util.defer(function() {\n callback(new Errors.UnsupportedStrategy());\n });\n return {\n abort: function() {\n deferred.ensureAborted();\n },\n forceMinPriority: function() {}\n };\n }\n};\n","import ConnectionManager from './connection/connection_manager';\nimport {\n ChannelAuthorizationOptions,\n UserAuthenticationOptions\n} from './auth/options';\nimport {\n ChannelAuthorizerGenerator,\n DeprecatedAuthOptions\n} from './auth/deprecated_channel_authorizer';\nimport { AuthTransport, Transport } from './config';\nimport * as nacl from 'tweetnacl';\nimport Logger from './logger';\n\nexport interface Options {\n activityTimeout?: number;\n\n auth?: DeprecatedAuthOptions; // DEPRECATED use channelAuthorization instead\n authEndpoint?: string; // DEPRECATED use channelAuthorization instead\n authTransport?: AuthTransport; // DEPRECATED use channelAuthorization instead\n authorizer?: ChannelAuthorizerGenerator; // DEPRECATED use channelAuthorization instead\n\n channelAuthorization?: ChannelAuthorizationOptions;\n userAuthentication?: UserAuthenticationOptions;\n\n cluster: string;\n enableStats?: boolean;\n disableStats?: boolean;\n disabledTransports?: Transport[];\n enabledTransports?: Transport[];\n forceTLS?: boolean;\n httpHost?: string;\n httpPath?: string;\n httpPort?: number;\n httpsPort?: number;\n ignoreNullOrigin?: boolean;\n nacl?: nacl;\n pongTimeout?: number;\n statsHost?: string;\n timelineParams?: any;\n unavailableTimeout?: number;\n wsHost?: string;\n wsPath?: string;\n wsPort?: number;\n wssPort?: number;\n}\n\nexport interface ClusterOptions {\n appKey: string;\n cluster: string;\n}\n\nexport function validateOptions(options) {\n if (options == null) {\n throw 'You must pass an options object';\n }\n if (options.cluster == null) {\n throw 'Options object must provide a cluster';\n }\n if ('disableStats' in options) {\n Logger.warn(\n 'The disableStats option is deprecated in favor of enableStats'\n );\n }\n}\n","import {\n UserAuthenticationCallback,\n InternalAuthOptions,\n UserAuthenticationHandler,\n UserAuthenticationRequestParams,\n AuthRequestType\n} from './options';\n\nimport Runtime from 'runtime';\n\nconst composeChannelQuery = (\n params: UserAuthenticationRequestParams,\n authOptions: InternalAuthOptions\n) => {\n var query = 'socket_id=' + encodeURIComponent(params.socketId);\n\n for (var key in authOptions.params) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(authOptions.params[key]);\n }\n\n if (authOptions.paramsProvider != null) {\n let dynamicParams = authOptions.paramsProvider();\n for (var key in dynamicParams) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(dynamicParams[key]);\n }\n }\n\n return query;\n};\n\nconst UserAuthenticator = (\n authOptions: InternalAuthOptions\n): UserAuthenticationHandler => {\n if (typeof Runtime.getAuthorizers()[authOptions.transport] === 'undefined') {\n throw `'${authOptions.transport}' is not a recognized auth transport`;\n }\n\n return (\n params: UserAuthenticationRequestParams,\n callback: UserAuthenticationCallback\n ) => {\n const query = composeChannelQuery(params, authOptions);\n\n Runtime.getAuthorizers()[authOptions.transport](\n Runtime,\n query,\n authOptions,\n AuthRequestType.UserAuthentication,\n callback\n );\n };\n};\n\nexport default UserAuthenticator;\n","import {\n AuthRequestType,\n InternalAuthOptions,\n ChannelAuthorizationHandler,\n ChannelAuthorizationRequestParams,\n ChannelAuthorizationCallback\n} from './options';\n\nimport Runtime from 'runtime';\n\nconst composeChannelQuery = (\n params: ChannelAuthorizationRequestParams,\n authOptions: InternalAuthOptions\n) => {\n var query = 'socket_id=' + encodeURIComponent(params.socketId);\n\n query += '&channel_name=' + encodeURIComponent(params.channelName);\n\n for (var key in authOptions.params) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(authOptions.params[key]);\n }\n\n if (authOptions.paramsProvider != null) {\n let dynamicParams = authOptions.paramsProvider();\n for (var key in dynamicParams) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(dynamicParams[key]);\n }\n }\n\n return query;\n};\n\nconst ChannelAuthorizer = (\n authOptions: InternalAuthOptions\n): ChannelAuthorizationHandler => {\n if (typeof Runtime.getAuthorizers()[authOptions.transport] === 'undefined') {\n throw `'${authOptions.transport}' is not a recognized auth transport`;\n }\n\n return (\n params: ChannelAuthorizationRequestParams,\n callback: ChannelAuthorizationCallback\n ) => {\n const query = composeChannelQuery(params, authOptions);\n\n Runtime.getAuthorizers()[authOptions.transport](\n Runtime,\n query,\n authOptions,\n AuthRequestType.ChannelAuthorization,\n callback\n );\n };\n};\n\nexport default ChannelAuthorizer;\n","import Channel from '../channels/channel';\nimport {\n ChannelAuthorizationCallback,\n ChannelAuthorizationHandler,\n ChannelAuthorizationRequestParams,\n InternalAuthOptions\n} from './options';\n\nexport interface DeprecatedChannelAuthorizer {\n authorize(socketId: string, callback: ChannelAuthorizationCallback): void;\n}\n\nexport interface ChannelAuthorizerGenerator {\n (\n channel: Channel,\n options: DeprecatedAuthorizerOptions\n ): DeprecatedChannelAuthorizer;\n}\n\nexport interface DeprecatedAuthOptions {\n params?: any;\n headers?: any;\n}\n\nexport interface DeprecatedAuthorizerOptions {\n authTransport: 'ajax' | 'jsonp';\n authEndpoint: string;\n auth?: DeprecatedAuthOptions;\n}\n\nexport const ChannelAuthorizerProxy = (\n pusher,\n authOptions: InternalAuthOptions,\n channelAuthorizerGenerator: ChannelAuthorizerGenerator\n): ChannelAuthorizationHandler => {\n const deprecatedAuthorizerOptions: DeprecatedAuthorizerOptions = {\n authTransport: authOptions.transport,\n authEndpoint: authOptions.endpoint,\n auth: {\n params: authOptions.params,\n headers: authOptions.headers\n }\n };\n return (\n params: ChannelAuthorizationRequestParams,\n callback: ChannelAuthorizationCallback\n ) => {\n const channel = pusher.channel(params.channelName);\n // This line creates a new channel authorizer every time.\n // In the past, this was only done once per channel and reused.\n // We can do that again if we want to keep this behavior intact.\n const channelAuthorizer: DeprecatedChannelAuthorizer = channelAuthorizerGenerator(\n channel,\n deprecatedAuthorizerOptions\n );\n channelAuthorizer.authorize(params.socketId, callback);\n };\n};\n","import { Options } from './options';\nimport Defaults from './defaults';\nimport {\n ChannelAuthorizationHandler,\n UserAuthenticationHandler,\n ChannelAuthorizationOptions\n} from './auth/options';\nimport UserAuthenticator from './auth/user_authenticator';\nimport ChannelAuthorizer from './auth/channel_authorizer';\nimport { ChannelAuthorizerProxy } from './auth/deprecated_channel_authorizer';\nimport Runtime from 'runtime';\nimport * as nacl from 'tweetnacl';\n\nexport type AuthTransport = 'ajax' | 'jsonp';\nexport type Transport =\n | 'ws'\n | 'wss'\n | 'xhr_streaming'\n | 'xhr_polling'\n | 'sockjs';\n\nexport interface Config {\n // these are all 'required' config parameters, it's not necessary for the user\n // to set them, but they have configured defaults.\n activityTimeout: number;\n enableStats: boolean;\n httpHost: string;\n httpPath: string;\n httpPort: number;\n httpsPort: number;\n pongTimeout: number;\n statsHost: string;\n unavailableTimeout: number;\n useTLS: boolean;\n wsHost: string;\n wsPath: string;\n wsPort: number;\n wssPort: number;\n userAuthenticator: UserAuthenticationHandler;\n channelAuthorizer: ChannelAuthorizationHandler;\n\n // these are all optional parameters or overrrides. The customer can set these\n // but it's not strictly necessary\n forceTLS?: boolean;\n cluster?: string;\n disabledTransports?: Transport[];\n enabledTransports?: Transport[];\n ignoreNullOrigin?: boolean;\n nacl?: nacl;\n timelineParams?: any;\n}\n\n// getConfig mainly sets the defaults for the options that are not provided\nexport function getConfig(opts: Options, pusher): Config {\n let config: Config = {\n activityTimeout: opts.activityTimeout || Defaults.activityTimeout,\n cluster: opts.cluster,\n httpPath: opts.httpPath || Defaults.httpPath,\n httpPort: opts.httpPort || Defaults.httpPort,\n httpsPort: opts.httpsPort || Defaults.httpsPort,\n pongTimeout: opts.pongTimeout || Defaults.pongTimeout,\n statsHost: opts.statsHost || Defaults.stats_host,\n unavailableTimeout: opts.unavailableTimeout || Defaults.unavailableTimeout,\n wsPath: opts.wsPath || Defaults.wsPath,\n wsPort: opts.wsPort || Defaults.wsPort,\n wssPort: opts.wssPort || Defaults.wssPort,\n\n enableStats: getEnableStatsConfig(opts),\n httpHost: getHttpHost(opts),\n useTLS: shouldUseTLS(opts),\n wsHost: getWebsocketHost(opts),\n\n userAuthenticator: buildUserAuthenticator(opts),\n channelAuthorizer: buildChannelAuthorizer(opts, pusher)\n };\n\n if ('disabledTransports' in opts)\n config.disabledTransports = opts.disabledTransports;\n if ('enabledTransports' in opts)\n config.enabledTransports = opts.enabledTransports;\n if ('ignoreNullOrigin' in opts)\n config.ignoreNullOrigin = opts.ignoreNullOrigin;\n if ('timelineParams' in opts) config.timelineParams = opts.timelineParams;\n if ('nacl' in opts) {\n config.nacl = opts.nacl;\n }\n\n return config;\n}\n\nfunction getHttpHost(opts: Options): string {\n if (opts.httpHost) {\n return opts.httpHost;\n }\n if (opts.cluster) {\n return `sockjs-${opts.cluster}.pusher.com`;\n }\n return Defaults.httpHost;\n}\n\nfunction getWebsocketHost(opts: Options): string {\n if (opts.wsHost) {\n return opts.wsHost;\n }\n return getWebsocketHostFromCluster(opts.cluster);\n}\n\nfunction getWebsocketHostFromCluster(cluster: string): string {\n return `ws-${cluster}.pusher.com`;\n}\n\nfunction shouldUseTLS(opts: Options): boolean {\n if (Runtime.getProtocol() === 'https:') {\n return true;\n } else if (opts.forceTLS === false) {\n return false;\n }\n return true;\n}\n\n// if enableStats is set take the value\n// if disableStats is set take the inverse\n// otherwise default to false\nfunction getEnableStatsConfig(opts: Options): boolean {\n if ('enableStats' in opts) {\n return opts.enableStats;\n }\n if ('disableStats' in opts) {\n return !opts.disableStats;\n }\n return false;\n}\n\nfunction buildUserAuthenticator(opts: Options): UserAuthenticationHandler {\n const userAuthentication = {\n ...Defaults.userAuthentication,\n ...opts.userAuthentication\n };\n if (\n 'customHandler' in userAuthentication &&\n userAuthentication['customHandler'] != null\n ) {\n return userAuthentication['customHandler'];\n }\n\n return UserAuthenticator(userAuthentication);\n}\n\nfunction buildChannelAuth(opts: Options, pusher): ChannelAuthorizationOptions {\n let channelAuthorization: ChannelAuthorizationOptions;\n if ('channelAuthorization' in opts) {\n channelAuthorization = {\n ...Defaults.channelAuthorization,\n ...opts.channelAuthorization\n };\n } else {\n channelAuthorization = {\n transport: opts.authTransport || Defaults.authTransport,\n endpoint: opts.authEndpoint || Defaults.authEndpoint\n };\n if ('auth' in opts) {\n if ('params' in opts.auth) channelAuthorization.params = opts.auth.params;\n if ('headers' in opts.auth)\n channelAuthorization.headers = opts.auth.headers;\n }\n if ('authorizer' in opts)\n channelAuthorization.customHandler = ChannelAuthorizerProxy(\n pusher,\n channelAuthorization,\n opts.authorizer\n );\n }\n return channelAuthorization;\n}\n\nfunction buildChannelAuthorizer(\n opts: Options,\n pusher\n): ChannelAuthorizationHandler {\n const channelAuthorization = buildChannelAuth(opts, pusher);\n if (\n 'customHandler' in channelAuthorization &&\n channelAuthorization['customHandler'] != null\n ) {\n return channelAuthorization['customHandler'];\n }\n\n return ChannelAuthorizer(channelAuthorization);\n}\n","import Logger from './logger';\nimport Pusher from './pusher';\nimport EventsDispatcher from './events/dispatcher';\n\nexport default class WatchlistFacade extends EventsDispatcher {\n private pusher: Pusher;\n\n public constructor(pusher: Pusher) {\n super(function(eventName, data) {\n Logger.debug(`No callbacks on watchlist events for ${eventName}`);\n });\n\n this.pusher = pusher;\n this.bindWatchlistInternalEvent();\n }\n\n handleEvent(pusherEvent) {\n pusherEvent.data.events.forEach(watchlistEvent => {\n this.emit(watchlistEvent.name, watchlistEvent);\n });\n }\n\n private bindWatchlistInternalEvent() {\n this.pusher.connection.bind('message', pusherEvent => {\n var eventName = pusherEvent.event;\n if (eventName === 'pusher_internal:watchlist_events') {\n this.handleEvent(pusherEvent);\n }\n });\n }\n}\n","function flatPromise() {\n let resolve, reject;\n const promise = new Promise((res, rej) => {\n resolve = res;\n reject = rej;\n });\n return { promise, resolve, reject };\n}\n\nexport default flatPromise;\n","import Pusher from './pusher';\nimport Logger from './logger';\nimport {\n UserAuthenticationData,\n UserAuthenticationCallback\n} from './auth/options';\nimport Channel from './channels/channel';\nimport WatchlistFacade from './watchlist';\nimport EventsDispatcher from './events/dispatcher';\nimport flatPromise from './utils/flat_promise';\n\nexport default class UserFacade extends EventsDispatcher {\n pusher: Pusher;\n signin_requested: boolean = false;\n user_data: any = null;\n serverToUserChannel: Channel = null;\n signinDonePromise: Promise = null;\n watchlist: WatchlistFacade;\n private _signinDoneResolve: Function = null;\n\n public constructor(pusher: Pusher) {\n super(function(eventName, data) {\n Logger.debug('No callbacks on user for ' + eventName);\n });\n this.pusher = pusher;\n this.pusher.connection.bind('state_change', ({ previous, current }) => {\n if (previous !== 'connected' && current === 'connected') {\n this._signin();\n }\n if (previous === 'connected' && current !== 'connected') {\n this._cleanup();\n this._newSigninPromiseIfNeeded();\n }\n });\n\n this.watchlist = new WatchlistFacade(pusher);\n\n this.pusher.connection.bind('message', event => {\n var eventName = event.event;\n if (eventName === 'pusher:signin_success') {\n this._onSigninSuccess(event.data);\n }\n if (\n this.serverToUserChannel &&\n this.serverToUserChannel.name === event.channel\n ) {\n this.serverToUserChannel.handleEvent(event);\n }\n });\n }\n\n public signin() {\n if (this.signin_requested) {\n return;\n }\n\n this.signin_requested = true;\n this._signin();\n }\n\n private _signin() {\n if (!this.signin_requested) {\n return;\n }\n\n this._newSigninPromiseIfNeeded();\n\n if (this.pusher.connection.state !== 'connected') {\n // Signin will be attempted when the connection is connected\n return;\n }\n\n this.pusher.config.userAuthenticator(\n {\n socketId: this.pusher.connection.socket_id\n },\n this._onAuthorize\n );\n }\n\n private _onAuthorize: UserAuthenticationCallback = (\n err,\n authData: UserAuthenticationData\n ) => {\n if (err) {\n Logger.warn(`Error during signin: ${err}`);\n this._cleanup();\n return;\n }\n\n this.pusher.send_event('pusher:signin', {\n auth: authData.auth,\n user_data: authData.user_data\n });\n\n // Later when we get pusher:singin_success event, the user will be marked as signed in\n };\n\n private _onSigninSuccess(data: any) {\n try {\n this.user_data = JSON.parse(data.user_data);\n } catch (e) {\n Logger.error(`Failed parsing user data after signin: ${data.user_data}`);\n this._cleanup();\n return;\n }\n\n if (typeof this.user_data.id !== 'string' || this.user_data.id === '') {\n Logger.error(\n `user_data doesn't contain an id. user_data: ${this.user_data}`\n );\n this._cleanup();\n return;\n }\n\n // Signin succeeded\n this._signinDoneResolve();\n this._subscribeChannels();\n }\n\n private _subscribeChannels() {\n const ensure_subscribed = channel => {\n if (channel.subscriptionPending && channel.subscriptionCancelled) {\n channel.reinstateSubscription();\n } else if (\n !channel.subscriptionPending &&\n this.pusher.connection.state === 'connected'\n ) {\n channel.subscribe();\n }\n };\n\n this.serverToUserChannel = new Channel(\n `#server-to-user-${this.user_data.id}`,\n this.pusher\n );\n this.serverToUserChannel.bind_global((eventName, data) => {\n if (\n eventName.indexOf('pusher_internal:') === 0 ||\n eventName.indexOf('pusher:') === 0\n ) {\n // ignore internal events\n return;\n }\n this.emit(eventName, data);\n });\n ensure_subscribed(this.serverToUserChannel);\n }\n\n private _cleanup() {\n this.user_data = null;\n if (this.serverToUserChannel) {\n this.serverToUserChannel.unbind_all();\n this.serverToUserChannel.disconnect();\n this.serverToUserChannel = null;\n }\n\n if (this.signin_requested) {\n // If signin is in progress and cleanup is called,\n // Mark the current signin process as done.\n this._signinDoneResolve();\n }\n }\n\n private _newSigninPromiseIfNeeded() {\n if (!this.signin_requested) {\n return;\n }\n\n // If there is a promise and it is not resolved, return without creating a new one.\n if (this.signinDonePromise && !(this.signinDonePromise as any).done) {\n return;\n }\n\n // This promise is never rejected.\n // It gets resolved when the signin process is done whether it failed or succeeded\n const { promise, resolve, reject: _ } = flatPromise();\n (promise as any).done = false;\n const setDone = () => {\n (promise as any).done = true;\n };\n promise.then(setDone).catch(setDone);\n this.signinDonePromise = promise;\n this._signinDoneResolve = resolve;\n }\n}\n","import AbstractRuntime from '../runtimes/interface';\nimport Runtime from 'runtime';\nimport * as Collections from './utils/collections';\nimport Channels from './channels/channels';\nimport Channel from './channels/channel';\nimport { default as EventsDispatcher } from './events/dispatcher';\nimport Timeline from './timeline/timeline';\nimport TimelineSender from './timeline/timeline_sender';\nimport TimelineLevel from './timeline/level';\nimport { defineTransport } from './strategies/strategy_builder';\nimport ConnectionManager from './connection/connection_manager';\nimport { PeriodicTimer } from './utils/timers';\nimport Defaults from './defaults';\nimport Logger from './logger';\nimport Factory from './utils/factory';\nimport { Options, ClusterOptions, validateOptions } from './options';\nimport { Config, getConfig } from './config';\nimport StrategyOptions from './strategies/strategy_options';\nimport UserFacade from './user';\n\nexport default class Pusher {\n /* STATIC PROPERTIES */\n static instances: Pusher[] = [];\n static isReady: boolean = false;\n static logToConsole: boolean = false;\n\n // for jsonp\n static Runtime: AbstractRuntime = Runtime;\n static ScriptReceivers: any = (Runtime).ScriptReceivers;\n static DependenciesReceivers: any = (Runtime).DependenciesReceivers;\n static auth_callbacks: any = (Runtime).auth_callbacks;\n\n static ready() {\n Pusher.isReady = true;\n for (var i = 0, l = Pusher.instances.length; i < l; i++) {\n Pusher.instances[i].connect();\n }\n }\n\n static log: (message: any) => void;\n\n private static getClientFeatures(): string[] {\n return Collections.keys(\n Collections.filterObject({ ws: Runtime.Transports.ws }, function(t) {\n return t.isSupported({});\n })\n );\n }\n\n /* INSTANCE PROPERTIES */\n key: string;\n options: Options;\n config: Config;\n channels: Channels;\n global_emitter: EventsDispatcher;\n sessionID: number;\n timeline: Timeline;\n timelineSender: TimelineSender;\n connection: ConnectionManager;\n timelineSenderTimer: PeriodicTimer;\n user: UserFacade;\n constructor(app_key: string, options: Options) {\n checkAppKey(app_key);\n validateOptions(options);\n this.key = app_key;\n this.config = getConfig(options, this);\n\n this.channels = Factory.createChannels();\n this.global_emitter = new EventsDispatcher();\n this.sessionID = Runtime.randomInt(1000000000);\n\n this.timeline = new Timeline(this.key, this.sessionID, {\n cluster: this.config.cluster,\n features: Pusher.getClientFeatures(),\n params: this.config.timelineParams || {},\n limit: 50,\n level: TimelineLevel.INFO,\n version: Defaults.VERSION\n });\n if (this.config.enableStats) {\n this.timelineSender = Factory.createTimelineSender(this.timeline, {\n host: this.config.statsHost,\n path: '/timeline/v2/' + Runtime.TimelineTransport.name\n });\n }\n\n var getStrategy = (options: StrategyOptions) => {\n return Runtime.getDefaultStrategy(this.config, options, defineTransport);\n };\n\n this.connection = Factory.createConnectionManager(this.key, {\n getStrategy: getStrategy,\n timeline: this.timeline,\n activityTimeout: this.config.activityTimeout,\n pongTimeout: this.config.pongTimeout,\n unavailableTimeout: this.config.unavailableTimeout,\n useTLS: Boolean(this.config.useTLS)\n });\n\n this.connection.bind('connected', () => {\n this.subscribeAll();\n if (this.timelineSender) {\n this.timelineSender.send(this.connection.isUsingTLS());\n }\n });\n\n this.connection.bind('message', event => {\n var eventName = event.event;\n var internal = eventName.indexOf('pusher_internal:') === 0;\n if (event.channel) {\n var channel = this.channel(event.channel);\n if (channel) {\n channel.handleEvent(event);\n }\n }\n // Emit globally [deprecated]\n if (!internal) {\n this.global_emitter.emit(event.event, event.data);\n }\n });\n this.connection.bind('connecting', () => {\n this.channels.disconnect();\n });\n this.connection.bind('disconnected', () => {\n this.channels.disconnect();\n });\n this.connection.bind('error', err => {\n Logger.warn(err);\n });\n\n Pusher.instances.push(this);\n this.timeline.info({ instances: Pusher.instances.length });\n\n this.user = new UserFacade(this);\n\n if (Pusher.isReady) {\n this.connect();\n }\n }\n\n /**\n * Allows you to switch Pusher cluster without\n * losing all the channels/subscription binding\n * as this is internally managed by the SDK.\n */\n switchCluster(options: ClusterOptions) {\n const { appKey, cluster } = options;\n this.key = appKey;\n this.options = { ...this.options, cluster };\n this.config = getConfig(this.options, this);\n this.connection.switchCluster(this.key);\n }\n\n channel(name: string): Channel {\n return this.channels.find(name);\n }\n\n allChannels(): Channel[] {\n return this.channels.all();\n }\n\n connect() {\n this.connection.connect();\n\n if (this.timelineSender) {\n if (!this.timelineSenderTimer) {\n var usingTLS = this.connection.isUsingTLS();\n var timelineSender = this.timelineSender;\n this.timelineSenderTimer = new PeriodicTimer(60000, function() {\n timelineSender.send(usingTLS);\n });\n }\n }\n }\n\n disconnect() {\n this.connection.disconnect();\n\n if (this.timelineSenderTimer) {\n this.timelineSenderTimer.ensureAborted();\n this.timelineSenderTimer = null;\n }\n }\n\n bind(event_name: string, callback: Function, context?: any): Pusher {\n this.global_emitter.bind(event_name, callback, context);\n return this;\n }\n\n unbind(event_name?: string, callback?: Function, context?: any): Pusher {\n this.global_emitter.unbind(event_name, callback, context);\n return this;\n }\n\n bind_global(callback: Function): Pusher {\n this.global_emitter.bind_global(callback);\n return this;\n }\n\n unbind_global(callback?: Function): Pusher {\n this.global_emitter.unbind_global(callback);\n return this;\n }\n\n unbind_all(callback?: Function): Pusher {\n this.global_emitter.unbind_all();\n return this;\n }\n\n subscribeAll() {\n var channelName;\n for (channelName in this.channels.channels) {\n if (this.channels.channels.hasOwnProperty(channelName)) {\n this.subscribe(channelName);\n }\n }\n }\n\n subscribe(channel_name: string) {\n var channel = this.channels.add(channel_name, this);\n if (channel.subscriptionPending && channel.subscriptionCancelled) {\n channel.reinstateSubscription();\n } else if (\n !channel.subscriptionPending &&\n this.connection.state === 'connected'\n ) {\n channel.subscribe();\n }\n return channel;\n }\n\n unsubscribe(channel_name: string) {\n var channel = this.channels.find(channel_name);\n if (channel && channel.subscriptionPending) {\n channel.cancelSubscription();\n } else {\n channel = this.channels.remove(channel_name);\n if (channel && channel.subscribed) {\n channel.unsubscribe();\n }\n }\n }\n\n send_event(event_name: string, data: any, channel?: string) {\n return this.connection.send_event(event_name, data, channel);\n }\n\n shouldUseTLS(): boolean {\n return this.config.useTLS;\n }\n\n signin() {\n this.user.signin();\n }\n}\n\nfunction checkAppKey(key) {\n if (key === null || key === undefined) {\n throw 'You must pass your app key when you instantiate Pusher.';\n }\n}\n\nRuntime.setup(Pusher);\n","import Pusher from './pusher';\nimport { Options, validateOptions } from './options';\nimport * as nacl from 'tweetnacl';\n\nexport default class PusherWithEncryption extends Pusher {\n constructor(app_key: string, options: Options) {\n Pusher.logToConsole = PusherWithEncryption.logToConsole;\n Pusher.log = PusherWithEncryption.log;\n\n validateOptions(options);\n options.nacl = nacl;\n super(app_key, options);\n }\n}\n"],"sourceRoot":""} \ No newline at end of file diff --git a/dist/web/pusher-with-encryption.min.js b/dist/web/pusher-with-encryption.min.js index d80ed5906..8683458b8 100644 --- a/dist/web/pusher-with-encryption.min.js +++ b/dist/web/pusher-with-encryption.min.js @@ -1,9 +1,9 @@ /*! - * Pusher JavaScript Library v8.4.0 + * Pusher JavaScript Library v8.4.0-rc1 * https://pusher.com/ * * Copyright 2020, Pusher * Released under the MIT licence. */ -!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.Pusher=e():t.Pusher=e()}(window,(function(){return function(t){var e={};function n(r){if(e[r])return e[r].exports;var i=e[r]={i:r,l:!1,exports:{}};return t[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)n.d(r,i,function(e){return t[e]}.bind(null,i));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=3)}([function(t,e,n){"use strict";var r,i=this&&this.__extends||(r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)},function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)});Object.defineProperty(e,"__esModule",{value:!0});var s=function(){function t(t){void 0===t&&(t="="),this._paddingCharacter=t}return t.prototype.encodedLength=function(t){return this._paddingCharacter?(t+2)/3*4|0:(8*t+5)/6|0},t.prototype.encode=function(t){for(var e="",n=0;n>>18&63),e+=this._encodeByte(r>>>12&63),e+=this._encodeByte(r>>>6&63),e+=this._encodeByte(r>>>0&63)}var i=t.length-n;if(i>0){r=t[n]<<16|(2===i?t[n+1]<<8:0);e+=this._encodeByte(r>>>18&63),e+=this._encodeByte(r>>>12&63),e+=2===i?this._encodeByte(r>>>6&63):this._paddingCharacter||"",e+=this._paddingCharacter||""}return e},t.prototype.maxDecodedLength=function(t){return this._paddingCharacter?t/4*3|0:(6*t+7)/8|0},t.prototype.decodedLength=function(t){return this.maxDecodedLength(t.length-this._getPaddingLength(t))},t.prototype.decode=function(t){if(0===t.length)return new Uint8Array(0);for(var e=this._getPaddingLength(t),n=t.length-e,r=new Uint8Array(this.maxDecodedLength(n)),i=0,s=0,o=0,a=0,c=0,h=0,u=0;s>>4,r[i++]=c<<4|h>>>2,r[i++]=h<<6|u,o|=256&a,o|=256&c,o|=256&h,o|=256&u;if(s>>4,o|=256&a,o|=256&c),s>>2,o|=256&h),s>>8&6,e+=51-t>>>8&-75,e+=61-t>>>8&-15,e+=62-t>>>8&3,String.fromCharCode(e)},t.prototype._decodeChar=function(t){var e=256;return e+=(42-t&t-44)>>>8&-256+t-43+62,e+=(46-t&t-48)>>>8&-256+t-47+63,e+=(47-t&t-58)>>>8&-256+t-48+52,e+=(64-t&t-91)>>>8&-256+t-65+0,e+=(96-t&t-123)>>>8&-256+t-97+26},t.prototype._getPaddingLength=function(t){var e=0;if(this._paddingCharacter){for(var n=t.length-1;n>=0&&t[n]===this._paddingCharacter;n--)e++;if(t.length<4||e>2)throw new Error("Base64Coder: incorrect padding")}return e},t}();e.Coder=s;var o=new s;e.encode=function(t){return o.encode(t)},e.decode=function(t){return o.decode(t)};var a=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return i(e,t),e.prototype._encodeByte=function(t){var e=t;return e+=65,e+=25-t>>>8&6,e+=51-t>>>8&-75,e+=61-t>>>8&-13,e+=62-t>>>8&49,String.fromCharCode(e)},e.prototype._decodeChar=function(t){var e=256;return e+=(44-t&t-46)>>>8&-256+t-45+62,e+=(94-t&t-96)>>>8&-256+t-95+63,e+=(47-t&t-58)>>>8&-256+t-48+52,e+=(64-t&t-91)>>>8&-256+t-65+0,e+=(96-t&t-123)>>>8&-256+t-97+26},e}(s);e.URLSafeCoder=a;var c=new a;e.encodeURLSafe=function(t){return c.encode(t)},e.decodeURLSafe=function(t){return c.decode(t)},e.encodedLength=function(t){return o.encodedLength(t)},e.maxDecodedLength=function(t){return o.maxDecodedLength(t)},e.decodedLength=function(t){return o.decodedLength(t)}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r="utf8: invalid source encoding";function i(t){for(var e=0,n=0;n=t.length-1)throw new Error("utf8: invalid string");n++,e+=4}}return e}e.encode=function(t){for(var e=new Uint8Array(i(t)),n=0,r=0;r>6,e[n++]=128|63&s):s<55296?(e[n++]=224|s>>12,e[n++]=128|s>>6&63,e[n++]=128|63&s):(r++,s=(1023&s)<<10,s|=1023&t.charCodeAt(r),s+=65536,e[n++]=240|s>>18,e[n++]=128|s>>12&63,e[n++]=128|s>>6&63,e[n++]=128|63&s)}return e},e.encodedLength=i,e.decode=function(t){for(var e=[],n=0;n=t.length)throw new Error(r);if(128!=(192&(o=t[++n])))throw new Error(r);i=(31&i)<<6|63&o,s=128}else if(i<240){if(n>=t.length-1)throw new Error(r);var o=t[++n],a=t[++n];if(128!=(192&o)||128!=(192&a))throw new Error(r);i=(15&i)<<12|(63&o)<<6|63&a,s=2048}else{if(!(i<248))throw new Error(r);if(n>=t.length-2)throw new Error(r);o=t[++n],a=t[++n];var c=t[++n];if(128!=(192&o)||128!=(192&a)||128!=(192&c))throw new Error(r);i=(15&i)<<18|(63&o)<<12|(63&a)<<6|63&c,s=65536}if(i=55296&&i<=57343)throw new Error(r);if(i>=65536){if(i>1114111)throw new Error(r);i-=65536,e.push(String.fromCharCode(55296|i>>10)),i=56320|1023&i}}e.push(String.fromCharCode(i))}return e.join("")}},function(t,e,n){!function(t){"use strict";var e=function(t){var e,n=new Float64Array(16);if(t)for(e=0;e>24&255,t[e+1]=n>>16&255,t[e+2]=n>>8&255,t[e+3]=255&n,t[e+4]=r>>24&255,t[e+5]=r>>16&255,t[e+6]=r>>8&255,t[e+7]=255&r}function g(t,e,n,r,i){var s,o=0;for(s=0;s>>8)-1}function v(t,e,n,r){return g(t,e,n,r,16)}function b(t,e,n,r){return g(t,e,n,r,32)}function y(t,e,n,r){!function(t,e,n,r){for(var i,s=255&r[0]|(255&r[1])<<8|(255&r[2])<<16|(255&r[3])<<24,o=255&n[0]|(255&n[1])<<8|(255&n[2])<<16|(255&n[3])<<24,a=255&n[4]|(255&n[5])<<8|(255&n[6])<<16|(255&n[7])<<24,c=255&n[8]|(255&n[9])<<8|(255&n[10])<<16|(255&n[11])<<24,h=255&n[12]|(255&n[13])<<8|(255&n[14])<<16|(255&n[15])<<24,u=255&r[4]|(255&r[5])<<8|(255&r[6])<<16|(255&r[7])<<24,l=255&e[0]|(255&e[1])<<8|(255&e[2])<<16|(255&e[3])<<24,d=255&e[4]|(255&e[5])<<8|(255&e[6])<<16|(255&e[7])<<24,p=255&e[8]|(255&e[9])<<8|(255&e[10])<<16|(255&e[11])<<24,f=255&e[12]|(255&e[13])<<8|(255&e[14])<<16|(255&e[15])<<24,g=255&r[8]|(255&r[9])<<8|(255&r[10])<<16|(255&r[11])<<24,v=255&n[16]|(255&n[17])<<8|(255&n[18])<<16|(255&n[19])<<24,b=255&n[20]|(255&n[21])<<8|(255&n[22])<<16|(255&n[23])<<24,y=255&n[24]|(255&n[25])<<8|(255&n[26])<<16|(255&n[27])<<24,m=255&n[28]|(255&n[29])<<8|(255&n[30])<<16|(255&n[31])<<24,w=255&r[12]|(255&r[13])<<8|(255&r[14])<<16|(255&r[15])<<24,_=s,S=o,k=a,C=c,T=h,E=u,P=l,x=d,A=p,O=f,L=g,R=v,U=b,I=y,M=m,D=w,N=0;N<20;N+=2)_^=(i=(U^=(i=(A^=(i=(T^=(i=_+U|0)<<7|i>>>25)+_|0)<<9|i>>>23)+T|0)<<13|i>>>19)+A|0)<<18|i>>>14,E^=(i=(S^=(i=(I^=(i=(O^=(i=E+S|0)<<7|i>>>25)+E|0)<<9|i>>>23)+O|0)<<13|i>>>19)+I|0)<<18|i>>>14,L^=(i=(P^=(i=(k^=(i=(M^=(i=L+P|0)<<7|i>>>25)+L|0)<<9|i>>>23)+M|0)<<13|i>>>19)+k|0)<<18|i>>>14,D^=(i=(R^=(i=(x^=(i=(C^=(i=D+R|0)<<7|i>>>25)+D|0)<<9|i>>>23)+C|0)<<13|i>>>19)+x|0)<<18|i>>>14,_^=(i=(C^=(i=(k^=(i=(S^=(i=_+C|0)<<7|i>>>25)+_|0)<<9|i>>>23)+S|0)<<13|i>>>19)+k|0)<<18|i>>>14,E^=(i=(T^=(i=(x^=(i=(P^=(i=E+T|0)<<7|i>>>25)+E|0)<<9|i>>>23)+P|0)<<13|i>>>19)+x|0)<<18|i>>>14,L^=(i=(O^=(i=(A^=(i=(R^=(i=L+O|0)<<7|i>>>25)+L|0)<<9|i>>>23)+R|0)<<13|i>>>19)+A|0)<<18|i>>>14,D^=(i=(M^=(i=(I^=(i=(U^=(i=D+M|0)<<7|i>>>25)+D|0)<<9|i>>>23)+U|0)<<13|i>>>19)+I|0)<<18|i>>>14;_=_+s|0,S=S+o|0,k=k+a|0,C=C+c|0,T=T+h|0,E=E+u|0,P=P+l|0,x=x+d|0,A=A+p|0,O=O+f|0,L=L+g|0,R=R+v|0,U=U+b|0,I=I+y|0,M=M+m|0,D=D+w|0,t[0]=_>>>0&255,t[1]=_>>>8&255,t[2]=_>>>16&255,t[3]=_>>>24&255,t[4]=S>>>0&255,t[5]=S>>>8&255,t[6]=S>>>16&255,t[7]=S>>>24&255,t[8]=k>>>0&255,t[9]=k>>>8&255,t[10]=k>>>16&255,t[11]=k>>>24&255,t[12]=C>>>0&255,t[13]=C>>>8&255,t[14]=C>>>16&255,t[15]=C>>>24&255,t[16]=T>>>0&255,t[17]=T>>>8&255,t[18]=T>>>16&255,t[19]=T>>>24&255,t[20]=E>>>0&255,t[21]=E>>>8&255,t[22]=E>>>16&255,t[23]=E>>>24&255,t[24]=P>>>0&255,t[25]=P>>>8&255,t[26]=P>>>16&255,t[27]=P>>>24&255,t[28]=x>>>0&255,t[29]=x>>>8&255,t[30]=x>>>16&255,t[31]=x>>>24&255,t[32]=A>>>0&255,t[33]=A>>>8&255,t[34]=A>>>16&255,t[35]=A>>>24&255,t[36]=O>>>0&255,t[37]=O>>>8&255,t[38]=O>>>16&255,t[39]=O>>>24&255,t[40]=L>>>0&255,t[41]=L>>>8&255,t[42]=L>>>16&255,t[43]=L>>>24&255,t[44]=R>>>0&255,t[45]=R>>>8&255,t[46]=R>>>16&255,t[47]=R>>>24&255,t[48]=U>>>0&255,t[49]=U>>>8&255,t[50]=U>>>16&255,t[51]=U>>>24&255,t[52]=I>>>0&255,t[53]=I>>>8&255,t[54]=I>>>16&255,t[55]=I>>>24&255,t[56]=M>>>0&255,t[57]=M>>>8&255,t[58]=M>>>16&255,t[59]=M>>>24&255,t[60]=D>>>0&255,t[61]=D>>>8&255,t[62]=D>>>16&255,t[63]=D>>>24&255}(t,e,n,r)}function m(t,e,n,r){!function(t,e,n,r){for(var i,s=255&r[0]|(255&r[1])<<8|(255&r[2])<<16|(255&r[3])<<24,o=255&n[0]|(255&n[1])<<8|(255&n[2])<<16|(255&n[3])<<24,a=255&n[4]|(255&n[5])<<8|(255&n[6])<<16|(255&n[7])<<24,c=255&n[8]|(255&n[9])<<8|(255&n[10])<<16|(255&n[11])<<24,h=255&n[12]|(255&n[13])<<8|(255&n[14])<<16|(255&n[15])<<24,u=255&r[4]|(255&r[5])<<8|(255&r[6])<<16|(255&r[7])<<24,l=255&e[0]|(255&e[1])<<8|(255&e[2])<<16|(255&e[3])<<24,d=255&e[4]|(255&e[5])<<8|(255&e[6])<<16|(255&e[7])<<24,p=255&e[8]|(255&e[9])<<8|(255&e[10])<<16|(255&e[11])<<24,f=255&e[12]|(255&e[13])<<8|(255&e[14])<<16|(255&e[15])<<24,g=255&r[8]|(255&r[9])<<8|(255&r[10])<<16|(255&r[11])<<24,v=255&n[16]|(255&n[17])<<8|(255&n[18])<<16|(255&n[19])<<24,b=255&n[20]|(255&n[21])<<8|(255&n[22])<<16|(255&n[23])<<24,y=255&n[24]|(255&n[25])<<8|(255&n[26])<<16|(255&n[27])<<24,m=255&n[28]|(255&n[29])<<8|(255&n[30])<<16|(255&n[31])<<24,w=255&r[12]|(255&r[13])<<8|(255&r[14])<<16|(255&r[15])<<24,_=0;_<20;_+=2)s^=(i=(b^=(i=(p^=(i=(h^=(i=s+b|0)<<7|i>>>25)+s|0)<<9|i>>>23)+h|0)<<13|i>>>19)+p|0)<<18|i>>>14,u^=(i=(o^=(i=(y^=(i=(f^=(i=u+o|0)<<7|i>>>25)+u|0)<<9|i>>>23)+f|0)<<13|i>>>19)+y|0)<<18|i>>>14,g^=(i=(l^=(i=(a^=(i=(m^=(i=g+l|0)<<7|i>>>25)+g|0)<<9|i>>>23)+m|0)<<13|i>>>19)+a|0)<<18|i>>>14,w^=(i=(v^=(i=(d^=(i=(c^=(i=w+v|0)<<7|i>>>25)+w|0)<<9|i>>>23)+c|0)<<13|i>>>19)+d|0)<<18|i>>>14,s^=(i=(c^=(i=(a^=(i=(o^=(i=s+c|0)<<7|i>>>25)+s|0)<<9|i>>>23)+o|0)<<13|i>>>19)+a|0)<<18|i>>>14,u^=(i=(h^=(i=(d^=(i=(l^=(i=u+h|0)<<7|i>>>25)+u|0)<<9|i>>>23)+l|0)<<13|i>>>19)+d|0)<<18|i>>>14,g^=(i=(f^=(i=(p^=(i=(v^=(i=g+f|0)<<7|i>>>25)+g|0)<<9|i>>>23)+v|0)<<13|i>>>19)+p|0)<<18|i>>>14,w^=(i=(m^=(i=(y^=(i=(b^=(i=w+m|0)<<7|i>>>25)+w|0)<<9|i>>>23)+b|0)<<13|i>>>19)+y|0)<<18|i>>>14;t[0]=s>>>0&255,t[1]=s>>>8&255,t[2]=s>>>16&255,t[3]=s>>>24&255,t[4]=u>>>0&255,t[5]=u>>>8&255,t[6]=u>>>16&255,t[7]=u>>>24&255,t[8]=g>>>0&255,t[9]=g>>>8&255,t[10]=g>>>16&255,t[11]=g>>>24&255,t[12]=w>>>0&255,t[13]=w>>>8&255,t[14]=w>>>16&255,t[15]=w>>>24&255,t[16]=l>>>0&255,t[17]=l>>>8&255,t[18]=l>>>16&255,t[19]=l>>>24&255,t[20]=d>>>0&255,t[21]=d>>>8&255,t[22]=d>>>16&255,t[23]=d>>>24&255,t[24]=p>>>0&255,t[25]=p>>>8&255,t[26]=p>>>16&255,t[27]=p>>>24&255,t[28]=f>>>0&255,t[29]=f>>>8&255,t[30]=f>>>16&255,t[31]=f>>>24&255}(t,e,n,r)}var w=new Uint8Array([101,120,112,97,110,100,32,51,50,45,98,121,116,101,32,107]);function _(t,e,n,r,i,s,o){var a,c,h=new Uint8Array(16),u=new Uint8Array(64);for(c=0;c<16;c++)h[c]=0;for(c=0;c<8;c++)h[c]=s[c];for(;i>=64;){for(y(u,h,o,w),c=0;c<64;c++)t[e+c]=n[r+c]^u[c];for(a=1,c=8;c<16;c++)a=a+(255&h[c])|0,h[c]=255&a,a>>>=8;i-=64,e+=64,r+=64}if(i>0)for(y(u,h,o,w),c=0;c=64;){for(y(c,a,i,w),o=0;o<64;o++)t[e+o]=c[o];for(s=1,o=8;o<16;o++)s=s+(255&a[o])|0,a[o]=255&s,s>>>=8;n-=64,e+=64}if(n>0)for(y(c,a,i,w),o=0;o>>13|n<<3),r=255&t[4]|(255&t[5])<<8,this.r[2]=7939&(n>>>10|r<<6),i=255&t[6]|(255&t[7])<<8,this.r[3]=8191&(r>>>7|i<<9),s=255&t[8]|(255&t[9])<<8,this.r[4]=255&(i>>>4|s<<12),this.r[5]=s>>>1&8190,o=255&t[10]|(255&t[11])<<8,this.r[6]=8191&(s>>>14|o<<2),a=255&t[12]|(255&t[13])<<8,this.r[7]=8065&(o>>>11|a<<5),c=255&t[14]|(255&t[15])<<8,this.r[8]=8191&(a>>>8|c<<8),this.r[9]=c>>>5&127,this.pad[0]=255&t[16]|(255&t[17])<<8,this.pad[1]=255&t[18]|(255&t[19])<<8,this.pad[2]=255&t[20]|(255&t[21])<<8,this.pad[3]=255&t[22]|(255&t[23])<<8,this.pad[4]=255&t[24]|(255&t[25])<<8,this.pad[5]=255&t[26]|(255&t[27])<<8,this.pad[6]=255&t[28]|(255&t[29])<<8,this.pad[7]=255&t[30]|(255&t[31])<<8};function E(t,e,n,r,i,s){var o=new T(s);return o.update(n,r,i),o.finish(t,e),0}function P(t,e,n,r,i,s){var o=new Uint8Array(16);return E(o,0,n,r,i,s),v(t,e,o,0)}function x(t,e,n,r,i){var s;if(n<32)return-1;for(C(t,0,e,0,n,r,i),E(t,16,t,32,n-32,t),s=0;s<16;s++)t[s]=0;return 0}function A(t,e,n,r,i){var s,o=new Uint8Array(32);if(n<32)return-1;if(k(o,0,32,r,i),0!==P(e,16,e,32,n-32,o))return-1;for(C(t,0,e,0,n,r,i),s=0;s<32;s++)t[s]=0;return 0}function O(t,e){var n;for(n=0;n<16;n++)t[n]=0|e[n]}function L(t){var e,n,r=1;for(e=0;e<16;e++)n=t[e]+r+65535,r=Math.floor(n/65536),t[e]=n-65536*r;t[0]+=r-1+37*(r-1)}function R(t,e,n){for(var r,i=~(n-1),s=0;s<16;s++)r=i&(t[s]^e[s]),t[s]^=r,e[s]^=r}function U(t,n){var r,i,s,o=e(),a=e();for(r=0;r<16;r++)a[r]=n[r];for(L(a),L(a),L(a),i=0;i<2;i++){for(o[0]=a[0]-65517,r=1;r<15;r++)o[r]=a[r]-65535-(o[r-1]>>16&1),o[r-1]&=65535;o[15]=a[15]-32767-(o[14]>>16&1),s=o[15]>>16&1,o[14]&=65535,R(a,o,1-s)}for(r=0;r<16;r++)t[2*r]=255&a[r],t[2*r+1]=a[r]>>8}function I(t,e){var n=new Uint8Array(32),r=new Uint8Array(32);return U(n,t),U(r,e),b(n,0,r,0)}function M(t){var e=new Uint8Array(32);return U(e,t),1&e[0]}function D(t,e){var n;for(n=0;n<16;n++)t[n]=e[2*n]+(e[2*n+1]<<8);t[15]&=32767}function N(t,e,n){for(var r=0;r<16;r++)t[r]=e[r]+n[r]}function j(t,e,n){for(var r=0;r<16;r++)t[r]=e[r]-n[r]}function B(t,e,n){var r,i,s=0,o=0,a=0,c=0,h=0,u=0,l=0,d=0,p=0,f=0,g=0,v=0,b=0,y=0,m=0,w=0,_=0,S=0,k=0,C=0,T=0,E=0,P=0,x=0,A=0,O=0,L=0,R=0,U=0,I=0,M=0,D=n[0],N=n[1],j=n[2],B=n[3],z=n[4],H=n[5],q=n[6],F=n[7],X=n[8],J=n[9],Y=n[10],K=n[11],$=n[12],W=n[13],G=n[14],V=n[15];s+=(r=e[0])*D,o+=r*N,a+=r*j,c+=r*B,h+=r*z,u+=r*H,l+=r*q,d+=r*F,p+=r*X,f+=r*J,g+=r*Y,v+=r*K,b+=r*$,y+=r*W,m+=r*G,w+=r*V,o+=(r=e[1])*D,a+=r*N,c+=r*j,h+=r*B,u+=r*z,l+=r*H,d+=r*q,p+=r*F,f+=r*X,g+=r*J,v+=r*Y,b+=r*K,y+=r*$,m+=r*W,w+=r*G,_+=r*V,a+=(r=e[2])*D,c+=r*N,h+=r*j,u+=r*B,l+=r*z,d+=r*H,p+=r*q,f+=r*F,g+=r*X,v+=r*J,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=r*B,w+=r*z,_+=r*H,S+=r*q,k+=r*F,C+=r*X,T+=r*J,E+=r*Y,P+=r*K,x+=r*$,A+=r*W,O+=r*G,L+=r*V,b+=(r=e[12])*D,y+=r*N,m+=r*j,w+=r*B,_+=r*z,S+=r*H,k+=r*q,C+=r*F,T+=r*X,E+=r*J,P+=r*Y,x+=r*K,A+=r*$,O+=r*W,L+=r*G,R+=r*V,y+=(r=e[13])*D,m+=r*N,w+=r*j,_+=r*B,S+=r*z,k+=r*H,C+=r*q,T+=r*F,E+=r*X,P+=r*J,x+=r*Y,A+=r*K,O+=r*$,L+=r*W,R+=r*G,U+=r*V,m+=(r=e[14])*D,w+=r*N,_+=r*j,S+=r*B,k+=r*z,C+=r*H,T+=r*q,E+=r*F,P+=r*X,x+=r*J,A+=r*Y,O+=r*K,L+=r*$,R+=r*W,U+=r*G,I+=r*V,w+=(r=e[15])*D,o+=38*(S+=r*j),a+=38*(k+=r*B),c+=38*(C+=r*z),h+=38*(T+=r*H),u+=38*(E+=r*q),l+=38*(P+=r*F),d+=38*(x+=r*X),p+=38*(A+=r*J),f+=38*(O+=r*Y),g+=38*(L+=r*K),v+=38*(R+=r*$),b+=38*(U+=r*W),y+=38*(I+=r*G),m+=38*(M+=r*V),s=(r=(s+=38*(_+=r*N))+(i=1)+65535)-65536*(i=Math.floor(r/65536)),o=(r=o+i+65535)-65536*(i=Math.floor(r/65536)),a=(r=a+i+65535)-65536*(i=Math.floor(r/65536)),c=(r=c+i+65535)-65536*(i=Math.floor(r/65536)),h=(r=h+i+65535)-65536*(i=Math.floor(r/65536)),u=(r=u+i+65535)-65536*(i=Math.floor(r/65536)),l=(r=l+i+65535)-65536*(i=Math.floor(r/65536)),d=(r=d+i+65535)-65536*(i=Math.floor(r/65536)),p=(r=p+i+65535)-65536*(i=Math.floor(r/65536)),f=(r=f+i+65535)-65536*(i=Math.floor(r/65536)),g=(r=g+i+65535)-65536*(i=Math.floor(r/65536)),v=(r=v+i+65535)-65536*(i=Math.floor(r/65536)),b=(r=b+i+65535)-65536*(i=Math.floor(r/65536)),y=(r=y+i+65535)-65536*(i=Math.floor(r/65536)),m=(r=m+i+65535)-65536*(i=Math.floor(r/65536)),w=(r=w+i+65535)-65536*(i=Math.floor(r/65536)),s=(r=(s+=i-1+37*(i-1))+(i=1)+65535)-65536*(i=Math.floor(r/65536)),o=(r=o+i+65535)-65536*(i=Math.floor(r/65536)),a=(r=a+i+65535)-65536*(i=Math.floor(r/65536)),c=(r=c+i+65535)-65536*(i=Math.floor(r/65536)),h=(r=h+i+65535)-65536*(i=Math.floor(r/65536)),u=(r=u+i+65535)-65536*(i=Math.floor(r/65536)),l=(r=l+i+65535)-65536*(i=Math.floor(r/65536)),d=(r=d+i+65535)-65536*(i=Math.floor(r/65536)),p=(r=p+i+65535)-65536*(i=Math.floor(r/65536)),f=(r=f+i+65535)-65536*(i=Math.floor(r/65536)),g=(r=g+i+65535)-65536*(i=Math.floor(r/65536)),v=(r=v+i+65535)-65536*(i=Math.floor(r/65536)),b=(r=b+i+65535)-65536*(i=Math.floor(r/65536)),y=(r=y+i+65535)-65536*(i=Math.floor(r/65536)),m=(r=m+i+65535)-65536*(i=Math.floor(r/65536)),w=(r=w+i+65535)-65536*(i=Math.floor(r/65536)),s+=i-1+37*(i-1),t[0]=s,t[1]=o,t[2]=a,t[3]=c,t[4]=h,t[5]=u,t[6]=l,t[7]=d,t[8]=p,t[9]=f,t[10]=g,t[11]=v,t[12]=b,t[13]=y,t[14]=m,t[15]=w}function z(t,e){B(t,e,e)}function H(t,n){var r,i=e();for(r=0;r<16;r++)i[r]=n[r];for(r=253;r>=0;r--)z(i,i),2!==r&&4!==r&&B(i,i,n);for(r=0;r<16;r++)t[r]=i[r]}function q(t,n){var r,i=e();for(r=0;r<16;r++)i[r]=n[r];for(r=250;r>=0;r--)z(i,i),1!==r&&B(i,i,n);for(r=0;r<16;r++)t[r]=i[r]}function F(t,n,r){var i,s,o=new Uint8Array(32),a=new Float64Array(80),h=e(),u=e(),l=e(),d=e(),p=e(),f=e();for(s=0;s<31;s++)o[s]=n[s];for(o[31]=127&n[31]|64,o[0]&=248,D(a,r),s=0;s<16;s++)u[s]=a[s],d[s]=h[s]=l[s]=0;for(h[0]=d[0]=1,s=254;s>=0;--s)R(h,u,i=o[s>>>3]>>>(7&s)&1),R(l,d,i),N(p,h,l),j(h,h,l),N(l,u,d),j(u,u,d),z(d,p),z(f,h),B(h,l,h),B(l,u,p),N(p,h,l),j(h,h,l),z(u,h),j(l,d,f),B(h,l,c),N(h,h,d),B(l,l,h),B(h,d,f),B(d,u,a),z(u,p),R(h,u,i),R(l,d,i);for(s=0;s<16;s++)a[s+16]=h[s],a[s+32]=l[s],a[s+48]=u[s],a[s+64]=d[s];var g=a.subarray(32),v=a.subarray(16);return H(g,g),B(v,v,g),U(t,v),0}function X(t,e){return F(t,e,s)}function J(t,e){return r(e,32),X(t,e)}function Y(t,e,n){var r=new Uint8Array(32);return F(r,n,e),m(t,i,r,w)}T.prototype.blocks=function(t,e,n){for(var r,i,s,o,a,c,h,u,l,d,p,f,g,v,b,y,m,w,_,S=this.fin?0:2048,k=this.h[0],C=this.h[1],T=this.h[2],E=this.h[3],P=this.h[4],x=this.h[5],A=this.h[6],O=this.h[7],L=this.h[8],R=this.h[9],U=this.r[0],I=this.r[1],M=this.r[2],D=this.r[3],N=this.r[4],j=this.r[5],B=this.r[6],z=this.r[7],H=this.r[8],q=this.r[9];n>=16;)d=l=0,d+=(k+=8191&(r=255&t[e+0]|(255&t[e+1])<<8))*U,d+=(C+=8191&(r>>>13|(i=255&t[e+2]|(255&t[e+3])<<8)<<3))*(5*q),d+=(T+=8191&(i>>>10|(s=255&t[e+4]|(255&t[e+5])<<8)<<6))*(5*H),d+=(E+=8191&(s>>>7|(o=255&t[e+6]|(255&t[e+7])<<8)<<9))*(5*z),l=(d+=(P+=8191&(o>>>4|(a=255&t[e+8]|(255&t[e+9])<<8)<<12))*(5*B))>>>13,d&=8191,d+=(x+=a>>>1&8191)*(5*j),d+=(A+=8191&(a>>>14|(c=255&t[e+10]|(255&t[e+11])<<8)<<2))*(5*N),d+=(O+=8191&(c>>>11|(h=255&t[e+12]|(255&t[e+13])<<8)<<5))*(5*D),d+=(L+=8191&(h>>>8|(u=255&t[e+14]|(255&t[e+15])<<8)<<8))*(5*M),p=l+=(d+=(R+=u>>>5|S)*(5*I))>>>13,p+=k*I,p+=C*U,p+=T*(5*q),p+=E*(5*H),l=(p+=P*(5*z))>>>13,p&=8191,p+=x*(5*B),p+=A*(5*j),p+=O*(5*N),p+=L*(5*D),l+=(p+=R*(5*M))>>>13,p&=8191,f=l,f+=k*M,f+=C*I,f+=T*U,f+=E*(5*q),l=(f+=P*(5*H))>>>13,f&=8191,f+=x*(5*z),f+=A*(5*B),f+=O*(5*j),f+=L*(5*N),g=l+=(f+=R*(5*D))>>>13,g+=k*D,g+=C*M,g+=T*I,g+=E*U,l=(g+=P*(5*q))>>>13,g&=8191,g+=x*(5*H),g+=A*(5*z),g+=O*(5*B),g+=L*(5*j),v=l+=(g+=R*(5*N))>>>13,v+=k*N,v+=C*D,v+=T*M,v+=E*I,l=(v+=P*U)>>>13,v&=8191,v+=x*(5*q),v+=A*(5*H),v+=O*(5*z),v+=L*(5*B),b=l+=(v+=R*(5*j))>>>13,b+=k*j,b+=C*N,b+=T*D,b+=E*M,l=(b+=P*I)>>>13,b&=8191,b+=x*U,b+=A*(5*q),b+=O*(5*H),b+=L*(5*z),y=l+=(b+=R*(5*B))>>>13,y+=k*B,y+=C*j,y+=T*N,y+=E*D,l=(y+=P*M)>>>13,y&=8191,y+=x*I,y+=A*U,y+=O*(5*q),y+=L*(5*H),m=l+=(y+=R*(5*z))>>>13,m+=k*z,m+=C*B,m+=T*j,m+=E*N,l=(m+=P*D)>>>13,m&=8191,m+=x*M,m+=A*I,m+=O*U,m+=L*(5*q),w=l+=(m+=R*(5*H))>>>13,w+=k*H,w+=C*z,w+=T*B,w+=E*j,l=(w+=P*N)>>>13,w&=8191,w+=x*D,w+=A*M,w+=O*I,w+=L*U,_=l+=(w+=R*(5*q))>>>13,_+=k*q,_+=C*H,_+=T*z,_+=E*B,l=(_+=P*j)>>>13,_&=8191,_+=x*N,_+=A*D,_+=O*M,_+=L*I,k=d=8191&(l=(l=((l+=(_+=R*U)>>>13)<<2)+l|0)+(d&=8191)|0),C=p+=l>>>=13,T=f&=8191,E=g&=8191,P=v&=8191,x=b&=8191,A=y&=8191,O=m&=8191,L=w&=8191,R=_&=8191,e+=16,n-=16;this.h[0]=k,this.h[1]=C,this.h[2]=T,this.h[3]=E,this.h[4]=P,this.h[5]=x,this.h[6]=A,this.h[7]=O,this.h[8]=L,this.h[9]=R},T.prototype.finish=function(t,e){var n,r,i,s,o=new Uint16Array(10);if(this.leftover){for(s=this.leftover,this.buffer[s++]=1;s<16;s++)this.buffer[s]=0;this.fin=1,this.blocks(this.buffer,0,16)}for(n=this.h[1]>>>13,this.h[1]&=8191,s=2;s<10;s++)this.h[s]+=n,n=this.h[s]>>>13,this.h[s]&=8191;for(this.h[0]+=5*n,n=this.h[0]>>>13,this.h[0]&=8191,this.h[1]+=n,n=this.h[1]>>>13,this.h[1]&=8191,this.h[2]+=n,o[0]=this.h[0]+5,n=o[0]>>>13,o[0]&=8191,s=1;s<10;s++)o[s]=this.h[s]+n,n=o[s]>>>13,o[s]&=8191;for(o[9]-=8192,r=(1^n)-1,s=0;s<10;s++)o[s]&=r;for(r=~r,s=0;s<10;s++)this.h[s]=this.h[s]&r|o[s];for(this.h[0]=65535&(this.h[0]|this.h[1]<<13),this.h[1]=65535&(this.h[1]>>>3|this.h[2]<<10),this.h[2]=65535&(this.h[2]>>>6|this.h[3]<<7),this.h[3]=65535&(this.h[3]>>>9|this.h[4]<<4),this.h[4]=65535&(this.h[4]>>>12|this.h[5]<<1|this.h[6]<<14),this.h[5]=65535&(this.h[6]>>>2|this.h[7]<<11),this.h[6]=65535&(this.h[7]>>>5|this.h[8]<<8),this.h[7]=65535&(this.h[8]>>>8|this.h[9]<<5),i=this.h[0]+this.pad[0],this.h[0]=65535&i,s=1;s<8;s++)i=(this.h[s]+this.pad[s]|0)+(i>>>16)|0,this.h[s]=65535&i;t[e+0]=this.h[0]>>>0&255,t[e+1]=this.h[0]>>>8&255,t[e+2]=this.h[1]>>>0&255,t[e+3]=this.h[1]>>>8&255,t[e+4]=this.h[2]>>>0&255,t[e+5]=this.h[2]>>>8&255,t[e+6]=this.h[3]>>>0&255,t[e+7]=this.h[3]>>>8&255,t[e+8]=this.h[4]>>>0&255,t[e+9]=this.h[4]>>>8&255,t[e+10]=this.h[5]>>>0&255,t[e+11]=this.h[5]>>>8&255,t[e+12]=this.h[6]>>>0&255,t[e+13]=this.h[6]>>>8&255,t[e+14]=this.h[7]>>>0&255,t[e+15]=this.h[7]>>>8&255},T.prototype.update=function(t,e,n){var r,i;if(this.leftover){for((i=16-this.leftover)>n&&(i=n),r=0;r=16&&(i=n-n%16,this.blocks(t,e,i),e+=i,n-=i),n){for(r=0;r=128;){for(S=0;S<16;S++)k=8*S+$,O[S]=n[k+0]<<24|n[k+1]<<16|n[k+2]<<8|n[k+3],L[S]=n[k+4]<<24|n[k+5]<<16|n[k+6]<<8|n[k+7];for(S=0;S<80;S++)if(i=R,s=U,o=I,a=M,c=D,h=N,u=j,B,d=z,p=H,f=q,g=F,v=X,b=J,y=Y,K,E=65535&(T=K),P=T>>>16,x=65535&(C=B),A=C>>>16,E+=65535&(T=(X>>>14|D<<18)^(X>>>18|D<<14)^(D>>>9|X<<23)),P+=T>>>16,x+=65535&(C=(D>>>14|X<<18)^(D>>>18|X<<14)^(X>>>9|D<<23)),A+=C>>>16,E+=65535&(T=X&J^~X&Y),P+=T>>>16,x+=65535&(C=D&N^~D&j),A+=C>>>16,E+=65535&(T=W[2*S+1]),P+=T>>>16,x+=65535&(C=W[2*S]),A+=C>>>16,C=O[S%16],P+=(T=L[S%16])>>>16,x+=65535&C,A+=C>>>16,x+=(P+=(E+=65535&T)>>>16)>>>16,E=65535&(T=_=65535&E|P<<16),P=T>>>16,x=65535&(C=w=65535&x|(A+=x>>>16)<<16),A=C>>>16,E+=65535&(T=(z>>>28|R<<4)^(R>>>2|z<<30)^(R>>>7|z<<25)),P+=T>>>16,x+=65535&(C=(R>>>28|z<<4)^(z>>>2|R<<30)^(z>>>7|R<<25)),A+=C>>>16,P+=(T=z&H^z&q^H&q)>>>16,x+=65535&(C=R&U^R&I^U&I),A+=C>>>16,l=65535&(x+=(P+=(E+=65535&T)>>>16)>>>16)|(A+=x>>>16)<<16,m=65535&E|P<<16,E=65535&(T=g),P=T>>>16,x=65535&(C=a),A=C>>>16,P+=(T=_)>>>16,x+=65535&(C=w),A+=C>>>16,U=i,I=s,M=o,D=a=65535&(x+=(P+=(E+=65535&T)>>>16)>>>16)|(A+=x>>>16)<<16,N=c,j=h,B=u,R=l,H=d,q=p,F=f,X=g=65535&E|P<<16,J=v,Y=b,K=y,z=m,S%16==15)for(k=0;k<16;k++)C=O[k],E=65535&(T=L[k]),P=T>>>16,x=65535&C,A=C>>>16,C=O[(k+9)%16],E+=65535&(T=L[(k+9)%16]),P+=T>>>16,x+=65535&C,A+=C>>>16,w=O[(k+1)%16],E+=65535&(T=((_=L[(k+1)%16])>>>1|w<<31)^(_>>>8|w<<24)^(_>>>7|w<<25)),P+=T>>>16,x+=65535&(C=(w>>>1|_<<31)^(w>>>8|_<<24)^w>>>7),A+=C>>>16,w=O[(k+14)%16],P+=(T=((_=L[(k+14)%16])>>>19|w<<13)^(w>>>29|_<<3)^(_>>>6|w<<26))>>>16,x+=65535&(C=(w>>>19|_<<13)^(_>>>29|w<<3)^w>>>6),A+=C>>>16,A+=(x+=(P+=(E+=65535&T)>>>16)>>>16)>>>16,O[k]=65535&x|A<<16,L[k]=65535&E|P<<16;E=65535&(T=z),P=T>>>16,x=65535&(C=R),A=C>>>16,C=t[0],P+=(T=e[0])>>>16,x+=65535&C,A+=C>>>16,A+=(x+=(P+=(E+=65535&T)>>>16)>>>16)>>>16,t[0]=R=65535&x|A<<16,e[0]=z=65535&E|P<<16,E=65535&(T=H),P=T>>>16,x=65535&(C=U),A=C>>>16,C=t[1],P+=(T=e[1])>>>16,x+=65535&C,A+=C>>>16,A+=(x+=(P+=(E+=65535&T)>>>16)>>>16)>>>16,t[1]=U=65535&x|A<<16,e[1]=H=65535&E|P<<16,E=65535&(T=q),P=T>>>16,x=65535&(C=I),A=C>>>16,C=t[2],P+=(T=e[2])>>>16,x+=65535&C,A+=C>>>16,A+=(x+=(P+=(E+=65535&T)>>>16)>>>16)>>>16,t[2]=I=65535&x|A<<16,e[2]=q=65535&E|P<<16,E=65535&(T=F),P=T>>>16,x=65535&(C=M),A=C>>>16,C=t[3],P+=(T=e[3])>>>16,x+=65535&C,A+=C>>>16,A+=(x+=(P+=(E+=65535&T)>>>16)>>>16)>>>16,t[3]=M=65535&x|A<<16,e[3]=F=65535&E|P<<16,E=65535&(T=X),P=T>>>16,x=65535&(C=D),A=C>>>16,C=t[4],P+=(T=e[4])>>>16,x+=65535&C,A+=C>>>16,A+=(x+=(P+=(E+=65535&T)>>>16)>>>16)>>>16,t[4]=D=65535&x|A<<16,e[4]=X=65535&E|P<<16,E=65535&(T=J),P=T>>>16,x=65535&(C=N),A=C>>>16,C=t[5],P+=(T=e[5])>>>16,x+=65535&C,A+=C>>>16,A+=(x+=(P+=(E+=65535&T)>>>16)>>>16)>>>16,t[5]=N=65535&x|A<<16,e[5]=J=65535&E|P<<16,E=65535&(T=Y),P=T>>>16,x=65535&(C=j),A=C>>>16,C=t[6],P+=(T=e[6])>>>16,x+=65535&C,A+=C>>>16,A+=(x+=(P+=(E+=65535&T)>>>16)>>>16)>>>16,t[6]=j=65535&x|A<<16,e[6]=Y=65535&E|P<<16,E=65535&(T=K),P=T>>>16,x=65535&(C=B),A=C>>>16,C=t[7],P+=(T=e[7])>>>16,x+=65535&C,A+=C>>>16,A+=(x+=(P+=(E+=65535&T)>>>16)>>>16)>>>16,t[7]=B=65535&x|A<<16,e[7]=K=65535&E|P<<16,$+=128,r-=128}return r}function V(t,e,n){var r,i=new Int32Array(8),s=new Int32Array(8),o=new Uint8Array(256),a=n;for(i[0]=1779033703,i[1]=3144134277,i[2]=1013904242,i[3]=2773480762,i[4]=1359893119,i[5]=2600822924,i[6]=528734635,i[7]=1541459225,s[0]=4089235720,s[1]=2227873595,s[2]=4271175723,s[3]=1595750129,s[4]=2917565137,s[5]=725511199,s[6]=4215389547,s[7]=327033209,G(i,s,e,n),n%=128,r=0;r=0;--i)Q(t,e,r=n[i/8|0]>>(7&i)&1),Z(e,t),Z(t,t),Q(t,e,r)}function nt(t,n){var r=[e(),e(),e(),e()];O(r[0],l),O(r[1],d),O(r[2],a),B(r[3],l,d),et(t,r,n)}function rt(t,n,i){var s,o=new Uint8Array(64),a=[e(),e(),e(),e()];for(i||r(n,32),V(o,n,32),o[0]&=248,o[31]&=127,o[31]|=64,nt(a,o),tt(t,a),s=0;s<32;s++)n[s+32]=t[s];return 0}var it=new Float64Array([237,211,245,92,26,99,18,88,214,156,247,162,222,249,222,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16]);function st(t,e){var n,r,i,s;for(r=63;r>=32;--r){for(n=0,i=r-32,s=r-12;i>4)*it[i],n=e[i]>>8,e[i]&=255;for(i=0;i<32;i++)e[i]-=n*it[i];for(r=0;r<32;r++)e[r+1]+=e[r]>>8,t[r]=255&e[r]}function ot(t){var e,n=new Float64Array(64);for(e=0;e<64;e++)n[e]=t[e];for(e=0;e<64;e++)t[e]=0;st(t,n)}function at(t,n,r,i){var s,o,a=new Uint8Array(64),c=new Uint8Array(64),h=new Uint8Array(64),u=new Float64Array(64),l=[e(),e(),e(),e()];V(a,i,32),a[0]&=248,a[31]&=127,a[31]|=64;var d=r+64;for(s=0;s>7&&j(t[0],o,t[0]),B(t[3],t[0],t[1]),0)}(d,i))return-1;for(s=0;s=0},t.sign.keyPair=function(){var t=new Uint8Array(32),e=new Uint8Array(64);return rt(t,e),{publicKey:t,secretKey:e}},t.sign.keyPair.fromSecretKey=function(t){if(ut(t),64!==t.length)throw new Error("bad secret key size");for(var e=new Uint8Array(32),n=0;n0)r.loading[t].push(n);else{r.loading[t]=[n];var i=ue.createScriptRequest(r.getPath(t,e)),s=r.receivers.create((function(e){if(r.receivers.remove(s),r.loading[t]){var n=r.loading[t];delete r.loading[t];for(var o=function(t){t||i.cleanup()},a=0;a>>6)+_(128|63&e):_(224|e>>>12&15)+_(128|e>>>6&63)+_(128|63&e)},P=function(t){return t.replace(/[^\x00-\x7F]/g,E)},x=function(t){var e=[0,2,1][t.length%3],n=t.charCodeAt(0)<<16|(t.length>1?t.charCodeAt(1):0)<<8|(t.length>2?t.charCodeAt(2):0);return[S.charAt(n>>>18),S.charAt(n>>>12&63),e>=2?"=":S.charAt(n>>>6&63),e>=1?"=":S.charAt(63&n)].join("")},A=window.btoa||function(t){return t.replace(/[\s\S]{1,3}/g,x)};var O=class{constructor(t,e,n,r){this.clear=e,this.timer=t(()=>{this.timer&&(this.timer=r(this.timer))},n)}isRunning(){return null!==this.timer}ensureAborted(){this.timer&&(this.clear(this.timer),this.timer=null)}};function L(t){window.clearTimeout(t)}function R(t){window.clearInterval(t)}class U extends O{constructor(t,e){super(setTimeout,L,t,(function(t){return e(),null}))}}class I extends O{constructor(t,e){super(setInterval,R,t,(function(t){return e(),t}))}}var M={now:()=>Date.now?Date.now():(new Date).valueOf(),defer:t=>new U(0,t),method(t,...e){var n=Array.prototype.slice.call(arguments,1);return function(e){return e[t].apply(e,n.concat(arguments))}}};function D(t,...e){for(var n=0;n{window.console&&window.console.log&&window.console.log(t)}}debug(...t){this.log(this.globalLog,t)}warn(...t){this.log(this.globalLogWarn,t)}error(...t){this.log(this.globalLogError,t)}globalLogWarn(t){window.console&&window.console.warn?window.console.warn(t):this.globalLog(t)}globalLogError(t){window.console&&window.console.error?window.console.error(t):this.globalLogWarn(t)}log(t,...e){var n=N.apply(this,arguments);if(Re.log)Re.log(n);else if(Re.logToConsole){t.bind(this)(n)}}},G=function(t,e,n,r,i){void 0===n.headers&&null==n.headersProvider||W.warn(`To send headers with the ${r.toString()} request, you must use AJAX, rather than JSONP.`);var s=t.nextAuthCallbackID.toString();t.nextAuthCallbackID++;var o=t.getDocument(),a=o.createElement("script");t.auth_callbacks[s]=function(t){i(null,t)};var c="Pusher.auth_callbacks['"+s+"']";a.src=n.endpoint+"?callback="+encodeURIComponent(c)+"&"+e;var h=o.getElementsByTagName("head")[0]||o.documentElement;h.insertBefore(a,h.firstChild)};class V{constructor(t){this.src=t}send(t){var e=this,n="Error loading "+e.src;e.script=document.createElement("script"),e.script.id=t.id,e.script.src=e.src,e.script.type="text/javascript",e.script.charset="UTF-8",e.script.addEventListener?(e.script.onerror=function(){t.callback(n)},e.script.onload=function(){t.callback(null)}):e.script.onreadystatechange=function(){"loaded"!==e.script.readyState&&"complete"!==e.script.readyState||t.callback(null)},void 0===e.script.async&&document.attachEvent&&/opera/i.test(navigator.userAgent)?(e.errorScript=document.createElement("script"),e.errorScript.id=t.id+"_error",e.errorScript.text=t.name+"('"+n+"');",e.script.async=e.errorScript.async=!1):e.script.async=!0;var r=document.getElementsByTagName("head")[0];r.insertBefore(e.script,r.firstChild),e.errorScript&&r.insertBefore(e.errorScript,e.script.nextSibling)}cleanup(){this.script&&(this.script.onload=this.script.onerror=null,this.script.onreadystatechange=null),this.script&&this.script.parentNode&&this.script.parentNode.removeChild(this.script),this.errorScript&&this.errorScript.parentNode&&this.errorScript.parentNode.removeChild(this.errorScript),this.script=null,this.errorScript=null}}class Z{constructor(t,e){this.url=t,this.data=e}send(t){if(!this.request){var e=K(this.data),n=this.url+"/"+t.number+"?"+e;this.request=ue.createScriptRequest(n),this.request.send(t)}}cleanup(){this.request&&this.request.cleanup()}}var Q={name:"jsonp",getAgent:function(t,e){return function(n,r){var s="http"+(e?"s":"")+"://"+(t.host||t.options.host)+t.options.path,o=ue.createJSONPRequest(s,n),a=ue.ScriptReceivers.create((function(e,n){i.remove(a),o.cleanup(),n&&n.host&&(t.host=n.host),r&&r(e,n)}));o.send(a)}}};function tt(t,e,n){return t+(e.useTLS?"s":"")+"://"+(e.useTLS?e.hostTLS:e.hostNonTLS)+n}function et(t,e){return"/app/"+t+("?protocol="+s.PROTOCOL+"&client=js&version="+s.VERSION+(e?"&"+e:""))}var nt={getInitial:function(t,e){return tt("ws",e,(e.httpPath||"")+et(t,"flash=false"))}},rt={getInitial:function(t,e){return tt("http",e,(e.httpPath||"/pusher")+et(t))}},it={getInitial:function(t,e){return tt("http",e,e.httpPath||"/pusher")},getPath:function(t,e){return et(t)}};class st{constructor(){this._callbacks={}}get(t){return this._callbacks[ot(t)]}add(t,e,n){var r=ot(t);this._callbacks[r]=this._callbacks[r]||[],this._callbacks[r].push({fn:e,context:n})}remove(t,e,n){if(t||e||n){var r=t?[ot(t)]:z(this._callbacks);e||n?this.removeCallback(r,e,n):this.removeAllCallbacks(r)}else this._callbacks={}}removeCallback(t,e,n){H(t,(function(t){this._callbacks[t]=F(this._callbacks[t]||[],(function(t){return e&&e!==t.fn||n&&n!==t.context})),0===this._callbacks[t].length&&delete this._callbacks[t]}),this)}removeAllCallbacks(t){H(t,(function(t){delete this._callbacks[t]}),this)}}function ot(t){return"_"+t}class at{constructor(t){this.callbacks=new st,this.global_callbacks=[],this.failThrough=t}bind(t,e,n){return this.callbacks.add(t,e,n),this}bind_global(t){return this.global_callbacks.push(t),this}unbind(t,e,n){return this.callbacks.remove(t,e,n),this}unbind_global(t){return t?(this.global_callbacks=F(this.global_callbacks||[],e=>e!==t),this):(this.global_callbacks=[],this)}unbind_all(){return this.unbind(),this.unbind_global(),this}emit(t,e,n){for(var r=0;r0)for(r=0;r{this.onError(t),this.changeState("closed")}),!1}return this.bindListeners(),W.debug("Connecting",{transport:this.name,url:t}),this.changeState("connecting"),!0}close(){return!!this.socket&&(this.socket.close(),!0)}send(t){return"open"===this.state&&(M.defer(()=>{this.socket&&this.socket.send(t)}),!0)}ping(){"open"===this.state&&this.supportsPing()&&this.socket.ping()}onOpen(){this.hooks.beforeOpen&&this.hooks.beforeOpen(this.socket,this.hooks.urls.getPath(this.key,this.options)),this.changeState("open"),this.socket.onopen=void 0}onError(t){this.emit("error",{type:"WebSocketError",error:t}),this.timeline.error(this.buildTimelineMessage({error:t.toString()}))}onClose(t){t?this.changeState("closed",{code:t.code,reason:t.reason,wasClean:t.wasClean}):this.changeState("closed"),this.unbindListeners(),this.socket=void 0}onMessage(t){this.emit("message",t)}onActivity(){this.emit("activity")}bindListeners(){this.socket.onopen=()=>{this.onOpen()},this.socket.onerror=t=>{this.onError(t)},this.socket.onclose=t=>{this.onClose(t)},this.socket.onmessage=t=>{this.onMessage(t)},this.supportsPing()&&(this.socket.onactivity=()=>{this.onActivity()})}unbindListeners(){this.socket&&(this.socket.onopen=void 0,this.socket.onerror=void 0,this.socket.onclose=void 0,this.socket.onmessage=void 0,this.supportsPing()&&(this.socket.onactivity=void 0))}changeState(t,e){this.state=t,this.timeline.info(this.buildTimelineMessage({state:t,params:e})),this.emit(t,e)}buildTimelineMessage(t){return D({cid:this.id},t)}}class ht{constructor(t){this.hooks=t}isSupported(t){return this.hooks.isSupported(t)}createConnection(t,e,n,r){return new ct(this.hooks,t,e,n,r)}}var ut=new ht({urls:nt,handlesActivityChecks:!1,supportsPing:!1,isInitialized:function(){return Boolean(ue.getWebSocketAPI())},isSupported:function(){return Boolean(ue.getWebSocketAPI())},getSocket:function(t){return ue.createWebSocket(t)}}),lt={urls:rt,handlesActivityChecks:!1,supportsPing:!0,isInitialized:function(){return!0}},dt=D({getSocket:function(t){return ue.HTTPFactory.createStreamingSocket(t)}},lt),pt=D({getSocket:function(t){return ue.HTTPFactory.createPollingSocket(t)}},lt),ft={isSupported:function(){return ue.isXHRSupported()}},gt={ws:ut,xhr_streaming:new ht(D({},dt,ft)),xhr_polling:new ht(D({},pt,ft))},vt=new ht({file:"sockjs",urls:it,handlesActivityChecks:!0,supportsPing:!1,isSupported:function(){return!0},isInitialized:function(){return void 0!==window.SockJS},getSocket:function(t,e){return new window.SockJS(t,null,{js_path:a.getPath("sockjs",{useTLS:e.useTLS}),ignore_null_origin:e.ignoreNullOrigin})},beforeOpen:function(t,e){t.send(JSON.stringify({path:e}))}}),bt={isSupported:function(t){return ue.isXDRSupported(t.useTLS)}},yt=new ht(D({},dt,bt)),mt=new ht(D({},pt,bt));gt.xdr_streaming=yt,gt.xdr_polling=mt,gt.sockjs=vt;var wt=gt;var _t=new class extends at{constructor(){super();var t=this;void 0!==window.addEventListener&&(window.addEventListener("online",(function(){t.emit("online")}),!1),window.addEventListener("offline",(function(){t.emit("offline")}),!1))}isOnline(){return void 0===window.navigator.onLine||window.navigator.onLine}};class St{constructor(t,e,n){this.manager=t,this.transport=e,this.minPingDelay=n.minPingDelay,this.maxPingDelay=n.maxPingDelay,this.pingDelay=void 0}createConnection(t,e,n,r){r=D({},r,{activityTimeout:this.pingDelay});var i=this.transport.createConnection(t,e,n,r),s=null,o=function(){i.unbind("open",o),i.bind("closed",a),s=M.now()},a=t=>{if(i.unbind("closed",a),1002===t.code||1003===t.code)this.manager.reportDeath();else if(!t.wasClean&&s){var e=M.now()-s;e<2*this.maxPingDelay&&(this.manager.reportDeath(),this.pingDelay=Math.max(e/2,this.minPingDelay))}};return i.bind("open",o),i}isSupported(t){return this.manager.isAlive()&&this.transport.isSupported(t)}}const kt={decodeMessage:function(t){try{var e=JSON.parse(t.data),n=e.data;if("string"==typeof n)try{n=JSON.parse(e.data)}catch(t){}var r={event:e.event,channel:e.channel,data:n};return e.user_id&&(r.user_id=e.user_id),r}catch(e){throw{type:"MessageParseError",error:e,data:t.data}}},encodeMessage:function(t){return JSON.stringify(t)},processHandshake:function(t){var e=kt.decodeMessage(t);if("pusher:connection_established"===e.event){if(!e.data.activity_timeout)throw"No activity timeout specified in handshake";return{action:"connected",id:e.data.socket_id,activityTimeout:1e3*e.data.activity_timeout}}if("pusher:error"===e.event)return{action:this.getCloseAction(e.data),error:this.getCloseError(e.data)};throw"Invalid handshake"},getCloseAction:function(t){return t.code<4e3?t.code>=1002&&t.code<=1004?"backoff":null:4e3===t.code?"tls_only":t.code<4100?"refused":t.code<4200?"backoff":t.code<4300?"retry":"refused"},getCloseError:function(t){return 1e3!==t.code&&1001!==t.code?{type:"PusherError",data:{code:t.code,message:t.reason||t.message}}:null}};var Ct=kt;class Tt extends at{constructor(t,e){super(),this.id=t,this.transport=e,this.activityTimeout=e.activityTimeout,this.bindListeners()}handlesActivityChecks(){return this.transport.handlesActivityChecks()}send(t){return this.transport.send(t)}send_event(t,e,n){var r={event:t,data:e};return n&&(r.channel=n),W.debug("Event sent",r),this.send(Ct.encodeMessage(r))}ping(){this.transport.supportsPing()?this.transport.ping():this.send_event("pusher:ping",{})}close(){this.transport.close()}bindListeners(){var t={message:t=>{var e;try{e=Ct.decodeMessage(t)}catch(e){this.emit("error",{type:"MessageParseError",error:e,data:t.data})}if(void 0!==e){switch(W.debug("Event recd",e),e.event){case"pusher:error":this.emit("error",{type:"PusherError",data:e.data});break;case"pusher:ping":this.emit("ping");break;case"pusher:pong":this.emit("pong")}this.emit("message",e)}},activity:()=>{this.emit("activity")},error:t=>{this.emit("error",t)},closed:t=>{e(),t&&t.code&&this.handleCloseEvent(t),this.transport=null,this.emit("closed")}},e=()=>{B(t,(t,e)=>{this.transport.unbind(e,t)})};B(t,(t,e)=>{this.transport.bind(e,t)})}handleCloseEvent(t){var e=Ct.getCloseAction(t),n=Ct.getCloseError(t);n&&this.emit("error",n),e&&this.emit(e,{action:e,error:n})}}class Et{constructor(t,e){this.transport=t,this.callback=e,this.bindListeners()}close(){this.unbindListeners(),this.transport.close()}bindListeners(){this.onMessage=t=>{var e;this.unbindListeners();try{e=Ct.processHandshake(t)}catch(t){return this.finish("error",{error:t}),void this.transport.close()}"connected"===e.action?this.finish("connected",{connection:new Tt(e.id,this.transport),activityTimeout:e.activityTimeout}):(this.finish(e.action,{error:e.error}),this.transport.close())},this.onClosed=t=>{this.unbindListeners();var e=Ct.getCloseAction(t)||"backoff",n=Ct.getCloseError(t);this.finish(e,{error:n})},this.transport.bind("message",this.onMessage),this.transport.bind("closed",this.onClosed)}unbindListeners(){this.transport.unbind("message",this.onMessage),this.transport.unbind("closed",this.onClosed)}finish(t,e){this.callback(D({transport:this.transport,action:t},e))}}class Pt{constructor(t,e){this.timeline=t,this.options=e||{}}send(t,e){this.timeline.isEmpty()||this.timeline.send(ue.TimelineTransport.getAgent(this,t),e)}}class xt extends at{constructor(t,e){super((function(e,n){W.debug("No callbacks on "+t+" for "+e)})),this.name=t,this.pusher=e,this.subscribed=!1,this.subscriptionPending=!1,this.subscriptionCancelled=!1}authorize(t,e){return e(null,{auth:""})}trigger(t,e){if(0!==t.indexOf("client-"))throw new l("Event '"+t+"' does not start with 'client-'");if(!this.subscribed){var n=u("triggeringClientEvents");W.warn("Client event triggered before channel 'subscription_succeeded' event . "+n)}return this.pusher.send_event(t,e,this.name)}disconnect(){this.subscribed=!1,this.subscriptionPending=!1}handleEvent(t){var e=t.event,n=t.data;if("pusher_internal:subscription_succeeded"===e)this.handleSubscriptionSucceededEvent(t);else if("pusher_internal:subscription_count"===e)this.handleSubscriptionCountEvent(t);else if(0!==e.indexOf("pusher_internal:")){this.emit(e,n,{})}}handleSubscriptionSucceededEvent(t){this.subscriptionPending=!1,this.subscribed=!0,this.subscriptionCancelled?this.pusher.unsubscribe(this.name):this.emit("pusher:subscription_succeeded",t.data)}handleSubscriptionCountEvent(t){t.data.subscription_count&&(this.subscriptionCount=t.data.subscription_count),this.emit("pusher:subscription_count",t.data)}subscribe(){this.subscribed||(this.subscriptionPending=!0,this.subscriptionCancelled=!1,this.authorize(this.pusher.connection.socket_id,(t,e)=>{t?(this.subscriptionPending=!1,W.error(t.toString()),this.emit("pusher:subscription_error",Object.assign({},{type:"AuthError",error:t.message},t instanceof m?{status:t.status}:{}))):this.pusher.send_event("pusher:subscribe",{auth:e.auth,channel_data:e.channel_data,channel:this.name})}))}unsubscribe(){this.subscribed=!1,this.pusher.send_event("pusher:unsubscribe",{channel:this.name})}cancelSubscription(){this.subscriptionCancelled=!0}reinstateSubscription(){this.subscriptionCancelled=!1}}class At extends xt{authorize(t,e){return this.pusher.config.channelAuthorizer({channelName:this.name,socketId:t},e)}}class Ot{constructor(){this.reset()}get(t){return Object.prototype.hasOwnProperty.call(this.members,t)?{id:t,info:this.members[t]}:null}each(t){B(this.members,(e,n)=>{t(this.get(n))})}setMyID(t){this.myID=t}onSubscription(t){this.members=t.presence.hash,this.count=t.presence.count,this.me=this.get(this.myID)}addMember(t){return null===this.get(t.user_id)&&this.count++,this.members[t.user_id]=t.user_info,this.get(t.user_id)}removeMember(t){var e=this.get(t.user_id);return e&&(delete this.members[t.user_id],this.count--),e}reset(){this.members={},this.count=0,this.myID=null,this.me=null}}var Lt=function(t,e,n,r){return new(n||(n=Promise))((function(i,s){function o(t){try{c(r.next(t))}catch(t){s(t)}}function a(t){try{c(r.throw(t))}catch(t){s(t)}}function c(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(o,a)}c((r=r.apply(t,e||[])).next())}))};class Rt extends At{constructor(t,e){super(t,e),this.members=new Ot}authorize(t,e){super.authorize(t,(t,n)=>Lt(this,void 0,void 0,(function*(){if(!t)if(null!=(n=n).channel_data){var r=JSON.parse(n.channel_data);this.members.setMyID(r.user_id)}else{if(yield this.pusher.user.signinDonePromise,null==this.pusher.user.user_data){let t=u("authorizationEndpoint");return W.error(`Invalid auth response for channel '${this.name}', expected 'channel_data' field. ${t}, or the user should be signed in.`),void e("Invalid auth response")}this.members.setMyID(this.pusher.user.user_data.id)}e(t,n)})))}handleEvent(t){var e=t.event;if(0===e.indexOf("pusher_internal:"))this.handleInternalEvent(t);else{var n=t.data,r={};t.user_id&&(r.user_id=t.user_id),this.emit(e,n,r)}}handleInternalEvent(t){var e=t.event,n=t.data;switch(e){case"pusher_internal:subscription_succeeded":this.handleSubscriptionSucceededEvent(t);break;case"pusher_internal:subscription_count":this.handleSubscriptionCountEvent(t);break;case"pusher_internal:member_added":var r=this.members.addMember(n);this.emit("pusher:member_added",r);break;case"pusher_internal:member_removed":var i=this.members.removeMember(n);i&&this.emit("pusher:member_removed",i)}}handleSubscriptionSucceededEvent(t){this.subscriptionPending=!1,this.subscribed=!0,this.subscriptionCancelled?this.pusher.unsubscribe(this.name):(this.members.onSubscription(t.data),this.emit("pusher:subscription_succeeded",this.members))}disconnect(){this.members.reset(),super.disconnect()}}var Ut=n(1),It=n(0);class Mt extends At{constructor(t,e,n){super(t,e),this.key=null,this.nacl=n}authorize(t,e){super.authorize(t,(t,n)=>{if(t)return void e(t,n);let r=n.shared_secret;r?(this.key=Object(It.decode)(r),delete n.shared_secret,e(null,n)):e(new Error("No shared_secret key in auth payload for encrypted channel: "+this.name),null)})}trigger(t,e){throw new v("Client events are not currently supported for encrypted channels")}handleEvent(t){var e=t.event,n=t.data;0!==e.indexOf("pusher_internal:")&&0!==e.indexOf("pusher:")?this.handleEncryptedEvent(e,n):super.handleEvent(t)}handleEncryptedEvent(t,e){if(!this.key)return void W.debug("Received encrypted event before key has been retrieved from the authEndpoint");if(!e.ciphertext||!e.nonce)return void W.error("Unexpected format for encrypted event, expected object with `ciphertext` and `nonce` fields, got: "+e);let n=Object(It.decode)(e.ciphertext);if(n.length{e?W.error(`Failed to make a request to the authEndpoint: ${s}. Unable to fetch new key, so dropping encrypted event`):(i=this.nacl.secretbox.open(n,r,this.key),null!==i?this.emit(t,this.getDataToEmit(i)):W.error("Failed to decrypt event with new key. Dropping encrypted event"))});this.emit(t,this.getDataToEmit(i))}getDataToEmit(t){let e=Object(Ut.decode)(t);try{return JSON.parse(e)}catch(t){return e}}}class Dt extends at{constructor(t,e){super(),this.state="initialized",this.connection=null,this.key=t,this.options=e,this.timeline=this.options.timeline,this.usingTLS=this.options.useTLS,this.errorCallbacks=this.buildErrorCallbacks(),this.connectionCallbacks=this.buildConnectionCallbacks(this.errorCallbacks),this.handshakeCallbacks=this.buildHandshakeCallbacks(this.errorCallbacks);var n=ue.getNetwork();n.bind("online",()=>{this.timeline.info({netinfo:"online"}),"connecting"!==this.state&&"unavailable"!==this.state||this.retryIn(0)}),n.bind("offline",()=>{this.timeline.info({netinfo:"offline"}),this.connection&&this.sendActivityCheck()}),this.updateStrategy()}switchCluster(t){this.key=t,this.updateStrategy(),this.retryIn(0)}connect(){this.connection||this.runner||(this.strategy.isSupported()?(this.updateState("connecting"),this.startConnecting(),this.setUnavailableTimer()):this.updateState("failed"))}send(t){return!!this.connection&&this.connection.send(t)}send_event(t,e,n){return!!this.connection&&this.connection.send_event(t,e,n)}disconnect(){this.disconnectInternally(),this.updateState("disconnected")}isUsingTLS(){return this.usingTLS}startConnecting(){var t=(e,n)=>{e?this.runner=this.strategy.connect(0,t):"error"===n.action?(this.emit("error",{type:"HandshakeError",error:n.error}),this.timeline.error({handshakeError:n.error})):(this.abortConnecting(),this.handshakeCallbacks[n.action](n))};this.runner=this.strategy.connect(0,t)}abortConnecting(){this.runner&&(this.runner.abort(),this.runner=null)}disconnectInternally(){(this.abortConnecting(),this.clearRetryTimer(),this.clearUnavailableTimer(),this.connection)&&this.abandonConnection().close()}updateStrategy(){this.strategy=this.options.getStrategy({key:this.key,timeline:this.timeline,useTLS:this.usingTLS})}retryIn(t){this.timeline.info({action:"retry",delay:t}),t>0&&this.emit("connecting_in",Math.round(t/1e3)),this.retryTimer=new U(t||0,()=>{this.disconnectInternally(),this.connect()})}clearRetryTimer(){this.retryTimer&&(this.retryTimer.ensureAborted(),this.retryTimer=null)}setUnavailableTimer(){this.unavailableTimer=new U(this.options.unavailableTimeout,()=>{this.updateState("unavailable")})}clearUnavailableTimer(){this.unavailableTimer&&this.unavailableTimer.ensureAborted()}sendActivityCheck(){this.stopActivityCheck(),this.connection.ping(),this.activityTimer=new U(this.options.pongTimeout,()=>{this.timeline.error({pong_timed_out:this.options.pongTimeout}),this.retryIn(0)})}resetActivityCheck(){this.stopActivityCheck(),this.connection&&!this.connection.handlesActivityChecks()&&(this.activityTimer=new U(this.activityTimeout,()=>{this.sendActivityCheck()}))}stopActivityCheck(){this.activityTimer&&this.activityTimer.ensureAborted()}buildConnectionCallbacks(t){return D({},t,{message:t=>{this.resetActivityCheck(),this.emit("message",t)},ping:()=>{this.send_event("pusher:pong",{})},activity:()=>{this.resetActivityCheck()},error:t=>{this.emit("error",t)},closed:()=>{this.abandonConnection(),this.shouldRetry()&&this.retryIn(1e3)}})}buildHandshakeCallbacks(t){return D({},t,{connected:t=>{this.activityTimeout=Math.min(this.options.activityTimeout,t.activityTimeout,t.connection.activityTimeout||1/0),this.clearUnavailableTimer(),this.setConnection(t.connection),this.socket_id=this.connection.id,this.updateState("connected",{socket_id:this.socket_id})}})}buildErrorCallbacks(){let t=t=>e=>{e.error&&this.emit("error",{type:"WebSocketError",error:e.error}),t(e)};return{tls_only:t(()=>{this.usingTLS=!0,this.updateStrategy(),this.retryIn(0)}),refused:t(()=>{this.disconnect()}),backoff:t(()=>{this.retryIn(1e3)}),retry:t(()=>{this.retryIn(0)})}}setConnection(t){for(var e in this.connection=t,this.connectionCallbacks)this.connection.bind(e,this.connectionCallbacks[e]);this.resetActivityCheck()}abandonConnection(){if(this.connection){for(var t in this.stopActivityCheck(),this.connectionCallbacks)this.connection.unbind(t,this.connectionCallbacks[t]);var e=this.connection;return this.connection=null,e}}updateState(t,e){var n=this.state;if(this.state=t,n!==t){var r=t;"connected"===r&&(r+=" with new socket ID "+e.socket_id),W.debug("State changed",n+" -> "+r),this.timeline.info({state:t,params:e}),this.emit("state_change",{previous:n,current:t}),this.emit(t,e)}}shouldRetry(){return"connecting"===this.state||"connected"===this.state}}class Nt{constructor(){this.channels={}}add(t,e){return this.channels[t]||(this.channels[t]=function(t,e){if(0===t.indexOf("private-encrypted-")){if(e.config.nacl)return jt.createEncryptedChannel(t,e,e.config.nacl);let n="Tried to subscribe to a private-encrypted- channel but no nacl implementation available",r=u("encryptedChannelSupport");throw new v(`${n}. ${r}`)}if(0===t.indexOf("private-"))return jt.createPrivateChannel(t,e);if(0===t.indexOf("presence-"))return jt.createPresenceChannel(t,e);if(0===t.indexOf("#"))throw new d('Cannot create a channel with name "'+t+'".');return jt.createChannel(t,e)}(t,e)),this.channels[t]}all(){return function(t){var e=[];return B(t,(function(t){e.push(t)})),e}(this.channels)}find(t){return this.channels[t]}remove(t){var e=this.channels[t];return delete this.channels[t],e}disconnect(){B(this.channels,(function(t){t.disconnect()}))}}var jt={createChannels:()=>new Nt,createConnectionManager:(t,e)=>new Dt(t,e),createChannel:(t,e)=>new xt(t,e),createPrivateChannel:(t,e)=>new At(t,e),createPresenceChannel:(t,e)=>new Rt(t,e),createEncryptedChannel:(t,e,n)=>new Mt(t,e,n),createTimelineSender:(t,e)=>new Pt(t,e),createHandshake:(t,e)=>new Et(t,e),createAssistantToTheTransportManager:(t,e,n)=>new St(t,e,n)};class Bt{constructor(t){this.options=t||{},this.livesLeft=this.options.lives||1/0}getAssistant(t){return jt.createAssistantToTheTransportManager(this,t,{minPingDelay:this.options.minPingDelay,maxPingDelay:this.options.maxPingDelay})}isAlive(){return this.livesLeft>0}reportDeath(){this.livesLeft-=1}}class zt{constructor(t,e){this.strategies=t,this.loop=Boolean(e.loop),this.failFast=Boolean(e.failFast),this.timeout=e.timeout,this.timeoutLimit=e.timeoutLimit}isSupported(){return J(this.strategies,M.method("isSupported"))}connect(t,e){var n=this.strategies,r=0,i=this.timeout,s=null,o=(a,c)=>{c?e(null,c):(r+=1,this.loop&&(r%=n.length),r0&&(i=new U(n.timeout,(function(){s.abort(),r(!0)}))),s=t.connect(e,(function(t,e){t&&i&&i.isRunning()&&!n.failFast||(i&&i.ensureAborted(),r(t,e))})),{abort:function(){i&&i.ensureAborted(),s.abort()},forceMinPriority:function(t){s.forceMinPriority(t)}}}}class Ht{constructor(t){this.strategies=t}isSupported(){return J(this.strategies,M.method("isSupported"))}connect(t,e){return function(t,e,n){var r=q(t,(function(t,r,i,s){return t.connect(e,n(r,s))}));return{abort:function(){H(r,qt)},forceMinPriority:function(t){H(r,(function(e){e.forceMinPriority(t)}))}}}(this.strategies,t,(function(t,n){return function(r,i){n[t].error=r,r?function(t){return function(t,e){for(var n=0;n=M.now()){var o=this.transports[r.transport];o&&(["ws","wss"].includes(r.transport)||i>3?(this.timeline.info({cached:!0,transport:r.transport,latency:r.latency}),s.push(new zt([o],{timeout:2*r.latency+1e3,failFast:!0}))):i++)}var a=M.now(),c=s.pop().connect(t,(function r(o,h){o?(Jt(n),s.length>0?(a=M.now(),c=s.pop().connect(t,r)):e(o)):(!function(t,e,n,r){var i=ue.getLocalStorage();if(i)try{i[Xt(t)]=$({timestamp:M.now(),transport:e,latency:n,cacheSkipCount:r})}catch(t){}}(n,h.transport.name,M.now()-a,i),e(null,h))}));return{abort:function(){c.abort()},forceMinPriority:function(e){t=e,c&&c.forceMinPriority(e)}}}}function Xt(t){return"pusherTransport"+(t?"TLS":"NonTLS")}function Jt(t){var e=ue.getLocalStorage();if(e)try{delete e[Xt(t)]}catch(t){}}class Yt{constructor(t,{delay:e}){this.strategy=t,this.options={delay:e}}isSupported(){return this.strategy.isSupported()}connect(t,e){var n,r=this.strategy,i=new U(this.options.delay,(function(){n=r.connect(t,e)}));return{abort:function(){i.ensureAborted(),n&&n.abort()},forceMinPriority:function(e){t=e,n&&n.forceMinPriority(e)}}}}class Kt{constructor(t,e,n){this.test=t,this.trueBranch=e,this.falseBranch=n}isSupported(){return(this.test()?this.trueBranch:this.falseBranch).isSupported()}connect(t,e){return(this.test()?this.trueBranch:this.falseBranch).connect(t,e)}}class $t{constructor(t){this.strategy=t}isSupported(){return this.strategy.isSupported()}connect(t,e){var n=this.strategy.connect(t,(function(t,r){r&&n.abort(),e(t,r)}));return n}}function Wt(t){return function(){return t.isSupported()}}var Gt=function(t,e,n){var r={};function i(e,i,s,o,a){var c=n(t,e,i,s,o,a);return r[e]=c,c}var s,o=Object.assign({},e,{hostNonTLS:t.wsHost+":"+t.wsPort,hostTLS:t.wsHost+":"+t.wssPort,httpPath:t.wsPath}),a=Object.assign({},o,{useTLS:!0}),c=Object.assign({},e,{hostNonTLS:t.httpHost+":"+t.httpPort,hostTLS:t.httpHost+":"+t.httpsPort,httpPath:t.httpPath}),h={loop:!0,timeout:15e3,timeoutLimit:6e4},u=new Bt({minPingDelay:1e4,maxPingDelay:t.activityTimeout}),l=new Bt({lives:2,minPingDelay:1e4,maxPingDelay:t.activityTimeout}),d=i("ws","ws",3,o,u),p=i("wss","ws",3,a,u),f=i("sockjs","sockjs",1,c),g=i("xhr_streaming","xhr_streaming",1,c,l),v=i("xdr_streaming","xdr_streaming",1,c,l),b=i("xhr_polling","xhr_polling",1,c),y=i("xdr_polling","xdr_polling",1,c),m=new zt([d],h),w=new zt([p],h),_=new zt([f],h),S=new zt([new Kt(Wt(g),g,v)],h),k=new zt([new Kt(Wt(b),b,y)],h),C=new zt([new Kt(Wt(S),new Ht([S,new Yt(k,{delay:4e3})]),k)],h),T=new Kt(Wt(C),C,_);return s=e.useTLS?new Ht([m,new Yt(T,{delay:2e3})]):new Ht([m,new Yt(w,{delay:2e3}),new Yt(T,{delay:5e3})]),new Ft(new $t(new Kt(Wt(d),s,T)),r,{ttl:18e5,timeline:e.timeline,useTLS:e.useTLS})},Vt={getRequest:function(t){var e=new window.XDomainRequest;return e.ontimeout=function(){t.emit("error",new p),t.close()},e.onerror=function(e){t.emit("error",e),t.close()},e.onprogress=function(){e.responseText&&e.responseText.length>0&&t.onChunk(200,e.responseText)},e.onload=function(){e.responseText&&e.responseText.length>0&&t.onChunk(200,e.responseText),t.emit("finished",200),t.close()},e},abortRequest:function(t){t.ontimeout=t.onerror=t.onprogress=t.onload=null,t.abort()}};class Zt extends at{constructor(t,e,n){super(),this.hooks=t,this.method=e,this.url=n}start(t){this.position=0,this.xhr=this.hooks.getRequest(this),this.unloader=()=>{this.close()},ue.addUnloadListener(this.unloader),this.xhr.open(this.method,this.url,!0),this.xhr.setRequestHeader&&this.xhr.setRequestHeader("Content-Type","application/json"),this.xhr.send(t)}close(){this.unloader&&(ue.removeUnloadListener(this.unloader),this.unloader=null),this.xhr&&(this.hooks.abortRequest(this.xhr),this.xhr=null)}onChunk(t,e){for(;;){var n=this.advanceBuffer(e);if(!n)break;this.emit("chunk",{status:t,data:n})}this.isBufferTooLong(e)&&this.emit("buffer_too_long")}advanceBuffer(t){var e=t.slice(this.position),n=e.indexOf("\n");return-1!==n?(this.position+=n+1,e.slice(0,n)):null}isBufferTooLong(t){return this.position===t.length&&t.length>262144}}var Qt;!function(t){t[t.CONNECTING=0]="CONNECTING",t[t.OPEN=1]="OPEN",t[t.CLOSED=3]="CLOSED"}(Qt||(Qt={}));var te=Qt,ee=1;function ne(t){var e=-1===t.indexOf("?")?"?":"&";return t+e+"t="+ +new Date+"&n="+ee++}function re(t){return ue.randomInt(t)}var ie,se=class{constructor(t,e){this.hooks=t,this.session=re(1e3)+"/"+function(t){for(var e=[],n=0;n{this.onChunk(t)}),this.stream.bind("finished",t=>{this.hooks.onFinished(this,t)}),this.stream.bind("buffer_too_long",()=>{this.reconnect()});try{this.stream.start()}catch(t){M.defer(()=>{this.onError(t),this.onClose(1006,"Could not start streaming",!1)})}}closeStream(){this.stream&&(this.stream.unbind_all(),this.stream.close(),this.stream=null)}},oe={getReceiveURL:function(t,e){return t.base+"/"+e+"/xhr_streaming"+t.queryString},onHeartbeat:function(t){t.sendRaw("[]")},sendHeartbeat:function(t){t.sendRaw("[]")},onFinished:function(t,e){t.onClose(1006,"Connection interrupted ("+e+")",!1)}},ae={getReceiveURL:function(t,e){return t.base+"/"+e+"/xhr"+t.queryString},onHeartbeat:function(){},sendHeartbeat:function(t){t.sendRaw("[]")},onFinished:function(t,e){200===e?t.reconnect():t.onClose(1006,"Connection interrupted ("+e+")",!1)}},ce={getRequest:function(t){var e=new(ue.getXHRAPI());return e.onreadystatechange=e.onprogress=function(){switch(e.readyState){case 3:e.responseText&&e.responseText.length>0&&t.onChunk(e.status,e.responseText);break;case 4:e.responseText&&e.responseText.length>0&&t.onChunk(e.status,e.responseText),t.emit("finished",e.status),t.close()}},e},abortRequest:function(t){t.onreadystatechange=null,t.abort()}},he={createStreamingSocket(t){return this.createSocket(oe,t)},createPollingSocket(t){return this.createSocket(ae,t)},createSocket:(t,e)=>new se(t,e),createXHR(t,e){return this.createRequest(ce,t,e)},createRequest:(t,e,n)=>new Zt(t,e,n),createXDR:function(t,e){return this.createRequest(Vt,t,e)}},ue={nextAuthCallbackID:1,auth_callbacks:{},ScriptReceivers:i,DependenciesReceivers:o,getDefaultStrategy:Gt,Transports:wt,transportConnectionInitializer:function(){var t=this;t.timeline.info(t.buildTimelineMessage({transport:t.name+(t.options.useTLS?"s":"")})),t.hooks.isInitialized()?t.changeState("initialized"):t.hooks.file?(t.changeState("initializing"),a.load(t.hooks.file,{useTLS:t.options.useTLS},(function(e,n){t.hooks.isInitialized()?(t.changeState("initialized"),n(!0)):(e&&t.onError(e),t.onClose(),n(!1))}))):t.onClose()},HTTPFactory:he,TimelineTransport:Q,getXHRAPI:()=>window.XMLHttpRequest,getWebSocketAPI:()=>window.WebSocket||window.MozWebSocket,setup(t){window.Pusher=t;var e=()=>{this.onDocumentBody(t.ready)};window.JSON?e():a.load("json2",{},e)},getDocument:()=>document,getProtocol(){return this.getDocument().location.protocol},getAuthorizers:()=>({ajax:w,jsonp:G}),onDocumentBody(t){document.body?t():setTimeout(()=>{this.onDocumentBody(t)},0)},createJSONPRequest:(t,e)=>new Z(t,e),createScriptRequest:t=>new V(t),getLocalStorage(){try{return window.localStorage}catch(t){return}},createXHR(){return this.getXHRAPI()?this.createXMLHttpRequest():this.createMicrosoftXHR()},createXMLHttpRequest(){return new(this.getXHRAPI())},createMicrosoftXHR:()=>new ActiveXObject("Microsoft.XMLHTTP"),getNetwork:()=>_t,createWebSocket(t){return new(this.getWebSocketAPI())(t)},createSocketRequest(t,e){if(this.isXHRSupported())return this.HTTPFactory.createXHR(t,e);if(this.isXDRSupported(0===e.indexOf("https:")))return this.HTTPFactory.createXDR(t,e);throw"Cross-origin HTTP requests are not supported"},isXHRSupported(){var t=this.getXHRAPI();return Boolean(t)&&void 0!==(new t).withCredentials},isXDRSupported(t){var e=t?"https:":"http:",n=this.getProtocol();return Boolean(window.XDomainRequest)&&n===e},addUnloadListener(t){void 0!==window.addEventListener?window.addEventListener("unload",t,!1):void 0!==window.attachEvent&&window.attachEvent("onunload",t)},removeUnloadListener(t){void 0!==window.addEventListener?window.removeEventListener("unload",t,!1):void 0!==window.detachEvent&&window.detachEvent("onunload",t)},randomInt:t=>Math.floor((window.crypto||window.msCrypto).getRandomValues(new Uint32Array(1))[0]/Math.pow(2,32)*t)};!function(t){t[t.ERROR=3]="ERROR",t[t.INFO=6]="INFO",t[t.DEBUG=7]="DEBUG"}(ie||(ie={}));var le=ie;class de{constructor(t,e,n){this.key=t,this.session=e,this.events=[],this.options=n||{},this.sent=0,this.uniqueID=0}log(t,e){t<=this.options.level&&(this.events.push(D({},e,{timestamp:M.now()})),this.options.limit&&this.events.length>this.options.limit&&this.events.shift())}error(t){this.log(le.ERROR,t)}info(t){this.log(le.INFO,t)}debug(t){this.log(le.DEBUG,t)}isEmpty(){return 0===this.events.length}send(t,e){var n=D({session:this.session,bundle:this.sent+1,key:this.key,lib:"js",version:this.options.version,cluster:this.options.cluster,features:this.options.features,timeline:this.events},this.options.params);return this.events=[],t(n,(t,n)=>{t||this.sent++,e&&e(t,n)}),!0}generateUniqueID(){return this.uniqueID++,this.uniqueID}}class pe{constructor(t,e,n,r){this.name=t,this.priority=e,this.transport=n,this.options=r||{}}isSupported(){return this.transport.isSupported({useTLS:this.options.useTLS})}connect(t,e){if(!this.isSupported())return fe(new y,e);if(this.priority{n||(h(),i?i.close():r.close())},forceMinPriority:t=>{n||this.priority{if(void 0===ue.getAuthorizers()[t.transport])throw`'${t.transport}' is not a recognized auth transport`;return(e,n)=>{const r=((t,e)=>{var n="socket_id="+encodeURIComponent(t.socketId);for(var r in e.params)n+="&"+encodeURIComponent(r)+"="+encodeURIComponent(e.params[r]);if(null!=e.paramsProvider){let t=e.paramsProvider();for(var r in t)n+="&"+encodeURIComponent(r)+"="+encodeURIComponent(t[r])}return n})(e,t);ue.getAuthorizers()[t.transport](ue,r,t,h.UserAuthentication,n)}};var we=t=>{if(void 0===ue.getAuthorizers()[t.transport])throw`'${t.transport}' is not a recognized auth transport`;return(e,n)=>{const r=((t,e)=>{var n="socket_id="+encodeURIComponent(t.socketId);for(var r in n+="&channel_name="+encodeURIComponent(t.channelName),e.params)n+="&"+encodeURIComponent(r)+"="+encodeURIComponent(e.params[r]);if(null!=e.paramsProvider){let t=e.paramsProvider();for(var r in t)n+="&"+encodeURIComponent(r)+"="+encodeURIComponent(t[r])}return n})(e,t);ue.getAuthorizers()[t.transport](ue,r,t,h.ChannelAuthorization,n)}};function _e(t,e){let n={activityTimeout:t.activityTimeout||s.activityTimeout,cluster:t.cluster,httpPath:t.httpPath||s.httpPath,httpPort:t.httpPort||s.httpPort,httpsPort:t.httpsPort||s.httpsPort,pongTimeout:t.pongTimeout||s.pongTimeout,statsHost:t.statsHost||s.stats_host,unavailableTimeout:t.unavailableTimeout||s.unavailableTimeout,wsPath:t.wsPath||s.wsPath,wsPort:t.wsPort||s.wsPort,wssPort:t.wssPort||s.wssPort,enableStats:Te(t),httpHost:Se(t),useTLS:Ce(t),wsHost:ke(t),userAuthenticator:Ee(t),channelAuthorizer:Pe(t,e)};return"disabledTransports"in t&&(n.disabledTransports=t.disabledTransports),"enabledTransports"in t&&(n.enabledTransports=t.enabledTransports),"ignoreNullOrigin"in t&&(n.ignoreNullOrigin=t.ignoreNullOrigin),"timelineParams"in t&&(n.timelineParams=t.timelineParams),"nacl"in t&&(n.nacl=t.nacl),n}function Se(t){return t.httpHost?t.httpHost:t.cluster?`sockjs-${t.cluster}.pusher.com`:s.httpHost}function ke(t){return t.wsHost?t.wsHost:`ws-${t.cluster}.pusher.com`}function Ce(t){return"https:"===ue.getProtocol()||!1!==t.forceTLS}function Te(t){return"enableStats"in t?t.enableStats:"disableStats"in t&&!t.disableStats}function Ee(t){const e=Object.assign(Object.assign({},s.userAuthentication),t.userAuthentication);return"customHandler"in e&&null!=e.customHandler?e.customHandler:me(e)}function Pe(t,e){const n=function(t,e){let n;return"channelAuthorization"in t?n=Object.assign(Object.assign({},s.channelAuthorization),t.channelAuthorization):(n={transport:t.authTransport||s.authTransport,endpoint:t.authEndpoint||s.authEndpoint},"auth"in t&&("params"in t.auth&&(n.params=t.auth.params),"headers"in t.auth&&(n.headers=t.auth.headers)),"authorizer"in t&&(n.customHandler=((t,e,n)=>{const r={authTransport:e.transport,authEndpoint:e.endpoint,auth:{params:e.params,headers:e.headers}};return(e,i)=>{const s=t.channel(e.channelName);n(s,r).authorize(e.socketId,i)}})(e,n,t.authorizer))),n}(t,e);return"customHandler"in n&&null!=n.customHandler?n.customHandler:we(n)}class xe extends at{constructor(t){super((function(t,e){W.debug("No callbacks on watchlist events for "+t)})),this.pusher=t,this.bindWatchlistInternalEvent()}handleEvent(t){t.data.events.forEach(t=>{this.emit(t.name,t)})}bindWatchlistInternalEvent(){this.pusher.connection.bind("message",t=>{"pusher_internal:watchlist_events"===t.event&&this.handleEvent(t)})}}var Ae=function(){let t,e;return{promise:new Promise((n,r)=>{t=n,e=r}),resolve:t,reject:e}};class Oe extends at{constructor(t){super((function(t,e){W.debug("No callbacks on user for "+t)})),this.signin_requested=!1,this.user_data=null,this.serverToUserChannel=null,this.signinDonePromise=null,this._signinDoneResolve=null,this._onAuthorize=(t,e)=>{if(t)return W.warn("Error during signin: "+t),void this._cleanup();this.pusher.send_event("pusher:signin",{auth:e.auth,user_data:e.user_data})},this.pusher=t,this.pusher.connection.bind("state_change",({previous:t,current:e})=>{"connected"!==t&&"connected"===e&&this._signin(),"connected"===t&&"connected"!==e&&(this._cleanup(),this._newSigninPromiseIfNeeded())}),this.watchlist=new xe(t),this.pusher.connection.bind("message",t=>{"pusher:signin_success"===t.event&&this._onSigninSuccess(t.data),this.serverToUserChannel&&this.serverToUserChannel.name===t.channel&&this.serverToUserChannel.handleEvent(t)})}signin(){this.signin_requested||(this.signin_requested=!0,this._signin())}_signin(){this.signin_requested&&(this._newSigninPromiseIfNeeded(),"connected"===this.pusher.connection.state&&this.pusher.config.userAuthenticator({socketId:this.pusher.connection.socket_id},this._onAuthorize))}_onSigninSuccess(t){try{this.user_data=JSON.parse(t.user_data)}catch(e){return W.error("Failed parsing user data after signin: "+t.user_data),void this._cleanup()}if("string"!=typeof this.user_data.id||""===this.user_data.id)return W.error("user_data doesn't contain an id. user_data: "+this.user_data),void this._cleanup();this._signinDoneResolve(),this._subscribeChannels()}_subscribeChannels(){this.serverToUserChannel=new xt("#server-to-user-"+this.user_data.id,this.pusher),this.serverToUserChannel.bind_global((t,e)=>{0!==t.indexOf("pusher_internal:")&&0!==t.indexOf("pusher:")&&this.emit(t,e)}),(t=>{t.subscriptionPending&&t.subscriptionCancelled?t.reinstateSubscription():t.subscriptionPending||"connected"!==this.pusher.connection.state||t.subscribe()})(this.serverToUserChannel)}_cleanup(){this.user_data=null,this.serverToUserChannel&&(this.serverToUserChannel.unbind_all(),this.serverToUserChannel.disconnect(),this.serverToUserChannel=null),this.signin_requested&&this._signinDoneResolve()}_newSigninPromiseIfNeeded(){if(!this.signin_requested)return;if(this.signinDonePromise&&!this.signinDonePromise.done)return;const{promise:t,resolve:e,reject:n}=Ae();t.done=!1;const r=()=>{t.done=!0};t.then(r).catch(r),this.signinDonePromise=t,this._signinDoneResolve=e}}class Le{static ready(){Le.isReady=!0;for(var t=0,e=Le.instances.length;tue.getDefaultStrategy(this.config,t,ve),timeline:this.timeline,activityTimeout:this.config.activityTimeout,pongTimeout:this.config.pongTimeout,unavailableTimeout:this.config.unavailableTimeout,useTLS:Boolean(this.config.useTLS)}),this.connection.bind("connected",()=>{this.subscribeAll(),this.timelineSender&&this.timelineSender.send(this.connection.isUsingTLS())}),this.connection.bind("message",t=>{var e=0===t.event.indexOf("pusher_internal:");if(t.channel){var n=this.channel(t.channel);n&&n.handleEvent(t)}e||this.global_emitter.emit(t.event,t.data)}),this.connection.bind("connecting",()=>{this.channels.disconnect()}),this.connection.bind("disconnected",()=>{this.channels.disconnect()}),this.connection.bind("error",t=>{W.warn(t)}),Le.instances.push(this),this.timeline.info({instances:Le.instances.length}),this.user=new Oe(this),Le.isReady&&this.connect()}switchCluster(t){const{appKey:e,cluster:n}=t;this.key=e,this.options=Object.assign(Object.assign({},this.options),{cluster:n}),this.config=_e(this.options,this),this.connection.switchCluster(this.key)}channel(t){return this.channels.find(t)}allChannels(){return this.channels.all()}connect(){if(this.connection.connect(),this.timelineSender&&!this.timelineSenderTimer){var t=this.connection.isUsingTLS(),e=this.timelineSender;this.timelineSenderTimer=new I(6e4,(function(){e.send(t)}))}}disconnect(){this.connection.disconnect(),this.timelineSenderTimer&&(this.timelineSenderTimer.ensureAborted(),this.timelineSenderTimer=null)}bind(t,e,n){return this.global_emitter.bind(t,e,n),this}unbind(t,e,n){return this.global_emitter.unbind(t,e,n),this}bind_global(t){return this.global_emitter.bind_global(t),this}unbind_global(t){return this.global_emitter.unbind_global(t),this}unbind_all(t){return this.global_emitter.unbind_all(),this}subscribeAll(){var t;for(t in this.channels.channels)this.channels.channels.hasOwnProperty(t)&&this.subscribe(t)}subscribe(t){var e=this.channels.add(t,this);return e.subscriptionPending&&e.subscriptionCancelled?e.reinstateSubscription():e.subscriptionPending||"connected"!==this.connection.state||e.subscribe(),e}unsubscribe(t){var e=this.channels.find(t);e&&e.subscriptionPending?e.cancelSubscription():(e=this.channels.remove(t))&&e.subscribed&&e.unsubscribe()}send_event(t,e,n){return this.connection.send_event(t,e,n)}shouldUseTLS(){return this.config.useTLS}signin(){this.user.signin()}}Le.instances=[],Le.isReady=!1,Le.logToConsole=!1,Le.Runtime=ue,Le.ScriptReceivers=ue.ScriptReceivers,Le.DependenciesReceivers=ue.DependenciesReceivers,Le.auth_callbacks=ue.auth_callbacks;var Re=Le;ue.setup(Le);var Ue=n(2);class Ie extends Re{constructor(t,e){Re.logToConsole=Ie.logToConsole,Re.log=Ie.log,ye(e),e.nacl=Ue,super(t,e)}}}])})); +!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.Pusher=e():t.Pusher=e()}(window,(function(){return function(t){var e={};function n(r){if(e[r])return e[r].exports;var i=e[r]={i:r,l:!1,exports:{}};return t[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)n.d(r,i,function(e){return t[e]}.bind(null,i));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=3)}([function(t,e,n){"use strict";var r,i=this&&this.__extends||(r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)},function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)});Object.defineProperty(e,"__esModule",{value:!0});var s=function(){function t(t){void 0===t&&(t="="),this._paddingCharacter=t}return t.prototype.encodedLength=function(t){return this._paddingCharacter?(t+2)/3*4|0:(8*t+5)/6|0},t.prototype.encode=function(t){for(var e="",n=0;n>>18&63),e+=this._encodeByte(r>>>12&63),e+=this._encodeByte(r>>>6&63),e+=this._encodeByte(r>>>0&63)}var i=t.length-n;if(i>0){r=t[n]<<16|(2===i?t[n+1]<<8:0);e+=this._encodeByte(r>>>18&63),e+=this._encodeByte(r>>>12&63),e+=2===i?this._encodeByte(r>>>6&63):this._paddingCharacter||"",e+=this._paddingCharacter||""}return e},t.prototype.maxDecodedLength=function(t){return this._paddingCharacter?t/4*3|0:(6*t+7)/8|0},t.prototype.decodedLength=function(t){return this.maxDecodedLength(t.length-this._getPaddingLength(t))},t.prototype.decode=function(t){if(0===t.length)return new Uint8Array(0);for(var e=this._getPaddingLength(t),n=t.length-e,r=new Uint8Array(this.maxDecodedLength(n)),i=0,s=0,o=0,a=0,c=0,h=0,u=0;s>>4,r[i++]=c<<4|h>>>2,r[i++]=h<<6|u,o|=256&a,o|=256&c,o|=256&h,o|=256&u;if(s>>4,o|=256&a,o|=256&c),s>>2,o|=256&h),s>>8&6,e+=51-t>>>8&-75,e+=61-t>>>8&-15,e+=62-t>>>8&3,String.fromCharCode(e)},t.prototype._decodeChar=function(t){var e=256;return e+=(42-t&t-44)>>>8&-256+t-43+62,e+=(46-t&t-48)>>>8&-256+t-47+63,e+=(47-t&t-58)>>>8&-256+t-48+52,e+=(64-t&t-91)>>>8&-256+t-65+0,e+=(96-t&t-123)>>>8&-256+t-97+26},t.prototype._getPaddingLength=function(t){var e=0;if(this._paddingCharacter){for(var n=t.length-1;n>=0&&t[n]===this._paddingCharacter;n--)e++;if(t.length<4||e>2)throw new Error("Base64Coder: incorrect padding")}return e},t}();e.Coder=s;var o=new s;e.encode=function(t){return o.encode(t)},e.decode=function(t){return o.decode(t)};var a=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return i(e,t),e.prototype._encodeByte=function(t){var e=t;return e+=65,e+=25-t>>>8&6,e+=51-t>>>8&-75,e+=61-t>>>8&-13,e+=62-t>>>8&49,String.fromCharCode(e)},e.prototype._decodeChar=function(t){var e=256;return e+=(44-t&t-46)>>>8&-256+t-45+62,e+=(94-t&t-96)>>>8&-256+t-95+63,e+=(47-t&t-58)>>>8&-256+t-48+52,e+=(64-t&t-91)>>>8&-256+t-65+0,e+=(96-t&t-123)>>>8&-256+t-97+26},e}(s);e.URLSafeCoder=a;var c=new a;e.encodeURLSafe=function(t){return c.encode(t)},e.decodeURLSafe=function(t){return c.decode(t)},e.encodedLength=function(t){return o.encodedLength(t)},e.maxDecodedLength=function(t){return o.maxDecodedLength(t)},e.decodedLength=function(t){return o.decodedLength(t)}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r="utf8: invalid source encoding";function i(t){for(var e=0,n=0;n=t.length-1)throw new Error("utf8: invalid string");n++,e+=4}}return e}e.encode=function(t){for(var e=new Uint8Array(i(t)),n=0,r=0;r>6,e[n++]=128|63&s):s<55296?(e[n++]=224|s>>12,e[n++]=128|s>>6&63,e[n++]=128|63&s):(r++,s=(1023&s)<<10,s|=1023&t.charCodeAt(r),s+=65536,e[n++]=240|s>>18,e[n++]=128|s>>12&63,e[n++]=128|s>>6&63,e[n++]=128|63&s)}return e},e.encodedLength=i,e.decode=function(t){for(var e=[],n=0;n=t.length)throw new Error(r);if(128!=(192&(o=t[++n])))throw new Error(r);i=(31&i)<<6|63&o,s=128}else if(i<240){if(n>=t.length-1)throw new Error(r);var o=t[++n],a=t[++n];if(128!=(192&o)||128!=(192&a))throw new Error(r);i=(15&i)<<12|(63&o)<<6|63&a,s=2048}else{if(!(i<248))throw new Error(r);if(n>=t.length-2)throw new Error(r);o=t[++n],a=t[++n];var c=t[++n];if(128!=(192&o)||128!=(192&a)||128!=(192&c))throw new Error(r);i=(15&i)<<18|(63&o)<<12|(63&a)<<6|63&c,s=65536}if(i=55296&&i<=57343)throw new Error(r);if(i>=65536){if(i>1114111)throw new Error(r);i-=65536,e.push(String.fromCharCode(55296|i>>10)),i=56320|1023&i}}e.push(String.fromCharCode(i))}return e.join("")}},function(t,e,n){!function(t){"use strict";var e=function(t){var e,n=new Float64Array(16);if(t)for(e=0;e>24&255,t[e+1]=n>>16&255,t[e+2]=n>>8&255,t[e+3]=255&n,t[e+4]=r>>24&255,t[e+5]=r>>16&255,t[e+6]=r>>8&255,t[e+7]=255&r}function g(t,e,n,r,i){var s,o=0;for(s=0;s>>8)-1}function v(t,e,n,r){return g(t,e,n,r,16)}function b(t,e,n,r){return g(t,e,n,r,32)}function y(t,e,n,r){!function(t,e,n,r){for(var i,s=255&r[0]|(255&r[1])<<8|(255&r[2])<<16|(255&r[3])<<24,o=255&n[0]|(255&n[1])<<8|(255&n[2])<<16|(255&n[3])<<24,a=255&n[4]|(255&n[5])<<8|(255&n[6])<<16|(255&n[7])<<24,c=255&n[8]|(255&n[9])<<8|(255&n[10])<<16|(255&n[11])<<24,h=255&n[12]|(255&n[13])<<8|(255&n[14])<<16|(255&n[15])<<24,u=255&r[4]|(255&r[5])<<8|(255&r[6])<<16|(255&r[7])<<24,l=255&e[0]|(255&e[1])<<8|(255&e[2])<<16|(255&e[3])<<24,d=255&e[4]|(255&e[5])<<8|(255&e[6])<<16|(255&e[7])<<24,p=255&e[8]|(255&e[9])<<8|(255&e[10])<<16|(255&e[11])<<24,f=255&e[12]|(255&e[13])<<8|(255&e[14])<<16|(255&e[15])<<24,g=255&r[8]|(255&r[9])<<8|(255&r[10])<<16|(255&r[11])<<24,v=255&n[16]|(255&n[17])<<8|(255&n[18])<<16|(255&n[19])<<24,b=255&n[20]|(255&n[21])<<8|(255&n[22])<<16|(255&n[23])<<24,y=255&n[24]|(255&n[25])<<8|(255&n[26])<<16|(255&n[27])<<24,m=255&n[28]|(255&n[29])<<8|(255&n[30])<<16|(255&n[31])<<24,w=255&r[12]|(255&r[13])<<8|(255&r[14])<<16|(255&r[15])<<24,_=s,S=o,k=a,C=c,T=h,E=u,P=l,x=d,A=p,O=f,L=g,R=v,U=b,I=y,M=m,D=w,N=0;N<20;N+=2)_^=(i=(U^=(i=(A^=(i=(T^=(i=_+U|0)<<7|i>>>25)+_|0)<<9|i>>>23)+T|0)<<13|i>>>19)+A|0)<<18|i>>>14,E^=(i=(S^=(i=(I^=(i=(O^=(i=E+S|0)<<7|i>>>25)+E|0)<<9|i>>>23)+O|0)<<13|i>>>19)+I|0)<<18|i>>>14,L^=(i=(P^=(i=(k^=(i=(M^=(i=L+P|0)<<7|i>>>25)+L|0)<<9|i>>>23)+M|0)<<13|i>>>19)+k|0)<<18|i>>>14,D^=(i=(R^=(i=(x^=(i=(C^=(i=D+R|0)<<7|i>>>25)+D|0)<<9|i>>>23)+C|0)<<13|i>>>19)+x|0)<<18|i>>>14,_^=(i=(C^=(i=(k^=(i=(S^=(i=_+C|0)<<7|i>>>25)+_|0)<<9|i>>>23)+S|0)<<13|i>>>19)+k|0)<<18|i>>>14,E^=(i=(T^=(i=(x^=(i=(P^=(i=E+T|0)<<7|i>>>25)+E|0)<<9|i>>>23)+P|0)<<13|i>>>19)+x|0)<<18|i>>>14,L^=(i=(O^=(i=(A^=(i=(R^=(i=L+O|0)<<7|i>>>25)+L|0)<<9|i>>>23)+R|0)<<13|i>>>19)+A|0)<<18|i>>>14,D^=(i=(M^=(i=(I^=(i=(U^=(i=D+M|0)<<7|i>>>25)+D|0)<<9|i>>>23)+U|0)<<13|i>>>19)+I|0)<<18|i>>>14;_=_+s|0,S=S+o|0,k=k+a|0,C=C+c|0,T=T+h|0,E=E+u|0,P=P+l|0,x=x+d|0,A=A+p|0,O=O+f|0,L=L+g|0,R=R+v|0,U=U+b|0,I=I+y|0,M=M+m|0,D=D+w|0,t[0]=_>>>0&255,t[1]=_>>>8&255,t[2]=_>>>16&255,t[3]=_>>>24&255,t[4]=S>>>0&255,t[5]=S>>>8&255,t[6]=S>>>16&255,t[7]=S>>>24&255,t[8]=k>>>0&255,t[9]=k>>>8&255,t[10]=k>>>16&255,t[11]=k>>>24&255,t[12]=C>>>0&255,t[13]=C>>>8&255,t[14]=C>>>16&255,t[15]=C>>>24&255,t[16]=T>>>0&255,t[17]=T>>>8&255,t[18]=T>>>16&255,t[19]=T>>>24&255,t[20]=E>>>0&255,t[21]=E>>>8&255,t[22]=E>>>16&255,t[23]=E>>>24&255,t[24]=P>>>0&255,t[25]=P>>>8&255,t[26]=P>>>16&255,t[27]=P>>>24&255,t[28]=x>>>0&255,t[29]=x>>>8&255,t[30]=x>>>16&255,t[31]=x>>>24&255,t[32]=A>>>0&255,t[33]=A>>>8&255,t[34]=A>>>16&255,t[35]=A>>>24&255,t[36]=O>>>0&255,t[37]=O>>>8&255,t[38]=O>>>16&255,t[39]=O>>>24&255,t[40]=L>>>0&255,t[41]=L>>>8&255,t[42]=L>>>16&255,t[43]=L>>>24&255,t[44]=R>>>0&255,t[45]=R>>>8&255,t[46]=R>>>16&255,t[47]=R>>>24&255,t[48]=U>>>0&255,t[49]=U>>>8&255,t[50]=U>>>16&255,t[51]=U>>>24&255,t[52]=I>>>0&255,t[53]=I>>>8&255,t[54]=I>>>16&255,t[55]=I>>>24&255,t[56]=M>>>0&255,t[57]=M>>>8&255,t[58]=M>>>16&255,t[59]=M>>>24&255,t[60]=D>>>0&255,t[61]=D>>>8&255,t[62]=D>>>16&255,t[63]=D>>>24&255}(t,e,n,r)}function m(t,e,n,r){!function(t,e,n,r){for(var i,s=255&r[0]|(255&r[1])<<8|(255&r[2])<<16|(255&r[3])<<24,o=255&n[0]|(255&n[1])<<8|(255&n[2])<<16|(255&n[3])<<24,a=255&n[4]|(255&n[5])<<8|(255&n[6])<<16|(255&n[7])<<24,c=255&n[8]|(255&n[9])<<8|(255&n[10])<<16|(255&n[11])<<24,h=255&n[12]|(255&n[13])<<8|(255&n[14])<<16|(255&n[15])<<24,u=255&r[4]|(255&r[5])<<8|(255&r[6])<<16|(255&r[7])<<24,l=255&e[0]|(255&e[1])<<8|(255&e[2])<<16|(255&e[3])<<24,d=255&e[4]|(255&e[5])<<8|(255&e[6])<<16|(255&e[7])<<24,p=255&e[8]|(255&e[9])<<8|(255&e[10])<<16|(255&e[11])<<24,f=255&e[12]|(255&e[13])<<8|(255&e[14])<<16|(255&e[15])<<24,g=255&r[8]|(255&r[9])<<8|(255&r[10])<<16|(255&r[11])<<24,v=255&n[16]|(255&n[17])<<8|(255&n[18])<<16|(255&n[19])<<24,b=255&n[20]|(255&n[21])<<8|(255&n[22])<<16|(255&n[23])<<24,y=255&n[24]|(255&n[25])<<8|(255&n[26])<<16|(255&n[27])<<24,m=255&n[28]|(255&n[29])<<8|(255&n[30])<<16|(255&n[31])<<24,w=255&r[12]|(255&r[13])<<8|(255&r[14])<<16|(255&r[15])<<24,_=0;_<20;_+=2)s^=(i=(b^=(i=(p^=(i=(h^=(i=s+b|0)<<7|i>>>25)+s|0)<<9|i>>>23)+h|0)<<13|i>>>19)+p|0)<<18|i>>>14,u^=(i=(o^=(i=(y^=(i=(f^=(i=u+o|0)<<7|i>>>25)+u|0)<<9|i>>>23)+f|0)<<13|i>>>19)+y|0)<<18|i>>>14,g^=(i=(l^=(i=(a^=(i=(m^=(i=g+l|0)<<7|i>>>25)+g|0)<<9|i>>>23)+m|0)<<13|i>>>19)+a|0)<<18|i>>>14,w^=(i=(v^=(i=(d^=(i=(c^=(i=w+v|0)<<7|i>>>25)+w|0)<<9|i>>>23)+c|0)<<13|i>>>19)+d|0)<<18|i>>>14,s^=(i=(c^=(i=(a^=(i=(o^=(i=s+c|0)<<7|i>>>25)+s|0)<<9|i>>>23)+o|0)<<13|i>>>19)+a|0)<<18|i>>>14,u^=(i=(h^=(i=(d^=(i=(l^=(i=u+h|0)<<7|i>>>25)+u|0)<<9|i>>>23)+l|0)<<13|i>>>19)+d|0)<<18|i>>>14,g^=(i=(f^=(i=(p^=(i=(v^=(i=g+f|0)<<7|i>>>25)+g|0)<<9|i>>>23)+v|0)<<13|i>>>19)+p|0)<<18|i>>>14,w^=(i=(m^=(i=(y^=(i=(b^=(i=w+m|0)<<7|i>>>25)+w|0)<<9|i>>>23)+b|0)<<13|i>>>19)+y|0)<<18|i>>>14;t[0]=s>>>0&255,t[1]=s>>>8&255,t[2]=s>>>16&255,t[3]=s>>>24&255,t[4]=u>>>0&255,t[5]=u>>>8&255,t[6]=u>>>16&255,t[7]=u>>>24&255,t[8]=g>>>0&255,t[9]=g>>>8&255,t[10]=g>>>16&255,t[11]=g>>>24&255,t[12]=w>>>0&255,t[13]=w>>>8&255,t[14]=w>>>16&255,t[15]=w>>>24&255,t[16]=l>>>0&255,t[17]=l>>>8&255,t[18]=l>>>16&255,t[19]=l>>>24&255,t[20]=d>>>0&255,t[21]=d>>>8&255,t[22]=d>>>16&255,t[23]=d>>>24&255,t[24]=p>>>0&255,t[25]=p>>>8&255,t[26]=p>>>16&255,t[27]=p>>>24&255,t[28]=f>>>0&255,t[29]=f>>>8&255,t[30]=f>>>16&255,t[31]=f>>>24&255}(t,e,n,r)}var w=new Uint8Array([101,120,112,97,110,100,32,51,50,45,98,121,116,101,32,107]);function _(t,e,n,r,i,s,o){var a,c,h=new Uint8Array(16),u=new Uint8Array(64);for(c=0;c<16;c++)h[c]=0;for(c=0;c<8;c++)h[c]=s[c];for(;i>=64;){for(y(u,h,o,w),c=0;c<64;c++)t[e+c]=n[r+c]^u[c];for(a=1,c=8;c<16;c++)a=a+(255&h[c])|0,h[c]=255&a,a>>>=8;i-=64,e+=64,r+=64}if(i>0)for(y(u,h,o,w),c=0;c=64;){for(y(c,a,i,w),o=0;o<64;o++)t[e+o]=c[o];for(s=1,o=8;o<16;o++)s=s+(255&a[o])|0,a[o]=255&s,s>>>=8;n-=64,e+=64}if(n>0)for(y(c,a,i,w),o=0;o>>13|n<<3),r=255&t[4]|(255&t[5])<<8,this.r[2]=7939&(n>>>10|r<<6),i=255&t[6]|(255&t[7])<<8,this.r[3]=8191&(r>>>7|i<<9),s=255&t[8]|(255&t[9])<<8,this.r[4]=255&(i>>>4|s<<12),this.r[5]=s>>>1&8190,o=255&t[10]|(255&t[11])<<8,this.r[6]=8191&(s>>>14|o<<2),a=255&t[12]|(255&t[13])<<8,this.r[7]=8065&(o>>>11|a<<5),c=255&t[14]|(255&t[15])<<8,this.r[8]=8191&(a>>>8|c<<8),this.r[9]=c>>>5&127,this.pad[0]=255&t[16]|(255&t[17])<<8,this.pad[1]=255&t[18]|(255&t[19])<<8,this.pad[2]=255&t[20]|(255&t[21])<<8,this.pad[3]=255&t[22]|(255&t[23])<<8,this.pad[4]=255&t[24]|(255&t[25])<<8,this.pad[5]=255&t[26]|(255&t[27])<<8,this.pad[6]=255&t[28]|(255&t[29])<<8,this.pad[7]=255&t[30]|(255&t[31])<<8};function E(t,e,n,r,i,s){var o=new T(s);return o.update(n,r,i),o.finish(t,e),0}function P(t,e,n,r,i,s){var o=new Uint8Array(16);return E(o,0,n,r,i,s),v(t,e,o,0)}function x(t,e,n,r,i){var s;if(n<32)return-1;for(C(t,0,e,0,n,r,i),E(t,16,t,32,n-32,t),s=0;s<16;s++)t[s]=0;return 0}function A(t,e,n,r,i){var s,o=new Uint8Array(32);if(n<32)return-1;if(k(o,0,32,r,i),0!==P(e,16,e,32,n-32,o))return-1;for(C(t,0,e,0,n,r,i),s=0;s<32;s++)t[s]=0;return 0}function O(t,e){var n;for(n=0;n<16;n++)t[n]=0|e[n]}function L(t){var e,n,r=1;for(e=0;e<16;e++)n=t[e]+r+65535,r=Math.floor(n/65536),t[e]=n-65536*r;t[0]+=r-1+37*(r-1)}function R(t,e,n){for(var r,i=~(n-1),s=0;s<16;s++)r=i&(t[s]^e[s]),t[s]^=r,e[s]^=r}function U(t,n){var r,i,s,o=e(),a=e();for(r=0;r<16;r++)a[r]=n[r];for(L(a),L(a),L(a),i=0;i<2;i++){for(o[0]=a[0]-65517,r=1;r<15;r++)o[r]=a[r]-65535-(o[r-1]>>16&1),o[r-1]&=65535;o[15]=a[15]-32767-(o[14]>>16&1),s=o[15]>>16&1,o[14]&=65535,R(a,o,1-s)}for(r=0;r<16;r++)t[2*r]=255&a[r],t[2*r+1]=a[r]>>8}function I(t,e){var n=new Uint8Array(32),r=new Uint8Array(32);return U(n,t),U(r,e),b(n,0,r,0)}function M(t){var e=new Uint8Array(32);return U(e,t),1&e[0]}function D(t,e){var n;for(n=0;n<16;n++)t[n]=e[2*n]+(e[2*n+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+=r*F,P+=r*X,x+=r*J,A+=r*Y,O+=r*K,L+=r*$,R+=r*W,U+=r*G,I+=r*V,w+=(r=e[15])*D,o+=38*(S+=r*j),a+=38*(k+=r*B),c+=38*(C+=r*z),h+=38*(T+=r*H),u+=38*(E+=r*q),l+=38*(P+=r*F),d+=38*(x+=r*X),p+=38*(A+=r*J),f+=38*(O+=r*Y),g+=38*(L+=r*K),v+=38*(R+=r*$),b+=38*(U+=r*W),y+=38*(I+=r*G),m+=38*(M+=r*V),s=(r=(s+=38*(_+=r*N))+(i=1)+65535)-65536*(i=Math.floor(r/65536)),o=(r=o+i+65535)-65536*(i=Math.floor(r/65536)),a=(r=a+i+65535)-65536*(i=Math.floor(r/65536)),c=(r=c+i+65535)-65536*(i=Math.floor(r/65536)),h=(r=h+i+65535)-65536*(i=Math.floor(r/65536)),u=(r=u+i+65535)-65536*(i=Math.floor(r/65536)),l=(r=l+i+65535)-65536*(i=Math.floor(r/65536)),d=(r=d+i+65535)-65536*(i=Math.floor(r/65536)),p=(r=p+i+65535)-65536*(i=Math.floor(r/65536)),f=(r=f+i+65535)-65536*(i=Math.floor(r/65536)),g=(r=g+i+65535)-65536*(i=Math.floor(r/65536)),v=(r=v+i+65535)-65536*(i=Math.floor(r/65536)),b=(r=b+i+65535)-65536*(i=Math.floor(r/65536)),y=(r=y+i+65535)-65536*(i=Math.floor(r/65536)),m=(r=m+i+65535)-65536*(i=Math.floor(r/65536)),w=(r=w+i+65535)-65536*(i=Math.floor(r/65536)),s=(r=(s+=i-1+37*(i-1))+(i=1)+65535)-65536*(i=Math.floor(r/65536)),o=(r=o+i+65535)-65536*(i=Math.floor(r/65536)),a=(r=a+i+65535)-65536*(i=Math.floor(r/65536)),c=(r=c+i+65535)-65536*(i=Math.floor(r/65536)),h=(r=h+i+65535)-65536*(i=Math.floor(r/65536)),u=(r=u+i+65535)-65536*(i=Math.floor(r/65536)),l=(r=l+i+65535)-65536*(i=Math.floor(r/65536)),d=(r=d+i+65535)-65536*(i=Math.floor(r/65536)),p=(r=p+i+65535)-65536*(i=Math.floor(r/65536)),f=(r=f+i+65535)-65536*(i=Math.floor(r/65536)),g=(r=g+i+65535)-65536*(i=Math.floor(r/65536)),v=(r=v+i+65535)-65536*(i=Math.floor(r/65536)),b=(r=b+i+65535)-65536*(i=Math.floor(r/65536)),y=(r=y+i+65535)-65536*(i=Math.floor(r/65536)),m=(r=m+i+65535)-65536*(i=Math.floor(r/65536)),w=(r=w+i+65535)-65536*(i=Math.floor(r/65536)),s+=i-1+37*(i-1),t[0]=s,t[1]=o,t[2]=a,t[3]=c,t[4]=h,t[5]=u,t[6]=l,t[7]=d,t[8]=p,t[9]=f,t[10]=g,t[11]=v,t[12]=b,t[13]=y,t[14]=m,t[15]=w}function z(t,e){B(t,e,e)}function H(t,n){var r,i=e();for(r=0;r<16;r++)i[r]=n[r];for(r=253;r>=0;r--)z(i,i),2!==r&&4!==r&&B(i,i,n);for(r=0;r<16;r++)t[r]=i[r]}function q(t,n){var r,i=e();for(r=0;r<16;r++)i[r]=n[r];for(r=250;r>=0;r--)z(i,i),1!==r&&B(i,i,n);for(r=0;r<16;r++)t[r]=i[r]}function F(t,n,r){var i,s,o=new Uint8Array(32),a=new Float64Array(80),h=e(),u=e(),l=e(),d=e(),p=e(),f=e();for(s=0;s<31;s++)o[s]=n[s];for(o[31]=127&n[31]|64,o[0]&=248,D(a,r),s=0;s<16;s++)u[s]=a[s],d[s]=h[s]=l[s]=0;for(h[0]=d[0]=1,s=254;s>=0;--s)R(h,u,i=o[s>>>3]>>>(7&s)&1),R(l,d,i),N(p,h,l),j(h,h,l),N(l,u,d),j(u,u,d),z(d,p),z(f,h),B(h,l,h),B(l,u,p),N(p,h,l),j(h,h,l),z(u,h),j(l,d,f),B(h,l,c),N(h,h,d),B(l,l,h),B(h,d,f),B(d,u,a),z(u,p),R(h,u,i),R(l,d,i);for(s=0;s<16;s++)a[s+16]=h[s],a[s+32]=l[s],a[s+48]=u[s],a[s+64]=d[s];var g=a.subarray(32),v=a.subarray(16);return H(g,g),B(v,v,g),U(t,v),0}function X(t,e){return F(t,e,s)}function J(t,e){return r(e,32),X(t,e)}function Y(t,e,n){var r=new Uint8Array(32);return F(r,n,e),m(t,i,r,w)}T.prototype.blocks=function(t,e,n){for(var r,i,s,o,a,c,h,u,l,d,p,f,g,v,b,y,m,w,_,S=this.fin?0:2048,k=this.h[0],C=this.h[1],T=this.h[2],E=this.h[3],P=this.h[4],x=this.h[5],A=this.h[6],O=this.h[7],L=this.h[8],R=this.h[9],U=this.r[0],I=this.r[1],M=this.r[2],D=this.r[3],N=this.r[4],j=this.r[5],B=this.r[6],z=this.r[7],H=this.r[8],q=this.r[9];n>=16;)d=l=0,d+=(k+=8191&(r=255&t[e+0]|(255&t[e+1])<<8))*U,d+=(C+=8191&(r>>>13|(i=255&t[e+2]|(255&t[e+3])<<8)<<3))*(5*q),d+=(T+=8191&(i>>>10|(s=255&t[e+4]|(255&t[e+5])<<8)<<6))*(5*H),d+=(E+=8191&(s>>>7|(o=255&t[e+6]|(255&t[e+7])<<8)<<9))*(5*z),l=(d+=(P+=8191&(o>>>4|(a=255&t[e+8]|(255&t[e+9])<<8)<<12))*(5*B))>>>13,d&=8191,d+=(x+=a>>>1&8191)*(5*j),d+=(A+=8191&(a>>>14|(c=255&t[e+10]|(255&t[e+11])<<8)<<2))*(5*N),d+=(O+=8191&(c>>>11|(h=255&t[e+12]|(255&t[e+13])<<8)<<5))*(5*D),d+=(L+=8191&(h>>>8|(u=255&t[e+14]|(255&t[e+15])<<8)<<8))*(5*M),p=l+=(d+=(R+=u>>>5|S)*(5*I))>>>13,p+=k*I,p+=C*U,p+=T*(5*q),p+=E*(5*H),l=(p+=P*(5*z))>>>13,p&=8191,p+=x*(5*B),p+=A*(5*j),p+=O*(5*N),p+=L*(5*D),l+=(p+=R*(5*M))>>>13,p&=8191,f=l,f+=k*M,f+=C*I,f+=T*U,f+=E*(5*q),l=(f+=P*(5*H))>>>13,f&=8191,f+=x*(5*z),f+=A*(5*B),f+=O*(5*j),f+=L*(5*N),g=l+=(f+=R*(5*D))>>>13,g+=k*D,g+=C*M,g+=T*I,g+=E*U,l=(g+=P*(5*q))>>>13,g&=8191,g+=x*(5*H),g+=A*(5*z),g+=O*(5*B),g+=L*(5*j),v=l+=(g+=R*(5*N))>>>13,v+=k*N,v+=C*D,v+=T*M,v+=E*I,l=(v+=P*U)>>>13,v&=8191,v+=x*(5*q),v+=A*(5*H),v+=O*(5*z),v+=L*(5*B),b=l+=(v+=R*(5*j))>>>13,b+=k*j,b+=C*N,b+=T*D,b+=E*M,l=(b+=P*I)>>>13,b&=8191,b+=x*U,b+=A*(5*q),b+=O*(5*H),b+=L*(5*z),y=l+=(b+=R*(5*B))>>>13,y+=k*B,y+=C*j,y+=T*N,y+=E*D,l=(y+=P*M)>>>13,y&=8191,y+=x*I,y+=A*U,y+=O*(5*q),y+=L*(5*H),m=l+=(y+=R*(5*z))>>>13,m+=k*z,m+=C*B,m+=T*j,m+=E*N,l=(m+=P*D)>>>13,m&=8191,m+=x*M,m+=A*I,m+=O*U,m+=L*(5*q),w=l+=(m+=R*(5*H))>>>13,w+=k*H,w+=C*z,w+=T*B,w+=E*j,l=(w+=P*N)>>>13,w&=8191,w+=x*D,w+=A*M,w+=O*I,w+=L*U,_=l+=(w+=R*(5*q))>>>13,_+=k*q,_+=C*H,_+=T*z,_+=E*B,l=(_+=P*j)>>>13,_&=8191,_+=x*N,_+=A*D,_+=O*M,_+=L*I,k=d=8191&(l=(l=((l+=(_+=R*U)>>>13)<<2)+l|0)+(d&=8191)|0),C=p+=l>>>=13,T=f&=8191,E=g&=8191,P=v&=8191,x=b&=8191,A=y&=8191,O=m&=8191,L=w&=8191,R=_&=8191,e+=16,n-=16;this.h[0]=k,this.h[1]=C,this.h[2]=T,this.h[3]=E,this.h[4]=P,this.h[5]=x,this.h[6]=A,this.h[7]=O,this.h[8]=L,this.h[9]=R},T.prototype.finish=function(t,e){var n,r,i,s,o=new Uint16Array(10);if(this.leftover){for(s=this.leftover,this.buffer[s++]=1;s<16;s++)this.buffer[s]=0;this.fin=1,this.blocks(this.buffer,0,16)}for(n=this.h[1]>>>13,this.h[1]&=8191,s=2;s<10;s++)this.h[s]+=n,n=this.h[s]>>>13,this.h[s]&=8191;for(this.h[0]+=5*n,n=this.h[0]>>>13,this.h[0]&=8191,this.h[1]+=n,n=this.h[1]>>>13,this.h[1]&=8191,this.h[2]+=n,o[0]=this.h[0]+5,n=o[0]>>>13,o[0]&=8191,s=1;s<10;s++)o[s]=this.h[s]+n,n=o[s]>>>13,o[s]&=8191;for(o[9]-=8192,r=(1^n)-1,s=0;s<10;s++)o[s]&=r;for(r=~r,s=0;s<10;s++)this.h[s]=this.h[s]&r|o[s];for(this.h[0]=65535&(this.h[0]|this.h[1]<<13),this.h[1]=65535&(this.h[1]>>>3|this.h[2]<<10),this.h[2]=65535&(this.h[2]>>>6|this.h[3]<<7),this.h[3]=65535&(this.h[3]>>>9|this.h[4]<<4),this.h[4]=65535&(this.h[4]>>>12|this.h[5]<<1|this.h[6]<<14),this.h[5]=65535&(this.h[6]>>>2|this.h[7]<<11),this.h[6]=65535&(this.h[7]>>>5|this.h[8]<<8),this.h[7]=65535&(this.h[8]>>>8|this.h[9]<<5),i=this.h[0]+this.pad[0],this.h[0]=65535&i,s=1;s<8;s++)i=(this.h[s]+this.pad[s]|0)+(i>>>16)|0,this.h[s]=65535&i;t[e+0]=this.h[0]>>>0&255,t[e+1]=this.h[0]>>>8&255,t[e+2]=this.h[1]>>>0&255,t[e+3]=this.h[1]>>>8&255,t[e+4]=this.h[2]>>>0&255,t[e+5]=this.h[2]>>>8&255,t[e+6]=this.h[3]>>>0&255,t[e+7]=this.h[3]>>>8&255,t[e+8]=this.h[4]>>>0&255,t[e+9]=this.h[4]>>>8&255,t[e+10]=this.h[5]>>>0&255,t[e+11]=this.h[5]>>>8&255,t[e+12]=this.h[6]>>>0&255,t[e+13]=this.h[6]>>>8&255,t[e+14]=this.h[7]>>>0&255,t[e+15]=this.h[7]>>>8&255},T.prototype.update=function(t,e,n){var r,i;if(this.leftover){for((i=16-this.leftover)>n&&(i=n),r=0;r=16&&(i=n-n%16,this.blocks(t,e,i),e+=i,n-=i),n){for(r=0;r=128;){for(S=0;S<16;S++)k=8*S+$,O[S]=n[k+0]<<24|n[k+1]<<16|n[k+2]<<8|n[k+3],L[S]=n[k+4]<<24|n[k+5]<<16|n[k+6]<<8|n[k+7];for(S=0;S<80;S++)if(i=R,s=U,o=I,a=M,c=D,h=N,u=j,B,d=z,p=H,f=q,g=F,v=X,b=J,y=Y,K,E=65535&(T=K),P=T>>>16,x=65535&(C=B),A=C>>>16,E+=65535&(T=(X>>>14|D<<18)^(X>>>18|D<<14)^(D>>>9|X<<23)),P+=T>>>16,x+=65535&(C=(D>>>14|X<<18)^(D>>>18|X<<14)^(X>>>9|D<<23)),A+=C>>>16,E+=65535&(T=X&J^~X&Y),P+=T>>>16,x+=65535&(C=D&N^~D&j),A+=C>>>16,E+=65535&(T=W[2*S+1]),P+=T>>>16,x+=65535&(C=W[2*S]),A+=C>>>16,C=O[S%16],P+=(T=L[S%16])>>>16,x+=65535&C,A+=C>>>16,x+=(P+=(E+=65535&T)>>>16)>>>16,E=65535&(T=_=65535&E|P<<16),P=T>>>16,x=65535&(C=w=65535&x|(A+=x>>>16)<<16),A=C>>>16,E+=65535&(T=(z>>>28|R<<4)^(R>>>2|z<<30)^(R>>>7|z<<25)),P+=T>>>16,x+=65535&(C=(R>>>28|z<<4)^(z>>>2|R<<30)^(z>>>7|R<<25)),A+=C>>>16,P+=(T=z&H^z&q^H&q)>>>16,x+=65535&(C=R&U^R&I^U&I),A+=C>>>16,l=65535&(x+=(P+=(E+=65535&T)>>>16)>>>16)|(A+=x>>>16)<<16,m=65535&E|P<<16,E=65535&(T=g),P=T>>>16,x=65535&(C=a),A=C>>>16,P+=(T=_)>>>16,x+=65535&(C=w),A+=C>>>16,U=i,I=s,M=o,D=a=65535&(x+=(P+=(E+=65535&T)>>>16)>>>16)|(A+=x>>>16)<<16,N=c,j=h,B=u,R=l,H=d,q=p,F=f,X=g=65535&E|P<<16,J=v,Y=b,K=y,z=m,S%16==15)for(k=0;k<16;k++)C=O[k],E=65535&(T=L[k]),P=T>>>16,x=65535&C,A=C>>>16,C=O[(k+9)%16],E+=65535&(T=L[(k+9)%16]),P+=T>>>16,x+=65535&C,A+=C>>>16,w=O[(k+1)%16],E+=65535&(T=((_=L[(k+1)%16])>>>1|w<<31)^(_>>>8|w<<24)^(_>>>7|w<<25)),P+=T>>>16,x+=65535&(C=(w>>>1|_<<31)^(w>>>8|_<<24)^w>>>7),A+=C>>>16,w=O[(k+14)%16],P+=(T=((_=L[(k+14)%16])>>>19|w<<13)^(w>>>29|_<<3)^(_>>>6|w<<26))>>>16,x+=65535&(C=(w>>>19|_<<13)^(_>>>29|w<<3)^w>>>6),A+=C>>>16,A+=(x+=(P+=(E+=65535&T)>>>16)>>>16)>>>16,O[k]=65535&x|A<<16,L[k]=65535&E|P<<16;E=65535&(T=z),P=T>>>16,x=65535&(C=R),A=C>>>16,C=t[0],P+=(T=e[0])>>>16,x+=65535&C,A+=C>>>16,A+=(x+=(P+=(E+=65535&T)>>>16)>>>16)>>>16,t[0]=R=65535&x|A<<16,e[0]=z=65535&E|P<<16,E=65535&(T=H),P=T>>>16,x=65535&(C=U),A=C>>>16,C=t[1],P+=(T=e[1])>>>16,x+=65535&C,A+=C>>>16,A+=(x+=(P+=(E+=65535&T)>>>16)>>>16)>>>16,t[1]=U=65535&x|A<<16,e[1]=H=65535&E|P<<16,E=65535&(T=q),P=T>>>16,x=65535&(C=I),A=C>>>16,C=t[2],P+=(T=e[2])>>>16,x+=65535&C,A+=C>>>16,A+=(x+=(P+=(E+=65535&T)>>>16)>>>16)>>>16,t[2]=I=65535&x|A<<16,e[2]=q=65535&E|P<<16,E=65535&(T=F),P=T>>>16,x=65535&(C=M),A=C>>>16,C=t[3],P+=(T=e[3])>>>16,x+=65535&C,A+=C>>>16,A+=(x+=(P+=(E+=65535&T)>>>16)>>>16)>>>16,t[3]=M=65535&x|A<<16,e[3]=F=65535&E|P<<16,E=65535&(T=X),P=T>>>16,x=65535&(C=D),A=C>>>16,C=t[4],P+=(T=e[4])>>>16,x+=65535&C,A+=C>>>16,A+=(x+=(P+=(E+=65535&T)>>>16)>>>16)>>>16,t[4]=D=65535&x|A<<16,e[4]=X=65535&E|P<<16,E=65535&(T=J),P=T>>>16,x=65535&(C=N),A=C>>>16,C=t[5],P+=(T=e[5])>>>16,x+=65535&C,A+=C>>>16,A+=(x+=(P+=(E+=65535&T)>>>16)>>>16)>>>16,t[5]=N=65535&x|A<<16,e[5]=J=65535&E|P<<16,E=65535&(T=Y),P=T>>>16,x=65535&(C=j),A=C>>>16,C=t[6],P+=(T=e[6])>>>16,x+=65535&C,A+=C>>>16,A+=(x+=(P+=(E+=65535&T)>>>16)>>>16)>>>16,t[6]=j=65535&x|A<<16,e[6]=Y=65535&E|P<<16,E=65535&(T=K),P=T>>>16,x=65535&(C=B),A=C>>>16,C=t[7],P+=(T=e[7])>>>16,x+=65535&C,A+=C>>>16,A+=(x+=(P+=(E+=65535&T)>>>16)>>>16)>>>16,t[7]=B=65535&x|A<<16,e[7]=K=65535&E|P<<16,$+=128,r-=128}return r}function V(t,e,n){var r,i=new Int32Array(8),s=new Int32Array(8),o=new Uint8Array(256),a=n;for(i[0]=1779033703,i[1]=3144134277,i[2]=1013904242,i[3]=2773480762,i[4]=1359893119,i[5]=2600822924,i[6]=528734635,i[7]=1541459225,s[0]=4089235720,s[1]=2227873595,s[2]=4271175723,s[3]=1595750129,s[4]=2917565137,s[5]=725511199,s[6]=4215389547,s[7]=327033209,G(i,s,e,n),n%=128,r=0;r=0;--i)Q(t,e,r=n[i/8|0]>>(7&i)&1),Z(e,t),Z(t,t),Q(t,e,r)}function nt(t,n){var r=[e(),e(),e(),e()];O(r[0],l),O(r[1],d),O(r[2],a),B(r[3],l,d),et(t,r,n)}function rt(t,n,i){var s,o=new Uint8Array(64),a=[e(),e(),e(),e()];for(i||r(n,32),V(o,n,32),o[0]&=248,o[31]&=127,o[31]|=64,nt(a,o),tt(t,a),s=0;s<32;s++)n[s+32]=t[s];return 0}var it=new Float64Array([237,211,245,92,26,99,18,88,214,156,247,162,222,249,222,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16]);function st(t,e){var n,r,i,s;for(r=63;r>=32;--r){for(n=0,i=r-32,s=r-12;i>4)*it[i],n=e[i]>>8,e[i]&=255;for(i=0;i<32;i++)e[i]-=n*it[i];for(r=0;r<32;r++)e[r+1]+=e[r]>>8,t[r]=255&e[r]}function ot(t){var e,n=new Float64Array(64);for(e=0;e<64;e++)n[e]=t[e];for(e=0;e<64;e++)t[e]=0;st(t,n)}function at(t,n,r,i){var s,o,a=new Uint8Array(64),c=new Uint8Array(64),h=new Uint8Array(64),u=new Float64Array(64),l=[e(),e(),e(),e()];V(a,i,32),a[0]&=248,a[31]&=127,a[31]|=64;var d=r+64;for(s=0;s>7&&j(t[0],o,t[0]),B(t[3],t[0],t[1]),0)}(d,i))return-1;for(s=0;s=0},t.sign.keyPair=function(){var t=new Uint8Array(32),e=new Uint8Array(64);return rt(t,e),{publicKey:t,secretKey:e}},t.sign.keyPair.fromSecretKey=function(t){if(ut(t),64!==t.length)throw new Error("bad secret key size");for(var e=new Uint8Array(32),n=0;n0)r.loading[t].push(n);else{r.loading[t]=[n];var i=ue.createScriptRequest(r.getPath(t,e)),s=r.receivers.create((function(e){if(r.receivers.remove(s),r.loading[t]){var n=r.loading[t];delete r.loading[t];for(var o=function(t){t||i.cleanup()},a=0;a>>6)+_(128|63&e):_(224|e>>>12&15)+_(128|e>>>6&63)+_(128|63&e)},P=function(t){return t.replace(/[^\x00-\x7F]/g,E)},x=function(t){var e=[0,2,1][t.length%3],n=t.charCodeAt(0)<<16|(t.length>1?t.charCodeAt(1):0)<<8|(t.length>2?t.charCodeAt(2):0);return[S.charAt(n>>>18),S.charAt(n>>>12&63),e>=2?"=":S.charAt(n>>>6&63),e>=1?"=":S.charAt(63&n)].join("")},A=window.btoa||function(t){return t.replace(/[\s\S]{1,3}/g,x)};var O=class{constructor(t,e,n,r){this.clear=e,this.timer=t(()=>{this.timer&&(this.timer=r(this.timer))},n)}isRunning(){return null!==this.timer}ensureAborted(){this.timer&&(this.clear(this.timer),this.timer=null)}};function L(t){window.clearTimeout(t)}function R(t){window.clearInterval(t)}class U extends O{constructor(t,e){super(setTimeout,L,t,(function(t){return e(),null}))}}class I extends O{constructor(t,e){super(setInterval,R,t,(function(t){return e(),t}))}}var M={now:()=>Date.now?Date.now():(new Date).valueOf(),defer:t=>new U(0,t),method(t,...e){var n=Array.prototype.slice.call(arguments,1);return function(e){return e[t].apply(e,n.concat(arguments))}}};function D(t,...e){for(var n=0;n{window.console&&window.console.log&&window.console.log(t)}}debug(...t){this.log(this.globalLog,t)}warn(...t){this.log(this.globalLogWarn,t)}error(...t){this.log(this.globalLogError,t)}globalLogWarn(t){window.console&&window.console.warn?window.console.warn(t):this.globalLog(t)}globalLogError(t){window.console&&window.console.error?window.console.error(t):this.globalLogWarn(t)}log(t,...e){var n=N.apply(this,arguments);if(Re.log)Re.log(n);else if(Re.logToConsole){t.bind(this)(n)}}},G=function(t,e,n,r,i){void 0===n.headers&&null==n.headersProvider||W.warn(`To send headers with the ${r.toString()} request, you must use AJAX, rather than JSONP.`);var s=t.nextAuthCallbackID.toString();t.nextAuthCallbackID++;var o=t.getDocument(),a=o.createElement("script");t.auth_callbacks[s]=function(t){i(null,t)};var c="Pusher.auth_callbacks['"+s+"']";a.src=n.endpoint+"?callback="+encodeURIComponent(c)+"&"+e;var h=o.getElementsByTagName("head")[0]||o.documentElement;h.insertBefore(a,h.firstChild)};class V{constructor(t){this.src=t}send(t){var e=this,n="Error loading "+e.src;e.script=document.createElement("script"),e.script.id=t.id,e.script.src=e.src,e.script.type="text/javascript",e.script.charset="UTF-8",e.script.addEventListener?(e.script.onerror=function(){t.callback(n)},e.script.onload=function(){t.callback(null)}):e.script.onreadystatechange=function(){"loaded"!==e.script.readyState&&"complete"!==e.script.readyState||t.callback(null)},void 0===e.script.async&&document.attachEvent&&/opera/i.test(navigator.userAgent)?(e.errorScript=document.createElement("script"),e.errorScript.id=t.id+"_error",e.errorScript.text=t.name+"('"+n+"');",e.script.async=e.errorScript.async=!1):e.script.async=!0;var r=document.getElementsByTagName("head")[0];r.insertBefore(e.script,r.firstChild),e.errorScript&&r.insertBefore(e.errorScript,e.script.nextSibling)}cleanup(){this.script&&(this.script.onload=this.script.onerror=null,this.script.onreadystatechange=null),this.script&&this.script.parentNode&&this.script.parentNode.removeChild(this.script),this.errorScript&&this.errorScript.parentNode&&this.errorScript.parentNode.removeChild(this.errorScript),this.script=null,this.errorScript=null}}class Z{constructor(t,e){this.url=t,this.data=e}send(t){if(!this.request){var e=K(this.data),n=this.url+"/"+t.number+"?"+e;this.request=ue.createScriptRequest(n),this.request.send(t)}}cleanup(){this.request&&this.request.cleanup()}}var Q={name:"jsonp",getAgent:function(t,e){return function(n,r){var s="http"+(e?"s":"")+"://"+(t.host||t.options.host)+t.options.path,o=ue.createJSONPRequest(s,n),a=ue.ScriptReceivers.create((function(e,n){i.remove(a),o.cleanup(),n&&n.host&&(t.host=n.host),r&&r(e,n)}));o.send(a)}}};function tt(t,e,n){return t+(e.useTLS?"s":"")+"://"+(e.useTLS?e.hostTLS:e.hostNonTLS)+n}function et(t,e){return"/app/"+t+("?protocol="+s.PROTOCOL+"&client=js&version="+s.VERSION+(e?"&"+e:""))}var nt={getInitial:function(t,e){return tt("ws",e,(e.httpPath||"")+et(t,"flash=false"))}},rt={getInitial:function(t,e){return tt("http",e,(e.httpPath||"/pusher")+et(t))}},it={getInitial:function(t,e){return tt("http",e,e.httpPath||"/pusher")},getPath:function(t,e){return et(t)}};class st{constructor(){this._callbacks={}}get(t){return this._callbacks[ot(t)]}add(t,e,n){var r=ot(t);this._callbacks[r]=this._callbacks[r]||[],this._callbacks[r].push({fn:e,context:n})}remove(t,e,n){if(t||e||n){var r=t?[ot(t)]:z(this._callbacks);e||n?this.removeCallback(r,e,n):this.removeAllCallbacks(r)}else this._callbacks={}}removeCallback(t,e,n){H(t,(function(t){this._callbacks[t]=F(this._callbacks[t]||[],(function(t){return e&&e!==t.fn||n&&n!==t.context})),0===this._callbacks[t].length&&delete this._callbacks[t]}),this)}removeAllCallbacks(t){H(t,(function(t){delete this._callbacks[t]}),this)}}function ot(t){return"_"+t}class at{constructor(t){this.callbacks=new st,this.global_callbacks=[],this.failThrough=t}bind(t,e,n){return this.callbacks.add(t,e,n),this}bind_global(t){return this.global_callbacks.push(t),this}unbind(t,e,n){return this.callbacks.remove(t,e,n),this}unbind_global(t){return t?(this.global_callbacks=F(this.global_callbacks||[],e=>e!==t),this):(this.global_callbacks=[],this)}unbind_all(){return this.unbind(),this.unbind_global(),this}emit(t,e,n){for(var r=0;r0)for(r=0;r{this.onError(t),this.changeState("closed")}),!1}return this.bindListeners(),W.debug("Connecting",{transport:this.name,url:t}),this.changeState("connecting"),!0}close(){return!!this.socket&&(this.socket.close(),!0)}send(t){return"open"===this.state&&(M.defer(()=>{this.socket&&this.socket.send(t)}),!0)}ping(){"open"===this.state&&this.supportsPing()&&this.socket.ping()}onOpen(){this.hooks.beforeOpen&&this.hooks.beforeOpen(this.socket,this.hooks.urls.getPath(this.key,this.options)),this.changeState("open"),this.socket.onopen=void 0}onError(t){this.emit("error",{type:"WebSocketError",error:t}),this.timeline.error(this.buildTimelineMessage({error:t.toString()}))}onClose(t){t?this.changeState("closed",{code:t.code,reason:t.reason,wasClean:t.wasClean}):this.changeState("closed"),this.unbindListeners(),this.socket=void 0}onMessage(t){this.emit("message",t)}onActivity(){this.emit("activity")}bindListeners(){this.socket.onopen=()=>{this.onOpen()},this.socket.onerror=t=>{this.onError(t)},this.socket.onclose=t=>{this.onClose(t)},this.socket.onmessage=t=>{this.onMessage(t)},this.supportsPing()&&(this.socket.onactivity=()=>{this.onActivity()})}unbindListeners(){this.socket&&(this.socket.onopen=void 0,this.socket.onerror=void 0,this.socket.onclose=void 0,this.socket.onmessage=void 0,this.supportsPing()&&(this.socket.onactivity=void 0))}changeState(t,e){this.state=t,this.timeline.info(this.buildTimelineMessage({state:t,params:e})),this.emit(t,e)}buildTimelineMessage(t){return D({cid:this.id},t)}}class ht{constructor(t){this.hooks=t}isSupported(t){return this.hooks.isSupported(t)}createConnection(t,e,n,r){return new ct(this.hooks,t,e,n,r)}}var ut=new ht({urls:nt,handlesActivityChecks:!1,supportsPing:!1,isInitialized:function(){return Boolean(ue.getWebSocketAPI())},isSupported:function(){return Boolean(ue.getWebSocketAPI())},getSocket:function(t){return ue.createWebSocket(t)}}),lt={urls:rt,handlesActivityChecks:!1,supportsPing:!0,isInitialized:function(){return!0}},dt=D({getSocket:function(t){return ue.HTTPFactory.createStreamingSocket(t)}},lt),pt=D({getSocket:function(t){return ue.HTTPFactory.createPollingSocket(t)}},lt),ft={isSupported:function(){return ue.isXHRSupported()}},gt={ws:ut,xhr_streaming:new ht(D({},dt,ft)),xhr_polling:new ht(D({},pt,ft))},vt=new ht({file:"sockjs",urls:it,handlesActivityChecks:!0,supportsPing:!1,isSupported:function(){return!0},isInitialized:function(){return void 0!==window.SockJS},getSocket:function(t,e){return new window.SockJS(t,null,{js_path:a.getPath("sockjs",{useTLS:e.useTLS}),ignore_null_origin:e.ignoreNullOrigin})},beforeOpen:function(t,e){t.send(JSON.stringify({path:e}))}}),bt={isSupported:function(t){return ue.isXDRSupported(t.useTLS)}},yt=new ht(D({},dt,bt)),mt=new ht(D({},pt,bt));gt.xdr_streaming=yt,gt.xdr_polling=mt,gt.sockjs=vt;var wt=gt;var _t=new class extends at{constructor(){super();var t=this;void 0!==window.addEventListener&&(window.addEventListener("online",(function(){t.emit("online")}),!1),window.addEventListener("offline",(function(){t.emit("offline")}),!1))}isOnline(){return void 0===window.navigator.onLine||window.navigator.onLine}};class St{constructor(t,e,n){this.manager=t,this.transport=e,this.minPingDelay=n.minPingDelay,this.maxPingDelay=n.maxPingDelay,this.pingDelay=void 0}createConnection(t,e,n,r){r=D({},r,{activityTimeout:this.pingDelay});var i=this.transport.createConnection(t,e,n,r),s=null,o=function(){i.unbind("open",o),i.bind("closed",a),s=M.now()},a=t=>{if(i.unbind("closed",a),1002===t.code||1003===t.code)this.manager.reportDeath();else if(!t.wasClean&&s){var e=M.now()-s;e<2*this.maxPingDelay&&(this.manager.reportDeath(),this.pingDelay=Math.max(e/2,this.minPingDelay))}};return i.bind("open",o),i}isSupported(t){return this.manager.isAlive()&&this.transport.isSupported(t)}}const kt={decodeMessage:function(t){try{var e=JSON.parse(t.data),n=e.data;if("string"==typeof n)try{n=JSON.parse(e.data)}catch(t){}var r={event:e.event,channel:e.channel,data:n};return e.user_id&&(r.user_id=e.user_id),r}catch(e){throw{type:"MessageParseError",error:e,data:t.data}}},encodeMessage:function(t){return JSON.stringify(t)},processHandshake:function(t){var e=kt.decodeMessage(t);if("pusher:connection_established"===e.event){if(!e.data.activity_timeout)throw"No activity timeout specified in handshake";return{action:"connected",id:e.data.socket_id,activityTimeout:1e3*e.data.activity_timeout}}if("pusher:error"===e.event)return{action:this.getCloseAction(e.data),error:this.getCloseError(e.data)};throw"Invalid handshake"},getCloseAction:function(t){return t.code<4e3?t.code>=1002&&t.code<=1004?"backoff":null:4e3===t.code?"tls_only":t.code<4100?"refused":t.code<4200?"backoff":t.code<4300?"retry":"refused"},getCloseError:function(t){return 1e3!==t.code&&1001!==t.code?{type:"PusherError",data:{code:t.code,message:t.reason||t.message}}:null}};var Ct=kt;class Tt extends at{constructor(t,e){super(),this.id=t,this.transport=e,this.activityTimeout=e.activityTimeout,this.bindListeners()}handlesActivityChecks(){return this.transport.handlesActivityChecks()}send(t){return this.transport.send(t)}send_event(t,e,n){var r={event:t,data:e};return n&&(r.channel=n),W.debug("Event sent",r),this.send(Ct.encodeMessage(r))}ping(){this.transport.supportsPing()?this.transport.ping():this.send_event("pusher:ping",{})}close(){this.transport.close()}bindListeners(){var t={message:t=>{var e;try{e=Ct.decodeMessage(t)}catch(e){this.emit("error",{type:"MessageParseError",error:e,data:t.data})}if(void 0!==e){switch(W.debug("Event recd",e),e.event){case"pusher:error":this.emit("error",{type:"PusherError",data:e.data});break;case"pusher:ping":this.emit("ping");break;case"pusher:pong":this.emit("pong")}this.emit("message",e)}},activity:()=>{this.emit("activity")},error:t=>{this.emit("error",t)},closed:t=>{e(),t&&t.code&&this.handleCloseEvent(t),this.transport=null,this.emit("closed")}},e=()=>{B(t,(t,e)=>{this.transport.unbind(e,t)})};B(t,(t,e)=>{this.transport.bind(e,t)})}handleCloseEvent(t){var e=Ct.getCloseAction(t),n=Ct.getCloseError(t);n&&this.emit("error",n),e&&this.emit(e,{action:e,error:n})}}class Et{constructor(t,e){this.transport=t,this.callback=e,this.bindListeners()}close(){this.unbindListeners(),this.transport.close()}bindListeners(){this.onMessage=t=>{var e;this.unbindListeners();try{e=Ct.processHandshake(t)}catch(t){return this.finish("error",{error:t}),void this.transport.close()}"connected"===e.action?this.finish("connected",{connection:new Tt(e.id,this.transport),activityTimeout:e.activityTimeout}):(this.finish(e.action,{error:e.error}),this.transport.close())},this.onClosed=t=>{this.unbindListeners();var e=Ct.getCloseAction(t)||"backoff",n=Ct.getCloseError(t);this.finish(e,{error:n})},this.transport.bind("message",this.onMessage),this.transport.bind("closed",this.onClosed)}unbindListeners(){this.transport.unbind("message",this.onMessage),this.transport.unbind("closed",this.onClosed)}finish(t,e){this.callback(D({transport:this.transport,action:t},e))}}class Pt{constructor(t,e){this.timeline=t,this.options=e||{}}send(t,e){this.timeline.isEmpty()||this.timeline.send(ue.TimelineTransport.getAgent(this,t),e)}}class xt extends at{constructor(t,e){super((function(e,n){W.debug("No callbacks on "+t+" for "+e)})),this.name=t,this.pusher=e,this.subscribed=!1,this.subscriptionPending=!1,this.subscriptionCancelled=!1}authorize(t,e){return e(null,{auth:""})}trigger(t,e){if(0!==t.indexOf("client-"))throw new l("Event '"+t+"' does not start with 'client-'");if(!this.subscribed){var n=u("triggeringClientEvents");W.warn("Client event triggered before channel 'subscription_succeeded' event . "+n)}return this.pusher.send_event(t,e,this.name)}disconnect(){this.subscribed=!1,this.subscriptionPending=!1}handleEvent(t){var e=t.event,n=t.data;if("pusher_internal:subscription_succeeded"===e)this.handleSubscriptionSucceededEvent(t);else if("pusher_internal:subscription_count"===e)this.handleSubscriptionCountEvent(t);else if(0!==e.indexOf("pusher_internal:")){this.emit(e,n,{})}}handleSubscriptionSucceededEvent(t){this.subscriptionPending=!1,this.subscribed=!0,this.subscriptionCancelled?this.pusher.unsubscribe(this.name):this.emit("pusher:subscription_succeeded",t.data)}handleSubscriptionCountEvent(t){t.data.subscription_count&&(this.subscriptionCount=t.data.subscription_count),this.emit("pusher:subscription_count",t.data)}subscribe(){this.subscribed||(this.subscriptionPending=!0,this.subscriptionCancelled=!1,this.authorize(this.pusher.connection.socket_id,(t,e)=>{t?(this.subscriptionPending=!1,W.error(t.toString()),this.emit("pusher:subscription_error",Object.assign({},{type:"AuthError",error:t.message},t instanceof m?{status:t.status}:{}))):this.pusher.send_event("pusher:subscribe",{auth:e.auth,channel_data:e.channel_data,channel:this.name})}))}unsubscribe(){this.subscribed=!1,this.pusher.send_event("pusher:unsubscribe",{channel:this.name})}cancelSubscription(){this.subscriptionCancelled=!0}reinstateSubscription(){this.subscriptionCancelled=!1}}class At extends xt{authorize(t,e){return this.pusher.config.channelAuthorizer({channelName:this.name,socketId:t},e)}}class Ot{constructor(){this.reset()}get(t){return Object.prototype.hasOwnProperty.call(this.members,t)?{id:t,info:this.members[t]}:null}each(t){B(this.members,(e,n)=>{t(this.get(n))})}setMyID(t){this.myID=t}onSubscription(t){this.members=t.presence.hash,this.count=t.presence.count,this.me=this.get(this.myID)}addMember(t){return null===this.get(t.user_id)&&this.count++,this.members[t.user_id]=t.user_info,this.get(t.user_id)}removeMember(t){var e=this.get(t.user_id);return e&&(delete this.members[t.user_id],this.count--),e}reset(){this.members={},this.count=0,this.myID=null,this.me=null}}var Lt=function(t,e,n,r){return new(n||(n=Promise))((function(i,s){function o(t){try{c(r.next(t))}catch(t){s(t)}}function a(t){try{c(r.throw(t))}catch(t){s(t)}}function c(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(o,a)}c((r=r.apply(t,e||[])).next())}))};class Rt extends At{constructor(t,e){super(t,e),this.members=new Ot}authorize(t,e){super.authorize(t,(t,n)=>Lt(this,void 0,void 0,(function*(){if(!t)if(null!=(n=n).channel_data){var r=JSON.parse(n.channel_data);this.members.setMyID(r.user_id)}else{if(yield this.pusher.user.signinDonePromise,null==this.pusher.user.user_data){let t=u("authorizationEndpoint");return W.error(`Invalid auth response for channel '${this.name}', expected 'channel_data' field. ${t}, or the user should be signed in.`),void e("Invalid auth response")}this.members.setMyID(this.pusher.user.user_data.id)}e(t,n)})))}handleEvent(t){var e=t.event;if(0===e.indexOf("pusher_internal:"))this.handleInternalEvent(t);else{var n=t.data,r={};t.user_id&&(r.user_id=t.user_id),this.emit(e,n,r)}}handleInternalEvent(t){var e=t.event,n=t.data;switch(e){case"pusher_internal:subscription_succeeded":this.handleSubscriptionSucceededEvent(t);break;case"pusher_internal:subscription_count":this.handleSubscriptionCountEvent(t);break;case"pusher_internal:member_added":var r=this.members.addMember(n);this.emit("pusher:member_added",r);break;case"pusher_internal:member_removed":var i=this.members.removeMember(n);i&&this.emit("pusher:member_removed",i)}}handleSubscriptionSucceededEvent(t){this.subscriptionPending=!1,this.subscribed=!0,this.subscriptionCancelled?this.pusher.unsubscribe(this.name):(this.members.onSubscription(t.data),this.emit("pusher:subscription_succeeded",this.members))}disconnect(){this.members.reset(),super.disconnect()}}var Ut=n(1),It=n(0);class Mt extends At{constructor(t,e,n){super(t,e),this.key=null,this.nacl=n}authorize(t,e){super.authorize(t,(t,n)=>{if(t)return void e(t,n);let r=n.shared_secret;r?(this.key=Object(It.decode)(r),delete n.shared_secret,e(null,n)):e(new Error("No shared_secret key in auth payload for encrypted channel: "+this.name),null)})}trigger(t,e){throw new v("Client events are not currently supported for encrypted channels")}handleEvent(t){var e=t.event,n=t.data;0!==e.indexOf("pusher_internal:")&&0!==e.indexOf("pusher:")?this.handleEncryptedEvent(e,n):super.handleEvent(t)}handleEncryptedEvent(t,e){if(!this.key)return void W.debug("Received encrypted event before key has been retrieved from the authEndpoint");if(!e.ciphertext||!e.nonce)return void W.error("Unexpected format for encrypted event, expected object with `ciphertext` and `nonce` fields, got: "+e);let n=Object(It.decode)(e.ciphertext);if(n.length{e?W.error(`Failed to make a request to the authEndpoint: ${s}. Unable to fetch new key, so dropping encrypted event`):(i=this.nacl.secretbox.open(n,r,this.key),null!==i?this.emit(t,this.getDataToEmit(i)):W.error("Failed to decrypt event with new key. Dropping encrypted event"))});this.emit(t,this.getDataToEmit(i))}getDataToEmit(t){let e=Object(Ut.decode)(t);try{return JSON.parse(e)}catch(t){return e}}}class Dt extends at{constructor(t,e){super(),this.state="initialized",this.connection=null,this.key=t,this.options=e,this.timeline=this.options.timeline,this.usingTLS=this.options.useTLS,this.errorCallbacks=this.buildErrorCallbacks(),this.connectionCallbacks=this.buildConnectionCallbacks(this.errorCallbacks),this.handshakeCallbacks=this.buildHandshakeCallbacks(this.errorCallbacks);var n=ue.getNetwork();n.bind("online",()=>{this.timeline.info({netinfo:"online"}),"connecting"!==this.state&&"unavailable"!==this.state||this.retryIn(0)}),n.bind("offline",()=>{this.timeline.info({netinfo:"offline"}),this.connection&&this.sendActivityCheck()}),this.updateStrategy()}switchCluster(t){this.key=t,this.updateStrategy(),this.retryIn(0)}connect(){this.connection||this.runner||(this.strategy.isSupported()?(this.updateState("connecting"),this.startConnecting(),this.setUnavailableTimer()):this.updateState("failed"))}send(t){return!!this.connection&&this.connection.send(t)}send_event(t,e,n){return!!this.connection&&this.connection.send_event(t,e,n)}disconnect(){this.disconnectInternally(),this.updateState("disconnected")}isUsingTLS(){return this.usingTLS}startConnecting(){var t=(e,n)=>{e?this.runner=this.strategy.connect(0,t):"error"===n.action?(this.emit("error",{type:"HandshakeError",error:n.error}),this.timeline.error({handshakeError:n.error})):(this.abortConnecting(),this.handshakeCallbacks[n.action](n))};this.runner=this.strategy.connect(0,t)}abortConnecting(){this.runner&&(this.runner.abort(),this.runner=null)}disconnectInternally(){(this.abortConnecting(),this.clearRetryTimer(),this.clearUnavailableTimer(),this.connection)&&this.abandonConnection().close()}updateStrategy(){this.strategy=this.options.getStrategy({key:this.key,timeline:this.timeline,useTLS:this.usingTLS})}retryIn(t){this.timeline.info({action:"retry",delay:t}),t>0&&this.emit("connecting_in",Math.round(t/1e3)),this.retryTimer=new U(t||0,()=>{this.disconnectInternally(),this.connect()})}clearRetryTimer(){this.retryTimer&&(this.retryTimer.ensureAborted(),this.retryTimer=null)}setUnavailableTimer(){this.unavailableTimer=new U(this.options.unavailableTimeout,()=>{this.updateState("unavailable")})}clearUnavailableTimer(){this.unavailableTimer&&this.unavailableTimer.ensureAborted()}sendActivityCheck(){this.stopActivityCheck(),this.connection.ping(),this.activityTimer=new U(this.options.pongTimeout,()=>{this.timeline.error({pong_timed_out:this.options.pongTimeout}),this.retryIn(0)})}resetActivityCheck(){this.stopActivityCheck(),this.connection&&!this.connection.handlesActivityChecks()&&(this.activityTimer=new U(this.activityTimeout,()=>{this.sendActivityCheck()}))}stopActivityCheck(){this.activityTimer&&this.activityTimer.ensureAborted()}buildConnectionCallbacks(t){return D({},t,{message:t=>{this.resetActivityCheck(),this.emit("message",t)},ping:()=>{this.send_event("pusher:pong",{})},activity:()=>{this.resetActivityCheck()},error:t=>{this.emit("error",t)},closed:()=>{this.abandonConnection(),this.shouldRetry()&&this.retryIn(1e3)}})}buildHandshakeCallbacks(t){return D({},t,{connected:t=>{this.activityTimeout=Math.min(this.options.activityTimeout,t.activityTimeout,t.connection.activityTimeout||1/0),this.clearUnavailableTimer(),this.setConnection(t.connection),this.socket_id=this.connection.id,this.updateState("connected",{socket_id:this.socket_id})}})}buildErrorCallbacks(){let t=t=>e=>{e.error&&this.emit("error",{type:"WebSocketError",error:e.error}),t(e)};return{tls_only:t(()=>{this.usingTLS=!0,this.updateStrategy(),this.retryIn(0)}),refused:t(()=>{this.disconnect()}),backoff:t(()=>{this.retryIn(1e3)}),retry:t(()=>{this.retryIn(0)})}}setConnection(t){for(var e in this.connection=t,this.connectionCallbacks)this.connection.bind(e,this.connectionCallbacks[e]);this.resetActivityCheck()}abandonConnection(){if(this.connection){for(var t in this.stopActivityCheck(),this.connectionCallbacks)this.connection.unbind(t,this.connectionCallbacks[t]);var e=this.connection;return this.connection=null,e}}updateState(t,e){var n=this.state;if(this.state=t,n!==t){var r=t;"connected"===r&&(r+=" with new socket ID "+e.socket_id),W.debug("State changed",n+" -> "+r),this.timeline.info({state:t,params:e}),this.emit("state_change",{previous:n,current:t}),this.emit(t,e)}}shouldRetry(){return"connecting"===this.state||"connected"===this.state}}class Nt{constructor(){this.channels={}}add(t,e){return this.channels[t]||(this.channels[t]=function(t,e){if(0===t.indexOf("private-encrypted-")){if(e.config.nacl)return jt.createEncryptedChannel(t,e,e.config.nacl);let n="Tried to subscribe to a private-encrypted- channel but no nacl implementation available",r=u("encryptedChannelSupport");throw new v(`${n}. ${r}`)}if(0===t.indexOf("private-"))return jt.createPrivateChannel(t,e);if(0===t.indexOf("presence-"))return jt.createPresenceChannel(t,e);if(0===t.indexOf("#"))throw new d('Cannot create a channel with name "'+t+'".');return jt.createChannel(t,e)}(t,e)),this.channels[t]}all(){return function(t){var e=[];return B(t,(function(t){e.push(t)})),e}(this.channels)}find(t){return this.channels[t]}remove(t){var e=this.channels[t];return delete this.channels[t],e}disconnect(){B(this.channels,(function(t){t.disconnect()}))}}var jt={createChannels:()=>new Nt,createConnectionManager:(t,e)=>new Dt(t,e),createChannel:(t,e)=>new xt(t,e),createPrivateChannel:(t,e)=>new At(t,e),createPresenceChannel:(t,e)=>new Rt(t,e),createEncryptedChannel:(t,e,n)=>new Mt(t,e,n),createTimelineSender:(t,e)=>new Pt(t,e),createHandshake:(t,e)=>new Et(t,e),createAssistantToTheTransportManager:(t,e,n)=>new St(t,e,n)};class Bt{constructor(t){this.options=t||{},this.livesLeft=this.options.lives||1/0}getAssistant(t){return jt.createAssistantToTheTransportManager(this,t,{minPingDelay:this.options.minPingDelay,maxPingDelay:this.options.maxPingDelay})}isAlive(){return this.livesLeft>0}reportDeath(){this.livesLeft-=1}}class zt{constructor(t,e){this.strategies=t,this.loop=Boolean(e.loop),this.failFast=Boolean(e.failFast),this.timeout=e.timeout,this.timeoutLimit=e.timeoutLimit}isSupported(){return J(this.strategies,M.method("isSupported"))}connect(t,e){var n=this.strategies,r=0,i=this.timeout,s=null,o=(a,c)=>{c?e(null,c):(r+=1,this.loop&&(r%=n.length),r0&&(i=new U(n.timeout,(function(){s.abort(),r(!0)}))),s=t.connect(e,(function(t,e){t&&i&&i.isRunning()&&!n.failFast||(i&&i.ensureAborted(),r(t,e))})),{abort:function(){i&&i.ensureAborted(),s.abort()},forceMinPriority:function(t){s.forceMinPriority(t)}}}}class Ht{constructor(t){this.strategies=t}isSupported(){return J(this.strategies,M.method("isSupported"))}connect(t,e){return function(t,e,n){var r=q(t,(function(t,r,i,s){return t.connect(e,n(r,s))}));return{abort:function(){H(r,qt)},forceMinPriority:function(t){H(r,(function(e){e.forceMinPriority(t)}))}}}(this.strategies,t,(function(t,n){return function(r,i){n[t].error=r,r?function(t){return function(t,e){for(var n=0;n=M.now()){var o=this.transports[r.transport];o&&(["ws","wss"].includes(r.transport)||i>3?(this.timeline.info({cached:!0,transport:r.transport,latency:r.latency}),s.push(new zt([o],{timeout:2*r.latency+1e3,failFast:!0}))):i++)}var a=M.now(),c=s.pop().connect(t,(function r(o,h){o?(Jt(n),s.length>0?(a=M.now(),c=s.pop().connect(t,r)):e(o)):(!function(t,e,n,r){var i=ue.getLocalStorage();if(i)try{i[Xt(t)]=$({timestamp:M.now(),transport:e,latency:n,cacheSkipCount:r})}catch(t){}}(n,h.transport.name,M.now()-a,i),e(null,h))}));return{abort:function(){c.abort()},forceMinPriority:function(e){t=e,c&&c.forceMinPriority(e)}}}}function Xt(t){return"pusherTransport"+(t?"TLS":"NonTLS")}function Jt(t){var e=ue.getLocalStorage();if(e)try{delete e[Xt(t)]}catch(t){}}class Yt{constructor(t,{delay:e}){this.strategy=t,this.options={delay:e}}isSupported(){return this.strategy.isSupported()}connect(t,e){var n,r=this.strategy,i=new U(this.options.delay,(function(){n=r.connect(t,e)}));return{abort:function(){i.ensureAborted(),n&&n.abort()},forceMinPriority:function(e){t=e,n&&n.forceMinPriority(e)}}}}class Kt{constructor(t,e,n){this.test=t,this.trueBranch=e,this.falseBranch=n}isSupported(){return(this.test()?this.trueBranch:this.falseBranch).isSupported()}connect(t,e){return(this.test()?this.trueBranch:this.falseBranch).connect(t,e)}}class $t{constructor(t){this.strategy=t}isSupported(){return this.strategy.isSupported()}connect(t,e){var n=this.strategy.connect(t,(function(t,r){r&&n.abort(),e(t,r)}));return n}}function Wt(t){return function(){return t.isSupported()}}var Gt=function(t,e,n){var r={};function i(e,i,s,o,a){var c=n(t,e,i,s,o,a);return r[e]=c,c}var s,o=Object.assign({},e,{hostNonTLS:t.wsHost+":"+t.wsPort,hostTLS:t.wsHost+":"+t.wssPort,httpPath:t.wsPath}),a=Object.assign({},o,{useTLS:!0}),c=Object.assign({},e,{hostNonTLS:t.httpHost+":"+t.httpPort,hostTLS:t.httpHost+":"+t.httpsPort,httpPath:t.httpPath}),h={loop:!0,timeout:15e3,timeoutLimit:6e4},u=new Bt({minPingDelay:1e4,maxPingDelay:t.activityTimeout}),l=new Bt({lives:2,minPingDelay:1e4,maxPingDelay:t.activityTimeout}),d=i("ws","ws",3,o,u),p=i("wss","ws",3,a,u),f=i("sockjs","sockjs",1,c),g=i("xhr_streaming","xhr_streaming",1,c,l),v=i("xdr_streaming","xdr_streaming",1,c,l),b=i("xhr_polling","xhr_polling",1,c),y=i("xdr_polling","xdr_polling",1,c),m=new zt([d],h),w=new zt([p],h),_=new zt([f],h),S=new zt([new Kt(Wt(g),g,v)],h),k=new zt([new Kt(Wt(b),b,y)],h),C=new zt([new Kt(Wt(S),new Ht([S,new Yt(k,{delay:4e3})]),k)],h),T=new Kt(Wt(C),C,_);return s=e.useTLS?new Ht([m,new Yt(T,{delay:2e3})]):new Ht([m,new Yt(w,{delay:2e3}),new Yt(T,{delay:5e3})]),new Ft(new $t(new Kt(Wt(d),s,T)),r,{ttl:18e5,timeline:e.timeline,useTLS:e.useTLS})},Vt={getRequest:function(t){var e=new window.XDomainRequest;return e.ontimeout=function(){t.emit("error",new p),t.close()},e.onerror=function(e){t.emit("error",e),t.close()},e.onprogress=function(){e.responseText&&e.responseText.length>0&&t.onChunk(200,e.responseText)},e.onload=function(){e.responseText&&e.responseText.length>0&&t.onChunk(200,e.responseText),t.emit("finished",200),t.close()},e},abortRequest:function(t){t.ontimeout=t.onerror=t.onprogress=t.onload=null,t.abort()}};class Zt extends at{constructor(t,e,n){super(),this.hooks=t,this.method=e,this.url=n}start(t){this.position=0,this.xhr=this.hooks.getRequest(this),this.unloader=()=>{this.close()},ue.addUnloadListener(this.unloader),this.xhr.open(this.method,this.url,!0),this.xhr.setRequestHeader&&this.xhr.setRequestHeader("Content-Type","application/json"),this.xhr.send(t)}close(){this.unloader&&(ue.removeUnloadListener(this.unloader),this.unloader=null),this.xhr&&(this.hooks.abortRequest(this.xhr),this.xhr=null)}onChunk(t,e){for(;;){var n=this.advanceBuffer(e);if(!n)break;this.emit("chunk",{status:t,data:n})}this.isBufferTooLong(e)&&this.emit("buffer_too_long")}advanceBuffer(t){var e=t.slice(this.position),n=e.indexOf("\n");return-1!==n?(this.position+=n+1,e.slice(0,n)):null}isBufferTooLong(t){return this.position===t.length&&t.length>262144}}var Qt;!function(t){t[t.CONNECTING=0]="CONNECTING",t[t.OPEN=1]="OPEN",t[t.CLOSED=3]="CLOSED"}(Qt||(Qt={}));var te=Qt,ee=1;function ne(t){var e=-1===t.indexOf("?")?"?":"&";return t+e+"t="+ +new Date+"&n="+ee++}function re(t){return ue.randomInt(t)}var ie,se=class{constructor(t,e){this.hooks=t,this.session=re(1e3)+"/"+function(t){for(var e=[],n=0;n{this.onChunk(t)}),this.stream.bind("finished",t=>{this.hooks.onFinished(this,t)}),this.stream.bind("buffer_too_long",()=>{this.reconnect()});try{this.stream.start()}catch(t){M.defer(()=>{this.onError(t),this.onClose(1006,"Could not start streaming",!1)})}}closeStream(){this.stream&&(this.stream.unbind_all(),this.stream.close(),this.stream=null)}},oe={getReceiveURL:function(t,e){return t.base+"/"+e+"/xhr_streaming"+t.queryString},onHeartbeat:function(t){t.sendRaw("[]")},sendHeartbeat:function(t){t.sendRaw("[]")},onFinished:function(t,e){t.onClose(1006,"Connection interrupted ("+e+")",!1)}},ae={getReceiveURL:function(t,e){return t.base+"/"+e+"/xhr"+t.queryString},onHeartbeat:function(){},sendHeartbeat:function(t){t.sendRaw("[]")},onFinished:function(t,e){200===e?t.reconnect():t.onClose(1006,"Connection interrupted ("+e+")",!1)}},ce={getRequest:function(t){var e=new(ue.getXHRAPI());return e.onreadystatechange=e.onprogress=function(){switch(e.readyState){case 3:e.responseText&&e.responseText.length>0&&t.onChunk(e.status,e.responseText);break;case 4:e.responseText&&e.responseText.length>0&&t.onChunk(e.status,e.responseText),t.emit("finished",e.status),t.close()}},e},abortRequest:function(t){t.onreadystatechange=null,t.abort()}},he={createStreamingSocket(t){return this.createSocket(oe,t)},createPollingSocket(t){return this.createSocket(ae,t)},createSocket:(t,e)=>new se(t,e),createXHR(t,e){return this.createRequest(ce,t,e)},createRequest:(t,e,n)=>new Zt(t,e,n),createXDR:function(t,e){return this.createRequest(Vt,t,e)}},ue={nextAuthCallbackID:1,auth_callbacks:{},ScriptReceivers:i,DependenciesReceivers:o,getDefaultStrategy:Gt,Transports:wt,transportConnectionInitializer:function(){var t=this;t.timeline.info(t.buildTimelineMessage({transport:t.name+(t.options.useTLS?"s":"")})),t.hooks.isInitialized()?t.changeState("initialized"):t.hooks.file?(t.changeState("initializing"),a.load(t.hooks.file,{useTLS:t.options.useTLS},(function(e,n){t.hooks.isInitialized()?(t.changeState("initialized"),n(!0)):(e&&t.onError(e),t.onClose(),n(!1))}))):t.onClose()},HTTPFactory:he,TimelineTransport:Q,getXHRAPI:()=>window.XMLHttpRequest,getWebSocketAPI:()=>window.WebSocket||window.MozWebSocket,setup(t){window.Pusher=t;var e=()=>{this.onDocumentBody(t.ready)};window.JSON?e():a.load("json2",{},e)},getDocument:()=>document,getProtocol(){return this.getDocument().location.protocol},getAuthorizers:()=>({ajax:w,jsonp:G}),onDocumentBody(t){document.body?t():setTimeout(()=>{this.onDocumentBody(t)},0)},createJSONPRequest:(t,e)=>new Z(t,e),createScriptRequest:t=>new V(t),getLocalStorage(){try{return window.localStorage}catch(t){return}},createXHR(){return this.getXHRAPI()?this.createXMLHttpRequest():this.createMicrosoftXHR()},createXMLHttpRequest(){return new(this.getXHRAPI())},createMicrosoftXHR:()=>new ActiveXObject("Microsoft.XMLHTTP"),getNetwork:()=>_t,createWebSocket(t){return new(this.getWebSocketAPI())(t)},createSocketRequest(t,e){if(this.isXHRSupported())return this.HTTPFactory.createXHR(t,e);if(this.isXDRSupported(0===e.indexOf("https:")))return this.HTTPFactory.createXDR(t,e);throw"Cross-origin HTTP requests are not supported"},isXHRSupported(){var t=this.getXHRAPI();return Boolean(t)&&void 0!==(new t).withCredentials},isXDRSupported(t){var e=t?"https:":"http:",n=this.getProtocol();return Boolean(window.XDomainRequest)&&n===e},addUnloadListener(t){void 0!==window.addEventListener?window.addEventListener("unload",t,!1):void 0!==window.attachEvent&&window.attachEvent("onunload",t)},removeUnloadListener(t){void 0!==window.addEventListener?window.removeEventListener("unload",t,!1):void 0!==window.detachEvent&&window.detachEvent("onunload",t)},randomInt:t=>Math.floor((window.crypto||window.msCrypto).getRandomValues(new Uint32Array(1))[0]/Math.pow(2,32)*t)};!function(t){t[t.ERROR=3]="ERROR",t[t.INFO=6]="INFO",t[t.DEBUG=7]="DEBUG"}(ie||(ie={}));var le=ie;class de{constructor(t,e,n){this.key=t,this.session=e,this.events=[],this.options=n||{},this.sent=0,this.uniqueID=0}log(t,e){t<=this.options.level&&(this.events.push(D({},e,{timestamp:M.now()})),this.options.limit&&this.events.length>this.options.limit&&this.events.shift())}error(t){this.log(le.ERROR,t)}info(t){this.log(le.INFO,t)}debug(t){this.log(le.DEBUG,t)}isEmpty(){return 0===this.events.length}send(t,e){var n=D({session:this.session,bundle:this.sent+1,key:this.key,lib:"js",version:this.options.version,cluster:this.options.cluster,features:this.options.features,timeline:this.events},this.options.params);return this.events=[],t(n,(t,n)=>{t||this.sent++,e&&e(t,n)}),!0}generateUniqueID(){return this.uniqueID++,this.uniqueID}}class pe{constructor(t,e,n,r){this.name=t,this.priority=e,this.transport=n,this.options=r||{}}isSupported(){return this.transport.isSupported({useTLS:this.options.useTLS})}connect(t,e){if(!this.isSupported())return fe(new y,e);if(this.priority{n||(h(),i?i.close():r.close())},forceMinPriority:t=>{n||this.priority{if(void 0===ue.getAuthorizers()[t.transport])throw`'${t.transport}' is not a recognized auth transport`;return(e,n)=>{const r=((t,e)=>{var n="socket_id="+encodeURIComponent(t.socketId);for(var r in e.params)n+="&"+encodeURIComponent(r)+"="+encodeURIComponent(e.params[r]);if(null!=e.paramsProvider){let t=e.paramsProvider();for(var r in t)n+="&"+encodeURIComponent(r)+"="+encodeURIComponent(t[r])}return n})(e,t);ue.getAuthorizers()[t.transport](ue,r,t,h.UserAuthentication,n)}};var we=t=>{if(void 0===ue.getAuthorizers()[t.transport])throw`'${t.transport}' is not a recognized auth transport`;return(e,n)=>{const r=((t,e)=>{var n="socket_id="+encodeURIComponent(t.socketId);for(var r in n+="&channel_name="+encodeURIComponent(t.channelName),e.params)n+="&"+encodeURIComponent(r)+"="+encodeURIComponent(e.params[r]);if(null!=e.paramsProvider){let t=e.paramsProvider();for(var r in t)n+="&"+encodeURIComponent(r)+"="+encodeURIComponent(t[r])}return n})(e,t);ue.getAuthorizers()[t.transport](ue,r,t,h.ChannelAuthorization,n)}};function _e(t,e){let n={activityTimeout:t.activityTimeout||s.activityTimeout,cluster:t.cluster,httpPath:t.httpPath||s.httpPath,httpPort:t.httpPort||s.httpPort,httpsPort:t.httpsPort||s.httpsPort,pongTimeout:t.pongTimeout||s.pongTimeout,statsHost:t.statsHost||s.stats_host,unavailableTimeout:t.unavailableTimeout||s.unavailableTimeout,wsPath:t.wsPath||s.wsPath,wsPort:t.wsPort||s.wsPort,wssPort:t.wssPort||s.wssPort,enableStats:Te(t),httpHost:Se(t),useTLS:Ce(t),wsHost:ke(t),userAuthenticator:Ee(t),channelAuthorizer:Pe(t,e)};return"disabledTransports"in t&&(n.disabledTransports=t.disabledTransports),"enabledTransports"in t&&(n.enabledTransports=t.enabledTransports),"ignoreNullOrigin"in t&&(n.ignoreNullOrigin=t.ignoreNullOrigin),"timelineParams"in t&&(n.timelineParams=t.timelineParams),"nacl"in t&&(n.nacl=t.nacl),n}function Se(t){return t.httpHost?t.httpHost:t.cluster?`sockjs-${t.cluster}.pusher.com`:s.httpHost}function ke(t){return t.wsHost?t.wsHost:`ws-${t.cluster}.pusher.com`}function Ce(t){return"https:"===ue.getProtocol()||!1!==t.forceTLS}function Te(t){return"enableStats"in t?t.enableStats:"disableStats"in t&&!t.disableStats}function Ee(t){const e=Object.assign(Object.assign({},s.userAuthentication),t.userAuthentication);return"customHandler"in e&&null!=e.customHandler?e.customHandler:me(e)}function Pe(t,e){const n=function(t,e){let n;return"channelAuthorization"in t?n=Object.assign(Object.assign({},s.channelAuthorization),t.channelAuthorization):(n={transport:t.authTransport||s.authTransport,endpoint:t.authEndpoint||s.authEndpoint},"auth"in t&&("params"in t.auth&&(n.params=t.auth.params),"headers"in t.auth&&(n.headers=t.auth.headers)),"authorizer"in t&&(n.customHandler=((t,e,n)=>{const r={authTransport:e.transport,authEndpoint:e.endpoint,auth:{params:e.params,headers:e.headers}};return(e,i)=>{const s=t.channel(e.channelName);n(s,r).authorize(e.socketId,i)}})(e,n,t.authorizer))),n}(t,e);return"customHandler"in n&&null!=n.customHandler?n.customHandler:we(n)}class xe extends at{constructor(t){super((function(t,e){W.debug("No callbacks on watchlist events for "+t)})),this.pusher=t,this.bindWatchlistInternalEvent()}handleEvent(t){t.data.events.forEach(t=>{this.emit(t.name,t)})}bindWatchlistInternalEvent(){this.pusher.connection.bind("message",t=>{"pusher_internal:watchlist_events"===t.event&&this.handleEvent(t)})}}var Ae=function(){let t,e;return{promise:new Promise((n,r)=>{t=n,e=r}),resolve:t,reject:e}};class Oe extends at{constructor(t){super((function(t,e){W.debug("No callbacks on user for "+t)})),this.signin_requested=!1,this.user_data=null,this.serverToUserChannel=null,this.signinDonePromise=null,this._signinDoneResolve=null,this._onAuthorize=(t,e)=>{if(t)return W.warn("Error during signin: "+t),void this._cleanup();this.pusher.send_event("pusher:signin",{auth:e.auth,user_data:e.user_data})},this.pusher=t,this.pusher.connection.bind("state_change",({previous:t,current:e})=>{"connected"!==t&&"connected"===e&&this._signin(),"connected"===t&&"connected"!==e&&(this._cleanup(),this._newSigninPromiseIfNeeded())}),this.watchlist=new xe(t),this.pusher.connection.bind("message",t=>{"pusher:signin_success"===t.event&&this._onSigninSuccess(t.data),this.serverToUserChannel&&this.serverToUserChannel.name===t.channel&&this.serverToUserChannel.handleEvent(t)})}signin(){this.signin_requested||(this.signin_requested=!0,this._signin())}_signin(){this.signin_requested&&(this._newSigninPromiseIfNeeded(),"connected"===this.pusher.connection.state&&this.pusher.config.userAuthenticator({socketId:this.pusher.connection.socket_id},this._onAuthorize))}_onSigninSuccess(t){try{this.user_data=JSON.parse(t.user_data)}catch(e){return W.error("Failed parsing user data after signin: "+t.user_data),void this._cleanup()}if("string"!=typeof this.user_data.id||""===this.user_data.id)return W.error("user_data doesn't contain an id. user_data: "+this.user_data),void this._cleanup();this._signinDoneResolve(),this._subscribeChannels()}_subscribeChannels(){this.serverToUserChannel=new xt("#server-to-user-"+this.user_data.id,this.pusher),this.serverToUserChannel.bind_global((t,e)=>{0!==t.indexOf("pusher_internal:")&&0!==t.indexOf("pusher:")&&this.emit(t,e)}),(t=>{t.subscriptionPending&&t.subscriptionCancelled?t.reinstateSubscription():t.subscriptionPending||"connected"!==this.pusher.connection.state||t.subscribe()})(this.serverToUserChannel)}_cleanup(){this.user_data=null,this.serverToUserChannel&&(this.serverToUserChannel.unbind_all(),this.serverToUserChannel.disconnect(),this.serverToUserChannel=null),this.signin_requested&&this._signinDoneResolve()}_newSigninPromiseIfNeeded(){if(!this.signin_requested)return;if(this.signinDonePromise&&!this.signinDonePromise.done)return;const{promise:t,resolve:e,reject:n}=Ae();t.done=!1;const r=()=>{t.done=!0};t.then(r).catch(r),this.signinDonePromise=t,this._signinDoneResolve=e}}class Le{static ready(){Le.isReady=!0;for(var t=0,e=Le.instances.length;tue.getDefaultStrategy(this.config,t,ve),timeline:this.timeline,activityTimeout:this.config.activityTimeout,pongTimeout:this.config.pongTimeout,unavailableTimeout:this.config.unavailableTimeout,useTLS:Boolean(this.config.useTLS)}),this.connection.bind("connected",()=>{this.subscribeAll(),this.timelineSender&&this.timelineSender.send(this.connection.isUsingTLS())}),this.connection.bind("message",t=>{var e=0===t.event.indexOf("pusher_internal:");if(t.channel){var n=this.channel(t.channel);n&&n.handleEvent(t)}e||this.global_emitter.emit(t.event,t.data)}),this.connection.bind("connecting",()=>{this.channels.disconnect()}),this.connection.bind("disconnected",()=>{this.channels.disconnect()}),this.connection.bind("error",t=>{W.warn(t)}),Le.instances.push(this),this.timeline.info({instances:Le.instances.length}),this.user=new Oe(this),Le.isReady&&this.connect()}switchCluster(t){const{appKey:e,cluster:n}=t;this.key=e,this.options=Object.assign(Object.assign({},this.options),{cluster:n}),this.config=_e(this.options,this),this.connection.switchCluster(this.key)}channel(t){return this.channels.find(t)}allChannels(){return this.channels.all()}connect(){if(this.connection.connect(),this.timelineSender&&!this.timelineSenderTimer){var t=this.connection.isUsingTLS(),e=this.timelineSender;this.timelineSenderTimer=new I(6e4,(function(){e.send(t)}))}}disconnect(){this.connection.disconnect(),this.timelineSenderTimer&&(this.timelineSenderTimer.ensureAborted(),this.timelineSenderTimer=null)}bind(t,e,n){return this.global_emitter.bind(t,e,n),this}unbind(t,e,n){return this.global_emitter.unbind(t,e,n),this}bind_global(t){return this.global_emitter.bind_global(t),this}unbind_global(t){return this.global_emitter.unbind_global(t),this}unbind_all(t){return this.global_emitter.unbind_all(),this}subscribeAll(){var t;for(t in this.channels.channels)this.channels.channels.hasOwnProperty(t)&&this.subscribe(t)}subscribe(t){var e=this.channels.add(t,this);return e.subscriptionPending&&e.subscriptionCancelled?e.reinstateSubscription():e.subscriptionPending||"connected"!==this.connection.state||e.subscribe(),e}unsubscribe(t){var e=this.channels.find(t);e&&e.subscriptionPending?e.cancelSubscription():(e=this.channels.remove(t))&&e.subscribed&&e.unsubscribe()}send_event(t,e,n){return this.connection.send_event(t,e,n)}shouldUseTLS(){return this.config.useTLS}signin(){this.user.signin()}}Le.instances=[],Le.isReady=!1,Le.logToConsole=!1,Le.Runtime=ue,Le.ScriptReceivers=ue.ScriptReceivers,Le.DependenciesReceivers=ue.DependenciesReceivers,Le.auth_callbacks=ue.auth_callbacks;var Re=Le;ue.setup(Le);var Ue=n(2);class Ie extends Re{constructor(t,e){Re.logToConsole=Ie.logToConsole,Re.log=Ie.log,ye(e),e.nacl=Ue,super(t,e)}}}])})); //# sourceMappingURL=pusher-with-encryption.min.js.map \ No newline at end of file diff --git a/dist/web/pusher-with-encryption.min.js.map b/dist/web/pusher-with-encryption.min.js.map index a91b0d5eb..4d0695f16 100644 --- a/dist/web/pusher-with-encryption.min.js.map +++ b/dist/web/pusher-with-encryption.min.js.map @@ -1 +1 @@ -{"version":3,"sources":["webpack://Pusher/webpack/universalModuleDefinition","webpack://Pusher/webpack/bootstrap","webpack://Pusher/./node_modules/@stablelib/base64/base64.ts","webpack://Pusher/./node_modules/@stablelib/utf8/utf8.ts","webpack://Pusher/./node_modules/tweetnacl/nacl-fast.js","webpack://Pusher/./src/core/pusher-with-encryption.js","webpack://Pusher/./src/runtimes/web/dom/script_receiver_factory.ts","webpack://Pusher/./src/core/defaults.ts","webpack://Pusher/./src/runtimes/web/dom/dependencies.ts","webpack://Pusher/./src/runtimes/web/dom/dependency_loader.ts","webpack://Pusher/./src/core/utils/url_store.ts","webpack://Pusher/./src/core/auth/options.ts","webpack://Pusher/./src/core/errors.ts","webpack://Pusher/./src/runtimes/isomorphic/auth/xhr_auth.ts","webpack://Pusher/./src/core/base64.ts","webpack://Pusher/./src/core/utils/timers/abstract_timer.ts","webpack://Pusher/./src/core/utils/timers/index.ts","webpack://Pusher/./src/core/util.ts","webpack://Pusher/./src/core/utils/collections.ts","webpack://Pusher/./src/core/logger.ts","webpack://Pusher/./src/runtimes/web/auth/jsonp_auth.ts","webpack://Pusher/./src/runtimes/web/dom/script_request.ts","webpack://Pusher/./src/runtimes/web/dom/jsonp_request.ts","webpack://Pusher/./src/runtimes/web/timeline/jsonp_timeline.ts","webpack://Pusher/./src/core/transports/url_schemes.ts","webpack://Pusher/./src/core/events/callback_registry.ts","webpack://Pusher/./src/core/events/dispatcher.ts","webpack://Pusher/./src/core/transports/transport_connection.ts","webpack://Pusher/./src/core/transports/transport.ts","webpack://Pusher/./src/runtimes/isomorphic/transports/transports.ts","webpack://Pusher/./src/runtimes/web/transports/transports.ts","webpack://Pusher/./src/runtimes/web/net_info.ts","webpack://Pusher/./src/core/transports/assistant_to_the_transport_manager.ts","webpack://Pusher/./src/core/connection/protocol/protocol.ts","webpack://Pusher/./src/core/connection/connection.ts","webpack://Pusher/./src/core/connection/handshake/index.ts","webpack://Pusher/./src/core/timeline/timeline_sender.ts","webpack://Pusher/./src/core/channels/channel.ts","webpack://Pusher/./src/core/channels/private_channel.ts","webpack://Pusher/./src/core/channels/members.ts","webpack://Pusher/./src/core/channels/presence_channel.ts","webpack://Pusher/./src/core/channels/encrypted_channel.ts","webpack://Pusher/./src/core/connection/connection_manager.ts","webpack://Pusher/./src/core/channels/channels.ts","webpack://Pusher/./src/core/utils/factory.ts","webpack://Pusher/./src/core/transports/transport_manager.ts","webpack://Pusher/./src/core/strategies/sequential_strategy.ts","webpack://Pusher/./src/core/strategies/best_connected_ever_strategy.ts","webpack://Pusher/./src/core/strategies/websocket_prioritized_cached_strategy.ts","webpack://Pusher/./src/core/strategies/delayed_strategy.ts","webpack://Pusher/./src/core/strategies/if_strategy.ts","webpack://Pusher/./src/core/strategies/first_connected_strategy.ts","webpack://Pusher/./src/runtimes/web/default_strategy.ts","webpack://Pusher/./src/runtimes/web/http/http_xdomain_request.ts","webpack://Pusher/./src/core/http/http_request.ts","webpack://Pusher/./src/core/http/state.ts","webpack://Pusher/./src/core/http/http_socket.ts","webpack://Pusher/./src/core/timeline/level.ts","webpack://Pusher/./src/core/http/http_streaming_socket.ts","webpack://Pusher/./src/core/http/http_polling_socket.ts","webpack://Pusher/./src/runtimes/isomorphic/http/http_xhr_request.ts","webpack://Pusher/./src/runtimes/isomorphic/http/http.ts","webpack://Pusher/./src/runtimes/web/http/http.ts","webpack://Pusher/./src/runtimes/web/runtime.ts","webpack://Pusher/./src/runtimes/web/transports/transport_connection_initializer.ts","webpack://Pusher/./src/core/timeline/timeline.ts","webpack://Pusher/./src/core/strategies/transport_strategy.ts","webpack://Pusher/./src/core/strategies/strategy_builder.ts","webpack://Pusher/./src/core/options.ts","webpack://Pusher/./src/core/auth/user_authenticator.ts","webpack://Pusher/./src/core/auth/channel_authorizer.ts","webpack://Pusher/./src/core/config.ts","webpack://Pusher/./src/core/auth/deprecated_channel_authorizer.ts","webpack://Pusher/./src/core/watchlist.ts","webpack://Pusher/./src/core/utils/flat_promise.ts","webpack://Pusher/./src/core/user.ts","webpack://Pusher/./src/core/pusher.ts","webpack://Pusher/./src/core/pusher-with-encryption.ts"],"names":["root","factory","exports","module","define","amd","window","installedModules","__webpack_require__","moduleId","i","l","modules","call","m","c","d","name","getter","o","Object","defineProperty","enumerable","get","r","Symbol","toStringTag","value","t","mode","__esModule","ns","create","key","bind","n","object","property","prototype","hasOwnProperty","p","s","_paddingCharacter","encodedLength","length","this","encode","data","out","_encodeByte","left","maxDecodedLength","decodedLength","_getPaddingLength","decode","Uint8Array","paddingLength","op","haveBad","v0","v1","v2","v3","_decodeChar","charCodeAt","Error","b","result","String","fromCharCode","Coder","stdCoder","URLSafeCoder","urlSafeCoder","INVALID_UTF8","arr","pos","chars","min","n1","n2","n3","push","join","nacl","gf","init","Float64Array","randombytes","_0","_9","gf0","gf1","_121665","D","D2","X","Y","I","ts64","x","h","vn","xi","y","yi","crypto_verify_16","crypto_verify_32","crypto_core_salsa20","inp","k","u","j0","j1","j2","j3","j4","j5","j6","j7","j8","j9","j10","j11","j12","j13","j14","j15","x0","x1","x2","x3","x4","x5","x6","x7","x8","x9","x10","x11","x12","x13","x14","x15","core_salsa20","crypto_core_hsalsa20","core_hsalsa20","sigma","crypto_stream_salsa20_xor","cpos","mpos","z","crypto_stream_salsa20","crypto_stream","sn","crypto_stream_xor","poly1305","t0","t1","t2","t3","t4","t5","t6","t7","buffer","Uint16Array","pad","leftover","fin","crypto_onetimeauth","outpos","update","finish","crypto_onetimeauth_verify","hpos","crypto_secretbox","crypto_secretbox_open","set25519","a","car25519","v","Math","floor","sel25519","q","pack25519","j","neq25519","par25519","unpack25519","A","Z","M","t8","t9","t10","t11","t12","t13","t14","t15","t16","t17","t18","t19","t20","t21","t22","t23","t24","t25","t26","t27","t28","t29","t30","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","b10","b11","b12","b13","b14","b15","S","inv25519","pow2523","crypto_scalarmult","e","f","x32","subarray","x16","crypto_scalarmult_base","crypto_box_keypair","crypto_box_beforenm","blocks","bytes","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","hibit","h0","h1","h2","h3","h4","h5","h6","h7","h8","h9","r0","r1","r2","r3","r4","r5","r6","r7","r8","r9","mac","macpos","mask","g","want","crypto_box_afternm","crypto_box_open_afternm","K","crypto_hashblocks_hl","hh","hl","bh0","bh1","bh2","bh3","bh4","bh5","bh6","bh7","bl0","bl1","bl2","bl3","bl4","bl5","bl6","bl7","th","tl","wh","Int32Array","wl","ah0","ah1","ah2","ah3","ah4","ah5","ah6","ah7","al0","al1","al2","al3","al4","al5","al6","al7","crypto_hash","add","cswap","pack","tx","ty","zi","scalarmult","scalarbase","crypto_sign_keypair","pk","sk","seeded","L","modL","carry","reduce","crypto_sign","sm","smlen","crypto_sign_open","chk","num","den","den2","den4","den6","unpackneg","checkLengths","checkArrayTypes","arguments","TypeError","cleanup","lowlevel","crypto_box","crypto_box_open","crypto_secretbox_KEYBYTES","crypto_secretbox_NONCEBYTES","crypto_secretbox_ZEROBYTES","crypto_secretbox_BOXZEROBYTES","crypto_scalarmult_BYTES","crypto_scalarmult_SCALARBYTES","crypto_box_PUBLICKEYBYTES","crypto_box_SECRETKEYBYTES","crypto_box_BEFORENMBYTES","crypto_box_NONCEBYTES","crypto_box_ZEROBYTES","crypto_box_BOXZEROBYTES","crypto_sign_BYTES","crypto_sign_PUBLICKEYBYTES","crypto_sign_SECRETKEYBYTES","crypto_sign_SEEDBYTES","crypto_hash_BYTES","randomBytes","secretbox","msg","nonce","open","box","keyLength","nonceLength","overheadLength","scalarMult","base","scalarLength","groupElementLength","publicKey","secretKey","before","checkBoxLengths","after","keyPair","fromSecretKey","publicKeyLength","secretKeyLength","sharedKeyLength","sign","signedMsg","tmp","mlen","detached","sig","verify","fromSeed","seed","seedLength","signatureLength","hash","hashLength","setPRNG","fn","crypto","self","msCrypto","getRandomValues","default","ScriptReceiverFactory","prefix","lastId","callback","number","id","called","callbackWrapper","apply","receiver","ScriptReceivers","VERSION","PROTOCOL","wsPort","wssPort","wsPath","httpHost","httpPort","httpsPort","httpPath","stats_host","authEndpoint","authTransport","activityTimeout","pongTimeout","unavailableTimeout","userAuthentication","endpoint","transport","channelAuthorization","cdn_http","cdn_https","dependency_suffix","DependenciesReceivers","Dependencies","options","receivers","loading","request","createScriptRequest","getPath","error","remove","callbacks","successCallback","wasSuccessful","send","protocol","getDocument","location","useTLS","replace","version","getRoot","suffix","urlStore","baseUrl","urls","authenticationEndpoint","path","authorizationEndpoint","javascriptQuickStart","triggeringClientEvents","encryptedChannelSupport","fullUrl","AuthRequestType","urlObj","url","BadEventName","super","setPrototypeOf","BadChannelName","RequestTimedOut","TransportPriorityTooLow","TransportClosed","UnsupportedFeature","UnsupportedTransport","UnsupportedStrategy","HTTPAuthError","status","context","query","authOptions","authRequestType","xhr","createXHR","headerName","setRequestHeader","headers","headersProvider","dynamicHeaders","onreadystatechange","readyState","parsed","JSON","parse","responseText","toString","UserAuthentication","ChannelAuthorization","b64chars","b64tab","charAt","cb_utob","cc","utob","cb_encode","ccc","padlen","ord","btoa","set","clear","delay","timer","clearTimeout","clearInterval","setTimeout","setInterval","now","Date","valueOf","defer","args","boundArguments","Array","slice","concat","extend","target","sources","extensions","constructor","stringify","safeJSONStringify","arrayIndexOf","array","item","nativeIndexOf","indexOf","objectApply","keys","_","map","filter","test","filterObject","Boolean","any","encodeParamsObject","encodeURIComponent","buildQueryString","params","undefined","method","source","objects","paths","derez","nu","$ref","globalLog","message","console","log","globalLogWarn","globalLogError","warn","defaultLoggingFunction","logToConsole","callbackName","nextAuthCallbackID","document","script","createElement","auth_callbacks","callback_name","src","head","getElementsByTagName","documentElement","insertBefore","firstChild","ScriptRequest","errorString","type","charset","addEventListener","onerror","onload","async","attachEvent","navigator","userAgent","errorScript","text","nextSibling","parentNode","removeChild","getAgent","sender","host","createJSONPRequest","getGenericURL","baseScheme","hostTLS","hostNonTLS","getGenericPath","queryString","ws","getInitial","http","sockjs","_callbacks","prefixedEventName","names","removeCallback","removeAllCallbacks","binding","failThrough","global_callbacks","eventName","unbind","unbind_global","metadata","hooks","priority","initialize","transportConnectionInitializer","state","timeline","generateUniqueID","handlesActivityChecks","supportsPing","socket","getSocket","onError","changeState","bindListeners","debug","close","ping","beforeOpen","onopen","emit","buildTimelineMessage","closeEvent","code","reason","wasClean","unbindListeners","onOpen","onclose","onClose","onmessage","onMessage","onactivity","onActivity","info","cid","environment","isSupported","WSTransport","isInitialized","getWebSocketAPI","createWebSocket","httpConfiguration","streamingConfiguration","HTTPFactory","createStreamingSocket","pollingConfiguration","createPollingSocket","xhrConfiguration","isXHRSupported","xhr_streaming","xhr_polling","SockJSTransport","file","SockJS","js_path","ignore_null_origin","ignoreNullOrigin","xdrConfiguration","isXDRSupported","XDRStreamingTransport","XDRPollingTransport","xdr_streaming","xdr_polling","onLine","manager","minPingDelay","maxPingDelay","pingDelay","connection","createConnection","openTimestamp","onClosed","reportDeath","lifespan","max","isAlive","Protocol","decodeMessage","messageEvent","messageData","pusherEventData","pusherEvent","event","channel","user_id","encodeMessage","processHandshake","activity_timeout","action","socket_id","getCloseAction","getCloseError","send_event","listeners","activity","closed","handleCloseEvent","listener","isEmpty","TimelineTransport","pusher","subscribed","subscriptionPending","subscriptionCancelled","socketId","auth","handleSubscriptionSucceededEvent","handleSubscriptionCountEvent","unsubscribe","subscription_count","subscriptionCount","authorize","assign","channel_data","config","channelAuthorizer","channelName","reset","members","member","myID","subscriptionData","presence","count","me","memberData","user_info","authData","channelData","setMyID","user","signinDonePromise","user_data","handleInternalEvent","addedMember","addMember","removedMember","removeMember","onSubscription","disconnect","sharedSecret","handleEncryptedEvent","handleEvent","ciphertext","cipherText","getDataToEmit","raw","usingTLS","errorCallbacks","buildErrorCallbacks","connectionCallbacks","buildConnectionCallbacks","handshakeCallbacks","buildHandshakeCallbacks","Network","getNetwork","netinfo","retryIn","sendActivityCheck","updateStrategy","runner","strategy","updateState","startConnecting","setUnavailableTimer","disconnectInternally","handshake","connect","handshakeError","abortConnecting","abort","clearRetryTimer","clearUnavailableTimer","abandonConnection","getStrategy","round","retryTimer","ensureAborted","unavailableTimer","stopActivityCheck","activityTimer","pong_timed_out","resetActivityCheck","shouldRetry","connected","Infinity","setConnection","withErrorEmitted","tls_only","refused","backoff","retry","newState","previousState","newStateDescription","previous","current","channels","createEncryptedChannel","errMsg","createPrivateChannel","createPresenceChannel","createChannel","values","createChannels","createConnectionManager","createTimelineSender","createHandshake","createAssistantToTheTransportManager","livesLeft","lives","strategies","loop","failFast","timeout","timeoutLimit","minPriority","tryNextStrategy","tryStrategy","forceMinPriority","isRunning","callbackBuilder","runners","rs","abortRunner","allRunnersFailed","aborted","transports","ttl","storage","getLocalStorage","serializedCache","getTransportCacheKey","flushTransportCache","fetchTransportCache","cacheSkipCount","timestamp","includes","cached","latency","startTimestamp","pop","cb","storeTransportCache","IfStrategy","trueBranch","falseBranch","FirstConnectedStrategy","testSupportsStrategy","baseOptions","defineTransport","definedTransports","defineTransportStrategy","wsStrategy","ws_options","wsHost","wss_options","sockjs_options","timeouts","ws_manager","streaming_manager","ws_transport","wss_transport","sockjs_transport","xhr_streaming_transport","xdr_streaming_transport","xhr_polling_transport","xdr_polling_transport","ws_loop","wss_loop","sockjs_loop","streaming_loop","polling_loop","http_loop","http_fallback_loop","getRequest","xdr","XDomainRequest","ontimeout","onprogress","onChunk","abortRequest","payload","position","unloader","addUnloadListener","removeUnloadListener","chunk","advanceBuffer","isBufferTooLong","unreadData","endOfLinePosition","State","autoIncrement","getUniqueURL","separator","randomNumber","randomInt","TimelineLevel","session","randomString","parts","exec","getLocation","CONNECTING","openStream","sendRaw","sendHeartbeat","OPEN","createSocketRequest","start","closeStream","CLOSED","onEvent","onHeartbeat","hostname","urlParts","stream","getReceiveURL","onFinished","reconnect","unbind_all","getXHRAPI","createSocket","createRequest","getDefaultStrategy","Transports","load","XMLHttpRequest","WebSocket","MozWebSocket","PusherClass","Pusher","initializeOnDocumentBody","onDocumentBody","ready","getAuthorizers","ajax","jsonp","body","localStorage","createXMLHttpRequest","createMicrosoftXHR","ActiveXObject","createXDR","Constructor","withCredentials","documentProtocol","getProtocol","removeEventListener","detachEvent","Uint32Array","events","sent","uniqueID","level","limit","shift","ERROR","INFO","DEBUG","sendfn","bundle","lib","cluster","features","failAttempt","onInitialized","serializedTransport","transportClass","enabledTransports","disabledTransports","getAssistant","deferred","validateOptions","paramsProvider","dynamicParams","composeChannelQuery","getConfig","opts","statsHost","enableStats","getEnableStatsConfig","getHttpHost","shouldUseTLS","getWebsocketHost","userAuthenticator","buildUserAuthenticator","buildChannelAuthorizer","timelineParams","forceTLS","disableStats","customHandler","channelAuthorizerGenerator","deprecatedAuthorizerOptions","ChannelAuthorizerProxy","authorizer","buildChannelAuth","bindWatchlistInternalEvent","forEach","watchlistEvent","resolve","reject","promise","Promise","res","rej","signin_requested","serverToUserChannel","_signinDoneResolve","_onAuthorize","err","_cleanup","_signin","_newSigninPromiseIfNeeded","watchlist","_onSigninSuccess","_subscribeChannels","bind_global","reinstateSubscription","subscribe","ensure_subscribed","done","setDone","then","catch","isReady","instances","app_key","checkAppKey","global_emitter","sessionID","getClientFeatures","timelineSender","subscribeAll","isUsingTLS","internal","appKey","switchCluster","find","all","timelineSenderTimer","event_name","channel_name","cancelSubscription","signin","Runtime","setup"],"mappings":";;;;;;;CAAA,SAA2CA,EAAMC,GAC1B,iBAAZC,SAA0C,iBAAXC,OACxCA,OAAOD,QAAUD,IACQ,mBAAXG,QAAyBA,OAAOC,IAC9CD,OAAO,GAAIH,GACe,iBAAZC,QACdA,QAAgB,OAAID,IAEpBD,EAAa,OAAIC,IARnB,CASGK,QAAQ,WACX,O,YCTE,IAAIC,EAAmB,GAGvB,SAASC,EAAoBC,GAG5B,GAAGF,EAAiBE,GACnB,OAAOF,EAAiBE,GAAUP,QAGnC,IAAIC,EAASI,EAAiBE,GAAY,CACzCC,EAAGD,EACHE,GAAG,EACHT,QAAS,IAUV,OANAU,EAAQH,GAAUI,KAAKV,EAAOD,QAASC,EAAQA,EAAOD,QAASM,GAG/DL,EAAOQ,GAAI,EAGJR,EAAOD,QA0Df,OArDAM,EAAoBM,EAAIF,EAGxBJ,EAAoBO,EAAIR,EAGxBC,EAAoBQ,EAAI,SAASd,EAASe,EAAMC,GAC3CV,EAAoBW,EAAEjB,EAASe,IAClCG,OAAOC,eAAenB,EAASe,EAAM,CAAEK,YAAY,EAAMC,IAAKL,KAKhE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AQmB,oBACrBnB,EAAQyW,sBAERzW,EAAU7qB,KAAK+xB,SAAS5X,OAAOknB,KAChBxW,EAAQkB,YACrBlB,EAAQyB,cAKd,WAAW8U,EAAoBlhC,EAAW2qB,GACxC,OAAO7qB,KAAK8pB,WAAWwB,WAAW8V,EAAYlhC,EAAM2qB,GAGtD,eACE,OAAO7qB,KAAK4sB,OAAOjS,OAGrB,SACE3a,KAAK4tB,KAAK2T,UAtOL,GAAAlB,UAAsB,GACtB,GAAAD,SAAmB,EACnB,GAAAle,cAAwB,EAGxB,GAAAsf,QAA2B,GAC3B,GAAArpB,gBAA6B,GAASA,gBACtC,GAAAuB,sBAAmC,GAASA,sBAC5C,GAAA8I,eAA4B,GAASA,eAVzB,UAkPrB,GAAQif,MAAM,I,YClQC,MAAM,WAA6B,GAChD,YAAYnB,EAAiB1mB,GAC3B,GAAOsI,aAAe,GAAqBA,aAC3C,GAAOL,IAAM,GAAqBA,IAElCmb,GAAgBpjB,GAChBA,EAAQrX,KAAO,GACfuZ,MAAMwkB,EAAS1mB","file":"pusher-with-encryption.min.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"Pusher\"] = factory();\n\telse\n\t\troot[\"Pusher\"] = factory();\n})(window, function() {\nreturn "," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 3);\n","// Copyright (C) 2016 Dmitry Chestnykh\n// MIT License. See LICENSE file for details.\n\n/**\n * Package base64 implements Base64 encoding and decoding.\n */\n\n// Invalid character used in decoding to indicate\n// that the character to decode is out of range of\n// alphabet and cannot be decoded.\nconst INVALID_BYTE = 256;\n\n/**\n * Implements standard Base64 encoding.\n *\n * Operates in constant time.\n */\nexport class Coder {\n // TODO(dchest): methods to encode chunk-by-chunk.\n\n constructor(private _paddingCharacter = \"=\") { }\n\n encodedLength(length: number): number {\n if (!this._paddingCharacter) {\n return (length * 8 + 5) / 6 | 0;\n }\n return (length + 2) / 3 * 4 | 0;\n }\n\n encode(data: Uint8Array): string {\n let out = \"\";\n\n let i = 0;\n for (; i < data.length - 2; i += 3) {\n let c = (data[i] << 16) | (data[i + 1] << 8) | (data[i + 2]);\n out += this._encodeByte((c >>> 3 * 6) & 63);\n out += this._encodeByte((c >>> 2 * 6) & 63);\n out += this._encodeByte((c >>> 1 * 6) & 63);\n out += this._encodeByte((c >>> 0 * 6) & 63);\n }\n\n const left = data.length - i;\n if (left > 0) {\n let c = (data[i] << 16) | (left === 2 ? data[i + 1] << 8 : 0);\n out += this._encodeByte((c >>> 3 * 6) & 63);\n out += this._encodeByte((c >>> 2 * 6) & 63);\n if (left === 2) {\n out += this._encodeByte((c >>> 1 * 6) & 63);\n } else {\n out += this._paddingCharacter || \"\";\n }\n out += this._paddingCharacter || \"\";\n }\n\n return out;\n }\n\n maxDecodedLength(length: number): number {\n if (!this._paddingCharacter) {\n return (length * 6 + 7) / 8 | 0;\n }\n return length / 4 * 3 | 0;\n }\n\n decodedLength(s: string): number {\n return this.maxDecodedLength(s.length - this._getPaddingLength(s));\n }\n\n decode(s: string): Uint8Array {\n if (s.length === 0) {\n return new Uint8Array(0);\n }\n const paddingLength = this._getPaddingLength(s);\n const length = s.length - paddingLength;\n const out = new Uint8Array(this.maxDecodedLength(length));\n let op = 0;\n let i = 0;\n let haveBad = 0;\n let v0 = 0, v1 = 0, v2 = 0, v3 = 0;\n for (; i < length - 4; i += 4) {\n v0 = this._decodeChar(s.charCodeAt(i + 0));\n v1 = this._decodeChar(s.charCodeAt(i + 1));\n v2 = this._decodeChar(s.charCodeAt(i + 2));\n v3 = this._decodeChar(s.charCodeAt(i + 3));\n out[op++] = (v0 << 2) | (v1 >>> 4);\n out[op++] = (v1 << 4) | (v2 >>> 2);\n out[op++] = (v2 << 6) | v3;\n haveBad |= v0 & INVALID_BYTE;\n haveBad |= v1 & INVALID_BYTE;\n haveBad |= v2 & INVALID_BYTE;\n haveBad |= v3 & INVALID_BYTE;\n }\n if (i < length - 1) {\n v0 = this._decodeChar(s.charCodeAt(i));\n v1 = this._decodeChar(s.charCodeAt(i + 1));\n out[op++] = (v0 << 2) | (v1 >>> 4);\n haveBad |= v0 & INVALID_BYTE;\n haveBad |= v1 & INVALID_BYTE;\n }\n if (i < length - 2) {\n v2 = this._decodeChar(s.charCodeAt(i + 2));\n out[op++] = (v1 << 4) | (v2 >>> 2);\n haveBad |= v2 & INVALID_BYTE;\n }\n if (i < length - 3) {\n v3 = this._decodeChar(s.charCodeAt(i + 3));\n out[op++] = (v2 << 6) | v3;\n haveBad |= v3 & INVALID_BYTE;\n }\n if (haveBad !== 0) {\n throw new Error(\"Base64Coder: incorrect characters for decoding\");\n }\n return out;\n }\n\n // Standard encoding have the following encoded/decoded ranges,\n // which we need to convert between.\n //\n // ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 0123456789 + /\n // Index: 0 - 25 26 - 51 52 - 61 62 63\n // ASCII: 65 - 90 97 - 122 48 - 57 43 47\n //\n\n // Encode 6 bits in b into a new character.\n protected _encodeByte(b: number): string {\n // Encoding uses constant time operations as follows:\n //\n // 1. Define comparison of A with B using (A - B) >>> 8:\n // if A > B, then result is positive integer\n // if A <= B, then result is 0\n //\n // 2. Define selection of C or 0 using bitwise AND: X & C:\n // if X == 0, then result is 0\n // if X != 0, then result is C\n //\n // 3. Start with the smallest comparison (b >= 0), which is always\n // true, so set the result to the starting ASCII value (65).\n //\n // 4. Continue comparing b to higher ASCII values, and selecting\n // zero if comparison isn't true, otherwise selecting a value\n // to add to result, which:\n //\n // a) undoes the previous addition\n // b) provides new value to add\n //\n let result = b;\n // b >= 0\n result += 65;\n // b > 25\n result += ((25 - b) >>> 8) & ((0 - 65) - 26 + 97);\n // b > 51\n result += ((51 - b) >>> 8) & ((26 - 97) - 52 + 48);\n // b > 61\n result += ((61 - b) >>> 8) & ((52 - 48) - 62 + 43);\n // b > 62\n result += ((62 - b) >>> 8) & ((62 - 43) - 63 + 47);\n\n return String.fromCharCode(result);\n }\n\n // Decode a character code into a byte.\n // Must return 256 if character is out of alphabet range.\n protected _decodeChar(c: number): number {\n // Decoding works similar to encoding: using the same comparison\n // function, but now it works on ranges: result is always incremented\n // by value, but this value becomes zero if the range is not\n // satisfied.\n //\n // Decoding starts with invalid value, 256, which is then\n // subtracted when the range is satisfied. If none of the ranges\n // apply, the function returns 256, which is then checked by\n // the caller to throw error.\n let result = INVALID_BYTE; // start with invalid character\n\n // c == 43 (c > 42 and c < 44)\n result += (((42 - c) & (c - 44)) >>> 8) & (-INVALID_BYTE + c - 43 + 62);\n // c == 47 (c > 46 and c < 48)\n result += (((46 - c) & (c - 48)) >>> 8) & (-INVALID_BYTE + c - 47 + 63);\n // c > 47 and c < 58\n result += (((47 - c) & (c - 58)) >>> 8) & (-INVALID_BYTE + c - 48 + 52);\n // c > 64 and c < 91\n result += (((64 - c) & (c - 91)) >>> 8) & (-INVALID_BYTE + c - 65 + 0);\n // c > 96 and c < 123\n result += (((96 - c) & (c - 123)) >>> 8) & (-INVALID_BYTE + c - 97 + 26);\n\n return result;\n }\n\n private _getPaddingLength(s: string): number {\n let paddingLength = 0;\n if (this._paddingCharacter) {\n for (let i = s.length - 1; i >= 0; i--) {\n if (s[i] !== this._paddingCharacter) {\n break;\n }\n paddingLength++;\n }\n if (s.length < 4 || paddingLength > 2) {\n throw new Error(\"Base64Coder: incorrect padding\");\n }\n }\n return paddingLength;\n }\n\n}\n\nconst stdCoder = new Coder();\n\nexport function encode(data: Uint8Array): string {\n return stdCoder.encode(data);\n}\n\nexport function decode(s: string): Uint8Array {\n return stdCoder.decode(s);\n}\n\n/**\n * Implements URL-safe Base64 encoding.\n * (Same as Base64, but '+' is replaced with '-', and '/' with '_').\n *\n * Operates in constant time.\n */\nexport class URLSafeCoder extends Coder {\n // URL-safe encoding have the following encoded/decoded ranges:\n //\n // ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 0123456789 - _\n // Index: 0 - 25 26 - 51 52 - 61 62 63\n // ASCII: 65 - 90 97 - 122 48 - 57 45 95\n //\n\n protected _encodeByte(b: number): string {\n let result = b;\n // b >= 0\n result += 65;\n // b > 25\n result += ((25 - b) >>> 8) & ((0 - 65) - 26 + 97);\n // b > 51\n result += ((51 - b) >>> 8) & ((26 - 97) - 52 + 48);\n // b > 61\n result += ((61 - b) >>> 8) & ((52 - 48) - 62 + 45);\n // b > 62\n result += ((62 - b) >>> 8) & ((62 - 45) - 63 + 95);\n\n return String.fromCharCode(result);\n }\n\n protected _decodeChar(c: number): number {\n let result = INVALID_BYTE;\n\n // c == 45 (c > 44 and c < 46)\n result += (((44 - c) & (c - 46)) >>> 8) & (-INVALID_BYTE + c - 45 + 62);\n // c == 95 (c > 94 and c < 96)\n result += (((94 - c) & (c - 96)) >>> 8) & (-INVALID_BYTE + c - 95 + 63);\n // c > 47 and c < 58\n result += (((47 - c) & (c - 58)) >>> 8) & (-INVALID_BYTE + c - 48 + 52);\n // c > 64 and c < 91\n result += (((64 - c) & (c - 91)) >>> 8) & (-INVALID_BYTE + c - 65 + 0);\n // c > 96 and c < 123\n result += (((96 - c) & (c - 123)) >>> 8) & (-INVALID_BYTE + c - 97 + 26);\n\n return result;\n }\n}\n\nconst urlSafeCoder = new URLSafeCoder();\n\nexport function encodeURLSafe(data: Uint8Array): string {\n return urlSafeCoder.encode(data);\n}\n\nexport function decodeURLSafe(s: string): Uint8Array {\n return urlSafeCoder.decode(s);\n}\n\n\nexport const encodedLength = (length: number) =>\n stdCoder.encodedLength(length);\n\nexport const maxDecodedLength = (length: number) =>\n stdCoder.maxDecodedLength(length);\n\nexport const decodedLength = (s: string) =>\n stdCoder.decodedLength(s);\n","// Copyright (C) 2016 Dmitry Chestnykh\n// MIT License. See LICENSE file for details.\n\n/**\n * Package utf8 implements UTF-8 encoding and decoding.\n */\n\nconst INVALID_UTF16 = \"utf8: invalid string\";\nconst INVALID_UTF8 = \"utf8: invalid source encoding\";\n\n/**\n * Encodes the given string into UTF-8 byte array.\n * Throws if the source string has invalid UTF-16 encoding.\n */\nexport function encode(s: string): Uint8Array {\n // Calculate result length and allocate output array.\n // encodedLength() also validates string and throws errors,\n // so we don't need repeat validation here.\n const arr = new Uint8Array(encodedLength(s));\n\n let pos = 0;\n for (let i = 0; i < s.length; i++) {\n let c = s.charCodeAt(i);\n if (c < 0x80) {\n arr[pos++] = c;\n } else if (c < 0x800) {\n arr[pos++] = 0xc0 | c >> 6;\n arr[pos++] = 0x80 | c & 0x3f;\n } else if (c < 0xd800) {\n arr[pos++] = 0xe0 | c >> 12;\n arr[pos++] = 0x80 | (c >> 6) & 0x3f;\n arr[pos++] = 0x80 | c & 0x3f;\n } else {\n i++; // get one more character\n c = (c & 0x3ff) << 10;\n c |= s.charCodeAt(i) & 0x3ff;\n c += 0x10000;\n\n arr[pos++] = 0xf0 | c >> 18;\n arr[pos++] = 0x80 | (c >> 12) & 0x3f;\n arr[pos++] = 0x80 | (c >> 6) & 0x3f;\n arr[pos++] = 0x80 | c & 0x3f;\n }\n }\n return arr;\n}\n\n/**\n * Returns the number of bytes required to encode the given string into UTF-8.\n * Throws if the source string has invalid UTF-16 encoding.\n */\nexport function encodedLength(s: string): number {\n let result = 0;\n for (let i = 0; i < s.length; i++) {\n const c = s.charCodeAt(i);\n if (c < 0x80) {\n result += 1;\n } else if (c < 0x800) {\n result += 2;\n } else if (c < 0xd800) {\n result += 3;\n } else if (c <= 0xdfff) {\n if (i >= s.length - 1) {\n throw new Error(INVALID_UTF16);\n }\n i++; // \"eat\" next character\n result += 4;\n } else {\n throw new Error(INVALID_UTF16);\n }\n }\n return result;\n}\n\n/**\n * Decodes the given byte array from UTF-8 into a string.\n * Throws if encoding is invalid.\n */\nexport function decode(arr: Uint8Array): string {\n const chars: string[] = [];\n for (let i = 0; i < arr.length; i++) {\n let b = arr[i];\n\n if (b & 0x80) {\n let min;\n if (b < 0xe0) {\n // Need 1 more byte.\n if (i >= arr.length) {\n throw new Error(INVALID_UTF8);\n }\n const n1 = arr[++i];\n if ((n1 & 0xc0) !== 0x80) {\n throw new Error(INVALID_UTF8);\n }\n b = (b & 0x1f) << 6 | (n1 & 0x3f);\n min = 0x80;\n } else if (b < 0xf0) {\n // Need 2 more bytes.\n if (i >= arr.length - 1) {\n throw new Error(INVALID_UTF8);\n }\n const n1 = arr[++i];\n const n2 = arr[++i];\n if ((n1 & 0xc0) !== 0x80 || (n2 & 0xc0) !== 0x80) {\n throw new Error(INVALID_UTF8);\n }\n b = (b & 0x0f) << 12 | (n1 & 0x3f) << 6 | (n2 & 0x3f);\n min = 0x800;\n } else if (b < 0xf8) {\n // Need 3 more bytes.\n if (i >= arr.length - 2) {\n throw new Error(INVALID_UTF8);\n }\n const n1 = arr[++i];\n const n2 = arr[++i];\n const n3 = arr[++i];\n if ((n1 & 0xc0) !== 0x80 || (n2 & 0xc0) !== 0x80 || (n3 & 0xc0) !== 0x80) {\n throw new Error(INVALID_UTF8);\n }\n b = (b & 0x0f) << 18 | (n1 & 0x3f) << 12 | (n2 & 0x3f) << 6 | (n3 & 0x3f);\n min = 0x10000;\n } else {\n throw new Error(INVALID_UTF8);\n }\n\n if (b < min || (b >= 0xd800 && b <= 0xdfff)) {\n throw new Error(INVALID_UTF8);\n }\n\n if (b >= 0x10000) {\n // Surrogate pair.\n if (b > 0x10ffff) {\n throw new Error(INVALID_UTF8);\n }\n b -= 0x10000;\n chars.push(String.fromCharCode(0xd800 | (b >> 10)));\n b = 0xdc00 | (b & 0x3ff);\n }\n }\n\n chars.push(String.fromCharCode(b));\n }\n return chars.join(\"\");\n}\n","(function(nacl) {\n'use strict';\n\n// Ported in 2014 by Dmitry Chestnykh and Devi Mandiri.\n// Public domain.\n//\n// Implementation derived from TweetNaCl version 20140427.\n// See for details: http://tweetnacl.cr.yp.to/\n\nvar gf = function(init) {\n var i, r = new Float64Array(16);\n if (init) for (i = 0; i < init.length; i++) r[i] = init[i];\n return r;\n};\n\n// Pluggable, initialized in high-level API below.\nvar randombytes = function(/* x, n */) { throw new Error('no PRNG'); };\n\nvar _0 = new Uint8Array(16);\nvar _9 = new Uint8Array(32); _9[0] = 9;\n\nvar gf0 = gf(),\n gf1 = gf([1]),\n _121665 = gf([0xdb41, 1]),\n D = gf([0x78a3, 0x1359, 0x4dca, 0x75eb, 0xd8ab, 0x4141, 0x0a4d, 0x0070, 0xe898, 0x7779, 0x4079, 0x8cc7, 0xfe73, 0x2b6f, 0x6cee, 0x5203]),\n D2 = gf([0xf159, 0x26b2, 0x9b94, 0xebd6, 0xb156, 0x8283, 0x149a, 0x00e0, 0xd130, 0xeef3, 0x80f2, 0x198e, 0xfce7, 0x56df, 0xd9dc, 0x2406]),\n X = gf([0xd51a, 0x8f25, 0x2d60, 0xc956, 0xa7b2, 0x9525, 0xc760, 0x692c, 0xdc5c, 0xfdd6, 0xe231, 0xc0a4, 0x53fe, 0xcd6e, 0x36d3, 0x2169]),\n Y = gf([0x6658, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666]),\n I = gf([0xa0b0, 0x4a0e, 0x1b27, 0xc4ee, 0xe478, 0xad2f, 0x1806, 0x2f43, 0xd7a7, 0x3dfb, 0x0099, 0x2b4d, 0xdf0b, 0x4fc1, 0x2480, 0x2b83]);\n\nfunction ts64(x, i, h, l) {\n x[i] = (h >> 24) & 0xff;\n x[i+1] = (h >> 16) & 0xff;\n x[i+2] = (h >> 8) & 0xff;\n x[i+3] = h & 0xff;\n x[i+4] = (l >> 24) & 0xff;\n x[i+5] = (l >> 16) & 0xff;\n x[i+6] = (l >> 8) & 0xff;\n x[i+7] = l & 0xff;\n}\n\nfunction vn(x, xi, y, yi, n) {\n var i,d = 0;\n for (i = 0; i < n; i++) d |= x[xi+i]^y[yi+i];\n return (1 & ((d - 1) >>> 8)) - 1;\n}\n\nfunction crypto_verify_16(x, xi, y, yi) {\n return vn(x,xi,y,yi,16);\n}\n\nfunction crypto_verify_32(x, xi, y, yi) {\n return vn(x,xi,y,yi,32);\n}\n\nfunction core_salsa20(o, p, k, c) {\n var j0 = c[ 0] & 0xff | (c[ 1] & 0xff)<<8 | (c[ 2] & 0xff)<<16 | (c[ 3] & 0xff)<<24,\n j1 = k[ 0] & 0xff | (k[ 1] & 0xff)<<8 | (k[ 2] & 0xff)<<16 | (k[ 3] & 0xff)<<24,\n j2 = k[ 4] & 0xff | (k[ 5] & 0xff)<<8 | (k[ 6] & 0xff)<<16 | (k[ 7] & 0xff)<<24,\n j3 = k[ 8] & 0xff | (k[ 9] & 0xff)<<8 | (k[10] & 0xff)<<16 | (k[11] & 0xff)<<24,\n j4 = k[12] & 0xff | (k[13] & 0xff)<<8 | (k[14] & 0xff)<<16 | (k[15] & 0xff)<<24,\n j5 = c[ 4] & 0xff | (c[ 5] & 0xff)<<8 | (c[ 6] & 0xff)<<16 | (c[ 7] & 0xff)<<24,\n j6 = p[ 0] & 0xff | (p[ 1] & 0xff)<<8 | (p[ 2] & 0xff)<<16 | (p[ 3] & 0xff)<<24,\n j7 = p[ 4] & 0xff | (p[ 5] & 0xff)<<8 | (p[ 6] & 0xff)<<16 | (p[ 7] & 0xff)<<24,\n j8 = p[ 8] & 0xff | (p[ 9] & 0xff)<<8 | (p[10] & 0xff)<<16 | (p[11] & 0xff)<<24,\n j9 = p[12] & 0xff | (p[13] & 0xff)<<8 | (p[14] & 0xff)<<16 | (p[15] & 0xff)<<24,\n j10 = c[ 8] & 0xff | (c[ 9] & 0xff)<<8 | (c[10] & 0xff)<<16 | (c[11] & 0xff)<<24,\n j11 = k[16] & 0xff | (k[17] & 0xff)<<8 | (k[18] & 0xff)<<16 | (k[19] & 0xff)<<24,\n j12 = k[20] & 0xff | (k[21] & 0xff)<<8 | (k[22] & 0xff)<<16 | (k[23] & 0xff)<<24,\n j13 = k[24] & 0xff | (k[25] & 0xff)<<8 | (k[26] & 0xff)<<16 | (k[27] & 0xff)<<24,\n j14 = k[28] & 0xff | (k[29] & 0xff)<<8 | (k[30] & 0xff)<<16 | (k[31] & 0xff)<<24,\n j15 = c[12] & 0xff | (c[13] & 0xff)<<8 | (c[14] & 0xff)<<16 | (c[15] & 0xff)<<24;\n\n var x0 = j0, x1 = j1, x2 = j2, x3 = j3, x4 = j4, x5 = j5, x6 = j6, x7 = j7,\n x8 = j8, x9 = j9, x10 = j10, x11 = j11, x12 = j12, x13 = j13, x14 = j14,\n x15 = j15, u;\n\n for (var i = 0; i < 20; i += 2) {\n u = x0 + x12 | 0;\n x4 ^= u<<7 | u>>>(32-7);\n u = x4 + x0 | 0;\n x8 ^= u<<9 | u>>>(32-9);\n u = x8 + x4 | 0;\n x12 ^= u<<13 | u>>>(32-13);\n u = x12 + x8 | 0;\n x0 ^= u<<18 | u>>>(32-18);\n\n u = x5 + x1 | 0;\n x9 ^= u<<7 | u>>>(32-7);\n u = x9 + x5 | 0;\n x13 ^= u<<9 | u>>>(32-9);\n u = x13 + x9 | 0;\n x1 ^= u<<13 | u>>>(32-13);\n u = x1 + x13 | 0;\n x5 ^= u<<18 | u>>>(32-18);\n\n u = x10 + x6 | 0;\n x14 ^= u<<7 | u>>>(32-7);\n u = x14 + x10 | 0;\n x2 ^= u<<9 | u>>>(32-9);\n u = x2 + x14 | 0;\n x6 ^= u<<13 | u>>>(32-13);\n u = x6 + x2 | 0;\n x10 ^= u<<18 | u>>>(32-18);\n\n u = x15 + x11 | 0;\n x3 ^= u<<7 | u>>>(32-7);\n u = x3 + x15 | 0;\n x7 ^= u<<9 | u>>>(32-9);\n u = x7 + x3 | 0;\n x11 ^= u<<13 | u>>>(32-13);\n u = x11 + x7 | 0;\n x15 ^= u<<18 | u>>>(32-18);\n\n u = x0 + x3 | 0;\n x1 ^= u<<7 | u>>>(32-7);\n u = x1 + x0 | 0;\n x2 ^= u<<9 | u>>>(32-9);\n u = x2 + x1 | 0;\n x3 ^= u<<13 | u>>>(32-13);\n u = x3 + x2 | 0;\n x0 ^= u<<18 | u>>>(32-18);\n\n u = x5 + x4 | 0;\n x6 ^= u<<7 | u>>>(32-7);\n u = x6 + x5 | 0;\n x7 ^= u<<9 | u>>>(32-9);\n u = x7 + x6 | 0;\n x4 ^= u<<13 | u>>>(32-13);\n u = x4 + x7 | 0;\n x5 ^= u<<18 | u>>>(32-18);\n\n u = x10 + x9 | 0;\n x11 ^= u<<7 | u>>>(32-7);\n u = x11 + x10 | 0;\n x8 ^= u<<9 | u>>>(32-9);\n u = x8 + x11 | 0;\n x9 ^= u<<13 | u>>>(32-13);\n u = x9 + x8 | 0;\n x10 ^= u<<18 | u>>>(32-18);\n\n u = x15 + x14 | 0;\n x12 ^= u<<7 | u>>>(32-7);\n u = x12 + x15 | 0;\n x13 ^= u<<9 | u>>>(32-9);\n u = x13 + x12 | 0;\n x14 ^= u<<13 | u>>>(32-13);\n u = x14 + x13 | 0;\n x15 ^= u<<18 | u>>>(32-18);\n }\n x0 = x0 + j0 | 0;\n x1 = x1 + j1 | 0;\n x2 = x2 + j2 | 0;\n x3 = x3 + j3 | 0;\n x4 = x4 + j4 | 0;\n x5 = x5 + j5 | 0;\n x6 = x6 + j6 | 0;\n x7 = x7 + j7 | 0;\n x8 = x8 + j8 | 0;\n x9 = x9 + j9 | 0;\n x10 = x10 + j10 | 0;\n x11 = x11 + j11 | 0;\n x12 = x12 + j12 | 0;\n x13 = x13 + j13 | 0;\n x14 = x14 + j14 | 0;\n x15 = x15 + j15 | 0;\n\n o[ 0] = x0 >>> 0 & 0xff;\n o[ 1] = x0 >>> 8 & 0xff;\n o[ 2] = x0 >>> 16 & 0xff;\n o[ 3] = x0 >>> 24 & 0xff;\n\n o[ 4] = x1 >>> 0 & 0xff;\n o[ 5] = x1 >>> 8 & 0xff;\n o[ 6] = x1 >>> 16 & 0xff;\n o[ 7] = x1 >>> 24 & 0xff;\n\n o[ 8] = x2 >>> 0 & 0xff;\n o[ 9] = x2 >>> 8 & 0xff;\n o[10] = x2 >>> 16 & 0xff;\n o[11] = x2 >>> 24 & 0xff;\n\n o[12] = x3 >>> 0 & 0xff;\n o[13] = x3 >>> 8 & 0xff;\n o[14] = x3 >>> 16 & 0xff;\n o[15] = x3 >>> 24 & 0xff;\n\n o[16] = x4 >>> 0 & 0xff;\n o[17] = x4 >>> 8 & 0xff;\n o[18] = x4 >>> 16 & 0xff;\n o[19] = x4 >>> 24 & 0xff;\n\n o[20] = x5 >>> 0 & 0xff;\n o[21] = x5 >>> 8 & 0xff;\n o[22] = x5 >>> 16 & 0xff;\n o[23] = x5 >>> 24 & 0xff;\n\n o[24] = x6 >>> 0 & 0xff;\n o[25] = x6 >>> 8 & 0xff;\n o[26] = x6 >>> 16 & 0xff;\n o[27] = x6 >>> 24 & 0xff;\n\n o[28] = x7 >>> 0 & 0xff;\n o[29] = x7 >>> 8 & 0xff;\n o[30] = x7 >>> 16 & 0xff;\n o[31] = x7 >>> 24 & 0xff;\n\n o[32] = x8 >>> 0 & 0xff;\n o[33] = x8 >>> 8 & 0xff;\n o[34] = x8 >>> 16 & 0xff;\n o[35] = x8 >>> 24 & 0xff;\n\n o[36] = x9 >>> 0 & 0xff;\n o[37] = x9 >>> 8 & 0xff;\n o[38] = x9 >>> 16 & 0xff;\n o[39] = x9 >>> 24 & 0xff;\n\n o[40] = x10 >>> 0 & 0xff;\n o[41] = x10 >>> 8 & 0xff;\n o[42] = x10 >>> 16 & 0xff;\n o[43] = x10 >>> 24 & 0xff;\n\n o[44] = x11 >>> 0 & 0xff;\n o[45] = x11 >>> 8 & 0xff;\n o[46] = x11 >>> 16 & 0xff;\n o[47] = x11 >>> 24 & 0xff;\n\n o[48] = x12 >>> 0 & 0xff;\n o[49] = x12 >>> 8 & 0xff;\n o[50] = x12 >>> 16 & 0xff;\n o[51] = x12 >>> 24 & 0xff;\n\n o[52] = x13 >>> 0 & 0xff;\n o[53] = x13 >>> 8 & 0xff;\n o[54] = x13 >>> 16 & 0xff;\n o[55] = x13 >>> 24 & 0xff;\n\n o[56] = x14 >>> 0 & 0xff;\n o[57] = x14 >>> 8 & 0xff;\n o[58] = x14 >>> 16 & 0xff;\n o[59] = x14 >>> 24 & 0xff;\n\n o[60] = x15 >>> 0 & 0xff;\n o[61] = x15 >>> 8 & 0xff;\n o[62] = x15 >>> 16 & 0xff;\n o[63] = x15 >>> 24 & 0xff;\n}\n\nfunction core_hsalsa20(o,p,k,c) {\n var j0 = c[ 0] & 0xff | (c[ 1] & 0xff)<<8 | (c[ 2] & 0xff)<<16 | (c[ 3] & 0xff)<<24,\n j1 = k[ 0] & 0xff | (k[ 1] & 0xff)<<8 | (k[ 2] & 0xff)<<16 | (k[ 3] & 0xff)<<24,\n j2 = k[ 4] & 0xff | (k[ 5] & 0xff)<<8 | (k[ 6] & 0xff)<<16 | (k[ 7] & 0xff)<<24,\n j3 = k[ 8] & 0xff | (k[ 9] & 0xff)<<8 | (k[10] & 0xff)<<16 | (k[11] & 0xff)<<24,\n j4 = k[12] & 0xff | (k[13] & 0xff)<<8 | (k[14] & 0xff)<<16 | (k[15] & 0xff)<<24,\n j5 = c[ 4] & 0xff | (c[ 5] & 0xff)<<8 | (c[ 6] & 0xff)<<16 | (c[ 7] & 0xff)<<24,\n j6 = p[ 0] & 0xff | (p[ 1] & 0xff)<<8 | (p[ 2] & 0xff)<<16 | (p[ 3] & 0xff)<<24,\n j7 = p[ 4] & 0xff | (p[ 5] & 0xff)<<8 | (p[ 6] & 0xff)<<16 | (p[ 7] & 0xff)<<24,\n j8 = p[ 8] & 0xff | (p[ 9] & 0xff)<<8 | (p[10] & 0xff)<<16 | (p[11] & 0xff)<<24,\n j9 = p[12] & 0xff | (p[13] & 0xff)<<8 | (p[14] & 0xff)<<16 | (p[15] & 0xff)<<24,\n j10 = c[ 8] & 0xff | (c[ 9] & 0xff)<<8 | (c[10] & 0xff)<<16 | (c[11] & 0xff)<<24,\n j11 = k[16] & 0xff | (k[17] & 0xff)<<8 | (k[18] & 0xff)<<16 | (k[19] & 0xff)<<24,\n j12 = k[20] & 0xff | (k[21] & 0xff)<<8 | (k[22] & 0xff)<<16 | (k[23] & 0xff)<<24,\n j13 = k[24] & 0xff | (k[25] & 0xff)<<8 | (k[26] & 0xff)<<16 | (k[27] & 0xff)<<24,\n j14 = k[28] & 0xff | (k[29] & 0xff)<<8 | (k[30] & 0xff)<<16 | (k[31] & 0xff)<<24,\n j15 = c[12] & 0xff | (c[13] & 0xff)<<8 | (c[14] & 0xff)<<16 | (c[15] & 0xff)<<24;\n\n var x0 = j0, x1 = j1, x2 = j2, x3 = j3, x4 = j4, x5 = j5, x6 = j6, x7 = j7,\n x8 = j8, x9 = j9, x10 = j10, x11 = j11, x12 = j12, x13 = j13, x14 = j14,\n x15 = j15, u;\n\n for (var i = 0; i < 20; i += 2) {\n u = x0 + x12 | 0;\n x4 ^= u<<7 | u>>>(32-7);\n u = x4 + x0 | 0;\n x8 ^= u<<9 | u>>>(32-9);\n u = x8 + x4 | 0;\n x12 ^= u<<13 | u>>>(32-13);\n u = x12 + x8 | 0;\n x0 ^= u<<18 | u>>>(32-18);\n\n u = x5 + x1 | 0;\n x9 ^= u<<7 | u>>>(32-7);\n u = x9 + x5 | 0;\n x13 ^= u<<9 | u>>>(32-9);\n u = x13 + x9 | 0;\n x1 ^= u<<13 | u>>>(32-13);\n u = x1 + x13 | 0;\n x5 ^= u<<18 | u>>>(32-18);\n\n u = x10 + x6 | 0;\n x14 ^= u<<7 | u>>>(32-7);\n u = x14 + x10 | 0;\n x2 ^= u<<9 | u>>>(32-9);\n u = x2 + x14 | 0;\n x6 ^= u<<13 | u>>>(32-13);\n u = x6 + x2 | 0;\n x10 ^= u<<18 | u>>>(32-18);\n\n u = x15 + x11 | 0;\n x3 ^= u<<7 | u>>>(32-7);\n u = x3 + x15 | 0;\n x7 ^= u<<9 | u>>>(32-9);\n u = x7 + x3 | 0;\n x11 ^= u<<13 | u>>>(32-13);\n u = x11 + x7 | 0;\n x15 ^= u<<18 | u>>>(32-18);\n\n u = x0 + x3 | 0;\n x1 ^= u<<7 | u>>>(32-7);\n u = x1 + x0 | 0;\n x2 ^= u<<9 | u>>>(32-9);\n u = x2 + x1 | 0;\n x3 ^= u<<13 | u>>>(32-13);\n u = x3 + x2 | 0;\n x0 ^= u<<18 | u>>>(32-18);\n\n u = x5 + x4 | 0;\n x6 ^= u<<7 | u>>>(32-7);\n u = x6 + x5 | 0;\n x7 ^= u<<9 | u>>>(32-9);\n u = x7 + x6 | 0;\n x4 ^= u<<13 | u>>>(32-13);\n u = x4 + x7 | 0;\n x5 ^= u<<18 | u>>>(32-18);\n\n u = x10 + x9 | 0;\n x11 ^= u<<7 | u>>>(32-7);\n u = x11 + x10 | 0;\n x8 ^= u<<9 | u>>>(32-9);\n u = x8 + x11 | 0;\n x9 ^= u<<13 | u>>>(32-13);\n u = x9 + x8 | 0;\n x10 ^= u<<18 | u>>>(32-18);\n\n u = x15 + x14 | 0;\n x12 ^= u<<7 | u>>>(32-7);\n u = x12 + x15 | 0;\n x13 ^= u<<9 | u>>>(32-9);\n u = x13 + x12 | 0;\n x14 ^= u<<13 | u>>>(32-13);\n u = x14 + x13 | 0;\n x15 ^= u<<18 | u>>>(32-18);\n }\n\n o[ 0] = x0 >>> 0 & 0xff;\n o[ 1] = x0 >>> 8 & 0xff;\n o[ 2] = x0 >>> 16 & 0xff;\n o[ 3] = x0 >>> 24 & 0xff;\n\n o[ 4] = x5 >>> 0 & 0xff;\n o[ 5] = x5 >>> 8 & 0xff;\n o[ 6] = x5 >>> 16 & 0xff;\n o[ 7] = x5 >>> 24 & 0xff;\n\n o[ 8] = x10 >>> 0 & 0xff;\n o[ 9] = x10 >>> 8 & 0xff;\n o[10] = x10 >>> 16 & 0xff;\n o[11] = x10 >>> 24 & 0xff;\n\n o[12] = x15 >>> 0 & 0xff;\n o[13] = x15 >>> 8 & 0xff;\n o[14] = x15 >>> 16 & 0xff;\n o[15] = x15 >>> 24 & 0xff;\n\n o[16] = x6 >>> 0 & 0xff;\n o[17] = x6 >>> 8 & 0xff;\n o[18] = x6 >>> 16 & 0xff;\n o[19] = x6 >>> 24 & 0xff;\n\n o[20] = x7 >>> 0 & 0xff;\n o[21] = x7 >>> 8 & 0xff;\n o[22] = x7 >>> 16 & 0xff;\n o[23] = x7 >>> 24 & 0xff;\n\n o[24] = x8 >>> 0 & 0xff;\n o[25] = x8 >>> 8 & 0xff;\n o[26] = x8 >>> 16 & 0xff;\n o[27] = x8 >>> 24 & 0xff;\n\n o[28] = x9 >>> 0 & 0xff;\n o[29] = x9 >>> 8 & 0xff;\n o[30] = x9 >>> 16 & 0xff;\n o[31] = x9 >>> 24 & 0xff;\n}\n\nfunction crypto_core_salsa20(out,inp,k,c) {\n core_salsa20(out,inp,k,c);\n}\n\nfunction crypto_core_hsalsa20(out,inp,k,c) {\n core_hsalsa20(out,inp,k,c);\n}\n\nvar sigma = new Uint8Array([101, 120, 112, 97, 110, 100, 32, 51, 50, 45, 98, 121, 116, 101, 32, 107]);\n // \"expand 32-byte k\"\n\nfunction crypto_stream_salsa20_xor(c,cpos,m,mpos,b,n,k) {\n var z = new Uint8Array(16), x = new Uint8Array(64);\n var u, i;\n for (i = 0; i < 16; i++) z[i] = 0;\n for (i = 0; i < 8; i++) z[i] = n[i];\n while (b >= 64) {\n crypto_core_salsa20(x,z,k,sigma);\n for (i = 0; i < 64; i++) c[cpos+i] = m[mpos+i] ^ x[i];\n u = 1;\n for (i = 8; i < 16; i++) {\n u = u + (z[i] & 0xff) | 0;\n z[i] = u & 0xff;\n u >>>= 8;\n }\n b -= 64;\n cpos += 64;\n mpos += 64;\n }\n if (b > 0) {\n crypto_core_salsa20(x,z,k,sigma);\n for (i = 0; i < b; i++) c[cpos+i] = m[mpos+i] ^ x[i];\n }\n return 0;\n}\n\nfunction crypto_stream_salsa20(c,cpos,b,n,k) {\n var z = new Uint8Array(16), x = new Uint8Array(64);\n var u, i;\n for (i = 0; i < 16; i++) z[i] = 0;\n for (i = 0; i < 8; i++) z[i] = n[i];\n while (b >= 64) {\n crypto_core_salsa20(x,z,k,sigma);\n for (i = 0; i < 64; i++) c[cpos+i] = x[i];\n u = 1;\n for (i = 8; i < 16; i++) {\n u = u + (z[i] & 0xff) | 0;\n z[i] = u & 0xff;\n u >>>= 8;\n }\n b -= 64;\n cpos += 64;\n }\n if (b > 0) {\n crypto_core_salsa20(x,z,k,sigma);\n for (i = 0; i < b; i++) c[cpos+i] = x[i];\n }\n return 0;\n}\n\nfunction crypto_stream(c,cpos,d,n,k) {\n var s = new Uint8Array(32);\n crypto_core_hsalsa20(s,n,k,sigma);\n var sn = new Uint8Array(8);\n for (var i = 0; i < 8; i++) sn[i] = n[i+16];\n return crypto_stream_salsa20(c,cpos,d,sn,s);\n}\n\nfunction crypto_stream_xor(c,cpos,m,mpos,d,n,k) {\n var s = new Uint8Array(32);\n crypto_core_hsalsa20(s,n,k,sigma);\n var sn = new Uint8Array(8);\n for (var i = 0; i < 8; i++) sn[i] = n[i+16];\n return crypto_stream_salsa20_xor(c,cpos,m,mpos,d,sn,s);\n}\n\n/*\n* Port of Andrew Moon's Poly1305-donna-16. Public domain.\n* https://github.com/floodyberry/poly1305-donna\n*/\n\nvar poly1305 = function(key) {\n this.buffer = new Uint8Array(16);\n this.r = new Uint16Array(10);\n this.h = new Uint16Array(10);\n this.pad = new Uint16Array(8);\n this.leftover = 0;\n this.fin = 0;\n\n var t0, t1, t2, t3, t4, t5, t6, t7;\n\n t0 = key[ 0] & 0xff | (key[ 1] & 0xff) << 8; this.r[0] = ( t0 ) & 0x1fff;\n t1 = key[ 2] & 0xff | (key[ 3] & 0xff) << 8; this.r[1] = ((t0 >>> 13) | (t1 << 3)) & 0x1fff;\n t2 = key[ 4] & 0xff | (key[ 5] & 0xff) << 8; this.r[2] = ((t1 >>> 10) | (t2 << 6)) & 0x1f03;\n t3 = key[ 6] & 0xff | (key[ 7] & 0xff) << 8; this.r[3] = ((t2 >>> 7) | (t3 << 9)) & 0x1fff;\n t4 = key[ 8] & 0xff | (key[ 9] & 0xff) << 8; this.r[4] = ((t3 >>> 4) | (t4 << 12)) & 0x00ff;\n this.r[5] = ((t4 >>> 1)) & 0x1ffe;\n t5 = key[10] & 0xff | (key[11] & 0xff) << 8; this.r[6] = ((t4 >>> 14) | (t5 << 2)) & 0x1fff;\n t6 = key[12] & 0xff | (key[13] & 0xff) << 8; this.r[7] = ((t5 >>> 11) | (t6 << 5)) & 0x1f81;\n t7 = key[14] & 0xff | (key[15] & 0xff) << 8; this.r[8] = ((t6 >>> 8) | (t7 << 8)) & 0x1fff;\n this.r[9] = ((t7 >>> 5)) & 0x007f;\n\n this.pad[0] = key[16] & 0xff | (key[17] & 0xff) << 8;\n this.pad[1] = key[18] & 0xff | (key[19] & 0xff) << 8;\n this.pad[2] = key[20] & 0xff | (key[21] & 0xff) << 8;\n this.pad[3] = key[22] & 0xff | (key[23] & 0xff) << 8;\n this.pad[4] = key[24] & 0xff | (key[25] & 0xff) << 8;\n this.pad[5] = key[26] & 0xff | (key[27] & 0xff) << 8;\n this.pad[6] = key[28] & 0xff | (key[29] & 0xff) << 8;\n this.pad[7] = key[30] & 0xff | (key[31] & 0xff) << 8;\n};\n\npoly1305.prototype.blocks = function(m, mpos, bytes) {\n var hibit = this.fin ? 0 : (1 << 11);\n var t0, t1, t2, t3, t4, t5, t6, t7, c;\n var d0, d1, d2, d3, d4, d5, d6, d7, d8, d9;\n\n var h0 = this.h[0],\n h1 = this.h[1],\n h2 = this.h[2],\n h3 = this.h[3],\n h4 = this.h[4],\n h5 = this.h[5],\n h6 = this.h[6],\n h7 = this.h[7],\n h8 = this.h[8],\n h9 = this.h[9];\n\n var r0 = this.r[0],\n r1 = this.r[1],\n r2 = this.r[2],\n r3 = this.r[3],\n r4 = this.r[4],\n r5 = this.r[5],\n r6 = this.r[6],\n r7 = this.r[7],\n r8 = this.r[8],\n r9 = this.r[9];\n\n while (bytes >= 16) {\n t0 = m[mpos+ 0] & 0xff | (m[mpos+ 1] & 0xff) << 8; h0 += ( t0 ) & 0x1fff;\n t1 = m[mpos+ 2] & 0xff | (m[mpos+ 3] & 0xff) << 8; h1 += ((t0 >>> 13) | (t1 << 3)) & 0x1fff;\n t2 = m[mpos+ 4] & 0xff | (m[mpos+ 5] & 0xff) << 8; h2 += ((t1 >>> 10) | (t2 << 6)) & 0x1fff;\n t3 = m[mpos+ 6] & 0xff | (m[mpos+ 7] & 0xff) << 8; h3 += ((t2 >>> 7) | (t3 << 9)) & 0x1fff;\n t4 = m[mpos+ 8] & 0xff | (m[mpos+ 9] & 0xff) << 8; h4 += ((t3 >>> 4) | (t4 << 12)) & 0x1fff;\n h5 += ((t4 >>> 1)) & 0x1fff;\n t5 = m[mpos+10] & 0xff | (m[mpos+11] & 0xff) << 8; h6 += ((t4 >>> 14) | (t5 << 2)) & 0x1fff;\n t6 = m[mpos+12] & 0xff | (m[mpos+13] & 0xff) << 8; h7 += ((t5 >>> 11) | (t6 << 5)) & 0x1fff;\n t7 = m[mpos+14] & 0xff | (m[mpos+15] & 0xff) << 8; h8 += ((t6 >>> 8) | (t7 << 8)) & 0x1fff;\n h9 += ((t7 >>> 5)) | hibit;\n\n c = 0;\n\n d0 = c;\n d0 += h0 * r0;\n d0 += h1 * (5 * r9);\n d0 += h2 * (5 * r8);\n d0 += h3 * (5 * r7);\n d0 += h4 * (5 * r6);\n c = (d0 >>> 13); d0 &= 0x1fff;\n d0 += h5 * (5 * r5);\n d0 += h6 * (5 * r4);\n d0 += h7 * (5 * r3);\n d0 += h8 * (5 * r2);\n d0 += h9 * (5 * r1);\n c += (d0 >>> 13); d0 &= 0x1fff;\n\n d1 = c;\n d1 += h0 * r1;\n d1 += h1 * r0;\n d1 += h2 * (5 * r9);\n d1 += h3 * (5 * r8);\n d1 += h4 * (5 * r7);\n c = (d1 >>> 13); d1 &= 0x1fff;\n d1 += h5 * (5 * r6);\n d1 += h6 * (5 * r5);\n d1 += h7 * (5 * r4);\n d1 += h8 * (5 * r3);\n d1 += h9 * (5 * r2);\n c += (d1 >>> 13); d1 &= 0x1fff;\n\n d2 = c;\n d2 += h0 * r2;\n d2 += h1 * r1;\n d2 += h2 * r0;\n d2 += h3 * (5 * r9);\n d2 += h4 * (5 * r8);\n c = (d2 >>> 13); d2 &= 0x1fff;\n d2 += h5 * (5 * r7);\n d2 += h6 * (5 * r6);\n d2 += h7 * (5 * r5);\n d2 += h8 * (5 * r4);\n d2 += h9 * (5 * r3);\n c += (d2 >>> 13); d2 &= 0x1fff;\n\n d3 = c;\n d3 += h0 * r3;\n d3 += h1 * r2;\n d3 += h2 * r1;\n d3 += h3 * r0;\n d3 += h4 * (5 * r9);\n c = (d3 >>> 13); d3 &= 0x1fff;\n d3 += h5 * (5 * r8);\n d3 += h6 * (5 * r7);\n d3 += h7 * (5 * r6);\n d3 += h8 * (5 * r5);\n d3 += h9 * (5 * r4);\n c += (d3 >>> 13); d3 &= 0x1fff;\n\n d4 = c;\n d4 += h0 * r4;\n d4 += h1 * r3;\n d4 += h2 * r2;\n d4 += h3 * r1;\n d4 += h4 * r0;\n c = (d4 >>> 13); d4 &= 0x1fff;\n d4 += h5 * (5 * r9);\n d4 += h6 * (5 * r8);\n d4 += h7 * (5 * r7);\n d4 += h8 * (5 * r6);\n d4 += h9 * (5 * r5);\n c += (d4 >>> 13); d4 &= 0x1fff;\n\n d5 = c;\n d5 += h0 * r5;\n d5 += h1 * r4;\n d5 += h2 * r3;\n d5 += h3 * r2;\n d5 += h4 * r1;\n c = (d5 >>> 13); d5 &= 0x1fff;\n d5 += h5 * r0;\n d5 += h6 * (5 * r9);\n d5 += h7 * (5 * r8);\n d5 += h8 * (5 * r7);\n d5 += h9 * (5 * r6);\n c += (d5 >>> 13); d5 &= 0x1fff;\n\n d6 = c;\n d6 += h0 * r6;\n d6 += h1 * r5;\n d6 += h2 * r4;\n d6 += h3 * r3;\n d6 += h4 * r2;\n c = (d6 >>> 13); d6 &= 0x1fff;\n d6 += h5 * r1;\n d6 += h6 * r0;\n d6 += h7 * (5 * r9);\n d6 += h8 * (5 * r8);\n d6 += h9 * (5 * r7);\n c += (d6 >>> 13); d6 &= 0x1fff;\n\n d7 = c;\n d7 += h0 * r7;\n d7 += h1 * r6;\n d7 += h2 * r5;\n d7 += h3 * r4;\n d7 += h4 * r3;\n c = (d7 >>> 13); d7 &= 0x1fff;\n d7 += h5 * r2;\n d7 += h6 * r1;\n d7 += h7 * r0;\n d7 += h8 * (5 * r9);\n d7 += h9 * (5 * r8);\n c += (d7 >>> 13); d7 &= 0x1fff;\n\n d8 = c;\n d8 += h0 * r8;\n d8 += h1 * r7;\n d8 += h2 * r6;\n d8 += h3 * r5;\n d8 += h4 * r4;\n c = (d8 >>> 13); d8 &= 0x1fff;\n d8 += h5 * r3;\n d8 += h6 * r2;\n d8 += h7 * r1;\n d8 += h8 * r0;\n d8 += h9 * (5 * r9);\n c += (d8 >>> 13); d8 &= 0x1fff;\n\n d9 = c;\n d9 += h0 * r9;\n d9 += h1 * r8;\n d9 += h2 * r7;\n d9 += h3 * r6;\n d9 += h4 * r5;\n c = (d9 >>> 13); d9 &= 0x1fff;\n d9 += h5 * r4;\n d9 += h6 * r3;\n d9 += h7 * r2;\n d9 += h8 * r1;\n d9 += h9 * r0;\n c += (d9 >>> 13); d9 &= 0x1fff;\n\n c = (((c << 2) + c)) | 0;\n c = (c + d0) | 0;\n d0 = c & 0x1fff;\n c = (c >>> 13);\n d1 += c;\n\n h0 = d0;\n h1 = d1;\n h2 = d2;\n h3 = d3;\n h4 = d4;\n h5 = d5;\n h6 = d6;\n h7 = d7;\n h8 = d8;\n h9 = d9;\n\n mpos += 16;\n bytes -= 16;\n }\n this.h[0] = h0;\n this.h[1] = h1;\n this.h[2] = h2;\n this.h[3] = h3;\n this.h[4] = h4;\n this.h[5] = h5;\n this.h[6] = h6;\n this.h[7] = h7;\n this.h[8] = h8;\n this.h[9] = h9;\n};\n\npoly1305.prototype.finish = function(mac, macpos) {\n var g = new Uint16Array(10);\n var c, mask, f, i;\n\n if (this.leftover) {\n i = this.leftover;\n this.buffer[i++] = 1;\n for (; i < 16; i++) this.buffer[i] = 0;\n this.fin = 1;\n this.blocks(this.buffer, 0, 16);\n }\n\n c = this.h[1] >>> 13;\n this.h[1] &= 0x1fff;\n for (i = 2; i < 10; i++) {\n this.h[i] += c;\n c = this.h[i] >>> 13;\n this.h[i] &= 0x1fff;\n }\n this.h[0] += (c * 5);\n c = this.h[0] >>> 13;\n this.h[0] &= 0x1fff;\n this.h[1] += c;\n c = this.h[1] >>> 13;\n this.h[1] &= 0x1fff;\n this.h[2] += c;\n\n g[0] = this.h[0] + 5;\n c = g[0] >>> 13;\n g[0] &= 0x1fff;\n for (i = 1; i < 10; i++) {\n g[i] = this.h[i] + c;\n c = g[i] >>> 13;\n g[i] &= 0x1fff;\n }\n g[9] -= (1 << 13);\n\n mask = (c ^ 1) - 1;\n for (i = 0; i < 10; i++) g[i] &= mask;\n mask = ~mask;\n for (i = 0; i < 10; i++) this.h[i] = (this.h[i] & mask) | g[i];\n\n this.h[0] = ((this.h[0] ) | (this.h[1] << 13) ) & 0xffff;\n this.h[1] = ((this.h[1] >>> 3) | (this.h[2] << 10) ) & 0xffff;\n this.h[2] = ((this.h[2] >>> 6) | (this.h[3] << 7) ) & 0xffff;\n this.h[3] = ((this.h[3] >>> 9) | (this.h[4] << 4) ) & 0xffff;\n this.h[4] = ((this.h[4] >>> 12) | (this.h[5] << 1) | (this.h[6] << 14)) & 0xffff;\n this.h[5] = ((this.h[6] >>> 2) | (this.h[7] << 11) ) & 0xffff;\n this.h[6] = ((this.h[7] >>> 5) | (this.h[8] << 8) ) & 0xffff;\n this.h[7] = ((this.h[8] >>> 8) | (this.h[9] << 5) ) & 0xffff;\n\n f = this.h[0] + this.pad[0];\n this.h[0] = f & 0xffff;\n for (i = 1; i < 8; i++) {\n f = (((this.h[i] + this.pad[i]) | 0) + (f >>> 16)) | 0;\n this.h[i] = f & 0xffff;\n }\n\n mac[macpos+ 0] = (this.h[0] >>> 0) & 0xff;\n mac[macpos+ 1] = (this.h[0] >>> 8) & 0xff;\n mac[macpos+ 2] = (this.h[1] >>> 0) & 0xff;\n mac[macpos+ 3] = (this.h[1] >>> 8) & 0xff;\n mac[macpos+ 4] = (this.h[2] >>> 0) & 0xff;\n mac[macpos+ 5] = (this.h[2] >>> 8) & 0xff;\n mac[macpos+ 6] = (this.h[3] >>> 0) & 0xff;\n mac[macpos+ 7] = (this.h[3] >>> 8) & 0xff;\n mac[macpos+ 8] = (this.h[4] >>> 0) & 0xff;\n mac[macpos+ 9] = (this.h[4] >>> 8) & 0xff;\n mac[macpos+10] = (this.h[5] >>> 0) & 0xff;\n mac[macpos+11] = (this.h[5] >>> 8) & 0xff;\n mac[macpos+12] = (this.h[6] >>> 0) & 0xff;\n mac[macpos+13] = (this.h[6] >>> 8) & 0xff;\n mac[macpos+14] = (this.h[7] >>> 0) & 0xff;\n mac[macpos+15] = (this.h[7] >>> 8) & 0xff;\n};\n\npoly1305.prototype.update = function(m, mpos, bytes) {\n var i, want;\n\n if (this.leftover) {\n want = (16 - this.leftover);\n if (want > bytes)\n want = bytes;\n for (i = 0; i < want; i++)\n this.buffer[this.leftover + i] = m[mpos+i];\n bytes -= want;\n mpos += want;\n this.leftover += want;\n if (this.leftover < 16)\n return;\n this.blocks(this.buffer, 0, 16);\n this.leftover = 0;\n }\n\n if (bytes >= 16) {\n want = bytes - (bytes % 16);\n this.blocks(m, mpos, want);\n mpos += want;\n bytes -= want;\n }\n\n if (bytes) {\n for (i = 0; i < bytes; i++)\n this.buffer[this.leftover + i] = m[mpos+i];\n this.leftover += bytes;\n }\n};\n\nfunction crypto_onetimeauth(out, outpos, m, mpos, n, k) {\n var s = new poly1305(k);\n s.update(m, mpos, n);\n s.finish(out, outpos);\n return 0;\n}\n\nfunction crypto_onetimeauth_verify(h, hpos, m, mpos, n, k) {\n var x = new Uint8Array(16);\n crypto_onetimeauth(x,0,m,mpos,n,k);\n return crypto_verify_16(h,hpos,x,0);\n}\n\nfunction crypto_secretbox(c,m,d,n,k) {\n var i;\n if (d < 32) return -1;\n crypto_stream_xor(c,0,m,0,d,n,k);\n crypto_onetimeauth(c, 16, c, 32, d - 32, c);\n for (i = 0; i < 16; i++) c[i] = 0;\n return 0;\n}\n\nfunction crypto_secretbox_open(m,c,d,n,k) {\n var i;\n var x = new Uint8Array(32);\n if (d < 32) return -1;\n crypto_stream(x,0,32,n,k);\n if (crypto_onetimeauth_verify(c, 16,c, 32,d - 32,x) !== 0) return -1;\n crypto_stream_xor(m,0,c,0,d,n,k);\n for (i = 0; i < 32; i++) m[i] = 0;\n return 0;\n}\n\nfunction set25519(r, a) {\n var i;\n for (i = 0; i < 16; i++) r[i] = a[i]|0;\n}\n\nfunction car25519(o) {\n var i, v, c = 1;\n for (i = 0; i < 16; i++) {\n v = o[i] + c + 65535;\n c = Math.floor(v / 65536);\n o[i] = v - c * 65536;\n }\n o[0] += c-1 + 37 * (c-1);\n}\n\nfunction sel25519(p, q, b) {\n var t, c = ~(b-1);\n for (var i = 0; i < 16; i++) {\n t = c & (p[i] ^ q[i]);\n p[i] ^= t;\n q[i] ^= t;\n }\n}\n\nfunction pack25519(o, n) {\n var i, j, b;\n var m = gf(), t = gf();\n for (i = 0; i < 16; i++) t[i] = n[i];\n car25519(t);\n car25519(t);\n car25519(t);\n for (j = 0; j < 2; j++) {\n m[0] = t[0] - 0xffed;\n for (i = 1; i < 15; i++) {\n m[i] = t[i] - 0xffff - ((m[i-1]>>16) & 1);\n m[i-1] &= 0xffff;\n }\n m[15] = t[15] - 0x7fff - ((m[14]>>16) & 1);\n b = (m[15]>>16) & 1;\n m[14] &= 0xffff;\n sel25519(t, m, 1-b);\n }\n for (i = 0; i < 16; i++) {\n o[2*i] = t[i] & 0xff;\n o[2*i+1] = t[i]>>8;\n }\n}\n\nfunction neq25519(a, b) {\n var c = new Uint8Array(32), d = new Uint8Array(32);\n pack25519(c, a);\n pack25519(d, b);\n return crypto_verify_32(c, 0, d, 0);\n}\n\nfunction par25519(a) {\n var d = new Uint8Array(32);\n pack25519(d, a);\n return d[0] & 1;\n}\n\nfunction unpack25519(o, n) {\n var i;\n for (i = 0; i < 16; i++) o[i] = n[2*i] + (n[2*i+1] << 8);\n o[15] &= 0x7fff;\n}\n\nfunction A(o, a, b) {\n for (var i = 0; i < 16; i++) o[i] = a[i] + b[i];\n}\n\nfunction Z(o, a, b) {\n for (var i = 0; i < 16; i++) o[i] = a[i] - b[i];\n}\n\nfunction M(o, a, b) {\n var v, c,\n t0 = 0, t1 = 0, t2 = 0, t3 = 0, t4 = 0, t5 = 0, t6 = 0, t7 = 0,\n t8 = 0, t9 = 0, t10 = 0, t11 = 0, t12 = 0, t13 = 0, t14 = 0, t15 = 0,\n t16 = 0, t17 = 0, t18 = 0, t19 = 0, t20 = 0, t21 = 0, t22 = 0, t23 = 0,\n t24 = 0, t25 = 0, t26 = 0, t27 = 0, t28 = 0, t29 = 0, t30 = 0,\n b0 = b[0],\n b1 = b[1],\n b2 = b[2],\n b3 = b[3],\n b4 = b[4],\n b5 = b[5],\n b6 = b[6],\n b7 = b[7],\n b8 = b[8],\n b9 = b[9],\n b10 = b[10],\n b11 = b[11],\n b12 = b[12],\n b13 = b[13],\n b14 = b[14],\n b15 = b[15];\n\n v = a[0];\n t0 += v * b0;\n t1 += v * b1;\n t2 += v * b2;\n t3 += v * b3;\n t4 += v * b4;\n t5 += v * b5;\n t6 += v * b6;\n t7 += v * b7;\n t8 += v * b8;\n t9 += v * b9;\n t10 += v * b10;\n t11 += v * b11;\n t12 += v * b12;\n t13 += v * b13;\n t14 += v * b14;\n t15 += v * b15;\n v = a[1];\n t1 += v * b0;\n t2 += v * b1;\n t3 += v * b2;\n t4 += v * b3;\n t5 += v * b4;\n t6 += v * b5;\n t7 += v * b6;\n t8 += v * b7;\n t9 += v * b8;\n t10 += v * b9;\n t11 += v * b10;\n t12 += v * b11;\n t13 += v * b12;\n t14 += v * b13;\n t15 += v * b14;\n t16 += v * b15;\n v = a[2];\n t2 += v * b0;\n t3 += v * b1;\n t4 += v * b2;\n t5 += v * b3;\n t6 += v * b4;\n t7 += v * b5;\n t8 += v * b6;\n t9 += v * b7;\n t10 += v * b8;\n t11 += v * b9;\n t12 += v * b10;\n t13 += v * b11;\n t14 += v * b12;\n t15 += v * b13;\n t16 += v * b14;\n t17 += v * b15;\n v = a[3];\n t3 += v * b0;\n t4 += v * b1;\n t5 += v * b2;\n t6 += v * b3;\n t7 += v * b4;\n t8 += v * b5;\n t9 += v * b6;\n t10 += v * b7;\n t11 += v * b8;\n t12 += v * b9;\n t13 += v * b10;\n t14 += v * b11;\n t15 += v * b12;\n t16 += v * b13;\n t17 += v * b14;\n t18 += v * b15;\n v = a[4];\n t4 += v * b0;\n t5 += v * b1;\n t6 += v * b2;\n t7 += v * b3;\n t8 += v * b4;\n t9 += v * b5;\n t10 += v * b6;\n t11 += v * b7;\n t12 += v * b8;\n t13 += v * b9;\n t14 += v * b10;\n t15 += v * b11;\n t16 += v * b12;\n t17 += v * b13;\n t18 += v * b14;\n t19 += v * b15;\n v = a[5];\n t5 += v * b0;\n t6 += v * b1;\n t7 += v * b2;\n t8 += v * b3;\n t9 += v * b4;\n t10 += v * b5;\n t11 += v * b6;\n t12 += v * b7;\n t13 += v * b8;\n t14 += v * b9;\n t15 += v * b10;\n t16 += v * b11;\n t17 += v * b12;\n t18 += v * b13;\n t19 += v * b14;\n t20 += v * b15;\n v = a[6];\n t6 += v * b0;\n t7 += v * b1;\n t8 += v * b2;\n t9 += v * b3;\n t10 += v * b4;\n t11 += v * b5;\n t12 += v * b6;\n t13 += v * b7;\n t14 += v * b8;\n t15 += v * b9;\n t16 += v * b10;\n t17 += v * b11;\n t18 += v * b12;\n t19 += v * b13;\n t20 += v * b14;\n t21 += v * b15;\n v = a[7];\n t7 += v * b0;\n t8 += v * b1;\n t9 += v * b2;\n t10 += v * b3;\n t11 += v * b4;\n t12 += v * b5;\n t13 += v * b6;\n t14 += v * b7;\n t15 += v * b8;\n t16 += v * b9;\n t17 += v * b10;\n t18 += v * b11;\n t19 += v * b12;\n t20 += v * b13;\n t21 += v * b14;\n t22 += v * b15;\n v = a[8];\n t8 += v * b0;\n t9 += v * b1;\n t10 += v * b2;\n t11 += v * b3;\n t12 += v * b4;\n t13 += v * b5;\n t14 += v * b6;\n t15 += v * b7;\n t16 += v * b8;\n t17 += v * b9;\n t18 += v * b10;\n t19 += v * b11;\n t20 += v * b12;\n t21 += v * b13;\n t22 += v * b14;\n t23 += v * b15;\n v = a[9];\n t9 += v * b0;\n t10 += v * b1;\n t11 += v * b2;\n t12 += v * b3;\n t13 += v * b4;\n t14 += v * b5;\n t15 += v * b6;\n t16 += v * b7;\n t17 += v * b8;\n t18 += v * b9;\n t19 += v * b10;\n t20 += v * b11;\n t21 += v * b12;\n t22 += v * b13;\n t23 += v * b14;\n t24 += v * b15;\n v = a[10];\n t10 += v * b0;\n t11 += v * b1;\n t12 += v * b2;\n t13 += v * b3;\n t14 += v * b4;\n t15 += v * b5;\n t16 += v * b6;\n t17 += v * b7;\n t18 += v * b8;\n t19 += v * b9;\n t20 += v * b10;\n t21 += v * b11;\n t22 += v * b12;\n t23 += v * b13;\n t24 += v * b14;\n t25 += v * b15;\n v = a[11];\n t11 += v * b0;\n t12 += v * b1;\n t13 += v * b2;\n t14 += v * b3;\n t15 += v * b4;\n t16 += v * b5;\n t17 += v * b6;\n t18 += v * b7;\n t19 += v * b8;\n t20 += v * b9;\n t21 += v * b10;\n t22 += v * b11;\n t23 += v * b12;\n t24 += v * b13;\n t25 += v * b14;\n t26 += v * b15;\n v = a[12];\n t12 += v * b0;\n t13 += v * b1;\n t14 += v * b2;\n t15 += v * b3;\n t16 += v * b4;\n t17 += v * b5;\n t18 += v * b6;\n t19 += v * b7;\n t20 += v * b8;\n t21 += v * b9;\n t22 += v * b10;\n t23 += v * b11;\n t24 += v * b12;\n t25 += v * b13;\n t26 += v * b14;\n t27 += v * b15;\n v = a[13];\n t13 += v * b0;\n t14 += v * b1;\n t15 += v * b2;\n t16 += v * b3;\n t17 += v * b4;\n t18 += v * b5;\n t19 += v * b6;\n t20 += v * b7;\n t21 += v * b8;\n t22 += v * b9;\n t23 += v * b10;\n t24 += v * b11;\n t25 += v * b12;\n t26 += v * b13;\n t27 += v * b14;\n t28 += v * b15;\n v = a[14];\n t14 += v * b0;\n t15 += v * b1;\n t16 += v * b2;\n t17 += v * b3;\n t18 += v * b4;\n t19 += v * b5;\n t20 += v * b6;\n t21 += v * b7;\n t22 += v * b8;\n t23 += v * b9;\n t24 += v * b10;\n t25 += v * b11;\n t26 += v * b12;\n t27 += v * b13;\n t28 += v * b14;\n t29 += v * b15;\n v = a[15];\n t15 += v * b0;\n t16 += v * b1;\n t17 += v * b2;\n t18 += v * b3;\n t19 += v * b4;\n t20 += v * b5;\n t21 += v * b6;\n t22 += v * b7;\n t23 += v * b8;\n t24 += v * b9;\n t25 += v * b10;\n t26 += v * b11;\n t27 += v * b12;\n t28 += v * b13;\n t29 += v * b14;\n t30 += v * b15;\n\n t0 += 38 * t16;\n t1 += 38 * t17;\n t2 += 38 * t18;\n t3 += 38 * t19;\n t4 += 38 * t20;\n t5 += 38 * t21;\n t6 += 38 * t22;\n t7 += 38 * t23;\n t8 += 38 * t24;\n t9 += 38 * t25;\n t10 += 38 * t26;\n t11 += 38 * t27;\n t12 += 38 * t28;\n t13 += 38 * t29;\n t14 += 38 * t30;\n // t15 left as is\n\n // first car\n c = 1;\n v = t0 + c + 65535; c = Math.floor(v / 65536); t0 = v - c * 65536;\n v = t1 + c + 65535; c = Math.floor(v / 65536); t1 = v - c * 65536;\n v = t2 + c + 65535; c = Math.floor(v / 65536); t2 = v - c * 65536;\n v = t3 + c + 65535; c = Math.floor(v / 65536); t3 = v - c * 65536;\n v = t4 + c + 65535; c = Math.floor(v / 65536); t4 = v - c * 65536;\n v = t5 + c + 65535; c = Math.floor(v / 65536); t5 = v - c * 65536;\n v = t6 + c + 65535; c = Math.floor(v / 65536); t6 = v - c * 65536;\n v = t7 + c + 65535; c = Math.floor(v / 65536); t7 = v - c * 65536;\n v = t8 + c + 65535; c = Math.floor(v / 65536); t8 = v - c * 65536;\n v = t9 + c + 65535; c = Math.floor(v / 65536); t9 = v - c * 65536;\n v = t10 + c + 65535; c = Math.floor(v / 65536); t10 = v - c * 65536;\n v = t11 + c + 65535; c = Math.floor(v / 65536); t11 = v - c * 65536;\n v = t12 + c + 65535; c = Math.floor(v / 65536); t12 = v - c * 65536;\n v = t13 + c + 65535; c = Math.floor(v / 65536); t13 = v - c * 65536;\n v = t14 + c + 65535; c = Math.floor(v / 65536); t14 = v - c * 65536;\n v = t15 + c + 65535; c = Math.floor(v / 65536); t15 = v - c * 65536;\n t0 += c-1 + 37 * (c-1);\n\n // second car\n c = 1;\n v = t0 + c + 65535; c = Math.floor(v / 65536); t0 = v - c * 65536;\n v = t1 + c + 65535; c = Math.floor(v / 65536); t1 = v - c * 65536;\n v = t2 + c + 65535; c = Math.floor(v / 65536); t2 = v - c * 65536;\n v = t3 + c + 65535; c = Math.floor(v / 65536); t3 = v - c * 65536;\n v = t4 + c + 65535; c = Math.floor(v / 65536); t4 = v - c * 65536;\n v = t5 + c + 65535; c = Math.floor(v / 65536); t5 = v - c * 65536;\n v = t6 + c + 65535; c = Math.floor(v / 65536); t6 = v - c * 65536;\n v = t7 + c + 65535; c = Math.floor(v / 65536); t7 = v - c * 65536;\n v = t8 + c + 65535; c = Math.floor(v / 65536); t8 = v - c * 65536;\n v = t9 + c + 65535; c = Math.floor(v / 65536); t9 = v - c * 65536;\n v = t10 + c + 65535; c = Math.floor(v / 65536); t10 = v - c * 65536;\n v = t11 + c + 65535; c = Math.floor(v / 65536); t11 = v - c * 65536;\n v = t12 + c + 65535; c = Math.floor(v / 65536); t12 = v - c * 65536;\n v = t13 + c + 65535; c = Math.floor(v / 65536); t13 = v - c * 65536;\n v = t14 + c + 65535; c = Math.floor(v / 65536); t14 = v - c * 65536;\n v = t15 + c + 65535; c = Math.floor(v / 65536); t15 = v - c * 65536;\n t0 += c-1 + 37 * (c-1);\n\n o[ 0] = t0;\n o[ 1] = t1;\n o[ 2] = t2;\n o[ 3] = t3;\n o[ 4] = t4;\n o[ 5] = t5;\n o[ 6] = t6;\n o[ 7] = t7;\n o[ 8] = t8;\n o[ 9] = t9;\n o[10] = t10;\n o[11] = t11;\n o[12] = t12;\n o[13] = t13;\n o[14] = t14;\n o[15] = t15;\n}\n\nfunction S(o, a) {\n M(o, a, a);\n}\n\nfunction inv25519(o, i) {\n var c = gf();\n var a;\n for (a = 0; a < 16; a++) c[a] = i[a];\n for (a = 253; a >= 0; a--) {\n S(c, c);\n if(a !== 2 && a !== 4) M(c, c, i);\n }\n for (a = 0; a < 16; a++) o[a] = c[a];\n}\n\nfunction pow2523(o, i) {\n var c = gf();\n var a;\n for (a = 0; a < 16; a++) c[a] = i[a];\n for (a = 250; a >= 0; a--) {\n S(c, c);\n if(a !== 1) M(c, c, i);\n }\n for (a = 0; a < 16; a++) o[a] = c[a];\n}\n\nfunction crypto_scalarmult(q, n, p) {\n var z = new Uint8Array(32);\n var x = new Float64Array(80), r, i;\n var a = gf(), b = gf(), c = gf(),\n d = gf(), e = gf(), f = gf();\n for (i = 0; i < 31; i++) z[i] = n[i];\n z[31]=(n[31]&127)|64;\n z[0]&=248;\n unpack25519(x,p);\n for (i = 0; i < 16; i++) {\n b[i]=x[i];\n d[i]=a[i]=c[i]=0;\n }\n a[0]=d[0]=1;\n for (i=254; i>=0; --i) {\n r=(z[i>>>3]>>>(i&7))&1;\n sel25519(a,b,r);\n sel25519(c,d,r);\n A(e,a,c);\n Z(a,a,c);\n A(c,b,d);\n Z(b,b,d);\n S(d,e);\n S(f,a);\n M(a,c,a);\n M(c,b,e);\n A(e,a,c);\n Z(a,a,c);\n S(b,a);\n Z(c,d,f);\n M(a,c,_121665);\n A(a,a,d);\n M(c,c,a);\n M(a,d,f);\n M(d,b,x);\n S(b,e);\n sel25519(a,b,r);\n sel25519(c,d,r);\n }\n for (i = 0; i < 16; i++) {\n x[i+16]=a[i];\n x[i+32]=c[i];\n x[i+48]=b[i];\n x[i+64]=d[i];\n }\n var x32 = x.subarray(32);\n var x16 = x.subarray(16);\n inv25519(x32,x32);\n M(x16,x16,x32);\n pack25519(q,x16);\n return 0;\n}\n\nfunction crypto_scalarmult_base(q, n) {\n return crypto_scalarmult(q, n, _9);\n}\n\nfunction crypto_box_keypair(y, x) {\n randombytes(x, 32);\n return crypto_scalarmult_base(y, x);\n}\n\nfunction crypto_box_beforenm(k, y, x) {\n var s = new Uint8Array(32);\n crypto_scalarmult(s, x, y);\n return crypto_core_hsalsa20(k, _0, s, sigma);\n}\n\nvar crypto_box_afternm = crypto_secretbox;\nvar crypto_box_open_afternm = crypto_secretbox_open;\n\nfunction crypto_box(c, m, d, n, y, x) {\n var k = new Uint8Array(32);\n crypto_box_beforenm(k, y, x);\n return crypto_box_afternm(c, m, d, n, k);\n}\n\nfunction crypto_box_open(m, c, d, n, y, x) {\n var k = new Uint8Array(32);\n crypto_box_beforenm(k, y, x);\n return crypto_box_open_afternm(m, c, d, n, k);\n}\n\nvar K = [\n 0x428a2f98, 0xd728ae22, 0x71374491, 0x23ef65cd,\n 0xb5c0fbcf, 0xec4d3b2f, 0xe9b5dba5, 0x8189dbbc,\n 0x3956c25b, 0xf348b538, 0x59f111f1, 0xb605d019,\n 0x923f82a4, 0xaf194f9b, 0xab1c5ed5, 0xda6d8118,\n 0xd807aa98, 0xa3030242, 0x12835b01, 0x45706fbe,\n 0x243185be, 0x4ee4b28c, 0x550c7dc3, 0xd5ffb4e2,\n 0x72be5d74, 0xf27b896f, 0x80deb1fe, 0x3b1696b1,\n 0x9bdc06a7, 0x25c71235, 0xc19bf174, 0xcf692694,\n 0xe49b69c1, 0x9ef14ad2, 0xefbe4786, 0x384f25e3,\n 0x0fc19dc6, 0x8b8cd5b5, 0x240ca1cc, 0x77ac9c65,\n 0x2de92c6f, 0x592b0275, 0x4a7484aa, 0x6ea6e483,\n 0x5cb0a9dc, 0xbd41fbd4, 0x76f988da, 0x831153b5,\n 0x983e5152, 0xee66dfab, 0xa831c66d, 0x2db43210,\n 0xb00327c8, 0x98fb213f, 0xbf597fc7, 0xbeef0ee4,\n 0xc6e00bf3, 0x3da88fc2, 0xd5a79147, 0x930aa725,\n 0x06ca6351, 0xe003826f, 0x14292967, 0x0a0e6e70,\n 0x27b70a85, 0x46d22ffc, 0x2e1b2138, 0x5c26c926,\n 0x4d2c6dfc, 0x5ac42aed, 0x53380d13, 0x9d95b3df,\n 0x650a7354, 0x8baf63de, 0x766a0abb, 0x3c77b2a8,\n 0x81c2c92e, 0x47edaee6, 0x92722c85, 0x1482353b,\n 0xa2bfe8a1, 0x4cf10364, 0xa81a664b, 0xbc423001,\n 0xc24b8b70, 0xd0f89791, 0xc76c51a3, 0x0654be30,\n 0xd192e819, 0xd6ef5218, 0xd6990624, 0x5565a910,\n 0xf40e3585, 0x5771202a, 0x106aa070, 0x32bbd1b8,\n 0x19a4c116, 0xb8d2d0c8, 0x1e376c08, 0x5141ab53,\n 0x2748774c, 0xdf8eeb99, 0x34b0bcb5, 0xe19b48a8,\n 0x391c0cb3, 0xc5c95a63, 0x4ed8aa4a, 0xe3418acb,\n 0x5b9cca4f, 0x7763e373, 0x682e6ff3, 0xd6b2b8a3,\n 0x748f82ee, 0x5defb2fc, 0x78a5636f, 0x43172f60,\n 0x84c87814, 0xa1f0ab72, 0x8cc70208, 0x1a6439ec,\n 0x90befffa, 0x23631e28, 0xa4506ceb, 0xde82bde9,\n 0xbef9a3f7, 0xb2c67915, 0xc67178f2, 0xe372532b,\n 0xca273ece, 0xea26619c, 0xd186b8c7, 0x21c0c207,\n 0xeada7dd6, 0xcde0eb1e, 0xf57d4f7f, 0xee6ed178,\n 0x06f067aa, 0x72176fba, 0x0a637dc5, 0xa2c898a6,\n 0x113f9804, 0xbef90dae, 0x1b710b35, 0x131c471b,\n 0x28db77f5, 0x23047d84, 0x32caab7b, 0x40c72493,\n 0x3c9ebe0a, 0x15c9bebc, 0x431d67c4, 0x9c100d4c,\n 0x4cc5d4be, 0xcb3e42b6, 0x597f299c, 0xfc657e2a,\n 0x5fcb6fab, 0x3ad6faec, 0x6c44198c, 0x4a475817\n];\n\nfunction crypto_hashblocks_hl(hh, hl, m, n) {\n var wh = new Int32Array(16), wl = new Int32Array(16),\n bh0, bh1, bh2, bh3, bh4, bh5, bh6, bh7,\n bl0, bl1, bl2, bl3, bl4, bl5, bl6, bl7,\n th, tl, i, j, h, l, a, b, c, d;\n\n var ah0 = hh[0],\n ah1 = hh[1],\n ah2 = hh[2],\n ah3 = hh[3],\n ah4 = hh[4],\n ah5 = hh[5],\n ah6 = hh[6],\n ah7 = hh[7],\n\n al0 = hl[0],\n al1 = hl[1],\n al2 = hl[2],\n al3 = hl[3],\n al4 = hl[4],\n al5 = hl[5],\n al6 = hl[6],\n al7 = hl[7];\n\n var pos = 0;\n while (n >= 128) {\n for (i = 0; i < 16; i++) {\n j = 8 * i + pos;\n wh[i] = (m[j+0] << 24) | (m[j+1] << 16) | (m[j+2] << 8) | m[j+3];\n wl[i] = (m[j+4] << 24) | (m[j+5] << 16) | (m[j+6] << 8) | m[j+7];\n }\n for (i = 0; i < 80; i++) {\n bh0 = ah0;\n bh1 = ah1;\n bh2 = ah2;\n bh3 = ah3;\n bh4 = ah4;\n bh5 = ah5;\n bh6 = ah6;\n bh7 = ah7;\n\n bl0 = al0;\n bl1 = al1;\n bl2 = al2;\n bl3 = al3;\n bl4 = al4;\n bl5 = al5;\n bl6 = al6;\n bl7 = al7;\n\n // add\n h = ah7;\n l = al7;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n // Sigma1\n h = ((ah4 >>> 14) | (al4 << (32-14))) ^ ((ah4 >>> 18) | (al4 << (32-18))) ^ ((al4 >>> (41-32)) | (ah4 << (32-(41-32))));\n l = ((al4 >>> 14) | (ah4 << (32-14))) ^ ((al4 >>> 18) | (ah4 << (32-18))) ^ ((ah4 >>> (41-32)) | (al4 << (32-(41-32))));\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // Ch\n h = (ah4 & ah5) ^ (~ah4 & ah6);\n l = (al4 & al5) ^ (~al4 & al6);\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // K\n h = K[i*2];\n l = K[i*2+1];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // w\n h = wh[i%16];\n l = wl[i%16];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n th = c & 0xffff | d << 16;\n tl = a & 0xffff | b << 16;\n\n // add\n h = th;\n l = tl;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n // Sigma0\n h = ((ah0 >>> 28) | (al0 << (32-28))) ^ ((al0 >>> (34-32)) | (ah0 << (32-(34-32)))) ^ ((al0 >>> (39-32)) | (ah0 << (32-(39-32))));\n l = ((al0 >>> 28) | (ah0 << (32-28))) ^ ((ah0 >>> (34-32)) | (al0 << (32-(34-32)))) ^ ((ah0 >>> (39-32)) | (al0 << (32-(39-32))));\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // Maj\n h = (ah0 & ah1) ^ (ah0 & ah2) ^ (ah1 & ah2);\n l = (al0 & al1) ^ (al0 & al2) ^ (al1 & al2);\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n bh7 = (c & 0xffff) | (d << 16);\n bl7 = (a & 0xffff) | (b << 16);\n\n // add\n h = bh3;\n l = bl3;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = th;\n l = tl;\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n bh3 = (c & 0xffff) | (d << 16);\n bl3 = (a & 0xffff) | (b << 16);\n\n ah1 = bh0;\n ah2 = bh1;\n ah3 = bh2;\n ah4 = bh3;\n ah5 = bh4;\n ah6 = bh5;\n ah7 = bh6;\n ah0 = bh7;\n\n al1 = bl0;\n al2 = bl1;\n al3 = bl2;\n al4 = bl3;\n al5 = bl4;\n al6 = bl5;\n al7 = bl6;\n al0 = bl7;\n\n if (i%16 === 15) {\n for (j = 0; j < 16; j++) {\n // add\n h = wh[j];\n l = wl[j];\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = wh[(j+9)%16];\n l = wl[(j+9)%16];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // sigma0\n th = wh[(j+1)%16];\n tl = wl[(j+1)%16];\n h = ((th >>> 1) | (tl << (32-1))) ^ ((th >>> 8) | (tl << (32-8))) ^ (th >>> 7);\n l = ((tl >>> 1) | (th << (32-1))) ^ ((tl >>> 8) | (th << (32-8))) ^ ((tl >>> 7) | (th << (32-7)));\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // sigma1\n th = wh[(j+14)%16];\n tl = wl[(j+14)%16];\n h = ((th >>> 19) | (tl << (32-19))) ^ ((tl >>> (61-32)) | (th << (32-(61-32)))) ^ (th >>> 6);\n l = ((tl >>> 19) | (th << (32-19))) ^ ((th >>> (61-32)) | (tl << (32-(61-32)))) ^ ((tl >>> 6) | (th << (32-6)));\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n wh[j] = (c & 0xffff) | (d << 16);\n wl[j] = (a & 0xffff) | (b << 16);\n }\n }\n }\n\n // add\n h = ah0;\n l = al0;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[0];\n l = hl[0];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[0] = ah0 = (c & 0xffff) | (d << 16);\n hl[0] = al0 = (a & 0xffff) | (b << 16);\n\n h = ah1;\n l = al1;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[1];\n l = hl[1];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[1] = ah1 = (c & 0xffff) | (d << 16);\n hl[1] = al1 = (a & 0xffff) | (b << 16);\n\n h = ah2;\n l = al2;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[2];\n l = hl[2];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[2] = ah2 = (c & 0xffff) | (d << 16);\n hl[2] = al2 = (a & 0xffff) | (b << 16);\n\n h = ah3;\n l = al3;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[3];\n l = hl[3];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[3] = ah3 = (c & 0xffff) | (d << 16);\n hl[3] = al3 = (a & 0xffff) | (b << 16);\n\n h = ah4;\n l = al4;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[4];\n l = hl[4];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[4] = ah4 = (c & 0xffff) | (d << 16);\n hl[4] = al4 = (a & 0xffff) | (b << 16);\n\n h = ah5;\n l = al5;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[5];\n l = hl[5];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[5] = ah5 = (c & 0xffff) | (d << 16);\n hl[5] = al5 = (a & 0xffff) | (b << 16);\n\n h = ah6;\n l = al6;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[6];\n l = hl[6];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[6] = ah6 = (c & 0xffff) | (d << 16);\n hl[6] = al6 = (a & 0xffff) | (b << 16);\n\n h = ah7;\n l = al7;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[7];\n l = hl[7];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[7] = ah7 = (c & 0xffff) | (d << 16);\n hl[7] = al7 = (a & 0xffff) | (b << 16);\n\n pos += 128;\n n -= 128;\n }\n\n return n;\n}\n\nfunction crypto_hash(out, m, n) {\n var hh = new Int32Array(8),\n hl = new Int32Array(8),\n x = new Uint8Array(256),\n i, b = n;\n\n hh[0] = 0x6a09e667;\n hh[1] = 0xbb67ae85;\n hh[2] = 0x3c6ef372;\n hh[3] = 0xa54ff53a;\n hh[4] = 0x510e527f;\n hh[5] = 0x9b05688c;\n hh[6] = 0x1f83d9ab;\n hh[7] = 0x5be0cd19;\n\n hl[0] = 0xf3bcc908;\n hl[1] = 0x84caa73b;\n hl[2] = 0xfe94f82b;\n hl[3] = 0x5f1d36f1;\n hl[4] = 0xade682d1;\n hl[5] = 0x2b3e6c1f;\n hl[6] = 0xfb41bd6b;\n hl[7] = 0x137e2179;\n\n crypto_hashblocks_hl(hh, hl, m, n);\n n %= 128;\n\n for (i = 0; i < n; i++) x[i] = m[b-n+i];\n x[n] = 128;\n\n n = 256-128*(n<112?1:0);\n x[n-9] = 0;\n ts64(x, n-8, (b / 0x20000000) | 0, b << 3);\n crypto_hashblocks_hl(hh, hl, x, n);\n\n for (i = 0; i < 8; i++) ts64(out, 8*i, hh[i], hl[i]);\n\n return 0;\n}\n\nfunction add(p, q) {\n var a = gf(), b = gf(), c = gf(),\n d = gf(), e = gf(), f = gf(),\n g = gf(), h = gf(), t = gf();\n\n Z(a, p[1], p[0]);\n Z(t, q[1], q[0]);\n M(a, a, t);\n A(b, p[0], p[1]);\n A(t, q[0], q[1]);\n M(b, b, t);\n M(c, p[3], q[3]);\n M(c, c, D2);\n M(d, p[2], q[2]);\n A(d, d, d);\n Z(e, b, a);\n Z(f, d, c);\n A(g, d, c);\n A(h, b, a);\n\n M(p[0], e, f);\n M(p[1], h, g);\n M(p[2], g, f);\n M(p[3], e, h);\n}\n\nfunction cswap(p, q, b) {\n var i;\n for (i = 0; i < 4; i++) {\n sel25519(p[i], q[i], b);\n }\n}\n\nfunction pack(r, p) {\n var tx = gf(), ty = gf(), zi = gf();\n inv25519(zi, p[2]);\n M(tx, p[0], zi);\n M(ty, p[1], zi);\n pack25519(r, ty);\n r[31] ^= par25519(tx) << 7;\n}\n\nfunction scalarmult(p, q, s) {\n var b, i;\n set25519(p[0], gf0);\n set25519(p[1], gf1);\n set25519(p[2], gf1);\n set25519(p[3], gf0);\n for (i = 255; i >= 0; --i) {\n b = (s[(i/8)|0] >> (i&7)) & 1;\n cswap(p, q, b);\n add(q, p);\n add(p, p);\n cswap(p, q, b);\n }\n}\n\nfunction scalarbase(p, s) {\n var q = [gf(), gf(), gf(), gf()];\n set25519(q[0], X);\n set25519(q[1], Y);\n set25519(q[2], gf1);\n M(q[3], X, Y);\n scalarmult(p, q, s);\n}\n\nfunction crypto_sign_keypair(pk, sk, seeded) {\n var d = new Uint8Array(64);\n var p = [gf(), gf(), gf(), gf()];\n var i;\n\n if (!seeded) randombytes(sk, 32);\n crypto_hash(d, sk, 32);\n d[0] &= 248;\n d[31] &= 127;\n d[31] |= 64;\n\n scalarbase(p, d);\n pack(pk, p);\n\n for (i = 0; i < 32; i++) sk[i+32] = pk[i];\n return 0;\n}\n\nvar L = new Float64Array([0xed, 0xd3, 0xf5, 0x5c, 0x1a, 0x63, 0x12, 0x58, 0xd6, 0x9c, 0xf7, 0xa2, 0xde, 0xf9, 0xde, 0x14, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x10]);\n\nfunction modL(r, x) {\n var carry, i, j, k;\n for (i = 63; i >= 32; --i) {\n carry = 0;\n for (j = i - 32, k = i - 12; j < k; ++j) {\n x[j] += carry - 16 * x[i] * L[j - (i - 32)];\n carry = Math.floor((x[j] + 128) / 256);\n x[j] -= carry * 256;\n }\n x[j] += carry;\n x[i] = 0;\n }\n carry = 0;\n for (j = 0; j < 32; j++) {\n x[j] += carry - (x[31] >> 4) * L[j];\n carry = x[j] >> 8;\n x[j] &= 255;\n }\n for (j = 0; j < 32; j++) x[j] -= carry * L[j];\n for (i = 0; i < 32; i++) {\n x[i+1] += x[i] >> 8;\n r[i] = x[i] & 255;\n }\n}\n\nfunction reduce(r) {\n var x = new Float64Array(64), i;\n for (i = 0; i < 64; i++) x[i] = r[i];\n for (i = 0; i < 64; i++) r[i] = 0;\n modL(r, x);\n}\n\n// Note: difference from C - smlen returned, not passed as argument.\nfunction crypto_sign(sm, m, n, sk) {\n var d = new Uint8Array(64), h = new Uint8Array(64), r = new Uint8Array(64);\n var i, j, x = new Float64Array(64);\n var p = [gf(), gf(), gf(), gf()];\n\n crypto_hash(d, sk, 32);\n d[0] &= 248;\n d[31] &= 127;\n d[31] |= 64;\n\n var smlen = n + 64;\n for (i = 0; i < n; i++) sm[64 + i] = m[i];\n for (i = 0; i < 32; i++) sm[32 + i] = d[32 + i];\n\n crypto_hash(r, sm.subarray(32), n+32);\n reduce(r);\n scalarbase(p, r);\n pack(sm, p);\n\n for (i = 32; i < 64; i++) sm[i] = sk[i];\n crypto_hash(h, sm, n + 64);\n reduce(h);\n\n for (i = 0; i < 64; i++) x[i] = 0;\n for (i = 0; i < 32; i++) x[i] = r[i];\n for (i = 0; i < 32; i++) {\n for (j = 0; j < 32; j++) {\n x[i+j] += h[i] * d[j];\n }\n }\n\n modL(sm.subarray(32), x);\n return smlen;\n}\n\nfunction unpackneg(r, p) {\n var t = gf(), chk = gf(), num = gf(),\n den = gf(), den2 = gf(), den4 = gf(),\n den6 = gf();\n\n set25519(r[2], gf1);\n unpack25519(r[1], p);\n S(num, r[1]);\n M(den, num, D);\n Z(num, num, r[2]);\n A(den, r[2], den);\n\n S(den2, den);\n S(den4, den2);\n M(den6, den4, den2);\n M(t, den6, num);\n M(t, t, den);\n\n pow2523(t, t);\n M(t, t, num);\n M(t, t, den);\n M(t, t, den);\n M(r[0], t, den);\n\n S(chk, r[0]);\n M(chk, chk, den);\n if (neq25519(chk, num)) M(r[0], r[0], I);\n\n S(chk, r[0]);\n M(chk, chk, den);\n if (neq25519(chk, num)) return -1;\n\n if (par25519(r[0]) === (p[31]>>7)) Z(r[0], gf0, r[0]);\n\n M(r[3], r[0], r[1]);\n return 0;\n}\n\nfunction crypto_sign_open(m, sm, n, pk) {\n var i;\n var t = new Uint8Array(32), h = new Uint8Array(64);\n var p = [gf(), gf(), gf(), gf()],\n q = [gf(), gf(), gf(), gf()];\n\n if (n < 64) return -1;\n\n if (unpackneg(q, pk)) return -1;\n\n for (i = 0; i < n; i++) m[i] = sm[i];\n for (i = 0; i < 32; i++) m[i+32] = pk[i];\n crypto_hash(h, m, n);\n reduce(h);\n scalarmult(p, q, h);\n\n scalarbase(q, sm.subarray(32));\n add(p, q);\n pack(t, p);\n\n n -= 64;\n if (crypto_verify_32(sm, 0, t, 0)) {\n for (i = 0; i < n; i++) m[i] = 0;\n return -1;\n }\n\n for (i = 0; i < n; i++) m[i] = sm[i + 64];\n return n;\n}\n\nvar crypto_secretbox_KEYBYTES = 32,\n crypto_secretbox_NONCEBYTES = 24,\n crypto_secretbox_ZEROBYTES = 32,\n crypto_secretbox_BOXZEROBYTES = 16,\n crypto_scalarmult_BYTES = 32,\n crypto_scalarmult_SCALARBYTES = 32,\n crypto_box_PUBLICKEYBYTES = 32,\n crypto_box_SECRETKEYBYTES = 32,\n crypto_box_BEFORENMBYTES = 32,\n crypto_box_NONCEBYTES = crypto_secretbox_NONCEBYTES,\n crypto_box_ZEROBYTES = crypto_secretbox_ZEROBYTES,\n crypto_box_BOXZEROBYTES = crypto_secretbox_BOXZEROBYTES,\n crypto_sign_BYTES = 64,\n crypto_sign_PUBLICKEYBYTES = 32,\n crypto_sign_SECRETKEYBYTES = 64,\n crypto_sign_SEEDBYTES = 32,\n crypto_hash_BYTES = 64;\n\nnacl.lowlevel = {\n crypto_core_hsalsa20: crypto_core_hsalsa20,\n crypto_stream_xor: crypto_stream_xor,\n crypto_stream: crypto_stream,\n crypto_stream_salsa20_xor: crypto_stream_salsa20_xor,\n crypto_stream_salsa20: crypto_stream_salsa20,\n crypto_onetimeauth: crypto_onetimeauth,\n crypto_onetimeauth_verify: crypto_onetimeauth_verify,\n crypto_verify_16: crypto_verify_16,\n crypto_verify_32: crypto_verify_32,\n crypto_secretbox: crypto_secretbox,\n crypto_secretbox_open: crypto_secretbox_open,\n crypto_scalarmult: crypto_scalarmult,\n crypto_scalarmult_base: crypto_scalarmult_base,\n crypto_box_beforenm: crypto_box_beforenm,\n crypto_box_afternm: crypto_box_afternm,\n crypto_box: crypto_box,\n crypto_box_open: crypto_box_open,\n crypto_box_keypair: crypto_box_keypair,\n crypto_hash: crypto_hash,\n crypto_sign: crypto_sign,\n crypto_sign_keypair: crypto_sign_keypair,\n crypto_sign_open: crypto_sign_open,\n\n crypto_secretbox_KEYBYTES: crypto_secretbox_KEYBYTES,\n crypto_secretbox_NONCEBYTES: crypto_secretbox_NONCEBYTES,\n crypto_secretbox_ZEROBYTES: crypto_secretbox_ZEROBYTES,\n crypto_secretbox_BOXZEROBYTES: crypto_secretbox_BOXZEROBYTES,\n crypto_scalarmult_BYTES: crypto_scalarmult_BYTES,\n crypto_scalarmult_SCALARBYTES: crypto_scalarmult_SCALARBYTES,\n crypto_box_PUBLICKEYBYTES: crypto_box_PUBLICKEYBYTES,\n crypto_box_SECRETKEYBYTES: crypto_box_SECRETKEYBYTES,\n crypto_box_BEFORENMBYTES: crypto_box_BEFORENMBYTES,\n crypto_box_NONCEBYTES: crypto_box_NONCEBYTES,\n crypto_box_ZEROBYTES: crypto_box_ZEROBYTES,\n crypto_box_BOXZEROBYTES: crypto_box_BOXZEROBYTES,\n crypto_sign_BYTES: crypto_sign_BYTES,\n crypto_sign_PUBLICKEYBYTES: crypto_sign_PUBLICKEYBYTES,\n crypto_sign_SECRETKEYBYTES: crypto_sign_SECRETKEYBYTES,\n crypto_sign_SEEDBYTES: crypto_sign_SEEDBYTES,\n crypto_hash_BYTES: crypto_hash_BYTES,\n\n gf: gf,\n D: D,\n L: L,\n pack25519: pack25519,\n unpack25519: unpack25519,\n M: M,\n A: A,\n S: S,\n Z: Z,\n pow2523: pow2523,\n add: add,\n set25519: set25519,\n modL: modL,\n scalarmult: scalarmult,\n scalarbase: scalarbase,\n};\n\n/* High-level API */\n\nfunction checkLengths(k, n) {\n if (k.length !== crypto_secretbox_KEYBYTES) throw new Error('bad key size');\n if (n.length !== crypto_secretbox_NONCEBYTES) throw new Error('bad nonce size');\n}\n\nfunction checkBoxLengths(pk, sk) {\n if (pk.length !== crypto_box_PUBLICKEYBYTES) throw new Error('bad public key size');\n if (sk.length !== crypto_box_SECRETKEYBYTES) throw new Error('bad secret key size');\n}\n\nfunction checkArrayTypes() {\n for (var i = 0; i < arguments.length; i++) {\n if (!(arguments[i] instanceof Uint8Array))\n throw new TypeError('unexpected type, use Uint8Array');\n }\n}\n\nfunction cleanup(arr) {\n for (var i = 0; i < arr.length; i++) arr[i] = 0;\n}\n\nnacl.randomBytes = function(n) {\n var b = new Uint8Array(n);\n randombytes(b, n);\n return b;\n};\n\nnacl.secretbox = function(msg, nonce, key) {\n checkArrayTypes(msg, nonce, key);\n checkLengths(key, nonce);\n var m = new Uint8Array(crypto_secretbox_ZEROBYTES + msg.length);\n var c = new Uint8Array(m.length);\n for (var i = 0; i < msg.length; i++) m[i+crypto_secretbox_ZEROBYTES] = msg[i];\n crypto_secretbox(c, m, m.length, nonce, key);\n return c.subarray(crypto_secretbox_BOXZEROBYTES);\n};\n\nnacl.secretbox.open = function(box, nonce, key) {\n checkArrayTypes(box, nonce, key);\n checkLengths(key, nonce);\n var c = new Uint8Array(crypto_secretbox_BOXZEROBYTES + box.length);\n var m = new Uint8Array(c.length);\n for (var i = 0; i < box.length; i++) c[i+crypto_secretbox_BOXZEROBYTES] = box[i];\n if (c.length < 32) return null;\n if (crypto_secretbox_open(m, c, c.length, nonce, key) !== 0) return null;\n return m.subarray(crypto_secretbox_ZEROBYTES);\n};\n\nnacl.secretbox.keyLength = crypto_secretbox_KEYBYTES;\nnacl.secretbox.nonceLength = crypto_secretbox_NONCEBYTES;\nnacl.secretbox.overheadLength = crypto_secretbox_BOXZEROBYTES;\n\nnacl.scalarMult = function(n, p) {\n checkArrayTypes(n, p);\n if (n.length !== crypto_scalarmult_SCALARBYTES) throw new Error('bad n size');\n if (p.length !== crypto_scalarmult_BYTES) throw new Error('bad p size');\n var q = new Uint8Array(crypto_scalarmult_BYTES);\n crypto_scalarmult(q, n, p);\n return q;\n};\n\nnacl.scalarMult.base = function(n) {\n checkArrayTypes(n);\n if (n.length !== crypto_scalarmult_SCALARBYTES) throw new Error('bad n size');\n var q = new Uint8Array(crypto_scalarmult_BYTES);\n crypto_scalarmult_base(q, n);\n return q;\n};\n\nnacl.scalarMult.scalarLength = crypto_scalarmult_SCALARBYTES;\nnacl.scalarMult.groupElementLength = crypto_scalarmult_BYTES;\n\nnacl.box = function(msg, nonce, publicKey, secretKey) {\n var k = nacl.box.before(publicKey, secretKey);\n return nacl.secretbox(msg, nonce, k);\n};\n\nnacl.box.before = function(publicKey, secretKey) {\n checkArrayTypes(publicKey, secretKey);\n checkBoxLengths(publicKey, secretKey);\n var k = new Uint8Array(crypto_box_BEFORENMBYTES);\n crypto_box_beforenm(k, publicKey, secretKey);\n return k;\n};\n\nnacl.box.after = nacl.secretbox;\n\nnacl.box.open = function(msg, nonce, publicKey, secretKey) {\n var k = nacl.box.before(publicKey, secretKey);\n return nacl.secretbox.open(msg, nonce, k);\n};\n\nnacl.box.open.after = nacl.secretbox.open;\n\nnacl.box.keyPair = function() {\n var pk = new Uint8Array(crypto_box_PUBLICKEYBYTES);\n var sk = new Uint8Array(crypto_box_SECRETKEYBYTES);\n crypto_box_keypair(pk, sk);\n return {publicKey: pk, secretKey: sk};\n};\n\nnacl.box.keyPair.fromSecretKey = function(secretKey) {\n checkArrayTypes(secretKey);\n if (secretKey.length !== crypto_box_SECRETKEYBYTES)\n throw new Error('bad secret key size');\n var pk = new Uint8Array(crypto_box_PUBLICKEYBYTES);\n crypto_scalarmult_base(pk, secretKey);\n return {publicKey: pk, secretKey: new Uint8Array(secretKey)};\n};\n\nnacl.box.publicKeyLength = crypto_box_PUBLICKEYBYTES;\nnacl.box.secretKeyLength = crypto_box_SECRETKEYBYTES;\nnacl.box.sharedKeyLength = crypto_box_BEFORENMBYTES;\nnacl.box.nonceLength = crypto_box_NONCEBYTES;\nnacl.box.overheadLength = nacl.secretbox.overheadLength;\n\nnacl.sign = function(msg, secretKey) {\n checkArrayTypes(msg, secretKey);\n if (secretKey.length !== crypto_sign_SECRETKEYBYTES)\n throw new Error('bad secret key size');\n var signedMsg = new Uint8Array(crypto_sign_BYTES+msg.length);\n crypto_sign(signedMsg, msg, msg.length, secretKey);\n return signedMsg;\n};\n\nnacl.sign.open = function(signedMsg, publicKey) {\n checkArrayTypes(signedMsg, publicKey);\n if (publicKey.length !== crypto_sign_PUBLICKEYBYTES)\n throw new Error('bad public key size');\n var tmp = new Uint8Array(signedMsg.length);\n var mlen = crypto_sign_open(tmp, signedMsg, signedMsg.length, publicKey);\n if (mlen < 0) return null;\n var m = new Uint8Array(mlen);\n for (var i = 0; i < m.length; i++) m[i] = tmp[i];\n return m;\n};\n\nnacl.sign.detached = function(msg, secretKey) {\n var signedMsg = nacl.sign(msg, secretKey);\n var sig = new Uint8Array(crypto_sign_BYTES);\n for (var i = 0; i < sig.length; i++) sig[i] = signedMsg[i];\n return sig;\n};\n\nnacl.sign.detached.verify = function(msg, sig, publicKey) {\n checkArrayTypes(msg, sig, publicKey);\n if (sig.length !== crypto_sign_BYTES)\n throw new Error('bad signature size');\n if (publicKey.length !== crypto_sign_PUBLICKEYBYTES)\n throw new Error('bad public key size');\n var sm = new Uint8Array(crypto_sign_BYTES + msg.length);\n var m = new Uint8Array(crypto_sign_BYTES + msg.length);\n var i;\n for (i = 0; i < crypto_sign_BYTES; i++) sm[i] = sig[i];\n for (i = 0; i < msg.length; i++) sm[i+crypto_sign_BYTES] = msg[i];\n return (crypto_sign_open(m, sm, sm.length, publicKey) >= 0);\n};\n\nnacl.sign.keyPair = function() {\n var pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);\n var sk = new Uint8Array(crypto_sign_SECRETKEYBYTES);\n crypto_sign_keypair(pk, sk);\n return {publicKey: pk, secretKey: sk};\n};\n\nnacl.sign.keyPair.fromSecretKey = function(secretKey) {\n checkArrayTypes(secretKey);\n if (secretKey.length !== crypto_sign_SECRETKEYBYTES)\n throw new Error('bad secret key size');\n var pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);\n for (var i = 0; i < pk.length; i++) pk[i] = secretKey[32+i];\n return {publicKey: pk, secretKey: new Uint8Array(secretKey)};\n};\n\nnacl.sign.keyPair.fromSeed = function(seed) {\n checkArrayTypes(seed);\n if (seed.length !== crypto_sign_SEEDBYTES)\n throw new Error('bad seed size');\n var pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);\n var sk = new Uint8Array(crypto_sign_SECRETKEYBYTES);\n for (var i = 0; i < 32; i++) sk[i] = seed[i];\n crypto_sign_keypair(pk, sk, true);\n return {publicKey: pk, secretKey: sk};\n};\n\nnacl.sign.publicKeyLength = crypto_sign_PUBLICKEYBYTES;\nnacl.sign.secretKeyLength = crypto_sign_SECRETKEYBYTES;\nnacl.sign.seedLength = crypto_sign_SEEDBYTES;\nnacl.sign.signatureLength = crypto_sign_BYTES;\n\nnacl.hash = function(msg) {\n checkArrayTypes(msg);\n var h = new Uint8Array(crypto_hash_BYTES);\n crypto_hash(h, msg, msg.length);\n return h;\n};\n\nnacl.hash.hashLength = crypto_hash_BYTES;\n\nnacl.verify = function(x, y) {\n checkArrayTypes(x, y);\n // Zero length arguments are considered not equal.\n if (x.length === 0 || y.length === 0) return false;\n if (x.length !== y.length) return false;\n return (vn(x, 0, y, 0, x.length) === 0) ? true : false;\n};\n\nnacl.setPRNG = function(fn) {\n randombytes = fn;\n};\n\n(function() {\n // Initialize PRNG if environment provides CSPRNG.\n // If not, methods calling randombytes will throw.\n var crypto = typeof self !== 'undefined' ? (self.crypto || self.msCrypto) : null;\n if (crypto && crypto.getRandomValues) {\n // Browsers.\n var QUOTA = 65536;\n nacl.setPRNG(function(x, n) {\n var i, v = new Uint8Array(n);\n for (i = 0; i < n; i += QUOTA) {\n crypto.getRandomValues(v.subarray(i, i + Math.min(n - i, QUOTA)));\n }\n for (i = 0; i < n; i++) x[i] = v[i];\n cleanup(v);\n });\n } else if (typeof require !== 'undefined') {\n // Node.js.\n crypto = require('crypto');\n if (crypto && crypto.randomBytes) {\n nacl.setPRNG(function(x, n) {\n var i, v = crypto.randomBytes(n);\n for (i = 0; i < n; i++) x[i] = v[i];\n cleanup(v);\n });\n }\n }\n})();\n\n})(typeof module !== 'undefined' && module.exports ? module.exports : (self.nacl = self.nacl || {}));\n","module.exports = require('./pusher-with-encryption').default;\n","import ScriptReceiver from './script_receiver';\n\n/** Builds receivers for JSONP and Script requests.\n *\n * Each receiver is an object with following fields:\n * - number - unique (for the factory instance), numerical id of the receiver\n * - id - a string ID that can be used in DOM attributes\n * - name - name of the function triggering the receiver\n * - callback - callback function\n *\n * Receivers are triggered only once, on the first callback call.\n *\n * Receivers can be called by their name or by accessing factory object\n * by the number key.\n *\n * @param {String} prefix the prefix used in ids\n * @param {String} name the name of the object\n */\nexport class ScriptReceiverFactory {\n lastId: number;\n prefix: string;\n name: string;\n\n constructor(prefix: string, name: string) {\n this.lastId = 0;\n this.prefix = prefix;\n this.name = name;\n }\n\n create(callback: Function): ScriptReceiver {\n this.lastId++;\n\n var number = this.lastId;\n var id = this.prefix + number;\n var name = this.name + '[' + number + ']';\n\n var called = false;\n var callbackWrapper = function() {\n if (!called) {\n callback.apply(null, arguments);\n called = true;\n }\n };\n\n this[number] = callbackWrapper;\n return { number: number, id: id, name: name, callback: callbackWrapper };\n }\n\n remove(receiver: ScriptReceiver) {\n delete this[receiver.number];\n }\n}\n\nexport var ScriptReceivers = new ScriptReceiverFactory(\n '_pusher_script_',\n 'Pusher.ScriptReceivers'\n);\n","import {\n ChannelAuthorizationOptions,\n UserAuthenticationOptions\n} from './auth/options';\nimport { AuthTransport } from './config';\n\nexport interface DefaultConfig {\n VERSION: string;\n PROTOCOL: number;\n wsPort: number;\n wssPort: number;\n wsPath: string;\n httpHost: string;\n httpPort: number;\n httpsPort: number;\n httpPath: string;\n stats_host: string;\n authEndpoint: string;\n authTransport: AuthTransport;\n activityTimeout: number;\n pongTimeout: number;\n unavailableTimeout: number;\n userAuthentication: UserAuthenticationOptions;\n channelAuthorization: ChannelAuthorizationOptions;\n\n cdn_http?: string;\n cdn_https?: string;\n dependency_suffix?: string;\n}\n\nvar Defaults: DefaultConfig = {\n VERSION: VERSION,\n PROTOCOL: 7,\n\n wsPort: 80,\n wssPort: 443,\n wsPath: '',\n // DEPRECATED: SockJS fallback parameters\n httpHost: 'sockjs.pusher.com',\n httpPort: 80,\n httpsPort: 443,\n httpPath: '/pusher',\n // DEPRECATED: Stats\n stats_host: 'stats.pusher.com',\n // DEPRECATED: Other settings\n authEndpoint: '/pusher/auth',\n authTransport: 'ajax',\n activityTimeout: 120000,\n pongTimeout: 30000,\n unavailableTimeout: 10000,\n userAuthentication: {\n endpoint: '/pusher/user-auth',\n transport: 'ajax'\n },\n channelAuthorization: {\n endpoint: '/pusher/auth',\n transport: 'ajax'\n },\n\n // CDN configuration\n cdn_http: CDN_HTTP,\n cdn_https: CDN_HTTPS,\n dependency_suffix: DEPENDENCY_SUFFIX\n};\n\nexport default Defaults;\n","import { ScriptReceiverFactory } from './script_receiver_factory';\nimport Defaults from 'core/defaults';\nimport DependencyLoader from './dependency_loader';\n\nexport var DependenciesReceivers = new ScriptReceiverFactory(\n '_pusher_dependencies',\n 'Pusher.DependenciesReceivers'\n);\n\nexport var Dependencies = new DependencyLoader({\n cdn_http: Defaults.cdn_http,\n cdn_https: Defaults.cdn_https,\n version: Defaults.VERSION,\n suffix: Defaults.dependency_suffix,\n receivers: DependenciesReceivers\n});\n","import {\n ScriptReceivers,\n ScriptReceiverFactory\n} from './script_receiver_factory';\nimport Runtime from 'runtime';\nimport ScriptRequest from './script_request';\n\n/** Handles loading dependency files.\n *\n * Dependency loaders don't remember whether a resource has been loaded or\n * not. It is caller's responsibility to make sure the resource is not loaded\n * twice. This is because it's impossible to detect resource loading status\n * without knowing its content.\n *\n * Options:\n * - cdn_http - url to HTTP CND\n * - cdn_https - url to HTTPS CDN\n * - version - version of pusher-js\n * - suffix - suffix appended to all names of dependency files\n *\n * @param {Object} options\n */\nexport default class DependencyLoader {\n options: any;\n receivers: ScriptReceiverFactory;\n loading: any;\n\n constructor(options: any) {\n this.options = options;\n this.receivers = options.receivers || ScriptReceivers;\n this.loading = {};\n }\n\n /** Loads the dependency from CDN.\n *\n * @param {String} name\n * @param {Function} callback\n */\n load(name: string, options: any, callback: Function) {\n var self = this;\n\n if (self.loading[name] && self.loading[name].length > 0) {\n self.loading[name].push(callback);\n } else {\n self.loading[name] = [callback];\n\n var request = Runtime.createScriptRequest(self.getPath(name, options));\n var receiver = self.receivers.create(function(error) {\n self.receivers.remove(receiver);\n\n if (self.loading[name]) {\n var callbacks = self.loading[name];\n delete self.loading[name];\n\n var successCallback = function(wasSuccessful) {\n if (!wasSuccessful) {\n request.cleanup();\n }\n };\n for (var i = 0; i < callbacks.length; i++) {\n callbacks[i](error, successCallback);\n }\n }\n });\n request.send(receiver);\n }\n }\n\n /** Returns a root URL for pusher-js CDN.\n *\n * @returns {String}\n */\n getRoot(options: any): string {\n var cdn;\n var protocol = Runtime.getDocument().location.protocol;\n if ((options && options.useTLS) || protocol === 'https:') {\n cdn = this.options.cdn_https;\n } else {\n cdn = this.options.cdn_http;\n }\n // make sure there are no double slashes\n return cdn.replace(/\\/*$/, '') + '/' + this.options.version;\n }\n\n /** Returns a full path to a dependency file.\n *\n * @param {String} name\n * @returns {String}\n */\n getPath(name: string, options: any): string {\n return this.getRoot(options) + '/' + name + this.options.suffix + '.js';\n }\n}\n","/**\n * A place to store help URLs for error messages etc\n */\n\nconst urlStore = {\n baseUrl: 'https://pusher.com',\n urls: {\n authenticationEndpoint: {\n path: '/docs/channels/server_api/authenticating_users'\n },\n authorizationEndpoint: {\n path: '/docs/channels/server_api/authorizing-users/'\n },\n javascriptQuickStart: {\n path: '/docs/javascript_quick_start'\n },\n triggeringClientEvents: {\n path: '/docs/client_api_guide/client_events#trigger-events'\n },\n encryptedChannelSupport: {\n fullUrl:\n 'https://github.com/pusher/pusher-js/tree/cc491015371a4bde5743d1c87a0fbac0feb53195#encrypted-channel-support'\n }\n }\n};\n\n/** Builds a consistent string with links to pusher documentation\n *\n * @param {string} key - relevant key in the url_store.urls object\n * @return {string} suffix string to append to log message\n */\nconst buildLogSuffix = function(key: string): string {\n const urlPrefix = 'See:';\n const urlObj = urlStore.urls[key];\n if (!urlObj) return '';\n\n let url;\n if (urlObj.fullUrl) {\n url = urlObj.fullUrl;\n } else if (urlObj.path) {\n url = urlStore.baseUrl + urlObj.path;\n }\n\n if (!url) return '';\n return `${urlPrefix} ${url}`;\n};\n\nexport default { buildLogSuffix };\n","export enum AuthRequestType {\n UserAuthentication = 'user-authentication',\n ChannelAuthorization = 'channel-authorization'\n}\n\nexport interface ChannelAuthorizationData {\n auth: string;\n channel_data?: string;\n shared_secret?: string;\n}\n\nexport type ChannelAuthorizationCallback = (\n error: Error | null,\n authData: ChannelAuthorizationData | null\n) => void;\n\nexport interface ChannelAuthorizationRequestParams {\n socketId: string;\n channelName: string;\n}\n\nexport interface ChannelAuthorizationHandler {\n (\n params: ChannelAuthorizationRequestParams,\n callback: ChannelAuthorizationCallback\n ): void;\n}\n\nexport interface UserAuthenticationData {\n auth: string;\n user_data: string;\n}\n\nexport type UserAuthenticationCallback = (\n error: Error | null,\n authData: UserAuthenticationData | null\n) => void;\n\nexport interface UserAuthenticationRequestParams {\n socketId: string;\n}\n\nexport interface UserAuthenticationHandler {\n (\n params: UserAuthenticationRequestParams,\n callback: UserAuthenticationCallback\n ): void;\n}\n\nexport type AuthTransportCallback =\n | ChannelAuthorizationCallback\n | UserAuthenticationCallback;\n\nexport interface AuthOptionsT {\n transport: 'ajax' | 'jsonp';\n endpoint: string;\n params?: any;\n headers?: any;\n paramsProvider?: () => any;\n headersProvider?: () => any;\n customHandler?: AuthHandler;\n}\n\nexport declare type UserAuthenticationOptions = AuthOptionsT<\n UserAuthenticationHandler\n>;\nexport declare type ChannelAuthorizationOptions = AuthOptionsT<\n ChannelAuthorizationHandler\n>;\n\nexport interface InternalAuthOptions {\n transport: 'ajax' | 'jsonp';\n endpoint: string;\n params?: any;\n headers?: any;\n paramsProvider?: () => any;\n headersProvider?: () => any;\n}\n","/** Error classes used throughout the library. */\n// https://github.com/Microsoft/TypeScript-wiki/blob/master/Breaking-Changes.md#extending-built-ins-like-error-array-and-map-may-no-longer-work\nexport class BadEventName extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\nexport class BadChannelName extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\nexport class RequestTimedOut extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class TransportPriorityTooLow extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class TransportClosed extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class UnsupportedFeature extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class UnsupportedTransport extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class UnsupportedStrategy extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class HTTPAuthError extends Error {\n status: number;\n constructor(status: number, msg?: string) {\n super(msg);\n this.status = status;\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n","import TimelineSender from 'core/timeline/timeline_sender';\nimport * as Collections from 'core/utils/collections';\nimport Util from 'core/util';\nimport Runtime from 'runtime';\nimport { AuthTransport } from 'core/auth/auth_transports';\nimport AbstractRuntime from 'runtimes/interface';\nimport UrlStore from 'core/utils/url_store';\nimport {\n AuthRequestType,\n AuthTransportCallback,\n InternalAuthOptions\n} from 'core/auth/options';\nimport { HTTPAuthError } from 'core/errors';\n\nconst ajax: AuthTransport = function(\n context: AbstractRuntime,\n query: string,\n authOptions: InternalAuthOptions,\n authRequestType: AuthRequestType,\n callback: AuthTransportCallback\n) {\n const xhr = Runtime.createXHR();\n xhr.open('POST', authOptions.endpoint, true);\n\n // add request headers\n xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');\n for (var headerName in authOptions.headers) {\n xhr.setRequestHeader(headerName, authOptions.headers[headerName]);\n }\n if (authOptions.headersProvider != null) {\n let dynamicHeaders = authOptions.headersProvider();\n for (var headerName in dynamicHeaders) {\n xhr.setRequestHeader(headerName, dynamicHeaders[headerName]);\n }\n }\n\n xhr.onreadystatechange = function() {\n if (xhr.readyState === 4) {\n if (xhr.status === 200) {\n let data;\n let parsed = false;\n\n try {\n data = JSON.parse(xhr.responseText);\n parsed = true;\n } catch (e) {\n callback(\n new HTTPAuthError(\n 200,\n `JSON returned from ${authRequestType.toString()} endpoint was invalid, yet status code was 200. Data was: ${\n xhr.responseText\n }`\n ),\n null\n );\n }\n\n if (parsed) {\n // prevents double execution.\n callback(null, data);\n }\n } else {\n let suffix = '';\n switch (authRequestType) {\n case AuthRequestType.UserAuthentication:\n suffix = UrlStore.buildLogSuffix('authenticationEndpoint');\n break;\n case AuthRequestType.ChannelAuthorization:\n suffix = `Clients must be authorized to join private or presence channels. ${UrlStore.buildLogSuffix(\n 'authorizationEndpoint'\n )}`;\n break;\n }\n callback(\n new HTTPAuthError(\n xhr.status,\n `Unable to retrieve auth string from ${authRequestType.toString()} endpoint - ` +\n `received status: ${xhr.status} from ${authOptions.endpoint}. ${suffix}`\n ),\n null\n );\n }\n }\n };\n\n xhr.send(query);\n return xhr;\n};\n\nexport default ajax;\n","export default function encode(s: any): string {\n return btoa(utob(s));\n}\n\nvar fromCharCode = String.fromCharCode;\n\nvar b64chars =\n 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';\nvar b64tab = {};\n\nfor (var i = 0, l = b64chars.length; i < l; i++) {\n b64tab[b64chars.charAt(i)] = i;\n}\n\nvar cb_utob = function(c) {\n var cc = c.charCodeAt(0);\n return cc < 0x80\n ? c\n : cc < 0x800\n ? fromCharCode(0xc0 | (cc >>> 6)) + fromCharCode(0x80 | (cc & 0x3f))\n : fromCharCode(0xe0 | ((cc >>> 12) & 0x0f)) +\n fromCharCode(0x80 | ((cc >>> 6) & 0x3f)) +\n fromCharCode(0x80 | (cc & 0x3f));\n};\n\nvar utob = function(u) {\n return u.replace(/[^\\x00-\\x7F]/g, cb_utob);\n};\n\nvar cb_encode = function(ccc) {\n var padlen = [0, 2, 1][ccc.length % 3];\n var ord =\n (ccc.charCodeAt(0) << 16) |\n ((ccc.length > 1 ? ccc.charCodeAt(1) : 0) << 8) |\n (ccc.length > 2 ? ccc.charCodeAt(2) : 0);\n var chars = [\n b64chars.charAt(ord >>> 18),\n b64chars.charAt((ord >>> 12) & 63),\n padlen >= 2 ? '=' : b64chars.charAt((ord >>> 6) & 63),\n padlen >= 1 ? '=' : b64chars.charAt(ord & 63)\n ];\n return chars.join('');\n};\n\nvar btoa =\n global.btoa ||\n function(b) {\n return b.replace(/[\\s\\S]{1,3}/g, cb_encode);\n };\n","import TimedCallback from './timed_callback';\nimport { Delay, Scheduler, Canceller } from './scheduling';\n\nabstract class Timer {\n protected clear: Canceller;\n protected timer: number | void;\n\n constructor(\n set: Scheduler,\n clear: Canceller,\n delay: Delay,\n callback: TimedCallback\n ) {\n this.clear = clear;\n this.timer = set(() => {\n if (this.timer) {\n this.timer = callback(this.timer);\n }\n }, delay);\n }\n\n /** Returns whether the timer is still running.\n *\n * @return {Boolean}\n */\n isRunning(): boolean {\n return this.timer !== null;\n }\n\n /** Aborts a timer when it's running. */\n ensureAborted() {\n if (this.timer) {\n this.clear(this.timer);\n this.timer = null;\n }\n }\n}\n\nexport default Timer;\n","import Timer from './abstract_timer';\nimport TimedCallback from './timed_callback';\nimport { Delay } from './scheduling';\n\n// We need to bind clear functions this way to avoid exceptions on IE8\nfunction clearTimeout(timer) {\n global.clearTimeout(timer);\n}\nfunction clearInterval(timer) {\n global.clearInterval(timer);\n}\n\n/** Cross-browser compatible one-off timer abstraction.\n *\n * @param {Number} delay\n * @param {Function} callback\n */\nexport class OneOffTimer extends Timer {\n constructor(delay: Delay, callback: TimedCallback) {\n super(setTimeout, clearTimeout, delay, function(timer) {\n callback();\n return null;\n });\n }\n}\n\n/** Cross-browser compatible periodic timer abstraction.\n *\n * @param {Number} delay\n * @param {Function} callback\n */\nexport class PeriodicTimer extends Timer {\n constructor(delay: Delay, callback: TimedCallback) {\n super(setInterval, clearInterval, delay, function(timer) {\n callback();\n return timer;\n });\n }\n}\n","import * as Collections from './utils/collections';\nimport TimedCallback from './utils/timers/timed_callback';\nimport { OneOffTimer, PeriodicTimer } from './utils/timers';\n\nvar Util = {\n now(): number {\n if (Date.now) {\n return Date.now();\n } else {\n return new Date().valueOf();\n }\n },\n\n defer(callback: TimedCallback): OneOffTimer {\n return new OneOffTimer(0, callback);\n },\n\n /** Builds a function that will proxy a method call to its first argument.\n *\n * Allows partial application of arguments, so additional arguments are\n * prepended to the argument list.\n *\n * @param {String} name method name\n * @return {Function} proxy function\n */\n method(name: string, ...args: any[]): Function {\n var boundArguments = Array.prototype.slice.call(arguments, 1);\n return function(object) {\n return object[name].apply(object, boundArguments.concat(arguments));\n };\n }\n};\n\nexport default Util;\n","import base64encode from '../base64';\nimport Util from '../util';\n\n/** Merges multiple objects into the target argument.\n *\n * For properties that are plain Objects, performs a deep-merge. For the\n * rest it just copies the value of the property.\n *\n * To extend prototypes use it as following:\n * Pusher.Util.extend(Target.prototype, Base.prototype)\n *\n * You can also use it to merge objects without altering them:\n * Pusher.Util.extend({}, object1, object2)\n *\n * @param {Object} target\n * @return {Object} the target argument\n */\nexport function extend(target: any, ...sources: any[]): T {\n for (var i = 0; i < sources.length; i++) {\n var extensions = sources[i];\n for (var property in extensions) {\n if (\n extensions[property] &&\n extensions[property].constructor &&\n extensions[property].constructor === Object\n ) {\n target[property] = extend(target[property] || {}, extensions[property]);\n } else {\n target[property] = extensions[property];\n }\n }\n }\n return target;\n}\n\nexport function stringify(): string {\n var m = ['Pusher'];\n for (var i = 0; i < arguments.length; i++) {\n if (typeof arguments[i] === 'string') {\n m.push(arguments[i]);\n } else {\n m.push(safeJSONStringify(arguments[i]));\n }\n }\n return m.join(' : ');\n}\n\nexport function arrayIndexOf(array: any[], item: any): number {\n // MSIE doesn't have array.indexOf\n var nativeIndexOf = Array.prototype.indexOf;\n if (array === null) {\n return -1;\n }\n if (nativeIndexOf && array.indexOf === nativeIndexOf) {\n return array.indexOf(item);\n }\n for (var i = 0, l = array.length; i < l; i++) {\n if (array[i] === item) {\n return i;\n }\n }\n return -1;\n}\n\n/** Applies a function f to all properties of an object.\n *\n * Function f gets 3 arguments passed:\n * - element from the object\n * - key of the element\n * - reference to the object\n *\n * @param {Object} object\n * @param {Function} f\n */\nexport function objectApply(object: any, f: Function) {\n for (var key in object) {\n if (Object.prototype.hasOwnProperty.call(object, key)) {\n f(object[key], key, object);\n }\n }\n}\n\n/** Return a list of objects own proerty keys\n *\n * @param {Object} object\n * @returns {Array}\n */\nexport function keys(object: any): string[] {\n var keys = [];\n objectApply(object, function(_, key) {\n keys.push(key);\n });\n return keys;\n}\n\n/** Return a list of object's own property values\n *\n * @param {Object} object\n * @returns {Array}\n */\nexport function values(object: any): any[] {\n var values = [];\n objectApply(object, function(value) {\n values.push(value);\n });\n return values;\n}\n\n/** Applies a function f to all elements of an array.\n *\n * Function f gets 3 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function apply(array: any[], f: Function, context?: any) {\n for (var i = 0; i < array.length; i++) {\n f.call(context || global, array[i], i, array);\n }\n}\n\n/** Maps all elements of the array and returns the result.\n *\n * Function f gets 4 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n * - reference to the destination array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function map(array: any[], f: Function): any[] {\n var result = [];\n for (var i = 0; i < array.length; i++) {\n result.push(f(array[i], i, array, result));\n }\n return result;\n}\n\n/** Maps all elements of the object and returns the result.\n *\n * Function f gets 4 arguments passed:\n * - element from the object\n * - key of the element\n * - reference to the source object\n * - reference to the destination object\n *\n * @param {Object} object\n * @param {Function} f\n */\nexport function mapObject(object: any, f: Function): any {\n var result = {};\n objectApply(object, function(value, key) {\n result[key] = f(value);\n });\n return result;\n}\n\n/** Filters elements of the array using a test function.\n *\n * Function test gets 4 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n * - reference to the destination array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function filter(array: any[], test: Function): any[] {\n test =\n test ||\n function(value) {\n return !!value;\n };\n\n var result = [];\n for (var i = 0; i < array.length; i++) {\n if (test(array[i], i, array, result)) {\n result.push(array[i]);\n }\n }\n return result;\n}\n\n/** Filters properties of the object using a test function.\n *\n * Function test gets 4 arguments passed:\n * - element from the object\n * - key of the element\n * - reference to the source object\n * - reference to the destination object\n *\n * @param {Object} object\n * @param {Function} f\n */\nexport function filterObject(object: Object, test: Function) {\n var result = {};\n objectApply(object, function(value, key) {\n if ((test && test(value, key, object, result)) || Boolean(value)) {\n result[key] = value;\n }\n });\n return result;\n}\n\n/** Flattens an object into a two-dimensional array.\n *\n * @param {Object} object\n * @return {Array} resulting array of [key, value] pairs\n */\nexport function flatten(object: Object): any[] {\n var result = [];\n objectApply(object, function(value, key) {\n result.push([key, value]);\n });\n return result;\n}\n\n/** Checks whether any element of the array passes the test.\n *\n * Function test gets 3 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function any(array: any[], test: Function): boolean {\n for (var i = 0; i < array.length; i++) {\n if (test(array[i], i, array)) {\n return true;\n }\n }\n return false;\n}\n\n/** Checks whether all elements of the array pass the test.\n *\n * Function test gets 3 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function all(array: any[], test: Function): boolean {\n for (var i = 0; i < array.length; i++) {\n if (!test(array[i], i, array)) {\n return false;\n }\n }\n return true;\n}\n\nexport function encodeParamsObject(data): string {\n return mapObject(data, function(value) {\n if (typeof value === 'object') {\n value = safeJSONStringify(value);\n }\n return encodeURIComponent(base64encode(value.toString()));\n });\n}\n\nexport function buildQueryString(data: any): string {\n var params = filterObject(data, function(value) {\n return value !== undefined;\n });\n\n var query = map(\n flatten(encodeParamsObject(params)),\n Util.method('join', '=')\n ).join('&');\n\n return query;\n}\n\n/**\n * See https://github.com/douglascrockford/JSON-js/blob/master/cycle.js\n *\n * Remove circular references from an object. Required for JSON.stringify in\n * React Native, which tends to blow up a lot.\n *\n * @param {any} object\n * @return {any} Decycled object\n */\nexport function decycleObject(object: any): any {\n var objects = [],\n paths = [];\n\n return (function derez(value, path) {\n var i, name, nu;\n\n switch (typeof value) {\n case 'object':\n if (!value) {\n return null;\n }\n for (i = 0; i < objects.length; i += 1) {\n if (objects[i] === value) {\n return { $ref: paths[i] };\n }\n }\n\n objects.push(value);\n paths.push(path);\n\n if (Object.prototype.toString.apply(value) === '[object Array]') {\n nu = [];\n for (i = 0; i < value.length; i += 1) {\n nu[i] = derez(value[i], path + '[' + i + ']');\n }\n } else {\n nu = {};\n for (name in value) {\n if (Object.prototype.hasOwnProperty.call(value, name)) {\n nu[name] = derez(\n value[name],\n path + '[' + JSON.stringify(name) + ']'\n );\n }\n }\n }\n return nu;\n case 'number':\n case 'string':\n case 'boolean':\n return value;\n }\n })(object, '$');\n}\n\n/**\n * Provides a cross-browser and cross-platform way to safely stringify objects\n * into JSON. This is particularly necessary for ReactNative, where circular JSON\n * structures throw an exception.\n *\n * @param {any} source The object to stringify\n * @return {string} The serialized output.\n */\nexport function safeJSONStringify(source: any): string {\n try {\n return JSON.stringify(source);\n } catch (e) {\n return JSON.stringify(decycleObject(source));\n }\n}\n","import { stringify } from './utils/collections';\nimport Pusher from './pusher';\n\nclass Logger {\n debug(...args: any[]) {\n this.log(this.globalLog, args);\n }\n\n warn(...args: any[]) {\n this.log(this.globalLogWarn, args);\n }\n\n error(...args: any[]) {\n this.log(this.globalLogError, args);\n }\n\n private globalLog = (message: string) => {\n if (global.console && global.console.log) {\n global.console.log(message);\n }\n };\n\n private globalLogWarn(message: string) {\n if (global.console && global.console.warn) {\n global.console.warn(message);\n } else {\n this.globalLog(message);\n }\n }\n\n private globalLogError(message: string) {\n if (global.console && global.console.error) {\n global.console.error(message);\n } else {\n this.globalLogWarn(message);\n }\n }\n\n private log(\n defaultLoggingFunction: (message: string) => void,\n ...args: any[]\n ) {\n var message = stringify.apply(this, arguments);\n if (Pusher.log) {\n Pusher.log(message);\n } else if (Pusher.logToConsole) {\n const log = defaultLoggingFunction.bind(this);\n log(message);\n }\n }\n}\n\nexport default new Logger();\n","import Browser from '../browser';\nimport Logger from 'core/logger';\nimport JSONPRequest from '../dom/jsonp_request';\nimport { ScriptReceivers } from '../dom/script_receiver_factory';\nimport { AuthTransport } from 'core/auth/auth_transports';\nimport {\n AuthRequestType,\n AuthTransportCallback,\n InternalAuthOptions\n} from 'core/auth/options';\n\nvar jsonp: AuthTransport = function(\n context: Browser,\n query: string,\n authOptions: InternalAuthOptions,\n authRequestType: AuthRequestType,\n callback: AuthTransportCallback\n) {\n if (\n authOptions.headers !== undefined ||\n authOptions.headersProvider != null\n ) {\n Logger.warn(\n `To send headers with the ${authRequestType.toString()} request, you must use AJAX, rather than JSONP.`\n );\n }\n\n var callbackName = context.nextAuthCallbackID.toString();\n context.nextAuthCallbackID++;\n\n var document = context.getDocument();\n var script = document.createElement('script');\n // Hacked wrapper.\n context.auth_callbacks[callbackName] = function(data) {\n callback(null, data);\n };\n\n var callback_name = \"Pusher.auth_callbacks['\" + callbackName + \"']\";\n script.src =\n authOptions.endpoint +\n '?callback=' +\n encodeURIComponent(callback_name) +\n '&' +\n query;\n\n var head =\n document.getElementsByTagName('head')[0] || document.documentElement;\n head.insertBefore(script, head.firstChild);\n};\n\nexport default jsonp;\n","import ScriptReceiver from './script_receiver';\n\n/** Sends a generic HTTP GET request using a script tag.\n *\n * By constructing URL in a specific way, it can be used for loading\n * JavaScript resources or JSONP requests. It can notify about errors, but\n * only in certain environments. Please take care of monitoring the state of\n * the request yourself.\n *\n * @param {String} src\n */\nexport default class ScriptRequest {\n src: string;\n script: any;\n errorScript: any;\n\n constructor(src: string) {\n this.src = src;\n }\n\n send(receiver: ScriptReceiver) {\n var self = this;\n var errorString = 'Error loading ' + self.src;\n\n self.script = document.createElement('script');\n self.script.id = receiver.id;\n self.script.src = self.src;\n self.script.type = 'text/javascript';\n self.script.charset = 'UTF-8';\n\n if (self.script.addEventListener) {\n self.script.onerror = function() {\n receiver.callback(errorString);\n };\n self.script.onload = function() {\n receiver.callback(null);\n };\n } else {\n self.script.onreadystatechange = function() {\n if (\n self.script.readyState === 'loaded' ||\n self.script.readyState === 'complete'\n ) {\n receiver.callback(null);\n }\n };\n }\n\n // Opera<11.6 hack for missing onerror callback\n if (\n self.script.async === undefined &&\n (document).attachEvent &&\n /opera/i.test(navigator.userAgent)\n ) {\n self.errorScript = document.createElement('script');\n self.errorScript.id = receiver.id + '_error';\n self.errorScript.text = receiver.name + \"('\" + errorString + \"');\";\n self.script.async = self.errorScript.async = false;\n } else {\n self.script.async = true;\n }\n\n var head = document.getElementsByTagName('head')[0];\n head.insertBefore(self.script, head.firstChild);\n if (self.errorScript) {\n head.insertBefore(self.errorScript, self.script.nextSibling);\n }\n }\n\n /** Cleans up the DOM remains of the script request. */\n cleanup() {\n if (this.script) {\n this.script.onload = this.script.onerror = null;\n this.script.onreadystatechange = null;\n }\n if (this.script && this.script.parentNode) {\n this.script.parentNode.removeChild(this.script);\n }\n if (this.errorScript && this.errorScript.parentNode) {\n this.errorScript.parentNode.removeChild(this.errorScript);\n }\n this.script = null;\n this.errorScript = null;\n }\n}\n","import ScriptReceiver from './script_receiver';\nimport ScriptRequest from './script_request';\nimport * as Collections from 'core/utils/collections';\nimport Util from 'core/util';\nimport Runtime from '../runtime';\n\n/** Sends data via JSONP.\n *\n * Data is a key-value map. Its values are JSON-encoded and then passed\n * through base64. Finally, keys and encoded values are appended to the query\n * string.\n *\n * The class itself does not guarantee raising errors on failures, as it's not\n * possible to support such feature on all browsers. Instead, JSONP endpoint\n * should call back in a way that's easy to distinguish from browser calls,\n * for example by passing a second argument to the receiver.\n *\n * @param {String} url\n * @param {Object} data key-value map of data to be submitted\n */\nexport default class JSONPRequest {\n url: string;\n data: any;\n request: ScriptRequest;\n\n constructor(url: string, data: any) {\n this.url = url;\n this.data = data;\n }\n\n /** Sends the actual JSONP request.\n *\n * @param {ScriptReceiver} receiver\n */\n send(receiver: ScriptReceiver) {\n if (this.request) {\n return;\n }\n\n var query = Collections.buildQueryString(this.data);\n var url = this.url + '/' + receiver.number + '?' + query;\n this.request = Runtime.createScriptRequest(url);\n this.request.send(receiver);\n }\n\n /** Cleans up the DOM remains of the JSONP request. */\n cleanup() {\n if (this.request) {\n this.request.cleanup();\n }\n }\n}\n","import TimelineSender from 'core/timeline/timeline_sender';\nimport TimelineTransport from 'core/timeline/timeline_transport';\nimport Browser from 'runtime';\nimport { AuthTransport } from 'core/auth/auth_transports';\nimport { ScriptReceivers } from '../dom/script_receiver_factory';\n\nvar getAgent = function(sender: TimelineSender, useTLS: boolean) {\n return function(data: any, callback: Function) {\n var scheme = 'http' + (useTLS ? 's' : '') + '://';\n var url =\n scheme + (sender.host || sender.options.host) + sender.options.path;\n var request = Browser.createJSONPRequest(url, data);\n\n var receiver = Browser.ScriptReceivers.create(function(error, result) {\n ScriptReceivers.remove(receiver);\n request.cleanup();\n\n if (result && result.host) {\n sender.host = result.host;\n }\n if (callback) {\n callback(error, result);\n }\n });\n request.send(receiver);\n };\n};\n\nvar jsonp = {\n name: 'jsonp',\n getAgent\n};\n\nexport default jsonp;\n","import Defaults from '../defaults';\nimport { default as URLScheme, URLSchemeParams } from './url_scheme';\n\nfunction getGenericURL(\n baseScheme: string,\n params: URLSchemeParams,\n path: string\n): string {\n var scheme = baseScheme + (params.useTLS ? 's' : '');\n var host = params.useTLS ? params.hostTLS : params.hostNonTLS;\n return scheme + '://' + host + path;\n}\n\nfunction getGenericPath(key: string, queryString?: string): string {\n var path = '/app/' + key;\n var query =\n '?protocol=' +\n Defaults.PROTOCOL +\n '&client=js' +\n '&version=' +\n Defaults.VERSION +\n (queryString ? '&' + queryString : '');\n return path + query;\n}\n\nexport var ws: URLScheme = {\n getInitial: function(key: string, params: URLSchemeParams): string {\n var path = (params.httpPath || '') + getGenericPath(key, 'flash=false');\n return getGenericURL('ws', params, path);\n }\n};\n\nexport var http: URLScheme = {\n getInitial: function(key: string, params: URLSchemeParams): string {\n var path = (params.httpPath || '/pusher') + getGenericPath(key);\n return getGenericURL('http', params, path);\n }\n};\n\nexport var sockjs: URLScheme = {\n getInitial: function(key: string, params: URLSchemeParams): string {\n return getGenericURL('http', params, params.httpPath || '/pusher');\n },\n getPath: function(key: string, params: URLSchemeParams): string {\n return getGenericPath(key);\n }\n};\n","import Callback from './callback';\nimport * as Collections from '../utils/collections';\nimport CallbackTable from './callback_table';\n\nexport default class CallbackRegistry {\n _callbacks: CallbackTable;\n\n constructor() {\n this._callbacks = {};\n }\n\n get(name: string): Callback[] {\n return this._callbacks[prefix(name)];\n }\n\n add(name: string, callback: Function, context: any) {\n var prefixedEventName = prefix(name);\n this._callbacks[prefixedEventName] =\n this._callbacks[prefixedEventName] || [];\n this._callbacks[prefixedEventName].push({\n fn: callback,\n context: context\n });\n }\n\n remove(name?: string, callback?: Function, context?: any) {\n if (!name && !callback && !context) {\n this._callbacks = {};\n return;\n }\n\n var names = name ? [prefix(name)] : Collections.keys(this._callbacks);\n\n if (callback || context) {\n this.removeCallback(names, callback, context);\n } else {\n this.removeAllCallbacks(names);\n }\n }\n\n private removeCallback(names: string[], callback: Function, context: any) {\n Collections.apply(\n names,\n function(name) {\n this._callbacks[name] = Collections.filter(\n this._callbacks[name] || [],\n function(binding) {\n return (\n (callback && callback !== binding.fn) ||\n (context && context !== binding.context)\n );\n }\n );\n if (this._callbacks[name].length === 0) {\n delete this._callbacks[name];\n }\n },\n this\n );\n }\n\n private removeAllCallbacks(names: string[]) {\n Collections.apply(\n names,\n function(name) {\n delete this._callbacks[name];\n },\n this\n );\n }\n}\n\nfunction prefix(name: string): string {\n return '_' + name;\n}\n","import * as Collections from '../utils/collections';\nimport Callback from './callback';\nimport Metadata from '../channels/metadata';\nimport CallbackRegistry from './callback_registry';\n\n/** Manages callback bindings and event emitting.\n *\n * @param Function failThrough called when no listeners are bound to an event\n */\nexport default class Dispatcher {\n callbacks: CallbackRegistry;\n global_callbacks: Function[];\n failThrough: Function;\n\n constructor(failThrough?: Function) {\n this.callbacks = new CallbackRegistry();\n this.global_callbacks = [];\n this.failThrough = failThrough;\n }\n\n bind(eventName: string, callback: Function, context?: any) {\n this.callbacks.add(eventName, callback, context);\n return this;\n }\n\n bind_global(callback: Function) {\n this.global_callbacks.push(callback);\n return this;\n }\n\n unbind(eventName?: string, callback?: Function, context?: any) {\n this.callbacks.remove(eventName, callback, context);\n return this;\n }\n\n unbind_global(callback?: Function) {\n if (!callback) {\n this.global_callbacks = [];\n return this;\n }\n\n this.global_callbacks = Collections.filter(\n this.global_callbacks || [],\n c => c !== callback\n );\n\n return this;\n }\n\n unbind_all() {\n this.unbind();\n this.unbind_global();\n return this;\n }\n\n emit(eventName: string, data?: any, metadata?: Metadata): Dispatcher {\n for (var i = 0; i < this.global_callbacks.length; i++) {\n this.global_callbacks[i](eventName, data);\n }\n\n var callbacks = this.callbacks.get(eventName);\n var args = [];\n\n if (metadata) {\n // if there's a metadata argument, we need to call the callback with both\n // data and metadata regardless of whether data is undefined\n args.push(data, metadata);\n } else if (data) {\n // metadata is undefined, so we only need to call the callback with data\n // if data exists\n args.push(data);\n }\n\n if (callbacks && callbacks.length > 0) {\n for (var i = 0; i < callbacks.length; i++) {\n callbacks[i].fn.apply(callbacks[i].context || global, args);\n }\n } else if (this.failThrough) {\n this.failThrough(eventName, data);\n }\n\n return this;\n }\n}\n","import Util from '../util';\nimport * as Collections from '../utils/collections';\nimport { default as EventsDispatcher } from '../events/dispatcher';\nimport Logger from '../logger';\nimport TransportHooks from './transport_hooks';\nimport Socket from '../socket';\nimport Runtime from 'runtime';\nimport Timeline from '../timeline/timeline';\nimport TransportConnectionOptions from './transport_connection_options';\n\n/** Provides universal API for transport connections.\n *\n * Transport connection is a low-level object that wraps a connection method\n * and exposes a simple evented interface for the connection state and\n * messaging. It does not implement Pusher-specific WebSocket protocol.\n *\n * Additionally, it fetches resources needed for transport to work and exposes\n * an interface for querying transport features.\n *\n * States:\n * - new - initial state after constructing the object\n * - initializing - during initialization phase, usually fetching resources\n * - intialized - ready to establish a connection\n * - connection - when connection is being established\n * - open - when connection ready to be used\n * - closed - after connection was closed be either side\n *\n * Emits:\n * - error - after the connection raised an error\n *\n * Options:\n * - useTLS - whether connection should be over TLS\n * - hostTLS - host to connect to when connection is over TLS\n * - hostNonTLS - host to connect to when connection is over TLS\n *\n * @param {String} key application key\n * @param {Object} options\n */\nexport default class TransportConnection extends EventsDispatcher {\n hooks: TransportHooks;\n name: string;\n priority: number;\n key: string;\n options: TransportConnectionOptions;\n state: string;\n timeline: Timeline;\n activityTimeout: number;\n id: number;\n socket: Socket;\n beforeOpen: Function;\n initialize: Function;\n\n constructor(\n hooks: TransportHooks,\n name: string,\n priority: number,\n key: string,\n options: TransportConnectionOptions\n ) {\n super();\n this.initialize = Runtime.transportConnectionInitializer;\n this.hooks = hooks;\n this.name = name;\n this.priority = priority;\n this.key = key;\n this.options = options;\n\n this.state = 'new';\n this.timeline = options.timeline;\n this.activityTimeout = options.activityTimeout;\n this.id = this.timeline.generateUniqueID();\n }\n\n /** Checks whether the transport handles activity checks by itself.\n *\n * @return {Boolean}\n */\n handlesActivityChecks(): boolean {\n return Boolean(this.hooks.handlesActivityChecks);\n }\n\n /** Checks whether the transport supports the ping/pong API.\n *\n * @return {Boolean}\n */\n supportsPing(): boolean {\n return Boolean(this.hooks.supportsPing);\n }\n\n /** Tries to establish a connection.\n *\n * @returns {Boolean} false if transport is in invalid state\n */\n connect(): boolean {\n if (this.socket || this.state !== 'initialized') {\n return false;\n }\n\n var url = this.hooks.urls.getInitial(this.key, this.options);\n try {\n this.socket = this.hooks.getSocket(url, this.options);\n } catch (e) {\n Util.defer(() => {\n this.onError(e);\n this.changeState('closed');\n });\n return false;\n }\n\n this.bindListeners();\n\n Logger.debug('Connecting', { transport: this.name, url });\n this.changeState('connecting');\n return true;\n }\n\n /** Closes the connection.\n *\n * @return {Boolean} true if there was a connection to close\n */\n close(): boolean {\n if (this.socket) {\n this.socket.close();\n return true;\n } else {\n return false;\n }\n }\n\n /** Sends data over the open connection.\n *\n * @param {String} data\n * @return {Boolean} true only when in the \"open\" state\n */\n send(data: any): boolean {\n if (this.state === 'open') {\n // Workaround for MobileSafari bug (see https://gist.github.com/2052006)\n Util.defer(() => {\n if (this.socket) {\n this.socket.send(data);\n }\n });\n return true;\n } else {\n return false;\n }\n }\n\n /** Sends a ping if the connection is open and transport supports it. */\n ping() {\n if (this.state === 'open' && this.supportsPing()) {\n this.socket.ping();\n }\n }\n\n private onOpen() {\n if (this.hooks.beforeOpen) {\n this.hooks.beforeOpen(\n this.socket,\n this.hooks.urls.getPath(this.key, this.options)\n );\n }\n this.changeState('open');\n this.socket.onopen = undefined;\n }\n\n private onError(error) {\n this.emit('error', { type: 'WebSocketError', error: error });\n this.timeline.error(this.buildTimelineMessage({ error: error.toString() }));\n }\n\n private onClose(closeEvent?: any) {\n if (closeEvent) {\n this.changeState('closed', {\n code: closeEvent.code,\n reason: closeEvent.reason,\n wasClean: closeEvent.wasClean\n });\n } else {\n this.changeState('closed');\n }\n this.unbindListeners();\n this.socket = undefined;\n }\n\n private onMessage(message) {\n this.emit('message', message);\n }\n\n private onActivity() {\n this.emit('activity');\n }\n\n private bindListeners() {\n this.socket.onopen = () => {\n this.onOpen();\n };\n this.socket.onerror = error => {\n this.onError(error);\n };\n this.socket.onclose = closeEvent => {\n this.onClose(closeEvent);\n };\n this.socket.onmessage = message => {\n this.onMessage(message);\n };\n\n if (this.supportsPing()) {\n this.socket.onactivity = () => {\n this.onActivity();\n };\n }\n }\n\n private unbindListeners() {\n if (this.socket) {\n this.socket.onopen = undefined;\n this.socket.onerror = undefined;\n this.socket.onclose = undefined;\n this.socket.onmessage = undefined;\n if (this.supportsPing()) {\n this.socket.onactivity = undefined;\n }\n }\n }\n\n private changeState(state: string, params?: any) {\n this.state = state;\n this.timeline.info(\n this.buildTimelineMessage({\n state: state,\n params: params\n })\n );\n this.emit(state, params);\n }\n\n buildTimelineMessage(message): any {\n return Collections.extend({ cid: this.id }, message);\n }\n}\n","import Factory from '../utils/factory';\nimport TransportHooks from './transport_hooks';\nimport TransportConnection from './transport_connection';\nimport TransportConnectionOptions from './transport_connection_options';\n\n/** Provides interface for transport connection instantiation.\n *\n * Takes transport-specific hooks as the only argument, which allow checking\n * for transport support and creating its connections.\n *\n * Supported hooks: * - file - the name of the file to be fetched during initialization\n * - urls - URL scheme to be used by transport\n * - handlesActivityCheck - true when the transport handles activity checks\n * - supportsPing - true when the transport has a ping/activity API\n * - isSupported - tells whether the transport is supported in the environment\n * - getSocket - creates a WebSocket-compatible transport socket\n *\n * See transports.js for specific implementations.\n *\n * @param {Object} hooks object containing all needed transport hooks\n */\nexport default class Transport {\n hooks: TransportHooks;\n\n constructor(hooks: TransportHooks) {\n this.hooks = hooks;\n }\n\n /** Returns whether the transport is supported in the environment.\n *\n * @param {Object} envronment te environment details (encryption, settings)\n * @returns {Boolean} true when the transport is supported\n */\n isSupported(environment: any): boolean {\n return this.hooks.isSupported(environment);\n }\n\n /** Creates a transport connection.\n *\n * @param {String} name\n * @param {Number} priority\n * @param {String} key the application key\n * @param {Object} options\n * @returns {TransportConnection}\n */\n createConnection(\n name: string,\n priority: number,\n key: string,\n options: any\n ): TransportConnection {\n return new TransportConnection(this.hooks, name, priority, key, options);\n }\n}\n","import * as URLSchemes from 'core/transports/url_schemes';\nimport URLScheme from 'core/transports/url_scheme';\nimport Transport from 'core/transports/transport';\nimport Util from 'core/util';\nimport * as Collections from 'core/utils/collections';\nimport TransportHooks from 'core/transports/transport_hooks';\nimport TransportsTable from 'core/transports/transports_table';\nimport Runtime from 'runtime';\n\n/** WebSocket transport.\n *\n * Uses native WebSocket implementation, including MozWebSocket supported by\n * earlier Firefox versions.\n */\nvar WSTransport = new Transport({\n urls: URLSchemes.ws,\n handlesActivityChecks: false,\n supportsPing: false,\n\n isInitialized: function() {\n return Boolean(Runtime.getWebSocketAPI());\n },\n isSupported: function(): boolean {\n return Boolean(Runtime.getWebSocketAPI());\n },\n getSocket: function(url) {\n return Runtime.createWebSocket(url);\n }\n});\n\nvar httpConfiguration = {\n urls: URLSchemes.http,\n handlesActivityChecks: false,\n supportsPing: true,\n isInitialized: function() {\n return true;\n }\n};\n\nexport var streamingConfiguration = Collections.extend(\n {\n getSocket: function(url) {\n return Runtime.HTTPFactory.createStreamingSocket(url);\n }\n },\n httpConfiguration\n);\nexport var pollingConfiguration = Collections.extend(\n {\n getSocket: function(url) {\n return Runtime.HTTPFactory.createPollingSocket(url);\n }\n },\n httpConfiguration\n);\n\nvar xhrConfiguration = {\n isSupported: function(): boolean {\n return Runtime.isXHRSupported();\n }\n};\n\n/** HTTP streaming transport using CORS-enabled XMLHttpRequest. */\nvar XHRStreamingTransport = new Transport(\n (\n Collections.extend({}, streamingConfiguration, xhrConfiguration)\n )\n);\n\n/** HTTP long-polling transport using CORS-enabled XMLHttpRequest. */\nvar XHRPollingTransport = new Transport(\n Collections.extend({}, pollingConfiguration, xhrConfiguration)\n);\n\nvar Transports: TransportsTable = {\n ws: WSTransport,\n xhr_streaming: XHRStreamingTransport,\n xhr_polling: XHRPollingTransport\n};\n\nexport default Transports;\n","import {\n default as Transports,\n streamingConfiguration,\n pollingConfiguration\n} from 'isomorphic/transports/transports';\nimport Transport from 'core/transports/transport';\nimport TransportHooks from 'core/transports/transport_hooks';\nimport * as URLSchemes from 'core/transports/url_schemes';\nimport Runtime from 'runtime';\nimport { Dependencies } from '../dom/dependencies';\nimport * as Collections from 'core/utils/collections';\n\nvar SockJSTransport = new Transport({\n file: 'sockjs',\n urls: URLSchemes.sockjs,\n handlesActivityChecks: true,\n supportsPing: false,\n\n isSupported: function() {\n return true;\n },\n isInitialized: function() {\n return window.SockJS !== undefined;\n },\n getSocket: function(url, options) {\n return new window.SockJS(url, null, {\n js_path: Dependencies.getPath('sockjs', {\n useTLS: options.useTLS\n }),\n ignore_null_origin: options.ignoreNullOrigin\n });\n },\n beforeOpen: function(socket, path) {\n socket.send(\n JSON.stringify({\n path: path\n })\n );\n }\n});\n\nvar xdrConfiguration = {\n isSupported: function(environment): boolean {\n var yes = Runtime.isXDRSupported(environment.useTLS);\n return yes;\n }\n};\n\n/** HTTP streaming transport using XDomainRequest (IE 8,9). */\nvar XDRStreamingTransport = new Transport(\n (\n Collections.extend({}, streamingConfiguration, xdrConfiguration)\n )\n);\n\n/** HTTP long-polling transport using XDomainRequest (IE 8,9). */\nvar XDRPollingTransport = new Transport(\n Collections.extend({}, pollingConfiguration, xdrConfiguration)\n);\n\nTransports.xdr_streaming = XDRStreamingTransport;\nTransports.xdr_polling = XDRPollingTransport;\nTransports.sockjs = SockJSTransport;\n\nexport default Transports;\n","import Reachability from 'core/reachability';\nimport { default as EventsDispatcher } from 'core/events/dispatcher';\n\n/** Really basic interface providing network availability info.\n *\n * Emits:\n * - online - when browser goes online\n * - offline - when browser goes offline\n */\nexport class NetInfo extends EventsDispatcher implements Reachability {\n constructor() {\n super();\n var self = this;\n // This is okay, as IE doesn't support this stuff anyway.\n if (window.addEventListener !== undefined) {\n window.addEventListener(\n 'online',\n function() {\n self.emit('online');\n },\n false\n );\n window.addEventListener(\n 'offline',\n function() {\n self.emit('offline');\n },\n false\n );\n }\n }\n\n /** Returns whether browser is online or not\n *\n * Offline means definitely offline (no connection to router).\n * Inverse does NOT mean definitely online (only currently supported in Safari\n * and even there only means the device has a connection to the router).\n *\n * @return {Boolean}\n */\n isOnline(): boolean {\n if (window.navigator.onLine === undefined) {\n return true;\n } else {\n return window.navigator.onLine;\n }\n }\n}\n\nexport var Network = new NetInfo();\n","import Util from '../util';\nimport * as Collections from '../utils/collections';\nimport TransportManager from './transport_manager';\nimport TransportConnection from './transport_connection';\nimport Transport from './transport';\nimport PingDelayOptions from './ping_delay_options';\n\n/** Creates transport connections monitored by a transport manager.\n *\n * When a transport is closed, it might mean the environment does not support\n * it. It's possible that messages get stuck in an intermediate buffer or\n * proxies terminate inactive connections. To combat these problems,\n * assistants monitor the connection lifetime, report unclean exits and\n * adjust ping timeouts to keep the connection active. The decision to disable\n * a transport is the manager's responsibility.\n *\n * @param {TransportManager} manager\n * @param {TransportConnection} transport\n * @param {Object} options\n */\nexport default class AssistantToTheTransportManager {\n manager: TransportManager;\n transport: Transport;\n minPingDelay: number;\n maxPingDelay: number;\n pingDelay: number;\n\n constructor(\n manager: TransportManager,\n transport: Transport,\n options: PingDelayOptions\n ) {\n this.manager = manager;\n this.transport = transport;\n this.minPingDelay = options.minPingDelay;\n this.maxPingDelay = options.maxPingDelay;\n this.pingDelay = undefined;\n }\n\n /** Creates a transport connection.\n *\n * This function has the same API as Transport#createConnection.\n *\n * @param {String} name\n * @param {Number} priority\n * @param {String} key the application key\n * @param {Object} options\n * @returns {TransportConnection}\n */\n createConnection(\n name: string,\n priority: number,\n key: string,\n options: Object\n ): TransportConnection {\n options = Collections.extend({}, options, {\n activityTimeout: this.pingDelay\n });\n var connection = this.transport.createConnection(\n name,\n priority,\n key,\n options\n );\n\n var openTimestamp = null;\n\n var onOpen = function() {\n connection.unbind('open', onOpen);\n connection.bind('closed', onClosed);\n openTimestamp = Util.now();\n };\n var onClosed = closeEvent => {\n connection.unbind('closed', onClosed);\n\n if (closeEvent.code === 1002 || closeEvent.code === 1003) {\n // we don't want to use transports not obeying the protocol\n this.manager.reportDeath();\n } else if (!closeEvent.wasClean && openTimestamp) {\n // report deaths only for short-living transport\n var lifespan = Util.now() - openTimestamp;\n if (lifespan < 2 * this.maxPingDelay) {\n this.manager.reportDeath();\n this.pingDelay = Math.max(lifespan / 2, this.minPingDelay);\n }\n }\n };\n\n connection.bind('open', onOpen);\n return connection;\n }\n\n /** Returns whether the transport is supported in the environment.\n *\n * This function has the same API as Transport#isSupported. Might return false\n * when the manager decides to kill the transport.\n *\n * @param {Object} environment the environment details (encryption, settings)\n * @returns {Boolean} true when the transport is supported\n */\n isSupported(environment: string): boolean {\n return this.manager.isAlive() && this.transport.isSupported(environment);\n }\n}\n","import Action from './action';\nimport { PusherEvent } from './message-types';\n/**\n * Provides functions for handling Pusher protocol-specific messages.\n */\n\nconst Protocol = {\n /**\n * Decodes a message in a Pusher format.\n *\n * The MessageEvent we receive from the transport should contain a pusher event\n * (https://pusher.com/docs/pusher_protocol#events) serialized as JSON in the\n * data field\n *\n * The pusher event may contain a data field too, and it may also be\n * serialised as JSON\n *\n * Throws errors when messages are not parse'able.\n *\n * @param {MessageEvent} messageEvent\n * @return {PusherEvent}\n */\n decodeMessage: function(messageEvent: MessageEvent): PusherEvent {\n try {\n var messageData = JSON.parse(messageEvent.data);\n var pusherEventData = messageData.data;\n if (typeof pusherEventData === 'string') {\n try {\n pusherEventData = JSON.parse(messageData.data);\n } catch (e) {}\n }\n var pusherEvent: PusherEvent = {\n event: messageData.event,\n channel: messageData.channel,\n data: pusherEventData\n };\n if (messageData.user_id) {\n pusherEvent.user_id = messageData.user_id;\n }\n return pusherEvent;\n } catch (e) {\n throw { type: 'MessageParseError', error: e, data: messageEvent.data };\n }\n },\n\n /**\n * Encodes a message to be sent.\n *\n * @param {PusherEvent} event\n * @return {String}\n */\n encodeMessage: function(event: PusherEvent): string {\n return JSON.stringify(event);\n },\n\n /**\n * Processes a handshake message and returns appropriate actions.\n *\n * Returns an object with an 'action' and other action-specific properties.\n *\n * There are three outcomes when calling this function. First is a successful\n * connection attempt, when pusher:connection_established is received, which\n * results in a 'connected' action with an 'id' property. When passed a\n * pusher:error event, it returns a result with action appropriate to the\n * close code and an error. Otherwise, it raises an exception.\n *\n * @param {String} message\n * @result Object\n */\n processHandshake: function(messageEvent: MessageEvent): Action {\n var message = Protocol.decodeMessage(messageEvent);\n\n if (message.event === 'pusher:connection_established') {\n if (!message.data.activity_timeout) {\n throw 'No activity timeout specified in handshake';\n }\n return {\n action: 'connected',\n id: message.data.socket_id,\n activityTimeout: message.data.activity_timeout * 1000\n };\n } else if (message.event === 'pusher:error') {\n // From protocol 6 close codes are sent only once, so this only\n // happens when connection does not support close codes\n return {\n action: this.getCloseAction(message.data),\n error: this.getCloseError(message.data)\n };\n } else {\n throw 'Invalid handshake';\n }\n },\n\n /**\n * Dispatches the close event and returns an appropriate action name.\n *\n * See:\n * 1. https://developer.mozilla.org/en-US/docs/WebSockets/WebSockets_reference/CloseEvent\n * 2. http://pusher.com/docs/pusher_protocol\n *\n * @param {CloseEvent} closeEvent\n * @return {String} close action name\n */\n getCloseAction: function(closeEvent): string {\n if (closeEvent.code < 4000) {\n // ignore 1000 CLOSE_NORMAL, 1001 CLOSE_GOING_AWAY,\n // 1005 CLOSE_NO_STATUS, 1006 CLOSE_ABNORMAL\n // ignore 1007...3999\n // handle 1002 CLOSE_PROTOCOL_ERROR, 1003 CLOSE_UNSUPPORTED,\n // 1004 CLOSE_TOO_LARGE\n if (closeEvent.code >= 1002 && closeEvent.code <= 1004) {\n return 'backoff';\n } else {\n return null;\n }\n } else if (closeEvent.code === 4000) {\n return 'tls_only';\n } else if (closeEvent.code < 4100) {\n return 'refused';\n } else if (closeEvent.code < 4200) {\n return 'backoff';\n } else if (closeEvent.code < 4300) {\n return 'retry';\n } else {\n // unknown error\n return 'refused';\n }\n },\n\n /**\n * Returns an error or null basing on the close event.\n *\n * Null is returned when connection was closed cleanly. Otherwise, an object\n * with error details is returned.\n *\n * @param {CloseEvent} closeEvent\n * @return {Object} error object\n */\n getCloseError: function(closeEvent): any {\n if (closeEvent.code !== 1000 && closeEvent.code !== 1001) {\n return {\n type: 'PusherError',\n data: {\n code: closeEvent.code,\n message: closeEvent.reason || closeEvent.message\n }\n };\n } else {\n return null;\n }\n }\n};\n\nexport default Protocol;\n","import * as Collections from '../utils/collections';\nimport { default as EventsDispatcher } from '../events/dispatcher';\nimport Protocol from './protocol/protocol';\nimport { PusherEvent } from './protocol/message-types';\nimport Logger from '../logger';\nimport TransportConnection from '../transports/transport_connection';\nimport Socket from '../socket';\n/**\n * Provides Pusher protocol interface for transports.\n *\n * Emits following events:\n * - message - on received messages\n * - ping - on ping requests\n * - pong - on pong responses\n * - error - when the transport emits an error\n * - closed - after closing the transport\n *\n * It also emits more events when connection closes with a code.\n * See Protocol.getCloseAction to get more details.\n *\n * @param {Number} id\n * @param {AbstractTransport} transport\n */\nexport default class Connection extends EventsDispatcher implements Socket {\n id: string;\n transport: TransportConnection;\n activityTimeout: number;\n\n constructor(id: string, transport: TransportConnection) {\n super();\n this.id = id;\n this.transport = transport;\n this.activityTimeout = transport.activityTimeout;\n this.bindListeners();\n }\n\n /** Returns whether used transport handles activity checks by itself\n *\n * @returns {Boolean} true if activity checks are handled by the transport\n */\n handlesActivityChecks() {\n return this.transport.handlesActivityChecks();\n }\n\n /** Sends raw data.\n *\n * @param {String} data\n */\n send(data: any): boolean {\n return this.transport.send(data);\n }\n\n /** Sends an event.\n *\n * @param {String} name\n * @param {String} data\n * @param {String} [channel]\n * @returns {Boolean} whether message was sent or not\n */\n send_event(name: string, data: any, channel?: string): boolean {\n var event: PusherEvent = { event: name, data: data };\n if (channel) {\n event.channel = channel;\n }\n Logger.debug('Event sent', event);\n return this.send(Protocol.encodeMessage(event));\n }\n\n /** Sends a ping message to the server.\n *\n * Basing on the underlying transport, it might send either transport's\n * protocol-specific ping or pusher:ping event.\n */\n ping() {\n if (this.transport.supportsPing()) {\n this.transport.ping();\n } else {\n this.send_event('pusher:ping', {});\n }\n }\n\n /** Closes the connection. */\n close() {\n this.transport.close();\n }\n\n private bindListeners() {\n var listeners = {\n message: (messageEvent: MessageEvent) => {\n var pusherEvent;\n try {\n pusherEvent = Protocol.decodeMessage(messageEvent);\n } catch (e) {\n this.emit('error', {\n type: 'MessageParseError',\n error: e,\n data: messageEvent.data\n });\n }\n\n if (pusherEvent !== undefined) {\n Logger.debug('Event recd', pusherEvent);\n\n switch (pusherEvent.event) {\n case 'pusher:error':\n this.emit('error', {\n type: 'PusherError',\n data: pusherEvent.data\n });\n break;\n case 'pusher:ping':\n this.emit('ping');\n break;\n case 'pusher:pong':\n this.emit('pong');\n break;\n }\n this.emit('message', pusherEvent);\n }\n },\n activity: () => {\n this.emit('activity');\n },\n error: error => {\n this.emit('error', error);\n },\n closed: closeEvent => {\n unbindListeners();\n\n if (closeEvent && closeEvent.code) {\n this.handleCloseEvent(closeEvent);\n }\n\n this.transport = null;\n this.emit('closed');\n }\n };\n\n var unbindListeners = () => {\n Collections.objectApply(listeners, (listener, event) => {\n this.transport.unbind(event, listener);\n });\n };\n\n Collections.objectApply(listeners, (listener, event) => {\n this.transport.bind(event, listener);\n });\n }\n\n private handleCloseEvent(closeEvent: any) {\n var action = Protocol.getCloseAction(closeEvent);\n var error = Protocol.getCloseError(closeEvent);\n if (error) {\n this.emit('error', error);\n }\n if (action) {\n this.emit(action, { action: action, error: error });\n }\n }\n}\n","import Util from '../../util';\nimport * as Collections from '../../utils/collections';\nimport Protocol from '../protocol/protocol';\nimport Connection from '../connection';\nimport TransportConnection from '../../transports/transport_connection';\nimport HandshakePayload from './handshake_payload';\n\n/**\n * Handles Pusher protocol handshakes for transports.\n *\n * Calls back with a result object after handshake is completed. Results\n * always have two fields:\n * - action - string describing action to be taken after the handshake\n * - transport - the transport object passed to the constructor\n *\n * Different actions can set different additional properties on the result.\n * In the case of 'connected' action, there will be a 'connection' property\n * containing a Connection object for the transport. Other actions should\n * carry an 'error' property.\n *\n * @param {AbstractTransport} transport\n * @param {Function} callback\n */\nexport default class Handshake {\n transport: TransportConnection;\n callback: (HandshakePayload) => void;\n onMessage: Function;\n onClosed: Function;\n\n constructor(\n transport: TransportConnection,\n callback: (HandshakePayload) => void\n ) {\n this.transport = transport;\n this.callback = callback;\n this.bindListeners();\n }\n\n close() {\n this.unbindListeners();\n this.transport.close();\n }\n\n private bindListeners() {\n this.onMessage = m => {\n this.unbindListeners();\n\n var result;\n try {\n result = Protocol.processHandshake(m);\n } catch (e) {\n this.finish('error', { error: e });\n this.transport.close();\n return;\n }\n\n if (result.action === 'connected') {\n this.finish('connected', {\n connection: new Connection(result.id, this.transport),\n activityTimeout: result.activityTimeout\n });\n } else {\n this.finish(result.action, { error: result.error });\n this.transport.close();\n }\n };\n\n this.onClosed = closeEvent => {\n this.unbindListeners();\n\n var action = Protocol.getCloseAction(closeEvent) || 'backoff';\n var error = Protocol.getCloseError(closeEvent);\n this.finish(action, { error: error });\n };\n\n this.transport.bind('message', this.onMessage);\n this.transport.bind('closed', this.onClosed);\n }\n\n private unbindListeners() {\n this.transport.unbind('message', this.onMessage);\n this.transport.unbind('closed', this.onClosed);\n }\n\n private finish(action: string, params: any) {\n this.callback(\n Collections.extend({ transport: this.transport, action: action }, params)\n );\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport base64encode from '../base64';\nimport Timeline from './timeline';\nimport Runtime from 'runtime';\n\nexport interface TimelineSenderOptions {\n host?: string;\n port?: number;\n path?: string;\n}\n\nexport default class TimelineSender {\n timeline: Timeline;\n options: TimelineSenderOptions;\n host: string;\n\n constructor(timeline: Timeline, options: TimelineSenderOptions) {\n this.timeline = timeline;\n this.options = options || {};\n }\n\n send(useTLS: boolean, callback?: Function) {\n if (this.timeline.isEmpty()) {\n return;\n }\n\n this.timeline.send(\n Runtime.TimelineTransport.getAgent(this, useTLS),\n callback\n );\n }\n}\n","import { default as EventsDispatcher } from '../events/dispatcher';\nimport * as Errors from '../errors';\nimport Logger from '../logger';\nimport Pusher from '../pusher';\nimport { PusherEvent } from '../connection/protocol/message-types';\nimport Metadata from './metadata';\nimport UrlStore from '../utils/url_store';\nimport {\n ChannelAuthorizationData,\n ChannelAuthorizationCallback\n} from '../auth/options';\nimport { HTTPAuthError } from '../errors';\n\n/** Provides base public channel interface with an event emitter.\n *\n * Emits:\n * - pusher:subscription_succeeded - after subscribing successfully\n * - other non-internal events\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\nexport default class Channel extends EventsDispatcher {\n name: string;\n pusher: Pusher;\n subscribed: boolean;\n subscriptionPending: boolean;\n subscriptionCancelled: boolean;\n subscriptionCount: null;\n\n constructor(name: string, pusher: Pusher) {\n super(function(event, data) {\n Logger.debug('No callbacks on ' + name + ' for ' + event);\n });\n\n this.name = name;\n this.pusher = pusher;\n this.subscribed = false;\n this.subscriptionPending = false;\n this.subscriptionCancelled = false;\n }\n\n /** Skips authorization, since public channels don't require it.\n *\n * @param {Function} callback\n */\n authorize(socketId: string, callback: ChannelAuthorizationCallback) {\n return callback(null, { auth: '' });\n }\n\n /** Triggers an event */\n trigger(event: string, data: any) {\n if (event.indexOf('client-') !== 0) {\n throw new Errors.BadEventName(\n \"Event '\" + event + \"' does not start with 'client-'\"\n );\n }\n if (!this.subscribed) {\n var suffix = UrlStore.buildLogSuffix('triggeringClientEvents');\n Logger.warn(\n `Client event triggered before channel 'subscription_succeeded' event . ${suffix}`\n );\n }\n return this.pusher.send_event(event, data, this.name);\n }\n\n /** Signals disconnection to the channel. For internal use only. */\n disconnect() {\n this.subscribed = false;\n this.subscriptionPending = false;\n }\n\n /** Handles a PusherEvent. For internal use only.\n *\n * @param {PusherEvent} event\n */\n handleEvent(event: PusherEvent) {\n var eventName = event.event;\n var data = event.data;\n if (eventName === 'pusher_internal:subscription_succeeded') {\n this.handleSubscriptionSucceededEvent(event);\n } else if (eventName === 'pusher_internal:subscription_count') {\n this.handleSubscriptionCountEvent(event);\n } else if (eventName.indexOf('pusher_internal:') !== 0) {\n var metadata: Metadata = {};\n this.emit(eventName, data, metadata);\n }\n }\n\n handleSubscriptionSucceededEvent(event: PusherEvent) {\n this.subscriptionPending = false;\n this.subscribed = true;\n if (this.subscriptionCancelled) {\n this.pusher.unsubscribe(this.name);\n } else {\n this.emit('pusher:subscription_succeeded', event.data);\n }\n }\n\n handleSubscriptionCountEvent(event: PusherEvent) {\n if (event.data.subscription_count) {\n this.subscriptionCount = event.data.subscription_count;\n }\n\n this.emit('pusher:subscription_count', event.data);\n }\n\n /** Sends a subscription request. For internal use only. */\n subscribe() {\n if (this.subscribed) {\n return;\n }\n this.subscriptionPending = true;\n this.subscriptionCancelled = false;\n this.authorize(\n this.pusher.connection.socket_id,\n (error: Error | null, data: ChannelAuthorizationData) => {\n if (error) {\n this.subscriptionPending = false;\n // Why not bind to 'pusher:subscription_error' a level up, and log there?\n // Binding to this event would cause the warning about no callbacks being\n // bound (see constructor) to be suppressed, that's not what we want.\n Logger.error(error.toString());\n this.emit(\n 'pusher:subscription_error',\n Object.assign(\n {},\n {\n type: 'AuthError',\n error: error.message\n },\n error instanceof HTTPAuthError ? { status: error.status } : {}\n )\n );\n } else {\n this.pusher.send_event('pusher:subscribe', {\n auth: data.auth,\n channel_data: data.channel_data,\n channel: this.name\n });\n }\n }\n );\n }\n\n /** Sends an unsubscription request. For internal use only. */\n unsubscribe() {\n this.subscribed = false;\n this.pusher.send_event('pusher:unsubscribe', {\n channel: this.name\n });\n }\n\n /** Cancels an in progress subscription. For internal use only. */\n cancelSubscription() {\n this.subscriptionCancelled = true;\n }\n\n /** Reinstates an in progress subscripiton. For internal use only. */\n reinstateSubscription() {\n this.subscriptionCancelled = false;\n }\n}\n","import Factory from '../utils/factory';\nimport Channel from './channel';\nimport { ChannelAuthorizationCallback } from '../auth/options';\n\n/** Extends public channels to provide private channel interface.\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\nexport default class PrivateChannel extends Channel {\n /** Authorizes the connection to use the channel.\n *\n * @param {String} socketId\n * @param {Function} callback\n */\n authorize(socketId: string, callback: ChannelAuthorizationCallback) {\n return this.pusher.config.channelAuthorizer(\n {\n channelName: this.name,\n socketId: socketId\n },\n callback\n );\n }\n}\n","import * as Collections from '../utils/collections';\n\n/** Represents a collection of members of a presence channel. */\nexport default class Members {\n members: any;\n count: number;\n myID: any;\n me: any;\n\n constructor() {\n this.reset();\n }\n\n /** Returns member's info for given id.\n *\n * Resulting object containts two fields - id and info.\n *\n * @param {Number} id\n * @return {Object} member's info or null\n */\n get(id: string): any {\n if (Object.prototype.hasOwnProperty.call(this.members, id)) {\n return {\n id: id,\n info: this.members[id]\n };\n } else {\n return null;\n }\n }\n\n /** Calls back for each member in unspecified order.\n *\n * @param {Function} callback\n */\n each(callback: Function) {\n Collections.objectApply(this.members, (member, id) => {\n callback(this.get(id));\n });\n }\n\n /** Updates the id for connected member. For internal use only. */\n setMyID(id: string) {\n this.myID = id;\n }\n\n /** Handles subscription data. For internal use only. */\n onSubscription(subscriptionData: any) {\n this.members = subscriptionData.presence.hash;\n this.count = subscriptionData.presence.count;\n this.me = this.get(this.myID);\n }\n\n /** Adds a new member to the collection. For internal use only. */\n addMember(memberData: any) {\n if (this.get(memberData.user_id) === null) {\n this.count++;\n }\n this.members[memberData.user_id] = memberData.user_info;\n return this.get(memberData.user_id);\n }\n\n /** Adds a member from the collection. For internal use only. */\n removeMember(memberData: any) {\n var member = this.get(memberData.user_id);\n if (member) {\n delete this.members[memberData.user_id];\n this.count--;\n }\n return member;\n }\n\n /** Resets the collection to the initial state. For internal use only. */\n reset() {\n this.members = {};\n this.count = 0;\n this.myID = null;\n this.me = null;\n }\n}\n","import PrivateChannel from './private_channel';\nimport Logger from '../logger';\nimport Members from './members';\nimport Pusher from '../pusher';\nimport UrlStore from 'core/utils/url_store';\nimport { PusherEvent } from '../connection/protocol/message-types';\nimport Metadata from './metadata';\nimport { ChannelAuthorizationData } from '../auth/options';\n\nexport default class PresenceChannel extends PrivateChannel {\n members: Members;\n\n /** Adds presence channel functionality to private channels.\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\n constructor(name: string, pusher: Pusher) {\n super(name, pusher);\n this.members = new Members();\n }\n\n /** Authorizes the connection as a member of the channel.\n *\n * @param {String} socketId\n * @param {Function} callback\n */\n authorize(socketId: string, callback: Function) {\n super.authorize(socketId, async (error, authData) => {\n if (!error) {\n authData = authData as ChannelAuthorizationData;\n if (authData.channel_data != null) {\n var channelData = JSON.parse(authData.channel_data);\n this.members.setMyID(channelData.user_id);\n } else {\n await this.pusher.user.signinDonePromise;\n if (this.pusher.user.user_data != null) {\n // If the user is signed in, get the id of the authenticated user\n // and allow the presence authorization to continue.\n this.members.setMyID(this.pusher.user.user_data.id);\n } else {\n let suffix = UrlStore.buildLogSuffix('authorizationEndpoint');\n Logger.error(\n `Invalid auth response for channel '${this.name}', ` +\n `expected 'channel_data' field. ${suffix}, ` +\n `or the user should be signed in.`\n );\n callback('Invalid auth response');\n return;\n }\n }\n }\n callback(error, authData);\n });\n }\n\n /** Handles presence and subscription events. For internal use only.\n *\n * @param {PusherEvent} event\n */\n handleEvent(event: PusherEvent) {\n var eventName = event.event;\n if (eventName.indexOf('pusher_internal:') === 0) {\n this.handleInternalEvent(event);\n } else {\n var data = event.data;\n var metadata: Metadata = {};\n if (event.user_id) {\n metadata.user_id = event.user_id;\n }\n this.emit(eventName, data, metadata);\n }\n }\n handleInternalEvent(event: PusherEvent) {\n var eventName = event.event;\n var data = event.data;\n switch (eventName) {\n case 'pusher_internal:subscription_succeeded':\n this.handleSubscriptionSucceededEvent(event);\n break;\n case 'pusher_internal:subscription_count':\n this.handleSubscriptionCountEvent(event);\n break;\n case 'pusher_internal:member_added':\n var addedMember = this.members.addMember(data);\n this.emit('pusher:member_added', addedMember);\n break;\n case 'pusher_internal:member_removed':\n var removedMember = this.members.removeMember(data);\n if (removedMember) {\n this.emit('pusher:member_removed', removedMember);\n }\n break;\n }\n }\n\n handleSubscriptionSucceededEvent(event: PusherEvent) {\n this.subscriptionPending = false;\n this.subscribed = true;\n if (this.subscriptionCancelled) {\n this.pusher.unsubscribe(this.name);\n } else {\n this.members.onSubscription(event.data);\n this.emit('pusher:subscription_succeeded', this.members);\n }\n }\n\n /** Resets the channel state, including members map. For internal use only. */\n disconnect() {\n this.members.reset();\n super.disconnect();\n }\n}\n","import PrivateChannel from './private_channel';\nimport * as Errors from '../errors';\nimport Logger from '../logger';\nimport Pusher from '../pusher';\nimport { decode as encodeUTF8 } from '@stablelib/utf8';\nimport { decode as decodeBase64 } from '@stablelib/base64';\nimport Dispatcher from '../events/dispatcher';\nimport { PusherEvent } from '../connection/protocol/message-types';\nimport {\n ChannelAuthorizationData,\n ChannelAuthorizationCallback\n} from '../auth/options';\nimport * as nacl from 'tweetnacl';\n\n/** Extends private channels to provide encrypted channel interface.\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\nexport default class EncryptedChannel extends PrivateChannel {\n key: Uint8Array = null;\n nacl: nacl;\n\n constructor(name: string, pusher: Pusher, nacl: nacl) {\n super(name, pusher);\n this.nacl = nacl;\n }\n\n /** Authorizes the connection to use the channel.\n *\n * @param {String} socketId\n * @param {Function} callback\n */\n authorize(socketId: string, callback: ChannelAuthorizationCallback) {\n super.authorize(\n socketId,\n (error: Error | null, authData: ChannelAuthorizationData) => {\n if (error) {\n callback(error, authData);\n return;\n }\n let sharedSecret = authData['shared_secret'];\n if (!sharedSecret) {\n callback(\n new Error(\n `No shared_secret key in auth payload for encrypted channel: ${this.name}`\n ),\n null\n );\n return;\n }\n this.key = decodeBase64(sharedSecret);\n delete authData['shared_secret'];\n callback(null, authData);\n }\n );\n }\n\n trigger(event: string, data: any): boolean {\n throw new Errors.UnsupportedFeature(\n 'Client events are not currently supported for encrypted channels'\n );\n }\n\n /** Handles an event. For internal use only.\n *\n * @param {PusherEvent} event\n */\n handleEvent(event: PusherEvent) {\n var eventName = event.event;\n var data = event.data;\n if (\n eventName.indexOf('pusher_internal:') === 0 ||\n eventName.indexOf('pusher:') === 0\n ) {\n super.handleEvent(event);\n return;\n }\n this.handleEncryptedEvent(eventName, data);\n }\n\n private handleEncryptedEvent(event: string, data: any): void {\n if (!this.key) {\n Logger.debug(\n 'Received encrypted event before key has been retrieved from the authEndpoint'\n );\n return;\n }\n if (!data.ciphertext || !data.nonce) {\n Logger.error(\n 'Unexpected format for encrypted event, expected object with `ciphertext` and `nonce` fields, got: ' +\n data\n );\n return;\n }\n let cipherText = decodeBase64(data.ciphertext);\n if (cipherText.length < this.nacl.secretbox.overheadLength) {\n Logger.error(\n `Expected encrypted event ciphertext length to be ${this.nacl.secretbox.overheadLength}, got: ${cipherText.length}`\n );\n return;\n }\n let nonce = decodeBase64(data.nonce);\n if (nonce.length < this.nacl.secretbox.nonceLength) {\n Logger.error(\n `Expected encrypted event nonce length to be ${this.nacl.secretbox.nonceLength}, got: ${nonce.length}`\n );\n return;\n }\n\n let bytes = this.nacl.secretbox.open(cipherText, nonce, this.key);\n if (bytes === null) {\n Logger.debug(\n 'Failed to decrypt an event, probably because it was encrypted with a different key. Fetching a new key from the authEndpoint...'\n );\n // Try a single time to retrieve a new auth key and decrypt the event with it\n // If this fails, a new key will be requested when a new message is received\n this.authorize(this.pusher.connection.socket_id, (error, authData) => {\n if (error) {\n Logger.error(\n `Failed to make a request to the authEndpoint: ${authData}. Unable to fetch new key, so dropping encrypted event`\n );\n return;\n }\n bytes = this.nacl.secretbox.open(cipherText, nonce, this.key);\n if (bytes === null) {\n Logger.error(\n `Failed to decrypt event with new key. Dropping encrypted event`\n );\n return;\n }\n this.emit(event, this.getDataToEmit(bytes));\n return;\n });\n return;\n }\n this.emit(event, this.getDataToEmit(bytes));\n }\n\n // Try and parse the decrypted bytes as JSON. If we can't parse it, just\n // return the utf-8 string\n getDataToEmit(bytes: Uint8Array): string {\n let raw = encodeUTF8(bytes);\n try {\n return JSON.parse(raw);\n } catch {\n return raw;\n }\n }\n}\n","import { default as EventsDispatcher } from '../events/dispatcher';\nimport { OneOffTimer as Timer } from '../utils/timers';\nimport { Config } from '../config';\nimport Logger from '../logger';\nimport HandshakePayload from './handshake/handshake_payload';\nimport Connection from './connection';\nimport Strategy from '../strategies/strategy';\nimport StrategyRunner from '../strategies/strategy_runner';\nimport * as Collections from '../utils/collections';\nimport Timeline from '../timeline/timeline';\nimport ConnectionManagerOptions from './connection_manager_options';\nimport Runtime from 'runtime';\n\nimport {\n ErrorCallbacks,\n HandshakeCallbacks,\n ConnectionCallbacks\n} from './callbacks';\nimport Action from './protocol/action';\n\n/** Manages connection to Pusher.\n *\n * Uses a strategy (currently only default), timers and network availability\n * info to establish a connection and export its state. In case of failures,\n * manages reconnection attempts.\n *\n * Exports state changes as following events:\n * - \"state_change\", { previous: p, current: state }\n * - state\n *\n * States:\n * - initialized - initial state, never transitioned to\n * - connecting - connection is being established\n * - connected - connection has been fully established\n * - disconnected - on requested disconnection\n * - unavailable - after connection timeout or when there's no network\n * - failed - when the connection strategy is not supported\n *\n * Options:\n * - unavailableTimeout - time to transition to unavailable state\n * - activityTimeout - time after which ping message should be sent\n * - pongTimeout - time for Pusher to respond with pong before reconnecting\n *\n * @param {String} key application key\n * @param {Object} options\n */\nexport default class ConnectionManager extends EventsDispatcher {\n key: string;\n options: ConnectionManagerOptions;\n state: string;\n connection: Connection;\n usingTLS: boolean;\n timeline: Timeline;\n socket_id: string;\n unavailableTimer: Timer;\n activityTimer: Timer;\n retryTimer: Timer;\n activityTimeout: number;\n strategy: Strategy;\n runner: StrategyRunner;\n errorCallbacks: ErrorCallbacks;\n handshakeCallbacks: HandshakeCallbacks;\n connectionCallbacks: ConnectionCallbacks;\n\n constructor(key: string, options: ConnectionManagerOptions) {\n super();\n this.state = 'initialized';\n this.connection = null;\n\n this.key = key;\n this.options = options;\n this.timeline = this.options.timeline;\n this.usingTLS = this.options.useTLS;\n\n this.errorCallbacks = this.buildErrorCallbacks();\n this.connectionCallbacks = this.buildConnectionCallbacks(\n this.errorCallbacks\n );\n this.handshakeCallbacks = this.buildHandshakeCallbacks(this.errorCallbacks);\n\n var Network = Runtime.getNetwork();\n\n Network.bind('online', () => {\n this.timeline.info({ netinfo: 'online' });\n if (this.state === 'connecting' || this.state === 'unavailable') {\n this.retryIn(0);\n }\n });\n Network.bind('offline', () => {\n this.timeline.info({ netinfo: 'offline' });\n if (this.connection) {\n this.sendActivityCheck();\n }\n });\n\n this.updateStrategy();\n }\n\n switchCluster(key: string) {\n this.key = key;\n // This ensures that the new config coming from\n // pusher instance are taken into account\n // such as appKey and cluster\n this.updateStrategy();\n this.retryIn(0);\n }\n\n /** Establishes a connection to Pusher.\n *\n * Does nothing when connection is already established. See top-level doc\n * to find events emitted on connection attempts.\n */\n connect() {\n if (this.connection || this.runner) {\n return;\n }\n if (!this.strategy.isSupported()) {\n this.updateState('failed');\n return;\n }\n this.updateState('connecting');\n this.startConnecting();\n this.setUnavailableTimer();\n }\n\n /** Sends raw data.\n *\n * @param {String} data\n */\n send(data) {\n if (this.connection) {\n return this.connection.send(data);\n } else {\n return false;\n }\n }\n\n /** Sends an event.\n *\n * @param {String} name\n * @param {String} data\n * @param {String} [channel]\n * @returns {Boolean} whether message was sent or not\n */\n send_event(name: string, data: any, channel?: string) {\n if (this.connection) {\n return this.connection.send_event(name, data, channel);\n } else {\n return false;\n }\n }\n\n /** Closes the connection. */\n disconnect() {\n this.disconnectInternally();\n this.updateState('disconnected');\n }\n\n isUsingTLS() {\n return this.usingTLS;\n }\n\n private startConnecting() {\n var callback = (error, handshake) => {\n if (error) {\n this.runner = this.strategy.connect(0, callback);\n } else {\n if (handshake.action === 'error') {\n this.emit('error', {\n type: 'HandshakeError',\n error: handshake.error\n });\n this.timeline.error({ handshakeError: handshake.error });\n } else {\n this.abortConnecting(); // we don't support switching connections yet\n this.handshakeCallbacks[handshake.action](handshake);\n }\n }\n };\n this.runner = this.strategy.connect(0, callback);\n }\n\n private abortConnecting() {\n if (this.runner) {\n this.runner.abort();\n this.runner = null;\n }\n }\n\n private disconnectInternally() {\n this.abortConnecting();\n this.clearRetryTimer();\n this.clearUnavailableTimer();\n if (this.connection) {\n var connection = this.abandonConnection();\n connection.close();\n }\n }\n\n private updateStrategy() {\n this.strategy = this.options.getStrategy({\n key: this.key,\n timeline: this.timeline,\n useTLS: this.usingTLS\n });\n }\n\n private retryIn(delay) {\n this.timeline.info({ action: 'retry', delay: delay });\n if (delay > 0) {\n this.emit('connecting_in', Math.round(delay / 1000));\n }\n this.retryTimer = new Timer(delay || 0, () => {\n this.disconnectInternally();\n this.connect();\n });\n }\n\n private clearRetryTimer() {\n if (this.retryTimer) {\n this.retryTimer.ensureAborted();\n this.retryTimer = null;\n }\n }\n\n private setUnavailableTimer() {\n this.unavailableTimer = new Timer(this.options.unavailableTimeout, () => {\n this.updateState('unavailable');\n });\n }\n\n private clearUnavailableTimer() {\n if (this.unavailableTimer) {\n this.unavailableTimer.ensureAborted();\n }\n }\n\n private sendActivityCheck() {\n this.stopActivityCheck();\n this.connection.ping();\n // wait for pong response\n this.activityTimer = new Timer(this.options.pongTimeout, () => {\n this.timeline.error({ pong_timed_out: this.options.pongTimeout });\n this.retryIn(0);\n });\n }\n\n private resetActivityCheck() {\n this.stopActivityCheck();\n // send ping after inactivity\n if (this.connection && !this.connection.handlesActivityChecks()) {\n this.activityTimer = new Timer(this.activityTimeout, () => {\n this.sendActivityCheck();\n });\n }\n }\n\n private stopActivityCheck() {\n if (this.activityTimer) {\n this.activityTimer.ensureAborted();\n }\n }\n\n private buildConnectionCallbacks(\n errorCallbacks: ErrorCallbacks\n ): ConnectionCallbacks {\n return Collections.extend({}, errorCallbacks, {\n message: message => {\n // includes pong messages from server\n this.resetActivityCheck();\n this.emit('message', message);\n },\n ping: () => {\n this.send_event('pusher:pong', {});\n },\n activity: () => {\n this.resetActivityCheck();\n },\n error: error => {\n // just emit error to user - socket will already be closed by browser\n this.emit('error', error);\n },\n closed: () => {\n this.abandonConnection();\n if (this.shouldRetry()) {\n this.retryIn(1000);\n }\n }\n });\n }\n\n private buildHandshakeCallbacks(\n errorCallbacks: ErrorCallbacks\n ): HandshakeCallbacks {\n return Collections.extend({}, errorCallbacks, {\n connected: (handshake: HandshakePayload) => {\n this.activityTimeout = Math.min(\n this.options.activityTimeout,\n handshake.activityTimeout,\n handshake.connection.activityTimeout || Infinity\n );\n this.clearUnavailableTimer();\n this.setConnection(handshake.connection);\n this.socket_id = this.connection.id;\n this.updateState('connected', { socket_id: this.socket_id });\n }\n });\n }\n\n private buildErrorCallbacks(): ErrorCallbacks {\n let withErrorEmitted = callback => {\n return (result: Action | HandshakePayload) => {\n if (result.error) {\n this.emit('error', { type: 'WebSocketError', error: result.error });\n }\n callback(result);\n };\n };\n\n return {\n tls_only: withErrorEmitted(() => {\n this.usingTLS = true;\n this.updateStrategy();\n this.retryIn(0);\n }),\n refused: withErrorEmitted(() => {\n this.disconnect();\n }),\n backoff: withErrorEmitted(() => {\n this.retryIn(1000);\n }),\n retry: withErrorEmitted(() => {\n this.retryIn(0);\n })\n };\n }\n\n private setConnection(connection) {\n this.connection = connection;\n for (var event in this.connectionCallbacks) {\n this.connection.bind(event, this.connectionCallbacks[event]);\n }\n this.resetActivityCheck();\n }\n\n private abandonConnection() {\n if (!this.connection) {\n return;\n }\n this.stopActivityCheck();\n for (var event in this.connectionCallbacks) {\n this.connection.unbind(event, this.connectionCallbacks[event]);\n }\n var connection = this.connection;\n this.connection = null;\n return connection;\n }\n\n private updateState(newState: string, data?: any) {\n var previousState = this.state;\n this.state = newState;\n if (previousState !== newState) {\n var newStateDescription = newState;\n if (newStateDescription === 'connected') {\n newStateDescription += ' with new socket ID ' + data.socket_id;\n }\n Logger.debug(\n 'State changed',\n previousState + ' -> ' + newStateDescription\n );\n this.timeline.info({ state: newState, params: data });\n this.emit('state_change', { previous: previousState, current: newState });\n this.emit(newState, data);\n }\n }\n\n private shouldRetry(): boolean {\n return this.state === 'connecting' || this.state === 'connected';\n }\n}\n","import Channel from './channel';\nimport * as Collections from '../utils/collections';\nimport ChannelTable from './channel_table';\nimport Factory from '../utils/factory';\nimport Pusher from '../pusher';\nimport Logger from '../logger';\nimport * as Errors from '../errors';\nimport urlStore from '../utils/url_store';\n\n/** Handles a channel map. */\nexport default class Channels {\n channels: ChannelTable;\n\n constructor() {\n this.channels = {};\n }\n\n /** Creates or retrieves an existing channel by its name.\n *\n * @param {String} name\n * @param {Pusher} pusher\n * @return {Channel}\n */\n add(name: string, pusher: Pusher) {\n if (!this.channels[name]) {\n this.channels[name] = createChannel(name, pusher);\n }\n return this.channels[name];\n }\n\n /** Returns a list of all channels\n *\n * @return {Array}\n */\n all(): Channel[] {\n return Collections.values(this.channels);\n }\n\n /** Finds a channel by its name.\n *\n * @param {String} name\n * @return {Channel} channel or null if it doesn't exist\n */\n find(name: string) {\n return this.channels[name];\n }\n\n /** Removes a channel from the map.\n *\n * @param {String} name\n */\n remove(name: string) {\n var channel = this.channels[name];\n delete this.channels[name];\n return channel;\n }\n\n /** Proxies disconnection signal to all channels. */\n disconnect() {\n Collections.objectApply(this.channels, function(channel) {\n channel.disconnect();\n });\n }\n}\n\nfunction createChannel(name: string, pusher: Pusher): Channel {\n if (name.indexOf('private-encrypted-') === 0) {\n if (pusher.config.nacl) {\n return Factory.createEncryptedChannel(name, pusher, pusher.config.nacl);\n }\n let errMsg =\n 'Tried to subscribe to a private-encrypted- channel but no nacl implementation available';\n let suffix = urlStore.buildLogSuffix('encryptedChannelSupport');\n throw new Errors.UnsupportedFeature(`${errMsg}. ${suffix}`);\n } else if (name.indexOf('private-') === 0) {\n return Factory.createPrivateChannel(name, pusher);\n } else if (name.indexOf('presence-') === 0) {\n return Factory.createPresenceChannel(name, pusher);\n } else if (name.indexOf('#') === 0) {\n throw new Errors.BadChannelName(\n 'Cannot create a channel with name \"' + name + '\".'\n );\n } else {\n return Factory.createChannel(name, pusher);\n }\n}\n","import AssistantToTheTransportManager from '../transports/assistant_to_the_transport_manager';\nimport PingDelayOptions from '../transports/ping_delay_options';\nimport Transport from '../transports/transport';\nimport TransportManager from '../transports/transport_manager';\nimport Handshake from '../connection/handshake';\nimport TransportConnection from '../transports/transport_connection';\nimport SocketHooks from '../http/socket_hooks';\nimport HTTPSocket from '../http/http_socket';\n\nimport Timeline from '../timeline/timeline';\nimport {\n default as TimelineSender,\n TimelineSenderOptions\n} from '../timeline/timeline_sender';\nimport PresenceChannel from '../channels/presence_channel';\nimport PrivateChannel from '../channels/private_channel';\nimport EncryptedChannel from '../channels/encrypted_channel';\nimport Channel from '../channels/channel';\nimport ConnectionManager from '../connection/connection_manager';\nimport ConnectionManagerOptions from '../connection/connection_manager_options';\nimport Ajax from '../http/ajax';\nimport Channels from '../channels/channels';\nimport Pusher from '../pusher';\nimport { Config } from '../config';\nimport * as nacl from 'tweetnacl';\n\nvar Factory = {\n createChannels(): Channels {\n return new Channels();\n },\n\n createConnectionManager(\n key: string,\n options: ConnectionManagerOptions\n ): ConnectionManager {\n return new ConnectionManager(key, options);\n },\n\n createChannel(name: string, pusher: Pusher): Channel {\n return new Channel(name, pusher);\n },\n\n createPrivateChannel(name: string, pusher: Pusher): PrivateChannel {\n return new PrivateChannel(name, pusher);\n },\n\n createPresenceChannel(name: string, pusher: Pusher): PresenceChannel {\n return new PresenceChannel(name, pusher);\n },\n\n createEncryptedChannel(\n name: string,\n pusher: Pusher,\n nacl: nacl\n ): EncryptedChannel {\n return new EncryptedChannel(name, pusher, nacl);\n },\n\n createTimelineSender(timeline: Timeline, options: TimelineSenderOptions) {\n return new TimelineSender(timeline, options);\n },\n\n createHandshake(\n transport: TransportConnection,\n callback: (HandshakePayload) => void\n ): Handshake {\n return new Handshake(transport, callback);\n },\n\n createAssistantToTheTransportManager(\n manager: TransportManager,\n transport: Transport,\n options: PingDelayOptions\n ): AssistantToTheTransportManager {\n return new AssistantToTheTransportManager(manager, transport, options);\n }\n};\n\nexport default Factory;\n","import AssistantToTheTransportManager from './assistant_to_the_transport_manager';\nimport Transport from './transport';\nimport PingDelayOptions from './ping_delay_options';\nimport Factory from '../utils/factory';\n\nexport interface TransportManagerOptions extends PingDelayOptions {\n lives?: number;\n}\n\n/** Keeps track of the number of lives left for a transport.\n *\n * In the beginning of a session, transports may be assigned a number of\n * lives. When an AssistantToTheTransportManager instance reports a transport\n * connection closed uncleanly, the transport loses a life. When the number\n * of lives drops to zero, the transport gets disabled by its manager.\n *\n * @param {Object} options\n */\nexport default class TransportManager {\n options: TransportManagerOptions;\n livesLeft: number;\n\n constructor(options: TransportManagerOptions) {\n this.options = options || {};\n this.livesLeft = this.options.lives || Infinity;\n }\n\n /** Creates a assistant for the transport.\n *\n * @param {Transport} transport\n * @returns {AssistantToTheTransportManager}\n */\n getAssistant(transport: Transport): AssistantToTheTransportManager {\n return Factory.createAssistantToTheTransportManager(this, transport, {\n minPingDelay: this.options.minPingDelay,\n maxPingDelay: this.options.maxPingDelay\n });\n }\n\n /** Returns whether the transport has any lives left.\n *\n * @returns {Boolean}\n */\n isAlive(): boolean {\n return this.livesLeft > 0;\n }\n\n /** Takes one life from the transport. */\n reportDeath() {\n this.livesLeft -= 1;\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport { OneOffTimer as Timer } from '../utils/timers';\nimport Strategy from './strategy';\nimport StrategyOptions from './strategy_options';\n\n/** Loops through strategies with optional timeouts.\n *\n * Options:\n * - loop - whether it should loop through the substrategy list\n * - timeout - initial timeout for a single substrategy\n * - timeoutLimit - maximum timeout\n *\n * @param {Strategy[]} strategies\n * @param {Object} options\n */\nexport default class SequentialStrategy implements Strategy {\n strategies: Strategy[];\n loop: boolean;\n failFast: boolean;\n timeout: number;\n timeoutLimit: number;\n\n constructor(strategies: Strategy[], options: StrategyOptions) {\n this.strategies = strategies;\n this.loop = Boolean(options.loop);\n this.failFast = Boolean(options.failFast);\n this.timeout = options.timeout;\n this.timeoutLimit = options.timeoutLimit;\n }\n\n isSupported(): boolean {\n return Collections.any(this.strategies, Util.method('isSupported'));\n }\n\n connect(minPriority: number, callback: Function) {\n var strategies = this.strategies;\n var current = 0;\n var timeout = this.timeout;\n var runner = null;\n\n var tryNextStrategy = (error, handshake) => {\n if (handshake) {\n callback(null, handshake);\n } else {\n current = current + 1;\n if (this.loop) {\n current = current % strategies.length;\n }\n\n if (current < strategies.length) {\n if (timeout) {\n timeout = timeout * 2;\n if (this.timeoutLimit) {\n timeout = Math.min(timeout, this.timeoutLimit);\n }\n }\n runner = this.tryStrategy(\n strategies[current],\n minPriority,\n { timeout, failFast: this.failFast },\n tryNextStrategy\n );\n } else {\n callback(true);\n }\n }\n };\n\n runner = this.tryStrategy(\n strategies[current],\n minPriority,\n { timeout: timeout, failFast: this.failFast },\n tryNextStrategy\n );\n\n return {\n abort: function() {\n runner.abort();\n },\n forceMinPriority: function(p) {\n minPriority = p;\n if (runner) {\n runner.forceMinPriority(p);\n }\n }\n };\n }\n\n private tryStrategy(\n strategy: Strategy,\n minPriority: number,\n options: StrategyOptions,\n callback: Function\n ) {\n var timer = null;\n var runner = null;\n\n if (options.timeout > 0) {\n timer = new Timer(options.timeout, function() {\n runner.abort();\n callback(true);\n });\n }\n\n runner = strategy.connect(minPriority, function(error, handshake) {\n if (error && timer && timer.isRunning() && !options.failFast) {\n // advance to the next strategy after the timeout\n return;\n }\n if (timer) {\n timer.ensureAborted();\n }\n callback(error, handshake);\n });\n\n return {\n abort: function() {\n if (timer) {\n timer.ensureAborted();\n }\n runner.abort();\n },\n forceMinPriority: function(p) {\n runner.forceMinPriority(p);\n }\n };\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport Strategy from './strategy';\n\n/** Launches all substrategies and emits prioritized connected transports.\n *\n * @param {Array} strategies\n */\nexport default class BestConnectedEverStrategy implements Strategy {\n strategies: Strategy[];\n\n constructor(strategies: Strategy[]) {\n this.strategies = strategies;\n }\n\n isSupported(): boolean {\n return Collections.any(this.strategies, Util.method('isSupported'));\n }\n\n connect(minPriority: number, callback: Function) {\n return connect(this.strategies, minPriority, function(i, runners) {\n return function(error, handshake) {\n runners[i].error = error;\n if (error) {\n if (allRunnersFailed(runners)) {\n callback(true);\n }\n return;\n }\n Collections.apply(runners, function(runner) {\n runner.forceMinPriority(handshake.transport.priority);\n });\n callback(null, handshake);\n };\n });\n }\n}\n\n/** Connects to all strategies in parallel.\n *\n * Callback builder should be a function that takes two arguments: index\n * and a list of runners. It should return another function that will be\n * passed to the substrategy with given index. Runners can be aborted using\n * abortRunner(s) functions from this class.\n *\n * @param {Array} strategies\n * @param {Function} callbackBuilder\n * @return {Object} strategy runner\n */\nfunction connect(\n strategies: Strategy[],\n minPriority: number,\n callbackBuilder: Function\n) {\n var runners = Collections.map(strategies, function(strategy, i, _, rs) {\n return strategy.connect(minPriority, callbackBuilder(i, rs));\n });\n return {\n abort: function() {\n Collections.apply(runners, abortRunner);\n },\n forceMinPriority: function(p) {\n Collections.apply(runners, function(runner) {\n runner.forceMinPriority(p);\n });\n }\n };\n}\n\nfunction allRunnersFailed(runners): boolean {\n return Collections.all(runners, function(runner) {\n return Boolean(runner.error);\n });\n}\n\nfunction abortRunner(runner) {\n if (!runner.error && !runner.aborted) {\n runner.abort();\n runner.aborted = true;\n }\n}\n","import Util from '../util';\nimport Runtime from 'runtime';\nimport Strategy from './strategy';\nimport SequentialStrategy from './sequential_strategy';\nimport StrategyOptions from './strategy_options';\nimport TransportStrategy from './transport_strategy';\nimport Timeline from '../timeline/timeline';\nimport * as Collections from '../utils/collections';\n\nexport interface TransportStrategyDictionary {\n [key: string]: TransportStrategy;\n}\n\n/** Caches the last successful transport and, after the first few attempts,\n * uses the cached transport for subsequent attempts.\n *\n * @param {Strategy} strategy\n * @param {Object} transports\n * @param {Object} options\n */\nexport default class WebSocketPrioritizedCachedStrategy implements Strategy {\n strategy: Strategy;\n transports: TransportStrategyDictionary;\n ttl: number;\n usingTLS: boolean;\n timeline: Timeline;\n\n constructor(\n strategy: Strategy,\n transports: TransportStrategyDictionary,\n options: StrategyOptions\n ) {\n this.strategy = strategy;\n this.transports = transports;\n this.ttl = options.ttl || 1800 * 1000;\n this.usingTLS = options.useTLS;\n this.timeline = options.timeline;\n }\n\n isSupported(): boolean {\n return this.strategy.isSupported();\n }\n\n connect(minPriority: number, callback: Function) {\n var usingTLS = this.usingTLS;\n var info = fetchTransportCache(usingTLS);\n var cacheSkipCount = info && info.cacheSkipCount ? info.cacheSkipCount : 0;\n\n var strategies = [this.strategy];\n if (info && info.timestamp + this.ttl >= Util.now()) {\n var transport = this.transports[info.transport];\n if (transport) {\n if (['ws', 'wss'].includes(info.transport) || cacheSkipCount > 3) {\n this.timeline.info({\n cached: true,\n transport: info.transport,\n latency: info.latency\n });\n strategies.push(\n new SequentialStrategy([transport], {\n timeout: info.latency * 2 + 1000,\n failFast: true\n })\n );\n } else {\n cacheSkipCount++;\n }\n }\n }\n\n var startTimestamp = Util.now();\n var runner = strategies\n .pop()\n .connect(minPriority, function cb(error, handshake) {\n if (error) {\n flushTransportCache(usingTLS);\n if (strategies.length > 0) {\n startTimestamp = Util.now();\n runner = strategies.pop().connect(minPriority, cb);\n } else {\n callback(error);\n }\n } else {\n storeTransportCache(\n usingTLS,\n handshake.transport.name,\n Util.now() - startTimestamp,\n cacheSkipCount\n );\n callback(null, handshake);\n }\n });\n\n return {\n abort: function() {\n runner.abort();\n },\n forceMinPriority: function(p) {\n minPriority = p;\n if (runner) {\n runner.forceMinPriority(p);\n }\n }\n };\n }\n}\n\nfunction getTransportCacheKey(usingTLS: boolean): string {\n return 'pusherTransport' + (usingTLS ? 'TLS' : 'NonTLS');\n}\n\nfunction fetchTransportCache(usingTLS: boolean): any {\n var storage = Runtime.getLocalStorage();\n if (storage) {\n try {\n var serializedCache = storage[getTransportCacheKey(usingTLS)];\n if (serializedCache) {\n return JSON.parse(serializedCache);\n }\n } catch (e) {\n flushTransportCache(usingTLS);\n }\n }\n return null;\n}\n\nfunction storeTransportCache(\n usingTLS: boolean,\n transport: TransportStrategy,\n latency: number,\n cacheSkipCount: number\n) {\n var storage = Runtime.getLocalStorage();\n if (storage) {\n try {\n storage[getTransportCacheKey(usingTLS)] = Collections.safeJSONStringify({\n timestamp: Util.now(),\n transport: transport,\n latency: latency,\n cacheSkipCount: cacheSkipCount\n });\n } catch (e) {\n // catch over quota exceptions raised by localStorage\n }\n }\n}\n\nfunction flushTransportCache(usingTLS: boolean) {\n var storage = Runtime.getLocalStorage();\n if (storage) {\n try {\n delete storage[getTransportCacheKey(usingTLS)];\n } catch (e) {\n // catch exceptions raised by localStorage\n }\n }\n}\n","import { OneOffTimer as Timer } from '../utils/timers';\nimport Strategy from './strategy';\nimport StrategyOptions from './strategy_options';\n\n/** Runs substrategy after specified delay.\n *\n * Options:\n * - delay - time in miliseconds to delay the substrategy attempt\n *\n * @param {Strategy} strategy\n * @param {Object} options\n */\nexport default class DelayedStrategy implements Strategy {\n strategy: Strategy;\n options: { delay: number };\n\n constructor(strategy: Strategy, { delay: number }) {\n this.strategy = strategy;\n this.options = { delay: number };\n }\n\n isSupported(): boolean {\n return this.strategy.isSupported();\n }\n\n connect(minPriority: number, callback: Function) {\n var strategy = this.strategy;\n var runner;\n var timer = new Timer(this.options.delay, function() {\n runner = strategy.connect(minPriority, callback);\n });\n\n return {\n abort: function() {\n timer.ensureAborted();\n if (runner) {\n runner.abort();\n }\n },\n forceMinPriority: function(p) {\n minPriority = p;\n if (runner) {\n runner.forceMinPriority(p);\n }\n }\n };\n }\n}\n","import Strategy from './strategy';\nimport StrategyRunner from './strategy_runner';\n\n/** Proxies method calls to one of substrategies basing on the test function.\n *\n * @param {Function} test\n * @param {Strategy} trueBranch strategy used when test returns true\n * @param {Strategy} falseBranch strategy used when test returns false\n */\nexport default class IfStrategy implements Strategy {\n test: () => boolean;\n trueBranch: Strategy;\n falseBranch: Strategy;\n\n constructor(\n test: () => boolean,\n trueBranch: Strategy,\n falseBranch: Strategy\n ) {\n this.test = test;\n this.trueBranch = trueBranch;\n this.falseBranch = falseBranch;\n }\n\n isSupported(): boolean {\n var branch = this.test() ? this.trueBranch : this.falseBranch;\n return branch.isSupported();\n }\n\n connect(minPriority: number, callback: Function): StrategyRunner {\n var branch = this.test() ? this.trueBranch : this.falseBranch;\n return branch.connect(minPriority, callback);\n }\n}\n","import Strategy from './strategy';\nimport StrategyRunner from './strategy_runner';\n\n/** Launches the substrategy and terminates on the first open connection.\n *\n * @param {Strategy} strategy\n */\nexport default class FirstConnectedStrategy implements Strategy {\n strategy: Strategy;\n\n constructor(strategy: Strategy) {\n this.strategy = strategy;\n }\n\n isSupported(): boolean {\n return this.strategy.isSupported();\n }\n\n connect(minPriority: number, callback: Function): StrategyRunner {\n var runner = this.strategy.connect(minPriority, function(error, handshake) {\n if (handshake) {\n runner.abort();\n }\n callback(error, handshake);\n });\n return runner;\n }\n}\n","import * as Collections from 'core/utils/collections';\nimport TransportManager from 'core/transports/transport_manager';\nimport Strategy from 'core/strategies/strategy';\nimport StrategyOptions from 'core/strategies/strategy_options';\nimport SequentialStrategy from 'core/strategies/sequential_strategy';\nimport BestConnectedEverStrategy from 'core/strategies/best_connected_ever_strategy';\nimport WebSocketPrioritizedCachedStrategy, {\n TransportStrategyDictionary\n} from 'core/strategies/websocket_prioritized_cached_strategy';\nimport DelayedStrategy from 'core/strategies/delayed_strategy';\nimport IfStrategy from 'core/strategies/if_strategy';\nimport FirstConnectedStrategy from 'core/strategies/first_connected_strategy';\nimport { Config } from 'core/config';\n\nfunction testSupportsStrategy(strategy: Strategy) {\n return function() {\n return strategy.isSupported();\n };\n}\n\nvar getDefaultStrategy = function(\n config: Config,\n baseOptions: StrategyOptions,\n defineTransport: Function\n): Strategy {\n var definedTransports = {};\n\n function defineTransportStrategy(\n name: string,\n type: string,\n priority: number,\n options: StrategyOptions,\n manager?: TransportManager\n ) {\n var transport = defineTransport(\n config,\n name,\n type,\n priority,\n options,\n manager\n );\n\n definedTransports[name] = transport;\n\n return transport;\n }\n\n var ws_options: StrategyOptions = Object.assign({}, baseOptions, {\n hostNonTLS: config.wsHost + ':' + config.wsPort,\n hostTLS: config.wsHost + ':' + config.wssPort,\n httpPath: config.wsPath\n });\n var wss_options: StrategyOptions = Object.assign({}, ws_options, {\n useTLS: true\n });\n var sockjs_options: StrategyOptions = Object.assign({}, baseOptions, {\n hostNonTLS: config.httpHost + ':' + config.httpPort,\n hostTLS: config.httpHost + ':' + config.httpsPort,\n httpPath: config.httpPath\n });\n\n var timeouts = {\n loop: true,\n timeout: 15000,\n timeoutLimit: 60000\n };\n\n var ws_manager = new TransportManager({\n minPingDelay: 10000,\n maxPingDelay: config.activityTimeout\n });\n var streaming_manager = new TransportManager({\n lives: 2,\n minPingDelay: 10000,\n maxPingDelay: config.activityTimeout\n });\n\n var ws_transport = defineTransportStrategy(\n 'ws',\n 'ws',\n 3,\n ws_options,\n ws_manager\n );\n var wss_transport = defineTransportStrategy(\n 'wss',\n 'ws',\n 3,\n wss_options,\n ws_manager\n );\n var sockjs_transport = defineTransportStrategy(\n 'sockjs',\n 'sockjs',\n 1,\n sockjs_options\n );\n var xhr_streaming_transport = defineTransportStrategy(\n 'xhr_streaming',\n 'xhr_streaming',\n 1,\n sockjs_options,\n streaming_manager\n );\n var xdr_streaming_transport = defineTransportStrategy(\n 'xdr_streaming',\n 'xdr_streaming',\n 1,\n sockjs_options,\n streaming_manager\n );\n var xhr_polling_transport = defineTransportStrategy(\n 'xhr_polling',\n 'xhr_polling',\n 1,\n sockjs_options\n );\n var xdr_polling_transport = defineTransportStrategy(\n 'xdr_polling',\n 'xdr_polling',\n 1,\n sockjs_options\n );\n\n var ws_loop = new SequentialStrategy([ws_transport], timeouts);\n var wss_loop = new SequentialStrategy([wss_transport], timeouts);\n var sockjs_loop = new SequentialStrategy([sockjs_transport], timeouts);\n var streaming_loop = new SequentialStrategy(\n [\n new IfStrategy(\n testSupportsStrategy(xhr_streaming_transport),\n xhr_streaming_transport,\n xdr_streaming_transport\n )\n ],\n timeouts\n );\n var polling_loop = new SequentialStrategy(\n [\n new IfStrategy(\n testSupportsStrategy(xhr_polling_transport),\n xhr_polling_transport,\n xdr_polling_transport\n )\n ],\n timeouts\n );\n\n var http_loop = new SequentialStrategy(\n [\n new IfStrategy(\n testSupportsStrategy(streaming_loop),\n new BestConnectedEverStrategy([\n streaming_loop,\n new DelayedStrategy(polling_loop, { delay: 4000 })\n ]),\n polling_loop\n )\n ],\n timeouts\n );\n\n var http_fallback_loop = new IfStrategy(\n testSupportsStrategy(http_loop),\n http_loop,\n sockjs_loop\n );\n\n var wsStrategy;\n if (baseOptions.useTLS) {\n wsStrategy = new BestConnectedEverStrategy([\n ws_loop,\n new DelayedStrategy(http_fallback_loop, { delay: 2000 })\n ]);\n } else {\n wsStrategy = new BestConnectedEverStrategy([\n ws_loop,\n new DelayedStrategy(wss_loop, { delay: 2000 }),\n new DelayedStrategy(http_fallback_loop, { delay: 5000 })\n ]);\n }\n\n return new WebSocketPrioritizedCachedStrategy(\n new FirstConnectedStrategy(\n new IfStrategy(\n testSupportsStrategy(ws_transport),\n wsStrategy,\n http_fallback_loop\n )\n ),\n definedTransports,\n {\n ttl: 1800000,\n timeline: baseOptions.timeline,\n useTLS: baseOptions.useTLS\n }\n );\n};\n\nexport default getDefaultStrategy;\n","import HTTPRequest from 'core/http/http_request';\nimport RequestHooks from 'core/http/request_hooks';\nimport Ajax from 'core/http/ajax';\nimport * as Errors from 'core/errors';\n\nvar hooks: RequestHooks = {\n getRequest: function(socket: HTTPRequest): Ajax {\n var xdr = new (window).XDomainRequest();\n xdr.ontimeout = function() {\n socket.emit('error', new Errors.RequestTimedOut());\n socket.close();\n };\n xdr.onerror = function(e) {\n socket.emit('error', e);\n socket.close();\n };\n xdr.onprogress = function() {\n if (xdr.responseText && xdr.responseText.length > 0) {\n socket.onChunk(200, xdr.responseText);\n }\n };\n xdr.onload = function() {\n if (xdr.responseText && xdr.responseText.length > 0) {\n socket.onChunk(200, xdr.responseText);\n }\n socket.emit('finished', 200);\n socket.close();\n };\n return xdr;\n },\n abortRequest: function(xdr: Ajax) {\n xdr.ontimeout = xdr.onerror = xdr.onprogress = xdr.onload = null;\n xdr.abort();\n }\n};\n\nexport default hooks;\n","import Runtime from 'runtime';\nimport RequestHooks from './request_hooks';\nimport Ajax from './ajax';\nimport { default as EventsDispatcher } from '../events/dispatcher';\n\nconst MAX_BUFFER_LENGTH = 256 * 1024;\n\nexport default class HTTPRequest extends EventsDispatcher {\n hooks: RequestHooks;\n method: string;\n url: string;\n position: number;\n xhr: Ajax;\n unloader: Function;\n\n constructor(hooks: RequestHooks, method: string, url: string) {\n super();\n this.hooks = hooks;\n this.method = method;\n this.url = url;\n }\n\n start(payload?: any) {\n this.position = 0;\n this.xhr = this.hooks.getRequest(this);\n\n this.unloader = () => {\n this.close();\n };\n Runtime.addUnloadListener(this.unloader);\n\n this.xhr.open(this.method, this.url, true);\n\n if (this.xhr.setRequestHeader) {\n this.xhr.setRequestHeader('Content-Type', 'application/json'); // ReactNative doesn't set this header by default.\n }\n this.xhr.send(payload);\n }\n\n close() {\n if (this.unloader) {\n Runtime.removeUnloadListener(this.unloader);\n this.unloader = null;\n }\n if (this.xhr) {\n this.hooks.abortRequest(this.xhr);\n this.xhr = null;\n }\n }\n\n onChunk(status: number, data: any) {\n while (true) {\n var chunk = this.advanceBuffer(data);\n if (chunk) {\n this.emit('chunk', { status: status, data: chunk });\n } else {\n break;\n }\n }\n if (this.isBufferTooLong(data)) {\n this.emit('buffer_too_long');\n }\n }\n\n private advanceBuffer(buffer: any[]): any {\n var unreadData = buffer.slice(this.position);\n var endOfLinePosition = unreadData.indexOf('\\n');\n\n if (endOfLinePosition !== -1) {\n this.position += endOfLinePosition + 1;\n return unreadData.slice(0, endOfLinePosition);\n } else {\n // chunk is not finished yet, don't move the buffer pointer\n return null;\n }\n }\n\n private isBufferTooLong(buffer: any): boolean {\n return this.position === buffer.length && buffer.length > MAX_BUFFER_LENGTH;\n }\n}\n","enum State {\n CONNECTING = 0,\n OPEN = 1,\n CLOSED = 3\n}\n\nexport default State;\n","import URLLocation from './url_location';\nimport State from './state';\nimport Socket from '../socket';\nimport SocketHooks from './socket_hooks';\nimport Util from '../util';\nimport Ajax from './ajax';\nimport HTTPRequest from './http_request';\nimport Runtime from 'runtime';\n\nvar autoIncrement = 1;\n\nclass HTTPSocket implements Socket {\n hooks: SocketHooks;\n session: string;\n location: URLLocation;\n readyState: State;\n stream: HTTPRequest;\n\n onopen: () => void;\n onerror: (error: any) => void;\n onclose: (closeEvent: any) => void;\n onmessage: (message: any) => void;\n onactivity: () => void;\n\n constructor(hooks: SocketHooks, url: string) {\n this.hooks = hooks;\n this.session = randomNumber(1000) + '/' + randomString(8);\n this.location = getLocation(url);\n this.readyState = State.CONNECTING;\n this.openStream();\n }\n\n send(payload: any) {\n return this.sendRaw(JSON.stringify([payload]));\n }\n\n ping() {\n this.hooks.sendHeartbeat(this);\n }\n\n close(code: any, reason: any) {\n this.onClose(code, reason, true);\n }\n\n /** For internal use only */\n sendRaw(payload: any): boolean {\n if (this.readyState === State.OPEN) {\n try {\n Runtime.createSocketRequest(\n 'POST',\n getUniqueURL(getSendURL(this.location, this.session))\n ).start(payload);\n return true;\n } catch (e) {\n return false;\n }\n } else {\n return false;\n }\n }\n\n /** For internal use only */\n reconnect() {\n this.closeStream();\n this.openStream();\n }\n\n /** For internal use only */\n onClose(code, reason, wasClean) {\n this.closeStream();\n this.readyState = State.CLOSED;\n if (this.onclose) {\n this.onclose({\n code: code,\n reason: reason,\n wasClean: wasClean\n });\n }\n }\n\n private onChunk(chunk) {\n if (chunk.status !== 200) {\n return;\n }\n if (this.readyState === State.OPEN) {\n this.onActivity();\n }\n\n var payload;\n var type = chunk.data.slice(0, 1);\n switch (type) {\n case 'o':\n payload = JSON.parse(chunk.data.slice(1) || '{}');\n this.onOpen(payload);\n break;\n case 'a':\n payload = JSON.parse(chunk.data.slice(1) || '[]');\n for (var i = 0; i < payload.length; i++) {\n this.onEvent(payload[i]);\n }\n break;\n case 'm':\n payload = JSON.parse(chunk.data.slice(1) || 'null');\n this.onEvent(payload);\n break;\n case 'h':\n this.hooks.onHeartbeat(this);\n break;\n case 'c':\n payload = JSON.parse(chunk.data.slice(1) || '[]');\n this.onClose(payload[0], payload[1], true);\n break;\n }\n }\n\n private onOpen(options) {\n if (this.readyState === State.CONNECTING) {\n if (options && options.hostname) {\n this.location.base = replaceHost(this.location.base, options.hostname);\n }\n this.readyState = State.OPEN;\n\n if (this.onopen) {\n this.onopen();\n }\n } else {\n this.onClose(1006, 'Server lost session', true);\n }\n }\n\n private onEvent(event) {\n if (this.readyState === State.OPEN && this.onmessage) {\n this.onmessage({ data: event });\n }\n }\n\n private onActivity() {\n if (this.onactivity) {\n this.onactivity();\n }\n }\n\n private onError(error) {\n if (this.onerror) {\n this.onerror(error);\n }\n }\n\n private openStream() {\n this.stream = Runtime.createSocketRequest(\n 'POST',\n getUniqueURL(this.hooks.getReceiveURL(this.location, this.session))\n );\n\n this.stream.bind('chunk', chunk => {\n this.onChunk(chunk);\n });\n this.stream.bind('finished', status => {\n this.hooks.onFinished(this, status);\n });\n this.stream.bind('buffer_too_long', () => {\n this.reconnect();\n });\n\n try {\n this.stream.start();\n } catch (error) {\n Util.defer(() => {\n this.onError(error);\n this.onClose(1006, 'Could not start streaming', false);\n });\n }\n }\n\n private closeStream() {\n if (this.stream) {\n this.stream.unbind_all();\n this.stream.close();\n this.stream = null;\n }\n }\n}\n\nfunction getLocation(url): URLLocation {\n var parts = /([^\\?]*)\\/*(\\??.*)/.exec(url);\n return {\n base: parts[1],\n queryString: parts[2]\n };\n}\n\nfunction getSendURL(url: URLLocation, session: string): string {\n return url.base + '/' + session + '/xhr_send';\n}\n\nfunction getUniqueURL(url: string): string {\n var separator = url.indexOf('?') === -1 ? '?' : '&';\n return url + separator + 't=' + +new Date() + '&n=' + autoIncrement++;\n}\n\nfunction replaceHost(url: string, hostname: string): string {\n var urlParts = /(https?:\\/\\/)([^\\/:]+)((\\/|:)?.*)/.exec(url);\n return urlParts[1] + hostname + urlParts[3];\n}\n\nfunction randomNumber(max: number): number {\n return Runtime.randomInt(max);\n}\n\nfunction randomString(length: number): string {\n var result = [];\n\n for (var i = 0; i < length; i++) {\n result.push(randomNumber(32).toString(32));\n }\n\n return result.join('');\n}\n\nexport default HTTPSocket;\n","enum TimelineLevel {\n ERROR = 3,\n INFO = 6,\n DEBUG = 7\n}\n\nexport default TimelineLevel;\n","import SocketHooks from './socket_hooks';\nimport HTTPSocket from './http_socket';\n\nvar hooks: SocketHooks = {\n getReceiveURL: function(url, session) {\n return url.base + '/' + session + '/xhr_streaming' + url.queryString;\n },\n onHeartbeat: function(socket) {\n socket.sendRaw('[]');\n },\n sendHeartbeat: function(socket) {\n socket.sendRaw('[]');\n },\n onFinished: function(socket, status) {\n socket.onClose(1006, 'Connection interrupted (' + status + ')', false);\n }\n};\n\nexport default hooks;\n","import SocketHooks from './socket_hooks';\nimport URLLocation from './url_location';\nimport HTTPSocket from './http_socket';\n\nvar hooks: SocketHooks = {\n getReceiveURL: function(url: URLLocation, session: string): string {\n return url.base + '/' + session + '/xhr' + url.queryString;\n },\n onHeartbeat: function() {\n // next HTTP request will reset server's activity timer\n },\n sendHeartbeat: function(socket) {\n socket.sendRaw('[]');\n },\n onFinished: function(socket, status) {\n if (status === 200) {\n socket.reconnect();\n } else {\n socket.onClose(1006, 'Connection interrupted (' + status + ')', false);\n }\n }\n};\n\nexport default hooks;\n","import HTTPRequest from 'core/http/http_request';\nimport RequestHooks from 'core/http/request_hooks';\nimport Ajax from 'core/http/ajax';\nimport Runtime from 'runtime';\n\nvar hooks: RequestHooks = {\n getRequest: function(socket: HTTPRequest): Ajax {\n var Constructor = Runtime.getXHRAPI();\n var xhr = new Constructor();\n xhr.onreadystatechange = xhr.onprogress = function() {\n switch (xhr.readyState) {\n case 3:\n if (xhr.responseText && xhr.responseText.length > 0) {\n socket.onChunk(xhr.status, xhr.responseText);\n }\n break;\n case 4:\n // this happens only on errors, never after calling close\n if (xhr.responseText && xhr.responseText.length > 0) {\n socket.onChunk(xhr.status, xhr.responseText);\n }\n socket.emit('finished', xhr.status);\n socket.close();\n break;\n }\n };\n return xhr;\n },\n abortRequest: function(xhr: Ajax) {\n xhr.onreadystatechange = null;\n xhr.abort();\n }\n};\n\nexport default hooks;\n","import HTTPRequest from 'core/http/http_request';\nimport HTTPSocket from 'core/http/http_socket';\nimport SocketHooks from 'core/http/socket_hooks';\nimport RequestHooks from 'core/http/request_hooks';\nimport streamingHooks from 'core/http/http_streaming_socket';\nimport pollingHooks from 'core/http/http_polling_socket';\nimport xhrHooks from './http_xhr_request';\nimport HTTPFactory from 'core/http/http_factory';\n\nvar HTTP: HTTPFactory = {\n createStreamingSocket(url: string): HTTPSocket {\n return this.createSocket(streamingHooks, url);\n },\n\n createPollingSocket(url: string): HTTPSocket {\n return this.createSocket(pollingHooks, url);\n },\n\n createSocket(hooks: SocketHooks, url: string): HTTPSocket {\n return new HTTPSocket(hooks, url);\n },\n\n createXHR(method: string, url: string): HTTPRequest {\n return this.createRequest(xhrHooks, method, url);\n },\n\n createRequest(hooks: RequestHooks, method: string, url: string): HTTPRequest {\n return new HTTPRequest(hooks, method, url);\n }\n};\n\nexport default HTTP;\n","import xdrHooks from './http_xdomain_request';\nimport HTTP from 'isomorphic/http/http';\n\nHTTP.createXDR = function(method, url) {\n return this.createRequest(xdrHooks, method, url);\n};\n\nexport default HTTP;\n","import Browser from './browser';\nimport { Dependencies, DependenciesReceivers } from './dom/dependencies';\nimport { AuthTransport, AuthTransports } from 'core/auth/auth_transports';\nimport xhrAuth from 'isomorphic/auth/xhr_auth';\nimport jsonpAuth from './auth/jsonp_auth';\nimport TimelineTransport from 'core/timeline/timeline_transport';\nimport TimelineSender from 'core/timeline/timeline_sender';\nimport ScriptRequest from './dom/script_request';\nimport JSONPRequest from './dom/jsonp_request';\nimport * as Collections from 'core/utils/collections';\nimport { ScriptReceivers } from './dom/script_receiver_factory';\nimport jsonpTimeline from './timeline/jsonp_timeline';\nimport Transports from './transports/transports';\nimport Ajax from 'core/http/ajax';\nimport { Network } from './net_info';\nimport getDefaultStrategy from './default_strategy';\nimport transportConnectionInitializer from './transports/transport_connection_initializer';\nimport HTTPFactory from './http/http';\nimport HTTPRequest from 'core/http/http_request';\n\nvar Runtime: Browser = {\n // for jsonp auth\n nextAuthCallbackID: 1,\n auth_callbacks: {},\n ScriptReceivers,\n DependenciesReceivers,\n getDefaultStrategy,\n Transports,\n transportConnectionInitializer,\n HTTPFactory,\n\n TimelineTransport: jsonpTimeline,\n\n getXHRAPI() {\n return window.XMLHttpRequest;\n },\n\n getWebSocketAPI() {\n return window.WebSocket || window.MozWebSocket;\n },\n\n setup(PusherClass): void {\n (window).Pusher = PusherClass; // JSONp requires Pusher to be in the global scope.\n var initializeOnDocumentBody = () => {\n this.onDocumentBody(PusherClass.ready);\n };\n if (!(window).JSON) {\n Dependencies.load('json2', {}, initializeOnDocumentBody);\n } else {\n initializeOnDocumentBody();\n }\n },\n\n getDocument(): Document {\n return document;\n },\n\n getProtocol(): string {\n return this.getDocument().location.protocol;\n },\n\n getAuthorizers(): AuthTransports {\n return { ajax: xhrAuth, jsonp: jsonpAuth };\n },\n\n onDocumentBody(callback: Function) {\n if (document.body) {\n callback();\n } else {\n setTimeout(() => {\n this.onDocumentBody(callback);\n }, 0);\n }\n },\n\n createJSONPRequest(url: string, data: any): JSONPRequest {\n return new JSONPRequest(url, data);\n },\n\n createScriptRequest(src: string): ScriptRequest {\n return new ScriptRequest(src);\n },\n\n getLocalStorage() {\n try {\n return window.localStorage;\n } catch (e) {\n return undefined;\n }\n },\n\n createXHR(): Ajax {\n if (this.getXHRAPI()) {\n return this.createXMLHttpRequest();\n } else {\n return this.createMicrosoftXHR();\n }\n },\n\n createXMLHttpRequest(): Ajax {\n var Constructor = this.getXHRAPI();\n return new Constructor();\n },\n\n createMicrosoftXHR(): Ajax {\n return new ActiveXObject('Microsoft.XMLHTTP');\n },\n\n getNetwork() {\n return Network;\n },\n\n createWebSocket(url: string): any {\n var Constructor = this.getWebSocketAPI();\n return new Constructor(url);\n },\n\n createSocketRequest(method: string, url: string): HTTPRequest {\n if (this.isXHRSupported()) {\n return this.HTTPFactory.createXHR(method, url);\n } else if (this.isXDRSupported(url.indexOf('https:') === 0)) {\n return this.HTTPFactory.createXDR(method, url);\n } else {\n throw 'Cross-origin HTTP requests are not supported';\n }\n },\n\n isXHRSupported(): boolean {\n var Constructor = this.getXHRAPI();\n return (\n Boolean(Constructor) && new Constructor().withCredentials !== undefined\n );\n },\n\n isXDRSupported(useTLS?: boolean): boolean {\n var protocol = useTLS ? 'https:' : 'http:';\n var documentProtocol = this.getProtocol();\n return (\n Boolean(window['XDomainRequest']) && documentProtocol === protocol\n );\n },\n\n addUnloadListener(listener: any) {\n if (window.addEventListener !== undefined) {\n window.addEventListener('unload', listener, false);\n } else if (window.attachEvent !== undefined) {\n window.attachEvent('onunload', listener);\n }\n },\n\n removeUnloadListener(listener: any) {\n if (window.addEventListener !== undefined) {\n window.removeEventListener('unload', listener, false);\n } else if (window.detachEvent !== undefined) {\n window.detachEvent('onunload', listener);\n }\n },\n\n randomInt(max: number): number {\n /**\n * Return values in the range of [0, 1[\n */\n const random = function() {\n const crypto = window.crypto || window['msCrypto'];\n const random = crypto.getRandomValues(new Uint32Array(1))[0];\n\n return random / 2 ** 32;\n };\n\n return Math.floor(random() * max);\n }\n};\n\nexport default Runtime;\n","import { Dependencies } from '../dom/dependencies';\n\n/** Initializes the transport.\n *\n * Fetches resources if needed and then transitions to initialized.\n */\nexport default function() {\n var self = this;\n\n self.timeline.info(\n self.buildTimelineMessage({\n transport: self.name + (self.options.useTLS ? 's' : '')\n })\n );\n\n if (self.hooks.isInitialized()) {\n self.changeState('initialized');\n } else if (self.hooks.file) {\n self.changeState('initializing');\n Dependencies.load(\n self.hooks.file,\n { useTLS: self.options.useTLS },\n function(error, callback) {\n if (self.hooks.isInitialized()) {\n self.changeState('initialized');\n callback(true);\n } else {\n if (error) {\n self.onError(error);\n }\n self.onClose();\n callback(false);\n }\n }\n );\n } else {\n self.onClose();\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport { default as Level } from './level';\n\nexport interface TimelineOptions {\n level?: Level;\n limit?: number;\n version?: string;\n cluster?: string;\n features?: string[];\n params?: any;\n}\n\nexport default class Timeline {\n key: string;\n session: number;\n events: any[];\n options: TimelineOptions;\n sent: number;\n uniqueID: number;\n\n constructor(key: string, session: number, options: TimelineOptions) {\n this.key = key;\n this.session = session;\n this.events = [];\n this.options = options || {};\n this.sent = 0;\n this.uniqueID = 0;\n }\n\n log(level, event) {\n if (level <= this.options.level) {\n this.events.push(\n Collections.extend({}, event, { timestamp: Util.now() })\n );\n if (this.options.limit && this.events.length > this.options.limit) {\n this.events.shift();\n }\n }\n }\n\n error(event) {\n this.log(Level.ERROR, event);\n }\n\n info(event) {\n this.log(Level.INFO, event);\n }\n\n debug(event) {\n this.log(Level.DEBUG, event);\n }\n\n isEmpty() {\n return this.events.length === 0;\n }\n\n send(sendfn, callback) {\n var data = Collections.extend(\n {\n session: this.session,\n bundle: this.sent + 1,\n key: this.key,\n lib: 'js',\n version: this.options.version,\n cluster: this.options.cluster,\n features: this.options.features,\n timeline: this.events\n },\n this.options.params\n );\n\n this.events = [];\n sendfn(data, (error, result) => {\n if (!error) {\n this.sent++;\n }\n if (callback) {\n callback(error, result);\n }\n });\n\n return true;\n }\n\n generateUniqueID(): number {\n this.uniqueID++;\n return this.uniqueID;\n }\n}\n","import Factory from '../utils/factory';\nimport Util from '../util';\nimport * as Errors from '../errors';\nimport * as Collections from '../utils/collections';\nimport Strategy from './strategy';\nimport Transport from '../transports/transport';\nimport StrategyOptions from './strategy_options';\nimport Handshake from '../connection/handshake';\n\n/** Provides a strategy interface for transports.\n *\n * @param {String} name\n * @param {Number} priority\n * @param {Class} transport\n * @param {Object} options\n */\nexport default class TransportStrategy implements Strategy {\n name: string;\n priority: number;\n transport: Transport;\n options: StrategyOptions;\n\n constructor(\n name: string,\n priority: number,\n transport: Transport,\n options: StrategyOptions\n ) {\n this.name = name;\n this.priority = priority;\n this.transport = transport;\n this.options = options || {};\n }\n\n /** Returns whether the transport is supported in the browser.\n *\n * @returns {Boolean}\n */\n isSupported(): boolean {\n return this.transport.isSupported({\n useTLS: this.options.useTLS\n });\n }\n\n /** Launches a connection attempt and returns a strategy runner.\n *\n * @param {Function} callback\n * @return {Object} strategy runner\n */\n connect(minPriority: number, callback: Function) {\n if (!this.isSupported()) {\n return failAttempt(new Errors.UnsupportedStrategy(), callback);\n } else if (this.priority < minPriority) {\n return failAttempt(new Errors.TransportPriorityTooLow(), callback);\n }\n\n var connected = false;\n var transport = this.transport.createConnection(\n this.name,\n this.priority,\n this.options.key,\n this.options\n );\n var handshake = null;\n\n var onInitialized = function() {\n transport.unbind('initialized', onInitialized);\n transport.connect();\n };\n var onOpen = function() {\n handshake = Factory.createHandshake(transport, function(result) {\n connected = true;\n unbindListeners();\n callback(null, result);\n });\n };\n var onError = function(error) {\n unbindListeners();\n callback(error);\n };\n var onClosed = function() {\n unbindListeners();\n var serializedTransport;\n\n // The reason for this try/catch block is that on React Native\n // the WebSocket object is circular. Therefore transport.socket will\n // throw errors upon stringification. Collections.safeJSONStringify\n // discards circular references when serializing.\n serializedTransport = Collections.safeJSONStringify(transport);\n callback(new Errors.TransportClosed(serializedTransport));\n };\n\n var unbindListeners = function() {\n transport.unbind('initialized', onInitialized);\n transport.unbind('open', onOpen);\n transport.unbind('error', onError);\n transport.unbind('closed', onClosed);\n };\n\n transport.bind('initialized', onInitialized);\n transport.bind('open', onOpen);\n transport.bind('error', onError);\n transport.bind('closed', onClosed);\n\n // connect will be called automatically after initialization\n transport.initialize();\n\n return {\n abort: () => {\n if (connected) {\n return;\n }\n unbindListeners();\n if (handshake) {\n handshake.close();\n } else {\n transport.close();\n }\n },\n forceMinPriority: p => {\n if (connected) {\n return;\n }\n if (this.priority < p) {\n if (handshake) {\n handshake.close();\n } else {\n transport.close();\n }\n }\n }\n };\n }\n}\n\nfunction failAttempt(error: Error, callback: Function) {\n Util.defer(function() {\n callback(error);\n });\n return {\n abort: function() {},\n forceMinPriority: function() {}\n };\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport TransportManager from '../transports/transport_manager';\nimport * as Errors from '../errors';\nimport Strategy from './strategy';\nimport TransportStrategy from './transport_strategy';\nimport StrategyOptions from '../strategies/strategy_options';\nimport { Config } from '../config';\nimport Runtime from 'runtime';\n\nconst { Transports } = Runtime;\n\nexport var defineTransport = function(\n config: Config,\n name: string,\n type: string,\n priority: number,\n options: StrategyOptions,\n manager?: TransportManager\n): Strategy {\n var transportClass = Transports[type];\n if (!transportClass) {\n throw new Errors.UnsupportedTransport(type);\n }\n\n var enabled =\n (!config.enabledTransports ||\n Collections.arrayIndexOf(config.enabledTransports, name) !== -1) &&\n (!config.disabledTransports ||\n Collections.arrayIndexOf(config.disabledTransports, name) === -1);\n\n var transport;\n if (enabled) {\n options = Object.assign(\n { ignoreNullOrigin: config.ignoreNullOrigin },\n options\n );\n\n transport = new TransportStrategy(\n name,\n priority,\n manager ? manager.getAssistant(transportClass) : transportClass,\n options\n );\n } else {\n transport = UnsupportedStrategy;\n }\n\n return transport;\n};\n\nvar UnsupportedStrategy: Strategy = {\n isSupported: function() {\n return false;\n },\n connect: function(_, callback) {\n var deferred = Util.defer(function() {\n callback(new Errors.UnsupportedStrategy());\n });\n return {\n abort: function() {\n deferred.ensureAborted();\n },\n forceMinPriority: function() {}\n };\n }\n};\n","import ConnectionManager from './connection/connection_manager';\nimport {\n ChannelAuthorizationOptions,\n UserAuthenticationOptions\n} from './auth/options';\nimport {\n ChannelAuthorizerGenerator,\n DeprecatedAuthOptions\n} from './auth/deprecated_channel_authorizer';\nimport { AuthTransport, Transport } from './config';\nimport * as nacl from 'tweetnacl';\nimport Logger from './logger';\n\nexport interface Options {\n activityTimeout?: number;\n\n auth?: DeprecatedAuthOptions; // DEPRECATED use channelAuthorization instead\n authEndpoint?: string; // DEPRECATED use channelAuthorization instead\n authTransport?: AuthTransport; // DEPRECATED use channelAuthorization instead\n authorizer?: ChannelAuthorizerGenerator; // DEPRECATED use channelAuthorization instead\n\n channelAuthorization?: ChannelAuthorizationOptions;\n userAuthentication?: UserAuthenticationOptions;\n\n cluster: string;\n enableStats?: boolean;\n disableStats?: boolean;\n disabledTransports?: Transport[];\n enabledTransports?: Transport[];\n forceTLS?: boolean;\n httpHost?: string;\n httpPath?: string;\n httpPort?: number;\n httpsPort?: number;\n ignoreNullOrigin?: boolean;\n nacl?: nacl;\n pongTimeout?: number;\n statsHost?: string;\n timelineParams?: any;\n unavailableTimeout?: number;\n wsHost?: string;\n wsPath?: string;\n wsPort?: number;\n wssPort?: number;\n}\n\nexport interface ClusterOptions {\n appKey: string;\n cluster: string;\n}\n\nexport function validateOptions(options) {\n if (options == null) {\n throw 'You must pass an options object';\n }\n if (options.cluster == null) {\n throw 'Options object must provide a cluster';\n }\n if ('disableStats' in options) {\n Logger.warn(\n 'The disableStats option is deprecated in favor of enableStats'\n );\n }\n}\n","import {\n UserAuthenticationCallback,\n InternalAuthOptions,\n UserAuthenticationHandler,\n UserAuthenticationRequestParams,\n AuthRequestType\n} from './options';\n\nimport Runtime from 'runtime';\n\nconst composeChannelQuery = (\n params: UserAuthenticationRequestParams,\n authOptions: InternalAuthOptions\n) => {\n var query = 'socket_id=' + encodeURIComponent(params.socketId);\n\n for (var key in authOptions.params) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(authOptions.params[key]);\n }\n\n if (authOptions.paramsProvider != null) {\n let dynamicParams = authOptions.paramsProvider();\n for (var key in dynamicParams) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(dynamicParams[key]);\n }\n }\n\n return query;\n};\n\nconst UserAuthenticator = (\n authOptions: InternalAuthOptions\n): UserAuthenticationHandler => {\n if (typeof Runtime.getAuthorizers()[authOptions.transport] === 'undefined') {\n throw `'${authOptions.transport}' is not a recognized auth transport`;\n }\n\n return (\n params: UserAuthenticationRequestParams,\n callback: UserAuthenticationCallback\n ) => {\n const query = composeChannelQuery(params, authOptions);\n\n Runtime.getAuthorizers()[authOptions.transport](\n Runtime,\n query,\n authOptions,\n AuthRequestType.UserAuthentication,\n callback\n );\n };\n};\n\nexport default UserAuthenticator;\n","import {\n AuthRequestType,\n InternalAuthOptions,\n ChannelAuthorizationHandler,\n ChannelAuthorizationRequestParams,\n ChannelAuthorizationCallback\n} from './options';\n\nimport Runtime from 'runtime';\n\nconst composeChannelQuery = (\n params: ChannelAuthorizationRequestParams,\n authOptions: InternalAuthOptions\n) => {\n var query = 'socket_id=' + encodeURIComponent(params.socketId);\n\n query += '&channel_name=' + encodeURIComponent(params.channelName);\n\n for (var key in authOptions.params) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(authOptions.params[key]);\n }\n\n if (authOptions.paramsProvider != null) {\n let dynamicParams = authOptions.paramsProvider();\n for (var key in dynamicParams) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(dynamicParams[key]);\n }\n }\n\n return query;\n};\n\nconst ChannelAuthorizer = (\n authOptions: InternalAuthOptions\n): ChannelAuthorizationHandler => {\n if (typeof Runtime.getAuthorizers()[authOptions.transport] === 'undefined') {\n throw `'${authOptions.transport}' is not a recognized auth transport`;\n }\n\n return (\n params: ChannelAuthorizationRequestParams,\n callback: ChannelAuthorizationCallback\n ) => {\n const query = composeChannelQuery(params, authOptions);\n\n Runtime.getAuthorizers()[authOptions.transport](\n Runtime,\n query,\n authOptions,\n AuthRequestType.ChannelAuthorization,\n callback\n );\n };\n};\n\nexport default ChannelAuthorizer;\n","import { Options } from './options';\nimport Defaults from './defaults';\nimport {\n ChannelAuthorizationHandler,\n UserAuthenticationHandler,\n ChannelAuthorizationOptions\n} from './auth/options';\nimport UserAuthenticator from './auth/user_authenticator';\nimport ChannelAuthorizer from './auth/channel_authorizer';\nimport { ChannelAuthorizerProxy } from './auth/deprecated_channel_authorizer';\nimport Runtime from 'runtime';\nimport * as nacl from 'tweetnacl';\n\nexport type AuthTransport = 'ajax' | 'jsonp';\nexport type Transport =\n | 'ws'\n | 'wss'\n | 'xhr_streaming'\n | 'xhr_polling'\n | 'sockjs';\n\nexport interface Config {\n // these are all 'required' config parameters, it's not necessary for the user\n // to set them, but they have configured defaults.\n activityTimeout: number;\n enableStats: boolean;\n httpHost: string;\n httpPath: string;\n httpPort: number;\n httpsPort: number;\n pongTimeout: number;\n statsHost: string;\n unavailableTimeout: number;\n useTLS: boolean;\n wsHost: string;\n wsPath: string;\n wsPort: number;\n wssPort: number;\n userAuthenticator: UserAuthenticationHandler;\n channelAuthorizer: ChannelAuthorizationHandler;\n\n // these are all optional parameters or overrrides. The customer can set these\n // but it's not strictly necessary\n forceTLS?: boolean;\n cluster?: string;\n disabledTransports?: Transport[];\n enabledTransports?: Transport[];\n ignoreNullOrigin?: boolean;\n nacl?: nacl;\n timelineParams?: any;\n}\n\n// getConfig mainly sets the defaults for the options that are not provided\nexport function getConfig(opts: Options, pusher): Config {\n let config: Config = {\n activityTimeout: opts.activityTimeout || Defaults.activityTimeout,\n cluster: opts.cluster,\n httpPath: opts.httpPath || Defaults.httpPath,\n httpPort: opts.httpPort || Defaults.httpPort,\n httpsPort: opts.httpsPort || Defaults.httpsPort,\n pongTimeout: opts.pongTimeout || Defaults.pongTimeout,\n statsHost: opts.statsHost || Defaults.stats_host,\n unavailableTimeout: opts.unavailableTimeout || Defaults.unavailableTimeout,\n wsPath: opts.wsPath || Defaults.wsPath,\n wsPort: opts.wsPort || Defaults.wsPort,\n wssPort: opts.wssPort || Defaults.wssPort,\n\n enableStats: getEnableStatsConfig(opts),\n httpHost: getHttpHost(opts),\n useTLS: shouldUseTLS(opts),\n wsHost: getWebsocketHost(opts),\n\n userAuthenticator: buildUserAuthenticator(opts),\n channelAuthorizer: buildChannelAuthorizer(opts, pusher)\n };\n\n if ('disabledTransports' in opts)\n config.disabledTransports = opts.disabledTransports;\n if ('enabledTransports' in opts)\n config.enabledTransports = opts.enabledTransports;\n if ('ignoreNullOrigin' in opts)\n config.ignoreNullOrigin = opts.ignoreNullOrigin;\n if ('timelineParams' in opts) config.timelineParams = opts.timelineParams;\n if ('nacl' in opts) {\n config.nacl = opts.nacl;\n }\n\n return config;\n}\n\nfunction getHttpHost(opts: Options): string {\n if (opts.httpHost) {\n return opts.httpHost;\n }\n if (opts.cluster) {\n return `sockjs-${opts.cluster}.pusher.com`;\n }\n return Defaults.httpHost;\n}\n\nfunction getWebsocketHost(opts: Options): string {\n if (opts.wsHost) {\n return opts.wsHost;\n }\n return getWebsocketHostFromCluster(opts.cluster);\n}\n\nfunction getWebsocketHostFromCluster(cluster: string): string {\n return `ws-${cluster}.pusher.com`;\n}\n\nfunction shouldUseTLS(opts: Options): boolean {\n if (Runtime.getProtocol() === 'https:') {\n return true;\n } else if (opts.forceTLS === false) {\n return false;\n }\n return true;\n}\n\n// if enableStats is set take the value\n// if disableStats is set take the inverse\n// otherwise default to false\nfunction getEnableStatsConfig(opts: Options): boolean {\n if ('enableStats' in opts) {\n return opts.enableStats;\n }\n if ('disableStats' in opts) {\n return !opts.disableStats;\n }\n return false;\n}\n\nfunction buildUserAuthenticator(opts: Options): UserAuthenticationHandler {\n const userAuthentication = {\n ...Defaults.userAuthentication,\n ...opts.userAuthentication\n };\n if (\n 'customHandler' in userAuthentication &&\n userAuthentication['customHandler'] != null\n ) {\n return userAuthentication['customHandler'];\n }\n\n return UserAuthenticator(userAuthentication);\n}\n\nfunction buildChannelAuth(opts: Options, pusher): ChannelAuthorizationOptions {\n let channelAuthorization: ChannelAuthorizationOptions;\n if ('channelAuthorization' in opts) {\n channelAuthorization = {\n ...Defaults.channelAuthorization,\n ...opts.channelAuthorization\n };\n } else {\n channelAuthorization = {\n transport: opts.authTransport || Defaults.authTransport,\n endpoint: opts.authEndpoint || Defaults.authEndpoint\n };\n if ('auth' in opts) {\n if ('params' in opts.auth) channelAuthorization.params = opts.auth.params;\n if ('headers' in opts.auth)\n channelAuthorization.headers = opts.auth.headers;\n }\n if ('authorizer' in opts)\n channelAuthorization.customHandler = ChannelAuthorizerProxy(\n pusher,\n channelAuthorization,\n opts.authorizer\n );\n }\n return channelAuthorization;\n}\n\nfunction buildChannelAuthorizer(\n opts: Options,\n pusher\n): ChannelAuthorizationHandler {\n const channelAuthorization = buildChannelAuth(opts, pusher);\n if (\n 'customHandler' in channelAuthorization &&\n channelAuthorization['customHandler'] != null\n ) {\n return channelAuthorization['customHandler'];\n }\n\n return ChannelAuthorizer(channelAuthorization);\n}\n","import Channel from '../channels/channel';\nimport {\n ChannelAuthorizationCallback,\n ChannelAuthorizationHandler,\n ChannelAuthorizationRequestParams,\n InternalAuthOptions\n} from './options';\n\nexport interface DeprecatedChannelAuthorizer {\n authorize(socketId: string, callback: ChannelAuthorizationCallback): void;\n}\n\nexport interface ChannelAuthorizerGenerator {\n (\n channel: Channel,\n options: DeprecatedAuthorizerOptions\n ): DeprecatedChannelAuthorizer;\n}\n\nexport interface DeprecatedAuthOptions {\n params?: any;\n headers?: any;\n}\n\nexport interface DeprecatedAuthorizerOptions {\n authTransport: 'ajax' | 'jsonp';\n authEndpoint: string;\n auth?: DeprecatedAuthOptions;\n}\n\nexport const ChannelAuthorizerProxy = (\n pusher,\n authOptions: InternalAuthOptions,\n channelAuthorizerGenerator: ChannelAuthorizerGenerator\n): ChannelAuthorizationHandler => {\n const deprecatedAuthorizerOptions: DeprecatedAuthorizerOptions = {\n authTransport: authOptions.transport,\n authEndpoint: authOptions.endpoint,\n auth: {\n params: authOptions.params,\n headers: authOptions.headers\n }\n };\n return (\n params: ChannelAuthorizationRequestParams,\n callback: ChannelAuthorizationCallback\n ) => {\n const channel = pusher.channel(params.channelName);\n // This line creates a new channel authorizer every time.\n // In the past, this was only done once per channel and reused.\n // We can do that again if we want to keep this behavior intact.\n const channelAuthorizer: DeprecatedChannelAuthorizer = channelAuthorizerGenerator(\n channel,\n deprecatedAuthorizerOptions\n );\n channelAuthorizer.authorize(params.socketId, callback);\n };\n};\n","import Logger from './logger';\nimport Pusher from './pusher';\nimport EventsDispatcher from './events/dispatcher';\n\nexport default class WatchlistFacade extends EventsDispatcher {\n private pusher: Pusher;\n\n public constructor(pusher: Pusher) {\n super(function(eventName, data) {\n Logger.debug(`No callbacks on watchlist events for ${eventName}`);\n });\n\n this.pusher = pusher;\n this.bindWatchlistInternalEvent();\n }\n\n handleEvent(pusherEvent) {\n pusherEvent.data.events.forEach(watchlistEvent => {\n this.emit(watchlistEvent.name, watchlistEvent);\n });\n }\n\n private bindWatchlistInternalEvent() {\n this.pusher.connection.bind('message', pusherEvent => {\n var eventName = pusherEvent.event;\n if (eventName === 'pusher_internal:watchlist_events') {\n this.handleEvent(pusherEvent);\n }\n });\n }\n}\n","function flatPromise() {\n let resolve, reject;\n const promise = new Promise((res, rej) => {\n resolve = res;\n reject = rej;\n });\n return { promise, resolve, reject };\n}\n\nexport default flatPromise;\n","import Pusher from './pusher';\nimport Logger from './logger';\nimport {\n UserAuthenticationData,\n UserAuthenticationCallback\n} from './auth/options';\nimport Channel from './channels/channel';\nimport WatchlistFacade from './watchlist';\nimport EventsDispatcher from './events/dispatcher';\nimport flatPromise from './utils/flat_promise';\n\nexport default class UserFacade extends EventsDispatcher {\n pusher: Pusher;\n signin_requested: boolean = false;\n user_data: any = null;\n serverToUserChannel: Channel = null;\n signinDonePromise: Promise = null;\n watchlist: WatchlistFacade;\n private _signinDoneResolve: Function = null;\n\n public constructor(pusher: Pusher) {\n super(function(eventName, data) {\n Logger.debug('No callbacks on user for ' + eventName);\n });\n this.pusher = pusher;\n this.pusher.connection.bind('state_change', ({ previous, current }) => {\n if (previous !== 'connected' && current === 'connected') {\n this._signin();\n }\n if (previous === 'connected' && current !== 'connected') {\n this._cleanup();\n this._newSigninPromiseIfNeeded();\n }\n });\n\n this.watchlist = new WatchlistFacade(pusher);\n\n this.pusher.connection.bind('message', event => {\n var eventName = event.event;\n if (eventName === 'pusher:signin_success') {\n this._onSigninSuccess(event.data);\n }\n if (\n this.serverToUserChannel &&\n this.serverToUserChannel.name === event.channel\n ) {\n this.serverToUserChannel.handleEvent(event);\n }\n });\n }\n\n public signin() {\n if (this.signin_requested) {\n return;\n }\n\n this.signin_requested = true;\n this._signin();\n }\n\n private _signin() {\n if (!this.signin_requested) {\n return;\n }\n\n this._newSigninPromiseIfNeeded();\n\n if (this.pusher.connection.state !== 'connected') {\n // Signin will be attempted when the connection is connected\n return;\n }\n\n this.pusher.config.userAuthenticator(\n {\n socketId: this.pusher.connection.socket_id\n },\n this._onAuthorize\n );\n }\n\n private _onAuthorize: UserAuthenticationCallback = (\n err,\n authData: UserAuthenticationData\n ) => {\n if (err) {\n Logger.warn(`Error during signin: ${err}`);\n this._cleanup();\n return;\n }\n\n this.pusher.send_event('pusher:signin', {\n auth: authData.auth,\n user_data: authData.user_data\n });\n\n // Later when we get pusher:singin_success event, the user will be marked as signed in\n };\n\n private _onSigninSuccess(data: any) {\n try {\n this.user_data = JSON.parse(data.user_data);\n } catch (e) {\n Logger.error(`Failed parsing user data after signin: ${data.user_data}`);\n this._cleanup();\n return;\n }\n\n if (typeof this.user_data.id !== 'string' || this.user_data.id === '') {\n Logger.error(\n `user_data doesn't contain an id. user_data: ${this.user_data}`\n );\n this._cleanup();\n return;\n }\n\n // Signin succeeded\n this._signinDoneResolve();\n this._subscribeChannels();\n }\n\n private _subscribeChannels() {\n const ensure_subscribed = channel => {\n if (channel.subscriptionPending && channel.subscriptionCancelled) {\n channel.reinstateSubscription();\n } else if (\n !channel.subscriptionPending &&\n this.pusher.connection.state === 'connected'\n ) {\n channel.subscribe();\n }\n };\n\n this.serverToUserChannel = new Channel(\n `#server-to-user-${this.user_data.id}`,\n this.pusher\n );\n this.serverToUserChannel.bind_global((eventName, data) => {\n if (\n eventName.indexOf('pusher_internal:') === 0 ||\n eventName.indexOf('pusher:') === 0\n ) {\n // ignore internal events\n return;\n }\n this.emit(eventName, data);\n });\n ensure_subscribed(this.serverToUserChannel);\n }\n\n private _cleanup() {\n this.user_data = null;\n if (this.serverToUserChannel) {\n this.serverToUserChannel.unbind_all();\n this.serverToUserChannel.disconnect();\n this.serverToUserChannel = null;\n }\n\n if (this.signin_requested) {\n // If signin is in progress and cleanup is called,\n // Mark the current signin process as done.\n this._signinDoneResolve();\n }\n }\n\n private _newSigninPromiseIfNeeded() {\n if (!this.signin_requested) {\n return;\n }\n\n // If there is a promise and it is not resolved, return without creating a new one.\n if (this.signinDonePromise && !(this.signinDonePromise as any).done) {\n return;\n }\n\n // This promise is never rejected.\n // It gets resolved when the signin process is done whether it failed or succeeded\n const { promise, resolve, reject: _ } = flatPromise();\n (promise as any).done = false;\n const setDone = () => {\n (promise as any).done = true;\n };\n promise.then(setDone).catch(setDone);\n this.signinDonePromise = promise;\n this._signinDoneResolve = resolve;\n }\n}\n","import AbstractRuntime from '../runtimes/interface';\nimport Runtime from 'runtime';\nimport * as Collections from './utils/collections';\nimport Channels from './channels/channels';\nimport Channel from './channels/channel';\nimport { default as EventsDispatcher } from './events/dispatcher';\nimport Timeline from './timeline/timeline';\nimport TimelineSender from './timeline/timeline_sender';\nimport TimelineLevel from './timeline/level';\nimport { defineTransport } from './strategies/strategy_builder';\nimport ConnectionManager from './connection/connection_manager';\nimport { PeriodicTimer } from './utils/timers';\nimport Defaults from './defaults';\nimport Logger from './logger';\nimport Factory from './utils/factory';\nimport { Options, ClusterOptions, validateOptions } from './options';\nimport { Config, getConfig } from './config';\nimport StrategyOptions from './strategies/strategy_options';\nimport UserFacade from './user';\n\nexport default class Pusher {\n /* STATIC PROPERTIES */\n static instances: Pusher[] = [];\n static isReady: boolean = false;\n static logToConsole: boolean = false;\n\n // for jsonp\n static Runtime: AbstractRuntime = Runtime;\n static ScriptReceivers: any = (Runtime).ScriptReceivers;\n static DependenciesReceivers: any = (Runtime).DependenciesReceivers;\n static auth_callbacks: any = (Runtime).auth_callbacks;\n\n static ready() {\n Pusher.isReady = true;\n for (var i = 0, l = Pusher.instances.length; i < l; i++) {\n Pusher.instances[i].connect();\n }\n }\n\n static log: (message: any) => void;\n\n private static getClientFeatures(): string[] {\n return Collections.keys(\n Collections.filterObject({ ws: Runtime.Transports.ws }, function(t) {\n return t.isSupported({});\n })\n );\n }\n\n /* INSTANCE PROPERTIES */\n key: string;\n options: Options;\n config: Config;\n channels: Channels;\n global_emitter: EventsDispatcher;\n sessionID: number;\n timeline: Timeline;\n timelineSender: TimelineSender;\n connection: ConnectionManager;\n timelineSenderTimer: PeriodicTimer;\n user: UserFacade;\n constructor(app_key: string, options: Options) {\n checkAppKey(app_key);\n validateOptions(options);\n this.key = app_key;\n this.config = getConfig(options, this);\n\n this.channels = Factory.createChannels();\n this.global_emitter = new EventsDispatcher();\n this.sessionID = Runtime.randomInt(1000000000);\n\n this.timeline = new Timeline(this.key, this.sessionID, {\n cluster: this.config.cluster,\n features: Pusher.getClientFeatures(),\n params: this.config.timelineParams || {},\n limit: 50,\n level: TimelineLevel.INFO,\n version: Defaults.VERSION\n });\n if (this.config.enableStats) {\n this.timelineSender = Factory.createTimelineSender(this.timeline, {\n host: this.config.statsHost,\n path: '/timeline/v2/' + Runtime.TimelineTransport.name\n });\n }\n\n var getStrategy = (options: StrategyOptions) => {\n return Runtime.getDefaultStrategy(this.config, options, defineTransport);\n };\n\n this.connection = Factory.createConnectionManager(this.key, {\n getStrategy: getStrategy,\n timeline: this.timeline,\n activityTimeout: this.config.activityTimeout,\n pongTimeout: this.config.pongTimeout,\n unavailableTimeout: this.config.unavailableTimeout,\n useTLS: Boolean(this.config.useTLS)\n });\n\n this.connection.bind('connected', () => {\n this.subscribeAll();\n if (this.timelineSender) {\n this.timelineSender.send(this.connection.isUsingTLS());\n }\n });\n\n this.connection.bind('message', event => {\n var eventName = event.event;\n var internal = eventName.indexOf('pusher_internal:') === 0;\n if (event.channel) {\n var channel = this.channel(event.channel);\n if (channel) {\n channel.handleEvent(event);\n }\n }\n // Emit globally [deprecated]\n if (!internal) {\n this.global_emitter.emit(event.event, event.data);\n }\n });\n this.connection.bind('connecting', () => {\n this.channels.disconnect();\n });\n this.connection.bind('disconnected', () => {\n this.channels.disconnect();\n });\n this.connection.bind('error', err => {\n Logger.warn(err);\n });\n\n Pusher.instances.push(this);\n this.timeline.info({ instances: Pusher.instances.length });\n\n this.user = new UserFacade(this);\n\n if (Pusher.isReady) {\n this.connect();\n }\n }\n\n /**\n * Allows you to switch Pusher cluster without\n * losing all the channels/subscription binding\n * as this is internally managed by the SDK.\n */\n switchCluster(options: ClusterOptions) {\n const { appKey, cluster } = options;\n this.key = appKey;\n this.options = { ...this.options, cluster };\n this.config = getConfig(this.options, this);\n this.connection.switchCluster(this.key);\n }\n\n channel(name: string): Channel {\n return this.channels.find(name);\n }\n\n allChannels(): Channel[] {\n return this.channels.all();\n }\n\n connect() {\n this.connection.connect();\n\n if (this.timelineSender) {\n if (!this.timelineSenderTimer) {\n var usingTLS = this.connection.isUsingTLS();\n var timelineSender = this.timelineSender;\n this.timelineSenderTimer = new PeriodicTimer(60000, function() {\n timelineSender.send(usingTLS);\n });\n }\n }\n }\n\n disconnect() {\n this.connection.disconnect();\n\n if (this.timelineSenderTimer) {\n this.timelineSenderTimer.ensureAborted();\n this.timelineSenderTimer = null;\n }\n }\n\n bind(event_name: string, callback: Function, context?: any): Pusher {\n this.global_emitter.bind(event_name, callback, context);\n return this;\n }\n\n unbind(event_name?: string, callback?: Function, context?: any): Pusher {\n this.global_emitter.unbind(event_name, callback, context);\n return this;\n }\n\n bind_global(callback: Function): Pusher {\n this.global_emitter.bind_global(callback);\n return this;\n }\n\n unbind_global(callback?: Function): Pusher {\n this.global_emitter.unbind_global(callback);\n return this;\n }\n\n unbind_all(callback?: Function): Pusher {\n this.global_emitter.unbind_all();\n return this;\n }\n\n subscribeAll() {\n var channelName;\n for (channelName in this.channels.channels) {\n if (this.channels.channels.hasOwnProperty(channelName)) {\n this.subscribe(channelName);\n }\n }\n }\n\n subscribe(channel_name: string) {\n var channel = this.channels.add(channel_name, this);\n if (channel.subscriptionPending && channel.subscriptionCancelled) {\n channel.reinstateSubscription();\n } else if (\n !channel.subscriptionPending &&\n this.connection.state === 'connected'\n ) {\n channel.subscribe();\n }\n return channel;\n }\n\n unsubscribe(channel_name: string) {\n var channel = this.channels.find(channel_name);\n if (channel && channel.subscriptionPending) {\n channel.cancelSubscription();\n } else {\n channel = this.channels.remove(channel_name);\n if (channel && channel.subscribed) {\n channel.unsubscribe();\n }\n }\n }\n\n send_event(event_name: string, data: any, channel?: string) {\n return this.connection.send_event(event_name, data, channel);\n }\n\n shouldUseTLS(): boolean {\n return this.config.useTLS;\n }\n\n signin() {\n this.user.signin();\n }\n}\n\nfunction checkAppKey(key) {\n if (key === null || key === undefined) {\n throw 'You must pass your app key when you instantiate Pusher.';\n }\n}\n\nRuntime.setup(Pusher);\n","import Pusher from './pusher';\nimport { Options, validateOptions } from './options';\nimport * as nacl from 'tweetnacl';\n\nexport default class PusherWithEncryption extends Pusher {\n constructor(app_key: string, options: Options) {\n Pusher.logToConsole = PusherWithEncryption.logToConsole;\n Pusher.log = PusherWithEncryption.log;\n\n validateOptions(options);\n options.nacl = nacl;\n super(app_key, options);\n }\n}\n"],"sourceRoot":""} \ No newline at end of file +{"version":3,"sources":["webpack://Pusher/webpack/universalModuleDefinition","webpack://Pusher/webpack/bootstrap","webpack://Pusher/./node_modules/@stablelib/base64/base64.ts","webpack://Pusher/./node_modules/@stablelib/utf8/utf8.ts","webpack://Pusher/./node_modules/tweetnacl/nacl-fast.js","webpack://Pusher/./src/core/pusher-with-encryption.js","webpack://Pusher/./src/runtimes/web/dom/script_receiver_factory.ts","webpack://Pusher/./src/core/defaults.ts","webpack://Pusher/./src/runtimes/web/dom/dependencies.ts","webpack://Pusher/./src/runtimes/web/dom/dependency_loader.ts","webpack://Pusher/./src/core/utils/url_store.ts","webpack://Pusher/./src/core/auth/options.ts","webpack://Pusher/./src/core/errors.ts","webpack://Pusher/./src/runtimes/isomorphic/auth/xhr_auth.ts","webpack://Pusher/./src/core/base64.ts","webpack://Pusher/./src/core/utils/timers/abstract_timer.ts","webpack://Pusher/./src/core/utils/timers/index.ts","webpack://Pusher/./src/core/util.ts","webpack://Pusher/./src/core/utils/collections.ts","webpack://Pusher/./src/core/logger.ts","webpack://Pusher/./src/runtimes/web/auth/jsonp_auth.ts","webpack://Pusher/./src/runtimes/web/dom/script_request.ts","webpack://Pusher/./src/runtimes/web/dom/jsonp_request.ts","webpack://Pusher/./src/runtimes/web/timeline/jsonp_timeline.ts","webpack://Pusher/./src/core/transports/url_schemes.ts","webpack://Pusher/./src/core/events/callback_registry.ts","webpack://Pusher/./src/core/events/dispatcher.ts","webpack://Pusher/./src/core/transports/transport_connection.ts","webpack://Pusher/./src/core/transports/transport.ts","webpack://Pusher/./src/runtimes/isomorphic/transports/transports.ts","webpack://Pusher/./src/runtimes/web/transports/transports.ts","webpack://Pusher/./src/runtimes/web/net_info.ts","webpack://Pusher/./src/core/transports/assistant_to_the_transport_manager.ts","webpack://Pusher/./src/core/connection/protocol/protocol.ts","webpack://Pusher/./src/core/connection/connection.ts","webpack://Pusher/./src/core/connection/handshake/index.ts","webpack://Pusher/./src/core/timeline/timeline_sender.ts","webpack://Pusher/./src/core/channels/channel.ts","webpack://Pusher/./src/core/channels/private_channel.ts","webpack://Pusher/./src/core/channels/members.ts","webpack://Pusher/./src/core/channels/presence_channel.ts","webpack://Pusher/./src/core/channels/encrypted_channel.ts","webpack://Pusher/./src/core/connection/connection_manager.ts","webpack://Pusher/./src/core/channels/channels.ts","webpack://Pusher/./src/core/utils/factory.ts","webpack://Pusher/./src/core/transports/transport_manager.ts","webpack://Pusher/./src/core/strategies/sequential_strategy.ts","webpack://Pusher/./src/core/strategies/best_connected_ever_strategy.ts","webpack://Pusher/./src/core/strategies/websocket_prioritized_cached_strategy.ts","webpack://Pusher/./src/core/strategies/delayed_strategy.ts","webpack://Pusher/./src/core/strategies/if_strategy.ts","webpack://Pusher/./src/core/strategies/first_connected_strategy.ts","webpack://Pusher/./src/runtimes/web/default_strategy.ts","webpack://Pusher/./src/runtimes/web/http/http_xdomain_request.ts","webpack://Pusher/./src/core/http/http_request.ts","webpack://Pusher/./src/core/http/state.ts","webpack://Pusher/./src/core/http/http_socket.ts","webpack://Pusher/./src/core/timeline/level.ts","webpack://Pusher/./src/core/http/http_streaming_socket.ts","webpack://Pusher/./src/core/http/http_polling_socket.ts","webpack://Pusher/./src/runtimes/isomorphic/http/http_xhr_request.ts","webpack://Pusher/./src/runtimes/isomorphic/http/http.ts","webpack://Pusher/./src/runtimes/web/http/http.ts","webpack://Pusher/./src/runtimes/web/runtime.ts","webpack://Pusher/./src/runtimes/web/transports/transport_connection_initializer.ts","webpack://Pusher/./src/core/timeline/timeline.ts","webpack://Pusher/./src/core/strategies/transport_strategy.ts","webpack://Pusher/./src/core/strategies/strategy_builder.ts","webpack://Pusher/./src/core/options.ts","webpack://Pusher/./src/core/auth/user_authenticator.ts","webpack://Pusher/./src/core/auth/channel_authorizer.ts","webpack://Pusher/./src/core/config.ts","webpack://Pusher/./src/core/auth/deprecated_channel_authorizer.ts","webpack://Pusher/./src/core/watchlist.ts","webpack://Pusher/./src/core/utils/flat_promise.ts","webpack://Pusher/./src/core/user.ts","webpack://Pusher/./src/core/pusher.ts","webpack://Pusher/./src/core/pusher-with-encryption.ts"],"names":["root","factory","exports","module","define","amd","window","installedModules","__webpack_require__","moduleId","i","l","modules","call","m","c","d","name","getter","o","Object","defineProperty","enumerable","get","r","Symbol","toStringTag","value","t","mode","__esModule","ns","create","key","bind","n","object","property","prototype","hasOwnProperty","p","s","_paddingCharacter","encodedLength","length","this","encode","data","out","_encodeByte","left","maxDecodedLength","decodedLength","_getPaddingLength","decode","Uint8Array","paddingLength","op","haveBad","v0","v1","v2","v3","_decodeChar","charCodeAt","Error","b","result","String","fromCharCode","Coder","stdCoder","URLSafeCoder","urlSafeCoder","INVALID_UTF8","arr","pos","chars","min","n1","n2","n3","push","join","nacl","gf","init","Float64Array","randombytes","_0","_9","gf0","gf1","_121665","D","D2","X","Y","I","ts64","x","h","vn","xi","y","yi","crypto_verify_16","crypto_verify_32","crypto_core_salsa20","inp","k","u","j0","j1","j2","j3","j4","j5","j6","j7","j8","j9","j10","j11","j12","j13","j14","j15","x0","x1","x2","x3","x4","x5","x6","x7","x8","x9","x10","x11","x12","x13","x14","x15","core_salsa20","crypto_core_hsalsa20","core_hsalsa20","sigma","crypto_stream_salsa20_xor","cpos","mpos","z","crypto_stream_salsa20","crypto_stream","sn","crypto_stream_xor","poly1305","t0","t1","t2","t3","t4","t5","t6","t7","buffer","Uint16Array","pad","leftover","fin","crypto_onetimeauth","outpos","update","finish","crypto_onetimeauth_verify","hpos","crypto_secretbox","crypto_secretbox_open","set25519","a","car25519","v","Math","floor","sel25519","q","pack25519","j","neq25519","par25519","unpack25519","A","Z","M","t8","t9","t10","t11","t12","t13","t14","t15","t16","t17","t18","t19","t20","t21","t22","t23","t24","t25","t26","t27","t28","t29","t30","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","b10","b11","b12","b13","b14","b15","S","inv25519","pow2523","crypto_scalarmult","e","f","x32","subarray","x16","crypto_scalarmult_base","crypto_box_keypair","crypto_box_beforenm","blocks","bytes","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","hibit","h0","h1","h2","h3","h4","h5","h6","h7","h8","h9","r0","r1","r2","r3","r4","r5","r6","r7","r8","r9","mac","macpos","mask","g","want","crypto_box_afternm","crypto_box_open_afternm","K","crypto_hashblocks_hl","hh","hl","bh0","bh1","bh2","bh3","bh4","bh5","bh6","bh7","bl0","bl1","bl2","bl3","bl4","bl5","bl6","bl7","th","tl","wh","Int32Array","wl","ah0","ah1","ah2","ah3","ah4","ah5","ah6","ah7","al0","al1","al2","al3","al4","al5","al6","al7","crypto_hash","add","cswap","pack","tx","ty","zi","scalarmult","scalarbase","crypto_sign_keypair","pk","sk","seeded","L","modL","carry","reduce","crypto_sign","sm","smlen","crypto_sign_open","chk","num","den","den2","den4","den6","unpackneg","checkLengths","checkArrayTypes","arguments","TypeError","cleanup","lowlevel","crypto_box","crypto_box_open","crypto_secretbox_KEYBYTES","crypto_secretbox_NONCEBYTES","crypto_secretbox_ZEROBYTES","crypto_secretbox_BOXZEROBYTES","crypto_scalarmult_BYTES","crypto_scalarmult_SCALARBYTES","crypto_box_PUBLICKEYBYTES","crypto_box_SECRETKEYBYTES","crypto_box_BEFORENMBYTES","crypto_box_NONCEBYTES","crypto_box_ZEROBYTES","crypto_box_BOXZEROBYTES","crypto_sign_BYTES","crypto_sign_PUBLICKEYBYTES","crypto_sign_SECRETKEYBYTES","crypto_sign_SEEDBYTES","crypto_hash_BYTES","randomBytes","secretbox","msg","nonce","open","box","keyLength","nonceLength","overheadLength","scalarMult","base","scalarLength","groupElementLength","publicKey","secretKey","before","checkBoxLengths","after","keyPair","fromSecretKey","publicKeyLength","secretKeyLength","sharedKeyLength","sign","signedMsg","tmp","mlen","detached","sig","verify","fromSeed","seed","seedLength","signatureLength","hash","hashLength","setPRNG","fn","crypto","self","msCrypto","getRandomValues","default","ScriptReceiverFactory","prefix","lastId","callback","number","id","called","callbackWrapper","apply","receiver","ScriptReceivers","VERSION","PROTOCOL","wsPort","wssPort","wsPath","httpHost","httpPort","httpsPort","httpPath","stats_host","authEndpoint","authTransport","activityTimeout","pongTimeout","unavailableTimeout","userAuthentication","endpoint","transport","channelAuthorization","cdn_http","cdn_https","dependency_suffix","DependenciesReceivers","Dependencies","options","receivers","loading","request","createScriptRequest","getPath","error","remove","callbacks","successCallback","wasSuccessful","send","protocol","getDocument","location","useTLS","replace","version","getRoot","suffix","urlStore","baseUrl","urls","authenticationEndpoint","path","authorizationEndpoint","javascriptQuickStart","triggeringClientEvents","encryptedChannelSupport","fullUrl","AuthRequestType","urlObj","url","BadEventName","super","setPrototypeOf","BadChannelName","RequestTimedOut","TransportPriorityTooLow","TransportClosed","UnsupportedFeature","UnsupportedTransport","UnsupportedStrategy","HTTPAuthError","status","context","query","authOptions","authRequestType","xhr","createXHR","headerName","setRequestHeader","headers","headersProvider","dynamicHeaders","onreadystatechange","readyState","parsed","JSON","parse","responseText","toString","UserAuthentication","ChannelAuthorization","b64chars","b64tab","charAt","cb_utob","cc","utob","cb_encode","ccc","padlen","ord","btoa","set","clear","delay","timer","clearTimeout","clearInterval","setTimeout","setInterval","now","Date","valueOf","defer","args","boundArguments","Array","slice","concat","extend","target","sources","extensions","constructor","stringify","safeJSONStringify","arrayIndexOf","array","item","nativeIndexOf","indexOf","objectApply","keys","_","map","filter","test","filterObject","Boolean","any","encodeParamsObject","encodeURIComponent","buildQueryString","params","undefined","method","source","objects","paths","derez","nu","$ref","globalLog","message","console","log","globalLogWarn","globalLogError","warn","defaultLoggingFunction","logToConsole","callbackName","nextAuthCallbackID","document","script","createElement","auth_callbacks","callback_name","src","head","getElementsByTagName","documentElement","insertBefore","firstChild","ScriptRequest","errorString","type","charset","addEventListener","onerror","onload","async","attachEvent","navigator","userAgent","errorScript","text","nextSibling","parentNode","removeChild","getAgent","sender","host","createJSONPRequest","getGenericURL","baseScheme","hostTLS","hostNonTLS","getGenericPath","queryString","ws","getInitial","http","sockjs","_callbacks","prefixedEventName","names","removeCallback","removeAllCallbacks","binding","failThrough","global_callbacks","eventName","unbind","unbind_global","metadata","hooks","priority","initialize","transportConnectionInitializer","state","timeline","generateUniqueID","handlesActivityChecks","supportsPing","socket","getSocket","onError","changeState","bindListeners","debug","close","ping","beforeOpen","onopen","emit","buildTimelineMessage","closeEvent","code","reason","wasClean","unbindListeners","onOpen","onclose","onClose","onmessage","onMessage","onactivity","onActivity","info","cid","environment","isSupported","WSTransport","isInitialized","getWebSocketAPI","createWebSocket","httpConfiguration","streamingConfiguration","HTTPFactory","createStreamingSocket","pollingConfiguration","createPollingSocket","xhrConfiguration","isXHRSupported","xhr_streaming","xhr_polling","SockJSTransport","file","SockJS","js_path","ignore_null_origin","ignoreNullOrigin","xdrConfiguration","isXDRSupported","XDRStreamingTransport","XDRPollingTransport","xdr_streaming","xdr_polling","onLine","manager","minPingDelay","maxPingDelay","pingDelay","connection","createConnection","openTimestamp","onClosed","reportDeath","lifespan","max","isAlive","Protocol","decodeMessage","messageEvent","messageData","pusherEventData","pusherEvent","event","channel","user_id","encodeMessage","processHandshake","activity_timeout","action","socket_id","getCloseAction","getCloseError","send_event","listeners","activity","closed","handleCloseEvent","listener","isEmpty","TimelineTransport","pusher","subscribed","subscriptionPending","subscriptionCancelled","socketId","auth","handleSubscriptionSucceededEvent","handleSubscriptionCountEvent","unsubscribe","subscription_count","subscriptionCount","authorize","assign","channel_data","config","channelAuthorizer","channelName","reset","members","member","myID","subscriptionData","presence","count","me","memberData","user_info","authData","channelData","setMyID","user","signinDonePromise","user_data","handleInternalEvent","addedMember","addMember","removedMember","removeMember","onSubscription","disconnect","sharedSecret","handleEncryptedEvent","handleEvent","ciphertext","cipherText","getDataToEmit","raw","usingTLS","errorCallbacks","buildErrorCallbacks","connectionCallbacks","buildConnectionCallbacks","handshakeCallbacks","buildHandshakeCallbacks","Network","getNetwork","netinfo","retryIn","sendActivityCheck","updateStrategy","runner","strategy","updateState","startConnecting","setUnavailableTimer","disconnectInternally","handshake","connect","handshakeError","abortConnecting","abort","clearRetryTimer","clearUnavailableTimer","abandonConnection","getStrategy","round","retryTimer","ensureAborted","unavailableTimer","stopActivityCheck","activityTimer","pong_timed_out","resetActivityCheck","shouldRetry","connected","Infinity","setConnection","withErrorEmitted","tls_only","refused","backoff","retry","newState","previousState","newStateDescription","previous","current","channels","createEncryptedChannel","errMsg","createPrivateChannel","createPresenceChannel","createChannel","values","createChannels","createConnectionManager","createTimelineSender","createHandshake","createAssistantToTheTransportManager","livesLeft","lives","strategies","loop","failFast","timeout","timeoutLimit","minPriority","tryNextStrategy","tryStrategy","forceMinPriority","isRunning","callbackBuilder","runners","rs","abortRunner","allRunnersFailed","aborted","transports","ttl","storage","getLocalStorage","serializedCache","getTransportCacheKey","flushTransportCache","fetchTransportCache","cacheSkipCount","timestamp","includes","cached","latency","startTimestamp","pop","cb","storeTransportCache","IfStrategy","trueBranch","falseBranch","FirstConnectedStrategy","testSupportsStrategy","baseOptions","defineTransport","definedTransports","defineTransportStrategy","wsStrategy","ws_options","wsHost","wss_options","sockjs_options","timeouts","ws_manager","streaming_manager","ws_transport","wss_transport","sockjs_transport","xhr_streaming_transport","xdr_streaming_transport","xhr_polling_transport","xdr_polling_transport","ws_loop","wss_loop","sockjs_loop","streaming_loop","polling_loop","http_loop","http_fallback_loop","getRequest","xdr","XDomainRequest","ontimeout","onprogress","onChunk","abortRequest","payload","position","unloader","addUnloadListener","removeUnloadListener","chunk","advanceBuffer","isBufferTooLong","unreadData","endOfLinePosition","State","autoIncrement","getUniqueURL","separator","randomNumber","randomInt","TimelineLevel","session","randomString","parts","exec","getLocation","CONNECTING","openStream","sendRaw","sendHeartbeat","OPEN","createSocketRequest","start","closeStream","CLOSED","onEvent","onHeartbeat","hostname","urlParts","stream","getReceiveURL","onFinished","reconnect","unbind_all","getXHRAPI","createSocket","createRequest","getDefaultStrategy","Transports","load","XMLHttpRequest","WebSocket","MozWebSocket","PusherClass","Pusher","initializeOnDocumentBody","onDocumentBody","ready","getAuthorizers","ajax","jsonp","body","localStorage","createXMLHttpRequest","createMicrosoftXHR","ActiveXObject","createXDR","Constructor","withCredentials","documentProtocol","getProtocol","removeEventListener","detachEvent","Uint32Array","events","sent","uniqueID","level","limit","shift","ERROR","INFO","DEBUG","sendfn","bundle","lib","cluster","features","failAttempt","onInitialized","serializedTransport","transportClass","enabledTransports","disabledTransports","getAssistant","deferred","validateOptions","paramsProvider","dynamicParams","composeChannelQuery","getConfig","opts","statsHost","enableStats","getEnableStatsConfig","getHttpHost","shouldUseTLS","getWebsocketHost","userAuthenticator","buildUserAuthenticator","buildChannelAuthorizer","timelineParams","forceTLS","disableStats","customHandler","channelAuthorizerGenerator","deprecatedAuthorizerOptions","ChannelAuthorizerProxy","authorizer","buildChannelAuth","bindWatchlistInternalEvent","forEach","watchlistEvent","resolve","reject","promise","Promise","res","rej","signin_requested","serverToUserChannel","_signinDoneResolve","_onAuthorize","err","_cleanup","_signin","_newSigninPromiseIfNeeded","watchlist","_onSigninSuccess","_subscribeChannels","bind_global","reinstateSubscription","subscribe","ensure_subscribed","done","setDone","then","catch","isReady","instances","app_key","checkAppKey","global_emitter","sessionID","getClientFeatures","timelineSender","subscribeAll","isUsingTLS","internal","appKey","switchCluster","find","all","timelineSenderTimer","event_name","channel_name","cancelSubscription","signin","Runtime","setup"],"mappings":";;;;;;;CAAA,SAA2CA,EAAMC,GAC1B,iBAAZC,SAA0C,iBAAXC,OACxCA,OAAOD,QAAUD,IACQ,mBAAXG,QAAyBA,OAAOC,IAC9CD,OAAO,GAAIH,GACe,iBAAZC,QACdA,QAAgB,OAAID,IAEpBD,EAAa,OAAIC,IARnB,CASGK,QAAQ,WACX,O,YCTE,IAAIC,EAAmB,GAGvB,SAASC,EAAoBC,GAG5B,GAAGF,EAAiBE,GACnB,OAAOF,EAAiBE,GAAUP,QAGnC,IAAIC,EAASI,EAAiBE,GAAY,CACzCC,EAAGD,EACHE,GAAG,EACHT,QAAS,IAUV,OANAU,EAAQH,GAAUI,KAAKV,EAAOD,QAASC,EAAQA,EAAOD,QAASM,GAG/DL,EAAOQ,GAAI,EAGJR,EAAOD,QA0Df,OArDAM,EAAoBM,EAAIF,EAGxBJ,EAAoBO,EAAIR,EAGxBC,EAAoBQ,EAAI,SAASd,EAASe,EAAMC,GAC3CV,EAAoBW,EAAEjB,EAASe,IAClCG,OAAOC,eAAenB,EAASe,EAAM,CAAEK,YAAY,EAAMC,IAAKL,KAKhEV,EAAoBgB,EAAI,SAAStB,GACX,oBAAXuB,QAA0BA,OAAOC,aAC1CN,OAAOC,eAAenB,EAASuB,OAAOC,YAAa,CAAEC,MAAO,WAE7DP,OAAOC,eAAenB,EAAS,aAAc,CAAEyB,OAAO,KAQvDnB,EAAoBoB,EAAI,SAASD,EAAOE,GAEvC,GADU,EAAPA,IAAUF,EAAQnB,EAAoBmB,IAC/B,EAAPE,EAAU,OAAOF,EACpB,GAAW,EAAPE,GAA8B,iBAAVF,GAAsBA,GAASA,EAAMG,WAAY,OAAOH,EAChF,IAAII,EAAKX,OAA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GAAArpB,gBAA6B,GAASA,gBACtC,GAAAuB,sBAAmC,GAASA,sBAC5C,GAAA8I,eAA4B,GAASA,eAVzB,UAkPrB,GAAQif,MAAM,I,YClQC,MAAM,WAA6B,GAChD,YAAYnB,EAAiB1mB,GAC3B,GAAOsI,aAAe,GAAqBA,aAC3C,GAAOL,IAAM,GAAqBA,IAElCmb,GAAgBpjB,GAChBA,EAAQrX,KAAO,GACfuZ,MAAMwkB,EAAS1mB","file":"pusher-with-encryption.min.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"Pusher\"] = factory();\n\telse\n\t\troot[\"Pusher\"] = factory();\n})(window, function() {\nreturn "," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 3);\n","// Copyright (C) 2016 Dmitry Chestnykh\n// MIT License. See LICENSE file for details.\n\n/**\n * Package base64 implements Base64 encoding and decoding.\n */\n\n// Invalid character used in decoding to indicate\n// that the character to decode is out of range of\n// alphabet and cannot be decoded.\nconst INVALID_BYTE = 256;\n\n/**\n * Implements standard Base64 encoding.\n *\n * Operates in constant time.\n */\nexport class Coder {\n // TODO(dchest): methods to encode chunk-by-chunk.\n\n constructor(private _paddingCharacter = \"=\") { }\n\n encodedLength(length: number): number {\n if (!this._paddingCharacter) {\n return (length * 8 + 5) / 6 | 0;\n }\n return (length + 2) / 3 * 4 | 0;\n }\n\n encode(data: Uint8Array): string {\n let out = \"\";\n\n let i = 0;\n for (; i < data.length - 2; i += 3) {\n let c = (data[i] << 16) | (data[i + 1] << 8) | (data[i + 2]);\n out += this._encodeByte((c >>> 3 * 6) & 63);\n out += this._encodeByte((c >>> 2 * 6) & 63);\n out += this._encodeByte((c >>> 1 * 6) & 63);\n out += this._encodeByte((c >>> 0 * 6) & 63);\n }\n\n const left = data.length - i;\n if (left > 0) {\n let c = (data[i] << 16) | (left === 2 ? data[i + 1] << 8 : 0);\n out += this._encodeByte((c >>> 3 * 6) & 63);\n out += this._encodeByte((c >>> 2 * 6) & 63);\n if (left === 2) {\n out += this._encodeByte((c >>> 1 * 6) & 63);\n } else {\n out += this._paddingCharacter || \"\";\n }\n out += this._paddingCharacter || \"\";\n }\n\n return out;\n }\n\n maxDecodedLength(length: number): number {\n if (!this._paddingCharacter) {\n return (length * 6 + 7) / 8 | 0;\n }\n return length / 4 * 3 | 0;\n }\n\n decodedLength(s: string): number {\n return this.maxDecodedLength(s.length - this._getPaddingLength(s));\n }\n\n decode(s: string): Uint8Array {\n if (s.length === 0) {\n return new Uint8Array(0);\n }\n const paddingLength = this._getPaddingLength(s);\n const length = s.length - paddingLength;\n const out = new Uint8Array(this.maxDecodedLength(length));\n let op = 0;\n let i = 0;\n let haveBad = 0;\n let v0 = 0, v1 = 0, v2 = 0, v3 = 0;\n for (; i < length - 4; i += 4) {\n v0 = this._decodeChar(s.charCodeAt(i + 0));\n v1 = this._decodeChar(s.charCodeAt(i + 1));\n v2 = this._decodeChar(s.charCodeAt(i + 2));\n v3 = this._decodeChar(s.charCodeAt(i + 3));\n out[op++] = (v0 << 2) | (v1 >>> 4);\n out[op++] = (v1 << 4) | (v2 >>> 2);\n out[op++] = (v2 << 6) | v3;\n haveBad |= v0 & INVALID_BYTE;\n haveBad |= v1 & INVALID_BYTE;\n haveBad |= v2 & INVALID_BYTE;\n haveBad |= v3 & INVALID_BYTE;\n }\n if (i < length - 1) {\n v0 = this._decodeChar(s.charCodeAt(i));\n v1 = this._decodeChar(s.charCodeAt(i + 1));\n out[op++] = (v0 << 2) | (v1 >>> 4);\n haveBad |= v0 & INVALID_BYTE;\n haveBad |= v1 & INVALID_BYTE;\n }\n if (i < length - 2) {\n v2 = this._decodeChar(s.charCodeAt(i + 2));\n out[op++] = (v1 << 4) | (v2 >>> 2);\n haveBad |= v2 & INVALID_BYTE;\n }\n if (i < length - 3) {\n v3 = this._decodeChar(s.charCodeAt(i + 3));\n out[op++] = (v2 << 6) | v3;\n haveBad |= v3 & INVALID_BYTE;\n }\n if (haveBad !== 0) {\n throw new Error(\"Base64Coder: incorrect characters for decoding\");\n }\n return out;\n }\n\n // Standard encoding have the following encoded/decoded ranges,\n // which we need to convert between.\n //\n // ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 0123456789 + /\n // Index: 0 - 25 26 - 51 52 - 61 62 63\n // ASCII: 65 - 90 97 - 122 48 - 57 43 47\n //\n\n // Encode 6 bits in b into a new character.\n protected _encodeByte(b: number): string {\n // Encoding uses constant time operations as follows:\n //\n // 1. Define comparison of A with B using (A - B) >>> 8:\n // if A > B, then result is positive integer\n // if A <= B, then result is 0\n //\n // 2. Define selection of C or 0 using bitwise AND: X & C:\n // if X == 0, then result is 0\n // if X != 0, then result is C\n //\n // 3. Start with the smallest comparison (b >= 0), which is always\n // true, so set the result to the starting ASCII value (65).\n //\n // 4. Continue comparing b to higher ASCII values, and selecting\n // zero if comparison isn't true, otherwise selecting a value\n // to add to result, which:\n //\n // a) undoes the previous addition\n // b) provides new value to add\n //\n let result = b;\n // b >= 0\n result += 65;\n // b > 25\n result += ((25 - b) >>> 8) & ((0 - 65) - 26 + 97);\n // b > 51\n result += ((51 - b) >>> 8) & ((26 - 97) - 52 + 48);\n // b > 61\n result += ((61 - b) >>> 8) & ((52 - 48) - 62 + 43);\n // b > 62\n result += ((62 - b) >>> 8) & ((62 - 43) - 63 + 47);\n\n return String.fromCharCode(result);\n }\n\n // Decode a character code into a byte.\n // Must return 256 if character is out of alphabet range.\n protected _decodeChar(c: number): number {\n // Decoding works similar to encoding: using the same comparison\n // function, but now it works on ranges: result is always incremented\n // by value, but this value becomes zero if the range is not\n // satisfied.\n //\n // Decoding starts with invalid value, 256, which is then\n // subtracted when the range is satisfied. If none of the ranges\n // apply, the function returns 256, which is then checked by\n // the caller to throw error.\n let result = INVALID_BYTE; // start with invalid character\n\n // c == 43 (c > 42 and c < 44)\n result += (((42 - c) & (c - 44)) >>> 8) & (-INVALID_BYTE + c - 43 + 62);\n // c == 47 (c > 46 and c < 48)\n result += (((46 - c) & (c - 48)) >>> 8) & (-INVALID_BYTE + c - 47 + 63);\n // c > 47 and c < 58\n result += (((47 - c) & (c - 58)) >>> 8) & (-INVALID_BYTE + c - 48 + 52);\n // c > 64 and c < 91\n result += (((64 - c) & (c - 91)) >>> 8) & (-INVALID_BYTE + c - 65 + 0);\n // c > 96 and c < 123\n result += (((96 - c) & (c - 123)) >>> 8) & (-INVALID_BYTE + c - 97 + 26);\n\n return result;\n }\n\n private _getPaddingLength(s: string): number {\n let paddingLength = 0;\n if (this._paddingCharacter) {\n for (let i = s.length - 1; i >= 0; i--) {\n if (s[i] !== this._paddingCharacter) {\n break;\n }\n paddingLength++;\n }\n if (s.length < 4 || paddingLength > 2) {\n throw new Error(\"Base64Coder: incorrect padding\");\n }\n }\n return paddingLength;\n }\n\n}\n\nconst stdCoder = new Coder();\n\nexport function encode(data: Uint8Array): string {\n return stdCoder.encode(data);\n}\n\nexport function decode(s: string): Uint8Array {\n return stdCoder.decode(s);\n}\n\n/**\n * Implements URL-safe Base64 encoding.\n * (Same as Base64, but '+' is replaced with '-', and '/' with '_').\n *\n * Operates in constant time.\n */\nexport class URLSafeCoder extends Coder {\n // URL-safe encoding have the following encoded/decoded ranges:\n //\n // ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 0123456789 - _\n // Index: 0 - 25 26 - 51 52 - 61 62 63\n // ASCII: 65 - 90 97 - 122 48 - 57 45 95\n //\n\n protected _encodeByte(b: number): string {\n let result = b;\n // b >= 0\n result += 65;\n // b > 25\n result += ((25 - b) >>> 8) & ((0 - 65) - 26 + 97);\n // b > 51\n result += ((51 - b) >>> 8) & ((26 - 97) - 52 + 48);\n // b > 61\n result += ((61 - b) >>> 8) & ((52 - 48) - 62 + 45);\n // b > 62\n result += ((62 - b) >>> 8) & ((62 - 45) - 63 + 95);\n\n return String.fromCharCode(result);\n }\n\n protected _decodeChar(c: number): number {\n let result = INVALID_BYTE;\n\n // c == 45 (c > 44 and c < 46)\n result += (((44 - c) & (c - 46)) >>> 8) & (-INVALID_BYTE + c - 45 + 62);\n // c == 95 (c > 94 and c < 96)\n result += (((94 - c) & (c - 96)) >>> 8) & (-INVALID_BYTE + c - 95 + 63);\n // c > 47 and c < 58\n result += (((47 - c) & (c - 58)) >>> 8) & (-INVALID_BYTE + c - 48 + 52);\n // c > 64 and c < 91\n result += (((64 - c) & (c - 91)) >>> 8) & (-INVALID_BYTE + c - 65 + 0);\n // c > 96 and c < 123\n result += (((96 - c) & (c - 123)) >>> 8) & (-INVALID_BYTE + c - 97 + 26);\n\n return result;\n }\n}\n\nconst urlSafeCoder = new URLSafeCoder();\n\nexport function encodeURLSafe(data: Uint8Array): string {\n return urlSafeCoder.encode(data);\n}\n\nexport function decodeURLSafe(s: string): Uint8Array {\n return urlSafeCoder.decode(s);\n}\n\n\nexport const encodedLength = (length: number) =>\n stdCoder.encodedLength(length);\n\nexport const maxDecodedLength = (length: number) =>\n stdCoder.maxDecodedLength(length);\n\nexport const decodedLength = (s: string) =>\n stdCoder.decodedLength(s);\n","// Copyright (C) 2016 Dmitry Chestnykh\n// MIT License. See LICENSE file for details.\n\n/**\n * Package utf8 implements UTF-8 encoding and decoding.\n */\n\nconst INVALID_UTF16 = \"utf8: invalid string\";\nconst INVALID_UTF8 = \"utf8: invalid source encoding\";\n\n/**\n * Encodes the given string into UTF-8 byte array.\n * Throws if the source string has invalid UTF-16 encoding.\n */\nexport function encode(s: string): Uint8Array {\n // Calculate result length and allocate output array.\n // encodedLength() also validates string and throws errors,\n // so we don't need repeat validation here.\n const arr = new Uint8Array(encodedLength(s));\n\n let pos = 0;\n for (let i = 0; i < s.length; i++) {\n let c = s.charCodeAt(i);\n if (c < 0x80) {\n arr[pos++] = c;\n } else if (c < 0x800) {\n arr[pos++] = 0xc0 | c >> 6;\n arr[pos++] = 0x80 | c & 0x3f;\n } else if (c < 0xd800) {\n arr[pos++] = 0xe0 | c >> 12;\n arr[pos++] = 0x80 | (c >> 6) & 0x3f;\n arr[pos++] = 0x80 | c & 0x3f;\n } else {\n i++; // get one more character\n c = (c & 0x3ff) << 10;\n c |= s.charCodeAt(i) & 0x3ff;\n c += 0x10000;\n\n arr[pos++] = 0xf0 | c >> 18;\n arr[pos++] = 0x80 | (c >> 12) & 0x3f;\n arr[pos++] = 0x80 | (c >> 6) & 0x3f;\n arr[pos++] = 0x80 | c & 0x3f;\n }\n }\n return arr;\n}\n\n/**\n * Returns the number of bytes required to encode the given string into UTF-8.\n * Throws if the source string has invalid UTF-16 encoding.\n */\nexport function encodedLength(s: string): number {\n let result = 0;\n for (let i = 0; i < s.length; i++) {\n const c = s.charCodeAt(i);\n if (c < 0x80) {\n result += 1;\n } else if (c < 0x800) {\n result += 2;\n } else if (c < 0xd800) {\n result += 3;\n } else if (c <= 0xdfff) {\n if (i >= s.length - 1) {\n throw new Error(INVALID_UTF16);\n }\n i++; // \"eat\" next character\n result += 4;\n } else {\n throw new Error(INVALID_UTF16);\n }\n }\n return result;\n}\n\n/**\n * Decodes the given byte array from UTF-8 into a string.\n * Throws if encoding is invalid.\n */\nexport function decode(arr: Uint8Array): string {\n const chars: string[] = [];\n for (let i = 0; i < arr.length; i++) {\n let b = arr[i];\n\n if (b & 0x80) {\n let min;\n if (b < 0xe0) {\n // Need 1 more byte.\n if (i >= arr.length) {\n throw new Error(INVALID_UTF8);\n }\n const n1 = arr[++i];\n if ((n1 & 0xc0) !== 0x80) {\n throw new Error(INVALID_UTF8);\n }\n b = (b & 0x1f) << 6 | (n1 & 0x3f);\n min = 0x80;\n } else if (b < 0xf0) {\n // Need 2 more bytes.\n if (i >= arr.length - 1) {\n throw new Error(INVALID_UTF8);\n }\n const n1 = arr[++i];\n const n2 = arr[++i];\n if ((n1 & 0xc0) !== 0x80 || (n2 & 0xc0) !== 0x80) {\n throw new Error(INVALID_UTF8);\n }\n b = (b & 0x0f) << 12 | (n1 & 0x3f) << 6 | (n2 & 0x3f);\n min = 0x800;\n } else if (b < 0xf8) {\n // Need 3 more bytes.\n if (i >= arr.length - 2) {\n throw new Error(INVALID_UTF8);\n }\n const n1 = arr[++i];\n const n2 = arr[++i];\n const n3 = arr[++i];\n if ((n1 & 0xc0) !== 0x80 || (n2 & 0xc0) !== 0x80 || (n3 & 0xc0) !== 0x80) {\n throw new Error(INVALID_UTF8);\n }\n b = (b & 0x0f) << 18 | (n1 & 0x3f) << 12 | (n2 & 0x3f) << 6 | (n3 & 0x3f);\n min = 0x10000;\n } else {\n throw new Error(INVALID_UTF8);\n }\n\n if (b < min || (b >= 0xd800 && b <= 0xdfff)) {\n throw new Error(INVALID_UTF8);\n }\n\n if (b >= 0x10000) {\n // Surrogate pair.\n if (b > 0x10ffff) {\n throw new Error(INVALID_UTF8);\n }\n b -= 0x10000;\n chars.push(String.fromCharCode(0xd800 | (b >> 10)));\n b = 0xdc00 | (b & 0x3ff);\n }\n }\n\n chars.push(String.fromCharCode(b));\n }\n return chars.join(\"\");\n}\n","(function(nacl) {\n'use strict';\n\n// Ported in 2014 by Dmitry Chestnykh and Devi Mandiri.\n// Public domain.\n//\n// Implementation derived from TweetNaCl version 20140427.\n// See for details: http://tweetnacl.cr.yp.to/\n\nvar gf = function(init) {\n var i, r = new Float64Array(16);\n if (init) for (i = 0; i < init.length; i++) r[i] = init[i];\n return r;\n};\n\n// Pluggable, initialized in high-level API below.\nvar randombytes = function(/* x, n */) { throw new Error('no PRNG'); };\n\nvar _0 = new Uint8Array(16);\nvar _9 = new Uint8Array(32); _9[0] = 9;\n\nvar gf0 = gf(),\n gf1 = gf([1]),\n _121665 = gf([0xdb41, 1]),\n D = gf([0x78a3, 0x1359, 0x4dca, 0x75eb, 0xd8ab, 0x4141, 0x0a4d, 0x0070, 0xe898, 0x7779, 0x4079, 0x8cc7, 0xfe73, 0x2b6f, 0x6cee, 0x5203]),\n D2 = gf([0xf159, 0x26b2, 0x9b94, 0xebd6, 0xb156, 0x8283, 0x149a, 0x00e0, 0xd130, 0xeef3, 0x80f2, 0x198e, 0xfce7, 0x56df, 0xd9dc, 0x2406]),\n X = gf([0xd51a, 0x8f25, 0x2d60, 0xc956, 0xa7b2, 0x9525, 0xc760, 0x692c, 0xdc5c, 0xfdd6, 0xe231, 0xc0a4, 0x53fe, 0xcd6e, 0x36d3, 0x2169]),\n Y = gf([0x6658, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666]),\n I = gf([0xa0b0, 0x4a0e, 0x1b27, 0xc4ee, 0xe478, 0xad2f, 0x1806, 0x2f43, 0xd7a7, 0x3dfb, 0x0099, 0x2b4d, 0xdf0b, 0x4fc1, 0x2480, 0x2b83]);\n\nfunction ts64(x, i, h, l) {\n x[i] = (h >> 24) & 0xff;\n x[i+1] = (h >> 16) & 0xff;\n x[i+2] = (h >> 8) & 0xff;\n x[i+3] = h & 0xff;\n x[i+4] = (l >> 24) & 0xff;\n x[i+5] = (l >> 16) & 0xff;\n x[i+6] = (l >> 8) & 0xff;\n x[i+7] = l & 0xff;\n}\n\nfunction vn(x, xi, y, yi, n) {\n var i,d = 0;\n for (i = 0; i < n; i++) d |= x[xi+i]^y[yi+i];\n return (1 & ((d - 1) >>> 8)) - 1;\n}\n\nfunction crypto_verify_16(x, xi, y, yi) {\n return vn(x,xi,y,yi,16);\n}\n\nfunction crypto_verify_32(x, xi, y, yi) {\n return vn(x,xi,y,yi,32);\n}\n\nfunction core_salsa20(o, p, k, c) {\n var j0 = c[ 0] & 0xff | (c[ 1] & 0xff)<<8 | (c[ 2] & 0xff)<<16 | (c[ 3] & 0xff)<<24,\n j1 = k[ 0] & 0xff | (k[ 1] & 0xff)<<8 | (k[ 2] & 0xff)<<16 | (k[ 3] & 0xff)<<24,\n j2 = k[ 4] & 0xff | (k[ 5] & 0xff)<<8 | (k[ 6] & 0xff)<<16 | (k[ 7] & 0xff)<<24,\n j3 = k[ 8] & 0xff | (k[ 9] & 0xff)<<8 | (k[10] & 0xff)<<16 | (k[11] & 0xff)<<24,\n j4 = k[12] & 0xff | (k[13] & 0xff)<<8 | (k[14] & 0xff)<<16 | (k[15] & 0xff)<<24,\n j5 = c[ 4] & 0xff | (c[ 5] & 0xff)<<8 | (c[ 6] & 0xff)<<16 | (c[ 7] & 0xff)<<24,\n j6 = p[ 0] & 0xff | (p[ 1] & 0xff)<<8 | (p[ 2] & 0xff)<<16 | (p[ 3] & 0xff)<<24,\n j7 = p[ 4] & 0xff | (p[ 5] & 0xff)<<8 | (p[ 6] & 0xff)<<16 | (p[ 7] & 0xff)<<24,\n j8 = p[ 8] & 0xff | (p[ 9] & 0xff)<<8 | (p[10] & 0xff)<<16 | (p[11] & 0xff)<<24,\n j9 = p[12] & 0xff | (p[13] & 0xff)<<8 | (p[14] & 0xff)<<16 | (p[15] & 0xff)<<24,\n j10 = c[ 8] & 0xff | (c[ 9] & 0xff)<<8 | (c[10] & 0xff)<<16 | (c[11] & 0xff)<<24,\n j11 = k[16] & 0xff | (k[17] & 0xff)<<8 | (k[18] & 0xff)<<16 | (k[19] & 0xff)<<24,\n j12 = k[20] & 0xff | (k[21] & 0xff)<<8 | (k[22] & 0xff)<<16 | (k[23] & 0xff)<<24,\n j13 = k[24] & 0xff | (k[25] & 0xff)<<8 | (k[26] & 0xff)<<16 | (k[27] & 0xff)<<24,\n j14 = k[28] & 0xff | (k[29] & 0xff)<<8 | (k[30] & 0xff)<<16 | (k[31] & 0xff)<<24,\n j15 = c[12] & 0xff | (c[13] & 0xff)<<8 | (c[14] & 0xff)<<16 | (c[15] & 0xff)<<24;\n\n var x0 = j0, x1 = j1, x2 = j2, x3 = j3, x4 = j4, x5 = j5, x6 = j6, x7 = j7,\n x8 = j8, x9 = j9, x10 = j10, x11 = j11, x12 = j12, x13 = j13, x14 = j14,\n x15 = j15, u;\n\n for (var i = 0; i < 20; i += 2) {\n u = x0 + x12 | 0;\n x4 ^= u<<7 | u>>>(32-7);\n u = x4 + x0 | 0;\n x8 ^= u<<9 | u>>>(32-9);\n u = x8 + x4 | 0;\n x12 ^= u<<13 | u>>>(32-13);\n u = x12 + x8 | 0;\n x0 ^= u<<18 | u>>>(32-18);\n\n u = x5 + x1 | 0;\n x9 ^= u<<7 | u>>>(32-7);\n u = x9 + x5 | 0;\n x13 ^= u<<9 | u>>>(32-9);\n u = x13 + x9 | 0;\n x1 ^= u<<13 | u>>>(32-13);\n u = x1 + x13 | 0;\n x5 ^= u<<18 | u>>>(32-18);\n\n u = x10 + x6 | 0;\n x14 ^= u<<7 | u>>>(32-7);\n u = x14 + x10 | 0;\n x2 ^= u<<9 | u>>>(32-9);\n u = x2 + x14 | 0;\n x6 ^= u<<13 | u>>>(32-13);\n u = x6 + x2 | 0;\n x10 ^= u<<18 | u>>>(32-18);\n\n u = x15 + x11 | 0;\n x3 ^= u<<7 | u>>>(32-7);\n u = x3 + x15 | 0;\n x7 ^= u<<9 | u>>>(32-9);\n u = x7 + x3 | 0;\n x11 ^= u<<13 | u>>>(32-13);\n u = x11 + x7 | 0;\n x15 ^= u<<18 | u>>>(32-18);\n\n u = x0 + x3 | 0;\n x1 ^= u<<7 | u>>>(32-7);\n u = x1 + x0 | 0;\n x2 ^= u<<9 | u>>>(32-9);\n u = x2 + x1 | 0;\n x3 ^= u<<13 | u>>>(32-13);\n u = x3 + x2 | 0;\n x0 ^= u<<18 | u>>>(32-18);\n\n u = x5 + x4 | 0;\n x6 ^= u<<7 | u>>>(32-7);\n u = x6 + x5 | 0;\n x7 ^= u<<9 | u>>>(32-9);\n u = x7 + x6 | 0;\n x4 ^= u<<13 | u>>>(32-13);\n u = x4 + x7 | 0;\n x5 ^= u<<18 | u>>>(32-18);\n\n u = x10 + x9 | 0;\n x11 ^= u<<7 | u>>>(32-7);\n u = x11 + x10 | 0;\n x8 ^= u<<9 | u>>>(32-9);\n u = x8 + x11 | 0;\n x9 ^= u<<13 | u>>>(32-13);\n u = x9 + x8 | 0;\n x10 ^= u<<18 | u>>>(32-18);\n\n u = x15 + x14 | 0;\n x12 ^= u<<7 | u>>>(32-7);\n u = x12 + x15 | 0;\n x13 ^= u<<9 | u>>>(32-9);\n u = x13 + x12 | 0;\n x14 ^= u<<13 | u>>>(32-13);\n u = x14 + x13 | 0;\n x15 ^= u<<18 | u>>>(32-18);\n }\n x0 = x0 + j0 | 0;\n x1 = x1 + j1 | 0;\n x2 = x2 + j2 | 0;\n x3 = x3 + j3 | 0;\n x4 = x4 + j4 | 0;\n x5 = x5 + j5 | 0;\n x6 = x6 + j6 | 0;\n x7 = x7 + j7 | 0;\n x8 = x8 + j8 | 0;\n x9 = x9 + j9 | 0;\n x10 = x10 + j10 | 0;\n x11 = x11 + j11 | 0;\n x12 = x12 + j12 | 0;\n x13 = x13 + j13 | 0;\n x14 = x14 + j14 | 0;\n x15 = x15 + j15 | 0;\n\n o[ 0] = x0 >>> 0 & 0xff;\n o[ 1] = x0 >>> 8 & 0xff;\n o[ 2] = x0 >>> 16 & 0xff;\n o[ 3] = x0 >>> 24 & 0xff;\n\n o[ 4] = x1 >>> 0 & 0xff;\n o[ 5] = x1 >>> 8 & 0xff;\n o[ 6] = x1 >>> 16 & 0xff;\n o[ 7] = x1 >>> 24 & 0xff;\n\n o[ 8] = x2 >>> 0 & 0xff;\n o[ 9] = x2 >>> 8 & 0xff;\n o[10] = x2 >>> 16 & 0xff;\n o[11] = x2 >>> 24 & 0xff;\n\n o[12] = x3 >>> 0 & 0xff;\n o[13] = x3 >>> 8 & 0xff;\n o[14] = x3 >>> 16 & 0xff;\n o[15] = x3 >>> 24 & 0xff;\n\n o[16] = x4 >>> 0 & 0xff;\n o[17] = x4 >>> 8 & 0xff;\n o[18] = x4 >>> 16 & 0xff;\n o[19] = x4 >>> 24 & 0xff;\n\n o[20] = x5 >>> 0 & 0xff;\n o[21] = x5 >>> 8 & 0xff;\n o[22] = x5 >>> 16 & 0xff;\n o[23] = x5 >>> 24 & 0xff;\n\n o[24] = x6 >>> 0 & 0xff;\n o[25] = x6 >>> 8 & 0xff;\n o[26] = x6 >>> 16 & 0xff;\n o[27] = x6 >>> 24 & 0xff;\n\n o[28] = x7 >>> 0 & 0xff;\n o[29] = x7 >>> 8 & 0xff;\n o[30] = x7 >>> 16 & 0xff;\n o[31] = x7 >>> 24 & 0xff;\n\n o[32] = x8 >>> 0 & 0xff;\n o[33] = x8 >>> 8 & 0xff;\n o[34] = x8 >>> 16 & 0xff;\n o[35] = x8 >>> 24 & 0xff;\n\n o[36] = x9 >>> 0 & 0xff;\n o[37] = x9 >>> 8 & 0xff;\n o[38] = x9 >>> 16 & 0xff;\n o[39] = x9 >>> 24 & 0xff;\n\n o[40] = x10 >>> 0 & 0xff;\n o[41] = x10 >>> 8 & 0xff;\n o[42] = x10 >>> 16 & 0xff;\n o[43] = x10 >>> 24 & 0xff;\n\n o[44] = x11 >>> 0 & 0xff;\n o[45] = x11 >>> 8 & 0xff;\n o[46] = x11 >>> 16 & 0xff;\n o[47] = x11 >>> 24 & 0xff;\n\n o[48] = x12 >>> 0 & 0xff;\n o[49] = x12 >>> 8 & 0xff;\n o[50] = x12 >>> 16 & 0xff;\n o[51] = x12 >>> 24 & 0xff;\n\n o[52] = x13 >>> 0 & 0xff;\n o[53] = x13 >>> 8 & 0xff;\n o[54] = x13 >>> 16 & 0xff;\n o[55] = x13 >>> 24 & 0xff;\n\n o[56] = x14 >>> 0 & 0xff;\n o[57] = x14 >>> 8 & 0xff;\n o[58] = x14 >>> 16 & 0xff;\n o[59] = x14 >>> 24 & 0xff;\n\n o[60] = x15 >>> 0 & 0xff;\n o[61] = x15 >>> 8 & 0xff;\n o[62] = x15 >>> 16 & 0xff;\n o[63] = x15 >>> 24 & 0xff;\n}\n\nfunction core_hsalsa20(o,p,k,c) {\n var j0 = c[ 0] & 0xff | (c[ 1] & 0xff)<<8 | (c[ 2] & 0xff)<<16 | (c[ 3] & 0xff)<<24,\n j1 = k[ 0] & 0xff | (k[ 1] & 0xff)<<8 | (k[ 2] & 0xff)<<16 | (k[ 3] & 0xff)<<24,\n j2 = k[ 4] & 0xff | (k[ 5] & 0xff)<<8 | (k[ 6] & 0xff)<<16 | (k[ 7] & 0xff)<<24,\n j3 = k[ 8] & 0xff | (k[ 9] & 0xff)<<8 | (k[10] & 0xff)<<16 | (k[11] & 0xff)<<24,\n j4 = k[12] & 0xff | (k[13] & 0xff)<<8 | (k[14] & 0xff)<<16 | (k[15] & 0xff)<<24,\n j5 = c[ 4] & 0xff | (c[ 5] & 0xff)<<8 | (c[ 6] & 0xff)<<16 | (c[ 7] & 0xff)<<24,\n j6 = p[ 0] & 0xff | (p[ 1] & 0xff)<<8 | (p[ 2] & 0xff)<<16 | (p[ 3] & 0xff)<<24,\n j7 = p[ 4] & 0xff | (p[ 5] & 0xff)<<8 | (p[ 6] & 0xff)<<16 | (p[ 7] & 0xff)<<24,\n j8 = p[ 8] & 0xff | (p[ 9] & 0xff)<<8 | (p[10] & 0xff)<<16 | (p[11] & 0xff)<<24,\n j9 = p[12] & 0xff | (p[13] & 0xff)<<8 | (p[14] & 0xff)<<16 | (p[15] & 0xff)<<24,\n j10 = c[ 8] & 0xff | (c[ 9] & 0xff)<<8 | (c[10] & 0xff)<<16 | (c[11] & 0xff)<<24,\n j11 = k[16] & 0xff | (k[17] & 0xff)<<8 | (k[18] & 0xff)<<16 | (k[19] & 0xff)<<24,\n j12 = k[20] & 0xff | (k[21] & 0xff)<<8 | (k[22] & 0xff)<<16 | (k[23] & 0xff)<<24,\n j13 = k[24] & 0xff | (k[25] & 0xff)<<8 | (k[26] & 0xff)<<16 | (k[27] & 0xff)<<24,\n j14 = k[28] & 0xff | (k[29] & 0xff)<<8 | (k[30] & 0xff)<<16 | (k[31] & 0xff)<<24,\n j15 = c[12] & 0xff | (c[13] & 0xff)<<8 | (c[14] & 0xff)<<16 | (c[15] & 0xff)<<24;\n\n var x0 = j0, x1 = j1, x2 = j2, x3 = j3, x4 = j4, x5 = j5, x6 = j6, x7 = j7,\n x8 = j8, x9 = j9, x10 = j10, x11 = j11, x12 = j12, x13 = j13, x14 = j14,\n x15 = j15, u;\n\n for (var i = 0; i < 20; i += 2) {\n u = x0 + x12 | 0;\n x4 ^= u<<7 | u>>>(32-7);\n u = x4 + x0 | 0;\n x8 ^= u<<9 | u>>>(32-9);\n u = x8 + x4 | 0;\n x12 ^= u<<13 | u>>>(32-13);\n u = x12 + x8 | 0;\n x0 ^= u<<18 | u>>>(32-18);\n\n u = x5 + x1 | 0;\n x9 ^= u<<7 | u>>>(32-7);\n u = x9 + x5 | 0;\n x13 ^= u<<9 | u>>>(32-9);\n u = x13 + x9 | 0;\n x1 ^= u<<13 | u>>>(32-13);\n u = x1 + x13 | 0;\n x5 ^= u<<18 | u>>>(32-18);\n\n u = x10 + x6 | 0;\n x14 ^= u<<7 | u>>>(32-7);\n u = x14 + x10 | 0;\n x2 ^= u<<9 | u>>>(32-9);\n u = x2 + x14 | 0;\n x6 ^= u<<13 | u>>>(32-13);\n u = x6 + x2 | 0;\n x10 ^= u<<18 | u>>>(32-18);\n\n u = x15 + x11 | 0;\n x3 ^= u<<7 | u>>>(32-7);\n u = x3 + x15 | 0;\n x7 ^= u<<9 | u>>>(32-9);\n u = x7 + x3 | 0;\n x11 ^= u<<13 | u>>>(32-13);\n u = x11 + x7 | 0;\n x15 ^= u<<18 | u>>>(32-18);\n\n u = x0 + x3 | 0;\n x1 ^= u<<7 | u>>>(32-7);\n u = x1 + x0 | 0;\n x2 ^= u<<9 | u>>>(32-9);\n u = x2 + x1 | 0;\n x3 ^= u<<13 | u>>>(32-13);\n u = x3 + x2 | 0;\n x0 ^= u<<18 | u>>>(32-18);\n\n u = x5 + x4 | 0;\n x6 ^= u<<7 | u>>>(32-7);\n u = x6 + x5 | 0;\n x7 ^= u<<9 | u>>>(32-9);\n u = x7 + x6 | 0;\n x4 ^= u<<13 | u>>>(32-13);\n u = x4 + x7 | 0;\n x5 ^= u<<18 | u>>>(32-18);\n\n u = x10 + x9 | 0;\n x11 ^= u<<7 | u>>>(32-7);\n u = x11 + x10 | 0;\n x8 ^= u<<9 | u>>>(32-9);\n u = x8 + x11 | 0;\n x9 ^= u<<13 | u>>>(32-13);\n u = x9 + x8 | 0;\n x10 ^= u<<18 | u>>>(32-18);\n\n u = x15 + x14 | 0;\n x12 ^= u<<7 | u>>>(32-7);\n u = x12 + x15 | 0;\n x13 ^= u<<9 | u>>>(32-9);\n u = x13 + x12 | 0;\n x14 ^= u<<13 | u>>>(32-13);\n u = x14 + x13 | 0;\n x15 ^= u<<18 | u>>>(32-18);\n }\n\n o[ 0] = x0 >>> 0 & 0xff;\n o[ 1] = x0 >>> 8 & 0xff;\n o[ 2] = x0 >>> 16 & 0xff;\n o[ 3] = x0 >>> 24 & 0xff;\n\n o[ 4] = x5 >>> 0 & 0xff;\n o[ 5] = x5 >>> 8 & 0xff;\n o[ 6] = x5 >>> 16 & 0xff;\n o[ 7] = x5 >>> 24 & 0xff;\n\n o[ 8] = x10 >>> 0 & 0xff;\n o[ 9] = x10 >>> 8 & 0xff;\n o[10] = x10 >>> 16 & 0xff;\n o[11] = x10 >>> 24 & 0xff;\n\n o[12] = x15 >>> 0 & 0xff;\n o[13] = x15 >>> 8 & 0xff;\n o[14] = x15 >>> 16 & 0xff;\n o[15] = x15 >>> 24 & 0xff;\n\n o[16] = x6 >>> 0 & 0xff;\n o[17] = x6 >>> 8 & 0xff;\n o[18] = x6 >>> 16 & 0xff;\n o[19] = x6 >>> 24 & 0xff;\n\n o[20] = x7 >>> 0 & 0xff;\n o[21] = x7 >>> 8 & 0xff;\n o[22] = x7 >>> 16 & 0xff;\n o[23] = x7 >>> 24 & 0xff;\n\n o[24] = x8 >>> 0 & 0xff;\n o[25] = x8 >>> 8 & 0xff;\n o[26] = x8 >>> 16 & 0xff;\n o[27] = x8 >>> 24 & 0xff;\n\n o[28] = x9 >>> 0 & 0xff;\n o[29] = x9 >>> 8 & 0xff;\n o[30] = x9 >>> 16 & 0xff;\n o[31] = x9 >>> 24 & 0xff;\n}\n\nfunction crypto_core_salsa20(out,inp,k,c) {\n core_salsa20(out,inp,k,c);\n}\n\nfunction crypto_core_hsalsa20(out,inp,k,c) {\n core_hsalsa20(out,inp,k,c);\n}\n\nvar sigma = new Uint8Array([101, 120, 112, 97, 110, 100, 32, 51, 50, 45, 98, 121, 116, 101, 32, 107]);\n // \"expand 32-byte k\"\n\nfunction crypto_stream_salsa20_xor(c,cpos,m,mpos,b,n,k) {\n var z = new Uint8Array(16), x = new Uint8Array(64);\n var u, i;\n for (i = 0; i < 16; i++) z[i] = 0;\n for (i = 0; i < 8; i++) z[i] = n[i];\n while (b >= 64) {\n crypto_core_salsa20(x,z,k,sigma);\n for (i = 0; i < 64; i++) c[cpos+i] = m[mpos+i] ^ x[i];\n u = 1;\n for (i = 8; i < 16; i++) {\n u = u + (z[i] & 0xff) | 0;\n z[i] = u & 0xff;\n u >>>= 8;\n }\n b -= 64;\n cpos += 64;\n mpos += 64;\n }\n if (b > 0) {\n crypto_core_salsa20(x,z,k,sigma);\n for (i = 0; i < b; i++) c[cpos+i] = m[mpos+i] ^ x[i];\n }\n return 0;\n}\n\nfunction crypto_stream_salsa20(c,cpos,b,n,k) {\n var z = new Uint8Array(16), x = new Uint8Array(64);\n var u, i;\n for (i = 0; i < 16; i++) z[i] = 0;\n for (i = 0; i < 8; i++) z[i] = n[i];\n while (b >= 64) {\n crypto_core_salsa20(x,z,k,sigma);\n for (i = 0; i < 64; i++) c[cpos+i] = x[i];\n u = 1;\n for (i = 8; i < 16; i++) {\n u = u + (z[i] & 0xff) | 0;\n z[i] = u & 0xff;\n u >>>= 8;\n }\n b -= 64;\n cpos += 64;\n }\n if (b > 0) {\n crypto_core_salsa20(x,z,k,sigma);\n for (i = 0; i < b; i++) c[cpos+i] = x[i];\n }\n return 0;\n}\n\nfunction crypto_stream(c,cpos,d,n,k) {\n var s = new Uint8Array(32);\n crypto_core_hsalsa20(s,n,k,sigma);\n var sn = new Uint8Array(8);\n for (var i = 0; i < 8; i++) sn[i] = n[i+16];\n return crypto_stream_salsa20(c,cpos,d,sn,s);\n}\n\nfunction crypto_stream_xor(c,cpos,m,mpos,d,n,k) {\n var s = new Uint8Array(32);\n crypto_core_hsalsa20(s,n,k,sigma);\n var sn = new Uint8Array(8);\n for (var i = 0; i < 8; i++) sn[i] = n[i+16];\n return crypto_stream_salsa20_xor(c,cpos,m,mpos,d,sn,s);\n}\n\n/*\n* Port of Andrew Moon's Poly1305-donna-16. Public domain.\n* https://github.com/floodyberry/poly1305-donna\n*/\n\nvar poly1305 = function(key) {\n this.buffer = new Uint8Array(16);\n this.r = new Uint16Array(10);\n this.h = new Uint16Array(10);\n this.pad = new Uint16Array(8);\n this.leftover = 0;\n this.fin = 0;\n\n var t0, t1, t2, t3, t4, t5, t6, t7;\n\n t0 = key[ 0] & 0xff | (key[ 1] & 0xff) << 8; this.r[0] = ( t0 ) & 0x1fff;\n t1 = key[ 2] & 0xff | (key[ 3] & 0xff) << 8; this.r[1] = ((t0 >>> 13) | (t1 << 3)) & 0x1fff;\n t2 = key[ 4] & 0xff | (key[ 5] & 0xff) << 8; this.r[2] = ((t1 >>> 10) | (t2 << 6)) & 0x1f03;\n t3 = key[ 6] & 0xff | (key[ 7] & 0xff) << 8; this.r[3] = ((t2 >>> 7) | (t3 << 9)) & 0x1fff;\n t4 = key[ 8] & 0xff | (key[ 9] & 0xff) << 8; this.r[4] = ((t3 >>> 4) | (t4 << 12)) & 0x00ff;\n this.r[5] = ((t4 >>> 1)) & 0x1ffe;\n t5 = key[10] & 0xff | (key[11] & 0xff) << 8; this.r[6] = ((t4 >>> 14) | (t5 << 2)) & 0x1fff;\n t6 = key[12] & 0xff | (key[13] & 0xff) << 8; this.r[7] = ((t5 >>> 11) | (t6 << 5)) & 0x1f81;\n t7 = key[14] & 0xff | (key[15] & 0xff) << 8; this.r[8] = ((t6 >>> 8) | (t7 << 8)) & 0x1fff;\n this.r[9] = ((t7 >>> 5)) & 0x007f;\n\n this.pad[0] = key[16] & 0xff | (key[17] & 0xff) << 8;\n this.pad[1] = key[18] & 0xff | (key[19] & 0xff) << 8;\n this.pad[2] = key[20] & 0xff | (key[21] & 0xff) << 8;\n this.pad[3] = key[22] & 0xff | (key[23] & 0xff) << 8;\n this.pad[4] = key[24] & 0xff | (key[25] & 0xff) << 8;\n this.pad[5] = key[26] & 0xff | (key[27] & 0xff) << 8;\n this.pad[6] = key[28] & 0xff | (key[29] & 0xff) << 8;\n this.pad[7] = key[30] & 0xff | (key[31] & 0xff) << 8;\n};\n\npoly1305.prototype.blocks = function(m, mpos, bytes) {\n var hibit = this.fin ? 0 : (1 << 11);\n var t0, t1, t2, t3, t4, t5, t6, t7, c;\n var d0, d1, d2, d3, d4, d5, d6, d7, d8, d9;\n\n var h0 = this.h[0],\n h1 = this.h[1],\n h2 = this.h[2],\n h3 = this.h[3],\n h4 = this.h[4],\n h5 = this.h[5],\n h6 = this.h[6],\n h7 = this.h[7],\n h8 = this.h[8],\n h9 = this.h[9];\n\n var r0 = this.r[0],\n r1 = this.r[1],\n r2 = this.r[2],\n r3 = this.r[3],\n r4 = this.r[4],\n r5 = this.r[5],\n r6 = this.r[6],\n r7 = this.r[7],\n r8 = this.r[8],\n r9 = this.r[9];\n\n while (bytes >= 16) {\n t0 = m[mpos+ 0] & 0xff | (m[mpos+ 1] & 0xff) << 8; h0 += ( t0 ) & 0x1fff;\n t1 = m[mpos+ 2] & 0xff | (m[mpos+ 3] & 0xff) << 8; h1 += ((t0 >>> 13) | (t1 << 3)) & 0x1fff;\n t2 = m[mpos+ 4] & 0xff | (m[mpos+ 5] & 0xff) << 8; h2 += ((t1 >>> 10) | (t2 << 6)) & 0x1fff;\n t3 = m[mpos+ 6] & 0xff | (m[mpos+ 7] & 0xff) << 8; h3 += ((t2 >>> 7) | (t3 << 9)) & 0x1fff;\n t4 = m[mpos+ 8] & 0xff | (m[mpos+ 9] & 0xff) << 8; h4 += ((t3 >>> 4) | (t4 << 12)) & 0x1fff;\n h5 += ((t4 >>> 1)) & 0x1fff;\n t5 = m[mpos+10] & 0xff | (m[mpos+11] & 0xff) << 8; h6 += ((t4 >>> 14) | (t5 << 2)) & 0x1fff;\n t6 = m[mpos+12] & 0xff | (m[mpos+13] & 0xff) << 8; h7 += ((t5 >>> 11) | (t6 << 5)) & 0x1fff;\n t7 = m[mpos+14] & 0xff | (m[mpos+15] & 0xff) << 8; h8 += ((t6 >>> 8) | (t7 << 8)) & 0x1fff;\n h9 += ((t7 >>> 5)) | hibit;\n\n c = 0;\n\n d0 = c;\n d0 += h0 * r0;\n d0 += h1 * (5 * r9);\n d0 += h2 * (5 * r8);\n d0 += h3 * (5 * r7);\n d0 += h4 * (5 * r6);\n c = (d0 >>> 13); d0 &= 0x1fff;\n d0 += h5 * (5 * r5);\n d0 += h6 * (5 * r4);\n d0 += h7 * (5 * r3);\n d0 += h8 * (5 * r2);\n d0 += h9 * (5 * r1);\n c += (d0 >>> 13); d0 &= 0x1fff;\n\n d1 = c;\n d1 += h0 * r1;\n d1 += h1 * r0;\n d1 += h2 * (5 * r9);\n d1 += h3 * (5 * r8);\n d1 += h4 * (5 * r7);\n c = (d1 >>> 13); d1 &= 0x1fff;\n d1 += h5 * (5 * r6);\n d1 += h6 * (5 * r5);\n d1 += h7 * (5 * r4);\n d1 += h8 * (5 * r3);\n d1 += h9 * (5 * r2);\n c += (d1 >>> 13); d1 &= 0x1fff;\n\n d2 = c;\n d2 += h0 * r2;\n d2 += h1 * r1;\n d2 += h2 * r0;\n d2 += h3 * (5 * r9);\n d2 += h4 * (5 * r8);\n c = (d2 >>> 13); d2 &= 0x1fff;\n d2 += h5 * (5 * r7);\n d2 += h6 * (5 * r6);\n d2 += h7 * (5 * r5);\n d2 += h8 * (5 * r4);\n d2 += h9 * (5 * r3);\n c += (d2 >>> 13); d2 &= 0x1fff;\n\n d3 = c;\n d3 += h0 * r3;\n d3 += h1 * r2;\n d3 += h2 * r1;\n d3 += h3 * r0;\n d3 += h4 * (5 * r9);\n c = (d3 >>> 13); d3 &= 0x1fff;\n d3 += h5 * (5 * r8);\n d3 += h6 * (5 * r7);\n d3 += h7 * (5 * r6);\n d3 += h8 * (5 * r5);\n d3 += h9 * (5 * r4);\n c += (d3 >>> 13); d3 &= 0x1fff;\n\n d4 = c;\n d4 += h0 * r4;\n d4 += h1 * r3;\n d4 += h2 * r2;\n d4 += h3 * r1;\n d4 += h4 * r0;\n c = (d4 >>> 13); d4 &= 0x1fff;\n d4 += h5 * (5 * r9);\n d4 += h6 * (5 * r8);\n d4 += h7 * (5 * r7);\n d4 += h8 * (5 * r6);\n d4 += h9 * (5 * r5);\n c += (d4 >>> 13); d4 &= 0x1fff;\n\n d5 = c;\n d5 += h0 * r5;\n d5 += h1 * r4;\n d5 += h2 * r3;\n d5 += h3 * r2;\n d5 += h4 * r1;\n c = (d5 >>> 13); d5 &= 0x1fff;\n d5 += h5 * r0;\n d5 += h6 * (5 * r9);\n d5 += h7 * (5 * r8);\n d5 += h8 * (5 * r7);\n d5 += h9 * (5 * r6);\n c += (d5 >>> 13); d5 &= 0x1fff;\n\n d6 = c;\n d6 += h0 * r6;\n d6 += h1 * r5;\n d6 += h2 * r4;\n d6 += h3 * r3;\n d6 += h4 * r2;\n c = (d6 >>> 13); d6 &= 0x1fff;\n d6 += h5 * r1;\n d6 += h6 * r0;\n d6 += h7 * (5 * r9);\n d6 += h8 * (5 * r8);\n d6 += h9 * (5 * r7);\n c += (d6 >>> 13); d6 &= 0x1fff;\n\n d7 = c;\n d7 += h0 * r7;\n d7 += h1 * r6;\n d7 += h2 * r5;\n d7 += h3 * r4;\n d7 += h4 * r3;\n c = (d7 >>> 13); d7 &= 0x1fff;\n d7 += h5 * r2;\n d7 += h6 * r1;\n d7 += h7 * r0;\n d7 += h8 * (5 * r9);\n d7 += h9 * (5 * r8);\n c += (d7 >>> 13); d7 &= 0x1fff;\n\n d8 = c;\n d8 += h0 * r8;\n d8 += h1 * r7;\n d8 += h2 * r6;\n d8 += h3 * r5;\n d8 += h4 * r4;\n c = (d8 >>> 13); d8 &= 0x1fff;\n d8 += h5 * r3;\n d8 += h6 * r2;\n d8 += h7 * r1;\n d8 += h8 * r0;\n d8 += h9 * (5 * r9);\n c += (d8 >>> 13); d8 &= 0x1fff;\n\n d9 = c;\n d9 += h0 * r9;\n d9 += h1 * r8;\n d9 += h2 * r7;\n d9 += h3 * r6;\n d9 += h4 * r5;\n c = (d9 >>> 13); d9 &= 0x1fff;\n d9 += h5 * r4;\n d9 += h6 * r3;\n d9 += h7 * r2;\n d9 += h8 * r1;\n d9 += h9 * r0;\n c += (d9 >>> 13); d9 &= 0x1fff;\n\n c = (((c << 2) + c)) | 0;\n c = (c + d0) | 0;\n d0 = c & 0x1fff;\n c = (c >>> 13);\n d1 += c;\n\n h0 = d0;\n h1 = d1;\n h2 = d2;\n h3 = d3;\n h4 = d4;\n h5 = d5;\n h6 = d6;\n h7 = d7;\n h8 = d8;\n h9 = d9;\n\n mpos += 16;\n bytes -= 16;\n }\n this.h[0] = h0;\n this.h[1] = h1;\n this.h[2] = h2;\n this.h[3] = h3;\n this.h[4] = h4;\n this.h[5] = h5;\n this.h[6] = h6;\n this.h[7] = h7;\n this.h[8] = h8;\n this.h[9] = h9;\n};\n\npoly1305.prototype.finish = function(mac, macpos) {\n var g = new Uint16Array(10);\n var c, mask, f, i;\n\n if (this.leftover) {\n i = this.leftover;\n this.buffer[i++] = 1;\n for (; i < 16; i++) this.buffer[i] = 0;\n this.fin = 1;\n this.blocks(this.buffer, 0, 16);\n }\n\n c = this.h[1] >>> 13;\n this.h[1] &= 0x1fff;\n for (i = 2; i < 10; i++) {\n this.h[i] += c;\n c = this.h[i] >>> 13;\n this.h[i] &= 0x1fff;\n }\n this.h[0] += (c * 5);\n c = this.h[0] >>> 13;\n this.h[0] &= 0x1fff;\n this.h[1] += c;\n c = this.h[1] >>> 13;\n this.h[1] &= 0x1fff;\n this.h[2] += c;\n\n g[0] = this.h[0] + 5;\n c = g[0] >>> 13;\n g[0] &= 0x1fff;\n for (i = 1; i < 10; i++) {\n g[i] = this.h[i] + c;\n c = g[i] >>> 13;\n g[i] &= 0x1fff;\n }\n g[9] -= (1 << 13);\n\n mask = (c ^ 1) - 1;\n for (i = 0; i < 10; i++) g[i] &= mask;\n mask = ~mask;\n for (i = 0; i < 10; i++) this.h[i] = (this.h[i] & mask) | g[i];\n\n this.h[0] = ((this.h[0] ) | (this.h[1] << 13) ) & 0xffff;\n this.h[1] = ((this.h[1] >>> 3) | (this.h[2] << 10) ) & 0xffff;\n this.h[2] = ((this.h[2] >>> 6) | (this.h[3] << 7) ) & 0xffff;\n this.h[3] = ((this.h[3] >>> 9) | (this.h[4] << 4) ) & 0xffff;\n this.h[4] = ((this.h[4] >>> 12) | (this.h[5] << 1) | (this.h[6] << 14)) & 0xffff;\n this.h[5] = ((this.h[6] >>> 2) | (this.h[7] << 11) ) & 0xffff;\n this.h[6] = ((this.h[7] >>> 5) | (this.h[8] << 8) ) & 0xffff;\n this.h[7] = ((this.h[8] >>> 8) | (this.h[9] << 5) ) & 0xffff;\n\n f = this.h[0] + this.pad[0];\n this.h[0] = f & 0xffff;\n for (i = 1; i < 8; i++) {\n f = (((this.h[i] + this.pad[i]) | 0) + (f >>> 16)) | 0;\n this.h[i] = f & 0xffff;\n }\n\n mac[macpos+ 0] = (this.h[0] >>> 0) & 0xff;\n mac[macpos+ 1] = (this.h[0] >>> 8) & 0xff;\n mac[macpos+ 2] = (this.h[1] >>> 0) & 0xff;\n mac[macpos+ 3] = (this.h[1] >>> 8) & 0xff;\n mac[macpos+ 4] = (this.h[2] >>> 0) & 0xff;\n mac[macpos+ 5] = (this.h[2] >>> 8) & 0xff;\n mac[macpos+ 6] = (this.h[3] >>> 0) & 0xff;\n mac[macpos+ 7] = (this.h[3] >>> 8) & 0xff;\n mac[macpos+ 8] = (this.h[4] >>> 0) & 0xff;\n mac[macpos+ 9] = (this.h[4] >>> 8) & 0xff;\n mac[macpos+10] = (this.h[5] >>> 0) & 0xff;\n mac[macpos+11] = (this.h[5] >>> 8) & 0xff;\n mac[macpos+12] = (this.h[6] >>> 0) & 0xff;\n mac[macpos+13] = (this.h[6] >>> 8) & 0xff;\n mac[macpos+14] = (this.h[7] >>> 0) & 0xff;\n mac[macpos+15] = (this.h[7] >>> 8) & 0xff;\n};\n\npoly1305.prototype.update = function(m, mpos, bytes) {\n var i, want;\n\n if (this.leftover) {\n want = (16 - this.leftover);\n if (want > bytes)\n want = bytes;\n for (i = 0; i < want; i++)\n this.buffer[this.leftover + i] = m[mpos+i];\n bytes -= want;\n mpos += want;\n this.leftover += want;\n if (this.leftover < 16)\n return;\n this.blocks(this.buffer, 0, 16);\n this.leftover = 0;\n }\n\n if (bytes >= 16) {\n want = bytes - (bytes % 16);\n this.blocks(m, mpos, want);\n mpos += want;\n bytes -= want;\n }\n\n if (bytes) {\n for (i = 0; i < bytes; i++)\n this.buffer[this.leftover + i] = m[mpos+i];\n this.leftover += bytes;\n }\n};\n\nfunction crypto_onetimeauth(out, outpos, m, mpos, n, k) {\n var s = new poly1305(k);\n s.update(m, mpos, n);\n s.finish(out, outpos);\n return 0;\n}\n\nfunction crypto_onetimeauth_verify(h, hpos, m, mpos, n, k) {\n var x = new Uint8Array(16);\n crypto_onetimeauth(x,0,m,mpos,n,k);\n return crypto_verify_16(h,hpos,x,0);\n}\n\nfunction crypto_secretbox(c,m,d,n,k) {\n var i;\n if (d < 32) return -1;\n crypto_stream_xor(c,0,m,0,d,n,k);\n crypto_onetimeauth(c, 16, c, 32, d - 32, c);\n for (i = 0; i < 16; i++) c[i] = 0;\n return 0;\n}\n\nfunction crypto_secretbox_open(m,c,d,n,k) {\n var i;\n var x = new Uint8Array(32);\n if (d < 32) return -1;\n crypto_stream(x,0,32,n,k);\n if (crypto_onetimeauth_verify(c, 16,c, 32,d - 32,x) !== 0) return -1;\n crypto_stream_xor(m,0,c,0,d,n,k);\n for (i = 0; i < 32; i++) m[i] = 0;\n return 0;\n}\n\nfunction set25519(r, a) {\n var i;\n for (i = 0; i < 16; i++) r[i] = a[i]|0;\n}\n\nfunction car25519(o) {\n var i, v, c = 1;\n for (i = 0; i < 16; i++) {\n v = o[i] + c + 65535;\n c = Math.floor(v / 65536);\n o[i] = v - c * 65536;\n }\n o[0] += c-1 + 37 * (c-1);\n}\n\nfunction sel25519(p, q, b) {\n var t, c = ~(b-1);\n for (var i = 0; i < 16; i++) {\n t = c & (p[i] ^ q[i]);\n p[i] ^= t;\n q[i] ^= t;\n }\n}\n\nfunction pack25519(o, n) {\n var i, j, b;\n var m = gf(), t = gf();\n for (i = 0; i < 16; i++) t[i] = n[i];\n car25519(t);\n car25519(t);\n car25519(t);\n for (j = 0; j < 2; j++) {\n m[0] = t[0] - 0xffed;\n for (i = 1; i < 15; i++) {\n m[i] = t[i] - 0xffff - ((m[i-1]>>16) & 1);\n m[i-1] &= 0xffff;\n }\n m[15] = t[15] - 0x7fff - ((m[14]>>16) & 1);\n b = (m[15]>>16) & 1;\n m[14] &= 0xffff;\n sel25519(t, m, 1-b);\n }\n for (i = 0; i < 16; i++) {\n o[2*i] = t[i] & 0xff;\n o[2*i+1] = t[i]>>8;\n }\n}\n\nfunction neq25519(a, b) {\n var c = new Uint8Array(32), d = new Uint8Array(32);\n pack25519(c, a);\n pack25519(d, b);\n return crypto_verify_32(c, 0, d, 0);\n}\n\nfunction par25519(a) {\n var d = new Uint8Array(32);\n pack25519(d, a);\n return d[0] & 1;\n}\n\nfunction unpack25519(o, n) {\n var i;\n for (i = 0; i < 16; i++) o[i] = n[2*i] + (n[2*i+1] << 8);\n o[15] &= 0x7fff;\n}\n\nfunction A(o, a, b) {\n for (var i = 0; i < 16; i++) o[i] = a[i] + b[i];\n}\n\nfunction Z(o, a, b) {\n for (var i = 0; i < 16; i++) o[i] = a[i] - b[i];\n}\n\nfunction M(o, a, b) {\n var v, c,\n t0 = 0, t1 = 0, t2 = 0, t3 = 0, t4 = 0, t5 = 0, t6 = 0, t7 = 0,\n t8 = 0, t9 = 0, t10 = 0, t11 = 0, t12 = 0, t13 = 0, t14 = 0, t15 = 0,\n t16 = 0, t17 = 0, t18 = 0, t19 = 0, t20 = 0, t21 = 0, t22 = 0, t23 = 0,\n t24 = 0, t25 = 0, t26 = 0, t27 = 0, t28 = 0, t29 = 0, t30 = 0,\n b0 = b[0],\n b1 = b[1],\n b2 = b[2],\n b3 = b[3],\n b4 = b[4],\n b5 = b[5],\n b6 = b[6],\n b7 = b[7],\n b8 = b[8],\n b9 = b[9],\n b10 = b[10],\n b11 = b[11],\n b12 = b[12],\n b13 = b[13],\n b14 = b[14],\n b15 = b[15];\n\n v = a[0];\n t0 += v * b0;\n t1 += v * b1;\n t2 += v * b2;\n t3 += v * b3;\n t4 += v * b4;\n t5 += v * b5;\n t6 += v * b6;\n t7 += v * b7;\n t8 += v * b8;\n t9 += v * b9;\n t10 += v * b10;\n t11 += v * b11;\n t12 += v * b12;\n t13 += v * b13;\n t14 += v * b14;\n t15 += v * b15;\n v = a[1];\n t1 += v * b0;\n t2 += v * b1;\n t3 += v * b2;\n t4 += v * b3;\n t5 += v * b4;\n t6 += v * b5;\n t7 += v * b6;\n t8 += v * b7;\n t9 += v * b8;\n t10 += v * b9;\n t11 += v * b10;\n t12 += v * b11;\n t13 += v * b12;\n t14 += v * b13;\n t15 += v * b14;\n t16 += v * b15;\n v = a[2];\n t2 += v * b0;\n t3 += v * b1;\n t4 += v * b2;\n t5 += v * b3;\n t6 += v * b4;\n t7 += v * b5;\n t8 += v * b6;\n t9 += v * b7;\n t10 += v * b8;\n t11 += v * b9;\n t12 += v * b10;\n t13 += v * b11;\n t14 += v * b12;\n t15 += v * b13;\n t16 += v * b14;\n t17 += v * b15;\n v = a[3];\n t3 += v * b0;\n t4 += v * b1;\n t5 += v * b2;\n t6 += v * b3;\n t7 += v * b4;\n t8 += v * b5;\n t9 += v * b6;\n t10 += v * b7;\n t11 += v * b8;\n t12 += v * b9;\n t13 += v * b10;\n t14 += v * b11;\n t15 += v * b12;\n t16 += v * b13;\n t17 += v * b14;\n t18 += v * b15;\n v = a[4];\n t4 += v * b0;\n t5 += v * b1;\n t6 += v * b2;\n t7 += v * b3;\n t8 += v * b4;\n t9 += v * b5;\n t10 += v * b6;\n t11 += v * b7;\n t12 += v * b8;\n t13 += v * b9;\n t14 += v * b10;\n t15 += v * b11;\n t16 += v * b12;\n t17 += v * b13;\n t18 += v * b14;\n t19 += v * b15;\n v = a[5];\n t5 += v * b0;\n t6 += v * b1;\n t7 += v * b2;\n t8 += v * b3;\n t9 += v * b4;\n t10 += v * b5;\n t11 += v * b6;\n t12 += v * b7;\n t13 += v * b8;\n t14 += v * b9;\n t15 += v * b10;\n t16 += v * b11;\n t17 += v * b12;\n t18 += v * b13;\n t19 += v * b14;\n t20 += v * b15;\n v = a[6];\n t6 += v * b0;\n t7 += v * b1;\n t8 += v * b2;\n t9 += v * b3;\n t10 += v * b4;\n t11 += v * b5;\n t12 += v * b6;\n t13 += v * b7;\n t14 += v * b8;\n t15 += v * b9;\n t16 += v * b10;\n t17 += v * b11;\n t18 += v * b12;\n t19 += v * b13;\n t20 += v * b14;\n t21 += v * b15;\n v = a[7];\n t7 += v * b0;\n t8 += v * b1;\n t9 += v * b2;\n t10 += v * b3;\n t11 += v * b4;\n t12 += v * b5;\n t13 += v * b6;\n t14 += v * b7;\n t15 += v * b8;\n t16 += v * b9;\n t17 += v * b10;\n t18 += v * b11;\n t19 += v * b12;\n t20 += v * b13;\n t21 += v * b14;\n t22 += v * b15;\n v = a[8];\n t8 += v * b0;\n t9 += v * b1;\n t10 += v * b2;\n t11 += v * b3;\n t12 += v * b4;\n t13 += v * b5;\n t14 += v * b6;\n t15 += v * b7;\n t16 += v * b8;\n t17 += v * b9;\n t18 += v * b10;\n t19 += v * b11;\n t20 += v * b12;\n t21 += v * b13;\n t22 += v * b14;\n t23 += v * b15;\n v = a[9];\n t9 += v * b0;\n t10 += v * b1;\n t11 += v * b2;\n t12 += v * b3;\n t13 += v * b4;\n t14 += v * b5;\n t15 += v * b6;\n t16 += v * b7;\n t17 += v * b8;\n t18 += v * b9;\n t19 += v * b10;\n t20 += v * b11;\n t21 += v * b12;\n t22 += v * b13;\n t23 += v * b14;\n t24 += v * b15;\n v = a[10];\n t10 += v * b0;\n t11 += v * b1;\n t12 += v * b2;\n t13 += v * b3;\n t14 += v * b4;\n t15 += v * b5;\n t16 += v * b6;\n t17 += v * b7;\n t18 += v * b8;\n t19 += v * b9;\n t20 += v * b10;\n t21 += v * b11;\n t22 += v * b12;\n t23 += v * b13;\n t24 += v * b14;\n t25 += v * b15;\n v = a[11];\n t11 += v * b0;\n t12 += v * b1;\n t13 += v * b2;\n t14 += v * b3;\n t15 += v * b4;\n t16 += v * b5;\n t17 += v * b6;\n t18 += v * b7;\n t19 += v * b8;\n t20 += v * b9;\n t21 += v * b10;\n t22 += v * b11;\n t23 += v * b12;\n t24 += v * b13;\n t25 += v * b14;\n t26 += v * b15;\n v = a[12];\n t12 += v * b0;\n t13 += v * b1;\n t14 += v * b2;\n t15 += v * b3;\n t16 += v * b4;\n t17 += v * b5;\n t18 += v * b6;\n t19 += v * b7;\n t20 += v * b8;\n t21 += v * b9;\n t22 += v * b10;\n t23 += v * b11;\n t24 += v * b12;\n t25 += v * b13;\n t26 += v * b14;\n t27 += v * b15;\n v = a[13];\n t13 += v * b0;\n t14 += v * b1;\n t15 += v * b2;\n t16 += v * b3;\n t17 += v * b4;\n t18 += v * b5;\n t19 += v * b6;\n t20 += v * b7;\n t21 += v * b8;\n t22 += v * b9;\n t23 += v * b10;\n t24 += v * b11;\n t25 += v * b12;\n t26 += v * b13;\n t27 += v * b14;\n t28 += v * b15;\n v = a[14];\n t14 += v * b0;\n t15 += v * b1;\n t16 += v * b2;\n t17 += v * b3;\n t18 += v * b4;\n t19 += v * b5;\n t20 += v * b6;\n t21 += v * b7;\n t22 += v * b8;\n t23 += v * b9;\n t24 += v * b10;\n t25 += v * b11;\n t26 += v * b12;\n t27 += v * b13;\n t28 += v * b14;\n t29 += v * b15;\n v = a[15];\n t15 += v * b0;\n t16 += v * b1;\n t17 += v * b2;\n t18 += v * b3;\n t19 += v * b4;\n t20 += v * b5;\n t21 += v * b6;\n t22 += v * b7;\n t23 += v * b8;\n t24 += v * b9;\n t25 += v * b10;\n t26 += v * b11;\n t27 += v * b12;\n t28 += v * b13;\n t29 += v * b14;\n t30 += v * b15;\n\n t0 += 38 * t16;\n t1 += 38 * t17;\n t2 += 38 * t18;\n t3 += 38 * t19;\n t4 += 38 * t20;\n t5 += 38 * t21;\n t6 += 38 * t22;\n t7 += 38 * t23;\n t8 += 38 * t24;\n t9 += 38 * t25;\n t10 += 38 * t26;\n t11 += 38 * t27;\n t12 += 38 * t28;\n t13 += 38 * t29;\n t14 += 38 * t30;\n // t15 left as is\n\n // first car\n c = 1;\n v = t0 + c + 65535; c = Math.floor(v / 65536); t0 = v - c * 65536;\n v = t1 + c + 65535; c = Math.floor(v / 65536); t1 = v - c * 65536;\n v = t2 + c + 65535; c = Math.floor(v / 65536); t2 = v - c * 65536;\n v = t3 + c + 65535; c = Math.floor(v / 65536); t3 = v - c * 65536;\n v = t4 + c + 65535; c = Math.floor(v / 65536); t4 = v - c * 65536;\n v = t5 + c + 65535; c = Math.floor(v / 65536); t5 = v - c * 65536;\n v = t6 + c + 65535; c = Math.floor(v / 65536); t6 = v - c * 65536;\n v = t7 + c + 65535; c = Math.floor(v / 65536); t7 = v - c * 65536;\n v = t8 + c + 65535; c = Math.floor(v / 65536); t8 = v - c * 65536;\n v = t9 + c + 65535; c = Math.floor(v / 65536); t9 = v - c * 65536;\n v = t10 + c + 65535; c = Math.floor(v / 65536); t10 = v - c * 65536;\n v = t11 + c + 65535; c = Math.floor(v / 65536); t11 = v - c * 65536;\n v = t12 + c + 65535; c = Math.floor(v / 65536); t12 = v - c * 65536;\n v = t13 + c + 65535; c = Math.floor(v / 65536); t13 = v - c * 65536;\n v = t14 + c + 65535; c = Math.floor(v / 65536); t14 = v - c * 65536;\n v = t15 + c + 65535; c = Math.floor(v / 65536); t15 = v - c * 65536;\n t0 += c-1 + 37 * (c-1);\n\n // second car\n c = 1;\n v = t0 + c + 65535; c = Math.floor(v / 65536); t0 = v - c * 65536;\n v = t1 + c + 65535; c = Math.floor(v / 65536); t1 = v - c * 65536;\n v = t2 + c + 65535; c = Math.floor(v / 65536); t2 = v - c * 65536;\n v = t3 + c + 65535; c = Math.floor(v / 65536); t3 = v - c * 65536;\n v = t4 + c + 65535; c = Math.floor(v / 65536); t4 = v - c * 65536;\n v = t5 + c + 65535; c = Math.floor(v / 65536); t5 = v - c * 65536;\n v = t6 + c + 65535; c = Math.floor(v / 65536); t6 = v - c * 65536;\n v = t7 + c + 65535; c = Math.floor(v / 65536); t7 = v - c * 65536;\n v = t8 + c + 65535; c = Math.floor(v / 65536); t8 = v - c * 65536;\n v = t9 + c + 65535; c = Math.floor(v / 65536); t9 = v - c * 65536;\n v = t10 + c + 65535; c = Math.floor(v / 65536); t10 = v - c * 65536;\n v = t11 + c + 65535; c = Math.floor(v / 65536); t11 = v - c * 65536;\n v = t12 + c + 65535; c = Math.floor(v / 65536); t12 = v - c * 65536;\n v = t13 + c + 65535; c = Math.floor(v / 65536); t13 = v - c * 65536;\n v = t14 + c + 65535; c = Math.floor(v / 65536); t14 = v - c * 65536;\n v = t15 + c + 65535; c = Math.floor(v / 65536); t15 = v - c * 65536;\n t0 += c-1 + 37 * (c-1);\n\n o[ 0] = t0;\n o[ 1] = t1;\n o[ 2] = t2;\n o[ 3] = t3;\n o[ 4] = t4;\n o[ 5] = t5;\n o[ 6] = t6;\n o[ 7] = t7;\n o[ 8] = t8;\n o[ 9] = t9;\n o[10] = t10;\n o[11] = t11;\n o[12] = t12;\n o[13] = t13;\n o[14] = t14;\n o[15] = t15;\n}\n\nfunction S(o, a) {\n M(o, a, a);\n}\n\nfunction inv25519(o, i) {\n var c = gf();\n var a;\n for (a = 0; a < 16; a++) c[a] = i[a];\n for (a = 253; a >= 0; a--) {\n S(c, c);\n if(a !== 2 && a !== 4) M(c, c, i);\n }\n for (a = 0; a < 16; a++) o[a] = c[a];\n}\n\nfunction pow2523(o, i) {\n var c = gf();\n var a;\n for (a = 0; a < 16; a++) c[a] = i[a];\n for (a = 250; a >= 0; a--) {\n S(c, c);\n if(a !== 1) M(c, c, i);\n }\n for (a = 0; a < 16; a++) o[a] = c[a];\n}\n\nfunction crypto_scalarmult(q, n, p) {\n var z = new Uint8Array(32);\n var x = new Float64Array(80), r, i;\n var a = gf(), b = gf(), c = gf(),\n d = gf(), e = gf(), f = gf();\n for (i = 0; i < 31; i++) z[i] = n[i];\n z[31]=(n[31]&127)|64;\n z[0]&=248;\n unpack25519(x,p);\n for (i = 0; i < 16; i++) {\n b[i]=x[i];\n d[i]=a[i]=c[i]=0;\n }\n a[0]=d[0]=1;\n for (i=254; i>=0; --i) {\n r=(z[i>>>3]>>>(i&7))&1;\n sel25519(a,b,r);\n sel25519(c,d,r);\n A(e,a,c);\n Z(a,a,c);\n A(c,b,d);\n Z(b,b,d);\n S(d,e);\n S(f,a);\n M(a,c,a);\n M(c,b,e);\n A(e,a,c);\n Z(a,a,c);\n S(b,a);\n Z(c,d,f);\n M(a,c,_121665);\n A(a,a,d);\n M(c,c,a);\n M(a,d,f);\n M(d,b,x);\n S(b,e);\n sel25519(a,b,r);\n sel25519(c,d,r);\n }\n for (i = 0; i < 16; i++) {\n x[i+16]=a[i];\n x[i+32]=c[i];\n x[i+48]=b[i];\n x[i+64]=d[i];\n }\n var x32 = x.subarray(32);\n var x16 = x.subarray(16);\n inv25519(x32,x32);\n M(x16,x16,x32);\n pack25519(q,x16);\n return 0;\n}\n\nfunction crypto_scalarmult_base(q, n) {\n return crypto_scalarmult(q, n, _9);\n}\n\nfunction crypto_box_keypair(y, x) {\n randombytes(x, 32);\n return crypto_scalarmult_base(y, x);\n}\n\nfunction crypto_box_beforenm(k, y, x) {\n var s = new Uint8Array(32);\n crypto_scalarmult(s, x, y);\n return crypto_core_hsalsa20(k, _0, s, sigma);\n}\n\nvar crypto_box_afternm = crypto_secretbox;\nvar crypto_box_open_afternm = crypto_secretbox_open;\n\nfunction crypto_box(c, m, d, n, y, x) {\n var k = new Uint8Array(32);\n crypto_box_beforenm(k, y, x);\n return crypto_box_afternm(c, m, d, n, k);\n}\n\nfunction crypto_box_open(m, c, d, n, y, x) {\n var k = new Uint8Array(32);\n crypto_box_beforenm(k, y, x);\n return crypto_box_open_afternm(m, c, d, n, k);\n}\n\nvar K = [\n 0x428a2f98, 0xd728ae22, 0x71374491, 0x23ef65cd,\n 0xb5c0fbcf, 0xec4d3b2f, 0xe9b5dba5, 0x8189dbbc,\n 0x3956c25b, 0xf348b538, 0x59f111f1, 0xb605d019,\n 0x923f82a4, 0xaf194f9b, 0xab1c5ed5, 0xda6d8118,\n 0xd807aa98, 0xa3030242, 0x12835b01, 0x45706fbe,\n 0x243185be, 0x4ee4b28c, 0x550c7dc3, 0xd5ffb4e2,\n 0x72be5d74, 0xf27b896f, 0x80deb1fe, 0x3b1696b1,\n 0x9bdc06a7, 0x25c71235, 0xc19bf174, 0xcf692694,\n 0xe49b69c1, 0x9ef14ad2, 0xefbe4786, 0x384f25e3,\n 0x0fc19dc6, 0x8b8cd5b5, 0x240ca1cc, 0x77ac9c65,\n 0x2de92c6f, 0x592b0275, 0x4a7484aa, 0x6ea6e483,\n 0x5cb0a9dc, 0xbd41fbd4, 0x76f988da, 0x831153b5,\n 0x983e5152, 0xee66dfab, 0xa831c66d, 0x2db43210,\n 0xb00327c8, 0x98fb213f, 0xbf597fc7, 0xbeef0ee4,\n 0xc6e00bf3, 0x3da88fc2, 0xd5a79147, 0x930aa725,\n 0x06ca6351, 0xe003826f, 0x14292967, 0x0a0e6e70,\n 0x27b70a85, 0x46d22ffc, 0x2e1b2138, 0x5c26c926,\n 0x4d2c6dfc, 0x5ac42aed, 0x53380d13, 0x9d95b3df,\n 0x650a7354, 0x8baf63de, 0x766a0abb, 0x3c77b2a8,\n 0x81c2c92e, 0x47edaee6, 0x92722c85, 0x1482353b,\n 0xa2bfe8a1, 0x4cf10364, 0xa81a664b, 0xbc423001,\n 0xc24b8b70, 0xd0f89791, 0xc76c51a3, 0x0654be30,\n 0xd192e819, 0xd6ef5218, 0xd6990624, 0x5565a910,\n 0xf40e3585, 0x5771202a, 0x106aa070, 0x32bbd1b8,\n 0x19a4c116, 0xb8d2d0c8, 0x1e376c08, 0x5141ab53,\n 0x2748774c, 0xdf8eeb99, 0x34b0bcb5, 0xe19b48a8,\n 0x391c0cb3, 0xc5c95a63, 0x4ed8aa4a, 0xe3418acb,\n 0x5b9cca4f, 0x7763e373, 0x682e6ff3, 0xd6b2b8a3,\n 0x748f82ee, 0x5defb2fc, 0x78a5636f, 0x43172f60,\n 0x84c87814, 0xa1f0ab72, 0x8cc70208, 0x1a6439ec,\n 0x90befffa, 0x23631e28, 0xa4506ceb, 0xde82bde9,\n 0xbef9a3f7, 0xb2c67915, 0xc67178f2, 0xe372532b,\n 0xca273ece, 0xea26619c, 0xd186b8c7, 0x21c0c207,\n 0xeada7dd6, 0xcde0eb1e, 0xf57d4f7f, 0xee6ed178,\n 0x06f067aa, 0x72176fba, 0x0a637dc5, 0xa2c898a6,\n 0x113f9804, 0xbef90dae, 0x1b710b35, 0x131c471b,\n 0x28db77f5, 0x23047d84, 0x32caab7b, 0x40c72493,\n 0x3c9ebe0a, 0x15c9bebc, 0x431d67c4, 0x9c100d4c,\n 0x4cc5d4be, 0xcb3e42b6, 0x597f299c, 0xfc657e2a,\n 0x5fcb6fab, 0x3ad6faec, 0x6c44198c, 0x4a475817\n];\n\nfunction crypto_hashblocks_hl(hh, hl, m, n) {\n var wh = new Int32Array(16), wl = new Int32Array(16),\n bh0, bh1, bh2, bh3, bh4, bh5, bh6, bh7,\n bl0, bl1, bl2, bl3, bl4, bl5, bl6, bl7,\n th, tl, i, j, h, l, a, b, c, d;\n\n var ah0 = hh[0],\n ah1 = hh[1],\n ah2 = hh[2],\n ah3 = hh[3],\n ah4 = hh[4],\n ah5 = hh[5],\n ah6 = hh[6],\n ah7 = hh[7],\n\n al0 = hl[0],\n al1 = hl[1],\n al2 = hl[2],\n al3 = hl[3],\n al4 = hl[4],\n al5 = hl[5],\n al6 = hl[6],\n al7 = hl[7];\n\n var pos = 0;\n while (n >= 128) {\n for (i = 0; i < 16; i++) {\n j = 8 * i + pos;\n wh[i] = (m[j+0] << 24) | (m[j+1] << 16) | (m[j+2] << 8) | m[j+3];\n wl[i] = (m[j+4] << 24) | (m[j+5] << 16) | (m[j+6] << 8) | m[j+7];\n }\n for (i = 0; i < 80; i++) {\n bh0 = ah0;\n bh1 = ah1;\n bh2 = ah2;\n bh3 = ah3;\n bh4 = ah4;\n bh5 = ah5;\n bh6 = ah6;\n bh7 = ah7;\n\n bl0 = al0;\n bl1 = al1;\n bl2 = al2;\n bl3 = al3;\n bl4 = al4;\n bl5 = al5;\n bl6 = al6;\n bl7 = al7;\n\n // add\n h = ah7;\n l = al7;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n // Sigma1\n h = ((ah4 >>> 14) | (al4 << (32-14))) ^ ((ah4 >>> 18) | (al4 << (32-18))) ^ ((al4 >>> (41-32)) | (ah4 << (32-(41-32))));\n l = ((al4 >>> 14) | (ah4 << (32-14))) ^ ((al4 >>> 18) | (ah4 << (32-18))) ^ ((ah4 >>> (41-32)) | (al4 << (32-(41-32))));\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // Ch\n h = (ah4 & ah5) ^ (~ah4 & ah6);\n l = (al4 & al5) ^ (~al4 & al6);\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // K\n h = K[i*2];\n l = K[i*2+1];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // w\n h = wh[i%16];\n l = wl[i%16];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n th = c & 0xffff | d << 16;\n tl = a & 0xffff | b << 16;\n\n // add\n h = th;\n l = tl;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n // Sigma0\n h = ((ah0 >>> 28) | (al0 << (32-28))) ^ ((al0 >>> (34-32)) | (ah0 << (32-(34-32)))) ^ ((al0 >>> (39-32)) | (ah0 << (32-(39-32))));\n l = ((al0 >>> 28) | (ah0 << (32-28))) ^ ((ah0 >>> (34-32)) | (al0 << (32-(34-32)))) ^ ((ah0 >>> (39-32)) | (al0 << (32-(39-32))));\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // Maj\n h = (ah0 & ah1) ^ (ah0 & ah2) ^ (ah1 & ah2);\n l = (al0 & al1) ^ (al0 & al2) ^ (al1 & al2);\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n bh7 = (c & 0xffff) | (d << 16);\n bl7 = (a & 0xffff) | (b << 16);\n\n // add\n h = bh3;\n l = bl3;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = th;\n l = tl;\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n bh3 = (c & 0xffff) | (d << 16);\n bl3 = (a & 0xffff) | (b << 16);\n\n ah1 = bh0;\n ah2 = bh1;\n ah3 = bh2;\n ah4 = bh3;\n ah5 = bh4;\n ah6 = bh5;\n ah7 = bh6;\n ah0 = bh7;\n\n al1 = bl0;\n al2 = bl1;\n al3 = bl2;\n al4 = bl3;\n al5 = bl4;\n al6 = bl5;\n al7 = bl6;\n al0 = bl7;\n\n if (i%16 === 15) {\n for (j = 0; j < 16; j++) {\n // add\n h = wh[j];\n l = wl[j];\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = wh[(j+9)%16];\n l = wl[(j+9)%16];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // sigma0\n th = wh[(j+1)%16];\n tl = wl[(j+1)%16];\n h = ((th >>> 1) | (tl << (32-1))) ^ ((th >>> 8) | (tl << (32-8))) ^ (th >>> 7);\n l = ((tl >>> 1) | (th << (32-1))) ^ ((tl >>> 8) | (th << (32-8))) ^ ((tl >>> 7) | (th << (32-7)));\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // sigma1\n th = wh[(j+14)%16];\n tl = wl[(j+14)%16];\n h = ((th >>> 19) | (tl << (32-19))) ^ ((tl >>> (61-32)) | (th << (32-(61-32)))) ^ (th >>> 6);\n l = ((tl >>> 19) | (th << (32-19))) ^ ((th >>> (61-32)) | (tl << (32-(61-32)))) ^ ((tl >>> 6) | (th << (32-6)));\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n wh[j] = (c & 0xffff) | (d << 16);\n wl[j] = (a & 0xffff) | (b << 16);\n }\n }\n }\n\n // add\n h = ah0;\n l = al0;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[0];\n l = hl[0];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[0] = ah0 = (c & 0xffff) | (d << 16);\n hl[0] = al0 = (a & 0xffff) | (b << 16);\n\n h = ah1;\n l = al1;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[1];\n l = hl[1];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[1] = ah1 = (c & 0xffff) | (d << 16);\n hl[1] = al1 = (a & 0xffff) | (b << 16);\n\n h = ah2;\n l = al2;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[2];\n l = hl[2];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[2] = ah2 = (c & 0xffff) | (d << 16);\n hl[2] = al2 = (a & 0xffff) | (b << 16);\n\n h = ah3;\n l = al3;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[3];\n l = hl[3];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[3] = ah3 = (c & 0xffff) | (d << 16);\n hl[3] = al3 = (a & 0xffff) | (b << 16);\n\n h = ah4;\n l = al4;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[4];\n l = hl[4];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[4] = ah4 = (c & 0xffff) | (d << 16);\n hl[4] = al4 = (a & 0xffff) | (b << 16);\n\n h = ah5;\n l = al5;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[5];\n l = hl[5];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[5] = ah5 = (c & 0xffff) | (d << 16);\n hl[5] = al5 = (a & 0xffff) | (b << 16);\n\n h = ah6;\n l = al6;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[6];\n l = hl[6];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[6] = ah6 = (c & 0xffff) | (d << 16);\n hl[6] = al6 = (a & 0xffff) | (b << 16);\n\n h = ah7;\n l = al7;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[7];\n l = hl[7];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[7] = ah7 = (c & 0xffff) | (d << 16);\n hl[7] = al7 = (a & 0xffff) | (b << 16);\n\n pos += 128;\n n -= 128;\n }\n\n return n;\n}\n\nfunction crypto_hash(out, m, n) {\n var hh = new Int32Array(8),\n hl = new Int32Array(8),\n x = new Uint8Array(256),\n i, b = n;\n\n hh[0] = 0x6a09e667;\n hh[1] = 0xbb67ae85;\n hh[2] = 0x3c6ef372;\n hh[3] = 0xa54ff53a;\n hh[4] = 0x510e527f;\n hh[5] = 0x9b05688c;\n hh[6] = 0x1f83d9ab;\n hh[7] = 0x5be0cd19;\n\n hl[0] = 0xf3bcc908;\n hl[1] = 0x84caa73b;\n hl[2] = 0xfe94f82b;\n hl[3] = 0x5f1d36f1;\n hl[4] = 0xade682d1;\n hl[5] = 0x2b3e6c1f;\n hl[6] = 0xfb41bd6b;\n hl[7] = 0x137e2179;\n\n crypto_hashblocks_hl(hh, hl, m, n);\n n %= 128;\n\n for (i = 0; i < n; i++) x[i] = m[b-n+i];\n x[n] = 128;\n\n n = 256-128*(n<112?1:0);\n x[n-9] = 0;\n ts64(x, n-8, (b / 0x20000000) | 0, b << 3);\n crypto_hashblocks_hl(hh, hl, x, n);\n\n for (i = 0; i < 8; i++) ts64(out, 8*i, hh[i], hl[i]);\n\n return 0;\n}\n\nfunction add(p, q) {\n var a = gf(), b = gf(), c = gf(),\n d = gf(), e = gf(), f = gf(),\n g = gf(), h = gf(), t = gf();\n\n Z(a, p[1], p[0]);\n Z(t, q[1], q[0]);\n M(a, a, t);\n A(b, p[0], p[1]);\n A(t, q[0], q[1]);\n M(b, b, t);\n M(c, p[3], q[3]);\n M(c, c, D2);\n M(d, p[2], q[2]);\n A(d, d, d);\n Z(e, b, a);\n Z(f, d, c);\n A(g, d, c);\n A(h, b, a);\n\n M(p[0], e, f);\n M(p[1], h, g);\n M(p[2], g, f);\n M(p[3], e, h);\n}\n\nfunction cswap(p, q, b) {\n var i;\n for (i = 0; i < 4; i++) {\n sel25519(p[i], q[i], b);\n }\n}\n\nfunction pack(r, p) {\n var tx = gf(), ty = gf(), zi = gf();\n inv25519(zi, p[2]);\n M(tx, p[0], zi);\n M(ty, p[1], zi);\n pack25519(r, ty);\n r[31] ^= par25519(tx) << 7;\n}\n\nfunction scalarmult(p, q, s) {\n var b, i;\n set25519(p[0], gf0);\n set25519(p[1], gf1);\n set25519(p[2], gf1);\n set25519(p[3], gf0);\n for (i = 255; i >= 0; --i) {\n b = (s[(i/8)|0] >> (i&7)) & 1;\n cswap(p, q, b);\n add(q, p);\n add(p, p);\n cswap(p, q, b);\n }\n}\n\nfunction scalarbase(p, s) {\n var q = [gf(), gf(), gf(), gf()];\n set25519(q[0], X);\n set25519(q[1], Y);\n set25519(q[2], gf1);\n M(q[3], X, Y);\n scalarmult(p, q, s);\n}\n\nfunction crypto_sign_keypair(pk, sk, seeded) {\n var d = new Uint8Array(64);\n var p = [gf(), gf(), gf(), gf()];\n var i;\n\n if (!seeded) randombytes(sk, 32);\n crypto_hash(d, sk, 32);\n d[0] &= 248;\n d[31] &= 127;\n d[31] |= 64;\n\n scalarbase(p, d);\n pack(pk, p);\n\n for (i = 0; i < 32; i++) sk[i+32] = pk[i];\n return 0;\n}\n\nvar L = new Float64Array([0xed, 0xd3, 0xf5, 0x5c, 0x1a, 0x63, 0x12, 0x58, 0xd6, 0x9c, 0xf7, 0xa2, 0xde, 0xf9, 0xde, 0x14, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x10]);\n\nfunction modL(r, x) {\n var carry, i, j, k;\n for (i = 63; i >= 32; --i) {\n carry = 0;\n for (j = i - 32, k = i - 12; j < k; ++j) {\n x[j] += carry - 16 * x[i] * L[j - (i - 32)];\n carry = Math.floor((x[j] + 128) / 256);\n x[j] -= carry * 256;\n }\n x[j] += carry;\n x[i] = 0;\n }\n carry = 0;\n for (j = 0; j < 32; j++) {\n x[j] += carry - (x[31] >> 4) * L[j];\n carry = x[j] >> 8;\n x[j] &= 255;\n }\n for (j = 0; j < 32; j++) x[j] -= carry * L[j];\n for (i = 0; i < 32; i++) {\n x[i+1] += x[i] >> 8;\n r[i] = x[i] & 255;\n }\n}\n\nfunction reduce(r) {\n var x = new Float64Array(64), i;\n for (i = 0; i < 64; i++) x[i] = r[i];\n for (i = 0; i < 64; i++) r[i] = 0;\n modL(r, x);\n}\n\n// Note: difference from C - smlen returned, not passed as argument.\nfunction crypto_sign(sm, m, n, sk) {\n var d = new Uint8Array(64), h = new Uint8Array(64), r = new Uint8Array(64);\n var i, j, x = new Float64Array(64);\n var p = [gf(), gf(), gf(), gf()];\n\n crypto_hash(d, sk, 32);\n d[0] &= 248;\n d[31] &= 127;\n d[31] |= 64;\n\n var smlen = n + 64;\n for (i = 0; i < n; i++) sm[64 + i] = m[i];\n for (i = 0; i < 32; i++) sm[32 + i] = d[32 + i];\n\n crypto_hash(r, sm.subarray(32), n+32);\n reduce(r);\n scalarbase(p, r);\n pack(sm, p);\n\n for (i = 32; i < 64; i++) sm[i] = sk[i];\n crypto_hash(h, sm, n + 64);\n reduce(h);\n\n for (i = 0; i < 64; i++) x[i] = 0;\n for (i = 0; i < 32; i++) x[i] = r[i];\n for (i = 0; i < 32; i++) {\n for (j = 0; j < 32; j++) {\n x[i+j] += h[i] * d[j];\n }\n }\n\n modL(sm.subarray(32), x);\n return smlen;\n}\n\nfunction unpackneg(r, p) {\n var t = gf(), chk = gf(), num = gf(),\n den = gf(), den2 = gf(), den4 = gf(),\n den6 = gf();\n\n set25519(r[2], gf1);\n unpack25519(r[1], p);\n S(num, r[1]);\n M(den, num, D);\n Z(num, num, r[2]);\n A(den, r[2], den);\n\n S(den2, den);\n S(den4, den2);\n M(den6, den4, den2);\n M(t, den6, num);\n M(t, t, den);\n\n pow2523(t, t);\n M(t, t, num);\n M(t, t, den);\n M(t, t, den);\n M(r[0], t, den);\n\n S(chk, r[0]);\n M(chk, chk, den);\n if (neq25519(chk, num)) M(r[0], r[0], I);\n\n S(chk, r[0]);\n M(chk, chk, den);\n if (neq25519(chk, num)) return -1;\n\n if (par25519(r[0]) === (p[31]>>7)) Z(r[0], gf0, r[0]);\n\n M(r[3], r[0], r[1]);\n return 0;\n}\n\nfunction crypto_sign_open(m, sm, n, pk) {\n var i;\n var t = new Uint8Array(32), h = new Uint8Array(64);\n var p = [gf(), gf(), gf(), gf()],\n q = [gf(), gf(), gf(), gf()];\n\n if (n < 64) return -1;\n\n if (unpackneg(q, pk)) return -1;\n\n for (i = 0; i < n; i++) m[i] = sm[i];\n for (i = 0; i < 32; i++) m[i+32] = pk[i];\n crypto_hash(h, m, n);\n reduce(h);\n scalarmult(p, q, h);\n\n scalarbase(q, sm.subarray(32));\n add(p, q);\n pack(t, p);\n\n n -= 64;\n if (crypto_verify_32(sm, 0, t, 0)) {\n for (i = 0; i < n; i++) m[i] = 0;\n return -1;\n }\n\n for (i = 0; i < n; i++) m[i] = sm[i + 64];\n return n;\n}\n\nvar crypto_secretbox_KEYBYTES = 32,\n crypto_secretbox_NONCEBYTES = 24,\n crypto_secretbox_ZEROBYTES = 32,\n crypto_secretbox_BOXZEROBYTES = 16,\n crypto_scalarmult_BYTES = 32,\n crypto_scalarmult_SCALARBYTES = 32,\n crypto_box_PUBLICKEYBYTES = 32,\n crypto_box_SECRETKEYBYTES = 32,\n crypto_box_BEFORENMBYTES = 32,\n crypto_box_NONCEBYTES = crypto_secretbox_NONCEBYTES,\n crypto_box_ZEROBYTES = crypto_secretbox_ZEROBYTES,\n crypto_box_BOXZEROBYTES = crypto_secretbox_BOXZEROBYTES,\n crypto_sign_BYTES = 64,\n crypto_sign_PUBLICKEYBYTES = 32,\n crypto_sign_SECRETKEYBYTES = 64,\n crypto_sign_SEEDBYTES = 32,\n crypto_hash_BYTES = 64;\n\nnacl.lowlevel = {\n crypto_core_hsalsa20: crypto_core_hsalsa20,\n crypto_stream_xor: crypto_stream_xor,\n crypto_stream: crypto_stream,\n crypto_stream_salsa20_xor: crypto_stream_salsa20_xor,\n crypto_stream_salsa20: crypto_stream_salsa20,\n crypto_onetimeauth: crypto_onetimeauth,\n crypto_onetimeauth_verify: crypto_onetimeauth_verify,\n crypto_verify_16: crypto_verify_16,\n crypto_verify_32: crypto_verify_32,\n crypto_secretbox: crypto_secretbox,\n crypto_secretbox_open: crypto_secretbox_open,\n crypto_scalarmult: crypto_scalarmult,\n crypto_scalarmult_base: crypto_scalarmult_base,\n crypto_box_beforenm: crypto_box_beforenm,\n crypto_box_afternm: crypto_box_afternm,\n crypto_box: crypto_box,\n crypto_box_open: crypto_box_open,\n crypto_box_keypair: crypto_box_keypair,\n crypto_hash: crypto_hash,\n crypto_sign: crypto_sign,\n crypto_sign_keypair: crypto_sign_keypair,\n crypto_sign_open: crypto_sign_open,\n\n crypto_secretbox_KEYBYTES: crypto_secretbox_KEYBYTES,\n crypto_secretbox_NONCEBYTES: crypto_secretbox_NONCEBYTES,\n crypto_secretbox_ZEROBYTES: crypto_secretbox_ZEROBYTES,\n crypto_secretbox_BOXZEROBYTES: crypto_secretbox_BOXZEROBYTES,\n crypto_scalarmult_BYTES: crypto_scalarmult_BYTES,\n crypto_scalarmult_SCALARBYTES: crypto_scalarmult_SCALARBYTES,\n crypto_box_PUBLICKEYBYTES: crypto_box_PUBLICKEYBYTES,\n crypto_box_SECRETKEYBYTES: crypto_box_SECRETKEYBYTES,\n crypto_box_BEFORENMBYTES: crypto_box_BEFORENMBYTES,\n crypto_box_NONCEBYTES: crypto_box_NONCEBYTES,\n crypto_box_ZEROBYTES: crypto_box_ZEROBYTES,\n crypto_box_BOXZEROBYTES: crypto_box_BOXZEROBYTES,\n crypto_sign_BYTES: crypto_sign_BYTES,\n crypto_sign_PUBLICKEYBYTES: crypto_sign_PUBLICKEYBYTES,\n crypto_sign_SECRETKEYBYTES: crypto_sign_SECRETKEYBYTES,\n crypto_sign_SEEDBYTES: crypto_sign_SEEDBYTES,\n crypto_hash_BYTES: crypto_hash_BYTES,\n\n gf: gf,\n D: D,\n L: L,\n pack25519: pack25519,\n unpack25519: unpack25519,\n M: M,\n A: A,\n S: S,\n Z: Z,\n pow2523: pow2523,\n add: add,\n set25519: set25519,\n modL: modL,\n scalarmult: scalarmult,\n scalarbase: scalarbase,\n};\n\n/* High-level API */\n\nfunction checkLengths(k, n) {\n if (k.length !== crypto_secretbox_KEYBYTES) throw new Error('bad key size');\n if (n.length !== crypto_secretbox_NONCEBYTES) throw new Error('bad nonce size');\n}\n\nfunction checkBoxLengths(pk, sk) {\n if (pk.length !== crypto_box_PUBLICKEYBYTES) throw new Error('bad public key size');\n if (sk.length !== crypto_box_SECRETKEYBYTES) throw new Error('bad secret key size');\n}\n\nfunction checkArrayTypes() {\n for (var i = 0; i < arguments.length; i++) {\n if (!(arguments[i] instanceof Uint8Array))\n throw new TypeError('unexpected type, use Uint8Array');\n }\n}\n\nfunction cleanup(arr) {\n for (var i = 0; i < arr.length; i++) arr[i] = 0;\n}\n\nnacl.randomBytes = function(n) {\n var b = new Uint8Array(n);\n randombytes(b, n);\n return b;\n};\n\nnacl.secretbox = function(msg, nonce, key) {\n checkArrayTypes(msg, nonce, key);\n checkLengths(key, nonce);\n var m = new Uint8Array(crypto_secretbox_ZEROBYTES + msg.length);\n var c = new Uint8Array(m.length);\n for (var i = 0; i < msg.length; i++) m[i+crypto_secretbox_ZEROBYTES] = msg[i];\n crypto_secretbox(c, m, m.length, nonce, key);\n return c.subarray(crypto_secretbox_BOXZEROBYTES);\n};\n\nnacl.secretbox.open = function(box, nonce, key) {\n checkArrayTypes(box, nonce, key);\n checkLengths(key, nonce);\n var c = new Uint8Array(crypto_secretbox_BOXZEROBYTES + box.length);\n var m = new Uint8Array(c.length);\n for (var i = 0; i < box.length; i++) c[i+crypto_secretbox_BOXZEROBYTES] = box[i];\n if (c.length < 32) return null;\n if (crypto_secretbox_open(m, c, c.length, nonce, key) !== 0) return null;\n return m.subarray(crypto_secretbox_ZEROBYTES);\n};\n\nnacl.secretbox.keyLength = crypto_secretbox_KEYBYTES;\nnacl.secretbox.nonceLength = crypto_secretbox_NONCEBYTES;\nnacl.secretbox.overheadLength = crypto_secretbox_BOXZEROBYTES;\n\nnacl.scalarMult = function(n, p) {\n checkArrayTypes(n, p);\n if (n.length !== crypto_scalarmult_SCALARBYTES) throw new Error('bad n size');\n if (p.length !== crypto_scalarmult_BYTES) throw new Error('bad p size');\n var q = new Uint8Array(crypto_scalarmult_BYTES);\n crypto_scalarmult(q, n, p);\n return q;\n};\n\nnacl.scalarMult.base = function(n) {\n checkArrayTypes(n);\n if (n.length !== crypto_scalarmult_SCALARBYTES) throw new Error('bad n size');\n var q = new Uint8Array(crypto_scalarmult_BYTES);\n crypto_scalarmult_base(q, n);\n return q;\n};\n\nnacl.scalarMult.scalarLength = crypto_scalarmult_SCALARBYTES;\nnacl.scalarMult.groupElementLength = crypto_scalarmult_BYTES;\n\nnacl.box = function(msg, nonce, publicKey, secretKey) {\n var k = nacl.box.before(publicKey, secretKey);\n return nacl.secretbox(msg, nonce, k);\n};\n\nnacl.box.before = function(publicKey, secretKey) {\n checkArrayTypes(publicKey, secretKey);\n checkBoxLengths(publicKey, secretKey);\n var k = new Uint8Array(crypto_box_BEFORENMBYTES);\n crypto_box_beforenm(k, publicKey, secretKey);\n return k;\n};\n\nnacl.box.after = nacl.secretbox;\n\nnacl.box.open = function(msg, nonce, publicKey, secretKey) {\n var k = nacl.box.before(publicKey, secretKey);\n return nacl.secretbox.open(msg, nonce, k);\n};\n\nnacl.box.open.after = nacl.secretbox.open;\n\nnacl.box.keyPair = function() {\n var pk = new Uint8Array(crypto_box_PUBLICKEYBYTES);\n var sk = new Uint8Array(crypto_box_SECRETKEYBYTES);\n crypto_box_keypair(pk, sk);\n return {publicKey: pk, secretKey: sk};\n};\n\nnacl.box.keyPair.fromSecretKey = function(secretKey) {\n checkArrayTypes(secretKey);\n if (secretKey.length !== crypto_box_SECRETKEYBYTES)\n throw new Error('bad secret key size');\n var pk = new Uint8Array(crypto_box_PUBLICKEYBYTES);\n crypto_scalarmult_base(pk, secretKey);\n return {publicKey: pk, secretKey: new Uint8Array(secretKey)};\n};\n\nnacl.box.publicKeyLength = crypto_box_PUBLICKEYBYTES;\nnacl.box.secretKeyLength = crypto_box_SECRETKEYBYTES;\nnacl.box.sharedKeyLength = crypto_box_BEFORENMBYTES;\nnacl.box.nonceLength = crypto_box_NONCEBYTES;\nnacl.box.overheadLength = nacl.secretbox.overheadLength;\n\nnacl.sign = function(msg, secretKey) {\n checkArrayTypes(msg, secretKey);\n if (secretKey.length !== crypto_sign_SECRETKEYBYTES)\n throw new Error('bad secret key size');\n var signedMsg = new Uint8Array(crypto_sign_BYTES+msg.length);\n crypto_sign(signedMsg, msg, msg.length, secretKey);\n return signedMsg;\n};\n\nnacl.sign.open = function(signedMsg, publicKey) {\n checkArrayTypes(signedMsg, publicKey);\n if (publicKey.length !== crypto_sign_PUBLICKEYBYTES)\n throw new Error('bad public key size');\n var tmp = new Uint8Array(signedMsg.length);\n var mlen = crypto_sign_open(tmp, signedMsg, signedMsg.length, publicKey);\n if (mlen < 0) return null;\n var m = new Uint8Array(mlen);\n for (var i = 0; i < m.length; i++) m[i] = tmp[i];\n return m;\n};\n\nnacl.sign.detached = function(msg, secretKey) {\n var signedMsg = nacl.sign(msg, secretKey);\n var sig = new Uint8Array(crypto_sign_BYTES);\n for (var i = 0; i < sig.length; i++) sig[i] = signedMsg[i];\n return sig;\n};\n\nnacl.sign.detached.verify = function(msg, sig, publicKey) {\n checkArrayTypes(msg, sig, publicKey);\n if (sig.length !== crypto_sign_BYTES)\n throw new Error('bad signature size');\n if (publicKey.length !== crypto_sign_PUBLICKEYBYTES)\n throw new Error('bad public key size');\n var sm = new Uint8Array(crypto_sign_BYTES + msg.length);\n var m = new Uint8Array(crypto_sign_BYTES + msg.length);\n var i;\n for (i = 0; i < crypto_sign_BYTES; i++) sm[i] = sig[i];\n for (i = 0; i < msg.length; i++) sm[i+crypto_sign_BYTES] = msg[i];\n return (crypto_sign_open(m, sm, sm.length, publicKey) >= 0);\n};\n\nnacl.sign.keyPair = function() {\n var pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);\n var sk = new Uint8Array(crypto_sign_SECRETKEYBYTES);\n crypto_sign_keypair(pk, sk);\n return {publicKey: pk, secretKey: sk};\n};\n\nnacl.sign.keyPair.fromSecretKey = function(secretKey) {\n checkArrayTypes(secretKey);\n if (secretKey.length !== crypto_sign_SECRETKEYBYTES)\n throw new Error('bad secret key size');\n var pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);\n for (var i = 0; i < pk.length; i++) pk[i] = secretKey[32+i];\n return {publicKey: pk, secretKey: new Uint8Array(secretKey)};\n};\n\nnacl.sign.keyPair.fromSeed = function(seed) {\n checkArrayTypes(seed);\n if (seed.length !== crypto_sign_SEEDBYTES)\n throw new Error('bad seed size');\n var pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);\n var sk = new Uint8Array(crypto_sign_SECRETKEYBYTES);\n for (var i = 0; i < 32; i++) sk[i] = seed[i];\n crypto_sign_keypair(pk, sk, true);\n return {publicKey: pk, secretKey: sk};\n};\n\nnacl.sign.publicKeyLength = crypto_sign_PUBLICKEYBYTES;\nnacl.sign.secretKeyLength = crypto_sign_SECRETKEYBYTES;\nnacl.sign.seedLength = crypto_sign_SEEDBYTES;\nnacl.sign.signatureLength = crypto_sign_BYTES;\n\nnacl.hash = function(msg) {\n checkArrayTypes(msg);\n var h = new Uint8Array(crypto_hash_BYTES);\n crypto_hash(h, msg, msg.length);\n return h;\n};\n\nnacl.hash.hashLength = crypto_hash_BYTES;\n\nnacl.verify = function(x, y) {\n checkArrayTypes(x, y);\n // Zero length arguments are considered not equal.\n if (x.length === 0 || y.length === 0) return false;\n if (x.length !== y.length) return false;\n return (vn(x, 0, y, 0, x.length) === 0) ? true : false;\n};\n\nnacl.setPRNG = function(fn) {\n randombytes = fn;\n};\n\n(function() {\n // Initialize PRNG if environment provides CSPRNG.\n // If not, methods calling randombytes will throw.\n var crypto = typeof self !== 'undefined' ? (self.crypto || self.msCrypto) : null;\n if (crypto && crypto.getRandomValues) {\n // Browsers.\n var QUOTA = 65536;\n nacl.setPRNG(function(x, n) {\n var i, v = new Uint8Array(n);\n for (i = 0; i < n; i += QUOTA) {\n crypto.getRandomValues(v.subarray(i, i + Math.min(n - i, QUOTA)));\n }\n for (i = 0; i < n; i++) x[i] = v[i];\n cleanup(v);\n });\n } else if (typeof require !== 'undefined') {\n // Node.js.\n crypto = require('crypto');\n if (crypto && crypto.randomBytes) {\n nacl.setPRNG(function(x, n) {\n var i, v = crypto.randomBytes(n);\n for (i = 0; i < n; i++) x[i] = v[i];\n cleanup(v);\n });\n }\n }\n})();\n\n})(typeof module !== 'undefined' && module.exports ? module.exports : (self.nacl = self.nacl || {}));\n","module.exports = require('./pusher-with-encryption').default;\n","import ScriptReceiver from './script_receiver';\n\n/** Builds receivers for JSONP and Script requests.\n *\n * Each receiver is an object with following fields:\n * - number - unique (for the factory instance), numerical id of the receiver\n * - id - a string ID that can be used in DOM attributes\n * - name - name of the function triggering the receiver\n * - callback - callback function\n *\n * Receivers are triggered only once, on the first callback call.\n *\n * Receivers can be called by their name or by accessing factory object\n * by the number key.\n *\n * @param {String} prefix the prefix used in ids\n * @param {String} name the name of the object\n */\nexport class ScriptReceiverFactory {\n lastId: number;\n prefix: string;\n name: string;\n\n constructor(prefix: string, name: string) {\n this.lastId = 0;\n this.prefix = prefix;\n this.name = name;\n }\n\n create(callback: Function): ScriptReceiver {\n this.lastId++;\n\n var number = this.lastId;\n var id = this.prefix + number;\n var name = this.name + '[' + number + ']';\n\n var called = false;\n var callbackWrapper = function() {\n if (!called) {\n callback.apply(null, arguments);\n called = true;\n }\n };\n\n this[number] = callbackWrapper;\n return { number: number, id: id, name: name, callback: callbackWrapper };\n }\n\n remove(receiver: ScriptReceiver) {\n delete this[receiver.number];\n }\n}\n\nexport var ScriptReceivers = new ScriptReceiverFactory(\n '_pusher_script_',\n 'Pusher.ScriptReceivers'\n);\n","import {\n ChannelAuthorizationOptions,\n UserAuthenticationOptions\n} from './auth/options';\nimport { AuthTransport } from './config';\n\nexport interface DefaultConfig {\n VERSION: string;\n PROTOCOL: number;\n wsPort: number;\n wssPort: number;\n wsPath: string;\n httpHost: string;\n httpPort: number;\n httpsPort: number;\n httpPath: string;\n stats_host: string;\n authEndpoint: string;\n authTransport: AuthTransport;\n activityTimeout: number;\n pongTimeout: number;\n unavailableTimeout: number;\n userAuthentication: UserAuthenticationOptions;\n channelAuthorization: ChannelAuthorizationOptions;\n\n cdn_http?: string;\n cdn_https?: string;\n dependency_suffix?: string;\n}\n\nvar Defaults: DefaultConfig = {\n VERSION: VERSION,\n PROTOCOL: 7,\n\n wsPort: 80,\n wssPort: 443,\n wsPath: '',\n // DEPRECATED: SockJS fallback parameters\n httpHost: 'sockjs.pusher.com',\n httpPort: 80,\n httpsPort: 443,\n httpPath: '/pusher',\n // DEPRECATED: Stats\n stats_host: 'stats.pusher.com',\n // DEPRECATED: Other settings\n authEndpoint: '/pusher/auth',\n authTransport: 'ajax',\n activityTimeout: 120000,\n pongTimeout: 30000,\n unavailableTimeout: 10000,\n userAuthentication: {\n endpoint: '/pusher/user-auth',\n transport: 'ajax'\n },\n channelAuthorization: {\n endpoint: '/pusher/auth',\n transport: 'ajax'\n },\n\n // CDN configuration\n cdn_http: CDN_HTTP,\n cdn_https: CDN_HTTPS,\n dependency_suffix: DEPENDENCY_SUFFIX\n};\n\nexport default Defaults;\n","import { ScriptReceiverFactory } from './script_receiver_factory';\nimport Defaults from 'core/defaults';\nimport DependencyLoader from './dependency_loader';\n\nexport var DependenciesReceivers = new ScriptReceiverFactory(\n '_pusher_dependencies',\n 'Pusher.DependenciesReceivers'\n);\n\nexport var Dependencies = new DependencyLoader({\n cdn_http: Defaults.cdn_http,\n cdn_https: Defaults.cdn_https,\n version: Defaults.VERSION,\n suffix: Defaults.dependency_suffix,\n receivers: DependenciesReceivers\n});\n","import {\n ScriptReceivers,\n ScriptReceiverFactory\n} from './script_receiver_factory';\nimport Runtime from 'runtime';\nimport ScriptRequest from './script_request';\n\n/** Handles loading dependency files.\n *\n * Dependency loaders don't remember whether a resource has been loaded or\n * not. It is caller's responsibility to make sure the resource is not loaded\n * twice. This is because it's impossible to detect resource loading status\n * without knowing its content.\n *\n * Options:\n * - cdn_http - url to HTTP CND\n * - cdn_https - url to HTTPS CDN\n * - version - version of pusher-js\n * - suffix - suffix appended to all names of dependency files\n *\n * @param {Object} options\n */\nexport default class DependencyLoader {\n options: any;\n receivers: ScriptReceiverFactory;\n loading: any;\n\n constructor(options: any) {\n this.options = options;\n this.receivers = options.receivers || ScriptReceivers;\n this.loading = {};\n }\n\n /** Loads the dependency from CDN.\n *\n * @param {String} name\n * @param {Function} callback\n */\n load(name: string, options: any, callback: Function) {\n var self = this;\n\n if (self.loading[name] && self.loading[name].length > 0) {\n self.loading[name].push(callback);\n } else {\n self.loading[name] = [callback];\n\n var request = Runtime.createScriptRequest(self.getPath(name, options));\n var receiver = self.receivers.create(function(error) {\n self.receivers.remove(receiver);\n\n if (self.loading[name]) {\n var callbacks = self.loading[name];\n delete self.loading[name];\n\n var successCallback = function(wasSuccessful) {\n if (!wasSuccessful) {\n request.cleanup();\n }\n };\n for (var i = 0; i < callbacks.length; i++) {\n callbacks[i](error, successCallback);\n }\n }\n });\n request.send(receiver);\n }\n }\n\n /** Returns a root URL for pusher-js CDN.\n *\n * @returns {String}\n */\n getRoot(options: any): string {\n var cdn;\n var protocol = Runtime.getDocument().location.protocol;\n if ((options && options.useTLS) || protocol === 'https:') {\n cdn = this.options.cdn_https;\n } else {\n cdn = this.options.cdn_http;\n }\n // make sure there are no double slashes\n return cdn.replace(/\\/*$/, '') + '/' + this.options.version;\n }\n\n /** Returns a full path to a dependency file.\n *\n * @param {String} name\n * @returns {String}\n */\n getPath(name: string, options: any): string {\n return this.getRoot(options) + '/' + name + this.options.suffix + '.js';\n }\n}\n","/**\n * A place to store help URLs for error messages etc\n */\n\nconst urlStore = {\n baseUrl: 'https://pusher.com',\n urls: {\n authenticationEndpoint: {\n path: '/docs/channels/server_api/authenticating_users'\n },\n authorizationEndpoint: {\n path: '/docs/channels/server_api/authorizing-users/'\n },\n javascriptQuickStart: {\n path: '/docs/javascript_quick_start'\n },\n triggeringClientEvents: {\n path: '/docs/client_api_guide/client_events#trigger-events'\n },\n encryptedChannelSupport: {\n fullUrl:\n 'https://github.com/pusher/pusher-js/tree/cc491015371a4bde5743d1c87a0fbac0feb53195#encrypted-channel-support'\n }\n }\n};\n\n/** Builds a consistent string with links to pusher documentation\n *\n * @param {string} key - relevant key in the url_store.urls object\n * @return {string} suffix string to append to log message\n */\nconst buildLogSuffix = function(key: string): string {\n const urlPrefix = 'See:';\n const urlObj = urlStore.urls[key];\n if (!urlObj) return '';\n\n let url;\n if (urlObj.fullUrl) {\n url = urlObj.fullUrl;\n } else if (urlObj.path) {\n url = urlStore.baseUrl + urlObj.path;\n }\n\n if (!url) return '';\n return `${urlPrefix} ${url}`;\n};\n\nexport default { buildLogSuffix };\n","export enum AuthRequestType {\n UserAuthentication = 'user-authentication',\n ChannelAuthorization = 'channel-authorization'\n}\n\nexport interface ChannelAuthorizationData {\n auth: string;\n channel_data?: string;\n shared_secret?: string;\n}\n\nexport type ChannelAuthorizationCallback = (\n error: Error | null,\n authData: ChannelAuthorizationData | null\n) => void;\n\nexport interface ChannelAuthorizationRequestParams {\n socketId: string;\n channelName: string;\n}\n\nexport interface ChannelAuthorizationHandler {\n (\n params: ChannelAuthorizationRequestParams,\n callback: ChannelAuthorizationCallback\n ): void;\n}\n\nexport interface UserAuthenticationData {\n auth: string;\n user_data: string;\n}\n\nexport type UserAuthenticationCallback = (\n error: Error | null,\n authData: UserAuthenticationData | null\n) => void;\n\nexport interface UserAuthenticationRequestParams {\n socketId: string;\n}\n\nexport interface UserAuthenticationHandler {\n (\n params: UserAuthenticationRequestParams,\n callback: UserAuthenticationCallback\n ): void;\n}\n\nexport type AuthTransportCallback =\n | ChannelAuthorizationCallback\n | UserAuthenticationCallback;\n\nexport interface AuthOptionsT {\n transport: 'ajax' | 'jsonp';\n endpoint: string;\n params?: any;\n headers?: any;\n paramsProvider?: () => any;\n headersProvider?: () => any;\n customHandler?: AuthHandler;\n}\n\nexport declare type UserAuthenticationOptions = AuthOptionsT<\n UserAuthenticationHandler\n>;\nexport declare type ChannelAuthorizationOptions = AuthOptionsT<\n ChannelAuthorizationHandler\n>;\n\nexport interface InternalAuthOptions {\n transport: 'ajax' | 'jsonp';\n endpoint: string;\n params?: any;\n headers?: any;\n paramsProvider?: () => any;\n headersProvider?: () => any;\n}\n","/** Error classes used throughout the library. */\n// https://github.com/Microsoft/TypeScript-wiki/blob/master/Breaking-Changes.md#extending-built-ins-like-error-array-and-map-may-no-longer-work\nexport class BadEventName extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\nexport class BadChannelName extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\nexport class RequestTimedOut extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class TransportPriorityTooLow extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class TransportClosed extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class UnsupportedFeature extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class UnsupportedTransport extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class UnsupportedStrategy extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class HTTPAuthError extends Error {\n status: number;\n constructor(status: number, msg?: string) {\n super(msg);\n this.status = status;\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n","import TimelineSender from 'core/timeline/timeline_sender';\nimport * as Collections from 'core/utils/collections';\nimport Util from 'core/util';\nimport Runtime from 'runtime';\nimport { AuthTransport } from 'core/auth/auth_transports';\nimport AbstractRuntime from 'runtimes/interface';\nimport UrlStore from 'core/utils/url_store';\nimport {\n AuthRequestType,\n AuthTransportCallback,\n InternalAuthOptions\n} from 'core/auth/options';\nimport { HTTPAuthError } from 'core/errors';\n\nconst ajax: AuthTransport = function(\n context: AbstractRuntime,\n query: string,\n authOptions: InternalAuthOptions,\n authRequestType: AuthRequestType,\n callback: AuthTransportCallback\n) {\n const xhr = Runtime.createXHR();\n xhr.open('POST', authOptions.endpoint, true);\n\n // add request headers\n xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');\n for (var headerName in authOptions.headers) {\n xhr.setRequestHeader(headerName, authOptions.headers[headerName]);\n }\n if (authOptions.headersProvider != null) {\n let dynamicHeaders = authOptions.headersProvider();\n for (var headerName in dynamicHeaders) {\n xhr.setRequestHeader(headerName, dynamicHeaders[headerName]);\n }\n }\n\n xhr.onreadystatechange = function() {\n if (xhr.readyState === 4) {\n if (xhr.status === 200) {\n let data;\n let parsed = false;\n\n try {\n data = JSON.parse(xhr.responseText);\n parsed = true;\n } catch (e) {\n callback(\n new HTTPAuthError(\n 200,\n `JSON returned from ${authRequestType.toString()} endpoint was invalid, yet status code was 200. Data was: ${\n xhr.responseText\n }`\n ),\n null\n );\n }\n\n if (parsed) {\n // prevents double execution.\n callback(null, data);\n }\n } else {\n let suffix = '';\n switch (authRequestType) {\n case AuthRequestType.UserAuthentication:\n suffix = UrlStore.buildLogSuffix('authenticationEndpoint');\n break;\n case AuthRequestType.ChannelAuthorization:\n suffix = `Clients must be authorized to join private or presence channels. ${UrlStore.buildLogSuffix(\n 'authorizationEndpoint'\n )}`;\n break;\n }\n callback(\n new HTTPAuthError(\n xhr.status,\n `Unable to retrieve auth string from ${authRequestType.toString()} endpoint - ` +\n `received status: ${xhr.status} from ${authOptions.endpoint}. ${suffix}`\n ),\n null\n );\n }\n }\n };\n\n xhr.send(query);\n return xhr;\n};\n\nexport default ajax;\n","export default function encode(s: any): string {\n return btoa(utob(s));\n}\n\nvar fromCharCode = String.fromCharCode;\n\nvar b64chars =\n 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';\nvar b64tab = {};\n\nfor (var i = 0, l = b64chars.length; i < l; i++) {\n b64tab[b64chars.charAt(i)] = i;\n}\n\nvar cb_utob = function(c) {\n var cc = c.charCodeAt(0);\n return cc < 0x80\n ? c\n : cc < 0x800\n ? fromCharCode(0xc0 | (cc >>> 6)) + fromCharCode(0x80 | (cc & 0x3f))\n : fromCharCode(0xe0 | ((cc >>> 12) & 0x0f)) +\n fromCharCode(0x80 | ((cc >>> 6) & 0x3f)) +\n fromCharCode(0x80 | (cc & 0x3f));\n};\n\nvar utob = function(u) {\n return u.replace(/[^\\x00-\\x7F]/g, cb_utob);\n};\n\nvar cb_encode = function(ccc) {\n var padlen = [0, 2, 1][ccc.length % 3];\n var ord =\n (ccc.charCodeAt(0) << 16) |\n ((ccc.length > 1 ? ccc.charCodeAt(1) : 0) << 8) |\n (ccc.length > 2 ? ccc.charCodeAt(2) : 0);\n var chars = [\n b64chars.charAt(ord >>> 18),\n b64chars.charAt((ord >>> 12) & 63),\n padlen >= 2 ? '=' : b64chars.charAt((ord >>> 6) & 63),\n padlen >= 1 ? '=' : b64chars.charAt(ord & 63)\n ];\n return chars.join('');\n};\n\nvar btoa =\n global.btoa ||\n function(b) {\n return b.replace(/[\\s\\S]{1,3}/g, cb_encode);\n };\n","import TimedCallback from './timed_callback';\nimport { Delay, Scheduler, Canceller } from './scheduling';\n\nabstract class Timer {\n protected clear: Canceller;\n protected timer: number | void;\n\n constructor(\n set: Scheduler,\n clear: Canceller,\n delay: Delay,\n callback: TimedCallback\n ) {\n this.clear = clear;\n this.timer = set(() => {\n if (this.timer) {\n this.timer = callback(this.timer);\n }\n }, delay);\n }\n\n /** Returns whether the timer is still running.\n *\n * @return {Boolean}\n */\n isRunning(): boolean {\n return this.timer !== null;\n }\n\n /** Aborts a timer when it's running. */\n ensureAborted() {\n if (this.timer) {\n this.clear(this.timer);\n this.timer = null;\n }\n }\n}\n\nexport default Timer;\n","import Timer from './abstract_timer';\nimport TimedCallback from './timed_callback';\nimport { Delay } from './scheduling';\n\n// We need to bind clear functions this way to avoid exceptions on IE8\nfunction clearTimeout(timer) {\n global.clearTimeout(timer);\n}\nfunction clearInterval(timer) {\n global.clearInterval(timer);\n}\n\n/** Cross-browser compatible one-off timer abstraction.\n *\n * @param {Number} delay\n * @param {Function} callback\n */\nexport class OneOffTimer extends Timer {\n constructor(delay: Delay, callback: TimedCallback) {\n super(setTimeout, clearTimeout, delay, function(timer) {\n callback();\n return null;\n });\n }\n}\n\n/** Cross-browser compatible periodic timer abstraction.\n *\n * @param {Number} delay\n * @param {Function} callback\n */\nexport class PeriodicTimer extends Timer {\n constructor(delay: Delay, callback: TimedCallback) {\n super(setInterval, clearInterval, delay, function(timer) {\n callback();\n return timer;\n });\n }\n}\n","import * as Collections from './utils/collections';\nimport TimedCallback from './utils/timers/timed_callback';\nimport { OneOffTimer, PeriodicTimer } from './utils/timers';\n\nvar Util = {\n now(): number {\n if (Date.now) {\n return Date.now();\n } else {\n return new Date().valueOf();\n }\n },\n\n defer(callback: TimedCallback): OneOffTimer {\n return new OneOffTimer(0, callback);\n },\n\n /** Builds a function that will proxy a method call to its first argument.\n *\n * Allows partial application of arguments, so additional arguments are\n * prepended to the argument list.\n *\n * @param {String} name method name\n * @return {Function} proxy function\n */\n method(name: string, ...args: any[]): Function {\n var boundArguments = Array.prototype.slice.call(arguments, 1);\n return function(object) {\n return object[name].apply(object, boundArguments.concat(arguments));\n };\n }\n};\n\nexport default Util;\n","import base64encode from '../base64';\nimport Util from '../util';\n\n/** Merges multiple objects into the target argument.\n *\n * For properties that are plain Objects, performs a deep-merge. For the\n * rest it just copies the value of the property.\n *\n * To extend prototypes use it as following:\n * Pusher.Util.extend(Target.prototype, Base.prototype)\n *\n * You can also use it to merge objects without altering them:\n * Pusher.Util.extend({}, object1, object2)\n *\n * @param {Object} target\n * @return {Object} the target argument\n */\nexport function extend(target: any, ...sources: any[]): T {\n for (var i = 0; i < sources.length; i++) {\n var extensions = sources[i];\n for (var property in extensions) {\n if (\n extensions[property] &&\n extensions[property].constructor &&\n extensions[property].constructor === Object\n ) {\n target[property] = extend(target[property] || {}, extensions[property]);\n } else {\n target[property] = extensions[property];\n }\n }\n }\n return target;\n}\n\nexport function stringify(): string {\n var m = ['Pusher'];\n for (var i = 0; i < arguments.length; i++) {\n if (typeof arguments[i] === 'string') {\n m.push(arguments[i]);\n } else {\n m.push(safeJSONStringify(arguments[i]));\n }\n }\n return m.join(' : ');\n}\n\nexport function arrayIndexOf(array: any[], item: any): number {\n // MSIE doesn't have array.indexOf\n var nativeIndexOf = Array.prototype.indexOf;\n if (array === null) {\n return -1;\n }\n if (nativeIndexOf && array.indexOf === nativeIndexOf) {\n return array.indexOf(item);\n }\n for (var i = 0, l = array.length; i < l; i++) {\n if (array[i] === item) {\n return i;\n }\n }\n return -1;\n}\n\n/** Applies a function f to all properties of an object.\n *\n * Function f gets 3 arguments passed:\n * - element from the object\n * - key of the element\n * - reference to the object\n *\n * @param {Object} object\n * @param {Function} f\n */\nexport function objectApply(object: any, f: Function) {\n for (var key in object) {\n if (Object.prototype.hasOwnProperty.call(object, key)) {\n f(object[key], key, object);\n }\n }\n}\n\n/** Return a list of objects own proerty keys\n *\n * @param {Object} object\n * @returns {Array}\n */\nexport function keys(object: any): string[] {\n var keys = [];\n objectApply(object, function(_, key) {\n keys.push(key);\n });\n return keys;\n}\n\n/** Return a list of object's own property values\n *\n * @param {Object} object\n * @returns {Array}\n */\nexport function values(object: any): any[] {\n var values = [];\n objectApply(object, function(value) {\n values.push(value);\n });\n return values;\n}\n\n/** Applies a function f to all elements of an array.\n *\n * Function f gets 3 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function apply(array: any[], f: Function, context?: any) {\n for (var i = 0; i < array.length; i++) {\n f.call(context || global, array[i], i, array);\n }\n}\n\n/** Maps all elements of the array and returns the result.\n *\n * Function f gets 4 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n * - reference to the destination array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function map(array: any[], f: Function): any[] {\n var result = [];\n for (var i = 0; i < array.length; i++) {\n result.push(f(array[i], i, array, result));\n }\n return result;\n}\n\n/** Maps all elements of the object and returns the result.\n *\n * Function f gets 4 arguments passed:\n * - element from the object\n * - key of the element\n * - reference to the source object\n * - reference to the destination object\n *\n * @param {Object} object\n * @param {Function} f\n */\nexport function mapObject(object: any, f: Function): any {\n var result = {};\n objectApply(object, function(value, key) {\n result[key] = f(value);\n });\n return result;\n}\n\n/** Filters elements of the array using a test function.\n *\n * Function test gets 4 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n * - reference to the destination array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function filter(array: any[], test: Function): any[] {\n test =\n test ||\n function(value) {\n return !!value;\n };\n\n var result = [];\n for (var i = 0; i < array.length; i++) {\n if (test(array[i], i, array, result)) {\n result.push(array[i]);\n }\n }\n return result;\n}\n\n/** Filters properties of the object using a test function.\n *\n * Function test gets 4 arguments passed:\n * - element from the object\n * - key of the element\n * - reference to the source object\n * - reference to the destination object\n *\n * @param {Object} object\n * @param {Function} f\n */\nexport function filterObject(object: Object, test: Function) {\n var result = {};\n objectApply(object, function(value, key) {\n if ((test && test(value, key, object, result)) || Boolean(value)) {\n result[key] = value;\n }\n });\n return result;\n}\n\n/** Flattens an object into a two-dimensional array.\n *\n * @param {Object} object\n * @return {Array} resulting array of [key, value] pairs\n */\nexport function flatten(object: Object): any[] {\n var result = [];\n objectApply(object, function(value, key) {\n result.push([key, value]);\n });\n return result;\n}\n\n/** Checks whether any element of the array passes the test.\n *\n * Function test gets 3 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function any(array: any[], test: Function): boolean {\n for (var i = 0; i < array.length; i++) {\n if (test(array[i], i, array)) {\n return true;\n }\n }\n return false;\n}\n\n/** Checks whether all elements of the array pass the test.\n *\n * Function test gets 3 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function all(array: any[], test: Function): boolean {\n for (var i = 0; i < array.length; i++) {\n if (!test(array[i], i, array)) {\n return false;\n }\n }\n return true;\n}\n\nexport function encodeParamsObject(data): string {\n return mapObject(data, function(value) {\n if (typeof value === 'object') {\n value = safeJSONStringify(value);\n }\n return encodeURIComponent(base64encode(value.toString()));\n });\n}\n\nexport function buildQueryString(data: any): string {\n var params = filterObject(data, function(value) {\n return value !== undefined;\n });\n\n var query = map(\n flatten(encodeParamsObject(params)),\n Util.method('join', '=')\n ).join('&');\n\n return query;\n}\n\n/**\n * See https://github.com/douglascrockford/JSON-js/blob/master/cycle.js\n *\n * Remove circular references from an object. Required for JSON.stringify in\n * React Native, which tends to blow up a lot.\n *\n * @param {any} object\n * @return {any} Decycled object\n */\nexport function decycleObject(object: any): any {\n var objects = [],\n paths = [];\n\n return (function derez(value, path) {\n var i, name, nu;\n\n switch (typeof value) {\n case 'object':\n if (!value) {\n return null;\n }\n for (i = 0; i < objects.length; i += 1) {\n if (objects[i] === value) {\n return { $ref: paths[i] };\n }\n }\n\n objects.push(value);\n paths.push(path);\n\n if (Object.prototype.toString.apply(value) === '[object Array]') {\n nu = [];\n for (i = 0; i < value.length; i += 1) {\n nu[i] = derez(value[i], path + '[' + i + ']');\n }\n } else {\n nu = {};\n for (name in value) {\n if (Object.prototype.hasOwnProperty.call(value, name)) {\n nu[name] = derez(\n value[name],\n path + '[' + JSON.stringify(name) + ']'\n );\n }\n }\n }\n return nu;\n case 'number':\n case 'string':\n case 'boolean':\n return value;\n }\n })(object, '$');\n}\n\n/**\n * Provides a cross-browser and cross-platform way to safely stringify objects\n * into JSON. This is particularly necessary for ReactNative, where circular JSON\n * structures throw an exception.\n *\n * @param {any} source The object to stringify\n * @return {string} The serialized output.\n */\nexport function safeJSONStringify(source: any): string {\n try {\n return JSON.stringify(source);\n } catch (e) {\n return JSON.stringify(decycleObject(source));\n }\n}\n","import { stringify } from './utils/collections';\nimport Pusher from './pusher';\n\nclass Logger {\n debug(...args: any[]) {\n this.log(this.globalLog, args);\n }\n\n warn(...args: any[]) {\n this.log(this.globalLogWarn, args);\n }\n\n error(...args: any[]) {\n this.log(this.globalLogError, args);\n }\n\n private globalLog = (message: string) => {\n if (global.console && global.console.log) {\n global.console.log(message);\n }\n };\n\n private globalLogWarn(message: string) {\n if (global.console && global.console.warn) {\n global.console.warn(message);\n } else {\n this.globalLog(message);\n }\n }\n\n private globalLogError(message: string) {\n if (global.console && global.console.error) {\n global.console.error(message);\n } else {\n this.globalLogWarn(message);\n }\n }\n\n private log(\n defaultLoggingFunction: (message: string) => void,\n ...args: any[]\n ) {\n var message = stringify.apply(this, arguments);\n if (Pusher.log) {\n Pusher.log(message);\n } else if (Pusher.logToConsole) {\n const log = defaultLoggingFunction.bind(this);\n log(message);\n }\n }\n}\n\nexport default new Logger();\n","import Browser from '../browser';\nimport Logger from 'core/logger';\nimport JSONPRequest from '../dom/jsonp_request';\nimport { ScriptReceivers } from '../dom/script_receiver_factory';\nimport { AuthTransport } from 'core/auth/auth_transports';\nimport {\n AuthRequestType,\n AuthTransportCallback,\n InternalAuthOptions\n} from 'core/auth/options';\n\nvar jsonp: AuthTransport = function(\n context: Browser,\n query: string,\n authOptions: InternalAuthOptions,\n authRequestType: AuthRequestType,\n callback: AuthTransportCallback\n) {\n if (\n authOptions.headers !== undefined ||\n authOptions.headersProvider != null\n ) {\n Logger.warn(\n `To send headers with the ${authRequestType.toString()} request, you must use AJAX, rather than JSONP.`\n );\n }\n\n var callbackName = context.nextAuthCallbackID.toString();\n context.nextAuthCallbackID++;\n\n var document = context.getDocument();\n var script = document.createElement('script');\n // Hacked wrapper.\n context.auth_callbacks[callbackName] = function(data) {\n callback(null, data);\n };\n\n var callback_name = \"Pusher.auth_callbacks['\" + callbackName + \"']\";\n script.src =\n authOptions.endpoint +\n '?callback=' +\n encodeURIComponent(callback_name) +\n '&' +\n query;\n\n var head =\n document.getElementsByTagName('head')[0] || document.documentElement;\n head.insertBefore(script, head.firstChild);\n};\n\nexport default jsonp;\n","import ScriptReceiver from './script_receiver';\n\n/** Sends a generic HTTP GET request using a script tag.\n *\n * By constructing URL in a specific way, it can be used for loading\n * JavaScript resources or JSONP requests. It can notify about errors, but\n * only in certain environments. Please take care of monitoring the state of\n * the request yourself.\n *\n * @param {String} src\n */\nexport default class ScriptRequest {\n src: string;\n script: any;\n errorScript: any;\n\n constructor(src: string) {\n this.src = src;\n }\n\n send(receiver: ScriptReceiver) {\n var self = this;\n var errorString = 'Error loading ' + self.src;\n\n self.script = document.createElement('script');\n self.script.id = receiver.id;\n self.script.src = self.src;\n self.script.type = 'text/javascript';\n self.script.charset = 'UTF-8';\n\n if (self.script.addEventListener) {\n self.script.onerror = function() {\n receiver.callback(errorString);\n };\n self.script.onload = function() {\n receiver.callback(null);\n };\n } else {\n self.script.onreadystatechange = function() {\n if (\n self.script.readyState === 'loaded' ||\n self.script.readyState === 'complete'\n ) {\n receiver.callback(null);\n }\n };\n }\n\n // Opera<11.6 hack for missing onerror callback\n if (\n self.script.async === undefined &&\n (document).attachEvent &&\n /opera/i.test(navigator.userAgent)\n ) {\n self.errorScript = document.createElement('script');\n self.errorScript.id = receiver.id + '_error';\n self.errorScript.text = receiver.name + \"('\" + errorString + \"');\";\n self.script.async = self.errorScript.async = false;\n } else {\n self.script.async = true;\n }\n\n var head = document.getElementsByTagName('head')[0];\n head.insertBefore(self.script, head.firstChild);\n if (self.errorScript) {\n head.insertBefore(self.errorScript, self.script.nextSibling);\n }\n }\n\n /** Cleans up the DOM remains of the script request. */\n cleanup() {\n if (this.script) {\n this.script.onload = this.script.onerror = null;\n this.script.onreadystatechange = null;\n }\n if (this.script && this.script.parentNode) {\n this.script.parentNode.removeChild(this.script);\n }\n if (this.errorScript && this.errorScript.parentNode) {\n this.errorScript.parentNode.removeChild(this.errorScript);\n }\n this.script = null;\n this.errorScript = null;\n }\n}\n","import ScriptReceiver from './script_receiver';\nimport ScriptRequest from './script_request';\nimport * as Collections from 'core/utils/collections';\nimport Util from 'core/util';\nimport Runtime from '../runtime';\n\n/** Sends data via JSONP.\n *\n * Data is a key-value map. Its values are JSON-encoded and then passed\n * through base64. Finally, keys and encoded values are appended to the query\n * string.\n *\n * The class itself does not guarantee raising errors on failures, as it's not\n * possible to support such feature on all browsers. Instead, JSONP endpoint\n * should call back in a way that's easy to distinguish from browser calls,\n * for example by passing a second argument to the receiver.\n *\n * @param {String} url\n * @param {Object} data key-value map of data to be submitted\n */\nexport default class JSONPRequest {\n url: string;\n data: any;\n request: ScriptRequest;\n\n constructor(url: string, data: any) {\n this.url = url;\n this.data = data;\n }\n\n /** Sends the actual JSONP request.\n *\n * @param {ScriptReceiver} receiver\n */\n send(receiver: ScriptReceiver) {\n if (this.request) {\n return;\n }\n\n var query = Collections.buildQueryString(this.data);\n var url = this.url + '/' + receiver.number + '?' + query;\n this.request = Runtime.createScriptRequest(url);\n this.request.send(receiver);\n }\n\n /** Cleans up the DOM remains of the JSONP request. */\n cleanup() {\n if (this.request) {\n this.request.cleanup();\n }\n }\n}\n","import TimelineSender from 'core/timeline/timeline_sender';\nimport TimelineTransport from 'core/timeline/timeline_transport';\nimport Browser from 'runtime';\nimport { AuthTransport } from 'core/auth/auth_transports';\nimport { ScriptReceivers } from '../dom/script_receiver_factory';\n\nvar getAgent = function(sender: TimelineSender, useTLS: boolean) {\n return function(data: any, callback: Function) {\n var scheme = 'http' + (useTLS ? 's' : '') + '://';\n var url =\n scheme + (sender.host || sender.options.host) + sender.options.path;\n var request = Browser.createJSONPRequest(url, data);\n\n var receiver = Browser.ScriptReceivers.create(function(error, result) {\n ScriptReceivers.remove(receiver);\n request.cleanup();\n\n if (result && result.host) {\n sender.host = result.host;\n }\n if (callback) {\n callback(error, result);\n }\n });\n request.send(receiver);\n };\n};\n\nvar jsonp = {\n name: 'jsonp',\n getAgent\n};\n\nexport default jsonp;\n","import Defaults from '../defaults';\nimport { default as URLScheme, URLSchemeParams } from './url_scheme';\n\nfunction getGenericURL(\n baseScheme: string,\n params: URLSchemeParams,\n path: string\n): string {\n var scheme = baseScheme + (params.useTLS ? 's' : '');\n var host = params.useTLS ? params.hostTLS : params.hostNonTLS;\n return scheme + '://' + host + path;\n}\n\nfunction getGenericPath(key: string, queryString?: string): string {\n var path = '/app/' + key;\n var query =\n '?protocol=' +\n Defaults.PROTOCOL +\n '&client=js' +\n '&version=' +\n Defaults.VERSION +\n (queryString ? '&' + queryString : '');\n return path + query;\n}\n\nexport var ws: URLScheme = {\n getInitial: function(key: string, params: URLSchemeParams): string {\n var path = (params.httpPath || '') + getGenericPath(key, 'flash=false');\n return getGenericURL('ws', params, path);\n }\n};\n\nexport var http: URLScheme = {\n getInitial: function(key: string, params: URLSchemeParams): string {\n var path = (params.httpPath || '/pusher') + getGenericPath(key);\n return getGenericURL('http', params, path);\n }\n};\n\nexport var sockjs: URLScheme = {\n getInitial: function(key: string, params: URLSchemeParams): string {\n return getGenericURL('http', params, params.httpPath || '/pusher');\n },\n getPath: function(key: string, params: URLSchemeParams): string {\n return getGenericPath(key);\n }\n};\n","import Callback from './callback';\nimport * as Collections from '../utils/collections';\nimport CallbackTable from './callback_table';\n\nexport default class CallbackRegistry {\n _callbacks: CallbackTable;\n\n constructor() {\n this._callbacks = {};\n }\n\n get(name: string): Callback[] {\n return this._callbacks[prefix(name)];\n }\n\n add(name: string, callback: Function, context: any) {\n var prefixedEventName = prefix(name);\n this._callbacks[prefixedEventName] =\n this._callbacks[prefixedEventName] || [];\n this._callbacks[prefixedEventName].push({\n fn: callback,\n context: context\n });\n }\n\n remove(name?: string, callback?: Function, context?: any) {\n if (!name && !callback && !context) {\n this._callbacks = {};\n return;\n }\n\n var names = name ? [prefix(name)] : Collections.keys(this._callbacks);\n\n if (callback || context) {\n this.removeCallback(names, callback, context);\n } else {\n this.removeAllCallbacks(names);\n }\n }\n\n private removeCallback(names: string[], callback: Function, context: any) {\n Collections.apply(\n names,\n function(name) {\n this._callbacks[name] = Collections.filter(\n this._callbacks[name] || [],\n function(binding) {\n return (\n (callback && callback !== binding.fn) ||\n (context && context !== binding.context)\n );\n }\n );\n if (this._callbacks[name].length === 0) {\n delete this._callbacks[name];\n }\n },\n this\n );\n }\n\n private removeAllCallbacks(names: string[]) {\n Collections.apply(\n names,\n function(name) {\n delete this._callbacks[name];\n },\n this\n );\n }\n}\n\nfunction prefix(name: string): string {\n return '_' + name;\n}\n","import * as Collections from '../utils/collections';\nimport Callback from './callback';\nimport Metadata from '../channels/metadata';\nimport CallbackRegistry from './callback_registry';\n\n/** Manages callback bindings and event emitting.\n *\n * @param Function failThrough called when no listeners are bound to an event\n */\nexport default class Dispatcher {\n callbacks: CallbackRegistry;\n global_callbacks: Function[];\n failThrough: Function;\n\n constructor(failThrough?: Function) {\n this.callbacks = new CallbackRegistry();\n this.global_callbacks = [];\n this.failThrough = failThrough;\n }\n\n bind(eventName: string, callback: Function, context?: any) {\n this.callbacks.add(eventName, callback, context);\n return this;\n }\n\n bind_global(callback: Function) {\n this.global_callbacks.push(callback);\n return this;\n }\n\n unbind(eventName?: string, callback?: Function, context?: any) {\n this.callbacks.remove(eventName, callback, context);\n return this;\n }\n\n unbind_global(callback?: Function) {\n if (!callback) {\n this.global_callbacks = [];\n return this;\n }\n\n this.global_callbacks = Collections.filter(\n this.global_callbacks || [],\n c => c !== callback\n );\n\n return this;\n }\n\n unbind_all() {\n this.unbind();\n this.unbind_global();\n return this;\n }\n\n emit(eventName: string, data?: any, metadata?: Metadata): Dispatcher {\n for (var i = 0; i < this.global_callbacks.length; i++) {\n this.global_callbacks[i](eventName, data);\n }\n\n var callbacks = this.callbacks.get(eventName);\n var args = [];\n\n if (metadata) {\n // if there's a metadata argument, we need to call the callback with both\n // data and metadata regardless of whether data is undefined\n args.push(data, metadata);\n } else if (data) {\n // metadata is undefined, so we only need to call the callback with data\n // if data exists\n args.push(data);\n }\n\n if (callbacks && callbacks.length > 0) {\n for (var i = 0; i < callbacks.length; i++) {\n callbacks[i].fn.apply(callbacks[i].context || global, args);\n }\n } else if (this.failThrough) {\n this.failThrough(eventName, data);\n }\n\n return this;\n }\n}\n","import Util from '../util';\nimport * as Collections from '../utils/collections';\nimport { default as EventsDispatcher } from '../events/dispatcher';\nimport Logger from '../logger';\nimport TransportHooks from './transport_hooks';\nimport Socket from '../socket';\nimport Runtime from 'runtime';\nimport Timeline from '../timeline/timeline';\nimport TransportConnectionOptions from './transport_connection_options';\n\n/** Provides universal API for transport connections.\n *\n * Transport connection is a low-level object that wraps a connection method\n * and exposes a simple evented interface for the connection state and\n * messaging. It does not implement Pusher-specific WebSocket protocol.\n *\n * Additionally, it fetches resources needed for transport to work and exposes\n * an interface for querying transport features.\n *\n * States:\n * - new - initial state after constructing the object\n * - initializing - during initialization phase, usually fetching resources\n * - intialized - ready to establish a connection\n * - connection - when connection is being established\n * - open - when connection ready to be used\n * - closed - after connection was closed be either side\n *\n * Emits:\n * - error - after the connection raised an error\n *\n * Options:\n * - useTLS - whether connection should be over TLS\n * - hostTLS - host to connect to when connection is over TLS\n * - hostNonTLS - host to connect to when connection is over TLS\n *\n * @param {String} key application key\n * @param {Object} options\n */\nexport default class TransportConnection extends EventsDispatcher {\n hooks: TransportHooks;\n name: string;\n priority: number;\n key: string;\n options: TransportConnectionOptions;\n state: string;\n timeline: Timeline;\n activityTimeout: number;\n id: number;\n socket: Socket;\n beforeOpen: Function;\n initialize: Function;\n\n constructor(\n hooks: TransportHooks,\n name: string,\n priority: number,\n key: string,\n options: TransportConnectionOptions\n ) {\n super();\n this.initialize = Runtime.transportConnectionInitializer;\n this.hooks = hooks;\n this.name = name;\n this.priority = priority;\n this.key = key;\n this.options = options;\n\n this.state = 'new';\n this.timeline = options.timeline;\n this.activityTimeout = options.activityTimeout;\n this.id = this.timeline.generateUniqueID();\n }\n\n /** Checks whether the transport handles activity checks by itself.\n *\n * @return {Boolean}\n */\n handlesActivityChecks(): boolean {\n return Boolean(this.hooks.handlesActivityChecks);\n }\n\n /** Checks whether the transport supports the ping/pong API.\n *\n * @return {Boolean}\n */\n supportsPing(): boolean {\n return Boolean(this.hooks.supportsPing);\n }\n\n /** Tries to establish a connection.\n *\n * @returns {Boolean} false if transport is in invalid state\n */\n connect(): boolean {\n if (this.socket || this.state !== 'initialized') {\n return false;\n }\n\n var url = this.hooks.urls.getInitial(this.key, this.options);\n try {\n this.socket = this.hooks.getSocket(url, this.options);\n } catch (e) {\n Util.defer(() => {\n this.onError(e);\n this.changeState('closed');\n });\n return false;\n }\n\n this.bindListeners();\n\n Logger.debug('Connecting', { transport: this.name, url });\n this.changeState('connecting');\n return true;\n }\n\n /** Closes the connection.\n *\n * @return {Boolean} true if there was a connection to close\n */\n close(): boolean {\n if (this.socket) {\n this.socket.close();\n return true;\n } else {\n return false;\n }\n }\n\n /** Sends data over the open connection.\n *\n * @param {String} data\n * @return {Boolean} true only when in the \"open\" state\n */\n send(data: any): boolean {\n if (this.state === 'open') {\n // Workaround for MobileSafari bug (see https://gist.github.com/2052006)\n Util.defer(() => {\n if (this.socket) {\n this.socket.send(data);\n }\n });\n return true;\n } else {\n return false;\n }\n }\n\n /** Sends a ping if the connection is open and transport supports it. */\n ping() {\n if (this.state === 'open' && this.supportsPing()) {\n this.socket.ping();\n }\n }\n\n private onOpen() {\n if (this.hooks.beforeOpen) {\n this.hooks.beforeOpen(\n this.socket,\n this.hooks.urls.getPath(this.key, this.options)\n );\n }\n this.changeState('open');\n this.socket.onopen = undefined;\n }\n\n private onError(error) {\n this.emit('error', { type: 'WebSocketError', error: error });\n this.timeline.error(this.buildTimelineMessage({ error: error.toString() }));\n }\n\n private onClose(closeEvent?: any) {\n if (closeEvent) {\n this.changeState('closed', {\n code: closeEvent.code,\n reason: closeEvent.reason,\n wasClean: closeEvent.wasClean\n });\n } else {\n this.changeState('closed');\n }\n this.unbindListeners();\n this.socket = undefined;\n }\n\n private onMessage(message) {\n this.emit('message', message);\n }\n\n private onActivity() {\n this.emit('activity');\n }\n\n private bindListeners() {\n this.socket.onopen = () => {\n this.onOpen();\n };\n this.socket.onerror = error => {\n this.onError(error);\n };\n this.socket.onclose = closeEvent => {\n this.onClose(closeEvent);\n };\n this.socket.onmessage = message => {\n this.onMessage(message);\n };\n\n if (this.supportsPing()) {\n this.socket.onactivity = () => {\n this.onActivity();\n };\n }\n }\n\n private unbindListeners() {\n if (this.socket) {\n this.socket.onopen = undefined;\n this.socket.onerror = undefined;\n this.socket.onclose = undefined;\n this.socket.onmessage = undefined;\n if (this.supportsPing()) {\n this.socket.onactivity = undefined;\n }\n }\n }\n\n private changeState(state: string, params?: any) {\n this.state = state;\n this.timeline.info(\n this.buildTimelineMessage({\n state: state,\n params: params\n })\n );\n this.emit(state, params);\n }\n\n buildTimelineMessage(message): any {\n return Collections.extend({ cid: this.id }, message);\n }\n}\n","import Factory from '../utils/factory';\nimport TransportHooks from './transport_hooks';\nimport TransportConnection from './transport_connection';\nimport TransportConnectionOptions from './transport_connection_options';\n\n/** Provides interface for transport connection instantiation.\n *\n * Takes transport-specific hooks as the only argument, which allow checking\n * for transport support and creating its connections.\n *\n * Supported hooks: * - file - the name of the file to be fetched during initialization\n * - urls - URL scheme to be used by transport\n * - handlesActivityCheck - true when the transport handles activity checks\n * - supportsPing - true when the transport has a ping/activity API\n * - isSupported - tells whether the transport is supported in the environment\n * - getSocket - creates a WebSocket-compatible transport socket\n *\n * See transports.js for specific implementations.\n *\n * @param {Object} hooks object containing all needed transport hooks\n */\nexport default class Transport {\n hooks: TransportHooks;\n\n constructor(hooks: TransportHooks) {\n this.hooks = hooks;\n }\n\n /** Returns whether the transport is supported in the environment.\n *\n * @param {Object} envronment te environment details (encryption, settings)\n * @returns {Boolean} true when the transport is supported\n */\n isSupported(environment: any): boolean {\n return this.hooks.isSupported(environment);\n }\n\n /** Creates a transport connection.\n *\n * @param {String} name\n * @param {Number} priority\n * @param {String} key the application key\n * @param {Object} options\n * @returns {TransportConnection}\n */\n createConnection(\n name: string,\n priority: number,\n key: string,\n options: any\n ): TransportConnection {\n return new TransportConnection(this.hooks, name, priority, key, options);\n }\n}\n","import * as URLSchemes from 'core/transports/url_schemes';\nimport URLScheme from 'core/transports/url_scheme';\nimport Transport from 'core/transports/transport';\nimport Util from 'core/util';\nimport * as Collections from 'core/utils/collections';\nimport TransportHooks from 'core/transports/transport_hooks';\nimport TransportsTable from 'core/transports/transports_table';\nimport Runtime from 'runtime';\n\n/** WebSocket transport.\n *\n * Uses native WebSocket implementation, including MozWebSocket supported by\n * earlier Firefox versions.\n */\nvar WSTransport = new Transport({\n urls: URLSchemes.ws,\n handlesActivityChecks: false,\n supportsPing: false,\n\n isInitialized: function() {\n return Boolean(Runtime.getWebSocketAPI());\n },\n isSupported: function(): boolean {\n return Boolean(Runtime.getWebSocketAPI());\n },\n getSocket: function(url) {\n return Runtime.createWebSocket(url);\n }\n});\n\nvar httpConfiguration = {\n urls: URLSchemes.http,\n handlesActivityChecks: false,\n supportsPing: true,\n isInitialized: function() {\n return true;\n }\n};\n\nexport var streamingConfiguration = Collections.extend(\n {\n getSocket: function(url) {\n return Runtime.HTTPFactory.createStreamingSocket(url);\n }\n },\n httpConfiguration\n);\nexport var pollingConfiguration = Collections.extend(\n {\n getSocket: function(url) {\n return Runtime.HTTPFactory.createPollingSocket(url);\n }\n },\n httpConfiguration\n);\n\nvar xhrConfiguration = {\n isSupported: function(): boolean {\n return Runtime.isXHRSupported();\n }\n};\n\n/** HTTP streaming transport using CORS-enabled XMLHttpRequest. */\nvar XHRStreamingTransport = new Transport(\n (\n Collections.extend({}, streamingConfiguration, xhrConfiguration)\n )\n);\n\n/** HTTP long-polling transport using CORS-enabled XMLHttpRequest. */\nvar XHRPollingTransport = new Transport(\n Collections.extend({}, pollingConfiguration, xhrConfiguration)\n);\n\nvar Transports: TransportsTable = {\n ws: WSTransport,\n xhr_streaming: XHRStreamingTransport,\n xhr_polling: XHRPollingTransport\n};\n\nexport default Transports;\n","import {\n default as Transports,\n streamingConfiguration,\n pollingConfiguration\n} from 'isomorphic/transports/transports';\nimport Transport from 'core/transports/transport';\nimport TransportHooks from 'core/transports/transport_hooks';\nimport * as URLSchemes from 'core/transports/url_schemes';\nimport Runtime from 'runtime';\nimport { Dependencies } from '../dom/dependencies';\nimport * as Collections from 'core/utils/collections';\n\nvar SockJSTransport = new Transport({\n file: 'sockjs',\n urls: URLSchemes.sockjs,\n handlesActivityChecks: true,\n supportsPing: false,\n\n isSupported: function() {\n return true;\n },\n isInitialized: function() {\n return window.SockJS !== undefined;\n },\n getSocket: function(url, options) {\n return new window.SockJS(url, null, {\n js_path: Dependencies.getPath('sockjs', {\n useTLS: options.useTLS\n }),\n ignore_null_origin: options.ignoreNullOrigin\n });\n },\n beforeOpen: function(socket, path) {\n socket.send(\n JSON.stringify({\n path: path\n })\n );\n }\n});\n\nvar xdrConfiguration = {\n isSupported: function(environment): boolean {\n var yes = Runtime.isXDRSupported(environment.useTLS);\n return yes;\n }\n};\n\n/** HTTP streaming transport using XDomainRequest (IE 8,9). */\nvar XDRStreamingTransport = new Transport(\n (\n Collections.extend({}, streamingConfiguration, xdrConfiguration)\n )\n);\n\n/** HTTP long-polling transport using XDomainRequest (IE 8,9). */\nvar XDRPollingTransport = new Transport(\n Collections.extend({}, pollingConfiguration, xdrConfiguration)\n);\n\nTransports.xdr_streaming = XDRStreamingTransport;\nTransports.xdr_polling = XDRPollingTransport;\nTransports.sockjs = SockJSTransport;\n\nexport default Transports;\n","import Reachability from 'core/reachability';\nimport { default as EventsDispatcher } from 'core/events/dispatcher';\n\n/** Really basic interface providing network availability info.\n *\n * Emits:\n * - online - when browser goes online\n * - offline - when browser goes offline\n */\nexport class NetInfo extends EventsDispatcher implements Reachability {\n constructor() {\n super();\n var self = this;\n // This is okay, as IE doesn't support this stuff anyway.\n if (window.addEventListener !== undefined) {\n window.addEventListener(\n 'online',\n function() {\n self.emit('online');\n },\n false\n );\n window.addEventListener(\n 'offline',\n function() {\n self.emit('offline');\n },\n false\n );\n }\n }\n\n /** Returns whether browser is online or not\n *\n * Offline means definitely offline (no connection to router).\n * Inverse does NOT mean definitely online (only currently supported in Safari\n * and even there only means the device has a connection to the router).\n *\n * @return {Boolean}\n */\n isOnline(): boolean {\n if (window.navigator.onLine === undefined) {\n return true;\n } else {\n return window.navigator.onLine;\n }\n }\n}\n\nexport var Network = new NetInfo();\n","import Util from '../util';\nimport * as Collections from '../utils/collections';\nimport TransportManager from './transport_manager';\nimport TransportConnection from './transport_connection';\nimport Transport from './transport';\nimport PingDelayOptions from './ping_delay_options';\n\n/** Creates transport connections monitored by a transport manager.\n *\n * When a transport is closed, it might mean the environment does not support\n * it. It's possible that messages get stuck in an intermediate buffer or\n * proxies terminate inactive connections. To combat these problems,\n * assistants monitor the connection lifetime, report unclean exits and\n * adjust ping timeouts to keep the connection active. The decision to disable\n * a transport is the manager's responsibility.\n *\n * @param {TransportManager} manager\n * @param {TransportConnection} transport\n * @param {Object} options\n */\nexport default class AssistantToTheTransportManager {\n manager: TransportManager;\n transport: Transport;\n minPingDelay: number;\n maxPingDelay: number;\n pingDelay: number;\n\n constructor(\n manager: TransportManager,\n transport: Transport,\n options: PingDelayOptions\n ) {\n this.manager = manager;\n this.transport = transport;\n this.minPingDelay = options.minPingDelay;\n this.maxPingDelay = options.maxPingDelay;\n this.pingDelay = undefined;\n }\n\n /** Creates a transport connection.\n *\n * This function has the same API as Transport#createConnection.\n *\n * @param {String} name\n * @param {Number} priority\n * @param {String} key the application key\n * @param {Object} options\n * @returns {TransportConnection}\n */\n createConnection(\n name: string,\n priority: number,\n key: string,\n options: Object\n ): TransportConnection {\n options = Collections.extend({}, options, {\n activityTimeout: this.pingDelay\n });\n var connection = this.transport.createConnection(\n name,\n priority,\n key,\n options\n );\n\n var openTimestamp = null;\n\n var onOpen = function() {\n connection.unbind('open', onOpen);\n connection.bind('closed', onClosed);\n openTimestamp = Util.now();\n };\n var onClosed = closeEvent => {\n connection.unbind('closed', onClosed);\n\n if (closeEvent.code === 1002 || closeEvent.code === 1003) {\n // we don't want to use transports not obeying the protocol\n this.manager.reportDeath();\n } else if (!closeEvent.wasClean && openTimestamp) {\n // report deaths only for short-living transport\n var lifespan = Util.now() - openTimestamp;\n if (lifespan < 2 * this.maxPingDelay) {\n this.manager.reportDeath();\n this.pingDelay = Math.max(lifespan / 2, this.minPingDelay);\n }\n }\n };\n\n connection.bind('open', onOpen);\n return connection;\n }\n\n /** Returns whether the transport is supported in the environment.\n *\n * This function has the same API as Transport#isSupported. Might return false\n * when the manager decides to kill the transport.\n *\n * @param {Object} environment the environment details (encryption, settings)\n * @returns {Boolean} true when the transport is supported\n */\n isSupported(environment: string): boolean {\n return this.manager.isAlive() && this.transport.isSupported(environment);\n }\n}\n","import Action from './action';\nimport { PusherEvent } from './message-types';\n/**\n * Provides functions for handling Pusher protocol-specific messages.\n */\n\nconst Protocol = {\n /**\n * Decodes a message in a Pusher format.\n *\n * The MessageEvent we receive from the transport should contain a pusher event\n * (https://pusher.com/docs/pusher_protocol#events) serialized as JSON in the\n * data field\n *\n * The pusher event may contain a data field too, and it may also be\n * serialised as JSON\n *\n * Throws errors when messages are not parse'able.\n *\n * @param {MessageEvent} messageEvent\n * @return {PusherEvent}\n */\n decodeMessage: function(messageEvent: MessageEvent): PusherEvent {\n try {\n var messageData = JSON.parse(messageEvent.data);\n var pusherEventData = messageData.data;\n if (typeof pusherEventData === 'string') {\n try {\n pusherEventData = JSON.parse(messageData.data);\n } catch (e) {}\n }\n var pusherEvent: PusherEvent = {\n event: messageData.event,\n channel: messageData.channel,\n data: pusherEventData\n };\n if (messageData.user_id) {\n pusherEvent.user_id = messageData.user_id;\n }\n return pusherEvent;\n } catch (e) {\n throw { type: 'MessageParseError', error: e, data: messageEvent.data };\n }\n },\n\n /**\n * Encodes a message to be sent.\n *\n * @param {PusherEvent} event\n * @return {String}\n */\n encodeMessage: function(event: PusherEvent): string {\n return JSON.stringify(event);\n },\n\n /**\n * Processes a handshake message and returns appropriate actions.\n *\n * Returns an object with an 'action' and other action-specific properties.\n *\n * There are three outcomes when calling this function. First is a successful\n * connection attempt, when pusher:connection_established is received, which\n * results in a 'connected' action with an 'id' property. When passed a\n * pusher:error event, it returns a result with action appropriate to the\n * close code and an error. Otherwise, it raises an exception.\n *\n * @param {String} message\n * @result Object\n */\n processHandshake: function(messageEvent: MessageEvent): Action {\n var message = Protocol.decodeMessage(messageEvent);\n\n if (message.event === 'pusher:connection_established') {\n if (!message.data.activity_timeout) {\n throw 'No activity timeout specified in handshake';\n }\n return {\n action: 'connected',\n id: message.data.socket_id,\n activityTimeout: message.data.activity_timeout * 1000\n };\n } else if (message.event === 'pusher:error') {\n // From protocol 6 close codes are sent only once, so this only\n // happens when connection does not support close codes\n return {\n action: this.getCloseAction(message.data),\n error: this.getCloseError(message.data)\n };\n } else {\n throw 'Invalid handshake';\n }\n },\n\n /**\n * Dispatches the close event and returns an appropriate action name.\n *\n * See:\n * 1. https://developer.mozilla.org/en-US/docs/WebSockets/WebSockets_reference/CloseEvent\n * 2. http://pusher.com/docs/pusher_protocol\n *\n * @param {CloseEvent} closeEvent\n * @return {String} close action name\n */\n getCloseAction: function(closeEvent): string {\n if (closeEvent.code < 4000) {\n // ignore 1000 CLOSE_NORMAL, 1001 CLOSE_GOING_AWAY,\n // 1005 CLOSE_NO_STATUS, 1006 CLOSE_ABNORMAL\n // ignore 1007...3999\n // handle 1002 CLOSE_PROTOCOL_ERROR, 1003 CLOSE_UNSUPPORTED,\n // 1004 CLOSE_TOO_LARGE\n if (closeEvent.code >= 1002 && closeEvent.code <= 1004) {\n return 'backoff';\n } else {\n return null;\n }\n } else if (closeEvent.code === 4000) {\n return 'tls_only';\n } else if (closeEvent.code < 4100) {\n return 'refused';\n } else if (closeEvent.code < 4200) {\n return 'backoff';\n } else if (closeEvent.code < 4300) {\n return 'retry';\n } else {\n // unknown error\n return 'refused';\n }\n },\n\n /**\n * Returns an error or null basing on the close event.\n *\n * Null is returned when connection was closed cleanly. Otherwise, an object\n * with error details is returned.\n *\n * @param {CloseEvent} closeEvent\n * @return {Object} error object\n */\n getCloseError: function(closeEvent): any {\n if (closeEvent.code !== 1000 && closeEvent.code !== 1001) {\n return {\n type: 'PusherError',\n data: {\n code: closeEvent.code,\n message: closeEvent.reason || closeEvent.message\n }\n };\n } else {\n return null;\n }\n }\n};\n\nexport default Protocol;\n","import * as Collections from '../utils/collections';\nimport { default as EventsDispatcher } from '../events/dispatcher';\nimport Protocol from './protocol/protocol';\nimport { PusherEvent } from './protocol/message-types';\nimport Logger from '../logger';\nimport TransportConnection from '../transports/transport_connection';\nimport Socket from '../socket';\n/**\n * Provides Pusher protocol interface for transports.\n *\n * Emits following events:\n * - message - on received messages\n * - ping - on ping requests\n * - pong - on pong responses\n * - error - when the transport emits an error\n * - closed - after closing the transport\n *\n * It also emits more events when connection closes with a code.\n * See Protocol.getCloseAction to get more details.\n *\n * @param {Number} id\n * @param {AbstractTransport} transport\n */\nexport default class Connection extends EventsDispatcher implements Socket {\n id: string;\n transport: TransportConnection;\n activityTimeout: number;\n\n constructor(id: string, transport: TransportConnection) {\n super();\n this.id = id;\n this.transport = transport;\n this.activityTimeout = transport.activityTimeout;\n this.bindListeners();\n }\n\n /** Returns whether used transport handles activity checks by itself\n *\n * @returns {Boolean} true if activity checks are handled by the transport\n */\n handlesActivityChecks() {\n return this.transport.handlesActivityChecks();\n }\n\n /** Sends raw data.\n *\n * @param {String} data\n */\n send(data: any): boolean {\n return this.transport.send(data);\n }\n\n /** Sends an event.\n *\n * @param {String} name\n * @param {String} data\n * @param {String} [channel]\n * @returns {Boolean} whether message was sent or not\n */\n send_event(name: string, data: any, channel?: string): boolean {\n var event: PusherEvent = { event: name, data: data };\n if (channel) {\n event.channel = channel;\n }\n Logger.debug('Event sent', event);\n return this.send(Protocol.encodeMessage(event));\n }\n\n /** Sends a ping message to the server.\n *\n * Basing on the underlying transport, it might send either transport's\n * protocol-specific ping or pusher:ping event.\n */\n ping() {\n if (this.transport.supportsPing()) {\n this.transport.ping();\n } else {\n this.send_event('pusher:ping', {});\n }\n }\n\n /** Closes the connection. */\n close() {\n this.transport.close();\n }\n\n private bindListeners() {\n var listeners = {\n message: (messageEvent: MessageEvent) => {\n var pusherEvent;\n try {\n pusherEvent = Protocol.decodeMessage(messageEvent);\n } catch (e) {\n this.emit('error', {\n type: 'MessageParseError',\n error: e,\n data: messageEvent.data\n });\n }\n\n if (pusherEvent !== undefined) {\n Logger.debug('Event recd', pusherEvent);\n\n switch (pusherEvent.event) {\n case 'pusher:error':\n this.emit('error', {\n type: 'PusherError',\n data: pusherEvent.data\n });\n break;\n case 'pusher:ping':\n this.emit('ping');\n break;\n case 'pusher:pong':\n this.emit('pong');\n break;\n }\n this.emit('message', pusherEvent);\n }\n },\n activity: () => {\n this.emit('activity');\n },\n error: error => {\n this.emit('error', error);\n },\n closed: closeEvent => {\n unbindListeners();\n\n if (closeEvent && closeEvent.code) {\n this.handleCloseEvent(closeEvent);\n }\n\n this.transport = null;\n this.emit('closed');\n }\n };\n\n var unbindListeners = () => {\n Collections.objectApply(listeners, (listener, event) => {\n this.transport.unbind(event, listener);\n });\n };\n\n Collections.objectApply(listeners, (listener, event) => {\n this.transport.bind(event, listener);\n });\n }\n\n private handleCloseEvent(closeEvent: any) {\n var action = Protocol.getCloseAction(closeEvent);\n var error = Protocol.getCloseError(closeEvent);\n if (error) {\n this.emit('error', error);\n }\n if (action) {\n this.emit(action, { action: action, error: error });\n }\n }\n}\n","import Util from '../../util';\nimport * as Collections from '../../utils/collections';\nimport Protocol from '../protocol/protocol';\nimport Connection from '../connection';\nimport TransportConnection from '../../transports/transport_connection';\nimport HandshakePayload from './handshake_payload';\n\n/**\n * Handles Pusher protocol handshakes for transports.\n *\n * Calls back with a result object after handshake is completed. Results\n * always have two fields:\n * - action - string describing action to be taken after the handshake\n * - transport - the transport object passed to the constructor\n *\n * Different actions can set different additional properties on the result.\n * In the case of 'connected' action, there will be a 'connection' property\n * containing a Connection object for the transport. Other actions should\n * carry an 'error' property.\n *\n * @param {AbstractTransport} transport\n * @param {Function} callback\n */\nexport default class Handshake {\n transport: TransportConnection;\n callback: (HandshakePayload) => void;\n onMessage: Function;\n onClosed: Function;\n\n constructor(\n transport: TransportConnection,\n callback: (HandshakePayload) => void\n ) {\n this.transport = transport;\n this.callback = callback;\n this.bindListeners();\n }\n\n close() {\n this.unbindListeners();\n this.transport.close();\n }\n\n private bindListeners() {\n this.onMessage = m => {\n this.unbindListeners();\n\n var result;\n try {\n result = Protocol.processHandshake(m);\n } catch (e) {\n this.finish('error', { error: e });\n this.transport.close();\n return;\n }\n\n if (result.action === 'connected') {\n this.finish('connected', {\n connection: new Connection(result.id, this.transport),\n activityTimeout: result.activityTimeout\n });\n } else {\n this.finish(result.action, { error: result.error });\n this.transport.close();\n }\n };\n\n this.onClosed = closeEvent => {\n this.unbindListeners();\n\n var action = Protocol.getCloseAction(closeEvent) || 'backoff';\n var error = Protocol.getCloseError(closeEvent);\n this.finish(action, { error: error });\n };\n\n this.transport.bind('message', this.onMessage);\n this.transport.bind('closed', this.onClosed);\n }\n\n private unbindListeners() {\n this.transport.unbind('message', this.onMessage);\n this.transport.unbind('closed', this.onClosed);\n }\n\n private finish(action: string, params: any) {\n this.callback(\n Collections.extend({ transport: this.transport, action: action }, params)\n );\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport base64encode from '../base64';\nimport Timeline from './timeline';\nimport Runtime from 'runtime';\n\nexport interface TimelineSenderOptions {\n host?: string;\n port?: number;\n path?: string;\n}\n\nexport default class TimelineSender {\n timeline: Timeline;\n options: TimelineSenderOptions;\n host: string;\n\n constructor(timeline: Timeline, options: TimelineSenderOptions) {\n this.timeline = timeline;\n this.options = options || {};\n }\n\n send(useTLS: boolean, callback?: Function) {\n if (this.timeline.isEmpty()) {\n return;\n }\n\n this.timeline.send(\n Runtime.TimelineTransport.getAgent(this, useTLS),\n callback\n );\n }\n}\n","import { default as EventsDispatcher } from '../events/dispatcher';\nimport * as Errors from '../errors';\nimport Logger from '../logger';\nimport Pusher from '../pusher';\nimport { PusherEvent } from '../connection/protocol/message-types';\nimport Metadata from './metadata';\nimport UrlStore from '../utils/url_store';\nimport {\n ChannelAuthorizationData,\n ChannelAuthorizationCallback\n} from '../auth/options';\nimport { HTTPAuthError } from '../errors';\n\n/** Provides base public channel interface with an event emitter.\n *\n * Emits:\n * - pusher:subscription_succeeded - after subscribing successfully\n * - other non-internal events\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\nexport default class Channel extends EventsDispatcher {\n name: string;\n pusher: Pusher;\n subscribed: boolean;\n subscriptionPending: boolean;\n subscriptionCancelled: boolean;\n subscriptionCount: null;\n\n constructor(name: string, pusher: Pusher) {\n super(function(event, data) {\n Logger.debug('No callbacks on ' + name + ' for ' + event);\n });\n\n this.name = name;\n this.pusher = pusher;\n this.subscribed = false;\n this.subscriptionPending = false;\n this.subscriptionCancelled = false;\n }\n\n /** Skips authorization, since public channels don't require it.\n *\n * @param {Function} callback\n */\n authorize(socketId: string, callback: ChannelAuthorizationCallback) {\n return callback(null, { auth: '' });\n }\n\n /** Triggers an event */\n trigger(event: string, data: any) {\n if (event.indexOf('client-') !== 0) {\n throw new Errors.BadEventName(\n \"Event '\" + event + \"' does not start with 'client-'\"\n );\n }\n if (!this.subscribed) {\n var suffix = UrlStore.buildLogSuffix('triggeringClientEvents');\n Logger.warn(\n `Client event triggered before channel 'subscription_succeeded' event . ${suffix}`\n );\n }\n return this.pusher.send_event(event, data, this.name);\n }\n\n /** Signals disconnection to the channel. For internal use only. */\n disconnect() {\n this.subscribed = false;\n this.subscriptionPending = false;\n }\n\n /** Handles a PusherEvent. For internal use only.\n *\n * @param {PusherEvent} event\n */\n handleEvent(event: PusherEvent) {\n var eventName = event.event;\n var data = event.data;\n if (eventName === 'pusher_internal:subscription_succeeded') {\n this.handleSubscriptionSucceededEvent(event);\n } else if (eventName === 'pusher_internal:subscription_count') {\n this.handleSubscriptionCountEvent(event);\n } else if (eventName.indexOf('pusher_internal:') !== 0) {\n var metadata: Metadata = {};\n this.emit(eventName, data, metadata);\n }\n }\n\n handleSubscriptionSucceededEvent(event: PusherEvent) {\n this.subscriptionPending = false;\n this.subscribed = true;\n if (this.subscriptionCancelled) {\n this.pusher.unsubscribe(this.name);\n } else {\n this.emit('pusher:subscription_succeeded', event.data);\n }\n }\n\n handleSubscriptionCountEvent(event: PusherEvent) {\n if (event.data.subscription_count) {\n this.subscriptionCount = event.data.subscription_count;\n }\n\n this.emit('pusher:subscription_count', event.data);\n }\n\n /** Sends a subscription request. For internal use only. */\n subscribe() {\n if (this.subscribed) {\n return;\n }\n this.subscriptionPending = true;\n this.subscriptionCancelled = false;\n this.authorize(\n this.pusher.connection.socket_id,\n (error: Error | null, data: ChannelAuthorizationData) => {\n if (error) {\n this.subscriptionPending = false;\n // Why not bind to 'pusher:subscription_error' a level up, and log there?\n // Binding to this event would cause the warning about no callbacks being\n // bound (see constructor) to be suppressed, that's not what we want.\n Logger.error(error.toString());\n this.emit(\n 'pusher:subscription_error',\n Object.assign(\n {},\n {\n type: 'AuthError',\n error: error.message\n },\n error instanceof HTTPAuthError ? { status: error.status } : {}\n )\n );\n } else {\n this.pusher.send_event('pusher:subscribe', {\n auth: data.auth,\n channel_data: data.channel_data,\n channel: this.name\n });\n }\n }\n );\n }\n\n /** Sends an unsubscription request. For internal use only. */\n unsubscribe() {\n this.subscribed = false;\n this.pusher.send_event('pusher:unsubscribe', {\n channel: this.name\n });\n }\n\n /** Cancels an in progress subscription. For internal use only. */\n cancelSubscription() {\n this.subscriptionCancelled = true;\n }\n\n /** Reinstates an in progress subscripiton. For internal use only. */\n reinstateSubscription() {\n this.subscriptionCancelled = false;\n }\n}\n","import Factory from '../utils/factory';\nimport Channel from './channel';\nimport { ChannelAuthorizationCallback } from '../auth/options';\n\n/** Extends public channels to provide private channel interface.\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\nexport default class PrivateChannel extends Channel {\n /** Authorizes the connection to use the channel.\n *\n * @param {String} socketId\n * @param {Function} callback\n */\n authorize(socketId: string, callback: ChannelAuthorizationCallback) {\n return this.pusher.config.channelAuthorizer(\n {\n channelName: this.name,\n socketId: socketId\n },\n callback\n );\n }\n}\n","import * as Collections from '../utils/collections';\n\n/** Represents a collection of members of a presence channel. */\nexport default class Members {\n members: any;\n count: number;\n myID: any;\n me: any;\n\n constructor() {\n this.reset();\n }\n\n /** Returns member's info for given id.\n *\n * Resulting object containts two fields - id and info.\n *\n * @param {Number} id\n * @return {Object} member's info or null\n */\n get(id: string): any {\n if (Object.prototype.hasOwnProperty.call(this.members, id)) {\n return {\n id: id,\n info: this.members[id]\n };\n } else {\n return null;\n }\n }\n\n /** Calls back for each member in unspecified order.\n *\n * @param {Function} callback\n */\n each(callback: Function) {\n Collections.objectApply(this.members, (member, id) => {\n callback(this.get(id));\n });\n }\n\n /** Updates the id for connected member. For internal use only. */\n setMyID(id: string) {\n this.myID = id;\n }\n\n /** Handles subscription data. For internal use only. */\n onSubscription(subscriptionData: any) {\n this.members = subscriptionData.presence.hash;\n this.count = subscriptionData.presence.count;\n this.me = this.get(this.myID);\n }\n\n /** Adds a new member to the collection. For internal use only. */\n addMember(memberData: any) {\n if (this.get(memberData.user_id) === null) {\n this.count++;\n }\n this.members[memberData.user_id] = memberData.user_info;\n return this.get(memberData.user_id);\n }\n\n /** Adds a member from the collection. For internal use only. */\n removeMember(memberData: any) {\n var member = this.get(memberData.user_id);\n if (member) {\n delete this.members[memberData.user_id];\n this.count--;\n }\n return member;\n }\n\n /** Resets the collection to the initial state. For internal use only. */\n reset() {\n this.members = {};\n this.count = 0;\n this.myID = null;\n this.me = null;\n }\n}\n","import PrivateChannel from './private_channel';\nimport Logger from '../logger';\nimport Members from './members';\nimport Pusher from '../pusher';\nimport UrlStore from 'core/utils/url_store';\nimport { PusherEvent } from '../connection/protocol/message-types';\nimport Metadata from './metadata';\nimport { ChannelAuthorizationData } from '../auth/options';\n\nexport default class PresenceChannel extends PrivateChannel {\n members: Members;\n\n /** Adds presence channel functionality to private channels.\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\n constructor(name: string, pusher: Pusher) {\n super(name, pusher);\n this.members = new Members();\n }\n\n /** Authorizes the connection as a member of the channel.\n *\n * @param {String} socketId\n * @param {Function} callback\n */\n authorize(socketId: string, callback: Function) {\n super.authorize(socketId, async (error, authData) => {\n if (!error) {\n authData = authData as ChannelAuthorizationData;\n if (authData.channel_data != null) {\n var channelData = JSON.parse(authData.channel_data);\n this.members.setMyID(channelData.user_id);\n } else {\n await this.pusher.user.signinDonePromise;\n if (this.pusher.user.user_data != null) {\n // If the user is signed in, get the id of the authenticated user\n // and allow the presence authorization to continue.\n this.members.setMyID(this.pusher.user.user_data.id);\n } else {\n let suffix = UrlStore.buildLogSuffix('authorizationEndpoint');\n Logger.error(\n `Invalid auth response for channel '${this.name}', ` +\n `expected 'channel_data' field. ${suffix}, ` +\n `or the user should be signed in.`\n );\n callback('Invalid auth response');\n return;\n }\n }\n }\n callback(error, authData);\n });\n }\n\n /** Handles presence and subscription events. For internal use only.\n *\n * @param {PusherEvent} event\n */\n handleEvent(event: PusherEvent) {\n var eventName = event.event;\n if (eventName.indexOf('pusher_internal:') === 0) {\n this.handleInternalEvent(event);\n } else {\n var data = event.data;\n var metadata: Metadata = {};\n if (event.user_id) {\n metadata.user_id = event.user_id;\n }\n this.emit(eventName, data, metadata);\n }\n }\n handleInternalEvent(event: PusherEvent) {\n var eventName = event.event;\n var data = event.data;\n switch (eventName) {\n case 'pusher_internal:subscription_succeeded':\n this.handleSubscriptionSucceededEvent(event);\n break;\n case 'pusher_internal:subscription_count':\n this.handleSubscriptionCountEvent(event);\n break;\n case 'pusher_internal:member_added':\n var addedMember = this.members.addMember(data);\n this.emit('pusher:member_added', addedMember);\n break;\n case 'pusher_internal:member_removed':\n var removedMember = this.members.removeMember(data);\n if (removedMember) {\n this.emit('pusher:member_removed', removedMember);\n }\n break;\n }\n }\n\n handleSubscriptionSucceededEvent(event: PusherEvent) {\n this.subscriptionPending = false;\n this.subscribed = true;\n if (this.subscriptionCancelled) {\n this.pusher.unsubscribe(this.name);\n } else {\n this.members.onSubscription(event.data);\n this.emit('pusher:subscription_succeeded', this.members);\n }\n }\n\n /** Resets the channel state, including members map. For internal use only. */\n disconnect() {\n this.members.reset();\n super.disconnect();\n }\n}\n","import PrivateChannel from './private_channel';\nimport * as Errors from '../errors';\nimport Logger from '../logger';\nimport Pusher from '../pusher';\nimport { decode as encodeUTF8 } from '@stablelib/utf8';\nimport { decode as decodeBase64 } from '@stablelib/base64';\nimport Dispatcher from '../events/dispatcher';\nimport { PusherEvent } from '../connection/protocol/message-types';\nimport {\n ChannelAuthorizationData,\n ChannelAuthorizationCallback\n} from '../auth/options';\nimport * as nacl from 'tweetnacl';\n\n/** Extends private channels to provide encrypted channel interface.\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\nexport default class EncryptedChannel extends PrivateChannel {\n key: Uint8Array = null;\n nacl: nacl;\n\n constructor(name: string, pusher: Pusher, nacl: nacl) {\n super(name, pusher);\n this.nacl = nacl;\n }\n\n /** Authorizes the connection to use the channel.\n *\n * @param {String} socketId\n * @param {Function} callback\n */\n authorize(socketId: string, callback: ChannelAuthorizationCallback) {\n super.authorize(\n socketId,\n (error: Error | null, authData: ChannelAuthorizationData) => {\n if (error) {\n callback(error, authData);\n return;\n }\n let sharedSecret = authData['shared_secret'];\n if (!sharedSecret) {\n callback(\n new Error(\n `No shared_secret key in auth payload for encrypted channel: ${this.name}`\n ),\n null\n );\n return;\n }\n this.key = decodeBase64(sharedSecret);\n delete authData['shared_secret'];\n callback(null, authData);\n }\n );\n }\n\n trigger(event: string, data: any): boolean {\n throw new Errors.UnsupportedFeature(\n 'Client events are not currently supported for encrypted channels'\n );\n }\n\n /** Handles an event. For internal use only.\n *\n * @param {PusherEvent} event\n */\n handleEvent(event: PusherEvent) {\n var eventName = event.event;\n var data = event.data;\n if (\n eventName.indexOf('pusher_internal:') === 0 ||\n eventName.indexOf('pusher:') === 0\n ) {\n super.handleEvent(event);\n return;\n }\n this.handleEncryptedEvent(eventName, data);\n }\n\n private handleEncryptedEvent(event: string, data: any): void {\n if (!this.key) {\n Logger.debug(\n 'Received encrypted event before key has been retrieved from the authEndpoint'\n );\n return;\n }\n if (!data.ciphertext || !data.nonce) {\n Logger.error(\n 'Unexpected format for encrypted event, expected object with `ciphertext` and `nonce` fields, got: ' +\n data\n );\n return;\n }\n let cipherText = decodeBase64(data.ciphertext);\n if (cipherText.length < this.nacl.secretbox.overheadLength) {\n Logger.error(\n `Expected encrypted event ciphertext length to be ${this.nacl.secretbox.overheadLength}, got: ${cipherText.length}`\n );\n return;\n }\n let nonce = decodeBase64(data.nonce);\n if (nonce.length < this.nacl.secretbox.nonceLength) {\n Logger.error(\n `Expected encrypted event nonce length to be ${this.nacl.secretbox.nonceLength}, got: ${nonce.length}`\n );\n return;\n }\n\n let bytes = this.nacl.secretbox.open(cipherText, nonce, this.key);\n if (bytes === null) {\n Logger.debug(\n 'Failed to decrypt an event, probably because it was encrypted with a different key. Fetching a new key from the authEndpoint...'\n );\n // Try a single time to retrieve a new auth key and decrypt the event with it\n // If this fails, a new key will be requested when a new message is received\n this.authorize(this.pusher.connection.socket_id, (error, authData) => {\n if (error) {\n Logger.error(\n `Failed to make a request to the authEndpoint: ${authData}. Unable to fetch new key, so dropping encrypted event`\n );\n return;\n }\n bytes = this.nacl.secretbox.open(cipherText, nonce, this.key);\n if (bytes === null) {\n Logger.error(\n `Failed to decrypt event with new key. Dropping encrypted event`\n );\n return;\n }\n this.emit(event, this.getDataToEmit(bytes));\n return;\n });\n return;\n }\n this.emit(event, this.getDataToEmit(bytes));\n }\n\n // Try and parse the decrypted bytes as JSON. If we can't parse it, just\n // return the utf-8 string\n getDataToEmit(bytes: Uint8Array): string {\n let raw = encodeUTF8(bytes);\n try {\n return JSON.parse(raw);\n } catch {\n return raw;\n }\n }\n}\n","import { default as EventsDispatcher } from '../events/dispatcher';\nimport { OneOffTimer as Timer } from '../utils/timers';\nimport { Config } from '../config';\nimport Logger from '../logger';\nimport HandshakePayload from './handshake/handshake_payload';\nimport Connection from './connection';\nimport Strategy from '../strategies/strategy';\nimport StrategyRunner from '../strategies/strategy_runner';\nimport * as Collections from '../utils/collections';\nimport Timeline from '../timeline/timeline';\nimport ConnectionManagerOptions from './connection_manager_options';\nimport Runtime from 'runtime';\n\nimport {\n ErrorCallbacks,\n HandshakeCallbacks,\n ConnectionCallbacks\n} from './callbacks';\nimport Action from './protocol/action';\n\n/** Manages connection to Pusher.\n *\n * Uses a strategy (currently only default), timers and network availability\n * info to establish a connection and export its state. In case of failures,\n * manages reconnection attempts.\n *\n * Exports state changes as following events:\n * - \"state_change\", { previous: p, current: state }\n * - state\n *\n * States:\n * - initialized - initial state, never transitioned to\n * - connecting - connection is being established\n * - connected - connection has been fully established\n * - disconnected - on requested disconnection\n * - unavailable - after connection timeout or when there's no network\n * - failed - when the connection strategy is not supported\n *\n * Options:\n * - unavailableTimeout - time to transition to unavailable state\n * - activityTimeout - time after which ping message should be sent\n * - pongTimeout - time for Pusher to respond with pong before reconnecting\n *\n * @param {String} key application key\n * @param {Object} options\n */\nexport default class ConnectionManager extends EventsDispatcher {\n key: string;\n options: ConnectionManagerOptions;\n state: string;\n connection: Connection;\n usingTLS: boolean;\n timeline: Timeline;\n socket_id: string;\n unavailableTimer: Timer;\n activityTimer: Timer;\n retryTimer: Timer;\n activityTimeout: number;\n strategy: Strategy;\n runner: StrategyRunner;\n errorCallbacks: ErrorCallbacks;\n handshakeCallbacks: HandshakeCallbacks;\n connectionCallbacks: ConnectionCallbacks;\n\n constructor(key: string, options: ConnectionManagerOptions) {\n super();\n this.state = 'initialized';\n this.connection = null;\n\n this.key = key;\n this.options = options;\n this.timeline = this.options.timeline;\n this.usingTLS = this.options.useTLS;\n\n this.errorCallbacks = this.buildErrorCallbacks();\n this.connectionCallbacks = this.buildConnectionCallbacks(\n this.errorCallbacks\n );\n this.handshakeCallbacks = this.buildHandshakeCallbacks(this.errorCallbacks);\n\n var Network = Runtime.getNetwork();\n\n Network.bind('online', () => {\n this.timeline.info({ netinfo: 'online' });\n if (this.state === 'connecting' || this.state === 'unavailable') {\n this.retryIn(0);\n }\n });\n Network.bind('offline', () => {\n this.timeline.info({ netinfo: 'offline' });\n if (this.connection) {\n this.sendActivityCheck();\n }\n });\n\n this.updateStrategy();\n }\n\n switchCluster(key: string) {\n this.key = key;\n // This ensures that the new config coming from\n // pusher instance are taken into account\n // such as appKey and cluster\n this.updateStrategy();\n this.retryIn(0);\n }\n\n /** Establishes a connection to Pusher.\n *\n * Does nothing when connection is already established. See top-level doc\n * to find events emitted on connection attempts.\n */\n connect() {\n if (this.connection || this.runner) {\n return;\n }\n if (!this.strategy.isSupported()) {\n this.updateState('failed');\n return;\n }\n this.updateState('connecting');\n this.startConnecting();\n this.setUnavailableTimer();\n }\n\n /** Sends raw data.\n *\n * @param {String} data\n */\n send(data) {\n if (this.connection) {\n return this.connection.send(data);\n } else {\n return false;\n }\n }\n\n /** Sends an event.\n *\n * @param {String} name\n * @param {String} data\n * @param {String} [channel]\n * @returns {Boolean} whether message was sent or not\n */\n send_event(name: string, data: any, channel?: string) {\n if (this.connection) {\n return this.connection.send_event(name, data, channel);\n } else {\n return false;\n }\n }\n\n /** Closes the connection. */\n disconnect() {\n this.disconnectInternally();\n this.updateState('disconnected');\n }\n\n isUsingTLS() {\n return this.usingTLS;\n }\n\n private startConnecting() {\n var callback = (error, handshake) => {\n if (error) {\n this.runner = this.strategy.connect(0, callback);\n } else {\n if (handshake.action === 'error') {\n this.emit('error', {\n type: 'HandshakeError',\n error: handshake.error\n });\n this.timeline.error({ handshakeError: handshake.error });\n } else {\n this.abortConnecting(); // we don't support switching connections yet\n this.handshakeCallbacks[handshake.action](handshake);\n }\n }\n };\n this.runner = this.strategy.connect(0, callback);\n }\n\n private abortConnecting() {\n if (this.runner) {\n this.runner.abort();\n this.runner = null;\n }\n }\n\n private disconnectInternally() {\n this.abortConnecting();\n this.clearRetryTimer();\n this.clearUnavailableTimer();\n if (this.connection) {\n var connection = this.abandonConnection();\n connection.close();\n }\n }\n\n private updateStrategy() {\n this.strategy = this.options.getStrategy({\n key: this.key,\n timeline: this.timeline,\n useTLS: this.usingTLS\n });\n }\n\n private retryIn(delay) {\n this.timeline.info({ action: 'retry', delay: delay });\n if (delay > 0) {\n this.emit('connecting_in', Math.round(delay / 1000));\n }\n this.retryTimer = new Timer(delay || 0, () => {\n this.disconnectInternally();\n this.connect();\n });\n }\n\n private clearRetryTimer() {\n if (this.retryTimer) {\n this.retryTimer.ensureAborted();\n this.retryTimer = null;\n }\n }\n\n private setUnavailableTimer() {\n this.unavailableTimer = new Timer(this.options.unavailableTimeout, () => {\n this.updateState('unavailable');\n });\n }\n\n private clearUnavailableTimer() {\n if (this.unavailableTimer) {\n this.unavailableTimer.ensureAborted();\n }\n }\n\n private sendActivityCheck() {\n this.stopActivityCheck();\n this.connection.ping();\n // wait for pong response\n this.activityTimer = new Timer(this.options.pongTimeout, () => {\n this.timeline.error({ pong_timed_out: this.options.pongTimeout });\n this.retryIn(0);\n });\n }\n\n private resetActivityCheck() {\n this.stopActivityCheck();\n // send ping after inactivity\n if (this.connection && !this.connection.handlesActivityChecks()) {\n this.activityTimer = new Timer(this.activityTimeout, () => {\n this.sendActivityCheck();\n });\n }\n }\n\n private stopActivityCheck() {\n if (this.activityTimer) {\n this.activityTimer.ensureAborted();\n }\n }\n\n private buildConnectionCallbacks(\n errorCallbacks: ErrorCallbacks\n ): ConnectionCallbacks {\n return Collections.extend({}, errorCallbacks, {\n message: message => {\n // includes pong messages from server\n this.resetActivityCheck();\n this.emit('message', message);\n },\n ping: () => {\n this.send_event('pusher:pong', {});\n },\n activity: () => {\n this.resetActivityCheck();\n },\n error: error => {\n // just emit error to user - socket will already be closed by browser\n this.emit('error', error);\n },\n closed: () => {\n this.abandonConnection();\n if (this.shouldRetry()) {\n this.retryIn(1000);\n }\n }\n });\n }\n\n private buildHandshakeCallbacks(\n errorCallbacks: ErrorCallbacks\n ): HandshakeCallbacks {\n return Collections.extend({}, errorCallbacks, {\n connected: (handshake: HandshakePayload) => {\n this.activityTimeout = Math.min(\n this.options.activityTimeout,\n handshake.activityTimeout,\n handshake.connection.activityTimeout || Infinity\n );\n this.clearUnavailableTimer();\n this.setConnection(handshake.connection);\n this.socket_id = this.connection.id;\n this.updateState('connected', { socket_id: this.socket_id });\n }\n });\n }\n\n private buildErrorCallbacks(): ErrorCallbacks {\n let withErrorEmitted = callback => {\n return (result: Action | HandshakePayload) => {\n if (result.error) {\n this.emit('error', { type: 'WebSocketError', error: result.error });\n }\n callback(result);\n };\n };\n\n return {\n tls_only: withErrorEmitted(() => {\n this.usingTLS = true;\n this.updateStrategy();\n this.retryIn(0);\n }),\n refused: withErrorEmitted(() => {\n this.disconnect();\n }),\n backoff: withErrorEmitted(() => {\n this.retryIn(1000);\n }),\n retry: withErrorEmitted(() => {\n this.retryIn(0);\n })\n };\n }\n\n private setConnection(connection) {\n this.connection = connection;\n for (var event in this.connectionCallbacks) {\n this.connection.bind(event, this.connectionCallbacks[event]);\n }\n this.resetActivityCheck();\n }\n\n private abandonConnection() {\n if (!this.connection) {\n return;\n }\n this.stopActivityCheck();\n for (var event in this.connectionCallbacks) {\n this.connection.unbind(event, this.connectionCallbacks[event]);\n }\n var connection = this.connection;\n this.connection = null;\n return connection;\n }\n\n private updateState(newState: string, data?: any) {\n var previousState = this.state;\n this.state = newState;\n if (previousState !== newState) {\n var newStateDescription = newState;\n if (newStateDescription === 'connected') {\n newStateDescription += ' with new socket ID ' + data.socket_id;\n }\n Logger.debug(\n 'State changed',\n previousState + ' -> ' + newStateDescription\n );\n this.timeline.info({ state: newState, params: data });\n this.emit('state_change', { previous: previousState, current: newState });\n this.emit(newState, data);\n }\n }\n\n private shouldRetry(): boolean {\n return this.state === 'connecting' || this.state === 'connected';\n }\n}\n","import Channel from './channel';\nimport * as Collections from '../utils/collections';\nimport ChannelTable from './channel_table';\nimport Factory from '../utils/factory';\nimport Pusher from '../pusher';\nimport Logger from '../logger';\nimport * as Errors from '../errors';\nimport urlStore from '../utils/url_store';\n\n/** Handles a channel map. */\nexport default class Channels {\n channels: ChannelTable;\n\n constructor() {\n this.channels = {};\n }\n\n /** Creates or retrieves an existing channel by its name.\n *\n * @param {String} name\n * @param {Pusher} pusher\n * @return {Channel}\n */\n add(name: string, pusher: Pusher) {\n if (!this.channels[name]) {\n this.channels[name] = createChannel(name, pusher);\n }\n return this.channels[name];\n }\n\n /** Returns a list of all channels\n *\n * @return {Array}\n */\n all(): Channel[] {\n return Collections.values(this.channels);\n }\n\n /** Finds a channel by its name.\n *\n * @param {String} name\n * @return {Channel} channel or null if it doesn't exist\n */\n find(name: string) {\n return this.channels[name];\n }\n\n /** Removes a channel from the map.\n *\n * @param {String} name\n */\n remove(name: string) {\n var channel = this.channels[name];\n delete this.channels[name];\n return channel;\n }\n\n /** Proxies disconnection signal to all channels. */\n disconnect() {\n Collections.objectApply(this.channels, function(channel) {\n channel.disconnect();\n });\n }\n}\n\nfunction createChannel(name: string, pusher: Pusher): Channel {\n if (name.indexOf('private-encrypted-') === 0) {\n if (pusher.config.nacl) {\n return Factory.createEncryptedChannel(name, pusher, pusher.config.nacl);\n }\n let errMsg =\n 'Tried to subscribe to a private-encrypted- channel but no nacl implementation available';\n let suffix = urlStore.buildLogSuffix('encryptedChannelSupport');\n throw new Errors.UnsupportedFeature(`${errMsg}. ${suffix}`);\n } else if (name.indexOf('private-') === 0) {\n return Factory.createPrivateChannel(name, pusher);\n } else if (name.indexOf('presence-') === 0) {\n return Factory.createPresenceChannel(name, pusher);\n } else if (name.indexOf('#') === 0) {\n throw new Errors.BadChannelName(\n 'Cannot create a channel with name \"' + name + '\".'\n );\n } else {\n return Factory.createChannel(name, pusher);\n }\n}\n","import AssistantToTheTransportManager from '../transports/assistant_to_the_transport_manager';\nimport PingDelayOptions from '../transports/ping_delay_options';\nimport Transport from '../transports/transport';\nimport TransportManager from '../transports/transport_manager';\nimport Handshake from '../connection/handshake';\nimport TransportConnection from '../transports/transport_connection';\nimport SocketHooks from '../http/socket_hooks';\nimport HTTPSocket from '../http/http_socket';\n\nimport Timeline from '../timeline/timeline';\nimport {\n default as TimelineSender,\n TimelineSenderOptions\n} from '../timeline/timeline_sender';\nimport PresenceChannel from '../channels/presence_channel';\nimport PrivateChannel from '../channels/private_channel';\nimport EncryptedChannel from '../channels/encrypted_channel';\nimport Channel from '../channels/channel';\nimport ConnectionManager from '../connection/connection_manager';\nimport ConnectionManagerOptions from '../connection/connection_manager_options';\nimport Ajax from '../http/ajax';\nimport Channels from '../channels/channels';\nimport Pusher from '../pusher';\nimport { Config } from '../config';\nimport * as nacl from 'tweetnacl';\n\nvar Factory = {\n createChannels(): Channels {\n return new Channels();\n },\n\n createConnectionManager(\n key: string,\n options: ConnectionManagerOptions\n ): ConnectionManager {\n return new ConnectionManager(key, options);\n },\n\n createChannel(name: string, pusher: Pusher): Channel {\n return new Channel(name, pusher);\n },\n\n createPrivateChannel(name: string, pusher: Pusher): PrivateChannel {\n return new PrivateChannel(name, pusher);\n },\n\n createPresenceChannel(name: string, pusher: Pusher): PresenceChannel {\n return new PresenceChannel(name, pusher);\n },\n\n createEncryptedChannel(\n name: string,\n pusher: Pusher,\n nacl: nacl\n ): EncryptedChannel {\n return new EncryptedChannel(name, pusher, nacl);\n },\n\n createTimelineSender(timeline: Timeline, options: TimelineSenderOptions) {\n return new TimelineSender(timeline, options);\n },\n\n createHandshake(\n transport: TransportConnection,\n callback: (HandshakePayload) => void\n ): Handshake {\n return new Handshake(transport, callback);\n },\n\n createAssistantToTheTransportManager(\n manager: TransportManager,\n transport: Transport,\n options: PingDelayOptions\n ): AssistantToTheTransportManager {\n return new AssistantToTheTransportManager(manager, transport, options);\n }\n};\n\nexport default Factory;\n","import AssistantToTheTransportManager from './assistant_to_the_transport_manager';\nimport Transport from './transport';\nimport PingDelayOptions from './ping_delay_options';\nimport Factory from '../utils/factory';\n\nexport interface TransportManagerOptions extends PingDelayOptions {\n lives?: number;\n}\n\n/** Keeps track of the number of lives left for a transport.\n *\n * In the beginning of a session, transports may be assigned a number of\n * lives. When an AssistantToTheTransportManager instance reports a transport\n * connection closed uncleanly, the transport loses a life. When the number\n * of lives drops to zero, the transport gets disabled by its manager.\n *\n * @param {Object} options\n */\nexport default class TransportManager {\n options: TransportManagerOptions;\n livesLeft: number;\n\n constructor(options: TransportManagerOptions) {\n this.options = options || {};\n this.livesLeft = this.options.lives || Infinity;\n }\n\n /** Creates a assistant for the transport.\n *\n * @param {Transport} transport\n * @returns {AssistantToTheTransportManager}\n */\n getAssistant(transport: Transport): AssistantToTheTransportManager {\n return Factory.createAssistantToTheTransportManager(this, transport, {\n minPingDelay: this.options.minPingDelay,\n maxPingDelay: this.options.maxPingDelay\n });\n }\n\n /** Returns whether the transport has any lives left.\n *\n * @returns {Boolean}\n */\n isAlive(): boolean {\n return this.livesLeft > 0;\n }\n\n /** Takes one life from the transport. */\n reportDeath() {\n this.livesLeft -= 1;\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport { OneOffTimer as Timer } from '../utils/timers';\nimport Strategy from './strategy';\nimport StrategyOptions from './strategy_options';\n\n/** Loops through strategies with optional timeouts.\n *\n * Options:\n * - loop - whether it should loop through the substrategy list\n * - timeout - initial timeout for a single substrategy\n * - timeoutLimit - maximum timeout\n *\n * @param {Strategy[]} strategies\n * @param {Object} options\n */\nexport default class SequentialStrategy implements Strategy {\n strategies: Strategy[];\n loop: boolean;\n failFast: boolean;\n timeout: number;\n timeoutLimit: number;\n\n constructor(strategies: Strategy[], options: StrategyOptions) {\n this.strategies = strategies;\n this.loop = Boolean(options.loop);\n this.failFast = Boolean(options.failFast);\n this.timeout = options.timeout;\n this.timeoutLimit = options.timeoutLimit;\n }\n\n isSupported(): boolean {\n return Collections.any(this.strategies, Util.method('isSupported'));\n }\n\n connect(minPriority: number, callback: Function) {\n var strategies = this.strategies;\n var current = 0;\n var timeout = this.timeout;\n var runner = null;\n\n var tryNextStrategy = (error, handshake) => {\n if (handshake) {\n callback(null, handshake);\n } else {\n current = current + 1;\n if (this.loop) {\n current = current % strategies.length;\n }\n\n if (current < strategies.length) {\n if (timeout) {\n timeout = timeout * 2;\n if (this.timeoutLimit) {\n timeout = Math.min(timeout, this.timeoutLimit);\n }\n }\n runner = this.tryStrategy(\n strategies[current],\n minPriority,\n { timeout, failFast: this.failFast },\n tryNextStrategy\n );\n } else {\n callback(true);\n }\n }\n };\n\n runner = this.tryStrategy(\n strategies[current],\n minPriority,\n { timeout: timeout, failFast: this.failFast },\n tryNextStrategy\n );\n\n return {\n abort: function() {\n runner.abort();\n },\n forceMinPriority: function(p) {\n minPriority = p;\n if (runner) {\n runner.forceMinPriority(p);\n }\n }\n };\n }\n\n private tryStrategy(\n strategy: Strategy,\n minPriority: number,\n options: StrategyOptions,\n callback: Function\n ) {\n var timer = null;\n var runner = null;\n\n if (options.timeout > 0) {\n timer = new Timer(options.timeout, function() {\n runner.abort();\n callback(true);\n });\n }\n\n runner = strategy.connect(minPriority, function(error, handshake) {\n if (error && timer && timer.isRunning() && !options.failFast) {\n // advance to the next strategy after the timeout\n return;\n }\n if (timer) {\n timer.ensureAborted();\n }\n callback(error, handshake);\n });\n\n return {\n abort: function() {\n if (timer) {\n timer.ensureAborted();\n }\n runner.abort();\n },\n forceMinPriority: function(p) {\n runner.forceMinPriority(p);\n }\n };\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport Strategy from './strategy';\n\n/** Launches all substrategies and emits prioritized connected transports.\n *\n * @param {Array} strategies\n */\nexport default class BestConnectedEverStrategy implements Strategy {\n strategies: Strategy[];\n\n constructor(strategies: Strategy[]) {\n this.strategies = strategies;\n }\n\n isSupported(): boolean {\n return Collections.any(this.strategies, Util.method('isSupported'));\n }\n\n connect(minPriority: number, callback: Function) {\n return connect(this.strategies, minPriority, function(i, runners) {\n return function(error, handshake) {\n runners[i].error = error;\n if (error) {\n if (allRunnersFailed(runners)) {\n callback(true);\n }\n return;\n }\n Collections.apply(runners, function(runner) {\n runner.forceMinPriority(handshake.transport.priority);\n });\n callback(null, handshake);\n };\n });\n }\n}\n\n/** Connects to all strategies in parallel.\n *\n * Callback builder should be a function that takes two arguments: index\n * and a list of runners. It should return another function that will be\n * passed to the substrategy with given index. Runners can be aborted using\n * abortRunner(s) functions from this class.\n *\n * @param {Array} strategies\n * @param {Function} callbackBuilder\n * @return {Object} strategy runner\n */\nfunction connect(\n strategies: Strategy[],\n minPriority: number,\n callbackBuilder: Function\n) {\n var runners = Collections.map(strategies, function(strategy, i, _, rs) {\n return strategy.connect(minPriority, callbackBuilder(i, rs));\n });\n return {\n abort: function() {\n Collections.apply(runners, abortRunner);\n },\n forceMinPriority: function(p) {\n Collections.apply(runners, function(runner) {\n runner.forceMinPriority(p);\n });\n }\n };\n}\n\nfunction allRunnersFailed(runners): boolean {\n return Collections.all(runners, function(runner) {\n return Boolean(runner.error);\n });\n}\n\nfunction abortRunner(runner) {\n if (!runner.error && !runner.aborted) {\n runner.abort();\n runner.aborted = true;\n }\n}\n","import Util from '../util';\nimport Runtime from 'runtime';\nimport Strategy from './strategy';\nimport SequentialStrategy from './sequential_strategy';\nimport StrategyOptions from './strategy_options';\nimport TransportStrategy from './transport_strategy';\nimport Timeline from '../timeline/timeline';\nimport * as Collections from '../utils/collections';\n\nexport interface TransportStrategyDictionary {\n [key: string]: TransportStrategy;\n}\n\n/** Caches the last successful transport and, after the first few attempts,\n * uses the cached transport for subsequent attempts.\n *\n * @param {Strategy} strategy\n * @param {Object} transports\n * @param {Object} options\n */\nexport default class WebSocketPrioritizedCachedStrategy implements Strategy {\n strategy: Strategy;\n transports: TransportStrategyDictionary;\n ttl: number;\n usingTLS: boolean;\n timeline: Timeline;\n\n constructor(\n strategy: Strategy,\n transports: TransportStrategyDictionary,\n options: StrategyOptions\n ) {\n this.strategy = strategy;\n this.transports = transports;\n this.ttl = options.ttl || 1800 * 1000;\n this.usingTLS = options.useTLS;\n this.timeline = options.timeline;\n }\n\n isSupported(): boolean {\n return this.strategy.isSupported();\n }\n\n connect(minPriority: number, callback: Function) {\n var usingTLS = this.usingTLS;\n var info = fetchTransportCache(usingTLS);\n var cacheSkipCount = info && info.cacheSkipCount ? info.cacheSkipCount : 0;\n\n var strategies = [this.strategy];\n if (info && info.timestamp + this.ttl >= Util.now()) {\n var transport = this.transports[info.transport];\n if (transport) {\n if (['ws', 'wss'].includes(info.transport) || cacheSkipCount > 3) {\n this.timeline.info({\n cached: true,\n transport: info.transport,\n latency: info.latency\n });\n strategies.push(\n new SequentialStrategy([transport], {\n timeout: info.latency * 2 + 1000,\n failFast: true\n })\n );\n } else {\n cacheSkipCount++;\n }\n }\n }\n\n var startTimestamp = Util.now();\n var runner = strategies\n .pop()\n .connect(minPriority, function cb(error, handshake) {\n if (error) {\n flushTransportCache(usingTLS);\n if (strategies.length > 0) {\n startTimestamp = Util.now();\n runner = strategies.pop().connect(minPriority, cb);\n } else {\n callback(error);\n }\n } else {\n storeTransportCache(\n usingTLS,\n handshake.transport.name,\n Util.now() - startTimestamp,\n cacheSkipCount\n );\n callback(null, handshake);\n }\n });\n\n return {\n abort: function() {\n runner.abort();\n },\n forceMinPriority: function(p) {\n minPriority = p;\n if (runner) {\n runner.forceMinPriority(p);\n }\n }\n };\n }\n}\n\nfunction getTransportCacheKey(usingTLS: boolean): string {\n return 'pusherTransport' + (usingTLS ? 'TLS' : 'NonTLS');\n}\n\nfunction fetchTransportCache(usingTLS: boolean): any {\n var storage = Runtime.getLocalStorage();\n if (storage) {\n try {\n var serializedCache = storage[getTransportCacheKey(usingTLS)];\n if (serializedCache) {\n return JSON.parse(serializedCache);\n }\n } catch (e) {\n flushTransportCache(usingTLS);\n }\n }\n return null;\n}\n\nfunction storeTransportCache(\n usingTLS: boolean,\n transport: TransportStrategy,\n latency: number,\n cacheSkipCount: number\n) {\n var storage = Runtime.getLocalStorage();\n if (storage) {\n try {\n storage[getTransportCacheKey(usingTLS)] = Collections.safeJSONStringify({\n timestamp: Util.now(),\n transport: transport,\n latency: latency,\n cacheSkipCount: cacheSkipCount\n });\n } catch (e) {\n // catch over quota exceptions raised by localStorage\n }\n }\n}\n\nfunction flushTransportCache(usingTLS: boolean) {\n var storage = Runtime.getLocalStorage();\n if (storage) {\n try {\n delete storage[getTransportCacheKey(usingTLS)];\n } catch (e) {\n // catch exceptions raised by localStorage\n }\n }\n}\n","import { OneOffTimer as Timer } from '../utils/timers';\nimport Strategy from './strategy';\nimport StrategyOptions from './strategy_options';\n\n/** Runs substrategy after specified delay.\n *\n * Options:\n * - delay - time in miliseconds to delay the substrategy attempt\n *\n * @param {Strategy} strategy\n * @param {Object} options\n */\nexport default class DelayedStrategy implements Strategy {\n strategy: Strategy;\n options: { delay: number };\n\n constructor(strategy: Strategy, { delay: number }) {\n this.strategy = strategy;\n this.options = { delay: number };\n }\n\n isSupported(): boolean {\n return this.strategy.isSupported();\n }\n\n connect(minPriority: number, callback: Function) {\n var strategy = this.strategy;\n var runner;\n var timer = new Timer(this.options.delay, function() {\n runner = strategy.connect(minPriority, callback);\n });\n\n return {\n abort: function() {\n timer.ensureAborted();\n if (runner) {\n runner.abort();\n }\n },\n forceMinPriority: function(p) {\n minPriority = p;\n if (runner) {\n runner.forceMinPriority(p);\n }\n }\n };\n }\n}\n","import Strategy from './strategy';\nimport StrategyRunner from './strategy_runner';\n\n/** Proxies method calls to one of substrategies basing on the test function.\n *\n * @param {Function} test\n * @param {Strategy} trueBranch strategy used when test returns true\n * @param {Strategy} falseBranch strategy used when test returns false\n */\nexport default class IfStrategy implements Strategy {\n test: () => boolean;\n trueBranch: Strategy;\n falseBranch: Strategy;\n\n constructor(\n test: () => boolean,\n trueBranch: Strategy,\n falseBranch: Strategy\n ) {\n this.test = test;\n this.trueBranch = trueBranch;\n this.falseBranch = falseBranch;\n }\n\n isSupported(): boolean {\n var branch = this.test() ? this.trueBranch : this.falseBranch;\n return branch.isSupported();\n }\n\n connect(minPriority: number, callback: Function): StrategyRunner {\n var branch = this.test() ? this.trueBranch : this.falseBranch;\n return branch.connect(minPriority, callback);\n }\n}\n","import Strategy from './strategy';\nimport StrategyRunner from './strategy_runner';\n\n/** Launches the substrategy and terminates on the first open connection.\n *\n * @param {Strategy} strategy\n */\nexport default class FirstConnectedStrategy implements Strategy {\n strategy: Strategy;\n\n constructor(strategy: Strategy) {\n this.strategy = strategy;\n }\n\n isSupported(): boolean {\n return this.strategy.isSupported();\n }\n\n connect(minPriority: number, callback: Function): StrategyRunner {\n var runner = this.strategy.connect(minPriority, function(error, handshake) {\n if (handshake) {\n runner.abort();\n }\n callback(error, handshake);\n });\n return runner;\n }\n}\n","import * as Collections from 'core/utils/collections';\nimport TransportManager from 'core/transports/transport_manager';\nimport Strategy from 'core/strategies/strategy';\nimport StrategyOptions from 'core/strategies/strategy_options';\nimport SequentialStrategy from 'core/strategies/sequential_strategy';\nimport BestConnectedEverStrategy from 'core/strategies/best_connected_ever_strategy';\nimport WebSocketPrioritizedCachedStrategy, {\n TransportStrategyDictionary\n} from 'core/strategies/websocket_prioritized_cached_strategy';\nimport DelayedStrategy from 'core/strategies/delayed_strategy';\nimport IfStrategy from 'core/strategies/if_strategy';\nimport FirstConnectedStrategy from 'core/strategies/first_connected_strategy';\nimport { Config } from 'core/config';\n\nfunction testSupportsStrategy(strategy: Strategy) {\n return function() {\n return strategy.isSupported();\n };\n}\n\nvar getDefaultStrategy = function(\n config: Config,\n baseOptions: StrategyOptions,\n defineTransport: Function\n): Strategy {\n var definedTransports = {};\n\n function defineTransportStrategy(\n name: string,\n type: string,\n priority: number,\n options: StrategyOptions,\n manager?: TransportManager\n ) {\n var transport = defineTransport(\n config,\n name,\n type,\n priority,\n options,\n manager\n );\n\n definedTransports[name] = transport;\n\n return transport;\n }\n\n var ws_options: StrategyOptions = Object.assign({}, baseOptions, {\n hostNonTLS: config.wsHost + ':' + config.wsPort,\n hostTLS: config.wsHost + ':' + config.wssPort,\n httpPath: config.wsPath\n });\n var wss_options: StrategyOptions = Object.assign({}, ws_options, {\n useTLS: true\n });\n var sockjs_options: StrategyOptions = Object.assign({}, baseOptions, {\n hostNonTLS: config.httpHost + ':' + config.httpPort,\n hostTLS: config.httpHost + ':' + config.httpsPort,\n httpPath: config.httpPath\n });\n\n var timeouts = {\n loop: true,\n timeout: 15000,\n timeoutLimit: 60000\n };\n\n var ws_manager = new TransportManager({\n minPingDelay: 10000,\n maxPingDelay: config.activityTimeout\n });\n var streaming_manager = new TransportManager({\n lives: 2,\n minPingDelay: 10000,\n maxPingDelay: config.activityTimeout\n });\n\n var ws_transport = defineTransportStrategy(\n 'ws',\n 'ws',\n 3,\n ws_options,\n ws_manager\n );\n var wss_transport = defineTransportStrategy(\n 'wss',\n 'ws',\n 3,\n wss_options,\n ws_manager\n );\n var sockjs_transport = defineTransportStrategy(\n 'sockjs',\n 'sockjs',\n 1,\n sockjs_options\n );\n var xhr_streaming_transport = defineTransportStrategy(\n 'xhr_streaming',\n 'xhr_streaming',\n 1,\n sockjs_options,\n streaming_manager\n );\n var xdr_streaming_transport = defineTransportStrategy(\n 'xdr_streaming',\n 'xdr_streaming',\n 1,\n sockjs_options,\n streaming_manager\n );\n var xhr_polling_transport = defineTransportStrategy(\n 'xhr_polling',\n 'xhr_polling',\n 1,\n sockjs_options\n );\n var xdr_polling_transport = defineTransportStrategy(\n 'xdr_polling',\n 'xdr_polling',\n 1,\n sockjs_options\n );\n\n var ws_loop = new SequentialStrategy([ws_transport], timeouts);\n var wss_loop = new SequentialStrategy([wss_transport], timeouts);\n var sockjs_loop = new SequentialStrategy([sockjs_transport], timeouts);\n var streaming_loop = new SequentialStrategy(\n [\n new IfStrategy(\n testSupportsStrategy(xhr_streaming_transport),\n xhr_streaming_transport,\n xdr_streaming_transport\n )\n ],\n timeouts\n );\n var polling_loop = new SequentialStrategy(\n [\n new IfStrategy(\n testSupportsStrategy(xhr_polling_transport),\n xhr_polling_transport,\n xdr_polling_transport\n )\n ],\n timeouts\n );\n\n var http_loop = new SequentialStrategy(\n [\n new IfStrategy(\n testSupportsStrategy(streaming_loop),\n new BestConnectedEverStrategy([\n streaming_loop,\n new DelayedStrategy(polling_loop, { delay: 4000 })\n ]),\n polling_loop\n )\n ],\n timeouts\n );\n\n var http_fallback_loop = new IfStrategy(\n testSupportsStrategy(http_loop),\n http_loop,\n sockjs_loop\n );\n\n var wsStrategy;\n if (baseOptions.useTLS) {\n wsStrategy = new BestConnectedEverStrategy([\n ws_loop,\n new DelayedStrategy(http_fallback_loop, { delay: 2000 })\n ]);\n } else {\n wsStrategy = new BestConnectedEverStrategy([\n ws_loop,\n new DelayedStrategy(wss_loop, { delay: 2000 }),\n new DelayedStrategy(http_fallback_loop, { delay: 5000 })\n ]);\n }\n\n return new WebSocketPrioritizedCachedStrategy(\n new FirstConnectedStrategy(\n new IfStrategy(\n testSupportsStrategy(ws_transport),\n wsStrategy,\n http_fallback_loop\n )\n ),\n definedTransports,\n {\n ttl: 1800000,\n timeline: baseOptions.timeline,\n useTLS: baseOptions.useTLS\n }\n );\n};\n\nexport default getDefaultStrategy;\n","import HTTPRequest from 'core/http/http_request';\nimport RequestHooks from 'core/http/request_hooks';\nimport Ajax from 'core/http/ajax';\nimport * as Errors from 'core/errors';\n\nvar hooks: RequestHooks = {\n getRequest: function(socket: HTTPRequest): Ajax {\n var xdr = new (window).XDomainRequest();\n xdr.ontimeout = function() {\n socket.emit('error', new Errors.RequestTimedOut());\n socket.close();\n };\n xdr.onerror = function(e) {\n socket.emit('error', e);\n socket.close();\n };\n xdr.onprogress = function() {\n if (xdr.responseText && xdr.responseText.length > 0) {\n socket.onChunk(200, xdr.responseText);\n }\n };\n xdr.onload = function() {\n if (xdr.responseText && xdr.responseText.length > 0) {\n socket.onChunk(200, xdr.responseText);\n }\n socket.emit('finished', 200);\n socket.close();\n };\n return xdr;\n },\n abortRequest: function(xdr: Ajax) {\n xdr.ontimeout = xdr.onerror = xdr.onprogress = xdr.onload = null;\n xdr.abort();\n }\n};\n\nexport default hooks;\n","import Runtime from 'runtime';\nimport RequestHooks from './request_hooks';\nimport Ajax from './ajax';\nimport { default as EventsDispatcher } from '../events/dispatcher';\n\nconst MAX_BUFFER_LENGTH = 256 * 1024;\n\nexport default class HTTPRequest extends EventsDispatcher {\n hooks: RequestHooks;\n method: string;\n url: string;\n position: number;\n xhr: Ajax;\n unloader: Function;\n\n constructor(hooks: RequestHooks, method: string, url: string) {\n super();\n this.hooks = hooks;\n this.method = method;\n this.url = url;\n }\n\n start(payload?: any) {\n this.position = 0;\n this.xhr = this.hooks.getRequest(this);\n\n this.unloader = () => {\n this.close();\n };\n Runtime.addUnloadListener(this.unloader);\n\n this.xhr.open(this.method, this.url, true);\n\n if (this.xhr.setRequestHeader) {\n this.xhr.setRequestHeader('Content-Type', 'application/json'); // ReactNative doesn't set this header by default.\n }\n this.xhr.send(payload);\n }\n\n close() {\n if (this.unloader) {\n Runtime.removeUnloadListener(this.unloader);\n this.unloader = null;\n }\n if (this.xhr) {\n this.hooks.abortRequest(this.xhr);\n this.xhr = null;\n }\n }\n\n onChunk(status: number, data: any) {\n while (true) {\n var chunk = this.advanceBuffer(data);\n if (chunk) {\n this.emit('chunk', { status: status, data: chunk });\n } else {\n break;\n }\n }\n if (this.isBufferTooLong(data)) {\n this.emit('buffer_too_long');\n }\n }\n\n private advanceBuffer(buffer: any[]): any {\n var unreadData = buffer.slice(this.position);\n var endOfLinePosition = unreadData.indexOf('\\n');\n\n if (endOfLinePosition !== -1) {\n this.position += endOfLinePosition + 1;\n return unreadData.slice(0, endOfLinePosition);\n } else {\n // chunk is not finished yet, don't move the buffer pointer\n return null;\n }\n }\n\n private isBufferTooLong(buffer: any): boolean {\n return this.position === buffer.length && buffer.length > MAX_BUFFER_LENGTH;\n }\n}\n","enum State {\n CONNECTING = 0,\n OPEN = 1,\n CLOSED = 3\n}\n\nexport default State;\n","import URLLocation from './url_location';\nimport State from './state';\nimport Socket from '../socket';\nimport SocketHooks from './socket_hooks';\nimport Util from '../util';\nimport Ajax from './ajax';\nimport HTTPRequest from './http_request';\nimport Runtime from 'runtime';\n\nvar autoIncrement = 1;\n\nclass HTTPSocket implements Socket {\n hooks: SocketHooks;\n session: string;\n location: URLLocation;\n readyState: State;\n stream: HTTPRequest;\n\n onopen: () => void;\n onerror: (error: any) => void;\n onclose: (closeEvent: any) => void;\n onmessage: (message: any) => void;\n onactivity: () => void;\n\n constructor(hooks: SocketHooks, url: string) {\n this.hooks = hooks;\n this.session = randomNumber(1000) + '/' + randomString(8);\n this.location = getLocation(url);\n this.readyState = State.CONNECTING;\n this.openStream();\n }\n\n send(payload: any) {\n return this.sendRaw(JSON.stringify([payload]));\n }\n\n ping() {\n this.hooks.sendHeartbeat(this);\n }\n\n close(code: any, reason: any) {\n this.onClose(code, reason, true);\n }\n\n /** For internal use only */\n sendRaw(payload: any): boolean {\n if (this.readyState === State.OPEN) {\n try {\n Runtime.createSocketRequest(\n 'POST',\n getUniqueURL(getSendURL(this.location, this.session))\n ).start(payload);\n return true;\n } catch (e) {\n return false;\n }\n } else {\n return false;\n }\n }\n\n /** For internal use only */\n reconnect() {\n this.closeStream();\n this.openStream();\n }\n\n /** For internal use only */\n onClose(code, reason, wasClean) {\n this.closeStream();\n this.readyState = State.CLOSED;\n if (this.onclose) {\n this.onclose({\n code: code,\n reason: reason,\n wasClean: wasClean\n });\n }\n }\n\n private onChunk(chunk) {\n if (chunk.status !== 200) {\n return;\n }\n if (this.readyState === State.OPEN) {\n this.onActivity();\n }\n\n var payload;\n var type = chunk.data.slice(0, 1);\n switch (type) {\n case 'o':\n payload = JSON.parse(chunk.data.slice(1) || '{}');\n this.onOpen(payload);\n break;\n case 'a':\n payload = JSON.parse(chunk.data.slice(1) || '[]');\n for (var i = 0; i < payload.length; i++) {\n this.onEvent(payload[i]);\n }\n break;\n case 'm':\n payload = JSON.parse(chunk.data.slice(1) || 'null');\n this.onEvent(payload);\n break;\n case 'h':\n this.hooks.onHeartbeat(this);\n break;\n case 'c':\n payload = JSON.parse(chunk.data.slice(1) || '[]');\n this.onClose(payload[0], payload[1], true);\n break;\n }\n }\n\n private onOpen(options) {\n if (this.readyState === State.CONNECTING) {\n if (options && options.hostname) {\n this.location.base = replaceHost(this.location.base, options.hostname);\n }\n this.readyState = State.OPEN;\n\n if (this.onopen) {\n this.onopen();\n }\n } else {\n this.onClose(1006, 'Server lost session', true);\n }\n }\n\n private onEvent(event) {\n if (this.readyState === State.OPEN && this.onmessage) {\n this.onmessage({ data: event });\n }\n }\n\n private onActivity() {\n if (this.onactivity) {\n this.onactivity();\n }\n }\n\n private onError(error) {\n if (this.onerror) {\n this.onerror(error);\n }\n }\n\n private openStream() {\n this.stream = Runtime.createSocketRequest(\n 'POST',\n getUniqueURL(this.hooks.getReceiveURL(this.location, this.session))\n );\n\n this.stream.bind('chunk', chunk => {\n this.onChunk(chunk);\n });\n this.stream.bind('finished', status => {\n this.hooks.onFinished(this, status);\n });\n this.stream.bind('buffer_too_long', () => {\n this.reconnect();\n });\n\n try {\n this.stream.start();\n } catch (error) {\n Util.defer(() => {\n this.onError(error);\n this.onClose(1006, 'Could not start streaming', false);\n });\n }\n }\n\n private closeStream() {\n if (this.stream) {\n this.stream.unbind_all();\n this.stream.close();\n this.stream = null;\n }\n }\n}\n\nfunction getLocation(url): URLLocation {\n var parts = /([^\\?]*)\\/*(\\??.*)/.exec(url);\n return {\n base: parts[1],\n queryString: parts[2]\n };\n}\n\nfunction getSendURL(url: URLLocation, session: string): string {\n return url.base + '/' + session + '/xhr_send';\n}\n\nfunction getUniqueURL(url: string): string {\n var separator = url.indexOf('?') === -1 ? '?' : '&';\n return url + separator + 't=' + +new Date() + '&n=' + autoIncrement++;\n}\n\nfunction replaceHost(url: string, hostname: string): string {\n var urlParts = /(https?:\\/\\/)([^\\/:]+)((\\/|:)?.*)/.exec(url);\n return urlParts[1] + hostname + urlParts[3];\n}\n\nfunction randomNumber(max: number): number {\n return Runtime.randomInt(max);\n}\n\nfunction randomString(length: number): string {\n var result = [];\n\n for (var i = 0; i < length; i++) {\n result.push(randomNumber(32).toString(32));\n }\n\n return result.join('');\n}\n\nexport default HTTPSocket;\n","enum TimelineLevel {\n ERROR = 3,\n INFO = 6,\n DEBUG = 7\n}\n\nexport default TimelineLevel;\n","import SocketHooks from './socket_hooks';\nimport HTTPSocket from './http_socket';\n\nvar hooks: SocketHooks = {\n getReceiveURL: function(url, session) {\n return url.base + '/' + session + '/xhr_streaming' + url.queryString;\n },\n onHeartbeat: function(socket) {\n socket.sendRaw('[]');\n },\n sendHeartbeat: function(socket) {\n socket.sendRaw('[]');\n },\n onFinished: function(socket, status) {\n socket.onClose(1006, 'Connection interrupted (' + status + ')', false);\n }\n};\n\nexport default hooks;\n","import SocketHooks from './socket_hooks';\nimport URLLocation from './url_location';\nimport HTTPSocket from './http_socket';\n\nvar hooks: SocketHooks = {\n getReceiveURL: function(url: URLLocation, session: string): string {\n return url.base + '/' + session + '/xhr' + url.queryString;\n },\n onHeartbeat: function() {\n // next HTTP request will reset server's activity timer\n },\n sendHeartbeat: function(socket) {\n socket.sendRaw('[]');\n },\n onFinished: function(socket, status) {\n if (status === 200) {\n socket.reconnect();\n } else {\n socket.onClose(1006, 'Connection interrupted (' + status + ')', false);\n }\n }\n};\n\nexport default hooks;\n","import HTTPRequest from 'core/http/http_request';\nimport RequestHooks from 'core/http/request_hooks';\nimport Ajax from 'core/http/ajax';\nimport Runtime from 'runtime';\n\nvar hooks: RequestHooks = {\n getRequest: function(socket: HTTPRequest): Ajax {\n var Constructor = Runtime.getXHRAPI();\n var xhr = new Constructor();\n xhr.onreadystatechange = xhr.onprogress = function() {\n switch (xhr.readyState) {\n case 3:\n if (xhr.responseText && xhr.responseText.length > 0) {\n socket.onChunk(xhr.status, xhr.responseText);\n }\n break;\n case 4:\n // this happens only on errors, never after calling close\n if (xhr.responseText && xhr.responseText.length > 0) {\n socket.onChunk(xhr.status, xhr.responseText);\n }\n socket.emit('finished', xhr.status);\n socket.close();\n break;\n }\n };\n return xhr;\n },\n abortRequest: function(xhr: Ajax) {\n xhr.onreadystatechange = null;\n xhr.abort();\n }\n};\n\nexport default hooks;\n","import HTTPRequest from 'core/http/http_request';\nimport HTTPSocket from 'core/http/http_socket';\nimport SocketHooks from 'core/http/socket_hooks';\nimport RequestHooks from 'core/http/request_hooks';\nimport streamingHooks from 'core/http/http_streaming_socket';\nimport pollingHooks from 'core/http/http_polling_socket';\nimport xhrHooks from './http_xhr_request';\nimport HTTPFactory from 'core/http/http_factory';\n\nvar HTTP: HTTPFactory = {\n createStreamingSocket(url: string): HTTPSocket {\n return this.createSocket(streamingHooks, url);\n },\n\n createPollingSocket(url: string): HTTPSocket {\n return this.createSocket(pollingHooks, url);\n },\n\n createSocket(hooks: SocketHooks, url: string): HTTPSocket {\n return new HTTPSocket(hooks, url);\n },\n\n createXHR(method: string, url: string): HTTPRequest {\n return this.createRequest(xhrHooks, method, url);\n },\n\n createRequest(hooks: RequestHooks, method: string, url: string): HTTPRequest {\n return new HTTPRequest(hooks, method, url);\n }\n};\n\nexport default HTTP;\n","import xdrHooks from './http_xdomain_request';\nimport HTTP from 'isomorphic/http/http';\n\nHTTP.createXDR = function(method, url) {\n return this.createRequest(xdrHooks, method, url);\n};\n\nexport default HTTP;\n","import Browser from './browser';\nimport { Dependencies, DependenciesReceivers } from './dom/dependencies';\nimport { AuthTransport, AuthTransports } from 'core/auth/auth_transports';\nimport xhrAuth from 'isomorphic/auth/xhr_auth';\nimport jsonpAuth from './auth/jsonp_auth';\nimport TimelineTransport from 'core/timeline/timeline_transport';\nimport TimelineSender from 'core/timeline/timeline_sender';\nimport ScriptRequest from './dom/script_request';\nimport JSONPRequest from './dom/jsonp_request';\nimport * as Collections from 'core/utils/collections';\nimport { ScriptReceivers } from './dom/script_receiver_factory';\nimport jsonpTimeline from './timeline/jsonp_timeline';\nimport Transports from './transports/transports';\nimport Ajax from 'core/http/ajax';\nimport { Network } from './net_info';\nimport getDefaultStrategy from './default_strategy';\nimport transportConnectionInitializer from './transports/transport_connection_initializer';\nimport HTTPFactory from './http/http';\nimport HTTPRequest from 'core/http/http_request';\n\nvar Runtime: Browser = {\n // for jsonp auth\n nextAuthCallbackID: 1,\n auth_callbacks: {},\n ScriptReceivers,\n DependenciesReceivers,\n getDefaultStrategy,\n Transports,\n transportConnectionInitializer,\n HTTPFactory,\n\n TimelineTransport: jsonpTimeline,\n\n getXHRAPI() {\n return window.XMLHttpRequest;\n },\n\n getWebSocketAPI() {\n return window.WebSocket || window.MozWebSocket;\n },\n\n setup(PusherClass): void {\n (window).Pusher = PusherClass; // JSONp requires Pusher to be in the global scope.\n var initializeOnDocumentBody = () => {\n this.onDocumentBody(PusherClass.ready);\n };\n if (!(window).JSON) {\n Dependencies.load('json2', {}, initializeOnDocumentBody);\n } else {\n initializeOnDocumentBody();\n }\n },\n\n getDocument(): Document {\n return document;\n },\n\n getProtocol(): string {\n return this.getDocument().location.protocol;\n },\n\n getAuthorizers(): AuthTransports {\n return { ajax: xhrAuth, jsonp: jsonpAuth };\n },\n\n onDocumentBody(callback: Function) {\n if (document.body) {\n callback();\n } else {\n setTimeout(() => {\n this.onDocumentBody(callback);\n }, 0);\n }\n },\n\n createJSONPRequest(url: string, data: any): JSONPRequest {\n return new JSONPRequest(url, data);\n },\n\n createScriptRequest(src: string): ScriptRequest {\n return new ScriptRequest(src);\n },\n\n getLocalStorage() {\n try {\n return window.localStorage;\n } catch (e) {\n return undefined;\n }\n },\n\n createXHR(): Ajax {\n if (this.getXHRAPI()) {\n return this.createXMLHttpRequest();\n } else {\n return this.createMicrosoftXHR();\n }\n },\n\n createXMLHttpRequest(): Ajax {\n var Constructor = this.getXHRAPI();\n return new Constructor();\n },\n\n createMicrosoftXHR(): Ajax {\n return new ActiveXObject('Microsoft.XMLHTTP');\n },\n\n getNetwork() {\n return Network;\n },\n\n createWebSocket(url: string): any {\n var Constructor = this.getWebSocketAPI();\n return new Constructor(url);\n },\n\n createSocketRequest(method: string, url: string): HTTPRequest {\n if (this.isXHRSupported()) {\n return this.HTTPFactory.createXHR(method, url);\n } else if (this.isXDRSupported(url.indexOf('https:') === 0)) {\n return this.HTTPFactory.createXDR(method, url);\n } else {\n throw 'Cross-origin HTTP requests are not supported';\n }\n },\n\n isXHRSupported(): boolean {\n var Constructor = this.getXHRAPI();\n return (\n Boolean(Constructor) && new Constructor().withCredentials !== undefined\n );\n },\n\n isXDRSupported(useTLS?: boolean): boolean {\n var protocol = useTLS ? 'https:' : 'http:';\n var documentProtocol = this.getProtocol();\n return (\n Boolean(window['XDomainRequest']) && documentProtocol === protocol\n );\n },\n\n addUnloadListener(listener: any) {\n if (window.addEventListener !== undefined) {\n window.addEventListener('unload', listener, false);\n } else if (window.attachEvent !== undefined) {\n window.attachEvent('onunload', listener);\n }\n },\n\n removeUnloadListener(listener: any) {\n if (window.addEventListener !== undefined) {\n window.removeEventListener('unload', listener, false);\n } else if (window.detachEvent !== undefined) {\n window.detachEvent('onunload', listener);\n }\n },\n\n randomInt(max: number): number {\n /**\n * Return values in the range of [0, 1[\n */\n const random = function() {\n const crypto = window.crypto || window['msCrypto'];\n const random = crypto.getRandomValues(new Uint32Array(1))[0];\n\n return random / 2 ** 32;\n };\n\n return Math.floor(random() * max);\n }\n};\n\nexport default Runtime;\n","import { Dependencies } from '../dom/dependencies';\n\n/** Initializes the transport.\n *\n * Fetches resources if needed and then transitions to initialized.\n */\nexport default function() {\n var self = this;\n\n self.timeline.info(\n self.buildTimelineMessage({\n transport: self.name + (self.options.useTLS ? 's' : '')\n })\n );\n\n if (self.hooks.isInitialized()) {\n self.changeState('initialized');\n } else if (self.hooks.file) {\n self.changeState('initializing');\n Dependencies.load(\n self.hooks.file,\n { useTLS: self.options.useTLS },\n function(error, callback) {\n if (self.hooks.isInitialized()) {\n self.changeState('initialized');\n callback(true);\n } else {\n if (error) {\n self.onError(error);\n }\n self.onClose();\n callback(false);\n }\n }\n );\n } else {\n self.onClose();\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport { default as Level } from './level';\n\nexport interface TimelineOptions {\n level?: Level;\n limit?: number;\n version?: string;\n cluster?: string;\n features?: string[];\n params?: any;\n}\n\nexport default class Timeline {\n key: string;\n session: number;\n events: any[];\n options: TimelineOptions;\n sent: number;\n uniqueID: number;\n\n constructor(key: string, session: number, options: TimelineOptions) {\n this.key = key;\n this.session = session;\n this.events = [];\n this.options = options || {};\n this.sent = 0;\n this.uniqueID = 0;\n }\n\n log(level, event) {\n if (level <= this.options.level) {\n this.events.push(\n Collections.extend({}, event, { timestamp: Util.now() })\n );\n if (this.options.limit && this.events.length > this.options.limit) {\n this.events.shift();\n }\n }\n }\n\n error(event) {\n this.log(Level.ERROR, event);\n }\n\n info(event) {\n this.log(Level.INFO, event);\n }\n\n debug(event) {\n this.log(Level.DEBUG, event);\n }\n\n isEmpty() {\n return this.events.length === 0;\n }\n\n send(sendfn, callback) {\n var data = Collections.extend(\n {\n session: this.session,\n bundle: this.sent + 1,\n key: this.key,\n lib: 'js',\n version: this.options.version,\n cluster: this.options.cluster,\n features: this.options.features,\n timeline: this.events\n },\n this.options.params\n );\n\n this.events = [];\n sendfn(data, (error, result) => {\n if (!error) {\n this.sent++;\n }\n if (callback) {\n callback(error, result);\n }\n });\n\n return true;\n }\n\n generateUniqueID(): number {\n this.uniqueID++;\n return this.uniqueID;\n }\n}\n","import Factory from '../utils/factory';\nimport Util from '../util';\nimport * as Errors from '../errors';\nimport * as Collections from '../utils/collections';\nimport Strategy from './strategy';\nimport Transport from '../transports/transport';\nimport StrategyOptions from './strategy_options';\nimport Handshake from '../connection/handshake';\n\n/** Provides a strategy interface for transports.\n *\n * @param {String} name\n * @param {Number} priority\n * @param {Class} transport\n * @param {Object} options\n */\nexport default class TransportStrategy implements Strategy {\n name: string;\n priority: number;\n transport: Transport;\n options: StrategyOptions;\n\n constructor(\n name: string,\n priority: number,\n transport: Transport,\n options: StrategyOptions\n ) {\n this.name = name;\n this.priority = priority;\n this.transport = transport;\n this.options = options || {};\n }\n\n /** Returns whether the transport is supported in the browser.\n *\n * @returns {Boolean}\n */\n isSupported(): boolean {\n return this.transport.isSupported({\n useTLS: this.options.useTLS\n });\n }\n\n /** Launches a connection attempt and returns a strategy runner.\n *\n * @param {Function} callback\n * @return {Object} strategy runner\n */\n connect(minPriority: number, callback: Function) {\n if (!this.isSupported()) {\n return failAttempt(new Errors.UnsupportedStrategy(), callback);\n } else if (this.priority < minPriority) {\n return failAttempt(new Errors.TransportPriorityTooLow(), callback);\n }\n\n var connected = false;\n var transport = this.transport.createConnection(\n this.name,\n this.priority,\n this.options.key,\n this.options\n );\n var handshake = null;\n\n var onInitialized = function() {\n transport.unbind('initialized', onInitialized);\n transport.connect();\n };\n var onOpen = function() {\n handshake = Factory.createHandshake(transport, function(result) {\n connected = true;\n unbindListeners();\n callback(null, result);\n });\n };\n var onError = function(error) {\n unbindListeners();\n callback(error);\n };\n var onClosed = function() {\n unbindListeners();\n var serializedTransport;\n\n // The reason for this try/catch block is that on React Native\n // the WebSocket object is circular. Therefore transport.socket will\n // throw errors upon stringification. Collections.safeJSONStringify\n // discards circular references when serializing.\n serializedTransport = Collections.safeJSONStringify(transport);\n callback(new Errors.TransportClosed(serializedTransport));\n };\n\n var unbindListeners = function() {\n transport.unbind('initialized', onInitialized);\n transport.unbind('open', onOpen);\n transport.unbind('error', onError);\n transport.unbind('closed', onClosed);\n };\n\n transport.bind('initialized', onInitialized);\n transport.bind('open', onOpen);\n transport.bind('error', onError);\n transport.bind('closed', onClosed);\n\n // connect will be called automatically after initialization\n transport.initialize();\n\n return {\n abort: () => {\n if (connected) {\n return;\n }\n unbindListeners();\n if (handshake) {\n handshake.close();\n } else {\n transport.close();\n }\n },\n forceMinPriority: p => {\n if (connected) {\n return;\n }\n if (this.priority < p) {\n if (handshake) {\n handshake.close();\n } else {\n transport.close();\n }\n }\n }\n };\n }\n}\n\nfunction failAttempt(error: Error, callback: Function) {\n Util.defer(function() {\n callback(error);\n });\n return {\n abort: function() {},\n forceMinPriority: function() {}\n };\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport TransportManager from '../transports/transport_manager';\nimport * as Errors from '../errors';\nimport Strategy from './strategy';\nimport TransportStrategy from './transport_strategy';\nimport StrategyOptions from '../strategies/strategy_options';\nimport { Config } from '../config';\nimport Runtime from 'runtime';\n\nconst { Transports } = Runtime;\n\nexport var defineTransport = function(\n config: Config,\n name: string,\n type: string,\n priority: number,\n options: StrategyOptions,\n manager?: TransportManager\n): Strategy {\n var transportClass = Transports[type];\n if (!transportClass) {\n throw new Errors.UnsupportedTransport(type);\n }\n\n var enabled =\n (!config.enabledTransports ||\n Collections.arrayIndexOf(config.enabledTransports, name) !== -1) &&\n (!config.disabledTransports ||\n Collections.arrayIndexOf(config.disabledTransports, name) === -1);\n\n var transport;\n if (enabled) {\n options = Object.assign(\n { ignoreNullOrigin: config.ignoreNullOrigin },\n options\n );\n\n transport = new TransportStrategy(\n name,\n priority,\n manager ? manager.getAssistant(transportClass) : transportClass,\n options\n );\n } else {\n transport = UnsupportedStrategy;\n }\n\n return transport;\n};\n\nvar UnsupportedStrategy: Strategy = {\n isSupported: function() {\n return false;\n },\n connect: function(_, callback) {\n var deferred = Util.defer(function() {\n callback(new Errors.UnsupportedStrategy());\n });\n return {\n abort: function() {\n deferred.ensureAborted();\n },\n forceMinPriority: function() {}\n };\n }\n};\n","import ConnectionManager from './connection/connection_manager';\nimport {\n ChannelAuthorizationOptions,\n UserAuthenticationOptions\n} from './auth/options';\nimport {\n ChannelAuthorizerGenerator,\n DeprecatedAuthOptions\n} from './auth/deprecated_channel_authorizer';\nimport { AuthTransport, Transport } from './config';\nimport * as nacl from 'tweetnacl';\nimport Logger from './logger';\n\nexport interface Options {\n activityTimeout?: number;\n\n auth?: DeprecatedAuthOptions; // DEPRECATED use channelAuthorization instead\n authEndpoint?: string; // DEPRECATED use channelAuthorization instead\n authTransport?: AuthTransport; // DEPRECATED use channelAuthorization instead\n authorizer?: ChannelAuthorizerGenerator; // DEPRECATED use channelAuthorization instead\n\n channelAuthorization?: ChannelAuthorizationOptions;\n userAuthentication?: UserAuthenticationOptions;\n\n cluster: string;\n enableStats?: boolean;\n disableStats?: boolean;\n disabledTransports?: Transport[];\n enabledTransports?: Transport[];\n forceTLS?: boolean;\n httpHost?: string;\n httpPath?: string;\n httpPort?: number;\n httpsPort?: number;\n ignoreNullOrigin?: boolean;\n nacl?: nacl;\n pongTimeout?: number;\n statsHost?: string;\n timelineParams?: any;\n unavailableTimeout?: number;\n wsHost?: string;\n wsPath?: string;\n wsPort?: number;\n wssPort?: number;\n}\n\nexport interface ClusterOptions {\n appKey: string;\n cluster: string;\n}\n\nexport function validateOptions(options) {\n if (options == null) {\n throw 'You must pass an options object';\n }\n if (options.cluster == null) {\n throw 'Options object must provide a cluster';\n }\n if ('disableStats' in options) {\n Logger.warn(\n 'The disableStats option is deprecated in favor of enableStats'\n );\n }\n}\n","import {\n UserAuthenticationCallback,\n InternalAuthOptions,\n UserAuthenticationHandler,\n UserAuthenticationRequestParams,\n AuthRequestType\n} from './options';\n\nimport Runtime from 'runtime';\n\nconst composeChannelQuery = (\n params: UserAuthenticationRequestParams,\n authOptions: InternalAuthOptions\n) => {\n var query = 'socket_id=' + encodeURIComponent(params.socketId);\n\n for (var key in authOptions.params) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(authOptions.params[key]);\n }\n\n if (authOptions.paramsProvider != null) {\n let dynamicParams = authOptions.paramsProvider();\n for (var key in dynamicParams) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(dynamicParams[key]);\n }\n }\n\n return query;\n};\n\nconst UserAuthenticator = (\n authOptions: InternalAuthOptions\n): UserAuthenticationHandler => {\n if (typeof Runtime.getAuthorizers()[authOptions.transport] === 'undefined') {\n throw `'${authOptions.transport}' is not a recognized auth transport`;\n }\n\n return (\n params: UserAuthenticationRequestParams,\n callback: UserAuthenticationCallback\n ) => {\n const query = composeChannelQuery(params, authOptions);\n\n Runtime.getAuthorizers()[authOptions.transport](\n Runtime,\n query,\n authOptions,\n AuthRequestType.UserAuthentication,\n callback\n );\n };\n};\n\nexport default UserAuthenticator;\n","import {\n AuthRequestType,\n InternalAuthOptions,\n ChannelAuthorizationHandler,\n ChannelAuthorizationRequestParams,\n ChannelAuthorizationCallback\n} from './options';\n\nimport Runtime from 'runtime';\n\nconst composeChannelQuery = (\n params: ChannelAuthorizationRequestParams,\n authOptions: InternalAuthOptions\n) => {\n var query = 'socket_id=' + encodeURIComponent(params.socketId);\n\n query += '&channel_name=' + encodeURIComponent(params.channelName);\n\n for (var key in authOptions.params) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(authOptions.params[key]);\n }\n\n if (authOptions.paramsProvider != null) {\n let dynamicParams = authOptions.paramsProvider();\n for (var key in dynamicParams) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(dynamicParams[key]);\n }\n }\n\n return query;\n};\n\nconst ChannelAuthorizer = (\n authOptions: InternalAuthOptions\n): ChannelAuthorizationHandler => {\n if (typeof Runtime.getAuthorizers()[authOptions.transport] === 'undefined') {\n throw `'${authOptions.transport}' is not a recognized auth transport`;\n }\n\n return (\n params: ChannelAuthorizationRequestParams,\n callback: ChannelAuthorizationCallback\n ) => {\n const query = composeChannelQuery(params, authOptions);\n\n Runtime.getAuthorizers()[authOptions.transport](\n Runtime,\n query,\n authOptions,\n AuthRequestType.ChannelAuthorization,\n callback\n );\n };\n};\n\nexport default ChannelAuthorizer;\n","import { Options } from './options';\nimport Defaults from './defaults';\nimport {\n ChannelAuthorizationHandler,\n UserAuthenticationHandler,\n ChannelAuthorizationOptions\n} from './auth/options';\nimport UserAuthenticator from './auth/user_authenticator';\nimport ChannelAuthorizer from './auth/channel_authorizer';\nimport { ChannelAuthorizerProxy } from './auth/deprecated_channel_authorizer';\nimport Runtime from 'runtime';\nimport * as nacl from 'tweetnacl';\n\nexport type AuthTransport = 'ajax' | 'jsonp';\nexport type Transport =\n | 'ws'\n | 'wss'\n | 'xhr_streaming'\n | 'xhr_polling'\n | 'sockjs';\n\nexport interface Config {\n // these are all 'required' config parameters, it's not necessary for the user\n // to set them, but they have configured defaults.\n activityTimeout: number;\n enableStats: boolean;\n httpHost: string;\n httpPath: string;\n httpPort: number;\n httpsPort: number;\n pongTimeout: number;\n statsHost: string;\n unavailableTimeout: number;\n useTLS: boolean;\n wsHost: string;\n wsPath: string;\n wsPort: number;\n wssPort: number;\n userAuthenticator: UserAuthenticationHandler;\n channelAuthorizer: ChannelAuthorizationHandler;\n\n // these are all optional parameters or overrrides. The customer can set these\n // but it's not strictly necessary\n forceTLS?: boolean;\n cluster?: string;\n disabledTransports?: Transport[];\n enabledTransports?: Transport[];\n ignoreNullOrigin?: boolean;\n nacl?: nacl;\n timelineParams?: any;\n}\n\n// getConfig mainly sets the defaults for the options that are not provided\nexport function getConfig(opts: Options, pusher): Config {\n let config: Config = {\n activityTimeout: opts.activityTimeout || Defaults.activityTimeout,\n cluster: opts.cluster,\n httpPath: opts.httpPath || Defaults.httpPath,\n httpPort: opts.httpPort || Defaults.httpPort,\n httpsPort: opts.httpsPort || Defaults.httpsPort,\n pongTimeout: opts.pongTimeout || Defaults.pongTimeout,\n statsHost: opts.statsHost || Defaults.stats_host,\n unavailableTimeout: opts.unavailableTimeout || Defaults.unavailableTimeout,\n wsPath: opts.wsPath || Defaults.wsPath,\n wsPort: opts.wsPort || Defaults.wsPort,\n wssPort: opts.wssPort || Defaults.wssPort,\n\n enableStats: getEnableStatsConfig(opts),\n httpHost: getHttpHost(opts),\n useTLS: shouldUseTLS(opts),\n wsHost: getWebsocketHost(opts),\n\n userAuthenticator: buildUserAuthenticator(opts),\n channelAuthorizer: buildChannelAuthorizer(opts, pusher)\n };\n\n if ('disabledTransports' in opts)\n config.disabledTransports = opts.disabledTransports;\n if ('enabledTransports' in opts)\n config.enabledTransports = opts.enabledTransports;\n if ('ignoreNullOrigin' in opts)\n config.ignoreNullOrigin = opts.ignoreNullOrigin;\n if ('timelineParams' in opts) config.timelineParams = opts.timelineParams;\n if ('nacl' in opts) {\n config.nacl = opts.nacl;\n }\n\n return config;\n}\n\nfunction getHttpHost(opts: Options): string {\n if (opts.httpHost) {\n return opts.httpHost;\n }\n if (opts.cluster) {\n return `sockjs-${opts.cluster}.pusher.com`;\n }\n return Defaults.httpHost;\n}\n\nfunction getWebsocketHost(opts: Options): string {\n if (opts.wsHost) {\n return opts.wsHost;\n }\n return getWebsocketHostFromCluster(opts.cluster);\n}\n\nfunction getWebsocketHostFromCluster(cluster: string): string {\n return `ws-${cluster}.pusher.com`;\n}\n\nfunction shouldUseTLS(opts: Options): boolean {\n if (Runtime.getProtocol() === 'https:') {\n return true;\n } else if (opts.forceTLS === false) {\n return false;\n }\n return true;\n}\n\n// if enableStats is set take the value\n// if disableStats is set take the inverse\n// otherwise default to false\nfunction getEnableStatsConfig(opts: Options): boolean {\n if ('enableStats' in opts) {\n return opts.enableStats;\n }\n if ('disableStats' in opts) {\n return !opts.disableStats;\n }\n return false;\n}\n\nfunction buildUserAuthenticator(opts: Options): UserAuthenticationHandler {\n const userAuthentication = {\n ...Defaults.userAuthentication,\n ...opts.userAuthentication\n };\n if (\n 'customHandler' in userAuthentication &&\n userAuthentication['customHandler'] != null\n ) {\n return userAuthentication['customHandler'];\n }\n\n return UserAuthenticator(userAuthentication);\n}\n\nfunction buildChannelAuth(opts: Options, pusher): ChannelAuthorizationOptions {\n let channelAuthorization: ChannelAuthorizationOptions;\n if ('channelAuthorization' in opts) {\n channelAuthorization = {\n ...Defaults.channelAuthorization,\n ...opts.channelAuthorization\n };\n } else {\n channelAuthorization = {\n transport: opts.authTransport || Defaults.authTransport,\n endpoint: opts.authEndpoint || Defaults.authEndpoint\n };\n if ('auth' in opts) {\n if ('params' in opts.auth) channelAuthorization.params = opts.auth.params;\n if ('headers' in opts.auth)\n channelAuthorization.headers = opts.auth.headers;\n }\n if ('authorizer' in opts)\n channelAuthorization.customHandler = ChannelAuthorizerProxy(\n pusher,\n channelAuthorization,\n opts.authorizer\n );\n }\n return channelAuthorization;\n}\n\nfunction buildChannelAuthorizer(\n opts: Options,\n pusher\n): ChannelAuthorizationHandler {\n const channelAuthorization = buildChannelAuth(opts, pusher);\n if (\n 'customHandler' in channelAuthorization &&\n channelAuthorization['customHandler'] != null\n ) {\n return channelAuthorization['customHandler'];\n }\n\n return ChannelAuthorizer(channelAuthorization);\n}\n","import Channel from '../channels/channel';\nimport {\n ChannelAuthorizationCallback,\n ChannelAuthorizationHandler,\n ChannelAuthorizationRequestParams,\n InternalAuthOptions\n} from './options';\n\nexport interface DeprecatedChannelAuthorizer {\n authorize(socketId: string, callback: ChannelAuthorizationCallback): void;\n}\n\nexport interface ChannelAuthorizerGenerator {\n (\n channel: Channel,\n options: DeprecatedAuthorizerOptions\n ): DeprecatedChannelAuthorizer;\n}\n\nexport interface DeprecatedAuthOptions {\n params?: any;\n headers?: any;\n}\n\nexport interface DeprecatedAuthorizerOptions {\n authTransport: 'ajax' | 'jsonp';\n authEndpoint: string;\n auth?: DeprecatedAuthOptions;\n}\n\nexport const ChannelAuthorizerProxy = (\n pusher,\n authOptions: InternalAuthOptions,\n channelAuthorizerGenerator: ChannelAuthorizerGenerator\n): ChannelAuthorizationHandler => {\n const deprecatedAuthorizerOptions: DeprecatedAuthorizerOptions = {\n authTransport: authOptions.transport,\n authEndpoint: authOptions.endpoint,\n auth: {\n params: authOptions.params,\n headers: authOptions.headers\n }\n };\n return (\n params: ChannelAuthorizationRequestParams,\n callback: ChannelAuthorizationCallback\n ) => {\n const channel = pusher.channel(params.channelName);\n // This line creates a new channel authorizer every time.\n // In the past, this was only done once per channel and reused.\n // We can do that again if we want to keep this behavior intact.\n const channelAuthorizer: DeprecatedChannelAuthorizer = channelAuthorizerGenerator(\n channel,\n deprecatedAuthorizerOptions\n );\n channelAuthorizer.authorize(params.socketId, callback);\n };\n};\n","import Logger from './logger';\nimport Pusher from './pusher';\nimport EventsDispatcher from './events/dispatcher';\n\nexport default class WatchlistFacade extends EventsDispatcher {\n private pusher: Pusher;\n\n public constructor(pusher: Pusher) {\n super(function(eventName, data) {\n Logger.debug(`No callbacks on watchlist events for ${eventName}`);\n });\n\n this.pusher = pusher;\n this.bindWatchlistInternalEvent();\n }\n\n handleEvent(pusherEvent) {\n pusherEvent.data.events.forEach(watchlistEvent => {\n this.emit(watchlistEvent.name, watchlistEvent);\n });\n }\n\n private bindWatchlistInternalEvent() {\n this.pusher.connection.bind('message', pusherEvent => {\n var eventName = pusherEvent.event;\n if (eventName === 'pusher_internal:watchlist_events') {\n this.handleEvent(pusherEvent);\n }\n });\n }\n}\n","function flatPromise() {\n let resolve, reject;\n const promise = new Promise((res, rej) => {\n resolve = res;\n reject = rej;\n });\n return { promise, resolve, reject };\n}\n\nexport default flatPromise;\n","import Pusher from './pusher';\nimport Logger from './logger';\nimport {\n UserAuthenticationData,\n UserAuthenticationCallback\n} from './auth/options';\nimport Channel from './channels/channel';\nimport WatchlistFacade from './watchlist';\nimport EventsDispatcher from './events/dispatcher';\nimport flatPromise from './utils/flat_promise';\n\nexport default class UserFacade extends EventsDispatcher {\n pusher: Pusher;\n signin_requested: boolean = false;\n user_data: any = null;\n serverToUserChannel: Channel = null;\n signinDonePromise: Promise = null;\n watchlist: WatchlistFacade;\n private _signinDoneResolve: Function = null;\n\n public constructor(pusher: Pusher) {\n super(function(eventName, data) {\n Logger.debug('No callbacks on user for ' + eventName);\n });\n this.pusher = pusher;\n this.pusher.connection.bind('state_change', ({ previous, current }) => {\n if (previous !== 'connected' && current === 'connected') {\n this._signin();\n }\n if (previous === 'connected' && current !== 'connected') {\n this._cleanup();\n this._newSigninPromiseIfNeeded();\n }\n });\n\n this.watchlist = new WatchlistFacade(pusher);\n\n this.pusher.connection.bind('message', event => {\n var eventName = event.event;\n if (eventName === 'pusher:signin_success') {\n this._onSigninSuccess(event.data);\n }\n if (\n this.serverToUserChannel &&\n this.serverToUserChannel.name === event.channel\n ) {\n this.serverToUserChannel.handleEvent(event);\n }\n });\n }\n\n public signin() {\n if (this.signin_requested) {\n return;\n }\n\n this.signin_requested = true;\n this._signin();\n }\n\n private _signin() {\n if (!this.signin_requested) {\n return;\n }\n\n this._newSigninPromiseIfNeeded();\n\n if (this.pusher.connection.state !== 'connected') {\n // Signin will be attempted when the connection is connected\n return;\n }\n\n this.pusher.config.userAuthenticator(\n {\n socketId: this.pusher.connection.socket_id\n },\n this._onAuthorize\n );\n }\n\n private _onAuthorize: UserAuthenticationCallback = (\n err,\n authData: UserAuthenticationData\n ) => {\n if (err) {\n Logger.warn(`Error during signin: ${err}`);\n this._cleanup();\n return;\n }\n\n this.pusher.send_event('pusher:signin', {\n auth: authData.auth,\n user_data: authData.user_data\n });\n\n // Later when we get pusher:singin_success event, the user will be marked as signed in\n };\n\n private _onSigninSuccess(data: any) {\n try {\n this.user_data = JSON.parse(data.user_data);\n } catch (e) {\n Logger.error(`Failed parsing user data after signin: ${data.user_data}`);\n this._cleanup();\n return;\n }\n\n if (typeof this.user_data.id !== 'string' || this.user_data.id === '') {\n Logger.error(\n `user_data doesn't contain an id. user_data: ${this.user_data}`\n );\n this._cleanup();\n return;\n }\n\n // Signin succeeded\n this._signinDoneResolve();\n this._subscribeChannels();\n }\n\n private _subscribeChannels() {\n const ensure_subscribed = channel => {\n if (channel.subscriptionPending && channel.subscriptionCancelled) {\n channel.reinstateSubscription();\n } else if (\n !channel.subscriptionPending &&\n this.pusher.connection.state === 'connected'\n ) {\n channel.subscribe();\n }\n };\n\n this.serverToUserChannel = new Channel(\n `#server-to-user-${this.user_data.id}`,\n this.pusher\n );\n this.serverToUserChannel.bind_global((eventName, data) => {\n if (\n eventName.indexOf('pusher_internal:') === 0 ||\n eventName.indexOf('pusher:') === 0\n ) {\n // ignore internal events\n return;\n }\n this.emit(eventName, data);\n });\n ensure_subscribed(this.serverToUserChannel);\n }\n\n private _cleanup() {\n this.user_data = null;\n if (this.serverToUserChannel) {\n this.serverToUserChannel.unbind_all();\n this.serverToUserChannel.disconnect();\n this.serverToUserChannel = null;\n }\n\n if (this.signin_requested) {\n // If signin is in progress and cleanup is called,\n // Mark the current signin process as done.\n this._signinDoneResolve();\n }\n }\n\n private _newSigninPromiseIfNeeded() {\n if (!this.signin_requested) {\n return;\n }\n\n // If there is a promise and it is not resolved, return without creating a new one.\n if (this.signinDonePromise && !(this.signinDonePromise as any).done) {\n return;\n }\n\n // This promise is never rejected.\n // It gets resolved when the signin process is done whether it failed or succeeded\n const { promise, resolve, reject: _ } = flatPromise();\n (promise as any).done = false;\n const setDone = () => {\n (promise as any).done = true;\n };\n promise.then(setDone).catch(setDone);\n this.signinDonePromise = promise;\n this._signinDoneResolve = resolve;\n }\n}\n","import AbstractRuntime from '../runtimes/interface';\nimport Runtime from 'runtime';\nimport * as Collections from './utils/collections';\nimport Channels from './channels/channels';\nimport Channel from './channels/channel';\nimport { default as EventsDispatcher } from './events/dispatcher';\nimport Timeline from './timeline/timeline';\nimport TimelineSender from './timeline/timeline_sender';\nimport TimelineLevel from './timeline/level';\nimport { defineTransport } from './strategies/strategy_builder';\nimport ConnectionManager from './connection/connection_manager';\nimport { PeriodicTimer } from './utils/timers';\nimport Defaults from './defaults';\nimport Logger from './logger';\nimport Factory from './utils/factory';\nimport { Options, ClusterOptions, validateOptions } from './options';\nimport { Config, getConfig } from './config';\nimport StrategyOptions from './strategies/strategy_options';\nimport UserFacade from './user';\n\nexport default class Pusher {\n /* STATIC PROPERTIES */\n static instances: Pusher[] = [];\n static isReady: boolean = false;\n static logToConsole: boolean = false;\n\n // for jsonp\n static Runtime: AbstractRuntime = Runtime;\n static ScriptReceivers: any = (Runtime).ScriptReceivers;\n static DependenciesReceivers: any = (Runtime).DependenciesReceivers;\n static auth_callbacks: any = (Runtime).auth_callbacks;\n\n static ready() {\n Pusher.isReady = true;\n for (var i = 0, l = Pusher.instances.length; i < l; i++) {\n Pusher.instances[i].connect();\n }\n }\n\n static log: (message: any) => void;\n\n private static getClientFeatures(): string[] {\n return Collections.keys(\n Collections.filterObject({ ws: Runtime.Transports.ws }, function(t) {\n return t.isSupported({});\n })\n );\n }\n\n /* INSTANCE PROPERTIES */\n key: string;\n options: Options;\n config: Config;\n channels: Channels;\n global_emitter: EventsDispatcher;\n sessionID: number;\n timeline: Timeline;\n timelineSender: TimelineSender;\n connection: ConnectionManager;\n timelineSenderTimer: PeriodicTimer;\n user: UserFacade;\n constructor(app_key: string, options: Options) {\n checkAppKey(app_key);\n validateOptions(options);\n this.key = app_key;\n this.config = getConfig(options, this);\n\n this.channels = Factory.createChannels();\n this.global_emitter = new EventsDispatcher();\n this.sessionID = Runtime.randomInt(1000000000);\n\n this.timeline = new Timeline(this.key, this.sessionID, {\n cluster: this.config.cluster,\n features: Pusher.getClientFeatures(),\n params: this.config.timelineParams || {},\n limit: 50,\n level: TimelineLevel.INFO,\n version: Defaults.VERSION\n });\n if (this.config.enableStats) {\n this.timelineSender = Factory.createTimelineSender(this.timeline, {\n host: this.config.statsHost,\n path: '/timeline/v2/' + Runtime.TimelineTransport.name\n });\n }\n\n var getStrategy = (options: StrategyOptions) => {\n return Runtime.getDefaultStrategy(this.config, options, defineTransport);\n };\n\n this.connection = Factory.createConnectionManager(this.key, {\n getStrategy: getStrategy,\n timeline: this.timeline,\n activityTimeout: this.config.activityTimeout,\n pongTimeout: this.config.pongTimeout,\n unavailableTimeout: this.config.unavailableTimeout,\n useTLS: Boolean(this.config.useTLS)\n });\n\n this.connection.bind('connected', () => {\n this.subscribeAll();\n if (this.timelineSender) {\n this.timelineSender.send(this.connection.isUsingTLS());\n }\n });\n\n this.connection.bind('message', event => {\n var eventName = event.event;\n var internal = eventName.indexOf('pusher_internal:') === 0;\n if (event.channel) {\n var channel = this.channel(event.channel);\n if (channel) {\n channel.handleEvent(event);\n }\n }\n // Emit globally [deprecated]\n if (!internal) {\n this.global_emitter.emit(event.event, event.data);\n }\n });\n this.connection.bind('connecting', () => {\n this.channels.disconnect();\n });\n this.connection.bind('disconnected', () => {\n this.channels.disconnect();\n });\n this.connection.bind('error', err => {\n Logger.warn(err);\n });\n\n Pusher.instances.push(this);\n this.timeline.info({ instances: Pusher.instances.length });\n\n this.user = new UserFacade(this);\n\n if (Pusher.isReady) {\n this.connect();\n }\n }\n\n /**\n * Allows you to switch Pusher cluster without\n * losing all the channels/subscription binding\n * as this is internally managed by the SDK.\n */\n switchCluster(options: ClusterOptions) {\n const { appKey, cluster } = options;\n this.key = appKey;\n this.options = { ...this.options, cluster };\n this.config = getConfig(this.options, this);\n this.connection.switchCluster(this.key);\n }\n\n channel(name: string): Channel {\n return this.channels.find(name);\n }\n\n allChannels(): Channel[] {\n return this.channels.all();\n }\n\n connect() {\n this.connection.connect();\n\n if (this.timelineSender) {\n if (!this.timelineSenderTimer) {\n var usingTLS = this.connection.isUsingTLS();\n var timelineSender = this.timelineSender;\n this.timelineSenderTimer = new PeriodicTimer(60000, function() {\n timelineSender.send(usingTLS);\n });\n }\n }\n }\n\n disconnect() {\n this.connection.disconnect();\n\n if (this.timelineSenderTimer) {\n this.timelineSenderTimer.ensureAborted();\n this.timelineSenderTimer = null;\n }\n }\n\n bind(event_name: string, callback: Function, context?: any): Pusher {\n this.global_emitter.bind(event_name, callback, context);\n return this;\n }\n\n unbind(event_name?: string, callback?: Function, context?: any): Pusher {\n this.global_emitter.unbind(event_name, callback, context);\n return this;\n }\n\n bind_global(callback: Function): Pusher {\n this.global_emitter.bind_global(callback);\n return this;\n }\n\n unbind_global(callback?: Function): Pusher {\n this.global_emitter.unbind_global(callback);\n return this;\n }\n\n unbind_all(callback?: Function): Pusher {\n this.global_emitter.unbind_all();\n return this;\n }\n\n subscribeAll() {\n var channelName;\n for (channelName in this.channels.channels) {\n if (this.channels.channels.hasOwnProperty(channelName)) {\n this.subscribe(channelName);\n }\n }\n }\n\n subscribe(channel_name: string) {\n var channel = this.channels.add(channel_name, this);\n if (channel.subscriptionPending && channel.subscriptionCancelled) {\n channel.reinstateSubscription();\n } else if (\n !channel.subscriptionPending &&\n this.connection.state === 'connected'\n ) {\n channel.subscribe();\n }\n return channel;\n }\n\n unsubscribe(channel_name: string) {\n var channel = this.channels.find(channel_name);\n if (channel && channel.subscriptionPending) {\n channel.cancelSubscription();\n } else {\n channel = this.channels.remove(channel_name);\n if (channel && channel.subscribed) {\n channel.unsubscribe();\n }\n }\n }\n\n send_event(event_name: string, data: any, channel?: string) {\n return this.connection.send_event(event_name, data, channel);\n }\n\n shouldUseTLS(): boolean {\n return this.config.useTLS;\n }\n\n signin() {\n this.user.signin();\n }\n}\n\nfunction checkAppKey(key) {\n if (key === null || key === undefined) {\n throw 'You must pass your app key when you instantiate Pusher.';\n }\n}\n\nRuntime.setup(Pusher);\n","import Pusher from './pusher';\nimport { Options, validateOptions } from './options';\nimport * as nacl from 'tweetnacl';\n\nexport default class PusherWithEncryption extends Pusher {\n constructor(app_key: string, options: Options) {\n Pusher.logToConsole = PusherWithEncryption.logToConsole;\n Pusher.log = PusherWithEncryption.log;\n\n validateOptions(options);\n options.nacl = nacl;\n super(app_key, options);\n }\n}\n"],"sourceRoot":""} \ No newline at end of file diff --git a/dist/web/pusher.js b/dist/web/pusher.js index 8a7fed47a..71278d861 100644 --- a/dist/web/pusher.js +++ b/dist/web/pusher.js @@ -1,5 +1,5 @@ /*! - * Pusher JavaScript Library v8.4.0 + * Pusher JavaScript Library v8.4.0-rc1 * https://pusher.com/ * * Copyright 2020, Pusher @@ -591,7 +591,7 @@ var ScriptReceivers = new ScriptReceiverFactory('_pusher_script_', 'Pusher.Scrip // CONCATENATED MODULE: ./src/core/defaults.ts var Defaults = { - VERSION: "8.4.0", + VERSION: "8.4.0-rc1", PROTOCOL: 7, wsPort: 80, wssPort: 443, diff --git a/dist/web/pusher.js.map b/dist/web/pusher.js.map index 1ec92ad7e..008bb9506 100644 --- a/dist/web/pusher.js.map +++ b/dist/web/pusher.js.map @@ -1 +1 @@ -{"version":3,"sources":["webpack://Pusher/webpack/universalModuleDefinition","webpack://Pusher/webpack/bootstrap","webpack://Pusher/./node_modules/@stablelib/base64/base64.ts","webpack://Pusher/./node_modules/@stablelib/utf8/utf8.ts","webpack://Pusher/./src/core/pusher.js","webpack://Pusher/./src/runtimes/web/dom/script_receiver_factory.ts","webpack://Pusher/./src/core/defaults.ts","webpack://Pusher/./src/runtimes/web/dom/dependency_loader.ts","webpack://Pusher/./src/runtimes/web/dom/dependencies.ts","webpack://Pusher/./src/core/utils/url_store.ts","webpack://Pusher/./src/core/auth/options.ts","webpack://Pusher/./src/core/errors.ts","webpack://Pusher/./src/runtimes/isomorphic/auth/xhr_auth.ts","webpack://Pusher/./src/core/base64.ts","webpack://Pusher/./src/core/utils/timers/abstract_timer.ts","webpack://Pusher/./src/core/utils/timers/index.ts","webpack://Pusher/./src/core/util.ts","webpack://Pusher/./src/core/utils/collections.ts","webpack://Pusher/./src/core/logger.ts","webpack://Pusher/./src/runtimes/web/auth/jsonp_auth.ts","webpack://Pusher/./src/runtimes/web/dom/script_request.ts","webpack://Pusher/./src/runtimes/web/dom/jsonp_request.ts","webpack://Pusher/./src/runtimes/web/timeline/jsonp_timeline.ts","webpack://Pusher/./src/core/transports/url_schemes.ts","webpack://Pusher/./src/core/events/callback_registry.ts","webpack://Pusher/./src/core/events/dispatcher.ts","webpack://Pusher/./src/core/transports/transport_connection.ts","webpack://Pusher/./src/core/transports/transport.ts","webpack://Pusher/./src/runtimes/isomorphic/transports/transports.ts","webpack://Pusher/./src/runtimes/web/transports/transports.ts","webpack://Pusher/./src/runtimes/web/net_info.ts","webpack://Pusher/./src/core/transports/assistant_to_the_transport_manager.ts","webpack://Pusher/./src/core/connection/protocol/protocol.ts","webpack://Pusher/./src/core/connection/connection.ts","webpack://Pusher/./src/core/connection/handshake/index.ts","webpack://Pusher/./src/core/timeline/timeline_sender.ts","webpack://Pusher/./src/core/channels/channel.ts","webpack://Pusher/./src/core/channels/private_channel.ts","webpack://Pusher/./src/core/channels/members.ts","webpack://Pusher/./src/core/channels/presence_channel.ts","webpack://Pusher/./src/core/channels/encrypted_channel.ts","webpack://Pusher/./src/core/connection/connection_manager.ts","webpack://Pusher/./src/core/channels/channels.ts","webpack://Pusher/./src/core/utils/factory.ts","webpack://Pusher/./src/core/transports/transport_manager.ts","webpack://Pusher/./src/core/strategies/sequential_strategy.ts","webpack://Pusher/./src/core/strategies/best_connected_ever_strategy.ts","webpack://Pusher/./src/core/strategies/websocket_prioritized_cached_strategy.ts","webpack://Pusher/./src/core/strategies/delayed_strategy.ts","webpack://Pusher/./src/core/strategies/if_strategy.ts","webpack://Pusher/./src/core/strategies/first_connected_strategy.ts","webpack://Pusher/./src/runtimes/web/default_strategy.ts","webpack://Pusher/./src/runtimes/web/transports/transport_connection_initializer.ts","webpack://Pusher/./src/runtimes/web/http/http_xdomain_request.ts","webpack://Pusher/./src/core/http/http_request.ts","webpack://Pusher/./src/core/http/state.ts","webpack://Pusher/./src/core/http/http_socket.ts","webpack://Pusher/./src/core/http/http_streaming_socket.ts","webpack://Pusher/./src/core/http/http_polling_socket.ts","webpack://Pusher/./src/runtimes/isomorphic/http/http_xhr_request.ts","webpack://Pusher/./src/runtimes/isomorphic/http/http.ts","webpack://Pusher/./src/runtimes/web/http/http.ts","webpack://Pusher/./src/runtimes/web/runtime.ts","webpack://Pusher/./src/core/timeline/level.ts","webpack://Pusher/./src/core/timeline/timeline.ts","webpack://Pusher/./src/core/strategies/transport_strategy.ts","webpack://Pusher/./src/core/strategies/strategy_builder.ts","webpack://Pusher/./src/core/options.ts","webpack://Pusher/./src/core/auth/user_authenticator.ts","webpack://Pusher/./src/core/auth/channel_authorizer.ts","webpack://Pusher/./src/core/auth/deprecated_channel_authorizer.ts","webpack://Pusher/./src/core/config.ts","webpack://Pusher/./src/core/watchlist.ts","webpack://Pusher/./src/core/utils/flat_promise.ts","webpack://Pusher/./src/core/user.ts","webpack://Pusher/./src/core/pusher.ts"],"names":[],"mappings":";;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AACD,O;QCVA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;;QAEA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;;;QAGA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;QACA,0CAA0C,gCAAgC;QAC1E;QACA;;QAEA;QACA;QACA;QACA,wDAAwD,kBAAkB;QAC1E;QACA,iDAAiD,cAAc;QAC/D;;QAEA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA,yCAAyC,iCAAiC;QAC1E,gHAAgH,mBAAmB,EAAE;QACrI;QACA;;QAEA;QACA;QACA;QAC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AAI,OAAO,IAAI,OAAO,CAAC,mBAAmB,EAAE;YAC1C,OAAO,CAAC,kBAAkB,EAAE,CAAC;SAC9B;aAAM;YACL,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;YAC7C,IAAI,OAAO,IAAI,OAAO,CAAC,UAAU,EAAE;gBACjC,OAAO,CAAC,WAAW,EAAE,CAAC;aACvB;SACF;IACH,CAAC;IAED,UAAU,CAAC,UAAkB,EAAE,IAAS,EAAE,OAAgB;QACxD,OAAO,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC,UAAU,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;IAC/D,CAAC;IAED,YAAY;QACV,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC;IAC5B,CAAC;IAED,MAAM;QACJ,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;IACrB,CAAC;;AAvOM,uBAAS,GAAa,EAAE,CAAC;AACzB,qBAAO,GAAY,KAAK,CAAC;AACzB,0BAAY,GAAY,KAAK,CAAC;AAG9B,qBAAO,GAAoB,OAAO,CAAC;AACnC,6BAAe,GAAc,OAAQ,CAAC,eAAe,CAAC;AACtD,mCAAqB,GAAc,OAAQ,CAAC,qBAAqB,CAAC;AAClE,4BAAc,GAAc,OAAQ,CAAC,cAAc,CAAC;AAVxC,8FAAM;AA4O3B,SAAS,WAAW,CAAC,GAAG;IACtB,IAAI,GAAG,KAAK,IAAI,IAAI,GAAG,KAAK,SAAS,EAAE;QACrC,MAAM,yDAAyD,CAAC;KACjE;AACH,CAAC;AAED,OAAO,CAAC,KAAK,CAAC,aAAM,CAAC,CAAC","file":"pusher.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"Pusher\"] = factory();\n\telse\n\t\troot[\"Pusher\"] = factory();\n})(window, function() {\nreturn "," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 2);\n","// Copyright (C) 2016 Dmitry Chestnykh\n// MIT License. See LICENSE file for details.\n\n/**\n * Package base64 implements Base64 encoding and decoding.\n */\n\n// Invalid character used in decoding to indicate\n// that the character to decode is out of range of\n// alphabet and cannot be decoded.\nconst INVALID_BYTE = 256;\n\n/**\n * Implements standard Base64 encoding.\n *\n * Operates in constant time.\n */\nexport class Coder {\n // TODO(dchest): methods to encode chunk-by-chunk.\n\n constructor(private _paddingCharacter = \"=\") { }\n\n encodedLength(length: number): number {\n if (!this._paddingCharacter) {\n return (length * 8 + 5) / 6 | 0;\n }\n return (length + 2) / 3 * 4 | 0;\n }\n\n encode(data: Uint8Array): string {\n let out = \"\";\n\n let i = 0;\n for (; i < data.length - 2; i += 3) {\n let c = (data[i] << 16) | (data[i + 1] << 8) | (data[i + 2]);\n out += this._encodeByte((c >>> 3 * 6) & 63);\n out += this._encodeByte((c >>> 2 * 6) & 63);\n out += this._encodeByte((c >>> 1 * 6) & 63);\n out += this._encodeByte((c >>> 0 * 6) & 63);\n }\n\n const left = data.length - i;\n if (left > 0) {\n let c = (data[i] << 16) | (left === 2 ? data[i + 1] << 8 : 0);\n out += this._encodeByte((c >>> 3 * 6) & 63);\n out += this._encodeByte((c >>> 2 * 6) & 63);\n if (left === 2) {\n out += this._encodeByte((c >>> 1 * 6) & 63);\n } else {\n out += this._paddingCharacter || \"\";\n }\n out += this._paddingCharacter || \"\";\n }\n\n return out;\n }\n\n maxDecodedLength(length: number): number {\n if (!this._paddingCharacter) {\n return (length * 6 + 7) / 8 | 0;\n }\n return length / 4 * 3 | 0;\n }\n\n decodedLength(s: string): number {\n return this.maxDecodedLength(s.length - this._getPaddingLength(s));\n }\n\n decode(s: string): Uint8Array {\n if (s.length === 0) {\n return new Uint8Array(0);\n }\n const paddingLength = this._getPaddingLength(s);\n const length = s.length - paddingLength;\n const out = new Uint8Array(this.maxDecodedLength(length));\n let op = 0;\n let i = 0;\n let haveBad = 0;\n let v0 = 0, v1 = 0, v2 = 0, v3 = 0;\n for (; i < length - 4; i += 4) {\n v0 = this._decodeChar(s.charCodeAt(i + 0));\n v1 = this._decodeChar(s.charCodeAt(i + 1));\n v2 = this._decodeChar(s.charCodeAt(i + 2));\n v3 = this._decodeChar(s.charCodeAt(i + 3));\n out[op++] = (v0 << 2) | (v1 >>> 4);\n out[op++] = (v1 << 4) | (v2 >>> 2);\n out[op++] = (v2 << 6) | v3;\n haveBad |= v0 & INVALID_BYTE;\n haveBad |= v1 & INVALID_BYTE;\n haveBad |= v2 & INVALID_BYTE;\n haveBad |= v3 & INVALID_BYTE;\n }\n if (i < length - 1) {\n v0 = this._decodeChar(s.charCodeAt(i));\n v1 = this._decodeChar(s.charCodeAt(i + 1));\n out[op++] = (v0 << 2) | (v1 >>> 4);\n haveBad |= v0 & INVALID_BYTE;\n haveBad |= v1 & INVALID_BYTE;\n }\n if (i < length - 2) {\n v2 = this._decodeChar(s.charCodeAt(i + 2));\n out[op++] = (v1 << 4) | (v2 >>> 2);\n haveBad |= v2 & INVALID_BYTE;\n }\n if (i < length - 3) {\n v3 = this._decodeChar(s.charCodeAt(i + 3));\n out[op++] = (v2 << 6) | v3;\n haveBad |= v3 & INVALID_BYTE;\n }\n if (haveBad !== 0) {\n throw new Error(\"Base64Coder: incorrect characters for decoding\");\n }\n return out;\n }\n\n // Standard encoding have the following encoded/decoded ranges,\n // which we need to convert between.\n //\n // ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 0123456789 + /\n // Index: 0 - 25 26 - 51 52 - 61 62 63\n // ASCII: 65 - 90 97 - 122 48 - 57 43 47\n //\n\n // Encode 6 bits in b into a new character.\n protected _encodeByte(b: number): string {\n // Encoding uses constant time operations as follows:\n //\n // 1. Define comparison of A with B using (A - B) >>> 8:\n // if A > B, then result is positive integer\n // if A <= B, then result is 0\n //\n // 2. Define selection of C or 0 using bitwise AND: X & C:\n // if X == 0, then result is 0\n // if X != 0, then result is C\n //\n // 3. Start with the smallest comparison (b >= 0), which is always\n // true, so set the result to the starting ASCII value (65).\n //\n // 4. Continue comparing b to higher ASCII values, and selecting\n // zero if comparison isn't true, otherwise selecting a value\n // to add to result, which:\n //\n // a) undoes the previous addition\n // b) provides new value to add\n //\n let result = b;\n // b >= 0\n result += 65;\n // b > 25\n result += ((25 - b) >>> 8) & ((0 - 65) - 26 + 97);\n // b > 51\n result += ((51 - b) >>> 8) & ((26 - 97) - 52 + 48);\n // b > 61\n result += ((61 - b) >>> 8) & ((52 - 48) - 62 + 43);\n // b > 62\n result += ((62 - b) >>> 8) & ((62 - 43) - 63 + 47);\n\n return String.fromCharCode(result);\n }\n\n // Decode a character code into a byte.\n // Must return 256 if character is out of alphabet range.\n protected _decodeChar(c: number): number {\n // Decoding works similar to encoding: using the same comparison\n // function, but now it works on ranges: result is always incremented\n // by value, but this value becomes zero if the range is not\n // satisfied.\n //\n // Decoding starts with invalid value, 256, which is then\n // subtracted when the range is satisfied. If none of the ranges\n // apply, the function returns 256, which is then checked by\n // the caller to throw error.\n let result = INVALID_BYTE; // start with invalid character\n\n // c == 43 (c > 42 and c < 44)\n result += (((42 - c) & (c - 44)) >>> 8) & (-INVALID_BYTE + c - 43 + 62);\n // c == 47 (c > 46 and c < 48)\n result += (((46 - c) & (c - 48)) >>> 8) & (-INVALID_BYTE + c - 47 + 63);\n // c > 47 and c < 58\n result += (((47 - c) & (c - 58)) >>> 8) & (-INVALID_BYTE + c - 48 + 52);\n // c > 64 and c < 91\n result += (((64 - c) & (c - 91)) >>> 8) & (-INVALID_BYTE + c - 65 + 0);\n // c > 96 and c < 123\n result += (((96 - c) & (c - 123)) >>> 8) & (-INVALID_BYTE + c - 97 + 26);\n\n return result;\n }\n\n private _getPaddingLength(s: string): number {\n let paddingLength = 0;\n if (this._paddingCharacter) {\n for (let i = s.length - 1; i >= 0; i--) {\n if (s[i] !== this._paddingCharacter) {\n break;\n }\n paddingLength++;\n }\n if (s.length < 4 || paddingLength > 2) {\n throw new Error(\"Base64Coder: incorrect padding\");\n }\n }\n return paddingLength;\n }\n\n}\n\nconst stdCoder = new Coder();\n\nexport function encode(data: Uint8Array): string {\n return stdCoder.encode(data);\n}\n\nexport function decode(s: string): Uint8Array {\n return stdCoder.decode(s);\n}\n\n/**\n * Implements URL-safe Base64 encoding.\n * (Same as Base64, but '+' is replaced with '-', and '/' with '_').\n *\n * Operates in constant time.\n */\nexport class URLSafeCoder extends Coder {\n // URL-safe encoding have the following encoded/decoded ranges:\n //\n // ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 0123456789 - _\n // Index: 0 - 25 26 - 51 52 - 61 62 63\n // ASCII: 65 - 90 97 - 122 48 - 57 45 95\n //\n\n protected _encodeByte(b: number): string {\n let result = b;\n // b >= 0\n result += 65;\n // b > 25\n result += ((25 - b) >>> 8) & ((0 - 65) - 26 + 97);\n // b > 51\n result += ((51 - b) >>> 8) & ((26 - 97) - 52 + 48);\n // b > 61\n result += ((61 - b) >>> 8) & ((52 - 48) - 62 + 45);\n // b > 62\n result += ((62 - b) >>> 8) & ((62 - 45) - 63 + 95);\n\n return String.fromCharCode(result);\n }\n\n protected _decodeChar(c: number): number {\n let result = INVALID_BYTE;\n\n // c == 45 (c > 44 and c < 46)\n result += (((44 - c) & (c - 46)) >>> 8) & (-INVALID_BYTE + c - 45 + 62);\n // c == 95 (c > 94 and c < 96)\n result += (((94 - c) & (c - 96)) >>> 8) & (-INVALID_BYTE + c - 95 + 63);\n // c > 47 and c < 58\n result += (((47 - c) & (c - 58)) >>> 8) & (-INVALID_BYTE + c - 48 + 52);\n // c > 64 and c < 91\n result += (((64 - c) & (c - 91)) >>> 8) & (-INVALID_BYTE + c - 65 + 0);\n // c > 96 and c < 123\n result += (((96 - c) & (c - 123)) >>> 8) & (-INVALID_BYTE + c - 97 + 26);\n\n return result;\n }\n}\n\nconst urlSafeCoder = new URLSafeCoder();\n\nexport function encodeURLSafe(data: Uint8Array): string {\n return urlSafeCoder.encode(data);\n}\n\nexport function decodeURLSafe(s: string): Uint8Array {\n return urlSafeCoder.decode(s);\n}\n\n\nexport const encodedLength = (length: number) =>\n stdCoder.encodedLength(length);\n\nexport const maxDecodedLength = (length: number) =>\n stdCoder.maxDecodedLength(length);\n\nexport const decodedLength = (s: string) =>\n stdCoder.decodedLength(s);\n","// Copyright (C) 2016 Dmitry Chestnykh\n// MIT License. See LICENSE file for details.\n\n/**\n * Package utf8 implements UTF-8 encoding and decoding.\n */\n\nconst INVALID_UTF16 = \"utf8: invalid string\";\nconst INVALID_UTF8 = \"utf8: invalid source encoding\";\n\n/**\n * Encodes the given string into UTF-8 byte array.\n * Throws if the source string has invalid UTF-16 encoding.\n */\nexport function encode(s: string): Uint8Array {\n // Calculate result length and allocate output array.\n // encodedLength() also validates string and throws errors,\n // so we don't need repeat validation here.\n const arr = new Uint8Array(encodedLength(s));\n\n let pos = 0;\n for (let i = 0; i < s.length; i++) {\n let c = s.charCodeAt(i);\n if (c < 0x80) {\n arr[pos++] = c;\n } else if (c < 0x800) {\n arr[pos++] = 0xc0 | c >> 6;\n arr[pos++] = 0x80 | c & 0x3f;\n } else if (c < 0xd800) {\n arr[pos++] = 0xe0 | c >> 12;\n arr[pos++] = 0x80 | (c >> 6) & 0x3f;\n arr[pos++] = 0x80 | c & 0x3f;\n } else {\n i++; // get one more character\n c = (c & 0x3ff) << 10;\n c |= s.charCodeAt(i) & 0x3ff;\n c += 0x10000;\n\n arr[pos++] = 0xf0 | c >> 18;\n arr[pos++] = 0x80 | (c >> 12) & 0x3f;\n arr[pos++] = 0x80 | (c >> 6) & 0x3f;\n arr[pos++] = 0x80 | c & 0x3f;\n }\n }\n return arr;\n}\n\n/**\n * Returns the number of bytes required to encode the given string into UTF-8.\n * Throws if the source string has invalid UTF-16 encoding.\n */\nexport function encodedLength(s: string): number {\n let result = 0;\n for (let i = 0; i < s.length; i++) {\n const c = s.charCodeAt(i);\n if (c < 0x80) {\n result += 1;\n } else if (c < 0x800) {\n result += 2;\n } else if (c < 0xd800) {\n result += 3;\n } else if (c <= 0xdfff) {\n if (i >= s.length - 1) {\n throw new Error(INVALID_UTF16);\n }\n i++; // \"eat\" next character\n result += 4;\n } else {\n throw new Error(INVALID_UTF16);\n }\n }\n return result;\n}\n\n/**\n * Decodes the given byte array from UTF-8 into a string.\n * Throws if encoding is invalid.\n */\nexport function decode(arr: Uint8Array): string {\n const chars: string[] = [];\n for (let i = 0; i < arr.length; i++) {\n let b = arr[i];\n\n if (b & 0x80) {\n let min;\n if (b < 0xe0) {\n // Need 1 more byte.\n if (i >= arr.length) {\n throw new Error(INVALID_UTF8);\n }\n const n1 = arr[++i];\n if ((n1 & 0xc0) !== 0x80) {\n throw new Error(INVALID_UTF8);\n }\n b = (b & 0x1f) << 6 | (n1 & 0x3f);\n min = 0x80;\n } else if (b < 0xf0) {\n // Need 2 more bytes.\n if (i >= arr.length - 1) {\n throw new Error(INVALID_UTF8);\n }\n const n1 = arr[++i];\n const n2 = arr[++i];\n if ((n1 & 0xc0) !== 0x80 || (n2 & 0xc0) !== 0x80) {\n throw new Error(INVALID_UTF8);\n }\n b = (b & 0x0f) << 12 | (n1 & 0x3f) << 6 | (n2 & 0x3f);\n min = 0x800;\n } else if (b < 0xf8) {\n // Need 3 more bytes.\n if (i >= arr.length - 2) {\n throw new Error(INVALID_UTF8);\n }\n const n1 = arr[++i];\n const n2 = arr[++i];\n const n3 = arr[++i];\n if ((n1 & 0xc0) !== 0x80 || (n2 & 0xc0) !== 0x80 || (n3 & 0xc0) !== 0x80) {\n throw new Error(INVALID_UTF8);\n }\n b = (b & 0x0f) << 18 | (n1 & 0x3f) << 12 | (n2 & 0x3f) << 6 | (n3 & 0x3f);\n min = 0x10000;\n } else {\n throw new Error(INVALID_UTF8);\n }\n\n if (b < min || (b >= 0xd800 && b <= 0xdfff)) {\n throw new Error(INVALID_UTF8);\n }\n\n if (b >= 0x10000) {\n // Surrogate pair.\n if (b > 0x10ffff) {\n throw new Error(INVALID_UTF8);\n }\n b -= 0x10000;\n chars.push(String.fromCharCode(0xd800 | (b >> 10)));\n b = 0xdc00 | (b & 0x3ff);\n }\n }\n\n chars.push(String.fromCharCode(b));\n }\n return chars.join(\"\");\n}\n","// required so we don't have to do require('pusher').default etc.\nmodule.exports = require('./pusher').default;\n","import ScriptReceiver from './script_receiver';\n\n/** Builds receivers for JSONP and Script requests.\n *\n * Each receiver is an object with following fields:\n * - number - unique (for the factory instance), numerical id of the receiver\n * - id - a string ID that can be used in DOM attributes\n * - name - name of the function triggering the receiver\n * - callback - callback function\n *\n * Receivers are triggered only once, on the first callback call.\n *\n * Receivers can be called by their name or by accessing factory object\n * by the number key.\n *\n * @param {String} prefix the prefix used in ids\n * @param {String} name the name of the object\n */\nexport class ScriptReceiverFactory {\n lastId: number;\n prefix: string;\n name: string;\n\n constructor(prefix: string, name: string) {\n this.lastId = 0;\n this.prefix = prefix;\n this.name = name;\n }\n\n create(callback: Function): ScriptReceiver {\n this.lastId++;\n\n var number = this.lastId;\n var id = this.prefix + number;\n var name = this.name + '[' + number + ']';\n\n var called = false;\n var callbackWrapper = function() {\n if (!called) {\n callback.apply(null, arguments);\n called = true;\n }\n };\n\n this[number] = callbackWrapper;\n return { number: number, id: id, name: name, callback: callbackWrapper };\n }\n\n remove(receiver: ScriptReceiver) {\n delete this[receiver.number];\n }\n}\n\nexport var ScriptReceivers = new ScriptReceiverFactory(\n '_pusher_script_',\n 'Pusher.ScriptReceivers'\n);\n","import {\n ChannelAuthorizationOptions,\n UserAuthenticationOptions\n} from './auth/options';\nimport { AuthTransport } from './config';\n\nexport interface DefaultConfig {\n VERSION: string;\n PROTOCOL: number;\n wsPort: number;\n wssPort: number;\n wsPath: string;\n httpHost: string;\n httpPort: number;\n httpsPort: number;\n httpPath: string;\n stats_host: string;\n authEndpoint: string;\n authTransport: AuthTransport;\n activityTimeout: number;\n pongTimeout: number;\n unavailableTimeout: number;\n userAuthentication: UserAuthenticationOptions;\n channelAuthorization: ChannelAuthorizationOptions;\n\n cdn_http?: string;\n cdn_https?: string;\n dependency_suffix?: string;\n}\n\nvar Defaults: DefaultConfig = {\n VERSION: VERSION,\n PROTOCOL: 7,\n\n wsPort: 80,\n wssPort: 443,\n wsPath: '',\n // DEPRECATED: SockJS fallback parameters\n httpHost: 'sockjs.pusher.com',\n httpPort: 80,\n httpsPort: 443,\n httpPath: '/pusher',\n // DEPRECATED: Stats\n stats_host: 'stats.pusher.com',\n // DEPRECATED: Other settings\n authEndpoint: '/pusher/auth',\n authTransport: 'ajax',\n activityTimeout: 120000,\n pongTimeout: 30000,\n unavailableTimeout: 10000,\n userAuthentication: {\n endpoint: '/pusher/user-auth',\n transport: 'ajax'\n },\n channelAuthorization: {\n endpoint: '/pusher/auth',\n transport: 'ajax'\n },\n\n // CDN configuration\n cdn_http: CDN_HTTP,\n cdn_https: CDN_HTTPS,\n dependency_suffix: DEPENDENCY_SUFFIX\n};\n\nexport default Defaults;\n","import {\n ScriptReceivers,\n ScriptReceiverFactory\n} from './script_receiver_factory';\nimport Runtime from 'runtime';\nimport ScriptRequest from './script_request';\n\n/** Handles loading dependency files.\n *\n * Dependency loaders don't remember whether a resource has been loaded or\n * not. It is caller's responsibility to make sure the resource is not loaded\n * twice. This is because it's impossible to detect resource loading status\n * without knowing its content.\n *\n * Options:\n * - cdn_http - url to HTTP CND\n * - cdn_https - url to HTTPS CDN\n * - version - version of pusher-js\n * - suffix - suffix appended to all names of dependency files\n *\n * @param {Object} options\n */\nexport default class DependencyLoader {\n options: any;\n receivers: ScriptReceiverFactory;\n loading: any;\n\n constructor(options: any) {\n this.options = options;\n this.receivers = options.receivers || ScriptReceivers;\n this.loading = {};\n }\n\n /** Loads the dependency from CDN.\n *\n * @param {String} name\n * @param {Function} callback\n */\n load(name: string, options: any, callback: Function) {\n var self = this;\n\n if (self.loading[name] && self.loading[name].length > 0) {\n self.loading[name].push(callback);\n } else {\n self.loading[name] = [callback];\n\n var request = Runtime.createScriptRequest(self.getPath(name, options));\n var receiver = self.receivers.create(function(error) {\n self.receivers.remove(receiver);\n\n if (self.loading[name]) {\n var callbacks = self.loading[name];\n delete self.loading[name];\n\n var successCallback = function(wasSuccessful) {\n if (!wasSuccessful) {\n request.cleanup();\n }\n };\n for (var i = 0; i < callbacks.length; i++) {\n callbacks[i](error, successCallback);\n }\n }\n });\n request.send(receiver);\n }\n }\n\n /** Returns a root URL for pusher-js CDN.\n *\n * @returns {String}\n */\n getRoot(options: any): string {\n var cdn;\n var protocol = Runtime.getDocument().location.protocol;\n if ((options && options.useTLS) || protocol === 'https:') {\n cdn = this.options.cdn_https;\n } else {\n cdn = this.options.cdn_http;\n }\n // make sure there are no double slashes\n return cdn.replace(/\\/*$/, '') + '/' + this.options.version;\n }\n\n /** Returns a full path to a dependency file.\n *\n * @param {String} name\n * @returns {String}\n */\n getPath(name: string, options: any): string {\n return this.getRoot(options) + '/' + name + this.options.suffix + '.js';\n }\n}\n","import { ScriptReceiverFactory } from './script_receiver_factory';\nimport Defaults from 'core/defaults';\nimport DependencyLoader from './dependency_loader';\n\nexport var DependenciesReceivers = new ScriptReceiverFactory(\n '_pusher_dependencies',\n 'Pusher.DependenciesReceivers'\n);\n\nexport var Dependencies = new DependencyLoader({\n cdn_http: Defaults.cdn_http,\n cdn_https: Defaults.cdn_https,\n version: Defaults.VERSION,\n suffix: Defaults.dependency_suffix,\n receivers: DependenciesReceivers\n});\n","/**\n * A place to store help URLs for error messages etc\n */\n\nconst urlStore = {\n baseUrl: 'https://pusher.com',\n urls: {\n authenticationEndpoint: {\n path: '/docs/channels/server_api/authenticating_users'\n },\n authorizationEndpoint: {\n path: '/docs/channels/server_api/authorizing-users/'\n },\n javascriptQuickStart: {\n path: '/docs/javascript_quick_start'\n },\n triggeringClientEvents: {\n path: '/docs/client_api_guide/client_events#trigger-events'\n },\n encryptedChannelSupport: {\n fullUrl:\n 'https://github.com/pusher/pusher-js/tree/cc491015371a4bde5743d1c87a0fbac0feb53195#encrypted-channel-support'\n }\n }\n};\n\n/** Builds a consistent string with links to pusher documentation\n *\n * @param {string} key - relevant key in the url_store.urls object\n * @return {string} suffix string to append to log message\n */\nconst buildLogSuffix = function(key: string): string {\n const urlPrefix = 'See:';\n const urlObj = urlStore.urls[key];\n if (!urlObj) return '';\n\n let url;\n if (urlObj.fullUrl) {\n url = urlObj.fullUrl;\n } else if (urlObj.path) {\n url = urlStore.baseUrl + urlObj.path;\n }\n\n if (!url) return '';\n return `${urlPrefix} ${url}`;\n};\n\nexport default { buildLogSuffix };\n","export enum AuthRequestType {\n UserAuthentication = 'user-authentication',\n ChannelAuthorization = 'channel-authorization'\n}\n\nexport interface ChannelAuthorizationData {\n auth: string;\n channel_data?: string;\n shared_secret?: string;\n}\n\nexport type ChannelAuthorizationCallback = (\n error: Error | null,\n authData: ChannelAuthorizationData | null\n) => void;\n\nexport interface ChannelAuthorizationRequestParams {\n socketId: string;\n channelName: string;\n}\n\nexport interface ChannelAuthorizationHandler {\n (\n params: ChannelAuthorizationRequestParams,\n callback: ChannelAuthorizationCallback\n ): void;\n}\n\nexport interface UserAuthenticationData {\n auth: string;\n user_data: string;\n}\n\nexport type UserAuthenticationCallback = (\n error: Error | null,\n authData: UserAuthenticationData | null\n) => void;\n\nexport interface UserAuthenticationRequestParams {\n socketId: string;\n}\n\nexport interface UserAuthenticationHandler {\n (\n params: UserAuthenticationRequestParams,\n callback: UserAuthenticationCallback\n ): void;\n}\n\nexport type AuthTransportCallback =\n | ChannelAuthorizationCallback\n | UserAuthenticationCallback;\n\nexport interface AuthOptionsT {\n transport: 'ajax' | 'jsonp';\n endpoint: string;\n params?: any;\n headers?: any;\n paramsProvider?: () => any;\n headersProvider?: () => any;\n customHandler?: AuthHandler;\n}\n\nexport declare type UserAuthenticationOptions = AuthOptionsT<\n UserAuthenticationHandler\n>;\nexport declare type ChannelAuthorizationOptions = AuthOptionsT<\n ChannelAuthorizationHandler\n>;\n\nexport interface InternalAuthOptions {\n transport: 'ajax' | 'jsonp';\n endpoint: string;\n params?: any;\n headers?: any;\n paramsProvider?: () => any;\n headersProvider?: () => any;\n}\n","/** Error classes used throughout the library. */\n// https://github.com/Microsoft/TypeScript-wiki/blob/master/Breaking-Changes.md#extending-built-ins-like-error-array-and-map-may-no-longer-work\nexport class BadEventName extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\nexport class BadChannelName extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\nexport class RequestTimedOut extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class TransportPriorityTooLow extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class TransportClosed extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class UnsupportedFeature extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class UnsupportedTransport extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class UnsupportedStrategy extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class HTTPAuthError extends Error {\n status: number;\n constructor(status: number, msg?: string) {\n super(msg);\n this.status = status;\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n","import TimelineSender from 'core/timeline/timeline_sender';\nimport * as Collections from 'core/utils/collections';\nimport Util from 'core/util';\nimport Runtime from 'runtime';\nimport { AuthTransport } from 'core/auth/auth_transports';\nimport AbstractRuntime from 'runtimes/interface';\nimport UrlStore from 'core/utils/url_store';\nimport {\n AuthRequestType,\n AuthTransportCallback,\n InternalAuthOptions\n} from 'core/auth/options';\nimport { HTTPAuthError } from 'core/errors';\n\nconst ajax: AuthTransport = function(\n context: AbstractRuntime,\n query: string,\n authOptions: InternalAuthOptions,\n authRequestType: AuthRequestType,\n callback: AuthTransportCallback\n) {\n const xhr = Runtime.createXHR();\n xhr.open('POST', authOptions.endpoint, true);\n\n // add request headers\n xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');\n for (var headerName in authOptions.headers) {\n xhr.setRequestHeader(headerName, authOptions.headers[headerName]);\n }\n if (authOptions.headersProvider != null) {\n let dynamicHeaders = authOptions.headersProvider();\n for (var headerName in dynamicHeaders) {\n xhr.setRequestHeader(headerName, dynamicHeaders[headerName]);\n }\n }\n\n xhr.onreadystatechange = function() {\n if (xhr.readyState === 4) {\n if (xhr.status === 200) {\n let data;\n let parsed = false;\n\n try {\n data = JSON.parse(xhr.responseText);\n parsed = true;\n } catch (e) {\n callback(\n new HTTPAuthError(\n 200,\n `JSON returned from ${authRequestType.toString()} endpoint was invalid, yet status code was 200. Data was: ${\n xhr.responseText\n }`\n ),\n null\n );\n }\n\n if (parsed) {\n // prevents double execution.\n callback(null, data);\n }\n } else {\n let suffix = '';\n switch (authRequestType) {\n case AuthRequestType.UserAuthentication:\n suffix = UrlStore.buildLogSuffix('authenticationEndpoint');\n break;\n case AuthRequestType.ChannelAuthorization:\n suffix = `Clients must be authorized to join private or presence channels. ${UrlStore.buildLogSuffix(\n 'authorizationEndpoint'\n )}`;\n break;\n }\n callback(\n new HTTPAuthError(\n xhr.status,\n `Unable to retrieve auth string from ${authRequestType.toString()} endpoint - ` +\n `received status: ${xhr.status} from ${authOptions.endpoint}. ${suffix}`\n ),\n null\n );\n }\n }\n };\n\n xhr.send(query);\n return xhr;\n};\n\nexport default ajax;\n","export default function encode(s: any): string {\n return btoa(utob(s));\n}\n\nvar fromCharCode = String.fromCharCode;\n\nvar b64chars =\n 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';\nvar b64tab = {};\n\nfor (var i = 0, l = b64chars.length; i < l; i++) {\n b64tab[b64chars.charAt(i)] = i;\n}\n\nvar cb_utob = function(c) {\n var cc = c.charCodeAt(0);\n return cc < 0x80\n ? c\n : cc < 0x800\n ? fromCharCode(0xc0 | (cc >>> 6)) + fromCharCode(0x80 | (cc & 0x3f))\n : fromCharCode(0xe0 | ((cc >>> 12) & 0x0f)) +\n fromCharCode(0x80 | ((cc >>> 6) & 0x3f)) +\n fromCharCode(0x80 | (cc & 0x3f));\n};\n\nvar utob = function(u) {\n return u.replace(/[^\\x00-\\x7F]/g, cb_utob);\n};\n\nvar cb_encode = function(ccc) {\n var padlen = [0, 2, 1][ccc.length % 3];\n var ord =\n (ccc.charCodeAt(0) << 16) |\n ((ccc.length > 1 ? ccc.charCodeAt(1) : 0) << 8) |\n (ccc.length > 2 ? ccc.charCodeAt(2) : 0);\n var chars = [\n b64chars.charAt(ord >>> 18),\n b64chars.charAt((ord >>> 12) & 63),\n padlen >= 2 ? '=' : b64chars.charAt((ord >>> 6) & 63),\n padlen >= 1 ? '=' : b64chars.charAt(ord & 63)\n ];\n return chars.join('');\n};\n\nvar btoa =\n global.btoa ||\n function(b) {\n return b.replace(/[\\s\\S]{1,3}/g, cb_encode);\n };\n","import TimedCallback from './timed_callback';\nimport { Delay, Scheduler, Canceller } from './scheduling';\n\nabstract class Timer {\n protected clear: Canceller;\n protected timer: number | void;\n\n constructor(\n set: Scheduler,\n clear: Canceller,\n delay: Delay,\n callback: TimedCallback\n ) {\n this.clear = clear;\n this.timer = set(() => {\n if (this.timer) {\n this.timer = callback(this.timer);\n }\n }, delay);\n }\n\n /** Returns whether the timer is still running.\n *\n * @return {Boolean}\n */\n isRunning(): boolean {\n return this.timer !== null;\n }\n\n /** Aborts a timer when it's running. */\n ensureAborted() {\n if (this.timer) {\n this.clear(this.timer);\n this.timer = null;\n }\n }\n}\n\nexport default Timer;\n","import Timer from './abstract_timer';\nimport TimedCallback from './timed_callback';\nimport { Delay } from './scheduling';\n\n// We need to bind clear functions this way to avoid exceptions on IE8\nfunction clearTimeout(timer) {\n global.clearTimeout(timer);\n}\nfunction clearInterval(timer) {\n global.clearInterval(timer);\n}\n\n/** Cross-browser compatible one-off timer abstraction.\n *\n * @param {Number} delay\n * @param {Function} callback\n */\nexport class OneOffTimer extends Timer {\n constructor(delay: Delay, callback: TimedCallback) {\n super(setTimeout, clearTimeout, delay, function(timer) {\n callback();\n return null;\n });\n }\n}\n\n/** Cross-browser compatible periodic timer abstraction.\n *\n * @param {Number} delay\n * @param {Function} callback\n */\nexport class PeriodicTimer extends Timer {\n constructor(delay: Delay, callback: TimedCallback) {\n super(setInterval, clearInterval, delay, function(timer) {\n callback();\n return timer;\n });\n }\n}\n","import * as Collections from './utils/collections';\nimport TimedCallback from './utils/timers/timed_callback';\nimport { OneOffTimer, PeriodicTimer } from './utils/timers';\n\nvar Util = {\n now(): number {\n if (Date.now) {\n return Date.now();\n } else {\n return new Date().valueOf();\n }\n },\n\n defer(callback: TimedCallback): OneOffTimer {\n return new OneOffTimer(0, callback);\n },\n\n /** Builds a function that will proxy a method call to its first argument.\n *\n * Allows partial application of arguments, so additional arguments are\n * prepended to the argument list.\n *\n * @param {String} name method name\n * @return {Function} proxy function\n */\n method(name: string, ...args: any[]): Function {\n var boundArguments = Array.prototype.slice.call(arguments, 1);\n return function(object) {\n return object[name].apply(object, boundArguments.concat(arguments));\n };\n }\n};\n\nexport default Util;\n","import base64encode from '../base64';\nimport Util from '../util';\n\n/** Merges multiple objects into the target argument.\n *\n * For properties that are plain Objects, performs a deep-merge. For the\n * rest it just copies the value of the property.\n *\n * To extend prototypes use it as following:\n * Pusher.Util.extend(Target.prototype, Base.prototype)\n *\n * You can also use it to merge objects without altering them:\n * Pusher.Util.extend({}, object1, object2)\n *\n * @param {Object} target\n * @return {Object} the target argument\n */\nexport function extend(target: any, ...sources: any[]): T {\n for (var i = 0; i < sources.length; i++) {\n var extensions = sources[i];\n for (var property in extensions) {\n if (\n extensions[property] &&\n extensions[property].constructor &&\n extensions[property].constructor === Object\n ) {\n target[property] = extend(target[property] || {}, extensions[property]);\n } else {\n target[property] = extensions[property];\n }\n }\n }\n return target;\n}\n\nexport function stringify(): string {\n var m = ['Pusher'];\n for (var i = 0; i < arguments.length; i++) {\n if (typeof arguments[i] === 'string') {\n m.push(arguments[i]);\n } else {\n m.push(safeJSONStringify(arguments[i]));\n }\n }\n return m.join(' : ');\n}\n\nexport function arrayIndexOf(array: any[], item: any): number {\n // MSIE doesn't have array.indexOf\n var nativeIndexOf = Array.prototype.indexOf;\n if (array === null) {\n return -1;\n }\n if (nativeIndexOf && array.indexOf === nativeIndexOf) {\n return array.indexOf(item);\n }\n for (var i = 0, l = array.length; i < l; i++) {\n if (array[i] === item) {\n return i;\n }\n }\n return -1;\n}\n\n/** Applies a function f to all properties of an object.\n *\n * Function f gets 3 arguments passed:\n * - element from the object\n * - key of the element\n * - reference to the object\n *\n * @param {Object} object\n * @param {Function} f\n */\nexport function objectApply(object: any, f: Function) {\n for (var key in object) {\n if (Object.prototype.hasOwnProperty.call(object, key)) {\n f(object[key], key, object);\n }\n }\n}\n\n/** Return a list of objects own proerty keys\n *\n * @param {Object} object\n * @returns {Array}\n */\nexport function keys(object: any): string[] {\n var keys = [];\n objectApply(object, function(_, key) {\n keys.push(key);\n });\n return keys;\n}\n\n/** Return a list of object's own property values\n *\n * @param {Object} object\n * @returns {Array}\n */\nexport function values(object: any): any[] {\n var values = [];\n objectApply(object, function(value) {\n values.push(value);\n });\n return values;\n}\n\n/** Applies a function f to all elements of an array.\n *\n * Function f gets 3 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function apply(array: any[], f: Function, context?: any) {\n for (var i = 0; i < array.length; i++) {\n f.call(context || global, array[i], i, array);\n }\n}\n\n/** Maps all elements of the array and returns the result.\n *\n * Function f gets 4 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n * - reference to the destination array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function map(array: any[], f: Function): any[] {\n var result = [];\n for (var i = 0; i < array.length; i++) {\n result.push(f(array[i], i, array, result));\n }\n return result;\n}\n\n/** Maps all elements of the object and returns the result.\n *\n * Function f gets 4 arguments passed:\n * - element from the object\n * - key of the element\n * - reference to the source object\n * - reference to the destination object\n *\n * @param {Object} object\n * @param {Function} f\n */\nexport function mapObject(object: any, f: Function): any {\n var result = {};\n objectApply(object, function(value, key) {\n result[key] = f(value);\n });\n return result;\n}\n\n/** Filters elements of the array using a test function.\n *\n * Function test gets 4 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n * - reference to the destination array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function filter(array: any[], test: Function): any[] {\n test =\n test ||\n function(value) {\n return !!value;\n };\n\n var result = [];\n for (var i = 0; i < array.length; i++) {\n if (test(array[i], i, array, result)) {\n result.push(array[i]);\n }\n }\n return result;\n}\n\n/** Filters properties of the object using a test function.\n *\n * Function test gets 4 arguments passed:\n * - element from the object\n * - key of the element\n * - reference to the source object\n * - reference to the destination object\n *\n * @param {Object} object\n * @param {Function} f\n */\nexport function filterObject(object: Object, test: Function) {\n var result = {};\n objectApply(object, function(value, key) {\n if ((test && test(value, key, object, result)) || Boolean(value)) {\n result[key] = value;\n }\n });\n return result;\n}\n\n/** Flattens an object into a two-dimensional array.\n *\n * @param {Object} object\n * @return {Array} resulting array of [key, value] pairs\n */\nexport function flatten(object: Object): any[] {\n var result = [];\n objectApply(object, function(value, key) {\n result.push([key, value]);\n });\n return result;\n}\n\n/** Checks whether any element of the array passes the test.\n *\n * Function test gets 3 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function any(array: any[], test: Function): boolean {\n for (var i = 0; i < array.length; i++) {\n if (test(array[i], i, array)) {\n return true;\n }\n }\n return false;\n}\n\n/** Checks whether all elements of the array pass the test.\n *\n * Function test gets 3 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function all(array: any[], test: Function): boolean {\n for (var i = 0; i < array.length; i++) {\n if (!test(array[i], i, array)) {\n return false;\n }\n }\n return true;\n}\n\nexport function encodeParamsObject(data): string {\n return mapObject(data, function(value) {\n if (typeof value === 'object') {\n value = safeJSONStringify(value);\n }\n return encodeURIComponent(base64encode(value.toString()));\n });\n}\n\nexport function buildQueryString(data: any): string {\n var params = filterObject(data, function(value) {\n return value !== undefined;\n });\n\n var query = map(\n flatten(encodeParamsObject(params)),\n Util.method('join', '=')\n ).join('&');\n\n return query;\n}\n\n/**\n * See https://github.com/douglascrockford/JSON-js/blob/master/cycle.js\n *\n * Remove circular references from an object. Required for JSON.stringify in\n * React Native, which tends to blow up a lot.\n *\n * @param {any} object\n * @return {any} Decycled object\n */\nexport function decycleObject(object: any): any {\n var objects = [],\n paths = [];\n\n return (function derez(value, path) {\n var i, name, nu;\n\n switch (typeof value) {\n case 'object':\n if (!value) {\n return null;\n }\n for (i = 0; i < objects.length; i += 1) {\n if (objects[i] === value) {\n return { $ref: paths[i] };\n }\n }\n\n objects.push(value);\n paths.push(path);\n\n if (Object.prototype.toString.apply(value) === '[object Array]') {\n nu = [];\n for (i = 0; i < value.length; i += 1) {\n nu[i] = derez(value[i], path + '[' + i + ']');\n }\n } else {\n nu = {};\n for (name in value) {\n if (Object.prototype.hasOwnProperty.call(value, name)) {\n nu[name] = derez(\n value[name],\n path + '[' + JSON.stringify(name) + ']'\n );\n }\n }\n }\n return nu;\n case 'number':\n case 'string':\n case 'boolean':\n return value;\n }\n })(object, '$');\n}\n\n/**\n * Provides a cross-browser and cross-platform way to safely stringify objects\n * into JSON. This is particularly necessary for ReactNative, where circular JSON\n * structures throw an exception.\n *\n * @param {any} source The object to stringify\n * @return {string} The serialized output.\n */\nexport function safeJSONStringify(source: any): string {\n try {\n return JSON.stringify(source);\n } catch (e) {\n return JSON.stringify(decycleObject(source));\n }\n}\n","import { stringify } from './utils/collections';\nimport Pusher from './pusher';\n\nclass Logger {\n debug(...args: any[]) {\n this.log(this.globalLog, args);\n }\n\n warn(...args: any[]) {\n this.log(this.globalLogWarn, args);\n }\n\n error(...args: any[]) {\n this.log(this.globalLogError, args);\n }\n\n private globalLog = (message: string) => {\n if (global.console && global.console.log) {\n global.console.log(message);\n }\n };\n\n private globalLogWarn(message: string) {\n if (global.console && global.console.warn) {\n global.console.warn(message);\n } else {\n this.globalLog(message);\n }\n }\n\n private globalLogError(message: string) {\n if (global.console && global.console.error) {\n global.console.error(message);\n } else {\n this.globalLogWarn(message);\n }\n }\n\n private log(\n defaultLoggingFunction: (message: string) => void,\n ...args: any[]\n ) {\n var message = stringify.apply(this, arguments);\n if (Pusher.log) {\n Pusher.log(message);\n } else if (Pusher.logToConsole) {\n const log = defaultLoggingFunction.bind(this);\n log(message);\n }\n }\n}\n\nexport default new Logger();\n","import Browser from '../browser';\nimport Logger from 'core/logger';\nimport JSONPRequest from '../dom/jsonp_request';\nimport { ScriptReceivers } from '../dom/script_receiver_factory';\nimport { AuthTransport } from 'core/auth/auth_transports';\nimport {\n AuthRequestType,\n AuthTransportCallback,\n InternalAuthOptions\n} from 'core/auth/options';\n\nvar jsonp: AuthTransport = function(\n context: Browser,\n query: string,\n authOptions: InternalAuthOptions,\n authRequestType: AuthRequestType,\n callback: AuthTransportCallback\n) {\n if (\n authOptions.headers !== undefined ||\n authOptions.headersProvider != null\n ) {\n Logger.warn(\n `To send headers with the ${authRequestType.toString()} request, you must use AJAX, rather than JSONP.`\n );\n }\n\n var callbackName = context.nextAuthCallbackID.toString();\n context.nextAuthCallbackID++;\n\n var document = context.getDocument();\n var script = document.createElement('script');\n // Hacked wrapper.\n context.auth_callbacks[callbackName] = function(data) {\n callback(null, data);\n };\n\n var callback_name = \"Pusher.auth_callbacks['\" + callbackName + \"']\";\n script.src =\n authOptions.endpoint +\n '?callback=' +\n encodeURIComponent(callback_name) +\n '&' +\n query;\n\n var head =\n document.getElementsByTagName('head')[0] || document.documentElement;\n head.insertBefore(script, head.firstChild);\n};\n\nexport default jsonp;\n","import ScriptReceiver from './script_receiver';\n\n/** Sends a generic HTTP GET request using a script tag.\n *\n * By constructing URL in a specific way, it can be used for loading\n * JavaScript resources or JSONP requests. It can notify about errors, but\n * only in certain environments. Please take care of monitoring the state of\n * the request yourself.\n *\n * @param {String} src\n */\nexport default class ScriptRequest {\n src: string;\n script: any;\n errorScript: any;\n\n constructor(src: string) {\n this.src = src;\n }\n\n send(receiver: ScriptReceiver) {\n var self = this;\n var errorString = 'Error loading ' + self.src;\n\n self.script = document.createElement('script');\n self.script.id = receiver.id;\n self.script.src = self.src;\n self.script.type = 'text/javascript';\n self.script.charset = 'UTF-8';\n\n if (self.script.addEventListener) {\n self.script.onerror = function() {\n receiver.callback(errorString);\n };\n self.script.onload = function() {\n receiver.callback(null);\n };\n } else {\n self.script.onreadystatechange = function() {\n if (\n self.script.readyState === 'loaded' ||\n self.script.readyState === 'complete'\n ) {\n receiver.callback(null);\n }\n };\n }\n\n // Opera<11.6 hack for missing onerror callback\n if (\n self.script.async === undefined &&\n (document).attachEvent &&\n /opera/i.test(navigator.userAgent)\n ) {\n self.errorScript = document.createElement('script');\n self.errorScript.id = receiver.id + '_error';\n self.errorScript.text = receiver.name + \"('\" + errorString + \"');\";\n self.script.async = self.errorScript.async = false;\n } else {\n self.script.async = true;\n }\n\n var head = document.getElementsByTagName('head')[0];\n head.insertBefore(self.script, head.firstChild);\n if (self.errorScript) {\n head.insertBefore(self.errorScript, self.script.nextSibling);\n }\n }\n\n /** Cleans up the DOM remains of the script request. */\n cleanup() {\n if (this.script) {\n this.script.onload = this.script.onerror = null;\n this.script.onreadystatechange = null;\n }\n if (this.script && this.script.parentNode) {\n this.script.parentNode.removeChild(this.script);\n }\n if (this.errorScript && this.errorScript.parentNode) {\n this.errorScript.parentNode.removeChild(this.errorScript);\n }\n this.script = null;\n this.errorScript = null;\n }\n}\n","import ScriptReceiver from './script_receiver';\nimport ScriptRequest from './script_request';\nimport * as Collections from 'core/utils/collections';\nimport Util from 'core/util';\nimport Runtime from '../runtime';\n\n/** Sends data via JSONP.\n *\n * Data is a key-value map. Its values are JSON-encoded and then passed\n * through base64. Finally, keys and encoded values are appended to the query\n * string.\n *\n * The class itself does not guarantee raising errors on failures, as it's not\n * possible to support such feature on all browsers. Instead, JSONP endpoint\n * should call back in a way that's easy to distinguish from browser calls,\n * for example by passing a second argument to the receiver.\n *\n * @param {String} url\n * @param {Object} data key-value map of data to be submitted\n */\nexport default class JSONPRequest {\n url: string;\n data: any;\n request: ScriptRequest;\n\n constructor(url: string, data: any) {\n this.url = url;\n this.data = data;\n }\n\n /** Sends the actual JSONP request.\n *\n * @param {ScriptReceiver} receiver\n */\n send(receiver: ScriptReceiver) {\n if (this.request) {\n return;\n }\n\n var query = Collections.buildQueryString(this.data);\n var url = this.url + '/' + receiver.number + '?' + query;\n this.request = Runtime.createScriptRequest(url);\n this.request.send(receiver);\n }\n\n /** Cleans up the DOM remains of the JSONP request. */\n cleanup() {\n if (this.request) {\n this.request.cleanup();\n }\n }\n}\n","import TimelineSender from 'core/timeline/timeline_sender';\nimport TimelineTransport from 'core/timeline/timeline_transport';\nimport Browser from 'runtime';\nimport { AuthTransport } from 'core/auth/auth_transports';\nimport { ScriptReceivers } from '../dom/script_receiver_factory';\n\nvar getAgent = function(sender: TimelineSender, useTLS: boolean) {\n return function(data: any, callback: Function) {\n var scheme = 'http' + (useTLS ? 's' : '') + '://';\n var url =\n scheme + (sender.host || sender.options.host) + sender.options.path;\n var request = Browser.createJSONPRequest(url, data);\n\n var receiver = Browser.ScriptReceivers.create(function(error, result) {\n ScriptReceivers.remove(receiver);\n request.cleanup();\n\n if (result && result.host) {\n sender.host = result.host;\n }\n if (callback) {\n callback(error, result);\n }\n });\n request.send(receiver);\n };\n};\n\nvar jsonp = {\n name: 'jsonp',\n getAgent\n};\n\nexport default jsonp;\n","import Defaults from '../defaults';\nimport { default as URLScheme, URLSchemeParams } from './url_scheme';\n\nfunction getGenericURL(\n baseScheme: string,\n params: URLSchemeParams,\n path: string\n): string {\n var scheme = baseScheme + (params.useTLS ? 's' : '');\n var host = params.useTLS ? params.hostTLS : params.hostNonTLS;\n return scheme + '://' + host + path;\n}\n\nfunction getGenericPath(key: string, queryString?: string): string {\n var path = '/app/' + key;\n var query =\n '?protocol=' +\n Defaults.PROTOCOL +\n '&client=js' +\n '&version=' +\n Defaults.VERSION +\n (queryString ? '&' + queryString : '');\n return path + query;\n}\n\nexport var ws: URLScheme = {\n getInitial: function(key: string, params: URLSchemeParams): string {\n var path = (params.httpPath || '') + getGenericPath(key, 'flash=false');\n return getGenericURL('ws', params, path);\n }\n};\n\nexport var http: URLScheme = {\n getInitial: function(key: string, params: URLSchemeParams): string {\n var path = (params.httpPath || '/pusher') + getGenericPath(key);\n return getGenericURL('http', params, path);\n }\n};\n\nexport var sockjs: URLScheme = {\n getInitial: function(key: string, params: URLSchemeParams): string {\n return getGenericURL('http', params, params.httpPath || '/pusher');\n },\n getPath: function(key: string, params: URLSchemeParams): string {\n return getGenericPath(key);\n }\n};\n","import Callback from './callback';\nimport * as Collections from '../utils/collections';\nimport CallbackTable from './callback_table';\n\nexport default class CallbackRegistry {\n _callbacks: CallbackTable;\n\n constructor() {\n this._callbacks = {};\n }\n\n get(name: string): Callback[] {\n return this._callbacks[prefix(name)];\n }\n\n add(name: string, callback: Function, context: any) {\n var prefixedEventName = prefix(name);\n this._callbacks[prefixedEventName] =\n this._callbacks[prefixedEventName] || [];\n this._callbacks[prefixedEventName].push({\n fn: callback,\n context: context\n });\n }\n\n remove(name?: string, callback?: Function, context?: any) {\n if (!name && !callback && !context) {\n this._callbacks = {};\n return;\n }\n\n var names = name ? [prefix(name)] : Collections.keys(this._callbacks);\n\n if (callback || context) {\n this.removeCallback(names, callback, context);\n } else {\n this.removeAllCallbacks(names);\n }\n }\n\n private removeCallback(names: string[], callback: Function, context: any) {\n Collections.apply(\n names,\n function(name) {\n this._callbacks[name] = Collections.filter(\n this._callbacks[name] || [],\n function(binding) {\n return (\n (callback && callback !== binding.fn) ||\n (context && context !== binding.context)\n );\n }\n );\n if (this._callbacks[name].length === 0) {\n delete this._callbacks[name];\n }\n },\n this\n );\n }\n\n private removeAllCallbacks(names: string[]) {\n Collections.apply(\n names,\n function(name) {\n delete this._callbacks[name];\n },\n this\n );\n }\n}\n\nfunction prefix(name: string): string {\n return '_' + name;\n}\n","import * as Collections from '../utils/collections';\nimport Callback from './callback';\nimport Metadata from '../channels/metadata';\nimport CallbackRegistry from './callback_registry';\n\n/** Manages callback bindings and event emitting.\n *\n * @param Function failThrough called when no listeners are bound to an event\n */\nexport default class Dispatcher {\n callbacks: CallbackRegistry;\n global_callbacks: Function[];\n failThrough: Function;\n\n constructor(failThrough?: Function) {\n this.callbacks = new CallbackRegistry();\n this.global_callbacks = [];\n this.failThrough = failThrough;\n }\n\n bind(eventName: string, callback: Function, context?: any) {\n this.callbacks.add(eventName, callback, context);\n return this;\n }\n\n bind_global(callback: Function) {\n this.global_callbacks.push(callback);\n return this;\n }\n\n unbind(eventName?: string, callback?: Function, context?: any) {\n this.callbacks.remove(eventName, callback, context);\n return this;\n }\n\n unbind_global(callback?: Function) {\n if (!callback) {\n this.global_callbacks = [];\n return this;\n }\n\n this.global_callbacks = Collections.filter(\n this.global_callbacks || [],\n c => c !== callback\n );\n\n return this;\n }\n\n unbind_all() {\n this.unbind();\n this.unbind_global();\n return this;\n }\n\n emit(eventName: string, data?: any, metadata?: Metadata): Dispatcher {\n for (var i = 0; i < this.global_callbacks.length; i++) {\n this.global_callbacks[i](eventName, data);\n }\n\n var callbacks = this.callbacks.get(eventName);\n var args = [];\n\n if (metadata) {\n // if there's a metadata argument, we need to call the callback with both\n // data and metadata regardless of whether data is undefined\n args.push(data, metadata);\n } else if (data) {\n // metadata is undefined, so we only need to call the callback with data\n // if data exists\n args.push(data);\n }\n\n if (callbacks && callbacks.length > 0) {\n for (var i = 0; i < callbacks.length; i++) {\n callbacks[i].fn.apply(callbacks[i].context || global, args);\n }\n } else if (this.failThrough) {\n this.failThrough(eventName, data);\n }\n\n return this;\n }\n}\n","import Util from '../util';\nimport * as Collections from '../utils/collections';\nimport { default as EventsDispatcher } from '../events/dispatcher';\nimport Logger from '../logger';\nimport TransportHooks from './transport_hooks';\nimport Socket from '../socket';\nimport Runtime from 'runtime';\nimport Timeline from '../timeline/timeline';\nimport TransportConnectionOptions from './transport_connection_options';\n\n/** Provides universal API for transport connections.\n *\n * Transport connection is a low-level object that wraps a connection method\n * and exposes a simple evented interface for the connection state and\n * messaging. It does not implement Pusher-specific WebSocket protocol.\n *\n * Additionally, it fetches resources needed for transport to work and exposes\n * an interface for querying transport features.\n *\n * States:\n * - new - initial state after constructing the object\n * - initializing - during initialization phase, usually fetching resources\n * - intialized - ready to establish a connection\n * - connection - when connection is being established\n * - open - when connection ready to be used\n * - closed - after connection was closed be either side\n *\n * Emits:\n * - error - after the connection raised an error\n *\n * Options:\n * - useTLS - whether connection should be over TLS\n * - hostTLS - host to connect to when connection is over TLS\n * - hostNonTLS - host to connect to when connection is over TLS\n *\n * @param {String} key application key\n * @param {Object} options\n */\nexport default class TransportConnection extends EventsDispatcher {\n hooks: TransportHooks;\n name: string;\n priority: number;\n key: string;\n options: TransportConnectionOptions;\n state: string;\n timeline: Timeline;\n activityTimeout: number;\n id: number;\n socket: Socket;\n beforeOpen: Function;\n initialize: Function;\n\n constructor(\n hooks: TransportHooks,\n name: string,\n priority: number,\n key: string,\n options: TransportConnectionOptions\n ) {\n super();\n this.initialize = Runtime.transportConnectionInitializer;\n this.hooks = hooks;\n this.name = name;\n this.priority = priority;\n this.key = key;\n this.options = options;\n\n this.state = 'new';\n this.timeline = options.timeline;\n this.activityTimeout = options.activityTimeout;\n this.id = this.timeline.generateUniqueID();\n }\n\n /** Checks whether the transport handles activity checks by itself.\n *\n * @return {Boolean}\n */\n handlesActivityChecks(): boolean {\n return Boolean(this.hooks.handlesActivityChecks);\n }\n\n /** Checks whether the transport supports the ping/pong API.\n *\n * @return {Boolean}\n */\n supportsPing(): boolean {\n return Boolean(this.hooks.supportsPing);\n }\n\n /** Tries to establish a connection.\n *\n * @returns {Boolean} false if transport is in invalid state\n */\n connect(): boolean {\n if (this.socket || this.state !== 'initialized') {\n return false;\n }\n\n var url = this.hooks.urls.getInitial(this.key, this.options);\n try {\n this.socket = this.hooks.getSocket(url, this.options);\n } catch (e) {\n Util.defer(() => {\n this.onError(e);\n this.changeState('closed');\n });\n return false;\n }\n\n this.bindListeners();\n\n Logger.debug('Connecting', { transport: this.name, url });\n this.changeState('connecting');\n return true;\n }\n\n /** Closes the connection.\n *\n * @return {Boolean} true if there was a connection to close\n */\n close(): boolean {\n if (this.socket) {\n this.socket.close();\n return true;\n } else {\n return false;\n }\n }\n\n /** Sends data over the open connection.\n *\n * @param {String} data\n * @return {Boolean} true only when in the \"open\" state\n */\n send(data: any): boolean {\n if (this.state === 'open') {\n // Workaround for MobileSafari bug (see https://gist.github.com/2052006)\n Util.defer(() => {\n if (this.socket) {\n this.socket.send(data);\n }\n });\n return true;\n } else {\n return false;\n }\n }\n\n /** Sends a ping if the connection is open and transport supports it. */\n ping() {\n if (this.state === 'open' && this.supportsPing()) {\n this.socket.ping();\n }\n }\n\n private onOpen() {\n if (this.hooks.beforeOpen) {\n this.hooks.beforeOpen(\n this.socket,\n this.hooks.urls.getPath(this.key, this.options)\n );\n }\n this.changeState('open');\n this.socket.onopen = undefined;\n }\n\n private onError(error) {\n this.emit('error', { type: 'WebSocketError', error: error });\n this.timeline.error(this.buildTimelineMessage({ error: error.toString() }));\n }\n\n private onClose(closeEvent?: any) {\n if (closeEvent) {\n this.changeState('closed', {\n code: closeEvent.code,\n reason: closeEvent.reason,\n wasClean: closeEvent.wasClean\n });\n } else {\n this.changeState('closed');\n }\n this.unbindListeners();\n this.socket = undefined;\n }\n\n private onMessage(message) {\n this.emit('message', message);\n }\n\n private onActivity() {\n this.emit('activity');\n }\n\n private bindListeners() {\n this.socket.onopen = () => {\n this.onOpen();\n };\n this.socket.onerror = error => {\n this.onError(error);\n };\n this.socket.onclose = closeEvent => {\n this.onClose(closeEvent);\n };\n this.socket.onmessage = message => {\n this.onMessage(message);\n };\n\n if (this.supportsPing()) {\n this.socket.onactivity = () => {\n this.onActivity();\n };\n }\n }\n\n private unbindListeners() {\n if (this.socket) {\n this.socket.onopen = undefined;\n this.socket.onerror = undefined;\n this.socket.onclose = undefined;\n this.socket.onmessage = undefined;\n if (this.supportsPing()) {\n this.socket.onactivity = undefined;\n }\n }\n }\n\n private changeState(state: string, params?: any) {\n this.state = state;\n this.timeline.info(\n this.buildTimelineMessage({\n state: state,\n params: params\n })\n );\n this.emit(state, params);\n }\n\n buildTimelineMessage(message): any {\n return Collections.extend({ cid: this.id }, message);\n }\n}\n","import Factory from '../utils/factory';\nimport TransportHooks from './transport_hooks';\nimport TransportConnection from './transport_connection';\nimport TransportConnectionOptions from './transport_connection_options';\n\n/** Provides interface for transport connection instantiation.\n *\n * Takes transport-specific hooks as the only argument, which allow checking\n * for transport support and creating its connections.\n *\n * Supported hooks: * - file - the name of the file to be fetched during initialization\n * - urls - URL scheme to be used by transport\n * - handlesActivityCheck - true when the transport handles activity checks\n * - supportsPing - true when the transport has a ping/activity API\n * - isSupported - tells whether the transport is supported in the environment\n * - getSocket - creates a WebSocket-compatible transport socket\n *\n * See transports.js for specific implementations.\n *\n * @param {Object} hooks object containing all needed transport hooks\n */\nexport default class Transport {\n hooks: TransportHooks;\n\n constructor(hooks: TransportHooks) {\n this.hooks = hooks;\n }\n\n /** Returns whether the transport is supported in the environment.\n *\n * @param {Object} envronment te environment details (encryption, settings)\n * @returns {Boolean} true when the transport is supported\n */\n isSupported(environment: any): boolean {\n return this.hooks.isSupported(environment);\n }\n\n /** Creates a transport connection.\n *\n * @param {String} name\n * @param {Number} priority\n * @param {String} key the application key\n * @param {Object} options\n * @returns {TransportConnection}\n */\n createConnection(\n name: string,\n priority: number,\n key: string,\n options: any\n ): TransportConnection {\n return new TransportConnection(this.hooks, name, priority, key, options);\n }\n}\n","import * as URLSchemes from 'core/transports/url_schemes';\nimport URLScheme from 'core/transports/url_scheme';\nimport Transport from 'core/transports/transport';\nimport Util from 'core/util';\nimport * as Collections from 'core/utils/collections';\nimport TransportHooks from 'core/transports/transport_hooks';\nimport TransportsTable from 'core/transports/transports_table';\nimport Runtime from 'runtime';\n\n/** WebSocket transport.\n *\n * Uses native WebSocket implementation, including MozWebSocket supported by\n * earlier Firefox versions.\n */\nvar WSTransport = new Transport({\n urls: URLSchemes.ws,\n handlesActivityChecks: false,\n supportsPing: false,\n\n isInitialized: function() {\n return Boolean(Runtime.getWebSocketAPI());\n },\n isSupported: function(): boolean {\n return Boolean(Runtime.getWebSocketAPI());\n },\n getSocket: function(url) {\n return Runtime.createWebSocket(url);\n }\n});\n\nvar httpConfiguration = {\n urls: URLSchemes.http,\n handlesActivityChecks: false,\n supportsPing: true,\n isInitialized: function() {\n return true;\n }\n};\n\nexport var streamingConfiguration = Collections.extend(\n {\n getSocket: function(url) {\n return Runtime.HTTPFactory.createStreamingSocket(url);\n }\n },\n httpConfiguration\n);\nexport var pollingConfiguration = Collections.extend(\n {\n getSocket: function(url) {\n return Runtime.HTTPFactory.createPollingSocket(url);\n }\n },\n httpConfiguration\n);\n\nvar xhrConfiguration = {\n isSupported: function(): boolean {\n return Runtime.isXHRSupported();\n }\n};\n\n/** HTTP streaming transport using CORS-enabled XMLHttpRequest. */\nvar XHRStreamingTransport = new Transport(\n (\n Collections.extend({}, streamingConfiguration, xhrConfiguration)\n )\n);\n\n/** HTTP long-polling transport using CORS-enabled XMLHttpRequest. */\nvar XHRPollingTransport = new Transport(\n Collections.extend({}, pollingConfiguration, xhrConfiguration)\n);\n\nvar Transports: TransportsTable = {\n ws: WSTransport,\n xhr_streaming: XHRStreamingTransport,\n xhr_polling: XHRPollingTransport\n};\n\nexport default Transports;\n","import {\n default as Transports,\n streamingConfiguration,\n pollingConfiguration\n} from 'isomorphic/transports/transports';\nimport Transport from 'core/transports/transport';\nimport TransportHooks from 'core/transports/transport_hooks';\nimport * as URLSchemes from 'core/transports/url_schemes';\nimport Runtime from 'runtime';\nimport { Dependencies } from '../dom/dependencies';\nimport * as Collections from 'core/utils/collections';\n\nvar SockJSTransport = new Transport({\n file: 'sockjs',\n urls: URLSchemes.sockjs,\n handlesActivityChecks: true,\n supportsPing: false,\n\n isSupported: function() {\n return true;\n },\n isInitialized: function() {\n return window.SockJS !== undefined;\n },\n getSocket: function(url, options) {\n return new window.SockJS(url, null, {\n js_path: Dependencies.getPath('sockjs', {\n useTLS: options.useTLS\n }),\n ignore_null_origin: options.ignoreNullOrigin\n });\n },\n beforeOpen: function(socket, path) {\n socket.send(\n JSON.stringify({\n path: path\n })\n );\n }\n});\n\nvar xdrConfiguration = {\n isSupported: function(environment): boolean {\n var yes = Runtime.isXDRSupported(environment.useTLS);\n return yes;\n }\n};\n\n/** HTTP streaming transport using XDomainRequest (IE 8,9). */\nvar XDRStreamingTransport = new Transport(\n (\n Collections.extend({}, streamingConfiguration, xdrConfiguration)\n )\n);\n\n/** HTTP long-polling transport using XDomainRequest (IE 8,9). */\nvar XDRPollingTransport = new Transport(\n Collections.extend({}, pollingConfiguration, xdrConfiguration)\n);\n\nTransports.xdr_streaming = XDRStreamingTransport;\nTransports.xdr_polling = XDRPollingTransport;\nTransports.sockjs = SockJSTransport;\n\nexport default Transports;\n","import Reachability from 'core/reachability';\nimport { default as EventsDispatcher } from 'core/events/dispatcher';\n\n/** Really basic interface providing network availability info.\n *\n * Emits:\n * - online - when browser goes online\n * - offline - when browser goes offline\n */\nexport class NetInfo extends EventsDispatcher implements Reachability {\n constructor() {\n super();\n var self = this;\n // This is okay, as IE doesn't support this stuff anyway.\n if (window.addEventListener !== undefined) {\n window.addEventListener(\n 'online',\n function() {\n self.emit('online');\n },\n false\n );\n window.addEventListener(\n 'offline',\n function() {\n self.emit('offline');\n },\n false\n );\n }\n }\n\n /** Returns whether browser is online or not\n *\n * Offline means definitely offline (no connection to router).\n * Inverse does NOT mean definitely online (only currently supported in Safari\n * and even there only means the device has a connection to the router).\n *\n * @return {Boolean}\n */\n isOnline(): boolean {\n if (window.navigator.onLine === undefined) {\n return true;\n } else {\n return window.navigator.onLine;\n }\n }\n}\n\nexport var Network = new NetInfo();\n","import Util from '../util';\nimport * as Collections from '../utils/collections';\nimport TransportManager from './transport_manager';\nimport TransportConnection from './transport_connection';\nimport Transport from './transport';\nimport PingDelayOptions from './ping_delay_options';\n\n/** Creates transport connections monitored by a transport manager.\n *\n * When a transport is closed, it might mean the environment does not support\n * it. It's possible that messages get stuck in an intermediate buffer or\n * proxies terminate inactive connections. To combat these problems,\n * assistants monitor the connection lifetime, report unclean exits and\n * adjust ping timeouts to keep the connection active. The decision to disable\n * a transport is the manager's responsibility.\n *\n * @param {TransportManager} manager\n * @param {TransportConnection} transport\n * @param {Object} options\n */\nexport default class AssistantToTheTransportManager {\n manager: TransportManager;\n transport: Transport;\n minPingDelay: number;\n maxPingDelay: number;\n pingDelay: number;\n\n constructor(\n manager: TransportManager,\n transport: Transport,\n options: PingDelayOptions\n ) {\n this.manager = manager;\n this.transport = transport;\n this.minPingDelay = options.minPingDelay;\n this.maxPingDelay = options.maxPingDelay;\n this.pingDelay = undefined;\n }\n\n /** Creates a transport connection.\n *\n * This function has the same API as Transport#createConnection.\n *\n * @param {String} name\n * @param {Number} priority\n * @param {String} key the application key\n * @param {Object} options\n * @returns {TransportConnection}\n */\n createConnection(\n name: string,\n priority: number,\n key: string,\n options: Object\n ): TransportConnection {\n options = Collections.extend({}, options, {\n activityTimeout: this.pingDelay\n });\n var connection = this.transport.createConnection(\n name,\n priority,\n key,\n options\n );\n\n var openTimestamp = null;\n\n var onOpen = function() {\n connection.unbind('open', onOpen);\n connection.bind('closed', onClosed);\n openTimestamp = Util.now();\n };\n var onClosed = closeEvent => {\n connection.unbind('closed', onClosed);\n\n if (closeEvent.code === 1002 || closeEvent.code === 1003) {\n // we don't want to use transports not obeying the protocol\n this.manager.reportDeath();\n } else if (!closeEvent.wasClean && openTimestamp) {\n // report deaths only for short-living transport\n var lifespan = Util.now() - openTimestamp;\n if (lifespan < 2 * this.maxPingDelay) {\n this.manager.reportDeath();\n this.pingDelay = Math.max(lifespan / 2, this.minPingDelay);\n }\n }\n };\n\n connection.bind('open', onOpen);\n return connection;\n }\n\n /** Returns whether the transport is supported in the environment.\n *\n * This function has the same API as Transport#isSupported. Might return false\n * when the manager decides to kill the transport.\n *\n * @param {Object} environment the environment details (encryption, settings)\n * @returns {Boolean} true when the transport is supported\n */\n isSupported(environment: string): boolean {\n return this.manager.isAlive() && this.transport.isSupported(environment);\n }\n}\n","import Action from './action';\nimport { PusherEvent } from './message-types';\n/**\n * Provides functions for handling Pusher protocol-specific messages.\n */\n\nconst Protocol = {\n /**\n * Decodes a message in a Pusher format.\n *\n * The MessageEvent we receive from the transport should contain a pusher event\n * (https://pusher.com/docs/pusher_protocol#events) serialized as JSON in the\n * data field\n *\n * The pusher event may contain a data field too, and it may also be\n * serialised as JSON\n *\n * Throws errors when messages are not parse'able.\n *\n * @param {MessageEvent} messageEvent\n * @return {PusherEvent}\n */\n decodeMessage: function(messageEvent: MessageEvent): PusherEvent {\n try {\n var messageData = JSON.parse(messageEvent.data);\n var pusherEventData = messageData.data;\n if (typeof pusherEventData === 'string') {\n try {\n pusherEventData = JSON.parse(messageData.data);\n } catch (e) {}\n }\n var pusherEvent: PusherEvent = {\n event: messageData.event,\n channel: messageData.channel,\n data: pusherEventData\n };\n if (messageData.user_id) {\n pusherEvent.user_id = messageData.user_id;\n }\n return pusherEvent;\n } catch (e) {\n throw { type: 'MessageParseError', error: e, data: messageEvent.data };\n }\n },\n\n /**\n * Encodes a message to be sent.\n *\n * @param {PusherEvent} event\n * @return {String}\n */\n encodeMessage: function(event: PusherEvent): string {\n return JSON.stringify(event);\n },\n\n /**\n * Processes a handshake message and returns appropriate actions.\n *\n * Returns an object with an 'action' and other action-specific properties.\n *\n * There are three outcomes when calling this function. First is a successful\n * connection attempt, when pusher:connection_established is received, which\n * results in a 'connected' action with an 'id' property. When passed a\n * pusher:error event, it returns a result with action appropriate to the\n * close code and an error. Otherwise, it raises an exception.\n *\n * @param {String} message\n * @result Object\n */\n processHandshake: function(messageEvent: MessageEvent): Action {\n var message = Protocol.decodeMessage(messageEvent);\n\n if (message.event === 'pusher:connection_established') {\n if (!message.data.activity_timeout) {\n throw 'No activity timeout specified in handshake';\n }\n return {\n action: 'connected',\n id: message.data.socket_id,\n activityTimeout: message.data.activity_timeout * 1000\n };\n } else if (message.event === 'pusher:error') {\n // From protocol 6 close codes are sent only once, so this only\n // happens when connection does not support close codes\n return {\n action: this.getCloseAction(message.data),\n error: this.getCloseError(message.data)\n };\n } else {\n throw 'Invalid handshake';\n }\n },\n\n /**\n * Dispatches the close event and returns an appropriate action name.\n *\n * See:\n * 1. https://developer.mozilla.org/en-US/docs/WebSockets/WebSockets_reference/CloseEvent\n * 2. http://pusher.com/docs/pusher_protocol\n *\n * @param {CloseEvent} closeEvent\n * @return {String} close action name\n */\n getCloseAction: function(closeEvent): string {\n if (closeEvent.code < 4000) {\n // ignore 1000 CLOSE_NORMAL, 1001 CLOSE_GOING_AWAY,\n // 1005 CLOSE_NO_STATUS, 1006 CLOSE_ABNORMAL\n // ignore 1007...3999\n // handle 1002 CLOSE_PROTOCOL_ERROR, 1003 CLOSE_UNSUPPORTED,\n // 1004 CLOSE_TOO_LARGE\n if (closeEvent.code >= 1002 && closeEvent.code <= 1004) {\n return 'backoff';\n } else {\n return null;\n }\n } else if (closeEvent.code === 4000) {\n return 'tls_only';\n } else if (closeEvent.code < 4100) {\n return 'refused';\n } else if (closeEvent.code < 4200) {\n return 'backoff';\n } else if (closeEvent.code < 4300) {\n return 'retry';\n } else {\n // unknown error\n return 'refused';\n }\n },\n\n /**\n * Returns an error or null basing on the close event.\n *\n * Null is returned when connection was closed cleanly. Otherwise, an object\n * with error details is returned.\n *\n * @param {CloseEvent} closeEvent\n * @return {Object} error object\n */\n getCloseError: function(closeEvent): any {\n if (closeEvent.code !== 1000 && closeEvent.code !== 1001) {\n return {\n type: 'PusherError',\n data: {\n code: closeEvent.code,\n message: closeEvent.reason || closeEvent.message\n }\n };\n } else {\n return null;\n }\n }\n};\n\nexport default Protocol;\n","import * as Collections from '../utils/collections';\nimport { default as EventsDispatcher } from '../events/dispatcher';\nimport Protocol from './protocol/protocol';\nimport { PusherEvent } from './protocol/message-types';\nimport Logger from '../logger';\nimport TransportConnection from '../transports/transport_connection';\nimport Socket from '../socket';\n/**\n * Provides Pusher protocol interface for transports.\n *\n * Emits following events:\n * - message - on received messages\n * - ping - on ping requests\n * - pong - on pong responses\n * - error - when the transport emits an error\n * - closed - after closing the transport\n *\n * It also emits more events when connection closes with a code.\n * See Protocol.getCloseAction to get more details.\n *\n * @param {Number} id\n * @param {AbstractTransport} transport\n */\nexport default class Connection extends EventsDispatcher implements Socket {\n id: string;\n transport: TransportConnection;\n activityTimeout: number;\n\n constructor(id: string, transport: TransportConnection) {\n super();\n this.id = id;\n this.transport = transport;\n this.activityTimeout = transport.activityTimeout;\n this.bindListeners();\n }\n\n /** Returns whether used transport handles activity checks by itself\n *\n * @returns {Boolean} true if activity checks are handled by the transport\n */\n handlesActivityChecks() {\n return this.transport.handlesActivityChecks();\n }\n\n /** Sends raw data.\n *\n * @param {String} data\n */\n send(data: any): boolean {\n return this.transport.send(data);\n }\n\n /** Sends an event.\n *\n * @param {String} name\n * @param {String} data\n * @param {String} [channel]\n * @returns {Boolean} whether message was sent or not\n */\n send_event(name: string, data: any, channel?: string): boolean {\n var event: PusherEvent = { event: name, data: data };\n if (channel) {\n event.channel = channel;\n }\n Logger.debug('Event sent', event);\n return this.send(Protocol.encodeMessage(event));\n }\n\n /** Sends a ping message to the server.\n *\n * Basing on the underlying transport, it might send either transport's\n * protocol-specific ping or pusher:ping event.\n */\n ping() {\n if (this.transport.supportsPing()) {\n this.transport.ping();\n } else {\n this.send_event('pusher:ping', {});\n }\n }\n\n /** Closes the connection. */\n close() {\n this.transport.close();\n }\n\n private bindListeners() {\n var listeners = {\n message: (messageEvent: MessageEvent) => {\n var pusherEvent;\n try {\n pusherEvent = Protocol.decodeMessage(messageEvent);\n } catch (e) {\n this.emit('error', {\n type: 'MessageParseError',\n error: e,\n data: messageEvent.data\n });\n }\n\n if (pusherEvent !== undefined) {\n Logger.debug('Event recd', pusherEvent);\n\n switch (pusherEvent.event) {\n case 'pusher:error':\n this.emit('error', {\n type: 'PusherError',\n data: pusherEvent.data\n });\n break;\n case 'pusher:ping':\n this.emit('ping');\n break;\n case 'pusher:pong':\n this.emit('pong');\n break;\n }\n this.emit('message', pusherEvent);\n }\n },\n activity: () => {\n this.emit('activity');\n },\n error: error => {\n this.emit('error', error);\n },\n closed: closeEvent => {\n unbindListeners();\n\n if (closeEvent && closeEvent.code) {\n this.handleCloseEvent(closeEvent);\n }\n\n this.transport = null;\n this.emit('closed');\n }\n };\n\n var unbindListeners = () => {\n Collections.objectApply(listeners, (listener, event) => {\n this.transport.unbind(event, listener);\n });\n };\n\n Collections.objectApply(listeners, (listener, event) => {\n this.transport.bind(event, listener);\n });\n }\n\n private handleCloseEvent(closeEvent: any) {\n var action = Protocol.getCloseAction(closeEvent);\n var error = Protocol.getCloseError(closeEvent);\n if (error) {\n this.emit('error', error);\n }\n if (action) {\n this.emit(action, { action: action, error: error });\n }\n }\n}\n","import Util from '../../util';\nimport * as Collections from '../../utils/collections';\nimport Protocol from '../protocol/protocol';\nimport Connection from '../connection';\nimport TransportConnection from '../../transports/transport_connection';\nimport HandshakePayload from './handshake_payload';\n\n/**\n * Handles Pusher protocol handshakes for transports.\n *\n * Calls back with a result object after handshake is completed. Results\n * always have two fields:\n * - action - string describing action to be taken after the handshake\n * - transport - the transport object passed to the constructor\n *\n * Different actions can set different additional properties on the result.\n * In the case of 'connected' action, there will be a 'connection' property\n * containing a Connection object for the transport. Other actions should\n * carry an 'error' property.\n *\n * @param {AbstractTransport} transport\n * @param {Function} callback\n */\nexport default class Handshake {\n transport: TransportConnection;\n callback: (HandshakePayload) => void;\n onMessage: Function;\n onClosed: Function;\n\n constructor(\n transport: TransportConnection,\n callback: (HandshakePayload) => void\n ) {\n this.transport = transport;\n this.callback = callback;\n this.bindListeners();\n }\n\n close() {\n this.unbindListeners();\n this.transport.close();\n }\n\n private bindListeners() {\n this.onMessage = m => {\n this.unbindListeners();\n\n var result;\n try {\n result = Protocol.processHandshake(m);\n } catch (e) {\n this.finish('error', { error: e });\n this.transport.close();\n return;\n }\n\n if (result.action === 'connected') {\n this.finish('connected', {\n connection: new Connection(result.id, this.transport),\n activityTimeout: result.activityTimeout\n });\n } else {\n this.finish(result.action, { error: result.error });\n this.transport.close();\n }\n };\n\n this.onClosed = closeEvent => {\n this.unbindListeners();\n\n var action = Protocol.getCloseAction(closeEvent) || 'backoff';\n var error = Protocol.getCloseError(closeEvent);\n this.finish(action, { error: error });\n };\n\n this.transport.bind('message', this.onMessage);\n this.transport.bind('closed', this.onClosed);\n }\n\n private unbindListeners() {\n this.transport.unbind('message', this.onMessage);\n this.transport.unbind('closed', this.onClosed);\n }\n\n private finish(action: string, params: any) {\n this.callback(\n Collections.extend({ transport: this.transport, action: action }, params)\n );\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport base64encode from '../base64';\nimport Timeline from './timeline';\nimport Runtime from 'runtime';\n\nexport interface TimelineSenderOptions {\n host?: string;\n port?: number;\n path?: string;\n}\n\nexport default class TimelineSender {\n timeline: Timeline;\n options: TimelineSenderOptions;\n host: string;\n\n constructor(timeline: Timeline, options: TimelineSenderOptions) {\n this.timeline = timeline;\n this.options = options || {};\n }\n\n send(useTLS: boolean, callback?: Function) {\n if (this.timeline.isEmpty()) {\n return;\n }\n\n this.timeline.send(\n Runtime.TimelineTransport.getAgent(this, useTLS),\n callback\n );\n }\n}\n","import { default as EventsDispatcher } from '../events/dispatcher';\nimport * as Errors from '../errors';\nimport Logger from '../logger';\nimport Pusher from '../pusher';\nimport { PusherEvent } from '../connection/protocol/message-types';\nimport Metadata from './metadata';\nimport UrlStore from '../utils/url_store';\nimport {\n ChannelAuthorizationData,\n ChannelAuthorizationCallback\n} from '../auth/options';\nimport { HTTPAuthError } from '../errors';\n\n/** Provides base public channel interface with an event emitter.\n *\n * Emits:\n * - pusher:subscription_succeeded - after subscribing successfully\n * - other non-internal events\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\nexport default class Channel extends EventsDispatcher {\n name: string;\n pusher: Pusher;\n subscribed: boolean;\n subscriptionPending: boolean;\n subscriptionCancelled: boolean;\n subscriptionCount: null;\n\n constructor(name: string, pusher: Pusher) {\n super(function(event, data) {\n Logger.debug('No callbacks on ' + name + ' for ' + event);\n });\n\n this.name = name;\n this.pusher = pusher;\n this.subscribed = false;\n this.subscriptionPending = false;\n this.subscriptionCancelled = false;\n }\n\n /** Skips authorization, since public channels don't require it.\n *\n * @param {Function} callback\n */\n authorize(socketId: string, callback: ChannelAuthorizationCallback) {\n return callback(null, { auth: '' });\n }\n\n /** Triggers an event */\n trigger(event: string, data: any) {\n if (event.indexOf('client-') !== 0) {\n throw new Errors.BadEventName(\n \"Event '\" + event + \"' does not start with 'client-'\"\n );\n }\n if (!this.subscribed) {\n var suffix = UrlStore.buildLogSuffix('triggeringClientEvents');\n Logger.warn(\n `Client event triggered before channel 'subscription_succeeded' event . ${suffix}`\n );\n }\n return this.pusher.send_event(event, data, this.name);\n }\n\n /** Signals disconnection to the channel. For internal use only. */\n disconnect() {\n this.subscribed = false;\n this.subscriptionPending = false;\n }\n\n /** Handles a PusherEvent. For internal use only.\n *\n * @param {PusherEvent} event\n */\n handleEvent(event: PusherEvent) {\n var eventName = event.event;\n var data = event.data;\n if (eventName === 'pusher_internal:subscription_succeeded') {\n this.handleSubscriptionSucceededEvent(event);\n } else if (eventName === 'pusher_internal:subscription_count') {\n this.handleSubscriptionCountEvent(event);\n } else if (eventName.indexOf('pusher_internal:') !== 0) {\n var metadata: Metadata = {};\n this.emit(eventName, data, metadata);\n }\n }\n\n handleSubscriptionSucceededEvent(event: PusherEvent) {\n this.subscriptionPending = false;\n this.subscribed = true;\n if (this.subscriptionCancelled) {\n this.pusher.unsubscribe(this.name);\n } else {\n this.emit('pusher:subscription_succeeded', event.data);\n }\n }\n\n handleSubscriptionCountEvent(event: PusherEvent) {\n if (event.data.subscription_count) {\n this.subscriptionCount = event.data.subscription_count;\n }\n\n this.emit('pusher:subscription_count', event.data);\n }\n\n /** Sends a subscription request. For internal use only. */\n subscribe() {\n if (this.subscribed) {\n return;\n }\n this.subscriptionPending = true;\n this.subscriptionCancelled = false;\n this.authorize(\n this.pusher.connection.socket_id,\n (error: Error | null, data: ChannelAuthorizationData) => {\n if (error) {\n this.subscriptionPending = false;\n // Why not bind to 'pusher:subscription_error' a level up, and log there?\n // Binding to this event would cause the warning about no callbacks being\n // bound (see constructor) to be suppressed, that's not what we want.\n Logger.error(error.toString());\n this.emit(\n 'pusher:subscription_error',\n Object.assign(\n {},\n {\n type: 'AuthError',\n error: error.message\n },\n error instanceof HTTPAuthError ? { status: error.status } : {}\n )\n );\n } else {\n this.pusher.send_event('pusher:subscribe', {\n auth: data.auth,\n channel_data: data.channel_data,\n channel: this.name\n });\n }\n }\n );\n }\n\n /** Sends an unsubscription request. For internal use only. */\n unsubscribe() {\n this.subscribed = false;\n this.pusher.send_event('pusher:unsubscribe', {\n channel: this.name\n });\n }\n\n /** Cancels an in progress subscription. For internal use only. */\n cancelSubscription() {\n this.subscriptionCancelled = true;\n }\n\n /** Reinstates an in progress subscripiton. For internal use only. */\n reinstateSubscription() {\n this.subscriptionCancelled = false;\n }\n}\n","import Factory from '../utils/factory';\nimport Channel from './channel';\nimport { ChannelAuthorizationCallback } from '../auth/options';\n\n/** Extends public channels to provide private channel interface.\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\nexport default class PrivateChannel extends Channel {\n /** Authorizes the connection to use the channel.\n *\n * @param {String} socketId\n * @param {Function} callback\n */\n authorize(socketId: string, callback: ChannelAuthorizationCallback) {\n return this.pusher.config.channelAuthorizer(\n {\n channelName: this.name,\n socketId: socketId\n },\n callback\n );\n }\n}\n","import * as Collections from '../utils/collections';\n\n/** Represents a collection of members of a presence channel. */\nexport default class Members {\n members: any;\n count: number;\n myID: any;\n me: any;\n\n constructor() {\n this.reset();\n }\n\n /** Returns member's info for given id.\n *\n * Resulting object containts two fields - id and info.\n *\n * @param {Number} id\n * @return {Object} member's info or null\n */\n get(id: string): any {\n if (Object.prototype.hasOwnProperty.call(this.members, id)) {\n return {\n id: id,\n info: this.members[id]\n };\n } else {\n return null;\n }\n }\n\n /** Calls back for each member in unspecified order.\n *\n * @param {Function} callback\n */\n each(callback: Function) {\n Collections.objectApply(this.members, (member, id) => {\n callback(this.get(id));\n });\n }\n\n /** Updates the id for connected member. For internal use only. */\n setMyID(id: string) {\n this.myID = id;\n }\n\n /** Handles subscription data. For internal use only. */\n onSubscription(subscriptionData: any) {\n this.members = subscriptionData.presence.hash;\n this.count = subscriptionData.presence.count;\n this.me = this.get(this.myID);\n }\n\n /** Adds a new member to the collection. For internal use only. */\n addMember(memberData: any) {\n if (this.get(memberData.user_id) === null) {\n this.count++;\n }\n this.members[memberData.user_id] = memberData.user_info;\n return this.get(memberData.user_id);\n }\n\n /** Adds a member from the collection. For internal use only. */\n removeMember(memberData: any) {\n var member = this.get(memberData.user_id);\n if (member) {\n delete this.members[memberData.user_id];\n this.count--;\n }\n return member;\n }\n\n /** Resets the collection to the initial state. For internal use only. */\n reset() {\n this.members = {};\n this.count = 0;\n this.myID = null;\n this.me = null;\n }\n}\n","import PrivateChannel from './private_channel';\nimport Logger from '../logger';\nimport Members from './members';\nimport Pusher from '../pusher';\nimport UrlStore from 'core/utils/url_store';\nimport { PusherEvent } from '../connection/protocol/message-types';\nimport Metadata from './metadata';\nimport { ChannelAuthorizationData } from '../auth/options';\n\nexport default class PresenceChannel extends PrivateChannel {\n members: Members;\n\n /** Adds presence channel functionality to private channels.\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\n constructor(name: string, pusher: Pusher) {\n super(name, pusher);\n this.members = new Members();\n }\n\n /** Authorizes the connection as a member of the channel.\n *\n * @param {String} socketId\n * @param {Function} callback\n */\n authorize(socketId: string, callback: Function) {\n super.authorize(socketId, async (error, authData) => {\n if (!error) {\n authData = authData as ChannelAuthorizationData;\n if (authData.channel_data != null) {\n var channelData = JSON.parse(authData.channel_data);\n this.members.setMyID(channelData.user_id);\n } else {\n await this.pusher.user.signinDonePromise;\n if (this.pusher.user.user_data != null) {\n // If the user is signed in, get the id of the authenticated user\n // and allow the presence authorization to continue.\n this.members.setMyID(this.pusher.user.user_data.id);\n } else {\n let suffix = UrlStore.buildLogSuffix('authorizationEndpoint');\n Logger.error(\n `Invalid auth response for channel '${this.name}', ` +\n `expected 'channel_data' field. ${suffix}, ` +\n `or the user should be signed in.`\n );\n callback('Invalid auth response');\n return;\n }\n }\n }\n callback(error, authData);\n });\n }\n\n /** Handles presence and subscription events. For internal use only.\n *\n * @param {PusherEvent} event\n */\n handleEvent(event: PusherEvent) {\n var eventName = event.event;\n if (eventName.indexOf('pusher_internal:') === 0) {\n this.handleInternalEvent(event);\n } else {\n var data = event.data;\n var metadata: Metadata = {};\n if (event.user_id) {\n metadata.user_id = event.user_id;\n }\n this.emit(eventName, data, metadata);\n }\n }\n handleInternalEvent(event: PusherEvent) {\n var eventName = event.event;\n var data = event.data;\n switch (eventName) {\n case 'pusher_internal:subscription_succeeded':\n this.handleSubscriptionSucceededEvent(event);\n break;\n case 'pusher_internal:subscription_count':\n this.handleSubscriptionCountEvent(event);\n break;\n case 'pusher_internal:member_added':\n var addedMember = this.members.addMember(data);\n this.emit('pusher:member_added', addedMember);\n break;\n case 'pusher_internal:member_removed':\n var removedMember = this.members.removeMember(data);\n if (removedMember) {\n this.emit('pusher:member_removed', removedMember);\n }\n break;\n }\n }\n\n handleSubscriptionSucceededEvent(event: PusherEvent) {\n this.subscriptionPending = false;\n this.subscribed = true;\n if (this.subscriptionCancelled) {\n this.pusher.unsubscribe(this.name);\n } else {\n this.members.onSubscription(event.data);\n this.emit('pusher:subscription_succeeded', this.members);\n }\n }\n\n /** Resets the channel state, including members map. For internal use only. */\n disconnect() {\n this.members.reset();\n super.disconnect();\n }\n}\n","import PrivateChannel from './private_channel';\nimport * as Errors from '../errors';\nimport Logger from '../logger';\nimport Pusher from '../pusher';\nimport { decode as encodeUTF8 } from '@stablelib/utf8';\nimport { decode as decodeBase64 } from '@stablelib/base64';\nimport Dispatcher from '../events/dispatcher';\nimport { PusherEvent } from '../connection/protocol/message-types';\nimport {\n ChannelAuthorizationData,\n ChannelAuthorizationCallback\n} from '../auth/options';\nimport * as nacl from 'tweetnacl';\n\n/** Extends private channels to provide encrypted channel interface.\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\nexport default class EncryptedChannel extends PrivateChannel {\n key: Uint8Array = null;\n nacl: nacl;\n\n constructor(name: string, pusher: Pusher, nacl: nacl) {\n super(name, pusher);\n this.nacl = nacl;\n }\n\n /** Authorizes the connection to use the channel.\n *\n * @param {String} socketId\n * @param {Function} callback\n */\n authorize(socketId: string, callback: ChannelAuthorizationCallback) {\n super.authorize(\n socketId,\n (error: Error | null, authData: ChannelAuthorizationData) => {\n if (error) {\n callback(error, authData);\n return;\n }\n let sharedSecret = authData['shared_secret'];\n if (!sharedSecret) {\n callback(\n new Error(\n `No shared_secret key in auth payload for encrypted channel: ${this.name}`\n ),\n null\n );\n return;\n }\n this.key = decodeBase64(sharedSecret);\n delete authData['shared_secret'];\n callback(null, authData);\n }\n );\n }\n\n trigger(event: string, data: any): boolean {\n throw new Errors.UnsupportedFeature(\n 'Client events are not currently supported for encrypted channels'\n );\n }\n\n /** Handles an event. For internal use only.\n *\n * @param {PusherEvent} event\n */\n handleEvent(event: PusherEvent) {\n var eventName = event.event;\n var data = event.data;\n if (\n eventName.indexOf('pusher_internal:') === 0 ||\n eventName.indexOf('pusher:') === 0\n ) {\n super.handleEvent(event);\n return;\n }\n this.handleEncryptedEvent(eventName, data);\n }\n\n private handleEncryptedEvent(event: string, data: any): void {\n if (!this.key) {\n Logger.debug(\n 'Received encrypted event before key has been retrieved from the authEndpoint'\n );\n return;\n }\n if (!data.ciphertext || !data.nonce) {\n Logger.error(\n 'Unexpected format for encrypted event, expected object with `ciphertext` and `nonce` fields, got: ' +\n data\n );\n return;\n }\n let cipherText = decodeBase64(data.ciphertext);\n if (cipherText.length < this.nacl.secretbox.overheadLength) {\n Logger.error(\n `Expected encrypted event ciphertext length to be ${this.nacl.secretbox.overheadLength}, got: ${cipherText.length}`\n );\n return;\n }\n let nonce = decodeBase64(data.nonce);\n if (nonce.length < this.nacl.secretbox.nonceLength) {\n Logger.error(\n `Expected encrypted event nonce length to be ${this.nacl.secretbox.nonceLength}, got: ${nonce.length}`\n );\n return;\n }\n\n let bytes = this.nacl.secretbox.open(cipherText, nonce, this.key);\n if (bytes === null) {\n Logger.debug(\n 'Failed to decrypt an event, probably because it was encrypted with a different key. Fetching a new key from the authEndpoint...'\n );\n // Try a single time to retrieve a new auth key and decrypt the event with it\n // If this fails, a new key will be requested when a new message is received\n this.authorize(this.pusher.connection.socket_id, (error, authData) => {\n if (error) {\n Logger.error(\n `Failed to make a request to the authEndpoint: ${authData}. Unable to fetch new key, so dropping encrypted event`\n );\n return;\n }\n bytes = this.nacl.secretbox.open(cipherText, nonce, this.key);\n if (bytes === null) {\n Logger.error(\n `Failed to decrypt event with new key. Dropping encrypted event`\n );\n return;\n }\n this.emit(event, this.getDataToEmit(bytes));\n return;\n });\n return;\n }\n this.emit(event, this.getDataToEmit(bytes));\n }\n\n // Try and parse the decrypted bytes as JSON. If we can't parse it, just\n // return the utf-8 string\n getDataToEmit(bytes: Uint8Array): string {\n let raw = encodeUTF8(bytes);\n try {\n return JSON.parse(raw);\n } catch {\n return raw;\n }\n }\n}\n","import { default as EventsDispatcher } from '../events/dispatcher';\nimport { OneOffTimer as Timer } from '../utils/timers';\nimport { Config } from '../config';\nimport Logger from '../logger';\nimport HandshakePayload from './handshake/handshake_payload';\nimport Connection from './connection';\nimport Strategy from '../strategies/strategy';\nimport StrategyRunner from '../strategies/strategy_runner';\nimport * as Collections from '../utils/collections';\nimport Timeline from '../timeline/timeline';\nimport ConnectionManagerOptions from './connection_manager_options';\nimport Runtime from 'runtime';\n\nimport {\n ErrorCallbacks,\n HandshakeCallbacks,\n ConnectionCallbacks\n} from './callbacks';\nimport Action from './protocol/action';\n\n/** Manages connection to Pusher.\n *\n * Uses a strategy (currently only default), timers and network availability\n * info to establish a connection and export its state. In case of failures,\n * manages reconnection attempts.\n *\n * Exports state changes as following events:\n * - \"state_change\", { previous: p, current: state }\n * - state\n *\n * States:\n * - initialized - initial state, never transitioned to\n * - connecting - connection is being established\n * - connected - connection has been fully established\n * - disconnected - on requested disconnection\n * - unavailable - after connection timeout or when there's no network\n * - failed - when the connection strategy is not supported\n *\n * Options:\n * - unavailableTimeout - time to transition to unavailable state\n * - activityTimeout - time after which ping message should be sent\n * - pongTimeout - time for Pusher to respond with pong before reconnecting\n *\n * @param {String} key application key\n * @param {Object} options\n */\nexport default class ConnectionManager extends EventsDispatcher {\n key: string;\n options: ConnectionManagerOptions;\n state: string;\n connection: Connection;\n usingTLS: boolean;\n timeline: Timeline;\n socket_id: string;\n unavailableTimer: Timer;\n activityTimer: Timer;\n retryTimer: Timer;\n activityTimeout: number;\n strategy: Strategy;\n runner: StrategyRunner;\n errorCallbacks: ErrorCallbacks;\n handshakeCallbacks: HandshakeCallbacks;\n connectionCallbacks: ConnectionCallbacks;\n\n constructor(key: string, options: ConnectionManagerOptions) {\n super();\n this.state = 'initialized';\n this.connection = null;\n\n this.key = key;\n this.options = options;\n this.timeline = this.options.timeline;\n this.usingTLS = this.options.useTLS;\n\n this.errorCallbacks = this.buildErrorCallbacks();\n this.connectionCallbacks = this.buildConnectionCallbacks(\n this.errorCallbacks\n );\n this.handshakeCallbacks = this.buildHandshakeCallbacks(this.errorCallbacks);\n\n var Network = Runtime.getNetwork();\n\n Network.bind('online', () => {\n this.timeline.info({ netinfo: 'online' });\n if (this.state === 'connecting' || this.state === 'unavailable') {\n this.retryIn(0);\n }\n });\n Network.bind('offline', () => {\n this.timeline.info({ netinfo: 'offline' });\n if (this.connection) {\n this.sendActivityCheck();\n }\n });\n\n this.updateStrategy();\n }\n\n switchCluster(key: string) {\n this.key = key;\n // This ensures that the new config coming from\n // pusher instance are taken into account\n // such as appKey and cluster\n this.updateStrategy();\n this.retryIn(0);\n }\n\n /** Establishes a connection to Pusher.\n *\n * Does nothing when connection is already established. See top-level doc\n * to find events emitted on connection attempts.\n */\n connect() {\n if (this.connection || this.runner) {\n return;\n }\n if (!this.strategy.isSupported()) {\n this.updateState('failed');\n return;\n }\n this.updateState('connecting');\n this.startConnecting();\n this.setUnavailableTimer();\n }\n\n /** Sends raw data.\n *\n * @param {String} data\n */\n send(data) {\n if (this.connection) {\n return this.connection.send(data);\n } else {\n return false;\n }\n }\n\n /** Sends an event.\n *\n * @param {String} name\n * @param {String} data\n * @param {String} [channel]\n * @returns {Boolean} whether message was sent or not\n */\n send_event(name: string, data: any, channel?: string) {\n if (this.connection) {\n return this.connection.send_event(name, data, channel);\n } else {\n return false;\n }\n }\n\n /** Closes the connection. */\n disconnect() {\n this.disconnectInternally();\n this.updateState('disconnected');\n }\n\n isUsingTLS() {\n return this.usingTLS;\n }\n\n private startConnecting() {\n var callback = (error, handshake) => {\n if (error) {\n this.runner = this.strategy.connect(0, callback);\n } else {\n if (handshake.action === 'error') {\n this.emit('error', {\n type: 'HandshakeError',\n error: handshake.error\n });\n this.timeline.error({ handshakeError: handshake.error });\n } else {\n this.abortConnecting(); // we don't support switching connections yet\n this.handshakeCallbacks[handshake.action](handshake);\n }\n }\n };\n this.runner = this.strategy.connect(0, callback);\n }\n\n private abortConnecting() {\n if (this.runner) {\n this.runner.abort();\n this.runner = null;\n }\n }\n\n private disconnectInternally() {\n this.abortConnecting();\n this.clearRetryTimer();\n this.clearUnavailableTimer();\n if (this.connection) {\n var connection = this.abandonConnection();\n connection.close();\n }\n }\n\n private updateStrategy() {\n this.strategy = this.options.getStrategy({\n key: this.key,\n timeline: this.timeline,\n useTLS: this.usingTLS\n });\n }\n\n private retryIn(delay) {\n this.timeline.info({ action: 'retry', delay: delay });\n if (delay > 0) {\n this.emit('connecting_in', Math.round(delay / 1000));\n }\n this.retryTimer = new Timer(delay || 0, () => {\n this.disconnectInternally();\n this.connect();\n });\n }\n\n private clearRetryTimer() {\n if (this.retryTimer) {\n this.retryTimer.ensureAborted();\n this.retryTimer = null;\n }\n }\n\n private setUnavailableTimer() {\n this.unavailableTimer = new Timer(this.options.unavailableTimeout, () => {\n this.updateState('unavailable');\n });\n }\n\n private clearUnavailableTimer() {\n if (this.unavailableTimer) {\n this.unavailableTimer.ensureAborted();\n }\n }\n\n private sendActivityCheck() {\n this.stopActivityCheck();\n this.connection.ping();\n // wait for pong response\n this.activityTimer = new Timer(this.options.pongTimeout, () => {\n this.timeline.error({ pong_timed_out: this.options.pongTimeout });\n this.retryIn(0);\n });\n }\n\n private resetActivityCheck() {\n this.stopActivityCheck();\n // send ping after inactivity\n if (this.connection && !this.connection.handlesActivityChecks()) {\n this.activityTimer = new Timer(this.activityTimeout, () => {\n this.sendActivityCheck();\n });\n }\n }\n\n private stopActivityCheck() {\n if (this.activityTimer) {\n this.activityTimer.ensureAborted();\n }\n }\n\n private buildConnectionCallbacks(\n errorCallbacks: ErrorCallbacks\n ): ConnectionCallbacks {\n return Collections.extend({}, errorCallbacks, {\n message: message => {\n // includes pong messages from server\n this.resetActivityCheck();\n this.emit('message', message);\n },\n ping: () => {\n this.send_event('pusher:pong', {});\n },\n activity: () => {\n this.resetActivityCheck();\n },\n error: error => {\n // just emit error to user - socket will already be closed by browser\n this.emit('error', error);\n },\n closed: () => {\n this.abandonConnection();\n if (this.shouldRetry()) {\n this.retryIn(1000);\n }\n }\n });\n }\n\n private buildHandshakeCallbacks(\n errorCallbacks: ErrorCallbacks\n ): HandshakeCallbacks {\n return Collections.extend({}, errorCallbacks, {\n connected: (handshake: HandshakePayload) => {\n this.activityTimeout = Math.min(\n this.options.activityTimeout,\n handshake.activityTimeout,\n handshake.connection.activityTimeout || Infinity\n );\n this.clearUnavailableTimer();\n this.setConnection(handshake.connection);\n this.socket_id = this.connection.id;\n this.updateState('connected', { socket_id: this.socket_id });\n }\n });\n }\n\n private buildErrorCallbacks(): ErrorCallbacks {\n let withErrorEmitted = callback => {\n return (result: Action | HandshakePayload) => {\n if (result.error) {\n this.emit('error', { type: 'WebSocketError', error: result.error });\n }\n callback(result);\n };\n };\n\n return {\n tls_only: withErrorEmitted(() => {\n this.usingTLS = true;\n this.updateStrategy();\n this.retryIn(0);\n }),\n refused: withErrorEmitted(() => {\n this.disconnect();\n }),\n backoff: withErrorEmitted(() => {\n this.retryIn(1000);\n }),\n retry: withErrorEmitted(() => {\n this.retryIn(0);\n })\n };\n }\n\n private setConnection(connection) {\n this.connection = connection;\n for (var event in this.connectionCallbacks) {\n this.connection.bind(event, this.connectionCallbacks[event]);\n }\n this.resetActivityCheck();\n }\n\n private abandonConnection() {\n if (!this.connection) {\n return;\n }\n this.stopActivityCheck();\n for (var event in this.connectionCallbacks) {\n this.connection.unbind(event, this.connectionCallbacks[event]);\n }\n var connection = this.connection;\n this.connection = null;\n return connection;\n }\n\n private updateState(newState: string, data?: any) {\n var previousState = this.state;\n this.state = newState;\n if (previousState !== newState) {\n var newStateDescription = newState;\n if (newStateDescription === 'connected') {\n newStateDescription += ' with new socket ID ' + data.socket_id;\n }\n Logger.debug(\n 'State changed',\n previousState + ' -> ' + newStateDescription\n );\n this.timeline.info({ state: newState, params: data });\n this.emit('state_change', { previous: previousState, current: newState });\n this.emit(newState, data);\n }\n }\n\n private shouldRetry(): boolean {\n return this.state === 'connecting' || this.state === 'connected';\n }\n}\n","import Channel from './channel';\nimport * as Collections from '../utils/collections';\nimport ChannelTable from './channel_table';\nimport Factory from '../utils/factory';\nimport Pusher from '../pusher';\nimport Logger from '../logger';\nimport * as Errors from '../errors';\nimport urlStore from '../utils/url_store';\n\n/** Handles a channel map. */\nexport default class Channels {\n channels: ChannelTable;\n\n constructor() {\n this.channels = {};\n }\n\n /** Creates or retrieves an existing channel by its name.\n *\n * @param {String} name\n * @param {Pusher} pusher\n * @return {Channel}\n */\n add(name: string, pusher: Pusher) {\n if (!this.channels[name]) {\n this.channels[name] = createChannel(name, pusher);\n }\n return this.channels[name];\n }\n\n /** Returns a list of all channels\n *\n * @return {Array}\n */\n all(): Channel[] {\n return Collections.values(this.channels);\n }\n\n /** Finds a channel by its name.\n *\n * @param {String} name\n * @return {Channel} channel or null if it doesn't exist\n */\n find(name: string) {\n return this.channels[name];\n }\n\n /** Removes a channel from the map.\n *\n * @param {String} name\n */\n remove(name: string) {\n var channel = this.channels[name];\n delete this.channels[name];\n return channel;\n }\n\n /** Proxies disconnection signal to all channels. */\n disconnect() {\n Collections.objectApply(this.channels, function(channel) {\n channel.disconnect();\n });\n }\n}\n\nfunction createChannel(name: string, pusher: Pusher): Channel {\n if (name.indexOf('private-encrypted-') === 0) {\n if (pusher.config.nacl) {\n return Factory.createEncryptedChannel(name, pusher, pusher.config.nacl);\n }\n let errMsg =\n 'Tried to subscribe to a private-encrypted- channel but no nacl implementation available';\n let suffix = urlStore.buildLogSuffix('encryptedChannelSupport');\n throw new Errors.UnsupportedFeature(`${errMsg}. ${suffix}`);\n } else if (name.indexOf('private-') === 0) {\n return Factory.createPrivateChannel(name, pusher);\n } else if (name.indexOf('presence-') === 0) {\n return Factory.createPresenceChannel(name, pusher);\n } else if (name.indexOf('#') === 0) {\n throw new Errors.BadChannelName(\n 'Cannot create a channel with name \"' + name + '\".'\n );\n } else {\n return Factory.createChannel(name, pusher);\n }\n}\n","import AssistantToTheTransportManager from '../transports/assistant_to_the_transport_manager';\nimport PingDelayOptions from '../transports/ping_delay_options';\nimport Transport from '../transports/transport';\nimport TransportManager from '../transports/transport_manager';\nimport Handshake from '../connection/handshake';\nimport TransportConnection from '../transports/transport_connection';\nimport SocketHooks from '../http/socket_hooks';\nimport HTTPSocket from '../http/http_socket';\n\nimport Timeline from '../timeline/timeline';\nimport {\n default as TimelineSender,\n TimelineSenderOptions\n} from '../timeline/timeline_sender';\nimport PresenceChannel from '../channels/presence_channel';\nimport PrivateChannel from '../channels/private_channel';\nimport EncryptedChannel from '../channels/encrypted_channel';\nimport Channel from '../channels/channel';\nimport ConnectionManager from '../connection/connection_manager';\nimport ConnectionManagerOptions from '../connection/connection_manager_options';\nimport Ajax from '../http/ajax';\nimport Channels from '../channels/channels';\nimport Pusher from '../pusher';\nimport { Config } from '../config';\nimport * as nacl from 'tweetnacl';\n\nvar Factory = {\n createChannels(): Channels {\n return new Channels();\n },\n\n createConnectionManager(\n key: string,\n options: ConnectionManagerOptions\n ): ConnectionManager {\n return new ConnectionManager(key, options);\n },\n\n createChannel(name: string, pusher: Pusher): Channel {\n return new Channel(name, pusher);\n },\n\n createPrivateChannel(name: string, pusher: Pusher): PrivateChannel {\n return new PrivateChannel(name, pusher);\n },\n\n createPresenceChannel(name: string, pusher: Pusher): PresenceChannel {\n return new PresenceChannel(name, pusher);\n },\n\n createEncryptedChannel(\n name: string,\n pusher: Pusher,\n nacl: nacl\n ): EncryptedChannel {\n return new EncryptedChannel(name, pusher, nacl);\n },\n\n createTimelineSender(timeline: Timeline, options: TimelineSenderOptions) {\n return new TimelineSender(timeline, options);\n },\n\n createHandshake(\n transport: TransportConnection,\n callback: (HandshakePayload) => void\n ): Handshake {\n return new Handshake(transport, callback);\n },\n\n createAssistantToTheTransportManager(\n manager: TransportManager,\n transport: Transport,\n options: PingDelayOptions\n ): AssistantToTheTransportManager {\n return new AssistantToTheTransportManager(manager, transport, options);\n }\n};\n\nexport default Factory;\n","import AssistantToTheTransportManager from './assistant_to_the_transport_manager';\nimport Transport from './transport';\nimport PingDelayOptions from './ping_delay_options';\nimport Factory from '../utils/factory';\n\nexport interface TransportManagerOptions extends PingDelayOptions {\n lives?: number;\n}\n\n/** Keeps track of the number of lives left for a transport.\n *\n * In the beginning of a session, transports may be assigned a number of\n * lives. When an AssistantToTheTransportManager instance reports a transport\n * connection closed uncleanly, the transport loses a life. When the number\n * of lives drops to zero, the transport gets disabled by its manager.\n *\n * @param {Object} options\n */\nexport default class TransportManager {\n options: TransportManagerOptions;\n livesLeft: number;\n\n constructor(options: TransportManagerOptions) {\n this.options = options || {};\n this.livesLeft = this.options.lives || Infinity;\n }\n\n /** Creates a assistant for the transport.\n *\n * @param {Transport} transport\n * @returns {AssistantToTheTransportManager}\n */\n getAssistant(transport: Transport): AssistantToTheTransportManager {\n return Factory.createAssistantToTheTransportManager(this, transport, {\n minPingDelay: this.options.minPingDelay,\n maxPingDelay: this.options.maxPingDelay\n });\n }\n\n /** Returns whether the transport has any lives left.\n *\n * @returns {Boolean}\n */\n isAlive(): boolean {\n return this.livesLeft > 0;\n }\n\n /** Takes one life from the transport. */\n reportDeath() {\n this.livesLeft -= 1;\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport { OneOffTimer as Timer } from '../utils/timers';\nimport Strategy from './strategy';\nimport StrategyOptions from './strategy_options';\n\n/** Loops through strategies with optional timeouts.\n *\n * Options:\n * - loop - whether it should loop through the substrategy list\n * - timeout - initial timeout for a single substrategy\n * - timeoutLimit - maximum timeout\n *\n * @param {Strategy[]} strategies\n * @param {Object} options\n */\nexport default class SequentialStrategy implements Strategy {\n strategies: Strategy[];\n loop: boolean;\n failFast: boolean;\n timeout: number;\n timeoutLimit: number;\n\n constructor(strategies: Strategy[], options: StrategyOptions) {\n this.strategies = strategies;\n this.loop = Boolean(options.loop);\n this.failFast = Boolean(options.failFast);\n this.timeout = options.timeout;\n this.timeoutLimit = options.timeoutLimit;\n }\n\n isSupported(): boolean {\n return Collections.any(this.strategies, Util.method('isSupported'));\n }\n\n connect(minPriority: number, callback: Function) {\n var strategies = this.strategies;\n var current = 0;\n var timeout = this.timeout;\n var runner = null;\n\n var tryNextStrategy = (error, handshake) => {\n if (handshake) {\n callback(null, handshake);\n } else {\n current = current + 1;\n if (this.loop) {\n current = current % strategies.length;\n }\n\n if (current < strategies.length) {\n if (timeout) {\n timeout = timeout * 2;\n if (this.timeoutLimit) {\n timeout = Math.min(timeout, this.timeoutLimit);\n }\n }\n runner = this.tryStrategy(\n strategies[current],\n minPriority,\n { timeout, failFast: this.failFast },\n tryNextStrategy\n );\n } else {\n callback(true);\n }\n }\n };\n\n runner = this.tryStrategy(\n strategies[current],\n minPriority,\n { timeout: timeout, failFast: this.failFast },\n tryNextStrategy\n );\n\n return {\n abort: function() {\n runner.abort();\n },\n forceMinPriority: function(p) {\n minPriority = p;\n if (runner) {\n runner.forceMinPriority(p);\n }\n }\n };\n }\n\n private tryStrategy(\n strategy: Strategy,\n minPriority: number,\n options: StrategyOptions,\n callback: Function\n ) {\n var timer = null;\n var runner = null;\n\n if (options.timeout > 0) {\n timer = new Timer(options.timeout, function() {\n runner.abort();\n callback(true);\n });\n }\n\n runner = strategy.connect(minPriority, function(error, handshake) {\n if (error && timer && timer.isRunning() && !options.failFast) {\n // advance to the next strategy after the timeout\n return;\n }\n if (timer) {\n timer.ensureAborted();\n }\n callback(error, handshake);\n });\n\n return {\n abort: function() {\n if (timer) {\n timer.ensureAborted();\n }\n runner.abort();\n },\n forceMinPriority: function(p) {\n runner.forceMinPriority(p);\n }\n };\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport Strategy from './strategy';\n\n/** Launches all substrategies and emits prioritized connected transports.\n *\n * @param {Array} strategies\n */\nexport default class BestConnectedEverStrategy implements Strategy {\n strategies: Strategy[];\n\n constructor(strategies: Strategy[]) {\n this.strategies = strategies;\n }\n\n isSupported(): boolean {\n return Collections.any(this.strategies, Util.method('isSupported'));\n }\n\n connect(minPriority: number, callback: Function) {\n return connect(this.strategies, minPriority, function(i, runners) {\n return function(error, handshake) {\n runners[i].error = error;\n if (error) {\n if (allRunnersFailed(runners)) {\n callback(true);\n }\n return;\n }\n Collections.apply(runners, function(runner) {\n runner.forceMinPriority(handshake.transport.priority);\n });\n callback(null, handshake);\n };\n });\n }\n}\n\n/** Connects to all strategies in parallel.\n *\n * Callback builder should be a function that takes two arguments: index\n * and a list of runners. It should return another function that will be\n * passed to the substrategy with given index. Runners can be aborted using\n * abortRunner(s) functions from this class.\n *\n * @param {Array} strategies\n * @param {Function} callbackBuilder\n * @return {Object} strategy runner\n */\nfunction connect(\n strategies: Strategy[],\n minPriority: number,\n callbackBuilder: Function\n) {\n var runners = Collections.map(strategies, function(strategy, i, _, rs) {\n return strategy.connect(minPriority, callbackBuilder(i, rs));\n });\n return {\n abort: function() {\n Collections.apply(runners, abortRunner);\n },\n forceMinPriority: function(p) {\n Collections.apply(runners, function(runner) {\n runner.forceMinPriority(p);\n });\n }\n };\n}\n\nfunction allRunnersFailed(runners): boolean {\n return Collections.all(runners, function(runner) {\n return Boolean(runner.error);\n });\n}\n\nfunction abortRunner(runner) {\n if (!runner.error && !runner.aborted) {\n runner.abort();\n runner.aborted = true;\n }\n}\n","import Util from '../util';\nimport Runtime from 'runtime';\nimport Strategy from './strategy';\nimport SequentialStrategy from './sequential_strategy';\nimport StrategyOptions from './strategy_options';\nimport TransportStrategy from './transport_strategy';\nimport Timeline from '../timeline/timeline';\nimport * as Collections from '../utils/collections';\n\nexport interface TransportStrategyDictionary {\n [key: string]: TransportStrategy;\n}\n\n/** Caches the last successful transport and, after the first few attempts,\n * uses the cached transport for subsequent attempts.\n *\n * @param {Strategy} strategy\n * @param {Object} transports\n * @param {Object} options\n */\nexport default class WebSocketPrioritizedCachedStrategy implements Strategy {\n strategy: Strategy;\n transports: TransportStrategyDictionary;\n ttl: number;\n usingTLS: boolean;\n timeline: Timeline;\n\n constructor(\n strategy: Strategy,\n transports: TransportStrategyDictionary,\n options: StrategyOptions\n ) {\n this.strategy = strategy;\n this.transports = transports;\n this.ttl = options.ttl || 1800 * 1000;\n this.usingTLS = options.useTLS;\n this.timeline = options.timeline;\n }\n\n isSupported(): boolean {\n return this.strategy.isSupported();\n }\n\n connect(minPriority: number, callback: Function) {\n var usingTLS = this.usingTLS;\n var info = fetchTransportCache(usingTLS);\n var cacheSkipCount = info && info.cacheSkipCount ? info.cacheSkipCount : 0;\n\n var strategies = [this.strategy];\n if (info && info.timestamp + this.ttl >= Util.now()) {\n var transport = this.transports[info.transport];\n if (transport) {\n if (['ws', 'wss'].includes(info.transport) || cacheSkipCount > 3) {\n this.timeline.info({\n cached: true,\n transport: info.transport,\n latency: info.latency\n });\n strategies.push(\n new SequentialStrategy([transport], {\n timeout: info.latency * 2 + 1000,\n failFast: true\n })\n );\n } else {\n cacheSkipCount++;\n }\n }\n }\n\n var startTimestamp = Util.now();\n var runner = strategies\n .pop()\n .connect(minPriority, function cb(error, handshake) {\n if (error) {\n flushTransportCache(usingTLS);\n if (strategies.length > 0) {\n startTimestamp = Util.now();\n runner = strategies.pop().connect(minPriority, cb);\n } else {\n callback(error);\n }\n } else {\n storeTransportCache(\n usingTLS,\n handshake.transport.name,\n Util.now() - startTimestamp,\n cacheSkipCount\n );\n callback(null, handshake);\n }\n });\n\n return {\n abort: function() {\n runner.abort();\n },\n forceMinPriority: function(p) {\n minPriority = p;\n if (runner) {\n runner.forceMinPriority(p);\n }\n }\n };\n }\n}\n\nfunction getTransportCacheKey(usingTLS: boolean): string {\n return 'pusherTransport' + (usingTLS ? 'TLS' : 'NonTLS');\n}\n\nfunction fetchTransportCache(usingTLS: boolean): any {\n var storage = Runtime.getLocalStorage();\n if (storage) {\n try {\n var serializedCache = storage[getTransportCacheKey(usingTLS)];\n if (serializedCache) {\n return JSON.parse(serializedCache);\n }\n } catch (e) {\n flushTransportCache(usingTLS);\n }\n }\n return null;\n}\n\nfunction storeTransportCache(\n usingTLS: boolean,\n transport: TransportStrategy,\n latency: number,\n cacheSkipCount: number\n) {\n var storage = Runtime.getLocalStorage();\n if (storage) {\n try {\n storage[getTransportCacheKey(usingTLS)] = Collections.safeJSONStringify({\n timestamp: Util.now(),\n transport: transport,\n latency: latency,\n cacheSkipCount: cacheSkipCount\n });\n } catch (e) {\n // catch over quota exceptions raised by localStorage\n }\n }\n}\n\nfunction flushTransportCache(usingTLS: boolean) {\n var storage = Runtime.getLocalStorage();\n if (storage) {\n try {\n delete storage[getTransportCacheKey(usingTLS)];\n } catch (e) {\n // catch exceptions raised by localStorage\n }\n }\n}\n","import { OneOffTimer as Timer } from '../utils/timers';\nimport Strategy from './strategy';\nimport StrategyOptions from './strategy_options';\n\n/** Runs substrategy after specified delay.\n *\n * Options:\n * - delay - time in miliseconds to delay the substrategy attempt\n *\n * @param {Strategy} strategy\n * @param {Object} options\n */\nexport default class DelayedStrategy implements Strategy {\n strategy: Strategy;\n options: { delay: number };\n\n constructor(strategy: Strategy, { delay: number }) {\n this.strategy = strategy;\n this.options = { delay: number };\n }\n\n isSupported(): boolean {\n return this.strategy.isSupported();\n }\n\n connect(minPriority: number, callback: Function) {\n var strategy = this.strategy;\n var runner;\n var timer = new Timer(this.options.delay, function() {\n runner = strategy.connect(minPriority, callback);\n });\n\n return {\n abort: function() {\n timer.ensureAborted();\n if (runner) {\n runner.abort();\n }\n },\n forceMinPriority: function(p) {\n minPriority = p;\n if (runner) {\n runner.forceMinPriority(p);\n }\n }\n };\n }\n}\n","import Strategy from './strategy';\nimport StrategyRunner from './strategy_runner';\n\n/** Proxies method calls to one of substrategies basing on the test function.\n *\n * @param {Function} test\n * @param {Strategy} trueBranch strategy used when test returns true\n * @param {Strategy} falseBranch strategy used when test returns false\n */\nexport default class IfStrategy implements Strategy {\n test: () => boolean;\n trueBranch: Strategy;\n falseBranch: Strategy;\n\n constructor(\n test: () => boolean,\n trueBranch: Strategy,\n falseBranch: Strategy\n ) {\n this.test = test;\n this.trueBranch = trueBranch;\n this.falseBranch = falseBranch;\n }\n\n isSupported(): boolean {\n var branch = this.test() ? this.trueBranch : this.falseBranch;\n return branch.isSupported();\n }\n\n connect(minPriority: number, callback: Function): StrategyRunner {\n var branch = this.test() ? this.trueBranch : this.falseBranch;\n return branch.connect(minPriority, callback);\n }\n}\n","import Strategy from './strategy';\nimport StrategyRunner from './strategy_runner';\n\n/** Launches the substrategy and terminates on the first open connection.\n *\n * @param {Strategy} strategy\n */\nexport default class FirstConnectedStrategy implements Strategy {\n strategy: Strategy;\n\n constructor(strategy: Strategy) {\n this.strategy = strategy;\n }\n\n isSupported(): boolean {\n return this.strategy.isSupported();\n }\n\n connect(minPriority: number, callback: Function): StrategyRunner {\n var runner = this.strategy.connect(minPriority, function(error, handshake) {\n if (handshake) {\n runner.abort();\n }\n callback(error, handshake);\n });\n return runner;\n }\n}\n","import * as Collections from 'core/utils/collections';\nimport TransportManager from 'core/transports/transport_manager';\nimport Strategy from 'core/strategies/strategy';\nimport StrategyOptions from 'core/strategies/strategy_options';\nimport SequentialStrategy from 'core/strategies/sequential_strategy';\nimport BestConnectedEverStrategy from 'core/strategies/best_connected_ever_strategy';\nimport WebSocketPrioritizedCachedStrategy, {\n TransportStrategyDictionary\n} from 'core/strategies/websocket_prioritized_cached_strategy';\nimport DelayedStrategy from 'core/strategies/delayed_strategy';\nimport IfStrategy from 'core/strategies/if_strategy';\nimport FirstConnectedStrategy from 'core/strategies/first_connected_strategy';\nimport { Config } from 'core/config';\n\nfunction testSupportsStrategy(strategy: Strategy) {\n return function() {\n return strategy.isSupported();\n };\n}\n\nvar getDefaultStrategy = function(\n config: Config,\n baseOptions: StrategyOptions,\n defineTransport: Function\n): Strategy {\n var definedTransports = {};\n\n function defineTransportStrategy(\n name: string,\n type: string,\n priority: number,\n options: StrategyOptions,\n manager?: TransportManager\n ) {\n var transport = defineTransport(\n config,\n name,\n type,\n priority,\n options,\n manager\n );\n\n definedTransports[name] = transport;\n\n return transport;\n }\n\n var ws_options: StrategyOptions = Object.assign({}, baseOptions, {\n hostNonTLS: config.wsHost + ':' + config.wsPort,\n hostTLS: config.wsHost + ':' + config.wssPort,\n httpPath: config.wsPath\n });\n var wss_options: StrategyOptions = Object.assign({}, ws_options, {\n useTLS: true\n });\n var sockjs_options: StrategyOptions = Object.assign({}, baseOptions, {\n hostNonTLS: config.httpHost + ':' + config.httpPort,\n hostTLS: config.httpHost + ':' + config.httpsPort,\n httpPath: config.httpPath\n });\n\n var timeouts = {\n loop: true,\n timeout: 15000,\n timeoutLimit: 60000\n };\n\n var ws_manager = new TransportManager({\n minPingDelay: 10000,\n maxPingDelay: config.activityTimeout\n });\n var streaming_manager = new TransportManager({\n lives: 2,\n minPingDelay: 10000,\n maxPingDelay: config.activityTimeout\n });\n\n var ws_transport = defineTransportStrategy(\n 'ws',\n 'ws',\n 3,\n ws_options,\n ws_manager\n );\n var wss_transport = defineTransportStrategy(\n 'wss',\n 'ws',\n 3,\n wss_options,\n ws_manager\n );\n var sockjs_transport = defineTransportStrategy(\n 'sockjs',\n 'sockjs',\n 1,\n sockjs_options\n );\n var xhr_streaming_transport = defineTransportStrategy(\n 'xhr_streaming',\n 'xhr_streaming',\n 1,\n sockjs_options,\n streaming_manager\n );\n var xdr_streaming_transport = defineTransportStrategy(\n 'xdr_streaming',\n 'xdr_streaming',\n 1,\n sockjs_options,\n streaming_manager\n );\n var xhr_polling_transport = defineTransportStrategy(\n 'xhr_polling',\n 'xhr_polling',\n 1,\n sockjs_options\n );\n var xdr_polling_transport = defineTransportStrategy(\n 'xdr_polling',\n 'xdr_polling',\n 1,\n sockjs_options\n );\n\n var ws_loop = new SequentialStrategy([ws_transport], timeouts);\n var wss_loop = new SequentialStrategy([wss_transport], timeouts);\n var sockjs_loop = new SequentialStrategy([sockjs_transport], timeouts);\n var streaming_loop = new SequentialStrategy(\n [\n new IfStrategy(\n testSupportsStrategy(xhr_streaming_transport),\n xhr_streaming_transport,\n xdr_streaming_transport\n )\n ],\n timeouts\n );\n var polling_loop = new SequentialStrategy(\n [\n new IfStrategy(\n testSupportsStrategy(xhr_polling_transport),\n xhr_polling_transport,\n xdr_polling_transport\n )\n ],\n timeouts\n );\n\n var http_loop = new SequentialStrategy(\n [\n new IfStrategy(\n testSupportsStrategy(streaming_loop),\n new BestConnectedEverStrategy([\n streaming_loop,\n new DelayedStrategy(polling_loop, { delay: 4000 })\n ]),\n polling_loop\n )\n ],\n timeouts\n );\n\n var http_fallback_loop = new IfStrategy(\n testSupportsStrategy(http_loop),\n http_loop,\n sockjs_loop\n );\n\n var wsStrategy;\n if (baseOptions.useTLS) {\n wsStrategy = new BestConnectedEverStrategy([\n ws_loop,\n new DelayedStrategy(http_fallback_loop, { delay: 2000 })\n ]);\n } else {\n wsStrategy = new BestConnectedEverStrategy([\n ws_loop,\n new DelayedStrategy(wss_loop, { delay: 2000 }),\n new DelayedStrategy(http_fallback_loop, { delay: 5000 })\n ]);\n }\n\n return new WebSocketPrioritizedCachedStrategy(\n new FirstConnectedStrategy(\n new IfStrategy(\n testSupportsStrategy(ws_transport),\n wsStrategy,\n http_fallback_loop\n )\n ),\n definedTransports,\n {\n ttl: 1800000,\n timeline: baseOptions.timeline,\n useTLS: baseOptions.useTLS\n }\n );\n};\n\nexport default getDefaultStrategy;\n","import { Dependencies } from '../dom/dependencies';\n\n/** Initializes the transport.\n *\n * Fetches resources if needed and then transitions to initialized.\n */\nexport default function() {\n var self = this;\n\n self.timeline.info(\n self.buildTimelineMessage({\n transport: self.name + (self.options.useTLS ? 's' : '')\n })\n );\n\n if (self.hooks.isInitialized()) {\n self.changeState('initialized');\n } else if (self.hooks.file) {\n self.changeState('initializing');\n Dependencies.load(\n self.hooks.file,\n { useTLS: self.options.useTLS },\n function(error, callback) {\n if (self.hooks.isInitialized()) {\n self.changeState('initialized');\n callback(true);\n } else {\n if (error) {\n self.onError(error);\n }\n self.onClose();\n callback(false);\n }\n }\n );\n } else {\n self.onClose();\n }\n}\n","import HTTPRequest from 'core/http/http_request';\nimport RequestHooks from 'core/http/request_hooks';\nimport Ajax from 'core/http/ajax';\nimport * as Errors from 'core/errors';\n\nvar hooks: RequestHooks = {\n getRequest: function(socket: HTTPRequest): Ajax {\n var xdr = new (window).XDomainRequest();\n xdr.ontimeout = function() {\n socket.emit('error', new Errors.RequestTimedOut());\n socket.close();\n };\n xdr.onerror = function(e) {\n socket.emit('error', e);\n socket.close();\n };\n xdr.onprogress = function() {\n if (xdr.responseText && xdr.responseText.length > 0) {\n socket.onChunk(200, xdr.responseText);\n }\n };\n xdr.onload = function() {\n if (xdr.responseText && xdr.responseText.length > 0) {\n socket.onChunk(200, xdr.responseText);\n }\n socket.emit('finished', 200);\n socket.close();\n };\n return xdr;\n },\n abortRequest: function(xdr: Ajax) {\n xdr.ontimeout = xdr.onerror = xdr.onprogress = xdr.onload = null;\n xdr.abort();\n }\n};\n\nexport default hooks;\n","import Runtime from 'runtime';\nimport RequestHooks from './request_hooks';\nimport Ajax from './ajax';\nimport { default as EventsDispatcher } from '../events/dispatcher';\n\nconst MAX_BUFFER_LENGTH = 256 * 1024;\n\nexport default class HTTPRequest extends EventsDispatcher {\n hooks: RequestHooks;\n method: string;\n url: string;\n position: number;\n xhr: Ajax;\n unloader: Function;\n\n constructor(hooks: RequestHooks, method: string, url: string) {\n super();\n this.hooks = hooks;\n this.method = method;\n this.url = url;\n }\n\n start(payload?: any) {\n this.position = 0;\n this.xhr = this.hooks.getRequest(this);\n\n this.unloader = () => {\n this.close();\n };\n Runtime.addUnloadListener(this.unloader);\n\n this.xhr.open(this.method, this.url, true);\n\n if (this.xhr.setRequestHeader) {\n this.xhr.setRequestHeader('Content-Type', 'application/json'); // ReactNative doesn't set this header by default.\n }\n this.xhr.send(payload);\n }\n\n close() {\n if (this.unloader) {\n Runtime.removeUnloadListener(this.unloader);\n this.unloader = null;\n }\n if (this.xhr) {\n this.hooks.abortRequest(this.xhr);\n this.xhr = null;\n }\n }\n\n onChunk(status: number, data: any) {\n while (true) {\n var chunk = this.advanceBuffer(data);\n if (chunk) {\n this.emit('chunk', { status: status, data: chunk });\n } else {\n break;\n }\n }\n if (this.isBufferTooLong(data)) {\n this.emit('buffer_too_long');\n }\n }\n\n private advanceBuffer(buffer: any[]): any {\n var unreadData = buffer.slice(this.position);\n var endOfLinePosition = unreadData.indexOf('\\n');\n\n if (endOfLinePosition !== -1) {\n this.position += endOfLinePosition + 1;\n return unreadData.slice(0, endOfLinePosition);\n } else {\n // chunk is not finished yet, don't move the buffer pointer\n return null;\n }\n }\n\n private isBufferTooLong(buffer: any): boolean {\n return this.position === buffer.length && buffer.length > MAX_BUFFER_LENGTH;\n }\n}\n","enum State {\n CONNECTING = 0,\n OPEN = 1,\n CLOSED = 3\n}\n\nexport default State;\n","import URLLocation from './url_location';\nimport State from './state';\nimport Socket from '../socket';\nimport SocketHooks from './socket_hooks';\nimport Util from '../util';\nimport Ajax from './ajax';\nimport HTTPRequest from './http_request';\nimport Runtime from 'runtime';\n\nvar autoIncrement = 1;\n\nclass HTTPSocket implements Socket {\n hooks: SocketHooks;\n session: string;\n location: URLLocation;\n readyState: State;\n stream: HTTPRequest;\n\n onopen: () => void;\n onerror: (error: any) => void;\n onclose: (closeEvent: any) => void;\n onmessage: (message: any) => void;\n onactivity: () => void;\n\n constructor(hooks: SocketHooks, url: string) {\n this.hooks = hooks;\n this.session = randomNumber(1000) + '/' + randomString(8);\n this.location = getLocation(url);\n this.readyState = State.CONNECTING;\n this.openStream();\n }\n\n send(payload: any) {\n return this.sendRaw(JSON.stringify([payload]));\n }\n\n ping() {\n this.hooks.sendHeartbeat(this);\n }\n\n close(code: any, reason: any) {\n this.onClose(code, reason, true);\n }\n\n /** For internal use only */\n sendRaw(payload: any): boolean {\n if (this.readyState === State.OPEN) {\n try {\n Runtime.createSocketRequest(\n 'POST',\n getUniqueURL(getSendURL(this.location, this.session))\n ).start(payload);\n return true;\n } catch (e) {\n return false;\n }\n } else {\n return false;\n }\n }\n\n /** For internal use only */\n reconnect() {\n this.closeStream();\n this.openStream();\n }\n\n /** For internal use only */\n onClose(code, reason, wasClean) {\n this.closeStream();\n this.readyState = State.CLOSED;\n if (this.onclose) {\n this.onclose({\n code: code,\n reason: reason,\n wasClean: wasClean\n });\n }\n }\n\n private onChunk(chunk) {\n if (chunk.status !== 200) {\n return;\n }\n if (this.readyState === State.OPEN) {\n this.onActivity();\n }\n\n var payload;\n var type = chunk.data.slice(0, 1);\n switch (type) {\n case 'o':\n payload = JSON.parse(chunk.data.slice(1) || '{}');\n this.onOpen(payload);\n break;\n case 'a':\n payload = JSON.parse(chunk.data.slice(1) || '[]');\n for (var i = 0; i < payload.length; i++) {\n this.onEvent(payload[i]);\n }\n break;\n case 'm':\n payload = JSON.parse(chunk.data.slice(1) || 'null');\n this.onEvent(payload);\n break;\n case 'h':\n this.hooks.onHeartbeat(this);\n break;\n case 'c':\n payload = JSON.parse(chunk.data.slice(1) || '[]');\n this.onClose(payload[0], payload[1], true);\n break;\n }\n }\n\n private onOpen(options) {\n if (this.readyState === State.CONNECTING) {\n if (options && options.hostname) {\n this.location.base = replaceHost(this.location.base, options.hostname);\n }\n this.readyState = State.OPEN;\n\n if (this.onopen) {\n this.onopen();\n }\n } else {\n this.onClose(1006, 'Server lost session', true);\n }\n }\n\n private onEvent(event) {\n if (this.readyState === State.OPEN && this.onmessage) {\n this.onmessage({ data: event });\n }\n }\n\n private onActivity() {\n if (this.onactivity) {\n this.onactivity();\n }\n }\n\n private onError(error) {\n if (this.onerror) {\n this.onerror(error);\n }\n }\n\n private openStream() {\n this.stream = Runtime.createSocketRequest(\n 'POST',\n getUniqueURL(this.hooks.getReceiveURL(this.location, this.session))\n );\n\n this.stream.bind('chunk', chunk => {\n this.onChunk(chunk);\n });\n this.stream.bind('finished', status => {\n this.hooks.onFinished(this, status);\n });\n this.stream.bind('buffer_too_long', () => {\n this.reconnect();\n });\n\n try {\n this.stream.start();\n } catch (error) {\n Util.defer(() => {\n this.onError(error);\n this.onClose(1006, 'Could not start streaming', false);\n });\n }\n }\n\n private closeStream() {\n if (this.stream) {\n this.stream.unbind_all();\n this.stream.close();\n this.stream = null;\n }\n }\n}\n\nfunction getLocation(url): URLLocation {\n var parts = /([^\\?]*)\\/*(\\??.*)/.exec(url);\n return {\n base: parts[1],\n queryString: parts[2]\n };\n}\n\nfunction getSendURL(url: URLLocation, session: string): string {\n return url.base + '/' + session + '/xhr_send';\n}\n\nfunction getUniqueURL(url: string): string {\n var separator = url.indexOf('?') === -1 ? '?' : '&';\n return url + separator + 't=' + +new Date() + '&n=' + autoIncrement++;\n}\n\nfunction replaceHost(url: string, hostname: string): string {\n var urlParts = /(https?:\\/\\/)([^\\/:]+)((\\/|:)?.*)/.exec(url);\n return urlParts[1] + hostname + urlParts[3];\n}\n\nfunction randomNumber(max: number): number {\n return Runtime.randomInt(max);\n}\n\nfunction randomString(length: number): string {\n var result = [];\n\n for (var i = 0; i < length; i++) {\n result.push(randomNumber(32).toString(32));\n }\n\n return result.join('');\n}\n\nexport default HTTPSocket;\n","import SocketHooks from './socket_hooks';\nimport HTTPSocket from './http_socket';\n\nvar hooks: SocketHooks = {\n getReceiveURL: function(url, session) {\n return url.base + '/' + session + '/xhr_streaming' + url.queryString;\n },\n onHeartbeat: function(socket) {\n socket.sendRaw('[]');\n },\n sendHeartbeat: function(socket) {\n socket.sendRaw('[]');\n },\n onFinished: function(socket, status) {\n socket.onClose(1006, 'Connection interrupted (' + status + ')', false);\n }\n};\n\nexport default hooks;\n","import SocketHooks from './socket_hooks';\nimport URLLocation from './url_location';\nimport HTTPSocket from './http_socket';\n\nvar hooks: SocketHooks = {\n getReceiveURL: function(url: URLLocation, session: string): string {\n return url.base + '/' + session + '/xhr' + url.queryString;\n },\n onHeartbeat: function() {\n // next HTTP request will reset server's activity timer\n },\n sendHeartbeat: function(socket) {\n socket.sendRaw('[]');\n },\n onFinished: function(socket, status) {\n if (status === 200) {\n socket.reconnect();\n } else {\n socket.onClose(1006, 'Connection interrupted (' + status + ')', false);\n }\n }\n};\n\nexport default hooks;\n","import HTTPRequest from 'core/http/http_request';\nimport RequestHooks from 'core/http/request_hooks';\nimport Ajax from 'core/http/ajax';\nimport Runtime from 'runtime';\n\nvar hooks: RequestHooks = {\n getRequest: function(socket: HTTPRequest): Ajax {\n var Constructor = Runtime.getXHRAPI();\n var xhr = new Constructor();\n xhr.onreadystatechange = xhr.onprogress = function() {\n switch (xhr.readyState) {\n case 3:\n if (xhr.responseText && xhr.responseText.length > 0) {\n socket.onChunk(xhr.status, xhr.responseText);\n }\n break;\n case 4:\n // this happens only on errors, never after calling close\n if (xhr.responseText && xhr.responseText.length > 0) {\n socket.onChunk(xhr.status, xhr.responseText);\n }\n socket.emit('finished', xhr.status);\n socket.close();\n break;\n }\n };\n return xhr;\n },\n abortRequest: function(xhr: Ajax) {\n xhr.onreadystatechange = null;\n xhr.abort();\n }\n};\n\nexport default hooks;\n","import HTTPRequest from 'core/http/http_request';\nimport HTTPSocket from 'core/http/http_socket';\nimport SocketHooks from 'core/http/socket_hooks';\nimport RequestHooks from 'core/http/request_hooks';\nimport streamingHooks from 'core/http/http_streaming_socket';\nimport pollingHooks from 'core/http/http_polling_socket';\nimport xhrHooks from './http_xhr_request';\nimport HTTPFactory from 'core/http/http_factory';\n\nvar HTTP: HTTPFactory = {\n createStreamingSocket(url: string): HTTPSocket {\n return this.createSocket(streamingHooks, url);\n },\n\n createPollingSocket(url: string): HTTPSocket {\n return this.createSocket(pollingHooks, url);\n },\n\n createSocket(hooks: SocketHooks, url: string): HTTPSocket {\n return new HTTPSocket(hooks, url);\n },\n\n createXHR(method: string, url: string): HTTPRequest {\n return this.createRequest(xhrHooks, method, url);\n },\n\n createRequest(hooks: RequestHooks, method: string, url: string): HTTPRequest {\n return new HTTPRequest(hooks, method, url);\n }\n};\n\nexport default HTTP;\n","import xdrHooks from './http_xdomain_request';\nimport HTTP from 'isomorphic/http/http';\n\nHTTP.createXDR = function(method, url) {\n return this.createRequest(xdrHooks, method, url);\n};\n\nexport default HTTP;\n","import Browser from './browser';\nimport { Dependencies, DependenciesReceivers } from './dom/dependencies';\nimport { AuthTransport, AuthTransports } from 'core/auth/auth_transports';\nimport xhrAuth from 'isomorphic/auth/xhr_auth';\nimport jsonpAuth from './auth/jsonp_auth';\nimport TimelineTransport from 'core/timeline/timeline_transport';\nimport TimelineSender from 'core/timeline/timeline_sender';\nimport ScriptRequest from './dom/script_request';\nimport JSONPRequest from './dom/jsonp_request';\nimport * as Collections from 'core/utils/collections';\nimport { ScriptReceivers } from './dom/script_receiver_factory';\nimport jsonpTimeline from './timeline/jsonp_timeline';\nimport Transports from './transports/transports';\nimport Ajax from 'core/http/ajax';\nimport { Network } from './net_info';\nimport getDefaultStrategy from './default_strategy';\nimport transportConnectionInitializer from './transports/transport_connection_initializer';\nimport HTTPFactory from './http/http';\nimport HTTPRequest from 'core/http/http_request';\n\nvar Runtime: Browser = {\n // for jsonp auth\n nextAuthCallbackID: 1,\n auth_callbacks: {},\n ScriptReceivers,\n DependenciesReceivers,\n getDefaultStrategy,\n Transports,\n transportConnectionInitializer,\n HTTPFactory,\n\n TimelineTransport: jsonpTimeline,\n\n getXHRAPI() {\n return window.XMLHttpRequest;\n },\n\n getWebSocketAPI() {\n return window.WebSocket || window.MozWebSocket;\n },\n\n setup(PusherClass): void {\n (window).Pusher = PusherClass; // JSONp requires Pusher to be in the global scope.\n var initializeOnDocumentBody = () => {\n this.onDocumentBody(PusherClass.ready);\n };\n if (!(window).JSON) {\n Dependencies.load('json2', {}, initializeOnDocumentBody);\n } else {\n initializeOnDocumentBody();\n }\n },\n\n getDocument(): Document {\n return document;\n },\n\n getProtocol(): string {\n return this.getDocument().location.protocol;\n },\n\n getAuthorizers(): AuthTransports {\n return { ajax: xhrAuth, jsonp: jsonpAuth };\n },\n\n onDocumentBody(callback: Function) {\n if (document.body) {\n callback();\n } else {\n setTimeout(() => {\n this.onDocumentBody(callback);\n }, 0);\n }\n },\n\n createJSONPRequest(url: string, data: any): JSONPRequest {\n return new JSONPRequest(url, data);\n },\n\n createScriptRequest(src: string): ScriptRequest {\n return new ScriptRequest(src);\n },\n\n getLocalStorage() {\n try {\n return window.localStorage;\n } catch (e) {\n return undefined;\n }\n },\n\n createXHR(): Ajax {\n if (this.getXHRAPI()) {\n return this.createXMLHttpRequest();\n } else {\n return this.createMicrosoftXHR();\n }\n },\n\n createXMLHttpRequest(): Ajax {\n var Constructor = this.getXHRAPI();\n return new Constructor();\n },\n\n createMicrosoftXHR(): Ajax {\n return new ActiveXObject('Microsoft.XMLHTTP');\n },\n\n getNetwork() {\n return Network;\n },\n\n createWebSocket(url: string): any {\n var Constructor = this.getWebSocketAPI();\n return new Constructor(url);\n },\n\n createSocketRequest(method: string, url: string): HTTPRequest {\n if (this.isXHRSupported()) {\n return this.HTTPFactory.createXHR(method, url);\n } else if (this.isXDRSupported(url.indexOf('https:') === 0)) {\n return this.HTTPFactory.createXDR(method, url);\n } else {\n throw 'Cross-origin HTTP requests are not supported';\n }\n },\n\n isXHRSupported(): boolean {\n var Constructor = this.getXHRAPI();\n return (\n Boolean(Constructor) && new Constructor().withCredentials !== undefined\n );\n },\n\n isXDRSupported(useTLS?: boolean): boolean {\n var protocol = useTLS ? 'https:' : 'http:';\n var documentProtocol = this.getProtocol();\n return (\n Boolean(window['XDomainRequest']) && documentProtocol === protocol\n );\n },\n\n addUnloadListener(listener: any) {\n if (window.addEventListener !== undefined) {\n window.addEventListener('unload', listener, false);\n } else if (window.attachEvent !== undefined) {\n window.attachEvent('onunload', listener);\n }\n },\n\n removeUnloadListener(listener: any) {\n if (window.addEventListener !== undefined) {\n window.removeEventListener('unload', listener, false);\n } else if (window.detachEvent !== undefined) {\n window.detachEvent('onunload', listener);\n }\n },\n\n randomInt(max: number): number {\n /**\n * Return values in the range of [0, 1[\n */\n const random = function() {\n const crypto = window.crypto || window['msCrypto'];\n const random = crypto.getRandomValues(new Uint32Array(1))[0];\n\n return random / 2 ** 32;\n };\n\n return Math.floor(random() * max);\n }\n};\n\nexport default Runtime;\n","enum TimelineLevel {\n ERROR = 3,\n INFO = 6,\n DEBUG = 7\n}\n\nexport default TimelineLevel;\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport { default as Level } from './level';\n\nexport interface TimelineOptions {\n level?: Level;\n limit?: number;\n version?: string;\n cluster?: string;\n features?: string[];\n params?: any;\n}\n\nexport default class Timeline {\n key: string;\n session: number;\n events: any[];\n options: TimelineOptions;\n sent: number;\n uniqueID: number;\n\n constructor(key: string, session: number, options: TimelineOptions) {\n this.key = key;\n this.session = session;\n this.events = [];\n this.options = options || {};\n this.sent = 0;\n this.uniqueID = 0;\n }\n\n log(level, event) {\n if (level <= this.options.level) {\n this.events.push(\n Collections.extend({}, event, { timestamp: Util.now() })\n );\n if (this.options.limit && this.events.length > this.options.limit) {\n this.events.shift();\n }\n }\n }\n\n error(event) {\n this.log(Level.ERROR, event);\n }\n\n info(event) {\n this.log(Level.INFO, event);\n }\n\n debug(event) {\n this.log(Level.DEBUG, event);\n }\n\n isEmpty() {\n return this.events.length === 0;\n }\n\n send(sendfn, callback) {\n var data = Collections.extend(\n {\n session: this.session,\n bundle: this.sent + 1,\n key: this.key,\n lib: 'js',\n version: this.options.version,\n cluster: this.options.cluster,\n features: this.options.features,\n timeline: this.events\n },\n this.options.params\n );\n\n this.events = [];\n sendfn(data, (error, result) => {\n if (!error) {\n this.sent++;\n }\n if (callback) {\n callback(error, result);\n }\n });\n\n return true;\n }\n\n generateUniqueID(): number {\n this.uniqueID++;\n return this.uniqueID;\n }\n}\n","import Factory from '../utils/factory';\nimport Util from '../util';\nimport * as Errors from '../errors';\nimport * as Collections from '../utils/collections';\nimport Strategy from './strategy';\nimport Transport from '../transports/transport';\nimport StrategyOptions from './strategy_options';\nimport Handshake from '../connection/handshake';\n\n/** Provides a strategy interface for transports.\n *\n * @param {String} name\n * @param {Number} priority\n * @param {Class} transport\n * @param {Object} options\n */\nexport default class TransportStrategy implements Strategy {\n name: string;\n priority: number;\n transport: Transport;\n options: StrategyOptions;\n\n constructor(\n name: string,\n priority: number,\n transport: Transport,\n options: StrategyOptions\n ) {\n this.name = name;\n this.priority = priority;\n this.transport = transport;\n this.options = options || {};\n }\n\n /** Returns whether the transport is supported in the browser.\n *\n * @returns {Boolean}\n */\n isSupported(): boolean {\n return this.transport.isSupported({\n useTLS: this.options.useTLS\n });\n }\n\n /** Launches a connection attempt and returns a strategy runner.\n *\n * @param {Function} callback\n * @return {Object} strategy runner\n */\n connect(minPriority: number, callback: Function) {\n if (!this.isSupported()) {\n return failAttempt(new Errors.UnsupportedStrategy(), callback);\n } else if (this.priority < minPriority) {\n return failAttempt(new Errors.TransportPriorityTooLow(), callback);\n }\n\n var connected = false;\n var transport = this.transport.createConnection(\n this.name,\n this.priority,\n this.options.key,\n this.options\n );\n var handshake = null;\n\n var onInitialized = function() {\n transport.unbind('initialized', onInitialized);\n transport.connect();\n };\n var onOpen = function() {\n handshake = Factory.createHandshake(transport, function(result) {\n connected = true;\n unbindListeners();\n callback(null, result);\n });\n };\n var onError = function(error) {\n unbindListeners();\n callback(error);\n };\n var onClosed = function() {\n unbindListeners();\n var serializedTransport;\n\n // The reason for this try/catch block is that on React Native\n // the WebSocket object is circular. Therefore transport.socket will\n // throw errors upon stringification. Collections.safeJSONStringify\n // discards circular references when serializing.\n serializedTransport = Collections.safeJSONStringify(transport);\n callback(new Errors.TransportClosed(serializedTransport));\n };\n\n var unbindListeners = function() {\n transport.unbind('initialized', onInitialized);\n transport.unbind('open', onOpen);\n transport.unbind('error', onError);\n transport.unbind('closed', onClosed);\n };\n\n transport.bind('initialized', onInitialized);\n transport.bind('open', onOpen);\n transport.bind('error', onError);\n transport.bind('closed', onClosed);\n\n // connect will be called automatically after initialization\n transport.initialize();\n\n return {\n abort: () => {\n if (connected) {\n return;\n }\n unbindListeners();\n if (handshake) {\n handshake.close();\n } else {\n transport.close();\n }\n },\n forceMinPriority: p => {\n if (connected) {\n return;\n }\n if (this.priority < p) {\n if (handshake) {\n handshake.close();\n } else {\n transport.close();\n }\n }\n }\n };\n }\n}\n\nfunction failAttempt(error: Error, callback: Function) {\n Util.defer(function() {\n callback(error);\n });\n return {\n abort: function() {},\n forceMinPriority: function() {}\n };\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport TransportManager from '../transports/transport_manager';\nimport * as Errors from '../errors';\nimport Strategy from './strategy';\nimport TransportStrategy from './transport_strategy';\nimport StrategyOptions from '../strategies/strategy_options';\nimport { Config } from '../config';\nimport Runtime from 'runtime';\n\nconst { Transports } = Runtime;\n\nexport var defineTransport = function(\n config: Config,\n name: string,\n type: string,\n priority: number,\n options: StrategyOptions,\n manager?: TransportManager\n): Strategy {\n var transportClass = Transports[type];\n if (!transportClass) {\n throw new Errors.UnsupportedTransport(type);\n }\n\n var enabled =\n (!config.enabledTransports ||\n Collections.arrayIndexOf(config.enabledTransports, name) !== -1) &&\n (!config.disabledTransports ||\n Collections.arrayIndexOf(config.disabledTransports, name) === -1);\n\n var transport;\n if (enabled) {\n options = Object.assign(\n { ignoreNullOrigin: config.ignoreNullOrigin },\n options\n );\n\n transport = new TransportStrategy(\n name,\n priority,\n manager ? manager.getAssistant(transportClass) : transportClass,\n options\n );\n } else {\n transport = UnsupportedStrategy;\n }\n\n return transport;\n};\n\nvar UnsupportedStrategy: Strategy = {\n isSupported: function() {\n return false;\n },\n connect: function(_, callback) {\n var deferred = Util.defer(function() {\n callback(new Errors.UnsupportedStrategy());\n });\n return {\n abort: function() {\n deferred.ensureAborted();\n },\n forceMinPriority: function() {}\n };\n }\n};\n","import ConnectionManager from './connection/connection_manager';\nimport {\n ChannelAuthorizationOptions,\n UserAuthenticationOptions\n} from './auth/options';\nimport {\n ChannelAuthorizerGenerator,\n DeprecatedAuthOptions\n} from './auth/deprecated_channel_authorizer';\nimport { AuthTransport, Transport } from './config';\nimport * as nacl from 'tweetnacl';\nimport Logger from './logger';\n\nexport interface Options {\n activityTimeout?: number;\n\n auth?: DeprecatedAuthOptions; // DEPRECATED use channelAuthorization instead\n authEndpoint?: string; // DEPRECATED use channelAuthorization instead\n authTransport?: AuthTransport; // DEPRECATED use channelAuthorization instead\n authorizer?: ChannelAuthorizerGenerator; // DEPRECATED use channelAuthorization instead\n\n channelAuthorization?: ChannelAuthorizationOptions;\n userAuthentication?: UserAuthenticationOptions;\n\n cluster: string;\n enableStats?: boolean;\n disableStats?: boolean;\n disabledTransports?: Transport[];\n enabledTransports?: Transport[];\n forceTLS?: boolean;\n httpHost?: string;\n httpPath?: string;\n httpPort?: number;\n httpsPort?: number;\n ignoreNullOrigin?: boolean;\n nacl?: nacl;\n pongTimeout?: number;\n statsHost?: string;\n timelineParams?: any;\n unavailableTimeout?: number;\n wsHost?: string;\n wsPath?: string;\n wsPort?: number;\n wssPort?: number;\n}\n\nexport interface ClusterOptions {\n appKey: string;\n cluster: string;\n}\n\nexport function validateOptions(options) {\n if (options == null) {\n throw 'You must pass an options object';\n }\n if (options.cluster == null) {\n throw 'Options object must provide a cluster';\n }\n if ('disableStats' in options) {\n Logger.warn(\n 'The disableStats option is deprecated in favor of enableStats'\n );\n }\n}\n","import {\n UserAuthenticationCallback,\n InternalAuthOptions,\n UserAuthenticationHandler,\n UserAuthenticationRequestParams,\n AuthRequestType\n} from './options';\n\nimport Runtime from 'runtime';\n\nconst composeChannelQuery = (\n params: UserAuthenticationRequestParams,\n authOptions: InternalAuthOptions\n) => {\n var query = 'socket_id=' + encodeURIComponent(params.socketId);\n\n for (var key in authOptions.params) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(authOptions.params[key]);\n }\n\n if (authOptions.paramsProvider != null) {\n let dynamicParams = authOptions.paramsProvider();\n for (var key in dynamicParams) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(dynamicParams[key]);\n }\n }\n\n return query;\n};\n\nconst UserAuthenticator = (\n authOptions: InternalAuthOptions\n): UserAuthenticationHandler => {\n if (typeof Runtime.getAuthorizers()[authOptions.transport] === 'undefined') {\n throw `'${authOptions.transport}' is not a recognized auth transport`;\n }\n\n return (\n params: UserAuthenticationRequestParams,\n callback: UserAuthenticationCallback\n ) => {\n const query = composeChannelQuery(params, authOptions);\n\n Runtime.getAuthorizers()[authOptions.transport](\n Runtime,\n query,\n authOptions,\n AuthRequestType.UserAuthentication,\n callback\n );\n };\n};\n\nexport default UserAuthenticator;\n","import {\n AuthRequestType,\n InternalAuthOptions,\n ChannelAuthorizationHandler,\n ChannelAuthorizationRequestParams,\n ChannelAuthorizationCallback\n} from './options';\n\nimport Runtime from 'runtime';\n\nconst composeChannelQuery = (\n params: ChannelAuthorizationRequestParams,\n authOptions: InternalAuthOptions\n) => {\n var query = 'socket_id=' + encodeURIComponent(params.socketId);\n\n query += '&channel_name=' + encodeURIComponent(params.channelName);\n\n for (var key in authOptions.params) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(authOptions.params[key]);\n }\n\n if (authOptions.paramsProvider != null) {\n let dynamicParams = authOptions.paramsProvider();\n for (var key in dynamicParams) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(dynamicParams[key]);\n }\n }\n\n return query;\n};\n\nconst ChannelAuthorizer = (\n authOptions: InternalAuthOptions\n): ChannelAuthorizationHandler => {\n if (typeof Runtime.getAuthorizers()[authOptions.transport] === 'undefined') {\n throw `'${authOptions.transport}' is not a recognized auth transport`;\n }\n\n return (\n params: ChannelAuthorizationRequestParams,\n callback: ChannelAuthorizationCallback\n ) => {\n const query = composeChannelQuery(params, authOptions);\n\n Runtime.getAuthorizers()[authOptions.transport](\n Runtime,\n query,\n authOptions,\n AuthRequestType.ChannelAuthorization,\n callback\n );\n };\n};\n\nexport default ChannelAuthorizer;\n","import Channel from '../channels/channel';\nimport {\n ChannelAuthorizationCallback,\n ChannelAuthorizationHandler,\n ChannelAuthorizationRequestParams,\n InternalAuthOptions\n} from './options';\n\nexport interface DeprecatedChannelAuthorizer {\n authorize(socketId: string, callback: ChannelAuthorizationCallback): void;\n}\n\nexport interface ChannelAuthorizerGenerator {\n (\n channel: Channel,\n options: DeprecatedAuthorizerOptions\n ): DeprecatedChannelAuthorizer;\n}\n\nexport interface DeprecatedAuthOptions {\n params?: any;\n headers?: any;\n}\n\nexport interface DeprecatedAuthorizerOptions {\n authTransport: 'ajax' | 'jsonp';\n authEndpoint: string;\n auth?: DeprecatedAuthOptions;\n}\n\nexport const ChannelAuthorizerProxy = (\n pusher,\n authOptions: InternalAuthOptions,\n channelAuthorizerGenerator: ChannelAuthorizerGenerator\n): ChannelAuthorizationHandler => {\n const deprecatedAuthorizerOptions: DeprecatedAuthorizerOptions = {\n authTransport: authOptions.transport,\n authEndpoint: authOptions.endpoint,\n auth: {\n params: authOptions.params,\n headers: authOptions.headers\n }\n };\n return (\n params: ChannelAuthorizationRequestParams,\n callback: ChannelAuthorizationCallback\n ) => {\n const channel = pusher.channel(params.channelName);\n // This line creates a new channel authorizer every time.\n // In the past, this was only done once per channel and reused.\n // We can do that again if we want to keep this behavior intact.\n const channelAuthorizer: DeprecatedChannelAuthorizer = channelAuthorizerGenerator(\n channel,\n deprecatedAuthorizerOptions\n );\n channelAuthorizer.authorize(params.socketId, callback);\n };\n};\n","import { Options } from './options';\nimport Defaults from './defaults';\nimport {\n ChannelAuthorizationHandler,\n UserAuthenticationHandler,\n ChannelAuthorizationOptions\n} from './auth/options';\nimport UserAuthenticator from './auth/user_authenticator';\nimport ChannelAuthorizer from './auth/channel_authorizer';\nimport { ChannelAuthorizerProxy } from './auth/deprecated_channel_authorizer';\nimport Runtime from 'runtime';\nimport * as nacl from 'tweetnacl';\n\nexport type AuthTransport = 'ajax' | 'jsonp';\nexport type Transport =\n | 'ws'\n | 'wss'\n | 'xhr_streaming'\n | 'xhr_polling'\n | 'sockjs';\n\nexport interface Config {\n // these are all 'required' config parameters, it's not necessary for the user\n // to set them, but they have configured defaults.\n activityTimeout: number;\n enableStats: boolean;\n httpHost: string;\n httpPath: string;\n httpPort: number;\n httpsPort: number;\n pongTimeout: number;\n statsHost: string;\n unavailableTimeout: number;\n useTLS: boolean;\n wsHost: string;\n wsPath: string;\n wsPort: number;\n wssPort: number;\n userAuthenticator: UserAuthenticationHandler;\n channelAuthorizer: ChannelAuthorizationHandler;\n\n // these are all optional parameters or overrrides. The customer can set these\n // but it's not strictly necessary\n forceTLS?: boolean;\n cluster?: string;\n disabledTransports?: Transport[];\n enabledTransports?: Transport[];\n ignoreNullOrigin?: boolean;\n nacl?: nacl;\n timelineParams?: any;\n}\n\n// getConfig mainly sets the defaults for the options that are not provided\nexport function getConfig(opts: Options, pusher): Config {\n let config: Config = {\n activityTimeout: opts.activityTimeout || Defaults.activityTimeout,\n cluster: opts.cluster,\n httpPath: opts.httpPath || Defaults.httpPath,\n httpPort: opts.httpPort || Defaults.httpPort,\n httpsPort: opts.httpsPort || Defaults.httpsPort,\n pongTimeout: opts.pongTimeout || Defaults.pongTimeout,\n statsHost: opts.statsHost || Defaults.stats_host,\n unavailableTimeout: opts.unavailableTimeout || Defaults.unavailableTimeout,\n wsPath: opts.wsPath || Defaults.wsPath,\n wsPort: opts.wsPort || Defaults.wsPort,\n wssPort: opts.wssPort || Defaults.wssPort,\n\n enableStats: getEnableStatsConfig(opts),\n httpHost: getHttpHost(opts),\n useTLS: shouldUseTLS(opts),\n wsHost: getWebsocketHost(opts),\n\n userAuthenticator: buildUserAuthenticator(opts),\n channelAuthorizer: buildChannelAuthorizer(opts, pusher)\n };\n\n if ('disabledTransports' in opts)\n config.disabledTransports = opts.disabledTransports;\n if ('enabledTransports' in opts)\n config.enabledTransports = opts.enabledTransports;\n if ('ignoreNullOrigin' in opts)\n config.ignoreNullOrigin = opts.ignoreNullOrigin;\n if ('timelineParams' in opts) config.timelineParams = opts.timelineParams;\n if ('nacl' in opts) {\n config.nacl = opts.nacl;\n }\n\n return config;\n}\n\nfunction getHttpHost(opts: Options): string {\n if (opts.httpHost) {\n return opts.httpHost;\n }\n if (opts.cluster) {\n return `sockjs-${opts.cluster}.pusher.com`;\n }\n return Defaults.httpHost;\n}\n\nfunction getWebsocketHost(opts: Options): string {\n if (opts.wsHost) {\n return opts.wsHost;\n }\n return getWebsocketHostFromCluster(opts.cluster);\n}\n\nfunction getWebsocketHostFromCluster(cluster: string): string {\n return `ws-${cluster}.pusher.com`;\n}\n\nfunction shouldUseTLS(opts: Options): boolean {\n if (Runtime.getProtocol() === 'https:') {\n return true;\n } else if (opts.forceTLS === false) {\n return false;\n }\n return true;\n}\n\n// if enableStats is set take the value\n// if disableStats is set take the inverse\n// otherwise default to false\nfunction getEnableStatsConfig(opts: Options): boolean {\n if ('enableStats' in opts) {\n return opts.enableStats;\n }\n if ('disableStats' in opts) {\n return !opts.disableStats;\n }\n return false;\n}\n\nfunction buildUserAuthenticator(opts: Options): UserAuthenticationHandler {\n const userAuthentication = {\n ...Defaults.userAuthentication,\n ...opts.userAuthentication\n };\n if (\n 'customHandler' in userAuthentication &&\n userAuthentication['customHandler'] != null\n ) {\n return userAuthentication['customHandler'];\n }\n\n return UserAuthenticator(userAuthentication);\n}\n\nfunction buildChannelAuth(opts: Options, pusher): ChannelAuthorizationOptions {\n let channelAuthorization: ChannelAuthorizationOptions;\n if ('channelAuthorization' in opts) {\n channelAuthorization = {\n ...Defaults.channelAuthorization,\n ...opts.channelAuthorization\n };\n } else {\n channelAuthorization = {\n transport: opts.authTransport || Defaults.authTransport,\n endpoint: opts.authEndpoint || Defaults.authEndpoint\n };\n if ('auth' in opts) {\n if ('params' in opts.auth) channelAuthorization.params = opts.auth.params;\n if ('headers' in opts.auth)\n channelAuthorization.headers = opts.auth.headers;\n }\n if ('authorizer' in opts)\n channelAuthorization.customHandler = ChannelAuthorizerProxy(\n pusher,\n channelAuthorization,\n opts.authorizer\n );\n }\n return channelAuthorization;\n}\n\nfunction buildChannelAuthorizer(\n opts: Options,\n pusher\n): ChannelAuthorizationHandler {\n const channelAuthorization = buildChannelAuth(opts, pusher);\n if (\n 'customHandler' in channelAuthorization &&\n channelAuthorization['customHandler'] != null\n ) {\n return channelAuthorization['customHandler'];\n }\n\n return ChannelAuthorizer(channelAuthorization);\n}\n","import Logger from './logger';\nimport Pusher from './pusher';\nimport EventsDispatcher from './events/dispatcher';\n\nexport default class WatchlistFacade extends EventsDispatcher {\n private pusher: Pusher;\n\n public constructor(pusher: Pusher) {\n super(function(eventName, data) {\n Logger.debug(`No callbacks on watchlist events for ${eventName}`);\n });\n\n this.pusher = pusher;\n this.bindWatchlistInternalEvent();\n }\n\n handleEvent(pusherEvent) {\n pusherEvent.data.events.forEach(watchlistEvent => {\n this.emit(watchlistEvent.name, watchlistEvent);\n });\n }\n\n private bindWatchlistInternalEvent() {\n this.pusher.connection.bind('message', pusherEvent => {\n var eventName = pusherEvent.event;\n if (eventName === 'pusher_internal:watchlist_events') {\n this.handleEvent(pusherEvent);\n }\n });\n }\n}\n","function flatPromise() {\n let resolve, reject;\n const promise = new Promise((res, rej) => {\n resolve = res;\n reject = rej;\n });\n return { promise, resolve, reject };\n}\n\nexport default flatPromise;\n","import Pusher from './pusher';\nimport Logger from './logger';\nimport {\n UserAuthenticationData,\n UserAuthenticationCallback\n} from './auth/options';\nimport Channel from './channels/channel';\nimport WatchlistFacade from './watchlist';\nimport EventsDispatcher from './events/dispatcher';\nimport flatPromise from './utils/flat_promise';\n\nexport default class UserFacade extends EventsDispatcher {\n pusher: Pusher;\n signin_requested: boolean = false;\n user_data: any = null;\n serverToUserChannel: Channel = null;\n signinDonePromise: Promise = null;\n watchlist: WatchlistFacade;\n private _signinDoneResolve: Function = null;\n\n public constructor(pusher: Pusher) {\n super(function(eventName, data) {\n Logger.debug('No callbacks on user for ' + eventName);\n });\n this.pusher = pusher;\n this.pusher.connection.bind('state_change', ({ previous, current }) => {\n if (previous !== 'connected' && current === 'connected') {\n this._signin();\n }\n if (previous === 'connected' && current !== 'connected') {\n this._cleanup();\n this._newSigninPromiseIfNeeded();\n }\n });\n\n this.watchlist = new WatchlistFacade(pusher);\n\n this.pusher.connection.bind('message', event => {\n var eventName = event.event;\n if (eventName === 'pusher:signin_success') {\n this._onSigninSuccess(event.data);\n }\n if (\n this.serverToUserChannel &&\n this.serverToUserChannel.name === event.channel\n ) {\n this.serverToUserChannel.handleEvent(event);\n }\n });\n }\n\n public signin() {\n if (this.signin_requested) {\n return;\n }\n\n this.signin_requested = true;\n this._signin();\n }\n\n private _signin() {\n if (!this.signin_requested) {\n return;\n }\n\n this._newSigninPromiseIfNeeded();\n\n if (this.pusher.connection.state !== 'connected') {\n // Signin will be attempted when the connection is connected\n return;\n }\n\n this.pusher.config.userAuthenticator(\n {\n socketId: this.pusher.connection.socket_id\n },\n this._onAuthorize\n );\n }\n\n private _onAuthorize: UserAuthenticationCallback = (\n err,\n authData: UserAuthenticationData\n ) => {\n if (err) {\n Logger.warn(`Error during signin: ${err}`);\n this._cleanup();\n return;\n }\n\n this.pusher.send_event('pusher:signin', {\n auth: authData.auth,\n user_data: authData.user_data\n });\n\n // Later when we get pusher:singin_success event, the user will be marked as signed in\n };\n\n private _onSigninSuccess(data: any) {\n try {\n this.user_data = JSON.parse(data.user_data);\n } catch (e) {\n Logger.error(`Failed parsing user data after signin: ${data.user_data}`);\n this._cleanup();\n return;\n }\n\n if (typeof this.user_data.id !== 'string' || this.user_data.id === '') {\n Logger.error(\n `user_data doesn't contain an id. user_data: ${this.user_data}`\n );\n this._cleanup();\n return;\n }\n\n // Signin succeeded\n this._signinDoneResolve();\n this._subscribeChannels();\n }\n\n private _subscribeChannels() {\n const ensure_subscribed = channel => {\n if (channel.subscriptionPending && channel.subscriptionCancelled) {\n channel.reinstateSubscription();\n } else if (\n !channel.subscriptionPending &&\n this.pusher.connection.state === 'connected'\n ) {\n channel.subscribe();\n }\n };\n\n this.serverToUserChannel = new Channel(\n `#server-to-user-${this.user_data.id}`,\n this.pusher\n );\n this.serverToUserChannel.bind_global((eventName, data) => {\n if (\n eventName.indexOf('pusher_internal:') === 0 ||\n eventName.indexOf('pusher:') === 0\n ) {\n // ignore internal events\n return;\n }\n this.emit(eventName, data);\n });\n ensure_subscribed(this.serverToUserChannel);\n }\n\n private _cleanup() {\n this.user_data = null;\n if (this.serverToUserChannel) {\n this.serverToUserChannel.unbind_all();\n this.serverToUserChannel.disconnect();\n this.serverToUserChannel = null;\n }\n\n if (this.signin_requested) {\n // If signin is in progress and cleanup is called,\n // Mark the current signin process as done.\n this._signinDoneResolve();\n }\n }\n\n private _newSigninPromiseIfNeeded() {\n if (!this.signin_requested) {\n return;\n }\n\n // If there is a promise and it is not resolved, return without creating a new one.\n if (this.signinDonePromise && !(this.signinDonePromise as any).done) {\n return;\n }\n\n // This promise is never rejected.\n // It gets resolved when the signin process is done whether it failed or succeeded\n const { promise, resolve, reject: _ } = flatPromise();\n (promise as any).done = false;\n const setDone = () => {\n (promise as any).done = true;\n };\n promise.then(setDone).catch(setDone);\n this.signinDonePromise = promise;\n this._signinDoneResolve = resolve;\n }\n}\n","import AbstractRuntime from '../runtimes/interface';\nimport Runtime from 'runtime';\nimport * as Collections from './utils/collections';\nimport Channels from './channels/channels';\nimport Channel from './channels/channel';\nimport { default as EventsDispatcher } from './events/dispatcher';\nimport Timeline from './timeline/timeline';\nimport TimelineSender from './timeline/timeline_sender';\nimport TimelineLevel from './timeline/level';\nimport { defineTransport } from './strategies/strategy_builder';\nimport ConnectionManager from './connection/connection_manager';\nimport { PeriodicTimer } from './utils/timers';\nimport Defaults from './defaults';\nimport Logger from './logger';\nimport Factory from './utils/factory';\nimport { Options, ClusterOptions, validateOptions } from './options';\nimport { Config, getConfig } from './config';\nimport StrategyOptions from './strategies/strategy_options';\nimport UserFacade from './user';\n\nexport default class Pusher {\n /* STATIC PROPERTIES */\n static instances: Pusher[] = [];\n static isReady: boolean = false;\n static logToConsole: boolean = false;\n\n // for jsonp\n static Runtime: AbstractRuntime = Runtime;\n static ScriptReceivers: any = (Runtime).ScriptReceivers;\n static DependenciesReceivers: any = (Runtime).DependenciesReceivers;\n static auth_callbacks: any = (Runtime).auth_callbacks;\n\n static ready() {\n Pusher.isReady = true;\n for (var i = 0, l = Pusher.instances.length; i < l; i++) {\n Pusher.instances[i].connect();\n }\n }\n\n static log: (message: any) => void;\n\n private static getClientFeatures(): string[] {\n return Collections.keys(\n Collections.filterObject({ ws: Runtime.Transports.ws }, function(t) {\n return t.isSupported({});\n })\n );\n }\n\n /* INSTANCE PROPERTIES */\n key: string;\n options: Options;\n config: Config;\n channels: Channels;\n global_emitter: EventsDispatcher;\n sessionID: number;\n timeline: Timeline;\n timelineSender: TimelineSender;\n connection: ConnectionManager;\n timelineSenderTimer: PeriodicTimer;\n user: UserFacade;\n constructor(app_key: string, options: Options) {\n checkAppKey(app_key);\n validateOptions(options);\n this.key = app_key;\n this.config = getConfig(options, this);\n\n this.channels = Factory.createChannels();\n this.global_emitter = new EventsDispatcher();\n this.sessionID = Runtime.randomInt(1000000000);\n\n this.timeline = new Timeline(this.key, this.sessionID, {\n cluster: this.config.cluster,\n features: Pusher.getClientFeatures(),\n params: this.config.timelineParams || {},\n limit: 50,\n level: TimelineLevel.INFO,\n version: Defaults.VERSION\n });\n if (this.config.enableStats) {\n this.timelineSender = Factory.createTimelineSender(this.timeline, {\n host: this.config.statsHost,\n path: '/timeline/v2/' + Runtime.TimelineTransport.name\n });\n }\n\n var getStrategy = (options: StrategyOptions) => {\n return Runtime.getDefaultStrategy(this.config, options, defineTransport);\n };\n\n this.connection = Factory.createConnectionManager(this.key, {\n getStrategy: getStrategy,\n timeline: this.timeline,\n activityTimeout: this.config.activityTimeout,\n pongTimeout: this.config.pongTimeout,\n unavailableTimeout: this.config.unavailableTimeout,\n useTLS: Boolean(this.config.useTLS)\n });\n\n this.connection.bind('connected', () => {\n this.subscribeAll();\n if (this.timelineSender) {\n this.timelineSender.send(this.connection.isUsingTLS());\n }\n });\n\n this.connection.bind('message', event => {\n var eventName = event.event;\n var internal = eventName.indexOf('pusher_internal:') === 0;\n if (event.channel) {\n var channel = this.channel(event.channel);\n if (channel) {\n channel.handleEvent(event);\n }\n }\n // Emit globally [deprecated]\n if (!internal) {\n this.global_emitter.emit(event.event, event.data);\n }\n });\n this.connection.bind('connecting', () => {\n this.channels.disconnect();\n });\n this.connection.bind('disconnected', () => {\n this.channels.disconnect();\n });\n this.connection.bind('error', err => {\n Logger.warn(err);\n });\n\n Pusher.instances.push(this);\n this.timeline.info({ instances: Pusher.instances.length });\n\n this.user = new UserFacade(this);\n\n if (Pusher.isReady) {\n this.connect();\n }\n }\n\n /**\n * Allows you to switch Pusher cluster without\n * losing all the channels/subscription binding\n * as this is internally managed by the SDK.\n */\n switchCluster(options: ClusterOptions) {\n const { appKey, cluster } = options;\n this.key = appKey;\n this.options = { ...this.options, cluster };\n this.config = getConfig(this.options, this);\n this.connection.switchCluster(this.key);\n }\n\n channel(name: string): Channel {\n return this.channels.find(name);\n }\n\n allChannels(): Channel[] {\n return this.channels.all();\n }\n\n connect() {\n this.connection.connect();\n\n if (this.timelineSender) {\n if (!this.timelineSenderTimer) {\n var usingTLS = this.connection.isUsingTLS();\n var timelineSender = this.timelineSender;\n this.timelineSenderTimer = new PeriodicTimer(60000, function() {\n timelineSender.send(usingTLS);\n });\n }\n }\n }\n\n disconnect() {\n this.connection.disconnect();\n\n if (this.timelineSenderTimer) {\n this.timelineSenderTimer.ensureAborted();\n this.timelineSenderTimer = null;\n }\n }\n\n bind(event_name: string, callback: Function, context?: any): Pusher {\n this.global_emitter.bind(event_name, callback, context);\n return this;\n }\n\n unbind(event_name?: string, callback?: Function, context?: any): Pusher {\n this.global_emitter.unbind(event_name, callback, context);\n return this;\n }\n\n bind_global(callback: Function): Pusher {\n this.global_emitter.bind_global(callback);\n return this;\n }\n\n unbind_global(callback?: Function): Pusher {\n this.global_emitter.unbind_global(callback);\n return this;\n }\n\n unbind_all(callback?: Function): Pusher {\n this.global_emitter.unbind_all();\n return this;\n }\n\n subscribeAll() {\n var channelName;\n for (channelName in this.channels.channels) {\n if (this.channels.channels.hasOwnProperty(channelName)) {\n this.subscribe(channelName);\n }\n }\n }\n\n subscribe(channel_name: string) {\n var channel = this.channels.add(channel_name, this);\n if (channel.subscriptionPending && channel.subscriptionCancelled) {\n channel.reinstateSubscription();\n } else if (\n !channel.subscriptionPending &&\n this.connection.state === 'connected'\n ) {\n channel.subscribe();\n }\n return channel;\n }\n\n unsubscribe(channel_name: string) {\n var channel = this.channels.find(channel_name);\n if (channel && channel.subscriptionPending) {\n channel.cancelSubscription();\n } else {\n channel = this.channels.remove(channel_name);\n if (channel && channel.subscribed) {\n channel.unsubscribe();\n }\n }\n }\n\n send_event(event_name: string, data: any, channel?: string) {\n return this.connection.send_event(event_name, data, channel);\n }\n\n shouldUseTLS(): boolean {\n return this.config.useTLS;\n }\n\n signin() {\n this.user.signin();\n }\n}\n\nfunction checkAppKey(key) {\n if (key === null || key === undefined) {\n throw 'You must pass your app key when you instantiate Pusher.';\n }\n}\n\nRuntime.setup(Pusher);\n"],"sourceRoot":""} \ No newline at end of file +{"version":3,"sources":["webpack://Pusher/webpack/universalModuleDefinition","webpack://Pusher/webpack/bootstrap","webpack://Pusher/./node_modules/@stablelib/base64/base64.ts","webpack://Pusher/./node_modules/@stablelib/utf8/utf8.ts","webpack://Pusher/./src/core/pusher.js","webpack://Pusher/./src/runtimes/web/dom/script_receiver_factory.ts","webpack://Pusher/./src/core/defaults.ts","webpack://Pusher/./src/runtimes/web/dom/dependency_loader.ts","webpack://Pusher/./src/runtimes/web/dom/dependencies.ts","webpack://Pusher/./src/core/utils/url_store.ts","webpack://Pusher/./src/core/auth/options.ts","webpack://Pusher/./src/core/errors.ts","webpack://Pusher/./src/runtimes/isomorphic/auth/xhr_auth.ts","webpack://Pusher/./src/core/base64.ts","webpack://Pusher/./src/core/utils/timers/abstract_timer.ts","webpack://Pusher/./src/core/utils/timers/index.ts","webpack://Pusher/./src/core/util.ts","webpack://Pusher/./src/core/utils/collections.ts","webpack://Pusher/./src/core/logger.ts","webpack://Pusher/./src/runtimes/web/auth/jsonp_auth.ts","webpack://Pusher/./src/runtimes/web/dom/script_request.ts","webpack://Pusher/./src/runtimes/web/dom/jsonp_request.ts","webpack://Pusher/./src/runtimes/web/timeline/jsonp_timeline.ts","webpack://Pusher/./src/core/transports/url_schemes.ts","webpack://Pusher/./src/core/events/callback_registry.ts","webpack://Pusher/./src/core/events/dispatcher.ts","webpack://Pusher/./src/core/transports/transport_connection.ts","webpack://Pusher/./src/core/transports/transport.ts","webpack://Pusher/./src/runtimes/isomorphic/transports/transports.ts","webpack://Pusher/./src/runtimes/web/transports/transports.ts","webpack://Pusher/./src/runtimes/web/net_info.ts","webpack://Pusher/./src/core/transports/assistant_to_the_transport_manager.ts","webpack://Pusher/./src/core/connection/protocol/protocol.ts","webpack://Pusher/./src/core/connection/connection.ts","webpack://Pusher/./src/core/connection/handshake/index.ts","webpack://Pusher/./src/core/timeline/timeline_sender.ts","webpack://Pusher/./src/core/channels/channel.ts","webpack://Pusher/./src/core/channels/private_channel.ts","webpack://Pusher/./src/core/channels/members.ts","webpack://Pusher/./src/core/channels/presence_channel.ts","webpack://Pusher/./src/core/channels/encrypted_channel.ts","webpack://Pusher/./src/core/connection/connection_manager.ts","webpack://Pusher/./src/core/channels/channels.ts","webpack://Pusher/./src/core/utils/factory.ts","webpack://Pusher/./src/core/transports/transport_manager.ts","webpack://Pusher/./src/core/strategies/sequential_strategy.ts","webpack://Pusher/./src/core/strategies/best_connected_ever_strategy.ts","webpack://Pusher/./src/core/strategies/websocket_prioritized_cached_strategy.ts","webpack://Pusher/./src/core/strategies/delayed_strategy.ts","webpack://Pusher/./src/core/strategies/if_strategy.ts","webpack://Pusher/./src/core/strategies/first_connected_strategy.ts","webpack://Pusher/./src/runtimes/web/default_strategy.ts","webpack://Pusher/./src/runtimes/web/transports/transport_connection_initializer.ts","webpack://Pusher/./src/runtimes/web/http/http_xdomain_request.ts","webpack://Pusher/./src/core/http/http_request.ts","webpack://Pusher/./src/core/http/state.ts","webpack://Pusher/./src/core/http/http_socket.ts","webpack://Pusher/./src/core/http/http_streaming_socket.ts","webpack://Pusher/./src/core/http/http_polling_socket.ts","webpack://Pusher/./src/runtimes/isomorphic/http/http_xhr_request.ts","webpack://Pusher/./src/runtimes/isomorphic/http/http.ts","webpack://Pusher/./src/runtimes/web/http/http.ts","webpack://Pusher/./src/runtimes/web/runtime.ts","webpack://Pusher/./src/core/timeline/level.ts","webpack://Pusher/./src/core/timeline/timeline.ts","webpack://Pusher/./src/core/strategies/transport_strategy.ts","webpack://Pusher/./src/core/strategies/strategy_builder.ts","webpack://Pusher/./src/core/options.ts","webpack://Pusher/./src/core/auth/user_authenticator.ts","webpack://Pusher/./src/core/auth/channel_authorizer.ts","webpack://Pusher/./src/core/auth/deprecated_channel_authorizer.ts","webpack://Pusher/./src/core/config.ts","webpack://Pusher/./src/core/watchlist.ts","webpack://Pusher/./src/core/utils/flat_promise.ts","webpack://Pusher/./src/core/user.ts","webpack://Pusher/./src/core/pusher.ts"],"names":[],"mappings":";;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AACD,O;QCVA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;;QAEA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;;;QAGA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;QACA,0CAA0C,gCAAgC;QAC1E;QACA;;QAEA;QACA;QACA;QACA,wDAAwD,kBAAkB;QAC1E;QACA,iDAAiD,cAAc;QAC/D;;QAEA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA,yCAAyC,iCAAiC;QAC1E,gHAAgH,mBAAmB,EAAE;QACrI;QACA;;QAEA;QACA;QACA;QACA,2BAA2B,0BAA0B,EAAE;QACvD,iCAAiC,eAAe;QAChD;QACA;QACA;;QAEA;QACA,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AE,CAAC;SAC9B;aAAM;YACL,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;YAC7C,IAAI,OAAO,IAAI,OAAO,CAAC,UAAU,EAAE;gBACjC,OAAO,CAAC,WAAW,EAAE,CAAC;aACvB;SACF;IACH,CAAC;IAED,UAAU,CAAC,UAAkB,EAAE,IAAS,EAAE,OAAgB;QACxD,OAAO,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC,UAAU,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;IAC/D,CAAC;IAED,YAAY;QACV,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC;IAC5B,CAAC;IAED,MAAM;QACJ,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;IACrB,CAAC;;AAvOM,uBAAS,GAAa,EAAE,CAAC;AACzB,qBAAO,GAAY,KAAK,CAAC;AACzB,0BAAY,GAAY,KAAK,CAAC;AAG9B,qBAAO,GAAoB,OAAO,CAAC;AACnC,6BAAe,GAAc,OAAQ,CAAC,eAAe,CAAC;AACtD,mCAAqB,GAAc,OAAQ,CAAC,qBAAqB,CAAC;AAClE,4BAAc,GAAc,OAAQ,CAAC,cAAc,CAAC;AAVxC,8FAAM;AA4O3B,SAAS,WAAW,CAAC,GAAG;IACtB,IAAI,GAAG,KAAK,IAAI,IAAI,GAAG,KAAK,SAAS,EAAE;QACrC,MAAM,yDAAyD,CAAC;KACjE;AACH,CAAC;AAED,OAAO,CAAC,KAAK,CAAC,aAAM,CAAC,CAAC","file":"pusher.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"Pusher\"] = factory();\n\telse\n\t\troot[\"Pusher\"] = factory();\n})(window, function() {\nreturn "," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 2);\n","// Copyright (C) 2016 Dmitry Chestnykh\n// MIT License. See LICENSE file for details.\n\n/**\n * Package base64 implements Base64 encoding and decoding.\n */\n\n// Invalid character used in decoding to indicate\n// that the character to decode is out of range of\n// alphabet and cannot be decoded.\nconst INVALID_BYTE = 256;\n\n/**\n * Implements standard Base64 encoding.\n *\n * Operates in constant time.\n */\nexport class Coder {\n // TODO(dchest): methods to encode chunk-by-chunk.\n\n constructor(private _paddingCharacter = \"=\") { }\n\n encodedLength(length: number): number {\n if (!this._paddingCharacter) {\n return (length * 8 + 5) / 6 | 0;\n }\n return (length + 2) / 3 * 4 | 0;\n }\n\n encode(data: Uint8Array): string {\n let out = \"\";\n\n let i = 0;\n for (; i < data.length - 2; i += 3) {\n let c = (data[i] << 16) | (data[i + 1] << 8) | (data[i + 2]);\n out += this._encodeByte((c >>> 3 * 6) & 63);\n out += this._encodeByte((c >>> 2 * 6) & 63);\n out += this._encodeByte((c >>> 1 * 6) & 63);\n out += this._encodeByte((c >>> 0 * 6) & 63);\n }\n\n const left = data.length - i;\n if (left > 0) {\n let c = (data[i] << 16) | (left === 2 ? data[i + 1] << 8 : 0);\n out += this._encodeByte((c >>> 3 * 6) & 63);\n out += this._encodeByte((c >>> 2 * 6) & 63);\n if (left === 2) {\n out += this._encodeByte((c >>> 1 * 6) & 63);\n } else {\n out += this._paddingCharacter || \"\";\n }\n out += this._paddingCharacter || \"\";\n }\n\n return out;\n }\n\n maxDecodedLength(length: number): number {\n if (!this._paddingCharacter) {\n return (length * 6 + 7) / 8 | 0;\n }\n return length / 4 * 3 | 0;\n }\n\n decodedLength(s: string): number {\n return this.maxDecodedLength(s.length - this._getPaddingLength(s));\n }\n\n decode(s: string): Uint8Array {\n if (s.length === 0) {\n return new Uint8Array(0);\n }\n const paddingLength = this._getPaddingLength(s);\n const length = s.length - paddingLength;\n const out = new Uint8Array(this.maxDecodedLength(length));\n let op = 0;\n let i = 0;\n let haveBad = 0;\n let v0 = 0, v1 = 0, v2 = 0, v3 = 0;\n for (; i < length - 4; i += 4) {\n v0 = this._decodeChar(s.charCodeAt(i + 0));\n v1 = this._decodeChar(s.charCodeAt(i + 1));\n v2 = this._decodeChar(s.charCodeAt(i + 2));\n v3 = this._decodeChar(s.charCodeAt(i + 3));\n out[op++] = (v0 << 2) | (v1 >>> 4);\n out[op++] = (v1 << 4) | (v2 >>> 2);\n out[op++] = (v2 << 6) | v3;\n haveBad |= v0 & INVALID_BYTE;\n haveBad |= v1 & INVALID_BYTE;\n haveBad |= v2 & INVALID_BYTE;\n haveBad |= v3 & INVALID_BYTE;\n }\n if (i < length - 1) {\n v0 = this._decodeChar(s.charCodeAt(i));\n v1 = this._decodeChar(s.charCodeAt(i + 1));\n out[op++] = (v0 << 2) | (v1 >>> 4);\n haveBad |= v0 & INVALID_BYTE;\n haveBad |= v1 & INVALID_BYTE;\n }\n if (i < length - 2) {\n v2 = this._decodeChar(s.charCodeAt(i + 2));\n out[op++] = (v1 << 4) | (v2 >>> 2);\n haveBad |= v2 & INVALID_BYTE;\n }\n if (i < length - 3) {\n v3 = this._decodeChar(s.charCodeAt(i + 3));\n out[op++] = (v2 << 6) | v3;\n haveBad |= v3 & INVALID_BYTE;\n }\n if (haveBad !== 0) {\n throw new Error(\"Base64Coder: incorrect characters for decoding\");\n }\n return out;\n }\n\n // Standard encoding have the following encoded/decoded ranges,\n // which we need to convert between.\n //\n // ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 0123456789 + /\n // Index: 0 - 25 26 - 51 52 - 61 62 63\n // ASCII: 65 - 90 97 - 122 48 - 57 43 47\n //\n\n // Encode 6 bits in b into a new character.\n protected _encodeByte(b: number): string {\n // Encoding uses constant time operations as follows:\n //\n // 1. Define comparison of A with B using (A - B) >>> 8:\n // if A > B, then result is positive integer\n // if A <= B, then result is 0\n //\n // 2. Define selection of C or 0 using bitwise AND: X & C:\n // if X == 0, then result is 0\n // if X != 0, then result is C\n //\n // 3. Start with the smallest comparison (b >= 0), which is always\n // true, so set the result to the starting ASCII value (65).\n //\n // 4. Continue comparing b to higher ASCII values, and selecting\n // zero if comparison isn't true, otherwise selecting a value\n // to add to result, which:\n //\n // a) undoes the previous addition\n // b) provides new value to add\n //\n let result = b;\n // b >= 0\n result += 65;\n // b > 25\n result += ((25 - b) >>> 8) & ((0 - 65) - 26 + 97);\n // b > 51\n result += ((51 - b) >>> 8) & ((26 - 97) - 52 + 48);\n // b > 61\n result += ((61 - b) >>> 8) & ((52 - 48) - 62 + 43);\n // b > 62\n result += ((62 - b) >>> 8) & ((62 - 43) - 63 + 47);\n\n return String.fromCharCode(result);\n }\n\n // Decode a character code into a byte.\n // Must return 256 if character is out of alphabet range.\n protected _decodeChar(c: number): number {\n // Decoding works similar to encoding: using the same comparison\n // function, but now it works on ranges: result is always incremented\n // by value, but this value becomes zero if the range is not\n // satisfied.\n //\n // Decoding starts with invalid value, 256, which is then\n // subtracted when the range is satisfied. If none of the ranges\n // apply, the function returns 256, which is then checked by\n // the caller to throw error.\n let result = INVALID_BYTE; // start with invalid character\n\n // c == 43 (c > 42 and c < 44)\n result += (((42 - c) & (c - 44)) >>> 8) & (-INVALID_BYTE + c - 43 + 62);\n // c == 47 (c > 46 and c < 48)\n result += (((46 - c) & (c - 48)) >>> 8) & (-INVALID_BYTE + c - 47 + 63);\n // c > 47 and c < 58\n result += (((47 - c) & (c - 58)) >>> 8) & (-INVALID_BYTE + c - 48 + 52);\n // c > 64 and c < 91\n result += (((64 - c) & (c - 91)) >>> 8) & (-INVALID_BYTE + c - 65 + 0);\n // c > 96 and c < 123\n result += (((96 - c) & (c - 123)) >>> 8) & (-INVALID_BYTE + c - 97 + 26);\n\n return result;\n }\n\n private _getPaddingLength(s: string): number {\n let paddingLength = 0;\n if (this._paddingCharacter) {\n for (let i = s.length - 1; i >= 0; i--) {\n if (s[i] !== this._paddingCharacter) {\n break;\n }\n paddingLength++;\n }\n if (s.length < 4 || paddingLength > 2) {\n throw new Error(\"Base64Coder: incorrect padding\");\n }\n }\n return paddingLength;\n }\n\n}\n\nconst stdCoder = new Coder();\n\nexport function encode(data: Uint8Array): string {\n return stdCoder.encode(data);\n}\n\nexport function decode(s: string): Uint8Array {\n return stdCoder.decode(s);\n}\n\n/**\n * Implements URL-safe Base64 encoding.\n * (Same as Base64, but '+' is replaced with '-', and '/' with '_').\n *\n * Operates in constant time.\n */\nexport class URLSafeCoder extends Coder {\n // URL-safe encoding have the following encoded/decoded ranges:\n //\n // ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 0123456789 - _\n // Index: 0 - 25 26 - 51 52 - 61 62 63\n // ASCII: 65 - 90 97 - 122 48 - 57 45 95\n //\n\n protected _encodeByte(b: number): string {\n let result = b;\n // b >= 0\n result += 65;\n // b > 25\n result += ((25 - b) >>> 8) & ((0 - 65) - 26 + 97);\n // b > 51\n result += ((51 - b) >>> 8) & ((26 - 97) - 52 + 48);\n // b > 61\n result += ((61 - b) >>> 8) & ((52 - 48) - 62 + 45);\n // b > 62\n result += ((62 - b) >>> 8) & ((62 - 45) - 63 + 95);\n\n return String.fromCharCode(result);\n }\n\n protected _decodeChar(c: number): number {\n let result = INVALID_BYTE;\n\n // c == 45 (c > 44 and c < 46)\n result += (((44 - c) & (c - 46)) >>> 8) & (-INVALID_BYTE + c - 45 + 62);\n // c == 95 (c > 94 and c < 96)\n result += (((94 - c) & (c - 96)) >>> 8) & (-INVALID_BYTE + c - 95 + 63);\n // c > 47 and c < 58\n result += (((47 - c) & (c - 58)) >>> 8) & (-INVALID_BYTE + c - 48 + 52);\n // c > 64 and c < 91\n result += (((64 - c) & (c - 91)) >>> 8) & (-INVALID_BYTE + c - 65 + 0);\n // c > 96 and c < 123\n result += (((96 - c) & (c - 123)) >>> 8) & (-INVALID_BYTE + c - 97 + 26);\n\n return result;\n }\n}\n\nconst urlSafeCoder = new URLSafeCoder();\n\nexport function encodeURLSafe(data: Uint8Array): string {\n return urlSafeCoder.encode(data);\n}\n\nexport function decodeURLSafe(s: string): Uint8Array {\n return urlSafeCoder.decode(s);\n}\n\n\nexport const encodedLength = (length: number) =>\n stdCoder.encodedLength(length);\n\nexport const maxDecodedLength = (length: number) =>\n stdCoder.maxDecodedLength(length);\n\nexport const decodedLength = (s: string) =>\n stdCoder.decodedLength(s);\n","// Copyright (C) 2016 Dmitry Chestnykh\n// MIT License. See LICENSE file for details.\n\n/**\n * Package utf8 implements UTF-8 encoding and decoding.\n */\n\nconst INVALID_UTF16 = \"utf8: invalid string\";\nconst INVALID_UTF8 = \"utf8: invalid source encoding\";\n\n/**\n * Encodes the given string into UTF-8 byte array.\n * Throws if the source string has invalid UTF-16 encoding.\n */\nexport function encode(s: string): Uint8Array {\n // Calculate result length and allocate output array.\n // encodedLength() also validates string and throws errors,\n // so we don't need repeat validation here.\n const arr = new Uint8Array(encodedLength(s));\n\n let pos = 0;\n for (let i = 0; i < s.length; i++) {\n let c = s.charCodeAt(i);\n if (c < 0x80) {\n arr[pos++] = c;\n } else if (c < 0x800) {\n arr[pos++] = 0xc0 | c >> 6;\n arr[pos++] = 0x80 | c & 0x3f;\n } else if (c < 0xd800) {\n arr[pos++] = 0xe0 | c >> 12;\n arr[pos++] = 0x80 | (c >> 6) & 0x3f;\n arr[pos++] = 0x80 | c & 0x3f;\n } else {\n i++; // get one more character\n c = (c & 0x3ff) << 10;\n c |= s.charCodeAt(i) & 0x3ff;\n c += 0x10000;\n\n arr[pos++] = 0xf0 | c >> 18;\n arr[pos++] = 0x80 | (c >> 12) & 0x3f;\n arr[pos++] = 0x80 | (c >> 6) & 0x3f;\n arr[pos++] = 0x80 | c & 0x3f;\n }\n }\n return arr;\n}\n\n/**\n * Returns the number of bytes required to encode the given string into UTF-8.\n * Throws if the source string has invalid UTF-16 encoding.\n */\nexport function encodedLength(s: string): number {\n let result = 0;\n for (let i = 0; i < s.length; i++) {\n const c = s.charCodeAt(i);\n if (c < 0x80) {\n result += 1;\n } else if (c < 0x800) {\n result += 2;\n } else if (c < 0xd800) {\n result += 3;\n } else if (c <= 0xdfff) {\n if (i >= s.length - 1) {\n throw new Error(INVALID_UTF16);\n }\n i++; // \"eat\" next character\n result += 4;\n } else {\n throw new Error(INVALID_UTF16);\n }\n }\n return result;\n}\n\n/**\n * Decodes the given byte array from UTF-8 into a string.\n * Throws if encoding is invalid.\n */\nexport function decode(arr: Uint8Array): string {\n const chars: string[] = [];\n for (let i = 0; i < arr.length; i++) {\n let b = arr[i];\n\n if (b & 0x80) {\n let min;\n if (b < 0xe0) {\n // Need 1 more byte.\n if (i >= arr.length) {\n throw new Error(INVALID_UTF8);\n }\n const n1 = arr[++i];\n if ((n1 & 0xc0) !== 0x80) {\n throw new Error(INVALID_UTF8);\n }\n b = (b & 0x1f) << 6 | (n1 & 0x3f);\n min = 0x80;\n } else if (b < 0xf0) {\n // Need 2 more bytes.\n if (i >= arr.length - 1) {\n throw new Error(INVALID_UTF8);\n }\n const n1 = arr[++i];\n const n2 = arr[++i];\n if ((n1 & 0xc0) !== 0x80 || (n2 & 0xc0) !== 0x80) {\n throw new Error(INVALID_UTF8);\n }\n b = (b & 0x0f) << 12 | (n1 & 0x3f) << 6 | (n2 & 0x3f);\n min = 0x800;\n } else if (b < 0xf8) {\n // Need 3 more bytes.\n if (i >= arr.length - 2) {\n throw new Error(INVALID_UTF8);\n }\n const n1 = arr[++i];\n const n2 = arr[++i];\n const n3 = arr[++i];\n if ((n1 & 0xc0) !== 0x80 || (n2 & 0xc0) !== 0x80 || (n3 & 0xc0) !== 0x80) {\n throw new Error(INVALID_UTF8);\n }\n b = (b & 0x0f) << 18 | (n1 & 0x3f) << 12 | (n2 & 0x3f) << 6 | (n3 & 0x3f);\n min = 0x10000;\n } else {\n throw new Error(INVALID_UTF8);\n }\n\n if (b < min || (b >= 0xd800 && b <= 0xdfff)) {\n throw new Error(INVALID_UTF8);\n }\n\n if (b >= 0x10000) {\n // Surrogate pair.\n if (b > 0x10ffff) {\n throw new Error(INVALID_UTF8);\n }\n b -= 0x10000;\n chars.push(String.fromCharCode(0xd800 | (b >> 10)));\n b = 0xdc00 | (b & 0x3ff);\n }\n }\n\n chars.push(String.fromCharCode(b));\n }\n return chars.join(\"\");\n}\n","// required so we don't have to do require('pusher').default etc.\nmodule.exports = require('./pusher').default;\n","import ScriptReceiver from './script_receiver';\n\n/** Builds receivers for JSONP and Script requests.\n *\n * Each receiver is an object with following fields:\n * - number - unique (for the factory instance), numerical id of the receiver\n * - id - a string ID that can be used in DOM attributes\n * - name - name of the function triggering the receiver\n * - callback - callback function\n *\n * Receivers are triggered only once, on the first callback call.\n *\n * Receivers can be called by their name or by accessing factory object\n * by the number key.\n *\n * @param {String} prefix the prefix used in ids\n * @param {String} name the name of the object\n */\nexport class ScriptReceiverFactory {\n lastId: number;\n prefix: string;\n name: string;\n\n constructor(prefix: string, name: string) {\n this.lastId = 0;\n this.prefix = prefix;\n this.name = name;\n }\n\n create(callback: Function): ScriptReceiver {\n this.lastId++;\n\n var number = this.lastId;\n var id = this.prefix + number;\n var name = this.name + '[' + number + ']';\n\n var called = false;\n var callbackWrapper = function() {\n if (!called) {\n callback.apply(null, arguments);\n called = true;\n }\n };\n\n this[number] = callbackWrapper;\n return { number: number, id: id, name: name, callback: callbackWrapper };\n }\n\n remove(receiver: ScriptReceiver) {\n delete this[receiver.number];\n }\n}\n\nexport var ScriptReceivers = new ScriptReceiverFactory(\n '_pusher_script_',\n 'Pusher.ScriptReceivers'\n);\n","import {\n ChannelAuthorizationOptions,\n UserAuthenticationOptions\n} from './auth/options';\nimport { AuthTransport } from './config';\n\nexport interface DefaultConfig {\n VERSION: string;\n PROTOCOL: number;\n wsPort: number;\n wssPort: number;\n wsPath: string;\n httpHost: string;\n httpPort: number;\n httpsPort: number;\n httpPath: string;\n stats_host: string;\n authEndpoint: string;\n authTransport: AuthTransport;\n activityTimeout: number;\n pongTimeout: number;\n unavailableTimeout: number;\n userAuthentication: UserAuthenticationOptions;\n channelAuthorization: ChannelAuthorizationOptions;\n\n cdn_http?: string;\n cdn_https?: string;\n dependency_suffix?: string;\n}\n\nvar Defaults: DefaultConfig = {\n VERSION: VERSION,\n PROTOCOL: 7,\n\n wsPort: 80,\n wssPort: 443,\n wsPath: '',\n // DEPRECATED: SockJS fallback parameters\n httpHost: 'sockjs.pusher.com',\n httpPort: 80,\n httpsPort: 443,\n httpPath: '/pusher',\n // DEPRECATED: Stats\n stats_host: 'stats.pusher.com',\n // DEPRECATED: Other settings\n authEndpoint: '/pusher/auth',\n authTransport: 'ajax',\n activityTimeout: 120000,\n pongTimeout: 30000,\n unavailableTimeout: 10000,\n userAuthentication: {\n endpoint: '/pusher/user-auth',\n transport: 'ajax'\n },\n channelAuthorization: {\n endpoint: '/pusher/auth',\n transport: 'ajax'\n },\n\n // CDN configuration\n cdn_http: CDN_HTTP,\n cdn_https: CDN_HTTPS,\n dependency_suffix: DEPENDENCY_SUFFIX\n};\n\nexport default Defaults;\n","import {\n ScriptReceivers,\n ScriptReceiverFactory\n} from './script_receiver_factory';\nimport Runtime from 'runtime';\nimport ScriptRequest from './script_request';\n\n/** Handles loading dependency files.\n *\n * Dependency loaders don't remember whether a resource has been loaded or\n * not. It is caller's responsibility to make sure the resource is not loaded\n * twice. This is because it's impossible to detect resource loading status\n * without knowing its content.\n *\n * Options:\n * - cdn_http - url to HTTP CND\n * - cdn_https - url to HTTPS CDN\n * - version - version of pusher-js\n * - suffix - suffix appended to all names of dependency files\n *\n * @param {Object} options\n */\nexport default class DependencyLoader {\n options: any;\n receivers: ScriptReceiverFactory;\n loading: any;\n\n constructor(options: any) {\n this.options = options;\n this.receivers = options.receivers || ScriptReceivers;\n this.loading = {};\n }\n\n /** Loads the dependency from CDN.\n *\n * @param {String} name\n * @param {Function} callback\n */\n load(name: string, options: any, callback: Function) {\n var self = this;\n\n if (self.loading[name] && self.loading[name].length > 0) {\n self.loading[name].push(callback);\n } else {\n self.loading[name] = [callback];\n\n var request = Runtime.createScriptRequest(self.getPath(name, options));\n var receiver = self.receivers.create(function(error) {\n self.receivers.remove(receiver);\n\n if (self.loading[name]) {\n var callbacks = self.loading[name];\n delete self.loading[name];\n\n var successCallback = function(wasSuccessful) {\n if (!wasSuccessful) {\n request.cleanup();\n }\n };\n for (var i = 0; i < callbacks.length; i++) {\n callbacks[i](error, successCallback);\n }\n }\n });\n request.send(receiver);\n }\n }\n\n /** Returns a root URL for pusher-js CDN.\n *\n * @returns {String}\n */\n getRoot(options: any): string {\n var cdn;\n var protocol = Runtime.getDocument().location.protocol;\n if ((options && options.useTLS) || protocol === 'https:') {\n cdn = this.options.cdn_https;\n } else {\n cdn = this.options.cdn_http;\n }\n // make sure there are no double slashes\n return cdn.replace(/\\/*$/, '') + '/' + this.options.version;\n }\n\n /** Returns a full path to a dependency file.\n *\n * @param {String} name\n * @returns {String}\n */\n getPath(name: string, options: any): string {\n return this.getRoot(options) + '/' + name + this.options.suffix + '.js';\n }\n}\n","import { ScriptReceiverFactory } from './script_receiver_factory';\nimport Defaults from 'core/defaults';\nimport DependencyLoader from './dependency_loader';\n\nexport var DependenciesReceivers = new ScriptReceiverFactory(\n '_pusher_dependencies',\n 'Pusher.DependenciesReceivers'\n);\n\nexport var Dependencies = new DependencyLoader({\n cdn_http: Defaults.cdn_http,\n cdn_https: Defaults.cdn_https,\n version: Defaults.VERSION,\n suffix: Defaults.dependency_suffix,\n receivers: DependenciesReceivers\n});\n","/**\n * A place to store help URLs for error messages etc\n */\n\nconst urlStore = {\n baseUrl: 'https://pusher.com',\n urls: {\n authenticationEndpoint: {\n path: '/docs/channels/server_api/authenticating_users'\n },\n authorizationEndpoint: {\n path: '/docs/channels/server_api/authorizing-users/'\n },\n javascriptQuickStart: {\n path: '/docs/javascript_quick_start'\n },\n triggeringClientEvents: {\n path: '/docs/client_api_guide/client_events#trigger-events'\n },\n encryptedChannelSupport: {\n fullUrl:\n 'https://github.com/pusher/pusher-js/tree/cc491015371a4bde5743d1c87a0fbac0feb53195#encrypted-channel-support'\n }\n }\n};\n\n/** Builds a consistent string with links to pusher documentation\n *\n * @param {string} key - relevant key in the url_store.urls object\n * @return {string} suffix string to append to log message\n */\nconst buildLogSuffix = function(key: string): string {\n const urlPrefix = 'See:';\n const urlObj = urlStore.urls[key];\n if (!urlObj) return '';\n\n let url;\n if (urlObj.fullUrl) {\n url = urlObj.fullUrl;\n } else if (urlObj.path) {\n url = urlStore.baseUrl + urlObj.path;\n }\n\n if (!url) return '';\n return `${urlPrefix} ${url}`;\n};\n\nexport default { buildLogSuffix };\n","export enum AuthRequestType {\n UserAuthentication = 'user-authentication',\n ChannelAuthorization = 'channel-authorization'\n}\n\nexport interface ChannelAuthorizationData {\n auth: string;\n channel_data?: string;\n shared_secret?: string;\n}\n\nexport type ChannelAuthorizationCallback = (\n error: Error | null,\n authData: ChannelAuthorizationData | null\n) => void;\n\nexport interface ChannelAuthorizationRequestParams {\n socketId: string;\n channelName: string;\n}\n\nexport interface ChannelAuthorizationHandler {\n (\n params: ChannelAuthorizationRequestParams,\n callback: ChannelAuthorizationCallback\n ): void;\n}\n\nexport interface UserAuthenticationData {\n auth: string;\n user_data: string;\n}\n\nexport type UserAuthenticationCallback = (\n error: Error | null,\n authData: UserAuthenticationData | null\n) => void;\n\nexport interface UserAuthenticationRequestParams {\n socketId: string;\n}\n\nexport interface UserAuthenticationHandler {\n (\n params: UserAuthenticationRequestParams,\n callback: UserAuthenticationCallback\n ): void;\n}\n\nexport type AuthTransportCallback =\n | ChannelAuthorizationCallback\n | UserAuthenticationCallback;\n\nexport interface AuthOptionsT {\n transport: 'ajax' | 'jsonp';\n endpoint: string;\n params?: any;\n headers?: any;\n paramsProvider?: () => any;\n headersProvider?: () => any;\n customHandler?: AuthHandler;\n}\n\nexport declare type UserAuthenticationOptions = AuthOptionsT<\n UserAuthenticationHandler\n>;\nexport declare type ChannelAuthorizationOptions = AuthOptionsT<\n ChannelAuthorizationHandler\n>;\n\nexport interface InternalAuthOptions {\n transport: 'ajax' | 'jsonp';\n endpoint: string;\n params?: any;\n headers?: any;\n paramsProvider?: () => any;\n headersProvider?: () => any;\n}\n","/** Error classes used throughout the library. */\n// https://github.com/Microsoft/TypeScript-wiki/blob/master/Breaking-Changes.md#extending-built-ins-like-error-array-and-map-may-no-longer-work\nexport class BadEventName extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\nexport class BadChannelName extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\nexport class RequestTimedOut extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class TransportPriorityTooLow extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class TransportClosed extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class UnsupportedFeature extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class UnsupportedTransport extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class UnsupportedStrategy extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class HTTPAuthError extends Error {\n status: number;\n constructor(status: number, msg?: string) {\n super(msg);\n this.status = status;\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n","import TimelineSender from 'core/timeline/timeline_sender';\nimport * as Collections from 'core/utils/collections';\nimport Util from 'core/util';\nimport Runtime from 'runtime';\nimport { AuthTransport } from 'core/auth/auth_transports';\nimport AbstractRuntime from 'runtimes/interface';\nimport UrlStore from 'core/utils/url_store';\nimport {\n AuthRequestType,\n AuthTransportCallback,\n InternalAuthOptions\n} from 'core/auth/options';\nimport { HTTPAuthError } from 'core/errors';\n\nconst ajax: AuthTransport = function(\n context: AbstractRuntime,\n query: string,\n authOptions: InternalAuthOptions,\n authRequestType: AuthRequestType,\n callback: AuthTransportCallback\n) {\n const xhr = Runtime.createXHR();\n xhr.open('POST', authOptions.endpoint, true);\n\n // add request headers\n xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');\n for (var headerName in authOptions.headers) {\n xhr.setRequestHeader(headerName, authOptions.headers[headerName]);\n }\n if (authOptions.headersProvider != null) {\n let dynamicHeaders = authOptions.headersProvider();\n for (var headerName in dynamicHeaders) {\n xhr.setRequestHeader(headerName, dynamicHeaders[headerName]);\n }\n }\n\n xhr.onreadystatechange = function() {\n if (xhr.readyState === 4) {\n if (xhr.status === 200) {\n let data;\n let parsed = false;\n\n try {\n data = JSON.parse(xhr.responseText);\n parsed = true;\n } catch (e) {\n callback(\n new HTTPAuthError(\n 200,\n `JSON returned from ${authRequestType.toString()} endpoint was invalid, yet status code was 200. Data was: ${\n xhr.responseText\n }`\n ),\n null\n );\n }\n\n if (parsed) {\n // prevents double execution.\n callback(null, data);\n }\n } else {\n let suffix = '';\n switch (authRequestType) {\n case AuthRequestType.UserAuthentication:\n suffix = UrlStore.buildLogSuffix('authenticationEndpoint');\n break;\n case AuthRequestType.ChannelAuthorization:\n suffix = `Clients must be authorized to join private or presence channels. ${UrlStore.buildLogSuffix(\n 'authorizationEndpoint'\n )}`;\n break;\n }\n callback(\n new HTTPAuthError(\n xhr.status,\n `Unable to retrieve auth string from ${authRequestType.toString()} endpoint - ` +\n `received status: ${xhr.status} from ${authOptions.endpoint}. ${suffix}`\n ),\n null\n );\n }\n }\n };\n\n xhr.send(query);\n return xhr;\n};\n\nexport default ajax;\n","export default function encode(s: any): string {\n return btoa(utob(s));\n}\n\nvar fromCharCode = String.fromCharCode;\n\nvar b64chars =\n 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';\nvar b64tab = {};\n\nfor (var i = 0, l = b64chars.length; i < l; i++) {\n b64tab[b64chars.charAt(i)] = i;\n}\n\nvar cb_utob = function(c) {\n var cc = c.charCodeAt(0);\n return cc < 0x80\n ? c\n : cc < 0x800\n ? fromCharCode(0xc0 | (cc >>> 6)) + fromCharCode(0x80 | (cc & 0x3f))\n : fromCharCode(0xe0 | ((cc >>> 12) & 0x0f)) +\n fromCharCode(0x80 | ((cc >>> 6) & 0x3f)) +\n fromCharCode(0x80 | (cc & 0x3f));\n};\n\nvar utob = function(u) {\n return u.replace(/[^\\x00-\\x7F]/g, cb_utob);\n};\n\nvar cb_encode = function(ccc) {\n var padlen = [0, 2, 1][ccc.length % 3];\n var ord =\n (ccc.charCodeAt(0) << 16) |\n ((ccc.length > 1 ? ccc.charCodeAt(1) : 0) << 8) |\n (ccc.length > 2 ? ccc.charCodeAt(2) : 0);\n var chars = [\n b64chars.charAt(ord >>> 18),\n b64chars.charAt((ord >>> 12) & 63),\n padlen >= 2 ? '=' : b64chars.charAt((ord >>> 6) & 63),\n padlen >= 1 ? '=' : b64chars.charAt(ord & 63)\n ];\n return chars.join('');\n};\n\nvar btoa =\n global.btoa ||\n function(b) {\n return b.replace(/[\\s\\S]{1,3}/g, cb_encode);\n };\n","import TimedCallback from './timed_callback';\nimport { Delay, Scheduler, Canceller } from './scheduling';\n\nabstract class Timer {\n protected clear: Canceller;\n protected timer: number | void;\n\n constructor(\n set: Scheduler,\n clear: Canceller,\n delay: Delay,\n callback: TimedCallback\n ) {\n this.clear = clear;\n this.timer = set(() => {\n if (this.timer) {\n this.timer = callback(this.timer);\n }\n }, delay);\n }\n\n /** Returns whether the timer is still running.\n *\n * @return {Boolean}\n */\n isRunning(): boolean {\n return this.timer !== null;\n }\n\n /** Aborts a timer when it's running. */\n ensureAborted() {\n if (this.timer) {\n this.clear(this.timer);\n this.timer = null;\n }\n }\n}\n\nexport default Timer;\n","import Timer from './abstract_timer';\nimport TimedCallback from './timed_callback';\nimport { Delay } from './scheduling';\n\n// We need to bind clear functions this way to avoid exceptions on IE8\nfunction clearTimeout(timer) {\n global.clearTimeout(timer);\n}\nfunction clearInterval(timer) {\n global.clearInterval(timer);\n}\n\n/** Cross-browser compatible one-off timer abstraction.\n *\n * @param {Number} delay\n * @param {Function} callback\n */\nexport class OneOffTimer extends Timer {\n constructor(delay: Delay, callback: TimedCallback) {\n super(setTimeout, clearTimeout, delay, function(timer) {\n callback();\n return null;\n });\n }\n}\n\n/** Cross-browser compatible periodic timer abstraction.\n *\n * @param {Number} delay\n * @param {Function} callback\n */\nexport class PeriodicTimer extends Timer {\n constructor(delay: Delay, callback: TimedCallback) {\n super(setInterval, clearInterval, delay, function(timer) {\n callback();\n return timer;\n });\n }\n}\n","import * as Collections from './utils/collections';\nimport TimedCallback from './utils/timers/timed_callback';\nimport { OneOffTimer, PeriodicTimer } from './utils/timers';\n\nvar Util = {\n now(): number {\n if (Date.now) {\n return Date.now();\n } else {\n return new Date().valueOf();\n }\n },\n\n defer(callback: TimedCallback): OneOffTimer {\n return new OneOffTimer(0, callback);\n },\n\n /** Builds a function that will proxy a method call to its first argument.\n *\n * Allows partial application of arguments, so additional arguments are\n * prepended to the argument list.\n *\n * @param {String} name method name\n * @return {Function} proxy function\n */\n method(name: string, ...args: any[]): Function {\n var boundArguments = Array.prototype.slice.call(arguments, 1);\n return function(object) {\n return object[name].apply(object, boundArguments.concat(arguments));\n };\n }\n};\n\nexport default Util;\n","import base64encode from '../base64';\nimport Util from '../util';\n\n/** Merges multiple objects into the target argument.\n *\n * For properties that are plain Objects, performs a deep-merge. For the\n * rest it just copies the value of the property.\n *\n * To extend prototypes use it as following:\n * Pusher.Util.extend(Target.prototype, Base.prototype)\n *\n * You can also use it to merge objects without altering them:\n * Pusher.Util.extend({}, object1, object2)\n *\n * @param {Object} target\n * @return {Object} the target argument\n */\nexport function extend(target: any, ...sources: any[]): T {\n for (var i = 0; i < sources.length; i++) {\n var extensions = sources[i];\n for (var property in extensions) {\n if (\n extensions[property] &&\n extensions[property].constructor &&\n extensions[property].constructor === Object\n ) {\n target[property] = extend(target[property] || {}, extensions[property]);\n } else {\n target[property] = extensions[property];\n }\n }\n }\n return target;\n}\n\nexport function stringify(): string {\n var m = ['Pusher'];\n for (var i = 0; i < arguments.length; i++) {\n if (typeof arguments[i] === 'string') {\n m.push(arguments[i]);\n } else {\n m.push(safeJSONStringify(arguments[i]));\n }\n }\n return m.join(' : ');\n}\n\nexport function arrayIndexOf(array: any[], item: any): number {\n // MSIE doesn't have array.indexOf\n var nativeIndexOf = Array.prototype.indexOf;\n if (array === null) {\n return -1;\n }\n if (nativeIndexOf && array.indexOf === nativeIndexOf) {\n return array.indexOf(item);\n }\n for (var i = 0, l = array.length; i < l; i++) {\n if (array[i] === item) {\n return i;\n }\n }\n return -1;\n}\n\n/** Applies a function f to all properties of an object.\n *\n * Function f gets 3 arguments passed:\n * - element from the object\n * - key of the element\n * - reference to the object\n *\n * @param {Object} object\n * @param {Function} f\n */\nexport function objectApply(object: any, f: Function) {\n for (var key in object) {\n if (Object.prototype.hasOwnProperty.call(object, key)) {\n f(object[key], key, object);\n }\n }\n}\n\n/** Return a list of objects own proerty keys\n *\n * @param {Object} object\n * @returns {Array}\n */\nexport function keys(object: any): string[] {\n var keys = [];\n objectApply(object, function(_, key) {\n keys.push(key);\n });\n return keys;\n}\n\n/** Return a list of object's own property values\n *\n * @param {Object} object\n * @returns {Array}\n */\nexport function values(object: any): any[] {\n var values = [];\n objectApply(object, function(value) {\n values.push(value);\n });\n return values;\n}\n\n/** Applies a function f to all elements of an array.\n *\n * Function f gets 3 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function apply(array: any[], f: Function, context?: any) {\n for (var i = 0; i < array.length; i++) {\n f.call(context || global, array[i], i, array);\n }\n}\n\n/** Maps all elements of the array and returns the result.\n *\n * Function f gets 4 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n * - reference to the destination array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function map(array: any[], f: Function): any[] {\n var result = [];\n for (var i = 0; i < array.length; i++) {\n result.push(f(array[i], i, array, result));\n }\n return result;\n}\n\n/** Maps all elements of the object and returns the result.\n *\n * Function f gets 4 arguments passed:\n * - element from the object\n * - key of the element\n * - reference to the source object\n * - reference to the destination object\n *\n * @param {Object} object\n * @param {Function} f\n */\nexport function mapObject(object: any, f: Function): any {\n var result = {};\n objectApply(object, function(value, key) {\n result[key] = f(value);\n });\n return result;\n}\n\n/** Filters elements of the array using a test function.\n *\n * Function test gets 4 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n * - reference to the destination array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function filter(array: any[], test: Function): any[] {\n test =\n test ||\n function(value) {\n return !!value;\n };\n\n var result = [];\n for (var i = 0; i < array.length; i++) {\n if (test(array[i], i, array, result)) {\n result.push(array[i]);\n }\n }\n return result;\n}\n\n/** Filters properties of the object using a test function.\n *\n * Function test gets 4 arguments passed:\n * - element from the object\n * - key of the element\n * - reference to the source object\n * - reference to the destination object\n *\n * @param {Object} object\n * @param {Function} f\n */\nexport function filterObject(object: Object, test: Function) {\n var result = {};\n objectApply(object, function(value, key) {\n if ((test && test(value, key, object, result)) || Boolean(value)) {\n result[key] = value;\n }\n });\n return result;\n}\n\n/** Flattens an object into a two-dimensional array.\n *\n * @param {Object} object\n * @return {Array} resulting array of [key, value] pairs\n */\nexport function flatten(object: Object): any[] {\n var result = [];\n objectApply(object, function(value, key) {\n result.push([key, value]);\n });\n return result;\n}\n\n/** Checks whether any element of the array passes the test.\n *\n * Function test gets 3 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function any(array: any[], test: Function): boolean {\n for (var i = 0; i < array.length; i++) {\n if (test(array[i], i, array)) {\n return true;\n }\n }\n return false;\n}\n\n/** Checks whether all elements of the array pass the test.\n *\n * Function test gets 3 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function all(array: any[], test: Function): boolean {\n for (var i = 0; i < array.length; i++) {\n if (!test(array[i], i, array)) {\n return false;\n }\n }\n return true;\n}\n\nexport function encodeParamsObject(data): string {\n return mapObject(data, function(value) {\n if (typeof value === 'object') {\n value = safeJSONStringify(value);\n }\n return encodeURIComponent(base64encode(value.toString()));\n });\n}\n\nexport function buildQueryString(data: any): string {\n var params = filterObject(data, function(value) {\n return value !== undefined;\n });\n\n var query = map(\n flatten(encodeParamsObject(params)),\n Util.method('join', '=')\n ).join('&');\n\n return query;\n}\n\n/**\n * See https://github.com/douglascrockford/JSON-js/blob/master/cycle.js\n *\n * Remove circular references from an object. Required for JSON.stringify in\n * React Native, which tends to blow up a lot.\n *\n * @param {any} object\n * @return {any} Decycled object\n */\nexport function decycleObject(object: any): any {\n var objects = [],\n paths = [];\n\n return (function derez(value, path) {\n var i, name, nu;\n\n switch (typeof value) {\n case 'object':\n if (!value) {\n return null;\n }\n for (i = 0; i < objects.length; i += 1) {\n if (objects[i] === value) {\n return { $ref: paths[i] };\n }\n }\n\n objects.push(value);\n paths.push(path);\n\n if (Object.prototype.toString.apply(value) === '[object Array]') {\n nu = [];\n for (i = 0; i < value.length; i += 1) {\n nu[i] = derez(value[i], path + '[' + i + ']');\n }\n } else {\n nu = {};\n for (name in value) {\n if (Object.prototype.hasOwnProperty.call(value, name)) {\n nu[name] = derez(\n value[name],\n path + '[' + JSON.stringify(name) + ']'\n );\n }\n }\n }\n return nu;\n case 'number':\n case 'string':\n case 'boolean':\n return value;\n }\n })(object, '$');\n}\n\n/**\n * Provides a cross-browser and cross-platform way to safely stringify objects\n * into JSON. This is particularly necessary for ReactNative, where circular JSON\n * structures throw an exception.\n *\n * @param {any} source The object to stringify\n * @return {string} The serialized output.\n */\nexport function safeJSONStringify(source: any): string {\n try {\n return JSON.stringify(source);\n } catch (e) {\n return JSON.stringify(decycleObject(source));\n }\n}\n","import { stringify } from './utils/collections';\nimport Pusher from './pusher';\n\nclass Logger {\n debug(...args: any[]) {\n this.log(this.globalLog, args);\n }\n\n warn(...args: any[]) {\n this.log(this.globalLogWarn, args);\n }\n\n error(...args: any[]) {\n this.log(this.globalLogError, args);\n }\n\n private globalLog = (message: string) => {\n if (global.console && global.console.log) {\n global.console.log(message);\n }\n };\n\n private globalLogWarn(message: string) {\n if (global.console && global.console.warn) {\n global.console.warn(message);\n } else {\n this.globalLog(message);\n }\n }\n\n private globalLogError(message: string) {\n if (global.console && global.console.error) {\n global.console.error(message);\n } else {\n this.globalLogWarn(message);\n }\n }\n\n private log(\n defaultLoggingFunction: (message: string) => void,\n ...args: any[]\n ) {\n var message = stringify.apply(this, arguments);\n if (Pusher.log) {\n Pusher.log(message);\n } else if (Pusher.logToConsole) {\n const log = defaultLoggingFunction.bind(this);\n log(message);\n }\n }\n}\n\nexport default new Logger();\n","import Browser from '../browser';\nimport Logger from 'core/logger';\nimport JSONPRequest from '../dom/jsonp_request';\nimport { ScriptReceivers } from '../dom/script_receiver_factory';\nimport { AuthTransport } from 'core/auth/auth_transports';\nimport {\n AuthRequestType,\n AuthTransportCallback,\n InternalAuthOptions\n} from 'core/auth/options';\n\nvar jsonp: AuthTransport = function(\n context: Browser,\n query: string,\n authOptions: InternalAuthOptions,\n authRequestType: AuthRequestType,\n callback: AuthTransportCallback\n) {\n if (\n authOptions.headers !== undefined ||\n authOptions.headersProvider != null\n ) {\n Logger.warn(\n `To send headers with the ${authRequestType.toString()} request, you must use AJAX, rather than JSONP.`\n );\n }\n\n var callbackName = context.nextAuthCallbackID.toString();\n context.nextAuthCallbackID++;\n\n var document = context.getDocument();\n var script = document.createElement('script');\n // Hacked wrapper.\n context.auth_callbacks[callbackName] = function(data) {\n callback(null, data);\n };\n\n var callback_name = \"Pusher.auth_callbacks['\" + callbackName + \"']\";\n script.src =\n authOptions.endpoint +\n '?callback=' +\n encodeURIComponent(callback_name) +\n '&' +\n query;\n\n var head =\n document.getElementsByTagName('head')[0] || document.documentElement;\n head.insertBefore(script, head.firstChild);\n};\n\nexport default jsonp;\n","import ScriptReceiver from './script_receiver';\n\n/** Sends a generic HTTP GET request using a script tag.\n *\n * By constructing URL in a specific way, it can be used for loading\n * JavaScript resources or JSONP requests. It can notify about errors, but\n * only in certain environments. Please take care of monitoring the state of\n * the request yourself.\n *\n * @param {String} src\n */\nexport default class ScriptRequest {\n src: string;\n script: any;\n errorScript: any;\n\n constructor(src: string) {\n this.src = src;\n }\n\n send(receiver: ScriptReceiver) {\n var self = this;\n var errorString = 'Error loading ' + self.src;\n\n self.script = document.createElement('script');\n self.script.id = receiver.id;\n self.script.src = self.src;\n self.script.type = 'text/javascript';\n self.script.charset = 'UTF-8';\n\n if (self.script.addEventListener) {\n self.script.onerror = function() {\n receiver.callback(errorString);\n };\n self.script.onload = function() {\n receiver.callback(null);\n };\n } else {\n self.script.onreadystatechange = function() {\n if (\n self.script.readyState === 'loaded' ||\n self.script.readyState === 'complete'\n ) {\n receiver.callback(null);\n }\n };\n }\n\n // Opera<11.6 hack for missing onerror callback\n if (\n self.script.async === undefined &&\n (document).attachEvent &&\n /opera/i.test(navigator.userAgent)\n ) {\n self.errorScript = document.createElement('script');\n self.errorScript.id = receiver.id + '_error';\n self.errorScript.text = receiver.name + \"('\" + errorString + \"');\";\n self.script.async = self.errorScript.async = false;\n } else {\n self.script.async = true;\n }\n\n var head = document.getElementsByTagName('head')[0];\n head.insertBefore(self.script, head.firstChild);\n if (self.errorScript) {\n head.insertBefore(self.errorScript, self.script.nextSibling);\n }\n }\n\n /** Cleans up the DOM remains of the script request. */\n cleanup() {\n if (this.script) {\n this.script.onload = this.script.onerror = null;\n this.script.onreadystatechange = null;\n }\n if (this.script && this.script.parentNode) {\n this.script.parentNode.removeChild(this.script);\n }\n if (this.errorScript && this.errorScript.parentNode) {\n this.errorScript.parentNode.removeChild(this.errorScript);\n }\n this.script = null;\n this.errorScript = null;\n }\n}\n","import ScriptReceiver from './script_receiver';\nimport ScriptRequest from './script_request';\nimport * as Collections from 'core/utils/collections';\nimport Util from 'core/util';\nimport Runtime from '../runtime';\n\n/** Sends data via JSONP.\n *\n * Data is a key-value map. Its values are JSON-encoded and then passed\n * through base64. Finally, keys and encoded values are appended to the query\n * string.\n *\n * The class itself does not guarantee raising errors on failures, as it's not\n * possible to support such feature on all browsers. Instead, JSONP endpoint\n * should call back in a way that's easy to distinguish from browser calls,\n * for example by passing a second argument to the receiver.\n *\n * @param {String} url\n * @param {Object} data key-value map of data to be submitted\n */\nexport default class JSONPRequest {\n url: string;\n data: any;\n request: ScriptRequest;\n\n constructor(url: string, data: any) {\n this.url = url;\n this.data = data;\n }\n\n /** Sends the actual JSONP request.\n *\n * @param {ScriptReceiver} receiver\n */\n send(receiver: ScriptReceiver) {\n if (this.request) {\n return;\n }\n\n var query = Collections.buildQueryString(this.data);\n var url = this.url + '/' + receiver.number + '?' + query;\n this.request = Runtime.createScriptRequest(url);\n this.request.send(receiver);\n }\n\n /** Cleans up the DOM remains of the JSONP request. */\n cleanup() {\n if (this.request) {\n this.request.cleanup();\n }\n }\n}\n","import TimelineSender from 'core/timeline/timeline_sender';\nimport TimelineTransport from 'core/timeline/timeline_transport';\nimport Browser from 'runtime';\nimport { AuthTransport } from 'core/auth/auth_transports';\nimport { ScriptReceivers } from '../dom/script_receiver_factory';\n\nvar getAgent = function(sender: TimelineSender, useTLS: boolean) {\n return function(data: any, callback: Function) {\n var scheme = 'http' + (useTLS ? 's' : '') + '://';\n var url =\n scheme + (sender.host || sender.options.host) + sender.options.path;\n var request = Browser.createJSONPRequest(url, data);\n\n var receiver = Browser.ScriptReceivers.create(function(error, result) {\n ScriptReceivers.remove(receiver);\n request.cleanup();\n\n if (result && result.host) {\n sender.host = result.host;\n }\n if (callback) {\n callback(error, result);\n }\n });\n request.send(receiver);\n };\n};\n\nvar jsonp = {\n name: 'jsonp',\n getAgent\n};\n\nexport default jsonp;\n","import Defaults from '../defaults';\nimport { default as URLScheme, URLSchemeParams } from './url_scheme';\n\nfunction getGenericURL(\n baseScheme: string,\n params: URLSchemeParams,\n path: string\n): string {\n var scheme = baseScheme + (params.useTLS ? 's' : '');\n var host = params.useTLS ? params.hostTLS : params.hostNonTLS;\n return scheme + '://' + host + path;\n}\n\nfunction getGenericPath(key: string, queryString?: string): string {\n var path = '/app/' + key;\n var query =\n '?protocol=' +\n Defaults.PROTOCOL +\n '&client=js' +\n '&version=' +\n Defaults.VERSION +\n (queryString ? '&' + queryString : '');\n return path + query;\n}\n\nexport var ws: URLScheme = {\n getInitial: function(key: string, params: URLSchemeParams): string {\n var path = (params.httpPath || '') + getGenericPath(key, 'flash=false');\n return getGenericURL('ws', params, path);\n }\n};\n\nexport var http: URLScheme = {\n getInitial: function(key: string, params: URLSchemeParams): string {\n var path = (params.httpPath || '/pusher') + getGenericPath(key);\n return getGenericURL('http', params, path);\n }\n};\n\nexport var sockjs: URLScheme = {\n getInitial: function(key: string, params: URLSchemeParams): string {\n return getGenericURL('http', params, params.httpPath || '/pusher');\n },\n getPath: function(key: string, params: URLSchemeParams): string {\n return getGenericPath(key);\n }\n};\n","import Callback from './callback';\nimport * as Collections from '../utils/collections';\nimport CallbackTable from './callback_table';\n\nexport default class CallbackRegistry {\n _callbacks: CallbackTable;\n\n constructor() {\n this._callbacks = {};\n }\n\n get(name: string): Callback[] {\n return this._callbacks[prefix(name)];\n }\n\n add(name: string, callback: Function, context: any) {\n var prefixedEventName = prefix(name);\n this._callbacks[prefixedEventName] =\n this._callbacks[prefixedEventName] || [];\n this._callbacks[prefixedEventName].push({\n fn: callback,\n context: context\n });\n }\n\n remove(name?: string, callback?: Function, context?: any) {\n if (!name && !callback && !context) {\n this._callbacks = {};\n return;\n }\n\n var names = name ? [prefix(name)] : Collections.keys(this._callbacks);\n\n if (callback || context) {\n this.removeCallback(names, callback, context);\n } else {\n this.removeAllCallbacks(names);\n }\n }\n\n private removeCallback(names: string[], callback: Function, context: any) {\n Collections.apply(\n names,\n function(name) {\n this._callbacks[name] = Collections.filter(\n this._callbacks[name] || [],\n function(binding) {\n return (\n (callback && callback !== binding.fn) ||\n (context && context !== binding.context)\n );\n }\n );\n if (this._callbacks[name].length === 0) {\n delete this._callbacks[name];\n }\n },\n this\n );\n }\n\n private removeAllCallbacks(names: string[]) {\n Collections.apply(\n names,\n function(name) {\n delete this._callbacks[name];\n },\n this\n );\n }\n}\n\nfunction prefix(name: string): string {\n return '_' + name;\n}\n","import * as Collections from '../utils/collections';\nimport Callback from './callback';\nimport Metadata from '../channels/metadata';\nimport CallbackRegistry from './callback_registry';\n\n/** Manages callback bindings and event emitting.\n *\n * @param Function failThrough called when no listeners are bound to an event\n */\nexport default class Dispatcher {\n callbacks: CallbackRegistry;\n global_callbacks: Function[];\n failThrough: Function;\n\n constructor(failThrough?: Function) {\n this.callbacks = new CallbackRegistry();\n this.global_callbacks = [];\n this.failThrough = failThrough;\n }\n\n bind(eventName: string, callback: Function, context?: any) {\n this.callbacks.add(eventName, callback, context);\n return this;\n }\n\n bind_global(callback: Function) {\n this.global_callbacks.push(callback);\n return this;\n }\n\n unbind(eventName?: string, callback?: Function, context?: any) {\n this.callbacks.remove(eventName, callback, context);\n return this;\n }\n\n unbind_global(callback?: Function) {\n if (!callback) {\n this.global_callbacks = [];\n return this;\n }\n\n this.global_callbacks = Collections.filter(\n this.global_callbacks || [],\n c => c !== callback\n );\n\n return this;\n }\n\n unbind_all() {\n this.unbind();\n this.unbind_global();\n return this;\n }\n\n emit(eventName: string, data?: any, metadata?: Metadata): Dispatcher {\n for (var i = 0; i < this.global_callbacks.length; i++) {\n this.global_callbacks[i](eventName, data);\n }\n\n var callbacks = this.callbacks.get(eventName);\n var args = [];\n\n if (metadata) {\n // if there's a metadata argument, we need to call the callback with both\n // data and metadata regardless of whether data is undefined\n args.push(data, metadata);\n } else if (data) {\n // metadata is undefined, so we only need to call the callback with data\n // if data exists\n args.push(data);\n }\n\n if (callbacks && callbacks.length > 0) {\n for (var i = 0; i < callbacks.length; i++) {\n callbacks[i].fn.apply(callbacks[i].context || global, args);\n }\n } else if (this.failThrough) {\n this.failThrough(eventName, data);\n }\n\n return this;\n }\n}\n","import Util from '../util';\nimport * as Collections from '../utils/collections';\nimport { default as EventsDispatcher } from '../events/dispatcher';\nimport Logger from '../logger';\nimport TransportHooks from './transport_hooks';\nimport Socket from '../socket';\nimport Runtime from 'runtime';\nimport Timeline from '../timeline/timeline';\nimport TransportConnectionOptions from './transport_connection_options';\n\n/** Provides universal API for transport connections.\n *\n * Transport connection is a low-level object that wraps a connection method\n * and exposes a simple evented interface for the connection state and\n * messaging. It does not implement Pusher-specific WebSocket protocol.\n *\n * Additionally, it fetches resources needed for transport to work and exposes\n * an interface for querying transport features.\n *\n * States:\n * - new - initial state after constructing the object\n * - initializing - during initialization phase, usually fetching resources\n * - intialized - ready to establish a connection\n * - connection - when connection is being established\n * - open - when connection ready to be used\n * - closed - after connection was closed be either side\n *\n * Emits:\n * - error - after the connection raised an error\n *\n * Options:\n * - useTLS - whether connection should be over TLS\n * - hostTLS - host to connect to when connection is over TLS\n * - hostNonTLS - host to connect to when connection is over TLS\n *\n * @param {String} key application key\n * @param {Object} options\n */\nexport default class TransportConnection extends EventsDispatcher {\n hooks: TransportHooks;\n name: string;\n priority: number;\n key: string;\n options: TransportConnectionOptions;\n state: string;\n timeline: Timeline;\n activityTimeout: number;\n id: number;\n socket: Socket;\n beforeOpen: Function;\n initialize: Function;\n\n constructor(\n hooks: TransportHooks,\n name: string,\n priority: number,\n key: string,\n options: TransportConnectionOptions\n ) {\n super();\n this.initialize = Runtime.transportConnectionInitializer;\n this.hooks = hooks;\n this.name = name;\n this.priority = priority;\n this.key = key;\n this.options = options;\n\n this.state = 'new';\n this.timeline = options.timeline;\n this.activityTimeout = options.activityTimeout;\n this.id = this.timeline.generateUniqueID();\n }\n\n /** Checks whether the transport handles activity checks by itself.\n *\n * @return {Boolean}\n */\n handlesActivityChecks(): boolean {\n return Boolean(this.hooks.handlesActivityChecks);\n }\n\n /** Checks whether the transport supports the ping/pong API.\n *\n * @return {Boolean}\n */\n supportsPing(): boolean {\n return Boolean(this.hooks.supportsPing);\n }\n\n /** Tries to establish a connection.\n *\n * @returns {Boolean} false if transport is in invalid state\n */\n connect(): boolean {\n if (this.socket || this.state !== 'initialized') {\n return false;\n }\n\n var url = this.hooks.urls.getInitial(this.key, this.options);\n try {\n this.socket = this.hooks.getSocket(url, this.options);\n } catch (e) {\n Util.defer(() => {\n this.onError(e);\n this.changeState('closed');\n });\n return false;\n }\n\n this.bindListeners();\n\n Logger.debug('Connecting', { transport: this.name, url });\n this.changeState('connecting');\n return true;\n }\n\n /** Closes the connection.\n *\n * @return {Boolean} true if there was a connection to close\n */\n close(): boolean {\n if (this.socket) {\n this.socket.close();\n return true;\n } else {\n return false;\n }\n }\n\n /** Sends data over the open connection.\n *\n * @param {String} data\n * @return {Boolean} true only when in the \"open\" state\n */\n send(data: any): boolean {\n if (this.state === 'open') {\n // Workaround for MobileSafari bug (see https://gist.github.com/2052006)\n Util.defer(() => {\n if (this.socket) {\n this.socket.send(data);\n }\n });\n return true;\n } else {\n return false;\n }\n }\n\n /** Sends a ping if the connection is open and transport supports it. */\n ping() {\n if (this.state === 'open' && this.supportsPing()) {\n this.socket.ping();\n }\n }\n\n private onOpen() {\n if (this.hooks.beforeOpen) {\n this.hooks.beforeOpen(\n this.socket,\n this.hooks.urls.getPath(this.key, this.options)\n );\n }\n this.changeState('open');\n this.socket.onopen = undefined;\n }\n\n private onError(error) {\n this.emit('error', { type: 'WebSocketError', error: error });\n this.timeline.error(this.buildTimelineMessage({ error: error.toString() }));\n }\n\n private onClose(closeEvent?: any) {\n if (closeEvent) {\n this.changeState('closed', {\n code: closeEvent.code,\n reason: closeEvent.reason,\n wasClean: closeEvent.wasClean\n });\n } else {\n this.changeState('closed');\n }\n this.unbindListeners();\n this.socket = undefined;\n }\n\n private onMessage(message) {\n this.emit('message', message);\n }\n\n private onActivity() {\n this.emit('activity');\n }\n\n private bindListeners() {\n this.socket.onopen = () => {\n this.onOpen();\n };\n this.socket.onerror = error => {\n this.onError(error);\n };\n this.socket.onclose = closeEvent => {\n this.onClose(closeEvent);\n };\n this.socket.onmessage = message => {\n this.onMessage(message);\n };\n\n if (this.supportsPing()) {\n this.socket.onactivity = () => {\n this.onActivity();\n };\n }\n }\n\n private unbindListeners() {\n if (this.socket) {\n this.socket.onopen = undefined;\n this.socket.onerror = undefined;\n this.socket.onclose = undefined;\n this.socket.onmessage = undefined;\n if (this.supportsPing()) {\n this.socket.onactivity = undefined;\n }\n }\n }\n\n private changeState(state: string, params?: any) {\n this.state = state;\n this.timeline.info(\n this.buildTimelineMessage({\n state: state,\n params: params\n })\n );\n this.emit(state, params);\n }\n\n buildTimelineMessage(message): any {\n return Collections.extend({ cid: this.id }, message);\n }\n}\n","import Factory from '../utils/factory';\nimport TransportHooks from './transport_hooks';\nimport TransportConnection from './transport_connection';\nimport TransportConnectionOptions from './transport_connection_options';\n\n/** Provides interface for transport connection instantiation.\n *\n * Takes transport-specific hooks as the only argument, which allow checking\n * for transport support and creating its connections.\n *\n * Supported hooks: * - file - the name of the file to be fetched during initialization\n * - urls - URL scheme to be used by transport\n * - handlesActivityCheck - true when the transport handles activity checks\n * - supportsPing - true when the transport has a ping/activity API\n * - isSupported - tells whether the transport is supported in the environment\n * - getSocket - creates a WebSocket-compatible transport socket\n *\n * See transports.js for specific implementations.\n *\n * @param {Object} hooks object containing all needed transport hooks\n */\nexport default class Transport {\n hooks: TransportHooks;\n\n constructor(hooks: TransportHooks) {\n this.hooks = hooks;\n }\n\n /** Returns whether the transport is supported in the environment.\n *\n * @param {Object} envronment te environment details (encryption, settings)\n * @returns {Boolean} true when the transport is supported\n */\n isSupported(environment: any): boolean {\n return this.hooks.isSupported(environment);\n }\n\n /** Creates a transport connection.\n *\n * @param {String} name\n * @param {Number} priority\n * @param {String} key the application key\n * @param {Object} options\n * @returns {TransportConnection}\n */\n createConnection(\n name: string,\n priority: number,\n key: string,\n options: any\n ): TransportConnection {\n return new TransportConnection(this.hooks, name, priority, key, options);\n }\n}\n","import * as URLSchemes from 'core/transports/url_schemes';\nimport URLScheme from 'core/transports/url_scheme';\nimport Transport from 'core/transports/transport';\nimport Util from 'core/util';\nimport * as Collections from 'core/utils/collections';\nimport TransportHooks from 'core/transports/transport_hooks';\nimport TransportsTable from 'core/transports/transports_table';\nimport Runtime from 'runtime';\n\n/** WebSocket transport.\n *\n * Uses native WebSocket implementation, including MozWebSocket supported by\n * earlier Firefox versions.\n */\nvar WSTransport = new Transport({\n urls: URLSchemes.ws,\n handlesActivityChecks: false,\n supportsPing: false,\n\n isInitialized: function() {\n return Boolean(Runtime.getWebSocketAPI());\n },\n isSupported: function(): boolean {\n return Boolean(Runtime.getWebSocketAPI());\n },\n getSocket: function(url) {\n return Runtime.createWebSocket(url);\n }\n});\n\nvar httpConfiguration = {\n urls: URLSchemes.http,\n handlesActivityChecks: false,\n supportsPing: true,\n isInitialized: function() {\n return true;\n }\n};\n\nexport var streamingConfiguration = Collections.extend(\n {\n getSocket: function(url) {\n return Runtime.HTTPFactory.createStreamingSocket(url);\n }\n },\n httpConfiguration\n);\nexport var pollingConfiguration = Collections.extend(\n {\n getSocket: function(url) {\n return Runtime.HTTPFactory.createPollingSocket(url);\n }\n },\n httpConfiguration\n);\n\nvar xhrConfiguration = {\n isSupported: function(): boolean {\n return Runtime.isXHRSupported();\n }\n};\n\n/** HTTP streaming transport using CORS-enabled XMLHttpRequest. */\nvar XHRStreamingTransport = new Transport(\n (\n Collections.extend({}, streamingConfiguration, xhrConfiguration)\n )\n);\n\n/** HTTP long-polling transport using CORS-enabled XMLHttpRequest. */\nvar XHRPollingTransport = new Transport(\n Collections.extend({}, pollingConfiguration, xhrConfiguration)\n);\n\nvar Transports: TransportsTable = {\n ws: WSTransport,\n xhr_streaming: XHRStreamingTransport,\n xhr_polling: XHRPollingTransport\n};\n\nexport default Transports;\n","import {\n default as Transports,\n streamingConfiguration,\n pollingConfiguration\n} from 'isomorphic/transports/transports';\nimport Transport from 'core/transports/transport';\nimport TransportHooks from 'core/transports/transport_hooks';\nimport * as URLSchemes from 'core/transports/url_schemes';\nimport Runtime from 'runtime';\nimport { Dependencies } from '../dom/dependencies';\nimport * as Collections from 'core/utils/collections';\n\nvar SockJSTransport = new Transport({\n file: 'sockjs',\n urls: URLSchemes.sockjs,\n handlesActivityChecks: true,\n supportsPing: false,\n\n isSupported: function() {\n return true;\n },\n isInitialized: function() {\n return window.SockJS !== undefined;\n },\n getSocket: function(url, options) {\n return new window.SockJS(url, null, {\n js_path: Dependencies.getPath('sockjs', {\n useTLS: options.useTLS\n }),\n ignore_null_origin: options.ignoreNullOrigin\n });\n },\n beforeOpen: function(socket, path) {\n socket.send(\n JSON.stringify({\n path: path\n })\n );\n }\n});\n\nvar xdrConfiguration = {\n isSupported: function(environment): boolean {\n var yes = Runtime.isXDRSupported(environment.useTLS);\n return yes;\n }\n};\n\n/** HTTP streaming transport using XDomainRequest (IE 8,9). */\nvar XDRStreamingTransport = new Transport(\n (\n Collections.extend({}, streamingConfiguration, xdrConfiguration)\n )\n);\n\n/** HTTP long-polling transport using XDomainRequest (IE 8,9). */\nvar XDRPollingTransport = new Transport(\n Collections.extend({}, pollingConfiguration, xdrConfiguration)\n);\n\nTransports.xdr_streaming = XDRStreamingTransport;\nTransports.xdr_polling = XDRPollingTransport;\nTransports.sockjs = SockJSTransport;\n\nexport default Transports;\n","import Reachability from 'core/reachability';\nimport { default as EventsDispatcher } from 'core/events/dispatcher';\n\n/** Really basic interface providing network availability info.\n *\n * Emits:\n * - online - when browser goes online\n * - offline - when browser goes offline\n */\nexport class NetInfo extends EventsDispatcher implements Reachability {\n constructor() {\n super();\n var self = this;\n // This is okay, as IE doesn't support this stuff anyway.\n if (window.addEventListener !== undefined) {\n window.addEventListener(\n 'online',\n function() {\n self.emit('online');\n },\n false\n );\n window.addEventListener(\n 'offline',\n function() {\n self.emit('offline');\n },\n false\n );\n }\n }\n\n /** Returns whether browser is online or not\n *\n * Offline means definitely offline (no connection to router).\n * Inverse does NOT mean definitely online (only currently supported in Safari\n * and even there only means the device has a connection to the router).\n *\n * @return {Boolean}\n */\n isOnline(): boolean {\n if (window.navigator.onLine === undefined) {\n return true;\n } else {\n return window.navigator.onLine;\n }\n }\n}\n\nexport var Network = new NetInfo();\n","import Util from '../util';\nimport * as Collections from '../utils/collections';\nimport TransportManager from './transport_manager';\nimport TransportConnection from './transport_connection';\nimport Transport from './transport';\nimport PingDelayOptions from './ping_delay_options';\n\n/** Creates transport connections monitored by a transport manager.\n *\n * When a transport is closed, it might mean the environment does not support\n * it. It's possible that messages get stuck in an intermediate buffer or\n * proxies terminate inactive connections. To combat these problems,\n * assistants monitor the connection lifetime, report unclean exits and\n * adjust ping timeouts to keep the connection active. The decision to disable\n * a transport is the manager's responsibility.\n *\n * @param {TransportManager} manager\n * @param {TransportConnection} transport\n * @param {Object} options\n */\nexport default class AssistantToTheTransportManager {\n manager: TransportManager;\n transport: Transport;\n minPingDelay: number;\n maxPingDelay: number;\n pingDelay: number;\n\n constructor(\n manager: TransportManager,\n transport: Transport,\n options: PingDelayOptions\n ) {\n this.manager = manager;\n this.transport = transport;\n this.minPingDelay = options.minPingDelay;\n this.maxPingDelay = options.maxPingDelay;\n this.pingDelay = undefined;\n }\n\n /** Creates a transport connection.\n *\n * This function has the same API as Transport#createConnection.\n *\n * @param {String} name\n * @param {Number} priority\n * @param {String} key the application key\n * @param {Object} options\n * @returns {TransportConnection}\n */\n createConnection(\n name: string,\n priority: number,\n key: string,\n options: Object\n ): TransportConnection {\n options = Collections.extend({}, options, {\n activityTimeout: this.pingDelay\n });\n var connection = this.transport.createConnection(\n name,\n priority,\n key,\n options\n );\n\n var openTimestamp = null;\n\n var onOpen = function() {\n connection.unbind('open', onOpen);\n connection.bind('closed', onClosed);\n openTimestamp = Util.now();\n };\n var onClosed = closeEvent => {\n connection.unbind('closed', onClosed);\n\n if (closeEvent.code === 1002 || closeEvent.code === 1003) {\n // we don't want to use transports not obeying the protocol\n this.manager.reportDeath();\n } else if (!closeEvent.wasClean && openTimestamp) {\n // report deaths only for short-living transport\n var lifespan = Util.now() - openTimestamp;\n if (lifespan < 2 * this.maxPingDelay) {\n this.manager.reportDeath();\n this.pingDelay = Math.max(lifespan / 2, this.minPingDelay);\n }\n }\n };\n\n connection.bind('open', onOpen);\n return connection;\n }\n\n /** Returns whether the transport is supported in the environment.\n *\n * This function has the same API as Transport#isSupported. Might return false\n * when the manager decides to kill the transport.\n *\n * @param {Object} environment the environment details (encryption, settings)\n * @returns {Boolean} true when the transport is supported\n */\n isSupported(environment: string): boolean {\n return this.manager.isAlive() && this.transport.isSupported(environment);\n }\n}\n","import Action from './action';\nimport { PusherEvent } from './message-types';\n/**\n * Provides functions for handling Pusher protocol-specific messages.\n */\n\nconst Protocol = {\n /**\n * Decodes a message in a Pusher format.\n *\n * The MessageEvent we receive from the transport should contain a pusher event\n * (https://pusher.com/docs/pusher_protocol#events) serialized as JSON in the\n * data field\n *\n * The pusher event may contain a data field too, and it may also be\n * serialised as JSON\n *\n * Throws errors when messages are not parse'able.\n *\n * @param {MessageEvent} messageEvent\n * @return {PusherEvent}\n */\n decodeMessage: function(messageEvent: MessageEvent): PusherEvent {\n try {\n var messageData = JSON.parse(messageEvent.data);\n var pusherEventData = messageData.data;\n if (typeof pusherEventData === 'string') {\n try {\n pusherEventData = JSON.parse(messageData.data);\n } catch (e) {}\n }\n var pusherEvent: PusherEvent = {\n event: messageData.event,\n channel: messageData.channel,\n data: pusherEventData\n };\n if (messageData.user_id) {\n pusherEvent.user_id = messageData.user_id;\n }\n return pusherEvent;\n } catch (e) {\n throw { type: 'MessageParseError', error: e, data: messageEvent.data };\n }\n },\n\n /**\n * Encodes a message to be sent.\n *\n * @param {PusherEvent} event\n * @return {String}\n */\n encodeMessage: function(event: PusherEvent): string {\n return JSON.stringify(event);\n },\n\n /**\n * Processes a handshake message and returns appropriate actions.\n *\n * Returns an object with an 'action' and other action-specific properties.\n *\n * There are three outcomes when calling this function. First is a successful\n * connection attempt, when pusher:connection_established is received, which\n * results in a 'connected' action with an 'id' property. When passed a\n * pusher:error event, it returns a result with action appropriate to the\n * close code and an error. Otherwise, it raises an exception.\n *\n * @param {String} message\n * @result Object\n */\n processHandshake: function(messageEvent: MessageEvent): Action {\n var message = Protocol.decodeMessage(messageEvent);\n\n if (message.event === 'pusher:connection_established') {\n if (!message.data.activity_timeout) {\n throw 'No activity timeout specified in handshake';\n }\n return {\n action: 'connected',\n id: message.data.socket_id,\n activityTimeout: message.data.activity_timeout * 1000\n };\n } else if (message.event === 'pusher:error') {\n // From protocol 6 close codes are sent only once, so this only\n // happens when connection does not support close codes\n return {\n action: this.getCloseAction(message.data),\n error: this.getCloseError(message.data)\n };\n } else {\n throw 'Invalid handshake';\n }\n },\n\n /**\n * Dispatches the close event and returns an appropriate action name.\n *\n * See:\n * 1. https://developer.mozilla.org/en-US/docs/WebSockets/WebSockets_reference/CloseEvent\n * 2. http://pusher.com/docs/pusher_protocol\n *\n * @param {CloseEvent} closeEvent\n * @return {String} close action name\n */\n getCloseAction: function(closeEvent): string {\n if (closeEvent.code < 4000) {\n // ignore 1000 CLOSE_NORMAL, 1001 CLOSE_GOING_AWAY,\n // 1005 CLOSE_NO_STATUS, 1006 CLOSE_ABNORMAL\n // ignore 1007...3999\n // handle 1002 CLOSE_PROTOCOL_ERROR, 1003 CLOSE_UNSUPPORTED,\n // 1004 CLOSE_TOO_LARGE\n if (closeEvent.code >= 1002 && closeEvent.code <= 1004) {\n return 'backoff';\n } else {\n return null;\n }\n } else if (closeEvent.code === 4000) {\n return 'tls_only';\n } else if (closeEvent.code < 4100) {\n return 'refused';\n } else if (closeEvent.code < 4200) {\n return 'backoff';\n } else if (closeEvent.code < 4300) {\n return 'retry';\n } else {\n // unknown error\n return 'refused';\n }\n },\n\n /**\n * Returns an error or null basing on the close event.\n *\n * Null is returned when connection was closed cleanly. Otherwise, an object\n * with error details is returned.\n *\n * @param {CloseEvent} closeEvent\n * @return {Object} error object\n */\n getCloseError: function(closeEvent): any {\n if (closeEvent.code !== 1000 && closeEvent.code !== 1001) {\n return {\n type: 'PusherError',\n data: {\n code: closeEvent.code,\n message: closeEvent.reason || closeEvent.message\n }\n };\n } else {\n return null;\n }\n }\n};\n\nexport default Protocol;\n","import * as Collections from '../utils/collections';\nimport { default as EventsDispatcher } from '../events/dispatcher';\nimport Protocol from './protocol/protocol';\nimport { PusherEvent } from './protocol/message-types';\nimport Logger from '../logger';\nimport TransportConnection from '../transports/transport_connection';\nimport Socket from '../socket';\n/**\n * Provides Pusher protocol interface for transports.\n *\n * Emits following events:\n * - message - on received messages\n * - ping - on ping requests\n * - pong - on pong responses\n * - error - when the transport emits an error\n * - closed - after closing the transport\n *\n * It also emits more events when connection closes with a code.\n * See Protocol.getCloseAction to get more details.\n *\n * @param {Number} id\n * @param {AbstractTransport} transport\n */\nexport default class Connection extends EventsDispatcher implements Socket {\n id: string;\n transport: TransportConnection;\n activityTimeout: number;\n\n constructor(id: string, transport: TransportConnection) {\n super();\n this.id = id;\n this.transport = transport;\n this.activityTimeout = transport.activityTimeout;\n this.bindListeners();\n }\n\n /** Returns whether used transport handles activity checks by itself\n *\n * @returns {Boolean} true if activity checks are handled by the transport\n */\n handlesActivityChecks() {\n return this.transport.handlesActivityChecks();\n }\n\n /** Sends raw data.\n *\n * @param {String} data\n */\n send(data: any): boolean {\n return this.transport.send(data);\n }\n\n /** Sends an event.\n *\n * @param {String} name\n * @param {String} data\n * @param {String} [channel]\n * @returns {Boolean} whether message was sent or not\n */\n send_event(name: string, data: any, channel?: string): boolean {\n var event: PusherEvent = { event: name, data: data };\n if (channel) {\n event.channel = channel;\n }\n Logger.debug('Event sent', event);\n return this.send(Protocol.encodeMessage(event));\n }\n\n /** Sends a ping message to the server.\n *\n * Basing on the underlying transport, it might send either transport's\n * protocol-specific ping or pusher:ping event.\n */\n ping() {\n if (this.transport.supportsPing()) {\n this.transport.ping();\n } else {\n this.send_event('pusher:ping', {});\n }\n }\n\n /** Closes the connection. */\n close() {\n this.transport.close();\n }\n\n private bindListeners() {\n var listeners = {\n message: (messageEvent: MessageEvent) => {\n var pusherEvent;\n try {\n pusherEvent = Protocol.decodeMessage(messageEvent);\n } catch (e) {\n this.emit('error', {\n type: 'MessageParseError',\n error: e,\n data: messageEvent.data\n });\n }\n\n if (pusherEvent !== undefined) {\n Logger.debug('Event recd', pusherEvent);\n\n switch (pusherEvent.event) {\n case 'pusher:error':\n this.emit('error', {\n type: 'PusherError',\n data: pusherEvent.data\n });\n break;\n case 'pusher:ping':\n this.emit('ping');\n break;\n case 'pusher:pong':\n this.emit('pong');\n break;\n }\n this.emit('message', pusherEvent);\n }\n },\n activity: () => {\n this.emit('activity');\n },\n error: error => {\n this.emit('error', error);\n },\n closed: closeEvent => {\n unbindListeners();\n\n if (closeEvent && closeEvent.code) {\n this.handleCloseEvent(closeEvent);\n }\n\n this.transport = null;\n this.emit('closed');\n }\n };\n\n var unbindListeners = () => {\n Collections.objectApply(listeners, (listener, event) => {\n this.transport.unbind(event, listener);\n });\n };\n\n Collections.objectApply(listeners, (listener, event) => {\n this.transport.bind(event, listener);\n });\n }\n\n private handleCloseEvent(closeEvent: any) {\n var action = Protocol.getCloseAction(closeEvent);\n var error = Protocol.getCloseError(closeEvent);\n if (error) {\n this.emit('error', error);\n }\n if (action) {\n this.emit(action, { action: action, error: error });\n }\n }\n}\n","import Util from '../../util';\nimport * as Collections from '../../utils/collections';\nimport Protocol from '../protocol/protocol';\nimport Connection from '../connection';\nimport TransportConnection from '../../transports/transport_connection';\nimport HandshakePayload from './handshake_payload';\n\n/**\n * Handles Pusher protocol handshakes for transports.\n *\n * Calls back with a result object after handshake is completed. Results\n * always have two fields:\n * - action - string describing action to be taken after the handshake\n * - transport - the transport object passed to the constructor\n *\n * Different actions can set different additional properties on the result.\n * In the case of 'connected' action, there will be a 'connection' property\n * containing a Connection object for the transport. Other actions should\n * carry an 'error' property.\n *\n * @param {AbstractTransport} transport\n * @param {Function} callback\n */\nexport default class Handshake {\n transport: TransportConnection;\n callback: (HandshakePayload) => void;\n onMessage: Function;\n onClosed: Function;\n\n constructor(\n transport: TransportConnection,\n callback: (HandshakePayload) => void\n ) {\n this.transport = transport;\n this.callback = callback;\n this.bindListeners();\n }\n\n close() {\n this.unbindListeners();\n this.transport.close();\n }\n\n private bindListeners() {\n this.onMessage = m => {\n this.unbindListeners();\n\n var result;\n try {\n result = Protocol.processHandshake(m);\n } catch (e) {\n this.finish('error', { error: e });\n this.transport.close();\n return;\n }\n\n if (result.action === 'connected') {\n this.finish('connected', {\n connection: new Connection(result.id, this.transport),\n activityTimeout: result.activityTimeout\n });\n } else {\n this.finish(result.action, { error: result.error });\n this.transport.close();\n }\n };\n\n this.onClosed = closeEvent => {\n this.unbindListeners();\n\n var action = Protocol.getCloseAction(closeEvent) || 'backoff';\n var error = Protocol.getCloseError(closeEvent);\n this.finish(action, { error: error });\n };\n\n this.transport.bind('message', this.onMessage);\n this.transport.bind('closed', this.onClosed);\n }\n\n private unbindListeners() {\n this.transport.unbind('message', this.onMessage);\n this.transport.unbind('closed', this.onClosed);\n }\n\n private finish(action: string, params: any) {\n this.callback(\n Collections.extend({ transport: this.transport, action: action }, params)\n );\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport base64encode from '../base64';\nimport Timeline from './timeline';\nimport Runtime from 'runtime';\n\nexport interface TimelineSenderOptions {\n host?: string;\n port?: number;\n path?: string;\n}\n\nexport default class TimelineSender {\n timeline: Timeline;\n options: TimelineSenderOptions;\n host: string;\n\n constructor(timeline: Timeline, options: TimelineSenderOptions) {\n this.timeline = timeline;\n this.options = options || {};\n }\n\n send(useTLS: boolean, callback?: Function) {\n if (this.timeline.isEmpty()) {\n return;\n }\n\n this.timeline.send(\n Runtime.TimelineTransport.getAgent(this, useTLS),\n callback\n );\n }\n}\n","import { default as EventsDispatcher } from '../events/dispatcher';\nimport * as Errors from '../errors';\nimport Logger from '../logger';\nimport Pusher from '../pusher';\nimport { PusherEvent } from '../connection/protocol/message-types';\nimport Metadata from './metadata';\nimport UrlStore from '../utils/url_store';\nimport {\n ChannelAuthorizationData,\n ChannelAuthorizationCallback\n} from '../auth/options';\nimport { HTTPAuthError } from '../errors';\n\n/** Provides base public channel interface with an event emitter.\n *\n * Emits:\n * - pusher:subscription_succeeded - after subscribing successfully\n * - other non-internal events\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\nexport default class Channel extends EventsDispatcher {\n name: string;\n pusher: Pusher;\n subscribed: boolean;\n subscriptionPending: boolean;\n subscriptionCancelled: boolean;\n subscriptionCount: null;\n\n constructor(name: string, pusher: Pusher) {\n super(function(event, data) {\n Logger.debug('No callbacks on ' + name + ' for ' + event);\n });\n\n this.name = name;\n this.pusher = pusher;\n this.subscribed = false;\n this.subscriptionPending = false;\n this.subscriptionCancelled = false;\n }\n\n /** Skips authorization, since public channels don't require it.\n *\n * @param {Function} callback\n */\n authorize(socketId: string, callback: ChannelAuthorizationCallback) {\n return callback(null, { auth: '' });\n }\n\n /** Triggers an event */\n trigger(event: string, data: any) {\n if (event.indexOf('client-') !== 0) {\n throw new Errors.BadEventName(\n \"Event '\" + event + \"' does not start with 'client-'\"\n );\n }\n if (!this.subscribed) {\n var suffix = UrlStore.buildLogSuffix('triggeringClientEvents');\n Logger.warn(\n `Client event triggered before channel 'subscription_succeeded' event . ${suffix}`\n );\n }\n return this.pusher.send_event(event, data, this.name);\n }\n\n /** Signals disconnection to the channel. For internal use only. */\n disconnect() {\n this.subscribed = false;\n this.subscriptionPending = false;\n }\n\n /** Handles a PusherEvent. For internal use only.\n *\n * @param {PusherEvent} event\n */\n handleEvent(event: PusherEvent) {\n var eventName = event.event;\n var data = event.data;\n if (eventName === 'pusher_internal:subscription_succeeded') {\n this.handleSubscriptionSucceededEvent(event);\n } else if (eventName === 'pusher_internal:subscription_count') {\n this.handleSubscriptionCountEvent(event);\n } else if (eventName.indexOf('pusher_internal:') !== 0) {\n var metadata: Metadata = {};\n this.emit(eventName, data, metadata);\n }\n }\n\n handleSubscriptionSucceededEvent(event: PusherEvent) {\n this.subscriptionPending = false;\n this.subscribed = true;\n if (this.subscriptionCancelled) {\n this.pusher.unsubscribe(this.name);\n } else {\n this.emit('pusher:subscription_succeeded', event.data);\n }\n }\n\n handleSubscriptionCountEvent(event: PusherEvent) {\n if (event.data.subscription_count) {\n this.subscriptionCount = event.data.subscription_count;\n }\n\n this.emit('pusher:subscription_count', event.data);\n }\n\n /** Sends a subscription request. For internal use only. */\n subscribe() {\n if (this.subscribed) {\n return;\n }\n this.subscriptionPending = true;\n this.subscriptionCancelled = false;\n this.authorize(\n this.pusher.connection.socket_id,\n (error: Error | null, data: ChannelAuthorizationData) => {\n if (error) {\n this.subscriptionPending = false;\n // Why not bind to 'pusher:subscription_error' a level up, and log there?\n // Binding to this event would cause the warning about no callbacks being\n // bound (see constructor) to be suppressed, that's not what we want.\n Logger.error(error.toString());\n this.emit(\n 'pusher:subscription_error',\n Object.assign(\n {},\n {\n type: 'AuthError',\n error: error.message\n },\n error instanceof HTTPAuthError ? { status: error.status } : {}\n )\n );\n } else {\n this.pusher.send_event('pusher:subscribe', {\n auth: data.auth,\n channel_data: data.channel_data,\n channel: this.name\n });\n }\n }\n );\n }\n\n /** Sends an unsubscription request. For internal use only. */\n unsubscribe() {\n this.subscribed = false;\n this.pusher.send_event('pusher:unsubscribe', {\n channel: this.name\n });\n }\n\n /** Cancels an in progress subscription. For internal use only. */\n cancelSubscription() {\n this.subscriptionCancelled = true;\n }\n\n /** Reinstates an in progress subscripiton. For internal use only. */\n reinstateSubscription() {\n this.subscriptionCancelled = false;\n }\n}\n","import Factory from '../utils/factory';\nimport Channel from './channel';\nimport { ChannelAuthorizationCallback } from '../auth/options';\n\n/** Extends public channels to provide private channel interface.\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\nexport default class PrivateChannel extends Channel {\n /** Authorizes the connection to use the channel.\n *\n * @param {String} socketId\n * @param {Function} callback\n */\n authorize(socketId: string, callback: ChannelAuthorizationCallback) {\n return this.pusher.config.channelAuthorizer(\n {\n channelName: this.name,\n socketId: socketId\n },\n callback\n );\n }\n}\n","import * as Collections from '../utils/collections';\n\n/** Represents a collection of members of a presence channel. */\nexport default class Members {\n members: any;\n count: number;\n myID: any;\n me: any;\n\n constructor() {\n this.reset();\n }\n\n /** Returns member's info for given id.\n *\n * Resulting object containts two fields - id and info.\n *\n * @param {Number} id\n * @return {Object} member's info or null\n */\n get(id: string): any {\n if (Object.prototype.hasOwnProperty.call(this.members, id)) {\n return {\n id: id,\n info: this.members[id]\n };\n } else {\n return null;\n }\n }\n\n /** Calls back for each member in unspecified order.\n *\n * @param {Function} callback\n */\n each(callback: Function) {\n Collections.objectApply(this.members, (member, id) => {\n callback(this.get(id));\n });\n }\n\n /** Updates the id for connected member. For internal use only. */\n setMyID(id: string) {\n this.myID = id;\n }\n\n /** Handles subscription data. For internal use only. */\n onSubscription(subscriptionData: any) {\n this.members = subscriptionData.presence.hash;\n this.count = subscriptionData.presence.count;\n this.me = this.get(this.myID);\n }\n\n /** Adds a new member to the collection. For internal use only. */\n addMember(memberData: any) {\n if (this.get(memberData.user_id) === null) {\n this.count++;\n }\n this.members[memberData.user_id] = memberData.user_info;\n return this.get(memberData.user_id);\n }\n\n /** Adds a member from the collection. For internal use only. */\n removeMember(memberData: any) {\n var member = this.get(memberData.user_id);\n if (member) {\n delete this.members[memberData.user_id];\n this.count--;\n }\n return member;\n }\n\n /** Resets the collection to the initial state. For internal use only. */\n reset() {\n this.members = {};\n this.count = 0;\n this.myID = null;\n this.me = null;\n }\n}\n","import PrivateChannel from './private_channel';\nimport Logger from '../logger';\nimport Members from './members';\nimport Pusher from '../pusher';\nimport UrlStore from 'core/utils/url_store';\nimport { PusherEvent } from '../connection/protocol/message-types';\nimport Metadata from './metadata';\nimport { ChannelAuthorizationData } from '../auth/options';\n\nexport default class PresenceChannel extends PrivateChannel {\n members: Members;\n\n /** Adds presence channel functionality to private channels.\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\n constructor(name: string, pusher: Pusher) {\n super(name, pusher);\n this.members = new Members();\n }\n\n /** Authorizes the connection as a member of the channel.\n *\n * @param {String} socketId\n * @param {Function} callback\n */\n authorize(socketId: string, callback: Function) {\n super.authorize(socketId, async (error, authData) => {\n if (!error) {\n authData = authData as ChannelAuthorizationData;\n if (authData.channel_data != null) {\n var channelData = JSON.parse(authData.channel_data);\n this.members.setMyID(channelData.user_id);\n } else {\n await this.pusher.user.signinDonePromise;\n if (this.pusher.user.user_data != null) {\n // If the user is signed in, get the id of the authenticated user\n // and allow the presence authorization to continue.\n this.members.setMyID(this.pusher.user.user_data.id);\n } else {\n let suffix = UrlStore.buildLogSuffix('authorizationEndpoint');\n Logger.error(\n `Invalid auth response for channel '${this.name}', ` +\n `expected 'channel_data' field. ${suffix}, ` +\n `or the user should be signed in.`\n );\n callback('Invalid auth response');\n return;\n }\n }\n }\n callback(error, authData);\n });\n }\n\n /** Handles presence and subscription events. For internal use only.\n *\n * @param {PusherEvent} event\n */\n handleEvent(event: PusherEvent) {\n var eventName = event.event;\n if (eventName.indexOf('pusher_internal:') === 0) {\n this.handleInternalEvent(event);\n } else {\n var data = event.data;\n var metadata: Metadata = {};\n if (event.user_id) {\n metadata.user_id = event.user_id;\n }\n this.emit(eventName, data, metadata);\n }\n }\n handleInternalEvent(event: PusherEvent) {\n var eventName = event.event;\n var data = event.data;\n switch (eventName) {\n case 'pusher_internal:subscription_succeeded':\n this.handleSubscriptionSucceededEvent(event);\n break;\n case 'pusher_internal:subscription_count':\n this.handleSubscriptionCountEvent(event);\n break;\n case 'pusher_internal:member_added':\n var addedMember = this.members.addMember(data);\n this.emit('pusher:member_added', addedMember);\n break;\n case 'pusher_internal:member_removed':\n var removedMember = this.members.removeMember(data);\n if (removedMember) {\n this.emit('pusher:member_removed', removedMember);\n }\n break;\n }\n }\n\n handleSubscriptionSucceededEvent(event: PusherEvent) {\n this.subscriptionPending = false;\n this.subscribed = true;\n if (this.subscriptionCancelled) {\n this.pusher.unsubscribe(this.name);\n } else {\n this.members.onSubscription(event.data);\n this.emit('pusher:subscription_succeeded', this.members);\n }\n }\n\n /** Resets the channel state, including members map. For internal use only. */\n disconnect() {\n this.members.reset();\n super.disconnect();\n }\n}\n","import PrivateChannel from './private_channel';\nimport * as Errors from '../errors';\nimport Logger from '../logger';\nimport Pusher from '../pusher';\nimport { decode as encodeUTF8 } from '@stablelib/utf8';\nimport { decode as decodeBase64 } from '@stablelib/base64';\nimport Dispatcher from '../events/dispatcher';\nimport { PusherEvent } from '../connection/protocol/message-types';\nimport {\n ChannelAuthorizationData,\n ChannelAuthorizationCallback\n} from '../auth/options';\nimport * as nacl from 'tweetnacl';\n\n/** Extends private channels to provide encrypted channel interface.\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\nexport default class EncryptedChannel extends PrivateChannel {\n key: Uint8Array = null;\n nacl: nacl;\n\n constructor(name: string, pusher: Pusher, nacl: nacl) {\n super(name, pusher);\n this.nacl = nacl;\n }\n\n /** Authorizes the connection to use the channel.\n *\n * @param {String} socketId\n * @param {Function} callback\n */\n authorize(socketId: string, callback: ChannelAuthorizationCallback) {\n super.authorize(\n socketId,\n (error: Error | null, authData: ChannelAuthorizationData) => {\n if (error) {\n callback(error, authData);\n return;\n }\n let sharedSecret = authData['shared_secret'];\n if (!sharedSecret) {\n callback(\n new Error(\n `No shared_secret key in auth payload for encrypted channel: ${this.name}`\n ),\n null\n );\n return;\n }\n this.key = decodeBase64(sharedSecret);\n delete authData['shared_secret'];\n callback(null, authData);\n }\n );\n }\n\n trigger(event: string, data: any): boolean {\n throw new Errors.UnsupportedFeature(\n 'Client events are not currently supported for encrypted channels'\n );\n }\n\n /** Handles an event. For internal use only.\n *\n * @param {PusherEvent} event\n */\n handleEvent(event: PusherEvent) {\n var eventName = event.event;\n var data = event.data;\n if (\n eventName.indexOf('pusher_internal:') === 0 ||\n eventName.indexOf('pusher:') === 0\n ) {\n super.handleEvent(event);\n return;\n }\n this.handleEncryptedEvent(eventName, data);\n }\n\n private handleEncryptedEvent(event: string, data: any): void {\n if (!this.key) {\n Logger.debug(\n 'Received encrypted event before key has been retrieved from the authEndpoint'\n );\n return;\n }\n if (!data.ciphertext || !data.nonce) {\n Logger.error(\n 'Unexpected format for encrypted event, expected object with `ciphertext` and `nonce` fields, got: ' +\n data\n );\n return;\n }\n let cipherText = decodeBase64(data.ciphertext);\n if (cipherText.length < this.nacl.secretbox.overheadLength) {\n Logger.error(\n `Expected encrypted event ciphertext length to be ${this.nacl.secretbox.overheadLength}, got: ${cipherText.length}`\n );\n return;\n }\n let nonce = decodeBase64(data.nonce);\n if (nonce.length < this.nacl.secretbox.nonceLength) {\n Logger.error(\n `Expected encrypted event nonce length to be ${this.nacl.secretbox.nonceLength}, got: ${nonce.length}`\n );\n return;\n }\n\n let bytes = this.nacl.secretbox.open(cipherText, nonce, this.key);\n if (bytes === null) {\n Logger.debug(\n 'Failed to decrypt an event, probably because it was encrypted with a different key. Fetching a new key from the authEndpoint...'\n );\n // Try a single time to retrieve a new auth key and decrypt the event with it\n // If this fails, a new key will be requested when a new message is received\n this.authorize(this.pusher.connection.socket_id, (error, authData) => {\n if (error) {\n Logger.error(\n `Failed to make a request to the authEndpoint: ${authData}. Unable to fetch new key, so dropping encrypted event`\n );\n return;\n }\n bytes = this.nacl.secretbox.open(cipherText, nonce, this.key);\n if (bytes === null) {\n Logger.error(\n `Failed to decrypt event with new key. Dropping encrypted event`\n );\n return;\n }\n this.emit(event, this.getDataToEmit(bytes));\n return;\n });\n return;\n }\n this.emit(event, this.getDataToEmit(bytes));\n }\n\n // Try and parse the decrypted bytes as JSON. If we can't parse it, just\n // return the utf-8 string\n getDataToEmit(bytes: Uint8Array): string {\n let raw = encodeUTF8(bytes);\n try {\n return JSON.parse(raw);\n } catch {\n return raw;\n }\n }\n}\n","import { default as EventsDispatcher } from '../events/dispatcher';\nimport { OneOffTimer as Timer } from '../utils/timers';\nimport { Config } from '../config';\nimport Logger from '../logger';\nimport HandshakePayload from './handshake/handshake_payload';\nimport Connection from './connection';\nimport Strategy from '../strategies/strategy';\nimport StrategyRunner from '../strategies/strategy_runner';\nimport * as Collections from '../utils/collections';\nimport Timeline from '../timeline/timeline';\nimport ConnectionManagerOptions from './connection_manager_options';\nimport Runtime from 'runtime';\n\nimport {\n ErrorCallbacks,\n HandshakeCallbacks,\n ConnectionCallbacks\n} from './callbacks';\nimport Action from './protocol/action';\n\n/** Manages connection to Pusher.\n *\n * Uses a strategy (currently only default), timers and network availability\n * info to establish a connection and export its state. In case of failures,\n * manages reconnection attempts.\n *\n * Exports state changes as following events:\n * - \"state_change\", { previous: p, current: state }\n * - state\n *\n * States:\n * - initialized - initial state, never transitioned to\n * - connecting - connection is being established\n * - connected - connection has been fully established\n * - disconnected - on requested disconnection\n * - unavailable - after connection timeout or when there's no network\n * - failed - when the connection strategy is not supported\n *\n * Options:\n * - unavailableTimeout - time to transition to unavailable state\n * - activityTimeout - time after which ping message should be sent\n * - pongTimeout - time for Pusher to respond with pong before reconnecting\n *\n * @param {String} key application key\n * @param {Object} options\n */\nexport default class ConnectionManager extends EventsDispatcher {\n key: string;\n options: ConnectionManagerOptions;\n state: string;\n connection: Connection;\n usingTLS: boolean;\n timeline: Timeline;\n socket_id: string;\n unavailableTimer: Timer;\n activityTimer: Timer;\n retryTimer: Timer;\n activityTimeout: number;\n strategy: Strategy;\n runner: StrategyRunner;\n errorCallbacks: ErrorCallbacks;\n handshakeCallbacks: HandshakeCallbacks;\n connectionCallbacks: ConnectionCallbacks;\n\n constructor(key: string, options: ConnectionManagerOptions) {\n super();\n this.state = 'initialized';\n this.connection = null;\n\n this.key = key;\n this.options = options;\n this.timeline = this.options.timeline;\n this.usingTLS = this.options.useTLS;\n\n this.errorCallbacks = this.buildErrorCallbacks();\n this.connectionCallbacks = this.buildConnectionCallbacks(\n this.errorCallbacks\n );\n this.handshakeCallbacks = this.buildHandshakeCallbacks(this.errorCallbacks);\n\n var Network = Runtime.getNetwork();\n\n Network.bind('online', () => {\n this.timeline.info({ netinfo: 'online' });\n if (this.state === 'connecting' || this.state === 'unavailable') {\n this.retryIn(0);\n }\n });\n Network.bind('offline', () => {\n this.timeline.info({ netinfo: 'offline' });\n if (this.connection) {\n this.sendActivityCheck();\n }\n });\n\n this.updateStrategy();\n }\n\n switchCluster(key: string) {\n this.key = key;\n // This ensures that the new config coming from\n // pusher instance are taken into account\n // such as appKey and cluster\n this.updateStrategy();\n this.retryIn(0);\n }\n\n /** Establishes a connection to Pusher.\n *\n * Does nothing when connection is already established. See top-level doc\n * to find events emitted on connection attempts.\n */\n connect() {\n if (this.connection || this.runner) {\n return;\n }\n if (!this.strategy.isSupported()) {\n this.updateState('failed');\n return;\n }\n this.updateState('connecting');\n this.startConnecting();\n this.setUnavailableTimer();\n }\n\n /** Sends raw data.\n *\n * @param {String} data\n */\n send(data) {\n if (this.connection) {\n return this.connection.send(data);\n } else {\n return false;\n }\n }\n\n /** Sends an event.\n *\n * @param {String} name\n * @param {String} data\n * @param {String} [channel]\n * @returns {Boolean} whether message was sent or not\n */\n send_event(name: string, data: any, channel?: string) {\n if (this.connection) {\n return this.connection.send_event(name, data, channel);\n } else {\n return false;\n }\n }\n\n /** Closes the connection. */\n disconnect() {\n this.disconnectInternally();\n this.updateState('disconnected');\n }\n\n isUsingTLS() {\n return this.usingTLS;\n }\n\n private startConnecting() {\n var callback = (error, handshake) => {\n if (error) {\n this.runner = this.strategy.connect(0, callback);\n } else {\n if (handshake.action === 'error') {\n this.emit('error', {\n type: 'HandshakeError',\n error: handshake.error\n });\n this.timeline.error({ handshakeError: handshake.error });\n } else {\n this.abortConnecting(); // we don't support switching connections yet\n this.handshakeCallbacks[handshake.action](handshake);\n }\n }\n };\n this.runner = this.strategy.connect(0, callback);\n }\n\n private abortConnecting() {\n if (this.runner) {\n this.runner.abort();\n this.runner = null;\n }\n }\n\n private disconnectInternally() {\n this.abortConnecting();\n this.clearRetryTimer();\n this.clearUnavailableTimer();\n if (this.connection) {\n var connection = this.abandonConnection();\n connection.close();\n }\n }\n\n private updateStrategy() {\n this.strategy = this.options.getStrategy({\n key: this.key,\n timeline: this.timeline,\n useTLS: this.usingTLS\n });\n }\n\n private retryIn(delay) {\n this.timeline.info({ action: 'retry', delay: delay });\n if (delay > 0) {\n this.emit('connecting_in', Math.round(delay / 1000));\n }\n this.retryTimer = new Timer(delay || 0, () => {\n this.disconnectInternally();\n this.connect();\n });\n }\n\n private clearRetryTimer() {\n if (this.retryTimer) {\n this.retryTimer.ensureAborted();\n this.retryTimer = null;\n }\n }\n\n private setUnavailableTimer() {\n this.unavailableTimer = new Timer(this.options.unavailableTimeout, () => {\n this.updateState('unavailable');\n });\n }\n\n private clearUnavailableTimer() {\n if (this.unavailableTimer) {\n this.unavailableTimer.ensureAborted();\n }\n }\n\n private sendActivityCheck() {\n this.stopActivityCheck();\n this.connection.ping();\n // wait for pong response\n this.activityTimer = new Timer(this.options.pongTimeout, () => {\n this.timeline.error({ pong_timed_out: this.options.pongTimeout });\n this.retryIn(0);\n });\n }\n\n private resetActivityCheck() {\n this.stopActivityCheck();\n // send ping after inactivity\n if (this.connection && !this.connection.handlesActivityChecks()) {\n this.activityTimer = new Timer(this.activityTimeout, () => {\n this.sendActivityCheck();\n });\n }\n }\n\n private stopActivityCheck() {\n if (this.activityTimer) {\n this.activityTimer.ensureAborted();\n }\n }\n\n private buildConnectionCallbacks(\n errorCallbacks: ErrorCallbacks\n ): ConnectionCallbacks {\n return Collections.extend({}, errorCallbacks, {\n message: message => {\n // includes pong messages from server\n this.resetActivityCheck();\n this.emit('message', message);\n },\n ping: () => {\n this.send_event('pusher:pong', {});\n },\n activity: () => {\n this.resetActivityCheck();\n },\n error: error => {\n // just emit error to user - socket will already be closed by browser\n this.emit('error', error);\n },\n closed: () => {\n this.abandonConnection();\n if (this.shouldRetry()) {\n this.retryIn(1000);\n }\n }\n });\n }\n\n private buildHandshakeCallbacks(\n errorCallbacks: ErrorCallbacks\n ): HandshakeCallbacks {\n return Collections.extend({}, errorCallbacks, {\n connected: (handshake: HandshakePayload) => {\n this.activityTimeout = Math.min(\n this.options.activityTimeout,\n handshake.activityTimeout,\n handshake.connection.activityTimeout || Infinity\n );\n this.clearUnavailableTimer();\n this.setConnection(handshake.connection);\n this.socket_id = this.connection.id;\n this.updateState('connected', { socket_id: this.socket_id });\n }\n });\n }\n\n private buildErrorCallbacks(): ErrorCallbacks {\n let withErrorEmitted = callback => {\n return (result: Action | HandshakePayload) => {\n if (result.error) {\n this.emit('error', { type: 'WebSocketError', error: result.error });\n }\n callback(result);\n };\n };\n\n return {\n tls_only: withErrorEmitted(() => {\n this.usingTLS = true;\n this.updateStrategy();\n this.retryIn(0);\n }),\n refused: withErrorEmitted(() => {\n this.disconnect();\n }),\n backoff: withErrorEmitted(() => {\n this.retryIn(1000);\n }),\n retry: withErrorEmitted(() => {\n this.retryIn(0);\n })\n };\n }\n\n private setConnection(connection) {\n this.connection = connection;\n for (var event in this.connectionCallbacks) {\n this.connection.bind(event, this.connectionCallbacks[event]);\n }\n this.resetActivityCheck();\n }\n\n private abandonConnection() {\n if (!this.connection) {\n return;\n }\n this.stopActivityCheck();\n for (var event in this.connectionCallbacks) {\n this.connection.unbind(event, this.connectionCallbacks[event]);\n }\n var connection = this.connection;\n this.connection = null;\n return connection;\n }\n\n private updateState(newState: string, data?: any) {\n var previousState = this.state;\n this.state = newState;\n if (previousState !== newState) {\n var newStateDescription = newState;\n if (newStateDescription === 'connected') {\n newStateDescription += ' with new socket ID ' + data.socket_id;\n }\n Logger.debug(\n 'State changed',\n previousState + ' -> ' + newStateDescription\n );\n this.timeline.info({ state: newState, params: data });\n this.emit('state_change', { previous: previousState, current: newState });\n this.emit(newState, data);\n }\n }\n\n private shouldRetry(): boolean {\n return this.state === 'connecting' || this.state === 'connected';\n }\n}\n","import Channel from './channel';\nimport * as Collections from '../utils/collections';\nimport ChannelTable from './channel_table';\nimport Factory from '../utils/factory';\nimport Pusher from '../pusher';\nimport Logger from '../logger';\nimport * as Errors from '../errors';\nimport urlStore from '../utils/url_store';\n\n/** Handles a channel map. */\nexport default class Channels {\n channels: ChannelTable;\n\n constructor() {\n this.channels = {};\n }\n\n /** Creates or retrieves an existing channel by its name.\n *\n * @param {String} name\n * @param {Pusher} pusher\n * @return {Channel}\n */\n add(name: string, pusher: Pusher) {\n if (!this.channels[name]) {\n this.channels[name] = createChannel(name, pusher);\n }\n return this.channels[name];\n }\n\n /** Returns a list of all channels\n *\n * @return {Array}\n */\n all(): Channel[] {\n return Collections.values(this.channels);\n }\n\n /** Finds a channel by its name.\n *\n * @param {String} name\n * @return {Channel} channel or null if it doesn't exist\n */\n find(name: string) {\n return this.channels[name];\n }\n\n /** Removes a channel from the map.\n *\n * @param {String} name\n */\n remove(name: string) {\n var channel = this.channels[name];\n delete this.channels[name];\n return channel;\n }\n\n /** Proxies disconnection signal to all channels. */\n disconnect() {\n Collections.objectApply(this.channels, function(channel) {\n channel.disconnect();\n });\n }\n}\n\nfunction createChannel(name: string, pusher: Pusher): Channel {\n if (name.indexOf('private-encrypted-') === 0) {\n if (pusher.config.nacl) {\n return Factory.createEncryptedChannel(name, pusher, pusher.config.nacl);\n }\n let errMsg =\n 'Tried to subscribe to a private-encrypted- channel but no nacl implementation available';\n let suffix = urlStore.buildLogSuffix('encryptedChannelSupport');\n throw new Errors.UnsupportedFeature(`${errMsg}. ${suffix}`);\n } else if (name.indexOf('private-') === 0) {\n return Factory.createPrivateChannel(name, pusher);\n } else if (name.indexOf('presence-') === 0) {\n return Factory.createPresenceChannel(name, pusher);\n } else if (name.indexOf('#') === 0) {\n throw new Errors.BadChannelName(\n 'Cannot create a channel with name \"' + name + '\".'\n );\n } else {\n return Factory.createChannel(name, pusher);\n }\n}\n","import AssistantToTheTransportManager from '../transports/assistant_to_the_transport_manager';\nimport PingDelayOptions from '../transports/ping_delay_options';\nimport Transport from '../transports/transport';\nimport TransportManager from '../transports/transport_manager';\nimport Handshake from '../connection/handshake';\nimport TransportConnection from '../transports/transport_connection';\nimport SocketHooks from '../http/socket_hooks';\nimport HTTPSocket from '../http/http_socket';\n\nimport Timeline from '../timeline/timeline';\nimport {\n default as TimelineSender,\n TimelineSenderOptions\n} from '../timeline/timeline_sender';\nimport PresenceChannel from '../channels/presence_channel';\nimport PrivateChannel from '../channels/private_channel';\nimport EncryptedChannel from '../channels/encrypted_channel';\nimport Channel from '../channels/channel';\nimport ConnectionManager from '../connection/connection_manager';\nimport ConnectionManagerOptions from '../connection/connection_manager_options';\nimport Ajax from '../http/ajax';\nimport Channels from '../channels/channels';\nimport Pusher from '../pusher';\nimport { Config } from '../config';\nimport * as nacl from 'tweetnacl';\n\nvar Factory = {\n createChannels(): Channels {\n return new Channels();\n },\n\n createConnectionManager(\n key: string,\n options: ConnectionManagerOptions\n ): ConnectionManager {\n return new ConnectionManager(key, options);\n },\n\n createChannel(name: string, pusher: Pusher): Channel {\n return new Channel(name, pusher);\n },\n\n createPrivateChannel(name: string, pusher: Pusher): PrivateChannel {\n return new PrivateChannel(name, pusher);\n },\n\n createPresenceChannel(name: string, pusher: Pusher): PresenceChannel {\n return new PresenceChannel(name, pusher);\n },\n\n createEncryptedChannel(\n name: string,\n pusher: Pusher,\n nacl: nacl\n ): EncryptedChannel {\n return new EncryptedChannel(name, pusher, nacl);\n },\n\n createTimelineSender(timeline: Timeline, options: TimelineSenderOptions) {\n return new TimelineSender(timeline, options);\n },\n\n createHandshake(\n transport: TransportConnection,\n callback: (HandshakePayload) => void\n ): Handshake {\n return new Handshake(transport, callback);\n },\n\n createAssistantToTheTransportManager(\n manager: TransportManager,\n transport: Transport,\n options: PingDelayOptions\n ): AssistantToTheTransportManager {\n return new AssistantToTheTransportManager(manager, transport, options);\n }\n};\n\nexport default Factory;\n","import AssistantToTheTransportManager from './assistant_to_the_transport_manager';\nimport Transport from './transport';\nimport PingDelayOptions from './ping_delay_options';\nimport Factory from '../utils/factory';\n\nexport interface TransportManagerOptions extends PingDelayOptions {\n lives?: number;\n}\n\n/** Keeps track of the number of lives left for a transport.\n *\n * In the beginning of a session, transports may be assigned a number of\n * lives. When an AssistantToTheTransportManager instance reports a transport\n * connection closed uncleanly, the transport loses a life. When the number\n * of lives drops to zero, the transport gets disabled by its manager.\n *\n * @param {Object} options\n */\nexport default class TransportManager {\n options: TransportManagerOptions;\n livesLeft: number;\n\n constructor(options: TransportManagerOptions) {\n this.options = options || {};\n this.livesLeft = this.options.lives || Infinity;\n }\n\n /** Creates a assistant for the transport.\n *\n * @param {Transport} transport\n * @returns {AssistantToTheTransportManager}\n */\n getAssistant(transport: Transport): AssistantToTheTransportManager {\n return Factory.createAssistantToTheTransportManager(this, transport, {\n minPingDelay: this.options.minPingDelay,\n maxPingDelay: this.options.maxPingDelay\n });\n }\n\n /** Returns whether the transport has any lives left.\n *\n * @returns {Boolean}\n */\n isAlive(): boolean {\n return this.livesLeft > 0;\n }\n\n /** Takes one life from the transport. */\n reportDeath() {\n this.livesLeft -= 1;\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport { OneOffTimer as Timer } from '../utils/timers';\nimport Strategy from './strategy';\nimport StrategyOptions from './strategy_options';\n\n/** Loops through strategies with optional timeouts.\n *\n * Options:\n * - loop - whether it should loop through the substrategy list\n * - timeout - initial timeout for a single substrategy\n * - timeoutLimit - maximum timeout\n *\n * @param {Strategy[]} strategies\n * @param {Object} options\n */\nexport default class SequentialStrategy implements Strategy {\n strategies: Strategy[];\n loop: boolean;\n failFast: boolean;\n timeout: number;\n timeoutLimit: number;\n\n constructor(strategies: Strategy[], options: StrategyOptions) {\n this.strategies = strategies;\n this.loop = Boolean(options.loop);\n this.failFast = Boolean(options.failFast);\n this.timeout = options.timeout;\n this.timeoutLimit = options.timeoutLimit;\n }\n\n isSupported(): boolean {\n return Collections.any(this.strategies, Util.method('isSupported'));\n }\n\n connect(minPriority: number, callback: Function) {\n var strategies = this.strategies;\n var current = 0;\n var timeout = this.timeout;\n var runner = null;\n\n var tryNextStrategy = (error, handshake) => {\n if (handshake) {\n callback(null, handshake);\n } else {\n current = current + 1;\n if (this.loop) {\n current = current % strategies.length;\n }\n\n if (current < strategies.length) {\n if (timeout) {\n timeout = timeout * 2;\n if (this.timeoutLimit) {\n timeout = Math.min(timeout, this.timeoutLimit);\n }\n }\n runner = this.tryStrategy(\n strategies[current],\n minPriority,\n { timeout, failFast: this.failFast },\n tryNextStrategy\n );\n } else {\n callback(true);\n }\n }\n };\n\n runner = this.tryStrategy(\n strategies[current],\n minPriority,\n { timeout: timeout, failFast: this.failFast },\n tryNextStrategy\n );\n\n return {\n abort: function() {\n runner.abort();\n },\n forceMinPriority: function(p) {\n minPriority = p;\n if (runner) {\n runner.forceMinPriority(p);\n }\n }\n };\n }\n\n private tryStrategy(\n strategy: Strategy,\n minPriority: number,\n options: StrategyOptions,\n callback: Function\n ) {\n var timer = null;\n var runner = null;\n\n if (options.timeout > 0) {\n timer = new Timer(options.timeout, function() {\n runner.abort();\n callback(true);\n });\n }\n\n runner = strategy.connect(minPriority, function(error, handshake) {\n if (error && timer && timer.isRunning() && !options.failFast) {\n // advance to the next strategy after the timeout\n return;\n }\n if (timer) {\n timer.ensureAborted();\n }\n callback(error, handshake);\n });\n\n return {\n abort: function() {\n if (timer) {\n timer.ensureAborted();\n }\n runner.abort();\n },\n forceMinPriority: function(p) {\n runner.forceMinPriority(p);\n }\n };\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport Strategy from './strategy';\n\n/** Launches all substrategies and emits prioritized connected transports.\n *\n * @param {Array} strategies\n */\nexport default class BestConnectedEverStrategy implements Strategy {\n strategies: Strategy[];\n\n constructor(strategies: Strategy[]) {\n this.strategies = strategies;\n }\n\n isSupported(): boolean {\n return Collections.any(this.strategies, Util.method('isSupported'));\n }\n\n connect(minPriority: number, callback: Function) {\n return connect(this.strategies, minPriority, function(i, runners) {\n return function(error, handshake) {\n runners[i].error = error;\n if (error) {\n if (allRunnersFailed(runners)) {\n callback(true);\n }\n return;\n }\n Collections.apply(runners, function(runner) {\n runner.forceMinPriority(handshake.transport.priority);\n });\n callback(null, handshake);\n };\n });\n }\n}\n\n/** Connects to all strategies in parallel.\n *\n * Callback builder should be a function that takes two arguments: index\n * and a list of runners. It should return another function that will be\n * passed to the substrategy with given index. Runners can be aborted using\n * abortRunner(s) functions from this class.\n *\n * @param {Array} strategies\n * @param {Function} callbackBuilder\n * @return {Object} strategy runner\n */\nfunction connect(\n strategies: Strategy[],\n minPriority: number,\n callbackBuilder: Function\n) {\n var runners = Collections.map(strategies, function(strategy, i, _, rs) {\n return strategy.connect(minPriority, callbackBuilder(i, rs));\n });\n return {\n abort: function() {\n Collections.apply(runners, abortRunner);\n },\n forceMinPriority: function(p) {\n Collections.apply(runners, function(runner) {\n runner.forceMinPriority(p);\n });\n }\n };\n}\n\nfunction allRunnersFailed(runners): boolean {\n return Collections.all(runners, function(runner) {\n return Boolean(runner.error);\n });\n}\n\nfunction abortRunner(runner) {\n if (!runner.error && !runner.aborted) {\n runner.abort();\n runner.aborted = true;\n }\n}\n","import Util from '../util';\nimport Runtime from 'runtime';\nimport Strategy from './strategy';\nimport SequentialStrategy from './sequential_strategy';\nimport StrategyOptions from './strategy_options';\nimport TransportStrategy from './transport_strategy';\nimport Timeline from '../timeline/timeline';\nimport * as Collections from '../utils/collections';\n\nexport interface TransportStrategyDictionary {\n [key: string]: TransportStrategy;\n}\n\n/** Caches the last successful transport and, after the first few attempts,\n * uses the cached transport for subsequent attempts.\n *\n * @param {Strategy} strategy\n * @param {Object} transports\n * @param {Object} options\n */\nexport default class WebSocketPrioritizedCachedStrategy implements Strategy {\n strategy: Strategy;\n transports: TransportStrategyDictionary;\n ttl: number;\n usingTLS: boolean;\n timeline: Timeline;\n\n constructor(\n strategy: Strategy,\n transports: TransportStrategyDictionary,\n options: StrategyOptions\n ) {\n this.strategy = strategy;\n this.transports = transports;\n this.ttl = options.ttl || 1800 * 1000;\n this.usingTLS = options.useTLS;\n this.timeline = options.timeline;\n }\n\n isSupported(): boolean {\n return this.strategy.isSupported();\n }\n\n connect(minPriority: number, callback: Function) {\n var usingTLS = this.usingTLS;\n var info = fetchTransportCache(usingTLS);\n var cacheSkipCount = info && info.cacheSkipCount ? info.cacheSkipCount : 0;\n\n var strategies = [this.strategy];\n if (info && info.timestamp + this.ttl >= Util.now()) {\n var transport = this.transports[info.transport];\n if (transport) {\n if (['ws', 'wss'].includes(info.transport) || cacheSkipCount > 3) {\n this.timeline.info({\n cached: true,\n transport: info.transport,\n latency: info.latency\n });\n strategies.push(\n new SequentialStrategy([transport], {\n timeout: info.latency * 2 + 1000,\n failFast: true\n })\n );\n } else {\n cacheSkipCount++;\n }\n }\n }\n\n var startTimestamp = Util.now();\n var runner = strategies\n .pop()\n .connect(minPriority, function cb(error, handshake) {\n if (error) {\n flushTransportCache(usingTLS);\n if (strategies.length > 0) {\n startTimestamp = Util.now();\n runner = strategies.pop().connect(minPriority, cb);\n } else {\n callback(error);\n }\n } else {\n storeTransportCache(\n usingTLS,\n handshake.transport.name,\n Util.now() - startTimestamp,\n cacheSkipCount\n );\n callback(null, handshake);\n }\n });\n\n return {\n abort: function() {\n runner.abort();\n },\n forceMinPriority: function(p) {\n minPriority = p;\n if (runner) {\n runner.forceMinPriority(p);\n }\n }\n };\n }\n}\n\nfunction getTransportCacheKey(usingTLS: boolean): string {\n return 'pusherTransport' + (usingTLS ? 'TLS' : 'NonTLS');\n}\n\nfunction fetchTransportCache(usingTLS: boolean): any {\n var storage = Runtime.getLocalStorage();\n if (storage) {\n try {\n var serializedCache = storage[getTransportCacheKey(usingTLS)];\n if (serializedCache) {\n return JSON.parse(serializedCache);\n }\n } catch (e) {\n flushTransportCache(usingTLS);\n }\n }\n return null;\n}\n\nfunction storeTransportCache(\n usingTLS: boolean,\n transport: TransportStrategy,\n latency: number,\n cacheSkipCount: number\n) {\n var storage = Runtime.getLocalStorage();\n if (storage) {\n try {\n storage[getTransportCacheKey(usingTLS)] = Collections.safeJSONStringify({\n timestamp: Util.now(),\n transport: transport,\n latency: latency,\n cacheSkipCount: cacheSkipCount\n });\n } catch (e) {\n // catch over quota exceptions raised by localStorage\n }\n }\n}\n\nfunction flushTransportCache(usingTLS: boolean) {\n var storage = Runtime.getLocalStorage();\n if (storage) {\n try {\n delete storage[getTransportCacheKey(usingTLS)];\n } catch (e) {\n // catch exceptions raised by localStorage\n }\n }\n}\n","import { OneOffTimer as Timer } from '../utils/timers';\nimport Strategy from './strategy';\nimport StrategyOptions from './strategy_options';\n\n/** Runs substrategy after specified delay.\n *\n * Options:\n * - delay - time in miliseconds to delay the substrategy attempt\n *\n * @param {Strategy} strategy\n * @param {Object} options\n */\nexport default class DelayedStrategy implements Strategy {\n strategy: Strategy;\n options: { delay: number };\n\n constructor(strategy: Strategy, { delay: number }) {\n this.strategy = strategy;\n this.options = { delay: number };\n }\n\n isSupported(): boolean {\n return this.strategy.isSupported();\n }\n\n connect(minPriority: number, callback: Function) {\n var strategy = this.strategy;\n var runner;\n var timer = new Timer(this.options.delay, function() {\n runner = strategy.connect(minPriority, callback);\n });\n\n return {\n abort: function() {\n timer.ensureAborted();\n if (runner) {\n runner.abort();\n }\n },\n forceMinPriority: function(p) {\n minPriority = p;\n if (runner) {\n runner.forceMinPriority(p);\n }\n }\n };\n }\n}\n","import Strategy from './strategy';\nimport StrategyRunner from './strategy_runner';\n\n/** Proxies method calls to one of substrategies basing on the test function.\n *\n * @param {Function} test\n * @param {Strategy} trueBranch strategy used when test returns true\n * @param {Strategy} falseBranch strategy used when test returns false\n */\nexport default class IfStrategy implements Strategy {\n test: () => boolean;\n trueBranch: Strategy;\n falseBranch: Strategy;\n\n constructor(\n test: () => boolean,\n trueBranch: Strategy,\n falseBranch: Strategy\n ) {\n this.test = test;\n this.trueBranch = trueBranch;\n this.falseBranch = falseBranch;\n }\n\n isSupported(): boolean {\n var branch = this.test() ? this.trueBranch : this.falseBranch;\n return branch.isSupported();\n }\n\n connect(minPriority: number, callback: Function): StrategyRunner {\n var branch = this.test() ? this.trueBranch : this.falseBranch;\n return branch.connect(minPriority, callback);\n }\n}\n","import Strategy from './strategy';\nimport StrategyRunner from './strategy_runner';\n\n/** Launches the substrategy and terminates on the first open connection.\n *\n * @param {Strategy} strategy\n */\nexport default class FirstConnectedStrategy implements Strategy {\n strategy: Strategy;\n\n constructor(strategy: Strategy) {\n this.strategy = strategy;\n }\n\n isSupported(): boolean {\n return this.strategy.isSupported();\n }\n\n connect(minPriority: number, callback: Function): StrategyRunner {\n var runner = this.strategy.connect(minPriority, function(error, handshake) {\n if (handshake) {\n runner.abort();\n }\n callback(error, handshake);\n });\n return runner;\n }\n}\n","import * as Collections from 'core/utils/collections';\nimport TransportManager from 'core/transports/transport_manager';\nimport Strategy from 'core/strategies/strategy';\nimport StrategyOptions from 'core/strategies/strategy_options';\nimport SequentialStrategy from 'core/strategies/sequential_strategy';\nimport BestConnectedEverStrategy from 'core/strategies/best_connected_ever_strategy';\nimport WebSocketPrioritizedCachedStrategy, {\n TransportStrategyDictionary\n} from 'core/strategies/websocket_prioritized_cached_strategy';\nimport DelayedStrategy from 'core/strategies/delayed_strategy';\nimport IfStrategy from 'core/strategies/if_strategy';\nimport FirstConnectedStrategy from 'core/strategies/first_connected_strategy';\nimport { Config } from 'core/config';\n\nfunction testSupportsStrategy(strategy: Strategy) {\n return function() {\n return strategy.isSupported();\n };\n}\n\nvar getDefaultStrategy = function(\n config: Config,\n baseOptions: StrategyOptions,\n defineTransport: Function\n): Strategy {\n var definedTransports = {};\n\n function defineTransportStrategy(\n name: string,\n type: string,\n priority: number,\n options: StrategyOptions,\n manager?: TransportManager\n ) {\n var transport = defineTransport(\n config,\n name,\n type,\n priority,\n options,\n manager\n );\n\n definedTransports[name] = transport;\n\n return transport;\n }\n\n var ws_options: StrategyOptions = Object.assign({}, baseOptions, {\n hostNonTLS: config.wsHost + ':' + config.wsPort,\n hostTLS: config.wsHost + ':' + config.wssPort,\n httpPath: config.wsPath\n });\n var wss_options: StrategyOptions = Object.assign({}, ws_options, {\n useTLS: true\n });\n var sockjs_options: StrategyOptions = Object.assign({}, baseOptions, {\n hostNonTLS: config.httpHost + ':' + config.httpPort,\n hostTLS: config.httpHost + ':' + config.httpsPort,\n httpPath: config.httpPath\n });\n\n var timeouts = {\n loop: true,\n timeout: 15000,\n timeoutLimit: 60000\n };\n\n var ws_manager = new TransportManager({\n minPingDelay: 10000,\n maxPingDelay: config.activityTimeout\n });\n var streaming_manager = new TransportManager({\n lives: 2,\n minPingDelay: 10000,\n maxPingDelay: config.activityTimeout\n });\n\n var ws_transport = defineTransportStrategy(\n 'ws',\n 'ws',\n 3,\n ws_options,\n ws_manager\n );\n var wss_transport = defineTransportStrategy(\n 'wss',\n 'ws',\n 3,\n wss_options,\n ws_manager\n );\n var sockjs_transport = defineTransportStrategy(\n 'sockjs',\n 'sockjs',\n 1,\n sockjs_options\n );\n var xhr_streaming_transport = defineTransportStrategy(\n 'xhr_streaming',\n 'xhr_streaming',\n 1,\n sockjs_options,\n streaming_manager\n );\n var xdr_streaming_transport = defineTransportStrategy(\n 'xdr_streaming',\n 'xdr_streaming',\n 1,\n sockjs_options,\n streaming_manager\n );\n var xhr_polling_transport = defineTransportStrategy(\n 'xhr_polling',\n 'xhr_polling',\n 1,\n sockjs_options\n );\n var xdr_polling_transport = defineTransportStrategy(\n 'xdr_polling',\n 'xdr_polling',\n 1,\n sockjs_options\n );\n\n var ws_loop = new SequentialStrategy([ws_transport], timeouts);\n var wss_loop = new SequentialStrategy([wss_transport], timeouts);\n var sockjs_loop = new SequentialStrategy([sockjs_transport], timeouts);\n var streaming_loop = new SequentialStrategy(\n [\n new IfStrategy(\n testSupportsStrategy(xhr_streaming_transport),\n xhr_streaming_transport,\n xdr_streaming_transport\n )\n ],\n timeouts\n );\n var polling_loop = new SequentialStrategy(\n [\n new IfStrategy(\n testSupportsStrategy(xhr_polling_transport),\n xhr_polling_transport,\n xdr_polling_transport\n )\n ],\n timeouts\n );\n\n var http_loop = new SequentialStrategy(\n [\n new IfStrategy(\n testSupportsStrategy(streaming_loop),\n new BestConnectedEverStrategy([\n streaming_loop,\n new DelayedStrategy(polling_loop, { delay: 4000 })\n ]),\n polling_loop\n )\n ],\n timeouts\n );\n\n var http_fallback_loop = new IfStrategy(\n testSupportsStrategy(http_loop),\n http_loop,\n sockjs_loop\n );\n\n var wsStrategy;\n if (baseOptions.useTLS) {\n wsStrategy = new BestConnectedEverStrategy([\n ws_loop,\n new DelayedStrategy(http_fallback_loop, { delay: 2000 })\n ]);\n } else {\n wsStrategy = new BestConnectedEverStrategy([\n ws_loop,\n new DelayedStrategy(wss_loop, { delay: 2000 }),\n new DelayedStrategy(http_fallback_loop, { delay: 5000 })\n ]);\n }\n\n return new WebSocketPrioritizedCachedStrategy(\n new FirstConnectedStrategy(\n new IfStrategy(\n testSupportsStrategy(ws_transport),\n wsStrategy,\n http_fallback_loop\n )\n ),\n definedTransports,\n {\n ttl: 1800000,\n timeline: baseOptions.timeline,\n useTLS: baseOptions.useTLS\n }\n );\n};\n\nexport default getDefaultStrategy;\n","import { Dependencies } from '../dom/dependencies';\n\n/** Initializes the transport.\n *\n * Fetches resources if needed and then transitions to initialized.\n */\nexport default function() {\n var self = this;\n\n self.timeline.info(\n self.buildTimelineMessage({\n transport: self.name + (self.options.useTLS ? 's' : '')\n })\n );\n\n if (self.hooks.isInitialized()) {\n self.changeState('initialized');\n } else if (self.hooks.file) {\n self.changeState('initializing');\n Dependencies.load(\n self.hooks.file,\n { useTLS: self.options.useTLS },\n function(error, callback) {\n if (self.hooks.isInitialized()) {\n self.changeState('initialized');\n callback(true);\n } else {\n if (error) {\n self.onError(error);\n }\n self.onClose();\n callback(false);\n }\n }\n );\n } else {\n self.onClose();\n }\n}\n","import HTTPRequest from 'core/http/http_request';\nimport RequestHooks from 'core/http/request_hooks';\nimport Ajax from 'core/http/ajax';\nimport * as Errors from 'core/errors';\n\nvar hooks: RequestHooks = {\n getRequest: function(socket: HTTPRequest): Ajax {\n var xdr = new (window).XDomainRequest();\n xdr.ontimeout = function() {\n socket.emit('error', new Errors.RequestTimedOut());\n socket.close();\n };\n xdr.onerror = function(e) {\n socket.emit('error', e);\n socket.close();\n };\n xdr.onprogress = function() {\n if (xdr.responseText && xdr.responseText.length > 0) {\n socket.onChunk(200, xdr.responseText);\n }\n };\n xdr.onload = function() {\n if (xdr.responseText && xdr.responseText.length > 0) {\n socket.onChunk(200, xdr.responseText);\n }\n socket.emit('finished', 200);\n socket.close();\n };\n return xdr;\n },\n abortRequest: function(xdr: Ajax) {\n xdr.ontimeout = xdr.onerror = xdr.onprogress = xdr.onload = null;\n xdr.abort();\n }\n};\n\nexport default hooks;\n","import Runtime from 'runtime';\nimport RequestHooks from './request_hooks';\nimport Ajax from './ajax';\nimport { default as EventsDispatcher } from '../events/dispatcher';\n\nconst MAX_BUFFER_LENGTH = 256 * 1024;\n\nexport default class HTTPRequest extends EventsDispatcher {\n hooks: RequestHooks;\n method: string;\n url: string;\n position: number;\n xhr: Ajax;\n unloader: Function;\n\n constructor(hooks: RequestHooks, method: string, url: string) {\n super();\n this.hooks = hooks;\n this.method = method;\n this.url = url;\n }\n\n start(payload?: any) {\n this.position = 0;\n this.xhr = this.hooks.getRequest(this);\n\n this.unloader = () => {\n this.close();\n };\n Runtime.addUnloadListener(this.unloader);\n\n this.xhr.open(this.method, this.url, true);\n\n if (this.xhr.setRequestHeader) {\n this.xhr.setRequestHeader('Content-Type', 'application/json'); // ReactNative doesn't set this header by default.\n }\n this.xhr.send(payload);\n }\n\n close() {\n if (this.unloader) {\n Runtime.removeUnloadListener(this.unloader);\n this.unloader = null;\n }\n if (this.xhr) {\n this.hooks.abortRequest(this.xhr);\n this.xhr = null;\n }\n }\n\n onChunk(status: number, data: any) {\n while (true) {\n var chunk = this.advanceBuffer(data);\n if (chunk) {\n this.emit('chunk', { status: status, data: chunk });\n } else {\n break;\n }\n }\n if (this.isBufferTooLong(data)) {\n this.emit('buffer_too_long');\n }\n }\n\n private advanceBuffer(buffer: any[]): any {\n var unreadData = buffer.slice(this.position);\n var endOfLinePosition = unreadData.indexOf('\\n');\n\n if (endOfLinePosition !== -1) {\n this.position += endOfLinePosition + 1;\n return unreadData.slice(0, endOfLinePosition);\n } else {\n // chunk is not finished yet, don't move the buffer pointer\n return null;\n }\n }\n\n private isBufferTooLong(buffer: any): boolean {\n return this.position === buffer.length && buffer.length > MAX_BUFFER_LENGTH;\n }\n}\n","enum State {\n CONNECTING = 0,\n OPEN = 1,\n CLOSED = 3\n}\n\nexport default State;\n","import URLLocation from './url_location';\nimport State from './state';\nimport Socket from '../socket';\nimport SocketHooks from './socket_hooks';\nimport Util from '../util';\nimport Ajax from './ajax';\nimport HTTPRequest from './http_request';\nimport Runtime from 'runtime';\n\nvar autoIncrement = 1;\n\nclass HTTPSocket implements Socket {\n hooks: SocketHooks;\n session: string;\n location: URLLocation;\n readyState: State;\n stream: HTTPRequest;\n\n onopen: () => void;\n onerror: (error: any) => void;\n onclose: (closeEvent: any) => void;\n onmessage: (message: any) => void;\n onactivity: () => void;\n\n constructor(hooks: SocketHooks, url: string) {\n this.hooks = hooks;\n this.session = randomNumber(1000) + '/' + randomString(8);\n this.location = getLocation(url);\n this.readyState = State.CONNECTING;\n this.openStream();\n }\n\n send(payload: any) {\n return this.sendRaw(JSON.stringify([payload]));\n }\n\n ping() {\n this.hooks.sendHeartbeat(this);\n }\n\n close(code: any, reason: any) {\n this.onClose(code, reason, true);\n }\n\n /** For internal use only */\n sendRaw(payload: any): boolean {\n if (this.readyState === State.OPEN) {\n try {\n Runtime.createSocketRequest(\n 'POST',\n getUniqueURL(getSendURL(this.location, this.session))\n ).start(payload);\n return true;\n } catch (e) {\n return false;\n }\n } else {\n return false;\n }\n }\n\n /** For internal use only */\n reconnect() {\n this.closeStream();\n this.openStream();\n }\n\n /** For internal use only */\n onClose(code, reason, wasClean) {\n this.closeStream();\n this.readyState = State.CLOSED;\n if (this.onclose) {\n this.onclose({\n code: code,\n reason: reason,\n wasClean: wasClean\n });\n }\n }\n\n private onChunk(chunk) {\n if (chunk.status !== 200) {\n return;\n }\n if (this.readyState === State.OPEN) {\n this.onActivity();\n }\n\n var payload;\n var type = chunk.data.slice(0, 1);\n switch (type) {\n case 'o':\n payload = JSON.parse(chunk.data.slice(1) || '{}');\n this.onOpen(payload);\n break;\n case 'a':\n payload = JSON.parse(chunk.data.slice(1) || '[]');\n for (var i = 0; i < payload.length; i++) {\n this.onEvent(payload[i]);\n }\n break;\n case 'm':\n payload = JSON.parse(chunk.data.slice(1) || 'null');\n this.onEvent(payload);\n break;\n case 'h':\n this.hooks.onHeartbeat(this);\n break;\n case 'c':\n payload = JSON.parse(chunk.data.slice(1) || '[]');\n this.onClose(payload[0], payload[1], true);\n break;\n }\n }\n\n private onOpen(options) {\n if (this.readyState === State.CONNECTING) {\n if (options && options.hostname) {\n this.location.base = replaceHost(this.location.base, options.hostname);\n }\n this.readyState = State.OPEN;\n\n if (this.onopen) {\n this.onopen();\n }\n } else {\n this.onClose(1006, 'Server lost session', true);\n }\n }\n\n private onEvent(event) {\n if (this.readyState === State.OPEN && this.onmessage) {\n this.onmessage({ data: event });\n }\n }\n\n private onActivity() {\n if (this.onactivity) {\n this.onactivity();\n }\n }\n\n private onError(error) {\n if (this.onerror) {\n this.onerror(error);\n }\n }\n\n private openStream() {\n this.stream = Runtime.createSocketRequest(\n 'POST',\n getUniqueURL(this.hooks.getReceiveURL(this.location, this.session))\n );\n\n this.stream.bind('chunk', chunk => {\n this.onChunk(chunk);\n });\n this.stream.bind('finished', status => {\n this.hooks.onFinished(this, status);\n });\n this.stream.bind('buffer_too_long', () => {\n this.reconnect();\n });\n\n try {\n this.stream.start();\n } catch (error) {\n Util.defer(() => {\n this.onError(error);\n this.onClose(1006, 'Could not start streaming', false);\n });\n }\n }\n\n private closeStream() {\n if (this.stream) {\n this.stream.unbind_all();\n this.stream.close();\n this.stream = null;\n }\n }\n}\n\nfunction getLocation(url): URLLocation {\n var parts = /([^\\?]*)\\/*(\\??.*)/.exec(url);\n return {\n base: parts[1],\n queryString: parts[2]\n };\n}\n\nfunction getSendURL(url: URLLocation, session: string): string {\n return url.base + '/' + session + '/xhr_send';\n}\n\nfunction getUniqueURL(url: string): string {\n var separator = url.indexOf('?') === -1 ? '?' : '&';\n return url + separator + 't=' + +new Date() + '&n=' + autoIncrement++;\n}\n\nfunction replaceHost(url: string, hostname: string): string {\n var urlParts = /(https?:\\/\\/)([^\\/:]+)((\\/|:)?.*)/.exec(url);\n return urlParts[1] + hostname + urlParts[3];\n}\n\nfunction randomNumber(max: number): number {\n return Runtime.randomInt(max);\n}\n\nfunction randomString(length: number): string {\n var result = [];\n\n for (var i = 0; i < length; i++) {\n result.push(randomNumber(32).toString(32));\n }\n\n return result.join('');\n}\n\nexport default HTTPSocket;\n","import SocketHooks from './socket_hooks';\nimport HTTPSocket from './http_socket';\n\nvar hooks: SocketHooks = {\n getReceiveURL: function(url, session) {\n return url.base + '/' + session + '/xhr_streaming' + url.queryString;\n },\n onHeartbeat: function(socket) {\n socket.sendRaw('[]');\n },\n sendHeartbeat: function(socket) {\n socket.sendRaw('[]');\n },\n onFinished: function(socket, status) {\n socket.onClose(1006, 'Connection interrupted (' + status + ')', false);\n }\n};\n\nexport default hooks;\n","import SocketHooks from './socket_hooks';\nimport URLLocation from './url_location';\nimport HTTPSocket from './http_socket';\n\nvar hooks: SocketHooks = {\n getReceiveURL: function(url: URLLocation, session: string): string {\n return url.base + '/' + session + '/xhr' + url.queryString;\n },\n onHeartbeat: function() {\n // next HTTP request will reset server's activity timer\n },\n sendHeartbeat: function(socket) {\n socket.sendRaw('[]');\n },\n onFinished: function(socket, status) {\n if (status === 200) {\n socket.reconnect();\n } else {\n socket.onClose(1006, 'Connection interrupted (' + status + ')', false);\n }\n }\n};\n\nexport default hooks;\n","import HTTPRequest from 'core/http/http_request';\nimport RequestHooks from 'core/http/request_hooks';\nimport Ajax from 'core/http/ajax';\nimport Runtime from 'runtime';\n\nvar hooks: RequestHooks = {\n getRequest: function(socket: HTTPRequest): Ajax {\n var Constructor = Runtime.getXHRAPI();\n var xhr = new Constructor();\n xhr.onreadystatechange = xhr.onprogress = function() {\n switch (xhr.readyState) {\n case 3:\n if (xhr.responseText && xhr.responseText.length > 0) {\n socket.onChunk(xhr.status, xhr.responseText);\n }\n break;\n case 4:\n // this happens only on errors, never after calling close\n if (xhr.responseText && xhr.responseText.length > 0) {\n socket.onChunk(xhr.status, xhr.responseText);\n }\n socket.emit('finished', xhr.status);\n socket.close();\n break;\n }\n };\n return xhr;\n },\n abortRequest: function(xhr: Ajax) {\n xhr.onreadystatechange = null;\n xhr.abort();\n }\n};\n\nexport default hooks;\n","import HTTPRequest from 'core/http/http_request';\nimport HTTPSocket from 'core/http/http_socket';\nimport SocketHooks from 'core/http/socket_hooks';\nimport RequestHooks from 'core/http/request_hooks';\nimport streamingHooks from 'core/http/http_streaming_socket';\nimport pollingHooks from 'core/http/http_polling_socket';\nimport xhrHooks from './http_xhr_request';\nimport HTTPFactory from 'core/http/http_factory';\n\nvar HTTP: HTTPFactory = {\n createStreamingSocket(url: string): HTTPSocket {\n return this.createSocket(streamingHooks, url);\n },\n\n createPollingSocket(url: string): HTTPSocket {\n return this.createSocket(pollingHooks, url);\n },\n\n createSocket(hooks: SocketHooks, url: string): HTTPSocket {\n return new HTTPSocket(hooks, url);\n },\n\n createXHR(method: string, url: string): HTTPRequest {\n return this.createRequest(xhrHooks, method, url);\n },\n\n createRequest(hooks: RequestHooks, method: string, url: string): HTTPRequest {\n return new HTTPRequest(hooks, method, url);\n }\n};\n\nexport default HTTP;\n","import xdrHooks from './http_xdomain_request';\nimport HTTP from 'isomorphic/http/http';\n\nHTTP.createXDR = function(method, url) {\n return this.createRequest(xdrHooks, method, url);\n};\n\nexport default HTTP;\n","import Browser from './browser';\nimport { Dependencies, DependenciesReceivers } from './dom/dependencies';\nimport { AuthTransport, AuthTransports } from 'core/auth/auth_transports';\nimport xhrAuth from 'isomorphic/auth/xhr_auth';\nimport jsonpAuth from './auth/jsonp_auth';\nimport TimelineTransport from 'core/timeline/timeline_transport';\nimport TimelineSender from 'core/timeline/timeline_sender';\nimport ScriptRequest from './dom/script_request';\nimport JSONPRequest from './dom/jsonp_request';\nimport * as Collections from 'core/utils/collections';\nimport { ScriptReceivers } from './dom/script_receiver_factory';\nimport jsonpTimeline from './timeline/jsonp_timeline';\nimport Transports from './transports/transports';\nimport Ajax from 'core/http/ajax';\nimport { Network } from './net_info';\nimport getDefaultStrategy from './default_strategy';\nimport transportConnectionInitializer from './transports/transport_connection_initializer';\nimport HTTPFactory from './http/http';\nimport HTTPRequest from 'core/http/http_request';\n\nvar Runtime: Browser = {\n // for jsonp auth\n nextAuthCallbackID: 1,\n auth_callbacks: {},\n ScriptReceivers,\n DependenciesReceivers,\n getDefaultStrategy,\n Transports,\n transportConnectionInitializer,\n HTTPFactory,\n\n TimelineTransport: jsonpTimeline,\n\n getXHRAPI() {\n return window.XMLHttpRequest;\n },\n\n getWebSocketAPI() {\n return window.WebSocket || window.MozWebSocket;\n },\n\n setup(PusherClass): void {\n (window).Pusher = PusherClass; // JSONp requires Pusher to be in the global scope.\n var initializeOnDocumentBody = () => {\n this.onDocumentBody(PusherClass.ready);\n };\n if (!(window).JSON) {\n Dependencies.load('json2', {}, initializeOnDocumentBody);\n } else {\n initializeOnDocumentBody();\n }\n },\n\n getDocument(): Document {\n return document;\n },\n\n getProtocol(): string {\n return this.getDocument().location.protocol;\n },\n\n getAuthorizers(): AuthTransports {\n return { ajax: xhrAuth, jsonp: jsonpAuth };\n },\n\n onDocumentBody(callback: Function) {\n if (document.body) {\n callback();\n } else {\n setTimeout(() => {\n this.onDocumentBody(callback);\n }, 0);\n }\n },\n\n createJSONPRequest(url: string, data: any): JSONPRequest {\n return new JSONPRequest(url, data);\n },\n\n createScriptRequest(src: string): ScriptRequest {\n return new ScriptRequest(src);\n },\n\n getLocalStorage() {\n try {\n return window.localStorage;\n } catch (e) {\n return undefined;\n }\n },\n\n createXHR(): Ajax {\n if (this.getXHRAPI()) {\n return this.createXMLHttpRequest();\n } else {\n return this.createMicrosoftXHR();\n }\n },\n\n createXMLHttpRequest(): Ajax {\n var Constructor = this.getXHRAPI();\n return new Constructor();\n },\n\n createMicrosoftXHR(): Ajax {\n return new ActiveXObject('Microsoft.XMLHTTP');\n },\n\n getNetwork() {\n return Network;\n },\n\n createWebSocket(url: string): any {\n var Constructor = this.getWebSocketAPI();\n return new Constructor(url);\n },\n\n createSocketRequest(method: string, url: string): HTTPRequest {\n if (this.isXHRSupported()) {\n return this.HTTPFactory.createXHR(method, url);\n } else if (this.isXDRSupported(url.indexOf('https:') === 0)) {\n return this.HTTPFactory.createXDR(method, url);\n } else {\n throw 'Cross-origin HTTP requests are not supported';\n }\n },\n\n isXHRSupported(): boolean {\n var Constructor = this.getXHRAPI();\n return (\n Boolean(Constructor) && new Constructor().withCredentials !== undefined\n );\n },\n\n isXDRSupported(useTLS?: boolean): boolean {\n var protocol = useTLS ? 'https:' : 'http:';\n var documentProtocol = this.getProtocol();\n return (\n Boolean(window['XDomainRequest']) && documentProtocol === protocol\n );\n },\n\n addUnloadListener(listener: any) {\n if (window.addEventListener !== undefined) {\n window.addEventListener('unload', listener, false);\n } else if (window.attachEvent !== undefined) {\n window.attachEvent('onunload', listener);\n }\n },\n\n removeUnloadListener(listener: any) {\n if (window.addEventListener !== undefined) {\n window.removeEventListener('unload', listener, false);\n } else if (window.detachEvent !== undefined) {\n window.detachEvent('onunload', listener);\n }\n },\n\n randomInt(max: number): number {\n /**\n * Return values in the range of [0, 1[\n */\n const random = function() {\n const crypto = window.crypto || window['msCrypto'];\n const random = crypto.getRandomValues(new Uint32Array(1))[0];\n\n return random / 2 ** 32;\n };\n\n return Math.floor(random() * max);\n }\n};\n\nexport default Runtime;\n","enum TimelineLevel {\n ERROR = 3,\n INFO = 6,\n DEBUG = 7\n}\n\nexport default TimelineLevel;\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport { default as Level } from './level';\n\nexport interface TimelineOptions {\n level?: Level;\n limit?: number;\n version?: string;\n cluster?: string;\n features?: string[];\n params?: any;\n}\n\nexport default class Timeline {\n key: string;\n session: number;\n events: any[];\n options: TimelineOptions;\n sent: number;\n uniqueID: number;\n\n constructor(key: string, session: number, options: TimelineOptions) {\n this.key = key;\n this.session = session;\n this.events = [];\n this.options = options || {};\n this.sent = 0;\n this.uniqueID = 0;\n }\n\n log(level, event) {\n if (level <= this.options.level) {\n this.events.push(\n Collections.extend({}, event, { timestamp: Util.now() })\n );\n if (this.options.limit && this.events.length > this.options.limit) {\n this.events.shift();\n }\n }\n }\n\n error(event) {\n this.log(Level.ERROR, event);\n }\n\n info(event) {\n this.log(Level.INFO, event);\n }\n\n debug(event) {\n this.log(Level.DEBUG, event);\n }\n\n isEmpty() {\n return this.events.length === 0;\n }\n\n send(sendfn, callback) {\n var data = Collections.extend(\n {\n session: this.session,\n bundle: this.sent + 1,\n key: this.key,\n lib: 'js',\n version: this.options.version,\n cluster: this.options.cluster,\n features: this.options.features,\n timeline: this.events\n },\n this.options.params\n );\n\n this.events = [];\n sendfn(data, (error, result) => {\n if (!error) {\n this.sent++;\n }\n if (callback) {\n callback(error, result);\n }\n });\n\n return true;\n }\n\n generateUniqueID(): number {\n this.uniqueID++;\n return this.uniqueID;\n }\n}\n","import Factory from '../utils/factory';\nimport Util from '../util';\nimport * as Errors from '../errors';\nimport * as Collections from '../utils/collections';\nimport Strategy from './strategy';\nimport Transport from '../transports/transport';\nimport StrategyOptions from './strategy_options';\nimport Handshake from '../connection/handshake';\n\n/** Provides a strategy interface for transports.\n *\n * @param {String} name\n * @param {Number} priority\n * @param {Class} transport\n * @param {Object} options\n */\nexport default class TransportStrategy implements Strategy {\n name: string;\n priority: number;\n transport: Transport;\n options: StrategyOptions;\n\n constructor(\n name: string,\n priority: number,\n transport: Transport,\n options: StrategyOptions\n ) {\n this.name = name;\n this.priority = priority;\n this.transport = transport;\n this.options = options || {};\n }\n\n /** Returns whether the transport is supported in the browser.\n *\n * @returns {Boolean}\n */\n isSupported(): boolean {\n return this.transport.isSupported({\n useTLS: this.options.useTLS\n });\n }\n\n /** Launches a connection attempt and returns a strategy runner.\n *\n * @param {Function} callback\n * @return {Object} strategy runner\n */\n connect(minPriority: number, callback: Function) {\n if (!this.isSupported()) {\n return failAttempt(new Errors.UnsupportedStrategy(), callback);\n } else if (this.priority < minPriority) {\n return failAttempt(new Errors.TransportPriorityTooLow(), callback);\n }\n\n var connected = false;\n var transport = this.transport.createConnection(\n this.name,\n this.priority,\n this.options.key,\n this.options\n );\n var handshake = null;\n\n var onInitialized = function() {\n transport.unbind('initialized', onInitialized);\n transport.connect();\n };\n var onOpen = function() {\n handshake = Factory.createHandshake(transport, function(result) {\n connected = true;\n unbindListeners();\n callback(null, result);\n });\n };\n var onError = function(error) {\n unbindListeners();\n callback(error);\n };\n var onClosed = function() {\n unbindListeners();\n var serializedTransport;\n\n // The reason for this try/catch block is that on React Native\n // the WebSocket object is circular. Therefore transport.socket will\n // throw errors upon stringification. Collections.safeJSONStringify\n // discards circular references when serializing.\n serializedTransport = Collections.safeJSONStringify(transport);\n callback(new Errors.TransportClosed(serializedTransport));\n };\n\n var unbindListeners = function() {\n transport.unbind('initialized', onInitialized);\n transport.unbind('open', onOpen);\n transport.unbind('error', onError);\n transport.unbind('closed', onClosed);\n };\n\n transport.bind('initialized', onInitialized);\n transport.bind('open', onOpen);\n transport.bind('error', onError);\n transport.bind('closed', onClosed);\n\n // connect will be called automatically after initialization\n transport.initialize();\n\n return {\n abort: () => {\n if (connected) {\n return;\n }\n unbindListeners();\n if (handshake) {\n handshake.close();\n } else {\n transport.close();\n }\n },\n forceMinPriority: p => {\n if (connected) {\n return;\n }\n if (this.priority < p) {\n if (handshake) {\n handshake.close();\n } else {\n transport.close();\n }\n }\n }\n };\n }\n}\n\nfunction failAttempt(error: Error, callback: Function) {\n Util.defer(function() {\n callback(error);\n });\n return {\n abort: function() {},\n forceMinPriority: function() {}\n };\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport TransportManager from '../transports/transport_manager';\nimport * as Errors from '../errors';\nimport Strategy from './strategy';\nimport TransportStrategy from './transport_strategy';\nimport StrategyOptions from '../strategies/strategy_options';\nimport { Config } from '../config';\nimport Runtime from 'runtime';\n\nconst { Transports } = Runtime;\n\nexport var defineTransport = function(\n config: Config,\n name: string,\n type: string,\n priority: number,\n options: StrategyOptions,\n manager?: TransportManager\n): Strategy {\n var transportClass = Transports[type];\n if (!transportClass) {\n throw new Errors.UnsupportedTransport(type);\n }\n\n var enabled =\n (!config.enabledTransports ||\n Collections.arrayIndexOf(config.enabledTransports, name) !== -1) &&\n (!config.disabledTransports ||\n Collections.arrayIndexOf(config.disabledTransports, name) === -1);\n\n var transport;\n if (enabled) {\n options = Object.assign(\n { ignoreNullOrigin: config.ignoreNullOrigin },\n options\n );\n\n transport = new TransportStrategy(\n name,\n priority,\n manager ? manager.getAssistant(transportClass) : transportClass,\n options\n );\n } else {\n transport = UnsupportedStrategy;\n }\n\n return transport;\n};\n\nvar UnsupportedStrategy: Strategy = {\n isSupported: function() {\n return false;\n },\n connect: function(_, callback) {\n var deferred = Util.defer(function() {\n callback(new Errors.UnsupportedStrategy());\n });\n return {\n abort: function() {\n deferred.ensureAborted();\n },\n forceMinPriority: function() {}\n };\n }\n};\n","import ConnectionManager from './connection/connection_manager';\nimport {\n ChannelAuthorizationOptions,\n UserAuthenticationOptions\n} from './auth/options';\nimport {\n ChannelAuthorizerGenerator,\n DeprecatedAuthOptions\n} from './auth/deprecated_channel_authorizer';\nimport { AuthTransport, Transport } from './config';\nimport * as nacl from 'tweetnacl';\nimport Logger from './logger';\n\nexport interface Options {\n activityTimeout?: number;\n\n auth?: DeprecatedAuthOptions; // DEPRECATED use channelAuthorization instead\n authEndpoint?: string; // DEPRECATED use channelAuthorization instead\n authTransport?: AuthTransport; // DEPRECATED use channelAuthorization instead\n authorizer?: ChannelAuthorizerGenerator; // DEPRECATED use channelAuthorization instead\n\n channelAuthorization?: ChannelAuthorizationOptions;\n userAuthentication?: UserAuthenticationOptions;\n\n cluster: string;\n enableStats?: boolean;\n disableStats?: boolean;\n disabledTransports?: Transport[];\n enabledTransports?: Transport[];\n forceTLS?: boolean;\n httpHost?: string;\n httpPath?: string;\n httpPort?: number;\n httpsPort?: number;\n ignoreNullOrigin?: boolean;\n nacl?: nacl;\n pongTimeout?: number;\n statsHost?: string;\n timelineParams?: any;\n unavailableTimeout?: number;\n wsHost?: string;\n wsPath?: string;\n wsPort?: number;\n wssPort?: number;\n}\n\nexport interface ClusterOptions {\n appKey: string;\n cluster: string;\n}\n\nexport function validateOptions(options) {\n if (options == null) {\n throw 'You must pass an options object';\n }\n if (options.cluster == null) {\n throw 'Options object must provide a cluster';\n }\n if ('disableStats' in options) {\n Logger.warn(\n 'The disableStats option is deprecated in favor of enableStats'\n );\n }\n}\n","import {\n UserAuthenticationCallback,\n InternalAuthOptions,\n UserAuthenticationHandler,\n UserAuthenticationRequestParams,\n AuthRequestType\n} from './options';\n\nimport Runtime from 'runtime';\n\nconst composeChannelQuery = (\n params: UserAuthenticationRequestParams,\n authOptions: InternalAuthOptions\n) => {\n var query = 'socket_id=' + encodeURIComponent(params.socketId);\n\n for (var key in authOptions.params) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(authOptions.params[key]);\n }\n\n if (authOptions.paramsProvider != null) {\n let dynamicParams = authOptions.paramsProvider();\n for (var key in dynamicParams) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(dynamicParams[key]);\n }\n }\n\n return query;\n};\n\nconst UserAuthenticator = (\n authOptions: InternalAuthOptions\n): UserAuthenticationHandler => {\n if (typeof Runtime.getAuthorizers()[authOptions.transport] === 'undefined') {\n throw `'${authOptions.transport}' is not a recognized auth transport`;\n }\n\n return (\n params: UserAuthenticationRequestParams,\n callback: UserAuthenticationCallback\n ) => {\n const query = composeChannelQuery(params, authOptions);\n\n Runtime.getAuthorizers()[authOptions.transport](\n Runtime,\n query,\n authOptions,\n AuthRequestType.UserAuthentication,\n callback\n );\n };\n};\n\nexport default UserAuthenticator;\n","import {\n AuthRequestType,\n InternalAuthOptions,\n ChannelAuthorizationHandler,\n ChannelAuthorizationRequestParams,\n ChannelAuthorizationCallback\n} from './options';\n\nimport Runtime from 'runtime';\n\nconst composeChannelQuery = (\n params: ChannelAuthorizationRequestParams,\n authOptions: InternalAuthOptions\n) => {\n var query = 'socket_id=' + encodeURIComponent(params.socketId);\n\n query += '&channel_name=' + encodeURIComponent(params.channelName);\n\n for (var key in authOptions.params) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(authOptions.params[key]);\n }\n\n if (authOptions.paramsProvider != null) {\n let dynamicParams = authOptions.paramsProvider();\n for (var key in dynamicParams) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(dynamicParams[key]);\n }\n }\n\n return query;\n};\n\nconst ChannelAuthorizer = (\n authOptions: InternalAuthOptions\n): ChannelAuthorizationHandler => {\n if (typeof Runtime.getAuthorizers()[authOptions.transport] === 'undefined') {\n throw `'${authOptions.transport}' is not a recognized auth transport`;\n }\n\n return (\n params: ChannelAuthorizationRequestParams,\n callback: ChannelAuthorizationCallback\n ) => {\n const query = composeChannelQuery(params, authOptions);\n\n Runtime.getAuthorizers()[authOptions.transport](\n Runtime,\n query,\n authOptions,\n AuthRequestType.ChannelAuthorization,\n callback\n );\n };\n};\n\nexport default ChannelAuthorizer;\n","import Channel from '../channels/channel';\nimport {\n ChannelAuthorizationCallback,\n ChannelAuthorizationHandler,\n ChannelAuthorizationRequestParams,\n InternalAuthOptions\n} from './options';\n\nexport interface DeprecatedChannelAuthorizer {\n authorize(socketId: string, callback: ChannelAuthorizationCallback): void;\n}\n\nexport interface ChannelAuthorizerGenerator {\n (\n channel: Channel,\n options: DeprecatedAuthorizerOptions\n ): DeprecatedChannelAuthorizer;\n}\n\nexport interface DeprecatedAuthOptions {\n params?: any;\n headers?: any;\n}\n\nexport interface DeprecatedAuthorizerOptions {\n authTransport: 'ajax' | 'jsonp';\n authEndpoint: string;\n auth?: DeprecatedAuthOptions;\n}\n\nexport const ChannelAuthorizerProxy = (\n pusher,\n authOptions: InternalAuthOptions,\n channelAuthorizerGenerator: ChannelAuthorizerGenerator\n): ChannelAuthorizationHandler => {\n const deprecatedAuthorizerOptions: DeprecatedAuthorizerOptions = {\n authTransport: authOptions.transport,\n authEndpoint: authOptions.endpoint,\n auth: {\n params: authOptions.params,\n headers: authOptions.headers\n }\n };\n return (\n params: ChannelAuthorizationRequestParams,\n callback: ChannelAuthorizationCallback\n ) => {\n const channel = pusher.channel(params.channelName);\n // This line creates a new channel authorizer every time.\n // In the past, this was only done once per channel and reused.\n // We can do that again if we want to keep this behavior intact.\n const channelAuthorizer: DeprecatedChannelAuthorizer = channelAuthorizerGenerator(\n channel,\n deprecatedAuthorizerOptions\n );\n channelAuthorizer.authorize(params.socketId, callback);\n };\n};\n","import { Options } from './options';\nimport Defaults from './defaults';\nimport {\n ChannelAuthorizationHandler,\n UserAuthenticationHandler,\n ChannelAuthorizationOptions\n} from './auth/options';\nimport UserAuthenticator from './auth/user_authenticator';\nimport ChannelAuthorizer from './auth/channel_authorizer';\nimport { ChannelAuthorizerProxy } from './auth/deprecated_channel_authorizer';\nimport Runtime from 'runtime';\nimport * as nacl from 'tweetnacl';\n\nexport type AuthTransport = 'ajax' | 'jsonp';\nexport type Transport =\n | 'ws'\n | 'wss'\n | 'xhr_streaming'\n | 'xhr_polling'\n | 'sockjs';\n\nexport interface Config {\n // these are all 'required' config parameters, it's not necessary for the user\n // to set them, but they have configured defaults.\n activityTimeout: number;\n enableStats: boolean;\n httpHost: string;\n httpPath: string;\n httpPort: number;\n httpsPort: number;\n pongTimeout: number;\n statsHost: string;\n unavailableTimeout: number;\n useTLS: boolean;\n wsHost: string;\n wsPath: string;\n wsPort: number;\n wssPort: number;\n userAuthenticator: UserAuthenticationHandler;\n channelAuthorizer: ChannelAuthorizationHandler;\n\n // these are all optional parameters or overrrides. The customer can set these\n // but it's not strictly necessary\n forceTLS?: boolean;\n cluster?: string;\n disabledTransports?: Transport[];\n enabledTransports?: Transport[];\n ignoreNullOrigin?: boolean;\n nacl?: nacl;\n timelineParams?: any;\n}\n\n// getConfig mainly sets the defaults for the options that are not provided\nexport function getConfig(opts: Options, pusher): Config {\n let config: Config = {\n activityTimeout: opts.activityTimeout || Defaults.activityTimeout,\n cluster: opts.cluster,\n httpPath: opts.httpPath || Defaults.httpPath,\n httpPort: opts.httpPort || Defaults.httpPort,\n httpsPort: opts.httpsPort || Defaults.httpsPort,\n pongTimeout: opts.pongTimeout || Defaults.pongTimeout,\n statsHost: opts.statsHost || Defaults.stats_host,\n unavailableTimeout: opts.unavailableTimeout || Defaults.unavailableTimeout,\n wsPath: opts.wsPath || Defaults.wsPath,\n wsPort: opts.wsPort || Defaults.wsPort,\n wssPort: opts.wssPort || Defaults.wssPort,\n\n enableStats: getEnableStatsConfig(opts),\n httpHost: getHttpHost(opts),\n useTLS: shouldUseTLS(opts),\n wsHost: getWebsocketHost(opts),\n\n userAuthenticator: buildUserAuthenticator(opts),\n channelAuthorizer: buildChannelAuthorizer(opts, pusher)\n };\n\n if ('disabledTransports' in opts)\n config.disabledTransports = opts.disabledTransports;\n if ('enabledTransports' in opts)\n config.enabledTransports = opts.enabledTransports;\n if ('ignoreNullOrigin' in opts)\n config.ignoreNullOrigin = opts.ignoreNullOrigin;\n if ('timelineParams' in opts) config.timelineParams = opts.timelineParams;\n if ('nacl' in opts) {\n config.nacl = opts.nacl;\n }\n\n return config;\n}\n\nfunction getHttpHost(opts: Options): string {\n if (opts.httpHost) {\n return opts.httpHost;\n }\n if (opts.cluster) {\n return `sockjs-${opts.cluster}.pusher.com`;\n }\n return Defaults.httpHost;\n}\n\nfunction getWebsocketHost(opts: Options): string {\n if (opts.wsHost) {\n return opts.wsHost;\n }\n return getWebsocketHostFromCluster(opts.cluster);\n}\n\nfunction getWebsocketHostFromCluster(cluster: string): string {\n return `ws-${cluster}.pusher.com`;\n}\n\nfunction shouldUseTLS(opts: Options): boolean {\n if (Runtime.getProtocol() === 'https:') {\n return true;\n } else if (opts.forceTLS === false) {\n return false;\n }\n return true;\n}\n\n// if enableStats is set take the value\n// if disableStats is set take the inverse\n// otherwise default to false\nfunction getEnableStatsConfig(opts: Options): boolean {\n if ('enableStats' in opts) {\n return opts.enableStats;\n }\n if ('disableStats' in opts) {\n return !opts.disableStats;\n }\n return false;\n}\n\nfunction buildUserAuthenticator(opts: Options): UserAuthenticationHandler {\n const userAuthentication = {\n ...Defaults.userAuthentication,\n ...opts.userAuthentication\n };\n if (\n 'customHandler' in userAuthentication &&\n userAuthentication['customHandler'] != null\n ) {\n return userAuthentication['customHandler'];\n }\n\n return UserAuthenticator(userAuthentication);\n}\n\nfunction buildChannelAuth(opts: Options, pusher): ChannelAuthorizationOptions {\n let channelAuthorization: ChannelAuthorizationOptions;\n if ('channelAuthorization' in opts) {\n channelAuthorization = {\n ...Defaults.channelAuthorization,\n ...opts.channelAuthorization\n };\n } else {\n channelAuthorization = {\n transport: opts.authTransport || Defaults.authTransport,\n endpoint: opts.authEndpoint || Defaults.authEndpoint\n };\n if ('auth' in opts) {\n if ('params' in opts.auth) channelAuthorization.params = opts.auth.params;\n if ('headers' in opts.auth)\n channelAuthorization.headers = opts.auth.headers;\n }\n if ('authorizer' in opts)\n channelAuthorization.customHandler = ChannelAuthorizerProxy(\n pusher,\n channelAuthorization,\n opts.authorizer\n );\n }\n return channelAuthorization;\n}\n\nfunction buildChannelAuthorizer(\n opts: Options,\n pusher\n): ChannelAuthorizationHandler {\n const channelAuthorization = buildChannelAuth(opts, pusher);\n if (\n 'customHandler' in channelAuthorization &&\n channelAuthorization['customHandler'] != null\n ) {\n return channelAuthorization['customHandler'];\n }\n\n return ChannelAuthorizer(channelAuthorization);\n}\n","import Logger from './logger';\nimport Pusher from './pusher';\nimport EventsDispatcher from './events/dispatcher';\n\nexport default class WatchlistFacade extends EventsDispatcher {\n private pusher: Pusher;\n\n public constructor(pusher: Pusher) {\n super(function(eventName, data) {\n Logger.debug(`No callbacks on watchlist events for ${eventName}`);\n });\n\n this.pusher = pusher;\n this.bindWatchlistInternalEvent();\n }\n\n handleEvent(pusherEvent) {\n pusherEvent.data.events.forEach(watchlistEvent => {\n this.emit(watchlistEvent.name, watchlistEvent);\n });\n }\n\n private bindWatchlistInternalEvent() {\n this.pusher.connection.bind('message', pusherEvent => {\n var eventName = pusherEvent.event;\n if (eventName === 'pusher_internal:watchlist_events') {\n this.handleEvent(pusherEvent);\n }\n });\n }\n}\n","function flatPromise() {\n let resolve, reject;\n const promise = new Promise((res, rej) => {\n resolve = res;\n reject = rej;\n });\n return { promise, resolve, reject };\n}\n\nexport default flatPromise;\n","import Pusher from './pusher';\nimport Logger from './logger';\nimport {\n UserAuthenticationData,\n UserAuthenticationCallback\n} from './auth/options';\nimport Channel from './channels/channel';\nimport WatchlistFacade from './watchlist';\nimport EventsDispatcher from './events/dispatcher';\nimport flatPromise from './utils/flat_promise';\n\nexport default class UserFacade extends EventsDispatcher {\n pusher: Pusher;\n signin_requested: boolean = false;\n user_data: any = null;\n serverToUserChannel: Channel = null;\n signinDonePromise: Promise = null;\n watchlist: WatchlistFacade;\n private _signinDoneResolve: Function = null;\n\n public constructor(pusher: Pusher) {\n super(function(eventName, data) {\n Logger.debug('No callbacks on user for ' + eventName);\n });\n this.pusher = pusher;\n this.pusher.connection.bind('state_change', ({ previous, current }) => {\n if (previous !== 'connected' && current === 'connected') {\n this._signin();\n }\n if (previous === 'connected' && current !== 'connected') {\n this._cleanup();\n this._newSigninPromiseIfNeeded();\n }\n });\n\n this.watchlist = new WatchlistFacade(pusher);\n\n this.pusher.connection.bind('message', event => {\n var eventName = event.event;\n if (eventName === 'pusher:signin_success') {\n this._onSigninSuccess(event.data);\n }\n if (\n this.serverToUserChannel &&\n this.serverToUserChannel.name === event.channel\n ) {\n this.serverToUserChannel.handleEvent(event);\n }\n });\n }\n\n public signin() {\n if (this.signin_requested) {\n return;\n }\n\n this.signin_requested = true;\n this._signin();\n }\n\n private _signin() {\n if (!this.signin_requested) {\n return;\n }\n\n this._newSigninPromiseIfNeeded();\n\n if (this.pusher.connection.state !== 'connected') {\n // Signin will be attempted when the connection is connected\n return;\n }\n\n this.pusher.config.userAuthenticator(\n {\n socketId: this.pusher.connection.socket_id\n },\n this._onAuthorize\n );\n }\n\n private _onAuthorize: UserAuthenticationCallback = (\n err,\n authData: UserAuthenticationData\n ) => {\n if (err) {\n Logger.warn(`Error during signin: ${err}`);\n this._cleanup();\n return;\n }\n\n this.pusher.send_event('pusher:signin', {\n auth: authData.auth,\n user_data: authData.user_data\n });\n\n // Later when we get pusher:singin_success event, the user will be marked as signed in\n };\n\n private _onSigninSuccess(data: any) {\n try {\n this.user_data = JSON.parse(data.user_data);\n } catch (e) {\n Logger.error(`Failed parsing user data after signin: ${data.user_data}`);\n this._cleanup();\n return;\n }\n\n if (typeof this.user_data.id !== 'string' || this.user_data.id === '') {\n Logger.error(\n `user_data doesn't contain an id. user_data: ${this.user_data}`\n );\n this._cleanup();\n return;\n }\n\n // Signin succeeded\n this._signinDoneResolve();\n this._subscribeChannels();\n }\n\n private _subscribeChannels() {\n const ensure_subscribed = channel => {\n if (channel.subscriptionPending && channel.subscriptionCancelled) {\n channel.reinstateSubscription();\n } else if (\n !channel.subscriptionPending &&\n this.pusher.connection.state === 'connected'\n ) {\n channel.subscribe();\n }\n };\n\n this.serverToUserChannel = new Channel(\n `#server-to-user-${this.user_data.id}`,\n this.pusher\n );\n this.serverToUserChannel.bind_global((eventName, data) => {\n if (\n eventName.indexOf('pusher_internal:') === 0 ||\n eventName.indexOf('pusher:') === 0\n ) {\n // ignore internal events\n return;\n }\n this.emit(eventName, data);\n });\n ensure_subscribed(this.serverToUserChannel);\n }\n\n private _cleanup() {\n this.user_data = null;\n if (this.serverToUserChannel) {\n this.serverToUserChannel.unbind_all();\n this.serverToUserChannel.disconnect();\n this.serverToUserChannel = null;\n }\n\n if (this.signin_requested) {\n // If signin is in progress and cleanup is called,\n // Mark the current signin process as done.\n this._signinDoneResolve();\n }\n }\n\n private _newSigninPromiseIfNeeded() {\n if (!this.signin_requested) {\n return;\n }\n\n // If there is a promise and it is not resolved, return without creating a new one.\n if (this.signinDonePromise && !(this.signinDonePromise as any).done) {\n return;\n }\n\n // This promise is never rejected.\n // It gets resolved when the signin process is done whether it failed or succeeded\n const { promise, resolve, reject: _ } = flatPromise();\n (promise as any).done = false;\n const setDone = () => {\n (promise as any).done = true;\n };\n promise.then(setDone).catch(setDone);\n this.signinDonePromise = promise;\n this._signinDoneResolve = resolve;\n }\n}\n","import AbstractRuntime from '../runtimes/interface';\nimport Runtime from 'runtime';\nimport * as Collections from './utils/collections';\nimport Channels from './channels/channels';\nimport Channel from './channels/channel';\nimport { default as EventsDispatcher } from './events/dispatcher';\nimport Timeline from './timeline/timeline';\nimport TimelineSender from './timeline/timeline_sender';\nimport TimelineLevel from './timeline/level';\nimport { defineTransport } from './strategies/strategy_builder';\nimport ConnectionManager from './connection/connection_manager';\nimport { PeriodicTimer } from './utils/timers';\nimport Defaults from './defaults';\nimport Logger from './logger';\nimport Factory from './utils/factory';\nimport { Options, ClusterOptions, validateOptions } from './options';\nimport { Config, getConfig } from './config';\nimport StrategyOptions from './strategies/strategy_options';\nimport UserFacade from './user';\n\nexport default class Pusher {\n /* STATIC PROPERTIES */\n static instances: Pusher[] = [];\n static isReady: boolean = false;\n static logToConsole: boolean = false;\n\n // for jsonp\n static Runtime: AbstractRuntime = Runtime;\n static ScriptReceivers: any = (Runtime).ScriptReceivers;\n static DependenciesReceivers: any = (Runtime).DependenciesReceivers;\n static auth_callbacks: any = (Runtime).auth_callbacks;\n\n static ready() {\n Pusher.isReady = true;\n for (var i = 0, l = Pusher.instances.length; i < l; i++) {\n Pusher.instances[i].connect();\n }\n }\n\n static log: (message: any) => void;\n\n private static getClientFeatures(): string[] {\n return Collections.keys(\n Collections.filterObject({ ws: Runtime.Transports.ws }, function(t) {\n return t.isSupported({});\n })\n );\n }\n\n /* INSTANCE PROPERTIES */\n key: string;\n options: Options;\n config: Config;\n channels: Channels;\n global_emitter: EventsDispatcher;\n sessionID: number;\n timeline: Timeline;\n timelineSender: TimelineSender;\n connection: ConnectionManager;\n timelineSenderTimer: PeriodicTimer;\n user: UserFacade;\n constructor(app_key: string, options: Options) {\n checkAppKey(app_key);\n validateOptions(options);\n this.key = app_key;\n this.config = getConfig(options, this);\n\n this.channels = Factory.createChannels();\n this.global_emitter = new EventsDispatcher();\n this.sessionID = Runtime.randomInt(1000000000);\n\n this.timeline = new Timeline(this.key, this.sessionID, {\n cluster: this.config.cluster,\n features: Pusher.getClientFeatures(),\n params: this.config.timelineParams || {},\n limit: 50,\n level: TimelineLevel.INFO,\n version: Defaults.VERSION\n });\n if (this.config.enableStats) {\n this.timelineSender = Factory.createTimelineSender(this.timeline, {\n host: this.config.statsHost,\n path: '/timeline/v2/' + Runtime.TimelineTransport.name\n });\n }\n\n var getStrategy = (options: StrategyOptions) => {\n return Runtime.getDefaultStrategy(this.config, options, defineTransport);\n };\n\n this.connection = Factory.createConnectionManager(this.key, {\n getStrategy: getStrategy,\n timeline: this.timeline,\n activityTimeout: this.config.activityTimeout,\n pongTimeout: this.config.pongTimeout,\n unavailableTimeout: this.config.unavailableTimeout,\n useTLS: Boolean(this.config.useTLS)\n });\n\n this.connection.bind('connected', () => {\n this.subscribeAll();\n if (this.timelineSender) {\n this.timelineSender.send(this.connection.isUsingTLS());\n }\n });\n\n this.connection.bind('message', event => {\n var eventName = event.event;\n var internal = eventName.indexOf('pusher_internal:') === 0;\n if (event.channel) {\n var channel = this.channel(event.channel);\n if (channel) {\n channel.handleEvent(event);\n }\n }\n // Emit globally [deprecated]\n if (!internal) {\n this.global_emitter.emit(event.event, event.data);\n }\n });\n this.connection.bind('connecting', () => {\n this.channels.disconnect();\n });\n this.connection.bind('disconnected', () => {\n this.channels.disconnect();\n });\n this.connection.bind('error', err => {\n Logger.warn(err);\n });\n\n Pusher.instances.push(this);\n this.timeline.info({ instances: Pusher.instances.length });\n\n this.user = new UserFacade(this);\n\n if (Pusher.isReady) {\n this.connect();\n }\n }\n\n /**\n * Allows you to switch Pusher cluster without\n * losing all the channels/subscription binding\n * as this is internally managed by the SDK.\n */\n switchCluster(options: ClusterOptions) {\n const { appKey, cluster } = options;\n this.key = appKey;\n this.options = { ...this.options, cluster };\n this.config = getConfig(this.options, this);\n this.connection.switchCluster(this.key);\n }\n\n channel(name: string): Channel {\n return this.channels.find(name);\n }\n\n allChannels(): Channel[] {\n return this.channels.all();\n }\n\n connect() {\n this.connection.connect();\n\n if (this.timelineSender) {\n if (!this.timelineSenderTimer) {\n var usingTLS = this.connection.isUsingTLS();\n var timelineSender = this.timelineSender;\n this.timelineSenderTimer = new PeriodicTimer(60000, function() {\n timelineSender.send(usingTLS);\n });\n }\n }\n }\n\n disconnect() {\n this.connection.disconnect();\n\n if (this.timelineSenderTimer) {\n this.timelineSenderTimer.ensureAborted();\n this.timelineSenderTimer = null;\n }\n }\n\n bind(event_name: string, callback: Function, context?: any): Pusher {\n this.global_emitter.bind(event_name, callback, context);\n return this;\n }\n\n unbind(event_name?: string, callback?: Function, context?: any): Pusher {\n this.global_emitter.unbind(event_name, callback, context);\n return this;\n }\n\n bind_global(callback: Function): Pusher {\n this.global_emitter.bind_global(callback);\n return this;\n }\n\n unbind_global(callback?: Function): Pusher {\n this.global_emitter.unbind_global(callback);\n return this;\n }\n\n unbind_all(callback?: Function): Pusher {\n this.global_emitter.unbind_all();\n return this;\n }\n\n subscribeAll() {\n var channelName;\n for (channelName in this.channels.channels) {\n if (this.channels.channels.hasOwnProperty(channelName)) {\n this.subscribe(channelName);\n }\n }\n }\n\n subscribe(channel_name: string) {\n var channel = this.channels.add(channel_name, this);\n if (channel.subscriptionPending && channel.subscriptionCancelled) {\n channel.reinstateSubscription();\n } else if (\n !channel.subscriptionPending &&\n this.connection.state === 'connected'\n ) {\n channel.subscribe();\n }\n return channel;\n }\n\n unsubscribe(channel_name: string) {\n var channel = this.channels.find(channel_name);\n if (channel && channel.subscriptionPending) {\n channel.cancelSubscription();\n } else {\n channel = this.channels.remove(channel_name);\n if (channel && channel.subscribed) {\n channel.unsubscribe();\n }\n }\n }\n\n send_event(event_name: string, data: any, channel?: string) {\n return this.connection.send_event(event_name, data, channel);\n }\n\n shouldUseTLS(): boolean {\n return this.config.useTLS;\n }\n\n signin() {\n this.user.signin();\n }\n}\n\nfunction checkAppKey(key) {\n if (key === null || key === undefined) {\n throw 'You must pass your app key when you instantiate Pusher.';\n }\n}\n\nRuntime.setup(Pusher);\n"],"sourceRoot":""} \ No newline at end of file diff --git a/dist/web/pusher.min.js b/dist/web/pusher.min.js index 0d5328a48..a476ca263 100644 --- a/dist/web/pusher.min.js +++ b/dist/web/pusher.min.js @@ -1,9 +1,9 @@ /*! - * Pusher JavaScript Library v8.4.0 + * Pusher JavaScript Library v8.4.0-rc1 * https://pusher.com/ * * Copyright 2020, Pusher * Released under the MIT licence. */ -!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.Pusher=e():t.Pusher=e()}(window,(function(){return function(t){var e={};function n(i){if(e[i])return e[i].exports;var r=e[i]={i:i,l:!1,exports:{}};return t[i].call(r.exports,r,r.exports,n),r.l=!0,r.exports}return n.m=t,n.c=e,n.d=function(t,e,i){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:i})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var i=Object.create(null);if(n.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var r in t)n.d(i,r,function(e){return t[e]}.bind(null,r));return i},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=2)}([function(t,e,n){"use strict";var i,r=this&&this.__extends||(i=function(t,e){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)},function(t,e){function n(){this.constructor=t}i(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)});Object.defineProperty(e,"__esModule",{value:!0});var s=function(){function t(t){void 0===t&&(t="="),this._paddingCharacter=t}return t.prototype.encodedLength=function(t){return this._paddingCharacter?(t+2)/3*4|0:(8*t+5)/6|0},t.prototype.encode=function(t){for(var e="",n=0;n>>18&63),e+=this._encodeByte(i>>>12&63),e+=this._encodeByte(i>>>6&63),e+=this._encodeByte(i>>>0&63)}var r=t.length-n;if(r>0){i=t[n]<<16|(2===r?t[n+1]<<8:0);e+=this._encodeByte(i>>>18&63),e+=this._encodeByte(i>>>12&63),e+=2===r?this._encodeByte(i>>>6&63):this._paddingCharacter||"",e+=this._paddingCharacter||""}return e},t.prototype.maxDecodedLength=function(t){return this._paddingCharacter?t/4*3|0:(6*t+7)/8|0},t.prototype.decodedLength=function(t){return this.maxDecodedLength(t.length-this._getPaddingLength(t))},t.prototype.decode=function(t){if(0===t.length)return new Uint8Array(0);for(var e=this._getPaddingLength(t),n=t.length-e,i=new Uint8Array(this.maxDecodedLength(n)),r=0,s=0,o=0,a=0,c=0,h=0,u=0;s>>4,i[r++]=c<<4|h>>>2,i[r++]=h<<6|u,o|=256&a,o|=256&c,o|=256&h,o|=256&u;if(s>>4,o|=256&a,o|=256&c),s>>2,o|=256&h),s>>8&6,e+=51-t>>>8&-75,e+=61-t>>>8&-15,e+=62-t>>>8&3,String.fromCharCode(e)},t.prototype._decodeChar=function(t){var e=256;return e+=(42-t&t-44)>>>8&-256+t-43+62,e+=(46-t&t-48)>>>8&-256+t-47+63,e+=(47-t&t-58)>>>8&-256+t-48+52,e+=(64-t&t-91)>>>8&-256+t-65+0,e+=(96-t&t-123)>>>8&-256+t-97+26},t.prototype._getPaddingLength=function(t){var e=0;if(this._paddingCharacter){for(var n=t.length-1;n>=0&&t[n]===this._paddingCharacter;n--)e++;if(t.length<4||e>2)throw new Error("Base64Coder: incorrect padding")}return e},t}();e.Coder=s;var o=new s;e.encode=function(t){return o.encode(t)},e.decode=function(t){return o.decode(t)};var a=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r(e,t),e.prototype._encodeByte=function(t){var e=t;return e+=65,e+=25-t>>>8&6,e+=51-t>>>8&-75,e+=61-t>>>8&-13,e+=62-t>>>8&49,String.fromCharCode(e)},e.prototype._decodeChar=function(t){var e=256;return e+=(44-t&t-46)>>>8&-256+t-45+62,e+=(94-t&t-96)>>>8&-256+t-95+63,e+=(47-t&t-58)>>>8&-256+t-48+52,e+=(64-t&t-91)>>>8&-256+t-65+0,e+=(96-t&t-123)>>>8&-256+t-97+26},e}(s);e.URLSafeCoder=a;var c=new a;e.encodeURLSafe=function(t){return c.encode(t)},e.decodeURLSafe=function(t){return c.decode(t)},e.encodedLength=function(t){return o.encodedLength(t)},e.maxDecodedLength=function(t){return o.maxDecodedLength(t)},e.decodedLength=function(t){return o.decodedLength(t)}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i="utf8: invalid source encoding";function r(t){for(var e=0,n=0;n=t.length-1)throw new Error("utf8: invalid string");n++,e+=4}}return e}e.encode=function(t){for(var e=new Uint8Array(r(t)),n=0,i=0;i>6,e[n++]=128|63&s):s<55296?(e[n++]=224|s>>12,e[n++]=128|s>>6&63,e[n++]=128|63&s):(i++,s=(1023&s)<<10,s|=1023&t.charCodeAt(i),s+=65536,e[n++]=240|s>>18,e[n++]=128|s>>12&63,e[n++]=128|s>>6&63,e[n++]=128|63&s)}return e},e.encodedLength=r,e.decode=function(t){for(var e=[],n=0;n=t.length)throw new Error(i);if(128!=(192&(o=t[++n])))throw new Error(i);r=(31&r)<<6|63&o,s=128}else if(r<240){if(n>=t.length-1)throw new Error(i);var o=t[++n],a=t[++n];if(128!=(192&o)||128!=(192&a))throw new Error(i);r=(15&r)<<12|(63&o)<<6|63&a,s=2048}else{if(!(r<248))throw new Error(i);if(n>=t.length-2)throw new Error(i);o=t[++n],a=t[++n];var c=t[++n];if(128!=(192&o)||128!=(192&a)||128!=(192&c))throw new Error(i);r=(15&r)<<18|(63&o)<<12|(63&a)<<6|63&c,s=65536}if(r=55296&&r<=57343)throw new Error(i);if(r>=65536){if(r>1114111)throw new Error(i);r-=65536,e.push(String.fromCharCode(55296|r>>10)),r=56320|1023&r}}e.push(String.fromCharCode(r))}return e.join("")}},function(t,e,n){t.exports=n(3).default},function(t,e,n){"use strict";n.r(e);class i{constructor(t,e){this.lastId=0,this.prefix=t,this.name=e}create(t){this.lastId++;var e=this.lastId,n=this.prefix+e,i=this.name+"["+e+"]",r=!1,s=function(){r||(t.apply(null,arguments),r=!0)};return this[e]=s,{number:e,id:n,name:i,callback:s}}remove(t){delete this[t.number]}}var r=new i("_pusher_script_","Pusher.ScriptReceivers"),s={VERSION:"8.4.0",PROTOCOL:7,wsPort:80,wssPort:443,wsPath:"",httpHost:"sockjs.pusher.com",httpPort:80,httpsPort:443,httpPath:"/pusher",stats_host:"stats.pusher.com",authEndpoint:"/pusher/auth",authTransport:"ajax",activityTimeout:12e4,pongTimeout:3e4,unavailableTimeout:1e4,userAuthentication:{endpoint:"/pusher/user-auth",transport:"ajax"},channelAuthorization:{endpoint:"/pusher/auth",transport:"ajax"},cdn_http:"http://js.pusher.com",cdn_https:"https://js.pusher.com",dependency_suffix:""};var o=new i("_pusher_dependencies","Pusher.DependenciesReceivers"),a=new class{constructor(t){this.options=t,this.receivers=t.receivers||r,this.loading={}}load(t,e,n){var i=this;if(i.loading[t]&&i.loading[t].length>0)i.loading[t].push(n);else{i.loading[t]=[n];var r=ue.createScriptRequest(i.getPath(t,e)),s=i.receivers.create((function(e){if(i.receivers.remove(s),i.loading[t]){var n=i.loading[t];delete i.loading[t];for(var o=function(t){t||r.cleanup()},a=0;a>>6)+S(128|63&e):S(224|e>>>12&15)+S(128|e>>>6&63)+S(128|63&e)},E=function(t){return t.replace(/[^\x00-\x7F]/g,P)},O=function(t){var e=[0,2,1][t.length%3],n=t.charCodeAt(0)<<16|(t.length>1?t.charCodeAt(1):0)<<8|(t.length>2?t.charCodeAt(2):0);return[_.charAt(n>>>18),_.charAt(n>>>12&63),e>=2?"=":_.charAt(n>>>6&63),e>=1?"=":_.charAt(63&n)].join("")},x=window.btoa||function(t){return t.replace(/[\s\S]{1,3}/g,O)};var L=class{constructor(t,e,n,i){this.clear=e,this.timer=t(()=>{this.timer&&(this.timer=i(this.timer))},n)}isRunning(){return null!==this.timer}ensureAborted(){this.timer&&(this.clear(this.timer),this.timer=null)}};function A(t){window.clearTimeout(t)}function R(t){window.clearInterval(t)}class I extends L{constructor(t,e){super(setTimeout,A,t,(function(t){return e(),null}))}}class D extends L{constructor(t,e){super(setInterval,R,t,(function(t){return e(),t}))}}var j={now:()=>Date.now?Date.now():(new Date).valueOf(),defer:t=>new I(0,t),method(t,...e){var n=Array.prototype.slice.call(arguments,1);return function(e){return e[t].apply(e,n.concat(arguments))}}};function N(t,...e){for(var n=0;n{window.console&&window.console.log&&window.console.log(t)}}debug(...t){this.log(this.globalLog,t)}warn(...t){this.log(this.globalLogWarn,t)}error(...t){this.log(this.globalLogError,t)}globalLogWarn(t){window.console&&window.console.warn?window.console.warn(t):this.globalLog(t)}globalLogError(t){window.console&&window.console.error?window.console.error(t):this.globalLogWarn(t)}log(t,...e){var n=H.apply(this,arguments);if(Ae.log)Ae.log(n);else if(Ae.logToConsole){t.bind(this)(n)}}},Y=function(t,e,n,i,r){void 0===n.headers&&null==n.headersProvider||V.warn(`To send headers with the ${i.toString()} request, you must use AJAX, rather than JSONP.`);var s=t.nextAuthCallbackID.toString();t.nextAuthCallbackID++;var o=t.getDocument(),a=o.createElement("script");t.auth_callbacks[s]=function(t){r(null,t)};var c="Pusher.auth_callbacks['"+s+"']";a.src=n.endpoint+"?callback="+encodeURIComponent(c)+"&"+e;var h=o.getElementsByTagName("head")[0]||o.documentElement;h.insertBefore(a,h.firstChild)};class K{constructor(t){this.src=t}send(t){var e=this,n="Error loading "+e.src;e.script=document.createElement("script"),e.script.id=t.id,e.script.src=e.src,e.script.type="text/javascript",e.script.charset="UTF-8",e.script.addEventListener?(e.script.onerror=function(){t.callback(n)},e.script.onload=function(){t.callback(null)}):e.script.onreadystatechange=function(){"loaded"!==e.script.readyState&&"complete"!==e.script.readyState||t.callback(null)},void 0===e.script.async&&document.attachEvent&&/opera/i.test(navigator.userAgent)?(e.errorScript=document.createElement("script"),e.errorScript.id=t.id+"_error",e.errorScript.text=t.name+"('"+n+"');",e.script.async=e.errorScript.async=!1):e.script.async=!0;var i=document.getElementsByTagName("head")[0];i.insertBefore(e.script,i.firstChild),e.errorScript&&i.insertBefore(e.errorScript,e.script.nextSibling)}cleanup(){this.script&&(this.script.onload=this.script.onerror=null,this.script.onreadystatechange=null),this.script&&this.script.parentNode&&this.script.parentNode.removeChild(this.script),this.errorScript&&this.errorScript.parentNode&&this.errorScript.parentNode.removeChild(this.errorScript),this.script=null,this.errorScript=null}}class Q{constructor(t,e){this.url=t,this.data=e}send(t){if(!this.request){var e=W(this.data),n=this.url+"/"+t.number+"?"+e;this.request=ue.createScriptRequest(n),this.request.send(t)}}cleanup(){this.request&&this.request.cleanup()}}var Z={name:"jsonp",getAgent:function(t,e){return function(n,i){var s="http"+(e?"s":"")+"://"+(t.host||t.options.host)+t.options.path,o=ue.createJSONPRequest(s,n),a=ue.ScriptReceivers.create((function(e,n){r.remove(a),o.cleanup(),n&&n.host&&(t.host=n.host),i&&i(e,n)}));o.send(a)}}};function tt(t,e,n){return t+(e.useTLS?"s":"")+"://"+(e.useTLS?e.hostTLS:e.hostNonTLS)+n}function et(t,e){return"/app/"+t+("?protocol="+s.PROTOCOL+"&client=js&version="+s.VERSION+(e?"&"+e:""))}var nt={getInitial:function(t,e){return tt("ws",e,(e.httpPath||"")+et(t,"flash=false"))}},it={getInitial:function(t,e){return tt("http",e,(e.httpPath||"/pusher")+et(t))}},rt={getInitial:function(t,e){return tt("http",e,e.httpPath||"/pusher")},getPath:function(t,e){return et(t)}};class st{constructor(){this._callbacks={}}get(t){return this._callbacks[ot(t)]}add(t,e,n){var i=ot(t);this._callbacks[i]=this._callbacks[i]||[],this._callbacks[i].push({fn:e,context:n})}remove(t,e,n){if(t||e||n){var i=t?[ot(t)]:z(this._callbacks);e||n?this.removeCallback(i,e,n):this.removeAllCallbacks(i)}else this._callbacks={}}removeCallback(t,e,n){q(t,(function(t){this._callbacks[t]=F(this._callbacks[t]||[],(function(t){return e&&e!==t.fn||n&&n!==t.context})),0===this._callbacks[t].length&&delete this._callbacks[t]}),this)}removeAllCallbacks(t){q(t,(function(t){delete this._callbacks[t]}),this)}}function ot(t){return"_"+t}class at{constructor(t){this.callbacks=new st,this.global_callbacks=[],this.failThrough=t}bind(t,e,n){return this.callbacks.add(t,e,n),this}bind_global(t){return this.global_callbacks.push(t),this}unbind(t,e,n){return this.callbacks.remove(t,e,n),this}unbind_global(t){return t?(this.global_callbacks=F(this.global_callbacks||[],e=>e!==t),this):(this.global_callbacks=[],this)}unbind_all(){return this.unbind(),this.unbind_global(),this}emit(t,e,n){for(var i=0;i0)for(i=0;i{this.onError(t),this.changeState("closed")}),!1}return this.bindListeners(),V.debug("Connecting",{transport:this.name,url:t}),this.changeState("connecting"),!0}close(){return!!this.socket&&(this.socket.close(),!0)}send(t){return"open"===this.state&&(j.defer(()=>{this.socket&&this.socket.send(t)}),!0)}ping(){"open"===this.state&&this.supportsPing()&&this.socket.ping()}onOpen(){this.hooks.beforeOpen&&this.hooks.beforeOpen(this.socket,this.hooks.urls.getPath(this.key,this.options)),this.changeState("open"),this.socket.onopen=void 0}onError(t){this.emit("error",{type:"WebSocketError",error:t}),this.timeline.error(this.buildTimelineMessage({error:t.toString()}))}onClose(t){t?this.changeState("closed",{code:t.code,reason:t.reason,wasClean:t.wasClean}):this.changeState("closed"),this.unbindListeners(),this.socket=void 0}onMessage(t){this.emit("message",t)}onActivity(){this.emit("activity")}bindListeners(){this.socket.onopen=()=>{this.onOpen()},this.socket.onerror=t=>{this.onError(t)},this.socket.onclose=t=>{this.onClose(t)},this.socket.onmessage=t=>{this.onMessage(t)},this.supportsPing()&&(this.socket.onactivity=()=>{this.onActivity()})}unbindListeners(){this.socket&&(this.socket.onopen=void 0,this.socket.onerror=void 0,this.socket.onclose=void 0,this.socket.onmessage=void 0,this.supportsPing()&&(this.socket.onactivity=void 0))}changeState(t,e){this.state=t,this.timeline.info(this.buildTimelineMessage({state:t,params:e})),this.emit(t,e)}buildTimelineMessage(t){return N({cid:this.id},t)}}class ht{constructor(t){this.hooks=t}isSupported(t){return this.hooks.isSupported(t)}createConnection(t,e,n,i){return new ct(this.hooks,t,e,n,i)}}var ut=new ht({urls:nt,handlesActivityChecks:!1,supportsPing:!1,isInitialized:function(){return Boolean(ue.getWebSocketAPI())},isSupported:function(){return Boolean(ue.getWebSocketAPI())},getSocket:function(t){return ue.createWebSocket(t)}}),lt={urls:it,handlesActivityChecks:!1,supportsPing:!0,isInitialized:function(){return!0}},dt=N({getSocket:function(t){return ue.HTTPFactory.createStreamingSocket(t)}},lt),pt=N({getSocket:function(t){return ue.HTTPFactory.createPollingSocket(t)}},lt),ft={isSupported:function(){return ue.isXHRSupported()}},gt={ws:ut,xhr_streaming:new ht(N({},dt,ft)),xhr_polling:new ht(N({},pt,ft))},vt=new ht({file:"sockjs",urls:rt,handlesActivityChecks:!0,supportsPing:!1,isSupported:function(){return!0},isInitialized:function(){return void 0!==window.SockJS},getSocket:function(t,e){return new window.SockJS(t,null,{js_path:a.getPath("sockjs",{useTLS:e.useTLS}),ignore_null_origin:e.ignoreNullOrigin})},beforeOpen:function(t,e){t.send(JSON.stringify({path:e}))}}),mt={isSupported:function(t){return ue.isXDRSupported(t.useTLS)}},bt=new ht(N({},dt,mt)),yt=new ht(N({},pt,mt));gt.xdr_streaming=bt,gt.xdr_polling=yt,gt.sockjs=vt;var wt=gt;var St=new class extends at{constructor(){super();var t=this;void 0!==window.addEventListener&&(window.addEventListener("online",(function(){t.emit("online")}),!1),window.addEventListener("offline",(function(){t.emit("offline")}),!1))}isOnline(){return void 0===window.navigator.onLine||window.navigator.onLine}};class _t{constructor(t,e,n){this.manager=t,this.transport=e,this.minPingDelay=n.minPingDelay,this.maxPingDelay=n.maxPingDelay,this.pingDelay=void 0}createConnection(t,e,n,i){i=N({},i,{activityTimeout:this.pingDelay});var r=this.transport.createConnection(t,e,n,i),s=null,o=function(){r.unbind("open",o),r.bind("closed",a),s=j.now()},a=t=>{if(r.unbind("closed",a),1002===t.code||1003===t.code)this.manager.reportDeath();else if(!t.wasClean&&s){var e=j.now()-s;e<2*this.maxPingDelay&&(this.manager.reportDeath(),this.pingDelay=Math.max(e/2,this.minPingDelay))}};return r.bind("open",o),r}isSupported(t){return this.manager.isAlive()&&this.transport.isSupported(t)}}const kt={decodeMessage:function(t){try{var e=JSON.parse(t.data),n=e.data;if("string"==typeof n)try{n=JSON.parse(e.data)}catch(t){}var i={event:e.event,channel:e.channel,data:n};return e.user_id&&(i.user_id=e.user_id),i}catch(e){throw{type:"MessageParseError",error:e,data:t.data}}},encodeMessage:function(t){return JSON.stringify(t)},processHandshake:function(t){var e=kt.decodeMessage(t);if("pusher:connection_established"===e.event){if(!e.data.activity_timeout)throw"No activity timeout specified in handshake";return{action:"connected",id:e.data.socket_id,activityTimeout:1e3*e.data.activity_timeout}}if("pusher:error"===e.event)return{action:this.getCloseAction(e.data),error:this.getCloseError(e.data)};throw"Invalid handshake"},getCloseAction:function(t){return t.code<4e3?t.code>=1002&&t.code<=1004?"backoff":null:4e3===t.code?"tls_only":t.code<4100?"refused":t.code<4200?"backoff":t.code<4300?"retry":"refused"},getCloseError:function(t){return 1e3!==t.code&&1001!==t.code?{type:"PusherError",data:{code:t.code,message:t.reason||t.message}}:null}};var Ct=kt;class Tt extends at{constructor(t,e){super(),this.id=t,this.transport=e,this.activityTimeout=e.activityTimeout,this.bindListeners()}handlesActivityChecks(){return this.transport.handlesActivityChecks()}send(t){return this.transport.send(t)}send_event(t,e,n){var i={event:t,data:e};return n&&(i.channel=n),V.debug("Event sent",i),this.send(Ct.encodeMessage(i))}ping(){this.transport.supportsPing()?this.transport.ping():this.send_event("pusher:ping",{})}close(){this.transport.close()}bindListeners(){var t={message:t=>{var e;try{e=Ct.decodeMessage(t)}catch(e){this.emit("error",{type:"MessageParseError",error:e,data:t.data})}if(void 0!==e){switch(V.debug("Event recd",e),e.event){case"pusher:error":this.emit("error",{type:"PusherError",data:e.data});break;case"pusher:ping":this.emit("ping");break;case"pusher:pong":this.emit("pong")}this.emit("message",e)}},activity:()=>{this.emit("activity")},error:t=>{this.emit("error",t)},closed:t=>{e(),t&&t.code&&this.handleCloseEvent(t),this.transport=null,this.emit("closed")}},e=()=>{M(t,(t,e)=>{this.transport.unbind(e,t)})};M(t,(t,e)=>{this.transport.bind(e,t)})}handleCloseEvent(t){var e=Ct.getCloseAction(t),n=Ct.getCloseError(t);n&&this.emit("error",n),e&&this.emit(e,{action:e,error:n})}}class Pt{constructor(t,e){this.transport=t,this.callback=e,this.bindListeners()}close(){this.unbindListeners(),this.transport.close()}bindListeners(){this.onMessage=t=>{var e;this.unbindListeners();try{e=Ct.processHandshake(t)}catch(t){return this.finish("error",{error:t}),void this.transport.close()}"connected"===e.action?this.finish("connected",{connection:new Tt(e.id,this.transport),activityTimeout:e.activityTimeout}):(this.finish(e.action,{error:e.error}),this.transport.close())},this.onClosed=t=>{this.unbindListeners();var e=Ct.getCloseAction(t)||"backoff",n=Ct.getCloseError(t);this.finish(e,{error:n})},this.transport.bind("message",this.onMessage),this.transport.bind("closed",this.onClosed)}unbindListeners(){this.transport.unbind("message",this.onMessage),this.transport.unbind("closed",this.onClosed)}finish(t,e){this.callback(N({transport:this.transport,action:t},e))}}class Et{constructor(t,e){this.timeline=t,this.options=e||{}}send(t,e){this.timeline.isEmpty()||this.timeline.send(ue.TimelineTransport.getAgent(this,t),e)}}class Ot extends at{constructor(t,e){super((function(e,n){V.debug("No callbacks on "+t+" for "+e)})),this.name=t,this.pusher=e,this.subscribed=!1,this.subscriptionPending=!1,this.subscriptionCancelled=!1}authorize(t,e){return e(null,{auth:""})}trigger(t,e){if(0!==t.indexOf("client-"))throw new l("Event '"+t+"' does not start with 'client-'");if(!this.subscribed){var n=u("triggeringClientEvents");V.warn("Client event triggered before channel 'subscription_succeeded' event . "+n)}return this.pusher.send_event(t,e,this.name)}disconnect(){this.subscribed=!1,this.subscriptionPending=!1}handleEvent(t){var e=t.event,n=t.data;if("pusher_internal:subscription_succeeded"===e)this.handleSubscriptionSucceededEvent(t);else if("pusher_internal:subscription_count"===e)this.handleSubscriptionCountEvent(t);else if(0!==e.indexOf("pusher_internal:")){this.emit(e,n,{})}}handleSubscriptionSucceededEvent(t){this.subscriptionPending=!1,this.subscribed=!0,this.subscriptionCancelled?this.pusher.unsubscribe(this.name):this.emit("pusher:subscription_succeeded",t.data)}handleSubscriptionCountEvent(t){t.data.subscription_count&&(this.subscriptionCount=t.data.subscription_count),this.emit("pusher:subscription_count",t.data)}subscribe(){this.subscribed||(this.subscriptionPending=!0,this.subscriptionCancelled=!1,this.authorize(this.pusher.connection.socket_id,(t,e)=>{t?(this.subscriptionPending=!1,V.error(t.toString()),this.emit("pusher:subscription_error",Object.assign({},{type:"AuthError",error:t.message},t instanceof y?{status:t.status}:{}))):this.pusher.send_event("pusher:subscribe",{auth:e.auth,channel_data:e.channel_data,channel:this.name})}))}unsubscribe(){this.subscribed=!1,this.pusher.send_event("pusher:unsubscribe",{channel:this.name})}cancelSubscription(){this.subscriptionCancelled=!0}reinstateSubscription(){this.subscriptionCancelled=!1}}class xt extends Ot{authorize(t,e){return this.pusher.config.channelAuthorizer({channelName:this.name,socketId:t},e)}}class Lt{constructor(){this.reset()}get(t){return Object.prototype.hasOwnProperty.call(this.members,t)?{id:t,info:this.members[t]}:null}each(t){M(this.members,(e,n)=>{t(this.get(n))})}setMyID(t){this.myID=t}onSubscription(t){this.members=t.presence.hash,this.count=t.presence.count,this.me=this.get(this.myID)}addMember(t){return null===this.get(t.user_id)&&this.count++,this.members[t.user_id]=t.user_info,this.get(t.user_id)}removeMember(t){var e=this.get(t.user_id);return e&&(delete this.members[t.user_id],this.count--),e}reset(){this.members={},this.count=0,this.myID=null,this.me=null}}var At=function(t,e,n,i){return new(n||(n=Promise))((function(r,s){function o(t){try{c(i.next(t))}catch(t){s(t)}}function a(t){try{c(i.throw(t))}catch(t){s(t)}}function c(t){var e;t.done?r(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(o,a)}c((i=i.apply(t,e||[])).next())}))};class Rt extends xt{constructor(t,e){super(t,e),this.members=new Lt}authorize(t,e){super.authorize(t,(t,n)=>At(this,void 0,void 0,(function*(){if(!t)if(null!=(n=n).channel_data){var i=JSON.parse(n.channel_data);this.members.setMyID(i.user_id)}else{if(yield this.pusher.user.signinDonePromise,null==this.pusher.user.user_data){let t=u("authorizationEndpoint");return V.error(`Invalid auth response for channel '${this.name}', expected 'channel_data' field. ${t}, or the user should be signed in.`),void e("Invalid auth response")}this.members.setMyID(this.pusher.user.user_data.id)}e(t,n)})))}handleEvent(t){var e=t.event;if(0===e.indexOf("pusher_internal:"))this.handleInternalEvent(t);else{var n=t.data,i={};t.user_id&&(i.user_id=t.user_id),this.emit(e,n,i)}}handleInternalEvent(t){var e=t.event,n=t.data;switch(e){case"pusher_internal:subscription_succeeded":this.handleSubscriptionSucceededEvent(t);break;case"pusher_internal:subscription_count":this.handleSubscriptionCountEvent(t);break;case"pusher_internal:member_added":var i=this.members.addMember(n);this.emit("pusher:member_added",i);break;case"pusher_internal:member_removed":var r=this.members.removeMember(n);r&&this.emit("pusher:member_removed",r)}}handleSubscriptionSucceededEvent(t){this.subscriptionPending=!1,this.subscribed=!0,this.subscriptionCancelled?this.pusher.unsubscribe(this.name):(this.members.onSubscription(t.data),this.emit("pusher:subscription_succeeded",this.members))}disconnect(){this.members.reset(),super.disconnect()}}var It=n(1),Dt=n(0);class jt extends xt{constructor(t,e,n){super(t,e),this.key=null,this.nacl=n}authorize(t,e){super.authorize(t,(t,n)=>{if(t)return void e(t,n);let i=n.shared_secret;i?(this.key=Object(Dt.decode)(i),delete n.shared_secret,e(null,n)):e(new Error("No shared_secret key in auth payload for encrypted channel: "+this.name),null)})}trigger(t,e){throw new v("Client events are not currently supported for encrypted channels")}handleEvent(t){var e=t.event,n=t.data;0!==e.indexOf("pusher_internal:")&&0!==e.indexOf("pusher:")?this.handleEncryptedEvent(e,n):super.handleEvent(t)}handleEncryptedEvent(t,e){if(!this.key)return void V.debug("Received encrypted event before key has been retrieved from the authEndpoint");if(!e.ciphertext||!e.nonce)return void V.error("Unexpected format for encrypted event, expected object with `ciphertext` and `nonce` fields, got: "+e);let n=Object(Dt.decode)(e.ciphertext);if(n.length{e?V.error(`Failed to make a request to the authEndpoint: ${s}. Unable to fetch new key, so dropping encrypted event`):(r=this.nacl.secretbox.open(n,i,this.key),null!==r?this.emit(t,this.getDataToEmit(r)):V.error("Failed to decrypt event with new key. Dropping encrypted event"))});this.emit(t,this.getDataToEmit(r))}getDataToEmit(t){let e=Object(It.decode)(t);try{return JSON.parse(e)}catch(t){return e}}}class Nt extends at{constructor(t,e){super(),this.state="initialized",this.connection=null,this.key=t,this.options=e,this.timeline=this.options.timeline,this.usingTLS=this.options.useTLS,this.errorCallbacks=this.buildErrorCallbacks(),this.connectionCallbacks=this.buildConnectionCallbacks(this.errorCallbacks),this.handshakeCallbacks=this.buildHandshakeCallbacks(this.errorCallbacks);var n=ue.getNetwork();n.bind("online",()=>{this.timeline.info({netinfo:"online"}),"connecting"!==this.state&&"unavailable"!==this.state||this.retryIn(0)}),n.bind("offline",()=>{this.timeline.info({netinfo:"offline"}),this.connection&&this.sendActivityCheck()}),this.updateStrategy()}switchCluster(t){this.key=t,this.updateStrategy(),this.retryIn(0)}connect(){this.connection||this.runner||(this.strategy.isSupported()?(this.updateState("connecting"),this.startConnecting(),this.setUnavailableTimer()):this.updateState("failed"))}send(t){return!!this.connection&&this.connection.send(t)}send_event(t,e,n){return!!this.connection&&this.connection.send_event(t,e,n)}disconnect(){this.disconnectInternally(),this.updateState("disconnected")}isUsingTLS(){return this.usingTLS}startConnecting(){var t=(e,n)=>{e?this.runner=this.strategy.connect(0,t):"error"===n.action?(this.emit("error",{type:"HandshakeError",error:n.error}),this.timeline.error({handshakeError:n.error})):(this.abortConnecting(),this.handshakeCallbacks[n.action](n))};this.runner=this.strategy.connect(0,t)}abortConnecting(){this.runner&&(this.runner.abort(),this.runner=null)}disconnectInternally(){(this.abortConnecting(),this.clearRetryTimer(),this.clearUnavailableTimer(),this.connection)&&this.abandonConnection().close()}updateStrategy(){this.strategy=this.options.getStrategy({key:this.key,timeline:this.timeline,useTLS:this.usingTLS})}retryIn(t){this.timeline.info({action:"retry",delay:t}),t>0&&this.emit("connecting_in",Math.round(t/1e3)),this.retryTimer=new I(t||0,()=>{this.disconnectInternally(),this.connect()})}clearRetryTimer(){this.retryTimer&&(this.retryTimer.ensureAborted(),this.retryTimer=null)}setUnavailableTimer(){this.unavailableTimer=new I(this.options.unavailableTimeout,()=>{this.updateState("unavailable")})}clearUnavailableTimer(){this.unavailableTimer&&this.unavailableTimer.ensureAborted()}sendActivityCheck(){this.stopActivityCheck(),this.connection.ping(),this.activityTimer=new I(this.options.pongTimeout,()=>{this.timeline.error({pong_timed_out:this.options.pongTimeout}),this.retryIn(0)})}resetActivityCheck(){this.stopActivityCheck(),this.connection&&!this.connection.handlesActivityChecks()&&(this.activityTimer=new I(this.activityTimeout,()=>{this.sendActivityCheck()}))}stopActivityCheck(){this.activityTimer&&this.activityTimer.ensureAborted()}buildConnectionCallbacks(t){return N({},t,{message:t=>{this.resetActivityCheck(),this.emit("message",t)},ping:()=>{this.send_event("pusher:pong",{})},activity:()=>{this.resetActivityCheck()},error:t=>{this.emit("error",t)},closed:()=>{this.abandonConnection(),this.shouldRetry()&&this.retryIn(1e3)}})}buildHandshakeCallbacks(t){return N({},t,{connected:t=>{this.activityTimeout=Math.min(this.options.activityTimeout,t.activityTimeout,t.connection.activityTimeout||1/0),this.clearUnavailableTimer(),this.setConnection(t.connection),this.socket_id=this.connection.id,this.updateState("connected",{socket_id:this.socket_id})}})}buildErrorCallbacks(){let t=t=>e=>{e.error&&this.emit("error",{type:"WebSocketError",error:e.error}),t(e)};return{tls_only:t(()=>{this.usingTLS=!0,this.updateStrategy(),this.retryIn(0)}),refused:t(()=>{this.disconnect()}),backoff:t(()=>{this.retryIn(1e3)}),retry:t(()=>{this.retryIn(0)})}}setConnection(t){for(var e in this.connection=t,this.connectionCallbacks)this.connection.bind(e,this.connectionCallbacks[e]);this.resetActivityCheck()}abandonConnection(){if(this.connection){for(var t in this.stopActivityCheck(),this.connectionCallbacks)this.connection.unbind(t,this.connectionCallbacks[t]);var e=this.connection;return this.connection=null,e}}updateState(t,e){var n=this.state;if(this.state=t,n!==t){var i=t;"connected"===i&&(i+=" with new socket ID "+e.socket_id),V.debug("State changed",n+" -> "+i),this.timeline.info({state:t,params:e}),this.emit("state_change",{previous:n,current:t}),this.emit(t,e)}}shouldRetry(){return"connecting"===this.state||"connected"===this.state}}class Ht{constructor(){this.channels={}}add(t,e){return this.channels[t]||(this.channels[t]=function(t,e){if(0===t.indexOf("private-encrypted-")){if(e.config.nacl)return Ut.createEncryptedChannel(t,e,e.config.nacl);let n="Tried to subscribe to a private-encrypted- channel but no nacl implementation available",i=u("encryptedChannelSupport");throw new v(`${n}. ${i}`)}if(0===t.indexOf("private-"))return Ut.createPrivateChannel(t,e);if(0===t.indexOf("presence-"))return Ut.createPresenceChannel(t,e);if(0===t.indexOf("#"))throw new d('Cannot create a channel with name "'+t+'".');return Ut.createChannel(t,e)}(t,e)),this.channels[t]}all(){return function(t){var e=[];return M(t,(function(t){e.push(t)})),e}(this.channels)}find(t){return this.channels[t]}remove(t){var e=this.channels[t];return delete this.channels[t],e}disconnect(){M(this.channels,(function(t){t.disconnect()}))}}var Ut={createChannels:()=>new Ht,createConnectionManager:(t,e)=>new Nt(t,e),createChannel:(t,e)=>new Ot(t,e),createPrivateChannel:(t,e)=>new xt(t,e),createPresenceChannel:(t,e)=>new Rt(t,e),createEncryptedChannel:(t,e,n)=>new jt(t,e,n),createTimelineSender:(t,e)=>new Et(t,e),createHandshake:(t,e)=>new Pt(t,e),createAssistantToTheTransportManager:(t,e,n)=>new _t(t,e,n)};class Mt{constructor(t){this.options=t||{},this.livesLeft=this.options.lives||1/0}getAssistant(t){return Ut.createAssistantToTheTransportManager(this,t,{minPingDelay:this.options.minPingDelay,maxPingDelay:this.options.maxPingDelay})}isAlive(){return this.livesLeft>0}reportDeath(){this.livesLeft-=1}}class zt{constructor(t,e){this.strategies=t,this.loop=Boolean(e.loop),this.failFast=Boolean(e.failFast),this.timeout=e.timeout,this.timeoutLimit=e.timeoutLimit}isSupported(){return J(this.strategies,j.method("isSupported"))}connect(t,e){var n=this.strategies,i=0,r=this.timeout,s=null,o=(a,c)=>{c?e(null,c):(i+=1,this.loop&&(i%=n.length),i0&&(r=new I(n.timeout,(function(){s.abort(),i(!0)}))),s=t.connect(e,(function(t,e){t&&r&&r.isRunning()&&!n.failFast||(r&&r.ensureAborted(),i(t,e))})),{abort:function(){r&&r.ensureAborted(),s.abort()},forceMinPriority:function(t){s.forceMinPriority(t)}}}}class qt{constructor(t){this.strategies=t}isSupported(){return J(this.strategies,j.method("isSupported"))}connect(t,e){return function(t,e,n){var i=B(t,(function(t,i,r,s){return t.connect(e,n(i,s))}));return{abort:function(){q(i,Bt)},forceMinPriority:function(t){q(i,(function(e){e.forceMinPriority(t)}))}}}(this.strategies,t,(function(t,n){return function(i,r){n[t].error=i,i?function(t){return function(t,e){for(var n=0;n=j.now()){var o=this.transports[i.transport];o&&(["ws","wss"].includes(i.transport)||r>3?(this.timeline.info({cached:!0,transport:i.transport,latency:i.latency}),s.push(new zt([o],{timeout:2*i.latency+1e3,failFast:!0}))):r++)}var a=j.now(),c=s.pop().connect(t,(function i(o,h){o?(Jt(n),s.length>0?(a=j.now(),c=s.pop().connect(t,i)):e(o)):(!function(t,e,n,i){var r=ue.getLocalStorage();if(r)try{r[Xt(t)]=G({timestamp:j.now(),transport:e,latency:n,cacheSkipCount:i})}catch(t){}}(n,h.transport.name,j.now()-a,r),e(null,h))}));return{abort:function(){c.abort()},forceMinPriority:function(e){t=e,c&&c.forceMinPriority(e)}}}}function Xt(t){return"pusherTransport"+(t?"TLS":"NonTLS")}function Jt(t){var e=ue.getLocalStorage();if(e)try{delete e[Xt(t)]}catch(t){}}class $t{constructor(t,{delay:e}){this.strategy=t,this.options={delay:e}}isSupported(){return this.strategy.isSupported()}connect(t,e){var n,i=this.strategy,r=new I(this.options.delay,(function(){n=i.connect(t,e)}));return{abort:function(){r.ensureAborted(),n&&n.abort()},forceMinPriority:function(e){t=e,n&&n.forceMinPriority(e)}}}}class Wt{constructor(t,e,n){this.test=t,this.trueBranch=e,this.falseBranch=n}isSupported(){return(this.test()?this.trueBranch:this.falseBranch).isSupported()}connect(t,e){return(this.test()?this.trueBranch:this.falseBranch).connect(t,e)}}class Gt{constructor(t){this.strategy=t}isSupported(){return this.strategy.isSupported()}connect(t,e){var n=this.strategy.connect(t,(function(t,i){i&&n.abort(),e(t,i)}));return n}}function Vt(t){return function(){return t.isSupported()}}var Yt=function(t,e,n){var i={};function r(e,r,s,o,a){var c=n(t,e,r,s,o,a);return i[e]=c,c}var s,o=Object.assign({},e,{hostNonTLS:t.wsHost+":"+t.wsPort,hostTLS:t.wsHost+":"+t.wssPort,httpPath:t.wsPath}),a=Object.assign({},o,{useTLS:!0}),c=Object.assign({},e,{hostNonTLS:t.httpHost+":"+t.httpPort,hostTLS:t.httpHost+":"+t.httpsPort,httpPath:t.httpPath}),h={loop:!0,timeout:15e3,timeoutLimit:6e4},u=new Mt({minPingDelay:1e4,maxPingDelay:t.activityTimeout}),l=new Mt({lives:2,minPingDelay:1e4,maxPingDelay:t.activityTimeout}),d=r("ws","ws",3,o,u),p=r("wss","ws",3,a,u),f=r("sockjs","sockjs",1,c),g=r("xhr_streaming","xhr_streaming",1,c,l),v=r("xdr_streaming","xdr_streaming",1,c,l),m=r("xhr_polling","xhr_polling",1,c),b=r("xdr_polling","xdr_polling",1,c),y=new zt([d],h),w=new zt([p],h),S=new zt([f],h),_=new zt([new Wt(Vt(g),g,v)],h),k=new zt([new Wt(Vt(m),m,b)],h),C=new zt([new Wt(Vt(_),new qt([_,new $t(k,{delay:4e3})]),k)],h),T=new Wt(Vt(C),C,S);return s=e.useTLS?new qt([y,new $t(T,{delay:2e3})]):new qt([y,new $t(w,{delay:2e3}),new $t(T,{delay:5e3})]),new Ft(new Gt(new Wt(Vt(d),s,T)),i,{ttl:18e5,timeline:e.timeline,useTLS:e.useTLS})},Kt={getRequest:function(t){var e=new window.XDomainRequest;return e.ontimeout=function(){t.emit("error",new p),t.close()},e.onerror=function(e){t.emit("error",e),t.close()},e.onprogress=function(){e.responseText&&e.responseText.length>0&&t.onChunk(200,e.responseText)},e.onload=function(){e.responseText&&e.responseText.length>0&&t.onChunk(200,e.responseText),t.emit("finished",200),t.close()},e},abortRequest:function(t){t.ontimeout=t.onerror=t.onprogress=t.onload=null,t.abort()}};class Qt extends at{constructor(t,e,n){super(),this.hooks=t,this.method=e,this.url=n}start(t){this.position=0,this.xhr=this.hooks.getRequest(this),this.unloader=()=>{this.close()},ue.addUnloadListener(this.unloader),this.xhr.open(this.method,this.url,!0),this.xhr.setRequestHeader&&this.xhr.setRequestHeader("Content-Type","application/json"),this.xhr.send(t)}close(){this.unloader&&(ue.removeUnloadListener(this.unloader),this.unloader=null),this.xhr&&(this.hooks.abortRequest(this.xhr),this.xhr=null)}onChunk(t,e){for(;;){var n=this.advanceBuffer(e);if(!n)break;this.emit("chunk",{status:t,data:n})}this.isBufferTooLong(e)&&this.emit("buffer_too_long")}advanceBuffer(t){var e=t.slice(this.position),n=e.indexOf("\n");return-1!==n?(this.position+=n+1,e.slice(0,n)):null}isBufferTooLong(t){return this.position===t.length&&t.length>262144}}var Zt;!function(t){t[t.CONNECTING=0]="CONNECTING",t[t.OPEN=1]="OPEN",t[t.CLOSED=3]="CLOSED"}(Zt||(Zt={}));var te=Zt,ee=1;function ne(t){var e=-1===t.indexOf("?")?"?":"&";return t+e+"t="+ +new Date+"&n="+ee++}function ie(t){return ue.randomInt(t)}var re,se=class{constructor(t,e){this.hooks=t,this.session=ie(1e3)+"/"+function(t){for(var e=[],n=0;n{this.onChunk(t)}),this.stream.bind("finished",t=>{this.hooks.onFinished(this,t)}),this.stream.bind("buffer_too_long",()=>{this.reconnect()});try{this.stream.start()}catch(t){j.defer(()=>{this.onError(t),this.onClose(1006,"Could not start streaming",!1)})}}closeStream(){this.stream&&(this.stream.unbind_all(),this.stream.close(),this.stream=null)}},oe={getReceiveURL:function(t,e){return t.base+"/"+e+"/xhr_streaming"+t.queryString},onHeartbeat:function(t){t.sendRaw("[]")},sendHeartbeat:function(t){t.sendRaw("[]")},onFinished:function(t,e){t.onClose(1006,"Connection interrupted ("+e+")",!1)}},ae={getReceiveURL:function(t,e){return t.base+"/"+e+"/xhr"+t.queryString},onHeartbeat:function(){},sendHeartbeat:function(t){t.sendRaw("[]")},onFinished:function(t,e){200===e?t.reconnect():t.onClose(1006,"Connection interrupted ("+e+")",!1)}},ce={getRequest:function(t){var e=new(ue.getXHRAPI());return e.onreadystatechange=e.onprogress=function(){switch(e.readyState){case 3:e.responseText&&e.responseText.length>0&&t.onChunk(e.status,e.responseText);break;case 4:e.responseText&&e.responseText.length>0&&t.onChunk(e.status,e.responseText),t.emit("finished",e.status),t.close()}},e},abortRequest:function(t){t.onreadystatechange=null,t.abort()}},he={createStreamingSocket(t){return this.createSocket(oe,t)},createPollingSocket(t){return this.createSocket(ae,t)},createSocket:(t,e)=>new se(t,e),createXHR(t,e){return this.createRequest(ce,t,e)},createRequest:(t,e,n)=>new Qt(t,e,n),createXDR:function(t,e){return this.createRequest(Kt,t,e)}},ue={nextAuthCallbackID:1,auth_callbacks:{},ScriptReceivers:r,DependenciesReceivers:o,getDefaultStrategy:Yt,Transports:wt,transportConnectionInitializer:function(){var t=this;t.timeline.info(t.buildTimelineMessage({transport:t.name+(t.options.useTLS?"s":"")})),t.hooks.isInitialized()?t.changeState("initialized"):t.hooks.file?(t.changeState("initializing"),a.load(t.hooks.file,{useTLS:t.options.useTLS},(function(e,n){t.hooks.isInitialized()?(t.changeState("initialized"),n(!0)):(e&&t.onError(e),t.onClose(),n(!1))}))):t.onClose()},HTTPFactory:he,TimelineTransport:Z,getXHRAPI:()=>window.XMLHttpRequest,getWebSocketAPI:()=>window.WebSocket||window.MozWebSocket,setup(t){window.Pusher=t;var e=()=>{this.onDocumentBody(t.ready)};window.JSON?e():a.load("json2",{},e)},getDocument:()=>document,getProtocol(){return this.getDocument().location.protocol},getAuthorizers:()=>({ajax:w,jsonp:Y}),onDocumentBody(t){document.body?t():setTimeout(()=>{this.onDocumentBody(t)},0)},createJSONPRequest:(t,e)=>new Q(t,e),createScriptRequest:t=>new K(t),getLocalStorage(){try{return window.localStorage}catch(t){return}},createXHR(){return this.getXHRAPI()?this.createXMLHttpRequest():this.createMicrosoftXHR()},createXMLHttpRequest(){return new(this.getXHRAPI())},createMicrosoftXHR:()=>new ActiveXObject("Microsoft.XMLHTTP"),getNetwork:()=>St,createWebSocket(t){return new(this.getWebSocketAPI())(t)},createSocketRequest(t,e){if(this.isXHRSupported())return this.HTTPFactory.createXHR(t,e);if(this.isXDRSupported(0===e.indexOf("https:")))return this.HTTPFactory.createXDR(t,e);throw"Cross-origin HTTP requests are not supported"},isXHRSupported(){var t=this.getXHRAPI();return Boolean(t)&&void 0!==(new t).withCredentials},isXDRSupported(t){var e=t?"https:":"http:",n=this.getProtocol();return Boolean(window.XDomainRequest)&&n===e},addUnloadListener(t){void 0!==window.addEventListener?window.addEventListener("unload",t,!1):void 0!==window.attachEvent&&window.attachEvent("onunload",t)},removeUnloadListener(t){void 0!==window.addEventListener?window.removeEventListener("unload",t,!1):void 0!==window.detachEvent&&window.detachEvent("onunload",t)},randomInt:t=>Math.floor((window.crypto||window.msCrypto).getRandomValues(new Uint32Array(1))[0]/Math.pow(2,32)*t)};!function(t){t[t.ERROR=3]="ERROR",t[t.INFO=6]="INFO",t[t.DEBUG=7]="DEBUG"}(re||(re={}));var le=re;class de{constructor(t,e,n){this.key=t,this.session=e,this.events=[],this.options=n||{},this.sent=0,this.uniqueID=0}log(t,e){t<=this.options.level&&(this.events.push(N({},e,{timestamp:j.now()})),this.options.limit&&this.events.length>this.options.limit&&this.events.shift())}error(t){this.log(le.ERROR,t)}info(t){this.log(le.INFO,t)}debug(t){this.log(le.DEBUG,t)}isEmpty(){return 0===this.events.length}send(t,e){var n=N({session:this.session,bundle:this.sent+1,key:this.key,lib:"js",version:this.options.version,cluster:this.options.cluster,features:this.options.features,timeline:this.events},this.options.params);return this.events=[],t(n,(t,n)=>{t||this.sent++,e&&e(t,n)}),!0}generateUniqueID(){return this.uniqueID++,this.uniqueID}}class pe{constructor(t,e,n,i){this.name=t,this.priority=e,this.transport=n,this.options=i||{}}isSupported(){return this.transport.isSupported({useTLS:this.options.useTLS})}connect(t,e){if(!this.isSupported())return fe(new b,e);if(this.priority{n||(h(),r?r.close():i.close())},forceMinPriority:t=>{n||this.priority{if(void 0===ue.getAuthorizers()[t.transport])throw`'${t.transport}' is not a recognized auth transport`;return(e,n)=>{const i=((t,e)=>{var n="socket_id="+encodeURIComponent(t.socketId);for(var i in e.params)n+="&"+encodeURIComponent(i)+"="+encodeURIComponent(e.params[i]);if(null!=e.paramsProvider){let t=e.paramsProvider();for(var i in t)n+="&"+encodeURIComponent(i)+"="+encodeURIComponent(t[i])}return n})(e,t);ue.getAuthorizers()[t.transport](ue,i,t,h.UserAuthentication,n)}};var ye=t=>{if(void 0===ue.getAuthorizers()[t.transport])throw`'${t.transport}' is not a recognized auth transport`;return(e,n)=>{const i=((t,e)=>{var n="socket_id="+encodeURIComponent(t.socketId);for(var i in n+="&channel_name="+encodeURIComponent(t.channelName),e.params)n+="&"+encodeURIComponent(i)+"="+encodeURIComponent(e.params[i]);if(null!=e.paramsProvider){let t=e.paramsProvider();for(var i in t)n+="&"+encodeURIComponent(i)+"="+encodeURIComponent(t[i])}return n})(e,t);ue.getAuthorizers()[t.transport](ue,i,t,h.ChannelAuthorization,n)}};function we(t,e){let n={activityTimeout:t.activityTimeout||s.activityTimeout,cluster:t.cluster,httpPath:t.httpPath||s.httpPath,httpPort:t.httpPort||s.httpPort,httpsPort:t.httpsPort||s.httpsPort,pongTimeout:t.pongTimeout||s.pongTimeout,statsHost:t.statsHost||s.stats_host,unavailableTimeout:t.unavailableTimeout||s.unavailableTimeout,wsPath:t.wsPath||s.wsPath,wsPort:t.wsPort||s.wsPort,wssPort:t.wssPort||s.wssPort,enableStats:Ce(t),httpHost:Se(t),useTLS:ke(t),wsHost:_e(t),userAuthenticator:Te(t),channelAuthorizer:Pe(t,e)};return"disabledTransports"in t&&(n.disabledTransports=t.disabledTransports),"enabledTransports"in t&&(n.enabledTransports=t.enabledTransports),"ignoreNullOrigin"in t&&(n.ignoreNullOrigin=t.ignoreNullOrigin),"timelineParams"in t&&(n.timelineParams=t.timelineParams),"nacl"in t&&(n.nacl=t.nacl),n}function Se(t){return t.httpHost?t.httpHost:t.cluster?`sockjs-${t.cluster}.pusher.com`:s.httpHost}function _e(t){return t.wsHost?t.wsHost:`ws-${t.cluster}.pusher.com`}function ke(t){return"https:"===ue.getProtocol()||!1!==t.forceTLS}function Ce(t){return"enableStats"in t?t.enableStats:"disableStats"in t&&!t.disableStats}function Te(t){const e=Object.assign(Object.assign({},s.userAuthentication),t.userAuthentication);return"customHandler"in e&&null!=e.customHandler?e.customHandler:be(e)}function Pe(t,e){const n=function(t,e){let n;return"channelAuthorization"in t?n=Object.assign(Object.assign({},s.channelAuthorization),t.channelAuthorization):(n={transport:t.authTransport||s.authTransport,endpoint:t.authEndpoint||s.authEndpoint},"auth"in t&&("params"in t.auth&&(n.params=t.auth.params),"headers"in t.auth&&(n.headers=t.auth.headers)),"authorizer"in t&&(n.customHandler=((t,e,n)=>{const i={authTransport:e.transport,authEndpoint:e.endpoint,auth:{params:e.params,headers:e.headers}};return(e,r)=>{const s=t.channel(e.channelName);n(s,i).authorize(e.socketId,r)}})(e,n,t.authorizer))),n}(t,e);return"customHandler"in n&&null!=n.customHandler?n.customHandler:ye(n)}class Ee extends at{constructor(t){super((function(t,e){V.debug("No callbacks on watchlist events for "+t)})),this.pusher=t,this.bindWatchlistInternalEvent()}handleEvent(t){t.data.events.forEach(t=>{this.emit(t.name,t)})}bindWatchlistInternalEvent(){this.pusher.connection.bind("message",t=>{"pusher_internal:watchlist_events"===t.event&&this.handleEvent(t)})}}var Oe=function(){let t,e;return{promise:new Promise((n,i)=>{t=n,e=i}),resolve:t,reject:e}};class xe extends at{constructor(t){super((function(t,e){V.debug("No callbacks on user for "+t)})),this.signin_requested=!1,this.user_data=null,this.serverToUserChannel=null,this.signinDonePromise=null,this._signinDoneResolve=null,this._onAuthorize=(t,e)=>{if(t)return V.warn("Error during signin: "+t),void this._cleanup();this.pusher.send_event("pusher:signin",{auth:e.auth,user_data:e.user_data})},this.pusher=t,this.pusher.connection.bind("state_change",({previous:t,current:e})=>{"connected"!==t&&"connected"===e&&this._signin(),"connected"===t&&"connected"!==e&&(this._cleanup(),this._newSigninPromiseIfNeeded())}),this.watchlist=new Ee(t),this.pusher.connection.bind("message",t=>{"pusher:signin_success"===t.event&&this._onSigninSuccess(t.data),this.serverToUserChannel&&this.serverToUserChannel.name===t.channel&&this.serverToUserChannel.handleEvent(t)})}signin(){this.signin_requested||(this.signin_requested=!0,this._signin())}_signin(){this.signin_requested&&(this._newSigninPromiseIfNeeded(),"connected"===this.pusher.connection.state&&this.pusher.config.userAuthenticator({socketId:this.pusher.connection.socket_id},this._onAuthorize))}_onSigninSuccess(t){try{this.user_data=JSON.parse(t.user_data)}catch(e){return V.error("Failed parsing user data after signin: "+t.user_data),void this._cleanup()}if("string"!=typeof this.user_data.id||""===this.user_data.id)return V.error("user_data doesn't contain an id. user_data: "+this.user_data),void this._cleanup();this._signinDoneResolve(),this._subscribeChannels()}_subscribeChannels(){this.serverToUserChannel=new Ot("#server-to-user-"+this.user_data.id,this.pusher),this.serverToUserChannel.bind_global((t,e)=>{0!==t.indexOf("pusher_internal:")&&0!==t.indexOf("pusher:")&&this.emit(t,e)}),(t=>{t.subscriptionPending&&t.subscriptionCancelled?t.reinstateSubscription():t.subscriptionPending||"connected"!==this.pusher.connection.state||t.subscribe()})(this.serverToUserChannel)}_cleanup(){this.user_data=null,this.serverToUserChannel&&(this.serverToUserChannel.unbind_all(),this.serverToUserChannel.disconnect(),this.serverToUserChannel=null),this.signin_requested&&this._signinDoneResolve()}_newSigninPromiseIfNeeded(){if(!this.signin_requested)return;if(this.signinDonePromise&&!this.signinDonePromise.done)return;const{promise:t,resolve:e,reject:n}=Oe();t.done=!1;const i=()=>{t.done=!0};t.then(i).catch(i),this.signinDonePromise=t,this._signinDoneResolve=e}}class Le{static ready(){Le.isReady=!0;for(var t=0,e=Le.instances.length;tue.getDefaultStrategy(this.config,t,ve),timeline:this.timeline,activityTimeout:this.config.activityTimeout,pongTimeout:this.config.pongTimeout,unavailableTimeout:this.config.unavailableTimeout,useTLS:Boolean(this.config.useTLS)}),this.connection.bind("connected",()=>{this.subscribeAll(),this.timelineSender&&this.timelineSender.send(this.connection.isUsingTLS())}),this.connection.bind("message",t=>{var e=0===t.event.indexOf("pusher_internal:");if(t.channel){var n=this.channel(t.channel);n&&n.handleEvent(t)}e||this.global_emitter.emit(t.event,t.data)}),this.connection.bind("connecting",()=>{this.channels.disconnect()}),this.connection.bind("disconnected",()=>{this.channels.disconnect()}),this.connection.bind("error",t=>{V.warn(t)}),Le.instances.push(this),this.timeline.info({instances:Le.instances.length}),this.user=new xe(this),Le.isReady&&this.connect()}switchCluster(t){const{appKey:e,cluster:n}=t;this.key=e,this.options=Object.assign(Object.assign({},this.options),{cluster:n}),this.config=we(this.options,this),this.connection.switchCluster(this.key)}channel(t){return this.channels.find(t)}allChannels(){return this.channels.all()}connect(){if(this.connection.connect(),this.timelineSender&&!this.timelineSenderTimer){var t=this.connection.isUsingTLS(),e=this.timelineSender;this.timelineSenderTimer=new D(6e4,(function(){e.send(t)}))}}disconnect(){this.connection.disconnect(),this.timelineSenderTimer&&(this.timelineSenderTimer.ensureAborted(),this.timelineSenderTimer=null)}bind(t,e,n){return this.global_emitter.bind(t,e,n),this}unbind(t,e,n){return this.global_emitter.unbind(t,e,n),this}bind_global(t){return this.global_emitter.bind_global(t),this}unbind_global(t){return this.global_emitter.unbind_global(t),this}unbind_all(t){return this.global_emitter.unbind_all(),this}subscribeAll(){var t;for(t in this.channels.channels)this.channels.channels.hasOwnProperty(t)&&this.subscribe(t)}subscribe(t){var e=this.channels.add(t,this);return e.subscriptionPending&&e.subscriptionCancelled?e.reinstateSubscription():e.subscriptionPending||"connected"!==this.connection.state||e.subscribe(),e}unsubscribe(t){var e=this.channels.find(t);e&&e.subscriptionPending?e.cancelSubscription():(e=this.channels.remove(t))&&e.subscribed&&e.unsubscribe()}send_event(t,e,n){return this.connection.send_event(t,e,n)}shouldUseTLS(){return this.config.useTLS}signin(){this.user.signin()}}Le.instances=[],Le.isReady=!1,Le.logToConsole=!1,Le.Runtime=ue,Le.ScriptReceivers=ue.ScriptReceivers,Le.DependenciesReceivers=ue.DependenciesReceivers,Le.auth_callbacks=ue.auth_callbacks;var Ae=e.default=Le;ue.setup(Le)}])})); +!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.Pusher=e():t.Pusher=e()}(window,(function(){return function(t){var e={};function n(i){if(e[i])return e[i].exports;var r=e[i]={i:i,l:!1,exports:{}};return t[i].call(r.exports,r,r.exports,n),r.l=!0,r.exports}return n.m=t,n.c=e,n.d=function(t,e,i){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:i})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var i=Object.create(null);if(n.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var r in t)n.d(i,r,function(e){return t[e]}.bind(null,r));return i},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=2)}([function(t,e,n){"use strict";var i,r=this&&this.__extends||(i=function(t,e){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)},function(t,e){function n(){this.constructor=t}i(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)});Object.defineProperty(e,"__esModule",{value:!0});var s=function(){function t(t){void 0===t&&(t="="),this._paddingCharacter=t}return t.prototype.encodedLength=function(t){return this._paddingCharacter?(t+2)/3*4|0:(8*t+5)/6|0},t.prototype.encode=function(t){for(var e="",n=0;n>>18&63),e+=this._encodeByte(i>>>12&63),e+=this._encodeByte(i>>>6&63),e+=this._encodeByte(i>>>0&63)}var r=t.length-n;if(r>0){i=t[n]<<16|(2===r?t[n+1]<<8:0);e+=this._encodeByte(i>>>18&63),e+=this._encodeByte(i>>>12&63),e+=2===r?this._encodeByte(i>>>6&63):this._paddingCharacter||"",e+=this._paddingCharacter||""}return e},t.prototype.maxDecodedLength=function(t){return this._paddingCharacter?t/4*3|0:(6*t+7)/8|0},t.prototype.decodedLength=function(t){return this.maxDecodedLength(t.length-this._getPaddingLength(t))},t.prototype.decode=function(t){if(0===t.length)return new Uint8Array(0);for(var e=this._getPaddingLength(t),n=t.length-e,i=new Uint8Array(this.maxDecodedLength(n)),r=0,s=0,o=0,a=0,c=0,h=0,u=0;s>>4,i[r++]=c<<4|h>>>2,i[r++]=h<<6|u,o|=256&a,o|=256&c,o|=256&h,o|=256&u;if(s>>4,o|=256&a,o|=256&c),s>>2,o|=256&h),s>>8&6,e+=51-t>>>8&-75,e+=61-t>>>8&-15,e+=62-t>>>8&3,String.fromCharCode(e)},t.prototype._decodeChar=function(t){var e=256;return e+=(42-t&t-44)>>>8&-256+t-43+62,e+=(46-t&t-48)>>>8&-256+t-47+63,e+=(47-t&t-58)>>>8&-256+t-48+52,e+=(64-t&t-91)>>>8&-256+t-65+0,e+=(96-t&t-123)>>>8&-256+t-97+26},t.prototype._getPaddingLength=function(t){var e=0;if(this._paddingCharacter){for(var n=t.length-1;n>=0&&t[n]===this._paddingCharacter;n--)e++;if(t.length<4||e>2)throw new Error("Base64Coder: incorrect padding")}return e},t}();e.Coder=s;var o=new s;e.encode=function(t){return o.encode(t)},e.decode=function(t){return o.decode(t)};var a=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r(e,t),e.prototype._encodeByte=function(t){var e=t;return e+=65,e+=25-t>>>8&6,e+=51-t>>>8&-75,e+=61-t>>>8&-13,e+=62-t>>>8&49,String.fromCharCode(e)},e.prototype._decodeChar=function(t){var e=256;return e+=(44-t&t-46)>>>8&-256+t-45+62,e+=(94-t&t-96)>>>8&-256+t-95+63,e+=(47-t&t-58)>>>8&-256+t-48+52,e+=(64-t&t-91)>>>8&-256+t-65+0,e+=(96-t&t-123)>>>8&-256+t-97+26},e}(s);e.URLSafeCoder=a;var c=new a;e.encodeURLSafe=function(t){return c.encode(t)},e.decodeURLSafe=function(t){return c.decode(t)},e.encodedLength=function(t){return o.encodedLength(t)},e.maxDecodedLength=function(t){return o.maxDecodedLength(t)},e.decodedLength=function(t){return o.decodedLength(t)}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i="utf8: invalid source encoding";function r(t){for(var e=0,n=0;n=t.length-1)throw new Error("utf8: invalid string");n++,e+=4}}return e}e.encode=function(t){for(var e=new Uint8Array(r(t)),n=0,i=0;i>6,e[n++]=128|63&s):s<55296?(e[n++]=224|s>>12,e[n++]=128|s>>6&63,e[n++]=128|63&s):(i++,s=(1023&s)<<10,s|=1023&t.charCodeAt(i),s+=65536,e[n++]=240|s>>18,e[n++]=128|s>>12&63,e[n++]=128|s>>6&63,e[n++]=128|63&s)}return e},e.encodedLength=r,e.decode=function(t){for(var e=[],n=0;n=t.length)throw new Error(i);if(128!=(192&(o=t[++n])))throw new Error(i);r=(31&r)<<6|63&o,s=128}else if(r<240){if(n>=t.length-1)throw new Error(i);var o=t[++n],a=t[++n];if(128!=(192&o)||128!=(192&a))throw new Error(i);r=(15&r)<<12|(63&o)<<6|63&a,s=2048}else{if(!(r<248))throw new Error(i);if(n>=t.length-2)throw new Error(i);o=t[++n],a=t[++n];var c=t[++n];if(128!=(192&o)||128!=(192&a)||128!=(192&c))throw new Error(i);r=(15&r)<<18|(63&o)<<12|(63&a)<<6|63&c,s=65536}if(r=55296&&r<=57343)throw new Error(i);if(r>=65536){if(r>1114111)throw new Error(i);r-=65536,e.push(String.fromCharCode(55296|r>>10)),r=56320|1023&r}}e.push(String.fromCharCode(r))}return e.join("")}},function(t,e,n){t.exports=n(3).default},function(t,e,n){"use strict";n.r(e);class i{constructor(t,e){this.lastId=0,this.prefix=t,this.name=e}create(t){this.lastId++;var e=this.lastId,n=this.prefix+e,i=this.name+"["+e+"]",r=!1,s=function(){r||(t.apply(null,arguments),r=!0)};return this[e]=s,{number:e,id:n,name:i,callback:s}}remove(t){delete this[t.number]}}var r=new i("_pusher_script_","Pusher.ScriptReceivers"),s={VERSION:"8.4.0-rc1",PROTOCOL:7,wsPort:80,wssPort:443,wsPath:"",httpHost:"sockjs.pusher.com",httpPort:80,httpsPort:443,httpPath:"/pusher",stats_host:"stats.pusher.com",authEndpoint:"/pusher/auth",authTransport:"ajax",activityTimeout:12e4,pongTimeout:3e4,unavailableTimeout:1e4,userAuthentication:{endpoint:"/pusher/user-auth",transport:"ajax"},channelAuthorization:{endpoint:"/pusher/auth",transport:"ajax"},cdn_http:"http://js.pusher.com",cdn_https:"https://js.pusher.com",dependency_suffix:""};var o=new i("_pusher_dependencies","Pusher.DependenciesReceivers"),a=new class{constructor(t){this.options=t,this.receivers=t.receivers||r,this.loading={}}load(t,e,n){var i=this;if(i.loading[t]&&i.loading[t].length>0)i.loading[t].push(n);else{i.loading[t]=[n];var r=ue.createScriptRequest(i.getPath(t,e)),s=i.receivers.create((function(e){if(i.receivers.remove(s),i.loading[t]){var n=i.loading[t];delete i.loading[t];for(var o=function(t){t||r.cleanup()},a=0;a>>6)+S(128|63&e):S(224|e>>>12&15)+S(128|e>>>6&63)+S(128|63&e)},E=function(t){return t.replace(/[^\x00-\x7F]/g,P)},O=function(t){var e=[0,2,1][t.length%3],n=t.charCodeAt(0)<<16|(t.length>1?t.charCodeAt(1):0)<<8|(t.length>2?t.charCodeAt(2):0);return[_.charAt(n>>>18),_.charAt(n>>>12&63),e>=2?"=":_.charAt(n>>>6&63),e>=1?"=":_.charAt(63&n)].join("")},x=window.btoa||function(t){return t.replace(/[\s\S]{1,3}/g,O)};var L=class{constructor(t,e,n,i){this.clear=e,this.timer=t(()=>{this.timer&&(this.timer=i(this.timer))},n)}isRunning(){return null!==this.timer}ensureAborted(){this.timer&&(this.clear(this.timer),this.timer=null)}};function A(t){window.clearTimeout(t)}function R(t){window.clearInterval(t)}class I extends L{constructor(t,e){super(setTimeout,A,t,(function(t){return e(),null}))}}class D extends L{constructor(t,e){super(setInterval,R,t,(function(t){return e(),t}))}}var j={now:()=>Date.now?Date.now():(new Date).valueOf(),defer:t=>new I(0,t),method(t,...e){var n=Array.prototype.slice.call(arguments,1);return function(e){return e[t].apply(e,n.concat(arguments))}}};function N(t,...e){for(var n=0;n{window.console&&window.console.log&&window.console.log(t)}}debug(...t){this.log(this.globalLog,t)}warn(...t){this.log(this.globalLogWarn,t)}error(...t){this.log(this.globalLogError,t)}globalLogWarn(t){window.console&&window.console.warn?window.console.warn(t):this.globalLog(t)}globalLogError(t){window.console&&window.console.error?window.console.error(t):this.globalLogWarn(t)}log(t,...e){var n=H.apply(this,arguments);if(Ae.log)Ae.log(n);else if(Ae.logToConsole){t.bind(this)(n)}}},Y=function(t,e,n,i,r){void 0===n.headers&&null==n.headersProvider||V.warn(`To send headers with the ${i.toString()} request, you must use AJAX, rather than JSONP.`);var s=t.nextAuthCallbackID.toString();t.nextAuthCallbackID++;var o=t.getDocument(),a=o.createElement("script");t.auth_callbacks[s]=function(t){r(null,t)};var c="Pusher.auth_callbacks['"+s+"']";a.src=n.endpoint+"?callback="+encodeURIComponent(c)+"&"+e;var h=o.getElementsByTagName("head")[0]||o.documentElement;h.insertBefore(a,h.firstChild)};class K{constructor(t){this.src=t}send(t){var e=this,n="Error loading "+e.src;e.script=document.createElement("script"),e.script.id=t.id,e.script.src=e.src,e.script.type="text/javascript",e.script.charset="UTF-8",e.script.addEventListener?(e.script.onerror=function(){t.callback(n)},e.script.onload=function(){t.callback(null)}):e.script.onreadystatechange=function(){"loaded"!==e.script.readyState&&"complete"!==e.script.readyState||t.callback(null)},void 0===e.script.async&&document.attachEvent&&/opera/i.test(navigator.userAgent)?(e.errorScript=document.createElement("script"),e.errorScript.id=t.id+"_error",e.errorScript.text=t.name+"('"+n+"');",e.script.async=e.errorScript.async=!1):e.script.async=!0;var i=document.getElementsByTagName("head")[0];i.insertBefore(e.script,i.firstChild),e.errorScript&&i.insertBefore(e.errorScript,e.script.nextSibling)}cleanup(){this.script&&(this.script.onload=this.script.onerror=null,this.script.onreadystatechange=null),this.script&&this.script.parentNode&&this.script.parentNode.removeChild(this.script),this.errorScript&&this.errorScript.parentNode&&this.errorScript.parentNode.removeChild(this.errorScript),this.script=null,this.errorScript=null}}class Q{constructor(t,e){this.url=t,this.data=e}send(t){if(!this.request){var e=W(this.data),n=this.url+"/"+t.number+"?"+e;this.request=ue.createScriptRequest(n),this.request.send(t)}}cleanup(){this.request&&this.request.cleanup()}}var Z={name:"jsonp",getAgent:function(t,e){return function(n,i){var s="http"+(e?"s":"")+"://"+(t.host||t.options.host)+t.options.path,o=ue.createJSONPRequest(s,n),a=ue.ScriptReceivers.create((function(e,n){r.remove(a),o.cleanup(),n&&n.host&&(t.host=n.host),i&&i(e,n)}));o.send(a)}}};function tt(t,e,n){return t+(e.useTLS?"s":"")+"://"+(e.useTLS?e.hostTLS:e.hostNonTLS)+n}function et(t,e){return"/app/"+t+("?protocol="+s.PROTOCOL+"&client=js&version="+s.VERSION+(e?"&"+e:""))}var nt={getInitial:function(t,e){return tt("ws",e,(e.httpPath||"")+et(t,"flash=false"))}},it={getInitial:function(t,e){return tt("http",e,(e.httpPath||"/pusher")+et(t))}},rt={getInitial:function(t,e){return tt("http",e,e.httpPath||"/pusher")},getPath:function(t,e){return et(t)}};class st{constructor(){this._callbacks={}}get(t){return this._callbacks[ot(t)]}add(t,e,n){var i=ot(t);this._callbacks[i]=this._callbacks[i]||[],this._callbacks[i].push({fn:e,context:n})}remove(t,e,n){if(t||e||n){var i=t?[ot(t)]:z(this._callbacks);e||n?this.removeCallback(i,e,n):this.removeAllCallbacks(i)}else this._callbacks={}}removeCallback(t,e,n){q(t,(function(t){this._callbacks[t]=F(this._callbacks[t]||[],(function(t){return e&&e!==t.fn||n&&n!==t.context})),0===this._callbacks[t].length&&delete this._callbacks[t]}),this)}removeAllCallbacks(t){q(t,(function(t){delete this._callbacks[t]}),this)}}function ot(t){return"_"+t}class at{constructor(t){this.callbacks=new st,this.global_callbacks=[],this.failThrough=t}bind(t,e,n){return this.callbacks.add(t,e,n),this}bind_global(t){return this.global_callbacks.push(t),this}unbind(t,e,n){return this.callbacks.remove(t,e,n),this}unbind_global(t){return t?(this.global_callbacks=F(this.global_callbacks||[],e=>e!==t),this):(this.global_callbacks=[],this)}unbind_all(){return this.unbind(),this.unbind_global(),this}emit(t,e,n){for(var i=0;i0)for(i=0;i{this.onError(t),this.changeState("closed")}),!1}return this.bindListeners(),V.debug("Connecting",{transport:this.name,url:t}),this.changeState("connecting"),!0}close(){return!!this.socket&&(this.socket.close(),!0)}send(t){return"open"===this.state&&(j.defer(()=>{this.socket&&this.socket.send(t)}),!0)}ping(){"open"===this.state&&this.supportsPing()&&this.socket.ping()}onOpen(){this.hooks.beforeOpen&&this.hooks.beforeOpen(this.socket,this.hooks.urls.getPath(this.key,this.options)),this.changeState("open"),this.socket.onopen=void 0}onError(t){this.emit("error",{type:"WebSocketError",error:t}),this.timeline.error(this.buildTimelineMessage({error:t.toString()}))}onClose(t){t?this.changeState("closed",{code:t.code,reason:t.reason,wasClean:t.wasClean}):this.changeState("closed"),this.unbindListeners(),this.socket=void 0}onMessage(t){this.emit("message",t)}onActivity(){this.emit("activity")}bindListeners(){this.socket.onopen=()=>{this.onOpen()},this.socket.onerror=t=>{this.onError(t)},this.socket.onclose=t=>{this.onClose(t)},this.socket.onmessage=t=>{this.onMessage(t)},this.supportsPing()&&(this.socket.onactivity=()=>{this.onActivity()})}unbindListeners(){this.socket&&(this.socket.onopen=void 0,this.socket.onerror=void 0,this.socket.onclose=void 0,this.socket.onmessage=void 0,this.supportsPing()&&(this.socket.onactivity=void 0))}changeState(t,e){this.state=t,this.timeline.info(this.buildTimelineMessage({state:t,params:e})),this.emit(t,e)}buildTimelineMessage(t){return N({cid:this.id},t)}}class ht{constructor(t){this.hooks=t}isSupported(t){return this.hooks.isSupported(t)}createConnection(t,e,n,i){return new ct(this.hooks,t,e,n,i)}}var ut=new ht({urls:nt,handlesActivityChecks:!1,supportsPing:!1,isInitialized:function(){return Boolean(ue.getWebSocketAPI())},isSupported:function(){return Boolean(ue.getWebSocketAPI())},getSocket:function(t){return ue.createWebSocket(t)}}),lt={urls:it,handlesActivityChecks:!1,supportsPing:!0,isInitialized:function(){return!0}},dt=N({getSocket:function(t){return ue.HTTPFactory.createStreamingSocket(t)}},lt),pt=N({getSocket:function(t){return ue.HTTPFactory.createPollingSocket(t)}},lt),ft={isSupported:function(){return ue.isXHRSupported()}},gt={ws:ut,xhr_streaming:new ht(N({},dt,ft)),xhr_polling:new ht(N({},pt,ft))},vt=new ht({file:"sockjs",urls:rt,handlesActivityChecks:!0,supportsPing:!1,isSupported:function(){return!0},isInitialized:function(){return void 0!==window.SockJS},getSocket:function(t,e){return new window.SockJS(t,null,{js_path:a.getPath("sockjs",{useTLS:e.useTLS}),ignore_null_origin:e.ignoreNullOrigin})},beforeOpen:function(t,e){t.send(JSON.stringify({path:e}))}}),mt={isSupported:function(t){return ue.isXDRSupported(t.useTLS)}},bt=new ht(N({},dt,mt)),yt=new ht(N({},pt,mt));gt.xdr_streaming=bt,gt.xdr_polling=yt,gt.sockjs=vt;var wt=gt;var St=new class extends at{constructor(){super();var t=this;void 0!==window.addEventListener&&(window.addEventListener("online",(function(){t.emit("online")}),!1),window.addEventListener("offline",(function(){t.emit("offline")}),!1))}isOnline(){return void 0===window.navigator.onLine||window.navigator.onLine}};class _t{constructor(t,e,n){this.manager=t,this.transport=e,this.minPingDelay=n.minPingDelay,this.maxPingDelay=n.maxPingDelay,this.pingDelay=void 0}createConnection(t,e,n,i){i=N({},i,{activityTimeout:this.pingDelay});var r=this.transport.createConnection(t,e,n,i),s=null,o=function(){r.unbind("open",o),r.bind("closed",a),s=j.now()},a=t=>{if(r.unbind("closed",a),1002===t.code||1003===t.code)this.manager.reportDeath();else if(!t.wasClean&&s){var e=j.now()-s;e<2*this.maxPingDelay&&(this.manager.reportDeath(),this.pingDelay=Math.max(e/2,this.minPingDelay))}};return r.bind("open",o),r}isSupported(t){return this.manager.isAlive()&&this.transport.isSupported(t)}}const kt={decodeMessage:function(t){try{var e=JSON.parse(t.data),n=e.data;if("string"==typeof n)try{n=JSON.parse(e.data)}catch(t){}var i={event:e.event,channel:e.channel,data:n};return e.user_id&&(i.user_id=e.user_id),i}catch(e){throw{type:"MessageParseError",error:e,data:t.data}}},encodeMessage:function(t){return JSON.stringify(t)},processHandshake:function(t){var e=kt.decodeMessage(t);if("pusher:connection_established"===e.event){if(!e.data.activity_timeout)throw"No activity timeout specified in handshake";return{action:"connected",id:e.data.socket_id,activityTimeout:1e3*e.data.activity_timeout}}if("pusher:error"===e.event)return{action:this.getCloseAction(e.data),error:this.getCloseError(e.data)};throw"Invalid handshake"},getCloseAction:function(t){return t.code<4e3?t.code>=1002&&t.code<=1004?"backoff":null:4e3===t.code?"tls_only":t.code<4100?"refused":t.code<4200?"backoff":t.code<4300?"retry":"refused"},getCloseError:function(t){return 1e3!==t.code&&1001!==t.code?{type:"PusherError",data:{code:t.code,message:t.reason||t.message}}:null}};var Ct=kt;class Tt extends at{constructor(t,e){super(),this.id=t,this.transport=e,this.activityTimeout=e.activityTimeout,this.bindListeners()}handlesActivityChecks(){return this.transport.handlesActivityChecks()}send(t){return this.transport.send(t)}send_event(t,e,n){var i={event:t,data:e};return n&&(i.channel=n),V.debug("Event sent",i),this.send(Ct.encodeMessage(i))}ping(){this.transport.supportsPing()?this.transport.ping():this.send_event("pusher:ping",{})}close(){this.transport.close()}bindListeners(){var t={message:t=>{var e;try{e=Ct.decodeMessage(t)}catch(e){this.emit("error",{type:"MessageParseError",error:e,data:t.data})}if(void 0!==e){switch(V.debug("Event recd",e),e.event){case"pusher:error":this.emit("error",{type:"PusherError",data:e.data});break;case"pusher:ping":this.emit("ping");break;case"pusher:pong":this.emit("pong")}this.emit("message",e)}},activity:()=>{this.emit("activity")},error:t=>{this.emit("error",t)},closed:t=>{e(),t&&t.code&&this.handleCloseEvent(t),this.transport=null,this.emit("closed")}},e=()=>{M(t,(t,e)=>{this.transport.unbind(e,t)})};M(t,(t,e)=>{this.transport.bind(e,t)})}handleCloseEvent(t){var e=Ct.getCloseAction(t),n=Ct.getCloseError(t);n&&this.emit("error",n),e&&this.emit(e,{action:e,error:n})}}class Pt{constructor(t,e){this.transport=t,this.callback=e,this.bindListeners()}close(){this.unbindListeners(),this.transport.close()}bindListeners(){this.onMessage=t=>{var e;this.unbindListeners();try{e=Ct.processHandshake(t)}catch(t){return this.finish("error",{error:t}),void this.transport.close()}"connected"===e.action?this.finish("connected",{connection:new Tt(e.id,this.transport),activityTimeout:e.activityTimeout}):(this.finish(e.action,{error:e.error}),this.transport.close())},this.onClosed=t=>{this.unbindListeners();var e=Ct.getCloseAction(t)||"backoff",n=Ct.getCloseError(t);this.finish(e,{error:n})},this.transport.bind("message",this.onMessage),this.transport.bind("closed",this.onClosed)}unbindListeners(){this.transport.unbind("message",this.onMessage),this.transport.unbind("closed",this.onClosed)}finish(t,e){this.callback(N({transport:this.transport,action:t},e))}}class Et{constructor(t,e){this.timeline=t,this.options=e||{}}send(t,e){this.timeline.isEmpty()||this.timeline.send(ue.TimelineTransport.getAgent(this,t),e)}}class Ot extends at{constructor(t,e){super((function(e,n){V.debug("No callbacks on "+t+" for "+e)})),this.name=t,this.pusher=e,this.subscribed=!1,this.subscriptionPending=!1,this.subscriptionCancelled=!1}authorize(t,e){return e(null,{auth:""})}trigger(t,e){if(0!==t.indexOf("client-"))throw new l("Event '"+t+"' does not start with 'client-'");if(!this.subscribed){var n=u("triggeringClientEvents");V.warn("Client event triggered before channel 'subscription_succeeded' event . "+n)}return this.pusher.send_event(t,e,this.name)}disconnect(){this.subscribed=!1,this.subscriptionPending=!1}handleEvent(t){var e=t.event,n=t.data;if("pusher_internal:subscription_succeeded"===e)this.handleSubscriptionSucceededEvent(t);else if("pusher_internal:subscription_count"===e)this.handleSubscriptionCountEvent(t);else if(0!==e.indexOf("pusher_internal:")){this.emit(e,n,{})}}handleSubscriptionSucceededEvent(t){this.subscriptionPending=!1,this.subscribed=!0,this.subscriptionCancelled?this.pusher.unsubscribe(this.name):this.emit("pusher:subscription_succeeded",t.data)}handleSubscriptionCountEvent(t){t.data.subscription_count&&(this.subscriptionCount=t.data.subscription_count),this.emit("pusher:subscription_count",t.data)}subscribe(){this.subscribed||(this.subscriptionPending=!0,this.subscriptionCancelled=!1,this.authorize(this.pusher.connection.socket_id,(t,e)=>{t?(this.subscriptionPending=!1,V.error(t.toString()),this.emit("pusher:subscription_error",Object.assign({},{type:"AuthError",error:t.message},t instanceof y?{status:t.status}:{}))):this.pusher.send_event("pusher:subscribe",{auth:e.auth,channel_data:e.channel_data,channel:this.name})}))}unsubscribe(){this.subscribed=!1,this.pusher.send_event("pusher:unsubscribe",{channel:this.name})}cancelSubscription(){this.subscriptionCancelled=!0}reinstateSubscription(){this.subscriptionCancelled=!1}}class xt extends Ot{authorize(t,e){return this.pusher.config.channelAuthorizer({channelName:this.name,socketId:t},e)}}class Lt{constructor(){this.reset()}get(t){return Object.prototype.hasOwnProperty.call(this.members,t)?{id:t,info:this.members[t]}:null}each(t){M(this.members,(e,n)=>{t(this.get(n))})}setMyID(t){this.myID=t}onSubscription(t){this.members=t.presence.hash,this.count=t.presence.count,this.me=this.get(this.myID)}addMember(t){return null===this.get(t.user_id)&&this.count++,this.members[t.user_id]=t.user_info,this.get(t.user_id)}removeMember(t){var e=this.get(t.user_id);return e&&(delete this.members[t.user_id],this.count--),e}reset(){this.members={},this.count=0,this.myID=null,this.me=null}}var At=function(t,e,n,i){return new(n||(n=Promise))((function(r,s){function o(t){try{c(i.next(t))}catch(t){s(t)}}function a(t){try{c(i.throw(t))}catch(t){s(t)}}function c(t){var e;t.done?r(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(o,a)}c((i=i.apply(t,e||[])).next())}))};class Rt extends xt{constructor(t,e){super(t,e),this.members=new Lt}authorize(t,e){super.authorize(t,(t,n)=>At(this,void 0,void 0,(function*(){if(!t)if(null!=(n=n).channel_data){var i=JSON.parse(n.channel_data);this.members.setMyID(i.user_id)}else{if(yield this.pusher.user.signinDonePromise,null==this.pusher.user.user_data){let t=u("authorizationEndpoint");return V.error(`Invalid auth response for channel '${this.name}', expected 'channel_data' field. ${t}, or the user should be signed in.`),void e("Invalid auth response")}this.members.setMyID(this.pusher.user.user_data.id)}e(t,n)})))}handleEvent(t){var e=t.event;if(0===e.indexOf("pusher_internal:"))this.handleInternalEvent(t);else{var n=t.data,i={};t.user_id&&(i.user_id=t.user_id),this.emit(e,n,i)}}handleInternalEvent(t){var e=t.event,n=t.data;switch(e){case"pusher_internal:subscription_succeeded":this.handleSubscriptionSucceededEvent(t);break;case"pusher_internal:subscription_count":this.handleSubscriptionCountEvent(t);break;case"pusher_internal:member_added":var i=this.members.addMember(n);this.emit("pusher:member_added",i);break;case"pusher_internal:member_removed":var r=this.members.removeMember(n);r&&this.emit("pusher:member_removed",r)}}handleSubscriptionSucceededEvent(t){this.subscriptionPending=!1,this.subscribed=!0,this.subscriptionCancelled?this.pusher.unsubscribe(this.name):(this.members.onSubscription(t.data),this.emit("pusher:subscription_succeeded",this.members))}disconnect(){this.members.reset(),super.disconnect()}}var It=n(1),Dt=n(0);class jt extends xt{constructor(t,e,n){super(t,e),this.key=null,this.nacl=n}authorize(t,e){super.authorize(t,(t,n)=>{if(t)return void e(t,n);let i=n.shared_secret;i?(this.key=Object(Dt.decode)(i),delete n.shared_secret,e(null,n)):e(new Error("No shared_secret key in auth payload for encrypted channel: "+this.name),null)})}trigger(t,e){throw new v("Client events are not currently supported for encrypted channels")}handleEvent(t){var e=t.event,n=t.data;0!==e.indexOf("pusher_internal:")&&0!==e.indexOf("pusher:")?this.handleEncryptedEvent(e,n):super.handleEvent(t)}handleEncryptedEvent(t,e){if(!this.key)return void V.debug("Received encrypted event before key has been retrieved from the authEndpoint");if(!e.ciphertext||!e.nonce)return void V.error("Unexpected format for encrypted event, expected object with `ciphertext` and `nonce` fields, got: "+e);let n=Object(Dt.decode)(e.ciphertext);if(n.length{e?V.error(`Failed to make a request to the authEndpoint: ${s}. Unable to fetch new key, so dropping encrypted event`):(r=this.nacl.secretbox.open(n,i,this.key),null!==r?this.emit(t,this.getDataToEmit(r)):V.error("Failed to decrypt event with new key. Dropping encrypted event"))});this.emit(t,this.getDataToEmit(r))}getDataToEmit(t){let e=Object(It.decode)(t);try{return JSON.parse(e)}catch(t){return e}}}class Nt extends at{constructor(t,e){super(),this.state="initialized",this.connection=null,this.key=t,this.options=e,this.timeline=this.options.timeline,this.usingTLS=this.options.useTLS,this.errorCallbacks=this.buildErrorCallbacks(),this.connectionCallbacks=this.buildConnectionCallbacks(this.errorCallbacks),this.handshakeCallbacks=this.buildHandshakeCallbacks(this.errorCallbacks);var n=ue.getNetwork();n.bind("online",()=>{this.timeline.info({netinfo:"online"}),"connecting"!==this.state&&"unavailable"!==this.state||this.retryIn(0)}),n.bind("offline",()=>{this.timeline.info({netinfo:"offline"}),this.connection&&this.sendActivityCheck()}),this.updateStrategy()}switchCluster(t){this.key=t,this.updateStrategy(),this.retryIn(0)}connect(){this.connection||this.runner||(this.strategy.isSupported()?(this.updateState("connecting"),this.startConnecting(),this.setUnavailableTimer()):this.updateState("failed"))}send(t){return!!this.connection&&this.connection.send(t)}send_event(t,e,n){return!!this.connection&&this.connection.send_event(t,e,n)}disconnect(){this.disconnectInternally(),this.updateState("disconnected")}isUsingTLS(){return this.usingTLS}startConnecting(){var t=(e,n)=>{e?this.runner=this.strategy.connect(0,t):"error"===n.action?(this.emit("error",{type:"HandshakeError",error:n.error}),this.timeline.error({handshakeError:n.error})):(this.abortConnecting(),this.handshakeCallbacks[n.action](n))};this.runner=this.strategy.connect(0,t)}abortConnecting(){this.runner&&(this.runner.abort(),this.runner=null)}disconnectInternally(){(this.abortConnecting(),this.clearRetryTimer(),this.clearUnavailableTimer(),this.connection)&&this.abandonConnection().close()}updateStrategy(){this.strategy=this.options.getStrategy({key:this.key,timeline:this.timeline,useTLS:this.usingTLS})}retryIn(t){this.timeline.info({action:"retry",delay:t}),t>0&&this.emit("connecting_in",Math.round(t/1e3)),this.retryTimer=new I(t||0,()=>{this.disconnectInternally(),this.connect()})}clearRetryTimer(){this.retryTimer&&(this.retryTimer.ensureAborted(),this.retryTimer=null)}setUnavailableTimer(){this.unavailableTimer=new I(this.options.unavailableTimeout,()=>{this.updateState("unavailable")})}clearUnavailableTimer(){this.unavailableTimer&&this.unavailableTimer.ensureAborted()}sendActivityCheck(){this.stopActivityCheck(),this.connection.ping(),this.activityTimer=new I(this.options.pongTimeout,()=>{this.timeline.error({pong_timed_out:this.options.pongTimeout}),this.retryIn(0)})}resetActivityCheck(){this.stopActivityCheck(),this.connection&&!this.connection.handlesActivityChecks()&&(this.activityTimer=new I(this.activityTimeout,()=>{this.sendActivityCheck()}))}stopActivityCheck(){this.activityTimer&&this.activityTimer.ensureAborted()}buildConnectionCallbacks(t){return N({},t,{message:t=>{this.resetActivityCheck(),this.emit("message",t)},ping:()=>{this.send_event("pusher:pong",{})},activity:()=>{this.resetActivityCheck()},error:t=>{this.emit("error",t)},closed:()=>{this.abandonConnection(),this.shouldRetry()&&this.retryIn(1e3)}})}buildHandshakeCallbacks(t){return N({},t,{connected:t=>{this.activityTimeout=Math.min(this.options.activityTimeout,t.activityTimeout,t.connection.activityTimeout||1/0),this.clearUnavailableTimer(),this.setConnection(t.connection),this.socket_id=this.connection.id,this.updateState("connected",{socket_id:this.socket_id})}})}buildErrorCallbacks(){let t=t=>e=>{e.error&&this.emit("error",{type:"WebSocketError",error:e.error}),t(e)};return{tls_only:t(()=>{this.usingTLS=!0,this.updateStrategy(),this.retryIn(0)}),refused:t(()=>{this.disconnect()}),backoff:t(()=>{this.retryIn(1e3)}),retry:t(()=>{this.retryIn(0)})}}setConnection(t){for(var e in this.connection=t,this.connectionCallbacks)this.connection.bind(e,this.connectionCallbacks[e]);this.resetActivityCheck()}abandonConnection(){if(this.connection){for(var t in this.stopActivityCheck(),this.connectionCallbacks)this.connection.unbind(t,this.connectionCallbacks[t]);var e=this.connection;return this.connection=null,e}}updateState(t,e){var n=this.state;if(this.state=t,n!==t){var i=t;"connected"===i&&(i+=" with new socket ID "+e.socket_id),V.debug("State changed",n+" -> "+i),this.timeline.info({state:t,params:e}),this.emit("state_change",{previous:n,current:t}),this.emit(t,e)}}shouldRetry(){return"connecting"===this.state||"connected"===this.state}}class Ht{constructor(){this.channels={}}add(t,e){return this.channels[t]||(this.channels[t]=function(t,e){if(0===t.indexOf("private-encrypted-")){if(e.config.nacl)return Ut.createEncryptedChannel(t,e,e.config.nacl);let n="Tried to subscribe to a private-encrypted- channel but no nacl implementation available",i=u("encryptedChannelSupport");throw new v(`${n}. ${i}`)}if(0===t.indexOf("private-"))return Ut.createPrivateChannel(t,e);if(0===t.indexOf("presence-"))return Ut.createPresenceChannel(t,e);if(0===t.indexOf("#"))throw new d('Cannot create a channel with name "'+t+'".');return Ut.createChannel(t,e)}(t,e)),this.channels[t]}all(){return function(t){var e=[];return M(t,(function(t){e.push(t)})),e}(this.channels)}find(t){return this.channels[t]}remove(t){var e=this.channels[t];return delete this.channels[t],e}disconnect(){M(this.channels,(function(t){t.disconnect()}))}}var Ut={createChannels:()=>new Ht,createConnectionManager:(t,e)=>new Nt(t,e),createChannel:(t,e)=>new Ot(t,e),createPrivateChannel:(t,e)=>new xt(t,e),createPresenceChannel:(t,e)=>new Rt(t,e),createEncryptedChannel:(t,e,n)=>new jt(t,e,n),createTimelineSender:(t,e)=>new Et(t,e),createHandshake:(t,e)=>new Pt(t,e),createAssistantToTheTransportManager:(t,e,n)=>new _t(t,e,n)};class Mt{constructor(t){this.options=t||{},this.livesLeft=this.options.lives||1/0}getAssistant(t){return Ut.createAssistantToTheTransportManager(this,t,{minPingDelay:this.options.minPingDelay,maxPingDelay:this.options.maxPingDelay})}isAlive(){return this.livesLeft>0}reportDeath(){this.livesLeft-=1}}class zt{constructor(t,e){this.strategies=t,this.loop=Boolean(e.loop),this.failFast=Boolean(e.failFast),this.timeout=e.timeout,this.timeoutLimit=e.timeoutLimit}isSupported(){return J(this.strategies,j.method("isSupported"))}connect(t,e){var n=this.strategies,i=0,r=this.timeout,s=null,o=(a,c)=>{c?e(null,c):(i+=1,this.loop&&(i%=n.length),i0&&(r=new I(n.timeout,(function(){s.abort(),i(!0)}))),s=t.connect(e,(function(t,e){t&&r&&r.isRunning()&&!n.failFast||(r&&r.ensureAborted(),i(t,e))})),{abort:function(){r&&r.ensureAborted(),s.abort()},forceMinPriority:function(t){s.forceMinPriority(t)}}}}class qt{constructor(t){this.strategies=t}isSupported(){return J(this.strategies,j.method("isSupported"))}connect(t,e){return function(t,e,n){var i=B(t,(function(t,i,r,s){return t.connect(e,n(i,s))}));return{abort:function(){q(i,Bt)},forceMinPriority:function(t){q(i,(function(e){e.forceMinPriority(t)}))}}}(this.strategies,t,(function(t,n){return function(i,r){n[t].error=i,i?function(t){return function(t,e){for(var n=0;n=j.now()){var o=this.transports[i.transport];o&&(["ws","wss"].includes(i.transport)||r>3?(this.timeline.info({cached:!0,transport:i.transport,latency:i.latency}),s.push(new zt([o],{timeout:2*i.latency+1e3,failFast:!0}))):r++)}var a=j.now(),c=s.pop().connect(t,(function i(o,h){o?(Jt(n),s.length>0?(a=j.now(),c=s.pop().connect(t,i)):e(o)):(!function(t,e,n,i){var r=ue.getLocalStorage();if(r)try{r[Xt(t)]=G({timestamp:j.now(),transport:e,latency:n,cacheSkipCount:i})}catch(t){}}(n,h.transport.name,j.now()-a,r),e(null,h))}));return{abort:function(){c.abort()},forceMinPriority:function(e){t=e,c&&c.forceMinPriority(e)}}}}function Xt(t){return"pusherTransport"+(t?"TLS":"NonTLS")}function Jt(t){var e=ue.getLocalStorage();if(e)try{delete e[Xt(t)]}catch(t){}}class $t{constructor(t,{delay:e}){this.strategy=t,this.options={delay:e}}isSupported(){return this.strategy.isSupported()}connect(t,e){var n,i=this.strategy,r=new I(this.options.delay,(function(){n=i.connect(t,e)}));return{abort:function(){r.ensureAborted(),n&&n.abort()},forceMinPriority:function(e){t=e,n&&n.forceMinPriority(e)}}}}class Wt{constructor(t,e,n){this.test=t,this.trueBranch=e,this.falseBranch=n}isSupported(){return(this.test()?this.trueBranch:this.falseBranch).isSupported()}connect(t,e){return(this.test()?this.trueBranch:this.falseBranch).connect(t,e)}}class Gt{constructor(t){this.strategy=t}isSupported(){return this.strategy.isSupported()}connect(t,e){var n=this.strategy.connect(t,(function(t,i){i&&n.abort(),e(t,i)}));return n}}function Vt(t){return function(){return t.isSupported()}}var Yt=function(t,e,n){var i={};function r(e,r,s,o,a){var c=n(t,e,r,s,o,a);return i[e]=c,c}var s,o=Object.assign({},e,{hostNonTLS:t.wsHost+":"+t.wsPort,hostTLS:t.wsHost+":"+t.wssPort,httpPath:t.wsPath}),a=Object.assign({},o,{useTLS:!0}),c=Object.assign({},e,{hostNonTLS:t.httpHost+":"+t.httpPort,hostTLS:t.httpHost+":"+t.httpsPort,httpPath:t.httpPath}),h={loop:!0,timeout:15e3,timeoutLimit:6e4},u=new Mt({minPingDelay:1e4,maxPingDelay:t.activityTimeout}),l=new Mt({lives:2,minPingDelay:1e4,maxPingDelay:t.activityTimeout}),d=r("ws","ws",3,o,u),p=r("wss","ws",3,a,u),f=r("sockjs","sockjs",1,c),g=r("xhr_streaming","xhr_streaming",1,c,l),v=r("xdr_streaming","xdr_streaming",1,c,l),m=r("xhr_polling","xhr_polling",1,c),b=r("xdr_polling","xdr_polling",1,c),y=new zt([d],h),w=new zt([p],h),S=new zt([f],h),_=new zt([new Wt(Vt(g),g,v)],h),k=new zt([new Wt(Vt(m),m,b)],h),C=new zt([new Wt(Vt(_),new qt([_,new $t(k,{delay:4e3})]),k)],h),T=new Wt(Vt(C),C,S);return s=e.useTLS?new qt([y,new $t(T,{delay:2e3})]):new qt([y,new $t(w,{delay:2e3}),new $t(T,{delay:5e3})]),new Ft(new Gt(new Wt(Vt(d),s,T)),i,{ttl:18e5,timeline:e.timeline,useTLS:e.useTLS})},Kt={getRequest:function(t){var e=new window.XDomainRequest;return e.ontimeout=function(){t.emit("error",new p),t.close()},e.onerror=function(e){t.emit("error",e),t.close()},e.onprogress=function(){e.responseText&&e.responseText.length>0&&t.onChunk(200,e.responseText)},e.onload=function(){e.responseText&&e.responseText.length>0&&t.onChunk(200,e.responseText),t.emit("finished",200),t.close()},e},abortRequest:function(t){t.ontimeout=t.onerror=t.onprogress=t.onload=null,t.abort()}};class Qt extends at{constructor(t,e,n){super(),this.hooks=t,this.method=e,this.url=n}start(t){this.position=0,this.xhr=this.hooks.getRequest(this),this.unloader=()=>{this.close()},ue.addUnloadListener(this.unloader),this.xhr.open(this.method,this.url,!0),this.xhr.setRequestHeader&&this.xhr.setRequestHeader("Content-Type","application/json"),this.xhr.send(t)}close(){this.unloader&&(ue.removeUnloadListener(this.unloader),this.unloader=null),this.xhr&&(this.hooks.abortRequest(this.xhr),this.xhr=null)}onChunk(t,e){for(;;){var n=this.advanceBuffer(e);if(!n)break;this.emit("chunk",{status:t,data:n})}this.isBufferTooLong(e)&&this.emit("buffer_too_long")}advanceBuffer(t){var e=t.slice(this.position),n=e.indexOf("\n");return-1!==n?(this.position+=n+1,e.slice(0,n)):null}isBufferTooLong(t){return this.position===t.length&&t.length>262144}}var Zt;!function(t){t[t.CONNECTING=0]="CONNECTING",t[t.OPEN=1]="OPEN",t[t.CLOSED=3]="CLOSED"}(Zt||(Zt={}));var te=Zt,ee=1;function ne(t){var e=-1===t.indexOf("?")?"?":"&";return t+e+"t="+ +new Date+"&n="+ee++}function ie(t){return ue.randomInt(t)}var re,se=class{constructor(t,e){this.hooks=t,this.session=ie(1e3)+"/"+function(t){for(var e=[],n=0;n{this.onChunk(t)}),this.stream.bind("finished",t=>{this.hooks.onFinished(this,t)}),this.stream.bind("buffer_too_long",()=>{this.reconnect()});try{this.stream.start()}catch(t){j.defer(()=>{this.onError(t),this.onClose(1006,"Could not start streaming",!1)})}}closeStream(){this.stream&&(this.stream.unbind_all(),this.stream.close(),this.stream=null)}},oe={getReceiveURL:function(t,e){return t.base+"/"+e+"/xhr_streaming"+t.queryString},onHeartbeat:function(t){t.sendRaw("[]")},sendHeartbeat:function(t){t.sendRaw("[]")},onFinished:function(t,e){t.onClose(1006,"Connection interrupted ("+e+")",!1)}},ae={getReceiveURL:function(t,e){return t.base+"/"+e+"/xhr"+t.queryString},onHeartbeat:function(){},sendHeartbeat:function(t){t.sendRaw("[]")},onFinished:function(t,e){200===e?t.reconnect():t.onClose(1006,"Connection interrupted ("+e+")",!1)}},ce={getRequest:function(t){var e=new(ue.getXHRAPI());return e.onreadystatechange=e.onprogress=function(){switch(e.readyState){case 3:e.responseText&&e.responseText.length>0&&t.onChunk(e.status,e.responseText);break;case 4:e.responseText&&e.responseText.length>0&&t.onChunk(e.status,e.responseText),t.emit("finished",e.status),t.close()}},e},abortRequest:function(t){t.onreadystatechange=null,t.abort()}},he={createStreamingSocket(t){return this.createSocket(oe,t)},createPollingSocket(t){return this.createSocket(ae,t)},createSocket:(t,e)=>new se(t,e),createXHR(t,e){return this.createRequest(ce,t,e)},createRequest:(t,e,n)=>new Qt(t,e,n),createXDR:function(t,e){return this.createRequest(Kt,t,e)}},ue={nextAuthCallbackID:1,auth_callbacks:{},ScriptReceivers:r,DependenciesReceivers:o,getDefaultStrategy:Yt,Transports:wt,transportConnectionInitializer:function(){var t=this;t.timeline.info(t.buildTimelineMessage({transport:t.name+(t.options.useTLS?"s":"")})),t.hooks.isInitialized()?t.changeState("initialized"):t.hooks.file?(t.changeState("initializing"),a.load(t.hooks.file,{useTLS:t.options.useTLS},(function(e,n){t.hooks.isInitialized()?(t.changeState("initialized"),n(!0)):(e&&t.onError(e),t.onClose(),n(!1))}))):t.onClose()},HTTPFactory:he,TimelineTransport:Z,getXHRAPI:()=>window.XMLHttpRequest,getWebSocketAPI:()=>window.WebSocket||window.MozWebSocket,setup(t){window.Pusher=t;var e=()=>{this.onDocumentBody(t.ready)};window.JSON?e():a.load("json2",{},e)},getDocument:()=>document,getProtocol(){return this.getDocument().location.protocol},getAuthorizers:()=>({ajax:w,jsonp:Y}),onDocumentBody(t){document.body?t():setTimeout(()=>{this.onDocumentBody(t)},0)},createJSONPRequest:(t,e)=>new Q(t,e),createScriptRequest:t=>new K(t),getLocalStorage(){try{return window.localStorage}catch(t){return}},createXHR(){return this.getXHRAPI()?this.createXMLHttpRequest():this.createMicrosoftXHR()},createXMLHttpRequest(){return new(this.getXHRAPI())},createMicrosoftXHR:()=>new ActiveXObject("Microsoft.XMLHTTP"),getNetwork:()=>St,createWebSocket(t){return new(this.getWebSocketAPI())(t)},createSocketRequest(t,e){if(this.isXHRSupported())return this.HTTPFactory.createXHR(t,e);if(this.isXDRSupported(0===e.indexOf("https:")))return this.HTTPFactory.createXDR(t,e);throw"Cross-origin HTTP requests are not supported"},isXHRSupported(){var t=this.getXHRAPI();return Boolean(t)&&void 0!==(new t).withCredentials},isXDRSupported(t){var e=t?"https:":"http:",n=this.getProtocol();return Boolean(window.XDomainRequest)&&n===e},addUnloadListener(t){void 0!==window.addEventListener?window.addEventListener("unload",t,!1):void 0!==window.attachEvent&&window.attachEvent("onunload",t)},removeUnloadListener(t){void 0!==window.addEventListener?window.removeEventListener("unload",t,!1):void 0!==window.detachEvent&&window.detachEvent("onunload",t)},randomInt:t=>Math.floor((window.crypto||window.msCrypto).getRandomValues(new Uint32Array(1))[0]/Math.pow(2,32)*t)};!function(t){t[t.ERROR=3]="ERROR",t[t.INFO=6]="INFO",t[t.DEBUG=7]="DEBUG"}(re||(re={}));var le=re;class de{constructor(t,e,n){this.key=t,this.session=e,this.events=[],this.options=n||{},this.sent=0,this.uniqueID=0}log(t,e){t<=this.options.level&&(this.events.push(N({},e,{timestamp:j.now()})),this.options.limit&&this.events.length>this.options.limit&&this.events.shift())}error(t){this.log(le.ERROR,t)}info(t){this.log(le.INFO,t)}debug(t){this.log(le.DEBUG,t)}isEmpty(){return 0===this.events.length}send(t,e){var n=N({session:this.session,bundle:this.sent+1,key:this.key,lib:"js",version:this.options.version,cluster:this.options.cluster,features:this.options.features,timeline:this.events},this.options.params);return this.events=[],t(n,(t,n)=>{t||this.sent++,e&&e(t,n)}),!0}generateUniqueID(){return this.uniqueID++,this.uniqueID}}class pe{constructor(t,e,n,i){this.name=t,this.priority=e,this.transport=n,this.options=i||{}}isSupported(){return this.transport.isSupported({useTLS:this.options.useTLS})}connect(t,e){if(!this.isSupported())return fe(new b,e);if(this.priority{n||(h(),r?r.close():i.close())},forceMinPriority:t=>{n||this.priority{if(void 0===ue.getAuthorizers()[t.transport])throw`'${t.transport}' is not a recognized auth transport`;return(e,n)=>{const i=((t,e)=>{var n="socket_id="+encodeURIComponent(t.socketId);for(var i in e.params)n+="&"+encodeURIComponent(i)+"="+encodeURIComponent(e.params[i]);if(null!=e.paramsProvider){let t=e.paramsProvider();for(var i in t)n+="&"+encodeURIComponent(i)+"="+encodeURIComponent(t[i])}return n})(e,t);ue.getAuthorizers()[t.transport](ue,i,t,h.UserAuthentication,n)}};var ye=t=>{if(void 0===ue.getAuthorizers()[t.transport])throw`'${t.transport}' is not a recognized auth transport`;return(e,n)=>{const i=((t,e)=>{var n="socket_id="+encodeURIComponent(t.socketId);for(var i in n+="&channel_name="+encodeURIComponent(t.channelName),e.params)n+="&"+encodeURIComponent(i)+"="+encodeURIComponent(e.params[i]);if(null!=e.paramsProvider){let t=e.paramsProvider();for(var i in t)n+="&"+encodeURIComponent(i)+"="+encodeURIComponent(t[i])}return n})(e,t);ue.getAuthorizers()[t.transport](ue,i,t,h.ChannelAuthorization,n)}};function we(t,e){let n={activityTimeout:t.activityTimeout||s.activityTimeout,cluster:t.cluster,httpPath:t.httpPath||s.httpPath,httpPort:t.httpPort||s.httpPort,httpsPort:t.httpsPort||s.httpsPort,pongTimeout:t.pongTimeout||s.pongTimeout,statsHost:t.statsHost||s.stats_host,unavailableTimeout:t.unavailableTimeout||s.unavailableTimeout,wsPath:t.wsPath||s.wsPath,wsPort:t.wsPort||s.wsPort,wssPort:t.wssPort||s.wssPort,enableStats:Ce(t),httpHost:Se(t),useTLS:ke(t),wsHost:_e(t),userAuthenticator:Te(t),channelAuthorizer:Pe(t,e)};return"disabledTransports"in t&&(n.disabledTransports=t.disabledTransports),"enabledTransports"in t&&(n.enabledTransports=t.enabledTransports),"ignoreNullOrigin"in t&&(n.ignoreNullOrigin=t.ignoreNullOrigin),"timelineParams"in t&&(n.timelineParams=t.timelineParams),"nacl"in t&&(n.nacl=t.nacl),n}function Se(t){return t.httpHost?t.httpHost:t.cluster?`sockjs-${t.cluster}.pusher.com`:s.httpHost}function _e(t){return t.wsHost?t.wsHost:`ws-${t.cluster}.pusher.com`}function ke(t){return"https:"===ue.getProtocol()||!1!==t.forceTLS}function Ce(t){return"enableStats"in t?t.enableStats:"disableStats"in t&&!t.disableStats}function Te(t){const e=Object.assign(Object.assign({},s.userAuthentication),t.userAuthentication);return"customHandler"in e&&null!=e.customHandler?e.customHandler:be(e)}function Pe(t,e){const n=function(t,e){let n;return"channelAuthorization"in t?n=Object.assign(Object.assign({},s.channelAuthorization),t.channelAuthorization):(n={transport:t.authTransport||s.authTransport,endpoint:t.authEndpoint||s.authEndpoint},"auth"in t&&("params"in t.auth&&(n.params=t.auth.params),"headers"in t.auth&&(n.headers=t.auth.headers)),"authorizer"in t&&(n.customHandler=((t,e,n)=>{const i={authTransport:e.transport,authEndpoint:e.endpoint,auth:{params:e.params,headers:e.headers}};return(e,r)=>{const s=t.channel(e.channelName);n(s,i).authorize(e.socketId,r)}})(e,n,t.authorizer))),n}(t,e);return"customHandler"in n&&null!=n.customHandler?n.customHandler:ye(n)}class Ee extends at{constructor(t){super((function(t,e){V.debug("No callbacks on watchlist events for "+t)})),this.pusher=t,this.bindWatchlistInternalEvent()}handleEvent(t){t.data.events.forEach(t=>{this.emit(t.name,t)})}bindWatchlistInternalEvent(){this.pusher.connection.bind("message",t=>{"pusher_internal:watchlist_events"===t.event&&this.handleEvent(t)})}}var Oe=function(){let t,e;return{promise:new Promise((n,i)=>{t=n,e=i}),resolve:t,reject:e}};class xe extends at{constructor(t){super((function(t,e){V.debug("No callbacks on user for "+t)})),this.signin_requested=!1,this.user_data=null,this.serverToUserChannel=null,this.signinDonePromise=null,this._signinDoneResolve=null,this._onAuthorize=(t,e)=>{if(t)return V.warn("Error during signin: "+t),void this._cleanup();this.pusher.send_event("pusher:signin",{auth:e.auth,user_data:e.user_data})},this.pusher=t,this.pusher.connection.bind("state_change",({previous:t,current:e})=>{"connected"!==t&&"connected"===e&&this._signin(),"connected"===t&&"connected"!==e&&(this._cleanup(),this._newSigninPromiseIfNeeded())}),this.watchlist=new Ee(t),this.pusher.connection.bind("message",t=>{"pusher:signin_success"===t.event&&this._onSigninSuccess(t.data),this.serverToUserChannel&&this.serverToUserChannel.name===t.channel&&this.serverToUserChannel.handleEvent(t)})}signin(){this.signin_requested||(this.signin_requested=!0,this._signin())}_signin(){this.signin_requested&&(this._newSigninPromiseIfNeeded(),"connected"===this.pusher.connection.state&&this.pusher.config.userAuthenticator({socketId:this.pusher.connection.socket_id},this._onAuthorize))}_onSigninSuccess(t){try{this.user_data=JSON.parse(t.user_data)}catch(e){return V.error("Failed parsing user data after signin: "+t.user_data),void this._cleanup()}if("string"!=typeof this.user_data.id||""===this.user_data.id)return V.error("user_data doesn't contain an id. user_data: "+this.user_data),void this._cleanup();this._signinDoneResolve(),this._subscribeChannels()}_subscribeChannels(){this.serverToUserChannel=new Ot("#server-to-user-"+this.user_data.id,this.pusher),this.serverToUserChannel.bind_global((t,e)=>{0!==t.indexOf("pusher_internal:")&&0!==t.indexOf("pusher:")&&this.emit(t,e)}),(t=>{t.subscriptionPending&&t.subscriptionCancelled?t.reinstateSubscription():t.subscriptionPending||"connected"!==this.pusher.connection.state||t.subscribe()})(this.serverToUserChannel)}_cleanup(){this.user_data=null,this.serverToUserChannel&&(this.serverToUserChannel.unbind_all(),this.serverToUserChannel.disconnect(),this.serverToUserChannel=null),this.signin_requested&&this._signinDoneResolve()}_newSigninPromiseIfNeeded(){if(!this.signin_requested)return;if(this.signinDonePromise&&!this.signinDonePromise.done)return;const{promise:t,resolve:e,reject:n}=Oe();t.done=!1;const i=()=>{t.done=!0};t.then(i).catch(i),this.signinDonePromise=t,this._signinDoneResolve=e}}class Le{static ready(){Le.isReady=!0;for(var t=0,e=Le.instances.length;tue.getDefaultStrategy(this.config,t,ve),timeline:this.timeline,activityTimeout:this.config.activityTimeout,pongTimeout:this.config.pongTimeout,unavailableTimeout:this.config.unavailableTimeout,useTLS:Boolean(this.config.useTLS)}),this.connection.bind("connected",()=>{this.subscribeAll(),this.timelineSender&&this.timelineSender.send(this.connection.isUsingTLS())}),this.connection.bind("message",t=>{var e=0===t.event.indexOf("pusher_internal:");if(t.channel){var n=this.channel(t.channel);n&&n.handleEvent(t)}e||this.global_emitter.emit(t.event,t.data)}),this.connection.bind("connecting",()=>{this.channels.disconnect()}),this.connection.bind("disconnected",()=>{this.channels.disconnect()}),this.connection.bind("error",t=>{V.warn(t)}),Le.instances.push(this),this.timeline.info({instances:Le.instances.length}),this.user=new xe(this),Le.isReady&&this.connect()}switchCluster(t){const{appKey:e,cluster:n}=t;this.key=e,this.options=Object.assign(Object.assign({},this.options),{cluster:n}),this.config=we(this.options,this),this.connection.switchCluster(this.key)}channel(t){return this.channels.find(t)}allChannels(){return this.channels.all()}connect(){if(this.connection.connect(),this.timelineSender&&!this.timelineSenderTimer){var t=this.connection.isUsingTLS(),e=this.timelineSender;this.timelineSenderTimer=new D(6e4,(function(){e.send(t)}))}}disconnect(){this.connection.disconnect(),this.timelineSenderTimer&&(this.timelineSenderTimer.ensureAborted(),this.timelineSenderTimer=null)}bind(t,e,n){return this.global_emitter.bind(t,e,n),this}unbind(t,e,n){return this.global_emitter.unbind(t,e,n),this}bind_global(t){return this.global_emitter.bind_global(t),this}unbind_global(t){return this.global_emitter.unbind_global(t),this}unbind_all(t){return this.global_emitter.unbind_all(),this}subscribeAll(){var t;for(t in this.channels.channels)this.channels.channels.hasOwnProperty(t)&&this.subscribe(t)}subscribe(t){var e=this.channels.add(t,this);return e.subscriptionPending&&e.subscriptionCancelled?e.reinstateSubscription():e.subscriptionPending||"connected"!==this.connection.state||e.subscribe(),e}unsubscribe(t){var e=this.channels.find(t);e&&e.subscriptionPending?e.cancelSubscription():(e=this.channels.remove(t))&&e.subscribed&&e.unsubscribe()}send_event(t,e,n){return this.connection.send_event(t,e,n)}shouldUseTLS(){return this.config.useTLS}signin(){this.user.signin()}}Le.instances=[],Le.isReady=!1,Le.logToConsole=!1,Le.Runtime=ue,Le.ScriptReceivers=ue.ScriptReceivers,Le.DependenciesReceivers=ue.DependenciesReceivers,Le.auth_callbacks=ue.auth_callbacks;var Ae=e.default=Le;ue.setup(Le)}])})); //# sourceMappingURL=pusher.min.js.map \ No newline at end of file diff --git a/dist/web/pusher.min.js.map b/dist/web/pusher.min.js.map index c1935fd3b..7d60b47a0 100644 --- a/dist/web/pusher.min.js.map +++ b/dist/web/pusher.min.js.map @@ -1 +1 @@ -{"version":3,"sources":["webpack://Pusher/webpack/universalModuleDefinition","webpack://Pusher/webpack/bootstrap","webpack://Pusher/./node_modules/@stablelib/base64/base64.ts","webpack://Pusher/./node_modules/@stablelib/utf8/utf8.ts","webpack://Pusher/./src/core/pusher.js","webpack://Pusher/./src/runtimes/web/dom/script_receiver_factory.ts","webpack://Pusher/./src/core/defaults.ts","webpack://Pusher/./src/runtimes/web/dom/dependencies.ts","webpack://Pusher/./src/runtimes/web/dom/dependency_loader.ts","webpack://Pusher/./src/core/utils/url_store.ts","webpack://Pusher/./src/core/auth/options.ts","webpack://Pusher/./src/core/errors.ts","webpack://Pusher/./src/runtimes/isomorphic/auth/xhr_auth.ts","webpack://Pusher/./src/core/base64.ts","webpack://Pusher/./src/core/utils/timers/abstract_timer.ts","webpack://Pusher/./src/core/utils/timers/index.ts","webpack://Pusher/./src/core/util.ts","webpack://Pusher/./src/core/utils/collections.ts","webpack://Pusher/./src/core/logger.ts","webpack://Pusher/./src/runtimes/web/auth/jsonp_auth.ts","webpack://Pusher/./src/runtimes/web/dom/script_request.ts","webpack://Pusher/./src/runtimes/web/dom/jsonp_request.ts","webpack://Pusher/./src/runtimes/web/timeline/jsonp_timeline.ts","webpack://Pusher/./src/core/transports/url_schemes.ts","webpack://Pusher/./src/core/events/callback_registry.ts","webpack://Pusher/./src/core/events/dispatcher.ts","webpack://Pusher/./src/core/transports/transport_connection.ts","webpack://Pusher/./src/core/transports/transport.ts","webpack://Pusher/./src/runtimes/isomorphic/transports/transports.ts","webpack://Pusher/./src/runtimes/web/transports/transports.ts","webpack://Pusher/./src/runtimes/web/net_info.ts","webpack://Pusher/./src/core/transports/assistant_to_the_transport_manager.ts","webpack://Pusher/./src/core/connection/protocol/protocol.ts","webpack://Pusher/./src/core/connection/connection.ts","webpack://Pusher/./src/core/connection/handshake/index.ts","webpack://Pusher/./src/core/timeline/timeline_sender.ts","webpack://Pusher/./src/core/channels/channel.ts","webpack://Pusher/./src/core/channels/private_channel.ts","webpack://Pusher/./src/core/channels/members.ts","webpack://Pusher/./src/core/channels/presence_channel.ts","webpack://Pusher/./src/core/channels/encrypted_channel.ts","webpack://Pusher/./src/core/connection/connection_manager.ts","webpack://Pusher/./src/core/channels/channels.ts","webpack://Pusher/./src/core/utils/factory.ts","webpack://Pusher/./src/core/transports/transport_manager.ts","webpack://Pusher/./src/core/strategies/sequential_strategy.ts","webpack://Pusher/./src/core/strategies/best_connected_ever_strategy.ts","webpack://Pusher/./src/core/strategies/websocket_prioritized_cached_strategy.ts","webpack://Pusher/./src/core/strategies/delayed_strategy.ts","webpack://Pusher/./src/core/strategies/if_strategy.ts","webpack://Pusher/./src/core/strategies/first_connected_strategy.ts","webpack://Pusher/./src/runtimes/web/default_strategy.ts","webpack://Pusher/./src/runtimes/web/http/http_xdomain_request.ts","webpack://Pusher/./src/core/http/http_request.ts","webpack://Pusher/./src/core/http/state.ts","webpack://Pusher/./src/core/http/http_socket.ts","webpack://Pusher/./src/core/timeline/level.ts","webpack://Pusher/./src/core/http/http_streaming_socket.ts","webpack://Pusher/./src/core/http/http_polling_socket.ts","webpack://Pusher/./src/runtimes/isomorphic/http/http_xhr_request.ts","webpack://Pusher/./src/runtimes/isomorphic/http/http.ts","webpack://Pusher/./src/runtimes/web/http/http.ts","webpack://Pusher/./src/runtimes/web/runtime.ts","webpack://Pusher/./src/runtimes/web/transports/transport_connection_initializer.ts","webpack://Pusher/./src/core/timeline/timeline.ts","webpack://Pusher/./src/core/strategies/transport_strategy.ts","webpack://Pusher/./src/core/strategies/strategy_builder.ts","webpack://Pusher/./src/core/auth/user_authenticator.ts","webpack://Pusher/./src/core/auth/channel_authorizer.ts","webpack://Pusher/./src/core/config.ts","webpack://Pusher/./src/core/auth/deprecated_channel_authorizer.ts","webpack://Pusher/./src/core/watchlist.ts","webpack://Pusher/./src/core/utils/flat_promise.ts","webpack://Pusher/./src/core/user.ts","webpack://Pusher/./src/core/pusher.ts","webpack://Pusher/./src/core/options.ts"],"names":["root","factory","exports","module","define","amd","window","installedModules","__webpack_require__","moduleId","i","l","modules","call","m","c","d","name","getter","o","Object","defineProperty","enumerable","get","r","Symbol","toStringTag","value","t","mode","__esModule","ns","create","key","bind","n","object","property","prototype","hasOwnProperty","p","s","_paddingCharacter","encodedLength","length","this","encode","data","out","_encodeByte","left","maxDecodedLength","decodedLength","_getPaddingLength","decode","Uint8Array","paddingLength","op","haveBad","v0","v1","v2","v3","_decodeChar","charCodeAt","Error","b","result","String","fromCharCode","Coder","stdCoder","URLSafeCoder","urlSafeCoder","INVALID_UTF8","arr","pos","chars","min","n1","n2","n3","push","join","default","ScriptReceiverFactory","prefix","lastId","callback","number","id","called","callbackWrapper","apply","arguments","receiver","ScriptReceivers","VERSION","PROTOCOL","wsPort","wssPort","wsPath","httpHost","httpPort","httpsPort","httpPath","stats_host","authEndpoint","authTransport","activityTimeout","pongTimeout","unavailableTimeout","userAuthentication","endpoint","transport","channelAuthorization","cdn_http","cdn_https","dependency_suffix","DependenciesReceivers","Dependencies","options","receivers","loading","self","request","createScriptRequest","getPath","error","remove","callbacks","successCallback","wasSuccessful","cleanup","send","protocol","getDocument","location","useTLS","replace","version","getRoot","suffix","urlStore","baseUrl","urls","authenticationEndpoint","path","authorizationEndpoint","javascriptQuickStart","triggeringClientEvents","encryptedChannelSupport","fullUrl","AuthRequestType","urlObj","url","BadEventName","msg","super","setPrototypeOf","BadChannelName","RequestTimedOut","TransportPriorityTooLow","TransportClosed","UnsupportedFeature","UnsupportedTransport","UnsupportedStrategy","HTTPAuthError","status","context","query","authOptions","authRequestType","xhr","createXHR","headerName","open","setRequestHeader","headers","headersProvider","dynamicHeaders","onreadystatechange","readyState","parsed","JSON","parse","responseText","e","toString","UserAuthentication","ChannelAuthorization","b64chars","b64tab","charAt","cb_utob","cc","utob","u","cb_encode","ccc","padlen","ord","btoa","set","clear","delay","timer","clearTimeout","clearInterval","setTimeout","setInterval","now","Date","valueOf","defer","args","boundArguments","Array","slice","concat","extend","target","sources","extensions","constructor","stringify","safeJSONStringify","arrayIndexOf","array","item","nativeIndexOf","indexOf","objectApply","f","keys","_","map","filter","test","filterObject","Boolean","any","encodeParamsObject","encodeURIComponent","buildQueryString","params","undefined","method","source","objects","paths","derez","nu","$ref","globalLog","message","console","log","globalLogWarn","globalLogError","warn","defaultLoggingFunction","logToConsole","callbackName","nextAuthCallbackID","document","script","createElement","auth_callbacks","callback_name","src","head","getElementsByTagName","documentElement","insertBefore","firstChild","ScriptRequest","errorString","type","charset","addEventListener","onerror","onload","async","attachEvent","navigator","userAgent","errorScript","text","nextSibling","parentNode","removeChild","getAgent","sender","host","createJSONPRequest","getGenericURL","baseScheme","hostTLS","hostNonTLS","getGenericPath","queryString","ws","getInitial","http","sockjs","_callbacks","prefixedEventName","fn","names","removeCallback","removeAllCallbacks","binding","failThrough","global_callbacks","eventName","add","unbind","unbind_global","metadata","hooks","priority","initialize","transportConnectionInitializer","state","timeline","generateUniqueID","handlesActivityChecks","supportsPing","socket","getSocket","onError","changeState","bindListeners","debug","close","ping","beforeOpen","onopen","emit","buildTimelineMessage","closeEvent","code","reason","wasClean","unbindListeners","onOpen","onclose","onClose","onmessage","onMessage","onactivity","onActivity","info","cid","environment","isSupported","WSTransport","isInitialized","getWebSocketAPI","createWebSocket","httpConfiguration","streamingConfiguration","HTTPFactory","createStreamingSocket","pollingConfiguration","createPollingSocket","xhrConfiguration","isXHRSupported","xhr_streaming","xhr_polling","SockJSTransport","file","SockJS","js_path","ignore_null_origin","ignoreNullOrigin","xdrConfiguration","isXDRSupported","XDRStreamingTransport","XDRPollingTransport","xdr_streaming","xdr_polling","onLine","manager","minPingDelay","maxPingDelay","pingDelay","connection","createConnection","openTimestamp","onClosed","reportDeath","lifespan","Math","max","isAlive","Protocol","decodeMessage","messageEvent","messageData","pusherEventData","pusherEvent","event","channel","user_id","encodeMessage","processHandshake","activity_timeout","action","socket_id","getCloseAction","getCloseError","send_event","listeners","activity","closed","handleCloseEvent","listener","finish","isEmpty","TimelineTransport","pusher","subscribed","subscriptionPending","subscriptionCancelled","socketId","auth","handleSubscriptionSucceededEvent","handleSubscriptionCountEvent","unsubscribe","subscription_count","subscriptionCount","authorize","assign","channel_data","config","channelAuthorizer","channelName","reset","members","member","myID","subscriptionData","presence","hash","count","me","memberData","user_info","authData","channelData","setMyID","user","signinDonePromise","user_data","handleInternalEvent","addedMember","addMember","removedMember","removeMember","onSubscription","disconnect","nacl","sharedSecret","handleEncryptedEvent","handleEvent","ciphertext","nonce","cipherText","secretbox","overheadLength","nonceLength","bytes","getDataToEmit","raw","usingTLS","errorCallbacks","buildErrorCallbacks","connectionCallbacks","buildConnectionCallbacks","handshakeCallbacks","buildHandshakeCallbacks","Network","getNetwork","netinfo","retryIn","sendActivityCheck","updateStrategy","runner","strategy","updateState","startConnecting","setUnavailableTimer","disconnectInternally","handshake","connect","handshakeError","abortConnecting","abort","clearRetryTimer","clearUnavailableTimer","abandonConnection","getStrategy","round","retryTimer","ensureAborted","unavailableTimer","stopActivityCheck","activityTimer","pong_timed_out","resetActivityCheck","shouldRetry","connected","Infinity","setConnection","withErrorEmitted","tls_only","refused","backoff","retry","newState","previousState","newStateDescription","previous","current","channels","createEncryptedChannel","errMsg","createPrivateChannel","createPresenceChannel","createChannel","values","createChannels","createConnectionManager","createTimelineSender","createHandshake","createAssistantToTheTransportManager","livesLeft","lives","strategies","loop","failFast","timeout","timeoutLimit","minPriority","tryNextStrategy","tryStrategy","forceMinPriority","isRunning","callbackBuilder","runners","rs","abortRunner","allRunnersFailed","aborted","transports","ttl","storage","getLocalStorage","serializedCache","getTransportCacheKey","flushTransportCache","fetchTransportCache","cacheSkipCount","timestamp","includes","cached","latency","startTimestamp","pop","cb","storeTransportCache","IfStrategy","trueBranch","falseBranch","FirstConnectedStrategy","testSupportsStrategy","baseOptions","defineTransport","definedTransports","defineTransportStrategy","wsStrategy","ws_options","wsHost","wss_options","sockjs_options","timeouts","ws_manager","streaming_manager","ws_transport","wss_transport","sockjs_transport","xhr_streaming_transport","xdr_streaming_transport","xhr_polling_transport","xdr_polling_transport","ws_loop","wss_loop","sockjs_loop","streaming_loop","polling_loop","http_loop","http_fallback_loop","getRequest","xdr","XDomainRequest","ontimeout","onprogress","onChunk","abortRequest","payload","position","unloader","addUnloadListener","removeUnloadListener","chunk","advanceBuffer","isBufferTooLong","buffer","unreadData","endOfLinePosition","State","autoIncrement","getUniqueURL","separator","randomNumber","randomInt","TimelineLevel","session","randomString","parts","exec","base","getLocation","CONNECTING","openStream","sendRaw","sendHeartbeat","OPEN","createSocketRequest","start","closeStream","CLOSED","onEvent","onHeartbeat","hostname","urlParts","stream","getReceiveURL","onFinished","reconnect","unbind_all","getXHRAPI","createSocket","createRequest","getDefaultStrategy","Transports","load","XMLHttpRequest","WebSocket","MozWebSocket","PusherClass","Pusher","initializeOnDocumentBody","onDocumentBody","ready","getAuthorizers","ajax","jsonp","body","localStorage","createXMLHttpRequest","createMicrosoftXHR","ActiveXObject","createXDR","Constructor","withCredentials","documentProtocol","getProtocol","removeEventListener","detachEvent","floor","crypto","getRandomValues","Uint32Array","events","sent","uniqueID","level","limit","shift","ERROR","INFO","DEBUG","sendfn","bundle","lib","cluster","features","failAttempt","onInitialized","serializedTransport","transportClass","enabledTransports","disabledTransports","getAssistant","deferred","paramsProvider","dynamicParams","composeChannelQuery","getConfig","opts","statsHost","enableStats","getEnableStatsConfig","getHttpHost","shouldUseTLS","getWebsocketHost","userAuthenticator","buildUserAuthenticator","buildChannelAuthorizer","timelineParams","forceTLS","disableStats","customHandler","channelAuthorizerGenerator","deprecatedAuthorizerOptions","ChannelAuthorizerProxy","authorizer","buildChannelAuth","bindWatchlistInternalEvent","forEach","watchlistEvent","resolve","reject","promise","Promise","res","rej","signin_requested","serverToUserChannel","_signinDoneResolve","_onAuthorize","err","_cleanup","_signin","_newSigninPromiseIfNeeded","watchlist","_onSigninSuccess","_subscribeChannels","bind_global","reinstateSubscription","subscribe","ensure_subscribed","done","setDone","then","catch","isReady","instances","app_key","checkAppKey","validateOptions","global_emitter","sessionID","getClientFeatures","timelineSender","subscribeAll","isUsingTLS","internal","appKey","switchCluster","find","all","timelineSenderTimer","event_name","channel_name","cancelSubscription","signin","Runtime","setup"],"mappings":";;;;;;;CAAA,SAA2CA,EAAMC,GAC1B,iBAAZC,SAA0C,iBAAXC,OACxCA,OAAOD,QAAUD,IACQ,mBAAXG,QAAyBA,OAAOC,IAC9CD,OAAO,GAAIH,GACe,iBAAZC,QACdA,QAAgB,OAAID,IAEpBD,EAAa,OAAIC,IARnB,CASGK,QAAQ,WACX,O,YCTE,IAAIC,EAAmB,GAGvB,SAASC,EAAoBC,GAG5B,GAAGF,EAAiBE,GACnB,OAAOF,EAAiBE,GAAUP,QAGnC,IAAIC,EAASI,EAAiBE,GAAY,CACzCC,EAAGD,EACHE,GAAG,EACHT,QAAS,IAUV,OANAU,EAAQH,GAAUI,KAAKV,EAAOD,QAASC,EAAQA,EAAOD,QAASM,GAG/DL,EAAOQ,GAAI,EAGJR,EAA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AAe/b,OAAO2c,EAAYhrB,EAAUiF,GAC1C5H,KAGT,YAAY2C,GAEV,OADA3C,KAAK+sB,eAAeb,YAAYvpB,GACzB3C,KAGT,cAAc2C,GAEZ,OADA3C,KAAK+sB,eAAe9b,cAActO,GAC3B3C,KAGT,WAAW2C,GAET,OADA3C,KAAK+sB,eAAehH,aACb/lB,KAGT,eACE,IAAIyY,EACJ,IAAKA,KAAezY,KAAKie,SAASA,SAC5Bje,KAAKie,SAASA,SAASve,eAAe+Y,IACxCzY,KAAKosB,UAAU3T,GAKrB,UAAUmV,GACR,IAAIrX,EAAUvW,KAAKie,SAASlN,IAAI6c,EAAc5tB,MAS9C,OARIuW,EAAQoB,qBAAuBpB,EAAQqB,sBACzCrB,EAAQ4V,wBAEP5V,EAAQoB,qBACiB,cAA1B3X,KAAKuV,WAAWhE,OAEhBgF,EAAQ6V,YAEH7V,EAGT,YAAYqX,GACV,IAAIrX,EAAUvW,KAAKie,SAASuP,KAAKI,GAC7BrX,GAAWA,EAAQoB,oBACrBpB,EAAQsX,sBAERtX,EAAUvW,KAAKie,SAAS7Y,OAAOwoB,KAChBrX,EAAQmB,YACrBnB,EAAQ0B,cAKd,WAAW0V,EAAoBztB,EAAWqW,GACxC,OAAOvW,KAAKuV,WAAWyB,WAAW2W,EAAYztB,EAAMqW,GAGtD,eACE,OAAOvW,KAAKuY,OAAO1S,OAGrB,SACE7F,KAAKwZ,KAAKsU,UAtOL,GAAAnB,UAAsB,GACtB,GAAAD,SAAmB,EACnB,GAAAjf,cAAwB,EAGxB,GAAAsgB,QAA2B,GAC3B,GAAA5qB,gBAA6B,GAASA,gBACtC,GAAAuB,sBAAmC,GAASA,sBAC5C,GAAAqJ,eAA4B,GAASA,eAVzB,oBAkPrB,GAAQigB,MAAM","file":"pusher.min.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"Pusher\"] = factory();\n\telse\n\t\troot[\"Pusher\"] = factory();\n})(window, function() {\nreturn "," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 2);\n","// Copyright (C) 2016 Dmitry Chestnykh\n// MIT License. See LICENSE file for details.\n\n/**\n * Package base64 implements Base64 encoding and decoding.\n */\n\n// Invalid character used in decoding to indicate\n// that the character to decode is out of range of\n// alphabet and cannot be decoded.\nconst INVALID_BYTE = 256;\n\n/**\n * Implements standard Base64 encoding.\n *\n * Operates in constant time.\n */\nexport class Coder {\n // TODO(dchest): methods to encode chunk-by-chunk.\n\n constructor(private _paddingCharacter = \"=\") { }\n\n encodedLength(length: number): number {\n if (!this._paddingCharacter) {\n return (length * 8 + 5) / 6 | 0;\n }\n return (length + 2) / 3 * 4 | 0;\n }\n\n encode(data: Uint8Array): string {\n let out = \"\";\n\n let i = 0;\n for (; i < data.length - 2; i += 3) {\n let c = (data[i] << 16) | (data[i + 1] << 8) | (data[i + 2]);\n out += this._encodeByte((c >>> 3 * 6) & 63);\n out += this._encodeByte((c >>> 2 * 6) & 63);\n out += this._encodeByte((c >>> 1 * 6) & 63);\n out += this._encodeByte((c >>> 0 * 6) & 63);\n }\n\n const left = data.length - i;\n if (left > 0) {\n let c = (data[i] << 16) | (left === 2 ? data[i + 1] << 8 : 0);\n out += this._encodeByte((c >>> 3 * 6) & 63);\n out += this._encodeByte((c >>> 2 * 6) & 63);\n if (left === 2) {\n out += this._encodeByte((c >>> 1 * 6) & 63);\n } else {\n out += this._paddingCharacter || \"\";\n }\n out += this._paddingCharacter || \"\";\n }\n\n return out;\n }\n\n maxDecodedLength(length: number): number {\n if (!this._paddingCharacter) {\n return (length * 6 + 7) / 8 | 0;\n }\n return length / 4 * 3 | 0;\n }\n\n decodedLength(s: string): number {\n return this.maxDecodedLength(s.length - this._getPaddingLength(s));\n }\n\n decode(s: string): Uint8Array {\n if (s.length === 0) {\n return new Uint8Array(0);\n }\n const paddingLength = this._getPaddingLength(s);\n const length = s.length - paddingLength;\n const out = new Uint8Array(this.maxDecodedLength(length));\n let op = 0;\n let i = 0;\n let haveBad = 0;\n let v0 = 0, v1 = 0, v2 = 0, v3 = 0;\n for (; i < length - 4; i += 4) {\n v0 = this._decodeChar(s.charCodeAt(i + 0));\n v1 = this._decodeChar(s.charCodeAt(i + 1));\n v2 = this._decodeChar(s.charCodeAt(i + 2));\n v3 = this._decodeChar(s.charCodeAt(i + 3));\n out[op++] = (v0 << 2) | (v1 >>> 4);\n out[op++] = (v1 << 4) | (v2 >>> 2);\n out[op++] = (v2 << 6) | v3;\n haveBad |= v0 & INVALID_BYTE;\n haveBad |= v1 & INVALID_BYTE;\n haveBad |= v2 & INVALID_BYTE;\n haveBad |= v3 & INVALID_BYTE;\n }\n if (i < length - 1) {\n v0 = this._decodeChar(s.charCodeAt(i));\n v1 = this._decodeChar(s.charCodeAt(i + 1));\n out[op++] = (v0 << 2) | (v1 >>> 4);\n haveBad |= v0 & INVALID_BYTE;\n haveBad |= v1 & INVALID_BYTE;\n }\n if (i < length - 2) {\n v2 = this._decodeChar(s.charCodeAt(i + 2));\n out[op++] = (v1 << 4) | (v2 >>> 2);\n haveBad |= v2 & INVALID_BYTE;\n }\n if (i < length - 3) {\n v3 = this._decodeChar(s.charCodeAt(i + 3));\n out[op++] = (v2 << 6) | v3;\n haveBad |= v3 & INVALID_BYTE;\n }\n if (haveBad !== 0) {\n throw new Error(\"Base64Coder: incorrect characters for decoding\");\n }\n return out;\n }\n\n // Standard encoding have the following encoded/decoded ranges,\n // which we need to convert between.\n //\n // ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 0123456789 + /\n // Index: 0 - 25 26 - 51 52 - 61 62 63\n // ASCII: 65 - 90 97 - 122 48 - 57 43 47\n //\n\n // Encode 6 bits in b into a new character.\n protected _encodeByte(b: number): string {\n // Encoding uses constant time operations as follows:\n //\n // 1. Define comparison of A with B using (A - B) >>> 8:\n // if A > B, then result is positive integer\n // if A <= B, then result is 0\n //\n // 2. Define selection of C or 0 using bitwise AND: X & C:\n // if X == 0, then result is 0\n // if X != 0, then result is C\n //\n // 3. Start with the smallest comparison (b >= 0), which is always\n // true, so set the result to the starting ASCII value (65).\n //\n // 4. Continue comparing b to higher ASCII values, and selecting\n // zero if comparison isn't true, otherwise selecting a value\n // to add to result, which:\n //\n // a) undoes the previous addition\n // b) provides new value to add\n //\n let result = b;\n // b >= 0\n result += 65;\n // b > 25\n result += ((25 - b) >>> 8) & ((0 - 65) - 26 + 97);\n // b > 51\n result += ((51 - b) >>> 8) & ((26 - 97) - 52 + 48);\n // b > 61\n result += ((61 - b) >>> 8) & ((52 - 48) - 62 + 43);\n // b > 62\n result += ((62 - b) >>> 8) & ((62 - 43) - 63 + 47);\n\n return String.fromCharCode(result);\n }\n\n // Decode a character code into a byte.\n // Must return 256 if character is out of alphabet range.\n protected _decodeChar(c: number): number {\n // Decoding works similar to encoding: using the same comparison\n // function, but now it works on ranges: result is always incremented\n // by value, but this value becomes zero if the range is not\n // satisfied.\n //\n // Decoding starts with invalid value, 256, which is then\n // subtracted when the range is satisfied. If none of the ranges\n // apply, the function returns 256, which is then checked by\n // the caller to throw error.\n let result = INVALID_BYTE; // start with invalid character\n\n // c == 43 (c > 42 and c < 44)\n result += (((42 - c) & (c - 44)) >>> 8) & (-INVALID_BYTE + c - 43 + 62);\n // c == 47 (c > 46 and c < 48)\n result += (((46 - c) & (c - 48)) >>> 8) & (-INVALID_BYTE + c - 47 + 63);\n // c > 47 and c < 58\n result += (((47 - c) & (c - 58)) >>> 8) & (-INVALID_BYTE + c - 48 + 52);\n // c > 64 and c < 91\n result += (((64 - c) & (c - 91)) >>> 8) & (-INVALID_BYTE + c - 65 + 0);\n // c > 96 and c < 123\n result += (((96 - c) & (c - 123)) >>> 8) & (-INVALID_BYTE + c - 97 + 26);\n\n return result;\n }\n\n private _getPaddingLength(s: string): number {\n let paddingLength = 0;\n if (this._paddingCharacter) {\n for (let i = s.length - 1; i >= 0; i--) {\n if (s[i] !== this._paddingCharacter) {\n break;\n }\n paddingLength++;\n }\n if (s.length < 4 || paddingLength > 2) {\n throw new Error(\"Base64Coder: incorrect padding\");\n }\n }\n return paddingLength;\n }\n\n}\n\nconst stdCoder = new Coder();\n\nexport function encode(data: Uint8Array): string {\n return stdCoder.encode(data);\n}\n\nexport function decode(s: string): Uint8Array {\n return stdCoder.decode(s);\n}\n\n/**\n * Implements URL-safe Base64 encoding.\n * (Same as Base64, but '+' is replaced with '-', and '/' with '_').\n *\n * Operates in constant time.\n */\nexport class URLSafeCoder extends Coder {\n // URL-safe encoding have the following encoded/decoded ranges:\n //\n // ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 0123456789 - _\n // Index: 0 - 25 26 - 51 52 - 61 62 63\n // ASCII: 65 - 90 97 - 122 48 - 57 45 95\n //\n\n protected _encodeByte(b: number): string {\n let result = b;\n // b >= 0\n result += 65;\n // b > 25\n result += ((25 - b) >>> 8) & ((0 - 65) - 26 + 97);\n // b > 51\n result += ((51 - b) >>> 8) & ((26 - 97) - 52 + 48);\n // b > 61\n result += ((61 - b) >>> 8) & ((52 - 48) - 62 + 45);\n // b > 62\n result += ((62 - b) >>> 8) & ((62 - 45) - 63 + 95);\n\n return String.fromCharCode(result);\n }\n\n protected _decodeChar(c: number): number {\n let result = INVALID_BYTE;\n\n // c == 45 (c > 44 and c < 46)\n result += (((44 - c) & (c - 46)) >>> 8) & (-INVALID_BYTE + c - 45 + 62);\n // c == 95 (c > 94 and c < 96)\n result += (((94 - c) & (c - 96)) >>> 8) & (-INVALID_BYTE + c - 95 + 63);\n // c > 47 and c < 58\n result += (((47 - c) & (c - 58)) >>> 8) & (-INVALID_BYTE + c - 48 + 52);\n // c > 64 and c < 91\n result += (((64 - c) & (c - 91)) >>> 8) & (-INVALID_BYTE + c - 65 + 0);\n // c > 96 and c < 123\n result += (((96 - c) & (c - 123)) >>> 8) & (-INVALID_BYTE + c - 97 + 26);\n\n return result;\n }\n}\n\nconst urlSafeCoder = new URLSafeCoder();\n\nexport function encodeURLSafe(data: Uint8Array): string {\n return urlSafeCoder.encode(data);\n}\n\nexport function decodeURLSafe(s: string): Uint8Array {\n return urlSafeCoder.decode(s);\n}\n\n\nexport const encodedLength = (length: number) =>\n stdCoder.encodedLength(length);\n\nexport const maxDecodedLength = (length: number) =>\n stdCoder.maxDecodedLength(length);\n\nexport const decodedLength = (s: string) =>\n stdCoder.decodedLength(s);\n","// Copyright (C) 2016 Dmitry Chestnykh\n// MIT License. See LICENSE file for details.\n\n/**\n * Package utf8 implements UTF-8 encoding and decoding.\n */\n\nconst INVALID_UTF16 = \"utf8: invalid string\";\nconst INVALID_UTF8 = \"utf8: invalid source encoding\";\n\n/**\n * Encodes the given string into UTF-8 byte array.\n * Throws if the source string has invalid UTF-16 encoding.\n */\nexport function encode(s: string): Uint8Array {\n // Calculate result length and allocate output array.\n // encodedLength() also validates string and throws errors,\n // so we don't need repeat validation here.\n const arr = new Uint8Array(encodedLength(s));\n\n let pos = 0;\n for (let i = 0; i < s.length; i++) {\n let c = s.charCodeAt(i);\n if (c < 0x80) {\n arr[pos++] = c;\n } else if (c < 0x800) {\n arr[pos++] = 0xc0 | c >> 6;\n arr[pos++] = 0x80 | c & 0x3f;\n } else if (c < 0xd800) {\n arr[pos++] = 0xe0 | c >> 12;\n arr[pos++] = 0x80 | (c >> 6) & 0x3f;\n arr[pos++] = 0x80 | c & 0x3f;\n } else {\n i++; // get one more character\n c = (c & 0x3ff) << 10;\n c |= s.charCodeAt(i) & 0x3ff;\n c += 0x10000;\n\n arr[pos++] = 0xf0 | c >> 18;\n arr[pos++] = 0x80 | (c >> 12) & 0x3f;\n arr[pos++] = 0x80 | (c >> 6) & 0x3f;\n arr[pos++] = 0x80 | c & 0x3f;\n }\n }\n return arr;\n}\n\n/**\n * Returns the number of bytes required to encode the given string into UTF-8.\n * Throws if the source string has invalid UTF-16 encoding.\n */\nexport function encodedLength(s: string): number {\n let result = 0;\n for (let i = 0; i < s.length; i++) {\n const c = s.charCodeAt(i);\n if (c < 0x80) {\n result += 1;\n } else if (c < 0x800) {\n result += 2;\n } else if (c < 0xd800) {\n result += 3;\n } else if (c <= 0xdfff) {\n if (i >= s.length - 1) {\n throw new Error(INVALID_UTF16);\n }\n i++; // \"eat\" next character\n result += 4;\n } else {\n throw new Error(INVALID_UTF16);\n }\n }\n return result;\n}\n\n/**\n * Decodes the given byte array from UTF-8 into a string.\n * Throws if encoding is invalid.\n */\nexport function decode(arr: Uint8Array): string {\n const chars: string[] = [];\n for (let i = 0; i < arr.length; i++) {\n let b = arr[i];\n\n if (b & 0x80) {\n let min;\n if (b < 0xe0) {\n // Need 1 more byte.\n if (i >= arr.length) {\n throw new Error(INVALID_UTF8);\n }\n const n1 = arr[++i];\n if ((n1 & 0xc0) !== 0x80) {\n throw new Error(INVALID_UTF8);\n }\n b = (b & 0x1f) << 6 | (n1 & 0x3f);\n min = 0x80;\n } else if (b < 0xf0) {\n // Need 2 more bytes.\n if (i >= arr.length - 1) {\n throw new Error(INVALID_UTF8);\n }\n const n1 = arr[++i];\n const n2 = arr[++i];\n if ((n1 & 0xc0) !== 0x80 || (n2 & 0xc0) !== 0x80) {\n throw new Error(INVALID_UTF8);\n }\n b = (b & 0x0f) << 12 | (n1 & 0x3f) << 6 | (n2 & 0x3f);\n min = 0x800;\n } else if (b < 0xf8) {\n // Need 3 more bytes.\n if (i >= arr.length - 2) {\n throw new Error(INVALID_UTF8);\n }\n const n1 = arr[++i];\n const n2 = arr[++i];\n const n3 = arr[++i];\n if ((n1 & 0xc0) !== 0x80 || (n2 & 0xc0) !== 0x80 || (n3 & 0xc0) !== 0x80) {\n throw new Error(INVALID_UTF8);\n }\n b = (b & 0x0f) << 18 | (n1 & 0x3f) << 12 | (n2 & 0x3f) << 6 | (n3 & 0x3f);\n min = 0x10000;\n } else {\n throw new Error(INVALID_UTF8);\n }\n\n if (b < min || (b >= 0xd800 && b <= 0xdfff)) {\n throw new Error(INVALID_UTF8);\n }\n\n if (b >= 0x10000) {\n // Surrogate pair.\n if (b > 0x10ffff) {\n throw new Error(INVALID_UTF8);\n }\n b -= 0x10000;\n chars.push(String.fromCharCode(0xd800 | (b >> 10)));\n b = 0xdc00 | (b & 0x3ff);\n }\n }\n\n chars.push(String.fromCharCode(b));\n }\n return chars.join(\"\");\n}\n","// required so we don't have to do require('pusher').default etc.\nmodule.exports = require('./pusher').default;\n","import ScriptReceiver from './script_receiver';\n\n/** Builds receivers for JSONP and Script requests.\n *\n * Each receiver is an object with following fields:\n * - number - unique (for the factory instance), numerical id of the receiver\n * - id - a string ID that can be used in DOM attributes\n * - name - name of the function triggering the receiver\n * - callback - callback function\n *\n * Receivers are triggered only once, on the first callback call.\n *\n * Receivers can be called by their name or by accessing factory object\n * by the number key.\n *\n * @param {String} prefix the prefix used in ids\n * @param {String} name the name of the object\n */\nexport class ScriptReceiverFactory {\n lastId: number;\n prefix: string;\n name: string;\n\n constructor(prefix: string, name: string) {\n this.lastId = 0;\n this.prefix = prefix;\n this.name = name;\n }\n\n create(callback: Function): ScriptReceiver {\n this.lastId++;\n\n var number = this.lastId;\n var id = this.prefix + number;\n var name = this.name + '[' + number + ']';\n\n var called = false;\n var callbackWrapper = function() {\n if (!called) {\n callback.apply(null, arguments);\n called = true;\n }\n };\n\n this[number] = callbackWrapper;\n return { number: number, id: id, name: name, callback: callbackWrapper };\n }\n\n remove(receiver: ScriptReceiver) {\n delete this[receiver.number];\n }\n}\n\nexport var ScriptReceivers = new ScriptReceiverFactory(\n '_pusher_script_',\n 'Pusher.ScriptReceivers'\n);\n","import {\n ChannelAuthorizationOptions,\n UserAuthenticationOptions\n} from './auth/options';\nimport { AuthTransport } from './config';\n\nexport interface DefaultConfig {\n VERSION: string;\n PROTOCOL: number;\n wsPort: number;\n wssPort: number;\n wsPath: string;\n httpHost: string;\n httpPort: number;\n httpsPort: number;\n httpPath: string;\n stats_host: string;\n authEndpoint: string;\n authTransport: AuthTransport;\n activityTimeout: number;\n pongTimeout: number;\n unavailableTimeout: number;\n userAuthentication: UserAuthenticationOptions;\n channelAuthorization: ChannelAuthorizationOptions;\n\n cdn_http?: string;\n cdn_https?: string;\n dependency_suffix?: string;\n}\n\nvar Defaults: DefaultConfig = {\n VERSION: VERSION,\n PROTOCOL: 7,\n\n wsPort: 80,\n wssPort: 443,\n wsPath: '',\n // DEPRECATED: SockJS fallback parameters\n httpHost: 'sockjs.pusher.com',\n httpPort: 80,\n httpsPort: 443,\n httpPath: '/pusher',\n // DEPRECATED: Stats\n stats_host: 'stats.pusher.com',\n // DEPRECATED: Other settings\n authEndpoint: '/pusher/auth',\n authTransport: 'ajax',\n activityTimeout: 120000,\n pongTimeout: 30000,\n unavailableTimeout: 10000,\n userAuthentication: {\n endpoint: '/pusher/user-auth',\n transport: 'ajax'\n },\n channelAuthorization: {\n endpoint: '/pusher/auth',\n transport: 'ajax'\n },\n\n // CDN configuration\n cdn_http: CDN_HTTP,\n cdn_https: CDN_HTTPS,\n dependency_suffix: DEPENDENCY_SUFFIX\n};\n\nexport default Defaults;\n","import { ScriptReceiverFactory } from './script_receiver_factory';\nimport Defaults from 'core/defaults';\nimport DependencyLoader from './dependency_loader';\n\nexport var DependenciesReceivers = new ScriptReceiverFactory(\n '_pusher_dependencies',\n 'Pusher.DependenciesReceivers'\n);\n\nexport var Dependencies = new DependencyLoader({\n cdn_http: Defaults.cdn_http,\n cdn_https: Defaults.cdn_https,\n version: Defaults.VERSION,\n suffix: Defaults.dependency_suffix,\n receivers: DependenciesReceivers\n});\n","import {\n ScriptReceivers,\n ScriptReceiverFactory\n} from './script_receiver_factory';\nimport Runtime from 'runtime';\nimport ScriptRequest from './script_request';\n\n/** Handles loading dependency files.\n *\n * Dependency loaders don't remember whether a resource has been loaded or\n * not. It is caller's responsibility to make sure the resource is not loaded\n * twice. This is because it's impossible to detect resource loading status\n * without knowing its content.\n *\n * Options:\n * - cdn_http - url to HTTP CND\n * - cdn_https - url to HTTPS CDN\n * - version - version of pusher-js\n * - suffix - suffix appended to all names of dependency files\n *\n * @param {Object} options\n */\nexport default class DependencyLoader {\n options: any;\n receivers: ScriptReceiverFactory;\n loading: any;\n\n constructor(options: any) {\n this.options = options;\n this.receivers = options.receivers || ScriptReceivers;\n this.loading = {};\n }\n\n /** Loads the dependency from CDN.\n *\n * @param {String} name\n * @param {Function} callback\n */\n load(name: string, options: any, callback: Function) {\n var self = this;\n\n if (self.loading[name] && self.loading[name].length > 0) {\n self.loading[name].push(callback);\n } else {\n self.loading[name] = [callback];\n\n var request = Runtime.createScriptRequest(self.getPath(name, options));\n var receiver = self.receivers.create(function(error) {\n self.receivers.remove(receiver);\n\n if (self.loading[name]) {\n var callbacks = self.loading[name];\n delete self.loading[name];\n\n var successCallback = function(wasSuccessful) {\n if (!wasSuccessful) {\n request.cleanup();\n }\n };\n for (var i = 0; i < callbacks.length; i++) {\n callbacks[i](error, successCallback);\n }\n }\n });\n request.send(receiver);\n }\n }\n\n /** Returns a root URL for pusher-js CDN.\n *\n * @returns {String}\n */\n getRoot(options: any): string {\n var cdn;\n var protocol = Runtime.getDocument().location.protocol;\n if ((options && options.useTLS) || protocol === 'https:') {\n cdn = this.options.cdn_https;\n } else {\n cdn = this.options.cdn_http;\n }\n // make sure there are no double slashes\n return cdn.replace(/\\/*$/, '') + '/' + this.options.version;\n }\n\n /** Returns a full path to a dependency file.\n *\n * @param {String} name\n * @returns {String}\n */\n getPath(name: string, options: any): string {\n return this.getRoot(options) + '/' + name + this.options.suffix + '.js';\n }\n}\n","/**\n * A place to store help URLs for error messages etc\n */\n\nconst urlStore = {\n baseUrl: 'https://pusher.com',\n urls: {\n authenticationEndpoint: {\n path: '/docs/channels/server_api/authenticating_users'\n },\n authorizationEndpoint: {\n path: '/docs/channels/server_api/authorizing-users/'\n },\n javascriptQuickStart: {\n path: '/docs/javascript_quick_start'\n },\n triggeringClientEvents: {\n path: '/docs/client_api_guide/client_events#trigger-events'\n },\n encryptedChannelSupport: {\n fullUrl:\n 'https://github.com/pusher/pusher-js/tree/cc491015371a4bde5743d1c87a0fbac0feb53195#encrypted-channel-support'\n }\n }\n};\n\n/** Builds a consistent string with links to pusher documentation\n *\n * @param {string} key - relevant key in the url_store.urls object\n * @return {string} suffix string to append to log message\n */\nconst buildLogSuffix = function(key: string): string {\n const urlPrefix = 'See:';\n const urlObj = urlStore.urls[key];\n if (!urlObj) return '';\n\n let url;\n if (urlObj.fullUrl) {\n url = urlObj.fullUrl;\n } else if (urlObj.path) {\n url = urlStore.baseUrl + urlObj.path;\n }\n\n if (!url) return '';\n return `${urlPrefix} ${url}`;\n};\n\nexport default { buildLogSuffix };\n","export enum AuthRequestType {\n UserAuthentication = 'user-authentication',\n ChannelAuthorization = 'channel-authorization'\n}\n\nexport interface ChannelAuthorizationData {\n auth: string;\n channel_data?: string;\n shared_secret?: string;\n}\n\nexport type ChannelAuthorizationCallback = (\n error: Error | null,\n authData: ChannelAuthorizationData | null\n) => void;\n\nexport interface ChannelAuthorizationRequestParams {\n socketId: string;\n channelName: string;\n}\n\nexport interface ChannelAuthorizationHandler {\n (\n params: ChannelAuthorizationRequestParams,\n callback: ChannelAuthorizationCallback\n ): void;\n}\n\nexport interface UserAuthenticationData {\n auth: string;\n user_data: string;\n}\n\nexport type UserAuthenticationCallback = (\n error: Error | null,\n authData: UserAuthenticationData | null\n) => void;\n\nexport interface UserAuthenticationRequestParams {\n socketId: string;\n}\n\nexport interface UserAuthenticationHandler {\n (\n params: UserAuthenticationRequestParams,\n callback: UserAuthenticationCallback\n ): void;\n}\n\nexport type AuthTransportCallback =\n | ChannelAuthorizationCallback\n | UserAuthenticationCallback;\n\nexport interface AuthOptionsT {\n transport: 'ajax' | 'jsonp';\n endpoint: string;\n params?: any;\n headers?: any;\n paramsProvider?: () => any;\n headersProvider?: () => any;\n customHandler?: AuthHandler;\n}\n\nexport declare type UserAuthenticationOptions = AuthOptionsT<\n UserAuthenticationHandler\n>;\nexport declare type ChannelAuthorizationOptions = AuthOptionsT<\n ChannelAuthorizationHandler\n>;\n\nexport interface InternalAuthOptions {\n transport: 'ajax' | 'jsonp';\n endpoint: string;\n params?: any;\n headers?: any;\n paramsProvider?: () => any;\n headersProvider?: () => any;\n}\n","/** Error classes used throughout the library. */\n// https://github.com/Microsoft/TypeScript-wiki/blob/master/Breaking-Changes.md#extending-built-ins-like-error-array-and-map-may-no-longer-work\nexport class BadEventName extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\nexport class BadChannelName extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\nexport class RequestTimedOut extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class TransportPriorityTooLow extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class TransportClosed extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class UnsupportedFeature extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class UnsupportedTransport extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class UnsupportedStrategy extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class HTTPAuthError extends Error {\n status: number;\n constructor(status: number, msg?: string) {\n super(msg);\n this.status = status;\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n","import TimelineSender from 'core/timeline/timeline_sender';\nimport * as Collections from 'core/utils/collections';\nimport Util from 'core/util';\nimport Runtime from 'runtime';\nimport { AuthTransport } from 'core/auth/auth_transports';\nimport AbstractRuntime from 'runtimes/interface';\nimport UrlStore from 'core/utils/url_store';\nimport {\n AuthRequestType,\n AuthTransportCallback,\n InternalAuthOptions\n} from 'core/auth/options';\nimport { HTTPAuthError } from 'core/errors';\n\nconst ajax: AuthTransport = function(\n context: AbstractRuntime,\n query: string,\n authOptions: InternalAuthOptions,\n authRequestType: AuthRequestType,\n callback: AuthTransportCallback\n) {\n const xhr = Runtime.createXHR();\n xhr.open('POST', authOptions.endpoint, true);\n\n // add request headers\n xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');\n for (var headerName in authOptions.headers) {\n xhr.setRequestHeader(headerName, authOptions.headers[headerName]);\n }\n if (authOptions.headersProvider != null) {\n let dynamicHeaders = authOptions.headersProvider();\n for (var headerName in dynamicHeaders) {\n xhr.setRequestHeader(headerName, dynamicHeaders[headerName]);\n }\n }\n\n xhr.onreadystatechange = function() {\n if (xhr.readyState === 4) {\n if (xhr.status === 200) {\n let data;\n let parsed = false;\n\n try {\n data = JSON.parse(xhr.responseText);\n parsed = true;\n } catch (e) {\n callback(\n new HTTPAuthError(\n 200,\n `JSON returned from ${authRequestType.toString()} endpoint was invalid, yet status code was 200. Data was: ${\n xhr.responseText\n }`\n ),\n null\n );\n }\n\n if (parsed) {\n // prevents double execution.\n callback(null, data);\n }\n } else {\n let suffix = '';\n switch (authRequestType) {\n case AuthRequestType.UserAuthentication:\n suffix = UrlStore.buildLogSuffix('authenticationEndpoint');\n break;\n case AuthRequestType.ChannelAuthorization:\n suffix = `Clients must be authorized to join private or presence channels. ${UrlStore.buildLogSuffix(\n 'authorizationEndpoint'\n )}`;\n break;\n }\n callback(\n new HTTPAuthError(\n xhr.status,\n `Unable to retrieve auth string from ${authRequestType.toString()} endpoint - ` +\n `received status: ${xhr.status} from ${authOptions.endpoint}. ${suffix}`\n ),\n null\n );\n }\n }\n };\n\n xhr.send(query);\n return xhr;\n};\n\nexport default ajax;\n","export default function encode(s: any): string {\n return btoa(utob(s));\n}\n\nvar fromCharCode = String.fromCharCode;\n\nvar b64chars =\n 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';\nvar b64tab = {};\n\nfor (var i = 0, l = b64chars.length; i < l; i++) {\n b64tab[b64chars.charAt(i)] = i;\n}\n\nvar cb_utob = function(c) {\n var cc = c.charCodeAt(0);\n return cc < 0x80\n ? c\n : cc < 0x800\n ? fromCharCode(0xc0 | (cc >>> 6)) + fromCharCode(0x80 | (cc & 0x3f))\n : fromCharCode(0xe0 | ((cc >>> 12) & 0x0f)) +\n fromCharCode(0x80 | ((cc >>> 6) & 0x3f)) +\n fromCharCode(0x80 | (cc & 0x3f));\n};\n\nvar utob = function(u) {\n return u.replace(/[^\\x00-\\x7F]/g, cb_utob);\n};\n\nvar cb_encode = function(ccc) {\n var padlen = [0, 2, 1][ccc.length % 3];\n var ord =\n (ccc.charCodeAt(0) << 16) |\n ((ccc.length > 1 ? ccc.charCodeAt(1) : 0) << 8) |\n (ccc.length > 2 ? ccc.charCodeAt(2) : 0);\n var chars = [\n b64chars.charAt(ord >>> 18),\n b64chars.charAt((ord >>> 12) & 63),\n padlen >= 2 ? '=' : b64chars.charAt((ord >>> 6) & 63),\n padlen >= 1 ? '=' : b64chars.charAt(ord & 63)\n ];\n return chars.join('');\n};\n\nvar btoa =\n global.btoa ||\n function(b) {\n return b.replace(/[\\s\\S]{1,3}/g, cb_encode);\n };\n","import TimedCallback from './timed_callback';\nimport { Delay, Scheduler, Canceller } from './scheduling';\n\nabstract class Timer {\n protected clear: Canceller;\n protected timer: number | void;\n\n constructor(\n set: Scheduler,\n clear: Canceller,\n delay: Delay,\n callback: TimedCallback\n ) {\n this.clear = clear;\n this.timer = set(() => {\n if (this.timer) {\n this.timer = callback(this.timer);\n }\n }, delay);\n }\n\n /** Returns whether the timer is still running.\n *\n * @return {Boolean}\n */\n isRunning(): boolean {\n return this.timer !== null;\n }\n\n /** Aborts a timer when it's running. */\n ensureAborted() {\n if (this.timer) {\n this.clear(this.timer);\n this.timer = null;\n }\n }\n}\n\nexport default Timer;\n","import Timer from './abstract_timer';\nimport TimedCallback from './timed_callback';\nimport { Delay } from './scheduling';\n\n// We need to bind clear functions this way to avoid exceptions on IE8\nfunction clearTimeout(timer) {\n global.clearTimeout(timer);\n}\nfunction clearInterval(timer) {\n global.clearInterval(timer);\n}\n\n/** Cross-browser compatible one-off timer abstraction.\n *\n * @param {Number} delay\n * @param {Function} callback\n */\nexport class OneOffTimer extends Timer {\n constructor(delay: Delay, callback: TimedCallback) {\n super(setTimeout, clearTimeout, delay, function(timer) {\n callback();\n return null;\n });\n }\n}\n\n/** Cross-browser compatible periodic timer abstraction.\n *\n * @param {Number} delay\n * @param {Function} callback\n */\nexport class PeriodicTimer extends Timer {\n constructor(delay: Delay, callback: TimedCallback) {\n super(setInterval, clearInterval, delay, function(timer) {\n callback();\n return timer;\n });\n }\n}\n","import * as Collections from './utils/collections';\nimport TimedCallback from './utils/timers/timed_callback';\nimport { OneOffTimer, PeriodicTimer } from './utils/timers';\n\nvar Util = {\n now(): number {\n if (Date.now) {\n return Date.now();\n } else {\n return new Date().valueOf();\n }\n },\n\n defer(callback: TimedCallback): OneOffTimer {\n return new OneOffTimer(0, callback);\n },\n\n /** Builds a function that will proxy a method call to its first argument.\n *\n * Allows partial application of arguments, so additional arguments are\n * prepended to the argument list.\n *\n * @param {String} name method name\n * @return {Function} proxy function\n */\n method(name: string, ...args: any[]): Function {\n var boundArguments = Array.prototype.slice.call(arguments, 1);\n return function(object) {\n return object[name].apply(object, boundArguments.concat(arguments));\n };\n }\n};\n\nexport default Util;\n","import base64encode from '../base64';\nimport Util from '../util';\n\n/** Merges multiple objects into the target argument.\n *\n * For properties that are plain Objects, performs a deep-merge. For the\n * rest it just copies the value of the property.\n *\n * To extend prototypes use it as following:\n * Pusher.Util.extend(Target.prototype, Base.prototype)\n *\n * You can also use it to merge objects without altering them:\n * Pusher.Util.extend({}, object1, object2)\n *\n * @param {Object} target\n * @return {Object} the target argument\n */\nexport function extend(target: any, ...sources: any[]): T {\n for (var i = 0; i < sources.length; i++) {\n var extensions = sources[i];\n for (var property in extensions) {\n if (\n extensions[property] &&\n extensions[property].constructor &&\n extensions[property].constructor === Object\n ) {\n target[property] = extend(target[property] || {}, extensions[property]);\n } else {\n target[property] = extensions[property];\n }\n }\n }\n return target;\n}\n\nexport function stringify(): string {\n var m = ['Pusher'];\n for (var i = 0; i < arguments.length; i++) {\n if (typeof arguments[i] === 'string') {\n m.push(arguments[i]);\n } else {\n m.push(safeJSONStringify(arguments[i]));\n }\n }\n return m.join(' : ');\n}\n\nexport function arrayIndexOf(array: any[], item: any): number {\n // MSIE doesn't have array.indexOf\n var nativeIndexOf = Array.prototype.indexOf;\n if (array === null) {\n return -1;\n }\n if (nativeIndexOf && array.indexOf === nativeIndexOf) {\n return array.indexOf(item);\n }\n for (var i = 0, l = array.length; i < l; i++) {\n if (array[i] === item) {\n return i;\n }\n }\n return -1;\n}\n\n/** Applies a function f to all properties of an object.\n *\n * Function f gets 3 arguments passed:\n * - element from the object\n * - key of the element\n * - reference to the object\n *\n * @param {Object} object\n * @param {Function} f\n */\nexport function objectApply(object: any, f: Function) {\n for (var key in object) {\n if (Object.prototype.hasOwnProperty.call(object, key)) {\n f(object[key], key, object);\n }\n }\n}\n\n/** Return a list of objects own proerty keys\n *\n * @param {Object} object\n * @returns {Array}\n */\nexport function keys(object: any): string[] {\n var keys = [];\n objectApply(object, function(_, key) {\n keys.push(key);\n });\n return keys;\n}\n\n/** Return a list of object's own property values\n *\n * @param {Object} object\n * @returns {Array}\n */\nexport function values(object: any): any[] {\n var values = [];\n objectApply(object, function(value) {\n values.push(value);\n });\n return values;\n}\n\n/** Applies a function f to all elements of an array.\n *\n * Function f gets 3 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function apply(array: any[], f: Function, context?: any) {\n for (var i = 0; i < array.length; i++) {\n f.call(context || global, array[i], i, array);\n }\n}\n\n/** Maps all elements of the array and returns the result.\n *\n * Function f gets 4 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n * - reference to the destination array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function map(array: any[], f: Function): any[] {\n var result = [];\n for (var i = 0; i < array.length; i++) {\n result.push(f(array[i], i, array, result));\n }\n return result;\n}\n\n/** Maps all elements of the object and returns the result.\n *\n * Function f gets 4 arguments passed:\n * - element from the object\n * - key of the element\n * - reference to the source object\n * - reference to the destination object\n *\n * @param {Object} object\n * @param {Function} f\n */\nexport function mapObject(object: any, f: Function): any {\n var result = {};\n objectApply(object, function(value, key) {\n result[key] = f(value);\n });\n return result;\n}\n\n/** Filters elements of the array using a test function.\n *\n * Function test gets 4 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n * - reference to the destination array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function filter(array: any[], test: Function): any[] {\n test =\n test ||\n function(value) {\n return !!value;\n };\n\n var result = [];\n for (var i = 0; i < array.length; i++) {\n if (test(array[i], i, array, result)) {\n result.push(array[i]);\n }\n }\n return result;\n}\n\n/** Filters properties of the object using a test function.\n *\n * Function test gets 4 arguments passed:\n * - element from the object\n * - key of the element\n * - reference to the source object\n * - reference to the destination object\n *\n * @param {Object} object\n * @param {Function} f\n */\nexport function filterObject(object: Object, test: Function) {\n var result = {};\n objectApply(object, function(value, key) {\n if ((test && test(value, key, object, result)) || Boolean(value)) {\n result[key] = value;\n }\n });\n return result;\n}\n\n/** Flattens an object into a two-dimensional array.\n *\n * @param {Object} object\n * @return {Array} resulting array of [key, value] pairs\n */\nexport function flatten(object: Object): any[] {\n var result = [];\n objectApply(object, function(value, key) {\n result.push([key, value]);\n });\n return result;\n}\n\n/** Checks whether any element of the array passes the test.\n *\n * Function test gets 3 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function any(array: any[], test: Function): boolean {\n for (var i = 0; i < array.length; i++) {\n if (test(array[i], i, array)) {\n return true;\n }\n }\n return false;\n}\n\n/** Checks whether all elements of the array pass the test.\n *\n * Function test gets 3 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function all(array: any[], test: Function): boolean {\n for (var i = 0; i < array.length; i++) {\n if (!test(array[i], i, array)) {\n return false;\n }\n }\n return true;\n}\n\nexport function encodeParamsObject(data): string {\n return mapObject(data, function(value) {\n if (typeof value === 'object') {\n value = safeJSONStringify(value);\n }\n return encodeURIComponent(base64encode(value.toString()));\n });\n}\n\nexport function buildQueryString(data: any): string {\n var params = filterObject(data, function(value) {\n return value !== undefined;\n });\n\n var query = map(\n flatten(encodeParamsObject(params)),\n Util.method('join', '=')\n ).join('&');\n\n return query;\n}\n\n/**\n * See https://github.com/douglascrockford/JSON-js/blob/master/cycle.js\n *\n * Remove circular references from an object. Required for JSON.stringify in\n * React Native, which tends to blow up a lot.\n *\n * @param {any} object\n * @return {any} Decycled object\n */\nexport function decycleObject(object: any): any {\n var objects = [],\n paths = [];\n\n return (function derez(value, path) {\n var i, name, nu;\n\n switch (typeof value) {\n case 'object':\n if (!value) {\n return null;\n }\n for (i = 0; i < objects.length; i += 1) {\n if (objects[i] === value) {\n return { $ref: paths[i] };\n }\n }\n\n objects.push(value);\n paths.push(path);\n\n if (Object.prototype.toString.apply(value) === '[object Array]') {\n nu = [];\n for (i = 0; i < value.length; i += 1) {\n nu[i] = derez(value[i], path + '[' + i + ']');\n }\n } else {\n nu = {};\n for (name in value) {\n if (Object.prototype.hasOwnProperty.call(value, name)) {\n nu[name] = derez(\n value[name],\n path + '[' + JSON.stringify(name) + ']'\n );\n }\n }\n }\n return nu;\n case 'number':\n case 'string':\n case 'boolean':\n return value;\n }\n })(object, '$');\n}\n\n/**\n * Provides a cross-browser and cross-platform way to safely stringify objects\n * into JSON. This is particularly necessary for ReactNative, where circular JSON\n * structures throw an exception.\n *\n * @param {any} source The object to stringify\n * @return {string} The serialized output.\n */\nexport function safeJSONStringify(source: any): string {\n try {\n return JSON.stringify(source);\n } catch (e) {\n return JSON.stringify(decycleObject(source));\n }\n}\n","import { stringify } from './utils/collections';\nimport Pusher from './pusher';\n\nclass Logger {\n debug(...args: any[]) {\n this.log(this.globalLog, args);\n }\n\n warn(...args: any[]) {\n this.log(this.globalLogWarn, args);\n }\n\n error(...args: any[]) {\n this.log(this.globalLogError, args);\n }\n\n private globalLog = (message: string) => {\n if (global.console && global.console.log) {\n global.console.log(message);\n }\n };\n\n private globalLogWarn(message: string) {\n if (global.console && global.console.warn) {\n global.console.warn(message);\n } else {\n this.globalLog(message);\n }\n }\n\n private globalLogError(message: string) {\n if (global.console && global.console.error) {\n global.console.error(message);\n } else {\n this.globalLogWarn(message);\n }\n }\n\n private log(\n defaultLoggingFunction: (message: string) => void,\n ...args: any[]\n ) {\n var message = stringify.apply(this, arguments);\n if (Pusher.log) {\n Pusher.log(message);\n } else if (Pusher.logToConsole) {\n const log = defaultLoggingFunction.bind(this);\n log(message);\n }\n }\n}\n\nexport default new Logger();\n","import Browser from '../browser';\nimport Logger from 'core/logger';\nimport JSONPRequest from '../dom/jsonp_request';\nimport { ScriptReceivers } from '../dom/script_receiver_factory';\nimport { AuthTransport } from 'core/auth/auth_transports';\nimport {\n AuthRequestType,\n AuthTransportCallback,\n InternalAuthOptions\n} from 'core/auth/options';\n\nvar jsonp: AuthTransport = function(\n context: Browser,\n query: string,\n authOptions: InternalAuthOptions,\n authRequestType: AuthRequestType,\n callback: AuthTransportCallback\n) {\n if (\n authOptions.headers !== undefined ||\n authOptions.headersProvider != null\n ) {\n Logger.warn(\n `To send headers with the ${authRequestType.toString()} request, you must use AJAX, rather than JSONP.`\n );\n }\n\n var callbackName = context.nextAuthCallbackID.toString();\n context.nextAuthCallbackID++;\n\n var document = context.getDocument();\n var script = document.createElement('script');\n // Hacked wrapper.\n context.auth_callbacks[callbackName] = function(data) {\n callback(null, data);\n };\n\n var callback_name = \"Pusher.auth_callbacks['\" + callbackName + \"']\";\n script.src =\n authOptions.endpoint +\n '?callback=' +\n encodeURIComponent(callback_name) +\n '&' +\n query;\n\n var head =\n document.getElementsByTagName('head')[0] || document.documentElement;\n head.insertBefore(script, head.firstChild);\n};\n\nexport default jsonp;\n","import ScriptReceiver from './script_receiver';\n\n/** Sends a generic HTTP GET request using a script tag.\n *\n * By constructing URL in a specific way, it can be used for loading\n * JavaScript resources or JSONP requests. It can notify about errors, but\n * only in certain environments. Please take care of monitoring the state of\n * the request yourself.\n *\n * @param {String} src\n */\nexport default class ScriptRequest {\n src: string;\n script: any;\n errorScript: any;\n\n constructor(src: string) {\n this.src = src;\n }\n\n send(receiver: ScriptReceiver) {\n var self = this;\n var errorString = 'Error loading ' + self.src;\n\n self.script = document.createElement('script');\n self.script.id = receiver.id;\n self.script.src = self.src;\n self.script.type = 'text/javascript';\n self.script.charset = 'UTF-8';\n\n if (self.script.addEventListener) {\n self.script.onerror = function() {\n receiver.callback(errorString);\n };\n self.script.onload = function() {\n receiver.callback(null);\n };\n } else {\n self.script.onreadystatechange = function() {\n if (\n self.script.readyState === 'loaded' ||\n self.script.readyState === 'complete'\n ) {\n receiver.callback(null);\n }\n };\n }\n\n // Opera<11.6 hack for missing onerror callback\n if (\n self.script.async === undefined &&\n (document).attachEvent &&\n /opera/i.test(navigator.userAgent)\n ) {\n self.errorScript = document.createElement('script');\n self.errorScript.id = receiver.id + '_error';\n self.errorScript.text = receiver.name + \"('\" + errorString + \"');\";\n self.script.async = self.errorScript.async = false;\n } else {\n self.script.async = true;\n }\n\n var head = document.getElementsByTagName('head')[0];\n head.insertBefore(self.script, head.firstChild);\n if (self.errorScript) {\n head.insertBefore(self.errorScript, self.script.nextSibling);\n }\n }\n\n /** Cleans up the DOM remains of the script request. */\n cleanup() {\n if (this.script) {\n this.script.onload = this.script.onerror = null;\n this.script.onreadystatechange = null;\n }\n if (this.script && this.script.parentNode) {\n this.script.parentNode.removeChild(this.script);\n }\n if (this.errorScript && this.errorScript.parentNode) {\n this.errorScript.parentNode.removeChild(this.errorScript);\n }\n this.script = null;\n this.errorScript = null;\n }\n}\n","import ScriptReceiver from './script_receiver';\nimport ScriptRequest from './script_request';\nimport * as Collections from 'core/utils/collections';\nimport Util from 'core/util';\nimport Runtime from '../runtime';\n\n/** Sends data via JSONP.\n *\n * Data is a key-value map. Its values are JSON-encoded and then passed\n * through base64. Finally, keys and encoded values are appended to the query\n * string.\n *\n * The class itself does not guarantee raising errors on failures, as it's not\n * possible to support such feature on all browsers. Instead, JSONP endpoint\n * should call back in a way that's easy to distinguish from browser calls,\n * for example by passing a second argument to the receiver.\n *\n * @param {String} url\n * @param {Object} data key-value map of data to be submitted\n */\nexport default class JSONPRequest {\n url: string;\n data: any;\n request: ScriptRequest;\n\n constructor(url: string, data: any) {\n this.url = url;\n this.data = data;\n }\n\n /** Sends the actual JSONP request.\n *\n * @param {ScriptReceiver} receiver\n */\n send(receiver: ScriptReceiver) {\n if (this.request) {\n return;\n }\n\n var query = Collections.buildQueryString(this.data);\n var url = this.url + '/' + receiver.number + '?' + query;\n this.request = Runtime.createScriptRequest(url);\n this.request.send(receiver);\n }\n\n /** Cleans up the DOM remains of the JSONP request. */\n cleanup() {\n if (this.request) {\n this.request.cleanup();\n }\n }\n}\n","import TimelineSender from 'core/timeline/timeline_sender';\nimport TimelineTransport from 'core/timeline/timeline_transport';\nimport Browser from 'runtime';\nimport { AuthTransport } from 'core/auth/auth_transports';\nimport { ScriptReceivers } from '../dom/script_receiver_factory';\n\nvar getAgent = function(sender: TimelineSender, useTLS: boolean) {\n return function(data: any, callback: Function) {\n var scheme = 'http' + (useTLS ? 's' : '') + '://';\n var url =\n scheme + (sender.host || sender.options.host) + sender.options.path;\n var request = Browser.createJSONPRequest(url, data);\n\n var receiver = Browser.ScriptReceivers.create(function(error, result) {\n ScriptReceivers.remove(receiver);\n request.cleanup();\n\n if (result && result.host) {\n sender.host = result.host;\n }\n if (callback) {\n callback(error, result);\n }\n });\n request.send(receiver);\n };\n};\n\nvar jsonp = {\n name: 'jsonp',\n getAgent\n};\n\nexport default jsonp;\n","import Defaults from '../defaults';\nimport { default as URLScheme, URLSchemeParams } from './url_scheme';\n\nfunction getGenericURL(\n baseScheme: string,\n params: URLSchemeParams,\n path: string\n): string {\n var scheme = baseScheme + (params.useTLS ? 's' : '');\n var host = params.useTLS ? params.hostTLS : params.hostNonTLS;\n return scheme + '://' + host + path;\n}\n\nfunction getGenericPath(key: string, queryString?: string): string {\n var path = '/app/' + key;\n var query =\n '?protocol=' +\n Defaults.PROTOCOL +\n '&client=js' +\n '&version=' +\n Defaults.VERSION +\n (queryString ? '&' + queryString : '');\n return path + query;\n}\n\nexport var ws: URLScheme = {\n getInitial: function(key: string, params: URLSchemeParams): string {\n var path = (params.httpPath || '') + getGenericPath(key, 'flash=false');\n return getGenericURL('ws', params, path);\n }\n};\n\nexport var http: URLScheme = {\n getInitial: function(key: string, params: URLSchemeParams): string {\n var path = (params.httpPath || '/pusher') + getGenericPath(key);\n return getGenericURL('http', params, path);\n }\n};\n\nexport var sockjs: URLScheme = {\n getInitial: function(key: string, params: URLSchemeParams): string {\n return getGenericURL('http', params, params.httpPath || '/pusher');\n },\n getPath: function(key: string, params: URLSchemeParams): string {\n return getGenericPath(key);\n }\n};\n","import Callback from './callback';\nimport * as Collections from '../utils/collections';\nimport CallbackTable from './callback_table';\n\nexport default class CallbackRegistry {\n _callbacks: CallbackTable;\n\n constructor() {\n this._callbacks = {};\n }\n\n get(name: string): Callback[] {\n return this._callbacks[prefix(name)];\n }\n\n add(name: string, callback: Function, context: any) {\n var prefixedEventName = prefix(name);\n this._callbacks[prefixedEventName] =\n this._callbacks[prefixedEventName] || [];\n this._callbacks[prefixedEventName].push({\n fn: callback,\n context: context\n });\n }\n\n remove(name?: string, callback?: Function, context?: any) {\n if (!name && !callback && !context) {\n this._callbacks = {};\n return;\n }\n\n var names = name ? [prefix(name)] : Collections.keys(this._callbacks);\n\n if (callback || context) {\n this.removeCallback(names, callback, context);\n } else {\n this.removeAllCallbacks(names);\n }\n }\n\n private removeCallback(names: string[], callback: Function, context: any) {\n Collections.apply(\n names,\n function(name) {\n this._callbacks[name] = Collections.filter(\n this._callbacks[name] || [],\n function(binding) {\n return (\n (callback && callback !== binding.fn) ||\n (context && context !== binding.context)\n );\n }\n );\n if (this._callbacks[name].length === 0) {\n delete this._callbacks[name];\n }\n },\n this\n );\n }\n\n private removeAllCallbacks(names: string[]) {\n Collections.apply(\n names,\n function(name) {\n delete this._callbacks[name];\n },\n this\n );\n }\n}\n\nfunction prefix(name: string): string {\n return '_' + name;\n}\n","import * as Collections from '../utils/collections';\nimport Callback from './callback';\nimport Metadata from '../channels/metadata';\nimport CallbackRegistry from './callback_registry';\n\n/** Manages callback bindings and event emitting.\n *\n * @param Function failThrough called when no listeners are bound to an event\n */\nexport default class Dispatcher {\n callbacks: CallbackRegistry;\n global_callbacks: Function[];\n failThrough: Function;\n\n constructor(failThrough?: Function) {\n this.callbacks = new CallbackRegistry();\n this.global_callbacks = [];\n this.failThrough = failThrough;\n }\n\n bind(eventName: string, callback: Function, context?: any) {\n this.callbacks.add(eventName, callback, context);\n return this;\n }\n\n bind_global(callback: Function) {\n this.global_callbacks.push(callback);\n return this;\n }\n\n unbind(eventName?: string, callback?: Function, context?: any) {\n this.callbacks.remove(eventName, callback, context);\n return this;\n }\n\n unbind_global(callback?: Function) {\n if (!callback) {\n this.global_callbacks = [];\n return this;\n }\n\n this.global_callbacks = Collections.filter(\n this.global_callbacks || [],\n c => c !== callback\n );\n\n return this;\n }\n\n unbind_all() {\n this.unbind();\n this.unbind_global();\n return this;\n }\n\n emit(eventName: string, data?: any, metadata?: Metadata): Dispatcher {\n for (var i = 0; i < this.global_callbacks.length; i++) {\n this.global_callbacks[i](eventName, data);\n }\n\n var callbacks = this.callbacks.get(eventName);\n var args = [];\n\n if (metadata) {\n // if there's a metadata argument, we need to call the callback with both\n // data and metadata regardless of whether data is undefined\n args.push(data, metadata);\n } else if (data) {\n // metadata is undefined, so we only need to call the callback with data\n // if data exists\n args.push(data);\n }\n\n if (callbacks && callbacks.length > 0) {\n for (var i = 0; i < callbacks.length; i++) {\n callbacks[i].fn.apply(callbacks[i].context || global, args);\n }\n } else if (this.failThrough) {\n this.failThrough(eventName, data);\n }\n\n return this;\n }\n}\n","import Util from '../util';\nimport * as Collections from '../utils/collections';\nimport { default as EventsDispatcher } from '../events/dispatcher';\nimport Logger from '../logger';\nimport TransportHooks from './transport_hooks';\nimport Socket from '../socket';\nimport Runtime from 'runtime';\nimport Timeline from '../timeline/timeline';\nimport TransportConnectionOptions from './transport_connection_options';\n\n/** Provides universal API for transport connections.\n *\n * Transport connection is a low-level object that wraps a connection method\n * and exposes a simple evented interface for the connection state and\n * messaging. It does not implement Pusher-specific WebSocket protocol.\n *\n * Additionally, it fetches resources needed for transport to work and exposes\n * an interface for querying transport features.\n *\n * States:\n * - new - initial state after constructing the object\n * - initializing - during initialization phase, usually fetching resources\n * - intialized - ready to establish a connection\n * - connection - when connection is being established\n * - open - when connection ready to be used\n * - closed - after connection was closed be either side\n *\n * Emits:\n * - error - after the connection raised an error\n *\n * Options:\n * - useTLS - whether connection should be over TLS\n * - hostTLS - host to connect to when connection is over TLS\n * - hostNonTLS - host to connect to when connection is over TLS\n *\n * @param {String} key application key\n * @param {Object} options\n */\nexport default class TransportConnection extends EventsDispatcher {\n hooks: TransportHooks;\n name: string;\n priority: number;\n key: string;\n options: TransportConnectionOptions;\n state: string;\n timeline: Timeline;\n activityTimeout: number;\n id: number;\n socket: Socket;\n beforeOpen: Function;\n initialize: Function;\n\n constructor(\n hooks: TransportHooks,\n name: string,\n priority: number,\n key: string,\n options: TransportConnectionOptions\n ) {\n super();\n this.initialize = Runtime.transportConnectionInitializer;\n this.hooks = hooks;\n this.name = name;\n this.priority = priority;\n this.key = key;\n this.options = options;\n\n this.state = 'new';\n this.timeline = options.timeline;\n this.activityTimeout = options.activityTimeout;\n this.id = this.timeline.generateUniqueID();\n }\n\n /** Checks whether the transport handles activity checks by itself.\n *\n * @return {Boolean}\n */\n handlesActivityChecks(): boolean {\n return Boolean(this.hooks.handlesActivityChecks);\n }\n\n /** Checks whether the transport supports the ping/pong API.\n *\n * @return {Boolean}\n */\n supportsPing(): boolean {\n return Boolean(this.hooks.supportsPing);\n }\n\n /** Tries to establish a connection.\n *\n * @returns {Boolean} false if transport is in invalid state\n */\n connect(): boolean {\n if (this.socket || this.state !== 'initialized') {\n return false;\n }\n\n var url = this.hooks.urls.getInitial(this.key, this.options);\n try {\n this.socket = this.hooks.getSocket(url, this.options);\n } catch (e) {\n Util.defer(() => {\n this.onError(e);\n this.changeState('closed');\n });\n return false;\n }\n\n this.bindListeners();\n\n Logger.debug('Connecting', { transport: this.name, url });\n this.changeState('connecting');\n return true;\n }\n\n /** Closes the connection.\n *\n * @return {Boolean} true if there was a connection to close\n */\n close(): boolean {\n if (this.socket) {\n this.socket.close();\n return true;\n } else {\n return false;\n }\n }\n\n /** Sends data over the open connection.\n *\n * @param {String} data\n * @return {Boolean} true only when in the \"open\" state\n */\n send(data: any): boolean {\n if (this.state === 'open') {\n // Workaround for MobileSafari bug (see https://gist.github.com/2052006)\n Util.defer(() => {\n if (this.socket) {\n this.socket.send(data);\n }\n });\n return true;\n } else {\n return false;\n }\n }\n\n /** Sends a ping if the connection is open and transport supports it. */\n ping() {\n if (this.state === 'open' && this.supportsPing()) {\n this.socket.ping();\n }\n }\n\n private onOpen() {\n if (this.hooks.beforeOpen) {\n this.hooks.beforeOpen(\n this.socket,\n this.hooks.urls.getPath(this.key, this.options)\n );\n }\n this.changeState('open');\n this.socket.onopen = undefined;\n }\n\n private onError(error) {\n this.emit('error', { type: 'WebSocketError', error: error });\n this.timeline.error(this.buildTimelineMessage({ error: error.toString() }));\n }\n\n private onClose(closeEvent?: any) {\n if (closeEvent) {\n this.changeState('closed', {\n code: closeEvent.code,\n reason: closeEvent.reason,\n wasClean: closeEvent.wasClean\n });\n } else {\n this.changeState('closed');\n }\n this.unbindListeners();\n this.socket = undefined;\n }\n\n private onMessage(message) {\n this.emit('message', message);\n }\n\n private onActivity() {\n this.emit('activity');\n }\n\n private bindListeners() {\n this.socket.onopen = () => {\n this.onOpen();\n };\n this.socket.onerror = error => {\n this.onError(error);\n };\n this.socket.onclose = closeEvent => {\n this.onClose(closeEvent);\n };\n this.socket.onmessage = message => {\n this.onMessage(message);\n };\n\n if (this.supportsPing()) {\n this.socket.onactivity = () => {\n this.onActivity();\n };\n }\n }\n\n private unbindListeners() {\n if (this.socket) {\n this.socket.onopen = undefined;\n this.socket.onerror = undefined;\n this.socket.onclose = undefined;\n this.socket.onmessage = undefined;\n if (this.supportsPing()) {\n this.socket.onactivity = undefined;\n }\n }\n }\n\n private changeState(state: string, params?: any) {\n this.state = state;\n this.timeline.info(\n this.buildTimelineMessage({\n state: state,\n params: params\n })\n );\n this.emit(state, params);\n }\n\n buildTimelineMessage(message): any {\n return Collections.extend({ cid: this.id }, message);\n }\n}\n","import Factory from '../utils/factory';\nimport TransportHooks from './transport_hooks';\nimport TransportConnection from './transport_connection';\nimport TransportConnectionOptions from './transport_connection_options';\n\n/** Provides interface for transport connection instantiation.\n *\n * Takes transport-specific hooks as the only argument, which allow checking\n * for transport support and creating its connections.\n *\n * Supported hooks: * - file - the name of the file to be fetched during initialization\n * - urls - URL scheme to be used by transport\n * - handlesActivityCheck - true when the transport handles activity checks\n * - supportsPing - true when the transport has a ping/activity API\n * - isSupported - tells whether the transport is supported in the environment\n * - getSocket - creates a WebSocket-compatible transport socket\n *\n * See transports.js for specific implementations.\n *\n * @param {Object} hooks object containing all needed transport hooks\n */\nexport default class Transport {\n hooks: TransportHooks;\n\n constructor(hooks: TransportHooks) {\n this.hooks = hooks;\n }\n\n /** Returns whether the transport is supported in the environment.\n *\n * @param {Object} envronment te environment details (encryption, settings)\n * @returns {Boolean} true when the transport is supported\n */\n isSupported(environment: any): boolean {\n return this.hooks.isSupported(environment);\n }\n\n /** Creates a transport connection.\n *\n * @param {String} name\n * @param {Number} priority\n * @param {String} key the application key\n * @param {Object} options\n * @returns {TransportConnection}\n */\n createConnection(\n name: string,\n priority: number,\n key: string,\n options: any\n ): TransportConnection {\n return new TransportConnection(this.hooks, name, priority, key, options);\n }\n}\n","import * as URLSchemes from 'core/transports/url_schemes';\nimport URLScheme from 'core/transports/url_scheme';\nimport Transport from 'core/transports/transport';\nimport Util from 'core/util';\nimport * as Collections from 'core/utils/collections';\nimport TransportHooks from 'core/transports/transport_hooks';\nimport TransportsTable from 'core/transports/transports_table';\nimport Runtime from 'runtime';\n\n/** WebSocket transport.\n *\n * Uses native WebSocket implementation, including MozWebSocket supported by\n * earlier Firefox versions.\n */\nvar WSTransport = new Transport({\n urls: URLSchemes.ws,\n handlesActivityChecks: false,\n supportsPing: false,\n\n isInitialized: function() {\n return Boolean(Runtime.getWebSocketAPI());\n },\n isSupported: function(): boolean {\n return Boolean(Runtime.getWebSocketAPI());\n },\n getSocket: function(url) {\n return Runtime.createWebSocket(url);\n }\n});\n\nvar httpConfiguration = {\n urls: URLSchemes.http,\n handlesActivityChecks: false,\n supportsPing: true,\n isInitialized: function() {\n return true;\n }\n};\n\nexport var streamingConfiguration = Collections.extend(\n {\n getSocket: function(url) {\n return Runtime.HTTPFactory.createStreamingSocket(url);\n }\n },\n httpConfiguration\n);\nexport var pollingConfiguration = Collections.extend(\n {\n getSocket: function(url) {\n return Runtime.HTTPFactory.createPollingSocket(url);\n }\n },\n httpConfiguration\n);\n\nvar xhrConfiguration = {\n isSupported: function(): boolean {\n return Runtime.isXHRSupported();\n }\n};\n\n/** HTTP streaming transport using CORS-enabled XMLHttpRequest. */\nvar XHRStreamingTransport = new Transport(\n (\n Collections.extend({}, streamingConfiguration, xhrConfiguration)\n )\n);\n\n/** HTTP long-polling transport using CORS-enabled XMLHttpRequest. */\nvar XHRPollingTransport = new Transport(\n Collections.extend({}, pollingConfiguration, xhrConfiguration)\n);\n\nvar Transports: TransportsTable = {\n ws: WSTransport,\n xhr_streaming: XHRStreamingTransport,\n xhr_polling: XHRPollingTransport\n};\n\nexport default Transports;\n","import {\n default as Transports,\n streamingConfiguration,\n pollingConfiguration\n} from 'isomorphic/transports/transports';\nimport Transport from 'core/transports/transport';\nimport TransportHooks from 'core/transports/transport_hooks';\nimport * as URLSchemes from 'core/transports/url_schemes';\nimport Runtime from 'runtime';\nimport { Dependencies } from '../dom/dependencies';\nimport * as Collections from 'core/utils/collections';\n\nvar SockJSTransport = new Transport({\n file: 'sockjs',\n urls: URLSchemes.sockjs,\n handlesActivityChecks: true,\n supportsPing: false,\n\n isSupported: function() {\n return true;\n },\n isInitialized: function() {\n return window.SockJS !== undefined;\n },\n getSocket: function(url, options) {\n return new window.SockJS(url, null, {\n js_path: Dependencies.getPath('sockjs', {\n useTLS: options.useTLS\n }),\n ignore_null_origin: options.ignoreNullOrigin\n });\n },\n beforeOpen: function(socket, path) {\n socket.send(\n JSON.stringify({\n path: path\n })\n );\n }\n});\n\nvar xdrConfiguration = {\n isSupported: function(environment): boolean {\n var yes = Runtime.isXDRSupported(environment.useTLS);\n return yes;\n }\n};\n\n/** HTTP streaming transport using XDomainRequest (IE 8,9). */\nvar XDRStreamingTransport = new Transport(\n (\n Collections.extend({}, streamingConfiguration, xdrConfiguration)\n )\n);\n\n/** HTTP long-polling transport using XDomainRequest (IE 8,9). */\nvar XDRPollingTransport = new Transport(\n Collections.extend({}, pollingConfiguration, xdrConfiguration)\n);\n\nTransports.xdr_streaming = XDRStreamingTransport;\nTransports.xdr_polling = XDRPollingTransport;\nTransports.sockjs = SockJSTransport;\n\nexport default Transports;\n","import Reachability from 'core/reachability';\nimport { default as EventsDispatcher } from 'core/events/dispatcher';\n\n/** Really basic interface providing network availability info.\n *\n * Emits:\n * - online - when browser goes online\n * - offline - when browser goes offline\n */\nexport class NetInfo extends EventsDispatcher implements Reachability {\n constructor() {\n super();\n var self = this;\n // This is okay, as IE doesn't support this stuff anyway.\n if (window.addEventListener !== undefined) {\n window.addEventListener(\n 'online',\n function() {\n self.emit('online');\n },\n false\n );\n window.addEventListener(\n 'offline',\n function() {\n self.emit('offline');\n },\n false\n );\n }\n }\n\n /** Returns whether browser is online or not\n *\n * Offline means definitely offline (no connection to router).\n * Inverse does NOT mean definitely online (only currently supported in Safari\n * and even there only means the device has a connection to the router).\n *\n * @return {Boolean}\n */\n isOnline(): boolean {\n if (window.navigator.onLine === undefined) {\n return true;\n } else {\n return window.navigator.onLine;\n }\n }\n}\n\nexport var Network = new NetInfo();\n","import Util from '../util';\nimport * as Collections from '../utils/collections';\nimport TransportManager from './transport_manager';\nimport TransportConnection from './transport_connection';\nimport Transport from './transport';\nimport PingDelayOptions from './ping_delay_options';\n\n/** Creates transport connections monitored by a transport manager.\n *\n * When a transport is closed, it might mean the environment does not support\n * it. It's possible that messages get stuck in an intermediate buffer or\n * proxies terminate inactive connections. To combat these problems,\n * assistants monitor the connection lifetime, report unclean exits and\n * adjust ping timeouts to keep the connection active. The decision to disable\n * a transport is the manager's responsibility.\n *\n * @param {TransportManager} manager\n * @param {TransportConnection} transport\n * @param {Object} options\n */\nexport default class AssistantToTheTransportManager {\n manager: TransportManager;\n transport: Transport;\n minPingDelay: number;\n maxPingDelay: number;\n pingDelay: number;\n\n constructor(\n manager: TransportManager,\n transport: Transport,\n options: PingDelayOptions\n ) {\n this.manager = manager;\n this.transport = transport;\n this.minPingDelay = options.minPingDelay;\n this.maxPingDelay = options.maxPingDelay;\n this.pingDelay = undefined;\n }\n\n /** Creates a transport connection.\n *\n * This function has the same API as Transport#createConnection.\n *\n * @param {String} name\n * @param {Number} priority\n * @param {String} key the application key\n * @param {Object} options\n * @returns {TransportConnection}\n */\n createConnection(\n name: string,\n priority: number,\n key: string,\n options: Object\n ): TransportConnection {\n options = Collections.extend({}, options, {\n activityTimeout: this.pingDelay\n });\n var connection = this.transport.createConnection(\n name,\n priority,\n key,\n options\n );\n\n var openTimestamp = null;\n\n var onOpen = function() {\n connection.unbind('open', onOpen);\n connection.bind('closed', onClosed);\n openTimestamp = Util.now();\n };\n var onClosed = closeEvent => {\n connection.unbind('closed', onClosed);\n\n if (closeEvent.code === 1002 || closeEvent.code === 1003) {\n // we don't want to use transports not obeying the protocol\n this.manager.reportDeath();\n } else if (!closeEvent.wasClean && openTimestamp) {\n // report deaths only for short-living transport\n var lifespan = Util.now() - openTimestamp;\n if (lifespan < 2 * this.maxPingDelay) {\n this.manager.reportDeath();\n this.pingDelay = Math.max(lifespan / 2, this.minPingDelay);\n }\n }\n };\n\n connection.bind('open', onOpen);\n return connection;\n }\n\n /** Returns whether the transport is supported in the environment.\n *\n * This function has the same API as Transport#isSupported. Might return false\n * when the manager decides to kill the transport.\n *\n * @param {Object} environment the environment details (encryption, settings)\n * @returns {Boolean} true when the transport is supported\n */\n isSupported(environment: string): boolean {\n return this.manager.isAlive() && this.transport.isSupported(environment);\n }\n}\n","import Action from './action';\nimport { PusherEvent } from './message-types';\n/**\n * Provides functions for handling Pusher protocol-specific messages.\n */\n\nconst Protocol = {\n /**\n * Decodes a message in a Pusher format.\n *\n * The MessageEvent we receive from the transport should contain a pusher event\n * (https://pusher.com/docs/pusher_protocol#events) serialized as JSON in the\n * data field\n *\n * The pusher event may contain a data field too, and it may also be\n * serialised as JSON\n *\n * Throws errors when messages are not parse'able.\n *\n * @param {MessageEvent} messageEvent\n * @return {PusherEvent}\n */\n decodeMessage: function(messageEvent: MessageEvent): PusherEvent {\n try {\n var messageData = JSON.parse(messageEvent.data);\n var pusherEventData = messageData.data;\n if (typeof pusherEventData === 'string') {\n try {\n pusherEventData = JSON.parse(messageData.data);\n } catch (e) {}\n }\n var pusherEvent: PusherEvent = {\n event: messageData.event,\n channel: messageData.channel,\n data: pusherEventData\n };\n if (messageData.user_id) {\n pusherEvent.user_id = messageData.user_id;\n }\n return pusherEvent;\n } catch (e) {\n throw { type: 'MessageParseError', error: e, data: messageEvent.data };\n }\n },\n\n /**\n * Encodes a message to be sent.\n *\n * @param {PusherEvent} event\n * @return {String}\n */\n encodeMessage: function(event: PusherEvent): string {\n return JSON.stringify(event);\n },\n\n /**\n * Processes a handshake message and returns appropriate actions.\n *\n * Returns an object with an 'action' and other action-specific properties.\n *\n * There are three outcomes when calling this function. First is a successful\n * connection attempt, when pusher:connection_established is received, which\n * results in a 'connected' action with an 'id' property. When passed a\n * pusher:error event, it returns a result with action appropriate to the\n * close code and an error. Otherwise, it raises an exception.\n *\n * @param {String} message\n * @result Object\n */\n processHandshake: function(messageEvent: MessageEvent): Action {\n var message = Protocol.decodeMessage(messageEvent);\n\n if (message.event === 'pusher:connection_established') {\n if (!message.data.activity_timeout) {\n throw 'No activity timeout specified in handshake';\n }\n return {\n action: 'connected',\n id: message.data.socket_id,\n activityTimeout: message.data.activity_timeout * 1000\n };\n } else if (message.event === 'pusher:error') {\n // From protocol 6 close codes are sent only once, so this only\n // happens when connection does not support close codes\n return {\n action: this.getCloseAction(message.data),\n error: this.getCloseError(message.data)\n };\n } else {\n throw 'Invalid handshake';\n }\n },\n\n /**\n * Dispatches the close event and returns an appropriate action name.\n *\n * See:\n * 1. https://developer.mozilla.org/en-US/docs/WebSockets/WebSockets_reference/CloseEvent\n * 2. http://pusher.com/docs/pusher_protocol\n *\n * @param {CloseEvent} closeEvent\n * @return {String} close action name\n */\n getCloseAction: function(closeEvent): string {\n if (closeEvent.code < 4000) {\n // ignore 1000 CLOSE_NORMAL, 1001 CLOSE_GOING_AWAY,\n // 1005 CLOSE_NO_STATUS, 1006 CLOSE_ABNORMAL\n // ignore 1007...3999\n // handle 1002 CLOSE_PROTOCOL_ERROR, 1003 CLOSE_UNSUPPORTED,\n // 1004 CLOSE_TOO_LARGE\n if (closeEvent.code >= 1002 && closeEvent.code <= 1004) {\n return 'backoff';\n } else {\n return null;\n }\n } else if (closeEvent.code === 4000) {\n return 'tls_only';\n } else if (closeEvent.code < 4100) {\n return 'refused';\n } else if (closeEvent.code < 4200) {\n return 'backoff';\n } else if (closeEvent.code < 4300) {\n return 'retry';\n } else {\n // unknown error\n return 'refused';\n }\n },\n\n /**\n * Returns an error or null basing on the close event.\n *\n * Null is returned when connection was closed cleanly. Otherwise, an object\n * with error details is returned.\n *\n * @param {CloseEvent} closeEvent\n * @return {Object} error object\n */\n getCloseError: function(closeEvent): any {\n if (closeEvent.code !== 1000 && closeEvent.code !== 1001) {\n return {\n type: 'PusherError',\n data: {\n code: closeEvent.code,\n message: closeEvent.reason || closeEvent.message\n }\n };\n } else {\n return null;\n }\n }\n};\n\nexport default Protocol;\n","import * as Collections from '../utils/collections';\nimport { default as EventsDispatcher } from '../events/dispatcher';\nimport Protocol from './protocol/protocol';\nimport { PusherEvent } from './protocol/message-types';\nimport Logger from '../logger';\nimport TransportConnection from '../transports/transport_connection';\nimport Socket from '../socket';\n/**\n * Provides Pusher protocol interface for transports.\n *\n * Emits following events:\n * - message - on received messages\n * - ping - on ping requests\n * - pong - on pong responses\n * - error - when the transport emits an error\n * - closed - after closing the transport\n *\n * It also emits more events when connection closes with a code.\n * See Protocol.getCloseAction to get more details.\n *\n * @param {Number} id\n * @param {AbstractTransport} transport\n */\nexport default class Connection extends EventsDispatcher implements Socket {\n id: string;\n transport: TransportConnection;\n activityTimeout: number;\n\n constructor(id: string, transport: TransportConnection) {\n super();\n this.id = id;\n this.transport = transport;\n this.activityTimeout = transport.activityTimeout;\n this.bindListeners();\n }\n\n /** Returns whether used transport handles activity checks by itself\n *\n * @returns {Boolean} true if activity checks are handled by the transport\n */\n handlesActivityChecks() {\n return this.transport.handlesActivityChecks();\n }\n\n /** Sends raw data.\n *\n * @param {String} data\n */\n send(data: any): boolean {\n return this.transport.send(data);\n }\n\n /** Sends an event.\n *\n * @param {String} name\n * @param {String} data\n * @param {String} [channel]\n * @returns {Boolean} whether message was sent or not\n */\n send_event(name: string, data: any, channel?: string): boolean {\n var event: PusherEvent = { event: name, data: data };\n if (channel) {\n event.channel = channel;\n }\n Logger.debug('Event sent', event);\n return this.send(Protocol.encodeMessage(event));\n }\n\n /** Sends a ping message to the server.\n *\n * Basing on the underlying transport, it might send either transport's\n * protocol-specific ping or pusher:ping event.\n */\n ping() {\n if (this.transport.supportsPing()) {\n this.transport.ping();\n } else {\n this.send_event('pusher:ping', {});\n }\n }\n\n /** Closes the connection. */\n close() {\n this.transport.close();\n }\n\n private bindListeners() {\n var listeners = {\n message: (messageEvent: MessageEvent) => {\n var pusherEvent;\n try {\n pusherEvent = Protocol.decodeMessage(messageEvent);\n } catch (e) {\n this.emit('error', {\n type: 'MessageParseError',\n error: e,\n data: messageEvent.data\n });\n }\n\n if (pusherEvent !== undefined) {\n Logger.debug('Event recd', pusherEvent);\n\n switch (pusherEvent.event) {\n case 'pusher:error':\n this.emit('error', {\n type: 'PusherError',\n data: pusherEvent.data\n });\n break;\n case 'pusher:ping':\n this.emit('ping');\n break;\n case 'pusher:pong':\n this.emit('pong');\n break;\n }\n this.emit('message', pusherEvent);\n }\n },\n activity: () => {\n this.emit('activity');\n },\n error: error => {\n this.emit('error', error);\n },\n closed: closeEvent => {\n unbindListeners();\n\n if (closeEvent && closeEvent.code) {\n this.handleCloseEvent(closeEvent);\n }\n\n this.transport = null;\n this.emit('closed');\n }\n };\n\n var unbindListeners = () => {\n Collections.objectApply(listeners, (listener, event) => {\n this.transport.unbind(event, listener);\n });\n };\n\n Collections.objectApply(listeners, (listener, event) => {\n this.transport.bind(event, listener);\n });\n }\n\n private handleCloseEvent(closeEvent: any) {\n var action = Protocol.getCloseAction(closeEvent);\n var error = Protocol.getCloseError(closeEvent);\n if (error) {\n this.emit('error', error);\n }\n if (action) {\n this.emit(action, { action: action, error: error });\n }\n }\n}\n","import Util from '../../util';\nimport * as Collections from '../../utils/collections';\nimport Protocol from '../protocol/protocol';\nimport Connection from '../connection';\nimport TransportConnection from '../../transports/transport_connection';\nimport HandshakePayload from './handshake_payload';\n\n/**\n * Handles Pusher protocol handshakes for transports.\n *\n * Calls back with a result object after handshake is completed. Results\n * always have two fields:\n * - action - string describing action to be taken after the handshake\n * - transport - the transport object passed to the constructor\n *\n * Different actions can set different additional properties on the result.\n * In the case of 'connected' action, there will be a 'connection' property\n * containing a Connection object for the transport. Other actions should\n * carry an 'error' property.\n *\n * @param {AbstractTransport} transport\n * @param {Function} callback\n */\nexport default class Handshake {\n transport: TransportConnection;\n callback: (HandshakePayload) => void;\n onMessage: Function;\n onClosed: Function;\n\n constructor(\n transport: TransportConnection,\n callback: (HandshakePayload) => void\n ) {\n this.transport = transport;\n this.callback = callback;\n this.bindListeners();\n }\n\n close() {\n this.unbindListeners();\n this.transport.close();\n }\n\n private bindListeners() {\n this.onMessage = m => {\n this.unbindListeners();\n\n var result;\n try {\n result = Protocol.processHandshake(m);\n } catch (e) {\n this.finish('error', { error: e });\n this.transport.close();\n return;\n }\n\n if (result.action === 'connected') {\n this.finish('connected', {\n connection: new Connection(result.id, this.transport),\n activityTimeout: result.activityTimeout\n });\n } else {\n this.finish(result.action, { error: result.error });\n this.transport.close();\n }\n };\n\n this.onClosed = closeEvent => {\n this.unbindListeners();\n\n var action = Protocol.getCloseAction(closeEvent) || 'backoff';\n var error = Protocol.getCloseError(closeEvent);\n this.finish(action, { error: error });\n };\n\n this.transport.bind('message', this.onMessage);\n this.transport.bind('closed', this.onClosed);\n }\n\n private unbindListeners() {\n this.transport.unbind('message', this.onMessage);\n this.transport.unbind('closed', this.onClosed);\n }\n\n private finish(action: string, params: any) {\n this.callback(\n Collections.extend({ transport: this.transport, action: action }, params)\n );\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport base64encode from '../base64';\nimport Timeline from './timeline';\nimport Runtime from 'runtime';\n\nexport interface TimelineSenderOptions {\n host?: string;\n port?: number;\n path?: string;\n}\n\nexport default class TimelineSender {\n timeline: Timeline;\n options: TimelineSenderOptions;\n host: string;\n\n constructor(timeline: Timeline, options: TimelineSenderOptions) {\n this.timeline = timeline;\n this.options = options || {};\n }\n\n send(useTLS: boolean, callback?: Function) {\n if (this.timeline.isEmpty()) {\n return;\n }\n\n this.timeline.send(\n Runtime.TimelineTransport.getAgent(this, useTLS),\n callback\n );\n }\n}\n","import { default as EventsDispatcher } from '../events/dispatcher';\nimport * as Errors from '../errors';\nimport Logger from '../logger';\nimport Pusher from '../pusher';\nimport { PusherEvent } from '../connection/protocol/message-types';\nimport Metadata from './metadata';\nimport UrlStore from '../utils/url_store';\nimport {\n ChannelAuthorizationData,\n ChannelAuthorizationCallback\n} from '../auth/options';\nimport { HTTPAuthError } from '../errors';\n\n/** Provides base public channel interface with an event emitter.\n *\n * Emits:\n * - pusher:subscription_succeeded - after subscribing successfully\n * - other non-internal events\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\nexport default class Channel extends EventsDispatcher {\n name: string;\n pusher: Pusher;\n subscribed: boolean;\n subscriptionPending: boolean;\n subscriptionCancelled: boolean;\n subscriptionCount: null;\n\n constructor(name: string, pusher: Pusher) {\n super(function(event, data) {\n Logger.debug('No callbacks on ' + name + ' for ' + event);\n });\n\n this.name = name;\n this.pusher = pusher;\n this.subscribed = false;\n this.subscriptionPending = false;\n this.subscriptionCancelled = false;\n }\n\n /** Skips authorization, since public channels don't require it.\n *\n * @param {Function} callback\n */\n authorize(socketId: string, callback: ChannelAuthorizationCallback) {\n return callback(null, { auth: '' });\n }\n\n /** Triggers an event */\n trigger(event: string, data: any) {\n if (event.indexOf('client-') !== 0) {\n throw new Errors.BadEventName(\n \"Event '\" + event + \"' does not start with 'client-'\"\n );\n }\n if (!this.subscribed) {\n var suffix = UrlStore.buildLogSuffix('triggeringClientEvents');\n Logger.warn(\n `Client event triggered before channel 'subscription_succeeded' event . ${suffix}`\n );\n }\n return this.pusher.send_event(event, data, this.name);\n }\n\n /** Signals disconnection to the channel. For internal use only. */\n disconnect() {\n this.subscribed = false;\n this.subscriptionPending = false;\n }\n\n /** Handles a PusherEvent. For internal use only.\n *\n * @param {PusherEvent} event\n */\n handleEvent(event: PusherEvent) {\n var eventName = event.event;\n var data = event.data;\n if (eventName === 'pusher_internal:subscription_succeeded') {\n this.handleSubscriptionSucceededEvent(event);\n } else if (eventName === 'pusher_internal:subscription_count') {\n this.handleSubscriptionCountEvent(event);\n } else if (eventName.indexOf('pusher_internal:') !== 0) {\n var metadata: Metadata = {};\n this.emit(eventName, data, metadata);\n }\n }\n\n handleSubscriptionSucceededEvent(event: PusherEvent) {\n this.subscriptionPending = false;\n this.subscribed = true;\n if (this.subscriptionCancelled) {\n this.pusher.unsubscribe(this.name);\n } else {\n this.emit('pusher:subscription_succeeded', event.data);\n }\n }\n\n handleSubscriptionCountEvent(event: PusherEvent) {\n if (event.data.subscription_count) {\n this.subscriptionCount = event.data.subscription_count;\n }\n\n this.emit('pusher:subscription_count', event.data);\n }\n\n /** Sends a subscription request. For internal use only. */\n subscribe() {\n if (this.subscribed) {\n return;\n }\n this.subscriptionPending = true;\n this.subscriptionCancelled = false;\n this.authorize(\n this.pusher.connection.socket_id,\n (error: Error | null, data: ChannelAuthorizationData) => {\n if (error) {\n this.subscriptionPending = false;\n // Why not bind to 'pusher:subscription_error' a level up, and log there?\n // Binding to this event would cause the warning about no callbacks being\n // bound (see constructor) to be suppressed, that's not what we want.\n Logger.error(error.toString());\n this.emit(\n 'pusher:subscription_error',\n Object.assign(\n {},\n {\n type: 'AuthError',\n error: error.message\n },\n error instanceof HTTPAuthError ? { status: error.status } : {}\n )\n );\n } else {\n this.pusher.send_event('pusher:subscribe', {\n auth: data.auth,\n channel_data: data.channel_data,\n channel: this.name\n });\n }\n }\n );\n }\n\n /** Sends an unsubscription request. For internal use only. */\n unsubscribe() {\n this.subscribed = false;\n this.pusher.send_event('pusher:unsubscribe', {\n channel: this.name\n });\n }\n\n /** Cancels an in progress subscription. For internal use only. */\n cancelSubscription() {\n this.subscriptionCancelled = true;\n }\n\n /** Reinstates an in progress subscripiton. For internal use only. */\n reinstateSubscription() {\n this.subscriptionCancelled = false;\n }\n}\n","import Factory from '../utils/factory';\nimport Channel from './channel';\nimport { ChannelAuthorizationCallback } from '../auth/options';\n\n/** Extends public channels to provide private channel interface.\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\nexport default class PrivateChannel extends Channel {\n /** Authorizes the connection to use the channel.\n *\n * @param {String} socketId\n * @param {Function} callback\n */\n authorize(socketId: string, callback: ChannelAuthorizationCallback) {\n return this.pusher.config.channelAuthorizer(\n {\n channelName: this.name,\n socketId: socketId\n },\n callback\n );\n }\n}\n","import * as Collections from '../utils/collections';\n\n/** Represents a collection of members of a presence channel. */\nexport default class Members {\n members: any;\n count: number;\n myID: any;\n me: any;\n\n constructor() {\n this.reset();\n }\n\n /** Returns member's info for given id.\n *\n * Resulting object containts two fields - id and info.\n *\n * @param {Number} id\n * @return {Object} member's info or null\n */\n get(id: string): any {\n if (Object.prototype.hasOwnProperty.call(this.members, id)) {\n return {\n id: id,\n info: this.members[id]\n };\n } else {\n return null;\n }\n }\n\n /** Calls back for each member in unspecified order.\n *\n * @param {Function} callback\n */\n each(callback: Function) {\n Collections.objectApply(this.members, (member, id) => {\n callback(this.get(id));\n });\n }\n\n /** Updates the id for connected member. For internal use only. */\n setMyID(id: string) {\n this.myID = id;\n }\n\n /** Handles subscription data. For internal use only. */\n onSubscription(subscriptionData: any) {\n this.members = subscriptionData.presence.hash;\n this.count = subscriptionData.presence.count;\n this.me = this.get(this.myID);\n }\n\n /** Adds a new member to the collection. For internal use only. */\n addMember(memberData: any) {\n if (this.get(memberData.user_id) === null) {\n this.count++;\n }\n this.members[memberData.user_id] = memberData.user_info;\n return this.get(memberData.user_id);\n }\n\n /** Adds a member from the collection. For internal use only. */\n removeMember(memberData: any) {\n var member = this.get(memberData.user_id);\n if (member) {\n delete this.members[memberData.user_id];\n this.count--;\n }\n return member;\n }\n\n /** Resets the collection to the initial state. For internal use only. */\n reset() {\n this.members = {};\n this.count = 0;\n this.myID = null;\n this.me = null;\n }\n}\n","import PrivateChannel from './private_channel';\nimport Logger from '../logger';\nimport Members from './members';\nimport Pusher from '../pusher';\nimport UrlStore from 'core/utils/url_store';\nimport { PusherEvent } from '../connection/protocol/message-types';\nimport Metadata from './metadata';\nimport { ChannelAuthorizationData } from '../auth/options';\n\nexport default class PresenceChannel extends PrivateChannel {\n members: Members;\n\n /** Adds presence channel functionality to private channels.\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\n constructor(name: string, pusher: Pusher) {\n super(name, pusher);\n this.members = new Members();\n }\n\n /** Authorizes the connection as a member of the channel.\n *\n * @param {String} socketId\n * @param {Function} callback\n */\n authorize(socketId: string, callback: Function) {\n super.authorize(socketId, async (error, authData) => {\n if (!error) {\n authData = authData as ChannelAuthorizationData;\n if (authData.channel_data != null) {\n var channelData = JSON.parse(authData.channel_data);\n this.members.setMyID(channelData.user_id);\n } else {\n await this.pusher.user.signinDonePromise;\n if (this.pusher.user.user_data != null) {\n // If the user is signed in, get the id of the authenticated user\n // and allow the presence authorization to continue.\n this.members.setMyID(this.pusher.user.user_data.id);\n } else {\n let suffix = UrlStore.buildLogSuffix('authorizationEndpoint');\n Logger.error(\n `Invalid auth response for channel '${this.name}', ` +\n `expected 'channel_data' field. ${suffix}, ` +\n `or the user should be signed in.`\n );\n callback('Invalid auth response');\n return;\n }\n }\n }\n callback(error, authData);\n });\n }\n\n /** Handles presence and subscription events. For internal use only.\n *\n * @param {PusherEvent} event\n */\n handleEvent(event: PusherEvent) {\n var eventName = event.event;\n if (eventName.indexOf('pusher_internal:') === 0) {\n this.handleInternalEvent(event);\n } else {\n var data = event.data;\n var metadata: Metadata = {};\n if (event.user_id) {\n metadata.user_id = event.user_id;\n }\n this.emit(eventName, data, metadata);\n }\n }\n handleInternalEvent(event: PusherEvent) {\n var eventName = event.event;\n var data = event.data;\n switch (eventName) {\n case 'pusher_internal:subscription_succeeded':\n this.handleSubscriptionSucceededEvent(event);\n break;\n case 'pusher_internal:subscription_count':\n this.handleSubscriptionCountEvent(event);\n break;\n case 'pusher_internal:member_added':\n var addedMember = this.members.addMember(data);\n this.emit('pusher:member_added', addedMember);\n break;\n case 'pusher_internal:member_removed':\n var removedMember = this.members.removeMember(data);\n if (removedMember) {\n this.emit('pusher:member_removed', removedMember);\n }\n break;\n }\n }\n\n handleSubscriptionSucceededEvent(event: PusherEvent) {\n this.subscriptionPending = false;\n this.subscribed = true;\n if (this.subscriptionCancelled) {\n this.pusher.unsubscribe(this.name);\n } else {\n this.members.onSubscription(event.data);\n this.emit('pusher:subscription_succeeded', this.members);\n }\n }\n\n /** Resets the channel state, including members map. For internal use only. */\n disconnect() {\n this.members.reset();\n super.disconnect();\n }\n}\n","import PrivateChannel from './private_channel';\nimport * as Errors from '../errors';\nimport Logger from '../logger';\nimport Pusher from '../pusher';\nimport { decode as encodeUTF8 } from '@stablelib/utf8';\nimport { decode as decodeBase64 } from '@stablelib/base64';\nimport Dispatcher from '../events/dispatcher';\nimport { PusherEvent } from '../connection/protocol/message-types';\nimport {\n ChannelAuthorizationData,\n ChannelAuthorizationCallback\n} from '../auth/options';\nimport * as nacl from 'tweetnacl';\n\n/** Extends private channels to provide encrypted channel interface.\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\nexport default class EncryptedChannel extends PrivateChannel {\n key: Uint8Array = null;\n nacl: nacl;\n\n constructor(name: string, pusher: Pusher, nacl: nacl) {\n super(name, pusher);\n this.nacl = nacl;\n }\n\n /** Authorizes the connection to use the channel.\n *\n * @param {String} socketId\n * @param {Function} callback\n */\n authorize(socketId: string, callback: ChannelAuthorizationCallback) {\n super.authorize(\n socketId,\n (error: Error | null, authData: ChannelAuthorizationData) => {\n if (error) {\n callback(error, authData);\n return;\n }\n let sharedSecret = authData['shared_secret'];\n if (!sharedSecret) {\n callback(\n new Error(\n `No shared_secret key in auth payload for encrypted channel: ${this.name}`\n ),\n null\n );\n return;\n }\n this.key = decodeBase64(sharedSecret);\n delete authData['shared_secret'];\n callback(null, authData);\n }\n );\n }\n\n trigger(event: string, data: any): boolean {\n throw new Errors.UnsupportedFeature(\n 'Client events are not currently supported for encrypted channels'\n );\n }\n\n /** Handles an event. For internal use only.\n *\n * @param {PusherEvent} event\n */\n handleEvent(event: PusherEvent) {\n var eventName = event.event;\n var data = event.data;\n if (\n eventName.indexOf('pusher_internal:') === 0 ||\n eventName.indexOf('pusher:') === 0\n ) {\n super.handleEvent(event);\n return;\n }\n this.handleEncryptedEvent(eventName, data);\n }\n\n private handleEncryptedEvent(event: string, data: any): void {\n if (!this.key) {\n Logger.debug(\n 'Received encrypted event before key has been retrieved from the authEndpoint'\n );\n return;\n }\n if (!data.ciphertext || !data.nonce) {\n Logger.error(\n 'Unexpected format for encrypted event, expected object with `ciphertext` and `nonce` fields, got: ' +\n data\n );\n return;\n }\n let cipherText = decodeBase64(data.ciphertext);\n if (cipherText.length < this.nacl.secretbox.overheadLength) {\n Logger.error(\n `Expected encrypted event ciphertext length to be ${this.nacl.secretbox.overheadLength}, got: ${cipherText.length}`\n );\n return;\n }\n let nonce = decodeBase64(data.nonce);\n if (nonce.length < this.nacl.secretbox.nonceLength) {\n Logger.error(\n `Expected encrypted event nonce length to be ${this.nacl.secretbox.nonceLength}, got: ${nonce.length}`\n );\n return;\n }\n\n let bytes = this.nacl.secretbox.open(cipherText, nonce, this.key);\n if (bytes === null) {\n Logger.debug(\n 'Failed to decrypt an event, probably because it was encrypted with a different key. Fetching a new key from the authEndpoint...'\n );\n // Try a single time to retrieve a new auth key and decrypt the event with it\n // If this fails, a new key will be requested when a new message is received\n this.authorize(this.pusher.connection.socket_id, (error, authData) => {\n if (error) {\n Logger.error(\n `Failed to make a request to the authEndpoint: ${authData}. Unable to fetch new key, so dropping encrypted event`\n );\n return;\n }\n bytes = this.nacl.secretbox.open(cipherText, nonce, this.key);\n if (bytes === null) {\n Logger.error(\n `Failed to decrypt event with new key. Dropping encrypted event`\n );\n return;\n }\n this.emit(event, this.getDataToEmit(bytes));\n return;\n });\n return;\n }\n this.emit(event, this.getDataToEmit(bytes));\n }\n\n // Try and parse the decrypted bytes as JSON. If we can't parse it, just\n // return the utf-8 string\n getDataToEmit(bytes: Uint8Array): string {\n let raw = encodeUTF8(bytes);\n try {\n return JSON.parse(raw);\n } catch {\n return raw;\n }\n }\n}\n","import { default as EventsDispatcher } from '../events/dispatcher';\nimport { OneOffTimer as Timer } from '../utils/timers';\nimport { Config } from '../config';\nimport Logger from '../logger';\nimport HandshakePayload from './handshake/handshake_payload';\nimport Connection from './connection';\nimport Strategy from '../strategies/strategy';\nimport StrategyRunner from '../strategies/strategy_runner';\nimport * as Collections from '../utils/collections';\nimport Timeline from '../timeline/timeline';\nimport ConnectionManagerOptions from './connection_manager_options';\nimport Runtime from 'runtime';\n\nimport {\n ErrorCallbacks,\n HandshakeCallbacks,\n ConnectionCallbacks\n} from './callbacks';\nimport Action from './protocol/action';\n\n/** Manages connection to Pusher.\n *\n * Uses a strategy (currently only default), timers and network availability\n * info to establish a connection and export its state. In case of failures,\n * manages reconnection attempts.\n *\n * Exports state changes as following events:\n * - \"state_change\", { previous: p, current: state }\n * - state\n *\n * States:\n * - initialized - initial state, never transitioned to\n * - connecting - connection is being established\n * - connected - connection has been fully established\n * - disconnected - on requested disconnection\n * - unavailable - after connection timeout or when there's no network\n * - failed - when the connection strategy is not supported\n *\n * Options:\n * - unavailableTimeout - time to transition to unavailable state\n * - activityTimeout - time after which ping message should be sent\n * - pongTimeout - time for Pusher to respond with pong before reconnecting\n *\n * @param {String} key application key\n * @param {Object} options\n */\nexport default class ConnectionManager extends EventsDispatcher {\n key: string;\n options: ConnectionManagerOptions;\n state: string;\n connection: Connection;\n usingTLS: boolean;\n timeline: Timeline;\n socket_id: string;\n unavailableTimer: Timer;\n activityTimer: Timer;\n retryTimer: Timer;\n activityTimeout: number;\n strategy: Strategy;\n runner: StrategyRunner;\n errorCallbacks: ErrorCallbacks;\n handshakeCallbacks: HandshakeCallbacks;\n connectionCallbacks: ConnectionCallbacks;\n\n constructor(key: string, options: ConnectionManagerOptions) {\n super();\n this.state = 'initialized';\n this.connection = null;\n\n this.key = key;\n this.options = options;\n this.timeline = this.options.timeline;\n this.usingTLS = this.options.useTLS;\n\n this.errorCallbacks = this.buildErrorCallbacks();\n this.connectionCallbacks = this.buildConnectionCallbacks(\n this.errorCallbacks\n );\n this.handshakeCallbacks = this.buildHandshakeCallbacks(this.errorCallbacks);\n\n var Network = Runtime.getNetwork();\n\n Network.bind('online', () => {\n this.timeline.info({ netinfo: 'online' });\n if (this.state === 'connecting' || this.state === 'unavailable') {\n this.retryIn(0);\n }\n });\n Network.bind('offline', () => {\n this.timeline.info({ netinfo: 'offline' });\n if (this.connection) {\n this.sendActivityCheck();\n }\n });\n\n this.updateStrategy();\n }\n\n switchCluster(key: string) {\n this.key = key;\n // This ensures that the new config coming from\n // pusher instance are taken into account\n // such as appKey and cluster\n this.updateStrategy();\n this.retryIn(0);\n }\n\n /** Establishes a connection to Pusher.\n *\n * Does nothing when connection is already established. See top-level doc\n * to find events emitted on connection attempts.\n */\n connect() {\n if (this.connection || this.runner) {\n return;\n }\n if (!this.strategy.isSupported()) {\n this.updateState('failed');\n return;\n }\n this.updateState('connecting');\n this.startConnecting();\n this.setUnavailableTimer();\n }\n\n /** Sends raw data.\n *\n * @param {String} data\n */\n send(data) {\n if (this.connection) {\n return this.connection.send(data);\n } else {\n return false;\n }\n }\n\n /** Sends an event.\n *\n * @param {String} name\n * @param {String} data\n * @param {String} [channel]\n * @returns {Boolean} whether message was sent or not\n */\n send_event(name: string, data: any, channel?: string) {\n if (this.connection) {\n return this.connection.send_event(name, data, channel);\n } else {\n return false;\n }\n }\n\n /** Closes the connection. */\n disconnect() {\n this.disconnectInternally();\n this.updateState('disconnected');\n }\n\n isUsingTLS() {\n return this.usingTLS;\n }\n\n private startConnecting() {\n var callback = (error, handshake) => {\n if (error) {\n this.runner = this.strategy.connect(0, callback);\n } else {\n if (handshake.action === 'error') {\n this.emit('error', {\n type: 'HandshakeError',\n error: handshake.error\n });\n this.timeline.error({ handshakeError: handshake.error });\n } else {\n this.abortConnecting(); // we don't support switching connections yet\n this.handshakeCallbacks[handshake.action](handshake);\n }\n }\n };\n this.runner = this.strategy.connect(0, callback);\n }\n\n private abortConnecting() {\n if (this.runner) {\n this.runner.abort();\n this.runner = null;\n }\n }\n\n private disconnectInternally() {\n this.abortConnecting();\n this.clearRetryTimer();\n this.clearUnavailableTimer();\n if (this.connection) {\n var connection = this.abandonConnection();\n connection.close();\n }\n }\n\n private updateStrategy() {\n this.strategy = this.options.getStrategy({\n key: this.key,\n timeline: this.timeline,\n useTLS: this.usingTLS\n });\n }\n\n private retryIn(delay) {\n this.timeline.info({ action: 'retry', delay: delay });\n if (delay > 0) {\n this.emit('connecting_in', Math.round(delay / 1000));\n }\n this.retryTimer = new Timer(delay || 0, () => {\n this.disconnectInternally();\n this.connect();\n });\n }\n\n private clearRetryTimer() {\n if (this.retryTimer) {\n this.retryTimer.ensureAborted();\n this.retryTimer = null;\n }\n }\n\n private setUnavailableTimer() {\n this.unavailableTimer = new Timer(this.options.unavailableTimeout, () => {\n this.updateState('unavailable');\n });\n }\n\n private clearUnavailableTimer() {\n if (this.unavailableTimer) {\n this.unavailableTimer.ensureAborted();\n }\n }\n\n private sendActivityCheck() {\n this.stopActivityCheck();\n this.connection.ping();\n // wait for pong response\n this.activityTimer = new Timer(this.options.pongTimeout, () => {\n this.timeline.error({ pong_timed_out: this.options.pongTimeout });\n this.retryIn(0);\n });\n }\n\n private resetActivityCheck() {\n this.stopActivityCheck();\n // send ping after inactivity\n if (this.connection && !this.connection.handlesActivityChecks()) {\n this.activityTimer = new Timer(this.activityTimeout, () => {\n this.sendActivityCheck();\n });\n }\n }\n\n private stopActivityCheck() {\n if (this.activityTimer) {\n this.activityTimer.ensureAborted();\n }\n }\n\n private buildConnectionCallbacks(\n errorCallbacks: ErrorCallbacks\n ): ConnectionCallbacks {\n return Collections.extend({}, errorCallbacks, {\n message: message => {\n // includes pong messages from server\n this.resetActivityCheck();\n this.emit('message', message);\n },\n ping: () => {\n this.send_event('pusher:pong', {});\n },\n activity: () => {\n this.resetActivityCheck();\n },\n error: error => {\n // just emit error to user - socket will already be closed by browser\n this.emit('error', error);\n },\n closed: () => {\n this.abandonConnection();\n if (this.shouldRetry()) {\n this.retryIn(1000);\n }\n }\n });\n }\n\n private buildHandshakeCallbacks(\n errorCallbacks: ErrorCallbacks\n ): HandshakeCallbacks {\n return Collections.extend({}, errorCallbacks, {\n connected: (handshake: HandshakePayload) => {\n this.activityTimeout = Math.min(\n this.options.activityTimeout,\n handshake.activityTimeout,\n handshake.connection.activityTimeout || Infinity\n );\n this.clearUnavailableTimer();\n this.setConnection(handshake.connection);\n this.socket_id = this.connection.id;\n this.updateState('connected', { socket_id: this.socket_id });\n }\n });\n }\n\n private buildErrorCallbacks(): ErrorCallbacks {\n let withErrorEmitted = callback => {\n return (result: Action | HandshakePayload) => {\n if (result.error) {\n this.emit('error', { type: 'WebSocketError', error: result.error });\n }\n callback(result);\n };\n };\n\n return {\n tls_only: withErrorEmitted(() => {\n this.usingTLS = true;\n this.updateStrategy();\n this.retryIn(0);\n }),\n refused: withErrorEmitted(() => {\n this.disconnect();\n }),\n backoff: withErrorEmitted(() => {\n this.retryIn(1000);\n }),\n retry: withErrorEmitted(() => {\n this.retryIn(0);\n })\n };\n }\n\n private setConnection(connection) {\n this.connection = connection;\n for (var event in this.connectionCallbacks) {\n this.connection.bind(event, this.connectionCallbacks[event]);\n }\n this.resetActivityCheck();\n }\n\n private abandonConnection() {\n if (!this.connection) {\n return;\n }\n this.stopActivityCheck();\n for (var event in this.connectionCallbacks) {\n this.connection.unbind(event, this.connectionCallbacks[event]);\n }\n var connection = this.connection;\n this.connection = null;\n return connection;\n }\n\n private updateState(newState: string, data?: any) {\n var previousState = this.state;\n this.state = newState;\n if (previousState !== newState) {\n var newStateDescription = newState;\n if (newStateDescription === 'connected') {\n newStateDescription += ' with new socket ID ' + data.socket_id;\n }\n Logger.debug(\n 'State changed',\n previousState + ' -> ' + newStateDescription\n );\n this.timeline.info({ state: newState, params: data });\n this.emit('state_change', { previous: previousState, current: newState });\n this.emit(newState, data);\n }\n }\n\n private shouldRetry(): boolean {\n return this.state === 'connecting' || this.state === 'connected';\n }\n}\n","import Channel from './channel';\nimport * as Collections from '../utils/collections';\nimport ChannelTable from './channel_table';\nimport Factory from '../utils/factory';\nimport Pusher from '../pusher';\nimport Logger from '../logger';\nimport * as Errors from '../errors';\nimport urlStore from '../utils/url_store';\n\n/** Handles a channel map. */\nexport default class Channels {\n channels: ChannelTable;\n\n constructor() {\n this.channels = {};\n }\n\n /** Creates or retrieves an existing channel by its name.\n *\n * @param {String} name\n * @param {Pusher} pusher\n * @return {Channel}\n */\n add(name: string, pusher: Pusher) {\n if (!this.channels[name]) {\n this.channels[name] = createChannel(name, pusher);\n }\n return this.channels[name];\n }\n\n /** Returns a list of all channels\n *\n * @return {Array}\n */\n all(): Channel[] {\n return Collections.values(this.channels);\n }\n\n /** Finds a channel by its name.\n *\n * @param {String} name\n * @return {Channel} channel or null if it doesn't exist\n */\n find(name: string) {\n return this.channels[name];\n }\n\n /** Removes a channel from the map.\n *\n * @param {String} name\n */\n remove(name: string) {\n var channel = this.channels[name];\n delete this.channels[name];\n return channel;\n }\n\n /** Proxies disconnection signal to all channels. */\n disconnect() {\n Collections.objectApply(this.channels, function(channel) {\n channel.disconnect();\n });\n }\n}\n\nfunction createChannel(name: string, pusher: Pusher): Channel {\n if (name.indexOf('private-encrypted-') === 0) {\n if (pusher.config.nacl) {\n return Factory.createEncryptedChannel(name, pusher, pusher.config.nacl);\n }\n let errMsg =\n 'Tried to subscribe to a private-encrypted- channel but no nacl implementation available';\n let suffix = urlStore.buildLogSuffix('encryptedChannelSupport');\n throw new Errors.UnsupportedFeature(`${errMsg}. ${suffix}`);\n } else if (name.indexOf('private-') === 0) {\n return Factory.createPrivateChannel(name, pusher);\n } else if (name.indexOf('presence-') === 0) {\n return Factory.createPresenceChannel(name, pusher);\n } else if (name.indexOf('#') === 0) {\n throw new Errors.BadChannelName(\n 'Cannot create a channel with name \"' + name + '\".'\n );\n } else {\n return Factory.createChannel(name, pusher);\n }\n}\n","import AssistantToTheTransportManager from '../transports/assistant_to_the_transport_manager';\nimport PingDelayOptions from '../transports/ping_delay_options';\nimport Transport from '../transports/transport';\nimport TransportManager from '../transports/transport_manager';\nimport Handshake from '../connection/handshake';\nimport TransportConnection from '../transports/transport_connection';\nimport SocketHooks from '../http/socket_hooks';\nimport HTTPSocket from '../http/http_socket';\n\nimport Timeline from '../timeline/timeline';\nimport {\n default as TimelineSender,\n TimelineSenderOptions\n} from '../timeline/timeline_sender';\nimport PresenceChannel from '../channels/presence_channel';\nimport PrivateChannel from '../channels/private_channel';\nimport EncryptedChannel from '../channels/encrypted_channel';\nimport Channel from '../channels/channel';\nimport ConnectionManager from '../connection/connection_manager';\nimport ConnectionManagerOptions from '../connection/connection_manager_options';\nimport Ajax from '../http/ajax';\nimport Channels from '../channels/channels';\nimport Pusher from '../pusher';\nimport { Config } from '../config';\nimport * as nacl from 'tweetnacl';\n\nvar Factory = {\n createChannels(): Channels {\n return new Channels();\n },\n\n createConnectionManager(\n key: string,\n options: ConnectionManagerOptions\n ): ConnectionManager {\n return new ConnectionManager(key, options);\n },\n\n createChannel(name: string, pusher: Pusher): Channel {\n return new Channel(name, pusher);\n },\n\n createPrivateChannel(name: string, pusher: Pusher): PrivateChannel {\n return new PrivateChannel(name, pusher);\n },\n\n createPresenceChannel(name: string, pusher: Pusher): PresenceChannel {\n return new PresenceChannel(name, pusher);\n },\n\n createEncryptedChannel(\n name: string,\n pusher: Pusher,\n nacl: nacl\n ): EncryptedChannel {\n return new EncryptedChannel(name, pusher, nacl);\n },\n\n createTimelineSender(timeline: Timeline, options: TimelineSenderOptions) {\n return new TimelineSender(timeline, options);\n },\n\n createHandshake(\n transport: TransportConnection,\n callback: (HandshakePayload) => void\n ): Handshake {\n return new Handshake(transport, callback);\n },\n\n createAssistantToTheTransportManager(\n manager: TransportManager,\n transport: Transport,\n options: PingDelayOptions\n ): AssistantToTheTransportManager {\n return new AssistantToTheTransportManager(manager, transport, options);\n }\n};\n\nexport default Factory;\n","import AssistantToTheTransportManager from './assistant_to_the_transport_manager';\nimport Transport from './transport';\nimport PingDelayOptions from './ping_delay_options';\nimport Factory from '../utils/factory';\n\nexport interface TransportManagerOptions extends PingDelayOptions {\n lives?: number;\n}\n\n/** Keeps track of the number of lives left for a transport.\n *\n * In the beginning of a session, transports may be assigned a number of\n * lives. When an AssistantToTheTransportManager instance reports a transport\n * connection closed uncleanly, the transport loses a life. When the number\n * of lives drops to zero, the transport gets disabled by its manager.\n *\n * @param {Object} options\n */\nexport default class TransportManager {\n options: TransportManagerOptions;\n livesLeft: number;\n\n constructor(options: TransportManagerOptions) {\n this.options = options || {};\n this.livesLeft = this.options.lives || Infinity;\n }\n\n /** Creates a assistant for the transport.\n *\n * @param {Transport} transport\n * @returns {AssistantToTheTransportManager}\n */\n getAssistant(transport: Transport): AssistantToTheTransportManager {\n return Factory.createAssistantToTheTransportManager(this, transport, {\n minPingDelay: this.options.minPingDelay,\n maxPingDelay: this.options.maxPingDelay\n });\n }\n\n /** Returns whether the transport has any lives left.\n *\n * @returns {Boolean}\n */\n isAlive(): boolean {\n return this.livesLeft > 0;\n }\n\n /** Takes one life from the transport. */\n reportDeath() {\n this.livesLeft -= 1;\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport { OneOffTimer as Timer } from '../utils/timers';\nimport Strategy from './strategy';\nimport StrategyOptions from './strategy_options';\n\n/** Loops through strategies with optional timeouts.\n *\n * Options:\n * - loop - whether it should loop through the substrategy list\n * - timeout - initial timeout for a single substrategy\n * - timeoutLimit - maximum timeout\n *\n * @param {Strategy[]} strategies\n * @param {Object} options\n */\nexport default class SequentialStrategy implements Strategy {\n strategies: Strategy[];\n loop: boolean;\n failFast: boolean;\n timeout: number;\n timeoutLimit: number;\n\n constructor(strategies: Strategy[], options: StrategyOptions) {\n this.strategies = strategies;\n this.loop = Boolean(options.loop);\n this.failFast = Boolean(options.failFast);\n this.timeout = options.timeout;\n this.timeoutLimit = options.timeoutLimit;\n }\n\n isSupported(): boolean {\n return Collections.any(this.strategies, Util.method('isSupported'));\n }\n\n connect(minPriority: number, callback: Function) {\n var strategies = this.strategies;\n var current = 0;\n var timeout = this.timeout;\n var runner = null;\n\n var tryNextStrategy = (error, handshake) => {\n if (handshake) {\n callback(null, handshake);\n } else {\n current = current + 1;\n if (this.loop) {\n current = current % strategies.length;\n }\n\n if (current < strategies.length) {\n if (timeout) {\n timeout = timeout * 2;\n if (this.timeoutLimit) {\n timeout = Math.min(timeout, this.timeoutLimit);\n }\n }\n runner = this.tryStrategy(\n strategies[current],\n minPriority,\n { timeout, failFast: this.failFast },\n tryNextStrategy\n );\n } else {\n callback(true);\n }\n }\n };\n\n runner = this.tryStrategy(\n strategies[current],\n minPriority,\n { timeout: timeout, failFast: this.failFast },\n tryNextStrategy\n );\n\n return {\n abort: function() {\n runner.abort();\n },\n forceMinPriority: function(p) {\n minPriority = p;\n if (runner) {\n runner.forceMinPriority(p);\n }\n }\n };\n }\n\n private tryStrategy(\n strategy: Strategy,\n minPriority: number,\n options: StrategyOptions,\n callback: Function\n ) {\n var timer = null;\n var runner = null;\n\n if (options.timeout > 0) {\n timer = new Timer(options.timeout, function() {\n runner.abort();\n callback(true);\n });\n }\n\n runner = strategy.connect(minPriority, function(error, handshake) {\n if (error && timer && timer.isRunning() && !options.failFast) {\n // advance to the next strategy after the timeout\n return;\n }\n if (timer) {\n timer.ensureAborted();\n }\n callback(error, handshake);\n });\n\n return {\n abort: function() {\n if (timer) {\n timer.ensureAborted();\n }\n runner.abort();\n },\n forceMinPriority: function(p) {\n runner.forceMinPriority(p);\n }\n };\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport Strategy from './strategy';\n\n/** Launches all substrategies and emits prioritized connected transports.\n *\n * @param {Array} strategies\n */\nexport default class BestConnectedEverStrategy implements Strategy {\n strategies: Strategy[];\n\n constructor(strategies: Strategy[]) {\n this.strategies = strategies;\n }\n\n isSupported(): boolean {\n return Collections.any(this.strategies, Util.method('isSupported'));\n }\n\n connect(minPriority: number, callback: Function) {\n return connect(this.strategies, minPriority, function(i, runners) {\n return function(error, handshake) {\n runners[i].error = error;\n if (error) {\n if (allRunnersFailed(runners)) {\n callback(true);\n }\n return;\n }\n Collections.apply(runners, function(runner) {\n runner.forceMinPriority(handshake.transport.priority);\n });\n callback(null, handshake);\n };\n });\n }\n}\n\n/** Connects to all strategies in parallel.\n *\n * Callback builder should be a function that takes two arguments: index\n * and a list of runners. It should return another function that will be\n * passed to the substrategy with given index. Runners can be aborted using\n * abortRunner(s) functions from this class.\n *\n * @param {Array} strategies\n * @param {Function} callbackBuilder\n * @return {Object} strategy runner\n */\nfunction connect(\n strategies: Strategy[],\n minPriority: number,\n callbackBuilder: Function\n) {\n var runners = Collections.map(strategies, function(strategy, i, _, rs) {\n return strategy.connect(minPriority, callbackBuilder(i, rs));\n });\n return {\n abort: function() {\n Collections.apply(runners, abortRunner);\n },\n forceMinPriority: function(p) {\n Collections.apply(runners, function(runner) {\n runner.forceMinPriority(p);\n });\n }\n };\n}\n\nfunction allRunnersFailed(runners): boolean {\n return Collections.all(runners, function(runner) {\n return Boolean(runner.error);\n });\n}\n\nfunction abortRunner(runner) {\n if (!runner.error && !runner.aborted) {\n runner.abort();\n runner.aborted = true;\n }\n}\n","import Util from '../util';\nimport Runtime from 'runtime';\nimport Strategy from './strategy';\nimport SequentialStrategy from './sequential_strategy';\nimport StrategyOptions from './strategy_options';\nimport TransportStrategy from './transport_strategy';\nimport Timeline from '../timeline/timeline';\nimport * as Collections from '../utils/collections';\n\nexport interface TransportStrategyDictionary {\n [key: string]: TransportStrategy;\n}\n\n/** Caches the last successful transport and, after the first few attempts,\n * uses the cached transport for subsequent attempts.\n *\n * @param {Strategy} strategy\n * @param {Object} transports\n * @param {Object} options\n */\nexport default class WebSocketPrioritizedCachedStrategy implements Strategy {\n strategy: Strategy;\n transports: TransportStrategyDictionary;\n ttl: number;\n usingTLS: boolean;\n timeline: Timeline;\n\n constructor(\n strategy: Strategy,\n transports: TransportStrategyDictionary,\n options: StrategyOptions\n ) {\n this.strategy = strategy;\n this.transports = transports;\n this.ttl = options.ttl || 1800 * 1000;\n this.usingTLS = options.useTLS;\n this.timeline = options.timeline;\n }\n\n isSupported(): boolean {\n return this.strategy.isSupported();\n }\n\n connect(minPriority: number, callback: Function) {\n var usingTLS = this.usingTLS;\n var info = fetchTransportCache(usingTLS);\n var cacheSkipCount = info && info.cacheSkipCount ? info.cacheSkipCount : 0;\n\n var strategies = [this.strategy];\n if (info && info.timestamp + this.ttl >= Util.now()) {\n var transport = this.transports[info.transport];\n if (transport) {\n if (['ws', 'wss'].includes(info.transport) || cacheSkipCount > 3) {\n this.timeline.info({\n cached: true,\n transport: info.transport,\n latency: info.latency\n });\n strategies.push(\n new SequentialStrategy([transport], {\n timeout: info.latency * 2 + 1000,\n failFast: true\n })\n );\n } else {\n cacheSkipCount++;\n }\n }\n }\n\n var startTimestamp = Util.now();\n var runner = strategies\n .pop()\n .connect(minPriority, function cb(error, handshake) {\n if (error) {\n flushTransportCache(usingTLS);\n if (strategies.length > 0) {\n startTimestamp = Util.now();\n runner = strategies.pop().connect(minPriority, cb);\n } else {\n callback(error);\n }\n } else {\n storeTransportCache(\n usingTLS,\n handshake.transport.name,\n Util.now() - startTimestamp,\n cacheSkipCount\n );\n callback(null, handshake);\n }\n });\n\n return {\n abort: function() {\n runner.abort();\n },\n forceMinPriority: function(p) {\n minPriority = p;\n if (runner) {\n runner.forceMinPriority(p);\n }\n }\n };\n }\n}\n\nfunction getTransportCacheKey(usingTLS: boolean): string {\n return 'pusherTransport' + (usingTLS ? 'TLS' : 'NonTLS');\n}\n\nfunction fetchTransportCache(usingTLS: boolean): any {\n var storage = Runtime.getLocalStorage();\n if (storage) {\n try {\n var serializedCache = storage[getTransportCacheKey(usingTLS)];\n if (serializedCache) {\n return JSON.parse(serializedCache);\n }\n } catch (e) {\n flushTransportCache(usingTLS);\n }\n }\n return null;\n}\n\nfunction storeTransportCache(\n usingTLS: boolean,\n transport: TransportStrategy,\n latency: number,\n cacheSkipCount: number\n) {\n var storage = Runtime.getLocalStorage();\n if (storage) {\n try {\n storage[getTransportCacheKey(usingTLS)] = Collections.safeJSONStringify({\n timestamp: Util.now(),\n transport: transport,\n latency: latency,\n cacheSkipCount: cacheSkipCount\n });\n } catch (e) {\n // catch over quota exceptions raised by localStorage\n }\n }\n}\n\nfunction flushTransportCache(usingTLS: boolean) {\n var storage = Runtime.getLocalStorage();\n if (storage) {\n try {\n delete storage[getTransportCacheKey(usingTLS)];\n } catch (e) {\n // catch exceptions raised by localStorage\n }\n }\n}\n","import { OneOffTimer as Timer } from '../utils/timers';\nimport Strategy from './strategy';\nimport StrategyOptions from './strategy_options';\n\n/** Runs substrategy after specified delay.\n *\n * Options:\n * - delay - time in miliseconds to delay the substrategy attempt\n *\n * @param {Strategy} strategy\n * @param {Object} options\n */\nexport default class DelayedStrategy implements Strategy {\n strategy: Strategy;\n options: { delay: number };\n\n constructor(strategy: Strategy, { delay: number }) {\n this.strategy = strategy;\n this.options = { delay: number };\n }\n\n isSupported(): boolean {\n return this.strategy.isSupported();\n }\n\n connect(minPriority: number, callback: Function) {\n var strategy = this.strategy;\n var runner;\n var timer = new Timer(this.options.delay, function() {\n runner = strategy.connect(minPriority, callback);\n });\n\n return {\n abort: function() {\n timer.ensureAborted();\n if (runner) {\n runner.abort();\n }\n },\n forceMinPriority: function(p) {\n minPriority = p;\n if (runner) {\n runner.forceMinPriority(p);\n }\n }\n };\n }\n}\n","import Strategy from './strategy';\nimport StrategyRunner from './strategy_runner';\n\n/** Proxies method calls to one of substrategies basing on the test function.\n *\n * @param {Function} test\n * @param {Strategy} trueBranch strategy used when test returns true\n * @param {Strategy} falseBranch strategy used when test returns false\n */\nexport default class IfStrategy implements Strategy {\n test: () => boolean;\n trueBranch: Strategy;\n falseBranch: Strategy;\n\n constructor(\n test: () => boolean,\n trueBranch: Strategy,\n falseBranch: Strategy\n ) {\n this.test = test;\n this.trueBranch = trueBranch;\n this.falseBranch = falseBranch;\n }\n\n isSupported(): boolean {\n var branch = this.test() ? this.trueBranch : this.falseBranch;\n return branch.isSupported();\n }\n\n connect(minPriority: number, callback: Function): StrategyRunner {\n var branch = this.test() ? this.trueBranch : this.falseBranch;\n return branch.connect(minPriority, callback);\n }\n}\n","import Strategy from './strategy';\nimport StrategyRunner from './strategy_runner';\n\n/** Launches the substrategy and terminates on the first open connection.\n *\n * @param {Strategy} strategy\n */\nexport default class FirstConnectedStrategy implements Strategy {\n strategy: Strategy;\n\n constructor(strategy: Strategy) {\n this.strategy = strategy;\n }\n\n isSupported(): boolean {\n return this.strategy.isSupported();\n }\n\n connect(minPriority: number, callback: Function): StrategyRunner {\n var runner = this.strategy.connect(minPriority, function(error, handshake) {\n if (handshake) {\n runner.abort();\n }\n callback(error, handshake);\n });\n return runner;\n }\n}\n","import * as Collections from 'core/utils/collections';\nimport TransportManager from 'core/transports/transport_manager';\nimport Strategy from 'core/strategies/strategy';\nimport StrategyOptions from 'core/strategies/strategy_options';\nimport SequentialStrategy from 'core/strategies/sequential_strategy';\nimport BestConnectedEverStrategy from 'core/strategies/best_connected_ever_strategy';\nimport WebSocketPrioritizedCachedStrategy, {\n TransportStrategyDictionary\n} from 'core/strategies/websocket_prioritized_cached_strategy';\nimport DelayedStrategy from 'core/strategies/delayed_strategy';\nimport IfStrategy from 'core/strategies/if_strategy';\nimport FirstConnectedStrategy from 'core/strategies/first_connected_strategy';\nimport { Config } from 'core/config';\n\nfunction testSupportsStrategy(strategy: Strategy) {\n return function() {\n return strategy.isSupported();\n };\n}\n\nvar getDefaultStrategy = function(\n config: Config,\n baseOptions: StrategyOptions,\n defineTransport: Function\n): Strategy {\n var definedTransports = {};\n\n function defineTransportStrategy(\n name: string,\n type: string,\n priority: number,\n options: StrategyOptions,\n manager?: TransportManager\n ) {\n var transport = defineTransport(\n config,\n name,\n type,\n priority,\n options,\n manager\n );\n\n definedTransports[name] = transport;\n\n return transport;\n }\n\n var ws_options: StrategyOptions = Object.assign({}, baseOptions, {\n hostNonTLS: config.wsHost + ':' + config.wsPort,\n hostTLS: config.wsHost + ':' + config.wssPort,\n httpPath: config.wsPath\n });\n var wss_options: StrategyOptions = Object.assign({}, ws_options, {\n useTLS: true\n });\n var sockjs_options: StrategyOptions = Object.assign({}, baseOptions, {\n hostNonTLS: config.httpHost + ':' + config.httpPort,\n hostTLS: config.httpHost + ':' + config.httpsPort,\n httpPath: config.httpPath\n });\n\n var timeouts = {\n loop: true,\n timeout: 15000,\n timeoutLimit: 60000\n };\n\n var ws_manager = new TransportManager({\n minPingDelay: 10000,\n maxPingDelay: config.activityTimeout\n });\n var streaming_manager = new TransportManager({\n lives: 2,\n minPingDelay: 10000,\n maxPingDelay: config.activityTimeout\n });\n\n var ws_transport = defineTransportStrategy(\n 'ws',\n 'ws',\n 3,\n ws_options,\n ws_manager\n );\n var wss_transport = defineTransportStrategy(\n 'wss',\n 'ws',\n 3,\n wss_options,\n ws_manager\n );\n var sockjs_transport = defineTransportStrategy(\n 'sockjs',\n 'sockjs',\n 1,\n sockjs_options\n );\n var xhr_streaming_transport = defineTransportStrategy(\n 'xhr_streaming',\n 'xhr_streaming',\n 1,\n sockjs_options,\n streaming_manager\n );\n var xdr_streaming_transport = defineTransportStrategy(\n 'xdr_streaming',\n 'xdr_streaming',\n 1,\n sockjs_options,\n streaming_manager\n );\n var xhr_polling_transport = defineTransportStrategy(\n 'xhr_polling',\n 'xhr_polling',\n 1,\n sockjs_options\n );\n var xdr_polling_transport = defineTransportStrategy(\n 'xdr_polling',\n 'xdr_polling',\n 1,\n sockjs_options\n );\n\n var ws_loop = new SequentialStrategy([ws_transport], timeouts);\n var wss_loop = new SequentialStrategy([wss_transport], timeouts);\n var sockjs_loop = new SequentialStrategy([sockjs_transport], timeouts);\n var streaming_loop = new SequentialStrategy(\n [\n new IfStrategy(\n testSupportsStrategy(xhr_streaming_transport),\n xhr_streaming_transport,\n xdr_streaming_transport\n )\n ],\n timeouts\n );\n var polling_loop = new SequentialStrategy(\n [\n new IfStrategy(\n testSupportsStrategy(xhr_polling_transport),\n xhr_polling_transport,\n xdr_polling_transport\n )\n ],\n timeouts\n );\n\n var http_loop = new SequentialStrategy(\n [\n new IfStrategy(\n testSupportsStrategy(streaming_loop),\n new BestConnectedEverStrategy([\n streaming_loop,\n new DelayedStrategy(polling_loop, { delay: 4000 })\n ]),\n polling_loop\n )\n ],\n timeouts\n );\n\n var http_fallback_loop = new IfStrategy(\n testSupportsStrategy(http_loop),\n http_loop,\n sockjs_loop\n );\n\n var wsStrategy;\n if (baseOptions.useTLS) {\n wsStrategy = new BestConnectedEverStrategy([\n ws_loop,\n new DelayedStrategy(http_fallback_loop, { delay: 2000 })\n ]);\n } else {\n wsStrategy = new BestConnectedEverStrategy([\n ws_loop,\n new DelayedStrategy(wss_loop, { delay: 2000 }),\n new DelayedStrategy(http_fallback_loop, { delay: 5000 })\n ]);\n }\n\n return new WebSocketPrioritizedCachedStrategy(\n new FirstConnectedStrategy(\n new IfStrategy(\n testSupportsStrategy(ws_transport),\n wsStrategy,\n http_fallback_loop\n )\n ),\n definedTransports,\n {\n ttl: 1800000,\n timeline: baseOptions.timeline,\n useTLS: baseOptions.useTLS\n }\n );\n};\n\nexport default getDefaultStrategy;\n","import HTTPRequest from 'core/http/http_request';\nimport RequestHooks from 'core/http/request_hooks';\nimport Ajax from 'core/http/ajax';\nimport * as Errors from 'core/errors';\n\nvar hooks: RequestHooks = {\n getRequest: function(socket: HTTPRequest): Ajax {\n var xdr = new (window).XDomainRequest();\n xdr.ontimeout = function() {\n socket.emit('error', new Errors.RequestTimedOut());\n socket.close();\n };\n xdr.onerror = function(e) {\n socket.emit('error', e);\n socket.close();\n };\n xdr.onprogress = function() {\n if (xdr.responseText && xdr.responseText.length > 0) {\n socket.onChunk(200, xdr.responseText);\n }\n };\n xdr.onload = function() {\n if (xdr.responseText && xdr.responseText.length > 0) {\n socket.onChunk(200, xdr.responseText);\n }\n socket.emit('finished', 200);\n socket.close();\n };\n return xdr;\n },\n abortRequest: function(xdr: Ajax) {\n xdr.ontimeout = xdr.onerror = xdr.onprogress = xdr.onload = null;\n xdr.abort();\n }\n};\n\nexport default hooks;\n","import Runtime from 'runtime';\nimport RequestHooks from './request_hooks';\nimport Ajax from './ajax';\nimport { default as EventsDispatcher } from '../events/dispatcher';\n\nconst MAX_BUFFER_LENGTH = 256 * 1024;\n\nexport default class HTTPRequest extends EventsDispatcher {\n hooks: RequestHooks;\n method: string;\n url: string;\n position: number;\n xhr: Ajax;\n unloader: Function;\n\n constructor(hooks: RequestHooks, method: string, url: string) {\n super();\n this.hooks = hooks;\n this.method = method;\n this.url = url;\n }\n\n start(payload?: any) {\n this.position = 0;\n this.xhr = this.hooks.getRequest(this);\n\n this.unloader = () => {\n this.close();\n };\n Runtime.addUnloadListener(this.unloader);\n\n this.xhr.open(this.method, this.url, true);\n\n if (this.xhr.setRequestHeader) {\n this.xhr.setRequestHeader('Content-Type', 'application/json'); // ReactNative doesn't set this header by default.\n }\n this.xhr.send(payload);\n }\n\n close() {\n if (this.unloader) {\n Runtime.removeUnloadListener(this.unloader);\n this.unloader = null;\n }\n if (this.xhr) {\n this.hooks.abortRequest(this.xhr);\n this.xhr = null;\n }\n }\n\n onChunk(status: number, data: any) {\n while (true) {\n var chunk = this.advanceBuffer(data);\n if (chunk) {\n this.emit('chunk', { status: status, data: chunk });\n } else {\n break;\n }\n }\n if (this.isBufferTooLong(data)) {\n this.emit('buffer_too_long');\n }\n }\n\n private advanceBuffer(buffer: any[]): any {\n var unreadData = buffer.slice(this.position);\n var endOfLinePosition = unreadData.indexOf('\\n');\n\n if (endOfLinePosition !== -1) {\n this.position += endOfLinePosition + 1;\n return unreadData.slice(0, endOfLinePosition);\n } else {\n // chunk is not finished yet, don't move the buffer pointer\n return null;\n }\n }\n\n private isBufferTooLong(buffer: any): boolean {\n return this.position === buffer.length && buffer.length > MAX_BUFFER_LENGTH;\n }\n}\n","enum State {\n CONNECTING = 0,\n OPEN = 1,\n CLOSED = 3\n}\n\nexport default State;\n","import URLLocation from './url_location';\nimport State from './state';\nimport Socket from '../socket';\nimport SocketHooks from './socket_hooks';\nimport Util from '../util';\nimport Ajax from './ajax';\nimport HTTPRequest from './http_request';\nimport Runtime from 'runtime';\n\nvar autoIncrement = 1;\n\nclass HTTPSocket implements Socket {\n hooks: SocketHooks;\n session: string;\n location: URLLocation;\n readyState: State;\n stream: HTTPRequest;\n\n onopen: () => void;\n onerror: (error: any) => void;\n onclose: (closeEvent: any) => void;\n onmessage: (message: any) => void;\n onactivity: () => void;\n\n constructor(hooks: SocketHooks, url: string) {\n this.hooks = hooks;\n this.session = randomNumber(1000) + '/' + randomString(8);\n this.location = getLocation(url);\n this.readyState = State.CONNECTING;\n this.openStream();\n }\n\n send(payload: any) {\n return this.sendRaw(JSON.stringify([payload]));\n }\n\n ping() {\n this.hooks.sendHeartbeat(this);\n }\n\n close(code: any, reason: any) {\n this.onClose(code, reason, true);\n }\n\n /** For internal use only */\n sendRaw(payload: any): boolean {\n if (this.readyState === State.OPEN) {\n try {\n Runtime.createSocketRequest(\n 'POST',\n getUniqueURL(getSendURL(this.location, this.session))\n ).start(payload);\n return true;\n } catch (e) {\n return false;\n }\n } else {\n return false;\n }\n }\n\n /** For internal use only */\n reconnect() {\n this.closeStream();\n this.openStream();\n }\n\n /** For internal use only */\n onClose(code, reason, wasClean) {\n this.closeStream();\n this.readyState = State.CLOSED;\n if (this.onclose) {\n this.onclose({\n code: code,\n reason: reason,\n wasClean: wasClean\n });\n }\n }\n\n private onChunk(chunk) {\n if (chunk.status !== 200) {\n return;\n }\n if (this.readyState === State.OPEN) {\n this.onActivity();\n }\n\n var payload;\n var type = chunk.data.slice(0, 1);\n switch (type) {\n case 'o':\n payload = JSON.parse(chunk.data.slice(1) || '{}');\n this.onOpen(payload);\n break;\n case 'a':\n payload = JSON.parse(chunk.data.slice(1) || '[]');\n for (var i = 0; i < payload.length; i++) {\n this.onEvent(payload[i]);\n }\n break;\n case 'm':\n payload = JSON.parse(chunk.data.slice(1) || 'null');\n this.onEvent(payload);\n break;\n case 'h':\n this.hooks.onHeartbeat(this);\n break;\n case 'c':\n payload = JSON.parse(chunk.data.slice(1) || '[]');\n this.onClose(payload[0], payload[1], true);\n break;\n }\n }\n\n private onOpen(options) {\n if (this.readyState === State.CONNECTING) {\n if (options && options.hostname) {\n this.location.base = replaceHost(this.location.base, options.hostname);\n }\n this.readyState = State.OPEN;\n\n if (this.onopen) {\n this.onopen();\n }\n } else {\n this.onClose(1006, 'Server lost session', true);\n }\n }\n\n private onEvent(event) {\n if (this.readyState === State.OPEN && this.onmessage) {\n this.onmessage({ data: event });\n }\n }\n\n private onActivity() {\n if (this.onactivity) {\n this.onactivity();\n }\n }\n\n private onError(error) {\n if (this.onerror) {\n this.onerror(error);\n }\n }\n\n private openStream() {\n this.stream = Runtime.createSocketRequest(\n 'POST',\n getUniqueURL(this.hooks.getReceiveURL(this.location, this.session))\n );\n\n this.stream.bind('chunk', chunk => {\n this.onChunk(chunk);\n });\n this.stream.bind('finished', status => {\n this.hooks.onFinished(this, status);\n });\n this.stream.bind('buffer_too_long', () => {\n this.reconnect();\n });\n\n try {\n this.stream.start();\n } catch (error) {\n Util.defer(() => {\n this.onError(error);\n this.onClose(1006, 'Could not start streaming', false);\n });\n }\n }\n\n private closeStream() {\n if (this.stream) {\n this.stream.unbind_all();\n this.stream.close();\n this.stream = null;\n }\n }\n}\n\nfunction getLocation(url): URLLocation {\n var parts = /([^\\?]*)\\/*(\\??.*)/.exec(url);\n return {\n base: parts[1],\n queryString: parts[2]\n };\n}\n\nfunction getSendURL(url: URLLocation, session: string): string {\n return url.base + '/' + session + '/xhr_send';\n}\n\nfunction getUniqueURL(url: string): string {\n var separator = url.indexOf('?') === -1 ? '?' : '&';\n return url + separator + 't=' + +new Date() + '&n=' + autoIncrement++;\n}\n\nfunction replaceHost(url: string, hostname: string): string {\n var urlParts = /(https?:\\/\\/)([^\\/:]+)((\\/|:)?.*)/.exec(url);\n return urlParts[1] + hostname + urlParts[3];\n}\n\nfunction randomNumber(max: number): number {\n return Runtime.randomInt(max);\n}\n\nfunction randomString(length: number): string {\n var result = [];\n\n for (var i = 0; i < length; i++) {\n result.push(randomNumber(32).toString(32));\n }\n\n return result.join('');\n}\n\nexport default HTTPSocket;\n","enum TimelineLevel {\n ERROR = 3,\n INFO = 6,\n DEBUG = 7\n}\n\nexport default TimelineLevel;\n","import SocketHooks from './socket_hooks';\nimport HTTPSocket from './http_socket';\n\nvar hooks: SocketHooks = {\n getReceiveURL: function(url, session) {\n return url.base + '/' + session + '/xhr_streaming' + url.queryString;\n },\n onHeartbeat: function(socket) {\n socket.sendRaw('[]');\n },\n sendHeartbeat: function(socket) {\n socket.sendRaw('[]');\n },\n onFinished: function(socket, status) {\n socket.onClose(1006, 'Connection interrupted (' + status + ')', false);\n }\n};\n\nexport default hooks;\n","import SocketHooks from './socket_hooks';\nimport URLLocation from './url_location';\nimport HTTPSocket from './http_socket';\n\nvar hooks: SocketHooks = {\n getReceiveURL: function(url: URLLocation, session: string): string {\n return url.base + '/' + session + '/xhr' + url.queryString;\n },\n onHeartbeat: function() {\n // next HTTP request will reset server's activity timer\n },\n sendHeartbeat: function(socket) {\n socket.sendRaw('[]');\n },\n onFinished: function(socket, status) {\n if (status === 200) {\n socket.reconnect();\n } else {\n socket.onClose(1006, 'Connection interrupted (' + status + ')', false);\n }\n }\n};\n\nexport default hooks;\n","import HTTPRequest from 'core/http/http_request';\nimport RequestHooks from 'core/http/request_hooks';\nimport Ajax from 'core/http/ajax';\nimport Runtime from 'runtime';\n\nvar hooks: RequestHooks = {\n getRequest: function(socket: HTTPRequest): Ajax {\n var Constructor = Runtime.getXHRAPI();\n var xhr = new Constructor();\n xhr.onreadystatechange = xhr.onprogress = function() {\n switch (xhr.readyState) {\n case 3:\n if (xhr.responseText && xhr.responseText.length > 0) {\n socket.onChunk(xhr.status, xhr.responseText);\n }\n break;\n case 4:\n // this happens only on errors, never after calling close\n if (xhr.responseText && xhr.responseText.length > 0) {\n socket.onChunk(xhr.status, xhr.responseText);\n }\n socket.emit('finished', xhr.status);\n socket.close();\n break;\n }\n };\n return xhr;\n },\n abortRequest: function(xhr: Ajax) {\n xhr.onreadystatechange = null;\n xhr.abort();\n }\n};\n\nexport default hooks;\n","import HTTPRequest from 'core/http/http_request';\nimport HTTPSocket from 'core/http/http_socket';\nimport SocketHooks from 'core/http/socket_hooks';\nimport RequestHooks from 'core/http/request_hooks';\nimport streamingHooks from 'core/http/http_streaming_socket';\nimport pollingHooks from 'core/http/http_polling_socket';\nimport xhrHooks from './http_xhr_request';\nimport HTTPFactory from 'core/http/http_factory';\n\nvar HTTP: HTTPFactory = {\n createStreamingSocket(url: string): HTTPSocket {\n return this.createSocket(streamingHooks, url);\n },\n\n createPollingSocket(url: string): HTTPSocket {\n return this.createSocket(pollingHooks, url);\n },\n\n createSocket(hooks: SocketHooks, url: string): HTTPSocket {\n return new HTTPSocket(hooks, url);\n },\n\n createXHR(method: string, url: string): HTTPRequest {\n return this.createRequest(xhrHooks, method, url);\n },\n\n createRequest(hooks: RequestHooks, method: string, url: string): HTTPRequest {\n return new HTTPRequest(hooks, method, url);\n }\n};\n\nexport default HTTP;\n","import xdrHooks from './http_xdomain_request';\nimport HTTP from 'isomorphic/http/http';\n\nHTTP.createXDR = function(method, url) {\n return this.createRequest(xdrHooks, method, url);\n};\n\nexport default HTTP;\n","import Browser from './browser';\nimport { Dependencies, DependenciesReceivers } from './dom/dependencies';\nimport { AuthTransport, AuthTransports } from 'core/auth/auth_transports';\nimport xhrAuth from 'isomorphic/auth/xhr_auth';\nimport jsonpAuth from './auth/jsonp_auth';\nimport TimelineTransport from 'core/timeline/timeline_transport';\nimport TimelineSender from 'core/timeline/timeline_sender';\nimport ScriptRequest from './dom/script_request';\nimport JSONPRequest from './dom/jsonp_request';\nimport * as Collections from 'core/utils/collections';\nimport { ScriptReceivers } from './dom/script_receiver_factory';\nimport jsonpTimeline from './timeline/jsonp_timeline';\nimport Transports from './transports/transports';\nimport Ajax from 'core/http/ajax';\nimport { Network } from './net_info';\nimport getDefaultStrategy from './default_strategy';\nimport transportConnectionInitializer from './transports/transport_connection_initializer';\nimport HTTPFactory from './http/http';\nimport HTTPRequest from 'core/http/http_request';\n\nvar Runtime: Browser = {\n // for jsonp auth\n nextAuthCallbackID: 1,\n auth_callbacks: {},\n ScriptReceivers,\n DependenciesReceivers,\n getDefaultStrategy,\n Transports,\n transportConnectionInitializer,\n HTTPFactory,\n\n TimelineTransport: jsonpTimeline,\n\n getXHRAPI() {\n return window.XMLHttpRequest;\n },\n\n getWebSocketAPI() {\n return window.WebSocket || window.MozWebSocket;\n },\n\n setup(PusherClass): void {\n (window).Pusher = PusherClass; // JSONp requires Pusher to be in the global scope.\n var initializeOnDocumentBody = () => {\n this.onDocumentBody(PusherClass.ready);\n };\n if (!(window).JSON) {\n Dependencies.load('json2', {}, initializeOnDocumentBody);\n } else {\n initializeOnDocumentBody();\n }\n },\n\n getDocument(): Document {\n return document;\n },\n\n getProtocol(): string {\n return this.getDocument().location.protocol;\n },\n\n getAuthorizers(): AuthTransports {\n return { ajax: xhrAuth, jsonp: jsonpAuth };\n },\n\n onDocumentBody(callback: Function) {\n if (document.body) {\n callback();\n } else {\n setTimeout(() => {\n this.onDocumentBody(callback);\n }, 0);\n }\n },\n\n createJSONPRequest(url: string, data: any): JSONPRequest {\n return new JSONPRequest(url, data);\n },\n\n createScriptRequest(src: string): ScriptRequest {\n return new ScriptRequest(src);\n },\n\n getLocalStorage() {\n try {\n return window.localStorage;\n } catch (e) {\n return undefined;\n }\n },\n\n createXHR(): Ajax {\n if (this.getXHRAPI()) {\n return this.createXMLHttpRequest();\n } else {\n return this.createMicrosoftXHR();\n }\n },\n\n createXMLHttpRequest(): Ajax {\n var Constructor = this.getXHRAPI();\n return new Constructor();\n },\n\n createMicrosoftXHR(): Ajax {\n return new ActiveXObject('Microsoft.XMLHTTP');\n },\n\n getNetwork() {\n return Network;\n },\n\n createWebSocket(url: string): any {\n var Constructor = this.getWebSocketAPI();\n return new Constructor(url);\n },\n\n createSocketRequest(method: string, url: string): HTTPRequest {\n if (this.isXHRSupported()) {\n return this.HTTPFactory.createXHR(method, url);\n } else if (this.isXDRSupported(url.indexOf('https:') === 0)) {\n return this.HTTPFactory.createXDR(method, url);\n } else {\n throw 'Cross-origin HTTP requests are not supported';\n }\n },\n\n isXHRSupported(): boolean {\n var Constructor = this.getXHRAPI();\n return (\n Boolean(Constructor) && new Constructor().withCredentials !== undefined\n );\n },\n\n isXDRSupported(useTLS?: boolean): boolean {\n var protocol = useTLS ? 'https:' : 'http:';\n var documentProtocol = this.getProtocol();\n return (\n Boolean(window['XDomainRequest']) && documentProtocol === protocol\n );\n },\n\n addUnloadListener(listener: any) {\n if (window.addEventListener !== undefined) {\n window.addEventListener('unload', listener, false);\n } else if (window.attachEvent !== undefined) {\n window.attachEvent('onunload', listener);\n }\n },\n\n removeUnloadListener(listener: any) {\n if (window.addEventListener !== undefined) {\n window.removeEventListener('unload', listener, false);\n } else if (window.detachEvent !== undefined) {\n window.detachEvent('onunload', listener);\n }\n },\n\n randomInt(max: number): number {\n /**\n * Return values in the range of [0, 1[\n */\n const random = function() {\n const crypto = window.crypto || window['msCrypto'];\n const random = crypto.getRandomValues(new Uint32Array(1))[0];\n\n return random / 2 ** 32;\n };\n\n return Math.floor(random() * max);\n }\n};\n\nexport default Runtime;\n","import { Dependencies } from '../dom/dependencies';\n\n/** Initializes the transport.\n *\n * Fetches resources if needed and then transitions to initialized.\n */\nexport default function() {\n var self = this;\n\n self.timeline.info(\n self.buildTimelineMessage({\n transport: self.name + (self.options.useTLS ? 's' : '')\n })\n );\n\n if (self.hooks.isInitialized()) {\n self.changeState('initialized');\n } else if (self.hooks.file) {\n self.changeState('initializing');\n Dependencies.load(\n self.hooks.file,\n { useTLS: self.options.useTLS },\n function(error, callback) {\n if (self.hooks.isInitialized()) {\n self.changeState('initialized');\n callback(true);\n } else {\n if (error) {\n self.onError(error);\n }\n self.onClose();\n callback(false);\n }\n }\n );\n } else {\n self.onClose();\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport { default as Level } from './level';\n\nexport interface TimelineOptions {\n level?: Level;\n limit?: number;\n version?: string;\n cluster?: string;\n features?: string[];\n params?: any;\n}\n\nexport default class Timeline {\n key: string;\n session: number;\n events: any[];\n options: TimelineOptions;\n sent: number;\n uniqueID: number;\n\n constructor(key: string, session: number, options: TimelineOptions) {\n this.key = key;\n this.session = session;\n this.events = [];\n this.options = options || {};\n this.sent = 0;\n this.uniqueID = 0;\n }\n\n log(level, event) {\n if (level <= this.options.level) {\n this.events.push(\n Collections.extend({}, event, { timestamp: Util.now() })\n );\n if (this.options.limit && this.events.length > this.options.limit) {\n this.events.shift();\n }\n }\n }\n\n error(event) {\n this.log(Level.ERROR, event);\n }\n\n info(event) {\n this.log(Level.INFO, event);\n }\n\n debug(event) {\n this.log(Level.DEBUG, event);\n }\n\n isEmpty() {\n return this.events.length === 0;\n }\n\n send(sendfn, callback) {\n var data = Collections.extend(\n {\n session: this.session,\n bundle: this.sent + 1,\n key: this.key,\n lib: 'js',\n version: this.options.version,\n cluster: this.options.cluster,\n features: this.options.features,\n timeline: this.events\n },\n this.options.params\n );\n\n this.events = [];\n sendfn(data, (error, result) => {\n if (!error) {\n this.sent++;\n }\n if (callback) {\n callback(error, result);\n }\n });\n\n return true;\n }\n\n generateUniqueID(): number {\n this.uniqueID++;\n return this.uniqueID;\n }\n}\n","import Factory from '../utils/factory';\nimport Util from '../util';\nimport * as Errors from '../errors';\nimport * as Collections from '../utils/collections';\nimport Strategy from './strategy';\nimport Transport from '../transports/transport';\nimport StrategyOptions from './strategy_options';\nimport Handshake from '../connection/handshake';\n\n/** Provides a strategy interface for transports.\n *\n * @param {String} name\n * @param {Number} priority\n * @param {Class} transport\n * @param {Object} options\n */\nexport default class TransportStrategy implements Strategy {\n name: string;\n priority: number;\n transport: Transport;\n options: StrategyOptions;\n\n constructor(\n name: string,\n priority: number,\n transport: Transport,\n options: StrategyOptions\n ) {\n this.name = name;\n this.priority = priority;\n this.transport = transport;\n this.options = options || {};\n }\n\n /** Returns whether the transport is supported in the browser.\n *\n * @returns {Boolean}\n */\n isSupported(): boolean {\n return this.transport.isSupported({\n useTLS: this.options.useTLS\n });\n }\n\n /** Launches a connection attempt and returns a strategy runner.\n *\n * @param {Function} callback\n * @return {Object} strategy runner\n */\n connect(minPriority: number, callback: Function) {\n if (!this.isSupported()) {\n return failAttempt(new Errors.UnsupportedStrategy(), callback);\n } else if (this.priority < minPriority) {\n return failAttempt(new Errors.TransportPriorityTooLow(), callback);\n }\n\n var connected = false;\n var transport = this.transport.createConnection(\n this.name,\n this.priority,\n this.options.key,\n this.options\n );\n var handshake = null;\n\n var onInitialized = function() {\n transport.unbind('initialized', onInitialized);\n transport.connect();\n };\n var onOpen = function() {\n handshake = Factory.createHandshake(transport, function(result) {\n connected = true;\n unbindListeners();\n callback(null, result);\n });\n };\n var onError = function(error) {\n unbindListeners();\n callback(error);\n };\n var onClosed = function() {\n unbindListeners();\n var serializedTransport;\n\n // The reason for this try/catch block is that on React Native\n // the WebSocket object is circular. Therefore transport.socket will\n // throw errors upon stringification. Collections.safeJSONStringify\n // discards circular references when serializing.\n serializedTransport = Collections.safeJSONStringify(transport);\n callback(new Errors.TransportClosed(serializedTransport));\n };\n\n var unbindListeners = function() {\n transport.unbind('initialized', onInitialized);\n transport.unbind('open', onOpen);\n transport.unbind('error', onError);\n transport.unbind('closed', onClosed);\n };\n\n transport.bind('initialized', onInitialized);\n transport.bind('open', onOpen);\n transport.bind('error', onError);\n transport.bind('closed', onClosed);\n\n // connect will be called automatically after initialization\n transport.initialize();\n\n return {\n abort: () => {\n if (connected) {\n return;\n }\n unbindListeners();\n if (handshake) {\n handshake.close();\n } else {\n transport.close();\n }\n },\n forceMinPriority: p => {\n if (connected) {\n return;\n }\n if (this.priority < p) {\n if (handshake) {\n handshake.close();\n } else {\n transport.close();\n }\n }\n }\n };\n }\n}\n\nfunction failAttempt(error: Error, callback: Function) {\n Util.defer(function() {\n callback(error);\n });\n return {\n abort: function() {},\n forceMinPriority: function() {}\n };\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport TransportManager from '../transports/transport_manager';\nimport * as Errors from '../errors';\nimport Strategy from './strategy';\nimport TransportStrategy from './transport_strategy';\nimport StrategyOptions from '../strategies/strategy_options';\nimport { Config } from '../config';\nimport Runtime from 'runtime';\n\nconst { Transports } = Runtime;\n\nexport var defineTransport = function(\n config: Config,\n name: string,\n type: string,\n priority: number,\n options: StrategyOptions,\n manager?: TransportManager\n): Strategy {\n var transportClass = Transports[type];\n if (!transportClass) {\n throw new Errors.UnsupportedTransport(type);\n }\n\n var enabled =\n (!config.enabledTransports ||\n Collections.arrayIndexOf(config.enabledTransports, name) !== -1) &&\n (!config.disabledTransports ||\n Collections.arrayIndexOf(config.disabledTransports, name) === -1);\n\n var transport;\n if (enabled) {\n options = Object.assign(\n { ignoreNullOrigin: config.ignoreNullOrigin },\n options\n );\n\n transport = new TransportStrategy(\n name,\n priority,\n manager ? manager.getAssistant(transportClass) : transportClass,\n options\n );\n } else {\n transport = UnsupportedStrategy;\n }\n\n return transport;\n};\n\nvar UnsupportedStrategy: Strategy = {\n isSupported: function() {\n return false;\n },\n connect: function(_, callback) {\n var deferred = Util.defer(function() {\n callback(new Errors.UnsupportedStrategy());\n });\n return {\n abort: function() {\n deferred.ensureAborted();\n },\n forceMinPriority: function() {}\n };\n }\n};\n","import {\n UserAuthenticationCallback,\n InternalAuthOptions,\n UserAuthenticationHandler,\n UserAuthenticationRequestParams,\n AuthRequestType\n} from './options';\n\nimport Runtime from 'runtime';\n\nconst composeChannelQuery = (\n params: UserAuthenticationRequestParams,\n authOptions: InternalAuthOptions\n) => {\n var query = 'socket_id=' + encodeURIComponent(params.socketId);\n\n for (var key in authOptions.params) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(authOptions.params[key]);\n }\n\n if (authOptions.paramsProvider != null) {\n let dynamicParams = authOptions.paramsProvider();\n for (var key in dynamicParams) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(dynamicParams[key]);\n }\n }\n\n return query;\n};\n\nconst UserAuthenticator = (\n authOptions: InternalAuthOptions\n): UserAuthenticationHandler => {\n if (typeof Runtime.getAuthorizers()[authOptions.transport] === 'undefined') {\n throw `'${authOptions.transport}' is not a recognized auth transport`;\n }\n\n return (\n params: UserAuthenticationRequestParams,\n callback: UserAuthenticationCallback\n ) => {\n const query = composeChannelQuery(params, authOptions);\n\n Runtime.getAuthorizers()[authOptions.transport](\n Runtime,\n query,\n authOptions,\n AuthRequestType.UserAuthentication,\n callback\n );\n };\n};\n\nexport default UserAuthenticator;\n","import {\n AuthRequestType,\n InternalAuthOptions,\n ChannelAuthorizationHandler,\n ChannelAuthorizationRequestParams,\n ChannelAuthorizationCallback\n} from './options';\n\nimport Runtime from 'runtime';\n\nconst composeChannelQuery = (\n params: ChannelAuthorizationRequestParams,\n authOptions: InternalAuthOptions\n) => {\n var query = 'socket_id=' + encodeURIComponent(params.socketId);\n\n query += '&channel_name=' + encodeURIComponent(params.channelName);\n\n for (var key in authOptions.params) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(authOptions.params[key]);\n }\n\n if (authOptions.paramsProvider != null) {\n let dynamicParams = authOptions.paramsProvider();\n for (var key in dynamicParams) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(dynamicParams[key]);\n }\n }\n\n return query;\n};\n\nconst ChannelAuthorizer = (\n authOptions: InternalAuthOptions\n): ChannelAuthorizationHandler => {\n if (typeof Runtime.getAuthorizers()[authOptions.transport] === 'undefined') {\n throw `'${authOptions.transport}' is not a recognized auth transport`;\n }\n\n return (\n params: ChannelAuthorizationRequestParams,\n callback: ChannelAuthorizationCallback\n ) => {\n const query = composeChannelQuery(params, authOptions);\n\n Runtime.getAuthorizers()[authOptions.transport](\n Runtime,\n query,\n authOptions,\n AuthRequestType.ChannelAuthorization,\n callback\n );\n };\n};\n\nexport default ChannelAuthorizer;\n","import { Options } from './options';\nimport Defaults from './defaults';\nimport {\n ChannelAuthorizationHandler,\n UserAuthenticationHandler,\n ChannelAuthorizationOptions\n} from './auth/options';\nimport UserAuthenticator from './auth/user_authenticator';\nimport ChannelAuthorizer from './auth/channel_authorizer';\nimport { ChannelAuthorizerProxy } from './auth/deprecated_channel_authorizer';\nimport Runtime from 'runtime';\nimport * as nacl from 'tweetnacl';\n\nexport type AuthTransport = 'ajax' | 'jsonp';\nexport type Transport =\n | 'ws'\n | 'wss'\n | 'xhr_streaming'\n | 'xhr_polling'\n | 'sockjs';\n\nexport interface Config {\n // these are all 'required' config parameters, it's not necessary for the user\n // to set them, but they have configured defaults.\n activityTimeout: number;\n enableStats: boolean;\n httpHost: string;\n httpPath: string;\n httpPort: number;\n httpsPort: number;\n pongTimeout: number;\n statsHost: string;\n unavailableTimeout: number;\n useTLS: boolean;\n wsHost: string;\n wsPath: string;\n wsPort: number;\n wssPort: number;\n userAuthenticator: UserAuthenticationHandler;\n channelAuthorizer: ChannelAuthorizationHandler;\n\n // these are all optional parameters or overrrides. The customer can set these\n // but it's not strictly necessary\n forceTLS?: boolean;\n cluster?: string;\n disabledTransports?: Transport[];\n enabledTransports?: Transport[];\n ignoreNullOrigin?: boolean;\n nacl?: nacl;\n timelineParams?: any;\n}\n\n// getConfig mainly sets the defaults for the options that are not provided\nexport function getConfig(opts: Options, pusher): Config {\n let config: Config = {\n activityTimeout: opts.activityTimeout || Defaults.activityTimeout,\n cluster: opts.cluster,\n httpPath: opts.httpPath || Defaults.httpPath,\n httpPort: opts.httpPort || Defaults.httpPort,\n httpsPort: opts.httpsPort || Defaults.httpsPort,\n pongTimeout: opts.pongTimeout || Defaults.pongTimeout,\n statsHost: opts.statsHost || Defaults.stats_host,\n unavailableTimeout: opts.unavailableTimeout || Defaults.unavailableTimeout,\n wsPath: opts.wsPath || Defaults.wsPath,\n wsPort: opts.wsPort || Defaults.wsPort,\n wssPort: opts.wssPort || Defaults.wssPort,\n\n enableStats: getEnableStatsConfig(opts),\n httpHost: getHttpHost(opts),\n useTLS: shouldUseTLS(opts),\n wsHost: getWebsocketHost(opts),\n\n userAuthenticator: buildUserAuthenticator(opts),\n channelAuthorizer: buildChannelAuthorizer(opts, pusher)\n };\n\n if ('disabledTransports' in opts)\n config.disabledTransports = opts.disabledTransports;\n if ('enabledTransports' in opts)\n config.enabledTransports = opts.enabledTransports;\n if ('ignoreNullOrigin' in opts)\n config.ignoreNullOrigin = opts.ignoreNullOrigin;\n if ('timelineParams' in opts) config.timelineParams = opts.timelineParams;\n if ('nacl' in opts) {\n config.nacl = opts.nacl;\n }\n\n return config;\n}\n\nfunction getHttpHost(opts: Options): string {\n if (opts.httpHost) {\n return opts.httpHost;\n }\n if (opts.cluster) {\n return `sockjs-${opts.cluster}.pusher.com`;\n }\n return Defaults.httpHost;\n}\n\nfunction getWebsocketHost(opts: Options): string {\n if (opts.wsHost) {\n return opts.wsHost;\n }\n return getWebsocketHostFromCluster(opts.cluster);\n}\n\nfunction getWebsocketHostFromCluster(cluster: string): string {\n return `ws-${cluster}.pusher.com`;\n}\n\nfunction shouldUseTLS(opts: Options): boolean {\n if (Runtime.getProtocol() === 'https:') {\n return true;\n } else if (opts.forceTLS === false) {\n return false;\n }\n return true;\n}\n\n// if enableStats is set take the value\n// if disableStats is set take the inverse\n// otherwise default to false\nfunction getEnableStatsConfig(opts: Options): boolean {\n if ('enableStats' in opts) {\n return opts.enableStats;\n }\n if ('disableStats' in opts) {\n return !opts.disableStats;\n }\n return false;\n}\n\nfunction buildUserAuthenticator(opts: Options): UserAuthenticationHandler {\n const userAuthentication = {\n ...Defaults.userAuthentication,\n ...opts.userAuthentication\n };\n if (\n 'customHandler' in userAuthentication &&\n userAuthentication['customHandler'] != null\n ) {\n return userAuthentication['customHandler'];\n }\n\n return UserAuthenticator(userAuthentication);\n}\n\nfunction buildChannelAuth(opts: Options, pusher): ChannelAuthorizationOptions {\n let channelAuthorization: ChannelAuthorizationOptions;\n if ('channelAuthorization' in opts) {\n channelAuthorization = {\n ...Defaults.channelAuthorization,\n ...opts.channelAuthorization\n };\n } else {\n channelAuthorization = {\n transport: opts.authTransport || Defaults.authTransport,\n endpoint: opts.authEndpoint || Defaults.authEndpoint\n };\n if ('auth' in opts) {\n if ('params' in opts.auth) channelAuthorization.params = opts.auth.params;\n if ('headers' in opts.auth)\n channelAuthorization.headers = opts.auth.headers;\n }\n if ('authorizer' in opts)\n channelAuthorization.customHandler = ChannelAuthorizerProxy(\n pusher,\n channelAuthorization,\n opts.authorizer\n );\n }\n return channelAuthorization;\n}\n\nfunction buildChannelAuthorizer(\n opts: Options,\n pusher\n): ChannelAuthorizationHandler {\n const channelAuthorization = buildChannelAuth(opts, pusher);\n if (\n 'customHandler' in channelAuthorization &&\n channelAuthorization['customHandler'] != null\n ) {\n return channelAuthorization['customHandler'];\n }\n\n return ChannelAuthorizer(channelAuthorization);\n}\n","import Channel from '../channels/channel';\nimport {\n ChannelAuthorizationCallback,\n ChannelAuthorizationHandler,\n ChannelAuthorizationRequestParams,\n InternalAuthOptions\n} from './options';\n\nexport interface DeprecatedChannelAuthorizer {\n authorize(socketId: string, callback: ChannelAuthorizationCallback): void;\n}\n\nexport interface ChannelAuthorizerGenerator {\n (\n channel: Channel,\n options: DeprecatedAuthorizerOptions\n ): DeprecatedChannelAuthorizer;\n}\n\nexport interface DeprecatedAuthOptions {\n params?: any;\n headers?: any;\n}\n\nexport interface DeprecatedAuthorizerOptions {\n authTransport: 'ajax' | 'jsonp';\n authEndpoint: string;\n auth?: DeprecatedAuthOptions;\n}\n\nexport const ChannelAuthorizerProxy = (\n pusher,\n authOptions: InternalAuthOptions,\n channelAuthorizerGenerator: ChannelAuthorizerGenerator\n): ChannelAuthorizationHandler => {\n const deprecatedAuthorizerOptions: DeprecatedAuthorizerOptions = {\n authTransport: authOptions.transport,\n authEndpoint: authOptions.endpoint,\n auth: {\n params: authOptions.params,\n headers: authOptions.headers\n }\n };\n return (\n params: ChannelAuthorizationRequestParams,\n callback: ChannelAuthorizationCallback\n ) => {\n const channel = pusher.channel(params.channelName);\n // This line creates a new channel authorizer every time.\n // In the past, this was only done once per channel and reused.\n // We can do that again if we want to keep this behavior intact.\n const channelAuthorizer: DeprecatedChannelAuthorizer = channelAuthorizerGenerator(\n channel,\n deprecatedAuthorizerOptions\n );\n channelAuthorizer.authorize(params.socketId, callback);\n };\n};\n","import Logger from './logger';\nimport Pusher from './pusher';\nimport EventsDispatcher from './events/dispatcher';\n\nexport default class WatchlistFacade extends EventsDispatcher {\n private pusher: Pusher;\n\n public constructor(pusher: Pusher) {\n super(function(eventName, data) {\n Logger.debug(`No callbacks on watchlist events for ${eventName}`);\n });\n\n this.pusher = pusher;\n this.bindWatchlistInternalEvent();\n }\n\n handleEvent(pusherEvent) {\n pusherEvent.data.events.forEach(watchlistEvent => {\n this.emit(watchlistEvent.name, watchlistEvent);\n });\n }\n\n private bindWatchlistInternalEvent() {\n this.pusher.connection.bind('message', pusherEvent => {\n var eventName = pusherEvent.event;\n if (eventName === 'pusher_internal:watchlist_events') {\n this.handleEvent(pusherEvent);\n }\n });\n }\n}\n","function flatPromise() {\n let resolve, reject;\n const promise = new Promise((res, rej) => {\n resolve = res;\n reject = rej;\n });\n return { promise, resolve, reject };\n}\n\nexport default flatPromise;\n","import Pusher from './pusher';\nimport Logger from './logger';\nimport {\n UserAuthenticationData,\n UserAuthenticationCallback\n} from './auth/options';\nimport Channel from './channels/channel';\nimport WatchlistFacade from './watchlist';\nimport EventsDispatcher from './events/dispatcher';\nimport flatPromise from './utils/flat_promise';\n\nexport default class UserFacade extends EventsDispatcher {\n pusher: Pusher;\n signin_requested: boolean = false;\n user_data: any = null;\n serverToUserChannel: Channel = null;\n signinDonePromise: Promise = null;\n watchlist: WatchlistFacade;\n private _signinDoneResolve: Function = null;\n\n public constructor(pusher: Pusher) {\n super(function(eventName, data) {\n Logger.debug('No callbacks on user for ' + eventName);\n });\n this.pusher = pusher;\n this.pusher.connection.bind('state_change', ({ previous, current }) => {\n if (previous !== 'connected' && current === 'connected') {\n this._signin();\n }\n if (previous === 'connected' && current !== 'connected') {\n this._cleanup();\n this._newSigninPromiseIfNeeded();\n }\n });\n\n this.watchlist = new WatchlistFacade(pusher);\n\n this.pusher.connection.bind('message', event => {\n var eventName = event.event;\n if (eventName === 'pusher:signin_success') {\n this._onSigninSuccess(event.data);\n }\n if (\n this.serverToUserChannel &&\n this.serverToUserChannel.name === event.channel\n ) {\n this.serverToUserChannel.handleEvent(event);\n }\n });\n }\n\n public signin() {\n if (this.signin_requested) {\n return;\n }\n\n this.signin_requested = true;\n this._signin();\n }\n\n private _signin() {\n if (!this.signin_requested) {\n return;\n }\n\n this._newSigninPromiseIfNeeded();\n\n if (this.pusher.connection.state !== 'connected') {\n // Signin will be attempted when the connection is connected\n return;\n }\n\n this.pusher.config.userAuthenticator(\n {\n socketId: this.pusher.connection.socket_id\n },\n this._onAuthorize\n );\n }\n\n private _onAuthorize: UserAuthenticationCallback = (\n err,\n authData: UserAuthenticationData\n ) => {\n if (err) {\n Logger.warn(`Error during signin: ${err}`);\n this._cleanup();\n return;\n }\n\n this.pusher.send_event('pusher:signin', {\n auth: authData.auth,\n user_data: authData.user_data\n });\n\n // Later when we get pusher:singin_success event, the user will be marked as signed in\n };\n\n private _onSigninSuccess(data: any) {\n try {\n this.user_data = JSON.parse(data.user_data);\n } catch (e) {\n Logger.error(`Failed parsing user data after signin: ${data.user_data}`);\n this._cleanup();\n return;\n }\n\n if (typeof this.user_data.id !== 'string' || this.user_data.id === '') {\n Logger.error(\n `user_data doesn't contain an id. user_data: ${this.user_data}`\n );\n this._cleanup();\n return;\n }\n\n // Signin succeeded\n this._signinDoneResolve();\n this._subscribeChannels();\n }\n\n private _subscribeChannels() {\n const ensure_subscribed = channel => {\n if (channel.subscriptionPending && channel.subscriptionCancelled) {\n channel.reinstateSubscription();\n } else if (\n !channel.subscriptionPending &&\n this.pusher.connection.state === 'connected'\n ) {\n channel.subscribe();\n }\n };\n\n this.serverToUserChannel = new Channel(\n `#server-to-user-${this.user_data.id}`,\n this.pusher\n );\n this.serverToUserChannel.bind_global((eventName, data) => {\n if (\n eventName.indexOf('pusher_internal:') === 0 ||\n eventName.indexOf('pusher:') === 0\n ) {\n // ignore internal events\n return;\n }\n this.emit(eventName, data);\n });\n ensure_subscribed(this.serverToUserChannel);\n }\n\n private _cleanup() {\n this.user_data = null;\n if (this.serverToUserChannel) {\n this.serverToUserChannel.unbind_all();\n this.serverToUserChannel.disconnect();\n this.serverToUserChannel = null;\n }\n\n if (this.signin_requested) {\n // If signin is in progress and cleanup is called,\n // Mark the current signin process as done.\n this._signinDoneResolve();\n }\n }\n\n private _newSigninPromiseIfNeeded() {\n if (!this.signin_requested) {\n return;\n }\n\n // If there is a promise and it is not resolved, return without creating a new one.\n if (this.signinDonePromise && !(this.signinDonePromise as any).done) {\n return;\n }\n\n // This promise is never rejected.\n // It gets resolved when the signin process is done whether it failed or succeeded\n const { promise, resolve, reject: _ } = flatPromise();\n (promise as any).done = false;\n const setDone = () => {\n (promise as any).done = true;\n };\n promise.then(setDone).catch(setDone);\n this.signinDonePromise = promise;\n this._signinDoneResolve = resolve;\n }\n}\n","import AbstractRuntime from '../runtimes/interface';\nimport Runtime from 'runtime';\nimport * as Collections from './utils/collections';\nimport Channels from './channels/channels';\nimport Channel from './channels/channel';\nimport { default as EventsDispatcher } from './events/dispatcher';\nimport Timeline from './timeline/timeline';\nimport TimelineSender from './timeline/timeline_sender';\nimport TimelineLevel from './timeline/level';\nimport { defineTransport } from './strategies/strategy_builder';\nimport ConnectionManager from './connection/connection_manager';\nimport { PeriodicTimer } from './utils/timers';\nimport Defaults from './defaults';\nimport Logger from './logger';\nimport Factory from './utils/factory';\nimport { Options, ClusterOptions, validateOptions } from './options';\nimport { Config, getConfig } from './config';\nimport StrategyOptions from './strategies/strategy_options';\nimport UserFacade from './user';\n\nexport default class Pusher {\n /* STATIC PROPERTIES */\n static instances: Pusher[] = [];\n static isReady: boolean = false;\n static logToConsole: boolean = false;\n\n // for jsonp\n static Runtime: AbstractRuntime = Runtime;\n static ScriptReceivers: any = (Runtime).ScriptReceivers;\n static DependenciesReceivers: any = (Runtime).DependenciesReceivers;\n static auth_callbacks: any = (Runtime).auth_callbacks;\n\n static ready() {\n Pusher.isReady = true;\n for (var i = 0, l = Pusher.instances.length; i < l; i++) {\n Pusher.instances[i].connect();\n }\n }\n\n static log: (message: any) => void;\n\n private static getClientFeatures(): string[] {\n return Collections.keys(\n Collections.filterObject({ ws: Runtime.Transports.ws }, function(t) {\n return t.isSupported({});\n })\n );\n }\n\n /* INSTANCE PROPERTIES */\n key: string;\n options: Options;\n config: Config;\n channels: Channels;\n global_emitter: EventsDispatcher;\n sessionID: number;\n timeline: Timeline;\n timelineSender: TimelineSender;\n connection: ConnectionManager;\n timelineSenderTimer: PeriodicTimer;\n user: UserFacade;\n constructor(app_key: string, options: Options) {\n checkAppKey(app_key);\n validateOptions(options);\n this.key = app_key;\n this.config = getConfig(options, this);\n\n this.channels = Factory.createChannels();\n this.global_emitter = new EventsDispatcher();\n this.sessionID = Runtime.randomInt(1000000000);\n\n this.timeline = new Timeline(this.key, this.sessionID, {\n cluster: this.config.cluster,\n features: Pusher.getClientFeatures(),\n params: this.config.timelineParams || {},\n limit: 50,\n level: TimelineLevel.INFO,\n version: Defaults.VERSION\n });\n if (this.config.enableStats) {\n this.timelineSender = Factory.createTimelineSender(this.timeline, {\n host: this.config.statsHost,\n path: '/timeline/v2/' + Runtime.TimelineTransport.name\n });\n }\n\n var getStrategy = (options: StrategyOptions) => {\n return Runtime.getDefaultStrategy(this.config, options, defineTransport);\n };\n\n this.connection = Factory.createConnectionManager(this.key, {\n getStrategy: getStrategy,\n timeline: this.timeline,\n activityTimeout: this.config.activityTimeout,\n pongTimeout: this.config.pongTimeout,\n unavailableTimeout: this.config.unavailableTimeout,\n useTLS: Boolean(this.config.useTLS)\n });\n\n this.connection.bind('connected', () => {\n this.subscribeAll();\n if (this.timelineSender) {\n this.timelineSender.send(this.connection.isUsingTLS());\n }\n });\n\n this.connection.bind('message', event => {\n var eventName = event.event;\n var internal = eventName.indexOf('pusher_internal:') === 0;\n if (event.channel) {\n var channel = this.channel(event.channel);\n if (channel) {\n channel.handleEvent(event);\n }\n }\n // Emit globally [deprecated]\n if (!internal) {\n this.global_emitter.emit(event.event, event.data);\n }\n });\n this.connection.bind('connecting', () => {\n this.channels.disconnect();\n });\n this.connection.bind('disconnected', () => {\n this.channels.disconnect();\n });\n this.connection.bind('error', err => {\n Logger.warn(err);\n });\n\n Pusher.instances.push(this);\n this.timeline.info({ instances: Pusher.instances.length });\n\n this.user = new UserFacade(this);\n\n if (Pusher.isReady) {\n this.connect();\n }\n }\n\n /**\n * Allows you to switch Pusher cluster without\n * losing all the channels/subscription binding\n * as this is internally managed by the SDK.\n */\n switchCluster(options: ClusterOptions) {\n const { appKey, cluster } = options;\n this.key = appKey;\n this.options = { ...this.options, cluster };\n this.config = getConfig(this.options, this);\n this.connection.switchCluster(this.key);\n }\n\n channel(name: string): Channel {\n return this.channels.find(name);\n }\n\n allChannels(): Channel[] {\n return this.channels.all();\n }\n\n connect() {\n this.connection.connect();\n\n if (this.timelineSender) {\n if (!this.timelineSenderTimer) {\n var usingTLS = this.connection.isUsingTLS();\n var timelineSender = this.timelineSender;\n this.timelineSenderTimer = new PeriodicTimer(60000, function() {\n timelineSender.send(usingTLS);\n });\n }\n }\n }\n\n disconnect() {\n this.connection.disconnect();\n\n if (this.timelineSenderTimer) {\n this.timelineSenderTimer.ensureAborted();\n this.timelineSenderTimer = null;\n }\n }\n\n bind(event_name: string, callback: Function, context?: any): Pusher {\n this.global_emitter.bind(event_name, callback, context);\n return this;\n }\n\n unbind(event_name?: string, callback?: Function, context?: any): Pusher {\n this.global_emitter.unbind(event_name, callback, context);\n return this;\n }\n\n bind_global(callback: Function): Pusher {\n this.global_emitter.bind_global(callback);\n return this;\n }\n\n unbind_global(callback?: Function): Pusher {\n this.global_emitter.unbind_global(callback);\n return this;\n }\n\n unbind_all(callback?: Function): Pusher {\n this.global_emitter.unbind_all();\n return this;\n }\n\n subscribeAll() {\n var channelName;\n for (channelName in this.channels.channels) {\n if (this.channels.channels.hasOwnProperty(channelName)) {\n this.subscribe(channelName);\n }\n }\n }\n\n subscribe(channel_name: string) {\n var channel = this.channels.add(channel_name, this);\n if (channel.subscriptionPending && channel.subscriptionCancelled) {\n channel.reinstateSubscription();\n } else if (\n !channel.subscriptionPending &&\n this.connection.state === 'connected'\n ) {\n channel.subscribe();\n }\n return channel;\n }\n\n unsubscribe(channel_name: string) {\n var channel = this.channels.find(channel_name);\n if (channel && channel.subscriptionPending) {\n channel.cancelSubscription();\n } else {\n channel = this.channels.remove(channel_name);\n if (channel && channel.subscribed) {\n channel.unsubscribe();\n }\n }\n }\n\n send_event(event_name: string, data: any, channel?: string) {\n return this.connection.send_event(event_name, data, channel);\n }\n\n shouldUseTLS(): boolean {\n return this.config.useTLS;\n }\n\n signin() {\n this.user.signin();\n }\n}\n\nfunction checkAppKey(key) {\n if (key === null || key === undefined) {\n throw 'You must pass your app key when you instantiate Pusher.';\n }\n}\n\nRuntime.setup(Pusher);\n","import ConnectionManager from './connection/connection_manager';\nimport {\n ChannelAuthorizationOptions,\n UserAuthenticationOptions\n} from './auth/options';\nimport {\n ChannelAuthorizerGenerator,\n DeprecatedAuthOptions\n} from './auth/deprecated_channel_authorizer';\nimport { AuthTransport, Transport } from './config';\nimport * as nacl from 'tweetnacl';\nimport Logger from './logger';\n\nexport interface Options {\n activityTimeout?: number;\n\n auth?: DeprecatedAuthOptions; // DEPRECATED use channelAuthorization instead\n authEndpoint?: string; // DEPRECATED use channelAuthorization instead\n authTransport?: AuthTransport; // DEPRECATED use channelAuthorization instead\n authorizer?: ChannelAuthorizerGenerator; // DEPRECATED use channelAuthorization instead\n\n channelAuthorization?: ChannelAuthorizationOptions;\n userAuthentication?: UserAuthenticationOptions;\n\n cluster: string;\n enableStats?: boolean;\n disableStats?: boolean;\n disabledTransports?: Transport[];\n enabledTransports?: Transport[];\n forceTLS?: boolean;\n httpHost?: string;\n httpPath?: string;\n httpPort?: number;\n httpsPort?: number;\n ignoreNullOrigin?: boolean;\n nacl?: nacl;\n pongTimeout?: number;\n statsHost?: string;\n timelineParams?: any;\n unavailableTimeout?: number;\n wsHost?: string;\n wsPath?: string;\n wsPort?: number;\n wssPort?: number;\n}\n\nexport interface ClusterOptions {\n appKey: string;\n cluster: string;\n}\n\nexport function validateOptions(options) {\n if (options == null) {\n throw 'You must pass an options object';\n }\n if (options.cluster == null) {\n throw 'Options object must provide a cluster';\n }\n if ('disableStats' in options) {\n Logger.warn(\n 'The disableStats option is deprecated in favor of enableStats'\n );\n }\n}\n"],"sourceRoot":""} \ No newline at end of file +{"version":3,"sources":["webpack://Pusher/webpack/universalModuleDefinition","webpack://Pusher/webpack/bootstrap","webpack://Pusher/./node_modules/@stablelib/base64/base64.ts","webpack://Pusher/./node_modules/@stablelib/utf8/utf8.ts","webpack://Pusher/./src/core/pusher.js","webpack://Pusher/./src/runtimes/web/dom/script_receiver_factory.ts","webpack://Pusher/./src/core/defaults.ts","webpack://Pusher/./src/runtimes/web/dom/dependencies.ts","webpack://Pusher/./src/runtimes/web/dom/dependency_loader.ts","webpack://Pusher/./src/core/utils/url_store.ts","webpack://Pusher/./src/core/auth/options.ts","webpack://Pusher/./src/core/errors.ts","webpack://Pusher/./src/runtimes/isomorphic/auth/xhr_auth.ts","webpack://Pusher/./src/core/base64.ts","webpack://Pusher/./src/core/utils/timers/abstract_timer.ts","webpack://Pusher/./src/core/utils/timers/index.ts","webpack://Pusher/./src/core/util.ts","webpack://Pusher/./src/core/utils/collections.ts","webpack://Pusher/./src/core/logger.ts","webpack://Pusher/./src/runtimes/web/auth/jsonp_auth.ts","webpack://Pusher/./src/runtimes/web/dom/script_request.ts","webpack://Pusher/./src/runtimes/web/dom/jsonp_request.ts","webpack://Pusher/./src/runtimes/web/timeline/jsonp_timeline.ts","webpack://Pusher/./src/core/transports/url_schemes.ts","webpack://Pusher/./src/core/events/callback_registry.ts","webpack://Pusher/./src/core/events/dispatcher.ts","webpack://Pusher/./src/core/transports/transport_connection.ts","webpack://Pusher/./src/core/transports/transport.ts","webpack://Pusher/./src/runtimes/isomorphic/transports/transports.ts","webpack://Pusher/./src/runtimes/web/transports/transports.ts","webpack://Pusher/./src/runtimes/web/net_info.ts","webpack://Pusher/./src/core/transports/assistant_to_the_transport_manager.ts","webpack://Pusher/./src/core/connection/protocol/protocol.ts","webpack://Pusher/./src/core/connection/connection.ts","webpack://Pusher/./src/core/connection/handshake/index.ts","webpack://Pusher/./src/core/timeline/timeline_sender.ts","webpack://Pusher/./src/core/channels/channel.ts","webpack://Pusher/./src/core/channels/private_channel.ts","webpack://Pusher/./src/core/channels/members.ts","webpack://Pusher/./src/core/channels/presence_channel.ts","webpack://Pusher/./src/core/channels/encrypted_channel.ts","webpack://Pusher/./src/core/connection/connection_manager.ts","webpack://Pusher/./src/core/channels/channels.ts","webpack://Pusher/./src/core/utils/factory.ts","webpack://Pusher/./src/core/transports/transport_manager.ts","webpack://Pusher/./src/core/strategies/sequential_strategy.ts","webpack://Pusher/./src/core/strategies/best_connected_ever_strategy.ts","webpack://Pusher/./src/core/strategies/websocket_prioritized_cached_strategy.ts","webpack://Pusher/./src/core/strategies/delayed_strategy.ts","webpack://Pusher/./src/core/strategies/if_strategy.ts","webpack://Pusher/./src/core/strategies/first_connected_strategy.ts","webpack://Pusher/./src/runtimes/web/default_strategy.ts","webpack://Pusher/./src/runtimes/web/http/http_xdomain_request.ts","webpack://Pusher/./src/core/http/http_request.ts","webpack://Pusher/./src/core/http/state.ts","webpack://Pusher/./src/core/http/http_socket.ts","webpack://Pusher/./src/core/timeline/level.ts","webpack://Pusher/./src/core/http/http_streaming_socket.ts","webpack://Pusher/./src/core/http/http_polling_socket.ts","webpack://Pusher/./src/runtimes/isomorphic/http/http_xhr_request.ts","webpack://Pusher/./src/runtimes/isomorphic/http/http.ts","webpack://Pusher/./src/runtimes/web/http/http.ts","webpack://Pusher/./src/runtimes/web/runtime.ts","webpack://Pusher/./src/runtimes/web/transports/transport_connection_initializer.ts","webpack://Pusher/./src/core/timeline/timeline.ts","webpack://Pusher/./src/core/strategies/transport_strategy.ts","webpack://Pusher/./src/core/strategies/strategy_builder.ts","webpack://Pusher/./src/core/auth/user_authenticator.ts","webpack://Pusher/./src/core/auth/channel_authorizer.ts","webpack://Pusher/./src/core/config.ts","webpack://Pusher/./src/core/auth/deprecated_channel_authorizer.ts","webpack://Pusher/./src/core/watchlist.ts","webpack://Pusher/./src/core/utils/flat_promise.ts","webpack://Pusher/./src/core/user.ts","webpack://Pusher/./src/core/pusher.ts","webpack://Pusher/./src/core/options.ts"],"names":["root","factory","exports","module","define","amd","window","installedModules","__webpack_require__","moduleId","i","l","modules","call","m","c","d","name","getter","o","Object","defineProperty","enumerable","get","r","Symbol","toStringTag","value","t","mode","__esModule","ns","create","key","bind","n","object","property","prototype","hasOwnProperty","p","s","_paddingCharacter","encodedLength","length","this","encode","data","out","_encodeByte","left","maxDecodedLength","decodedLength","_getPaddingLength","decode","Uint8Array","paddingLength","op","haveBad","v0","v1","v2","v3","_decodeChar","charCodeAt","Error","b","result","String","fromCharCode","Coder","stdCoder","URLSafeCoder","urlSafeCoder","INVALID_UTF8","arr","pos","chars","min","n1","n2","n3","push","join","default","ScriptReceiverFactory","prefix","lastId","callback","number","id","called","callbackWrapper","apply","arguments","receiver","ScriptReceivers","VERSION","PROTOCOL","wsPort","wssPort","wsPath","httpHost","httpPort","httpsPort","httpPath","stats_host","authEndpoint","authTransport","activityTimeout","pongTimeout","unavailableTimeout","userAuthentication","endpoint","transport","channelAuthorization","cdn_http","cdn_https","dependency_suffix","DependenciesReceivers","Dependencies","options","receivers","loading","self","request","createScriptRequest","getPath","error","remove","callbacks","successCallback","wasSuccessful","cleanup","send","protocol","getDocument","location","useTLS","replace","version","getRoot","suffix","urlStore","baseUrl","urls","authenticationEndpoint","path","authorizationEndpoint","javascriptQuickStart","triggeringClientEvents","encryptedChannelSupport","fullUrl","AuthRequestType","urlObj","url","BadEventName","msg","super","setPrototypeOf","BadChannelName","RequestTimedOut","TransportPriorityTooLow","TransportClosed","UnsupportedFeature","UnsupportedTransport","UnsupportedStrategy","HTTPAuthError","status","context","query","authOptions","authRequestType","xhr","createXHR","headerName","open","setRequestHeader","headers","headersProvider","dynamicHeaders","onreadystatechange","readyState","parsed","JSON","parse","responseText","e","toString","UserAuthentication","ChannelAuthorization","b64chars","b64tab","charAt","cb_utob","cc","utob","u","cb_encode","ccc","padlen","ord","btoa","set","clear","delay","timer","clearTimeout","clearInterval","setTimeout","setInterval","now","Date","valueOf","defer","args","boundArguments","Array","slice","concat","extend","target","sources","extensions","constructor","stringify","safeJSONStringify","arrayIndexOf","array","item","nativeIndexOf","indexOf","objectApply","f","keys","_","map","filter","test","filterObject","Boolean","any","encodeParamsObject","encodeURIComponent","buildQueryString","params","undefined","method","source","objects","paths","derez","nu","$ref","globalLog","message","console","log","globalLogWarn","globalLogError","warn","defaultLoggingFunction","logToConsole","callbackName","nextAuthCallbackID","document","script","createElement","auth_callbacks","callback_name","src","head","getElementsByTagName","documentElement","insertBefore","firstChild","ScriptRequest","errorString","type","charset","addEventListener","onerror","onload","async","attachEvent","navigator","userAgent","errorScript","text","nextSibling","parentNode","removeChild","getAgent","sender","host","createJSONPRequest","getGenericURL","baseScheme","hostTLS","hostNonTLS","getGenericPath","queryString","ws","getInitial","http","sockjs","_callbacks","prefixedEventName","fn","names","removeCallback","removeAllCallbacks","binding","failThrough","global_callbacks","eventName","add","unbind","unbind_global","metadata","hooks","priority","initialize","transportConnectionInitializer","state","timeline","generateUniqueID","handlesActivityChecks","supportsPing","socket","getSocket","onError","changeState","bindListeners","debug","close","ping","beforeOpen","onopen","emit","buildTimelineMessage","closeEvent","code","reason","wasClean","unbindListeners","onOpen","onclose","onClose","onmessage","onMessage","onactivity","onActivity","info","cid","environment","isSupported","WSTransport","isInitialized","getWebSocketAPI","createWebSocket","httpConfiguration","streamingConfiguration","HTTPFactory","createStreamingSocket","pollingConfiguration","createPollingSocket","xhrConfiguration","isXHRSupported","xhr_streaming","xhr_polling","SockJSTransport","file","SockJS","js_path","ignore_null_origin","ignoreNullOrigin","xdrConfiguration","isXDRSupported","XDRStreamingTransport","XDRPollingTransport","xdr_streaming","xdr_polling","onLine","manager","minPingDelay","maxPingDelay","pingDelay","connection","createConnection","openTimestamp","onClosed","reportDeath","lifespan","Math","max","isAlive","Protocol","decodeMessage","messageEvent","messageData","pusherEventData","pusherEvent","event","channel","user_id","encodeMessage","processHandshake","activity_timeout","action","socket_id","getCloseAction","getCloseError","send_event","listeners","activity","closed","handleCloseEvent","listener","finish","isEmpty","TimelineTransport","pusher","subscribed","subscriptionPending","subscriptionCancelled","socketId","auth","handleSubscriptionSucceededEvent","handleSubscriptionCountEvent","unsubscribe","subscription_count","subscriptionCount","authorize","assign","channel_data","config","channelAuthorizer","channelName","reset","members","member","myID","subscriptionData","presence","hash","count","me","memberData","user_info","authData","channelData","setMyID","user","signinDonePromise","user_data","handleInternalEvent","addedMember","addMember","removedMember","removeMember","onSubscription","disconnect","nacl","sharedSecret","handleEncryptedEvent","handleEvent","ciphertext","nonce","cipherText","secretbox","overheadLength","nonceLength","bytes","getDataToEmit","raw","usingTLS","errorCallbacks","buildErrorCallbacks","connectionCallbacks","buildConnectionCallbacks","handshakeCallbacks","buildHandshakeCallbacks","Network","getNetwork","netinfo","retryIn","sendActivityCheck","updateStrategy","runner","strategy","updateState","startConnecting","setUnavailableTimer","disconnectInternally","handshake","connect","handshakeError","abortConnecting","abort","clearRetryTimer","clearUnavailableTimer","abandonConnection","getStrategy","round","retryTimer","ensureAborted","unavailableTimer","stopActivityCheck","activityTimer","pong_timed_out","resetActivityCheck","shouldRetry","connected","Infinity","setConnection","withErrorEmitted","tls_only","refused","backoff","retry","newState","previousState","newStateDescription","previous","current","channels","createEncryptedChannel","errMsg","createPrivateChannel","createPresenceChannel","createChannel","values","createChannels","createConnectionManager","createTimelineSender","createHandshake","createAssistantToTheTransportManager","livesLeft","lives","strategies","loop","failFast","timeout","timeoutLimit","minPriority","tryNextStrategy","tryStrategy","forceMinPriority","isRunning","callbackBuilder","runners","rs","abortRunner","allRunnersFailed","aborted","transports","ttl","storage","getLocalStorage","serializedCache","getTransportCacheKey","flushTransportCache","fetchTransportCache","cacheSkipCount","timestamp","includes","cached","latency","startTimestamp","pop","cb","storeTransportCache","IfStrategy","trueBranch","falseBranch","FirstConnectedStrategy","testSupportsStrategy","baseOptions","defineTransport","definedTransports","defineTransportStrategy","wsStrategy","ws_options","wsHost","wss_options","sockjs_options","timeouts","ws_manager","streaming_manager","ws_transport","wss_transport","sockjs_transport","xhr_streaming_transport","xdr_streaming_transport","xhr_polling_transport","xdr_polling_transport","ws_loop","wss_loop","sockjs_loop","streaming_loop","polling_loop","http_loop","http_fallback_loop","getRequest","xdr","XDomainRequest","ontimeout","onprogress","onChunk","abortRequest","payload","position","unloader","addUnloadListener","removeUnloadListener","chunk","advanceBuffer","isBufferTooLong","buffer","unreadData","endOfLinePosition","State","autoIncrement","getUniqueURL","separator","randomNumber","randomInt","TimelineLevel","session","randomString","parts","exec","base","getLocation","CONNECTING","openStream","sendRaw","sendHeartbeat","OPEN","createSocketRequest","start","closeStream","CLOSED","onEvent","onHeartbeat","hostname","urlParts","stream","getReceiveURL","onFinished","reconnect","unbind_all","getXHRAPI","createSocket","createRequest","getDefaultStrategy","Transports","load","XMLHttpRequest","WebSocket","MozWebSocket","PusherClass","Pusher","initializeOnDocumentBody","onDocumentBody","ready","getAuthorizers","ajax","jsonp","body","localStorage","createXMLHttpRequest","createMicrosoftXHR","ActiveXObject","createXDR","Constructor","withCredentials","documentProtocol","getProtocol","removeEventListener","detachEvent","floor","crypto","getRandomValues","Uint32Array","events","sent","uniqueID","level","limit","shift","ERROR","INFO","DEBUG","sendfn","bundle","lib","cluster","features","failAttempt","onInitialized","serializedTransport","transportClass","enabledTransports","disabledTransports","getAssistant","deferred","paramsProvider","dynamicParams","composeChannelQuery","getConfig","opts","statsHost","enableStats","getEnableStatsConfig","getHttpHost","shouldUseTLS","getWebsocketHost","userAuthenticator","buildUserAuthenticator","buildChannelAuthorizer","timelineParams","forceTLS","disableStats","customHandler","channelAuthorizerGenerator","deprecatedAuthorizerOptions","ChannelAuthorizerProxy","authorizer","buildChannelAuth","bindWatchlistInternalEvent","forEach","watchlistEvent","resolve","reject","promise","Promise","res","rej","signin_requested","serverToUserChannel","_signinDoneResolve","_onAuthorize","err","_cleanup","_signin","_newSigninPromiseIfNeeded","watchlist","_onSigninSuccess","_subscribeChannels","bind_global","reinstateSubscription","subscribe","ensure_subscribed","done","setDone","then","catch","isReady","instances","app_key","checkAppKey","validateOptions","global_emitter","sessionID","getClientFeatures","timelineSender","subscribeAll","isUsingTLS","internal","appKey","switchCluster","find","all","timelineSenderTimer","event_name","channel_name","cancelSubscription","signin","Runtime","setup"],"mappings":";;;;;;;CAAA,SAA2CA,EAAMC,GAC1B,iBAAZC,SAA0C,iBAAXC,OACxCA,OAAOD,QAAUD,IACQ,mBAAXG,QAAyBA,OAAOC,IAC9CD,OAAO,GAAIH,GACe,iBAAZC,QACdA,QAAgB,OAAID,IAEpBD,EAAa,OAAIC,IARnB,CASGK,QAAQ,WACX,O,YCTE,IAAIC,EAAmB,GAGvB,SAASC,EAAoBC,GAG5B,GAAGF,EAAiBE,GACnB,OAAOF,EAAiBE,GAAUP,QAGnC,IAAIC,EAASI,EAAiBE,GAAY,CACzCC,EAAG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her.min.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"Pusher\"] = factory();\n\telse\n\t\troot[\"Pusher\"] = factory();\n})(window, function() {\nreturn "," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 2);\n","// Copyright (C) 2016 Dmitry Chestnykh\n// MIT License. See LICENSE file for details.\n\n/**\n * Package base64 implements Base64 encoding and decoding.\n */\n\n// Invalid character used in decoding to indicate\n// that the character to decode is out of range of\n// alphabet and cannot be decoded.\nconst INVALID_BYTE = 256;\n\n/**\n * Implements standard Base64 encoding.\n *\n * Operates in constant time.\n */\nexport class Coder {\n // TODO(dchest): methods to encode chunk-by-chunk.\n\n constructor(private _paddingCharacter = \"=\") { }\n\n encodedLength(length: number): number {\n if (!this._paddingCharacter) {\n return (length * 8 + 5) / 6 | 0;\n }\n return (length + 2) / 3 * 4 | 0;\n }\n\n encode(data: Uint8Array): string {\n let out = \"\";\n\n let i = 0;\n for (; i < data.length - 2; i += 3) {\n let c = (data[i] << 16) | (data[i + 1] << 8) | (data[i + 2]);\n out += this._encodeByte((c >>> 3 * 6) & 63);\n out += this._encodeByte((c >>> 2 * 6) & 63);\n out += this._encodeByte((c >>> 1 * 6) & 63);\n out += this._encodeByte((c >>> 0 * 6) & 63);\n }\n\n const left = data.length - i;\n if (left > 0) {\n let c = (data[i] << 16) | (left === 2 ? data[i + 1] << 8 : 0);\n out += this._encodeByte((c >>> 3 * 6) & 63);\n out += this._encodeByte((c >>> 2 * 6) & 63);\n if (left === 2) {\n out += this._encodeByte((c >>> 1 * 6) & 63);\n } else {\n out += this._paddingCharacter || \"\";\n }\n out += this._paddingCharacter || \"\";\n }\n\n return out;\n }\n\n maxDecodedLength(length: number): number {\n if (!this._paddingCharacter) {\n return (length * 6 + 7) / 8 | 0;\n }\n return length / 4 * 3 | 0;\n }\n\n decodedLength(s: string): number {\n return this.maxDecodedLength(s.length - this._getPaddingLength(s));\n }\n\n decode(s: string): Uint8Array {\n if (s.length === 0) {\n return new Uint8Array(0);\n }\n const paddingLength = this._getPaddingLength(s);\n const length = s.length - paddingLength;\n const out = new Uint8Array(this.maxDecodedLength(length));\n let op = 0;\n let i = 0;\n let haveBad = 0;\n let v0 = 0, v1 = 0, v2 = 0, v3 = 0;\n for (; i < length - 4; i += 4) {\n v0 = this._decodeChar(s.charCodeAt(i + 0));\n v1 = this._decodeChar(s.charCodeAt(i + 1));\n v2 = this._decodeChar(s.charCodeAt(i + 2));\n v3 = this._decodeChar(s.charCodeAt(i + 3));\n out[op++] = (v0 << 2) | (v1 >>> 4);\n out[op++] = (v1 << 4) | (v2 >>> 2);\n out[op++] = (v2 << 6) | v3;\n haveBad |= v0 & INVALID_BYTE;\n haveBad |= v1 & INVALID_BYTE;\n haveBad |= v2 & INVALID_BYTE;\n haveBad |= v3 & INVALID_BYTE;\n }\n if (i < length - 1) {\n v0 = this._decodeChar(s.charCodeAt(i));\n v1 = this._decodeChar(s.charCodeAt(i + 1));\n out[op++] = (v0 << 2) | (v1 >>> 4);\n haveBad |= v0 & INVALID_BYTE;\n haveBad |= v1 & INVALID_BYTE;\n }\n if (i < length - 2) {\n v2 = this._decodeChar(s.charCodeAt(i + 2));\n out[op++] = (v1 << 4) | (v2 >>> 2);\n haveBad |= v2 & INVALID_BYTE;\n }\n if (i < length - 3) {\n v3 = this._decodeChar(s.charCodeAt(i + 3));\n out[op++] = (v2 << 6) | v3;\n haveBad |= v3 & INVALID_BYTE;\n }\n if (haveBad !== 0) {\n throw new Error(\"Base64Coder: incorrect characters for decoding\");\n }\n return out;\n }\n\n // Standard encoding have the following encoded/decoded ranges,\n // which we need to convert between.\n //\n // ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 0123456789 + /\n // Index: 0 - 25 26 - 51 52 - 61 62 63\n // ASCII: 65 - 90 97 - 122 48 - 57 43 47\n //\n\n // Encode 6 bits in b into a new character.\n protected _encodeByte(b: number): string {\n // Encoding uses constant time operations as follows:\n //\n // 1. Define comparison of A with B using (A - B) >>> 8:\n // if A > B, then result is positive integer\n // if A <= B, then result is 0\n //\n // 2. Define selection of C or 0 using bitwise AND: X & C:\n // if X == 0, then result is 0\n // if X != 0, then result is C\n //\n // 3. Start with the smallest comparison (b >= 0), which is always\n // true, so set the result to the starting ASCII value (65).\n //\n // 4. Continue comparing b to higher ASCII values, and selecting\n // zero if comparison isn't true, otherwise selecting a value\n // to add to result, which:\n //\n // a) undoes the previous addition\n // b) provides new value to add\n //\n let result = b;\n // b >= 0\n result += 65;\n // b > 25\n result += ((25 - b) >>> 8) & ((0 - 65) - 26 + 97);\n // b > 51\n result += ((51 - b) >>> 8) & ((26 - 97) - 52 + 48);\n // b > 61\n result += ((61 - b) >>> 8) & ((52 - 48) - 62 + 43);\n // b > 62\n result += ((62 - b) >>> 8) & ((62 - 43) - 63 + 47);\n\n return String.fromCharCode(result);\n }\n\n // Decode a character code into a byte.\n // Must return 256 if character is out of alphabet range.\n protected _decodeChar(c: number): number {\n // Decoding works similar to encoding: using the same comparison\n // function, but now it works on ranges: result is always incremented\n // by value, but this value becomes zero if the range is not\n // satisfied.\n //\n // Decoding starts with invalid value, 256, which is then\n // subtracted when the range is satisfied. If none of the ranges\n // apply, the function returns 256, which is then checked by\n // the caller to throw error.\n let result = INVALID_BYTE; // start with invalid character\n\n // c == 43 (c > 42 and c < 44)\n result += (((42 - c) & (c - 44)) >>> 8) & (-INVALID_BYTE + c - 43 + 62);\n // c == 47 (c > 46 and c < 48)\n result += (((46 - c) & (c - 48)) >>> 8) & (-INVALID_BYTE + c - 47 + 63);\n // c > 47 and c < 58\n result += (((47 - c) & (c - 58)) >>> 8) & (-INVALID_BYTE + c - 48 + 52);\n // c > 64 and c < 91\n result += (((64 - c) & (c - 91)) >>> 8) & (-INVALID_BYTE + c - 65 + 0);\n // c > 96 and c < 123\n result += (((96 - c) & (c - 123)) >>> 8) & (-INVALID_BYTE + c - 97 + 26);\n\n return result;\n }\n\n private _getPaddingLength(s: string): number {\n let paddingLength = 0;\n if (this._paddingCharacter) {\n for (let i = s.length - 1; i >= 0; i--) {\n if (s[i] !== this._paddingCharacter) {\n break;\n }\n paddingLength++;\n }\n if (s.length < 4 || paddingLength > 2) {\n throw new Error(\"Base64Coder: incorrect padding\");\n }\n }\n return paddingLength;\n }\n\n}\n\nconst stdCoder = new Coder();\n\nexport function encode(data: Uint8Array): string {\n return stdCoder.encode(data);\n}\n\nexport function decode(s: string): Uint8Array {\n return stdCoder.decode(s);\n}\n\n/**\n * Implements URL-safe Base64 encoding.\n * (Same as Base64, but '+' is replaced with '-', and '/' with '_').\n *\n * Operates in constant time.\n */\nexport class URLSafeCoder extends Coder {\n // URL-safe encoding have the following encoded/decoded ranges:\n //\n // ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 0123456789 - _\n // Index: 0 - 25 26 - 51 52 - 61 62 63\n // ASCII: 65 - 90 97 - 122 48 - 57 45 95\n //\n\n protected _encodeByte(b: number): string {\n let result = b;\n // b >= 0\n result += 65;\n // b > 25\n result += ((25 - b) >>> 8) & ((0 - 65) - 26 + 97);\n // b > 51\n result += ((51 - b) >>> 8) & ((26 - 97) - 52 + 48);\n // b > 61\n result += ((61 - b) >>> 8) & ((52 - 48) - 62 + 45);\n // b > 62\n result += ((62 - b) >>> 8) & ((62 - 45) - 63 + 95);\n\n return String.fromCharCode(result);\n }\n\n protected _decodeChar(c: number): number {\n let result = INVALID_BYTE;\n\n // c == 45 (c > 44 and c < 46)\n result += (((44 - c) & (c - 46)) >>> 8) & (-INVALID_BYTE + c - 45 + 62);\n // c == 95 (c > 94 and c < 96)\n result += (((94 - c) & (c - 96)) >>> 8) & (-INVALID_BYTE + c - 95 + 63);\n // c > 47 and c < 58\n result += (((47 - c) & (c - 58)) >>> 8) & (-INVALID_BYTE + c - 48 + 52);\n // c > 64 and c < 91\n result += (((64 - c) & (c - 91)) >>> 8) & (-INVALID_BYTE + c - 65 + 0);\n // c > 96 and c < 123\n result += (((96 - c) & (c - 123)) >>> 8) & (-INVALID_BYTE + c - 97 + 26);\n\n return result;\n }\n}\n\nconst urlSafeCoder = new URLSafeCoder();\n\nexport function encodeURLSafe(data: Uint8Array): string {\n return urlSafeCoder.encode(data);\n}\n\nexport function decodeURLSafe(s: string): Uint8Array {\n return urlSafeCoder.decode(s);\n}\n\n\nexport const encodedLength = (length: number) =>\n stdCoder.encodedLength(length);\n\nexport const maxDecodedLength = (length: number) =>\n stdCoder.maxDecodedLength(length);\n\nexport const decodedLength = (s: string) =>\n stdCoder.decodedLength(s);\n","// Copyright (C) 2016 Dmitry Chestnykh\n// MIT License. See LICENSE file for details.\n\n/**\n * Package utf8 implements UTF-8 encoding and decoding.\n */\n\nconst INVALID_UTF16 = \"utf8: invalid string\";\nconst INVALID_UTF8 = \"utf8: invalid source encoding\";\n\n/**\n * Encodes the given string into UTF-8 byte array.\n * Throws if the source string has invalid UTF-16 encoding.\n */\nexport function encode(s: string): Uint8Array {\n // Calculate result length and allocate output array.\n // encodedLength() also validates string and throws errors,\n // so we don't need repeat validation here.\n const arr = new Uint8Array(encodedLength(s));\n\n let pos = 0;\n for (let i = 0; i < s.length; i++) {\n let c = s.charCodeAt(i);\n if (c < 0x80) {\n arr[pos++] = c;\n } else if (c < 0x800) {\n arr[pos++] = 0xc0 | c >> 6;\n arr[pos++] = 0x80 | c & 0x3f;\n } else if (c < 0xd800) {\n arr[pos++] = 0xe0 | c >> 12;\n arr[pos++] = 0x80 | (c >> 6) & 0x3f;\n arr[pos++] = 0x80 | c & 0x3f;\n } else {\n i++; // get one more character\n c = (c & 0x3ff) << 10;\n c |= s.charCodeAt(i) & 0x3ff;\n c += 0x10000;\n\n arr[pos++] = 0xf0 | c >> 18;\n arr[pos++] = 0x80 | (c >> 12) & 0x3f;\n arr[pos++] = 0x80 | (c >> 6) & 0x3f;\n arr[pos++] = 0x80 | c & 0x3f;\n }\n }\n return arr;\n}\n\n/**\n * Returns the number of bytes required to encode the given string into UTF-8.\n * Throws if the source string has invalid UTF-16 encoding.\n */\nexport function encodedLength(s: string): number {\n let result = 0;\n for (let i = 0; i < s.length; i++) {\n const c = s.charCodeAt(i);\n if (c < 0x80) {\n result += 1;\n } else if (c < 0x800) {\n result += 2;\n } else if (c < 0xd800) {\n result += 3;\n } else if (c <= 0xdfff) {\n if (i >= s.length - 1) {\n throw new Error(INVALID_UTF16);\n }\n i++; // \"eat\" next character\n result += 4;\n } else {\n throw new Error(INVALID_UTF16);\n }\n }\n return result;\n}\n\n/**\n * Decodes the given byte array from UTF-8 into a string.\n * Throws if encoding is invalid.\n */\nexport function decode(arr: Uint8Array): string {\n const chars: string[] = [];\n for (let i = 0; i < arr.length; i++) {\n let b = arr[i];\n\n if (b & 0x80) {\n let min;\n if (b < 0xe0) {\n // Need 1 more byte.\n if (i >= arr.length) {\n throw new Error(INVALID_UTF8);\n }\n const n1 = arr[++i];\n if ((n1 & 0xc0) !== 0x80) {\n throw new Error(INVALID_UTF8);\n }\n b = (b & 0x1f) << 6 | (n1 & 0x3f);\n min = 0x80;\n } else if (b < 0xf0) {\n // Need 2 more bytes.\n if (i >= arr.length - 1) {\n throw new Error(INVALID_UTF8);\n }\n const n1 = arr[++i];\n const n2 = arr[++i];\n if ((n1 & 0xc0) !== 0x80 || (n2 & 0xc0) !== 0x80) {\n throw new Error(INVALID_UTF8);\n }\n b = (b & 0x0f) << 12 | (n1 & 0x3f) << 6 | (n2 & 0x3f);\n min = 0x800;\n } else if (b < 0xf8) {\n // Need 3 more bytes.\n if (i >= arr.length - 2) {\n throw new Error(INVALID_UTF8);\n }\n const n1 = arr[++i];\n const n2 = arr[++i];\n const n3 = arr[++i];\n if ((n1 & 0xc0) !== 0x80 || (n2 & 0xc0) !== 0x80 || (n3 & 0xc0) !== 0x80) {\n throw new Error(INVALID_UTF8);\n }\n b = (b & 0x0f) << 18 | (n1 & 0x3f) << 12 | (n2 & 0x3f) << 6 | (n3 & 0x3f);\n min = 0x10000;\n } else {\n throw new Error(INVALID_UTF8);\n }\n\n if (b < min || (b >= 0xd800 && b <= 0xdfff)) {\n throw new Error(INVALID_UTF8);\n }\n\n if (b >= 0x10000) {\n // Surrogate pair.\n if (b > 0x10ffff) {\n throw new Error(INVALID_UTF8);\n }\n b -= 0x10000;\n chars.push(String.fromCharCode(0xd800 | (b >> 10)));\n b = 0xdc00 | (b & 0x3ff);\n }\n }\n\n chars.push(String.fromCharCode(b));\n }\n return chars.join(\"\");\n}\n","// required so we don't have to do require('pusher').default etc.\nmodule.exports = require('./pusher').default;\n","import ScriptReceiver from './script_receiver';\n\n/** Builds receivers for JSONP and Script requests.\n *\n * Each receiver is an object with following fields:\n * - number - unique (for the factory instance), numerical id of the receiver\n * - id - a string ID that can be used in DOM attributes\n * - name - name of the function triggering the receiver\n * - callback - callback function\n *\n * Receivers are triggered only once, on the first callback call.\n *\n * Receivers can be called by their name or by accessing factory object\n * by the number key.\n *\n * @param {String} prefix the prefix used in ids\n * @param {String} name the name of the object\n */\nexport class ScriptReceiverFactory {\n lastId: number;\n prefix: string;\n name: string;\n\n constructor(prefix: string, name: string) {\n this.lastId = 0;\n this.prefix = prefix;\n this.name = name;\n }\n\n create(callback: Function): ScriptReceiver {\n this.lastId++;\n\n var number = this.lastId;\n var id = this.prefix + number;\n var name = this.name + '[' + number + ']';\n\n var called = false;\n var callbackWrapper = function() {\n if (!called) {\n callback.apply(null, arguments);\n called = true;\n }\n };\n\n this[number] = callbackWrapper;\n return { number: number, id: id, name: name, callback: callbackWrapper };\n }\n\n remove(receiver: ScriptReceiver) {\n delete this[receiver.number];\n }\n}\n\nexport var ScriptReceivers = new ScriptReceiverFactory(\n '_pusher_script_',\n 'Pusher.ScriptReceivers'\n);\n","import {\n ChannelAuthorizationOptions,\n UserAuthenticationOptions\n} from './auth/options';\nimport { AuthTransport } from './config';\n\nexport interface DefaultConfig {\n VERSION: string;\n PROTOCOL: number;\n wsPort: number;\n wssPort: number;\n wsPath: string;\n httpHost: string;\n httpPort: number;\n httpsPort: number;\n httpPath: string;\n stats_host: string;\n authEndpoint: string;\n authTransport: AuthTransport;\n activityTimeout: number;\n pongTimeout: number;\n unavailableTimeout: number;\n userAuthentication: UserAuthenticationOptions;\n channelAuthorization: ChannelAuthorizationOptions;\n\n cdn_http?: string;\n cdn_https?: string;\n dependency_suffix?: string;\n}\n\nvar Defaults: DefaultConfig = {\n VERSION: VERSION,\n PROTOCOL: 7,\n\n wsPort: 80,\n wssPort: 443,\n wsPath: '',\n // DEPRECATED: SockJS fallback parameters\n httpHost: 'sockjs.pusher.com',\n httpPort: 80,\n httpsPort: 443,\n httpPath: '/pusher',\n // DEPRECATED: Stats\n stats_host: 'stats.pusher.com',\n // DEPRECATED: Other settings\n authEndpoint: '/pusher/auth',\n authTransport: 'ajax',\n activityTimeout: 120000,\n pongTimeout: 30000,\n unavailableTimeout: 10000,\n userAuthentication: {\n endpoint: '/pusher/user-auth',\n transport: 'ajax'\n },\n channelAuthorization: {\n endpoint: '/pusher/auth',\n transport: 'ajax'\n },\n\n // CDN configuration\n cdn_http: CDN_HTTP,\n cdn_https: CDN_HTTPS,\n dependency_suffix: DEPENDENCY_SUFFIX\n};\n\nexport default Defaults;\n","import { ScriptReceiverFactory } from './script_receiver_factory';\nimport Defaults from 'core/defaults';\nimport DependencyLoader from './dependency_loader';\n\nexport var DependenciesReceivers = new ScriptReceiverFactory(\n '_pusher_dependencies',\n 'Pusher.DependenciesReceivers'\n);\n\nexport var Dependencies = new DependencyLoader({\n cdn_http: Defaults.cdn_http,\n cdn_https: Defaults.cdn_https,\n version: Defaults.VERSION,\n suffix: Defaults.dependency_suffix,\n receivers: DependenciesReceivers\n});\n","import {\n ScriptReceivers,\n ScriptReceiverFactory\n} from './script_receiver_factory';\nimport Runtime from 'runtime';\nimport ScriptRequest from './script_request';\n\n/** Handles loading dependency files.\n *\n * Dependency loaders don't remember whether a resource has been loaded or\n * not. It is caller's responsibility to make sure the resource is not loaded\n * twice. This is because it's impossible to detect resource loading status\n * without knowing its content.\n *\n * Options:\n * - cdn_http - url to HTTP CND\n * - cdn_https - url to HTTPS CDN\n * - version - version of pusher-js\n * - suffix - suffix appended to all names of dependency files\n *\n * @param {Object} options\n */\nexport default class DependencyLoader {\n options: any;\n receivers: ScriptReceiverFactory;\n loading: any;\n\n constructor(options: any) {\n this.options = options;\n this.receivers = options.receivers || ScriptReceivers;\n this.loading = {};\n }\n\n /** Loads the dependency from CDN.\n *\n * @param {String} name\n * @param {Function} callback\n */\n load(name: string, options: any, callback: Function) {\n var self = this;\n\n if (self.loading[name] && self.loading[name].length > 0) {\n self.loading[name].push(callback);\n } else {\n self.loading[name] = [callback];\n\n var request = Runtime.createScriptRequest(self.getPath(name, options));\n var receiver = self.receivers.create(function(error) {\n self.receivers.remove(receiver);\n\n if (self.loading[name]) {\n var callbacks = self.loading[name];\n delete self.loading[name];\n\n var successCallback = function(wasSuccessful) {\n if (!wasSuccessful) {\n request.cleanup();\n }\n };\n for (var i = 0; i < callbacks.length; i++) {\n callbacks[i](error, successCallback);\n }\n }\n });\n request.send(receiver);\n }\n }\n\n /** Returns a root URL for pusher-js CDN.\n *\n * @returns {String}\n */\n getRoot(options: any): string {\n var cdn;\n var protocol = Runtime.getDocument().location.protocol;\n if ((options && options.useTLS) || protocol === 'https:') {\n cdn = this.options.cdn_https;\n } else {\n cdn = this.options.cdn_http;\n }\n // make sure there are no double slashes\n return cdn.replace(/\\/*$/, '') + '/' + this.options.version;\n }\n\n /** Returns a full path to a dependency file.\n *\n * @param {String} name\n * @returns {String}\n */\n getPath(name: string, options: any): string {\n return this.getRoot(options) + '/' + name + this.options.suffix + '.js';\n }\n}\n","/**\n * A place to store help URLs for error messages etc\n */\n\nconst urlStore = {\n baseUrl: 'https://pusher.com',\n urls: {\n authenticationEndpoint: {\n path: '/docs/channels/server_api/authenticating_users'\n },\n authorizationEndpoint: {\n path: '/docs/channels/server_api/authorizing-users/'\n },\n javascriptQuickStart: {\n path: '/docs/javascript_quick_start'\n },\n triggeringClientEvents: {\n path: '/docs/client_api_guide/client_events#trigger-events'\n },\n encryptedChannelSupport: {\n fullUrl:\n 'https://github.com/pusher/pusher-js/tree/cc491015371a4bde5743d1c87a0fbac0feb53195#encrypted-channel-support'\n }\n }\n};\n\n/** Builds a consistent string with links to pusher documentation\n *\n * @param {string} key - relevant key in the url_store.urls object\n * @return {string} suffix string to append to log message\n */\nconst buildLogSuffix = function(key: string): string {\n const urlPrefix = 'See:';\n const urlObj = urlStore.urls[key];\n if (!urlObj) return '';\n\n let url;\n if (urlObj.fullUrl) {\n url = urlObj.fullUrl;\n } else if (urlObj.path) {\n url = urlStore.baseUrl + urlObj.path;\n }\n\n if (!url) return '';\n return `${urlPrefix} ${url}`;\n};\n\nexport default { buildLogSuffix };\n","export enum AuthRequestType {\n UserAuthentication = 'user-authentication',\n ChannelAuthorization = 'channel-authorization'\n}\n\nexport interface ChannelAuthorizationData {\n auth: string;\n channel_data?: string;\n shared_secret?: string;\n}\n\nexport type ChannelAuthorizationCallback = (\n error: Error | null,\n authData: ChannelAuthorizationData | null\n) => void;\n\nexport interface ChannelAuthorizationRequestParams {\n socketId: string;\n channelName: string;\n}\n\nexport interface ChannelAuthorizationHandler {\n (\n params: ChannelAuthorizationRequestParams,\n callback: ChannelAuthorizationCallback\n ): void;\n}\n\nexport interface UserAuthenticationData {\n auth: string;\n user_data: string;\n}\n\nexport type UserAuthenticationCallback = (\n error: Error | null,\n authData: UserAuthenticationData | null\n) => void;\n\nexport interface UserAuthenticationRequestParams {\n socketId: string;\n}\n\nexport interface UserAuthenticationHandler {\n (\n params: UserAuthenticationRequestParams,\n callback: UserAuthenticationCallback\n ): void;\n}\n\nexport type AuthTransportCallback =\n | ChannelAuthorizationCallback\n | UserAuthenticationCallback;\n\nexport interface AuthOptionsT {\n transport: 'ajax' | 'jsonp';\n endpoint: string;\n params?: any;\n headers?: any;\n paramsProvider?: () => any;\n headersProvider?: () => any;\n customHandler?: AuthHandler;\n}\n\nexport declare type UserAuthenticationOptions = AuthOptionsT<\n UserAuthenticationHandler\n>;\nexport declare type ChannelAuthorizationOptions = AuthOptionsT<\n ChannelAuthorizationHandler\n>;\n\nexport interface InternalAuthOptions {\n transport: 'ajax' | 'jsonp';\n endpoint: string;\n params?: any;\n headers?: any;\n paramsProvider?: () => any;\n headersProvider?: () => any;\n}\n","/** Error classes used throughout the library. */\n// https://github.com/Microsoft/TypeScript-wiki/blob/master/Breaking-Changes.md#extending-built-ins-like-error-array-and-map-may-no-longer-work\nexport class BadEventName extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\nexport class BadChannelName extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\nexport class RequestTimedOut extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class TransportPriorityTooLow extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class TransportClosed extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class UnsupportedFeature extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class UnsupportedTransport extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class UnsupportedStrategy extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class HTTPAuthError extends Error {\n status: number;\n constructor(status: number, msg?: string) {\n super(msg);\n this.status = status;\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n","import TimelineSender from 'core/timeline/timeline_sender';\nimport * as Collections from 'core/utils/collections';\nimport Util from 'core/util';\nimport Runtime from 'runtime';\nimport { AuthTransport } from 'core/auth/auth_transports';\nimport AbstractRuntime from 'runtimes/interface';\nimport UrlStore from 'core/utils/url_store';\nimport {\n AuthRequestType,\n AuthTransportCallback,\n InternalAuthOptions\n} from 'core/auth/options';\nimport { HTTPAuthError } from 'core/errors';\n\nconst ajax: AuthTransport = function(\n context: AbstractRuntime,\n query: string,\n authOptions: InternalAuthOptions,\n authRequestType: AuthRequestType,\n callback: AuthTransportCallback\n) {\n const xhr = Runtime.createXHR();\n xhr.open('POST', authOptions.endpoint, true);\n\n // add request headers\n xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');\n for (var headerName in authOptions.headers) {\n xhr.setRequestHeader(headerName, authOptions.headers[headerName]);\n }\n if (authOptions.headersProvider != null) {\n let dynamicHeaders = authOptions.headersProvider();\n for (var headerName in dynamicHeaders) {\n xhr.setRequestHeader(headerName, dynamicHeaders[headerName]);\n }\n }\n\n xhr.onreadystatechange = function() {\n if (xhr.readyState === 4) {\n if (xhr.status === 200) {\n let data;\n let parsed = false;\n\n try {\n data = JSON.parse(xhr.responseText);\n parsed = true;\n } catch (e) {\n callback(\n new HTTPAuthError(\n 200,\n `JSON returned from ${authRequestType.toString()} endpoint was invalid, yet status code was 200. Data was: ${\n xhr.responseText\n }`\n ),\n null\n );\n }\n\n if (parsed) {\n // prevents double execution.\n callback(null, data);\n }\n } else {\n let suffix = '';\n switch (authRequestType) {\n case AuthRequestType.UserAuthentication:\n suffix = UrlStore.buildLogSuffix('authenticationEndpoint');\n break;\n case AuthRequestType.ChannelAuthorization:\n suffix = `Clients must be authorized to join private or presence channels. ${UrlStore.buildLogSuffix(\n 'authorizationEndpoint'\n )}`;\n break;\n }\n callback(\n new HTTPAuthError(\n xhr.status,\n `Unable to retrieve auth string from ${authRequestType.toString()} endpoint - ` +\n `received status: ${xhr.status} from ${authOptions.endpoint}. ${suffix}`\n ),\n null\n );\n }\n }\n };\n\n xhr.send(query);\n return xhr;\n};\n\nexport default ajax;\n","export default function encode(s: any): string {\n return btoa(utob(s));\n}\n\nvar fromCharCode = String.fromCharCode;\n\nvar b64chars =\n 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';\nvar b64tab = {};\n\nfor (var i = 0, l = b64chars.length; i < l; i++) {\n b64tab[b64chars.charAt(i)] = i;\n}\n\nvar cb_utob = function(c) {\n var cc = c.charCodeAt(0);\n return cc < 0x80\n ? c\n : cc < 0x800\n ? fromCharCode(0xc0 | (cc >>> 6)) + fromCharCode(0x80 | (cc & 0x3f))\n : fromCharCode(0xe0 | ((cc >>> 12) & 0x0f)) +\n fromCharCode(0x80 | ((cc >>> 6) & 0x3f)) +\n fromCharCode(0x80 | (cc & 0x3f));\n};\n\nvar utob = function(u) {\n return u.replace(/[^\\x00-\\x7F]/g, cb_utob);\n};\n\nvar cb_encode = function(ccc) {\n var padlen = [0, 2, 1][ccc.length % 3];\n var ord =\n (ccc.charCodeAt(0) << 16) |\n ((ccc.length > 1 ? ccc.charCodeAt(1) : 0) << 8) |\n (ccc.length > 2 ? ccc.charCodeAt(2) : 0);\n var chars = [\n b64chars.charAt(ord >>> 18),\n b64chars.charAt((ord >>> 12) & 63),\n padlen >= 2 ? '=' : b64chars.charAt((ord >>> 6) & 63),\n padlen >= 1 ? '=' : b64chars.charAt(ord & 63)\n ];\n return chars.join('');\n};\n\nvar btoa =\n global.btoa ||\n function(b) {\n return b.replace(/[\\s\\S]{1,3}/g, cb_encode);\n };\n","import TimedCallback from './timed_callback';\nimport { Delay, Scheduler, Canceller } from './scheduling';\n\nabstract class Timer {\n protected clear: Canceller;\n protected timer: number | void;\n\n constructor(\n set: Scheduler,\n clear: Canceller,\n delay: Delay,\n callback: TimedCallback\n ) {\n this.clear = clear;\n this.timer = set(() => {\n if (this.timer) {\n this.timer = callback(this.timer);\n }\n }, delay);\n }\n\n /** Returns whether the timer is still running.\n *\n * @return {Boolean}\n */\n isRunning(): boolean {\n return this.timer !== null;\n }\n\n /** Aborts a timer when it's running. */\n ensureAborted() {\n if (this.timer) {\n this.clear(this.timer);\n this.timer = null;\n }\n }\n}\n\nexport default Timer;\n","import Timer from './abstract_timer';\nimport TimedCallback from './timed_callback';\nimport { Delay } from './scheduling';\n\n// We need to bind clear functions this way to avoid exceptions on IE8\nfunction clearTimeout(timer) {\n global.clearTimeout(timer);\n}\nfunction clearInterval(timer) {\n global.clearInterval(timer);\n}\n\n/** Cross-browser compatible one-off timer abstraction.\n *\n * @param {Number} delay\n * @param {Function} callback\n */\nexport class OneOffTimer extends Timer {\n constructor(delay: Delay, callback: TimedCallback) {\n super(setTimeout, clearTimeout, delay, function(timer) {\n callback();\n return null;\n });\n }\n}\n\n/** Cross-browser compatible periodic timer abstraction.\n *\n * @param {Number} delay\n * @param {Function} callback\n */\nexport class PeriodicTimer extends Timer {\n constructor(delay: Delay, callback: TimedCallback) {\n super(setInterval, clearInterval, delay, function(timer) {\n callback();\n return timer;\n });\n }\n}\n","import * as Collections from './utils/collections';\nimport TimedCallback from './utils/timers/timed_callback';\nimport { OneOffTimer, PeriodicTimer } from './utils/timers';\n\nvar Util = {\n now(): number {\n if (Date.now) {\n return Date.now();\n } else {\n return new Date().valueOf();\n }\n },\n\n defer(callback: TimedCallback): OneOffTimer {\n return new OneOffTimer(0, callback);\n },\n\n /** Builds a function that will proxy a method call to its first argument.\n *\n * Allows partial application of arguments, so additional arguments are\n * prepended to the argument list.\n *\n * @param {String} name method name\n * @return {Function} proxy function\n */\n method(name: string, ...args: any[]): Function {\n var boundArguments = Array.prototype.slice.call(arguments, 1);\n return function(object) {\n return object[name].apply(object, boundArguments.concat(arguments));\n };\n }\n};\n\nexport default Util;\n","import base64encode from '../base64';\nimport Util from '../util';\n\n/** Merges multiple objects into the target argument.\n *\n * For properties that are plain Objects, performs a deep-merge. For the\n * rest it just copies the value of the property.\n *\n * To extend prototypes use it as following:\n * Pusher.Util.extend(Target.prototype, Base.prototype)\n *\n * You can also use it to merge objects without altering them:\n * Pusher.Util.extend({}, object1, object2)\n *\n * @param {Object} target\n * @return {Object} the target argument\n */\nexport function extend(target: any, ...sources: any[]): T {\n for (var i = 0; i < sources.length; i++) {\n var extensions = sources[i];\n for (var property in extensions) {\n if (\n extensions[property] &&\n extensions[property].constructor &&\n extensions[property].constructor === Object\n ) {\n target[property] = extend(target[property] || {}, extensions[property]);\n } else {\n target[property] = extensions[property];\n }\n }\n }\n return target;\n}\n\nexport function stringify(): string {\n var m = ['Pusher'];\n for (var i = 0; i < arguments.length; i++) {\n if (typeof arguments[i] === 'string') {\n m.push(arguments[i]);\n } else {\n m.push(safeJSONStringify(arguments[i]));\n }\n }\n return m.join(' : ');\n}\n\nexport function arrayIndexOf(array: any[], item: any): number {\n // MSIE doesn't have array.indexOf\n var nativeIndexOf = Array.prototype.indexOf;\n if (array === null) {\n return -1;\n }\n if (nativeIndexOf && array.indexOf === nativeIndexOf) {\n return array.indexOf(item);\n }\n for (var i = 0, l = array.length; i < l; i++) {\n if (array[i] === item) {\n return i;\n }\n }\n return -1;\n}\n\n/** Applies a function f to all properties of an object.\n *\n * Function f gets 3 arguments passed:\n * - element from the object\n * - key of the element\n * - reference to the object\n *\n * @param {Object} object\n * @param {Function} f\n */\nexport function objectApply(object: any, f: Function) {\n for (var key in object) {\n if (Object.prototype.hasOwnProperty.call(object, key)) {\n f(object[key], key, object);\n }\n }\n}\n\n/** Return a list of objects own proerty keys\n *\n * @param {Object} object\n * @returns {Array}\n */\nexport function keys(object: any): string[] {\n var keys = [];\n objectApply(object, function(_, key) {\n keys.push(key);\n });\n return keys;\n}\n\n/** Return a list of object's own property values\n *\n * @param {Object} object\n * @returns {Array}\n */\nexport function values(object: any): any[] {\n var values = [];\n objectApply(object, function(value) {\n values.push(value);\n });\n return values;\n}\n\n/** Applies a function f to all elements of an array.\n *\n * Function f gets 3 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function apply(array: any[], f: Function, context?: any) {\n for (var i = 0; i < array.length; i++) {\n f.call(context || global, array[i], i, array);\n }\n}\n\n/** Maps all elements of the array and returns the result.\n *\n * Function f gets 4 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n * - reference to the destination array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function map(array: any[], f: Function): any[] {\n var result = [];\n for (var i = 0; i < array.length; i++) {\n result.push(f(array[i], i, array, result));\n }\n return result;\n}\n\n/** Maps all elements of the object and returns the result.\n *\n * Function f gets 4 arguments passed:\n * - element from the object\n * - key of the element\n * - reference to the source object\n * - reference to the destination object\n *\n * @param {Object} object\n * @param {Function} f\n */\nexport function mapObject(object: any, f: Function): any {\n var result = {};\n objectApply(object, function(value, key) {\n result[key] = f(value);\n });\n return result;\n}\n\n/** Filters elements of the array using a test function.\n *\n * Function test gets 4 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n * - reference to the destination array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function filter(array: any[], test: Function): any[] {\n test =\n test ||\n function(value) {\n return !!value;\n };\n\n var result = [];\n for (var i = 0; i < array.length; i++) {\n if (test(array[i], i, array, result)) {\n result.push(array[i]);\n }\n }\n return result;\n}\n\n/** Filters properties of the object using a test function.\n *\n * Function test gets 4 arguments passed:\n * - element from the object\n * - key of the element\n * - reference to the source object\n * - reference to the destination object\n *\n * @param {Object} object\n * @param {Function} f\n */\nexport function filterObject(object: Object, test: Function) {\n var result = {};\n objectApply(object, function(value, key) {\n if ((test && test(value, key, object, result)) || Boolean(value)) {\n result[key] = value;\n }\n });\n return result;\n}\n\n/** Flattens an object into a two-dimensional array.\n *\n * @param {Object} object\n * @return {Array} resulting array of [key, value] pairs\n */\nexport function flatten(object: Object): any[] {\n var result = [];\n objectApply(object, function(value, key) {\n result.push([key, value]);\n });\n return result;\n}\n\n/** Checks whether any element of the array passes the test.\n *\n * Function test gets 3 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function any(array: any[], test: Function): boolean {\n for (var i = 0; i < array.length; i++) {\n if (test(array[i], i, array)) {\n return true;\n }\n }\n return false;\n}\n\n/** Checks whether all elements of the array pass the test.\n *\n * Function test gets 3 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function all(array: any[], test: Function): boolean {\n for (var i = 0; i < array.length; i++) {\n if (!test(array[i], i, array)) {\n return false;\n }\n }\n return true;\n}\n\nexport function encodeParamsObject(data): string {\n return mapObject(data, function(value) {\n if (typeof value === 'object') {\n value = safeJSONStringify(value);\n }\n return encodeURIComponent(base64encode(value.toString()));\n });\n}\n\nexport function buildQueryString(data: any): string {\n var params = filterObject(data, function(value) {\n return value !== undefined;\n });\n\n var query = map(\n flatten(encodeParamsObject(params)),\n Util.method('join', '=')\n ).join('&');\n\n return query;\n}\n\n/**\n * See https://github.com/douglascrockford/JSON-js/blob/master/cycle.js\n *\n * Remove circular references from an object. Required for JSON.stringify in\n * React Native, which tends to blow up a lot.\n *\n * @param {any} object\n * @return {any} Decycled object\n */\nexport function decycleObject(object: any): any {\n var objects = [],\n paths = [];\n\n return (function derez(value, path) {\n var i, name, nu;\n\n switch (typeof value) {\n case 'object':\n if (!value) {\n return null;\n }\n for (i = 0; i < objects.length; i += 1) {\n if (objects[i] === value) {\n return { $ref: paths[i] };\n }\n }\n\n objects.push(value);\n paths.push(path);\n\n if (Object.prototype.toString.apply(value) === '[object Array]') {\n nu = [];\n for (i = 0; i < value.length; i += 1) {\n nu[i] = derez(value[i], path + '[' + i + ']');\n }\n } else {\n nu = {};\n for (name in value) {\n if (Object.prototype.hasOwnProperty.call(value, name)) {\n nu[name] = derez(\n value[name],\n path + '[' + JSON.stringify(name) + ']'\n );\n }\n }\n }\n return nu;\n case 'number':\n case 'string':\n case 'boolean':\n return value;\n }\n })(object, '$');\n}\n\n/**\n * Provides a cross-browser and cross-platform way to safely stringify objects\n * into JSON. This is particularly necessary for ReactNative, where circular JSON\n * structures throw an exception.\n *\n * @param {any} source The object to stringify\n * @return {string} The serialized output.\n */\nexport function safeJSONStringify(source: any): string {\n try {\n return JSON.stringify(source);\n } catch (e) {\n return JSON.stringify(decycleObject(source));\n }\n}\n","import { stringify } from './utils/collections';\nimport Pusher from './pusher';\n\nclass Logger {\n debug(...args: any[]) {\n this.log(this.globalLog, args);\n }\n\n warn(...args: any[]) {\n this.log(this.globalLogWarn, args);\n }\n\n error(...args: any[]) {\n this.log(this.globalLogError, args);\n }\n\n private globalLog = (message: string) => {\n if (global.console && global.console.log) {\n global.console.log(message);\n }\n };\n\n private globalLogWarn(message: string) {\n if (global.console && global.console.warn) {\n global.console.warn(message);\n } else {\n this.globalLog(message);\n }\n }\n\n private globalLogError(message: string) {\n if (global.console && global.console.error) {\n global.console.error(message);\n } else {\n this.globalLogWarn(message);\n }\n }\n\n private log(\n defaultLoggingFunction: (message: string) => void,\n ...args: any[]\n ) {\n var message = stringify.apply(this, arguments);\n if (Pusher.log) {\n Pusher.log(message);\n } else if (Pusher.logToConsole) {\n const log = defaultLoggingFunction.bind(this);\n log(message);\n }\n }\n}\n\nexport default new Logger();\n","import Browser from '../browser';\nimport Logger from 'core/logger';\nimport JSONPRequest from '../dom/jsonp_request';\nimport { ScriptReceivers } from '../dom/script_receiver_factory';\nimport { AuthTransport } from 'core/auth/auth_transports';\nimport {\n AuthRequestType,\n AuthTransportCallback,\n InternalAuthOptions\n} from 'core/auth/options';\n\nvar jsonp: AuthTransport = function(\n context: Browser,\n query: string,\n authOptions: InternalAuthOptions,\n authRequestType: AuthRequestType,\n callback: AuthTransportCallback\n) {\n if (\n authOptions.headers !== undefined ||\n authOptions.headersProvider != null\n ) {\n Logger.warn(\n `To send headers with the ${authRequestType.toString()} request, you must use AJAX, rather than JSONP.`\n );\n }\n\n var callbackName = context.nextAuthCallbackID.toString();\n context.nextAuthCallbackID++;\n\n var document = context.getDocument();\n var script = document.createElement('script');\n // Hacked wrapper.\n context.auth_callbacks[callbackName] = function(data) {\n callback(null, data);\n };\n\n var callback_name = \"Pusher.auth_callbacks['\" + callbackName + \"']\";\n script.src =\n authOptions.endpoint +\n '?callback=' +\n encodeURIComponent(callback_name) +\n '&' +\n query;\n\n var head =\n document.getElementsByTagName('head')[0] || document.documentElement;\n head.insertBefore(script, head.firstChild);\n};\n\nexport default jsonp;\n","import ScriptReceiver from './script_receiver';\n\n/** Sends a generic HTTP GET request using a script tag.\n *\n * By constructing URL in a specific way, it can be used for loading\n * JavaScript resources or JSONP requests. It can notify about errors, but\n * only in certain environments. Please take care of monitoring the state of\n * the request yourself.\n *\n * @param {String} src\n */\nexport default class ScriptRequest {\n src: string;\n script: any;\n errorScript: any;\n\n constructor(src: string) {\n this.src = src;\n }\n\n send(receiver: ScriptReceiver) {\n var self = this;\n var errorString = 'Error loading ' + self.src;\n\n self.script = document.createElement('script');\n self.script.id = receiver.id;\n self.script.src = self.src;\n self.script.type = 'text/javascript';\n self.script.charset = 'UTF-8';\n\n if (self.script.addEventListener) {\n self.script.onerror = function() {\n receiver.callback(errorString);\n };\n self.script.onload = function() {\n receiver.callback(null);\n };\n } else {\n self.script.onreadystatechange = function() {\n if (\n self.script.readyState === 'loaded' ||\n self.script.readyState === 'complete'\n ) {\n receiver.callback(null);\n }\n };\n }\n\n // Opera<11.6 hack for missing onerror callback\n if (\n self.script.async === undefined &&\n (document).attachEvent &&\n /opera/i.test(navigator.userAgent)\n ) {\n self.errorScript = document.createElement('script');\n self.errorScript.id = receiver.id + '_error';\n self.errorScript.text = receiver.name + \"('\" + errorString + \"');\";\n self.script.async = self.errorScript.async = false;\n } else {\n self.script.async = true;\n }\n\n var head = document.getElementsByTagName('head')[0];\n head.insertBefore(self.script, head.firstChild);\n if (self.errorScript) {\n head.insertBefore(self.errorScript, self.script.nextSibling);\n }\n }\n\n /** Cleans up the DOM remains of the script request. */\n cleanup() {\n if (this.script) {\n this.script.onload = this.script.onerror = null;\n this.script.onreadystatechange = null;\n }\n if (this.script && this.script.parentNode) {\n this.script.parentNode.removeChild(this.script);\n }\n if (this.errorScript && this.errorScript.parentNode) {\n this.errorScript.parentNode.removeChild(this.errorScript);\n }\n this.script = null;\n this.errorScript = null;\n }\n}\n","import ScriptReceiver from './script_receiver';\nimport ScriptRequest from './script_request';\nimport * as Collections from 'core/utils/collections';\nimport Util from 'core/util';\nimport Runtime from '../runtime';\n\n/** Sends data via JSONP.\n *\n * Data is a key-value map. Its values are JSON-encoded and then passed\n * through base64. Finally, keys and encoded values are appended to the query\n * string.\n *\n * The class itself does not guarantee raising errors on failures, as it's not\n * possible to support such feature on all browsers. Instead, JSONP endpoint\n * should call back in a way that's easy to distinguish from browser calls,\n * for example by passing a second argument to the receiver.\n *\n * @param {String} url\n * @param {Object} data key-value map of data to be submitted\n */\nexport default class JSONPRequest {\n url: string;\n data: any;\n request: ScriptRequest;\n\n constructor(url: string, data: any) {\n this.url = url;\n this.data = data;\n }\n\n /** Sends the actual JSONP request.\n *\n * @param {ScriptReceiver} receiver\n */\n send(receiver: ScriptReceiver) {\n if (this.request) {\n return;\n }\n\n var query = Collections.buildQueryString(this.data);\n var url = this.url + '/' + receiver.number + '?' + query;\n this.request = Runtime.createScriptRequest(url);\n this.request.send(receiver);\n }\n\n /** Cleans up the DOM remains of the JSONP request. */\n cleanup() {\n if (this.request) {\n this.request.cleanup();\n }\n }\n}\n","import TimelineSender from 'core/timeline/timeline_sender';\nimport TimelineTransport from 'core/timeline/timeline_transport';\nimport Browser from 'runtime';\nimport { AuthTransport } from 'core/auth/auth_transports';\nimport { ScriptReceivers } from '../dom/script_receiver_factory';\n\nvar getAgent = function(sender: TimelineSender, useTLS: boolean) {\n return function(data: any, callback: Function) {\n var scheme = 'http' + (useTLS ? 's' : '') + '://';\n var url =\n scheme + (sender.host || sender.options.host) + sender.options.path;\n var request = Browser.createJSONPRequest(url, data);\n\n var receiver = Browser.ScriptReceivers.create(function(error, result) {\n ScriptReceivers.remove(receiver);\n request.cleanup();\n\n if (result && result.host) {\n sender.host = result.host;\n }\n if (callback) {\n callback(error, result);\n }\n });\n request.send(receiver);\n };\n};\n\nvar jsonp = {\n name: 'jsonp',\n getAgent\n};\n\nexport default jsonp;\n","import Defaults from '../defaults';\nimport { default as URLScheme, URLSchemeParams } from './url_scheme';\n\nfunction getGenericURL(\n baseScheme: string,\n params: URLSchemeParams,\n path: string\n): string {\n var scheme = baseScheme + (params.useTLS ? 's' : '');\n var host = params.useTLS ? params.hostTLS : params.hostNonTLS;\n return scheme + '://' + host + path;\n}\n\nfunction getGenericPath(key: string, queryString?: string): string {\n var path = '/app/' + key;\n var query =\n '?protocol=' +\n Defaults.PROTOCOL +\n '&client=js' +\n '&version=' +\n Defaults.VERSION +\n (queryString ? '&' + queryString : '');\n return path + query;\n}\n\nexport var ws: URLScheme = {\n getInitial: function(key: string, params: URLSchemeParams): string {\n var path = (params.httpPath || '') + getGenericPath(key, 'flash=false');\n return getGenericURL('ws', params, path);\n }\n};\n\nexport var http: URLScheme = {\n getInitial: function(key: string, params: URLSchemeParams): string {\n var path = (params.httpPath || '/pusher') + getGenericPath(key);\n return getGenericURL('http', params, path);\n }\n};\n\nexport var sockjs: URLScheme = {\n getInitial: function(key: string, params: URLSchemeParams): string {\n return getGenericURL('http', params, params.httpPath || '/pusher');\n },\n getPath: function(key: string, params: URLSchemeParams): string {\n return getGenericPath(key);\n }\n};\n","import Callback from './callback';\nimport * as Collections from '../utils/collections';\nimport CallbackTable from './callback_table';\n\nexport default class CallbackRegistry {\n _callbacks: CallbackTable;\n\n constructor() {\n this._callbacks = {};\n }\n\n get(name: string): Callback[] {\n return this._callbacks[prefix(name)];\n }\n\n add(name: string, callback: Function, context: any) {\n var prefixedEventName = prefix(name);\n this._callbacks[prefixedEventName] =\n this._callbacks[prefixedEventName] || [];\n this._callbacks[prefixedEventName].push({\n fn: callback,\n context: context\n });\n }\n\n remove(name?: string, callback?: Function, context?: any) {\n if (!name && !callback && !context) {\n this._callbacks = {};\n return;\n }\n\n var names = name ? [prefix(name)] : Collections.keys(this._callbacks);\n\n if (callback || context) {\n this.removeCallback(names, callback, context);\n } else {\n this.removeAllCallbacks(names);\n }\n }\n\n private removeCallback(names: string[], callback: Function, context: any) {\n Collections.apply(\n names,\n function(name) {\n this._callbacks[name] = Collections.filter(\n this._callbacks[name] || [],\n function(binding) {\n return (\n (callback && callback !== binding.fn) ||\n (context && context !== binding.context)\n );\n }\n );\n if (this._callbacks[name].length === 0) {\n delete this._callbacks[name];\n }\n },\n this\n );\n }\n\n private removeAllCallbacks(names: string[]) {\n Collections.apply(\n names,\n function(name) {\n delete this._callbacks[name];\n },\n this\n );\n }\n}\n\nfunction prefix(name: string): string {\n return '_' + name;\n}\n","import * as Collections from '../utils/collections';\nimport Callback from './callback';\nimport Metadata from '../channels/metadata';\nimport CallbackRegistry from './callback_registry';\n\n/** Manages callback bindings and event emitting.\n *\n * @param Function failThrough called when no listeners are bound to an event\n */\nexport default class Dispatcher {\n callbacks: CallbackRegistry;\n global_callbacks: Function[];\n failThrough: Function;\n\n constructor(failThrough?: Function) {\n this.callbacks = new CallbackRegistry();\n this.global_callbacks = [];\n this.failThrough = failThrough;\n }\n\n bind(eventName: string, callback: Function, context?: any) {\n this.callbacks.add(eventName, callback, context);\n return this;\n }\n\n bind_global(callback: Function) {\n this.global_callbacks.push(callback);\n return this;\n }\n\n unbind(eventName?: string, callback?: Function, context?: any) {\n this.callbacks.remove(eventName, callback, context);\n return this;\n }\n\n unbind_global(callback?: Function) {\n if (!callback) {\n this.global_callbacks = [];\n return this;\n }\n\n this.global_callbacks = Collections.filter(\n this.global_callbacks || [],\n c => c !== callback\n );\n\n return this;\n }\n\n unbind_all() {\n this.unbind();\n this.unbind_global();\n return this;\n }\n\n emit(eventName: string, data?: any, metadata?: Metadata): Dispatcher {\n for (var i = 0; i < this.global_callbacks.length; i++) {\n this.global_callbacks[i](eventName, data);\n }\n\n var callbacks = this.callbacks.get(eventName);\n var args = [];\n\n if (metadata) {\n // if there's a metadata argument, we need to call the callback with both\n // data and metadata regardless of whether data is undefined\n args.push(data, metadata);\n } else if (data) {\n // metadata is undefined, so we only need to call the callback with data\n // if data exists\n args.push(data);\n }\n\n if (callbacks && callbacks.length > 0) {\n for (var i = 0; i < callbacks.length; i++) {\n callbacks[i].fn.apply(callbacks[i].context || global, args);\n }\n } else if (this.failThrough) {\n this.failThrough(eventName, data);\n }\n\n return this;\n }\n}\n","import Util from '../util';\nimport * as Collections from '../utils/collections';\nimport { default as EventsDispatcher } from '../events/dispatcher';\nimport Logger from '../logger';\nimport TransportHooks from './transport_hooks';\nimport Socket from '../socket';\nimport Runtime from 'runtime';\nimport Timeline from '../timeline/timeline';\nimport TransportConnectionOptions from './transport_connection_options';\n\n/** Provides universal API for transport connections.\n *\n * Transport connection is a low-level object that wraps a connection method\n * and exposes a simple evented interface for the connection state and\n * messaging. It does not implement Pusher-specific WebSocket protocol.\n *\n * Additionally, it fetches resources needed for transport to work and exposes\n * an interface for querying transport features.\n *\n * States:\n * - new - initial state after constructing the object\n * - initializing - during initialization phase, usually fetching resources\n * - intialized - ready to establish a connection\n * - connection - when connection is being established\n * - open - when connection ready to be used\n * - closed - after connection was closed be either side\n *\n * Emits:\n * - error - after the connection raised an error\n *\n * Options:\n * - useTLS - whether connection should be over TLS\n * - hostTLS - host to connect to when connection is over TLS\n * - hostNonTLS - host to connect to when connection is over TLS\n *\n * @param {String} key application key\n * @param {Object} options\n */\nexport default class TransportConnection extends EventsDispatcher {\n hooks: TransportHooks;\n name: string;\n priority: number;\n key: string;\n options: TransportConnectionOptions;\n state: string;\n timeline: Timeline;\n activityTimeout: number;\n id: number;\n socket: Socket;\n beforeOpen: Function;\n initialize: Function;\n\n constructor(\n hooks: TransportHooks,\n name: string,\n priority: number,\n key: string,\n options: TransportConnectionOptions\n ) {\n super();\n this.initialize = Runtime.transportConnectionInitializer;\n this.hooks = hooks;\n this.name = name;\n this.priority = priority;\n this.key = key;\n this.options = options;\n\n this.state = 'new';\n this.timeline = options.timeline;\n this.activityTimeout = options.activityTimeout;\n this.id = this.timeline.generateUniqueID();\n }\n\n /** Checks whether the transport handles activity checks by itself.\n *\n * @return {Boolean}\n */\n handlesActivityChecks(): boolean {\n return Boolean(this.hooks.handlesActivityChecks);\n }\n\n /** Checks whether the transport supports the ping/pong API.\n *\n * @return {Boolean}\n */\n supportsPing(): boolean {\n return Boolean(this.hooks.supportsPing);\n }\n\n /** Tries to establish a connection.\n *\n * @returns {Boolean} false if transport is in invalid state\n */\n connect(): boolean {\n if (this.socket || this.state !== 'initialized') {\n return false;\n }\n\n var url = this.hooks.urls.getInitial(this.key, this.options);\n try {\n this.socket = this.hooks.getSocket(url, this.options);\n } catch (e) {\n Util.defer(() => {\n this.onError(e);\n this.changeState('closed');\n });\n return false;\n }\n\n this.bindListeners();\n\n Logger.debug('Connecting', { transport: this.name, url });\n this.changeState('connecting');\n return true;\n }\n\n /** Closes the connection.\n *\n * @return {Boolean} true if there was a connection to close\n */\n close(): boolean {\n if (this.socket) {\n this.socket.close();\n return true;\n } else {\n return false;\n }\n }\n\n /** Sends data over the open connection.\n *\n * @param {String} data\n * @return {Boolean} true only when in the \"open\" state\n */\n send(data: any): boolean {\n if (this.state === 'open') {\n // Workaround for MobileSafari bug (see https://gist.github.com/2052006)\n Util.defer(() => {\n if (this.socket) {\n this.socket.send(data);\n }\n });\n return true;\n } else {\n return false;\n }\n }\n\n /** Sends a ping if the connection is open and transport supports it. */\n ping() {\n if (this.state === 'open' && this.supportsPing()) {\n this.socket.ping();\n }\n }\n\n private onOpen() {\n if (this.hooks.beforeOpen) {\n this.hooks.beforeOpen(\n this.socket,\n this.hooks.urls.getPath(this.key, this.options)\n );\n }\n this.changeState('open');\n this.socket.onopen = undefined;\n }\n\n private onError(error) {\n this.emit('error', { type: 'WebSocketError', error: error });\n this.timeline.error(this.buildTimelineMessage({ error: error.toString() }));\n }\n\n private onClose(closeEvent?: any) {\n if (closeEvent) {\n this.changeState('closed', {\n code: closeEvent.code,\n reason: closeEvent.reason,\n wasClean: closeEvent.wasClean\n });\n } else {\n this.changeState('closed');\n }\n this.unbindListeners();\n this.socket = undefined;\n }\n\n private onMessage(message) {\n this.emit('message', message);\n }\n\n private onActivity() {\n this.emit('activity');\n }\n\n private bindListeners() {\n this.socket.onopen = () => {\n this.onOpen();\n };\n this.socket.onerror = error => {\n this.onError(error);\n };\n this.socket.onclose = closeEvent => {\n this.onClose(closeEvent);\n };\n this.socket.onmessage = message => {\n this.onMessage(message);\n };\n\n if (this.supportsPing()) {\n this.socket.onactivity = () => {\n this.onActivity();\n };\n }\n }\n\n private unbindListeners() {\n if (this.socket) {\n this.socket.onopen = undefined;\n this.socket.onerror = undefined;\n this.socket.onclose = undefined;\n this.socket.onmessage = undefined;\n if (this.supportsPing()) {\n this.socket.onactivity = undefined;\n }\n }\n }\n\n private changeState(state: string, params?: any) {\n this.state = state;\n this.timeline.info(\n this.buildTimelineMessage({\n state: state,\n params: params\n })\n );\n this.emit(state, params);\n }\n\n buildTimelineMessage(message): any {\n return Collections.extend({ cid: this.id }, message);\n }\n}\n","import Factory from '../utils/factory';\nimport TransportHooks from './transport_hooks';\nimport TransportConnection from './transport_connection';\nimport TransportConnectionOptions from './transport_connection_options';\n\n/** Provides interface for transport connection instantiation.\n *\n * Takes transport-specific hooks as the only argument, which allow checking\n * for transport support and creating its connections.\n *\n * Supported hooks: * - file - the name of the file to be fetched during initialization\n * - urls - URL scheme to be used by transport\n * - handlesActivityCheck - true when the transport handles activity checks\n * - supportsPing - true when the transport has a ping/activity API\n * - isSupported - tells whether the transport is supported in the environment\n * - getSocket - creates a WebSocket-compatible transport socket\n *\n * See transports.js for specific implementations.\n *\n * @param {Object} hooks object containing all needed transport hooks\n */\nexport default class Transport {\n hooks: TransportHooks;\n\n constructor(hooks: TransportHooks) {\n this.hooks = hooks;\n }\n\n /** Returns whether the transport is supported in the environment.\n *\n * @param {Object} envronment te environment details (encryption, settings)\n * @returns {Boolean} true when the transport is supported\n */\n isSupported(environment: any): boolean {\n return this.hooks.isSupported(environment);\n }\n\n /** Creates a transport connection.\n *\n * @param {String} name\n * @param {Number} priority\n * @param {String} key the application key\n * @param {Object} options\n * @returns {TransportConnection}\n */\n createConnection(\n name: string,\n priority: number,\n key: string,\n options: any\n ): TransportConnection {\n return new TransportConnection(this.hooks, name, priority, key, options);\n }\n}\n","import * as URLSchemes from 'core/transports/url_schemes';\nimport URLScheme from 'core/transports/url_scheme';\nimport Transport from 'core/transports/transport';\nimport Util from 'core/util';\nimport * as Collections from 'core/utils/collections';\nimport TransportHooks from 'core/transports/transport_hooks';\nimport TransportsTable from 'core/transports/transports_table';\nimport Runtime from 'runtime';\n\n/** WebSocket transport.\n *\n * Uses native WebSocket implementation, including MozWebSocket supported by\n * earlier Firefox versions.\n */\nvar WSTransport = new Transport({\n urls: URLSchemes.ws,\n handlesActivityChecks: false,\n supportsPing: false,\n\n isInitialized: function() {\n return Boolean(Runtime.getWebSocketAPI());\n },\n isSupported: function(): boolean {\n return Boolean(Runtime.getWebSocketAPI());\n },\n getSocket: function(url) {\n return Runtime.createWebSocket(url);\n }\n});\n\nvar httpConfiguration = {\n urls: URLSchemes.http,\n handlesActivityChecks: false,\n supportsPing: true,\n isInitialized: function() {\n return true;\n }\n};\n\nexport var streamingConfiguration = Collections.extend(\n {\n getSocket: function(url) {\n return Runtime.HTTPFactory.createStreamingSocket(url);\n }\n },\n httpConfiguration\n);\nexport var pollingConfiguration = Collections.extend(\n {\n getSocket: function(url) {\n return Runtime.HTTPFactory.createPollingSocket(url);\n }\n },\n httpConfiguration\n);\n\nvar xhrConfiguration = {\n isSupported: function(): boolean {\n return Runtime.isXHRSupported();\n }\n};\n\n/** HTTP streaming transport using CORS-enabled XMLHttpRequest. */\nvar XHRStreamingTransport = new Transport(\n (\n Collections.extend({}, streamingConfiguration, xhrConfiguration)\n )\n);\n\n/** HTTP long-polling transport using CORS-enabled XMLHttpRequest. */\nvar XHRPollingTransport = new Transport(\n Collections.extend({}, pollingConfiguration, xhrConfiguration)\n);\n\nvar Transports: TransportsTable = {\n ws: WSTransport,\n xhr_streaming: XHRStreamingTransport,\n xhr_polling: XHRPollingTransport\n};\n\nexport default Transports;\n","import {\n default as Transports,\n streamingConfiguration,\n pollingConfiguration\n} from 'isomorphic/transports/transports';\nimport Transport from 'core/transports/transport';\nimport TransportHooks from 'core/transports/transport_hooks';\nimport * as URLSchemes from 'core/transports/url_schemes';\nimport Runtime from 'runtime';\nimport { Dependencies } from '../dom/dependencies';\nimport * as Collections from 'core/utils/collections';\n\nvar SockJSTransport = new Transport({\n file: 'sockjs',\n urls: URLSchemes.sockjs,\n handlesActivityChecks: true,\n supportsPing: false,\n\n isSupported: function() {\n return true;\n },\n isInitialized: function() {\n return window.SockJS !== undefined;\n },\n getSocket: function(url, options) {\n return new window.SockJS(url, null, {\n js_path: Dependencies.getPath('sockjs', {\n useTLS: options.useTLS\n }),\n ignore_null_origin: options.ignoreNullOrigin\n });\n },\n beforeOpen: function(socket, path) {\n socket.send(\n JSON.stringify({\n path: path\n })\n );\n }\n});\n\nvar xdrConfiguration = {\n isSupported: function(environment): boolean {\n var yes = Runtime.isXDRSupported(environment.useTLS);\n return yes;\n }\n};\n\n/** HTTP streaming transport using XDomainRequest (IE 8,9). */\nvar XDRStreamingTransport = new Transport(\n (\n Collections.extend({}, streamingConfiguration, xdrConfiguration)\n )\n);\n\n/** HTTP long-polling transport using XDomainRequest (IE 8,9). */\nvar XDRPollingTransport = new Transport(\n Collections.extend({}, pollingConfiguration, xdrConfiguration)\n);\n\nTransports.xdr_streaming = XDRStreamingTransport;\nTransports.xdr_polling = XDRPollingTransport;\nTransports.sockjs = SockJSTransport;\n\nexport default Transports;\n","import Reachability from 'core/reachability';\nimport { default as EventsDispatcher } from 'core/events/dispatcher';\n\n/** Really basic interface providing network availability info.\n *\n * Emits:\n * - online - when browser goes online\n * - offline - when browser goes offline\n */\nexport class NetInfo extends EventsDispatcher implements Reachability {\n constructor() {\n super();\n var self = this;\n // This is okay, as IE doesn't support this stuff anyway.\n if (window.addEventListener !== undefined) {\n window.addEventListener(\n 'online',\n function() {\n self.emit('online');\n },\n false\n );\n window.addEventListener(\n 'offline',\n function() {\n self.emit('offline');\n },\n false\n );\n }\n }\n\n /** Returns whether browser is online or not\n *\n * Offline means definitely offline (no connection to router).\n * Inverse does NOT mean definitely online (only currently supported in Safari\n * and even there only means the device has a connection to the router).\n *\n * @return {Boolean}\n */\n isOnline(): boolean {\n if (window.navigator.onLine === undefined) {\n return true;\n } else {\n return window.navigator.onLine;\n }\n }\n}\n\nexport var Network = new NetInfo();\n","import Util from '../util';\nimport * as Collections from '../utils/collections';\nimport TransportManager from './transport_manager';\nimport TransportConnection from './transport_connection';\nimport Transport from './transport';\nimport PingDelayOptions from './ping_delay_options';\n\n/** Creates transport connections monitored by a transport manager.\n *\n * When a transport is closed, it might mean the environment does not support\n * it. It's possible that messages get stuck in an intermediate buffer or\n * proxies terminate inactive connections. To combat these problems,\n * assistants monitor the connection lifetime, report unclean exits and\n * adjust ping timeouts to keep the connection active. The decision to disable\n * a transport is the manager's responsibility.\n *\n * @param {TransportManager} manager\n * @param {TransportConnection} transport\n * @param {Object} options\n */\nexport default class AssistantToTheTransportManager {\n manager: TransportManager;\n transport: Transport;\n minPingDelay: number;\n maxPingDelay: number;\n pingDelay: number;\n\n constructor(\n manager: TransportManager,\n transport: Transport,\n options: PingDelayOptions\n ) {\n this.manager = manager;\n this.transport = transport;\n this.minPingDelay = options.minPingDelay;\n this.maxPingDelay = options.maxPingDelay;\n this.pingDelay = undefined;\n }\n\n /** Creates a transport connection.\n *\n * This function has the same API as Transport#createConnection.\n *\n * @param {String} name\n * @param {Number} priority\n * @param {String} key the application key\n * @param {Object} options\n * @returns {TransportConnection}\n */\n createConnection(\n name: string,\n priority: number,\n key: string,\n options: Object\n ): TransportConnection {\n options = Collections.extend({}, options, {\n activityTimeout: this.pingDelay\n });\n var connection = this.transport.createConnection(\n name,\n priority,\n key,\n options\n );\n\n var openTimestamp = null;\n\n var onOpen = function() {\n connection.unbind('open', onOpen);\n connection.bind('closed', onClosed);\n openTimestamp = Util.now();\n };\n var onClosed = closeEvent => {\n connection.unbind('closed', onClosed);\n\n if (closeEvent.code === 1002 || closeEvent.code === 1003) {\n // we don't want to use transports not obeying the protocol\n this.manager.reportDeath();\n } else if (!closeEvent.wasClean && openTimestamp) {\n // report deaths only for short-living transport\n var lifespan = Util.now() - openTimestamp;\n if (lifespan < 2 * this.maxPingDelay) {\n this.manager.reportDeath();\n this.pingDelay = Math.max(lifespan / 2, this.minPingDelay);\n }\n }\n };\n\n connection.bind('open', onOpen);\n return connection;\n }\n\n /** Returns whether the transport is supported in the environment.\n *\n * This function has the same API as Transport#isSupported. Might return false\n * when the manager decides to kill the transport.\n *\n * @param {Object} environment the environment details (encryption, settings)\n * @returns {Boolean} true when the transport is supported\n */\n isSupported(environment: string): boolean {\n return this.manager.isAlive() && this.transport.isSupported(environment);\n }\n}\n","import Action from './action';\nimport { PusherEvent } from './message-types';\n/**\n * Provides functions for handling Pusher protocol-specific messages.\n */\n\nconst Protocol = {\n /**\n * Decodes a message in a Pusher format.\n *\n * The MessageEvent we receive from the transport should contain a pusher event\n * (https://pusher.com/docs/pusher_protocol#events) serialized as JSON in the\n * data field\n *\n * The pusher event may contain a data field too, and it may also be\n * serialised as JSON\n *\n * Throws errors when messages are not parse'able.\n *\n * @param {MessageEvent} messageEvent\n * @return {PusherEvent}\n */\n decodeMessage: function(messageEvent: MessageEvent): PusherEvent {\n try {\n var messageData = JSON.parse(messageEvent.data);\n var pusherEventData = messageData.data;\n if (typeof pusherEventData === 'string') {\n try {\n pusherEventData = JSON.parse(messageData.data);\n } catch (e) {}\n }\n var pusherEvent: PusherEvent = {\n event: messageData.event,\n channel: messageData.channel,\n data: pusherEventData\n };\n if (messageData.user_id) {\n pusherEvent.user_id = messageData.user_id;\n }\n return pusherEvent;\n } catch (e) {\n throw { type: 'MessageParseError', error: e, data: messageEvent.data };\n }\n },\n\n /**\n * Encodes a message to be sent.\n *\n * @param {PusherEvent} event\n * @return {String}\n */\n encodeMessage: function(event: PusherEvent): string {\n return JSON.stringify(event);\n },\n\n /**\n * Processes a handshake message and returns appropriate actions.\n *\n * Returns an object with an 'action' and other action-specific properties.\n *\n * There are three outcomes when calling this function. First is a successful\n * connection attempt, when pusher:connection_established is received, which\n * results in a 'connected' action with an 'id' property. When passed a\n * pusher:error event, it returns a result with action appropriate to the\n * close code and an error. Otherwise, it raises an exception.\n *\n * @param {String} message\n * @result Object\n */\n processHandshake: function(messageEvent: MessageEvent): Action {\n var message = Protocol.decodeMessage(messageEvent);\n\n if (message.event === 'pusher:connection_established') {\n if (!message.data.activity_timeout) {\n throw 'No activity timeout specified in handshake';\n }\n return {\n action: 'connected',\n id: message.data.socket_id,\n activityTimeout: message.data.activity_timeout * 1000\n };\n } else if (message.event === 'pusher:error') {\n // From protocol 6 close codes are sent only once, so this only\n // happens when connection does not support close codes\n return {\n action: this.getCloseAction(message.data),\n error: this.getCloseError(message.data)\n };\n } else {\n throw 'Invalid handshake';\n }\n },\n\n /**\n * Dispatches the close event and returns an appropriate action name.\n *\n * See:\n * 1. https://developer.mozilla.org/en-US/docs/WebSockets/WebSockets_reference/CloseEvent\n * 2. http://pusher.com/docs/pusher_protocol\n *\n * @param {CloseEvent} closeEvent\n * @return {String} close action name\n */\n getCloseAction: function(closeEvent): string {\n if (closeEvent.code < 4000) {\n // ignore 1000 CLOSE_NORMAL, 1001 CLOSE_GOING_AWAY,\n // 1005 CLOSE_NO_STATUS, 1006 CLOSE_ABNORMAL\n // ignore 1007...3999\n // handle 1002 CLOSE_PROTOCOL_ERROR, 1003 CLOSE_UNSUPPORTED,\n // 1004 CLOSE_TOO_LARGE\n if (closeEvent.code >= 1002 && closeEvent.code <= 1004) {\n return 'backoff';\n } else {\n return null;\n }\n } else if (closeEvent.code === 4000) {\n return 'tls_only';\n } else if (closeEvent.code < 4100) {\n return 'refused';\n } else if (closeEvent.code < 4200) {\n return 'backoff';\n } else if (closeEvent.code < 4300) {\n return 'retry';\n } else {\n // unknown error\n return 'refused';\n }\n },\n\n /**\n * Returns an error or null basing on the close event.\n *\n * Null is returned when connection was closed cleanly. Otherwise, an object\n * with error details is returned.\n *\n * @param {CloseEvent} closeEvent\n * @return {Object} error object\n */\n getCloseError: function(closeEvent): any {\n if (closeEvent.code !== 1000 && closeEvent.code !== 1001) {\n return {\n type: 'PusherError',\n data: {\n code: closeEvent.code,\n message: closeEvent.reason || closeEvent.message\n }\n };\n } else {\n return null;\n }\n }\n};\n\nexport default Protocol;\n","import * as Collections from '../utils/collections';\nimport { default as EventsDispatcher } from '../events/dispatcher';\nimport Protocol from './protocol/protocol';\nimport { PusherEvent } from './protocol/message-types';\nimport Logger from '../logger';\nimport TransportConnection from '../transports/transport_connection';\nimport Socket from '../socket';\n/**\n * Provides Pusher protocol interface for transports.\n *\n * Emits following events:\n * - message - on received messages\n * - ping - on ping requests\n * - pong - on pong responses\n * - error - when the transport emits an error\n * - closed - after closing the transport\n *\n * It also emits more events when connection closes with a code.\n * See Protocol.getCloseAction to get more details.\n *\n * @param {Number} id\n * @param {AbstractTransport} transport\n */\nexport default class Connection extends EventsDispatcher implements Socket {\n id: string;\n transport: TransportConnection;\n activityTimeout: number;\n\n constructor(id: string, transport: TransportConnection) {\n super();\n this.id = id;\n this.transport = transport;\n this.activityTimeout = transport.activityTimeout;\n this.bindListeners();\n }\n\n /** Returns whether used transport handles activity checks by itself\n *\n * @returns {Boolean} true if activity checks are handled by the transport\n */\n handlesActivityChecks() {\n return this.transport.handlesActivityChecks();\n }\n\n /** Sends raw data.\n *\n * @param {String} data\n */\n send(data: any): boolean {\n return this.transport.send(data);\n }\n\n /** Sends an event.\n *\n * @param {String} name\n * @param {String} data\n * @param {String} [channel]\n * @returns {Boolean} whether message was sent or not\n */\n send_event(name: string, data: any, channel?: string): boolean {\n var event: PusherEvent = { event: name, data: data };\n if (channel) {\n event.channel = channel;\n }\n Logger.debug('Event sent', event);\n return this.send(Protocol.encodeMessage(event));\n }\n\n /** Sends a ping message to the server.\n *\n * Basing on the underlying transport, it might send either transport's\n * protocol-specific ping or pusher:ping event.\n */\n ping() {\n if (this.transport.supportsPing()) {\n this.transport.ping();\n } else {\n this.send_event('pusher:ping', {});\n }\n }\n\n /** Closes the connection. */\n close() {\n this.transport.close();\n }\n\n private bindListeners() {\n var listeners = {\n message: (messageEvent: MessageEvent) => {\n var pusherEvent;\n try {\n pusherEvent = Protocol.decodeMessage(messageEvent);\n } catch (e) {\n this.emit('error', {\n type: 'MessageParseError',\n error: e,\n data: messageEvent.data\n });\n }\n\n if (pusherEvent !== undefined) {\n Logger.debug('Event recd', pusherEvent);\n\n switch (pusherEvent.event) {\n case 'pusher:error':\n this.emit('error', {\n type: 'PusherError',\n data: pusherEvent.data\n });\n break;\n case 'pusher:ping':\n this.emit('ping');\n break;\n case 'pusher:pong':\n this.emit('pong');\n break;\n }\n this.emit('message', pusherEvent);\n }\n },\n activity: () => {\n this.emit('activity');\n },\n error: error => {\n this.emit('error', error);\n },\n closed: closeEvent => {\n unbindListeners();\n\n if (closeEvent && closeEvent.code) {\n this.handleCloseEvent(closeEvent);\n }\n\n this.transport = null;\n this.emit('closed');\n }\n };\n\n var unbindListeners = () => {\n Collections.objectApply(listeners, (listener, event) => {\n this.transport.unbind(event, listener);\n });\n };\n\n Collections.objectApply(listeners, (listener, event) => {\n this.transport.bind(event, listener);\n });\n }\n\n private handleCloseEvent(closeEvent: any) {\n var action = Protocol.getCloseAction(closeEvent);\n var error = Protocol.getCloseError(closeEvent);\n if (error) {\n this.emit('error', error);\n }\n if (action) {\n this.emit(action, { action: action, error: error });\n }\n }\n}\n","import Util from '../../util';\nimport * as Collections from '../../utils/collections';\nimport Protocol from '../protocol/protocol';\nimport Connection from '../connection';\nimport TransportConnection from '../../transports/transport_connection';\nimport HandshakePayload from './handshake_payload';\n\n/**\n * Handles Pusher protocol handshakes for transports.\n *\n * Calls back with a result object after handshake is completed. Results\n * always have two fields:\n * - action - string describing action to be taken after the handshake\n * - transport - the transport object passed to the constructor\n *\n * Different actions can set different additional properties on the result.\n * In the case of 'connected' action, there will be a 'connection' property\n * containing a Connection object for the transport. Other actions should\n * carry an 'error' property.\n *\n * @param {AbstractTransport} transport\n * @param {Function} callback\n */\nexport default class Handshake {\n transport: TransportConnection;\n callback: (HandshakePayload) => void;\n onMessage: Function;\n onClosed: Function;\n\n constructor(\n transport: TransportConnection,\n callback: (HandshakePayload) => void\n ) {\n this.transport = transport;\n this.callback = callback;\n this.bindListeners();\n }\n\n close() {\n this.unbindListeners();\n this.transport.close();\n }\n\n private bindListeners() {\n this.onMessage = m => {\n this.unbindListeners();\n\n var result;\n try {\n result = Protocol.processHandshake(m);\n } catch (e) {\n this.finish('error', { error: e });\n this.transport.close();\n return;\n }\n\n if (result.action === 'connected') {\n this.finish('connected', {\n connection: new Connection(result.id, this.transport),\n activityTimeout: result.activityTimeout\n });\n } else {\n this.finish(result.action, { error: result.error });\n this.transport.close();\n }\n };\n\n this.onClosed = closeEvent => {\n this.unbindListeners();\n\n var action = Protocol.getCloseAction(closeEvent) || 'backoff';\n var error = Protocol.getCloseError(closeEvent);\n this.finish(action, { error: error });\n };\n\n this.transport.bind('message', this.onMessage);\n this.transport.bind('closed', this.onClosed);\n }\n\n private unbindListeners() {\n this.transport.unbind('message', this.onMessage);\n this.transport.unbind('closed', this.onClosed);\n }\n\n private finish(action: string, params: any) {\n this.callback(\n Collections.extend({ transport: this.transport, action: action }, params)\n );\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport base64encode from '../base64';\nimport Timeline from './timeline';\nimport Runtime from 'runtime';\n\nexport interface TimelineSenderOptions {\n host?: string;\n port?: number;\n path?: string;\n}\n\nexport default class TimelineSender {\n timeline: Timeline;\n options: TimelineSenderOptions;\n host: string;\n\n constructor(timeline: Timeline, options: TimelineSenderOptions) {\n this.timeline = timeline;\n this.options = options || {};\n }\n\n send(useTLS: boolean, callback?: Function) {\n if (this.timeline.isEmpty()) {\n return;\n }\n\n this.timeline.send(\n Runtime.TimelineTransport.getAgent(this, useTLS),\n callback\n );\n }\n}\n","import { default as EventsDispatcher } from '../events/dispatcher';\nimport * as Errors from '../errors';\nimport Logger from '../logger';\nimport Pusher from '../pusher';\nimport { PusherEvent } from '../connection/protocol/message-types';\nimport Metadata from './metadata';\nimport UrlStore from '../utils/url_store';\nimport {\n ChannelAuthorizationData,\n ChannelAuthorizationCallback\n} from '../auth/options';\nimport { HTTPAuthError } from '../errors';\n\n/** Provides base public channel interface with an event emitter.\n *\n * Emits:\n * - pusher:subscription_succeeded - after subscribing successfully\n * - other non-internal events\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\nexport default class Channel extends EventsDispatcher {\n name: string;\n pusher: Pusher;\n subscribed: boolean;\n subscriptionPending: boolean;\n subscriptionCancelled: boolean;\n subscriptionCount: null;\n\n constructor(name: string, pusher: Pusher) {\n super(function(event, data) {\n Logger.debug('No callbacks on ' + name + ' for ' + event);\n });\n\n this.name = name;\n this.pusher = pusher;\n this.subscribed = false;\n this.subscriptionPending = false;\n this.subscriptionCancelled = false;\n }\n\n /** Skips authorization, since public channels don't require it.\n *\n * @param {Function} callback\n */\n authorize(socketId: string, callback: ChannelAuthorizationCallback) {\n return callback(null, { auth: '' });\n }\n\n /** Triggers an event */\n trigger(event: string, data: any) {\n if (event.indexOf('client-') !== 0) {\n throw new Errors.BadEventName(\n \"Event '\" + event + \"' does not start with 'client-'\"\n );\n }\n if (!this.subscribed) {\n var suffix = UrlStore.buildLogSuffix('triggeringClientEvents');\n Logger.warn(\n `Client event triggered before channel 'subscription_succeeded' event . ${suffix}`\n );\n }\n return this.pusher.send_event(event, data, this.name);\n }\n\n /** Signals disconnection to the channel. For internal use only. */\n disconnect() {\n this.subscribed = false;\n this.subscriptionPending = false;\n }\n\n /** Handles a PusherEvent. For internal use only.\n *\n * @param {PusherEvent} event\n */\n handleEvent(event: PusherEvent) {\n var eventName = event.event;\n var data = event.data;\n if (eventName === 'pusher_internal:subscription_succeeded') {\n this.handleSubscriptionSucceededEvent(event);\n } else if (eventName === 'pusher_internal:subscription_count') {\n this.handleSubscriptionCountEvent(event);\n } else if (eventName.indexOf('pusher_internal:') !== 0) {\n var metadata: Metadata = {};\n this.emit(eventName, data, metadata);\n }\n }\n\n handleSubscriptionSucceededEvent(event: PusherEvent) {\n this.subscriptionPending = false;\n this.subscribed = true;\n if (this.subscriptionCancelled) {\n this.pusher.unsubscribe(this.name);\n } else {\n this.emit('pusher:subscription_succeeded', event.data);\n }\n }\n\n handleSubscriptionCountEvent(event: PusherEvent) {\n if (event.data.subscription_count) {\n this.subscriptionCount = event.data.subscription_count;\n }\n\n this.emit('pusher:subscription_count', event.data);\n }\n\n /** Sends a subscription request. For internal use only. */\n subscribe() {\n if (this.subscribed) {\n return;\n }\n this.subscriptionPending = true;\n this.subscriptionCancelled = false;\n this.authorize(\n this.pusher.connection.socket_id,\n (error: Error | null, data: ChannelAuthorizationData) => {\n if (error) {\n this.subscriptionPending = false;\n // Why not bind to 'pusher:subscription_error' a level up, and log there?\n // Binding to this event would cause the warning about no callbacks being\n // bound (see constructor) to be suppressed, that's not what we want.\n Logger.error(error.toString());\n this.emit(\n 'pusher:subscription_error',\n Object.assign(\n {},\n {\n type: 'AuthError',\n error: error.message\n },\n error instanceof HTTPAuthError ? { status: error.status } : {}\n )\n );\n } else {\n this.pusher.send_event('pusher:subscribe', {\n auth: data.auth,\n channel_data: data.channel_data,\n channel: this.name\n });\n }\n }\n );\n }\n\n /** Sends an unsubscription request. For internal use only. */\n unsubscribe() {\n this.subscribed = false;\n this.pusher.send_event('pusher:unsubscribe', {\n channel: this.name\n });\n }\n\n /** Cancels an in progress subscription. For internal use only. */\n cancelSubscription() {\n this.subscriptionCancelled = true;\n }\n\n /** Reinstates an in progress subscripiton. For internal use only. */\n reinstateSubscription() {\n this.subscriptionCancelled = false;\n }\n}\n","import Factory from '../utils/factory';\nimport Channel from './channel';\nimport { ChannelAuthorizationCallback } from '../auth/options';\n\n/** Extends public channels to provide private channel interface.\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\nexport default class PrivateChannel extends Channel {\n /** Authorizes the connection to use the channel.\n *\n * @param {String} socketId\n * @param {Function} callback\n */\n authorize(socketId: string, callback: ChannelAuthorizationCallback) {\n return this.pusher.config.channelAuthorizer(\n {\n channelName: this.name,\n socketId: socketId\n },\n callback\n );\n }\n}\n","import * as Collections from '../utils/collections';\n\n/** Represents a collection of members of a presence channel. */\nexport default class Members {\n members: any;\n count: number;\n myID: any;\n me: any;\n\n constructor() {\n this.reset();\n }\n\n /** Returns member's info for given id.\n *\n * Resulting object containts two fields - id and info.\n *\n * @param {Number} id\n * @return {Object} member's info or null\n */\n get(id: string): any {\n if (Object.prototype.hasOwnProperty.call(this.members, id)) {\n return {\n id: id,\n info: this.members[id]\n };\n } else {\n return null;\n }\n }\n\n /** Calls back for each member in unspecified order.\n *\n * @param {Function} callback\n */\n each(callback: Function) {\n Collections.objectApply(this.members, (member, id) => {\n callback(this.get(id));\n });\n }\n\n /** Updates the id for connected member. For internal use only. */\n setMyID(id: string) {\n this.myID = id;\n }\n\n /** Handles subscription data. For internal use only. */\n onSubscription(subscriptionData: any) {\n this.members = subscriptionData.presence.hash;\n this.count = subscriptionData.presence.count;\n this.me = this.get(this.myID);\n }\n\n /** Adds a new member to the collection. For internal use only. */\n addMember(memberData: any) {\n if (this.get(memberData.user_id) === null) {\n this.count++;\n }\n this.members[memberData.user_id] = memberData.user_info;\n return this.get(memberData.user_id);\n }\n\n /** Adds a member from the collection. For internal use only. */\n removeMember(memberData: any) {\n var member = this.get(memberData.user_id);\n if (member) {\n delete this.members[memberData.user_id];\n this.count--;\n }\n return member;\n }\n\n /** Resets the collection to the initial state. For internal use only. */\n reset() {\n this.members = {};\n this.count = 0;\n this.myID = null;\n this.me = null;\n }\n}\n","import PrivateChannel from './private_channel';\nimport Logger from '../logger';\nimport Members from './members';\nimport Pusher from '../pusher';\nimport UrlStore from 'core/utils/url_store';\nimport { PusherEvent } from '../connection/protocol/message-types';\nimport Metadata from './metadata';\nimport { ChannelAuthorizationData } from '../auth/options';\n\nexport default class PresenceChannel extends PrivateChannel {\n members: Members;\n\n /** Adds presence channel functionality to private channels.\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\n constructor(name: string, pusher: Pusher) {\n super(name, pusher);\n this.members = new Members();\n }\n\n /** Authorizes the connection as a member of the channel.\n *\n * @param {String} socketId\n * @param {Function} callback\n */\n authorize(socketId: string, callback: Function) {\n super.authorize(socketId, async (error, authData) => {\n if (!error) {\n authData = authData as ChannelAuthorizationData;\n if (authData.channel_data != null) {\n var channelData = JSON.parse(authData.channel_data);\n this.members.setMyID(channelData.user_id);\n } else {\n await this.pusher.user.signinDonePromise;\n if (this.pusher.user.user_data != null) {\n // If the user is signed in, get the id of the authenticated user\n // and allow the presence authorization to continue.\n this.members.setMyID(this.pusher.user.user_data.id);\n } else {\n let suffix = UrlStore.buildLogSuffix('authorizationEndpoint');\n Logger.error(\n `Invalid auth response for channel '${this.name}', ` +\n `expected 'channel_data' field. ${suffix}, ` +\n `or the user should be signed in.`\n );\n callback('Invalid auth response');\n return;\n }\n }\n }\n callback(error, authData);\n });\n }\n\n /** Handles presence and subscription events. For internal use only.\n *\n * @param {PusherEvent} event\n */\n handleEvent(event: PusherEvent) {\n var eventName = event.event;\n if (eventName.indexOf('pusher_internal:') === 0) {\n this.handleInternalEvent(event);\n } else {\n var data = event.data;\n var metadata: Metadata = {};\n if (event.user_id) {\n metadata.user_id = event.user_id;\n }\n this.emit(eventName, data, metadata);\n }\n }\n handleInternalEvent(event: PusherEvent) {\n var eventName = event.event;\n var data = event.data;\n switch (eventName) {\n case 'pusher_internal:subscription_succeeded':\n this.handleSubscriptionSucceededEvent(event);\n break;\n case 'pusher_internal:subscription_count':\n this.handleSubscriptionCountEvent(event);\n break;\n case 'pusher_internal:member_added':\n var addedMember = this.members.addMember(data);\n this.emit('pusher:member_added', addedMember);\n break;\n case 'pusher_internal:member_removed':\n var removedMember = this.members.removeMember(data);\n if (removedMember) {\n this.emit('pusher:member_removed', removedMember);\n }\n break;\n }\n }\n\n handleSubscriptionSucceededEvent(event: PusherEvent) {\n this.subscriptionPending = false;\n this.subscribed = true;\n if (this.subscriptionCancelled) {\n this.pusher.unsubscribe(this.name);\n } else {\n this.members.onSubscription(event.data);\n this.emit('pusher:subscription_succeeded', this.members);\n }\n }\n\n /** Resets the channel state, including members map. For internal use only. */\n disconnect() {\n this.members.reset();\n super.disconnect();\n }\n}\n","import PrivateChannel from './private_channel';\nimport * as Errors from '../errors';\nimport Logger from '../logger';\nimport Pusher from '../pusher';\nimport { decode as encodeUTF8 } from '@stablelib/utf8';\nimport { decode as decodeBase64 } from '@stablelib/base64';\nimport Dispatcher from '../events/dispatcher';\nimport { PusherEvent } from '../connection/protocol/message-types';\nimport {\n ChannelAuthorizationData,\n ChannelAuthorizationCallback\n} from '../auth/options';\nimport * as nacl from 'tweetnacl';\n\n/** Extends private channels to provide encrypted channel interface.\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\nexport default class EncryptedChannel extends PrivateChannel {\n key: Uint8Array = null;\n nacl: nacl;\n\n constructor(name: string, pusher: Pusher, nacl: nacl) {\n super(name, pusher);\n this.nacl = nacl;\n }\n\n /** Authorizes the connection to use the channel.\n *\n * @param {String} socketId\n * @param {Function} callback\n */\n authorize(socketId: string, callback: ChannelAuthorizationCallback) {\n super.authorize(\n socketId,\n (error: Error | null, authData: ChannelAuthorizationData) => {\n if (error) {\n callback(error, authData);\n return;\n }\n let sharedSecret = authData['shared_secret'];\n if (!sharedSecret) {\n callback(\n new Error(\n `No shared_secret key in auth payload for encrypted channel: ${this.name}`\n ),\n null\n );\n return;\n }\n this.key = decodeBase64(sharedSecret);\n delete authData['shared_secret'];\n callback(null, authData);\n }\n );\n }\n\n trigger(event: string, data: any): boolean {\n throw new Errors.UnsupportedFeature(\n 'Client events are not currently supported for encrypted channels'\n );\n }\n\n /** Handles an event. For internal use only.\n *\n * @param {PusherEvent} event\n */\n handleEvent(event: PusherEvent) {\n var eventName = event.event;\n var data = event.data;\n if (\n eventName.indexOf('pusher_internal:') === 0 ||\n eventName.indexOf('pusher:') === 0\n ) {\n super.handleEvent(event);\n return;\n }\n this.handleEncryptedEvent(eventName, data);\n }\n\n private handleEncryptedEvent(event: string, data: any): void {\n if (!this.key) {\n Logger.debug(\n 'Received encrypted event before key has been retrieved from the authEndpoint'\n );\n return;\n }\n if (!data.ciphertext || !data.nonce) {\n Logger.error(\n 'Unexpected format for encrypted event, expected object with `ciphertext` and `nonce` fields, got: ' +\n data\n );\n return;\n }\n let cipherText = decodeBase64(data.ciphertext);\n if (cipherText.length < this.nacl.secretbox.overheadLength) {\n Logger.error(\n `Expected encrypted event ciphertext length to be ${this.nacl.secretbox.overheadLength}, got: ${cipherText.length}`\n );\n return;\n }\n let nonce = decodeBase64(data.nonce);\n if (nonce.length < this.nacl.secretbox.nonceLength) {\n Logger.error(\n `Expected encrypted event nonce length to be ${this.nacl.secretbox.nonceLength}, got: ${nonce.length}`\n );\n return;\n }\n\n let bytes = this.nacl.secretbox.open(cipherText, nonce, this.key);\n if (bytes === null) {\n Logger.debug(\n 'Failed to decrypt an event, probably because it was encrypted with a different key. Fetching a new key from the authEndpoint...'\n );\n // Try a single time to retrieve a new auth key and decrypt the event with it\n // If this fails, a new key will be requested when a new message is received\n this.authorize(this.pusher.connection.socket_id, (error, authData) => {\n if (error) {\n Logger.error(\n `Failed to make a request to the authEndpoint: ${authData}. Unable to fetch new key, so dropping encrypted event`\n );\n return;\n }\n bytes = this.nacl.secretbox.open(cipherText, nonce, this.key);\n if (bytes === null) {\n Logger.error(\n `Failed to decrypt event with new key. Dropping encrypted event`\n );\n return;\n }\n this.emit(event, this.getDataToEmit(bytes));\n return;\n });\n return;\n }\n this.emit(event, this.getDataToEmit(bytes));\n }\n\n // Try and parse the decrypted bytes as JSON. If we can't parse it, just\n // return the utf-8 string\n getDataToEmit(bytes: Uint8Array): string {\n let raw = encodeUTF8(bytes);\n try {\n return JSON.parse(raw);\n } catch {\n return raw;\n }\n }\n}\n","import { default as EventsDispatcher } from '../events/dispatcher';\nimport { OneOffTimer as Timer } from '../utils/timers';\nimport { Config } from '../config';\nimport Logger from '../logger';\nimport HandshakePayload from './handshake/handshake_payload';\nimport Connection from './connection';\nimport Strategy from '../strategies/strategy';\nimport StrategyRunner from '../strategies/strategy_runner';\nimport * as Collections from '../utils/collections';\nimport Timeline from '../timeline/timeline';\nimport ConnectionManagerOptions from './connection_manager_options';\nimport Runtime from 'runtime';\n\nimport {\n ErrorCallbacks,\n HandshakeCallbacks,\n ConnectionCallbacks\n} from './callbacks';\nimport Action from './protocol/action';\n\n/** Manages connection to Pusher.\n *\n * Uses a strategy (currently only default), timers and network availability\n * info to establish a connection and export its state. In case of failures,\n * manages reconnection attempts.\n *\n * Exports state changes as following events:\n * - \"state_change\", { previous: p, current: state }\n * - state\n *\n * States:\n * - initialized - initial state, never transitioned to\n * - connecting - connection is being established\n * - connected - connection has been fully established\n * - disconnected - on requested disconnection\n * - unavailable - after connection timeout or when there's no network\n * - failed - when the connection strategy is not supported\n *\n * Options:\n * - unavailableTimeout - time to transition to unavailable state\n * - activityTimeout - time after which ping message should be sent\n * - pongTimeout - time for Pusher to respond with pong before reconnecting\n *\n * @param {String} key application key\n * @param {Object} options\n */\nexport default class ConnectionManager extends EventsDispatcher {\n key: string;\n options: ConnectionManagerOptions;\n state: string;\n connection: Connection;\n usingTLS: boolean;\n timeline: Timeline;\n socket_id: string;\n unavailableTimer: Timer;\n activityTimer: Timer;\n retryTimer: Timer;\n activityTimeout: number;\n strategy: Strategy;\n runner: StrategyRunner;\n errorCallbacks: ErrorCallbacks;\n handshakeCallbacks: HandshakeCallbacks;\n connectionCallbacks: ConnectionCallbacks;\n\n constructor(key: string, options: ConnectionManagerOptions) {\n super();\n this.state = 'initialized';\n this.connection = null;\n\n this.key = key;\n this.options = options;\n this.timeline = this.options.timeline;\n this.usingTLS = this.options.useTLS;\n\n this.errorCallbacks = this.buildErrorCallbacks();\n this.connectionCallbacks = this.buildConnectionCallbacks(\n this.errorCallbacks\n );\n this.handshakeCallbacks = this.buildHandshakeCallbacks(this.errorCallbacks);\n\n var Network = Runtime.getNetwork();\n\n Network.bind('online', () => {\n this.timeline.info({ netinfo: 'online' });\n if (this.state === 'connecting' || this.state === 'unavailable') {\n this.retryIn(0);\n }\n });\n Network.bind('offline', () => {\n this.timeline.info({ netinfo: 'offline' });\n if (this.connection) {\n this.sendActivityCheck();\n }\n });\n\n this.updateStrategy();\n }\n\n switchCluster(key: string) {\n this.key = key;\n // This ensures that the new config coming from\n // pusher instance are taken into account\n // such as appKey and cluster\n this.updateStrategy();\n this.retryIn(0);\n }\n\n /** Establishes a connection to Pusher.\n *\n * Does nothing when connection is already established. See top-level doc\n * to find events emitted on connection attempts.\n */\n connect() {\n if (this.connection || this.runner) {\n return;\n }\n if (!this.strategy.isSupported()) {\n this.updateState('failed');\n return;\n }\n this.updateState('connecting');\n this.startConnecting();\n this.setUnavailableTimer();\n }\n\n /** Sends raw data.\n *\n * @param {String} data\n */\n send(data) {\n if (this.connection) {\n return this.connection.send(data);\n } else {\n return false;\n }\n }\n\n /** Sends an event.\n *\n * @param {String} name\n * @param {String} data\n * @param {String} [channel]\n * @returns {Boolean} whether message was sent or not\n */\n send_event(name: string, data: any, channel?: string) {\n if (this.connection) {\n return this.connection.send_event(name, data, channel);\n } else {\n return false;\n }\n }\n\n /** Closes the connection. */\n disconnect() {\n this.disconnectInternally();\n this.updateState('disconnected');\n }\n\n isUsingTLS() {\n return this.usingTLS;\n }\n\n private startConnecting() {\n var callback = (error, handshake) => {\n if (error) {\n this.runner = this.strategy.connect(0, callback);\n } else {\n if (handshake.action === 'error') {\n this.emit('error', {\n type: 'HandshakeError',\n error: handshake.error\n });\n this.timeline.error({ handshakeError: handshake.error });\n } else {\n this.abortConnecting(); // we don't support switching connections yet\n this.handshakeCallbacks[handshake.action](handshake);\n }\n }\n };\n this.runner = this.strategy.connect(0, callback);\n }\n\n private abortConnecting() {\n if (this.runner) {\n this.runner.abort();\n this.runner = null;\n }\n }\n\n private disconnectInternally() {\n this.abortConnecting();\n this.clearRetryTimer();\n this.clearUnavailableTimer();\n if (this.connection) {\n var connection = this.abandonConnection();\n connection.close();\n }\n }\n\n private updateStrategy() {\n this.strategy = this.options.getStrategy({\n key: this.key,\n timeline: this.timeline,\n useTLS: this.usingTLS\n });\n }\n\n private retryIn(delay) {\n this.timeline.info({ action: 'retry', delay: delay });\n if (delay > 0) {\n this.emit('connecting_in', Math.round(delay / 1000));\n }\n this.retryTimer = new Timer(delay || 0, () => {\n this.disconnectInternally();\n this.connect();\n });\n }\n\n private clearRetryTimer() {\n if (this.retryTimer) {\n this.retryTimer.ensureAborted();\n this.retryTimer = null;\n }\n }\n\n private setUnavailableTimer() {\n this.unavailableTimer = new Timer(this.options.unavailableTimeout, () => {\n this.updateState('unavailable');\n });\n }\n\n private clearUnavailableTimer() {\n if (this.unavailableTimer) {\n this.unavailableTimer.ensureAborted();\n }\n }\n\n private sendActivityCheck() {\n this.stopActivityCheck();\n this.connection.ping();\n // wait for pong response\n this.activityTimer = new Timer(this.options.pongTimeout, () => {\n this.timeline.error({ pong_timed_out: this.options.pongTimeout });\n this.retryIn(0);\n });\n }\n\n private resetActivityCheck() {\n this.stopActivityCheck();\n // send ping after inactivity\n if (this.connection && !this.connection.handlesActivityChecks()) {\n this.activityTimer = new Timer(this.activityTimeout, () => {\n this.sendActivityCheck();\n });\n }\n }\n\n private stopActivityCheck() {\n if (this.activityTimer) {\n this.activityTimer.ensureAborted();\n }\n }\n\n private buildConnectionCallbacks(\n errorCallbacks: ErrorCallbacks\n ): ConnectionCallbacks {\n return Collections.extend({}, errorCallbacks, {\n message: message => {\n // includes pong messages from server\n this.resetActivityCheck();\n this.emit('message', message);\n },\n ping: () => {\n this.send_event('pusher:pong', {});\n },\n activity: () => {\n this.resetActivityCheck();\n },\n error: error => {\n // just emit error to user - socket will already be closed by browser\n this.emit('error', error);\n },\n closed: () => {\n this.abandonConnection();\n if (this.shouldRetry()) {\n this.retryIn(1000);\n }\n }\n });\n }\n\n private buildHandshakeCallbacks(\n errorCallbacks: ErrorCallbacks\n ): HandshakeCallbacks {\n return Collections.extend({}, errorCallbacks, {\n connected: (handshake: HandshakePayload) => {\n this.activityTimeout = Math.min(\n this.options.activityTimeout,\n handshake.activityTimeout,\n handshake.connection.activityTimeout || Infinity\n );\n this.clearUnavailableTimer();\n this.setConnection(handshake.connection);\n this.socket_id = this.connection.id;\n this.updateState('connected', { socket_id: this.socket_id });\n }\n });\n }\n\n private buildErrorCallbacks(): ErrorCallbacks {\n let withErrorEmitted = callback => {\n return (result: Action | HandshakePayload) => {\n if (result.error) {\n this.emit('error', { type: 'WebSocketError', error: result.error });\n }\n callback(result);\n };\n };\n\n return {\n tls_only: withErrorEmitted(() => {\n this.usingTLS = true;\n this.updateStrategy();\n this.retryIn(0);\n }),\n refused: withErrorEmitted(() => {\n this.disconnect();\n }),\n backoff: withErrorEmitted(() => {\n this.retryIn(1000);\n }),\n retry: withErrorEmitted(() => {\n this.retryIn(0);\n })\n };\n }\n\n private setConnection(connection) {\n this.connection = connection;\n for (var event in this.connectionCallbacks) {\n this.connection.bind(event, this.connectionCallbacks[event]);\n }\n this.resetActivityCheck();\n }\n\n private abandonConnection() {\n if (!this.connection) {\n return;\n }\n this.stopActivityCheck();\n for (var event in this.connectionCallbacks) {\n this.connection.unbind(event, this.connectionCallbacks[event]);\n }\n var connection = this.connection;\n this.connection = null;\n return connection;\n }\n\n private updateState(newState: string, data?: any) {\n var previousState = this.state;\n this.state = newState;\n if (previousState !== newState) {\n var newStateDescription = newState;\n if (newStateDescription === 'connected') {\n newStateDescription += ' with new socket ID ' + data.socket_id;\n }\n Logger.debug(\n 'State changed',\n previousState + ' -> ' + newStateDescription\n );\n this.timeline.info({ state: newState, params: data });\n this.emit('state_change', { previous: previousState, current: newState });\n this.emit(newState, data);\n }\n }\n\n private shouldRetry(): boolean {\n return this.state === 'connecting' || this.state === 'connected';\n }\n}\n","import Channel from './channel';\nimport * as Collections from '../utils/collections';\nimport ChannelTable from './channel_table';\nimport Factory from '../utils/factory';\nimport Pusher from '../pusher';\nimport Logger from '../logger';\nimport * as Errors from '../errors';\nimport urlStore from '../utils/url_store';\n\n/** Handles a channel map. */\nexport default class Channels {\n channels: ChannelTable;\n\n constructor() {\n this.channels = {};\n }\n\n /** Creates or retrieves an existing channel by its name.\n *\n * @param {String} name\n * @param {Pusher} pusher\n * @return {Channel}\n */\n add(name: string, pusher: Pusher) {\n if (!this.channels[name]) {\n this.channels[name] = createChannel(name, pusher);\n }\n return this.channels[name];\n }\n\n /** Returns a list of all channels\n *\n * @return {Array}\n */\n all(): Channel[] {\n return Collections.values(this.channels);\n }\n\n /** Finds a channel by its name.\n *\n * @param {String} name\n * @return {Channel} channel or null if it doesn't exist\n */\n find(name: string) {\n return this.channels[name];\n }\n\n /** Removes a channel from the map.\n *\n * @param {String} name\n */\n remove(name: string) {\n var channel = this.channels[name];\n delete this.channels[name];\n return channel;\n }\n\n /** Proxies disconnection signal to all channels. */\n disconnect() {\n Collections.objectApply(this.channels, function(channel) {\n channel.disconnect();\n });\n }\n}\n\nfunction createChannel(name: string, pusher: Pusher): Channel {\n if (name.indexOf('private-encrypted-') === 0) {\n if (pusher.config.nacl) {\n return Factory.createEncryptedChannel(name, pusher, pusher.config.nacl);\n }\n let errMsg =\n 'Tried to subscribe to a private-encrypted- channel but no nacl implementation available';\n let suffix = urlStore.buildLogSuffix('encryptedChannelSupport');\n throw new Errors.UnsupportedFeature(`${errMsg}. ${suffix}`);\n } else if (name.indexOf('private-') === 0) {\n return Factory.createPrivateChannel(name, pusher);\n } else if (name.indexOf('presence-') === 0) {\n return Factory.createPresenceChannel(name, pusher);\n } else if (name.indexOf('#') === 0) {\n throw new Errors.BadChannelName(\n 'Cannot create a channel with name \"' + name + '\".'\n );\n } else {\n return Factory.createChannel(name, pusher);\n }\n}\n","import AssistantToTheTransportManager from '../transports/assistant_to_the_transport_manager';\nimport PingDelayOptions from '../transports/ping_delay_options';\nimport Transport from '../transports/transport';\nimport TransportManager from '../transports/transport_manager';\nimport Handshake from '../connection/handshake';\nimport TransportConnection from '../transports/transport_connection';\nimport SocketHooks from '../http/socket_hooks';\nimport HTTPSocket from '../http/http_socket';\n\nimport Timeline from '../timeline/timeline';\nimport {\n default as TimelineSender,\n TimelineSenderOptions\n} from '../timeline/timeline_sender';\nimport PresenceChannel from '../channels/presence_channel';\nimport PrivateChannel from '../channels/private_channel';\nimport EncryptedChannel from '../channels/encrypted_channel';\nimport Channel from '../channels/channel';\nimport ConnectionManager from '../connection/connection_manager';\nimport ConnectionManagerOptions from '../connection/connection_manager_options';\nimport Ajax from '../http/ajax';\nimport Channels from '../channels/channels';\nimport Pusher from '../pusher';\nimport { Config } from '../config';\nimport * as nacl from 'tweetnacl';\n\nvar Factory = {\n createChannels(): Channels {\n return new Channels();\n },\n\n createConnectionManager(\n key: string,\n options: ConnectionManagerOptions\n ): ConnectionManager {\n return new ConnectionManager(key, options);\n },\n\n createChannel(name: string, pusher: Pusher): Channel {\n return new Channel(name, pusher);\n },\n\n createPrivateChannel(name: string, pusher: Pusher): PrivateChannel {\n return new PrivateChannel(name, pusher);\n },\n\n createPresenceChannel(name: string, pusher: Pusher): PresenceChannel {\n return new PresenceChannel(name, pusher);\n },\n\n createEncryptedChannel(\n name: string,\n pusher: Pusher,\n nacl: nacl\n ): EncryptedChannel {\n return new EncryptedChannel(name, pusher, nacl);\n },\n\n createTimelineSender(timeline: Timeline, options: TimelineSenderOptions) {\n return new TimelineSender(timeline, options);\n },\n\n createHandshake(\n transport: TransportConnection,\n callback: (HandshakePayload) => void\n ): Handshake {\n return new Handshake(transport, callback);\n },\n\n createAssistantToTheTransportManager(\n manager: TransportManager,\n transport: Transport,\n options: PingDelayOptions\n ): AssistantToTheTransportManager {\n return new AssistantToTheTransportManager(manager, transport, options);\n }\n};\n\nexport default Factory;\n","import AssistantToTheTransportManager from './assistant_to_the_transport_manager';\nimport Transport from './transport';\nimport PingDelayOptions from './ping_delay_options';\nimport Factory from '../utils/factory';\n\nexport interface TransportManagerOptions extends PingDelayOptions {\n lives?: number;\n}\n\n/** Keeps track of the number of lives left for a transport.\n *\n * In the beginning of a session, transports may be assigned a number of\n * lives. When an AssistantToTheTransportManager instance reports a transport\n * connection closed uncleanly, the transport loses a life. When the number\n * of lives drops to zero, the transport gets disabled by its manager.\n *\n * @param {Object} options\n */\nexport default class TransportManager {\n options: TransportManagerOptions;\n livesLeft: number;\n\n constructor(options: TransportManagerOptions) {\n this.options = options || {};\n this.livesLeft = this.options.lives || Infinity;\n }\n\n /** Creates a assistant for the transport.\n *\n * @param {Transport} transport\n * @returns {AssistantToTheTransportManager}\n */\n getAssistant(transport: Transport): AssistantToTheTransportManager {\n return Factory.createAssistantToTheTransportManager(this, transport, {\n minPingDelay: this.options.minPingDelay,\n maxPingDelay: this.options.maxPingDelay\n });\n }\n\n /** Returns whether the transport has any lives left.\n *\n * @returns {Boolean}\n */\n isAlive(): boolean {\n return this.livesLeft > 0;\n }\n\n /** Takes one life from the transport. */\n reportDeath() {\n this.livesLeft -= 1;\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport { OneOffTimer as Timer } from '../utils/timers';\nimport Strategy from './strategy';\nimport StrategyOptions from './strategy_options';\n\n/** Loops through strategies with optional timeouts.\n *\n * Options:\n * - loop - whether it should loop through the substrategy list\n * - timeout - initial timeout for a single substrategy\n * - timeoutLimit - maximum timeout\n *\n * @param {Strategy[]} strategies\n * @param {Object} options\n */\nexport default class SequentialStrategy implements Strategy {\n strategies: Strategy[];\n loop: boolean;\n failFast: boolean;\n timeout: number;\n timeoutLimit: number;\n\n constructor(strategies: Strategy[], options: StrategyOptions) {\n this.strategies = strategies;\n this.loop = Boolean(options.loop);\n this.failFast = Boolean(options.failFast);\n this.timeout = options.timeout;\n this.timeoutLimit = options.timeoutLimit;\n }\n\n isSupported(): boolean {\n return Collections.any(this.strategies, Util.method('isSupported'));\n }\n\n connect(minPriority: number, callback: Function) {\n var strategies = this.strategies;\n var current = 0;\n var timeout = this.timeout;\n var runner = null;\n\n var tryNextStrategy = (error, handshake) => {\n if (handshake) {\n callback(null, handshake);\n } else {\n current = current + 1;\n if (this.loop) {\n current = current % strategies.length;\n }\n\n if (current < strategies.length) {\n if (timeout) {\n timeout = timeout * 2;\n if (this.timeoutLimit) {\n timeout = Math.min(timeout, this.timeoutLimit);\n }\n }\n runner = this.tryStrategy(\n strategies[current],\n minPriority,\n { timeout, failFast: this.failFast },\n tryNextStrategy\n );\n } else {\n callback(true);\n }\n }\n };\n\n runner = this.tryStrategy(\n strategies[current],\n minPriority,\n { timeout: timeout, failFast: this.failFast },\n tryNextStrategy\n );\n\n return {\n abort: function() {\n runner.abort();\n },\n forceMinPriority: function(p) {\n minPriority = p;\n if (runner) {\n runner.forceMinPriority(p);\n }\n }\n };\n }\n\n private tryStrategy(\n strategy: Strategy,\n minPriority: number,\n options: StrategyOptions,\n callback: Function\n ) {\n var timer = null;\n var runner = null;\n\n if (options.timeout > 0) {\n timer = new Timer(options.timeout, function() {\n runner.abort();\n callback(true);\n });\n }\n\n runner = strategy.connect(minPriority, function(error, handshake) {\n if (error && timer && timer.isRunning() && !options.failFast) {\n // advance to the next strategy after the timeout\n return;\n }\n if (timer) {\n timer.ensureAborted();\n }\n callback(error, handshake);\n });\n\n return {\n abort: function() {\n if (timer) {\n timer.ensureAborted();\n }\n runner.abort();\n },\n forceMinPriority: function(p) {\n runner.forceMinPriority(p);\n }\n };\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport Strategy from './strategy';\n\n/** Launches all substrategies and emits prioritized connected transports.\n *\n * @param {Array} strategies\n */\nexport default class BestConnectedEverStrategy implements Strategy {\n strategies: Strategy[];\n\n constructor(strategies: Strategy[]) {\n this.strategies = strategies;\n }\n\n isSupported(): boolean {\n return Collections.any(this.strategies, Util.method('isSupported'));\n }\n\n connect(minPriority: number, callback: Function) {\n return connect(this.strategies, minPriority, function(i, runners) {\n return function(error, handshake) {\n runners[i].error = error;\n if (error) {\n if (allRunnersFailed(runners)) {\n callback(true);\n }\n return;\n }\n Collections.apply(runners, function(runner) {\n runner.forceMinPriority(handshake.transport.priority);\n });\n callback(null, handshake);\n };\n });\n }\n}\n\n/** Connects to all strategies in parallel.\n *\n * Callback builder should be a function that takes two arguments: index\n * and a list of runners. It should return another function that will be\n * passed to the substrategy with given index. Runners can be aborted using\n * abortRunner(s) functions from this class.\n *\n * @param {Array} strategies\n * @param {Function} callbackBuilder\n * @return {Object} strategy runner\n */\nfunction connect(\n strategies: Strategy[],\n minPriority: number,\n callbackBuilder: Function\n) {\n var runners = Collections.map(strategies, function(strategy, i, _, rs) {\n return strategy.connect(minPriority, callbackBuilder(i, rs));\n });\n return {\n abort: function() {\n Collections.apply(runners, abortRunner);\n },\n forceMinPriority: function(p) {\n Collections.apply(runners, function(runner) {\n runner.forceMinPriority(p);\n });\n }\n };\n}\n\nfunction allRunnersFailed(runners): boolean {\n return Collections.all(runners, function(runner) {\n return Boolean(runner.error);\n });\n}\n\nfunction abortRunner(runner) {\n if (!runner.error && !runner.aborted) {\n runner.abort();\n runner.aborted = true;\n }\n}\n","import Util from '../util';\nimport Runtime from 'runtime';\nimport Strategy from './strategy';\nimport SequentialStrategy from './sequential_strategy';\nimport StrategyOptions from './strategy_options';\nimport TransportStrategy from './transport_strategy';\nimport Timeline from '../timeline/timeline';\nimport * as Collections from '../utils/collections';\n\nexport interface TransportStrategyDictionary {\n [key: string]: TransportStrategy;\n}\n\n/** Caches the last successful transport and, after the first few attempts,\n * uses the cached transport for subsequent attempts.\n *\n * @param {Strategy} strategy\n * @param {Object} transports\n * @param {Object} options\n */\nexport default class WebSocketPrioritizedCachedStrategy implements Strategy {\n strategy: Strategy;\n transports: TransportStrategyDictionary;\n ttl: number;\n usingTLS: boolean;\n timeline: Timeline;\n\n constructor(\n strategy: Strategy,\n transports: TransportStrategyDictionary,\n options: StrategyOptions\n ) {\n this.strategy = strategy;\n this.transports = transports;\n this.ttl = options.ttl || 1800 * 1000;\n this.usingTLS = options.useTLS;\n this.timeline = options.timeline;\n }\n\n isSupported(): boolean {\n return this.strategy.isSupported();\n }\n\n connect(minPriority: number, callback: Function) {\n var usingTLS = this.usingTLS;\n var info = fetchTransportCache(usingTLS);\n var cacheSkipCount = info && info.cacheSkipCount ? info.cacheSkipCount : 0;\n\n var strategies = [this.strategy];\n if (info && info.timestamp + this.ttl >= Util.now()) {\n var transport = this.transports[info.transport];\n if (transport) {\n if (['ws', 'wss'].includes(info.transport) || cacheSkipCount > 3) {\n this.timeline.info({\n cached: true,\n transport: info.transport,\n latency: info.latency\n });\n strategies.push(\n new SequentialStrategy([transport], {\n timeout: info.latency * 2 + 1000,\n failFast: true\n })\n );\n } else {\n cacheSkipCount++;\n }\n }\n }\n\n var startTimestamp = Util.now();\n var runner = strategies\n .pop()\n .connect(minPriority, function cb(error, handshake) {\n if (error) {\n flushTransportCache(usingTLS);\n if (strategies.length > 0) {\n startTimestamp = Util.now();\n runner = strategies.pop().connect(minPriority, cb);\n } else {\n callback(error);\n }\n } else {\n storeTransportCache(\n usingTLS,\n handshake.transport.name,\n Util.now() - startTimestamp,\n cacheSkipCount\n );\n callback(null, handshake);\n }\n });\n\n return {\n abort: function() {\n runner.abort();\n },\n forceMinPriority: function(p) {\n minPriority = p;\n if (runner) {\n runner.forceMinPriority(p);\n }\n }\n };\n }\n}\n\nfunction getTransportCacheKey(usingTLS: boolean): string {\n return 'pusherTransport' + (usingTLS ? 'TLS' : 'NonTLS');\n}\n\nfunction fetchTransportCache(usingTLS: boolean): any {\n var storage = Runtime.getLocalStorage();\n if (storage) {\n try {\n var serializedCache = storage[getTransportCacheKey(usingTLS)];\n if (serializedCache) {\n return JSON.parse(serializedCache);\n }\n } catch (e) {\n flushTransportCache(usingTLS);\n }\n }\n return null;\n}\n\nfunction storeTransportCache(\n usingTLS: boolean,\n transport: TransportStrategy,\n latency: number,\n cacheSkipCount: number\n) {\n var storage = Runtime.getLocalStorage();\n if (storage) {\n try {\n storage[getTransportCacheKey(usingTLS)] = Collections.safeJSONStringify({\n timestamp: Util.now(),\n transport: transport,\n latency: latency,\n cacheSkipCount: cacheSkipCount\n });\n } catch (e) {\n // catch over quota exceptions raised by localStorage\n }\n }\n}\n\nfunction flushTransportCache(usingTLS: boolean) {\n var storage = Runtime.getLocalStorage();\n if (storage) {\n try {\n delete storage[getTransportCacheKey(usingTLS)];\n } catch (e) {\n // catch exceptions raised by localStorage\n }\n }\n}\n","import { OneOffTimer as Timer } from '../utils/timers';\nimport Strategy from './strategy';\nimport StrategyOptions from './strategy_options';\n\n/** Runs substrategy after specified delay.\n *\n * Options:\n * - delay - time in miliseconds to delay the substrategy attempt\n *\n * @param {Strategy} strategy\n * @param {Object} options\n */\nexport default class DelayedStrategy implements Strategy {\n strategy: Strategy;\n options: { delay: number };\n\n constructor(strategy: Strategy, { delay: number }) {\n this.strategy = strategy;\n this.options = { delay: number };\n }\n\n isSupported(): boolean {\n return this.strategy.isSupported();\n }\n\n connect(minPriority: number, callback: Function) {\n var strategy = this.strategy;\n var runner;\n var timer = new Timer(this.options.delay, function() {\n runner = strategy.connect(minPriority, callback);\n });\n\n return {\n abort: function() {\n timer.ensureAborted();\n if (runner) {\n runner.abort();\n }\n },\n forceMinPriority: function(p) {\n minPriority = p;\n if (runner) {\n runner.forceMinPriority(p);\n }\n }\n };\n }\n}\n","import Strategy from './strategy';\nimport StrategyRunner from './strategy_runner';\n\n/** Proxies method calls to one of substrategies basing on the test function.\n *\n * @param {Function} test\n * @param {Strategy} trueBranch strategy used when test returns true\n * @param {Strategy} falseBranch strategy used when test returns false\n */\nexport default class IfStrategy implements Strategy {\n test: () => boolean;\n trueBranch: Strategy;\n falseBranch: Strategy;\n\n constructor(\n test: () => boolean,\n trueBranch: Strategy,\n falseBranch: Strategy\n ) {\n this.test = test;\n this.trueBranch = trueBranch;\n this.falseBranch = falseBranch;\n }\n\n isSupported(): boolean {\n var branch = this.test() ? this.trueBranch : this.falseBranch;\n return branch.isSupported();\n }\n\n connect(minPriority: number, callback: Function): StrategyRunner {\n var branch = this.test() ? this.trueBranch : this.falseBranch;\n return branch.connect(minPriority, callback);\n }\n}\n","import Strategy from './strategy';\nimport StrategyRunner from './strategy_runner';\n\n/** Launches the substrategy and terminates on the first open connection.\n *\n * @param {Strategy} strategy\n */\nexport default class FirstConnectedStrategy implements Strategy {\n strategy: Strategy;\n\n constructor(strategy: Strategy) {\n this.strategy = strategy;\n }\n\n isSupported(): boolean {\n return this.strategy.isSupported();\n }\n\n connect(minPriority: number, callback: Function): StrategyRunner {\n var runner = this.strategy.connect(minPriority, function(error, handshake) {\n if (handshake) {\n runner.abort();\n }\n callback(error, handshake);\n });\n return runner;\n }\n}\n","import * as Collections from 'core/utils/collections';\nimport TransportManager from 'core/transports/transport_manager';\nimport Strategy from 'core/strategies/strategy';\nimport StrategyOptions from 'core/strategies/strategy_options';\nimport SequentialStrategy from 'core/strategies/sequential_strategy';\nimport BestConnectedEverStrategy from 'core/strategies/best_connected_ever_strategy';\nimport WebSocketPrioritizedCachedStrategy, {\n TransportStrategyDictionary\n} from 'core/strategies/websocket_prioritized_cached_strategy';\nimport DelayedStrategy from 'core/strategies/delayed_strategy';\nimport IfStrategy from 'core/strategies/if_strategy';\nimport FirstConnectedStrategy from 'core/strategies/first_connected_strategy';\nimport { Config } from 'core/config';\n\nfunction testSupportsStrategy(strategy: Strategy) {\n return function() {\n return strategy.isSupported();\n };\n}\n\nvar getDefaultStrategy = function(\n config: Config,\n baseOptions: StrategyOptions,\n defineTransport: Function\n): Strategy {\n var definedTransports = {};\n\n function defineTransportStrategy(\n name: string,\n type: string,\n priority: number,\n options: StrategyOptions,\n manager?: TransportManager\n ) {\n var transport = defineTransport(\n config,\n name,\n type,\n priority,\n options,\n manager\n );\n\n definedTransports[name] = transport;\n\n return transport;\n }\n\n var ws_options: StrategyOptions = Object.assign({}, baseOptions, {\n hostNonTLS: config.wsHost + ':' + config.wsPort,\n hostTLS: config.wsHost + ':' + config.wssPort,\n httpPath: config.wsPath\n });\n var wss_options: StrategyOptions = Object.assign({}, ws_options, {\n useTLS: true\n });\n var sockjs_options: StrategyOptions = Object.assign({}, baseOptions, {\n hostNonTLS: config.httpHost + ':' + config.httpPort,\n hostTLS: config.httpHost + ':' + config.httpsPort,\n httpPath: config.httpPath\n });\n\n var timeouts = {\n loop: true,\n timeout: 15000,\n timeoutLimit: 60000\n };\n\n var ws_manager = new TransportManager({\n minPingDelay: 10000,\n maxPingDelay: config.activityTimeout\n });\n var streaming_manager = new TransportManager({\n lives: 2,\n minPingDelay: 10000,\n maxPingDelay: config.activityTimeout\n });\n\n var ws_transport = defineTransportStrategy(\n 'ws',\n 'ws',\n 3,\n ws_options,\n ws_manager\n );\n var wss_transport = defineTransportStrategy(\n 'wss',\n 'ws',\n 3,\n wss_options,\n ws_manager\n );\n var sockjs_transport = defineTransportStrategy(\n 'sockjs',\n 'sockjs',\n 1,\n sockjs_options\n );\n var xhr_streaming_transport = defineTransportStrategy(\n 'xhr_streaming',\n 'xhr_streaming',\n 1,\n sockjs_options,\n streaming_manager\n );\n var xdr_streaming_transport = defineTransportStrategy(\n 'xdr_streaming',\n 'xdr_streaming',\n 1,\n sockjs_options,\n streaming_manager\n );\n var xhr_polling_transport = defineTransportStrategy(\n 'xhr_polling',\n 'xhr_polling',\n 1,\n sockjs_options\n );\n var xdr_polling_transport = defineTransportStrategy(\n 'xdr_polling',\n 'xdr_polling',\n 1,\n sockjs_options\n );\n\n var ws_loop = new SequentialStrategy([ws_transport], timeouts);\n var wss_loop = new SequentialStrategy([wss_transport], timeouts);\n var sockjs_loop = new SequentialStrategy([sockjs_transport], timeouts);\n var streaming_loop = new SequentialStrategy(\n [\n new IfStrategy(\n testSupportsStrategy(xhr_streaming_transport),\n xhr_streaming_transport,\n xdr_streaming_transport\n )\n ],\n timeouts\n );\n var polling_loop = new SequentialStrategy(\n [\n new IfStrategy(\n testSupportsStrategy(xhr_polling_transport),\n xhr_polling_transport,\n xdr_polling_transport\n )\n ],\n timeouts\n );\n\n var http_loop = new SequentialStrategy(\n [\n new IfStrategy(\n testSupportsStrategy(streaming_loop),\n new BestConnectedEverStrategy([\n streaming_loop,\n new DelayedStrategy(polling_loop, { delay: 4000 })\n ]),\n polling_loop\n )\n ],\n timeouts\n );\n\n var http_fallback_loop = new IfStrategy(\n testSupportsStrategy(http_loop),\n http_loop,\n sockjs_loop\n );\n\n var wsStrategy;\n if (baseOptions.useTLS) {\n wsStrategy = new BestConnectedEverStrategy([\n ws_loop,\n new DelayedStrategy(http_fallback_loop, { delay: 2000 })\n ]);\n } else {\n wsStrategy = new BestConnectedEverStrategy([\n ws_loop,\n new DelayedStrategy(wss_loop, { delay: 2000 }),\n new DelayedStrategy(http_fallback_loop, { delay: 5000 })\n ]);\n }\n\n return new WebSocketPrioritizedCachedStrategy(\n new FirstConnectedStrategy(\n new IfStrategy(\n testSupportsStrategy(ws_transport),\n wsStrategy,\n http_fallback_loop\n )\n ),\n definedTransports,\n {\n ttl: 1800000,\n timeline: baseOptions.timeline,\n useTLS: baseOptions.useTLS\n }\n );\n};\n\nexport default getDefaultStrategy;\n","import HTTPRequest from 'core/http/http_request';\nimport RequestHooks from 'core/http/request_hooks';\nimport Ajax from 'core/http/ajax';\nimport * as Errors from 'core/errors';\n\nvar hooks: RequestHooks = {\n getRequest: function(socket: HTTPRequest): Ajax {\n var xdr = new (window).XDomainRequest();\n xdr.ontimeout = function() {\n socket.emit('error', new Errors.RequestTimedOut());\n socket.close();\n };\n xdr.onerror = function(e) {\n socket.emit('error', e);\n socket.close();\n };\n xdr.onprogress = function() {\n if (xdr.responseText && xdr.responseText.length > 0) {\n socket.onChunk(200, xdr.responseText);\n }\n };\n xdr.onload = function() {\n if (xdr.responseText && xdr.responseText.length > 0) {\n socket.onChunk(200, xdr.responseText);\n }\n socket.emit('finished', 200);\n socket.close();\n };\n return xdr;\n },\n abortRequest: function(xdr: Ajax) {\n xdr.ontimeout = xdr.onerror = xdr.onprogress = xdr.onload = null;\n xdr.abort();\n }\n};\n\nexport default hooks;\n","import Runtime from 'runtime';\nimport RequestHooks from './request_hooks';\nimport Ajax from './ajax';\nimport { default as EventsDispatcher } from '../events/dispatcher';\n\nconst MAX_BUFFER_LENGTH = 256 * 1024;\n\nexport default class HTTPRequest extends EventsDispatcher {\n hooks: RequestHooks;\n method: string;\n url: string;\n position: number;\n xhr: Ajax;\n unloader: Function;\n\n constructor(hooks: RequestHooks, method: string, url: string) {\n super();\n this.hooks = hooks;\n this.method = method;\n this.url = url;\n }\n\n start(payload?: any) {\n this.position = 0;\n this.xhr = this.hooks.getRequest(this);\n\n this.unloader = () => {\n this.close();\n };\n Runtime.addUnloadListener(this.unloader);\n\n this.xhr.open(this.method, this.url, true);\n\n if (this.xhr.setRequestHeader) {\n this.xhr.setRequestHeader('Content-Type', 'application/json'); // ReactNative doesn't set this header by default.\n }\n this.xhr.send(payload);\n }\n\n close() {\n if (this.unloader) {\n Runtime.removeUnloadListener(this.unloader);\n this.unloader = null;\n }\n if (this.xhr) {\n this.hooks.abortRequest(this.xhr);\n this.xhr = null;\n }\n }\n\n onChunk(status: number, data: any) {\n while (true) {\n var chunk = this.advanceBuffer(data);\n if (chunk) {\n this.emit('chunk', { status: status, data: chunk });\n } else {\n break;\n }\n }\n if (this.isBufferTooLong(data)) {\n this.emit('buffer_too_long');\n }\n }\n\n private advanceBuffer(buffer: any[]): any {\n var unreadData = buffer.slice(this.position);\n var endOfLinePosition = unreadData.indexOf('\\n');\n\n if (endOfLinePosition !== -1) {\n this.position += endOfLinePosition + 1;\n return unreadData.slice(0, endOfLinePosition);\n } else {\n // chunk is not finished yet, don't move the buffer pointer\n return null;\n }\n }\n\n private isBufferTooLong(buffer: any): boolean {\n return this.position === buffer.length && buffer.length > MAX_BUFFER_LENGTH;\n }\n}\n","enum State {\n CONNECTING = 0,\n OPEN = 1,\n CLOSED = 3\n}\n\nexport default State;\n","import URLLocation from './url_location';\nimport State from './state';\nimport Socket from '../socket';\nimport SocketHooks from './socket_hooks';\nimport Util from '../util';\nimport Ajax from './ajax';\nimport HTTPRequest from './http_request';\nimport Runtime from 'runtime';\n\nvar autoIncrement = 1;\n\nclass HTTPSocket implements Socket {\n hooks: SocketHooks;\n session: string;\n location: URLLocation;\n readyState: State;\n stream: HTTPRequest;\n\n onopen: () => void;\n onerror: (error: any) => void;\n onclose: (closeEvent: any) => void;\n onmessage: (message: any) => void;\n onactivity: () => void;\n\n constructor(hooks: SocketHooks, url: string) {\n this.hooks = hooks;\n this.session = randomNumber(1000) + '/' + randomString(8);\n this.location = getLocation(url);\n this.readyState = State.CONNECTING;\n this.openStream();\n }\n\n send(payload: any) {\n return this.sendRaw(JSON.stringify([payload]));\n }\n\n ping() {\n this.hooks.sendHeartbeat(this);\n }\n\n close(code: any, reason: any) {\n this.onClose(code, reason, true);\n }\n\n /** For internal use only */\n sendRaw(payload: any): boolean {\n if (this.readyState === State.OPEN) {\n try {\n Runtime.createSocketRequest(\n 'POST',\n getUniqueURL(getSendURL(this.location, this.session))\n ).start(payload);\n return true;\n } catch (e) {\n return false;\n }\n } else {\n return false;\n }\n }\n\n /** For internal use only */\n reconnect() {\n this.closeStream();\n this.openStream();\n }\n\n /** For internal use only */\n onClose(code, reason, wasClean) {\n this.closeStream();\n this.readyState = State.CLOSED;\n if (this.onclose) {\n this.onclose({\n code: code,\n reason: reason,\n wasClean: wasClean\n });\n }\n }\n\n private onChunk(chunk) {\n if (chunk.status !== 200) {\n return;\n }\n if (this.readyState === State.OPEN) {\n this.onActivity();\n }\n\n var payload;\n var type = chunk.data.slice(0, 1);\n switch (type) {\n case 'o':\n payload = JSON.parse(chunk.data.slice(1) || '{}');\n this.onOpen(payload);\n break;\n case 'a':\n payload = JSON.parse(chunk.data.slice(1) || '[]');\n for (var i = 0; i < payload.length; i++) {\n this.onEvent(payload[i]);\n }\n break;\n case 'm':\n payload = JSON.parse(chunk.data.slice(1) || 'null');\n this.onEvent(payload);\n break;\n case 'h':\n this.hooks.onHeartbeat(this);\n break;\n case 'c':\n payload = JSON.parse(chunk.data.slice(1) || '[]');\n this.onClose(payload[0], payload[1], true);\n break;\n }\n }\n\n private onOpen(options) {\n if (this.readyState === State.CONNECTING) {\n if (options && options.hostname) {\n this.location.base = replaceHost(this.location.base, options.hostname);\n }\n this.readyState = State.OPEN;\n\n if (this.onopen) {\n this.onopen();\n }\n } else {\n this.onClose(1006, 'Server lost session', true);\n }\n }\n\n private onEvent(event) {\n if (this.readyState === State.OPEN && this.onmessage) {\n this.onmessage({ data: event });\n }\n }\n\n private onActivity() {\n if (this.onactivity) {\n this.onactivity();\n }\n }\n\n private onError(error) {\n if (this.onerror) {\n this.onerror(error);\n }\n }\n\n private openStream() {\n this.stream = Runtime.createSocketRequest(\n 'POST',\n getUniqueURL(this.hooks.getReceiveURL(this.location, this.session))\n );\n\n this.stream.bind('chunk', chunk => {\n this.onChunk(chunk);\n });\n this.stream.bind('finished', status => {\n this.hooks.onFinished(this, status);\n });\n this.stream.bind('buffer_too_long', () => {\n this.reconnect();\n });\n\n try {\n this.stream.start();\n } catch (error) {\n Util.defer(() => {\n this.onError(error);\n this.onClose(1006, 'Could not start streaming', false);\n });\n }\n }\n\n private closeStream() {\n if (this.stream) {\n this.stream.unbind_all();\n this.stream.close();\n this.stream = null;\n }\n }\n}\n\nfunction getLocation(url): URLLocation {\n var parts = /([^\\?]*)\\/*(\\??.*)/.exec(url);\n return {\n base: parts[1],\n queryString: parts[2]\n };\n}\n\nfunction getSendURL(url: URLLocation, session: string): string {\n return url.base + '/' + session + '/xhr_send';\n}\n\nfunction getUniqueURL(url: string): string {\n var separator = url.indexOf('?') === -1 ? '?' : '&';\n return url + separator + 't=' + +new Date() + '&n=' + autoIncrement++;\n}\n\nfunction replaceHost(url: string, hostname: string): string {\n var urlParts = /(https?:\\/\\/)([^\\/:]+)((\\/|:)?.*)/.exec(url);\n return urlParts[1] + hostname + urlParts[3];\n}\n\nfunction randomNumber(max: number): number {\n return Runtime.randomInt(max);\n}\n\nfunction randomString(length: number): string {\n var result = [];\n\n for (var i = 0; i < length; i++) {\n result.push(randomNumber(32).toString(32));\n }\n\n return result.join('');\n}\n\nexport default HTTPSocket;\n","enum TimelineLevel {\n ERROR = 3,\n INFO = 6,\n DEBUG = 7\n}\n\nexport default TimelineLevel;\n","import SocketHooks from './socket_hooks';\nimport HTTPSocket from './http_socket';\n\nvar hooks: SocketHooks = {\n getReceiveURL: function(url, session) {\n return url.base + '/' + session + '/xhr_streaming' + url.queryString;\n },\n onHeartbeat: function(socket) {\n socket.sendRaw('[]');\n },\n sendHeartbeat: function(socket) {\n socket.sendRaw('[]');\n },\n onFinished: function(socket, status) {\n socket.onClose(1006, 'Connection interrupted (' + status + ')', false);\n }\n};\n\nexport default hooks;\n","import SocketHooks from './socket_hooks';\nimport URLLocation from './url_location';\nimport HTTPSocket from './http_socket';\n\nvar hooks: SocketHooks = {\n getReceiveURL: function(url: URLLocation, session: string): string {\n return url.base + '/' + session + '/xhr' + url.queryString;\n },\n onHeartbeat: function() {\n // next HTTP request will reset server's activity timer\n },\n sendHeartbeat: function(socket) {\n socket.sendRaw('[]');\n },\n onFinished: function(socket, status) {\n if (status === 200) {\n socket.reconnect();\n } else {\n socket.onClose(1006, 'Connection interrupted (' + status + ')', false);\n }\n }\n};\n\nexport default hooks;\n","import HTTPRequest from 'core/http/http_request';\nimport RequestHooks from 'core/http/request_hooks';\nimport Ajax from 'core/http/ajax';\nimport Runtime from 'runtime';\n\nvar hooks: RequestHooks = {\n getRequest: function(socket: HTTPRequest): Ajax {\n var Constructor = Runtime.getXHRAPI();\n var xhr = new Constructor();\n xhr.onreadystatechange = xhr.onprogress = function() {\n switch (xhr.readyState) {\n case 3:\n if (xhr.responseText && xhr.responseText.length > 0) {\n socket.onChunk(xhr.status, xhr.responseText);\n }\n break;\n case 4:\n // this happens only on errors, never after calling close\n if (xhr.responseText && xhr.responseText.length > 0) {\n socket.onChunk(xhr.status, xhr.responseText);\n }\n socket.emit('finished', xhr.status);\n socket.close();\n break;\n }\n };\n return xhr;\n },\n abortRequest: function(xhr: Ajax) {\n xhr.onreadystatechange = null;\n xhr.abort();\n }\n};\n\nexport default hooks;\n","import HTTPRequest from 'core/http/http_request';\nimport HTTPSocket from 'core/http/http_socket';\nimport SocketHooks from 'core/http/socket_hooks';\nimport RequestHooks from 'core/http/request_hooks';\nimport streamingHooks from 'core/http/http_streaming_socket';\nimport pollingHooks from 'core/http/http_polling_socket';\nimport xhrHooks from './http_xhr_request';\nimport HTTPFactory from 'core/http/http_factory';\n\nvar HTTP: HTTPFactory = {\n createStreamingSocket(url: string): HTTPSocket {\n return this.createSocket(streamingHooks, url);\n },\n\n createPollingSocket(url: string): HTTPSocket {\n return this.createSocket(pollingHooks, url);\n },\n\n createSocket(hooks: SocketHooks, url: string): HTTPSocket {\n return new HTTPSocket(hooks, url);\n },\n\n createXHR(method: string, url: string): HTTPRequest {\n return this.createRequest(xhrHooks, method, url);\n },\n\n createRequest(hooks: RequestHooks, method: string, url: string): HTTPRequest {\n return new HTTPRequest(hooks, method, url);\n }\n};\n\nexport default HTTP;\n","import xdrHooks from './http_xdomain_request';\nimport HTTP from 'isomorphic/http/http';\n\nHTTP.createXDR = function(method, url) {\n return this.createRequest(xdrHooks, method, url);\n};\n\nexport default HTTP;\n","import Browser from './browser';\nimport { Dependencies, DependenciesReceivers } from './dom/dependencies';\nimport { AuthTransport, AuthTransports } from 'core/auth/auth_transports';\nimport xhrAuth from 'isomorphic/auth/xhr_auth';\nimport jsonpAuth from './auth/jsonp_auth';\nimport TimelineTransport from 'core/timeline/timeline_transport';\nimport TimelineSender from 'core/timeline/timeline_sender';\nimport ScriptRequest from './dom/script_request';\nimport JSONPRequest from './dom/jsonp_request';\nimport * as Collections from 'core/utils/collections';\nimport { ScriptReceivers } from './dom/script_receiver_factory';\nimport jsonpTimeline from './timeline/jsonp_timeline';\nimport Transports from './transports/transports';\nimport Ajax from 'core/http/ajax';\nimport { Network } from './net_info';\nimport getDefaultStrategy from './default_strategy';\nimport transportConnectionInitializer from './transports/transport_connection_initializer';\nimport HTTPFactory from './http/http';\nimport HTTPRequest from 'core/http/http_request';\n\nvar Runtime: Browser = {\n // for jsonp auth\n nextAuthCallbackID: 1,\n auth_callbacks: {},\n ScriptReceivers,\n DependenciesReceivers,\n getDefaultStrategy,\n Transports,\n transportConnectionInitializer,\n HTTPFactory,\n\n TimelineTransport: jsonpTimeline,\n\n getXHRAPI() {\n return window.XMLHttpRequest;\n },\n\n getWebSocketAPI() {\n return window.WebSocket || window.MozWebSocket;\n },\n\n setup(PusherClass): void {\n (window).Pusher = PusherClass; // JSONp requires Pusher to be in the global scope.\n var initializeOnDocumentBody = () => {\n this.onDocumentBody(PusherClass.ready);\n };\n if (!(window).JSON) {\n Dependencies.load('json2', {}, initializeOnDocumentBody);\n } else {\n initializeOnDocumentBody();\n }\n },\n\n getDocument(): Document {\n return document;\n },\n\n getProtocol(): string {\n return this.getDocument().location.protocol;\n },\n\n getAuthorizers(): AuthTransports {\n return { ajax: xhrAuth, jsonp: jsonpAuth };\n },\n\n onDocumentBody(callback: Function) {\n if (document.body) {\n callback();\n } else {\n setTimeout(() => {\n this.onDocumentBody(callback);\n }, 0);\n }\n },\n\n createJSONPRequest(url: string, data: any): JSONPRequest {\n return new JSONPRequest(url, data);\n },\n\n createScriptRequest(src: string): ScriptRequest {\n return new ScriptRequest(src);\n },\n\n getLocalStorage() {\n try {\n return window.localStorage;\n } catch (e) {\n return undefined;\n }\n },\n\n createXHR(): Ajax {\n if (this.getXHRAPI()) {\n return this.createXMLHttpRequest();\n } else {\n return this.createMicrosoftXHR();\n }\n },\n\n createXMLHttpRequest(): Ajax {\n var Constructor = this.getXHRAPI();\n return new Constructor();\n },\n\n createMicrosoftXHR(): Ajax {\n return new ActiveXObject('Microsoft.XMLHTTP');\n },\n\n getNetwork() {\n return Network;\n },\n\n createWebSocket(url: string): any {\n var Constructor = this.getWebSocketAPI();\n return new Constructor(url);\n },\n\n createSocketRequest(method: string, url: string): HTTPRequest {\n if (this.isXHRSupported()) {\n return this.HTTPFactory.createXHR(method, url);\n } else if (this.isXDRSupported(url.indexOf('https:') === 0)) {\n return this.HTTPFactory.createXDR(method, url);\n } else {\n throw 'Cross-origin HTTP requests are not supported';\n }\n },\n\n isXHRSupported(): boolean {\n var Constructor = this.getXHRAPI();\n return (\n Boolean(Constructor) && new Constructor().withCredentials !== undefined\n );\n },\n\n isXDRSupported(useTLS?: boolean): boolean {\n var protocol = useTLS ? 'https:' : 'http:';\n var documentProtocol = this.getProtocol();\n return (\n Boolean(window['XDomainRequest']) && documentProtocol === protocol\n );\n },\n\n addUnloadListener(listener: any) {\n if (window.addEventListener !== undefined) {\n window.addEventListener('unload', listener, false);\n } else if (window.attachEvent !== undefined) {\n window.attachEvent('onunload', listener);\n }\n },\n\n removeUnloadListener(listener: any) {\n if (window.addEventListener !== undefined) {\n window.removeEventListener('unload', listener, false);\n } else if (window.detachEvent !== undefined) {\n window.detachEvent('onunload', listener);\n }\n },\n\n randomInt(max: number): number {\n /**\n * Return values in the range of [0, 1[\n */\n const random = function() {\n const crypto = window.crypto || window['msCrypto'];\n const random = crypto.getRandomValues(new Uint32Array(1))[0];\n\n return random / 2 ** 32;\n };\n\n return Math.floor(random() * max);\n }\n};\n\nexport default Runtime;\n","import { Dependencies } from '../dom/dependencies';\n\n/** Initializes the transport.\n *\n * Fetches resources if needed and then transitions to initialized.\n */\nexport default function() {\n var self = this;\n\n self.timeline.info(\n self.buildTimelineMessage({\n transport: self.name + (self.options.useTLS ? 's' : '')\n })\n );\n\n if (self.hooks.isInitialized()) {\n self.changeState('initialized');\n } else if (self.hooks.file) {\n self.changeState('initializing');\n Dependencies.load(\n self.hooks.file,\n { useTLS: self.options.useTLS },\n function(error, callback) {\n if (self.hooks.isInitialized()) {\n self.changeState('initialized');\n callback(true);\n } else {\n if (error) {\n self.onError(error);\n }\n self.onClose();\n callback(false);\n }\n }\n );\n } else {\n self.onClose();\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport { default as Level } from './level';\n\nexport interface TimelineOptions {\n level?: Level;\n limit?: number;\n version?: string;\n cluster?: string;\n features?: string[];\n params?: any;\n}\n\nexport default class Timeline {\n key: string;\n session: number;\n events: any[];\n options: TimelineOptions;\n sent: number;\n uniqueID: number;\n\n constructor(key: string, session: number, options: TimelineOptions) {\n this.key = key;\n this.session = session;\n this.events = [];\n this.options = options || {};\n this.sent = 0;\n this.uniqueID = 0;\n }\n\n log(level, event) {\n if (level <= this.options.level) {\n this.events.push(\n Collections.extend({}, event, { timestamp: Util.now() })\n );\n if (this.options.limit && this.events.length > this.options.limit) {\n this.events.shift();\n }\n }\n }\n\n error(event) {\n this.log(Level.ERROR, event);\n }\n\n info(event) {\n this.log(Level.INFO, event);\n }\n\n debug(event) {\n this.log(Level.DEBUG, event);\n }\n\n isEmpty() {\n return this.events.length === 0;\n }\n\n send(sendfn, callback) {\n var data = Collections.extend(\n {\n session: this.session,\n bundle: this.sent + 1,\n key: this.key,\n lib: 'js',\n version: this.options.version,\n cluster: this.options.cluster,\n features: this.options.features,\n timeline: this.events\n },\n this.options.params\n );\n\n this.events = [];\n sendfn(data, (error, result) => {\n if (!error) {\n this.sent++;\n }\n if (callback) {\n callback(error, result);\n }\n });\n\n return true;\n }\n\n generateUniqueID(): number {\n this.uniqueID++;\n return this.uniqueID;\n }\n}\n","import Factory from '../utils/factory';\nimport Util from '../util';\nimport * as Errors from '../errors';\nimport * as Collections from '../utils/collections';\nimport Strategy from './strategy';\nimport Transport from '../transports/transport';\nimport StrategyOptions from './strategy_options';\nimport Handshake from '../connection/handshake';\n\n/** Provides a strategy interface for transports.\n *\n * @param {String} name\n * @param {Number} priority\n * @param {Class} transport\n * @param {Object} options\n */\nexport default class TransportStrategy implements Strategy {\n name: string;\n priority: number;\n transport: Transport;\n options: StrategyOptions;\n\n constructor(\n name: string,\n priority: number,\n transport: Transport,\n options: StrategyOptions\n ) {\n this.name = name;\n this.priority = priority;\n this.transport = transport;\n this.options = options || {};\n }\n\n /** Returns whether the transport is supported in the browser.\n *\n * @returns {Boolean}\n */\n isSupported(): boolean {\n return this.transport.isSupported({\n useTLS: this.options.useTLS\n });\n }\n\n /** Launches a connection attempt and returns a strategy runner.\n *\n * @param {Function} callback\n * @return {Object} strategy runner\n */\n connect(minPriority: number, callback: Function) {\n if (!this.isSupported()) {\n return failAttempt(new Errors.UnsupportedStrategy(), callback);\n } else if (this.priority < minPriority) {\n return failAttempt(new Errors.TransportPriorityTooLow(), callback);\n }\n\n var connected = false;\n var transport = this.transport.createConnection(\n this.name,\n this.priority,\n this.options.key,\n this.options\n );\n var handshake = null;\n\n var onInitialized = function() {\n transport.unbind('initialized', onInitialized);\n transport.connect();\n };\n var onOpen = function() {\n handshake = Factory.createHandshake(transport, function(result) {\n connected = true;\n unbindListeners();\n callback(null, result);\n });\n };\n var onError = function(error) {\n unbindListeners();\n callback(error);\n };\n var onClosed = function() {\n unbindListeners();\n var serializedTransport;\n\n // The reason for this try/catch block is that on React Native\n // the WebSocket object is circular. Therefore transport.socket will\n // throw errors upon stringification. Collections.safeJSONStringify\n // discards circular references when serializing.\n serializedTransport = Collections.safeJSONStringify(transport);\n callback(new Errors.TransportClosed(serializedTransport));\n };\n\n var unbindListeners = function() {\n transport.unbind('initialized', onInitialized);\n transport.unbind('open', onOpen);\n transport.unbind('error', onError);\n transport.unbind('closed', onClosed);\n };\n\n transport.bind('initialized', onInitialized);\n transport.bind('open', onOpen);\n transport.bind('error', onError);\n transport.bind('closed', onClosed);\n\n // connect will be called automatically after initialization\n transport.initialize();\n\n return {\n abort: () => {\n if (connected) {\n return;\n }\n unbindListeners();\n if (handshake) {\n handshake.close();\n } else {\n transport.close();\n }\n },\n forceMinPriority: p => {\n if (connected) {\n return;\n }\n if (this.priority < p) {\n if (handshake) {\n handshake.close();\n } else {\n transport.close();\n }\n }\n }\n };\n }\n}\n\nfunction failAttempt(error: Error, callback: Function) {\n Util.defer(function() {\n callback(error);\n });\n return {\n abort: function() {},\n forceMinPriority: function() {}\n };\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport TransportManager from '../transports/transport_manager';\nimport * as Errors from '../errors';\nimport Strategy from './strategy';\nimport TransportStrategy from './transport_strategy';\nimport StrategyOptions from '../strategies/strategy_options';\nimport { Config } from '../config';\nimport Runtime from 'runtime';\n\nconst { Transports } = Runtime;\n\nexport var defineTransport = function(\n config: Config,\n name: string,\n type: string,\n priority: number,\n options: StrategyOptions,\n manager?: TransportManager\n): Strategy {\n var transportClass = Transports[type];\n if (!transportClass) {\n throw new Errors.UnsupportedTransport(type);\n }\n\n var enabled =\n (!config.enabledTransports ||\n Collections.arrayIndexOf(config.enabledTransports, name) !== -1) &&\n (!config.disabledTransports ||\n Collections.arrayIndexOf(config.disabledTransports, name) === -1);\n\n var transport;\n if (enabled) {\n options = Object.assign(\n { ignoreNullOrigin: config.ignoreNullOrigin },\n options\n );\n\n transport = new TransportStrategy(\n name,\n priority,\n manager ? manager.getAssistant(transportClass) : transportClass,\n options\n );\n } else {\n transport = UnsupportedStrategy;\n }\n\n return transport;\n};\n\nvar UnsupportedStrategy: Strategy = {\n isSupported: function() {\n return false;\n },\n connect: function(_, callback) {\n var deferred = Util.defer(function() {\n callback(new Errors.UnsupportedStrategy());\n });\n return {\n abort: function() {\n deferred.ensureAborted();\n },\n forceMinPriority: function() {}\n };\n }\n};\n","import {\n UserAuthenticationCallback,\n InternalAuthOptions,\n UserAuthenticationHandler,\n UserAuthenticationRequestParams,\n AuthRequestType\n} from './options';\n\nimport Runtime from 'runtime';\n\nconst composeChannelQuery = (\n params: UserAuthenticationRequestParams,\n authOptions: InternalAuthOptions\n) => {\n var query = 'socket_id=' + encodeURIComponent(params.socketId);\n\n for (var key in authOptions.params) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(authOptions.params[key]);\n }\n\n if (authOptions.paramsProvider != null) {\n let dynamicParams = authOptions.paramsProvider();\n for (var key in dynamicParams) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(dynamicParams[key]);\n }\n }\n\n return query;\n};\n\nconst UserAuthenticator = (\n authOptions: InternalAuthOptions\n): UserAuthenticationHandler => {\n if (typeof Runtime.getAuthorizers()[authOptions.transport] === 'undefined') {\n throw `'${authOptions.transport}' is not a recognized auth transport`;\n }\n\n return (\n params: UserAuthenticationRequestParams,\n callback: UserAuthenticationCallback\n ) => {\n const query = composeChannelQuery(params, authOptions);\n\n Runtime.getAuthorizers()[authOptions.transport](\n Runtime,\n query,\n authOptions,\n AuthRequestType.UserAuthentication,\n callback\n );\n };\n};\n\nexport default UserAuthenticator;\n","import {\n AuthRequestType,\n InternalAuthOptions,\n ChannelAuthorizationHandler,\n ChannelAuthorizationRequestParams,\n ChannelAuthorizationCallback\n} from './options';\n\nimport Runtime from 'runtime';\n\nconst composeChannelQuery = (\n params: ChannelAuthorizationRequestParams,\n authOptions: InternalAuthOptions\n) => {\n var query = 'socket_id=' + encodeURIComponent(params.socketId);\n\n query += '&channel_name=' + encodeURIComponent(params.channelName);\n\n for (var key in authOptions.params) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(authOptions.params[key]);\n }\n\n if (authOptions.paramsProvider != null) {\n let dynamicParams = authOptions.paramsProvider();\n for (var key in dynamicParams) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(dynamicParams[key]);\n }\n }\n\n return query;\n};\n\nconst ChannelAuthorizer = (\n authOptions: InternalAuthOptions\n): ChannelAuthorizationHandler => {\n if (typeof Runtime.getAuthorizers()[authOptions.transport] === 'undefined') {\n throw `'${authOptions.transport}' is not a recognized auth transport`;\n }\n\n return (\n params: ChannelAuthorizationRequestParams,\n callback: ChannelAuthorizationCallback\n ) => {\n const query = composeChannelQuery(params, authOptions);\n\n Runtime.getAuthorizers()[authOptions.transport](\n Runtime,\n query,\n authOptions,\n AuthRequestType.ChannelAuthorization,\n callback\n );\n };\n};\n\nexport default ChannelAuthorizer;\n","import { Options } from './options';\nimport Defaults from './defaults';\nimport {\n ChannelAuthorizationHandler,\n UserAuthenticationHandler,\n ChannelAuthorizationOptions\n} from './auth/options';\nimport UserAuthenticator from './auth/user_authenticator';\nimport ChannelAuthorizer from './auth/channel_authorizer';\nimport { ChannelAuthorizerProxy } from './auth/deprecated_channel_authorizer';\nimport Runtime from 'runtime';\nimport * as nacl from 'tweetnacl';\n\nexport type AuthTransport = 'ajax' | 'jsonp';\nexport type Transport =\n | 'ws'\n | 'wss'\n | 'xhr_streaming'\n | 'xhr_polling'\n | 'sockjs';\n\nexport interface Config {\n // these are all 'required' config parameters, it's not necessary for the user\n // to set them, but they have configured defaults.\n activityTimeout: number;\n enableStats: boolean;\n httpHost: string;\n httpPath: string;\n httpPort: number;\n httpsPort: number;\n pongTimeout: number;\n statsHost: string;\n unavailableTimeout: number;\n useTLS: boolean;\n wsHost: string;\n wsPath: string;\n wsPort: number;\n wssPort: number;\n userAuthenticator: UserAuthenticationHandler;\n channelAuthorizer: ChannelAuthorizationHandler;\n\n // these are all optional parameters or overrrides. The customer can set these\n // but it's not strictly necessary\n forceTLS?: boolean;\n cluster?: string;\n disabledTransports?: Transport[];\n enabledTransports?: Transport[];\n ignoreNullOrigin?: boolean;\n nacl?: nacl;\n timelineParams?: any;\n}\n\n// getConfig mainly sets the defaults for the options that are not provided\nexport function getConfig(opts: Options, pusher): Config {\n let config: Config = {\n activityTimeout: opts.activityTimeout || Defaults.activityTimeout,\n cluster: opts.cluster,\n httpPath: opts.httpPath || Defaults.httpPath,\n httpPort: opts.httpPort || Defaults.httpPort,\n httpsPort: opts.httpsPort || Defaults.httpsPort,\n pongTimeout: opts.pongTimeout || Defaults.pongTimeout,\n statsHost: opts.statsHost || Defaults.stats_host,\n unavailableTimeout: opts.unavailableTimeout || Defaults.unavailableTimeout,\n wsPath: opts.wsPath || Defaults.wsPath,\n wsPort: opts.wsPort || Defaults.wsPort,\n wssPort: opts.wssPort || Defaults.wssPort,\n\n enableStats: getEnableStatsConfig(opts),\n httpHost: getHttpHost(opts),\n useTLS: shouldUseTLS(opts),\n wsHost: getWebsocketHost(opts),\n\n userAuthenticator: buildUserAuthenticator(opts),\n channelAuthorizer: buildChannelAuthorizer(opts, pusher)\n };\n\n if ('disabledTransports' in opts)\n config.disabledTransports = opts.disabledTransports;\n if ('enabledTransports' in opts)\n config.enabledTransports = opts.enabledTransports;\n if ('ignoreNullOrigin' in opts)\n config.ignoreNullOrigin = opts.ignoreNullOrigin;\n if ('timelineParams' in opts) config.timelineParams = opts.timelineParams;\n if ('nacl' in opts) {\n config.nacl = opts.nacl;\n }\n\n return config;\n}\n\nfunction getHttpHost(opts: Options): string {\n if (opts.httpHost) {\n return opts.httpHost;\n }\n if (opts.cluster) {\n return `sockjs-${opts.cluster}.pusher.com`;\n }\n return Defaults.httpHost;\n}\n\nfunction getWebsocketHost(opts: Options): string {\n if (opts.wsHost) {\n return opts.wsHost;\n }\n return getWebsocketHostFromCluster(opts.cluster);\n}\n\nfunction getWebsocketHostFromCluster(cluster: string): string {\n return `ws-${cluster}.pusher.com`;\n}\n\nfunction shouldUseTLS(opts: Options): boolean {\n if (Runtime.getProtocol() === 'https:') {\n return true;\n } else if (opts.forceTLS === false) {\n return false;\n }\n return true;\n}\n\n// if enableStats is set take the value\n// if disableStats is set take the inverse\n// otherwise default to false\nfunction getEnableStatsConfig(opts: Options): boolean {\n if ('enableStats' in opts) {\n return opts.enableStats;\n }\n if ('disableStats' in opts) {\n return !opts.disableStats;\n }\n return false;\n}\n\nfunction buildUserAuthenticator(opts: Options): UserAuthenticationHandler {\n const userAuthentication = {\n ...Defaults.userAuthentication,\n ...opts.userAuthentication\n };\n if (\n 'customHandler' in userAuthentication &&\n userAuthentication['customHandler'] != null\n ) {\n return userAuthentication['customHandler'];\n }\n\n return UserAuthenticator(userAuthentication);\n}\n\nfunction buildChannelAuth(opts: Options, pusher): ChannelAuthorizationOptions {\n let channelAuthorization: ChannelAuthorizationOptions;\n if ('channelAuthorization' in opts) {\n channelAuthorization = {\n ...Defaults.channelAuthorization,\n ...opts.channelAuthorization\n };\n } else {\n channelAuthorization = {\n transport: opts.authTransport || Defaults.authTransport,\n endpoint: opts.authEndpoint || Defaults.authEndpoint\n };\n if ('auth' in opts) {\n if ('params' in opts.auth) channelAuthorization.params = opts.auth.params;\n if ('headers' in opts.auth)\n channelAuthorization.headers = opts.auth.headers;\n }\n if ('authorizer' in opts)\n channelAuthorization.customHandler = ChannelAuthorizerProxy(\n pusher,\n channelAuthorization,\n opts.authorizer\n );\n }\n return channelAuthorization;\n}\n\nfunction buildChannelAuthorizer(\n opts: Options,\n pusher\n): ChannelAuthorizationHandler {\n const channelAuthorization = buildChannelAuth(opts, pusher);\n if (\n 'customHandler' in channelAuthorization &&\n channelAuthorization['customHandler'] != null\n ) {\n return channelAuthorization['customHandler'];\n }\n\n return ChannelAuthorizer(channelAuthorization);\n}\n","import Channel from '../channels/channel';\nimport {\n ChannelAuthorizationCallback,\n ChannelAuthorizationHandler,\n ChannelAuthorizationRequestParams,\n InternalAuthOptions\n} from './options';\n\nexport interface DeprecatedChannelAuthorizer {\n authorize(socketId: string, callback: ChannelAuthorizationCallback): void;\n}\n\nexport interface ChannelAuthorizerGenerator {\n (\n channel: Channel,\n options: DeprecatedAuthorizerOptions\n ): DeprecatedChannelAuthorizer;\n}\n\nexport interface DeprecatedAuthOptions {\n params?: any;\n headers?: any;\n}\n\nexport interface DeprecatedAuthorizerOptions {\n authTransport: 'ajax' | 'jsonp';\n authEndpoint: string;\n auth?: DeprecatedAuthOptions;\n}\n\nexport const ChannelAuthorizerProxy = (\n pusher,\n authOptions: InternalAuthOptions,\n channelAuthorizerGenerator: ChannelAuthorizerGenerator\n): ChannelAuthorizationHandler => {\n const deprecatedAuthorizerOptions: DeprecatedAuthorizerOptions = {\n authTransport: authOptions.transport,\n authEndpoint: authOptions.endpoint,\n auth: {\n params: authOptions.params,\n headers: authOptions.headers\n }\n };\n return (\n params: ChannelAuthorizationRequestParams,\n callback: ChannelAuthorizationCallback\n ) => {\n const channel = pusher.channel(params.channelName);\n // This line creates a new channel authorizer every time.\n // In the past, this was only done once per channel and reused.\n // We can do that again if we want to keep this behavior intact.\n const channelAuthorizer: DeprecatedChannelAuthorizer = channelAuthorizerGenerator(\n channel,\n deprecatedAuthorizerOptions\n );\n channelAuthorizer.authorize(params.socketId, callback);\n };\n};\n","import Logger from './logger';\nimport Pusher from './pusher';\nimport EventsDispatcher from './events/dispatcher';\n\nexport default class WatchlistFacade extends EventsDispatcher {\n private pusher: Pusher;\n\n public constructor(pusher: Pusher) {\n super(function(eventName, data) {\n Logger.debug(`No callbacks on watchlist events for ${eventName}`);\n });\n\n this.pusher = pusher;\n this.bindWatchlistInternalEvent();\n }\n\n handleEvent(pusherEvent) {\n pusherEvent.data.events.forEach(watchlistEvent => {\n this.emit(watchlistEvent.name, watchlistEvent);\n });\n }\n\n private bindWatchlistInternalEvent() {\n this.pusher.connection.bind('message', pusherEvent => {\n var eventName = pusherEvent.event;\n if (eventName === 'pusher_internal:watchlist_events') {\n this.handleEvent(pusherEvent);\n }\n });\n }\n}\n","function flatPromise() {\n let resolve, reject;\n const promise = new Promise((res, rej) => {\n resolve = res;\n reject = rej;\n });\n return { promise, resolve, reject };\n}\n\nexport default flatPromise;\n","import Pusher from './pusher';\nimport Logger from './logger';\nimport {\n UserAuthenticationData,\n UserAuthenticationCallback\n} from './auth/options';\nimport Channel from './channels/channel';\nimport WatchlistFacade from './watchlist';\nimport EventsDispatcher from './events/dispatcher';\nimport flatPromise from './utils/flat_promise';\n\nexport default class UserFacade extends EventsDispatcher {\n pusher: Pusher;\n signin_requested: boolean = false;\n user_data: any = null;\n serverToUserChannel: Channel = null;\n signinDonePromise: Promise = null;\n watchlist: WatchlistFacade;\n private _signinDoneResolve: Function = null;\n\n public constructor(pusher: Pusher) {\n super(function(eventName, data) {\n Logger.debug('No callbacks on user for ' + eventName);\n });\n this.pusher = pusher;\n this.pusher.connection.bind('state_change', ({ previous, current }) => {\n if (previous !== 'connected' && current === 'connected') {\n this._signin();\n }\n if (previous === 'connected' && current !== 'connected') {\n this._cleanup();\n this._newSigninPromiseIfNeeded();\n }\n });\n\n this.watchlist = new WatchlistFacade(pusher);\n\n this.pusher.connection.bind('message', event => {\n var eventName = event.event;\n if (eventName === 'pusher:signin_success') {\n this._onSigninSuccess(event.data);\n }\n if (\n this.serverToUserChannel &&\n this.serverToUserChannel.name === event.channel\n ) {\n this.serverToUserChannel.handleEvent(event);\n }\n });\n }\n\n public signin() {\n if (this.signin_requested) {\n return;\n }\n\n this.signin_requested = true;\n this._signin();\n }\n\n private _signin() {\n if (!this.signin_requested) {\n return;\n }\n\n this._newSigninPromiseIfNeeded();\n\n if (this.pusher.connection.state !== 'connected') {\n // Signin will be attempted when the connection is connected\n return;\n }\n\n this.pusher.config.userAuthenticator(\n {\n socketId: this.pusher.connection.socket_id\n },\n this._onAuthorize\n );\n }\n\n private _onAuthorize: UserAuthenticationCallback = (\n err,\n authData: UserAuthenticationData\n ) => {\n if (err) {\n Logger.warn(`Error during signin: ${err}`);\n this._cleanup();\n return;\n }\n\n this.pusher.send_event('pusher:signin', {\n auth: authData.auth,\n user_data: authData.user_data\n });\n\n // Later when we get pusher:singin_success event, the user will be marked as signed in\n };\n\n private _onSigninSuccess(data: any) {\n try {\n this.user_data = JSON.parse(data.user_data);\n } catch (e) {\n Logger.error(`Failed parsing user data after signin: ${data.user_data}`);\n this._cleanup();\n return;\n }\n\n if (typeof this.user_data.id !== 'string' || this.user_data.id === '') {\n Logger.error(\n `user_data doesn't contain an id. user_data: ${this.user_data}`\n );\n this._cleanup();\n return;\n }\n\n // Signin succeeded\n this._signinDoneResolve();\n this._subscribeChannels();\n }\n\n private _subscribeChannels() {\n const ensure_subscribed = channel => {\n if (channel.subscriptionPending && channel.subscriptionCancelled) {\n channel.reinstateSubscription();\n } else if (\n !channel.subscriptionPending &&\n this.pusher.connection.state === 'connected'\n ) {\n channel.subscribe();\n }\n };\n\n this.serverToUserChannel = new Channel(\n `#server-to-user-${this.user_data.id}`,\n this.pusher\n );\n this.serverToUserChannel.bind_global((eventName, data) => {\n if (\n eventName.indexOf('pusher_internal:') === 0 ||\n eventName.indexOf('pusher:') === 0\n ) {\n // ignore internal events\n return;\n }\n this.emit(eventName, data);\n });\n ensure_subscribed(this.serverToUserChannel);\n }\n\n private _cleanup() {\n this.user_data = null;\n if (this.serverToUserChannel) {\n this.serverToUserChannel.unbind_all();\n this.serverToUserChannel.disconnect();\n this.serverToUserChannel = null;\n }\n\n if (this.signin_requested) {\n // If signin is in progress and cleanup is called,\n // Mark the current signin process as done.\n this._signinDoneResolve();\n }\n }\n\n private _newSigninPromiseIfNeeded() {\n if (!this.signin_requested) {\n return;\n }\n\n // If there is a promise and it is not resolved, return without creating a new one.\n if (this.signinDonePromise && !(this.signinDonePromise as any).done) {\n return;\n }\n\n // This promise is never rejected.\n // It gets resolved when the signin process is done whether it failed or succeeded\n const { promise, resolve, reject: _ } = flatPromise();\n (promise as any).done = false;\n const setDone = () => {\n (promise as any).done = true;\n };\n promise.then(setDone).catch(setDone);\n this.signinDonePromise = promise;\n this._signinDoneResolve = resolve;\n }\n}\n","import AbstractRuntime from '../runtimes/interface';\nimport Runtime from 'runtime';\nimport * as Collections from './utils/collections';\nimport Channels from './channels/channels';\nimport Channel from './channels/channel';\nimport { default as EventsDispatcher } from './events/dispatcher';\nimport Timeline from './timeline/timeline';\nimport TimelineSender from './timeline/timeline_sender';\nimport TimelineLevel from './timeline/level';\nimport { defineTransport } from './strategies/strategy_builder';\nimport ConnectionManager from './connection/connection_manager';\nimport { PeriodicTimer } from './utils/timers';\nimport Defaults from './defaults';\nimport Logger from './logger';\nimport Factory from './utils/factory';\nimport { Options, ClusterOptions, validateOptions } from './options';\nimport { Config, getConfig } from './config';\nimport StrategyOptions from './strategies/strategy_options';\nimport UserFacade from './user';\n\nexport default class Pusher {\n /* STATIC PROPERTIES */\n static instances: Pusher[] = [];\n static isReady: boolean = false;\n static logToConsole: boolean = false;\n\n // for jsonp\n static Runtime: AbstractRuntime = Runtime;\n static ScriptReceivers: any = (Runtime).ScriptReceivers;\n static DependenciesReceivers: any = (Runtime).DependenciesReceivers;\n static auth_callbacks: any = (Runtime).auth_callbacks;\n\n static ready() {\n Pusher.isReady = true;\n for (var i = 0, l = Pusher.instances.length; i < l; i++) {\n Pusher.instances[i].connect();\n }\n }\n\n static log: (message: any) => void;\n\n private static getClientFeatures(): string[] {\n return Collections.keys(\n Collections.filterObject({ ws: Runtime.Transports.ws }, function(t) {\n return t.isSupported({});\n })\n );\n }\n\n /* INSTANCE PROPERTIES */\n key: string;\n options: Options;\n config: Config;\n channels: Channels;\n global_emitter: EventsDispatcher;\n sessionID: number;\n timeline: Timeline;\n timelineSender: TimelineSender;\n connection: ConnectionManager;\n timelineSenderTimer: PeriodicTimer;\n user: UserFacade;\n constructor(app_key: string, options: Options) {\n checkAppKey(app_key);\n validateOptions(options);\n this.key = app_key;\n this.config = getConfig(options, this);\n\n this.channels = Factory.createChannels();\n this.global_emitter = new EventsDispatcher();\n this.sessionID = Runtime.randomInt(1000000000);\n\n this.timeline = new Timeline(this.key, this.sessionID, {\n cluster: this.config.cluster,\n features: Pusher.getClientFeatures(),\n params: this.config.timelineParams || {},\n limit: 50,\n level: TimelineLevel.INFO,\n version: Defaults.VERSION\n });\n if (this.config.enableStats) {\n this.timelineSender = Factory.createTimelineSender(this.timeline, {\n host: this.config.statsHost,\n path: '/timeline/v2/' + Runtime.TimelineTransport.name\n });\n }\n\n var getStrategy = (options: StrategyOptions) => {\n return Runtime.getDefaultStrategy(this.config, options, defineTransport);\n };\n\n this.connection = Factory.createConnectionManager(this.key, {\n getStrategy: getStrategy,\n timeline: this.timeline,\n activityTimeout: this.config.activityTimeout,\n pongTimeout: this.config.pongTimeout,\n unavailableTimeout: this.config.unavailableTimeout,\n useTLS: Boolean(this.config.useTLS)\n });\n\n this.connection.bind('connected', () => {\n this.subscribeAll();\n if (this.timelineSender) {\n this.timelineSender.send(this.connection.isUsingTLS());\n }\n });\n\n this.connection.bind('message', event => {\n var eventName = event.event;\n var internal = eventName.indexOf('pusher_internal:') === 0;\n if (event.channel) {\n var channel = this.channel(event.channel);\n if (channel) {\n channel.handleEvent(event);\n }\n }\n // Emit globally [deprecated]\n if (!internal) {\n this.global_emitter.emit(event.event, event.data);\n }\n });\n this.connection.bind('connecting', () => {\n this.channels.disconnect();\n });\n this.connection.bind('disconnected', () => {\n this.channels.disconnect();\n });\n this.connection.bind('error', err => {\n Logger.warn(err);\n });\n\n Pusher.instances.push(this);\n this.timeline.info({ instances: Pusher.instances.length });\n\n this.user = new UserFacade(this);\n\n if (Pusher.isReady) {\n this.connect();\n }\n }\n\n /**\n * Allows you to switch Pusher cluster without\n * losing all the channels/subscription binding\n * as this is internally managed by the SDK.\n */\n switchCluster(options: ClusterOptions) {\n const { appKey, cluster } = options;\n this.key = appKey;\n this.options = { ...this.options, cluster };\n this.config = getConfig(this.options, this);\n this.connection.switchCluster(this.key);\n }\n\n channel(name: string): Channel {\n return this.channels.find(name);\n }\n\n allChannels(): Channel[] {\n return this.channels.all();\n }\n\n connect() {\n this.connection.connect();\n\n if (this.timelineSender) {\n if (!this.timelineSenderTimer) {\n var usingTLS = this.connection.isUsingTLS();\n var timelineSender = this.timelineSender;\n this.timelineSenderTimer = new PeriodicTimer(60000, function() {\n timelineSender.send(usingTLS);\n });\n }\n }\n }\n\n disconnect() {\n this.connection.disconnect();\n\n if (this.timelineSenderTimer) {\n this.timelineSenderTimer.ensureAborted();\n this.timelineSenderTimer = null;\n }\n }\n\n bind(event_name: string, callback: Function, context?: any): Pusher {\n this.global_emitter.bind(event_name, callback, context);\n return this;\n }\n\n unbind(event_name?: string, callback?: Function, context?: any): Pusher {\n this.global_emitter.unbind(event_name, callback, context);\n return this;\n }\n\n bind_global(callback: Function): Pusher {\n this.global_emitter.bind_global(callback);\n return this;\n }\n\n unbind_global(callback?: Function): Pusher {\n this.global_emitter.unbind_global(callback);\n return this;\n }\n\n unbind_all(callback?: Function): Pusher {\n this.global_emitter.unbind_all();\n return this;\n }\n\n subscribeAll() {\n var channelName;\n for (channelName in this.channels.channels) {\n if (this.channels.channels.hasOwnProperty(channelName)) {\n this.subscribe(channelName);\n }\n }\n }\n\n subscribe(channel_name: string) {\n var channel = this.channels.add(channel_name, this);\n if (channel.subscriptionPending && channel.subscriptionCancelled) {\n channel.reinstateSubscription();\n } else if (\n !channel.subscriptionPending &&\n this.connection.state === 'connected'\n ) {\n channel.subscribe();\n }\n return channel;\n }\n\n unsubscribe(channel_name: string) {\n var channel = this.channels.find(channel_name);\n if (channel && channel.subscriptionPending) {\n channel.cancelSubscription();\n } else {\n channel = this.channels.remove(channel_name);\n if (channel && channel.subscribed) {\n channel.unsubscribe();\n }\n }\n }\n\n send_event(event_name: string, data: any, channel?: string) {\n return this.connection.send_event(event_name, data, channel);\n }\n\n shouldUseTLS(): boolean {\n return this.config.useTLS;\n }\n\n signin() {\n this.user.signin();\n }\n}\n\nfunction checkAppKey(key) {\n if (key === null || key === undefined) {\n throw 'You must pass your app key when you instantiate Pusher.';\n }\n}\n\nRuntime.setup(Pusher);\n","import ConnectionManager from './connection/connection_manager';\nimport {\n ChannelAuthorizationOptions,\n UserAuthenticationOptions\n} from './auth/options';\nimport {\n ChannelAuthorizerGenerator,\n DeprecatedAuthOptions\n} from './auth/deprecated_channel_authorizer';\nimport { AuthTransport, Transport } from './config';\nimport * as nacl from 'tweetnacl';\nimport Logger from './logger';\n\nexport interface Options {\n activityTimeout?: number;\n\n auth?: DeprecatedAuthOptions; // DEPRECATED use channelAuthorization instead\n authEndpoint?: string; // DEPRECATED use channelAuthorization instead\n authTransport?: AuthTransport; // DEPRECATED use channelAuthorization instead\n authorizer?: ChannelAuthorizerGenerator; // DEPRECATED use channelAuthorization instead\n\n channelAuthorization?: ChannelAuthorizationOptions;\n userAuthentication?: UserAuthenticationOptions;\n\n cluster: string;\n enableStats?: boolean;\n disableStats?: boolean;\n disabledTransports?: Transport[];\n enabledTransports?: Transport[];\n forceTLS?: boolean;\n httpHost?: string;\n httpPath?: string;\n httpPort?: number;\n httpsPort?: number;\n ignoreNullOrigin?: boolean;\n nacl?: nacl;\n pongTimeout?: number;\n statsHost?: string;\n timelineParams?: any;\n unavailableTimeout?: number;\n wsHost?: string;\n wsPath?: string;\n wsPort?: number;\n wssPort?: number;\n}\n\nexport interface ClusterOptions {\n appKey: string;\n cluster: string;\n}\n\nexport function validateOptions(options) {\n if (options == null) {\n throw 'You must pass an options object';\n }\n if (options.cluster == null) {\n throw 'Options object must provide a cluster';\n }\n if ('disableStats' in options) {\n Logger.warn(\n 'The disableStats option is deprecated in favor of enableStats'\n );\n }\n}\n"],"sourceRoot":""} \ No newline at end of file diff --git a/dist/worker/pusher-with-encryption.worker.js b/dist/worker/pusher-with-encryption.worker.js index a2ebda472..9f2784ef8 100644 --- a/dist/worker/pusher-with-encryption.worker.js +++ b/dist/worker/pusher-with-encryption.worker.js @@ -1,5 +1,5 @@ /*! - * Pusher JavaScript Library v8.4.0 + * Pusher JavaScript Library v8.4.0-rc1 * https://pusher.com/ * * Copyright 2020, Pusher @@ -3273,7 +3273,7 @@ function safeJSONStringify(source) { // CONCATENATED MODULE: ./src/core/defaults.ts var Defaults = { - VERSION: "8.4.0", + VERSION: "8.4.0-rc1", PROTOCOL: 7, wsPort: 80, wssPort: 443, diff --git a/dist/worker/pusher-with-encryption.worker.js.map b/dist/worker/pusher-with-encryption.worker.js.map index 9a96ac022..8e8d04a8d 100644 --- a/dist/worker/pusher-with-encryption.worker.js.map +++ b/dist/worker/pusher-with-encryption.worker.js.map @@ -1 +1 @@ -{"version":3,"sources":["webpack://Pusher/webpack/universalModuleDefinition","webpack://Pusher/webpack/bootstrap","webpack://Pusher/./node_modules/@stablelib/base64/base64.ts","webpack://Pusher/./node_modules/@stablelib/utf8/utf8.ts","webpack://Pusher/./node_modules/tweetnacl/nacl-fast.js","webpack://Pusher/./src/core/pusher-with-encryption.js","webpack://Pusher/crypto (ignored)","webpack://Pusher/./src/core/base64.ts","webpack://Pusher/./src/core/utils/timers/abstract_timer.ts","webpack://Pusher/./src/core/utils/timers/index.ts","webpack://Pusher/./src/core/util.ts","webpack://Pusher/./src/core/utils/collections.ts","webpack://Pusher/./src/core/defaults.ts","webpack://Pusher/./src/core/transports/url_schemes.ts","webpack://Pusher/./src/core/events/callback_registry.ts","webpack://Pusher/./src/core/events/dispatcher.ts","webpack://Pusher/./src/core/logger.ts","webpack://Pusher/./src/core/transports/transport_connection.ts","webpack://Pusher/./src/core/transports/transport.ts","webpack://Pusher/./src/runtimes/isomorphic/transports/transports.ts","webpack://Pusher/./src/core/transports/assistant_to_the_transport_manager.ts","webpack://Pusher/./src/core/connection/protocol/protocol.ts","webpack://Pusher/./src/core/connection/connection.ts","webpack://Pusher/./src/core/connection/handshake/index.ts","webpack://Pusher/./src/core/timeline/timeline_sender.ts","webpack://Pusher/./src/core/errors.ts","webpack://Pusher/./src/core/utils/url_store.ts","webpack://Pusher/./src/core/channels/channel.ts","webpack://Pusher/./src/core/channels/private_channel.ts","webpack://Pusher/./src/core/channels/members.ts","webpack://Pusher/./src/core/channels/presence_channel.ts","webpack://Pusher/./src/core/channels/encrypted_channel.ts","webpack://Pusher/./src/core/connection/connection_manager.ts","webpack://Pusher/./src/core/channels/channels.ts","webpack://Pusher/./src/core/utils/factory.ts","webpack://Pusher/./src/core/transports/transport_manager.ts","webpack://Pusher/./src/core/strategies/sequential_strategy.ts","webpack://Pusher/./src/core/strategies/best_connected_ever_strategy.ts","webpack://Pusher/./src/core/strategies/websocket_prioritized_cached_strategy.ts","webpack://Pusher/./src/core/strategies/delayed_strategy.ts","webpack://Pusher/./src/core/strategies/if_strategy.ts","webpack://Pusher/./src/core/strategies/first_connected_strategy.ts","webpack://Pusher/./src/runtimes/isomorphic/default_strategy.ts","webpack://Pusher/./src/runtimes/isomorphic/transports/transport_connection_initializer.ts","webpack://Pusher/./src/core/http/http_request.ts","webpack://Pusher/./src/core/http/state.ts","webpack://Pusher/./src/core/http/http_socket.ts","webpack://Pusher/./src/core/http/http_streaming_socket.ts","webpack://Pusher/./src/core/http/http_polling_socket.ts","webpack://Pusher/./src/runtimes/isomorphic/http/http_xhr_request.ts","webpack://Pusher/./src/runtimes/isomorphic/http/http.ts","webpack://Pusher/./src/runtimes/isomorphic/runtime.ts","webpack://Pusher/./src/runtimes/worker/net_info.ts","webpack://Pusher/./src/runtimes/worker/auth/fetch_auth.ts","webpack://Pusher/./src/runtimes/worker/timeline/fetch_timeline.ts","webpack://Pusher/./src/runtimes/worker/runtime.ts","webpack://Pusher/./src/core/timeline/level.ts","webpack://Pusher/./src/core/timeline/timeline.ts","webpack://Pusher/./src/core/strategies/transport_strategy.ts","webpack://Pusher/./src/core/strategies/strategy_builder.ts","webpack://Pusher/./src/core/options.ts","webpack://Pusher/./src/core/auth/options.ts","webpack://Pusher/./src/core/auth/user_authenticator.ts","webpack://Pusher/./src/core/auth/channel_authorizer.ts","webpack://Pusher/./src/core/auth/deprecated_channel_authorizer.ts","webpack://Pusher/./src/core/config.ts","webpack://Pusher/./src/core/watchlist.ts","webpack://Pusher/./src/core/utils/flat_promise.ts","webpack://Pusher/./src/core/user.ts","webpack://Pusher/./src/core/pusher.ts","webpack://Pusher/./src/core/pusher-with-encryption.ts"],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AC;gBACpD,CAAC,GAAG,MAAM,GAAG,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC;aAC5B;SACJ;QAED,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC;KACtC;IACD,OAAO,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AAC1B,CAAC;AAjED,wBAiEC;;;;;;;AC/ID;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,uBAAuB,iBAAiB;AACxC;AACA;;AAEA;AACA,wCAAwC,4BAA4B;;AAEpE;AACA,4BAA4B;;AAE5B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa,OAAO;AACpB;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,aAAa,QAAQ;AACrB,aAAa,OAAO;AACpB;AACA;AACA,eAAe,QAAQ;AACvB;AACA,eAAe,QAAQ;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB;AACA;AACA;;AAEA;AACA;AACA;AACA,aAAa,QAAQ;AACrB,aAAa,OAAO;AACpB;AACA;AACA,eAAe,QAAQ;AACvB;AACA,eAAe,QAAQ;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,iBAAiB,OAAO;AACxB;AACA;;AAEA;AACA;AACA;AACA;AACA,iBAAiB,OAAO;AACxB;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA,8CAA8C;AAC9C,8CAA8C;AAC9C,8CAA8C;AAC9C,8CAA8C;AAC9C,8CAA8C;AAC9C;AACA,8CAA8C;AAC9C,8CAA8C;AAC9C,8CAA8C;AAC9C;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,sDAAsD;AACtD,sDAAsD;AACtD,sDAAsD;AACtD,sDAAsD;AACtD,sDAAsD;AACtD;AACA,sDAAsD;AACtD,sDAAsD;AACtD,sDAAsD;AACtD;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA,qBAAqB;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA,qBAAqB;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA,qBAAqB;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA,qBAAqB;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA,qBAAqB;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA,qBAAqB;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA,qBAAqB;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA,qBAAqB;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA,qBAAqB;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA,qBAAqB;;AAErB;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA,UAAU,QAAQ;AAClB;AACA;AACA;;AAEA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA;AACA;;AAEA;AACA,aAAa,QAAQ;AACrB;AACA,aAAa,QAAQ;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa,OAAO;AACpB;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,UAAU;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,eAAe,WAAW;AAC1B;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;;AAEA;AACA;AACA,aAAa,QAAQ;AACrB;;AAEA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA,aAAa,OAAO;AACpB;AACA,eAAe,QAAQ;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;;AAEA;AACA,iBAAiB,QAAQ;AACzB;;AAEA;AACA,iBAAiB,QAAQ;AACzB;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD;;AAEA;AACA;AACA,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA,aAAa,QAAQ;AACrB,eAAe,QAAQ;AACvB;AACA;AACA;AACA,aAAa,QAAQ;AACrB;;AAEA;AACA;AACA;AACA,aAAa,QAAQ;AACrB,eAAe,QAAQ;AACvB;AACA;AACA;AACA,aAAa,QAAQ;AACrB;;AAEA;AACA;AACA;AACA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA;AACA,aAAa,MAAM;AACnB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,eAAe,QAAQ;AACvB;AACA;AACA;AACA;AACA,eAAe,QAAQ;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA,qBAAqB;AACrB,qBAAqB;;AAErB;AACA;AACA;;AAEA,sBAAsB;AACtB,sBAAsB;;AAEtB;AACA;AACA;;AAEA,sBAAsB;AACtB,sBAAsB;;AAEtB;AACA;AACA;;AAEA,sBAAsB;AACtB,sBAAsB;;AAEtB;AACA;AACA;;AAEA,sBAAsB;AACtB,sBAAsB;;AAEtB;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA,qBAAqB;AACrB,qBAAqB;;AAErB;AACA;AACA;;AAEA,sBAAsB;AACtB,sBAAsB;;AAEtB;AACA;AACA;;AAEA,sBAAsB;AACtB,sBAAsB;;AAEtB;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA,qBAAqB;AACrB,qBAAqB;;AAErB;AACA;;AAEA,sBAAsB;AACtB,sBAAsB;;AAEtB;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,mBAAmB,QAAQ;AAC3B;AACA;AACA;;AAEA,yBAAyB;AACzB,yBAAyB;;AAEzB;AACA;;AAEA,0BAA0B;AAC1B,0BAA0B;;AAE1B;AACA;AACA;AACA;AACA;;AAEA,0BAA0B;AAC1B,0BAA0B;;AAE1B;AACA;AACA;AACA;AACA;;AAEA,0BAA0B;AAC1B,0BAA0B;;AAE1B;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA,mBAAmB;AACnB,mBAAmB;;AAEnB;AACA;;AAEA,oBAAoB;AACpB,oBAAoB;;AAEpB;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA,mBAAmB;AACnB,mBAAmB;;AAEnB;AACA;;AAEA,oBAAoB;AACpB,oBAAoB;;AAEpB;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA,mBAAmB;AACnB,mBAAmB;;AAEnB;AACA;;AAEA,oBAAoB;AACpB,oBAAoB;;AAEpB;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA,mBAAmB;AACnB,mBAAmB;;AAEnB;AACA;;AAEA,oBAAoB;AACpB,oBAAoB;;AAEpB;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA,mBAAmB;AACnB,mBAAmB;;AAEnB;AACA;;AAEA,oBAAoB;AACpB,oBAAoB;;AAEpB;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA,mBAAmB;AACnB,mBAAmB;;AAEnB;AACA;;AAEA,oBAAoB;AACpB,oBAAoB;;AAEpB;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA,mBAAmB;AACnB,mBAAmB;;AAEnB;AACA;;AAEA,oBAAoB;AACpB,oBAAoB;;AAEpB;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA,mBAAmB;AACnB,mBAAmB;;AAEnB;AACA;;AAEA,oBAAoB;AACpB,oBAAoB;;AAEpB;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA,aAAa,OAAO;AACpB;;AAEA;AACA;AACA;AACA;;AAEA,aAAa,OAAO;;AAEpB;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa,OAAO;AACpB;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,QAAQ;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA,aAAa,QAAQ;AACrB;AACA;;AAEA;;AAEA;AACA;AACA,cAAc,SAAS;AACvB;AACA,gCAAgC,OAAO;AACvC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA;AACA,aAAa,QAAQ;AACrB,aAAa,QAAQ;AACrB;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa,QAAQ;AACrB,aAAa,QAAQ;AACrB;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA,aAAa,OAAO;AACpB,aAAa,QAAQ;;AAErB;AACA;AACA;AACA;;AAEA,cAAc,QAAQ;AACtB;AACA;;AAEA,aAAa,QAAQ;AACrB,aAAa,QAAQ;AACrB,aAAa,QAAQ;AACrB,eAAe,QAAQ;AACvB;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;;AAEA,aAAa,OAAO;AACpB,aAAa,QAAQ;AACrB;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA,eAAe,OAAO;AACtB;AACA;;AAEA,aAAa,OAAO;AACpB;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA,iBAAiB,sBAAsB;AACvC;AACA;AACA;AACA;;AAEA;AACA,iBAAiB,gBAAgB;AACjC;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,iBAAiB,gBAAgB;AACjC;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,iBAAiB,gBAAgB;AACjC;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA,UAAU;AACV;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,UAAU;AACV;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAiB,cAAc;AAC/B;AACA;;AAEA;AACA;AACA;AACA,iBAAiB,gBAAgB;AACjC;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa,uBAAuB;AACpC,aAAa,gBAAgB;AAC7B;AACA;;AAEA;AACA;AACA;AACA;AACA,UAAU;AACV;;AAEA;AACA;AACA;AACA;AACA;AACA,iBAAiB,eAAe;AAChC,UAAU;AACV;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAiB,QAAQ;AACzB;AACA,UAAU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CAAoB,CAAC,GAAG,CAAC;QAEtC,eAAe,CAAC,OAAO,CAAC,CAAC;QACzB,OAAO,CAAC,IAAI,GAAG,SAAI,CAAC;QACpB,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAC1B,CAAC;CACF","file":"pusher-with-encryption.worker.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"Pusher\"] = factory();\n\telse\n\t\troot[\"Pusher\"] = factory();\n})(this, function() {\nreturn "," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 3);\n","// Copyright (C) 2016 Dmitry Chestnykh\n// MIT License. See LICENSE file for details.\n\n/**\n * Package base64 implements Base64 encoding and decoding.\n */\n\n// Invalid character used in decoding to indicate\n// that the character to decode is out of range of\n// alphabet and cannot be decoded.\nconst INVALID_BYTE = 256;\n\n/**\n * Implements standard Base64 encoding.\n *\n * Operates in constant time.\n */\nexport class Coder {\n // TODO(dchest): methods to encode chunk-by-chunk.\n\n constructor(private _paddingCharacter = \"=\") { }\n\n encodedLength(length: number): number {\n if (!this._paddingCharacter) {\n return (length * 8 + 5) / 6 | 0;\n }\n return (length + 2) / 3 * 4 | 0;\n }\n\n encode(data: Uint8Array): string {\n let out = \"\";\n\n let i = 0;\n for (; i < data.length - 2; i += 3) {\n let c = (data[i] << 16) | (data[i + 1] << 8) | (data[i + 2]);\n out += this._encodeByte((c >>> 3 * 6) & 63);\n out += this._encodeByte((c >>> 2 * 6) & 63);\n out += this._encodeByte((c >>> 1 * 6) & 63);\n out += this._encodeByte((c >>> 0 * 6) & 63);\n }\n\n const left = data.length - i;\n if (left > 0) {\n let c = (data[i] << 16) | (left === 2 ? data[i + 1] << 8 : 0);\n out += this._encodeByte((c >>> 3 * 6) & 63);\n out += this._encodeByte((c >>> 2 * 6) & 63);\n if (left === 2) {\n out += this._encodeByte((c >>> 1 * 6) & 63);\n } else {\n out += this._paddingCharacter || \"\";\n }\n out += this._paddingCharacter || \"\";\n }\n\n return out;\n }\n\n maxDecodedLength(length: number): number {\n if (!this._paddingCharacter) {\n return (length * 6 + 7) / 8 | 0;\n }\n return length / 4 * 3 | 0;\n }\n\n decodedLength(s: string): number {\n return this.maxDecodedLength(s.length - this._getPaddingLength(s));\n }\n\n decode(s: string): Uint8Array {\n if (s.length === 0) {\n return new Uint8Array(0);\n }\n const paddingLength = this._getPaddingLength(s);\n const length = s.length - paddingLength;\n const out = new Uint8Array(this.maxDecodedLength(length));\n let op = 0;\n let i = 0;\n let haveBad = 0;\n let v0 = 0, v1 = 0, v2 = 0, v3 = 0;\n for (; i < length - 4; i += 4) {\n v0 = this._decodeChar(s.charCodeAt(i + 0));\n v1 = this._decodeChar(s.charCodeAt(i + 1));\n v2 = this._decodeChar(s.charCodeAt(i + 2));\n v3 = this._decodeChar(s.charCodeAt(i + 3));\n out[op++] = (v0 << 2) | (v1 >>> 4);\n out[op++] = (v1 << 4) | (v2 >>> 2);\n out[op++] = (v2 << 6) | v3;\n haveBad |= v0 & INVALID_BYTE;\n haveBad |= v1 & INVALID_BYTE;\n haveBad |= v2 & INVALID_BYTE;\n haveBad |= v3 & INVALID_BYTE;\n }\n if (i < length - 1) {\n v0 = this._decodeChar(s.charCodeAt(i));\n v1 = this._decodeChar(s.charCodeAt(i + 1));\n out[op++] = (v0 << 2) | (v1 >>> 4);\n haveBad |= v0 & INVALID_BYTE;\n haveBad |= v1 & INVALID_BYTE;\n }\n if (i < length - 2) {\n v2 = this._decodeChar(s.charCodeAt(i + 2));\n out[op++] = (v1 << 4) | (v2 >>> 2);\n haveBad |= v2 & INVALID_BYTE;\n }\n if (i < length - 3) {\n v3 = this._decodeChar(s.charCodeAt(i + 3));\n out[op++] = (v2 << 6) | v3;\n haveBad |= v3 & INVALID_BYTE;\n }\n if (haveBad !== 0) {\n throw new Error(\"Base64Coder: incorrect characters for decoding\");\n }\n return out;\n }\n\n // Standard encoding have the following encoded/decoded ranges,\n // which we need to convert between.\n //\n // ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 0123456789 + /\n // Index: 0 - 25 26 - 51 52 - 61 62 63\n // ASCII: 65 - 90 97 - 122 48 - 57 43 47\n //\n\n // Encode 6 bits in b into a new character.\n protected _encodeByte(b: number): string {\n // Encoding uses constant time operations as follows:\n //\n // 1. Define comparison of A with B using (A - B) >>> 8:\n // if A > B, then result is positive integer\n // if A <= B, then result is 0\n //\n // 2. Define selection of C or 0 using bitwise AND: X & C:\n // if X == 0, then result is 0\n // if X != 0, then result is C\n //\n // 3. Start with the smallest comparison (b >= 0), which is always\n // true, so set the result to the starting ASCII value (65).\n //\n // 4. Continue comparing b to higher ASCII values, and selecting\n // zero if comparison isn't true, otherwise selecting a value\n // to add to result, which:\n //\n // a) undoes the previous addition\n // b) provides new value to add\n //\n let result = b;\n // b >= 0\n result += 65;\n // b > 25\n result += ((25 - b) >>> 8) & ((0 - 65) - 26 + 97);\n // b > 51\n result += ((51 - b) >>> 8) & ((26 - 97) - 52 + 48);\n // b > 61\n result += ((61 - b) >>> 8) & ((52 - 48) - 62 + 43);\n // b > 62\n result += ((62 - b) >>> 8) & ((62 - 43) - 63 + 47);\n\n return String.fromCharCode(result);\n }\n\n // Decode a character code into a byte.\n // Must return 256 if character is out of alphabet range.\n protected _decodeChar(c: number): number {\n // Decoding works similar to encoding: using the same comparison\n // function, but now it works on ranges: result is always incremented\n // by value, but this value becomes zero if the range is not\n // satisfied.\n //\n // Decoding starts with invalid value, 256, which is then\n // subtracted when the range is satisfied. If none of the ranges\n // apply, the function returns 256, which is then checked by\n // the caller to throw error.\n let result = INVALID_BYTE; // start with invalid character\n\n // c == 43 (c > 42 and c < 44)\n result += (((42 - c) & (c - 44)) >>> 8) & (-INVALID_BYTE + c - 43 + 62);\n // c == 47 (c > 46 and c < 48)\n result += (((46 - c) & (c - 48)) >>> 8) & (-INVALID_BYTE + c - 47 + 63);\n // c > 47 and c < 58\n result += (((47 - c) & (c - 58)) >>> 8) & (-INVALID_BYTE + c - 48 + 52);\n // c > 64 and c < 91\n result += (((64 - c) & (c - 91)) >>> 8) & (-INVALID_BYTE + c - 65 + 0);\n // c > 96 and c < 123\n result += (((96 - c) & (c - 123)) >>> 8) & (-INVALID_BYTE + c - 97 + 26);\n\n return result;\n }\n\n private _getPaddingLength(s: string): number {\n let paddingLength = 0;\n if (this._paddingCharacter) {\n for (let i = s.length - 1; i >= 0; i--) {\n if (s[i] !== this._paddingCharacter) {\n break;\n }\n paddingLength++;\n }\n if (s.length < 4 || paddingLength > 2) {\n throw new Error(\"Base64Coder: incorrect padding\");\n }\n }\n return paddingLength;\n }\n\n}\n\nconst stdCoder = new Coder();\n\nexport function encode(data: Uint8Array): string {\n return stdCoder.encode(data);\n}\n\nexport function decode(s: string): Uint8Array {\n return stdCoder.decode(s);\n}\n\n/**\n * Implements URL-safe Base64 encoding.\n * (Same as Base64, but '+' is replaced with '-', and '/' with '_').\n *\n * Operates in constant time.\n */\nexport class URLSafeCoder extends Coder {\n // URL-safe encoding have the following encoded/decoded ranges:\n //\n // ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 0123456789 - _\n // Index: 0 - 25 26 - 51 52 - 61 62 63\n // ASCII: 65 - 90 97 - 122 48 - 57 45 95\n //\n\n protected _encodeByte(b: number): string {\n let result = b;\n // b >= 0\n result += 65;\n // b > 25\n result += ((25 - b) >>> 8) & ((0 - 65) - 26 + 97);\n // b > 51\n result += ((51 - b) >>> 8) & ((26 - 97) - 52 + 48);\n // b > 61\n result += ((61 - b) >>> 8) & ((52 - 48) - 62 + 45);\n // b > 62\n result += ((62 - b) >>> 8) & ((62 - 45) - 63 + 95);\n\n return String.fromCharCode(result);\n }\n\n protected _decodeChar(c: number): number {\n let result = INVALID_BYTE;\n\n // c == 45 (c > 44 and c < 46)\n result += (((44 - c) & (c - 46)) >>> 8) & (-INVALID_BYTE + c - 45 + 62);\n // c == 95 (c > 94 and c < 96)\n result += (((94 - c) & (c - 96)) >>> 8) & (-INVALID_BYTE + c - 95 + 63);\n // c > 47 and c < 58\n result += (((47 - c) & (c - 58)) >>> 8) & (-INVALID_BYTE + c - 48 + 52);\n // c > 64 and c < 91\n result += (((64 - c) & (c - 91)) >>> 8) & (-INVALID_BYTE + c - 65 + 0);\n // c > 96 and c < 123\n result += (((96 - c) & (c - 123)) >>> 8) & (-INVALID_BYTE + c - 97 + 26);\n\n return result;\n }\n}\n\nconst urlSafeCoder = new URLSafeCoder();\n\nexport function encodeURLSafe(data: Uint8Array): string {\n return urlSafeCoder.encode(data);\n}\n\nexport function decodeURLSafe(s: string): Uint8Array {\n return urlSafeCoder.decode(s);\n}\n\n\nexport const encodedLength = (length: number) =>\n stdCoder.encodedLength(length);\n\nexport const maxDecodedLength = (length: number) =>\n stdCoder.maxDecodedLength(length);\n\nexport const decodedLength = (s: string) =>\n stdCoder.decodedLength(s);\n","// Copyright (C) 2016 Dmitry Chestnykh\n// MIT License. See LICENSE file for details.\n\n/**\n * Package utf8 implements UTF-8 encoding and decoding.\n */\n\nconst INVALID_UTF16 = \"utf8: invalid string\";\nconst INVALID_UTF8 = \"utf8: invalid source encoding\";\n\n/**\n * Encodes the given string into UTF-8 byte array.\n * Throws if the source string has invalid UTF-16 encoding.\n */\nexport function encode(s: string): Uint8Array {\n // Calculate result length and allocate output array.\n // encodedLength() also validates string and throws errors,\n // so we don't need repeat validation here.\n const arr = new Uint8Array(encodedLength(s));\n\n let pos = 0;\n for (let i = 0; i < s.length; i++) {\n let c = s.charCodeAt(i);\n if (c < 0x80) {\n arr[pos++] = c;\n } else if (c < 0x800) {\n arr[pos++] = 0xc0 | c >> 6;\n arr[pos++] = 0x80 | c & 0x3f;\n } else if (c < 0xd800) {\n arr[pos++] = 0xe0 | c >> 12;\n arr[pos++] = 0x80 | (c >> 6) & 0x3f;\n arr[pos++] = 0x80 | c & 0x3f;\n } else {\n i++; // get one more character\n c = (c & 0x3ff) << 10;\n c |= s.charCodeAt(i) & 0x3ff;\n c += 0x10000;\n\n arr[pos++] = 0xf0 | c >> 18;\n arr[pos++] = 0x80 | (c >> 12) & 0x3f;\n arr[pos++] = 0x80 | (c >> 6) & 0x3f;\n arr[pos++] = 0x80 | c & 0x3f;\n }\n }\n return arr;\n}\n\n/**\n * Returns the number of bytes required to encode the given string into UTF-8.\n * Throws if the source string has invalid UTF-16 encoding.\n */\nexport function encodedLength(s: string): number {\n let result = 0;\n for (let i = 0; i < s.length; i++) {\n const c = s.charCodeAt(i);\n if (c < 0x80) {\n result += 1;\n } else if (c < 0x800) {\n result += 2;\n } else if (c < 0xd800) {\n result += 3;\n } else if (c <= 0xdfff) {\n if (i >= s.length - 1) {\n throw new Error(INVALID_UTF16);\n }\n i++; // \"eat\" next character\n result += 4;\n } else {\n throw new Error(INVALID_UTF16);\n }\n }\n return result;\n}\n\n/**\n * Decodes the given byte array from UTF-8 into a string.\n * Throws if encoding is invalid.\n */\nexport function decode(arr: Uint8Array): string {\n const chars: string[] = [];\n for (let i = 0; i < arr.length; i++) {\n let b = arr[i];\n\n if (b & 0x80) {\n let min;\n if (b < 0xe0) {\n // Need 1 more byte.\n if (i >= arr.length) {\n throw new Error(INVALID_UTF8);\n }\n const n1 = arr[++i];\n if ((n1 & 0xc0) !== 0x80) {\n throw new Error(INVALID_UTF8);\n }\n b = (b & 0x1f) << 6 | (n1 & 0x3f);\n min = 0x80;\n } else if (b < 0xf0) {\n // Need 2 more bytes.\n if (i >= arr.length - 1) {\n throw new Error(INVALID_UTF8);\n }\n const n1 = arr[++i];\n const n2 = arr[++i];\n if ((n1 & 0xc0) !== 0x80 || (n2 & 0xc0) !== 0x80) {\n throw new Error(INVALID_UTF8);\n }\n b = (b & 0x0f) << 12 | (n1 & 0x3f) << 6 | (n2 & 0x3f);\n min = 0x800;\n } else if (b < 0xf8) {\n // Need 3 more bytes.\n if (i >= arr.length - 2) {\n throw new Error(INVALID_UTF8);\n }\n const n1 = arr[++i];\n const n2 = arr[++i];\n const n3 = arr[++i];\n if ((n1 & 0xc0) !== 0x80 || (n2 & 0xc0) !== 0x80 || (n3 & 0xc0) !== 0x80) {\n throw new Error(INVALID_UTF8);\n }\n b = (b & 0x0f) << 18 | (n1 & 0x3f) << 12 | (n2 & 0x3f) << 6 | (n3 & 0x3f);\n min = 0x10000;\n } else {\n throw new Error(INVALID_UTF8);\n }\n\n if (b < min || (b >= 0xd800 && b <= 0xdfff)) {\n throw new Error(INVALID_UTF8);\n }\n\n if (b >= 0x10000) {\n // Surrogate pair.\n if (b > 0x10ffff) {\n throw new Error(INVALID_UTF8);\n }\n b -= 0x10000;\n chars.push(String.fromCharCode(0xd800 | (b >> 10)));\n b = 0xdc00 | (b & 0x3ff);\n }\n }\n\n chars.push(String.fromCharCode(b));\n }\n return chars.join(\"\");\n}\n","(function(nacl) {\n'use strict';\n\n// Ported in 2014 by Dmitry Chestnykh and Devi Mandiri.\n// Public domain.\n//\n// Implementation derived from TweetNaCl version 20140427.\n// See for details: http://tweetnacl.cr.yp.to/\n\nvar gf = function(init) {\n var i, r = new Float64Array(16);\n if (init) for (i = 0; i < init.length; i++) r[i] = init[i];\n return r;\n};\n\n// Pluggable, initialized in high-level API below.\nvar randombytes = function(/* x, n */) { throw new Error('no PRNG'); };\n\nvar _0 = new Uint8Array(16);\nvar _9 = new Uint8Array(32); _9[0] = 9;\n\nvar gf0 = gf(),\n gf1 = gf([1]),\n _121665 = gf([0xdb41, 1]),\n D = gf([0x78a3, 0x1359, 0x4dca, 0x75eb, 0xd8ab, 0x4141, 0x0a4d, 0x0070, 0xe898, 0x7779, 0x4079, 0x8cc7, 0xfe73, 0x2b6f, 0x6cee, 0x5203]),\n D2 = gf([0xf159, 0x26b2, 0x9b94, 0xebd6, 0xb156, 0x8283, 0x149a, 0x00e0, 0xd130, 0xeef3, 0x80f2, 0x198e, 0xfce7, 0x56df, 0xd9dc, 0x2406]),\n X = gf([0xd51a, 0x8f25, 0x2d60, 0xc956, 0xa7b2, 0x9525, 0xc760, 0x692c, 0xdc5c, 0xfdd6, 0xe231, 0xc0a4, 0x53fe, 0xcd6e, 0x36d3, 0x2169]),\n Y = gf([0x6658, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666]),\n I = gf([0xa0b0, 0x4a0e, 0x1b27, 0xc4ee, 0xe478, 0xad2f, 0x1806, 0x2f43, 0xd7a7, 0x3dfb, 0x0099, 0x2b4d, 0xdf0b, 0x4fc1, 0x2480, 0x2b83]);\n\nfunction ts64(x, i, h, l) {\n x[i] = (h >> 24) & 0xff;\n x[i+1] = (h >> 16) & 0xff;\n x[i+2] = (h >> 8) & 0xff;\n x[i+3] = h & 0xff;\n x[i+4] = (l >> 24) & 0xff;\n x[i+5] = (l >> 16) & 0xff;\n x[i+6] = (l >> 8) & 0xff;\n x[i+7] = l & 0xff;\n}\n\nfunction vn(x, xi, y, yi, n) {\n var i,d = 0;\n for (i = 0; i < n; i++) d |= x[xi+i]^y[yi+i];\n return (1 & ((d - 1) >>> 8)) - 1;\n}\n\nfunction crypto_verify_16(x, xi, y, yi) {\n return vn(x,xi,y,yi,16);\n}\n\nfunction crypto_verify_32(x, xi, y, yi) {\n return vn(x,xi,y,yi,32);\n}\n\nfunction core_salsa20(o, p, k, c) {\n var j0 = c[ 0] & 0xff | (c[ 1] & 0xff)<<8 | (c[ 2] & 0xff)<<16 | (c[ 3] & 0xff)<<24,\n j1 = k[ 0] & 0xff | (k[ 1] & 0xff)<<8 | (k[ 2] & 0xff)<<16 | (k[ 3] & 0xff)<<24,\n j2 = k[ 4] & 0xff | (k[ 5] & 0xff)<<8 | (k[ 6] & 0xff)<<16 | (k[ 7] & 0xff)<<24,\n j3 = k[ 8] & 0xff | (k[ 9] & 0xff)<<8 | (k[10] & 0xff)<<16 | (k[11] & 0xff)<<24,\n j4 = k[12] & 0xff | (k[13] & 0xff)<<8 | (k[14] & 0xff)<<16 | (k[15] & 0xff)<<24,\n j5 = c[ 4] & 0xff | (c[ 5] & 0xff)<<8 | (c[ 6] & 0xff)<<16 | (c[ 7] & 0xff)<<24,\n j6 = p[ 0] & 0xff | (p[ 1] & 0xff)<<8 | (p[ 2] & 0xff)<<16 | (p[ 3] & 0xff)<<24,\n j7 = p[ 4] & 0xff | (p[ 5] & 0xff)<<8 | (p[ 6] & 0xff)<<16 | (p[ 7] & 0xff)<<24,\n j8 = p[ 8] & 0xff | (p[ 9] & 0xff)<<8 | (p[10] & 0xff)<<16 | (p[11] & 0xff)<<24,\n j9 = p[12] & 0xff | (p[13] & 0xff)<<8 | (p[14] & 0xff)<<16 | (p[15] & 0xff)<<24,\n j10 = c[ 8] & 0xff | (c[ 9] & 0xff)<<8 | (c[10] & 0xff)<<16 | (c[11] & 0xff)<<24,\n j11 = k[16] & 0xff | (k[17] & 0xff)<<8 | (k[18] & 0xff)<<16 | (k[19] & 0xff)<<24,\n j12 = k[20] & 0xff | (k[21] & 0xff)<<8 | (k[22] & 0xff)<<16 | (k[23] & 0xff)<<24,\n j13 = k[24] & 0xff | (k[25] & 0xff)<<8 | (k[26] & 0xff)<<16 | (k[27] & 0xff)<<24,\n j14 = k[28] & 0xff | (k[29] & 0xff)<<8 | (k[30] & 0xff)<<16 | (k[31] & 0xff)<<24,\n j15 = c[12] & 0xff | (c[13] & 0xff)<<8 | (c[14] & 0xff)<<16 | (c[15] & 0xff)<<24;\n\n var x0 = j0, x1 = j1, x2 = j2, x3 = j3, x4 = j4, x5 = j5, x6 = j6, x7 = j7,\n x8 = j8, x9 = j9, x10 = j10, x11 = j11, x12 = j12, x13 = j13, x14 = j14,\n x15 = j15, u;\n\n for (var i = 0; i < 20; i += 2) {\n u = x0 + x12 | 0;\n x4 ^= u<<7 | u>>>(32-7);\n u = x4 + x0 | 0;\n x8 ^= u<<9 | u>>>(32-9);\n u = x8 + x4 | 0;\n x12 ^= u<<13 | u>>>(32-13);\n u = x12 + x8 | 0;\n x0 ^= u<<18 | u>>>(32-18);\n\n u = x5 + x1 | 0;\n x9 ^= u<<7 | u>>>(32-7);\n u = x9 + x5 | 0;\n x13 ^= u<<9 | u>>>(32-9);\n u = x13 + x9 | 0;\n x1 ^= u<<13 | u>>>(32-13);\n u = x1 + x13 | 0;\n x5 ^= u<<18 | u>>>(32-18);\n\n u = x10 + x6 | 0;\n x14 ^= u<<7 | u>>>(32-7);\n u = x14 + x10 | 0;\n x2 ^= u<<9 | u>>>(32-9);\n u = x2 + x14 | 0;\n x6 ^= u<<13 | u>>>(32-13);\n u = x6 + x2 | 0;\n x10 ^= u<<18 | u>>>(32-18);\n\n u = x15 + x11 | 0;\n x3 ^= u<<7 | u>>>(32-7);\n u = x3 + x15 | 0;\n x7 ^= u<<9 | u>>>(32-9);\n u = x7 + x3 | 0;\n x11 ^= u<<13 | u>>>(32-13);\n u = x11 + x7 | 0;\n x15 ^= u<<18 | u>>>(32-18);\n\n u = x0 + x3 | 0;\n x1 ^= u<<7 | u>>>(32-7);\n u = x1 + x0 | 0;\n x2 ^= u<<9 | u>>>(32-9);\n u = x2 + x1 | 0;\n x3 ^= u<<13 | u>>>(32-13);\n u = x3 + x2 | 0;\n x0 ^= u<<18 | u>>>(32-18);\n\n u = x5 + x4 | 0;\n x6 ^= u<<7 | u>>>(32-7);\n u = x6 + x5 | 0;\n x7 ^= u<<9 | u>>>(32-9);\n u = x7 + x6 | 0;\n x4 ^= u<<13 | u>>>(32-13);\n u = x4 + x7 | 0;\n x5 ^= u<<18 | u>>>(32-18);\n\n u = x10 + x9 | 0;\n x11 ^= u<<7 | u>>>(32-7);\n u = x11 + x10 | 0;\n x8 ^= u<<9 | u>>>(32-9);\n u = x8 + x11 | 0;\n x9 ^= u<<13 | u>>>(32-13);\n u = x9 + x8 | 0;\n x10 ^= u<<18 | u>>>(32-18);\n\n u = x15 + x14 | 0;\n x12 ^= u<<7 | u>>>(32-7);\n u = x12 + x15 | 0;\n x13 ^= u<<9 | u>>>(32-9);\n u = x13 + x12 | 0;\n x14 ^= u<<13 | u>>>(32-13);\n u = x14 + x13 | 0;\n x15 ^= u<<18 | u>>>(32-18);\n }\n x0 = x0 + j0 | 0;\n x1 = x1 + j1 | 0;\n x2 = x2 + j2 | 0;\n x3 = x3 + j3 | 0;\n x4 = x4 + j4 | 0;\n x5 = x5 + j5 | 0;\n x6 = x6 + j6 | 0;\n x7 = x7 + j7 | 0;\n x8 = x8 + j8 | 0;\n x9 = x9 + j9 | 0;\n x10 = x10 + j10 | 0;\n x11 = x11 + j11 | 0;\n x12 = x12 + j12 | 0;\n x13 = x13 + j13 | 0;\n x14 = x14 + j14 | 0;\n x15 = x15 + j15 | 0;\n\n o[ 0] = x0 >>> 0 & 0xff;\n o[ 1] = x0 >>> 8 & 0xff;\n o[ 2] = x0 >>> 16 & 0xff;\n o[ 3] = x0 >>> 24 & 0xff;\n\n o[ 4] = x1 >>> 0 & 0xff;\n o[ 5] = x1 >>> 8 & 0xff;\n o[ 6] = x1 >>> 16 & 0xff;\n o[ 7] = x1 >>> 24 & 0xff;\n\n o[ 8] = x2 >>> 0 & 0xff;\n o[ 9] = x2 >>> 8 & 0xff;\n o[10] = x2 >>> 16 & 0xff;\n o[11] = x2 >>> 24 & 0xff;\n\n o[12] = x3 >>> 0 & 0xff;\n o[13] = x3 >>> 8 & 0xff;\n o[14] = x3 >>> 16 & 0xff;\n o[15] = x3 >>> 24 & 0xff;\n\n o[16] = x4 >>> 0 & 0xff;\n o[17] = x4 >>> 8 & 0xff;\n o[18] = x4 >>> 16 & 0xff;\n o[19] = x4 >>> 24 & 0xff;\n\n o[20] = x5 >>> 0 & 0xff;\n o[21] = x5 >>> 8 & 0xff;\n o[22] = x5 >>> 16 & 0xff;\n o[23] = x5 >>> 24 & 0xff;\n\n o[24] = x6 >>> 0 & 0xff;\n o[25] = x6 >>> 8 & 0xff;\n o[26] = x6 >>> 16 & 0xff;\n o[27] = x6 >>> 24 & 0xff;\n\n o[28] = x7 >>> 0 & 0xff;\n o[29] = x7 >>> 8 & 0xff;\n o[30] = x7 >>> 16 & 0xff;\n o[31] = x7 >>> 24 & 0xff;\n\n o[32] = x8 >>> 0 & 0xff;\n o[33] = x8 >>> 8 & 0xff;\n o[34] = x8 >>> 16 & 0xff;\n o[35] = x8 >>> 24 & 0xff;\n\n o[36] = x9 >>> 0 & 0xff;\n o[37] = x9 >>> 8 & 0xff;\n o[38] = x9 >>> 16 & 0xff;\n o[39] = x9 >>> 24 & 0xff;\n\n o[40] = x10 >>> 0 & 0xff;\n o[41] = x10 >>> 8 & 0xff;\n o[42] = x10 >>> 16 & 0xff;\n o[43] = x10 >>> 24 & 0xff;\n\n o[44] = x11 >>> 0 & 0xff;\n o[45] = x11 >>> 8 & 0xff;\n o[46] = x11 >>> 16 & 0xff;\n o[47] = x11 >>> 24 & 0xff;\n\n o[48] = x12 >>> 0 & 0xff;\n o[49] = x12 >>> 8 & 0xff;\n o[50] = x12 >>> 16 & 0xff;\n o[51] = x12 >>> 24 & 0xff;\n\n o[52] = x13 >>> 0 & 0xff;\n o[53] = x13 >>> 8 & 0xff;\n o[54] = x13 >>> 16 & 0xff;\n o[55] = x13 >>> 24 & 0xff;\n\n o[56] = x14 >>> 0 & 0xff;\n o[57] = x14 >>> 8 & 0xff;\n o[58] = x14 >>> 16 & 0xff;\n o[59] = x14 >>> 24 & 0xff;\n\n o[60] = x15 >>> 0 & 0xff;\n o[61] = x15 >>> 8 & 0xff;\n o[62] = x15 >>> 16 & 0xff;\n o[63] = x15 >>> 24 & 0xff;\n}\n\nfunction core_hsalsa20(o,p,k,c) {\n var j0 = c[ 0] & 0xff | (c[ 1] & 0xff)<<8 | (c[ 2] & 0xff)<<16 | (c[ 3] & 0xff)<<24,\n j1 = k[ 0] & 0xff | (k[ 1] & 0xff)<<8 | (k[ 2] & 0xff)<<16 | (k[ 3] & 0xff)<<24,\n j2 = k[ 4] & 0xff | (k[ 5] & 0xff)<<8 | (k[ 6] & 0xff)<<16 | (k[ 7] & 0xff)<<24,\n j3 = k[ 8] & 0xff | (k[ 9] & 0xff)<<8 | (k[10] & 0xff)<<16 | (k[11] & 0xff)<<24,\n j4 = k[12] & 0xff | (k[13] & 0xff)<<8 | (k[14] & 0xff)<<16 | (k[15] & 0xff)<<24,\n j5 = c[ 4] & 0xff | (c[ 5] & 0xff)<<8 | (c[ 6] & 0xff)<<16 | (c[ 7] & 0xff)<<24,\n j6 = p[ 0] & 0xff | (p[ 1] & 0xff)<<8 | (p[ 2] & 0xff)<<16 | (p[ 3] & 0xff)<<24,\n j7 = p[ 4] & 0xff | (p[ 5] & 0xff)<<8 | (p[ 6] & 0xff)<<16 | (p[ 7] & 0xff)<<24,\n j8 = p[ 8] & 0xff | (p[ 9] & 0xff)<<8 | (p[10] & 0xff)<<16 | (p[11] & 0xff)<<24,\n j9 = p[12] & 0xff | (p[13] & 0xff)<<8 | (p[14] & 0xff)<<16 | (p[15] & 0xff)<<24,\n j10 = c[ 8] & 0xff | (c[ 9] & 0xff)<<8 | (c[10] & 0xff)<<16 | (c[11] & 0xff)<<24,\n j11 = k[16] & 0xff | (k[17] & 0xff)<<8 | (k[18] & 0xff)<<16 | (k[19] & 0xff)<<24,\n j12 = k[20] & 0xff | (k[21] & 0xff)<<8 | (k[22] & 0xff)<<16 | (k[23] & 0xff)<<24,\n j13 = k[24] & 0xff | (k[25] & 0xff)<<8 | (k[26] & 0xff)<<16 | (k[27] & 0xff)<<24,\n j14 = k[28] & 0xff | (k[29] & 0xff)<<8 | (k[30] & 0xff)<<16 | (k[31] & 0xff)<<24,\n j15 = c[12] & 0xff | (c[13] & 0xff)<<8 | (c[14] & 0xff)<<16 | (c[15] & 0xff)<<24;\n\n var x0 = j0, x1 = j1, x2 = j2, x3 = j3, x4 = j4, x5 = j5, x6 = j6, x7 = j7,\n x8 = j8, x9 = j9, x10 = j10, x11 = j11, x12 = j12, x13 = j13, x14 = j14,\n x15 = j15, u;\n\n for (var i = 0; i < 20; i += 2) {\n u = x0 + x12 | 0;\n x4 ^= u<<7 | u>>>(32-7);\n u = x4 + x0 | 0;\n x8 ^= u<<9 | u>>>(32-9);\n u = x8 + x4 | 0;\n x12 ^= u<<13 | u>>>(32-13);\n u = x12 + x8 | 0;\n x0 ^= u<<18 | u>>>(32-18);\n\n u = x5 + x1 | 0;\n x9 ^= u<<7 | u>>>(32-7);\n u = x9 + x5 | 0;\n x13 ^= u<<9 | u>>>(32-9);\n u = x13 + x9 | 0;\n x1 ^= u<<13 | u>>>(32-13);\n u = x1 + x13 | 0;\n x5 ^= u<<18 | u>>>(32-18);\n\n u = x10 + x6 | 0;\n x14 ^= u<<7 | u>>>(32-7);\n u = x14 + x10 | 0;\n x2 ^= u<<9 | u>>>(32-9);\n u = x2 + x14 | 0;\n x6 ^= u<<13 | u>>>(32-13);\n u = x6 + x2 | 0;\n x10 ^= u<<18 | u>>>(32-18);\n\n u = x15 + x11 | 0;\n x3 ^= u<<7 | u>>>(32-7);\n u = x3 + x15 | 0;\n x7 ^= u<<9 | u>>>(32-9);\n u = x7 + x3 | 0;\n x11 ^= u<<13 | u>>>(32-13);\n u = x11 + x7 | 0;\n x15 ^= u<<18 | u>>>(32-18);\n\n u = x0 + x3 | 0;\n x1 ^= u<<7 | u>>>(32-7);\n u = x1 + x0 | 0;\n x2 ^= u<<9 | u>>>(32-9);\n u = x2 + x1 | 0;\n x3 ^= u<<13 | u>>>(32-13);\n u = x3 + x2 | 0;\n x0 ^= u<<18 | u>>>(32-18);\n\n u = x5 + x4 | 0;\n x6 ^= u<<7 | u>>>(32-7);\n u = x6 + x5 | 0;\n x7 ^= u<<9 | u>>>(32-9);\n u = x7 + x6 | 0;\n x4 ^= u<<13 | u>>>(32-13);\n u = x4 + x7 | 0;\n x5 ^= u<<18 | u>>>(32-18);\n\n u = x10 + x9 | 0;\n x11 ^= u<<7 | u>>>(32-7);\n u = x11 + x10 | 0;\n x8 ^= u<<9 | u>>>(32-9);\n u = x8 + x11 | 0;\n x9 ^= u<<13 | u>>>(32-13);\n u = x9 + x8 | 0;\n x10 ^= u<<18 | u>>>(32-18);\n\n u = x15 + x14 | 0;\n x12 ^= u<<7 | u>>>(32-7);\n u = x12 + x15 | 0;\n x13 ^= u<<9 | u>>>(32-9);\n u = x13 + x12 | 0;\n x14 ^= u<<13 | u>>>(32-13);\n u = x14 + x13 | 0;\n x15 ^= u<<18 | u>>>(32-18);\n }\n\n o[ 0] = x0 >>> 0 & 0xff;\n o[ 1] = x0 >>> 8 & 0xff;\n o[ 2] = x0 >>> 16 & 0xff;\n o[ 3] = x0 >>> 24 & 0xff;\n\n o[ 4] = x5 >>> 0 & 0xff;\n o[ 5] = x5 >>> 8 & 0xff;\n o[ 6] = x5 >>> 16 & 0xff;\n o[ 7] = x5 >>> 24 & 0xff;\n\n o[ 8] = x10 >>> 0 & 0xff;\n o[ 9] = x10 >>> 8 & 0xff;\n o[10] = x10 >>> 16 & 0xff;\n o[11] = x10 >>> 24 & 0xff;\n\n o[12] = x15 >>> 0 & 0xff;\n o[13] = x15 >>> 8 & 0xff;\n o[14] = x15 >>> 16 & 0xff;\n o[15] = x15 >>> 24 & 0xff;\n\n o[16] = x6 >>> 0 & 0xff;\n o[17] = x6 >>> 8 & 0xff;\n o[18] = x6 >>> 16 & 0xff;\n o[19] = x6 >>> 24 & 0xff;\n\n o[20] = x7 >>> 0 & 0xff;\n o[21] = x7 >>> 8 & 0xff;\n o[22] = x7 >>> 16 & 0xff;\n o[23] = x7 >>> 24 & 0xff;\n\n o[24] = x8 >>> 0 & 0xff;\n o[25] = x8 >>> 8 & 0xff;\n o[26] = x8 >>> 16 & 0xff;\n o[27] = x8 >>> 24 & 0xff;\n\n o[28] = x9 >>> 0 & 0xff;\n o[29] = x9 >>> 8 & 0xff;\n o[30] = x9 >>> 16 & 0xff;\n o[31] = x9 >>> 24 & 0xff;\n}\n\nfunction crypto_core_salsa20(out,inp,k,c) {\n core_salsa20(out,inp,k,c);\n}\n\nfunction crypto_core_hsalsa20(out,inp,k,c) {\n core_hsalsa20(out,inp,k,c);\n}\n\nvar sigma = new Uint8Array([101, 120, 112, 97, 110, 100, 32, 51, 50, 45, 98, 121, 116, 101, 32, 107]);\n // \"expand 32-byte k\"\n\nfunction crypto_stream_salsa20_xor(c,cpos,m,mpos,b,n,k) {\n var z = new Uint8Array(16), x = new Uint8Array(64);\n var u, i;\n for (i = 0; i < 16; i++) z[i] = 0;\n for (i = 0; i < 8; i++) z[i] = n[i];\n while (b >= 64) {\n crypto_core_salsa20(x,z,k,sigma);\n for (i = 0; i < 64; i++) c[cpos+i] = m[mpos+i] ^ x[i];\n u = 1;\n for (i = 8; i < 16; i++) {\n u = u + (z[i] & 0xff) | 0;\n z[i] = u & 0xff;\n u >>>= 8;\n }\n b -= 64;\n cpos += 64;\n mpos += 64;\n }\n if (b > 0) {\n crypto_core_salsa20(x,z,k,sigma);\n for (i = 0; i < b; i++) c[cpos+i] = m[mpos+i] ^ x[i];\n }\n return 0;\n}\n\nfunction crypto_stream_salsa20(c,cpos,b,n,k) {\n var z = new Uint8Array(16), x = new Uint8Array(64);\n var u, i;\n for (i = 0; i < 16; i++) z[i] = 0;\n for (i = 0; i < 8; i++) z[i] = n[i];\n while (b >= 64) {\n crypto_core_salsa20(x,z,k,sigma);\n for (i = 0; i < 64; i++) c[cpos+i] = x[i];\n u = 1;\n for (i = 8; i < 16; i++) {\n u = u + (z[i] & 0xff) | 0;\n z[i] = u & 0xff;\n u >>>= 8;\n }\n b -= 64;\n cpos += 64;\n }\n if (b > 0) {\n crypto_core_salsa20(x,z,k,sigma);\n for (i = 0; i < b; i++) c[cpos+i] = x[i];\n }\n return 0;\n}\n\nfunction crypto_stream(c,cpos,d,n,k) {\n var s = new Uint8Array(32);\n crypto_core_hsalsa20(s,n,k,sigma);\n var sn = new Uint8Array(8);\n for (var i = 0; i < 8; i++) sn[i] = n[i+16];\n return crypto_stream_salsa20(c,cpos,d,sn,s);\n}\n\nfunction crypto_stream_xor(c,cpos,m,mpos,d,n,k) {\n var s = new Uint8Array(32);\n crypto_core_hsalsa20(s,n,k,sigma);\n var sn = new Uint8Array(8);\n for (var i = 0; i < 8; i++) sn[i] = n[i+16];\n return crypto_stream_salsa20_xor(c,cpos,m,mpos,d,sn,s);\n}\n\n/*\n* Port of Andrew Moon's Poly1305-donna-16. Public domain.\n* https://github.com/floodyberry/poly1305-donna\n*/\n\nvar poly1305 = function(key) {\n this.buffer = new Uint8Array(16);\n this.r = new Uint16Array(10);\n this.h = new Uint16Array(10);\n this.pad = new Uint16Array(8);\n this.leftover = 0;\n this.fin = 0;\n\n var t0, t1, t2, t3, t4, t5, t6, t7;\n\n t0 = key[ 0] & 0xff | (key[ 1] & 0xff) << 8; this.r[0] = ( t0 ) & 0x1fff;\n t1 = key[ 2] & 0xff | (key[ 3] & 0xff) << 8; this.r[1] = ((t0 >>> 13) | (t1 << 3)) & 0x1fff;\n t2 = key[ 4] & 0xff | (key[ 5] & 0xff) << 8; this.r[2] = ((t1 >>> 10) | (t2 << 6)) & 0x1f03;\n t3 = key[ 6] & 0xff | (key[ 7] & 0xff) << 8; this.r[3] = ((t2 >>> 7) | (t3 << 9)) & 0x1fff;\n t4 = key[ 8] & 0xff | (key[ 9] & 0xff) << 8; this.r[4] = ((t3 >>> 4) | (t4 << 12)) & 0x00ff;\n this.r[5] = ((t4 >>> 1)) & 0x1ffe;\n t5 = key[10] & 0xff | (key[11] & 0xff) << 8; this.r[6] = ((t4 >>> 14) | (t5 << 2)) & 0x1fff;\n t6 = key[12] & 0xff | (key[13] & 0xff) << 8; this.r[7] = ((t5 >>> 11) | (t6 << 5)) & 0x1f81;\n t7 = key[14] & 0xff | (key[15] & 0xff) << 8; this.r[8] = ((t6 >>> 8) | (t7 << 8)) & 0x1fff;\n this.r[9] = ((t7 >>> 5)) & 0x007f;\n\n this.pad[0] = key[16] & 0xff | (key[17] & 0xff) << 8;\n this.pad[1] = key[18] & 0xff | (key[19] & 0xff) << 8;\n this.pad[2] = key[20] & 0xff | (key[21] & 0xff) << 8;\n this.pad[3] = key[22] & 0xff | (key[23] & 0xff) << 8;\n this.pad[4] = key[24] & 0xff | (key[25] & 0xff) << 8;\n this.pad[5] = key[26] & 0xff | (key[27] & 0xff) << 8;\n this.pad[6] = key[28] & 0xff | (key[29] & 0xff) << 8;\n this.pad[7] = key[30] & 0xff | (key[31] & 0xff) << 8;\n};\n\npoly1305.prototype.blocks = function(m, mpos, bytes) {\n var hibit = this.fin ? 0 : (1 << 11);\n var t0, t1, t2, t3, t4, t5, t6, t7, c;\n var d0, d1, d2, d3, d4, d5, d6, d7, d8, d9;\n\n var h0 = this.h[0],\n h1 = this.h[1],\n h2 = this.h[2],\n h3 = this.h[3],\n h4 = this.h[4],\n h5 = this.h[5],\n h6 = this.h[6],\n h7 = this.h[7],\n h8 = this.h[8],\n h9 = this.h[9];\n\n var r0 = this.r[0],\n r1 = this.r[1],\n r2 = this.r[2],\n r3 = this.r[3],\n r4 = this.r[4],\n r5 = this.r[5],\n r6 = this.r[6],\n r7 = this.r[7],\n r8 = this.r[8],\n r9 = this.r[9];\n\n while (bytes >= 16) {\n t0 = m[mpos+ 0] & 0xff | (m[mpos+ 1] & 0xff) << 8; h0 += ( t0 ) & 0x1fff;\n t1 = m[mpos+ 2] & 0xff | (m[mpos+ 3] & 0xff) << 8; h1 += ((t0 >>> 13) | (t1 << 3)) & 0x1fff;\n t2 = m[mpos+ 4] & 0xff | (m[mpos+ 5] & 0xff) << 8; h2 += ((t1 >>> 10) | (t2 << 6)) & 0x1fff;\n t3 = m[mpos+ 6] & 0xff | (m[mpos+ 7] & 0xff) << 8; h3 += ((t2 >>> 7) | (t3 << 9)) & 0x1fff;\n t4 = m[mpos+ 8] & 0xff | (m[mpos+ 9] & 0xff) << 8; h4 += ((t3 >>> 4) | (t4 << 12)) & 0x1fff;\n h5 += ((t4 >>> 1)) & 0x1fff;\n t5 = m[mpos+10] & 0xff | (m[mpos+11] & 0xff) << 8; h6 += ((t4 >>> 14) | (t5 << 2)) & 0x1fff;\n t6 = m[mpos+12] & 0xff | (m[mpos+13] & 0xff) << 8; h7 += ((t5 >>> 11) | (t6 << 5)) & 0x1fff;\n t7 = m[mpos+14] & 0xff | (m[mpos+15] & 0xff) << 8; h8 += ((t6 >>> 8) | (t7 << 8)) & 0x1fff;\n h9 += ((t7 >>> 5)) | hibit;\n\n c = 0;\n\n d0 = c;\n d0 += h0 * r0;\n d0 += h1 * (5 * r9);\n d0 += h2 * (5 * r8);\n d0 += h3 * (5 * r7);\n d0 += h4 * (5 * r6);\n c = (d0 >>> 13); d0 &= 0x1fff;\n d0 += h5 * (5 * r5);\n d0 += h6 * (5 * r4);\n d0 += h7 * (5 * r3);\n d0 += h8 * (5 * r2);\n d0 += h9 * (5 * r1);\n c += (d0 >>> 13); d0 &= 0x1fff;\n\n d1 = c;\n d1 += h0 * r1;\n d1 += h1 * r0;\n d1 += h2 * (5 * r9);\n d1 += h3 * (5 * r8);\n d1 += h4 * (5 * r7);\n c = (d1 >>> 13); d1 &= 0x1fff;\n d1 += h5 * (5 * r6);\n d1 += h6 * (5 * r5);\n d1 += h7 * (5 * r4);\n d1 += h8 * (5 * r3);\n d1 += h9 * (5 * r2);\n c += (d1 >>> 13); d1 &= 0x1fff;\n\n d2 = c;\n d2 += h0 * r2;\n d2 += h1 * r1;\n d2 += h2 * r0;\n d2 += h3 * (5 * r9);\n d2 += h4 * (5 * r8);\n c = (d2 >>> 13); d2 &= 0x1fff;\n d2 += h5 * (5 * r7);\n d2 += h6 * (5 * r6);\n d2 += h7 * (5 * r5);\n d2 += h8 * (5 * r4);\n d2 += h9 * (5 * r3);\n c += (d2 >>> 13); d2 &= 0x1fff;\n\n d3 = c;\n d3 += h0 * r3;\n d3 += h1 * r2;\n d3 += h2 * r1;\n d3 += h3 * r0;\n d3 += h4 * (5 * r9);\n c = (d3 >>> 13); d3 &= 0x1fff;\n d3 += h5 * (5 * r8);\n d3 += h6 * (5 * r7);\n d3 += h7 * (5 * r6);\n d3 += h8 * (5 * r5);\n d3 += h9 * (5 * r4);\n c += (d3 >>> 13); d3 &= 0x1fff;\n\n d4 = c;\n d4 += h0 * r4;\n d4 += h1 * r3;\n d4 += h2 * r2;\n d4 += h3 * r1;\n d4 += h4 * r0;\n c = (d4 >>> 13); d4 &= 0x1fff;\n d4 += h5 * (5 * r9);\n d4 += h6 * (5 * r8);\n d4 += h7 * (5 * r7);\n d4 += h8 * (5 * r6);\n d4 += h9 * (5 * r5);\n c += (d4 >>> 13); d4 &= 0x1fff;\n\n d5 = c;\n d5 += h0 * r5;\n d5 += h1 * r4;\n d5 += h2 * r3;\n d5 += h3 * r2;\n d5 += h4 * r1;\n c = (d5 >>> 13); d5 &= 0x1fff;\n d5 += h5 * r0;\n d5 += h6 * (5 * r9);\n d5 += h7 * (5 * r8);\n d5 += h8 * (5 * r7);\n d5 += h9 * (5 * r6);\n c += (d5 >>> 13); d5 &= 0x1fff;\n\n d6 = c;\n d6 += h0 * r6;\n d6 += h1 * r5;\n d6 += h2 * r4;\n d6 += h3 * r3;\n d6 += h4 * r2;\n c = (d6 >>> 13); d6 &= 0x1fff;\n d6 += h5 * r1;\n d6 += h6 * r0;\n d6 += h7 * (5 * r9);\n d6 += h8 * (5 * r8);\n d6 += h9 * (5 * r7);\n c += (d6 >>> 13); d6 &= 0x1fff;\n\n d7 = c;\n d7 += h0 * r7;\n d7 += h1 * r6;\n d7 += h2 * r5;\n d7 += h3 * r4;\n d7 += h4 * r3;\n c = (d7 >>> 13); d7 &= 0x1fff;\n d7 += h5 * r2;\n d7 += h6 * r1;\n d7 += h7 * r0;\n d7 += h8 * (5 * r9);\n d7 += h9 * (5 * r8);\n c += (d7 >>> 13); d7 &= 0x1fff;\n\n d8 = c;\n d8 += h0 * r8;\n d8 += h1 * r7;\n d8 += h2 * r6;\n d8 += h3 * r5;\n d8 += h4 * r4;\n c = (d8 >>> 13); d8 &= 0x1fff;\n d8 += h5 * r3;\n d8 += h6 * r2;\n d8 += h7 * r1;\n d8 += h8 * r0;\n d8 += h9 * (5 * r9);\n c += (d8 >>> 13); d8 &= 0x1fff;\n\n d9 = c;\n d9 += h0 * r9;\n d9 += h1 * r8;\n d9 += h2 * r7;\n d9 += h3 * r6;\n d9 += h4 * r5;\n c = (d9 >>> 13); d9 &= 0x1fff;\n d9 += h5 * r4;\n d9 += h6 * r3;\n d9 += h7 * r2;\n d9 += h8 * r1;\n d9 += h9 * r0;\n c += (d9 >>> 13); d9 &= 0x1fff;\n\n c = (((c << 2) + c)) | 0;\n c = (c + d0) | 0;\n d0 = c & 0x1fff;\n c = (c >>> 13);\n d1 += c;\n\n h0 = d0;\n h1 = d1;\n h2 = d2;\n h3 = d3;\n h4 = d4;\n h5 = d5;\n h6 = d6;\n h7 = d7;\n h8 = d8;\n h9 = d9;\n\n mpos += 16;\n bytes -= 16;\n }\n this.h[0] = h0;\n this.h[1] = h1;\n this.h[2] = h2;\n this.h[3] = h3;\n this.h[4] = h4;\n this.h[5] = h5;\n this.h[6] = h6;\n this.h[7] = h7;\n this.h[8] = h8;\n this.h[9] = h9;\n};\n\npoly1305.prototype.finish = function(mac, macpos) {\n var g = new Uint16Array(10);\n var c, mask, f, i;\n\n if (this.leftover) {\n i = this.leftover;\n this.buffer[i++] = 1;\n for (; i < 16; i++) this.buffer[i] = 0;\n this.fin = 1;\n this.blocks(this.buffer, 0, 16);\n }\n\n c = this.h[1] >>> 13;\n this.h[1] &= 0x1fff;\n for (i = 2; i < 10; i++) {\n this.h[i] += c;\n c = this.h[i] >>> 13;\n this.h[i] &= 0x1fff;\n }\n this.h[0] += (c * 5);\n c = this.h[0] >>> 13;\n this.h[0] &= 0x1fff;\n this.h[1] += c;\n c = this.h[1] >>> 13;\n this.h[1] &= 0x1fff;\n this.h[2] += c;\n\n g[0] = this.h[0] + 5;\n c = g[0] >>> 13;\n g[0] &= 0x1fff;\n for (i = 1; i < 10; i++) {\n g[i] = this.h[i] + c;\n c = g[i] >>> 13;\n g[i] &= 0x1fff;\n }\n g[9] -= (1 << 13);\n\n mask = (c ^ 1) - 1;\n for (i = 0; i < 10; i++) g[i] &= mask;\n mask = ~mask;\n for (i = 0; i < 10; i++) this.h[i] = (this.h[i] & mask) | g[i];\n\n this.h[0] = ((this.h[0] ) | (this.h[1] << 13) ) & 0xffff;\n this.h[1] = ((this.h[1] >>> 3) | (this.h[2] << 10) ) & 0xffff;\n this.h[2] = ((this.h[2] >>> 6) | (this.h[3] << 7) ) & 0xffff;\n this.h[3] = ((this.h[3] >>> 9) | (this.h[4] << 4) ) & 0xffff;\n this.h[4] = ((this.h[4] >>> 12) | (this.h[5] << 1) | (this.h[6] << 14)) & 0xffff;\n this.h[5] = ((this.h[6] >>> 2) | (this.h[7] << 11) ) & 0xffff;\n this.h[6] = ((this.h[7] >>> 5) | (this.h[8] << 8) ) & 0xffff;\n this.h[7] = ((this.h[8] >>> 8) | (this.h[9] << 5) ) & 0xffff;\n\n f = this.h[0] + this.pad[0];\n this.h[0] = f & 0xffff;\n for (i = 1; i < 8; i++) {\n f = (((this.h[i] + this.pad[i]) | 0) + (f >>> 16)) | 0;\n this.h[i] = f & 0xffff;\n }\n\n mac[macpos+ 0] = (this.h[0] >>> 0) & 0xff;\n mac[macpos+ 1] = (this.h[0] >>> 8) & 0xff;\n mac[macpos+ 2] = (this.h[1] >>> 0) & 0xff;\n mac[macpos+ 3] = (this.h[1] >>> 8) & 0xff;\n mac[macpos+ 4] = (this.h[2] >>> 0) & 0xff;\n mac[macpos+ 5] = (this.h[2] >>> 8) & 0xff;\n mac[macpos+ 6] = (this.h[3] >>> 0) & 0xff;\n mac[macpos+ 7] = (this.h[3] >>> 8) & 0xff;\n mac[macpos+ 8] = (this.h[4] >>> 0) & 0xff;\n mac[macpos+ 9] = (this.h[4] >>> 8) & 0xff;\n mac[macpos+10] = (this.h[5] >>> 0) & 0xff;\n mac[macpos+11] = (this.h[5] >>> 8) & 0xff;\n mac[macpos+12] = (this.h[6] >>> 0) & 0xff;\n mac[macpos+13] = (this.h[6] >>> 8) & 0xff;\n mac[macpos+14] = (this.h[7] >>> 0) & 0xff;\n mac[macpos+15] = (this.h[7] >>> 8) & 0xff;\n};\n\npoly1305.prototype.update = function(m, mpos, bytes) {\n var i, want;\n\n if (this.leftover) {\n want = (16 - this.leftover);\n if (want > bytes)\n want = bytes;\n for (i = 0; i < want; i++)\n this.buffer[this.leftover + i] = m[mpos+i];\n bytes -= want;\n mpos += want;\n this.leftover += want;\n if (this.leftover < 16)\n return;\n this.blocks(this.buffer, 0, 16);\n this.leftover = 0;\n }\n\n if (bytes >= 16) {\n want = bytes - (bytes % 16);\n this.blocks(m, mpos, want);\n mpos += want;\n bytes -= want;\n }\n\n if (bytes) {\n for (i = 0; i < bytes; i++)\n this.buffer[this.leftover + i] = m[mpos+i];\n this.leftover += bytes;\n }\n};\n\nfunction crypto_onetimeauth(out, outpos, m, mpos, n, k) {\n var s = new poly1305(k);\n s.update(m, mpos, n);\n s.finish(out, outpos);\n return 0;\n}\n\nfunction crypto_onetimeauth_verify(h, hpos, m, mpos, n, k) {\n var x = new Uint8Array(16);\n crypto_onetimeauth(x,0,m,mpos,n,k);\n return crypto_verify_16(h,hpos,x,0);\n}\n\nfunction crypto_secretbox(c,m,d,n,k) {\n var i;\n if (d < 32) return -1;\n crypto_stream_xor(c,0,m,0,d,n,k);\n crypto_onetimeauth(c, 16, c, 32, d - 32, c);\n for (i = 0; i < 16; i++) c[i] = 0;\n return 0;\n}\n\nfunction crypto_secretbox_open(m,c,d,n,k) {\n var i;\n var x = new Uint8Array(32);\n if (d < 32) return -1;\n crypto_stream(x,0,32,n,k);\n if (crypto_onetimeauth_verify(c, 16,c, 32,d - 32,x) !== 0) return -1;\n crypto_stream_xor(m,0,c,0,d,n,k);\n for (i = 0; i < 32; i++) m[i] = 0;\n return 0;\n}\n\nfunction set25519(r, a) {\n var i;\n for (i = 0; i < 16; i++) r[i] = a[i]|0;\n}\n\nfunction car25519(o) {\n var i, v, c = 1;\n for (i = 0; i < 16; i++) {\n v = o[i] + c + 65535;\n c = Math.floor(v / 65536);\n o[i] = v - c * 65536;\n }\n o[0] += c-1 + 37 * (c-1);\n}\n\nfunction sel25519(p, q, b) {\n var t, c = ~(b-1);\n for (var i = 0; i < 16; i++) {\n t = c & (p[i] ^ q[i]);\n p[i] ^= t;\n q[i] ^= t;\n }\n}\n\nfunction pack25519(o, n) {\n var i, j, b;\n var m = gf(), t = gf();\n for (i = 0; i < 16; i++) t[i] = n[i];\n car25519(t);\n car25519(t);\n car25519(t);\n for (j = 0; j < 2; j++) {\n m[0] = t[0] - 0xffed;\n for (i = 1; i < 15; i++) {\n m[i] = t[i] - 0xffff - ((m[i-1]>>16) & 1);\n m[i-1] &= 0xffff;\n }\n m[15] = t[15] - 0x7fff - ((m[14]>>16) & 1);\n b = (m[15]>>16) & 1;\n m[14] &= 0xffff;\n sel25519(t, m, 1-b);\n }\n for (i = 0; i < 16; i++) {\n o[2*i] = t[i] & 0xff;\n o[2*i+1] = t[i]>>8;\n }\n}\n\nfunction neq25519(a, b) {\n var c = new Uint8Array(32), d = new Uint8Array(32);\n pack25519(c, a);\n pack25519(d, b);\n return crypto_verify_32(c, 0, d, 0);\n}\n\nfunction par25519(a) {\n var d = new Uint8Array(32);\n pack25519(d, a);\n return d[0] & 1;\n}\n\nfunction unpack25519(o, n) {\n var i;\n for (i = 0; i < 16; i++) o[i] = n[2*i] + (n[2*i+1] << 8);\n o[15] &= 0x7fff;\n}\n\nfunction A(o, a, b) {\n for (var i = 0; i < 16; i++) o[i] = a[i] + b[i];\n}\n\nfunction Z(o, a, b) {\n for (var i = 0; i < 16; i++) o[i] = a[i] - b[i];\n}\n\nfunction M(o, a, b) {\n var v, c,\n t0 = 0, t1 = 0, t2 = 0, t3 = 0, t4 = 0, t5 = 0, t6 = 0, t7 = 0,\n t8 = 0, t9 = 0, t10 = 0, t11 = 0, t12 = 0, t13 = 0, t14 = 0, t15 = 0,\n t16 = 0, t17 = 0, t18 = 0, t19 = 0, t20 = 0, t21 = 0, t22 = 0, t23 = 0,\n t24 = 0, t25 = 0, t26 = 0, t27 = 0, t28 = 0, t29 = 0, t30 = 0,\n b0 = b[0],\n b1 = b[1],\n b2 = b[2],\n b3 = b[3],\n b4 = b[4],\n b5 = b[5],\n b6 = b[6],\n b7 = b[7],\n b8 = b[8],\n b9 = b[9],\n b10 = b[10],\n b11 = b[11],\n b12 = b[12],\n b13 = b[13],\n b14 = b[14],\n b15 = b[15];\n\n v = a[0];\n t0 += v * b0;\n t1 += v * b1;\n t2 += v * b2;\n t3 += v * b3;\n t4 += v * b4;\n t5 += v * b5;\n t6 += v * b6;\n t7 += v * b7;\n t8 += v * b8;\n t9 += v * b9;\n t10 += v * b10;\n t11 += v * b11;\n t12 += v * b12;\n t13 += v * b13;\n t14 += v * b14;\n t15 += v * b15;\n v = a[1];\n t1 += v * b0;\n t2 += v * b1;\n t3 += v * b2;\n t4 += v * b3;\n t5 += v * b4;\n t6 += v * b5;\n t7 += v * b6;\n t8 += v * b7;\n t9 += v * b8;\n t10 += v * b9;\n t11 += v * b10;\n t12 += v * b11;\n t13 += v * b12;\n t14 += v * b13;\n t15 += v * b14;\n t16 += v * b15;\n v = a[2];\n t2 += v * b0;\n t3 += v * b1;\n t4 += v * b2;\n t5 += v * b3;\n t6 += v * b4;\n t7 += v * b5;\n t8 += v * b6;\n t9 += v * b7;\n t10 += v * b8;\n t11 += v * b9;\n t12 += v * b10;\n t13 += v * b11;\n t14 += v * b12;\n t15 += v * b13;\n t16 += v * b14;\n t17 += v * b15;\n v = a[3];\n t3 += v * b0;\n t4 += v * b1;\n t5 += v * b2;\n t6 += v * b3;\n t7 += v * b4;\n t8 += v * b5;\n t9 += v * b6;\n t10 += v * b7;\n t11 += v * b8;\n t12 += v * b9;\n t13 += v * b10;\n t14 += v * b11;\n t15 += v * b12;\n t16 += v * b13;\n t17 += v * b14;\n t18 += v * b15;\n v = a[4];\n t4 += v * b0;\n t5 += v * b1;\n t6 += v * b2;\n t7 += v * b3;\n t8 += v * b4;\n t9 += v * b5;\n t10 += v * b6;\n t11 += v * b7;\n t12 += v * b8;\n t13 += v * b9;\n t14 += v * b10;\n t15 += v * b11;\n t16 += v * b12;\n t17 += v * b13;\n t18 += v * b14;\n t19 += v * b15;\n v = a[5];\n t5 += v * b0;\n t6 += v * b1;\n t7 += v * b2;\n t8 += v * b3;\n t9 += v * b4;\n t10 += v * b5;\n t11 += v * b6;\n t12 += v * b7;\n t13 += v * b8;\n t14 += v * b9;\n t15 += v * b10;\n t16 += v * b11;\n t17 += v * b12;\n t18 += v * b13;\n t19 += v * b14;\n t20 += v * b15;\n v = a[6];\n t6 += v * b0;\n t7 += v * b1;\n t8 += v * b2;\n t9 += v * b3;\n t10 += v * b4;\n t11 += v * b5;\n t12 += v * b6;\n t13 += v * b7;\n t14 += v * b8;\n t15 += v * b9;\n t16 += v * b10;\n t17 += v * b11;\n t18 += v * b12;\n t19 += v * b13;\n t20 += v * b14;\n t21 += v * b15;\n v = a[7];\n t7 += v * b0;\n t8 += v * b1;\n t9 += v * b2;\n t10 += v * b3;\n t11 += v * b4;\n t12 += v * b5;\n t13 += v * b6;\n t14 += v * b7;\n t15 += v * b8;\n t16 += v * b9;\n t17 += v * b10;\n t18 += v * b11;\n t19 += v * b12;\n t20 += v * b13;\n t21 += v * b14;\n t22 += v * b15;\n v = a[8];\n t8 += v * b0;\n t9 += v * b1;\n t10 += v * b2;\n t11 += v * b3;\n t12 += v * b4;\n t13 += v * b5;\n t14 += v * b6;\n t15 += v * b7;\n t16 += v * b8;\n t17 += v * b9;\n t18 += v * b10;\n t19 += v * b11;\n t20 += v * b12;\n t21 += v * b13;\n t22 += v * b14;\n t23 += v * b15;\n v = a[9];\n t9 += v * b0;\n t10 += v * b1;\n t11 += v * b2;\n t12 += v * b3;\n t13 += v * b4;\n t14 += v * b5;\n t15 += v * b6;\n t16 += v * b7;\n t17 += v * b8;\n t18 += v * b9;\n t19 += v * b10;\n t20 += v * b11;\n t21 += v * b12;\n t22 += v * b13;\n t23 += v * b14;\n t24 += v * b15;\n v = a[10];\n t10 += v * b0;\n t11 += v * b1;\n t12 += v * b2;\n t13 += v * b3;\n t14 += v * b4;\n t15 += v * b5;\n t16 += v * b6;\n t17 += v * b7;\n t18 += v * b8;\n t19 += v * b9;\n t20 += v * b10;\n t21 += v * b11;\n t22 += v * b12;\n t23 += v * b13;\n t24 += v * b14;\n t25 += v * b15;\n v = a[11];\n t11 += v * b0;\n t12 += v * b1;\n t13 += v * b2;\n t14 += v * b3;\n t15 += v * b4;\n t16 += v * b5;\n t17 += v * b6;\n t18 += v * b7;\n t19 += v * b8;\n t20 += v * b9;\n t21 += v * b10;\n t22 += v * b11;\n t23 += v * b12;\n t24 += v * b13;\n t25 += v * b14;\n t26 += v * b15;\n v = a[12];\n t12 += v * b0;\n t13 += v * b1;\n t14 += v * b2;\n t15 += v * b3;\n t16 += v * b4;\n t17 += v * b5;\n t18 += v * b6;\n t19 += v * b7;\n t20 += v * b8;\n t21 += v * b9;\n t22 += v * b10;\n t23 += v * b11;\n t24 += v * b12;\n t25 += v * b13;\n t26 += v * b14;\n t27 += v * b15;\n v = a[13];\n t13 += v * b0;\n t14 += v * b1;\n t15 += v * b2;\n t16 += v * b3;\n t17 += v * b4;\n t18 += v * b5;\n t19 += v * b6;\n t20 += v * b7;\n t21 += v * b8;\n t22 += v * b9;\n t23 += v * b10;\n t24 += v * b11;\n t25 += v * b12;\n t26 += v * b13;\n t27 += v * b14;\n t28 += v * b15;\n v = a[14];\n t14 += v * b0;\n t15 += v * b1;\n t16 += v * b2;\n t17 += v * b3;\n t18 += v * b4;\n t19 += v * b5;\n t20 += v * b6;\n t21 += v * b7;\n t22 += v * b8;\n t23 += v * b9;\n t24 += v * b10;\n t25 += v * b11;\n t26 += v * b12;\n t27 += v * b13;\n t28 += v * b14;\n t29 += v * b15;\n v = a[15];\n t15 += v * b0;\n t16 += v * b1;\n t17 += v * b2;\n t18 += v * b3;\n t19 += v * b4;\n t20 += v * b5;\n t21 += v * b6;\n t22 += v * b7;\n t23 += v * b8;\n t24 += v * b9;\n t25 += v * b10;\n t26 += v * b11;\n t27 += v * b12;\n t28 += v * b13;\n t29 += v * b14;\n t30 += v * b15;\n\n t0 += 38 * t16;\n t1 += 38 * t17;\n t2 += 38 * t18;\n t3 += 38 * t19;\n t4 += 38 * t20;\n t5 += 38 * t21;\n t6 += 38 * t22;\n t7 += 38 * t23;\n t8 += 38 * t24;\n t9 += 38 * t25;\n t10 += 38 * t26;\n t11 += 38 * t27;\n t12 += 38 * t28;\n t13 += 38 * t29;\n t14 += 38 * t30;\n // t15 left as is\n\n // first car\n c = 1;\n v = t0 + c + 65535; c = Math.floor(v / 65536); t0 = v - c * 65536;\n v = t1 + c + 65535; c = Math.floor(v / 65536); t1 = v - c * 65536;\n v = t2 + c + 65535; c = Math.floor(v / 65536); t2 = v - c * 65536;\n v = t3 + c + 65535; c = Math.floor(v / 65536); t3 = v - c * 65536;\n v = t4 + c + 65535; c = Math.floor(v / 65536); t4 = v - c * 65536;\n v = t5 + c + 65535; c = Math.floor(v / 65536); t5 = v - c * 65536;\n v = t6 + c + 65535; c = Math.floor(v / 65536); t6 = v - c * 65536;\n v = t7 + c + 65535; c = Math.floor(v / 65536); t7 = v - c * 65536;\n v = t8 + c + 65535; c = Math.floor(v / 65536); t8 = v - c * 65536;\n v = t9 + c + 65535; c = Math.floor(v / 65536); t9 = v - c * 65536;\n v = t10 + c + 65535; c = Math.floor(v / 65536); t10 = v - c * 65536;\n v = t11 + c + 65535; c = Math.floor(v / 65536); t11 = v - c * 65536;\n v = t12 + c + 65535; c = Math.floor(v / 65536); t12 = v - c * 65536;\n v = t13 + c + 65535; c = Math.floor(v / 65536); t13 = v - c * 65536;\n v = t14 + c + 65535; c = Math.floor(v / 65536); t14 = v - c * 65536;\n v = t15 + c + 65535; c = Math.floor(v / 65536); t15 = v - c * 65536;\n t0 += c-1 + 37 * (c-1);\n\n // second car\n c = 1;\n v = t0 + c + 65535; c = Math.floor(v / 65536); t0 = v - c * 65536;\n v = t1 + c + 65535; c = Math.floor(v / 65536); t1 = v - c * 65536;\n v = t2 + c + 65535; c = Math.floor(v / 65536); t2 = v - c * 65536;\n v = t3 + c + 65535; c = Math.floor(v / 65536); t3 = v - c * 65536;\n v = t4 + c + 65535; c = Math.floor(v / 65536); t4 = v - c * 65536;\n v = t5 + c + 65535; c = Math.floor(v / 65536); t5 = v - c * 65536;\n v = t6 + c + 65535; c = Math.floor(v / 65536); t6 = v - c * 65536;\n v = t7 + c + 65535; c = Math.floor(v / 65536); t7 = v - c * 65536;\n v = t8 + c + 65535; c = Math.floor(v / 65536); t8 = v - c * 65536;\n v = t9 + c + 65535; c = Math.floor(v / 65536); t9 = v - c * 65536;\n v = t10 + c + 65535; c = Math.floor(v / 65536); t10 = v - c * 65536;\n v = t11 + c + 65535; c = Math.floor(v / 65536); t11 = v - c * 65536;\n v = t12 + c + 65535; c = Math.floor(v / 65536); t12 = v - c * 65536;\n v = t13 + c + 65535; c = Math.floor(v / 65536); t13 = v - c * 65536;\n v = t14 + c + 65535; c = Math.floor(v / 65536); t14 = v - c * 65536;\n v = t15 + c + 65535; c = Math.floor(v / 65536); t15 = v - c * 65536;\n t0 += c-1 + 37 * (c-1);\n\n o[ 0] = t0;\n o[ 1] = t1;\n o[ 2] = t2;\n o[ 3] = t3;\n o[ 4] = t4;\n o[ 5] = t5;\n o[ 6] = t6;\n o[ 7] = t7;\n o[ 8] = t8;\n o[ 9] = t9;\n o[10] = t10;\n o[11] = t11;\n o[12] = t12;\n o[13] = t13;\n o[14] = t14;\n o[15] = t15;\n}\n\nfunction S(o, a) {\n M(o, a, a);\n}\n\nfunction inv25519(o, i) {\n var c = gf();\n var a;\n for (a = 0; a < 16; a++) c[a] = i[a];\n for (a = 253; a >= 0; a--) {\n S(c, c);\n if(a !== 2 && a !== 4) M(c, c, i);\n }\n for (a = 0; a < 16; a++) o[a] = c[a];\n}\n\nfunction pow2523(o, i) {\n var c = gf();\n var a;\n for (a = 0; a < 16; a++) c[a] = i[a];\n for (a = 250; a >= 0; a--) {\n S(c, c);\n if(a !== 1) M(c, c, i);\n }\n for (a = 0; a < 16; a++) o[a] = c[a];\n}\n\nfunction crypto_scalarmult(q, n, p) {\n var z = new Uint8Array(32);\n var x = new Float64Array(80), r, i;\n var a = gf(), b = gf(), c = gf(),\n d = gf(), e = gf(), f = gf();\n for (i = 0; i < 31; i++) z[i] = n[i];\n z[31]=(n[31]&127)|64;\n z[0]&=248;\n unpack25519(x,p);\n for (i = 0; i < 16; i++) {\n b[i]=x[i];\n d[i]=a[i]=c[i]=0;\n }\n a[0]=d[0]=1;\n for (i=254; i>=0; --i) {\n r=(z[i>>>3]>>>(i&7))&1;\n sel25519(a,b,r);\n sel25519(c,d,r);\n A(e,a,c);\n Z(a,a,c);\n A(c,b,d);\n Z(b,b,d);\n S(d,e);\n S(f,a);\n M(a,c,a);\n M(c,b,e);\n A(e,a,c);\n Z(a,a,c);\n S(b,a);\n Z(c,d,f);\n M(a,c,_121665);\n A(a,a,d);\n M(c,c,a);\n M(a,d,f);\n M(d,b,x);\n S(b,e);\n sel25519(a,b,r);\n sel25519(c,d,r);\n }\n for (i = 0; i < 16; i++) {\n x[i+16]=a[i];\n x[i+32]=c[i];\n x[i+48]=b[i];\n x[i+64]=d[i];\n }\n var x32 = x.subarray(32);\n var x16 = x.subarray(16);\n inv25519(x32,x32);\n M(x16,x16,x32);\n pack25519(q,x16);\n return 0;\n}\n\nfunction crypto_scalarmult_base(q, n) {\n return crypto_scalarmult(q, n, _9);\n}\n\nfunction crypto_box_keypair(y, x) {\n randombytes(x, 32);\n return crypto_scalarmult_base(y, x);\n}\n\nfunction crypto_box_beforenm(k, y, x) {\n var s = new Uint8Array(32);\n crypto_scalarmult(s, x, y);\n return crypto_core_hsalsa20(k, _0, s, sigma);\n}\n\nvar crypto_box_afternm = crypto_secretbox;\nvar crypto_box_open_afternm = crypto_secretbox_open;\n\nfunction crypto_box(c, m, d, n, y, x) {\n var k = new Uint8Array(32);\n crypto_box_beforenm(k, y, x);\n return crypto_box_afternm(c, m, d, n, k);\n}\n\nfunction crypto_box_open(m, c, d, n, y, x) {\n var k = new Uint8Array(32);\n crypto_box_beforenm(k, y, x);\n return crypto_box_open_afternm(m, c, d, n, k);\n}\n\nvar K = [\n 0x428a2f98, 0xd728ae22, 0x71374491, 0x23ef65cd,\n 0xb5c0fbcf, 0xec4d3b2f, 0xe9b5dba5, 0x8189dbbc,\n 0x3956c25b, 0xf348b538, 0x59f111f1, 0xb605d019,\n 0x923f82a4, 0xaf194f9b, 0xab1c5ed5, 0xda6d8118,\n 0xd807aa98, 0xa3030242, 0x12835b01, 0x45706fbe,\n 0x243185be, 0x4ee4b28c, 0x550c7dc3, 0xd5ffb4e2,\n 0x72be5d74, 0xf27b896f, 0x80deb1fe, 0x3b1696b1,\n 0x9bdc06a7, 0x25c71235, 0xc19bf174, 0xcf692694,\n 0xe49b69c1, 0x9ef14ad2, 0xefbe4786, 0x384f25e3,\n 0x0fc19dc6, 0x8b8cd5b5, 0x240ca1cc, 0x77ac9c65,\n 0x2de92c6f, 0x592b0275, 0x4a7484aa, 0x6ea6e483,\n 0x5cb0a9dc, 0xbd41fbd4, 0x76f988da, 0x831153b5,\n 0x983e5152, 0xee66dfab, 0xa831c66d, 0x2db43210,\n 0xb00327c8, 0x98fb213f, 0xbf597fc7, 0xbeef0ee4,\n 0xc6e00bf3, 0x3da88fc2, 0xd5a79147, 0x930aa725,\n 0x06ca6351, 0xe003826f, 0x14292967, 0x0a0e6e70,\n 0x27b70a85, 0x46d22ffc, 0x2e1b2138, 0x5c26c926,\n 0x4d2c6dfc, 0x5ac42aed, 0x53380d13, 0x9d95b3df,\n 0x650a7354, 0x8baf63de, 0x766a0abb, 0x3c77b2a8,\n 0x81c2c92e, 0x47edaee6, 0x92722c85, 0x1482353b,\n 0xa2bfe8a1, 0x4cf10364, 0xa81a664b, 0xbc423001,\n 0xc24b8b70, 0xd0f89791, 0xc76c51a3, 0x0654be30,\n 0xd192e819, 0xd6ef5218, 0xd6990624, 0x5565a910,\n 0xf40e3585, 0x5771202a, 0x106aa070, 0x32bbd1b8,\n 0x19a4c116, 0xb8d2d0c8, 0x1e376c08, 0x5141ab53,\n 0x2748774c, 0xdf8eeb99, 0x34b0bcb5, 0xe19b48a8,\n 0x391c0cb3, 0xc5c95a63, 0x4ed8aa4a, 0xe3418acb,\n 0x5b9cca4f, 0x7763e373, 0x682e6ff3, 0xd6b2b8a3,\n 0x748f82ee, 0x5defb2fc, 0x78a5636f, 0x43172f60,\n 0x84c87814, 0xa1f0ab72, 0x8cc70208, 0x1a6439ec,\n 0x90befffa, 0x23631e28, 0xa4506ceb, 0xde82bde9,\n 0xbef9a3f7, 0xb2c67915, 0xc67178f2, 0xe372532b,\n 0xca273ece, 0xea26619c, 0xd186b8c7, 0x21c0c207,\n 0xeada7dd6, 0xcde0eb1e, 0xf57d4f7f, 0xee6ed178,\n 0x06f067aa, 0x72176fba, 0x0a637dc5, 0xa2c898a6,\n 0x113f9804, 0xbef90dae, 0x1b710b35, 0x131c471b,\n 0x28db77f5, 0x23047d84, 0x32caab7b, 0x40c72493,\n 0x3c9ebe0a, 0x15c9bebc, 0x431d67c4, 0x9c100d4c,\n 0x4cc5d4be, 0xcb3e42b6, 0x597f299c, 0xfc657e2a,\n 0x5fcb6fab, 0x3ad6faec, 0x6c44198c, 0x4a475817\n];\n\nfunction crypto_hashblocks_hl(hh, hl, m, n) {\n var wh = new Int32Array(16), wl = new Int32Array(16),\n bh0, bh1, bh2, bh3, bh4, bh5, bh6, bh7,\n bl0, bl1, bl2, bl3, bl4, bl5, bl6, bl7,\n th, tl, i, j, h, l, a, b, c, d;\n\n var ah0 = hh[0],\n ah1 = hh[1],\n ah2 = hh[2],\n ah3 = hh[3],\n ah4 = hh[4],\n ah5 = hh[5],\n ah6 = hh[6],\n ah7 = hh[7],\n\n al0 = hl[0],\n al1 = hl[1],\n al2 = hl[2],\n al3 = hl[3],\n al4 = hl[4],\n al5 = hl[5],\n al6 = hl[6],\n al7 = hl[7];\n\n var pos = 0;\n while (n >= 128) {\n for (i = 0; i < 16; i++) {\n j = 8 * i + pos;\n wh[i] = (m[j+0] << 24) | (m[j+1] << 16) | (m[j+2] << 8) | m[j+3];\n wl[i] = (m[j+4] << 24) | (m[j+5] << 16) | (m[j+6] << 8) | m[j+7];\n }\n for (i = 0; i < 80; i++) {\n bh0 = ah0;\n bh1 = ah1;\n bh2 = ah2;\n bh3 = ah3;\n bh4 = ah4;\n bh5 = ah5;\n bh6 = ah6;\n bh7 = ah7;\n\n bl0 = al0;\n bl1 = al1;\n bl2 = al2;\n bl3 = al3;\n bl4 = al4;\n bl5 = al5;\n bl6 = al6;\n bl7 = al7;\n\n // add\n h = ah7;\n l = al7;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n // Sigma1\n h = ((ah4 >>> 14) | (al4 << (32-14))) ^ ((ah4 >>> 18) | (al4 << (32-18))) ^ ((al4 >>> (41-32)) | (ah4 << (32-(41-32))));\n l = ((al4 >>> 14) | (ah4 << (32-14))) ^ ((al4 >>> 18) | (ah4 << (32-18))) ^ ((ah4 >>> (41-32)) | (al4 << (32-(41-32))));\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // Ch\n h = (ah4 & ah5) ^ (~ah4 & ah6);\n l = (al4 & al5) ^ (~al4 & al6);\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // K\n h = K[i*2];\n l = K[i*2+1];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // w\n h = wh[i%16];\n l = wl[i%16];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n th = c & 0xffff | d << 16;\n tl = a & 0xffff | b << 16;\n\n // add\n h = th;\n l = tl;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n // Sigma0\n h = ((ah0 >>> 28) | (al0 << (32-28))) ^ ((al0 >>> (34-32)) | (ah0 << (32-(34-32)))) ^ ((al0 >>> (39-32)) | (ah0 << (32-(39-32))));\n l = ((al0 >>> 28) | (ah0 << (32-28))) ^ ((ah0 >>> (34-32)) | (al0 << (32-(34-32)))) ^ ((ah0 >>> (39-32)) | (al0 << (32-(39-32))));\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // Maj\n h = (ah0 & ah1) ^ (ah0 & ah2) ^ (ah1 & ah2);\n l = (al0 & al1) ^ (al0 & al2) ^ (al1 & al2);\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n bh7 = (c & 0xffff) | (d << 16);\n bl7 = (a & 0xffff) | (b << 16);\n\n // add\n h = bh3;\n l = bl3;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = th;\n l = tl;\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n bh3 = (c & 0xffff) | (d << 16);\n bl3 = (a & 0xffff) | (b << 16);\n\n ah1 = bh0;\n ah2 = bh1;\n ah3 = bh2;\n ah4 = bh3;\n ah5 = bh4;\n ah6 = bh5;\n ah7 = bh6;\n ah0 = bh7;\n\n al1 = bl0;\n al2 = bl1;\n al3 = bl2;\n al4 = bl3;\n al5 = bl4;\n al6 = bl5;\n al7 = bl6;\n al0 = bl7;\n\n if (i%16 === 15) {\n for (j = 0; j < 16; j++) {\n // add\n h = wh[j];\n l = wl[j];\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = wh[(j+9)%16];\n l = wl[(j+9)%16];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // sigma0\n th = wh[(j+1)%16];\n tl = wl[(j+1)%16];\n h = ((th >>> 1) | (tl << (32-1))) ^ ((th >>> 8) | (tl << (32-8))) ^ (th >>> 7);\n l = ((tl >>> 1) | (th << (32-1))) ^ ((tl >>> 8) | (th << (32-8))) ^ ((tl >>> 7) | (th << (32-7)));\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // sigma1\n th = wh[(j+14)%16];\n tl = wl[(j+14)%16];\n h = ((th >>> 19) | (tl << (32-19))) ^ ((tl >>> (61-32)) | (th << (32-(61-32)))) ^ (th >>> 6);\n l = ((tl >>> 19) | (th << (32-19))) ^ ((th >>> (61-32)) | (tl << (32-(61-32)))) ^ ((tl >>> 6) | (th << (32-6)));\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n wh[j] = (c & 0xffff) | (d << 16);\n wl[j] = (a & 0xffff) | (b << 16);\n }\n }\n }\n\n // add\n h = ah0;\n l = al0;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[0];\n l = hl[0];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[0] = ah0 = (c & 0xffff) | (d << 16);\n hl[0] = al0 = (a & 0xffff) | (b << 16);\n\n h = ah1;\n l = al1;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[1];\n l = hl[1];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[1] = ah1 = (c & 0xffff) | (d << 16);\n hl[1] = al1 = (a & 0xffff) | (b << 16);\n\n h = ah2;\n l = al2;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[2];\n l = hl[2];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[2] = ah2 = (c & 0xffff) | (d << 16);\n hl[2] = al2 = (a & 0xffff) | (b << 16);\n\n h = ah3;\n l = al3;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[3];\n l = hl[3];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[3] = ah3 = (c & 0xffff) | (d << 16);\n hl[3] = al3 = (a & 0xffff) | (b << 16);\n\n h = ah4;\n l = al4;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[4];\n l = hl[4];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[4] = ah4 = (c & 0xffff) | (d << 16);\n hl[4] = al4 = (a & 0xffff) | (b << 16);\n\n h = ah5;\n l = al5;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[5];\n l = hl[5];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[5] = ah5 = (c & 0xffff) | (d << 16);\n hl[5] = al5 = (a & 0xffff) | (b << 16);\n\n h = ah6;\n l = al6;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[6];\n l = hl[6];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[6] = ah6 = (c & 0xffff) | (d << 16);\n hl[6] = al6 = (a & 0xffff) | (b << 16);\n\n h = ah7;\n l = al7;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[7];\n l = hl[7];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[7] = ah7 = (c & 0xffff) | (d << 16);\n hl[7] = al7 = (a & 0xffff) | (b << 16);\n\n pos += 128;\n n -= 128;\n }\n\n return n;\n}\n\nfunction crypto_hash(out, m, n) {\n var hh = new Int32Array(8),\n hl = new Int32Array(8),\n x = new Uint8Array(256),\n i, b = n;\n\n hh[0] = 0x6a09e667;\n hh[1] = 0xbb67ae85;\n hh[2] = 0x3c6ef372;\n hh[3] = 0xa54ff53a;\n hh[4] = 0x510e527f;\n hh[5] = 0x9b05688c;\n hh[6] = 0x1f83d9ab;\n hh[7] = 0x5be0cd19;\n\n hl[0] = 0xf3bcc908;\n hl[1] = 0x84caa73b;\n hl[2] = 0xfe94f82b;\n hl[3] = 0x5f1d36f1;\n hl[4] = 0xade682d1;\n hl[5] = 0x2b3e6c1f;\n hl[6] = 0xfb41bd6b;\n hl[7] = 0x137e2179;\n\n crypto_hashblocks_hl(hh, hl, m, n);\n n %= 128;\n\n for (i = 0; i < n; i++) x[i] = m[b-n+i];\n x[n] = 128;\n\n n = 256-128*(n<112?1:0);\n x[n-9] = 0;\n ts64(x, n-8, (b / 0x20000000) | 0, b << 3);\n crypto_hashblocks_hl(hh, hl, x, n);\n\n for (i = 0; i < 8; i++) ts64(out, 8*i, hh[i], hl[i]);\n\n return 0;\n}\n\nfunction add(p, q) {\n var a = gf(), b = gf(), c = gf(),\n d = gf(), e = gf(), f = gf(),\n g = gf(), h = gf(), t = gf();\n\n Z(a, p[1], p[0]);\n Z(t, q[1], q[0]);\n M(a, a, t);\n A(b, p[0], p[1]);\n A(t, q[0], q[1]);\n M(b, b, t);\n M(c, p[3], q[3]);\n M(c, c, D2);\n M(d, p[2], q[2]);\n A(d, d, d);\n Z(e, b, a);\n Z(f, d, c);\n A(g, d, c);\n A(h, b, a);\n\n M(p[0], e, f);\n M(p[1], h, g);\n M(p[2], g, f);\n M(p[3], e, h);\n}\n\nfunction cswap(p, q, b) {\n var i;\n for (i = 0; i < 4; i++) {\n sel25519(p[i], q[i], b);\n }\n}\n\nfunction pack(r, p) {\n var tx = gf(), ty = gf(), zi = gf();\n inv25519(zi, p[2]);\n M(tx, p[0], zi);\n M(ty, p[1], zi);\n pack25519(r, ty);\n r[31] ^= par25519(tx) << 7;\n}\n\nfunction scalarmult(p, q, s) {\n var b, i;\n set25519(p[0], gf0);\n set25519(p[1], gf1);\n set25519(p[2], gf1);\n set25519(p[3], gf0);\n for (i = 255; i >= 0; --i) {\n b = (s[(i/8)|0] >> (i&7)) & 1;\n cswap(p, q, b);\n add(q, p);\n add(p, p);\n cswap(p, q, b);\n }\n}\n\nfunction scalarbase(p, s) {\n var q = [gf(), gf(), gf(), gf()];\n set25519(q[0], X);\n set25519(q[1], Y);\n set25519(q[2], gf1);\n M(q[3], X, Y);\n scalarmult(p, q, s);\n}\n\nfunction crypto_sign_keypair(pk, sk, seeded) {\n var d = new Uint8Array(64);\n var p = [gf(), gf(), gf(), gf()];\n var i;\n\n if (!seeded) randombytes(sk, 32);\n crypto_hash(d, sk, 32);\n d[0] &= 248;\n d[31] &= 127;\n d[31] |= 64;\n\n scalarbase(p, d);\n pack(pk, p);\n\n for (i = 0; i < 32; i++) sk[i+32] = pk[i];\n return 0;\n}\n\nvar L = new Float64Array([0xed, 0xd3, 0xf5, 0x5c, 0x1a, 0x63, 0x12, 0x58, 0xd6, 0x9c, 0xf7, 0xa2, 0xde, 0xf9, 0xde, 0x14, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x10]);\n\nfunction modL(r, x) {\n var carry, i, j, k;\n for (i = 63; i >= 32; --i) {\n carry = 0;\n for (j = i - 32, k = i - 12; j < k; ++j) {\n x[j] += carry - 16 * x[i] * L[j - (i - 32)];\n carry = Math.floor((x[j] + 128) / 256);\n x[j] -= carry * 256;\n }\n x[j] += carry;\n x[i] = 0;\n }\n carry = 0;\n for (j = 0; j < 32; j++) {\n x[j] += carry - (x[31] >> 4) * L[j];\n carry = x[j] >> 8;\n x[j] &= 255;\n }\n for (j = 0; j < 32; j++) x[j] -= carry * L[j];\n for (i = 0; i < 32; i++) {\n x[i+1] += x[i] >> 8;\n r[i] = x[i] & 255;\n }\n}\n\nfunction reduce(r) {\n var x = new Float64Array(64), i;\n for (i = 0; i < 64; i++) x[i] = r[i];\n for (i = 0; i < 64; i++) r[i] = 0;\n modL(r, x);\n}\n\n// Note: difference from C - smlen returned, not passed as argument.\nfunction crypto_sign(sm, m, n, sk) {\n var d = new Uint8Array(64), h = new Uint8Array(64), r = new Uint8Array(64);\n var i, j, x = new Float64Array(64);\n var p = [gf(), gf(), gf(), gf()];\n\n crypto_hash(d, sk, 32);\n d[0] &= 248;\n d[31] &= 127;\n d[31] |= 64;\n\n var smlen = n + 64;\n for (i = 0; i < n; i++) sm[64 + i] = m[i];\n for (i = 0; i < 32; i++) sm[32 + i] = d[32 + i];\n\n crypto_hash(r, sm.subarray(32), n+32);\n reduce(r);\n scalarbase(p, r);\n pack(sm, p);\n\n for (i = 32; i < 64; i++) sm[i] = sk[i];\n crypto_hash(h, sm, n + 64);\n reduce(h);\n\n for (i = 0; i < 64; i++) x[i] = 0;\n for (i = 0; i < 32; i++) x[i] = r[i];\n for (i = 0; i < 32; i++) {\n for (j = 0; j < 32; j++) {\n x[i+j] += h[i] * d[j];\n }\n }\n\n modL(sm.subarray(32), x);\n return smlen;\n}\n\nfunction unpackneg(r, p) {\n var t = gf(), chk = gf(), num = gf(),\n den = gf(), den2 = gf(), den4 = gf(),\n den6 = gf();\n\n set25519(r[2], gf1);\n unpack25519(r[1], p);\n S(num, r[1]);\n M(den, num, D);\n Z(num, num, r[2]);\n A(den, r[2], den);\n\n S(den2, den);\n S(den4, den2);\n M(den6, den4, den2);\n M(t, den6, num);\n M(t, t, den);\n\n pow2523(t, t);\n M(t, t, num);\n M(t, t, den);\n M(t, t, den);\n M(r[0], t, den);\n\n S(chk, r[0]);\n M(chk, chk, den);\n if (neq25519(chk, num)) M(r[0], r[0], I);\n\n S(chk, r[0]);\n M(chk, chk, den);\n if (neq25519(chk, num)) return -1;\n\n if (par25519(r[0]) === (p[31]>>7)) Z(r[0], gf0, r[0]);\n\n M(r[3], r[0], r[1]);\n return 0;\n}\n\nfunction crypto_sign_open(m, sm, n, pk) {\n var i;\n var t = new Uint8Array(32), h = new Uint8Array(64);\n var p = [gf(), gf(), gf(), gf()],\n q = [gf(), gf(), gf(), gf()];\n\n if (n < 64) return -1;\n\n if (unpackneg(q, pk)) return -1;\n\n for (i = 0; i < n; i++) m[i] = sm[i];\n for (i = 0; i < 32; i++) m[i+32] = pk[i];\n crypto_hash(h, m, n);\n reduce(h);\n scalarmult(p, q, h);\n\n scalarbase(q, sm.subarray(32));\n add(p, q);\n pack(t, p);\n\n n -= 64;\n if (crypto_verify_32(sm, 0, t, 0)) {\n for (i = 0; i < n; i++) m[i] = 0;\n return -1;\n }\n\n for (i = 0; i < n; i++) m[i] = sm[i + 64];\n return n;\n}\n\nvar crypto_secretbox_KEYBYTES = 32,\n crypto_secretbox_NONCEBYTES = 24,\n crypto_secretbox_ZEROBYTES = 32,\n crypto_secretbox_BOXZEROBYTES = 16,\n crypto_scalarmult_BYTES = 32,\n crypto_scalarmult_SCALARBYTES = 32,\n crypto_box_PUBLICKEYBYTES = 32,\n crypto_box_SECRETKEYBYTES = 32,\n crypto_box_BEFORENMBYTES = 32,\n crypto_box_NONCEBYTES = crypto_secretbox_NONCEBYTES,\n crypto_box_ZEROBYTES = crypto_secretbox_ZEROBYTES,\n crypto_box_BOXZEROBYTES = crypto_secretbox_BOXZEROBYTES,\n crypto_sign_BYTES = 64,\n crypto_sign_PUBLICKEYBYTES = 32,\n crypto_sign_SECRETKEYBYTES = 64,\n crypto_sign_SEEDBYTES = 32,\n crypto_hash_BYTES = 64;\n\nnacl.lowlevel = {\n crypto_core_hsalsa20: crypto_core_hsalsa20,\n crypto_stream_xor: crypto_stream_xor,\n crypto_stream: crypto_stream,\n crypto_stream_salsa20_xor: crypto_stream_salsa20_xor,\n crypto_stream_salsa20: crypto_stream_salsa20,\n crypto_onetimeauth: crypto_onetimeauth,\n crypto_onetimeauth_verify: crypto_onetimeauth_verify,\n crypto_verify_16: crypto_verify_16,\n crypto_verify_32: crypto_verify_32,\n crypto_secretbox: crypto_secretbox,\n crypto_secretbox_open: crypto_secretbox_open,\n crypto_scalarmult: crypto_scalarmult,\n crypto_scalarmult_base: crypto_scalarmult_base,\n crypto_box_beforenm: crypto_box_beforenm,\n crypto_box_afternm: crypto_box_afternm,\n crypto_box: crypto_box,\n crypto_box_open: crypto_box_open,\n crypto_box_keypair: crypto_box_keypair,\n crypto_hash: crypto_hash,\n crypto_sign: crypto_sign,\n crypto_sign_keypair: crypto_sign_keypair,\n crypto_sign_open: crypto_sign_open,\n\n crypto_secretbox_KEYBYTES: crypto_secretbox_KEYBYTES,\n crypto_secretbox_NONCEBYTES: crypto_secretbox_NONCEBYTES,\n crypto_secretbox_ZEROBYTES: crypto_secretbox_ZEROBYTES,\n crypto_secretbox_BOXZEROBYTES: crypto_secretbox_BOXZEROBYTES,\n crypto_scalarmult_BYTES: crypto_scalarmult_BYTES,\n crypto_scalarmult_SCALARBYTES: crypto_scalarmult_SCALARBYTES,\n crypto_box_PUBLICKEYBYTES: crypto_box_PUBLICKEYBYTES,\n crypto_box_SECRETKEYBYTES: crypto_box_SECRETKEYBYTES,\n crypto_box_BEFORENMBYTES: crypto_box_BEFORENMBYTES,\n crypto_box_NONCEBYTES: crypto_box_NONCEBYTES,\n crypto_box_ZEROBYTES: crypto_box_ZEROBYTES,\n crypto_box_BOXZEROBYTES: crypto_box_BOXZEROBYTES,\n crypto_sign_BYTES: crypto_sign_BYTES,\n crypto_sign_PUBLICKEYBYTES: crypto_sign_PUBLICKEYBYTES,\n crypto_sign_SECRETKEYBYTES: crypto_sign_SECRETKEYBYTES,\n crypto_sign_SEEDBYTES: crypto_sign_SEEDBYTES,\n crypto_hash_BYTES: crypto_hash_BYTES,\n\n gf: gf,\n D: D,\n L: L,\n pack25519: pack25519,\n unpack25519: unpack25519,\n M: M,\n A: A,\n S: S,\n Z: Z,\n pow2523: pow2523,\n add: add,\n set25519: set25519,\n modL: modL,\n scalarmult: scalarmult,\n scalarbase: scalarbase,\n};\n\n/* High-level API */\n\nfunction checkLengths(k, n) {\n if (k.length !== crypto_secretbox_KEYBYTES) throw new Error('bad key size');\n if (n.length !== crypto_secretbox_NONCEBYTES) throw new Error('bad nonce size');\n}\n\nfunction checkBoxLengths(pk, sk) {\n if (pk.length !== crypto_box_PUBLICKEYBYTES) throw new Error('bad public key size');\n if (sk.length !== crypto_box_SECRETKEYBYTES) throw new Error('bad secret key size');\n}\n\nfunction checkArrayTypes() {\n for (var i = 0; i < arguments.length; i++) {\n if (!(arguments[i] instanceof Uint8Array))\n throw new TypeError('unexpected type, use Uint8Array');\n }\n}\n\nfunction cleanup(arr) {\n for (var i = 0; i < arr.length; i++) arr[i] = 0;\n}\n\nnacl.randomBytes = function(n) {\n var b = new Uint8Array(n);\n randombytes(b, n);\n return b;\n};\n\nnacl.secretbox = function(msg, nonce, key) {\n checkArrayTypes(msg, nonce, key);\n checkLengths(key, nonce);\n var m = new Uint8Array(crypto_secretbox_ZEROBYTES + msg.length);\n var c = new Uint8Array(m.length);\n for (var i = 0; i < msg.length; i++) m[i+crypto_secretbox_ZEROBYTES] = msg[i];\n crypto_secretbox(c, m, m.length, nonce, key);\n return c.subarray(crypto_secretbox_BOXZEROBYTES);\n};\n\nnacl.secretbox.open = function(box, nonce, key) {\n checkArrayTypes(box, nonce, key);\n checkLengths(key, nonce);\n var c = new Uint8Array(crypto_secretbox_BOXZEROBYTES + box.length);\n var m = new Uint8Array(c.length);\n for (var i = 0; i < box.length; i++) c[i+crypto_secretbox_BOXZEROBYTES] = box[i];\n if (c.length < 32) return null;\n if (crypto_secretbox_open(m, c, c.length, nonce, key) !== 0) return null;\n return m.subarray(crypto_secretbox_ZEROBYTES);\n};\n\nnacl.secretbox.keyLength = crypto_secretbox_KEYBYTES;\nnacl.secretbox.nonceLength = crypto_secretbox_NONCEBYTES;\nnacl.secretbox.overheadLength = crypto_secretbox_BOXZEROBYTES;\n\nnacl.scalarMult = function(n, p) {\n checkArrayTypes(n, p);\n if (n.length !== crypto_scalarmult_SCALARBYTES) throw new Error('bad n size');\n if (p.length !== crypto_scalarmult_BYTES) throw new Error('bad p size');\n var q = new Uint8Array(crypto_scalarmult_BYTES);\n crypto_scalarmult(q, n, p);\n return q;\n};\n\nnacl.scalarMult.base = function(n) {\n checkArrayTypes(n);\n if (n.length !== crypto_scalarmult_SCALARBYTES) throw new Error('bad n size');\n var q = new Uint8Array(crypto_scalarmult_BYTES);\n crypto_scalarmult_base(q, n);\n return q;\n};\n\nnacl.scalarMult.scalarLength = crypto_scalarmult_SCALARBYTES;\nnacl.scalarMult.groupElementLength = crypto_scalarmult_BYTES;\n\nnacl.box = function(msg, nonce, publicKey, secretKey) {\n var k = nacl.box.before(publicKey, secretKey);\n return nacl.secretbox(msg, nonce, k);\n};\n\nnacl.box.before = function(publicKey, secretKey) {\n checkArrayTypes(publicKey, secretKey);\n checkBoxLengths(publicKey, secretKey);\n var k = new Uint8Array(crypto_box_BEFORENMBYTES);\n crypto_box_beforenm(k, publicKey, secretKey);\n return k;\n};\n\nnacl.box.after = nacl.secretbox;\n\nnacl.box.open = function(msg, nonce, publicKey, secretKey) {\n var k = nacl.box.before(publicKey, secretKey);\n return nacl.secretbox.open(msg, nonce, k);\n};\n\nnacl.box.open.after = nacl.secretbox.open;\n\nnacl.box.keyPair = function() {\n var pk = new Uint8Array(crypto_box_PUBLICKEYBYTES);\n var sk = new Uint8Array(crypto_box_SECRETKEYBYTES);\n crypto_box_keypair(pk, sk);\n return {publicKey: pk, secretKey: sk};\n};\n\nnacl.box.keyPair.fromSecretKey = function(secretKey) {\n checkArrayTypes(secretKey);\n if (secretKey.length !== crypto_box_SECRETKEYBYTES)\n throw new Error('bad secret key size');\n var pk = new Uint8Array(crypto_box_PUBLICKEYBYTES);\n crypto_scalarmult_base(pk, secretKey);\n return {publicKey: pk, secretKey: new Uint8Array(secretKey)};\n};\n\nnacl.box.publicKeyLength = crypto_box_PUBLICKEYBYTES;\nnacl.box.secretKeyLength = crypto_box_SECRETKEYBYTES;\nnacl.box.sharedKeyLength = crypto_box_BEFORENMBYTES;\nnacl.box.nonceLength = crypto_box_NONCEBYTES;\nnacl.box.overheadLength = nacl.secretbox.overheadLength;\n\nnacl.sign = function(msg, secretKey) {\n checkArrayTypes(msg, secretKey);\n if (secretKey.length !== crypto_sign_SECRETKEYBYTES)\n throw new Error('bad secret key size');\n var signedMsg = new Uint8Array(crypto_sign_BYTES+msg.length);\n crypto_sign(signedMsg, msg, msg.length, secretKey);\n return signedMsg;\n};\n\nnacl.sign.open = function(signedMsg, publicKey) {\n checkArrayTypes(signedMsg, publicKey);\n if (publicKey.length !== crypto_sign_PUBLICKEYBYTES)\n throw new Error('bad public key size');\n var tmp = new Uint8Array(signedMsg.length);\n var mlen = crypto_sign_open(tmp, signedMsg, signedMsg.length, publicKey);\n if (mlen < 0) return null;\n var m = new Uint8Array(mlen);\n for (var i = 0; i < m.length; i++) m[i] = tmp[i];\n return m;\n};\n\nnacl.sign.detached = function(msg, secretKey) {\n var signedMsg = nacl.sign(msg, secretKey);\n var sig = new Uint8Array(crypto_sign_BYTES);\n for (var i = 0; i < sig.length; i++) sig[i] = signedMsg[i];\n return sig;\n};\n\nnacl.sign.detached.verify = function(msg, sig, publicKey) {\n checkArrayTypes(msg, sig, publicKey);\n if (sig.length !== crypto_sign_BYTES)\n throw new Error('bad signature size');\n if (publicKey.length !== crypto_sign_PUBLICKEYBYTES)\n throw new Error('bad public key size');\n var sm = new Uint8Array(crypto_sign_BYTES + msg.length);\n var m = new Uint8Array(crypto_sign_BYTES + msg.length);\n var i;\n for (i = 0; i < crypto_sign_BYTES; i++) sm[i] = sig[i];\n for (i = 0; i < msg.length; i++) sm[i+crypto_sign_BYTES] = msg[i];\n return (crypto_sign_open(m, sm, sm.length, publicKey) >= 0);\n};\n\nnacl.sign.keyPair = function() {\n var pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);\n var sk = new Uint8Array(crypto_sign_SECRETKEYBYTES);\n crypto_sign_keypair(pk, sk);\n return {publicKey: pk, secretKey: sk};\n};\n\nnacl.sign.keyPair.fromSecretKey = function(secretKey) {\n checkArrayTypes(secretKey);\n if (secretKey.length !== crypto_sign_SECRETKEYBYTES)\n throw new Error('bad secret key size');\n var pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);\n for (var i = 0; i < pk.length; i++) pk[i] = secretKey[32+i];\n return {publicKey: pk, secretKey: new Uint8Array(secretKey)};\n};\n\nnacl.sign.keyPair.fromSeed = function(seed) {\n checkArrayTypes(seed);\n if (seed.length !== crypto_sign_SEEDBYTES)\n throw new Error('bad seed size');\n var pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);\n var sk = new Uint8Array(crypto_sign_SECRETKEYBYTES);\n for (var i = 0; i < 32; i++) sk[i] = seed[i];\n crypto_sign_keypair(pk, sk, true);\n return {publicKey: pk, secretKey: sk};\n};\n\nnacl.sign.publicKeyLength = crypto_sign_PUBLICKEYBYTES;\nnacl.sign.secretKeyLength = crypto_sign_SECRETKEYBYTES;\nnacl.sign.seedLength = crypto_sign_SEEDBYTES;\nnacl.sign.signatureLength = crypto_sign_BYTES;\n\nnacl.hash = function(msg) {\n checkArrayTypes(msg);\n var h = new Uint8Array(crypto_hash_BYTES);\n crypto_hash(h, msg, msg.length);\n return h;\n};\n\nnacl.hash.hashLength = crypto_hash_BYTES;\n\nnacl.verify = function(x, y) {\n checkArrayTypes(x, y);\n // Zero length arguments are considered not equal.\n if (x.length === 0 || y.length === 0) return false;\n if (x.length !== y.length) return false;\n return (vn(x, 0, y, 0, x.length) === 0) ? true : false;\n};\n\nnacl.setPRNG = function(fn) {\n randombytes = fn;\n};\n\n(function() {\n // Initialize PRNG if environment provides CSPRNG.\n // If not, methods calling randombytes will throw.\n var crypto = typeof self !== 'undefined' ? (self.crypto || self.msCrypto) : null;\n if (crypto && crypto.getRandomValues) {\n // Browsers.\n var QUOTA = 65536;\n nacl.setPRNG(function(x, n) {\n var i, v = new Uint8Array(n);\n for (i = 0; i < n; i += QUOTA) {\n crypto.getRandomValues(v.subarray(i, i + Math.min(n - i, QUOTA)));\n }\n for (i = 0; i < n; i++) x[i] = v[i];\n cleanup(v);\n });\n } else if (typeof require !== 'undefined') {\n // Node.js.\n crypto = require('crypto');\n if (crypto && crypto.randomBytes) {\n nacl.setPRNG(function(x, n) {\n var i, v = crypto.randomBytes(n);\n for (i = 0; i < n; i++) x[i] = v[i];\n cleanup(v);\n });\n }\n }\n})();\n\n})(typeof module !== 'undefined' && module.exports ? module.exports : (self.nacl = self.nacl || {}));\n","module.exports = require('./pusher-with-encryption').default;\n","/* (ignored) */","export default function encode(s: any): string {\n return btoa(utob(s));\n}\n\nvar fromCharCode = String.fromCharCode;\n\nvar b64chars =\n 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';\nvar b64tab = {};\n\nfor (var i = 0, l = b64chars.length; i < l; i++) {\n b64tab[b64chars.charAt(i)] = i;\n}\n\nvar cb_utob = function(c) {\n var cc = c.charCodeAt(0);\n return cc < 0x80\n ? c\n : cc < 0x800\n ? fromCharCode(0xc0 | (cc >>> 6)) + fromCharCode(0x80 | (cc & 0x3f))\n : fromCharCode(0xe0 | ((cc >>> 12) & 0x0f)) +\n fromCharCode(0x80 | ((cc >>> 6) & 0x3f)) +\n fromCharCode(0x80 | (cc & 0x3f));\n};\n\nvar utob = function(u) {\n return u.replace(/[^\\x00-\\x7F]/g, cb_utob);\n};\n\nvar cb_encode = function(ccc) {\n var padlen = [0, 2, 1][ccc.length % 3];\n var ord =\n (ccc.charCodeAt(0) << 16) |\n ((ccc.length > 1 ? ccc.charCodeAt(1) : 0) << 8) |\n (ccc.length > 2 ? ccc.charCodeAt(2) : 0);\n var chars = [\n b64chars.charAt(ord >>> 18),\n b64chars.charAt((ord >>> 12) & 63),\n padlen >= 2 ? '=' : b64chars.charAt((ord >>> 6) & 63),\n padlen >= 1 ? '=' : b64chars.charAt(ord & 63)\n ];\n return chars.join('');\n};\n\nvar btoa =\n global.btoa ||\n function(b) {\n return b.replace(/[\\s\\S]{1,3}/g, cb_encode);\n };\n","import TimedCallback from './timed_callback';\nimport { Delay, Scheduler, Canceller } from './scheduling';\n\nabstract class Timer {\n protected clear: Canceller;\n protected timer: number | void;\n\n constructor(\n set: Scheduler,\n clear: Canceller,\n delay: Delay,\n callback: TimedCallback\n ) {\n this.clear = clear;\n this.timer = set(() => {\n if (this.timer) {\n this.timer = callback(this.timer);\n }\n }, delay);\n }\n\n /** Returns whether the timer is still running.\n *\n * @return {Boolean}\n */\n isRunning(): boolean {\n return this.timer !== null;\n }\n\n /** Aborts a timer when it's running. */\n ensureAborted() {\n if (this.timer) {\n this.clear(this.timer);\n this.timer = null;\n }\n }\n}\n\nexport default Timer;\n","import Timer from './abstract_timer';\nimport TimedCallback from './timed_callback';\nimport { Delay } from './scheduling';\n\n// We need to bind clear functions this way to avoid exceptions on IE8\nfunction clearTimeout(timer) {\n global.clearTimeout(timer);\n}\nfunction clearInterval(timer) {\n global.clearInterval(timer);\n}\n\n/** Cross-browser compatible one-off timer abstraction.\n *\n * @param {Number} delay\n * @param {Function} callback\n */\nexport class OneOffTimer extends Timer {\n constructor(delay: Delay, callback: TimedCallback) {\n super(setTimeout, clearTimeout, delay, function(timer) {\n callback();\n return null;\n });\n }\n}\n\n/** Cross-browser compatible periodic timer abstraction.\n *\n * @param {Number} delay\n * @param {Function} callback\n */\nexport class PeriodicTimer extends Timer {\n constructor(delay: Delay, callback: TimedCallback) {\n super(setInterval, clearInterval, delay, function(timer) {\n callback();\n return timer;\n });\n }\n}\n","import * as Collections from './utils/collections';\nimport TimedCallback from './utils/timers/timed_callback';\nimport { OneOffTimer, PeriodicTimer } from './utils/timers';\n\nvar Util = {\n now(): number {\n if (Date.now) {\n return Date.now();\n } else {\n return new Date().valueOf();\n }\n },\n\n defer(callback: TimedCallback): OneOffTimer {\n return new OneOffTimer(0, callback);\n },\n\n /** Builds a function that will proxy a method call to its first argument.\n *\n * Allows partial application of arguments, so additional arguments are\n * prepended to the argument list.\n *\n * @param {String} name method name\n * @return {Function} proxy function\n */\n method(name: string, ...args: any[]): Function {\n var boundArguments = Array.prototype.slice.call(arguments, 1);\n return function(object) {\n return object[name].apply(object, boundArguments.concat(arguments));\n };\n }\n};\n\nexport default Util;\n","import base64encode from '../base64';\nimport Util from '../util';\n\n/** Merges multiple objects into the target argument.\n *\n * For properties that are plain Objects, performs a deep-merge. For the\n * rest it just copies the value of the property.\n *\n * To extend prototypes use it as following:\n * Pusher.Util.extend(Target.prototype, Base.prototype)\n *\n * You can also use it to merge objects without altering them:\n * Pusher.Util.extend({}, object1, object2)\n *\n * @param {Object} target\n * @return {Object} the target argument\n */\nexport function extend(target: any, ...sources: any[]): T {\n for (var i = 0; i < sources.length; i++) {\n var extensions = sources[i];\n for (var property in extensions) {\n if (\n extensions[property] &&\n extensions[property].constructor &&\n extensions[property].constructor === Object\n ) {\n target[property] = extend(target[property] || {}, extensions[property]);\n } else {\n target[property] = extensions[property];\n }\n }\n }\n return target;\n}\n\nexport function stringify(): string {\n var m = ['Pusher'];\n for (var i = 0; i < arguments.length; i++) {\n if (typeof arguments[i] === 'string') {\n m.push(arguments[i]);\n } else {\n m.push(safeJSONStringify(arguments[i]));\n }\n }\n return m.join(' : ');\n}\n\nexport function arrayIndexOf(array: any[], item: any): number {\n // MSIE doesn't have array.indexOf\n var nativeIndexOf = Array.prototype.indexOf;\n if (array === null) {\n return -1;\n }\n if (nativeIndexOf && array.indexOf === nativeIndexOf) {\n return array.indexOf(item);\n }\n for (var i = 0, l = array.length; i < l; i++) {\n if (array[i] === item) {\n return i;\n }\n }\n return -1;\n}\n\n/** Applies a function f to all properties of an object.\n *\n * Function f gets 3 arguments passed:\n * - element from the object\n * - key of the element\n * - reference to the object\n *\n * @param {Object} object\n * @param {Function} f\n */\nexport function objectApply(object: any, f: Function) {\n for (var key in object) {\n if (Object.prototype.hasOwnProperty.call(object, key)) {\n f(object[key], key, object);\n }\n }\n}\n\n/** Return a list of objects own proerty keys\n *\n * @param {Object} object\n * @returns {Array}\n */\nexport function keys(object: any): string[] {\n var keys = [];\n objectApply(object, function(_, key) {\n keys.push(key);\n });\n return keys;\n}\n\n/** Return a list of object's own property values\n *\n * @param {Object} object\n * @returns {Array}\n */\nexport function values(object: any): any[] {\n var values = [];\n objectApply(object, function(value) {\n values.push(value);\n });\n return values;\n}\n\n/** Applies a function f to all elements of an array.\n *\n * Function f gets 3 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function apply(array: any[], f: Function, context?: any) {\n for (var i = 0; i < array.length; i++) {\n f.call(context || global, array[i], i, array);\n }\n}\n\n/** Maps all elements of the array and returns the result.\n *\n * Function f gets 4 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n * - reference to the destination array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function map(array: any[], f: Function): any[] {\n var result = [];\n for (var i = 0; i < array.length; i++) {\n result.push(f(array[i], i, array, result));\n }\n return result;\n}\n\n/** Maps all elements of the object and returns the result.\n *\n * Function f gets 4 arguments passed:\n * - element from the object\n * - key of the element\n * - reference to the source object\n * - reference to the destination object\n *\n * @param {Object} object\n * @param {Function} f\n */\nexport function mapObject(object: any, f: Function): any {\n var result = {};\n objectApply(object, function(value, key) {\n result[key] = f(value);\n });\n return result;\n}\n\n/** Filters elements of the array using a test function.\n *\n * Function test gets 4 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n * - reference to the destination array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function filter(array: any[], test: Function): any[] {\n test =\n test ||\n function(value) {\n return !!value;\n };\n\n var result = [];\n for (var i = 0; i < array.length; i++) {\n if (test(array[i], i, array, result)) {\n result.push(array[i]);\n }\n }\n return result;\n}\n\n/** Filters properties of the object using a test function.\n *\n * Function test gets 4 arguments passed:\n * - element from the object\n * - key of the element\n * - reference to the source object\n * - reference to the destination object\n *\n * @param {Object} object\n * @param {Function} f\n */\nexport function filterObject(object: Object, test: Function) {\n var result = {};\n objectApply(object, function(value, key) {\n if ((test && test(value, key, object, result)) || Boolean(value)) {\n result[key] = value;\n }\n });\n return result;\n}\n\n/** Flattens an object into a two-dimensional array.\n *\n * @param {Object} object\n * @return {Array} resulting array of [key, value] pairs\n */\nexport function flatten(object: Object): any[] {\n var result = [];\n objectApply(object, function(value, key) {\n result.push([key, value]);\n });\n return result;\n}\n\n/** Checks whether any element of the array passes the test.\n *\n * Function test gets 3 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function any(array: any[], test: Function): boolean {\n for (var i = 0; i < array.length; i++) {\n if (test(array[i], i, array)) {\n return true;\n }\n }\n return false;\n}\n\n/** Checks whether all elements of the array pass the test.\n *\n * Function test gets 3 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function all(array: any[], test: Function): boolean {\n for (var i = 0; i < array.length; i++) {\n if (!test(array[i], i, array)) {\n return false;\n }\n }\n return true;\n}\n\nexport function encodeParamsObject(data): string {\n return mapObject(data, function(value) {\n if (typeof value === 'object') {\n value = safeJSONStringify(value);\n }\n return encodeURIComponent(base64encode(value.toString()));\n });\n}\n\nexport function buildQueryString(data: any): string {\n var params = filterObject(data, function(value) {\n return value !== undefined;\n });\n\n var query = map(\n flatten(encodeParamsObject(params)),\n Util.method('join', '=')\n ).join('&');\n\n return query;\n}\n\n/**\n * See https://github.com/douglascrockford/JSON-js/blob/master/cycle.js\n *\n * Remove circular references from an object. Required for JSON.stringify in\n * React Native, which tends to blow up a lot.\n *\n * @param {any} object\n * @return {any} Decycled object\n */\nexport function decycleObject(object: any): any {\n var objects = [],\n paths = [];\n\n return (function derez(value, path) {\n var i, name, nu;\n\n switch (typeof value) {\n case 'object':\n if (!value) {\n return null;\n }\n for (i = 0; i < objects.length; i += 1) {\n if (objects[i] === value) {\n return { $ref: paths[i] };\n }\n }\n\n objects.push(value);\n paths.push(path);\n\n if (Object.prototype.toString.apply(value) === '[object Array]') {\n nu = [];\n for (i = 0; i < value.length; i += 1) {\n nu[i] = derez(value[i], path + '[' + i + ']');\n }\n } else {\n nu = {};\n for (name in value) {\n if (Object.prototype.hasOwnProperty.call(value, name)) {\n nu[name] = derez(\n value[name],\n path + '[' + JSON.stringify(name) + ']'\n );\n }\n }\n }\n return nu;\n case 'number':\n case 'string':\n case 'boolean':\n return value;\n }\n })(object, '$');\n}\n\n/**\n * Provides a cross-browser and cross-platform way to safely stringify objects\n * into JSON. This is particularly necessary for ReactNative, where circular JSON\n * structures throw an exception.\n *\n * @param {any} source The object to stringify\n * @return {string} The serialized output.\n */\nexport function safeJSONStringify(source: any): string {\n try {\n return JSON.stringify(source);\n } catch (e) {\n return JSON.stringify(decycleObject(source));\n }\n}\n","import {\n ChannelAuthorizationOptions,\n UserAuthenticationOptions\n} from './auth/options';\nimport { AuthTransport } from './config';\n\nexport interface DefaultConfig {\n VERSION: string;\n PROTOCOL: number;\n wsPort: number;\n wssPort: number;\n wsPath: string;\n httpHost: string;\n httpPort: number;\n httpsPort: number;\n httpPath: string;\n stats_host: string;\n authEndpoint: string;\n authTransport: AuthTransport;\n activityTimeout: number;\n pongTimeout: number;\n unavailableTimeout: number;\n userAuthentication: UserAuthenticationOptions;\n channelAuthorization: ChannelAuthorizationOptions;\n\n cdn_http?: string;\n cdn_https?: string;\n dependency_suffix?: string;\n}\n\nvar Defaults: DefaultConfig = {\n VERSION: VERSION,\n PROTOCOL: 7,\n\n wsPort: 80,\n wssPort: 443,\n wsPath: '',\n // DEPRECATED: SockJS fallback parameters\n httpHost: 'sockjs.pusher.com',\n httpPort: 80,\n httpsPort: 443,\n httpPath: '/pusher',\n // DEPRECATED: Stats\n stats_host: 'stats.pusher.com',\n // DEPRECATED: Other settings\n authEndpoint: '/pusher/auth',\n authTransport: 'ajax',\n activityTimeout: 120000,\n pongTimeout: 30000,\n unavailableTimeout: 10000,\n userAuthentication: {\n endpoint: '/pusher/user-auth',\n transport: 'ajax'\n },\n channelAuthorization: {\n endpoint: '/pusher/auth',\n transport: 'ajax'\n },\n\n // CDN configuration\n cdn_http: CDN_HTTP,\n cdn_https: CDN_HTTPS,\n dependency_suffix: DEPENDENCY_SUFFIX\n};\n\nexport default Defaults;\n","import Defaults from '../defaults';\nimport { default as URLScheme, URLSchemeParams } from './url_scheme';\n\nfunction getGenericURL(\n baseScheme: string,\n params: URLSchemeParams,\n path: string\n): string {\n var scheme = baseScheme + (params.useTLS ? 's' : '');\n var host = params.useTLS ? params.hostTLS : params.hostNonTLS;\n return scheme + '://' + host + path;\n}\n\nfunction getGenericPath(key: string, queryString?: string): string {\n var path = '/app/' + key;\n var query =\n '?protocol=' +\n Defaults.PROTOCOL +\n '&client=js' +\n '&version=' +\n Defaults.VERSION +\n (queryString ? '&' + queryString : '');\n return path + query;\n}\n\nexport var ws: URLScheme = {\n getInitial: function(key: string, params: URLSchemeParams): string {\n var path = (params.httpPath || '') + getGenericPath(key, 'flash=false');\n return getGenericURL('ws', params, path);\n }\n};\n\nexport var http: URLScheme = {\n getInitial: function(key: string, params: URLSchemeParams): string {\n var path = (params.httpPath || '/pusher') + getGenericPath(key);\n return getGenericURL('http', params, path);\n }\n};\n\nexport var sockjs: URLScheme = {\n getInitial: function(key: string, params: URLSchemeParams): string {\n return getGenericURL('http', params, params.httpPath || '/pusher');\n },\n getPath: function(key: string, params: URLSchemeParams): string {\n return getGenericPath(key);\n }\n};\n","import Callback from './callback';\nimport * as Collections from '../utils/collections';\nimport CallbackTable from './callback_table';\n\nexport default class CallbackRegistry {\n _callbacks: CallbackTable;\n\n constructor() {\n this._callbacks = {};\n }\n\n get(name: string): Callback[] {\n return this._callbacks[prefix(name)];\n }\n\n add(name: string, callback: Function, context: any) {\n var prefixedEventName = prefix(name);\n this._callbacks[prefixedEventName] =\n this._callbacks[prefixedEventName] || [];\n this._callbacks[prefixedEventName].push({\n fn: callback,\n context: context\n });\n }\n\n remove(name?: string, callback?: Function, context?: any) {\n if (!name && !callback && !context) {\n this._callbacks = {};\n return;\n }\n\n var names = name ? [prefix(name)] : Collections.keys(this._callbacks);\n\n if (callback || context) {\n this.removeCallback(names, callback, context);\n } else {\n this.removeAllCallbacks(names);\n }\n }\n\n private removeCallback(names: string[], callback: Function, context: any) {\n Collections.apply(\n names,\n function(name) {\n this._callbacks[name] = Collections.filter(\n this._callbacks[name] || [],\n function(binding) {\n return (\n (callback && callback !== binding.fn) ||\n (context && context !== binding.context)\n );\n }\n );\n if (this._callbacks[name].length === 0) {\n delete this._callbacks[name];\n }\n },\n this\n );\n }\n\n private removeAllCallbacks(names: string[]) {\n Collections.apply(\n names,\n function(name) {\n delete this._callbacks[name];\n },\n this\n );\n }\n}\n\nfunction prefix(name: string): string {\n return '_' + name;\n}\n","import * as Collections from '../utils/collections';\nimport Callback from './callback';\nimport Metadata from '../channels/metadata';\nimport CallbackRegistry from './callback_registry';\n\n/** Manages callback bindings and event emitting.\n *\n * @param Function failThrough called when no listeners are bound to an event\n */\nexport default class Dispatcher {\n callbacks: CallbackRegistry;\n global_callbacks: Function[];\n failThrough: Function;\n\n constructor(failThrough?: Function) {\n this.callbacks = new CallbackRegistry();\n this.global_callbacks = [];\n this.failThrough = failThrough;\n }\n\n bind(eventName: string, callback: Function, context?: any) {\n this.callbacks.add(eventName, callback, context);\n return this;\n }\n\n bind_global(callback: Function) {\n this.global_callbacks.push(callback);\n return this;\n }\n\n unbind(eventName?: string, callback?: Function, context?: any) {\n this.callbacks.remove(eventName, callback, context);\n return this;\n }\n\n unbind_global(callback?: Function) {\n if (!callback) {\n this.global_callbacks = [];\n return this;\n }\n\n this.global_callbacks = Collections.filter(\n this.global_callbacks || [],\n c => c !== callback\n );\n\n return this;\n }\n\n unbind_all() {\n this.unbind();\n this.unbind_global();\n return this;\n }\n\n emit(eventName: string, data?: any, metadata?: Metadata): Dispatcher {\n for (var i = 0; i < this.global_callbacks.length; i++) {\n this.global_callbacks[i](eventName, data);\n }\n\n var callbacks = this.callbacks.get(eventName);\n var args = [];\n\n if (metadata) {\n // if there's a metadata argument, we need to call the callback with both\n // data and metadata regardless of whether data is undefined\n args.push(data, metadata);\n } else if (data) {\n // metadata is undefined, so we only need to call the callback with data\n // if data exists\n args.push(data);\n }\n\n if (callbacks && callbacks.length > 0) {\n for (var i = 0; i < callbacks.length; i++) {\n callbacks[i].fn.apply(callbacks[i].context || global, args);\n }\n } else if (this.failThrough) {\n this.failThrough(eventName, data);\n }\n\n return this;\n }\n}\n","import { stringify } from './utils/collections';\nimport Pusher from './pusher';\n\nclass Logger {\n debug(...args: any[]) {\n this.log(this.globalLog, args);\n }\n\n warn(...args: any[]) {\n this.log(this.globalLogWarn, args);\n }\n\n error(...args: any[]) {\n this.log(this.globalLogError, args);\n }\n\n private globalLog = (message: string) => {\n if (global.console && global.console.log) {\n global.console.log(message);\n }\n };\n\n private globalLogWarn(message: string) {\n if (global.console && global.console.warn) {\n global.console.warn(message);\n } else {\n this.globalLog(message);\n }\n }\n\n private globalLogError(message: string) {\n if (global.console && global.console.error) {\n global.console.error(message);\n } else {\n this.globalLogWarn(message);\n }\n }\n\n private log(\n defaultLoggingFunction: (message: string) => void,\n ...args: any[]\n ) {\n var message = stringify.apply(this, arguments);\n if (Pusher.log) {\n Pusher.log(message);\n } else if (Pusher.logToConsole) {\n const log = defaultLoggingFunction.bind(this);\n log(message);\n }\n }\n}\n\nexport default new Logger();\n","import Util from '../util';\nimport * as Collections from '../utils/collections';\nimport { default as EventsDispatcher } from '../events/dispatcher';\nimport Logger from '../logger';\nimport TransportHooks from './transport_hooks';\nimport Socket from '../socket';\nimport Runtime from 'runtime';\nimport Timeline from '../timeline/timeline';\nimport TransportConnectionOptions from './transport_connection_options';\n\n/** Provides universal API for transport connections.\n *\n * Transport connection is a low-level object that wraps a connection method\n * and exposes a simple evented interface for the connection state and\n * messaging. It does not implement Pusher-specific WebSocket protocol.\n *\n * Additionally, it fetches resources needed for transport to work and exposes\n * an interface for querying transport features.\n *\n * States:\n * - new - initial state after constructing the object\n * - initializing - during initialization phase, usually fetching resources\n * - intialized - ready to establish a connection\n * - connection - when connection is being established\n * - open - when connection ready to be used\n * - closed - after connection was closed be either side\n *\n * Emits:\n * - error - after the connection raised an error\n *\n * Options:\n * - useTLS - whether connection should be over TLS\n * - hostTLS - host to connect to when connection is over TLS\n * - hostNonTLS - host to connect to when connection is over TLS\n *\n * @param {String} key application key\n * @param {Object} options\n */\nexport default class TransportConnection extends EventsDispatcher {\n hooks: TransportHooks;\n name: string;\n priority: number;\n key: string;\n options: TransportConnectionOptions;\n state: string;\n timeline: Timeline;\n activityTimeout: number;\n id: number;\n socket: Socket;\n beforeOpen: Function;\n initialize: Function;\n\n constructor(\n hooks: TransportHooks,\n name: string,\n priority: number,\n key: string,\n options: TransportConnectionOptions\n ) {\n super();\n this.initialize = Runtime.transportConnectionInitializer;\n this.hooks = hooks;\n this.name = name;\n this.priority = priority;\n this.key = key;\n this.options = options;\n\n this.state = 'new';\n this.timeline = options.timeline;\n this.activityTimeout = options.activityTimeout;\n this.id = this.timeline.generateUniqueID();\n }\n\n /** Checks whether the transport handles activity checks by itself.\n *\n * @return {Boolean}\n */\n handlesActivityChecks(): boolean {\n return Boolean(this.hooks.handlesActivityChecks);\n }\n\n /** Checks whether the transport supports the ping/pong API.\n *\n * @return {Boolean}\n */\n supportsPing(): boolean {\n return Boolean(this.hooks.supportsPing);\n }\n\n /** Tries to establish a connection.\n *\n * @returns {Boolean} false if transport is in invalid state\n */\n connect(): boolean {\n if (this.socket || this.state !== 'initialized') {\n return false;\n }\n\n var url = this.hooks.urls.getInitial(this.key, this.options);\n try {\n this.socket = this.hooks.getSocket(url, this.options);\n } catch (e) {\n Util.defer(() => {\n this.onError(e);\n this.changeState('closed');\n });\n return false;\n }\n\n this.bindListeners();\n\n Logger.debug('Connecting', { transport: this.name, url });\n this.changeState('connecting');\n return true;\n }\n\n /** Closes the connection.\n *\n * @return {Boolean} true if there was a connection to close\n */\n close(): boolean {\n if (this.socket) {\n this.socket.close();\n return true;\n } else {\n return false;\n }\n }\n\n /** Sends data over the open connection.\n *\n * @param {String} data\n * @return {Boolean} true only when in the \"open\" state\n */\n send(data: any): boolean {\n if (this.state === 'open') {\n // Workaround for MobileSafari bug (see https://gist.github.com/2052006)\n Util.defer(() => {\n if (this.socket) {\n this.socket.send(data);\n }\n });\n return true;\n } else {\n return false;\n }\n }\n\n /** Sends a ping if the connection is open and transport supports it. */\n ping() {\n if (this.state === 'open' && this.supportsPing()) {\n this.socket.ping();\n }\n }\n\n private onOpen() {\n if (this.hooks.beforeOpen) {\n this.hooks.beforeOpen(\n this.socket,\n this.hooks.urls.getPath(this.key, this.options)\n );\n }\n this.changeState('open');\n this.socket.onopen = undefined;\n }\n\n private onError(error) {\n this.emit('error', { type: 'WebSocketError', error: error });\n this.timeline.error(this.buildTimelineMessage({ error: error.toString() }));\n }\n\n private onClose(closeEvent?: any) {\n if (closeEvent) {\n this.changeState('closed', {\n code: closeEvent.code,\n reason: closeEvent.reason,\n wasClean: closeEvent.wasClean\n });\n } else {\n this.changeState('closed');\n }\n this.unbindListeners();\n this.socket = undefined;\n }\n\n private onMessage(message) {\n this.emit('message', message);\n }\n\n private onActivity() {\n this.emit('activity');\n }\n\n private bindListeners() {\n this.socket.onopen = () => {\n this.onOpen();\n };\n this.socket.onerror = error => {\n this.onError(error);\n };\n this.socket.onclose = closeEvent => {\n this.onClose(closeEvent);\n };\n this.socket.onmessage = message => {\n this.onMessage(message);\n };\n\n if (this.supportsPing()) {\n this.socket.onactivity = () => {\n this.onActivity();\n };\n }\n }\n\n private unbindListeners() {\n if (this.socket) {\n this.socket.onopen = undefined;\n this.socket.onerror = undefined;\n this.socket.onclose = undefined;\n this.socket.onmessage = undefined;\n if (this.supportsPing()) {\n this.socket.onactivity = undefined;\n }\n }\n }\n\n private changeState(state: string, params?: any) {\n this.state = state;\n this.timeline.info(\n this.buildTimelineMessage({\n state: state,\n params: params\n })\n );\n this.emit(state, params);\n }\n\n buildTimelineMessage(message): any {\n return Collections.extend({ cid: this.id }, message);\n }\n}\n","import Factory from '../utils/factory';\nimport TransportHooks from './transport_hooks';\nimport TransportConnection from './transport_connection';\nimport TransportConnectionOptions from './transport_connection_options';\n\n/** Provides interface for transport connection instantiation.\n *\n * Takes transport-specific hooks as the only argument, which allow checking\n * for transport support and creating its connections.\n *\n * Supported hooks: * - file - the name of the file to be fetched during initialization\n * - urls - URL scheme to be used by transport\n * - handlesActivityCheck - true when the transport handles activity checks\n * - supportsPing - true when the transport has a ping/activity API\n * - isSupported - tells whether the transport is supported in the environment\n * - getSocket - creates a WebSocket-compatible transport socket\n *\n * See transports.js for specific implementations.\n *\n * @param {Object} hooks object containing all needed transport hooks\n */\nexport default class Transport {\n hooks: TransportHooks;\n\n constructor(hooks: TransportHooks) {\n this.hooks = hooks;\n }\n\n /** Returns whether the transport is supported in the environment.\n *\n * @param {Object} envronment te environment details (encryption, settings)\n * @returns {Boolean} true when the transport is supported\n */\n isSupported(environment: any): boolean {\n return this.hooks.isSupported(environment);\n }\n\n /** Creates a transport connection.\n *\n * @param {String} name\n * @param {Number} priority\n * @param {String} key the application key\n * @param {Object} options\n * @returns {TransportConnection}\n */\n createConnection(\n name: string,\n priority: number,\n key: string,\n options: any\n ): TransportConnection {\n return new TransportConnection(this.hooks, name, priority, key, options);\n }\n}\n","import * as URLSchemes from 'core/transports/url_schemes';\nimport URLScheme from 'core/transports/url_scheme';\nimport Transport from 'core/transports/transport';\nimport Util from 'core/util';\nimport * as Collections from 'core/utils/collections';\nimport TransportHooks from 'core/transports/transport_hooks';\nimport TransportsTable from 'core/transports/transports_table';\nimport Runtime from 'runtime';\n\n/** WebSocket transport.\n *\n * Uses native WebSocket implementation, including MozWebSocket supported by\n * earlier Firefox versions.\n */\nvar WSTransport = new Transport({\n urls: URLSchemes.ws,\n handlesActivityChecks: false,\n supportsPing: false,\n\n isInitialized: function() {\n return Boolean(Runtime.getWebSocketAPI());\n },\n isSupported: function(): boolean {\n return Boolean(Runtime.getWebSocketAPI());\n },\n getSocket: function(url) {\n return Runtime.createWebSocket(url);\n }\n});\n\nvar httpConfiguration = {\n urls: URLSchemes.http,\n handlesActivityChecks: false,\n supportsPing: true,\n isInitialized: function() {\n return true;\n }\n};\n\nexport var streamingConfiguration = Collections.extend(\n {\n getSocket: function(url) {\n return Runtime.HTTPFactory.createStreamingSocket(url);\n }\n },\n httpConfiguration\n);\nexport var pollingConfiguration = Collections.extend(\n {\n getSocket: function(url) {\n return Runtime.HTTPFactory.createPollingSocket(url);\n }\n },\n httpConfiguration\n);\n\nvar xhrConfiguration = {\n isSupported: function(): boolean {\n return Runtime.isXHRSupported();\n }\n};\n\n/** HTTP streaming transport using CORS-enabled XMLHttpRequest. */\nvar XHRStreamingTransport = new Transport(\n (\n Collections.extend({}, streamingConfiguration, xhrConfiguration)\n )\n);\n\n/** HTTP long-polling transport using CORS-enabled XMLHttpRequest. */\nvar XHRPollingTransport = new Transport(\n Collections.extend({}, pollingConfiguration, xhrConfiguration)\n);\n\nvar Transports: TransportsTable = {\n ws: WSTransport,\n xhr_streaming: XHRStreamingTransport,\n xhr_polling: XHRPollingTransport\n};\n\nexport default Transports;\n","import Util from '../util';\nimport * as Collections from '../utils/collections';\nimport TransportManager from './transport_manager';\nimport TransportConnection from './transport_connection';\nimport Transport from './transport';\nimport PingDelayOptions from './ping_delay_options';\n\n/** Creates transport connections monitored by a transport manager.\n *\n * When a transport is closed, it might mean the environment does not support\n * it. It's possible that messages get stuck in an intermediate buffer or\n * proxies terminate inactive connections. To combat these problems,\n * assistants monitor the connection lifetime, report unclean exits and\n * adjust ping timeouts to keep the connection active. The decision to disable\n * a transport is the manager's responsibility.\n *\n * @param {TransportManager} manager\n * @param {TransportConnection} transport\n * @param {Object} options\n */\nexport default class AssistantToTheTransportManager {\n manager: TransportManager;\n transport: Transport;\n minPingDelay: number;\n maxPingDelay: number;\n pingDelay: number;\n\n constructor(\n manager: TransportManager,\n transport: Transport,\n options: PingDelayOptions\n ) {\n this.manager = manager;\n this.transport = transport;\n this.minPingDelay = options.minPingDelay;\n this.maxPingDelay = options.maxPingDelay;\n this.pingDelay = undefined;\n }\n\n /** Creates a transport connection.\n *\n * This function has the same API as Transport#createConnection.\n *\n * @param {String} name\n * @param {Number} priority\n * @param {String} key the application key\n * @param {Object} options\n * @returns {TransportConnection}\n */\n createConnection(\n name: string,\n priority: number,\n key: string,\n options: Object\n ): TransportConnection {\n options = Collections.extend({}, options, {\n activityTimeout: this.pingDelay\n });\n var connection = this.transport.createConnection(\n name,\n priority,\n key,\n options\n );\n\n var openTimestamp = null;\n\n var onOpen = function() {\n connection.unbind('open', onOpen);\n connection.bind('closed', onClosed);\n openTimestamp = Util.now();\n };\n var onClosed = closeEvent => {\n connection.unbind('closed', onClosed);\n\n if (closeEvent.code === 1002 || closeEvent.code === 1003) {\n // we don't want to use transports not obeying the protocol\n this.manager.reportDeath();\n } else if (!closeEvent.wasClean && openTimestamp) {\n // report deaths only for short-living transport\n var lifespan = Util.now() - openTimestamp;\n if (lifespan < 2 * this.maxPingDelay) {\n this.manager.reportDeath();\n this.pingDelay = Math.max(lifespan / 2, this.minPingDelay);\n }\n }\n };\n\n connection.bind('open', onOpen);\n return connection;\n }\n\n /** Returns whether the transport is supported in the environment.\n *\n * This function has the same API as Transport#isSupported. Might return false\n * when the manager decides to kill the transport.\n *\n * @param {Object} environment the environment details (encryption, settings)\n * @returns {Boolean} true when the transport is supported\n */\n isSupported(environment: string): boolean {\n return this.manager.isAlive() && this.transport.isSupported(environment);\n }\n}\n","import Action from './action';\nimport { PusherEvent } from './message-types';\n/**\n * Provides functions for handling Pusher protocol-specific messages.\n */\n\nconst Protocol = {\n /**\n * Decodes a message in a Pusher format.\n *\n * The MessageEvent we receive from the transport should contain a pusher event\n * (https://pusher.com/docs/pusher_protocol#events) serialized as JSON in the\n * data field\n *\n * The pusher event may contain a data field too, and it may also be\n * serialised as JSON\n *\n * Throws errors when messages are not parse'able.\n *\n * @param {MessageEvent} messageEvent\n * @return {PusherEvent}\n */\n decodeMessage: function(messageEvent: MessageEvent): PusherEvent {\n try {\n var messageData = JSON.parse(messageEvent.data);\n var pusherEventData = messageData.data;\n if (typeof pusherEventData === 'string') {\n try {\n pusherEventData = JSON.parse(messageData.data);\n } catch (e) {}\n }\n var pusherEvent: PusherEvent = {\n event: messageData.event,\n channel: messageData.channel,\n data: pusherEventData\n };\n if (messageData.user_id) {\n pusherEvent.user_id = messageData.user_id;\n }\n return pusherEvent;\n } catch (e) {\n throw { type: 'MessageParseError', error: e, data: messageEvent.data };\n }\n },\n\n /**\n * Encodes a message to be sent.\n *\n * @param {PusherEvent} event\n * @return {String}\n */\n encodeMessage: function(event: PusherEvent): string {\n return JSON.stringify(event);\n },\n\n /**\n * Processes a handshake message and returns appropriate actions.\n *\n * Returns an object with an 'action' and other action-specific properties.\n *\n * There are three outcomes when calling this function. First is a successful\n * connection attempt, when pusher:connection_established is received, which\n * results in a 'connected' action with an 'id' property. When passed a\n * pusher:error event, it returns a result with action appropriate to the\n * close code and an error. Otherwise, it raises an exception.\n *\n * @param {String} message\n * @result Object\n */\n processHandshake: function(messageEvent: MessageEvent): Action {\n var message = Protocol.decodeMessage(messageEvent);\n\n if (message.event === 'pusher:connection_established') {\n if (!message.data.activity_timeout) {\n throw 'No activity timeout specified in handshake';\n }\n return {\n action: 'connected',\n id: message.data.socket_id,\n activityTimeout: message.data.activity_timeout * 1000\n };\n } else if (message.event === 'pusher:error') {\n // From protocol 6 close codes are sent only once, so this only\n // happens when connection does not support close codes\n return {\n action: this.getCloseAction(message.data),\n error: this.getCloseError(message.data)\n };\n } else {\n throw 'Invalid handshake';\n }\n },\n\n /**\n * Dispatches the close event and returns an appropriate action name.\n *\n * See:\n * 1. https://developer.mozilla.org/en-US/docs/WebSockets/WebSockets_reference/CloseEvent\n * 2. http://pusher.com/docs/pusher_protocol\n *\n * @param {CloseEvent} closeEvent\n * @return {String} close action name\n */\n getCloseAction: function(closeEvent): string {\n if (closeEvent.code < 4000) {\n // ignore 1000 CLOSE_NORMAL, 1001 CLOSE_GOING_AWAY,\n // 1005 CLOSE_NO_STATUS, 1006 CLOSE_ABNORMAL\n // ignore 1007...3999\n // handle 1002 CLOSE_PROTOCOL_ERROR, 1003 CLOSE_UNSUPPORTED,\n // 1004 CLOSE_TOO_LARGE\n if (closeEvent.code >= 1002 && closeEvent.code <= 1004) {\n return 'backoff';\n } else {\n return null;\n }\n } else if (closeEvent.code === 4000) {\n return 'tls_only';\n } else if (closeEvent.code < 4100) {\n return 'refused';\n } else if (closeEvent.code < 4200) {\n return 'backoff';\n } else if (closeEvent.code < 4300) {\n return 'retry';\n } else {\n // unknown error\n return 'refused';\n }\n },\n\n /**\n * Returns an error or null basing on the close event.\n *\n * Null is returned when connection was closed cleanly. Otherwise, an object\n * with error details is returned.\n *\n * @param {CloseEvent} closeEvent\n * @return {Object} error object\n */\n getCloseError: function(closeEvent): any {\n if (closeEvent.code !== 1000 && closeEvent.code !== 1001) {\n return {\n type: 'PusherError',\n data: {\n code: closeEvent.code,\n message: closeEvent.reason || closeEvent.message\n }\n };\n } else {\n return null;\n }\n }\n};\n\nexport default Protocol;\n","import * as Collections from '../utils/collections';\nimport { default as EventsDispatcher } from '../events/dispatcher';\nimport Protocol from './protocol/protocol';\nimport { PusherEvent } from './protocol/message-types';\nimport Logger from '../logger';\nimport TransportConnection from '../transports/transport_connection';\nimport Socket from '../socket';\n/**\n * Provides Pusher protocol interface for transports.\n *\n * Emits following events:\n * - message - on received messages\n * - ping - on ping requests\n * - pong - on pong responses\n * - error - when the transport emits an error\n * - closed - after closing the transport\n *\n * It also emits more events when connection closes with a code.\n * See Protocol.getCloseAction to get more details.\n *\n * @param {Number} id\n * @param {AbstractTransport} transport\n */\nexport default class Connection extends EventsDispatcher implements Socket {\n id: string;\n transport: TransportConnection;\n activityTimeout: number;\n\n constructor(id: string, transport: TransportConnection) {\n super();\n this.id = id;\n this.transport = transport;\n this.activityTimeout = transport.activityTimeout;\n this.bindListeners();\n }\n\n /** Returns whether used transport handles activity checks by itself\n *\n * @returns {Boolean} true if activity checks are handled by the transport\n */\n handlesActivityChecks() {\n return this.transport.handlesActivityChecks();\n }\n\n /** Sends raw data.\n *\n * @param {String} data\n */\n send(data: any): boolean {\n return this.transport.send(data);\n }\n\n /** Sends an event.\n *\n * @param {String} name\n * @param {String} data\n * @param {String} [channel]\n * @returns {Boolean} whether message was sent or not\n */\n send_event(name: string, data: any, channel?: string): boolean {\n var event: PusherEvent = { event: name, data: data };\n if (channel) {\n event.channel = channel;\n }\n Logger.debug('Event sent', event);\n return this.send(Protocol.encodeMessage(event));\n }\n\n /** Sends a ping message to the server.\n *\n * Basing on the underlying transport, it might send either transport's\n * protocol-specific ping or pusher:ping event.\n */\n ping() {\n if (this.transport.supportsPing()) {\n this.transport.ping();\n } else {\n this.send_event('pusher:ping', {});\n }\n }\n\n /** Closes the connection. */\n close() {\n this.transport.close();\n }\n\n private bindListeners() {\n var listeners = {\n message: (messageEvent: MessageEvent) => {\n var pusherEvent;\n try {\n pusherEvent = Protocol.decodeMessage(messageEvent);\n } catch (e) {\n this.emit('error', {\n type: 'MessageParseError',\n error: e,\n data: messageEvent.data\n });\n }\n\n if (pusherEvent !== undefined) {\n Logger.debug('Event recd', pusherEvent);\n\n switch (pusherEvent.event) {\n case 'pusher:error':\n this.emit('error', {\n type: 'PusherError',\n data: pusherEvent.data\n });\n break;\n case 'pusher:ping':\n this.emit('ping');\n break;\n case 'pusher:pong':\n this.emit('pong');\n break;\n }\n this.emit('message', pusherEvent);\n }\n },\n activity: () => {\n this.emit('activity');\n },\n error: error => {\n this.emit('error', error);\n },\n closed: closeEvent => {\n unbindListeners();\n\n if (closeEvent && closeEvent.code) {\n this.handleCloseEvent(closeEvent);\n }\n\n this.transport = null;\n this.emit('closed');\n }\n };\n\n var unbindListeners = () => {\n Collections.objectApply(listeners, (listener, event) => {\n this.transport.unbind(event, listener);\n });\n };\n\n Collections.objectApply(listeners, (listener, event) => {\n this.transport.bind(event, listener);\n });\n }\n\n private handleCloseEvent(closeEvent: any) {\n var action = Protocol.getCloseAction(closeEvent);\n var error = Protocol.getCloseError(closeEvent);\n if (error) {\n this.emit('error', error);\n }\n if (action) {\n this.emit(action, { action: action, error: error });\n }\n }\n}\n","import Util from '../../util';\nimport * as Collections from '../../utils/collections';\nimport Protocol from '../protocol/protocol';\nimport Connection from '../connection';\nimport TransportConnection from '../../transports/transport_connection';\nimport HandshakePayload from './handshake_payload';\n\n/**\n * Handles Pusher protocol handshakes for transports.\n *\n * Calls back with a result object after handshake is completed. Results\n * always have two fields:\n * - action - string describing action to be taken after the handshake\n * - transport - the transport object passed to the constructor\n *\n * Different actions can set different additional properties on the result.\n * In the case of 'connected' action, there will be a 'connection' property\n * containing a Connection object for the transport. Other actions should\n * carry an 'error' property.\n *\n * @param {AbstractTransport} transport\n * @param {Function} callback\n */\nexport default class Handshake {\n transport: TransportConnection;\n callback: (HandshakePayload) => void;\n onMessage: Function;\n onClosed: Function;\n\n constructor(\n transport: TransportConnection,\n callback: (HandshakePayload) => void\n ) {\n this.transport = transport;\n this.callback = callback;\n this.bindListeners();\n }\n\n close() {\n this.unbindListeners();\n this.transport.close();\n }\n\n private bindListeners() {\n this.onMessage = m => {\n this.unbindListeners();\n\n var result;\n try {\n result = Protocol.processHandshake(m);\n } catch (e) {\n this.finish('error', { error: e });\n this.transport.close();\n return;\n }\n\n if (result.action === 'connected') {\n this.finish('connected', {\n connection: new Connection(result.id, this.transport),\n activityTimeout: result.activityTimeout\n });\n } else {\n this.finish(result.action, { error: result.error });\n this.transport.close();\n }\n };\n\n this.onClosed = closeEvent => {\n this.unbindListeners();\n\n var action = Protocol.getCloseAction(closeEvent) || 'backoff';\n var error = Protocol.getCloseError(closeEvent);\n this.finish(action, { error: error });\n };\n\n this.transport.bind('message', this.onMessage);\n this.transport.bind('closed', this.onClosed);\n }\n\n private unbindListeners() {\n this.transport.unbind('message', this.onMessage);\n this.transport.unbind('closed', this.onClosed);\n }\n\n private finish(action: string, params: any) {\n this.callback(\n Collections.extend({ transport: this.transport, action: action }, params)\n );\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport base64encode from '../base64';\nimport Timeline from './timeline';\nimport Runtime from 'runtime';\n\nexport interface TimelineSenderOptions {\n host?: string;\n port?: number;\n path?: string;\n}\n\nexport default class TimelineSender {\n timeline: Timeline;\n options: TimelineSenderOptions;\n host: string;\n\n constructor(timeline: Timeline, options: TimelineSenderOptions) {\n this.timeline = timeline;\n this.options = options || {};\n }\n\n send(useTLS: boolean, callback?: Function) {\n if (this.timeline.isEmpty()) {\n return;\n }\n\n this.timeline.send(\n Runtime.TimelineTransport.getAgent(this, useTLS),\n callback\n );\n }\n}\n","/** Error classes used throughout the library. */\n// https://github.com/Microsoft/TypeScript-wiki/blob/master/Breaking-Changes.md#extending-built-ins-like-error-array-and-map-may-no-longer-work\nexport class BadEventName extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\nexport class BadChannelName extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\nexport class RequestTimedOut extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class TransportPriorityTooLow extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class TransportClosed extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class UnsupportedFeature extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class UnsupportedTransport extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class UnsupportedStrategy extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class HTTPAuthError extends Error {\n status: number;\n constructor(status: number, msg?: string) {\n super(msg);\n this.status = status;\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n","/**\n * A place to store help URLs for error messages etc\n */\n\nconst urlStore = {\n baseUrl: 'https://pusher.com',\n urls: {\n authenticationEndpoint: {\n path: '/docs/channels/server_api/authenticating_users'\n },\n authorizationEndpoint: {\n path: '/docs/channels/server_api/authorizing-users/'\n },\n javascriptQuickStart: {\n path: '/docs/javascript_quick_start'\n },\n triggeringClientEvents: {\n path: '/docs/client_api_guide/client_events#trigger-events'\n },\n encryptedChannelSupport: {\n fullUrl:\n 'https://github.com/pusher/pusher-js/tree/cc491015371a4bde5743d1c87a0fbac0feb53195#encrypted-channel-support'\n }\n }\n};\n\n/** Builds a consistent string with links to pusher documentation\n *\n * @param {string} key - relevant key in the url_store.urls object\n * @return {string} suffix string to append to log message\n */\nconst buildLogSuffix = function(key: string): string {\n const urlPrefix = 'See:';\n const urlObj = urlStore.urls[key];\n if (!urlObj) return '';\n\n let url;\n if (urlObj.fullUrl) {\n url = urlObj.fullUrl;\n } else if (urlObj.path) {\n url = urlStore.baseUrl + urlObj.path;\n }\n\n if (!url) return '';\n return `${urlPrefix} ${url}`;\n};\n\nexport default { buildLogSuffix };\n","import { default as EventsDispatcher } from '../events/dispatcher';\nimport * as Errors from '../errors';\nimport Logger from '../logger';\nimport Pusher from '../pusher';\nimport { PusherEvent } from '../connection/protocol/message-types';\nimport Metadata from './metadata';\nimport UrlStore from '../utils/url_store';\nimport {\n ChannelAuthorizationData,\n ChannelAuthorizationCallback\n} from '../auth/options';\nimport { HTTPAuthError } from '../errors';\n\n/** Provides base public channel interface with an event emitter.\n *\n * Emits:\n * - pusher:subscription_succeeded - after subscribing successfully\n * - other non-internal events\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\nexport default class Channel extends EventsDispatcher {\n name: string;\n pusher: Pusher;\n subscribed: boolean;\n subscriptionPending: boolean;\n subscriptionCancelled: boolean;\n subscriptionCount: null;\n\n constructor(name: string, pusher: Pusher) {\n super(function(event, data) {\n Logger.debug('No callbacks on ' + name + ' for ' + event);\n });\n\n this.name = name;\n this.pusher = pusher;\n this.subscribed = false;\n this.subscriptionPending = false;\n this.subscriptionCancelled = false;\n }\n\n /** Skips authorization, since public channels don't require it.\n *\n * @param {Function} callback\n */\n authorize(socketId: string, callback: ChannelAuthorizationCallback) {\n return callback(null, { auth: '' });\n }\n\n /** Triggers an event */\n trigger(event: string, data: any) {\n if (event.indexOf('client-') !== 0) {\n throw new Errors.BadEventName(\n \"Event '\" + event + \"' does not start with 'client-'\"\n );\n }\n if (!this.subscribed) {\n var suffix = UrlStore.buildLogSuffix('triggeringClientEvents');\n Logger.warn(\n `Client event triggered before channel 'subscription_succeeded' event . ${suffix}`\n );\n }\n return this.pusher.send_event(event, data, this.name);\n }\n\n /** Signals disconnection to the channel. For internal use only. */\n disconnect() {\n this.subscribed = false;\n this.subscriptionPending = false;\n }\n\n /** Handles a PusherEvent. For internal use only.\n *\n * @param {PusherEvent} event\n */\n handleEvent(event: PusherEvent) {\n var eventName = event.event;\n var data = event.data;\n if (eventName === 'pusher_internal:subscription_succeeded') {\n this.handleSubscriptionSucceededEvent(event);\n } else if (eventName === 'pusher_internal:subscription_count') {\n this.handleSubscriptionCountEvent(event);\n } else if (eventName.indexOf('pusher_internal:') !== 0) {\n var metadata: Metadata = {};\n this.emit(eventName, data, metadata);\n }\n }\n\n handleSubscriptionSucceededEvent(event: PusherEvent) {\n this.subscriptionPending = false;\n this.subscribed = true;\n if (this.subscriptionCancelled) {\n this.pusher.unsubscribe(this.name);\n } else {\n this.emit('pusher:subscription_succeeded', event.data);\n }\n }\n\n handleSubscriptionCountEvent(event: PusherEvent) {\n if (event.data.subscription_count) {\n this.subscriptionCount = event.data.subscription_count;\n }\n\n this.emit('pusher:subscription_count', event.data);\n }\n\n /** Sends a subscription request. For internal use only. */\n subscribe() {\n if (this.subscribed) {\n return;\n }\n this.subscriptionPending = true;\n this.subscriptionCancelled = false;\n this.authorize(\n this.pusher.connection.socket_id,\n (error: Error | null, data: ChannelAuthorizationData) => {\n if (error) {\n this.subscriptionPending = false;\n // Why not bind to 'pusher:subscription_error' a level up, and log there?\n // Binding to this event would cause the warning about no callbacks being\n // bound (see constructor) to be suppressed, that's not what we want.\n Logger.error(error.toString());\n this.emit(\n 'pusher:subscription_error',\n Object.assign(\n {},\n {\n type: 'AuthError',\n error: error.message\n },\n error instanceof HTTPAuthError ? { status: error.status } : {}\n )\n );\n } else {\n this.pusher.send_event('pusher:subscribe', {\n auth: data.auth,\n channel_data: data.channel_data,\n channel: this.name\n });\n }\n }\n );\n }\n\n /** Sends an unsubscription request. For internal use only. */\n unsubscribe() {\n this.subscribed = false;\n this.pusher.send_event('pusher:unsubscribe', {\n channel: this.name\n });\n }\n\n /** Cancels an in progress subscription. For internal use only. */\n cancelSubscription() {\n this.subscriptionCancelled = true;\n }\n\n /** Reinstates an in progress subscripiton. For internal use only. */\n reinstateSubscription() {\n this.subscriptionCancelled = false;\n }\n}\n","import Factory from '../utils/factory';\nimport Channel from './channel';\nimport { ChannelAuthorizationCallback } from '../auth/options';\n\n/** Extends public channels to provide private channel interface.\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\nexport default class PrivateChannel extends Channel {\n /** Authorizes the connection to use the channel.\n *\n * @param {String} socketId\n * @param {Function} callback\n */\n authorize(socketId: string, callback: ChannelAuthorizationCallback) {\n return this.pusher.config.channelAuthorizer(\n {\n channelName: this.name,\n socketId: socketId\n },\n callback\n );\n }\n}\n","import * as Collections from '../utils/collections';\n\n/** Represents a collection of members of a presence channel. */\nexport default class Members {\n members: any;\n count: number;\n myID: any;\n me: any;\n\n constructor() {\n this.reset();\n }\n\n /** Returns member's info for given id.\n *\n * Resulting object containts two fields - id and info.\n *\n * @param {Number} id\n * @return {Object} member's info or null\n */\n get(id: string): any {\n if (Object.prototype.hasOwnProperty.call(this.members, id)) {\n return {\n id: id,\n info: this.members[id]\n };\n } else {\n return null;\n }\n }\n\n /** Calls back for each member in unspecified order.\n *\n * @param {Function} callback\n */\n each(callback: Function) {\n Collections.objectApply(this.members, (member, id) => {\n callback(this.get(id));\n });\n }\n\n /** Updates the id for connected member. For internal use only. */\n setMyID(id: string) {\n this.myID = id;\n }\n\n /** Handles subscription data. For internal use only. */\n onSubscription(subscriptionData: any) {\n this.members = subscriptionData.presence.hash;\n this.count = subscriptionData.presence.count;\n this.me = this.get(this.myID);\n }\n\n /** Adds a new member to the collection. For internal use only. */\n addMember(memberData: any) {\n if (this.get(memberData.user_id) === null) {\n this.count++;\n }\n this.members[memberData.user_id] = memberData.user_info;\n return this.get(memberData.user_id);\n }\n\n /** Adds a member from the collection. For internal use only. */\n removeMember(memberData: any) {\n var member = this.get(memberData.user_id);\n if (member) {\n delete this.members[memberData.user_id];\n this.count--;\n }\n return member;\n }\n\n /** Resets the collection to the initial state. For internal use only. */\n reset() {\n this.members = {};\n this.count = 0;\n this.myID = null;\n this.me = null;\n }\n}\n","import PrivateChannel from './private_channel';\nimport Logger from '../logger';\nimport Members from './members';\nimport Pusher from '../pusher';\nimport UrlStore from 'core/utils/url_store';\nimport { PusherEvent } from '../connection/protocol/message-types';\nimport Metadata from './metadata';\nimport { ChannelAuthorizationData } from '../auth/options';\n\nexport default class PresenceChannel extends PrivateChannel {\n members: Members;\n\n /** Adds presence channel functionality to private channels.\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\n constructor(name: string, pusher: Pusher) {\n super(name, pusher);\n this.members = new Members();\n }\n\n /** Authorizes the connection as a member of the channel.\n *\n * @param {String} socketId\n * @param {Function} callback\n */\n authorize(socketId: string, callback: Function) {\n super.authorize(socketId, async (error, authData) => {\n if (!error) {\n authData = authData as ChannelAuthorizationData;\n if (authData.channel_data != null) {\n var channelData = JSON.parse(authData.channel_data);\n this.members.setMyID(channelData.user_id);\n } else {\n await this.pusher.user.signinDonePromise;\n if (this.pusher.user.user_data != null) {\n // If the user is signed in, get the id of the authenticated user\n // and allow the presence authorization to continue.\n this.members.setMyID(this.pusher.user.user_data.id);\n } else {\n let suffix = UrlStore.buildLogSuffix('authorizationEndpoint');\n Logger.error(\n `Invalid auth response for channel '${this.name}', ` +\n `expected 'channel_data' field. ${suffix}, ` +\n `or the user should be signed in.`\n );\n callback('Invalid auth response');\n return;\n }\n }\n }\n callback(error, authData);\n });\n }\n\n /** Handles presence and subscription events. For internal use only.\n *\n * @param {PusherEvent} event\n */\n handleEvent(event: PusherEvent) {\n var eventName = event.event;\n if (eventName.indexOf('pusher_internal:') === 0) {\n this.handleInternalEvent(event);\n } else {\n var data = event.data;\n var metadata: Metadata = {};\n if (event.user_id) {\n metadata.user_id = event.user_id;\n }\n this.emit(eventName, data, metadata);\n }\n }\n handleInternalEvent(event: PusherEvent) {\n var eventName = event.event;\n var data = event.data;\n switch (eventName) {\n case 'pusher_internal:subscription_succeeded':\n this.handleSubscriptionSucceededEvent(event);\n break;\n case 'pusher_internal:subscription_count':\n this.handleSubscriptionCountEvent(event);\n break;\n case 'pusher_internal:member_added':\n var addedMember = this.members.addMember(data);\n this.emit('pusher:member_added', addedMember);\n break;\n case 'pusher_internal:member_removed':\n var removedMember = this.members.removeMember(data);\n if (removedMember) {\n this.emit('pusher:member_removed', removedMember);\n }\n break;\n }\n }\n\n handleSubscriptionSucceededEvent(event: PusherEvent) {\n this.subscriptionPending = false;\n this.subscribed = true;\n if (this.subscriptionCancelled) {\n this.pusher.unsubscribe(this.name);\n } else {\n this.members.onSubscription(event.data);\n this.emit('pusher:subscription_succeeded', this.members);\n }\n }\n\n /** Resets the channel state, including members map. For internal use only. */\n disconnect() {\n this.members.reset();\n super.disconnect();\n }\n}\n","import PrivateChannel from './private_channel';\nimport * as Errors from '../errors';\nimport Logger from '../logger';\nimport Pusher from '../pusher';\nimport { decode as encodeUTF8 } from '@stablelib/utf8';\nimport { decode as decodeBase64 } from '@stablelib/base64';\nimport Dispatcher from '../events/dispatcher';\nimport { PusherEvent } from '../connection/protocol/message-types';\nimport {\n ChannelAuthorizationData,\n ChannelAuthorizationCallback\n} from '../auth/options';\nimport * as nacl from 'tweetnacl';\n\n/** Extends private channels to provide encrypted channel interface.\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\nexport default class EncryptedChannel extends PrivateChannel {\n key: Uint8Array = null;\n nacl: nacl;\n\n constructor(name: string, pusher: Pusher, nacl: nacl) {\n super(name, pusher);\n this.nacl = nacl;\n }\n\n /** Authorizes the connection to use the channel.\n *\n * @param {String} socketId\n * @param {Function} callback\n */\n authorize(socketId: string, callback: ChannelAuthorizationCallback) {\n super.authorize(\n socketId,\n (error: Error | null, authData: ChannelAuthorizationData) => {\n if (error) {\n callback(error, authData);\n return;\n }\n let sharedSecret = authData['shared_secret'];\n if (!sharedSecret) {\n callback(\n new Error(\n `No shared_secret key in auth payload for encrypted channel: ${this.name}`\n ),\n null\n );\n return;\n }\n this.key = decodeBase64(sharedSecret);\n delete authData['shared_secret'];\n callback(null, authData);\n }\n );\n }\n\n trigger(event: string, data: any): boolean {\n throw new Errors.UnsupportedFeature(\n 'Client events are not currently supported for encrypted channels'\n );\n }\n\n /** Handles an event. For internal use only.\n *\n * @param {PusherEvent} event\n */\n handleEvent(event: PusherEvent) {\n var eventName = event.event;\n var data = event.data;\n if (\n eventName.indexOf('pusher_internal:') === 0 ||\n eventName.indexOf('pusher:') === 0\n ) {\n super.handleEvent(event);\n return;\n }\n this.handleEncryptedEvent(eventName, data);\n }\n\n private handleEncryptedEvent(event: string, data: any): void {\n if (!this.key) {\n Logger.debug(\n 'Received encrypted event before key has been retrieved from the authEndpoint'\n );\n return;\n }\n if (!data.ciphertext || !data.nonce) {\n Logger.error(\n 'Unexpected format for encrypted event, expected object with `ciphertext` and `nonce` fields, got: ' +\n data\n );\n return;\n }\n let cipherText = decodeBase64(data.ciphertext);\n if (cipherText.length < this.nacl.secretbox.overheadLength) {\n Logger.error(\n `Expected encrypted event ciphertext length to be ${this.nacl.secretbox.overheadLength}, got: ${cipherText.length}`\n );\n return;\n }\n let nonce = decodeBase64(data.nonce);\n if (nonce.length < this.nacl.secretbox.nonceLength) {\n Logger.error(\n `Expected encrypted event nonce length to be ${this.nacl.secretbox.nonceLength}, got: ${nonce.length}`\n );\n return;\n }\n\n let bytes = this.nacl.secretbox.open(cipherText, nonce, this.key);\n if (bytes === null) {\n Logger.debug(\n 'Failed to decrypt an event, probably because it was encrypted with a different key. Fetching a new key from the authEndpoint...'\n );\n // Try a single time to retrieve a new auth key and decrypt the event with it\n // If this fails, a new key will be requested when a new message is received\n this.authorize(this.pusher.connection.socket_id, (error, authData) => {\n if (error) {\n Logger.error(\n `Failed to make a request to the authEndpoint: ${authData}. Unable to fetch new key, so dropping encrypted event`\n );\n return;\n }\n bytes = this.nacl.secretbox.open(cipherText, nonce, this.key);\n if (bytes === null) {\n Logger.error(\n `Failed to decrypt event with new key. Dropping encrypted event`\n );\n return;\n }\n this.emit(event, this.getDataToEmit(bytes));\n return;\n });\n return;\n }\n this.emit(event, this.getDataToEmit(bytes));\n }\n\n // Try and parse the decrypted bytes as JSON. If we can't parse it, just\n // return the utf-8 string\n getDataToEmit(bytes: Uint8Array): string {\n let raw = encodeUTF8(bytes);\n try {\n return JSON.parse(raw);\n } catch {\n return raw;\n }\n }\n}\n","import { default as EventsDispatcher } from '../events/dispatcher';\nimport { OneOffTimer as Timer } from '../utils/timers';\nimport { Config } from '../config';\nimport Logger from '../logger';\nimport HandshakePayload from './handshake/handshake_payload';\nimport Connection from './connection';\nimport Strategy from '../strategies/strategy';\nimport StrategyRunner from '../strategies/strategy_runner';\nimport * as Collections from '../utils/collections';\nimport Timeline from '../timeline/timeline';\nimport ConnectionManagerOptions from './connection_manager_options';\nimport Runtime from 'runtime';\n\nimport {\n ErrorCallbacks,\n HandshakeCallbacks,\n ConnectionCallbacks\n} from './callbacks';\nimport Action from './protocol/action';\n\n/** Manages connection to Pusher.\n *\n * Uses a strategy (currently only default), timers and network availability\n * info to establish a connection and export its state. In case of failures,\n * manages reconnection attempts.\n *\n * Exports state changes as following events:\n * - \"state_change\", { previous: p, current: state }\n * - state\n *\n * States:\n * - initialized - initial state, never transitioned to\n * - connecting - connection is being established\n * - connected - connection has been fully established\n * - disconnected - on requested disconnection\n * - unavailable - after connection timeout or when there's no network\n * - failed - when the connection strategy is not supported\n *\n * Options:\n * - unavailableTimeout - time to transition to unavailable state\n * - activityTimeout - time after which ping message should be sent\n * - pongTimeout - time for Pusher to respond with pong before reconnecting\n *\n * @param {String} key application key\n * @param {Object} options\n */\nexport default class ConnectionManager extends EventsDispatcher {\n key: string;\n options: ConnectionManagerOptions;\n state: string;\n connection: Connection;\n usingTLS: boolean;\n timeline: Timeline;\n socket_id: string;\n unavailableTimer: Timer;\n activityTimer: Timer;\n retryTimer: Timer;\n activityTimeout: number;\n strategy: Strategy;\n runner: StrategyRunner;\n errorCallbacks: ErrorCallbacks;\n handshakeCallbacks: HandshakeCallbacks;\n connectionCallbacks: ConnectionCallbacks;\n\n constructor(key: string, options: ConnectionManagerOptions) {\n super();\n this.state = 'initialized';\n this.connection = null;\n\n this.key = key;\n this.options = options;\n this.timeline = this.options.timeline;\n this.usingTLS = this.options.useTLS;\n\n this.errorCallbacks = this.buildErrorCallbacks();\n this.connectionCallbacks = this.buildConnectionCallbacks(\n this.errorCallbacks\n );\n this.handshakeCallbacks = this.buildHandshakeCallbacks(this.errorCallbacks);\n\n var Network = Runtime.getNetwork();\n\n Network.bind('online', () => {\n this.timeline.info({ netinfo: 'online' });\n if (this.state === 'connecting' || this.state === 'unavailable') {\n this.retryIn(0);\n }\n });\n Network.bind('offline', () => {\n this.timeline.info({ netinfo: 'offline' });\n if (this.connection) {\n this.sendActivityCheck();\n }\n });\n\n this.updateStrategy();\n }\n\n switchCluster(key: string) {\n this.key = key;\n // This ensures that the new config coming from\n // pusher instance are taken into account\n // such as appKey and cluster\n this.updateStrategy();\n this.retryIn(0);\n }\n\n /** Establishes a connection to Pusher.\n *\n * Does nothing when connection is already established. See top-level doc\n * to find events emitted on connection attempts.\n */\n connect() {\n if (this.connection || this.runner) {\n return;\n }\n if (!this.strategy.isSupported()) {\n this.updateState('failed');\n return;\n }\n this.updateState('connecting');\n this.startConnecting();\n this.setUnavailableTimer();\n }\n\n /** Sends raw data.\n *\n * @param {String} data\n */\n send(data) {\n if (this.connection) {\n return this.connection.send(data);\n } else {\n return false;\n }\n }\n\n /** Sends an event.\n *\n * @param {String} name\n * @param {String} data\n * @param {String} [channel]\n * @returns {Boolean} whether message was sent or not\n */\n send_event(name: string, data: any, channel?: string) {\n if (this.connection) {\n return this.connection.send_event(name, data, channel);\n } else {\n return false;\n }\n }\n\n /** Closes the connection. */\n disconnect() {\n this.disconnectInternally();\n this.updateState('disconnected');\n }\n\n isUsingTLS() {\n return this.usingTLS;\n }\n\n private startConnecting() {\n var callback = (error, handshake) => {\n if (error) {\n this.runner = this.strategy.connect(0, callback);\n } else {\n if (handshake.action === 'error') {\n this.emit('error', {\n type: 'HandshakeError',\n error: handshake.error\n });\n this.timeline.error({ handshakeError: handshake.error });\n } else {\n this.abortConnecting(); // we don't support switching connections yet\n this.handshakeCallbacks[handshake.action](handshake);\n }\n }\n };\n this.runner = this.strategy.connect(0, callback);\n }\n\n private abortConnecting() {\n if (this.runner) {\n this.runner.abort();\n this.runner = null;\n }\n }\n\n private disconnectInternally() {\n this.abortConnecting();\n this.clearRetryTimer();\n this.clearUnavailableTimer();\n if (this.connection) {\n var connection = this.abandonConnection();\n connection.close();\n }\n }\n\n private updateStrategy() {\n this.strategy = this.options.getStrategy({\n key: this.key,\n timeline: this.timeline,\n useTLS: this.usingTLS\n });\n }\n\n private retryIn(delay) {\n this.timeline.info({ action: 'retry', delay: delay });\n if (delay > 0) {\n this.emit('connecting_in', Math.round(delay / 1000));\n }\n this.retryTimer = new Timer(delay || 0, () => {\n this.disconnectInternally();\n this.connect();\n });\n }\n\n private clearRetryTimer() {\n if (this.retryTimer) {\n this.retryTimer.ensureAborted();\n this.retryTimer = null;\n }\n }\n\n private setUnavailableTimer() {\n this.unavailableTimer = new Timer(this.options.unavailableTimeout, () => {\n this.updateState('unavailable');\n });\n }\n\n private clearUnavailableTimer() {\n if (this.unavailableTimer) {\n this.unavailableTimer.ensureAborted();\n }\n }\n\n private sendActivityCheck() {\n this.stopActivityCheck();\n this.connection.ping();\n // wait for pong response\n this.activityTimer = new Timer(this.options.pongTimeout, () => {\n this.timeline.error({ pong_timed_out: this.options.pongTimeout });\n this.retryIn(0);\n });\n }\n\n private resetActivityCheck() {\n this.stopActivityCheck();\n // send ping after inactivity\n if (this.connection && !this.connection.handlesActivityChecks()) {\n this.activityTimer = new Timer(this.activityTimeout, () => {\n this.sendActivityCheck();\n });\n }\n }\n\n private stopActivityCheck() {\n if (this.activityTimer) {\n this.activityTimer.ensureAborted();\n }\n }\n\n private buildConnectionCallbacks(\n errorCallbacks: ErrorCallbacks\n ): ConnectionCallbacks {\n return Collections.extend({}, errorCallbacks, {\n message: message => {\n // includes pong messages from server\n this.resetActivityCheck();\n this.emit('message', message);\n },\n ping: () => {\n this.send_event('pusher:pong', {});\n },\n activity: () => {\n this.resetActivityCheck();\n },\n error: error => {\n // just emit error to user - socket will already be closed by browser\n this.emit('error', error);\n },\n closed: () => {\n this.abandonConnection();\n if (this.shouldRetry()) {\n this.retryIn(1000);\n }\n }\n });\n }\n\n private buildHandshakeCallbacks(\n errorCallbacks: ErrorCallbacks\n ): HandshakeCallbacks {\n return Collections.extend({}, errorCallbacks, {\n connected: (handshake: HandshakePayload) => {\n this.activityTimeout = Math.min(\n this.options.activityTimeout,\n handshake.activityTimeout,\n handshake.connection.activityTimeout || Infinity\n );\n this.clearUnavailableTimer();\n this.setConnection(handshake.connection);\n this.socket_id = this.connection.id;\n this.updateState('connected', { socket_id: this.socket_id });\n }\n });\n }\n\n private buildErrorCallbacks(): ErrorCallbacks {\n let withErrorEmitted = callback => {\n return (result: Action | HandshakePayload) => {\n if (result.error) {\n this.emit('error', { type: 'WebSocketError', error: result.error });\n }\n callback(result);\n };\n };\n\n return {\n tls_only: withErrorEmitted(() => {\n this.usingTLS = true;\n this.updateStrategy();\n this.retryIn(0);\n }),\n refused: withErrorEmitted(() => {\n this.disconnect();\n }),\n backoff: withErrorEmitted(() => {\n this.retryIn(1000);\n }),\n retry: withErrorEmitted(() => {\n this.retryIn(0);\n })\n };\n }\n\n private setConnection(connection) {\n this.connection = connection;\n for (var event in this.connectionCallbacks) {\n this.connection.bind(event, this.connectionCallbacks[event]);\n }\n this.resetActivityCheck();\n }\n\n private abandonConnection() {\n if (!this.connection) {\n return;\n }\n this.stopActivityCheck();\n for (var event in this.connectionCallbacks) {\n this.connection.unbind(event, this.connectionCallbacks[event]);\n }\n var connection = this.connection;\n this.connection = null;\n return connection;\n }\n\n private updateState(newState: string, data?: any) {\n var previousState = this.state;\n this.state = newState;\n if (previousState !== newState) {\n var newStateDescription = newState;\n if (newStateDescription === 'connected') {\n newStateDescription += ' with new socket ID ' + data.socket_id;\n }\n Logger.debug(\n 'State changed',\n previousState + ' -> ' + newStateDescription\n );\n this.timeline.info({ state: newState, params: data });\n this.emit('state_change', { previous: previousState, current: newState });\n this.emit(newState, data);\n }\n }\n\n private shouldRetry(): boolean {\n return this.state === 'connecting' || this.state === 'connected';\n }\n}\n","import Channel from './channel';\nimport * as Collections from '../utils/collections';\nimport ChannelTable from './channel_table';\nimport Factory from '../utils/factory';\nimport Pusher from '../pusher';\nimport Logger from '../logger';\nimport * as Errors from '../errors';\nimport urlStore from '../utils/url_store';\n\n/** Handles a channel map. */\nexport default class Channels {\n channels: ChannelTable;\n\n constructor() {\n this.channels = {};\n }\n\n /** Creates or retrieves an existing channel by its name.\n *\n * @param {String} name\n * @param {Pusher} pusher\n * @return {Channel}\n */\n add(name: string, pusher: Pusher) {\n if (!this.channels[name]) {\n this.channels[name] = createChannel(name, pusher);\n }\n return this.channels[name];\n }\n\n /** Returns a list of all channels\n *\n * @return {Array}\n */\n all(): Channel[] {\n return Collections.values(this.channels);\n }\n\n /** Finds a channel by its name.\n *\n * @param {String} name\n * @return {Channel} channel or null if it doesn't exist\n */\n find(name: string) {\n return this.channels[name];\n }\n\n /** Removes a channel from the map.\n *\n * @param {String} name\n */\n remove(name: string) {\n var channel = this.channels[name];\n delete this.channels[name];\n return channel;\n }\n\n /** Proxies disconnection signal to all channels. */\n disconnect() {\n Collections.objectApply(this.channels, function(channel) {\n channel.disconnect();\n });\n }\n}\n\nfunction createChannel(name: string, pusher: Pusher): Channel {\n if (name.indexOf('private-encrypted-') === 0) {\n if (pusher.config.nacl) {\n return Factory.createEncryptedChannel(name, pusher, pusher.config.nacl);\n }\n let errMsg =\n 'Tried to subscribe to a private-encrypted- channel but no nacl implementation available';\n let suffix = urlStore.buildLogSuffix('encryptedChannelSupport');\n throw new Errors.UnsupportedFeature(`${errMsg}. ${suffix}`);\n } else if (name.indexOf('private-') === 0) {\n return Factory.createPrivateChannel(name, pusher);\n } else if (name.indexOf('presence-') === 0) {\n return Factory.createPresenceChannel(name, pusher);\n } else if (name.indexOf('#') === 0) {\n throw new Errors.BadChannelName(\n 'Cannot create a channel with name \"' + name + '\".'\n );\n } else {\n return Factory.createChannel(name, pusher);\n }\n}\n","import AssistantToTheTransportManager from '../transports/assistant_to_the_transport_manager';\nimport PingDelayOptions from '../transports/ping_delay_options';\nimport Transport from '../transports/transport';\nimport TransportManager from '../transports/transport_manager';\nimport Handshake from '../connection/handshake';\nimport TransportConnection from '../transports/transport_connection';\nimport SocketHooks from '../http/socket_hooks';\nimport HTTPSocket from '../http/http_socket';\n\nimport Timeline from '../timeline/timeline';\nimport {\n default as TimelineSender,\n TimelineSenderOptions\n} from '../timeline/timeline_sender';\nimport PresenceChannel from '../channels/presence_channel';\nimport PrivateChannel from '../channels/private_channel';\nimport EncryptedChannel from '../channels/encrypted_channel';\nimport Channel from '../channels/channel';\nimport ConnectionManager from '../connection/connection_manager';\nimport ConnectionManagerOptions from '../connection/connection_manager_options';\nimport Ajax from '../http/ajax';\nimport Channels from '../channels/channels';\nimport Pusher from '../pusher';\nimport { Config } from '../config';\nimport * as nacl from 'tweetnacl';\n\nvar Factory = {\n createChannels(): Channels {\n return new Channels();\n },\n\n createConnectionManager(\n key: string,\n options: ConnectionManagerOptions\n ): ConnectionManager {\n return new ConnectionManager(key, options);\n },\n\n createChannel(name: string, pusher: Pusher): Channel {\n return new Channel(name, pusher);\n },\n\n createPrivateChannel(name: string, pusher: Pusher): PrivateChannel {\n return new PrivateChannel(name, pusher);\n },\n\n createPresenceChannel(name: string, pusher: Pusher): PresenceChannel {\n return new PresenceChannel(name, pusher);\n },\n\n createEncryptedChannel(\n name: string,\n pusher: Pusher,\n nacl: nacl\n ): EncryptedChannel {\n return new EncryptedChannel(name, pusher, nacl);\n },\n\n createTimelineSender(timeline: Timeline, options: TimelineSenderOptions) {\n return new TimelineSender(timeline, options);\n },\n\n createHandshake(\n transport: TransportConnection,\n callback: (HandshakePayload) => void\n ): Handshake {\n return new Handshake(transport, callback);\n },\n\n createAssistantToTheTransportManager(\n manager: TransportManager,\n transport: Transport,\n options: PingDelayOptions\n ): AssistantToTheTransportManager {\n return new AssistantToTheTransportManager(manager, transport, options);\n }\n};\n\nexport default Factory;\n","import AssistantToTheTransportManager from './assistant_to_the_transport_manager';\nimport Transport from './transport';\nimport PingDelayOptions from './ping_delay_options';\nimport Factory from '../utils/factory';\n\nexport interface TransportManagerOptions extends PingDelayOptions {\n lives?: number;\n}\n\n/** Keeps track of the number of lives left for a transport.\n *\n * In the beginning of a session, transports may be assigned a number of\n * lives. When an AssistantToTheTransportManager instance reports a transport\n * connection closed uncleanly, the transport loses a life. When the number\n * of lives drops to zero, the transport gets disabled by its manager.\n *\n * @param {Object} options\n */\nexport default class TransportManager {\n options: TransportManagerOptions;\n livesLeft: number;\n\n constructor(options: TransportManagerOptions) {\n this.options = options || {};\n this.livesLeft = this.options.lives || Infinity;\n }\n\n /** Creates a assistant for the transport.\n *\n * @param {Transport} transport\n * @returns {AssistantToTheTransportManager}\n */\n getAssistant(transport: Transport): AssistantToTheTransportManager {\n return Factory.createAssistantToTheTransportManager(this, transport, {\n minPingDelay: this.options.minPingDelay,\n maxPingDelay: this.options.maxPingDelay\n });\n }\n\n /** Returns whether the transport has any lives left.\n *\n * @returns {Boolean}\n */\n isAlive(): boolean {\n return this.livesLeft > 0;\n }\n\n /** Takes one life from the transport. */\n reportDeath() {\n this.livesLeft -= 1;\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport { OneOffTimer as Timer } from '../utils/timers';\nimport Strategy from './strategy';\nimport StrategyOptions from './strategy_options';\n\n/** Loops through strategies with optional timeouts.\n *\n * Options:\n * - loop - whether it should loop through the substrategy list\n * - timeout - initial timeout for a single substrategy\n * - timeoutLimit - maximum timeout\n *\n * @param {Strategy[]} strategies\n * @param {Object} options\n */\nexport default class SequentialStrategy implements Strategy {\n strategies: Strategy[];\n loop: boolean;\n failFast: boolean;\n timeout: number;\n timeoutLimit: number;\n\n constructor(strategies: Strategy[], options: StrategyOptions) {\n this.strategies = strategies;\n this.loop = Boolean(options.loop);\n this.failFast = Boolean(options.failFast);\n this.timeout = options.timeout;\n this.timeoutLimit = options.timeoutLimit;\n }\n\n isSupported(): boolean {\n return Collections.any(this.strategies, Util.method('isSupported'));\n }\n\n connect(minPriority: number, callback: Function) {\n var strategies = this.strategies;\n var current = 0;\n var timeout = this.timeout;\n var runner = null;\n\n var tryNextStrategy = (error, handshake) => {\n if (handshake) {\n callback(null, handshake);\n } else {\n current = current + 1;\n if (this.loop) {\n current = current % strategies.length;\n }\n\n if (current < strategies.length) {\n if (timeout) {\n timeout = timeout * 2;\n if (this.timeoutLimit) {\n timeout = Math.min(timeout, this.timeoutLimit);\n }\n }\n runner = this.tryStrategy(\n strategies[current],\n minPriority,\n { timeout, failFast: this.failFast },\n tryNextStrategy\n );\n } else {\n callback(true);\n }\n }\n };\n\n runner = this.tryStrategy(\n strategies[current],\n minPriority,\n { timeout: timeout, failFast: this.failFast },\n tryNextStrategy\n );\n\n return {\n abort: function() {\n runner.abort();\n },\n forceMinPriority: function(p) {\n minPriority = p;\n if (runner) {\n runner.forceMinPriority(p);\n }\n }\n };\n }\n\n private tryStrategy(\n strategy: Strategy,\n minPriority: number,\n options: StrategyOptions,\n callback: Function\n ) {\n var timer = null;\n var runner = null;\n\n if (options.timeout > 0) {\n timer = new Timer(options.timeout, function() {\n runner.abort();\n callback(true);\n });\n }\n\n runner = strategy.connect(minPriority, function(error, handshake) {\n if (error && timer && timer.isRunning() && !options.failFast) {\n // advance to the next strategy after the timeout\n return;\n }\n if (timer) {\n timer.ensureAborted();\n }\n callback(error, handshake);\n });\n\n return {\n abort: function() {\n if (timer) {\n timer.ensureAborted();\n }\n runner.abort();\n },\n forceMinPriority: function(p) {\n runner.forceMinPriority(p);\n }\n };\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport Strategy from './strategy';\n\n/** Launches all substrategies and emits prioritized connected transports.\n *\n * @param {Array} strategies\n */\nexport default class BestConnectedEverStrategy implements Strategy {\n strategies: Strategy[];\n\n constructor(strategies: Strategy[]) {\n this.strategies = strategies;\n }\n\n isSupported(): boolean {\n return Collections.any(this.strategies, Util.method('isSupported'));\n }\n\n connect(minPriority: number, callback: Function) {\n return connect(this.strategies, minPriority, function(i, runners) {\n return function(error, handshake) {\n runners[i].error = error;\n if (error) {\n if (allRunnersFailed(runners)) {\n callback(true);\n }\n return;\n }\n Collections.apply(runners, function(runner) {\n runner.forceMinPriority(handshake.transport.priority);\n });\n callback(null, handshake);\n };\n });\n }\n}\n\n/** Connects to all strategies in parallel.\n *\n * Callback builder should be a function that takes two arguments: index\n * and a list of runners. It should return another function that will be\n * passed to the substrategy with given index. Runners can be aborted using\n * abortRunner(s) functions from this class.\n *\n * @param {Array} strategies\n * @param {Function} callbackBuilder\n * @return {Object} strategy runner\n */\nfunction connect(\n strategies: Strategy[],\n minPriority: number,\n callbackBuilder: Function\n) {\n var runners = Collections.map(strategies, function(strategy, i, _, rs) {\n return strategy.connect(minPriority, callbackBuilder(i, rs));\n });\n return {\n abort: function() {\n Collections.apply(runners, abortRunner);\n },\n forceMinPriority: function(p) {\n Collections.apply(runners, function(runner) {\n runner.forceMinPriority(p);\n });\n }\n };\n}\n\nfunction allRunnersFailed(runners): boolean {\n return Collections.all(runners, function(runner) {\n return Boolean(runner.error);\n });\n}\n\nfunction abortRunner(runner) {\n if (!runner.error && !runner.aborted) {\n runner.abort();\n runner.aborted = true;\n }\n}\n","import Util from '../util';\nimport Runtime from 'runtime';\nimport Strategy from './strategy';\nimport SequentialStrategy from './sequential_strategy';\nimport StrategyOptions from './strategy_options';\nimport TransportStrategy from './transport_strategy';\nimport Timeline from '../timeline/timeline';\nimport * as Collections from '../utils/collections';\n\nexport interface TransportStrategyDictionary {\n [key: string]: TransportStrategy;\n}\n\n/** Caches the last successful transport and, after the first few attempts,\n * uses the cached transport for subsequent attempts.\n *\n * @param {Strategy} strategy\n * @param {Object} transports\n * @param {Object} options\n */\nexport default class WebSocketPrioritizedCachedStrategy implements Strategy {\n strategy: Strategy;\n transports: TransportStrategyDictionary;\n ttl: number;\n usingTLS: boolean;\n timeline: Timeline;\n\n constructor(\n strategy: Strategy,\n transports: TransportStrategyDictionary,\n options: StrategyOptions\n ) {\n this.strategy = strategy;\n this.transports = transports;\n this.ttl = options.ttl || 1800 * 1000;\n this.usingTLS = options.useTLS;\n this.timeline = options.timeline;\n }\n\n isSupported(): boolean {\n return this.strategy.isSupported();\n }\n\n connect(minPriority: number, callback: Function) {\n var usingTLS = this.usingTLS;\n var info = fetchTransportCache(usingTLS);\n var cacheSkipCount = info && info.cacheSkipCount ? info.cacheSkipCount : 0;\n\n var strategies = [this.strategy];\n if (info && info.timestamp + this.ttl >= Util.now()) {\n var transport = this.transports[info.transport];\n if (transport) {\n if (['ws', 'wss'].includes(info.transport) || cacheSkipCount > 3) {\n this.timeline.info({\n cached: true,\n transport: info.transport,\n latency: info.latency\n });\n strategies.push(\n new SequentialStrategy([transport], {\n timeout: info.latency * 2 + 1000,\n failFast: true\n })\n );\n } else {\n cacheSkipCount++;\n }\n }\n }\n\n var startTimestamp = Util.now();\n var runner = strategies\n .pop()\n .connect(minPriority, function cb(error, handshake) {\n if (error) {\n flushTransportCache(usingTLS);\n if (strategies.length > 0) {\n startTimestamp = Util.now();\n runner = strategies.pop().connect(minPriority, cb);\n } else {\n callback(error);\n }\n } else {\n storeTransportCache(\n usingTLS,\n handshake.transport.name,\n Util.now() - startTimestamp,\n cacheSkipCount\n );\n callback(null, handshake);\n }\n });\n\n return {\n abort: function() {\n runner.abort();\n },\n forceMinPriority: function(p) {\n minPriority = p;\n if (runner) {\n runner.forceMinPriority(p);\n }\n }\n };\n }\n}\n\nfunction getTransportCacheKey(usingTLS: boolean): string {\n return 'pusherTransport' + (usingTLS ? 'TLS' : 'NonTLS');\n}\n\nfunction fetchTransportCache(usingTLS: boolean): any {\n var storage = Runtime.getLocalStorage();\n if (storage) {\n try {\n var serializedCache = storage[getTransportCacheKey(usingTLS)];\n if (serializedCache) {\n return JSON.parse(serializedCache);\n }\n } catch (e) {\n flushTransportCache(usingTLS);\n }\n }\n return null;\n}\n\nfunction storeTransportCache(\n usingTLS: boolean,\n transport: TransportStrategy,\n latency: number,\n cacheSkipCount: number\n) {\n var storage = Runtime.getLocalStorage();\n if (storage) {\n try {\n storage[getTransportCacheKey(usingTLS)] = Collections.safeJSONStringify({\n timestamp: Util.now(),\n transport: transport,\n latency: latency,\n cacheSkipCount: cacheSkipCount\n });\n } catch (e) {\n // catch over quota exceptions raised by localStorage\n }\n }\n}\n\nfunction flushTransportCache(usingTLS: boolean) {\n var storage = Runtime.getLocalStorage();\n if (storage) {\n try {\n delete storage[getTransportCacheKey(usingTLS)];\n } catch (e) {\n // catch exceptions raised by localStorage\n }\n }\n}\n","import { OneOffTimer as Timer } from '../utils/timers';\nimport Strategy from './strategy';\nimport StrategyOptions from './strategy_options';\n\n/** Runs substrategy after specified delay.\n *\n * Options:\n * - delay - time in miliseconds to delay the substrategy attempt\n *\n * @param {Strategy} strategy\n * @param {Object} options\n */\nexport default class DelayedStrategy implements Strategy {\n strategy: Strategy;\n options: { delay: number };\n\n constructor(strategy: Strategy, { delay: number }) {\n this.strategy = strategy;\n this.options = { delay: number };\n }\n\n isSupported(): boolean {\n return this.strategy.isSupported();\n }\n\n connect(minPriority: number, callback: Function) {\n var strategy = this.strategy;\n var runner;\n var timer = new Timer(this.options.delay, function() {\n runner = strategy.connect(minPriority, callback);\n });\n\n return {\n abort: function() {\n timer.ensureAborted();\n if (runner) {\n runner.abort();\n }\n },\n forceMinPriority: function(p) {\n minPriority = p;\n if (runner) {\n runner.forceMinPriority(p);\n }\n }\n };\n }\n}\n","import Strategy from './strategy';\nimport StrategyRunner from './strategy_runner';\n\n/** Proxies method calls to one of substrategies basing on the test function.\n *\n * @param {Function} test\n * @param {Strategy} trueBranch strategy used when test returns true\n * @param {Strategy} falseBranch strategy used when test returns false\n */\nexport default class IfStrategy implements Strategy {\n test: () => boolean;\n trueBranch: Strategy;\n falseBranch: Strategy;\n\n constructor(\n test: () => boolean,\n trueBranch: Strategy,\n falseBranch: Strategy\n ) {\n this.test = test;\n this.trueBranch = trueBranch;\n this.falseBranch = falseBranch;\n }\n\n isSupported(): boolean {\n var branch = this.test() ? this.trueBranch : this.falseBranch;\n return branch.isSupported();\n }\n\n connect(minPriority: number, callback: Function): StrategyRunner {\n var branch = this.test() ? this.trueBranch : this.falseBranch;\n return branch.connect(minPriority, callback);\n }\n}\n","import Strategy from './strategy';\nimport StrategyRunner from './strategy_runner';\n\n/** Launches the substrategy and terminates on the first open connection.\n *\n * @param {Strategy} strategy\n */\nexport default class FirstConnectedStrategy implements Strategy {\n strategy: Strategy;\n\n constructor(strategy: Strategy) {\n this.strategy = strategy;\n }\n\n isSupported(): boolean {\n return this.strategy.isSupported();\n }\n\n connect(minPriority: number, callback: Function): StrategyRunner {\n var runner = this.strategy.connect(minPriority, function(error, handshake) {\n if (handshake) {\n runner.abort();\n }\n callback(error, handshake);\n });\n return runner;\n }\n}\n","import * as Collections from 'core/utils/collections';\nimport TransportManager from 'core/transports/transport_manager';\nimport Strategy from 'core/strategies/strategy';\nimport SequentialStrategy from 'core/strategies/sequential_strategy';\nimport BestConnectedEverStrategy from 'core/strategies/best_connected_ever_strategy';\nimport WebSocketPrioritizedCachedStrategy, {\n TransportStrategyDictionary\n} from 'core/strategies/websocket_prioritized_cached_strategy';\nimport DelayedStrategy from 'core/strategies/delayed_strategy';\nimport IfStrategy from 'core/strategies/if_strategy';\nimport FirstConnectedStrategy from 'core/strategies/first_connected_strategy';\nimport { Config } from 'core/config';\nimport StrategyOptions from 'core/strategies/strategy_options';\n\nfunction testSupportsStrategy(strategy: Strategy) {\n return function() {\n return strategy.isSupported();\n };\n}\n\nvar getDefaultStrategy = function(\n config: Config,\n baseOptions: StrategyOptions,\n defineTransport: Function\n): Strategy {\n var definedTransports = {};\n\n function defineTransportStrategy(\n name: string,\n type: string,\n priority: number,\n options: StrategyOptions,\n manager?: TransportManager\n ) {\n var transport = defineTransport(\n config,\n name,\n type,\n priority,\n options,\n manager\n );\n\n definedTransports[name] = transport;\n\n return transport;\n }\n\n var ws_options: StrategyOptions = Object.assign({}, baseOptions, {\n hostNonTLS: config.wsHost + ':' + config.wsPort,\n hostTLS: config.wsHost + ':' + config.wssPort,\n httpPath: config.wsPath\n });\n var wss_options: StrategyOptions = Collections.extend({}, ws_options, {\n useTLS: true\n });\n var http_options: StrategyOptions = Object.assign({}, baseOptions, {\n hostNonTLS: config.httpHost + ':' + config.httpPort,\n hostTLS: config.httpHost + ':' + config.httpsPort,\n httpPath: config.httpPath\n });\n var timeouts = {\n loop: true,\n timeout: 15000,\n timeoutLimit: 60000\n };\n\n var ws_manager = new TransportManager({\n minPingDelay: 10000,\n maxPingDelay: config.activityTimeout\n });\n var streaming_manager = new TransportManager({\n lives: 2,\n minPingDelay: 10000,\n maxPingDelay: config.activityTimeout\n });\n\n var ws_transport = defineTransportStrategy(\n 'ws',\n 'ws',\n 3,\n ws_options,\n ws_manager\n );\n var wss_transport = defineTransportStrategy(\n 'wss',\n 'ws',\n 3,\n wss_options,\n ws_manager\n );\n var xhr_streaming_transport = defineTransportStrategy(\n 'xhr_streaming',\n 'xhr_streaming',\n 1,\n http_options,\n streaming_manager\n );\n var xhr_polling_transport = defineTransportStrategy(\n 'xhr_polling',\n 'xhr_polling',\n 1,\n http_options\n );\n\n var ws_loop = new SequentialStrategy([ws_transport], timeouts);\n var wss_loop = new SequentialStrategy([wss_transport], timeouts);\n var streaming_loop = new SequentialStrategy(\n [xhr_streaming_transport],\n timeouts\n );\n var polling_loop = new SequentialStrategy([xhr_polling_transport], timeouts);\n\n var http_loop = new SequentialStrategy(\n [\n new IfStrategy(\n testSupportsStrategy(streaming_loop),\n new BestConnectedEverStrategy([\n streaming_loop,\n new DelayedStrategy(polling_loop, { delay: 4000 })\n ]),\n polling_loop\n )\n ],\n timeouts\n );\n\n var wsStrategy;\n if (baseOptions.useTLS) {\n wsStrategy = new BestConnectedEverStrategy([\n ws_loop,\n new DelayedStrategy(http_loop, { delay: 2000 })\n ]);\n } else {\n wsStrategy = new BestConnectedEverStrategy([\n ws_loop,\n new DelayedStrategy(wss_loop, { delay: 2000 }),\n new DelayedStrategy(http_loop, { delay: 5000 })\n ]);\n }\n\n return new WebSocketPrioritizedCachedStrategy(\n new FirstConnectedStrategy(\n new IfStrategy(testSupportsStrategy(ws_transport), wsStrategy, http_loop)\n ),\n definedTransports,\n {\n ttl: 1800000,\n timeline: baseOptions.timeline,\n useTLS: baseOptions.useTLS\n }\n );\n};\n\nexport default getDefaultStrategy;\n","/** Initializes the transport.\n *\n * Fetches resources if needed and then transitions to initialized.\n */\nexport default function() {\n var self = this;\n\n self.timeline.info(\n self.buildTimelineMessage({\n transport: self.name + (self.options.useTLS ? 's' : '')\n })\n );\n\n if (self.hooks.isInitialized()) {\n self.changeState('initialized');\n } else {\n self.onClose();\n }\n}\n","import Runtime from 'runtime';\nimport RequestHooks from './request_hooks';\nimport Ajax from './ajax';\nimport { default as EventsDispatcher } from '../events/dispatcher';\n\nconst MAX_BUFFER_LENGTH = 256 * 1024;\n\nexport default class HTTPRequest extends EventsDispatcher {\n hooks: RequestHooks;\n method: string;\n url: string;\n position: number;\n xhr: Ajax;\n unloader: Function;\n\n constructor(hooks: RequestHooks, method: string, url: string) {\n super();\n this.hooks = hooks;\n this.method = method;\n this.url = url;\n }\n\n start(payload?: any) {\n this.position = 0;\n this.xhr = this.hooks.getRequest(this);\n\n this.unloader = () => {\n this.close();\n };\n Runtime.addUnloadListener(this.unloader);\n\n this.xhr.open(this.method, this.url, true);\n\n if (this.xhr.setRequestHeader) {\n this.xhr.setRequestHeader('Content-Type', 'application/json'); // ReactNative doesn't set this header by default.\n }\n this.xhr.send(payload);\n }\n\n close() {\n if (this.unloader) {\n Runtime.removeUnloadListener(this.unloader);\n this.unloader = null;\n }\n if (this.xhr) {\n this.hooks.abortRequest(this.xhr);\n this.xhr = null;\n }\n }\n\n onChunk(status: number, data: any) {\n while (true) {\n var chunk = this.advanceBuffer(data);\n if (chunk) {\n this.emit('chunk', { status: status, data: chunk });\n } else {\n break;\n }\n }\n if (this.isBufferTooLong(data)) {\n this.emit('buffer_too_long');\n }\n }\n\n private advanceBuffer(buffer: any[]): any {\n var unreadData = buffer.slice(this.position);\n var endOfLinePosition = unreadData.indexOf('\\n');\n\n if (endOfLinePosition !== -1) {\n this.position += endOfLinePosition + 1;\n return unreadData.slice(0, endOfLinePosition);\n } else {\n // chunk is not finished yet, don't move the buffer pointer\n return null;\n }\n }\n\n private isBufferTooLong(buffer: any): boolean {\n return this.position === buffer.length && buffer.length > MAX_BUFFER_LENGTH;\n }\n}\n","enum State {\n CONNECTING = 0,\n OPEN = 1,\n CLOSED = 3\n}\n\nexport default State;\n","import URLLocation from './url_location';\nimport State from './state';\nimport Socket from '../socket';\nimport SocketHooks from './socket_hooks';\nimport Util from '../util';\nimport Ajax from './ajax';\nimport HTTPRequest from './http_request';\nimport Runtime from 'runtime';\n\nvar autoIncrement = 1;\n\nclass HTTPSocket implements Socket {\n hooks: SocketHooks;\n session: string;\n location: URLLocation;\n readyState: State;\n stream: HTTPRequest;\n\n onopen: () => void;\n onerror: (error: any) => void;\n onclose: (closeEvent: any) => void;\n onmessage: (message: any) => void;\n onactivity: () => void;\n\n constructor(hooks: SocketHooks, url: string) {\n this.hooks = hooks;\n this.session = randomNumber(1000) + '/' + randomString(8);\n this.location = getLocation(url);\n this.readyState = State.CONNECTING;\n this.openStream();\n }\n\n send(payload: any) {\n return this.sendRaw(JSON.stringify([payload]));\n }\n\n ping() {\n this.hooks.sendHeartbeat(this);\n }\n\n close(code: any, reason: any) {\n this.onClose(code, reason, true);\n }\n\n /** For internal use only */\n sendRaw(payload: any): boolean {\n if (this.readyState === State.OPEN) {\n try {\n Runtime.createSocketRequest(\n 'POST',\n getUniqueURL(getSendURL(this.location, this.session))\n ).start(payload);\n return true;\n } catch (e) {\n return false;\n }\n } else {\n return false;\n }\n }\n\n /** For internal use only */\n reconnect() {\n this.closeStream();\n this.openStream();\n }\n\n /** For internal use only */\n onClose(code, reason, wasClean) {\n this.closeStream();\n this.readyState = State.CLOSED;\n if (this.onclose) {\n this.onclose({\n code: code,\n reason: reason,\n wasClean: wasClean\n });\n }\n }\n\n private onChunk(chunk) {\n if (chunk.status !== 200) {\n return;\n }\n if (this.readyState === State.OPEN) {\n this.onActivity();\n }\n\n var payload;\n var type = chunk.data.slice(0, 1);\n switch (type) {\n case 'o':\n payload = JSON.parse(chunk.data.slice(1) || '{}');\n this.onOpen(payload);\n break;\n case 'a':\n payload = JSON.parse(chunk.data.slice(1) || '[]');\n for (var i = 0; i < payload.length; i++) {\n this.onEvent(payload[i]);\n }\n break;\n case 'm':\n payload = JSON.parse(chunk.data.slice(1) || 'null');\n this.onEvent(payload);\n break;\n case 'h':\n this.hooks.onHeartbeat(this);\n break;\n case 'c':\n payload = JSON.parse(chunk.data.slice(1) || '[]');\n this.onClose(payload[0], payload[1], true);\n break;\n }\n }\n\n private onOpen(options) {\n if (this.readyState === State.CONNECTING) {\n if (options && options.hostname) {\n this.location.base = replaceHost(this.location.base, options.hostname);\n }\n this.readyState = State.OPEN;\n\n if (this.onopen) {\n this.onopen();\n }\n } else {\n this.onClose(1006, 'Server lost session', true);\n }\n }\n\n private onEvent(event) {\n if (this.readyState === State.OPEN && this.onmessage) {\n this.onmessage({ data: event });\n }\n }\n\n private onActivity() {\n if (this.onactivity) {\n this.onactivity();\n }\n }\n\n private onError(error) {\n if (this.onerror) {\n this.onerror(error);\n }\n }\n\n private openStream() {\n this.stream = Runtime.createSocketRequest(\n 'POST',\n getUniqueURL(this.hooks.getReceiveURL(this.location, this.session))\n );\n\n this.stream.bind('chunk', chunk => {\n this.onChunk(chunk);\n });\n this.stream.bind('finished', status => {\n this.hooks.onFinished(this, status);\n });\n this.stream.bind('buffer_too_long', () => {\n this.reconnect();\n });\n\n try {\n this.stream.start();\n } catch (error) {\n Util.defer(() => {\n this.onError(error);\n this.onClose(1006, 'Could not start streaming', false);\n });\n }\n }\n\n private closeStream() {\n if (this.stream) {\n this.stream.unbind_all();\n this.stream.close();\n this.stream = null;\n }\n }\n}\n\nfunction getLocation(url): URLLocation {\n var parts = /([^\\?]*)\\/*(\\??.*)/.exec(url);\n return {\n base: parts[1],\n queryString: parts[2]\n };\n}\n\nfunction getSendURL(url: URLLocation, session: string): string {\n return url.base + '/' + session + '/xhr_send';\n}\n\nfunction getUniqueURL(url: string): string {\n var separator = url.indexOf('?') === -1 ? '?' : '&';\n return url + separator + 't=' + +new Date() + '&n=' + autoIncrement++;\n}\n\nfunction replaceHost(url: string, hostname: string): string {\n var urlParts = /(https?:\\/\\/)([^\\/:]+)((\\/|:)?.*)/.exec(url);\n return urlParts[1] + hostname + urlParts[3];\n}\n\nfunction randomNumber(max: number): number {\n return Runtime.randomInt(max);\n}\n\nfunction randomString(length: number): string {\n var result = [];\n\n for (var i = 0; i < length; i++) {\n result.push(randomNumber(32).toString(32));\n }\n\n return result.join('');\n}\n\nexport default HTTPSocket;\n","import SocketHooks from './socket_hooks';\nimport HTTPSocket from './http_socket';\n\nvar hooks: SocketHooks = {\n getReceiveURL: function(url, session) {\n return url.base + '/' + session + '/xhr_streaming' + url.queryString;\n },\n onHeartbeat: function(socket) {\n socket.sendRaw('[]');\n },\n sendHeartbeat: function(socket) {\n socket.sendRaw('[]');\n },\n onFinished: function(socket, status) {\n socket.onClose(1006, 'Connection interrupted (' + status + ')', false);\n }\n};\n\nexport default hooks;\n","import SocketHooks from './socket_hooks';\nimport URLLocation from './url_location';\nimport HTTPSocket from './http_socket';\n\nvar hooks: SocketHooks = {\n getReceiveURL: function(url: URLLocation, session: string): string {\n return url.base + '/' + session + '/xhr' + url.queryString;\n },\n onHeartbeat: function() {\n // next HTTP request will reset server's activity timer\n },\n sendHeartbeat: function(socket) {\n socket.sendRaw('[]');\n },\n onFinished: function(socket, status) {\n if (status === 200) {\n socket.reconnect();\n } else {\n socket.onClose(1006, 'Connection interrupted (' + status + ')', false);\n }\n }\n};\n\nexport default hooks;\n","import HTTPRequest from 'core/http/http_request';\nimport RequestHooks from 'core/http/request_hooks';\nimport Ajax from 'core/http/ajax';\nimport Runtime from 'runtime';\n\nvar hooks: RequestHooks = {\n getRequest: function(socket: HTTPRequest): Ajax {\n var Constructor = Runtime.getXHRAPI();\n var xhr = new Constructor();\n xhr.onreadystatechange = xhr.onprogress = function() {\n switch (xhr.readyState) {\n case 3:\n if (xhr.responseText && xhr.responseText.length > 0) {\n socket.onChunk(xhr.status, xhr.responseText);\n }\n break;\n case 4:\n // this happens only on errors, never after calling close\n if (xhr.responseText && xhr.responseText.length > 0) {\n socket.onChunk(xhr.status, xhr.responseText);\n }\n socket.emit('finished', xhr.status);\n socket.close();\n break;\n }\n };\n return xhr;\n },\n abortRequest: function(xhr: Ajax) {\n xhr.onreadystatechange = null;\n xhr.abort();\n }\n};\n\nexport default hooks;\n","import HTTPRequest from 'core/http/http_request';\nimport HTTPSocket from 'core/http/http_socket';\nimport SocketHooks from 'core/http/socket_hooks';\nimport RequestHooks from 'core/http/request_hooks';\nimport streamingHooks from 'core/http/http_streaming_socket';\nimport pollingHooks from 'core/http/http_polling_socket';\nimport xhrHooks from './http_xhr_request';\nimport HTTPFactory from 'core/http/http_factory';\n\nvar HTTP: HTTPFactory = {\n createStreamingSocket(url: string): HTTPSocket {\n return this.createSocket(streamingHooks, url);\n },\n\n createPollingSocket(url: string): HTTPSocket {\n return this.createSocket(pollingHooks, url);\n },\n\n createSocket(hooks: SocketHooks, url: string): HTTPSocket {\n return new HTTPSocket(hooks, url);\n },\n\n createXHR(method: string, url: string): HTTPRequest {\n return this.createRequest(xhrHooks, method, url);\n },\n\n createRequest(hooks: RequestHooks, method: string, url: string): HTTPRequest {\n return new HTTPRequest(hooks, method, url);\n }\n};\n\nexport default HTTP;\n","import * as Collections from 'core/utils/collections';\nimport Transports from 'isomorphic/transports/transports';\nimport TimelineSender from 'core/timeline/timeline_sender';\nimport Ajax from 'core/http/ajax';\nimport getDefaultStrategy from './default_strategy';\nimport TransportsTable from 'core/transports/transports_table';\nimport transportConnectionInitializer from './transports/transport_connection_initializer';\nimport HTTPFactory from './http/http';\n\nvar Isomorphic: any = {\n getDefaultStrategy,\n Transports: Transports,\n transportConnectionInitializer,\n HTTPFactory,\n\n setup(PusherClass): void {\n PusherClass.ready();\n },\n\n getLocalStorage(): any {\n return undefined;\n },\n\n getClientFeatures(): any[] {\n return Collections.keys(\n Collections.filterObject({ ws: Transports.ws }, function(t) {\n return t.isSupported({});\n })\n );\n },\n\n getProtocol(): string {\n return 'http:';\n },\n\n isXHRSupported(): boolean {\n return true;\n },\n\n createSocketRequest(method: string, url: string) {\n if (this.isXHRSupported()) {\n return this.HTTPFactory.createXHR(method, url);\n } else {\n throw 'Cross-origin HTTP requests are not supported';\n }\n },\n\n createXHR(): Ajax {\n var Constructor = this.getXHRAPI();\n return new Constructor();\n },\n\n createWebSocket(url: string): any {\n var Constructor = this.getWebSocketAPI();\n return new Constructor(url);\n },\n\n addUnloadListener(listener: any) {},\n removeUnloadListener(listener: any) {}\n};\n\nexport default Isomorphic;\n","import { default as EventsDispatcher } from 'core/events/dispatcher';\nimport Reachability from 'core/reachability';\n\nexport class NetInfo extends EventsDispatcher implements Reachability {\n isOnline(): boolean {\n return true;\n }\n}\n\nexport var Network = new NetInfo();\n","import AbstractRuntime from 'runtimes/interface';\nimport { AuthTransport } from 'core/auth/auth_transports';\nimport {\n AuthRequestType,\n AuthTransportCallback,\n InternalAuthOptions\n} from 'core/auth/options';\nimport { HTTPAuthError } from 'core/errors';\n\nvar fetchAuth: AuthTransport = function(\n context: AbstractRuntime,\n query: string,\n authOptions: InternalAuthOptions,\n authRequestType: AuthRequestType,\n callback: AuthTransportCallback\n) {\n var headers = new Headers();\n headers.set('Content-Type', 'application/x-www-form-urlencoded');\n\n for (var headerName in authOptions.headers) {\n headers.set(headerName, authOptions.headers[headerName]);\n }\n\n if (authOptions.headersProvider != null) {\n const dynamicHeaders = authOptions.headersProvider();\n for (var headerName in dynamicHeaders) {\n headers.set(headerName, dynamicHeaders[headerName]);\n }\n }\n\n var body = query;\n var request = new Request(authOptions.endpoint, {\n headers,\n body,\n credentials: 'same-origin',\n method: 'POST'\n });\n\n return fetch(request)\n .then(response => {\n let { status } = response;\n if (status === 200) {\n // manually parse the json so we can provide a more helpful error in\n // failure case\n return response.text();\n }\n throw new HTTPAuthError(\n status,\n `Could not get ${authRequestType.toString()} info from your auth endpoint, status: ${status}`\n );\n })\n .then(data => {\n let parsedData;\n try {\n parsedData = JSON.parse(data);\n } catch (e) {\n throw new HTTPAuthError(\n 200,\n `JSON returned from ${authRequestType.toString()} endpoint was invalid, yet status code was 200. Data was: ${data}`\n );\n }\n callback(null, parsedData);\n })\n .catch(err => {\n callback(err, null);\n });\n};\n\nexport default fetchAuth;\n","import Logger from 'core/logger';\nimport TimelineSender from 'core/timeline/timeline_sender';\nimport * as Collections from 'core/utils/collections';\nimport Util from 'core/util';\nimport Runtime from 'runtime';\nimport TimelineTransport from 'core/timeline/timeline_transport';\n\nvar getAgent = function(sender: TimelineSender, useTLS: boolean) {\n return function(data: any, callback: Function) {\n var scheme = 'http' + (useTLS ? 's' : '') + '://';\n var url =\n scheme + (sender.host || sender.options.host) + sender.options.path;\n var query = Collections.buildQueryString(data);\n url += '/' + 2 + '?' + query;\n\n fetch(url)\n .then(response => {\n if (response.status !== 200) {\n throw `received ${response.status} from stats.pusher.com`;\n }\n return response.json();\n })\n .then(({ host }) => {\n if (host) {\n sender.host = host;\n }\n })\n .catch(err => {\n Logger.debug('TimelineSender Error: ', err);\n });\n };\n};\n\nvar fetchTimeline = {\n name: 'xhr',\n getAgent\n};\n\nexport default fetchTimeline;\n","import Isomorphic from 'isomorphic/runtime';\nimport Runtime from '../interface';\nimport { Network } from './net_info';\nimport fetchAuth from './auth/fetch_auth';\nimport { AuthTransports } from 'core/auth/auth_transports';\nimport fetchTimeline from './timeline/fetch_timeline';\n\n// Very verbose but until unavoidable until\n// TypeScript 2.1, when spread attributes will be\n// supported\nconst {\n getDefaultStrategy,\n Transports,\n setup,\n getProtocol,\n isXHRSupported,\n getLocalStorage,\n createXHR,\n createWebSocket,\n addUnloadListener,\n removeUnloadListener,\n transportConnectionInitializer,\n createSocketRequest,\n HTTPFactory\n} = Isomorphic;\n\nconst Worker: Runtime = {\n getDefaultStrategy,\n Transports,\n setup,\n getProtocol,\n isXHRSupported,\n getLocalStorage,\n createXHR,\n createWebSocket,\n addUnloadListener,\n removeUnloadListener,\n transportConnectionInitializer,\n createSocketRequest,\n HTTPFactory,\n\n TimelineTransport: fetchTimeline,\n\n getAuthorizers(): AuthTransports {\n return { ajax: fetchAuth };\n },\n\n getWebSocketAPI() {\n return WebSocket;\n },\n\n getXHRAPI() {\n return XMLHttpRequest;\n },\n\n getNetwork() {\n return Network;\n },\n\n randomInt(max: number): number {\n /**\n * Return values in the range of [0, 1[\n */\n const random = function() {\n const crypto = globalThis.crypto || globalThis['msCrypto'];\n const random = crypto.getRandomValues(new Uint32Array(1))[0];\n\n return random / 2 ** 32;\n };\n\n return Math.floor(random() * max);\n }\n};\n\nexport default Worker;\n","enum TimelineLevel {\n ERROR = 3,\n INFO = 6,\n DEBUG = 7\n}\n\nexport default TimelineLevel;\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport { default as Level } from './level';\n\nexport interface TimelineOptions {\n level?: Level;\n limit?: number;\n version?: string;\n cluster?: string;\n features?: string[];\n params?: any;\n}\n\nexport default class Timeline {\n key: string;\n session: number;\n events: any[];\n options: TimelineOptions;\n sent: number;\n uniqueID: number;\n\n constructor(key: string, session: number, options: TimelineOptions) {\n this.key = key;\n this.session = session;\n this.events = [];\n this.options = options || {};\n this.sent = 0;\n this.uniqueID = 0;\n }\n\n log(level, event) {\n if (level <= this.options.level) {\n this.events.push(\n Collections.extend({}, event, { timestamp: Util.now() })\n );\n if (this.options.limit && this.events.length > this.options.limit) {\n this.events.shift();\n }\n }\n }\n\n error(event) {\n this.log(Level.ERROR, event);\n }\n\n info(event) {\n this.log(Level.INFO, event);\n }\n\n debug(event) {\n this.log(Level.DEBUG, event);\n }\n\n isEmpty() {\n return this.events.length === 0;\n }\n\n send(sendfn, callback) {\n var data = Collections.extend(\n {\n session: this.session,\n bundle: this.sent + 1,\n key: this.key,\n lib: 'js',\n version: this.options.version,\n cluster: this.options.cluster,\n features: this.options.features,\n timeline: this.events\n },\n this.options.params\n );\n\n this.events = [];\n sendfn(data, (error, result) => {\n if (!error) {\n this.sent++;\n }\n if (callback) {\n callback(error, result);\n }\n });\n\n return true;\n }\n\n generateUniqueID(): number {\n this.uniqueID++;\n return this.uniqueID;\n }\n}\n","import Factory from '../utils/factory';\nimport Util from '../util';\nimport * as Errors from '../errors';\nimport * as Collections from '../utils/collections';\nimport Strategy from './strategy';\nimport Transport from '../transports/transport';\nimport StrategyOptions from './strategy_options';\nimport Handshake from '../connection/handshake';\n\n/** Provides a strategy interface for transports.\n *\n * @param {String} name\n * @param {Number} priority\n * @param {Class} transport\n * @param {Object} options\n */\nexport default class TransportStrategy implements Strategy {\n name: string;\n priority: number;\n transport: Transport;\n options: StrategyOptions;\n\n constructor(\n name: string,\n priority: number,\n transport: Transport,\n options: StrategyOptions\n ) {\n this.name = name;\n this.priority = priority;\n this.transport = transport;\n this.options = options || {};\n }\n\n /** Returns whether the transport is supported in the browser.\n *\n * @returns {Boolean}\n */\n isSupported(): boolean {\n return this.transport.isSupported({\n useTLS: this.options.useTLS\n });\n }\n\n /** Launches a connection attempt and returns a strategy runner.\n *\n * @param {Function} callback\n * @return {Object} strategy runner\n */\n connect(minPriority: number, callback: Function) {\n if (!this.isSupported()) {\n return failAttempt(new Errors.UnsupportedStrategy(), callback);\n } else if (this.priority < minPriority) {\n return failAttempt(new Errors.TransportPriorityTooLow(), callback);\n }\n\n var connected = false;\n var transport = this.transport.createConnection(\n this.name,\n this.priority,\n this.options.key,\n this.options\n );\n var handshake = null;\n\n var onInitialized = function() {\n transport.unbind('initialized', onInitialized);\n transport.connect();\n };\n var onOpen = function() {\n handshake = Factory.createHandshake(transport, function(result) {\n connected = true;\n unbindListeners();\n callback(null, result);\n });\n };\n var onError = function(error) {\n unbindListeners();\n callback(error);\n };\n var onClosed = function() {\n unbindListeners();\n var serializedTransport;\n\n // The reason for this try/catch block is that on React Native\n // the WebSocket object is circular. Therefore transport.socket will\n // throw errors upon stringification. Collections.safeJSONStringify\n // discards circular references when serializing.\n serializedTransport = Collections.safeJSONStringify(transport);\n callback(new Errors.TransportClosed(serializedTransport));\n };\n\n var unbindListeners = function() {\n transport.unbind('initialized', onInitialized);\n transport.unbind('open', onOpen);\n transport.unbind('error', onError);\n transport.unbind('closed', onClosed);\n };\n\n transport.bind('initialized', onInitialized);\n transport.bind('open', onOpen);\n transport.bind('error', onError);\n transport.bind('closed', onClosed);\n\n // connect will be called automatically after initialization\n transport.initialize();\n\n return {\n abort: () => {\n if (connected) {\n return;\n }\n unbindListeners();\n if (handshake) {\n handshake.close();\n } else {\n transport.close();\n }\n },\n forceMinPriority: p => {\n if (connected) {\n return;\n }\n if (this.priority < p) {\n if (handshake) {\n handshake.close();\n } else {\n transport.close();\n }\n }\n }\n };\n }\n}\n\nfunction failAttempt(error: Error, callback: Function) {\n Util.defer(function() {\n callback(error);\n });\n return {\n abort: function() {},\n forceMinPriority: function() {}\n };\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport TransportManager from '../transports/transport_manager';\nimport * as Errors from '../errors';\nimport Strategy from './strategy';\nimport TransportStrategy from './transport_strategy';\nimport StrategyOptions from '../strategies/strategy_options';\nimport { Config } from '../config';\nimport Runtime from 'runtime';\n\nconst { Transports } = Runtime;\n\nexport var defineTransport = function(\n config: Config,\n name: string,\n type: string,\n priority: number,\n options: StrategyOptions,\n manager?: TransportManager\n): Strategy {\n var transportClass = Transports[type];\n if (!transportClass) {\n throw new Errors.UnsupportedTransport(type);\n }\n\n var enabled =\n (!config.enabledTransports ||\n Collections.arrayIndexOf(config.enabledTransports, name) !== -1) &&\n (!config.disabledTransports ||\n Collections.arrayIndexOf(config.disabledTransports, name) === -1);\n\n var transport;\n if (enabled) {\n options = Object.assign(\n { ignoreNullOrigin: config.ignoreNullOrigin },\n options\n );\n\n transport = new TransportStrategy(\n name,\n priority,\n manager ? manager.getAssistant(transportClass) : transportClass,\n options\n );\n } else {\n transport = UnsupportedStrategy;\n }\n\n return transport;\n};\n\nvar UnsupportedStrategy: Strategy = {\n isSupported: function() {\n return false;\n },\n connect: function(_, callback) {\n var deferred = Util.defer(function() {\n callback(new Errors.UnsupportedStrategy());\n });\n return {\n abort: function() {\n deferred.ensureAborted();\n },\n forceMinPriority: function() {}\n };\n }\n};\n","import ConnectionManager from './connection/connection_manager';\nimport {\n ChannelAuthorizationOptions,\n UserAuthenticationOptions\n} from './auth/options';\nimport {\n ChannelAuthorizerGenerator,\n DeprecatedAuthOptions\n} from './auth/deprecated_channel_authorizer';\nimport { AuthTransport, Transport } from './config';\nimport * as nacl from 'tweetnacl';\nimport Logger from './logger';\n\nexport interface Options {\n activityTimeout?: number;\n\n auth?: DeprecatedAuthOptions; // DEPRECATED use channelAuthorization instead\n authEndpoint?: string; // DEPRECATED use channelAuthorization instead\n authTransport?: AuthTransport; // DEPRECATED use channelAuthorization instead\n authorizer?: ChannelAuthorizerGenerator; // DEPRECATED use channelAuthorization instead\n\n channelAuthorization?: ChannelAuthorizationOptions;\n userAuthentication?: UserAuthenticationOptions;\n\n cluster: string;\n enableStats?: boolean;\n disableStats?: boolean;\n disabledTransports?: Transport[];\n enabledTransports?: Transport[];\n forceTLS?: boolean;\n httpHost?: string;\n httpPath?: string;\n httpPort?: number;\n httpsPort?: number;\n ignoreNullOrigin?: boolean;\n nacl?: nacl;\n pongTimeout?: number;\n statsHost?: string;\n timelineParams?: any;\n unavailableTimeout?: number;\n wsHost?: string;\n wsPath?: string;\n wsPort?: number;\n wssPort?: number;\n}\n\nexport interface ClusterOptions {\n appKey: string;\n cluster: string;\n}\n\nexport function validateOptions(options) {\n if (options == null) {\n throw 'You must pass an options object';\n }\n if (options.cluster == null) {\n throw 'Options object must provide a cluster';\n }\n if ('disableStats' in options) {\n Logger.warn(\n 'The disableStats option is deprecated in favor of enableStats'\n );\n }\n}\n","export enum AuthRequestType {\n UserAuthentication = 'user-authentication',\n ChannelAuthorization = 'channel-authorization'\n}\n\nexport interface ChannelAuthorizationData {\n auth: string;\n channel_data?: string;\n shared_secret?: string;\n}\n\nexport type ChannelAuthorizationCallback = (\n error: Error | null,\n authData: ChannelAuthorizationData | null\n) => void;\n\nexport interface ChannelAuthorizationRequestParams {\n socketId: string;\n channelName: string;\n}\n\nexport interface ChannelAuthorizationHandler {\n (\n params: ChannelAuthorizationRequestParams,\n callback: ChannelAuthorizationCallback\n ): void;\n}\n\nexport interface UserAuthenticationData {\n auth: string;\n user_data: string;\n}\n\nexport type UserAuthenticationCallback = (\n error: Error | null,\n authData: UserAuthenticationData | null\n) => void;\n\nexport interface UserAuthenticationRequestParams {\n socketId: string;\n}\n\nexport interface UserAuthenticationHandler {\n (\n params: UserAuthenticationRequestParams,\n callback: UserAuthenticationCallback\n ): void;\n}\n\nexport type AuthTransportCallback =\n | ChannelAuthorizationCallback\n | UserAuthenticationCallback;\n\nexport interface AuthOptionsT {\n transport: 'ajax' | 'jsonp';\n endpoint: string;\n params?: any;\n headers?: any;\n paramsProvider?: () => any;\n headersProvider?: () => any;\n customHandler?: AuthHandler;\n}\n\nexport declare type UserAuthenticationOptions = AuthOptionsT<\n UserAuthenticationHandler\n>;\nexport declare type ChannelAuthorizationOptions = AuthOptionsT<\n ChannelAuthorizationHandler\n>;\n\nexport interface InternalAuthOptions {\n transport: 'ajax' | 'jsonp';\n endpoint: string;\n params?: any;\n headers?: any;\n paramsProvider?: () => any;\n headersProvider?: () => any;\n}\n","import {\n UserAuthenticationCallback,\n InternalAuthOptions,\n UserAuthenticationHandler,\n UserAuthenticationRequestParams,\n AuthRequestType\n} from './options';\n\nimport Runtime from 'runtime';\n\nconst composeChannelQuery = (\n params: UserAuthenticationRequestParams,\n authOptions: InternalAuthOptions\n) => {\n var query = 'socket_id=' + encodeURIComponent(params.socketId);\n\n for (var key in authOptions.params) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(authOptions.params[key]);\n }\n\n if (authOptions.paramsProvider != null) {\n let dynamicParams = authOptions.paramsProvider();\n for (var key in dynamicParams) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(dynamicParams[key]);\n }\n }\n\n return query;\n};\n\nconst UserAuthenticator = (\n authOptions: InternalAuthOptions\n): UserAuthenticationHandler => {\n if (typeof Runtime.getAuthorizers()[authOptions.transport] === 'undefined') {\n throw `'${authOptions.transport}' is not a recognized auth transport`;\n }\n\n return (\n params: UserAuthenticationRequestParams,\n callback: UserAuthenticationCallback\n ) => {\n const query = composeChannelQuery(params, authOptions);\n\n Runtime.getAuthorizers()[authOptions.transport](\n Runtime,\n query,\n authOptions,\n AuthRequestType.UserAuthentication,\n callback\n );\n };\n};\n\nexport default UserAuthenticator;\n","import {\n AuthRequestType,\n InternalAuthOptions,\n ChannelAuthorizationHandler,\n ChannelAuthorizationRequestParams,\n ChannelAuthorizationCallback\n} from './options';\n\nimport Runtime from 'runtime';\n\nconst composeChannelQuery = (\n params: ChannelAuthorizationRequestParams,\n authOptions: InternalAuthOptions\n) => {\n var query = 'socket_id=' + encodeURIComponent(params.socketId);\n\n query += '&channel_name=' + encodeURIComponent(params.channelName);\n\n for (var key in authOptions.params) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(authOptions.params[key]);\n }\n\n if (authOptions.paramsProvider != null) {\n let dynamicParams = authOptions.paramsProvider();\n for (var key in dynamicParams) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(dynamicParams[key]);\n }\n }\n\n return query;\n};\n\nconst ChannelAuthorizer = (\n authOptions: InternalAuthOptions\n): ChannelAuthorizationHandler => {\n if (typeof Runtime.getAuthorizers()[authOptions.transport] === 'undefined') {\n throw `'${authOptions.transport}' is not a recognized auth transport`;\n }\n\n return (\n params: ChannelAuthorizationRequestParams,\n callback: ChannelAuthorizationCallback\n ) => {\n const query = composeChannelQuery(params, authOptions);\n\n Runtime.getAuthorizers()[authOptions.transport](\n Runtime,\n query,\n authOptions,\n AuthRequestType.ChannelAuthorization,\n callback\n );\n };\n};\n\nexport default ChannelAuthorizer;\n","import Channel from '../channels/channel';\nimport {\n ChannelAuthorizationCallback,\n ChannelAuthorizationHandler,\n ChannelAuthorizationRequestParams,\n InternalAuthOptions\n} from './options';\n\nexport interface DeprecatedChannelAuthorizer {\n authorize(socketId: string, callback: ChannelAuthorizationCallback): void;\n}\n\nexport interface ChannelAuthorizerGenerator {\n (\n channel: Channel,\n options: DeprecatedAuthorizerOptions\n ): DeprecatedChannelAuthorizer;\n}\n\nexport interface DeprecatedAuthOptions {\n params?: any;\n headers?: any;\n}\n\nexport interface DeprecatedAuthorizerOptions {\n authTransport: 'ajax' | 'jsonp';\n authEndpoint: string;\n auth?: DeprecatedAuthOptions;\n}\n\nexport const ChannelAuthorizerProxy = (\n pusher,\n authOptions: InternalAuthOptions,\n channelAuthorizerGenerator: ChannelAuthorizerGenerator\n): ChannelAuthorizationHandler => {\n const deprecatedAuthorizerOptions: DeprecatedAuthorizerOptions = {\n authTransport: authOptions.transport,\n authEndpoint: authOptions.endpoint,\n auth: {\n params: authOptions.params,\n headers: authOptions.headers\n }\n };\n return (\n params: ChannelAuthorizationRequestParams,\n callback: ChannelAuthorizationCallback\n ) => {\n const channel = pusher.channel(params.channelName);\n // This line creates a new channel authorizer every time.\n // In the past, this was only done once per channel and reused.\n // We can do that again if we want to keep this behavior intact.\n const channelAuthorizer: DeprecatedChannelAuthorizer = channelAuthorizerGenerator(\n channel,\n deprecatedAuthorizerOptions\n );\n channelAuthorizer.authorize(params.socketId, callback);\n };\n};\n","import { Options } from './options';\nimport Defaults from './defaults';\nimport {\n ChannelAuthorizationHandler,\n UserAuthenticationHandler,\n ChannelAuthorizationOptions\n} from './auth/options';\nimport UserAuthenticator from './auth/user_authenticator';\nimport ChannelAuthorizer from './auth/channel_authorizer';\nimport { ChannelAuthorizerProxy } from './auth/deprecated_channel_authorizer';\nimport Runtime from 'runtime';\nimport * as nacl from 'tweetnacl';\n\nexport type AuthTransport = 'ajax' | 'jsonp';\nexport type Transport =\n | 'ws'\n | 'wss'\n | 'xhr_streaming'\n | 'xhr_polling'\n | 'sockjs';\n\nexport interface Config {\n // these are all 'required' config parameters, it's not necessary for the user\n // to set them, but they have configured defaults.\n activityTimeout: number;\n enableStats: boolean;\n httpHost: string;\n httpPath: string;\n httpPort: number;\n httpsPort: number;\n pongTimeout: number;\n statsHost: string;\n unavailableTimeout: number;\n useTLS: boolean;\n wsHost: string;\n wsPath: string;\n wsPort: number;\n wssPort: number;\n userAuthenticator: UserAuthenticationHandler;\n channelAuthorizer: ChannelAuthorizationHandler;\n\n // these are all optional parameters or overrrides. The customer can set these\n // but it's not strictly necessary\n forceTLS?: boolean;\n cluster?: string;\n disabledTransports?: Transport[];\n enabledTransports?: Transport[];\n ignoreNullOrigin?: boolean;\n nacl?: nacl;\n timelineParams?: any;\n}\n\n// getConfig mainly sets the defaults for the options that are not provided\nexport function getConfig(opts: Options, pusher): Config {\n let config: Config = {\n activityTimeout: opts.activityTimeout || Defaults.activityTimeout,\n cluster: opts.cluster,\n httpPath: opts.httpPath || Defaults.httpPath,\n httpPort: opts.httpPort || Defaults.httpPort,\n httpsPort: opts.httpsPort || Defaults.httpsPort,\n pongTimeout: opts.pongTimeout || Defaults.pongTimeout,\n statsHost: opts.statsHost || Defaults.stats_host,\n unavailableTimeout: opts.unavailableTimeout || Defaults.unavailableTimeout,\n wsPath: opts.wsPath || Defaults.wsPath,\n wsPort: opts.wsPort || Defaults.wsPort,\n wssPort: opts.wssPort || Defaults.wssPort,\n\n enableStats: getEnableStatsConfig(opts),\n httpHost: getHttpHost(opts),\n useTLS: shouldUseTLS(opts),\n wsHost: getWebsocketHost(opts),\n\n userAuthenticator: buildUserAuthenticator(opts),\n channelAuthorizer: buildChannelAuthorizer(opts, pusher)\n };\n\n if ('disabledTransports' in opts)\n config.disabledTransports = opts.disabledTransports;\n if ('enabledTransports' in opts)\n config.enabledTransports = opts.enabledTransports;\n if ('ignoreNullOrigin' in opts)\n config.ignoreNullOrigin = opts.ignoreNullOrigin;\n if ('timelineParams' in opts) config.timelineParams = opts.timelineParams;\n if ('nacl' in opts) {\n config.nacl = opts.nacl;\n }\n\n return config;\n}\n\nfunction getHttpHost(opts: Options): string {\n if (opts.httpHost) {\n return opts.httpHost;\n }\n if (opts.cluster) {\n return `sockjs-${opts.cluster}.pusher.com`;\n }\n return Defaults.httpHost;\n}\n\nfunction getWebsocketHost(opts: Options): string {\n if (opts.wsHost) {\n return opts.wsHost;\n }\n return getWebsocketHostFromCluster(opts.cluster);\n}\n\nfunction getWebsocketHostFromCluster(cluster: string): string {\n return `ws-${cluster}.pusher.com`;\n}\n\nfunction shouldUseTLS(opts: Options): boolean {\n if (Runtime.getProtocol() === 'https:') {\n return true;\n } else if (opts.forceTLS === false) {\n return false;\n }\n return true;\n}\n\n// if enableStats is set take the value\n// if disableStats is set take the inverse\n// otherwise default to false\nfunction getEnableStatsConfig(opts: Options): boolean {\n if ('enableStats' in opts) {\n return opts.enableStats;\n }\n if ('disableStats' in opts) {\n return !opts.disableStats;\n }\n return false;\n}\n\nfunction buildUserAuthenticator(opts: Options): UserAuthenticationHandler {\n const userAuthentication = {\n ...Defaults.userAuthentication,\n ...opts.userAuthentication\n };\n if (\n 'customHandler' in userAuthentication &&\n userAuthentication['customHandler'] != null\n ) {\n return userAuthentication['customHandler'];\n }\n\n return UserAuthenticator(userAuthentication);\n}\n\nfunction buildChannelAuth(opts: Options, pusher): ChannelAuthorizationOptions {\n let channelAuthorization: ChannelAuthorizationOptions;\n if ('channelAuthorization' in opts) {\n channelAuthorization = {\n ...Defaults.channelAuthorization,\n ...opts.channelAuthorization\n };\n } else {\n channelAuthorization = {\n transport: opts.authTransport || Defaults.authTransport,\n endpoint: opts.authEndpoint || Defaults.authEndpoint\n };\n if ('auth' in opts) {\n if ('params' in opts.auth) channelAuthorization.params = opts.auth.params;\n if ('headers' in opts.auth)\n channelAuthorization.headers = opts.auth.headers;\n }\n if ('authorizer' in opts)\n channelAuthorization.customHandler = ChannelAuthorizerProxy(\n pusher,\n channelAuthorization,\n opts.authorizer\n );\n }\n return channelAuthorization;\n}\n\nfunction buildChannelAuthorizer(\n opts: Options,\n pusher\n): ChannelAuthorizationHandler {\n const channelAuthorization = buildChannelAuth(opts, pusher);\n if (\n 'customHandler' in channelAuthorization &&\n channelAuthorization['customHandler'] != null\n ) {\n return channelAuthorization['customHandler'];\n }\n\n return ChannelAuthorizer(channelAuthorization);\n}\n","import Logger from './logger';\nimport Pusher from './pusher';\nimport EventsDispatcher from './events/dispatcher';\n\nexport default class WatchlistFacade extends EventsDispatcher {\n private pusher: Pusher;\n\n public constructor(pusher: Pusher) {\n super(function(eventName, data) {\n Logger.debug(`No callbacks on watchlist events for ${eventName}`);\n });\n\n this.pusher = pusher;\n this.bindWatchlistInternalEvent();\n }\n\n handleEvent(pusherEvent) {\n pusherEvent.data.events.forEach(watchlistEvent => {\n this.emit(watchlistEvent.name, watchlistEvent);\n });\n }\n\n private bindWatchlistInternalEvent() {\n this.pusher.connection.bind('message', pusherEvent => {\n var eventName = pusherEvent.event;\n if (eventName === 'pusher_internal:watchlist_events') {\n this.handleEvent(pusherEvent);\n }\n });\n }\n}\n","function flatPromise() {\n let resolve, reject;\n const promise = new Promise((res, rej) => {\n resolve = res;\n reject = rej;\n });\n return { promise, resolve, reject };\n}\n\nexport default flatPromise;\n","import Pusher from './pusher';\nimport Logger from './logger';\nimport {\n UserAuthenticationData,\n UserAuthenticationCallback\n} from './auth/options';\nimport Channel from './channels/channel';\nimport WatchlistFacade from './watchlist';\nimport EventsDispatcher from './events/dispatcher';\nimport flatPromise from './utils/flat_promise';\n\nexport default class UserFacade extends EventsDispatcher {\n pusher: Pusher;\n signin_requested: boolean = false;\n user_data: any = null;\n serverToUserChannel: Channel = null;\n signinDonePromise: Promise = null;\n watchlist: WatchlistFacade;\n private _signinDoneResolve: Function = null;\n\n public constructor(pusher: Pusher) {\n super(function(eventName, data) {\n Logger.debug('No callbacks on user for ' + eventName);\n });\n this.pusher = pusher;\n this.pusher.connection.bind('state_change', ({ previous, current }) => {\n if (previous !== 'connected' && current === 'connected') {\n this._signin();\n }\n if (previous === 'connected' && current !== 'connected') {\n this._cleanup();\n this._newSigninPromiseIfNeeded();\n }\n });\n\n this.watchlist = new WatchlistFacade(pusher);\n\n this.pusher.connection.bind('message', event => {\n var eventName = event.event;\n if (eventName === 'pusher:signin_success') {\n this._onSigninSuccess(event.data);\n }\n if (\n this.serverToUserChannel &&\n this.serverToUserChannel.name === event.channel\n ) {\n this.serverToUserChannel.handleEvent(event);\n }\n });\n }\n\n public signin() {\n if (this.signin_requested) {\n return;\n }\n\n this.signin_requested = true;\n this._signin();\n }\n\n private _signin() {\n if (!this.signin_requested) {\n return;\n }\n\n this._newSigninPromiseIfNeeded();\n\n if (this.pusher.connection.state !== 'connected') {\n // Signin will be attempted when the connection is connected\n return;\n }\n\n this.pusher.config.userAuthenticator(\n {\n socketId: this.pusher.connection.socket_id\n },\n this._onAuthorize\n );\n }\n\n private _onAuthorize: UserAuthenticationCallback = (\n err,\n authData: UserAuthenticationData\n ) => {\n if (err) {\n Logger.warn(`Error during signin: ${err}`);\n this._cleanup();\n return;\n }\n\n this.pusher.send_event('pusher:signin', {\n auth: authData.auth,\n user_data: authData.user_data\n });\n\n // Later when we get pusher:singin_success event, the user will be marked as signed in\n };\n\n private _onSigninSuccess(data: any) {\n try {\n this.user_data = JSON.parse(data.user_data);\n } catch (e) {\n Logger.error(`Failed parsing user data after signin: ${data.user_data}`);\n this._cleanup();\n return;\n }\n\n if (typeof this.user_data.id !== 'string' || this.user_data.id === '') {\n Logger.error(\n `user_data doesn't contain an id. user_data: ${this.user_data}`\n );\n this._cleanup();\n return;\n }\n\n // Signin succeeded\n this._signinDoneResolve();\n this._subscribeChannels();\n }\n\n private _subscribeChannels() {\n const ensure_subscribed = channel => {\n if (channel.subscriptionPending && channel.subscriptionCancelled) {\n channel.reinstateSubscription();\n } else if (\n !channel.subscriptionPending &&\n this.pusher.connection.state === 'connected'\n ) {\n channel.subscribe();\n }\n };\n\n this.serverToUserChannel = new Channel(\n `#server-to-user-${this.user_data.id}`,\n this.pusher\n );\n this.serverToUserChannel.bind_global((eventName, data) => {\n if (\n eventName.indexOf('pusher_internal:') === 0 ||\n eventName.indexOf('pusher:') === 0\n ) {\n // ignore internal events\n return;\n }\n this.emit(eventName, data);\n });\n ensure_subscribed(this.serverToUserChannel);\n }\n\n private _cleanup() {\n this.user_data = null;\n if (this.serverToUserChannel) {\n this.serverToUserChannel.unbind_all();\n this.serverToUserChannel.disconnect();\n this.serverToUserChannel = null;\n }\n\n if (this.signin_requested) {\n // If signin is in progress and cleanup is called,\n // Mark the current signin process as done.\n this._signinDoneResolve();\n }\n }\n\n private _newSigninPromiseIfNeeded() {\n if (!this.signin_requested) {\n return;\n }\n\n // If there is a promise and it is not resolved, return without creating a new one.\n if (this.signinDonePromise && !(this.signinDonePromise as any).done) {\n return;\n }\n\n // This promise is never rejected.\n // It gets resolved when the signin process is done whether it failed or succeeded\n const { promise, resolve, reject: _ } = flatPromise();\n (promise as any).done = false;\n const setDone = () => {\n (promise as any).done = true;\n };\n promise.then(setDone).catch(setDone);\n this.signinDonePromise = promise;\n this._signinDoneResolve = resolve;\n }\n}\n","import AbstractRuntime from '../runtimes/interface';\nimport Runtime from 'runtime';\nimport * as Collections from './utils/collections';\nimport Channels from './channels/channels';\nimport Channel from './channels/channel';\nimport { default as EventsDispatcher } from './events/dispatcher';\nimport Timeline from './timeline/timeline';\nimport TimelineSender from './timeline/timeline_sender';\nimport TimelineLevel from './timeline/level';\nimport { defineTransport } from './strategies/strategy_builder';\nimport ConnectionManager from './connection/connection_manager';\nimport { PeriodicTimer } from './utils/timers';\nimport Defaults from './defaults';\nimport Logger from './logger';\nimport Factory from './utils/factory';\nimport { Options, ClusterOptions, validateOptions } from './options';\nimport { Config, getConfig } from './config';\nimport StrategyOptions from './strategies/strategy_options';\nimport UserFacade from './user';\n\nexport default class Pusher {\n /* STATIC PROPERTIES */\n static instances: Pusher[] = [];\n static isReady: boolean = false;\n static logToConsole: boolean = false;\n\n // for jsonp\n static Runtime: AbstractRuntime = Runtime;\n static ScriptReceivers: any = (Runtime).ScriptReceivers;\n static DependenciesReceivers: any = (Runtime).DependenciesReceivers;\n static auth_callbacks: any = (Runtime).auth_callbacks;\n\n static ready() {\n Pusher.isReady = true;\n for (var i = 0, l = Pusher.instances.length; i < l; i++) {\n Pusher.instances[i].connect();\n }\n }\n\n static log: (message: any) => void;\n\n private static getClientFeatures(): string[] {\n return Collections.keys(\n Collections.filterObject({ ws: Runtime.Transports.ws }, function(t) {\n return t.isSupported({});\n })\n );\n }\n\n /* INSTANCE PROPERTIES */\n key: string;\n options: Options;\n config: Config;\n channels: Channels;\n global_emitter: EventsDispatcher;\n sessionID: number;\n timeline: Timeline;\n timelineSender: TimelineSender;\n connection: ConnectionManager;\n timelineSenderTimer: PeriodicTimer;\n user: UserFacade;\n constructor(app_key: string, options: Options) {\n checkAppKey(app_key);\n validateOptions(options);\n this.key = app_key;\n this.config = getConfig(options, this);\n\n this.channels = Factory.createChannels();\n this.global_emitter = new EventsDispatcher();\n this.sessionID = Runtime.randomInt(1000000000);\n\n this.timeline = new Timeline(this.key, this.sessionID, {\n cluster: this.config.cluster,\n features: Pusher.getClientFeatures(),\n params: this.config.timelineParams || {},\n limit: 50,\n level: TimelineLevel.INFO,\n version: Defaults.VERSION\n });\n if (this.config.enableStats) {\n this.timelineSender = Factory.createTimelineSender(this.timeline, {\n host: this.config.statsHost,\n path: '/timeline/v2/' + Runtime.TimelineTransport.name\n });\n }\n\n var getStrategy = (options: StrategyOptions) => {\n return Runtime.getDefaultStrategy(this.config, options, defineTransport);\n };\n\n this.connection = Factory.createConnectionManager(this.key, {\n getStrategy: getStrategy,\n timeline: this.timeline,\n activityTimeout: this.config.activityTimeout,\n pongTimeout: this.config.pongTimeout,\n unavailableTimeout: this.config.unavailableTimeout,\n useTLS: Boolean(this.config.useTLS)\n });\n\n this.connection.bind('connected', () => {\n this.subscribeAll();\n if (this.timelineSender) {\n this.timelineSender.send(this.connection.isUsingTLS());\n }\n });\n\n this.connection.bind('message', event => {\n var eventName = event.event;\n var internal = eventName.indexOf('pusher_internal:') === 0;\n if (event.channel) {\n var channel = this.channel(event.channel);\n if (channel) {\n channel.handleEvent(event);\n }\n }\n // Emit globally [deprecated]\n if (!internal) {\n this.global_emitter.emit(event.event, event.data);\n }\n });\n this.connection.bind('connecting', () => {\n this.channels.disconnect();\n });\n this.connection.bind('disconnected', () => {\n this.channels.disconnect();\n });\n this.connection.bind('error', err => {\n Logger.warn(err);\n });\n\n Pusher.instances.push(this);\n this.timeline.info({ instances: Pusher.instances.length });\n\n this.user = new UserFacade(this);\n\n if (Pusher.isReady) {\n this.connect();\n }\n }\n\n /**\n * Allows you to switch Pusher cluster without\n * losing all the channels/subscription binding\n * as this is internally managed by the SDK.\n */\n switchCluster(options: ClusterOptions) {\n const { appKey, cluster } = options;\n this.key = appKey;\n this.options = { ...this.options, cluster };\n this.config = getConfig(this.options, this);\n this.connection.switchCluster(this.key);\n }\n\n channel(name: string): Channel {\n return this.channels.find(name);\n }\n\n allChannels(): Channel[] {\n return this.channels.all();\n }\n\n connect() {\n this.connection.connect();\n\n if (this.timelineSender) {\n if (!this.timelineSenderTimer) {\n var usingTLS = this.connection.isUsingTLS();\n var timelineSender = this.timelineSender;\n this.timelineSenderTimer = new PeriodicTimer(60000, function() {\n timelineSender.send(usingTLS);\n });\n }\n }\n }\n\n disconnect() {\n this.connection.disconnect();\n\n if (this.timelineSenderTimer) {\n this.timelineSenderTimer.ensureAborted();\n this.timelineSenderTimer = null;\n }\n }\n\n bind(event_name: string, callback: Function, context?: any): Pusher {\n this.global_emitter.bind(event_name, callback, context);\n return this;\n }\n\n unbind(event_name?: string, callback?: Function, context?: any): Pusher {\n this.global_emitter.unbind(event_name, callback, context);\n return this;\n }\n\n bind_global(callback: Function): Pusher {\n this.global_emitter.bind_global(callback);\n return this;\n }\n\n unbind_global(callback?: Function): Pusher {\n this.global_emitter.unbind_global(callback);\n return this;\n }\n\n unbind_all(callback?: Function): Pusher {\n this.global_emitter.unbind_all();\n return this;\n }\n\n subscribeAll() {\n var channelName;\n for (channelName in this.channels.channels) {\n if (this.channels.channels.hasOwnProperty(channelName)) {\n this.subscribe(channelName);\n }\n }\n }\n\n subscribe(channel_name: string) {\n var channel = this.channels.add(channel_name, this);\n if (channel.subscriptionPending && channel.subscriptionCancelled) {\n channel.reinstateSubscription();\n } else if (\n !channel.subscriptionPending &&\n this.connection.state === 'connected'\n ) {\n channel.subscribe();\n }\n return channel;\n }\n\n unsubscribe(channel_name: string) {\n var channel = this.channels.find(channel_name);\n if (channel && channel.subscriptionPending) {\n channel.cancelSubscription();\n } else {\n channel = this.channels.remove(channel_name);\n if (channel && channel.subscribed) {\n channel.unsubscribe();\n }\n }\n }\n\n send_event(event_name: string, data: any, channel?: string) {\n return this.connection.send_event(event_name, data, channel);\n }\n\n shouldUseTLS(): boolean {\n return this.config.useTLS;\n }\n\n signin() {\n this.user.signin();\n }\n}\n\nfunction checkAppKey(key) {\n if (key === null || key === undefined) {\n throw 'You must pass your app key when you instantiate Pusher.';\n }\n}\n\nRuntime.setup(Pusher);\n","import Pusher from './pusher';\nimport { Options, validateOptions } from './options';\nimport * as nacl from 'tweetnacl';\n\nexport default class PusherWithEncryption extends Pusher {\n constructor(app_key: string, options: Options) {\n Pusher.logToConsole = PusherWithEncryption.logToConsole;\n Pusher.log = PusherWithEncryption.log;\n\n validateOptions(options);\n options.nacl = nacl;\n super(app_key, options);\n }\n}\n"],"sourceRoot":""} \ No newline at end of file +{"version":3,"sources":["webpack://Pusher/webpack/universalModuleDefinition","webpack://Pusher/webpack/bootstrap","webpack://Pusher/./node_modules/@stablelib/base64/base64.ts","webpack://Pusher/./node_modules/@stablelib/utf8/utf8.ts","webpack://Pusher/./node_modules/tweetnacl/nacl-fast.js","webpack://Pusher/./src/core/pusher-with-encryption.js","webpack://Pusher/crypto (ignored)","webpack://Pusher/./src/core/base64.ts","webpack://Pusher/./src/core/utils/timers/abstract_timer.ts","webpack://Pusher/./src/core/utils/timers/index.ts","webpack://Pusher/./src/core/util.ts","webpack://Pusher/./src/core/utils/collections.ts","webpack://Pusher/./src/core/defaults.ts","webpack://Pusher/./src/core/transports/url_schemes.ts","webpack://Pusher/./src/core/events/callback_registry.ts","webpack://Pusher/./src/core/events/dispatcher.ts","webpack://Pusher/./src/core/logger.ts","webpack://Pusher/./src/core/transports/transport_connection.ts","webpack://Pusher/./src/core/transports/transport.ts","webpack://Pusher/./src/runtimes/isomorphic/transports/transports.ts","webpack://Pusher/./src/core/transports/assistant_to_the_transport_manager.ts","webpack://Pusher/./src/core/connection/protocol/protocol.ts","webpack://Pusher/./src/core/connection/connection.ts","webpack://Pusher/./src/core/connection/handshake/index.ts","webpack://Pusher/./src/core/timeline/timeline_sender.ts","webpack://Pusher/./src/core/errors.ts","webpack://Pusher/./src/core/utils/url_store.ts","webpack://Pusher/./src/core/channels/channel.ts","webpack://Pusher/./src/core/channels/private_channel.ts","webpack://Pusher/./src/core/channels/members.ts","webpack://Pusher/./src/core/channels/presence_channel.ts","webpack://Pusher/./src/core/channels/encrypted_channel.ts","webpack://Pusher/./src/core/connection/connection_manager.ts","webpack://Pusher/./src/core/channels/channels.ts","webpack://Pusher/./src/core/utils/factory.ts","webpack://Pusher/./src/core/transports/transport_manager.ts","webpack://Pusher/./src/core/strategies/sequential_strategy.ts","webpack://Pusher/./src/core/strategies/best_connected_ever_strategy.ts","webpack://Pusher/./src/core/strategies/websocket_prioritized_cached_strategy.ts","webpack://Pusher/./src/core/strategies/delayed_strategy.ts","webpack://Pusher/./src/core/strategies/if_strategy.ts","webpack://Pusher/./src/core/strategies/first_connected_strategy.ts","webpack://Pusher/./src/runtimes/isomorphic/default_strategy.ts","webpack://Pusher/./src/runtimes/isomorphic/transports/transport_connection_initializer.ts","webpack://Pusher/./src/core/http/http_request.ts","webpack://Pusher/./src/core/http/state.ts","webpack://Pusher/./src/core/http/http_socket.ts","webpack://Pusher/./src/core/http/http_streaming_socket.ts","webpack://Pusher/./src/core/http/http_polling_socket.ts","webpack://Pusher/./src/runtimes/isomorphic/http/http_xhr_request.ts","webpack://Pusher/./src/runtimes/isomorphic/http/http.ts","webpack://Pusher/./src/runtimes/isomorphic/runtime.ts","webpack://Pusher/./src/runtimes/worker/net_info.ts","webpack://Pusher/./src/runtimes/worker/auth/fetch_auth.ts","webpack://Pusher/./src/runtimes/worker/timeline/fetch_timeline.ts","webpack://Pusher/./src/runtimes/worker/runtime.ts","webpack://Pusher/./src/core/timeline/level.ts","webpack://Pusher/./src/core/timeline/timeline.ts","webpack://Pusher/./src/core/strategies/transport_strategy.ts","webpack://Pusher/./src/core/strategies/strategy_builder.ts","webpack://Pusher/./src/core/options.ts","webpack://Pusher/./src/core/auth/options.ts","webpack://Pusher/./src/core/auth/user_authenticator.ts","webpack://Pusher/./src/core/auth/channel_authorizer.ts","webpack://Pusher/./src/core/auth/deprecated_channel_authorizer.ts","webpack://Pusher/./src/core/config.ts","webpack://Pusher/./src/core/watchlist.ts","webpack://Pusher/./src/core/utils/flat_promise.ts","webpack://Pusher/./src/core/user.ts","webpack://Pusher/./src/core/pusher.ts","webpack://Pusher/./src/core/pusher-with-encryption.ts"],"names":[],"mappings":";;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AACD,O;QCVA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;QACA;QAC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CAAC,CAAC,CAAC,CAAC,CAAC;KACtC;IACD,OAAO,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AAC1B,CAAC;AAjED,wBAiEC;;;;;;;AC/ID;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,uBAAuB,iBAAiB;AACxC;AACA;;AAEA;AACA,wCAAwC,4BAA4B;;AAEpE;AACA,4BAA4B;;AAE5B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa,OAAO;AACpB;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,aAAa,QAAQ;AACrB,aAAa,OAAO;AACpB;AACA;AACA,eAAe,QAAQ;AACvB;AACA,eAAe,QAAQ;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB;AACA;AACA;;AAEA;AACA;AACA;AACA,aAAa,QAAQ;AACrB,aAAa,OAAO;AACpB;AACA;AACA,eAAe,QAAQ;AACvB;AACA,eAAe,QAAQ;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,iBAAiB,OAAO;AACxB;AACA;;AAEA;AACA;AACA;AACA;AACA,iBAAiB,OAAO;AACxB;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA,8CAA8C;AAC9C,8CAA8C;AAC9C,8CAA8C;AAC9C,8CAA8C;AAC9C,8CAA8C;AAC9C;AACA,8CAA8C;AAC9C,8CAA8C;AAC9C,8CAA8C;AAC9C;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,sDAAsD;AACtD,sDAAsD;AACtD,sDAAsD;AACtD,sDAAsD;AACtD,sDAAsD;AACtD;AACA,sDAAsD;AACtD,sDAAsD;AACtD,sDAAsD;AACtD;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA,qBAAqB;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA,qBAAqB;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA,qBAAqB;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA,qBAAqB;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA,qBAAqB;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA,qBAAqB;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA,qBAAqB;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA,qBAAqB;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA,qBAAqB;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA,qBAAqB;;AAErB;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA,UAAU,QAAQ;AAClB;AACA;AACA;;AAEA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA;AACA;;AAEA;AACA,aAAa,QAAQ;AACrB;AACA,aAAa,QAAQ;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa,OAAO;AACpB;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,UAAU;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,eAAe,WAAW;AAC1B;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;;AAEA;AACA;AACA,aAAa,QAAQ;AACrB;;AAEA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA,aAAa,OAAO;AACpB;AACA,eAAe,QAAQ;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;;AAEA;AACA,iBAAiB,QAAQ;AACzB;;AAEA;AACA,iBAAiB,QAAQ;AACzB;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD;;AAEA;AACA;AACA,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA,aAAa,QAAQ;AACrB,eAAe,QAAQ;AACvB;AACA;AACA;AACA,aAAa,QAAQ;AACrB;;AAEA;AACA;AACA;AACA,aAAa,QAAQ;AACrB,eAAe,QAAQ;AACvB;AACA;AACA;AACA,aAAa,QAAQ;AACrB;;AAEA;AACA;AACA;AACA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA;AACA,aAAa,MAAM;AACnB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,eAAe,QAAQ;AACvB;AACA;AACA;AACA;AACA,eAAe,QAAQ;AACvB;AACA;AACA;AACA;AACA;AACA;AACA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;AACnB,mBAAmB;;AAEnB;AACA;;AAEA,oBAAoB;AACpB,oBAAoB;;AAEpB;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA,mBAAmB;AACnB,mBAAmB;;AAEnB;AACA;;AAEA,oBAAoB;AACpB,oBAAoB;;AAEpB;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA,mBAAmB;AACnB,mBAAmB;;AAEnB;AACA;;AAEA,oBAAoB;AACpB,oBAAoB;;AAEpB;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA,mBAAmB;AACnB,mBAAmB;;AAEnB;AACA;;AAEA,oBAAoB;AACpB,oBAAoB;;AAEpB;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA,mBAAmB;AACnB,mBAAmB;;AAEnB;AACA;;AAEA,oBAAoB;AACpB,oBAAoB;;AAEpB;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA,mBAAmB;AACnB,mBAAmB;;AAEnB;AACA;;AAEA,oBAAoB;AACpB,oBAAoB;;AAEpB;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA,aAAa,OAAO;AACpB;;AAEA;AACA;AACA;AACA;;AAEA,aAAa,OAAO;;AAEpB;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa,OAAO;AACpB;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,QAAQ;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA,aAAa,QAAQ;AACrB;AACA;;AAEA;;AAEA;AACA;AACA,cAAc,SAAS;AACvB;AACA,gCAAgC,OAAO;AACvC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA;AACA,aAAa,QAAQ;AACrB,aAAa,QAAQ;AACrB;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa,QAAQ;AACrB,aAAa,QAAQ;AACrB;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA,aAAa,OAAO;AACpB,aAAa,QAAQ;;AAErB;AACA;AACA;AACA;;AAEA,cAAc,QAAQ;AACtB;AACA;;AAEA,aAAa,QAAQ;AACrB,aAAa,QAAQ;AACrB,aAAa,QAAQ;AACrB,eAAe,QAAQ;AACvB;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;;AAEA,aAAa,OAAO;AACpB,aAAa,QAAQ;AACrB;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA,eAAe,OAAO;AACtB;AACA;;AAEA,aAAa,OAAO;AACpB;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA,iBAAiB,sBAAsB;AACvC;AACA;AACA;AACA;;AAEA;AACA,iBAAiB,gBAAgB;AACjC;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,iBAAiB,gBAAgB;AACjC;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,iBAAiB,gBAAgB;AACjC;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA,UAAU;AACV;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,UAAU;AACV;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAiB,cAAc;AAC/B;AACA;;AAEA;AACA;AACA;AACA,iBAAiB,gBAAgB;AACjC;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa,uBAAuB;AACpC,aAAa,gBAAgB;AAC7B;AACA;;AAEA;AACA;AACA;AACA;AACA,UAAU;AACV;;AAEA;AACA;AACA;AACA;AACA;AACA,iBAAiB,eAAe;AAChC,UAAU;AACV;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAiB,QAAQ;AACzB;AACA,UAAU;AACV;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;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AE,OAAO,CAAC,CAAC;IAC1B,CAAC;CACF","file":"pusher-with-encryption.worker.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"Pusher\"] = factory();\n\telse\n\t\troot[\"Pusher\"] = factory();\n})(this, function() {\nreturn "," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 3);\n","// Copyright (C) 2016 Dmitry Chestnykh\n// MIT License. See LICENSE file for details.\n\n/**\n * Package base64 implements Base64 encoding and decoding.\n */\n\n// Invalid character used in decoding to indicate\n// that the character to decode is out of range of\n// alphabet and cannot be decoded.\nconst INVALID_BYTE = 256;\n\n/**\n * Implements standard Base64 encoding.\n *\n * Operates in constant time.\n */\nexport class Coder {\n // TODO(dchest): methods to encode chunk-by-chunk.\n\n constructor(private _paddingCharacter = \"=\") { }\n\n encodedLength(length: number): number {\n if (!this._paddingCharacter) {\n return (length * 8 + 5) / 6 | 0;\n }\n return (length + 2) / 3 * 4 | 0;\n }\n\n encode(data: Uint8Array): string {\n let out = \"\";\n\n let i = 0;\n for (; i < data.length - 2; i += 3) {\n let c = (data[i] << 16) | (data[i + 1] << 8) | (data[i + 2]);\n out += this._encodeByte((c >>> 3 * 6) & 63);\n out += this._encodeByte((c >>> 2 * 6) & 63);\n out += this._encodeByte((c >>> 1 * 6) & 63);\n out += this._encodeByte((c >>> 0 * 6) & 63);\n }\n\n const left = data.length - i;\n if (left > 0) {\n let c = (data[i] << 16) | (left === 2 ? data[i + 1] << 8 : 0);\n out += this._encodeByte((c >>> 3 * 6) & 63);\n out += this._encodeByte((c >>> 2 * 6) & 63);\n if (left === 2) {\n out += this._encodeByte((c >>> 1 * 6) & 63);\n } else {\n out += this._paddingCharacter || \"\";\n }\n out += this._paddingCharacter || \"\";\n }\n\n return out;\n }\n\n maxDecodedLength(length: number): number {\n if (!this._paddingCharacter) {\n return (length * 6 + 7) / 8 | 0;\n }\n return length / 4 * 3 | 0;\n }\n\n decodedLength(s: string): number {\n return this.maxDecodedLength(s.length - this._getPaddingLength(s));\n }\n\n decode(s: string): Uint8Array {\n if (s.length === 0) {\n return new Uint8Array(0);\n }\n const paddingLength = this._getPaddingLength(s);\n const length = s.length - paddingLength;\n const out = new Uint8Array(this.maxDecodedLength(length));\n let op = 0;\n let i = 0;\n let haveBad = 0;\n let v0 = 0, v1 = 0, v2 = 0, v3 = 0;\n for (; i < length - 4; i += 4) {\n v0 = this._decodeChar(s.charCodeAt(i + 0));\n v1 = this._decodeChar(s.charCodeAt(i + 1));\n v2 = this._decodeChar(s.charCodeAt(i + 2));\n v3 = this._decodeChar(s.charCodeAt(i + 3));\n out[op++] = (v0 << 2) | (v1 >>> 4);\n out[op++] = (v1 << 4) | (v2 >>> 2);\n out[op++] = (v2 << 6) | v3;\n haveBad |= v0 & INVALID_BYTE;\n haveBad |= v1 & INVALID_BYTE;\n haveBad |= v2 & INVALID_BYTE;\n haveBad |= v3 & INVALID_BYTE;\n }\n if (i < length - 1) {\n v0 = this._decodeChar(s.charCodeAt(i));\n v1 = this._decodeChar(s.charCodeAt(i + 1));\n out[op++] = (v0 << 2) | (v1 >>> 4);\n haveBad |= v0 & INVALID_BYTE;\n haveBad |= v1 & INVALID_BYTE;\n }\n if (i < length - 2) {\n v2 = this._decodeChar(s.charCodeAt(i + 2));\n out[op++] = (v1 << 4) | (v2 >>> 2);\n haveBad |= v2 & INVALID_BYTE;\n }\n if (i < length - 3) {\n v3 = this._decodeChar(s.charCodeAt(i + 3));\n out[op++] = (v2 << 6) | v3;\n haveBad |= v3 & INVALID_BYTE;\n }\n if (haveBad !== 0) {\n throw new Error(\"Base64Coder: incorrect characters for decoding\");\n }\n return out;\n }\n\n // Standard encoding have the following encoded/decoded ranges,\n // which we need to convert between.\n //\n // ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 0123456789 + /\n // Index: 0 - 25 26 - 51 52 - 61 62 63\n // ASCII: 65 - 90 97 - 122 48 - 57 43 47\n //\n\n // Encode 6 bits in b into a new character.\n protected _encodeByte(b: number): string {\n // Encoding uses constant time operations as follows:\n //\n // 1. Define comparison of A with B using (A - B) >>> 8:\n // if A > B, then result is positive integer\n // if A <= B, then result is 0\n //\n // 2. Define selection of C or 0 using bitwise AND: X & C:\n // if X == 0, then result is 0\n // if X != 0, then result is C\n //\n // 3. Start with the smallest comparison (b >= 0), which is always\n // true, so set the result to the starting ASCII value (65).\n //\n // 4. Continue comparing b to higher ASCII values, and selecting\n // zero if comparison isn't true, otherwise selecting a value\n // to add to result, which:\n //\n // a) undoes the previous addition\n // b) provides new value to add\n //\n let result = b;\n // b >= 0\n result += 65;\n // b > 25\n result += ((25 - b) >>> 8) & ((0 - 65) - 26 + 97);\n // b > 51\n result += ((51 - b) >>> 8) & ((26 - 97) - 52 + 48);\n // b > 61\n result += ((61 - b) >>> 8) & ((52 - 48) - 62 + 43);\n // b > 62\n result += ((62 - b) >>> 8) & ((62 - 43) - 63 + 47);\n\n return String.fromCharCode(result);\n }\n\n // Decode a character code into a byte.\n // Must return 256 if character is out of alphabet range.\n protected _decodeChar(c: number): number {\n // Decoding works similar to encoding: using the same comparison\n // function, but now it works on ranges: result is always incremented\n // by value, but this value becomes zero if the range is not\n // satisfied.\n //\n // Decoding starts with invalid value, 256, which is then\n // subtracted when the range is satisfied. If none of the ranges\n // apply, the function returns 256, which is then checked by\n // the caller to throw error.\n let result = INVALID_BYTE; // start with invalid character\n\n // c == 43 (c > 42 and c < 44)\n result += (((42 - c) & (c - 44)) >>> 8) & (-INVALID_BYTE + c - 43 + 62);\n // c == 47 (c > 46 and c < 48)\n result += (((46 - c) & (c - 48)) >>> 8) & (-INVALID_BYTE + c - 47 + 63);\n // c > 47 and c < 58\n result += (((47 - c) & (c - 58)) >>> 8) & (-INVALID_BYTE + c - 48 + 52);\n // c > 64 and c < 91\n result += (((64 - c) & (c - 91)) >>> 8) & (-INVALID_BYTE + c - 65 + 0);\n // c > 96 and c < 123\n result += (((96 - c) & (c - 123)) >>> 8) & (-INVALID_BYTE + c - 97 + 26);\n\n return result;\n }\n\n private _getPaddingLength(s: string): number {\n let paddingLength = 0;\n if (this._paddingCharacter) {\n for (let i = s.length - 1; i >= 0; i--) {\n if (s[i] !== this._paddingCharacter) {\n break;\n }\n paddingLength++;\n }\n if (s.length < 4 || paddingLength > 2) {\n throw new Error(\"Base64Coder: incorrect padding\");\n }\n }\n return paddingLength;\n }\n\n}\n\nconst stdCoder = new Coder();\n\nexport function encode(data: Uint8Array): string {\n return stdCoder.encode(data);\n}\n\nexport function decode(s: string): Uint8Array {\n return stdCoder.decode(s);\n}\n\n/**\n * Implements URL-safe Base64 encoding.\n * (Same as Base64, but '+' is replaced with '-', and '/' with '_').\n *\n * Operates in constant time.\n */\nexport class URLSafeCoder extends Coder {\n // URL-safe encoding have the following encoded/decoded ranges:\n //\n // ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 0123456789 - _\n // Index: 0 - 25 26 - 51 52 - 61 62 63\n // ASCII: 65 - 90 97 - 122 48 - 57 45 95\n //\n\n protected _encodeByte(b: number): string {\n let result = b;\n // b >= 0\n result += 65;\n // b > 25\n result += ((25 - b) >>> 8) & ((0 - 65) - 26 + 97);\n // b > 51\n result += ((51 - b) >>> 8) & ((26 - 97) - 52 + 48);\n // b > 61\n result += ((61 - b) >>> 8) & ((52 - 48) - 62 + 45);\n // b > 62\n result += ((62 - b) >>> 8) & ((62 - 45) - 63 + 95);\n\n return String.fromCharCode(result);\n }\n\n protected _decodeChar(c: number): number {\n let result = INVALID_BYTE;\n\n // c == 45 (c > 44 and c < 46)\n result += (((44 - c) & (c - 46)) >>> 8) & (-INVALID_BYTE + c - 45 + 62);\n // c == 95 (c > 94 and c < 96)\n result += (((94 - c) & (c - 96)) >>> 8) & (-INVALID_BYTE + c - 95 + 63);\n // c > 47 and c < 58\n result += (((47 - c) & (c - 58)) >>> 8) & (-INVALID_BYTE + c - 48 + 52);\n // c > 64 and c < 91\n result += (((64 - c) & (c - 91)) >>> 8) & (-INVALID_BYTE + c - 65 + 0);\n // c > 96 and c < 123\n result += (((96 - c) & (c - 123)) >>> 8) & (-INVALID_BYTE + c - 97 + 26);\n\n return result;\n }\n}\n\nconst urlSafeCoder = new URLSafeCoder();\n\nexport function encodeURLSafe(data: Uint8Array): string {\n return urlSafeCoder.encode(data);\n}\n\nexport function decodeURLSafe(s: string): Uint8Array {\n return urlSafeCoder.decode(s);\n}\n\n\nexport const encodedLength = (length: number) =>\n stdCoder.encodedLength(length);\n\nexport const maxDecodedLength = (length: number) =>\n stdCoder.maxDecodedLength(length);\n\nexport const decodedLength = (s: string) =>\n stdCoder.decodedLength(s);\n","// Copyright (C) 2016 Dmitry Chestnykh\n// MIT License. See LICENSE file for details.\n\n/**\n * Package utf8 implements UTF-8 encoding and decoding.\n */\n\nconst INVALID_UTF16 = \"utf8: invalid string\";\nconst INVALID_UTF8 = \"utf8: invalid source encoding\";\n\n/**\n * Encodes the given string into UTF-8 byte array.\n * Throws if the source string has invalid UTF-16 encoding.\n */\nexport function encode(s: string): Uint8Array {\n // Calculate result length and allocate output array.\n // encodedLength() also validates string and throws errors,\n // so we don't need repeat validation here.\n const arr = new Uint8Array(encodedLength(s));\n\n let pos = 0;\n for (let i = 0; i < s.length; i++) {\n let c = s.charCodeAt(i);\n if (c < 0x80) {\n arr[pos++] = c;\n } else if (c < 0x800) {\n arr[pos++] = 0xc0 | c >> 6;\n arr[pos++] = 0x80 | c & 0x3f;\n } else if (c < 0xd800) {\n arr[pos++] = 0xe0 | c >> 12;\n arr[pos++] = 0x80 | (c >> 6) & 0x3f;\n arr[pos++] = 0x80 | c & 0x3f;\n } else {\n i++; // get one more character\n c = (c & 0x3ff) << 10;\n c |= s.charCodeAt(i) & 0x3ff;\n c += 0x10000;\n\n arr[pos++] = 0xf0 | c >> 18;\n arr[pos++] = 0x80 | (c >> 12) & 0x3f;\n arr[pos++] = 0x80 | (c >> 6) & 0x3f;\n arr[pos++] = 0x80 | c & 0x3f;\n }\n }\n return arr;\n}\n\n/**\n * Returns the number of bytes required to encode the given string into UTF-8.\n * Throws if the source string has invalid UTF-16 encoding.\n */\nexport function encodedLength(s: string): number {\n let result = 0;\n for (let i = 0; i < s.length; i++) {\n const c = s.charCodeAt(i);\n if (c < 0x80) {\n result += 1;\n } else if (c < 0x800) {\n result += 2;\n } else if (c < 0xd800) {\n result += 3;\n } else if (c <= 0xdfff) {\n if (i >= s.length - 1) {\n throw new Error(INVALID_UTF16);\n }\n i++; // \"eat\" next character\n result += 4;\n } else {\n throw new Error(INVALID_UTF16);\n }\n }\n return result;\n}\n\n/**\n * Decodes the given byte array from UTF-8 into a string.\n * Throws if encoding is invalid.\n */\nexport function decode(arr: Uint8Array): string {\n const chars: string[] = [];\n for (let i = 0; i < arr.length; i++) {\n let b = arr[i];\n\n if (b & 0x80) {\n let min;\n if (b < 0xe0) {\n // Need 1 more byte.\n if (i >= arr.length) {\n throw new Error(INVALID_UTF8);\n }\n const n1 = arr[++i];\n if ((n1 & 0xc0) !== 0x80) {\n throw new Error(INVALID_UTF8);\n }\n b = (b & 0x1f) << 6 | (n1 & 0x3f);\n min = 0x80;\n } else if (b < 0xf0) {\n // Need 2 more bytes.\n if (i >= arr.length - 1) {\n throw new Error(INVALID_UTF8);\n }\n const n1 = arr[++i];\n const n2 = arr[++i];\n if ((n1 & 0xc0) !== 0x80 || (n2 & 0xc0) !== 0x80) {\n throw new Error(INVALID_UTF8);\n }\n b = (b & 0x0f) << 12 | (n1 & 0x3f) << 6 | (n2 & 0x3f);\n min = 0x800;\n } else if (b < 0xf8) {\n // Need 3 more bytes.\n if (i >= arr.length - 2) {\n throw new Error(INVALID_UTF8);\n }\n const n1 = arr[++i];\n const n2 = arr[++i];\n const n3 = arr[++i];\n if ((n1 & 0xc0) !== 0x80 || (n2 & 0xc0) !== 0x80 || (n3 & 0xc0) !== 0x80) {\n throw new Error(INVALID_UTF8);\n }\n b = (b & 0x0f) << 18 | (n1 & 0x3f) << 12 | (n2 & 0x3f) << 6 | (n3 & 0x3f);\n min = 0x10000;\n } else {\n throw new Error(INVALID_UTF8);\n }\n\n if (b < min || (b >= 0xd800 && b <= 0xdfff)) {\n throw new Error(INVALID_UTF8);\n }\n\n if (b >= 0x10000) {\n // Surrogate pair.\n if (b > 0x10ffff) {\n throw new Error(INVALID_UTF8);\n }\n b -= 0x10000;\n chars.push(String.fromCharCode(0xd800 | (b >> 10)));\n b = 0xdc00 | (b & 0x3ff);\n }\n }\n\n chars.push(String.fromCharCode(b));\n }\n return chars.join(\"\");\n}\n","(function(nacl) {\n'use strict';\n\n// Ported in 2014 by Dmitry Chestnykh and Devi Mandiri.\n// Public domain.\n//\n// Implementation derived from TweetNaCl version 20140427.\n// See for details: http://tweetnacl.cr.yp.to/\n\nvar gf = function(init) {\n var i, r = new Float64Array(16);\n if (init) for (i = 0; i < init.length; i++) r[i] = init[i];\n return r;\n};\n\n// Pluggable, initialized in high-level API below.\nvar randombytes = function(/* x, n */) { throw new Error('no PRNG'); };\n\nvar _0 = new Uint8Array(16);\nvar _9 = new Uint8Array(32); _9[0] = 9;\n\nvar gf0 = gf(),\n gf1 = gf([1]),\n _121665 = gf([0xdb41, 1]),\n D = gf([0x78a3, 0x1359, 0x4dca, 0x75eb, 0xd8ab, 0x4141, 0x0a4d, 0x0070, 0xe898, 0x7779, 0x4079, 0x8cc7, 0xfe73, 0x2b6f, 0x6cee, 0x5203]),\n D2 = gf([0xf159, 0x26b2, 0x9b94, 0xebd6, 0xb156, 0x8283, 0x149a, 0x00e0, 0xd130, 0xeef3, 0x80f2, 0x198e, 0xfce7, 0x56df, 0xd9dc, 0x2406]),\n X = gf([0xd51a, 0x8f25, 0x2d60, 0xc956, 0xa7b2, 0x9525, 0xc760, 0x692c, 0xdc5c, 0xfdd6, 0xe231, 0xc0a4, 0x53fe, 0xcd6e, 0x36d3, 0x2169]),\n Y = gf([0x6658, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666]),\n I = gf([0xa0b0, 0x4a0e, 0x1b27, 0xc4ee, 0xe478, 0xad2f, 0x1806, 0x2f43, 0xd7a7, 0x3dfb, 0x0099, 0x2b4d, 0xdf0b, 0x4fc1, 0x2480, 0x2b83]);\n\nfunction ts64(x, i, h, l) {\n x[i] = (h >> 24) & 0xff;\n x[i+1] = (h >> 16) & 0xff;\n x[i+2] = (h >> 8) & 0xff;\n x[i+3] = h & 0xff;\n x[i+4] = (l >> 24) & 0xff;\n x[i+5] = (l >> 16) & 0xff;\n x[i+6] = (l >> 8) & 0xff;\n x[i+7] = l & 0xff;\n}\n\nfunction vn(x, xi, y, yi, n) {\n var i,d = 0;\n for (i = 0; i < n; i++) d |= x[xi+i]^y[yi+i];\n return (1 & ((d - 1) >>> 8)) - 1;\n}\n\nfunction crypto_verify_16(x, xi, y, yi) {\n return vn(x,xi,y,yi,16);\n}\n\nfunction crypto_verify_32(x, xi, y, yi) {\n return vn(x,xi,y,yi,32);\n}\n\nfunction core_salsa20(o, p, k, c) {\n var j0 = c[ 0] & 0xff | (c[ 1] & 0xff)<<8 | (c[ 2] & 0xff)<<16 | (c[ 3] & 0xff)<<24,\n j1 = k[ 0] & 0xff | (k[ 1] & 0xff)<<8 | (k[ 2] & 0xff)<<16 | (k[ 3] & 0xff)<<24,\n j2 = k[ 4] & 0xff | (k[ 5] & 0xff)<<8 | (k[ 6] & 0xff)<<16 | (k[ 7] & 0xff)<<24,\n j3 = k[ 8] & 0xff | (k[ 9] & 0xff)<<8 | (k[10] & 0xff)<<16 | (k[11] & 0xff)<<24,\n j4 = k[12] & 0xff | (k[13] & 0xff)<<8 | (k[14] & 0xff)<<16 | (k[15] & 0xff)<<24,\n j5 = c[ 4] & 0xff | (c[ 5] & 0xff)<<8 | (c[ 6] & 0xff)<<16 | (c[ 7] & 0xff)<<24,\n j6 = p[ 0] & 0xff | (p[ 1] & 0xff)<<8 | (p[ 2] & 0xff)<<16 | (p[ 3] & 0xff)<<24,\n j7 = p[ 4] & 0xff | (p[ 5] & 0xff)<<8 | (p[ 6] & 0xff)<<16 | (p[ 7] & 0xff)<<24,\n j8 = p[ 8] & 0xff | (p[ 9] & 0xff)<<8 | (p[10] & 0xff)<<16 | (p[11] & 0xff)<<24,\n j9 = p[12] & 0xff | (p[13] & 0xff)<<8 | (p[14] & 0xff)<<16 | (p[15] & 0xff)<<24,\n j10 = c[ 8] & 0xff | (c[ 9] & 0xff)<<8 | (c[10] & 0xff)<<16 | (c[11] & 0xff)<<24,\n j11 = k[16] & 0xff | (k[17] & 0xff)<<8 | (k[18] & 0xff)<<16 | (k[19] & 0xff)<<24,\n j12 = k[20] & 0xff | (k[21] & 0xff)<<8 | (k[22] & 0xff)<<16 | (k[23] & 0xff)<<24,\n j13 = k[24] & 0xff | (k[25] & 0xff)<<8 | (k[26] & 0xff)<<16 | (k[27] & 0xff)<<24,\n j14 = k[28] & 0xff | (k[29] & 0xff)<<8 | (k[30] & 0xff)<<16 | (k[31] & 0xff)<<24,\n j15 = c[12] & 0xff | (c[13] & 0xff)<<8 | (c[14] & 0xff)<<16 | (c[15] & 0xff)<<24;\n\n var x0 = j0, x1 = j1, x2 = j2, x3 = j3, x4 = j4, x5 = j5, x6 = j6, x7 = j7,\n x8 = j8, x9 = j9, x10 = j10, x11 = j11, x12 = j12, x13 = j13, x14 = j14,\n x15 = j15, u;\n\n for (var i = 0; i < 20; i += 2) {\n u = x0 + x12 | 0;\n x4 ^= u<<7 | u>>>(32-7);\n u = x4 + x0 | 0;\n x8 ^= u<<9 | u>>>(32-9);\n u = x8 + x4 | 0;\n x12 ^= u<<13 | u>>>(32-13);\n u = x12 + x8 | 0;\n x0 ^= u<<18 | u>>>(32-18);\n\n u = x5 + x1 | 0;\n x9 ^= u<<7 | u>>>(32-7);\n u = x9 + x5 | 0;\n x13 ^= u<<9 | u>>>(32-9);\n u = x13 + x9 | 0;\n x1 ^= u<<13 | u>>>(32-13);\n u = x1 + x13 | 0;\n x5 ^= u<<18 | u>>>(32-18);\n\n u = x10 + x6 | 0;\n x14 ^= u<<7 | u>>>(32-7);\n u = x14 + x10 | 0;\n x2 ^= u<<9 | u>>>(32-9);\n u = x2 + x14 | 0;\n x6 ^= u<<13 | u>>>(32-13);\n u = x6 + x2 | 0;\n x10 ^= u<<18 | u>>>(32-18);\n\n u = x15 + x11 | 0;\n x3 ^= u<<7 | u>>>(32-7);\n u = x3 + x15 | 0;\n x7 ^= u<<9 | u>>>(32-9);\n u = x7 + x3 | 0;\n x11 ^= u<<13 | u>>>(32-13);\n u = x11 + x7 | 0;\n x15 ^= u<<18 | u>>>(32-18);\n\n u = x0 + x3 | 0;\n x1 ^= u<<7 | u>>>(32-7);\n u = x1 + x0 | 0;\n x2 ^= u<<9 | u>>>(32-9);\n u = x2 + x1 | 0;\n x3 ^= u<<13 | u>>>(32-13);\n u = x3 + x2 | 0;\n x0 ^= u<<18 | u>>>(32-18);\n\n u = x5 + x4 | 0;\n x6 ^= u<<7 | u>>>(32-7);\n u = x6 + x5 | 0;\n x7 ^= u<<9 | u>>>(32-9);\n u = x7 + x6 | 0;\n x4 ^= u<<13 | u>>>(32-13);\n u = x4 + x7 | 0;\n x5 ^= u<<18 | u>>>(32-18);\n\n u = x10 + x9 | 0;\n x11 ^= u<<7 | u>>>(32-7);\n u = x11 + x10 | 0;\n x8 ^= u<<9 | u>>>(32-9);\n u = x8 + x11 | 0;\n x9 ^= u<<13 | u>>>(32-13);\n u = x9 + x8 | 0;\n x10 ^= u<<18 | u>>>(32-18);\n\n u = x15 + x14 | 0;\n x12 ^= u<<7 | u>>>(32-7);\n u = x12 + x15 | 0;\n x13 ^= u<<9 | u>>>(32-9);\n u = x13 + x12 | 0;\n x14 ^= u<<13 | u>>>(32-13);\n u = x14 + x13 | 0;\n x15 ^= u<<18 | u>>>(32-18);\n }\n x0 = x0 + j0 | 0;\n x1 = x1 + j1 | 0;\n x2 = x2 + j2 | 0;\n x3 = x3 + j3 | 0;\n x4 = x4 + j4 | 0;\n x5 = x5 + j5 | 0;\n x6 = x6 + j6 | 0;\n x7 = x7 + j7 | 0;\n x8 = x8 + j8 | 0;\n x9 = x9 + j9 | 0;\n x10 = x10 + j10 | 0;\n x11 = x11 + j11 | 0;\n x12 = x12 + j12 | 0;\n x13 = x13 + j13 | 0;\n x14 = x14 + j14 | 0;\n x15 = x15 + j15 | 0;\n\n o[ 0] = x0 >>> 0 & 0xff;\n o[ 1] = x0 >>> 8 & 0xff;\n o[ 2] = x0 >>> 16 & 0xff;\n o[ 3] = x0 >>> 24 & 0xff;\n\n o[ 4] = x1 >>> 0 & 0xff;\n o[ 5] = x1 >>> 8 & 0xff;\n o[ 6] = x1 >>> 16 & 0xff;\n o[ 7] = x1 >>> 24 & 0xff;\n\n o[ 8] = x2 >>> 0 & 0xff;\n o[ 9] = x2 >>> 8 & 0xff;\n o[10] = x2 >>> 16 & 0xff;\n o[11] = x2 >>> 24 & 0xff;\n\n o[12] = x3 >>> 0 & 0xff;\n o[13] = x3 >>> 8 & 0xff;\n o[14] = x3 >>> 16 & 0xff;\n o[15] = x3 >>> 24 & 0xff;\n\n o[16] = x4 >>> 0 & 0xff;\n o[17] = x4 >>> 8 & 0xff;\n o[18] = x4 >>> 16 & 0xff;\n o[19] = x4 >>> 24 & 0xff;\n\n o[20] = x5 >>> 0 & 0xff;\n o[21] = x5 >>> 8 & 0xff;\n o[22] = x5 >>> 16 & 0xff;\n o[23] = x5 >>> 24 & 0xff;\n\n o[24] = x6 >>> 0 & 0xff;\n o[25] = x6 >>> 8 & 0xff;\n o[26] = x6 >>> 16 & 0xff;\n o[27] = x6 >>> 24 & 0xff;\n\n o[28] = x7 >>> 0 & 0xff;\n o[29] = x7 >>> 8 & 0xff;\n o[30] = x7 >>> 16 & 0xff;\n o[31] = x7 >>> 24 & 0xff;\n\n o[32] = x8 >>> 0 & 0xff;\n o[33] = x8 >>> 8 & 0xff;\n o[34] = x8 >>> 16 & 0xff;\n o[35] = x8 >>> 24 & 0xff;\n\n o[36] = x9 >>> 0 & 0xff;\n o[37] = x9 >>> 8 & 0xff;\n o[38] = x9 >>> 16 & 0xff;\n o[39] = x9 >>> 24 & 0xff;\n\n o[40] = x10 >>> 0 & 0xff;\n o[41] = x10 >>> 8 & 0xff;\n o[42] = x10 >>> 16 & 0xff;\n o[43] = x10 >>> 24 & 0xff;\n\n o[44] = x11 >>> 0 & 0xff;\n o[45] = x11 >>> 8 & 0xff;\n o[46] = x11 >>> 16 & 0xff;\n o[47] = x11 >>> 24 & 0xff;\n\n o[48] = x12 >>> 0 & 0xff;\n o[49] = x12 >>> 8 & 0xff;\n o[50] = x12 >>> 16 & 0xff;\n o[51] = x12 >>> 24 & 0xff;\n\n o[52] = x13 >>> 0 & 0xff;\n o[53] = x13 >>> 8 & 0xff;\n o[54] = x13 >>> 16 & 0xff;\n o[55] = x13 >>> 24 & 0xff;\n\n o[56] = x14 >>> 0 & 0xff;\n o[57] = x14 >>> 8 & 0xff;\n o[58] = x14 >>> 16 & 0xff;\n o[59] = x14 >>> 24 & 0xff;\n\n o[60] = x15 >>> 0 & 0xff;\n o[61] = x15 >>> 8 & 0xff;\n o[62] = x15 >>> 16 & 0xff;\n o[63] = x15 >>> 24 & 0xff;\n}\n\nfunction core_hsalsa20(o,p,k,c) {\n var j0 = c[ 0] & 0xff | (c[ 1] & 0xff)<<8 | (c[ 2] & 0xff)<<16 | (c[ 3] & 0xff)<<24,\n j1 = k[ 0] & 0xff | (k[ 1] & 0xff)<<8 | (k[ 2] & 0xff)<<16 | (k[ 3] & 0xff)<<24,\n j2 = k[ 4] & 0xff | (k[ 5] & 0xff)<<8 | (k[ 6] & 0xff)<<16 | (k[ 7] & 0xff)<<24,\n j3 = k[ 8] & 0xff | (k[ 9] & 0xff)<<8 | (k[10] & 0xff)<<16 | (k[11] & 0xff)<<24,\n j4 = k[12] & 0xff | (k[13] & 0xff)<<8 | (k[14] & 0xff)<<16 | (k[15] & 0xff)<<24,\n j5 = c[ 4] & 0xff | (c[ 5] & 0xff)<<8 | (c[ 6] & 0xff)<<16 | (c[ 7] & 0xff)<<24,\n j6 = p[ 0] & 0xff | (p[ 1] & 0xff)<<8 | (p[ 2] & 0xff)<<16 | (p[ 3] & 0xff)<<24,\n j7 = p[ 4] & 0xff | (p[ 5] & 0xff)<<8 | (p[ 6] & 0xff)<<16 | (p[ 7] & 0xff)<<24,\n j8 = p[ 8] & 0xff | (p[ 9] & 0xff)<<8 | (p[10] & 0xff)<<16 | (p[11] & 0xff)<<24,\n j9 = p[12] & 0xff | (p[13] & 0xff)<<8 | (p[14] & 0xff)<<16 | (p[15] & 0xff)<<24,\n j10 = c[ 8] & 0xff | (c[ 9] & 0xff)<<8 | (c[10] & 0xff)<<16 | (c[11] & 0xff)<<24,\n j11 = k[16] & 0xff | (k[17] & 0xff)<<8 | (k[18] & 0xff)<<16 | (k[19] & 0xff)<<24,\n j12 = k[20] & 0xff | (k[21] & 0xff)<<8 | (k[22] & 0xff)<<16 | (k[23] & 0xff)<<24,\n j13 = k[24] & 0xff | (k[25] & 0xff)<<8 | (k[26] & 0xff)<<16 | (k[27] & 0xff)<<24,\n j14 = k[28] & 0xff | (k[29] & 0xff)<<8 | (k[30] & 0xff)<<16 | (k[31] & 0xff)<<24,\n j15 = c[12] & 0xff | (c[13] & 0xff)<<8 | (c[14] & 0xff)<<16 | (c[15] & 0xff)<<24;\n\n var x0 = j0, x1 = j1, x2 = j2, x3 = j3, x4 = j4, x5 = j5, x6 = j6, x7 = j7,\n x8 = j8, x9 = j9, x10 = j10, x11 = j11, x12 = j12, x13 = j13, x14 = j14,\n x15 = j15, u;\n\n for (var i = 0; i < 20; i += 2) {\n u = x0 + x12 | 0;\n x4 ^= u<<7 | u>>>(32-7);\n u = x4 + x0 | 0;\n x8 ^= u<<9 | u>>>(32-9);\n u = x8 + x4 | 0;\n x12 ^= u<<13 | u>>>(32-13);\n u = x12 + x8 | 0;\n x0 ^= u<<18 | u>>>(32-18);\n\n u = x5 + x1 | 0;\n x9 ^= u<<7 | u>>>(32-7);\n u = x9 + x5 | 0;\n x13 ^= u<<9 | u>>>(32-9);\n u = x13 + x9 | 0;\n x1 ^= u<<13 | u>>>(32-13);\n u = x1 + x13 | 0;\n x5 ^= u<<18 | u>>>(32-18);\n\n u = x10 + x6 | 0;\n x14 ^= u<<7 | u>>>(32-7);\n u = x14 + x10 | 0;\n x2 ^= u<<9 | u>>>(32-9);\n u = x2 + x14 | 0;\n x6 ^= u<<13 | u>>>(32-13);\n u = x6 + x2 | 0;\n x10 ^= u<<18 | u>>>(32-18);\n\n u = x15 + x11 | 0;\n x3 ^= u<<7 | u>>>(32-7);\n u = x3 + x15 | 0;\n x7 ^= u<<9 | u>>>(32-9);\n u = x7 + x3 | 0;\n x11 ^= u<<13 | u>>>(32-13);\n u = x11 + x7 | 0;\n x15 ^= u<<18 | u>>>(32-18);\n\n u = x0 + x3 | 0;\n x1 ^= u<<7 | u>>>(32-7);\n u = x1 + x0 | 0;\n x2 ^= u<<9 | u>>>(32-9);\n u = x2 + x1 | 0;\n x3 ^= u<<13 | u>>>(32-13);\n u = x3 + x2 | 0;\n x0 ^= u<<18 | u>>>(32-18);\n\n u = x5 + x4 | 0;\n x6 ^= u<<7 | u>>>(32-7);\n u = x6 + x5 | 0;\n x7 ^= u<<9 | u>>>(32-9);\n u = x7 + x6 | 0;\n x4 ^= u<<13 | u>>>(32-13);\n u = x4 + x7 | 0;\n x5 ^= u<<18 | u>>>(32-18);\n\n u = x10 + x9 | 0;\n x11 ^= u<<7 | u>>>(32-7);\n u = x11 + x10 | 0;\n x8 ^= u<<9 | u>>>(32-9);\n u = x8 + x11 | 0;\n x9 ^= u<<13 | u>>>(32-13);\n u = x9 + x8 | 0;\n x10 ^= u<<18 | u>>>(32-18);\n\n u = x15 + x14 | 0;\n x12 ^= u<<7 | u>>>(32-7);\n u = x12 + x15 | 0;\n x13 ^= u<<9 | u>>>(32-9);\n u = x13 + x12 | 0;\n x14 ^= u<<13 | u>>>(32-13);\n u = x14 + x13 | 0;\n x15 ^= u<<18 | u>>>(32-18);\n }\n\n o[ 0] = x0 >>> 0 & 0xff;\n o[ 1] = x0 >>> 8 & 0xff;\n o[ 2] = x0 >>> 16 & 0xff;\n o[ 3] = x0 >>> 24 & 0xff;\n\n o[ 4] = x5 >>> 0 & 0xff;\n o[ 5] = x5 >>> 8 & 0xff;\n o[ 6] = x5 >>> 16 & 0xff;\n o[ 7] = x5 >>> 24 & 0xff;\n\n o[ 8] = x10 >>> 0 & 0xff;\n o[ 9] = x10 >>> 8 & 0xff;\n o[10] = x10 >>> 16 & 0xff;\n o[11] = x10 >>> 24 & 0xff;\n\n o[12] = x15 >>> 0 & 0xff;\n o[13] = x15 >>> 8 & 0xff;\n o[14] = x15 >>> 16 & 0xff;\n o[15] = x15 >>> 24 & 0xff;\n\n o[16] = x6 >>> 0 & 0xff;\n o[17] = x6 >>> 8 & 0xff;\n o[18] = x6 >>> 16 & 0xff;\n o[19] = x6 >>> 24 & 0xff;\n\n o[20] = x7 >>> 0 & 0xff;\n o[21] = x7 >>> 8 & 0xff;\n o[22] = x7 >>> 16 & 0xff;\n o[23] = x7 >>> 24 & 0xff;\n\n o[24] = x8 >>> 0 & 0xff;\n o[25] = x8 >>> 8 & 0xff;\n o[26] = x8 >>> 16 & 0xff;\n o[27] = x8 >>> 24 & 0xff;\n\n o[28] = x9 >>> 0 & 0xff;\n o[29] = x9 >>> 8 & 0xff;\n o[30] = x9 >>> 16 & 0xff;\n o[31] = x9 >>> 24 & 0xff;\n}\n\nfunction crypto_core_salsa20(out,inp,k,c) {\n core_salsa20(out,inp,k,c);\n}\n\nfunction crypto_core_hsalsa20(out,inp,k,c) {\n core_hsalsa20(out,inp,k,c);\n}\n\nvar sigma = new Uint8Array([101, 120, 112, 97, 110, 100, 32, 51, 50, 45, 98, 121, 116, 101, 32, 107]);\n // \"expand 32-byte k\"\n\nfunction crypto_stream_salsa20_xor(c,cpos,m,mpos,b,n,k) {\n var z = new Uint8Array(16), x = new Uint8Array(64);\n var u, i;\n for (i = 0; i < 16; i++) z[i] = 0;\n for (i = 0; i < 8; i++) z[i] = n[i];\n while (b >= 64) {\n crypto_core_salsa20(x,z,k,sigma);\n for (i = 0; i < 64; i++) c[cpos+i] = m[mpos+i] ^ x[i];\n u = 1;\n for (i = 8; i < 16; i++) {\n u = u + (z[i] & 0xff) | 0;\n z[i] = u & 0xff;\n u >>>= 8;\n }\n b -= 64;\n cpos += 64;\n mpos += 64;\n }\n if (b > 0) {\n crypto_core_salsa20(x,z,k,sigma);\n for (i = 0; i < b; i++) c[cpos+i] = m[mpos+i] ^ x[i];\n }\n return 0;\n}\n\nfunction crypto_stream_salsa20(c,cpos,b,n,k) {\n var z = new Uint8Array(16), x = new Uint8Array(64);\n var u, i;\n for (i = 0; i < 16; i++) z[i] = 0;\n for (i = 0; i < 8; i++) z[i] = n[i];\n while (b >= 64) {\n crypto_core_salsa20(x,z,k,sigma);\n for (i = 0; i < 64; i++) c[cpos+i] = x[i];\n u = 1;\n for (i = 8; i < 16; i++) {\n u = u + (z[i] & 0xff) | 0;\n z[i] = u & 0xff;\n u >>>= 8;\n }\n b -= 64;\n cpos += 64;\n }\n if (b > 0) {\n crypto_core_salsa20(x,z,k,sigma);\n for (i = 0; i < b; i++) c[cpos+i] = x[i];\n }\n return 0;\n}\n\nfunction crypto_stream(c,cpos,d,n,k) {\n var s = new Uint8Array(32);\n crypto_core_hsalsa20(s,n,k,sigma);\n var sn = new Uint8Array(8);\n for (var i = 0; i < 8; i++) sn[i] = n[i+16];\n return crypto_stream_salsa20(c,cpos,d,sn,s);\n}\n\nfunction crypto_stream_xor(c,cpos,m,mpos,d,n,k) {\n var s = new Uint8Array(32);\n crypto_core_hsalsa20(s,n,k,sigma);\n var sn = new Uint8Array(8);\n for (var i = 0; i < 8; i++) sn[i] = n[i+16];\n return crypto_stream_salsa20_xor(c,cpos,m,mpos,d,sn,s);\n}\n\n/*\n* Port of Andrew Moon's Poly1305-donna-16. Public domain.\n* https://github.com/floodyberry/poly1305-donna\n*/\n\nvar poly1305 = function(key) {\n this.buffer = new Uint8Array(16);\n this.r = new Uint16Array(10);\n this.h = new Uint16Array(10);\n this.pad = new Uint16Array(8);\n this.leftover = 0;\n this.fin = 0;\n\n var t0, t1, t2, t3, t4, t5, t6, t7;\n\n t0 = key[ 0] & 0xff | (key[ 1] & 0xff) << 8; this.r[0] = ( t0 ) & 0x1fff;\n t1 = key[ 2] & 0xff | (key[ 3] & 0xff) << 8; this.r[1] = ((t0 >>> 13) | (t1 << 3)) & 0x1fff;\n t2 = key[ 4] & 0xff | (key[ 5] & 0xff) << 8; this.r[2] = ((t1 >>> 10) | (t2 << 6)) & 0x1f03;\n t3 = key[ 6] & 0xff | (key[ 7] & 0xff) << 8; this.r[3] = ((t2 >>> 7) | (t3 << 9)) & 0x1fff;\n t4 = key[ 8] & 0xff | (key[ 9] & 0xff) << 8; this.r[4] = ((t3 >>> 4) | (t4 << 12)) & 0x00ff;\n this.r[5] = ((t4 >>> 1)) & 0x1ffe;\n t5 = key[10] & 0xff | (key[11] & 0xff) << 8; this.r[6] = ((t4 >>> 14) | (t5 << 2)) & 0x1fff;\n t6 = key[12] & 0xff | (key[13] & 0xff) << 8; this.r[7] = ((t5 >>> 11) | (t6 << 5)) & 0x1f81;\n t7 = key[14] & 0xff | (key[15] & 0xff) << 8; this.r[8] = ((t6 >>> 8) | (t7 << 8)) & 0x1fff;\n this.r[9] = ((t7 >>> 5)) & 0x007f;\n\n this.pad[0] = key[16] & 0xff | (key[17] & 0xff) << 8;\n this.pad[1] = key[18] & 0xff | (key[19] & 0xff) << 8;\n this.pad[2] = key[20] & 0xff | (key[21] & 0xff) << 8;\n this.pad[3] = key[22] & 0xff | (key[23] & 0xff) << 8;\n this.pad[4] = key[24] & 0xff | (key[25] & 0xff) << 8;\n this.pad[5] = key[26] & 0xff | (key[27] & 0xff) << 8;\n this.pad[6] = key[28] & 0xff | (key[29] & 0xff) << 8;\n this.pad[7] = key[30] & 0xff | (key[31] & 0xff) << 8;\n};\n\npoly1305.prototype.blocks = function(m, mpos, bytes) {\n var hibit = this.fin ? 0 : (1 << 11);\n var t0, t1, t2, t3, t4, t5, t6, t7, c;\n var d0, d1, d2, d3, d4, d5, d6, d7, d8, d9;\n\n var h0 = this.h[0],\n h1 = this.h[1],\n h2 = this.h[2],\n h3 = this.h[3],\n h4 = this.h[4],\n h5 = this.h[5],\n h6 = this.h[6],\n h7 = this.h[7],\n h8 = this.h[8],\n h9 = this.h[9];\n\n var r0 = this.r[0],\n r1 = this.r[1],\n r2 = this.r[2],\n r3 = this.r[3],\n r4 = this.r[4],\n r5 = this.r[5],\n r6 = this.r[6],\n r7 = this.r[7],\n r8 = this.r[8],\n r9 = this.r[9];\n\n while (bytes >= 16) {\n t0 = m[mpos+ 0] & 0xff | (m[mpos+ 1] & 0xff) << 8; h0 += ( t0 ) & 0x1fff;\n t1 = m[mpos+ 2] & 0xff | (m[mpos+ 3] & 0xff) << 8; h1 += ((t0 >>> 13) | (t1 << 3)) & 0x1fff;\n t2 = m[mpos+ 4] & 0xff | (m[mpos+ 5] & 0xff) << 8; h2 += ((t1 >>> 10) | (t2 << 6)) & 0x1fff;\n t3 = m[mpos+ 6] & 0xff | (m[mpos+ 7] & 0xff) << 8; h3 += ((t2 >>> 7) | (t3 << 9)) & 0x1fff;\n t4 = m[mpos+ 8] & 0xff | (m[mpos+ 9] & 0xff) << 8; h4 += ((t3 >>> 4) | (t4 << 12)) & 0x1fff;\n h5 += ((t4 >>> 1)) & 0x1fff;\n t5 = m[mpos+10] & 0xff | (m[mpos+11] & 0xff) << 8; h6 += ((t4 >>> 14) | (t5 << 2)) & 0x1fff;\n t6 = m[mpos+12] & 0xff | (m[mpos+13] & 0xff) << 8; h7 += ((t5 >>> 11) | (t6 << 5)) & 0x1fff;\n t7 = m[mpos+14] & 0xff | (m[mpos+15] & 0xff) << 8; h8 += ((t6 >>> 8) | (t7 << 8)) & 0x1fff;\n h9 += ((t7 >>> 5)) | hibit;\n\n c = 0;\n\n d0 = c;\n d0 += h0 * r0;\n d0 += h1 * (5 * r9);\n d0 += h2 * (5 * r8);\n d0 += h3 * (5 * r7);\n d0 += h4 * (5 * r6);\n c = (d0 >>> 13); d0 &= 0x1fff;\n d0 += h5 * (5 * r5);\n d0 += h6 * (5 * r4);\n d0 += h7 * (5 * r3);\n d0 += h8 * (5 * r2);\n d0 += h9 * (5 * r1);\n c += (d0 >>> 13); d0 &= 0x1fff;\n\n d1 = c;\n d1 += h0 * r1;\n d1 += h1 * r0;\n d1 += h2 * (5 * r9);\n d1 += h3 * (5 * r8);\n d1 += h4 * (5 * r7);\n c = (d1 >>> 13); d1 &= 0x1fff;\n d1 += h5 * (5 * r6);\n d1 += h6 * (5 * r5);\n d1 += h7 * (5 * r4);\n d1 += h8 * (5 * r3);\n d1 += h9 * (5 * r2);\n c += (d1 >>> 13); d1 &= 0x1fff;\n\n d2 = c;\n d2 += h0 * r2;\n d2 += h1 * r1;\n d2 += h2 * r0;\n d2 += h3 * (5 * r9);\n d2 += h4 * (5 * r8);\n c = (d2 >>> 13); d2 &= 0x1fff;\n d2 += h5 * (5 * r7);\n d2 += h6 * (5 * r6);\n d2 += h7 * (5 * r5);\n d2 += h8 * (5 * r4);\n d2 += h9 * (5 * r3);\n c += (d2 >>> 13); d2 &= 0x1fff;\n\n d3 = c;\n d3 += h0 * r3;\n d3 += h1 * r2;\n d3 += h2 * r1;\n d3 += h3 * r0;\n d3 += h4 * (5 * r9);\n c = (d3 >>> 13); d3 &= 0x1fff;\n d3 += h5 * (5 * r8);\n d3 += h6 * (5 * r7);\n d3 += h7 * (5 * r6);\n d3 += h8 * (5 * r5);\n d3 += h9 * (5 * r4);\n c += (d3 >>> 13); d3 &= 0x1fff;\n\n d4 = c;\n d4 += h0 * r4;\n d4 += h1 * r3;\n d4 += h2 * r2;\n d4 += h3 * r1;\n d4 += h4 * r0;\n c = (d4 >>> 13); d4 &= 0x1fff;\n d4 += h5 * (5 * r9);\n d4 += h6 * (5 * r8);\n d4 += h7 * (5 * r7);\n d4 += h8 * (5 * r6);\n d4 += h9 * (5 * r5);\n c += (d4 >>> 13); d4 &= 0x1fff;\n\n d5 = c;\n d5 += h0 * r5;\n d5 += h1 * r4;\n d5 += h2 * r3;\n d5 += h3 * r2;\n d5 += h4 * r1;\n c = (d5 >>> 13); d5 &= 0x1fff;\n d5 += h5 * r0;\n d5 += h6 * (5 * r9);\n d5 += h7 * (5 * r8);\n d5 += h8 * (5 * r7);\n d5 += h9 * (5 * r6);\n c += (d5 >>> 13); d5 &= 0x1fff;\n\n d6 = c;\n d6 += h0 * r6;\n d6 += h1 * r5;\n d6 += h2 * r4;\n d6 += h3 * r3;\n d6 += h4 * r2;\n c = (d6 >>> 13); d6 &= 0x1fff;\n d6 += h5 * r1;\n d6 += h6 * r0;\n d6 += h7 * (5 * r9);\n d6 += h8 * (5 * r8);\n d6 += h9 * (5 * r7);\n c += (d6 >>> 13); d6 &= 0x1fff;\n\n d7 = c;\n d7 += h0 * r7;\n d7 += h1 * r6;\n d7 += h2 * r5;\n d7 += h3 * r4;\n d7 += h4 * r3;\n c = (d7 >>> 13); d7 &= 0x1fff;\n d7 += h5 * r2;\n d7 += h6 * r1;\n d7 += h7 * r0;\n d7 += h8 * (5 * r9);\n d7 += h9 * (5 * r8);\n c += (d7 >>> 13); d7 &= 0x1fff;\n\n d8 = c;\n d8 += h0 * r8;\n d8 += h1 * r7;\n d8 += h2 * r6;\n d8 += h3 * r5;\n d8 += h4 * r4;\n c = (d8 >>> 13); d8 &= 0x1fff;\n d8 += h5 * r3;\n d8 += h6 * r2;\n d8 += h7 * r1;\n d8 += h8 * r0;\n d8 += h9 * (5 * r9);\n c += (d8 >>> 13); d8 &= 0x1fff;\n\n d9 = c;\n d9 += h0 * r9;\n d9 += h1 * r8;\n d9 += h2 * r7;\n d9 += h3 * r6;\n d9 += h4 * r5;\n c = (d9 >>> 13); d9 &= 0x1fff;\n d9 += h5 * r4;\n d9 += h6 * r3;\n d9 += h7 * r2;\n d9 += h8 * r1;\n d9 += h9 * r0;\n c += (d9 >>> 13); d9 &= 0x1fff;\n\n c = (((c << 2) + c)) | 0;\n c = (c + d0) | 0;\n d0 = c & 0x1fff;\n c = (c >>> 13);\n d1 += c;\n\n h0 = d0;\n h1 = d1;\n h2 = d2;\n h3 = d3;\n h4 = d4;\n h5 = d5;\n h6 = d6;\n h7 = d7;\n h8 = d8;\n h9 = d9;\n\n mpos += 16;\n bytes -= 16;\n }\n this.h[0] = h0;\n this.h[1] = h1;\n this.h[2] = h2;\n this.h[3] = h3;\n this.h[4] = h4;\n this.h[5] = h5;\n this.h[6] = h6;\n this.h[7] = h7;\n this.h[8] = h8;\n this.h[9] = h9;\n};\n\npoly1305.prototype.finish = function(mac, macpos) {\n var g = new Uint16Array(10);\n var c, mask, f, i;\n\n if (this.leftover) {\n i = this.leftover;\n this.buffer[i++] = 1;\n for (; i < 16; i++) this.buffer[i] = 0;\n this.fin = 1;\n this.blocks(this.buffer, 0, 16);\n }\n\n c = this.h[1] >>> 13;\n this.h[1] &= 0x1fff;\n for (i = 2; i < 10; i++) {\n this.h[i] += c;\n c = this.h[i] >>> 13;\n this.h[i] &= 0x1fff;\n }\n this.h[0] += (c * 5);\n c = this.h[0] >>> 13;\n this.h[0] &= 0x1fff;\n this.h[1] += c;\n c = this.h[1] >>> 13;\n this.h[1] &= 0x1fff;\n this.h[2] += c;\n\n g[0] = this.h[0] + 5;\n c = g[0] >>> 13;\n g[0] &= 0x1fff;\n for (i = 1; i < 10; i++) {\n g[i] = this.h[i] + c;\n c = g[i] >>> 13;\n g[i] &= 0x1fff;\n }\n g[9] -= (1 << 13);\n\n mask = (c ^ 1) - 1;\n for (i = 0; i < 10; i++) g[i] &= mask;\n mask = ~mask;\n for (i = 0; i < 10; i++) this.h[i] = (this.h[i] & mask) | g[i];\n\n this.h[0] = ((this.h[0] ) | (this.h[1] << 13) ) & 0xffff;\n this.h[1] = ((this.h[1] >>> 3) | (this.h[2] << 10) ) & 0xffff;\n this.h[2] = ((this.h[2] >>> 6) | (this.h[3] << 7) ) & 0xffff;\n this.h[3] = ((this.h[3] >>> 9) | (this.h[4] << 4) ) & 0xffff;\n this.h[4] = ((this.h[4] >>> 12) | (this.h[5] << 1) | (this.h[6] << 14)) & 0xffff;\n this.h[5] = ((this.h[6] >>> 2) | (this.h[7] << 11) ) & 0xffff;\n this.h[6] = ((this.h[7] >>> 5) | (this.h[8] << 8) ) & 0xffff;\n this.h[7] = ((this.h[8] >>> 8) | (this.h[9] << 5) ) & 0xffff;\n\n f = this.h[0] + this.pad[0];\n this.h[0] = f & 0xffff;\n for (i = 1; i < 8; i++) {\n f = (((this.h[i] + this.pad[i]) | 0) + (f >>> 16)) | 0;\n this.h[i] = f & 0xffff;\n }\n\n mac[macpos+ 0] = (this.h[0] >>> 0) & 0xff;\n mac[macpos+ 1] = (this.h[0] >>> 8) & 0xff;\n mac[macpos+ 2] = (this.h[1] >>> 0) & 0xff;\n mac[macpos+ 3] = (this.h[1] >>> 8) & 0xff;\n mac[macpos+ 4] = (this.h[2] >>> 0) & 0xff;\n mac[macpos+ 5] = (this.h[2] >>> 8) & 0xff;\n mac[macpos+ 6] = (this.h[3] >>> 0) & 0xff;\n mac[macpos+ 7] = (this.h[3] >>> 8) & 0xff;\n mac[macpos+ 8] = (this.h[4] >>> 0) & 0xff;\n mac[macpos+ 9] = (this.h[4] >>> 8) & 0xff;\n mac[macpos+10] = (this.h[5] >>> 0) & 0xff;\n mac[macpos+11] = (this.h[5] >>> 8) & 0xff;\n mac[macpos+12] = (this.h[6] >>> 0) & 0xff;\n mac[macpos+13] = (this.h[6] >>> 8) & 0xff;\n mac[macpos+14] = (this.h[7] >>> 0) & 0xff;\n mac[macpos+15] = (this.h[7] >>> 8) & 0xff;\n};\n\npoly1305.prototype.update = function(m, mpos, bytes) {\n var i, want;\n\n if (this.leftover) {\n want = (16 - this.leftover);\n if (want > bytes)\n want = bytes;\n for (i = 0; i < want; i++)\n this.buffer[this.leftover + i] = m[mpos+i];\n bytes -= want;\n mpos += want;\n this.leftover += want;\n if (this.leftover < 16)\n return;\n this.blocks(this.buffer, 0, 16);\n this.leftover = 0;\n }\n\n if (bytes >= 16) {\n want = bytes - (bytes % 16);\n this.blocks(m, mpos, want);\n mpos += want;\n bytes -= want;\n }\n\n if (bytes) {\n for (i = 0; i < bytes; i++)\n this.buffer[this.leftover + i] = m[mpos+i];\n this.leftover += bytes;\n }\n};\n\nfunction crypto_onetimeauth(out, outpos, m, mpos, n, k) {\n var s = new poly1305(k);\n s.update(m, mpos, n);\n s.finish(out, outpos);\n return 0;\n}\n\nfunction crypto_onetimeauth_verify(h, hpos, m, mpos, n, k) {\n var x = new Uint8Array(16);\n crypto_onetimeauth(x,0,m,mpos,n,k);\n return crypto_verify_16(h,hpos,x,0);\n}\n\nfunction crypto_secretbox(c,m,d,n,k) {\n var i;\n if (d < 32) return -1;\n crypto_stream_xor(c,0,m,0,d,n,k);\n crypto_onetimeauth(c, 16, c, 32, d - 32, c);\n for (i = 0; i < 16; i++) c[i] = 0;\n return 0;\n}\n\nfunction crypto_secretbox_open(m,c,d,n,k) {\n var i;\n var x = new Uint8Array(32);\n if (d < 32) return -1;\n crypto_stream(x,0,32,n,k);\n if (crypto_onetimeauth_verify(c, 16,c, 32,d - 32,x) !== 0) return -1;\n crypto_stream_xor(m,0,c,0,d,n,k);\n for (i = 0; i < 32; i++) m[i] = 0;\n return 0;\n}\n\nfunction set25519(r, a) {\n var i;\n for (i = 0; i < 16; i++) r[i] = a[i]|0;\n}\n\nfunction car25519(o) {\n var i, v, c = 1;\n for (i = 0; i < 16; i++) {\n v = o[i] + c + 65535;\n c = Math.floor(v / 65536);\n o[i] = v - c * 65536;\n }\n o[0] += c-1 + 37 * (c-1);\n}\n\nfunction sel25519(p, q, b) {\n var t, c = ~(b-1);\n for (var i = 0; i < 16; i++) {\n t = c & (p[i] ^ q[i]);\n p[i] ^= t;\n q[i] ^= t;\n }\n}\n\nfunction pack25519(o, n) {\n var i, j, b;\n var m = gf(), t = gf();\n for (i = 0; i < 16; i++) t[i] = n[i];\n car25519(t);\n car25519(t);\n car25519(t);\n for (j = 0; j < 2; j++) {\n m[0] = t[0] - 0xffed;\n for (i = 1; i < 15; i++) {\n m[i] = t[i] - 0xffff - ((m[i-1]>>16) & 1);\n m[i-1] &= 0xffff;\n }\n m[15] = t[15] - 0x7fff - ((m[14]>>16) & 1);\n b = (m[15]>>16) & 1;\n m[14] &= 0xffff;\n sel25519(t, m, 1-b);\n }\n for (i = 0; i < 16; i++) {\n o[2*i] = t[i] & 0xff;\n o[2*i+1] = t[i]>>8;\n }\n}\n\nfunction neq25519(a, b) {\n var c = new Uint8Array(32), d = new Uint8Array(32);\n pack25519(c, a);\n pack25519(d, b);\n return crypto_verify_32(c, 0, d, 0);\n}\n\nfunction par25519(a) {\n var d = new Uint8Array(32);\n pack25519(d, a);\n return d[0] & 1;\n}\n\nfunction unpack25519(o, n) {\n var i;\n for (i = 0; i < 16; i++) o[i] = n[2*i] + (n[2*i+1] << 8);\n o[15] &= 0x7fff;\n}\n\nfunction A(o, a, b) {\n for (var i = 0; i < 16; i++) o[i] = a[i] + b[i];\n}\n\nfunction Z(o, a, b) {\n for (var i = 0; i < 16; i++) o[i] = a[i] - b[i];\n}\n\nfunction M(o, a, b) {\n var v, c,\n t0 = 0, t1 = 0, t2 = 0, t3 = 0, t4 = 0, t5 = 0, t6 = 0, t7 = 0,\n t8 = 0, t9 = 0, t10 = 0, t11 = 0, t12 = 0, t13 = 0, t14 = 0, t15 = 0,\n t16 = 0, t17 = 0, t18 = 0, t19 = 0, t20 = 0, t21 = 0, t22 = 0, t23 = 0,\n t24 = 0, t25 = 0, t26 = 0, t27 = 0, t28 = 0, t29 = 0, t30 = 0,\n b0 = b[0],\n b1 = b[1],\n b2 = b[2],\n b3 = b[3],\n b4 = b[4],\n b5 = b[5],\n b6 = b[6],\n b7 = b[7],\n b8 = b[8],\n b9 = b[9],\n b10 = b[10],\n b11 = b[11],\n b12 = b[12],\n b13 = b[13],\n b14 = b[14],\n b15 = b[15];\n\n v = a[0];\n t0 += v * b0;\n t1 += v * b1;\n t2 += v * b2;\n t3 += v * b3;\n t4 += v * b4;\n t5 += v * b5;\n t6 += v * b6;\n t7 += v * b7;\n t8 += v * b8;\n t9 += v * b9;\n t10 += v * b10;\n t11 += v * b11;\n t12 += v * b12;\n t13 += v * b13;\n t14 += v * b14;\n t15 += v * b15;\n v = a[1];\n t1 += v * b0;\n t2 += v * b1;\n t3 += v * b2;\n t4 += v * b3;\n t5 += v * b4;\n t6 += v * b5;\n t7 += v * b6;\n t8 += v * b7;\n t9 += v * b8;\n t10 += v * b9;\n t11 += v * b10;\n t12 += v * b11;\n t13 += v * b12;\n t14 += v * b13;\n t15 += v * b14;\n t16 += v * b15;\n v = a[2];\n t2 += v * b0;\n t3 += v * b1;\n t4 += v * b2;\n t5 += v * b3;\n t6 += v * b4;\n t7 += v * b5;\n t8 += v * b6;\n t9 += v * b7;\n t10 += v * b8;\n t11 += v * b9;\n t12 += v * b10;\n t13 += v * b11;\n t14 += v * b12;\n t15 += v * b13;\n t16 += v * b14;\n t17 += v * b15;\n v = a[3];\n t3 += v * b0;\n t4 += v * b1;\n t5 += v * b2;\n t6 += v * b3;\n t7 += v * b4;\n t8 += v * b5;\n t9 += v * b6;\n t10 += v * b7;\n t11 += v * b8;\n t12 += v * b9;\n t13 += v * b10;\n t14 += v * b11;\n t15 += v * b12;\n t16 += v * b13;\n t17 += v * b14;\n t18 += v * b15;\n v = a[4];\n t4 += v * b0;\n t5 += v * b1;\n t6 += v * b2;\n t7 += v * b3;\n t8 += v * b4;\n t9 += v * b5;\n t10 += v * b6;\n t11 += v * b7;\n t12 += v * b8;\n t13 += v * b9;\n t14 += v * b10;\n t15 += v * b11;\n t16 += v * b12;\n t17 += v * b13;\n t18 += v * b14;\n t19 += v * b15;\n v = a[5];\n t5 += v * b0;\n t6 += v * b1;\n t7 += v * b2;\n t8 += v * b3;\n t9 += v * b4;\n t10 += v * b5;\n t11 += v * b6;\n t12 += v * b7;\n t13 += v * b8;\n t14 += v * b9;\n t15 += v * b10;\n t16 += v * b11;\n t17 += v * b12;\n t18 += v * b13;\n t19 += v * b14;\n t20 += v * b15;\n v = a[6];\n t6 += v * b0;\n t7 += v * b1;\n t8 += v * b2;\n t9 += v * b3;\n t10 += v * b4;\n t11 += v * b5;\n t12 += v * b6;\n t13 += v * b7;\n t14 += v * b8;\n t15 += v * b9;\n t16 += v * b10;\n t17 += v * b11;\n t18 += v * b12;\n t19 += v * b13;\n t20 += v * b14;\n t21 += v * b15;\n v = a[7];\n t7 += v * b0;\n t8 += v * b1;\n t9 += v * b2;\n t10 += v * b3;\n t11 += v * b4;\n t12 += v * b5;\n t13 += v * b6;\n t14 += v * b7;\n t15 += v * b8;\n t16 += v * b9;\n t17 += v * b10;\n t18 += v * b11;\n t19 += v * b12;\n t20 += v * b13;\n t21 += v * b14;\n t22 += v * b15;\n v = a[8];\n t8 += v * b0;\n t9 += v * b1;\n t10 += v * b2;\n t11 += v * b3;\n t12 += v * b4;\n t13 += v * b5;\n t14 += v * b6;\n t15 += v * b7;\n t16 += v * b8;\n t17 += v * b9;\n t18 += v * b10;\n t19 += v * b11;\n t20 += v * b12;\n t21 += v * b13;\n t22 += v * b14;\n t23 += v * b15;\n v = a[9];\n t9 += v * b0;\n t10 += v * b1;\n t11 += v * b2;\n t12 += v * b3;\n t13 += v * b4;\n t14 += v * b5;\n t15 += v * b6;\n t16 += v * b7;\n t17 += v * b8;\n t18 += v * b9;\n t19 += v * b10;\n t20 += v * b11;\n t21 += v * b12;\n t22 += v * b13;\n t23 += v * b14;\n t24 += v * b15;\n v = a[10];\n t10 += v * b0;\n t11 += v * b1;\n t12 += v * b2;\n t13 += v * b3;\n t14 += v * b4;\n t15 += v * b5;\n t16 += v * b6;\n t17 += v * b7;\n t18 += v * b8;\n t19 += v * b9;\n t20 += v * b10;\n t21 += v * b11;\n t22 += v * b12;\n t23 += v * b13;\n t24 += v * b14;\n t25 += v * b15;\n v = a[11];\n t11 += v * b0;\n t12 += v * b1;\n t13 += v * b2;\n t14 += v * b3;\n t15 += v * b4;\n t16 += v * b5;\n t17 += v * b6;\n t18 += v * b7;\n t19 += v * b8;\n t20 += v * b9;\n t21 += v * b10;\n t22 += v * b11;\n t23 += v * b12;\n t24 += v * b13;\n t25 += v * b14;\n t26 += v * b15;\n v = a[12];\n t12 += v * b0;\n t13 += v * b1;\n t14 += v * b2;\n t15 += v * b3;\n t16 += v * b4;\n t17 += v * b5;\n t18 += v * b6;\n t19 += v * b7;\n t20 += v * b8;\n t21 += v * b9;\n t22 += v * b10;\n t23 += v * b11;\n t24 += v * b12;\n t25 += v * b13;\n t26 += v * b14;\n t27 += v * b15;\n v = a[13];\n t13 += v * b0;\n t14 += v * b1;\n t15 += v * b2;\n t16 += v * b3;\n t17 += v * b4;\n t18 += v * b5;\n t19 += v * b6;\n t20 += v * b7;\n t21 += v * b8;\n t22 += v * b9;\n t23 += v * b10;\n t24 += v * b11;\n t25 += v * b12;\n t26 += v * b13;\n t27 += v * b14;\n t28 += v * b15;\n v = a[14];\n t14 += v * b0;\n t15 += v * b1;\n t16 += v * b2;\n t17 += v * b3;\n t18 += v * b4;\n t19 += v * b5;\n t20 += v * b6;\n t21 += v * b7;\n t22 += v * b8;\n t23 += v * b9;\n t24 += v * b10;\n t25 += v * b11;\n t26 += v * b12;\n t27 += v * b13;\n t28 += v * b14;\n t29 += v * b15;\n v = a[15];\n t15 += v * b0;\n t16 += v * b1;\n t17 += v * b2;\n t18 += v * b3;\n t19 += v * b4;\n t20 += v * b5;\n t21 += v * b6;\n t22 += v * b7;\n t23 += v * b8;\n t24 += v * b9;\n t25 += v * b10;\n t26 += v * b11;\n t27 += v * b12;\n t28 += v * b13;\n t29 += v * b14;\n t30 += v * b15;\n\n t0 += 38 * t16;\n t1 += 38 * t17;\n t2 += 38 * t18;\n t3 += 38 * t19;\n t4 += 38 * t20;\n t5 += 38 * t21;\n t6 += 38 * t22;\n t7 += 38 * t23;\n t8 += 38 * t24;\n t9 += 38 * t25;\n t10 += 38 * t26;\n t11 += 38 * t27;\n t12 += 38 * t28;\n t13 += 38 * t29;\n t14 += 38 * t30;\n // t15 left as is\n\n // first car\n c = 1;\n v = t0 + c + 65535; c = Math.floor(v / 65536); t0 = v - c * 65536;\n v = t1 + c + 65535; c = Math.floor(v / 65536); t1 = v - c * 65536;\n v = t2 + c + 65535; c = Math.floor(v / 65536); t2 = v - c * 65536;\n v = t3 + c + 65535; c = Math.floor(v / 65536); t3 = v - c * 65536;\n v = t4 + c + 65535; c = Math.floor(v / 65536); t4 = v - c * 65536;\n v = t5 + c + 65535; c = Math.floor(v / 65536); t5 = v - c * 65536;\n v = t6 + c + 65535; c = Math.floor(v / 65536); t6 = v - c * 65536;\n v = t7 + c + 65535; c = Math.floor(v / 65536); t7 = v - c * 65536;\n v = t8 + c + 65535; c = Math.floor(v / 65536); t8 = v - c * 65536;\n v = t9 + c + 65535; c = Math.floor(v / 65536); t9 = v - c * 65536;\n v = t10 + c + 65535; c = Math.floor(v / 65536); t10 = v - c * 65536;\n v = t11 + c + 65535; c = Math.floor(v / 65536); t11 = v - c * 65536;\n v = t12 + c + 65535; c = Math.floor(v / 65536); t12 = v - c * 65536;\n v = t13 + c + 65535; c = Math.floor(v / 65536); t13 = v - c * 65536;\n v = t14 + c + 65535; c = Math.floor(v / 65536); t14 = v - c * 65536;\n v = t15 + c + 65535; c = Math.floor(v / 65536); t15 = v - c * 65536;\n t0 += c-1 + 37 * (c-1);\n\n // second car\n c = 1;\n v = t0 + c + 65535; c = Math.floor(v / 65536); t0 = v - c * 65536;\n v = t1 + c + 65535; c = Math.floor(v / 65536); t1 = v - c * 65536;\n v = t2 + c + 65535; c = Math.floor(v / 65536); t2 = v - c * 65536;\n v = t3 + c + 65535; c = Math.floor(v / 65536); t3 = v - c * 65536;\n v = t4 + c + 65535; c = Math.floor(v / 65536); t4 = v - c * 65536;\n v = t5 + c + 65535; c = Math.floor(v / 65536); t5 = v - c * 65536;\n v = t6 + c + 65535; c = Math.floor(v / 65536); t6 = v - c * 65536;\n v = t7 + c + 65535; c = Math.floor(v / 65536); t7 = v - c * 65536;\n v = t8 + c + 65535; c = Math.floor(v / 65536); t8 = v - c * 65536;\n v = t9 + c + 65535; c = Math.floor(v / 65536); t9 = v - c * 65536;\n v = t10 + c + 65535; c = Math.floor(v / 65536); t10 = v - c * 65536;\n v = t11 + c + 65535; c = Math.floor(v / 65536); t11 = v - c * 65536;\n v = t12 + c + 65535; c = Math.floor(v / 65536); t12 = v - c * 65536;\n v = t13 + c + 65535; c = Math.floor(v / 65536); t13 = v - c * 65536;\n v = t14 + c + 65535; c = Math.floor(v / 65536); t14 = v - c * 65536;\n v = t15 + c + 65535; c = Math.floor(v / 65536); t15 = v - c * 65536;\n t0 += c-1 + 37 * (c-1);\n\n o[ 0] = t0;\n o[ 1] = t1;\n o[ 2] = t2;\n o[ 3] = t3;\n o[ 4] = t4;\n o[ 5] = t5;\n o[ 6] = t6;\n o[ 7] = t7;\n o[ 8] = t8;\n o[ 9] = t9;\n o[10] = t10;\n o[11] = t11;\n o[12] = t12;\n o[13] = t13;\n o[14] = t14;\n o[15] = t15;\n}\n\nfunction S(o, a) {\n M(o, a, a);\n}\n\nfunction inv25519(o, i) {\n var c = gf();\n var a;\n for (a = 0; a < 16; a++) c[a] = i[a];\n for (a = 253; a >= 0; a--) {\n S(c, c);\n if(a !== 2 && a !== 4) M(c, c, i);\n }\n for (a = 0; a < 16; a++) o[a] = c[a];\n}\n\nfunction pow2523(o, i) {\n var c = gf();\n var a;\n for (a = 0; a < 16; a++) c[a] = i[a];\n for (a = 250; a >= 0; a--) {\n S(c, c);\n if(a !== 1) M(c, c, i);\n }\n for (a = 0; a < 16; a++) o[a] = c[a];\n}\n\nfunction crypto_scalarmult(q, n, p) {\n var z = new Uint8Array(32);\n var x = new Float64Array(80), r, i;\n var a = gf(), b = gf(), c = gf(),\n d = gf(), e = gf(), f = gf();\n for (i = 0; i < 31; i++) z[i] = n[i];\n z[31]=(n[31]&127)|64;\n z[0]&=248;\n unpack25519(x,p);\n for (i = 0; i < 16; i++) {\n b[i]=x[i];\n d[i]=a[i]=c[i]=0;\n }\n a[0]=d[0]=1;\n for (i=254; i>=0; --i) {\n r=(z[i>>>3]>>>(i&7))&1;\n sel25519(a,b,r);\n sel25519(c,d,r);\n A(e,a,c);\n Z(a,a,c);\n A(c,b,d);\n Z(b,b,d);\n S(d,e);\n S(f,a);\n M(a,c,a);\n M(c,b,e);\n A(e,a,c);\n Z(a,a,c);\n S(b,a);\n Z(c,d,f);\n M(a,c,_121665);\n A(a,a,d);\n M(c,c,a);\n M(a,d,f);\n M(d,b,x);\n S(b,e);\n sel25519(a,b,r);\n sel25519(c,d,r);\n }\n for (i = 0; i < 16; i++) {\n x[i+16]=a[i];\n x[i+32]=c[i];\n x[i+48]=b[i];\n x[i+64]=d[i];\n }\n var x32 = x.subarray(32);\n var x16 = x.subarray(16);\n inv25519(x32,x32);\n M(x16,x16,x32);\n pack25519(q,x16);\n return 0;\n}\n\nfunction crypto_scalarmult_base(q, n) {\n return crypto_scalarmult(q, n, _9);\n}\n\nfunction crypto_box_keypair(y, x) {\n randombytes(x, 32);\n return crypto_scalarmult_base(y, x);\n}\n\nfunction crypto_box_beforenm(k, y, x) {\n var s = new Uint8Array(32);\n crypto_scalarmult(s, x, y);\n return crypto_core_hsalsa20(k, _0, s, sigma);\n}\n\nvar crypto_box_afternm = crypto_secretbox;\nvar crypto_box_open_afternm = crypto_secretbox_open;\n\nfunction crypto_box(c, m, d, n, y, x) {\n var k = new Uint8Array(32);\n crypto_box_beforenm(k, y, x);\n return crypto_box_afternm(c, m, d, n, k);\n}\n\nfunction crypto_box_open(m, c, d, n, y, x) {\n var k = new Uint8Array(32);\n crypto_box_beforenm(k, y, x);\n return crypto_box_open_afternm(m, c, d, n, k);\n}\n\nvar K = [\n 0x428a2f98, 0xd728ae22, 0x71374491, 0x23ef65cd,\n 0xb5c0fbcf, 0xec4d3b2f, 0xe9b5dba5, 0x8189dbbc,\n 0x3956c25b, 0xf348b538, 0x59f111f1, 0xb605d019,\n 0x923f82a4, 0xaf194f9b, 0xab1c5ed5, 0xda6d8118,\n 0xd807aa98, 0xa3030242, 0x12835b01, 0x45706fbe,\n 0x243185be, 0x4ee4b28c, 0x550c7dc3, 0xd5ffb4e2,\n 0x72be5d74, 0xf27b896f, 0x80deb1fe, 0x3b1696b1,\n 0x9bdc06a7, 0x25c71235, 0xc19bf174, 0xcf692694,\n 0xe49b69c1, 0x9ef14ad2, 0xefbe4786, 0x384f25e3,\n 0x0fc19dc6, 0x8b8cd5b5, 0x240ca1cc, 0x77ac9c65,\n 0x2de92c6f, 0x592b0275, 0x4a7484aa, 0x6ea6e483,\n 0x5cb0a9dc, 0xbd41fbd4, 0x76f988da, 0x831153b5,\n 0x983e5152, 0xee66dfab, 0xa831c66d, 0x2db43210,\n 0xb00327c8, 0x98fb213f, 0xbf597fc7, 0xbeef0ee4,\n 0xc6e00bf3, 0x3da88fc2, 0xd5a79147, 0x930aa725,\n 0x06ca6351, 0xe003826f, 0x14292967, 0x0a0e6e70,\n 0x27b70a85, 0x46d22ffc, 0x2e1b2138, 0x5c26c926,\n 0x4d2c6dfc, 0x5ac42aed, 0x53380d13, 0x9d95b3df,\n 0x650a7354, 0x8baf63de, 0x766a0abb, 0x3c77b2a8,\n 0x81c2c92e, 0x47edaee6, 0x92722c85, 0x1482353b,\n 0xa2bfe8a1, 0x4cf10364, 0xa81a664b, 0xbc423001,\n 0xc24b8b70, 0xd0f89791, 0xc76c51a3, 0x0654be30,\n 0xd192e819, 0xd6ef5218, 0xd6990624, 0x5565a910,\n 0xf40e3585, 0x5771202a, 0x106aa070, 0x32bbd1b8,\n 0x19a4c116, 0xb8d2d0c8, 0x1e376c08, 0x5141ab53,\n 0x2748774c, 0xdf8eeb99, 0x34b0bcb5, 0xe19b48a8,\n 0x391c0cb3, 0xc5c95a63, 0x4ed8aa4a, 0xe3418acb,\n 0x5b9cca4f, 0x7763e373, 0x682e6ff3, 0xd6b2b8a3,\n 0x748f82ee, 0x5defb2fc, 0x78a5636f, 0x43172f60,\n 0x84c87814, 0xa1f0ab72, 0x8cc70208, 0x1a6439ec,\n 0x90befffa, 0x23631e28, 0xa4506ceb, 0xde82bde9,\n 0xbef9a3f7, 0xb2c67915, 0xc67178f2, 0xe372532b,\n 0xca273ece, 0xea26619c, 0xd186b8c7, 0x21c0c207,\n 0xeada7dd6, 0xcde0eb1e, 0xf57d4f7f, 0xee6ed178,\n 0x06f067aa, 0x72176fba, 0x0a637dc5, 0xa2c898a6,\n 0x113f9804, 0xbef90dae, 0x1b710b35, 0x131c471b,\n 0x28db77f5, 0x23047d84, 0x32caab7b, 0x40c72493,\n 0x3c9ebe0a, 0x15c9bebc, 0x431d67c4, 0x9c100d4c,\n 0x4cc5d4be, 0xcb3e42b6, 0x597f299c, 0xfc657e2a,\n 0x5fcb6fab, 0x3ad6faec, 0x6c44198c, 0x4a475817\n];\n\nfunction crypto_hashblocks_hl(hh, hl, m, n) {\n var wh = new Int32Array(16), wl = new Int32Array(16),\n bh0, bh1, bh2, bh3, bh4, bh5, bh6, bh7,\n bl0, bl1, bl2, bl3, bl4, bl5, bl6, bl7,\n th, tl, i, j, h, l, a, b, c, d;\n\n var ah0 = hh[0],\n ah1 = hh[1],\n ah2 = hh[2],\n ah3 = hh[3],\n ah4 = hh[4],\n ah5 = hh[5],\n ah6 = hh[6],\n ah7 = hh[7],\n\n al0 = hl[0],\n al1 = hl[1],\n al2 = hl[2],\n al3 = hl[3],\n al4 = hl[4],\n al5 = hl[5],\n al6 = hl[6],\n al7 = hl[7];\n\n var pos = 0;\n while (n >= 128) {\n for (i = 0; i < 16; i++) {\n j = 8 * i + pos;\n wh[i] = (m[j+0] << 24) | (m[j+1] << 16) | (m[j+2] << 8) | m[j+3];\n wl[i] = (m[j+4] << 24) | (m[j+5] << 16) | (m[j+6] << 8) | m[j+7];\n }\n for (i = 0; i < 80; i++) {\n bh0 = ah0;\n bh1 = ah1;\n bh2 = ah2;\n bh3 = ah3;\n bh4 = ah4;\n bh5 = ah5;\n bh6 = ah6;\n bh7 = ah7;\n\n bl0 = al0;\n bl1 = al1;\n bl2 = al2;\n bl3 = al3;\n bl4 = al4;\n bl5 = al5;\n bl6 = al6;\n bl7 = al7;\n\n // add\n h = ah7;\n l = al7;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n // Sigma1\n h = ((ah4 >>> 14) | (al4 << (32-14))) ^ ((ah4 >>> 18) | (al4 << (32-18))) ^ ((al4 >>> (41-32)) | (ah4 << (32-(41-32))));\n l = ((al4 >>> 14) | (ah4 << (32-14))) ^ ((al4 >>> 18) | (ah4 << (32-18))) ^ ((ah4 >>> (41-32)) | (al4 << (32-(41-32))));\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // Ch\n h = (ah4 & ah5) ^ (~ah4 & ah6);\n l = (al4 & al5) ^ (~al4 & al6);\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // K\n h = K[i*2];\n l = K[i*2+1];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // w\n h = wh[i%16];\n l = wl[i%16];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n th = c & 0xffff | d << 16;\n tl = a & 0xffff | b << 16;\n\n // add\n h = th;\n l = tl;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n // Sigma0\n h = ((ah0 >>> 28) | (al0 << (32-28))) ^ ((al0 >>> (34-32)) | (ah0 << (32-(34-32)))) ^ ((al0 >>> (39-32)) | (ah0 << (32-(39-32))));\n l = ((al0 >>> 28) | (ah0 << (32-28))) ^ ((ah0 >>> (34-32)) | (al0 << (32-(34-32)))) ^ ((ah0 >>> (39-32)) | (al0 << (32-(39-32))));\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // Maj\n h = (ah0 & ah1) ^ (ah0 & ah2) ^ (ah1 & ah2);\n l = (al0 & al1) ^ (al0 & al2) ^ (al1 & al2);\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n bh7 = (c & 0xffff) | (d << 16);\n bl7 = (a & 0xffff) | (b << 16);\n\n // add\n h = bh3;\n l = bl3;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = th;\n l = tl;\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n bh3 = (c & 0xffff) | (d << 16);\n bl3 = (a & 0xffff) | (b << 16);\n\n ah1 = bh0;\n ah2 = bh1;\n ah3 = bh2;\n ah4 = bh3;\n ah5 = bh4;\n ah6 = bh5;\n ah7 = bh6;\n ah0 = bh7;\n\n al1 = bl0;\n al2 = bl1;\n al3 = bl2;\n al4 = bl3;\n al5 = bl4;\n al6 = bl5;\n al7 = bl6;\n al0 = bl7;\n\n if (i%16 === 15) {\n for (j = 0; j < 16; j++) {\n // add\n h = wh[j];\n l = wl[j];\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = wh[(j+9)%16];\n l = wl[(j+9)%16];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // sigma0\n th = wh[(j+1)%16];\n tl = wl[(j+1)%16];\n h = ((th >>> 1) | (tl << (32-1))) ^ ((th >>> 8) | (tl << (32-8))) ^ (th >>> 7);\n l = ((tl >>> 1) | (th << (32-1))) ^ ((tl >>> 8) | (th << (32-8))) ^ ((tl >>> 7) | (th << (32-7)));\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // sigma1\n th = wh[(j+14)%16];\n tl = wl[(j+14)%16];\n h = ((th >>> 19) | (tl << (32-19))) ^ ((tl >>> (61-32)) | (th << (32-(61-32)))) ^ (th >>> 6);\n l = ((tl >>> 19) | (th << (32-19))) ^ ((th >>> (61-32)) | (tl << (32-(61-32)))) ^ ((tl >>> 6) | (th << (32-6)));\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n wh[j] = (c & 0xffff) | (d << 16);\n wl[j] = (a & 0xffff) | (b << 16);\n }\n }\n }\n\n // add\n h = ah0;\n l = al0;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[0];\n l = hl[0];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[0] = ah0 = (c & 0xffff) | (d << 16);\n hl[0] = al0 = (a & 0xffff) | (b << 16);\n\n h = ah1;\n l = al1;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[1];\n l = hl[1];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[1] = ah1 = (c & 0xffff) | (d << 16);\n hl[1] = al1 = (a & 0xffff) | (b << 16);\n\n h = ah2;\n l = al2;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[2];\n l = hl[2];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[2] = ah2 = (c & 0xffff) | (d << 16);\n hl[2] = al2 = (a & 0xffff) | (b << 16);\n\n h = ah3;\n l = al3;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[3];\n l = hl[3];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[3] = ah3 = (c & 0xffff) | (d << 16);\n hl[3] = al3 = (a & 0xffff) | (b << 16);\n\n h = ah4;\n l = al4;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[4];\n l = hl[4];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[4] = ah4 = (c & 0xffff) | (d << 16);\n hl[4] = al4 = (a & 0xffff) | (b << 16);\n\n h = ah5;\n l = al5;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[5];\n l = hl[5];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[5] = ah5 = (c & 0xffff) | (d << 16);\n hl[5] = al5 = (a & 0xffff) | (b << 16);\n\n h = ah6;\n l = al6;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[6];\n l = hl[6];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[6] = ah6 = (c & 0xffff) | (d << 16);\n hl[6] = al6 = (a & 0xffff) | (b << 16);\n\n h = ah7;\n l = al7;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[7];\n l = hl[7];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[7] = ah7 = (c & 0xffff) | (d << 16);\n hl[7] = al7 = (a & 0xffff) | (b << 16);\n\n pos += 128;\n n -= 128;\n }\n\n return n;\n}\n\nfunction crypto_hash(out, m, n) {\n var hh = new Int32Array(8),\n hl = new Int32Array(8),\n x = new Uint8Array(256),\n i, b = n;\n\n hh[0] = 0x6a09e667;\n hh[1] = 0xbb67ae85;\n hh[2] = 0x3c6ef372;\n hh[3] = 0xa54ff53a;\n hh[4] = 0x510e527f;\n hh[5] = 0x9b05688c;\n hh[6] = 0x1f83d9ab;\n hh[7] = 0x5be0cd19;\n\n hl[0] = 0xf3bcc908;\n hl[1] = 0x84caa73b;\n hl[2] = 0xfe94f82b;\n hl[3] = 0x5f1d36f1;\n hl[4] = 0xade682d1;\n hl[5] = 0x2b3e6c1f;\n hl[6] = 0xfb41bd6b;\n hl[7] = 0x137e2179;\n\n crypto_hashblocks_hl(hh, hl, m, n);\n n %= 128;\n\n for (i = 0; i < n; i++) x[i] = m[b-n+i];\n x[n] = 128;\n\n n = 256-128*(n<112?1:0);\n x[n-9] = 0;\n ts64(x, n-8, (b / 0x20000000) | 0, b << 3);\n crypto_hashblocks_hl(hh, hl, x, n);\n\n for (i = 0; i < 8; i++) ts64(out, 8*i, hh[i], hl[i]);\n\n return 0;\n}\n\nfunction add(p, q) {\n var a = gf(), b = gf(), c = gf(),\n d = gf(), e = gf(), f = gf(),\n g = gf(), h = gf(), t = gf();\n\n Z(a, p[1], p[0]);\n Z(t, q[1], q[0]);\n M(a, a, t);\n A(b, p[0], p[1]);\n A(t, q[0], q[1]);\n M(b, b, t);\n M(c, p[3], q[3]);\n M(c, c, D2);\n M(d, p[2], q[2]);\n A(d, d, d);\n Z(e, b, a);\n Z(f, d, c);\n A(g, d, c);\n A(h, b, a);\n\n M(p[0], e, f);\n M(p[1], h, g);\n M(p[2], g, f);\n M(p[3], e, h);\n}\n\nfunction cswap(p, q, b) {\n var i;\n for (i = 0; i < 4; i++) {\n sel25519(p[i], q[i], b);\n }\n}\n\nfunction pack(r, p) {\n var tx = gf(), ty = gf(), zi = gf();\n inv25519(zi, p[2]);\n M(tx, p[0], zi);\n M(ty, p[1], zi);\n pack25519(r, ty);\n r[31] ^= par25519(tx) << 7;\n}\n\nfunction scalarmult(p, q, s) {\n var b, i;\n set25519(p[0], gf0);\n set25519(p[1], gf1);\n set25519(p[2], gf1);\n set25519(p[3], gf0);\n for (i = 255; i >= 0; --i) {\n b = (s[(i/8)|0] >> (i&7)) & 1;\n cswap(p, q, b);\n add(q, p);\n add(p, p);\n cswap(p, q, b);\n }\n}\n\nfunction scalarbase(p, s) {\n var q = [gf(), gf(), gf(), gf()];\n set25519(q[0], X);\n set25519(q[1], Y);\n set25519(q[2], gf1);\n M(q[3], X, Y);\n scalarmult(p, q, s);\n}\n\nfunction crypto_sign_keypair(pk, sk, seeded) {\n var d = new Uint8Array(64);\n var p = [gf(), gf(), gf(), gf()];\n var i;\n\n if (!seeded) randombytes(sk, 32);\n crypto_hash(d, sk, 32);\n d[0] &= 248;\n d[31] &= 127;\n d[31] |= 64;\n\n scalarbase(p, d);\n pack(pk, p);\n\n for (i = 0; i < 32; i++) sk[i+32] = pk[i];\n return 0;\n}\n\nvar L = new Float64Array([0xed, 0xd3, 0xf5, 0x5c, 0x1a, 0x63, 0x12, 0x58, 0xd6, 0x9c, 0xf7, 0xa2, 0xde, 0xf9, 0xde, 0x14, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x10]);\n\nfunction modL(r, x) {\n var carry, i, j, k;\n for (i = 63; i >= 32; --i) {\n carry = 0;\n for (j = i - 32, k = i - 12; j < k; ++j) {\n x[j] += carry - 16 * x[i] * L[j - (i - 32)];\n carry = Math.floor((x[j] + 128) / 256);\n x[j] -= carry * 256;\n }\n x[j] += carry;\n x[i] = 0;\n }\n carry = 0;\n for (j = 0; j < 32; j++) {\n x[j] += carry - (x[31] >> 4) * L[j];\n carry = x[j] >> 8;\n x[j] &= 255;\n }\n for (j = 0; j < 32; j++) x[j] -= carry * L[j];\n for (i = 0; i < 32; i++) {\n x[i+1] += x[i] >> 8;\n r[i] = x[i] & 255;\n }\n}\n\nfunction reduce(r) {\n var x = new Float64Array(64), i;\n for (i = 0; i < 64; i++) x[i] = r[i];\n for (i = 0; i < 64; i++) r[i] = 0;\n modL(r, x);\n}\n\n// Note: difference from C - smlen returned, not passed as argument.\nfunction crypto_sign(sm, m, n, sk) {\n var d = new Uint8Array(64), h = new Uint8Array(64), r = new Uint8Array(64);\n var i, j, x = new Float64Array(64);\n var p = [gf(), gf(), gf(), gf()];\n\n crypto_hash(d, sk, 32);\n d[0] &= 248;\n d[31] &= 127;\n d[31] |= 64;\n\n var smlen = n + 64;\n for (i = 0; i < n; i++) sm[64 + i] = m[i];\n for (i = 0; i < 32; i++) sm[32 + i] = d[32 + i];\n\n crypto_hash(r, sm.subarray(32), n+32);\n reduce(r);\n scalarbase(p, r);\n pack(sm, p);\n\n for (i = 32; i < 64; i++) sm[i] = sk[i];\n crypto_hash(h, sm, n + 64);\n reduce(h);\n\n for (i = 0; i < 64; i++) x[i] = 0;\n for (i = 0; i < 32; i++) x[i] = r[i];\n for (i = 0; i < 32; i++) {\n for (j = 0; j < 32; j++) {\n x[i+j] += h[i] * d[j];\n }\n }\n\n modL(sm.subarray(32), x);\n return smlen;\n}\n\nfunction unpackneg(r, p) {\n var t = gf(), chk = gf(), num = gf(),\n den = gf(), den2 = gf(), den4 = gf(),\n den6 = gf();\n\n set25519(r[2], gf1);\n unpack25519(r[1], p);\n S(num, r[1]);\n M(den, num, D);\n Z(num, num, r[2]);\n A(den, r[2], den);\n\n S(den2, den);\n S(den4, den2);\n M(den6, den4, den2);\n M(t, den6, num);\n M(t, t, den);\n\n pow2523(t, t);\n M(t, t, num);\n M(t, t, den);\n M(t, t, den);\n M(r[0], t, den);\n\n S(chk, r[0]);\n M(chk, chk, den);\n if (neq25519(chk, num)) M(r[0], r[0], I);\n\n S(chk, r[0]);\n M(chk, chk, den);\n if (neq25519(chk, num)) return -1;\n\n if (par25519(r[0]) === (p[31]>>7)) Z(r[0], gf0, r[0]);\n\n M(r[3], r[0], r[1]);\n return 0;\n}\n\nfunction crypto_sign_open(m, sm, n, pk) {\n var i;\n var t = new Uint8Array(32), h = new Uint8Array(64);\n var p = [gf(), gf(), gf(), gf()],\n q = [gf(), gf(), gf(), gf()];\n\n if (n < 64) return -1;\n\n if (unpackneg(q, pk)) return -1;\n\n for (i = 0; i < n; i++) m[i] = sm[i];\n for (i = 0; i < 32; i++) m[i+32] = pk[i];\n crypto_hash(h, m, n);\n reduce(h);\n scalarmult(p, q, h);\n\n scalarbase(q, sm.subarray(32));\n add(p, q);\n pack(t, p);\n\n n -= 64;\n if (crypto_verify_32(sm, 0, t, 0)) {\n for (i = 0; i < n; i++) m[i] = 0;\n return -1;\n }\n\n for (i = 0; i < n; i++) m[i] = sm[i + 64];\n return n;\n}\n\nvar crypto_secretbox_KEYBYTES = 32,\n crypto_secretbox_NONCEBYTES = 24,\n crypto_secretbox_ZEROBYTES = 32,\n crypto_secretbox_BOXZEROBYTES = 16,\n crypto_scalarmult_BYTES = 32,\n crypto_scalarmult_SCALARBYTES = 32,\n crypto_box_PUBLICKEYBYTES = 32,\n crypto_box_SECRETKEYBYTES = 32,\n crypto_box_BEFORENMBYTES = 32,\n crypto_box_NONCEBYTES = crypto_secretbox_NONCEBYTES,\n crypto_box_ZEROBYTES = crypto_secretbox_ZEROBYTES,\n crypto_box_BOXZEROBYTES = crypto_secretbox_BOXZEROBYTES,\n crypto_sign_BYTES = 64,\n crypto_sign_PUBLICKEYBYTES = 32,\n crypto_sign_SECRETKEYBYTES = 64,\n crypto_sign_SEEDBYTES = 32,\n crypto_hash_BYTES = 64;\n\nnacl.lowlevel = {\n crypto_core_hsalsa20: crypto_core_hsalsa20,\n crypto_stream_xor: crypto_stream_xor,\n crypto_stream: crypto_stream,\n crypto_stream_salsa20_xor: crypto_stream_salsa20_xor,\n crypto_stream_salsa20: crypto_stream_salsa20,\n crypto_onetimeauth: crypto_onetimeauth,\n crypto_onetimeauth_verify: crypto_onetimeauth_verify,\n crypto_verify_16: crypto_verify_16,\n crypto_verify_32: crypto_verify_32,\n crypto_secretbox: crypto_secretbox,\n crypto_secretbox_open: crypto_secretbox_open,\n crypto_scalarmult: crypto_scalarmult,\n crypto_scalarmult_base: crypto_scalarmult_base,\n crypto_box_beforenm: crypto_box_beforenm,\n crypto_box_afternm: crypto_box_afternm,\n crypto_box: crypto_box,\n crypto_box_open: crypto_box_open,\n crypto_box_keypair: crypto_box_keypair,\n crypto_hash: crypto_hash,\n crypto_sign: crypto_sign,\n crypto_sign_keypair: crypto_sign_keypair,\n crypto_sign_open: crypto_sign_open,\n\n crypto_secretbox_KEYBYTES: crypto_secretbox_KEYBYTES,\n crypto_secretbox_NONCEBYTES: crypto_secretbox_NONCEBYTES,\n crypto_secretbox_ZEROBYTES: crypto_secretbox_ZEROBYTES,\n crypto_secretbox_BOXZEROBYTES: crypto_secretbox_BOXZEROBYTES,\n crypto_scalarmult_BYTES: crypto_scalarmult_BYTES,\n crypto_scalarmult_SCALARBYTES: crypto_scalarmult_SCALARBYTES,\n crypto_box_PUBLICKEYBYTES: crypto_box_PUBLICKEYBYTES,\n crypto_box_SECRETKEYBYTES: crypto_box_SECRETKEYBYTES,\n crypto_box_BEFORENMBYTES: crypto_box_BEFORENMBYTES,\n crypto_box_NONCEBYTES: crypto_box_NONCEBYTES,\n crypto_box_ZEROBYTES: crypto_box_ZEROBYTES,\n crypto_box_BOXZEROBYTES: crypto_box_BOXZEROBYTES,\n crypto_sign_BYTES: crypto_sign_BYTES,\n crypto_sign_PUBLICKEYBYTES: crypto_sign_PUBLICKEYBYTES,\n crypto_sign_SECRETKEYBYTES: crypto_sign_SECRETKEYBYTES,\n crypto_sign_SEEDBYTES: crypto_sign_SEEDBYTES,\n crypto_hash_BYTES: crypto_hash_BYTES,\n\n gf: gf,\n D: D,\n L: L,\n pack25519: pack25519,\n unpack25519: unpack25519,\n M: M,\n A: A,\n S: S,\n Z: Z,\n pow2523: pow2523,\n add: add,\n set25519: set25519,\n modL: modL,\n scalarmult: scalarmult,\n scalarbase: scalarbase,\n};\n\n/* High-level API */\n\nfunction checkLengths(k, n) {\n if (k.length !== crypto_secretbox_KEYBYTES) throw new Error('bad key size');\n if (n.length !== crypto_secretbox_NONCEBYTES) throw new Error('bad nonce size');\n}\n\nfunction checkBoxLengths(pk, sk) {\n if (pk.length !== crypto_box_PUBLICKEYBYTES) throw new Error('bad public key size');\n if (sk.length !== crypto_box_SECRETKEYBYTES) throw new Error('bad secret key size');\n}\n\nfunction checkArrayTypes() {\n for (var i = 0; i < arguments.length; i++) {\n if (!(arguments[i] instanceof Uint8Array))\n throw new TypeError('unexpected type, use Uint8Array');\n }\n}\n\nfunction cleanup(arr) {\n for (var i = 0; i < arr.length; i++) arr[i] = 0;\n}\n\nnacl.randomBytes = function(n) {\n var b = new Uint8Array(n);\n randombytes(b, n);\n return b;\n};\n\nnacl.secretbox = function(msg, nonce, key) {\n checkArrayTypes(msg, nonce, key);\n checkLengths(key, nonce);\n var m = new Uint8Array(crypto_secretbox_ZEROBYTES + msg.length);\n var c = new Uint8Array(m.length);\n for (var i = 0; i < msg.length; i++) m[i+crypto_secretbox_ZEROBYTES] = msg[i];\n crypto_secretbox(c, m, m.length, nonce, key);\n return c.subarray(crypto_secretbox_BOXZEROBYTES);\n};\n\nnacl.secretbox.open = function(box, nonce, key) {\n checkArrayTypes(box, nonce, key);\n checkLengths(key, nonce);\n var c = new Uint8Array(crypto_secretbox_BOXZEROBYTES + box.length);\n var m = new Uint8Array(c.length);\n for (var i = 0; i < box.length; i++) c[i+crypto_secretbox_BOXZEROBYTES] = box[i];\n if (c.length < 32) return null;\n if (crypto_secretbox_open(m, c, c.length, nonce, key) !== 0) return null;\n return m.subarray(crypto_secretbox_ZEROBYTES);\n};\n\nnacl.secretbox.keyLength = crypto_secretbox_KEYBYTES;\nnacl.secretbox.nonceLength = crypto_secretbox_NONCEBYTES;\nnacl.secretbox.overheadLength = crypto_secretbox_BOXZEROBYTES;\n\nnacl.scalarMult = function(n, p) {\n checkArrayTypes(n, p);\n if (n.length !== crypto_scalarmult_SCALARBYTES) throw new Error('bad n size');\n if (p.length !== crypto_scalarmult_BYTES) throw new Error('bad p size');\n var q = new Uint8Array(crypto_scalarmult_BYTES);\n crypto_scalarmult(q, n, p);\n return q;\n};\n\nnacl.scalarMult.base = function(n) {\n checkArrayTypes(n);\n if (n.length !== crypto_scalarmult_SCALARBYTES) throw new Error('bad n size');\n var q = new Uint8Array(crypto_scalarmult_BYTES);\n crypto_scalarmult_base(q, n);\n return q;\n};\n\nnacl.scalarMult.scalarLength = crypto_scalarmult_SCALARBYTES;\nnacl.scalarMult.groupElementLength = crypto_scalarmult_BYTES;\n\nnacl.box = function(msg, nonce, publicKey, secretKey) {\n var k = nacl.box.before(publicKey, secretKey);\n return nacl.secretbox(msg, nonce, k);\n};\n\nnacl.box.before = function(publicKey, secretKey) {\n checkArrayTypes(publicKey, secretKey);\n checkBoxLengths(publicKey, secretKey);\n var k = new Uint8Array(crypto_box_BEFORENMBYTES);\n crypto_box_beforenm(k, publicKey, secretKey);\n return k;\n};\n\nnacl.box.after = nacl.secretbox;\n\nnacl.box.open = function(msg, nonce, publicKey, secretKey) {\n var k = nacl.box.before(publicKey, secretKey);\n return nacl.secretbox.open(msg, nonce, k);\n};\n\nnacl.box.open.after = nacl.secretbox.open;\n\nnacl.box.keyPair = function() {\n var pk = new Uint8Array(crypto_box_PUBLICKEYBYTES);\n var sk = new Uint8Array(crypto_box_SECRETKEYBYTES);\n crypto_box_keypair(pk, sk);\n return {publicKey: pk, secretKey: sk};\n};\n\nnacl.box.keyPair.fromSecretKey = function(secretKey) {\n checkArrayTypes(secretKey);\n if (secretKey.length !== crypto_box_SECRETKEYBYTES)\n throw new Error('bad secret key size');\n var pk = new Uint8Array(crypto_box_PUBLICKEYBYTES);\n crypto_scalarmult_base(pk, secretKey);\n return {publicKey: pk, secretKey: new Uint8Array(secretKey)};\n};\n\nnacl.box.publicKeyLength = crypto_box_PUBLICKEYBYTES;\nnacl.box.secretKeyLength = crypto_box_SECRETKEYBYTES;\nnacl.box.sharedKeyLength = crypto_box_BEFORENMBYTES;\nnacl.box.nonceLength = crypto_box_NONCEBYTES;\nnacl.box.overheadLength = nacl.secretbox.overheadLength;\n\nnacl.sign = function(msg, secretKey) {\n checkArrayTypes(msg, secretKey);\n if (secretKey.length !== crypto_sign_SECRETKEYBYTES)\n throw new Error('bad secret key size');\n var signedMsg = new Uint8Array(crypto_sign_BYTES+msg.length);\n crypto_sign(signedMsg, msg, msg.length, secretKey);\n return signedMsg;\n};\n\nnacl.sign.open = function(signedMsg, publicKey) {\n checkArrayTypes(signedMsg, publicKey);\n if (publicKey.length !== crypto_sign_PUBLICKEYBYTES)\n throw new Error('bad public key size');\n var tmp = new Uint8Array(signedMsg.length);\n var mlen = crypto_sign_open(tmp, signedMsg, signedMsg.length, publicKey);\n if (mlen < 0) return null;\n var m = new Uint8Array(mlen);\n for (var i = 0; i < m.length; i++) m[i] = tmp[i];\n return m;\n};\n\nnacl.sign.detached = function(msg, secretKey) {\n var signedMsg = nacl.sign(msg, secretKey);\n var sig = new Uint8Array(crypto_sign_BYTES);\n for (var i = 0; i < sig.length; i++) sig[i] = signedMsg[i];\n return sig;\n};\n\nnacl.sign.detached.verify = function(msg, sig, publicKey) {\n checkArrayTypes(msg, sig, publicKey);\n if (sig.length !== crypto_sign_BYTES)\n throw new Error('bad signature size');\n if (publicKey.length !== crypto_sign_PUBLICKEYBYTES)\n throw new Error('bad public key size');\n var sm = new Uint8Array(crypto_sign_BYTES + msg.length);\n var m = new Uint8Array(crypto_sign_BYTES + msg.length);\n var i;\n for (i = 0; i < crypto_sign_BYTES; i++) sm[i] = sig[i];\n for (i = 0; i < msg.length; i++) sm[i+crypto_sign_BYTES] = msg[i];\n return (crypto_sign_open(m, sm, sm.length, publicKey) >= 0);\n};\n\nnacl.sign.keyPair = function() {\n var pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);\n var sk = new Uint8Array(crypto_sign_SECRETKEYBYTES);\n crypto_sign_keypair(pk, sk);\n return {publicKey: pk, secretKey: sk};\n};\n\nnacl.sign.keyPair.fromSecretKey = function(secretKey) {\n checkArrayTypes(secretKey);\n if (secretKey.length !== crypto_sign_SECRETKEYBYTES)\n throw new Error('bad secret key size');\n var pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);\n for (var i = 0; i < pk.length; i++) pk[i] = secretKey[32+i];\n return {publicKey: pk, secretKey: new Uint8Array(secretKey)};\n};\n\nnacl.sign.keyPair.fromSeed = function(seed) {\n checkArrayTypes(seed);\n if (seed.length !== crypto_sign_SEEDBYTES)\n throw new Error('bad seed size');\n var pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);\n var sk = new Uint8Array(crypto_sign_SECRETKEYBYTES);\n for (var i = 0; i < 32; i++) sk[i] = seed[i];\n crypto_sign_keypair(pk, sk, true);\n return {publicKey: pk, secretKey: sk};\n};\n\nnacl.sign.publicKeyLength = crypto_sign_PUBLICKEYBYTES;\nnacl.sign.secretKeyLength = crypto_sign_SECRETKEYBYTES;\nnacl.sign.seedLength = crypto_sign_SEEDBYTES;\nnacl.sign.signatureLength = crypto_sign_BYTES;\n\nnacl.hash = function(msg) {\n checkArrayTypes(msg);\n var h = new Uint8Array(crypto_hash_BYTES);\n crypto_hash(h, msg, msg.length);\n return h;\n};\n\nnacl.hash.hashLength = crypto_hash_BYTES;\n\nnacl.verify = function(x, y) {\n checkArrayTypes(x, y);\n // Zero length arguments are considered not equal.\n if (x.length === 0 || y.length === 0) return false;\n if (x.length !== y.length) return false;\n return (vn(x, 0, y, 0, x.length) === 0) ? true : false;\n};\n\nnacl.setPRNG = function(fn) {\n randombytes = fn;\n};\n\n(function() {\n // Initialize PRNG if environment provides CSPRNG.\n // If not, methods calling randombytes will throw.\n var crypto = typeof self !== 'undefined' ? (self.crypto || self.msCrypto) : null;\n if (crypto && crypto.getRandomValues) {\n // Browsers.\n var QUOTA = 65536;\n nacl.setPRNG(function(x, n) {\n var i, v = new Uint8Array(n);\n for (i = 0; i < n; i += QUOTA) {\n crypto.getRandomValues(v.subarray(i, i + Math.min(n - i, QUOTA)));\n }\n for (i = 0; i < n; i++) x[i] = v[i];\n cleanup(v);\n });\n } else if (typeof require !== 'undefined') {\n // Node.js.\n crypto = require('crypto');\n if (crypto && crypto.randomBytes) {\n nacl.setPRNG(function(x, n) {\n var i, v = crypto.randomBytes(n);\n for (i = 0; i < n; i++) x[i] = v[i];\n cleanup(v);\n });\n }\n }\n})();\n\n})(typeof module !== 'undefined' && module.exports ? module.exports : (self.nacl = self.nacl || {}));\n","module.exports = require('./pusher-with-encryption').default;\n","/* (ignored) */","export default function encode(s: any): string {\n return btoa(utob(s));\n}\n\nvar fromCharCode = String.fromCharCode;\n\nvar b64chars =\n 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';\nvar b64tab = {};\n\nfor (var i = 0, l = b64chars.length; i < l; i++) {\n b64tab[b64chars.charAt(i)] = i;\n}\n\nvar cb_utob = function(c) {\n var cc = c.charCodeAt(0);\n return cc < 0x80\n ? c\n : cc < 0x800\n ? fromCharCode(0xc0 | (cc >>> 6)) + fromCharCode(0x80 | (cc & 0x3f))\n : fromCharCode(0xe0 | ((cc >>> 12) & 0x0f)) +\n fromCharCode(0x80 | ((cc >>> 6) & 0x3f)) +\n fromCharCode(0x80 | (cc & 0x3f));\n};\n\nvar utob = function(u) {\n return u.replace(/[^\\x00-\\x7F]/g, cb_utob);\n};\n\nvar cb_encode = function(ccc) {\n var padlen = [0, 2, 1][ccc.length % 3];\n var ord =\n (ccc.charCodeAt(0) << 16) |\n ((ccc.length > 1 ? ccc.charCodeAt(1) : 0) << 8) |\n (ccc.length > 2 ? ccc.charCodeAt(2) : 0);\n var chars = [\n b64chars.charAt(ord >>> 18),\n b64chars.charAt((ord >>> 12) & 63),\n padlen >= 2 ? '=' : b64chars.charAt((ord >>> 6) & 63),\n padlen >= 1 ? '=' : b64chars.charAt(ord & 63)\n ];\n return chars.join('');\n};\n\nvar btoa =\n global.btoa ||\n function(b) {\n return b.replace(/[\\s\\S]{1,3}/g, cb_encode);\n };\n","import TimedCallback from './timed_callback';\nimport { Delay, Scheduler, Canceller } from './scheduling';\n\nabstract class Timer {\n protected clear: Canceller;\n protected timer: number | void;\n\n constructor(\n set: Scheduler,\n clear: Canceller,\n delay: Delay,\n callback: TimedCallback\n ) {\n this.clear = clear;\n this.timer = set(() => {\n if (this.timer) {\n this.timer = callback(this.timer);\n }\n }, delay);\n }\n\n /** Returns whether the timer is still running.\n *\n * @return {Boolean}\n */\n isRunning(): boolean {\n return this.timer !== null;\n }\n\n /** Aborts a timer when it's running. */\n ensureAborted() {\n if (this.timer) {\n this.clear(this.timer);\n this.timer = null;\n }\n }\n}\n\nexport default Timer;\n","import Timer from './abstract_timer';\nimport TimedCallback from './timed_callback';\nimport { Delay } from './scheduling';\n\n// We need to bind clear functions this way to avoid exceptions on IE8\nfunction clearTimeout(timer) {\n global.clearTimeout(timer);\n}\nfunction clearInterval(timer) {\n global.clearInterval(timer);\n}\n\n/** Cross-browser compatible one-off timer abstraction.\n *\n * @param {Number} delay\n * @param {Function} callback\n */\nexport class OneOffTimer extends Timer {\n constructor(delay: Delay, callback: TimedCallback) {\n super(setTimeout, clearTimeout, delay, function(timer) {\n callback();\n return null;\n });\n }\n}\n\n/** Cross-browser compatible periodic timer abstraction.\n *\n * @param {Number} delay\n * @param {Function} callback\n */\nexport class PeriodicTimer extends Timer {\n constructor(delay: Delay, callback: TimedCallback) {\n super(setInterval, clearInterval, delay, function(timer) {\n callback();\n return timer;\n });\n }\n}\n","import * as Collections from './utils/collections';\nimport TimedCallback from './utils/timers/timed_callback';\nimport { OneOffTimer, PeriodicTimer } from './utils/timers';\n\nvar Util = {\n now(): number {\n if (Date.now) {\n return Date.now();\n } else {\n return new Date().valueOf();\n }\n },\n\n defer(callback: TimedCallback): OneOffTimer {\n return new OneOffTimer(0, callback);\n },\n\n /** Builds a function that will proxy a method call to its first argument.\n *\n * Allows partial application of arguments, so additional arguments are\n * prepended to the argument list.\n *\n * @param {String} name method name\n * @return {Function} proxy function\n */\n method(name: string, ...args: any[]): Function {\n var boundArguments = Array.prototype.slice.call(arguments, 1);\n return function(object) {\n return object[name].apply(object, boundArguments.concat(arguments));\n };\n }\n};\n\nexport default Util;\n","import base64encode from '../base64';\nimport Util from '../util';\n\n/** Merges multiple objects into the target argument.\n *\n * For properties that are plain Objects, performs a deep-merge. For the\n * rest it just copies the value of the property.\n *\n * To extend prototypes use it as following:\n * Pusher.Util.extend(Target.prototype, Base.prototype)\n *\n * You can also use it to merge objects without altering them:\n * Pusher.Util.extend({}, object1, object2)\n *\n * @param {Object} target\n * @return {Object} the target argument\n */\nexport function extend(target: any, ...sources: any[]): T {\n for (var i = 0; i < sources.length; i++) {\n var extensions = sources[i];\n for (var property in extensions) {\n if (\n extensions[property] &&\n extensions[property].constructor &&\n extensions[property].constructor === Object\n ) {\n target[property] = extend(target[property] || {}, extensions[property]);\n } else {\n target[property] = extensions[property];\n }\n }\n }\n return target;\n}\n\nexport function stringify(): string {\n var m = ['Pusher'];\n for (var i = 0; i < arguments.length; i++) {\n if (typeof arguments[i] === 'string') {\n m.push(arguments[i]);\n } else {\n m.push(safeJSONStringify(arguments[i]));\n }\n }\n return m.join(' : ');\n}\n\nexport function arrayIndexOf(array: any[], item: any): number {\n // MSIE doesn't have array.indexOf\n var nativeIndexOf = Array.prototype.indexOf;\n if (array === null) {\n return -1;\n }\n if (nativeIndexOf && array.indexOf === nativeIndexOf) {\n return array.indexOf(item);\n }\n for (var i = 0, l = array.length; i < l; i++) {\n if (array[i] === item) {\n return i;\n }\n }\n return -1;\n}\n\n/** Applies a function f to all properties of an object.\n *\n * Function f gets 3 arguments passed:\n * - element from the object\n * - key of the element\n * - reference to the object\n *\n * @param {Object} object\n * @param {Function} f\n */\nexport function objectApply(object: any, f: Function) {\n for (var key in object) {\n if (Object.prototype.hasOwnProperty.call(object, key)) {\n f(object[key], key, object);\n }\n }\n}\n\n/** Return a list of objects own proerty keys\n *\n * @param {Object} object\n * @returns {Array}\n */\nexport function keys(object: any): string[] {\n var keys = [];\n objectApply(object, function(_, key) {\n keys.push(key);\n });\n return keys;\n}\n\n/** Return a list of object's own property values\n *\n * @param {Object} object\n * @returns {Array}\n */\nexport function values(object: any): any[] {\n var values = [];\n objectApply(object, function(value) {\n values.push(value);\n });\n return values;\n}\n\n/** Applies a function f to all elements of an array.\n *\n * Function f gets 3 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function apply(array: any[], f: Function, context?: any) {\n for (var i = 0; i < array.length; i++) {\n f.call(context || global, array[i], i, array);\n }\n}\n\n/** Maps all elements of the array and returns the result.\n *\n * Function f gets 4 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n * - reference to the destination array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function map(array: any[], f: Function): any[] {\n var result = [];\n for (var i = 0; i < array.length; i++) {\n result.push(f(array[i], i, array, result));\n }\n return result;\n}\n\n/** Maps all elements of the object and returns the result.\n *\n * Function f gets 4 arguments passed:\n * - element from the object\n * - key of the element\n * - reference to the source object\n * - reference to the destination object\n *\n * @param {Object} object\n * @param {Function} f\n */\nexport function mapObject(object: any, f: Function): any {\n var result = {};\n objectApply(object, function(value, key) {\n result[key] = f(value);\n });\n return result;\n}\n\n/** Filters elements of the array using a test function.\n *\n * Function test gets 4 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n * - reference to the destination array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function filter(array: any[], test: Function): any[] {\n test =\n test ||\n function(value) {\n return !!value;\n };\n\n var result = [];\n for (var i = 0; i < array.length; i++) {\n if (test(array[i], i, array, result)) {\n result.push(array[i]);\n }\n }\n return result;\n}\n\n/** Filters properties of the object using a test function.\n *\n * Function test gets 4 arguments passed:\n * - element from the object\n * - key of the element\n * - reference to the source object\n * - reference to the destination object\n *\n * @param {Object} object\n * @param {Function} f\n */\nexport function filterObject(object: Object, test: Function) {\n var result = {};\n objectApply(object, function(value, key) {\n if ((test && test(value, key, object, result)) || Boolean(value)) {\n result[key] = value;\n }\n });\n return result;\n}\n\n/** Flattens an object into a two-dimensional array.\n *\n * @param {Object} object\n * @return {Array} resulting array of [key, value] pairs\n */\nexport function flatten(object: Object): any[] {\n var result = [];\n objectApply(object, function(value, key) {\n result.push([key, value]);\n });\n return result;\n}\n\n/** Checks whether any element of the array passes the test.\n *\n * Function test gets 3 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function any(array: any[], test: Function): boolean {\n for (var i = 0; i < array.length; i++) {\n if (test(array[i], i, array)) {\n return true;\n }\n }\n return false;\n}\n\n/** Checks whether all elements of the array pass the test.\n *\n * Function test gets 3 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function all(array: any[], test: Function): boolean {\n for (var i = 0; i < array.length; i++) {\n if (!test(array[i], i, array)) {\n return false;\n }\n }\n return true;\n}\n\nexport function encodeParamsObject(data): string {\n return mapObject(data, function(value) {\n if (typeof value === 'object') {\n value = safeJSONStringify(value);\n }\n return encodeURIComponent(base64encode(value.toString()));\n });\n}\n\nexport function buildQueryString(data: any): string {\n var params = filterObject(data, function(value) {\n return value !== undefined;\n });\n\n var query = map(\n flatten(encodeParamsObject(params)),\n Util.method('join', '=')\n ).join('&');\n\n return query;\n}\n\n/**\n * See https://github.com/douglascrockford/JSON-js/blob/master/cycle.js\n *\n * Remove circular references from an object. Required for JSON.stringify in\n * React Native, which tends to blow up a lot.\n *\n * @param {any} object\n * @return {any} Decycled object\n */\nexport function decycleObject(object: any): any {\n var objects = [],\n paths = [];\n\n return (function derez(value, path) {\n var i, name, nu;\n\n switch (typeof value) {\n case 'object':\n if (!value) {\n return null;\n }\n for (i = 0; i < objects.length; i += 1) {\n if (objects[i] === value) {\n return { $ref: paths[i] };\n }\n }\n\n objects.push(value);\n paths.push(path);\n\n if (Object.prototype.toString.apply(value) === '[object Array]') {\n nu = [];\n for (i = 0; i < value.length; i += 1) {\n nu[i] = derez(value[i], path + '[' + i + ']');\n }\n } else {\n nu = {};\n for (name in value) {\n if (Object.prototype.hasOwnProperty.call(value, name)) {\n nu[name] = derez(\n value[name],\n path + '[' + JSON.stringify(name) + ']'\n );\n }\n }\n }\n return nu;\n case 'number':\n case 'string':\n case 'boolean':\n return value;\n }\n })(object, '$');\n}\n\n/**\n * Provides a cross-browser and cross-platform way to safely stringify objects\n * into JSON. This is particularly necessary for ReactNative, where circular JSON\n * structures throw an exception.\n *\n * @param {any} source The object to stringify\n * @return {string} The serialized output.\n */\nexport function safeJSONStringify(source: any): string {\n try {\n return JSON.stringify(source);\n } catch (e) {\n return JSON.stringify(decycleObject(source));\n }\n}\n","import {\n ChannelAuthorizationOptions,\n UserAuthenticationOptions\n} from './auth/options';\nimport { AuthTransport } from './config';\n\nexport interface DefaultConfig {\n VERSION: string;\n PROTOCOL: number;\n wsPort: number;\n wssPort: number;\n wsPath: string;\n httpHost: string;\n httpPort: number;\n httpsPort: number;\n httpPath: string;\n stats_host: string;\n authEndpoint: string;\n authTransport: AuthTransport;\n activityTimeout: number;\n pongTimeout: number;\n unavailableTimeout: number;\n userAuthentication: UserAuthenticationOptions;\n channelAuthorization: ChannelAuthorizationOptions;\n\n cdn_http?: string;\n cdn_https?: string;\n dependency_suffix?: string;\n}\n\nvar Defaults: DefaultConfig = {\n VERSION: VERSION,\n PROTOCOL: 7,\n\n wsPort: 80,\n wssPort: 443,\n wsPath: '',\n // DEPRECATED: SockJS fallback parameters\n httpHost: 'sockjs.pusher.com',\n httpPort: 80,\n httpsPort: 443,\n httpPath: '/pusher',\n // DEPRECATED: Stats\n stats_host: 'stats.pusher.com',\n // DEPRECATED: Other settings\n authEndpoint: '/pusher/auth',\n authTransport: 'ajax',\n activityTimeout: 120000,\n pongTimeout: 30000,\n unavailableTimeout: 10000,\n userAuthentication: {\n endpoint: '/pusher/user-auth',\n transport: 'ajax'\n },\n channelAuthorization: {\n endpoint: '/pusher/auth',\n transport: 'ajax'\n },\n\n // CDN configuration\n cdn_http: CDN_HTTP,\n cdn_https: CDN_HTTPS,\n dependency_suffix: DEPENDENCY_SUFFIX\n};\n\nexport default Defaults;\n","import Defaults from '../defaults';\nimport { default as URLScheme, URLSchemeParams } from './url_scheme';\n\nfunction getGenericURL(\n baseScheme: string,\n params: URLSchemeParams,\n path: string\n): string {\n var scheme = baseScheme + (params.useTLS ? 's' : '');\n var host = params.useTLS ? params.hostTLS : params.hostNonTLS;\n return scheme + '://' + host + path;\n}\n\nfunction getGenericPath(key: string, queryString?: string): string {\n var path = '/app/' + key;\n var query =\n '?protocol=' +\n Defaults.PROTOCOL +\n '&client=js' +\n '&version=' +\n Defaults.VERSION +\n (queryString ? '&' + queryString : '');\n return path + query;\n}\n\nexport var ws: URLScheme = {\n getInitial: function(key: string, params: URLSchemeParams): string {\n var path = (params.httpPath || '') + getGenericPath(key, 'flash=false');\n return getGenericURL('ws', params, path);\n }\n};\n\nexport var http: URLScheme = {\n getInitial: function(key: string, params: URLSchemeParams): string {\n var path = (params.httpPath || '/pusher') + getGenericPath(key);\n return getGenericURL('http', params, path);\n }\n};\n\nexport var sockjs: URLScheme = {\n getInitial: function(key: string, params: URLSchemeParams): string {\n return getGenericURL('http', params, params.httpPath || '/pusher');\n },\n getPath: function(key: string, params: URLSchemeParams): string {\n return getGenericPath(key);\n }\n};\n","import Callback from './callback';\nimport * as Collections from '../utils/collections';\nimport CallbackTable from './callback_table';\n\nexport default class CallbackRegistry {\n _callbacks: CallbackTable;\n\n constructor() {\n this._callbacks = {};\n }\n\n get(name: string): Callback[] {\n return this._callbacks[prefix(name)];\n }\n\n add(name: string, callback: Function, context: any) {\n var prefixedEventName = prefix(name);\n this._callbacks[prefixedEventName] =\n this._callbacks[prefixedEventName] || [];\n this._callbacks[prefixedEventName].push({\n fn: callback,\n context: context\n });\n }\n\n remove(name?: string, callback?: Function, context?: any) {\n if (!name && !callback && !context) {\n this._callbacks = {};\n return;\n }\n\n var names = name ? [prefix(name)] : Collections.keys(this._callbacks);\n\n if (callback || context) {\n this.removeCallback(names, callback, context);\n } else {\n this.removeAllCallbacks(names);\n }\n }\n\n private removeCallback(names: string[], callback: Function, context: any) {\n Collections.apply(\n names,\n function(name) {\n this._callbacks[name] = Collections.filter(\n this._callbacks[name] || [],\n function(binding) {\n return (\n (callback && callback !== binding.fn) ||\n (context && context !== binding.context)\n );\n }\n );\n if (this._callbacks[name].length === 0) {\n delete this._callbacks[name];\n }\n },\n this\n );\n }\n\n private removeAllCallbacks(names: string[]) {\n Collections.apply(\n names,\n function(name) {\n delete this._callbacks[name];\n },\n this\n );\n }\n}\n\nfunction prefix(name: string): string {\n return '_' + name;\n}\n","import * as Collections from '../utils/collections';\nimport Callback from './callback';\nimport Metadata from '../channels/metadata';\nimport CallbackRegistry from './callback_registry';\n\n/** Manages callback bindings and event emitting.\n *\n * @param Function failThrough called when no listeners are bound to an event\n */\nexport default class Dispatcher {\n callbacks: CallbackRegistry;\n global_callbacks: Function[];\n failThrough: Function;\n\n constructor(failThrough?: Function) {\n this.callbacks = new CallbackRegistry();\n this.global_callbacks = [];\n this.failThrough = failThrough;\n }\n\n bind(eventName: string, callback: Function, context?: any) {\n this.callbacks.add(eventName, callback, context);\n return this;\n }\n\n bind_global(callback: Function) {\n this.global_callbacks.push(callback);\n return this;\n }\n\n unbind(eventName?: string, callback?: Function, context?: any) {\n this.callbacks.remove(eventName, callback, context);\n return this;\n }\n\n unbind_global(callback?: Function) {\n if (!callback) {\n this.global_callbacks = [];\n return this;\n }\n\n this.global_callbacks = Collections.filter(\n this.global_callbacks || [],\n c => c !== callback\n );\n\n return this;\n }\n\n unbind_all() {\n this.unbind();\n this.unbind_global();\n return this;\n }\n\n emit(eventName: string, data?: any, metadata?: Metadata): Dispatcher {\n for (var i = 0; i < this.global_callbacks.length; i++) {\n this.global_callbacks[i](eventName, data);\n }\n\n var callbacks = this.callbacks.get(eventName);\n var args = [];\n\n if (metadata) {\n // if there's a metadata argument, we need to call the callback with both\n // data and metadata regardless of whether data is undefined\n args.push(data, metadata);\n } else if (data) {\n // metadata is undefined, so we only need to call the callback with data\n // if data exists\n args.push(data);\n }\n\n if (callbacks && callbacks.length > 0) {\n for (var i = 0; i < callbacks.length; i++) {\n callbacks[i].fn.apply(callbacks[i].context || global, args);\n }\n } else if (this.failThrough) {\n this.failThrough(eventName, data);\n }\n\n return this;\n }\n}\n","import { stringify } from './utils/collections';\nimport Pusher from './pusher';\n\nclass Logger {\n debug(...args: any[]) {\n this.log(this.globalLog, args);\n }\n\n warn(...args: any[]) {\n this.log(this.globalLogWarn, args);\n }\n\n error(...args: any[]) {\n this.log(this.globalLogError, args);\n }\n\n private globalLog = (message: string) => {\n if (global.console && global.console.log) {\n global.console.log(message);\n }\n };\n\n private globalLogWarn(message: string) {\n if (global.console && global.console.warn) {\n global.console.warn(message);\n } else {\n this.globalLog(message);\n }\n }\n\n private globalLogError(message: string) {\n if (global.console && global.console.error) {\n global.console.error(message);\n } else {\n this.globalLogWarn(message);\n }\n }\n\n private log(\n defaultLoggingFunction: (message: string) => void,\n ...args: any[]\n ) {\n var message = stringify.apply(this, arguments);\n if (Pusher.log) {\n Pusher.log(message);\n } else if (Pusher.logToConsole) {\n const log = defaultLoggingFunction.bind(this);\n log(message);\n }\n }\n}\n\nexport default new Logger();\n","import Util from '../util';\nimport * as Collections from '../utils/collections';\nimport { default as EventsDispatcher } from '../events/dispatcher';\nimport Logger from '../logger';\nimport TransportHooks from './transport_hooks';\nimport Socket from '../socket';\nimport Runtime from 'runtime';\nimport Timeline from '../timeline/timeline';\nimport TransportConnectionOptions from './transport_connection_options';\n\n/** Provides universal API for transport connections.\n *\n * Transport connection is a low-level object that wraps a connection method\n * and exposes a simple evented interface for the connection state and\n * messaging. It does not implement Pusher-specific WebSocket protocol.\n *\n * Additionally, it fetches resources needed for transport to work and exposes\n * an interface for querying transport features.\n *\n * States:\n * - new - initial state after constructing the object\n * - initializing - during initialization phase, usually fetching resources\n * - intialized - ready to establish a connection\n * - connection - when connection is being established\n * - open - when connection ready to be used\n * - closed - after connection was closed be either side\n *\n * Emits:\n * - error - after the connection raised an error\n *\n * Options:\n * - useTLS - whether connection should be over TLS\n * - hostTLS - host to connect to when connection is over TLS\n * - hostNonTLS - host to connect to when connection is over TLS\n *\n * @param {String} key application key\n * @param {Object} options\n */\nexport default class TransportConnection extends EventsDispatcher {\n hooks: TransportHooks;\n name: string;\n priority: number;\n key: string;\n options: TransportConnectionOptions;\n state: string;\n timeline: Timeline;\n activityTimeout: number;\n id: number;\n socket: Socket;\n beforeOpen: Function;\n initialize: Function;\n\n constructor(\n hooks: TransportHooks,\n name: string,\n priority: number,\n key: string,\n options: TransportConnectionOptions\n ) {\n super();\n this.initialize = Runtime.transportConnectionInitializer;\n this.hooks = hooks;\n this.name = name;\n this.priority = priority;\n this.key = key;\n this.options = options;\n\n this.state = 'new';\n this.timeline = options.timeline;\n this.activityTimeout = options.activityTimeout;\n this.id = this.timeline.generateUniqueID();\n }\n\n /** Checks whether the transport handles activity checks by itself.\n *\n * @return {Boolean}\n */\n handlesActivityChecks(): boolean {\n return Boolean(this.hooks.handlesActivityChecks);\n }\n\n /** Checks whether the transport supports the ping/pong API.\n *\n * @return {Boolean}\n */\n supportsPing(): boolean {\n return Boolean(this.hooks.supportsPing);\n }\n\n /** Tries to establish a connection.\n *\n * @returns {Boolean} false if transport is in invalid state\n */\n connect(): boolean {\n if (this.socket || this.state !== 'initialized') {\n return false;\n }\n\n var url = this.hooks.urls.getInitial(this.key, this.options);\n try {\n this.socket = this.hooks.getSocket(url, this.options);\n } catch (e) {\n Util.defer(() => {\n this.onError(e);\n this.changeState('closed');\n });\n return false;\n }\n\n this.bindListeners();\n\n Logger.debug('Connecting', { transport: this.name, url });\n this.changeState('connecting');\n return true;\n }\n\n /** Closes the connection.\n *\n * @return {Boolean} true if there was a connection to close\n */\n close(): boolean {\n if (this.socket) {\n this.socket.close();\n return true;\n } else {\n return false;\n }\n }\n\n /** Sends data over the open connection.\n *\n * @param {String} data\n * @return {Boolean} true only when in the \"open\" state\n */\n send(data: any): boolean {\n if (this.state === 'open') {\n // Workaround for MobileSafari bug (see https://gist.github.com/2052006)\n Util.defer(() => {\n if (this.socket) {\n this.socket.send(data);\n }\n });\n return true;\n } else {\n return false;\n }\n }\n\n /** Sends a ping if the connection is open and transport supports it. */\n ping() {\n if (this.state === 'open' && this.supportsPing()) {\n this.socket.ping();\n }\n }\n\n private onOpen() {\n if (this.hooks.beforeOpen) {\n this.hooks.beforeOpen(\n this.socket,\n this.hooks.urls.getPath(this.key, this.options)\n );\n }\n this.changeState('open');\n this.socket.onopen = undefined;\n }\n\n private onError(error) {\n this.emit('error', { type: 'WebSocketError', error: error });\n this.timeline.error(this.buildTimelineMessage({ error: error.toString() }));\n }\n\n private onClose(closeEvent?: any) {\n if (closeEvent) {\n this.changeState('closed', {\n code: closeEvent.code,\n reason: closeEvent.reason,\n wasClean: closeEvent.wasClean\n });\n } else {\n this.changeState('closed');\n }\n this.unbindListeners();\n this.socket = undefined;\n }\n\n private onMessage(message) {\n this.emit('message', message);\n }\n\n private onActivity() {\n this.emit('activity');\n }\n\n private bindListeners() {\n this.socket.onopen = () => {\n this.onOpen();\n };\n this.socket.onerror = error => {\n this.onError(error);\n };\n this.socket.onclose = closeEvent => {\n this.onClose(closeEvent);\n };\n this.socket.onmessage = message => {\n this.onMessage(message);\n };\n\n if (this.supportsPing()) {\n this.socket.onactivity = () => {\n this.onActivity();\n };\n }\n }\n\n private unbindListeners() {\n if (this.socket) {\n this.socket.onopen = undefined;\n this.socket.onerror = undefined;\n this.socket.onclose = undefined;\n this.socket.onmessage = undefined;\n if (this.supportsPing()) {\n this.socket.onactivity = undefined;\n }\n }\n }\n\n private changeState(state: string, params?: any) {\n this.state = state;\n this.timeline.info(\n this.buildTimelineMessage({\n state: state,\n params: params\n })\n );\n this.emit(state, params);\n }\n\n buildTimelineMessage(message): any {\n return Collections.extend({ cid: this.id }, message);\n }\n}\n","import Factory from '../utils/factory';\nimport TransportHooks from './transport_hooks';\nimport TransportConnection from './transport_connection';\nimport TransportConnectionOptions from './transport_connection_options';\n\n/** Provides interface for transport connection instantiation.\n *\n * Takes transport-specific hooks as the only argument, which allow checking\n * for transport support and creating its connections.\n *\n * Supported hooks: * - file - the name of the file to be fetched during initialization\n * - urls - URL scheme to be used by transport\n * - handlesActivityCheck - true when the transport handles activity checks\n * - supportsPing - true when the transport has a ping/activity API\n * - isSupported - tells whether the transport is supported in the environment\n * - getSocket - creates a WebSocket-compatible transport socket\n *\n * See transports.js for specific implementations.\n *\n * @param {Object} hooks object containing all needed transport hooks\n */\nexport default class Transport {\n hooks: TransportHooks;\n\n constructor(hooks: TransportHooks) {\n this.hooks = hooks;\n }\n\n /** Returns whether the transport is supported in the environment.\n *\n * @param {Object} envronment te environment details (encryption, settings)\n * @returns {Boolean} true when the transport is supported\n */\n isSupported(environment: any): boolean {\n return this.hooks.isSupported(environment);\n }\n\n /** Creates a transport connection.\n *\n * @param {String} name\n * @param {Number} priority\n * @param {String} key the application key\n * @param {Object} options\n * @returns {TransportConnection}\n */\n createConnection(\n name: string,\n priority: number,\n key: string,\n options: any\n ): TransportConnection {\n return new TransportConnection(this.hooks, name, priority, key, options);\n }\n}\n","import * as URLSchemes from 'core/transports/url_schemes';\nimport URLScheme from 'core/transports/url_scheme';\nimport Transport from 'core/transports/transport';\nimport Util from 'core/util';\nimport * as Collections from 'core/utils/collections';\nimport TransportHooks from 'core/transports/transport_hooks';\nimport TransportsTable from 'core/transports/transports_table';\nimport Runtime from 'runtime';\n\n/** WebSocket transport.\n *\n * Uses native WebSocket implementation, including MozWebSocket supported by\n * earlier Firefox versions.\n */\nvar WSTransport = new Transport({\n urls: URLSchemes.ws,\n handlesActivityChecks: false,\n supportsPing: false,\n\n isInitialized: function() {\n return Boolean(Runtime.getWebSocketAPI());\n },\n isSupported: function(): boolean {\n return Boolean(Runtime.getWebSocketAPI());\n },\n getSocket: function(url) {\n return Runtime.createWebSocket(url);\n }\n});\n\nvar httpConfiguration = {\n urls: URLSchemes.http,\n handlesActivityChecks: false,\n supportsPing: true,\n isInitialized: function() {\n return true;\n }\n};\n\nexport var streamingConfiguration = Collections.extend(\n {\n getSocket: function(url) {\n return Runtime.HTTPFactory.createStreamingSocket(url);\n }\n },\n httpConfiguration\n);\nexport var pollingConfiguration = Collections.extend(\n {\n getSocket: function(url) {\n return Runtime.HTTPFactory.createPollingSocket(url);\n }\n },\n httpConfiguration\n);\n\nvar xhrConfiguration = {\n isSupported: function(): boolean {\n return Runtime.isXHRSupported();\n }\n};\n\n/** HTTP streaming transport using CORS-enabled XMLHttpRequest. */\nvar XHRStreamingTransport = new Transport(\n (\n Collections.extend({}, streamingConfiguration, xhrConfiguration)\n )\n);\n\n/** HTTP long-polling transport using CORS-enabled XMLHttpRequest. */\nvar XHRPollingTransport = new Transport(\n Collections.extend({}, pollingConfiguration, xhrConfiguration)\n);\n\nvar Transports: TransportsTable = {\n ws: WSTransport,\n xhr_streaming: XHRStreamingTransport,\n xhr_polling: XHRPollingTransport\n};\n\nexport default Transports;\n","import Util from '../util';\nimport * as Collections from '../utils/collections';\nimport TransportManager from './transport_manager';\nimport TransportConnection from './transport_connection';\nimport Transport from './transport';\nimport PingDelayOptions from './ping_delay_options';\n\n/** Creates transport connections monitored by a transport manager.\n *\n * When a transport is closed, it might mean the environment does not support\n * it. It's possible that messages get stuck in an intermediate buffer or\n * proxies terminate inactive connections. To combat these problems,\n * assistants monitor the connection lifetime, report unclean exits and\n * adjust ping timeouts to keep the connection active. The decision to disable\n * a transport is the manager's responsibility.\n *\n * @param {TransportManager} manager\n * @param {TransportConnection} transport\n * @param {Object} options\n */\nexport default class AssistantToTheTransportManager {\n manager: TransportManager;\n transport: Transport;\n minPingDelay: number;\n maxPingDelay: number;\n pingDelay: number;\n\n constructor(\n manager: TransportManager,\n transport: Transport,\n options: PingDelayOptions\n ) {\n this.manager = manager;\n this.transport = transport;\n this.minPingDelay = options.minPingDelay;\n this.maxPingDelay = options.maxPingDelay;\n this.pingDelay = undefined;\n }\n\n /** Creates a transport connection.\n *\n * This function has the same API as Transport#createConnection.\n *\n * @param {String} name\n * @param {Number} priority\n * @param {String} key the application key\n * @param {Object} options\n * @returns {TransportConnection}\n */\n createConnection(\n name: string,\n priority: number,\n key: string,\n options: Object\n ): TransportConnection {\n options = Collections.extend({}, options, {\n activityTimeout: this.pingDelay\n });\n var connection = this.transport.createConnection(\n name,\n priority,\n key,\n options\n );\n\n var openTimestamp = null;\n\n var onOpen = function() {\n connection.unbind('open', onOpen);\n connection.bind('closed', onClosed);\n openTimestamp = Util.now();\n };\n var onClosed = closeEvent => {\n connection.unbind('closed', onClosed);\n\n if (closeEvent.code === 1002 || closeEvent.code === 1003) {\n // we don't want to use transports not obeying the protocol\n this.manager.reportDeath();\n } else if (!closeEvent.wasClean && openTimestamp) {\n // report deaths only for short-living transport\n var lifespan = Util.now() - openTimestamp;\n if (lifespan < 2 * this.maxPingDelay) {\n this.manager.reportDeath();\n this.pingDelay = Math.max(lifespan / 2, this.minPingDelay);\n }\n }\n };\n\n connection.bind('open', onOpen);\n return connection;\n }\n\n /** Returns whether the transport is supported in the environment.\n *\n * This function has the same API as Transport#isSupported. Might return false\n * when the manager decides to kill the transport.\n *\n * @param {Object} environment the environment details (encryption, settings)\n * @returns {Boolean} true when the transport is supported\n */\n isSupported(environment: string): boolean {\n return this.manager.isAlive() && this.transport.isSupported(environment);\n }\n}\n","import Action from './action';\nimport { PusherEvent } from './message-types';\n/**\n * Provides functions for handling Pusher protocol-specific messages.\n */\n\nconst Protocol = {\n /**\n * Decodes a message in a Pusher format.\n *\n * The MessageEvent we receive from the transport should contain a pusher event\n * (https://pusher.com/docs/pusher_protocol#events) serialized as JSON in the\n * data field\n *\n * The pusher event may contain a data field too, and it may also be\n * serialised as JSON\n *\n * Throws errors when messages are not parse'able.\n *\n * @param {MessageEvent} messageEvent\n * @return {PusherEvent}\n */\n decodeMessage: function(messageEvent: MessageEvent): PusherEvent {\n try {\n var messageData = JSON.parse(messageEvent.data);\n var pusherEventData = messageData.data;\n if (typeof pusherEventData === 'string') {\n try {\n pusherEventData = JSON.parse(messageData.data);\n } catch (e) {}\n }\n var pusherEvent: PusherEvent = {\n event: messageData.event,\n channel: messageData.channel,\n data: pusherEventData\n };\n if (messageData.user_id) {\n pusherEvent.user_id = messageData.user_id;\n }\n return pusherEvent;\n } catch (e) {\n throw { type: 'MessageParseError', error: e, data: messageEvent.data };\n }\n },\n\n /**\n * Encodes a message to be sent.\n *\n * @param {PusherEvent} event\n * @return {String}\n */\n encodeMessage: function(event: PusherEvent): string {\n return JSON.stringify(event);\n },\n\n /**\n * Processes a handshake message and returns appropriate actions.\n *\n * Returns an object with an 'action' and other action-specific properties.\n *\n * There are three outcomes when calling this function. First is a successful\n * connection attempt, when pusher:connection_established is received, which\n * results in a 'connected' action with an 'id' property. When passed a\n * pusher:error event, it returns a result with action appropriate to the\n * close code and an error. Otherwise, it raises an exception.\n *\n * @param {String} message\n * @result Object\n */\n processHandshake: function(messageEvent: MessageEvent): Action {\n var message = Protocol.decodeMessage(messageEvent);\n\n if (message.event === 'pusher:connection_established') {\n if (!message.data.activity_timeout) {\n throw 'No activity timeout specified in handshake';\n }\n return {\n action: 'connected',\n id: message.data.socket_id,\n activityTimeout: message.data.activity_timeout * 1000\n };\n } else if (message.event === 'pusher:error') {\n // From protocol 6 close codes are sent only once, so this only\n // happens when connection does not support close codes\n return {\n action: this.getCloseAction(message.data),\n error: this.getCloseError(message.data)\n };\n } else {\n throw 'Invalid handshake';\n }\n },\n\n /**\n * Dispatches the close event and returns an appropriate action name.\n *\n * See:\n * 1. https://developer.mozilla.org/en-US/docs/WebSockets/WebSockets_reference/CloseEvent\n * 2. http://pusher.com/docs/pusher_protocol\n *\n * @param {CloseEvent} closeEvent\n * @return {String} close action name\n */\n getCloseAction: function(closeEvent): string {\n if (closeEvent.code < 4000) {\n // ignore 1000 CLOSE_NORMAL, 1001 CLOSE_GOING_AWAY,\n // 1005 CLOSE_NO_STATUS, 1006 CLOSE_ABNORMAL\n // ignore 1007...3999\n // handle 1002 CLOSE_PROTOCOL_ERROR, 1003 CLOSE_UNSUPPORTED,\n // 1004 CLOSE_TOO_LARGE\n if (closeEvent.code >= 1002 && closeEvent.code <= 1004) {\n return 'backoff';\n } else {\n return null;\n }\n } else if (closeEvent.code === 4000) {\n return 'tls_only';\n } else if (closeEvent.code < 4100) {\n return 'refused';\n } else if (closeEvent.code < 4200) {\n return 'backoff';\n } else if (closeEvent.code < 4300) {\n return 'retry';\n } else {\n // unknown error\n return 'refused';\n }\n },\n\n /**\n * Returns an error or null basing on the close event.\n *\n * Null is returned when connection was closed cleanly. Otherwise, an object\n * with error details is returned.\n *\n * @param {CloseEvent} closeEvent\n * @return {Object} error object\n */\n getCloseError: function(closeEvent): any {\n if (closeEvent.code !== 1000 && closeEvent.code !== 1001) {\n return {\n type: 'PusherError',\n data: {\n code: closeEvent.code,\n message: closeEvent.reason || closeEvent.message\n }\n };\n } else {\n return null;\n }\n }\n};\n\nexport default Protocol;\n","import * as Collections from '../utils/collections';\nimport { default as EventsDispatcher } from '../events/dispatcher';\nimport Protocol from './protocol/protocol';\nimport { PusherEvent } from './protocol/message-types';\nimport Logger from '../logger';\nimport TransportConnection from '../transports/transport_connection';\nimport Socket from '../socket';\n/**\n * Provides Pusher protocol interface for transports.\n *\n * Emits following events:\n * - message - on received messages\n * - ping - on ping requests\n * - pong - on pong responses\n * - error - when the transport emits an error\n * - closed - after closing the transport\n *\n * It also emits more events when connection closes with a code.\n * See Protocol.getCloseAction to get more details.\n *\n * @param {Number} id\n * @param {AbstractTransport} transport\n */\nexport default class Connection extends EventsDispatcher implements Socket {\n id: string;\n transport: TransportConnection;\n activityTimeout: number;\n\n constructor(id: string, transport: TransportConnection) {\n super();\n this.id = id;\n this.transport = transport;\n this.activityTimeout = transport.activityTimeout;\n this.bindListeners();\n }\n\n /** Returns whether used transport handles activity checks by itself\n *\n * @returns {Boolean} true if activity checks are handled by the transport\n */\n handlesActivityChecks() {\n return this.transport.handlesActivityChecks();\n }\n\n /** Sends raw data.\n *\n * @param {String} data\n */\n send(data: any): boolean {\n return this.transport.send(data);\n }\n\n /** Sends an event.\n *\n * @param {String} name\n * @param {String} data\n * @param {String} [channel]\n * @returns {Boolean} whether message was sent or not\n */\n send_event(name: string, data: any, channel?: string): boolean {\n var event: PusherEvent = { event: name, data: data };\n if (channel) {\n event.channel = channel;\n }\n Logger.debug('Event sent', event);\n return this.send(Protocol.encodeMessage(event));\n }\n\n /** Sends a ping message to the server.\n *\n * Basing on the underlying transport, it might send either transport's\n * protocol-specific ping or pusher:ping event.\n */\n ping() {\n if (this.transport.supportsPing()) {\n this.transport.ping();\n } else {\n this.send_event('pusher:ping', {});\n }\n }\n\n /** Closes the connection. */\n close() {\n this.transport.close();\n }\n\n private bindListeners() {\n var listeners = {\n message: (messageEvent: MessageEvent) => {\n var pusherEvent;\n try {\n pusherEvent = Protocol.decodeMessage(messageEvent);\n } catch (e) {\n this.emit('error', {\n type: 'MessageParseError',\n error: e,\n data: messageEvent.data\n });\n }\n\n if (pusherEvent !== undefined) {\n Logger.debug('Event recd', pusherEvent);\n\n switch (pusherEvent.event) {\n case 'pusher:error':\n this.emit('error', {\n type: 'PusherError',\n data: pusherEvent.data\n });\n break;\n case 'pusher:ping':\n this.emit('ping');\n break;\n case 'pusher:pong':\n this.emit('pong');\n break;\n }\n this.emit('message', pusherEvent);\n }\n },\n activity: () => {\n this.emit('activity');\n },\n error: error => {\n this.emit('error', error);\n },\n closed: closeEvent => {\n unbindListeners();\n\n if (closeEvent && closeEvent.code) {\n this.handleCloseEvent(closeEvent);\n }\n\n this.transport = null;\n this.emit('closed');\n }\n };\n\n var unbindListeners = () => {\n Collections.objectApply(listeners, (listener, event) => {\n this.transport.unbind(event, listener);\n });\n };\n\n Collections.objectApply(listeners, (listener, event) => {\n this.transport.bind(event, listener);\n });\n }\n\n private handleCloseEvent(closeEvent: any) {\n var action = Protocol.getCloseAction(closeEvent);\n var error = Protocol.getCloseError(closeEvent);\n if (error) {\n this.emit('error', error);\n }\n if (action) {\n this.emit(action, { action: action, error: error });\n }\n }\n}\n","import Util from '../../util';\nimport * as Collections from '../../utils/collections';\nimport Protocol from '../protocol/protocol';\nimport Connection from '../connection';\nimport TransportConnection from '../../transports/transport_connection';\nimport HandshakePayload from './handshake_payload';\n\n/**\n * Handles Pusher protocol handshakes for transports.\n *\n * Calls back with a result object after handshake is completed. Results\n * always have two fields:\n * - action - string describing action to be taken after the handshake\n * - transport - the transport object passed to the constructor\n *\n * Different actions can set different additional properties on the result.\n * In the case of 'connected' action, there will be a 'connection' property\n * containing a Connection object for the transport. Other actions should\n * carry an 'error' property.\n *\n * @param {AbstractTransport} transport\n * @param {Function} callback\n */\nexport default class Handshake {\n transport: TransportConnection;\n callback: (HandshakePayload) => void;\n onMessage: Function;\n onClosed: Function;\n\n constructor(\n transport: TransportConnection,\n callback: (HandshakePayload) => void\n ) {\n this.transport = transport;\n this.callback = callback;\n this.bindListeners();\n }\n\n close() {\n this.unbindListeners();\n this.transport.close();\n }\n\n private bindListeners() {\n this.onMessage = m => {\n this.unbindListeners();\n\n var result;\n try {\n result = Protocol.processHandshake(m);\n } catch (e) {\n this.finish('error', { error: e });\n this.transport.close();\n return;\n }\n\n if (result.action === 'connected') {\n this.finish('connected', {\n connection: new Connection(result.id, this.transport),\n activityTimeout: result.activityTimeout\n });\n } else {\n this.finish(result.action, { error: result.error });\n this.transport.close();\n }\n };\n\n this.onClosed = closeEvent => {\n this.unbindListeners();\n\n var action = Protocol.getCloseAction(closeEvent) || 'backoff';\n var error = Protocol.getCloseError(closeEvent);\n this.finish(action, { error: error });\n };\n\n this.transport.bind('message', this.onMessage);\n this.transport.bind('closed', this.onClosed);\n }\n\n private unbindListeners() {\n this.transport.unbind('message', this.onMessage);\n this.transport.unbind('closed', this.onClosed);\n }\n\n private finish(action: string, params: any) {\n this.callback(\n Collections.extend({ transport: this.transport, action: action }, params)\n );\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport base64encode from '../base64';\nimport Timeline from './timeline';\nimport Runtime from 'runtime';\n\nexport interface TimelineSenderOptions {\n host?: string;\n port?: number;\n path?: string;\n}\n\nexport default class TimelineSender {\n timeline: Timeline;\n options: TimelineSenderOptions;\n host: string;\n\n constructor(timeline: Timeline, options: TimelineSenderOptions) {\n this.timeline = timeline;\n this.options = options || {};\n }\n\n send(useTLS: boolean, callback?: Function) {\n if (this.timeline.isEmpty()) {\n return;\n }\n\n this.timeline.send(\n Runtime.TimelineTransport.getAgent(this, useTLS),\n callback\n );\n }\n}\n","/** Error classes used throughout the library. */\n// https://github.com/Microsoft/TypeScript-wiki/blob/master/Breaking-Changes.md#extending-built-ins-like-error-array-and-map-may-no-longer-work\nexport class BadEventName extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\nexport class BadChannelName extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\nexport class RequestTimedOut extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class TransportPriorityTooLow extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class TransportClosed extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class UnsupportedFeature extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class UnsupportedTransport extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class UnsupportedStrategy extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class HTTPAuthError extends Error {\n status: number;\n constructor(status: number, msg?: string) {\n super(msg);\n this.status = status;\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n","/**\n * A place to store help URLs for error messages etc\n */\n\nconst urlStore = {\n baseUrl: 'https://pusher.com',\n urls: {\n authenticationEndpoint: {\n path: '/docs/channels/server_api/authenticating_users'\n },\n authorizationEndpoint: {\n path: '/docs/channels/server_api/authorizing-users/'\n },\n javascriptQuickStart: {\n path: '/docs/javascript_quick_start'\n },\n triggeringClientEvents: {\n path: '/docs/client_api_guide/client_events#trigger-events'\n },\n encryptedChannelSupport: {\n fullUrl:\n 'https://github.com/pusher/pusher-js/tree/cc491015371a4bde5743d1c87a0fbac0feb53195#encrypted-channel-support'\n }\n }\n};\n\n/** Builds a consistent string with links to pusher documentation\n *\n * @param {string} key - relevant key in the url_store.urls object\n * @return {string} suffix string to append to log message\n */\nconst buildLogSuffix = function(key: string): string {\n const urlPrefix = 'See:';\n const urlObj = urlStore.urls[key];\n if (!urlObj) return '';\n\n let url;\n if (urlObj.fullUrl) {\n url = urlObj.fullUrl;\n } else if (urlObj.path) {\n url = urlStore.baseUrl + urlObj.path;\n }\n\n if (!url) return '';\n return `${urlPrefix} ${url}`;\n};\n\nexport default { buildLogSuffix };\n","import { default as EventsDispatcher } from '../events/dispatcher';\nimport * as Errors from '../errors';\nimport Logger from '../logger';\nimport Pusher from '../pusher';\nimport { PusherEvent } from '../connection/protocol/message-types';\nimport Metadata from './metadata';\nimport UrlStore from '../utils/url_store';\nimport {\n ChannelAuthorizationData,\n ChannelAuthorizationCallback\n} from '../auth/options';\nimport { HTTPAuthError } from '../errors';\n\n/** Provides base public channel interface with an event emitter.\n *\n * Emits:\n * - pusher:subscription_succeeded - after subscribing successfully\n * - other non-internal events\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\nexport default class Channel extends EventsDispatcher {\n name: string;\n pusher: Pusher;\n subscribed: boolean;\n subscriptionPending: boolean;\n subscriptionCancelled: boolean;\n subscriptionCount: null;\n\n constructor(name: string, pusher: Pusher) {\n super(function(event, data) {\n Logger.debug('No callbacks on ' + name + ' for ' + event);\n });\n\n this.name = name;\n this.pusher = pusher;\n this.subscribed = false;\n this.subscriptionPending = false;\n this.subscriptionCancelled = false;\n }\n\n /** Skips authorization, since public channels don't require it.\n *\n * @param {Function} callback\n */\n authorize(socketId: string, callback: ChannelAuthorizationCallback) {\n return callback(null, { auth: '' });\n }\n\n /** Triggers an event */\n trigger(event: string, data: any) {\n if (event.indexOf('client-') !== 0) {\n throw new Errors.BadEventName(\n \"Event '\" + event + \"' does not start with 'client-'\"\n );\n }\n if (!this.subscribed) {\n var suffix = UrlStore.buildLogSuffix('triggeringClientEvents');\n Logger.warn(\n `Client event triggered before channel 'subscription_succeeded' event . ${suffix}`\n );\n }\n return this.pusher.send_event(event, data, this.name);\n }\n\n /** Signals disconnection to the channel. For internal use only. */\n disconnect() {\n this.subscribed = false;\n this.subscriptionPending = false;\n }\n\n /** Handles a PusherEvent. For internal use only.\n *\n * @param {PusherEvent} event\n */\n handleEvent(event: PusherEvent) {\n var eventName = event.event;\n var data = event.data;\n if (eventName === 'pusher_internal:subscription_succeeded') {\n this.handleSubscriptionSucceededEvent(event);\n } else if (eventName === 'pusher_internal:subscription_count') {\n this.handleSubscriptionCountEvent(event);\n } else if (eventName.indexOf('pusher_internal:') !== 0) {\n var metadata: Metadata = {};\n this.emit(eventName, data, metadata);\n }\n }\n\n handleSubscriptionSucceededEvent(event: PusherEvent) {\n this.subscriptionPending = false;\n this.subscribed = true;\n if (this.subscriptionCancelled) {\n this.pusher.unsubscribe(this.name);\n } else {\n this.emit('pusher:subscription_succeeded', event.data);\n }\n }\n\n handleSubscriptionCountEvent(event: PusherEvent) {\n if (event.data.subscription_count) {\n this.subscriptionCount = event.data.subscription_count;\n }\n\n this.emit('pusher:subscription_count', event.data);\n }\n\n /** Sends a subscription request. For internal use only. */\n subscribe() {\n if (this.subscribed) {\n return;\n }\n this.subscriptionPending = true;\n this.subscriptionCancelled = false;\n this.authorize(\n this.pusher.connection.socket_id,\n (error: Error | null, data: ChannelAuthorizationData) => {\n if (error) {\n this.subscriptionPending = false;\n // Why not bind to 'pusher:subscription_error' a level up, and log there?\n // Binding to this event would cause the warning about no callbacks being\n // bound (see constructor) to be suppressed, that's not what we want.\n Logger.error(error.toString());\n this.emit(\n 'pusher:subscription_error',\n Object.assign(\n {},\n {\n type: 'AuthError',\n error: error.message\n },\n error instanceof HTTPAuthError ? { status: error.status } : {}\n )\n );\n } else {\n this.pusher.send_event('pusher:subscribe', {\n auth: data.auth,\n channel_data: data.channel_data,\n channel: this.name\n });\n }\n }\n );\n }\n\n /** Sends an unsubscription request. For internal use only. */\n unsubscribe() {\n this.subscribed = false;\n this.pusher.send_event('pusher:unsubscribe', {\n channel: this.name\n });\n }\n\n /** Cancels an in progress subscription. For internal use only. */\n cancelSubscription() {\n this.subscriptionCancelled = true;\n }\n\n /** Reinstates an in progress subscripiton. For internal use only. */\n reinstateSubscription() {\n this.subscriptionCancelled = false;\n }\n}\n","import Factory from '../utils/factory';\nimport Channel from './channel';\nimport { ChannelAuthorizationCallback } from '../auth/options';\n\n/** Extends public channels to provide private channel interface.\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\nexport default class PrivateChannel extends Channel {\n /** Authorizes the connection to use the channel.\n *\n * @param {String} socketId\n * @param {Function} callback\n */\n authorize(socketId: string, callback: ChannelAuthorizationCallback) {\n return this.pusher.config.channelAuthorizer(\n {\n channelName: this.name,\n socketId: socketId\n },\n callback\n );\n }\n}\n","import * as Collections from '../utils/collections';\n\n/** Represents a collection of members of a presence channel. */\nexport default class Members {\n members: any;\n count: number;\n myID: any;\n me: any;\n\n constructor() {\n this.reset();\n }\n\n /** Returns member's info for given id.\n *\n * Resulting object containts two fields - id and info.\n *\n * @param {Number} id\n * @return {Object} member's info or null\n */\n get(id: string): any {\n if (Object.prototype.hasOwnProperty.call(this.members, id)) {\n return {\n id: id,\n info: this.members[id]\n };\n } else {\n return null;\n }\n }\n\n /** Calls back for each member in unspecified order.\n *\n * @param {Function} callback\n */\n each(callback: Function) {\n Collections.objectApply(this.members, (member, id) => {\n callback(this.get(id));\n });\n }\n\n /** Updates the id for connected member. For internal use only. */\n setMyID(id: string) {\n this.myID = id;\n }\n\n /** Handles subscription data. For internal use only. */\n onSubscription(subscriptionData: any) {\n this.members = subscriptionData.presence.hash;\n this.count = subscriptionData.presence.count;\n this.me = this.get(this.myID);\n }\n\n /** Adds a new member to the collection. For internal use only. */\n addMember(memberData: any) {\n if (this.get(memberData.user_id) === null) {\n this.count++;\n }\n this.members[memberData.user_id] = memberData.user_info;\n return this.get(memberData.user_id);\n }\n\n /** Adds a member from the collection. For internal use only. */\n removeMember(memberData: any) {\n var member = this.get(memberData.user_id);\n if (member) {\n delete this.members[memberData.user_id];\n this.count--;\n }\n return member;\n }\n\n /** Resets the collection to the initial state. For internal use only. */\n reset() {\n this.members = {};\n this.count = 0;\n this.myID = null;\n this.me = null;\n }\n}\n","import PrivateChannel from './private_channel';\nimport Logger from '../logger';\nimport Members from './members';\nimport Pusher from '../pusher';\nimport UrlStore from 'core/utils/url_store';\nimport { PusherEvent } from '../connection/protocol/message-types';\nimport Metadata from './metadata';\nimport { ChannelAuthorizationData } from '../auth/options';\n\nexport default class PresenceChannel extends PrivateChannel {\n members: Members;\n\n /** Adds presence channel functionality to private channels.\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\n constructor(name: string, pusher: Pusher) {\n super(name, pusher);\n this.members = new Members();\n }\n\n /** Authorizes the connection as a member of the channel.\n *\n * @param {String} socketId\n * @param {Function} callback\n */\n authorize(socketId: string, callback: Function) {\n super.authorize(socketId, async (error, authData) => {\n if (!error) {\n authData = authData as ChannelAuthorizationData;\n if (authData.channel_data != null) {\n var channelData = JSON.parse(authData.channel_data);\n this.members.setMyID(channelData.user_id);\n } else {\n await this.pusher.user.signinDonePromise;\n if (this.pusher.user.user_data != null) {\n // If the user is signed in, get the id of the authenticated user\n // and allow the presence authorization to continue.\n this.members.setMyID(this.pusher.user.user_data.id);\n } else {\n let suffix = UrlStore.buildLogSuffix('authorizationEndpoint');\n Logger.error(\n `Invalid auth response for channel '${this.name}', ` +\n `expected 'channel_data' field. ${suffix}, ` +\n `or the user should be signed in.`\n );\n callback('Invalid auth response');\n return;\n }\n }\n }\n callback(error, authData);\n });\n }\n\n /** Handles presence and subscription events. For internal use only.\n *\n * @param {PusherEvent} event\n */\n handleEvent(event: PusherEvent) {\n var eventName = event.event;\n if (eventName.indexOf('pusher_internal:') === 0) {\n this.handleInternalEvent(event);\n } else {\n var data = event.data;\n var metadata: Metadata = {};\n if (event.user_id) {\n metadata.user_id = event.user_id;\n }\n this.emit(eventName, data, metadata);\n }\n }\n handleInternalEvent(event: PusherEvent) {\n var eventName = event.event;\n var data = event.data;\n switch (eventName) {\n case 'pusher_internal:subscription_succeeded':\n this.handleSubscriptionSucceededEvent(event);\n break;\n case 'pusher_internal:subscription_count':\n this.handleSubscriptionCountEvent(event);\n break;\n case 'pusher_internal:member_added':\n var addedMember = this.members.addMember(data);\n this.emit('pusher:member_added', addedMember);\n break;\n case 'pusher_internal:member_removed':\n var removedMember = this.members.removeMember(data);\n if (removedMember) {\n this.emit('pusher:member_removed', removedMember);\n }\n break;\n }\n }\n\n handleSubscriptionSucceededEvent(event: PusherEvent) {\n this.subscriptionPending = false;\n this.subscribed = true;\n if (this.subscriptionCancelled) {\n this.pusher.unsubscribe(this.name);\n } else {\n this.members.onSubscription(event.data);\n this.emit('pusher:subscription_succeeded', this.members);\n }\n }\n\n /** Resets the channel state, including members map. For internal use only. */\n disconnect() {\n this.members.reset();\n super.disconnect();\n }\n}\n","import PrivateChannel from './private_channel';\nimport * as Errors from '../errors';\nimport Logger from '../logger';\nimport Pusher from '../pusher';\nimport { decode as encodeUTF8 } from '@stablelib/utf8';\nimport { decode as decodeBase64 } from '@stablelib/base64';\nimport Dispatcher from '../events/dispatcher';\nimport { PusherEvent } from '../connection/protocol/message-types';\nimport {\n ChannelAuthorizationData,\n ChannelAuthorizationCallback\n} from '../auth/options';\nimport * as nacl from 'tweetnacl';\n\n/** Extends private channels to provide encrypted channel interface.\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\nexport default class EncryptedChannel extends PrivateChannel {\n key: Uint8Array = null;\n nacl: nacl;\n\n constructor(name: string, pusher: Pusher, nacl: nacl) {\n super(name, pusher);\n this.nacl = nacl;\n }\n\n /** Authorizes the connection to use the channel.\n *\n * @param {String} socketId\n * @param {Function} callback\n */\n authorize(socketId: string, callback: ChannelAuthorizationCallback) {\n super.authorize(\n socketId,\n (error: Error | null, authData: ChannelAuthorizationData) => {\n if (error) {\n callback(error, authData);\n return;\n }\n let sharedSecret = authData['shared_secret'];\n if (!sharedSecret) {\n callback(\n new Error(\n `No shared_secret key in auth payload for encrypted channel: ${this.name}`\n ),\n null\n );\n return;\n }\n this.key = decodeBase64(sharedSecret);\n delete authData['shared_secret'];\n callback(null, authData);\n }\n );\n }\n\n trigger(event: string, data: any): boolean {\n throw new Errors.UnsupportedFeature(\n 'Client events are not currently supported for encrypted channels'\n );\n }\n\n /** Handles an event. For internal use only.\n *\n * @param {PusherEvent} event\n */\n handleEvent(event: PusherEvent) {\n var eventName = event.event;\n var data = event.data;\n if (\n eventName.indexOf('pusher_internal:') === 0 ||\n eventName.indexOf('pusher:') === 0\n ) {\n super.handleEvent(event);\n return;\n }\n this.handleEncryptedEvent(eventName, data);\n }\n\n private handleEncryptedEvent(event: string, data: any): void {\n if (!this.key) {\n Logger.debug(\n 'Received encrypted event before key has been retrieved from the authEndpoint'\n );\n return;\n }\n if (!data.ciphertext || !data.nonce) {\n Logger.error(\n 'Unexpected format for encrypted event, expected object with `ciphertext` and `nonce` fields, got: ' +\n data\n );\n return;\n }\n let cipherText = decodeBase64(data.ciphertext);\n if (cipherText.length < this.nacl.secretbox.overheadLength) {\n Logger.error(\n `Expected encrypted event ciphertext length to be ${this.nacl.secretbox.overheadLength}, got: ${cipherText.length}`\n );\n return;\n }\n let nonce = decodeBase64(data.nonce);\n if (nonce.length < this.nacl.secretbox.nonceLength) {\n Logger.error(\n `Expected encrypted event nonce length to be ${this.nacl.secretbox.nonceLength}, got: ${nonce.length}`\n );\n return;\n }\n\n let bytes = this.nacl.secretbox.open(cipherText, nonce, this.key);\n if (bytes === null) {\n Logger.debug(\n 'Failed to decrypt an event, probably because it was encrypted with a different key. Fetching a new key from the authEndpoint...'\n );\n // Try a single time to retrieve a new auth key and decrypt the event with it\n // If this fails, a new key will be requested when a new message is received\n this.authorize(this.pusher.connection.socket_id, (error, authData) => {\n if (error) {\n Logger.error(\n `Failed to make a request to the authEndpoint: ${authData}. Unable to fetch new key, so dropping encrypted event`\n );\n return;\n }\n bytes = this.nacl.secretbox.open(cipherText, nonce, this.key);\n if (bytes === null) {\n Logger.error(\n `Failed to decrypt event with new key. Dropping encrypted event`\n );\n return;\n }\n this.emit(event, this.getDataToEmit(bytes));\n return;\n });\n return;\n }\n this.emit(event, this.getDataToEmit(bytes));\n }\n\n // Try and parse the decrypted bytes as JSON. If we can't parse it, just\n // return the utf-8 string\n getDataToEmit(bytes: Uint8Array): string {\n let raw = encodeUTF8(bytes);\n try {\n return JSON.parse(raw);\n } catch {\n return raw;\n }\n }\n}\n","import { default as EventsDispatcher } from '../events/dispatcher';\nimport { OneOffTimer as Timer } from '../utils/timers';\nimport { Config } from '../config';\nimport Logger from '../logger';\nimport HandshakePayload from './handshake/handshake_payload';\nimport Connection from './connection';\nimport Strategy from '../strategies/strategy';\nimport StrategyRunner from '../strategies/strategy_runner';\nimport * as Collections from '../utils/collections';\nimport Timeline from '../timeline/timeline';\nimport ConnectionManagerOptions from './connection_manager_options';\nimport Runtime from 'runtime';\n\nimport {\n ErrorCallbacks,\n HandshakeCallbacks,\n ConnectionCallbacks\n} from './callbacks';\nimport Action from './protocol/action';\n\n/** Manages connection to Pusher.\n *\n * Uses a strategy (currently only default), timers and network availability\n * info to establish a connection and export its state. In case of failures,\n * manages reconnection attempts.\n *\n * Exports state changes as following events:\n * - \"state_change\", { previous: p, current: state }\n * - state\n *\n * States:\n * - initialized - initial state, never transitioned to\n * - connecting - connection is being established\n * - connected - connection has been fully established\n * - disconnected - on requested disconnection\n * - unavailable - after connection timeout or when there's no network\n * - failed - when the connection strategy is not supported\n *\n * Options:\n * - unavailableTimeout - time to transition to unavailable state\n * - activityTimeout - time after which ping message should be sent\n * - pongTimeout - time for Pusher to respond with pong before reconnecting\n *\n * @param {String} key application key\n * @param {Object} options\n */\nexport default class ConnectionManager extends EventsDispatcher {\n key: string;\n options: ConnectionManagerOptions;\n state: string;\n connection: Connection;\n usingTLS: boolean;\n timeline: Timeline;\n socket_id: string;\n unavailableTimer: Timer;\n activityTimer: Timer;\n retryTimer: Timer;\n activityTimeout: number;\n strategy: Strategy;\n runner: StrategyRunner;\n errorCallbacks: ErrorCallbacks;\n handshakeCallbacks: HandshakeCallbacks;\n connectionCallbacks: ConnectionCallbacks;\n\n constructor(key: string, options: ConnectionManagerOptions) {\n super();\n this.state = 'initialized';\n this.connection = null;\n\n this.key = key;\n this.options = options;\n this.timeline = this.options.timeline;\n this.usingTLS = this.options.useTLS;\n\n this.errorCallbacks = this.buildErrorCallbacks();\n this.connectionCallbacks = this.buildConnectionCallbacks(\n this.errorCallbacks\n );\n this.handshakeCallbacks = this.buildHandshakeCallbacks(this.errorCallbacks);\n\n var Network = Runtime.getNetwork();\n\n Network.bind('online', () => {\n this.timeline.info({ netinfo: 'online' });\n if (this.state === 'connecting' || this.state === 'unavailable') {\n this.retryIn(0);\n }\n });\n Network.bind('offline', () => {\n this.timeline.info({ netinfo: 'offline' });\n if (this.connection) {\n this.sendActivityCheck();\n }\n });\n\n this.updateStrategy();\n }\n\n switchCluster(key: string) {\n this.key = key;\n // This ensures that the new config coming from\n // pusher instance are taken into account\n // such as appKey and cluster\n this.updateStrategy();\n this.retryIn(0);\n }\n\n /** Establishes a connection to Pusher.\n *\n * Does nothing when connection is already established. See top-level doc\n * to find events emitted on connection attempts.\n */\n connect() {\n if (this.connection || this.runner) {\n return;\n }\n if (!this.strategy.isSupported()) {\n this.updateState('failed');\n return;\n }\n this.updateState('connecting');\n this.startConnecting();\n this.setUnavailableTimer();\n }\n\n /** Sends raw data.\n *\n * @param {String} data\n */\n send(data) {\n if (this.connection) {\n return this.connection.send(data);\n } else {\n return false;\n }\n }\n\n /** Sends an event.\n *\n * @param {String} name\n * @param {String} data\n * @param {String} [channel]\n * @returns {Boolean} whether message was sent or not\n */\n send_event(name: string, data: any, channel?: string) {\n if (this.connection) {\n return this.connection.send_event(name, data, channel);\n } else {\n return false;\n }\n }\n\n /** Closes the connection. */\n disconnect() {\n this.disconnectInternally();\n this.updateState('disconnected');\n }\n\n isUsingTLS() {\n return this.usingTLS;\n }\n\n private startConnecting() {\n var callback = (error, handshake) => {\n if (error) {\n this.runner = this.strategy.connect(0, callback);\n } else {\n if (handshake.action === 'error') {\n this.emit('error', {\n type: 'HandshakeError',\n error: handshake.error\n });\n this.timeline.error({ handshakeError: handshake.error });\n } else {\n this.abortConnecting(); // we don't support switching connections yet\n this.handshakeCallbacks[handshake.action](handshake);\n }\n }\n };\n this.runner = this.strategy.connect(0, callback);\n }\n\n private abortConnecting() {\n if (this.runner) {\n this.runner.abort();\n this.runner = null;\n }\n }\n\n private disconnectInternally() {\n this.abortConnecting();\n this.clearRetryTimer();\n this.clearUnavailableTimer();\n if (this.connection) {\n var connection = this.abandonConnection();\n connection.close();\n }\n }\n\n private updateStrategy() {\n this.strategy = this.options.getStrategy({\n key: this.key,\n timeline: this.timeline,\n useTLS: this.usingTLS\n });\n }\n\n private retryIn(delay) {\n this.timeline.info({ action: 'retry', delay: delay });\n if (delay > 0) {\n this.emit('connecting_in', Math.round(delay / 1000));\n }\n this.retryTimer = new Timer(delay || 0, () => {\n this.disconnectInternally();\n this.connect();\n });\n }\n\n private clearRetryTimer() {\n if (this.retryTimer) {\n this.retryTimer.ensureAborted();\n this.retryTimer = null;\n }\n }\n\n private setUnavailableTimer() {\n this.unavailableTimer = new Timer(this.options.unavailableTimeout, () => {\n this.updateState('unavailable');\n });\n }\n\n private clearUnavailableTimer() {\n if (this.unavailableTimer) {\n this.unavailableTimer.ensureAborted();\n }\n }\n\n private sendActivityCheck() {\n this.stopActivityCheck();\n this.connection.ping();\n // wait for pong response\n this.activityTimer = new Timer(this.options.pongTimeout, () => {\n this.timeline.error({ pong_timed_out: this.options.pongTimeout });\n this.retryIn(0);\n });\n }\n\n private resetActivityCheck() {\n this.stopActivityCheck();\n // send ping after inactivity\n if (this.connection && !this.connection.handlesActivityChecks()) {\n this.activityTimer = new Timer(this.activityTimeout, () => {\n this.sendActivityCheck();\n });\n }\n }\n\n private stopActivityCheck() {\n if (this.activityTimer) {\n this.activityTimer.ensureAborted();\n }\n }\n\n private buildConnectionCallbacks(\n errorCallbacks: ErrorCallbacks\n ): ConnectionCallbacks {\n return Collections.extend({}, errorCallbacks, {\n message: message => {\n // includes pong messages from server\n this.resetActivityCheck();\n this.emit('message', message);\n },\n ping: () => {\n this.send_event('pusher:pong', {});\n },\n activity: () => {\n this.resetActivityCheck();\n },\n error: error => {\n // just emit error to user - socket will already be closed by browser\n this.emit('error', error);\n },\n closed: () => {\n this.abandonConnection();\n if (this.shouldRetry()) {\n this.retryIn(1000);\n }\n }\n });\n }\n\n private buildHandshakeCallbacks(\n errorCallbacks: ErrorCallbacks\n ): HandshakeCallbacks {\n return Collections.extend({}, errorCallbacks, {\n connected: (handshake: HandshakePayload) => {\n this.activityTimeout = Math.min(\n this.options.activityTimeout,\n handshake.activityTimeout,\n handshake.connection.activityTimeout || Infinity\n );\n this.clearUnavailableTimer();\n this.setConnection(handshake.connection);\n this.socket_id = this.connection.id;\n this.updateState('connected', { socket_id: this.socket_id });\n }\n });\n }\n\n private buildErrorCallbacks(): ErrorCallbacks {\n let withErrorEmitted = callback => {\n return (result: Action | HandshakePayload) => {\n if (result.error) {\n this.emit('error', { type: 'WebSocketError', error: result.error });\n }\n callback(result);\n };\n };\n\n return {\n tls_only: withErrorEmitted(() => {\n this.usingTLS = true;\n this.updateStrategy();\n this.retryIn(0);\n }),\n refused: withErrorEmitted(() => {\n this.disconnect();\n }),\n backoff: withErrorEmitted(() => {\n this.retryIn(1000);\n }),\n retry: withErrorEmitted(() => {\n this.retryIn(0);\n })\n };\n }\n\n private setConnection(connection) {\n this.connection = connection;\n for (var event in this.connectionCallbacks) {\n this.connection.bind(event, this.connectionCallbacks[event]);\n }\n this.resetActivityCheck();\n }\n\n private abandonConnection() {\n if (!this.connection) {\n return;\n }\n this.stopActivityCheck();\n for (var event in this.connectionCallbacks) {\n this.connection.unbind(event, this.connectionCallbacks[event]);\n }\n var connection = this.connection;\n this.connection = null;\n return connection;\n }\n\n private updateState(newState: string, data?: any) {\n var previousState = this.state;\n this.state = newState;\n if (previousState !== newState) {\n var newStateDescription = newState;\n if (newStateDescription === 'connected') {\n newStateDescription += ' with new socket ID ' + data.socket_id;\n }\n Logger.debug(\n 'State changed',\n previousState + ' -> ' + newStateDescription\n );\n this.timeline.info({ state: newState, params: data });\n this.emit('state_change', { previous: previousState, current: newState });\n this.emit(newState, data);\n }\n }\n\n private shouldRetry(): boolean {\n return this.state === 'connecting' || this.state === 'connected';\n }\n}\n","import Channel from './channel';\nimport * as Collections from '../utils/collections';\nimport ChannelTable from './channel_table';\nimport Factory from '../utils/factory';\nimport Pusher from '../pusher';\nimport Logger from '../logger';\nimport * as Errors from '../errors';\nimport urlStore from '../utils/url_store';\n\n/** Handles a channel map. */\nexport default class Channels {\n channels: ChannelTable;\n\n constructor() {\n this.channels = {};\n }\n\n /** Creates or retrieves an existing channel by its name.\n *\n * @param {String} name\n * @param {Pusher} pusher\n * @return {Channel}\n */\n add(name: string, pusher: Pusher) {\n if (!this.channels[name]) {\n this.channels[name] = createChannel(name, pusher);\n }\n return this.channels[name];\n }\n\n /** Returns a list of all channels\n *\n * @return {Array}\n */\n all(): Channel[] {\n return Collections.values(this.channels);\n }\n\n /** Finds a channel by its name.\n *\n * @param {String} name\n * @return {Channel} channel or null if it doesn't exist\n */\n find(name: string) {\n return this.channels[name];\n }\n\n /** Removes a channel from the map.\n *\n * @param {String} name\n */\n remove(name: string) {\n var channel = this.channels[name];\n delete this.channels[name];\n return channel;\n }\n\n /** Proxies disconnection signal to all channels. */\n disconnect() {\n Collections.objectApply(this.channels, function(channel) {\n channel.disconnect();\n });\n }\n}\n\nfunction createChannel(name: string, pusher: Pusher): Channel {\n if (name.indexOf('private-encrypted-') === 0) {\n if (pusher.config.nacl) {\n return Factory.createEncryptedChannel(name, pusher, pusher.config.nacl);\n }\n let errMsg =\n 'Tried to subscribe to a private-encrypted- channel but no nacl implementation available';\n let suffix = urlStore.buildLogSuffix('encryptedChannelSupport');\n throw new Errors.UnsupportedFeature(`${errMsg}. ${suffix}`);\n } else if (name.indexOf('private-') === 0) {\n return Factory.createPrivateChannel(name, pusher);\n } else if (name.indexOf('presence-') === 0) {\n return Factory.createPresenceChannel(name, pusher);\n } else if (name.indexOf('#') === 0) {\n throw new Errors.BadChannelName(\n 'Cannot create a channel with name \"' + name + '\".'\n );\n } else {\n return Factory.createChannel(name, pusher);\n }\n}\n","import AssistantToTheTransportManager from '../transports/assistant_to_the_transport_manager';\nimport PingDelayOptions from '../transports/ping_delay_options';\nimport Transport from '../transports/transport';\nimport TransportManager from '../transports/transport_manager';\nimport Handshake from '../connection/handshake';\nimport TransportConnection from '../transports/transport_connection';\nimport SocketHooks from '../http/socket_hooks';\nimport HTTPSocket from '../http/http_socket';\n\nimport Timeline from '../timeline/timeline';\nimport {\n default as TimelineSender,\n TimelineSenderOptions\n} from '../timeline/timeline_sender';\nimport PresenceChannel from '../channels/presence_channel';\nimport PrivateChannel from '../channels/private_channel';\nimport EncryptedChannel from '../channels/encrypted_channel';\nimport Channel from '../channels/channel';\nimport ConnectionManager from '../connection/connection_manager';\nimport ConnectionManagerOptions from '../connection/connection_manager_options';\nimport Ajax from '../http/ajax';\nimport Channels from '../channels/channels';\nimport Pusher from '../pusher';\nimport { Config } from '../config';\nimport * as nacl from 'tweetnacl';\n\nvar Factory = {\n createChannels(): Channels {\n return new Channels();\n },\n\n createConnectionManager(\n key: string,\n options: ConnectionManagerOptions\n ): ConnectionManager {\n return new ConnectionManager(key, options);\n },\n\n createChannel(name: string, pusher: Pusher): Channel {\n return new Channel(name, pusher);\n },\n\n createPrivateChannel(name: string, pusher: Pusher): PrivateChannel {\n return new PrivateChannel(name, pusher);\n },\n\n createPresenceChannel(name: string, pusher: Pusher): PresenceChannel {\n return new PresenceChannel(name, pusher);\n },\n\n createEncryptedChannel(\n name: string,\n pusher: Pusher,\n nacl: nacl\n ): EncryptedChannel {\n return new EncryptedChannel(name, pusher, nacl);\n },\n\n createTimelineSender(timeline: Timeline, options: TimelineSenderOptions) {\n return new TimelineSender(timeline, options);\n },\n\n createHandshake(\n transport: TransportConnection,\n callback: (HandshakePayload) => void\n ): Handshake {\n return new Handshake(transport, callback);\n },\n\n createAssistantToTheTransportManager(\n manager: TransportManager,\n transport: Transport,\n options: PingDelayOptions\n ): AssistantToTheTransportManager {\n return new AssistantToTheTransportManager(manager, transport, options);\n }\n};\n\nexport default Factory;\n","import AssistantToTheTransportManager from './assistant_to_the_transport_manager';\nimport Transport from './transport';\nimport PingDelayOptions from './ping_delay_options';\nimport Factory from '../utils/factory';\n\nexport interface TransportManagerOptions extends PingDelayOptions {\n lives?: number;\n}\n\n/** Keeps track of the number of lives left for a transport.\n *\n * In the beginning of a session, transports may be assigned a number of\n * lives. When an AssistantToTheTransportManager instance reports a transport\n * connection closed uncleanly, the transport loses a life. When the number\n * of lives drops to zero, the transport gets disabled by its manager.\n *\n * @param {Object} options\n */\nexport default class TransportManager {\n options: TransportManagerOptions;\n livesLeft: number;\n\n constructor(options: TransportManagerOptions) {\n this.options = options || {};\n this.livesLeft = this.options.lives || Infinity;\n }\n\n /** Creates a assistant for the transport.\n *\n * @param {Transport} transport\n * @returns {AssistantToTheTransportManager}\n */\n getAssistant(transport: Transport): AssistantToTheTransportManager {\n return Factory.createAssistantToTheTransportManager(this, transport, {\n minPingDelay: this.options.minPingDelay,\n maxPingDelay: this.options.maxPingDelay\n });\n }\n\n /** Returns whether the transport has any lives left.\n *\n * @returns {Boolean}\n */\n isAlive(): boolean {\n return this.livesLeft > 0;\n }\n\n /** Takes one life from the transport. */\n reportDeath() {\n this.livesLeft -= 1;\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport { OneOffTimer as Timer } from '../utils/timers';\nimport Strategy from './strategy';\nimport StrategyOptions from './strategy_options';\n\n/** Loops through strategies with optional timeouts.\n *\n * Options:\n * - loop - whether it should loop through the substrategy list\n * - timeout - initial timeout for a single substrategy\n * - timeoutLimit - maximum timeout\n *\n * @param {Strategy[]} strategies\n * @param {Object} options\n */\nexport default class SequentialStrategy implements Strategy {\n strategies: Strategy[];\n loop: boolean;\n failFast: boolean;\n timeout: number;\n timeoutLimit: number;\n\n constructor(strategies: Strategy[], options: StrategyOptions) {\n this.strategies = strategies;\n this.loop = Boolean(options.loop);\n this.failFast = Boolean(options.failFast);\n this.timeout = options.timeout;\n this.timeoutLimit = options.timeoutLimit;\n }\n\n isSupported(): boolean {\n return Collections.any(this.strategies, Util.method('isSupported'));\n }\n\n connect(minPriority: number, callback: Function) {\n var strategies = this.strategies;\n var current = 0;\n var timeout = this.timeout;\n var runner = null;\n\n var tryNextStrategy = (error, handshake) => {\n if (handshake) {\n callback(null, handshake);\n } else {\n current = current + 1;\n if (this.loop) {\n current = current % strategies.length;\n }\n\n if (current < strategies.length) {\n if (timeout) {\n timeout = timeout * 2;\n if (this.timeoutLimit) {\n timeout = Math.min(timeout, this.timeoutLimit);\n }\n }\n runner = this.tryStrategy(\n strategies[current],\n minPriority,\n { timeout, failFast: this.failFast },\n tryNextStrategy\n );\n } else {\n callback(true);\n }\n }\n };\n\n runner = this.tryStrategy(\n strategies[current],\n minPriority,\n { timeout: timeout, failFast: this.failFast },\n tryNextStrategy\n );\n\n return {\n abort: function() {\n runner.abort();\n },\n forceMinPriority: function(p) {\n minPriority = p;\n if (runner) {\n runner.forceMinPriority(p);\n }\n }\n };\n }\n\n private tryStrategy(\n strategy: Strategy,\n minPriority: number,\n options: StrategyOptions,\n callback: Function\n ) {\n var timer = null;\n var runner = null;\n\n if (options.timeout > 0) {\n timer = new Timer(options.timeout, function() {\n runner.abort();\n callback(true);\n });\n }\n\n runner = strategy.connect(minPriority, function(error, handshake) {\n if (error && timer && timer.isRunning() && !options.failFast) {\n // advance to the next strategy after the timeout\n return;\n }\n if (timer) {\n timer.ensureAborted();\n }\n callback(error, handshake);\n });\n\n return {\n abort: function() {\n if (timer) {\n timer.ensureAborted();\n }\n runner.abort();\n },\n forceMinPriority: function(p) {\n runner.forceMinPriority(p);\n }\n };\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport Strategy from './strategy';\n\n/** Launches all substrategies and emits prioritized connected transports.\n *\n * @param {Array} strategies\n */\nexport default class BestConnectedEverStrategy implements Strategy {\n strategies: Strategy[];\n\n constructor(strategies: Strategy[]) {\n this.strategies = strategies;\n }\n\n isSupported(): boolean {\n return Collections.any(this.strategies, Util.method('isSupported'));\n }\n\n connect(minPriority: number, callback: Function) {\n return connect(this.strategies, minPriority, function(i, runners) {\n return function(error, handshake) {\n runners[i].error = error;\n if (error) {\n if (allRunnersFailed(runners)) {\n callback(true);\n }\n return;\n }\n Collections.apply(runners, function(runner) {\n runner.forceMinPriority(handshake.transport.priority);\n });\n callback(null, handshake);\n };\n });\n }\n}\n\n/** Connects to all strategies in parallel.\n *\n * Callback builder should be a function that takes two arguments: index\n * and a list of runners. It should return another function that will be\n * passed to the substrategy with given index. Runners can be aborted using\n * abortRunner(s) functions from this class.\n *\n * @param {Array} strategies\n * @param {Function} callbackBuilder\n * @return {Object} strategy runner\n */\nfunction connect(\n strategies: Strategy[],\n minPriority: number,\n callbackBuilder: Function\n) {\n var runners = Collections.map(strategies, function(strategy, i, _, rs) {\n return strategy.connect(minPriority, callbackBuilder(i, rs));\n });\n return {\n abort: function() {\n Collections.apply(runners, abortRunner);\n },\n forceMinPriority: function(p) {\n Collections.apply(runners, function(runner) {\n runner.forceMinPriority(p);\n });\n }\n };\n}\n\nfunction allRunnersFailed(runners): boolean {\n return Collections.all(runners, function(runner) {\n return Boolean(runner.error);\n });\n}\n\nfunction abortRunner(runner) {\n if (!runner.error && !runner.aborted) {\n runner.abort();\n runner.aborted = true;\n }\n}\n","import Util from '../util';\nimport Runtime from 'runtime';\nimport Strategy from './strategy';\nimport SequentialStrategy from './sequential_strategy';\nimport StrategyOptions from './strategy_options';\nimport TransportStrategy from './transport_strategy';\nimport Timeline from '../timeline/timeline';\nimport * as Collections from '../utils/collections';\n\nexport interface TransportStrategyDictionary {\n [key: string]: TransportStrategy;\n}\n\n/** Caches the last successful transport and, after the first few attempts,\n * uses the cached transport for subsequent attempts.\n *\n * @param {Strategy} strategy\n * @param {Object} transports\n * @param {Object} options\n */\nexport default class WebSocketPrioritizedCachedStrategy implements Strategy {\n strategy: Strategy;\n transports: TransportStrategyDictionary;\n ttl: number;\n usingTLS: boolean;\n timeline: Timeline;\n\n constructor(\n strategy: Strategy,\n transports: TransportStrategyDictionary,\n options: StrategyOptions\n ) {\n this.strategy = strategy;\n this.transports = transports;\n this.ttl = options.ttl || 1800 * 1000;\n this.usingTLS = options.useTLS;\n this.timeline = options.timeline;\n }\n\n isSupported(): boolean {\n return this.strategy.isSupported();\n }\n\n connect(minPriority: number, callback: Function) {\n var usingTLS = this.usingTLS;\n var info = fetchTransportCache(usingTLS);\n var cacheSkipCount = info && info.cacheSkipCount ? info.cacheSkipCount : 0;\n\n var strategies = [this.strategy];\n if (info && info.timestamp + this.ttl >= Util.now()) {\n var transport = this.transports[info.transport];\n if (transport) {\n if (['ws', 'wss'].includes(info.transport) || cacheSkipCount > 3) {\n this.timeline.info({\n cached: true,\n transport: info.transport,\n latency: info.latency\n });\n strategies.push(\n new SequentialStrategy([transport], {\n timeout: info.latency * 2 + 1000,\n failFast: true\n })\n );\n } else {\n cacheSkipCount++;\n }\n }\n }\n\n var startTimestamp = Util.now();\n var runner = strategies\n .pop()\n .connect(minPriority, function cb(error, handshake) {\n if (error) {\n flushTransportCache(usingTLS);\n if (strategies.length > 0) {\n startTimestamp = Util.now();\n runner = strategies.pop().connect(minPriority, cb);\n } else {\n callback(error);\n }\n } else {\n storeTransportCache(\n usingTLS,\n handshake.transport.name,\n Util.now() - startTimestamp,\n cacheSkipCount\n );\n callback(null, handshake);\n }\n });\n\n return {\n abort: function() {\n runner.abort();\n },\n forceMinPriority: function(p) {\n minPriority = p;\n if (runner) {\n runner.forceMinPriority(p);\n }\n }\n };\n }\n}\n\nfunction getTransportCacheKey(usingTLS: boolean): string {\n return 'pusherTransport' + (usingTLS ? 'TLS' : 'NonTLS');\n}\n\nfunction fetchTransportCache(usingTLS: boolean): any {\n var storage = Runtime.getLocalStorage();\n if (storage) {\n try {\n var serializedCache = storage[getTransportCacheKey(usingTLS)];\n if (serializedCache) {\n return JSON.parse(serializedCache);\n }\n } catch (e) {\n flushTransportCache(usingTLS);\n }\n }\n return null;\n}\n\nfunction storeTransportCache(\n usingTLS: boolean,\n transport: TransportStrategy,\n latency: number,\n cacheSkipCount: number\n) {\n var storage = Runtime.getLocalStorage();\n if (storage) {\n try {\n storage[getTransportCacheKey(usingTLS)] = Collections.safeJSONStringify({\n timestamp: Util.now(),\n transport: transport,\n latency: latency,\n cacheSkipCount: cacheSkipCount\n });\n } catch (e) {\n // catch over quota exceptions raised by localStorage\n }\n }\n}\n\nfunction flushTransportCache(usingTLS: boolean) {\n var storage = Runtime.getLocalStorage();\n if (storage) {\n try {\n delete storage[getTransportCacheKey(usingTLS)];\n } catch (e) {\n // catch exceptions raised by localStorage\n }\n }\n}\n","import { OneOffTimer as Timer } from '../utils/timers';\nimport Strategy from './strategy';\nimport StrategyOptions from './strategy_options';\n\n/** Runs substrategy after specified delay.\n *\n * Options:\n * - delay - time in miliseconds to delay the substrategy attempt\n *\n * @param {Strategy} strategy\n * @param {Object} options\n */\nexport default class DelayedStrategy implements Strategy {\n strategy: Strategy;\n options: { delay: number };\n\n constructor(strategy: Strategy, { delay: number }) {\n this.strategy = strategy;\n this.options = { delay: number };\n }\n\n isSupported(): boolean {\n return this.strategy.isSupported();\n }\n\n connect(minPriority: number, callback: Function) {\n var strategy = this.strategy;\n var runner;\n var timer = new Timer(this.options.delay, function() {\n runner = strategy.connect(minPriority, callback);\n });\n\n return {\n abort: function() {\n timer.ensureAborted();\n if (runner) {\n runner.abort();\n }\n },\n forceMinPriority: function(p) {\n minPriority = p;\n if (runner) {\n runner.forceMinPriority(p);\n }\n }\n };\n }\n}\n","import Strategy from './strategy';\nimport StrategyRunner from './strategy_runner';\n\n/** Proxies method calls to one of substrategies basing on the test function.\n *\n * @param {Function} test\n * @param {Strategy} trueBranch strategy used when test returns true\n * @param {Strategy} falseBranch strategy used when test returns false\n */\nexport default class IfStrategy implements Strategy {\n test: () => boolean;\n trueBranch: Strategy;\n falseBranch: Strategy;\n\n constructor(\n test: () => boolean,\n trueBranch: Strategy,\n falseBranch: Strategy\n ) {\n this.test = test;\n this.trueBranch = trueBranch;\n this.falseBranch = falseBranch;\n }\n\n isSupported(): boolean {\n var branch = this.test() ? this.trueBranch : this.falseBranch;\n return branch.isSupported();\n }\n\n connect(minPriority: number, callback: Function): StrategyRunner {\n var branch = this.test() ? this.trueBranch : this.falseBranch;\n return branch.connect(minPriority, callback);\n }\n}\n","import Strategy from './strategy';\nimport StrategyRunner from './strategy_runner';\n\n/** Launches the substrategy and terminates on the first open connection.\n *\n * @param {Strategy} strategy\n */\nexport default class FirstConnectedStrategy implements Strategy {\n strategy: Strategy;\n\n constructor(strategy: Strategy) {\n this.strategy = strategy;\n }\n\n isSupported(): boolean {\n return this.strategy.isSupported();\n }\n\n connect(minPriority: number, callback: Function): StrategyRunner {\n var runner = this.strategy.connect(minPriority, function(error, handshake) {\n if (handshake) {\n runner.abort();\n }\n callback(error, handshake);\n });\n return runner;\n }\n}\n","import * as Collections from 'core/utils/collections';\nimport TransportManager from 'core/transports/transport_manager';\nimport Strategy from 'core/strategies/strategy';\nimport SequentialStrategy from 'core/strategies/sequential_strategy';\nimport BestConnectedEverStrategy from 'core/strategies/best_connected_ever_strategy';\nimport WebSocketPrioritizedCachedStrategy, {\n TransportStrategyDictionary\n} from 'core/strategies/websocket_prioritized_cached_strategy';\nimport DelayedStrategy from 'core/strategies/delayed_strategy';\nimport IfStrategy from 'core/strategies/if_strategy';\nimport FirstConnectedStrategy from 'core/strategies/first_connected_strategy';\nimport { Config } from 'core/config';\nimport StrategyOptions from 'core/strategies/strategy_options';\n\nfunction testSupportsStrategy(strategy: Strategy) {\n return function() {\n return strategy.isSupported();\n };\n}\n\nvar getDefaultStrategy = function(\n config: Config,\n baseOptions: StrategyOptions,\n defineTransport: Function\n): Strategy {\n var definedTransports = {};\n\n function defineTransportStrategy(\n name: string,\n type: string,\n priority: number,\n options: StrategyOptions,\n manager?: TransportManager\n ) {\n var transport = defineTransport(\n config,\n name,\n type,\n priority,\n options,\n manager\n );\n\n definedTransports[name] = transport;\n\n return transport;\n }\n\n var ws_options: StrategyOptions = Object.assign({}, baseOptions, {\n hostNonTLS: config.wsHost + ':' + config.wsPort,\n hostTLS: config.wsHost + ':' + config.wssPort,\n httpPath: config.wsPath\n });\n var wss_options: StrategyOptions = Collections.extend({}, ws_options, {\n useTLS: true\n });\n var http_options: StrategyOptions = Object.assign({}, baseOptions, {\n hostNonTLS: config.httpHost + ':' + config.httpPort,\n hostTLS: config.httpHost + ':' + config.httpsPort,\n httpPath: config.httpPath\n });\n var timeouts = {\n loop: true,\n timeout: 15000,\n timeoutLimit: 60000\n };\n\n var ws_manager = new TransportManager({\n minPingDelay: 10000,\n maxPingDelay: config.activityTimeout\n });\n var streaming_manager = new TransportManager({\n lives: 2,\n minPingDelay: 10000,\n maxPingDelay: config.activityTimeout\n });\n\n var ws_transport = defineTransportStrategy(\n 'ws',\n 'ws',\n 3,\n ws_options,\n ws_manager\n );\n var wss_transport = defineTransportStrategy(\n 'wss',\n 'ws',\n 3,\n wss_options,\n ws_manager\n );\n var xhr_streaming_transport = defineTransportStrategy(\n 'xhr_streaming',\n 'xhr_streaming',\n 1,\n http_options,\n streaming_manager\n );\n var xhr_polling_transport = defineTransportStrategy(\n 'xhr_polling',\n 'xhr_polling',\n 1,\n http_options\n );\n\n var ws_loop = new SequentialStrategy([ws_transport], timeouts);\n var wss_loop = new SequentialStrategy([wss_transport], timeouts);\n var streaming_loop = new SequentialStrategy(\n [xhr_streaming_transport],\n timeouts\n );\n var polling_loop = new SequentialStrategy([xhr_polling_transport], timeouts);\n\n var http_loop = new SequentialStrategy(\n [\n new IfStrategy(\n testSupportsStrategy(streaming_loop),\n new BestConnectedEverStrategy([\n streaming_loop,\n new DelayedStrategy(polling_loop, { delay: 4000 })\n ]),\n polling_loop\n )\n ],\n timeouts\n );\n\n var wsStrategy;\n if (baseOptions.useTLS) {\n wsStrategy = new BestConnectedEverStrategy([\n ws_loop,\n new DelayedStrategy(http_loop, { delay: 2000 })\n ]);\n } else {\n wsStrategy = new BestConnectedEverStrategy([\n ws_loop,\n new DelayedStrategy(wss_loop, { delay: 2000 }),\n new DelayedStrategy(http_loop, { delay: 5000 })\n ]);\n }\n\n return new WebSocketPrioritizedCachedStrategy(\n new FirstConnectedStrategy(\n new IfStrategy(testSupportsStrategy(ws_transport), wsStrategy, http_loop)\n ),\n definedTransports,\n {\n ttl: 1800000,\n timeline: baseOptions.timeline,\n useTLS: baseOptions.useTLS\n }\n );\n};\n\nexport default getDefaultStrategy;\n","/** Initializes the transport.\n *\n * Fetches resources if needed and then transitions to initialized.\n */\nexport default function() {\n var self = this;\n\n self.timeline.info(\n self.buildTimelineMessage({\n transport: self.name + (self.options.useTLS ? 's' : '')\n })\n );\n\n if (self.hooks.isInitialized()) {\n self.changeState('initialized');\n } else {\n self.onClose();\n }\n}\n","import Runtime from 'runtime';\nimport RequestHooks from './request_hooks';\nimport Ajax from './ajax';\nimport { default as EventsDispatcher } from '../events/dispatcher';\n\nconst MAX_BUFFER_LENGTH = 256 * 1024;\n\nexport default class HTTPRequest extends EventsDispatcher {\n hooks: RequestHooks;\n method: string;\n url: string;\n position: number;\n xhr: Ajax;\n unloader: Function;\n\n constructor(hooks: RequestHooks, method: string, url: string) {\n super();\n this.hooks = hooks;\n this.method = method;\n this.url = url;\n }\n\n start(payload?: any) {\n this.position = 0;\n this.xhr = this.hooks.getRequest(this);\n\n this.unloader = () => {\n this.close();\n };\n Runtime.addUnloadListener(this.unloader);\n\n this.xhr.open(this.method, this.url, true);\n\n if (this.xhr.setRequestHeader) {\n this.xhr.setRequestHeader('Content-Type', 'application/json'); // ReactNative doesn't set this header by default.\n }\n this.xhr.send(payload);\n }\n\n close() {\n if (this.unloader) {\n Runtime.removeUnloadListener(this.unloader);\n this.unloader = null;\n }\n if (this.xhr) {\n this.hooks.abortRequest(this.xhr);\n this.xhr = null;\n }\n }\n\n onChunk(status: number, data: any) {\n while (true) {\n var chunk = this.advanceBuffer(data);\n if (chunk) {\n this.emit('chunk', { status: status, data: chunk });\n } else {\n break;\n }\n }\n if (this.isBufferTooLong(data)) {\n this.emit('buffer_too_long');\n }\n }\n\n private advanceBuffer(buffer: any[]): any {\n var unreadData = buffer.slice(this.position);\n var endOfLinePosition = unreadData.indexOf('\\n');\n\n if (endOfLinePosition !== -1) {\n this.position += endOfLinePosition + 1;\n return unreadData.slice(0, endOfLinePosition);\n } else {\n // chunk is not finished yet, don't move the buffer pointer\n return null;\n }\n }\n\n private isBufferTooLong(buffer: any): boolean {\n return this.position === buffer.length && buffer.length > MAX_BUFFER_LENGTH;\n }\n}\n","enum State {\n CONNECTING = 0,\n OPEN = 1,\n CLOSED = 3\n}\n\nexport default State;\n","import URLLocation from './url_location';\nimport State from './state';\nimport Socket from '../socket';\nimport SocketHooks from './socket_hooks';\nimport Util from '../util';\nimport Ajax from './ajax';\nimport HTTPRequest from './http_request';\nimport Runtime from 'runtime';\n\nvar autoIncrement = 1;\n\nclass HTTPSocket implements Socket {\n hooks: SocketHooks;\n session: string;\n location: URLLocation;\n readyState: State;\n stream: HTTPRequest;\n\n onopen: () => void;\n onerror: (error: any) => void;\n onclose: (closeEvent: any) => void;\n onmessage: (message: any) => void;\n onactivity: () => void;\n\n constructor(hooks: SocketHooks, url: string) {\n this.hooks = hooks;\n this.session = randomNumber(1000) + '/' + randomString(8);\n this.location = getLocation(url);\n this.readyState = State.CONNECTING;\n this.openStream();\n }\n\n send(payload: any) {\n return this.sendRaw(JSON.stringify([payload]));\n }\n\n ping() {\n this.hooks.sendHeartbeat(this);\n }\n\n close(code: any, reason: any) {\n this.onClose(code, reason, true);\n }\n\n /** For internal use only */\n sendRaw(payload: any): boolean {\n if (this.readyState === State.OPEN) {\n try {\n Runtime.createSocketRequest(\n 'POST',\n getUniqueURL(getSendURL(this.location, this.session))\n ).start(payload);\n return true;\n } catch (e) {\n return false;\n }\n } else {\n return false;\n }\n }\n\n /** For internal use only */\n reconnect() {\n this.closeStream();\n this.openStream();\n }\n\n /** For internal use only */\n onClose(code, reason, wasClean) {\n this.closeStream();\n this.readyState = State.CLOSED;\n if (this.onclose) {\n this.onclose({\n code: code,\n reason: reason,\n wasClean: wasClean\n });\n }\n }\n\n private onChunk(chunk) {\n if (chunk.status !== 200) {\n return;\n }\n if (this.readyState === State.OPEN) {\n this.onActivity();\n }\n\n var payload;\n var type = chunk.data.slice(0, 1);\n switch (type) {\n case 'o':\n payload = JSON.parse(chunk.data.slice(1) || '{}');\n this.onOpen(payload);\n break;\n case 'a':\n payload = JSON.parse(chunk.data.slice(1) || '[]');\n for (var i = 0; i < payload.length; i++) {\n this.onEvent(payload[i]);\n }\n break;\n case 'm':\n payload = JSON.parse(chunk.data.slice(1) || 'null');\n this.onEvent(payload);\n break;\n case 'h':\n this.hooks.onHeartbeat(this);\n break;\n case 'c':\n payload = JSON.parse(chunk.data.slice(1) || '[]');\n this.onClose(payload[0], payload[1], true);\n break;\n }\n }\n\n private onOpen(options) {\n if (this.readyState === State.CONNECTING) {\n if (options && options.hostname) {\n this.location.base = replaceHost(this.location.base, options.hostname);\n }\n this.readyState = State.OPEN;\n\n if (this.onopen) {\n this.onopen();\n }\n } else {\n this.onClose(1006, 'Server lost session', true);\n }\n }\n\n private onEvent(event) {\n if (this.readyState === State.OPEN && this.onmessage) {\n this.onmessage({ data: event });\n }\n }\n\n private onActivity() {\n if (this.onactivity) {\n this.onactivity();\n }\n }\n\n private onError(error) {\n if (this.onerror) {\n this.onerror(error);\n }\n }\n\n private openStream() {\n this.stream = Runtime.createSocketRequest(\n 'POST',\n getUniqueURL(this.hooks.getReceiveURL(this.location, this.session))\n );\n\n this.stream.bind('chunk', chunk => {\n this.onChunk(chunk);\n });\n this.stream.bind('finished', status => {\n this.hooks.onFinished(this, status);\n });\n this.stream.bind('buffer_too_long', () => {\n this.reconnect();\n });\n\n try {\n this.stream.start();\n } catch (error) {\n Util.defer(() => {\n this.onError(error);\n this.onClose(1006, 'Could not start streaming', false);\n });\n }\n }\n\n private closeStream() {\n if (this.stream) {\n this.stream.unbind_all();\n this.stream.close();\n this.stream = null;\n }\n }\n}\n\nfunction getLocation(url): URLLocation {\n var parts = /([^\\?]*)\\/*(\\??.*)/.exec(url);\n return {\n base: parts[1],\n queryString: parts[2]\n };\n}\n\nfunction getSendURL(url: URLLocation, session: string): string {\n return url.base + '/' + session + '/xhr_send';\n}\n\nfunction getUniqueURL(url: string): string {\n var separator = url.indexOf('?') === -1 ? '?' : '&';\n return url + separator + 't=' + +new Date() + '&n=' + autoIncrement++;\n}\n\nfunction replaceHost(url: string, hostname: string): string {\n var urlParts = /(https?:\\/\\/)([^\\/:]+)((\\/|:)?.*)/.exec(url);\n return urlParts[1] + hostname + urlParts[3];\n}\n\nfunction randomNumber(max: number): number {\n return Runtime.randomInt(max);\n}\n\nfunction randomString(length: number): string {\n var result = [];\n\n for (var i = 0; i < length; i++) {\n result.push(randomNumber(32).toString(32));\n }\n\n return result.join('');\n}\n\nexport default HTTPSocket;\n","import SocketHooks from './socket_hooks';\nimport HTTPSocket from './http_socket';\n\nvar hooks: SocketHooks = {\n getReceiveURL: function(url, session) {\n return url.base + '/' + session + '/xhr_streaming' + url.queryString;\n },\n onHeartbeat: function(socket) {\n socket.sendRaw('[]');\n },\n sendHeartbeat: function(socket) {\n socket.sendRaw('[]');\n },\n onFinished: function(socket, status) {\n socket.onClose(1006, 'Connection interrupted (' + status + ')', false);\n }\n};\n\nexport default hooks;\n","import SocketHooks from './socket_hooks';\nimport URLLocation from './url_location';\nimport HTTPSocket from './http_socket';\n\nvar hooks: SocketHooks = {\n getReceiveURL: function(url: URLLocation, session: string): string {\n return url.base + '/' + session + '/xhr' + url.queryString;\n },\n onHeartbeat: function() {\n // next HTTP request will reset server's activity timer\n },\n sendHeartbeat: function(socket) {\n socket.sendRaw('[]');\n },\n onFinished: function(socket, status) {\n if (status === 200) {\n socket.reconnect();\n } else {\n socket.onClose(1006, 'Connection interrupted (' + status + ')', false);\n }\n }\n};\n\nexport default hooks;\n","import HTTPRequest from 'core/http/http_request';\nimport RequestHooks from 'core/http/request_hooks';\nimport Ajax from 'core/http/ajax';\nimport Runtime from 'runtime';\n\nvar hooks: RequestHooks = {\n getRequest: function(socket: HTTPRequest): Ajax {\n var Constructor = Runtime.getXHRAPI();\n var xhr = new Constructor();\n xhr.onreadystatechange = xhr.onprogress = function() {\n switch (xhr.readyState) {\n case 3:\n if (xhr.responseText && xhr.responseText.length > 0) {\n socket.onChunk(xhr.status, xhr.responseText);\n }\n break;\n case 4:\n // this happens only on errors, never after calling close\n if (xhr.responseText && xhr.responseText.length > 0) {\n socket.onChunk(xhr.status, xhr.responseText);\n }\n socket.emit('finished', xhr.status);\n socket.close();\n break;\n }\n };\n return xhr;\n },\n abortRequest: function(xhr: Ajax) {\n xhr.onreadystatechange = null;\n xhr.abort();\n }\n};\n\nexport default hooks;\n","import HTTPRequest from 'core/http/http_request';\nimport HTTPSocket from 'core/http/http_socket';\nimport SocketHooks from 'core/http/socket_hooks';\nimport RequestHooks from 'core/http/request_hooks';\nimport streamingHooks from 'core/http/http_streaming_socket';\nimport pollingHooks from 'core/http/http_polling_socket';\nimport xhrHooks from './http_xhr_request';\nimport HTTPFactory from 'core/http/http_factory';\n\nvar HTTP: HTTPFactory = {\n createStreamingSocket(url: string): HTTPSocket {\n return this.createSocket(streamingHooks, url);\n },\n\n createPollingSocket(url: string): HTTPSocket {\n return this.createSocket(pollingHooks, url);\n },\n\n createSocket(hooks: SocketHooks, url: string): HTTPSocket {\n return new HTTPSocket(hooks, url);\n },\n\n createXHR(method: string, url: string): HTTPRequest {\n return this.createRequest(xhrHooks, method, url);\n },\n\n createRequest(hooks: RequestHooks, method: string, url: string): HTTPRequest {\n return new HTTPRequest(hooks, method, url);\n }\n};\n\nexport default HTTP;\n","import * as Collections from 'core/utils/collections';\nimport Transports from 'isomorphic/transports/transports';\nimport TimelineSender from 'core/timeline/timeline_sender';\nimport Ajax from 'core/http/ajax';\nimport getDefaultStrategy from './default_strategy';\nimport TransportsTable from 'core/transports/transports_table';\nimport transportConnectionInitializer from './transports/transport_connection_initializer';\nimport HTTPFactory from './http/http';\n\nvar Isomorphic: any = {\n getDefaultStrategy,\n Transports: Transports,\n transportConnectionInitializer,\n HTTPFactory,\n\n setup(PusherClass): void {\n PusherClass.ready();\n },\n\n getLocalStorage(): any {\n return undefined;\n },\n\n getClientFeatures(): any[] {\n return Collections.keys(\n Collections.filterObject({ ws: Transports.ws }, function(t) {\n return t.isSupported({});\n })\n );\n },\n\n getProtocol(): string {\n return 'http:';\n },\n\n isXHRSupported(): boolean {\n return true;\n },\n\n createSocketRequest(method: string, url: string) {\n if (this.isXHRSupported()) {\n return this.HTTPFactory.createXHR(method, url);\n } else {\n throw 'Cross-origin HTTP requests are not supported';\n }\n },\n\n createXHR(): Ajax {\n var Constructor = this.getXHRAPI();\n return new Constructor();\n },\n\n createWebSocket(url: string): any {\n var Constructor = this.getWebSocketAPI();\n return new Constructor(url);\n },\n\n addUnloadListener(listener: any) {},\n removeUnloadListener(listener: any) {}\n};\n\nexport default Isomorphic;\n","import { default as EventsDispatcher } from 'core/events/dispatcher';\nimport Reachability from 'core/reachability';\n\nexport class NetInfo extends EventsDispatcher implements Reachability {\n isOnline(): boolean {\n return true;\n }\n}\n\nexport var Network = new NetInfo();\n","import AbstractRuntime from 'runtimes/interface';\nimport { AuthTransport } from 'core/auth/auth_transports';\nimport {\n AuthRequestType,\n AuthTransportCallback,\n InternalAuthOptions\n} from 'core/auth/options';\nimport { HTTPAuthError } from 'core/errors';\n\nvar fetchAuth: AuthTransport = function(\n context: AbstractRuntime,\n query: string,\n authOptions: InternalAuthOptions,\n authRequestType: AuthRequestType,\n callback: AuthTransportCallback\n) {\n var headers = new Headers();\n headers.set('Content-Type', 'application/x-www-form-urlencoded');\n\n for (var headerName in authOptions.headers) {\n headers.set(headerName, authOptions.headers[headerName]);\n }\n\n if (authOptions.headersProvider != null) {\n const dynamicHeaders = authOptions.headersProvider();\n for (var headerName in dynamicHeaders) {\n headers.set(headerName, dynamicHeaders[headerName]);\n }\n }\n\n var body = query;\n var request = new Request(authOptions.endpoint, {\n headers,\n body,\n credentials: 'same-origin',\n method: 'POST'\n });\n\n return fetch(request)\n .then(response => {\n let { status } = response;\n if (status === 200) {\n // manually parse the json so we can provide a more helpful error in\n // failure case\n return response.text();\n }\n throw new HTTPAuthError(\n status,\n `Could not get ${authRequestType.toString()} info from your auth endpoint, status: ${status}`\n );\n })\n .then(data => {\n let parsedData;\n try {\n parsedData = JSON.parse(data);\n } catch (e) {\n throw new HTTPAuthError(\n 200,\n `JSON returned from ${authRequestType.toString()} endpoint was invalid, yet status code was 200. Data was: ${data}`\n );\n }\n callback(null, parsedData);\n })\n .catch(err => {\n callback(err, null);\n });\n};\n\nexport default fetchAuth;\n","import Logger from 'core/logger';\nimport TimelineSender from 'core/timeline/timeline_sender';\nimport * as Collections from 'core/utils/collections';\nimport Util from 'core/util';\nimport Runtime from 'runtime';\nimport TimelineTransport from 'core/timeline/timeline_transport';\n\nvar getAgent = function(sender: TimelineSender, useTLS: boolean) {\n return function(data: any, callback: Function) {\n var scheme = 'http' + (useTLS ? 's' : '') + '://';\n var url =\n scheme + (sender.host || sender.options.host) + sender.options.path;\n var query = Collections.buildQueryString(data);\n url += '/' + 2 + '?' + query;\n\n fetch(url)\n .then(response => {\n if (response.status !== 200) {\n throw `received ${response.status} from stats.pusher.com`;\n }\n return response.json();\n })\n .then(({ host }) => {\n if (host) {\n sender.host = host;\n }\n })\n .catch(err => {\n Logger.debug('TimelineSender Error: ', err);\n });\n };\n};\n\nvar fetchTimeline = {\n name: 'xhr',\n getAgent\n};\n\nexport default fetchTimeline;\n","import Isomorphic from 'isomorphic/runtime';\nimport Runtime from '../interface';\nimport { Network } from './net_info';\nimport fetchAuth from './auth/fetch_auth';\nimport { AuthTransports } from 'core/auth/auth_transports';\nimport fetchTimeline from './timeline/fetch_timeline';\n\n// Very verbose but until unavoidable until\n// TypeScript 2.1, when spread attributes will be\n// supported\nconst {\n getDefaultStrategy,\n Transports,\n setup,\n getProtocol,\n isXHRSupported,\n getLocalStorage,\n createXHR,\n createWebSocket,\n addUnloadListener,\n removeUnloadListener,\n transportConnectionInitializer,\n createSocketRequest,\n HTTPFactory\n} = Isomorphic;\n\nconst Worker: Runtime = {\n getDefaultStrategy,\n Transports,\n setup,\n getProtocol,\n isXHRSupported,\n getLocalStorage,\n createXHR,\n createWebSocket,\n addUnloadListener,\n removeUnloadListener,\n transportConnectionInitializer,\n createSocketRequest,\n HTTPFactory,\n\n TimelineTransport: fetchTimeline,\n\n getAuthorizers(): AuthTransports {\n return { ajax: fetchAuth };\n },\n\n getWebSocketAPI() {\n return WebSocket;\n },\n\n getXHRAPI() {\n return XMLHttpRequest;\n },\n\n getNetwork() {\n return Network;\n },\n\n randomInt(max: number): number {\n /**\n * Return values in the range of [0, 1[\n */\n const random = function() {\n const crypto = globalThis.crypto || globalThis['msCrypto'];\n const random = crypto.getRandomValues(new Uint32Array(1))[0];\n\n return random / 2 ** 32;\n };\n\n return Math.floor(random() * max);\n }\n};\n\nexport default Worker;\n","enum TimelineLevel {\n ERROR = 3,\n INFO = 6,\n DEBUG = 7\n}\n\nexport default TimelineLevel;\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport { default as Level } from './level';\n\nexport interface TimelineOptions {\n level?: Level;\n limit?: number;\n version?: string;\n cluster?: string;\n features?: string[];\n params?: any;\n}\n\nexport default class Timeline {\n key: string;\n session: number;\n events: any[];\n options: TimelineOptions;\n sent: number;\n uniqueID: number;\n\n constructor(key: string, session: number, options: TimelineOptions) {\n this.key = key;\n this.session = session;\n this.events = [];\n this.options = options || {};\n this.sent = 0;\n this.uniqueID = 0;\n }\n\n log(level, event) {\n if (level <= this.options.level) {\n this.events.push(\n Collections.extend({}, event, { timestamp: Util.now() })\n );\n if (this.options.limit && this.events.length > this.options.limit) {\n this.events.shift();\n }\n }\n }\n\n error(event) {\n this.log(Level.ERROR, event);\n }\n\n info(event) {\n this.log(Level.INFO, event);\n }\n\n debug(event) {\n this.log(Level.DEBUG, event);\n }\n\n isEmpty() {\n return this.events.length === 0;\n }\n\n send(sendfn, callback) {\n var data = Collections.extend(\n {\n session: this.session,\n bundle: this.sent + 1,\n key: this.key,\n lib: 'js',\n version: this.options.version,\n cluster: this.options.cluster,\n features: this.options.features,\n timeline: this.events\n },\n this.options.params\n );\n\n this.events = [];\n sendfn(data, (error, result) => {\n if (!error) {\n this.sent++;\n }\n if (callback) {\n callback(error, result);\n }\n });\n\n return true;\n }\n\n generateUniqueID(): number {\n this.uniqueID++;\n return this.uniqueID;\n }\n}\n","import Factory from '../utils/factory';\nimport Util from '../util';\nimport * as Errors from '../errors';\nimport * as Collections from '../utils/collections';\nimport Strategy from './strategy';\nimport Transport from '../transports/transport';\nimport StrategyOptions from './strategy_options';\nimport Handshake from '../connection/handshake';\n\n/** Provides a strategy interface for transports.\n *\n * @param {String} name\n * @param {Number} priority\n * @param {Class} transport\n * @param {Object} options\n */\nexport default class TransportStrategy implements Strategy {\n name: string;\n priority: number;\n transport: Transport;\n options: StrategyOptions;\n\n constructor(\n name: string,\n priority: number,\n transport: Transport,\n options: StrategyOptions\n ) {\n this.name = name;\n this.priority = priority;\n this.transport = transport;\n this.options = options || {};\n }\n\n /** Returns whether the transport is supported in the browser.\n *\n * @returns {Boolean}\n */\n isSupported(): boolean {\n return this.transport.isSupported({\n useTLS: this.options.useTLS\n });\n }\n\n /** Launches a connection attempt and returns a strategy runner.\n *\n * @param {Function} callback\n * @return {Object} strategy runner\n */\n connect(minPriority: number, callback: Function) {\n if (!this.isSupported()) {\n return failAttempt(new Errors.UnsupportedStrategy(), callback);\n } else if (this.priority < minPriority) {\n return failAttempt(new Errors.TransportPriorityTooLow(), callback);\n }\n\n var connected = false;\n var transport = this.transport.createConnection(\n this.name,\n this.priority,\n this.options.key,\n this.options\n );\n var handshake = null;\n\n var onInitialized = function() {\n transport.unbind('initialized', onInitialized);\n transport.connect();\n };\n var onOpen = function() {\n handshake = Factory.createHandshake(transport, function(result) {\n connected = true;\n unbindListeners();\n callback(null, result);\n });\n };\n var onError = function(error) {\n unbindListeners();\n callback(error);\n };\n var onClosed = function() {\n unbindListeners();\n var serializedTransport;\n\n // The reason for this try/catch block is that on React Native\n // the WebSocket object is circular. Therefore transport.socket will\n // throw errors upon stringification. Collections.safeJSONStringify\n // discards circular references when serializing.\n serializedTransport = Collections.safeJSONStringify(transport);\n callback(new Errors.TransportClosed(serializedTransport));\n };\n\n var unbindListeners = function() {\n transport.unbind('initialized', onInitialized);\n transport.unbind('open', onOpen);\n transport.unbind('error', onError);\n transport.unbind('closed', onClosed);\n };\n\n transport.bind('initialized', onInitialized);\n transport.bind('open', onOpen);\n transport.bind('error', onError);\n transport.bind('closed', onClosed);\n\n // connect will be called automatically after initialization\n transport.initialize();\n\n return {\n abort: () => {\n if (connected) {\n return;\n }\n unbindListeners();\n if (handshake) {\n handshake.close();\n } else {\n transport.close();\n }\n },\n forceMinPriority: p => {\n if (connected) {\n return;\n }\n if (this.priority < p) {\n if (handshake) {\n handshake.close();\n } else {\n transport.close();\n }\n }\n }\n };\n }\n}\n\nfunction failAttempt(error: Error, callback: Function) {\n Util.defer(function() {\n callback(error);\n });\n return {\n abort: function() {},\n forceMinPriority: function() {}\n };\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport TransportManager from '../transports/transport_manager';\nimport * as Errors from '../errors';\nimport Strategy from './strategy';\nimport TransportStrategy from './transport_strategy';\nimport StrategyOptions from '../strategies/strategy_options';\nimport { Config } from '../config';\nimport Runtime from 'runtime';\n\nconst { Transports } = Runtime;\n\nexport var defineTransport = function(\n config: Config,\n name: string,\n type: string,\n priority: number,\n options: StrategyOptions,\n manager?: TransportManager\n): Strategy {\n var transportClass = Transports[type];\n if (!transportClass) {\n throw new Errors.UnsupportedTransport(type);\n }\n\n var enabled =\n (!config.enabledTransports ||\n Collections.arrayIndexOf(config.enabledTransports, name) !== -1) &&\n (!config.disabledTransports ||\n Collections.arrayIndexOf(config.disabledTransports, name) === -1);\n\n var transport;\n if (enabled) {\n options = Object.assign(\n { ignoreNullOrigin: config.ignoreNullOrigin },\n options\n );\n\n transport = new TransportStrategy(\n name,\n priority,\n manager ? manager.getAssistant(transportClass) : transportClass,\n options\n );\n } else {\n transport = UnsupportedStrategy;\n }\n\n return transport;\n};\n\nvar UnsupportedStrategy: Strategy = {\n isSupported: function() {\n return false;\n },\n connect: function(_, callback) {\n var deferred = Util.defer(function() {\n callback(new Errors.UnsupportedStrategy());\n });\n return {\n abort: function() {\n deferred.ensureAborted();\n },\n forceMinPriority: function() {}\n };\n }\n};\n","import ConnectionManager from './connection/connection_manager';\nimport {\n ChannelAuthorizationOptions,\n UserAuthenticationOptions\n} from './auth/options';\nimport {\n ChannelAuthorizerGenerator,\n DeprecatedAuthOptions\n} from './auth/deprecated_channel_authorizer';\nimport { AuthTransport, Transport } from './config';\nimport * as nacl from 'tweetnacl';\nimport Logger from './logger';\n\nexport interface Options {\n activityTimeout?: number;\n\n auth?: DeprecatedAuthOptions; // DEPRECATED use channelAuthorization instead\n authEndpoint?: string; // DEPRECATED use channelAuthorization instead\n authTransport?: AuthTransport; // DEPRECATED use channelAuthorization instead\n authorizer?: ChannelAuthorizerGenerator; // DEPRECATED use channelAuthorization instead\n\n channelAuthorization?: ChannelAuthorizationOptions;\n userAuthentication?: UserAuthenticationOptions;\n\n cluster: string;\n enableStats?: boolean;\n disableStats?: boolean;\n disabledTransports?: Transport[];\n enabledTransports?: Transport[];\n forceTLS?: boolean;\n httpHost?: string;\n httpPath?: string;\n httpPort?: number;\n httpsPort?: number;\n ignoreNullOrigin?: boolean;\n nacl?: nacl;\n pongTimeout?: number;\n statsHost?: string;\n timelineParams?: any;\n unavailableTimeout?: number;\n wsHost?: string;\n wsPath?: string;\n wsPort?: number;\n wssPort?: number;\n}\n\nexport interface ClusterOptions {\n appKey: string;\n cluster: string;\n}\n\nexport function validateOptions(options) {\n if (options == null) {\n throw 'You must pass an options object';\n }\n if (options.cluster == null) {\n throw 'Options object must provide a cluster';\n }\n if ('disableStats' in options) {\n Logger.warn(\n 'The disableStats option is deprecated in favor of enableStats'\n );\n }\n}\n","export enum AuthRequestType {\n UserAuthentication = 'user-authentication',\n ChannelAuthorization = 'channel-authorization'\n}\n\nexport interface ChannelAuthorizationData {\n auth: string;\n channel_data?: string;\n shared_secret?: string;\n}\n\nexport type ChannelAuthorizationCallback = (\n error: Error | null,\n authData: ChannelAuthorizationData | null\n) => void;\n\nexport interface ChannelAuthorizationRequestParams {\n socketId: string;\n channelName: string;\n}\n\nexport interface ChannelAuthorizationHandler {\n (\n params: ChannelAuthorizationRequestParams,\n callback: ChannelAuthorizationCallback\n ): void;\n}\n\nexport interface UserAuthenticationData {\n auth: string;\n user_data: string;\n}\n\nexport type UserAuthenticationCallback = (\n error: Error | null,\n authData: UserAuthenticationData | null\n) => void;\n\nexport interface UserAuthenticationRequestParams {\n socketId: string;\n}\n\nexport interface UserAuthenticationHandler {\n (\n params: UserAuthenticationRequestParams,\n callback: UserAuthenticationCallback\n ): void;\n}\n\nexport type AuthTransportCallback =\n | ChannelAuthorizationCallback\n | UserAuthenticationCallback;\n\nexport interface AuthOptionsT {\n transport: 'ajax' | 'jsonp';\n endpoint: string;\n params?: any;\n headers?: any;\n paramsProvider?: () => any;\n headersProvider?: () => any;\n customHandler?: AuthHandler;\n}\n\nexport declare type UserAuthenticationOptions = AuthOptionsT<\n UserAuthenticationHandler\n>;\nexport declare type ChannelAuthorizationOptions = AuthOptionsT<\n ChannelAuthorizationHandler\n>;\n\nexport interface InternalAuthOptions {\n transport: 'ajax' | 'jsonp';\n endpoint: string;\n params?: any;\n headers?: any;\n paramsProvider?: () => any;\n headersProvider?: () => any;\n}\n","import {\n UserAuthenticationCallback,\n InternalAuthOptions,\n UserAuthenticationHandler,\n UserAuthenticationRequestParams,\n AuthRequestType\n} from './options';\n\nimport Runtime from 'runtime';\n\nconst composeChannelQuery = (\n params: UserAuthenticationRequestParams,\n authOptions: InternalAuthOptions\n) => {\n var query = 'socket_id=' + encodeURIComponent(params.socketId);\n\n for (var key in authOptions.params) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(authOptions.params[key]);\n }\n\n if (authOptions.paramsProvider != null) {\n let dynamicParams = authOptions.paramsProvider();\n for (var key in dynamicParams) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(dynamicParams[key]);\n }\n }\n\n return query;\n};\n\nconst UserAuthenticator = (\n authOptions: InternalAuthOptions\n): UserAuthenticationHandler => {\n if (typeof Runtime.getAuthorizers()[authOptions.transport] === 'undefined') {\n throw `'${authOptions.transport}' is not a recognized auth transport`;\n }\n\n return (\n params: UserAuthenticationRequestParams,\n callback: UserAuthenticationCallback\n ) => {\n const query = composeChannelQuery(params, authOptions);\n\n Runtime.getAuthorizers()[authOptions.transport](\n Runtime,\n query,\n authOptions,\n AuthRequestType.UserAuthentication,\n callback\n );\n };\n};\n\nexport default UserAuthenticator;\n","import {\n AuthRequestType,\n InternalAuthOptions,\n ChannelAuthorizationHandler,\n ChannelAuthorizationRequestParams,\n ChannelAuthorizationCallback\n} from './options';\n\nimport Runtime from 'runtime';\n\nconst composeChannelQuery = (\n params: ChannelAuthorizationRequestParams,\n authOptions: InternalAuthOptions\n) => {\n var query = 'socket_id=' + encodeURIComponent(params.socketId);\n\n query += '&channel_name=' + encodeURIComponent(params.channelName);\n\n for (var key in authOptions.params) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(authOptions.params[key]);\n }\n\n if (authOptions.paramsProvider != null) {\n let dynamicParams = authOptions.paramsProvider();\n for (var key in dynamicParams) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(dynamicParams[key]);\n }\n }\n\n return query;\n};\n\nconst ChannelAuthorizer = (\n authOptions: InternalAuthOptions\n): ChannelAuthorizationHandler => {\n if (typeof Runtime.getAuthorizers()[authOptions.transport] === 'undefined') {\n throw `'${authOptions.transport}' is not a recognized auth transport`;\n }\n\n return (\n params: ChannelAuthorizationRequestParams,\n callback: ChannelAuthorizationCallback\n ) => {\n const query = composeChannelQuery(params, authOptions);\n\n Runtime.getAuthorizers()[authOptions.transport](\n Runtime,\n query,\n authOptions,\n AuthRequestType.ChannelAuthorization,\n callback\n );\n };\n};\n\nexport default ChannelAuthorizer;\n","import Channel from '../channels/channel';\nimport {\n ChannelAuthorizationCallback,\n ChannelAuthorizationHandler,\n ChannelAuthorizationRequestParams,\n InternalAuthOptions\n} from './options';\n\nexport interface DeprecatedChannelAuthorizer {\n authorize(socketId: string, callback: ChannelAuthorizationCallback): void;\n}\n\nexport interface ChannelAuthorizerGenerator {\n (\n channel: Channel,\n options: DeprecatedAuthorizerOptions\n ): DeprecatedChannelAuthorizer;\n}\n\nexport interface DeprecatedAuthOptions {\n params?: any;\n headers?: any;\n}\n\nexport interface DeprecatedAuthorizerOptions {\n authTransport: 'ajax' | 'jsonp';\n authEndpoint: string;\n auth?: DeprecatedAuthOptions;\n}\n\nexport const ChannelAuthorizerProxy = (\n pusher,\n authOptions: InternalAuthOptions,\n channelAuthorizerGenerator: ChannelAuthorizerGenerator\n): ChannelAuthorizationHandler => {\n const deprecatedAuthorizerOptions: DeprecatedAuthorizerOptions = {\n authTransport: authOptions.transport,\n authEndpoint: authOptions.endpoint,\n auth: {\n params: authOptions.params,\n headers: authOptions.headers\n }\n };\n return (\n params: ChannelAuthorizationRequestParams,\n callback: ChannelAuthorizationCallback\n ) => {\n const channel = pusher.channel(params.channelName);\n // This line creates a new channel authorizer every time.\n // In the past, this was only done once per channel and reused.\n // We can do that again if we want to keep this behavior intact.\n const channelAuthorizer: DeprecatedChannelAuthorizer = channelAuthorizerGenerator(\n channel,\n deprecatedAuthorizerOptions\n );\n channelAuthorizer.authorize(params.socketId, callback);\n };\n};\n","import { Options } from './options';\nimport Defaults from './defaults';\nimport {\n ChannelAuthorizationHandler,\n UserAuthenticationHandler,\n ChannelAuthorizationOptions\n} from './auth/options';\nimport UserAuthenticator from './auth/user_authenticator';\nimport ChannelAuthorizer from './auth/channel_authorizer';\nimport { ChannelAuthorizerProxy } from './auth/deprecated_channel_authorizer';\nimport Runtime from 'runtime';\nimport * as nacl from 'tweetnacl';\n\nexport type AuthTransport = 'ajax' | 'jsonp';\nexport type Transport =\n | 'ws'\n | 'wss'\n | 'xhr_streaming'\n | 'xhr_polling'\n | 'sockjs';\n\nexport interface Config {\n // these are all 'required' config parameters, it's not necessary for the user\n // to set them, but they have configured defaults.\n activityTimeout: number;\n enableStats: boolean;\n httpHost: string;\n httpPath: string;\n httpPort: number;\n httpsPort: number;\n pongTimeout: number;\n statsHost: string;\n unavailableTimeout: number;\n useTLS: boolean;\n wsHost: string;\n wsPath: string;\n wsPort: number;\n wssPort: number;\n userAuthenticator: UserAuthenticationHandler;\n channelAuthorizer: ChannelAuthorizationHandler;\n\n // these are all optional parameters or overrrides. The customer can set these\n // but it's not strictly necessary\n forceTLS?: boolean;\n cluster?: string;\n disabledTransports?: Transport[];\n enabledTransports?: Transport[];\n ignoreNullOrigin?: boolean;\n nacl?: nacl;\n timelineParams?: any;\n}\n\n// getConfig mainly sets the defaults for the options that are not provided\nexport function getConfig(opts: Options, pusher): Config {\n let config: Config = {\n activityTimeout: opts.activityTimeout || Defaults.activityTimeout,\n cluster: opts.cluster,\n httpPath: opts.httpPath || Defaults.httpPath,\n httpPort: opts.httpPort || Defaults.httpPort,\n httpsPort: opts.httpsPort || Defaults.httpsPort,\n pongTimeout: opts.pongTimeout || Defaults.pongTimeout,\n statsHost: opts.statsHost || Defaults.stats_host,\n unavailableTimeout: opts.unavailableTimeout || Defaults.unavailableTimeout,\n wsPath: opts.wsPath || Defaults.wsPath,\n wsPort: opts.wsPort || Defaults.wsPort,\n wssPort: opts.wssPort || Defaults.wssPort,\n\n enableStats: getEnableStatsConfig(opts),\n httpHost: getHttpHost(opts),\n useTLS: shouldUseTLS(opts),\n wsHost: getWebsocketHost(opts),\n\n userAuthenticator: buildUserAuthenticator(opts),\n channelAuthorizer: buildChannelAuthorizer(opts, pusher)\n };\n\n if ('disabledTransports' in opts)\n config.disabledTransports = opts.disabledTransports;\n if ('enabledTransports' in opts)\n config.enabledTransports = opts.enabledTransports;\n if ('ignoreNullOrigin' in opts)\n config.ignoreNullOrigin = opts.ignoreNullOrigin;\n if ('timelineParams' in opts) config.timelineParams = opts.timelineParams;\n if ('nacl' in opts) {\n config.nacl = opts.nacl;\n }\n\n return config;\n}\n\nfunction getHttpHost(opts: Options): string {\n if (opts.httpHost) {\n return opts.httpHost;\n }\n if (opts.cluster) {\n return `sockjs-${opts.cluster}.pusher.com`;\n }\n return Defaults.httpHost;\n}\n\nfunction getWebsocketHost(opts: Options): string {\n if (opts.wsHost) {\n return opts.wsHost;\n }\n return getWebsocketHostFromCluster(opts.cluster);\n}\n\nfunction getWebsocketHostFromCluster(cluster: string): string {\n return `ws-${cluster}.pusher.com`;\n}\n\nfunction shouldUseTLS(opts: Options): boolean {\n if (Runtime.getProtocol() === 'https:') {\n return true;\n } else if (opts.forceTLS === false) {\n return false;\n }\n return true;\n}\n\n// if enableStats is set take the value\n// if disableStats is set take the inverse\n// otherwise default to false\nfunction getEnableStatsConfig(opts: Options): boolean {\n if ('enableStats' in opts) {\n return opts.enableStats;\n }\n if ('disableStats' in opts) {\n return !opts.disableStats;\n }\n return false;\n}\n\nfunction buildUserAuthenticator(opts: Options): UserAuthenticationHandler {\n const userAuthentication = {\n ...Defaults.userAuthentication,\n ...opts.userAuthentication\n };\n if (\n 'customHandler' in userAuthentication &&\n userAuthentication['customHandler'] != null\n ) {\n return userAuthentication['customHandler'];\n }\n\n return UserAuthenticator(userAuthentication);\n}\n\nfunction buildChannelAuth(opts: Options, pusher): ChannelAuthorizationOptions {\n let channelAuthorization: ChannelAuthorizationOptions;\n if ('channelAuthorization' in opts) {\n channelAuthorization = {\n ...Defaults.channelAuthorization,\n ...opts.channelAuthorization\n };\n } else {\n channelAuthorization = {\n transport: opts.authTransport || Defaults.authTransport,\n endpoint: opts.authEndpoint || Defaults.authEndpoint\n };\n if ('auth' in opts) {\n if ('params' in opts.auth) channelAuthorization.params = opts.auth.params;\n if ('headers' in opts.auth)\n channelAuthorization.headers = opts.auth.headers;\n }\n if ('authorizer' in opts)\n channelAuthorization.customHandler = ChannelAuthorizerProxy(\n pusher,\n channelAuthorization,\n opts.authorizer\n );\n }\n return channelAuthorization;\n}\n\nfunction buildChannelAuthorizer(\n opts: Options,\n pusher\n): ChannelAuthorizationHandler {\n const channelAuthorization = buildChannelAuth(opts, pusher);\n if (\n 'customHandler' in channelAuthorization &&\n channelAuthorization['customHandler'] != null\n ) {\n return channelAuthorization['customHandler'];\n }\n\n return ChannelAuthorizer(channelAuthorization);\n}\n","import Logger from './logger';\nimport Pusher from './pusher';\nimport EventsDispatcher from './events/dispatcher';\n\nexport default class WatchlistFacade extends EventsDispatcher {\n private pusher: Pusher;\n\n public constructor(pusher: Pusher) {\n super(function(eventName, data) {\n Logger.debug(`No callbacks on watchlist events for ${eventName}`);\n });\n\n this.pusher = pusher;\n this.bindWatchlistInternalEvent();\n }\n\n handleEvent(pusherEvent) {\n pusherEvent.data.events.forEach(watchlistEvent => {\n this.emit(watchlistEvent.name, watchlistEvent);\n });\n }\n\n private bindWatchlistInternalEvent() {\n this.pusher.connection.bind('message', pusherEvent => {\n var eventName = pusherEvent.event;\n if (eventName === 'pusher_internal:watchlist_events') {\n this.handleEvent(pusherEvent);\n }\n });\n }\n}\n","function flatPromise() {\n let resolve, reject;\n const promise = new Promise((res, rej) => {\n resolve = res;\n reject = rej;\n });\n return { promise, resolve, reject };\n}\n\nexport default flatPromise;\n","import Pusher from './pusher';\nimport Logger from './logger';\nimport {\n UserAuthenticationData,\n UserAuthenticationCallback\n} from './auth/options';\nimport Channel from './channels/channel';\nimport WatchlistFacade from './watchlist';\nimport EventsDispatcher from './events/dispatcher';\nimport flatPromise from './utils/flat_promise';\n\nexport default class UserFacade extends EventsDispatcher {\n pusher: Pusher;\n signin_requested: boolean = false;\n user_data: any = null;\n serverToUserChannel: Channel = null;\n signinDonePromise: Promise = null;\n watchlist: WatchlistFacade;\n private _signinDoneResolve: Function = null;\n\n public constructor(pusher: Pusher) {\n super(function(eventName, data) {\n Logger.debug('No callbacks on user for ' + eventName);\n });\n this.pusher = pusher;\n this.pusher.connection.bind('state_change', ({ previous, current }) => {\n if (previous !== 'connected' && current === 'connected') {\n this._signin();\n }\n if (previous === 'connected' && current !== 'connected') {\n this._cleanup();\n this._newSigninPromiseIfNeeded();\n }\n });\n\n this.watchlist = new WatchlistFacade(pusher);\n\n this.pusher.connection.bind('message', event => {\n var eventName = event.event;\n if (eventName === 'pusher:signin_success') {\n this._onSigninSuccess(event.data);\n }\n if (\n this.serverToUserChannel &&\n this.serverToUserChannel.name === event.channel\n ) {\n this.serverToUserChannel.handleEvent(event);\n }\n });\n }\n\n public signin() {\n if (this.signin_requested) {\n return;\n }\n\n this.signin_requested = true;\n this._signin();\n }\n\n private _signin() {\n if (!this.signin_requested) {\n return;\n }\n\n this._newSigninPromiseIfNeeded();\n\n if (this.pusher.connection.state !== 'connected') {\n // Signin will be attempted when the connection is connected\n return;\n }\n\n this.pusher.config.userAuthenticator(\n {\n socketId: this.pusher.connection.socket_id\n },\n this._onAuthorize\n );\n }\n\n private _onAuthorize: UserAuthenticationCallback = (\n err,\n authData: UserAuthenticationData\n ) => {\n if (err) {\n Logger.warn(`Error during signin: ${err}`);\n this._cleanup();\n return;\n }\n\n this.pusher.send_event('pusher:signin', {\n auth: authData.auth,\n user_data: authData.user_data\n });\n\n // Later when we get pusher:singin_success event, the user will be marked as signed in\n };\n\n private _onSigninSuccess(data: any) {\n try {\n this.user_data = JSON.parse(data.user_data);\n } catch (e) {\n Logger.error(`Failed parsing user data after signin: ${data.user_data}`);\n this._cleanup();\n return;\n }\n\n if (typeof this.user_data.id !== 'string' || this.user_data.id === '') {\n Logger.error(\n `user_data doesn't contain an id. user_data: ${this.user_data}`\n );\n this._cleanup();\n return;\n }\n\n // Signin succeeded\n this._signinDoneResolve();\n this._subscribeChannels();\n }\n\n private _subscribeChannels() {\n const ensure_subscribed = channel => {\n if (channel.subscriptionPending && channel.subscriptionCancelled) {\n channel.reinstateSubscription();\n } else if (\n !channel.subscriptionPending &&\n this.pusher.connection.state === 'connected'\n ) {\n channel.subscribe();\n }\n };\n\n this.serverToUserChannel = new Channel(\n `#server-to-user-${this.user_data.id}`,\n this.pusher\n );\n this.serverToUserChannel.bind_global((eventName, data) => {\n if (\n eventName.indexOf('pusher_internal:') === 0 ||\n eventName.indexOf('pusher:') === 0\n ) {\n // ignore internal events\n return;\n }\n this.emit(eventName, data);\n });\n ensure_subscribed(this.serverToUserChannel);\n }\n\n private _cleanup() {\n this.user_data = null;\n if (this.serverToUserChannel) {\n this.serverToUserChannel.unbind_all();\n this.serverToUserChannel.disconnect();\n this.serverToUserChannel = null;\n }\n\n if (this.signin_requested) {\n // If signin is in progress and cleanup is called,\n // Mark the current signin process as done.\n this._signinDoneResolve();\n }\n }\n\n private _newSigninPromiseIfNeeded() {\n if (!this.signin_requested) {\n return;\n }\n\n // If there is a promise and it is not resolved, return without creating a new one.\n if (this.signinDonePromise && !(this.signinDonePromise as any).done) {\n return;\n }\n\n // This promise is never rejected.\n // It gets resolved when the signin process is done whether it failed or succeeded\n const { promise, resolve, reject: _ } = flatPromise();\n (promise as any).done = false;\n const setDone = () => {\n (promise as any).done = true;\n };\n promise.then(setDone).catch(setDone);\n this.signinDonePromise = promise;\n this._signinDoneResolve = resolve;\n }\n}\n","import AbstractRuntime from '../runtimes/interface';\nimport Runtime from 'runtime';\nimport * as Collections from './utils/collections';\nimport Channels from './channels/channels';\nimport Channel from './channels/channel';\nimport { default as EventsDispatcher } from './events/dispatcher';\nimport Timeline from './timeline/timeline';\nimport TimelineSender from './timeline/timeline_sender';\nimport TimelineLevel from './timeline/level';\nimport { defineTransport } from './strategies/strategy_builder';\nimport ConnectionManager from './connection/connection_manager';\nimport { PeriodicTimer } from './utils/timers';\nimport Defaults from './defaults';\nimport Logger from './logger';\nimport Factory from './utils/factory';\nimport { Options, ClusterOptions, validateOptions } from './options';\nimport { Config, getConfig } from './config';\nimport StrategyOptions from './strategies/strategy_options';\nimport UserFacade from './user';\n\nexport default class Pusher {\n /* STATIC PROPERTIES */\n static instances: Pusher[] = [];\n static isReady: boolean = false;\n static logToConsole: boolean = false;\n\n // for jsonp\n static Runtime: AbstractRuntime = Runtime;\n static ScriptReceivers: any = (Runtime).ScriptReceivers;\n static DependenciesReceivers: any = (Runtime).DependenciesReceivers;\n static auth_callbacks: any = (Runtime).auth_callbacks;\n\n static ready() {\n Pusher.isReady = true;\n for (var i = 0, l = Pusher.instances.length; i < l; i++) {\n Pusher.instances[i].connect();\n }\n }\n\n static log: (message: any) => void;\n\n private static getClientFeatures(): string[] {\n return Collections.keys(\n Collections.filterObject({ ws: Runtime.Transports.ws }, function(t) {\n return t.isSupported({});\n })\n );\n }\n\n /* INSTANCE PROPERTIES */\n key: string;\n options: Options;\n config: Config;\n channels: Channels;\n global_emitter: EventsDispatcher;\n sessionID: number;\n timeline: Timeline;\n timelineSender: TimelineSender;\n connection: ConnectionManager;\n timelineSenderTimer: PeriodicTimer;\n user: UserFacade;\n constructor(app_key: string, options: Options) {\n checkAppKey(app_key);\n validateOptions(options);\n this.key = app_key;\n this.config = getConfig(options, this);\n\n this.channels = Factory.createChannels();\n this.global_emitter = new EventsDispatcher();\n this.sessionID = Runtime.randomInt(1000000000);\n\n this.timeline = new Timeline(this.key, this.sessionID, {\n cluster: this.config.cluster,\n features: Pusher.getClientFeatures(),\n params: this.config.timelineParams || {},\n limit: 50,\n level: TimelineLevel.INFO,\n version: Defaults.VERSION\n });\n if (this.config.enableStats) {\n this.timelineSender = Factory.createTimelineSender(this.timeline, {\n host: this.config.statsHost,\n path: '/timeline/v2/' + Runtime.TimelineTransport.name\n });\n }\n\n var getStrategy = (options: StrategyOptions) => {\n return Runtime.getDefaultStrategy(this.config, options, defineTransport);\n };\n\n this.connection = Factory.createConnectionManager(this.key, {\n getStrategy: getStrategy,\n timeline: this.timeline,\n activityTimeout: this.config.activityTimeout,\n pongTimeout: this.config.pongTimeout,\n unavailableTimeout: this.config.unavailableTimeout,\n useTLS: Boolean(this.config.useTLS)\n });\n\n this.connection.bind('connected', () => {\n this.subscribeAll();\n if (this.timelineSender) {\n this.timelineSender.send(this.connection.isUsingTLS());\n }\n });\n\n this.connection.bind('message', event => {\n var eventName = event.event;\n var internal = eventName.indexOf('pusher_internal:') === 0;\n if (event.channel) {\n var channel = this.channel(event.channel);\n if (channel) {\n channel.handleEvent(event);\n }\n }\n // Emit globally [deprecated]\n if (!internal) {\n this.global_emitter.emit(event.event, event.data);\n }\n });\n this.connection.bind('connecting', () => {\n this.channels.disconnect();\n });\n this.connection.bind('disconnected', () => {\n this.channels.disconnect();\n });\n this.connection.bind('error', err => {\n Logger.warn(err);\n });\n\n Pusher.instances.push(this);\n this.timeline.info({ instances: Pusher.instances.length });\n\n this.user = new UserFacade(this);\n\n if (Pusher.isReady) {\n this.connect();\n }\n }\n\n /**\n * Allows you to switch Pusher cluster without\n * losing all the channels/subscription binding\n * as this is internally managed by the SDK.\n */\n switchCluster(options: ClusterOptions) {\n const { appKey, cluster } = options;\n this.key = appKey;\n this.options = { ...this.options, cluster };\n this.config = getConfig(this.options, this);\n this.connection.switchCluster(this.key);\n }\n\n channel(name: string): Channel {\n return this.channels.find(name);\n }\n\n allChannels(): Channel[] {\n return this.channels.all();\n }\n\n connect() {\n this.connection.connect();\n\n if (this.timelineSender) {\n if (!this.timelineSenderTimer) {\n var usingTLS = this.connection.isUsingTLS();\n var timelineSender = this.timelineSender;\n this.timelineSenderTimer = new PeriodicTimer(60000, function() {\n timelineSender.send(usingTLS);\n });\n }\n }\n }\n\n disconnect() {\n this.connection.disconnect();\n\n if (this.timelineSenderTimer) {\n this.timelineSenderTimer.ensureAborted();\n this.timelineSenderTimer = null;\n }\n }\n\n bind(event_name: string, callback: Function, context?: any): Pusher {\n this.global_emitter.bind(event_name, callback, context);\n return this;\n }\n\n unbind(event_name?: string, callback?: Function, context?: any): Pusher {\n this.global_emitter.unbind(event_name, callback, context);\n return this;\n }\n\n bind_global(callback: Function): Pusher {\n this.global_emitter.bind_global(callback);\n return this;\n }\n\n unbind_global(callback?: Function): Pusher {\n this.global_emitter.unbind_global(callback);\n return this;\n }\n\n unbind_all(callback?: Function): Pusher {\n this.global_emitter.unbind_all();\n return this;\n }\n\n subscribeAll() {\n var channelName;\n for (channelName in this.channels.channels) {\n if (this.channels.channels.hasOwnProperty(channelName)) {\n this.subscribe(channelName);\n }\n }\n }\n\n subscribe(channel_name: string) {\n var channel = this.channels.add(channel_name, this);\n if (channel.subscriptionPending && channel.subscriptionCancelled) {\n channel.reinstateSubscription();\n } else if (\n !channel.subscriptionPending &&\n this.connection.state === 'connected'\n ) {\n channel.subscribe();\n }\n return channel;\n }\n\n unsubscribe(channel_name: string) {\n var channel = this.channels.find(channel_name);\n if (channel && channel.subscriptionPending) {\n channel.cancelSubscription();\n } else {\n channel = this.channels.remove(channel_name);\n if (channel && channel.subscribed) {\n channel.unsubscribe();\n }\n }\n }\n\n send_event(event_name: string, data: any, channel?: string) {\n return this.connection.send_event(event_name, data, channel);\n }\n\n shouldUseTLS(): boolean {\n return this.config.useTLS;\n }\n\n signin() {\n this.user.signin();\n }\n}\n\nfunction checkAppKey(key) {\n if (key === null || key === undefined) {\n throw 'You must pass your app key when you instantiate Pusher.';\n }\n}\n\nRuntime.setup(Pusher);\n","import Pusher from './pusher';\nimport { Options, validateOptions } from './options';\nimport * as nacl from 'tweetnacl';\n\nexport default class PusherWithEncryption extends Pusher {\n constructor(app_key: string, options: Options) {\n Pusher.logToConsole = PusherWithEncryption.logToConsole;\n Pusher.log = PusherWithEncryption.log;\n\n validateOptions(options);\n options.nacl = nacl;\n super(app_key, options);\n }\n}\n"],"sourceRoot":""} \ No newline at end of file diff --git a/dist/worker/pusher-with-encryption.worker.min.js b/dist/worker/pusher-with-encryption.worker.min.js index f83b992a3..6513b89c1 100644 --- a/dist/worker/pusher-with-encryption.worker.min.js +++ b/dist/worker/pusher-with-encryption.worker.min.js @@ -1,9 +1,9 @@ /*! - * Pusher JavaScript Library v8.4.0 + * Pusher JavaScript Library v8.4.0-rc1 * https://pusher.com/ * * Copyright 2020, Pusher * Released under the MIT licence. */ -!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.Pusher=e():t.Pusher=e()}(this,(function(){return function(t){var e={};function n(r){if(e[r])return e[r].exports;var i=e[r]={i:r,l:!1,exports:{}};return t[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)n.d(r,i,function(e){return t[e]}.bind(null,i));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=3)}([function(t,e,n){"use strict";var r,i=this&&this.__extends||(r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)},function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)});Object.defineProperty(e,"__esModule",{value:!0});var s=function(){function t(t){void 0===t&&(t="="),this._paddingCharacter=t}return t.prototype.encodedLength=function(t){return this._paddingCharacter?(t+2)/3*4|0:(8*t+5)/6|0},t.prototype.encode=function(t){for(var e="",n=0;n>>18&63),e+=this._encodeByte(r>>>12&63),e+=this._encodeByte(r>>>6&63),e+=this._encodeByte(r>>>0&63)}var i=t.length-n;if(i>0){r=t[n]<<16|(2===i?t[n+1]<<8:0);e+=this._encodeByte(r>>>18&63),e+=this._encodeByte(r>>>12&63),e+=2===i?this._encodeByte(r>>>6&63):this._paddingCharacter||"",e+=this._paddingCharacter||""}return e},t.prototype.maxDecodedLength=function(t){return this._paddingCharacter?t/4*3|0:(6*t+7)/8|0},t.prototype.decodedLength=function(t){return this.maxDecodedLength(t.length-this._getPaddingLength(t))},t.prototype.decode=function(t){if(0===t.length)return new Uint8Array(0);for(var e=this._getPaddingLength(t),n=t.length-e,r=new Uint8Array(this.maxDecodedLength(n)),i=0,s=0,o=0,a=0,h=0,c=0,u=0;s>>4,r[i++]=h<<4|c>>>2,r[i++]=c<<6|u,o|=256&a,o|=256&h,o|=256&c,o|=256&u;if(s>>4,o|=256&a,o|=256&h),s>>2,o|=256&c),s>>8&6,e+=51-t>>>8&-75,e+=61-t>>>8&-15,e+=62-t>>>8&3,String.fromCharCode(e)},t.prototype._decodeChar=function(t){var e=256;return e+=(42-t&t-44)>>>8&-256+t-43+62,e+=(46-t&t-48)>>>8&-256+t-47+63,e+=(47-t&t-58)>>>8&-256+t-48+52,e+=(64-t&t-91)>>>8&-256+t-65+0,e+=(96-t&t-123)>>>8&-256+t-97+26},t.prototype._getPaddingLength=function(t){var e=0;if(this._paddingCharacter){for(var n=t.length-1;n>=0&&t[n]===this._paddingCharacter;n--)e++;if(t.length<4||e>2)throw new Error("Base64Coder: incorrect padding")}return e},t}();e.Coder=s;var o=new s;e.encode=function(t){return o.encode(t)},e.decode=function(t){return o.decode(t)};var a=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return i(e,t),e.prototype._encodeByte=function(t){var e=t;return e+=65,e+=25-t>>>8&6,e+=51-t>>>8&-75,e+=61-t>>>8&-13,e+=62-t>>>8&49,String.fromCharCode(e)},e.prototype._decodeChar=function(t){var e=256;return e+=(44-t&t-46)>>>8&-256+t-45+62,e+=(94-t&t-96)>>>8&-256+t-95+63,e+=(47-t&t-58)>>>8&-256+t-48+52,e+=(64-t&t-91)>>>8&-256+t-65+0,e+=(96-t&t-123)>>>8&-256+t-97+26},e}(s);e.URLSafeCoder=a;var h=new a;e.encodeURLSafe=function(t){return h.encode(t)},e.decodeURLSafe=function(t){return h.decode(t)},e.encodedLength=function(t){return o.encodedLength(t)},e.maxDecodedLength=function(t){return o.maxDecodedLength(t)},e.decodedLength=function(t){return o.decodedLength(t)}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r="utf8: invalid source encoding";function i(t){for(var e=0,n=0;n=t.length-1)throw new Error("utf8: invalid string");n++,e+=4}}return e}e.encode=function(t){for(var e=new Uint8Array(i(t)),n=0,r=0;r>6,e[n++]=128|63&s):s<55296?(e[n++]=224|s>>12,e[n++]=128|s>>6&63,e[n++]=128|63&s):(r++,s=(1023&s)<<10,s|=1023&t.charCodeAt(r),s+=65536,e[n++]=240|s>>18,e[n++]=128|s>>12&63,e[n++]=128|s>>6&63,e[n++]=128|63&s)}return e},e.encodedLength=i,e.decode=function(t){for(var e=[],n=0;n=t.length)throw new Error(r);if(128!=(192&(o=t[++n])))throw new Error(r);i=(31&i)<<6|63&o,s=128}else if(i<240){if(n>=t.length-1)throw new Error(r);var o=t[++n],a=t[++n];if(128!=(192&o)||128!=(192&a))throw new Error(r);i=(15&i)<<12|(63&o)<<6|63&a,s=2048}else{if(!(i<248))throw new Error(r);if(n>=t.length-2)throw new Error(r);o=t[++n],a=t[++n];var h=t[++n];if(128!=(192&o)||128!=(192&a)||128!=(192&h))throw new Error(r);i=(15&i)<<18|(63&o)<<12|(63&a)<<6|63&h,s=65536}if(i=55296&&i<=57343)throw new Error(r);if(i>=65536){if(i>1114111)throw new Error(r);i-=65536,e.push(String.fromCharCode(55296|i>>10)),i=56320|1023&i}}e.push(String.fromCharCode(i))}return e.join("")}},function(t,e,n){!function(t){"use strict";var e=function(t){var e,n=new Float64Array(16);if(t)for(e=0;e>24&255,t[e+1]=n>>16&255,t[e+2]=n>>8&255,t[e+3]=255&n,t[e+4]=r>>24&255,t[e+5]=r>>16&255,t[e+6]=r>>8&255,t[e+7]=255&r}function g(t,e,n,r,i){var s,o=0;for(s=0;s>>8)-1}function b(t,e,n,r){return g(t,e,n,r,16)}function v(t,e,n,r){return g(t,e,n,r,32)}function y(t,e,n,r){!function(t,e,n,r){for(var i,s=255&r[0]|(255&r[1])<<8|(255&r[2])<<16|(255&r[3])<<24,o=255&n[0]|(255&n[1])<<8|(255&n[2])<<16|(255&n[3])<<24,a=255&n[4]|(255&n[5])<<8|(255&n[6])<<16|(255&n[7])<<24,h=255&n[8]|(255&n[9])<<8|(255&n[10])<<16|(255&n[11])<<24,c=255&n[12]|(255&n[13])<<8|(255&n[14])<<16|(255&n[15])<<24,u=255&r[4]|(255&r[5])<<8|(255&r[6])<<16|(255&r[7])<<24,l=255&e[0]|(255&e[1])<<8|(255&e[2])<<16|(255&e[3])<<24,d=255&e[4]|(255&e[5])<<8|(255&e[6])<<16|(255&e[7])<<24,p=255&e[8]|(255&e[9])<<8|(255&e[10])<<16|(255&e[11])<<24,f=255&e[12]|(255&e[13])<<8|(255&e[14])<<16|(255&e[15])<<24,g=255&r[8]|(255&r[9])<<8|(255&r[10])<<16|(255&r[11])<<24,b=255&n[16]|(255&n[17])<<8|(255&n[18])<<16|(255&n[19])<<24,v=255&n[20]|(255&n[21])<<8|(255&n[22])<<16|(255&n[23])<<24,y=255&n[24]|(255&n[25])<<8|(255&n[26])<<16|(255&n[27])<<24,m=255&n[28]|(255&n[29])<<8|(255&n[30])<<16|(255&n[31])<<24,w=255&r[12]|(255&r[13])<<8|(255&r[14])<<16|(255&r[15])<<24,_=s,S=o,k=a,C=h,T=c,P=u,A=l,E=d,x=p,O=f,L=g,U=b,R=v,M=y,I=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=C>>>8&255,t[14]=C>>>16&255,t[15]=C>>>24&255,t[16]=T>>>0&255,t[17]=T>>>8&255,t[18]=T>>>16&255,t[19]=T>>>24&255,t[20]=P>>>0&255,t[21]=P>>>8&255,t[22]=P>>>16&255,t[23]=P>>>24&255,t[24]=A>>>0&255,t[25]=A>>>8&255,t[26]=A>>>16&255,t[27]=A>>>24&255,t[28]=E>>>0&255,t[29]=E>>>8&255,t[30]=E>>>16&255,t[31]=E>>>24&255,t[32]=x>>>0&255,t[33]=x>>>8&255,t[34]=x>>>16&255,t[35]=x>>>24&255,t[36]=O>>>0&255,t[37]=O>>>8&255,t[38]=O>>>16&255,t[39]=O>>>24&255,t[40]=L>>>0&255,t[41]=L>>>8&255,t[42]=L>>>16&255,t[43]=L>>>24&255,t[44]=U>>>0&255,t[45]=U>>>8&255,t[46]=U>>>16&255,t[47]=U>>>24&255,t[48]=R>>>0&255,t[49]=R>>>8&255,t[50]=R>>>16&255,t[51]=R>>>24&255,t[52]=M>>>0&255,t[53]=M>>>8&255,t[54]=M>>>16&255,t[55]=M>>>24&255,t[56]=I>>>0&255,t[57]=I>>>8&255,t[58]=I>>>16&255,t[59]=I>>>24&255,t[60]=N>>>0&255,t[61]=N>>>8&255,t[62]=N>>>16&255,t[63]=N>>>24&255}(t,e,n,r)}function m(t,e,n,r){!function(t,e,n,r){for(var i,s=255&r[0]|(255&r[1])<<8|(255&r[2])<<16|(255&r[3])<<24,o=255&n[0]|(255&n[1])<<8|(255&n[2])<<16|(255&n[3])<<24,a=255&n[4]|(255&n[5])<<8|(255&n[6])<<16|(255&n[7])<<24,h=255&n[8]|(255&n[9])<<8|(255&n[10])<<16|(255&n[11])<<24,c=255&n[12]|(255&n[13])<<8|(255&n[14])<<16|(255&n[15])<<24,u=255&r[4]|(255&r[5])<<8|(255&r[6])<<16|(255&r[7])<<24,l=255&e[0]|(255&e[1])<<8|(255&e[2])<<16|(255&e[3])<<24,d=255&e[4]|(255&e[5])<<8|(255&e[6])<<16|(255&e[7])<<24,p=255&e[8]|(255&e[9])<<8|(255&e[10])<<16|(255&e[11])<<24,f=255&e[12]|(255&e[13])<<8|(255&e[14])<<16|(255&e[15])<<24,g=255&r[8]|(255&r[9])<<8|(255&r[10])<<16|(255&r[11])<<24,b=255&n[16]|(255&n[17])<<8|(255&n[18])<<16|(255&n[19])<<24,v=255&n[20]|(255&n[21])<<8|(255&n[22])<<16|(255&n[23])<<24,y=255&n[24]|(255&n[25])<<8|(255&n[26])<<16|(255&n[27])<<24,m=255&n[28]|(255&n[29])<<8|(255&n[30])<<16|(255&n[31])<<24,w=255&r[12]|(255&r[13])<<8|(255&r[14])<<16|(255&r[15])<<24,_=0;_<20;_+=2)s^=(i=(v^=(i=(p^=(i=(c^=(i=s+v|0)<<7|i>>>25)+s|0)<<9|i>>>23)+c|0)<<13|i>>>19)+p|0)<<18|i>>>14,u^=(i=(o^=(i=(y^=(i=(f^=(i=u+o|0)<<7|i>>>25)+u|0)<<9|i>>>23)+f|0)<<13|i>>>19)+y|0)<<18|i>>>14,g^=(i=(l^=(i=(a^=(i=(m^=(i=g+l|0)<<7|i>>>25)+g|0)<<9|i>>>23)+m|0)<<13|i>>>19)+a|0)<<18|i>>>14,w^=(i=(b^=(i=(d^=(i=(h^=(i=w+b|0)<<7|i>>>25)+w|0)<<9|i>>>23)+h|0)<<13|i>>>19)+d|0)<<18|i>>>14,s^=(i=(h^=(i=(a^=(i=(o^=(i=s+h|0)<<7|i>>>25)+s|0)<<9|i>>>23)+o|0)<<13|i>>>19)+a|0)<<18|i>>>14,u^=(i=(c^=(i=(d^=(i=(l^=(i=u+c|0)<<7|i>>>25)+u|0)<<9|i>>>23)+l|0)<<13|i>>>19)+d|0)<<18|i>>>14,g^=(i=(f^=(i=(p^=(i=(b^=(i=g+f|0)<<7|i>>>25)+g|0)<<9|i>>>23)+b|0)<<13|i>>>19)+p|0)<<18|i>>>14,w^=(i=(m^=(i=(y^=(i=(v^=(i=w+m|0)<<7|i>>>25)+w|0)<<9|i>>>23)+v|0)<<13|i>>>19)+y|0)<<18|i>>>14;t[0]=s>>>0&255,t[1]=s>>>8&255,t[2]=s>>>16&255,t[3]=s>>>24&255,t[4]=u>>>0&255,t[5]=u>>>8&255,t[6]=u>>>16&255,t[7]=u>>>24&255,t[8]=g>>>0&255,t[9]=g>>>8&255,t[10]=g>>>16&255,t[11]=g>>>24&255,t[12]=w>>>0&255,t[13]=w>>>8&255,t[14]=w>>>16&255,t[15]=w>>>24&255,t[16]=l>>>0&255,t[17]=l>>>8&255,t[18]=l>>>16&255,t[19]=l>>>24&255,t[20]=d>>>0&255,t[21]=d>>>8&255,t[22]=d>>>16&255,t[23]=d>>>24&255,t[24]=p>>>0&255,t[25]=p>>>8&255,t[26]=p>>>16&255,t[27]=p>>>24&255,t[28]=f>>>0&255,t[29]=f>>>8&255,t[30]=f>>>16&255,t[31]=f>>>24&255}(t,e,n,r)}var w=new Uint8Array([101,120,112,97,110,100,32,51,50,45,98,121,116,101,32,107]);function _(t,e,n,r,i,s,o){var a,h,c=new Uint8Array(16),u=new Uint8Array(64);for(h=0;h<16;h++)c[h]=0;for(h=0;h<8;h++)c[h]=s[h];for(;i>=64;){for(y(u,c,o,w),h=0;h<64;h++)t[e+h]=n[r+h]^u[h];for(a=1,h=8;h<16;h++)a=a+(255&c[h])|0,c[h]=255&a,a>>>=8;i-=64,e+=64,r+=64}if(i>0)for(y(u,c,o,w),h=0;h=64;){for(y(h,a,i,w),o=0;o<64;o++)t[e+o]=h[o];for(s=1,o=8;o<16;o++)s=s+(255&a[o])|0,a[o]=255&s,s>>>=8;n-=64,e+=64}if(n>0)for(y(h,a,i,w),o=0;o>>13|n<<3),r=255&t[4]|(255&t[5])<<8,this.r[2]=7939&(n>>>10|r<<6),i=255&t[6]|(255&t[7])<<8,this.r[3]=8191&(r>>>7|i<<9),s=255&t[8]|(255&t[9])<<8,this.r[4]=255&(i>>>4|s<<12),this.r[5]=s>>>1&8190,o=255&t[10]|(255&t[11])<<8,this.r[6]=8191&(s>>>14|o<<2),a=255&t[12]|(255&t[13])<<8,this.r[7]=8065&(o>>>11|a<<5),h=255&t[14]|(255&t[15])<<8,this.r[8]=8191&(a>>>8|h<<8),this.r[9]=h>>>5&127,this.pad[0]=255&t[16]|(255&t[17])<<8,this.pad[1]=255&t[18]|(255&t[19])<<8,this.pad[2]=255&t[20]|(255&t[21])<<8,this.pad[3]=255&t[22]|(255&t[23])<<8,this.pad[4]=255&t[24]|(255&t[25])<<8,this.pad[5]=255&t[26]|(255&t[27])<<8,this.pad[6]=255&t[28]|(255&t[29])<<8,this.pad[7]=255&t[30]|(255&t[31])<<8};function P(t,e,n,r,i,s){var o=new T(s);return o.update(n,r,i),o.finish(t,e),0}function A(t,e,n,r,i,s){var o=new Uint8Array(16);return P(o,0,n,r,i,s),b(t,e,o,0)}function E(t,e,n,r,i){var s;if(n<32)return-1;for(C(t,0,e,0,n,r,i),P(t,16,t,32,n-32,t),s=0;s<16;s++)t[s]=0;return 0}function x(t,e,n,r,i){var s,o=new Uint8Array(32);if(n<32)return-1;if(k(o,0,32,r,i),0!==A(e,16,e,32,n-32,o))return-1;for(C(t,0,e,0,n,r,i),s=0;s<32;s++)t[s]=0;return 0}function O(t,e){var n;for(n=0;n<16;n++)t[n]=0|e[n]}function L(t){var e,n,r=1;for(e=0;e<16;e++)n=t[e]+r+65535,r=Math.floor(n/65536),t[e]=n-65536*r;t[0]+=r-1+37*(r-1)}function U(t,e,n){for(var r,i=~(n-1),s=0;s<16;s++)r=i&(t[s]^e[s]),t[s]^=r,e[s]^=r}function R(t,n){var r,i,s,o=e(),a=e();for(r=0;r<16;r++)a[r]=n[r];for(L(a),L(a),L(a),i=0;i<2;i++){for(o[0]=a[0]-65517,r=1;r<15;r++)o[r]=a[r]-65535-(o[r-1]>>16&1),o[r-1]&=65535;o[15]=a[15]-32767-(o[14]>>16&1),s=o[15]>>16&1,o[14]&=65535,U(a,o,1-s)}for(r=0;r<16;r++)t[2*r]=255&a[r],t[2*r+1]=a[r]>>8}function M(t,e){var n=new Uint8Array(32),r=new Uint8Array(32);return R(n,t),R(r,e),v(n,0,r,0)}function I(t){var e=new Uint8Array(32);return R(e,t),1&e[0]}function N(t,e){var n;for(n=0;n<16;n++)t[n]=e[2*n]+(e[2*n+1]<<8);t[15]&=32767}function D(t,e,n){for(var r=0;r<16;r++)t[r]=e[r]+n[r]}function j(t,e,n){for(var r=0;r<16;r++)t[r]=e[r]-n[r]}function z(t,e,n){var r,i,s=0,o=0,a=0,h=0,c=0,u=0,l=0,d=0,p=0,f=0,g=0,b=0,v=0,y=0,m=0,w=0,_=0,S=0,k=0,C=0,T=0,P=0,A=0,E=0,x=0,O=0,L=0,U=0,R=0,M=0,I=0,N=n[0],D=n[1],j=n[2],z=n[3],H=n[4],B=n[5],F=n[6],q=n[7],Y=n[8],K=n[9],$=n[10],J=n[11],W=n[12],X=n[13],G=n[14],V=n[15];s+=(r=e[0])*N,o+=r*D,a+=r*j,h+=r*z,c+=r*H,u+=r*B,l+=r*F,d+=r*q,p+=r*Y,f+=r*K,g+=r*$,b+=r*J,v+=r*W,y+=r*X,m+=r*G,w+=r*V,o+=(r=e[1])*N,a+=r*D,h+=r*j,c+=r*z,u+=r*H,l+=r*B,d+=r*F,p+=r*q,f+=r*Y,g+=r*K,b+=r*$,v+=r*J,y+=r*W,m+=r*X,w+=r*G,_+=r*V,a+=(r=e[2])*N,h+=r*D,c+=r*j,u+=r*z,l+=r*H,d+=r*B,p+=r*F,f+=r*q,g+=r*Y,b+=r*K,v+=r*$,y+=r*J,m+=r*W,w+=r*X,_+=r*G,S+=r*V,h+=(r=e[3])*N,c+=r*D,u+=r*j,l+=r*z,d+=r*H,p+=r*B,f+=r*F,g+=r*q,b+=r*Y,v+=r*K,y+=r*$,m+=r*J,w+=r*W,_+=r*X,S+=r*G,k+=r*V,c+=(r=e[4])*N,u+=r*D,l+=r*j,d+=r*z,p+=r*H,f+=r*B,g+=r*F,b+=r*q,v+=r*Y,y+=r*K,m+=r*$,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r*H,k+=r*B,C+=r*F,T+=r*q,P+=r*Y,A+=r*K,E+=r*$,x+=r*J,O+=r*W,L+=r*X,U+=r*G,R+=r*V,m+=(r=e[14])*N,w+=r*D,_+=r*j,S+=r*z,k+=r*H,C+=r*B,T+=r*F,P+=r*q,A+=r*Y,E+=r*K,x+=r*$,O+=r*J,L+=r*W,U+=r*X,R+=r*G,M+=r*V,w+=(r=e[15])*N,o+=38*(S+=r*j),a+=38*(k+=r*z),h+=38*(C+=r*H),c+=38*(T+=r*B),u+=38*(P+=r*F),l+=38*(A+=r*q),d+=38*(E+=r*Y),p+=38*(x+=r*K),f+=38*(O+=r*$),g+=38*(L+=r*J),b+=38*(U+=r*W),v+=38*(R+=r*X),y+=38*(M+=r*G),m+=38*(I+=r*V),s=(r=(s+=38*(_+=r*D))+(i=1)+65535)-65536*(i=Math.floor(r/65536)),o=(r=o+i+65535)-65536*(i=Math.floor(r/65536)),a=(r=a+i+65535)-65536*(i=Math.floor(r/65536)),h=(r=h+i+65535)-65536*(i=Math.floor(r/65536)),c=(r=c+i+65535)-65536*(i=Math.floor(r/65536)),u=(r=u+i+65535)-65536*(i=Math.floor(r/65536)),l=(r=l+i+65535)-65536*(i=Math.floor(r/65536)),d=(r=d+i+65535)-65536*(i=Math.floor(r/65536)),p=(r=p+i+65535)-65536*(i=Math.floor(r/65536)),f=(r=f+i+65535)-65536*(i=Math.floor(r/65536)),g=(r=g+i+65535)-65536*(i=Math.floor(r/65536)),b=(r=b+i+65535)-65536*(i=Math.floor(r/65536)),v=(r=v+i+65535)-65536*(i=Math.floor(r/65536)),y=(r=y+i+65535)-65536*(i=Math.floor(r/65536)),m=(r=m+i+65535)-65536*(i=Math.floor(r/65536)),w=(r=w+i+65535)-65536*(i=Math.floor(r/65536)),s=(r=(s+=i-1+37*(i-1))+(i=1)+65535)-65536*(i=Math.floor(r/65536)),o=(r=o+i+65535)-65536*(i=Math.floor(r/65536)),a=(r=a+i+65535)-65536*(i=Math.floor(r/65536)),h=(r=h+i+65535)-65536*(i=Math.floor(r/65536)),c=(r=c+i+65535)-65536*(i=Math.floor(r/65536)),u=(r=u+i+65535)-65536*(i=Math.floor(r/65536)),l=(r=l+i+65535)-65536*(i=Math.floor(r/65536)),d=(r=d+i+65535)-65536*(i=Math.floor(r/65536)),p=(r=p+i+65535)-65536*(i=Math.floor(r/65536)),f=(r=f+i+65535)-65536*(i=Math.floor(r/65536)),g=(r=g+i+65535)-65536*(i=Math.floor(r/65536)),b=(r=b+i+65535)-65536*(i=Math.floor(r/65536)),v=(r=v+i+65535)-65536*(i=Math.floor(r/65536)),y=(r=y+i+65535)-65536*(i=Math.floor(r/65536)),m=(r=m+i+65535)-65536*(i=Math.floor(r/65536)),w=(r=w+i+65535)-65536*(i=Math.floor(r/65536)),s+=i-1+37*(i-1),t[0]=s,t[1]=o,t[2]=a,t[3]=h,t[4]=c,t[5]=u,t[6]=l,t[7]=d,t[8]=p,t[9]=f,t[10]=g,t[11]=b,t[12]=v,t[13]=y,t[14]=m,t[15]=w}function H(t,e){z(t,e,e)}function B(t,n){var r,i=e();for(r=0;r<16;r++)i[r]=n[r];for(r=253;r>=0;r--)H(i,i),2!==r&&4!==r&&z(i,i,n);for(r=0;r<16;r++)t[r]=i[r]}function F(t,n){var r,i=e();for(r=0;r<16;r++)i[r]=n[r];for(r=250;r>=0;r--)H(i,i),1!==r&&z(i,i,n);for(r=0;r<16;r++)t[r]=i[r]}function q(t,n,r){var i,s,o=new Uint8Array(32),a=new Float64Array(80),c=e(),u=e(),l=e(),d=e(),p=e(),f=e();for(s=0;s<31;s++)o[s]=n[s];for(o[31]=127&n[31]|64,o[0]&=248,N(a,r),s=0;s<16;s++)u[s]=a[s],d[s]=c[s]=l[s]=0;for(c[0]=d[0]=1,s=254;s>=0;--s)U(c,u,i=o[s>>>3]>>>(7&s)&1),U(l,d,i),D(p,c,l),j(c,c,l),D(l,u,d),j(u,u,d),H(d,p),H(f,c),z(c,l,c),z(l,u,p),D(p,c,l),j(c,c,l),H(u,c),j(l,d,f),z(c,l,h),D(c,c,d),z(l,l,c),z(c,d,f),z(d,u,a),H(u,p),U(c,u,i),U(l,d,i);for(s=0;s<16;s++)a[s+16]=c[s],a[s+32]=l[s],a[s+48]=u[s],a[s+64]=d[s];var g=a.subarray(32),b=a.subarray(16);return B(g,g),z(b,b,g),R(t,b),0}function Y(t,e){return q(t,e,s)}function K(t,e){return r(e,32),Y(t,e)}function $(t,e,n){var r=new Uint8Array(32);return q(r,n,e),m(t,i,r,w)}T.prototype.blocks=function(t,e,n){for(var r,i,s,o,a,h,c,u,l,d,p,f,g,b,v,y,m,w,_,S=this.fin?0:2048,k=this.h[0],C=this.h[1],T=this.h[2],P=this.h[3],A=this.h[4],E=this.h[5],x=this.h[6],O=this.h[7],L=this.h[8],U=this.h[9],R=this.r[0],M=this.r[1],I=this.r[2],N=this.r[3],D=this.r[4],j=this.r[5],z=this.r[6],H=this.r[7],B=this.r[8],F=this.r[9];n>=16;)d=l=0,d+=(k+=8191&(r=255&t[e+0]|(255&t[e+1])<<8))*R,d+=(C+=8191&(r>>>13|(i=255&t[e+2]|(255&t[e+3])<<8)<<3))*(5*F),d+=(T+=8191&(i>>>10|(s=255&t[e+4]|(255&t[e+5])<<8)<<6))*(5*B),d+=(P+=8191&(s>>>7|(o=255&t[e+6]|(255&t[e+7])<<8)<<9))*(5*H),l=(d+=(A+=8191&(o>>>4|(a=255&t[e+8]|(255&t[e+9])<<8)<<12))*(5*z))>>>13,d&=8191,d+=(E+=a>>>1&8191)*(5*j),d+=(x+=8191&(a>>>14|(h=255&t[e+10]|(255&t[e+11])<<8)<<2))*(5*D),d+=(O+=8191&(h>>>11|(c=255&t[e+12]|(255&t[e+13])<<8)<<5))*(5*N),d+=(L+=8191&(c>>>8|(u=255&t[e+14]|(255&t[e+15])<<8)<<8))*(5*I),p=l+=(d+=(U+=u>>>5|S)*(5*M))>>>13,p+=k*M,p+=C*R,p+=T*(5*F),p+=P*(5*B),l=(p+=A*(5*H))>>>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&=8191,e+=16,n-=16;this.h[0]=k,this.h[1]=C,this.h[2]=T,this.h[3]=P,this.h[4]=A,this.h[5]=E,this.h[6]=x,this.h[7]=O,this.h[8]=L,this.h[9]=U},T.prototype.finish=function(t,e){var n,r,i,s,o=new Uint16Array(10);if(this.leftover){for(s=this.leftover,this.buffer[s++]=1;s<16;s++)this.buffer[s]=0;this.fin=1,this.blocks(this.buffer,0,16)}for(n=this.h[1]>>>13,this.h[1]&=8191,s=2;s<10;s++)this.h[s]+=n,n=this.h[s]>>>13,this.h[s]&=8191;for(this.h[0]+=5*n,n=this.h[0]>>>13,this.h[0]&=8191,this.h[1]+=n,n=this.h[1]>>>13,this.h[1]&=8191,this.h[2]+=n,o[0]=this.h[0]+5,n=o[0]>>>13,o[0]&=8191,s=1;s<10;s++)o[s]=this.h[s]+n,n=o[s]>>>13,o[s]&=8191;for(o[9]-=8192,r=(1^n)-1,s=0;s<10;s++)o[s]&=r;for(r=~r,s=0;s<10;s++)this.h[s]=this.h[s]&r|o[s];for(this.h[0]=65535&(this.h[0]|this.h[1]<<13),this.h[1]=65535&(this.h[1]>>>3|this.h[2]<<10),this.h[2]=65535&(this.h[2]>>>6|this.h[3]<<7),this.h[3]=65535&(this.h[3]>>>9|this.h[4]<<4),this.h[4]=65535&(this.h[4]>>>12|this.h[5]<<1|this.h[6]<<14),this.h[5]=65535&(this.h[6]>>>2|this.h[7]<<11),this.h[6]=65535&(this.h[7]>>>5|this.h[8]<<8),this.h[7]=65535&(this.h[8]>>>8|this.h[9]<<5),i=this.h[0]+this.pad[0],this.h[0]=65535&i,s=1;s<8;s++)i=(this.h[s]+this.pad[s]|0)+(i>>>16)|0,this.h[s]=65535&i;t[e+0]=this.h[0]>>>0&255,t[e+1]=this.h[0]>>>8&255,t[e+2]=this.h[1]>>>0&255,t[e+3]=this.h[1]>>>8&255,t[e+4]=this.h[2]>>>0&255,t[e+5]=this.h[2]>>>8&255,t[e+6]=this.h[3]>>>0&255,t[e+7]=this.h[3]>>>8&255,t[e+8]=this.h[4]>>>0&255,t[e+9]=this.h[4]>>>8&255,t[e+10]=this.h[5]>>>0&255,t[e+11]=this.h[5]>>>8&255,t[e+12]=this.h[6]>>>0&255,t[e+13]=this.h[6]>>>8&255,t[e+14]=this.h[7]>>>0&255,t[e+15]=this.h[7]>>>8&255},T.prototype.update=function(t,e,n){var r,i;if(this.leftover){for((i=16-this.leftover)>n&&(i=n),r=0;r=16&&(i=n-n%16,this.blocks(t,e,i),e+=i,n-=i),n){for(r=0;r=128;){for(S=0;S<16;S++)k=8*S+W,O[S]=n[k+0]<<24|n[k+1]<<16|n[k+2]<<8|n[k+3],L[S]=n[k+4]<<24|n[k+5]<<16|n[k+6]<<8|n[k+7];for(S=0;S<80;S++)if(i=U,s=R,o=M,a=I,h=N,c=D,u=j,z,d=H,p=B,f=F,g=q,b=Y,v=K,y=$,J,P=65535&(T=J),A=T>>>16,E=65535&(C=z),x=C>>>16,P+=65535&(T=(Y>>>14|N<<18)^(Y>>>18|N<<14)^(N>>>9|Y<<23)),A+=T>>>16,E+=65535&(C=(N>>>14|Y<<18)^(N>>>18|Y<<14)^(Y>>>9|N<<23)),x+=C>>>16,P+=65535&(T=Y&K^~Y&$),A+=T>>>16,E+=65535&(C=N&D^~N&j),x+=C>>>16,P+=65535&(T=X[2*S+1]),A+=T>>>16,E+=65535&(C=X[2*S]),x+=C>>>16,C=O[S%16],A+=(T=L[S%16])>>>16,E+=65535&C,x+=C>>>16,E+=(A+=(P+=65535&T)>>>16)>>>16,P=65535&(T=_=65535&P|A<<16),A=T>>>16,E=65535&(C=w=65535&E|(x+=E>>>16)<<16),x=C>>>16,P+=65535&(T=(H>>>28|U<<4)^(U>>>2|H<<30)^(U>>>7|H<<25)),A+=T>>>16,E+=65535&(C=(U>>>28|H<<4)^(H>>>2|U<<30)^(H>>>7|U<<25)),x+=C>>>16,A+=(T=H&B^H&F^B&F)>>>16,E+=65535&(C=U&R^U&M^R&M),x+=C>>>16,l=65535&(E+=(A+=(P+=65535&T)>>>16)>>>16)|(x+=E>>>16)<<16,m=65535&P|A<<16,P=65535&(T=g),A=T>>>16,E=65535&(C=a),x=C>>>16,A+=(T=_)>>>16,E+=65535&(C=w),x+=C>>>16,R=i,M=s,I=o,N=a=65535&(E+=(A+=(P+=65535&T)>>>16)>>>16)|(x+=E>>>16)<<16,D=h,j=c,z=u,U=l,B=d,F=p,q=f,Y=g=65535&P|A<<16,K=b,$=v,J=y,H=m,S%16==15)for(k=0;k<16;k++)C=O[k],P=65535&(T=L[k]),A=T>>>16,E=65535&C,x=C>>>16,C=O[(k+9)%16],P+=65535&(T=L[(k+9)%16]),A+=T>>>16,E+=65535&C,x+=C>>>16,w=O[(k+1)%16],P+=65535&(T=((_=L[(k+1)%16])>>>1|w<<31)^(_>>>8|w<<24)^(_>>>7|w<<25)),A+=T>>>16,E+=65535&(C=(w>>>1|_<<31)^(w>>>8|_<<24)^w>>>7),x+=C>>>16,w=O[(k+14)%16],A+=(T=((_=L[(k+14)%16])>>>19|w<<13)^(w>>>29|_<<3)^(_>>>6|w<<26))>>>16,E+=65535&(C=(w>>>19|_<<13)^(_>>>29|w<<3)^w>>>6),x+=C>>>16,x+=(E+=(A+=(P+=65535&T)>>>16)>>>16)>>>16,O[k]=65535&E|x<<16,L[k]=65535&P|A<<16;P=65535&(T=H),A=T>>>16,E=65535&(C=U),x=C>>>16,C=t[0],A+=(T=e[0])>>>16,E+=65535&C,x+=C>>>16,x+=(E+=(A+=(P+=65535&T)>>>16)>>>16)>>>16,t[0]=U=65535&E|x<<16,e[0]=H=65535&P|A<<16,P=65535&(T=B),A=T>>>16,E=65535&(C=R),x=C>>>16,C=t[1],A+=(T=e[1])>>>16,E+=65535&C,x+=C>>>16,x+=(E+=(A+=(P+=65535&T)>>>16)>>>16)>>>16,t[1]=R=65535&E|x<<16,e[1]=B=65535&P|A<<16,P=65535&(T=F),A=T>>>16,E=65535&(C=M),x=C>>>16,C=t[2],A+=(T=e[2])>>>16,E+=65535&C,x+=C>>>16,x+=(E+=(A+=(P+=65535&T)>>>16)>>>16)>>>16,t[2]=M=65535&E|x<<16,e[2]=F=65535&P|A<<16,P=65535&(T=q),A=T>>>16,E=65535&(C=I),x=C>>>16,C=t[3],A+=(T=e[3])>>>16,E+=65535&C,x+=C>>>16,x+=(E+=(A+=(P+=65535&T)>>>16)>>>16)>>>16,t[3]=I=65535&E|x<<16,e[3]=q=65535&P|A<<16,P=65535&(T=Y),A=T>>>16,E=65535&(C=N),x=C>>>16,C=t[4],A+=(T=e[4])>>>16,E+=65535&C,x+=C>>>16,x+=(E+=(A+=(P+=65535&T)>>>16)>>>16)>>>16,t[4]=N=65535&E|x<<16,e[4]=Y=65535&P|A<<16,P=65535&(T=K),A=T>>>16,E=65535&(C=D),x=C>>>16,C=t[5],A+=(T=e[5])>>>16,E+=65535&C,x+=C>>>16,x+=(E+=(A+=(P+=65535&T)>>>16)>>>16)>>>16,t[5]=D=65535&E|x<<16,e[5]=K=65535&P|A<<16,P=65535&(T=$),A=T>>>16,E=65535&(C=j),x=C>>>16,C=t[6],A+=(T=e[6])>>>16,E+=65535&C,x+=C>>>16,x+=(E+=(A+=(P+=65535&T)>>>16)>>>16)>>>16,t[6]=j=65535&E|x<<16,e[6]=$=65535&P|A<<16,P=65535&(T=J),A=T>>>16,E=65535&(C=z),x=C>>>16,C=t[7],A+=(T=e[7])>>>16,E+=65535&C,x+=C>>>16,x+=(E+=(A+=(P+=65535&T)>>>16)>>>16)>>>16,t[7]=z=65535&E|x<<16,e[7]=J=65535&P|A<<16,W+=128,r-=128}return r}function V(t,e,n){var r,i=new Int32Array(8),s=new Int32Array(8),o=new Uint8Array(256),a=n;for(i[0]=1779033703,i[1]=3144134277,i[2]=1013904242,i[3]=2773480762,i[4]=1359893119,i[5]=2600822924,i[6]=528734635,i[7]=1541459225,s[0]=4089235720,s[1]=2227873595,s[2]=4271175723,s[3]=1595750129,s[4]=2917565137,s[5]=725511199,s[6]=4215389547,s[7]=327033209,G(i,s,e,n),n%=128,r=0;r=0;--i)Q(t,e,r=n[i/8|0]>>(7&i)&1),Z(e,t),Z(t,t),Q(t,e,r)}function nt(t,n){var r=[e(),e(),e(),e()];O(r[0],l),O(r[1],d),O(r[2],a),z(r[3],l,d),et(t,r,n)}function rt(t,n,i){var s,o=new Uint8Array(64),a=[e(),e(),e(),e()];for(i||r(n,32),V(o,n,32),o[0]&=248,o[31]&=127,o[31]|=64,nt(a,o),tt(t,a),s=0;s<32;s++)n[s+32]=t[s];return 0}var it=new Float64Array([237,211,245,92,26,99,18,88,214,156,247,162,222,249,222,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16]);function st(t,e){var n,r,i,s;for(r=63;r>=32;--r){for(n=0,i=r-32,s=r-12;i>4)*it[i],n=e[i]>>8,e[i]&=255;for(i=0;i<32;i++)e[i]-=n*it[i];for(r=0;r<32;r++)e[r+1]+=e[r]>>8,t[r]=255&e[r]}function ot(t){var e,n=new Float64Array(64);for(e=0;e<64;e++)n[e]=t[e];for(e=0;e<64;e++)t[e]=0;st(t,n)}function at(t,n,r,i){var s,o,a=new Uint8Array(64),h=new Uint8Array(64),c=new Uint8Array(64),u=new Float64Array(64),l=[e(),e(),e(),e()];V(a,i,32),a[0]&=248,a[31]&=127,a[31]|=64;var d=r+64;for(s=0;s>7&&j(t[0],o,t[0]),z(t[3],t[0],t[1]),0)}(d,i))return-1;for(s=0;s=0},t.sign.keyPair=function(){var t=new Uint8Array(32),e=new Uint8Array(64);return rt(t,e),{publicKey:t,secretKey:e}},t.sign.keyPair.fromSecretKey=function(t){if(ut(t),64!==t.length)throw new Error("bad secret key size");for(var e=new Uint8Array(32),n=0;n>>6)+r(128|63&e):r(224|e>>>12&15)+r(128|e>>>6&63)+r(128|63&e)},c=function(t){return t.replace(/[^\x00-\x7F]/g,h)},u=function(t){var e=[0,2,1][t.length%3],n=t.charCodeAt(0)<<16|(t.length>1?t.charCodeAt(1):0)<<8|(t.length>2?t.charCodeAt(2):0);return[i.charAt(n>>>18),i.charAt(n>>>12&63),e>=2?"=":i.charAt(n>>>6&63),e>=1?"=":i.charAt(63&n)].join("")},l=self.btoa||function(t){return t.replace(/[\s\S]{1,3}/g,u)};var d=class{constructor(t,e,n,r){this.clear=e,this.timer=t(()=>{this.timer&&(this.timer=r(this.timer))},n)}isRunning(){return null!==this.timer}ensureAborted(){this.timer&&(this.clear(this.timer),this.timer=null)}};function p(t){self.clearTimeout(t)}function f(t){self.clearInterval(t)}class g extends d{constructor(t,e){super(setTimeout,p,t,(function(t){return e(),null}))}}class b extends d{constructor(t,e){super(setInterval,f,t,(function(t){return e(),t}))}}var v={now:()=>Date.now?Date.now():(new Date).valueOf(),defer:t=>new g(0,t),method(t,...e){var n=Array.prototype.slice.call(arguments,1);return function(e){return e[t].apply(e,n.concat(arguments))}}};function y(t,...e){for(var n=0;ne!==t),this):(this.global_callbacks=[],this)}unbind_all(){return this.unbind(),this.unbind_global(),this}emit(t,e,n){for(var r=0;r0)for(r=0;r{self.console&&self.console.log&&self.console.log(t)}}debug(...t){this.log(this.globalLog,t)}warn(...t){this.log(this.globalLogWarn,t)}error(...t){this.log(this.globalLogError,t)}globalLogWarn(t){self.console&&self.console.warn?self.console.warn(t):this.globalLog(t)}globalLogError(t){self.console&&self.console.error?self.console.error(t):this.globalLogWarn(t)}log(t,...e){var n=m.apply(this,arguments);if(Oe.log)Oe.log(n);else if(Oe.logToConsole){t.bind(this)(n)}}};class H extends j{constructor(t,e,n,r,i){super(),this.initialize=ae.transportConnectionInitializer,this.hooks=t,this.name=e,this.priority=n,this.key=r,this.options=i,this.state="new",this.timeline=i.timeline,this.activityTimeout=i.activityTimeout,this.id=this.timeline.generateUniqueID()}handlesActivityChecks(){return Boolean(this.hooks.handlesActivityChecks)}supportsPing(){return Boolean(this.hooks.supportsPing)}connect(){if(this.socket||"initialized"!==this.state)return!1;var t=this.hooks.urls.getInitial(this.key,this.options);try{this.socket=this.hooks.getSocket(t,this.options)}catch(t){return v.defer(()=>{this.onError(t),this.changeState("closed")}),!1}return this.bindListeners(),z.debug("Connecting",{transport:this.name,url:t}),this.changeState("connecting"),!0}close(){return!!this.socket&&(this.socket.close(),!0)}send(t){return"open"===this.state&&(v.defer(()=>{this.socket&&this.socket.send(t)}),!0)}ping(){"open"===this.state&&this.supportsPing()&&this.socket.ping()}onOpen(){this.hooks.beforeOpen&&this.hooks.beforeOpen(this.socket,this.hooks.urls.getPath(this.key,this.options)),this.changeState("open"),this.socket.onopen=void 0}onError(t){this.emit("error",{type:"WebSocketError",error:t}),this.timeline.error(this.buildTimelineMessage({error:t.toString()}))}onClose(t){t?this.changeState("closed",{code:t.code,reason:t.reason,wasClean:t.wasClean}):this.changeState("closed"),this.unbindListeners(),this.socket=void 0}onMessage(t){this.emit("message",t)}onActivity(){this.emit("activity")}bindListeners(){this.socket.onopen=()=>{this.onOpen()},this.socket.onerror=t=>{this.onError(t)},this.socket.onclose=t=>{this.onClose(t)},this.socket.onmessage=t=>{this.onMessage(t)},this.supportsPing()&&(this.socket.onactivity=()=>{this.onActivity()})}unbindListeners(){this.socket&&(this.socket.onopen=void 0,this.socket.onerror=void 0,this.socket.onclose=void 0,this.socket.onmessage=void 0,this.supportsPing()&&(this.socket.onactivity=void 0))}changeState(t,e){this.state=t,this.timeline.info(this.buildTimelineMessage({state:t,params:e})),this.emit(t,e)}buildTimelineMessage(t){return y({cid:this.id},t)}}class B{constructor(t){this.hooks=t}isSupported(t){return this.hooks.isSupported(t)}createConnection(t,e,n,r){return new H(this.hooks,t,e,n,r)}}var F=new B({urls:M,handlesActivityChecks:!1,supportsPing:!1,isInitialized:function(){return Boolean(ae.getWebSocketAPI())},isSupported:function(){return Boolean(ae.getWebSocketAPI())},getSocket:function(t){return ae.createWebSocket(t)}}),q={urls:I,handlesActivityChecks:!1,supportsPing:!0,isInitialized:function(){return!0}},Y=y({getSocket:function(t){return ae.HTTPFactory.createStreamingSocket(t)}},q),K=y({getSocket:function(t){return ae.HTTPFactory.createPollingSocket(t)}},q),$={isSupported:function(){return ae.isXHRSupported()}},J={ws:F,xhr_streaming:new B(y({},Y,$)),xhr_polling:new B(y({},K,$))};class W{constructor(t,e,n){this.manager=t,this.transport=e,this.minPingDelay=n.minPingDelay,this.maxPingDelay=n.maxPingDelay,this.pingDelay=void 0}createConnection(t,e,n,r){r=y({},r,{activityTimeout:this.pingDelay});var i=this.transport.createConnection(t,e,n,r),s=null,o=function(){i.unbind("open",o),i.bind("closed",a),s=v.now()},a=t=>{if(i.unbind("closed",a),1002===t.code||1003===t.code)this.manager.reportDeath();else if(!t.wasClean&&s){var e=v.now()-s;e<2*this.maxPingDelay&&(this.manager.reportDeath(),this.pingDelay=Math.max(e/2,this.minPingDelay))}};return i.bind("open",o),i}isSupported(t){return this.manager.isAlive()&&this.transport.isSupported(t)}}const X={decodeMessage:function(t){try{var e=JSON.parse(t.data),n=e.data;if("string"==typeof n)try{n=JSON.parse(e.data)}catch(t){}var r={event:e.event,channel:e.channel,data:n};return e.user_id&&(r.user_id=e.user_id),r}catch(e){throw{type:"MessageParseError",error:e,data:t.data}}},encodeMessage:function(t){return JSON.stringify(t)},processHandshake:function(t){var e=X.decodeMessage(t);if("pusher:connection_established"===e.event){if(!e.data.activity_timeout)throw"No activity timeout specified in handshake";return{action:"connected",id:e.data.socket_id,activityTimeout:1e3*e.data.activity_timeout}}if("pusher:error"===e.event)return{action:this.getCloseAction(e.data),error:this.getCloseError(e.data)};throw"Invalid handshake"},getCloseAction:function(t){return t.code<4e3?t.code>=1002&&t.code<=1004?"backoff":null:4e3===t.code?"tls_only":t.code<4100?"refused":t.code<4200?"backoff":t.code<4300?"retry":"refused"},getCloseError:function(t){return 1e3!==t.code&&1001!==t.code?{type:"PusherError",data:{code:t.code,message:t.reason||t.message}}:null}};var G=X;class V extends j{constructor(t,e){super(),this.id=t,this.transport=e,this.activityTimeout=e.activityTimeout,this.bindListeners()}handlesActivityChecks(){return this.transport.handlesActivityChecks()}send(t){return this.transport.send(t)}send_event(t,e,n){var r={event:t,data:e};return n&&(r.channel=n),z.debug("Event sent",r),this.send(G.encodeMessage(r))}ping(){this.transport.supportsPing()?this.transport.ping():this.send_event("pusher:ping",{})}close(){this.transport.close()}bindListeners(){var t={message:t=>{var e;try{e=G.decodeMessage(t)}catch(e){this.emit("error",{type:"MessageParseError",error:e,data:t.data})}if(void 0!==e){switch(z.debug("Event recd",e),e.event){case"pusher:error":this.emit("error",{type:"PusherError",data:e.data});break;case"pusher:ping":this.emit("ping");break;case"pusher:pong":this.emit("pong")}this.emit("message",e)}},activity:()=>{this.emit("activity")},error:t=>{this.emit("error",t)},closed:t=>{e(),t&&t.code&&this.handleCloseEvent(t),this.transport=null,this.emit("closed")}},e=()=>{_(t,(t,e)=>{this.transport.unbind(e,t)})};_(t,(t,e)=>{this.transport.bind(e,t)})}handleCloseEvent(t){var e=G.getCloseAction(t),n=G.getCloseError(t);n&&this.emit("error",n),e&&this.emit(e,{action:e,error:n})}}class Z{constructor(t,e){this.transport=t,this.callback=e,this.bindListeners()}close(){this.unbindListeners(),this.transport.close()}bindListeners(){this.onMessage=t=>{var e;this.unbindListeners();try{e=G.processHandshake(t)}catch(t){return this.finish("error",{error:t}),void this.transport.close()}"connected"===e.action?this.finish("connected",{connection:new V(e.id,this.transport),activityTimeout:e.activityTimeout}):(this.finish(e.action,{error:e.error}),this.transport.close())},this.onClosed=t=>{this.unbindListeners();var e=G.getCloseAction(t)||"backoff",n=G.getCloseError(t);this.finish(e,{error:n})},this.transport.bind("message",this.onMessage),this.transport.bind("closed",this.onClosed)}unbindListeners(){this.transport.unbind("message",this.onMessage),this.transport.unbind("closed",this.onClosed)}finish(t,e){this.callback(y({transport:this.transport,action:t},e))}}class Q{constructor(t,e){this.timeline=t,this.options=e||{}}send(t,e){this.timeline.isEmpty()||this.timeline.send(ae.TimelineTransport.getAgent(this,t),e)}}class tt extends Error{constructor(t){super(t),Object.setPrototypeOf(this,new.target.prototype)}}class et extends Error{constructor(t){super(t),Object.setPrototypeOf(this,new.target.prototype)}}Error;class nt extends Error{constructor(t){super(t),Object.setPrototypeOf(this,new.target.prototype)}}class rt extends Error{constructor(t){super(t),Object.setPrototypeOf(this,new.target.prototype)}}class it extends Error{constructor(t){super(t),Object.setPrototypeOf(this,new.target.prototype)}}class st extends Error{constructor(t){super(t),Object.setPrototypeOf(this,new.target.prototype)}}class ot extends Error{constructor(t){super(t),Object.setPrototypeOf(this,new.target.prototype)}}class at extends Error{constructor(t,e){super(e),this.status=t,Object.setPrototypeOf(this,new.target.prototype)}}const ht={baseUrl:"https://pusher.com",urls:{authenticationEndpoint:{path:"/docs/channels/server_api/authenticating_users"},authorizationEndpoint:{path:"/docs/channels/server_api/authorizing-users/"},javascriptQuickStart:{path:"/docs/javascript_quick_start"},triggeringClientEvents:{path:"/docs/client_api_guide/client_events#trigger-events"},encryptedChannelSupport:{fullUrl:"https://github.com/pusher/pusher-js/tree/cc491015371a4bde5743d1c87a0fbac0feb53195#encrypted-channel-support"}}};var ct=function(t){const e=ht.urls[t];if(!e)return"";let n;return e.fullUrl?n=e.fullUrl:e.path&&(n=ht.baseUrl+e.path),n?"See: "+n:""};class ut extends j{constructor(t,e){super((function(e,n){z.debug("No callbacks on "+t+" for "+e)})),this.name=t,this.pusher=e,this.subscribed=!1,this.subscriptionPending=!1,this.subscriptionCancelled=!1}authorize(t,e){return e(null,{auth:""})}trigger(t,e){if(0!==t.indexOf("client-"))throw new tt("Event '"+t+"' does not start with 'client-'");if(!this.subscribed){var n=ct("triggeringClientEvents");z.warn("Client event triggered before channel 'subscription_succeeded' event . "+n)}return this.pusher.send_event(t,e,this.name)}disconnect(){this.subscribed=!1,this.subscriptionPending=!1}handleEvent(t){var e=t.event,n=t.data;if("pusher_internal:subscription_succeeded"===e)this.handleSubscriptionSucceededEvent(t);else if("pusher_internal:subscription_count"===e)this.handleSubscriptionCountEvent(t);else if(0!==e.indexOf("pusher_internal:")){this.emit(e,n,{})}}handleSubscriptionSucceededEvent(t){this.subscriptionPending=!1,this.subscribed=!0,this.subscriptionCancelled?this.pusher.unsubscribe(this.name):this.emit("pusher:subscription_succeeded",t.data)}handleSubscriptionCountEvent(t){t.data.subscription_count&&(this.subscriptionCount=t.data.subscription_count),this.emit("pusher:subscription_count",t.data)}subscribe(){this.subscribed||(this.subscriptionPending=!0,this.subscriptionCancelled=!1,this.authorize(this.pusher.connection.socket_id,(t,e)=>{t?(this.subscriptionPending=!1,z.error(t.toString()),this.emit("pusher:subscription_error",Object.assign({},{type:"AuthError",error:t.message},t instanceof at?{status:t.status}:{}))):this.pusher.send_event("pusher:subscribe",{auth:e.auth,channel_data:e.channel_data,channel:this.name})}))}unsubscribe(){this.subscribed=!1,this.pusher.send_event("pusher:unsubscribe",{channel:this.name})}cancelSubscription(){this.subscriptionCancelled=!0}reinstateSubscription(){this.subscriptionCancelled=!1}}class lt extends ut{authorize(t,e){return this.pusher.config.channelAuthorizer({channelName:this.name,socketId:t},e)}}class dt{constructor(){this.reset()}get(t){return Object.prototype.hasOwnProperty.call(this.members,t)?{id:t,info:this.members[t]}:null}each(t){_(this.members,(e,n)=>{t(this.get(n))})}setMyID(t){this.myID=t}onSubscription(t){this.members=t.presence.hash,this.count=t.presence.count,this.me=this.get(this.myID)}addMember(t){return null===this.get(t.user_id)&&this.count++,this.members[t.user_id]=t.user_info,this.get(t.user_id)}removeMember(t){var e=this.get(t.user_id);return e&&(delete this.members[t.user_id],this.count--),e}reset(){this.members={},this.count=0,this.myID=null,this.me=null}}var pt=function(t,e,n,r){return new(n||(n=Promise))((function(i,s){function o(t){try{h(r.next(t))}catch(t){s(t)}}function a(t){try{h(r.throw(t))}catch(t){s(t)}}function h(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(o,a)}h((r=r.apply(t,e||[])).next())}))};class ft extends lt{constructor(t,e){super(t,e),this.members=new dt}authorize(t,e){super.authorize(t,(t,n)=>pt(this,void 0,void 0,(function*(){if(!t)if(null!=(n=n).channel_data){var r=JSON.parse(n.channel_data);this.members.setMyID(r.user_id)}else{if(yield this.pusher.user.signinDonePromise,null==this.pusher.user.user_data){let t=ct("authorizationEndpoint");return z.error(`Invalid auth response for channel '${this.name}', expected 'channel_data' field. ${t}, or the user should be signed in.`),void e("Invalid auth response")}this.members.setMyID(this.pusher.user.user_data.id)}e(t,n)})))}handleEvent(t){var e=t.event;if(0===e.indexOf("pusher_internal:"))this.handleInternalEvent(t);else{var n=t.data,r={};t.user_id&&(r.user_id=t.user_id),this.emit(e,n,r)}}handleInternalEvent(t){var e=t.event,n=t.data;switch(e){case"pusher_internal:subscription_succeeded":this.handleSubscriptionSucceededEvent(t);break;case"pusher_internal:subscription_count":this.handleSubscriptionCountEvent(t);break;case"pusher_internal:member_added":var r=this.members.addMember(n);this.emit("pusher:member_added",r);break;case"pusher_internal:member_removed":var i=this.members.removeMember(n);i&&this.emit("pusher:member_removed",i)}}handleSubscriptionSucceededEvent(t){this.subscriptionPending=!1,this.subscribed=!0,this.subscriptionCancelled?this.pusher.unsubscribe(this.name):(this.members.onSubscription(t.data),this.emit("pusher:subscription_succeeded",this.members))}disconnect(){this.members.reset(),super.disconnect()}}var gt=n(1),bt=n(0);class vt extends lt{constructor(t,e,n){super(t,e),this.key=null,this.nacl=n}authorize(t,e){super.authorize(t,(t,n)=>{if(t)return void e(t,n);let r=n.shared_secret;r?(this.key=Object(bt.decode)(r),delete n.shared_secret,e(null,n)):e(new Error("No shared_secret key in auth payload for encrypted channel: "+this.name),null)})}trigger(t,e){throw new it("Client events are not currently supported for encrypted channels")}handleEvent(t){var e=t.event,n=t.data;0!==e.indexOf("pusher_internal:")&&0!==e.indexOf("pusher:")?this.handleEncryptedEvent(e,n):super.handleEvent(t)}handleEncryptedEvent(t,e){if(!this.key)return void z.debug("Received encrypted event before key has been retrieved from the authEndpoint");if(!e.ciphertext||!e.nonce)return void z.error("Unexpected format for encrypted event, expected object with `ciphertext` and `nonce` fields, got: "+e);let n=Object(bt.decode)(e.ciphertext);if(n.length{e?z.error(`Failed to make a request to the authEndpoint: ${s}. Unable to fetch new key, so dropping encrypted event`):(i=this.nacl.secretbox.open(n,r,this.key),null!==i?this.emit(t,this.getDataToEmit(i)):z.error("Failed to decrypt event with new key. Dropping encrypted event"))});this.emit(t,this.getDataToEmit(i))}getDataToEmit(t){let e=Object(gt.decode)(t);try{return JSON.parse(e)}catch(t){return e}}}class yt extends j{constructor(t,e){super(),this.state="initialized",this.connection=null,this.key=t,this.options=e,this.timeline=this.options.timeline,this.usingTLS=this.options.useTLS,this.errorCallbacks=this.buildErrorCallbacks(),this.connectionCallbacks=this.buildConnectionCallbacks(this.errorCallbacks),this.handshakeCallbacks=this.buildHandshakeCallbacks(this.errorCallbacks);var n=ae.getNetwork();n.bind("online",()=>{this.timeline.info({netinfo:"online"}),"connecting"!==this.state&&"unavailable"!==this.state||this.retryIn(0)}),n.bind("offline",()=>{this.timeline.info({netinfo:"offline"}),this.connection&&this.sendActivityCheck()}),this.updateStrategy()}switchCluster(t){this.key=t,this.updateStrategy(),this.retryIn(0)}connect(){this.connection||this.runner||(this.strategy.isSupported()?(this.updateState("connecting"),this.startConnecting(),this.setUnavailableTimer()):this.updateState("failed"))}send(t){return!!this.connection&&this.connection.send(t)}send_event(t,e,n){return!!this.connection&&this.connection.send_event(t,e,n)}disconnect(){this.disconnectInternally(),this.updateState("disconnected")}isUsingTLS(){return this.usingTLS}startConnecting(){var t=(e,n)=>{e?this.runner=this.strategy.connect(0,t):"error"===n.action?(this.emit("error",{type:"HandshakeError",error:n.error}),this.timeline.error({handshakeError:n.error})):(this.abortConnecting(),this.handshakeCallbacks[n.action](n))};this.runner=this.strategy.connect(0,t)}abortConnecting(){this.runner&&(this.runner.abort(),this.runner=null)}disconnectInternally(){(this.abortConnecting(),this.clearRetryTimer(),this.clearUnavailableTimer(),this.connection)&&this.abandonConnection().close()}updateStrategy(){this.strategy=this.options.getStrategy({key:this.key,timeline:this.timeline,useTLS:this.usingTLS})}retryIn(t){this.timeline.info({action:"retry",delay:t}),t>0&&this.emit("connecting_in",Math.round(t/1e3)),this.retryTimer=new g(t||0,()=>{this.disconnectInternally(),this.connect()})}clearRetryTimer(){this.retryTimer&&(this.retryTimer.ensureAborted(),this.retryTimer=null)}setUnavailableTimer(){this.unavailableTimer=new g(this.options.unavailableTimeout,()=>{this.updateState("unavailable")})}clearUnavailableTimer(){this.unavailableTimer&&this.unavailableTimer.ensureAborted()}sendActivityCheck(){this.stopActivityCheck(),this.connection.ping(),this.activityTimer=new g(this.options.pongTimeout,()=>{this.timeline.error({pong_timed_out:this.options.pongTimeout}),this.retryIn(0)})}resetActivityCheck(){this.stopActivityCheck(),this.connection&&!this.connection.handlesActivityChecks()&&(this.activityTimer=new g(this.activityTimeout,()=>{this.sendActivityCheck()}))}stopActivityCheck(){this.activityTimer&&this.activityTimer.ensureAborted()}buildConnectionCallbacks(t){return y({},t,{message:t=>{this.resetActivityCheck(),this.emit("message",t)},ping:()=>{this.send_event("pusher:pong",{})},activity:()=>{this.resetActivityCheck()},error:t=>{this.emit("error",t)},closed:()=>{this.abandonConnection(),this.shouldRetry()&&this.retryIn(1e3)}})}buildHandshakeCallbacks(t){return y({},t,{connected:t=>{this.activityTimeout=Math.min(this.options.activityTimeout,t.activityTimeout,t.connection.activityTimeout||1/0),this.clearUnavailableTimer(),this.setConnection(t.connection),this.socket_id=this.connection.id,this.updateState("connected",{socket_id:this.socket_id})}})}buildErrorCallbacks(){let t=t=>e=>{e.error&&this.emit("error",{type:"WebSocketError",error:e.error}),t(e)};return{tls_only:t(()=>{this.usingTLS=!0,this.updateStrategy(),this.retryIn(0)}),refused:t(()=>{this.disconnect()}),backoff:t(()=>{this.retryIn(1e3)}),retry:t(()=>{this.retryIn(0)})}}setConnection(t){for(var e in this.connection=t,this.connectionCallbacks)this.connection.bind(e,this.connectionCallbacks[e]);this.resetActivityCheck()}abandonConnection(){if(this.connection){for(var t in this.stopActivityCheck(),this.connectionCallbacks)this.connection.unbind(t,this.connectionCallbacks[t]);var e=this.connection;return this.connection=null,e}}updateState(t,e){var n=this.state;if(this.state=t,n!==t){var r=t;"connected"===r&&(r+=" with new socket ID "+e.socket_id),z.debug("State changed",n+" -> "+r),this.timeline.info({state:t,params:e}),this.emit("state_change",{previous:n,current:t}),this.emit(t,e)}}shouldRetry(){return"connecting"===this.state||"connected"===this.state}}class mt{constructor(){this.channels={}}add(t,e){return this.channels[t]||(this.channels[t]=function(t,e){if(0===t.indexOf("private-encrypted-")){if(e.config.nacl)return wt.createEncryptedChannel(t,e,e.config.nacl);let n="Tried to subscribe to a private-encrypted- channel but no nacl implementation available",r=ct("encryptedChannelSupport");throw new it(`${n}. ${r}`)}if(0===t.indexOf("private-"))return wt.createPrivateChannel(t,e);if(0===t.indexOf("presence-"))return wt.createPresenceChannel(t,e);if(0===t.indexOf("#"))throw new et('Cannot create a channel with name "'+t+'".');return wt.createChannel(t,e)}(t,e)),this.channels[t]}all(){return function(t){var e=[];return _(t,(function(t){e.push(t)})),e}(this.channels)}find(t){return this.channels[t]}remove(t){var e=this.channels[t];return delete this.channels[t],e}disconnect(){_(this.channels,(function(t){t.disconnect()}))}}var wt={createChannels:()=>new mt,createConnectionManager:(t,e)=>new yt(t,e),createChannel:(t,e)=>new ut(t,e),createPrivateChannel:(t,e)=>new lt(t,e),createPresenceChannel:(t,e)=>new ft(t,e),createEncryptedChannel:(t,e,n)=>new vt(t,e,n),createTimelineSender:(t,e)=>new Q(t,e),createHandshake:(t,e)=>new Z(t,e),createAssistantToTheTransportManager:(t,e,n)=>new W(t,e,n)};class _t{constructor(t){this.options=t||{},this.livesLeft=this.options.lives||1/0}getAssistant(t){return wt.createAssistantToTheTransportManager(this,t,{minPingDelay:this.options.minPingDelay,maxPingDelay:this.options.maxPingDelay})}isAlive(){return this.livesLeft>0}reportDeath(){this.livesLeft-=1}}class St{constructor(t,e){this.strategies=t,this.loop=Boolean(e.loop),this.failFast=Boolean(e.failFast),this.timeout=e.timeout,this.timeoutLimit=e.timeoutLimit}isSupported(){return A(this.strategies,v.method("isSupported"))}connect(t,e){var n=this.strategies,r=0,i=this.timeout,s=null,o=(a,h)=>{h?e(null,h):(r+=1,this.loop&&(r%=n.length),r0&&(i=new g(n.timeout,(function(){s.abort(),r(!0)}))),s=t.connect(e,(function(t,e){t&&i&&i.isRunning()&&!n.failFast||(i&&i.ensureAborted(),r(t,e))})),{abort:function(){i&&i.ensureAborted(),s.abort()},forceMinPriority:function(t){s.forceMinPriority(t)}}}}class kt{constructor(t){this.strategies=t}isSupported(){return A(this.strategies,v.method("isSupported"))}connect(t,e){return function(t,e,n){var r=C(t,(function(t,r,i,s){return t.connect(e,n(r,s))}));return{abort:function(){k(r,Ct)},forceMinPriority:function(t){k(r,(function(e){e.forceMinPriority(t)}))}}}(this.strategies,t,(function(t,n){return function(r,i){n[t].error=r,r?function(t){return function(t,e){for(var n=0;n=v.now()){var o=this.transports[r.transport];o&&(["ws","wss"].includes(r.transport)||i>3?(this.timeline.info({cached:!0,transport:r.transport,latency:r.latency}),s.push(new St([o],{timeout:2*r.latency+1e3,failFast:!0}))):i++)}var a=v.now(),h=s.pop().connect(t,(function r(o,c){o?(At(n),s.length>0?(a=v.now(),h=s.pop().connect(t,r)):e(o)):(!function(t,e,n,r){var i=ae.getLocalStorage();if(i)try{i[Pt(t)]=O({timestamp:v.now(),transport:e,latency:n,cacheSkipCount:r})}catch(t){}}(n,c.transport.name,v.now()-a,i),e(null,c))}));return{abort:function(){h.abort()},forceMinPriority:function(e){t=e,h&&h.forceMinPriority(e)}}}}function Pt(t){return"pusherTransport"+(t?"TLS":"NonTLS")}function At(t){var e=ae.getLocalStorage();if(e)try{delete e[Pt(t)]}catch(t){}}class Et{constructor(t,{delay:e}){this.strategy=t,this.options={delay:e}}isSupported(){return this.strategy.isSupported()}connect(t,e){var n,r=this.strategy,i=new g(this.options.delay,(function(){n=r.connect(t,e)}));return{abort:function(){i.ensureAborted(),n&&n.abort()},forceMinPriority:function(e){t=e,n&&n.forceMinPriority(e)}}}}class xt{constructor(t,e,n){this.test=t,this.trueBranch=e,this.falseBranch=n}isSupported(){return(this.test()?this.trueBranch:this.falseBranch).isSupported()}connect(t,e){return(this.test()?this.trueBranch:this.falseBranch).connect(t,e)}}class Ot{constructor(t){this.strategy=t}isSupported(){return this.strategy.isSupported()}connect(t,e){var n=this.strategy.connect(t,(function(t,r){r&&n.abort(),e(t,r)}));return n}}function Lt(t){return function(){return t.isSupported()}}var Ut=function(t,e,n){var r={};function i(e,i,s,o,a){var h=n(t,e,i,s,o,a);return r[e]=h,h}var s,o=Object.assign({},e,{hostNonTLS:t.wsHost+":"+t.wsPort,hostTLS:t.wsHost+":"+t.wssPort,httpPath:t.wsPath}),a=y({},o,{useTLS:!0}),h=Object.assign({},e,{hostNonTLS:t.httpHost+":"+t.httpPort,hostTLS:t.httpHost+":"+t.httpsPort,httpPath:t.httpPath}),c={loop:!0,timeout:15e3,timeoutLimit:6e4},u=new _t({minPingDelay:1e4,maxPingDelay:t.activityTimeout}),l=new _t({lives:2,minPingDelay:1e4,maxPingDelay:t.activityTimeout}),d=i("ws","ws",3,o,u),p=i("wss","ws",3,a,u),f=i("xhr_streaming","xhr_streaming",1,h,l),g=i("xhr_polling","xhr_polling",1,h),b=new St([d],c),v=new St([p],c),m=new St([f],c),w=new St([g],c),_=new St([new xt(Lt(m),new kt([m,new Et(w,{delay:4e3})]),w)],c);return s=e.useTLS?new kt([b,new Et(_,{delay:2e3})]):new kt([b,new Et(v,{delay:2e3}),new Et(_,{delay:5e3})]),new Tt(new Ot(new xt(Lt(d),s,_)),r,{ttl:18e5,timeline:e.timeline,useTLS:e.useTLS})};class Rt extends j{constructor(t,e,n){super(),this.hooks=t,this.method=e,this.url=n}start(t){this.position=0,this.xhr=this.hooks.getRequest(this),this.unloader=()=>{this.close()},ae.addUnloadListener(this.unloader),this.xhr.open(this.method,this.url,!0),this.xhr.setRequestHeader&&this.xhr.setRequestHeader("Content-Type","application/json"),this.xhr.send(t)}close(){this.unloader&&(ae.removeUnloadListener(this.unloader),this.unloader=null),this.xhr&&(this.hooks.abortRequest(this.xhr),this.xhr=null)}onChunk(t,e){for(;;){var n=this.advanceBuffer(e);if(!n)break;this.emit("chunk",{status:t,data:n})}this.isBufferTooLong(e)&&this.emit("buffer_too_long")}advanceBuffer(t){var e=t.slice(this.position),n=e.indexOf("\n");return-1!==n?(this.position+=n+1,e.slice(0,n)):null}isBufferTooLong(t){return this.position===t.length&&t.length>262144}}var Mt;!function(t){t[t.CONNECTING=0]="CONNECTING",t[t.OPEN=1]="OPEN",t[t.CLOSED=3]="CLOSED"}(Mt||(Mt={}));var It=Mt,Nt=1;function Dt(t){var e=-1===t.indexOf("?")?"?":"&";return t+e+"t="+ +new Date+"&n="+Nt++}function jt(t){return ae.randomInt(t)}var zt=class{constructor(t,e){this.hooks=t,this.session=jt(1e3)+"/"+function(t){for(var e=[],n=0;n{this.onChunk(t)}),this.stream.bind("finished",t=>{this.hooks.onFinished(this,t)}),this.stream.bind("buffer_too_long",()=>{this.reconnect()});try{this.stream.start()}catch(t){v.defer(()=>{this.onError(t),this.onClose(1006,"Could not start streaming",!1)})}}closeStream(){this.stream&&(this.stream.unbind_all(),this.stream.close(),this.stream=null)}},Ht={getReceiveURL:function(t,e){return t.base+"/"+e+"/xhr_streaming"+t.queryString},onHeartbeat:function(t){t.sendRaw("[]")},sendHeartbeat:function(t){t.sendRaw("[]")},onFinished:function(t,e){t.onClose(1006,"Connection interrupted ("+e+")",!1)}},Bt={getReceiveURL:function(t,e){return t.base+"/"+e+"/xhr"+t.queryString},onHeartbeat:function(){},sendHeartbeat:function(t){t.sendRaw("[]")},onFinished:function(t,e){200===e?t.reconnect():t.onClose(1006,"Connection interrupted ("+e+")",!1)}},Ft={getRequest:function(t){var e=new(ae.getXHRAPI());return e.onreadystatechange=e.onprogress=function(){switch(e.readyState){case 3:e.responseText&&e.responseText.length>0&&t.onChunk(e.status,e.responseText);break;case 4:e.responseText&&e.responseText.length>0&&t.onChunk(e.status,e.responseText),t.emit("finished",e.status),t.close()}},e},abortRequest:function(t){t.onreadystatechange=null,t.abort()}},qt={getDefaultStrategy:Ut,Transports:J,transportConnectionInitializer:function(){this.timeline.info(this.buildTimelineMessage({transport:this.name+(this.options.useTLS?"s":"")})),this.hooks.isInitialized()?this.changeState("initialized"):this.onClose()},HTTPFactory:{createStreamingSocket(t){return this.createSocket(Ht,t)},createPollingSocket(t){return this.createSocket(Bt,t)},createSocket:(t,e)=>new zt(t,e),createXHR(t,e){return this.createRequest(Ft,t,e)},createRequest:(t,e,n)=>new Rt(t,e,n)},setup(t){t.ready()},getLocalStorage(){},getClientFeatures:()=>S(P({ws:J.ws},(function(t){return t.isSupported({})}))),getProtocol:()=>"http:",isXHRSupported:()=>!0,createSocketRequest(t,e){if(this.isXHRSupported())return this.HTTPFactory.createXHR(t,e);throw"Cross-origin HTTP requests are not supported"},createXHR(){return new(this.getXHRAPI())},createWebSocket(t){return new(this.getWebSocketAPI())(t)},addUnloadListener(t){},removeUnloadListener(t){}};var Yt=new class extends j{isOnline(){return!0}},Kt=function(t,e,n,r,i){var s=new Headers;for(var o in s.set("Content-Type","application/x-www-form-urlencoded"),n.headers)s.set(o,n.headers[o]);if(null!=n.headersProvider){const t=n.headersProvider();for(var o in t)s.set(o,t[o])}var a=e,h=new Request(n.endpoint,{headers:s,body:a,credentials:"same-origin",method:"POST"});return fetch(h).then(t=>{let{status:e}=t;if(200===e)return t.text();throw new at(e,`Could not get ${r.toString()} info from your auth endpoint, status: ${e}`)}).then(t=>{let e;try{e=JSON.parse(t)}catch(e){throw new at(200,`JSON returned from ${r.toString()} endpoint was invalid, yet status code was 200. Data was: ${t}`)}i(null,e)}).catch(t=>{i(t,null)})},$t={name:"xhr",getAgent:function(t,e){return function(n,r){var i="http"+(e?"s":"")+"://"+(t.host||t.options.host)+t.options.path,s=x(n);fetch(i+="/2?"+s).then(t=>{if(200!==t.status)throw`received ${t.status} from stats.pusher.com`;return t.json()}).then(({host:e})=>{e&&(t.host=e)}).catch(t=>{z.debug("TimelineSender Error: ",t)})}}};const{getDefaultStrategy:Jt,Transports:Wt,setup:Xt,getProtocol:Gt,isXHRSupported:Vt,getLocalStorage:Zt,createXHR:Qt,createWebSocket:te,addUnloadListener:ee,removeUnloadListener:ne,transportConnectionInitializer:re,createSocketRequest:ie,HTTPFactory:se}=qt;var oe,ae={getDefaultStrategy:Jt,Transports:Wt,setup:Xt,getProtocol:Gt,isXHRSupported:Vt,getLocalStorage:Zt,createXHR:Qt,createWebSocket:te,addUnloadListener:ee,removeUnloadListener:ne,transportConnectionInitializer:re,createSocketRequest:ie,HTTPFactory:se,TimelineTransport:$t,getAuthorizers:()=>({ajax:Kt}),getWebSocketAPI:()=>WebSocket,getXHRAPI:()=>XMLHttpRequest,getNetwork:()=>Yt,randomInt:t=>Math.floor((globalThis.crypto||globalThis.msCrypto).getRandomValues(new Uint32Array(1))[0]/Math.pow(2,32)*t)};!function(t){t[t.ERROR=3]="ERROR",t[t.INFO=6]="INFO",t[t.DEBUG=7]="DEBUG"}(oe||(oe={}));var he=oe;class ce{constructor(t,e,n){this.key=t,this.session=e,this.events=[],this.options=n||{},this.sent=0,this.uniqueID=0}log(t,e){t<=this.options.level&&(this.events.push(y({},e,{timestamp:v.now()})),this.options.limit&&this.events.length>this.options.limit&&this.events.shift())}error(t){this.log(he.ERROR,t)}info(t){this.log(he.INFO,t)}debug(t){this.log(he.DEBUG,t)}isEmpty(){return 0===this.events.length}send(t,e){var n=y({session:this.session,bundle:this.sent+1,key:this.key,lib:"js",version:this.options.version,cluster:this.options.cluster,features:this.options.features,timeline:this.events},this.options.params);return this.events=[],t(n,(t,n)=>{t||this.sent++,e&&e(t,n)}),!0}generateUniqueID(){return this.uniqueID++,this.uniqueID}}class ue{constructor(t,e,n,r){this.name=t,this.priority=e,this.transport=n,this.options=r||{}}isSupported(){return this.transport.isSupported({useTLS:this.options.useTLS})}connect(t,e){if(!this.isSupported())return le(new ot,e);if(this.priority{n||(c(),i?i.close():r.close())},forceMinPriority:t=>{n||this.priority{if(void 0===ae.getAuthorizers()[t.transport])throw`'${t.transport}' is not a recognized auth transport`;return(e,n)=>{const r=((t,e)=>{var n="socket_id="+encodeURIComponent(t.socketId);for(var r in e.params)n+="&"+encodeURIComponent(r)+"="+encodeURIComponent(e.params[r]);if(null!=e.paramsProvider){let t=e.paramsProvider();for(var r in t)n+="&"+encodeURIComponent(r)+"="+encodeURIComponent(t[r])}return n})(e,t);ae.getAuthorizers()[t.transport](ae,r,t,pe.UserAuthentication,n)}};var ye=t=>{if(void 0===ae.getAuthorizers()[t.transport])throw`'${t.transport}' is not a recognized auth transport`;return(e,n)=>{const r=((t,e)=>{var n="socket_id="+encodeURIComponent(t.socketId);for(var r in n+="&channel_name="+encodeURIComponent(t.channelName),e.params)n+="&"+encodeURIComponent(r)+"="+encodeURIComponent(e.params[r]);if(null!=e.paramsProvider){let t=e.paramsProvider();for(var r in t)n+="&"+encodeURIComponent(r)+"="+encodeURIComponent(t[r])}return n})(e,t);ae.getAuthorizers()[t.transport](ae,r,t,pe.ChannelAuthorization,n)}};function me(t,e){let n={activityTimeout:t.activityTimeout||L.activityTimeout,cluster:t.cluster,httpPath:t.httpPath||L.httpPath,httpPort:t.httpPort||L.httpPort,httpsPort:t.httpsPort||L.httpsPort,pongTimeout:t.pongTimeout||L.pongTimeout,statsHost:t.statsHost||L.stats_host,unavailableTimeout:t.unavailableTimeout||L.unavailableTimeout,wsPath:t.wsPath||L.wsPath,wsPort:t.wsPort||L.wsPort,wssPort:t.wssPort||L.wssPort,enableStats:ke(t),httpHost:we(t),useTLS:Se(t),wsHost:_e(t),userAuthenticator:Ce(t),channelAuthorizer:Te(t,e)};return"disabledTransports"in t&&(n.disabledTransports=t.disabledTransports),"enabledTransports"in t&&(n.enabledTransports=t.enabledTransports),"ignoreNullOrigin"in t&&(n.ignoreNullOrigin=t.ignoreNullOrigin),"timelineParams"in t&&(n.timelineParams=t.timelineParams),"nacl"in t&&(n.nacl=t.nacl),n}function we(t){return t.httpHost?t.httpHost:t.cluster?`sockjs-${t.cluster}.pusher.com`:L.httpHost}function _e(t){return t.wsHost?t.wsHost:`ws-${t.cluster}.pusher.com`}function Se(t){return"https:"===ae.getProtocol()||!1!==t.forceTLS}function ke(t){return"enableStats"in t?t.enableStats:"disableStats"in t&&!t.disableStats}function Ce(t){const e=Object.assign(Object.assign({},L.userAuthentication),t.userAuthentication);return"customHandler"in e&&null!=e.customHandler?e.customHandler:ve(e)}function Te(t,e){const n=function(t,e){let n;return"channelAuthorization"in t?n=Object.assign(Object.assign({},L.channelAuthorization),t.channelAuthorization):(n={transport:t.authTransport||L.authTransport,endpoint:t.authEndpoint||L.authEndpoint},"auth"in t&&("params"in t.auth&&(n.params=t.auth.params),"headers"in t.auth&&(n.headers=t.auth.headers)),"authorizer"in t&&(n.customHandler=((t,e,n)=>{const r={authTransport:e.transport,authEndpoint:e.endpoint,auth:{params:e.params,headers:e.headers}};return(e,i)=>{const s=t.channel(e.channelName);n(s,r).authorize(e.socketId,i)}})(e,n,t.authorizer))),n}(t,e);return"customHandler"in n&&null!=n.customHandler?n.customHandler:ye(n)}class Pe extends j{constructor(t){super((function(t,e){z.debug("No callbacks on watchlist events for "+t)})),this.pusher=t,this.bindWatchlistInternalEvent()}handleEvent(t){t.data.events.forEach(t=>{this.emit(t.name,t)})}bindWatchlistInternalEvent(){this.pusher.connection.bind("message",t=>{"pusher_internal:watchlist_events"===t.event&&this.handleEvent(t)})}}var Ae=function(){let t,e;return{promise:new Promise((n,r)=>{t=n,e=r}),resolve:t,reject:e}};class Ee extends j{constructor(t){super((function(t,e){z.debug("No callbacks on user for "+t)})),this.signin_requested=!1,this.user_data=null,this.serverToUserChannel=null,this.signinDonePromise=null,this._signinDoneResolve=null,this._onAuthorize=(t,e)=>{if(t)return z.warn("Error during signin: "+t),void this._cleanup();this.pusher.send_event("pusher:signin",{auth:e.auth,user_data:e.user_data})},this.pusher=t,this.pusher.connection.bind("state_change",({previous:t,current:e})=>{"connected"!==t&&"connected"===e&&this._signin(),"connected"===t&&"connected"!==e&&(this._cleanup(),this._newSigninPromiseIfNeeded())}),this.watchlist=new Pe(t),this.pusher.connection.bind("message",t=>{"pusher:signin_success"===t.event&&this._onSigninSuccess(t.data),this.serverToUserChannel&&this.serverToUserChannel.name===t.channel&&this.serverToUserChannel.handleEvent(t)})}signin(){this.signin_requested||(this.signin_requested=!0,this._signin())}_signin(){this.signin_requested&&(this._newSigninPromiseIfNeeded(),"connected"===this.pusher.connection.state&&this.pusher.config.userAuthenticator({socketId:this.pusher.connection.socket_id},this._onAuthorize))}_onSigninSuccess(t){try{this.user_data=JSON.parse(t.user_data)}catch(e){return z.error("Failed parsing user data after signin: "+t.user_data),void this._cleanup()}if("string"!=typeof this.user_data.id||""===this.user_data.id)return z.error("user_data doesn't contain an id. user_data: "+this.user_data),void this._cleanup();this._signinDoneResolve(),this._subscribeChannels()}_subscribeChannels(){this.serverToUserChannel=new ut("#server-to-user-"+this.user_data.id,this.pusher),this.serverToUserChannel.bind_global((t,e)=>{0!==t.indexOf("pusher_internal:")&&0!==t.indexOf("pusher:")&&this.emit(t,e)}),(t=>{t.subscriptionPending&&t.subscriptionCancelled?t.reinstateSubscription():t.subscriptionPending||"connected"!==this.pusher.connection.state||t.subscribe()})(this.serverToUserChannel)}_cleanup(){this.user_data=null,this.serverToUserChannel&&(this.serverToUserChannel.unbind_all(),this.serverToUserChannel.disconnect(),this.serverToUserChannel=null),this.signin_requested&&this._signinDoneResolve()}_newSigninPromiseIfNeeded(){if(!this.signin_requested)return;if(this.signinDonePromise&&!this.signinDonePromise.done)return;const{promise:t,resolve:e,reject:n}=Ae();t.done=!1;const r=()=>{t.done=!0};t.then(r).catch(r),this.signinDonePromise=t,this._signinDoneResolve=e}}class xe{static ready(){xe.isReady=!0;for(var t=0,e=xe.instances.length;tae.getDefaultStrategy(this.config,t,fe),timeline:this.timeline,activityTimeout:this.config.activityTimeout,pongTimeout:this.config.pongTimeout,unavailableTimeout:this.config.unavailableTimeout,useTLS:Boolean(this.config.useTLS)}),this.connection.bind("connected",()=>{this.subscribeAll(),this.timelineSender&&this.timelineSender.send(this.connection.isUsingTLS())}),this.connection.bind("message",t=>{var e=0===t.event.indexOf("pusher_internal:");if(t.channel){var n=this.channel(t.channel);n&&n.handleEvent(t)}e||this.global_emitter.emit(t.event,t.data)}),this.connection.bind("connecting",()=>{this.channels.disconnect()}),this.connection.bind("disconnected",()=>{this.channels.disconnect()}),this.connection.bind("error",t=>{z.warn(t)}),xe.instances.push(this),this.timeline.info({instances:xe.instances.length}),this.user=new Ee(this),xe.isReady&&this.connect()}switchCluster(t){const{appKey:e,cluster:n}=t;this.key=e,this.options=Object.assign(Object.assign({},this.options),{cluster:n}),this.config=me(this.options,this),this.connection.switchCluster(this.key)}channel(t){return this.channels.find(t)}allChannels(){return this.channels.all()}connect(){if(this.connection.connect(),this.timelineSender&&!this.timelineSenderTimer){var t=this.connection.isUsingTLS(),e=this.timelineSender;this.timelineSenderTimer=new b(6e4,(function(){e.send(t)}))}}disconnect(){this.connection.disconnect(),this.timelineSenderTimer&&(this.timelineSenderTimer.ensureAborted(),this.timelineSenderTimer=null)}bind(t,e,n){return this.global_emitter.bind(t,e,n),this}unbind(t,e,n){return this.global_emitter.unbind(t,e,n),this}bind_global(t){return this.global_emitter.bind_global(t),this}unbind_global(t){return this.global_emitter.unbind_global(t),this}unbind_all(t){return this.global_emitter.unbind_all(),this}subscribeAll(){var t;for(t in this.channels.channels)this.channels.channels.hasOwnProperty(t)&&this.subscribe(t)}subscribe(t){var e=this.channels.add(t,this);return e.subscriptionPending&&e.subscriptionCancelled?e.reinstateSubscription():e.subscriptionPending||"connected"!==this.connection.state||e.subscribe(),e}unsubscribe(t){var e=this.channels.find(t);e&&e.subscriptionPending?e.cancelSubscription():(e=this.channels.remove(t))&&e.subscribed&&e.unsubscribe()}send_event(t,e,n){return this.connection.send_event(t,e,n)}shouldUseTLS(){return this.config.useTLS}signin(){this.user.signin()}}xe.instances=[],xe.isReady=!1,xe.logToConsole=!1,xe.Runtime=ae,xe.ScriptReceivers=ae.ScriptReceivers,xe.DependenciesReceivers=ae.DependenciesReceivers,xe.auth_callbacks=ae.auth_callbacks;var Oe=xe;ae.setup(xe);var Le=n(2);class Ue extends Oe{constructor(t,e){Oe.logToConsole=Ue.logToConsole,Oe.log=Ue.log,be(e),e.nacl=Le,super(t,e)}}}])})); +!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.Pusher=e():t.Pusher=e()}(this,(function(){return function(t){var e={};function n(r){if(e[r])return e[r].exports;var i=e[r]={i:r,l:!1,exports:{}};return t[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)n.d(r,i,function(e){return t[e]}.bind(null,i));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=3)}([function(t,e,n){"use strict";var r,i=this&&this.__extends||(r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)},function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)});Object.defineProperty(e,"__esModule",{value:!0});var s=function(){function t(t){void 0===t&&(t="="),this._paddingCharacter=t}return t.prototype.encodedLength=function(t){return this._paddingCharacter?(t+2)/3*4|0:(8*t+5)/6|0},t.prototype.encode=function(t){for(var e="",n=0;n>>18&63),e+=this._encodeByte(r>>>12&63),e+=this._encodeByte(r>>>6&63),e+=this._encodeByte(r>>>0&63)}var i=t.length-n;if(i>0){r=t[n]<<16|(2===i?t[n+1]<<8:0);e+=this._encodeByte(r>>>18&63),e+=this._encodeByte(r>>>12&63),e+=2===i?this._encodeByte(r>>>6&63):this._paddingCharacter||"",e+=this._paddingCharacter||""}return e},t.prototype.maxDecodedLength=function(t){return this._paddingCharacter?t/4*3|0:(6*t+7)/8|0},t.prototype.decodedLength=function(t){return this.maxDecodedLength(t.length-this._getPaddingLength(t))},t.prototype.decode=function(t){if(0===t.length)return new Uint8Array(0);for(var e=this._getPaddingLength(t),n=t.length-e,r=new Uint8Array(this.maxDecodedLength(n)),i=0,s=0,o=0,a=0,h=0,c=0,u=0;s>>4,r[i++]=h<<4|c>>>2,r[i++]=c<<6|u,o|=256&a,o|=256&h,o|=256&c,o|=256&u;if(s>>4,o|=256&a,o|=256&h),s>>2,o|=256&c),s>>8&6,e+=51-t>>>8&-75,e+=61-t>>>8&-15,e+=62-t>>>8&3,String.fromCharCode(e)},t.prototype._decodeChar=function(t){var e=256;return e+=(42-t&t-44)>>>8&-256+t-43+62,e+=(46-t&t-48)>>>8&-256+t-47+63,e+=(47-t&t-58)>>>8&-256+t-48+52,e+=(64-t&t-91)>>>8&-256+t-65+0,e+=(96-t&t-123)>>>8&-256+t-97+26},t.prototype._getPaddingLength=function(t){var e=0;if(this._paddingCharacter){for(var n=t.length-1;n>=0&&t[n]===this._paddingCharacter;n--)e++;if(t.length<4||e>2)throw new Error("Base64Coder: incorrect padding")}return e},t}();e.Coder=s;var o=new s;e.encode=function(t){return o.encode(t)},e.decode=function(t){return o.decode(t)};var a=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return i(e,t),e.prototype._encodeByte=function(t){var e=t;return e+=65,e+=25-t>>>8&6,e+=51-t>>>8&-75,e+=61-t>>>8&-13,e+=62-t>>>8&49,String.fromCharCode(e)},e.prototype._decodeChar=function(t){var e=256;return e+=(44-t&t-46)>>>8&-256+t-45+62,e+=(94-t&t-96)>>>8&-256+t-95+63,e+=(47-t&t-58)>>>8&-256+t-48+52,e+=(64-t&t-91)>>>8&-256+t-65+0,e+=(96-t&t-123)>>>8&-256+t-97+26},e}(s);e.URLSafeCoder=a;var h=new a;e.encodeURLSafe=function(t){return h.encode(t)},e.decodeURLSafe=function(t){return h.decode(t)},e.encodedLength=function(t){return o.encodedLength(t)},e.maxDecodedLength=function(t){return o.maxDecodedLength(t)},e.decodedLength=function(t){return o.decodedLength(t)}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r="utf8: invalid source encoding";function i(t){for(var e=0,n=0;n=t.length-1)throw new Error("utf8: invalid string");n++,e+=4}}return e}e.encode=function(t){for(var e=new Uint8Array(i(t)),n=0,r=0;r>6,e[n++]=128|63&s):s<55296?(e[n++]=224|s>>12,e[n++]=128|s>>6&63,e[n++]=128|63&s):(r++,s=(1023&s)<<10,s|=1023&t.charCodeAt(r),s+=65536,e[n++]=240|s>>18,e[n++]=128|s>>12&63,e[n++]=128|s>>6&63,e[n++]=128|63&s)}return e},e.encodedLength=i,e.decode=function(t){for(var e=[],n=0;n=t.length)throw new Error(r);if(128!=(192&(o=t[++n])))throw new Error(r);i=(31&i)<<6|63&o,s=128}else if(i<240){if(n>=t.length-1)throw new Error(r);var o=t[++n],a=t[++n];if(128!=(192&o)||128!=(192&a))throw new Error(r);i=(15&i)<<12|(63&o)<<6|63&a,s=2048}else{if(!(i<248))throw new Error(r);if(n>=t.length-2)throw new Error(r);o=t[++n],a=t[++n];var h=t[++n];if(128!=(192&o)||128!=(192&a)||128!=(192&h))throw new Error(r);i=(15&i)<<18|(63&o)<<12|(63&a)<<6|63&h,s=65536}if(i=55296&&i<=57343)throw new Error(r);if(i>=65536){if(i>1114111)throw new Error(r);i-=65536,e.push(String.fromCharCode(55296|i>>10)),i=56320|1023&i}}e.push(String.fromCharCode(i))}return e.join("")}},function(t,e,n){!function(t){"use strict";var e=function(t){var e,n=new Float64Array(16);if(t)for(e=0;e>24&255,t[e+1]=n>>16&255,t[e+2]=n>>8&255,t[e+3]=255&n,t[e+4]=r>>24&255,t[e+5]=r>>16&255,t[e+6]=r>>8&255,t[e+7]=255&r}function g(t,e,n,r,i){var s,o=0;for(s=0;s>>8)-1}function b(t,e,n,r){return g(t,e,n,r,16)}function v(t,e,n,r){return g(t,e,n,r,32)}function y(t,e,n,r){!function(t,e,n,r){for(var i,s=255&r[0]|(255&r[1])<<8|(255&r[2])<<16|(255&r[3])<<24,o=255&n[0]|(255&n[1])<<8|(255&n[2])<<16|(255&n[3])<<24,a=255&n[4]|(255&n[5])<<8|(255&n[6])<<16|(255&n[7])<<24,h=255&n[8]|(255&n[9])<<8|(255&n[10])<<16|(255&n[11])<<24,c=255&n[12]|(255&n[13])<<8|(255&n[14])<<16|(255&n[15])<<24,u=255&r[4]|(255&r[5])<<8|(255&r[6])<<16|(255&r[7])<<24,l=255&e[0]|(255&e[1])<<8|(255&e[2])<<16|(255&e[3])<<24,d=255&e[4]|(255&e[5])<<8|(255&e[6])<<16|(255&e[7])<<24,p=255&e[8]|(255&e[9])<<8|(255&e[10])<<16|(255&e[11])<<24,f=255&e[12]|(255&e[13])<<8|(255&e[14])<<16|(255&e[15])<<24,g=255&r[8]|(255&r[9])<<8|(255&r[10])<<16|(255&r[11])<<24,b=255&n[16]|(255&n[17])<<8|(255&n[18])<<16|(255&n[19])<<24,v=255&n[20]|(255&n[21])<<8|(255&n[22])<<16|(255&n[23])<<24,y=255&n[24]|(255&n[25])<<8|(255&n[26])<<16|(255&n[27])<<24,m=255&n[28]|(255&n[29])<<8|(255&n[30])<<16|(255&n[31])<<24,w=255&r[12]|(255&r[13])<<8|(255&r[14])<<16|(255&r[15])<<24,_=s,S=o,k=a,C=h,T=c,P=u,A=l,E=d,x=p,O=f,L=g,U=b,R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>0&255,t[13]=C>>>8&255,t[14]=C>>>16&255,t[15]=C>>>24&255,t[16]=T>>>0&255,t[17]=T>>>8&255,t[18]=T>>>16&255,t[19]=T>>>24&255,t[20]=P>>>0&255,t[21]=P>>>8&255,t[22]=P>>>16&255,t[23]=P>>>24&255,t[24]=A>>>0&255,t[25]=A>>>8&255,t[26]=A>>>16&255,t[27]=A>>>24&255,t[28]=E>>>0&255,t[29]=E>>>8&255,t[30]=E>>>16&255,t[31]=E>>>24&255,t[32]=x>>>0&255,t[33]=x>>>8&255,t[34]=x>>>16&255,t[35]=x>>>24&255,t[36]=O>>>0&255,t[37]=O>>>8&255,t[38]=O>>>16&255,t[39]=O>>>24&255,t[40]=L>>>0&255,t[41]=L>>>8&255,t[42]=L>>>16&255,t[43]=L>>>24&255,t[44]=U>>>0&255,t[45]=U>>>8&255,t[46]=U>>>16&255,t[47]=U>>>24&255,t[48]=R>>>0&255,t[49]=R>>>8&255,t[50]=R>>>16&255,t[51]=R>>>24&255,t[52]=M>>>0&255,t[53]=M>>>8&255,t[54]=M>>>16&255,t[55]=M>>>24&255,t[56]=I>>>0&255,t[57]=I>>>8&255,t[58]=I>>>16&255,t[59]=I>>>24&255,t[60]=N>>>0&255,t[61]=N>>>8&255,t[62]=N>>>16&255,t[63]=N>>>24&255}(t,e,n,r)}function m(t,e,n,r){!function(t,e,n,r){for(var i,s=255&r[0]|(255&r[1])<<8|(255&r[2])<<16|(255&r[3])<<24,o=255&n[0]|(255&n[1])<<8|(255&n[2])<<16|(255&n[3])<<24,a=255&n[4]|(255&n[5])<<8|(255&n[6])<<16|(255&n[7])<<24,h=255&n[8]|(255&n[9])<<8|(255&n[10])<<16|(255&n[11])<<24,c=255&n[12]|(255&n[13])<<8|(255&n[14])<<16|(255&n[15])<<24,u=255&r[4]|(255&r[5])<<8|(255&r[6])<<16|(255&r[7])<<24,l=255&e[0]|(255&e[1])<<8|(255&e[2])<<16|(255&e[3])<<24,d=255&e[4]|(255&e[5])<<8|(255&e[6])<<16|(255&e[7])<<24,p=255&e[8]|(255&e[9])<<8|(255&e[10])<<16|(255&e[11])<<24,f=255&e[12]|(255&e[13])<<8|(255&e[14])<<16|(255&e[15])<<24,g=255&r[8]|(255&r[9])<<8|(255&r[10])<<16|(255&r[11])<<24,b=255&n[16]|(255&n[17])<<8|(255&n[18])<<16|(255&n[19])<<24,v=255&n[20]|(255&n[21])<<8|(255&n[22])<<16|(255&n[23])<<24,y=255&n[24]|(255&n[25])<<8|(255&n[26])<<16|(255&n[27])<<24,m=255&n[28]|(255&n[29])<<8|(255&n[30])<<16|(255&n[31])<<24,w=255&r[12]|(255&r[13])<<8|(255&r[14])<<16|(255&r[15])<<24,_=0;_<20;_+=2)s^=(i=(v^=(i=(p^=(i=(c^=(i=s+v|0)<<7|i>>>25)+s|0)<<9|i>>>23)+c|0)<<13|i>>>19)+p|0)<<18|i>>>14,u^=(i=(o^=(i=(y^=(i=(f^=(i=u+o|0)<<7|i>>>25)+u|0)<<9|i>>>23)+f|0)<<13|i>>>19)+y|0)<<18|i>>>14,g^=(i=(l^=(i=(a^=(i=(m^=(i=g+l|0)<<7|i>>>25)+g|0)<<9|i>>>23)+m|0)<<13|i>>>19)+a|0)<<18|i>>>14,w^=(i=(b^=(i=(d^=(i=(h^=(i=w+b|0)<<7|i>>>25)+w|0)<<9|i>>>23)+h|0)<<13|i>>>19)+d|0)<<18|i>>>14,s^=(i=(h^=(i=(a^=(i=(o^=(i=s+h|0)<<7|i>>>25)+s|0)<<9|i>>>23)+o|0)<<13|i>>>19)+a|0)<<18|i>>>14,u^=(i=(c^=(i=(d^=(i=(l^=(i=u+c|0)<<7|i>>>25)+u|0)<<9|i>>>23)+l|0)<<13|i>>>19)+d|0)<<18|i>>>14,g^=(i=(f^=(i=(p^=(i=(b^=(i=g+f|0)<<7|i>>>25)+g|0)<<9|i>>>23)+b|0)<<13|i>>>19)+p|0)<<18|i>>>14,w^=(i=(m^=(i=(y^=(i=(v^=(i=w+m|0)<<7|i>>>25)+w|0)<<9|i>>>23)+v|0)<<13|i>>>19)+y|0)<<18|i>>>14;t[0]=s>>>0&255,t[1]=s>>>8&255,t[2]=s>>>16&255,t[3]=s>>>24&255,t[4]=u>>>0&255,t[5]=u>>>8&255,t[6]=u>>>16&255,t[7]=u>>>24&255,t[8]=g>>>0&255,t[9]=g>>>8&255,t[10]=g>>>16&255,t[11]=g>>>24&255,t[12]=w>>>0&255,t[13]=w>>>8&255,t[14]=w>>>16&255,t[15]=w>>>24&255,t[16]=l>>>0&255,t[17]=l>>>8&255,t[18]=l>>>16&255,t[19]=l>>>24&255,t[20]=d>>>0&255,t[21]=d>>>8&255,t[22]=d>>>16&255,t[23]=d>>>24&255,t[24]=p>>>0&255,t[25]=p>>>8&255,t[26]=p>>>16&255,t[27]=p>>>24&255,t[28]=f>>>0&255,t[29]=f>>>8&255,t[30]=f>>>16&255,t[31]=f>>>24&255}(t,e,n,r)}var w=new Uint8Array([101,120,112,97,110,100,32,51,50,45,98,121,116,101,32,107]);function _(t,e,n,r,i,s,o){var a,h,c=new Uint8Array(16),u=new Uint8Array(64);for(h=0;h<16;h++)c[h]=0;for(h=0;h<8;h++)c[h]=s[h];for(;i>=64;){for(y(u,c,o,w),h=0;h<64;h++)t[e+h]=n[r+h]^u[h];for(a=1,h=8;h<16;h++)a=a+(255&c[h])|0,c[h]=255&a,a>>>=8;i-=64,e+=64,r+=64}if(i>0)for(y(u,c,o,w),h=0;h=64;){for(y(h,a,i,w),o=0;o<64;o++)t[e+o]=h[o];for(s=1,o=8;o<16;o++)s=s+(255&a[o])|0,a[o]=255&s,s>>>=8;n-=64,e+=64}if(n>0)for(y(h,a,i,w),o=0;o>>13|n<<3),r=255&t[4]|(255&t[5])<<8,this.r[2]=7939&(n>>>10|r<<6),i=255&t[6]|(255&t[7])<<8,this.r[3]=8191&(r>>>7|i<<9),s=255&t[8]|(255&t[9])<<8,this.r[4]=255&(i>>>4|s<<12),this.r[5]=s>>>1&8190,o=255&t[10]|(255&t[11])<<8,this.r[6]=8191&(s>>>14|o<<2),a=255&t[12]|(255&t[13])<<8,this.r[7]=8065&(o>>>11|a<<5),h=255&t[14]|(255&t[15])<<8,this.r[8]=8191&(a>>>8|h<<8),this.r[9]=h>>>5&127,this.pad[0]=255&t[16]|(255&t[17])<<8,this.pad[1]=255&t[18]|(255&t[19])<<8,this.pad[2]=255&t[20]|(255&t[21])<<8,this.pad[3]=255&t[22]|(255&t[23])<<8,this.pad[4]=255&t[24]|(255&t[25])<<8,this.pad[5]=255&t[26]|(255&t[27])<<8,this.pad[6]=255&t[28]|(255&t[29])<<8,this.pad[7]=255&t[30]|(255&t[31])<<8};function P(t,e,n,r,i,s){var o=new T(s);return o.update(n,r,i),o.finish(t,e),0}function A(t,e,n,r,i,s){var o=new Uint8Array(16);return P(o,0,n,r,i,s),b(t,e,o,0)}function E(t,e,n,r,i){var s;if(n<32)return-1;for(C(t,0,e,0,n,r,i),P(t,16,t,32,n-32,t),s=0;s<16;s++)t[s]=0;return 0}function x(t,e,n,r,i){var s,o=new Uint8Array(32);if(n<32)return-1;if(k(o,0,32,r,i),0!==A(e,16,e,32,n-32,o))return-1;for(C(t,0,e,0,n,r,i),s=0;s<32;s++)t[s]=0;return 0}function O(t,e){var n;for(n=0;n<16;n++)t[n]=0|e[n]}function L(t){var e,n,r=1;for(e=0;e<16;e++)n=t[e]+r+65535,r=Math.floor(n/65536),t[e]=n-65536*r;t[0]+=r-1+37*(r-1)}function U(t,e,n){for(var r,i=~(n-1),s=0;s<16;s++)r=i&(t[s]^e[s]),t[s]^=r,e[s]^=r}function R(t,n){var r,i,s,o=e(),a=e();for(r=0;r<16;r++)a[r]=n[r];for(L(a),L(a),L(a),i=0;i<2;i++){for(o[0]=a[0]-65517,r=1;r<15;r++)o[r]=a[r]-65535-(o[r-1]>>16&1),o[r-1]&=65535;o[15]=a[15]-32767-(o[14]>>16&1),s=o[15]>>16&1,o[14]&=65535,U(a,o,1-s)}for(r=0;r<16;r++)t[2*r]=255&a[r],t[2*r+1]=a[r]>>8}function M(t,e){var n=new Uint8Array(32),r=new Uint8Array(32);return R(n,t),R(r,e),v(n,0,r,0)}function I(t){var e=new Uint8Array(32);return R(e,t),1&e[0]}function N(t,e){var n;for(n=0;n<16;n++)t[n]=e[2*n]+(e[2*n+1]<<8);t[15]&=32767}function D(t,e,n){for(var r=0;r<16;r++)t[r]=e[r]+n[r]}function j(t,e,n){for(var r=0;r<16;r++)t[r]=e[r]-n[r]}function z(t,e,n){var r,i,s=0,o=0,a=0,h=0,c=0,u=0,l=0,d=0,p=0,f=0,g=0,b=0,v=0,y=0,m=0,w=0,_=0,S=0,k=0,C=0,T=0,P=0,A=0,E=0,x=0,O=0,L=0,U=0,R=0,M=0,I=0,N=n[0],D=n[1],j=n[2],z=n[3],H=n[4],B=n[5],F=n[6],q=n[7],Y=n[8],K=n[9],$=n[10],J=n[11],W=n[12],X=n[13],G=n[14],V=n[15];s+=(r=e[0])*N,o+=r*D,a+=r*j,h+=r*z,c+=r*H,u+=r*B,l+=r*F,d+=r*q,p+=r*Y,f+=r*K,g+=r*$,b+=r*J,v+=r*W,y+=r*X,m+=r*G,w+=r*V,o+=(r=e[1])*N,a+=r*D,h+=r*j,c+=r*z,u+=r*H,l+=r*B,d+=r*F,p+=r*q,f+=r*Y,g+=r*K,b+=r*$,v+=r*J,y+=r*W,m+=r*X,w+=r*G,_+=r*V,a+=(r=e[2])*N,h+=r*D,c+=r*j,u+=r*z,l+=r*H,d+=r*B,p+=r*F,f+=r*q,g+=r*Y,b+=r*K,v+=r*$,y+=r*J,m+=r*W,w+=r*X,_+=r*G,S+=r*V,h+=(r=e[3])*N,c+=r*D,u+=r*j,l+=r*z,d+=r*H,p+=r*B,f+=r*F,g+=r*q,b+=r*Y,v+=r*K,y+=r*$,m+=r*J,w+=r*W,_+=r*X,S+=r*G,k+=r*V,c+=(r=e[4])*N,u+=r*D,l+=r*j,d+=r*z,p+=r*H,f+=r*B,g+=r*F,b+=r*q,v+=r*Y,y+=r*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+=r*z,S+=r*H,k+=r*B,C+=r*F,T+=r*q,P+=r*Y,A+=r*K,E+=r*$,x+=r*J,O+=r*W,L+=r*X,U+=r*G,R+=r*V,m+=(r=e[14])*N,w+=r*D,_+=r*j,S+=r*z,k+=r*H,C+=r*B,T+=r*F,P+=r*q,A+=r*Y,E+=r*K,x+=r*$,O+=r*J,L+=r*W,U+=r*X,R+=r*G,M+=r*V,w+=(r=e[15])*N,o+=38*(S+=r*j),a+=38*(k+=r*z),h+=38*(C+=r*H),c+=38*(T+=r*B),u+=38*(P+=r*F),l+=38*(A+=r*q),d+=38*(E+=r*Y),p+=38*(x+=r*K),f+=38*(O+=r*$),g+=38*(L+=r*J),b+=38*(U+=r*W),v+=38*(R+=r*X),y+=38*(M+=r*G),m+=38*(I+=r*V),s=(r=(s+=38*(_+=r*D))+(i=1)+65535)-65536*(i=Math.floor(r/65536)),o=(r=o+i+65535)-65536*(i=Math.floor(r/65536)),a=(r=a+i+65535)-65536*(i=Math.floor(r/65536)),h=(r=h+i+65535)-65536*(i=Math.floor(r/65536)),c=(r=c+i+65535)-65536*(i=Math.floor(r/65536)),u=(r=u+i+65535)-65536*(i=Math.floor(r/65536)),l=(r=l+i+65535)-65536*(i=Math.floor(r/65536)),d=(r=d+i+65535)-65536*(i=Math.floor(r/65536)),p=(r=p+i+65535)-65536*(i=Math.floor(r/65536)),f=(r=f+i+65535)-65536*(i=Math.floor(r/65536)),g=(r=g+i+65535)-65536*(i=Math.floor(r/65536)),b=(r=b+i+65535)-65536*(i=Math.floor(r/65536)),v=(r=v+i+65535)-65536*(i=Math.floor(r/65536)),y=(r=y+i+65535)-65536*(i=Math.floor(r/65536)),m=(r=m+i+65535)-65536*(i=Math.floor(r/65536)),w=(r=w+i+65535)-65536*(i=Math.floor(r/65536)),s=(r=(s+=i-1+37*(i-1))+(i=1)+65535)-65536*(i=Math.floor(r/65536)),o=(r=o+i+65535)-65536*(i=Math.floor(r/65536)),a=(r=a+i+65535)-65536*(i=Math.floor(r/65536)),h=(r=h+i+65535)-65536*(i=Math.floor(r/65536)),c=(r=c+i+65535)-65536*(i=Math.floor(r/65536)),u=(r=u+i+65535)-65536*(i=Math.floor(r/65536)),l=(r=l+i+65535)-65536*(i=Math.floor(r/65536)),d=(r=d+i+65535)-65536*(i=Math.floor(r/65536)),p=(r=p+i+65535)-65536*(i=Math.floor(r/65536)),f=(r=f+i+65535)-65536*(i=Math.floor(r/65536)),g=(r=g+i+65535)-65536*(i=Math.floor(r/65536)),b=(r=b+i+65535)-65536*(i=Math.floor(r/65536)),v=(r=v+i+65535)-65536*(i=Math.floor(r/65536)),y=(r=y+i+65535)-65536*(i=Math.floor(r/65536)),m=(r=m+i+65535)-65536*(i=Math.floor(r/65536)),w=(r=w+i+65535)-65536*(i=Math.floor(r/65536)),s+=i-1+37*(i-1),t[0]=s,t[1]=o,t[2]=a,t[3]=h,t[4]=c,t[5]=u,t[6]=l,t[7]=d,t[8]=p,t[9]=f,t[10]=g,t[11]=b,t[12]=v,t[13]=y,t[14]=m,t[15]=w}function H(t,e){z(t,e,e)}function B(t,n){var r,i=e();for(r=0;r<16;r++)i[r]=n[r];for(r=253;r>=0;r--)H(i,i),2!==r&&4!==r&&z(i,i,n);for(r=0;r<16;r++)t[r]=i[r]}function F(t,n){var r,i=e();for(r=0;r<16;r++)i[r]=n[r];for(r=250;r>=0;r--)H(i,i),1!==r&&z(i,i,n);for(r=0;r<16;r++)t[r]=i[r]}function q(t,n,r){var i,s,o=new Uint8Array(32),a=new Float64Array(80),c=e(),u=e(),l=e(),d=e(),p=e(),f=e();for(s=0;s<31;s++)o[s]=n[s];for(o[31]=127&n[31]|64,o[0]&=248,N(a,r),s=0;s<16;s++)u[s]=a[s],d[s]=c[s]=l[s]=0;for(c[0]=d[0]=1,s=254;s>=0;--s)U(c,u,i=o[s>>>3]>>>(7&s)&1),U(l,d,i),D(p,c,l),j(c,c,l),D(l,u,d),j(u,u,d),H(d,p),H(f,c),z(c,l,c),z(l,u,p),D(p,c,l),j(c,c,l),H(u,c),j(l,d,f),z(c,l,h),D(c,c,d),z(l,l,c),z(c,d,f),z(d,u,a),H(u,p),U(c,u,i),U(l,d,i);for(s=0;s<16;s++)a[s+16]=c[s],a[s+32]=l[s],a[s+48]=u[s],a[s+64]=d[s];var g=a.subarray(32),b=a.subarray(16);return B(g,g),z(b,b,g),R(t,b),0}function Y(t,e){return q(t,e,s)}function K(t,e){return r(e,32),Y(t,e)}function $(t,e,n){var r=new Uint8Array(32);return q(r,n,e),m(t,i,r,w)}T.prototype.blocks=function(t,e,n){for(var r,i,s,o,a,h,c,u,l,d,p,f,g,b,v,y,m,w,_,S=this.fin?0:2048,k=this.h[0],C=this.h[1],T=this.h[2],P=this.h[3],A=this.h[4],E=this.h[5],x=this.h[6],O=this.h[7],L=this.h[8],U=this.h[9],R=this.r[0],M=this.r[1],I=this.r[2],N=this.r[3],D=this.r[4],j=this.r[5],z=this.r[6],H=this.r[7],B=this.r[8],F=this.r[9];n>=16;)d=l=0,d+=(k+=8191&(r=255&t[e+0]|(255&t[e+1])<<8))*R,d+=(C+=8191&(r>>>13|(i=255&t[e+2]|(255&t[e+3])<<8)<<3))*(5*F),d+=(T+=8191&(i>>>10|(s=255&t[e+4]|(255&t[e+5])<<8)<<6))*(5*B),d+=(P+=8191&(s>>>7|(o=255&t[e+6]|(255&t[e+7])<<8)<<9))*(5*H),l=(d+=(A+=8191&(o>>>4|(a=255&t[e+8]|(255&t[e+9])<<8)<<12))*(5*z))>>>13,d&=8191,d+=(E+=a>>>1&8191)*(5*j),d+=(x+=8191&(a>>>14|(h=255&t[e+10]|(255&t[e+11])<<8)<<2))*(5*D),d+=(O+=8191&(h>>>11|(c=255&t[e+12]|(255&t[e+13])<<8)<<5))*(5*N),d+=(L+=8191&(c>>>8|(u=255&t[e+14]|(255&t[e+15])<<8)<<8))*(5*I),p=l+=(d+=(U+=u>>>5|S)*(5*M))>>>13,p+=k*M,p+=C*R,p+=T*(5*F),p+=P*(5*B),l=(p+=A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w&=8191,U=_&=8191,e+=16,n-=16;this.h[0]=k,this.h[1]=C,this.h[2]=T,this.h[3]=P,this.h[4]=A,this.h[5]=E,this.h[6]=x,this.h[7]=O,this.h[8]=L,this.h[9]=U},T.prototype.finish=function(t,e){var n,r,i,s,o=new Uint16Array(10);if(this.leftover){for(s=this.leftover,this.buffer[s++]=1;s<16;s++)this.buffer[s]=0;this.fin=1,this.blocks(this.buffer,0,16)}for(n=this.h[1]>>>13,this.h[1]&=8191,s=2;s<10;s++)this.h[s]+=n,n=this.h[s]>>>13,this.h[s]&=8191;for(this.h[0]+=5*n,n=this.h[0]>>>13,this.h[0]&=8191,this.h[1]+=n,n=this.h[1]>>>13,this.h[1]&=8191,this.h[2]+=n,o[0]=this.h[0]+5,n=o[0]>>>13,o[0]&=8191,s=1;s<10;s++)o[s]=this.h[s]+n,n=o[s]>>>13,o[s]&=8191;for(o[9]-=8192,r=(1^n)-1,s=0;s<10;s++)o[s]&=r;for(r=~r,s=0;s<10;s++)this.h[s]=this.h[s]&r|o[s];for(this.h[0]=65535&(this.h[0]|this.h[1]<<13),this.h[1]=65535&(this.h[1]>>>3|this.h[2]<<10),this.h[2]=65535&(this.h[2]>>>6|this.h[3]<<7),this.h[3]=65535&(this.h[3]>>>9|this.h[4]<<4),this.h[4]=65535&(this.h[4]>>>12|this.h[5]<<1|this.h[6]<<14),this.h[5]=65535&(this.h[6]>>>2|this.h[7]<<11),this.h[6]=65535&(this.h[7]>>>5|this.h[8]<<8),this.h[7]=65535&(this.h[8]>>>8|this.h[9]<<5),i=this.h[0]+this.pad[0],this.h[0]=65535&i,s=1;s<8;s++)i=(this.h[s]+this.pad[s]|0)+(i>>>16)|0,this.h[s]=65535&i;t[e+0]=this.h[0]>>>0&255,t[e+1]=this.h[0]>>>8&255,t[e+2]=this.h[1]>>>0&255,t[e+3]=this.h[1]>>>8&255,t[e+4]=this.h[2]>>>0&255,t[e+5]=this.h[2]>>>8&255,t[e+6]=this.h[3]>>>0&255,t[e+7]=this.h[3]>>>8&255,t[e+8]=this.h[4]>>>0&255,t[e+9]=this.h[4]>>>8&255,t[e+10]=this.h[5]>>>0&255,t[e+11]=this.h[5]>>>8&255,t[e+12]=this.h[6]>>>0&255,t[e+13]=this.h[6]>>>8&255,t[e+14]=this.h[7]>>>0&255,t[e+15]=this.h[7]>>>8&255},T.prototype.update=function(t,e,n){var r,i;if(this.leftover){for((i=16-this.leftover)>n&&(i=n),r=0;r=16&&(i=n-n%16,this.blocks(t,e,i),e+=i,n-=i),n){for(r=0;r=128;){for(S=0;S<16;S++)k=8*S+W,O[S]=n[k+0]<<24|n[k+1]<<16|n[k+2]<<8|n[k+3],L[S]=n[k+4]<<24|n[k+5]<<16|n[k+6]<<8|n[k+7];for(S=0;S<80;S++)if(i=U,s=R,o=M,a=I,h=N,c=D,u=j,z,d=H,p=B,f=F,g=q,b=Y,v=K,y=$,J,P=65535&(T=J),A=T>>>16,E=65535&(C=z),x=C>>>16,P+=65535&(T=(Y>>>14|N<<18)^(Y>>>18|N<<14)^(N>>>9|Y<<23)),A+=T>>>16,E+=65535&(C=(N>>>14|Y<<18)^(N>>>18|Y<<14)^(Y>>>9|N<<23)),x+=C>>>16,P+=65535&(T=Y&K^~Y&$),A+=T>>>16,E+=65535&(C=N&D^~N&j),x+=C>>>16,P+=65535&(T=X[2*S+1]),A+=T>>>16,E+=65535&(C=X[2*S]),x+=C>>>16,C=O[S%16],A+=(T=L[S%16])>>>16,E+=65535&C,x+=C>>>16,E+=(A+=(P+=65535&T)>>>16)>>>16,P=65535&(T=_=65535&P|A<<16),A=T>>>16,E=65535&(C=w=65535&E|(x+=E>>>16)<<16),x=C>>>16,P+=65535&(T=(H>>>28|U<<4)^(U>>>2|H<<30)^(U>>>7|H<<25)),A+=T>>>16,E+=65535&(C=(U>>>28|H<<4)^(H>>>2|U<<30)^(H>>>7|U<<25)),x+=C>>>16,A+=(T=H&B^H&F^B&F)>>>16,E+=65535&(C=U&R^U&M^R&M),x+=C>>>16,l=65535&(E+=(A+=(P+=65535&T)>>>16)>>>16)|(x+=E>>>16)<<16,m=65535&P|A<<16,P=65535&(T=g),A=T>>>16,E=65535&(C=a),x=C>>>16,A+=(T=_)>>>16,E+=65535&(C=w),x+=C>>>16,R=i,M=s,I=o,N=a=65535&(E+=(A+=(P+=65535&T)>>>16)>>>16)|(x+=E>>>16)<<16,D=h,j=c,z=u,U=l,B=d,F=p,q=f,Y=g=65535&P|A<<16,K=b,$=v,J=y,H=m,S%16==15)for(k=0;k<16;k++)C=O[k],P=65535&(T=L[k]),A=T>>>16,E=65535&C,x=C>>>16,C=O[(k+9)%16],P+=65535&(T=L[(k+9)%16]),A+=T>>>16,E+=65535&C,x+=C>>>16,w=O[(k+1)%16],P+=65535&(T=((_=L[(k+1)%16])>>>1|w<<31)^(_>>>8|w<<24)^(_>>>7|w<<25)),A+=T>>>16,E+=65535&(C=(w>>>1|_<<31)^(w>>>8|_<<24)^w>>>7),x+=C>>>16,w=O[(k+14)%16],A+=(T=((_=L[(k+14)%16])>>>19|w<<13)^(w>>>29|_<<3)^(_>>>6|w<<26))>>>16,E+=65535&(C=(w>>>19|_<<13)^(_>>>29|w<<3)^w>>>6),x+=C>>>16,x+=(E+=(A+=(P+=65535&T)>>>16)>>>16)>>>16,O[k]=65535&E|x<<16,L[k]=65535&P|A<<16;P=65535&(T=H),A=T>>>16,E=65535&(C=U),x=C>>>16,C=t[0],A+=(T=e[0])>>>16,E+=65535&C,x+=C>>>16,x+=(E+=(A+=(P+=65535&T)>>>16)>>>16)>>>16,t[0]=U=65535&E|x<<16,e[0]=H=65535&P|A<<16,P=65535&(T=B),A=T>>>16,E=65535&(C=R),x=C>>>16,C=t[1],A+=(T=e[1])>>>16,E+=65535&C,x+=C>>>16,x+=(E+=(A+=(P+=65535&T)>>>16)>>>16)>>>16,t[1]=R=65535&E|x<<16,e[1]=B=65535&P|A<<16,P=65535&(T=F),A=T>>>16,E=65535&(C=M),x=C>>>16,C=t[2],A+=(T=e[2])>>>16,E+=65535&C,x+=C>>>16,x+=(E+=(A+=(P+=65535&T)>>>16)>>>16)>>>16,t[2]=M=65535&E|x<<16,e[2]=F=65535&P|A<<16,P=65535&(T=q),A=T>>>16,E=65535&(C=I),x=C>>>16,C=t[3],A+=(T=e[3])>>>16,E+=65535&C,x+=C>>>16,x+=(E+=(A+=(P+=65535&T)>>>16)>>>16)>>>16,t[3]=I=65535&E|x<<16,e[3]=q=65535&P|A<<16,P=65535&(T=Y),A=T>>>16,E=65535&(C=N),x=C>>>16,C=t[4],A+=(T=e[4])>>>16,E+=65535&C,x+=C>>>16,x+=(E+=(A+=(P+=65535&T)>>>16)>>>16)>>>16,t[4]=N=65535&E|x<<16,e[4]=Y=65535&P|A<<16,P=65535&(T=K),A=T>>>16,E=65535&(C=D),x=C>>>16,C=t[5],A+=(T=e[5])>>>16,E+=65535&C,x+=C>>>16,x+=(E+=(A+=(P+=65535&T)>>>16)>>>16)>>>16,t[5]=D=65535&E|x<<16,e[5]=K=65535&P|A<<16,P=65535&(T=$),A=T>>>16,E=65535&(C=j),x=C>>>16,C=t[6],A+=(T=e[6])>>>16,E+=65535&C,x+=C>>>16,x+=(E+=(A+=(P+=65535&T)>>>16)>>>16)>>>16,t[6]=j=65535&E|x<<16,e[6]=$=65535&P|A<<16,P=65535&(T=J),A=T>>>16,E=65535&(C=z),x=C>>>16,C=t[7],A+=(T=e[7])>>>16,E+=65535&C,x+=C>>>16,x+=(E+=(A+=(P+=65535&T)>>>16)>>>16)>>>16,t[7]=z=65535&E|x<<16,e[7]=J=65535&P|A<<16,W+=128,r-=128}return r}function V(t,e,n){var r,i=new Int32Array(8),s=new Int32Array(8),o=new Uint8Array(256),a=n;for(i[0]=1779033703,i[1]=3144134277,i[2]=1013904242,i[3]=2773480762,i[4]=1359893119,i[5]=2600822924,i[6]=528734635,i[7]=1541459225,s[0]=4089235720,s[1]=2227873595,s[2]=4271175723,s[3]=1595750129,s[4]=2917565137,s[5]=725511199,s[6]=4215389547,s[7]=327033209,G(i,s,e,n),n%=128,r=0;r=0;--i)Q(t,e,r=n[i/8|0]>>(7&i)&1),Z(e,t),Z(t,t),Q(t,e,r)}function nt(t,n){var r=[e(),e(),e(),e()];O(r[0],l),O(r[1],d),O(r[2],a),z(r[3],l,d),et(t,r,n)}function rt(t,n,i){var s,o=new Uint8Array(64),a=[e(),e(),e(),e()];for(i||r(n,32),V(o,n,32),o[0]&=248,o[31]&=127,o[31]|=64,nt(a,o),tt(t,a),s=0;s<32;s++)n[s+32]=t[s];return 0}var it=new Float64Array([237,211,245,92,26,99,18,88,214,156,247,162,222,249,222,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16]);function st(t,e){var n,r,i,s;for(r=63;r>=32;--r){for(n=0,i=r-32,s=r-12;i>4)*it[i],n=e[i]>>8,e[i]&=255;for(i=0;i<32;i++)e[i]-=n*it[i];for(r=0;r<32;r++)e[r+1]+=e[r]>>8,t[r]=255&e[r]}function ot(t){var e,n=new Float64Array(64);for(e=0;e<64;e++)n[e]=t[e];for(e=0;e<64;e++)t[e]=0;st(t,n)}function at(t,n,r,i){var s,o,a=new Uint8Array(64),h=new Uint8Array(64),c=new Uint8Array(64),u=new Float64Array(64),l=[e(),e(),e(),e()];V(a,i,32),a[0]&=248,a[31]&=127,a[31]|=64;var d=r+64;for(s=0;s>7&&j(t[0],o,t[0]),z(t[3],t[0],t[1]),0)}(d,i))return-1;for(s=0;s=0},t.sign.keyPair=function(){var t=new Uint8Array(32),e=new Uint8Array(64);return rt(t,e),{publicKey:t,secretKey:e}},t.sign.keyPair.fromSecretKey=function(t){if(ut(t),64!==t.length)throw new Error("bad secret key size");for(var e=new Uint8Array(32),n=0;n>>6)+r(128|63&e):r(224|e>>>12&15)+r(128|e>>>6&63)+r(128|63&e)},c=function(t){return t.replace(/[^\x00-\x7F]/g,h)},u=function(t){var e=[0,2,1][t.length%3],n=t.charCodeAt(0)<<16|(t.length>1?t.charCodeAt(1):0)<<8|(t.length>2?t.charCodeAt(2):0);return[i.charAt(n>>>18),i.charAt(n>>>12&63),e>=2?"=":i.charAt(n>>>6&63),e>=1?"=":i.charAt(63&n)].join("")},l=self.btoa||function(t){return t.replace(/[\s\S]{1,3}/g,u)};var d=class{constructor(t,e,n,r){this.clear=e,this.timer=t(()=>{this.timer&&(this.timer=r(this.timer))},n)}isRunning(){return null!==this.timer}ensureAborted(){this.timer&&(this.clear(this.timer),this.timer=null)}};function p(t){self.clearTimeout(t)}function f(t){self.clearInterval(t)}class g extends d{constructor(t,e){super(setTimeout,p,t,(function(t){return e(),null}))}}class b extends d{constructor(t,e){super(setInterval,f,t,(function(t){return e(),t}))}}var v={now:()=>Date.now?Date.now():(new Date).valueOf(),defer:t=>new g(0,t),method(t,...e){var n=Array.prototype.slice.call(arguments,1);return function(e){return e[t].apply(e,n.concat(arguments))}}};function y(t,...e){for(var n=0;ne!==t),this):(this.global_callbacks=[],this)}unbind_all(){return this.unbind(),this.unbind_global(),this}emit(t,e,n){for(var r=0;r0)for(r=0;r{self.console&&self.console.log&&self.console.log(t)}}debug(...t){this.log(this.globalLog,t)}warn(...t){this.log(this.globalLogWarn,t)}error(...t){this.log(this.globalLogError,t)}globalLogWarn(t){self.console&&self.console.warn?self.console.warn(t):this.globalLog(t)}globalLogError(t){self.console&&self.console.error?self.console.error(t):this.globalLogWarn(t)}log(t,...e){var n=m.apply(this,arguments);if(Oe.log)Oe.log(n);else if(Oe.logToConsole){t.bind(this)(n)}}};class H extends j{constructor(t,e,n,r,i){super(),this.initialize=ae.transportConnectionInitializer,this.hooks=t,this.name=e,this.priority=n,this.key=r,this.options=i,this.state="new",this.timeline=i.timeline,this.activityTimeout=i.activityTimeout,this.id=this.timeline.generateUniqueID()}handlesActivityChecks(){return Boolean(this.hooks.handlesActivityChecks)}supportsPing(){return Boolean(this.hooks.supportsPing)}connect(){if(this.socket||"initialized"!==this.state)return!1;var t=this.hooks.urls.getInitial(this.key,this.options);try{this.socket=this.hooks.getSocket(t,this.options)}catch(t){return v.defer(()=>{this.onError(t),this.changeState("closed")}),!1}return this.bindListeners(),z.debug("Connecting",{transport:this.name,url:t}),this.changeState("connecting"),!0}close(){return!!this.socket&&(this.socket.close(),!0)}send(t){return"open"===this.state&&(v.defer(()=>{this.socket&&this.socket.send(t)}),!0)}ping(){"open"===this.state&&this.supportsPing()&&this.socket.ping()}onOpen(){this.hooks.beforeOpen&&this.hooks.beforeOpen(this.socket,this.hooks.urls.getPath(this.key,this.options)),this.changeState("open"),this.socket.onopen=void 0}onError(t){this.emit("error",{type:"WebSocketError",error:t}),this.timeline.error(this.buildTimelineMessage({error:t.toString()}))}onClose(t){t?this.changeState("closed",{code:t.code,reason:t.reason,wasClean:t.wasClean}):this.changeState("closed"),this.unbindListeners(),this.socket=void 0}onMessage(t){this.emit("message",t)}onActivity(){this.emit("activity")}bindListeners(){this.socket.onopen=()=>{this.onOpen()},this.socket.onerror=t=>{this.onError(t)},this.socket.onclose=t=>{this.onClose(t)},this.socket.onmessage=t=>{this.onMessage(t)},this.supportsPing()&&(this.socket.onactivity=()=>{this.onActivity()})}unbindListeners(){this.socket&&(this.socket.onopen=void 0,this.socket.onerror=void 0,this.socket.onclose=void 0,this.socket.onmessage=void 0,this.supportsPing()&&(this.socket.onactivity=void 0))}changeState(t,e){this.state=t,this.timeline.info(this.buildTimelineMessage({state:t,params:e})),this.emit(t,e)}buildTimelineMessage(t){return y({cid:this.id},t)}}class B{constructor(t){this.hooks=t}isSupported(t){return this.hooks.isSupported(t)}createConnection(t,e,n,r){return new H(this.hooks,t,e,n,r)}}var F=new B({urls:M,handlesActivityChecks:!1,supportsPing:!1,isInitialized:function(){return Boolean(ae.getWebSocketAPI())},isSupported:function(){return Boolean(ae.getWebSocketAPI())},getSocket:function(t){return ae.createWebSocket(t)}}),q={urls:I,handlesActivityChecks:!1,supportsPing:!0,isInitialized:function(){return!0}},Y=y({getSocket:function(t){return ae.HTTPFactory.createStreamingSocket(t)}},q),K=y({getSocket:function(t){return ae.HTTPFactory.createPollingSocket(t)}},q),$={isSupported:function(){return ae.isXHRSupported()}},J={ws:F,xhr_streaming:new B(y({},Y,$)),xhr_polling:new B(y({},K,$))};class W{constructor(t,e,n){this.manager=t,this.transport=e,this.minPingDelay=n.minPingDelay,this.maxPingDelay=n.maxPingDelay,this.pingDelay=void 0}createConnection(t,e,n,r){r=y({},r,{activityTimeout:this.pingDelay});var i=this.transport.createConnection(t,e,n,r),s=null,o=function(){i.unbind("open",o),i.bind("closed",a),s=v.now()},a=t=>{if(i.unbind("closed",a),1002===t.code||1003===t.code)this.manager.reportDeath();else if(!t.wasClean&&s){var e=v.now()-s;e<2*this.maxPingDelay&&(this.manager.reportDeath(),this.pingDelay=Math.max(e/2,this.minPingDelay))}};return i.bind("open",o),i}isSupported(t){return this.manager.isAlive()&&this.transport.isSupported(t)}}const X={decodeMessage:function(t){try{var e=JSON.parse(t.data),n=e.data;if("string"==typeof n)try{n=JSON.parse(e.data)}catch(t){}var r={event:e.event,channel:e.channel,data:n};return e.user_id&&(r.user_id=e.user_id),r}catch(e){throw{type:"MessageParseError",error:e,data:t.data}}},encodeMessage:function(t){return JSON.stringify(t)},processHandshake:function(t){var e=X.decodeMessage(t);if("pusher:connection_established"===e.event){if(!e.data.activity_timeout)throw"No activity timeout specified in handshake";return{action:"connected",id:e.data.socket_id,activityTimeout:1e3*e.data.activity_timeout}}if("pusher:error"===e.event)return{action:this.getCloseAction(e.data),error:this.getCloseError(e.data)};throw"Invalid handshake"},getCloseAction:function(t){return t.code<4e3?t.code>=1002&&t.code<=1004?"backoff":null:4e3===t.code?"tls_only":t.code<4100?"refused":t.code<4200?"backoff":t.code<4300?"retry":"refused"},getCloseError:function(t){return 1e3!==t.code&&1001!==t.code?{type:"PusherError",data:{code:t.code,message:t.reason||t.message}}:null}};var G=X;class V extends j{constructor(t,e){super(),this.id=t,this.transport=e,this.activityTimeout=e.activityTimeout,this.bindListeners()}handlesActivityChecks(){return this.transport.handlesActivityChecks()}send(t){return this.transport.send(t)}send_event(t,e,n){var r={event:t,data:e};return n&&(r.channel=n),z.debug("Event sent",r),this.send(G.encodeMessage(r))}ping(){this.transport.supportsPing()?this.transport.ping():this.send_event("pusher:ping",{})}close(){this.transport.close()}bindListeners(){var t={message:t=>{var e;try{e=G.decodeMessage(t)}catch(e){this.emit("error",{type:"MessageParseError",error:e,data:t.data})}if(void 0!==e){switch(z.debug("Event recd",e),e.event){case"pusher:error":this.emit("error",{type:"PusherError",data:e.data});break;case"pusher:ping":this.emit("ping");break;case"pusher:pong":this.emit("pong")}this.emit("message",e)}},activity:()=>{this.emit("activity")},error:t=>{this.emit("error",t)},closed:t=>{e(),t&&t.code&&this.handleCloseEvent(t),this.transport=null,this.emit("closed")}},e=()=>{_(t,(t,e)=>{this.transport.unbind(e,t)})};_(t,(t,e)=>{this.transport.bind(e,t)})}handleCloseEvent(t){var e=G.getCloseAction(t),n=G.getCloseError(t);n&&this.emit("error",n),e&&this.emit(e,{action:e,error:n})}}class Z{constructor(t,e){this.transport=t,this.callback=e,this.bindListeners()}close(){this.unbindListeners(),this.transport.close()}bindListeners(){this.onMessage=t=>{var e;this.unbindListeners();try{e=G.processHandshake(t)}catch(t){return this.finish("error",{error:t}),void this.transport.close()}"connected"===e.action?this.finish("connected",{connection:new V(e.id,this.transport),activityTimeout:e.activityTimeout}):(this.finish(e.action,{error:e.error}),this.transport.close())},this.onClosed=t=>{this.unbindListeners();var e=G.getCloseAction(t)||"backoff",n=G.getCloseError(t);this.finish(e,{error:n})},this.transport.bind("message",this.onMessage),this.transport.bind("closed",this.onClosed)}unbindListeners(){this.transport.unbind("message",this.onMessage),this.transport.unbind("closed",this.onClosed)}finish(t,e){this.callback(y({transport:this.transport,action:t},e))}}class Q{constructor(t,e){this.timeline=t,this.options=e||{}}send(t,e){this.timeline.isEmpty()||this.timeline.send(ae.TimelineTransport.getAgent(this,t),e)}}class tt extends Error{constructor(t){super(t),Object.setPrototypeOf(this,new.target.prototype)}}class et extends Error{constructor(t){super(t),Object.setPrototypeOf(this,new.target.prototype)}}Error;class nt extends Error{constructor(t){super(t),Object.setPrototypeOf(this,new.target.prototype)}}class rt extends Error{constructor(t){super(t),Object.setPrototypeOf(this,new.target.prototype)}}class it extends Error{constructor(t){super(t),Object.setPrototypeOf(this,new.target.prototype)}}class st extends Error{constructor(t){super(t),Object.setPrototypeOf(this,new.target.prototype)}}class ot extends Error{constructor(t){super(t),Object.setPrototypeOf(this,new.target.prototype)}}class at extends Error{constructor(t,e){super(e),this.status=t,Object.setPrototypeOf(this,new.target.prototype)}}const ht={baseUrl:"https://pusher.com",urls:{authenticationEndpoint:{path:"/docs/channels/server_api/authenticating_users"},authorizationEndpoint:{path:"/docs/channels/server_api/authorizing-users/"},javascriptQuickStart:{path:"/docs/javascript_quick_start"},triggeringClientEvents:{path:"/docs/client_api_guide/client_events#trigger-events"},encryptedChannelSupport:{fullUrl:"https://github.com/pusher/pusher-js/tree/cc491015371a4bde5743d1c87a0fbac0feb53195#encrypted-channel-support"}}};var ct=function(t){const e=ht.urls[t];if(!e)return"";let n;return e.fullUrl?n=e.fullUrl:e.path&&(n=ht.baseUrl+e.path),n?"See: "+n:""};class ut extends j{constructor(t,e){super((function(e,n){z.debug("No callbacks on "+t+" for "+e)})),this.name=t,this.pusher=e,this.subscribed=!1,this.subscriptionPending=!1,this.subscriptionCancelled=!1}authorize(t,e){return e(null,{auth:""})}trigger(t,e){if(0!==t.indexOf("client-"))throw new tt("Event '"+t+"' does not start with 'client-'");if(!this.subscribed){var n=ct("triggeringClientEvents");z.warn("Client event triggered before channel 'subscription_succeeded' event . "+n)}return this.pusher.send_event(t,e,this.name)}disconnect(){this.subscribed=!1,this.subscriptionPending=!1}handleEvent(t){var e=t.event,n=t.data;if("pusher_internal:subscription_succeeded"===e)this.handleSubscriptionSucceededEvent(t);else if("pusher_internal:subscription_count"===e)this.handleSubscriptionCountEvent(t);else if(0!==e.indexOf("pusher_internal:")){this.emit(e,n,{})}}handleSubscriptionSucceededEvent(t){this.subscriptionPending=!1,this.subscribed=!0,this.subscriptionCancelled?this.pusher.unsubscribe(this.name):this.emit("pusher:subscription_succeeded",t.data)}handleSubscriptionCountEvent(t){t.data.subscription_count&&(this.subscriptionCount=t.data.subscription_count),this.emit("pusher:subscription_count",t.data)}subscribe(){this.subscribed||(this.subscriptionPending=!0,this.subscriptionCancelled=!1,this.authorize(this.pusher.connection.socket_id,(t,e)=>{t?(this.subscriptionPending=!1,z.error(t.toString()),this.emit("pusher:subscription_error",Object.assign({},{type:"AuthError",error:t.message},t instanceof at?{status:t.status}:{}))):this.pusher.send_event("pusher:subscribe",{auth:e.auth,channel_data:e.channel_data,channel:this.name})}))}unsubscribe(){this.subscribed=!1,this.pusher.send_event("pusher:unsubscribe",{channel:this.name})}cancelSubscription(){this.subscriptionCancelled=!0}reinstateSubscription(){this.subscriptionCancelled=!1}}class lt extends ut{authorize(t,e){return this.pusher.config.channelAuthorizer({channelName:this.name,socketId:t},e)}}class dt{constructor(){this.reset()}get(t){return Object.prototype.hasOwnProperty.call(this.members,t)?{id:t,info:this.members[t]}:null}each(t){_(this.members,(e,n)=>{t(this.get(n))})}setMyID(t){this.myID=t}onSubscription(t){this.members=t.presence.hash,this.count=t.presence.count,this.me=this.get(this.myID)}addMember(t){return null===this.get(t.user_id)&&this.count++,this.members[t.user_id]=t.user_info,this.get(t.user_id)}removeMember(t){var e=this.get(t.user_id);return e&&(delete this.members[t.user_id],this.count--),e}reset(){this.members={},this.count=0,this.myID=null,this.me=null}}var pt=function(t,e,n,r){return new(n||(n=Promise))((function(i,s){function o(t){try{h(r.next(t))}catch(t){s(t)}}function a(t){try{h(r.throw(t))}catch(t){s(t)}}function h(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(o,a)}h((r=r.apply(t,e||[])).next())}))};class ft extends lt{constructor(t,e){super(t,e),this.members=new dt}authorize(t,e){super.authorize(t,(t,n)=>pt(this,void 0,void 0,(function*(){if(!t)if(null!=(n=n).channel_data){var r=JSON.parse(n.channel_data);this.members.setMyID(r.user_id)}else{if(yield this.pusher.user.signinDonePromise,null==this.pusher.user.user_data){let t=ct("authorizationEndpoint");return z.error(`Invalid auth response for channel '${this.name}', expected 'channel_data' field. ${t}, or the user should be signed in.`),void e("Invalid auth response")}this.members.setMyID(this.pusher.user.user_data.id)}e(t,n)})))}handleEvent(t){var e=t.event;if(0===e.indexOf("pusher_internal:"))this.handleInternalEvent(t);else{var n=t.data,r={};t.user_id&&(r.user_id=t.user_id),this.emit(e,n,r)}}handleInternalEvent(t){var e=t.event,n=t.data;switch(e){case"pusher_internal:subscription_succeeded":this.handleSubscriptionSucceededEvent(t);break;case"pusher_internal:subscription_count":this.handleSubscriptionCountEvent(t);break;case"pusher_internal:member_added":var r=this.members.addMember(n);this.emit("pusher:member_added",r);break;case"pusher_internal:member_removed":var i=this.members.removeMember(n);i&&this.emit("pusher:member_removed",i)}}handleSubscriptionSucceededEvent(t){this.subscriptionPending=!1,this.subscribed=!0,this.subscriptionCancelled?this.pusher.unsubscribe(this.name):(this.members.onSubscription(t.data),this.emit("pusher:subscription_succeeded",this.members))}disconnect(){this.members.reset(),super.disconnect()}}var gt=n(1),bt=n(0);class vt extends lt{constructor(t,e,n){super(t,e),this.key=null,this.nacl=n}authorize(t,e){super.authorize(t,(t,n)=>{if(t)return void e(t,n);let r=n.shared_secret;r?(this.key=Object(bt.decode)(r),delete n.shared_secret,e(null,n)):e(new Error("No shared_secret key in auth payload for encrypted channel: "+this.name),null)})}trigger(t,e){throw new it("Client events are not currently supported for encrypted channels")}handleEvent(t){var e=t.event,n=t.data;0!==e.indexOf("pusher_internal:")&&0!==e.indexOf("pusher:")?this.handleEncryptedEvent(e,n):super.handleEvent(t)}handleEncryptedEvent(t,e){if(!this.key)return void z.debug("Received encrypted event before key has been retrieved from the authEndpoint");if(!e.ciphertext||!e.nonce)return void z.error("Unexpected format for encrypted event, expected object with `ciphertext` and `nonce` fields, got: "+e);let n=Object(bt.decode)(e.ciphertext);if(n.length{e?z.error(`Failed to make a request to the authEndpoint: ${s}. Unable to fetch new key, so dropping encrypted event`):(i=this.nacl.secretbox.open(n,r,this.key),null!==i?this.emit(t,this.getDataToEmit(i)):z.error("Failed to decrypt event with new key. Dropping encrypted event"))});this.emit(t,this.getDataToEmit(i))}getDataToEmit(t){let e=Object(gt.decode)(t);try{return JSON.parse(e)}catch(t){return e}}}class yt extends j{constructor(t,e){super(),this.state="initialized",this.connection=null,this.key=t,this.options=e,this.timeline=this.options.timeline,this.usingTLS=this.options.useTLS,this.errorCallbacks=this.buildErrorCallbacks(),this.connectionCallbacks=this.buildConnectionCallbacks(this.errorCallbacks),this.handshakeCallbacks=this.buildHandshakeCallbacks(this.errorCallbacks);var n=ae.getNetwork();n.bind("online",()=>{this.timeline.info({netinfo:"online"}),"connecting"!==this.state&&"unavailable"!==this.state||this.retryIn(0)}),n.bind("offline",()=>{this.timeline.info({netinfo:"offline"}),this.connection&&this.sendActivityCheck()}),this.updateStrategy()}switchCluster(t){this.key=t,this.updateStrategy(),this.retryIn(0)}connect(){this.connection||this.runner||(this.strategy.isSupported()?(this.updateState("connecting"),this.startConnecting(),this.setUnavailableTimer()):this.updateState("failed"))}send(t){return!!this.connection&&this.connection.send(t)}send_event(t,e,n){return!!this.connection&&this.connection.send_event(t,e,n)}disconnect(){this.disconnectInternally(),this.updateState("disconnected")}isUsingTLS(){return this.usingTLS}startConnecting(){var t=(e,n)=>{e?this.runner=this.strategy.connect(0,t):"error"===n.action?(this.emit("error",{type:"HandshakeError",error:n.error}),this.timeline.error({handshakeError:n.error})):(this.abortConnecting(),this.handshakeCallbacks[n.action](n))};this.runner=this.strategy.connect(0,t)}abortConnecting(){this.runner&&(this.runner.abort(),this.runner=null)}disconnectInternally(){(this.abortConnecting(),this.clearRetryTimer(),this.clearUnavailableTimer(),this.connection)&&this.abandonConnection().close()}updateStrategy(){this.strategy=this.options.getStrategy({key:this.key,timeline:this.timeline,useTLS:this.usingTLS})}retryIn(t){this.timeline.info({action:"retry",delay:t}),t>0&&this.emit("connecting_in",Math.round(t/1e3)),this.retryTimer=new g(t||0,()=>{this.disconnectInternally(),this.connect()})}clearRetryTimer(){this.retryTimer&&(this.retryTimer.ensureAborted(),this.retryTimer=null)}setUnavailableTimer(){this.unavailableTimer=new g(this.options.unavailableTimeout,()=>{this.updateState("unavailable")})}clearUnavailableTimer(){this.unavailableTimer&&this.unavailableTimer.ensureAborted()}sendActivityCheck(){this.stopActivityCheck(),this.connection.ping(),this.activityTimer=new g(this.options.pongTimeout,()=>{this.timeline.error({pong_timed_out:this.options.pongTimeout}),this.retryIn(0)})}resetActivityCheck(){this.stopActivityCheck(),this.connection&&!this.connection.handlesActivityChecks()&&(this.activityTimer=new g(this.activityTimeout,()=>{this.sendActivityCheck()}))}stopActivityCheck(){this.activityTimer&&this.activityTimer.ensureAborted()}buildConnectionCallbacks(t){return y({},t,{message:t=>{this.resetActivityCheck(),this.emit("message",t)},ping:()=>{this.send_event("pusher:pong",{})},activity:()=>{this.resetActivityCheck()},error:t=>{this.emit("error",t)},closed:()=>{this.abandonConnection(),this.shouldRetry()&&this.retryIn(1e3)}})}buildHandshakeCallbacks(t){return y({},t,{connected:t=>{this.activityTimeout=Math.min(this.options.activityTimeout,t.activityTimeout,t.connection.activityTimeout||1/0),this.clearUnavailableTimer(),this.setConnection(t.connection),this.socket_id=this.connection.id,this.updateState("connected",{socket_id:this.socket_id})}})}buildErrorCallbacks(){let t=t=>e=>{e.error&&this.emit("error",{type:"WebSocketError",error:e.error}),t(e)};return{tls_only:t(()=>{this.usingTLS=!0,this.updateStrategy(),this.retryIn(0)}),refused:t(()=>{this.disconnect()}),backoff:t(()=>{this.retryIn(1e3)}),retry:t(()=>{this.retryIn(0)})}}setConnection(t){for(var e in this.connection=t,this.connectionCallbacks)this.connection.bind(e,this.connectionCallbacks[e]);this.resetActivityCheck()}abandonConnection(){if(this.connection){for(var t in this.stopActivityCheck(),this.connectionCallbacks)this.connection.unbind(t,this.connectionCallbacks[t]);var e=this.connection;return this.connection=null,e}}updateState(t,e){var n=this.state;if(this.state=t,n!==t){var r=t;"connected"===r&&(r+=" with new socket ID "+e.socket_id),z.debug("State changed",n+" -> "+r),this.timeline.info({state:t,params:e}),this.emit("state_change",{previous:n,current:t}),this.emit(t,e)}}shouldRetry(){return"connecting"===this.state||"connected"===this.state}}class mt{constructor(){this.channels={}}add(t,e){return this.channels[t]||(this.channels[t]=function(t,e){if(0===t.indexOf("private-encrypted-")){if(e.config.nacl)return wt.createEncryptedChannel(t,e,e.config.nacl);let n="Tried to subscribe to a private-encrypted- channel but no nacl implementation available",r=ct("encryptedChannelSupport");throw new it(`${n}. ${r}`)}if(0===t.indexOf("private-"))return wt.createPrivateChannel(t,e);if(0===t.indexOf("presence-"))return wt.createPresenceChannel(t,e);if(0===t.indexOf("#"))throw new et('Cannot create a channel with name "'+t+'".');return wt.createChannel(t,e)}(t,e)),this.channels[t]}all(){return function(t){var e=[];return _(t,(function(t){e.push(t)})),e}(this.channels)}find(t){return this.channels[t]}remove(t){var e=this.channels[t];return delete this.channels[t],e}disconnect(){_(this.channels,(function(t){t.disconnect()}))}}var wt={createChannels:()=>new mt,createConnectionManager:(t,e)=>new yt(t,e),createChannel:(t,e)=>new ut(t,e),createPrivateChannel:(t,e)=>new lt(t,e),createPresenceChannel:(t,e)=>new ft(t,e),createEncryptedChannel:(t,e,n)=>new vt(t,e,n),createTimelineSender:(t,e)=>new Q(t,e),createHandshake:(t,e)=>new Z(t,e),createAssistantToTheTransportManager:(t,e,n)=>new W(t,e,n)};class _t{constructor(t){this.options=t||{},this.livesLeft=this.options.lives||1/0}getAssistant(t){return wt.createAssistantToTheTransportManager(this,t,{minPingDelay:this.options.minPingDelay,maxPingDelay:this.options.maxPingDelay})}isAlive(){return this.livesLeft>0}reportDeath(){this.livesLeft-=1}}class St{constructor(t,e){this.strategies=t,this.loop=Boolean(e.loop),this.failFast=Boolean(e.failFast),this.timeout=e.timeout,this.timeoutLimit=e.timeoutLimit}isSupported(){return A(this.strategies,v.method("isSupported"))}connect(t,e){var n=this.strategies,r=0,i=this.timeout,s=null,o=(a,h)=>{h?e(null,h):(r+=1,this.loop&&(r%=n.length),r0&&(i=new g(n.timeout,(function(){s.abort(),r(!0)}))),s=t.connect(e,(function(t,e){t&&i&&i.isRunning()&&!n.failFast||(i&&i.ensureAborted(),r(t,e))})),{abort:function(){i&&i.ensureAborted(),s.abort()},forceMinPriority:function(t){s.forceMinPriority(t)}}}}class kt{constructor(t){this.strategies=t}isSupported(){return A(this.strategies,v.method("isSupported"))}connect(t,e){return function(t,e,n){var r=C(t,(function(t,r,i,s){return t.connect(e,n(r,s))}));return{abort:function(){k(r,Ct)},forceMinPriority:function(t){k(r,(function(e){e.forceMinPriority(t)}))}}}(this.strategies,t,(function(t,n){return function(r,i){n[t].error=r,r?function(t){return function(t,e){for(var n=0;n=v.now()){var o=this.transports[r.transport];o&&(["ws","wss"].includes(r.transport)||i>3?(this.timeline.info({cached:!0,transport:r.transport,latency:r.latency}),s.push(new St([o],{timeout:2*r.latency+1e3,failFast:!0}))):i++)}var a=v.now(),h=s.pop().connect(t,(function r(o,c){o?(At(n),s.length>0?(a=v.now(),h=s.pop().connect(t,r)):e(o)):(!function(t,e,n,r){var i=ae.getLocalStorage();if(i)try{i[Pt(t)]=O({timestamp:v.now(),transport:e,latency:n,cacheSkipCount:r})}catch(t){}}(n,c.transport.name,v.now()-a,i),e(null,c))}));return{abort:function(){h.abort()},forceMinPriority:function(e){t=e,h&&h.forceMinPriority(e)}}}}function Pt(t){return"pusherTransport"+(t?"TLS":"NonTLS")}function At(t){var e=ae.getLocalStorage();if(e)try{delete e[Pt(t)]}catch(t){}}class Et{constructor(t,{delay:e}){this.strategy=t,this.options={delay:e}}isSupported(){return this.strategy.isSupported()}connect(t,e){var n,r=this.strategy,i=new g(this.options.delay,(function(){n=r.connect(t,e)}));return{abort:function(){i.ensureAborted(),n&&n.abort()},forceMinPriority:function(e){t=e,n&&n.forceMinPriority(e)}}}}class xt{constructor(t,e,n){this.test=t,this.trueBranch=e,this.falseBranch=n}isSupported(){return(this.test()?this.trueBranch:this.falseBranch).isSupported()}connect(t,e){return(this.test()?this.trueBranch:this.falseBranch).connect(t,e)}}class Ot{constructor(t){this.strategy=t}isSupported(){return this.strategy.isSupported()}connect(t,e){var n=this.strategy.connect(t,(function(t,r){r&&n.abort(),e(t,r)}));return n}}function Lt(t){return function(){return t.isSupported()}}var Ut=function(t,e,n){var r={};function i(e,i,s,o,a){var h=n(t,e,i,s,o,a);return r[e]=h,h}var s,o=Object.assign({},e,{hostNonTLS:t.wsHost+":"+t.wsPort,hostTLS:t.wsHost+":"+t.wssPort,httpPath:t.wsPath}),a=y({},o,{useTLS:!0}),h=Object.assign({},e,{hostNonTLS:t.httpHost+":"+t.httpPort,hostTLS:t.httpHost+":"+t.httpsPort,httpPath:t.httpPath}),c={loop:!0,timeout:15e3,timeoutLimit:6e4},u=new _t({minPingDelay:1e4,maxPingDelay:t.activityTimeout}),l=new _t({lives:2,minPingDelay:1e4,maxPingDelay:t.activityTimeout}),d=i("ws","ws",3,o,u),p=i("wss","ws",3,a,u),f=i("xhr_streaming","xhr_streaming",1,h,l),g=i("xhr_polling","xhr_polling",1,h),b=new St([d],c),v=new St([p],c),m=new St([f],c),w=new St([g],c),_=new St([new xt(Lt(m),new kt([m,new Et(w,{delay:4e3})]),w)],c);return s=e.useTLS?new kt([b,new Et(_,{delay:2e3})]):new kt([b,new Et(v,{delay:2e3}),new Et(_,{delay:5e3})]),new Tt(new Ot(new xt(Lt(d),s,_)),r,{ttl:18e5,timeline:e.timeline,useTLS:e.useTLS})};class Rt extends j{constructor(t,e,n){super(),this.hooks=t,this.method=e,this.url=n}start(t){this.position=0,this.xhr=this.hooks.getRequest(this),this.unloader=()=>{this.close()},ae.addUnloadListener(this.unloader),this.xhr.open(this.method,this.url,!0),this.xhr.setRequestHeader&&this.xhr.setRequestHeader("Content-Type","application/json"),this.xhr.send(t)}close(){this.unloader&&(ae.removeUnloadListener(this.unloader),this.unloader=null),this.xhr&&(this.hooks.abortRequest(this.xhr),this.xhr=null)}onChunk(t,e){for(;;){var n=this.advanceBuffer(e);if(!n)break;this.emit("chunk",{status:t,data:n})}this.isBufferTooLong(e)&&this.emit("buffer_too_long")}advanceBuffer(t){var e=t.slice(this.position),n=e.indexOf("\n");return-1!==n?(this.position+=n+1,e.slice(0,n)):null}isBufferTooLong(t){return this.position===t.length&&t.length>262144}}var Mt;!function(t){t[t.CONNECTING=0]="CONNECTING",t[t.OPEN=1]="OPEN",t[t.CLOSED=3]="CLOSED"}(Mt||(Mt={}));var It=Mt,Nt=1;function Dt(t){var e=-1===t.indexOf("?")?"?":"&";return t+e+"t="+ +new Date+"&n="+Nt++}function jt(t){return ae.randomInt(t)}var zt=class{constructor(t,e){this.hooks=t,this.session=jt(1e3)+"/"+function(t){for(var e=[],n=0;n{this.onChunk(t)}),this.stream.bind("finished",t=>{this.hooks.onFinished(this,t)}),this.stream.bind("buffer_too_long",()=>{this.reconnect()});try{this.stream.start()}catch(t){v.defer(()=>{this.onError(t),this.onClose(1006,"Could not start streaming",!1)})}}closeStream(){this.stream&&(this.stream.unbind_all(),this.stream.close(),this.stream=null)}},Ht={getReceiveURL:function(t,e){return t.base+"/"+e+"/xhr_streaming"+t.queryString},onHeartbeat:function(t){t.sendRaw("[]")},sendHeartbeat:function(t){t.sendRaw("[]")},onFinished:function(t,e){t.onClose(1006,"Connection interrupted ("+e+")",!1)}},Bt={getReceiveURL:function(t,e){return t.base+"/"+e+"/xhr"+t.queryString},onHeartbeat:function(){},sendHeartbeat:function(t){t.sendRaw("[]")},onFinished:function(t,e){200===e?t.reconnect():t.onClose(1006,"Connection interrupted ("+e+")",!1)}},Ft={getRequest:function(t){var e=new(ae.getXHRAPI());return e.onreadystatechange=e.onprogress=function(){switch(e.readyState){case 3:e.responseText&&e.responseText.length>0&&t.onChunk(e.status,e.responseText);break;case 4:e.responseText&&e.responseText.length>0&&t.onChunk(e.status,e.responseText),t.emit("finished",e.status),t.close()}},e},abortRequest:function(t){t.onreadystatechange=null,t.abort()}},qt={getDefaultStrategy:Ut,Transports:J,transportConnectionInitializer:function(){this.timeline.info(this.buildTimelineMessage({transport:this.name+(this.options.useTLS?"s":"")})),this.hooks.isInitialized()?this.changeState("initialized"):this.onClose()},HTTPFactory:{createStreamingSocket(t){return this.createSocket(Ht,t)},createPollingSocket(t){return this.createSocket(Bt,t)},createSocket:(t,e)=>new zt(t,e),createXHR(t,e){return this.createRequest(Ft,t,e)},createRequest:(t,e,n)=>new Rt(t,e,n)},setup(t){t.ready()},getLocalStorage(){},getClientFeatures:()=>S(P({ws:J.ws},(function(t){return t.isSupported({})}))),getProtocol:()=>"http:",isXHRSupported:()=>!0,createSocketRequest(t,e){if(this.isXHRSupported())return this.HTTPFactory.createXHR(t,e);throw"Cross-origin HTTP requests are not supported"},createXHR(){return new(this.getXHRAPI())},createWebSocket(t){return new(this.getWebSocketAPI())(t)},addUnloadListener(t){},removeUnloadListener(t){}};var Yt=new class extends j{isOnline(){return!0}},Kt=function(t,e,n,r,i){var s=new Headers;for(var o in s.set("Content-Type","application/x-www-form-urlencoded"),n.headers)s.set(o,n.headers[o]);if(null!=n.headersProvider){const t=n.headersProvider();for(var o in t)s.set(o,t[o])}var a=e,h=new Request(n.endpoint,{headers:s,body:a,credentials:"same-origin",method:"POST"});return fetch(h).then(t=>{let{status:e}=t;if(200===e)return t.text();throw new at(e,`Could not get ${r.toString()} info from your auth endpoint, status: ${e}`)}).then(t=>{let e;try{e=JSON.parse(t)}catch(e){throw new at(200,`JSON returned from ${r.toString()} endpoint was invalid, yet status code was 200. Data was: ${t}`)}i(null,e)}).catch(t=>{i(t,null)})},$t={name:"xhr",getAgent:function(t,e){return function(n,r){var i="http"+(e?"s":"")+"://"+(t.host||t.options.host)+t.options.path,s=x(n);fetch(i+="/2?"+s).then(t=>{if(200!==t.status)throw`received ${t.status} from stats.pusher.com`;return t.json()}).then(({host:e})=>{e&&(t.host=e)}).catch(t=>{z.debug("TimelineSender Error: ",t)})}}};const{getDefaultStrategy:Jt,Transports:Wt,setup:Xt,getProtocol:Gt,isXHRSupported:Vt,getLocalStorage:Zt,createXHR:Qt,createWebSocket:te,addUnloadListener:ee,removeUnloadListener:ne,transportConnectionInitializer:re,createSocketRequest:ie,HTTPFactory:se}=qt;var oe,ae={getDefaultStrategy:Jt,Transports:Wt,setup:Xt,getProtocol:Gt,isXHRSupported:Vt,getLocalStorage:Zt,createXHR:Qt,createWebSocket:te,addUnloadListener:ee,removeUnloadListener:ne,transportConnectionInitializer:re,createSocketRequest:ie,HTTPFactory:se,TimelineTransport:$t,getAuthorizers:()=>({ajax:Kt}),getWebSocketAPI:()=>WebSocket,getXHRAPI:()=>XMLHttpRequest,getNetwork:()=>Yt,randomInt:t=>Math.floor((globalThis.crypto||globalThis.msCrypto).getRandomValues(new Uint32Array(1))[0]/Math.pow(2,32)*t)};!function(t){t[t.ERROR=3]="ERROR",t[t.INFO=6]="INFO",t[t.DEBUG=7]="DEBUG"}(oe||(oe={}));var he=oe;class ce{constructor(t,e,n){this.key=t,this.session=e,this.events=[],this.options=n||{},this.sent=0,this.uniqueID=0}log(t,e){t<=this.options.level&&(this.events.push(y({},e,{timestamp:v.now()})),this.options.limit&&this.events.length>this.options.limit&&this.events.shift())}error(t){this.log(he.ERROR,t)}info(t){this.log(he.INFO,t)}debug(t){this.log(he.DEBUG,t)}isEmpty(){return 0===this.events.length}send(t,e){var n=y({session:this.session,bundle:this.sent+1,key:this.key,lib:"js",version:this.options.version,cluster:this.options.cluster,features:this.options.features,timeline:this.events},this.options.params);return this.events=[],t(n,(t,n)=>{t||this.sent++,e&&e(t,n)}),!0}generateUniqueID(){return this.uniqueID++,this.uniqueID}}class ue{constructor(t,e,n,r){this.name=t,this.priority=e,this.transport=n,this.options=r||{}}isSupported(){return this.transport.isSupported({useTLS:this.options.useTLS})}connect(t,e){if(!this.isSupported())return le(new ot,e);if(this.priority{n||(c(),i?i.close():r.close())},forceMinPriority:t=>{n||this.priority{if(void 0===ae.getAuthorizers()[t.transport])throw`'${t.transport}' is not a recognized auth transport`;return(e,n)=>{const r=((t,e)=>{var n="socket_id="+encodeURIComponent(t.socketId);for(var r in e.params)n+="&"+encodeURIComponent(r)+"="+encodeURIComponent(e.params[r]);if(null!=e.paramsProvider){let t=e.paramsProvider();for(var r in t)n+="&"+encodeURIComponent(r)+"="+encodeURIComponent(t[r])}return n})(e,t);ae.getAuthorizers()[t.transport](ae,r,t,pe.UserAuthentication,n)}};var ye=t=>{if(void 0===ae.getAuthorizers()[t.transport])throw`'${t.transport}' is not a recognized auth transport`;return(e,n)=>{const r=((t,e)=>{var n="socket_id="+encodeURIComponent(t.socketId);for(var r in n+="&channel_name="+encodeURIComponent(t.channelName),e.params)n+="&"+encodeURIComponent(r)+"="+encodeURIComponent(e.params[r]);if(null!=e.paramsProvider){let t=e.paramsProvider();for(var r in t)n+="&"+encodeURIComponent(r)+"="+encodeURIComponent(t[r])}return n})(e,t);ae.getAuthorizers()[t.transport](ae,r,t,pe.ChannelAuthorization,n)}};function me(t,e){let n={activityTimeout:t.activityTimeout||L.activityTimeout,cluster:t.cluster,httpPath:t.httpPath||L.httpPath,httpPort:t.httpPort||L.httpPort,httpsPort:t.httpsPort||L.httpsPort,pongTimeout:t.pongTimeout||L.pongTimeout,statsHost:t.statsHost||L.stats_host,unavailableTimeout:t.unavailableTimeout||L.unavailableTimeout,wsPath:t.wsPath||L.wsPath,wsPort:t.wsPort||L.wsPort,wssPort:t.wssPort||L.wssPort,enableStats:ke(t),httpHost:we(t),useTLS:Se(t),wsHost:_e(t),userAuthenticator:Ce(t),channelAuthorizer:Te(t,e)};return"disabledTransports"in t&&(n.disabledTransports=t.disabledTransports),"enabledTransports"in t&&(n.enabledTransports=t.enabledTransports),"ignoreNullOrigin"in t&&(n.ignoreNullOrigin=t.ignoreNullOrigin),"timelineParams"in t&&(n.timelineParams=t.timelineParams),"nacl"in t&&(n.nacl=t.nacl),n}function we(t){return t.httpHost?t.httpHost:t.cluster?`sockjs-${t.cluster}.pusher.com`:L.httpHost}function _e(t){return t.wsHost?t.wsHost:`ws-${t.cluster}.pusher.com`}function Se(t){return"https:"===ae.getProtocol()||!1!==t.forceTLS}function ke(t){return"enableStats"in t?t.enableStats:"disableStats"in t&&!t.disableStats}function Ce(t){const e=Object.assign(Object.assign({},L.userAuthentication),t.userAuthentication);return"customHandler"in e&&null!=e.customHandler?e.customHandler:ve(e)}function Te(t,e){const n=function(t,e){let n;return"channelAuthorization"in t?n=Object.assign(Object.assign({},L.channelAuthorization),t.channelAuthorization):(n={transport:t.authTransport||L.authTransport,endpoint:t.authEndpoint||L.authEndpoint},"auth"in t&&("params"in t.auth&&(n.params=t.auth.params),"headers"in t.auth&&(n.headers=t.auth.headers)),"authorizer"in t&&(n.customHandler=((t,e,n)=>{const r={authTransport:e.transport,authEndpoint:e.endpoint,auth:{params:e.params,headers:e.headers}};return(e,i)=>{const s=t.channel(e.channelName);n(s,r).authorize(e.socketId,i)}})(e,n,t.authorizer))),n}(t,e);return"customHandler"in n&&null!=n.customHandler?n.customHandler:ye(n)}class Pe extends j{constructor(t){super((function(t,e){z.debug("No callbacks on watchlist events for "+t)})),this.pusher=t,this.bindWatchlistInternalEvent()}handleEvent(t){t.data.events.forEach(t=>{this.emit(t.name,t)})}bindWatchlistInternalEvent(){this.pusher.connection.bind("message",t=>{"pusher_internal:watchlist_events"===t.event&&this.handleEvent(t)})}}var Ae=function(){let t,e;return{promise:new Promise((n,r)=>{t=n,e=r}),resolve:t,reject:e}};class Ee extends j{constructor(t){super((function(t,e){z.debug("No callbacks on user for "+t)})),this.signin_requested=!1,this.user_data=null,this.serverToUserChannel=null,this.signinDonePromise=null,this._signinDoneResolve=null,this._onAuthorize=(t,e)=>{if(t)return z.warn("Error during signin: "+t),void this._cleanup();this.pusher.send_event("pusher:signin",{auth:e.auth,user_data:e.user_data})},this.pusher=t,this.pusher.connection.bind("state_change",({previous:t,current:e})=>{"connected"!==t&&"connected"===e&&this._signin(),"connected"===t&&"connected"!==e&&(this._cleanup(),this._newSigninPromiseIfNeeded())}),this.watchlist=new Pe(t),this.pusher.connection.bind("message",t=>{"pusher:signin_success"===t.event&&this._onSigninSuccess(t.data),this.serverToUserChannel&&this.serverToUserChannel.name===t.channel&&this.serverToUserChannel.handleEvent(t)})}signin(){this.signin_requested||(this.signin_requested=!0,this._signin())}_signin(){this.signin_requested&&(this._newSigninPromiseIfNeeded(),"connected"===this.pusher.connection.state&&this.pusher.config.userAuthenticator({socketId:this.pusher.connection.socket_id},this._onAuthorize))}_onSigninSuccess(t){try{this.user_data=JSON.parse(t.user_data)}catch(e){return z.error("Failed parsing user data after signin: "+t.user_data),void this._cleanup()}if("string"!=typeof this.user_data.id||""===this.user_data.id)return z.error("user_data doesn't contain an id. user_data: "+this.user_data),void this._cleanup();this._signinDoneResolve(),this._subscribeChannels()}_subscribeChannels(){this.serverToUserChannel=new ut("#server-to-user-"+this.user_data.id,this.pusher),this.serverToUserChannel.bind_global((t,e)=>{0!==t.indexOf("pusher_internal:")&&0!==t.indexOf("pusher:")&&this.emit(t,e)}),(t=>{t.subscriptionPending&&t.subscriptionCancelled?t.reinstateSubscription():t.subscriptionPending||"connected"!==this.pusher.connection.state||t.subscribe()})(this.serverToUserChannel)}_cleanup(){this.user_data=null,this.serverToUserChannel&&(this.serverToUserChannel.unbind_all(),this.serverToUserChannel.disconnect(),this.serverToUserChannel=null),this.signin_requested&&this._signinDoneResolve()}_newSigninPromiseIfNeeded(){if(!this.signin_requested)return;if(this.signinDonePromise&&!this.signinDonePromise.done)return;const{promise:t,resolve:e,reject:n}=Ae();t.done=!1;const r=()=>{t.done=!0};t.then(r).catch(r),this.signinDonePromise=t,this._signinDoneResolve=e}}class xe{static ready(){xe.isReady=!0;for(var t=0,e=xe.instances.length;tae.getDefaultStrategy(this.config,t,fe),timeline:this.timeline,activityTimeout:this.config.activityTimeout,pongTimeout:this.config.pongTimeout,unavailableTimeout:this.config.unavailableTimeout,useTLS:Boolean(this.config.useTLS)}),this.connection.bind("connected",()=>{this.subscribeAll(),this.timelineSender&&this.timelineSender.send(this.connection.isUsingTLS())}),this.connection.bind("message",t=>{var e=0===t.event.indexOf("pusher_internal:");if(t.channel){var n=this.channel(t.channel);n&&n.handleEvent(t)}e||this.global_emitter.emit(t.event,t.data)}),this.connection.bind("connecting",()=>{this.channels.disconnect()}),this.connection.bind("disconnected",()=>{this.channels.disconnect()}),this.connection.bind("error",t=>{z.warn(t)}),xe.instances.push(this),this.timeline.info({instances:xe.instances.length}),this.user=new Ee(this),xe.isReady&&this.connect()}switchCluster(t){const{appKey:e,cluster:n}=t;this.key=e,this.options=Object.assign(Object.assign({},this.options),{cluster:n}),this.config=me(this.options,this),this.connection.switchCluster(this.key)}channel(t){return this.channels.find(t)}allChannels(){return this.channels.all()}connect(){if(this.connection.connect(),this.timelineSender&&!this.timelineSenderTimer){var t=this.connection.isUsingTLS(),e=this.timelineSender;this.timelineSenderTimer=new b(6e4,(function(){e.send(t)}))}}disconnect(){this.connection.disconnect(),this.timelineSenderTimer&&(this.timelineSenderTimer.ensureAborted(),this.timelineSenderTimer=null)}bind(t,e,n){return this.global_emitter.bind(t,e,n),this}unbind(t,e,n){return this.global_emitter.unbind(t,e,n),this}bind_global(t){return this.global_emitter.bind_global(t),this}unbind_global(t){return this.global_emitter.unbind_global(t),this}unbind_all(t){return this.global_emitter.unbind_all(),this}subscribeAll(){var t;for(t in this.channels.channels)this.channels.channels.hasOwnProperty(t)&&this.subscribe(t)}subscribe(t){var e=this.channels.add(t,this);return e.subscriptionPending&&e.subscriptionCancelled?e.reinstateSubscription():e.subscriptionPending||"connected"!==this.connection.state||e.subscribe(),e}unsubscribe(t){var e=this.channels.find(t);e&&e.subscriptionPending?e.cancelSubscription():(e=this.channels.remove(t))&&e.subscribed&&e.unsubscribe()}send_event(t,e,n){return this.connection.send_event(t,e,n)}shouldUseTLS(){return this.config.useTLS}signin(){this.user.signin()}}xe.instances=[],xe.isReady=!1,xe.logToConsole=!1,xe.Runtime=ae,xe.ScriptReceivers=ae.ScriptReceivers,xe.DependenciesReceivers=ae.DependenciesReceivers,xe.auth_callbacks=ae.auth_callbacks;var Oe=xe;ae.setup(xe);var Le=n(2);class Ue extends Oe{constructor(t,e){Oe.logToConsole=Ue.logToConsole,Oe.log=Ue.log,be(e),e.nacl=Le,super(t,e)}}}])})); //# sourceMappingURL=pusher-with-encryption.worker.min.js.map \ No newline at end of file diff --git a/dist/worker/pusher-with-encryption.worker.min.js.map b/dist/worker/pusher-with-encryption.worker.min.js.map index df7b9e0ab..3a198b0af 100644 --- a/dist/worker/pusher-with-encryption.worker.min.js.map +++ b/dist/worker/pusher-with-encryption.worker.min.js.map @@ -1 +1 @@ -{"version":3,"sources":["webpack://Pusher/webpack/universalModuleDefinition","webpack://Pusher/webpack/bootstrap","webpack://Pusher/./node_modules/@stablelib/base64/base64.ts","webpack://Pusher/./node_modules/@stablelib/utf8/utf8.ts","webpack://Pusher/./node_modules/tweetnacl/nacl-fast.js","webpack://Pusher/./src/core/pusher-with-encryption.js","webpack://Pusher/./src/core/base64.ts","webpack://Pusher/./src/core/utils/timers/abstract_timer.ts","webpack://Pusher/./src/core/utils/timers/index.ts","webpack://Pusher/./src/core/util.ts","webpack://Pusher/./src/core/utils/collections.ts","webpack://Pusher/./src/core/defaults.ts","webpack://Pusher/./src/core/transports/url_schemes.ts","webpack://Pusher/./src/core/events/callback_registry.ts","webpack://Pusher/./src/core/events/dispatcher.ts","webpack://Pusher/./src/core/logger.ts","webpack://Pusher/./src/core/transports/transport_connection.ts","webpack://Pusher/./src/core/transports/transport.ts","webpack://Pusher/./src/runtimes/isomorphic/transports/transports.ts","webpack://Pusher/./src/core/transports/assistant_to_the_transport_manager.ts","webpack://Pusher/./src/core/connection/protocol/protocol.ts","webpack://Pusher/./src/core/connection/connection.ts","webpack://Pusher/./src/core/connection/handshake/index.ts","webpack://Pusher/./src/core/timeline/timeline_sender.ts","webpack://Pusher/./src/core/errors.ts","webpack://Pusher/./src/core/utils/url_store.ts","webpack://Pusher/./src/core/channels/channel.ts","webpack://Pusher/./src/core/channels/private_channel.ts","webpack://Pusher/./src/core/channels/members.ts","webpack://Pusher/./src/core/channels/presence_channel.ts","webpack://Pusher/./src/core/channels/encrypted_channel.ts","webpack://Pusher/./src/core/connection/connection_manager.ts","webpack://Pusher/./src/core/channels/channels.ts","webpack://Pusher/./src/core/utils/factory.ts","webpack://Pusher/./src/core/transports/transport_manager.ts","webpack://Pusher/./src/core/strategies/sequential_strategy.ts","webpack://Pusher/./src/core/strategies/best_connected_ever_strategy.ts","webpack://Pusher/./src/core/strategies/websocket_prioritized_cached_strategy.ts","webpack://Pusher/./src/core/strategies/delayed_strategy.ts","webpack://Pusher/./src/core/strategies/if_strategy.ts","webpack://Pusher/./src/core/strategies/first_connected_strategy.ts","webpack://Pusher/./src/runtimes/isomorphic/default_strategy.ts","webpack://Pusher/./src/core/http/http_request.ts","webpack://Pusher/./src/core/http/state.ts","webpack://Pusher/./src/core/http/http_socket.ts","webpack://Pusher/./src/core/http/http_streaming_socket.ts","webpack://Pusher/./src/core/http/http_polling_socket.ts","webpack://Pusher/./src/runtimes/isomorphic/http/http_xhr_request.ts","webpack://Pusher/./src/runtimes/isomorphic/runtime.ts","webpack://Pusher/./src/runtimes/isomorphic/transports/transport_connection_initializer.ts","webpack://Pusher/./src/runtimes/isomorphic/http/http.ts","webpack://Pusher/./src/runtimes/worker/net_info.ts","webpack://Pusher/./src/runtimes/worker/auth/fetch_auth.ts","webpack://Pusher/./src/runtimes/worker/timeline/fetch_timeline.ts","webpack://Pusher/./src/runtimes/worker/runtime.ts","webpack://Pusher/./src/core/timeline/level.ts","webpack://Pusher/./src/core/timeline/timeline.ts","webpack://Pusher/./src/core/strategies/transport_strategy.ts","webpack://Pusher/./src/core/strategies/strategy_builder.ts","webpack://Pusher/./src/core/auth/options.ts","webpack://Pusher/./src/core/options.ts","webpack://Pusher/./src/core/auth/user_authenticator.ts","webpack://Pusher/./src/core/auth/channel_authorizer.ts","webpack://Pusher/./src/core/config.ts","webpack://Pusher/./src/core/auth/deprecated_channel_authorizer.ts","webpack://Pusher/./src/core/watchlist.ts","webpack://Pusher/./src/core/utils/flat_promise.ts","webpack://Pusher/./src/core/user.ts","webpack://Pusher/./src/core/pusher.ts","webpack://Pusher/./src/core/pusher-with-encryption.ts"],"names":["root","factory","exports","module","define","amd","this","installedModules","__webpack_require__","moduleId","i","l","modules","call","m","c","d","name","getter","o","Object","defineProperty","enumerable","get","r","Symbol","toStringTag","value","t","mode","__esModule","ns","create","key","bind","n","object","property","prototype","hasOwnProperty","p","s","_paddingCharacter","encodedLength","length","encode","data","out","_encodeByte","left","maxDecodedLength","decodedLength","_getPaddingLength","decode","Uint8Array","paddingLength","op","haveBad","v0","v1","v2","v3","_decodeChar","charCodeAt","Error","b","result","String","fromCharCode","Coder","stdCoder","URLSafeCoder","urlSafeCoder","INVALID_UTF8","arr","pos","chars","min","n1","n2","n3","push","join","nacl","gf","init","Float64Array","randombytes","_0","_9","gf0","gf1","_121665","D","D2","X","Y","I","ts64","x","h","vn","xi","y","yi","crypto_verify_16","crypto_verify_32","crypto_core_salsa20","inp","k","u","j0","j1","j2","j3","j4","j5","j6","j7","j8","j9","j10","j11","j12","j13","j14","j15","x0","x1","x2","x3","x4","x5","x6","x7","x8","x9","x10","x11","x12","x13","x14","x15","core_salsa20","crypto_core_hsalsa20","core_hsalsa20","sigma","crypto_stream_salsa20_xor","cpos","mpos","z","crypto_stream_salsa20","crypto_stream","sn","crypto_stream_xor","poly1305","t0","t1","t2","t3","t4","t5","t6","t7","buffer","Uint16Array","pad","leftover","fin","crypto_onetimeauth","outpos","update","finish","crypto_onetimeauth_verify","hpos","crypto_secretbox","crypto_secretbox_open","set25519","a","car25519","v","Math","floor","sel25519","q","pack25519","j","neq25519","par25519","unpack25519","A","Z","M","t8","t9","t10","t11","t12","t13","t14","t15","t16","t17","t18","t19","t20","t21","t22","t23","t24","t25","t26","t27","t28","t29","t30","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","b10","b11","b12","b13","b14","b15","S","inv25519","pow2523","crypto_scalarmult","e","f","x32","subarray","x16","crypto_scalarmult_base","crypto_box_keypair","crypto_box_beforenm","blocks","bytes","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","hibit","h0","h1","h2","h3","h4","h5","h6","h7","h8","h9","r0","r1","r2","r3","r4","r5","r6","r7","r8","r9","mac","macpos","mask","g","want","crypto_box_afternm","crypto_box_open_afternm","K","crypto_hashblocks_hl","hh","hl","bh0","bh1","bh2","bh3","bh4","bh5","bh6","bh7","bl0","bl1","bl2","bl3","bl4","bl5","bl6","bl7","th","tl","wh","Int32Array","wl","ah0","ah1","ah2","ah3","ah4","ah5","ah6","ah7","al0","al1","al2","al3","al4","al5","al6","al7","crypto_hash","add","cswap","pack","tx","ty","zi","scalarmult","scalarbase","crypto_sign_keypair","pk","sk","seeded","L","modL","carry","reduce","crypto_sign","sm","smlen","crypto_sign_open","chk","num","den","den2","den4","den6","unpackneg","checkLengths","checkArrayTypes","arguments","TypeError","cleanup","lowlevel","crypto_box","crypto_box_open","crypto_secretbox_KEYBYTES","crypto_secretbox_NONCEBYTES","crypto_secretbox_ZEROBYTES","crypto_secretbox_BOXZEROBYTES","crypto_scalarmult_BYTES","crypto_scalarmult_SCALARBYTES","crypto_box_PUBLICKEYBYTES","crypto_box_SECRETKEYBYTES","crypto_box_BEFORENMBYTES","crypto_box_NONCEBYTES","crypto_box_ZEROBYTES","crypto_box_BOXZEROBYTES","crypto_sign_BYTES","crypto_sign_PUBLICKEYBYTES","crypto_sign_SECRETKEYBYTES","crypto_sign_SEEDBYTES","crypto_hash_BYTES","randomBytes","secretbox","msg","nonce","open","box","keyLength","nonceLength","overheadLength","scalarMult","base","scalarLength","groupElementLength","publicKey","secretKey","before","checkBoxLengths","after","keyPair","fromSecretKey","publicKeyLength","secretKeyLength","sharedKeyLength","sign","signedMsg","tmp","mlen","detached","sig","verify","fromSeed","seed","seedLength","signatureLength","hash","hashLength","setPRNG","fn","crypto","self","msCrypto","getRandomValues","default","b64chars","b64tab","charAt","cb_utob","cc","utob","replace","cb_encode","ccc","padlen","ord","btoa","set","clear","delay","callback","timer","clearTimeout","clearInterval","super","setTimeout","setInterval","now","Date","valueOf","defer","args","boundArguments","Array","slice","apply","concat","extend","target","sources","extensions","constructor","stringify","safeJSONStringify","arrayIndexOf","array","item","nativeIndexOf","indexOf","objectApply","keys","_","context","map","filter","test","filterObject","Boolean","any","encodeParamsObject","encodeURIComponent","toString","buildQueryString","params","undefined","method","source","JSON","objects","paths","derez","path","nu","$ref","VERSION","PROTOCOL","wsPort","wssPort","wsPath","httpHost","httpPort","httpsPort","httpPath","stats_host","authEndpoint","authTransport","activityTimeout","pongTimeout","unavailableTimeout","userAuthentication","endpoint","transport","channelAuthorization","cdn_http","cdn_https","dependency_suffix","getGenericURL","baseScheme","useTLS","hostTLS","hostNonTLS","getGenericPath","queryString","ws","getInitial","http","_callbacks","prefix","prefixedEventName","names","removeCallback","removeAllCallbacks","binding","failThrough","callbacks","global_callbacks","eventName","remove","unbind","unbind_global","metadata","globalLog","message","console","log","globalLogWarn","globalLogError","warn","error","defaultLoggingFunction","logToConsole","hooks","priority","options","initialize","transportConnectionInitializer","state","timeline","id","generateUniqueID","handlesActivityChecks","supportsPing","socket","url","urls","getSocket","onError","changeState","bindListeners","debug","close","send","ping","beforeOpen","getPath","onopen","emit","type","buildTimelineMessage","closeEvent","code","reason","wasClean","unbindListeners","onOpen","onerror","onclose","onClose","onmessage","onMessage","onactivity","onActivity","info","cid","environment","isSupported","WSTransport","isInitialized","getWebSocketAPI","createWebSocket","httpConfiguration","streamingConfiguration","HTTPFactory","createStreamingSocket","pollingConfiguration","createPollingSocket","xhrConfiguration","isXHRSupported","xhr_streaming","xhr_polling","manager","minPingDelay","maxPingDelay","pingDelay","connection","createConnection","openTimestamp","onClosed","reportDeath","lifespan","max","isAlive","Protocol","decodeMessage","messageEvent","messageData","parse","pusherEventData","pusherEvent","event","channel","user_id","encodeMessage","processHandshake","activity_timeout","action","socket_id","getCloseAction","getCloseError","send_event","listeners","activity","closed","handleCloseEvent","listener","isEmpty","TimelineTransport","getAgent","BadEventName","setPrototypeOf","BadChannelName","TransportPriorityTooLow","TransportClosed","UnsupportedFeature","UnsupportedTransport","UnsupportedStrategy","HTTPAuthError","status","urlStore","baseUrl","authenticationEndpoint","authorizationEndpoint","javascriptQuickStart","triggeringClientEvents","encryptedChannelSupport","fullUrl","urlObj","pusher","subscribed","subscriptionPending","subscriptionCancelled","socketId","auth","suffix","handleSubscriptionSucceededEvent","handleSubscriptionCountEvent","unsubscribe","subscription_count","subscriptionCount","authorize","assign","channel_data","config","channelAuthorizer","channelName","reset","members","member","myID","subscriptionData","presence","count","me","memberData","user_info","authData","channelData","setMyID","user","signinDonePromise","user_data","handleInternalEvent","addedMember","addMember","removedMember","removeMember","onSubscription","disconnect","sharedSecret","handleEncryptedEvent","handleEvent","ciphertext","cipherText","getDataToEmit","raw","usingTLS","errorCallbacks","buildErrorCallbacks","connectionCallbacks","buildConnectionCallbacks","handshakeCallbacks","buildHandshakeCallbacks","Network","getNetwork","netinfo","retryIn","sendActivityCheck","updateStrategy","runner","strategy","updateState","startConnecting","setUnavailableTimer","disconnectInternally","handshake","connect","handshakeError","abortConnecting","abort","clearRetryTimer","clearUnavailableTimer","abandonConnection","getStrategy","round","retryTimer","ensureAborted","unavailableTimer","stopActivityCheck","activityTimer","pong_timed_out","resetActivityCheck","shouldRetry","connected","Infinity","setConnection","withErrorEmitted","tls_only","refused","backoff","retry","newState","previousState","newStateDescription","previous","current","channels","createEncryptedChannel","errMsg","createPrivateChannel","createPresenceChannel","createChannel","values","createChannels","createConnectionManager","createTimelineSender","createHandshake","createAssistantToTheTransportManager","livesLeft","lives","strategies","loop","failFast","timeout","timeoutLimit","minPriority","tryNextStrategy","tryStrategy","forceMinPriority","isRunning","callbackBuilder","runners","rs","abortRunner","allRunnersFailed","aborted","transports","ttl","storage","getLocalStorage","serializedCache","getTransportCacheKey","flushTransportCache","fetchTransportCache","cacheSkipCount","timestamp","includes","cached","latency","startTimestamp","pop","cb","storeTransportCache","number","IfStrategy","trueBranch","falseBranch","FirstConnectedStrategy","testSupportsStrategy","baseOptions","defineTransport","definedTransports","defineTransportStrategy","wsStrategy","ws_options","wsHost","wss_options","http_options","timeouts","ws_manager","streaming_manager","ws_transport","wss_transport","xhr_streaming_transport","xhr_polling_transport","ws_loop","wss_loop","streaming_loop","polling_loop","http_loop","payload","position","xhr","getRequest","unloader","addUnloadListener","setRequestHeader","removeUnloadListener","abortRequest","chunk","advanceBuffer","isBufferTooLong","unreadData","endOfLinePosition","State","autoIncrement","getUniqueURL","separator","randomNumber","randomInt","session","randomString","location","parts","exec","getLocation","readyState","CONNECTING","openStream","sendRaw","sendHeartbeat","OPEN","createSocketRequest","start","closeStream","CLOSED","onEvent","onHeartbeat","hostname","urlParts","stream","getReceiveURL","onChunk","onFinished","reconnect","unbind_all","getXHRAPI","onreadystatechange","onprogress","responseText","getDefaultStrategy","Transports","createSocket","createRequest","PusherClass","ready","getClientFeatures","getProtocol","createXHR","query","authOptions","authRequestType","headers","Headers","headerName","headersProvider","dynamicHeaders","body","request","Request","credentials","fetch","then","response","text","parsedData","catch","err","sender","host","json","setup","TimelineLevel","getAuthorizers","ajax","WebSocket","XMLHttpRequest","globalThis","Uint32Array","events","sent","uniqueID","level","limit","shift","ERROR","INFO","DEBUG","sendfn","bundle","lib","version","cluster","features","failAttempt","onInitialized","serializedTransport","AuthRequestType","transportClass","enabledTransports","disabledTransports","ignoreNullOrigin","getAssistant","deferred","validateOptions","paramsProvider","dynamicParams","composeChannelQuery","UserAuthentication","ChannelAuthorization","getConfig","opts","statsHost","enableStats","getEnableStatsConfig","getHttpHost","shouldUseTLS","getWebsocketHost","userAuthenticator","buildUserAuthenticator","buildChannelAuthorizer","timelineParams","forceTLS","disableStats","customHandler","channelAuthorizerGenerator","deprecatedAuthorizerOptions","ChannelAuthorizerProxy","authorizer","buildChannelAuth","bindWatchlistInternalEvent","forEach","watchlistEvent","resolve","reject","promise","Promise","res","rej","signin_requested","serverToUserChannel","_signinDoneResolve","_onAuthorize","_cleanup","_signin","_newSigninPromiseIfNeeded","watchlist","_onSigninSuccess","_subscribeChannels","bind_global","reinstateSubscription","subscribe","ensure_subscribed","done","setDone","isReady","instances","app_key","checkAppKey","global_emitter","sessionID","timelineSender","subscribeAll","isUsingTLS","internal","appKey","switchCluster","find","all","timelineSenderTimer","event_name","channel_name","cancelSubscription","signin","Runtime","ScriptReceivers","DependenciesReceivers","auth_callbacks"],"mappings":";;;;;;;CAAA,SAA2CA,EAAMC,GAC1B,iBAAZC,SAA0C,iBAAXC,OACxCA,OAAOD,QAAUD,IACQ,mBAAXG,QAAyBA,OAAOC,IAC9CD,OAAO,GAAIH,GACe,iBAAZC,QACdA,QAAgB,OAAID,IAEpBD,EAAa,OAAIC,IARnB,CASGK,MAAM,WACT,O,YCTE,IAAIC,EAAmB,GAGvB,SAASC,EAAoBC,GAG5B,GAAGF,EAAiBE,GACnB,OAAOF,EAAiBE,GAAUP,QAGnC,IAAIC,EAASI,EAAiBE,GAAY,CACzCC,EAAGD,EACHE,GAAG,EACHT,QAAS,IAUV,OANAU,EAAQH,GAAUI,KAAKV,EAAOD,QAASC,EAAQA,EAAOD,QAASM,GAG/DL,EAAOQ,GAAI,EAGJR,EAAOD,QA0Df,OArDAM,EAAoBM,EAAIF,EAGxBJ,EAAoBO,EAAIR,EAGxBC,EAAoBQ,EAAI,SAASd,EAASe,EAAMC,GAC3CV,EAAoBW,EAAEjB,EAASe,IAClCG,OAAOC,eAAenB,EAASe,EAAM,CAAEK,YAAY,EAAMC,IAAKL,KAKhEV,EAAoBgB,EAAI,SAAStB,GACX,oBAAXuB,QAA0BA,OAAOC,aAC1CN,OAAOC,eAAenB,EAASuB,OAAOC,YAAa,CAAEC,MAAO,WAE7DP,OAAOC,eAAenB,EAAS,aAAc,CAAEyB,OAAO,KAQvDnB,E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BAC5C,GAAAC,eAA4B,GAASA,eAVzB,UAkPrB,GAAQ1G,MAAM,I,YClQC,MAAM,WAA6B,GAChD,YAAYsF,EAAiBrc,GAC3B,GAAOH,aAAe,GAAqBA,aAC3C,GAAON,IAAM,GAAqBA,IAElCyZ,GAAgBhZ,GAChBA,EAAQld,KAAO,GACfqW,MAAMkjB,EAASrc","file":"pusher-with-encryption.worker.min.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"Pusher\"] = factory();\n\telse\n\t\troot[\"Pusher\"] = factory();\n})(this, function() {\nreturn "," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 3);\n","// Copyright (C) 2016 Dmitry Chestnykh\n// MIT License. See LICENSE file for details.\n\n/**\n * Package base64 implements Base64 encoding and decoding.\n */\n\n// Invalid character used in decoding to indicate\n// that the character to decode is out of range of\n// alphabet and cannot be decoded.\nconst INVALID_BYTE = 256;\n\n/**\n * Implements standard Base64 encoding.\n *\n * Operates in constant time.\n */\nexport class Coder {\n // TODO(dchest): methods to encode chunk-by-chunk.\n\n constructor(private _paddingCharacter = \"=\") { }\n\n encodedLength(length: number): number {\n if (!this._paddingCharacter) {\n return (length * 8 + 5) / 6 | 0;\n }\n return (length + 2) / 3 * 4 | 0;\n }\n\n encode(data: Uint8Array): string {\n let out = \"\";\n\n let i = 0;\n for (; i < data.length - 2; i += 3) {\n let c = (data[i] << 16) | (data[i + 1] << 8) | (data[i + 2]);\n out += this._encodeByte((c >>> 3 * 6) & 63);\n out += this._encodeByte((c >>> 2 * 6) & 63);\n out += this._encodeByte((c >>> 1 * 6) & 63);\n out += this._encodeByte((c >>> 0 * 6) & 63);\n }\n\n const left = data.length - i;\n if (left > 0) {\n let c = (data[i] << 16) | (left === 2 ? data[i + 1] << 8 : 0);\n out += this._encodeByte((c >>> 3 * 6) & 63);\n out += this._encodeByte((c >>> 2 * 6) & 63);\n if (left === 2) {\n out += this._encodeByte((c >>> 1 * 6) & 63);\n } else {\n out += this._paddingCharacter || \"\";\n }\n out += this._paddingCharacter || \"\";\n }\n\n return out;\n }\n\n maxDecodedLength(length: number): number {\n if (!this._paddingCharacter) {\n return (length * 6 + 7) / 8 | 0;\n }\n return length / 4 * 3 | 0;\n }\n\n decodedLength(s: string): number {\n return this.maxDecodedLength(s.length - this._getPaddingLength(s));\n }\n\n decode(s: string): Uint8Array {\n if (s.length === 0) {\n return new Uint8Array(0);\n }\n const paddingLength = this._getPaddingLength(s);\n const length = s.length - paddingLength;\n const out = new Uint8Array(this.maxDecodedLength(length));\n let op = 0;\n let i = 0;\n let haveBad = 0;\n let v0 = 0, v1 = 0, v2 = 0, v3 = 0;\n for (; i < length - 4; i += 4) {\n v0 = this._decodeChar(s.charCodeAt(i + 0));\n v1 = this._decodeChar(s.charCodeAt(i + 1));\n v2 = this._decodeChar(s.charCodeAt(i + 2));\n v3 = this._decodeChar(s.charCodeAt(i + 3));\n out[op++] = (v0 << 2) | (v1 >>> 4);\n out[op++] = (v1 << 4) | (v2 >>> 2);\n out[op++] = (v2 << 6) | v3;\n haveBad |= v0 & INVALID_BYTE;\n haveBad |= v1 & INVALID_BYTE;\n haveBad |= v2 & INVALID_BYTE;\n haveBad |= v3 & INVALID_BYTE;\n }\n if (i < length - 1) {\n v0 = this._decodeChar(s.charCodeAt(i));\n v1 = this._decodeChar(s.charCodeAt(i + 1));\n out[op++] = (v0 << 2) | (v1 >>> 4);\n haveBad |= v0 & INVALID_BYTE;\n haveBad |= v1 & INVALID_BYTE;\n }\n if (i < length - 2) {\n v2 = this._decodeChar(s.charCodeAt(i + 2));\n out[op++] = (v1 << 4) | (v2 >>> 2);\n haveBad |= v2 & INVALID_BYTE;\n }\n if (i < length - 3) {\n v3 = this._decodeChar(s.charCodeAt(i + 3));\n out[op++] = (v2 << 6) | v3;\n haveBad |= v3 & INVALID_BYTE;\n }\n if (haveBad !== 0) {\n throw new Error(\"Base64Coder: incorrect characters for decoding\");\n }\n return out;\n }\n\n // Standard encoding have the following encoded/decoded ranges,\n // which we need to convert between.\n //\n // ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 0123456789 + /\n // Index: 0 - 25 26 - 51 52 - 61 62 63\n // ASCII: 65 - 90 97 - 122 48 - 57 43 47\n //\n\n // Encode 6 bits in b into a new character.\n protected _encodeByte(b: number): string {\n // Encoding uses constant time operations as follows:\n //\n // 1. Define comparison of A with B using (A - B) >>> 8:\n // if A > B, then result is positive integer\n // if A <= B, then result is 0\n //\n // 2. Define selection of C or 0 using bitwise AND: X & C:\n // if X == 0, then result is 0\n // if X != 0, then result is C\n //\n // 3. Start with the smallest comparison (b >= 0), which is always\n // true, so set the result to the starting ASCII value (65).\n //\n // 4. Continue comparing b to higher ASCII values, and selecting\n // zero if comparison isn't true, otherwise selecting a value\n // to add to result, which:\n //\n // a) undoes the previous addition\n // b) provides new value to add\n //\n let result = b;\n // b >= 0\n result += 65;\n // b > 25\n result += ((25 - b) >>> 8) & ((0 - 65) - 26 + 97);\n // b > 51\n result += ((51 - b) >>> 8) & ((26 - 97) - 52 + 48);\n // b > 61\n result += ((61 - b) >>> 8) & ((52 - 48) - 62 + 43);\n // b > 62\n result += ((62 - b) >>> 8) & ((62 - 43) - 63 + 47);\n\n return String.fromCharCode(result);\n }\n\n // Decode a character code into a byte.\n // Must return 256 if character is out of alphabet range.\n protected _decodeChar(c: number): number {\n // Decoding works similar to encoding: using the same comparison\n // function, but now it works on ranges: result is always incremented\n // by value, but this value becomes zero if the range is not\n // satisfied.\n //\n // Decoding starts with invalid value, 256, which is then\n // subtracted when the range is satisfied. If none of the ranges\n // apply, the function returns 256, which is then checked by\n // the caller to throw error.\n let result = INVALID_BYTE; // start with invalid character\n\n // c == 43 (c > 42 and c < 44)\n result += (((42 - c) & (c - 44)) >>> 8) & (-INVALID_BYTE + c - 43 + 62);\n // c == 47 (c > 46 and c < 48)\n result += (((46 - c) & (c - 48)) >>> 8) & (-INVALID_BYTE + c - 47 + 63);\n // c > 47 and c < 58\n result += (((47 - c) & (c - 58)) >>> 8) & (-INVALID_BYTE + c - 48 + 52);\n // c > 64 and c < 91\n result += (((64 - c) & (c - 91)) >>> 8) & (-INVALID_BYTE + c - 65 + 0);\n // c > 96 and c < 123\n result += (((96 - c) & (c - 123)) >>> 8) & (-INVALID_BYTE + c - 97 + 26);\n\n return result;\n }\n\n private _getPaddingLength(s: string): number {\n let paddingLength = 0;\n if (this._paddingCharacter) {\n for (let i = s.length - 1; i >= 0; i--) {\n if (s[i] !== this._paddingCharacter) {\n break;\n }\n paddingLength++;\n }\n if (s.length < 4 || paddingLength > 2) {\n throw new Error(\"Base64Coder: incorrect padding\");\n }\n }\n return paddingLength;\n }\n\n}\n\nconst stdCoder = new Coder();\n\nexport function encode(data: Uint8Array): string {\n return stdCoder.encode(data);\n}\n\nexport function decode(s: string): Uint8Array {\n return stdCoder.decode(s);\n}\n\n/**\n * Implements URL-safe Base64 encoding.\n * (Same as Base64, but '+' is replaced with '-', and '/' with '_').\n *\n * Operates in constant time.\n */\nexport class URLSafeCoder extends Coder {\n // URL-safe encoding have the following encoded/decoded ranges:\n //\n // ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 0123456789 - _\n // Index: 0 - 25 26 - 51 52 - 61 62 63\n // ASCII: 65 - 90 97 - 122 48 - 57 45 95\n //\n\n protected _encodeByte(b: number): string {\n let result = b;\n // b >= 0\n result += 65;\n // b > 25\n result += ((25 - b) >>> 8) & ((0 - 65) - 26 + 97);\n // b > 51\n result += ((51 - b) >>> 8) & ((26 - 97) - 52 + 48);\n // b > 61\n result += ((61 - b) >>> 8) & ((52 - 48) - 62 + 45);\n // b > 62\n result += ((62 - b) >>> 8) & ((62 - 45) - 63 + 95);\n\n return String.fromCharCode(result);\n }\n\n protected _decodeChar(c: number): number {\n let result = INVALID_BYTE;\n\n // c == 45 (c > 44 and c < 46)\n result += (((44 - c) & (c - 46)) >>> 8) & (-INVALID_BYTE + c - 45 + 62);\n // c == 95 (c > 94 and c < 96)\n result += (((94 - c) & (c - 96)) >>> 8) & (-INVALID_BYTE + c - 95 + 63);\n // c > 47 and c < 58\n result += (((47 - c) & (c - 58)) >>> 8) & (-INVALID_BYTE + c - 48 + 52);\n // c > 64 and c < 91\n result += (((64 - c) & (c - 91)) >>> 8) & (-INVALID_BYTE + c - 65 + 0);\n // c > 96 and c < 123\n result += (((96 - c) & (c - 123)) >>> 8) & (-INVALID_BYTE + c - 97 + 26);\n\n return result;\n }\n}\n\nconst urlSafeCoder = new URLSafeCoder();\n\nexport function encodeURLSafe(data: Uint8Array): string {\n return urlSafeCoder.encode(data);\n}\n\nexport function decodeURLSafe(s: string): Uint8Array {\n return urlSafeCoder.decode(s);\n}\n\n\nexport const encodedLength = (length: number) =>\n stdCoder.encodedLength(length);\n\nexport const maxDecodedLength = (length: number) =>\n stdCoder.maxDecodedLength(length);\n\nexport const decodedLength = (s: string) =>\n stdCoder.decodedLength(s);\n","// Copyright (C) 2016 Dmitry Chestnykh\n// MIT License. See LICENSE file for details.\n\n/**\n * Package utf8 implements UTF-8 encoding and decoding.\n */\n\nconst INVALID_UTF16 = \"utf8: invalid string\";\nconst INVALID_UTF8 = \"utf8: invalid source encoding\";\n\n/**\n * Encodes the given string into UTF-8 byte array.\n * Throws if the source string has invalid UTF-16 encoding.\n */\nexport function encode(s: string): Uint8Array {\n // Calculate result length and allocate output array.\n // encodedLength() also validates string and throws errors,\n // so we don't need repeat validation here.\n const arr = new Uint8Array(encodedLength(s));\n\n let pos = 0;\n for (let i = 0; i < s.length; i++) {\n let c = s.charCodeAt(i);\n if (c < 0x80) {\n arr[pos++] = c;\n } else if (c < 0x800) {\n arr[pos++] = 0xc0 | c >> 6;\n arr[pos++] = 0x80 | c & 0x3f;\n } else if (c < 0xd800) {\n arr[pos++] = 0xe0 | c >> 12;\n arr[pos++] = 0x80 | (c >> 6) & 0x3f;\n arr[pos++] = 0x80 | c & 0x3f;\n } else {\n i++; // get one more character\n c = (c & 0x3ff) << 10;\n c |= s.charCodeAt(i) & 0x3ff;\n c += 0x10000;\n\n arr[pos++] = 0xf0 | c >> 18;\n arr[pos++] = 0x80 | (c >> 12) & 0x3f;\n arr[pos++] = 0x80 | (c >> 6) & 0x3f;\n arr[pos++] = 0x80 | c & 0x3f;\n }\n }\n return arr;\n}\n\n/**\n * Returns the number of bytes required to encode the given string into UTF-8.\n * Throws if the source string has invalid UTF-16 encoding.\n */\nexport function encodedLength(s: string): number {\n let result = 0;\n for (let i = 0; i < s.length; i++) {\n const c = s.charCodeAt(i);\n if (c < 0x80) {\n result += 1;\n } else if (c < 0x800) {\n result += 2;\n } else if (c < 0xd800) {\n result += 3;\n } else if (c <= 0xdfff) {\n if (i >= s.length - 1) {\n throw new Error(INVALID_UTF16);\n }\n i++; // \"eat\" next character\n result += 4;\n } else {\n throw new Error(INVALID_UTF16);\n }\n }\n return result;\n}\n\n/**\n * Decodes the given byte array from UTF-8 into a string.\n * Throws if encoding is invalid.\n */\nexport function decode(arr: Uint8Array): string {\n const chars: string[] = [];\n for (let i = 0; i < arr.length; i++) {\n let b = arr[i];\n\n if (b & 0x80) {\n let min;\n if (b < 0xe0) {\n // Need 1 more byte.\n if (i >= arr.length) {\n throw new Error(INVALID_UTF8);\n }\n const n1 = arr[++i];\n if ((n1 & 0xc0) !== 0x80) {\n throw new Error(INVALID_UTF8);\n }\n b = (b & 0x1f) << 6 | (n1 & 0x3f);\n min = 0x80;\n } else if (b < 0xf0) {\n // Need 2 more bytes.\n if (i >= arr.length - 1) {\n throw new Error(INVALID_UTF8);\n }\n const n1 = arr[++i];\n const n2 = arr[++i];\n if ((n1 & 0xc0) !== 0x80 || (n2 & 0xc0) !== 0x80) {\n throw new Error(INVALID_UTF8);\n }\n b = (b & 0x0f) << 12 | (n1 & 0x3f) << 6 | (n2 & 0x3f);\n min = 0x800;\n } else if (b < 0xf8) {\n // Need 3 more bytes.\n if (i >= arr.length - 2) {\n throw new Error(INVALID_UTF8);\n }\n const n1 = arr[++i];\n const n2 = arr[++i];\n const n3 = arr[++i];\n if ((n1 & 0xc0) !== 0x80 || (n2 & 0xc0) !== 0x80 || (n3 & 0xc0) !== 0x80) {\n throw new Error(INVALID_UTF8);\n }\n b = (b & 0x0f) << 18 | (n1 & 0x3f) << 12 | (n2 & 0x3f) << 6 | (n3 & 0x3f);\n min = 0x10000;\n } else {\n throw new Error(INVALID_UTF8);\n }\n\n if (b < min || (b >= 0xd800 && b <= 0xdfff)) {\n throw new Error(INVALID_UTF8);\n }\n\n if (b >= 0x10000) {\n // Surrogate pair.\n if (b > 0x10ffff) {\n throw new Error(INVALID_UTF8);\n }\n b -= 0x10000;\n chars.push(String.fromCharCode(0xd800 | (b >> 10)));\n b = 0xdc00 | (b & 0x3ff);\n }\n }\n\n chars.push(String.fromCharCode(b));\n }\n return chars.join(\"\");\n}\n","(function(nacl) {\n'use strict';\n\n// Ported in 2014 by Dmitry Chestnykh and Devi Mandiri.\n// Public domain.\n//\n// Implementation derived from TweetNaCl version 20140427.\n// See for details: http://tweetnacl.cr.yp.to/\n\nvar gf = function(init) {\n var i, r = new Float64Array(16);\n if (init) for (i = 0; i < init.length; i++) r[i] = init[i];\n return r;\n};\n\n// Pluggable, initialized in high-level API below.\nvar randombytes = function(/* x, n */) { throw new Error('no PRNG'); };\n\nvar _0 = new Uint8Array(16);\nvar _9 = new Uint8Array(32); _9[0] = 9;\n\nvar gf0 = gf(),\n gf1 = gf([1]),\n _121665 = gf([0xdb41, 1]),\n D = gf([0x78a3, 0x1359, 0x4dca, 0x75eb, 0xd8ab, 0x4141, 0x0a4d, 0x0070, 0xe898, 0x7779, 0x4079, 0x8cc7, 0xfe73, 0x2b6f, 0x6cee, 0x5203]),\n D2 = gf([0xf159, 0x26b2, 0x9b94, 0xebd6, 0xb156, 0x8283, 0x149a, 0x00e0, 0xd130, 0xeef3, 0x80f2, 0x198e, 0xfce7, 0x56df, 0xd9dc, 0x2406]),\n X = gf([0xd51a, 0x8f25, 0x2d60, 0xc956, 0xa7b2, 0x9525, 0xc760, 0x692c, 0xdc5c, 0xfdd6, 0xe231, 0xc0a4, 0x53fe, 0xcd6e, 0x36d3, 0x2169]),\n Y = gf([0x6658, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666]),\n I = gf([0xa0b0, 0x4a0e, 0x1b27, 0xc4ee, 0xe478, 0xad2f, 0x1806, 0x2f43, 0xd7a7, 0x3dfb, 0x0099, 0x2b4d, 0xdf0b, 0x4fc1, 0x2480, 0x2b83]);\n\nfunction ts64(x, i, h, l) {\n x[i] = (h >> 24) & 0xff;\n x[i+1] = (h >> 16) & 0xff;\n x[i+2] = (h >> 8) & 0xff;\n x[i+3] = h & 0xff;\n x[i+4] = (l >> 24) & 0xff;\n x[i+5] = (l >> 16) & 0xff;\n x[i+6] = (l >> 8) & 0xff;\n x[i+7] = l & 0xff;\n}\n\nfunction vn(x, xi, y, yi, n) {\n var i,d = 0;\n for (i = 0; i < n; i++) d |= x[xi+i]^y[yi+i];\n return (1 & ((d - 1) >>> 8)) - 1;\n}\n\nfunction crypto_verify_16(x, xi, y, yi) {\n return vn(x,xi,y,yi,16);\n}\n\nfunction crypto_verify_32(x, xi, y, yi) {\n return vn(x,xi,y,yi,32);\n}\n\nfunction core_salsa20(o, p, k, c) {\n var j0 = c[ 0] & 0xff | (c[ 1] & 0xff)<<8 | (c[ 2] & 0xff)<<16 | (c[ 3] & 0xff)<<24,\n j1 = k[ 0] & 0xff | (k[ 1] & 0xff)<<8 | (k[ 2] & 0xff)<<16 | (k[ 3] & 0xff)<<24,\n j2 = k[ 4] & 0xff | (k[ 5] & 0xff)<<8 | (k[ 6] & 0xff)<<16 | (k[ 7] & 0xff)<<24,\n j3 = k[ 8] & 0xff | (k[ 9] & 0xff)<<8 | (k[10] & 0xff)<<16 | (k[11] & 0xff)<<24,\n j4 = k[12] & 0xff | (k[13] & 0xff)<<8 | (k[14] & 0xff)<<16 | (k[15] & 0xff)<<24,\n j5 = c[ 4] & 0xff | (c[ 5] & 0xff)<<8 | (c[ 6] & 0xff)<<16 | (c[ 7] & 0xff)<<24,\n j6 = p[ 0] & 0xff | (p[ 1] & 0xff)<<8 | (p[ 2] & 0xff)<<16 | (p[ 3] & 0xff)<<24,\n j7 = p[ 4] & 0xff | (p[ 5] & 0xff)<<8 | (p[ 6] & 0xff)<<16 | (p[ 7] & 0xff)<<24,\n j8 = p[ 8] & 0xff | (p[ 9] & 0xff)<<8 | (p[10] & 0xff)<<16 | (p[11] & 0xff)<<24,\n j9 = p[12] & 0xff | (p[13] & 0xff)<<8 | (p[14] & 0xff)<<16 | (p[15] & 0xff)<<24,\n j10 = c[ 8] & 0xff | (c[ 9] & 0xff)<<8 | (c[10] & 0xff)<<16 | (c[11] & 0xff)<<24,\n j11 = k[16] & 0xff | (k[17] & 0xff)<<8 | (k[18] & 0xff)<<16 | (k[19] & 0xff)<<24,\n j12 = k[20] & 0xff | (k[21] & 0xff)<<8 | (k[22] & 0xff)<<16 | (k[23] & 0xff)<<24,\n j13 = k[24] & 0xff | (k[25] & 0xff)<<8 | (k[26] & 0xff)<<16 | (k[27] & 0xff)<<24,\n j14 = k[28] & 0xff | (k[29] & 0xff)<<8 | (k[30] & 0xff)<<16 | (k[31] & 0xff)<<24,\n j15 = c[12] & 0xff | (c[13] & 0xff)<<8 | (c[14] & 0xff)<<16 | (c[15] & 0xff)<<24;\n\n var x0 = j0, x1 = j1, x2 = j2, x3 = j3, x4 = j4, x5 = j5, x6 = j6, x7 = j7,\n x8 = j8, x9 = j9, x10 = j10, x11 = j11, x12 = j12, x13 = j13, x14 = j14,\n x15 = j15, u;\n\n for (var i = 0; i < 20; i += 2) {\n u = x0 + x12 | 0;\n x4 ^= u<<7 | u>>>(32-7);\n u = x4 + x0 | 0;\n x8 ^= u<<9 | u>>>(32-9);\n u = x8 + x4 | 0;\n x12 ^= u<<13 | u>>>(32-13);\n u = x12 + x8 | 0;\n x0 ^= u<<18 | u>>>(32-18);\n\n u = x5 + x1 | 0;\n x9 ^= u<<7 | u>>>(32-7);\n u = x9 + x5 | 0;\n x13 ^= u<<9 | u>>>(32-9);\n u = x13 + x9 | 0;\n x1 ^= u<<13 | u>>>(32-13);\n u = x1 + x13 | 0;\n x5 ^= u<<18 | u>>>(32-18);\n\n u = x10 + x6 | 0;\n x14 ^= u<<7 | u>>>(32-7);\n u = x14 + x10 | 0;\n x2 ^= u<<9 | u>>>(32-9);\n u = x2 + x14 | 0;\n x6 ^= u<<13 | u>>>(32-13);\n u = x6 + x2 | 0;\n x10 ^= u<<18 | u>>>(32-18);\n\n u = x15 + x11 | 0;\n x3 ^= u<<7 | u>>>(32-7);\n u = x3 + x15 | 0;\n x7 ^= u<<9 | u>>>(32-9);\n u = x7 + x3 | 0;\n x11 ^= u<<13 | u>>>(32-13);\n u = x11 + x7 | 0;\n x15 ^= u<<18 | u>>>(32-18);\n\n u = x0 + x3 | 0;\n x1 ^= u<<7 | u>>>(32-7);\n u = x1 + x0 | 0;\n x2 ^= u<<9 | u>>>(32-9);\n u = x2 + x1 | 0;\n x3 ^= u<<13 | u>>>(32-13);\n u = x3 + x2 | 0;\n x0 ^= u<<18 | u>>>(32-18);\n\n u = x5 + x4 | 0;\n x6 ^= u<<7 | u>>>(32-7);\n u = x6 + x5 | 0;\n x7 ^= u<<9 | u>>>(32-9);\n u = x7 + x6 | 0;\n x4 ^= u<<13 | u>>>(32-13);\n u = x4 + x7 | 0;\n x5 ^= u<<18 | u>>>(32-18);\n\n u = x10 + x9 | 0;\n x11 ^= u<<7 | u>>>(32-7);\n u = x11 + x10 | 0;\n x8 ^= u<<9 | u>>>(32-9);\n u = x8 + x11 | 0;\n x9 ^= u<<13 | u>>>(32-13);\n u = x9 + x8 | 0;\n x10 ^= u<<18 | u>>>(32-18);\n\n u = x15 + x14 | 0;\n x12 ^= u<<7 | u>>>(32-7);\n u = x12 + x15 | 0;\n x13 ^= u<<9 | u>>>(32-9);\n u = x13 + x12 | 0;\n x14 ^= u<<13 | u>>>(32-13);\n u = x14 + x13 | 0;\n x15 ^= u<<18 | u>>>(32-18);\n }\n x0 = x0 + j0 | 0;\n x1 = x1 + j1 | 0;\n x2 = x2 + j2 | 0;\n x3 = x3 + j3 | 0;\n x4 = x4 + j4 | 0;\n x5 = x5 + j5 | 0;\n x6 = x6 + j6 | 0;\n x7 = x7 + j7 | 0;\n x8 = x8 + j8 | 0;\n x9 = x9 + j9 | 0;\n x10 = x10 + j10 | 0;\n x11 = x11 + j11 | 0;\n x12 = x12 + j12 | 0;\n x13 = x13 + j13 | 0;\n x14 = x14 + j14 | 0;\n x15 = x15 + j15 | 0;\n\n o[ 0] = x0 >>> 0 & 0xff;\n o[ 1] = x0 >>> 8 & 0xff;\n o[ 2] = x0 >>> 16 & 0xff;\n o[ 3] = x0 >>> 24 & 0xff;\n\n o[ 4] = x1 >>> 0 & 0xff;\n o[ 5] = x1 >>> 8 & 0xff;\n o[ 6] = x1 >>> 16 & 0xff;\n o[ 7] = x1 >>> 24 & 0xff;\n\n o[ 8] = x2 >>> 0 & 0xff;\n o[ 9] = x2 >>> 8 & 0xff;\n o[10] = x2 >>> 16 & 0xff;\n o[11] = x2 >>> 24 & 0xff;\n\n o[12] = x3 >>> 0 & 0xff;\n o[13] = x3 >>> 8 & 0xff;\n o[14] = x3 >>> 16 & 0xff;\n o[15] = x3 >>> 24 & 0xff;\n\n o[16] = x4 >>> 0 & 0xff;\n o[17] = x4 >>> 8 & 0xff;\n o[18] = x4 >>> 16 & 0xff;\n o[19] = x4 >>> 24 & 0xff;\n\n o[20] = x5 >>> 0 & 0xff;\n o[21] = x5 >>> 8 & 0xff;\n o[22] = x5 >>> 16 & 0xff;\n o[23] = x5 >>> 24 & 0xff;\n\n o[24] = x6 >>> 0 & 0xff;\n o[25] = x6 >>> 8 & 0xff;\n o[26] = x6 >>> 16 & 0xff;\n o[27] = x6 >>> 24 & 0xff;\n\n o[28] = x7 >>> 0 & 0xff;\n o[29] = x7 >>> 8 & 0xff;\n o[30] = x7 >>> 16 & 0xff;\n o[31] = x7 >>> 24 & 0xff;\n\n o[32] = x8 >>> 0 & 0xff;\n o[33] = x8 >>> 8 & 0xff;\n o[34] = x8 >>> 16 & 0xff;\n o[35] = x8 >>> 24 & 0xff;\n\n o[36] = x9 >>> 0 & 0xff;\n o[37] = x9 >>> 8 & 0xff;\n o[38] = x9 >>> 16 & 0xff;\n o[39] = x9 >>> 24 & 0xff;\n\n o[40] = x10 >>> 0 & 0xff;\n o[41] = x10 >>> 8 & 0xff;\n o[42] = x10 >>> 16 & 0xff;\n o[43] = x10 >>> 24 & 0xff;\n\n o[44] = x11 >>> 0 & 0xff;\n o[45] = x11 >>> 8 & 0xff;\n o[46] = x11 >>> 16 & 0xff;\n o[47] = x11 >>> 24 & 0xff;\n\n o[48] = x12 >>> 0 & 0xff;\n o[49] = x12 >>> 8 & 0xff;\n o[50] = x12 >>> 16 & 0xff;\n o[51] = x12 >>> 24 & 0xff;\n\n o[52] = x13 >>> 0 & 0xff;\n o[53] = x13 >>> 8 & 0xff;\n o[54] = x13 >>> 16 & 0xff;\n o[55] = x13 >>> 24 & 0xff;\n\n o[56] = x14 >>> 0 & 0xff;\n o[57] = x14 >>> 8 & 0xff;\n o[58] = x14 >>> 16 & 0xff;\n o[59] = x14 >>> 24 & 0xff;\n\n o[60] = x15 >>> 0 & 0xff;\n o[61] = x15 >>> 8 & 0xff;\n o[62] = x15 >>> 16 & 0xff;\n o[63] = x15 >>> 24 & 0xff;\n}\n\nfunction core_hsalsa20(o,p,k,c) {\n var j0 = c[ 0] & 0xff | (c[ 1] & 0xff)<<8 | (c[ 2] & 0xff)<<16 | (c[ 3] & 0xff)<<24,\n j1 = k[ 0] & 0xff | (k[ 1] & 0xff)<<8 | (k[ 2] & 0xff)<<16 | (k[ 3] & 0xff)<<24,\n j2 = k[ 4] & 0xff | (k[ 5] & 0xff)<<8 | (k[ 6] & 0xff)<<16 | (k[ 7] & 0xff)<<24,\n j3 = k[ 8] & 0xff | (k[ 9] & 0xff)<<8 | (k[10] & 0xff)<<16 | (k[11] & 0xff)<<24,\n j4 = k[12] & 0xff | (k[13] & 0xff)<<8 | (k[14] & 0xff)<<16 | (k[15] & 0xff)<<24,\n j5 = c[ 4] & 0xff | (c[ 5] & 0xff)<<8 | (c[ 6] & 0xff)<<16 | (c[ 7] & 0xff)<<24,\n j6 = p[ 0] & 0xff | (p[ 1] & 0xff)<<8 | (p[ 2] & 0xff)<<16 | (p[ 3] & 0xff)<<24,\n j7 = p[ 4] & 0xff | (p[ 5] & 0xff)<<8 | (p[ 6] & 0xff)<<16 | (p[ 7] & 0xff)<<24,\n j8 = p[ 8] & 0xff | (p[ 9] & 0xff)<<8 | (p[10] & 0xff)<<16 | (p[11] & 0xff)<<24,\n j9 = p[12] & 0xff | (p[13] & 0xff)<<8 | (p[14] & 0xff)<<16 | (p[15] & 0xff)<<24,\n j10 = c[ 8] & 0xff | (c[ 9] & 0xff)<<8 | (c[10] & 0xff)<<16 | (c[11] & 0xff)<<24,\n j11 = k[16] & 0xff | (k[17] & 0xff)<<8 | (k[18] & 0xff)<<16 | (k[19] & 0xff)<<24,\n j12 = k[20] & 0xff | (k[21] & 0xff)<<8 | (k[22] & 0xff)<<16 | (k[23] & 0xff)<<24,\n j13 = k[24] & 0xff | (k[25] & 0xff)<<8 | (k[26] & 0xff)<<16 | (k[27] & 0xff)<<24,\n j14 = k[28] & 0xff | (k[29] & 0xff)<<8 | (k[30] & 0xff)<<16 | (k[31] & 0xff)<<24,\n j15 = c[12] & 0xff | (c[13] & 0xff)<<8 | (c[14] & 0xff)<<16 | (c[15] & 0xff)<<24;\n\n var x0 = j0, x1 = j1, x2 = j2, x3 = j3, x4 = j4, x5 = j5, x6 = j6, x7 = j7,\n x8 = j8, x9 = j9, x10 = j10, x11 = j11, x12 = j12, x13 = j13, x14 = j14,\n x15 = j15, u;\n\n for (var i = 0; i < 20; i += 2) {\n u = x0 + x12 | 0;\n x4 ^= u<<7 | u>>>(32-7);\n u = x4 + x0 | 0;\n x8 ^= u<<9 | u>>>(32-9);\n u = x8 + x4 | 0;\n x12 ^= u<<13 | u>>>(32-13);\n u = x12 + x8 | 0;\n x0 ^= u<<18 | u>>>(32-18);\n\n u = x5 + x1 | 0;\n x9 ^= u<<7 | u>>>(32-7);\n u = x9 + x5 | 0;\n x13 ^= u<<9 | u>>>(32-9);\n u = x13 + x9 | 0;\n x1 ^= u<<13 | u>>>(32-13);\n u = x1 + x13 | 0;\n x5 ^= u<<18 | u>>>(32-18);\n\n u = x10 + x6 | 0;\n x14 ^= u<<7 | u>>>(32-7);\n u = x14 + x10 | 0;\n x2 ^= u<<9 | u>>>(32-9);\n u = x2 + x14 | 0;\n x6 ^= u<<13 | u>>>(32-13);\n u = x6 + x2 | 0;\n x10 ^= u<<18 | u>>>(32-18);\n\n u = x15 + x11 | 0;\n x3 ^= u<<7 | u>>>(32-7);\n u = x3 + x15 | 0;\n x7 ^= u<<9 | u>>>(32-9);\n u = x7 + x3 | 0;\n x11 ^= u<<13 | u>>>(32-13);\n u = x11 + x7 | 0;\n x15 ^= u<<18 | u>>>(32-18);\n\n u = x0 + x3 | 0;\n x1 ^= u<<7 | u>>>(32-7);\n u = x1 + x0 | 0;\n x2 ^= u<<9 | u>>>(32-9);\n u = x2 + x1 | 0;\n x3 ^= u<<13 | u>>>(32-13);\n u = x3 + x2 | 0;\n x0 ^= u<<18 | u>>>(32-18);\n\n u = x5 + x4 | 0;\n x6 ^= u<<7 | u>>>(32-7);\n u = x6 + x5 | 0;\n x7 ^= u<<9 | u>>>(32-9);\n u = x7 + x6 | 0;\n x4 ^= u<<13 | u>>>(32-13);\n u = x4 + x7 | 0;\n x5 ^= u<<18 | u>>>(32-18);\n\n u = x10 + x9 | 0;\n x11 ^= u<<7 | u>>>(32-7);\n u = x11 + x10 | 0;\n x8 ^= u<<9 | u>>>(32-9);\n u = x8 + x11 | 0;\n x9 ^= u<<13 | u>>>(32-13);\n u = x9 + x8 | 0;\n x10 ^= u<<18 | u>>>(32-18);\n\n u = x15 + x14 | 0;\n x12 ^= u<<7 | u>>>(32-7);\n u = x12 + x15 | 0;\n x13 ^= u<<9 | u>>>(32-9);\n u = x13 + x12 | 0;\n x14 ^= u<<13 | u>>>(32-13);\n u = x14 + x13 | 0;\n x15 ^= u<<18 | u>>>(32-18);\n }\n\n o[ 0] = x0 >>> 0 & 0xff;\n o[ 1] = x0 >>> 8 & 0xff;\n o[ 2] = x0 >>> 16 & 0xff;\n o[ 3] = x0 >>> 24 & 0xff;\n\n o[ 4] = x5 >>> 0 & 0xff;\n o[ 5] = x5 >>> 8 & 0xff;\n o[ 6] = x5 >>> 16 & 0xff;\n o[ 7] = x5 >>> 24 & 0xff;\n\n o[ 8] = x10 >>> 0 & 0xff;\n o[ 9] = x10 >>> 8 & 0xff;\n o[10] = x10 >>> 16 & 0xff;\n o[11] = x10 >>> 24 & 0xff;\n\n o[12] = x15 >>> 0 & 0xff;\n o[13] = x15 >>> 8 & 0xff;\n o[14] = x15 >>> 16 & 0xff;\n o[15] = x15 >>> 24 & 0xff;\n\n o[16] = x6 >>> 0 & 0xff;\n o[17] = x6 >>> 8 & 0xff;\n o[18] = x6 >>> 16 & 0xff;\n o[19] = x6 >>> 24 & 0xff;\n\n o[20] = x7 >>> 0 & 0xff;\n o[21] = x7 >>> 8 & 0xff;\n o[22] = x7 >>> 16 & 0xff;\n o[23] = x7 >>> 24 & 0xff;\n\n o[24] = x8 >>> 0 & 0xff;\n o[25] = x8 >>> 8 & 0xff;\n o[26] = x8 >>> 16 & 0xff;\n o[27] = x8 >>> 24 & 0xff;\n\n o[28] = x9 >>> 0 & 0xff;\n o[29] = x9 >>> 8 & 0xff;\n o[30] = x9 >>> 16 & 0xff;\n o[31] = x9 >>> 24 & 0xff;\n}\n\nfunction crypto_core_salsa20(out,inp,k,c) {\n core_salsa20(out,inp,k,c);\n}\n\nfunction crypto_core_hsalsa20(out,inp,k,c) {\n core_hsalsa20(out,inp,k,c);\n}\n\nvar sigma = new Uint8Array([101, 120, 112, 97, 110, 100, 32, 51, 50, 45, 98, 121, 116, 101, 32, 107]);\n // \"expand 32-byte k\"\n\nfunction crypto_stream_salsa20_xor(c,cpos,m,mpos,b,n,k) {\n var z = new Uint8Array(16), x = new Uint8Array(64);\n var u, i;\n for (i = 0; i < 16; i++) z[i] = 0;\n for (i = 0; i < 8; i++) z[i] = n[i];\n while (b >= 64) {\n crypto_core_salsa20(x,z,k,sigma);\n for (i = 0; i < 64; i++) c[cpos+i] = m[mpos+i] ^ x[i];\n u = 1;\n for (i = 8; i < 16; i++) {\n u = u + (z[i] & 0xff) | 0;\n z[i] = u & 0xff;\n u >>>= 8;\n }\n b -= 64;\n cpos += 64;\n mpos += 64;\n }\n if (b > 0) {\n crypto_core_salsa20(x,z,k,sigma);\n for (i = 0; i < b; i++) c[cpos+i] = m[mpos+i] ^ x[i];\n }\n return 0;\n}\n\nfunction crypto_stream_salsa20(c,cpos,b,n,k) {\n var z = new Uint8Array(16), x = new Uint8Array(64);\n var u, i;\n for (i = 0; i < 16; i++) z[i] = 0;\n for (i = 0; i < 8; i++) z[i] = n[i];\n while (b >= 64) {\n crypto_core_salsa20(x,z,k,sigma);\n for (i = 0; i < 64; i++) c[cpos+i] = x[i];\n u = 1;\n for (i = 8; i < 16; i++) {\n u = u + (z[i] & 0xff) | 0;\n z[i] = u & 0xff;\n u >>>= 8;\n }\n b -= 64;\n cpos += 64;\n }\n if (b > 0) {\n crypto_core_salsa20(x,z,k,sigma);\n for (i = 0; i < b; i++) c[cpos+i] = x[i];\n }\n return 0;\n}\n\nfunction crypto_stream(c,cpos,d,n,k) {\n var s = new Uint8Array(32);\n crypto_core_hsalsa20(s,n,k,sigma);\n var sn = new Uint8Array(8);\n for (var i = 0; i < 8; i++) sn[i] = n[i+16];\n return crypto_stream_salsa20(c,cpos,d,sn,s);\n}\n\nfunction crypto_stream_xor(c,cpos,m,mpos,d,n,k) {\n var s = new Uint8Array(32);\n crypto_core_hsalsa20(s,n,k,sigma);\n var sn = new Uint8Array(8);\n for (var i = 0; i < 8; i++) sn[i] = n[i+16];\n return crypto_stream_salsa20_xor(c,cpos,m,mpos,d,sn,s);\n}\n\n/*\n* Port of Andrew Moon's Poly1305-donna-16. Public domain.\n* https://github.com/floodyberry/poly1305-donna\n*/\n\nvar poly1305 = function(key) {\n this.buffer = new Uint8Array(16);\n this.r = new Uint16Array(10);\n this.h = new Uint16Array(10);\n this.pad = new Uint16Array(8);\n this.leftover = 0;\n this.fin = 0;\n\n var t0, t1, t2, t3, t4, t5, t6, t7;\n\n t0 = key[ 0] & 0xff | (key[ 1] & 0xff) << 8; this.r[0] = ( t0 ) & 0x1fff;\n t1 = key[ 2] & 0xff | (key[ 3] & 0xff) << 8; this.r[1] = ((t0 >>> 13) | (t1 << 3)) & 0x1fff;\n t2 = key[ 4] & 0xff | (key[ 5] & 0xff) << 8; this.r[2] = ((t1 >>> 10) | (t2 << 6)) & 0x1f03;\n t3 = key[ 6] & 0xff | (key[ 7] & 0xff) << 8; this.r[3] = ((t2 >>> 7) | (t3 << 9)) & 0x1fff;\n t4 = key[ 8] & 0xff | (key[ 9] & 0xff) << 8; this.r[4] = ((t3 >>> 4) | (t4 << 12)) & 0x00ff;\n this.r[5] = ((t4 >>> 1)) & 0x1ffe;\n t5 = key[10] & 0xff | (key[11] & 0xff) << 8; this.r[6] = ((t4 >>> 14) | (t5 << 2)) & 0x1fff;\n t6 = key[12] & 0xff | (key[13] & 0xff) << 8; this.r[7] = ((t5 >>> 11) | (t6 << 5)) & 0x1f81;\n t7 = key[14] & 0xff | (key[15] & 0xff) << 8; this.r[8] = ((t6 >>> 8) | (t7 << 8)) & 0x1fff;\n this.r[9] = ((t7 >>> 5)) & 0x007f;\n\n this.pad[0] = key[16] & 0xff | (key[17] & 0xff) << 8;\n this.pad[1] = key[18] & 0xff | (key[19] & 0xff) << 8;\n this.pad[2] = key[20] & 0xff | (key[21] & 0xff) << 8;\n this.pad[3] = key[22] & 0xff | (key[23] & 0xff) << 8;\n this.pad[4] = key[24] & 0xff | (key[25] & 0xff) << 8;\n this.pad[5] = key[26] & 0xff | (key[27] & 0xff) << 8;\n this.pad[6] = key[28] & 0xff | (key[29] & 0xff) << 8;\n this.pad[7] = key[30] & 0xff | (key[31] & 0xff) << 8;\n};\n\npoly1305.prototype.blocks = function(m, mpos, bytes) {\n var hibit = this.fin ? 0 : (1 << 11);\n var t0, t1, t2, t3, t4, t5, t6, t7, c;\n var d0, d1, d2, d3, d4, d5, d6, d7, d8, d9;\n\n var h0 = this.h[0],\n h1 = this.h[1],\n h2 = this.h[2],\n h3 = this.h[3],\n h4 = this.h[4],\n h5 = this.h[5],\n h6 = this.h[6],\n h7 = this.h[7],\n h8 = this.h[8],\n h9 = this.h[9];\n\n var r0 = this.r[0],\n r1 = this.r[1],\n r2 = this.r[2],\n r3 = this.r[3],\n r4 = this.r[4],\n r5 = this.r[5],\n r6 = this.r[6],\n r7 = this.r[7],\n r8 = this.r[8],\n r9 = this.r[9];\n\n while (bytes >= 16) {\n t0 = m[mpos+ 0] & 0xff | (m[mpos+ 1] & 0xff) << 8; h0 += ( t0 ) & 0x1fff;\n t1 = m[mpos+ 2] & 0xff | (m[mpos+ 3] & 0xff) << 8; h1 += ((t0 >>> 13) | (t1 << 3)) & 0x1fff;\n t2 = m[mpos+ 4] & 0xff | (m[mpos+ 5] & 0xff) << 8; h2 += ((t1 >>> 10) | (t2 << 6)) & 0x1fff;\n t3 = m[mpos+ 6] & 0xff | (m[mpos+ 7] & 0xff) << 8; h3 += ((t2 >>> 7) | (t3 << 9)) & 0x1fff;\n t4 = m[mpos+ 8] & 0xff | (m[mpos+ 9] & 0xff) << 8; h4 += ((t3 >>> 4) | (t4 << 12)) & 0x1fff;\n h5 += ((t4 >>> 1)) & 0x1fff;\n t5 = m[mpos+10] & 0xff | (m[mpos+11] & 0xff) << 8; h6 += ((t4 >>> 14) | (t5 << 2)) & 0x1fff;\n t6 = m[mpos+12] & 0xff | (m[mpos+13] & 0xff) << 8; h7 += ((t5 >>> 11) | (t6 << 5)) & 0x1fff;\n t7 = m[mpos+14] & 0xff | (m[mpos+15] & 0xff) << 8; h8 += ((t6 >>> 8) | (t7 << 8)) & 0x1fff;\n h9 += ((t7 >>> 5)) | hibit;\n\n c = 0;\n\n d0 = c;\n d0 += h0 * r0;\n d0 += h1 * (5 * r9);\n d0 += h2 * (5 * r8);\n d0 += h3 * (5 * r7);\n d0 += h4 * (5 * r6);\n c = (d0 >>> 13); d0 &= 0x1fff;\n d0 += h5 * (5 * r5);\n d0 += h6 * (5 * r4);\n d0 += h7 * (5 * r3);\n d0 += h8 * (5 * r2);\n d0 += h9 * (5 * r1);\n c += (d0 >>> 13); d0 &= 0x1fff;\n\n d1 = c;\n d1 += h0 * r1;\n d1 += h1 * r0;\n d1 += h2 * (5 * r9);\n d1 += h3 * (5 * r8);\n d1 += h4 * (5 * r7);\n c = (d1 >>> 13); d1 &= 0x1fff;\n d1 += h5 * (5 * r6);\n d1 += h6 * (5 * r5);\n d1 += h7 * (5 * r4);\n d1 += h8 * (5 * r3);\n d1 += h9 * (5 * r2);\n c += (d1 >>> 13); d1 &= 0x1fff;\n\n d2 = c;\n d2 += h0 * r2;\n d2 += h1 * r1;\n d2 += h2 * r0;\n d2 += h3 * (5 * r9);\n d2 += h4 * (5 * r8);\n c = (d2 >>> 13); d2 &= 0x1fff;\n d2 += h5 * (5 * r7);\n d2 += h6 * (5 * r6);\n d2 += h7 * (5 * r5);\n d2 += h8 * (5 * r4);\n d2 += h9 * (5 * r3);\n c += (d2 >>> 13); d2 &= 0x1fff;\n\n d3 = c;\n d3 += h0 * r3;\n d3 += h1 * r2;\n d3 += h2 * r1;\n d3 += h3 * r0;\n d3 += h4 * (5 * r9);\n c = (d3 >>> 13); d3 &= 0x1fff;\n d3 += h5 * (5 * r8);\n d3 += h6 * (5 * r7);\n d3 += h7 * (5 * r6);\n d3 += h8 * (5 * r5);\n d3 += h9 * (5 * r4);\n c += (d3 >>> 13); d3 &= 0x1fff;\n\n d4 = c;\n d4 += h0 * r4;\n d4 += h1 * r3;\n d4 += h2 * r2;\n d4 += h3 * r1;\n d4 += h4 * r0;\n c = (d4 >>> 13); d4 &= 0x1fff;\n d4 += h5 * (5 * r9);\n d4 += h6 * (5 * r8);\n d4 += h7 * (5 * r7);\n d4 += h8 * (5 * r6);\n d4 += h9 * (5 * r5);\n c += (d4 >>> 13); d4 &= 0x1fff;\n\n d5 = c;\n d5 += h0 * r5;\n d5 += h1 * r4;\n d5 += h2 * r3;\n d5 += h3 * r2;\n d5 += h4 * r1;\n c = (d5 >>> 13); d5 &= 0x1fff;\n d5 += h5 * r0;\n d5 += h6 * (5 * r9);\n d5 += h7 * (5 * r8);\n d5 += h8 * (5 * r7);\n d5 += h9 * (5 * r6);\n c += (d5 >>> 13); d5 &= 0x1fff;\n\n d6 = c;\n d6 += h0 * r6;\n d6 += h1 * r5;\n d6 += h2 * r4;\n d6 += h3 * r3;\n d6 += h4 * r2;\n c = (d6 >>> 13); d6 &= 0x1fff;\n d6 += h5 * r1;\n d6 += h6 * r0;\n d6 += h7 * (5 * r9);\n d6 += h8 * (5 * r8);\n d6 += h9 * (5 * r7);\n c += (d6 >>> 13); d6 &= 0x1fff;\n\n d7 = c;\n d7 += h0 * r7;\n d7 += h1 * r6;\n d7 += h2 * r5;\n d7 += h3 * r4;\n d7 += h4 * r3;\n c = (d7 >>> 13); d7 &= 0x1fff;\n d7 += h5 * r2;\n d7 += h6 * r1;\n d7 += h7 * r0;\n d7 += h8 * (5 * r9);\n d7 += h9 * (5 * r8);\n c += (d7 >>> 13); d7 &= 0x1fff;\n\n d8 = c;\n d8 += h0 * r8;\n d8 += h1 * r7;\n d8 += h2 * r6;\n d8 += h3 * r5;\n d8 += h4 * r4;\n c = (d8 >>> 13); d8 &= 0x1fff;\n d8 += h5 * r3;\n d8 += h6 * r2;\n d8 += h7 * r1;\n d8 += h8 * r0;\n d8 += h9 * (5 * r9);\n c += (d8 >>> 13); d8 &= 0x1fff;\n\n d9 = c;\n d9 += h0 * r9;\n d9 += h1 * r8;\n d9 += h2 * r7;\n d9 += h3 * r6;\n d9 += h4 * r5;\n c = (d9 >>> 13); d9 &= 0x1fff;\n d9 += h5 * r4;\n d9 += h6 * r3;\n d9 += h7 * r2;\n d9 += h8 * r1;\n d9 += h9 * r0;\n c += (d9 >>> 13); d9 &= 0x1fff;\n\n c = (((c << 2) + c)) | 0;\n c = (c + d0) | 0;\n d0 = c & 0x1fff;\n c = (c >>> 13);\n d1 += c;\n\n h0 = d0;\n h1 = d1;\n h2 = d2;\n h3 = d3;\n h4 = d4;\n h5 = d5;\n h6 = d6;\n h7 = d7;\n h8 = d8;\n h9 = d9;\n\n mpos += 16;\n bytes -= 16;\n }\n this.h[0] = h0;\n this.h[1] = h1;\n this.h[2] = h2;\n this.h[3] = h3;\n this.h[4] = h4;\n this.h[5] = h5;\n this.h[6] = h6;\n this.h[7] = h7;\n this.h[8] = h8;\n this.h[9] = h9;\n};\n\npoly1305.prototype.finish = function(mac, macpos) {\n var g = new Uint16Array(10);\n var c, mask, f, i;\n\n if (this.leftover) {\n i = this.leftover;\n this.buffer[i++] = 1;\n for (; i < 16; i++) this.buffer[i] = 0;\n this.fin = 1;\n this.blocks(this.buffer, 0, 16);\n }\n\n c = this.h[1] >>> 13;\n this.h[1] &= 0x1fff;\n for (i = 2; i < 10; i++) {\n this.h[i] += c;\n c = this.h[i] >>> 13;\n this.h[i] &= 0x1fff;\n }\n this.h[0] += (c * 5);\n c = this.h[0] >>> 13;\n this.h[0] &= 0x1fff;\n this.h[1] += c;\n c = this.h[1] >>> 13;\n this.h[1] &= 0x1fff;\n this.h[2] += c;\n\n g[0] = this.h[0] + 5;\n c = g[0] >>> 13;\n g[0] &= 0x1fff;\n for (i = 1; i < 10; i++) {\n g[i] = this.h[i] + c;\n c = g[i] >>> 13;\n g[i] &= 0x1fff;\n }\n g[9] -= (1 << 13);\n\n mask = (c ^ 1) - 1;\n for (i = 0; i < 10; i++) g[i] &= mask;\n mask = ~mask;\n for (i = 0; i < 10; i++) this.h[i] = (this.h[i] & mask) | g[i];\n\n this.h[0] = ((this.h[0] ) | (this.h[1] << 13) ) & 0xffff;\n this.h[1] = ((this.h[1] >>> 3) | (this.h[2] << 10) ) & 0xffff;\n this.h[2] = ((this.h[2] >>> 6) | (this.h[3] << 7) ) & 0xffff;\n this.h[3] = ((this.h[3] >>> 9) | (this.h[4] << 4) ) & 0xffff;\n this.h[4] = ((this.h[4] >>> 12) | (this.h[5] << 1) | (this.h[6] << 14)) & 0xffff;\n this.h[5] = ((this.h[6] >>> 2) | (this.h[7] << 11) ) & 0xffff;\n this.h[6] = ((this.h[7] >>> 5) | (this.h[8] << 8) ) & 0xffff;\n this.h[7] = ((this.h[8] >>> 8) | (this.h[9] << 5) ) & 0xffff;\n\n f = this.h[0] + this.pad[0];\n this.h[0] = f & 0xffff;\n for (i = 1; i < 8; i++) {\n f = (((this.h[i] + this.pad[i]) | 0) + (f >>> 16)) | 0;\n this.h[i] = f & 0xffff;\n }\n\n mac[macpos+ 0] = (this.h[0] >>> 0) & 0xff;\n mac[macpos+ 1] = (this.h[0] >>> 8) & 0xff;\n mac[macpos+ 2] = (this.h[1] >>> 0) & 0xff;\n mac[macpos+ 3] = (this.h[1] >>> 8) & 0xff;\n mac[macpos+ 4] = (this.h[2] >>> 0) & 0xff;\n mac[macpos+ 5] = (this.h[2] >>> 8) & 0xff;\n mac[macpos+ 6] = (this.h[3] >>> 0) & 0xff;\n mac[macpos+ 7] = (this.h[3] >>> 8) & 0xff;\n mac[macpos+ 8] = (this.h[4] >>> 0) & 0xff;\n mac[macpos+ 9] = (this.h[4] >>> 8) & 0xff;\n mac[macpos+10] = (this.h[5] >>> 0) & 0xff;\n mac[macpos+11] = (this.h[5] >>> 8) & 0xff;\n mac[macpos+12] = (this.h[6] >>> 0) & 0xff;\n mac[macpos+13] = (this.h[6] >>> 8) & 0xff;\n mac[macpos+14] = (this.h[7] >>> 0) & 0xff;\n mac[macpos+15] = (this.h[7] >>> 8) & 0xff;\n};\n\npoly1305.prototype.update = function(m, mpos, bytes) {\n var i, want;\n\n if (this.leftover) {\n want = (16 - this.leftover);\n if (want > bytes)\n want = bytes;\n for (i = 0; i < want; i++)\n this.buffer[this.leftover + i] = m[mpos+i];\n bytes -= want;\n mpos += want;\n this.leftover += want;\n if (this.leftover < 16)\n return;\n this.blocks(this.buffer, 0, 16);\n this.leftover = 0;\n }\n\n if (bytes >= 16) {\n want = bytes - (bytes % 16);\n this.blocks(m, mpos, want);\n mpos += want;\n bytes -= want;\n }\n\n if (bytes) {\n for (i = 0; i < bytes; i++)\n this.buffer[this.leftover + i] = m[mpos+i];\n this.leftover += bytes;\n }\n};\n\nfunction crypto_onetimeauth(out, outpos, m, mpos, n, k) {\n var s = new poly1305(k);\n s.update(m, mpos, n);\n s.finish(out, outpos);\n return 0;\n}\n\nfunction crypto_onetimeauth_verify(h, hpos, m, mpos, n, k) {\n var x = new Uint8Array(16);\n crypto_onetimeauth(x,0,m,mpos,n,k);\n return crypto_verify_16(h,hpos,x,0);\n}\n\nfunction crypto_secretbox(c,m,d,n,k) {\n var i;\n if (d < 32) return -1;\n crypto_stream_xor(c,0,m,0,d,n,k);\n crypto_onetimeauth(c, 16, c, 32, d - 32, c);\n for (i = 0; i < 16; i++) c[i] = 0;\n return 0;\n}\n\nfunction crypto_secretbox_open(m,c,d,n,k) {\n var i;\n var x = new Uint8Array(32);\n if (d < 32) return -1;\n crypto_stream(x,0,32,n,k);\n if (crypto_onetimeauth_verify(c, 16,c, 32,d - 32,x) !== 0) return -1;\n crypto_stream_xor(m,0,c,0,d,n,k);\n for (i = 0; i < 32; i++) m[i] = 0;\n return 0;\n}\n\nfunction set25519(r, a) {\n var i;\n for (i = 0; i < 16; i++) r[i] = a[i]|0;\n}\n\nfunction car25519(o) {\n var i, v, c = 1;\n for (i = 0; i < 16; i++) {\n v = o[i] + c + 65535;\n c = Math.floor(v / 65536);\n o[i] = v - c * 65536;\n }\n o[0] += c-1 + 37 * (c-1);\n}\n\nfunction sel25519(p, q, b) {\n var t, c = ~(b-1);\n for (var i = 0; i < 16; i++) {\n t = c & (p[i] ^ q[i]);\n p[i] ^= t;\n q[i] ^= t;\n }\n}\n\nfunction pack25519(o, n) {\n var i, j, b;\n var m = gf(), t = gf();\n for (i = 0; i < 16; i++) t[i] = n[i];\n car25519(t);\n car25519(t);\n car25519(t);\n for (j = 0; j < 2; j++) {\n m[0] = t[0] - 0xffed;\n for (i = 1; i < 15; i++) {\n m[i] = t[i] - 0xffff - ((m[i-1]>>16) & 1);\n m[i-1] &= 0xffff;\n }\n m[15] = t[15] - 0x7fff - ((m[14]>>16) & 1);\n b = (m[15]>>16) & 1;\n m[14] &= 0xffff;\n sel25519(t, m, 1-b);\n }\n for (i = 0; i < 16; i++) {\n o[2*i] = t[i] & 0xff;\n o[2*i+1] = t[i]>>8;\n }\n}\n\nfunction neq25519(a, b) {\n var c = new Uint8Array(32), d = new Uint8Array(32);\n pack25519(c, a);\n pack25519(d, b);\n return crypto_verify_32(c, 0, d, 0);\n}\n\nfunction par25519(a) {\n var d = new Uint8Array(32);\n pack25519(d, a);\n return d[0] & 1;\n}\n\nfunction unpack25519(o, n) {\n var i;\n for (i = 0; i < 16; i++) o[i] = n[2*i] + (n[2*i+1] << 8);\n o[15] &= 0x7fff;\n}\n\nfunction A(o, a, b) {\n for (var i = 0; i < 16; i++) o[i] = a[i] + b[i];\n}\n\nfunction Z(o, a, b) {\n for (var i = 0; i < 16; i++) o[i] = a[i] - b[i];\n}\n\nfunction M(o, a, b) {\n var v, c,\n t0 = 0, t1 = 0, t2 = 0, t3 = 0, t4 = 0, t5 = 0, t6 = 0, t7 = 0,\n t8 = 0, t9 = 0, t10 = 0, t11 = 0, t12 = 0, t13 = 0, t14 = 0, t15 = 0,\n t16 = 0, t17 = 0, t18 = 0, t19 = 0, t20 = 0, t21 = 0, t22 = 0, t23 = 0,\n t24 = 0, t25 = 0, t26 = 0, t27 = 0, t28 = 0, t29 = 0, t30 = 0,\n b0 = b[0],\n b1 = b[1],\n b2 = b[2],\n b3 = b[3],\n b4 = b[4],\n b5 = b[5],\n b6 = b[6],\n b7 = b[7],\n b8 = b[8],\n b9 = b[9],\n b10 = b[10],\n b11 = b[11],\n b12 = b[12],\n b13 = b[13],\n b14 = b[14],\n b15 = b[15];\n\n v = a[0];\n t0 += v * b0;\n t1 += v * b1;\n t2 += v * b2;\n t3 += v * b3;\n t4 += v * b4;\n t5 += v * b5;\n t6 += v * b6;\n t7 += v * b7;\n t8 += v * b8;\n t9 += v * b9;\n t10 += v * b10;\n t11 += v * b11;\n t12 += v * b12;\n t13 += v * b13;\n t14 += v * b14;\n t15 += v * b15;\n v = a[1];\n t1 += v * b0;\n t2 += v * b1;\n t3 += v * b2;\n t4 += v * b3;\n t5 += v * b4;\n t6 += v * b5;\n t7 += v * b6;\n t8 += v * b7;\n t9 += v * b8;\n t10 += v * b9;\n t11 += v * b10;\n t12 += v * b11;\n t13 += v * b12;\n t14 += v * b13;\n t15 += v * b14;\n t16 += v * b15;\n v = a[2];\n t2 += v * b0;\n t3 += v * b1;\n t4 += v * b2;\n t5 += v * b3;\n t6 += v * b4;\n t7 += v * b5;\n t8 += v * b6;\n t9 += v * b7;\n t10 += v * b8;\n t11 += v * b9;\n t12 += v * b10;\n t13 += v * b11;\n t14 += v * b12;\n t15 += v * b13;\n t16 += v * b14;\n t17 += v * b15;\n v = a[3];\n t3 += v * b0;\n t4 += v * b1;\n t5 += v * b2;\n t6 += v * b3;\n t7 += v * b4;\n t8 += v * b5;\n t9 += v * b6;\n t10 += v * b7;\n t11 += v * b8;\n t12 += v * b9;\n t13 += v * b10;\n t14 += v * b11;\n t15 += v * b12;\n t16 += v * b13;\n t17 += v * b14;\n t18 += v * b15;\n v = a[4];\n t4 += v * b0;\n t5 += v * b1;\n t6 += v * b2;\n t7 += v * b3;\n t8 += v * b4;\n t9 += v * b5;\n t10 += v * b6;\n t11 += v * b7;\n t12 += v * b8;\n t13 += v * b9;\n t14 += v * b10;\n t15 += v * b11;\n t16 += v * b12;\n t17 += v * b13;\n t18 += v * b14;\n t19 += v * b15;\n v = a[5];\n t5 += v * b0;\n t6 += v * b1;\n t7 += v * b2;\n t8 += v * b3;\n t9 += v * b4;\n t10 += v * b5;\n t11 += v * b6;\n t12 += v * b7;\n t13 += v * b8;\n t14 += v * b9;\n t15 += v * b10;\n t16 += v * b11;\n t17 += v * b12;\n t18 += v * b13;\n t19 += v * b14;\n t20 += v * b15;\n v = a[6];\n t6 += v * b0;\n t7 += v * b1;\n t8 += v * b2;\n t9 += v * b3;\n t10 += v * b4;\n t11 += v * b5;\n t12 += v * b6;\n t13 += v * b7;\n t14 += v * b8;\n t15 += v * b9;\n t16 += v * b10;\n t17 += v * b11;\n t18 += v * b12;\n t19 += v * b13;\n t20 += v * b14;\n t21 += v * b15;\n v = a[7];\n t7 += v * b0;\n t8 += v * b1;\n t9 += v * b2;\n t10 += v * b3;\n t11 += v * b4;\n t12 += v * b5;\n t13 += v * b6;\n t14 += v * b7;\n t15 += v * b8;\n t16 += v * b9;\n t17 += v * b10;\n t18 += v * b11;\n t19 += v * b12;\n t20 += v * b13;\n t21 += v * b14;\n t22 += v * b15;\n v = a[8];\n t8 += v * b0;\n t9 += v * b1;\n t10 += v * b2;\n t11 += v * b3;\n t12 += v * b4;\n t13 += v * b5;\n t14 += v * b6;\n t15 += v * b7;\n t16 += v * b8;\n t17 += v * b9;\n t18 += v * b10;\n t19 += v * b11;\n t20 += v * b12;\n t21 += v * b13;\n t22 += v * b14;\n t23 += v * b15;\n v = a[9];\n t9 += v * b0;\n t10 += v * b1;\n t11 += v * b2;\n t12 += v * b3;\n t13 += v * b4;\n t14 += v * b5;\n t15 += v * b6;\n t16 += v * b7;\n t17 += v * b8;\n t18 += v * b9;\n t19 += v * b10;\n t20 += v * b11;\n t21 += v * b12;\n t22 += v * b13;\n t23 += v * b14;\n t24 += v * b15;\n v = a[10];\n t10 += v * b0;\n t11 += v * b1;\n t12 += v * b2;\n t13 += v * b3;\n t14 += v * b4;\n t15 += v * b5;\n t16 += v * b6;\n t17 += v * b7;\n t18 += v * b8;\n t19 += v * b9;\n t20 += v * b10;\n t21 += v * b11;\n t22 += v * b12;\n t23 += v * b13;\n t24 += v * b14;\n t25 += v * b15;\n v = a[11];\n t11 += v * b0;\n t12 += v * b1;\n t13 += v * b2;\n t14 += v * b3;\n t15 += v * b4;\n t16 += v * b5;\n t17 += v * b6;\n t18 += v * b7;\n t19 += v * b8;\n t20 += v * b9;\n t21 += v * b10;\n t22 += v * b11;\n t23 += v * b12;\n t24 += v * b13;\n t25 += v * b14;\n t26 += v * b15;\n v = a[12];\n t12 += v * b0;\n t13 += v * b1;\n t14 += v * b2;\n t15 += v * b3;\n t16 += v * b4;\n t17 += v * b5;\n t18 += v * b6;\n t19 += v * b7;\n t20 += v * b8;\n t21 += v * b9;\n t22 += v * b10;\n t23 += v * b11;\n t24 += v * b12;\n t25 += v * b13;\n t26 += v * b14;\n t27 += v * b15;\n v = a[13];\n t13 += v * b0;\n t14 += v * b1;\n t15 += v * b2;\n t16 += v * b3;\n t17 += v * b4;\n t18 += v * b5;\n t19 += v * b6;\n t20 += v * b7;\n t21 += v * b8;\n t22 += v * b9;\n t23 += v * b10;\n t24 += v * b11;\n t25 += v * b12;\n t26 += v * b13;\n t27 += v * b14;\n t28 += v * b15;\n v = a[14];\n t14 += v * b0;\n t15 += v * b1;\n t16 += v * b2;\n t17 += v * b3;\n t18 += v * b4;\n t19 += v * b5;\n t20 += v * b6;\n t21 += v * b7;\n t22 += v * b8;\n t23 += v * b9;\n t24 += v * b10;\n t25 += v * b11;\n t26 += v * b12;\n t27 += v * b13;\n t28 += v * b14;\n t29 += v * b15;\n v = a[15];\n t15 += v * b0;\n t16 += v * b1;\n t17 += v * b2;\n t18 += v * b3;\n t19 += v * b4;\n t20 += v * b5;\n t21 += v * b6;\n t22 += v * b7;\n t23 += v * b8;\n t24 += v * b9;\n t25 += v * b10;\n t26 += v * b11;\n t27 += v * b12;\n t28 += v * b13;\n t29 += v * b14;\n t30 += v * b15;\n\n t0 += 38 * t16;\n t1 += 38 * t17;\n t2 += 38 * t18;\n t3 += 38 * t19;\n t4 += 38 * t20;\n t5 += 38 * t21;\n t6 += 38 * t22;\n t7 += 38 * t23;\n t8 += 38 * t24;\n t9 += 38 * t25;\n t10 += 38 * t26;\n t11 += 38 * t27;\n t12 += 38 * t28;\n t13 += 38 * t29;\n t14 += 38 * t30;\n // t15 left as is\n\n // first car\n c = 1;\n v = t0 + c + 65535; c = Math.floor(v / 65536); t0 = v - c * 65536;\n v = t1 + c + 65535; c = Math.floor(v / 65536); t1 = v - c * 65536;\n v = t2 + c + 65535; c = Math.floor(v / 65536); t2 = v - c * 65536;\n v = t3 + c + 65535; c = Math.floor(v / 65536); t3 = v - c * 65536;\n v = t4 + c + 65535; c = Math.floor(v / 65536); t4 = v - c * 65536;\n v = t5 + c + 65535; c = Math.floor(v / 65536); t5 = v - c * 65536;\n v = t6 + c + 65535; c = Math.floor(v / 65536); t6 = v - c * 65536;\n v = t7 + c + 65535; c = Math.floor(v / 65536); t7 = v - c * 65536;\n v = t8 + c + 65535; c = Math.floor(v / 65536); t8 = v - c * 65536;\n v = t9 + c + 65535; c = Math.floor(v / 65536); t9 = v - c * 65536;\n v = t10 + c + 65535; c = Math.floor(v / 65536); t10 = v - c * 65536;\n v = t11 + c + 65535; c = Math.floor(v / 65536); t11 = v - c * 65536;\n v = t12 + c + 65535; c = Math.floor(v / 65536); t12 = v - c * 65536;\n v = t13 + c + 65535; c = Math.floor(v / 65536); t13 = v - c * 65536;\n v = t14 + c + 65535; c = Math.floor(v / 65536); t14 = v - c * 65536;\n v = t15 + c + 65535; c = Math.floor(v / 65536); t15 = v - c * 65536;\n t0 += c-1 + 37 * (c-1);\n\n // second car\n c = 1;\n v = t0 + c + 65535; c = Math.floor(v / 65536); t0 = v - c * 65536;\n v = t1 + c + 65535; c = Math.floor(v / 65536); t1 = v - c * 65536;\n v = t2 + c + 65535; c = Math.floor(v / 65536); t2 = v - c * 65536;\n v = t3 + c + 65535; c = Math.floor(v / 65536); t3 = v - c * 65536;\n v = t4 + c + 65535; c = Math.floor(v / 65536); t4 = v - c * 65536;\n v = t5 + c + 65535; c = Math.floor(v / 65536); t5 = v - c * 65536;\n v = t6 + c + 65535; c = Math.floor(v / 65536); t6 = v - c * 65536;\n v = t7 + c + 65535; c = Math.floor(v / 65536); t7 = v - c * 65536;\n v = t8 + c + 65535; c = Math.floor(v / 65536); t8 = v - c * 65536;\n v = t9 + c + 65535; c = Math.floor(v / 65536); t9 = v - c * 65536;\n v = t10 + c + 65535; c = Math.floor(v / 65536); t10 = v - c * 65536;\n v = t11 + c + 65535; c = Math.floor(v / 65536); t11 = v - c * 65536;\n v = t12 + c + 65535; c = Math.floor(v / 65536); t12 = v - c * 65536;\n v = t13 + c + 65535; c = Math.floor(v / 65536); t13 = v - c * 65536;\n v = t14 + c + 65535; c = Math.floor(v / 65536); t14 = v - c * 65536;\n v = t15 + c + 65535; c = Math.floor(v / 65536); t15 = v - c * 65536;\n t0 += c-1 + 37 * (c-1);\n\n o[ 0] = t0;\n o[ 1] = t1;\n o[ 2] = t2;\n o[ 3] = t3;\n o[ 4] = t4;\n o[ 5] = t5;\n o[ 6] = t6;\n o[ 7] = t7;\n o[ 8] = t8;\n o[ 9] = t9;\n o[10] = t10;\n o[11] = t11;\n o[12] = t12;\n o[13] = t13;\n o[14] = t14;\n o[15] = t15;\n}\n\nfunction S(o, a) {\n M(o, a, a);\n}\n\nfunction inv25519(o, i) {\n var c = gf();\n var a;\n for (a = 0; a < 16; a++) c[a] = i[a];\n for (a = 253; a >= 0; a--) {\n S(c, c);\n if(a !== 2 && a !== 4) M(c, c, i);\n }\n for (a = 0; a < 16; a++) o[a] = c[a];\n}\n\nfunction pow2523(o, i) {\n var c = gf();\n var a;\n for (a = 0; a < 16; a++) c[a] = i[a];\n for (a = 250; a >= 0; a--) {\n S(c, c);\n if(a !== 1) M(c, c, i);\n }\n for (a = 0; a < 16; a++) o[a] = c[a];\n}\n\nfunction crypto_scalarmult(q, n, p) {\n var z = new Uint8Array(32);\n var x = new Float64Array(80), r, i;\n var a = gf(), b = gf(), c = gf(),\n d = gf(), e = gf(), f = gf();\n for (i = 0; i < 31; i++) z[i] = n[i];\n z[31]=(n[31]&127)|64;\n z[0]&=248;\n unpack25519(x,p);\n for (i = 0; i < 16; i++) {\n b[i]=x[i];\n d[i]=a[i]=c[i]=0;\n }\n a[0]=d[0]=1;\n for (i=254; i>=0; --i) {\n r=(z[i>>>3]>>>(i&7))&1;\n sel25519(a,b,r);\n sel25519(c,d,r);\n A(e,a,c);\n Z(a,a,c);\n A(c,b,d);\n Z(b,b,d);\n S(d,e);\n S(f,a);\n M(a,c,a);\n M(c,b,e);\n A(e,a,c);\n Z(a,a,c);\n S(b,a);\n Z(c,d,f);\n M(a,c,_121665);\n A(a,a,d);\n M(c,c,a);\n M(a,d,f);\n M(d,b,x);\n S(b,e);\n sel25519(a,b,r);\n sel25519(c,d,r);\n }\n for (i = 0; i < 16; i++) {\n x[i+16]=a[i];\n x[i+32]=c[i];\n x[i+48]=b[i];\n x[i+64]=d[i];\n }\n var x32 = x.subarray(32);\n var x16 = x.subarray(16);\n inv25519(x32,x32);\n M(x16,x16,x32);\n pack25519(q,x16);\n return 0;\n}\n\nfunction crypto_scalarmult_base(q, n) {\n return crypto_scalarmult(q, n, _9);\n}\n\nfunction crypto_box_keypair(y, x) {\n randombytes(x, 32);\n return crypto_scalarmult_base(y, x);\n}\n\nfunction crypto_box_beforenm(k, y, x) {\n var s = new Uint8Array(32);\n crypto_scalarmult(s, x, y);\n return crypto_core_hsalsa20(k, _0, s, sigma);\n}\n\nvar crypto_box_afternm = crypto_secretbox;\nvar crypto_box_open_afternm = crypto_secretbox_open;\n\nfunction crypto_box(c, m, d, n, y, x) {\n var k = new Uint8Array(32);\n crypto_box_beforenm(k, y, x);\n return crypto_box_afternm(c, m, d, n, k);\n}\n\nfunction crypto_box_open(m, c, d, n, y, x) {\n var k = new Uint8Array(32);\n crypto_box_beforenm(k, y, x);\n return crypto_box_open_afternm(m, c, d, n, k);\n}\n\nvar K = [\n 0x428a2f98, 0xd728ae22, 0x71374491, 0x23ef65cd,\n 0xb5c0fbcf, 0xec4d3b2f, 0xe9b5dba5, 0x8189dbbc,\n 0x3956c25b, 0xf348b538, 0x59f111f1, 0xb605d019,\n 0x923f82a4, 0xaf194f9b, 0xab1c5ed5, 0xda6d8118,\n 0xd807aa98, 0xa3030242, 0x12835b01, 0x45706fbe,\n 0x243185be, 0x4ee4b28c, 0x550c7dc3, 0xd5ffb4e2,\n 0x72be5d74, 0xf27b896f, 0x80deb1fe, 0x3b1696b1,\n 0x9bdc06a7, 0x25c71235, 0xc19bf174, 0xcf692694,\n 0xe49b69c1, 0x9ef14ad2, 0xefbe4786, 0x384f25e3,\n 0x0fc19dc6, 0x8b8cd5b5, 0x240ca1cc, 0x77ac9c65,\n 0x2de92c6f, 0x592b0275, 0x4a7484aa, 0x6ea6e483,\n 0x5cb0a9dc, 0xbd41fbd4, 0x76f988da, 0x831153b5,\n 0x983e5152, 0xee66dfab, 0xa831c66d, 0x2db43210,\n 0xb00327c8, 0x98fb213f, 0xbf597fc7, 0xbeef0ee4,\n 0xc6e00bf3, 0x3da88fc2, 0xd5a79147, 0x930aa725,\n 0x06ca6351, 0xe003826f, 0x14292967, 0x0a0e6e70,\n 0x27b70a85, 0x46d22ffc, 0x2e1b2138, 0x5c26c926,\n 0x4d2c6dfc, 0x5ac42aed, 0x53380d13, 0x9d95b3df,\n 0x650a7354, 0x8baf63de, 0x766a0abb, 0x3c77b2a8,\n 0x81c2c92e, 0x47edaee6, 0x92722c85, 0x1482353b,\n 0xa2bfe8a1, 0x4cf10364, 0xa81a664b, 0xbc423001,\n 0xc24b8b70, 0xd0f89791, 0xc76c51a3, 0x0654be30,\n 0xd192e819, 0xd6ef5218, 0xd6990624, 0x5565a910,\n 0xf40e3585, 0x5771202a, 0x106aa070, 0x32bbd1b8,\n 0x19a4c116, 0xb8d2d0c8, 0x1e376c08, 0x5141ab53,\n 0x2748774c, 0xdf8eeb99, 0x34b0bcb5, 0xe19b48a8,\n 0x391c0cb3, 0xc5c95a63, 0x4ed8aa4a, 0xe3418acb,\n 0x5b9cca4f, 0x7763e373, 0x682e6ff3, 0xd6b2b8a3,\n 0x748f82ee, 0x5defb2fc, 0x78a5636f, 0x43172f60,\n 0x84c87814, 0xa1f0ab72, 0x8cc70208, 0x1a6439ec,\n 0x90befffa, 0x23631e28, 0xa4506ceb, 0xde82bde9,\n 0xbef9a3f7, 0xb2c67915, 0xc67178f2, 0xe372532b,\n 0xca273ece, 0xea26619c, 0xd186b8c7, 0x21c0c207,\n 0xeada7dd6, 0xcde0eb1e, 0xf57d4f7f, 0xee6ed178,\n 0x06f067aa, 0x72176fba, 0x0a637dc5, 0xa2c898a6,\n 0x113f9804, 0xbef90dae, 0x1b710b35, 0x131c471b,\n 0x28db77f5, 0x23047d84, 0x32caab7b, 0x40c72493,\n 0x3c9ebe0a, 0x15c9bebc, 0x431d67c4, 0x9c100d4c,\n 0x4cc5d4be, 0xcb3e42b6, 0x597f299c, 0xfc657e2a,\n 0x5fcb6fab, 0x3ad6faec, 0x6c44198c, 0x4a475817\n];\n\nfunction crypto_hashblocks_hl(hh, hl, m, n) {\n var wh = new Int32Array(16), wl = new Int32Array(16),\n bh0, bh1, bh2, bh3, bh4, bh5, bh6, bh7,\n bl0, bl1, bl2, bl3, bl4, bl5, bl6, bl7,\n th, tl, i, j, h, l, a, b, c, d;\n\n var ah0 = hh[0],\n ah1 = hh[1],\n ah2 = hh[2],\n ah3 = hh[3],\n ah4 = hh[4],\n ah5 = hh[5],\n ah6 = hh[6],\n ah7 = hh[7],\n\n al0 = hl[0],\n al1 = hl[1],\n al2 = hl[2],\n al3 = hl[3],\n al4 = hl[4],\n al5 = hl[5],\n al6 = hl[6],\n al7 = hl[7];\n\n var pos = 0;\n while (n >= 128) {\n for (i = 0; i < 16; i++) {\n j = 8 * i + pos;\n wh[i] = (m[j+0] << 24) | (m[j+1] << 16) | (m[j+2] << 8) | m[j+3];\n wl[i] = (m[j+4] << 24) | (m[j+5] << 16) | (m[j+6] << 8) | m[j+7];\n }\n for (i = 0; i < 80; i++) {\n bh0 = ah0;\n bh1 = ah1;\n bh2 = ah2;\n bh3 = ah3;\n bh4 = ah4;\n bh5 = ah5;\n bh6 = ah6;\n bh7 = ah7;\n\n bl0 = al0;\n bl1 = al1;\n bl2 = al2;\n bl3 = al3;\n bl4 = al4;\n bl5 = al5;\n bl6 = al6;\n bl7 = al7;\n\n // add\n h = ah7;\n l = al7;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n // Sigma1\n h = ((ah4 >>> 14) | (al4 << (32-14))) ^ ((ah4 >>> 18) | (al4 << (32-18))) ^ ((al4 >>> (41-32)) | (ah4 << (32-(41-32))));\n l = ((al4 >>> 14) | (ah4 << (32-14))) ^ ((al4 >>> 18) | (ah4 << (32-18))) ^ ((ah4 >>> (41-32)) | (al4 << (32-(41-32))));\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // Ch\n h = (ah4 & ah5) ^ (~ah4 & ah6);\n l = (al4 & al5) ^ (~al4 & al6);\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // K\n h = K[i*2];\n l = K[i*2+1];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // w\n h = wh[i%16];\n l = wl[i%16];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n th = c & 0xffff | d << 16;\n tl = a & 0xffff | b << 16;\n\n // add\n h = th;\n l = tl;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n // Sigma0\n h = ((ah0 >>> 28) | (al0 << (32-28))) ^ ((al0 >>> (34-32)) | (ah0 << (32-(34-32)))) ^ ((al0 >>> (39-32)) | (ah0 << (32-(39-32))));\n l = ((al0 >>> 28) | (ah0 << (32-28))) ^ ((ah0 >>> (34-32)) | (al0 << (32-(34-32)))) ^ ((ah0 >>> (39-32)) | (al0 << (32-(39-32))));\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // Maj\n h = (ah0 & ah1) ^ (ah0 & ah2) ^ (ah1 & ah2);\n l = (al0 & al1) ^ (al0 & al2) ^ (al1 & al2);\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n bh7 = (c & 0xffff) | (d << 16);\n bl7 = (a & 0xffff) | (b << 16);\n\n // add\n h = bh3;\n l = bl3;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = th;\n l = tl;\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n bh3 = (c & 0xffff) | (d << 16);\n bl3 = (a & 0xffff) | (b << 16);\n\n ah1 = bh0;\n ah2 = bh1;\n ah3 = bh2;\n ah4 = bh3;\n ah5 = bh4;\n ah6 = bh5;\n ah7 = bh6;\n ah0 = bh7;\n\n al1 = bl0;\n al2 = bl1;\n al3 = bl2;\n al4 = bl3;\n al5 = bl4;\n al6 = bl5;\n al7 = bl6;\n al0 = bl7;\n\n if (i%16 === 15) {\n for (j = 0; j < 16; j++) {\n // add\n h = wh[j];\n l = wl[j];\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = wh[(j+9)%16];\n l = wl[(j+9)%16];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // sigma0\n th = wh[(j+1)%16];\n tl = wl[(j+1)%16];\n h = ((th >>> 1) | (tl << (32-1))) ^ ((th >>> 8) | (tl << (32-8))) ^ (th >>> 7);\n l = ((tl >>> 1) | (th << (32-1))) ^ ((tl >>> 8) | (th << (32-8))) ^ ((tl >>> 7) | (th << (32-7)));\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // sigma1\n th = wh[(j+14)%16];\n tl = wl[(j+14)%16];\n h = ((th >>> 19) | (tl << (32-19))) ^ ((tl >>> (61-32)) | (th << (32-(61-32)))) ^ (th >>> 6);\n l = ((tl >>> 19) | (th << (32-19))) ^ ((th >>> (61-32)) | (tl << (32-(61-32)))) ^ ((tl >>> 6) | (th << (32-6)));\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n wh[j] = (c & 0xffff) | (d << 16);\n wl[j] = (a & 0xffff) | (b << 16);\n }\n }\n }\n\n // add\n h = ah0;\n l = al0;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[0];\n l = hl[0];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[0] = ah0 = (c & 0xffff) | (d << 16);\n hl[0] = al0 = (a & 0xffff) | (b << 16);\n\n h = ah1;\n l = al1;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[1];\n l = hl[1];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[1] = ah1 = (c & 0xffff) | (d << 16);\n hl[1] = al1 = (a & 0xffff) | (b << 16);\n\n h = ah2;\n l = al2;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[2];\n l = hl[2];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[2] = ah2 = (c & 0xffff) | (d << 16);\n hl[2] = al2 = (a & 0xffff) | (b << 16);\n\n h = ah3;\n l = al3;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[3];\n l = hl[3];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[3] = ah3 = (c & 0xffff) | (d << 16);\n hl[3] = al3 = (a & 0xffff) | (b << 16);\n\n h = ah4;\n l = al4;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[4];\n l = hl[4];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[4] = ah4 = (c & 0xffff) | (d << 16);\n hl[4] = al4 = (a & 0xffff) | (b << 16);\n\n h = ah5;\n l = al5;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[5];\n l = hl[5];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[5] = ah5 = (c & 0xffff) | (d << 16);\n hl[5] = al5 = (a & 0xffff) | (b << 16);\n\n h = ah6;\n l = al6;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[6];\n l = hl[6];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[6] = ah6 = (c & 0xffff) | (d << 16);\n hl[6] = al6 = (a & 0xffff) | (b << 16);\n\n h = ah7;\n l = al7;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[7];\n l = hl[7];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[7] = ah7 = (c & 0xffff) | (d << 16);\n hl[7] = al7 = (a & 0xffff) | (b << 16);\n\n pos += 128;\n n -= 128;\n }\n\n return n;\n}\n\nfunction crypto_hash(out, m, n) {\n var hh = new Int32Array(8),\n hl = new Int32Array(8),\n x = new Uint8Array(256),\n i, b = n;\n\n hh[0] = 0x6a09e667;\n hh[1] = 0xbb67ae85;\n hh[2] = 0x3c6ef372;\n hh[3] = 0xa54ff53a;\n hh[4] = 0x510e527f;\n hh[5] = 0x9b05688c;\n hh[6] = 0x1f83d9ab;\n hh[7] = 0x5be0cd19;\n\n hl[0] = 0xf3bcc908;\n hl[1] = 0x84caa73b;\n hl[2] = 0xfe94f82b;\n hl[3] = 0x5f1d36f1;\n hl[4] = 0xade682d1;\n hl[5] = 0x2b3e6c1f;\n hl[6] = 0xfb41bd6b;\n hl[7] = 0x137e2179;\n\n crypto_hashblocks_hl(hh, hl, m, n);\n n %= 128;\n\n for (i = 0; i < n; i++) x[i] = m[b-n+i];\n x[n] = 128;\n\n n = 256-128*(n<112?1:0);\n x[n-9] = 0;\n ts64(x, n-8, (b / 0x20000000) | 0, b << 3);\n crypto_hashblocks_hl(hh, hl, x, n);\n\n for (i = 0; i < 8; i++) ts64(out, 8*i, hh[i], hl[i]);\n\n return 0;\n}\n\nfunction add(p, q) {\n var a = gf(), b = gf(), c = gf(),\n d = gf(), e = gf(), f = gf(),\n g = gf(), h = gf(), t = gf();\n\n Z(a, p[1], p[0]);\n Z(t, q[1], q[0]);\n M(a, a, t);\n A(b, p[0], p[1]);\n A(t, q[0], q[1]);\n M(b, b, t);\n M(c, p[3], q[3]);\n M(c, c, D2);\n M(d, p[2], q[2]);\n A(d, d, d);\n Z(e, b, a);\n Z(f, d, c);\n A(g, d, c);\n A(h, b, a);\n\n M(p[0], e, f);\n M(p[1], h, g);\n M(p[2], g, f);\n M(p[3], e, h);\n}\n\nfunction cswap(p, q, b) {\n var i;\n for (i = 0; i < 4; i++) {\n sel25519(p[i], q[i], b);\n }\n}\n\nfunction pack(r, p) {\n var tx = gf(), ty = gf(), zi = gf();\n inv25519(zi, p[2]);\n M(tx, p[0], zi);\n M(ty, p[1], zi);\n pack25519(r, ty);\n r[31] ^= par25519(tx) << 7;\n}\n\nfunction scalarmult(p, q, s) {\n var b, i;\n set25519(p[0], gf0);\n set25519(p[1], gf1);\n set25519(p[2], gf1);\n set25519(p[3], gf0);\n for (i = 255; i >= 0; --i) {\n b = (s[(i/8)|0] >> (i&7)) & 1;\n cswap(p, q, b);\n add(q, p);\n add(p, p);\n cswap(p, q, b);\n }\n}\n\nfunction scalarbase(p, s) {\n var q = [gf(), gf(), gf(), gf()];\n set25519(q[0], X);\n set25519(q[1], Y);\n set25519(q[2], gf1);\n M(q[3], X, Y);\n scalarmult(p, q, s);\n}\n\nfunction crypto_sign_keypair(pk, sk, seeded) {\n var d = new Uint8Array(64);\n var p = [gf(), gf(), gf(), gf()];\n var i;\n\n if (!seeded) randombytes(sk, 32);\n crypto_hash(d, sk, 32);\n d[0] &= 248;\n d[31] &= 127;\n d[31] |= 64;\n\n scalarbase(p, d);\n pack(pk, p);\n\n for (i = 0; i < 32; i++) sk[i+32] = pk[i];\n return 0;\n}\n\nvar L = new Float64Array([0xed, 0xd3, 0xf5, 0x5c, 0x1a, 0x63, 0x12, 0x58, 0xd6, 0x9c, 0xf7, 0xa2, 0xde, 0xf9, 0xde, 0x14, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x10]);\n\nfunction modL(r, x) {\n var carry, i, j, k;\n for (i = 63; i >= 32; --i) {\n carry = 0;\n for (j = i - 32, k = i - 12; j < k; ++j) {\n x[j] += carry - 16 * x[i] * L[j - (i - 32)];\n carry = Math.floor((x[j] + 128) / 256);\n x[j] -= carry * 256;\n }\n x[j] += carry;\n x[i] = 0;\n }\n carry = 0;\n for (j = 0; j < 32; j++) {\n x[j] += carry - (x[31] >> 4) * L[j];\n carry = x[j] >> 8;\n x[j] &= 255;\n }\n for (j = 0; j < 32; j++) x[j] -= carry * L[j];\n for (i = 0; i < 32; i++) {\n x[i+1] += x[i] >> 8;\n r[i] = x[i] & 255;\n }\n}\n\nfunction reduce(r) {\n var x = new Float64Array(64), i;\n for (i = 0; i < 64; i++) x[i] = r[i];\n for (i = 0; i < 64; i++) r[i] = 0;\n modL(r, x);\n}\n\n// Note: difference from C - smlen returned, not passed as argument.\nfunction crypto_sign(sm, m, n, sk) {\n var d = new Uint8Array(64), h = new Uint8Array(64), r = new Uint8Array(64);\n var i, j, x = new Float64Array(64);\n var p = [gf(), gf(), gf(), gf()];\n\n crypto_hash(d, sk, 32);\n d[0] &= 248;\n d[31] &= 127;\n d[31] |= 64;\n\n var smlen = n + 64;\n for (i = 0; i < n; i++) sm[64 + i] = m[i];\n for (i = 0; i < 32; i++) sm[32 + i] = d[32 + i];\n\n crypto_hash(r, sm.subarray(32), n+32);\n reduce(r);\n scalarbase(p, r);\n pack(sm, p);\n\n for (i = 32; i < 64; i++) sm[i] = sk[i];\n crypto_hash(h, sm, n + 64);\n reduce(h);\n\n for (i = 0; i < 64; i++) x[i] = 0;\n for (i = 0; i < 32; i++) x[i] = r[i];\n for (i = 0; i < 32; i++) {\n for (j = 0; j < 32; j++) {\n x[i+j] += h[i] * d[j];\n }\n }\n\n modL(sm.subarray(32), x);\n return smlen;\n}\n\nfunction unpackneg(r, p) {\n var t = gf(), chk = gf(), num = gf(),\n den = gf(), den2 = gf(), den4 = gf(),\n den6 = gf();\n\n set25519(r[2], gf1);\n unpack25519(r[1], p);\n S(num, r[1]);\n M(den, num, D);\n Z(num, num, r[2]);\n A(den, r[2], den);\n\n S(den2, den);\n S(den4, den2);\n M(den6, den4, den2);\n M(t, den6, num);\n M(t, t, den);\n\n pow2523(t, t);\n M(t, t, num);\n M(t, t, den);\n M(t, t, den);\n M(r[0], t, den);\n\n S(chk, r[0]);\n M(chk, chk, den);\n if (neq25519(chk, num)) M(r[0], r[0], I);\n\n S(chk, r[0]);\n M(chk, chk, den);\n if (neq25519(chk, num)) return -1;\n\n if (par25519(r[0]) === (p[31]>>7)) Z(r[0], gf0, r[0]);\n\n M(r[3], r[0], r[1]);\n return 0;\n}\n\nfunction crypto_sign_open(m, sm, n, pk) {\n var i;\n var t = new Uint8Array(32), h = new Uint8Array(64);\n var p = [gf(), gf(), gf(), gf()],\n q = [gf(), gf(), gf(), gf()];\n\n if (n < 64) return -1;\n\n if (unpackneg(q, pk)) return -1;\n\n for (i = 0; i < n; i++) m[i] = sm[i];\n for (i = 0; i < 32; i++) m[i+32] = pk[i];\n crypto_hash(h, m, n);\n reduce(h);\n scalarmult(p, q, h);\n\n scalarbase(q, sm.subarray(32));\n add(p, q);\n pack(t, p);\n\n n -= 64;\n if (crypto_verify_32(sm, 0, t, 0)) {\n for (i = 0; i < n; i++) m[i] = 0;\n return -1;\n }\n\n for (i = 0; i < n; i++) m[i] = sm[i + 64];\n return n;\n}\n\nvar crypto_secretbox_KEYBYTES = 32,\n crypto_secretbox_NONCEBYTES = 24,\n crypto_secretbox_ZEROBYTES = 32,\n crypto_secretbox_BOXZEROBYTES = 16,\n crypto_scalarmult_BYTES = 32,\n crypto_scalarmult_SCALARBYTES = 32,\n crypto_box_PUBLICKEYBYTES = 32,\n crypto_box_SECRETKEYBYTES = 32,\n crypto_box_BEFORENMBYTES = 32,\n crypto_box_NONCEBYTES = crypto_secretbox_NONCEBYTES,\n crypto_box_ZEROBYTES = crypto_secretbox_ZEROBYTES,\n crypto_box_BOXZEROBYTES = crypto_secretbox_BOXZEROBYTES,\n crypto_sign_BYTES = 64,\n crypto_sign_PUBLICKEYBYTES = 32,\n crypto_sign_SECRETKEYBYTES = 64,\n crypto_sign_SEEDBYTES = 32,\n crypto_hash_BYTES = 64;\n\nnacl.lowlevel = {\n crypto_core_hsalsa20: crypto_core_hsalsa20,\n crypto_stream_xor: crypto_stream_xor,\n crypto_stream: crypto_stream,\n crypto_stream_salsa20_xor: crypto_stream_salsa20_xor,\n crypto_stream_salsa20: crypto_stream_salsa20,\n crypto_onetimeauth: crypto_onetimeauth,\n crypto_onetimeauth_verify: crypto_onetimeauth_verify,\n crypto_verify_16: crypto_verify_16,\n crypto_verify_32: crypto_verify_32,\n crypto_secretbox: crypto_secretbox,\n crypto_secretbox_open: crypto_secretbox_open,\n crypto_scalarmult: crypto_scalarmult,\n crypto_scalarmult_base: crypto_scalarmult_base,\n crypto_box_beforenm: crypto_box_beforenm,\n crypto_box_afternm: crypto_box_afternm,\n crypto_box: crypto_box,\n crypto_box_open: crypto_box_open,\n crypto_box_keypair: crypto_box_keypair,\n crypto_hash: crypto_hash,\n crypto_sign: crypto_sign,\n crypto_sign_keypair: crypto_sign_keypair,\n crypto_sign_open: crypto_sign_open,\n\n crypto_secretbox_KEYBYTES: crypto_secretbox_KEYBYTES,\n crypto_secretbox_NONCEBYTES: crypto_secretbox_NONCEBYTES,\n crypto_secretbox_ZEROBYTES: crypto_secretbox_ZEROBYTES,\n crypto_secretbox_BOXZEROBYTES: crypto_secretbox_BOXZEROBYTES,\n crypto_scalarmult_BYTES: crypto_scalarmult_BYTES,\n crypto_scalarmult_SCALARBYTES: crypto_scalarmult_SCALARBYTES,\n crypto_box_PUBLICKEYBYTES: crypto_box_PUBLICKEYBYTES,\n crypto_box_SECRETKEYBYTES: crypto_box_SECRETKEYBYTES,\n crypto_box_BEFORENMBYTES: crypto_box_BEFORENMBYTES,\n crypto_box_NONCEBYTES: crypto_box_NONCEBYTES,\n crypto_box_ZEROBYTES: crypto_box_ZEROBYTES,\n crypto_box_BOXZEROBYTES: crypto_box_BOXZEROBYTES,\n crypto_sign_BYTES: crypto_sign_BYTES,\n crypto_sign_PUBLICKEYBYTES: crypto_sign_PUBLICKEYBYTES,\n crypto_sign_SECRETKEYBYTES: crypto_sign_SECRETKEYBYTES,\n crypto_sign_SEEDBYTES: crypto_sign_SEEDBYTES,\n crypto_hash_BYTES: crypto_hash_BYTES,\n\n gf: gf,\n D: D,\n L: L,\n pack25519: pack25519,\n unpack25519: unpack25519,\n M: M,\n A: A,\n S: S,\n Z: Z,\n pow2523: pow2523,\n add: add,\n set25519: set25519,\n modL: modL,\n scalarmult: scalarmult,\n scalarbase: scalarbase,\n};\n\n/* High-level API */\n\nfunction checkLengths(k, n) {\n if (k.length !== crypto_secretbox_KEYBYTES) throw new Error('bad key size');\n if (n.length !== crypto_secretbox_NONCEBYTES) throw new Error('bad nonce size');\n}\n\nfunction checkBoxLengths(pk, sk) {\n if (pk.length !== crypto_box_PUBLICKEYBYTES) throw new Error('bad public key size');\n if (sk.length !== crypto_box_SECRETKEYBYTES) throw new Error('bad secret key size');\n}\n\nfunction checkArrayTypes() {\n for (var i = 0; i < arguments.length; i++) {\n if (!(arguments[i] instanceof Uint8Array))\n throw new TypeError('unexpected type, use Uint8Array');\n }\n}\n\nfunction cleanup(arr) {\n for (var i = 0; i < arr.length; i++) arr[i] = 0;\n}\n\nnacl.randomBytes = function(n) {\n var b = new Uint8Array(n);\n randombytes(b, n);\n return b;\n};\n\nnacl.secretbox = function(msg, nonce, key) {\n checkArrayTypes(msg, nonce, key);\n checkLengths(key, nonce);\n var m = new Uint8Array(crypto_secretbox_ZEROBYTES + msg.length);\n var c = new Uint8Array(m.length);\n for (var i = 0; i < msg.length; i++) m[i+crypto_secretbox_ZEROBYTES] = msg[i];\n crypto_secretbox(c, m, m.length, nonce, key);\n return c.subarray(crypto_secretbox_BOXZEROBYTES);\n};\n\nnacl.secretbox.open = function(box, nonce, key) {\n checkArrayTypes(box, nonce, key);\n checkLengths(key, nonce);\n var c = new Uint8Array(crypto_secretbox_BOXZEROBYTES + box.length);\n var m = new Uint8Array(c.length);\n for (var i = 0; i < box.length; i++) c[i+crypto_secretbox_BOXZEROBYTES] = box[i];\n if (c.length < 32) return null;\n if (crypto_secretbox_open(m, c, c.length, nonce, key) !== 0) return null;\n return m.subarray(crypto_secretbox_ZEROBYTES);\n};\n\nnacl.secretbox.keyLength = crypto_secretbox_KEYBYTES;\nnacl.secretbox.nonceLength = crypto_secretbox_NONCEBYTES;\nnacl.secretbox.overheadLength = crypto_secretbox_BOXZEROBYTES;\n\nnacl.scalarMult = function(n, p) {\n checkArrayTypes(n, p);\n if (n.length !== crypto_scalarmult_SCALARBYTES) throw new Error('bad n size');\n if (p.length !== crypto_scalarmult_BYTES) throw new Error('bad p size');\n var q = new Uint8Array(crypto_scalarmult_BYTES);\n crypto_scalarmult(q, n, p);\n return q;\n};\n\nnacl.scalarMult.base = function(n) {\n checkArrayTypes(n);\n if (n.length !== crypto_scalarmult_SCALARBYTES) throw new Error('bad n size');\n var q = new Uint8Array(crypto_scalarmult_BYTES);\n crypto_scalarmult_base(q, n);\n return q;\n};\n\nnacl.scalarMult.scalarLength = crypto_scalarmult_SCALARBYTES;\nnacl.scalarMult.groupElementLength = crypto_scalarmult_BYTES;\n\nnacl.box = function(msg, nonce, publicKey, secretKey) {\n var k = nacl.box.before(publicKey, secretKey);\n return nacl.secretbox(msg, nonce, k);\n};\n\nnacl.box.before = function(publicKey, secretKey) {\n checkArrayTypes(publicKey, secretKey);\n checkBoxLengths(publicKey, secretKey);\n var k = new Uint8Array(crypto_box_BEFORENMBYTES);\n crypto_box_beforenm(k, publicKey, secretKey);\n return k;\n};\n\nnacl.box.after = nacl.secretbox;\n\nnacl.box.open = function(msg, nonce, publicKey, secretKey) {\n var k = nacl.box.before(publicKey, secretKey);\n return nacl.secretbox.open(msg, nonce, k);\n};\n\nnacl.box.open.after = nacl.secretbox.open;\n\nnacl.box.keyPair = function() {\n var pk = new Uint8Array(crypto_box_PUBLICKEYBYTES);\n var sk = new Uint8Array(crypto_box_SECRETKEYBYTES);\n crypto_box_keypair(pk, sk);\n return {publicKey: pk, secretKey: sk};\n};\n\nnacl.box.keyPair.fromSecretKey = function(secretKey) {\n checkArrayTypes(secretKey);\n if (secretKey.length !== crypto_box_SECRETKEYBYTES)\n throw new Error('bad secret key size');\n var pk = new Uint8Array(crypto_box_PUBLICKEYBYTES);\n crypto_scalarmult_base(pk, secretKey);\n return {publicKey: pk, secretKey: new Uint8Array(secretKey)};\n};\n\nnacl.box.publicKeyLength = crypto_box_PUBLICKEYBYTES;\nnacl.box.secretKeyLength = crypto_box_SECRETKEYBYTES;\nnacl.box.sharedKeyLength = crypto_box_BEFORENMBYTES;\nnacl.box.nonceLength = crypto_box_NONCEBYTES;\nnacl.box.overheadLength = nacl.secretbox.overheadLength;\n\nnacl.sign = function(msg, secretKey) {\n checkArrayTypes(msg, secretKey);\n if (secretKey.length !== crypto_sign_SECRETKEYBYTES)\n throw new Error('bad secret key size');\n var signedMsg = new Uint8Array(crypto_sign_BYTES+msg.length);\n crypto_sign(signedMsg, msg, msg.length, secretKey);\n return signedMsg;\n};\n\nnacl.sign.open = function(signedMsg, publicKey) {\n checkArrayTypes(signedMsg, publicKey);\n if (publicKey.length !== crypto_sign_PUBLICKEYBYTES)\n throw new Error('bad public key size');\n var tmp = new Uint8Array(signedMsg.length);\n var mlen = crypto_sign_open(tmp, signedMsg, signedMsg.length, publicKey);\n if (mlen < 0) return null;\n var m = new Uint8Array(mlen);\n for (var i = 0; i < m.length; i++) m[i] = tmp[i];\n return m;\n};\n\nnacl.sign.detached = function(msg, secretKey) {\n var signedMsg = nacl.sign(msg, secretKey);\n var sig = new Uint8Array(crypto_sign_BYTES);\n for (var i = 0; i < sig.length; i++) sig[i] = signedMsg[i];\n return sig;\n};\n\nnacl.sign.detached.verify = function(msg, sig, publicKey) {\n checkArrayTypes(msg, sig, publicKey);\n if (sig.length !== crypto_sign_BYTES)\n throw new Error('bad signature size');\n if (publicKey.length !== crypto_sign_PUBLICKEYBYTES)\n throw new Error('bad public key size');\n var sm = new Uint8Array(crypto_sign_BYTES + msg.length);\n var m = new Uint8Array(crypto_sign_BYTES + msg.length);\n var i;\n for (i = 0; i < crypto_sign_BYTES; i++) sm[i] = sig[i];\n for (i = 0; i < msg.length; i++) sm[i+crypto_sign_BYTES] = msg[i];\n return (crypto_sign_open(m, sm, sm.length, publicKey) >= 0);\n};\n\nnacl.sign.keyPair = function() {\n var pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);\n var sk = new Uint8Array(crypto_sign_SECRETKEYBYTES);\n crypto_sign_keypair(pk, sk);\n return {publicKey: pk, secretKey: sk};\n};\n\nnacl.sign.keyPair.fromSecretKey = function(secretKey) {\n checkArrayTypes(secretKey);\n if (secretKey.length !== crypto_sign_SECRETKEYBYTES)\n throw new Error('bad secret key size');\n var pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);\n for (var i = 0; i < pk.length; i++) pk[i] = secretKey[32+i];\n return {publicKey: pk, secretKey: new Uint8Array(secretKey)};\n};\n\nnacl.sign.keyPair.fromSeed = function(seed) {\n checkArrayTypes(seed);\n if (seed.length !== crypto_sign_SEEDBYTES)\n throw new Error('bad seed size');\n var pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);\n var sk = new Uint8Array(crypto_sign_SECRETKEYBYTES);\n for (var i = 0; i < 32; i++) sk[i] = seed[i];\n crypto_sign_keypair(pk, sk, true);\n return {publicKey: pk, secretKey: sk};\n};\n\nnacl.sign.publicKeyLength = crypto_sign_PUBLICKEYBYTES;\nnacl.sign.secretKeyLength = crypto_sign_SECRETKEYBYTES;\nnacl.sign.seedLength = crypto_sign_SEEDBYTES;\nnacl.sign.signatureLength = crypto_sign_BYTES;\n\nnacl.hash = function(msg) {\n checkArrayTypes(msg);\n var h = new Uint8Array(crypto_hash_BYTES);\n crypto_hash(h, msg, msg.length);\n return h;\n};\n\nnacl.hash.hashLength = crypto_hash_BYTES;\n\nnacl.verify = function(x, y) {\n checkArrayTypes(x, y);\n // Zero length arguments are considered not equal.\n if (x.length === 0 || y.length === 0) return false;\n if (x.length !== y.length) return false;\n return (vn(x, 0, y, 0, x.length) === 0) ? true : false;\n};\n\nnacl.setPRNG = function(fn) {\n randombytes = fn;\n};\n\n(function() {\n // Initialize PRNG if environment provides CSPRNG.\n // If not, methods calling randombytes will throw.\n var crypto = typeof self !== 'undefined' ? (self.crypto || self.msCrypto) : null;\n if (crypto && crypto.getRandomValues) {\n // Browsers.\n var QUOTA = 65536;\n nacl.setPRNG(function(x, n) {\n var i, v = new Uint8Array(n);\n for (i = 0; i < n; i += QUOTA) {\n crypto.getRandomValues(v.subarray(i, i + Math.min(n - i, QUOTA)));\n }\n for (i = 0; i < n; i++) x[i] = v[i];\n cleanup(v);\n });\n } else if (typeof require !== 'undefined') {\n // Node.js.\n crypto = require('crypto');\n if (crypto && crypto.randomBytes) {\n nacl.setPRNG(function(x, n) {\n var i, v = crypto.randomBytes(n);\n for (i = 0; i < n; i++) x[i] = v[i];\n cleanup(v);\n });\n }\n }\n})();\n\n})(typeof module !== 'undefined' && module.exports ? module.exports : (self.nacl = self.nacl || {}));\n","module.exports = require('./pusher-with-encryption').default;\n","export default function encode(s: any): string {\n return btoa(utob(s));\n}\n\nvar fromCharCode = String.fromCharCode;\n\nvar b64chars =\n 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';\nvar b64tab = {};\n\nfor (var i = 0, l = b64chars.length; i < l; i++) {\n b64tab[b64chars.charAt(i)] = i;\n}\n\nvar cb_utob = function(c) {\n var cc = c.charCodeAt(0);\n return cc < 0x80\n ? c\n : cc < 0x800\n ? fromCharCode(0xc0 | (cc >>> 6)) + fromCharCode(0x80 | (cc & 0x3f))\n : fromCharCode(0xe0 | ((cc >>> 12) & 0x0f)) +\n fromCharCode(0x80 | ((cc >>> 6) & 0x3f)) +\n fromCharCode(0x80 | (cc & 0x3f));\n};\n\nvar utob = function(u) {\n return u.replace(/[^\\x00-\\x7F]/g, cb_utob);\n};\n\nvar cb_encode = function(ccc) {\n var padlen = [0, 2, 1][ccc.length % 3];\n var ord =\n (ccc.charCodeAt(0) << 16) |\n ((ccc.length > 1 ? ccc.charCodeAt(1) : 0) << 8) |\n (ccc.length > 2 ? ccc.charCodeAt(2) : 0);\n var chars = [\n b64chars.charAt(ord >>> 18),\n b64chars.charAt((ord >>> 12) & 63),\n padlen >= 2 ? '=' : b64chars.charAt((ord >>> 6) & 63),\n padlen >= 1 ? '=' : b64chars.charAt(ord & 63)\n ];\n return chars.join('');\n};\n\nvar btoa =\n global.btoa ||\n function(b) {\n return b.replace(/[\\s\\S]{1,3}/g, cb_encode);\n };\n","import TimedCallback from './timed_callback';\nimport { Delay, Scheduler, Canceller } from './scheduling';\n\nabstract class Timer {\n protected clear: Canceller;\n protected timer: number | void;\n\n constructor(\n set: Scheduler,\n clear: Canceller,\n delay: Delay,\n callback: TimedCallback\n ) {\n this.clear = clear;\n this.timer = set(() => {\n if (this.timer) {\n this.timer = callback(this.timer);\n }\n }, delay);\n }\n\n /** Returns whether the timer is still running.\n *\n * @return {Boolean}\n */\n isRunning(): boolean {\n return this.timer !== null;\n }\n\n /** Aborts a timer when it's running. */\n ensureAborted() {\n if (this.timer) {\n this.clear(this.timer);\n this.timer = null;\n }\n }\n}\n\nexport default Timer;\n","import Timer from './abstract_timer';\nimport TimedCallback from './timed_callback';\nimport { Delay } from './scheduling';\n\n// We need to bind clear functions this way to avoid exceptions on IE8\nfunction clearTimeout(timer) {\n global.clearTimeout(timer);\n}\nfunction clearInterval(timer) {\n global.clearInterval(timer);\n}\n\n/** Cross-browser compatible one-off timer abstraction.\n *\n * @param {Number} delay\n * @param {Function} callback\n */\nexport class OneOffTimer extends Timer {\n constructor(delay: Delay, callback: TimedCallback) {\n super(setTimeout, clearTimeout, delay, function(timer) {\n callback();\n return null;\n });\n }\n}\n\n/** Cross-browser compatible periodic timer abstraction.\n *\n * @param {Number} delay\n * @param {Function} callback\n */\nexport class PeriodicTimer extends Timer {\n constructor(delay: Delay, callback: TimedCallback) {\n super(setInterval, clearInterval, delay, function(timer) {\n callback();\n return timer;\n });\n }\n}\n","import * as Collections from './utils/collections';\nimport TimedCallback from './utils/timers/timed_callback';\nimport { OneOffTimer, PeriodicTimer } from './utils/timers';\n\nvar Util = {\n now(): number {\n if (Date.now) {\n return Date.now();\n } else {\n return new Date().valueOf();\n }\n },\n\n defer(callback: TimedCallback): OneOffTimer {\n return new OneOffTimer(0, callback);\n },\n\n /** Builds a function that will proxy a method call to its first argument.\n *\n * Allows partial application of arguments, so additional arguments are\n * prepended to the argument list.\n *\n * @param {String} name method name\n * @return {Function} proxy function\n */\n method(name: string, ...args: any[]): Function {\n var boundArguments = Array.prototype.slice.call(arguments, 1);\n return function(object) {\n return object[name].apply(object, boundArguments.concat(arguments));\n };\n }\n};\n\nexport default Util;\n","import base64encode from '../base64';\nimport Util from '../util';\n\n/** Merges multiple objects into the target argument.\n *\n * For properties that are plain Objects, performs a deep-merge. For the\n * rest it just copies the value of the property.\n *\n * To extend prototypes use it as following:\n * Pusher.Util.extend(Target.prototype, Base.prototype)\n *\n * You can also use it to merge objects without altering them:\n * Pusher.Util.extend({}, object1, object2)\n *\n * @param {Object} target\n * @return {Object} the target argument\n */\nexport function extend(target: any, ...sources: any[]): T {\n for (var i = 0; i < sources.length; i++) {\n var extensions = sources[i];\n for (var property in extensions) {\n if (\n extensions[property] &&\n extensions[property].constructor &&\n extensions[property].constructor === Object\n ) {\n target[property] = extend(target[property] || {}, extensions[property]);\n } else {\n target[property] = extensions[property];\n }\n }\n }\n return target;\n}\n\nexport function stringify(): string {\n var m = ['Pusher'];\n for (var i = 0; i < arguments.length; i++) {\n if (typeof arguments[i] === 'string') {\n m.push(arguments[i]);\n } else {\n m.push(safeJSONStringify(arguments[i]));\n }\n }\n return m.join(' : ');\n}\n\nexport function arrayIndexOf(array: any[], item: any): number {\n // MSIE doesn't have array.indexOf\n var nativeIndexOf = Array.prototype.indexOf;\n if (array === null) {\n return -1;\n }\n if (nativeIndexOf && array.indexOf === nativeIndexOf) {\n return array.indexOf(item);\n }\n for (var i = 0, l = array.length; i < l; i++) {\n if (array[i] === item) {\n return i;\n }\n }\n return -1;\n}\n\n/** Applies a function f to all properties of an object.\n *\n * Function f gets 3 arguments passed:\n * - element from the object\n * - key of the element\n * - reference to the object\n *\n * @param {Object} object\n * @param {Function} f\n */\nexport function objectApply(object: any, f: Function) {\n for (var key in object) {\n if (Object.prototype.hasOwnProperty.call(object, key)) {\n f(object[key], key, object);\n }\n }\n}\n\n/** Return a list of objects own proerty keys\n *\n * @param {Object} object\n * @returns {Array}\n */\nexport function keys(object: any): string[] {\n var keys = [];\n objectApply(object, function(_, key) {\n keys.push(key);\n });\n return keys;\n}\n\n/** Return a list of object's own property values\n *\n * @param {Object} object\n * @returns {Array}\n */\nexport function values(object: any): any[] {\n var values = [];\n objectApply(object, function(value) {\n values.push(value);\n });\n return values;\n}\n\n/** Applies a function f to all elements of an array.\n *\n * Function f gets 3 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function apply(array: any[], f: Function, context?: any) {\n for (var i = 0; i < array.length; i++) {\n f.call(context || global, array[i], i, array);\n }\n}\n\n/** Maps all elements of the array and returns the result.\n *\n * Function f gets 4 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n * - reference to the destination array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function map(array: any[], f: Function): any[] {\n var result = [];\n for (var i = 0; i < array.length; i++) {\n result.push(f(array[i], i, array, result));\n }\n return result;\n}\n\n/** Maps all elements of the object and returns the result.\n *\n * Function f gets 4 arguments passed:\n * - element from the object\n * - key of the element\n * - reference to the source object\n * - reference to the destination object\n *\n * @param {Object} object\n * @param {Function} f\n */\nexport function mapObject(object: any, f: Function): any {\n var result = {};\n objectApply(object, function(value, key) {\n result[key] = f(value);\n });\n return result;\n}\n\n/** Filters elements of the array using a test function.\n *\n * Function test gets 4 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n * - reference to the destination array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function filter(array: any[], test: Function): any[] {\n test =\n test ||\n function(value) {\n return !!value;\n };\n\n var result = [];\n for (var i = 0; i < array.length; i++) {\n if (test(array[i], i, array, result)) {\n result.push(array[i]);\n }\n }\n return result;\n}\n\n/** Filters properties of the object using a test function.\n *\n * Function test gets 4 arguments passed:\n * - element from the object\n * - key of the element\n * - reference to the source object\n * - reference to the destination object\n *\n * @param {Object} object\n * @param {Function} f\n */\nexport function filterObject(object: Object, test: Function) {\n var result = {};\n objectApply(object, function(value, key) {\n if ((test && test(value, key, object, result)) || Boolean(value)) {\n result[key] = value;\n }\n });\n return result;\n}\n\n/** Flattens an object into a two-dimensional array.\n *\n * @param {Object} object\n * @return {Array} resulting array of [key, value] pairs\n */\nexport function flatten(object: Object): any[] {\n var result = [];\n objectApply(object, function(value, key) {\n result.push([key, value]);\n });\n return result;\n}\n\n/** Checks whether any element of the array passes the test.\n *\n * Function test gets 3 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function any(array: any[], test: Function): boolean {\n for (var i = 0; i < array.length; i++) {\n if (test(array[i], i, array)) {\n return true;\n }\n }\n return false;\n}\n\n/** Checks whether all elements of the array pass the test.\n *\n * Function test gets 3 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function all(array: any[], test: Function): boolean {\n for (var i = 0; i < array.length; i++) {\n if (!test(array[i], i, array)) {\n return false;\n }\n }\n return true;\n}\n\nexport function encodeParamsObject(data): string {\n return mapObject(data, function(value) {\n if (typeof value === 'object') {\n value = safeJSONStringify(value);\n }\n return encodeURIComponent(base64encode(value.toString()));\n });\n}\n\nexport function buildQueryString(data: any): string {\n var params = filterObject(data, function(value) {\n return value !== undefined;\n });\n\n var query = map(\n flatten(encodeParamsObject(params)),\n Util.method('join', '=')\n ).join('&');\n\n return query;\n}\n\n/**\n * See https://github.com/douglascrockford/JSON-js/blob/master/cycle.js\n *\n * Remove circular references from an object. Required for JSON.stringify in\n * React Native, which tends to blow up a lot.\n *\n * @param {any} object\n * @return {any} Decycled object\n */\nexport function decycleObject(object: any): any {\n var objects = [],\n paths = [];\n\n return (function derez(value, path) {\n var i, name, nu;\n\n switch (typeof value) {\n case 'object':\n if (!value) {\n return null;\n }\n for (i = 0; i < objects.length; i += 1) {\n if (objects[i] === value) {\n return { $ref: paths[i] };\n }\n }\n\n objects.push(value);\n paths.push(path);\n\n if (Object.prototype.toString.apply(value) === '[object Array]') {\n nu = [];\n for (i = 0; i < value.length; i += 1) {\n nu[i] = derez(value[i], path + '[' + i + ']');\n }\n } else {\n nu = {};\n for (name in value) {\n if (Object.prototype.hasOwnProperty.call(value, name)) {\n nu[name] = derez(\n value[name],\n path + '[' + JSON.stringify(name) + ']'\n );\n }\n }\n }\n return nu;\n case 'number':\n case 'string':\n case 'boolean':\n return value;\n }\n })(object, '$');\n}\n\n/**\n * Provides a cross-browser and cross-platform way to safely stringify objects\n * into JSON. This is particularly necessary for ReactNative, where circular JSON\n * structures throw an exception.\n *\n * @param {any} source The object to stringify\n * @return {string} The serialized output.\n */\nexport function safeJSONStringify(source: any): string {\n try {\n return JSON.stringify(source);\n } catch (e) {\n return JSON.stringify(decycleObject(source));\n }\n}\n","import {\n ChannelAuthorizationOptions,\n UserAuthenticationOptions\n} from './auth/options';\nimport { AuthTransport } from './config';\n\nexport interface DefaultConfig {\n VERSION: string;\n PROTOCOL: number;\n wsPort: number;\n wssPort: number;\n wsPath: string;\n httpHost: string;\n httpPort: number;\n httpsPort: number;\n httpPath: string;\n stats_host: string;\n authEndpoint: string;\n authTransport: AuthTransport;\n activityTimeout: number;\n pongTimeout: number;\n unavailableTimeout: number;\n userAuthentication: UserAuthenticationOptions;\n channelAuthorization: ChannelAuthorizationOptions;\n\n cdn_http?: string;\n cdn_https?: string;\n dependency_suffix?: string;\n}\n\nvar Defaults: DefaultConfig = {\n VERSION: VERSION,\n PROTOCOL: 7,\n\n wsPort: 80,\n wssPort: 443,\n wsPath: '',\n // DEPRECATED: SockJS fallback parameters\n httpHost: 'sockjs.pusher.com',\n httpPort: 80,\n httpsPort: 443,\n httpPath: '/pusher',\n // DEPRECATED: Stats\n stats_host: 'stats.pusher.com',\n // DEPRECATED: Other settings\n authEndpoint: '/pusher/auth',\n authTransport: 'ajax',\n activityTimeout: 120000,\n pongTimeout: 30000,\n unavailableTimeout: 10000,\n userAuthentication: {\n endpoint: '/pusher/user-auth',\n transport: 'ajax'\n },\n channelAuthorization: {\n endpoint: '/pusher/auth',\n transport: 'ajax'\n },\n\n // CDN configuration\n cdn_http: CDN_HTTP,\n cdn_https: CDN_HTTPS,\n dependency_suffix: DEPENDENCY_SUFFIX\n};\n\nexport default Defaults;\n","import Defaults from '../defaults';\nimport { default as URLScheme, URLSchemeParams } from './url_scheme';\n\nfunction getGenericURL(\n baseScheme: string,\n params: URLSchemeParams,\n path: string\n): string {\n var scheme = baseScheme + (params.useTLS ? 's' : '');\n var host = params.useTLS ? params.hostTLS : params.hostNonTLS;\n return scheme + '://' + host + path;\n}\n\nfunction getGenericPath(key: string, queryString?: string): string {\n var path = '/app/' + key;\n var query =\n '?protocol=' +\n Defaults.PROTOCOL +\n '&client=js' +\n '&version=' +\n Defaults.VERSION +\n (queryString ? '&' + queryString : '');\n return path + query;\n}\n\nexport var ws: URLScheme = {\n getInitial: function(key: string, params: URLSchemeParams): string {\n var path = (params.httpPath || '') + getGenericPath(key, 'flash=false');\n return getGenericURL('ws', params, path);\n }\n};\n\nexport var http: URLScheme = {\n getInitial: function(key: string, params: URLSchemeParams): string {\n var path = (params.httpPath || '/pusher') + getGenericPath(key);\n return getGenericURL('http', params, path);\n }\n};\n\nexport var sockjs: URLScheme = {\n getInitial: function(key: string, params: URLSchemeParams): string {\n return getGenericURL('http', params, params.httpPath || '/pusher');\n },\n getPath: function(key: string, params: URLSchemeParams): string {\n return getGenericPath(key);\n }\n};\n","import Callback from './callback';\nimport * as Collections from '../utils/collections';\nimport CallbackTable from './callback_table';\n\nexport default class CallbackRegistry {\n _callbacks: CallbackTable;\n\n constructor() {\n this._callbacks = {};\n }\n\n get(name: string): Callback[] {\n return this._callbacks[prefix(name)];\n }\n\n add(name: string, callback: Function, context: any) {\n var prefixedEventName = prefix(name);\n this._callbacks[prefixedEventName] =\n this._callbacks[prefixedEventName] || [];\n this._callbacks[prefixedEventName].push({\n fn: callback,\n context: context\n });\n }\n\n remove(name?: string, callback?: Function, context?: any) {\n if (!name && !callback && !context) {\n this._callbacks = {};\n return;\n }\n\n var names = name ? [prefix(name)] : Collections.keys(this._callbacks);\n\n if (callback || context) {\n this.removeCallback(names, callback, context);\n } else {\n this.removeAllCallbacks(names);\n }\n }\n\n private removeCallback(names: string[], callback: Function, context: any) {\n Collections.apply(\n names,\n function(name) {\n this._callbacks[name] = Collections.filter(\n this._callbacks[name] || [],\n function(binding) {\n return (\n (callback && callback !== binding.fn) ||\n (context && context !== binding.context)\n );\n }\n );\n if (this._callbacks[name].length === 0) {\n delete this._callbacks[name];\n }\n },\n this\n );\n }\n\n private removeAllCallbacks(names: string[]) {\n Collections.apply(\n names,\n function(name) {\n delete this._callbacks[name];\n },\n this\n );\n }\n}\n\nfunction prefix(name: string): string {\n return '_' + name;\n}\n","import * as Collections from '../utils/collections';\nimport Callback from './callback';\nimport Metadata from '../channels/metadata';\nimport CallbackRegistry from './callback_registry';\n\n/** Manages callback bindings and event emitting.\n *\n * @param Function failThrough called when no listeners are bound to an event\n */\nexport default class Dispatcher {\n callbacks: CallbackRegistry;\n global_callbacks: Function[];\n failThrough: Function;\n\n constructor(failThrough?: Function) {\n this.callbacks = new CallbackRegistry();\n this.global_callbacks = [];\n this.failThrough = failThrough;\n }\n\n bind(eventName: string, callback: Function, context?: any) {\n this.callbacks.add(eventName, callback, context);\n return this;\n }\n\n bind_global(callback: Function) {\n this.global_callbacks.push(callback);\n return this;\n }\n\n unbind(eventName?: string, callback?: Function, context?: any) {\n this.callbacks.remove(eventName, callback, context);\n return this;\n }\n\n unbind_global(callback?: Function) {\n if (!callback) {\n this.global_callbacks = [];\n return this;\n }\n\n this.global_callbacks = Collections.filter(\n this.global_callbacks || [],\n c => c !== callback\n );\n\n return this;\n }\n\n unbind_all() {\n this.unbind();\n this.unbind_global();\n return this;\n }\n\n emit(eventName: string, data?: any, metadata?: Metadata): Dispatcher {\n for (var i = 0; i < this.global_callbacks.length; i++) {\n this.global_callbacks[i](eventName, data);\n }\n\n var callbacks = this.callbacks.get(eventName);\n var args = [];\n\n if (metadata) {\n // if there's a metadata argument, we need to call the callback with both\n // data and metadata regardless of whether data is undefined\n args.push(data, metadata);\n } else if (data) {\n // metadata is undefined, so we only need to call the callback with data\n // if data exists\n args.push(data);\n }\n\n if (callbacks && callbacks.length > 0) {\n for (var i = 0; i < callbacks.length; i++) {\n callbacks[i].fn.apply(callbacks[i].context || global, args);\n }\n } else if (this.failThrough) {\n this.failThrough(eventName, data);\n }\n\n return this;\n }\n}\n","import { stringify } from './utils/collections';\nimport Pusher from './pusher';\n\nclass Logger {\n debug(...args: any[]) {\n this.log(this.globalLog, args);\n }\n\n warn(...args: any[]) {\n this.log(this.globalLogWarn, args);\n }\n\n error(...args: any[]) {\n this.log(this.globalLogError, args);\n }\n\n private globalLog = (message: string) => {\n if (global.console && global.console.log) {\n global.console.log(message);\n }\n };\n\n private globalLogWarn(message: string) {\n if (global.console && global.console.warn) {\n global.console.warn(message);\n } else {\n this.globalLog(message);\n }\n }\n\n private globalLogError(message: string) {\n if (global.console && global.console.error) {\n global.console.error(message);\n } else {\n this.globalLogWarn(message);\n }\n }\n\n private log(\n defaultLoggingFunction: (message: string) => void,\n ...args: any[]\n ) {\n var message = stringify.apply(this, arguments);\n if (Pusher.log) {\n Pusher.log(message);\n } else if (Pusher.logToConsole) {\n const log = defaultLoggingFunction.bind(this);\n log(message);\n }\n }\n}\n\nexport default new Logger();\n","import Util from '../util';\nimport * as Collections from '../utils/collections';\nimport { default as EventsDispatcher } from '../events/dispatcher';\nimport Logger from '../logger';\nimport TransportHooks from './transport_hooks';\nimport Socket from '../socket';\nimport Runtime from 'runtime';\nimport Timeline from '../timeline/timeline';\nimport TransportConnectionOptions from './transport_connection_options';\n\n/** Provides universal API for transport connections.\n *\n * Transport connection is a low-level object that wraps a connection method\n * and exposes a simple evented interface for the connection state and\n * messaging. It does not implement Pusher-specific WebSocket protocol.\n *\n * Additionally, it fetches resources needed for transport to work and exposes\n * an interface for querying transport features.\n *\n * States:\n * - new - initial state after constructing the object\n * - initializing - during initialization phase, usually fetching resources\n * - intialized - ready to establish a connection\n * - connection - when connection is being established\n * - open - when connection ready to be used\n * - closed - after connection was closed be either side\n *\n * Emits:\n * - error - after the connection raised an error\n *\n * Options:\n * - useTLS - whether connection should be over TLS\n * - hostTLS - host to connect to when connection is over TLS\n * - hostNonTLS - host to connect to when connection is over TLS\n *\n * @param {String} key application key\n * @param {Object} options\n */\nexport default class TransportConnection extends EventsDispatcher {\n hooks: TransportHooks;\n name: string;\n priority: number;\n key: string;\n options: TransportConnectionOptions;\n state: string;\n timeline: Timeline;\n activityTimeout: number;\n id: number;\n socket: Socket;\n beforeOpen: Function;\n initialize: Function;\n\n constructor(\n hooks: TransportHooks,\n name: string,\n priority: number,\n key: string,\n options: TransportConnectionOptions\n ) {\n super();\n this.initialize = Runtime.transportConnectionInitializer;\n this.hooks = hooks;\n this.name = name;\n this.priority = priority;\n this.key = key;\n this.options = options;\n\n this.state = 'new';\n this.timeline = options.timeline;\n this.activityTimeout = options.activityTimeout;\n this.id = this.timeline.generateUniqueID();\n }\n\n /** Checks whether the transport handles activity checks by itself.\n *\n * @return {Boolean}\n */\n handlesActivityChecks(): boolean {\n return Boolean(this.hooks.handlesActivityChecks);\n }\n\n /** Checks whether the transport supports the ping/pong API.\n *\n * @return {Boolean}\n */\n supportsPing(): boolean {\n return Boolean(this.hooks.supportsPing);\n }\n\n /** Tries to establish a connection.\n *\n * @returns {Boolean} false if transport is in invalid state\n */\n connect(): boolean {\n if (this.socket || this.state !== 'initialized') {\n return false;\n }\n\n var url = this.hooks.urls.getInitial(this.key, this.options);\n try {\n this.socket = this.hooks.getSocket(url, this.options);\n } catch (e) {\n Util.defer(() => {\n this.onError(e);\n this.changeState('closed');\n });\n return false;\n }\n\n this.bindListeners();\n\n Logger.debug('Connecting', { transport: this.name, url });\n this.changeState('connecting');\n return true;\n }\n\n /** Closes the connection.\n *\n * @return {Boolean} true if there was a connection to close\n */\n close(): boolean {\n if (this.socket) {\n this.socket.close();\n return true;\n } else {\n return false;\n }\n }\n\n /** Sends data over the open connection.\n *\n * @param {String} data\n * @return {Boolean} true only when in the \"open\" state\n */\n send(data: any): boolean {\n if (this.state === 'open') {\n // Workaround for MobileSafari bug (see https://gist.github.com/2052006)\n Util.defer(() => {\n if (this.socket) {\n this.socket.send(data);\n }\n });\n return true;\n } else {\n return false;\n }\n }\n\n /** Sends a ping if the connection is open and transport supports it. */\n ping() {\n if (this.state === 'open' && this.supportsPing()) {\n this.socket.ping();\n }\n }\n\n private onOpen() {\n if (this.hooks.beforeOpen) {\n this.hooks.beforeOpen(\n this.socket,\n this.hooks.urls.getPath(this.key, this.options)\n );\n }\n this.changeState('open');\n this.socket.onopen = undefined;\n }\n\n private onError(error) {\n this.emit('error', { type: 'WebSocketError', error: error });\n this.timeline.error(this.buildTimelineMessage({ error: error.toString() }));\n }\n\n private onClose(closeEvent?: any) {\n if (closeEvent) {\n this.changeState('closed', {\n code: closeEvent.code,\n reason: closeEvent.reason,\n wasClean: closeEvent.wasClean\n });\n } else {\n this.changeState('closed');\n }\n this.unbindListeners();\n this.socket = undefined;\n }\n\n private onMessage(message) {\n this.emit('message', message);\n }\n\n private onActivity() {\n this.emit('activity');\n }\n\n private bindListeners() {\n this.socket.onopen = () => {\n this.onOpen();\n };\n this.socket.onerror = error => {\n this.onError(error);\n };\n this.socket.onclose = closeEvent => {\n this.onClose(closeEvent);\n };\n this.socket.onmessage = message => {\n this.onMessage(message);\n };\n\n if (this.supportsPing()) {\n this.socket.onactivity = () => {\n this.onActivity();\n };\n }\n }\n\n private unbindListeners() {\n if (this.socket) {\n this.socket.onopen = undefined;\n this.socket.onerror = undefined;\n this.socket.onclose = undefined;\n this.socket.onmessage = undefined;\n if (this.supportsPing()) {\n this.socket.onactivity = undefined;\n }\n }\n }\n\n private changeState(state: string, params?: any) {\n this.state = state;\n this.timeline.info(\n this.buildTimelineMessage({\n state: state,\n params: params\n })\n );\n this.emit(state, params);\n }\n\n buildTimelineMessage(message): any {\n return Collections.extend({ cid: this.id }, message);\n }\n}\n","import Factory from '../utils/factory';\nimport TransportHooks from './transport_hooks';\nimport TransportConnection from './transport_connection';\nimport TransportConnectionOptions from './transport_connection_options';\n\n/** Provides interface for transport connection instantiation.\n *\n * Takes transport-specific hooks as the only argument, which allow checking\n * for transport support and creating its connections.\n *\n * Supported hooks: * - file - the name of the file to be fetched during initialization\n * - urls - URL scheme to be used by transport\n * - handlesActivityCheck - true when the transport handles activity checks\n * - supportsPing - true when the transport has a ping/activity API\n * - isSupported - tells whether the transport is supported in the environment\n * - getSocket - creates a WebSocket-compatible transport socket\n *\n * See transports.js for specific implementations.\n *\n * @param {Object} hooks object containing all needed transport hooks\n */\nexport default class Transport {\n hooks: TransportHooks;\n\n constructor(hooks: TransportHooks) {\n this.hooks = hooks;\n }\n\n /** Returns whether the transport is supported in the environment.\n *\n * @param {Object} envronment te environment details (encryption, settings)\n * @returns {Boolean} true when the transport is supported\n */\n isSupported(environment: any): boolean {\n return this.hooks.isSupported(environment);\n }\n\n /** Creates a transport connection.\n *\n * @param {String} name\n * @param {Number} priority\n * @param {String} key the application key\n * @param {Object} options\n * @returns {TransportConnection}\n */\n createConnection(\n name: string,\n priority: number,\n key: string,\n options: any\n ): TransportConnection {\n return new TransportConnection(this.hooks, name, priority, key, options);\n }\n}\n","import * as URLSchemes from 'core/transports/url_schemes';\nimport URLScheme from 'core/transports/url_scheme';\nimport Transport from 'core/transports/transport';\nimport Util from 'core/util';\nimport * as Collections from 'core/utils/collections';\nimport TransportHooks from 'core/transports/transport_hooks';\nimport TransportsTable from 'core/transports/transports_table';\nimport Runtime from 'runtime';\n\n/** WebSocket transport.\n *\n * Uses native WebSocket implementation, including MozWebSocket supported by\n * earlier Firefox versions.\n */\nvar WSTransport = new Transport({\n urls: URLSchemes.ws,\n handlesActivityChecks: false,\n supportsPing: false,\n\n isInitialized: function() {\n return Boolean(Runtime.getWebSocketAPI());\n },\n isSupported: function(): boolean {\n return Boolean(Runtime.getWebSocketAPI());\n },\n getSocket: function(url) {\n return Runtime.createWebSocket(url);\n }\n});\n\nvar httpConfiguration = {\n urls: URLSchemes.http,\n handlesActivityChecks: false,\n supportsPing: true,\n isInitialized: function() {\n return true;\n }\n};\n\nexport var streamingConfiguration = Collections.extend(\n {\n getSocket: function(url) {\n return Runtime.HTTPFactory.createStreamingSocket(url);\n }\n },\n httpConfiguration\n);\nexport var pollingConfiguration = Collections.extend(\n {\n getSocket: function(url) {\n return Runtime.HTTPFactory.createPollingSocket(url);\n }\n },\n httpConfiguration\n);\n\nvar xhrConfiguration = {\n isSupported: function(): boolean {\n return Runtime.isXHRSupported();\n }\n};\n\n/** HTTP streaming transport using CORS-enabled XMLHttpRequest. */\nvar XHRStreamingTransport = new Transport(\n (\n Collections.extend({}, streamingConfiguration, xhrConfiguration)\n )\n);\n\n/** HTTP long-polling transport using CORS-enabled XMLHttpRequest. */\nvar XHRPollingTransport = new Transport(\n Collections.extend({}, pollingConfiguration, xhrConfiguration)\n);\n\nvar Transports: TransportsTable = {\n ws: WSTransport,\n xhr_streaming: XHRStreamingTransport,\n xhr_polling: XHRPollingTransport\n};\n\nexport default Transports;\n","import Util from '../util';\nimport * as Collections from '../utils/collections';\nimport TransportManager from './transport_manager';\nimport TransportConnection from './transport_connection';\nimport Transport from './transport';\nimport PingDelayOptions from './ping_delay_options';\n\n/** Creates transport connections monitored by a transport manager.\n *\n * When a transport is closed, it might mean the environment does not support\n * it. It's possible that messages get stuck in an intermediate buffer or\n * proxies terminate inactive connections. To combat these problems,\n * assistants monitor the connection lifetime, report unclean exits and\n * adjust ping timeouts to keep the connection active. The decision to disable\n * a transport is the manager's responsibility.\n *\n * @param {TransportManager} manager\n * @param {TransportConnection} transport\n * @param {Object} options\n */\nexport default class AssistantToTheTransportManager {\n manager: TransportManager;\n transport: Transport;\n minPingDelay: number;\n maxPingDelay: number;\n pingDelay: number;\n\n constructor(\n manager: TransportManager,\n transport: Transport,\n options: PingDelayOptions\n ) {\n this.manager = manager;\n this.transport = transport;\n this.minPingDelay = options.minPingDelay;\n this.maxPingDelay = options.maxPingDelay;\n this.pingDelay = undefined;\n }\n\n /** Creates a transport connection.\n *\n * This function has the same API as Transport#createConnection.\n *\n * @param {String} name\n * @param {Number} priority\n * @param {String} key the application key\n * @param {Object} options\n * @returns {TransportConnection}\n */\n createConnection(\n name: string,\n priority: number,\n key: string,\n options: Object\n ): TransportConnection {\n options = Collections.extend({}, options, {\n activityTimeout: this.pingDelay\n });\n var connection = this.transport.createConnection(\n name,\n priority,\n key,\n options\n );\n\n var openTimestamp = null;\n\n var onOpen = function() {\n connection.unbind('open', onOpen);\n connection.bind('closed', onClosed);\n openTimestamp = Util.now();\n };\n var onClosed = closeEvent => {\n connection.unbind('closed', onClosed);\n\n if (closeEvent.code === 1002 || closeEvent.code === 1003) {\n // we don't want to use transports not obeying the protocol\n this.manager.reportDeath();\n } else if (!closeEvent.wasClean && openTimestamp) {\n // report deaths only for short-living transport\n var lifespan = Util.now() - openTimestamp;\n if (lifespan < 2 * this.maxPingDelay) {\n this.manager.reportDeath();\n this.pingDelay = Math.max(lifespan / 2, this.minPingDelay);\n }\n }\n };\n\n connection.bind('open', onOpen);\n return connection;\n }\n\n /** Returns whether the transport is supported in the environment.\n *\n * This function has the same API as Transport#isSupported. Might return false\n * when the manager decides to kill the transport.\n *\n * @param {Object} environment the environment details (encryption, settings)\n * @returns {Boolean} true when the transport is supported\n */\n isSupported(environment: string): boolean {\n return this.manager.isAlive() && this.transport.isSupported(environment);\n }\n}\n","import Action from './action';\nimport { PusherEvent } from './message-types';\n/**\n * Provides functions for handling Pusher protocol-specific messages.\n */\n\nconst Protocol = {\n /**\n * Decodes a message in a Pusher format.\n *\n * The MessageEvent we receive from the transport should contain a pusher event\n * (https://pusher.com/docs/pusher_protocol#events) serialized as JSON in the\n * data field\n *\n * The pusher event may contain a data field too, and it may also be\n * serialised as JSON\n *\n * Throws errors when messages are not parse'able.\n *\n * @param {MessageEvent} messageEvent\n * @return {PusherEvent}\n */\n decodeMessage: function(messageEvent: MessageEvent): PusherEvent {\n try {\n var messageData = JSON.parse(messageEvent.data);\n var pusherEventData = messageData.data;\n if (typeof pusherEventData === 'string') {\n try {\n pusherEventData = JSON.parse(messageData.data);\n } catch (e) {}\n }\n var pusherEvent: PusherEvent = {\n event: messageData.event,\n channel: messageData.channel,\n data: pusherEventData\n };\n if (messageData.user_id) {\n pusherEvent.user_id = messageData.user_id;\n }\n return pusherEvent;\n } catch (e) {\n throw { type: 'MessageParseError', error: e, data: messageEvent.data };\n }\n },\n\n /**\n * Encodes a message to be sent.\n *\n * @param {PusherEvent} event\n * @return {String}\n */\n encodeMessage: function(event: PusherEvent): string {\n return JSON.stringify(event);\n },\n\n /**\n * Processes a handshake message and returns appropriate actions.\n *\n * Returns an object with an 'action' and other action-specific properties.\n *\n * There are three outcomes when calling this function. First is a successful\n * connection attempt, when pusher:connection_established is received, which\n * results in a 'connected' action with an 'id' property. When passed a\n * pusher:error event, it returns a result with action appropriate to the\n * close code and an error. Otherwise, it raises an exception.\n *\n * @param {String} message\n * @result Object\n */\n processHandshake: function(messageEvent: MessageEvent): Action {\n var message = Protocol.decodeMessage(messageEvent);\n\n if (message.event === 'pusher:connection_established') {\n if (!message.data.activity_timeout) {\n throw 'No activity timeout specified in handshake';\n }\n return {\n action: 'connected',\n id: message.data.socket_id,\n activityTimeout: message.data.activity_timeout * 1000\n };\n } else if (message.event === 'pusher:error') {\n // From protocol 6 close codes are sent only once, so this only\n // happens when connection does not support close codes\n return {\n action: this.getCloseAction(message.data),\n error: this.getCloseError(message.data)\n };\n } else {\n throw 'Invalid handshake';\n }\n },\n\n /**\n * Dispatches the close event and returns an appropriate action name.\n *\n * See:\n * 1. https://developer.mozilla.org/en-US/docs/WebSockets/WebSockets_reference/CloseEvent\n * 2. http://pusher.com/docs/pusher_protocol\n *\n * @param {CloseEvent} closeEvent\n * @return {String} close action name\n */\n getCloseAction: function(closeEvent): string {\n if (closeEvent.code < 4000) {\n // ignore 1000 CLOSE_NORMAL, 1001 CLOSE_GOING_AWAY,\n // 1005 CLOSE_NO_STATUS, 1006 CLOSE_ABNORMAL\n // ignore 1007...3999\n // handle 1002 CLOSE_PROTOCOL_ERROR, 1003 CLOSE_UNSUPPORTED,\n // 1004 CLOSE_TOO_LARGE\n if (closeEvent.code >= 1002 && closeEvent.code <= 1004) {\n return 'backoff';\n } else {\n return null;\n }\n } else if (closeEvent.code === 4000) {\n return 'tls_only';\n } else if (closeEvent.code < 4100) {\n return 'refused';\n } else if (closeEvent.code < 4200) {\n return 'backoff';\n } else if (closeEvent.code < 4300) {\n return 'retry';\n } else {\n // unknown error\n return 'refused';\n }\n },\n\n /**\n * Returns an error or null basing on the close event.\n *\n * Null is returned when connection was closed cleanly. Otherwise, an object\n * with error details is returned.\n *\n * @param {CloseEvent} closeEvent\n * @return {Object} error object\n */\n getCloseError: function(closeEvent): any {\n if (closeEvent.code !== 1000 && closeEvent.code !== 1001) {\n return {\n type: 'PusherError',\n data: {\n code: closeEvent.code,\n message: closeEvent.reason || closeEvent.message\n }\n };\n } else {\n return null;\n }\n }\n};\n\nexport default Protocol;\n","import * as Collections from '../utils/collections';\nimport { default as EventsDispatcher } from '../events/dispatcher';\nimport Protocol from './protocol/protocol';\nimport { PusherEvent } from './protocol/message-types';\nimport Logger from '../logger';\nimport TransportConnection from '../transports/transport_connection';\nimport Socket from '../socket';\n/**\n * Provides Pusher protocol interface for transports.\n *\n * Emits following events:\n * - message - on received messages\n * - ping - on ping requests\n * - pong - on pong responses\n * - error - when the transport emits an error\n * - closed - after closing the transport\n *\n * It also emits more events when connection closes with a code.\n * See Protocol.getCloseAction to get more details.\n *\n * @param {Number} id\n * @param {AbstractTransport} transport\n */\nexport default class Connection extends EventsDispatcher implements Socket {\n id: string;\n transport: TransportConnection;\n activityTimeout: number;\n\n constructor(id: string, transport: TransportConnection) {\n super();\n this.id = id;\n this.transport = transport;\n this.activityTimeout = transport.activityTimeout;\n this.bindListeners();\n }\n\n /** Returns whether used transport handles activity checks by itself\n *\n * @returns {Boolean} true if activity checks are handled by the transport\n */\n handlesActivityChecks() {\n return this.transport.handlesActivityChecks();\n }\n\n /** Sends raw data.\n *\n * @param {String} data\n */\n send(data: any): boolean {\n return this.transport.send(data);\n }\n\n /** Sends an event.\n *\n * @param {String} name\n * @param {String} data\n * @param {String} [channel]\n * @returns {Boolean} whether message was sent or not\n */\n send_event(name: string, data: any, channel?: string): boolean {\n var event: PusherEvent = { event: name, data: data };\n if (channel) {\n event.channel = channel;\n }\n Logger.debug('Event sent', event);\n return this.send(Protocol.encodeMessage(event));\n }\n\n /** Sends a ping message to the server.\n *\n * Basing on the underlying transport, it might send either transport's\n * protocol-specific ping or pusher:ping event.\n */\n ping() {\n if (this.transport.supportsPing()) {\n this.transport.ping();\n } else {\n this.send_event('pusher:ping', {});\n }\n }\n\n /** Closes the connection. */\n close() {\n this.transport.close();\n }\n\n private bindListeners() {\n var listeners = {\n message: (messageEvent: MessageEvent) => {\n var pusherEvent;\n try {\n pusherEvent = Protocol.decodeMessage(messageEvent);\n } catch (e) {\n this.emit('error', {\n type: 'MessageParseError',\n error: e,\n data: messageEvent.data\n });\n }\n\n if (pusherEvent !== undefined) {\n Logger.debug('Event recd', pusherEvent);\n\n switch (pusherEvent.event) {\n case 'pusher:error':\n this.emit('error', {\n type: 'PusherError',\n data: pusherEvent.data\n });\n break;\n case 'pusher:ping':\n this.emit('ping');\n break;\n case 'pusher:pong':\n this.emit('pong');\n break;\n }\n this.emit('message', pusherEvent);\n }\n },\n activity: () => {\n this.emit('activity');\n },\n error: error => {\n this.emit('error', error);\n },\n closed: closeEvent => {\n unbindListeners();\n\n if (closeEvent && closeEvent.code) {\n this.handleCloseEvent(closeEvent);\n }\n\n this.transport = null;\n this.emit('closed');\n }\n };\n\n var unbindListeners = () => {\n Collections.objectApply(listeners, (listener, event) => {\n this.transport.unbind(event, listener);\n });\n };\n\n Collections.objectApply(listeners, (listener, event) => {\n this.transport.bind(event, listener);\n });\n }\n\n private handleCloseEvent(closeEvent: any) {\n var action = Protocol.getCloseAction(closeEvent);\n var error = Protocol.getCloseError(closeEvent);\n if (error) {\n this.emit('error', error);\n }\n if (action) {\n this.emit(action, { action: action, error: error });\n }\n }\n}\n","import Util from '../../util';\nimport * as Collections from '../../utils/collections';\nimport Protocol from '../protocol/protocol';\nimport Connection from '../connection';\nimport TransportConnection from '../../transports/transport_connection';\nimport HandshakePayload from './handshake_payload';\n\n/**\n * Handles Pusher protocol handshakes for transports.\n *\n * Calls back with a result object after handshake is completed. Results\n * always have two fields:\n * - action - string describing action to be taken after the handshake\n * - transport - the transport object passed to the constructor\n *\n * Different actions can set different additional properties on the result.\n * In the case of 'connected' action, there will be a 'connection' property\n * containing a Connection object for the transport. Other actions should\n * carry an 'error' property.\n *\n * @param {AbstractTransport} transport\n * @param {Function} callback\n */\nexport default class Handshake {\n transport: TransportConnection;\n callback: (HandshakePayload) => void;\n onMessage: Function;\n onClosed: Function;\n\n constructor(\n transport: TransportConnection,\n callback: (HandshakePayload) => void\n ) {\n this.transport = transport;\n this.callback = callback;\n this.bindListeners();\n }\n\n close() {\n this.unbindListeners();\n this.transport.close();\n }\n\n private bindListeners() {\n this.onMessage = m => {\n this.unbindListeners();\n\n var result;\n try {\n result = Protocol.processHandshake(m);\n } catch (e) {\n this.finish('error', { error: e });\n this.transport.close();\n return;\n }\n\n if (result.action === 'connected') {\n this.finish('connected', {\n connection: new Connection(result.id, this.transport),\n activityTimeout: result.activityTimeout\n });\n } else {\n this.finish(result.action, { error: result.error });\n this.transport.close();\n }\n };\n\n this.onClosed = closeEvent => {\n this.unbindListeners();\n\n var action = Protocol.getCloseAction(closeEvent) || 'backoff';\n var error = Protocol.getCloseError(closeEvent);\n this.finish(action, { error: error });\n };\n\n this.transport.bind('message', this.onMessage);\n this.transport.bind('closed', this.onClosed);\n }\n\n private unbindListeners() {\n this.transport.unbind('message', this.onMessage);\n this.transport.unbind('closed', this.onClosed);\n }\n\n private finish(action: string, params: any) {\n this.callback(\n Collections.extend({ transport: this.transport, action: action }, params)\n );\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport base64encode from '../base64';\nimport Timeline from './timeline';\nimport Runtime from 'runtime';\n\nexport interface TimelineSenderOptions {\n host?: string;\n port?: number;\n path?: string;\n}\n\nexport default class TimelineSender {\n timeline: Timeline;\n options: TimelineSenderOptions;\n host: string;\n\n constructor(timeline: Timeline, options: TimelineSenderOptions) {\n this.timeline = timeline;\n this.options = options || {};\n }\n\n send(useTLS: boolean, callback?: Function) {\n if (this.timeline.isEmpty()) {\n return;\n }\n\n this.timeline.send(\n Runtime.TimelineTransport.getAgent(this, useTLS),\n callback\n );\n }\n}\n","/** Error classes used throughout the library. */\n// https://github.com/Microsoft/TypeScript-wiki/blob/master/Breaking-Changes.md#extending-built-ins-like-error-array-and-map-may-no-longer-work\nexport class BadEventName extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\nexport class BadChannelName extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\nexport class RequestTimedOut extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class TransportPriorityTooLow extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class TransportClosed extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class UnsupportedFeature extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class UnsupportedTransport extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class UnsupportedStrategy extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class HTTPAuthError extends Error {\n status: number;\n constructor(status: number, msg?: string) {\n super(msg);\n this.status = status;\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n","/**\n * A place to store help URLs for error messages etc\n */\n\nconst urlStore = {\n baseUrl: 'https://pusher.com',\n urls: {\n authenticationEndpoint: {\n path: '/docs/channels/server_api/authenticating_users'\n },\n authorizationEndpoint: {\n path: '/docs/channels/server_api/authorizing-users/'\n },\n javascriptQuickStart: {\n path: '/docs/javascript_quick_start'\n },\n triggeringClientEvents: {\n path: '/docs/client_api_guide/client_events#trigger-events'\n },\n encryptedChannelSupport: {\n fullUrl:\n 'https://github.com/pusher/pusher-js/tree/cc491015371a4bde5743d1c87a0fbac0feb53195#encrypted-channel-support'\n }\n }\n};\n\n/** Builds a consistent string with links to pusher documentation\n *\n * @param {string} key - relevant key in the url_store.urls object\n * @return {string} suffix string to append to log message\n */\nconst buildLogSuffix = function(key: string): string {\n const urlPrefix = 'See:';\n const urlObj = urlStore.urls[key];\n if (!urlObj) return '';\n\n let url;\n if (urlObj.fullUrl) {\n url = urlObj.fullUrl;\n } else if (urlObj.path) {\n url = urlStore.baseUrl + urlObj.path;\n }\n\n if (!url) return '';\n return `${urlPrefix} ${url}`;\n};\n\nexport default { buildLogSuffix };\n","import { default as EventsDispatcher } from '../events/dispatcher';\nimport * as Errors from '../errors';\nimport Logger from '../logger';\nimport Pusher from '../pusher';\nimport { PusherEvent } from '../connection/protocol/message-types';\nimport Metadata from './metadata';\nimport UrlStore from '../utils/url_store';\nimport {\n ChannelAuthorizationData,\n ChannelAuthorizationCallback\n} from '../auth/options';\nimport { HTTPAuthError } from '../errors';\n\n/** Provides base public channel interface with an event emitter.\n *\n * Emits:\n * - pusher:subscription_succeeded - after subscribing successfully\n * - other non-internal events\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\nexport default class Channel extends EventsDispatcher {\n name: string;\n pusher: Pusher;\n subscribed: boolean;\n subscriptionPending: boolean;\n subscriptionCancelled: boolean;\n subscriptionCount: null;\n\n constructor(name: string, pusher: Pusher) {\n super(function(event, data) {\n Logger.debug('No callbacks on ' + name + ' for ' + event);\n });\n\n this.name = name;\n this.pusher = pusher;\n this.subscribed = false;\n this.subscriptionPending = false;\n this.subscriptionCancelled = false;\n }\n\n /** Skips authorization, since public channels don't require it.\n *\n * @param {Function} callback\n */\n authorize(socketId: string, callback: ChannelAuthorizationCallback) {\n return callback(null, { auth: '' });\n }\n\n /** Triggers an event */\n trigger(event: string, data: any) {\n if (event.indexOf('client-') !== 0) {\n throw new Errors.BadEventName(\n \"Event '\" + event + \"' does not start with 'client-'\"\n );\n }\n if (!this.subscribed) {\n var suffix = UrlStore.buildLogSuffix('triggeringClientEvents');\n Logger.warn(\n `Client event triggered before channel 'subscription_succeeded' event . ${suffix}`\n );\n }\n return this.pusher.send_event(event, data, this.name);\n }\n\n /** Signals disconnection to the channel. For internal use only. */\n disconnect() {\n this.subscribed = false;\n this.subscriptionPending = false;\n }\n\n /** Handles a PusherEvent. For internal use only.\n *\n * @param {PusherEvent} event\n */\n handleEvent(event: PusherEvent) {\n var eventName = event.event;\n var data = event.data;\n if (eventName === 'pusher_internal:subscription_succeeded') {\n this.handleSubscriptionSucceededEvent(event);\n } else if (eventName === 'pusher_internal:subscription_count') {\n this.handleSubscriptionCountEvent(event);\n } else if (eventName.indexOf('pusher_internal:') !== 0) {\n var metadata: Metadata = {};\n this.emit(eventName, data, metadata);\n }\n }\n\n handleSubscriptionSucceededEvent(event: PusherEvent) {\n this.subscriptionPending = false;\n this.subscribed = true;\n if (this.subscriptionCancelled) {\n this.pusher.unsubscribe(this.name);\n } else {\n this.emit('pusher:subscription_succeeded', event.data);\n }\n }\n\n handleSubscriptionCountEvent(event: PusherEvent) {\n if (event.data.subscription_count) {\n this.subscriptionCount = event.data.subscription_count;\n }\n\n this.emit('pusher:subscription_count', event.data);\n }\n\n /** Sends a subscription request. For internal use only. */\n subscribe() {\n if (this.subscribed) {\n return;\n }\n this.subscriptionPending = true;\n this.subscriptionCancelled = false;\n this.authorize(\n this.pusher.connection.socket_id,\n (error: Error | null, data: ChannelAuthorizationData) => {\n if (error) {\n this.subscriptionPending = false;\n // Why not bind to 'pusher:subscription_error' a level up, and log there?\n // Binding to this event would cause the warning about no callbacks being\n // bound (see constructor) to be suppressed, that's not what we want.\n Logger.error(error.toString());\n this.emit(\n 'pusher:subscription_error',\n Object.assign(\n {},\n {\n type: 'AuthError',\n error: error.message\n },\n error instanceof HTTPAuthError ? { status: error.status } : {}\n )\n );\n } else {\n this.pusher.send_event('pusher:subscribe', {\n auth: data.auth,\n channel_data: data.channel_data,\n channel: this.name\n });\n }\n }\n );\n }\n\n /** Sends an unsubscription request. For internal use only. */\n unsubscribe() {\n this.subscribed = false;\n this.pusher.send_event('pusher:unsubscribe', {\n channel: this.name\n });\n }\n\n /** Cancels an in progress subscription. For internal use only. */\n cancelSubscription() {\n this.subscriptionCancelled = true;\n }\n\n /** Reinstates an in progress subscripiton. For internal use only. */\n reinstateSubscription() {\n this.subscriptionCancelled = false;\n }\n}\n","import Factory from '../utils/factory';\nimport Channel from './channel';\nimport { ChannelAuthorizationCallback } from '../auth/options';\n\n/** Extends public channels to provide private channel interface.\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\nexport default class PrivateChannel extends Channel {\n /** Authorizes the connection to use the channel.\n *\n * @param {String} socketId\n * @param {Function} callback\n */\n authorize(socketId: string, callback: ChannelAuthorizationCallback) {\n return this.pusher.config.channelAuthorizer(\n {\n channelName: this.name,\n socketId: socketId\n },\n callback\n );\n }\n}\n","import * as Collections from '../utils/collections';\n\n/** Represents a collection of members of a presence channel. */\nexport default class Members {\n members: any;\n count: number;\n myID: any;\n me: any;\n\n constructor() {\n this.reset();\n }\n\n /** Returns member's info for given id.\n *\n * Resulting object containts two fields - id and info.\n *\n * @param {Number} id\n * @return {Object} member's info or null\n */\n get(id: string): any {\n if (Object.prototype.hasOwnProperty.call(this.members, id)) {\n return {\n id: id,\n info: this.members[id]\n };\n } else {\n return null;\n }\n }\n\n /** Calls back for each member in unspecified order.\n *\n * @param {Function} callback\n */\n each(callback: Function) {\n Collections.objectApply(this.members, (member, id) => {\n callback(this.get(id));\n });\n }\n\n /** Updates the id for connected member. For internal use only. */\n setMyID(id: string) {\n this.myID = id;\n }\n\n /** Handles subscription data. For internal use only. */\n onSubscription(subscriptionData: any) {\n this.members = subscriptionData.presence.hash;\n this.count = subscriptionData.presence.count;\n this.me = this.get(this.myID);\n }\n\n /** Adds a new member to the collection. For internal use only. */\n addMember(memberData: any) {\n if (this.get(memberData.user_id) === null) {\n this.count++;\n }\n this.members[memberData.user_id] = memberData.user_info;\n return this.get(memberData.user_id);\n }\n\n /** Adds a member from the collection. For internal use only. */\n removeMember(memberData: any) {\n var member = this.get(memberData.user_id);\n if (member) {\n delete this.members[memberData.user_id];\n this.count--;\n }\n return member;\n }\n\n /** Resets the collection to the initial state. For internal use only. */\n reset() {\n this.members = {};\n this.count = 0;\n this.myID = null;\n this.me = null;\n }\n}\n","import PrivateChannel from './private_channel';\nimport Logger from '../logger';\nimport Members from './members';\nimport Pusher from '../pusher';\nimport UrlStore from 'core/utils/url_store';\nimport { PusherEvent } from '../connection/protocol/message-types';\nimport Metadata from './metadata';\nimport { ChannelAuthorizationData } from '../auth/options';\n\nexport default class PresenceChannel extends PrivateChannel {\n members: Members;\n\n /** Adds presence channel functionality to private channels.\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\n constructor(name: string, pusher: Pusher) {\n super(name, pusher);\n this.members = new Members();\n }\n\n /** Authorizes the connection as a member of the channel.\n *\n * @param {String} socketId\n * @param {Function} callback\n */\n authorize(socketId: string, callback: Function) {\n super.authorize(socketId, async (error, authData) => {\n if (!error) {\n authData = authData as ChannelAuthorizationData;\n if (authData.channel_data != null) {\n var channelData = JSON.parse(authData.channel_data);\n this.members.setMyID(channelData.user_id);\n } else {\n await this.pusher.user.signinDonePromise;\n if (this.pusher.user.user_data != null) {\n // If the user is signed in, get the id of the authenticated user\n // and allow the presence authorization to continue.\n this.members.setMyID(this.pusher.user.user_data.id);\n } else {\n let suffix = UrlStore.buildLogSuffix('authorizationEndpoint');\n Logger.error(\n `Invalid auth response for channel '${this.name}', ` +\n `expected 'channel_data' field. ${suffix}, ` +\n `or the user should be signed in.`\n );\n callback('Invalid auth response');\n return;\n }\n }\n }\n callback(error, authData);\n });\n }\n\n /** Handles presence and subscription events. For internal use only.\n *\n * @param {PusherEvent} event\n */\n handleEvent(event: PusherEvent) {\n var eventName = event.event;\n if (eventName.indexOf('pusher_internal:') === 0) {\n this.handleInternalEvent(event);\n } else {\n var data = event.data;\n var metadata: Metadata = {};\n if (event.user_id) {\n metadata.user_id = event.user_id;\n }\n this.emit(eventName, data, metadata);\n }\n }\n handleInternalEvent(event: PusherEvent) {\n var eventName = event.event;\n var data = event.data;\n switch (eventName) {\n case 'pusher_internal:subscription_succeeded':\n this.handleSubscriptionSucceededEvent(event);\n break;\n case 'pusher_internal:subscription_count':\n this.handleSubscriptionCountEvent(event);\n break;\n case 'pusher_internal:member_added':\n var addedMember = this.members.addMember(data);\n this.emit('pusher:member_added', addedMember);\n break;\n case 'pusher_internal:member_removed':\n var removedMember = this.members.removeMember(data);\n if (removedMember) {\n this.emit('pusher:member_removed', removedMember);\n }\n break;\n }\n }\n\n handleSubscriptionSucceededEvent(event: PusherEvent) {\n this.subscriptionPending = false;\n this.subscribed = true;\n if (this.subscriptionCancelled) {\n this.pusher.unsubscribe(this.name);\n } else {\n this.members.onSubscription(event.data);\n this.emit('pusher:subscription_succeeded', this.members);\n }\n }\n\n /** Resets the channel state, including members map. For internal use only. */\n disconnect() {\n this.members.reset();\n super.disconnect();\n }\n}\n","import PrivateChannel from './private_channel';\nimport * as Errors from '../errors';\nimport Logger from '../logger';\nimport Pusher from '../pusher';\nimport { decode as encodeUTF8 } from '@stablelib/utf8';\nimport { decode as decodeBase64 } from '@stablelib/base64';\nimport Dispatcher from '../events/dispatcher';\nimport { PusherEvent } from '../connection/protocol/message-types';\nimport {\n ChannelAuthorizationData,\n ChannelAuthorizationCallback\n} from '../auth/options';\nimport * as nacl from 'tweetnacl';\n\n/** Extends private channels to provide encrypted channel interface.\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\nexport default class EncryptedChannel extends PrivateChannel {\n key: Uint8Array = null;\n nacl: nacl;\n\n constructor(name: string, pusher: Pusher, nacl: nacl) {\n super(name, pusher);\n this.nacl = nacl;\n }\n\n /** Authorizes the connection to use the channel.\n *\n * @param {String} socketId\n * @param {Function} callback\n */\n authorize(socketId: string, callback: ChannelAuthorizationCallback) {\n super.authorize(\n socketId,\n (error: Error | null, authData: ChannelAuthorizationData) => {\n if (error) {\n callback(error, authData);\n return;\n }\n let sharedSecret = authData['shared_secret'];\n if (!sharedSecret) {\n callback(\n new Error(\n `No shared_secret key in auth payload for encrypted channel: ${this.name}`\n ),\n null\n );\n return;\n }\n this.key = decodeBase64(sharedSecret);\n delete authData['shared_secret'];\n callback(null, authData);\n }\n );\n }\n\n trigger(event: string, data: any): boolean {\n throw new Errors.UnsupportedFeature(\n 'Client events are not currently supported for encrypted channels'\n );\n }\n\n /** Handles an event. For internal use only.\n *\n * @param {PusherEvent} event\n */\n handleEvent(event: PusherEvent) {\n var eventName = event.event;\n var data = event.data;\n if (\n eventName.indexOf('pusher_internal:') === 0 ||\n eventName.indexOf('pusher:') === 0\n ) {\n super.handleEvent(event);\n return;\n }\n this.handleEncryptedEvent(eventName, data);\n }\n\n private handleEncryptedEvent(event: string, data: any): void {\n if (!this.key) {\n Logger.debug(\n 'Received encrypted event before key has been retrieved from the authEndpoint'\n );\n return;\n }\n if (!data.ciphertext || !data.nonce) {\n Logger.error(\n 'Unexpected format for encrypted event, expected object with `ciphertext` and `nonce` fields, got: ' +\n data\n );\n return;\n }\n let cipherText = decodeBase64(data.ciphertext);\n if (cipherText.length < this.nacl.secretbox.overheadLength) {\n Logger.error(\n `Expected encrypted event ciphertext length to be ${this.nacl.secretbox.overheadLength}, got: ${cipherText.length}`\n );\n return;\n }\n let nonce = decodeBase64(data.nonce);\n if (nonce.length < this.nacl.secretbox.nonceLength) {\n Logger.error(\n `Expected encrypted event nonce length to be ${this.nacl.secretbox.nonceLength}, got: ${nonce.length}`\n );\n return;\n }\n\n let bytes = this.nacl.secretbox.open(cipherText, nonce, this.key);\n if (bytes === null) {\n Logger.debug(\n 'Failed to decrypt an event, probably because it was encrypted with a different key. Fetching a new key from the authEndpoint...'\n );\n // Try a single time to retrieve a new auth key and decrypt the event with it\n // If this fails, a new key will be requested when a new message is received\n this.authorize(this.pusher.connection.socket_id, (error, authData) => {\n if (error) {\n Logger.error(\n `Failed to make a request to the authEndpoint: ${authData}. Unable to fetch new key, so dropping encrypted event`\n );\n return;\n }\n bytes = this.nacl.secretbox.open(cipherText, nonce, this.key);\n if (bytes === null) {\n Logger.error(\n `Failed to decrypt event with new key. Dropping encrypted event`\n );\n return;\n }\n this.emit(event, this.getDataToEmit(bytes));\n return;\n });\n return;\n }\n this.emit(event, this.getDataToEmit(bytes));\n }\n\n // Try and parse the decrypted bytes as JSON. If we can't parse it, just\n // return the utf-8 string\n getDataToEmit(bytes: Uint8Array): string {\n let raw = encodeUTF8(bytes);\n try {\n return JSON.parse(raw);\n } catch {\n return raw;\n }\n }\n}\n","import { default as EventsDispatcher } from '../events/dispatcher';\nimport { OneOffTimer as Timer } from '../utils/timers';\nimport { Config } from '../config';\nimport Logger from '../logger';\nimport HandshakePayload from './handshake/handshake_payload';\nimport Connection from './connection';\nimport Strategy from '../strategies/strategy';\nimport StrategyRunner from '../strategies/strategy_runner';\nimport * as Collections from '../utils/collections';\nimport Timeline from '../timeline/timeline';\nimport ConnectionManagerOptions from './connection_manager_options';\nimport Runtime from 'runtime';\n\nimport {\n ErrorCallbacks,\n HandshakeCallbacks,\n ConnectionCallbacks\n} from './callbacks';\nimport Action from './protocol/action';\n\n/** Manages connection to Pusher.\n *\n * Uses a strategy (currently only default), timers and network availability\n * info to establish a connection and export its state. In case of failures,\n * manages reconnection attempts.\n *\n * Exports state changes as following events:\n * - \"state_change\", { previous: p, current: state }\n * - state\n *\n * States:\n * - initialized - initial state, never transitioned to\n * - connecting - connection is being established\n * - connected - connection has been fully established\n * - disconnected - on requested disconnection\n * - unavailable - after connection timeout or when there's no network\n * - failed - when the connection strategy is not supported\n *\n * Options:\n * - unavailableTimeout - time to transition to unavailable state\n * - activityTimeout - time after which ping message should be sent\n * - pongTimeout - time for Pusher to respond with pong before reconnecting\n *\n * @param {String} key application key\n * @param {Object} options\n */\nexport default class ConnectionManager extends EventsDispatcher {\n key: string;\n options: ConnectionManagerOptions;\n state: string;\n connection: Connection;\n usingTLS: boolean;\n timeline: Timeline;\n socket_id: string;\n unavailableTimer: Timer;\n activityTimer: Timer;\n retryTimer: Timer;\n activityTimeout: number;\n strategy: Strategy;\n runner: StrategyRunner;\n errorCallbacks: ErrorCallbacks;\n handshakeCallbacks: HandshakeCallbacks;\n connectionCallbacks: ConnectionCallbacks;\n\n constructor(key: string, options: ConnectionManagerOptions) {\n super();\n this.state = 'initialized';\n this.connection = null;\n\n this.key = key;\n this.options = options;\n this.timeline = this.options.timeline;\n this.usingTLS = this.options.useTLS;\n\n this.errorCallbacks = this.buildErrorCallbacks();\n this.connectionCallbacks = this.buildConnectionCallbacks(\n this.errorCallbacks\n );\n this.handshakeCallbacks = this.buildHandshakeCallbacks(this.errorCallbacks);\n\n var Network = Runtime.getNetwork();\n\n Network.bind('online', () => {\n this.timeline.info({ netinfo: 'online' });\n if (this.state === 'connecting' || this.state === 'unavailable') {\n this.retryIn(0);\n }\n });\n Network.bind('offline', () => {\n this.timeline.info({ netinfo: 'offline' });\n if (this.connection) {\n this.sendActivityCheck();\n }\n });\n\n this.updateStrategy();\n }\n\n switchCluster(key: string) {\n this.key = key;\n // This ensures that the new config coming from\n // pusher instance are taken into account\n // such as appKey and cluster\n this.updateStrategy();\n this.retryIn(0);\n }\n\n /** Establishes a connection to Pusher.\n *\n * Does nothing when connection is already established. See top-level doc\n * to find events emitted on connection attempts.\n */\n connect() {\n if (this.connection || this.runner) {\n return;\n }\n if (!this.strategy.isSupported()) {\n this.updateState('failed');\n return;\n }\n this.updateState('connecting');\n this.startConnecting();\n this.setUnavailableTimer();\n }\n\n /** Sends raw data.\n *\n * @param {String} data\n */\n send(data) {\n if (this.connection) {\n return this.connection.send(data);\n } else {\n return false;\n }\n }\n\n /** Sends an event.\n *\n * @param {String} name\n * @param {String} data\n * @param {String} [channel]\n * @returns {Boolean} whether message was sent or not\n */\n send_event(name: string, data: any, channel?: string) {\n if (this.connection) {\n return this.connection.send_event(name, data, channel);\n } else {\n return false;\n }\n }\n\n /** Closes the connection. */\n disconnect() {\n this.disconnectInternally();\n this.updateState('disconnected');\n }\n\n isUsingTLS() {\n return this.usingTLS;\n }\n\n private startConnecting() {\n var callback = (error, handshake) => {\n if (error) {\n this.runner = this.strategy.connect(0, callback);\n } else {\n if (handshake.action === 'error') {\n this.emit('error', {\n type: 'HandshakeError',\n error: handshake.error\n });\n this.timeline.error({ handshakeError: handshake.error });\n } else {\n this.abortConnecting(); // we don't support switching connections yet\n this.handshakeCallbacks[handshake.action](handshake);\n }\n }\n };\n this.runner = this.strategy.connect(0, callback);\n }\n\n private abortConnecting() {\n if (this.runner) {\n this.runner.abort();\n this.runner = null;\n }\n }\n\n private disconnectInternally() {\n this.abortConnecting();\n this.clearRetryTimer();\n this.clearUnavailableTimer();\n if (this.connection) {\n var connection = this.abandonConnection();\n connection.close();\n }\n }\n\n private updateStrategy() {\n this.strategy = this.options.getStrategy({\n key: this.key,\n timeline: this.timeline,\n useTLS: this.usingTLS\n });\n }\n\n private retryIn(delay) {\n this.timeline.info({ action: 'retry', delay: delay });\n if (delay > 0) {\n this.emit('connecting_in', Math.round(delay / 1000));\n }\n this.retryTimer = new Timer(delay || 0, () => {\n this.disconnectInternally();\n this.connect();\n });\n }\n\n private clearRetryTimer() {\n if (this.retryTimer) {\n this.retryTimer.ensureAborted();\n this.retryTimer = null;\n }\n }\n\n private setUnavailableTimer() {\n this.unavailableTimer = new Timer(this.options.unavailableTimeout, () => {\n this.updateState('unavailable');\n });\n }\n\n private clearUnavailableTimer() {\n if (this.unavailableTimer) {\n this.unavailableTimer.ensureAborted();\n }\n }\n\n private sendActivityCheck() {\n this.stopActivityCheck();\n this.connection.ping();\n // wait for pong response\n this.activityTimer = new Timer(this.options.pongTimeout, () => {\n this.timeline.error({ pong_timed_out: this.options.pongTimeout });\n this.retryIn(0);\n });\n }\n\n private resetActivityCheck() {\n this.stopActivityCheck();\n // send ping after inactivity\n if (this.connection && !this.connection.handlesActivityChecks()) {\n this.activityTimer = new Timer(this.activityTimeout, () => {\n this.sendActivityCheck();\n });\n }\n }\n\n private stopActivityCheck() {\n if (this.activityTimer) {\n this.activityTimer.ensureAborted();\n }\n }\n\n private buildConnectionCallbacks(\n errorCallbacks: ErrorCallbacks\n ): ConnectionCallbacks {\n return Collections.extend({}, errorCallbacks, {\n message: message => {\n // includes pong messages from server\n this.resetActivityCheck();\n this.emit('message', message);\n },\n ping: () => {\n this.send_event('pusher:pong', {});\n },\n activity: () => {\n this.resetActivityCheck();\n },\n error: error => {\n // just emit error to user - socket will already be closed by browser\n this.emit('error', error);\n },\n closed: () => {\n this.abandonConnection();\n if (this.shouldRetry()) {\n this.retryIn(1000);\n }\n }\n });\n }\n\n private buildHandshakeCallbacks(\n errorCallbacks: ErrorCallbacks\n ): HandshakeCallbacks {\n return Collections.extend({}, errorCallbacks, {\n connected: (handshake: HandshakePayload) => {\n this.activityTimeout = Math.min(\n this.options.activityTimeout,\n handshake.activityTimeout,\n handshake.connection.activityTimeout || Infinity\n );\n this.clearUnavailableTimer();\n this.setConnection(handshake.connection);\n this.socket_id = this.connection.id;\n this.updateState('connected', { socket_id: this.socket_id });\n }\n });\n }\n\n private buildErrorCallbacks(): ErrorCallbacks {\n let withErrorEmitted = callback => {\n return (result: Action | HandshakePayload) => {\n if (result.error) {\n this.emit('error', { type: 'WebSocketError', error: result.error });\n }\n callback(result);\n };\n };\n\n return {\n tls_only: withErrorEmitted(() => {\n this.usingTLS = true;\n this.updateStrategy();\n this.retryIn(0);\n }),\n refused: withErrorEmitted(() => {\n this.disconnect();\n }),\n backoff: withErrorEmitted(() => {\n this.retryIn(1000);\n }),\n retry: withErrorEmitted(() => {\n this.retryIn(0);\n })\n };\n }\n\n private setConnection(connection) {\n this.connection = connection;\n for (var event in this.connectionCallbacks) {\n this.connection.bind(event, this.connectionCallbacks[event]);\n }\n this.resetActivityCheck();\n }\n\n private abandonConnection() {\n if (!this.connection) {\n return;\n }\n this.stopActivityCheck();\n for (var event in this.connectionCallbacks) {\n this.connection.unbind(event, this.connectionCallbacks[event]);\n }\n var connection = this.connection;\n this.connection = null;\n return connection;\n }\n\n private updateState(newState: string, data?: any) {\n var previousState = this.state;\n this.state = newState;\n if (previousState !== newState) {\n var newStateDescription = newState;\n if (newStateDescription === 'connected') {\n newStateDescription += ' with new socket ID ' + data.socket_id;\n }\n Logger.debug(\n 'State changed',\n previousState + ' -> ' + newStateDescription\n );\n this.timeline.info({ state: newState, params: data });\n this.emit('state_change', { previous: previousState, current: newState });\n this.emit(newState, data);\n }\n }\n\n private shouldRetry(): boolean {\n return this.state === 'connecting' || this.state === 'connected';\n }\n}\n","import Channel from './channel';\nimport * as Collections from '../utils/collections';\nimport ChannelTable from './channel_table';\nimport Factory from '../utils/factory';\nimport Pusher from '../pusher';\nimport Logger from '../logger';\nimport * as Errors from '../errors';\nimport urlStore from '../utils/url_store';\n\n/** Handles a channel map. */\nexport default class Channels {\n channels: ChannelTable;\n\n constructor() {\n this.channels = {};\n }\n\n /** Creates or retrieves an existing channel by its name.\n *\n * @param {String} name\n * @param {Pusher} pusher\n * @return {Channel}\n */\n add(name: string, pusher: Pusher) {\n if (!this.channels[name]) {\n this.channels[name] = createChannel(name, pusher);\n }\n return this.channels[name];\n }\n\n /** Returns a list of all channels\n *\n * @return {Array}\n */\n all(): Channel[] {\n return Collections.values(this.channels);\n }\n\n /** Finds a channel by its name.\n *\n * @param {String} name\n * @return {Channel} channel or null if it doesn't exist\n */\n find(name: string) {\n return this.channels[name];\n }\n\n /** Removes a channel from the map.\n *\n * @param {String} name\n */\n remove(name: string) {\n var channel = this.channels[name];\n delete this.channels[name];\n return channel;\n }\n\n /** Proxies disconnection signal to all channels. */\n disconnect() {\n Collections.objectApply(this.channels, function(channel) {\n channel.disconnect();\n });\n }\n}\n\nfunction createChannel(name: string, pusher: Pusher): Channel {\n if (name.indexOf('private-encrypted-') === 0) {\n if (pusher.config.nacl) {\n return Factory.createEncryptedChannel(name, pusher, pusher.config.nacl);\n }\n let errMsg =\n 'Tried to subscribe to a private-encrypted- channel but no nacl implementation available';\n let suffix = urlStore.buildLogSuffix('encryptedChannelSupport');\n throw new Errors.UnsupportedFeature(`${errMsg}. ${suffix}`);\n } else if (name.indexOf('private-') === 0) {\n return Factory.createPrivateChannel(name, pusher);\n } else if (name.indexOf('presence-') === 0) {\n return Factory.createPresenceChannel(name, pusher);\n } else if (name.indexOf('#') === 0) {\n throw new Errors.BadChannelName(\n 'Cannot create a channel with name \"' + name + '\".'\n );\n } else {\n return Factory.createChannel(name, pusher);\n }\n}\n","import AssistantToTheTransportManager from '../transports/assistant_to_the_transport_manager';\nimport PingDelayOptions from '../transports/ping_delay_options';\nimport Transport from '../transports/transport';\nimport TransportManager from '../transports/transport_manager';\nimport Handshake from '../connection/handshake';\nimport TransportConnection from '../transports/transport_connection';\nimport SocketHooks from '../http/socket_hooks';\nimport HTTPSocket from '../http/http_socket';\n\nimport Timeline from '../timeline/timeline';\nimport {\n default as TimelineSender,\n TimelineSenderOptions\n} from '../timeline/timeline_sender';\nimport PresenceChannel from '../channels/presence_channel';\nimport PrivateChannel from '../channels/private_channel';\nimport EncryptedChannel from '../channels/encrypted_channel';\nimport Channel from '../channels/channel';\nimport ConnectionManager from '../connection/connection_manager';\nimport ConnectionManagerOptions from '../connection/connection_manager_options';\nimport Ajax from '../http/ajax';\nimport Channels from '../channels/channels';\nimport Pusher from '../pusher';\nimport { Config } from '../config';\nimport * as nacl from 'tweetnacl';\n\nvar Factory = {\n createChannels(): Channels {\n return new Channels();\n },\n\n createConnectionManager(\n key: string,\n options: ConnectionManagerOptions\n ): ConnectionManager {\n return new ConnectionManager(key, options);\n },\n\n createChannel(name: string, pusher: Pusher): Channel {\n return new Channel(name, pusher);\n },\n\n createPrivateChannel(name: string, pusher: Pusher): PrivateChannel {\n return new PrivateChannel(name, pusher);\n },\n\n createPresenceChannel(name: string, pusher: Pusher): PresenceChannel {\n return new PresenceChannel(name, pusher);\n },\n\n createEncryptedChannel(\n name: string,\n pusher: Pusher,\n nacl: nacl\n ): EncryptedChannel {\n return new EncryptedChannel(name, pusher, nacl);\n },\n\n createTimelineSender(timeline: Timeline, options: TimelineSenderOptions) {\n return new TimelineSender(timeline, options);\n },\n\n createHandshake(\n transport: TransportConnection,\n callback: (HandshakePayload) => void\n ): Handshake {\n return new Handshake(transport, callback);\n },\n\n createAssistantToTheTransportManager(\n manager: TransportManager,\n transport: Transport,\n options: PingDelayOptions\n ): AssistantToTheTransportManager {\n return new AssistantToTheTransportManager(manager, transport, options);\n }\n};\n\nexport default Factory;\n","import AssistantToTheTransportManager from './assistant_to_the_transport_manager';\nimport Transport from './transport';\nimport PingDelayOptions from './ping_delay_options';\nimport Factory from '../utils/factory';\n\nexport interface TransportManagerOptions extends PingDelayOptions {\n lives?: number;\n}\n\n/** Keeps track of the number of lives left for a transport.\n *\n * In the beginning of a session, transports may be assigned a number of\n * lives. When an AssistantToTheTransportManager instance reports a transport\n * connection closed uncleanly, the transport loses a life. When the number\n * of lives drops to zero, the transport gets disabled by its manager.\n *\n * @param {Object} options\n */\nexport default class TransportManager {\n options: TransportManagerOptions;\n livesLeft: number;\n\n constructor(options: TransportManagerOptions) {\n this.options = options || {};\n this.livesLeft = this.options.lives || Infinity;\n }\n\n /** Creates a assistant for the transport.\n *\n * @param {Transport} transport\n * @returns {AssistantToTheTransportManager}\n */\n getAssistant(transport: Transport): AssistantToTheTransportManager {\n return Factory.createAssistantToTheTransportManager(this, transport, {\n minPingDelay: this.options.minPingDelay,\n maxPingDelay: this.options.maxPingDelay\n });\n }\n\n /** Returns whether the transport has any lives left.\n *\n * @returns {Boolean}\n */\n isAlive(): boolean {\n return this.livesLeft > 0;\n }\n\n /** Takes one life from the transport. */\n reportDeath() {\n this.livesLeft -= 1;\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport { OneOffTimer as Timer } from '../utils/timers';\nimport Strategy from './strategy';\nimport StrategyOptions from './strategy_options';\n\n/** Loops through strategies with optional timeouts.\n *\n * Options:\n * - loop - whether it should loop through the substrategy list\n * - timeout - initial timeout for a single substrategy\n * - timeoutLimit - maximum timeout\n *\n * @param {Strategy[]} strategies\n * @param {Object} options\n */\nexport default class SequentialStrategy implements Strategy {\n strategies: Strategy[];\n loop: boolean;\n failFast: boolean;\n timeout: number;\n timeoutLimit: number;\n\n constructor(strategies: Strategy[], options: StrategyOptions) {\n this.strategies = strategies;\n this.loop = Boolean(options.loop);\n this.failFast = Boolean(options.failFast);\n this.timeout = options.timeout;\n this.timeoutLimit = options.timeoutLimit;\n }\n\n isSupported(): boolean {\n return Collections.any(this.strategies, Util.method('isSupported'));\n }\n\n connect(minPriority: number, callback: Function) {\n var strategies = this.strategies;\n var current = 0;\n var timeout = this.timeout;\n var runner = null;\n\n var tryNextStrategy = (error, handshake) => {\n if (handshake) {\n callback(null, handshake);\n } else {\n current = current + 1;\n if (this.loop) {\n current = current % strategies.length;\n }\n\n if (current < strategies.length) {\n if (timeout) {\n timeout = timeout * 2;\n if (this.timeoutLimit) {\n timeout = Math.min(timeout, this.timeoutLimit);\n }\n }\n runner = this.tryStrategy(\n strategies[current],\n minPriority,\n { timeout, failFast: this.failFast },\n tryNextStrategy\n );\n } else {\n callback(true);\n }\n }\n };\n\n runner = this.tryStrategy(\n strategies[current],\n minPriority,\n { timeout: timeout, failFast: this.failFast },\n tryNextStrategy\n );\n\n return {\n abort: function() {\n runner.abort();\n },\n forceMinPriority: function(p) {\n minPriority = p;\n if (runner) {\n runner.forceMinPriority(p);\n }\n }\n };\n }\n\n private tryStrategy(\n strategy: Strategy,\n minPriority: number,\n options: StrategyOptions,\n callback: Function\n ) {\n var timer = null;\n var runner = null;\n\n if (options.timeout > 0) {\n timer = new Timer(options.timeout, function() {\n runner.abort();\n callback(true);\n });\n }\n\n runner = strategy.connect(minPriority, function(error, handshake) {\n if (error && timer && timer.isRunning() && !options.failFast) {\n // advance to the next strategy after the timeout\n return;\n }\n if (timer) {\n timer.ensureAborted();\n }\n callback(error, handshake);\n });\n\n return {\n abort: function() {\n if (timer) {\n timer.ensureAborted();\n }\n runner.abort();\n },\n forceMinPriority: function(p) {\n runner.forceMinPriority(p);\n }\n };\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport Strategy from './strategy';\n\n/** Launches all substrategies and emits prioritized connected transports.\n *\n * @param {Array} strategies\n */\nexport default class BestConnectedEverStrategy implements Strategy {\n strategies: Strategy[];\n\n constructor(strategies: Strategy[]) {\n this.strategies = strategies;\n }\n\n isSupported(): boolean {\n return Collections.any(this.strategies, Util.method('isSupported'));\n }\n\n connect(minPriority: number, callback: Function) {\n return connect(this.strategies, minPriority, function(i, runners) {\n return function(error, handshake) {\n runners[i].error = error;\n if (error) {\n if (allRunnersFailed(runners)) {\n callback(true);\n }\n return;\n }\n Collections.apply(runners, function(runner) {\n runner.forceMinPriority(handshake.transport.priority);\n });\n callback(null, handshake);\n };\n });\n }\n}\n\n/** Connects to all strategies in parallel.\n *\n * Callback builder should be a function that takes two arguments: index\n * and a list of runners. It should return another function that will be\n * passed to the substrategy with given index. Runners can be aborted using\n * abortRunner(s) functions from this class.\n *\n * @param {Array} strategies\n * @param {Function} callbackBuilder\n * @return {Object} strategy runner\n */\nfunction connect(\n strategies: Strategy[],\n minPriority: number,\n callbackBuilder: Function\n) {\n var runners = Collections.map(strategies, function(strategy, i, _, rs) {\n return strategy.connect(minPriority, callbackBuilder(i, rs));\n });\n return {\n abort: function() {\n Collections.apply(runners, abortRunner);\n },\n forceMinPriority: function(p) {\n Collections.apply(runners, function(runner) {\n runner.forceMinPriority(p);\n });\n }\n };\n}\n\nfunction allRunnersFailed(runners): boolean {\n return Collections.all(runners, function(runner) {\n return Boolean(runner.error);\n });\n}\n\nfunction abortRunner(runner) {\n if (!runner.error && !runner.aborted) {\n runner.abort();\n runner.aborted = true;\n }\n}\n","import Util from '../util';\nimport Runtime from 'runtime';\nimport Strategy from './strategy';\nimport SequentialStrategy from './sequential_strategy';\nimport StrategyOptions from './strategy_options';\nimport TransportStrategy from './transport_strategy';\nimport Timeline from '../timeline/timeline';\nimport * as Collections from '../utils/collections';\n\nexport interface TransportStrategyDictionary {\n [key: string]: TransportStrategy;\n}\n\n/** Caches the last successful transport and, after the first few attempts,\n * uses the cached transport for subsequent attempts.\n *\n * @param {Strategy} strategy\n * @param {Object} transports\n * @param {Object} options\n */\nexport default class WebSocketPrioritizedCachedStrategy implements Strategy {\n strategy: Strategy;\n transports: TransportStrategyDictionary;\n ttl: number;\n usingTLS: boolean;\n timeline: Timeline;\n\n constructor(\n strategy: Strategy,\n transports: TransportStrategyDictionary,\n options: StrategyOptions\n ) {\n this.strategy = strategy;\n this.transports = transports;\n this.ttl = options.ttl || 1800 * 1000;\n this.usingTLS = options.useTLS;\n this.timeline = options.timeline;\n }\n\n isSupported(): boolean {\n return this.strategy.isSupported();\n }\n\n connect(minPriority: number, callback: Function) {\n var usingTLS = this.usingTLS;\n var info = fetchTransportCache(usingTLS);\n var cacheSkipCount = info && info.cacheSkipCount ? info.cacheSkipCount : 0;\n\n var strategies = [this.strategy];\n if (info && info.timestamp + this.ttl >= Util.now()) {\n var transport = this.transports[info.transport];\n if (transport) {\n if (['ws', 'wss'].includes(info.transport) || cacheSkipCount > 3) {\n this.timeline.info({\n cached: true,\n transport: info.transport,\n latency: info.latency\n });\n strategies.push(\n new SequentialStrategy([transport], {\n timeout: info.latency * 2 + 1000,\n failFast: true\n })\n );\n } else {\n cacheSkipCount++;\n }\n }\n }\n\n var startTimestamp = Util.now();\n var runner = strategies\n .pop()\n .connect(minPriority, function cb(error, handshake) {\n if (error) {\n flushTransportCache(usingTLS);\n if (strategies.length > 0) {\n startTimestamp = Util.now();\n runner = strategies.pop().connect(minPriority, cb);\n } else {\n callback(error);\n }\n } else {\n storeTransportCache(\n usingTLS,\n handshake.transport.name,\n Util.now() - startTimestamp,\n cacheSkipCount\n );\n callback(null, handshake);\n }\n });\n\n return {\n abort: function() {\n runner.abort();\n },\n forceMinPriority: function(p) {\n minPriority = p;\n if (runner) {\n runner.forceMinPriority(p);\n }\n }\n };\n }\n}\n\nfunction getTransportCacheKey(usingTLS: boolean): string {\n return 'pusherTransport' + (usingTLS ? 'TLS' : 'NonTLS');\n}\n\nfunction fetchTransportCache(usingTLS: boolean): any {\n var storage = Runtime.getLocalStorage();\n if (storage) {\n try {\n var serializedCache = storage[getTransportCacheKey(usingTLS)];\n if (serializedCache) {\n return JSON.parse(serializedCache);\n }\n } catch (e) {\n flushTransportCache(usingTLS);\n }\n }\n return null;\n}\n\nfunction storeTransportCache(\n usingTLS: boolean,\n transport: TransportStrategy,\n latency: number,\n cacheSkipCount: number\n) {\n var storage = Runtime.getLocalStorage();\n if (storage) {\n try {\n storage[getTransportCacheKey(usingTLS)] = Collections.safeJSONStringify({\n timestamp: Util.now(),\n transport: transport,\n latency: latency,\n cacheSkipCount: cacheSkipCount\n });\n } catch (e) {\n // catch over quota exceptions raised by localStorage\n }\n }\n}\n\nfunction flushTransportCache(usingTLS: boolean) {\n var storage = Runtime.getLocalStorage();\n if (storage) {\n try {\n delete storage[getTransportCacheKey(usingTLS)];\n } catch (e) {\n // catch exceptions raised by localStorage\n }\n }\n}\n","import { OneOffTimer as Timer } from '../utils/timers';\nimport Strategy from './strategy';\nimport StrategyOptions from './strategy_options';\n\n/** Runs substrategy after specified delay.\n *\n * Options:\n * - delay - time in miliseconds to delay the substrategy attempt\n *\n * @param {Strategy} strategy\n * @param {Object} options\n */\nexport default class DelayedStrategy implements Strategy {\n strategy: Strategy;\n options: { delay: number };\n\n constructor(strategy: Strategy, { delay: number }) {\n this.strategy = strategy;\n this.options = { delay: number };\n }\n\n isSupported(): boolean {\n return this.strategy.isSupported();\n }\n\n connect(minPriority: number, callback: Function) {\n var strategy = this.strategy;\n var runner;\n var timer = new Timer(this.options.delay, function() {\n runner = strategy.connect(minPriority, callback);\n });\n\n return {\n abort: function() {\n timer.ensureAborted();\n if (runner) {\n runner.abort();\n }\n },\n forceMinPriority: function(p) {\n minPriority = p;\n if (runner) {\n runner.forceMinPriority(p);\n }\n }\n };\n }\n}\n","import Strategy from './strategy';\nimport StrategyRunner from './strategy_runner';\n\n/** Proxies method calls to one of substrategies basing on the test function.\n *\n * @param {Function} test\n * @param {Strategy} trueBranch strategy used when test returns true\n * @param {Strategy} falseBranch strategy used when test returns false\n */\nexport default class IfStrategy implements Strategy {\n test: () => boolean;\n trueBranch: Strategy;\n falseBranch: Strategy;\n\n constructor(\n test: () => boolean,\n trueBranch: Strategy,\n falseBranch: Strategy\n ) {\n this.test = test;\n this.trueBranch = trueBranch;\n this.falseBranch = falseBranch;\n }\n\n isSupported(): boolean {\n var branch = this.test() ? this.trueBranch : this.falseBranch;\n return branch.isSupported();\n }\n\n connect(minPriority: number, callback: Function): StrategyRunner {\n var branch = this.test() ? this.trueBranch : this.falseBranch;\n return branch.connect(minPriority, callback);\n }\n}\n","import Strategy from './strategy';\nimport StrategyRunner from './strategy_runner';\n\n/** Launches the substrategy and terminates on the first open connection.\n *\n * @param {Strategy} strategy\n */\nexport default class FirstConnectedStrategy implements Strategy {\n strategy: Strategy;\n\n constructor(strategy: Strategy) {\n this.strategy = strategy;\n }\n\n isSupported(): boolean {\n return this.strategy.isSupported();\n }\n\n connect(minPriority: number, callback: Function): StrategyRunner {\n var runner = this.strategy.connect(minPriority, function(error, handshake) {\n if (handshake) {\n runner.abort();\n }\n callback(error, handshake);\n });\n return runner;\n }\n}\n","import * as Collections from 'core/utils/collections';\nimport TransportManager from 'core/transports/transport_manager';\nimport Strategy from 'core/strategies/strategy';\nimport SequentialStrategy from 'core/strategies/sequential_strategy';\nimport BestConnectedEverStrategy from 'core/strategies/best_connected_ever_strategy';\nimport WebSocketPrioritizedCachedStrategy, {\n TransportStrategyDictionary\n} from 'core/strategies/websocket_prioritized_cached_strategy';\nimport DelayedStrategy from 'core/strategies/delayed_strategy';\nimport IfStrategy from 'core/strategies/if_strategy';\nimport FirstConnectedStrategy from 'core/strategies/first_connected_strategy';\nimport { Config } from 'core/config';\nimport StrategyOptions from 'core/strategies/strategy_options';\n\nfunction testSupportsStrategy(strategy: Strategy) {\n return function() {\n return strategy.isSupported();\n };\n}\n\nvar getDefaultStrategy = function(\n config: Config,\n baseOptions: StrategyOptions,\n defineTransport: Function\n): Strategy {\n var definedTransports = {};\n\n function defineTransportStrategy(\n name: string,\n type: string,\n priority: number,\n options: StrategyOptions,\n manager?: TransportManager\n ) {\n var transport = defineTransport(\n config,\n name,\n type,\n priority,\n options,\n manager\n );\n\n definedTransports[name] = transport;\n\n return transport;\n }\n\n var ws_options: StrategyOptions = Object.assign({}, baseOptions, {\n hostNonTLS: config.wsHost + ':' + config.wsPort,\n hostTLS: config.wsHost + ':' + config.wssPort,\n httpPath: config.wsPath\n });\n var wss_options: StrategyOptions = Collections.extend({}, ws_options, {\n useTLS: true\n });\n var http_options: StrategyOptions = Object.assign({}, baseOptions, {\n hostNonTLS: config.httpHost + ':' + config.httpPort,\n hostTLS: config.httpHost + ':' + config.httpsPort,\n httpPath: config.httpPath\n });\n var timeouts = {\n loop: true,\n timeout: 15000,\n timeoutLimit: 60000\n };\n\n var ws_manager = new TransportManager({\n minPingDelay: 10000,\n maxPingDelay: config.activityTimeout\n });\n var streaming_manager = new TransportManager({\n lives: 2,\n minPingDelay: 10000,\n maxPingDelay: config.activityTimeout\n });\n\n var ws_transport = defineTransportStrategy(\n 'ws',\n 'ws',\n 3,\n ws_options,\n ws_manager\n );\n var wss_transport = defineTransportStrategy(\n 'wss',\n 'ws',\n 3,\n wss_options,\n ws_manager\n );\n var xhr_streaming_transport = defineTransportStrategy(\n 'xhr_streaming',\n 'xhr_streaming',\n 1,\n http_options,\n streaming_manager\n );\n var xhr_polling_transport = defineTransportStrategy(\n 'xhr_polling',\n 'xhr_polling',\n 1,\n http_options\n );\n\n var ws_loop = new SequentialStrategy([ws_transport], timeouts);\n var wss_loop = new SequentialStrategy([wss_transport], timeouts);\n var streaming_loop = new SequentialStrategy(\n [xhr_streaming_transport],\n timeouts\n );\n var polling_loop = new SequentialStrategy([xhr_polling_transport], timeouts);\n\n var http_loop = new SequentialStrategy(\n [\n new IfStrategy(\n testSupportsStrategy(streaming_loop),\n new BestConnectedEverStrategy([\n streaming_loop,\n new DelayedStrategy(polling_loop, { delay: 4000 })\n ]),\n polling_loop\n )\n ],\n timeouts\n );\n\n var wsStrategy;\n if (baseOptions.useTLS) {\n wsStrategy = new BestConnectedEverStrategy([\n ws_loop,\n new DelayedStrategy(http_loop, { delay: 2000 })\n ]);\n } else {\n wsStrategy = new BestConnectedEverStrategy([\n ws_loop,\n new DelayedStrategy(wss_loop, { delay: 2000 }),\n new DelayedStrategy(http_loop, { delay: 5000 })\n ]);\n }\n\n return new WebSocketPrioritizedCachedStrategy(\n new FirstConnectedStrategy(\n new IfStrategy(testSupportsStrategy(ws_transport), wsStrategy, http_loop)\n ),\n definedTransports,\n {\n ttl: 1800000,\n timeline: baseOptions.timeline,\n useTLS: baseOptions.useTLS\n }\n );\n};\n\nexport default getDefaultStrategy;\n","import Runtime from 'runtime';\nimport RequestHooks from './request_hooks';\nimport Ajax from './ajax';\nimport { default as EventsDispatcher } from '../events/dispatcher';\n\nconst MAX_BUFFER_LENGTH = 256 * 1024;\n\nexport default class HTTPRequest extends EventsDispatcher {\n hooks: RequestHooks;\n method: string;\n url: string;\n position: number;\n xhr: Ajax;\n unloader: Function;\n\n constructor(hooks: RequestHooks, method: string, url: string) {\n super();\n this.hooks = hooks;\n this.method = method;\n this.url = url;\n }\n\n start(payload?: any) {\n this.position = 0;\n this.xhr = this.hooks.getRequest(this);\n\n this.unloader = () => {\n this.close();\n };\n Runtime.addUnloadListener(this.unloader);\n\n this.xhr.open(this.method, this.url, true);\n\n if (this.xhr.setRequestHeader) {\n this.xhr.setRequestHeader('Content-Type', 'application/json'); // ReactNative doesn't set this header by default.\n }\n this.xhr.send(payload);\n }\n\n close() {\n if (this.unloader) {\n Runtime.removeUnloadListener(this.unloader);\n this.unloader = null;\n }\n if (this.xhr) {\n this.hooks.abortRequest(this.xhr);\n this.xhr = null;\n }\n }\n\n onChunk(status: number, data: any) {\n while (true) {\n var chunk = this.advanceBuffer(data);\n if (chunk) {\n this.emit('chunk', { status: status, data: chunk });\n } else {\n break;\n }\n }\n if (this.isBufferTooLong(data)) {\n this.emit('buffer_too_long');\n }\n }\n\n private advanceBuffer(buffer: any[]): any {\n var unreadData = buffer.slice(this.position);\n var endOfLinePosition = unreadData.indexOf('\\n');\n\n if (endOfLinePosition !== -1) {\n this.position += endOfLinePosition + 1;\n return unreadData.slice(0, endOfLinePosition);\n } else {\n // chunk is not finished yet, don't move the buffer pointer\n return null;\n }\n }\n\n private isBufferTooLong(buffer: any): boolean {\n return this.position === buffer.length && buffer.length > MAX_BUFFER_LENGTH;\n }\n}\n","enum State {\n CONNECTING = 0,\n OPEN = 1,\n CLOSED = 3\n}\n\nexport default State;\n","import URLLocation from './url_location';\nimport State from './state';\nimport Socket from '../socket';\nimport SocketHooks from './socket_hooks';\nimport Util from '../util';\nimport Ajax from './ajax';\nimport HTTPRequest from './http_request';\nimport Runtime from 'runtime';\n\nvar autoIncrement = 1;\n\nclass HTTPSocket implements Socket {\n hooks: SocketHooks;\n session: string;\n location: URLLocation;\n readyState: State;\n stream: HTTPRequest;\n\n onopen: () => void;\n onerror: (error: any) => void;\n onclose: (closeEvent: any) => void;\n onmessage: (message: any) => void;\n onactivity: () => void;\n\n constructor(hooks: SocketHooks, url: string) {\n this.hooks = hooks;\n this.session = randomNumber(1000) + '/' + randomString(8);\n this.location = getLocation(url);\n this.readyState = State.CONNECTING;\n this.openStream();\n }\n\n send(payload: any) {\n return this.sendRaw(JSON.stringify([payload]));\n }\n\n ping() {\n this.hooks.sendHeartbeat(this);\n }\n\n close(code: any, reason: any) {\n this.onClose(code, reason, true);\n }\n\n /** For internal use only */\n sendRaw(payload: any): boolean {\n if (this.readyState === State.OPEN) {\n try {\n Runtime.createSocketRequest(\n 'POST',\n getUniqueURL(getSendURL(this.location, this.session))\n ).start(payload);\n return true;\n } catch (e) {\n return false;\n }\n } else {\n return false;\n }\n }\n\n /** For internal use only */\n reconnect() {\n this.closeStream();\n this.openStream();\n }\n\n /** For internal use only */\n onClose(code, reason, wasClean) {\n this.closeStream();\n this.readyState = State.CLOSED;\n if (this.onclose) {\n this.onclose({\n code: code,\n reason: reason,\n wasClean: wasClean\n });\n }\n }\n\n private onChunk(chunk) {\n if (chunk.status !== 200) {\n return;\n }\n if (this.readyState === State.OPEN) {\n this.onActivity();\n }\n\n var payload;\n var type = chunk.data.slice(0, 1);\n switch (type) {\n case 'o':\n payload = JSON.parse(chunk.data.slice(1) || '{}');\n this.onOpen(payload);\n break;\n case 'a':\n payload = JSON.parse(chunk.data.slice(1) || '[]');\n for (var i = 0; i < payload.length; i++) {\n this.onEvent(payload[i]);\n }\n break;\n case 'm':\n payload = JSON.parse(chunk.data.slice(1) || 'null');\n this.onEvent(payload);\n break;\n case 'h':\n this.hooks.onHeartbeat(this);\n break;\n case 'c':\n payload = JSON.parse(chunk.data.slice(1) || '[]');\n this.onClose(payload[0], payload[1], true);\n break;\n }\n }\n\n private onOpen(options) {\n if (this.readyState === State.CONNECTING) {\n if (options && options.hostname) {\n this.location.base = replaceHost(this.location.base, options.hostname);\n }\n this.readyState = State.OPEN;\n\n if (this.onopen) {\n this.onopen();\n }\n } else {\n this.onClose(1006, 'Server lost session', true);\n }\n }\n\n private onEvent(event) {\n if (this.readyState === State.OPEN && this.onmessage) {\n this.onmessage({ data: event });\n }\n }\n\n private onActivity() {\n if (this.onactivity) {\n this.onactivity();\n }\n }\n\n private onError(error) {\n if (this.onerror) {\n this.onerror(error);\n }\n }\n\n private openStream() {\n this.stream = Runtime.createSocketRequest(\n 'POST',\n getUniqueURL(this.hooks.getReceiveURL(this.location, this.session))\n );\n\n this.stream.bind('chunk', chunk => {\n this.onChunk(chunk);\n });\n this.stream.bind('finished', status => {\n this.hooks.onFinished(this, status);\n });\n this.stream.bind('buffer_too_long', () => {\n this.reconnect();\n });\n\n try {\n this.stream.start();\n } catch (error) {\n Util.defer(() => {\n this.onError(error);\n this.onClose(1006, 'Could not start streaming', false);\n });\n }\n }\n\n private closeStream() {\n if (this.stream) {\n this.stream.unbind_all();\n this.stream.close();\n this.stream = null;\n }\n }\n}\n\nfunction getLocation(url): URLLocation {\n var parts = /([^\\?]*)\\/*(\\??.*)/.exec(url);\n return {\n base: parts[1],\n queryString: parts[2]\n };\n}\n\nfunction getSendURL(url: URLLocation, session: string): string {\n return url.base + '/' + session + '/xhr_send';\n}\n\nfunction getUniqueURL(url: string): string {\n var separator = url.indexOf('?') === -1 ? '?' : '&';\n return url + separator + 't=' + +new Date() + '&n=' + autoIncrement++;\n}\n\nfunction replaceHost(url: string, hostname: string): string {\n var urlParts = /(https?:\\/\\/)([^\\/:]+)((\\/|:)?.*)/.exec(url);\n return urlParts[1] + hostname + urlParts[3];\n}\n\nfunction randomNumber(max: number): number {\n return Runtime.randomInt(max);\n}\n\nfunction randomString(length: number): string {\n var result = [];\n\n for (var i = 0; i < length; i++) {\n result.push(randomNumber(32).toString(32));\n }\n\n return result.join('');\n}\n\nexport default HTTPSocket;\n","import SocketHooks from './socket_hooks';\nimport HTTPSocket from './http_socket';\n\nvar hooks: SocketHooks = {\n getReceiveURL: function(url, session) {\n return url.base + '/' + session + '/xhr_streaming' + url.queryString;\n },\n onHeartbeat: function(socket) {\n socket.sendRaw('[]');\n },\n sendHeartbeat: function(socket) {\n socket.sendRaw('[]');\n },\n onFinished: function(socket, status) {\n socket.onClose(1006, 'Connection interrupted (' + status + ')', false);\n }\n};\n\nexport default hooks;\n","import SocketHooks from './socket_hooks';\nimport URLLocation from './url_location';\nimport HTTPSocket from './http_socket';\n\nvar hooks: SocketHooks = {\n getReceiveURL: function(url: URLLocation, session: string): string {\n return url.base + '/' + session + '/xhr' + url.queryString;\n },\n onHeartbeat: function() {\n // next HTTP request will reset server's activity timer\n },\n sendHeartbeat: function(socket) {\n socket.sendRaw('[]');\n },\n onFinished: function(socket, status) {\n if (status === 200) {\n socket.reconnect();\n } else {\n socket.onClose(1006, 'Connection interrupted (' + status + ')', false);\n }\n }\n};\n\nexport default hooks;\n","import HTTPRequest from 'core/http/http_request';\nimport RequestHooks from 'core/http/request_hooks';\nimport Ajax from 'core/http/ajax';\nimport Runtime from 'runtime';\n\nvar hooks: RequestHooks = {\n getRequest: function(socket: HTTPRequest): Ajax {\n var Constructor = Runtime.getXHRAPI();\n var xhr = new Constructor();\n xhr.onreadystatechange = xhr.onprogress = function() {\n switch (xhr.readyState) {\n case 3:\n if (xhr.responseText && xhr.responseText.length > 0) {\n socket.onChunk(xhr.status, xhr.responseText);\n }\n break;\n case 4:\n // this happens only on errors, never after calling close\n if (xhr.responseText && xhr.responseText.length > 0) {\n socket.onChunk(xhr.status, xhr.responseText);\n }\n socket.emit('finished', xhr.status);\n socket.close();\n break;\n }\n };\n return xhr;\n },\n abortRequest: function(xhr: Ajax) {\n xhr.onreadystatechange = null;\n xhr.abort();\n }\n};\n\nexport default hooks;\n","import * as Collections from 'core/utils/collections';\nimport Transports from 'isomorphic/transports/transports';\nimport TimelineSender from 'core/timeline/timeline_sender';\nimport Ajax from 'core/http/ajax';\nimport getDefaultStrategy from './default_strategy';\nimport TransportsTable from 'core/transports/transports_table';\nimport transportConnectionInitializer from './transports/transport_connection_initializer';\nimport HTTPFactory from './http/http';\n\nvar Isomorphic: any = {\n getDefaultStrategy,\n Transports: Transports,\n transportConnectionInitializer,\n HTTPFactory,\n\n setup(PusherClass): void {\n PusherClass.ready();\n },\n\n getLocalStorage(): any {\n return undefined;\n },\n\n getClientFeatures(): any[] {\n return Collections.keys(\n Collections.filterObject({ ws: Transports.ws }, function(t) {\n return t.isSupported({});\n })\n );\n },\n\n getProtocol(): string {\n return 'http:';\n },\n\n isXHRSupported(): boolean {\n return true;\n },\n\n createSocketRequest(method: string, url: string) {\n if (this.isXHRSupported()) {\n return this.HTTPFactory.createXHR(method, url);\n } else {\n throw 'Cross-origin HTTP requests are not supported';\n }\n },\n\n createXHR(): Ajax {\n var Constructor = this.getXHRAPI();\n return new Constructor();\n },\n\n createWebSocket(url: string): any {\n var Constructor = this.getWebSocketAPI();\n return new Constructor(url);\n },\n\n addUnloadListener(listener: any) {},\n removeUnloadListener(listener: any) {}\n};\n\nexport default Isomorphic;\n","/** Initializes the transport.\n *\n * Fetches resources if needed and then transitions to initialized.\n */\nexport default function() {\n var self = this;\n\n self.timeline.info(\n self.buildTimelineMessage({\n transport: self.name + (self.options.useTLS ? 's' : '')\n })\n );\n\n if (self.hooks.isInitialized()) {\n self.changeState('initialized');\n } else {\n self.onClose();\n }\n}\n","import HTTPRequest from 'core/http/http_request';\nimport HTTPSocket from 'core/http/http_socket';\nimport SocketHooks from 'core/http/socket_hooks';\nimport RequestHooks from 'core/http/request_hooks';\nimport streamingHooks from 'core/http/http_streaming_socket';\nimport pollingHooks from 'core/http/http_polling_socket';\nimport xhrHooks from './http_xhr_request';\nimport HTTPFactory from 'core/http/http_factory';\n\nvar HTTP: HTTPFactory = {\n createStreamingSocket(url: string): HTTPSocket {\n return this.createSocket(streamingHooks, url);\n },\n\n createPollingSocket(url: string): HTTPSocket {\n return this.createSocket(pollingHooks, url);\n },\n\n createSocket(hooks: SocketHooks, url: string): HTTPSocket {\n return new HTTPSocket(hooks, url);\n },\n\n createXHR(method: string, url: string): HTTPRequest {\n return this.createRequest(xhrHooks, method, url);\n },\n\n createRequest(hooks: RequestHooks, method: string, url: string): HTTPRequest {\n return new HTTPRequest(hooks, method, url);\n }\n};\n\nexport default HTTP;\n","import { default as EventsDispatcher } from 'core/events/dispatcher';\nimport Reachability from 'core/reachability';\n\nexport class NetInfo extends EventsDispatcher implements Reachability {\n isOnline(): boolean {\n return true;\n }\n}\n\nexport var Network = new NetInfo();\n","import AbstractRuntime from 'runtimes/interface';\nimport { AuthTransport } from 'core/auth/auth_transports';\nimport {\n AuthRequestType,\n AuthTransportCallback,\n InternalAuthOptions\n} from 'core/auth/options';\nimport { HTTPAuthError } from 'core/errors';\n\nvar fetchAuth: AuthTransport = function(\n context: AbstractRuntime,\n query: string,\n authOptions: InternalAuthOptions,\n authRequestType: AuthRequestType,\n callback: AuthTransportCallback\n) {\n var headers = new Headers();\n headers.set('Content-Type', 'application/x-www-form-urlencoded');\n\n for (var headerName in authOptions.headers) {\n headers.set(headerName, authOptions.headers[headerName]);\n }\n\n if (authOptions.headersProvider != null) {\n const dynamicHeaders = authOptions.headersProvider();\n for (var headerName in dynamicHeaders) {\n headers.set(headerName, dynamicHeaders[headerName]);\n }\n }\n\n var body = query;\n var request = new Request(authOptions.endpoint, {\n headers,\n body,\n credentials: 'same-origin',\n method: 'POST'\n });\n\n return fetch(request)\n .then(response => {\n let { status } = response;\n if (status === 200) {\n // manually parse the json so we can provide a more helpful error in\n // failure case\n return response.text();\n }\n throw new HTTPAuthError(\n status,\n `Could not get ${authRequestType.toString()} info from your auth endpoint, status: ${status}`\n );\n })\n .then(data => {\n let parsedData;\n try {\n parsedData = JSON.parse(data);\n } catch (e) {\n throw new HTTPAuthError(\n 200,\n `JSON returned from ${authRequestType.toString()} endpoint was invalid, yet status code was 200. Data was: ${data}`\n );\n }\n callback(null, parsedData);\n })\n .catch(err => {\n callback(err, null);\n });\n};\n\nexport default fetchAuth;\n","import Logger from 'core/logger';\nimport TimelineSender from 'core/timeline/timeline_sender';\nimport * as Collections from 'core/utils/collections';\nimport Util from 'core/util';\nimport Runtime from 'runtime';\nimport TimelineTransport from 'core/timeline/timeline_transport';\n\nvar getAgent = function(sender: TimelineSender, useTLS: boolean) {\n return function(data: any, callback: Function) {\n var scheme = 'http' + (useTLS ? 's' : '') + '://';\n var url =\n scheme + (sender.host || sender.options.host) + sender.options.path;\n var query = Collections.buildQueryString(data);\n url += '/' + 2 + '?' + query;\n\n fetch(url)\n .then(response => {\n if (response.status !== 200) {\n throw `received ${response.status} from stats.pusher.com`;\n }\n return response.json();\n })\n .then(({ host }) => {\n if (host) {\n sender.host = host;\n }\n })\n .catch(err => {\n Logger.debug('TimelineSender Error: ', err);\n });\n };\n};\n\nvar fetchTimeline = {\n name: 'xhr',\n getAgent\n};\n\nexport default fetchTimeline;\n","import Isomorphic from 'isomorphic/runtime';\nimport Runtime from '../interface';\nimport { Network } from './net_info';\nimport fetchAuth from './auth/fetch_auth';\nimport { AuthTransports } from 'core/auth/auth_transports';\nimport fetchTimeline from './timeline/fetch_timeline';\n\n// Very verbose but until unavoidable until\n// TypeScript 2.1, when spread attributes will be\n// supported\nconst {\n getDefaultStrategy,\n Transports,\n setup,\n getProtocol,\n isXHRSupported,\n getLocalStorage,\n createXHR,\n createWebSocket,\n addUnloadListener,\n removeUnloadListener,\n transportConnectionInitializer,\n createSocketRequest,\n HTTPFactory\n} = Isomorphic;\n\nconst Worker: Runtime = {\n getDefaultStrategy,\n Transports,\n setup,\n getProtocol,\n isXHRSupported,\n getLocalStorage,\n createXHR,\n createWebSocket,\n addUnloadListener,\n removeUnloadListener,\n transportConnectionInitializer,\n createSocketRequest,\n HTTPFactory,\n\n TimelineTransport: fetchTimeline,\n\n getAuthorizers(): AuthTransports {\n return { ajax: fetchAuth };\n },\n\n getWebSocketAPI() {\n return WebSocket;\n },\n\n getXHRAPI() {\n return XMLHttpRequest;\n },\n\n getNetwork() {\n return Network;\n },\n\n randomInt(max: number): number {\n /**\n * Return values in the range of [0, 1[\n */\n const random = function() {\n const crypto = globalThis.crypto || globalThis['msCrypto'];\n const random = crypto.getRandomValues(new Uint32Array(1))[0];\n\n return random / 2 ** 32;\n };\n\n return Math.floor(random() * max);\n }\n};\n\nexport default Worker;\n","enum TimelineLevel {\n ERROR = 3,\n INFO = 6,\n DEBUG = 7\n}\n\nexport default TimelineLevel;\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport { default as Level } from './level';\n\nexport interface TimelineOptions {\n level?: Level;\n limit?: number;\n version?: string;\n cluster?: string;\n features?: string[];\n params?: any;\n}\n\nexport default class Timeline {\n key: string;\n session: number;\n events: any[];\n options: TimelineOptions;\n sent: number;\n uniqueID: number;\n\n constructor(key: string, session: number, options: TimelineOptions) {\n this.key = key;\n this.session = session;\n this.events = [];\n this.options = options || {};\n this.sent = 0;\n this.uniqueID = 0;\n }\n\n log(level, event) {\n if (level <= this.options.level) {\n this.events.push(\n Collections.extend({}, event, { timestamp: Util.now() })\n );\n if (this.options.limit && this.events.length > this.options.limit) {\n this.events.shift();\n }\n }\n }\n\n error(event) {\n this.log(Level.ERROR, event);\n }\n\n info(event) {\n this.log(Level.INFO, event);\n }\n\n debug(event) {\n this.log(Level.DEBUG, event);\n }\n\n isEmpty() {\n return this.events.length === 0;\n }\n\n send(sendfn, callback) {\n var data = Collections.extend(\n {\n session: this.session,\n bundle: this.sent + 1,\n key: this.key,\n lib: 'js',\n version: this.options.version,\n cluster: this.options.cluster,\n features: this.options.features,\n timeline: this.events\n },\n this.options.params\n );\n\n this.events = [];\n sendfn(data, (error, result) => {\n if (!error) {\n this.sent++;\n }\n if (callback) {\n callback(error, result);\n }\n });\n\n return true;\n }\n\n generateUniqueID(): number {\n this.uniqueID++;\n return this.uniqueID;\n }\n}\n","import Factory from '../utils/factory';\nimport Util from '../util';\nimport * as Errors from '../errors';\nimport * as Collections from '../utils/collections';\nimport Strategy from './strategy';\nimport Transport from '../transports/transport';\nimport StrategyOptions from './strategy_options';\nimport Handshake from '../connection/handshake';\n\n/** Provides a strategy interface for transports.\n *\n * @param {String} name\n * @param {Number} priority\n * @param {Class} transport\n * @param {Object} options\n */\nexport default class TransportStrategy implements Strategy {\n name: string;\n priority: number;\n transport: Transport;\n options: StrategyOptions;\n\n constructor(\n name: string,\n priority: number,\n transport: Transport,\n options: StrategyOptions\n ) {\n this.name = name;\n this.priority = priority;\n this.transport = transport;\n this.options = options || {};\n }\n\n /** Returns whether the transport is supported in the browser.\n *\n * @returns {Boolean}\n */\n isSupported(): boolean {\n return this.transport.isSupported({\n useTLS: this.options.useTLS\n });\n }\n\n /** Launches a connection attempt and returns a strategy runner.\n *\n * @param {Function} callback\n * @return {Object} strategy runner\n */\n connect(minPriority: number, callback: Function) {\n if (!this.isSupported()) {\n return failAttempt(new Errors.UnsupportedStrategy(), callback);\n } else if (this.priority < minPriority) {\n return failAttempt(new Errors.TransportPriorityTooLow(), callback);\n }\n\n var connected = false;\n var transport = this.transport.createConnection(\n this.name,\n this.priority,\n this.options.key,\n this.options\n );\n var handshake = null;\n\n var onInitialized = function() {\n transport.unbind('initialized', onInitialized);\n transport.connect();\n };\n var onOpen = function() {\n handshake = Factory.createHandshake(transport, function(result) {\n connected = true;\n unbindListeners();\n callback(null, result);\n });\n };\n var onError = function(error) {\n unbindListeners();\n callback(error);\n };\n var onClosed = function() {\n unbindListeners();\n var serializedTransport;\n\n // The reason for this try/catch block is that on React Native\n // the WebSocket object is circular. Therefore transport.socket will\n // throw errors upon stringification. Collections.safeJSONStringify\n // discards circular references when serializing.\n serializedTransport = Collections.safeJSONStringify(transport);\n callback(new Errors.TransportClosed(serializedTransport));\n };\n\n var unbindListeners = function() {\n transport.unbind('initialized', onInitialized);\n transport.unbind('open', onOpen);\n transport.unbind('error', onError);\n transport.unbind('closed', onClosed);\n };\n\n transport.bind('initialized', onInitialized);\n transport.bind('open', onOpen);\n transport.bind('error', onError);\n transport.bind('closed', onClosed);\n\n // connect will be called automatically after initialization\n transport.initialize();\n\n return {\n abort: () => {\n if (connected) {\n return;\n }\n unbindListeners();\n if (handshake) {\n handshake.close();\n } else {\n transport.close();\n }\n },\n forceMinPriority: p => {\n if (connected) {\n return;\n }\n if (this.priority < p) {\n if (handshake) {\n handshake.close();\n } else {\n transport.close();\n }\n }\n }\n };\n }\n}\n\nfunction failAttempt(error: Error, callback: Function) {\n Util.defer(function() {\n callback(error);\n });\n return {\n abort: function() {},\n forceMinPriority: function() {}\n };\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport TransportManager from '../transports/transport_manager';\nimport * as Errors from '../errors';\nimport Strategy from './strategy';\nimport TransportStrategy from './transport_strategy';\nimport StrategyOptions from '../strategies/strategy_options';\nimport { Config } from '../config';\nimport Runtime from 'runtime';\n\nconst { Transports } = Runtime;\n\nexport var defineTransport = function(\n config: Config,\n name: string,\n type: string,\n priority: number,\n options: StrategyOptions,\n manager?: TransportManager\n): Strategy {\n var transportClass = Transports[type];\n if (!transportClass) {\n throw new Errors.UnsupportedTransport(type);\n }\n\n var enabled =\n (!config.enabledTransports ||\n Collections.arrayIndexOf(config.enabledTransports, name) !== -1) &&\n (!config.disabledTransports ||\n Collections.arrayIndexOf(config.disabledTransports, name) === -1);\n\n var transport;\n if (enabled) {\n options = Object.assign(\n { ignoreNullOrigin: config.ignoreNullOrigin },\n options\n );\n\n transport = new TransportStrategy(\n name,\n priority,\n manager ? manager.getAssistant(transportClass) : transportClass,\n options\n );\n } else {\n transport = UnsupportedStrategy;\n }\n\n return transport;\n};\n\nvar UnsupportedStrategy: Strategy = {\n isSupported: function() {\n return false;\n },\n connect: function(_, callback) {\n var deferred = Util.defer(function() {\n callback(new Errors.UnsupportedStrategy());\n });\n return {\n abort: function() {\n deferred.ensureAborted();\n },\n forceMinPriority: function() {}\n };\n }\n};\n","export enum AuthRequestType {\n UserAuthentication = 'user-authentication',\n ChannelAuthorization = 'channel-authorization'\n}\n\nexport interface ChannelAuthorizationData {\n auth: string;\n channel_data?: string;\n shared_secret?: string;\n}\n\nexport type ChannelAuthorizationCallback = (\n error: Error | null,\n authData: ChannelAuthorizationData | null\n) => void;\n\nexport interface ChannelAuthorizationRequestParams {\n socketId: string;\n channelName: string;\n}\n\nexport interface ChannelAuthorizationHandler {\n (\n params: ChannelAuthorizationRequestParams,\n callback: ChannelAuthorizationCallback\n ): void;\n}\n\nexport interface UserAuthenticationData {\n auth: string;\n user_data: string;\n}\n\nexport type UserAuthenticationCallback = (\n error: Error | null,\n authData: UserAuthenticationData | null\n) => void;\n\nexport interface UserAuthenticationRequestParams {\n socketId: string;\n}\n\nexport interface UserAuthenticationHandler {\n (\n params: UserAuthenticationRequestParams,\n callback: UserAuthenticationCallback\n ): void;\n}\n\nexport type AuthTransportCallback =\n | ChannelAuthorizationCallback\n | UserAuthenticationCallback;\n\nexport interface AuthOptionsT {\n transport: 'ajax' | 'jsonp';\n endpoint: string;\n params?: any;\n headers?: any;\n paramsProvider?: () => any;\n headersProvider?: () => any;\n customHandler?: AuthHandler;\n}\n\nexport declare type UserAuthenticationOptions = AuthOptionsT<\n UserAuthenticationHandler\n>;\nexport declare type ChannelAuthorizationOptions = AuthOptionsT<\n ChannelAuthorizationHandler\n>;\n\nexport interface InternalAuthOptions {\n transport: 'ajax' | 'jsonp';\n endpoint: string;\n params?: any;\n headers?: any;\n paramsProvider?: () => any;\n headersProvider?: () => any;\n}\n","import ConnectionManager from './connection/connection_manager';\nimport {\n ChannelAuthorizationOptions,\n UserAuthenticationOptions\n} from './auth/options';\nimport {\n ChannelAuthorizerGenerator,\n DeprecatedAuthOptions\n} from './auth/deprecated_channel_authorizer';\nimport { AuthTransport, Transport } from './config';\nimport * as nacl from 'tweetnacl';\nimport Logger from './logger';\n\nexport interface Options {\n activityTimeout?: number;\n\n auth?: DeprecatedAuthOptions; // DEPRECATED use channelAuthorization instead\n authEndpoint?: string; // DEPRECATED use channelAuthorization instead\n authTransport?: AuthTransport; // DEPRECATED use channelAuthorization instead\n authorizer?: ChannelAuthorizerGenerator; // DEPRECATED use channelAuthorization instead\n\n channelAuthorization?: ChannelAuthorizationOptions;\n userAuthentication?: UserAuthenticationOptions;\n\n cluster: string;\n enableStats?: boolean;\n disableStats?: boolean;\n disabledTransports?: Transport[];\n enabledTransports?: Transport[];\n forceTLS?: boolean;\n httpHost?: string;\n httpPath?: string;\n httpPort?: number;\n httpsPort?: number;\n ignoreNullOrigin?: boolean;\n nacl?: nacl;\n pongTimeout?: number;\n statsHost?: string;\n timelineParams?: any;\n unavailableTimeout?: number;\n wsHost?: string;\n wsPath?: string;\n wsPort?: number;\n wssPort?: number;\n}\n\nexport interface ClusterOptions {\n appKey: string;\n cluster: string;\n}\n\nexport function validateOptions(options) {\n if (options == null) {\n throw 'You must pass an options object';\n }\n if (options.cluster == null) {\n throw 'Options object must provide a cluster';\n }\n if ('disableStats' in options) {\n Logger.warn(\n 'The disableStats option is deprecated in favor of enableStats'\n );\n }\n}\n","import {\n UserAuthenticationCallback,\n InternalAuthOptions,\n UserAuthenticationHandler,\n UserAuthenticationRequestParams,\n AuthRequestType\n} from './options';\n\nimport Runtime from 'runtime';\n\nconst composeChannelQuery = (\n params: UserAuthenticationRequestParams,\n authOptions: InternalAuthOptions\n) => {\n var query = 'socket_id=' + encodeURIComponent(params.socketId);\n\n for (var key in authOptions.params) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(authOptions.params[key]);\n }\n\n if (authOptions.paramsProvider != null) {\n let dynamicParams = authOptions.paramsProvider();\n for (var key in dynamicParams) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(dynamicParams[key]);\n }\n }\n\n return query;\n};\n\nconst UserAuthenticator = (\n authOptions: InternalAuthOptions\n): UserAuthenticationHandler => {\n if (typeof Runtime.getAuthorizers()[authOptions.transport] === 'undefined') {\n throw `'${authOptions.transport}' is not a recognized auth transport`;\n }\n\n return (\n params: UserAuthenticationRequestParams,\n callback: UserAuthenticationCallback\n ) => {\n const query = composeChannelQuery(params, authOptions);\n\n Runtime.getAuthorizers()[authOptions.transport](\n Runtime,\n query,\n authOptions,\n AuthRequestType.UserAuthentication,\n callback\n );\n };\n};\n\nexport default UserAuthenticator;\n","import {\n AuthRequestType,\n InternalAuthOptions,\n ChannelAuthorizationHandler,\n ChannelAuthorizationRequestParams,\n ChannelAuthorizationCallback\n} from './options';\n\nimport Runtime from 'runtime';\n\nconst composeChannelQuery = (\n params: ChannelAuthorizationRequestParams,\n authOptions: InternalAuthOptions\n) => {\n var query = 'socket_id=' + encodeURIComponent(params.socketId);\n\n query += '&channel_name=' + encodeURIComponent(params.channelName);\n\n for (var key in authOptions.params) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(authOptions.params[key]);\n }\n\n if (authOptions.paramsProvider != null) {\n let dynamicParams = authOptions.paramsProvider();\n for (var key in dynamicParams) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(dynamicParams[key]);\n }\n }\n\n return query;\n};\n\nconst ChannelAuthorizer = (\n authOptions: InternalAuthOptions\n): ChannelAuthorizationHandler => {\n if (typeof Runtime.getAuthorizers()[authOptions.transport] === 'undefined') {\n throw `'${authOptions.transport}' is not a recognized auth transport`;\n }\n\n return (\n params: ChannelAuthorizationRequestParams,\n callback: ChannelAuthorizationCallback\n ) => {\n const query = composeChannelQuery(params, authOptions);\n\n Runtime.getAuthorizers()[authOptions.transport](\n Runtime,\n query,\n authOptions,\n AuthRequestType.ChannelAuthorization,\n callback\n );\n };\n};\n\nexport default ChannelAuthorizer;\n","import { Options } from './options';\nimport Defaults from './defaults';\nimport {\n ChannelAuthorizationHandler,\n UserAuthenticationHandler,\n ChannelAuthorizationOptions\n} from './auth/options';\nimport UserAuthenticator from './auth/user_authenticator';\nimport ChannelAuthorizer from './auth/channel_authorizer';\nimport { ChannelAuthorizerProxy } from './auth/deprecated_channel_authorizer';\nimport Runtime from 'runtime';\nimport * as nacl from 'tweetnacl';\n\nexport type AuthTransport = 'ajax' | 'jsonp';\nexport type Transport =\n | 'ws'\n | 'wss'\n | 'xhr_streaming'\n | 'xhr_polling'\n | 'sockjs';\n\nexport interface Config {\n // these are all 'required' config parameters, it's not necessary for the user\n // to set them, but they have configured defaults.\n activityTimeout: number;\n enableStats: boolean;\n httpHost: string;\n httpPath: string;\n httpPort: number;\n httpsPort: number;\n pongTimeout: number;\n statsHost: string;\n unavailableTimeout: number;\n useTLS: boolean;\n wsHost: string;\n wsPath: string;\n wsPort: number;\n wssPort: number;\n userAuthenticator: UserAuthenticationHandler;\n channelAuthorizer: ChannelAuthorizationHandler;\n\n // these are all optional parameters or overrrides. The customer can set these\n // but it's not strictly necessary\n forceTLS?: boolean;\n cluster?: string;\n disabledTransports?: Transport[];\n enabledTransports?: Transport[];\n ignoreNullOrigin?: boolean;\n nacl?: nacl;\n timelineParams?: any;\n}\n\n// getConfig mainly sets the defaults for the options that are not provided\nexport function getConfig(opts: Options, pusher): Config {\n let config: Config = {\n activityTimeout: opts.activityTimeout || Defaults.activityTimeout,\n cluster: opts.cluster,\n httpPath: opts.httpPath || Defaults.httpPath,\n httpPort: opts.httpPort || Defaults.httpPort,\n httpsPort: opts.httpsPort || Defaults.httpsPort,\n pongTimeout: opts.pongTimeout || Defaults.pongTimeout,\n statsHost: opts.statsHost || Defaults.stats_host,\n unavailableTimeout: opts.unavailableTimeout || Defaults.unavailableTimeout,\n wsPath: opts.wsPath || Defaults.wsPath,\n wsPort: opts.wsPort || Defaults.wsPort,\n wssPort: opts.wssPort || Defaults.wssPort,\n\n enableStats: getEnableStatsConfig(opts),\n httpHost: getHttpHost(opts),\n useTLS: shouldUseTLS(opts),\n wsHost: getWebsocketHost(opts),\n\n userAuthenticator: buildUserAuthenticator(opts),\n channelAuthorizer: buildChannelAuthorizer(opts, pusher)\n };\n\n if ('disabledTransports' in opts)\n config.disabledTransports = opts.disabledTransports;\n if ('enabledTransports' in opts)\n config.enabledTransports = opts.enabledTransports;\n if ('ignoreNullOrigin' in opts)\n config.ignoreNullOrigin = opts.ignoreNullOrigin;\n if ('timelineParams' in opts) config.timelineParams = opts.timelineParams;\n if ('nacl' in opts) {\n config.nacl = opts.nacl;\n }\n\n return config;\n}\n\nfunction getHttpHost(opts: Options): string {\n if (opts.httpHost) {\n return opts.httpHost;\n }\n if (opts.cluster) {\n return `sockjs-${opts.cluster}.pusher.com`;\n }\n return Defaults.httpHost;\n}\n\nfunction getWebsocketHost(opts: Options): string {\n if (opts.wsHost) {\n return opts.wsHost;\n }\n return getWebsocketHostFromCluster(opts.cluster);\n}\n\nfunction getWebsocketHostFromCluster(cluster: string): string {\n return `ws-${cluster}.pusher.com`;\n}\n\nfunction shouldUseTLS(opts: Options): boolean {\n if (Runtime.getProtocol() === 'https:') {\n return true;\n } else if (opts.forceTLS === false) {\n return false;\n }\n return true;\n}\n\n// if enableStats is set take the value\n// if disableStats is set take the inverse\n// otherwise default to false\nfunction getEnableStatsConfig(opts: Options): boolean {\n if ('enableStats' in opts) {\n return opts.enableStats;\n }\n if ('disableStats' in opts) {\n return !opts.disableStats;\n }\n return false;\n}\n\nfunction buildUserAuthenticator(opts: Options): UserAuthenticationHandler {\n const userAuthentication = {\n ...Defaults.userAuthentication,\n ...opts.userAuthentication\n };\n if (\n 'customHandler' in userAuthentication &&\n userAuthentication['customHandler'] != null\n ) {\n return userAuthentication['customHandler'];\n }\n\n return UserAuthenticator(userAuthentication);\n}\n\nfunction buildChannelAuth(opts: Options, pusher): ChannelAuthorizationOptions {\n let channelAuthorization: ChannelAuthorizationOptions;\n if ('channelAuthorization' in opts) {\n channelAuthorization = {\n ...Defaults.channelAuthorization,\n ...opts.channelAuthorization\n };\n } else {\n channelAuthorization = {\n transport: opts.authTransport || Defaults.authTransport,\n endpoint: opts.authEndpoint || Defaults.authEndpoint\n };\n if ('auth' in opts) {\n if ('params' in opts.auth) channelAuthorization.params = opts.auth.params;\n if ('headers' in opts.auth)\n channelAuthorization.headers = opts.auth.headers;\n }\n if ('authorizer' in opts)\n channelAuthorization.customHandler = ChannelAuthorizerProxy(\n pusher,\n channelAuthorization,\n opts.authorizer\n );\n }\n return channelAuthorization;\n}\n\nfunction buildChannelAuthorizer(\n opts: Options,\n pusher\n): ChannelAuthorizationHandler {\n const channelAuthorization = buildChannelAuth(opts, pusher);\n if (\n 'customHandler' in channelAuthorization &&\n channelAuthorization['customHandler'] != null\n ) {\n return channelAuthorization['customHandler'];\n }\n\n return ChannelAuthorizer(channelAuthorization);\n}\n","import Channel from '../channels/channel';\nimport {\n ChannelAuthorizationCallback,\n ChannelAuthorizationHandler,\n ChannelAuthorizationRequestParams,\n InternalAuthOptions\n} from './options';\n\nexport interface DeprecatedChannelAuthorizer {\n authorize(socketId: string, callback: ChannelAuthorizationCallback): void;\n}\n\nexport interface ChannelAuthorizerGenerator {\n (\n channel: Channel,\n options: DeprecatedAuthorizerOptions\n ): DeprecatedChannelAuthorizer;\n}\n\nexport interface DeprecatedAuthOptions {\n params?: any;\n headers?: any;\n}\n\nexport interface DeprecatedAuthorizerOptions {\n authTransport: 'ajax' | 'jsonp';\n authEndpoint: string;\n auth?: DeprecatedAuthOptions;\n}\n\nexport const ChannelAuthorizerProxy = (\n pusher,\n authOptions: InternalAuthOptions,\n channelAuthorizerGenerator: ChannelAuthorizerGenerator\n): ChannelAuthorizationHandler => {\n const deprecatedAuthorizerOptions: DeprecatedAuthorizerOptions = {\n authTransport: authOptions.transport,\n authEndpoint: authOptions.endpoint,\n auth: {\n params: authOptions.params,\n headers: authOptions.headers\n }\n };\n return (\n params: ChannelAuthorizationRequestParams,\n callback: ChannelAuthorizationCallback\n ) => {\n const channel = pusher.channel(params.channelName);\n // This line creates a new channel authorizer every time.\n // In the past, this was only done once per channel and reused.\n // We can do that again if we want to keep this behavior intact.\n const channelAuthorizer: DeprecatedChannelAuthorizer = channelAuthorizerGenerator(\n channel,\n deprecatedAuthorizerOptions\n );\n channelAuthorizer.authorize(params.socketId, callback);\n };\n};\n","import Logger from './logger';\nimport Pusher from './pusher';\nimport EventsDispatcher from './events/dispatcher';\n\nexport default class WatchlistFacade extends EventsDispatcher {\n private pusher: Pusher;\n\n public constructor(pusher: Pusher) {\n super(function(eventName, data) {\n Logger.debug(`No callbacks on watchlist events for ${eventName}`);\n });\n\n this.pusher = pusher;\n this.bindWatchlistInternalEvent();\n }\n\n handleEvent(pusherEvent) {\n pusherEvent.data.events.forEach(watchlistEvent => {\n this.emit(watchlistEvent.name, watchlistEvent);\n });\n }\n\n private bindWatchlistInternalEvent() {\n this.pusher.connection.bind('message', pusherEvent => {\n var eventName = pusherEvent.event;\n if (eventName === 'pusher_internal:watchlist_events') {\n this.handleEvent(pusherEvent);\n }\n });\n }\n}\n","function flatPromise() {\n let resolve, reject;\n const promise = new Promise((res, rej) => {\n resolve = res;\n reject = rej;\n });\n return { promise, resolve, reject };\n}\n\nexport default flatPromise;\n","import Pusher from './pusher';\nimport Logger from './logger';\nimport {\n UserAuthenticationData,\n UserAuthenticationCallback\n} from './auth/options';\nimport Channel from './channels/channel';\nimport WatchlistFacade from './watchlist';\nimport EventsDispatcher from './events/dispatcher';\nimport flatPromise from './utils/flat_promise';\n\nexport default class UserFacade extends EventsDispatcher {\n pusher: Pusher;\n signin_requested: boolean = false;\n user_data: any = null;\n serverToUserChannel: Channel = null;\n signinDonePromise: Promise = null;\n watchlist: WatchlistFacade;\n private _signinDoneResolve: Function = null;\n\n public constructor(pusher: Pusher) {\n super(function(eventName, data) {\n Logger.debug('No callbacks on user for ' + eventName);\n });\n this.pusher = pusher;\n this.pusher.connection.bind('state_change', ({ previous, current }) => {\n if (previous !== 'connected' && current === 'connected') {\n this._signin();\n }\n if (previous === 'connected' && current !== 'connected') {\n this._cleanup();\n this._newSigninPromiseIfNeeded();\n }\n });\n\n this.watchlist = new WatchlistFacade(pusher);\n\n this.pusher.connection.bind('message', event => {\n var eventName = event.event;\n if (eventName === 'pusher:signin_success') {\n this._onSigninSuccess(event.data);\n }\n if (\n this.serverToUserChannel &&\n this.serverToUserChannel.name === event.channel\n ) {\n this.serverToUserChannel.handleEvent(event);\n }\n });\n }\n\n public signin() {\n if (this.signin_requested) {\n return;\n }\n\n this.signin_requested = true;\n this._signin();\n }\n\n private _signin() {\n if (!this.signin_requested) {\n return;\n }\n\n this._newSigninPromiseIfNeeded();\n\n if (this.pusher.connection.state !== 'connected') {\n // Signin will be attempted when the connection is connected\n return;\n }\n\n this.pusher.config.userAuthenticator(\n {\n socketId: this.pusher.connection.socket_id\n },\n this._onAuthorize\n );\n }\n\n private _onAuthorize: UserAuthenticationCallback = (\n err,\n authData: UserAuthenticationData\n ) => {\n if (err) {\n Logger.warn(`Error during signin: ${err}`);\n this._cleanup();\n return;\n }\n\n this.pusher.send_event('pusher:signin', {\n auth: authData.auth,\n user_data: authData.user_data\n });\n\n // Later when we get pusher:singin_success event, the user will be marked as signed in\n };\n\n private _onSigninSuccess(data: any) {\n try {\n this.user_data = JSON.parse(data.user_data);\n } catch (e) {\n Logger.error(`Failed parsing user data after signin: ${data.user_data}`);\n this._cleanup();\n return;\n }\n\n if (typeof this.user_data.id !== 'string' || this.user_data.id === '') {\n Logger.error(\n `user_data doesn't contain an id. user_data: ${this.user_data}`\n );\n this._cleanup();\n return;\n }\n\n // Signin succeeded\n this._signinDoneResolve();\n this._subscribeChannels();\n }\n\n private _subscribeChannels() {\n const ensure_subscribed = channel => {\n if (channel.subscriptionPending && channel.subscriptionCancelled) {\n channel.reinstateSubscription();\n } else if (\n !channel.subscriptionPending &&\n this.pusher.connection.state === 'connected'\n ) {\n channel.subscribe();\n }\n };\n\n this.serverToUserChannel = new Channel(\n `#server-to-user-${this.user_data.id}`,\n this.pusher\n );\n this.serverToUserChannel.bind_global((eventName, data) => {\n if (\n eventName.indexOf('pusher_internal:') === 0 ||\n eventName.indexOf('pusher:') === 0\n ) {\n // ignore internal events\n return;\n }\n this.emit(eventName, data);\n });\n ensure_subscribed(this.serverToUserChannel);\n }\n\n private _cleanup() {\n this.user_data = null;\n if (this.serverToUserChannel) {\n this.serverToUserChannel.unbind_all();\n this.serverToUserChannel.disconnect();\n this.serverToUserChannel = null;\n }\n\n if (this.signin_requested) {\n // If signin is in progress and cleanup is called,\n // Mark the current signin process as done.\n this._signinDoneResolve();\n }\n }\n\n private _newSigninPromiseIfNeeded() {\n if (!this.signin_requested) {\n return;\n }\n\n // If there is a promise and it is not resolved, return without creating a new one.\n if (this.signinDonePromise && !(this.signinDonePromise as any).done) {\n return;\n }\n\n // This promise is never rejected.\n // It gets resolved when the signin process is done whether it failed or succeeded\n const { promise, resolve, reject: _ } = flatPromise();\n (promise as any).done = false;\n const setDone = () => {\n (promise as any).done = true;\n };\n promise.then(setDone).catch(setDone);\n this.signinDonePromise = promise;\n this._signinDoneResolve = resolve;\n }\n}\n","import AbstractRuntime from '../runtimes/interface';\nimport Runtime from 'runtime';\nimport * as Collections from './utils/collections';\nimport Channels from './channels/channels';\nimport Channel from './channels/channel';\nimport { default as EventsDispatcher } from './events/dispatcher';\nimport Timeline from './timeline/timeline';\nimport TimelineSender from './timeline/timeline_sender';\nimport TimelineLevel from './timeline/level';\nimport { defineTransport } from './strategies/strategy_builder';\nimport ConnectionManager from './connection/connection_manager';\nimport { PeriodicTimer } from './utils/timers';\nimport Defaults from './defaults';\nimport Logger from './logger';\nimport Factory from './utils/factory';\nimport { Options, ClusterOptions, validateOptions } from './options';\nimport { Config, getConfig } from './config';\nimport StrategyOptions from './strategies/strategy_options';\nimport UserFacade from './user';\n\nexport default class Pusher {\n /* STATIC PROPERTIES */\n static instances: Pusher[] = [];\n static isReady: boolean = false;\n static logToConsole: boolean = false;\n\n // for jsonp\n static Runtime: AbstractRuntime = Runtime;\n static ScriptReceivers: any = (Runtime).ScriptReceivers;\n static DependenciesReceivers: any = (Runtime).DependenciesReceivers;\n static auth_callbacks: any = (Runtime).auth_callbacks;\n\n static ready() {\n Pusher.isReady = true;\n for (var i = 0, l = Pusher.instances.length; i < l; i++) {\n Pusher.instances[i].connect();\n }\n }\n\n static log: (message: any) => void;\n\n private static getClientFeatures(): string[] {\n return Collections.keys(\n Collections.filterObject({ ws: Runtime.Transports.ws }, function(t) {\n return t.isSupported({});\n })\n );\n }\n\n /* INSTANCE PROPERTIES */\n key: string;\n options: Options;\n config: Config;\n channels: Channels;\n global_emitter: EventsDispatcher;\n sessionID: number;\n timeline: Timeline;\n timelineSender: TimelineSender;\n connection: ConnectionManager;\n timelineSenderTimer: PeriodicTimer;\n user: UserFacade;\n constructor(app_key: string, options: Options) {\n checkAppKey(app_key);\n validateOptions(options);\n this.key = app_key;\n this.config = getConfig(options, this);\n\n this.channels = Factory.createChannels();\n this.global_emitter = new EventsDispatcher();\n this.sessionID = Runtime.randomInt(1000000000);\n\n this.timeline = new Timeline(this.key, this.sessionID, {\n cluster: this.config.cluster,\n features: Pusher.getClientFeatures(),\n params: this.config.timelineParams || {},\n limit: 50,\n level: TimelineLevel.INFO,\n version: Defaults.VERSION\n });\n if (this.config.enableStats) {\n this.timelineSender = Factory.createTimelineSender(this.timeline, {\n host: this.config.statsHost,\n path: '/timeline/v2/' + Runtime.TimelineTransport.name\n });\n }\n\n var getStrategy = (options: StrategyOptions) => {\n return Runtime.getDefaultStrategy(this.config, options, defineTransport);\n };\n\n this.connection = Factory.createConnectionManager(this.key, {\n getStrategy: getStrategy,\n timeline: this.timeline,\n activityTimeout: this.config.activityTimeout,\n pongTimeout: this.config.pongTimeout,\n unavailableTimeout: this.config.unavailableTimeout,\n useTLS: Boolean(this.config.useTLS)\n });\n\n this.connection.bind('connected', () => {\n this.subscribeAll();\n if (this.timelineSender) {\n this.timelineSender.send(this.connection.isUsingTLS());\n }\n });\n\n this.connection.bind('message', event => {\n var eventName = event.event;\n var internal = eventName.indexOf('pusher_internal:') === 0;\n if (event.channel) {\n var channel = this.channel(event.channel);\n if (channel) {\n channel.handleEvent(event);\n }\n }\n // Emit globally [deprecated]\n if (!internal) {\n this.global_emitter.emit(event.event, event.data);\n }\n });\n this.connection.bind('connecting', () => {\n this.channels.disconnect();\n });\n this.connection.bind('disconnected', () => {\n this.channels.disconnect();\n });\n this.connection.bind('error', err => {\n Logger.warn(err);\n });\n\n Pusher.instances.push(this);\n this.timeline.info({ instances: Pusher.instances.length });\n\n this.user = new UserFacade(this);\n\n if (Pusher.isReady) {\n this.connect();\n }\n }\n\n /**\n * Allows you to switch Pusher cluster without\n * losing all the channels/subscription binding\n * as this is internally managed by the SDK.\n */\n switchCluster(options: ClusterOptions) {\n const { appKey, cluster } = options;\n this.key = appKey;\n this.options = { ...this.options, cluster };\n this.config = getConfig(this.options, this);\n this.connection.switchCluster(this.key);\n }\n\n channel(name: string): Channel {\n return this.channels.find(name);\n }\n\n allChannels(): Channel[] {\n return this.channels.all();\n }\n\n connect() {\n this.connection.connect();\n\n if (this.timelineSender) {\n if (!this.timelineSenderTimer) {\n var usingTLS = this.connection.isUsingTLS();\n var timelineSender = this.timelineSender;\n this.timelineSenderTimer = new PeriodicTimer(60000, function() {\n timelineSender.send(usingTLS);\n });\n }\n }\n }\n\n disconnect() {\n this.connection.disconnect();\n\n if (this.timelineSenderTimer) {\n this.timelineSenderTimer.ensureAborted();\n this.timelineSenderTimer = null;\n }\n }\n\n bind(event_name: string, callback: Function, context?: any): Pusher {\n this.global_emitter.bind(event_name, callback, context);\n return this;\n }\n\n unbind(event_name?: string, callback?: Function, context?: any): Pusher {\n this.global_emitter.unbind(event_name, callback, context);\n return this;\n }\n\n bind_global(callback: Function): Pusher {\n this.global_emitter.bind_global(callback);\n return this;\n }\n\n unbind_global(callback?: Function): Pusher {\n this.global_emitter.unbind_global(callback);\n return this;\n }\n\n unbind_all(callback?: Function): Pusher {\n this.global_emitter.unbind_all();\n return this;\n }\n\n subscribeAll() {\n var channelName;\n for (channelName in this.channels.channels) {\n if (this.channels.channels.hasOwnProperty(channelName)) {\n this.subscribe(channelName);\n }\n }\n }\n\n subscribe(channel_name: string) {\n var channel = this.channels.add(channel_name, this);\n if (channel.subscriptionPending && channel.subscriptionCancelled) {\n channel.reinstateSubscription();\n } else if (\n !channel.subscriptionPending &&\n this.connection.state === 'connected'\n ) {\n channel.subscribe();\n }\n return channel;\n }\n\n unsubscribe(channel_name: string) {\n var channel = this.channels.find(channel_name);\n if (channel && channel.subscriptionPending) {\n channel.cancelSubscription();\n } else {\n channel = this.channels.remove(channel_name);\n if (channel && channel.subscribed) {\n channel.unsubscribe();\n }\n }\n }\n\n send_event(event_name: string, data: any, channel?: string) {\n return this.connection.send_event(event_name, data, channel);\n }\n\n shouldUseTLS(): boolean {\n return this.config.useTLS;\n }\n\n signin() {\n this.user.signin();\n }\n}\n\nfunction checkAppKey(key) {\n if (key === null || key === undefined) {\n throw 'You must pass your app key when you instantiate Pusher.';\n }\n}\n\nRuntime.setup(Pusher);\n","import Pusher from './pusher';\nimport { Options, validateOptions } from './options';\nimport * as nacl from 'tweetnacl';\n\nexport default class PusherWithEncryption extends Pusher {\n constructor(app_key: string, options: Options) {\n Pusher.logToConsole = PusherWithEncryption.logToConsole;\n Pusher.log = PusherWithEncryption.log;\n\n validateOptions(options);\n options.nacl = nacl;\n super(app_key, options);\n }\n}\n"],"sourceRoot":""} \ No newline at end of file +{"version":3,"sources":["webpack://Pusher/webpack/universalModuleDefinition","webpack://Pusher/webpack/bootstrap","webpack://Pusher/./node_modules/@stablelib/base64/base64.ts","webpack://Pusher/./node_modules/@stablelib/utf8/utf8.ts","webpack://Pusher/./node_modules/tweetnacl/nacl-fast.js","webpack://Pusher/./src/core/pusher-with-encryption.js","webpack://Pusher/./src/core/base64.ts","webpack://Pusher/./src/core/utils/timers/abstract_timer.ts","webpack://Pusher/./src/core/utils/timers/index.ts","webpack://Pusher/./src/core/util.ts","webpack://Pusher/./src/core/utils/collections.ts","webpack://Pusher/./src/core/defaults.ts","webpack://Pusher/./src/core/transports/url_schemes.ts","webpack://Pusher/./src/core/events/callback_registry.ts","webpack://Pusher/./src/core/events/dispatcher.ts","webpack://Pusher/./src/core/logger.ts","webpack://Pusher/./src/core/transports/transport_connection.ts","webpack://Pusher/./src/core/transports/transport.ts","webpack://Pusher/./src/runtimes/isomorphic/transports/transports.ts","webpack://Pusher/./src/core/transports/assistant_to_the_transport_manager.ts","webpack://Pusher/./src/core/connection/protocol/protocol.ts","webpack://Pusher/./src/core/connection/connection.ts","webpack://Pusher/./src/core/connection/handshake/index.ts","webpack://Pusher/./src/core/timeline/timeline_sender.ts","webpack://Pusher/./src/core/errors.ts","webpack://Pusher/./src/core/utils/url_store.ts","webpack://Pusher/./src/core/channels/channel.ts","webpack://Pusher/./src/core/channels/private_channel.ts","webpack://Pusher/./src/core/channels/members.ts","webpack://Pusher/./src/core/channels/presence_channel.ts","webpack://Pusher/./src/core/channels/encrypted_channel.ts","webpack://Pusher/./src/core/connection/connection_manager.ts","webpack://Pusher/./src/core/channels/channels.ts","webpack://Pusher/./src/core/utils/factory.ts","webpack://Pusher/./src/core/transports/transport_manager.ts","webpack://Pusher/./src/core/strategies/sequential_strategy.ts","webpack://Pusher/./src/core/strategies/best_connected_ever_strategy.ts","webpack://Pusher/./src/core/strategies/websocket_prioritized_cached_strategy.ts","webpack://Pusher/./src/core/strategies/delayed_strategy.ts","webpack://Pusher/./src/core/strategies/if_strategy.ts","webpack://Pusher/./src/core/strategies/first_connected_strategy.ts","webpack://Pusher/./src/runtimes/isomorphic/default_strategy.ts","webpack://Pusher/./src/core/http/http_request.ts","webpack://Pusher/./src/core/http/state.ts","webpack://Pusher/./src/core/http/http_socket.ts","webpack://Pusher/./src/core/http/http_streaming_socket.ts","webpack://Pusher/./src/core/http/http_polling_socket.ts","webpack://Pusher/./src/runtimes/isomorphic/http/http_xhr_request.ts","webpack://Pusher/./src/runtimes/isomorphic/runtime.ts","webpack://Pusher/./src/runtimes/isomorphic/transports/transport_connection_initializer.ts","webpack://Pusher/./src/runtimes/isomorphic/http/http.ts","webpack://Pusher/./src/runtimes/worker/net_info.ts","webpack://Pusher/./src/runtimes/worker/auth/fetch_auth.ts","webpack://Pusher/./src/runtimes/worker/timeline/fetch_timeline.ts","webpack://Pusher/./src/runtimes/worker/runtime.ts","webpack://Pusher/./src/core/timeline/level.ts","webpack://Pusher/./src/core/timeline/timeline.ts","webpack://Pusher/./src/core/strategies/transport_strategy.ts","webpack://Pusher/./src/core/strategies/strategy_builder.ts","webpack://Pusher/./src/core/auth/options.ts","webpack://Pusher/./src/core/options.ts","webpack://Pusher/./src/core/auth/user_authenticator.ts","webpack://Pusher/./src/core/auth/channel_authorizer.ts","webpack://Pusher/./src/core/config.ts","webpack://Pusher/./src/core/auth/deprecated_channel_authorizer.ts","webpack://Pusher/./src/core/watchlist.ts","webpack://Pusher/./src/core/utils/flat_promise.ts","webpack://Pusher/./src/core/user.ts","webpack://Pusher/./src/core/pusher.ts","webpack://Pusher/./src/core/pusher-with-encryption.ts"],"names":["root","factory","exports","module","define","amd","this","installedModules","__webpack_require__","moduleId","i","l","modules","call","m","c","d","name","getter","o","Object","defineProperty","enumerable","get","r","Symbol","toStringTag","value","t","mode","__esModule","ns","create","key","bind","n","object","property","prototype","hasOwnProperty","p","s","_paddingCharacter","encodedLength","length","encode","data","out","_encodeByte","left","maxDecodedLength","decodedLength","_getPaddingLength","decode","Uint8Array","paddingLength","op","haveBad","v0","v1","v2","v3","_decodeChar","charCodeAt","Error","b","result","String","fromCharCode","Coder","stdCoder","URLSafeCoder","urlSafeCoder","INVALID_UTF8","arr","pos","chars","min","n1","n2","n3","push","join","nacl","gf","init","Float64Array","randombytes","_0","_9","gf0","gf1","_121665","D","D2","X","Y","I","ts64","x","h","vn","xi","y","yi","crypto_verify_16","crypto_verify_32","crypto_core_salsa20","inp","k","u","j0","j1","j2","j3","j4","j5","j6","j7","j8","j9","j10","j11","j12","j13","j14","j15","x0","x1","x2","x3","x4","x5","x6","x7","x8","x9","x10","x11","x12","x13","x14","x15","core_salsa20","crypto_core_hsalsa20","core_hsalsa20","sigma","crypto_stream_salsa20_xor","cpos","mpos","z","crypto_stream_salsa20","crypto_stream","sn","crypto_stream_xor","poly1305","t0","t1","t2","t3","t4","t5","t6","t7","buffer","Uint16Array","pad","leftover","fin","crypto_onetimeauth","outpos","update","finish","crypto_onetimeauth_verify","hpos","crypto_secretbox","crypto_secretbox_open","set25519","a","car25519","v","Math","floor","sel25519","q","pack25519","j","neq25519","par25519","unpack25519","A","Z","M","t8","t9","t10","t11","t12","t13","t14","t15","t16","t17","t18","t19","t20","t21","t22","t23","t24","t25","t26","t27","t28","t29","t30","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","b10","b11","b12","b13","b14","b15","S","inv25519","pow2523","crypto_scalarmult","e","f","x32","subarray","x16","crypto_scalarmult_base","crypto_box_keypair","crypto_box_beforenm","blocks","bytes","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","hibit","h0","h1","h2","h3","h4","h5","h6","h7","h8","h9","r0","r1","r2","r3","r4","r5","r6","r7","r8","r9","mac","macpos","mask","g","want","crypto_box_afternm","crypto_box_open_afternm","K","crypto_hashblocks_hl","hh","hl","bh0","bh1","bh2","bh3","bh4","bh5","bh6","bh7","bl0","bl1","bl2","bl3","bl4","bl5","bl6","bl7","th","tl","wh","Int32Array","wl","ah0","ah1","ah2","ah3","ah4","ah5","ah6","ah7","al0","al1","al2","al3","al4","al5","al6","al7","crypto_hash","add","cswap","pack","tx","ty","zi","scalarmult","scalarbase","crypto_sign_keypair","pk","sk","seeded","L","modL","carry","reduce","crypto_sign","sm","smlen","crypto_sign_open","chk","num","den","den2","den4","den6","unpackneg","checkLengths","checkArrayTypes","arguments","TypeError","cleanup","lowlevel","crypto_box","crypto_box_open","crypto_secretbox_KEYBYTES","crypto_secretbox_NONCEBYTES","crypto_secretbox_ZEROBYTES","crypto_secretbox_BOXZEROBYTES","crypto_scalarmult_BYTES","crypto_scalarmult_SCALARBYTES","crypto_box_PUBLICKEYBYTES","crypto_box_SECRETKEYBYTES","crypto_box_BEFORENMBYTES","crypto_box_NONCEBYTES","crypto_box_ZEROBYTES","crypto_box_BOXZEROBYTES","crypto_sign_BYTES","crypto_sign_PUBLICKEYBYTES","crypto_sign_SECRETKEYBYTES","crypto_sign_SEEDBYTES","crypto_hash_BYTES","randomBytes","secretbox","msg","nonce","open","box","keyLength","nonceLength","overheadLength","scalarMult","base","scalarLength","groupElementLength","publicKey","secretKey","before","checkBoxLengths","after","keyPair","fromSecretKey","publicKeyLength","secretKeyLength","sharedKeyLength","sign","signedMsg","tmp","mlen","detached","sig","verify","fromSeed","seed","seedLength","signatureLength","hash","hashLength","setPRNG","fn","crypto","self","msCrypto","getRandomValues","default","b64chars","b64tab","charAt","cb_utob","cc","utob","replace","cb_encode","ccc","padlen","ord","btoa","set","clear","delay","callback","timer","clearTimeout","clearInterval","super","setTimeout","setInterval","now","Date","valueOf","defer","args","boundArguments","Array","slice","apply","concat","extend","target","sources","extensions","constructor","stringify","safeJSONStringify","arrayIndexOf","array","item","nativeIndexOf","indexOf","objectApply","keys","_","context","map","filter","test","filterObject","Boolean","any","encodeParamsObject","encodeURIComponent","toString","buildQueryString","params","undefined","method","source","JSON","objects","paths","derez","path","nu","$ref","VERSION","PROTOCOL","wsPort","wssPort","wsPath","httpHost","httpPort","httpsPort","httpPath","stats_host","authEndpoint","authTransport","activityTimeout","pongTimeout","unavailableTimeout","userAuthentication","endpoint","transport","channelAuthorization","cdn_http","cdn_https","dependency_suffix","getGenericURL","baseScheme","useTLS","hostTLS","hostNonTLS","getGenericPath","queryString","ws","getInitial","http","_callbacks","prefix","prefixedEventName","names","removeCallback","removeAllCallbacks","binding","failThrough","callbacks","global_callbacks","eventName","remove","unbind","unbind_global","metadata","globalLog","message","console","log","globalLogWarn","globalLogError","warn","error","defaultLoggingFunction","logToConsole","hooks","priority","options","initialize","transportConnectionInitializer","state","timeline","id","generateUniqueID","handlesActivityChecks","supportsPing","socket","url","urls","getSocket","onError","changeState","bindListeners","debug","close","send","ping","beforeOpen","getPath","onopen","emit","type","buildTimelineMessage","closeEvent","code","reason","wasClean","unbindListeners","onOpen","onerror","onclose","onClose","onmessage","onMessage","onactivity","onActivity","info","cid","environment","isSupported","WSTransport","isInitialized","getWebSocketAPI","createWebSocket","httpConfiguration","streamingConfiguration","HTTPFactory","createStreamingSocket","pollingConfiguration","createPollingSocket","xhrConfiguration","isXHRSupported","xhr_streaming","xhr_polling","manager","minPingDelay","maxPingDelay","pingDelay","connection","createConnection","openTimestamp","onClosed","reportDeath","lifespan","max","isAlive","Protocol","decodeMessage","messageEvent","messageData","parse","pusherEventData","pusherEvent","event","channel","user_id","encodeMessage","processHandshake","activity_timeout","action","socket_id","getCloseAction","getCloseError","send_event","listeners","activity","closed","handleCloseEvent","listener","isEmpty","TimelineTransport","getAgent","BadEventName","setPrototypeOf","BadChannelName","TransportPriorityTooLow","TransportClosed","UnsupportedFeature","UnsupportedTransport","UnsupportedStrategy","HTTPAuthError","status","urlStore","baseUrl","authenticationEndpoint","authorizationEndpoint","javascriptQuickStart","triggeringClientEvents","encryptedChannelSupport","fullUrl","urlObj","pusher","subscribed","subscriptionPending","subscriptionCancelled","socketId","auth","suffix","handleSubscriptionSucceededEvent","handleSubscriptionCountEvent","unsubscribe","subscription_count","subscriptionCount","authorize","assign","channel_data","config","channelAuthorizer","channelName","reset","members","member","myID","subscriptionData","presence","count","me","memberData","user_info","authData","channelData","setMyID","user","signinDonePromise","user_data","handleInternalEvent","addedMember","addMember","removedMember","removeMember","onSubscription","disconnect","sharedSecret","handleEncryptedEvent","handleEvent","ciphertext","cipherText","getDataToEmit","raw","usingTLS","errorCallbacks","buildErrorCallbacks","connectionCallbacks","buildConnectionCallbacks","handshakeCallbacks","buildHandshakeCallbacks","Network","getNetwork","netinfo","retryIn","sendActivityCheck","updateStrategy","runner","strategy","updateState","startConnecting","setUnavailableTimer","disconnectInternally","handshake","connect","handshakeError","abortConnecting","abort","clearRetryTimer","clearUnavailableTimer","abandonConnection","getStrategy","round","retryTimer","ensureAborted","unavailableTimer","stopActivityCheck","activityTimer","pong_timed_out","resetActivityCheck","shouldRetry","connected","Infinity","setConnection","withErrorEmitted","tls_only","refused","backoff","retry","newState","previousState","newStateDescription","previous","current","channels","createEncryptedChannel","errMsg","createPrivateChannel","createPresenceChannel","createChannel","values","createChannels","createConnectionManager","createTimelineSender","createHandshake","createAssistantToTheTransportManager","livesLeft","lives","strategies","loop","failFast","timeout","timeoutLimit","minPriority","tryNextStrategy","tryStrategy","forceMinPriority","isRunning","callbackBuilder","runners","rs","abortRunner","allRunnersFailed","aborted","transports","ttl","storage","getLocalStorage","serializedCache","getTransportCacheKey","flushTransportCache","fetchTransportCache","cacheSkipCount","timestamp","includes","cached","latency","startTimestamp","pop","cb","storeTransportCache","number","IfStrategy","trueBranch","falseBranch","FirstConnectedStrategy","testSupportsStrategy","baseOptions","defineTransport","definedTransports","defineTransportStrategy","wsStrategy","ws_options","wsHost","wss_options","http_options","timeouts","ws_manager","streaming_manager","ws_transport","wss_transport","xhr_streaming_transport","xhr_polling_transport","ws_loop","wss_loop","streaming_loop","polling_loop","http_loop","payload","position","xhr","getRequest","unloader","addUnloadListener","setRequestHeader","removeUnloadListener","abortRequest","chunk","advanceBuffer","isBufferTooLong","unreadData","endOfLinePosition","State","autoIncrement","getUniqueURL","separator","randomNumber","randomInt","session","randomString","location","parts","exec","getLocation","readyState","CONNECTING","openStream","sendRaw","sendHeartbeat","OPEN","createSocketRequest","start","closeStream","CLOSED","onEvent","onHeartbeat","hostname","urlParts","stream","getReceiveURL","onChunk","onFinished","reconnect","unbind_all","getXHRAPI","onreadystatechange","onprogress","responseText","getDefaultStrategy","Transports","createSocket","createRequest","PusherClass","ready","getClientFeatures","getProtocol","createXHR","query","authOptions","authRequestType","headers","Headers","headerName","headersProvider","dynamicHeaders","body","request","Request","credentials","fetch","then","response","text","parsedData","catch","err","sender","host","json","setup","TimelineLevel","getAuthorizers","ajax","WebSocket","XMLHttpRequest","globalThis","Uint32Array","events","sent","uniqueID","level","limit","shift","ERROR","INFO","DEBUG","sendfn","bundle","lib","version","cluster","features","failAttempt","onInitialized","serializedTransport","AuthRequestType","transportClass","enabledTransports","disabledTransports","ignoreNullOrigin","getAssistant","deferred","validateOptions","paramsProvider","dynamicParams","composeChannelQuery","UserAuthentication","ChannelAuthorization","getConfig","opts","statsHost","enableStats","getEnableStatsConfig","getHttpHost","shouldUseTLS","getWebsocketHost","userAuthenticator","buildUserAuthenticator","buildChannelAuthorizer","timelineParams","forceTLS","disableStats","customHandler","channelAuthorizerGenerator","deprecatedAuthorizerOptions","ChannelAuthorizerProxy","authorizer","buildChannelAuth","bindWatchlistInternalEvent","forEach","watchlistEvent","resolve","reject","promise","Promise","res","rej","signin_requested","serverToUserChannel","_signinDoneResolve","_onAuthorize","_cleanup","_signin","_newSigninPromiseIfNeeded","watchlist","_onSigninSuccess","_subscribeChannels","bind_global","reinstateSubscription","subscribe","ensure_subscribed","done","setDone","isReady","instances","app_key","checkAppKey","global_emitter","sessionID","timelineSender","subscribeAll","isUsingTLS","internal","appKey","switchCluster","find","all","timelineSenderTimer","event_name","channel_name","cancelSubscription","signin","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nG,GAC3B9a,KAGT,WAAW8a,GAET,OADA9a,KAAKs+B,eAAe5H,aACb12B,KAGT,eACE,IAAIkqB,EACJ,IAAKA,KAAelqB,KAAKmvB,SAASA,SAC5BnvB,KAAKmvB,SAASA,SAASltB,eAAeioB,IACxClqB,KAAK89B,UAAU5T,GAKrB,UAAUgV,GACR,IAAItY,EAAU5mB,KAAKmvB,SAASnb,IAAIkrB,EAAcl/B,MAS9C,OARI4mB,EAAQuC,qBAAuBvC,EAAQwC,sBACzCxC,EAAQiX,wBAEPjX,EAAQuC,qBACiB,cAA1BnpB,KAAK4lB,WAAW1D,OAEhB0E,EAAQkX,YAEHlX,EAGT,YAAYsY,GACV,IAAItY,EAAU5mB,KAAKmvB,SAAS2P,KAAKI,GAC7BtY,GAAWA,EAAQuC,oBACrBvC,EAAQuY,sBAERvY,EAAU5mB,KAAKmvB,SAASpO,OAAOme,KAChBtY,EAAQsC,YACrBtC,EAAQ8C,cAKd,WAAWuV,EAAoBz8B,EAAWokB,GACxC,OAAO5mB,KAAK4lB,WAAWyB,WAAW4X,EAAYz8B,EAAMokB,GAGtD,eACE,OAAO5mB,KAAKgqB,OAAOpK,OAGrB,SACE5f,KAAKgrB,KAAKoU,UAtOL,GAAAjB,UAAsB,GACtB,GAAAD,SAAmB,EACnB,GAAAtc,cAAwB,EAGxB,GAAAyd,QAA2B,GAC3B,GAAAC,gBAA6B,GAASA,gBACtC,GAAAC,sBAAmC,GAASA,sBAC5C,GAAAC,eAA4B,GAASA,eAVzB,UAkPrB,GAAQ1G,MAAM,I,YClQC,MAAM,WAA6B,GAChD,YAAYsF,EAAiBrc,GAC3B,GAAOH,aAAe,GAAqBA,aAC3C,GAAON,IAAM,GAAqBA,IAElCyZ,GAAgBhZ,GAChBA,EAAQld,KAAO,GACfqW,MAAMkjB,EAASrc","file":"pusher-with-encryption.worker.min.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"Pusher\"] = factory();\n\telse\n\t\troot[\"Pusher\"] = factory();\n})(this, function() {\nreturn "," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 3);\n","// Copyright (C) 2016 Dmitry Chestnykh\n// MIT License. See LICENSE file for details.\n\n/**\n * Package base64 implements Base64 encoding and decoding.\n */\n\n// Invalid character used in decoding to indicate\n// that the character to decode is out of range of\n// alphabet and cannot be decoded.\nconst INVALID_BYTE = 256;\n\n/**\n * Implements standard Base64 encoding.\n *\n * Operates in constant time.\n */\nexport class Coder {\n // TODO(dchest): methods to encode chunk-by-chunk.\n\n constructor(private _paddingCharacter = \"=\") { }\n\n encodedLength(length: number): number {\n if (!this._paddingCharacter) {\n return (length * 8 + 5) / 6 | 0;\n }\n return (length + 2) / 3 * 4 | 0;\n }\n\n encode(data: Uint8Array): string {\n let out = \"\";\n\n let i = 0;\n for (; i < data.length - 2; i += 3) {\n let c = (data[i] << 16) | (data[i + 1] << 8) | (data[i + 2]);\n out += this._encodeByte((c >>> 3 * 6) & 63);\n out += this._encodeByte((c >>> 2 * 6) & 63);\n out += this._encodeByte((c >>> 1 * 6) & 63);\n out += this._encodeByte((c >>> 0 * 6) & 63);\n }\n\n const left = data.length - i;\n if (left > 0) {\n let c = (data[i] << 16) | (left === 2 ? data[i + 1] << 8 : 0);\n out += this._encodeByte((c >>> 3 * 6) & 63);\n out += this._encodeByte((c >>> 2 * 6) & 63);\n if (left === 2) {\n out += this._encodeByte((c >>> 1 * 6) & 63);\n } else {\n out += this._paddingCharacter || \"\";\n }\n out += this._paddingCharacter || \"\";\n }\n\n return out;\n }\n\n maxDecodedLength(length: number): number {\n if (!this._paddingCharacter) {\n return (length * 6 + 7) / 8 | 0;\n }\n return length / 4 * 3 | 0;\n }\n\n decodedLength(s: string): number {\n return this.maxDecodedLength(s.length - this._getPaddingLength(s));\n }\n\n decode(s: string): Uint8Array {\n if (s.length === 0) {\n return new Uint8Array(0);\n }\n const paddingLength = this._getPaddingLength(s);\n const length = s.length - paddingLength;\n const out = new Uint8Array(this.maxDecodedLength(length));\n let op = 0;\n let i = 0;\n let haveBad = 0;\n let v0 = 0, v1 = 0, v2 = 0, v3 = 0;\n for (; i < length - 4; i += 4) {\n v0 = this._decodeChar(s.charCodeAt(i + 0));\n v1 = this._decodeChar(s.charCodeAt(i + 1));\n v2 = this._decodeChar(s.charCodeAt(i + 2));\n v3 = this._decodeChar(s.charCodeAt(i + 3));\n out[op++] = (v0 << 2) | (v1 >>> 4);\n out[op++] = (v1 << 4) | (v2 >>> 2);\n out[op++] = (v2 << 6) | v3;\n haveBad |= v0 & INVALID_BYTE;\n haveBad |= v1 & INVALID_BYTE;\n haveBad |= v2 & INVALID_BYTE;\n haveBad |= v3 & INVALID_BYTE;\n }\n if (i < length - 1) {\n v0 = this._decodeChar(s.charCodeAt(i));\n v1 = this._decodeChar(s.charCodeAt(i + 1));\n out[op++] = (v0 << 2) | (v1 >>> 4);\n haveBad |= v0 & INVALID_BYTE;\n haveBad |= v1 & INVALID_BYTE;\n }\n if (i < length - 2) {\n v2 = this._decodeChar(s.charCodeAt(i + 2));\n out[op++] = (v1 << 4) | (v2 >>> 2);\n haveBad |= v2 & INVALID_BYTE;\n }\n if (i < length - 3) {\n v3 = this._decodeChar(s.charCodeAt(i + 3));\n out[op++] = (v2 << 6) | v3;\n haveBad |= v3 & INVALID_BYTE;\n }\n if (haveBad !== 0) {\n throw new Error(\"Base64Coder: incorrect characters for decoding\");\n }\n return out;\n }\n\n // Standard encoding have the following encoded/decoded ranges,\n // which we need to convert between.\n //\n // ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 0123456789 + /\n // Index: 0 - 25 26 - 51 52 - 61 62 63\n // ASCII: 65 - 90 97 - 122 48 - 57 43 47\n //\n\n // Encode 6 bits in b into a new character.\n protected _encodeByte(b: number): string {\n // Encoding uses constant time operations as follows:\n //\n // 1. Define comparison of A with B using (A - B) >>> 8:\n // if A > B, then result is positive integer\n // if A <= B, then result is 0\n //\n // 2. Define selection of C or 0 using bitwise AND: X & C:\n // if X == 0, then result is 0\n // if X != 0, then result is C\n //\n // 3. Start with the smallest comparison (b >= 0), which is always\n // true, so set the result to the starting ASCII value (65).\n //\n // 4. Continue comparing b to higher ASCII values, and selecting\n // zero if comparison isn't true, otherwise selecting a value\n // to add to result, which:\n //\n // a) undoes the previous addition\n // b) provides new value to add\n //\n let result = b;\n // b >= 0\n result += 65;\n // b > 25\n result += ((25 - b) >>> 8) & ((0 - 65) - 26 + 97);\n // b > 51\n result += ((51 - b) >>> 8) & ((26 - 97) - 52 + 48);\n // b > 61\n result += ((61 - b) >>> 8) & ((52 - 48) - 62 + 43);\n // b > 62\n result += ((62 - b) >>> 8) & ((62 - 43) - 63 + 47);\n\n return String.fromCharCode(result);\n }\n\n // Decode a character code into a byte.\n // Must return 256 if character is out of alphabet range.\n protected _decodeChar(c: number): number {\n // Decoding works similar to encoding: using the same comparison\n // function, but now it works on ranges: result is always incremented\n // by value, but this value becomes zero if the range is not\n // satisfied.\n //\n // Decoding starts with invalid value, 256, which is then\n // subtracted when the range is satisfied. If none of the ranges\n // apply, the function returns 256, which is then checked by\n // the caller to throw error.\n let result = INVALID_BYTE; // start with invalid character\n\n // c == 43 (c > 42 and c < 44)\n result += (((42 - c) & (c - 44)) >>> 8) & (-INVALID_BYTE + c - 43 + 62);\n // c == 47 (c > 46 and c < 48)\n result += (((46 - c) & (c - 48)) >>> 8) & (-INVALID_BYTE + c - 47 + 63);\n // c > 47 and c < 58\n result += (((47 - c) & (c - 58)) >>> 8) & (-INVALID_BYTE + c - 48 + 52);\n // c > 64 and c < 91\n result += (((64 - c) & (c - 91)) >>> 8) & (-INVALID_BYTE + c - 65 + 0);\n // c > 96 and c < 123\n result += (((96 - c) & (c - 123)) >>> 8) & (-INVALID_BYTE + c - 97 + 26);\n\n return result;\n }\n\n private _getPaddingLength(s: string): number {\n let paddingLength = 0;\n if (this._paddingCharacter) {\n for (let i = s.length - 1; i >= 0; i--) {\n if (s[i] !== this._paddingCharacter) {\n break;\n }\n paddingLength++;\n }\n if (s.length < 4 || paddingLength > 2) {\n throw new Error(\"Base64Coder: incorrect padding\");\n }\n }\n return paddingLength;\n }\n\n}\n\nconst stdCoder = new Coder();\n\nexport function encode(data: Uint8Array): string {\n return stdCoder.encode(data);\n}\n\nexport function decode(s: string): Uint8Array {\n return stdCoder.decode(s);\n}\n\n/**\n * Implements URL-safe Base64 encoding.\n * (Same as Base64, but '+' is replaced with '-', and '/' with '_').\n *\n * Operates in constant time.\n */\nexport class URLSafeCoder extends Coder {\n // URL-safe encoding have the following encoded/decoded ranges:\n //\n // ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 0123456789 - _\n // Index: 0 - 25 26 - 51 52 - 61 62 63\n // ASCII: 65 - 90 97 - 122 48 - 57 45 95\n //\n\n protected _encodeByte(b: number): string {\n let result = b;\n // b >= 0\n result += 65;\n // b > 25\n result += ((25 - b) >>> 8) & ((0 - 65) - 26 + 97);\n // b > 51\n result += ((51 - b) >>> 8) & ((26 - 97) - 52 + 48);\n // b > 61\n result += ((61 - b) >>> 8) & ((52 - 48) - 62 + 45);\n // b > 62\n result += ((62 - b) >>> 8) & ((62 - 45) - 63 + 95);\n\n return String.fromCharCode(result);\n }\n\n protected _decodeChar(c: number): number {\n let result = INVALID_BYTE;\n\n // c == 45 (c > 44 and c < 46)\n result += (((44 - c) & (c - 46)) >>> 8) & (-INVALID_BYTE + c - 45 + 62);\n // c == 95 (c > 94 and c < 96)\n result += (((94 - c) & (c - 96)) >>> 8) & (-INVALID_BYTE + c - 95 + 63);\n // c > 47 and c < 58\n result += (((47 - c) & (c - 58)) >>> 8) & (-INVALID_BYTE + c - 48 + 52);\n // c > 64 and c < 91\n result += (((64 - c) & (c - 91)) >>> 8) & (-INVALID_BYTE + c - 65 + 0);\n // c > 96 and c < 123\n result += (((96 - c) & (c - 123)) >>> 8) & (-INVALID_BYTE + c - 97 + 26);\n\n return result;\n }\n}\n\nconst urlSafeCoder = new URLSafeCoder();\n\nexport function encodeURLSafe(data: Uint8Array): string {\n return urlSafeCoder.encode(data);\n}\n\nexport function decodeURLSafe(s: string): Uint8Array {\n return urlSafeCoder.decode(s);\n}\n\n\nexport const encodedLength = (length: number) =>\n stdCoder.encodedLength(length);\n\nexport const maxDecodedLength = (length: number) =>\n stdCoder.maxDecodedLength(length);\n\nexport const decodedLength = (s: string) =>\n stdCoder.decodedLength(s);\n","// Copyright (C) 2016 Dmitry Chestnykh\n// MIT License. See LICENSE file for details.\n\n/**\n * Package utf8 implements UTF-8 encoding and decoding.\n */\n\nconst INVALID_UTF16 = \"utf8: invalid string\";\nconst INVALID_UTF8 = \"utf8: invalid source encoding\";\n\n/**\n * Encodes the given string into UTF-8 byte array.\n * Throws if the source string has invalid UTF-16 encoding.\n */\nexport function encode(s: string): Uint8Array {\n // Calculate result length and allocate output array.\n // encodedLength() also validates string and throws errors,\n // so we don't need repeat validation here.\n const arr = new Uint8Array(encodedLength(s));\n\n let pos = 0;\n for (let i = 0; i < s.length; i++) {\n let c = s.charCodeAt(i);\n if (c < 0x80) {\n arr[pos++] = c;\n } else if (c < 0x800) {\n arr[pos++] = 0xc0 | c >> 6;\n arr[pos++] = 0x80 | c & 0x3f;\n } else if (c < 0xd800) {\n arr[pos++] = 0xe0 | c >> 12;\n arr[pos++] = 0x80 | (c >> 6) & 0x3f;\n arr[pos++] = 0x80 | c & 0x3f;\n } else {\n i++; // get one more character\n c = (c & 0x3ff) << 10;\n c |= s.charCodeAt(i) & 0x3ff;\n c += 0x10000;\n\n arr[pos++] = 0xf0 | c >> 18;\n arr[pos++] = 0x80 | (c >> 12) & 0x3f;\n arr[pos++] = 0x80 | (c >> 6) & 0x3f;\n arr[pos++] = 0x80 | c & 0x3f;\n }\n }\n return arr;\n}\n\n/**\n * Returns the number of bytes required to encode the given string into UTF-8.\n * Throws if the source string has invalid UTF-16 encoding.\n */\nexport function encodedLength(s: string): number {\n let result = 0;\n for (let i = 0; i < s.length; i++) {\n const c = s.charCodeAt(i);\n if (c < 0x80) {\n result += 1;\n } else if (c < 0x800) {\n result += 2;\n } else if (c < 0xd800) {\n result += 3;\n } else if (c <= 0xdfff) {\n if (i >= s.length - 1) {\n throw new Error(INVALID_UTF16);\n }\n i++; // \"eat\" next character\n result += 4;\n } else {\n throw new Error(INVALID_UTF16);\n }\n }\n return result;\n}\n\n/**\n * Decodes the given byte array from UTF-8 into a string.\n * Throws if encoding is invalid.\n */\nexport function decode(arr: Uint8Array): string {\n const chars: string[] = [];\n for (let i = 0; i < arr.length; i++) {\n let b = arr[i];\n\n if (b & 0x80) {\n let min;\n if (b < 0xe0) {\n // Need 1 more byte.\n if (i >= arr.length) {\n throw new Error(INVALID_UTF8);\n }\n const n1 = arr[++i];\n if ((n1 & 0xc0) !== 0x80) {\n throw new Error(INVALID_UTF8);\n }\n b = (b & 0x1f) << 6 | (n1 & 0x3f);\n min = 0x80;\n } else if (b < 0xf0) {\n // Need 2 more bytes.\n if (i >= arr.length - 1) {\n throw new Error(INVALID_UTF8);\n }\n const n1 = arr[++i];\n const n2 = arr[++i];\n if ((n1 & 0xc0) !== 0x80 || (n2 & 0xc0) !== 0x80) {\n throw new Error(INVALID_UTF8);\n }\n b = (b & 0x0f) << 12 | (n1 & 0x3f) << 6 | (n2 & 0x3f);\n min = 0x800;\n } else if (b < 0xf8) {\n // Need 3 more bytes.\n if (i >= arr.length - 2) {\n throw new Error(INVALID_UTF8);\n }\n const n1 = arr[++i];\n const n2 = arr[++i];\n const n3 = arr[++i];\n if ((n1 & 0xc0) !== 0x80 || (n2 & 0xc0) !== 0x80 || (n3 & 0xc0) !== 0x80) {\n throw new Error(INVALID_UTF8);\n }\n b = (b & 0x0f) << 18 | (n1 & 0x3f) << 12 | (n2 & 0x3f) << 6 | (n3 & 0x3f);\n min = 0x10000;\n } else {\n throw new Error(INVALID_UTF8);\n }\n\n if (b < min || (b >= 0xd800 && b <= 0xdfff)) {\n throw new Error(INVALID_UTF8);\n }\n\n if (b >= 0x10000) {\n // Surrogate pair.\n if (b > 0x10ffff) {\n throw new Error(INVALID_UTF8);\n }\n b -= 0x10000;\n chars.push(String.fromCharCode(0xd800 | (b >> 10)));\n b = 0xdc00 | (b & 0x3ff);\n }\n }\n\n chars.push(String.fromCharCode(b));\n }\n return chars.join(\"\");\n}\n","(function(nacl) {\n'use strict';\n\n// Ported in 2014 by Dmitry Chestnykh and Devi Mandiri.\n// Public domain.\n//\n// Implementation derived from TweetNaCl version 20140427.\n// See for details: http://tweetnacl.cr.yp.to/\n\nvar gf = function(init) {\n var i, r = new Float64Array(16);\n if (init) for (i = 0; i < init.length; i++) r[i] = init[i];\n return r;\n};\n\n// Pluggable, initialized in high-level API below.\nvar randombytes = function(/* x, n */) { throw new Error('no PRNG'); };\n\nvar _0 = new Uint8Array(16);\nvar _9 = new Uint8Array(32); _9[0] = 9;\n\nvar gf0 = gf(),\n gf1 = gf([1]),\n _121665 = gf([0xdb41, 1]),\n D = gf([0x78a3, 0x1359, 0x4dca, 0x75eb, 0xd8ab, 0x4141, 0x0a4d, 0x0070, 0xe898, 0x7779, 0x4079, 0x8cc7, 0xfe73, 0x2b6f, 0x6cee, 0x5203]),\n D2 = gf([0xf159, 0x26b2, 0x9b94, 0xebd6, 0xb156, 0x8283, 0x149a, 0x00e0, 0xd130, 0xeef3, 0x80f2, 0x198e, 0xfce7, 0x56df, 0xd9dc, 0x2406]),\n X = gf([0xd51a, 0x8f25, 0x2d60, 0xc956, 0xa7b2, 0x9525, 0xc760, 0x692c, 0xdc5c, 0xfdd6, 0xe231, 0xc0a4, 0x53fe, 0xcd6e, 0x36d3, 0x2169]),\n Y = gf([0x6658, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666]),\n I = gf([0xa0b0, 0x4a0e, 0x1b27, 0xc4ee, 0xe478, 0xad2f, 0x1806, 0x2f43, 0xd7a7, 0x3dfb, 0x0099, 0x2b4d, 0xdf0b, 0x4fc1, 0x2480, 0x2b83]);\n\nfunction ts64(x, i, h, l) {\n x[i] = (h >> 24) & 0xff;\n x[i+1] = (h >> 16) & 0xff;\n x[i+2] = (h >> 8) & 0xff;\n x[i+3] = h & 0xff;\n x[i+4] = (l >> 24) & 0xff;\n x[i+5] = (l >> 16) & 0xff;\n x[i+6] = (l >> 8) & 0xff;\n x[i+7] = l & 0xff;\n}\n\nfunction vn(x, xi, y, yi, n) {\n var i,d = 0;\n for (i = 0; i < n; i++) d |= x[xi+i]^y[yi+i];\n return (1 & ((d - 1) >>> 8)) - 1;\n}\n\nfunction crypto_verify_16(x, xi, y, yi) {\n return vn(x,xi,y,yi,16);\n}\n\nfunction crypto_verify_32(x, xi, y, yi) {\n return vn(x,xi,y,yi,32);\n}\n\nfunction core_salsa20(o, p, k, c) {\n var j0 = c[ 0] & 0xff | (c[ 1] & 0xff)<<8 | (c[ 2] & 0xff)<<16 | (c[ 3] & 0xff)<<24,\n j1 = k[ 0] & 0xff | (k[ 1] & 0xff)<<8 | (k[ 2] & 0xff)<<16 | (k[ 3] & 0xff)<<24,\n j2 = k[ 4] & 0xff | (k[ 5] & 0xff)<<8 | (k[ 6] & 0xff)<<16 | (k[ 7] & 0xff)<<24,\n j3 = k[ 8] & 0xff | (k[ 9] & 0xff)<<8 | (k[10] & 0xff)<<16 | (k[11] & 0xff)<<24,\n j4 = k[12] & 0xff | (k[13] & 0xff)<<8 | (k[14] & 0xff)<<16 | (k[15] & 0xff)<<24,\n j5 = c[ 4] & 0xff | (c[ 5] & 0xff)<<8 | (c[ 6] & 0xff)<<16 | (c[ 7] & 0xff)<<24,\n j6 = p[ 0] & 0xff | (p[ 1] & 0xff)<<8 | (p[ 2] & 0xff)<<16 | (p[ 3] & 0xff)<<24,\n j7 = p[ 4] & 0xff | (p[ 5] & 0xff)<<8 | (p[ 6] & 0xff)<<16 | (p[ 7] & 0xff)<<24,\n j8 = p[ 8] & 0xff | (p[ 9] & 0xff)<<8 | (p[10] & 0xff)<<16 | (p[11] & 0xff)<<24,\n j9 = p[12] & 0xff | (p[13] & 0xff)<<8 | (p[14] & 0xff)<<16 | (p[15] & 0xff)<<24,\n j10 = c[ 8] & 0xff | (c[ 9] & 0xff)<<8 | (c[10] & 0xff)<<16 | (c[11] & 0xff)<<24,\n j11 = k[16] & 0xff | (k[17] & 0xff)<<8 | (k[18] & 0xff)<<16 | (k[19] & 0xff)<<24,\n j12 = k[20] & 0xff | (k[21] & 0xff)<<8 | (k[22] & 0xff)<<16 | (k[23] & 0xff)<<24,\n j13 = k[24] & 0xff | (k[25] & 0xff)<<8 | (k[26] & 0xff)<<16 | (k[27] & 0xff)<<24,\n j14 = k[28] & 0xff | (k[29] & 0xff)<<8 | (k[30] & 0xff)<<16 | (k[31] & 0xff)<<24,\n j15 = c[12] & 0xff | (c[13] & 0xff)<<8 | (c[14] & 0xff)<<16 | (c[15] & 0xff)<<24;\n\n var x0 = j0, x1 = j1, x2 = j2, x3 = j3, x4 = j4, x5 = j5, x6 = j6, x7 = j7,\n x8 = j8, x9 = j9, x10 = j10, x11 = j11, x12 = j12, x13 = j13, x14 = j14,\n x15 = j15, u;\n\n for (var i = 0; i < 20; i += 2) {\n u = x0 + x12 | 0;\n x4 ^= u<<7 | u>>>(32-7);\n u = x4 + x0 | 0;\n x8 ^= u<<9 | u>>>(32-9);\n u = x8 + x4 | 0;\n x12 ^= u<<13 | u>>>(32-13);\n u = x12 + x8 | 0;\n x0 ^= u<<18 | u>>>(32-18);\n\n u = x5 + x1 | 0;\n x9 ^= u<<7 | u>>>(32-7);\n u = x9 + x5 | 0;\n x13 ^= u<<9 | u>>>(32-9);\n u = x13 + x9 | 0;\n x1 ^= u<<13 | u>>>(32-13);\n u = x1 + x13 | 0;\n x5 ^= u<<18 | u>>>(32-18);\n\n u = x10 + x6 | 0;\n x14 ^= u<<7 | u>>>(32-7);\n u = x14 + x10 | 0;\n x2 ^= u<<9 | u>>>(32-9);\n u = x2 + x14 | 0;\n x6 ^= u<<13 | u>>>(32-13);\n u = x6 + x2 | 0;\n x10 ^= u<<18 | u>>>(32-18);\n\n u = x15 + x11 | 0;\n x3 ^= u<<7 | u>>>(32-7);\n u = x3 + x15 | 0;\n x7 ^= u<<9 | u>>>(32-9);\n u = x7 + x3 | 0;\n x11 ^= u<<13 | u>>>(32-13);\n u = x11 + x7 | 0;\n x15 ^= u<<18 | u>>>(32-18);\n\n u = x0 + x3 | 0;\n x1 ^= u<<7 | u>>>(32-7);\n u = x1 + x0 | 0;\n x2 ^= u<<9 | u>>>(32-9);\n u = x2 + x1 | 0;\n x3 ^= u<<13 | u>>>(32-13);\n u = x3 + x2 | 0;\n x0 ^= u<<18 | u>>>(32-18);\n\n u = x5 + x4 | 0;\n x6 ^= u<<7 | u>>>(32-7);\n u = x6 + x5 | 0;\n x7 ^= u<<9 | u>>>(32-9);\n u = x7 + x6 | 0;\n x4 ^= u<<13 | u>>>(32-13);\n u = x4 + x7 | 0;\n x5 ^= u<<18 | u>>>(32-18);\n\n u = x10 + x9 | 0;\n x11 ^= u<<7 | u>>>(32-7);\n u = x11 + x10 | 0;\n x8 ^= u<<9 | u>>>(32-9);\n u = x8 + x11 | 0;\n x9 ^= u<<13 | u>>>(32-13);\n u = x9 + x8 | 0;\n x10 ^= u<<18 | u>>>(32-18);\n\n u = x15 + x14 | 0;\n x12 ^= u<<7 | u>>>(32-7);\n u = x12 + x15 | 0;\n x13 ^= u<<9 | u>>>(32-9);\n u = x13 + x12 | 0;\n x14 ^= u<<13 | u>>>(32-13);\n u = x14 + x13 | 0;\n x15 ^= u<<18 | u>>>(32-18);\n }\n x0 = x0 + j0 | 0;\n x1 = x1 + j1 | 0;\n x2 = x2 + j2 | 0;\n x3 = x3 + j3 | 0;\n x4 = x4 + j4 | 0;\n x5 = x5 + j5 | 0;\n x6 = x6 + j6 | 0;\n x7 = x7 + j7 | 0;\n x8 = x8 + j8 | 0;\n x9 = x9 + j9 | 0;\n x10 = x10 + j10 | 0;\n x11 = x11 + j11 | 0;\n x12 = x12 + j12 | 0;\n x13 = x13 + j13 | 0;\n x14 = x14 + j14 | 0;\n x15 = x15 + j15 | 0;\n\n o[ 0] = x0 >>> 0 & 0xff;\n o[ 1] = x0 >>> 8 & 0xff;\n o[ 2] = x0 >>> 16 & 0xff;\n o[ 3] = x0 >>> 24 & 0xff;\n\n o[ 4] = x1 >>> 0 & 0xff;\n o[ 5] = x1 >>> 8 & 0xff;\n o[ 6] = x1 >>> 16 & 0xff;\n o[ 7] = x1 >>> 24 & 0xff;\n\n o[ 8] = x2 >>> 0 & 0xff;\n o[ 9] = x2 >>> 8 & 0xff;\n o[10] = x2 >>> 16 & 0xff;\n o[11] = x2 >>> 24 & 0xff;\n\n o[12] = x3 >>> 0 & 0xff;\n o[13] = x3 >>> 8 & 0xff;\n o[14] = x3 >>> 16 & 0xff;\n o[15] = x3 >>> 24 & 0xff;\n\n o[16] = x4 >>> 0 & 0xff;\n o[17] = x4 >>> 8 & 0xff;\n o[18] = x4 >>> 16 & 0xff;\n o[19] = x4 >>> 24 & 0xff;\n\n o[20] = x5 >>> 0 & 0xff;\n o[21] = x5 >>> 8 & 0xff;\n o[22] = x5 >>> 16 & 0xff;\n o[23] = x5 >>> 24 & 0xff;\n\n o[24] = x6 >>> 0 & 0xff;\n o[25] = x6 >>> 8 & 0xff;\n o[26] = x6 >>> 16 & 0xff;\n o[27] = x6 >>> 24 & 0xff;\n\n o[28] = x7 >>> 0 & 0xff;\n o[29] = x7 >>> 8 & 0xff;\n o[30] = x7 >>> 16 & 0xff;\n o[31] = x7 >>> 24 & 0xff;\n\n o[32] = x8 >>> 0 & 0xff;\n o[33] = x8 >>> 8 & 0xff;\n o[34] = x8 >>> 16 & 0xff;\n o[35] = x8 >>> 24 & 0xff;\n\n o[36] = x9 >>> 0 & 0xff;\n o[37] = x9 >>> 8 & 0xff;\n o[38] = x9 >>> 16 & 0xff;\n o[39] = x9 >>> 24 & 0xff;\n\n o[40] = x10 >>> 0 & 0xff;\n o[41] = x10 >>> 8 & 0xff;\n o[42] = x10 >>> 16 & 0xff;\n o[43] = x10 >>> 24 & 0xff;\n\n o[44] = x11 >>> 0 & 0xff;\n o[45] = x11 >>> 8 & 0xff;\n o[46] = x11 >>> 16 & 0xff;\n o[47] = x11 >>> 24 & 0xff;\n\n o[48] = x12 >>> 0 & 0xff;\n o[49] = x12 >>> 8 & 0xff;\n o[50] = x12 >>> 16 & 0xff;\n o[51] = x12 >>> 24 & 0xff;\n\n o[52] = x13 >>> 0 & 0xff;\n o[53] = x13 >>> 8 & 0xff;\n o[54] = x13 >>> 16 & 0xff;\n o[55] = x13 >>> 24 & 0xff;\n\n o[56] = x14 >>> 0 & 0xff;\n o[57] = x14 >>> 8 & 0xff;\n o[58] = x14 >>> 16 & 0xff;\n o[59] = x14 >>> 24 & 0xff;\n\n o[60] = x15 >>> 0 & 0xff;\n o[61] = x15 >>> 8 & 0xff;\n o[62] = x15 >>> 16 & 0xff;\n o[63] = x15 >>> 24 & 0xff;\n}\n\nfunction core_hsalsa20(o,p,k,c) {\n var j0 = c[ 0] & 0xff | (c[ 1] & 0xff)<<8 | (c[ 2] & 0xff)<<16 | (c[ 3] & 0xff)<<24,\n j1 = k[ 0] & 0xff | (k[ 1] & 0xff)<<8 | (k[ 2] & 0xff)<<16 | (k[ 3] & 0xff)<<24,\n j2 = k[ 4] & 0xff | (k[ 5] & 0xff)<<8 | (k[ 6] & 0xff)<<16 | (k[ 7] & 0xff)<<24,\n j3 = k[ 8] & 0xff | (k[ 9] & 0xff)<<8 | (k[10] & 0xff)<<16 | (k[11] & 0xff)<<24,\n j4 = k[12] & 0xff | (k[13] & 0xff)<<8 | (k[14] & 0xff)<<16 | (k[15] & 0xff)<<24,\n j5 = c[ 4] & 0xff | (c[ 5] & 0xff)<<8 | (c[ 6] & 0xff)<<16 | (c[ 7] & 0xff)<<24,\n j6 = p[ 0] & 0xff | (p[ 1] & 0xff)<<8 | (p[ 2] & 0xff)<<16 | (p[ 3] & 0xff)<<24,\n j7 = p[ 4] & 0xff | (p[ 5] & 0xff)<<8 | (p[ 6] & 0xff)<<16 | (p[ 7] & 0xff)<<24,\n j8 = p[ 8] & 0xff | (p[ 9] & 0xff)<<8 | (p[10] & 0xff)<<16 | (p[11] & 0xff)<<24,\n j9 = p[12] & 0xff | (p[13] & 0xff)<<8 | (p[14] & 0xff)<<16 | (p[15] & 0xff)<<24,\n j10 = c[ 8] & 0xff | (c[ 9] & 0xff)<<8 | (c[10] & 0xff)<<16 | (c[11] & 0xff)<<24,\n j11 = k[16] & 0xff | (k[17] & 0xff)<<8 | (k[18] & 0xff)<<16 | (k[19] & 0xff)<<24,\n j12 = k[20] & 0xff | (k[21] & 0xff)<<8 | (k[22] & 0xff)<<16 | (k[23] & 0xff)<<24,\n j13 = k[24] & 0xff | (k[25] & 0xff)<<8 | (k[26] & 0xff)<<16 | (k[27] & 0xff)<<24,\n j14 = k[28] & 0xff | (k[29] & 0xff)<<8 | (k[30] & 0xff)<<16 | (k[31] & 0xff)<<24,\n j15 = c[12] & 0xff | (c[13] & 0xff)<<8 | (c[14] & 0xff)<<16 | (c[15] & 0xff)<<24;\n\n var x0 = j0, x1 = j1, x2 = j2, x3 = j3, x4 = j4, x5 = j5, x6 = j6, x7 = j7,\n x8 = j8, x9 = j9, x10 = j10, x11 = j11, x12 = j12, x13 = j13, x14 = j14,\n x15 = j15, u;\n\n for (var i = 0; i < 20; i += 2) {\n u = x0 + x12 | 0;\n x4 ^= u<<7 | u>>>(32-7);\n u = x4 + x0 | 0;\n x8 ^= u<<9 | u>>>(32-9);\n u = x8 + x4 | 0;\n x12 ^= u<<13 | u>>>(32-13);\n u = x12 + x8 | 0;\n x0 ^= u<<18 | u>>>(32-18);\n\n u = x5 + x1 | 0;\n x9 ^= u<<7 | u>>>(32-7);\n u = x9 + x5 | 0;\n x13 ^= u<<9 | u>>>(32-9);\n u = x13 + x9 | 0;\n x1 ^= u<<13 | u>>>(32-13);\n u = x1 + x13 | 0;\n x5 ^= u<<18 | u>>>(32-18);\n\n u = x10 + x6 | 0;\n x14 ^= u<<7 | u>>>(32-7);\n u = x14 + x10 | 0;\n x2 ^= u<<9 | u>>>(32-9);\n u = x2 + x14 | 0;\n x6 ^= u<<13 | u>>>(32-13);\n u = x6 + x2 | 0;\n x10 ^= u<<18 | u>>>(32-18);\n\n u = x15 + x11 | 0;\n x3 ^= u<<7 | u>>>(32-7);\n u = x3 + x15 | 0;\n x7 ^= u<<9 | u>>>(32-9);\n u = x7 + x3 | 0;\n x11 ^= u<<13 | u>>>(32-13);\n u = x11 + x7 | 0;\n x15 ^= u<<18 | u>>>(32-18);\n\n u = x0 + x3 | 0;\n x1 ^= u<<7 | u>>>(32-7);\n u = x1 + x0 | 0;\n x2 ^= u<<9 | u>>>(32-9);\n u = x2 + x1 | 0;\n x3 ^= u<<13 | u>>>(32-13);\n u = x3 + x2 | 0;\n x0 ^= u<<18 | u>>>(32-18);\n\n u = x5 + x4 | 0;\n x6 ^= u<<7 | u>>>(32-7);\n u = x6 + x5 | 0;\n x7 ^= u<<9 | u>>>(32-9);\n u = x7 + x6 | 0;\n x4 ^= u<<13 | u>>>(32-13);\n u = x4 + x7 | 0;\n x5 ^= u<<18 | u>>>(32-18);\n\n u = x10 + x9 | 0;\n x11 ^= u<<7 | u>>>(32-7);\n u = x11 + x10 | 0;\n x8 ^= u<<9 | u>>>(32-9);\n u = x8 + x11 | 0;\n x9 ^= u<<13 | u>>>(32-13);\n u = x9 + x8 | 0;\n x10 ^= u<<18 | u>>>(32-18);\n\n u = x15 + x14 | 0;\n x12 ^= u<<7 | u>>>(32-7);\n u = x12 + x15 | 0;\n x13 ^= u<<9 | u>>>(32-9);\n u = x13 + x12 | 0;\n x14 ^= u<<13 | u>>>(32-13);\n u = x14 + x13 | 0;\n x15 ^= u<<18 | u>>>(32-18);\n }\n\n o[ 0] = x0 >>> 0 & 0xff;\n o[ 1] = x0 >>> 8 & 0xff;\n o[ 2] = x0 >>> 16 & 0xff;\n o[ 3] = x0 >>> 24 & 0xff;\n\n o[ 4] = x5 >>> 0 & 0xff;\n o[ 5] = x5 >>> 8 & 0xff;\n o[ 6] = x5 >>> 16 & 0xff;\n o[ 7] = x5 >>> 24 & 0xff;\n\n o[ 8] = x10 >>> 0 & 0xff;\n o[ 9] = x10 >>> 8 & 0xff;\n o[10] = x10 >>> 16 & 0xff;\n o[11] = x10 >>> 24 & 0xff;\n\n o[12] = x15 >>> 0 & 0xff;\n o[13] = x15 >>> 8 & 0xff;\n o[14] = x15 >>> 16 & 0xff;\n o[15] = x15 >>> 24 & 0xff;\n\n o[16] = x6 >>> 0 & 0xff;\n o[17] = x6 >>> 8 & 0xff;\n o[18] = x6 >>> 16 & 0xff;\n o[19] = x6 >>> 24 & 0xff;\n\n o[20] = x7 >>> 0 & 0xff;\n o[21] = x7 >>> 8 & 0xff;\n o[22] = x7 >>> 16 & 0xff;\n o[23] = x7 >>> 24 & 0xff;\n\n o[24] = x8 >>> 0 & 0xff;\n o[25] = x8 >>> 8 & 0xff;\n o[26] = x8 >>> 16 & 0xff;\n o[27] = x8 >>> 24 & 0xff;\n\n o[28] = x9 >>> 0 & 0xff;\n o[29] = x9 >>> 8 & 0xff;\n o[30] = x9 >>> 16 & 0xff;\n o[31] = x9 >>> 24 & 0xff;\n}\n\nfunction crypto_core_salsa20(out,inp,k,c) {\n core_salsa20(out,inp,k,c);\n}\n\nfunction crypto_core_hsalsa20(out,inp,k,c) {\n core_hsalsa20(out,inp,k,c);\n}\n\nvar sigma = new Uint8Array([101, 120, 112, 97, 110, 100, 32, 51, 50, 45, 98, 121, 116, 101, 32, 107]);\n // \"expand 32-byte k\"\n\nfunction crypto_stream_salsa20_xor(c,cpos,m,mpos,b,n,k) {\n var z = new Uint8Array(16), x = new Uint8Array(64);\n var u, i;\n for (i = 0; i < 16; i++) z[i] = 0;\n for (i = 0; i < 8; i++) z[i] = n[i];\n while (b >= 64) {\n crypto_core_salsa20(x,z,k,sigma);\n for (i = 0; i < 64; i++) c[cpos+i] = m[mpos+i] ^ x[i];\n u = 1;\n for (i = 8; i < 16; i++) {\n u = u + (z[i] & 0xff) | 0;\n z[i] = u & 0xff;\n u >>>= 8;\n }\n b -= 64;\n cpos += 64;\n mpos += 64;\n }\n if (b > 0) {\n crypto_core_salsa20(x,z,k,sigma);\n for (i = 0; i < b; i++) c[cpos+i] = m[mpos+i] ^ x[i];\n }\n return 0;\n}\n\nfunction crypto_stream_salsa20(c,cpos,b,n,k) {\n var z = new Uint8Array(16), x = new Uint8Array(64);\n var u, i;\n for (i = 0; i < 16; i++) z[i] = 0;\n for (i = 0; i < 8; i++) z[i] = n[i];\n while (b >= 64) {\n crypto_core_salsa20(x,z,k,sigma);\n for (i = 0; i < 64; i++) c[cpos+i] = x[i];\n u = 1;\n for (i = 8; i < 16; i++) {\n u = u + (z[i] & 0xff) | 0;\n z[i] = u & 0xff;\n u >>>= 8;\n }\n b -= 64;\n cpos += 64;\n }\n if (b > 0) {\n crypto_core_salsa20(x,z,k,sigma);\n for (i = 0; i < b; i++) c[cpos+i] = x[i];\n }\n return 0;\n}\n\nfunction crypto_stream(c,cpos,d,n,k) {\n var s = new Uint8Array(32);\n crypto_core_hsalsa20(s,n,k,sigma);\n var sn = new Uint8Array(8);\n for (var i = 0; i < 8; i++) sn[i] = n[i+16];\n return crypto_stream_salsa20(c,cpos,d,sn,s);\n}\n\nfunction crypto_stream_xor(c,cpos,m,mpos,d,n,k) {\n var s = new Uint8Array(32);\n crypto_core_hsalsa20(s,n,k,sigma);\n var sn = new Uint8Array(8);\n for (var i = 0; i < 8; i++) sn[i] = n[i+16];\n return crypto_stream_salsa20_xor(c,cpos,m,mpos,d,sn,s);\n}\n\n/*\n* Port of Andrew Moon's Poly1305-donna-16. Public domain.\n* https://github.com/floodyberry/poly1305-donna\n*/\n\nvar poly1305 = function(key) {\n this.buffer = new Uint8Array(16);\n this.r = new Uint16Array(10);\n this.h = new Uint16Array(10);\n this.pad = new Uint16Array(8);\n this.leftover = 0;\n this.fin = 0;\n\n var t0, t1, t2, t3, t4, t5, t6, t7;\n\n t0 = key[ 0] & 0xff | (key[ 1] & 0xff) << 8; this.r[0] = ( t0 ) & 0x1fff;\n t1 = key[ 2] & 0xff | (key[ 3] & 0xff) << 8; this.r[1] = ((t0 >>> 13) | (t1 << 3)) & 0x1fff;\n t2 = key[ 4] & 0xff | (key[ 5] & 0xff) << 8; this.r[2] = ((t1 >>> 10) | (t2 << 6)) & 0x1f03;\n t3 = key[ 6] & 0xff | (key[ 7] & 0xff) << 8; this.r[3] = ((t2 >>> 7) | (t3 << 9)) & 0x1fff;\n t4 = key[ 8] & 0xff | (key[ 9] & 0xff) << 8; this.r[4] = ((t3 >>> 4) | (t4 << 12)) & 0x00ff;\n this.r[5] = ((t4 >>> 1)) & 0x1ffe;\n t5 = key[10] & 0xff | (key[11] & 0xff) << 8; this.r[6] = ((t4 >>> 14) | (t5 << 2)) & 0x1fff;\n t6 = key[12] & 0xff | (key[13] & 0xff) << 8; this.r[7] = ((t5 >>> 11) | (t6 << 5)) & 0x1f81;\n t7 = key[14] & 0xff | (key[15] & 0xff) << 8; this.r[8] = ((t6 >>> 8) | (t7 << 8)) & 0x1fff;\n this.r[9] = ((t7 >>> 5)) & 0x007f;\n\n this.pad[0] = key[16] & 0xff | (key[17] & 0xff) << 8;\n this.pad[1] = key[18] & 0xff | (key[19] & 0xff) << 8;\n this.pad[2] = key[20] & 0xff | (key[21] & 0xff) << 8;\n this.pad[3] = key[22] & 0xff | (key[23] & 0xff) << 8;\n this.pad[4] = key[24] & 0xff | (key[25] & 0xff) << 8;\n this.pad[5] = key[26] & 0xff | (key[27] & 0xff) << 8;\n this.pad[6] = key[28] & 0xff | (key[29] & 0xff) << 8;\n this.pad[7] = key[30] & 0xff | (key[31] & 0xff) << 8;\n};\n\npoly1305.prototype.blocks = function(m, mpos, bytes) {\n var hibit = this.fin ? 0 : (1 << 11);\n var t0, t1, t2, t3, t4, t5, t6, t7, c;\n var d0, d1, d2, d3, d4, d5, d6, d7, d8, d9;\n\n var h0 = this.h[0],\n h1 = this.h[1],\n h2 = this.h[2],\n h3 = this.h[3],\n h4 = this.h[4],\n h5 = this.h[5],\n h6 = this.h[6],\n h7 = this.h[7],\n h8 = this.h[8],\n h9 = this.h[9];\n\n var r0 = this.r[0],\n r1 = this.r[1],\n r2 = this.r[2],\n r3 = this.r[3],\n r4 = this.r[4],\n r5 = this.r[5],\n r6 = this.r[6],\n r7 = this.r[7],\n r8 = this.r[8],\n r9 = this.r[9];\n\n while (bytes >= 16) {\n t0 = m[mpos+ 0] & 0xff | (m[mpos+ 1] & 0xff) << 8; h0 += ( t0 ) & 0x1fff;\n t1 = m[mpos+ 2] & 0xff | (m[mpos+ 3] & 0xff) << 8; h1 += ((t0 >>> 13) | (t1 << 3)) & 0x1fff;\n t2 = m[mpos+ 4] & 0xff | (m[mpos+ 5] & 0xff) << 8; h2 += ((t1 >>> 10) | (t2 << 6)) & 0x1fff;\n t3 = m[mpos+ 6] & 0xff | (m[mpos+ 7] & 0xff) << 8; h3 += ((t2 >>> 7) | (t3 << 9)) & 0x1fff;\n t4 = m[mpos+ 8] & 0xff | (m[mpos+ 9] & 0xff) << 8; h4 += ((t3 >>> 4) | (t4 << 12)) & 0x1fff;\n h5 += ((t4 >>> 1)) & 0x1fff;\n t5 = m[mpos+10] & 0xff | (m[mpos+11] & 0xff) << 8; h6 += ((t4 >>> 14) | (t5 << 2)) & 0x1fff;\n t6 = m[mpos+12] & 0xff | (m[mpos+13] & 0xff) << 8; h7 += ((t5 >>> 11) | (t6 << 5)) & 0x1fff;\n t7 = m[mpos+14] & 0xff | (m[mpos+15] & 0xff) << 8; h8 += ((t6 >>> 8) | (t7 << 8)) & 0x1fff;\n h9 += ((t7 >>> 5)) | hibit;\n\n c = 0;\n\n d0 = c;\n d0 += h0 * r0;\n d0 += h1 * (5 * r9);\n d0 += h2 * (5 * r8);\n d0 += h3 * (5 * r7);\n d0 += h4 * (5 * r6);\n c = (d0 >>> 13); d0 &= 0x1fff;\n d0 += h5 * (5 * r5);\n d0 += h6 * (5 * r4);\n d0 += h7 * (5 * r3);\n d0 += h8 * (5 * r2);\n d0 += h9 * (5 * r1);\n c += (d0 >>> 13); d0 &= 0x1fff;\n\n d1 = c;\n d1 += h0 * r1;\n d1 += h1 * r0;\n d1 += h2 * (5 * r9);\n d1 += h3 * (5 * r8);\n d1 += h4 * (5 * r7);\n c = (d1 >>> 13); d1 &= 0x1fff;\n d1 += h5 * (5 * r6);\n d1 += h6 * (5 * r5);\n d1 += h7 * (5 * r4);\n d1 += h8 * (5 * r3);\n d1 += h9 * (5 * r2);\n c += (d1 >>> 13); d1 &= 0x1fff;\n\n d2 = c;\n d2 += h0 * r2;\n d2 += h1 * r1;\n d2 += h2 * r0;\n d2 += h3 * (5 * r9);\n d2 += h4 * (5 * r8);\n c = (d2 >>> 13); d2 &= 0x1fff;\n d2 += h5 * (5 * r7);\n d2 += h6 * (5 * r6);\n d2 += h7 * (5 * r5);\n d2 += h8 * (5 * r4);\n d2 += h9 * (5 * r3);\n c += (d2 >>> 13); d2 &= 0x1fff;\n\n d3 = c;\n d3 += h0 * r3;\n d3 += h1 * r2;\n d3 += h2 * r1;\n d3 += h3 * r0;\n d3 += h4 * (5 * r9);\n c = (d3 >>> 13); d3 &= 0x1fff;\n d3 += h5 * (5 * r8);\n d3 += h6 * (5 * r7);\n d3 += h7 * (5 * r6);\n d3 += h8 * (5 * r5);\n d3 += h9 * (5 * r4);\n c += (d3 >>> 13); d3 &= 0x1fff;\n\n d4 = c;\n d4 += h0 * r4;\n d4 += h1 * r3;\n d4 += h2 * r2;\n d4 += h3 * r1;\n d4 += h4 * r0;\n c = (d4 >>> 13); d4 &= 0x1fff;\n d4 += h5 * (5 * r9);\n d4 += h6 * (5 * r8);\n d4 += h7 * (5 * r7);\n d4 += h8 * (5 * r6);\n d4 += h9 * (5 * r5);\n c += (d4 >>> 13); d4 &= 0x1fff;\n\n d5 = c;\n d5 += h0 * r5;\n d5 += h1 * r4;\n d5 += h2 * r3;\n d5 += h3 * r2;\n d5 += h4 * r1;\n c = (d5 >>> 13); d5 &= 0x1fff;\n d5 += h5 * r0;\n d5 += h6 * (5 * r9);\n d5 += h7 * (5 * r8);\n d5 += h8 * (5 * r7);\n d5 += h9 * (5 * r6);\n c += (d5 >>> 13); d5 &= 0x1fff;\n\n d6 = c;\n d6 += h0 * r6;\n d6 += h1 * r5;\n d6 += h2 * r4;\n d6 += h3 * r3;\n d6 += h4 * r2;\n c = (d6 >>> 13); d6 &= 0x1fff;\n d6 += h5 * r1;\n d6 += h6 * r0;\n d6 += h7 * (5 * r9);\n d6 += h8 * (5 * r8);\n d6 += h9 * (5 * r7);\n c += (d6 >>> 13); d6 &= 0x1fff;\n\n d7 = c;\n d7 += h0 * r7;\n d7 += h1 * r6;\n d7 += h2 * r5;\n d7 += h3 * r4;\n d7 += h4 * r3;\n c = (d7 >>> 13); d7 &= 0x1fff;\n d7 += h5 * r2;\n d7 += h6 * r1;\n d7 += h7 * r0;\n d7 += h8 * (5 * r9);\n d7 += h9 * (5 * r8);\n c += (d7 >>> 13); d7 &= 0x1fff;\n\n d8 = c;\n d8 += h0 * r8;\n d8 += h1 * r7;\n d8 += h2 * r6;\n d8 += h3 * r5;\n d8 += h4 * r4;\n c = (d8 >>> 13); d8 &= 0x1fff;\n d8 += h5 * r3;\n d8 += h6 * r2;\n d8 += h7 * r1;\n d8 += h8 * r0;\n d8 += h9 * (5 * r9);\n c += (d8 >>> 13); d8 &= 0x1fff;\n\n d9 = c;\n d9 += h0 * r9;\n d9 += h1 * r8;\n d9 += h2 * r7;\n d9 += h3 * r6;\n d9 += h4 * r5;\n c = (d9 >>> 13); d9 &= 0x1fff;\n d9 += h5 * r4;\n d9 += h6 * r3;\n d9 += h7 * r2;\n d9 += h8 * r1;\n d9 += h9 * r0;\n c += (d9 >>> 13); d9 &= 0x1fff;\n\n c = (((c << 2) + c)) | 0;\n c = (c + d0) | 0;\n d0 = c & 0x1fff;\n c = (c >>> 13);\n d1 += c;\n\n h0 = d0;\n h1 = d1;\n h2 = d2;\n h3 = d3;\n h4 = d4;\n h5 = d5;\n h6 = d6;\n h7 = d7;\n h8 = d8;\n h9 = d9;\n\n mpos += 16;\n bytes -= 16;\n }\n this.h[0] = h0;\n this.h[1] = h1;\n this.h[2] = h2;\n this.h[3] = h3;\n this.h[4] = h4;\n this.h[5] = h5;\n this.h[6] = h6;\n this.h[7] = h7;\n this.h[8] = h8;\n this.h[9] = h9;\n};\n\npoly1305.prototype.finish = function(mac, macpos) {\n var g = new Uint16Array(10);\n var c, mask, f, i;\n\n if (this.leftover) {\n i = this.leftover;\n this.buffer[i++] = 1;\n for (; i < 16; i++) this.buffer[i] = 0;\n this.fin = 1;\n this.blocks(this.buffer, 0, 16);\n }\n\n c = this.h[1] >>> 13;\n this.h[1] &= 0x1fff;\n for (i = 2; i < 10; i++) {\n this.h[i] += c;\n c = this.h[i] >>> 13;\n this.h[i] &= 0x1fff;\n }\n this.h[0] += (c * 5);\n c = this.h[0] >>> 13;\n this.h[0] &= 0x1fff;\n this.h[1] += c;\n c = this.h[1] >>> 13;\n this.h[1] &= 0x1fff;\n this.h[2] += c;\n\n g[0] = this.h[0] + 5;\n c = g[0] >>> 13;\n g[0] &= 0x1fff;\n for (i = 1; i < 10; i++) {\n g[i] = this.h[i] + c;\n c = g[i] >>> 13;\n g[i] &= 0x1fff;\n }\n g[9] -= (1 << 13);\n\n mask = (c ^ 1) - 1;\n for (i = 0; i < 10; i++) g[i] &= mask;\n mask = ~mask;\n for (i = 0; i < 10; i++) this.h[i] = (this.h[i] & mask) | g[i];\n\n this.h[0] = ((this.h[0] ) | (this.h[1] << 13) ) & 0xffff;\n this.h[1] = ((this.h[1] >>> 3) | (this.h[2] << 10) ) & 0xffff;\n this.h[2] = ((this.h[2] >>> 6) | (this.h[3] << 7) ) & 0xffff;\n this.h[3] = ((this.h[3] >>> 9) | (this.h[4] << 4) ) & 0xffff;\n this.h[4] = ((this.h[4] >>> 12) | (this.h[5] << 1) | (this.h[6] << 14)) & 0xffff;\n this.h[5] = ((this.h[6] >>> 2) | (this.h[7] << 11) ) & 0xffff;\n this.h[6] = ((this.h[7] >>> 5) | (this.h[8] << 8) ) & 0xffff;\n this.h[7] = ((this.h[8] >>> 8) | (this.h[9] << 5) ) & 0xffff;\n\n f = this.h[0] + this.pad[0];\n this.h[0] = f & 0xffff;\n for (i = 1; i < 8; i++) {\n f = (((this.h[i] + this.pad[i]) | 0) + (f >>> 16)) | 0;\n this.h[i] = f & 0xffff;\n }\n\n mac[macpos+ 0] = (this.h[0] >>> 0) & 0xff;\n mac[macpos+ 1] = (this.h[0] >>> 8) & 0xff;\n mac[macpos+ 2] = (this.h[1] >>> 0) & 0xff;\n mac[macpos+ 3] = (this.h[1] >>> 8) & 0xff;\n mac[macpos+ 4] = (this.h[2] >>> 0) & 0xff;\n mac[macpos+ 5] = (this.h[2] >>> 8) & 0xff;\n mac[macpos+ 6] = (this.h[3] >>> 0) & 0xff;\n mac[macpos+ 7] = (this.h[3] >>> 8) & 0xff;\n mac[macpos+ 8] = (this.h[4] >>> 0) & 0xff;\n mac[macpos+ 9] = (this.h[4] >>> 8) & 0xff;\n mac[macpos+10] = (this.h[5] >>> 0) & 0xff;\n mac[macpos+11] = (this.h[5] >>> 8) & 0xff;\n mac[macpos+12] = (this.h[6] >>> 0) & 0xff;\n mac[macpos+13] = (this.h[6] >>> 8) & 0xff;\n mac[macpos+14] = (this.h[7] >>> 0) & 0xff;\n mac[macpos+15] = (this.h[7] >>> 8) & 0xff;\n};\n\npoly1305.prototype.update = function(m, mpos, bytes) {\n var i, want;\n\n if (this.leftover) {\n want = (16 - this.leftover);\n if (want > bytes)\n want = bytes;\n for (i = 0; i < want; i++)\n this.buffer[this.leftover + i] = m[mpos+i];\n bytes -= want;\n mpos += want;\n this.leftover += want;\n if (this.leftover < 16)\n return;\n this.blocks(this.buffer, 0, 16);\n this.leftover = 0;\n }\n\n if (bytes >= 16) {\n want = bytes - (bytes % 16);\n this.blocks(m, mpos, want);\n mpos += want;\n bytes -= want;\n }\n\n if (bytes) {\n for (i = 0; i < bytes; i++)\n this.buffer[this.leftover + i] = m[mpos+i];\n this.leftover += bytes;\n }\n};\n\nfunction crypto_onetimeauth(out, outpos, m, mpos, n, k) {\n var s = new poly1305(k);\n s.update(m, mpos, n);\n s.finish(out, outpos);\n return 0;\n}\n\nfunction crypto_onetimeauth_verify(h, hpos, m, mpos, n, k) {\n var x = new Uint8Array(16);\n crypto_onetimeauth(x,0,m,mpos,n,k);\n return crypto_verify_16(h,hpos,x,0);\n}\n\nfunction crypto_secretbox(c,m,d,n,k) {\n var i;\n if (d < 32) return -1;\n crypto_stream_xor(c,0,m,0,d,n,k);\n crypto_onetimeauth(c, 16, c, 32, d - 32, c);\n for (i = 0; i < 16; i++) c[i] = 0;\n return 0;\n}\n\nfunction crypto_secretbox_open(m,c,d,n,k) {\n var i;\n var x = new Uint8Array(32);\n if (d < 32) return -1;\n crypto_stream(x,0,32,n,k);\n if (crypto_onetimeauth_verify(c, 16,c, 32,d - 32,x) !== 0) return -1;\n crypto_stream_xor(m,0,c,0,d,n,k);\n for (i = 0; i < 32; i++) m[i] = 0;\n return 0;\n}\n\nfunction set25519(r, a) {\n var i;\n for (i = 0; i < 16; i++) r[i] = a[i]|0;\n}\n\nfunction car25519(o) {\n var i, v, c = 1;\n for (i = 0; i < 16; i++) {\n v = o[i] + c + 65535;\n c = Math.floor(v / 65536);\n o[i] = v - c * 65536;\n }\n o[0] += c-1 + 37 * (c-1);\n}\n\nfunction sel25519(p, q, b) {\n var t, c = ~(b-1);\n for (var i = 0; i < 16; i++) {\n t = c & (p[i] ^ q[i]);\n p[i] ^= t;\n q[i] ^= t;\n }\n}\n\nfunction pack25519(o, n) {\n var i, j, b;\n var m = gf(), t = gf();\n for (i = 0; i < 16; i++) t[i] = n[i];\n car25519(t);\n car25519(t);\n car25519(t);\n for (j = 0; j < 2; j++) {\n m[0] = t[0] - 0xffed;\n for (i = 1; i < 15; i++) {\n m[i] = t[i] - 0xffff - ((m[i-1]>>16) & 1);\n m[i-1] &= 0xffff;\n }\n m[15] = t[15] - 0x7fff - ((m[14]>>16) & 1);\n b = (m[15]>>16) & 1;\n m[14] &= 0xffff;\n sel25519(t, m, 1-b);\n }\n for (i = 0; i < 16; i++) {\n o[2*i] = t[i] & 0xff;\n o[2*i+1] = t[i]>>8;\n }\n}\n\nfunction neq25519(a, b) {\n var c = new Uint8Array(32), d = new Uint8Array(32);\n pack25519(c, a);\n pack25519(d, b);\n return crypto_verify_32(c, 0, d, 0);\n}\n\nfunction par25519(a) {\n var d = new Uint8Array(32);\n pack25519(d, a);\n return d[0] & 1;\n}\n\nfunction unpack25519(o, n) {\n var i;\n for (i = 0; i < 16; i++) o[i] = n[2*i] + (n[2*i+1] << 8);\n o[15] &= 0x7fff;\n}\n\nfunction A(o, a, b) {\n for (var i = 0; i < 16; i++) o[i] = a[i] + b[i];\n}\n\nfunction Z(o, a, b) {\n for (var i = 0; i < 16; i++) o[i] = a[i] - b[i];\n}\n\nfunction M(o, a, b) {\n var v, c,\n t0 = 0, t1 = 0, t2 = 0, t3 = 0, t4 = 0, t5 = 0, t6 = 0, t7 = 0,\n t8 = 0, t9 = 0, t10 = 0, t11 = 0, t12 = 0, t13 = 0, t14 = 0, t15 = 0,\n t16 = 0, t17 = 0, t18 = 0, t19 = 0, t20 = 0, t21 = 0, t22 = 0, t23 = 0,\n t24 = 0, t25 = 0, t26 = 0, t27 = 0, t28 = 0, t29 = 0, t30 = 0,\n b0 = b[0],\n b1 = b[1],\n b2 = b[2],\n b3 = b[3],\n b4 = b[4],\n b5 = b[5],\n b6 = b[6],\n b7 = b[7],\n b8 = b[8],\n b9 = b[9],\n b10 = b[10],\n b11 = b[11],\n b12 = b[12],\n b13 = b[13],\n b14 = b[14],\n b15 = b[15];\n\n v = a[0];\n t0 += v * b0;\n t1 += v * b1;\n t2 += v * b2;\n t3 += v * b3;\n t4 += v * b4;\n t5 += v * b5;\n t6 += v * b6;\n t7 += v * b7;\n t8 += v * b8;\n t9 += v * b9;\n t10 += v * b10;\n t11 += v * b11;\n t12 += v * b12;\n t13 += v * b13;\n t14 += v * b14;\n t15 += v * b15;\n v = a[1];\n t1 += v * b0;\n t2 += v * b1;\n t3 += v * b2;\n t4 += v * b3;\n t5 += v * b4;\n t6 += v * b5;\n t7 += v * b6;\n t8 += v * b7;\n t9 += v * b8;\n t10 += v * b9;\n t11 += v * b10;\n t12 += v * b11;\n t13 += v * b12;\n t14 += v * b13;\n t15 += v * b14;\n t16 += v * b15;\n v = a[2];\n t2 += v * b0;\n t3 += v * b1;\n t4 += v * b2;\n t5 += v * b3;\n t6 += v * b4;\n t7 += v * b5;\n t8 += v * b6;\n t9 += v * b7;\n t10 += v * b8;\n t11 += v * b9;\n t12 += v * b10;\n t13 += v * b11;\n t14 += v * b12;\n t15 += v * b13;\n t16 += v * b14;\n t17 += v * b15;\n v = a[3];\n t3 += v * b0;\n t4 += v * b1;\n t5 += v * b2;\n t6 += v * b3;\n t7 += v * b4;\n t8 += v * b5;\n t9 += v * b6;\n t10 += v * b7;\n t11 += v * b8;\n t12 += v * b9;\n t13 += v * b10;\n t14 += v * b11;\n t15 += v * b12;\n t16 += v * b13;\n t17 += v * b14;\n t18 += v * b15;\n v = a[4];\n t4 += v * b0;\n t5 += v * b1;\n t6 += v * b2;\n t7 += v * b3;\n t8 += v * b4;\n t9 += v * b5;\n t10 += v * b6;\n t11 += v * b7;\n t12 += v * b8;\n t13 += v * b9;\n t14 += v * b10;\n t15 += v * b11;\n t16 += v * b12;\n t17 += v * b13;\n t18 += v * b14;\n t19 += v * b15;\n v = a[5];\n t5 += v * b0;\n t6 += v * b1;\n t7 += v * b2;\n t8 += v * b3;\n t9 += v * b4;\n t10 += v * b5;\n t11 += v * b6;\n t12 += v * b7;\n t13 += v * b8;\n t14 += v * b9;\n t15 += v * b10;\n t16 += v * b11;\n t17 += v * b12;\n t18 += v * b13;\n t19 += v * b14;\n t20 += v * b15;\n v = a[6];\n t6 += v * b0;\n t7 += v * b1;\n t8 += v * b2;\n t9 += v * b3;\n t10 += v * b4;\n t11 += v * b5;\n t12 += v * b6;\n t13 += v * b7;\n t14 += v * b8;\n t15 += v * b9;\n t16 += v * b10;\n t17 += v * b11;\n t18 += v * b12;\n t19 += v * b13;\n t20 += v * b14;\n t21 += v * b15;\n v = a[7];\n t7 += v * b0;\n t8 += v * b1;\n t9 += v * b2;\n t10 += v * b3;\n t11 += v * b4;\n t12 += v * b5;\n t13 += v * b6;\n t14 += v * b7;\n t15 += v * b8;\n t16 += v * b9;\n t17 += v * b10;\n t18 += v * b11;\n t19 += v * b12;\n t20 += v * b13;\n t21 += v * b14;\n t22 += v * b15;\n v = a[8];\n t8 += v * b0;\n t9 += v * b1;\n t10 += v * b2;\n t11 += v * b3;\n t12 += v * b4;\n t13 += v * b5;\n t14 += v * b6;\n t15 += v * b7;\n t16 += v * b8;\n t17 += v * b9;\n t18 += v * b10;\n t19 += v * b11;\n t20 += v * b12;\n t21 += v * b13;\n t22 += v * b14;\n t23 += v * b15;\n v = a[9];\n t9 += v * b0;\n t10 += v * b1;\n t11 += v * b2;\n t12 += v * b3;\n t13 += v * b4;\n t14 += v * b5;\n t15 += v * b6;\n t16 += v * b7;\n t17 += v * b8;\n t18 += v * b9;\n t19 += v * b10;\n t20 += v * b11;\n t21 += v * b12;\n t22 += v * b13;\n t23 += v * b14;\n t24 += v * b15;\n v = a[10];\n t10 += v * b0;\n t11 += v * b1;\n t12 += v * b2;\n t13 += v * b3;\n t14 += v * b4;\n t15 += v * b5;\n t16 += v * b6;\n t17 += v * b7;\n t18 += v * b8;\n t19 += v * b9;\n t20 += v * b10;\n t21 += v * b11;\n t22 += v * b12;\n t23 += v * b13;\n t24 += v * b14;\n t25 += v * b15;\n v = a[11];\n t11 += v * b0;\n t12 += v * b1;\n t13 += v * b2;\n t14 += v * b3;\n t15 += v * b4;\n t16 += v * b5;\n t17 += v * b6;\n t18 += v * b7;\n t19 += v * b8;\n t20 += v * b9;\n t21 += v * b10;\n t22 += v * b11;\n t23 += v * b12;\n t24 += v * b13;\n t25 += v * b14;\n t26 += v * b15;\n v = a[12];\n t12 += v * b0;\n t13 += v * b1;\n t14 += v * b2;\n t15 += v * b3;\n t16 += v * b4;\n t17 += v * b5;\n t18 += v * b6;\n t19 += v * b7;\n t20 += v * b8;\n t21 += v * b9;\n t22 += v * b10;\n t23 += v * b11;\n t24 += v * b12;\n t25 += v * b13;\n t26 += v * b14;\n t27 += v * b15;\n v = a[13];\n t13 += v * b0;\n t14 += v * b1;\n t15 += v * b2;\n t16 += v * b3;\n t17 += v * b4;\n t18 += v * b5;\n t19 += v * b6;\n t20 += v * b7;\n t21 += v * b8;\n t22 += v * b9;\n t23 += v * b10;\n t24 += v * b11;\n t25 += v * b12;\n t26 += v * b13;\n t27 += v * b14;\n t28 += v * b15;\n v = a[14];\n t14 += v * b0;\n t15 += v * b1;\n t16 += v * b2;\n t17 += v * b3;\n t18 += v * b4;\n t19 += v * b5;\n t20 += v * b6;\n t21 += v * b7;\n t22 += v * b8;\n t23 += v * b9;\n t24 += v * b10;\n t25 += v * b11;\n t26 += v * b12;\n t27 += v * b13;\n t28 += v * b14;\n t29 += v * b15;\n v = a[15];\n t15 += v * b0;\n t16 += v * b1;\n t17 += v * b2;\n t18 += v * b3;\n t19 += v * b4;\n t20 += v * b5;\n t21 += v * b6;\n t22 += v * b7;\n t23 += v * b8;\n t24 += v * b9;\n t25 += v * b10;\n t26 += v * b11;\n t27 += v * b12;\n t28 += v * b13;\n t29 += v * b14;\n t30 += v * b15;\n\n t0 += 38 * t16;\n t1 += 38 * t17;\n t2 += 38 * t18;\n t3 += 38 * t19;\n t4 += 38 * t20;\n t5 += 38 * t21;\n t6 += 38 * t22;\n t7 += 38 * t23;\n t8 += 38 * t24;\n t9 += 38 * t25;\n t10 += 38 * t26;\n t11 += 38 * t27;\n t12 += 38 * t28;\n t13 += 38 * t29;\n t14 += 38 * t30;\n // t15 left as is\n\n // first car\n c = 1;\n v = t0 + c + 65535; c = Math.floor(v / 65536); t0 = v - c * 65536;\n v = t1 + c + 65535; c = Math.floor(v / 65536); t1 = v - c * 65536;\n v = t2 + c + 65535; c = Math.floor(v / 65536); t2 = v - c * 65536;\n v = t3 + c + 65535; c = Math.floor(v / 65536); t3 = v - c * 65536;\n v = t4 + c + 65535; c = Math.floor(v / 65536); t4 = v - c * 65536;\n v = t5 + c + 65535; c = Math.floor(v / 65536); t5 = v - c * 65536;\n v = t6 + c + 65535; c = Math.floor(v / 65536); t6 = v - c * 65536;\n v = t7 + c + 65535; c = Math.floor(v / 65536); t7 = v - c * 65536;\n v = t8 + c + 65535; c = Math.floor(v / 65536); t8 = v - c * 65536;\n v = t9 + c + 65535; c = Math.floor(v / 65536); t9 = v - c * 65536;\n v = t10 + c + 65535; c = Math.floor(v / 65536); t10 = v - c * 65536;\n v = t11 + c + 65535; c = Math.floor(v / 65536); t11 = v - c * 65536;\n v = t12 + c + 65535; c = Math.floor(v / 65536); t12 = v - c * 65536;\n v = t13 + c + 65535; c = Math.floor(v / 65536); t13 = v - c * 65536;\n v = t14 + c + 65535; c = Math.floor(v / 65536); t14 = v - c * 65536;\n v = t15 + c + 65535; c = Math.floor(v / 65536); t15 = v - c * 65536;\n t0 += c-1 + 37 * (c-1);\n\n // second car\n c = 1;\n v = t0 + c + 65535; c = Math.floor(v / 65536); t0 = v - c * 65536;\n v = t1 + c + 65535; c = Math.floor(v / 65536); t1 = v - c * 65536;\n v = t2 + c + 65535; c = Math.floor(v / 65536); t2 = v - c * 65536;\n v = t3 + c + 65535; c = Math.floor(v / 65536); t3 = v - c * 65536;\n v = t4 + c + 65535; c = Math.floor(v / 65536); t4 = v - c * 65536;\n v = t5 + c + 65535; c = Math.floor(v / 65536); t5 = v - c * 65536;\n v = t6 + c + 65535; c = Math.floor(v / 65536); t6 = v - c * 65536;\n v = t7 + c + 65535; c = Math.floor(v / 65536); t7 = v - c * 65536;\n v = t8 + c + 65535; c = Math.floor(v / 65536); t8 = v - c * 65536;\n v = t9 + c + 65535; c = Math.floor(v / 65536); t9 = v - c * 65536;\n v = t10 + c + 65535; c = Math.floor(v / 65536); t10 = v - c * 65536;\n v = t11 + c + 65535; c = Math.floor(v / 65536); t11 = v - c * 65536;\n v = t12 + c + 65535; c = Math.floor(v / 65536); t12 = v - c * 65536;\n v = t13 + c + 65535; c = Math.floor(v / 65536); t13 = v - c * 65536;\n v = t14 + c + 65535; c = Math.floor(v / 65536); t14 = v - c * 65536;\n v = t15 + c + 65535; c = Math.floor(v / 65536); t15 = v - c * 65536;\n t0 += c-1 + 37 * (c-1);\n\n o[ 0] = t0;\n o[ 1] = t1;\n o[ 2] = t2;\n o[ 3] = t3;\n o[ 4] = t4;\n o[ 5] = t5;\n o[ 6] = t6;\n o[ 7] = t7;\n o[ 8] = t8;\n o[ 9] = t9;\n o[10] = t10;\n o[11] = t11;\n o[12] = t12;\n o[13] = t13;\n o[14] = t14;\n o[15] = t15;\n}\n\nfunction S(o, a) {\n M(o, a, a);\n}\n\nfunction inv25519(o, i) {\n var c = gf();\n var a;\n for (a = 0; a < 16; a++) c[a] = i[a];\n for (a = 253; a >= 0; a--) {\n S(c, c);\n if(a !== 2 && a !== 4) M(c, c, i);\n }\n for (a = 0; a < 16; a++) o[a] = c[a];\n}\n\nfunction pow2523(o, i) {\n var c = gf();\n var a;\n for (a = 0; a < 16; a++) c[a] = i[a];\n for (a = 250; a >= 0; a--) {\n S(c, c);\n if(a !== 1) M(c, c, i);\n }\n for (a = 0; a < 16; a++) o[a] = c[a];\n}\n\nfunction crypto_scalarmult(q, n, p) {\n var z = new Uint8Array(32);\n var x = new Float64Array(80), r, i;\n var a = gf(), b = gf(), c = gf(),\n d = gf(), e = gf(), f = gf();\n for (i = 0; i < 31; i++) z[i] = n[i];\n z[31]=(n[31]&127)|64;\n z[0]&=248;\n unpack25519(x,p);\n for (i = 0; i < 16; i++) {\n b[i]=x[i];\n d[i]=a[i]=c[i]=0;\n }\n a[0]=d[0]=1;\n for (i=254; i>=0; --i) {\n r=(z[i>>>3]>>>(i&7))&1;\n sel25519(a,b,r);\n sel25519(c,d,r);\n A(e,a,c);\n Z(a,a,c);\n A(c,b,d);\n Z(b,b,d);\n S(d,e);\n S(f,a);\n M(a,c,a);\n M(c,b,e);\n A(e,a,c);\n Z(a,a,c);\n S(b,a);\n Z(c,d,f);\n M(a,c,_121665);\n A(a,a,d);\n M(c,c,a);\n M(a,d,f);\n M(d,b,x);\n S(b,e);\n sel25519(a,b,r);\n sel25519(c,d,r);\n }\n for (i = 0; i < 16; i++) {\n x[i+16]=a[i];\n x[i+32]=c[i];\n x[i+48]=b[i];\n x[i+64]=d[i];\n }\n var x32 = x.subarray(32);\n var x16 = x.subarray(16);\n inv25519(x32,x32);\n M(x16,x16,x32);\n pack25519(q,x16);\n return 0;\n}\n\nfunction crypto_scalarmult_base(q, n) {\n return crypto_scalarmult(q, n, _9);\n}\n\nfunction crypto_box_keypair(y, x) {\n randombytes(x, 32);\n return crypto_scalarmult_base(y, x);\n}\n\nfunction crypto_box_beforenm(k, y, x) {\n var s = new Uint8Array(32);\n crypto_scalarmult(s, x, y);\n return crypto_core_hsalsa20(k, _0, s, sigma);\n}\n\nvar crypto_box_afternm = crypto_secretbox;\nvar crypto_box_open_afternm = crypto_secretbox_open;\n\nfunction crypto_box(c, m, d, n, y, x) {\n var k = new Uint8Array(32);\n crypto_box_beforenm(k, y, x);\n return crypto_box_afternm(c, m, d, n, k);\n}\n\nfunction crypto_box_open(m, c, d, n, y, x) {\n var k = new Uint8Array(32);\n crypto_box_beforenm(k, y, x);\n return crypto_box_open_afternm(m, c, d, n, k);\n}\n\nvar K = [\n 0x428a2f98, 0xd728ae22, 0x71374491, 0x23ef65cd,\n 0xb5c0fbcf, 0xec4d3b2f, 0xe9b5dba5, 0x8189dbbc,\n 0x3956c25b, 0xf348b538, 0x59f111f1, 0xb605d019,\n 0x923f82a4, 0xaf194f9b, 0xab1c5ed5, 0xda6d8118,\n 0xd807aa98, 0xa3030242, 0x12835b01, 0x45706fbe,\n 0x243185be, 0x4ee4b28c, 0x550c7dc3, 0xd5ffb4e2,\n 0x72be5d74, 0xf27b896f, 0x80deb1fe, 0x3b1696b1,\n 0x9bdc06a7, 0x25c71235, 0xc19bf174, 0xcf692694,\n 0xe49b69c1, 0x9ef14ad2, 0xefbe4786, 0x384f25e3,\n 0x0fc19dc6, 0x8b8cd5b5, 0x240ca1cc, 0x77ac9c65,\n 0x2de92c6f, 0x592b0275, 0x4a7484aa, 0x6ea6e483,\n 0x5cb0a9dc, 0xbd41fbd4, 0x76f988da, 0x831153b5,\n 0x983e5152, 0xee66dfab, 0xa831c66d, 0x2db43210,\n 0xb00327c8, 0x98fb213f, 0xbf597fc7, 0xbeef0ee4,\n 0xc6e00bf3, 0x3da88fc2, 0xd5a79147, 0x930aa725,\n 0x06ca6351, 0xe003826f, 0x14292967, 0x0a0e6e70,\n 0x27b70a85, 0x46d22ffc, 0x2e1b2138, 0x5c26c926,\n 0x4d2c6dfc, 0x5ac42aed, 0x53380d13, 0x9d95b3df,\n 0x650a7354, 0x8baf63de, 0x766a0abb, 0x3c77b2a8,\n 0x81c2c92e, 0x47edaee6, 0x92722c85, 0x1482353b,\n 0xa2bfe8a1, 0x4cf10364, 0xa81a664b, 0xbc423001,\n 0xc24b8b70, 0xd0f89791, 0xc76c51a3, 0x0654be30,\n 0xd192e819, 0xd6ef5218, 0xd6990624, 0x5565a910,\n 0xf40e3585, 0x5771202a, 0x106aa070, 0x32bbd1b8,\n 0x19a4c116, 0xb8d2d0c8, 0x1e376c08, 0x5141ab53,\n 0x2748774c, 0xdf8eeb99, 0x34b0bcb5, 0xe19b48a8,\n 0x391c0cb3, 0xc5c95a63, 0x4ed8aa4a, 0xe3418acb,\n 0x5b9cca4f, 0x7763e373, 0x682e6ff3, 0xd6b2b8a3,\n 0x748f82ee, 0x5defb2fc, 0x78a5636f, 0x43172f60,\n 0x84c87814, 0xa1f0ab72, 0x8cc70208, 0x1a6439ec,\n 0x90befffa, 0x23631e28, 0xa4506ceb, 0xde82bde9,\n 0xbef9a3f7, 0xb2c67915, 0xc67178f2, 0xe372532b,\n 0xca273ece, 0xea26619c, 0xd186b8c7, 0x21c0c207,\n 0xeada7dd6, 0xcde0eb1e, 0xf57d4f7f, 0xee6ed178,\n 0x06f067aa, 0x72176fba, 0x0a637dc5, 0xa2c898a6,\n 0x113f9804, 0xbef90dae, 0x1b710b35, 0x131c471b,\n 0x28db77f5, 0x23047d84, 0x32caab7b, 0x40c72493,\n 0x3c9ebe0a, 0x15c9bebc, 0x431d67c4, 0x9c100d4c,\n 0x4cc5d4be, 0xcb3e42b6, 0x597f299c, 0xfc657e2a,\n 0x5fcb6fab, 0x3ad6faec, 0x6c44198c, 0x4a475817\n];\n\nfunction crypto_hashblocks_hl(hh, hl, m, n) {\n var wh = new Int32Array(16), wl = new Int32Array(16),\n bh0, bh1, bh2, bh3, bh4, bh5, bh6, bh7,\n bl0, bl1, bl2, bl3, bl4, bl5, bl6, bl7,\n th, tl, i, j, h, l, a, b, c, d;\n\n var ah0 = hh[0],\n ah1 = hh[1],\n ah2 = hh[2],\n ah3 = hh[3],\n ah4 = hh[4],\n ah5 = hh[5],\n ah6 = hh[6],\n ah7 = hh[7],\n\n al0 = hl[0],\n al1 = hl[1],\n al2 = hl[2],\n al3 = hl[3],\n al4 = hl[4],\n al5 = hl[5],\n al6 = hl[6],\n al7 = hl[7];\n\n var pos = 0;\n while (n >= 128) {\n for (i = 0; i < 16; i++) {\n j = 8 * i + pos;\n wh[i] = (m[j+0] << 24) | (m[j+1] << 16) | (m[j+2] << 8) | m[j+3];\n wl[i] = (m[j+4] << 24) | (m[j+5] << 16) | (m[j+6] << 8) | m[j+7];\n }\n for (i = 0; i < 80; i++) {\n bh0 = ah0;\n bh1 = ah1;\n bh2 = ah2;\n bh3 = ah3;\n bh4 = ah4;\n bh5 = ah5;\n bh6 = ah6;\n bh7 = ah7;\n\n bl0 = al0;\n bl1 = al1;\n bl2 = al2;\n bl3 = al3;\n bl4 = al4;\n bl5 = al5;\n bl6 = al6;\n bl7 = al7;\n\n // add\n h = ah7;\n l = al7;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n // Sigma1\n h = ((ah4 >>> 14) | (al4 << (32-14))) ^ ((ah4 >>> 18) | (al4 << (32-18))) ^ ((al4 >>> (41-32)) | (ah4 << (32-(41-32))));\n l = ((al4 >>> 14) | (ah4 << (32-14))) ^ ((al4 >>> 18) | (ah4 << (32-18))) ^ ((ah4 >>> (41-32)) | (al4 << (32-(41-32))));\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // Ch\n h = (ah4 & ah5) ^ (~ah4 & ah6);\n l = (al4 & al5) ^ (~al4 & al6);\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // K\n h = K[i*2];\n l = K[i*2+1];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // w\n h = wh[i%16];\n l = wl[i%16];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n th = c & 0xffff | d << 16;\n tl = a & 0xffff | b << 16;\n\n // add\n h = th;\n l = tl;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n // Sigma0\n h = ((ah0 >>> 28) | (al0 << (32-28))) ^ ((al0 >>> (34-32)) | (ah0 << (32-(34-32)))) ^ ((al0 >>> (39-32)) | (ah0 << (32-(39-32))));\n l = ((al0 >>> 28) | (ah0 << (32-28))) ^ ((ah0 >>> (34-32)) | (al0 << (32-(34-32)))) ^ ((ah0 >>> (39-32)) | (al0 << (32-(39-32))));\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // Maj\n h = (ah0 & ah1) ^ (ah0 & ah2) ^ (ah1 & ah2);\n l = (al0 & al1) ^ (al0 & al2) ^ (al1 & al2);\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n bh7 = (c & 0xffff) | (d << 16);\n bl7 = (a & 0xffff) | (b << 16);\n\n // add\n h = bh3;\n l = bl3;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = th;\n l = tl;\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n bh3 = (c & 0xffff) | (d << 16);\n bl3 = (a & 0xffff) | (b << 16);\n\n ah1 = bh0;\n ah2 = bh1;\n ah3 = bh2;\n ah4 = bh3;\n ah5 = bh4;\n ah6 = bh5;\n ah7 = bh6;\n ah0 = bh7;\n\n al1 = bl0;\n al2 = bl1;\n al3 = bl2;\n al4 = bl3;\n al5 = bl4;\n al6 = bl5;\n al7 = bl6;\n al0 = bl7;\n\n if (i%16 === 15) {\n for (j = 0; j < 16; j++) {\n // add\n h = wh[j];\n l = wl[j];\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = wh[(j+9)%16];\n l = wl[(j+9)%16];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // sigma0\n th = wh[(j+1)%16];\n tl = wl[(j+1)%16];\n h = ((th >>> 1) | (tl << (32-1))) ^ ((th >>> 8) | (tl << (32-8))) ^ (th >>> 7);\n l = ((tl >>> 1) | (th << (32-1))) ^ ((tl >>> 8) | (th << (32-8))) ^ ((tl >>> 7) | (th << (32-7)));\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // sigma1\n th = wh[(j+14)%16];\n tl = wl[(j+14)%16];\n h = ((th >>> 19) | (tl << (32-19))) ^ ((tl >>> (61-32)) | (th << (32-(61-32)))) ^ (th >>> 6);\n l = ((tl >>> 19) | (th << (32-19))) ^ ((th >>> (61-32)) | (tl << (32-(61-32)))) ^ ((tl >>> 6) | (th << (32-6)));\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n wh[j] = (c & 0xffff) | (d << 16);\n wl[j] = (a & 0xffff) | (b << 16);\n }\n }\n }\n\n // add\n h = ah0;\n l = al0;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[0];\n l = hl[0];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[0] = ah0 = (c & 0xffff) | (d << 16);\n hl[0] = al0 = (a & 0xffff) | (b << 16);\n\n h = ah1;\n l = al1;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[1];\n l = hl[1];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[1] = ah1 = (c & 0xffff) | (d << 16);\n hl[1] = al1 = (a & 0xffff) | (b << 16);\n\n h = ah2;\n l = al2;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[2];\n l = hl[2];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[2] = ah2 = (c & 0xffff) | (d << 16);\n hl[2] = al2 = (a & 0xffff) | (b << 16);\n\n h = ah3;\n l = al3;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[3];\n l = hl[3];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[3] = ah3 = (c & 0xffff) | (d << 16);\n hl[3] = al3 = (a & 0xffff) | (b << 16);\n\n h = ah4;\n l = al4;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[4];\n l = hl[4];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[4] = ah4 = (c & 0xffff) | (d << 16);\n hl[4] = al4 = (a & 0xffff) | (b << 16);\n\n h = ah5;\n l = al5;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[5];\n l = hl[5];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[5] = ah5 = (c & 0xffff) | (d << 16);\n hl[5] = al5 = (a & 0xffff) | (b << 16);\n\n h = ah6;\n l = al6;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[6];\n l = hl[6];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[6] = ah6 = (c & 0xffff) | (d << 16);\n hl[6] = al6 = (a & 0xffff) | (b << 16);\n\n h = ah7;\n l = al7;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[7];\n l = hl[7];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[7] = ah7 = (c & 0xffff) | (d << 16);\n hl[7] = al7 = (a & 0xffff) | (b << 16);\n\n pos += 128;\n n -= 128;\n }\n\n return n;\n}\n\nfunction crypto_hash(out, m, n) {\n var hh = new Int32Array(8),\n hl = new Int32Array(8),\n x = new Uint8Array(256),\n i, b = n;\n\n hh[0] = 0x6a09e667;\n hh[1] = 0xbb67ae85;\n hh[2] = 0x3c6ef372;\n hh[3] = 0xa54ff53a;\n hh[4] = 0x510e527f;\n hh[5] = 0x9b05688c;\n hh[6] = 0x1f83d9ab;\n hh[7] = 0x5be0cd19;\n\n hl[0] = 0xf3bcc908;\n hl[1] = 0x84caa73b;\n hl[2] = 0xfe94f82b;\n hl[3] = 0x5f1d36f1;\n hl[4] = 0xade682d1;\n hl[5] = 0x2b3e6c1f;\n hl[6] = 0xfb41bd6b;\n hl[7] = 0x137e2179;\n\n crypto_hashblocks_hl(hh, hl, m, n);\n n %= 128;\n\n for (i = 0; i < n; i++) x[i] = m[b-n+i];\n x[n] = 128;\n\n n = 256-128*(n<112?1:0);\n x[n-9] = 0;\n ts64(x, n-8, (b / 0x20000000) | 0, b << 3);\n crypto_hashblocks_hl(hh, hl, x, n);\n\n for (i = 0; i < 8; i++) ts64(out, 8*i, hh[i], hl[i]);\n\n return 0;\n}\n\nfunction add(p, q) {\n var a = gf(), b = gf(), c = gf(),\n d = gf(), e = gf(), f = gf(),\n g = gf(), h = gf(), t = gf();\n\n Z(a, p[1], p[0]);\n Z(t, q[1], q[0]);\n M(a, a, t);\n A(b, p[0], p[1]);\n A(t, q[0], q[1]);\n M(b, b, t);\n M(c, p[3], q[3]);\n M(c, c, D2);\n M(d, p[2], q[2]);\n A(d, d, d);\n Z(e, b, a);\n Z(f, d, c);\n A(g, d, c);\n A(h, b, a);\n\n M(p[0], e, f);\n M(p[1], h, g);\n M(p[2], g, f);\n M(p[3], e, h);\n}\n\nfunction cswap(p, q, b) {\n var i;\n for (i = 0; i < 4; i++) {\n sel25519(p[i], q[i], b);\n }\n}\n\nfunction pack(r, p) {\n var tx = gf(), ty = gf(), zi = gf();\n inv25519(zi, p[2]);\n M(tx, p[0], zi);\n M(ty, p[1], zi);\n pack25519(r, ty);\n r[31] ^= par25519(tx) << 7;\n}\n\nfunction scalarmult(p, q, s) {\n var b, i;\n set25519(p[0], gf0);\n set25519(p[1], gf1);\n set25519(p[2], gf1);\n set25519(p[3], gf0);\n for (i = 255; i >= 0; --i) {\n b = (s[(i/8)|0] >> (i&7)) & 1;\n cswap(p, q, b);\n add(q, p);\n add(p, p);\n cswap(p, q, b);\n }\n}\n\nfunction scalarbase(p, s) {\n var q = [gf(), gf(), gf(), gf()];\n set25519(q[0], X);\n set25519(q[1], Y);\n set25519(q[2], gf1);\n M(q[3], X, Y);\n scalarmult(p, q, s);\n}\n\nfunction crypto_sign_keypair(pk, sk, seeded) {\n var d = new Uint8Array(64);\n var p = [gf(), gf(), gf(), gf()];\n var i;\n\n if (!seeded) randombytes(sk, 32);\n crypto_hash(d, sk, 32);\n d[0] &= 248;\n d[31] &= 127;\n d[31] |= 64;\n\n scalarbase(p, d);\n pack(pk, p);\n\n for (i = 0; i < 32; i++) sk[i+32] = pk[i];\n return 0;\n}\n\nvar L = new Float64Array([0xed, 0xd3, 0xf5, 0x5c, 0x1a, 0x63, 0x12, 0x58, 0xd6, 0x9c, 0xf7, 0xa2, 0xde, 0xf9, 0xde, 0x14, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x10]);\n\nfunction modL(r, x) {\n var carry, i, j, k;\n for (i = 63; i >= 32; --i) {\n carry = 0;\n for (j = i - 32, k = i - 12; j < k; ++j) {\n x[j] += carry - 16 * x[i] * L[j - (i - 32)];\n carry = Math.floor((x[j] + 128) / 256);\n x[j] -= carry * 256;\n }\n x[j] += carry;\n x[i] = 0;\n }\n carry = 0;\n for (j = 0; j < 32; j++) {\n x[j] += carry - (x[31] >> 4) * L[j];\n carry = x[j] >> 8;\n x[j] &= 255;\n }\n for (j = 0; j < 32; j++) x[j] -= carry * L[j];\n for (i = 0; i < 32; i++) {\n x[i+1] += x[i] >> 8;\n r[i] = x[i] & 255;\n }\n}\n\nfunction reduce(r) {\n var x = new Float64Array(64), i;\n for (i = 0; i < 64; i++) x[i] = r[i];\n for (i = 0; i < 64; i++) r[i] = 0;\n modL(r, x);\n}\n\n// Note: difference from C - smlen returned, not passed as argument.\nfunction crypto_sign(sm, m, n, sk) {\n var d = new Uint8Array(64), h = new Uint8Array(64), r = new Uint8Array(64);\n var i, j, x = new Float64Array(64);\n var p = [gf(), gf(), gf(), gf()];\n\n crypto_hash(d, sk, 32);\n d[0] &= 248;\n d[31] &= 127;\n d[31] |= 64;\n\n var smlen = n + 64;\n for (i = 0; i < n; i++) sm[64 + i] = m[i];\n for (i = 0; i < 32; i++) sm[32 + i] = d[32 + i];\n\n crypto_hash(r, sm.subarray(32), n+32);\n reduce(r);\n scalarbase(p, r);\n pack(sm, p);\n\n for (i = 32; i < 64; i++) sm[i] = sk[i];\n crypto_hash(h, sm, n + 64);\n reduce(h);\n\n for (i = 0; i < 64; i++) x[i] = 0;\n for (i = 0; i < 32; i++) x[i] = r[i];\n for (i = 0; i < 32; i++) {\n for (j = 0; j < 32; j++) {\n x[i+j] += h[i] * d[j];\n }\n }\n\n modL(sm.subarray(32), x);\n return smlen;\n}\n\nfunction unpackneg(r, p) {\n var t = gf(), chk = gf(), num = gf(),\n den = gf(), den2 = gf(), den4 = gf(),\n den6 = gf();\n\n set25519(r[2], gf1);\n unpack25519(r[1], p);\n S(num, r[1]);\n M(den, num, D);\n Z(num, num, r[2]);\n A(den, r[2], den);\n\n S(den2, den);\n S(den4, den2);\n M(den6, den4, den2);\n M(t, den6, num);\n M(t, t, den);\n\n pow2523(t, t);\n M(t, t, num);\n M(t, t, den);\n M(t, t, den);\n M(r[0], t, den);\n\n S(chk, r[0]);\n M(chk, chk, den);\n if (neq25519(chk, num)) M(r[0], r[0], I);\n\n S(chk, r[0]);\n M(chk, chk, den);\n if (neq25519(chk, num)) return -1;\n\n if (par25519(r[0]) === (p[31]>>7)) Z(r[0], gf0, r[0]);\n\n M(r[3], r[0], r[1]);\n return 0;\n}\n\nfunction crypto_sign_open(m, sm, n, pk) {\n var i;\n var t = new Uint8Array(32), h = new Uint8Array(64);\n var p = [gf(), gf(), gf(), gf()],\n q = [gf(), gf(), gf(), gf()];\n\n if (n < 64) return -1;\n\n if (unpackneg(q, pk)) return -1;\n\n for (i = 0; i < n; i++) m[i] = sm[i];\n for (i = 0; i < 32; i++) m[i+32] = pk[i];\n crypto_hash(h, m, n);\n reduce(h);\n scalarmult(p, q, h);\n\n scalarbase(q, sm.subarray(32));\n add(p, q);\n pack(t, p);\n\n n -= 64;\n if (crypto_verify_32(sm, 0, t, 0)) {\n for (i = 0; i < n; i++) m[i] = 0;\n return -1;\n }\n\n for (i = 0; i < n; i++) m[i] = sm[i + 64];\n return n;\n}\n\nvar crypto_secretbox_KEYBYTES = 32,\n crypto_secretbox_NONCEBYTES = 24,\n crypto_secretbox_ZEROBYTES = 32,\n crypto_secretbox_BOXZEROBYTES = 16,\n crypto_scalarmult_BYTES = 32,\n crypto_scalarmult_SCALARBYTES = 32,\n crypto_box_PUBLICKEYBYTES = 32,\n crypto_box_SECRETKEYBYTES = 32,\n crypto_box_BEFORENMBYTES = 32,\n crypto_box_NONCEBYTES = crypto_secretbox_NONCEBYTES,\n crypto_box_ZEROBYTES = crypto_secretbox_ZEROBYTES,\n crypto_box_BOXZEROBYTES = crypto_secretbox_BOXZEROBYTES,\n crypto_sign_BYTES = 64,\n crypto_sign_PUBLICKEYBYTES = 32,\n crypto_sign_SECRETKEYBYTES = 64,\n crypto_sign_SEEDBYTES = 32,\n crypto_hash_BYTES = 64;\n\nnacl.lowlevel = {\n crypto_core_hsalsa20: crypto_core_hsalsa20,\n crypto_stream_xor: crypto_stream_xor,\n crypto_stream: crypto_stream,\n crypto_stream_salsa20_xor: crypto_stream_salsa20_xor,\n crypto_stream_salsa20: crypto_stream_salsa20,\n crypto_onetimeauth: crypto_onetimeauth,\n crypto_onetimeauth_verify: crypto_onetimeauth_verify,\n crypto_verify_16: crypto_verify_16,\n crypto_verify_32: crypto_verify_32,\n crypto_secretbox: crypto_secretbox,\n crypto_secretbox_open: crypto_secretbox_open,\n crypto_scalarmult: crypto_scalarmult,\n crypto_scalarmult_base: crypto_scalarmult_base,\n crypto_box_beforenm: crypto_box_beforenm,\n crypto_box_afternm: crypto_box_afternm,\n crypto_box: crypto_box,\n crypto_box_open: crypto_box_open,\n crypto_box_keypair: crypto_box_keypair,\n crypto_hash: crypto_hash,\n crypto_sign: crypto_sign,\n crypto_sign_keypair: crypto_sign_keypair,\n crypto_sign_open: crypto_sign_open,\n\n crypto_secretbox_KEYBYTES: crypto_secretbox_KEYBYTES,\n crypto_secretbox_NONCEBYTES: crypto_secretbox_NONCEBYTES,\n crypto_secretbox_ZEROBYTES: crypto_secretbox_ZEROBYTES,\n crypto_secretbox_BOXZEROBYTES: crypto_secretbox_BOXZEROBYTES,\n crypto_scalarmult_BYTES: crypto_scalarmult_BYTES,\n crypto_scalarmult_SCALARBYTES: crypto_scalarmult_SCALARBYTES,\n crypto_box_PUBLICKEYBYTES: crypto_box_PUBLICKEYBYTES,\n crypto_box_SECRETKEYBYTES: crypto_box_SECRETKEYBYTES,\n crypto_box_BEFORENMBYTES: crypto_box_BEFORENMBYTES,\n crypto_box_NONCEBYTES: crypto_box_NONCEBYTES,\n crypto_box_ZEROBYTES: crypto_box_ZEROBYTES,\n crypto_box_BOXZEROBYTES: crypto_box_BOXZEROBYTES,\n crypto_sign_BYTES: crypto_sign_BYTES,\n crypto_sign_PUBLICKEYBYTES: crypto_sign_PUBLICKEYBYTES,\n crypto_sign_SECRETKEYBYTES: crypto_sign_SECRETKEYBYTES,\n crypto_sign_SEEDBYTES: crypto_sign_SEEDBYTES,\n crypto_hash_BYTES: crypto_hash_BYTES,\n\n gf: gf,\n D: D,\n L: L,\n pack25519: pack25519,\n unpack25519: unpack25519,\n M: M,\n A: A,\n S: S,\n Z: Z,\n pow2523: pow2523,\n add: add,\n set25519: set25519,\n modL: modL,\n scalarmult: scalarmult,\n scalarbase: scalarbase,\n};\n\n/* High-level API */\n\nfunction checkLengths(k, n) {\n if (k.length !== crypto_secretbox_KEYBYTES) throw new Error('bad key size');\n if (n.length !== crypto_secretbox_NONCEBYTES) throw new Error('bad nonce size');\n}\n\nfunction checkBoxLengths(pk, sk) {\n if (pk.length !== crypto_box_PUBLICKEYBYTES) throw new Error('bad public key size');\n if (sk.length !== crypto_box_SECRETKEYBYTES) throw new Error('bad secret key size');\n}\n\nfunction checkArrayTypes() {\n for (var i = 0; i < arguments.length; i++) {\n if (!(arguments[i] instanceof Uint8Array))\n throw new TypeError('unexpected type, use Uint8Array');\n }\n}\n\nfunction cleanup(arr) {\n for (var i = 0; i < arr.length; i++) arr[i] = 0;\n}\n\nnacl.randomBytes = function(n) {\n var b = new Uint8Array(n);\n randombytes(b, n);\n return b;\n};\n\nnacl.secretbox = function(msg, nonce, key) {\n checkArrayTypes(msg, nonce, key);\n checkLengths(key, nonce);\n var m = new Uint8Array(crypto_secretbox_ZEROBYTES + msg.length);\n var c = new Uint8Array(m.length);\n for (var i = 0; i < msg.length; i++) m[i+crypto_secretbox_ZEROBYTES] = msg[i];\n crypto_secretbox(c, m, m.length, nonce, key);\n return c.subarray(crypto_secretbox_BOXZEROBYTES);\n};\n\nnacl.secretbox.open = function(box, nonce, key) {\n checkArrayTypes(box, nonce, key);\n checkLengths(key, nonce);\n var c = new Uint8Array(crypto_secretbox_BOXZEROBYTES + box.length);\n var m = new Uint8Array(c.length);\n for (var i = 0; i < box.length; i++) c[i+crypto_secretbox_BOXZEROBYTES] = box[i];\n if (c.length < 32) return null;\n if (crypto_secretbox_open(m, c, c.length, nonce, key) !== 0) return null;\n return m.subarray(crypto_secretbox_ZEROBYTES);\n};\n\nnacl.secretbox.keyLength = crypto_secretbox_KEYBYTES;\nnacl.secretbox.nonceLength = crypto_secretbox_NONCEBYTES;\nnacl.secretbox.overheadLength = crypto_secretbox_BOXZEROBYTES;\n\nnacl.scalarMult = function(n, p) {\n checkArrayTypes(n, p);\n if (n.length !== crypto_scalarmult_SCALARBYTES) throw new Error('bad n size');\n if (p.length !== crypto_scalarmult_BYTES) throw new Error('bad p size');\n var q = new Uint8Array(crypto_scalarmult_BYTES);\n crypto_scalarmult(q, n, p);\n return q;\n};\n\nnacl.scalarMult.base = function(n) {\n checkArrayTypes(n);\n if (n.length !== crypto_scalarmult_SCALARBYTES) throw new Error('bad n size');\n var q = new Uint8Array(crypto_scalarmult_BYTES);\n crypto_scalarmult_base(q, n);\n return q;\n};\n\nnacl.scalarMult.scalarLength = crypto_scalarmult_SCALARBYTES;\nnacl.scalarMult.groupElementLength = crypto_scalarmult_BYTES;\n\nnacl.box = function(msg, nonce, publicKey, secretKey) {\n var k = nacl.box.before(publicKey, secretKey);\n return nacl.secretbox(msg, nonce, k);\n};\n\nnacl.box.before = function(publicKey, secretKey) {\n checkArrayTypes(publicKey, secretKey);\n checkBoxLengths(publicKey, secretKey);\n var k = new Uint8Array(crypto_box_BEFORENMBYTES);\n crypto_box_beforenm(k, publicKey, secretKey);\n return k;\n};\n\nnacl.box.after = nacl.secretbox;\n\nnacl.box.open = function(msg, nonce, publicKey, secretKey) {\n var k = nacl.box.before(publicKey, secretKey);\n return nacl.secretbox.open(msg, nonce, k);\n};\n\nnacl.box.open.after = nacl.secretbox.open;\n\nnacl.box.keyPair = function() {\n var pk = new Uint8Array(crypto_box_PUBLICKEYBYTES);\n var sk = new Uint8Array(crypto_box_SECRETKEYBYTES);\n crypto_box_keypair(pk, sk);\n return {publicKey: pk, secretKey: sk};\n};\n\nnacl.box.keyPair.fromSecretKey = function(secretKey) {\n checkArrayTypes(secretKey);\n if (secretKey.length !== crypto_box_SECRETKEYBYTES)\n throw new Error('bad secret key size');\n var pk = new Uint8Array(crypto_box_PUBLICKEYBYTES);\n crypto_scalarmult_base(pk, secretKey);\n return {publicKey: pk, secretKey: new Uint8Array(secretKey)};\n};\n\nnacl.box.publicKeyLength = crypto_box_PUBLICKEYBYTES;\nnacl.box.secretKeyLength = crypto_box_SECRETKEYBYTES;\nnacl.box.sharedKeyLength = crypto_box_BEFORENMBYTES;\nnacl.box.nonceLength = crypto_box_NONCEBYTES;\nnacl.box.overheadLength = nacl.secretbox.overheadLength;\n\nnacl.sign = function(msg, secretKey) {\n checkArrayTypes(msg, secretKey);\n if (secretKey.length !== crypto_sign_SECRETKEYBYTES)\n throw new Error('bad secret key size');\n var signedMsg = new Uint8Array(crypto_sign_BYTES+msg.length);\n crypto_sign(signedMsg, msg, msg.length, secretKey);\n return signedMsg;\n};\n\nnacl.sign.open = function(signedMsg, publicKey) {\n checkArrayTypes(signedMsg, publicKey);\n if (publicKey.length !== crypto_sign_PUBLICKEYBYTES)\n throw new Error('bad public key size');\n var tmp = new Uint8Array(signedMsg.length);\n var mlen = crypto_sign_open(tmp, signedMsg, signedMsg.length, publicKey);\n if (mlen < 0) return null;\n var m = new Uint8Array(mlen);\n for (var i = 0; i < m.length; i++) m[i] = tmp[i];\n return m;\n};\n\nnacl.sign.detached = function(msg, secretKey) {\n var signedMsg = nacl.sign(msg, secretKey);\n var sig = new Uint8Array(crypto_sign_BYTES);\n for (var i = 0; i < sig.length; i++) sig[i] = signedMsg[i];\n return sig;\n};\n\nnacl.sign.detached.verify = function(msg, sig, publicKey) {\n checkArrayTypes(msg, sig, publicKey);\n if (sig.length !== crypto_sign_BYTES)\n throw new Error('bad signature size');\n if (publicKey.length !== crypto_sign_PUBLICKEYBYTES)\n throw new Error('bad public key size');\n var sm = new Uint8Array(crypto_sign_BYTES + msg.length);\n var m = new Uint8Array(crypto_sign_BYTES + msg.length);\n var i;\n for (i = 0; i < crypto_sign_BYTES; i++) sm[i] = sig[i];\n for (i = 0; i < msg.length; i++) sm[i+crypto_sign_BYTES] = msg[i];\n return (crypto_sign_open(m, sm, sm.length, publicKey) >= 0);\n};\n\nnacl.sign.keyPair = function() {\n var pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);\n var sk = new Uint8Array(crypto_sign_SECRETKEYBYTES);\n crypto_sign_keypair(pk, sk);\n return {publicKey: pk, secretKey: sk};\n};\n\nnacl.sign.keyPair.fromSecretKey = function(secretKey) {\n checkArrayTypes(secretKey);\n if (secretKey.length !== crypto_sign_SECRETKEYBYTES)\n throw new Error('bad secret key size');\n var pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);\n for (var i = 0; i < pk.length; i++) pk[i] = secretKey[32+i];\n return {publicKey: pk, secretKey: new Uint8Array(secretKey)};\n};\n\nnacl.sign.keyPair.fromSeed = function(seed) {\n checkArrayTypes(seed);\n if (seed.length !== crypto_sign_SEEDBYTES)\n throw new Error('bad seed size');\n var pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);\n var sk = new Uint8Array(crypto_sign_SECRETKEYBYTES);\n for (var i = 0; i < 32; i++) sk[i] = seed[i];\n crypto_sign_keypair(pk, sk, true);\n return {publicKey: pk, secretKey: sk};\n};\n\nnacl.sign.publicKeyLength = crypto_sign_PUBLICKEYBYTES;\nnacl.sign.secretKeyLength = crypto_sign_SECRETKEYBYTES;\nnacl.sign.seedLength = crypto_sign_SEEDBYTES;\nnacl.sign.signatureLength = crypto_sign_BYTES;\n\nnacl.hash = function(msg) {\n checkArrayTypes(msg);\n var h = new Uint8Array(crypto_hash_BYTES);\n crypto_hash(h, msg, msg.length);\n return h;\n};\n\nnacl.hash.hashLength = crypto_hash_BYTES;\n\nnacl.verify = function(x, y) {\n checkArrayTypes(x, y);\n // Zero length arguments are considered not equal.\n if (x.length === 0 || y.length === 0) return false;\n if (x.length !== y.length) return false;\n return (vn(x, 0, y, 0, x.length) === 0) ? true : false;\n};\n\nnacl.setPRNG = function(fn) {\n randombytes = fn;\n};\n\n(function() {\n // Initialize PRNG if environment provides CSPRNG.\n // If not, methods calling randombytes will throw.\n var crypto = typeof self !== 'undefined' ? (self.crypto || self.msCrypto) : null;\n if (crypto && crypto.getRandomValues) {\n // Browsers.\n var QUOTA = 65536;\n nacl.setPRNG(function(x, n) {\n var i, v = new Uint8Array(n);\n for (i = 0; i < n; i += QUOTA) {\n crypto.getRandomValues(v.subarray(i, i + Math.min(n - i, QUOTA)));\n }\n for (i = 0; i < n; i++) x[i] = v[i];\n cleanup(v);\n });\n } else if (typeof require !== 'undefined') {\n // Node.js.\n crypto = require('crypto');\n if (crypto && crypto.randomBytes) {\n nacl.setPRNG(function(x, n) {\n var i, v = crypto.randomBytes(n);\n for (i = 0; i < n; i++) x[i] = v[i];\n cleanup(v);\n });\n }\n }\n})();\n\n})(typeof module !== 'undefined' && module.exports ? module.exports : (self.nacl = self.nacl || {}));\n","module.exports = require('./pusher-with-encryption').default;\n","export default function encode(s: any): string {\n return btoa(utob(s));\n}\n\nvar fromCharCode = String.fromCharCode;\n\nvar b64chars =\n 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';\nvar b64tab = {};\n\nfor (var i = 0, l = b64chars.length; i < l; i++) {\n b64tab[b64chars.charAt(i)] = i;\n}\n\nvar cb_utob = function(c) {\n var cc = c.charCodeAt(0);\n return cc < 0x80\n ? c\n : cc < 0x800\n ? fromCharCode(0xc0 | (cc >>> 6)) + fromCharCode(0x80 | (cc & 0x3f))\n : fromCharCode(0xe0 | ((cc >>> 12) & 0x0f)) +\n fromCharCode(0x80 | ((cc >>> 6) & 0x3f)) +\n fromCharCode(0x80 | (cc & 0x3f));\n};\n\nvar utob = function(u) {\n return u.replace(/[^\\x00-\\x7F]/g, cb_utob);\n};\n\nvar cb_encode = function(ccc) {\n var padlen = [0, 2, 1][ccc.length % 3];\n var ord =\n (ccc.charCodeAt(0) << 16) |\n ((ccc.length > 1 ? ccc.charCodeAt(1) : 0) << 8) |\n (ccc.length > 2 ? ccc.charCodeAt(2) : 0);\n var chars = [\n b64chars.charAt(ord >>> 18),\n b64chars.charAt((ord >>> 12) & 63),\n padlen >= 2 ? '=' : b64chars.charAt((ord >>> 6) & 63),\n padlen >= 1 ? '=' : b64chars.charAt(ord & 63)\n ];\n return chars.join('');\n};\n\nvar btoa =\n global.btoa ||\n function(b) {\n return b.replace(/[\\s\\S]{1,3}/g, cb_encode);\n };\n","import TimedCallback from './timed_callback';\nimport { Delay, Scheduler, Canceller } from './scheduling';\n\nabstract class Timer {\n protected clear: Canceller;\n protected timer: number | void;\n\n constructor(\n set: Scheduler,\n clear: Canceller,\n delay: Delay,\n callback: TimedCallback\n ) {\n this.clear = clear;\n this.timer = set(() => {\n if (this.timer) {\n this.timer = callback(this.timer);\n }\n }, delay);\n }\n\n /** Returns whether the timer is still running.\n *\n * @return {Boolean}\n */\n isRunning(): boolean {\n return this.timer !== null;\n }\n\n /** Aborts a timer when it's running. */\n ensureAborted() {\n if (this.timer) {\n this.clear(this.timer);\n this.timer = null;\n }\n }\n}\n\nexport default Timer;\n","import Timer from './abstract_timer';\nimport TimedCallback from './timed_callback';\nimport { Delay } from './scheduling';\n\n// We need to bind clear functions this way to avoid exceptions on IE8\nfunction clearTimeout(timer) {\n global.clearTimeout(timer);\n}\nfunction clearInterval(timer) {\n global.clearInterval(timer);\n}\n\n/** Cross-browser compatible one-off timer abstraction.\n *\n * @param {Number} delay\n * @param {Function} callback\n */\nexport class OneOffTimer extends Timer {\n constructor(delay: Delay, callback: TimedCallback) {\n super(setTimeout, clearTimeout, delay, function(timer) {\n callback();\n return null;\n });\n }\n}\n\n/** Cross-browser compatible periodic timer abstraction.\n *\n * @param {Number} delay\n * @param {Function} callback\n */\nexport class PeriodicTimer extends Timer {\n constructor(delay: Delay, callback: TimedCallback) {\n super(setInterval, clearInterval, delay, function(timer) {\n callback();\n return timer;\n });\n }\n}\n","import * as Collections from './utils/collections';\nimport TimedCallback from './utils/timers/timed_callback';\nimport { OneOffTimer, PeriodicTimer } from './utils/timers';\n\nvar Util = {\n now(): number {\n if (Date.now) {\n return Date.now();\n } else {\n return new Date().valueOf();\n }\n },\n\n defer(callback: TimedCallback): OneOffTimer {\n return new OneOffTimer(0, callback);\n },\n\n /** Builds a function that will proxy a method call to its first argument.\n *\n * Allows partial application of arguments, so additional arguments are\n * prepended to the argument list.\n *\n * @param {String} name method name\n * @return {Function} proxy function\n */\n method(name: string, ...args: any[]): Function {\n var boundArguments = Array.prototype.slice.call(arguments, 1);\n return function(object) {\n return object[name].apply(object, boundArguments.concat(arguments));\n };\n }\n};\n\nexport default Util;\n","import base64encode from '../base64';\nimport Util from '../util';\n\n/** Merges multiple objects into the target argument.\n *\n * For properties that are plain Objects, performs a deep-merge. For the\n * rest it just copies the value of the property.\n *\n * To extend prototypes use it as following:\n * Pusher.Util.extend(Target.prototype, Base.prototype)\n *\n * You can also use it to merge objects without altering them:\n * Pusher.Util.extend({}, object1, object2)\n *\n * @param {Object} target\n * @return {Object} the target argument\n */\nexport function extend(target: any, ...sources: any[]): T {\n for (var i = 0; i < sources.length; i++) {\n var extensions = sources[i];\n for (var property in extensions) {\n if (\n extensions[property] &&\n extensions[property].constructor &&\n extensions[property].constructor === Object\n ) {\n target[property] = extend(target[property] || {}, extensions[property]);\n } else {\n target[property] = extensions[property];\n }\n }\n }\n return target;\n}\n\nexport function stringify(): string {\n var m = ['Pusher'];\n for (var i = 0; i < arguments.length; i++) {\n if (typeof arguments[i] === 'string') {\n m.push(arguments[i]);\n } else {\n m.push(safeJSONStringify(arguments[i]));\n }\n }\n return m.join(' : ');\n}\n\nexport function arrayIndexOf(array: any[], item: any): number {\n // MSIE doesn't have array.indexOf\n var nativeIndexOf = Array.prototype.indexOf;\n if (array === null) {\n return -1;\n }\n if (nativeIndexOf && array.indexOf === nativeIndexOf) {\n return array.indexOf(item);\n }\n for (var i = 0, l = array.length; i < l; i++) {\n if (array[i] === item) {\n return i;\n }\n }\n return -1;\n}\n\n/** Applies a function f to all properties of an object.\n *\n * Function f gets 3 arguments passed:\n * - element from the object\n * - key of the element\n * - reference to the object\n *\n * @param {Object} object\n * @param {Function} f\n */\nexport function objectApply(object: any, f: Function) {\n for (var key in object) {\n if (Object.prototype.hasOwnProperty.call(object, key)) {\n f(object[key], key, object);\n }\n }\n}\n\n/** Return a list of objects own proerty keys\n *\n * @param {Object} object\n * @returns {Array}\n */\nexport function keys(object: any): string[] {\n var keys = [];\n objectApply(object, function(_, key) {\n keys.push(key);\n });\n return keys;\n}\n\n/** Return a list of object's own property values\n *\n * @param {Object} object\n * @returns {Array}\n */\nexport function values(object: any): any[] {\n var values = [];\n objectApply(object, function(value) {\n values.push(value);\n });\n return values;\n}\n\n/** Applies a function f to all elements of an array.\n *\n * Function f gets 3 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function apply(array: any[], f: Function, context?: any) {\n for (var i = 0; i < array.length; i++) {\n f.call(context || global, array[i], i, array);\n }\n}\n\n/** Maps all elements of the array and returns the result.\n *\n * Function f gets 4 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n * - reference to the destination array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function map(array: any[], f: Function): any[] {\n var result = [];\n for (var i = 0; i < array.length; i++) {\n result.push(f(array[i], i, array, result));\n }\n return result;\n}\n\n/** Maps all elements of the object and returns the result.\n *\n * Function f gets 4 arguments passed:\n * - element from the object\n * - key of the element\n * - reference to the source object\n * - reference to the destination object\n *\n * @param {Object} object\n * @param {Function} f\n */\nexport function mapObject(object: any, f: Function): any {\n var result = {};\n objectApply(object, function(value, key) {\n result[key] = f(value);\n });\n return result;\n}\n\n/** Filters elements of the array using a test function.\n *\n * Function test gets 4 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n * - reference to the destination array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function filter(array: any[], test: Function): any[] {\n test =\n test ||\n function(value) {\n return !!value;\n };\n\n var result = [];\n for (var i = 0; i < array.length; i++) {\n if (test(array[i], i, array, result)) {\n result.push(array[i]);\n }\n }\n return result;\n}\n\n/** Filters properties of the object using a test function.\n *\n * Function test gets 4 arguments passed:\n * - element from the object\n * - key of the element\n * - reference to the source object\n * - reference to the destination object\n *\n * @param {Object} object\n * @param {Function} f\n */\nexport function filterObject(object: Object, test: Function) {\n var result = {};\n objectApply(object, function(value, key) {\n if ((test && test(value, key, object, result)) || Boolean(value)) {\n result[key] = value;\n }\n });\n return result;\n}\n\n/** Flattens an object into a two-dimensional array.\n *\n * @param {Object} object\n * @return {Array} resulting array of [key, value] pairs\n */\nexport function flatten(object: Object): any[] {\n var result = [];\n objectApply(object, function(value, key) {\n result.push([key, value]);\n });\n return result;\n}\n\n/** Checks whether any element of the array passes the test.\n *\n * Function test gets 3 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function any(array: any[], test: Function): boolean {\n for (var i = 0; i < array.length; i++) {\n if (test(array[i], i, array)) {\n return true;\n }\n }\n return false;\n}\n\n/** Checks whether all elements of the array pass the test.\n *\n * Function test gets 3 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function all(array: any[], test: Function): boolean {\n for (var i = 0; i < array.length; i++) {\n if (!test(array[i], i, array)) {\n return false;\n }\n }\n return true;\n}\n\nexport function encodeParamsObject(data): string {\n return mapObject(data, function(value) {\n if (typeof value === 'object') {\n value = safeJSONStringify(value);\n }\n return encodeURIComponent(base64encode(value.toString()));\n });\n}\n\nexport function buildQueryString(data: any): string {\n var params = filterObject(data, function(value) {\n return value !== undefined;\n });\n\n var query = map(\n flatten(encodeParamsObject(params)),\n Util.method('join', '=')\n ).join('&');\n\n return query;\n}\n\n/**\n * See https://github.com/douglascrockford/JSON-js/blob/master/cycle.js\n *\n * Remove circular references from an object. Required for JSON.stringify in\n * React Native, which tends to blow up a lot.\n *\n * @param {any} object\n * @return {any} Decycled object\n */\nexport function decycleObject(object: any): any {\n var objects = [],\n paths = [];\n\n return (function derez(value, path) {\n var i, name, nu;\n\n switch (typeof value) {\n case 'object':\n if (!value) {\n return null;\n }\n for (i = 0; i < objects.length; i += 1) {\n if (objects[i] === value) {\n return { $ref: paths[i] };\n }\n }\n\n objects.push(value);\n paths.push(path);\n\n if (Object.prototype.toString.apply(value) === '[object Array]') {\n nu = [];\n for (i = 0; i < value.length; i += 1) {\n nu[i] = derez(value[i], path + '[' + i + ']');\n }\n } else {\n nu = {};\n for (name in value) {\n if (Object.prototype.hasOwnProperty.call(value, name)) {\n nu[name] = derez(\n value[name],\n path + '[' + JSON.stringify(name) + ']'\n );\n }\n }\n }\n return nu;\n case 'number':\n case 'string':\n case 'boolean':\n return value;\n }\n })(object, '$');\n}\n\n/**\n * Provides a cross-browser and cross-platform way to safely stringify objects\n * into JSON. This is particularly necessary for ReactNative, where circular JSON\n * structures throw an exception.\n *\n * @param {any} source The object to stringify\n * @return {string} The serialized output.\n */\nexport function safeJSONStringify(source: any): string {\n try {\n return JSON.stringify(source);\n } catch (e) {\n return JSON.stringify(decycleObject(source));\n }\n}\n","import {\n ChannelAuthorizationOptions,\n UserAuthenticationOptions\n} from './auth/options';\nimport { AuthTransport } from './config';\n\nexport interface DefaultConfig {\n VERSION: string;\n PROTOCOL: number;\n wsPort: number;\n wssPort: number;\n wsPath: string;\n httpHost: string;\n httpPort: number;\n httpsPort: number;\n httpPath: string;\n stats_host: string;\n authEndpoint: string;\n authTransport: AuthTransport;\n activityTimeout: number;\n pongTimeout: number;\n unavailableTimeout: number;\n userAuthentication: UserAuthenticationOptions;\n channelAuthorization: ChannelAuthorizationOptions;\n\n cdn_http?: string;\n cdn_https?: string;\n dependency_suffix?: string;\n}\n\nvar Defaults: DefaultConfig = {\n VERSION: VERSION,\n PROTOCOL: 7,\n\n wsPort: 80,\n wssPort: 443,\n wsPath: '',\n // DEPRECATED: SockJS fallback parameters\n httpHost: 'sockjs.pusher.com',\n httpPort: 80,\n httpsPort: 443,\n httpPath: '/pusher',\n // DEPRECATED: Stats\n stats_host: 'stats.pusher.com',\n // DEPRECATED: Other settings\n authEndpoint: '/pusher/auth',\n authTransport: 'ajax',\n activityTimeout: 120000,\n pongTimeout: 30000,\n unavailableTimeout: 10000,\n userAuthentication: {\n endpoint: '/pusher/user-auth',\n transport: 'ajax'\n },\n channelAuthorization: {\n endpoint: '/pusher/auth',\n transport: 'ajax'\n },\n\n // CDN configuration\n cdn_http: CDN_HTTP,\n cdn_https: CDN_HTTPS,\n dependency_suffix: DEPENDENCY_SUFFIX\n};\n\nexport default Defaults;\n","import Defaults from '../defaults';\nimport { default as URLScheme, URLSchemeParams } from './url_scheme';\n\nfunction getGenericURL(\n baseScheme: string,\n params: URLSchemeParams,\n path: string\n): string {\n var scheme = baseScheme + (params.useTLS ? 's' : '');\n var host = params.useTLS ? params.hostTLS : params.hostNonTLS;\n return scheme + '://' + host + path;\n}\n\nfunction getGenericPath(key: string, queryString?: string): string {\n var path = '/app/' + key;\n var query =\n '?protocol=' +\n Defaults.PROTOCOL +\n '&client=js' +\n '&version=' +\n Defaults.VERSION +\n (queryString ? '&' + queryString : '');\n return path + query;\n}\n\nexport var ws: URLScheme = {\n getInitial: function(key: string, params: URLSchemeParams): string {\n var path = (params.httpPath || '') + getGenericPath(key, 'flash=false');\n return getGenericURL('ws', params, path);\n }\n};\n\nexport var http: URLScheme = {\n getInitial: function(key: string, params: URLSchemeParams): string {\n var path = (params.httpPath || '/pusher') + getGenericPath(key);\n return getGenericURL('http', params, path);\n }\n};\n\nexport var sockjs: URLScheme = {\n getInitial: function(key: string, params: URLSchemeParams): string {\n return getGenericURL('http', params, params.httpPath || '/pusher');\n },\n getPath: function(key: string, params: URLSchemeParams): string {\n return getGenericPath(key);\n }\n};\n","import Callback from './callback';\nimport * as Collections from '../utils/collections';\nimport CallbackTable from './callback_table';\n\nexport default class CallbackRegistry {\n _callbacks: CallbackTable;\n\n constructor() {\n this._callbacks = {};\n }\n\n get(name: string): Callback[] {\n return this._callbacks[prefix(name)];\n }\n\n add(name: string, callback: Function, context: any) {\n var prefixedEventName = prefix(name);\n this._callbacks[prefixedEventName] =\n this._callbacks[prefixedEventName] || [];\n this._callbacks[prefixedEventName].push({\n fn: callback,\n context: context\n });\n }\n\n remove(name?: string, callback?: Function, context?: any) {\n if (!name && !callback && !context) {\n this._callbacks = {};\n return;\n }\n\n var names = name ? [prefix(name)] : Collections.keys(this._callbacks);\n\n if (callback || context) {\n this.removeCallback(names, callback, context);\n } else {\n this.removeAllCallbacks(names);\n }\n }\n\n private removeCallback(names: string[], callback: Function, context: any) {\n Collections.apply(\n names,\n function(name) {\n this._callbacks[name] = Collections.filter(\n this._callbacks[name] || [],\n function(binding) {\n return (\n (callback && callback !== binding.fn) ||\n (context && context !== binding.context)\n );\n }\n );\n if (this._callbacks[name].length === 0) {\n delete this._callbacks[name];\n }\n },\n this\n );\n }\n\n private removeAllCallbacks(names: string[]) {\n Collections.apply(\n names,\n function(name) {\n delete this._callbacks[name];\n },\n this\n );\n }\n}\n\nfunction prefix(name: string): string {\n return '_' + name;\n}\n","import * as Collections from '../utils/collections';\nimport Callback from './callback';\nimport Metadata from '../channels/metadata';\nimport CallbackRegistry from './callback_registry';\n\n/** Manages callback bindings and event emitting.\n *\n * @param Function failThrough called when no listeners are bound to an event\n */\nexport default class Dispatcher {\n callbacks: CallbackRegistry;\n global_callbacks: Function[];\n failThrough: Function;\n\n constructor(failThrough?: Function) {\n this.callbacks = new CallbackRegistry();\n this.global_callbacks = [];\n this.failThrough = failThrough;\n }\n\n bind(eventName: string, callback: Function, context?: any) {\n this.callbacks.add(eventName, callback, context);\n return this;\n }\n\n bind_global(callback: Function) {\n this.global_callbacks.push(callback);\n return this;\n }\n\n unbind(eventName?: string, callback?: Function, context?: any) {\n this.callbacks.remove(eventName, callback, context);\n return this;\n }\n\n unbind_global(callback?: Function) {\n if (!callback) {\n this.global_callbacks = [];\n return this;\n }\n\n this.global_callbacks = Collections.filter(\n this.global_callbacks || [],\n c => c !== callback\n );\n\n return this;\n }\n\n unbind_all() {\n this.unbind();\n this.unbind_global();\n return this;\n }\n\n emit(eventName: string, data?: any, metadata?: Metadata): Dispatcher {\n for (var i = 0; i < this.global_callbacks.length; i++) {\n this.global_callbacks[i](eventName, data);\n }\n\n var callbacks = this.callbacks.get(eventName);\n var args = [];\n\n if (metadata) {\n // if there's a metadata argument, we need to call the callback with both\n // data and metadata regardless of whether data is undefined\n args.push(data, metadata);\n } else if (data) {\n // metadata is undefined, so we only need to call the callback with data\n // if data exists\n args.push(data);\n }\n\n if (callbacks && callbacks.length > 0) {\n for (var i = 0; i < callbacks.length; i++) {\n callbacks[i].fn.apply(callbacks[i].context || global, args);\n }\n } else if (this.failThrough) {\n this.failThrough(eventName, data);\n }\n\n return this;\n }\n}\n","import { stringify } from './utils/collections';\nimport Pusher from './pusher';\n\nclass Logger {\n debug(...args: any[]) {\n this.log(this.globalLog, args);\n }\n\n warn(...args: any[]) {\n this.log(this.globalLogWarn, args);\n }\n\n error(...args: any[]) {\n this.log(this.globalLogError, args);\n }\n\n private globalLog = (message: string) => {\n if (global.console && global.console.log) {\n global.console.log(message);\n }\n };\n\n private globalLogWarn(message: string) {\n if (global.console && global.console.warn) {\n global.console.warn(message);\n } else {\n this.globalLog(message);\n }\n }\n\n private globalLogError(message: string) {\n if (global.console && global.console.error) {\n global.console.error(message);\n } else {\n this.globalLogWarn(message);\n }\n }\n\n private log(\n defaultLoggingFunction: (message: string) => void,\n ...args: any[]\n ) {\n var message = stringify.apply(this, arguments);\n if (Pusher.log) {\n Pusher.log(message);\n } else if (Pusher.logToConsole) {\n const log = defaultLoggingFunction.bind(this);\n log(message);\n }\n }\n}\n\nexport default new Logger();\n","import Util from '../util';\nimport * as Collections from '../utils/collections';\nimport { default as EventsDispatcher } from '../events/dispatcher';\nimport Logger from '../logger';\nimport TransportHooks from './transport_hooks';\nimport Socket from '../socket';\nimport Runtime from 'runtime';\nimport Timeline from '../timeline/timeline';\nimport TransportConnectionOptions from './transport_connection_options';\n\n/** Provides universal API for transport connections.\n *\n * Transport connection is a low-level object that wraps a connection method\n * and exposes a simple evented interface for the connection state and\n * messaging. It does not implement Pusher-specific WebSocket protocol.\n *\n * Additionally, it fetches resources needed for transport to work and exposes\n * an interface for querying transport features.\n *\n * States:\n * - new - initial state after constructing the object\n * - initializing - during initialization phase, usually fetching resources\n * - intialized - ready to establish a connection\n * - connection - when connection is being established\n * - open - when connection ready to be used\n * - closed - after connection was closed be either side\n *\n * Emits:\n * - error - after the connection raised an error\n *\n * Options:\n * - useTLS - whether connection should be over TLS\n * - hostTLS - host to connect to when connection is over TLS\n * - hostNonTLS - host to connect to when connection is over TLS\n *\n * @param {String} key application key\n * @param {Object} options\n */\nexport default class TransportConnection extends EventsDispatcher {\n hooks: TransportHooks;\n name: string;\n priority: number;\n key: string;\n options: TransportConnectionOptions;\n state: string;\n timeline: Timeline;\n activityTimeout: number;\n id: number;\n socket: Socket;\n beforeOpen: Function;\n initialize: Function;\n\n constructor(\n hooks: TransportHooks,\n name: string,\n priority: number,\n key: string,\n options: TransportConnectionOptions\n ) {\n super();\n this.initialize = Runtime.transportConnectionInitializer;\n this.hooks = hooks;\n this.name = name;\n this.priority = priority;\n this.key = key;\n this.options = options;\n\n this.state = 'new';\n this.timeline = options.timeline;\n this.activityTimeout = options.activityTimeout;\n this.id = this.timeline.generateUniqueID();\n }\n\n /** Checks whether the transport handles activity checks by itself.\n *\n * @return {Boolean}\n */\n handlesActivityChecks(): boolean {\n return Boolean(this.hooks.handlesActivityChecks);\n }\n\n /** Checks whether the transport supports the ping/pong API.\n *\n * @return {Boolean}\n */\n supportsPing(): boolean {\n return Boolean(this.hooks.supportsPing);\n }\n\n /** Tries to establish a connection.\n *\n * @returns {Boolean} false if transport is in invalid state\n */\n connect(): boolean {\n if (this.socket || this.state !== 'initialized') {\n return false;\n }\n\n var url = this.hooks.urls.getInitial(this.key, this.options);\n try {\n this.socket = this.hooks.getSocket(url, this.options);\n } catch (e) {\n Util.defer(() => {\n this.onError(e);\n this.changeState('closed');\n });\n return false;\n }\n\n this.bindListeners();\n\n Logger.debug('Connecting', { transport: this.name, url });\n this.changeState('connecting');\n return true;\n }\n\n /** Closes the connection.\n *\n * @return {Boolean} true if there was a connection to close\n */\n close(): boolean {\n if (this.socket) {\n this.socket.close();\n return true;\n } else {\n return false;\n }\n }\n\n /** Sends data over the open connection.\n *\n * @param {String} data\n * @return {Boolean} true only when in the \"open\" state\n */\n send(data: any): boolean {\n if (this.state === 'open') {\n // Workaround for MobileSafari bug (see https://gist.github.com/2052006)\n Util.defer(() => {\n if (this.socket) {\n this.socket.send(data);\n }\n });\n return true;\n } else {\n return false;\n }\n }\n\n /** Sends a ping if the connection is open and transport supports it. */\n ping() {\n if (this.state === 'open' && this.supportsPing()) {\n this.socket.ping();\n }\n }\n\n private onOpen() {\n if (this.hooks.beforeOpen) {\n this.hooks.beforeOpen(\n this.socket,\n this.hooks.urls.getPath(this.key, this.options)\n );\n }\n this.changeState('open');\n this.socket.onopen = undefined;\n }\n\n private onError(error) {\n this.emit('error', { type: 'WebSocketError', error: error });\n this.timeline.error(this.buildTimelineMessage({ error: error.toString() }));\n }\n\n private onClose(closeEvent?: any) {\n if (closeEvent) {\n this.changeState('closed', {\n code: closeEvent.code,\n reason: closeEvent.reason,\n wasClean: closeEvent.wasClean\n });\n } else {\n this.changeState('closed');\n }\n this.unbindListeners();\n this.socket = undefined;\n }\n\n private onMessage(message) {\n this.emit('message', message);\n }\n\n private onActivity() {\n this.emit('activity');\n }\n\n private bindListeners() {\n this.socket.onopen = () => {\n this.onOpen();\n };\n this.socket.onerror = error => {\n this.onError(error);\n };\n this.socket.onclose = closeEvent => {\n this.onClose(closeEvent);\n };\n this.socket.onmessage = message => {\n this.onMessage(message);\n };\n\n if (this.supportsPing()) {\n this.socket.onactivity = () => {\n this.onActivity();\n };\n }\n }\n\n private unbindListeners() {\n if (this.socket) {\n this.socket.onopen = undefined;\n this.socket.onerror = undefined;\n this.socket.onclose = undefined;\n this.socket.onmessage = undefined;\n if (this.supportsPing()) {\n this.socket.onactivity = undefined;\n }\n }\n }\n\n private changeState(state: string, params?: any) {\n this.state = state;\n this.timeline.info(\n this.buildTimelineMessage({\n state: state,\n params: params\n })\n );\n this.emit(state, params);\n }\n\n buildTimelineMessage(message): any {\n return Collections.extend({ cid: this.id }, message);\n }\n}\n","import Factory from '../utils/factory';\nimport TransportHooks from './transport_hooks';\nimport TransportConnection from './transport_connection';\nimport TransportConnectionOptions from './transport_connection_options';\n\n/** Provides interface for transport connection instantiation.\n *\n * Takes transport-specific hooks as the only argument, which allow checking\n * for transport support and creating its connections.\n *\n * Supported hooks: * - file - the name of the file to be fetched during initialization\n * - urls - URL scheme to be used by transport\n * - handlesActivityCheck - true when the transport handles activity checks\n * - supportsPing - true when the transport has a ping/activity API\n * - isSupported - tells whether the transport is supported in the environment\n * - getSocket - creates a WebSocket-compatible transport socket\n *\n * See transports.js for specific implementations.\n *\n * @param {Object} hooks object containing all needed transport hooks\n */\nexport default class Transport {\n hooks: TransportHooks;\n\n constructor(hooks: TransportHooks) {\n this.hooks = hooks;\n }\n\n /** Returns whether the transport is supported in the environment.\n *\n * @param {Object} envronment te environment details (encryption, settings)\n * @returns {Boolean} true when the transport is supported\n */\n isSupported(environment: any): boolean {\n return this.hooks.isSupported(environment);\n }\n\n /** Creates a transport connection.\n *\n * @param {String} name\n * @param {Number} priority\n * @param {String} key the application key\n * @param {Object} options\n * @returns {TransportConnection}\n */\n createConnection(\n name: string,\n priority: number,\n key: string,\n options: any\n ): TransportConnection {\n return new TransportConnection(this.hooks, name, priority, key, options);\n }\n}\n","import * as URLSchemes from 'core/transports/url_schemes';\nimport URLScheme from 'core/transports/url_scheme';\nimport Transport from 'core/transports/transport';\nimport Util from 'core/util';\nimport * as Collections from 'core/utils/collections';\nimport TransportHooks from 'core/transports/transport_hooks';\nimport TransportsTable from 'core/transports/transports_table';\nimport Runtime from 'runtime';\n\n/** WebSocket transport.\n *\n * Uses native WebSocket implementation, including MozWebSocket supported by\n * earlier Firefox versions.\n */\nvar WSTransport = new Transport({\n urls: URLSchemes.ws,\n handlesActivityChecks: false,\n supportsPing: false,\n\n isInitialized: function() {\n return Boolean(Runtime.getWebSocketAPI());\n },\n isSupported: function(): boolean {\n return Boolean(Runtime.getWebSocketAPI());\n },\n getSocket: function(url) {\n return Runtime.createWebSocket(url);\n }\n});\n\nvar httpConfiguration = {\n urls: URLSchemes.http,\n handlesActivityChecks: false,\n supportsPing: true,\n isInitialized: function() {\n return true;\n }\n};\n\nexport var streamingConfiguration = Collections.extend(\n {\n getSocket: function(url) {\n return Runtime.HTTPFactory.createStreamingSocket(url);\n }\n },\n httpConfiguration\n);\nexport var pollingConfiguration = Collections.extend(\n {\n getSocket: function(url) {\n return Runtime.HTTPFactory.createPollingSocket(url);\n }\n },\n httpConfiguration\n);\n\nvar xhrConfiguration = {\n isSupported: function(): boolean {\n return Runtime.isXHRSupported();\n }\n};\n\n/** HTTP streaming transport using CORS-enabled XMLHttpRequest. */\nvar XHRStreamingTransport = new Transport(\n (\n Collections.extend({}, streamingConfiguration, xhrConfiguration)\n )\n);\n\n/** HTTP long-polling transport using CORS-enabled XMLHttpRequest. */\nvar XHRPollingTransport = new Transport(\n Collections.extend({}, pollingConfiguration, xhrConfiguration)\n);\n\nvar Transports: TransportsTable = {\n ws: WSTransport,\n xhr_streaming: XHRStreamingTransport,\n xhr_polling: XHRPollingTransport\n};\n\nexport default Transports;\n","import Util from '../util';\nimport * as Collections from '../utils/collections';\nimport TransportManager from './transport_manager';\nimport TransportConnection from './transport_connection';\nimport Transport from './transport';\nimport PingDelayOptions from './ping_delay_options';\n\n/** Creates transport connections monitored by a transport manager.\n *\n * When a transport is closed, it might mean the environment does not support\n * it. It's possible that messages get stuck in an intermediate buffer or\n * proxies terminate inactive connections. To combat these problems,\n * assistants monitor the connection lifetime, report unclean exits and\n * adjust ping timeouts to keep the connection active. The decision to disable\n * a transport is the manager's responsibility.\n *\n * @param {TransportManager} manager\n * @param {TransportConnection} transport\n * @param {Object} options\n */\nexport default class AssistantToTheTransportManager {\n manager: TransportManager;\n transport: Transport;\n minPingDelay: number;\n maxPingDelay: number;\n pingDelay: number;\n\n constructor(\n manager: TransportManager,\n transport: Transport,\n options: PingDelayOptions\n ) {\n this.manager = manager;\n this.transport = transport;\n this.minPingDelay = options.minPingDelay;\n this.maxPingDelay = options.maxPingDelay;\n this.pingDelay = undefined;\n }\n\n /** Creates a transport connection.\n *\n * This function has the same API as Transport#createConnection.\n *\n * @param {String} name\n * @param {Number} priority\n * @param {String} key the application key\n * @param {Object} options\n * @returns {TransportConnection}\n */\n createConnection(\n name: string,\n priority: number,\n key: string,\n options: Object\n ): TransportConnection {\n options = Collections.extend({}, options, {\n activityTimeout: this.pingDelay\n });\n var connection = this.transport.createConnection(\n name,\n priority,\n key,\n options\n );\n\n var openTimestamp = null;\n\n var onOpen = function() {\n connection.unbind('open', onOpen);\n connection.bind('closed', onClosed);\n openTimestamp = Util.now();\n };\n var onClosed = closeEvent => {\n connection.unbind('closed', onClosed);\n\n if (closeEvent.code === 1002 || closeEvent.code === 1003) {\n // we don't want to use transports not obeying the protocol\n this.manager.reportDeath();\n } else if (!closeEvent.wasClean && openTimestamp) {\n // report deaths only for short-living transport\n var lifespan = Util.now() - openTimestamp;\n if (lifespan < 2 * this.maxPingDelay) {\n this.manager.reportDeath();\n this.pingDelay = Math.max(lifespan / 2, this.minPingDelay);\n }\n }\n };\n\n connection.bind('open', onOpen);\n return connection;\n }\n\n /** Returns whether the transport is supported in the environment.\n *\n * This function has the same API as Transport#isSupported. Might return false\n * when the manager decides to kill the transport.\n *\n * @param {Object} environment the environment details (encryption, settings)\n * @returns {Boolean} true when the transport is supported\n */\n isSupported(environment: string): boolean {\n return this.manager.isAlive() && this.transport.isSupported(environment);\n }\n}\n","import Action from './action';\nimport { PusherEvent } from './message-types';\n/**\n * Provides functions for handling Pusher protocol-specific messages.\n */\n\nconst Protocol = {\n /**\n * Decodes a message in a Pusher format.\n *\n * The MessageEvent we receive from the transport should contain a pusher event\n * (https://pusher.com/docs/pusher_protocol#events) serialized as JSON in the\n * data field\n *\n * The pusher event may contain a data field too, and it may also be\n * serialised as JSON\n *\n * Throws errors when messages are not parse'able.\n *\n * @param {MessageEvent} messageEvent\n * @return {PusherEvent}\n */\n decodeMessage: function(messageEvent: MessageEvent): PusherEvent {\n try {\n var messageData = JSON.parse(messageEvent.data);\n var pusherEventData = messageData.data;\n if (typeof pusherEventData === 'string') {\n try {\n pusherEventData = JSON.parse(messageData.data);\n } catch (e) {}\n }\n var pusherEvent: PusherEvent = {\n event: messageData.event,\n channel: messageData.channel,\n data: pusherEventData\n };\n if (messageData.user_id) {\n pusherEvent.user_id = messageData.user_id;\n }\n return pusherEvent;\n } catch (e) {\n throw { type: 'MessageParseError', error: e, data: messageEvent.data };\n }\n },\n\n /**\n * Encodes a message to be sent.\n *\n * @param {PusherEvent} event\n * @return {String}\n */\n encodeMessage: function(event: PusherEvent): string {\n return JSON.stringify(event);\n },\n\n /**\n * Processes a handshake message and returns appropriate actions.\n *\n * Returns an object with an 'action' and other action-specific properties.\n *\n * There are three outcomes when calling this function. First is a successful\n * connection attempt, when pusher:connection_established is received, which\n * results in a 'connected' action with an 'id' property. When passed a\n * pusher:error event, it returns a result with action appropriate to the\n * close code and an error. Otherwise, it raises an exception.\n *\n * @param {String} message\n * @result Object\n */\n processHandshake: function(messageEvent: MessageEvent): Action {\n var message = Protocol.decodeMessage(messageEvent);\n\n if (message.event === 'pusher:connection_established') {\n if (!message.data.activity_timeout) {\n throw 'No activity timeout specified in handshake';\n }\n return {\n action: 'connected',\n id: message.data.socket_id,\n activityTimeout: message.data.activity_timeout * 1000\n };\n } else if (message.event === 'pusher:error') {\n // From protocol 6 close codes are sent only once, so this only\n // happens when connection does not support close codes\n return {\n action: this.getCloseAction(message.data),\n error: this.getCloseError(message.data)\n };\n } else {\n throw 'Invalid handshake';\n }\n },\n\n /**\n * Dispatches the close event and returns an appropriate action name.\n *\n * See:\n * 1. https://developer.mozilla.org/en-US/docs/WebSockets/WebSockets_reference/CloseEvent\n * 2. http://pusher.com/docs/pusher_protocol\n *\n * @param {CloseEvent} closeEvent\n * @return {String} close action name\n */\n getCloseAction: function(closeEvent): string {\n if (closeEvent.code < 4000) {\n // ignore 1000 CLOSE_NORMAL, 1001 CLOSE_GOING_AWAY,\n // 1005 CLOSE_NO_STATUS, 1006 CLOSE_ABNORMAL\n // ignore 1007...3999\n // handle 1002 CLOSE_PROTOCOL_ERROR, 1003 CLOSE_UNSUPPORTED,\n // 1004 CLOSE_TOO_LARGE\n if (closeEvent.code >= 1002 && closeEvent.code <= 1004) {\n return 'backoff';\n } else {\n return null;\n }\n } else if (closeEvent.code === 4000) {\n return 'tls_only';\n } else if (closeEvent.code < 4100) {\n return 'refused';\n } else if (closeEvent.code < 4200) {\n return 'backoff';\n } else if (closeEvent.code < 4300) {\n return 'retry';\n } else {\n // unknown error\n return 'refused';\n }\n },\n\n /**\n * Returns an error or null basing on the close event.\n *\n * Null is returned when connection was closed cleanly. Otherwise, an object\n * with error details is returned.\n *\n * @param {CloseEvent} closeEvent\n * @return {Object} error object\n */\n getCloseError: function(closeEvent): any {\n if (closeEvent.code !== 1000 && closeEvent.code !== 1001) {\n return {\n type: 'PusherError',\n data: {\n code: closeEvent.code,\n message: closeEvent.reason || closeEvent.message\n }\n };\n } else {\n return null;\n }\n }\n};\n\nexport default Protocol;\n","import * as Collections from '../utils/collections';\nimport { default as EventsDispatcher } from '../events/dispatcher';\nimport Protocol from './protocol/protocol';\nimport { PusherEvent } from './protocol/message-types';\nimport Logger from '../logger';\nimport TransportConnection from '../transports/transport_connection';\nimport Socket from '../socket';\n/**\n * Provides Pusher protocol interface for transports.\n *\n * Emits following events:\n * - message - on received messages\n * - ping - on ping requests\n * - pong - on pong responses\n * - error - when the transport emits an error\n * - closed - after closing the transport\n *\n * It also emits more events when connection closes with a code.\n * See Protocol.getCloseAction to get more details.\n *\n * @param {Number} id\n * @param {AbstractTransport} transport\n */\nexport default class Connection extends EventsDispatcher implements Socket {\n id: string;\n transport: TransportConnection;\n activityTimeout: number;\n\n constructor(id: string, transport: TransportConnection) {\n super();\n this.id = id;\n this.transport = transport;\n this.activityTimeout = transport.activityTimeout;\n this.bindListeners();\n }\n\n /** Returns whether used transport handles activity checks by itself\n *\n * @returns {Boolean} true if activity checks are handled by the transport\n */\n handlesActivityChecks() {\n return this.transport.handlesActivityChecks();\n }\n\n /** Sends raw data.\n *\n * @param {String} data\n */\n send(data: any): boolean {\n return this.transport.send(data);\n }\n\n /** Sends an event.\n *\n * @param {String} name\n * @param {String} data\n * @param {String} [channel]\n * @returns {Boolean} whether message was sent or not\n */\n send_event(name: string, data: any, channel?: string): boolean {\n var event: PusherEvent = { event: name, data: data };\n if (channel) {\n event.channel = channel;\n }\n Logger.debug('Event sent', event);\n return this.send(Protocol.encodeMessage(event));\n }\n\n /** Sends a ping message to the server.\n *\n * Basing on the underlying transport, it might send either transport's\n * protocol-specific ping or pusher:ping event.\n */\n ping() {\n if (this.transport.supportsPing()) {\n this.transport.ping();\n } else {\n this.send_event('pusher:ping', {});\n }\n }\n\n /** Closes the connection. */\n close() {\n this.transport.close();\n }\n\n private bindListeners() {\n var listeners = {\n message: (messageEvent: MessageEvent) => {\n var pusherEvent;\n try {\n pusherEvent = Protocol.decodeMessage(messageEvent);\n } catch (e) {\n this.emit('error', {\n type: 'MessageParseError',\n error: e,\n data: messageEvent.data\n });\n }\n\n if (pusherEvent !== undefined) {\n Logger.debug('Event recd', pusherEvent);\n\n switch (pusherEvent.event) {\n case 'pusher:error':\n this.emit('error', {\n type: 'PusherError',\n data: pusherEvent.data\n });\n break;\n case 'pusher:ping':\n this.emit('ping');\n break;\n case 'pusher:pong':\n this.emit('pong');\n break;\n }\n this.emit('message', pusherEvent);\n }\n },\n activity: () => {\n this.emit('activity');\n },\n error: error => {\n this.emit('error', error);\n },\n closed: closeEvent => {\n unbindListeners();\n\n if (closeEvent && closeEvent.code) {\n this.handleCloseEvent(closeEvent);\n }\n\n this.transport = null;\n this.emit('closed');\n }\n };\n\n var unbindListeners = () => {\n Collections.objectApply(listeners, (listener, event) => {\n this.transport.unbind(event, listener);\n });\n };\n\n Collections.objectApply(listeners, (listener, event) => {\n this.transport.bind(event, listener);\n });\n }\n\n private handleCloseEvent(closeEvent: any) {\n var action = Protocol.getCloseAction(closeEvent);\n var error = Protocol.getCloseError(closeEvent);\n if (error) {\n this.emit('error', error);\n }\n if (action) {\n this.emit(action, { action: action, error: error });\n }\n }\n}\n","import Util from '../../util';\nimport * as Collections from '../../utils/collections';\nimport Protocol from '../protocol/protocol';\nimport Connection from '../connection';\nimport TransportConnection from '../../transports/transport_connection';\nimport HandshakePayload from './handshake_payload';\n\n/**\n * Handles Pusher protocol handshakes for transports.\n *\n * Calls back with a result object after handshake is completed. Results\n * always have two fields:\n * - action - string describing action to be taken after the handshake\n * - transport - the transport object passed to the constructor\n *\n * Different actions can set different additional properties on the result.\n * In the case of 'connected' action, there will be a 'connection' property\n * containing a Connection object for the transport. Other actions should\n * carry an 'error' property.\n *\n * @param {AbstractTransport} transport\n * @param {Function} callback\n */\nexport default class Handshake {\n transport: TransportConnection;\n callback: (HandshakePayload) => void;\n onMessage: Function;\n onClosed: Function;\n\n constructor(\n transport: TransportConnection,\n callback: (HandshakePayload) => void\n ) {\n this.transport = transport;\n this.callback = callback;\n this.bindListeners();\n }\n\n close() {\n this.unbindListeners();\n this.transport.close();\n }\n\n private bindListeners() {\n this.onMessage = m => {\n this.unbindListeners();\n\n var result;\n try {\n result = Protocol.processHandshake(m);\n } catch (e) {\n this.finish('error', { error: e });\n this.transport.close();\n return;\n }\n\n if (result.action === 'connected') {\n this.finish('connected', {\n connection: new Connection(result.id, this.transport),\n activityTimeout: result.activityTimeout\n });\n } else {\n this.finish(result.action, { error: result.error });\n this.transport.close();\n }\n };\n\n this.onClosed = closeEvent => {\n this.unbindListeners();\n\n var action = Protocol.getCloseAction(closeEvent) || 'backoff';\n var error = Protocol.getCloseError(closeEvent);\n this.finish(action, { error: error });\n };\n\n this.transport.bind('message', this.onMessage);\n this.transport.bind('closed', this.onClosed);\n }\n\n private unbindListeners() {\n this.transport.unbind('message', this.onMessage);\n this.transport.unbind('closed', this.onClosed);\n }\n\n private finish(action: string, params: any) {\n this.callback(\n Collections.extend({ transport: this.transport, action: action }, params)\n );\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport base64encode from '../base64';\nimport Timeline from './timeline';\nimport Runtime from 'runtime';\n\nexport interface TimelineSenderOptions {\n host?: string;\n port?: number;\n path?: string;\n}\n\nexport default class TimelineSender {\n timeline: Timeline;\n options: TimelineSenderOptions;\n host: string;\n\n constructor(timeline: Timeline, options: TimelineSenderOptions) {\n this.timeline = timeline;\n this.options = options || {};\n }\n\n send(useTLS: boolean, callback?: Function) {\n if (this.timeline.isEmpty()) {\n return;\n }\n\n this.timeline.send(\n Runtime.TimelineTransport.getAgent(this, useTLS),\n callback\n );\n }\n}\n","/** Error classes used throughout the library. */\n// https://github.com/Microsoft/TypeScript-wiki/blob/master/Breaking-Changes.md#extending-built-ins-like-error-array-and-map-may-no-longer-work\nexport class BadEventName extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\nexport class BadChannelName extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\nexport class RequestTimedOut extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class TransportPriorityTooLow extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class TransportClosed extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class UnsupportedFeature extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class UnsupportedTransport extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class UnsupportedStrategy extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class HTTPAuthError extends Error {\n status: number;\n constructor(status: number, msg?: string) {\n super(msg);\n this.status = status;\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n","/**\n * A place to store help URLs for error messages etc\n */\n\nconst urlStore = {\n baseUrl: 'https://pusher.com',\n urls: {\n authenticationEndpoint: {\n path: '/docs/channels/server_api/authenticating_users'\n },\n authorizationEndpoint: {\n path: '/docs/channels/server_api/authorizing-users/'\n },\n javascriptQuickStart: {\n path: '/docs/javascript_quick_start'\n },\n triggeringClientEvents: {\n path: '/docs/client_api_guide/client_events#trigger-events'\n },\n encryptedChannelSupport: {\n fullUrl:\n 'https://github.com/pusher/pusher-js/tree/cc491015371a4bde5743d1c87a0fbac0feb53195#encrypted-channel-support'\n }\n }\n};\n\n/** Builds a consistent string with links to pusher documentation\n *\n * @param {string} key - relevant key in the url_store.urls object\n * @return {string} suffix string to append to log message\n */\nconst buildLogSuffix = function(key: string): string {\n const urlPrefix = 'See:';\n const urlObj = urlStore.urls[key];\n if (!urlObj) return '';\n\n let url;\n if (urlObj.fullUrl) {\n url = urlObj.fullUrl;\n } else if (urlObj.path) {\n url = urlStore.baseUrl + urlObj.path;\n }\n\n if (!url) return '';\n return `${urlPrefix} ${url}`;\n};\n\nexport default { buildLogSuffix };\n","import { default as EventsDispatcher } from '../events/dispatcher';\nimport * as Errors from '../errors';\nimport Logger from '../logger';\nimport Pusher from '../pusher';\nimport { PusherEvent } from '../connection/protocol/message-types';\nimport Metadata from './metadata';\nimport UrlStore from '../utils/url_store';\nimport {\n ChannelAuthorizationData,\n ChannelAuthorizationCallback\n} from '../auth/options';\nimport { HTTPAuthError } from '../errors';\n\n/** Provides base public channel interface with an event emitter.\n *\n * Emits:\n * - pusher:subscription_succeeded - after subscribing successfully\n * - other non-internal events\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\nexport default class Channel extends EventsDispatcher {\n name: string;\n pusher: Pusher;\n subscribed: boolean;\n subscriptionPending: boolean;\n subscriptionCancelled: boolean;\n subscriptionCount: null;\n\n constructor(name: string, pusher: Pusher) {\n super(function(event, data) {\n Logger.debug('No callbacks on ' + name + ' for ' + event);\n });\n\n this.name = name;\n this.pusher = pusher;\n this.subscribed = false;\n this.subscriptionPending = false;\n this.subscriptionCancelled = false;\n }\n\n /** Skips authorization, since public channels don't require it.\n *\n * @param {Function} callback\n */\n authorize(socketId: string, callback: ChannelAuthorizationCallback) {\n return callback(null, { auth: '' });\n }\n\n /** Triggers an event */\n trigger(event: string, data: any) {\n if (event.indexOf('client-') !== 0) {\n throw new Errors.BadEventName(\n \"Event '\" + event + \"' does not start with 'client-'\"\n );\n }\n if (!this.subscribed) {\n var suffix = UrlStore.buildLogSuffix('triggeringClientEvents');\n Logger.warn(\n `Client event triggered before channel 'subscription_succeeded' event . ${suffix}`\n );\n }\n return this.pusher.send_event(event, data, this.name);\n }\n\n /** Signals disconnection to the channel. For internal use only. */\n disconnect() {\n this.subscribed = false;\n this.subscriptionPending = false;\n }\n\n /** Handles a PusherEvent. For internal use only.\n *\n * @param {PusherEvent} event\n */\n handleEvent(event: PusherEvent) {\n var eventName = event.event;\n var data = event.data;\n if (eventName === 'pusher_internal:subscription_succeeded') {\n this.handleSubscriptionSucceededEvent(event);\n } else if (eventName === 'pusher_internal:subscription_count') {\n this.handleSubscriptionCountEvent(event);\n } else if (eventName.indexOf('pusher_internal:') !== 0) {\n var metadata: Metadata = {};\n this.emit(eventName, data, metadata);\n }\n }\n\n handleSubscriptionSucceededEvent(event: PusherEvent) {\n this.subscriptionPending = false;\n this.subscribed = true;\n if (this.subscriptionCancelled) {\n this.pusher.unsubscribe(this.name);\n } else {\n this.emit('pusher:subscription_succeeded', event.data);\n }\n }\n\n handleSubscriptionCountEvent(event: PusherEvent) {\n if (event.data.subscription_count) {\n this.subscriptionCount = event.data.subscription_count;\n }\n\n this.emit('pusher:subscription_count', event.data);\n }\n\n /** Sends a subscription request. For internal use only. */\n subscribe() {\n if (this.subscribed) {\n return;\n }\n this.subscriptionPending = true;\n this.subscriptionCancelled = false;\n this.authorize(\n this.pusher.connection.socket_id,\n (error: Error | null, data: ChannelAuthorizationData) => {\n if (error) {\n this.subscriptionPending = false;\n // Why not bind to 'pusher:subscription_error' a level up, and log there?\n // Binding to this event would cause the warning about no callbacks being\n // bound (see constructor) to be suppressed, that's not what we want.\n Logger.error(error.toString());\n this.emit(\n 'pusher:subscription_error',\n Object.assign(\n {},\n {\n type: 'AuthError',\n error: error.message\n },\n error instanceof HTTPAuthError ? { status: error.status } : {}\n )\n );\n } else {\n this.pusher.send_event('pusher:subscribe', {\n auth: data.auth,\n channel_data: data.channel_data,\n channel: this.name\n });\n }\n }\n );\n }\n\n /** Sends an unsubscription request. For internal use only. */\n unsubscribe() {\n this.subscribed = false;\n this.pusher.send_event('pusher:unsubscribe', {\n channel: this.name\n });\n }\n\n /** Cancels an in progress subscription. For internal use only. */\n cancelSubscription() {\n this.subscriptionCancelled = true;\n }\n\n /** Reinstates an in progress subscripiton. For internal use only. */\n reinstateSubscription() {\n this.subscriptionCancelled = false;\n }\n}\n","import Factory from '../utils/factory';\nimport Channel from './channel';\nimport { ChannelAuthorizationCallback } from '../auth/options';\n\n/** Extends public channels to provide private channel interface.\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\nexport default class PrivateChannel extends Channel {\n /** Authorizes the connection to use the channel.\n *\n * @param {String} socketId\n * @param {Function} callback\n */\n authorize(socketId: string, callback: ChannelAuthorizationCallback) {\n return this.pusher.config.channelAuthorizer(\n {\n channelName: this.name,\n socketId: socketId\n },\n callback\n );\n }\n}\n","import * as Collections from '../utils/collections';\n\n/** Represents a collection of members of a presence channel. */\nexport default class Members {\n members: any;\n count: number;\n myID: any;\n me: any;\n\n constructor() {\n this.reset();\n }\n\n /** Returns member's info for given id.\n *\n * Resulting object containts two fields - id and info.\n *\n * @param {Number} id\n * @return {Object} member's info or null\n */\n get(id: string): any {\n if (Object.prototype.hasOwnProperty.call(this.members, id)) {\n return {\n id: id,\n info: this.members[id]\n };\n } else {\n return null;\n }\n }\n\n /** Calls back for each member in unspecified order.\n *\n * @param {Function} callback\n */\n each(callback: Function) {\n Collections.objectApply(this.members, (member, id) => {\n callback(this.get(id));\n });\n }\n\n /** Updates the id for connected member. For internal use only. */\n setMyID(id: string) {\n this.myID = id;\n }\n\n /** Handles subscription data. For internal use only. */\n onSubscription(subscriptionData: any) {\n this.members = subscriptionData.presence.hash;\n this.count = subscriptionData.presence.count;\n this.me = this.get(this.myID);\n }\n\n /** Adds a new member to the collection. For internal use only. */\n addMember(memberData: any) {\n if (this.get(memberData.user_id) === null) {\n this.count++;\n }\n this.members[memberData.user_id] = memberData.user_info;\n return this.get(memberData.user_id);\n }\n\n /** Adds a member from the collection. For internal use only. */\n removeMember(memberData: any) {\n var member = this.get(memberData.user_id);\n if (member) {\n delete this.members[memberData.user_id];\n this.count--;\n }\n return member;\n }\n\n /** Resets the collection to the initial state. For internal use only. */\n reset() {\n this.members = {};\n this.count = 0;\n this.myID = null;\n this.me = null;\n }\n}\n","import PrivateChannel from './private_channel';\nimport Logger from '../logger';\nimport Members from './members';\nimport Pusher from '../pusher';\nimport UrlStore from 'core/utils/url_store';\nimport { PusherEvent } from '../connection/protocol/message-types';\nimport Metadata from './metadata';\nimport { ChannelAuthorizationData } from '../auth/options';\n\nexport default class PresenceChannel extends PrivateChannel {\n members: Members;\n\n /** Adds presence channel functionality to private channels.\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\n constructor(name: string, pusher: Pusher) {\n super(name, pusher);\n this.members = new Members();\n }\n\n /** Authorizes the connection as a member of the channel.\n *\n * @param {String} socketId\n * @param {Function} callback\n */\n authorize(socketId: string, callback: Function) {\n super.authorize(socketId, async (error, authData) => {\n if (!error) {\n authData = authData as ChannelAuthorizationData;\n if (authData.channel_data != null) {\n var channelData = JSON.parse(authData.channel_data);\n this.members.setMyID(channelData.user_id);\n } else {\n await this.pusher.user.signinDonePromise;\n if (this.pusher.user.user_data != null) {\n // If the user is signed in, get the id of the authenticated user\n // and allow the presence authorization to continue.\n this.members.setMyID(this.pusher.user.user_data.id);\n } else {\n let suffix = UrlStore.buildLogSuffix('authorizationEndpoint');\n Logger.error(\n `Invalid auth response for channel '${this.name}', ` +\n `expected 'channel_data' field. ${suffix}, ` +\n `or the user should be signed in.`\n );\n callback('Invalid auth response');\n return;\n }\n }\n }\n callback(error, authData);\n });\n }\n\n /** Handles presence and subscription events. For internal use only.\n *\n * @param {PusherEvent} event\n */\n handleEvent(event: PusherEvent) {\n var eventName = event.event;\n if (eventName.indexOf('pusher_internal:') === 0) {\n this.handleInternalEvent(event);\n } else {\n var data = event.data;\n var metadata: Metadata = {};\n if (event.user_id) {\n metadata.user_id = event.user_id;\n }\n this.emit(eventName, data, metadata);\n }\n }\n handleInternalEvent(event: PusherEvent) {\n var eventName = event.event;\n var data = event.data;\n switch (eventName) {\n case 'pusher_internal:subscription_succeeded':\n this.handleSubscriptionSucceededEvent(event);\n break;\n case 'pusher_internal:subscription_count':\n this.handleSubscriptionCountEvent(event);\n break;\n case 'pusher_internal:member_added':\n var addedMember = this.members.addMember(data);\n this.emit('pusher:member_added', addedMember);\n break;\n case 'pusher_internal:member_removed':\n var removedMember = this.members.removeMember(data);\n if (removedMember) {\n this.emit('pusher:member_removed', removedMember);\n }\n break;\n }\n }\n\n handleSubscriptionSucceededEvent(event: PusherEvent) {\n this.subscriptionPending = false;\n this.subscribed = true;\n if (this.subscriptionCancelled) {\n this.pusher.unsubscribe(this.name);\n } else {\n this.members.onSubscription(event.data);\n this.emit('pusher:subscription_succeeded', this.members);\n }\n }\n\n /** Resets the channel state, including members map. For internal use only. */\n disconnect() {\n this.members.reset();\n super.disconnect();\n }\n}\n","import PrivateChannel from './private_channel';\nimport * as Errors from '../errors';\nimport Logger from '../logger';\nimport Pusher from '../pusher';\nimport { decode as encodeUTF8 } from '@stablelib/utf8';\nimport { decode as decodeBase64 } from '@stablelib/base64';\nimport Dispatcher from '../events/dispatcher';\nimport { PusherEvent } from '../connection/protocol/message-types';\nimport {\n ChannelAuthorizationData,\n ChannelAuthorizationCallback\n} from '../auth/options';\nimport * as nacl from 'tweetnacl';\n\n/** Extends private channels to provide encrypted channel interface.\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\nexport default class EncryptedChannel extends PrivateChannel {\n key: Uint8Array = null;\n nacl: nacl;\n\n constructor(name: string, pusher: Pusher, nacl: nacl) {\n super(name, pusher);\n this.nacl = nacl;\n }\n\n /** Authorizes the connection to use the channel.\n *\n * @param {String} socketId\n * @param {Function} callback\n */\n authorize(socketId: string, callback: ChannelAuthorizationCallback) {\n super.authorize(\n socketId,\n (error: Error | null, authData: ChannelAuthorizationData) => {\n if (error) {\n callback(error, authData);\n return;\n }\n let sharedSecret = authData['shared_secret'];\n if (!sharedSecret) {\n callback(\n new Error(\n `No shared_secret key in auth payload for encrypted channel: ${this.name}`\n ),\n null\n );\n return;\n }\n this.key = decodeBase64(sharedSecret);\n delete authData['shared_secret'];\n callback(null, authData);\n }\n );\n }\n\n trigger(event: string, data: any): boolean {\n throw new Errors.UnsupportedFeature(\n 'Client events are not currently supported for encrypted channels'\n );\n }\n\n /** Handles an event. For internal use only.\n *\n * @param {PusherEvent} event\n */\n handleEvent(event: PusherEvent) {\n var eventName = event.event;\n var data = event.data;\n if (\n eventName.indexOf('pusher_internal:') === 0 ||\n eventName.indexOf('pusher:') === 0\n ) {\n super.handleEvent(event);\n return;\n }\n this.handleEncryptedEvent(eventName, data);\n }\n\n private handleEncryptedEvent(event: string, data: any): void {\n if (!this.key) {\n Logger.debug(\n 'Received encrypted event before key has been retrieved from the authEndpoint'\n );\n return;\n }\n if (!data.ciphertext || !data.nonce) {\n Logger.error(\n 'Unexpected format for encrypted event, expected object with `ciphertext` and `nonce` fields, got: ' +\n data\n );\n return;\n }\n let cipherText = decodeBase64(data.ciphertext);\n if (cipherText.length < this.nacl.secretbox.overheadLength) {\n Logger.error(\n `Expected encrypted event ciphertext length to be ${this.nacl.secretbox.overheadLength}, got: ${cipherText.length}`\n );\n return;\n }\n let nonce = decodeBase64(data.nonce);\n if (nonce.length < this.nacl.secretbox.nonceLength) {\n Logger.error(\n `Expected encrypted event nonce length to be ${this.nacl.secretbox.nonceLength}, got: ${nonce.length}`\n );\n return;\n }\n\n let bytes = this.nacl.secretbox.open(cipherText, nonce, this.key);\n if (bytes === null) {\n Logger.debug(\n 'Failed to decrypt an event, probably because it was encrypted with a different key. Fetching a new key from the authEndpoint...'\n );\n // Try a single time to retrieve a new auth key and decrypt the event with it\n // If this fails, a new key will be requested when a new message is received\n this.authorize(this.pusher.connection.socket_id, (error, authData) => {\n if (error) {\n Logger.error(\n `Failed to make a request to the authEndpoint: ${authData}. Unable to fetch new key, so dropping encrypted event`\n );\n return;\n }\n bytes = this.nacl.secretbox.open(cipherText, nonce, this.key);\n if (bytes === null) {\n Logger.error(\n `Failed to decrypt event with new key. Dropping encrypted event`\n );\n return;\n }\n this.emit(event, this.getDataToEmit(bytes));\n return;\n });\n return;\n }\n this.emit(event, this.getDataToEmit(bytes));\n }\n\n // Try and parse the decrypted bytes as JSON. If we can't parse it, just\n // return the utf-8 string\n getDataToEmit(bytes: Uint8Array): string {\n let raw = encodeUTF8(bytes);\n try {\n return JSON.parse(raw);\n } catch {\n return raw;\n }\n }\n}\n","import { default as EventsDispatcher } from '../events/dispatcher';\nimport { OneOffTimer as Timer } from '../utils/timers';\nimport { Config } from '../config';\nimport Logger from '../logger';\nimport HandshakePayload from './handshake/handshake_payload';\nimport Connection from './connection';\nimport Strategy from '../strategies/strategy';\nimport StrategyRunner from '../strategies/strategy_runner';\nimport * as Collections from '../utils/collections';\nimport Timeline from '../timeline/timeline';\nimport ConnectionManagerOptions from './connection_manager_options';\nimport Runtime from 'runtime';\n\nimport {\n ErrorCallbacks,\n HandshakeCallbacks,\n ConnectionCallbacks\n} from './callbacks';\nimport Action from './protocol/action';\n\n/** Manages connection to Pusher.\n *\n * Uses a strategy (currently only default), timers and network availability\n * info to establish a connection and export its state. In case of failures,\n * manages reconnection attempts.\n *\n * Exports state changes as following events:\n * - \"state_change\", { previous: p, current: state }\n * - state\n *\n * States:\n * - initialized - initial state, never transitioned to\n * - connecting - connection is being established\n * - connected - connection has been fully established\n * - disconnected - on requested disconnection\n * - unavailable - after connection timeout or when there's no network\n * - failed - when the connection strategy is not supported\n *\n * Options:\n * - unavailableTimeout - time to transition to unavailable state\n * - activityTimeout - time after which ping message should be sent\n * - pongTimeout - time for Pusher to respond with pong before reconnecting\n *\n * @param {String} key application key\n * @param {Object} options\n */\nexport default class ConnectionManager extends EventsDispatcher {\n key: string;\n options: ConnectionManagerOptions;\n state: string;\n connection: Connection;\n usingTLS: boolean;\n timeline: Timeline;\n socket_id: string;\n unavailableTimer: Timer;\n activityTimer: Timer;\n retryTimer: Timer;\n activityTimeout: number;\n strategy: Strategy;\n runner: StrategyRunner;\n errorCallbacks: ErrorCallbacks;\n handshakeCallbacks: HandshakeCallbacks;\n connectionCallbacks: ConnectionCallbacks;\n\n constructor(key: string, options: ConnectionManagerOptions) {\n super();\n this.state = 'initialized';\n this.connection = null;\n\n this.key = key;\n this.options = options;\n this.timeline = this.options.timeline;\n this.usingTLS = this.options.useTLS;\n\n this.errorCallbacks = this.buildErrorCallbacks();\n this.connectionCallbacks = this.buildConnectionCallbacks(\n this.errorCallbacks\n );\n this.handshakeCallbacks = this.buildHandshakeCallbacks(this.errorCallbacks);\n\n var Network = Runtime.getNetwork();\n\n Network.bind('online', () => {\n this.timeline.info({ netinfo: 'online' });\n if (this.state === 'connecting' || this.state === 'unavailable') {\n this.retryIn(0);\n }\n });\n Network.bind('offline', () => {\n this.timeline.info({ netinfo: 'offline' });\n if (this.connection) {\n this.sendActivityCheck();\n }\n });\n\n this.updateStrategy();\n }\n\n switchCluster(key: string) {\n this.key = key;\n // This ensures that the new config coming from\n // pusher instance are taken into account\n // such as appKey and cluster\n this.updateStrategy();\n this.retryIn(0);\n }\n\n /** Establishes a connection to Pusher.\n *\n * Does nothing when connection is already established. See top-level doc\n * to find events emitted on connection attempts.\n */\n connect() {\n if (this.connection || this.runner) {\n return;\n }\n if (!this.strategy.isSupported()) {\n this.updateState('failed');\n return;\n }\n this.updateState('connecting');\n this.startConnecting();\n this.setUnavailableTimer();\n }\n\n /** Sends raw data.\n *\n * @param {String} data\n */\n send(data) {\n if (this.connection) {\n return this.connection.send(data);\n } else {\n return false;\n }\n }\n\n /** Sends an event.\n *\n * @param {String} name\n * @param {String} data\n * @param {String} [channel]\n * @returns {Boolean} whether message was sent or not\n */\n send_event(name: string, data: any, channel?: string) {\n if (this.connection) {\n return this.connection.send_event(name, data, channel);\n } else {\n return false;\n }\n }\n\n /** Closes the connection. */\n disconnect() {\n this.disconnectInternally();\n this.updateState('disconnected');\n }\n\n isUsingTLS() {\n return this.usingTLS;\n }\n\n private startConnecting() {\n var callback = (error, handshake) => {\n if (error) {\n this.runner = this.strategy.connect(0, callback);\n } else {\n if (handshake.action === 'error') {\n this.emit('error', {\n type: 'HandshakeError',\n error: handshake.error\n });\n this.timeline.error({ handshakeError: handshake.error });\n } else {\n this.abortConnecting(); // we don't support switching connections yet\n this.handshakeCallbacks[handshake.action](handshake);\n }\n }\n };\n this.runner = this.strategy.connect(0, callback);\n }\n\n private abortConnecting() {\n if (this.runner) {\n this.runner.abort();\n this.runner = null;\n }\n }\n\n private disconnectInternally() {\n this.abortConnecting();\n this.clearRetryTimer();\n this.clearUnavailableTimer();\n if (this.connection) {\n var connection = this.abandonConnection();\n connection.close();\n }\n }\n\n private updateStrategy() {\n this.strategy = this.options.getStrategy({\n key: this.key,\n timeline: this.timeline,\n useTLS: this.usingTLS\n });\n }\n\n private retryIn(delay) {\n this.timeline.info({ action: 'retry', delay: delay });\n if (delay > 0) {\n this.emit('connecting_in', Math.round(delay / 1000));\n }\n this.retryTimer = new Timer(delay || 0, () => {\n this.disconnectInternally();\n this.connect();\n });\n }\n\n private clearRetryTimer() {\n if (this.retryTimer) {\n this.retryTimer.ensureAborted();\n this.retryTimer = null;\n }\n }\n\n private setUnavailableTimer() {\n this.unavailableTimer = new Timer(this.options.unavailableTimeout, () => {\n this.updateState('unavailable');\n });\n }\n\n private clearUnavailableTimer() {\n if (this.unavailableTimer) {\n this.unavailableTimer.ensureAborted();\n }\n }\n\n private sendActivityCheck() {\n this.stopActivityCheck();\n this.connection.ping();\n // wait for pong response\n this.activityTimer = new Timer(this.options.pongTimeout, () => {\n this.timeline.error({ pong_timed_out: this.options.pongTimeout });\n this.retryIn(0);\n });\n }\n\n private resetActivityCheck() {\n this.stopActivityCheck();\n // send ping after inactivity\n if (this.connection && !this.connection.handlesActivityChecks()) {\n this.activityTimer = new Timer(this.activityTimeout, () => {\n this.sendActivityCheck();\n });\n }\n }\n\n private stopActivityCheck() {\n if (this.activityTimer) {\n this.activityTimer.ensureAborted();\n }\n }\n\n private buildConnectionCallbacks(\n errorCallbacks: ErrorCallbacks\n ): ConnectionCallbacks {\n return Collections.extend({}, errorCallbacks, {\n message: message => {\n // includes pong messages from server\n this.resetActivityCheck();\n this.emit('message', message);\n },\n ping: () => {\n this.send_event('pusher:pong', {});\n },\n activity: () => {\n this.resetActivityCheck();\n },\n error: error => {\n // just emit error to user - socket will already be closed by browser\n this.emit('error', error);\n },\n closed: () => {\n this.abandonConnection();\n if (this.shouldRetry()) {\n this.retryIn(1000);\n }\n }\n });\n }\n\n private buildHandshakeCallbacks(\n errorCallbacks: ErrorCallbacks\n ): HandshakeCallbacks {\n return Collections.extend({}, errorCallbacks, {\n connected: (handshake: HandshakePayload) => {\n this.activityTimeout = Math.min(\n this.options.activityTimeout,\n handshake.activityTimeout,\n handshake.connection.activityTimeout || Infinity\n );\n this.clearUnavailableTimer();\n this.setConnection(handshake.connection);\n this.socket_id = this.connection.id;\n this.updateState('connected', { socket_id: this.socket_id });\n }\n });\n }\n\n private buildErrorCallbacks(): ErrorCallbacks {\n let withErrorEmitted = callback => {\n return (result: Action | HandshakePayload) => {\n if (result.error) {\n this.emit('error', { type: 'WebSocketError', error: result.error });\n }\n callback(result);\n };\n };\n\n return {\n tls_only: withErrorEmitted(() => {\n this.usingTLS = true;\n this.updateStrategy();\n this.retryIn(0);\n }),\n refused: withErrorEmitted(() => {\n this.disconnect();\n }),\n backoff: withErrorEmitted(() => {\n this.retryIn(1000);\n }),\n retry: withErrorEmitted(() => {\n this.retryIn(0);\n })\n };\n }\n\n private setConnection(connection) {\n this.connection = connection;\n for (var event in this.connectionCallbacks) {\n this.connection.bind(event, this.connectionCallbacks[event]);\n }\n this.resetActivityCheck();\n }\n\n private abandonConnection() {\n if (!this.connection) {\n return;\n }\n this.stopActivityCheck();\n for (var event in this.connectionCallbacks) {\n this.connection.unbind(event, this.connectionCallbacks[event]);\n }\n var connection = this.connection;\n this.connection = null;\n return connection;\n }\n\n private updateState(newState: string, data?: any) {\n var previousState = this.state;\n this.state = newState;\n if (previousState !== newState) {\n var newStateDescription = newState;\n if (newStateDescription === 'connected') {\n newStateDescription += ' with new socket ID ' + data.socket_id;\n }\n Logger.debug(\n 'State changed',\n previousState + ' -> ' + newStateDescription\n );\n this.timeline.info({ state: newState, params: data });\n this.emit('state_change', { previous: previousState, current: newState });\n this.emit(newState, data);\n }\n }\n\n private shouldRetry(): boolean {\n return this.state === 'connecting' || this.state === 'connected';\n }\n}\n","import Channel from './channel';\nimport * as Collections from '../utils/collections';\nimport ChannelTable from './channel_table';\nimport Factory from '../utils/factory';\nimport Pusher from '../pusher';\nimport Logger from '../logger';\nimport * as Errors from '../errors';\nimport urlStore from '../utils/url_store';\n\n/** Handles a channel map. */\nexport default class Channels {\n channels: ChannelTable;\n\n constructor() {\n this.channels = {};\n }\n\n /** Creates or retrieves an existing channel by its name.\n *\n * @param {String} name\n * @param {Pusher} pusher\n * @return {Channel}\n */\n add(name: string, pusher: Pusher) {\n if (!this.channels[name]) {\n this.channels[name] = createChannel(name, pusher);\n }\n return this.channels[name];\n }\n\n /** Returns a list of all channels\n *\n * @return {Array}\n */\n all(): Channel[] {\n return Collections.values(this.channels);\n }\n\n /** Finds a channel by its name.\n *\n * @param {String} name\n * @return {Channel} channel or null if it doesn't exist\n */\n find(name: string) {\n return this.channels[name];\n }\n\n /** Removes a channel from the map.\n *\n * @param {String} name\n */\n remove(name: string) {\n var channel = this.channels[name];\n delete this.channels[name];\n return channel;\n }\n\n /** Proxies disconnection signal to all channels. */\n disconnect() {\n Collections.objectApply(this.channels, function(channel) {\n channel.disconnect();\n });\n }\n}\n\nfunction createChannel(name: string, pusher: Pusher): Channel {\n if (name.indexOf('private-encrypted-') === 0) {\n if (pusher.config.nacl) {\n return Factory.createEncryptedChannel(name, pusher, pusher.config.nacl);\n }\n let errMsg =\n 'Tried to subscribe to a private-encrypted- channel but no nacl implementation available';\n let suffix = urlStore.buildLogSuffix('encryptedChannelSupport');\n throw new Errors.UnsupportedFeature(`${errMsg}. ${suffix}`);\n } else if (name.indexOf('private-') === 0) {\n return Factory.createPrivateChannel(name, pusher);\n } else if (name.indexOf('presence-') === 0) {\n return Factory.createPresenceChannel(name, pusher);\n } else if (name.indexOf('#') === 0) {\n throw new Errors.BadChannelName(\n 'Cannot create a channel with name \"' + name + '\".'\n );\n } else {\n return Factory.createChannel(name, pusher);\n }\n}\n","import AssistantToTheTransportManager from '../transports/assistant_to_the_transport_manager';\nimport PingDelayOptions from '../transports/ping_delay_options';\nimport Transport from '../transports/transport';\nimport TransportManager from '../transports/transport_manager';\nimport Handshake from '../connection/handshake';\nimport TransportConnection from '../transports/transport_connection';\nimport SocketHooks from '../http/socket_hooks';\nimport HTTPSocket from '../http/http_socket';\n\nimport Timeline from '../timeline/timeline';\nimport {\n default as TimelineSender,\n TimelineSenderOptions\n} from '../timeline/timeline_sender';\nimport PresenceChannel from '../channels/presence_channel';\nimport PrivateChannel from '../channels/private_channel';\nimport EncryptedChannel from '../channels/encrypted_channel';\nimport Channel from '../channels/channel';\nimport ConnectionManager from '../connection/connection_manager';\nimport ConnectionManagerOptions from '../connection/connection_manager_options';\nimport Ajax from '../http/ajax';\nimport Channels from '../channels/channels';\nimport Pusher from '../pusher';\nimport { Config } from '../config';\nimport * as nacl from 'tweetnacl';\n\nvar Factory = {\n createChannels(): Channels {\n return new Channels();\n },\n\n createConnectionManager(\n key: string,\n options: ConnectionManagerOptions\n ): ConnectionManager {\n return new ConnectionManager(key, options);\n },\n\n createChannel(name: string, pusher: Pusher): Channel {\n return new Channel(name, pusher);\n },\n\n createPrivateChannel(name: string, pusher: Pusher): PrivateChannel {\n return new PrivateChannel(name, pusher);\n },\n\n createPresenceChannel(name: string, pusher: Pusher): PresenceChannel {\n return new PresenceChannel(name, pusher);\n },\n\n createEncryptedChannel(\n name: string,\n pusher: Pusher,\n nacl: nacl\n ): EncryptedChannel {\n return new EncryptedChannel(name, pusher, nacl);\n },\n\n createTimelineSender(timeline: Timeline, options: TimelineSenderOptions) {\n return new TimelineSender(timeline, options);\n },\n\n createHandshake(\n transport: TransportConnection,\n callback: (HandshakePayload) => void\n ): Handshake {\n return new Handshake(transport, callback);\n },\n\n createAssistantToTheTransportManager(\n manager: TransportManager,\n transport: Transport,\n options: PingDelayOptions\n ): AssistantToTheTransportManager {\n return new AssistantToTheTransportManager(manager, transport, options);\n }\n};\n\nexport default Factory;\n","import AssistantToTheTransportManager from './assistant_to_the_transport_manager';\nimport Transport from './transport';\nimport PingDelayOptions from './ping_delay_options';\nimport Factory from '../utils/factory';\n\nexport interface TransportManagerOptions extends PingDelayOptions {\n lives?: number;\n}\n\n/** Keeps track of the number of lives left for a transport.\n *\n * In the beginning of a session, transports may be assigned a number of\n * lives. When an AssistantToTheTransportManager instance reports a transport\n * connection closed uncleanly, the transport loses a life. When the number\n * of lives drops to zero, the transport gets disabled by its manager.\n *\n * @param {Object} options\n */\nexport default class TransportManager {\n options: TransportManagerOptions;\n livesLeft: number;\n\n constructor(options: TransportManagerOptions) {\n this.options = options || {};\n this.livesLeft = this.options.lives || Infinity;\n }\n\n /** Creates a assistant for the transport.\n *\n * @param {Transport} transport\n * @returns {AssistantToTheTransportManager}\n */\n getAssistant(transport: Transport): AssistantToTheTransportManager {\n return Factory.createAssistantToTheTransportManager(this, transport, {\n minPingDelay: this.options.minPingDelay,\n maxPingDelay: this.options.maxPingDelay\n });\n }\n\n /** Returns whether the transport has any lives left.\n *\n * @returns {Boolean}\n */\n isAlive(): boolean {\n return this.livesLeft > 0;\n }\n\n /** Takes one life from the transport. */\n reportDeath() {\n this.livesLeft -= 1;\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport { OneOffTimer as Timer } from '../utils/timers';\nimport Strategy from './strategy';\nimport StrategyOptions from './strategy_options';\n\n/** Loops through strategies with optional timeouts.\n *\n * Options:\n * - loop - whether it should loop through the substrategy list\n * - timeout - initial timeout for a single substrategy\n * - timeoutLimit - maximum timeout\n *\n * @param {Strategy[]} strategies\n * @param {Object} options\n */\nexport default class SequentialStrategy implements Strategy {\n strategies: Strategy[];\n loop: boolean;\n failFast: boolean;\n timeout: number;\n timeoutLimit: number;\n\n constructor(strategies: Strategy[], options: StrategyOptions) {\n this.strategies = strategies;\n this.loop = Boolean(options.loop);\n this.failFast = Boolean(options.failFast);\n this.timeout = options.timeout;\n this.timeoutLimit = options.timeoutLimit;\n }\n\n isSupported(): boolean {\n return Collections.any(this.strategies, Util.method('isSupported'));\n }\n\n connect(minPriority: number, callback: Function) {\n var strategies = this.strategies;\n var current = 0;\n var timeout = this.timeout;\n var runner = null;\n\n var tryNextStrategy = (error, handshake) => {\n if (handshake) {\n callback(null, handshake);\n } else {\n current = current + 1;\n if (this.loop) {\n current = current % strategies.length;\n }\n\n if (current < strategies.length) {\n if (timeout) {\n timeout = timeout * 2;\n if (this.timeoutLimit) {\n timeout = Math.min(timeout, this.timeoutLimit);\n }\n }\n runner = this.tryStrategy(\n strategies[current],\n minPriority,\n { timeout, failFast: this.failFast },\n tryNextStrategy\n );\n } else {\n callback(true);\n }\n }\n };\n\n runner = this.tryStrategy(\n strategies[current],\n minPriority,\n { timeout: timeout, failFast: this.failFast },\n tryNextStrategy\n );\n\n return {\n abort: function() {\n runner.abort();\n },\n forceMinPriority: function(p) {\n minPriority = p;\n if (runner) {\n runner.forceMinPriority(p);\n }\n }\n };\n }\n\n private tryStrategy(\n strategy: Strategy,\n minPriority: number,\n options: StrategyOptions,\n callback: Function\n ) {\n var timer = null;\n var runner = null;\n\n if (options.timeout > 0) {\n timer = new Timer(options.timeout, function() {\n runner.abort();\n callback(true);\n });\n }\n\n runner = strategy.connect(minPriority, function(error, handshake) {\n if (error && timer && timer.isRunning() && !options.failFast) {\n // advance to the next strategy after the timeout\n return;\n }\n if (timer) {\n timer.ensureAborted();\n }\n callback(error, handshake);\n });\n\n return {\n abort: function() {\n if (timer) {\n timer.ensureAborted();\n }\n runner.abort();\n },\n forceMinPriority: function(p) {\n runner.forceMinPriority(p);\n }\n };\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport Strategy from './strategy';\n\n/** Launches all substrategies and emits prioritized connected transports.\n *\n * @param {Array} strategies\n */\nexport default class BestConnectedEverStrategy implements Strategy {\n strategies: Strategy[];\n\n constructor(strategies: Strategy[]) {\n this.strategies = strategies;\n }\n\n isSupported(): boolean {\n return Collections.any(this.strategies, Util.method('isSupported'));\n }\n\n connect(minPriority: number, callback: Function) {\n return connect(this.strategies, minPriority, function(i, runners) {\n return function(error, handshake) {\n runners[i].error = error;\n if (error) {\n if (allRunnersFailed(runners)) {\n callback(true);\n }\n return;\n }\n Collections.apply(runners, function(runner) {\n runner.forceMinPriority(handshake.transport.priority);\n });\n callback(null, handshake);\n };\n });\n }\n}\n\n/** Connects to all strategies in parallel.\n *\n * Callback builder should be a function that takes two arguments: index\n * and a list of runners. It should return another function that will be\n * passed to the substrategy with given index. Runners can be aborted using\n * abortRunner(s) functions from this class.\n *\n * @param {Array} strategies\n * @param {Function} callbackBuilder\n * @return {Object} strategy runner\n */\nfunction connect(\n strategies: Strategy[],\n minPriority: number,\n callbackBuilder: Function\n) {\n var runners = Collections.map(strategies, function(strategy, i, _, rs) {\n return strategy.connect(minPriority, callbackBuilder(i, rs));\n });\n return {\n abort: function() {\n Collections.apply(runners, abortRunner);\n },\n forceMinPriority: function(p) {\n Collections.apply(runners, function(runner) {\n runner.forceMinPriority(p);\n });\n }\n };\n}\n\nfunction allRunnersFailed(runners): boolean {\n return Collections.all(runners, function(runner) {\n return Boolean(runner.error);\n });\n}\n\nfunction abortRunner(runner) {\n if (!runner.error && !runner.aborted) {\n runner.abort();\n runner.aborted = true;\n }\n}\n","import Util from '../util';\nimport Runtime from 'runtime';\nimport Strategy from './strategy';\nimport SequentialStrategy from './sequential_strategy';\nimport StrategyOptions from './strategy_options';\nimport TransportStrategy from './transport_strategy';\nimport Timeline from '../timeline/timeline';\nimport * as Collections from '../utils/collections';\n\nexport interface TransportStrategyDictionary {\n [key: string]: TransportStrategy;\n}\n\n/** Caches the last successful transport and, after the first few attempts,\n * uses the cached transport for subsequent attempts.\n *\n * @param {Strategy} strategy\n * @param {Object} transports\n * @param {Object} options\n */\nexport default class WebSocketPrioritizedCachedStrategy implements Strategy {\n strategy: Strategy;\n transports: TransportStrategyDictionary;\n ttl: number;\n usingTLS: boolean;\n timeline: Timeline;\n\n constructor(\n strategy: Strategy,\n transports: TransportStrategyDictionary,\n options: StrategyOptions\n ) {\n this.strategy = strategy;\n this.transports = transports;\n this.ttl = options.ttl || 1800 * 1000;\n this.usingTLS = options.useTLS;\n this.timeline = options.timeline;\n }\n\n isSupported(): boolean {\n return this.strategy.isSupported();\n }\n\n connect(minPriority: number, callback: Function) {\n var usingTLS = this.usingTLS;\n var info = fetchTransportCache(usingTLS);\n var cacheSkipCount = info && info.cacheSkipCount ? info.cacheSkipCount : 0;\n\n var strategies = [this.strategy];\n if (info && info.timestamp + this.ttl >= Util.now()) {\n var transport = this.transports[info.transport];\n if (transport) {\n if (['ws', 'wss'].includes(info.transport) || cacheSkipCount > 3) {\n this.timeline.info({\n cached: true,\n transport: info.transport,\n latency: info.latency\n });\n strategies.push(\n new SequentialStrategy([transport], {\n timeout: info.latency * 2 + 1000,\n failFast: true\n })\n );\n } else {\n cacheSkipCount++;\n }\n }\n }\n\n var startTimestamp = Util.now();\n var runner = strategies\n .pop()\n .connect(minPriority, function cb(error, handshake) {\n if (error) {\n flushTransportCache(usingTLS);\n if (strategies.length > 0) {\n startTimestamp = Util.now();\n runner = strategies.pop().connect(minPriority, cb);\n } else {\n callback(error);\n }\n } else {\n storeTransportCache(\n usingTLS,\n handshake.transport.name,\n Util.now() - startTimestamp,\n cacheSkipCount\n );\n callback(null, handshake);\n }\n });\n\n return {\n abort: function() {\n runner.abort();\n },\n forceMinPriority: function(p) {\n minPriority = p;\n if (runner) {\n runner.forceMinPriority(p);\n }\n }\n };\n }\n}\n\nfunction getTransportCacheKey(usingTLS: boolean): string {\n return 'pusherTransport' + (usingTLS ? 'TLS' : 'NonTLS');\n}\n\nfunction fetchTransportCache(usingTLS: boolean): any {\n var storage = Runtime.getLocalStorage();\n if (storage) {\n try {\n var serializedCache = storage[getTransportCacheKey(usingTLS)];\n if (serializedCache) {\n return JSON.parse(serializedCache);\n }\n } catch (e) {\n flushTransportCache(usingTLS);\n }\n }\n return null;\n}\n\nfunction storeTransportCache(\n usingTLS: boolean,\n transport: TransportStrategy,\n latency: number,\n cacheSkipCount: number\n) {\n var storage = Runtime.getLocalStorage();\n if (storage) {\n try {\n storage[getTransportCacheKey(usingTLS)] = Collections.safeJSONStringify({\n timestamp: Util.now(),\n transport: transport,\n latency: latency,\n cacheSkipCount: cacheSkipCount\n });\n } catch (e) {\n // catch over quota exceptions raised by localStorage\n }\n }\n}\n\nfunction flushTransportCache(usingTLS: boolean) {\n var storage = Runtime.getLocalStorage();\n if (storage) {\n try {\n delete storage[getTransportCacheKey(usingTLS)];\n } catch (e) {\n // catch exceptions raised by localStorage\n }\n }\n}\n","import { OneOffTimer as Timer } from '../utils/timers';\nimport Strategy from './strategy';\nimport StrategyOptions from './strategy_options';\n\n/** Runs substrategy after specified delay.\n *\n * Options:\n * - delay - time in miliseconds to delay the substrategy attempt\n *\n * @param {Strategy} strategy\n * @param {Object} options\n */\nexport default class DelayedStrategy implements Strategy {\n strategy: Strategy;\n options: { delay: number };\n\n constructor(strategy: Strategy, { delay: number }) {\n this.strategy = strategy;\n this.options = { delay: number };\n }\n\n isSupported(): boolean {\n return this.strategy.isSupported();\n }\n\n connect(minPriority: number, callback: Function) {\n var strategy = this.strategy;\n var runner;\n var timer = new Timer(this.options.delay, function() {\n runner = strategy.connect(minPriority, callback);\n });\n\n return {\n abort: function() {\n timer.ensureAborted();\n if (runner) {\n runner.abort();\n }\n },\n forceMinPriority: function(p) {\n minPriority = p;\n if (runner) {\n runner.forceMinPriority(p);\n }\n }\n };\n }\n}\n","import Strategy from './strategy';\nimport StrategyRunner from './strategy_runner';\n\n/** Proxies method calls to one of substrategies basing on the test function.\n *\n * @param {Function} test\n * @param {Strategy} trueBranch strategy used when test returns true\n * @param {Strategy} falseBranch strategy used when test returns false\n */\nexport default class IfStrategy implements Strategy {\n test: () => boolean;\n trueBranch: Strategy;\n falseBranch: Strategy;\n\n constructor(\n test: () => boolean,\n trueBranch: Strategy,\n falseBranch: Strategy\n ) {\n this.test = test;\n this.trueBranch = trueBranch;\n this.falseBranch = falseBranch;\n }\n\n isSupported(): boolean {\n var branch = this.test() ? this.trueBranch : this.falseBranch;\n return branch.isSupported();\n }\n\n connect(minPriority: number, callback: Function): StrategyRunner {\n var branch = this.test() ? this.trueBranch : this.falseBranch;\n return branch.connect(minPriority, callback);\n }\n}\n","import Strategy from './strategy';\nimport StrategyRunner from './strategy_runner';\n\n/** Launches the substrategy and terminates on the first open connection.\n *\n * @param {Strategy} strategy\n */\nexport default class FirstConnectedStrategy implements Strategy {\n strategy: Strategy;\n\n constructor(strategy: Strategy) {\n this.strategy = strategy;\n }\n\n isSupported(): boolean {\n return this.strategy.isSupported();\n }\n\n connect(minPriority: number, callback: Function): StrategyRunner {\n var runner = this.strategy.connect(minPriority, function(error, handshake) {\n if (handshake) {\n runner.abort();\n }\n callback(error, handshake);\n });\n return runner;\n }\n}\n","import * as Collections from 'core/utils/collections';\nimport TransportManager from 'core/transports/transport_manager';\nimport Strategy from 'core/strategies/strategy';\nimport SequentialStrategy from 'core/strategies/sequential_strategy';\nimport BestConnectedEverStrategy from 'core/strategies/best_connected_ever_strategy';\nimport WebSocketPrioritizedCachedStrategy, {\n TransportStrategyDictionary\n} from 'core/strategies/websocket_prioritized_cached_strategy';\nimport DelayedStrategy from 'core/strategies/delayed_strategy';\nimport IfStrategy from 'core/strategies/if_strategy';\nimport FirstConnectedStrategy from 'core/strategies/first_connected_strategy';\nimport { Config } from 'core/config';\nimport StrategyOptions from 'core/strategies/strategy_options';\n\nfunction testSupportsStrategy(strategy: Strategy) {\n return function() {\n return strategy.isSupported();\n };\n}\n\nvar getDefaultStrategy = function(\n config: Config,\n baseOptions: StrategyOptions,\n defineTransport: Function\n): Strategy {\n var definedTransports = {};\n\n function defineTransportStrategy(\n name: string,\n type: string,\n priority: number,\n options: StrategyOptions,\n manager?: TransportManager\n ) {\n var transport = defineTransport(\n config,\n name,\n type,\n priority,\n options,\n manager\n );\n\n definedTransports[name] = transport;\n\n return transport;\n }\n\n var ws_options: StrategyOptions = Object.assign({}, baseOptions, {\n hostNonTLS: config.wsHost + ':' + config.wsPort,\n hostTLS: config.wsHost + ':' + config.wssPort,\n httpPath: config.wsPath\n });\n var wss_options: StrategyOptions = Collections.extend({}, ws_options, {\n useTLS: true\n });\n var http_options: StrategyOptions = Object.assign({}, baseOptions, {\n hostNonTLS: config.httpHost + ':' + config.httpPort,\n hostTLS: config.httpHost + ':' + config.httpsPort,\n httpPath: config.httpPath\n });\n var timeouts = {\n loop: true,\n timeout: 15000,\n timeoutLimit: 60000\n };\n\n var ws_manager = new TransportManager({\n minPingDelay: 10000,\n maxPingDelay: config.activityTimeout\n });\n var streaming_manager = new TransportManager({\n lives: 2,\n minPingDelay: 10000,\n maxPingDelay: config.activityTimeout\n });\n\n var ws_transport = defineTransportStrategy(\n 'ws',\n 'ws',\n 3,\n ws_options,\n ws_manager\n );\n var wss_transport = defineTransportStrategy(\n 'wss',\n 'ws',\n 3,\n wss_options,\n ws_manager\n );\n var xhr_streaming_transport = defineTransportStrategy(\n 'xhr_streaming',\n 'xhr_streaming',\n 1,\n http_options,\n streaming_manager\n );\n var xhr_polling_transport = defineTransportStrategy(\n 'xhr_polling',\n 'xhr_polling',\n 1,\n http_options\n );\n\n var ws_loop = new SequentialStrategy([ws_transport], timeouts);\n var wss_loop = new SequentialStrategy([wss_transport], timeouts);\n var streaming_loop = new SequentialStrategy(\n [xhr_streaming_transport],\n timeouts\n );\n var polling_loop = new SequentialStrategy([xhr_polling_transport], timeouts);\n\n var http_loop = new SequentialStrategy(\n [\n new IfStrategy(\n testSupportsStrategy(streaming_loop),\n new BestConnectedEverStrategy([\n streaming_loop,\n new DelayedStrategy(polling_loop, { delay: 4000 })\n ]),\n polling_loop\n )\n ],\n timeouts\n );\n\n var wsStrategy;\n if (baseOptions.useTLS) {\n wsStrategy = new BestConnectedEverStrategy([\n ws_loop,\n new DelayedStrategy(http_loop, { delay: 2000 })\n ]);\n } else {\n wsStrategy = new BestConnectedEverStrategy([\n ws_loop,\n new DelayedStrategy(wss_loop, { delay: 2000 }),\n new DelayedStrategy(http_loop, { delay: 5000 })\n ]);\n }\n\n return new WebSocketPrioritizedCachedStrategy(\n new FirstConnectedStrategy(\n new IfStrategy(testSupportsStrategy(ws_transport), wsStrategy, http_loop)\n ),\n definedTransports,\n {\n ttl: 1800000,\n timeline: baseOptions.timeline,\n useTLS: baseOptions.useTLS\n }\n );\n};\n\nexport default getDefaultStrategy;\n","import Runtime from 'runtime';\nimport RequestHooks from './request_hooks';\nimport Ajax from './ajax';\nimport { default as EventsDispatcher } from '../events/dispatcher';\n\nconst MAX_BUFFER_LENGTH = 256 * 1024;\n\nexport default class HTTPRequest extends EventsDispatcher {\n hooks: RequestHooks;\n method: string;\n url: string;\n position: number;\n xhr: Ajax;\n unloader: Function;\n\n constructor(hooks: RequestHooks, method: string, url: string) {\n super();\n this.hooks = hooks;\n this.method = method;\n this.url = url;\n }\n\n start(payload?: any) {\n this.position = 0;\n this.xhr = this.hooks.getRequest(this);\n\n this.unloader = () => {\n this.close();\n };\n Runtime.addUnloadListener(this.unloader);\n\n this.xhr.open(this.method, this.url, true);\n\n if (this.xhr.setRequestHeader) {\n this.xhr.setRequestHeader('Content-Type', 'application/json'); // ReactNative doesn't set this header by default.\n }\n this.xhr.send(payload);\n }\n\n close() {\n if (this.unloader) {\n Runtime.removeUnloadListener(this.unloader);\n this.unloader = null;\n }\n if (this.xhr) {\n this.hooks.abortRequest(this.xhr);\n this.xhr = null;\n }\n }\n\n onChunk(status: number, data: any) {\n while (true) {\n var chunk = this.advanceBuffer(data);\n if (chunk) {\n this.emit('chunk', { status: status, data: chunk });\n } else {\n break;\n }\n }\n if (this.isBufferTooLong(data)) {\n this.emit('buffer_too_long');\n }\n }\n\n private advanceBuffer(buffer: any[]): any {\n var unreadData = buffer.slice(this.position);\n var endOfLinePosition = unreadData.indexOf('\\n');\n\n if (endOfLinePosition !== -1) {\n this.position += endOfLinePosition + 1;\n return unreadData.slice(0, endOfLinePosition);\n } else {\n // chunk is not finished yet, don't move the buffer pointer\n return null;\n }\n }\n\n private isBufferTooLong(buffer: any): boolean {\n return this.position === buffer.length && buffer.length > MAX_BUFFER_LENGTH;\n }\n}\n","enum State {\n CONNECTING = 0,\n OPEN = 1,\n CLOSED = 3\n}\n\nexport default State;\n","import URLLocation from './url_location';\nimport State from './state';\nimport Socket from '../socket';\nimport SocketHooks from './socket_hooks';\nimport Util from '../util';\nimport Ajax from './ajax';\nimport HTTPRequest from './http_request';\nimport Runtime from 'runtime';\n\nvar autoIncrement = 1;\n\nclass HTTPSocket implements Socket {\n hooks: SocketHooks;\n session: string;\n location: URLLocation;\n readyState: State;\n stream: HTTPRequest;\n\n onopen: () => void;\n onerror: (error: any) => void;\n onclose: (closeEvent: any) => void;\n onmessage: (message: any) => void;\n onactivity: () => void;\n\n constructor(hooks: SocketHooks, url: string) {\n this.hooks = hooks;\n this.session = randomNumber(1000) + '/' + randomString(8);\n this.location = getLocation(url);\n this.readyState = State.CONNECTING;\n this.openStream();\n }\n\n send(payload: any) {\n return this.sendRaw(JSON.stringify([payload]));\n }\n\n ping() {\n this.hooks.sendHeartbeat(this);\n }\n\n close(code: any, reason: any) {\n this.onClose(code, reason, true);\n }\n\n /** For internal use only */\n sendRaw(payload: any): boolean {\n if (this.readyState === State.OPEN) {\n try {\n Runtime.createSocketRequest(\n 'POST',\n getUniqueURL(getSendURL(this.location, this.session))\n ).start(payload);\n return true;\n } catch (e) {\n return false;\n }\n } else {\n return false;\n }\n }\n\n /** For internal use only */\n reconnect() {\n this.closeStream();\n this.openStream();\n }\n\n /** For internal use only */\n onClose(code, reason, wasClean) {\n this.closeStream();\n this.readyState = State.CLOSED;\n if (this.onclose) {\n this.onclose({\n code: code,\n reason: reason,\n wasClean: wasClean\n });\n }\n }\n\n private onChunk(chunk) {\n if (chunk.status !== 200) {\n return;\n }\n if (this.readyState === State.OPEN) {\n this.onActivity();\n }\n\n var payload;\n var type = chunk.data.slice(0, 1);\n switch (type) {\n case 'o':\n payload = JSON.parse(chunk.data.slice(1) || '{}');\n this.onOpen(payload);\n break;\n case 'a':\n payload = JSON.parse(chunk.data.slice(1) || '[]');\n for (var i = 0; i < payload.length; i++) {\n this.onEvent(payload[i]);\n }\n break;\n case 'm':\n payload = JSON.parse(chunk.data.slice(1) || 'null');\n this.onEvent(payload);\n break;\n case 'h':\n this.hooks.onHeartbeat(this);\n break;\n case 'c':\n payload = JSON.parse(chunk.data.slice(1) || '[]');\n this.onClose(payload[0], payload[1], true);\n break;\n }\n }\n\n private onOpen(options) {\n if (this.readyState === State.CONNECTING) {\n if (options && options.hostname) {\n this.location.base = replaceHost(this.location.base, options.hostname);\n }\n this.readyState = State.OPEN;\n\n if (this.onopen) {\n this.onopen();\n }\n } else {\n this.onClose(1006, 'Server lost session', true);\n }\n }\n\n private onEvent(event) {\n if (this.readyState === State.OPEN && this.onmessage) {\n this.onmessage({ data: event });\n }\n }\n\n private onActivity() {\n if (this.onactivity) {\n this.onactivity();\n }\n }\n\n private onError(error) {\n if (this.onerror) {\n this.onerror(error);\n }\n }\n\n private openStream() {\n this.stream = Runtime.createSocketRequest(\n 'POST',\n getUniqueURL(this.hooks.getReceiveURL(this.location, this.session))\n );\n\n this.stream.bind('chunk', chunk => {\n this.onChunk(chunk);\n });\n this.stream.bind('finished', status => {\n this.hooks.onFinished(this, status);\n });\n this.stream.bind('buffer_too_long', () => {\n this.reconnect();\n });\n\n try {\n this.stream.start();\n } catch (error) {\n Util.defer(() => {\n this.onError(error);\n this.onClose(1006, 'Could not start streaming', false);\n });\n }\n }\n\n private closeStream() {\n if (this.stream) {\n this.stream.unbind_all();\n this.stream.close();\n this.stream = null;\n }\n }\n}\n\nfunction getLocation(url): URLLocation {\n var parts = /([^\\?]*)\\/*(\\??.*)/.exec(url);\n return {\n base: parts[1],\n queryString: parts[2]\n };\n}\n\nfunction getSendURL(url: URLLocation, session: string): string {\n return url.base + '/' + session + '/xhr_send';\n}\n\nfunction getUniqueURL(url: string): string {\n var separator = url.indexOf('?') === -1 ? '?' : '&';\n return url + separator + 't=' + +new Date() + '&n=' + autoIncrement++;\n}\n\nfunction replaceHost(url: string, hostname: string): string {\n var urlParts = /(https?:\\/\\/)([^\\/:]+)((\\/|:)?.*)/.exec(url);\n return urlParts[1] + hostname + urlParts[3];\n}\n\nfunction randomNumber(max: number): number {\n return Runtime.randomInt(max);\n}\n\nfunction randomString(length: number): string {\n var result = [];\n\n for (var i = 0; i < length; i++) {\n result.push(randomNumber(32).toString(32));\n }\n\n return result.join('');\n}\n\nexport default HTTPSocket;\n","import SocketHooks from './socket_hooks';\nimport HTTPSocket from './http_socket';\n\nvar hooks: SocketHooks = {\n getReceiveURL: function(url, session) {\n return url.base + '/' + session + '/xhr_streaming' + url.queryString;\n },\n onHeartbeat: function(socket) {\n socket.sendRaw('[]');\n },\n sendHeartbeat: function(socket) {\n socket.sendRaw('[]');\n },\n onFinished: function(socket, status) {\n socket.onClose(1006, 'Connection interrupted (' + status + ')', false);\n }\n};\n\nexport default hooks;\n","import SocketHooks from './socket_hooks';\nimport URLLocation from './url_location';\nimport HTTPSocket from './http_socket';\n\nvar hooks: SocketHooks = {\n getReceiveURL: function(url: URLLocation, session: string): string {\n return url.base + '/' + session + '/xhr' + url.queryString;\n },\n onHeartbeat: function() {\n // next HTTP request will reset server's activity timer\n },\n sendHeartbeat: function(socket) {\n socket.sendRaw('[]');\n },\n onFinished: function(socket, status) {\n if (status === 200) {\n socket.reconnect();\n } else {\n socket.onClose(1006, 'Connection interrupted (' + status + ')', false);\n }\n }\n};\n\nexport default hooks;\n","import HTTPRequest from 'core/http/http_request';\nimport RequestHooks from 'core/http/request_hooks';\nimport Ajax from 'core/http/ajax';\nimport Runtime from 'runtime';\n\nvar hooks: RequestHooks = {\n getRequest: function(socket: HTTPRequest): Ajax {\n var Constructor = Runtime.getXHRAPI();\n var xhr = new Constructor();\n xhr.onreadystatechange = xhr.onprogress = function() {\n switch (xhr.readyState) {\n case 3:\n if (xhr.responseText && xhr.responseText.length > 0) {\n socket.onChunk(xhr.status, xhr.responseText);\n }\n break;\n case 4:\n // this happens only on errors, never after calling close\n if (xhr.responseText && xhr.responseText.length > 0) {\n socket.onChunk(xhr.status, xhr.responseText);\n }\n socket.emit('finished', xhr.status);\n socket.close();\n break;\n }\n };\n return xhr;\n },\n abortRequest: function(xhr: Ajax) {\n xhr.onreadystatechange = null;\n xhr.abort();\n }\n};\n\nexport default hooks;\n","import * as Collections from 'core/utils/collections';\nimport Transports from 'isomorphic/transports/transports';\nimport TimelineSender from 'core/timeline/timeline_sender';\nimport Ajax from 'core/http/ajax';\nimport getDefaultStrategy from './default_strategy';\nimport TransportsTable from 'core/transports/transports_table';\nimport transportConnectionInitializer from './transports/transport_connection_initializer';\nimport HTTPFactory from './http/http';\n\nvar Isomorphic: any = {\n getDefaultStrategy,\n Transports: Transports,\n transportConnectionInitializer,\n HTTPFactory,\n\n setup(PusherClass): void {\n PusherClass.ready();\n },\n\n getLocalStorage(): any {\n return undefined;\n },\n\n getClientFeatures(): any[] {\n return Collections.keys(\n Collections.filterObject({ ws: Transports.ws }, function(t) {\n return t.isSupported({});\n })\n );\n },\n\n getProtocol(): string {\n return 'http:';\n },\n\n isXHRSupported(): boolean {\n return true;\n },\n\n createSocketRequest(method: string, url: string) {\n if (this.isXHRSupported()) {\n return this.HTTPFactory.createXHR(method, url);\n } else {\n throw 'Cross-origin HTTP requests are not supported';\n }\n },\n\n createXHR(): Ajax {\n var Constructor = this.getXHRAPI();\n return new Constructor();\n },\n\n createWebSocket(url: string): any {\n var Constructor = this.getWebSocketAPI();\n return new Constructor(url);\n },\n\n addUnloadListener(listener: any) {},\n removeUnloadListener(listener: any) {}\n};\n\nexport default Isomorphic;\n","/** Initializes the transport.\n *\n * Fetches resources if needed and then transitions to initialized.\n */\nexport default function() {\n var self = this;\n\n self.timeline.info(\n self.buildTimelineMessage({\n transport: self.name + (self.options.useTLS ? 's' : '')\n })\n );\n\n if (self.hooks.isInitialized()) {\n self.changeState('initialized');\n } else {\n self.onClose();\n }\n}\n","import HTTPRequest from 'core/http/http_request';\nimport HTTPSocket from 'core/http/http_socket';\nimport SocketHooks from 'core/http/socket_hooks';\nimport RequestHooks from 'core/http/request_hooks';\nimport streamingHooks from 'core/http/http_streaming_socket';\nimport pollingHooks from 'core/http/http_polling_socket';\nimport xhrHooks from './http_xhr_request';\nimport HTTPFactory from 'core/http/http_factory';\n\nvar HTTP: HTTPFactory = {\n createStreamingSocket(url: string): HTTPSocket {\n return this.createSocket(streamingHooks, url);\n },\n\n createPollingSocket(url: string): HTTPSocket {\n return this.createSocket(pollingHooks, url);\n },\n\n createSocket(hooks: SocketHooks, url: string): HTTPSocket {\n return new HTTPSocket(hooks, url);\n },\n\n createXHR(method: string, url: string): HTTPRequest {\n return this.createRequest(xhrHooks, method, url);\n },\n\n createRequest(hooks: RequestHooks, method: string, url: string): HTTPRequest {\n return new HTTPRequest(hooks, method, url);\n }\n};\n\nexport default HTTP;\n","import { default as EventsDispatcher } from 'core/events/dispatcher';\nimport Reachability from 'core/reachability';\n\nexport class NetInfo extends EventsDispatcher implements Reachability {\n isOnline(): boolean {\n return true;\n }\n}\n\nexport var Network = new NetInfo();\n","import AbstractRuntime from 'runtimes/interface';\nimport { AuthTransport } from 'core/auth/auth_transports';\nimport {\n AuthRequestType,\n AuthTransportCallback,\n InternalAuthOptions\n} from 'core/auth/options';\nimport { HTTPAuthError } from 'core/errors';\n\nvar fetchAuth: AuthTransport = function(\n context: AbstractRuntime,\n query: string,\n authOptions: InternalAuthOptions,\n authRequestType: AuthRequestType,\n callback: AuthTransportCallback\n) {\n var headers = new Headers();\n headers.set('Content-Type', 'application/x-www-form-urlencoded');\n\n for (var headerName in authOptions.headers) {\n headers.set(headerName, authOptions.headers[headerName]);\n }\n\n if (authOptions.headersProvider != null) {\n const dynamicHeaders = authOptions.headersProvider();\n for (var headerName in dynamicHeaders) {\n headers.set(headerName, dynamicHeaders[headerName]);\n }\n }\n\n var body = query;\n var request = new Request(authOptions.endpoint, {\n headers,\n body,\n credentials: 'same-origin',\n method: 'POST'\n });\n\n return fetch(request)\n .then(response => {\n let { status } = response;\n if (status === 200) {\n // manually parse the json so we can provide a more helpful error in\n // failure case\n return response.text();\n }\n throw new HTTPAuthError(\n status,\n `Could not get ${authRequestType.toString()} info from your auth endpoint, status: ${status}`\n );\n })\n .then(data => {\n let parsedData;\n try {\n parsedData = JSON.parse(data);\n } catch (e) {\n throw new HTTPAuthError(\n 200,\n `JSON returned from ${authRequestType.toString()} endpoint was invalid, yet status code was 200. Data was: ${data}`\n );\n }\n callback(null, parsedData);\n })\n .catch(err => {\n callback(err, null);\n });\n};\n\nexport default fetchAuth;\n","import Logger from 'core/logger';\nimport TimelineSender from 'core/timeline/timeline_sender';\nimport * as Collections from 'core/utils/collections';\nimport Util from 'core/util';\nimport Runtime from 'runtime';\nimport TimelineTransport from 'core/timeline/timeline_transport';\n\nvar getAgent = function(sender: TimelineSender, useTLS: boolean) {\n return function(data: any, callback: Function) {\n var scheme = 'http' + (useTLS ? 's' : '') + '://';\n var url =\n scheme + (sender.host || sender.options.host) + sender.options.path;\n var query = Collections.buildQueryString(data);\n url += '/' + 2 + '?' + query;\n\n fetch(url)\n .then(response => {\n if (response.status !== 200) {\n throw `received ${response.status} from stats.pusher.com`;\n }\n return response.json();\n })\n .then(({ host }) => {\n if (host) {\n sender.host = host;\n }\n })\n .catch(err => {\n Logger.debug('TimelineSender Error: ', err);\n });\n };\n};\n\nvar fetchTimeline = {\n name: 'xhr',\n getAgent\n};\n\nexport default fetchTimeline;\n","import Isomorphic from 'isomorphic/runtime';\nimport Runtime from '../interface';\nimport { Network } from './net_info';\nimport fetchAuth from './auth/fetch_auth';\nimport { AuthTransports } from 'core/auth/auth_transports';\nimport fetchTimeline from './timeline/fetch_timeline';\n\n// Very verbose but until unavoidable until\n// TypeScript 2.1, when spread attributes will be\n// supported\nconst {\n getDefaultStrategy,\n Transports,\n setup,\n getProtocol,\n isXHRSupported,\n getLocalStorage,\n createXHR,\n createWebSocket,\n addUnloadListener,\n removeUnloadListener,\n transportConnectionInitializer,\n createSocketRequest,\n HTTPFactory\n} = Isomorphic;\n\nconst Worker: Runtime = {\n getDefaultStrategy,\n Transports,\n setup,\n getProtocol,\n isXHRSupported,\n getLocalStorage,\n createXHR,\n createWebSocket,\n addUnloadListener,\n removeUnloadListener,\n transportConnectionInitializer,\n createSocketRequest,\n HTTPFactory,\n\n TimelineTransport: fetchTimeline,\n\n getAuthorizers(): AuthTransports {\n return { ajax: fetchAuth };\n },\n\n getWebSocketAPI() {\n return WebSocket;\n },\n\n getXHRAPI() {\n return XMLHttpRequest;\n },\n\n getNetwork() {\n return Network;\n },\n\n randomInt(max: number): number {\n /**\n * Return values in the range of [0, 1[\n */\n const random = function() {\n const crypto = globalThis.crypto || globalThis['msCrypto'];\n const random = crypto.getRandomValues(new Uint32Array(1))[0];\n\n return random / 2 ** 32;\n };\n\n return Math.floor(random() * max);\n }\n};\n\nexport default Worker;\n","enum TimelineLevel {\n ERROR = 3,\n INFO = 6,\n DEBUG = 7\n}\n\nexport default TimelineLevel;\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport { default as Level } from './level';\n\nexport interface TimelineOptions {\n level?: Level;\n limit?: number;\n version?: string;\n cluster?: string;\n features?: string[];\n params?: any;\n}\n\nexport default class Timeline {\n key: string;\n session: number;\n events: any[];\n options: TimelineOptions;\n sent: number;\n uniqueID: number;\n\n constructor(key: string, session: number, options: TimelineOptions) {\n this.key = key;\n this.session = session;\n this.events = [];\n this.options = options || {};\n this.sent = 0;\n this.uniqueID = 0;\n }\n\n log(level, event) {\n if (level <= this.options.level) {\n this.events.push(\n Collections.extend({}, event, { timestamp: Util.now() })\n );\n if (this.options.limit && this.events.length > this.options.limit) {\n this.events.shift();\n }\n }\n }\n\n error(event) {\n this.log(Level.ERROR, event);\n }\n\n info(event) {\n this.log(Level.INFO, event);\n }\n\n debug(event) {\n this.log(Level.DEBUG, event);\n }\n\n isEmpty() {\n return this.events.length === 0;\n }\n\n send(sendfn, callback) {\n var data = Collections.extend(\n {\n session: this.session,\n bundle: this.sent + 1,\n key: this.key,\n lib: 'js',\n version: this.options.version,\n cluster: this.options.cluster,\n features: this.options.features,\n timeline: this.events\n },\n this.options.params\n );\n\n this.events = [];\n sendfn(data, (error, result) => {\n if (!error) {\n this.sent++;\n }\n if (callback) {\n callback(error, result);\n }\n });\n\n return true;\n }\n\n generateUniqueID(): number {\n this.uniqueID++;\n return this.uniqueID;\n }\n}\n","import Factory from '../utils/factory';\nimport Util from '../util';\nimport * as Errors from '../errors';\nimport * as Collections from '../utils/collections';\nimport Strategy from './strategy';\nimport Transport from '../transports/transport';\nimport StrategyOptions from './strategy_options';\nimport Handshake from '../connection/handshake';\n\n/** Provides a strategy interface for transports.\n *\n * @param {String} name\n * @param {Number} priority\n * @param {Class} transport\n * @param {Object} options\n */\nexport default class TransportStrategy implements Strategy {\n name: string;\n priority: number;\n transport: Transport;\n options: StrategyOptions;\n\n constructor(\n name: string,\n priority: number,\n transport: Transport,\n options: StrategyOptions\n ) {\n this.name = name;\n this.priority = priority;\n this.transport = transport;\n this.options = options || {};\n }\n\n /** Returns whether the transport is supported in the browser.\n *\n * @returns {Boolean}\n */\n isSupported(): boolean {\n return this.transport.isSupported({\n useTLS: this.options.useTLS\n });\n }\n\n /** Launches a connection attempt and returns a strategy runner.\n *\n * @param {Function} callback\n * @return {Object} strategy runner\n */\n connect(minPriority: number, callback: Function) {\n if (!this.isSupported()) {\n return failAttempt(new Errors.UnsupportedStrategy(), callback);\n } else if (this.priority < minPriority) {\n return failAttempt(new Errors.TransportPriorityTooLow(), callback);\n }\n\n var connected = false;\n var transport = this.transport.createConnection(\n this.name,\n this.priority,\n this.options.key,\n this.options\n );\n var handshake = null;\n\n var onInitialized = function() {\n transport.unbind('initialized', onInitialized);\n transport.connect();\n };\n var onOpen = function() {\n handshake = Factory.createHandshake(transport, function(result) {\n connected = true;\n unbindListeners();\n callback(null, result);\n });\n };\n var onError = function(error) {\n unbindListeners();\n callback(error);\n };\n var onClosed = function() {\n unbindListeners();\n var serializedTransport;\n\n // The reason for this try/catch block is that on React Native\n // the WebSocket object is circular. Therefore transport.socket will\n // throw errors upon stringification. Collections.safeJSONStringify\n // discards circular references when serializing.\n serializedTransport = Collections.safeJSONStringify(transport);\n callback(new Errors.TransportClosed(serializedTransport));\n };\n\n var unbindListeners = function() {\n transport.unbind('initialized', onInitialized);\n transport.unbind('open', onOpen);\n transport.unbind('error', onError);\n transport.unbind('closed', onClosed);\n };\n\n transport.bind('initialized', onInitialized);\n transport.bind('open', onOpen);\n transport.bind('error', onError);\n transport.bind('closed', onClosed);\n\n // connect will be called automatically after initialization\n transport.initialize();\n\n return {\n abort: () => {\n if (connected) {\n return;\n }\n unbindListeners();\n if (handshake) {\n handshake.close();\n } else {\n transport.close();\n }\n },\n forceMinPriority: p => {\n if (connected) {\n return;\n }\n if (this.priority < p) {\n if (handshake) {\n handshake.close();\n } else {\n transport.close();\n }\n }\n }\n };\n }\n}\n\nfunction failAttempt(error: Error, callback: Function) {\n Util.defer(function() {\n callback(error);\n });\n return {\n abort: function() {},\n forceMinPriority: function() {}\n };\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport TransportManager from '../transports/transport_manager';\nimport * as Errors from '../errors';\nimport Strategy from './strategy';\nimport TransportStrategy from './transport_strategy';\nimport StrategyOptions from '../strategies/strategy_options';\nimport { Config } from '../config';\nimport Runtime from 'runtime';\n\nconst { Transports } = Runtime;\n\nexport var defineTransport = function(\n config: Config,\n name: string,\n type: string,\n priority: number,\n options: StrategyOptions,\n manager?: TransportManager\n): Strategy {\n var transportClass = Transports[type];\n if (!transportClass) {\n throw new Errors.UnsupportedTransport(type);\n }\n\n var enabled =\n (!config.enabledTransports ||\n Collections.arrayIndexOf(config.enabledTransports, name) !== -1) &&\n (!config.disabledTransports ||\n Collections.arrayIndexOf(config.disabledTransports, name) === -1);\n\n var transport;\n if (enabled) {\n options = Object.assign(\n { ignoreNullOrigin: config.ignoreNullOrigin },\n options\n );\n\n transport = new TransportStrategy(\n name,\n priority,\n manager ? manager.getAssistant(transportClass) : transportClass,\n options\n );\n } else {\n transport = UnsupportedStrategy;\n }\n\n return transport;\n};\n\nvar UnsupportedStrategy: Strategy = {\n isSupported: function() {\n return false;\n },\n connect: function(_, callback) {\n var deferred = Util.defer(function() {\n callback(new Errors.UnsupportedStrategy());\n });\n return {\n abort: function() {\n deferred.ensureAborted();\n },\n forceMinPriority: function() {}\n };\n }\n};\n","export enum AuthRequestType {\n UserAuthentication = 'user-authentication',\n ChannelAuthorization = 'channel-authorization'\n}\n\nexport interface ChannelAuthorizationData {\n auth: string;\n channel_data?: string;\n shared_secret?: string;\n}\n\nexport type ChannelAuthorizationCallback = (\n error: Error | null,\n authData: ChannelAuthorizationData | null\n) => void;\n\nexport interface ChannelAuthorizationRequestParams {\n socketId: string;\n channelName: string;\n}\n\nexport interface ChannelAuthorizationHandler {\n (\n params: ChannelAuthorizationRequestParams,\n callback: ChannelAuthorizationCallback\n ): void;\n}\n\nexport interface UserAuthenticationData {\n auth: string;\n user_data: string;\n}\n\nexport type UserAuthenticationCallback = (\n error: Error | null,\n authData: UserAuthenticationData | null\n) => void;\n\nexport interface UserAuthenticationRequestParams {\n socketId: string;\n}\n\nexport interface UserAuthenticationHandler {\n (\n params: UserAuthenticationRequestParams,\n callback: UserAuthenticationCallback\n ): void;\n}\n\nexport type AuthTransportCallback =\n | ChannelAuthorizationCallback\n | UserAuthenticationCallback;\n\nexport interface AuthOptionsT {\n transport: 'ajax' | 'jsonp';\n endpoint: string;\n params?: any;\n headers?: any;\n paramsProvider?: () => any;\n headersProvider?: () => any;\n customHandler?: AuthHandler;\n}\n\nexport declare type UserAuthenticationOptions = AuthOptionsT<\n UserAuthenticationHandler\n>;\nexport declare type ChannelAuthorizationOptions = AuthOptionsT<\n ChannelAuthorizationHandler\n>;\n\nexport interface InternalAuthOptions {\n transport: 'ajax' | 'jsonp';\n endpoint: string;\n params?: any;\n headers?: any;\n paramsProvider?: () => any;\n headersProvider?: () => any;\n}\n","import ConnectionManager from './connection/connection_manager';\nimport {\n ChannelAuthorizationOptions,\n UserAuthenticationOptions\n} from './auth/options';\nimport {\n ChannelAuthorizerGenerator,\n DeprecatedAuthOptions\n} from './auth/deprecated_channel_authorizer';\nimport { AuthTransport, Transport } from './config';\nimport * as nacl from 'tweetnacl';\nimport Logger from './logger';\n\nexport interface Options {\n activityTimeout?: number;\n\n auth?: DeprecatedAuthOptions; // DEPRECATED use channelAuthorization instead\n authEndpoint?: string; // DEPRECATED use channelAuthorization instead\n authTransport?: AuthTransport; // DEPRECATED use channelAuthorization instead\n authorizer?: ChannelAuthorizerGenerator; // DEPRECATED use channelAuthorization instead\n\n channelAuthorization?: ChannelAuthorizationOptions;\n userAuthentication?: UserAuthenticationOptions;\n\n cluster: string;\n enableStats?: boolean;\n disableStats?: boolean;\n disabledTransports?: Transport[];\n enabledTransports?: Transport[];\n forceTLS?: boolean;\n httpHost?: string;\n httpPath?: string;\n httpPort?: number;\n httpsPort?: number;\n ignoreNullOrigin?: boolean;\n nacl?: nacl;\n pongTimeout?: number;\n statsHost?: string;\n timelineParams?: any;\n unavailableTimeout?: number;\n wsHost?: string;\n wsPath?: string;\n wsPort?: number;\n wssPort?: number;\n}\n\nexport interface ClusterOptions {\n appKey: string;\n cluster: string;\n}\n\nexport function validateOptions(options) {\n if (options == null) {\n throw 'You must pass an options object';\n }\n if (options.cluster == null) {\n throw 'Options object must provide a cluster';\n }\n if ('disableStats' in options) {\n Logger.warn(\n 'The disableStats option is deprecated in favor of enableStats'\n );\n }\n}\n","import {\n UserAuthenticationCallback,\n InternalAuthOptions,\n UserAuthenticationHandler,\n UserAuthenticationRequestParams,\n AuthRequestType\n} from './options';\n\nimport Runtime from 'runtime';\n\nconst composeChannelQuery = (\n params: UserAuthenticationRequestParams,\n authOptions: InternalAuthOptions\n) => {\n var query = 'socket_id=' + encodeURIComponent(params.socketId);\n\n for (var key in authOptions.params) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(authOptions.params[key]);\n }\n\n if (authOptions.paramsProvider != null) {\n let dynamicParams = authOptions.paramsProvider();\n for (var key in dynamicParams) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(dynamicParams[key]);\n }\n }\n\n return query;\n};\n\nconst UserAuthenticator = (\n authOptions: InternalAuthOptions\n): UserAuthenticationHandler => {\n if (typeof Runtime.getAuthorizers()[authOptions.transport] === 'undefined') {\n throw `'${authOptions.transport}' is not a recognized auth transport`;\n }\n\n return (\n params: UserAuthenticationRequestParams,\n callback: UserAuthenticationCallback\n ) => {\n const query = composeChannelQuery(params, authOptions);\n\n Runtime.getAuthorizers()[authOptions.transport](\n Runtime,\n query,\n authOptions,\n AuthRequestType.UserAuthentication,\n callback\n );\n };\n};\n\nexport default UserAuthenticator;\n","import {\n AuthRequestType,\n InternalAuthOptions,\n ChannelAuthorizationHandler,\n ChannelAuthorizationRequestParams,\n ChannelAuthorizationCallback\n} from './options';\n\nimport Runtime from 'runtime';\n\nconst composeChannelQuery = (\n params: ChannelAuthorizationRequestParams,\n authOptions: InternalAuthOptions\n) => {\n var query = 'socket_id=' + encodeURIComponent(params.socketId);\n\n query += '&channel_name=' + encodeURIComponent(params.channelName);\n\n for (var key in authOptions.params) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(authOptions.params[key]);\n }\n\n if (authOptions.paramsProvider != null) {\n let dynamicParams = authOptions.paramsProvider();\n for (var key in dynamicParams) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(dynamicParams[key]);\n }\n }\n\n return query;\n};\n\nconst ChannelAuthorizer = (\n authOptions: InternalAuthOptions\n): ChannelAuthorizationHandler => {\n if (typeof Runtime.getAuthorizers()[authOptions.transport] === 'undefined') {\n throw `'${authOptions.transport}' is not a recognized auth transport`;\n }\n\n return (\n params: ChannelAuthorizationRequestParams,\n callback: ChannelAuthorizationCallback\n ) => {\n const query = composeChannelQuery(params, authOptions);\n\n Runtime.getAuthorizers()[authOptions.transport](\n Runtime,\n query,\n authOptions,\n AuthRequestType.ChannelAuthorization,\n callback\n );\n };\n};\n\nexport default ChannelAuthorizer;\n","import { Options } from './options';\nimport Defaults from './defaults';\nimport {\n ChannelAuthorizationHandler,\n UserAuthenticationHandler,\n ChannelAuthorizationOptions\n} from './auth/options';\nimport UserAuthenticator from './auth/user_authenticator';\nimport ChannelAuthorizer from './auth/channel_authorizer';\nimport { ChannelAuthorizerProxy } from './auth/deprecated_channel_authorizer';\nimport Runtime from 'runtime';\nimport * as nacl from 'tweetnacl';\n\nexport type AuthTransport = 'ajax' | 'jsonp';\nexport type Transport =\n | 'ws'\n | 'wss'\n | 'xhr_streaming'\n | 'xhr_polling'\n | 'sockjs';\n\nexport interface Config {\n // these are all 'required' config parameters, it's not necessary for the user\n // to set them, but they have configured defaults.\n activityTimeout: number;\n enableStats: boolean;\n httpHost: string;\n httpPath: string;\n httpPort: number;\n httpsPort: number;\n pongTimeout: number;\n statsHost: string;\n unavailableTimeout: number;\n useTLS: boolean;\n wsHost: string;\n wsPath: string;\n wsPort: number;\n wssPort: number;\n userAuthenticator: UserAuthenticationHandler;\n channelAuthorizer: ChannelAuthorizationHandler;\n\n // these are all optional parameters or overrrides. The customer can set these\n // but it's not strictly necessary\n forceTLS?: boolean;\n cluster?: string;\n disabledTransports?: Transport[];\n enabledTransports?: Transport[];\n ignoreNullOrigin?: boolean;\n nacl?: nacl;\n timelineParams?: any;\n}\n\n// getConfig mainly sets the defaults for the options that are not provided\nexport function getConfig(opts: Options, pusher): Config {\n let config: Config = {\n activityTimeout: opts.activityTimeout || Defaults.activityTimeout,\n cluster: opts.cluster,\n httpPath: opts.httpPath || Defaults.httpPath,\n httpPort: opts.httpPort || Defaults.httpPort,\n httpsPort: opts.httpsPort || Defaults.httpsPort,\n pongTimeout: opts.pongTimeout || Defaults.pongTimeout,\n statsHost: opts.statsHost || Defaults.stats_host,\n unavailableTimeout: opts.unavailableTimeout || Defaults.unavailableTimeout,\n wsPath: opts.wsPath || Defaults.wsPath,\n wsPort: opts.wsPort || Defaults.wsPort,\n wssPort: opts.wssPort || Defaults.wssPort,\n\n enableStats: getEnableStatsConfig(opts),\n httpHost: getHttpHost(opts),\n useTLS: shouldUseTLS(opts),\n wsHost: getWebsocketHost(opts),\n\n userAuthenticator: buildUserAuthenticator(opts),\n channelAuthorizer: buildChannelAuthorizer(opts, pusher)\n };\n\n if ('disabledTransports' in opts)\n config.disabledTransports = opts.disabledTransports;\n if ('enabledTransports' in opts)\n config.enabledTransports = opts.enabledTransports;\n if ('ignoreNullOrigin' in opts)\n config.ignoreNullOrigin = opts.ignoreNullOrigin;\n if ('timelineParams' in opts) config.timelineParams = opts.timelineParams;\n if ('nacl' in opts) {\n config.nacl = opts.nacl;\n }\n\n return config;\n}\n\nfunction getHttpHost(opts: Options): string {\n if (opts.httpHost) {\n return opts.httpHost;\n }\n if (opts.cluster) {\n return `sockjs-${opts.cluster}.pusher.com`;\n }\n return Defaults.httpHost;\n}\n\nfunction getWebsocketHost(opts: Options): string {\n if (opts.wsHost) {\n return opts.wsHost;\n }\n return getWebsocketHostFromCluster(opts.cluster);\n}\n\nfunction getWebsocketHostFromCluster(cluster: string): string {\n return `ws-${cluster}.pusher.com`;\n}\n\nfunction shouldUseTLS(opts: Options): boolean {\n if (Runtime.getProtocol() === 'https:') {\n return true;\n } else if (opts.forceTLS === false) {\n return false;\n }\n return true;\n}\n\n// if enableStats is set take the value\n// if disableStats is set take the inverse\n// otherwise default to false\nfunction getEnableStatsConfig(opts: Options): boolean {\n if ('enableStats' in opts) {\n return opts.enableStats;\n }\n if ('disableStats' in opts) {\n return !opts.disableStats;\n }\n return false;\n}\n\nfunction buildUserAuthenticator(opts: Options): UserAuthenticationHandler {\n const userAuthentication = {\n ...Defaults.userAuthentication,\n ...opts.userAuthentication\n };\n if (\n 'customHandler' in userAuthentication &&\n userAuthentication['customHandler'] != null\n ) {\n return userAuthentication['customHandler'];\n }\n\n return UserAuthenticator(userAuthentication);\n}\n\nfunction buildChannelAuth(opts: Options, pusher): ChannelAuthorizationOptions {\n let channelAuthorization: ChannelAuthorizationOptions;\n if ('channelAuthorization' in opts) {\n channelAuthorization = {\n ...Defaults.channelAuthorization,\n ...opts.channelAuthorization\n };\n } else {\n channelAuthorization = {\n transport: opts.authTransport || Defaults.authTransport,\n endpoint: opts.authEndpoint || Defaults.authEndpoint\n };\n if ('auth' in opts) {\n if ('params' in opts.auth) channelAuthorization.params = opts.auth.params;\n if ('headers' in opts.auth)\n channelAuthorization.headers = opts.auth.headers;\n }\n if ('authorizer' in opts)\n channelAuthorization.customHandler = ChannelAuthorizerProxy(\n pusher,\n channelAuthorization,\n opts.authorizer\n );\n }\n return channelAuthorization;\n}\n\nfunction buildChannelAuthorizer(\n opts: Options,\n pusher\n): ChannelAuthorizationHandler {\n const channelAuthorization = buildChannelAuth(opts, pusher);\n if (\n 'customHandler' in channelAuthorization &&\n channelAuthorization['customHandler'] != null\n ) {\n return channelAuthorization['customHandler'];\n }\n\n return ChannelAuthorizer(channelAuthorization);\n}\n","import Channel from '../channels/channel';\nimport {\n ChannelAuthorizationCallback,\n ChannelAuthorizationHandler,\n ChannelAuthorizationRequestParams,\n InternalAuthOptions\n} from './options';\n\nexport interface DeprecatedChannelAuthorizer {\n authorize(socketId: string, callback: ChannelAuthorizationCallback): void;\n}\n\nexport interface ChannelAuthorizerGenerator {\n (\n channel: Channel,\n options: DeprecatedAuthorizerOptions\n ): DeprecatedChannelAuthorizer;\n}\n\nexport interface DeprecatedAuthOptions {\n params?: any;\n headers?: any;\n}\n\nexport interface DeprecatedAuthorizerOptions {\n authTransport: 'ajax' | 'jsonp';\n authEndpoint: string;\n auth?: DeprecatedAuthOptions;\n}\n\nexport const ChannelAuthorizerProxy = (\n pusher,\n authOptions: InternalAuthOptions,\n channelAuthorizerGenerator: ChannelAuthorizerGenerator\n): ChannelAuthorizationHandler => {\n const deprecatedAuthorizerOptions: DeprecatedAuthorizerOptions = {\n authTransport: authOptions.transport,\n authEndpoint: authOptions.endpoint,\n auth: {\n params: authOptions.params,\n headers: authOptions.headers\n }\n };\n return (\n params: ChannelAuthorizationRequestParams,\n callback: ChannelAuthorizationCallback\n ) => {\n const channel = pusher.channel(params.channelName);\n // This line creates a new channel authorizer every time.\n // In the past, this was only done once per channel and reused.\n // We can do that again if we want to keep this behavior intact.\n const channelAuthorizer: DeprecatedChannelAuthorizer = channelAuthorizerGenerator(\n channel,\n deprecatedAuthorizerOptions\n );\n channelAuthorizer.authorize(params.socketId, callback);\n };\n};\n","import Logger from './logger';\nimport Pusher from './pusher';\nimport EventsDispatcher from './events/dispatcher';\n\nexport default class WatchlistFacade extends EventsDispatcher {\n private pusher: Pusher;\n\n public constructor(pusher: Pusher) {\n super(function(eventName, data) {\n Logger.debug(`No callbacks on watchlist events for ${eventName}`);\n });\n\n this.pusher = pusher;\n this.bindWatchlistInternalEvent();\n }\n\n handleEvent(pusherEvent) {\n pusherEvent.data.events.forEach(watchlistEvent => {\n this.emit(watchlistEvent.name, watchlistEvent);\n });\n }\n\n private bindWatchlistInternalEvent() {\n this.pusher.connection.bind('message', pusherEvent => {\n var eventName = pusherEvent.event;\n if (eventName === 'pusher_internal:watchlist_events') {\n this.handleEvent(pusherEvent);\n }\n });\n }\n}\n","function flatPromise() {\n let resolve, reject;\n const promise = new Promise((res, rej) => {\n resolve = res;\n reject = rej;\n });\n return { promise, resolve, reject };\n}\n\nexport default flatPromise;\n","import Pusher from './pusher';\nimport Logger from './logger';\nimport {\n UserAuthenticationData,\n UserAuthenticationCallback\n} from './auth/options';\nimport Channel from './channels/channel';\nimport WatchlistFacade from './watchlist';\nimport EventsDispatcher from './events/dispatcher';\nimport flatPromise from './utils/flat_promise';\n\nexport default class UserFacade extends EventsDispatcher {\n pusher: Pusher;\n signin_requested: boolean = false;\n user_data: any = null;\n serverToUserChannel: Channel = null;\n signinDonePromise: Promise = null;\n watchlist: WatchlistFacade;\n private _signinDoneResolve: Function = null;\n\n public constructor(pusher: Pusher) {\n super(function(eventName, data) {\n Logger.debug('No callbacks on user for ' + eventName);\n });\n this.pusher = pusher;\n this.pusher.connection.bind('state_change', ({ previous, current }) => {\n if (previous !== 'connected' && current === 'connected') {\n this._signin();\n }\n if (previous === 'connected' && current !== 'connected') {\n this._cleanup();\n this._newSigninPromiseIfNeeded();\n }\n });\n\n this.watchlist = new WatchlistFacade(pusher);\n\n this.pusher.connection.bind('message', event => {\n var eventName = event.event;\n if (eventName === 'pusher:signin_success') {\n this._onSigninSuccess(event.data);\n }\n if (\n this.serverToUserChannel &&\n this.serverToUserChannel.name === event.channel\n ) {\n this.serverToUserChannel.handleEvent(event);\n }\n });\n }\n\n public signin() {\n if (this.signin_requested) {\n return;\n }\n\n this.signin_requested = true;\n this._signin();\n }\n\n private _signin() {\n if (!this.signin_requested) {\n return;\n }\n\n this._newSigninPromiseIfNeeded();\n\n if (this.pusher.connection.state !== 'connected') {\n // Signin will be attempted when the connection is connected\n return;\n }\n\n this.pusher.config.userAuthenticator(\n {\n socketId: this.pusher.connection.socket_id\n },\n this._onAuthorize\n );\n }\n\n private _onAuthorize: UserAuthenticationCallback = (\n err,\n authData: UserAuthenticationData\n ) => {\n if (err) {\n Logger.warn(`Error during signin: ${err}`);\n this._cleanup();\n return;\n }\n\n this.pusher.send_event('pusher:signin', {\n auth: authData.auth,\n user_data: authData.user_data\n });\n\n // Later when we get pusher:singin_success event, the user will be marked as signed in\n };\n\n private _onSigninSuccess(data: any) {\n try {\n this.user_data = JSON.parse(data.user_data);\n } catch (e) {\n Logger.error(`Failed parsing user data after signin: ${data.user_data}`);\n this._cleanup();\n return;\n }\n\n if (typeof this.user_data.id !== 'string' || this.user_data.id === '') {\n Logger.error(\n `user_data doesn't contain an id. user_data: ${this.user_data}`\n );\n this._cleanup();\n return;\n }\n\n // Signin succeeded\n this._signinDoneResolve();\n this._subscribeChannels();\n }\n\n private _subscribeChannels() {\n const ensure_subscribed = channel => {\n if (channel.subscriptionPending && channel.subscriptionCancelled) {\n channel.reinstateSubscription();\n } else if (\n !channel.subscriptionPending &&\n this.pusher.connection.state === 'connected'\n ) {\n channel.subscribe();\n }\n };\n\n this.serverToUserChannel = new Channel(\n `#server-to-user-${this.user_data.id}`,\n this.pusher\n );\n this.serverToUserChannel.bind_global((eventName, data) => {\n if (\n eventName.indexOf('pusher_internal:') === 0 ||\n eventName.indexOf('pusher:') === 0\n ) {\n // ignore internal events\n return;\n }\n this.emit(eventName, data);\n });\n ensure_subscribed(this.serverToUserChannel);\n }\n\n private _cleanup() {\n this.user_data = null;\n if (this.serverToUserChannel) {\n this.serverToUserChannel.unbind_all();\n this.serverToUserChannel.disconnect();\n this.serverToUserChannel = null;\n }\n\n if (this.signin_requested) {\n // If signin is in progress and cleanup is called,\n // Mark the current signin process as done.\n this._signinDoneResolve();\n }\n }\n\n private _newSigninPromiseIfNeeded() {\n if (!this.signin_requested) {\n return;\n }\n\n // If there is a promise and it is not resolved, return without creating a new one.\n if (this.signinDonePromise && !(this.signinDonePromise as any).done) {\n return;\n }\n\n // This promise is never rejected.\n // It gets resolved when the signin process is done whether it failed or succeeded\n const { promise, resolve, reject: _ } = flatPromise();\n (promise as any).done = false;\n const setDone = () => {\n (promise as any).done = true;\n };\n promise.then(setDone).catch(setDone);\n this.signinDonePromise = promise;\n this._signinDoneResolve = resolve;\n }\n}\n","import AbstractRuntime from '../runtimes/interface';\nimport Runtime from 'runtime';\nimport * as Collections from './utils/collections';\nimport Channels from './channels/channels';\nimport Channel from './channels/channel';\nimport { default as EventsDispatcher } from './events/dispatcher';\nimport Timeline from './timeline/timeline';\nimport TimelineSender from './timeline/timeline_sender';\nimport TimelineLevel from './timeline/level';\nimport { defineTransport } from './strategies/strategy_builder';\nimport ConnectionManager from './connection/connection_manager';\nimport { PeriodicTimer } from './utils/timers';\nimport Defaults from './defaults';\nimport Logger from './logger';\nimport Factory from './utils/factory';\nimport { Options, ClusterOptions, validateOptions } from './options';\nimport { Config, getConfig } from './config';\nimport StrategyOptions from './strategies/strategy_options';\nimport UserFacade from './user';\n\nexport default class Pusher {\n /* STATIC PROPERTIES */\n static instances: Pusher[] = [];\n static isReady: boolean = false;\n static logToConsole: boolean = false;\n\n // for jsonp\n static Runtime: AbstractRuntime = Runtime;\n static ScriptReceivers: any = (Runtime).ScriptReceivers;\n static DependenciesReceivers: any = (Runtime).DependenciesReceivers;\n static auth_callbacks: any = (Runtime).auth_callbacks;\n\n static ready() {\n Pusher.isReady = true;\n for (var i = 0, l = Pusher.instances.length; i < l; i++) {\n Pusher.instances[i].connect();\n }\n }\n\n static log: (message: any) => void;\n\n private static getClientFeatures(): string[] {\n return Collections.keys(\n Collections.filterObject({ ws: Runtime.Transports.ws }, function(t) {\n return t.isSupported({});\n })\n );\n }\n\n /* INSTANCE PROPERTIES */\n key: string;\n options: Options;\n config: Config;\n channels: Channels;\n global_emitter: EventsDispatcher;\n sessionID: number;\n timeline: Timeline;\n timelineSender: TimelineSender;\n connection: ConnectionManager;\n timelineSenderTimer: PeriodicTimer;\n user: UserFacade;\n constructor(app_key: string, options: Options) {\n checkAppKey(app_key);\n validateOptions(options);\n this.key = app_key;\n this.config = getConfig(options, this);\n\n this.channels = Factory.createChannels();\n this.global_emitter = new EventsDispatcher();\n this.sessionID = Runtime.randomInt(1000000000);\n\n this.timeline = new Timeline(this.key, this.sessionID, {\n cluster: this.config.cluster,\n features: Pusher.getClientFeatures(),\n params: this.config.timelineParams || {},\n limit: 50,\n level: TimelineLevel.INFO,\n version: Defaults.VERSION\n });\n if (this.config.enableStats) {\n this.timelineSender = Factory.createTimelineSender(this.timeline, {\n host: this.config.statsHost,\n path: '/timeline/v2/' + Runtime.TimelineTransport.name\n });\n }\n\n var getStrategy = (options: StrategyOptions) => {\n return Runtime.getDefaultStrategy(this.config, options, defineTransport);\n };\n\n this.connection = Factory.createConnectionManager(this.key, {\n getStrategy: getStrategy,\n timeline: this.timeline,\n activityTimeout: this.config.activityTimeout,\n pongTimeout: this.config.pongTimeout,\n unavailableTimeout: this.config.unavailableTimeout,\n useTLS: Boolean(this.config.useTLS)\n });\n\n this.connection.bind('connected', () => {\n this.subscribeAll();\n if (this.timelineSender) {\n this.timelineSender.send(this.connection.isUsingTLS());\n }\n });\n\n this.connection.bind('message', event => {\n var eventName = event.event;\n var internal = eventName.indexOf('pusher_internal:') === 0;\n if (event.channel) {\n var channel = this.channel(event.channel);\n if (channel) {\n channel.handleEvent(event);\n }\n }\n // Emit globally [deprecated]\n if (!internal) {\n this.global_emitter.emit(event.event, event.data);\n }\n });\n this.connection.bind('connecting', () => {\n this.channels.disconnect();\n });\n this.connection.bind('disconnected', () => {\n this.channels.disconnect();\n });\n this.connection.bind('error', err => {\n Logger.warn(err);\n });\n\n Pusher.instances.push(this);\n this.timeline.info({ instances: Pusher.instances.length });\n\n this.user = new UserFacade(this);\n\n if (Pusher.isReady) {\n this.connect();\n }\n }\n\n /**\n * Allows you to switch Pusher cluster without\n * losing all the channels/subscription binding\n * as this is internally managed by the SDK.\n */\n switchCluster(options: ClusterOptions) {\n const { appKey, cluster } = options;\n this.key = appKey;\n this.options = { ...this.options, cluster };\n this.config = getConfig(this.options, this);\n this.connection.switchCluster(this.key);\n }\n\n channel(name: string): Channel {\n return this.channels.find(name);\n }\n\n allChannels(): Channel[] {\n return this.channels.all();\n }\n\n connect() {\n this.connection.connect();\n\n if (this.timelineSender) {\n if (!this.timelineSenderTimer) {\n var usingTLS = this.connection.isUsingTLS();\n var timelineSender = this.timelineSender;\n this.timelineSenderTimer = new PeriodicTimer(60000, function() {\n timelineSender.send(usingTLS);\n });\n }\n }\n }\n\n disconnect() {\n this.connection.disconnect();\n\n if (this.timelineSenderTimer) {\n this.timelineSenderTimer.ensureAborted();\n this.timelineSenderTimer = null;\n }\n }\n\n bind(event_name: string, callback: Function, context?: any): Pusher {\n this.global_emitter.bind(event_name, callback, context);\n return this;\n }\n\n unbind(event_name?: string, callback?: Function, context?: any): Pusher {\n this.global_emitter.unbind(event_name, callback, context);\n return this;\n }\n\n bind_global(callback: Function): Pusher {\n this.global_emitter.bind_global(callback);\n return this;\n }\n\n unbind_global(callback?: Function): Pusher {\n this.global_emitter.unbind_global(callback);\n return this;\n }\n\n unbind_all(callback?: Function): Pusher {\n this.global_emitter.unbind_all();\n return this;\n }\n\n subscribeAll() {\n var channelName;\n for (channelName in this.channels.channels) {\n if (this.channels.channels.hasOwnProperty(channelName)) {\n this.subscribe(channelName);\n }\n }\n }\n\n subscribe(channel_name: string) {\n var channel = this.channels.add(channel_name, this);\n if (channel.subscriptionPending && channel.subscriptionCancelled) {\n channel.reinstateSubscription();\n } else if (\n !channel.subscriptionPending &&\n this.connection.state === 'connected'\n ) {\n channel.subscribe();\n }\n return channel;\n }\n\n unsubscribe(channel_name: string) {\n var channel = this.channels.find(channel_name);\n if (channel && channel.subscriptionPending) {\n channel.cancelSubscription();\n } else {\n channel = this.channels.remove(channel_name);\n if (channel && channel.subscribed) {\n channel.unsubscribe();\n }\n }\n }\n\n send_event(event_name: string, data: any, channel?: string) {\n return this.connection.send_event(event_name, data, channel);\n }\n\n shouldUseTLS(): boolean {\n return this.config.useTLS;\n }\n\n signin() {\n this.user.signin();\n }\n}\n\nfunction checkAppKey(key) {\n if (key === null || key === undefined) {\n throw 'You must pass your app key when you instantiate Pusher.';\n }\n}\n\nRuntime.setup(Pusher);\n","import Pusher from './pusher';\nimport { Options, validateOptions } from './options';\nimport * as nacl from 'tweetnacl';\n\nexport default class PusherWithEncryption extends Pusher {\n constructor(app_key: string, options: Options) {\n Pusher.logToConsole = PusherWithEncryption.logToConsole;\n Pusher.log = PusherWithEncryption.log;\n\n validateOptions(options);\n options.nacl = nacl;\n super(app_key, options);\n }\n}\n"],"sourceRoot":""} \ No newline at end of file diff --git a/dist/worker/pusher.worker.js b/dist/worker/pusher.worker.js index 16aaac4af..7699c92c0 100644 --- a/dist/worker/pusher.worker.js +++ b/dist/worker/pusher.worker.js @@ -1,5 +1,5 @@ /*! - * Pusher JavaScript Library v8.4.0 + * Pusher JavaScript Library v8.4.0-rc1 * https://pusher.com/ * * Copyright 2020, Pusher @@ -868,7 +868,7 @@ function safeJSONStringify(source) { // CONCATENATED MODULE: ./src/core/defaults.ts var Defaults = { - VERSION: "8.4.0", + VERSION: "8.4.0-rc1", PROTOCOL: 7, wsPort: 80, wssPort: 443, diff --git a/dist/worker/pusher.worker.js.map b/dist/worker/pusher.worker.js.map index 326be4223..0d44eba5f 100644 --- a/dist/worker/pusher.worker.js.map +++ b/dist/worker/pusher.worker.js.map @@ -1 +1 @@ -{"version":3,"sources":["webpack://Pusher/webpack/universalModuleDefinition","webpack://Pusher/webpack/bootstrap","webpack://Pusher/./node_modules/@stablelib/base64/base64.ts","webpack://Pusher/./node_modules/@stablelib/utf8/utf8.ts","webpack://Pusher/./src/core/pusher.js","webpack://Pusher/./src/core/base64.ts","webpack://Pusher/./src/core/utils/timers/abstract_timer.ts","webpack://Pusher/./src/core/utils/timers/index.ts","webpack://Pusher/./src/core/util.ts","webpack://Pusher/./src/core/utils/collections.ts","webpack://Pusher/./src/core/defaults.ts","webpack://Pusher/./src/core/transports/url_schemes.ts","webpack://Pusher/./src/core/events/callback_registry.ts","webpack://Pusher/./src/core/events/dispatcher.ts","webpack://Pusher/./src/core/logger.ts","webpack://Pusher/./src/core/transports/transport_connection.ts","webpack://Pusher/./src/core/transports/transport.ts","webpack://Pusher/./src/runtimes/isomorphic/transports/transports.ts","webpack://Pusher/./src/core/transports/assistant_to_the_transport_manager.ts","webpack://Pusher/./src/core/connection/protocol/protocol.ts","webpack://Pusher/./src/core/connection/connection.ts","webpack://Pusher/./src/core/connection/handshake/index.ts","webpack://Pusher/./src/core/timeline/timeline_sender.ts","webpack://Pusher/./src/core/errors.ts","webpack://Pusher/./src/core/utils/url_store.ts","webpack://Pusher/./src/core/channels/channel.ts","webpack://Pusher/./src/core/channels/private_channel.ts","webpack://Pusher/./src/core/channels/members.ts","webpack://Pusher/./src/core/channels/presence_channel.ts","webpack://Pusher/./src/core/channels/encrypted_channel.ts","webpack://Pusher/./src/core/connection/connection_manager.ts","webpack://Pusher/./src/core/channels/channels.ts","webpack://Pusher/./src/core/utils/factory.ts","webpack://Pusher/./src/core/transports/transport_manager.ts","webpack://Pusher/./src/core/strategies/sequential_strategy.ts","webpack://Pusher/./src/core/strategies/best_connected_ever_strategy.ts","webpack://Pusher/./src/core/strategies/websocket_prioritized_cached_strategy.ts","webpack://Pusher/./src/core/strategies/delayed_strategy.ts","webpack://Pusher/./src/core/strategies/if_strategy.ts","webpack://Pusher/./src/core/strategies/first_connected_strategy.ts","webpack://Pusher/./src/runtimes/isomorphic/default_strategy.ts","webpack://Pusher/./src/runtimes/isomorphic/transports/transport_connection_initializer.ts","webpack://Pusher/./src/core/http/http_request.ts","webpack://Pusher/./src/core/http/state.ts","webpack://Pusher/./src/core/http/http_socket.ts","webpack://Pusher/./src/core/http/http_streaming_socket.ts","webpack://Pusher/./src/core/http/http_polling_socket.ts","webpack://Pusher/./src/runtimes/isomorphic/http/http_xhr_request.ts","webpack://Pusher/./src/runtimes/isomorphic/http/http.ts","webpack://Pusher/./src/runtimes/isomorphic/runtime.ts","webpack://Pusher/./src/runtimes/worker/net_info.ts","webpack://Pusher/./src/runtimes/worker/auth/fetch_auth.ts","webpack://Pusher/./src/runtimes/worker/timeline/fetch_timeline.ts","webpack://Pusher/./src/runtimes/worker/runtime.ts","webpack://Pusher/./src/core/timeline/level.ts","webpack://Pusher/./src/core/timeline/timeline.ts","webpack://Pusher/./src/core/strategies/transport_strategy.ts","webpack://Pusher/./src/core/strategies/strategy_builder.ts","webpack://Pusher/./src/core/options.ts","webpack://Pusher/./src/core/auth/options.ts","webpack://Pusher/./src/core/auth/user_authenticator.ts","webpack://Pusher/./src/core/auth/channel_authorizer.ts","webpack://Pusher/./src/core/auth/deprecated_channel_authorizer.ts","webpack://Pusher/./src/core/config.ts","webpack://Pusher/./src/core/watchlist.ts","webpack://Pusher/./src/core/utils/flat_promise.ts","webpack://Pusher/./src/core/user.ts","webpack://Pusher/./src/core/pusher.ts"],"names":[],"mappings":";;;;;;;;AAAA;AACA;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AAI,OAAO,CAAC,UAAU,EAAE;gBACjC,OAAO,CAAC,WAAW,EAAE,CAAC;aACvB;SACF;IACH,CAAC;IAED,UAAU,CAAC,UAAkB,EAAE,IAAS,EAAE,OAAgB;QACxD,OAAO,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC,UAAU,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;IAC/D,CAAC;IAED,YAAY;QACV,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC;IAC5B,CAAC;IAED,MAAM;QACJ,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;IACrB,CAAC;;AAvOM,uBAAS,GAAa,EAAE,CAAC;AACzB,qBAAO,GAAY,KAAK,CAAC;AACzB,0BAAY,GAAY,KAAK,CAAC;AAG9B,qBAAO,GAAoB,cAAO,CAAC;AACnC,6BAAe,GAAc,cAAQ,CAAC,eAAe,CAAC;AACtD,mCAAqB,GAAc,cAAQ,CAAC,qBAAqB,CAAC;AAClE,4BAAc,GAAc,cAAQ,CAAC,cAAc,CAAC;AAVxC,8FAAM;AA4O3B,SAAS,WAAW,CAAC,GAAG;IACtB,IAAI,GAAG,KAAK,IAAI,IAAI,GAAG,KAAK,SAAS,EAAE;QACrC,MAAM,yDAAyD,CAAC;KACjE;AACH,CAAC;AAED,cAAO,CAAC,KAAK,CAAC,aAAM,CAAC,CAAC","file":"pusher.worker.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"Pusher\"] = factory();\n\telse\n\t\troot[\"Pusher\"] = factory();\n})(this, function() {\nreturn "," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 2);\n","// Copyright (C) 2016 Dmitry Chestnykh\n// MIT License. See LICENSE file for details.\n\n/**\n * Package base64 implements Base64 encoding and decoding.\n */\n\n// Invalid character used in decoding to indicate\n// that the character to decode is out of range of\n// alphabet and cannot be decoded.\nconst INVALID_BYTE = 256;\n\n/**\n * Implements standard Base64 encoding.\n *\n * Operates in constant time.\n */\nexport class Coder {\n // TODO(dchest): methods to encode chunk-by-chunk.\n\n constructor(private _paddingCharacter = \"=\") { }\n\n encodedLength(length: number): number {\n if (!this._paddingCharacter) {\n return (length * 8 + 5) / 6 | 0;\n }\n return (length + 2) / 3 * 4 | 0;\n }\n\n encode(data: Uint8Array): string {\n let out = \"\";\n\n let i = 0;\n for (; i < data.length - 2; i += 3) {\n let c = (data[i] << 16) | (data[i + 1] << 8) | (data[i + 2]);\n out += this._encodeByte((c >>> 3 * 6) & 63);\n out += this._encodeByte((c >>> 2 * 6) & 63);\n out += this._encodeByte((c >>> 1 * 6) & 63);\n out += this._encodeByte((c >>> 0 * 6) & 63);\n }\n\n const left = data.length - i;\n if (left > 0) {\n let c = (data[i] << 16) | (left === 2 ? data[i + 1] << 8 : 0);\n out += this._encodeByte((c >>> 3 * 6) & 63);\n out += this._encodeByte((c >>> 2 * 6) & 63);\n if (left === 2) {\n out += this._encodeByte((c >>> 1 * 6) & 63);\n } else {\n out += this._paddingCharacter || \"\";\n }\n out += this._paddingCharacter || \"\";\n }\n\n return out;\n }\n\n maxDecodedLength(length: number): number {\n if (!this._paddingCharacter) {\n return (length * 6 + 7) / 8 | 0;\n }\n return length / 4 * 3 | 0;\n }\n\n decodedLength(s: string): number {\n return this.maxDecodedLength(s.length - this._getPaddingLength(s));\n }\n\n decode(s: string): Uint8Array {\n if (s.length === 0) {\n return new Uint8Array(0);\n }\n const paddingLength = this._getPaddingLength(s);\n const length = s.length - paddingLength;\n const out = new Uint8Array(this.maxDecodedLength(length));\n let op = 0;\n let i = 0;\n let haveBad = 0;\n let v0 = 0, v1 = 0, v2 = 0, v3 = 0;\n for (; i < length - 4; i += 4) {\n v0 = this._decodeChar(s.charCodeAt(i + 0));\n v1 = this._decodeChar(s.charCodeAt(i + 1));\n v2 = this._decodeChar(s.charCodeAt(i + 2));\n v3 = this._decodeChar(s.charCodeAt(i + 3));\n out[op++] = (v0 << 2) | (v1 >>> 4);\n out[op++] = (v1 << 4) | (v2 >>> 2);\n out[op++] = (v2 << 6) | v3;\n haveBad |= v0 & INVALID_BYTE;\n haveBad |= v1 & INVALID_BYTE;\n haveBad |= v2 & INVALID_BYTE;\n haveBad |= v3 & INVALID_BYTE;\n }\n if (i < length - 1) {\n v0 = this._decodeChar(s.charCodeAt(i));\n v1 = this._decodeChar(s.charCodeAt(i + 1));\n out[op++] = (v0 << 2) | (v1 >>> 4);\n haveBad |= v0 & INVALID_BYTE;\n haveBad |= v1 & INVALID_BYTE;\n }\n if (i < length - 2) {\n v2 = this._decodeChar(s.charCodeAt(i + 2));\n out[op++] = (v1 << 4) | (v2 >>> 2);\n haveBad |= v2 & INVALID_BYTE;\n }\n if (i < length - 3) {\n v3 = this._decodeChar(s.charCodeAt(i + 3));\n out[op++] = (v2 << 6) | v3;\n haveBad |= v3 & INVALID_BYTE;\n }\n if (haveBad !== 0) {\n throw new Error(\"Base64Coder: incorrect characters for decoding\");\n }\n return out;\n }\n\n // Standard encoding have the following encoded/decoded ranges,\n // which we need to convert between.\n //\n // ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 0123456789 + /\n // Index: 0 - 25 26 - 51 52 - 61 62 63\n // ASCII: 65 - 90 97 - 122 48 - 57 43 47\n //\n\n // Encode 6 bits in b into a new character.\n protected _encodeByte(b: number): string {\n // Encoding uses constant time operations as follows:\n //\n // 1. Define comparison of A with B using (A - B) >>> 8:\n // if A > B, then result is positive integer\n // if A <= B, then result is 0\n //\n // 2. Define selection of C or 0 using bitwise AND: X & C:\n // if X == 0, then result is 0\n // if X != 0, then result is C\n //\n // 3. Start with the smallest comparison (b >= 0), which is always\n // true, so set the result to the starting ASCII value (65).\n //\n // 4. Continue comparing b to higher ASCII values, and selecting\n // zero if comparison isn't true, otherwise selecting a value\n // to add to result, which:\n //\n // a) undoes the previous addition\n // b) provides new value to add\n //\n let result = b;\n // b >= 0\n result += 65;\n // b > 25\n result += ((25 - b) >>> 8) & ((0 - 65) - 26 + 97);\n // b > 51\n result += ((51 - b) >>> 8) & ((26 - 97) - 52 + 48);\n // b > 61\n result += ((61 - b) >>> 8) & ((52 - 48) - 62 + 43);\n // b > 62\n result += ((62 - b) >>> 8) & ((62 - 43) - 63 + 47);\n\n return String.fromCharCode(result);\n }\n\n // Decode a character code into a byte.\n // Must return 256 if character is out of alphabet range.\n protected _decodeChar(c: number): number {\n // Decoding works similar to encoding: using the same comparison\n // function, but now it works on ranges: result is always incremented\n // by value, but this value becomes zero if the range is not\n // satisfied.\n //\n // Decoding starts with invalid value, 256, which is then\n // subtracted when the range is satisfied. If none of the ranges\n // apply, the function returns 256, which is then checked by\n // the caller to throw error.\n let result = INVALID_BYTE; // start with invalid character\n\n // c == 43 (c > 42 and c < 44)\n result += (((42 - c) & (c - 44)) >>> 8) & (-INVALID_BYTE + c - 43 + 62);\n // c == 47 (c > 46 and c < 48)\n result += (((46 - c) & (c - 48)) >>> 8) & (-INVALID_BYTE + c - 47 + 63);\n // c > 47 and c < 58\n result += (((47 - c) & (c - 58)) >>> 8) & (-INVALID_BYTE + c - 48 + 52);\n // c > 64 and c < 91\n result += (((64 - c) & (c - 91)) >>> 8) & (-INVALID_BYTE + c - 65 + 0);\n // c > 96 and c < 123\n result += (((96 - c) & (c - 123)) >>> 8) & (-INVALID_BYTE + c - 97 + 26);\n\n return result;\n }\n\n private _getPaddingLength(s: string): number {\n let paddingLength = 0;\n if (this._paddingCharacter) {\n for (let i = s.length - 1; i >= 0; i--) {\n if (s[i] !== this._paddingCharacter) {\n break;\n }\n paddingLength++;\n }\n if (s.length < 4 || paddingLength > 2) {\n throw new Error(\"Base64Coder: incorrect padding\");\n }\n }\n return paddingLength;\n }\n\n}\n\nconst stdCoder = new Coder();\n\nexport function encode(data: Uint8Array): string {\n return stdCoder.encode(data);\n}\n\nexport function decode(s: string): Uint8Array {\n return stdCoder.decode(s);\n}\n\n/**\n * Implements URL-safe Base64 encoding.\n * (Same as Base64, but '+' is replaced with '-', and '/' with '_').\n *\n * Operates in constant time.\n */\nexport class URLSafeCoder extends Coder {\n // URL-safe encoding have the following encoded/decoded ranges:\n //\n // ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 0123456789 - _\n // Index: 0 - 25 26 - 51 52 - 61 62 63\n // ASCII: 65 - 90 97 - 122 48 - 57 45 95\n //\n\n protected _encodeByte(b: number): string {\n let result = b;\n // b >= 0\n result += 65;\n // b > 25\n result += ((25 - b) >>> 8) & ((0 - 65) - 26 + 97);\n // b > 51\n result += ((51 - b) >>> 8) & ((26 - 97) - 52 + 48);\n // b > 61\n result += ((61 - b) >>> 8) & ((52 - 48) - 62 + 45);\n // b > 62\n result += ((62 - b) >>> 8) & ((62 - 45) - 63 + 95);\n\n return String.fromCharCode(result);\n }\n\n protected _decodeChar(c: number): number {\n let result = INVALID_BYTE;\n\n // c == 45 (c > 44 and c < 46)\n result += (((44 - c) & (c - 46)) >>> 8) & (-INVALID_BYTE + c - 45 + 62);\n // c == 95 (c > 94 and c < 96)\n result += (((94 - c) & (c - 96)) >>> 8) & (-INVALID_BYTE + c - 95 + 63);\n // c > 47 and c < 58\n result += (((47 - c) & (c - 58)) >>> 8) & (-INVALID_BYTE + c - 48 + 52);\n // c > 64 and c < 91\n result += (((64 - c) & (c - 91)) >>> 8) & (-INVALID_BYTE + c - 65 + 0);\n // c > 96 and c < 123\n result += (((96 - c) & (c - 123)) >>> 8) & (-INVALID_BYTE + c - 97 + 26);\n\n return result;\n }\n}\n\nconst urlSafeCoder = new URLSafeCoder();\n\nexport function encodeURLSafe(data: Uint8Array): string {\n return urlSafeCoder.encode(data);\n}\n\nexport function decodeURLSafe(s: string): Uint8Array {\n return urlSafeCoder.decode(s);\n}\n\n\nexport const encodedLength = (length: number) =>\n stdCoder.encodedLength(length);\n\nexport const maxDecodedLength = (length: number) =>\n stdCoder.maxDecodedLength(length);\n\nexport const decodedLength = (s: string) =>\n stdCoder.decodedLength(s);\n","// Copyright (C) 2016 Dmitry Chestnykh\n// MIT License. See LICENSE file for details.\n\n/**\n * Package utf8 implements UTF-8 encoding and decoding.\n */\n\nconst INVALID_UTF16 = \"utf8: invalid string\";\nconst INVALID_UTF8 = \"utf8: invalid source encoding\";\n\n/**\n * Encodes the given string into UTF-8 byte array.\n * Throws if the source string has invalid UTF-16 encoding.\n */\nexport function encode(s: string): Uint8Array {\n // Calculate result length and allocate output array.\n // encodedLength() also validates string and throws errors,\n // so we don't need repeat validation here.\n const arr = new Uint8Array(encodedLength(s));\n\n let pos = 0;\n for (let i = 0; i < s.length; i++) {\n let c = s.charCodeAt(i);\n if (c < 0x80) {\n arr[pos++] = c;\n } else if (c < 0x800) {\n arr[pos++] = 0xc0 | c >> 6;\n arr[pos++] = 0x80 | c & 0x3f;\n } else if (c < 0xd800) {\n arr[pos++] = 0xe0 | c >> 12;\n arr[pos++] = 0x80 | (c >> 6) & 0x3f;\n arr[pos++] = 0x80 | c & 0x3f;\n } else {\n i++; // get one more character\n c = (c & 0x3ff) << 10;\n c |= s.charCodeAt(i) & 0x3ff;\n c += 0x10000;\n\n arr[pos++] = 0xf0 | c >> 18;\n arr[pos++] = 0x80 | (c >> 12) & 0x3f;\n arr[pos++] = 0x80 | (c >> 6) & 0x3f;\n arr[pos++] = 0x80 | c & 0x3f;\n }\n }\n return arr;\n}\n\n/**\n * Returns the number of bytes required to encode the given string into UTF-8.\n * Throws if the source string has invalid UTF-16 encoding.\n */\nexport function encodedLength(s: string): number {\n let result = 0;\n for (let i = 0; i < s.length; i++) {\n const c = s.charCodeAt(i);\n if (c < 0x80) {\n result += 1;\n } else if (c < 0x800) {\n result += 2;\n } else if (c < 0xd800) {\n result += 3;\n } else if (c <= 0xdfff) {\n if (i >= s.length - 1) {\n throw new Error(INVALID_UTF16);\n }\n i++; // \"eat\" next character\n result += 4;\n } else {\n throw new Error(INVALID_UTF16);\n }\n }\n return result;\n}\n\n/**\n * Decodes the given byte array from UTF-8 into a string.\n * Throws if encoding is invalid.\n */\nexport function decode(arr: Uint8Array): string {\n const chars: string[] = [];\n for (let i = 0; i < arr.length; i++) {\n let b = arr[i];\n\n if (b & 0x80) {\n let min;\n if (b < 0xe0) {\n // Need 1 more byte.\n if (i >= arr.length) {\n throw new Error(INVALID_UTF8);\n }\n const n1 = arr[++i];\n if ((n1 & 0xc0) !== 0x80) {\n throw new Error(INVALID_UTF8);\n }\n b = (b & 0x1f) << 6 | (n1 & 0x3f);\n min = 0x80;\n } else if (b < 0xf0) {\n // Need 2 more bytes.\n if (i >= arr.length - 1) {\n throw new Error(INVALID_UTF8);\n }\n const n1 = arr[++i];\n const n2 = arr[++i];\n if ((n1 & 0xc0) !== 0x80 || (n2 & 0xc0) !== 0x80) {\n throw new Error(INVALID_UTF8);\n }\n b = (b & 0x0f) << 12 | (n1 & 0x3f) << 6 | (n2 & 0x3f);\n min = 0x800;\n } else if (b < 0xf8) {\n // Need 3 more bytes.\n if (i >= arr.length - 2) {\n throw new Error(INVALID_UTF8);\n }\n const n1 = arr[++i];\n const n2 = arr[++i];\n const n3 = arr[++i];\n if ((n1 & 0xc0) !== 0x80 || (n2 & 0xc0) !== 0x80 || (n3 & 0xc0) !== 0x80) {\n throw new Error(INVALID_UTF8);\n }\n b = (b & 0x0f) << 18 | (n1 & 0x3f) << 12 | (n2 & 0x3f) << 6 | (n3 & 0x3f);\n min = 0x10000;\n } else {\n throw new Error(INVALID_UTF8);\n }\n\n if (b < min || (b >= 0xd800 && b <= 0xdfff)) {\n throw new Error(INVALID_UTF8);\n }\n\n if (b >= 0x10000) {\n // Surrogate pair.\n if (b > 0x10ffff) {\n throw new Error(INVALID_UTF8);\n }\n b -= 0x10000;\n chars.push(String.fromCharCode(0xd800 | (b >> 10)));\n b = 0xdc00 | (b & 0x3ff);\n }\n }\n\n chars.push(String.fromCharCode(b));\n }\n return chars.join(\"\");\n}\n","// required so we don't have to do require('pusher').default etc.\nmodule.exports = require('./pusher').default;\n","export default function encode(s: any): string {\n return btoa(utob(s));\n}\n\nvar fromCharCode = String.fromCharCode;\n\nvar b64chars =\n 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';\nvar b64tab = {};\n\nfor (var i = 0, l = b64chars.length; i < l; i++) {\n b64tab[b64chars.charAt(i)] = i;\n}\n\nvar cb_utob = function(c) {\n var cc = c.charCodeAt(0);\n return cc < 0x80\n ? c\n : cc < 0x800\n ? fromCharCode(0xc0 | (cc >>> 6)) + fromCharCode(0x80 | (cc & 0x3f))\n : fromCharCode(0xe0 | ((cc >>> 12) & 0x0f)) +\n fromCharCode(0x80 | ((cc >>> 6) & 0x3f)) +\n fromCharCode(0x80 | (cc & 0x3f));\n};\n\nvar utob = function(u) {\n return u.replace(/[^\\x00-\\x7F]/g, cb_utob);\n};\n\nvar cb_encode = function(ccc) {\n var padlen = [0, 2, 1][ccc.length % 3];\n var ord =\n (ccc.charCodeAt(0) << 16) |\n ((ccc.length > 1 ? ccc.charCodeAt(1) : 0) << 8) |\n (ccc.length > 2 ? ccc.charCodeAt(2) : 0);\n var chars = [\n b64chars.charAt(ord >>> 18),\n b64chars.charAt((ord >>> 12) & 63),\n padlen >= 2 ? '=' : b64chars.charAt((ord >>> 6) & 63),\n padlen >= 1 ? '=' : b64chars.charAt(ord & 63)\n ];\n return chars.join('');\n};\n\nvar btoa =\n global.btoa ||\n function(b) {\n return b.replace(/[\\s\\S]{1,3}/g, cb_encode);\n };\n","import TimedCallback from './timed_callback';\nimport { Delay, Scheduler, Canceller } from './scheduling';\n\nabstract class Timer {\n protected clear: Canceller;\n protected timer: number | void;\n\n constructor(\n set: Scheduler,\n clear: Canceller,\n delay: Delay,\n callback: TimedCallback\n ) {\n this.clear = clear;\n this.timer = set(() => {\n if (this.timer) {\n this.timer = callback(this.timer);\n }\n }, delay);\n }\n\n /** Returns whether the timer is still running.\n *\n * @return {Boolean}\n */\n isRunning(): boolean {\n return this.timer !== null;\n }\n\n /** Aborts a timer when it's running. */\n ensureAborted() {\n if (this.timer) {\n this.clear(this.timer);\n this.timer = null;\n }\n }\n}\n\nexport default Timer;\n","import Timer from './abstract_timer';\nimport TimedCallback from './timed_callback';\nimport { Delay } from './scheduling';\n\n// We need to bind clear functions this way to avoid exceptions on IE8\nfunction clearTimeout(timer) {\n global.clearTimeout(timer);\n}\nfunction clearInterval(timer) {\n global.clearInterval(timer);\n}\n\n/** Cross-browser compatible one-off timer abstraction.\n *\n * @param {Number} delay\n * @param {Function} callback\n */\nexport class OneOffTimer extends Timer {\n constructor(delay: Delay, callback: TimedCallback) {\n super(setTimeout, clearTimeout, delay, function(timer) {\n callback();\n return null;\n });\n }\n}\n\n/** Cross-browser compatible periodic timer abstraction.\n *\n * @param {Number} delay\n * @param {Function} callback\n */\nexport class PeriodicTimer extends Timer {\n constructor(delay: Delay, callback: TimedCallback) {\n super(setInterval, clearInterval, delay, function(timer) {\n callback();\n return timer;\n });\n }\n}\n","import * as Collections from './utils/collections';\nimport TimedCallback from './utils/timers/timed_callback';\nimport { OneOffTimer, PeriodicTimer } from './utils/timers';\n\nvar Util = {\n now(): number {\n if (Date.now) {\n return Date.now();\n } else {\n return new Date().valueOf();\n }\n },\n\n defer(callback: TimedCallback): OneOffTimer {\n return new OneOffTimer(0, callback);\n },\n\n /** Builds a function that will proxy a method call to its first argument.\n *\n * Allows partial application of arguments, so additional arguments are\n * prepended to the argument list.\n *\n * @param {String} name method name\n * @return {Function} proxy function\n */\n method(name: string, ...args: any[]): Function {\n var boundArguments = Array.prototype.slice.call(arguments, 1);\n return function(object) {\n return object[name].apply(object, boundArguments.concat(arguments));\n };\n }\n};\n\nexport default Util;\n","import base64encode from '../base64';\nimport Util from '../util';\n\n/** Merges multiple objects into the target argument.\n *\n * For properties that are plain Objects, performs a deep-merge. For the\n * rest it just copies the value of the property.\n *\n * To extend prototypes use it as following:\n * Pusher.Util.extend(Target.prototype, Base.prototype)\n *\n * You can also use it to merge objects without altering them:\n * Pusher.Util.extend({}, object1, object2)\n *\n * @param {Object} target\n * @return {Object} the target argument\n */\nexport function extend(target: any, ...sources: any[]): T {\n for (var i = 0; i < sources.length; i++) {\n var extensions = sources[i];\n for (var property in extensions) {\n if (\n extensions[property] &&\n extensions[property].constructor &&\n extensions[property].constructor === Object\n ) {\n target[property] = extend(target[property] || {}, extensions[property]);\n } else {\n target[property] = extensions[property];\n }\n }\n }\n return target;\n}\n\nexport function stringify(): string {\n var m = ['Pusher'];\n for (var i = 0; i < arguments.length; i++) {\n if (typeof arguments[i] === 'string') {\n m.push(arguments[i]);\n } else {\n m.push(safeJSONStringify(arguments[i]));\n }\n }\n return m.join(' : ');\n}\n\nexport function arrayIndexOf(array: any[], item: any): number {\n // MSIE doesn't have array.indexOf\n var nativeIndexOf = Array.prototype.indexOf;\n if (array === null) {\n return -1;\n }\n if (nativeIndexOf && array.indexOf === nativeIndexOf) {\n return array.indexOf(item);\n }\n for (var i = 0, l = array.length; i < l; i++) {\n if (array[i] === item) {\n return i;\n }\n }\n return -1;\n}\n\n/** Applies a function f to all properties of an object.\n *\n * Function f gets 3 arguments passed:\n * - element from the object\n * - key of the element\n * - reference to the object\n *\n * @param {Object} object\n * @param {Function} f\n */\nexport function objectApply(object: any, f: Function) {\n for (var key in object) {\n if (Object.prototype.hasOwnProperty.call(object, key)) {\n f(object[key], key, object);\n }\n }\n}\n\n/** Return a list of objects own proerty keys\n *\n * @param {Object} object\n * @returns {Array}\n */\nexport function keys(object: any): string[] {\n var keys = [];\n objectApply(object, function(_, key) {\n keys.push(key);\n });\n return keys;\n}\n\n/** Return a list of object's own property values\n *\n * @param {Object} object\n * @returns {Array}\n */\nexport function values(object: any): any[] {\n var values = [];\n objectApply(object, function(value) {\n values.push(value);\n });\n return values;\n}\n\n/** Applies a function f to all elements of an array.\n *\n * Function f gets 3 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function apply(array: any[], f: Function, context?: any) {\n for (var i = 0; i < array.length; i++) {\n f.call(context || global, array[i], i, array);\n }\n}\n\n/** Maps all elements of the array and returns the result.\n *\n * Function f gets 4 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n * - reference to the destination array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function map(array: any[], f: Function): any[] {\n var result = [];\n for (var i = 0; i < array.length; i++) {\n result.push(f(array[i], i, array, result));\n }\n return result;\n}\n\n/** Maps all elements of the object and returns the result.\n *\n * Function f gets 4 arguments passed:\n * - element from the object\n * - key of the element\n * - reference to the source object\n * - reference to the destination object\n *\n * @param {Object} object\n * @param {Function} f\n */\nexport function mapObject(object: any, f: Function): any {\n var result = {};\n objectApply(object, function(value, key) {\n result[key] = f(value);\n });\n return result;\n}\n\n/** Filters elements of the array using a test function.\n *\n * Function test gets 4 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n * - reference to the destination array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function filter(array: any[], test: Function): any[] {\n test =\n test ||\n function(value) {\n return !!value;\n };\n\n var result = [];\n for (var i = 0; i < array.length; i++) {\n if (test(array[i], i, array, result)) {\n result.push(array[i]);\n }\n }\n return result;\n}\n\n/** Filters properties of the object using a test function.\n *\n * Function test gets 4 arguments passed:\n * - element from the object\n * - key of the element\n * - reference to the source object\n * - reference to the destination object\n *\n * @param {Object} object\n * @param {Function} f\n */\nexport function filterObject(object: Object, test: Function) {\n var result = {};\n objectApply(object, function(value, key) {\n if ((test && test(value, key, object, result)) || Boolean(value)) {\n result[key] = value;\n }\n });\n return result;\n}\n\n/** Flattens an object into a two-dimensional array.\n *\n * @param {Object} object\n * @return {Array} resulting array of [key, value] pairs\n */\nexport function flatten(object: Object): any[] {\n var result = [];\n objectApply(object, function(value, key) {\n result.push([key, value]);\n });\n return result;\n}\n\n/** Checks whether any element of the array passes the test.\n *\n * Function test gets 3 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function any(array: any[], test: Function): boolean {\n for (var i = 0; i < array.length; i++) {\n if (test(array[i], i, array)) {\n return true;\n }\n }\n return false;\n}\n\n/** Checks whether all elements of the array pass the test.\n *\n * Function test gets 3 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function all(array: any[], test: Function): boolean {\n for (var i = 0; i < array.length; i++) {\n if (!test(array[i], i, array)) {\n return false;\n }\n }\n return true;\n}\n\nexport function encodeParamsObject(data): string {\n return mapObject(data, function(value) {\n if (typeof value === 'object') {\n value = safeJSONStringify(value);\n }\n return encodeURIComponent(base64encode(value.toString()));\n });\n}\n\nexport function buildQueryString(data: any): string {\n var params = filterObject(data, function(value) {\n return value !== undefined;\n });\n\n var query = map(\n flatten(encodeParamsObject(params)),\n Util.method('join', '=')\n ).join('&');\n\n return query;\n}\n\n/**\n * See https://github.com/douglascrockford/JSON-js/blob/master/cycle.js\n *\n * Remove circular references from an object. Required for JSON.stringify in\n * React Native, which tends to blow up a lot.\n *\n * @param {any} object\n * @return {any} Decycled object\n */\nexport function decycleObject(object: any): any {\n var objects = [],\n paths = [];\n\n return (function derez(value, path) {\n var i, name, nu;\n\n switch (typeof value) {\n case 'object':\n if (!value) {\n return null;\n }\n for (i = 0; i < objects.length; i += 1) {\n if (objects[i] === value) {\n return { $ref: paths[i] };\n }\n }\n\n objects.push(value);\n paths.push(path);\n\n if (Object.prototype.toString.apply(value) === '[object Array]') {\n nu = [];\n for (i = 0; i < value.length; i += 1) {\n nu[i] = derez(value[i], path + '[' + i + ']');\n }\n } else {\n nu = {};\n for (name in value) {\n if (Object.prototype.hasOwnProperty.call(value, name)) {\n nu[name] = derez(\n value[name],\n path + '[' + JSON.stringify(name) + ']'\n );\n }\n }\n }\n return nu;\n case 'number':\n case 'string':\n case 'boolean':\n return value;\n }\n })(object, '$');\n}\n\n/**\n * Provides a cross-browser and cross-platform way to safely stringify objects\n * into JSON. This is particularly necessary for ReactNative, where circular JSON\n * structures throw an exception.\n *\n * @param {any} source The object to stringify\n * @return {string} The serialized output.\n */\nexport function safeJSONStringify(source: any): string {\n try {\n return JSON.stringify(source);\n } catch (e) {\n return JSON.stringify(decycleObject(source));\n }\n}\n","import {\n ChannelAuthorizationOptions,\n UserAuthenticationOptions\n} from './auth/options';\nimport { AuthTransport } from './config';\n\nexport interface DefaultConfig {\n VERSION: string;\n PROTOCOL: number;\n wsPort: number;\n wssPort: number;\n wsPath: string;\n httpHost: string;\n httpPort: number;\n httpsPort: number;\n httpPath: string;\n stats_host: string;\n authEndpoint: string;\n authTransport: AuthTransport;\n activityTimeout: number;\n pongTimeout: number;\n unavailableTimeout: number;\n userAuthentication: UserAuthenticationOptions;\n channelAuthorization: ChannelAuthorizationOptions;\n\n cdn_http?: string;\n cdn_https?: string;\n dependency_suffix?: string;\n}\n\nvar Defaults: DefaultConfig = {\n VERSION: VERSION,\n PROTOCOL: 7,\n\n wsPort: 80,\n wssPort: 443,\n wsPath: '',\n // DEPRECATED: SockJS fallback parameters\n httpHost: 'sockjs.pusher.com',\n httpPort: 80,\n httpsPort: 443,\n httpPath: '/pusher',\n // DEPRECATED: Stats\n stats_host: 'stats.pusher.com',\n // DEPRECATED: Other settings\n authEndpoint: '/pusher/auth',\n authTransport: 'ajax',\n activityTimeout: 120000,\n pongTimeout: 30000,\n unavailableTimeout: 10000,\n userAuthentication: {\n endpoint: '/pusher/user-auth',\n transport: 'ajax'\n },\n channelAuthorization: {\n endpoint: '/pusher/auth',\n transport: 'ajax'\n },\n\n // CDN configuration\n cdn_http: CDN_HTTP,\n cdn_https: CDN_HTTPS,\n dependency_suffix: DEPENDENCY_SUFFIX\n};\n\nexport default Defaults;\n","import Defaults from '../defaults';\nimport { default as URLScheme, URLSchemeParams } from './url_scheme';\n\nfunction getGenericURL(\n baseScheme: string,\n params: URLSchemeParams,\n path: string\n): string {\n var scheme = baseScheme + (params.useTLS ? 's' : '');\n var host = params.useTLS ? params.hostTLS : params.hostNonTLS;\n return scheme + '://' + host + path;\n}\n\nfunction getGenericPath(key: string, queryString?: string): string {\n var path = '/app/' + key;\n var query =\n '?protocol=' +\n Defaults.PROTOCOL +\n '&client=js' +\n '&version=' +\n Defaults.VERSION +\n (queryString ? '&' + queryString : '');\n return path + query;\n}\n\nexport var ws: URLScheme = {\n getInitial: function(key: string, params: URLSchemeParams): string {\n var path = (params.httpPath || '') + getGenericPath(key, 'flash=false');\n return getGenericURL('ws', params, path);\n }\n};\n\nexport var http: URLScheme = {\n getInitial: function(key: string, params: URLSchemeParams): string {\n var path = (params.httpPath || '/pusher') + getGenericPath(key);\n return getGenericURL('http', params, path);\n }\n};\n\nexport var sockjs: URLScheme = {\n getInitial: function(key: string, params: URLSchemeParams): string {\n return getGenericURL('http', params, params.httpPath || '/pusher');\n },\n getPath: function(key: string, params: URLSchemeParams): string {\n return getGenericPath(key);\n }\n};\n","import Callback from './callback';\nimport * as Collections from '../utils/collections';\nimport CallbackTable from './callback_table';\n\nexport default class CallbackRegistry {\n _callbacks: CallbackTable;\n\n constructor() {\n this._callbacks = {};\n }\n\n get(name: string): Callback[] {\n return this._callbacks[prefix(name)];\n }\n\n add(name: string, callback: Function, context: any) {\n var prefixedEventName = prefix(name);\n this._callbacks[prefixedEventName] =\n this._callbacks[prefixedEventName] || [];\n this._callbacks[prefixedEventName].push({\n fn: callback,\n context: context\n });\n }\n\n remove(name?: string, callback?: Function, context?: any) {\n if (!name && !callback && !context) {\n this._callbacks = {};\n return;\n }\n\n var names = name ? [prefix(name)] : Collections.keys(this._callbacks);\n\n if (callback || context) {\n this.removeCallback(names, callback, context);\n } else {\n this.removeAllCallbacks(names);\n }\n }\n\n private removeCallback(names: string[], callback: Function, context: any) {\n Collections.apply(\n names,\n function(name) {\n this._callbacks[name] = Collections.filter(\n this._callbacks[name] || [],\n function(binding) {\n return (\n (callback && callback !== binding.fn) ||\n (context && context !== binding.context)\n );\n }\n );\n if (this._callbacks[name].length === 0) {\n delete this._callbacks[name];\n }\n },\n this\n );\n }\n\n private removeAllCallbacks(names: string[]) {\n Collections.apply(\n names,\n function(name) {\n delete this._callbacks[name];\n },\n this\n );\n }\n}\n\nfunction prefix(name: string): string {\n return '_' + name;\n}\n","import * as Collections from '../utils/collections';\nimport Callback from './callback';\nimport Metadata from '../channels/metadata';\nimport CallbackRegistry from './callback_registry';\n\n/** Manages callback bindings and event emitting.\n *\n * @param Function failThrough called when no listeners are bound to an event\n */\nexport default class Dispatcher {\n callbacks: CallbackRegistry;\n global_callbacks: Function[];\n failThrough: Function;\n\n constructor(failThrough?: Function) {\n this.callbacks = new CallbackRegistry();\n this.global_callbacks = [];\n this.failThrough = failThrough;\n }\n\n bind(eventName: string, callback: Function, context?: any) {\n this.callbacks.add(eventName, callback, context);\n return this;\n }\n\n bind_global(callback: Function) {\n this.global_callbacks.push(callback);\n return this;\n }\n\n unbind(eventName?: string, callback?: Function, context?: any) {\n this.callbacks.remove(eventName, callback, context);\n return this;\n }\n\n unbind_global(callback?: Function) {\n if (!callback) {\n this.global_callbacks = [];\n return this;\n }\n\n this.global_callbacks = Collections.filter(\n this.global_callbacks || [],\n c => c !== callback\n );\n\n return this;\n }\n\n unbind_all() {\n this.unbind();\n this.unbind_global();\n return this;\n }\n\n emit(eventName: string, data?: any, metadata?: Metadata): Dispatcher {\n for (var i = 0; i < this.global_callbacks.length; i++) {\n this.global_callbacks[i](eventName, data);\n }\n\n var callbacks = this.callbacks.get(eventName);\n var args = [];\n\n if (metadata) {\n // if there's a metadata argument, we need to call the callback with both\n // data and metadata regardless of whether data is undefined\n args.push(data, metadata);\n } else if (data) {\n // metadata is undefined, so we only need to call the callback with data\n // if data exists\n args.push(data);\n }\n\n if (callbacks && callbacks.length > 0) {\n for (var i = 0; i < callbacks.length; i++) {\n callbacks[i].fn.apply(callbacks[i].context || global, args);\n }\n } else if (this.failThrough) {\n this.failThrough(eventName, data);\n }\n\n return this;\n }\n}\n","import { stringify } from './utils/collections';\nimport Pusher from './pusher';\n\nclass Logger {\n debug(...args: any[]) {\n this.log(this.globalLog, args);\n }\n\n warn(...args: any[]) {\n this.log(this.globalLogWarn, args);\n }\n\n error(...args: any[]) {\n this.log(this.globalLogError, args);\n }\n\n private globalLog = (message: string) => {\n if (global.console && global.console.log) {\n global.console.log(message);\n }\n };\n\n private globalLogWarn(message: string) {\n if (global.console && global.console.warn) {\n global.console.warn(message);\n } else {\n this.globalLog(message);\n }\n }\n\n private globalLogError(message: string) {\n if (global.console && global.console.error) {\n global.console.error(message);\n } else {\n this.globalLogWarn(message);\n }\n }\n\n private log(\n defaultLoggingFunction: (message: string) => void,\n ...args: any[]\n ) {\n var message = stringify.apply(this, arguments);\n if (Pusher.log) {\n Pusher.log(message);\n } else if (Pusher.logToConsole) {\n const log = defaultLoggingFunction.bind(this);\n log(message);\n }\n }\n}\n\nexport default new Logger();\n","import Util from '../util';\nimport * as Collections from '../utils/collections';\nimport { default as EventsDispatcher } from '../events/dispatcher';\nimport Logger from '../logger';\nimport TransportHooks from './transport_hooks';\nimport Socket from '../socket';\nimport Runtime from 'runtime';\nimport Timeline from '../timeline/timeline';\nimport TransportConnectionOptions from './transport_connection_options';\n\n/** Provides universal API for transport connections.\n *\n * Transport connection is a low-level object that wraps a connection method\n * and exposes a simple evented interface for the connection state and\n * messaging. It does not implement Pusher-specific WebSocket protocol.\n *\n * Additionally, it fetches resources needed for transport to work and exposes\n * an interface for querying transport features.\n *\n * States:\n * - new - initial state after constructing the object\n * - initializing - during initialization phase, usually fetching resources\n * - intialized - ready to establish a connection\n * - connection - when connection is being established\n * - open - when connection ready to be used\n * - closed - after connection was closed be either side\n *\n * Emits:\n * - error - after the connection raised an error\n *\n * Options:\n * - useTLS - whether connection should be over TLS\n * - hostTLS - host to connect to when connection is over TLS\n * - hostNonTLS - host to connect to when connection is over TLS\n *\n * @param {String} key application key\n * @param {Object} options\n */\nexport default class TransportConnection extends EventsDispatcher {\n hooks: TransportHooks;\n name: string;\n priority: number;\n key: string;\n options: TransportConnectionOptions;\n state: string;\n timeline: Timeline;\n activityTimeout: number;\n id: number;\n socket: Socket;\n beforeOpen: Function;\n initialize: Function;\n\n constructor(\n hooks: TransportHooks,\n name: string,\n priority: number,\n key: string,\n options: TransportConnectionOptions\n ) {\n super();\n this.initialize = Runtime.transportConnectionInitializer;\n this.hooks = hooks;\n this.name = name;\n this.priority = priority;\n this.key = key;\n this.options = options;\n\n this.state = 'new';\n this.timeline = options.timeline;\n this.activityTimeout = options.activityTimeout;\n this.id = this.timeline.generateUniqueID();\n }\n\n /** Checks whether the transport handles activity checks by itself.\n *\n * @return {Boolean}\n */\n handlesActivityChecks(): boolean {\n return Boolean(this.hooks.handlesActivityChecks);\n }\n\n /** Checks whether the transport supports the ping/pong API.\n *\n * @return {Boolean}\n */\n supportsPing(): boolean {\n return Boolean(this.hooks.supportsPing);\n }\n\n /** Tries to establish a connection.\n *\n * @returns {Boolean} false if transport is in invalid state\n */\n connect(): boolean {\n if (this.socket || this.state !== 'initialized') {\n return false;\n }\n\n var url = this.hooks.urls.getInitial(this.key, this.options);\n try {\n this.socket = this.hooks.getSocket(url, this.options);\n } catch (e) {\n Util.defer(() => {\n this.onError(e);\n this.changeState('closed');\n });\n return false;\n }\n\n this.bindListeners();\n\n Logger.debug('Connecting', { transport: this.name, url });\n this.changeState('connecting');\n return true;\n }\n\n /** Closes the connection.\n *\n * @return {Boolean} true if there was a connection to close\n */\n close(): boolean {\n if (this.socket) {\n this.socket.close();\n return true;\n } else {\n return false;\n }\n }\n\n /** Sends data over the open connection.\n *\n * @param {String} data\n * @return {Boolean} true only when in the \"open\" state\n */\n send(data: any): boolean {\n if (this.state === 'open') {\n // Workaround for MobileSafari bug (see https://gist.github.com/2052006)\n Util.defer(() => {\n if (this.socket) {\n this.socket.send(data);\n }\n });\n return true;\n } else {\n return false;\n }\n }\n\n /** Sends a ping if the connection is open and transport supports it. */\n ping() {\n if (this.state === 'open' && this.supportsPing()) {\n this.socket.ping();\n }\n }\n\n private onOpen() {\n if (this.hooks.beforeOpen) {\n this.hooks.beforeOpen(\n this.socket,\n this.hooks.urls.getPath(this.key, this.options)\n );\n }\n this.changeState('open');\n this.socket.onopen = undefined;\n }\n\n private onError(error) {\n this.emit('error', { type: 'WebSocketError', error: error });\n this.timeline.error(this.buildTimelineMessage({ error: error.toString() }));\n }\n\n private onClose(closeEvent?: any) {\n if (closeEvent) {\n this.changeState('closed', {\n code: closeEvent.code,\n reason: closeEvent.reason,\n wasClean: closeEvent.wasClean\n });\n } else {\n this.changeState('closed');\n }\n this.unbindListeners();\n this.socket = undefined;\n }\n\n private onMessage(message) {\n this.emit('message', message);\n }\n\n private onActivity() {\n this.emit('activity');\n }\n\n private bindListeners() {\n this.socket.onopen = () => {\n this.onOpen();\n };\n this.socket.onerror = error => {\n this.onError(error);\n };\n this.socket.onclose = closeEvent => {\n this.onClose(closeEvent);\n };\n this.socket.onmessage = message => {\n this.onMessage(message);\n };\n\n if (this.supportsPing()) {\n this.socket.onactivity = () => {\n this.onActivity();\n };\n }\n }\n\n private unbindListeners() {\n if (this.socket) {\n this.socket.onopen = undefined;\n this.socket.onerror = undefined;\n this.socket.onclose = undefined;\n this.socket.onmessage = undefined;\n if (this.supportsPing()) {\n this.socket.onactivity = undefined;\n }\n }\n }\n\n private changeState(state: string, params?: any) {\n this.state = state;\n this.timeline.info(\n this.buildTimelineMessage({\n state: state,\n params: params\n })\n );\n this.emit(state, params);\n }\n\n buildTimelineMessage(message): any {\n return Collections.extend({ cid: this.id }, message);\n }\n}\n","import Factory from '../utils/factory';\nimport TransportHooks from './transport_hooks';\nimport TransportConnection from './transport_connection';\nimport TransportConnectionOptions from './transport_connection_options';\n\n/** Provides interface for transport connection instantiation.\n *\n * Takes transport-specific hooks as the only argument, which allow checking\n * for transport support and creating its connections.\n *\n * Supported hooks: * - file - the name of the file to be fetched during initialization\n * - urls - URL scheme to be used by transport\n * - handlesActivityCheck - true when the transport handles activity checks\n * - supportsPing - true when the transport has a ping/activity API\n * - isSupported - tells whether the transport is supported in the environment\n * - getSocket - creates a WebSocket-compatible transport socket\n *\n * See transports.js for specific implementations.\n *\n * @param {Object} hooks object containing all needed transport hooks\n */\nexport default class Transport {\n hooks: TransportHooks;\n\n constructor(hooks: TransportHooks) {\n this.hooks = hooks;\n }\n\n /** Returns whether the transport is supported in the environment.\n *\n * @param {Object} envronment te environment details (encryption, settings)\n * @returns {Boolean} true when the transport is supported\n */\n isSupported(environment: any): boolean {\n return this.hooks.isSupported(environment);\n }\n\n /** Creates a transport connection.\n *\n * @param {String} name\n * @param {Number} priority\n * @param {String} key the application key\n * @param {Object} options\n * @returns {TransportConnection}\n */\n createConnection(\n name: string,\n priority: number,\n key: string,\n options: any\n ): TransportConnection {\n return new TransportConnection(this.hooks, name, priority, key, options);\n }\n}\n","import * as URLSchemes from 'core/transports/url_schemes';\nimport URLScheme from 'core/transports/url_scheme';\nimport Transport from 'core/transports/transport';\nimport Util from 'core/util';\nimport * as Collections from 'core/utils/collections';\nimport TransportHooks from 'core/transports/transport_hooks';\nimport TransportsTable from 'core/transports/transports_table';\nimport Runtime from 'runtime';\n\n/** WebSocket transport.\n *\n * Uses native WebSocket implementation, including MozWebSocket supported by\n * earlier Firefox versions.\n */\nvar WSTransport = new Transport({\n urls: URLSchemes.ws,\n handlesActivityChecks: false,\n supportsPing: false,\n\n isInitialized: function() {\n return Boolean(Runtime.getWebSocketAPI());\n },\n isSupported: function(): boolean {\n return Boolean(Runtime.getWebSocketAPI());\n },\n getSocket: function(url) {\n return Runtime.createWebSocket(url);\n }\n});\n\nvar httpConfiguration = {\n urls: URLSchemes.http,\n handlesActivityChecks: false,\n supportsPing: true,\n isInitialized: function() {\n return true;\n }\n};\n\nexport var streamingConfiguration = Collections.extend(\n {\n getSocket: function(url) {\n return Runtime.HTTPFactory.createStreamingSocket(url);\n }\n },\n httpConfiguration\n);\nexport var pollingConfiguration = Collections.extend(\n {\n getSocket: function(url) {\n return Runtime.HTTPFactory.createPollingSocket(url);\n }\n },\n httpConfiguration\n);\n\nvar xhrConfiguration = {\n isSupported: function(): boolean {\n return Runtime.isXHRSupported();\n }\n};\n\n/** HTTP streaming transport using CORS-enabled XMLHttpRequest. */\nvar XHRStreamingTransport = new Transport(\n (\n Collections.extend({}, streamingConfiguration, xhrConfiguration)\n )\n);\n\n/** HTTP long-polling transport using CORS-enabled XMLHttpRequest. */\nvar XHRPollingTransport = new Transport(\n Collections.extend({}, pollingConfiguration, xhrConfiguration)\n);\n\nvar Transports: TransportsTable = {\n ws: WSTransport,\n xhr_streaming: XHRStreamingTransport,\n xhr_polling: XHRPollingTransport\n};\n\nexport default Transports;\n","import Util from '../util';\nimport * as Collections from '../utils/collections';\nimport TransportManager from './transport_manager';\nimport TransportConnection from './transport_connection';\nimport Transport from './transport';\nimport PingDelayOptions from './ping_delay_options';\n\n/** Creates transport connections monitored by a transport manager.\n *\n * When a transport is closed, it might mean the environment does not support\n * it. It's possible that messages get stuck in an intermediate buffer or\n * proxies terminate inactive connections. To combat these problems,\n * assistants monitor the connection lifetime, report unclean exits and\n * adjust ping timeouts to keep the connection active. The decision to disable\n * a transport is the manager's responsibility.\n *\n * @param {TransportManager} manager\n * @param {TransportConnection} transport\n * @param {Object} options\n */\nexport default class AssistantToTheTransportManager {\n manager: TransportManager;\n transport: Transport;\n minPingDelay: number;\n maxPingDelay: number;\n pingDelay: number;\n\n constructor(\n manager: TransportManager,\n transport: Transport,\n options: PingDelayOptions\n ) {\n this.manager = manager;\n this.transport = transport;\n this.minPingDelay = options.minPingDelay;\n this.maxPingDelay = options.maxPingDelay;\n this.pingDelay = undefined;\n }\n\n /** Creates a transport connection.\n *\n * This function has the same API as Transport#createConnection.\n *\n * @param {String} name\n * @param {Number} priority\n * @param {String} key the application key\n * @param {Object} options\n * @returns {TransportConnection}\n */\n createConnection(\n name: string,\n priority: number,\n key: string,\n options: Object\n ): TransportConnection {\n options = Collections.extend({}, options, {\n activityTimeout: this.pingDelay\n });\n var connection = this.transport.createConnection(\n name,\n priority,\n key,\n options\n );\n\n var openTimestamp = null;\n\n var onOpen = function() {\n connection.unbind('open', onOpen);\n connection.bind('closed', onClosed);\n openTimestamp = Util.now();\n };\n var onClosed = closeEvent => {\n connection.unbind('closed', onClosed);\n\n if (closeEvent.code === 1002 || closeEvent.code === 1003) {\n // we don't want to use transports not obeying the protocol\n this.manager.reportDeath();\n } else if (!closeEvent.wasClean && openTimestamp) {\n // report deaths only for short-living transport\n var lifespan = Util.now() - openTimestamp;\n if (lifespan < 2 * this.maxPingDelay) {\n this.manager.reportDeath();\n this.pingDelay = Math.max(lifespan / 2, this.minPingDelay);\n }\n }\n };\n\n connection.bind('open', onOpen);\n return connection;\n }\n\n /** Returns whether the transport is supported in the environment.\n *\n * This function has the same API as Transport#isSupported. Might return false\n * when the manager decides to kill the transport.\n *\n * @param {Object} environment the environment details (encryption, settings)\n * @returns {Boolean} true when the transport is supported\n */\n isSupported(environment: string): boolean {\n return this.manager.isAlive() && this.transport.isSupported(environment);\n }\n}\n","import Action from './action';\nimport { PusherEvent } from './message-types';\n/**\n * Provides functions for handling Pusher protocol-specific messages.\n */\n\nconst Protocol = {\n /**\n * Decodes a message in a Pusher format.\n *\n * The MessageEvent we receive from the transport should contain a pusher event\n * (https://pusher.com/docs/pusher_protocol#events) serialized as JSON in the\n * data field\n *\n * The pusher event may contain a data field too, and it may also be\n * serialised as JSON\n *\n * Throws errors when messages are not parse'able.\n *\n * @param {MessageEvent} messageEvent\n * @return {PusherEvent}\n */\n decodeMessage: function(messageEvent: MessageEvent): PusherEvent {\n try {\n var messageData = JSON.parse(messageEvent.data);\n var pusherEventData = messageData.data;\n if (typeof pusherEventData === 'string') {\n try {\n pusherEventData = JSON.parse(messageData.data);\n } catch (e) {}\n }\n var pusherEvent: PusherEvent = {\n event: messageData.event,\n channel: messageData.channel,\n data: pusherEventData\n };\n if (messageData.user_id) {\n pusherEvent.user_id = messageData.user_id;\n }\n return pusherEvent;\n } catch (e) {\n throw { type: 'MessageParseError', error: e, data: messageEvent.data };\n }\n },\n\n /**\n * Encodes a message to be sent.\n *\n * @param {PusherEvent} event\n * @return {String}\n */\n encodeMessage: function(event: PusherEvent): string {\n return JSON.stringify(event);\n },\n\n /**\n * Processes a handshake message and returns appropriate actions.\n *\n * Returns an object with an 'action' and other action-specific properties.\n *\n * There are three outcomes when calling this function. First is a successful\n * connection attempt, when pusher:connection_established is received, which\n * results in a 'connected' action with an 'id' property. When passed a\n * pusher:error event, it returns a result with action appropriate to the\n * close code and an error. Otherwise, it raises an exception.\n *\n * @param {String} message\n * @result Object\n */\n processHandshake: function(messageEvent: MessageEvent): Action {\n var message = Protocol.decodeMessage(messageEvent);\n\n if (message.event === 'pusher:connection_established') {\n if (!message.data.activity_timeout) {\n throw 'No activity timeout specified in handshake';\n }\n return {\n action: 'connected',\n id: message.data.socket_id,\n activityTimeout: message.data.activity_timeout * 1000\n };\n } else if (message.event === 'pusher:error') {\n // From protocol 6 close codes are sent only once, so this only\n // happens when connection does not support close codes\n return {\n action: this.getCloseAction(message.data),\n error: this.getCloseError(message.data)\n };\n } else {\n throw 'Invalid handshake';\n }\n },\n\n /**\n * Dispatches the close event and returns an appropriate action name.\n *\n * See:\n * 1. https://developer.mozilla.org/en-US/docs/WebSockets/WebSockets_reference/CloseEvent\n * 2. http://pusher.com/docs/pusher_protocol\n *\n * @param {CloseEvent} closeEvent\n * @return {String} close action name\n */\n getCloseAction: function(closeEvent): string {\n if (closeEvent.code < 4000) {\n // ignore 1000 CLOSE_NORMAL, 1001 CLOSE_GOING_AWAY,\n // 1005 CLOSE_NO_STATUS, 1006 CLOSE_ABNORMAL\n // ignore 1007...3999\n // handle 1002 CLOSE_PROTOCOL_ERROR, 1003 CLOSE_UNSUPPORTED,\n // 1004 CLOSE_TOO_LARGE\n if (closeEvent.code >= 1002 && closeEvent.code <= 1004) {\n return 'backoff';\n } else {\n return null;\n }\n } else if (closeEvent.code === 4000) {\n return 'tls_only';\n } else if (closeEvent.code < 4100) {\n return 'refused';\n } else if (closeEvent.code < 4200) {\n return 'backoff';\n } else if (closeEvent.code < 4300) {\n return 'retry';\n } else {\n // unknown error\n return 'refused';\n }\n },\n\n /**\n * Returns an error or null basing on the close event.\n *\n * Null is returned when connection was closed cleanly. Otherwise, an object\n * with error details is returned.\n *\n * @param {CloseEvent} closeEvent\n * @return {Object} error object\n */\n getCloseError: function(closeEvent): any {\n if (closeEvent.code !== 1000 && closeEvent.code !== 1001) {\n return {\n type: 'PusherError',\n data: {\n code: closeEvent.code,\n message: closeEvent.reason || closeEvent.message\n }\n };\n } else {\n return null;\n }\n }\n};\n\nexport default Protocol;\n","import * as Collections from '../utils/collections';\nimport { default as EventsDispatcher } from '../events/dispatcher';\nimport Protocol from './protocol/protocol';\nimport { PusherEvent } from './protocol/message-types';\nimport Logger from '../logger';\nimport TransportConnection from '../transports/transport_connection';\nimport Socket from '../socket';\n/**\n * Provides Pusher protocol interface for transports.\n *\n * Emits following events:\n * - message - on received messages\n * - ping - on ping requests\n * - pong - on pong responses\n * - error - when the transport emits an error\n * - closed - after closing the transport\n *\n * It also emits more events when connection closes with a code.\n * See Protocol.getCloseAction to get more details.\n *\n * @param {Number} id\n * @param {AbstractTransport} transport\n */\nexport default class Connection extends EventsDispatcher implements Socket {\n id: string;\n transport: TransportConnection;\n activityTimeout: number;\n\n constructor(id: string, transport: TransportConnection) {\n super();\n this.id = id;\n this.transport = transport;\n this.activityTimeout = transport.activityTimeout;\n this.bindListeners();\n }\n\n /** Returns whether used transport handles activity checks by itself\n *\n * @returns {Boolean} true if activity checks are handled by the transport\n */\n handlesActivityChecks() {\n return this.transport.handlesActivityChecks();\n }\n\n /** Sends raw data.\n *\n * @param {String} data\n */\n send(data: any): boolean {\n return this.transport.send(data);\n }\n\n /** Sends an event.\n *\n * @param {String} name\n * @param {String} data\n * @param {String} [channel]\n * @returns {Boolean} whether message was sent or not\n */\n send_event(name: string, data: any, channel?: string): boolean {\n var event: PusherEvent = { event: name, data: data };\n if (channel) {\n event.channel = channel;\n }\n Logger.debug('Event sent', event);\n return this.send(Protocol.encodeMessage(event));\n }\n\n /** Sends a ping message to the server.\n *\n * Basing on the underlying transport, it might send either transport's\n * protocol-specific ping or pusher:ping event.\n */\n ping() {\n if (this.transport.supportsPing()) {\n this.transport.ping();\n } else {\n this.send_event('pusher:ping', {});\n }\n }\n\n /** Closes the connection. */\n close() {\n this.transport.close();\n }\n\n private bindListeners() {\n var listeners = {\n message: (messageEvent: MessageEvent) => {\n var pusherEvent;\n try {\n pusherEvent = Protocol.decodeMessage(messageEvent);\n } catch (e) {\n this.emit('error', {\n type: 'MessageParseError',\n error: e,\n data: messageEvent.data\n });\n }\n\n if (pusherEvent !== undefined) {\n Logger.debug('Event recd', pusherEvent);\n\n switch (pusherEvent.event) {\n case 'pusher:error':\n this.emit('error', {\n type: 'PusherError',\n data: pusherEvent.data\n });\n break;\n case 'pusher:ping':\n this.emit('ping');\n break;\n case 'pusher:pong':\n this.emit('pong');\n break;\n }\n this.emit('message', pusherEvent);\n }\n },\n activity: () => {\n this.emit('activity');\n },\n error: error => {\n this.emit('error', error);\n },\n closed: closeEvent => {\n unbindListeners();\n\n if (closeEvent && closeEvent.code) {\n this.handleCloseEvent(closeEvent);\n }\n\n this.transport = null;\n this.emit('closed');\n }\n };\n\n var unbindListeners = () => {\n Collections.objectApply(listeners, (listener, event) => {\n this.transport.unbind(event, listener);\n });\n };\n\n Collections.objectApply(listeners, (listener, event) => {\n this.transport.bind(event, listener);\n });\n }\n\n private handleCloseEvent(closeEvent: any) {\n var action = Protocol.getCloseAction(closeEvent);\n var error = Protocol.getCloseError(closeEvent);\n if (error) {\n this.emit('error', error);\n }\n if (action) {\n this.emit(action, { action: action, error: error });\n }\n }\n}\n","import Util from '../../util';\nimport * as Collections from '../../utils/collections';\nimport Protocol from '../protocol/protocol';\nimport Connection from '../connection';\nimport TransportConnection from '../../transports/transport_connection';\nimport HandshakePayload from './handshake_payload';\n\n/**\n * Handles Pusher protocol handshakes for transports.\n *\n * Calls back with a result object after handshake is completed. Results\n * always have two fields:\n * - action - string describing action to be taken after the handshake\n * - transport - the transport object passed to the constructor\n *\n * Different actions can set different additional properties on the result.\n * In the case of 'connected' action, there will be a 'connection' property\n * containing a Connection object for the transport. Other actions should\n * carry an 'error' property.\n *\n * @param {AbstractTransport} transport\n * @param {Function} callback\n */\nexport default class Handshake {\n transport: TransportConnection;\n callback: (HandshakePayload) => void;\n onMessage: Function;\n onClosed: Function;\n\n constructor(\n transport: TransportConnection,\n callback: (HandshakePayload) => void\n ) {\n this.transport = transport;\n this.callback = callback;\n this.bindListeners();\n }\n\n close() {\n this.unbindListeners();\n this.transport.close();\n }\n\n private bindListeners() {\n this.onMessage = m => {\n this.unbindListeners();\n\n var result;\n try {\n result = Protocol.processHandshake(m);\n } catch (e) {\n this.finish('error', { error: e });\n this.transport.close();\n return;\n }\n\n if (result.action === 'connected') {\n this.finish('connected', {\n connection: new Connection(result.id, this.transport),\n activityTimeout: result.activityTimeout\n });\n } else {\n this.finish(result.action, { error: result.error });\n this.transport.close();\n }\n };\n\n this.onClosed = closeEvent => {\n this.unbindListeners();\n\n var action = Protocol.getCloseAction(closeEvent) || 'backoff';\n var error = Protocol.getCloseError(closeEvent);\n this.finish(action, { error: error });\n };\n\n this.transport.bind('message', this.onMessage);\n this.transport.bind('closed', this.onClosed);\n }\n\n private unbindListeners() {\n this.transport.unbind('message', this.onMessage);\n this.transport.unbind('closed', this.onClosed);\n }\n\n private finish(action: string, params: any) {\n this.callback(\n Collections.extend({ transport: this.transport, action: action }, params)\n );\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport base64encode from '../base64';\nimport Timeline from './timeline';\nimport Runtime from 'runtime';\n\nexport interface TimelineSenderOptions {\n host?: string;\n port?: number;\n path?: string;\n}\n\nexport default class TimelineSender {\n timeline: Timeline;\n options: TimelineSenderOptions;\n host: string;\n\n constructor(timeline: Timeline, options: TimelineSenderOptions) {\n this.timeline = timeline;\n this.options = options || {};\n }\n\n send(useTLS: boolean, callback?: Function) {\n if (this.timeline.isEmpty()) {\n return;\n }\n\n this.timeline.send(\n Runtime.TimelineTransport.getAgent(this, useTLS),\n callback\n );\n }\n}\n","/** Error classes used throughout the library. */\n// https://github.com/Microsoft/TypeScript-wiki/blob/master/Breaking-Changes.md#extending-built-ins-like-error-array-and-map-may-no-longer-work\nexport class BadEventName extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\nexport class BadChannelName extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\nexport class RequestTimedOut extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class TransportPriorityTooLow extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class TransportClosed extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class UnsupportedFeature extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class UnsupportedTransport extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class UnsupportedStrategy extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class HTTPAuthError extends Error {\n status: number;\n constructor(status: number, msg?: string) {\n super(msg);\n this.status = status;\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n","/**\n * A place to store help URLs for error messages etc\n */\n\nconst urlStore = {\n baseUrl: 'https://pusher.com',\n urls: {\n authenticationEndpoint: {\n path: '/docs/channels/server_api/authenticating_users'\n },\n authorizationEndpoint: {\n path: '/docs/channels/server_api/authorizing-users/'\n },\n javascriptQuickStart: {\n path: '/docs/javascript_quick_start'\n },\n triggeringClientEvents: {\n path: '/docs/client_api_guide/client_events#trigger-events'\n },\n encryptedChannelSupport: {\n fullUrl:\n 'https://github.com/pusher/pusher-js/tree/cc491015371a4bde5743d1c87a0fbac0feb53195#encrypted-channel-support'\n }\n }\n};\n\n/** Builds a consistent string with links to pusher documentation\n *\n * @param {string} key - relevant key in the url_store.urls object\n * @return {string} suffix string to append to log message\n */\nconst buildLogSuffix = function(key: string): string {\n const urlPrefix = 'See:';\n const urlObj = urlStore.urls[key];\n if (!urlObj) return '';\n\n let url;\n if (urlObj.fullUrl) {\n url = urlObj.fullUrl;\n } else if (urlObj.path) {\n url = urlStore.baseUrl + urlObj.path;\n }\n\n if (!url) return '';\n return `${urlPrefix} ${url}`;\n};\n\nexport default { buildLogSuffix };\n","import { default as EventsDispatcher } from '../events/dispatcher';\nimport * as Errors from '../errors';\nimport Logger from '../logger';\nimport Pusher from '../pusher';\nimport { PusherEvent } from '../connection/protocol/message-types';\nimport Metadata from './metadata';\nimport UrlStore from '../utils/url_store';\nimport {\n ChannelAuthorizationData,\n ChannelAuthorizationCallback\n} from '../auth/options';\nimport { HTTPAuthError } from '../errors';\n\n/** Provides base public channel interface with an event emitter.\n *\n * Emits:\n * - pusher:subscription_succeeded - after subscribing successfully\n * - other non-internal events\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\nexport default class Channel extends EventsDispatcher {\n name: string;\n pusher: Pusher;\n subscribed: boolean;\n subscriptionPending: boolean;\n subscriptionCancelled: boolean;\n subscriptionCount: null;\n\n constructor(name: string, pusher: Pusher) {\n super(function(event, data) {\n Logger.debug('No callbacks on ' + name + ' for ' + event);\n });\n\n this.name = name;\n this.pusher = pusher;\n this.subscribed = false;\n this.subscriptionPending = false;\n this.subscriptionCancelled = false;\n }\n\n /** Skips authorization, since public channels don't require it.\n *\n * @param {Function} callback\n */\n authorize(socketId: string, callback: ChannelAuthorizationCallback) {\n return callback(null, { auth: '' });\n }\n\n /** Triggers an event */\n trigger(event: string, data: any) {\n if (event.indexOf('client-') !== 0) {\n throw new Errors.BadEventName(\n \"Event '\" + event + \"' does not start with 'client-'\"\n );\n }\n if (!this.subscribed) {\n var suffix = UrlStore.buildLogSuffix('triggeringClientEvents');\n Logger.warn(\n `Client event triggered before channel 'subscription_succeeded' event . ${suffix}`\n );\n }\n return this.pusher.send_event(event, data, this.name);\n }\n\n /** Signals disconnection to the channel. For internal use only. */\n disconnect() {\n this.subscribed = false;\n this.subscriptionPending = false;\n }\n\n /** Handles a PusherEvent. For internal use only.\n *\n * @param {PusherEvent} event\n */\n handleEvent(event: PusherEvent) {\n var eventName = event.event;\n var data = event.data;\n if (eventName === 'pusher_internal:subscription_succeeded') {\n this.handleSubscriptionSucceededEvent(event);\n } else if (eventName === 'pusher_internal:subscription_count') {\n this.handleSubscriptionCountEvent(event);\n } else if (eventName.indexOf('pusher_internal:') !== 0) {\n var metadata: Metadata = {};\n this.emit(eventName, data, metadata);\n }\n }\n\n handleSubscriptionSucceededEvent(event: PusherEvent) {\n this.subscriptionPending = false;\n this.subscribed = true;\n if (this.subscriptionCancelled) {\n this.pusher.unsubscribe(this.name);\n } else {\n this.emit('pusher:subscription_succeeded', event.data);\n }\n }\n\n handleSubscriptionCountEvent(event: PusherEvent) {\n if (event.data.subscription_count) {\n this.subscriptionCount = event.data.subscription_count;\n }\n\n this.emit('pusher:subscription_count', event.data);\n }\n\n /** Sends a subscription request. For internal use only. */\n subscribe() {\n if (this.subscribed) {\n return;\n }\n this.subscriptionPending = true;\n this.subscriptionCancelled = false;\n this.authorize(\n this.pusher.connection.socket_id,\n (error: Error | null, data: ChannelAuthorizationData) => {\n if (error) {\n this.subscriptionPending = false;\n // Why not bind to 'pusher:subscription_error' a level up, and log there?\n // Binding to this event would cause the warning about no callbacks being\n // bound (see constructor) to be suppressed, that's not what we want.\n Logger.error(error.toString());\n this.emit(\n 'pusher:subscription_error',\n Object.assign(\n {},\n {\n type: 'AuthError',\n error: error.message\n },\n error instanceof HTTPAuthError ? { status: error.status } : {}\n )\n );\n } else {\n this.pusher.send_event('pusher:subscribe', {\n auth: data.auth,\n channel_data: data.channel_data,\n channel: this.name\n });\n }\n }\n );\n }\n\n /** Sends an unsubscription request. For internal use only. */\n unsubscribe() {\n this.subscribed = false;\n this.pusher.send_event('pusher:unsubscribe', {\n channel: this.name\n });\n }\n\n /** Cancels an in progress subscription. For internal use only. */\n cancelSubscription() {\n this.subscriptionCancelled = true;\n }\n\n /** Reinstates an in progress subscripiton. For internal use only. */\n reinstateSubscription() {\n this.subscriptionCancelled = false;\n }\n}\n","import Factory from '../utils/factory';\nimport Channel from './channel';\nimport { ChannelAuthorizationCallback } from '../auth/options';\n\n/** Extends public channels to provide private channel interface.\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\nexport default class PrivateChannel extends Channel {\n /** Authorizes the connection to use the channel.\n *\n * @param {String} socketId\n * @param {Function} callback\n */\n authorize(socketId: string, callback: ChannelAuthorizationCallback) {\n return this.pusher.config.channelAuthorizer(\n {\n channelName: this.name,\n socketId: socketId\n },\n callback\n );\n }\n}\n","import * as Collections from '../utils/collections';\n\n/** Represents a collection of members of a presence channel. */\nexport default class Members {\n members: any;\n count: number;\n myID: any;\n me: any;\n\n constructor() {\n this.reset();\n }\n\n /** Returns member's info for given id.\n *\n * Resulting object containts two fields - id and info.\n *\n * @param {Number} id\n * @return {Object} member's info or null\n */\n get(id: string): any {\n if (Object.prototype.hasOwnProperty.call(this.members, id)) {\n return {\n id: id,\n info: this.members[id]\n };\n } else {\n return null;\n }\n }\n\n /** Calls back for each member in unspecified order.\n *\n * @param {Function} callback\n */\n each(callback: Function) {\n Collections.objectApply(this.members, (member, id) => {\n callback(this.get(id));\n });\n }\n\n /** Updates the id for connected member. For internal use only. */\n setMyID(id: string) {\n this.myID = id;\n }\n\n /** Handles subscription data. For internal use only. */\n onSubscription(subscriptionData: any) {\n this.members = subscriptionData.presence.hash;\n this.count = subscriptionData.presence.count;\n this.me = this.get(this.myID);\n }\n\n /** Adds a new member to the collection. For internal use only. */\n addMember(memberData: any) {\n if (this.get(memberData.user_id) === null) {\n this.count++;\n }\n this.members[memberData.user_id] = memberData.user_info;\n return this.get(memberData.user_id);\n }\n\n /** Adds a member from the collection. For internal use only. */\n removeMember(memberData: any) {\n var member = this.get(memberData.user_id);\n if (member) {\n delete this.members[memberData.user_id];\n this.count--;\n }\n return member;\n }\n\n /** Resets the collection to the initial state. For internal use only. */\n reset() {\n this.members = {};\n this.count = 0;\n this.myID = null;\n this.me = null;\n }\n}\n","import PrivateChannel from './private_channel';\nimport Logger from '../logger';\nimport Members from './members';\nimport Pusher from '../pusher';\nimport UrlStore from 'core/utils/url_store';\nimport { PusherEvent } from '../connection/protocol/message-types';\nimport Metadata from './metadata';\nimport { ChannelAuthorizationData } from '../auth/options';\n\nexport default class PresenceChannel extends PrivateChannel {\n members: Members;\n\n /** Adds presence channel functionality to private channels.\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\n constructor(name: string, pusher: Pusher) {\n super(name, pusher);\n this.members = new Members();\n }\n\n /** Authorizes the connection as a member of the channel.\n *\n * @param {String} socketId\n * @param {Function} callback\n */\n authorize(socketId: string, callback: Function) {\n super.authorize(socketId, async (error, authData) => {\n if (!error) {\n authData = authData as ChannelAuthorizationData;\n if (authData.channel_data != null) {\n var channelData = JSON.parse(authData.channel_data);\n this.members.setMyID(channelData.user_id);\n } else {\n await this.pusher.user.signinDonePromise;\n if (this.pusher.user.user_data != null) {\n // If the user is signed in, get the id of the authenticated user\n // and allow the presence authorization to continue.\n this.members.setMyID(this.pusher.user.user_data.id);\n } else {\n let suffix = UrlStore.buildLogSuffix('authorizationEndpoint');\n Logger.error(\n `Invalid auth response for channel '${this.name}', ` +\n `expected 'channel_data' field. ${suffix}, ` +\n `or the user should be signed in.`\n );\n callback('Invalid auth response');\n return;\n }\n }\n }\n callback(error, authData);\n });\n }\n\n /** Handles presence and subscription events. For internal use only.\n *\n * @param {PusherEvent} event\n */\n handleEvent(event: PusherEvent) {\n var eventName = event.event;\n if (eventName.indexOf('pusher_internal:') === 0) {\n this.handleInternalEvent(event);\n } else {\n var data = event.data;\n var metadata: Metadata = {};\n if (event.user_id) {\n metadata.user_id = event.user_id;\n }\n this.emit(eventName, data, metadata);\n }\n }\n handleInternalEvent(event: PusherEvent) {\n var eventName = event.event;\n var data = event.data;\n switch (eventName) {\n case 'pusher_internal:subscription_succeeded':\n this.handleSubscriptionSucceededEvent(event);\n break;\n case 'pusher_internal:subscription_count':\n this.handleSubscriptionCountEvent(event);\n break;\n case 'pusher_internal:member_added':\n var addedMember = this.members.addMember(data);\n this.emit('pusher:member_added', addedMember);\n break;\n case 'pusher_internal:member_removed':\n var removedMember = this.members.removeMember(data);\n if (removedMember) {\n this.emit('pusher:member_removed', removedMember);\n }\n break;\n }\n }\n\n handleSubscriptionSucceededEvent(event: PusherEvent) {\n this.subscriptionPending = false;\n this.subscribed = true;\n if (this.subscriptionCancelled) {\n this.pusher.unsubscribe(this.name);\n } else {\n this.members.onSubscription(event.data);\n this.emit('pusher:subscription_succeeded', this.members);\n }\n }\n\n /** Resets the channel state, including members map. For internal use only. */\n disconnect() {\n this.members.reset();\n super.disconnect();\n }\n}\n","import PrivateChannel from './private_channel';\nimport * as Errors from '../errors';\nimport Logger from '../logger';\nimport Pusher from '../pusher';\nimport { decode as encodeUTF8 } from '@stablelib/utf8';\nimport { decode as decodeBase64 } from '@stablelib/base64';\nimport Dispatcher from '../events/dispatcher';\nimport { PusherEvent } from '../connection/protocol/message-types';\nimport {\n ChannelAuthorizationData,\n ChannelAuthorizationCallback\n} from '../auth/options';\nimport * as nacl from 'tweetnacl';\n\n/** Extends private channels to provide encrypted channel interface.\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\nexport default class EncryptedChannel extends PrivateChannel {\n key: Uint8Array = null;\n nacl: nacl;\n\n constructor(name: string, pusher: Pusher, nacl: nacl) {\n super(name, pusher);\n this.nacl = nacl;\n }\n\n /** Authorizes the connection to use the channel.\n *\n * @param {String} socketId\n * @param {Function} callback\n */\n authorize(socketId: string, callback: ChannelAuthorizationCallback) {\n super.authorize(\n socketId,\n (error: Error | null, authData: ChannelAuthorizationData) => {\n if (error) {\n callback(error, authData);\n return;\n }\n let sharedSecret = authData['shared_secret'];\n if (!sharedSecret) {\n callback(\n new Error(\n `No shared_secret key in auth payload for encrypted channel: ${this.name}`\n ),\n null\n );\n return;\n }\n this.key = decodeBase64(sharedSecret);\n delete authData['shared_secret'];\n callback(null, authData);\n }\n );\n }\n\n trigger(event: string, data: any): boolean {\n throw new Errors.UnsupportedFeature(\n 'Client events are not currently supported for encrypted channels'\n );\n }\n\n /** Handles an event. For internal use only.\n *\n * @param {PusherEvent} event\n */\n handleEvent(event: PusherEvent) {\n var eventName = event.event;\n var data = event.data;\n if (\n eventName.indexOf('pusher_internal:') === 0 ||\n eventName.indexOf('pusher:') === 0\n ) {\n super.handleEvent(event);\n return;\n }\n this.handleEncryptedEvent(eventName, data);\n }\n\n private handleEncryptedEvent(event: string, data: any): void {\n if (!this.key) {\n Logger.debug(\n 'Received encrypted event before key has been retrieved from the authEndpoint'\n );\n return;\n }\n if (!data.ciphertext || !data.nonce) {\n Logger.error(\n 'Unexpected format for encrypted event, expected object with `ciphertext` and `nonce` fields, got: ' +\n data\n );\n return;\n }\n let cipherText = decodeBase64(data.ciphertext);\n if (cipherText.length < this.nacl.secretbox.overheadLength) {\n Logger.error(\n `Expected encrypted event ciphertext length to be ${this.nacl.secretbox.overheadLength}, got: ${cipherText.length}`\n );\n return;\n }\n let nonce = decodeBase64(data.nonce);\n if (nonce.length < this.nacl.secretbox.nonceLength) {\n Logger.error(\n `Expected encrypted event nonce length to be ${this.nacl.secretbox.nonceLength}, got: ${nonce.length}`\n );\n return;\n }\n\n let bytes = this.nacl.secretbox.open(cipherText, nonce, this.key);\n if (bytes === null) {\n Logger.debug(\n 'Failed to decrypt an event, probably because it was encrypted with a different key. Fetching a new key from the authEndpoint...'\n );\n // Try a single time to retrieve a new auth key and decrypt the event with it\n // If this fails, a new key will be requested when a new message is received\n this.authorize(this.pusher.connection.socket_id, (error, authData) => {\n if (error) {\n Logger.error(\n `Failed to make a request to the authEndpoint: ${authData}. Unable to fetch new key, so dropping encrypted event`\n );\n return;\n }\n bytes = this.nacl.secretbox.open(cipherText, nonce, this.key);\n if (bytes === null) {\n Logger.error(\n `Failed to decrypt event with new key. Dropping encrypted event`\n );\n return;\n }\n this.emit(event, this.getDataToEmit(bytes));\n return;\n });\n return;\n }\n this.emit(event, this.getDataToEmit(bytes));\n }\n\n // Try and parse the decrypted bytes as JSON. If we can't parse it, just\n // return the utf-8 string\n getDataToEmit(bytes: Uint8Array): string {\n let raw = encodeUTF8(bytes);\n try {\n return JSON.parse(raw);\n } catch {\n return raw;\n }\n }\n}\n","import { default as EventsDispatcher } from '../events/dispatcher';\nimport { OneOffTimer as Timer } from '../utils/timers';\nimport { Config } from '../config';\nimport Logger from '../logger';\nimport HandshakePayload from './handshake/handshake_payload';\nimport Connection from './connection';\nimport Strategy from '../strategies/strategy';\nimport StrategyRunner from '../strategies/strategy_runner';\nimport * as Collections from '../utils/collections';\nimport Timeline from '../timeline/timeline';\nimport ConnectionManagerOptions from './connection_manager_options';\nimport Runtime from 'runtime';\n\nimport {\n ErrorCallbacks,\n HandshakeCallbacks,\n ConnectionCallbacks\n} from './callbacks';\nimport Action from './protocol/action';\n\n/** Manages connection to Pusher.\n *\n * Uses a strategy (currently only default), timers and network availability\n * info to establish a connection and export its state. In case of failures,\n * manages reconnection attempts.\n *\n * Exports state changes as following events:\n * - \"state_change\", { previous: p, current: state }\n * - state\n *\n * States:\n * - initialized - initial state, never transitioned to\n * - connecting - connection is being established\n * - connected - connection has been fully established\n * - disconnected - on requested disconnection\n * - unavailable - after connection timeout or when there's no network\n * - failed - when the connection strategy is not supported\n *\n * Options:\n * - unavailableTimeout - time to transition to unavailable state\n * - activityTimeout - time after which ping message should be sent\n * - pongTimeout - time for Pusher to respond with pong before reconnecting\n *\n * @param {String} key application key\n * @param {Object} options\n */\nexport default class ConnectionManager extends EventsDispatcher {\n key: string;\n options: ConnectionManagerOptions;\n state: string;\n connection: Connection;\n usingTLS: boolean;\n timeline: Timeline;\n socket_id: string;\n unavailableTimer: Timer;\n activityTimer: Timer;\n retryTimer: Timer;\n activityTimeout: number;\n strategy: Strategy;\n runner: StrategyRunner;\n errorCallbacks: ErrorCallbacks;\n handshakeCallbacks: HandshakeCallbacks;\n connectionCallbacks: ConnectionCallbacks;\n\n constructor(key: string, options: ConnectionManagerOptions) {\n super();\n this.state = 'initialized';\n this.connection = null;\n\n this.key = key;\n this.options = options;\n this.timeline = this.options.timeline;\n this.usingTLS = this.options.useTLS;\n\n this.errorCallbacks = this.buildErrorCallbacks();\n this.connectionCallbacks = this.buildConnectionCallbacks(\n this.errorCallbacks\n );\n this.handshakeCallbacks = this.buildHandshakeCallbacks(this.errorCallbacks);\n\n var Network = Runtime.getNetwork();\n\n Network.bind('online', () => {\n this.timeline.info({ netinfo: 'online' });\n if (this.state === 'connecting' || this.state === 'unavailable') {\n this.retryIn(0);\n }\n });\n Network.bind('offline', () => {\n this.timeline.info({ netinfo: 'offline' });\n if (this.connection) {\n this.sendActivityCheck();\n }\n });\n\n this.updateStrategy();\n }\n\n switchCluster(key: string) {\n this.key = key;\n // This ensures that the new config coming from\n // pusher instance are taken into account\n // such as appKey and cluster\n this.updateStrategy();\n this.retryIn(0);\n }\n\n /** Establishes a connection to Pusher.\n *\n * Does nothing when connection is already established. See top-level doc\n * to find events emitted on connection attempts.\n */\n connect() {\n if (this.connection || this.runner) {\n return;\n }\n if (!this.strategy.isSupported()) {\n this.updateState('failed');\n return;\n }\n this.updateState('connecting');\n this.startConnecting();\n this.setUnavailableTimer();\n }\n\n /** Sends raw data.\n *\n * @param {String} data\n */\n send(data) {\n if (this.connection) {\n return this.connection.send(data);\n } else {\n return false;\n }\n }\n\n /** Sends an event.\n *\n * @param {String} name\n * @param {String} data\n * @param {String} [channel]\n * @returns {Boolean} whether message was sent or not\n */\n send_event(name: string, data: any, channel?: string) {\n if (this.connection) {\n return this.connection.send_event(name, data, channel);\n } else {\n return false;\n }\n }\n\n /** Closes the connection. */\n disconnect() {\n this.disconnectInternally();\n this.updateState('disconnected');\n }\n\n isUsingTLS() {\n return this.usingTLS;\n }\n\n private startConnecting() {\n var callback = (error, handshake) => {\n if (error) {\n this.runner = this.strategy.connect(0, callback);\n } else {\n if (handshake.action === 'error') {\n this.emit('error', {\n type: 'HandshakeError',\n error: handshake.error\n });\n this.timeline.error({ handshakeError: handshake.error });\n } else {\n this.abortConnecting(); // we don't support switching connections yet\n this.handshakeCallbacks[handshake.action](handshake);\n }\n }\n };\n this.runner = this.strategy.connect(0, callback);\n }\n\n private abortConnecting() {\n if (this.runner) {\n this.runner.abort();\n this.runner = null;\n }\n }\n\n private disconnectInternally() {\n this.abortConnecting();\n this.clearRetryTimer();\n this.clearUnavailableTimer();\n if (this.connection) {\n var connection = this.abandonConnection();\n connection.close();\n }\n }\n\n private updateStrategy() {\n this.strategy = this.options.getStrategy({\n key: this.key,\n timeline: this.timeline,\n useTLS: this.usingTLS\n });\n }\n\n private retryIn(delay) {\n this.timeline.info({ action: 'retry', delay: delay });\n if (delay > 0) {\n this.emit('connecting_in', Math.round(delay / 1000));\n }\n this.retryTimer = new Timer(delay || 0, () => {\n this.disconnectInternally();\n this.connect();\n });\n }\n\n private clearRetryTimer() {\n if (this.retryTimer) {\n this.retryTimer.ensureAborted();\n this.retryTimer = null;\n }\n }\n\n private setUnavailableTimer() {\n this.unavailableTimer = new Timer(this.options.unavailableTimeout, () => {\n this.updateState('unavailable');\n });\n }\n\n private clearUnavailableTimer() {\n if (this.unavailableTimer) {\n this.unavailableTimer.ensureAborted();\n }\n }\n\n private sendActivityCheck() {\n this.stopActivityCheck();\n this.connection.ping();\n // wait for pong response\n this.activityTimer = new Timer(this.options.pongTimeout, () => {\n this.timeline.error({ pong_timed_out: this.options.pongTimeout });\n this.retryIn(0);\n });\n }\n\n private resetActivityCheck() {\n this.stopActivityCheck();\n // send ping after inactivity\n if (this.connection && !this.connection.handlesActivityChecks()) {\n this.activityTimer = new Timer(this.activityTimeout, () => {\n this.sendActivityCheck();\n });\n }\n }\n\n private stopActivityCheck() {\n if (this.activityTimer) {\n this.activityTimer.ensureAborted();\n }\n }\n\n private buildConnectionCallbacks(\n errorCallbacks: ErrorCallbacks\n ): ConnectionCallbacks {\n return Collections.extend({}, errorCallbacks, {\n message: message => {\n // includes pong messages from server\n this.resetActivityCheck();\n this.emit('message', message);\n },\n ping: () => {\n this.send_event('pusher:pong', {});\n },\n activity: () => {\n this.resetActivityCheck();\n },\n error: error => {\n // just emit error to user - socket will already be closed by browser\n this.emit('error', error);\n },\n closed: () => {\n this.abandonConnection();\n if (this.shouldRetry()) {\n this.retryIn(1000);\n }\n }\n });\n }\n\n private buildHandshakeCallbacks(\n errorCallbacks: ErrorCallbacks\n ): HandshakeCallbacks {\n return Collections.extend({}, errorCallbacks, {\n connected: (handshake: HandshakePayload) => {\n this.activityTimeout = Math.min(\n this.options.activityTimeout,\n handshake.activityTimeout,\n handshake.connection.activityTimeout || Infinity\n );\n this.clearUnavailableTimer();\n this.setConnection(handshake.connection);\n this.socket_id = this.connection.id;\n this.updateState('connected', { socket_id: this.socket_id });\n }\n });\n }\n\n private buildErrorCallbacks(): ErrorCallbacks {\n let withErrorEmitted = callback => {\n return (result: Action | HandshakePayload) => {\n if (result.error) {\n this.emit('error', { type: 'WebSocketError', error: result.error });\n }\n callback(result);\n };\n };\n\n return {\n tls_only: withErrorEmitted(() => {\n this.usingTLS = true;\n this.updateStrategy();\n this.retryIn(0);\n }),\n refused: withErrorEmitted(() => {\n this.disconnect();\n }),\n backoff: withErrorEmitted(() => {\n this.retryIn(1000);\n }),\n retry: withErrorEmitted(() => {\n this.retryIn(0);\n })\n };\n }\n\n private setConnection(connection) {\n this.connection = connection;\n for (var event in this.connectionCallbacks) {\n this.connection.bind(event, this.connectionCallbacks[event]);\n }\n this.resetActivityCheck();\n }\n\n private abandonConnection() {\n if (!this.connection) {\n return;\n }\n this.stopActivityCheck();\n for (var event in this.connectionCallbacks) {\n this.connection.unbind(event, this.connectionCallbacks[event]);\n }\n var connection = this.connection;\n this.connection = null;\n return connection;\n }\n\n private updateState(newState: string, data?: any) {\n var previousState = this.state;\n this.state = newState;\n if (previousState !== newState) {\n var newStateDescription = newState;\n if (newStateDescription === 'connected') {\n newStateDescription += ' with new socket ID ' + data.socket_id;\n }\n Logger.debug(\n 'State changed',\n previousState + ' -> ' + newStateDescription\n );\n this.timeline.info({ state: newState, params: data });\n this.emit('state_change', { previous: previousState, current: newState });\n this.emit(newState, data);\n }\n }\n\n private shouldRetry(): boolean {\n return this.state === 'connecting' || this.state === 'connected';\n }\n}\n","import Channel from './channel';\nimport * as Collections from '../utils/collections';\nimport ChannelTable from './channel_table';\nimport Factory from '../utils/factory';\nimport Pusher from '../pusher';\nimport Logger from '../logger';\nimport * as Errors from '../errors';\nimport urlStore from '../utils/url_store';\n\n/** Handles a channel map. */\nexport default class Channels {\n channels: ChannelTable;\n\n constructor() {\n this.channels = {};\n }\n\n /** Creates or retrieves an existing channel by its name.\n *\n * @param {String} name\n * @param {Pusher} pusher\n * @return {Channel}\n */\n add(name: string, pusher: Pusher) {\n if (!this.channels[name]) {\n this.channels[name] = createChannel(name, pusher);\n }\n return this.channels[name];\n }\n\n /** Returns a list of all channels\n *\n * @return {Array}\n */\n all(): Channel[] {\n return Collections.values(this.channels);\n }\n\n /** Finds a channel by its name.\n *\n * @param {String} name\n * @return {Channel} channel or null if it doesn't exist\n */\n find(name: string) {\n return this.channels[name];\n }\n\n /** Removes a channel from the map.\n *\n * @param {String} name\n */\n remove(name: string) {\n var channel = this.channels[name];\n delete this.channels[name];\n return channel;\n }\n\n /** Proxies disconnection signal to all channels. */\n disconnect() {\n Collections.objectApply(this.channels, function(channel) {\n channel.disconnect();\n });\n }\n}\n\nfunction createChannel(name: string, pusher: Pusher): Channel {\n if (name.indexOf('private-encrypted-') === 0) {\n if (pusher.config.nacl) {\n return Factory.createEncryptedChannel(name, pusher, pusher.config.nacl);\n }\n let errMsg =\n 'Tried to subscribe to a private-encrypted- channel but no nacl implementation available';\n let suffix = urlStore.buildLogSuffix('encryptedChannelSupport');\n throw new Errors.UnsupportedFeature(`${errMsg}. ${suffix}`);\n } else if (name.indexOf('private-') === 0) {\n return Factory.createPrivateChannel(name, pusher);\n } else if (name.indexOf('presence-') === 0) {\n return Factory.createPresenceChannel(name, pusher);\n } else if (name.indexOf('#') === 0) {\n throw new Errors.BadChannelName(\n 'Cannot create a channel with name \"' + name + '\".'\n );\n } else {\n return Factory.createChannel(name, pusher);\n }\n}\n","import AssistantToTheTransportManager from '../transports/assistant_to_the_transport_manager';\nimport PingDelayOptions from '../transports/ping_delay_options';\nimport Transport from '../transports/transport';\nimport TransportManager from '../transports/transport_manager';\nimport Handshake from '../connection/handshake';\nimport TransportConnection from '../transports/transport_connection';\nimport SocketHooks from '../http/socket_hooks';\nimport HTTPSocket from '../http/http_socket';\n\nimport Timeline from '../timeline/timeline';\nimport {\n default as TimelineSender,\n TimelineSenderOptions\n} from '../timeline/timeline_sender';\nimport PresenceChannel from '../channels/presence_channel';\nimport PrivateChannel from '../channels/private_channel';\nimport EncryptedChannel from '../channels/encrypted_channel';\nimport Channel from '../channels/channel';\nimport ConnectionManager from '../connection/connection_manager';\nimport ConnectionManagerOptions from '../connection/connection_manager_options';\nimport Ajax from '../http/ajax';\nimport Channels from '../channels/channels';\nimport Pusher from '../pusher';\nimport { Config } from '../config';\nimport * as nacl from 'tweetnacl';\n\nvar Factory = {\n createChannels(): Channels {\n return new Channels();\n },\n\n createConnectionManager(\n key: string,\n options: ConnectionManagerOptions\n ): ConnectionManager {\n return new ConnectionManager(key, options);\n },\n\n createChannel(name: string, pusher: Pusher): Channel {\n return new Channel(name, pusher);\n },\n\n createPrivateChannel(name: string, pusher: Pusher): PrivateChannel {\n return new PrivateChannel(name, pusher);\n },\n\n createPresenceChannel(name: string, pusher: Pusher): PresenceChannel {\n return new PresenceChannel(name, pusher);\n },\n\n createEncryptedChannel(\n name: string,\n pusher: Pusher,\n nacl: nacl\n ): EncryptedChannel {\n return new EncryptedChannel(name, pusher, nacl);\n },\n\n createTimelineSender(timeline: Timeline, options: TimelineSenderOptions) {\n return new TimelineSender(timeline, options);\n },\n\n createHandshake(\n transport: TransportConnection,\n callback: (HandshakePayload) => void\n ): Handshake {\n return new Handshake(transport, callback);\n },\n\n createAssistantToTheTransportManager(\n manager: TransportManager,\n transport: Transport,\n options: PingDelayOptions\n ): AssistantToTheTransportManager {\n return new AssistantToTheTransportManager(manager, transport, options);\n }\n};\n\nexport default Factory;\n","import AssistantToTheTransportManager from './assistant_to_the_transport_manager';\nimport Transport from './transport';\nimport PingDelayOptions from './ping_delay_options';\nimport Factory from '../utils/factory';\n\nexport interface TransportManagerOptions extends PingDelayOptions {\n lives?: number;\n}\n\n/** Keeps track of the number of lives left for a transport.\n *\n * In the beginning of a session, transports may be assigned a number of\n * lives. When an AssistantToTheTransportManager instance reports a transport\n * connection closed uncleanly, the transport loses a life. When the number\n * of lives drops to zero, the transport gets disabled by its manager.\n *\n * @param {Object} options\n */\nexport default class TransportManager {\n options: TransportManagerOptions;\n livesLeft: number;\n\n constructor(options: TransportManagerOptions) {\n this.options = options || {};\n this.livesLeft = this.options.lives || Infinity;\n }\n\n /** Creates a assistant for the transport.\n *\n * @param {Transport} transport\n * @returns {AssistantToTheTransportManager}\n */\n getAssistant(transport: Transport): AssistantToTheTransportManager {\n return Factory.createAssistantToTheTransportManager(this, transport, {\n minPingDelay: this.options.minPingDelay,\n maxPingDelay: this.options.maxPingDelay\n });\n }\n\n /** Returns whether the transport has any lives left.\n *\n * @returns {Boolean}\n */\n isAlive(): boolean {\n return this.livesLeft > 0;\n }\n\n /** Takes one life from the transport. */\n reportDeath() {\n this.livesLeft -= 1;\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport { OneOffTimer as Timer } from '../utils/timers';\nimport Strategy from './strategy';\nimport StrategyOptions from './strategy_options';\n\n/** Loops through strategies with optional timeouts.\n *\n * Options:\n * - loop - whether it should loop through the substrategy list\n * - timeout - initial timeout for a single substrategy\n * - timeoutLimit - maximum timeout\n *\n * @param {Strategy[]} strategies\n * @param {Object} options\n */\nexport default class SequentialStrategy implements Strategy {\n strategies: Strategy[];\n loop: boolean;\n failFast: boolean;\n timeout: number;\n timeoutLimit: number;\n\n constructor(strategies: Strategy[], options: StrategyOptions) {\n this.strategies = strategies;\n this.loop = Boolean(options.loop);\n this.failFast = Boolean(options.failFast);\n this.timeout = options.timeout;\n this.timeoutLimit = options.timeoutLimit;\n }\n\n isSupported(): boolean {\n return Collections.any(this.strategies, Util.method('isSupported'));\n }\n\n connect(minPriority: number, callback: Function) {\n var strategies = this.strategies;\n var current = 0;\n var timeout = this.timeout;\n var runner = null;\n\n var tryNextStrategy = (error, handshake) => {\n if (handshake) {\n callback(null, handshake);\n } else {\n current = current + 1;\n if (this.loop) {\n current = current % strategies.length;\n }\n\n if (current < strategies.length) {\n if (timeout) {\n timeout = timeout * 2;\n if (this.timeoutLimit) {\n timeout = Math.min(timeout, this.timeoutLimit);\n }\n }\n runner = this.tryStrategy(\n strategies[current],\n minPriority,\n { timeout, failFast: this.failFast },\n tryNextStrategy\n );\n } else {\n callback(true);\n }\n }\n };\n\n runner = this.tryStrategy(\n strategies[current],\n minPriority,\n { timeout: timeout, failFast: this.failFast },\n tryNextStrategy\n );\n\n return {\n abort: function() {\n runner.abort();\n },\n forceMinPriority: function(p) {\n minPriority = p;\n if (runner) {\n runner.forceMinPriority(p);\n }\n }\n };\n }\n\n private tryStrategy(\n strategy: Strategy,\n minPriority: number,\n options: StrategyOptions,\n callback: Function\n ) {\n var timer = null;\n var runner = null;\n\n if (options.timeout > 0) {\n timer = new Timer(options.timeout, function() {\n runner.abort();\n callback(true);\n });\n }\n\n runner = strategy.connect(minPriority, function(error, handshake) {\n if (error && timer && timer.isRunning() && !options.failFast) {\n // advance to the next strategy after the timeout\n return;\n }\n if (timer) {\n timer.ensureAborted();\n }\n callback(error, handshake);\n });\n\n return {\n abort: function() {\n if (timer) {\n timer.ensureAborted();\n }\n runner.abort();\n },\n forceMinPriority: function(p) {\n runner.forceMinPriority(p);\n }\n };\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport Strategy from './strategy';\n\n/** Launches all substrategies and emits prioritized connected transports.\n *\n * @param {Array} strategies\n */\nexport default class BestConnectedEverStrategy implements Strategy {\n strategies: Strategy[];\n\n constructor(strategies: Strategy[]) {\n this.strategies = strategies;\n }\n\n isSupported(): boolean {\n return Collections.any(this.strategies, Util.method('isSupported'));\n }\n\n connect(minPriority: number, callback: Function) {\n return connect(this.strategies, minPriority, function(i, runners) {\n return function(error, handshake) {\n runners[i].error = error;\n if (error) {\n if (allRunnersFailed(runners)) {\n callback(true);\n }\n return;\n }\n Collections.apply(runners, function(runner) {\n runner.forceMinPriority(handshake.transport.priority);\n });\n callback(null, handshake);\n };\n });\n }\n}\n\n/** Connects to all strategies in parallel.\n *\n * Callback builder should be a function that takes two arguments: index\n * and a list of runners. It should return another function that will be\n * passed to the substrategy with given index. Runners can be aborted using\n * abortRunner(s) functions from this class.\n *\n * @param {Array} strategies\n * @param {Function} callbackBuilder\n * @return {Object} strategy runner\n */\nfunction connect(\n strategies: Strategy[],\n minPriority: number,\n callbackBuilder: Function\n) {\n var runners = Collections.map(strategies, function(strategy, i, _, rs) {\n return strategy.connect(minPriority, callbackBuilder(i, rs));\n });\n return {\n abort: function() {\n Collections.apply(runners, abortRunner);\n },\n forceMinPriority: function(p) {\n Collections.apply(runners, function(runner) {\n runner.forceMinPriority(p);\n });\n }\n };\n}\n\nfunction allRunnersFailed(runners): boolean {\n return Collections.all(runners, function(runner) {\n return Boolean(runner.error);\n });\n}\n\nfunction abortRunner(runner) {\n if (!runner.error && !runner.aborted) {\n runner.abort();\n runner.aborted = true;\n }\n}\n","import Util from '../util';\nimport Runtime from 'runtime';\nimport Strategy from './strategy';\nimport SequentialStrategy from './sequential_strategy';\nimport StrategyOptions from './strategy_options';\nimport TransportStrategy from './transport_strategy';\nimport Timeline from '../timeline/timeline';\nimport * as Collections from '../utils/collections';\n\nexport interface TransportStrategyDictionary {\n [key: string]: TransportStrategy;\n}\n\n/** Caches the last successful transport and, after the first few attempts,\n * uses the cached transport for subsequent attempts.\n *\n * @param {Strategy} strategy\n * @param {Object} transports\n * @param {Object} options\n */\nexport default class WebSocketPrioritizedCachedStrategy implements Strategy {\n strategy: Strategy;\n transports: TransportStrategyDictionary;\n ttl: number;\n usingTLS: boolean;\n timeline: Timeline;\n\n constructor(\n strategy: Strategy,\n transports: TransportStrategyDictionary,\n options: StrategyOptions\n ) {\n this.strategy = strategy;\n this.transports = transports;\n this.ttl = options.ttl || 1800 * 1000;\n this.usingTLS = options.useTLS;\n this.timeline = options.timeline;\n }\n\n isSupported(): boolean {\n return this.strategy.isSupported();\n }\n\n connect(minPriority: number, callback: Function) {\n var usingTLS = this.usingTLS;\n var info = fetchTransportCache(usingTLS);\n var cacheSkipCount = info && info.cacheSkipCount ? info.cacheSkipCount : 0;\n\n var strategies = [this.strategy];\n if (info && info.timestamp + this.ttl >= Util.now()) {\n var transport = this.transports[info.transport];\n if (transport) {\n if (['ws', 'wss'].includes(info.transport) || cacheSkipCount > 3) {\n this.timeline.info({\n cached: true,\n transport: info.transport,\n latency: info.latency\n });\n strategies.push(\n new SequentialStrategy([transport], {\n timeout: info.latency * 2 + 1000,\n failFast: true\n })\n );\n } else {\n cacheSkipCount++;\n }\n }\n }\n\n var startTimestamp = Util.now();\n var runner = strategies\n .pop()\n .connect(minPriority, function cb(error, handshake) {\n if (error) {\n flushTransportCache(usingTLS);\n if (strategies.length > 0) {\n startTimestamp = Util.now();\n runner = strategies.pop().connect(minPriority, cb);\n } else {\n callback(error);\n }\n } else {\n storeTransportCache(\n usingTLS,\n handshake.transport.name,\n Util.now() - startTimestamp,\n cacheSkipCount\n );\n callback(null, handshake);\n }\n });\n\n return {\n abort: function() {\n runner.abort();\n },\n forceMinPriority: function(p) {\n minPriority = p;\n if (runner) {\n runner.forceMinPriority(p);\n }\n }\n };\n }\n}\n\nfunction getTransportCacheKey(usingTLS: boolean): string {\n return 'pusherTransport' + (usingTLS ? 'TLS' : 'NonTLS');\n}\n\nfunction fetchTransportCache(usingTLS: boolean): any {\n var storage = Runtime.getLocalStorage();\n if (storage) {\n try {\n var serializedCache = storage[getTransportCacheKey(usingTLS)];\n if (serializedCache) {\n return JSON.parse(serializedCache);\n }\n } catch (e) {\n flushTransportCache(usingTLS);\n }\n }\n return null;\n}\n\nfunction storeTransportCache(\n usingTLS: boolean,\n transport: TransportStrategy,\n latency: number,\n cacheSkipCount: number\n) {\n var storage = Runtime.getLocalStorage();\n if (storage) {\n try {\n storage[getTransportCacheKey(usingTLS)] = Collections.safeJSONStringify({\n timestamp: Util.now(),\n transport: transport,\n latency: latency,\n cacheSkipCount: cacheSkipCount\n });\n } catch (e) {\n // catch over quota exceptions raised by localStorage\n }\n }\n}\n\nfunction flushTransportCache(usingTLS: boolean) {\n var storage = Runtime.getLocalStorage();\n if (storage) {\n try {\n delete storage[getTransportCacheKey(usingTLS)];\n } catch (e) {\n // catch exceptions raised by localStorage\n }\n }\n}\n","import { OneOffTimer as Timer } from '../utils/timers';\nimport Strategy from './strategy';\nimport StrategyOptions from './strategy_options';\n\n/** Runs substrategy after specified delay.\n *\n * Options:\n * - delay - time in miliseconds to delay the substrategy attempt\n *\n * @param {Strategy} strategy\n * @param {Object} options\n */\nexport default class DelayedStrategy implements Strategy {\n strategy: Strategy;\n options: { delay: number };\n\n constructor(strategy: Strategy, { delay: number }) {\n this.strategy = strategy;\n this.options = { delay: number };\n }\n\n isSupported(): boolean {\n return this.strategy.isSupported();\n }\n\n connect(minPriority: number, callback: Function) {\n var strategy = this.strategy;\n var runner;\n var timer = new Timer(this.options.delay, function() {\n runner = strategy.connect(minPriority, callback);\n });\n\n return {\n abort: function() {\n timer.ensureAborted();\n if (runner) {\n runner.abort();\n }\n },\n forceMinPriority: function(p) {\n minPriority = p;\n if (runner) {\n runner.forceMinPriority(p);\n }\n }\n };\n }\n}\n","import Strategy from './strategy';\nimport StrategyRunner from './strategy_runner';\n\n/** Proxies method calls to one of substrategies basing on the test function.\n *\n * @param {Function} test\n * @param {Strategy} trueBranch strategy used when test returns true\n * @param {Strategy} falseBranch strategy used when test returns false\n */\nexport default class IfStrategy implements Strategy {\n test: () => boolean;\n trueBranch: Strategy;\n falseBranch: Strategy;\n\n constructor(\n test: () => boolean,\n trueBranch: Strategy,\n falseBranch: Strategy\n ) {\n this.test = test;\n this.trueBranch = trueBranch;\n this.falseBranch = falseBranch;\n }\n\n isSupported(): boolean {\n var branch = this.test() ? this.trueBranch : this.falseBranch;\n return branch.isSupported();\n }\n\n connect(minPriority: number, callback: Function): StrategyRunner {\n var branch = this.test() ? this.trueBranch : this.falseBranch;\n return branch.connect(minPriority, callback);\n }\n}\n","import Strategy from './strategy';\nimport StrategyRunner from './strategy_runner';\n\n/** Launches the substrategy and terminates on the first open connection.\n *\n * @param {Strategy} strategy\n */\nexport default class FirstConnectedStrategy implements Strategy {\n strategy: Strategy;\n\n constructor(strategy: Strategy) {\n this.strategy = strategy;\n }\n\n isSupported(): boolean {\n return this.strategy.isSupported();\n }\n\n connect(minPriority: number, callback: Function): StrategyRunner {\n var runner = this.strategy.connect(minPriority, function(error, handshake) {\n if (handshake) {\n runner.abort();\n }\n callback(error, handshake);\n });\n return runner;\n }\n}\n","import * as Collections from 'core/utils/collections';\nimport TransportManager from 'core/transports/transport_manager';\nimport Strategy from 'core/strategies/strategy';\nimport SequentialStrategy from 'core/strategies/sequential_strategy';\nimport BestConnectedEverStrategy from 'core/strategies/best_connected_ever_strategy';\nimport WebSocketPrioritizedCachedStrategy, {\n TransportStrategyDictionary\n} from 'core/strategies/websocket_prioritized_cached_strategy';\nimport DelayedStrategy from 'core/strategies/delayed_strategy';\nimport IfStrategy from 'core/strategies/if_strategy';\nimport FirstConnectedStrategy from 'core/strategies/first_connected_strategy';\nimport { Config } from 'core/config';\nimport StrategyOptions from 'core/strategies/strategy_options';\n\nfunction testSupportsStrategy(strategy: Strategy) {\n return function() {\n return strategy.isSupported();\n };\n}\n\nvar getDefaultStrategy = function(\n config: Config,\n baseOptions: StrategyOptions,\n defineTransport: Function\n): Strategy {\n var definedTransports = {};\n\n function defineTransportStrategy(\n name: string,\n type: string,\n priority: number,\n options: StrategyOptions,\n manager?: TransportManager\n ) {\n var transport = defineTransport(\n config,\n name,\n type,\n priority,\n options,\n manager\n );\n\n definedTransports[name] = transport;\n\n return transport;\n }\n\n var ws_options: StrategyOptions = Object.assign({}, baseOptions, {\n hostNonTLS: config.wsHost + ':' + config.wsPort,\n hostTLS: config.wsHost + ':' + config.wssPort,\n httpPath: config.wsPath\n });\n var wss_options: StrategyOptions = Collections.extend({}, ws_options, {\n useTLS: true\n });\n var http_options: StrategyOptions = Object.assign({}, baseOptions, {\n hostNonTLS: config.httpHost + ':' + config.httpPort,\n hostTLS: config.httpHost + ':' + config.httpsPort,\n httpPath: config.httpPath\n });\n var timeouts = {\n loop: true,\n timeout: 15000,\n timeoutLimit: 60000\n };\n\n var ws_manager = new TransportManager({\n minPingDelay: 10000,\n maxPingDelay: config.activityTimeout\n });\n var streaming_manager = new TransportManager({\n lives: 2,\n minPingDelay: 10000,\n maxPingDelay: config.activityTimeout\n });\n\n var ws_transport = defineTransportStrategy(\n 'ws',\n 'ws',\n 3,\n ws_options,\n ws_manager\n );\n var wss_transport = defineTransportStrategy(\n 'wss',\n 'ws',\n 3,\n wss_options,\n ws_manager\n );\n var xhr_streaming_transport = defineTransportStrategy(\n 'xhr_streaming',\n 'xhr_streaming',\n 1,\n http_options,\n streaming_manager\n );\n var xhr_polling_transport = defineTransportStrategy(\n 'xhr_polling',\n 'xhr_polling',\n 1,\n http_options\n );\n\n var ws_loop = new SequentialStrategy([ws_transport], timeouts);\n var wss_loop = new SequentialStrategy([wss_transport], timeouts);\n var streaming_loop = new SequentialStrategy(\n [xhr_streaming_transport],\n timeouts\n );\n var polling_loop = new SequentialStrategy([xhr_polling_transport], timeouts);\n\n var http_loop = new SequentialStrategy(\n [\n new IfStrategy(\n testSupportsStrategy(streaming_loop),\n new BestConnectedEverStrategy([\n streaming_loop,\n new DelayedStrategy(polling_loop, { delay: 4000 })\n ]),\n polling_loop\n )\n ],\n timeouts\n );\n\n var wsStrategy;\n if (baseOptions.useTLS) {\n wsStrategy = new BestConnectedEverStrategy([\n ws_loop,\n new DelayedStrategy(http_loop, { delay: 2000 })\n ]);\n } else {\n wsStrategy = new BestConnectedEverStrategy([\n ws_loop,\n new DelayedStrategy(wss_loop, { delay: 2000 }),\n new DelayedStrategy(http_loop, { delay: 5000 })\n ]);\n }\n\n return new WebSocketPrioritizedCachedStrategy(\n new FirstConnectedStrategy(\n new IfStrategy(testSupportsStrategy(ws_transport), wsStrategy, http_loop)\n ),\n definedTransports,\n {\n ttl: 1800000,\n timeline: baseOptions.timeline,\n useTLS: baseOptions.useTLS\n }\n );\n};\n\nexport default getDefaultStrategy;\n","/** Initializes the transport.\n *\n * Fetches resources if needed and then transitions to initialized.\n */\nexport default function() {\n var self = this;\n\n self.timeline.info(\n self.buildTimelineMessage({\n transport: self.name + (self.options.useTLS ? 's' : '')\n })\n );\n\n if (self.hooks.isInitialized()) {\n self.changeState('initialized');\n } else {\n self.onClose();\n }\n}\n","import Runtime from 'runtime';\nimport RequestHooks from './request_hooks';\nimport Ajax from './ajax';\nimport { default as EventsDispatcher } from '../events/dispatcher';\n\nconst MAX_BUFFER_LENGTH = 256 * 1024;\n\nexport default class HTTPRequest extends EventsDispatcher {\n hooks: RequestHooks;\n method: string;\n url: string;\n position: number;\n xhr: Ajax;\n unloader: Function;\n\n constructor(hooks: RequestHooks, method: string, url: string) {\n super();\n this.hooks = hooks;\n this.method = method;\n this.url = url;\n }\n\n start(payload?: any) {\n this.position = 0;\n this.xhr = this.hooks.getRequest(this);\n\n this.unloader = () => {\n this.close();\n };\n Runtime.addUnloadListener(this.unloader);\n\n this.xhr.open(this.method, this.url, true);\n\n if (this.xhr.setRequestHeader) {\n this.xhr.setRequestHeader('Content-Type', 'application/json'); // ReactNative doesn't set this header by default.\n }\n this.xhr.send(payload);\n }\n\n close() {\n if (this.unloader) {\n Runtime.removeUnloadListener(this.unloader);\n this.unloader = null;\n }\n if (this.xhr) {\n this.hooks.abortRequest(this.xhr);\n this.xhr = null;\n }\n }\n\n onChunk(status: number, data: any) {\n while (true) {\n var chunk = this.advanceBuffer(data);\n if (chunk) {\n this.emit('chunk', { status: status, data: chunk });\n } else {\n break;\n }\n }\n if (this.isBufferTooLong(data)) {\n this.emit('buffer_too_long');\n }\n }\n\n private advanceBuffer(buffer: any[]): any {\n var unreadData = buffer.slice(this.position);\n var endOfLinePosition = unreadData.indexOf('\\n');\n\n if (endOfLinePosition !== -1) {\n this.position += endOfLinePosition + 1;\n return unreadData.slice(0, endOfLinePosition);\n } else {\n // chunk is not finished yet, don't move the buffer pointer\n return null;\n }\n }\n\n private isBufferTooLong(buffer: any): boolean {\n return this.position === buffer.length && buffer.length > MAX_BUFFER_LENGTH;\n }\n}\n","enum State {\n CONNECTING = 0,\n OPEN = 1,\n CLOSED = 3\n}\n\nexport default State;\n","import URLLocation from './url_location';\nimport State from './state';\nimport Socket from '../socket';\nimport SocketHooks from './socket_hooks';\nimport Util from '../util';\nimport Ajax from './ajax';\nimport HTTPRequest from './http_request';\nimport Runtime from 'runtime';\n\nvar autoIncrement = 1;\n\nclass HTTPSocket implements Socket {\n hooks: SocketHooks;\n session: string;\n location: URLLocation;\n readyState: State;\n stream: HTTPRequest;\n\n onopen: () => void;\n onerror: (error: any) => void;\n onclose: (closeEvent: any) => void;\n onmessage: (message: any) => void;\n onactivity: () => void;\n\n constructor(hooks: SocketHooks, url: string) {\n this.hooks = hooks;\n this.session = randomNumber(1000) + '/' + randomString(8);\n this.location = getLocation(url);\n this.readyState = State.CONNECTING;\n this.openStream();\n }\n\n send(payload: any) {\n return this.sendRaw(JSON.stringify([payload]));\n }\n\n ping() {\n this.hooks.sendHeartbeat(this);\n }\n\n close(code: any, reason: any) {\n this.onClose(code, reason, true);\n }\n\n /** For internal use only */\n sendRaw(payload: any): boolean {\n if (this.readyState === State.OPEN) {\n try {\n Runtime.createSocketRequest(\n 'POST',\n getUniqueURL(getSendURL(this.location, this.session))\n ).start(payload);\n return true;\n } catch (e) {\n return false;\n }\n } else {\n return false;\n }\n }\n\n /** For internal use only */\n reconnect() {\n this.closeStream();\n this.openStream();\n }\n\n /** For internal use only */\n onClose(code, reason, wasClean) {\n this.closeStream();\n this.readyState = State.CLOSED;\n if (this.onclose) {\n this.onclose({\n code: code,\n reason: reason,\n wasClean: wasClean\n });\n }\n }\n\n private onChunk(chunk) {\n if (chunk.status !== 200) {\n return;\n }\n if (this.readyState === State.OPEN) {\n this.onActivity();\n }\n\n var payload;\n var type = chunk.data.slice(0, 1);\n switch (type) {\n case 'o':\n payload = JSON.parse(chunk.data.slice(1) || '{}');\n this.onOpen(payload);\n break;\n case 'a':\n payload = JSON.parse(chunk.data.slice(1) || '[]');\n for (var i = 0; i < payload.length; i++) {\n this.onEvent(payload[i]);\n }\n break;\n case 'm':\n payload = JSON.parse(chunk.data.slice(1) || 'null');\n this.onEvent(payload);\n break;\n case 'h':\n this.hooks.onHeartbeat(this);\n break;\n case 'c':\n payload = JSON.parse(chunk.data.slice(1) || '[]');\n this.onClose(payload[0], payload[1], true);\n break;\n }\n }\n\n private onOpen(options) {\n if (this.readyState === State.CONNECTING) {\n if (options && options.hostname) {\n this.location.base = replaceHost(this.location.base, options.hostname);\n }\n this.readyState = State.OPEN;\n\n if (this.onopen) {\n this.onopen();\n }\n } else {\n this.onClose(1006, 'Server lost session', true);\n }\n }\n\n private onEvent(event) {\n if (this.readyState === State.OPEN && this.onmessage) {\n this.onmessage({ data: event });\n }\n }\n\n private onActivity() {\n if (this.onactivity) {\n this.onactivity();\n }\n }\n\n private onError(error) {\n if (this.onerror) {\n this.onerror(error);\n }\n }\n\n private openStream() {\n this.stream = Runtime.createSocketRequest(\n 'POST',\n getUniqueURL(this.hooks.getReceiveURL(this.location, this.session))\n );\n\n this.stream.bind('chunk', chunk => {\n this.onChunk(chunk);\n });\n this.stream.bind('finished', status => {\n this.hooks.onFinished(this, status);\n });\n this.stream.bind('buffer_too_long', () => {\n this.reconnect();\n });\n\n try {\n this.stream.start();\n } catch (error) {\n Util.defer(() => {\n this.onError(error);\n this.onClose(1006, 'Could not start streaming', false);\n });\n }\n }\n\n private closeStream() {\n if (this.stream) {\n this.stream.unbind_all();\n this.stream.close();\n this.stream = null;\n }\n }\n}\n\nfunction getLocation(url): URLLocation {\n var parts = /([^\\?]*)\\/*(\\??.*)/.exec(url);\n return {\n base: parts[1],\n queryString: parts[2]\n };\n}\n\nfunction getSendURL(url: URLLocation, session: string): string {\n return url.base + '/' + session + '/xhr_send';\n}\n\nfunction getUniqueURL(url: string): string {\n var separator = url.indexOf('?') === -1 ? '?' : '&';\n return url + separator + 't=' + +new Date() + '&n=' + autoIncrement++;\n}\n\nfunction replaceHost(url: string, hostname: string): string {\n var urlParts = /(https?:\\/\\/)([^\\/:]+)((\\/|:)?.*)/.exec(url);\n return urlParts[1] + hostname + urlParts[3];\n}\n\nfunction randomNumber(max: number): number {\n return Runtime.randomInt(max);\n}\n\nfunction randomString(length: number): string {\n var result = [];\n\n for (var i = 0; i < length; i++) {\n result.push(randomNumber(32).toString(32));\n }\n\n return result.join('');\n}\n\nexport default HTTPSocket;\n","import SocketHooks from './socket_hooks';\nimport HTTPSocket from './http_socket';\n\nvar hooks: SocketHooks = {\n getReceiveURL: function(url, session) {\n return url.base + '/' + session + '/xhr_streaming' + url.queryString;\n },\n onHeartbeat: function(socket) {\n socket.sendRaw('[]');\n },\n sendHeartbeat: function(socket) {\n socket.sendRaw('[]');\n },\n onFinished: function(socket, status) {\n socket.onClose(1006, 'Connection interrupted (' + status + ')', false);\n }\n};\n\nexport default hooks;\n","import SocketHooks from './socket_hooks';\nimport URLLocation from './url_location';\nimport HTTPSocket from './http_socket';\n\nvar hooks: SocketHooks = {\n getReceiveURL: function(url: URLLocation, session: string): string {\n return url.base + '/' + session + '/xhr' + url.queryString;\n },\n onHeartbeat: function() {\n // next HTTP request will reset server's activity timer\n },\n sendHeartbeat: function(socket) {\n socket.sendRaw('[]');\n },\n onFinished: function(socket, status) {\n if (status === 200) {\n socket.reconnect();\n } else {\n socket.onClose(1006, 'Connection interrupted (' + status + ')', false);\n }\n }\n};\n\nexport default hooks;\n","import HTTPRequest from 'core/http/http_request';\nimport RequestHooks from 'core/http/request_hooks';\nimport Ajax from 'core/http/ajax';\nimport Runtime from 'runtime';\n\nvar hooks: RequestHooks = {\n getRequest: function(socket: HTTPRequest): Ajax {\n var Constructor = Runtime.getXHRAPI();\n var xhr = new Constructor();\n xhr.onreadystatechange = xhr.onprogress = function() {\n switch (xhr.readyState) {\n case 3:\n if (xhr.responseText && xhr.responseText.length > 0) {\n socket.onChunk(xhr.status, xhr.responseText);\n }\n break;\n case 4:\n // this happens only on errors, never after calling close\n if (xhr.responseText && xhr.responseText.length > 0) {\n socket.onChunk(xhr.status, xhr.responseText);\n }\n socket.emit('finished', xhr.status);\n socket.close();\n break;\n }\n };\n return xhr;\n },\n abortRequest: function(xhr: Ajax) {\n xhr.onreadystatechange = null;\n xhr.abort();\n }\n};\n\nexport default hooks;\n","import HTTPRequest from 'core/http/http_request';\nimport HTTPSocket from 'core/http/http_socket';\nimport SocketHooks from 'core/http/socket_hooks';\nimport RequestHooks from 'core/http/request_hooks';\nimport streamingHooks from 'core/http/http_streaming_socket';\nimport pollingHooks from 'core/http/http_polling_socket';\nimport xhrHooks from './http_xhr_request';\nimport HTTPFactory from 'core/http/http_factory';\n\nvar HTTP: HTTPFactory = {\n createStreamingSocket(url: string): HTTPSocket {\n return this.createSocket(streamingHooks, url);\n },\n\n createPollingSocket(url: string): HTTPSocket {\n return this.createSocket(pollingHooks, url);\n },\n\n createSocket(hooks: SocketHooks, url: string): HTTPSocket {\n return new HTTPSocket(hooks, url);\n },\n\n createXHR(method: string, url: string): HTTPRequest {\n return this.createRequest(xhrHooks, method, url);\n },\n\n createRequest(hooks: RequestHooks, method: string, url: string): HTTPRequest {\n return new HTTPRequest(hooks, method, url);\n }\n};\n\nexport default HTTP;\n","import * as Collections from 'core/utils/collections';\nimport Transports from 'isomorphic/transports/transports';\nimport TimelineSender from 'core/timeline/timeline_sender';\nimport Ajax from 'core/http/ajax';\nimport getDefaultStrategy from './default_strategy';\nimport TransportsTable from 'core/transports/transports_table';\nimport transportConnectionInitializer from './transports/transport_connection_initializer';\nimport HTTPFactory from './http/http';\n\nvar Isomorphic: any = {\n getDefaultStrategy,\n Transports: Transports,\n transportConnectionInitializer,\n HTTPFactory,\n\n setup(PusherClass): void {\n PusherClass.ready();\n },\n\n getLocalStorage(): any {\n return undefined;\n },\n\n getClientFeatures(): any[] {\n return Collections.keys(\n Collections.filterObject({ ws: Transports.ws }, function(t) {\n return t.isSupported({});\n })\n );\n },\n\n getProtocol(): string {\n return 'http:';\n },\n\n isXHRSupported(): boolean {\n return true;\n },\n\n createSocketRequest(method: string, url: string) {\n if (this.isXHRSupported()) {\n return this.HTTPFactory.createXHR(method, url);\n } else {\n throw 'Cross-origin HTTP requests are not supported';\n }\n },\n\n createXHR(): Ajax {\n var Constructor = this.getXHRAPI();\n return new Constructor();\n },\n\n createWebSocket(url: string): any {\n var Constructor = this.getWebSocketAPI();\n return new Constructor(url);\n },\n\n addUnloadListener(listener: any) {},\n removeUnloadListener(listener: any) {}\n};\n\nexport default Isomorphic;\n","import { default as EventsDispatcher } from 'core/events/dispatcher';\nimport Reachability from 'core/reachability';\n\nexport class NetInfo extends EventsDispatcher implements Reachability {\n isOnline(): boolean {\n return true;\n }\n}\n\nexport var Network = new NetInfo();\n","import AbstractRuntime from 'runtimes/interface';\nimport { AuthTransport } from 'core/auth/auth_transports';\nimport {\n AuthRequestType,\n AuthTransportCallback,\n InternalAuthOptions\n} from 'core/auth/options';\nimport { HTTPAuthError } from 'core/errors';\n\nvar fetchAuth: AuthTransport = function(\n context: AbstractRuntime,\n query: string,\n authOptions: InternalAuthOptions,\n authRequestType: AuthRequestType,\n callback: AuthTransportCallback\n) {\n var headers = new Headers();\n headers.set('Content-Type', 'application/x-www-form-urlencoded');\n\n for (var headerName in authOptions.headers) {\n headers.set(headerName, authOptions.headers[headerName]);\n }\n\n if (authOptions.headersProvider != null) {\n const dynamicHeaders = authOptions.headersProvider();\n for (var headerName in dynamicHeaders) {\n headers.set(headerName, dynamicHeaders[headerName]);\n }\n }\n\n var body = query;\n var request = new Request(authOptions.endpoint, {\n headers,\n body,\n credentials: 'same-origin',\n method: 'POST'\n });\n\n return fetch(request)\n .then(response => {\n let { status } = response;\n if (status === 200) {\n // manually parse the json so we can provide a more helpful error in\n // failure case\n return response.text();\n }\n throw new HTTPAuthError(\n status,\n `Could not get ${authRequestType.toString()} info from your auth endpoint, status: ${status}`\n );\n })\n .then(data => {\n let parsedData;\n try {\n parsedData = JSON.parse(data);\n } catch (e) {\n throw new HTTPAuthError(\n 200,\n `JSON returned from ${authRequestType.toString()} endpoint was invalid, yet status code was 200. Data was: ${data}`\n );\n }\n callback(null, parsedData);\n })\n .catch(err => {\n callback(err, null);\n });\n};\n\nexport default fetchAuth;\n","import Logger from 'core/logger';\nimport TimelineSender from 'core/timeline/timeline_sender';\nimport * as Collections from 'core/utils/collections';\nimport Util from 'core/util';\nimport Runtime from 'runtime';\nimport TimelineTransport from 'core/timeline/timeline_transport';\n\nvar getAgent = function(sender: TimelineSender, useTLS: boolean) {\n return function(data: any, callback: Function) {\n var scheme = 'http' + (useTLS ? 's' : '') + '://';\n var url =\n scheme + (sender.host || sender.options.host) + sender.options.path;\n var query = Collections.buildQueryString(data);\n url += '/' + 2 + '?' + query;\n\n fetch(url)\n .then(response => {\n if (response.status !== 200) {\n throw `received ${response.status} from stats.pusher.com`;\n }\n return response.json();\n })\n .then(({ host }) => {\n if (host) {\n sender.host = host;\n }\n })\n .catch(err => {\n Logger.debug('TimelineSender Error: ', err);\n });\n };\n};\n\nvar fetchTimeline = {\n name: 'xhr',\n getAgent\n};\n\nexport default fetchTimeline;\n","import Isomorphic from 'isomorphic/runtime';\nimport Runtime from '../interface';\nimport { Network } from './net_info';\nimport fetchAuth from './auth/fetch_auth';\nimport { AuthTransports } from 'core/auth/auth_transports';\nimport fetchTimeline from './timeline/fetch_timeline';\n\n// Very verbose but until unavoidable until\n// TypeScript 2.1, when spread attributes will be\n// supported\nconst {\n getDefaultStrategy,\n Transports,\n setup,\n getProtocol,\n isXHRSupported,\n getLocalStorage,\n createXHR,\n createWebSocket,\n addUnloadListener,\n removeUnloadListener,\n transportConnectionInitializer,\n createSocketRequest,\n HTTPFactory\n} = Isomorphic;\n\nconst Worker: Runtime = {\n getDefaultStrategy,\n Transports,\n setup,\n getProtocol,\n isXHRSupported,\n getLocalStorage,\n createXHR,\n createWebSocket,\n addUnloadListener,\n removeUnloadListener,\n transportConnectionInitializer,\n createSocketRequest,\n HTTPFactory,\n\n TimelineTransport: fetchTimeline,\n\n getAuthorizers(): AuthTransports {\n return { ajax: fetchAuth };\n },\n\n getWebSocketAPI() {\n return WebSocket;\n },\n\n getXHRAPI() {\n return XMLHttpRequest;\n },\n\n getNetwork() {\n return Network;\n },\n\n randomInt(max: number): number {\n /**\n * Return values in the range of [0, 1[\n */\n const random = function() {\n const crypto = globalThis.crypto || globalThis['msCrypto'];\n const random = crypto.getRandomValues(new Uint32Array(1))[0];\n\n return random / 2 ** 32;\n };\n\n return Math.floor(random() * max);\n }\n};\n\nexport default Worker;\n","enum TimelineLevel {\n ERROR = 3,\n INFO = 6,\n DEBUG = 7\n}\n\nexport default TimelineLevel;\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport { default as Level } from './level';\n\nexport interface TimelineOptions {\n level?: Level;\n limit?: number;\n version?: string;\n cluster?: string;\n features?: string[];\n params?: any;\n}\n\nexport default class Timeline {\n key: string;\n session: number;\n events: any[];\n options: TimelineOptions;\n sent: number;\n uniqueID: number;\n\n constructor(key: string, session: number, options: TimelineOptions) {\n this.key = key;\n this.session = session;\n this.events = [];\n this.options = options || {};\n this.sent = 0;\n this.uniqueID = 0;\n }\n\n log(level, event) {\n if (level <= this.options.level) {\n this.events.push(\n Collections.extend({}, event, { timestamp: Util.now() })\n );\n if (this.options.limit && this.events.length > this.options.limit) {\n this.events.shift();\n }\n }\n }\n\n error(event) {\n this.log(Level.ERROR, event);\n }\n\n info(event) {\n this.log(Level.INFO, event);\n }\n\n debug(event) {\n this.log(Level.DEBUG, event);\n }\n\n isEmpty() {\n return this.events.length === 0;\n }\n\n send(sendfn, callback) {\n var data = Collections.extend(\n {\n session: this.session,\n bundle: this.sent + 1,\n key: this.key,\n lib: 'js',\n version: this.options.version,\n cluster: this.options.cluster,\n features: this.options.features,\n timeline: this.events\n },\n this.options.params\n );\n\n this.events = [];\n sendfn(data, (error, result) => {\n if (!error) {\n this.sent++;\n }\n if (callback) {\n callback(error, result);\n }\n });\n\n return true;\n }\n\n generateUniqueID(): number {\n this.uniqueID++;\n return this.uniqueID;\n }\n}\n","import Factory from '../utils/factory';\nimport Util from '../util';\nimport * as Errors from '../errors';\nimport * as Collections from '../utils/collections';\nimport Strategy from './strategy';\nimport Transport from '../transports/transport';\nimport StrategyOptions from './strategy_options';\nimport Handshake from '../connection/handshake';\n\n/** Provides a strategy interface for transports.\n *\n * @param {String} name\n * @param {Number} priority\n * @param {Class} transport\n * @param {Object} options\n */\nexport default class TransportStrategy implements Strategy {\n name: string;\n priority: number;\n transport: Transport;\n options: StrategyOptions;\n\n constructor(\n name: string,\n priority: number,\n transport: Transport,\n options: StrategyOptions\n ) {\n this.name = name;\n this.priority = priority;\n this.transport = transport;\n this.options = options || {};\n }\n\n /** Returns whether the transport is supported in the browser.\n *\n * @returns {Boolean}\n */\n isSupported(): boolean {\n return this.transport.isSupported({\n useTLS: this.options.useTLS\n });\n }\n\n /** Launches a connection attempt and returns a strategy runner.\n *\n * @param {Function} callback\n * @return {Object} strategy runner\n */\n connect(minPriority: number, callback: Function) {\n if (!this.isSupported()) {\n return failAttempt(new Errors.UnsupportedStrategy(), callback);\n } else if (this.priority < minPriority) {\n return failAttempt(new Errors.TransportPriorityTooLow(), callback);\n }\n\n var connected = false;\n var transport = this.transport.createConnection(\n this.name,\n this.priority,\n this.options.key,\n this.options\n );\n var handshake = null;\n\n var onInitialized = function() {\n transport.unbind('initialized', onInitialized);\n transport.connect();\n };\n var onOpen = function() {\n handshake = Factory.createHandshake(transport, function(result) {\n connected = true;\n unbindListeners();\n callback(null, result);\n });\n };\n var onError = function(error) {\n unbindListeners();\n callback(error);\n };\n var onClosed = function() {\n unbindListeners();\n var serializedTransport;\n\n // The reason for this try/catch block is that on React Native\n // the WebSocket object is circular. Therefore transport.socket will\n // throw errors upon stringification. Collections.safeJSONStringify\n // discards circular references when serializing.\n serializedTransport = Collections.safeJSONStringify(transport);\n callback(new Errors.TransportClosed(serializedTransport));\n };\n\n var unbindListeners = function() {\n transport.unbind('initialized', onInitialized);\n transport.unbind('open', onOpen);\n transport.unbind('error', onError);\n transport.unbind('closed', onClosed);\n };\n\n transport.bind('initialized', onInitialized);\n transport.bind('open', onOpen);\n transport.bind('error', onError);\n transport.bind('closed', onClosed);\n\n // connect will be called automatically after initialization\n transport.initialize();\n\n return {\n abort: () => {\n if (connected) {\n return;\n }\n unbindListeners();\n if (handshake) {\n handshake.close();\n } else {\n transport.close();\n }\n },\n forceMinPriority: p => {\n if (connected) {\n return;\n }\n if (this.priority < p) {\n if (handshake) {\n handshake.close();\n } else {\n transport.close();\n }\n }\n }\n };\n }\n}\n\nfunction failAttempt(error: Error, callback: Function) {\n Util.defer(function() {\n callback(error);\n });\n return {\n abort: function() {},\n forceMinPriority: function() {}\n };\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport TransportManager from '../transports/transport_manager';\nimport * as Errors from '../errors';\nimport Strategy from './strategy';\nimport TransportStrategy from './transport_strategy';\nimport StrategyOptions from '../strategies/strategy_options';\nimport { Config } from '../config';\nimport Runtime from 'runtime';\n\nconst { Transports } = Runtime;\n\nexport var defineTransport = function(\n config: Config,\n name: string,\n type: string,\n priority: number,\n options: StrategyOptions,\n manager?: TransportManager\n): Strategy {\n var transportClass = Transports[type];\n if (!transportClass) {\n throw new Errors.UnsupportedTransport(type);\n }\n\n var enabled =\n (!config.enabledTransports ||\n Collections.arrayIndexOf(config.enabledTransports, name) !== -1) &&\n (!config.disabledTransports ||\n Collections.arrayIndexOf(config.disabledTransports, name) === -1);\n\n var transport;\n if (enabled) {\n options = Object.assign(\n { ignoreNullOrigin: config.ignoreNullOrigin },\n options\n );\n\n transport = new TransportStrategy(\n name,\n priority,\n manager ? manager.getAssistant(transportClass) : transportClass,\n options\n );\n } else {\n transport = UnsupportedStrategy;\n }\n\n return transport;\n};\n\nvar UnsupportedStrategy: Strategy = {\n isSupported: function() {\n return false;\n },\n connect: function(_, callback) {\n var deferred = Util.defer(function() {\n callback(new Errors.UnsupportedStrategy());\n });\n return {\n abort: function() {\n deferred.ensureAborted();\n },\n forceMinPriority: function() {}\n };\n }\n};\n","import ConnectionManager from './connection/connection_manager';\nimport {\n ChannelAuthorizationOptions,\n UserAuthenticationOptions\n} from './auth/options';\nimport {\n ChannelAuthorizerGenerator,\n DeprecatedAuthOptions\n} from './auth/deprecated_channel_authorizer';\nimport { AuthTransport, Transport } from './config';\nimport * as nacl from 'tweetnacl';\nimport Logger from './logger';\n\nexport interface Options {\n activityTimeout?: number;\n\n auth?: DeprecatedAuthOptions; // DEPRECATED use channelAuthorization instead\n authEndpoint?: string; // DEPRECATED use channelAuthorization instead\n authTransport?: AuthTransport; // DEPRECATED use channelAuthorization instead\n authorizer?: ChannelAuthorizerGenerator; // DEPRECATED use channelAuthorization instead\n\n channelAuthorization?: ChannelAuthorizationOptions;\n userAuthentication?: UserAuthenticationOptions;\n\n cluster: string;\n enableStats?: boolean;\n disableStats?: boolean;\n disabledTransports?: Transport[];\n enabledTransports?: Transport[];\n forceTLS?: boolean;\n httpHost?: string;\n httpPath?: string;\n httpPort?: number;\n httpsPort?: number;\n ignoreNullOrigin?: boolean;\n nacl?: nacl;\n pongTimeout?: number;\n statsHost?: string;\n timelineParams?: any;\n unavailableTimeout?: number;\n wsHost?: string;\n wsPath?: string;\n wsPort?: number;\n wssPort?: number;\n}\n\nexport interface ClusterOptions {\n appKey: string;\n cluster: string;\n}\n\nexport function validateOptions(options) {\n if (options == null) {\n throw 'You must pass an options object';\n }\n if (options.cluster == null) {\n throw 'Options object must provide a cluster';\n }\n if ('disableStats' in options) {\n Logger.warn(\n 'The disableStats option is deprecated in favor of enableStats'\n );\n }\n}\n","export enum AuthRequestType {\n UserAuthentication = 'user-authentication',\n ChannelAuthorization = 'channel-authorization'\n}\n\nexport interface ChannelAuthorizationData {\n auth: string;\n channel_data?: string;\n shared_secret?: string;\n}\n\nexport type ChannelAuthorizationCallback = (\n error: Error | null,\n authData: ChannelAuthorizationData | null\n) => void;\n\nexport interface ChannelAuthorizationRequestParams {\n socketId: string;\n channelName: string;\n}\n\nexport interface ChannelAuthorizationHandler {\n (\n params: ChannelAuthorizationRequestParams,\n callback: ChannelAuthorizationCallback\n ): void;\n}\n\nexport interface UserAuthenticationData {\n auth: string;\n user_data: string;\n}\n\nexport type UserAuthenticationCallback = (\n error: Error | null,\n authData: UserAuthenticationData | null\n) => void;\n\nexport interface UserAuthenticationRequestParams {\n socketId: string;\n}\n\nexport interface UserAuthenticationHandler {\n (\n params: UserAuthenticationRequestParams,\n callback: UserAuthenticationCallback\n ): void;\n}\n\nexport type AuthTransportCallback =\n | ChannelAuthorizationCallback\n | UserAuthenticationCallback;\n\nexport interface AuthOptionsT {\n transport: 'ajax' | 'jsonp';\n endpoint: string;\n params?: any;\n headers?: any;\n paramsProvider?: () => any;\n headersProvider?: () => any;\n customHandler?: AuthHandler;\n}\n\nexport declare type UserAuthenticationOptions = AuthOptionsT<\n UserAuthenticationHandler\n>;\nexport declare type ChannelAuthorizationOptions = AuthOptionsT<\n ChannelAuthorizationHandler\n>;\n\nexport interface InternalAuthOptions {\n transport: 'ajax' | 'jsonp';\n endpoint: string;\n params?: any;\n headers?: any;\n paramsProvider?: () => any;\n headersProvider?: () => any;\n}\n","import {\n UserAuthenticationCallback,\n InternalAuthOptions,\n UserAuthenticationHandler,\n UserAuthenticationRequestParams,\n AuthRequestType\n} from './options';\n\nimport Runtime from 'runtime';\n\nconst composeChannelQuery = (\n params: UserAuthenticationRequestParams,\n authOptions: InternalAuthOptions\n) => {\n var query = 'socket_id=' + encodeURIComponent(params.socketId);\n\n for (var key in authOptions.params) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(authOptions.params[key]);\n }\n\n if (authOptions.paramsProvider != null) {\n let dynamicParams = authOptions.paramsProvider();\n for (var key in dynamicParams) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(dynamicParams[key]);\n }\n }\n\n return query;\n};\n\nconst UserAuthenticator = (\n authOptions: InternalAuthOptions\n): UserAuthenticationHandler => {\n if (typeof Runtime.getAuthorizers()[authOptions.transport] === 'undefined') {\n throw `'${authOptions.transport}' is not a recognized auth transport`;\n }\n\n return (\n params: UserAuthenticationRequestParams,\n callback: UserAuthenticationCallback\n ) => {\n const query = composeChannelQuery(params, authOptions);\n\n Runtime.getAuthorizers()[authOptions.transport](\n Runtime,\n query,\n authOptions,\n AuthRequestType.UserAuthentication,\n callback\n );\n };\n};\n\nexport default UserAuthenticator;\n","import {\n AuthRequestType,\n InternalAuthOptions,\n ChannelAuthorizationHandler,\n ChannelAuthorizationRequestParams,\n ChannelAuthorizationCallback\n} from './options';\n\nimport Runtime from 'runtime';\n\nconst composeChannelQuery = (\n params: ChannelAuthorizationRequestParams,\n authOptions: InternalAuthOptions\n) => {\n var query = 'socket_id=' + encodeURIComponent(params.socketId);\n\n query += '&channel_name=' + encodeURIComponent(params.channelName);\n\n for (var key in authOptions.params) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(authOptions.params[key]);\n }\n\n if (authOptions.paramsProvider != null) {\n let dynamicParams = authOptions.paramsProvider();\n for (var key in dynamicParams) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(dynamicParams[key]);\n }\n }\n\n return query;\n};\n\nconst ChannelAuthorizer = (\n authOptions: InternalAuthOptions\n): ChannelAuthorizationHandler => {\n if (typeof Runtime.getAuthorizers()[authOptions.transport] === 'undefined') {\n throw `'${authOptions.transport}' is not a recognized auth transport`;\n }\n\n return (\n params: ChannelAuthorizationRequestParams,\n callback: ChannelAuthorizationCallback\n ) => {\n const query = composeChannelQuery(params, authOptions);\n\n Runtime.getAuthorizers()[authOptions.transport](\n Runtime,\n query,\n authOptions,\n AuthRequestType.ChannelAuthorization,\n callback\n );\n };\n};\n\nexport default ChannelAuthorizer;\n","import Channel from '../channels/channel';\nimport {\n ChannelAuthorizationCallback,\n ChannelAuthorizationHandler,\n ChannelAuthorizationRequestParams,\n InternalAuthOptions\n} from './options';\n\nexport interface DeprecatedChannelAuthorizer {\n authorize(socketId: string, callback: ChannelAuthorizationCallback): void;\n}\n\nexport interface ChannelAuthorizerGenerator {\n (\n channel: Channel,\n options: DeprecatedAuthorizerOptions\n ): DeprecatedChannelAuthorizer;\n}\n\nexport interface DeprecatedAuthOptions {\n params?: any;\n headers?: any;\n}\n\nexport interface DeprecatedAuthorizerOptions {\n authTransport: 'ajax' | 'jsonp';\n authEndpoint: string;\n auth?: DeprecatedAuthOptions;\n}\n\nexport const ChannelAuthorizerProxy = (\n pusher,\n authOptions: InternalAuthOptions,\n channelAuthorizerGenerator: ChannelAuthorizerGenerator\n): ChannelAuthorizationHandler => {\n const deprecatedAuthorizerOptions: DeprecatedAuthorizerOptions = {\n authTransport: authOptions.transport,\n authEndpoint: authOptions.endpoint,\n auth: {\n params: authOptions.params,\n headers: authOptions.headers\n }\n };\n return (\n params: ChannelAuthorizationRequestParams,\n callback: ChannelAuthorizationCallback\n ) => {\n const channel = pusher.channel(params.channelName);\n // This line creates a new channel authorizer every time.\n // In the past, this was only done once per channel and reused.\n // We can do that again if we want to keep this behavior intact.\n const channelAuthorizer: DeprecatedChannelAuthorizer = channelAuthorizerGenerator(\n channel,\n deprecatedAuthorizerOptions\n );\n channelAuthorizer.authorize(params.socketId, callback);\n };\n};\n","import { Options } from './options';\nimport Defaults from './defaults';\nimport {\n ChannelAuthorizationHandler,\n UserAuthenticationHandler,\n ChannelAuthorizationOptions\n} from './auth/options';\nimport UserAuthenticator from './auth/user_authenticator';\nimport ChannelAuthorizer from './auth/channel_authorizer';\nimport { ChannelAuthorizerProxy } from './auth/deprecated_channel_authorizer';\nimport Runtime from 'runtime';\nimport * as nacl from 'tweetnacl';\n\nexport type AuthTransport = 'ajax' | 'jsonp';\nexport type Transport =\n | 'ws'\n | 'wss'\n | 'xhr_streaming'\n | 'xhr_polling'\n | 'sockjs';\n\nexport interface Config {\n // these are all 'required' config parameters, it's not necessary for the user\n // to set them, but they have configured defaults.\n activityTimeout: number;\n enableStats: boolean;\n httpHost: string;\n httpPath: string;\n httpPort: number;\n httpsPort: number;\n pongTimeout: number;\n statsHost: string;\n unavailableTimeout: number;\n useTLS: boolean;\n wsHost: string;\n wsPath: string;\n wsPort: number;\n wssPort: number;\n userAuthenticator: UserAuthenticationHandler;\n channelAuthorizer: ChannelAuthorizationHandler;\n\n // these are all optional parameters or overrrides. The customer can set these\n // but it's not strictly necessary\n forceTLS?: boolean;\n cluster?: string;\n disabledTransports?: Transport[];\n enabledTransports?: Transport[];\n ignoreNullOrigin?: boolean;\n nacl?: nacl;\n timelineParams?: any;\n}\n\n// getConfig mainly sets the defaults for the options that are not provided\nexport function getConfig(opts: Options, pusher): Config {\n let config: Config = {\n activityTimeout: opts.activityTimeout || Defaults.activityTimeout,\n cluster: opts.cluster,\n httpPath: opts.httpPath || Defaults.httpPath,\n httpPort: opts.httpPort || Defaults.httpPort,\n httpsPort: opts.httpsPort || Defaults.httpsPort,\n pongTimeout: opts.pongTimeout || Defaults.pongTimeout,\n statsHost: opts.statsHost || Defaults.stats_host,\n unavailableTimeout: opts.unavailableTimeout || Defaults.unavailableTimeout,\n wsPath: opts.wsPath || Defaults.wsPath,\n wsPort: opts.wsPort || Defaults.wsPort,\n wssPort: opts.wssPort || Defaults.wssPort,\n\n enableStats: getEnableStatsConfig(opts),\n httpHost: getHttpHost(opts),\n useTLS: shouldUseTLS(opts),\n wsHost: getWebsocketHost(opts),\n\n userAuthenticator: buildUserAuthenticator(opts),\n channelAuthorizer: buildChannelAuthorizer(opts, pusher)\n };\n\n if ('disabledTransports' in opts)\n config.disabledTransports = opts.disabledTransports;\n if ('enabledTransports' in opts)\n config.enabledTransports = opts.enabledTransports;\n if ('ignoreNullOrigin' in opts)\n config.ignoreNullOrigin = opts.ignoreNullOrigin;\n if ('timelineParams' in opts) config.timelineParams = opts.timelineParams;\n if ('nacl' in opts) {\n config.nacl = opts.nacl;\n }\n\n return config;\n}\n\nfunction getHttpHost(opts: Options): string {\n if (opts.httpHost) {\n return opts.httpHost;\n }\n if (opts.cluster) {\n return `sockjs-${opts.cluster}.pusher.com`;\n }\n return Defaults.httpHost;\n}\n\nfunction getWebsocketHost(opts: Options): string {\n if (opts.wsHost) {\n return opts.wsHost;\n }\n return getWebsocketHostFromCluster(opts.cluster);\n}\n\nfunction getWebsocketHostFromCluster(cluster: string): string {\n return `ws-${cluster}.pusher.com`;\n}\n\nfunction shouldUseTLS(opts: Options): boolean {\n if (Runtime.getProtocol() === 'https:') {\n return true;\n } else if (opts.forceTLS === false) {\n return false;\n }\n return true;\n}\n\n// if enableStats is set take the value\n// if disableStats is set take the inverse\n// otherwise default to false\nfunction getEnableStatsConfig(opts: Options): boolean {\n if ('enableStats' in opts) {\n return opts.enableStats;\n }\n if ('disableStats' in opts) {\n return !opts.disableStats;\n }\n return false;\n}\n\nfunction buildUserAuthenticator(opts: Options): UserAuthenticationHandler {\n const userAuthentication = {\n ...Defaults.userAuthentication,\n ...opts.userAuthentication\n };\n if (\n 'customHandler' in userAuthentication &&\n userAuthentication['customHandler'] != null\n ) {\n return userAuthentication['customHandler'];\n }\n\n return UserAuthenticator(userAuthentication);\n}\n\nfunction buildChannelAuth(opts: Options, pusher): ChannelAuthorizationOptions {\n let channelAuthorization: ChannelAuthorizationOptions;\n if ('channelAuthorization' in opts) {\n channelAuthorization = {\n ...Defaults.channelAuthorization,\n ...opts.channelAuthorization\n };\n } else {\n channelAuthorization = {\n transport: opts.authTransport || Defaults.authTransport,\n endpoint: opts.authEndpoint || Defaults.authEndpoint\n };\n if ('auth' in opts) {\n if ('params' in opts.auth) channelAuthorization.params = opts.auth.params;\n if ('headers' in opts.auth)\n channelAuthorization.headers = opts.auth.headers;\n }\n if ('authorizer' in opts)\n channelAuthorization.customHandler = ChannelAuthorizerProxy(\n pusher,\n channelAuthorization,\n opts.authorizer\n );\n }\n return channelAuthorization;\n}\n\nfunction buildChannelAuthorizer(\n opts: Options,\n pusher\n): ChannelAuthorizationHandler {\n const channelAuthorization = buildChannelAuth(opts, pusher);\n if (\n 'customHandler' in channelAuthorization &&\n channelAuthorization['customHandler'] != null\n ) {\n return channelAuthorization['customHandler'];\n }\n\n return ChannelAuthorizer(channelAuthorization);\n}\n","import Logger from './logger';\nimport Pusher from './pusher';\nimport EventsDispatcher from './events/dispatcher';\n\nexport default class WatchlistFacade extends EventsDispatcher {\n private pusher: Pusher;\n\n public constructor(pusher: Pusher) {\n super(function(eventName, data) {\n Logger.debug(`No callbacks on watchlist events for ${eventName}`);\n });\n\n this.pusher = pusher;\n this.bindWatchlistInternalEvent();\n }\n\n handleEvent(pusherEvent) {\n pusherEvent.data.events.forEach(watchlistEvent => {\n this.emit(watchlistEvent.name, watchlistEvent);\n });\n }\n\n private bindWatchlistInternalEvent() {\n this.pusher.connection.bind('message', pusherEvent => {\n var eventName = pusherEvent.event;\n if (eventName === 'pusher_internal:watchlist_events') {\n this.handleEvent(pusherEvent);\n }\n });\n }\n}\n","function flatPromise() {\n let resolve, reject;\n const promise = new Promise((res, rej) => {\n resolve = res;\n reject = rej;\n });\n return { promise, resolve, reject };\n}\n\nexport default flatPromise;\n","import Pusher from './pusher';\nimport Logger from './logger';\nimport {\n UserAuthenticationData,\n UserAuthenticationCallback\n} from './auth/options';\nimport Channel from './channels/channel';\nimport WatchlistFacade from './watchlist';\nimport EventsDispatcher from './events/dispatcher';\nimport flatPromise from './utils/flat_promise';\n\nexport default class UserFacade extends EventsDispatcher {\n pusher: Pusher;\n signin_requested: boolean = false;\n user_data: any = null;\n serverToUserChannel: Channel = null;\n signinDonePromise: Promise = null;\n watchlist: WatchlistFacade;\n private _signinDoneResolve: Function = null;\n\n public constructor(pusher: Pusher) {\n super(function(eventName, data) {\n Logger.debug('No callbacks on user for ' + eventName);\n });\n this.pusher = pusher;\n this.pusher.connection.bind('state_change', ({ previous, current }) => {\n if (previous !== 'connected' && current === 'connected') {\n this._signin();\n }\n if (previous === 'connected' && current !== 'connected') {\n this._cleanup();\n this._newSigninPromiseIfNeeded();\n }\n });\n\n this.watchlist = new WatchlistFacade(pusher);\n\n this.pusher.connection.bind('message', event => {\n var eventName = event.event;\n if (eventName === 'pusher:signin_success') {\n this._onSigninSuccess(event.data);\n }\n if (\n this.serverToUserChannel &&\n this.serverToUserChannel.name === event.channel\n ) {\n this.serverToUserChannel.handleEvent(event);\n }\n });\n }\n\n public signin() {\n if (this.signin_requested) {\n return;\n }\n\n this.signin_requested = true;\n this._signin();\n }\n\n private _signin() {\n if (!this.signin_requested) {\n return;\n }\n\n this._newSigninPromiseIfNeeded();\n\n if (this.pusher.connection.state !== 'connected') {\n // Signin will be attempted when the connection is connected\n return;\n }\n\n this.pusher.config.userAuthenticator(\n {\n socketId: this.pusher.connection.socket_id\n },\n this._onAuthorize\n );\n }\n\n private _onAuthorize: UserAuthenticationCallback = (\n err,\n authData: UserAuthenticationData\n ) => {\n if (err) {\n Logger.warn(`Error during signin: ${err}`);\n this._cleanup();\n return;\n }\n\n this.pusher.send_event('pusher:signin', {\n auth: authData.auth,\n user_data: authData.user_data\n });\n\n // Later when we get pusher:singin_success event, the user will be marked as signed in\n };\n\n private _onSigninSuccess(data: any) {\n try {\n this.user_data = JSON.parse(data.user_data);\n } catch (e) {\n Logger.error(`Failed parsing user data after signin: ${data.user_data}`);\n this._cleanup();\n return;\n }\n\n if (typeof this.user_data.id !== 'string' || this.user_data.id === '') {\n Logger.error(\n `user_data doesn't contain an id. user_data: ${this.user_data}`\n );\n this._cleanup();\n return;\n }\n\n // Signin succeeded\n this._signinDoneResolve();\n this._subscribeChannels();\n }\n\n private _subscribeChannels() {\n const ensure_subscribed = channel => {\n if (channel.subscriptionPending && channel.subscriptionCancelled) {\n channel.reinstateSubscription();\n } else if (\n !channel.subscriptionPending &&\n this.pusher.connection.state === 'connected'\n ) {\n channel.subscribe();\n }\n };\n\n this.serverToUserChannel = new Channel(\n `#server-to-user-${this.user_data.id}`,\n this.pusher\n );\n this.serverToUserChannel.bind_global((eventName, data) => {\n if (\n eventName.indexOf('pusher_internal:') === 0 ||\n eventName.indexOf('pusher:') === 0\n ) {\n // ignore internal events\n return;\n }\n this.emit(eventName, data);\n });\n ensure_subscribed(this.serverToUserChannel);\n }\n\n private _cleanup() {\n this.user_data = null;\n if (this.serverToUserChannel) {\n this.serverToUserChannel.unbind_all();\n this.serverToUserChannel.disconnect();\n this.serverToUserChannel = null;\n }\n\n if (this.signin_requested) {\n // If signin is in progress and cleanup is called,\n // Mark the current signin process as done.\n this._signinDoneResolve();\n }\n }\n\n private _newSigninPromiseIfNeeded() {\n if (!this.signin_requested) {\n return;\n }\n\n // If there is a promise and it is not resolved, return without creating a new one.\n if (this.signinDonePromise && !(this.signinDonePromise as any).done) {\n return;\n }\n\n // This promise is never rejected.\n // It gets resolved when the signin process is done whether it failed or succeeded\n const { promise, resolve, reject: _ } = flatPromise();\n (promise as any).done = false;\n const setDone = () => {\n (promise as any).done = true;\n };\n promise.then(setDone).catch(setDone);\n this.signinDonePromise = promise;\n this._signinDoneResolve = resolve;\n }\n}\n","import AbstractRuntime from '../runtimes/interface';\nimport Runtime from 'runtime';\nimport * as Collections from './utils/collections';\nimport Channels from './channels/channels';\nimport Channel from './channels/channel';\nimport { default as EventsDispatcher } from './events/dispatcher';\nimport Timeline from './timeline/timeline';\nimport TimelineSender from './timeline/timeline_sender';\nimport TimelineLevel from './timeline/level';\nimport { defineTransport } from './strategies/strategy_builder';\nimport ConnectionManager from './connection/connection_manager';\nimport { PeriodicTimer } from './utils/timers';\nimport Defaults from './defaults';\nimport Logger from './logger';\nimport Factory from './utils/factory';\nimport { Options, ClusterOptions, validateOptions } from './options';\nimport { Config, getConfig } from './config';\nimport StrategyOptions from './strategies/strategy_options';\nimport UserFacade from './user';\n\nexport default class Pusher {\n /* STATIC PROPERTIES */\n static instances: Pusher[] = [];\n static isReady: boolean = false;\n static logToConsole: boolean = false;\n\n // for jsonp\n static Runtime: AbstractRuntime = Runtime;\n static ScriptReceivers: any = (Runtime).ScriptReceivers;\n static DependenciesReceivers: any = (Runtime).DependenciesReceivers;\n static auth_callbacks: any = (Runtime).auth_callbacks;\n\n static ready() {\n Pusher.isReady = true;\n for (var i = 0, l = Pusher.instances.length; i < l; i++) {\n Pusher.instances[i].connect();\n }\n }\n\n static log: (message: any) => void;\n\n private static getClientFeatures(): string[] {\n return Collections.keys(\n Collections.filterObject({ ws: Runtime.Transports.ws }, function(t) {\n return t.isSupported({});\n })\n );\n }\n\n /* INSTANCE PROPERTIES */\n key: string;\n options: Options;\n config: Config;\n channels: Channels;\n global_emitter: EventsDispatcher;\n sessionID: number;\n timeline: Timeline;\n timelineSender: TimelineSender;\n connection: ConnectionManager;\n timelineSenderTimer: PeriodicTimer;\n user: UserFacade;\n constructor(app_key: string, options: Options) {\n checkAppKey(app_key);\n validateOptions(options);\n this.key = app_key;\n this.config = getConfig(options, this);\n\n this.channels = Factory.createChannels();\n this.global_emitter = new EventsDispatcher();\n this.sessionID = Runtime.randomInt(1000000000);\n\n this.timeline = new Timeline(this.key, this.sessionID, {\n cluster: this.config.cluster,\n features: Pusher.getClientFeatures(),\n params: this.config.timelineParams || {},\n limit: 50,\n level: TimelineLevel.INFO,\n version: Defaults.VERSION\n });\n if (this.config.enableStats) {\n this.timelineSender = Factory.createTimelineSender(this.timeline, {\n host: this.config.statsHost,\n path: '/timeline/v2/' + Runtime.TimelineTransport.name\n });\n }\n\n var getStrategy = (options: StrategyOptions) => {\n return Runtime.getDefaultStrategy(this.config, options, defineTransport);\n };\n\n this.connection = Factory.createConnectionManager(this.key, {\n getStrategy: getStrategy,\n timeline: this.timeline,\n activityTimeout: this.config.activityTimeout,\n pongTimeout: this.config.pongTimeout,\n unavailableTimeout: this.config.unavailableTimeout,\n useTLS: Boolean(this.config.useTLS)\n });\n\n this.connection.bind('connected', () => {\n this.subscribeAll();\n if (this.timelineSender) {\n this.timelineSender.send(this.connection.isUsingTLS());\n }\n });\n\n this.connection.bind('message', event => {\n var eventName = event.event;\n var internal = eventName.indexOf('pusher_internal:') === 0;\n if (event.channel) {\n var channel = this.channel(event.channel);\n if (channel) {\n channel.handleEvent(event);\n }\n }\n // Emit globally [deprecated]\n if (!internal) {\n this.global_emitter.emit(event.event, event.data);\n }\n });\n this.connection.bind('connecting', () => {\n this.channels.disconnect();\n });\n this.connection.bind('disconnected', () => {\n this.channels.disconnect();\n });\n this.connection.bind('error', err => {\n Logger.warn(err);\n });\n\n Pusher.instances.push(this);\n this.timeline.info({ instances: Pusher.instances.length });\n\n this.user = new UserFacade(this);\n\n if (Pusher.isReady) {\n this.connect();\n }\n }\n\n /**\n * Allows you to switch Pusher cluster without\n * losing all the channels/subscription binding\n * as this is internally managed by the SDK.\n */\n switchCluster(options: ClusterOptions) {\n const { appKey, cluster } = options;\n this.key = appKey;\n this.options = { ...this.options, cluster };\n this.config = getConfig(this.options, this);\n this.connection.switchCluster(this.key);\n }\n\n channel(name: string): Channel {\n return this.channels.find(name);\n }\n\n allChannels(): Channel[] {\n return this.channels.all();\n }\n\n connect() {\n this.connection.connect();\n\n if (this.timelineSender) {\n if (!this.timelineSenderTimer) {\n var usingTLS = this.connection.isUsingTLS();\n var timelineSender = this.timelineSender;\n this.timelineSenderTimer = new PeriodicTimer(60000, function() {\n timelineSender.send(usingTLS);\n });\n }\n }\n }\n\n disconnect() {\n this.connection.disconnect();\n\n if (this.timelineSenderTimer) {\n this.timelineSenderTimer.ensureAborted();\n this.timelineSenderTimer = null;\n }\n }\n\n bind(event_name: string, callback: Function, context?: any): Pusher {\n this.global_emitter.bind(event_name, callback, context);\n return this;\n }\n\n unbind(event_name?: string, callback?: Function, context?: any): Pusher {\n this.global_emitter.unbind(event_name, callback, context);\n return this;\n }\n\n bind_global(callback: Function): Pusher {\n this.global_emitter.bind_global(callback);\n return this;\n }\n\n unbind_global(callback?: Function): Pusher {\n this.global_emitter.unbind_global(callback);\n return this;\n }\n\n unbind_all(callback?: Function): Pusher {\n this.global_emitter.unbind_all();\n return this;\n }\n\n subscribeAll() {\n var channelName;\n for (channelName in this.channels.channels) {\n if (this.channels.channels.hasOwnProperty(channelName)) {\n this.subscribe(channelName);\n }\n }\n }\n\n subscribe(channel_name: string) {\n var channel = this.channels.add(channel_name, this);\n if (channel.subscriptionPending && channel.subscriptionCancelled) {\n channel.reinstateSubscription();\n } else if (\n !channel.subscriptionPending &&\n this.connection.state === 'connected'\n ) {\n channel.subscribe();\n }\n return channel;\n }\n\n unsubscribe(channel_name: string) {\n var channel = this.channels.find(channel_name);\n if (channel && channel.subscriptionPending) {\n channel.cancelSubscription();\n } else {\n channel = this.channels.remove(channel_name);\n if (channel && channel.subscribed) {\n channel.unsubscribe();\n }\n }\n }\n\n send_event(event_name: string, data: any, channel?: string) {\n return this.connection.send_event(event_name, data, channel);\n }\n\n shouldUseTLS(): boolean {\n return this.config.useTLS;\n }\n\n signin() {\n this.user.signin();\n }\n}\n\nfunction checkAppKey(key) {\n if (key === null || key === undefined) {\n throw 'You must pass your app key when you instantiate Pusher.';\n }\n}\n\nRuntime.setup(Pusher);\n"],"sourceRoot":""} \ No newline at end of file +{"version":3,"sources":["webpack://Pusher/webpack/universalModuleDefinition","webpack://Pusher/webpack/bootstrap","webpack://Pusher/./node_modules/@stablelib/base64/base64.ts","webpack://Pusher/./node_modules/@stablelib/utf8/utf8.ts","webpack://Pusher/./src/core/pusher.js","webpack://Pusher/./src/core/base64.ts","webpack://Pusher/./src/core/utils/timers/abstract_timer.ts","webpack://Pusher/./src/core/utils/timers/index.ts","webpack://Pusher/./src/core/util.ts","webpack://Pusher/./src/core/utils/collections.ts","webpack://Pusher/./src/core/defaults.ts","webpack://Pusher/./src/core/transports/url_schemes.ts","webpack://Pusher/./src/core/events/callback_registry.ts","webpack://Pusher/./src/core/events/dispatcher.ts","webpack://Pusher/./src/core/logger.ts","webpack://Pusher/./src/core/transports/transport_connection.ts","webpack://Pusher/./src/core/transports/transport.ts","webpack://Pusher/./src/runtimes/isomorphic/transports/transports.ts","webpack://Pusher/./src/core/transports/assistant_to_the_transport_manager.ts","webpack://Pusher/./src/core/connection/protocol/protocol.ts","webpack://Pusher/./src/core/connection/connection.ts","webpack://Pusher/./src/core/connection/handshake/index.ts","webpack://Pusher/./src/core/timeline/timeline_sender.ts","webpack://Pusher/./src/core/errors.ts","webpack://Pusher/./src/core/utils/url_store.ts","webpack://Pusher/./src/core/channels/channel.ts","webpack://Pusher/./src/core/channels/private_channel.ts","webpack://Pusher/./src/core/channels/members.ts","webpack://Pusher/./src/core/channels/presence_channel.ts","webpack://Pusher/./src/core/channels/encrypted_channel.ts","webpack://Pusher/./src/core/connection/connection_manager.ts","webpack://Pusher/./src/core/channels/channels.ts","webpack://Pusher/./src/core/utils/factory.ts","webpack://Pusher/./src/core/transports/transport_manager.ts","webpack://Pusher/./src/core/strategies/sequential_strategy.ts","webpack://Pusher/./src/core/strategies/best_connected_ever_strategy.ts","webpack://Pusher/./src/core/strategies/websocket_prioritized_cached_strategy.ts","webpack://Pusher/./src/core/strategies/delayed_strategy.ts","webpack://Pusher/./src/core/strategies/if_strategy.ts","webpack://Pusher/./src/core/strategies/first_connected_strategy.ts","webpack://Pusher/./src/runtimes/isomorphic/default_strategy.ts","webpack://Pusher/./src/runtimes/isomorphic/transports/transport_connection_initializer.ts","webpack://Pusher/./src/core/http/http_request.ts","webpack://Pusher/./src/core/http/state.ts","webpack://Pusher/./src/core/http/http_socket.ts","webpack://Pusher/./src/core/http/http_streaming_socket.ts","webpack://Pusher/./src/core/http/http_polling_socket.ts","webpack://Pusher/./src/runtimes/isomorphic/http/http_xhr_request.ts","webpack://Pusher/./src/runtimes/isomorphic/http/http.ts","webpack://Pusher/./src/runtimes/isomorphic/runtime.ts","webpack://Pusher/./src/runtimes/worker/net_info.ts","webpack://Pusher/./src/runtimes/worker/auth/fetch_auth.ts","webpack://Pusher/./src/runtimes/worker/timeline/fetch_timeline.ts","webpack://Pusher/./src/runtimes/worker/runtime.ts","webpack://Pusher/./src/core/timeline/level.ts","webpack://Pusher/./src/core/timeline/timeline.ts","webpack://Pusher/./src/core/strategies/transport_strategy.ts","webpack://Pusher/./src/core/strategies/strategy_builder.ts","webpack://Pusher/./src/core/options.ts","webpack://Pusher/./src/core/auth/options.ts","webpack://Pusher/./src/core/auth/user_authenticator.ts","webpack://Pusher/./src/core/auth/channel_authorizer.ts","webpack://Pusher/./src/core/auth/deprecated_channel_authorizer.ts","webpack://Pusher/./src/core/config.ts","webpack://Pusher/./src/core/watchlist.ts","webpack://Pusher/./src/core/utils/flat_promise.ts","webpack://Pusher/./src/core/user.ts","webpack://Pusher/./src/core/pusher.ts"],"names":[],"mappings":";;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AACD,O;QCVA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;;QAEA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;;;QAGA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;QACA,0CAA0C,gCAAgC;QAC1E;QACA;;QAEA;QACA;QACA;QACA,wDAAwD,kBAAkB;QAC1E;QACA,iDAAiD,cAAc;QAC/D;;QAEA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA,yCAAyC,iCAAiC;QAC1E,gHAAgH,mBAAmB,EAAE;QACrI;QACA;;QAEA;QACA;QACA;QACA,2BAA2B,0BAA0B,EAAE;QACvD,iCAAiC,eAAe;QAChD;QACA;QACA;;QAEA;QACA,sDAAsD,+DAA+D;;QAErH;QACA;;;QAGA;QACA;;;;;;;;;AClFA,sCAAsC;AACtC,6CAA6C;;;;;;;;;;;;;;;AAE7C;;GAEG;AAEH,iDAAiD;AACjD,kDAAkD;AAClD,kCAAkC;AAClC,IAAM,YAAY,GAAG,GAAG,CAAC;AAEzB;;;;GAIG;AACH;IACI,kDAAkD;IAElD,eAAoB,iBAAuB;QAAvB,2DAAuB;QAAvB,sBAAiB,GAAjB,iBAAiB,CAAM;IAAI,CAAC;IAEhD,6BAAa,GAAb,UAAc,MAAc;QACxB,IAAI,CAAC,IAAI,CAAC,iBAAiB,EAAE;YACzB,OAAO,CAAC,MAAM,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;SACnC;QACD,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IACpC,CAAC;IAED,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,kBAAkB,EAAE,CAAC;SAC9B;aAAM;YACL,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;YAC7C,IAAI,OAAO,IAAI,OAAO,CAAC,UAAU,EAAE;gBACjC,OAAO,CAAC,WAAW,EAAE,CAAC;aACvB;SACF;IACH,CAAC;IAED,UAAU,CAAC,UAAkB,EAAE,IAAS,EAAE,OAAgB;QACxD,OAAO,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC,UAAU,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;IAC/D,CAAC;IAED,YAAY;QACV,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC;IAC5B,CAAC;IAED,MAAM;QACJ,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;IACrB,CAAC;;AAvOM,uBAAS,GAAa,EAAE,CAAC;AACzB,qBAAO,GAAY,KAAK,CAAC;AACzB,0BAAY,GAAY,KAAK,CAAC;AAG9B,qBAAO,GAAoB,cAAO,CAAC;AACnC,6BAAe,GAAc,cAAQ,CAAC,eAAe,CAAC;AACtD,mCAAqB,GAAc,cAAQ,CAAC,qBAAqB,CAAC;AAClE,4BAAc,GAAc,cAAQ,CAAC,cAAc,CAAC;AAVxC,8FAAM;AA4O3B,SAAS,WAAW,CAAC,GAAG;IACtB,IAAI,GAAG,KAAK,IAAI,IAAI,GAAG,KAAK,SAAS,EAAE;QACrC,MAAM,yDAAyD,CAAC;KACjE;AACH,CAAC;AAED,cAAO,CAAC,KAAK,CAAC,aAAM,CAAC,CAAC","file":"pusher.worker.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"Pusher\"] = factory();\n\telse\n\t\troot[\"Pusher\"] = factory();\n})(this, function() {\nreturn "," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 2);\n","// Copyright (C) 2016 Dmitry Chestnykh\n// MIT License. See LICENSE file for details.\n\n/**\n * Package base64 implements Base64 encoding and decoding.\n */\n\n// Invalid character used in decoding to indicate\n// that the character to decode is out of range of\n// alphabet and cannot be decoded.\nconst INVALID_BYTE = 256;\n\n/**\n * Implements standard Base64 encoding.\n *\n * Operates in constant time.\n */\nexport class Coder {\n // TODO(dchest): methods to encode chunk-by-chunk.\n\n constructor(private _paddingCharacter = \"=\") { }\n\n encodedLength(length: number): number {\n if (!this._paddingCharacter) {\n return (length * 8 + 5) / 6 | 0;\n }\n return (length + 2) / 3 * 4 | 0;\n }\n\n encode(data: Uint8Array): string {\n let out = \"\";\n\n let i = 0;\n for (; i < data.length - 2; i += 3) {\n let c = (data[i] << 16) | (data[i + 1] << 8) | (data[i + 2]);\n out += this._encodeByte((c >>> 3 * 6) & 63);\n out += this._encodeByte((c >>> 2 * 6) & 63);\n out += this._encodeByte((c >>> 1 * 6) & 63);\n out += this._encodeByte((c >>> 0 * 6) & 63);\n }\n\n const left = data.length - i;\n if (left > 0) {\n let c = (data[i] << 16) | (left === 2 ? data[i + 1] << 8 : 0);\n out += this._encodeByte((c >>> 3 * 6) & 63);\n out += this._encodeByte((c >>> 2 * 6) & 63);\n if (left === 2) {\n out += this._encodeByte((c >>> 1 * 6) & 63);\n } else {\n out += this._paddingCharacter || \"\";\n }\n out += this._paddingCharacter || \"\";\n }\n\n return out;\n }\n\n maxDecodedLength(length: number): number {\n if (!this._paddingCharacter) {\n return (length * 6 + 7) / 8 | 0;\n }\n return length / 4 * 3 | 0;\n }\n\n decodedLength(s: string): number {\n return this.maxDecodedLength(s.length - this._getPaddingLength(s));\n }\n\n decode(s: string): Uint8Array {\n if (s.length === 0) {\n return new Uint8Array(0);\n }\n const paddingLength = this._getPaddingLength(s);\n const length = s.length - paddingLength;\n const out = new Uint8Array(this.maxDecodedLength(length));\n let op = 0;\n let i = 0;\n let haveBad = 0;\n let v0 = 0, v1 = 0, v2 = 0, v3 = 0;\n for (; i < length - 4; i += 4) {\n v0 = this._decodeChar(s.charCodeAt(i + 0));\n v1 = this._decodeChar(s.charCodeAt(i + 1));\n v2 = this._decodeChar(s.charCodeAt(i + 2));\n v3 = this._decodeChar(s.charCodeAt(i + 3));\n out[op++] = (v0 << 2) | (v1 >>> 4);\n out[op++] = (v1 << 4) | (v2 >>> 2);\n out[op++] = (v2 << 6) | v3;\n haveBad |= v0 & INVALID_BYTE;\n haveBad |= v1 & INVALID_BYTE;\n haveBad |= v2 & INVALID_BYTE;\n haveBad |= v3 & INVALID_BYTE;\n }\n if (i < length - 1) {\n v0 = this._decodeChar(s.charCodeAt(i));\n v1 = this._decodeChar(s.charCodeAt(i + 1));\n out[op++] = (v0 << 2) | (v1 >>> 4);\n haveBad |= v0 & INVALID_BYTE;\n haveBad |= v1 & INVALID_BYTE;\n }\n if (i < length - 2) {\n v2 = this._decodeChar(s.charCodeAt(i + 2));\n out[op++] = (v1 << 4) | (v2 >>> 2);\n haveBad |= v2 & INVALID_BYTE;\n }\n if (i < length - 3) {\n v3 = this._decodeChar(s.charCodeAt(i + 3));\n out[op++] = (v2 << 6) | v3;\n haveBad |= v3 & INVALID_BYTE;\n }\n if (haveBad !== 0) {\n throw new Error(\"Base64Coder: incorrect characters for decoding\");\n }\n return out;\n }\n\n // Standard encoding have the following encoded/decoded ranges,\n // which we need to convert between.\n //\n // ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 0123456789 + /\n // Index: 0 - 25 26 - 51 52 - 61 62 63\n // ASCII: 65 - 90 97 - 122 48 - 57 43 47\n //\n\n // Encode 6 bits in b into a new character.\n protected _encodeByte(b: number): string {\n // Encoding uses constant time operations as follows:\n //\n // 1. Define comparison of A with B using (A - B) >>> 8:\n // if A > B, then result is positive integer\n // if A <= B, then result is 0\n //\n // 2. Define selection of C or 0 using bitwise AND: X & C:\n // if X == 0, then result is 0\n // if X != 0, then result is C\n //\n // 3. Start with the smallest comparison (b >= 0), which is always\n // true, so set the result to the starting ASCII value (65).\n //\n // 4. Continue comparing b to higher ASCII values, and selecting\n // zero if comparison isn't true, otherwise selecting a value\n // to add to result, which:\n //\n // a) undoes the previous addition\n // b) provides new value to add\n //\n let result = b;\n // b >= 0\n result += 65;\n // b > 25\n result += ((25 - b) >>> 8) & ((0 - 65) - 26 + 97);\n // b > 51\n result += ((51 - b) >>> 8) & ((26 - 97) - 52 + 48);\n // b > 61\n result += ((61 - b) >>> 8) & ((52 - 48) - 62 + 43);\n // b > 62\n result += ((62 - b) >>> 8) & ((62 - 43) - 63 + 47);\n\n return String.fromCharCode(result);\n }\n\n // Decode a character code into a byte.\n // Must return 256 if character is out of alphabet range.\n protected _decodeChar(c: number): number {\n // Decoding works similar to encoding: using the same comparison\n // function, but now it works on ranges: result is always incremented\n // by value, but this value becomes zero if the range is not\n // satisfied.\n //\n // Decoding starts with invalid value, 256, which is then\n // subtracted when the range is satisfied. If none of the ranges\n // apply, the function returns 256, which is then checked by\n // the caller to throw error.\n let result = INVALID_BYTE; // start with invalid character\n\n // c == 43 (c > 42 and c < 44)\n result += (((42 - c) & (c - 44)) >>> 8) & (-INVALID_BYTE + c - 43 + 62);\n // c == 47 (c > 46 and c < 48)\n result += (((46 - c) & (c - 48)) >>> 8) & (-INVALID_BYTE + c - 47 + 63);\n // c > 47 and c < 58\n result += (((47 - c) & (c - 58)) >>> 8) & (-INVALID_BYTE + c - 48 + 52);\n // c > 64 and c < 91\n result += (((64 - c) & (c - 91)) >>> 8) & (-INVALID_BYTE + c - 65 + 0);\n // c > 96 and c < 123\n result += (((96 - c) & (c - 123)) >>> 8) & (-INVALID_BYTE + c - 97 + 26);\n\n return result;\n }\n\n private _getPaddingLength(s: string): number {\n let paddingLength = 0;\n if (this._paddingCharacter) {\n for (let i = s.length - 1; i >= 0; i--) {\n if (s[i] !== this._paddingCharacter) {\n break;\n }\n paddingLength++;\n }\n if (s.length < 4 || paddingLength > 2) {\n throw new Error(\"Base64Coder: incorrect padding\");\n }\n }\n return paddingLength;\n }\n\n}\n\nconst stdCoder = new Coder();\n\nexport function encode(data: Uint8Array): string {\n return stdCoder.encode(data);\n}\n\nexport function decode(s: string): Uint8Array {\n return stdCoder.decode(s);\n}\n\n/**\n * Implements URL-safe Base64 encoding.\n * (Same as Base64, but '+' is replaced with '-', and '/' with '_').\n *\n * Operates in constant time.\n */\nexport class URLSafeCoder extends Coder {\n // URL-safe encoding have the following encoded/decoded ranges:\n //\n // ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 0123456789 - _\n // Index: 0 - 25 26 - 51 52 - 61 62 63\n // ASCII: 65 - 90 97 - 122 48 - 57 45 95\n //\n\n protected _encodeByte(b: number): string {\n let result = b;\n // b >= 0\n result += 65;\n // b > 25\n result += ((25 - b) >>> 8) & ((0 - 65) - 26 + 97);\n // b > 51\n result += ((51 - b) >>> 8) & ((26 - 97) - 52 + 48);\n // b > 61\n result += ((61 - b) >>> 8) & ((52 - 48) - 62 + 45);\n // b > 62\n result += ((62 - b) >>> 8) & ((62 - 45) - 63 + 95);\n\n return String.fromCharCode(result);\n }\n\n protected _decodeChar(c: number): number {\n let result = INVALID_BYTE;\n\n // c == 45 (c > 44 and c < 46)\n result += (((44 - c) & (c - 46)) >>> 8) & (-INVALID_BYTE + c - 45 + 62);\n // c == 95 (c > 94 and c < 96)\n result += (((94 - c) & (c - 96)) >>> 8) & (-INVALID_BYTE + c - 95 + 63);\n // c > 47 and c < 58\n result += (((47 - c) & (c - 58)) >>> 8) & (-INVALID_BYTE + c - 48 + 52);\n // c > 64 and c < 91\n result += (((64 - c) & (c - 91)) >>> 8) & (-INVALID_BYTE + c - 65 + 0);\n // c > 96 and c < 123\n result += (((96 - c) & (c - 123)) >>> 8) & (-INVALID_BYTE + c - 97 + 26);\n\n return result;\n }\n}\n\nconst urlSafeCoder = new URLSafeCoder();\n\nexport function encodeURLSafe(data: Uint8Array): string {\n return urlSafeCoder.encode(data);\n}\n\nexport function decodeURLSafe(s: string): Uint8Array {\n return urlSafeCoder.decode(s);\n}\n\n\nexport const encodedLength = (length: number) =>\n stdCoder.encodedLength(length);\n\nexport const maxDecodedLength = (length: number) =>\n stdCoder.maxDecodedLength(length);\n\nexport const decodedLength = (s: string) =>\n stdCoder.decodedLength(s);\n","// Copyright (C) 2016 Dmitry Chestnykh\n// MIT License. See LICENSE file for details.\n\n/**\n * Package utf8 implements UTF-8 encoding and decoding.\n */\n\nconst INVALID_UTF16 = \"utf8: invalid string\";\nconst INVALID_UTF8 = \"utf8: invalid source encoding\";\n\n/**\n * Encodes the given string into UTF-8 byte array.\n * Throws if the source string has invalid UTF-16 encoding.\n */\nexport function encode(s: string): Uint8Array {\n // Calculate result length and allocate output array.\n // encodedLength() also validates string and throws errors,\n // so we don't need repeat validation here.\n const arr = new Uint8Array(encodedLength(s));\n\n let pos = 0;\n for (let i = 0; i < s.length; i++) {\n let c = s.charCodeAt(i);\n if (c < 0x80) {\n arr[pos++] = c;\n } else if (c < 0x800) {\n arr[pos++] = 0xc0 | c >> 6;\n arr[pos++] = 0x80 | c & 0x3f;\n } else if (c < 0xd800) {\n arr[pos++] = 0xe0 | c >> 12;\n arr[pos++] = 0x80 | (c >> 6) & 0x3f;\n arr[pos++] = 0x80 | c & 0x3f;\n } else {\n i++; // get one more character\n c = (c & 0x3ff) << 10;\n c |= s.charCodeAt(i) & 0x3ff;\n c += 0x10000;\n\n arr[pos++] = 0xf0 | c >> 18;\n arr[pos++] = 0x80 | (c >> 12) & 0x3f;\n arr[pos++] = 0x80 | (c >> 6) & 0x3f;\n arr[pos++] = 0x80 | c & 0x3f;\n }\n }\n return arr;\n}\n\n/**\n * Returns the number of bytes required to encode the given string into UTF-8.\n * Throws if the source string has invalid UTF-16 encoding.\n */\nexport function encodedLength(s: string): number {\n let result = 0;\n for (let i = 0; i < s.length; i++) {\n const c = s.charCodeAt(i);\n if (c < 0x80) {\n result += 1;\n } else if (c < 0x800) {\n result += 2;\n } else if (c < 0xd800) {\n result += 3;\n } else if (c <= 0xdfff) {\n if (i >= s.length - 1) {\n throw new Error(INVALID_UTF16);\n }\n i++; // \"eat\" next character\n result += 4;\n } else {\n throw new Error(INVALID_UTF16);\n }\n }\n return result;\n}\n\n/**\n * Decodes the given byte array from UTF-8 into a string.\n * Throws if encoding is invalid.\n */\nexport function decode(arr: Uint8Array): string {\n const chars: string[] = [];\n for (let i = 0; i < arr.length; i++) {\n let b = arr[i];\n\n if (b & 0x80) {\n let min;\n if (b < 0xe0) {\n // Need 1 more byte.\n if (i >= arr.length) {\n throw new Error(INVALID_UTF8);\n }\n const n1 = arr[++i];\n if ((n1 & 0xc0) !== 0x80) {\n throw new Error(INVALID_UTF8);\n }\n b = (b & 0x1f) << 6 | (n1 & 0x3f);\n min = 0x80;\n } else if (b < 0xf0) {\n // Need 2 more bytes.\n if (i >= arr.length - 1) {\n throw new Error(INVALID_UTF8);\n }\n const n1 = arr[++i];\n const n2 = arr[++i];\n if ((n1 & 0xc0) !== 0x80 || (n2 & 0xc0) !== 0x80) {\n throw new Error(INVALID_UTF8);\n }\n b = (b & 0x0f) << 12 | (n1 & 0x3f) << 6 | (n2 & 0x3f);\n min = 0x800;\n } else if (b < 0xf8) {\n // Need 3 more bytes.\n if (i >= arr.length - 2) {\n throw new Error(INVALID_UTF8);\n }\n const n1 = arr[++i];\n const n2 = arr[++i];\n const n3 = arr[++i];\n if ((n1 & 0xc0) !== 0x80 || (n2 & 0xc0) !== 0x80 || (n3 & 0xc0) !== 0x80) {\n throw new Error(INVALID_UTF8);\n }\n b = (b & 0x0f) << 18 | (n1 & 0x3f) << 12 | (n2 & 0x3f) << 6 | (n3 & 0x3f);\n min = 0x10000;\n } else {\n throw new Error(INVALID_UTF8);\n }\n\n if (b < min || (b >= 0xd800 && b <= 0xdfff)) {\n throw new Error(INVALID_UTF8);\n }\n\n if (b >= 0x10000) {\n // Surrogate pair.\n if (b > 0x10ffff) {\n throw new Error(INVALID_UTF8);\n }\n b -= 0x10000;\n chars.push(String.fromCharCode(0xd800 | (b >> 10)));\n b = 0xdc00 | (b & 0x3ff);\n }\n }\n\n chars.push(String.fromCharCode(b));\n }\n return chars.join(\"\");\n}\n","// required so we don't have to do require('pusher').default etc.\nmodule.exports = require('./pusher').default;\n","export default function encode(s: any): string {\n return btoa(utob(s));\n}\n\nvar fromCharCode = String.fromCharCode;\n\nvar b64chars =\n 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';\nvar b64tab = {};\n\nfor (var i = 0, l = b64chars.length; i < l; i++) {\n b64tab[b64chars.charAt(i)] = i;\n}\n\nvar cb_utob = function(c) {\n var cc = c.charCodeAt(0);\n return cc < 0x80\n ? c\n : cc < 0x800\n ? fromCharCode(0xc0 | (cc >>> 6)) + fromCharCode(0x80 | (cc & 0x3f))\n : fromCharCode(0xe0 | ((cc >>> 12) & 0x0f)) +\n fromCharCode(0x80 | ((cc >>> 6) & 0x3f)) +\n fromCharCode(0x80 | (cc & 0x3f));\n};\n\nvar utob = function(u) {\n return u.replace(/[^\\x00-\\x7F]/g, cb_utob);\n};\n\nvar cb_encode = function(ccc) {\n var padlen = [0, 2, 1][ccc.length % 3];\n var ord =\n (ccc.charCodeAt(0) << 16) |\n ((ccc.length > 1 ? ccc.charCodeAt(1) : 0) << 8) |\n (ccc.length > 2 ? ccc.charCodeAt(2) : 0);\n var chars = [\n b64chars.charAt(ord >>> 18),\n b64chars.charAt((ord >>> 12) & 63),\n padlen >= 2 ? '=' : b64chars.charAt((ord >>> 6) & 63),\n padlen >= 1 ? '=' : b64chars.charAt(ord & 63)\n ];\n return chars.join('');\n};\n\nvar btoa =\n global.btoa ||\n function(b) {\n return b.replace(/[\\s\\S]{1,3}/g, cb_encode);\n };\n","import TimedCallback from './timed_callback';\nimport { Delay, Scheduler, Canceller } from './scheduling';\n\nabstract class Timer {\n protected clear: Canceller;\n protected timer: number | void;\n\n constructor(\n set: Scheduler,\n clear: Canceller,\n delay: Delay,\n callback: TimedCallback\n ) {\n this.clear = clear;\n this.timer = set(() => {\n if (this.timer) {\n this.timer = callback(this.timer);\n }\n }, delay);\n }\n\n /** Returns whether the timer is still running.\n *\n * @return {Boolean}\n */\n isRunning(): boolean {\n return this.timer !== null;\n }\n\n /** Aborts a timer when it's running. */\n ensureAborted() {\n if (this.timer) {\n this.clear(this.timer);\n this.timer = null;\n }\n }\n}\n\nexport default Timer;\n","import Timer from './abstract_timer';\nimport TimedCallback from './timed_callback';\nimport { Delay } from './scheduling';\n\n// We need to bind clear functions this way to avoid exceptions on IE8\nfunction clearTimeout(timer) {\n global.clearTimeout(timer);\n}\nfunction clearInterval(timer) {\n global.clearInterval(timer);\n}\n\n/** Cross-browser compatible one-off timer abstraction.\n *\n * @param {Number} delay\n * @param {Function} callback\n */\nexport class OneOffTimer extends Timer {\n constructor(delay: Delay, callback: TimedCallback) {\n super(setTimeout, clearTimeout, delay, function(timer) {\n callback();\n return null;\n });\n }\n}\n\n/** Cross-browser compatible periodic timer abstraction.\n *\n * @param {Number} delay\n * @param {Function} callback\n */\nexport class PeriodicTimer extends Timer {\n constructor(delay: Delay, callback: TimedCallback) {\n super(setInterval, clearInterval, delay, function(timer) {\n callback();\n return timer;\n });\n }\n}\n","import * as Collections from './utils/collections';\nimport TimedCallback from './utils/timers/timed_callback';\nimport { OneOffTimer, PeriodicTimer } from './utils/timers';\n\nvar Util = {\n now(): number {\n if (Date.now) {\n return Date.now();\n } else {\n return new Date().valueOf();\n }\n },\n\n defer(callback: TimedCallback): OneOffTimer {\n return new OneOffTimer(0, callback);\n },\n\n /** Builds a function that will proxy a method call to its first argument.\n *\n * Allows partial application of arguments, so additional arguments are\n * prepended to the argument list.\n *\n * @param {String} name method name\n * @return {Function} proxy function\n */\n method(name: string, ...args: any[]): Function {\n var boundArguments = Array.prototype.slice.call(arguments, 1);\n return function(object) {\n return object[name].apply(object, boundArguments.concat(arguments));\n };\n }\n};\n\nexport default Util;\n","import base64encode from '../base64';\nimport Util from '../util';\n\n/** Merges multiple objects into the target argument.\n *\n * For properties that are plain Objects, performs a deep-merge. For the\n * rest it just copies the value of the property.\n *\n * To extend prototypes use it as following:\n * Pusher.Util.extend(Target.prototype, Base.prototype)\n *\n * You can also use it to merge objects without altering them:\n * Pusher.Util.extend({}, object1, object2)\n *\n * @param {Object} target\n * @return {Object} the target argument\n */\nexport function extend(target: any, ...sources: any[]): T {\n for (var i = 0; i < sources.length; i++) {\n var extensions = sources[i];\n for (var property in extensions) {\n if (\n extensions[property] &&\n extensions[property].constructor &&\n extensions[property].constructor === Object\n ) {\n target[property] = extend(target[property] || {}, extensions[property]);\n } else {\n target[property] = extensions[property];\n }\n }\n }\n return target;\n}\n\nexport function stringify(): string {\n var m = ['Pusher'];\n for (var i = 0; i < arguments.length; i++) {\n if (typeof arguments[i] === 'string') {\n m.push(arguments[i]);\n } else {\n m.push(safeJSONStringify(arguments[i]));\n }\n }\n return m.join(' : ');\n}\n\nexport function arrayIndexOf(array: any[], item: any): number {\n // MSIE doesn't have array.indexOf\n var nativeIndexOf = Array.prototype.indexOf;\n if (array === null) {\n return -1;\n }\n if (nativeIndexOf && array.indexOf === nativeIndexOf) {\n return array.indexOf(item);\n }\n for (var i = 0, l = array.length; i < l; i++) {\n if (array[i] === item) {\n return i;\n }\n }\n return -1;\n}\n\n/** Applies a function f to all properties of an object.\n *\n * Function f gets 3 arguments passed:\n * - element from the object\n * - key of the element\n * - reference to the object\n *\n * @param {Object} object\n * @param {Function} f\n */\nexport function objectApply(object: any, f: Function) {\n for (var key in object) {\n if (Object.prototype.hasOwnProperty.call(object, key)) {\n f(object[key], key, object);\n }\n }\n}\n\n/** Return a list of objects own proerty keys\n *\n * @param {Object} object\n * @returns {Array}\n */\nexport function keys(object: any): string[] {\n var keys = [];\n objectApply(object, function(_, key) {\n keys.push(key);\n });\n return keys;\n}\n\n/** Return a list of object's own property values\n *\n * @param {Object} object\n * @returns {Array}\n */\nexport function values(object: any): any[] {\n var values = [];\n objectApply(object, function(value) {\n values.push(value);\n });\n return values;\n}\n\n/** Applies a function f to all elements of an array.\n *\n * Function f gets 3 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function apply(array: any[], f: Function, context?: any) {\n for (var i = 0; i < array.length; i++) {\n f.call(context || global, array[i], i, array);\n }\n}\n\n/** Maps all elements of the array and returns the result.\n *\n * Function f gets 4 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n * - reference to the destination array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function map(array: any[], f: Function): any[] {\n var result = [];\n for (var i = 0; i < array.length; i++) {\n result.push(f(array[i], i, array, result));\n }\n return result;\n}\n\n/** Maps all elements of the object and returns the result.\n *\n * Function f gets 4 arguments passed:\n * - element from the object\n * - key of the element\n * - reference to the source object\n * - reference to the destination object\n *\n * @param {Object} object\n * @param {Function} f\n */\nexport function mapObject(object: any, f: Function): any {\n var result = {};\n objectApply(object, function(value, key) {\n result[key] = f(value);\n });\n return result;\n}\n\n/** Filters elements of the array using a test function.\n *\n * Function test gets 4 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n * - reference to the destination array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function filter(array: any[], test: Function): any[] {\n test =\n test ||\n function(value) {\n return !!value;\n };\n\n var result = [];\n for (var i = 0; i < array.length; i++) {\n if (test(array[i], i, array, result)) {\n result.push(array[i]);\n }\n }\n return result;\n}\n\n/** Filters properties of the object using a test function.\n *\n * Function test gets 4 arguments passed:\n * - element from the object\n * - key of the element\n * - reference to the source object\n * - reference to the destination object\n *\n * @param {Object} object\n * @param {Function} f\n */\nexport function filterObject(object: Object, test: Function) {\n var result = {};\n objectApply(object, function(value, key) {\n if ((test && test(value, key, object, result)) || Boolean(value)) {\n result[key] = value;\n }\n });\n return result;\n}\n\n/** Flattens an object into a two-dimensional array.\n *\n * @param {Object} object\n * @return {Array} resulting array of [key, value] pairs\n */\nexport function flatten(object: Object): any[] {\n var result = [];\n objectApply(object, function(value, key) {\n result.push([key, value]);\n });\n return result;\n}\n\n/** Checks whether any element of the array passes the test.\n *\n * Function test gets 3 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function any(array: any[], test: Function): boolean {\n for (var i = 0; i < array.length; i++) {\n if (test(array[i], i, array)) {\n return true;\n }\n }\n return false;\n}\n\n/** Checks whether all elements of the array pass the test.\n *\n * Function test gets 3 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function all(array: any[], test: Function): boolean {\n for (var i = 0; i < array.length; i++) {\n if (!test(array[i], i, array)) {\n return false;\n }\n }\n return true;\n}\n\nexport function encodeParamsObject(data): string {\n return mapObject(data, function(value) {\n if (typeof value === 'object') {\n value = safeJSONStringify(value);\n }\n return encodeURIComponent(base64encode(value.toString()));\n });\n}\n\nexport function buildQueryString(data: any): string {\n var params = filterObject(data, function(value) {\n return value !== undefined;\n });\n\n var query = map(\n flatten(encodeParamsObject(params)),\n Util.method('join', '=')\n ).join('&');\n\n return query;\n}\n\n/**\n * See https://github.com/douglascrockford/JSON-js/blob/master/cycle.js\n *\n * Remove circular references from an object. Required for JSON.stringify in\n * React Native, which tends to blow up a lot.\n *\n * @param {any} object\n * @return {any} Decycled object\n */\nexport function decycleObject(object: any): any {\n var objects = [],\n paths = [];\n\n return (function derez(value, path) {\n var i, name, nu;\n\n switch (typeof value) {\n case 'object':\n if (!value) {\n return null;\n }\n for (i = 0; i < objects.length; i += 1) {\n if (objects[i] === value) {\n return { $ref: paths[i] };\n }\n }\n\n objects.push(value);\n paths.push(path);\n\n if (Object.prototype.toString.apply(value) === '[object Array]') {\n nu = [];\n for (i = 0; i < value.length; i += 1) {\n nu[i] = derez(value[i], path + '[' + i + ']');\n }\n } else {\n nu = {};\n for (name in value) {\n if (Object.prototype.hasOwnProperty.call(value, name)) {\n nu[name] = derez(\n value[name],\n path + '[' + JSON.stringify(name) + ']'\n );\n }\n }\n }\n return nu;\n case 'number':\n case 'string':\n case 'boolean':\n return value;\n }\n })(object, '$');\n}\n\n/**\n * Provides a cross-browser and cross-platform way to safely stringify objects\n * into JSON. This is particularly necessary for ReactNative, where circular JSON\n * structures throw an exception.\n *\n * @param {any} source The object to stringify\n * @return {string} The serialized output.\n */\nexport function safeJSONStringify(source: any): string {\n try {\n return JSON.stringify(source);\n } catch (e) {\n return JSON.stringify(decycleObject(source));\n }\n}\n","import {\n ChannelAuthorizationOptions,\n UserAuthenticationOptions\n} from './auth/options';\nimport { AuthTransport } from './config';\n\nexport interface DefaultConfig {\n VERSION: string;\n PROTOCOL: number;\n wsPort: number;\n wssPort: number;\n wsPath: string;\n httpHost: string;\n httpPort: number;\n httpsPort: number;\n httpPath: string;\n stats_host: string;\n authEndpoint: string;\n authTransport: AuthTransport;\n activityTimeout: number;\n pongTimeout: number;\n unavailableTimeout: number;\n userAuthentication: UserAuthenticationOptions;\n channelAuthorization: ChannelAuthorizationOptions;\n\n cdn_http?: string;\n cdn_https?: string;\n dependency_suffix?: string;\n}\n\nvar Defaults: DefaultConfig = {\n VERSION: VERSION,\n PROTOCOL: 7,\n\n wsPort: 80,\n wssPort: 443,\n wsPath: '',\n // DEPRECATED: SockJS fallback parameters\n httpHost: 'sockjs.pusher.com',\n httpPort: 80,\n httpsPort: 443,\n httpPath: '/pusher',\n // DEPRECATED: Stats\n stats_host: 'stats.pusher.com',\n // DEPRECATED: Other settings\n authEndpoint: '/pusher/auth',\n authTransport: 'ajax',\n activityTimeout: 120000,\n pongTimeout: 30000,\n unavailableTimeout: 10000,\n userAuthentication: {\n endpoint: '/pusher/user-auth',\n transport: 'ajax'\n },\n channelAuthorization: {\n endpoint: '/pusher/auth',\n transport: 'ajax'\n },\n\n // CDN configuration\n cdn_http: CDN_HTTP,\n cdn_https: CDN_HTTPS,\n dependency_suffix: DEPENDENCY_SUFFIX\n};\n\nexport default Defaults;\n","import Defaults from '../defaults';\nimport { default as URLScheme, URLSchemeParams } from './url_scheme';\n\nfunction getGenericURL(\n baseScheme: string,\n params: URLSchemeParams,\n path: string\n): string {\n var scheme = baseScheme + (params.useTLS ? 's' : '');\n var host = params.useTLS ? params.hostTLS : params.hostNonTLS;\n return scheme + '://' + host + path;\n}\n\nfunction getGenericPath(key: string, queryString?: string): string {\n var path = '/app/' + key;\n var query =\n '?protocol=' +\n Defaults.PROTOCOL +\n '&client=js' +\n '&version=' +\n Defaults.VERSION +\n (queryString ? '&' + queryString : '');\n return path + query;\n}\n\nexport var ws: URLScheme = {\n getInitial: function(key: string, params: URLSchemeParams): string {\n var path = (params.httpPath || '') + getGenericPath(key, 'flash=false');\n return getGenericURL('ws', params, path);\n }\n};\n\nexport var http: URLScheme = {\n getInitial: function(key: string, params: URLSchemeParams): string {\n var path = (params.httpPath || '/pusher') + getGenericPath(key);\n return getGenericURL('http', params, path);\n }\n};\n\nexport var sockjs: URLScheme = {\n getInitial: function(key: string, params: URLSchemeParams): string {\n return getGenericURL('http', params, params.httpPath || '/pusher');\n },\n getPath: function(key: string, params: URLSchemeParams): string {\n return getGenericPath(key);\n }\n};\n","import Callback from './callback';\nimport * as Collections from '../utils/collections';\nimport CallbackTable from './callback_table';\n\nexport default class CallbackRegistry {\n _callbacks: CallbackTable;\n\n constructor() {\n this._callbacks = {};\n }\n\n get(name: string): Callback[] {\n return this._callbacks[prefix(name)];\n }\n\n add(name: string, callback: Function, context: any) {\n var prefixedEventName = prefix(name);\n this._callbacks[prefixedEventName] =\n this._callbacks[prefixedEventName] || [];\n this._callbacks[prefixedEventName].push({\n fn: callback,\n context: context\n });\n }\n\n remove(name?: string, callback?: Function, context?: any) {\n if (!name && !callback && !context) {\n this._callbacks = {};\n return;\n }\n\n var names = name ? [prefix(name)] : Collections.keys(this._callbacks);\n\n if (callback || context) {\n this.removeCallback(names, callback, context);\n } else {\n this.removeAllCallbacks(names);\n }\n }\n\n private removeCallback(names: string[], callback: Function, context: any) {\n Collections.apply(\n names,\n function(name) {\n this._callbacks[name] = Collections.filter(\n this._callbacks[name] || [],\n function(binding) {\n return (\n (callback && callback !== binding.fn) ||\n (context && context !== binding.context)\n );\n }\n );\n if (this._callbacks[name].length === 0) {\n delete this._callbacks[name];\n }\n },\n this\n );\n }\n\n private removeAllCallbacks(names: string[]) {\n Collections.apply(\n names,\n function(name) {\n delete this._callbacks[name];\n },\n this\n );\n }\n}\n\nfunction prefix(name: string): string {\n return '_' + name;\n}\n","import * as Collections from '../utils/collections';\nimport Callback from './callback';\nimport Metadata from '../channels/metadata';\nimport CallbackRegistry from './callback_registry';\n\n/** Manages callback bindings and event emitting.\n *\n * @param Function failThrough called when no listeners are bound to an event\n */\nexport default class Dispatcher {\n callbacks: CallbackRegistry;\n global_callbacks: Function[];\n failThrough: Function;\n\n constructor(failThrough?: Function) {\n this.callbacks = new CallbackRegistry();\n this.global_callbacks = [];\n this.failThrough = failThrough;\n }\n\n bind(eventName: string, callback: Function, context?: any) {\n this.callbacks.add(eventName, callback, context);\n return this;\n }\n\n bind_global(callback: Function) {\n this.global_callbacks.push(callback);\n return this;\n }\n\n unbind(eventName?: string, callback?: Function, context?: any) {\n this.callbacks.remove(eventName, callback, context);\n return this;\n }\n\n unbind_global(callback?: Function) {\n if (!callback) {\n this.global_callbacks = [];\n return this;\n }\n\n this.global_callbacks = Collections.filter(\n this.global_callbacks || [],\n c => c !== callback\n );\n\n return this;\n }\n\n unbind_all() {\n this.unbind();\n this.unbind_global();\n return this;\n }\n\n emit(eventName: string, data?: any, metadata?: Metadata): Dispatcher {\n for (var i = 0; i < this.global_callbacks.length; i++) {\n this.global_callbacks[i](eventName, data);\n }\n\n var callbacks = this.callbacks.get(eventName);\n var args = [];\n\n if (metadata) {\n // if there's a metadata argument, we need to call the callback with both\n // data and metadata regardless of whether data is undefined\n args.push(data, metadata);\n } else if (data) {\n // metadata is undefined, so we only need to call the callback with data\n // if data exists\n args.push(data);\n }\n\n if (callbacks && callbacks.length > 0) {\n for (var i = 0; i < callbacks.length; i++) {\n callbacks[i].fn.apply(callbacks[i].context || global, args);\n }\n } else if (this.failThrough) {\n this.failThrough(eventName, data);\n }\n\n return this;\n }\n}\n","import { stringify } from './utils/collections';\nimport Pusher from './pusher';\n\nclass Logger {\n debug(...args: any[]) {\n this.log(this.globalLog, args);\n }\n\n warn(...args: any[]) {\n this.log(this.globalLogWarn, args);\n }\n\n error(...args: any[]) {\n this.log(this.globalLogError, args);\n }\n\n private globalLog = (message: string) => {\n if (global.console && global.console.log) {\n global.console.log(message);\n }\n };\n\n private globalLogWarn(message: string) {\n if (global.console && global.console.warn) {\n global.console.warn(message);\n } else {\n this.globalLog(message);\n }\n }\n\n private globalLogError(message: string) {\n if (global.console && global.console.error) {\n global.console.error(message);\n } else {\n this.globalLogWarn(message);\n }\n }\n\n private log(\n defaultLoggingFunction: (message: string) => void,\n ...args: any[]\n ) {\n var message = stringify.apply(this, arguments);\n if (Pusher.log) {\n Pusher.log(message);\n } else if (Pusher.logToConsole) {\n const log = defaultLoggingFunction.bind(this);\n log(message);\n }\n }\n}\n\nexport default new Logger();\n","import Util from '../util';\nimport * as Collections from '../utils/collections';\nimport { default as EventsDispatcher } from '../events/dispatcher';\nimport Logger from '../logger';\nimport TransportHooks from './transport_hooks';\nimport Socket from '../socket';\nimport Runtime from 'runtime';\nimport Timeline from '../timeline/timeline';\nimport TransportConnectionOptions from './transport_connection_options';\n\n/** Provides universal API for transport connections.\n *\n * Transport connection is a low-level object that wraps a connection method\n * and exposes a simple evented interface for the connection state and\n * messaging. It does not implement Pusher-specific WebSocket protocol.\n *\n * Additionally, it fetches resources needed for transport to work and exposes\n * an interface for querying transport features.\n *\n * States:\n * - new - initial state after constructing the object\n * - initializing - during initialization phase, usually fetching resources\n * - intialized - ready to establish a connection\n * - connection - when connection is being established\n * - open - when connection ready to be used\n * - closed - after connection was closed be either side\n *\n * Emits:\n * - error - after the connection raised an error\n *\n * Options:\n * - useTLS - whether connection should be over TLS\n * - hostTLS - host to connect to when connection is over TLS\n * - hostNonTLS - host to connect to when connection is over TLS\n *\n * @param {String} key application key\n * @param {Object} options\n */\nexport default class TransportConnection extends EventsDispatcher {\n hooks: TransportHooks;\n name: string;\n priority: number;\n key: string;\n options: TransportConnectionOptions;\n state: string;\n timeline: Timeline;\n activityTimeout: number;\n id: number;\n socket: Socket;\n beforeOpen: Function;\n initialize: Function;\n\n constructor(\n hooks: TransportHooks,\n name: string,\n priority: number,\n key: string,\n options: TransportConnectionOptions\n ) {\n super();\n this.initialize = Runtime.transportConnectionInitializer;\n this.hooks = hooks;\n this.name = name;\n this.priority = priority;\n this.key = key;\n this.options = options;\n\n this.state = 'new';\n this.timeline = options.timeline;\n this.activityTimeout = options.activityTimeout;\n this.id = this.timeline.generateUniqueID();\n }\n\n /** Checks whether the transport handles activity checks by itself.\n *\n * @return {Boolean}\n */\n handlesActivityChecks(): boolean {\n return Boolean(this.hooks.handlesActivityChecks);\n }\n\n /** Checks whether the transport supports the ping/pong API.\n *\n * @return {Boolean}\n */\n supportsPing(): boolean {\n return Boolean(this.hooks.supportsPing);\n }\n\n /** Tries to establish a connection.\n *\n * @returns {Boolean} false if transport is in invalid state\n */\n connect(): boolean {\n if (this.socket || this.state !== 'initialized') {\n return false;\n }\n\n var url = this.hooks.urls.getInitial(this.key, this.options);\n try {\n this.socket = this.hooks.getSocket(url, this.options);\n } catch (e) {\n Util.defer(() => {\n this.onError(e);\n this.changeState('closed');\n });\n return false;\n }\n\n this.bindListeners();\n\n Logger.debug('Connecting', { transport: this.name, url });\n this.changeState('connecting');\n return true;\n }\n\n /** Closes the connection.\n *\n * @return {Boolean} true if there was a connection to close\n */\n close(): boolean {\n if (this.socket) {\n this.socket.close();\n return true;\n } else {\n return false;\n }\n }\n\n /** Sends data over the open connection.\n *\n * @param {String} data\n * @return {Boolean} true only when in the \"open\" state\n */\n send(data: any): boolean {\n if (this.state === 'open') {\n // Workaround for MobileSafari bug (see https://gist.github.com/2052006)\n Util.defer(() => {\n if (this.socket) {\n this.socket.send(data);\n }\n });\n return true;\n } else {\n return false;\n }\n }\n\n /** Sends a ping if the connection is open and transport supports it. */\n ping() {\n if (this.state === 'open' && this.supportsPing()) {\n this.socket.ping();\n }\n }\n\n private onOpen() {\n if (this.hooks.beforeOpen) {\n this.hooks.beforeOpen(\n this.socket,\n this.hooks.urls.getPath(this.key, this.options)\n );\n }\n this.changeState('open');\n this.socket.onopen = undefined;\n }\n\n private onError(error) {\n this.emit('error', { type: 'WebSocketError', error: error });\n this.timeline.error(this.buildTimelineMessage({ error: error.toString() }));\n }\n\n private onClose(closeEvent?: any) {\n if (closeEvent) {\n this.changeState('closed', {\n code: closeEvent.code,\n reason: closeEvent.reason,\n wasClean: closeEvent.wasClean\n });\n } else {\n this.changeState('closed');\n }\n this.unbindListeners();\n this.socket = undefined;\n }\n\n private onMessage(message) {\n this.emit('message', message);\n }\n\n private onActivity() {\n this.emit('activity');\n }\n\n private bindListeners() {\n this.socket.onopen = () => {\n this.onOpen();\n };\n this.socket.onerror = error => {\n this.onError(error);\n };\n this.socket.onclose = closeEvent => {\n this.onClose(closeEvent);\n };\n this.socket.onmessage = message => {\n this.onMessage(message);\n };\n\n if (this.supportsPing()) {\n this.socket.onactivity = () => {\n this.onActivity();\n };\n }\n }\n\n private unbindListeners() {\n if (this.socket) {\n this.socket.onopen = undefined;\n this.socket.onerror = undefined;\n this.socket.onclose = undefined;\n this.socket.onmessage = undefined;\n if (this.supportsPing()) {\n this.socket.onactivity = undefined;\n }\n }\n }\n\n private changeState(state: string, params?: any) {\n this.state = state;\n this.timeline.info(\n this.buildTimelineMessage({\n state: state,\n params: params\n })\n );\n this.emit(state, params);\n }\n\n buildTimelineMessage(message): any {\n return Collections.extend({ cid: this.id }, message);\n }\n}\n","import Factory from '../utils/factory';\nimport TransportHooks from './transport_hooks';\nimport TransportConnection from './transport_connection';\nimport TransportConnectionOptions from './transport_connection_options';\n\n/** Provides interface for transport connection instantiation.\n *\n * Takes transport-specific hooks as the only argument, which allow checking\n * for transport support and creating its connections.\n *\n * Supported hooks: * - file - the name of the file to be fetched during initialization\n * - urls - URL scheme to be used by transport\n * - handlesActivityCheck - true when the transport handles activity checks\n * - supportsPing - true when the transport has a ping/activity API\n * - isSupported - tells whether the transport is supported in the environment\n * - getSocket - creates a WebSocket-compatible transport socket\n *\n * See transports.js for specific implementations.\n *\n * @param {Object} hooks object containing all needed transport hooks\n */\nexport default class Transport {\n hooks: TransportHooks;\n\n constructor(hooks: TransportHooks) {\n this.hooks = hooks;\n }\n\n /** Returns whether the transport is supported in the environment.\n *\n * @param {Object} envronment te environment details (encryption, settings)\n * @returns {Boolean} true when the transport is supported\n */\n isSupported(environment: any): boolean {\n return this.hooks.isSupported(environment);\n }\n\n /** Creates a transport connection.\n *\n * @param {String} name\n * @param {Number} priority\n * @param {String} key the application key\n * @param {Object} options\n * @returns {TransportConnection}\n */\n createConnection(\n name: string,\n priority: number,\n key: string,\n options: any\n ): TransportConnection {\n return new TransportConnection(this.hooks, name, priority, key, options);\n }\n}\n","import * as URLSchemes from 'core/transports/url_schemes';\nimport URLScheme from 'core/transports/url_scheme';\nimport Transport from 'core/transports/transport';\nimport Util from 'core/util';\nimport * as Collections from 'core/utils/collections';\nimport TransportHooks from 'core/transports/transport_hooks';\nimport TransportsTable from 'core/transports/transports_table';\nimport Runtime from 'runtime';\n\n/** WebSocket transport.\n *\n * Uses native WebSocket implementation, including MozWebSocket supported by\n * earlier Firefox versions.\n */\nvar WSTransport = new Transport({\n urls: URLSchemes.ws,\n handlesActivityChecks: false,\n supportsPing: false,\n\n isInitialized: function() {\n return Boolean(Runtime.getWebSocketAPI());\n },\n isSupported: function(): boolean {\n return Boolean(Runtime.getWebSocketAPI());\n },\n getSocket: function(url) {\n return Runtime.createWebSocket(url);\n }\n});\n\nvar httpConfiguration = {\n urls: URLSchemes.http,\n handlesActivityChecks: false,\n supportsPing: true,\n isInitialized: function() {\n return true;\n }\n};\n\nexport var streamingConfiguration = Collections.extend(\n {\n getSocket: function(url) {\n return Runtime.HTTPFactory.createStreamingSocket(url);\n }\n },\n httpConfiguration\n);\nexport var pollingConfiguration = Collections.extend(\n {\n getSocket: function(url) {\n return Runtime.HTTPFactory.createPollingSocket(url);\n }\n },\n httpConfiguration\n);\n\nvar xhrConfiguration = {\n isSupported: function(): boolean {\n return Runtime.isXHRSupported();\n }\n};\n\n/** HTTP streaming transport using CORS-enabled XMLHttpRequest. */\nvar XHRStreamingTransport = new Transport(\n (\n Collections.extend({}, streamingConfiguration, xhrConfiguration)\n )\n);\n\n/** HTTP long-polling transport using CORS-enabled XMLHttpRequest. */\nvar XHRPollingTransport = new Transport(\n Collections.extend({}, pollingConfiguration, xhrConfiguration)\n);\n\nvar Transports: TransportsTable = {\n ws: WSTransport,\n xhr_streaming: XHRStreamingTransport,\n xhr_polling: XHRPollingTransport\n};\n\nexport default Transports;\n","import Util from '../util';\nimport * as Collections from '../utils/collections';\nimport TransportManager from './transport_manager';\nimport TransportConnection from './transport_connection';\nimport Transport from './transport';\nimport PingDelayOptions from './ping_delay_options';\n\n/** Creates transport connections monitored by a transport manager.\n *\n * When a transport is closed, it might mean the environment does not support\n * it. It's possible that messages get stuck in an intermediate buffer or\n * proxies terminate inactive connections. To combat these problems,\n * assistants monitor the connection lifetime, report unclean exits and\n * adjust ping timeouts to keep the connection active. The decision to disable\n * a transport is the manager's responsibility.\n *\n * @param {TransportManager} manager\n * @param {TransportConnection} transport\n * @param {Object} options\n */\nexport default class AssistantToTheTransportManager {\n manager: TransportManager;\n transport: Transport;\n minPingDelay: number;\n maxPingDelay: number;\n pingDelay: number;\n\n constructor(\n manager: TransportManager,\n transport: Transport,\n options: PingDelayOptions\n ) {\n this.manager = manager;\n this.transport = transport;\n this.minPingDelay = options.minPingDelay;\n this.maxPingDelay = options.maxPingDelay;\n this.pingDelay = undefined;\n }\n\n /** Creates a transport connection.\n *\n * This function has the same API as Transport#createConnection.\n *\n * @param {String} name\n * @param {Number} priority\n * @param {String} key the application key\n * @param {Object} options\n * @returns {TransportConnection}\n */\n createConnection(\n name: string,\n priority: number,\n key: string,\n options: Object\n ): TransportConnection {\n options = Collections.extend({}, options, {\n activityTimeout: this.pingDelay\n });\n var connection = this.transport.createConnection(\n name,\n priority,\n key,\n options\n );\n\n var openTimestamp = null;\n\n var onOpen = function() {\n connection.unbind('open', onOpen);\n connection.bind('closed', onClosed);\n openTimestamp = Util.now();\n };\n var onClosed = closeEvent => {\n connection.unbind('closed', onClosed);\n\n if (closeEvent.code === 1002 || closeEvent.code === 1003) {\n // we don't want to use transports not obeying the protocol\n this.manager.reportDeath();\n } else if (!closeEvent.wasClean && openTimestamp) {\n // report deaths only for short-living transport\n var lifespan = Util.now() - openTimestamp;\n if (lifespan < 2 * this.maxPingDelay) {\n this.manager.reportDeath();\n this.pingDelay = Math.max(lifespan / 2, this.minPingDelay);\n }\n }\n };\n\n connection.bind('open', onOpen);\n return connection;\n }\n\n /** Returns whether the transport is supported in the environment.\n *\n * This function has the same API as Transport#isSupported. Might return false\n * when the manager decides to kill the transport.\n *\n * @param {Object} environment the environment details (encryption, settings)\n * @returns {Boolean} true when the transport is supported\n */\n isSupported(environment: string): boolean {\n return this.manager.isAlive() && this.transport.isSupported(environment);\n }\n}\n","import Action from './action';\nimport { PusherEvent } from './message-types';\n/**\n * Provides functions for handling Pusher protocol-specific messages.\n */\n\nconst Protocol = {\n /**\n * Decodes a message in a Pusher format.\n *\n * The MessageEvent we receive from the transport should contain a pusher event\n * (https://pusher.com/docs/pusher_protocol#events) serialized as JSON in the\n * data field\n *\n * The pusher event may contain a data field too, and it may also be\n * serialised as JSON\n *\n * Throws errors when messages are not parse'able.\n *\n * @param {MessageEvent} messageEvent\n * @return {PusherEvent}\n */\n decodeMessage: function(messageEvent: MessageEvent): PusherEvent {\n try {\n var messageData = JSON.parse(messageEvent.data);\n var pusherEventData = messageData.data;\n if (typeof pusherEventData === 'string') {\n try {\n pusherEventData = JSON.parse(messageData.data);\n } catch (e) {}\n }\n var pusherEvent: PusherEvent = {\n event: messageData.event,\n channel: messageData.channel,\n data: pusherEventData\n };\n if (messageData.user_id) {\n pusherEvent.user_id = messageData.user_id;\n }\n return pusherEvent;\n } catch (e) {\n throw { type: 'MessageParseError', error: e, data: messageEvent.data };\n }\n },\n\n /**\n * Encodes a message to be sent.\n *\n * @param {PusherEvent} event\n * @return {String}\n */\n encodeMessage: function(event: PusherEvent): string {\n return JSON.stringify(event);\n },\n\n /**\n * Processes a handshake message and returns appropriate actions.\n *\n * Returns an object with an 'action' and other action-specific properties.\n *\n * There are three outcomes when calling this function. First is a successful\n * connection attempt, when pusher:connection_established is received, which\n * results in a 'connected' action with an 'id' property. When passed a\n * pusher:error event, it returns a result with action appropriate to the\n * close code and an error. Otherwise, it raises an exception.\n *\n * @param {String} message\n * @result Object\n */\n processHandshake: function(messageEvent: MessageEvent): Action {\n var message = Protocol.decodeMessage(messageEvent);\n\n if (message.event === 'pusher:connection_established') {\n if (!message.data.activity_timeout) {\n throw 'No activity timeout specified in handshake';\n }\n return {\n action: 'connected',\n id: message.data.socket_id,\n activityTimeout: message.data.activity_timeout * 1000\n };\n } else if (message.event === 'pusher:error') {\n // From protocol 6 close codes are sent only once, so this only\n // happens when connection does not support close codes\n return {\n action: this.getCloseAction(message.data),\n error: this.getCloseError(message.data)\n };\n } else {\n throw 'Invalid handshake';\n }\n },\n\n /**\n * Dispatches the close event and returns an appropriate action name.\n *\n * See:\n * 1. https://developer.mozilla.org/en-US/docs/WebSockets/WebSockets_reference/CloseEvent\n * 2. http://pusher.com/docs/pusher_protocol\n *\n * @param {CloseEvent} closeEvent\n * @return {String} close action name\n */\n getCloseAction: function(closeEvent): string {\n if (closeEvent.code < 4000) {\n // ignore 1000 CLOSE_NORMAL, 1001 CLOSE_GOING_AWAY,\n // 1005 CLOSE_NO_STATUS, 1006 CLOSE_ABNORMAL\n // ignore 1007...3999\n // handle 1002 CLOSE_PROTOCOL_ERROR, 1003 CLOSE_UNSUPPORTED,\n // 1004 CLOSE_TOO_LARGE\n if (closeEvent.code >= 1002 && closeEvent.code <= 1004) {\n return 'backoff';\n } else {\n return null;\n }\n } else if (closeEvent.code === 4000) {\n return 'tls_only';\n } else if (closeEvent.code < 4100) {\n return 'refused';\n } else if (closeEvent.code < 4200) {\n return 'backoff';\n } else if (closeEvent.code < 4300) {\n return 'retry';\n } else {\n // unknown error\n return 'refused';\n }\n },\n\n /**\n * Returns an error or null basing on the close event.\n *\n * Null is returned when connection was closed cleanly. Otherwise, an object\n * with error details is returned.\n *\n * @param {CloseEvent} closeEvent\n * @return {Object} error object\n */\n getCloseError: function(closeEvent): any {\n if (closeEvent.code !== 1000 && closeEvent.code !== 1001) {\n return {\n type: 'PusherError',\n data: {\n code: closeEvent.code,\n message: closeEvent.reason || closeEvent.message\n }\n };\n } else {\n return null;\n }\n }\n};\n\nexport default Protocol;\n","import * as Collections from '../utils/collections';\nimport { default as EventsDispatcher } from '../events/dispatcher';\nimport Protocol from './protocol/protocol';\nimport { PusherEvent } from './protocol/message-types';\nimport Logger from '../logger';\nimport TransportConnection from '../transports/transport_connection';\nimport Socket from '../socket';\n/**\n * Provides Pusher protocol interface for transports.\n *\n * Emits following events:\n * - message - on received messages\n * - ping - on ping requests\n * - pong - on pong responses\n * - error - when the transport emits an error\n * - closed - after closing the transport\n *\n * It also emits more events when connection closes with a code.\n * See Protocol.getCloseAction to get more details.\n *\n * @param {Number} id\n * @param {AbstractTransport} transport\n */\nexport default class Connection extends EventsDispatcher implements Socket {\n id: string;\n transport: TransportConnection;\n activityTimeout: number;\n\n constructor(id: string, transport: TransportConnection) {\n super();\n this.id = id;\n this.transport = transport;\n this.activityTimeout = transport.activityTimeout;\n this.bindListeners();\n }\n\n /** Returns whether used transport handles activity checks by itself\n *\n * @returns {Boolean} true if activity checks are handled by the transport\n */\n handlesActivityChecks() {\n return this.transport.handlesActivityChecks();\n }\n\n /** Sends raw data.\n *\n * @param {String} data\n */\n send(data: any): boolean {\n return this.transport.send(data);\n }\n\n /** Sends an event.\n *\n * @param {String} name\n * @param {String} data\n * @param {String} [channel]\n * @returns {Boolean} whether message was sent or not\n */\n send_event(name: string, data: any, channel?: string): boolean {\n var event: PusherEvent = { event: name, data: data };\n if (channel) {\n event.channel = channel;\n }\n Logger.debug('Event sent', event);\n return this.send(Protocol.encodeMessage(event));\n }\n\n /** Sends a ping message to the server.\n *\n * Basing on the underlying transport, it might send either transport's\n * protocol-specific ping or pusher:ping event.\n */\n ping() {\n if (this.transport.supportsPing()) {\n this.transport.ping();\n } else {\n this.send_event('pusher:ping', {});\n }\n }\n\n /** Closes the connection. */\n close() {\n this.transport.close();\n }\n\n private bindListeners() {\n var listeners = {\n message: (messageEvent: MessageEvent) => {\n var pusherEvent;\n try {\n pusherEvent = Protocol.decodeMessage(messageEvent);\n } catch (e) {\n this.emit('error', {\n type: 'MessageParseError',\n error: e,\n data: messageEvent.data\n });\n }\n\n if (pusherEvent !== undefined) {\n Logger.debug('Event recd', pusherEvent);\n\n switch (pusherEvent.event) {\n case 'pusher:error':\n this.emit('error', {\n type: 'PusherError',\n data: pusherEvent.data\n });\n break;\n case 'pusher:ping':\n this.emit('ping');\n break;\n case 'pusher:pong':\n this.emit('pong');\n break;\n }\n this.emit('message', pusherEvent);\n }\n },\n activity: () => {\n this.emit('activity');\n },\n error: error => {\n this.emit('error', error);\n },\n closed: closeEvent => {\n unbindListeners();\n\n if (closeEvent && closeEvent.code) {\n this.handleCloseEvent(closeEvent);\n }\n\n this.transport = null;\n this.emit('closed');\n }\n };\n\n var unbindListeners = () => {\n Collections.objectApply(listeners, (listener, event) => {\n this.transport.unbind(event, listener);\n });\n };\n\n Collections.objectApply(listeners, (listener, event) => {\n this.transport.bind(event, listener);\n });\n }\n\n private handleCloseEvent(closeEvent: any) {\n var action = Protocol.getCloseAction(closeEvent);\n var error = Protocol.getCloseError(closeEvent);\n if (error) {\n this.emit('error', error);\n }\n if (action) {\n this.emit(action, { action: action, error: error });\n }\n }\n}\n","import Util from '../../util';\nimport * as Collections from '../../utils/collections';\nimport Protocol from '../protocol/protocol';\nimport Connection from '../connection';\nimport TransportConnection from '../../transports/transport_connection';\nimport HandshakePayload from './handshake_payload';\n\n/**\n * Handles Pusher protocol handshakes for transports.\n *\n * Calls back with a result object after handshake is completed. Results\n * always have two fields:\n * - action - string describing action to be taken after the handshake\n * - transport - the transport object passed to the constructor\n *\n * Different actions can set different additional properties on the result.\n * In the case of 'connected' action, there will be a 'connection' property\n * containing a Connection object for the transport. Other actions should\n * carry an 'error' property.\n *\n * @param {AbstractTransport} transport\n * @param {Function} callback\n */\nexport default class Handshake {\n transport: TransportConnection;\n callback: (HandshakePayload) => void;\n onMessage: Function;\n onClosed: Function;\n\n constructor(\n transport: TransportConnection,\n callback: (HandshakePayload) => void\n ) {\n this.transport = transport;\n this.callback = callback;\n this.bindListeners();\n }\n\n close() {\n this.unbindListeners();\n this.transport.close();\n }\n\n private bindListeners() {\n this.onMessage = m => {\n this.unbindListeners();\n\n var result;\n try {\n result = Protocol.processHandshake(m);\n } catch (e) {\n this.finish('error', { error: e });\n this.transport.close();\n return;\n }\n\n if (result.action === 'connected') {\n this.finish('connected', {\n connection: new Connection(result.id, this.transport),\n activityTimeout: result.activityTimeout\n });\n } else {\n this.finish(result.action, { error: result.error });\n this.transport.close();\n }\n };\n\n this.onClosed = closeEvent => {\n this.unbindListeners();\n\n var action = Protocol.getCloseAction(closeEvent) || 'backoff';\n var error = Protocol.getCloseError(closeEvent);\n this.finish(action, { error: error });\n };\n\n this.transport.bind('message', this.onMessage);\n this.transport.bind('closed', this.onClosed);\n }\n\n private unbindListeners() {\n this.transport.unbind('message', this.onMessage);\n this.transport.unbind('closed', this.onClosed);\n }\n\n private finish(action: string, params: any) {\n this.callback(\n Collections.extend({ transport: this.transport, action: action }, params)\n );\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport base64encode from '../base64';\nimport Timeline from './timeline';\nimport Runtime from 'runtime';\n\nexport interface TimelineSenderOptions {\n host?: string;\n port?: number;\n path?: string;\n}\n\nexport default class TimelineSender {\n timeline: Timeline;\n options: TimelineSenderOptions;\n host: string;\n\n constructor(timeline: Timeline, options: TimelineSenderOptions) {\n this.timeline = timeline;\n this.options = options || {};\n }\n\n send(useTLS: boolean, callback?: Function) {\n if (this.timeline.isEmpty()) {\n return;\n }\n\n this.timeline.send(\n Runtime.TimelineTransport.getAgent(this, useTLS),\n callback\n );\n }\n}\n","/** Error classes used throughout the library. */\n// https://github.com/Microsoft/TypeScript-wiki/blob/master/Breaking-Changes.md#extending-built-ins-like-error-array-and-map-may-no-longer-work\nexport class BadEventName extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\nexport class BadChannelName extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\nexport class RequestTimedOut extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class TransportPriorityTooLow extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class TransportClosed extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class UnsupportedFeature extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class UnsupportedTransport extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class UnsupportedStrategy extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class HTTPAuthError extends Error {\n status: number;\n constructor(status: number, msg?: string) {\n super(msg);\n this.status = status;\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n","/**\n * A place to store help URLs for error messages etc\n */\n\nconst urlStore = {\n baseUrl: 'https://pusher.com',\n urls: {\n authenticationEndpoint: {\n path: '/docs/channels/server_api/authenticating_users'\n },\n authorizationEndpoint: {\n path: '/docs/channels/server_api/authorizing-users/'\n },\n javascriptQuickStart: {\n path: '/docs/javascript_quick_start'\n },\n triggeringClientEvents: {\n path: '/docs/client_api_guide/client_events#trigger-events'\n },\n encryptedChannelSupport: {\n fullUrl:\n 'https://github.com/pusher/pusher-js/tree/cc491015371a4bde5743d1c87a0fbac0feb53195#encrypted-channel-support'\n }\n }\n};\n\n/** Builds a consistent string with links to pusher documentation\n *\n * @param {string} key - relevant key in the url_store.urls object\n * @return {string} suffix string to append to log message\n */\nconst buildLogSuffix = function(key: string): string {\n const urlPrefix = 'See:';\n const urlObj = urlStore.urls[key];\n if (!urlObj) return '';\n\n let url;\n if (urlObj.fullUrl) {\n url = urlObj.fullUrl;\n } else if (urlObj.path) {\n url = urlStore.baseUrl + urlObj.path;\n }\n\n if (!url) return '';\n return `${urlPrefix} ${url}`;\n};\n\nexport default { buildLogSuffix };\n","import { default as EventsDispatcher } from '../events/dispatcher';\nimport * as Errors from '../errors';\nimport Logger from '../logger';\nimport Pusher from '../pusher';\nimport { PusherEvent } from '../connection/protocol/message-types';\nimport Metadata from './metadata';\nimport UrlStore from '../utils/url_store';\nimport {\n ChannelAuthorizationData,\n ChannelAuthorizationCallback\n} from '../auth/options';\nimport { HTTPAuthError } from '../errors';\n\n/** Provides base public channel interface with an event emitter.\n *\n * Emits:\n * - pusher:subscription_succeeded - after subscribing successfully\n * - other non-internal events\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\nexport default class Channel extends EventsDispatcher {\n name: string;\n pusher: Pusher;\n subscribed: boolean;\n subscriptionPending: boolean;\n subscriptionCancelled: boolean;\n subscriptionCount: null;\n\n constructor(name: string, pusher: Pusher) {\n super(function(event, data) {\n Logger.debug('No callbacks on ' + name + ' for ' + event);\n });\n\n this.name = name;\n this.pusher = pusher;\n this.subscribed = false;\n this.subscriptionPending = false;\n this.subscriptionCancelled = false;\n }\n\n /** Skips authorization, since public channels don't require it.\n *\n * @param {Function} callback\n */\n authorize(socketId: string, callback: ChannelAuthorizationCallback) {\n return callback(null, { auth: '' });\n }\n\n /** Triggers an event */\n trigger(event: string, data: any) {\n if (event.indexOf('client-') !== 0) {\n throw new Errors.BadEventName(\n \"Event '\" + event + \"' does not start with 'client-'\"\n );\n }\n if (!this.subscribed) {\n var suffix = UrlStore.buildLogSuffix('triggeringClientEvents');\n Logger.warn(\n `Client event triggered before channel 'subscription_succeeded' event . ${suffix}`\n );\n }\n return this.pusher.send_event(event, data, this.name);\n }\n\n /** Signals disconnection to the channel. For internal use only. */\n disconnect() {\n this.subscribed = false;\n this.subscriptionPending = false;\n }\n\n /** Handles a PusherEvent. For internal use only.\n *\n * @param {PusherEvent} event\n */\n handleEvent(event: PusherEvent) {\n var eventName = event.event;\n var data = event.data;\n if (eventName === 'pusher_internal:subscription_succeeded') {\n this.handleSubscriptionSucceededEvent(event);\n } else if (eventName === 'pusher_internal:subscription_count') {\n this.handleSubscriptionCountEvent(event);\n } else if (eventName.indexOf('pusher_internal:') !== 0) {\n var metadata: Metadata = {};\n this.emit(eventName, data, metadata);\n }\n }\n\n handleSubscriptionSucceededEvent(event: PusherEvent) {\n this.subscriptionPending = false;\n this.subscribed = true;\n if (this.subscriptionCancelled) {\n this.pusher.unsubscribe(this.name);\n } else {\n this.emit('pusher:subscription_succeeded', event.data);\n }\n }\n\n handleSubscriptionCountEvent(event: PusherEvent) {\n if (event.data.subscription_count) {\n this.subscriptionCount = event.data.subscription_count;\n }\n\n this.emit('pusher:subscription_count', event.data);\n }\n\n /** Sends a subscription request. For internal use only. */\n subscribe() {\n if (this.subscribed) {\n return;\n }\n this.subscriptionPending = true;\n this.subscriptionCancelled = false;\n this.authorize(\n this.pusher.connection.socket_id,\n (error: Error | null, data: ChannelAuthorizationData) => {\n if (error) {\n this.subscriptionPending = false;\n // Why not bind to 'pusher:subscription_error' a level up, and log there?\n // Binding to this event would cause the warning about no callbacks being\n // bound (see constructor) to be suppressed, that's not what we want.\n Logger.error(error.toString());\n this.emit(\n 'pusher:subscription_error',\n Object.assign(\n {},\n {\n type: 'AuthError',\n error: error.message\n },\n error instanceof HTTPAuthError ? { status: error.status } : {}\n )\n );\n } else {\n this.pusher.send_event('pusher:subscribe', {\n auth: data.auth,\n channel_data: data.channel_data,\n channel: this.name\n });\n }\n }\n );\n }\n\n /** Sends an unsubscription request. For internal use only. */\n unsubscribe() {\n this.subscribed = false;\n this.pusher.send_event('pusher:unsubscribe', {\n channel: this.name\n });\n }\n\n /** Cancels an in progress subscription. For internal use only. */\n cancelSubscription() {\n this.subscriptionCancelled = true;\n }\n\n /** Reinstates an in progress subscripiton. For internal use only. */\n reinstateSubscription() {\n this.subscriptionCancelled = false;\n }\n}\n","import Factory from '../utils/factory';\nimport Channel from './channel';\nimport { ChannelAuthorizationCallback } from '../auth/options';\n\n/** Extends public channels to provide private channel interface.\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\nexport default class PrivateChannel extends Channel {\n /** Authorizes the connection to use the channel.\n *\n * @param {String} socketId\n * @param {Function} callback\n */\n authorize(socketId: string, callback: ChannelAuthorizationCallback) {\n return this.pusher.config.channelAuthorizer(\n {\n channelName: this.name,\n socketId: socketId\n },\n callback\n );\n }\n}\n","import * as Collections from '../utils/collections';\n\n/** Represents a collection of members of a presence channel. */\nexport default class Members {\n members: any;\n count: number;\n myID: any;\n me: any;\n\n constructor() {\n this.reset();\n }\n\n /** Returns member's info for given id.\n *\n * Resulting object containts two fields - id and info.\n *\n * @param {Number} id\n * @return {Object} member's info or null\n */\n get(id: string): any {\n if (Object.prototype.hasOwnProperty.call(this.members, id)) {\n return {\n id: id,\n info: this.members[id]\n };\n } else {\n return null;\n }\n }\n\n /** Calls back for each member in unspecified order.\n *\n * @param {Function} callback\n */\n each(callback: Function) {\n Collections.objectApply(this.members, (member, id) => {\n callback(this.get(id));\n });\n }\n\n /** Updates the id for connected member. For internal use only. */\n setMyID(id: string) {\n this.myID = id;\n }\n\n /** Handles subscription data. For internal use only. */\n onSubscription(subscriptionData: any) {\n this.members = subscriptionData.presence.hash;\n this.count = subscriptionData.presence.count;\n this.me = this.get(this.myID);\n }\n\n /** Adds a new member to the collection. For internal use only. */\n addMember(memberData: any) {\n if (this.get(memberData.user_id) === null) {\n this.count++;\n }\n this.members[memberData.user_id] = memberData.user_info;\n return this.get(memberData.user_id);\n }\n\n /** Adds a member from the collection. For internal use only. */\n removeMember(memberData: any) {\n var member = this.get(memberData.user_id);\n if (member) {\n delete this.members[memberData.user_id];\n this.count--;\n }\n return member;\n }\n\n /** Resets the collection to the initial state. For internal use only. */\n reset() {\n this.members = {};\n this.count = 0;\n this.myID = null;\n this.me = null;\n }\n}\n","import PrivateChannel from './private_channel';\nimport Logger from '../logger';\nimport Members from './members';\nimport Pusher from '../pusher';\nimport UrlStore from 'core/utils/url_store';\nimport { PusherEvent } from '../connection/protocol/message-types';\nimport Metadata from './metadata';\nimport { ChannelAuthorizationData } from '../auth/options';\n\nexport default class PresenceChannel extends PrivateChannel {\n members: Members;\n\n /** Adds presence channel functionality to private channels.\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\n constructor(name: string, pusher: Pusher) {\n super(name, pusher);\n this.members = new Members();\n }\n\n /** Authorizes the connection as a member of the channel.\n *\n * @param {String} socketId\n * @param {Function} callback\n */\n authorize(socketId: string, callback: Function) {\n super.authorize(socketId, async (error, authData) => {\n if (!error) {\n authData = authData as ChannelAuthorizationData;\n if (authData.channel_data != null) {\n var channelData = JSON.parse(authData.channel_data);\n this.members.setMyID(channelData.user_id);\n } else {\n await this.pusher.user.signinDonePromise;\n if (this.pusher.user.user_data != null) {\n // If the user is signed in, get the id of the authenticated user\n // and allow the presence authorization to continue.\n this.members.setMyID(this.pusher.user.user_data.id);\n } else {\n let suffix = UrlStore.buildLogSuffix('authorizationEndpoint');\n Logger.error(\n `Invalid auth response for channel '${this.name}', ` +\n `expected 'channel_data' field. ${suffix}, ` +\n `or the user should be signed in.`\n );\n callback('Invalid auth response');\n return;\n }\n }\n }\n callback(error, authData);\n });\n }\n\n /** Handles presence and subscription events. For internal use only.\n *\n * @param {PusherEvent} event\n */\n handleEvent(event: PusherEvent) {\n var eventName = event.event;\n if (eventName.indexOf('pusher_internal:') === 0) {\n this.handleInternalEvent(event);\n } else {\n var data = event.data;\n var metadata: Metadata = {};\n if (event.user_id) {\n metadata.user_id = event.user_id;\n }\n this.emit(eventName, data, metadata);\n }\n }\n handleInternalEvent(event: PusherEvent) {\n var eventName = event.event;\n var data = event.data;\n switch (eventName) {\n case 'pusher_internal:subscription_succeeded':\n this.handleSubscriptionSucceededEvent(event);\n break;\n case 'pusher_internal:subscription_count':\n this.handleSubscriptionCountEvent(event);\n break;\n case 'pusher_internal:member_added':\n var addedMember = this.members.addMember(data);\n this.emit('pusher:member_added', addedMember);\n break;\n case 'pusher_internal:member_removed':\n var removedMember = this.members.removeMember(data);\n if (removedMember) {\n this.emit('pusher:member_removed', removedMember);\n }\n break;\n }\n }\n\n handleSubscriptionSucceededEvent(event: PusherEvent) {\n this.subscriptionPending = false;\n this.subscribed = true;\n if (this.subscriptionCancelled) {\n this.pusher.unsubscribe(this.name);\n } else {\n this.members.onSubscription(event.data);\n this.emit('pusher:subscription_succeeded', this.members);\n }\n }\n\n /** Resets the channel state, including members map. For internal use only. */\n disconnect() {\n this.members.reset();\n super.disconnect();\n }\n}\n","import PrivateChannel from './private_channel';\nimport * as Errors from '../errors';\nimport Logger from '../logger';\nimport Pusher from '../pusher';\nimport { decode as encodeUTF8 } from '@stablelib/utf8';\nimport { decode as decodeBase64 } from '@stablelib/base64';\nimport Dispatcher from '../events/dispatcher';\nimport { PusherEvent } from '../connection/protocol/message-types';\nimport {\n ChannelAuthorizationData,\n ChannelAuthorizationCallback\n} from '../auth/options';\nimport * as nacl from 'tweetnacl';\n\n/** Extends private channels to provide encrypted channel interface.\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\nexport default class EncryptedChannel extends PrivateChannel {\n key: Uint8Array = null;\n nacl: nacl;\n\n constructor(name: string, pusher: Pusher, nacl: nacl) {\n super(name, pusher);\n this.nacl = nacl;\n }\n\n /** Authorizes the connection to use the channel.\n *\n * @param {String} socketId\n * @param {Function} callback\n */\n authorize(socketId: string, callback: ChannelAuthorizationCallback) {\n super.authorize(\n socketId,\n (error: Error | null, authData: ChannelAuthorizationData) => {\n if (error) {\n callback(error, authData);\n return;\n }\n let sharedSecret = authData['shared_secret'];\n if (!sharedSecret) {\n callback(\n new Error(\n `No shared_secret key in auth payload for encrypted channel: ${this.name}`\n ),\n null\n );\n return;\n }\n this.key = decodeBase64(sharedSecret);\n delete authData['shared_secret'];\n callback(null, authData);\n }\n );\n }\n\n trigger(event: string, data: any): boolean {\n throw new Errors.UnsupportedFeature(\n 'Client events are not currently supported for encrypted channels'\n );\n }\n\n /** Handles an event. For internal use only.\n *\n * @param {PusherEvent} event\n */\n handleEvent(event: PusherEvent) {\n var eventName = event.event;\n var data = event.data;\n if (\n eventName.indexOf('pusher_internal:') === 0 ||\n eventName.indexOf('pusher:') === 0\n ) {\n super.handleEvent(event);\n return;\n }\n this.handleEncryptedEvent(eventName, data);\n }\n\n private handleEncryptedEvent(event: string, data: any): void {\n if (!this.key) {\n Logger.debug(\n 'Received encrypted event before key has been retrieved from the authEndpoint'\n );\n return;\n }\n if (!data.ciphertext || !data.nonce) {\n Logger.error(\n 'Unexpected format for encrypted event, expected object with `ciphertext` and `nonce` fields, got: ' +\n data\n );\n return;\n }\n let cipherText = decodeBase64(data.ciphertext);\n if (cipherText.length < this.nacl.secretbox.overheadLength) {\n Logger.error(\n `Expected encrypted event ciphertext length to be ${this.nacl.secretbox.overheadLength}, got: ${cipherText.length}`\n );\n return;\n }\n let nonce = decodeBase64(data.nonce);\n if (nonce.length < this.nacl.secretbox.nonceLength) {\n Logger.error(\n `Expected encrypted event nonce length to be ${this.nacl.secretbox.nonceLength}, got: ${nonce.length}`\n );\n return;\n }\n\n let bytes = this.nacl.secretbox.open(cipherText, nonce, this.key);\n if (bytes === null) {\n Logger.debug(\n 'Failed to decrypt an event, probably because it was encrypted with a different key. Fetching a new key from the authEndpoint...'\n );\n // Try a single time to retrieve a new auth key and decrypt the event with it\n // If this fails, a new key will be requested when a new message is received\n this.authorize(this.pusher.connection.socket_id, (error, authData) => {\n if (error) {\n Logger.error(\n `Failed to make a request to the authEndpoint: ${authData}. Unable to fetch new key, so dropping encrypted event`\n );\n return;\n }\n bytes = this.nacl.secretbox.open(cipherText, nonce, this.key);\n if (bytes === null) {\n Logger.error(\n `Failed to decrypt event with new key. Dropping encrypted event`\n );\n return;\n }\n this.emit(event, this.getDataToEmit(bytes));\n return;\n });\n return;\n }\n this.emit(event, this.getDataToEmit(bytes));\n }\n\n // Try and parse the decrypted bytes as JSON. If we can't parse it, just\n // return the utf-8 string\n getDataToEmit(bytes: Uint8Array): string {\n let raw = encodeUTF8(bytes);\n try {\n return JSON.parse(raw);\n } catch {\n return raw;\n }\n }\n}\n","import { default as EventsDispatcher } from '../events/dispatcher';\nimport { OneOffTimer as Timer } from '../utils/timers';\nimport { Config } from '../config';\nimport Logger from '../logger';\nimport HandshakePayload from './handshake/handshake_payload';\nimport Connection from './connection';\nimport Strategy from '../strategies/strategy';\nimport StrategyRunner from '../strategies/strategy_runner';\nimport * as Collections from '../utils/collections';\nimport Timeline from '../timeline/timeline';\nimport ConnectionManagerOptions from './connection_manager_options';\nimport Runtime from 'runtime';\n\nimport {\n ErrorCallbacks,\n HandshakeCallbacks,\n ConnectionCallbacks\n} from './callbacks';\nimport Action from './protocol/action';\n\n/** Manages connection to Pusher.\n *\n * Uses a strategy (currently only default), timers and network availability\n * info to establish a connection and export its state. In case of failures,\n * manages reconnection attempts.\n *\n * Exports state changes as following events:\n * - \"state_change\", { previous: p, current: state }\n * - state\n *\n * States:\n * - initialized - initial state, never transitioned to\n * - connecting - connection is being established\n * - connected - connection has been fully established\n * - disconnected - on requested disconnection\n * - unavailable - after connection timeout or when there's no network\n * - failed - when the connection strategy is not supported\n *\n * Options:\n * - unavailableTimeout - time to transition to unavailable state\n * - activityTimeout - time after which ping message should be sent\n * - pongTimeout - time for Pusher to respond with pong before reconnecting\n *\n * @param {String} key application key\n * @param {Object} options\n */\nexport default class ConnectionManager extends EventsDispatcher {\n key: string;\n options: ConnectionManagerOptions;\n state: string;\n connection: Connection;\n usingTLS: boolean;\n timeline: Timeline;\n socket_id: string;\n unavailableTimer: Timer;\n activityTimer: Timer;\n retryTimer: Timer;\n activityTimeout: number;\n strategy: Strategy;\n runner: StrategyRunner;\n errorCallbacks: ErrorCallbacks;\n handshakeCallbacks: HandshakeCallbacks;\n connectionCallbacks: ConnectionCallbacks;\n\n constructor(key: string, options: ConnectionManagerOptions) {\n super();\n this.state = 'initialized';\n this.connection = null;\n\n this.key = key;\n this.options = options;\n this.timeline = this.options.timeline;\n this.usingTLS = this.options.useTLS;\n\n this.errorCallbacks = this.buildErrorCallbacks();\n this.connectionCallbacks = this.buildConnectionCallbacks(\n this.errorCallbacks\n );\n this.handshakeCallbacks = this.buildHandshakeCallbacks(this.errorCallbacks);\n\n var Network = Runtime.getNetwork();\n\n Network.bind('online', () => {\n this.timeline.info({ netinfo: 'online' });\n if (this.state === 'connecting' || this.state === 'unavailable') {\n this.retryIn(0);\n }\n });\n Network.bind('offline', () => {\n this.timeline.info({ netinfo: 'offline' });\n if (this.connection) {\n this.sendActivityCheck();\n }\n });\n\n this.updateStrategy();\n }\n\n switchCluster(key: string) {\n this.key = key;\n // This ensures that the new config coming from\n // pusher instance are taken into account\n // such as appKey and cluster\n this.updateStrategy();\n this.retryIn(0);\n }\n\n /** Establishes a connection to Pusher.\n *\n * Does nothing when connection is already established. See top-level doc\n * to find events emitted on connection attempts.\n */\n connect() {\n if (this.connection || this.runner) {\n return;\n }\n if (!this.strategy.isSupported()) {\n this.updateState('failed');\n return;\n }\n this.updateState('connecting');\n this.startConnecting();\n this.setUnavailableTimer();\n }\n\n /** Sends raw data.\n *\n * @param {String} data\n */\n send(data) {\n if (this.connection) {\n return this.connection.send(data);\n } else {\n return false;\n }\n }\n\n /** Sends an event.\n *\n * @param {String} name\n * @param {String} data\n * @param {String} [channel]\n * @returns {Boolean} whether message was sent or not\n */\n send_event(name: string, data: any, channel?: string) {\n if (this.connection) {\n return this.connection.send_event(name, data, channel);\n } else {\n return false;\n }\n }\n\n /** Closes the connection. */\n disconnect() {\n this.disconnectInternally();\n this.updateState('disconnected');\n }\n\n isUsingTLS() {\n return this.usingTLS;\n }\n\n private startConnecting() {\n var callback = (error, handshake) => {\n if (error) {\n this.runner = this.strategy.connect(0, callback);\n } else {\n if (handshake.action === 'error') {\n this.emit('error', {\n type: 'HandshakeError',\n error: handshake.error\n });\n this.timeline.error({ handshakeError: handshake.error });\n } else {\n this.abortConnecting(); // we don't support switching connections yet\n this.handshakeCallbacks[handshake.action](handshake);\n }\n }\n };\n this.runner = this.strategy.connect(0, callback);\n }\n\n private abortConnecting() {\n if (this.runner) {\n this.runner.abort();\n this.runner = null;\n }\n }\n\n private disconnectInternally() {\n this.abortConnecting();\n this.clearRetryTimer();\n this.clearUnavailableTimer();\n if (this.connection) {\n var connection = this.abandonConnection();\n connection.close();\n }\n }\n\n private updateStrategy() {\n this.strategy = this.options.getStrategy({\n key: this.key,\n timeline: this.timeline,\n useTLS: this.usingTLS\n });\n }\n\n private retryIn(delay) {\n this.timeline.info({ action: 'retry', delay: delay });\n if (delay > 0) {\n this.emit('connecting_in', Math.round(delay / 1000));\n }\n this.retryTimer = new Timer(delay || 0, () => {\n this.disconnectInternally();\n this.connect();\n });\n }\n\n private clearRetryTimer() {\n if (this.retryTimer) {\n this.retryTimer.ensureAborted();\n this.retryTimer = null;\n }\n }\n\n private setUnavailableTimer() {\n this.unavailableTimer = new Timer(this.options.unavailableTimeout, () => {\n this.updateState('unavailable');\n });\n }\n\n private clearUnavailableTimer() {\n if (this.unavailableTimer) {\n this.unavailableTimer.ensureAborted();\n }\n }\n\n private sendActivityCheck() {\n this.stopActivityCheck();\n this.connection.ping();\n // wait for pong response\n this.activityTimer = new Timer(this.options.pongTimeout, () => {\n this.timeline.error({ pong_timed_out: this.options.pongTimeout });\n this.retryIn(0);\n });\n }\n\n private resetActivityCheck() {\n this.stopActivityCheck();\n // send ping after inactivity\n if (this.connection && !this.connection.handlesActivityChecks()) {\n this.activityTimer = new Timer(this.activityTimeout, () => {\n this.sendActivityCheck();\n });\n }\n }\n\n private stopActivityCheck() {\n if (this.activityTimer) {\n this.activityTimer.ensureAborted();\n }\n }\n\n private buildConnectionCallbacks(\n errorCallbacks: ErrorCallbacks\n ): ConnectionCallbacks {\n return Collections.extend({}, errorCallbacks, {\n message: message => {\n // includes pong messages from server\n this.resetActivityCheck();\n this.emit('message', message);\n },\n ping: () => {\n this.send_event('pusher:pong', {});\n },\n activity: () => {\n this.resetActivityCheck();\n },\n error: error => {\n // just emit error to user - socket will already be closed by browser\n this.emit('error', error);\n },\n closed: () => {\n this.abandonConnection();\n if (this.shouldRetry()) {\n this.retryIn(1000);\n }\n }\n });\n }\n\n private buildHandshakeCallbacks(\n errorCallbacks: ErrorCallbacks\n ): HandshakeCallbacks {\n return Collections.extend({}, errorCallbacks, {\n connected: (handshake: HandshakePayload) => {\n this.activityTimeout = Math.min(\n this.options.activityTimeout,\n handshake.activityTimeout,\n handshake.connection.activityTimeout || Infinity\n );\n this.clearUnavailableTimer();\n this.setConnection(handshake.connection);\n this.socket_id = this.connection.id;\n this.updateState('connected', { socket_id: this.socket_id });\n }\n });\n }\n\n private buildErrorCallbacks(): ErrorCallbacks {\n let withErrorEmitted = callback => {\n return (result: Action | HandshakePayload) => {\n if (result.error) {\n this.emit('error', { type: 'WebSocketError', error: result.error });\n }\n callback(result);\n };\n };\n\n return {\n tls_only: withErrorEmitted(() => {\n this.usingTLS = true;\n this.updateStrategy();\n this.retryIn(0);\n }),\n refused: withErrorEmitted(() => {\n this.disconnect();\n }),\n backoff: withErrorEmitted(() => {\n this.retryIn(1000);\n }),\n retry: withErrorEmitted(() => {\n this.retryIn(0);\n })\n };\n }\n\n private setConnection(connection) {\n this.connection = connection;\n for (var event in this.connectionCallbacks) {\n this.connection.bind(event, this.connectionCallbacks[event]);\n }\n this.resetActivityCheck();\n }\n\n private abandonConnection() {\n if (!this.connection) {\n return;\n }\n this.stopActivityCheck();\n for (var event in this.connectionCallbacks) {\n this.connection.unbind(event, this.connectionCallbacks[event]);\n }\n var connection = this.connection;\n this.connection = null;\n return connection;\n }\n\n private updateState(newState: string, data?: any) {\n var previousState = this.state;\n this.state = newState;\n if (previousState !== newState) {\n var newStateDescription = newState;\n if (newStateDescription === 'connected') {\n newStateDescription += ' with new socket ID ' + data.socket_id;\n }\n Logger.debug(\n 'State changed',\n previousState + ' -> ' + newStateDescription\n );\n this.timeline.info({ state: newState, params: data });\n this.emit('state_change', { previous: previousState, current: newState });\n this.emit(newState, data);\n }\n }\n\n private shouldRetry(): boolean {\n return this.state === 'connecting' || this.state === 'connected';\n }\n}\n","import Channel from './channel';\nimport * as Collections from '../utils/collections';\nimport ChannelTable from './channel_table';\nimport Factory from '../utils/factory';\nimport Pusher from '../pusher';\nimport Logger from '../logger';\nimport * as Errors from '../errors';\nimport urlStore from '../utils/url_store';\n\n/** Handles a channel map. */\nexport default class Channels {\n channels: ChannelTable;\n\n constructor() {\n this.channels = {};\n }\n\n /** Creates or retrieves an existing channel by its name.\n *\n * @param {String} name\n * @param {Pusher} pusher\n * @return {Channel}\n */\n add(name: string, pusher: Pusher) {\n if (!this.channels[name]) {\n this.channels[name] = createChannel(name, pusher);\n }\n return this.channels[name];\n }\n\n /** Returns a list of all channels\n *\n * @return {Array}\n */\n all(): Channel[] {\n return Collections.values(this.channels);\n }\n\n /** Finds a channel by its name.\n *\n * @param {String} name\n * @return {Channel} channel or null if it doesn't exist\n */\n find(name: string) {\n return this.channels[name];\n }\n\n /** Removes a channel from the map.\n *\n * @param {String} name\n */\n remove(name: string) {\n var channel = this.channels[name];\n delete this.channels[name];\n return channel;\n }\n\n /** Proxies disconnection signal to all channels. */\n disconnect() {\n Collections.objectApply(this.channels, function(channel) {\n channel.disconnect();\n });\n }\n}\n\nfunction createChannel(name: string, pusher: Pusher): Channel {\n if (name.indexOf('private-encrypted-') === 0) {\n if (pusher.config.nacl) {\n return Factory.createEncryptedChannel(name, pusher, pusher.config.nacl);\n }\n let errMsg =\n 'Tried to subscribe to a private-encrypted- channel but no nacl implementation available';\n let suffix = urlStore.buildLogSuffix('encryptedChannelSupport');\n throw new Errors.UnsupportedFeature(`${errMsg}. ${suffix}`);\n } else if (name.indexOf('private-') === 0) {\n return Factory.createPrivateChannel(name, pusher);\n } else if (name.indexOf('presence-') === 0) {\n return Factory.createPresenceChannel(name, pusher);\n } else if (name.indexOf('#') === 0) {\n throw new Errors.BadChannelName(\n 'Cannot create a channel with name \"' + name + '\".'\n );\n } else {\n return Factory.createChannel(name, pusher);\n }\n}\n","import AssistantToTheTransportManager from '../transports/assistant_to_the_transport_manager';\nimport PingDelayOptions from '../transports/ping_delay_options';\nimport Transport from '../transports/transport';\nimport TransportManager from '../transports/transport_manager';\nimport Handshake from '../connection/handshake';\nimport TransportConnection from '../transports/transport_connection';\nimport SocketHooks from '../http/socket_hooks';\nimport HTTPSocket from '../http/http_socket';\n\nimport Timeline from '../timeline/timeline';\nimport {\n default as TimelineSender,\n TimelineSenderOptions\n} from '../timeline/timeline_sender';\nimport PresenceChannel from '../channels/presence_channel';\nimport PrivateChannel from '../channels/private_channel';\nimport EncryptedChannel from '../channels/encrypted_channel';\nimport Channel from '../channels/channel';\nimport ConnectionManager from '../connection/connection_manager';\nimport ConnectionManagerOptions from '../connection/connection_manager_options';\nimport Ajax from '../http/ajax';\nimport Channels from '../channels/channels';\nimport Pusher from '../pusher';\nimport { Config } from '../config';\nimport * as nacl from 'tweetnacl';\n\nvar Factory = {\n createChannels(): Channels {\n return new Channels();\n },\n\n createConnectionManager(\n key: string,\n options: ConnectionManagerOptions\n ): ConnectionManager {\n return new ConnectionManager(key, options);\n },\n\n createChannel(name: string, pusher: Pusher): Channel {\n return new Channel(name, pusher);\n },\n\n createPrivateChannel(name: string, pusher: Pusher): PrivateChannel {\n return new PrivateChannel(name, pusher);\n },\n\n createPresenceChannel(name: string, pusher: Pusher): PresenceChannel {\n return new PresenceChannel(name, pusher);\n },\n\n createEncryptedChannel(\n name: string,\n pusher: Pusher,\n nacl: nacl\n ): EncryptedChannel {\n return new EncryptedChannel(name, pusher, nacl);\n },\n\n createTimelineSender(timeline: Timeline, options: TimelineSenderOptions) {\n return new TimelineSender(timeline, options);\n },\n\n createHandshake(\n transport: TransportConnection,\n callback: (HandshakePayload) => void\n ): Handshake {\n return new Handshake(transport, callback);\n },\n\n createAssistantToTheTransportManager(\n manager: TransportManager,\n transport: Transport,\n options: PingDelayOptions\n ): AssistantToTheTransportManager {\n return new AssistantToTheTransportManager(manager, transport, options);\n }\n};\n\nexport default Factory;\n","import AssistantToTheTransportManager from './assistant_to_the_transport_manager';\nimport Transport from './transport';\nimport PingDelayOptions from './ping_delay_options';\nimport Factory from '../utils/factory';\n\nexport interface TransportManagerOptions extends PingDelayOptions {\n lives?: number;\n}\n\n/** Keeps track of the number of lives left for a transport.\n *\n * In the beginning of a session, transports may be assigned a number of\n * lives. When an AssistantToTheTransportManager instance reports a transport\n * connection closed uncleanly, the transport loses a life. When the number\n * of lives drops to zero, the transport gets disabled by its manager.\n *\n * @param {Object} options\n */\nexport default class TransportManager {\n options: TransportManagerOptions;\n livesLeft: number;\n\n constructor(options: TransportManagerOptions) {\n this.options = options || {};\n this.livesLeft = this.options.lives || Infinity;\n }\n\n /** Creates a assistant for the transport.\n *\n * @param {Transport} transport\n * @returns {AssistantToTheTransportManager}\n */\n getAssistant(transport: Transport): AssistantToTheTransportManager {\n return Factory.createAssistantToTheTransportManager(this, transport, {\n minPingDelay: this.options.minPingDelay,\n maxPingDelay: this.options.maxPingDelay\n });\n }\n\n /** Returns whether the transport has any lives left.\n *\n * @returns {Boolean}\n */\n isAlive(): boolean {\n return this.livesLeft > 0;\n }\n\n /** Takes one life from the transport. */\n reportDeath() {\n this.livesLeft -= 1;\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport { OneOffTimer as Timer } from '../utils/timers';\nimport Strategy from './strategy';\nimport StrategyOptions from './strategy_options';\n\n/** Loops through strategies with optional timeouts.\n *\n * Options:\n * - loop - whether it should loop through the substrategy list\n * - timeout - initial timeout for a single substrategy\n * - timeoutLimit - maximum timeout\n *\n * @param {Strategy[]} strategies\n * @param {Object} options\n */\nexport default class SequentialStrategy implements Strategy {\n strategies: Strategy[];\n loop: boolean;\n failFast: boolean;\n timeout: number;\n timeoutLimit: number;\n\n constructor(strategies: Strategy[], options: StrategyOptions) {\n this.strategies = strategies;\n this.loop = Boolean(options.loop);\n this.failFast = Boolean(options.failFast);\n this.timeout = options.timeout;\n this.timeoutLimit = options.timeoutLimit;\n }\n\n isSupported(): boolean {\n return Collections.any(this.strategies, Util.method('isSupported'));\n }\n\n connect(minPriority: number, callback: Function) {\n var strategies = this.strategies;\n var current = 0;\n var timeout = this.timeout;\n var runner = null;\n\n var tryNextStrategy = (error, handshake) => {\n if (handshake) {\n callback(null, handshake);\n } else {\n current = current + 1;\n if (this.loop) {\n current = current % strategies.length;\n }\n\n if (current < strategies.length) {\n if (timeout) {\n timeout = timeout * 2;\n if (this.timeoutLimit) {\n timeout = Math.min(timeout, this.timeoutLimit);\n }\n }\n runner = this.tryStrategy(\n strategies[current],\n minPriority,\n { timeout, failFast: this.failFast },\n tryNextStrategy\n );\n } else {\n callback(true);\n }\n }\n };\n\n runner = this.tryStrategy(\n strategies[current],\n minPriority,\n { timeout: timeout, failFast: this.failFast },\n tryNextStrategy\n );\n\n return {\n abort: function() {\n runner.abort();\n },\n forceMinPriority: function(p) {\n minPriority = p;\n if (runner) {\n runner.forceMinPriority(p);\n }\n }\n };\n }\n\n private tryStrategy(\n strategy: Strategy,\n minPriority: number,\n options: StrategyOptions,\n callback: Function\n ) {\n var timer = null;\n var runner = null;\n\n if (options.timeout > 0) {\n timer = new Timer(options.timeout, function() {\n runner.abort();\n callback(true);\n });\n }\n\n runner = strategy.connect(minPriority, function(error, handshake) {\n if (error && timer && timer.isRunning() && !options.failFast) {\n // advance to the next strategy after the timeout\n return;\n }\n if (timer) {\n timer.ensureAborted();\n }\n callback(error, handshake);\n });\n\n return {\n abort: function() {\n if (timer) {\n timer.ensureAborted();\n }\n runner.abort();\n },\n forceMinPriority: function(p) {\n runner.forceMinPriority(p);\n }\n };\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport Strategy from './strategy';\n\n/** Launches all substrategies and emits prioritized connected transports.\n *\n * @param {Array} strategies\n */\nexport default class BestConnectedEverStrategy implements Strategy {\n strategies: Strategy[];\n\n constructor(strategies: Strategy[]) {\n this.strategies = strategies;\n }\n\n isSupported(): boolean {\n return Collections.any(this.strategies, Util.method('isSupported'));\n }\n\n connect(minPriority: number, callback: Function) {\n return connect(this.strategies, minPriority, function(i, runners) {\n return function(error, handshake) {\n runners[i].error = error;\n if (error) {\n if (allRunnersFailed(runners)) {\n callback(true);\n }\n return;\n }\n Collections.apply(runners, function(runner) {\n runner.forceMinPriority(handshake.transport.priority);\n });\n callback(null, handshake);\n };\n });\n }\n}\n\n/** Connects to all strategies in parallel.\n *\n * Callback builder should be a function that takes two arguments: index\n * and a list of runners. It should return another function that will be\n * passed to the substrategy with given index. Runners can be aborted using\n * abortRunner(s) functions from this class.\n *\n * @param {Array} strategies\n * @param {Function} callbackBuilder\n * @return {Object} strategy runner\n */\nfunction connect(\n strategies: Strategy[],\n minPriority: number,\n callbackBuilder: Function\n) {\n var runners = Collections.map(strategies, function(strategy, i, _, rs) {\n return strategy.connect(minPriority, callbackBuilder(i, rs));\n });\n return {\n abort: function() {\n Collections.apply(runners, abortRunner);\n },\n forceMinPriority: function(p) {\n Collections.apply(runners, function(runner) {\n runner.forceMinPriority(p);\n });\n }\n };\n}\n\nfunction allRunnersFailed(runners): boolean {\n return Collections.all(runners, function(runner) {\n return Boolean(runner.error);\n });\n}\n\nfunction abortRunner(runner) {\n if (!runner.error && !runner.aborted) {\n runner.abort();\n runner.aborted = true;\n }\n}\n","import Util from '../util';\nimport Runtime from 'runtime';\nimport Strategy from './strategy';\nimport SequentialStrategy from './sequential_strategy';\nimport StrategyOptions from './strategy_options';\nimport TransportStrategy from './transport_strategy';\nimport Timeline from '../timeline/timeline';\nimport * as Collections from '../utils/collections';\n\nexport interface TransportStrategyDictionary {\n [key: string]: TransportStrategy;\n}\n\n/** Caches the last successful transport and, after the first few attempts,\n * uses the cached transport for subsequent attempts.\n *\n * @param {Strategy} strategy\n * @param {Object} transports\n * @param {Object} options\n */\nexport default class WebSocketPrioritizedCachedStrategy implements Strategy {\n strategy: Strategy;\n transports: TransportStrategyDictionary;\n ttl: number;\n usingTLS: boolean;\n timeline: Timeline;\n\n constructor(\n strategy: Strategy,\n transports: TransportStrategyDictionary,\n options: StrategyOptions\n ) {\n this.strategy = strategy;\n this.transports = transports;\n this.ttl = options.ttl || 1800 * 1000;\n this.usingTLS = options.useTLS;\n this.timeline = options.timeline;\n }\n\n isSupported(): boolean {\n return this.strategy.isSupported();\n }\n\n connect(minPriority: number, callback: Function) {\n var usingTLS = this.usingTLS;\n var info = fetchTransportCache(usingTLS);\n var cacheSkipCount = info && info.cacheSkipCount ? info.cacheSkipCount : 0;\n\n var strategies = [this.strategy];\n if (info && info.timestamp + this.ttl >= Util.now()) {\n var transport = this.transports[info.transport];\n if (transport) {\n if (['ws', 'wss'].includes(info.transport) || cacheSkipCount > 3) {\n this.timeline.info({\n cached: true,\n transport: info.transport,\n latency: info.latency\n });\n strategies.push(\n new SequentialStrategy([transport], {\n timeout: info.latency * 2 + 1000,\n failFast: true\n })\n );\n } else {\n cacheSkipCount++;\n }\n }\n }\n\n var startTimestamp = Util.now();\n var runner = strategies\n .pop()\n .connect(minPriority, function cb(error, handshake) {\n if (error) {\n flushTransportCache(usingTLS);\n if (strategies.length > 0) {\n startTimestamp = Util.now();\n runner = strategies.pop().connect(minPriority, cb);\n } else {\n callback(error);\n }\n } else {\n storeTransportCache(\n usingTLS,\n handshake.transport.name,\n Util.now() - startTimestamp,\n cacheSkipCount\n );\n callback(null, handshake);\n }\n });\n\n return {\n abort: function() {\n runner.abort();\n },\n forceMinPriority: function(p) {\n minPriority = p;\n if (runner) {\n runner.forceMinPriority(p);\n }\n }\n };\n }\n}\n\nfunction getTransportCacheKey(usingTLS: boolean): string {\n return 'pusherTransport' + (usingTLS ? 'TLS' : 'NonTLS');\n}\n\nfunction fetchTransportCache(usingTLS: boolean): any {\n var storage = Runtime.getLocalStorage();\n if (storage) {\n try {\n var serializedCache = storage[getTransportCacheKey(usingTLS)];\n if (serializedCache) {\n return JSON.parse(serializedCache);\n }\n } catch (e) {\n flushTransportCache(usingTLS);\n }\n }\n return null;\n}\n\nfunction storeTransportCache(\n usingTLS: boolean,\n transport: TransportStrategy,\n latency: number,\n cacheSkipCount: number\n) {\n var storage = Runtime.getLocalStorage();\n if (storage) {\n try {\n storage[getTransportCacheKey(usingTLS)] = Collections.safeJSONStringify({\n timestamp: Util.now(),\n transport: transport,\n latency: latency,\n cacheSkipCount: cacheSkipCount\n });\n } catch (e) {\n // catch over quota exceptions raised by localStorage\n }\n }\n}\n\nfunction flushTransportCache(usingTLS: boolean) {\n var storage = Runtime.getLocalStorage();\n if (storage) {\n try {\n delete storage[getTransportCacheKey(usingTLS)];\n } catch (e) {\n // catch exceptions raised by localStorage\n }\n }\n}\n","import { OneOffTimer as Timer } from '../utils/timers';\nimport Strategy from './strategy';\nimport StrategyOptions from './strategy_options';\n\n/** Runs substrategy after specified delay.\n *\n * Options:\n * - delay - time in miliseconds to delay the substrategy attempt\n *\n * @param {Strategy} strategy\n * @param {Object} options\n */\nexport default class DelayedStrategy implements Strategy {\n strategy: Strategy;\n options: { delay: number };\n\n constructor(strategy: Strategy, { delay: number }) {\n this.strategy = strategy;\n this.options = { delay: number };\n }\n\n isSupported(): boolean {\n return this.strategy.isSupported();\n }\n\n connect(minPriority: number, callback: Function) {\n var strategy = this.strategy;\n var runner;\n var timer = new Timer(this.options.delay, function() {\n runner = strategy.connect(minPriority, callback);\n });\n\n return {\n abort: function() {\n timer.ensureAborted();\n if (runner) {\n runner.abort();\n }\n },\n forceMinPriority: function(p) {\n minPriority = p;\n if (runner) {\n runner.forceMinPriority(p);\n }\n }\n };\n }\n}\n","import Strategy from './strategy';\nimport StrategyRunner from './strategy_runner';\n\n/** Proxies method calls to one of substrategies basing on the test function.\n *\n * @param {Function} test\n * @param {Strategy} trueBranch strategy used when test returns true\n * @param {Strategy} falseBranch strategy used when test returns false\n */\nexport default class IfStrategy implements Strategy {\n test: () => boolean;\n trueBranch: Strategy;\n falseBranch: Strategy;\n\n constructor(\n test: () => boolean,\n trueBranch: Strategy,\n falseBranch: Strategy\n ) {\n this.test = test;\n this.trueBranch = trueBranch;\n this.falseBranch = falseBranch;\n }\n\n isSupported(): boolean {\n var branch = this.test() ? this.trueBranch : this.falseBranch;\n return branch.isSupported();\n }\n\n connect(minPriority: number, callback: Function): StrategyRunner {\n var branch = this.test() ? this.trueBranch : this.falseBranch;\n return branch.connect(minPriority, callback);\n }\n}\n","import Strategy from './strategy';\nimport StrategyRunner from './strategy_runner';\n\n/** Launches the substrategy and terminates on the first open connection.\n *\n * @param {Strategy} strategy\n */\nexport default class FirstConnectedStrategy implements Strategy {\n strategy: Strategy;\n\n constructor(strategy: Strategy) {\n this.strategy = strategy;\n }\n\n isSupported(): boolean {\n return this.strategy.isSupported();\n }\n\n connect(minPriority: number, callback: Function): StrategyRunner {\n var runner = this.strategy.connect(minPriority, function(error, handshake) {\n if (handshake) {\n runner.abort();\n }\n callback(error, handshake);\n });\n return runner;\n }\n}\n","import * as Collections from 'core/utils/collections';\nimport TransportManager from 'core/transports/transport_manager';\nimport Strategy from 'core/strategies/strategy';\nimport SequentialStrategy from 'core/strategies/sequential_strategy';\nimport BestConnectedEverStrategy from 'core/strategies/best_connected_ever_strategy';\nimport WebSocketPrioritizedCachedStrategy, {\n TransportStrategyDictionary\n} from 'core/strategies/websocket_prioritized_cached_strategy';\nimport DelayedStrategy from 'core/strategies/delayed_strategy';\nimport IfStrategy from 'core/strategies/if_strategy';\nimport FirstConnectedStrategy from 'core/strategies/first_connected_strategy';\nimport { Config } from 'core/config';\nimport StrategyOptions from 'core/strategies/strategy_options';\n\nfunction testSupportsStrategy(strategy: Strategy) {\n return function() {\n return strategy.isSupported();\n };\n}\n\nvar getDefaultStrategy = function(\n config: Config,\n baseOptions: StrategyOptions,\n defineTransport: Function\n): Strategy {\n var definedTransports = {};\n\n function defineTransportStrategy(\n name: string,\n type: string,\n priority: number,\n options: StrategyOptions,\n manager?: TransportManager\n ) {\n var transport = defineTransport(\n config,\n name,\n type,\n priority,\n options,\n manager\n );\n\n definedTransports[name] = transport;\n\n return transport;\n }\n\n var ws_options: StrategyOptions = Object.assign({}, baseOptions, {\n hostNonTLS: config.wsHost + ':' + config.wsPort,\n hostTLS: config.wsHost + ':' + config.wssPort,\n httpPath: config.wsPath\n });\n var wss_options: StrategyOptions = Collections.extend({}, ws_options, {\n useTLS: true\n });\n var http_options: StrategyOptions = Object.assign({}, baseOptions, {\n hostNonTLS: config.httpHost + ':' + config.httpPort,\n hostTLS: config.httpHost + ':' + config.httpsPort,\n httpPath: config.httpPath\n });\n var timeouts = {\n loop: true,\n timeout: 15000,\n timeoutLimit: 60000\n };\n\n var ws_manager = new TransportManager({\n minPingDelay: 10000,\n maxPingDelay: config.activityTimeout\n });\n var streaming_manager = new TransportManager({\n lives: 2,\n minPingDelay: 10000,\n maxPingDelay: config.activityTimeout\n });\n\n var ws_transport = defineTransportStrategy(\n 'ws',\n 'ws',\n 3,\n ws_options,\n ws_manager\n );\n var wss_transport = defineTransportStrategy(\n 'wss',\n 'ws',\n 3,\n wss_options,\n ws_manager\n );\n var xhr_streaming_transport = defineTransportStrategy(\n 'xhr_streaming',\n 'xhr_streaming',\n 1,\n http_options,\n streaming_manager\n );\n var xhr_polling_transport = defineTransportStrategy(\n 'xhr_polling',\n 'xhr_polling',\n 1,\n http_options\n );\n\n var ws_loop = new SequentialStrategy([ws_transport], timeouts);\n var wss_loop = new SequentialStrategy([wss_transport], timeouts);\n var streaming_loop = new SequentialStrategy(\n [xhr_streaming_transport],\n timeouts\n );\n var polling_loop = new SequentialStrategy([xhr_polling_transport], timeouts);\n\n var http_loop = new SequentialStrategy(\n [\n new IfStrategy(\n testSupportsStrategy(streaming_loop),\n new BestConnectedEverStrategy([\n streaming_loop,\n new DelayedStrategy(polling_loop, { delay: 4000 })\n ]),\n polling_loop\n )\n ],\n timeouts\n );\n\n var wsStrategy;\n if (baseOptions.useTLS) {\n wsStrategy = new BestConnectedEverStrategy([\n ws_loop,\n new DelayedStrategy(http_loop, { delay: 2000 })\n ]);\n } else {\n wsStrategy = new BestConnectedEverStrategy([\n ws_loop,\n new DelayedStrategy(wss_loop, { delay: 2000 }),\n new DelayedStrategy(http_loop, { delay: 5000 })\n ]);\n }\n\n return new WebSocketPrioritizedCachedStrategy(\n new FirstConnectedStrategy(\n new IfStrategy(testSupportsStrategy(ws_transport), wsStrategy, http_loop)\n ),\n definedTransports,\n {\n ttl: 1800000,\n timeline: baseOptions.timeline,\n useTLS: baseOptions.useTLS\n }\n );\n};\n\nexport default getDefaultStrategy;\n","/** Initializes the transport.\n *\n * Fetches resources if needed and then transitions to initialized.\n */\nexport default function() {\n var self = this;\n\n self.timeline.info(\n self.buildTimelineMessage({\n transport: self.name + (self.options.useTLS ? 's' : '')\n })\n );\n\n if (self.hooks.isInitialized()) {\n self.changeState('initialized');\n } else {\n self.onClose();\n }\n}\n","import Runtime from 'runtime';\nimport RequestHooks from './request_hooks';\nimport Ajax from './ajax';\nimport { default as EventsDispatcher } from '../events/dispatcher';\n\nconst MAX_BUFFER_LENGTH = 256 * 1024;\n\nexport default class HTTPRequest extends EventsDispatcher {\n hooks: RequestHooks;\n method: string;\n url: string;\n position: number;\n xhr: Ajax;\n unloader: Function;\n\n constructor(hooks: RequestHooks, method: string, url: string) {\n super();\n this.hooks = hooks;\n this.method = method;\n this.url = url;\n }\n\n start(payload?: any) {\n this.position = 0;\n this.xhr = this.hooks.getRequest(this);\n\n this.unloader = () => {\n this.close();\n };\n Runtime.addUnloadListener(this.unloader);\n\n this.xhr.open(this.method, this.url, true);\n\n if (this.xhr.setRequestHeader) {\n this.xhr.setRequestHeader('Content-Type', 'application/json'); // ReactNative doesn't set this header by default.\n }\n this.xhr.send(payload);\n }\n\n close() {\n if (this.unloader) {\n Runtime.removeUnloadListener(this.unloader);\n this.unloader = null;\n }\n if (this.xhr) {\n this.hooks.abortRequest(this.xhr);\n this.xhr = null;\n }\n }\n\n onChunk(status: number, data: any) {\n while (true) {\n var chunk = this.advanceBuffer(data);\n if (chunk) {\n this.emit('chunk', { status: status, data: chunk });\n } else {\n break;\n }\n }\n if (this.isBufferTooLong(data)) {\n this.emit('buffer_too_long');\n }\n }\n\n private advanceBuffer(buffer: any[]): any {\n var unreadData = buffer.slice(this.position);\n var endOfLinePosition = unreadData.indexOf('\\n');\n\n if (endOfLinePosition !== -1) {\n this.position += endOfLinePosition + 1;\n return unreadData.slice(0, endOfLinePosition);\n } else {\n // chunk is not finished yet, don't move the buffer pointer\n return null;\n }\n }\n\n private isBufferTooLong(buffer: any): boolean {\n return this.position === buffer.length && buffer.length > MAX_BUFFER_LENGTH;\n }\n}\n","enum State {\n CONNECTING = 0,\n OPEN = 1,\n CLOSED = 3\n}\n\nexport default State;\n","import URLLocation from './url_location';\nimport State from './state';\nimport Socket from '../socket';\nimport SocketHooks from './socket_hooks';\nimport Util from '../util';\nimport Ajax from './ajax';\nimport HTTPRequest from './http_request';\nimport Runtime from 'runtime';\n\nvar autoIncrement = 1;\n\nclass HTTPSocket implements Socket {\n hooks: SocketHooks;\n session: string;\n location: URLLocation;\n readyState: State;\n stream: HTTPRequest;\n\n onopen: () => void;\n onerror: (error: any) => void;\n onclose: (closeEvent: any) => void;\n onmessage: (message: any) => void;\n onactivity: () => void;\n\n constructor(hooks: SocketHooks, url: string) {\n this.hooks = hooks;\n this.session = randomNumber(1000) + '/' + randomString(8);\n this.location = getLocation(url);\n this.readyState = State.CONNECTING;\n this.openStream();\n }\n\n send(payload: any) {\n return this.sendRaw(JSON.stringify([payload]));\n }\n\n ping() {\n this.hooks.sendHeartbeat(this);\n }\n\n close(code: any, reason: any) {\n this.onClose(code, reason, true);\n }\n\n /** For internal use only */\n sendRaw(payload: any): boolean {\n if (this.readyState === State.OPEN) {\n try {\n Runtime.createSocketRequest(\n 'POST',\n getUniqueURL(getSendURL(this.location, this.session))\n ).start(payload);\n return true;\n } catch (e) {\n return false;\n }\n } else {\n return false;\n }\n }\n\n /** For internal use only */\n reconnect() {\n this.closeStream();\n this.openStream();\n }\n\n /** For internal use only */\n onClose(code, reason, wasClean) {\n this.closeStream();\n this.readyState = State.CLOSED;\n if (this.onclose) {\n this.onclose({\n code: code,\n reason: reason,\n wasClean: wasClean\n });\n }\n }\n\n private onChunk(chunk) {\n if (chunk.status !== 200) {\n return;\n }\n if (this.readyState === State.OPEN) {\n this.onActivity();\n }\n\n var payload;\n var type = chunk.data.slice(0, 1);\n switch (type) {\n case 'o':\n payload = JSON.parse(chunk.data.slice(1) || '{}');\n this.onOpen(payload);\n break;\n case 'a':\n payload = JSON.parse(chunk.data.slice(1) || '[]');\n for (var i = 0; i < payload.length; i++) {\n this.onEvent(payload[i]);\n }\n break;\n case 'm':\n payload = JSON.parse(chunk.data.slice(1) || 'null');\n this.onEvent(payload);\n break;\n case 'h':\n this.hooks.onHeartbeat(this);\n break;\n case 'c':\n payload = JSON.parse(chunk.data.slice(1) || '[]');\n this.onClose(payload[0], payload[1], true);\n break;\n }\n }\n\n private onOpen(options) {\n if (this.readyState === State.CONNECTING) {\n if (options && options.hostname) {\n this.location.base = replaceHost(this.location.base, options.hostname);\n }\n this.readyState = State.OPEN;\n\n if (this.onopen) {\n this.onopen();\n }\n } else {\n this.onClose(1006, 'Server lost session', true);\n }\n }\n\n private onEvent(event) {\n if (this.readyState === State.OPEN && this.onmessage) {\n this.onmessage({ data: event });\n }\n }\n\n private onActivity() {\n if (this.onactivity) {\n this.onactivity();\n }\n }\n\n private onError(error) {\n if (this.onerror) {\n this.onerror(error);\n }\n }\n\n private openStream() {\n this.stream = Runtime.createSocketRequest(\n 'POST',\n getUniqueURL(this.hooks.getReceiveURL(this.location, this.session))\n );\n\n this.stream.bind('chunk', chunk => {\n this.onChunk(chunk);\n });\n this.stream.bind('finished', status => {\n this.hooks.onFinished(this, status);\n });\n this.stream.bind('buffer_too_long', () => {\n this.reconnect();\n });\n\n try {\n this.stream.start();\n } catch (error) {\n Util.defer(() => {\n this.onError(error);\n this.onClose(1006, 'Could not start streaming', false);\n });\n }\n }\n\n private closeStream() {\n if (this.stream) {\n this.stream.unbind_all();\n this.stream.close();\n this.stream = null;\n }\n }\n}\n\nfunction getLocation(url): URLLocation {\n var parts = /([^\\?]*)\\/*(\\??.*)/.exec(url);\n return {\n base: parts[1],\n queryString: parts[2]\n };\n}\n\nfunction getSendURL(url: URLLocation, session: string): string {\n return url.base + '/' + session + '/xhr_send';\n}\n\nfunction getUniqueURL(url: string): string {\n var separator = url.indexOf('?') === -1 ? '?' : '&';\n return url + separator + 't=' + +new Date() + '&n=' + autoIncrement++;\n}\n\nfunction replaceHost(url: string, hostname: string): string {\n var urlParts = /(https?:\\/\\/)([^\\/:]+)((\\/|:)?.*)/.exec(url);\n return urlParts[1] + hostname + urlParts[3];\n}\n\nfunction randomNumber(max: number): number {\n return Runtime.randomInt(max);\n}\n\nfunction randomString(length: number): string {\n var result = [];\n\n for (var i = 0; i < length; i++) {\n result.push(randomNumber(32).toString(32));\n }\n\n return result.join('');\n}\n\nexport default HTTPSocket;\n","import SocketHooks from './socket_hooks';\nimport HTTPSocket from './http_socket';\n\nvar hooks: SocketHooks = {\n getReceiveURL: function(url, session) {\n return url.base + '/' + session + '/xhr_streaming' + url.queryString;\n },\n onHeartbeat: function(socket) {\n socket.sendRaw('[]');\n },\n sendHeartbeat: function(socket) {\n socket.sendRaw('[]');\n },\n onFinished: function(socket, status) {\n socket.onClose(1006, 'Connection interrupted (' + status + ')', false);\n }\n};\n\nexport default hooks;\n","import SocketHooks from './socket_hooks';\nimport URLLocation from './url_location';\nimport HTTPSocket from './http_socket';\n\nvar hooks: SocketHooks = {\n getReceiveURL: function(url: URLLocation, session: string): string {\n return url.base + '/' + session + '/xhr' + url.queryString;\n },\n onHeartbeat: function() {\n // next HTTP request will reset server's activity timer\n },\n sendHeartbeat: function(socket) {\n socket.sendRaw('[]');\n },\n onFinished: function(socket, status) {\n if (status === 200) {\n socket.reconnect();\n } else {\n socket.onClose(1006, 'Connection interrupted (' + status + ')', false);\n }\n }\n};\n\nexport default hooks;\n","import HTTPRequest from 'core/http/http_request';\nimport RequestHooks from 'core/http/request_hooks';\nimport Ajax from 'core/http/ajax';\nimport Runtime from 'runtime';\n\nvar hooks: RequestHooks = {\n getRequest: function(socket: HTTPRequest): Ajax {\n var Constructor = Runtime.getXHRAPI();\n var xhr = new Constructor();\n xhr.onreadystatechange = xhr.onprogress = function() {\n switch (xhr.readyState) {\n case 3:\n if (xhr.responseText && xhr.responseText.length > 0) {\n socket.onChunk(xhr.status, xhr.responseText);\n }\n break;\n case 4:\n // this happens only on errors, never after calling close\n if (xhr.responseText && xhr.responseText.length > 0) {\n socket.onChunk(xhr.status, xhr.responseText);\n }\n socket.emit('finished', xhr.status);\n socket.close();\n break;\n }\n };\n return xhr;\n },\n abortRequest: function(xhr: Ajax) {\n xhr.onreadystatechange = null;\n xhr.abort();\n }\n};\n\nexport default hooks;\n","import HTTPRequest from 'core/http/http_request';\nimport HTTPSocket from 'core/http/http_socket';\nimport SocketHooks from 'core/http/socket_hooks';\nimport RequestHooks from 'core/http/request_hooks';\nimport streamingHooks from 'core/http/http_streaming_socket';\nimport pollingHooks from 'core/http/http_polling_socket';\nimport xhrHooks from './http_xhr_request';\nimport HTTPFactory from 'core/http/http_factory';\n\nvar HTTP: HTTPFactory = {\n createStreamingSocket(url: string): HTTPSocket {\n return this.createSocket(streamingHooks, url);\n },\n\n createPollingSocket(url: string): HTTPSocket {\n return this.createSocket(pollingHooks, url);\n },\n\n createSocket(hooks: SocketHooks, url: string): HTTPSocket {\n return new HTTPSocket(hooks, url);\n },\n\n createXHR(method: string, url: string): HTTPRequest {\n return this.createRequest(xhrHooks, method, url);\n },\n\n createRequest(hooks: RequestHooks, method: string, url: string): HTTPRequest {\n return new HTTPRequest(hooks, method, url);\n }\n};\n\nexport default HTTP;\n","import * as Collections from 'core/utils/collections';\nimport Transports from 'isomorphic/transports/transports';\nimport TimelineSender from 'core/timeline/timeline_sender';\nimport Ajax from 'core/http/ajax';\nimport getDefaultStrategy from './default_strategy';\nimport TransportsTable from 'core/transports/transports_table';\nimport transportConnectionInitializer from './transports/transport_connection_initializer';\nimport HTTPFactory from './http/http';\n\nvar Isomorphic: any = {\n getDefaultStrategy,\n Transports: Transports,\n transportConnectionInitializer,\n HTTPFactory,\n\n setup(PusherClass): void {\n PusherClass.ready();\n },\n\n getLocalStorage(): any {\n return undefined;\n },\n\n getClientFeatures(): any[] {\n return Collections.keys(\n Collections.filterObject({ ws: Transports.ws }, function(t) {\n return t.isSupported({});\n })\n );\n },\n\n getProtocol(): string {\n return 'http:';\n },\n\n isXHRSupported(): boolean {\n return true;\n },\n\n createSocketRequest(method: string, url: string) {\n if (this.isXHRSupported()) {\n return this.HTTPFactory.createXHR(method, url);\n } else {\n throw 'Cross-origin HTTP requests are not supported';\n }\n },\n\n createXHR(): Ajax {\n var Constructor = this.getXHRAPI();\n return new Constructor();\n },\n\n createWebSocket(url: string): any {\n var Constructor = this.getWebSocketAPI();\n return new Constructor(url);\n },\n\n addUnloadListener(listener: any) {},\n removeUnloadListener(listener: any) {}\n};\n\nexport default Isomorphic;\n","import { default as EventsDispatcher } from 'core/events/dispatcher';\nimport Reachability from 'core/reachability';\n\nexport class NetInfo extends EventsDispatcher implements Reachability {\n isOnline(): boolean {\n return true;\n }\n}\n\nexport var Network = new NetInfo();\n","import AbstractRuntime from 'runtimes/interface';\nimport { AuthTransport } from 'core/auth/auth_transports';\nimport {\n AuthRequestType,\n AuthTransportCallback,\n InternalAuthOptions\n} from 'core/auth/options';\nimport { HTTPAuthError } from 'core/errors';\n\nvar fetchAuth: AuthTransport = function(\n context: AbstractRuntime,\n query: string,\n authOptions: InternalAuthOptions,\n authRequestType: AuthRequestType,\n callback: AuthTransportCallback\n) {\n var headers = new Headers();\n headers.set('Content-Type', 'application/x-www-form-urlencoded');\n\n for (var headerName in authOptions.headers) {\n headers.set(headerName, authOptions.headers[headerName]);\n }\n\n if (authOptions.headersProvider != null) {\n const dynamicHeaders = authOptions.headersProvider();\n for (var headerName in dynamicHeaders) {\n headers.set(headerName, dynamicHeaders[headerName]);\n }\n }\n\n var body = query;\n var request = new Request(authOptions.endpoint, {\n headers,\n body,\n credentials: 'same-origin',\n method: 'POST'\n });\n\n return fetch(request)\n .then(response => {\n let { status } = response;\n if (status === 200) {\n // manually parse the json so we can provide a more helpful error in\n // failure case\n return response.text();\n }\n throw new HTTPAuthError(\n status,\n `Could not get ${authRequestType.toString()} info from your auth endpoint, status: ${status}`\n );\n })\n .then(data => {\n let parsedData;\n try {\n parsedData = JSON.parse(data);\n } catch (e) {\n throw new HTTPAuthError(\n 200,\n `JSON returned from ${authRequestType.toString()} endpoint was invalid, yet status code was 200. Data was: ${data}`\n );\n }\n callback(null, parsedData);\n })\n .catch(err => {\n callback(err, null);\n });\n};\n\nexport default fetchAuth;\n","import Logger from 'core/logger';\nimport TimelineSender from 'core/timeline/timeline_sender';\nimport * as Collections from 'core/utils/collections';\nimport Util from 'core/util';\nimport Runtime from 'runtime';\nimport TimelineTransport from 'core/timeline/timeline_transport';\n\nvar getAgent = function(sender: TimelineSender, useTLS: boolean) {\n return function(data: any, callback: Function) {\n var scheme = 'http' + (useTLS ? 's' : '') + '://';\n var url =\n scheme + (sender.host || sender.options.host) + sender.options.path;\n var query = Collections.buildQueryString(data);\n url += '/' + 2 + '?' + query;\n\n fetch(url)\n .then(response => {\n if (response.status !== 200) {\n throw `received ${response.status} from stats.pusher.com`;\n }\n return response.json();\n })\n .then(({ host }) => {\n if (host) {\n sender.host = host;\n }\n })\n .catch(err => {\n Logger.debug('TimelineSender Error: ', err);\n });\n };\n};\n\nvar fetchTimeline = {\n name: 'xhr',\n getAgent\n};\n\nexport default fetchTimeline;\n","import Isomorphic from 'isomorphic/runtime';\nimport Runtime from '../interface';\nimport { Network } from './net_info';\nimport fetchAuth from './auth/fetch_auth';\nimport { AuthTransports } from 'core/auth/auth_transports';\nimport fetchTimeline from './timeline/fetch_timeline';\n\n// Very verbose but until unavoidable until\n// TypeScript 2.1, when spread attributes will be\n// supported\nconst {\n getDefaultStrategy,\n Transports,\n setup,\n getProtocol,\n isXHRSupported,\n getLocalStorage,\n createXHR,\n createWebSocket,\n addUnloadListener,\n removeUnloadListener,\n transportConnectionInitializer,\n createSocketRequest,\n HTTPFactory\n} = Isomorphic;\n\nconst Worker: Runtime = {\n getDefaultStrategy,\n Transports,\n setup,\n getProtocol,\n isXHRSupported,\n getLocalStorage,\n createXHR,\n createWebSocket,\n addUnloadListener,\n removeUnloadListener,\n transportConnectionInitializer,\n createSocketRequest,\n HTTPFactory,\n\n TimelineTransport: fetchTimeline,\n\n getAuthorizers(): AuthTransports {\n return { ajax: fetchAuth };\n },\n\n getWebSocketAPI() {\n return WebSocket;\n },\n\n getXHRAPI() {\n return XMLHttpRequest;\n },\n\n getNetwork() {\n return Network;\n },\n\n randomInt(max: number): number {\n /**\n * Return values in the range of [0, 1[\n */\n const random = function() {\n const crypto = globalThis.crypto || globalThis['msCrypto'];\n const random = crypto.getRandomValues(new Uint32Array(1))[0];\n\n return random / 2 ** 32;\n };\n\n return Math.floor(random() * max);\n }\n};\n\nexport default Worker;\n","enum TimelineLevel {\n ERROR = 3,\n INFO = 6,\n DEBUG = 7\n}\n\nexport default TimelineLevel;\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport { default as Level } from './level';\n\nexport interface TimelineOptions {\n level?: Level;\n limit?: number;\n version?: string;\n cluster?: string;\n features?: string[];\n params?: any;\n}\n\nexport default class Timeline {\n key: string;\n session: number;\n events: any[];\n options: TimelineOptions;\n sent: number;\n uniqueID: number;\n\n constructor(key: string, session: number, options: TimelineOptions) {\n this.key = key;\n this.session = session;\n this.events = [];\n this.options = options || {};\n this.sent = 0;\n this.uniqueID = 0;\n }\n\n log(level, event) {\n if (level <= this.options.level) {\n this.events.push(\n Collections.extend({}, event, { timestamp: Util.now() })\n );\n if (this.options.limit && this.events.length > this.options.limit) {\n this.events.shift();\n }\n }\n }\n\n error(event) {\n this.log(Level.ERROR, event);\n }\n\n info(event) {\n this.log(Level.INFO, event);\n }\n\n debug(event) {\n this.log(Level.DEBUG, event);\n }\n\n isEmpty() {\n return this.events.length === 0;\n }\n\n send(sendfn, callback) {\n var data = Collections.extend(\n {\n session: this.session,\n bundle: this.sent + 1,\n key: this.key,\n lib: 'js',\n version: this.options.version,\n cluster: this.options.cluster,\n features: this.options.features,\n timeline: this.events\n },\n this.options.params\n );\n\n this.events = [];\n sendfn(data, (error, result) => {\n if (!error) {\n this.sent++;\n }\n if (callback) {\n callback(error, result);\n }\n });\n\n return true;\n }\n\n generateUniqueID(): number {\n this.uniqueID++;\n return this.uniqueID;\n }\n}\n","import Factory from '../utils/factory';\nimport Util from '../util';\nimport * as Errors from '../errors';\nimport * as Collections from '../utils/collections';\nimport Strategy from './strategy';\nimport Transport from '../transports/transport';\nimport StrategyOptions from './strategy_options';\nimport Handshake from '../connection/handshake';\n\n/** Provides a strategy interface for transports.\n *\n * @param {String} name\n * @param {Number} priority\n * @param {Class} transport\n * @param {Object} options\n */\nexport default class TransportStrategy implements Strategy {\n name: string;\n priority: number;\n transport: Transport;\n options: StrategyOptions;\n\n constructor(\n name: string,\n priority: number,\n transport: Transport,\n options: StrategyOptions\n ) {\n this.name = name;\n this.priority = priority;\n this.transport = transport;\n this.options = options || {};\n }\n\n /** Returns whether the transport is supported in the browser.\n *\n * @returns {Boolean}\n */\n isSupported(): boolean {\n return this.transport.isSupported({\n useTLS: this.options.useTLS\n });\n }\n\n /** Launches a connection attempt and returns a strategy runner.\n *\n * @param {Function} callback\n * @return {Object} strategy runner\n */\n connect(minPriority: number, callback: Function) {\n if (!this.isSupported()) {\n return failAttempt(new Errors.UnsupportedStrategy(), callback);\n } else if (this.priority < minPriority) {\n return failAttempt(new Errors.TransportPriorityTooLow(), callback);\n }\n\n var connected = false;\n var transport = this.transport.createConnection(\n this.name,\n this.priority,\n this.options.key,\n this.options\n );\n var handshake = null;\n\n var onInitialized = function() {\n transport.unbind('initialized', onInitialized);\n transport.connect();\n };\n var onOpen = function() {\n handshake = Factory.createHandshake(transport, function(result) {\n connected = true;\n unbindListeners();\n callback(null, result);\n });\n };\n var onError = function(error) {\n unbindListeners();\n callback(error);\n };\n var onClosed = function() {\n unbindListeners();\n var serializedTransport;\n\n // The reason for this try/catch block is that on React Native\n // the WebSocket object is circular. Therefore transport.socket will\n // throw errors upon stringification. Collections.safeJSONStringify\n // discards circular references when serializing.\n serializedTransport = Collections.safeJSONStringify(transport);\n callback(new Errors.TransportClosed(serializedTransport));\n };\n\n var unbindListeners = function() {\n transport.unbind('initialized', onInitialized);\n transport.unbind('open', onOpen);\n transport.unbind('error', onError);\n transport.unbind('closed', onClosed);\n };\n\n transport.bind('initialized', onInitialized);\n transport.bind('open', onOpen);\n transport.bind('error', onError);\n transport.bind('closed', onClosed);\n\n // connect will be called automatically after initialization\n transport.initialize();\n\n return {\n abort: () => {\n if (connected) {\n return;\n }\n unbindListeners();\n if (handshake) {\n handshake.close();\n } else {\n transport.close();\n }\n },\n forceMinPriority: p => {\n if (connected) {\n return;\n }\n if (this.priority < p) {\n if (handshake) {\n handshake.close();\n } else {\n transport.close();\n }\n }\n }\n };\n }\n}\n\nfunction failAttempt(error: Error, callback: Function) {\n Util.defer(function() {\n callback(error);\n });\n return {\n abort: function() {},\n forceMinPriority: function() {}\n };\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport TransportManager from '../transports/transport_manager';\nimport * as Errors from '../errors';\nimport Strategy from './strategy';\nimport TransportStrategy from './transport_strategy';\nimport StrategyOptions from '../strategies/strategy_options';\nimport { Config } from '../config';\nimport Runtime from 'runtime';\n\nconst { Transports } = Runtime;\n\nexport var defineTransport = function(\n config: Config,\n name: string,\n type: string,\n priority: number,\n options: StrategyOptions,\n manager?: TransportManager\n): Strategy {\n var transportClass = Transports[type];\n if (!transportClass) {\n throw new Errors.UnsupportedTransport(type);\n }\n\n var enabled =\n (!config.enabledTransports ||\n Collections.arrayIndexOf(config.enabledTransports, name) !== -1) &&\n (!config.disabledTransports ||\n Collections.arrayIndexOf(config.disabledTransports, name) === -1);\n\n var transport;\n if (enabled) {\n options = Object.assign(\n { ignoreNullOrigin: config.ignoreNullOrigin },\n options\n );\n\n transport = new TransportStrategy(\n name,\n priority,\n manager ? manager.getAssistant(transportClass) : transportClass,\n options\n );\n } else {\n transport = UnsupportedStrategy;\n }\n\n return transport;\n};\n\nvar UnsupportedStrategy: Strategy = {\n isSupported: function() {\n return false;\n },\n connect: function(_, callback) {\n var deferred = Util.defer(function() {\n callback(new Errors.UnsupportedStrategy());\n });\n return {\n abort: function() {\n deferred.ensureAborted();\n },\n forceMinPriority: function() {}\n };\n }\n};\n","import ConnectionManager from './connection/connection_manager';\nimport {\n ChannelAuthorizationOptions,\n UserAuthenticationOptions\n} from './auth/options';\nimport {\n ChannelAuthorizerGenerator,\n DeprecatedAuthOptions\n} from './auth/deprecated_channel_authorizer';\nimport { AuthTransport, Transport } from './config';\nimport * as nacl from 'tweetnacl';\nimport Logger from './logger';\n\nexport interface Options {\n activityTimeout?: number;\n\n auth?: DeprecatedAuthOptions; // DEPRECATED use channelAuthorization instead\n authEndpoint?: string; // DEPRECATED use channelAuthorization instead\n authTransport?: AuthTransport; // DEPRECATED use channelAuthorization instead\n authorizer?: ChannelAuthorizerGenerator; // DEPRECATED use channelAuthorization instead\n\n channelAuthorization?: ChannelAuthorizationOptions;\n userAuthentication?: UserAuthenticationOptions;\n\n cluster: string;\n enableStats?: boolean;\n disableStats?: boolean;\n disabledTransports?: Transport[];\n enabledTransports?: Transport[];\n forceTLS?: boolean;\n httpHost?: string;\n httpPath?: string;\n httpPort?: number;\n httpsPort?: number;\n ignoreNullOrigin?: boolean;\n nacl?: nacl;\n pongTimeout?: number;\n statsHost?: string;\n timelineParams?: any;\n unavailableTimeout?: number;\n wsHost?: string;\n wsPath?: string;\n wsPort?: number;\n wssPort?: number;\n}\n\nexport interface ClusterOptions {\n appKey: string;\n cluster: string;\n}\n\nexport function validateOptions(options) {\n if (options == null) {\n throw 'You must pass an options object';\n }\n if (options.cluster == null) {\n throw 'Options object must provide a cluster';\n }\n if ('disableStats' in options) {\n Logger.warn(\n 'The disableStats option is deprecated in favor of enableStats'\n );\n }\n}\n","export enum AuthRequestType {\n UserAuthentication = 'user-authentication',\n ChannelAuthorization = 'channel-authorization'\n}\n\nexport interface ChannelAuthorizationData {\n auth: string;\n channel_data?: string;\n shared_secret?: string;\n}\n\nexport type ChannelAuthorizationCallback = (\n error: Error | null,\n authData: ChannelAuthorizationData | null\n) => void;\n\nexport interface ChannelAuthorizationRequestParams {\n socketId: string;\n channelName: string;\n}\n\nexport interface ChannelAuthorizationHandler {\n (\n params: ChannelAuthorizationRequestParams,\n callback: ChannelAuthorizationCallback\n ): void;\n}\n\nexport interface UserAuthenticationData {\n auth: string;\n user_data: string;\n}\n\nexport type UserAuthenticationCallback = (\n error: Error | null,\n authData: UserAuthenticationData | null\n) => void;\n\nexport interface UserAuthenticationRequestParams {\n socketId: string;\n}\n\nexport interface UserAuthenticationHandler {\n (\n params: UserAuthenticationRequestParams,\n callback: UserAuthenticationCallback\n ): void;\n}\n\nexport type AuthTransportCallback =\n | ChannelAuthorizationCallback\n | UserAuthenticationCallback;\n\nexport interface AuthOptionsT {\n transport: 'ajax' | 'jsonp';\n endpoint: string;\n params?: any;\n headers?: any;\n paramsProvider?: () => any;\n headersProvider?: () => any;\n customHandler?: AuthHandler;\n}\n\nexport declare type UserAuthenticationOptions = AuthOptionsT<\n UserAuthenticationHandler\n>;\nexport declare type ChannelAuthorizationOptions = AuthOptionsT<\n ChannelAuthorizationHandler\n>;\n\nexport interface InternalAuthOptions {\n transport: 'ajax' | 'jsonp';\n endpoint: string;\n params?: any;\n headers?: any;\n paramsProvider?: () => any;\n headersProvider?: () => any;\n}\n","import {\n UserAuthenticationCallback,\n InternalAuthOptions,\n UserAuthenticationHandler,\n UserAuthenticationRequestParams,\n AuthRequestType\n} from './options';\n\nimport Runtime from 'runtime';\n\nconst composeChannelQuery = (\n params: UserAuthenticationRequestParams,\n authOptions: InternalAuthOptions\n) => {\n var query = 'socket_id=' + encodeURIComponent(params.socketId);\n\n for (var key in authOptions.params) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(authOptions.params[key]);\n }\n\n if (authOptions.paramsProvider != null) {\n let dynamicParams = authOptions.paramsProvider();\n for (var key in dynamicParams) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(dynamicParams[key]);\n }\n }\n\n return query;\n};\n\nconst UserAuthenticator = (\n authOptions: InternalAuthOptions\n): UserAuthenticationHandler => {\n if (typeof Runtime.getAuthorizers()[authOptions.transport] === 'undefined') {\n throw `'${authOptions.transport}' is not a recognized auth transport`;\n }\n\n return (\n params: UserAuthenticationRequestParams,\n callback: UserAuthenticationCallback\n ) => {\n const query = composeChannelQuery(params, authOptions);\n\n Runtime.getAuthorizers()[authOptions.transport](\n Runtime,\n query,\n authOptions,\n AuthRequestType.UserAuthentication,\n callback\n );\n };\n};\n\nexport default UserAuthenticator;\n","import {\n AuthRequestType,\n InternalAuthOptions,\n ChannelAuthorizationHandler,\n ChannelAuthorizationRequestParams,\n ChannelAuthorizationCallback\n} from './options';\n\nimport Runtime from 'runtime';\n\nconst composeChannelQuery = (\n params: ChannelAuthorizationRequestParams,\n authOptions: InternalAuthOptions\n) => {\n var query = 'socket_id=' + encodeURIComponent(params.socketId);\n\n query += '&channel_name=' + encodeURIComponent(params.channelName);\n\n for (var key in authOptions.params) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(authOptions.params[key]);\n }\n\n if (authOptions.paramsProvider != null) {\n let dynamicParams = authOptions.paramsProvider();\n for (var key in dynamicParams) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(dynamicParams[key]);\n }\n }\n\n return query;\n};\n\nconst ChannelAuthorizer = (\n authOptions: InternalAuthOptions\n): ChannelAuthorizationHandler => {\n if (typeof Runtime.getAuthorizers()[authOptions.transport] === 'undefined') {\n throw `'${authOptions.transport}' is not a recognized auth transport`;\n }\n\n return (\n params: ChannelAuthorizationRequestParams,\n callback: ChannelAuthorizationCallback\n ) => {\n const query = composeChannelQuery(params, authOptions);\n\n Runtime.getAuthorizers()[authOptions.transport](\n Runtime,\n query,\n authOptions,\n AuthRequestType.ChannelAuthorization,\n callback\n );\n };\n};\n\nexport default ChannelAuthorizer;\n","import Channel from '../channels/channel';\nimport {\n ChannelAuthorizationCallback,\n ChannelAuthorizationHandler,\n ChannelAuthorizationRequestParams,\n InternalAuthOptions\n} from './options';\n\nexport interface DeprecatedChannelAuthorizer {\n authorize(socketId: string, callback: ChannelAuthorizationCallback): void;\n}\n\nexport interface ChannelAuthorizerGenerator {\n (\n channel: Channel,\n options: DeprecatedAuthorizerOptions\n ): DeprecatedChannelAuthorizer;\n}\n\nexport interface DeprecatedAuthOptions {\n params?: any;\n headers?: any;\n}\n\nexport interface DeprecatedAuthorizerOptions {\n authTransport: 'ajax' | 'jsonp';\n authEndpoint: string;\n auth?: DeprecatedAuthOptions;\n}\n\nexport const ChannelAuthorizerProxy = (\n pusher,\n authOptions: InternalAuthOptions,\n channelAuthorizerGenerator: ChannelAuthorizerGenerator\n): ChannelAuthorizationHandler => {\n const deprecatedAuthorizerOptions: DeprecatedAuthorizerOptions = {\n authTransport: authOptions.transport,\n authEndpoint: authOptions.endpoint,\n auth: {\n params: authOptions.params,\n headers: authOptions.headers\n }\n };\n return (\n params: ChannelAuthorizationRequestParams,\n callback: ChannelAuthorizationCallback\n ) => {\n const channel = pusher.channel(params.channelName);\n // This line creates a new channel authorizer every time.\n // In the past, this was only done once per channel and reused.\n // We can do that again if we want to keep this behavior intact.\n const channelAuthorizer: DeprecatedChannelAuthorizer = channelAuthorizerGenerator(\n channel,\n deprecatedAuthorizerOptions\n );\n channelAuthorizer.authorize(params.socketId, callback);\n };\n};\n","import { Options } from './options';\nimport Defaults from './defaults';\nimport {\n ChannelAuthorizationHandler,\n UserAuthenticationHandler,\n ChannelAuthorizationOptions\n} from './auth/options';\nimport UserAuthenticator from './auth/user_authenticator';\nimport ChannelAuthorizer from './auth/channel_authorizer';\nimport { ChannelAuthorizerProxy } from './auth/deprecated_channel_authorizer';\nimport Runtime from 'runtime';\nimport * as nacl from 'tweetnacl';\n\nexport type AuthTransport = 'ajax' | 'jsonp';\nexport type Transport =\n | 'ws'\n | 'wss'\n | 'xhr_streaming'\n | 'xhr_polling'\n | 'sockjs';\n\nexport interface Config {\n // these are all 'required' config parameters, it's not necessary for the user\n // to set them, but they have configured defaults.\n activityTimeout: number;\n enableStats: boolean;\n httpHost: string;\n httpPath: string;\n httpPort: number;\n httpsPort: number;\n pongTimeout: number;\n statsHost: string;\n unavailableTimeout: number;\n useTLS: boolean;\n wsHost: string;\n wsPath: string;\n wsPort: number;\n wssPort: number;\n userAuthenticator: UserAuthenticationHandler;\n channelAuthorizer: ChannelAuthorizationHandler;\n\n // these are all optional parameters or overrrides. The customer can set these\n // but it's not strictly necessary\n forceTLS?: boolean;\n cluster?: string;\n disabledTransports?: Transport[];\n enabledTransports?: Transport[];\n ignoreNullOrigin?: boolean;\n nacl?: nacl;\n timelineParams?: any;\n}\n\n// getConfig mainly sets the defaults for the options that are not provided\nexport function getConfig(opts: Options, pusher): Config {\n let config: Config = {\n activityTimeout: opts.activityTimeout || Defaults.activityTimeout,\n cluster: opts.cluster,\n httpPath: opts.httpPath || Defaults.httpPath,\n httpPort: opts.httpPort || Defaults.httpPort,\n httpsPort: opts.httpsPort || Defaults.httpsPort,\n pongTimeout: opts.pongTimeout || Defaults.pongTimeout,\n statsHost: opts.statsHost || Defaults.stats_host,\n unavailableTimeout: opts.unavailableTimeout || Defaults.unavailableTimeout,\n wsPath: opts.wsPath || Defaults.wsPath,\n wsPort: opts.wsPort || Defaults.wsPort,\n wssPort: opts.wssPort || Defaults.wssPort,\n\n enableStats: getEnableStatsConfig(opts),\n httpHost: getHttpHost(opts),\n useTLS: shouldUseTLS(opts),\n wsHost: getWebsocketHost(opts),\n\n userAuthenticator: buildUserAuthenticator(opts),\n channelAuthorizer: buildChannelAuthorizer(opts, pusher)\n };\n\n if ('disabledTransports' in opts)\n config.disabledTransports = opts.disabledTransports;\n if ('enabledTransports' in opts)\n config.enabledTransports = opts.enabledTransports;\n if ('ignoreNullOrigin' in opts)\n config.ignoreNullOrigin = opts.ignoreNullOrigin;\n if ('timelineParams' in opts) config.timelineParams = opts.timelineParams;\n if ('nacl' in opts) {\n config.nacl = opts.nacl;\n }\n\n return config;\n}\n\nfunction getHttpHost(opts: Options): string {\n if (opts.httpHost) {\n return opts.httpHost;\n }\n if (opts.cluster) {\n return `sockjs-${opts.cluster}.pusher.com`;\n }\n return Defaults.httpHost;\n}\n\nfunction getWebsocketHost(opts: Options): string {\n if (opts.wsHost) {\n return opts.wsHost;\n }\n return getWebsocketHostFromCluster(opts.cluster);\n}\n\nfunction getWebsocketHostFromCluster(cluster: string): string {\n return `ws-${cluster}.pusher.com`;\n}\n\nfunction shouldUseTLS(opts: Options): boolean {\n if (Runtime.getProtocol() === 'https:') {\n return true;\n } else if (opts.forceTLS === false) {\n return false;\n }\n return true;\n}\n\n// if enableStats is set take the value\n// if disableStats is set take the inverse\n// otherwise default to false\nfunction getEnableStatsConfig(opts: Options): boolean {\n if ('enableStats' in opts) {\n return opts.enableStats;\n }\n if ('disableStats' in opts) {\n return !opts.disableStats;\n }\n return false;\n}\n\nfunction buildUserAuthenticator(opts: Options): UserAuthenticationHandler {\n const userAuthentication = {\n ...Defaults.userAuthentication,\n ...opts.userAuthentication\n };\n if (\n 'customHandler' in userAuthentication &&\n userAuthentication['customHandler'] != null\n ) {\n return userAuthentication['customHandler'];\n }\n\n return UserAuthenticator(userAuthentication);\n}\n\nfunction buildChannelAuth(opts: Options, pusher): ChannelAuthorizationOptions {\n let channelAuthorization: ChannelAuthorizationOptions;\n if ('channelAuthorization' in opts) {\n channelAuthorization = {\n ...Defaults.channelAuthorization,\n ...opts.channelAuthorization\n };\n } else {\n channelAuthorization = {\n transport: opts.authTransport || Defaults.authTransport,\n endpoint: opts.authEndpoint || Defaults.authEndpoint\n };\n if ('auth' in opts) {\n if ('params' in opts.auth) channelAuthorization.params = opts.auth.params;\n if ('headers' in opts.auth)\n channelAuthorization.headers = opts.auth.headers;\n }\n if ('authorizer' in opts)\n channelAuthorization.customHandler = ChannelAuthorizerProxy(\n pusher,\n channelAuthorization,\n opts.authorizer\n );\n }\n return channelAuthorization;\n}\n\nfunction buildChannelAuthorizer(\n opts: Options,\n pusher\n): ChannelAuthorizationHandler {\n const channelAuthorization = buildChannelAuth(opts, pusher);\n if (\n 'customHandler' in channelAuthorization &&\n channelAuthorization['customHandler'] != null\n ) {\n return channelAuthorization['customHandler'];\n }\n\n return ChannelAuthorizer(channelAuthorization);\n}\n","import Logger from './logger';\nimport Pusher from './pusher';\nimport EventsDispatcher from './events/dispatcher';\n\nexport default class WatchlistFacade extends EventsDispatcher {\n private pusher: Pusher;\n\n public constructor(pusher: Pusher) {\n super(function(eventName, data) {\n Logger.debug(`No callbacks on watchlist events for ${eventName}`);\n });\n\n this.pusher = pusher;\n this.bindWatchlistInternalEvent();\n }\n\n handleEvent(pusherEvent) {\n pusherEvent.data.events.forEach(watchlistEvent => {\n this.emit(watchlistEvent.name, watchlistEvent);\n });\n }\n\n private bindWatchlistInternalEvent() {\n this.pusher.connection.bind('message', pusherEvent => {\n var eventName = pusherEvent.event;\n if (eventName === 'pusher_internal:watchlist_events') {\n this.handleEvent(pusherEvent);\n }\n });\n }\n}\n","function flatPromise() {\n let resolve, reject;\n const promise = new Promise((res, rej) => {\n resolve = res;\n reject = rej;\n });\n return { promise, resolve, reject };\n}\n\nexport default flatPromise;\n","import Pusher from './pusher';\nimport Logger from './logger';\nimport {\n UserAuthenticationData,\n UserAuthenticationCallback\n} from './auth/options';\nimport Channel from './channels/channel';\nimport WatchlistFacade from './watchlist';\nimport EventsDispatcher from './events/dispatcher';\nimport flatPromise from './utils/flat_promise';\n\nexport default class UserFacade extends EventsDispatcher {\n pusher: Pusher;\n signin_requested: boolean = false;\n user_data: any = null;\n serverToUserChannel: Channel = null;\n signinDonePromise: Promise = null;\n watchlist: WatchlistFacade;\n private _signinDoneResolve: Function = null;\n\n public constructor(pusher: Pusher) {\n super(function(eventName, data) {\n Logger.debug('No callbacks on user for ' + eventName);\n });\n this.pusher = pusher;\n this.pusher.connection.bind('state_change', ({ previous, current }) => {\n if (previous !== 'connected' && current === 'connected') {\n this._signin();\n }\n if (previous === 'connected' && current !== 'connected') {\n this._cleanup();\n this._newSigninPromiseIfNeeded();\n }\n });\n\n this.watchlist = new WatchlistFacade(pusher);\n\n this.pusher.connection.bind('message', event => {\n var eventName = event.event;\n if (eventName === 'pusher:signin_success') {\n this._onSigninSuccess(event.data);\n }\n if (\n this.serverToUserChannel &&\n this.serverToUserChannel.name === event.channel\n ) {\n this.serverToUserChannel.handleEvent(event);\n }\n });\n }\n\n public signin() {\n if (this.signin_requested) {\n return;\n }\n\n this.signin_requested = true;\n this._signin();\n }\n\n private _signin() {\n if (!this.signin_requested) {\n return;\n }\n\n this._newSigninPromiseIfNeeded();\n\n if (this.pusher.connection.state !== 'connected') {\n // Signin will be attempted when the connection is connected\n return;\n }\n\n this.pusher.config.userAuthenticator(\n {\n socketId: this.pusher.connection.socket_id\n },\n this._onAuthorize\n );\n }\n\n private _onAuthorize: UserAuthenticationCallback = (\n err,\n authData: UserAuthenticationData\n ) => {\n if (err) {\n Logger.warn(`Error during signin: ${err}`);\n this._cleanup();\n return;\n }\n\n this.pusher.send_event('pusher:signin', {\n auth: authData.auth,\n user_data: authData.user_data\n });\n\n // Later when we get pusher:singin_success event, the user will be marked as signed in\n };\n\n private _onSigninSuccess(data: any) {\n try {\n this.user_data = JSON.parse(data.user_data);\n } catch (e) {\n Logger.error(`Failed parsing user data after signin: ${data.user_data}`);\n this._cleanup();\n return;\n }\n\n if (typeof this.user_data.id !== 'string' || this.user_data.id === '') {\n Logger.error(\n `user_data doesn't contain an id. user_data: ${this.user_data}`\n );\n this._cleanup();\n return;\n }\n\n // Signin succeeded\n this._signinDoneResolve();\n this._subscribeChannels();\n }\n\n private _subscribeChannels() {\n const ensure_subscribed = channel => {\n if (channel.subscriptionPending && channel.subscriptionCancelled) {\n channel.reinstateSubscription();\n } else if (\n !channel.subscriptionPending &&\n this.pusher.connection.state === 'connected'\n ) {\n channel.subscribe();\n }\n };\n\n this.serverToUserChannel = new Channel(\n `#server-to-user-${this.user_data.id}`,\n this.pusher\n );\n this.serverToUserChannel.bind_global((eventName, data) => {\n if (\n eventName.indexOf('pusher_internal:') === 0 ||\n eventName.indexOf('pusher:') === 0\n ) {\n // ignore internal events\n return;\n }\n this.emit(eventName, data);\n });\n ensure_subscribed(this.serverToUserChannel);\n }\n\n private _cleanup() {\n this.user_data = null;\n if (this.serverToUserChannel) {\n this.serverToUserChannel.unbind_all();\n this.serverToUserChannel.disconnect();\n this.serverToUserChannel = null;\n }\n\n if (this.signin_requested) {\n // If signin is in progress and cleanup is called,\n // Mark the current signin process as done.\n this._signinDoneResolve();\n }\n }\n\n private _newSigninPromiseIfNeeded() {\n if (!this.signin_requested) {\n return;\n }\n\n // If there is a promise and it is not resolved, return without creating a new one.\n if (this.signinDonePromise && !(this.signinDonePromise as any).done) {\n return;\n }\n\n // This promise is never rejected.\n // It gets resolved when the signin process is done whether it failed or succeeded\n const { promise, resolve, reject: _ } = flatPromise();\n (promise as any).done = false;\n const setDone = () => {\n (promise as any).done = true;\n };\n promise.then(setDone).catch(setDone);\n this.signinDonePromise = promise;\n this._signinDoneResolve = resolve;\n }\n}\n","import AbstractRuntime from '../runtimes/interface';\nimport Runtime from 'runtime';\nimport * as Collections from './utils/collections';\nimport Channels from './channels/channels';\nimport Channel from './channels/channel';\nimport { default as EventsDispatcher } from './events/dispatcher';\nimport Timeline from './timeline/timeline';\nimport TimelineSender from './timeline/timeline_sender';\nimport TimelineLevel from './timeline/level';\nimport { defineTransport } from './strategies/strategy_builder';\nimport ConnectionManager from './connection/connection_manager';\nimport { PeriodicTimer } from './utils/timers';\nimport Defaults from './defaults';\nimport Logger from './logger';\nimport Factory from './utils/factory';\nimport { Options, ClusterOptions, validateOptions } from './options';\nimport { Config, getConfig } from './config';\nimport StrategyOptions from './strategies/strategy_options';\nimport UserFacade from './user';\n\nexport default class Pusher {\n /* STATIC PROPERTIES */\n static instances: Pusher[] = [];\n static isReady: boolean = false;\n static logToConsole: boolean = false;\n\n // for jsonp\n static Runtime: AbstractRuntime = Runtime;\n static ScriptReceivers: any = (Runtime).ScriptReceivers;\n static DependenciesReceivers: any = (Runtime).DependenciesReceivers;\n static auth_callbacks: any = (Runtime).auth_callbacks;\n\n static ready() {\n Pusher.isReady = true;\n for (var i = 0, l = Pusher.instances.length; i < l; i++) {\n Pusher.instances[i].connect();\n }\n }\n\n static log: (message: any) => void;\n\n private static getClientFeatures(): string[] {\n return Collections.keys(\n Collections.filterObject({ ws: Runtime.Transports.ws }, function(t) {\n return t.isSupported({});\n })\n );\n }\n\n /* INSTANCE PROPERTIES */\n key: string;\n options: Options;\n config: Config;\n channels: Channels;\n global_emitter: EventsDispatcher;\n sessionID: number;\n timeline: Timeline;\n timelineSender: TimelineSender;\n connection: ConnectionManager;\n timelineSenderTimer: PeriodicTimer;\n user: UserFacade;\n constructor(app_key: string, options: Options) {\n checkAppKey(app_key);\n validateOptions(options);\n this.key = app_key;\n this.config = getConfig(options, this);\n\n this.channels = Factory.createChannels();\n this.global_emitter = new EventsDispatcher();\n this.sessionID = Runtime.randomInt(1000000000);\n\n this.timeline = new Timeline(this.key, this.sessionID, {\n cluster: this.config.cluster,\n features: Pusher.getClientFeatures(),\n params: this.config.timelineParams || {},\n limit: 50,\n level: TimelineLevel.INFO,\n version: Defaults.VERSION\n });\n if (this.config.enableStats) {\n this.timelineSender = Factory.createTimelineSender(this.timeline, {\n host: this.config.statsHost,\n path: '/timeline/v2/' + Runtime.TimelineTransport.name\n });\n }\n\n var getStrategy = (options: StrategyOptions) => {\n return Runtime.getDefaultStrategy(this.config, options, defineTransport);\n };\n\n this.connection = Factory.createConnectionManager(this.key, {\n getStrategy: getStrategy,\n timeline: this.timeline,\n activityTimeout: this.config.activityTimeout,\n pongTimeout: this.config.pongTimeout,\n unavailableTimeout: this.config.unavailableTimeout,\n useTLS: Boolean(this.config.useTLS)\n });\n\n this.connection.bind('connected', () => {\n this.subscribeAll();\n if (this.timelineSender) {\n this.timelineSender.send(this.connection.isUsingTLS());\n }\n });\n\n this.connection.bind('message', event => {\n var eventName = event.event;\n var internal = eventName.indexOf('pusher_internal:') === 0;\n if (event.channel) {\n var channel = this.channel(event.channel);\n if (channel) {\n channel.handleEvent(event);\n }\n }\n // Emit globally [deprecated]\n if (!internal) {\n this.global_emitter.emit(event.event, event.data);\n }\n });\n this.connection.bind('connecting', () => {\n this.channels.disconnect();\n });\n this.connection.bind('disconnected', () => {\n this.channels.disconnect();\n });\n this.connection.bind('error', err => {\n Logger.warn(err);\n });\n\n Pusher.instances.push(this);\n this.timeline.info({ instances: Pusher.instances.length });\n\n this.user = new UserFacade(this);\n\n if (Pusher.isReady) {\n this.connect();\n }\n }\n\n /**\n * Allows you to switch Pusher cluster without\n * losing all the channels/subscription binding\n * as this is internally managed by the SDK.\n */\n switchCluster(options: ClusterOptions) {\n const { appKey, cluster } = options;\n this.key = appKey;\n this.options = { ...this.options, cluster };\n this.config = getConfig(this.options, this);\n this.connection.switchCluster(this.key);\n }\n\n channel(name: string): Channel {\n return this.channels.find(name);\n }\n\n allChannels(): Channel[] {\n return this.channels.all();\n }\n\n connect() {\n this.connection.connect();\n\n if (this.timelineSender) {\n if (!this.timelineSenderTimer) {\n var usingTLS = this.connection.isUsingTLS();\n var timelineSender = this.timelineSender;\n this.timelineSenderTimer = new PeriodicTimer(60000, function() {\n timelineSender.send(usingTLS);\n });\n }\n }\n }\n\n disconnect() {\n this.connection.disconnect();\n\n if (this.timelineSenderTimer) {\n this.timelineSenderTimer.ensureAborted();\n this.timelineSenderTimer = null;\n }\n }\n\n bind(event_name: string, callback: Function, context?: any): Pusher {\n this.global_emitter.bind(event_name, callback, context);\n return this;\n }\n\n unbind(event_name?: string, callback?: Function, context?: any): Pusher {\n this.global_emitter.unbind(event_name, callback, context);\n return this;\n }\n\n bind_global(callback: Function): Pusher {\n this.global_emitter.bind_global(callback);\n return this;\n }\n\n unbind_global(callback?: Function): Pusher {\n this.global_emitter.unbind_global(callback);\n return this;\n }\n\n unbind_all(callback?: Function): Pusher {\n this.global_emitter.unbind_all();\n return this;\n }\n\n subscribeAll() {\n var channelName;\n for (channelName in this.channels.channels) {\n if (this.channels.channels.hasOwnProperty(channelName)) {\n this.subscribe(channelName);\n }\n }\n }\n\n subscribe(channel_name: string) {\n var channel = this.channels.add(channel_name, this);\n if (channel.subscriptionPending && channel.subscriptionCancelled) {\n channel.reinstateSubscription();\n } else if (\n !channel.subscriptionPending &&\n this.connection.state === 'connected'\n ) {\n channel.subscribe();\n }\n return channel;\n }\n\n unsubscribe(channel_name: string) {\n var channel = this.channels.find(channel_name);\n if (channel && channel.subscriptionPending) {\n channel.cancelSubscription();\n } else {\n channel = this.channels.remove(channel_name);\n if (channel && channel.subscribed) {\n channel.unsubscribe();\n }\n }\n }\n\n send_event(event_name: string, data: any, channel?: string) {\n return this.connection.send_event(event_name, data, channel);\n }\n\n shouldUseTLS(): boolean {\n return this.config.useTLS;\n }\n\n signin() {\n this.user.signin();\n }\n}\n\nfunction checkAppKey(key) {\n if (key === null || key === undefined) {\n throw 'You must pass your app key when you instantiate Pusher.';\n }\n}\n\nRuntime.setup(Pusher);\n"],"sourceRoot":""} \ No newline at end of file diff --git a/dist/worker/pusher.worker.min.js b/dist/worker/pusher.worker.min.js index 192d42c06..3093a9f8d 100644 --- a/dist/worker/pusher.worker.min.js +++ b/dist/worker/pusher.worker.min.js @@ -1,9 +1,9 @@ /*! - * Pusher JavaScript Library v8.4.0 + * Pusher JavaScript Library v8.4.0-rc1 * https://pusher.com/ * * Copyright 2020, Pusher * Released under the MIT licence. */ -!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.Pusher=e():t.Pusher=e()}(this,(function(){return function(t){var e={};function n(i){if(e[i])return e[i].exports;var s=e[i]={i:i,l:!1,exports:{}};return t[i].call(s.exports,s,s.exports,n),s.l=!0,s.exports}return n.m=t,n.c=e,n.d=function(t,e,i){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:i})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var i=Object.create(null);if(n.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var s in t)n.d(i,s,function(e){return t[e]}.bind(null,s));return i},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=2)}([function(t,e,n){"use strict";var i,s=this&&this.__extends||(i=function(t,e){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)},function(t,e){function n(){this.constructor=t}i(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)});Object.defineProperty(e,"__esModule",{value:!0});var r=function(){function t(t){void 0===t&&(t="="),this._paddingCharacter=t}return t.prototype.encodedLength=function(t){return this._paddingCharacter?(t+2)/3*4|0:(8*t+5)/6|0},t.prototype.encode=function(t){for(var e="",n=0;n>>18&63),e+=this._encodeByte(i>>>12&63),e+=this._encodeByte(i>>>6&63),e+=this._encodeByte(i>>>0&63)}var s=t.length-n;if(s>0){i=t[n]<<16|(2===s?t[n+1]<<8:0);e+=this._encodeByte(i>>>18&63),e+=this._encodeByte(i>>>12&63),e+=2===s?this._encodeByte(i>>>6&63):this._paddingCharacter||"",e+=this._paddingCharacter||""}return e},t.prototype.maxDecodedLength=function(t){return this._paddingCharacter?t/4*3|0:(6*t+7)/8|0},t.prototype.decodedLength=function(t){return this.maxDecodedLength(t.length-this._getPaddingLength(t))},t.prototype.decode=function(t){if(0===t.length)return new Uint8Array(0);for(var e=this._getPaddingLength(t),n=t.length-e,i=new Uint8Array(this.maxDecodedLength(n)),s=0,r=0,o=0,a=0,c=0,h=0,u=0;r>>4,i[s++]=c<<4|h>>>2,i[s++]=h<<6|u,o|=256&a,o|=256&c,o|=256&h,o|=256&u;if(r>>4,o|=256&a,o|=256&c),r>>2,o|=256&h),r>>8&6,e+=51-t>>>8&-75,e+=61-t>>>8&-15,e+=62-t>>>8&3,String.fromCharCode(e)},t.prototype._decodeChar=function(t){var e=256;return e+=(42-t&t-44)>>>8&-256+t-43+62,e+=(46-t&t-48)>>>8&-256+t-47+63,e+=(47-t&t-58)>>>8&-256+t-48+52,e+=(64-t&t-91)>>>8&-256+t-65+0,e+=(96-t&t-123)>>>8&-256+t-97+26},t.prototype._getPaddingLength=function(t){var e=0;if(this._paddingCharacter){for(var n=t.length-1;n>=0&&t[n]===this._paddingCharacter;n--)e++;if(t.length<4||e>2)throw new Error("Base64Coder: incorrect padding")}return e},t}();e.Coder=r;var o=new r;e.encode=function(t){return o.encode(t)},e.decode=function(t){return o.decode(t)};var a=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return s(e,t),e.prototype._encodeByte=function(t){var e=t;return e+=65,e+=25-t>>>8&6,e+=51-t>>>8&-75,e+=61-t>>>8&-13,e+=62-t>>>8&49,String.fromCharCode(e)},e.prototype._decodeChar=function(t){var e=256;return e+=(44-t&t-46)>>>8&-256+t-45+62,e+=(94-t&t-96)>>>8&-256+t-95+63,e+=(47-t&t-58)>>>8&-256+t-48+52,e+=(64-t&t-91)>>>8&-256+t-65+0,e+=(96-t&t-123)>>>8&-256+t-97+26},e}(r);e.URLSafeCoder=a;var c=new a;e.encodeURLSafe=function(t){return c.encode(t)},e.decodeURLSafe=function(t){return c.decode(t)},e.encodedLength=function(t){return o.encodedLength(t)},e.maxDecodedLength=function(t){return o.maxDecodedLength(t)},e.decodedLength=function(t){return o.decodedLength(t)}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i="utf8: invalid source encoding";function s(t){for(var e=0,n=0;n=t.length-1)throw new Error("utf8: invalid string");n++,e+=4}}return e}e.encode=function(t){for(var e=new Uint8Array(s(t)),n=0,i=0;i>6,e[n++]=128|63&r):r<55296?(e[n++]=224|r>>12,e[n++]=128|r>>6&63,e[n++]=128|63&r):(i++,r=(1023&r)<<10,r|=1023&t.charCodeAt(i),r+=65536,e[n++]=240|r>>18,e[n++]=128|r>>12&63,e[n++]=128|r>>6&63,e[n++]=128|63&r)}return e},e.encodedLength=s,e.decode=function(t){for(var e=[],n=0;n=t.length)throw new Error(i);if(128!=(192&(o=t[++n])))throw new Error(i);s=(31&s)<<6|63&o,r=128}else if(s<240){if(n>=t.length-1)throw new Error(i);var o=t[++n],a=t[++n];if(128!=(192&o)||128!=(192&a))throw new Error(i);s=(15&s)<<12|(63&o)<<6|63&a,r=2048}else{if(!(s<248))throw new Error(i);if(n>=t.length-2)throw new Error(i);o=t[++n],a=t[++n];var c=t[++n];if(128!=(192&o)||128!=(192&a)||128!=(192&c))throw new Error(i);s=(15&s)<<18|(63&o)<<12|(63&a)<<6|63&c,r=65536}if(s=55296&&s<=57343)throw new Error(i);if(s>=65536){if(s>1114111)throw new Error(i);s-=65536,e.push(String.fromCharCode(55296|s>>10)),s=56320|1023&s}}e.push(String.fromCharCode(s))}return e.join("")}},function(t,e,n){t.exports=n(3).default},function(t,e,n){"use strict";n.r(e);for(var i=String.fromCharCode,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",r={},o=0,a=s.length;o>>6)+i(128|63&e):i(224|e>>>12&15)+i(128|e>>>6&63)+i(128|63&e)},h=function(t){return t.replace(/[^\x00-\x7F]/g,c)},u=function(t){var e=[0,2,1][t.length%3],n=t.charCodeAt(0)<<16|(t.length>1?t.charCodeAt(1):0)<<8|(t.length>2?t.charCodeAt(2):0);return[s.charAt(n>>>18),s.charAt(n>>>12&63),e>=2?"=":s.charAt(n>>>6&63),e>=1?"=":s.charAt(63&n)].join("")},l=self.btoa||function(t){return t.replace(/[\s\S]{1,3}/g,u)};var d=class{constructor(t,e,n,i){this.clear=e,this.timer=t(()=>{this.timer&&(this.timer=i(this.timer))},n)}isRunning(){return null!==this.timer}ensureAborted(){this.timer&&(this.clear(this.timer),this.timer=null)}};function p(t){self.clearTimeout(t)}function f(t){self.clearInterval(t)}class g extends d{constructor(t,e){super(setTimeout,p,t,(function(t){return e(),null}))}}class b extends d{constructor(t,e){super(setInterval,f,t,(function(t){return e(),t}))}}var m={now:()=>Date.now?Date.now():(new Date).valueOf(),defer:t=>new g(0,t),method(t,...e){var n=Array.prototype.slice.call(arguments,1);return function(e){return e[t].apply(e,n.concat(arguments))}}};function v(t,...e){for(var n=0;ne!==t),this):(this.global_callbacks=[],this)}unbind_all(){return this.unbind(),this.unbind_global(),this}emit(t,e,n){for(var i=0;i0)for(i=0;i{self.console&&self.console.log&&self.console.log(t)}}debug(...t){this.log(this.globalLog,t)}warn(...t){this.log(this.globalLogWarn,t)}error(...t){this.log(this.globalLogError,t)}globalLogWarn(t){self.console&&self.console.warn?self.console.warn(t):this.globalLog(t)}globalLogError(t){self.console&&self.console.error?self.console.error(t):this.globalLogWarn(t)}log(t,...e){var n=y.apply(this,arguments);if(xe.log)xe.log(n);else if(xe.logToConsole){t.bind(this)(n)}}};class z extends H{constructor(t,e,n,i,s){super(),this.initialize=ae.transportConnectionInitializer,this.hooks=t,this.name=e,this.priority=n,this.key=i,this.options=s,this.state="new",this.timeline=s.timeline,this.activityTimeout=s.activityTimeout,this.id=this.timeline.generateUniqueID()}handlesActivityChecks(){return Boolean(this.hooks.handlesActivityChecks)}supportsPing(){return Boolean(this.hooks.supportsPing)}connect(){if(this.socket||"initialized"!==this.state)return!1;var t=this.hooks.urls.getInitial(this.key,this.options);try{this.socket=this.hooks.getSocket(t,this.options)}catch(t){return m.defer(()=>{this.onError(t),this.changeState("closed")}),!1}return this.bindListeners(),M.debug("Connecting",{transport:this.name,url:t}),this.changeState("connecting"),!0}close(){return!!this.socket&&(this.socket.close(),!0)}send(t){return"open"===this.state&&(m.defer(()=>{this.socket&&this.socket.send(t)}),!0)}ping(){"open"===this.state&&this.supportsPing()&&this.socket.ping()}onOpen(){this.hooks.beforeOpen&&this.hooks.beforeOpen(this.socket,this.hooks.urls.getPath(this.key,this.options)),this.changeState("open"),this.socket.onopen=void 0}onError(t){this.emit("error",{type:"WebSocketError",error:t}),this.timeline.error(this.buildTimelineMessage({error:t.toString()}))}onClose(t){t?this.changeState("closed",{code:t.code,reason:t.reason,wasClean:t.wasClean}):this.changeState("closed"),this.unbindListeners(),this.socket=void 0}onMessage(t){this.emit("message",t)}onActivity(){this.emit("activity")}bindListeners(){this.socket.onopen=()=>{this.onOpen()},this.socket.onerror=t=>{this.onError(t)},this.socket.onclose=t=>{this.onClose(t)},this.socket.onmessage=t=>{this.onMessage(t)},this.supportsPing()&&(this.socket.onactivity=()=>{this.onActivity()})}unbindListeners(){this.socket&&(this.socket.onopen=void 0,this.socket.onerror=void 0,this.socket.onclose=void 0,this.socket.onmessage=void 0,this.supportsPing()&&(this.socket.onactivity=void 0))}changeState(t,e){this.state=t,this.timeline.info(this.buildTimelineMessage({state:t,params:e})),this.emit(t,e)}buildTimelineMessage(t){return v({cid:this.id},t)}}class B{constructor(t){this.hooks=t}isSupported(t){return this.hooks.isSupported(t)}createConnection(t,e,n,i){return new z(this.hooks,t,e,n,i)}}var q=new B({urls:j,handlesActivityChecks:!1,supportsPing:!1,isInitialized:function(){return Boolean(ae.getWebSocketAPI())},isSupported:function(){return Boolean(ae.getWebSocketAPI())},getSocket:function(t){return ae.createWebSocket(t)}}),F={urls:D,handlesActivityChecks:!1,supportsPing:!0,isInitialized:function(){return!0}},$=v({getSocket:function(t){return ae.HTTPFactory.createStreamingSocket(t)}},F),J=v({getSocket:function(t){return ae.HTTPFactory.createPollingSocket(t)}},F),W={isSupported:function(){return ae.isXHRSupported()}},X={ws:q,xhr_streaming:new B(v({},$,W)),xhr_polling:new B(v({},J,W))};class G{constructor(t,e,n){this.manager=t,this.transport=e,this.minPingDelay=n.minPingDelay,this.maxPingDelay=n.maxPingDelay,this.pingDelay=void 0}createConnection(t,e,n,i){i=v({},i,{activityTimeout:this.pingDelay});var s=this.transport.createConnection(t,e,n,i),r=null,o=function(){s.unbind("open",o),s.bind("closed",a),r=m.now()},a=t=>{if(s.unbind("closed",a),1002===t.code||1003===t.code)this.manager.reportDeath();else if(!t.wasClean&&r){var e=m.now()-r;e<2*this.maxPingDelay&&(this.manager.reportDeath(),this.pingDelay=Math.max(e/2,this.minPingDelay))}};return s.bind("open",o),s}isSupported(t){return this.manager.isAlive()&&this.transport.isSupported(t)}}const V={decodeMessage:function(t){try{var e=JSON.parse(t.data),n=e.data;if("string"==typeof n)try{n=JSON.parse(e.data)}catch(t){}var i={event:e.event,channel:e.channel,data:n};return e.user_id&&(i.user_id=e.user_id),i}catch(e){throw{type:"MessageParseError",error:e,data:t.data}}},encodeMessage:function(t){return JSON.stringify(t)},processHandshake:function(t){var e=V.decodeMessage(t);if("pusher:connection_established"===e.event){if(!e.data.activity_timeout)throw"No activity timeout specified in handshake";return{action:"connected",id:e.data.socket_id,activityTimeout:1e3*e.data.activity_timeout}}if("pusher:error"===e.event)return{action:this.getCloseAction(e.data),error:this.getCloseError(e.data)};throw"Invalid handshake"},getCloseAction:function(t){return t.code<4e3?t.code>=1002&&t.code<=1004?"backoff":null:4e3===t.code?"tls_only":t.code<4100?"refused":t.code<4200?"backoff":t.code<4300?"retry":"refused"},getCloseError:function(t){return 1e3!==t.code&&1001!==t.code?{type:"PusherError",data:{code:t.code,message:t.reason||t.message}}:null}};var Y=V;class K extends H{constructor(t,e){super(),this.id=t,this.transport=e,this.activityTimeout=e.activityTimeout,this.bindListeners()}handlesActivityChecks(){return this.transport.handlesActivityChecks()}send(t){return this.transport.send(t)}send_event(t,e,n){var i={event:t,data:e};return n&&(i.channel=n),M.debug("Event sent",i),this.send(Y.encodeMessage(i))}ping(){this.transport.supportsPing()?this.transport.ping():this.send_event("pusher:ping",{})}close(){this.transport.close()}bindListeners(){var t={message:t=>{var e;try{e=Y.decodeMessage(t)}catch(e){this.emit("error",{type:"MessageParseError",error:e,data:t.data})}if(void 0!==e){switch(M.debug("Event recd",e),e.event){case"pusher:error":this.emit("error",{type:"PusherError",data:e.data});break;case"pusher:ping":this.emit("ping");break;case"pusher:pong":this.emit("pong")}this.emit("message",e)}},activity:()=>{this.emit("activity")},error:t=>{this.emit("error",t)},closed:t=>{e(),t&&t.code&&this.handleCloseEvent(t),this.transport=null,this.emit("closed")}},e=()=>{_(t,(t,e)=>{this.transport.unbind(e,t)})};_(t,(t,e)=>{this.transport.bind(e,t)})}handleCloseEvent(t){var e=Y.getCloseAction(t),n=Y.getCloseError(t);n&&this.emit("error",n),e&&this.emit(e,{action:e,error:n})}}class Q{constructor(t,e){this.transport=t,this.callback=e,this.bindListeners()}close(){this.unbindListeners(),this.transport.close()}bindListeners(){this.onMessage=t=>{var e;this.unbindListeners();try{e=Y.processHandshake(t)}catch(t){return this.finish("error",{error:t}),void this.transport.close()}"connected"===e.action?this.finish("connected",{connection:new K(e.id,this.transport),activityTimeout:e.activityTimeout}):(this.finish(e.action,{error:e.error}),this.transport.close())},this.onClosed=t=>{this.unbindListeners();var e=Y.getCloseAction(t)||"backoff",n=Y.getCloseError(t);this.finish(e,{error:n})},this.transport.bind("message",this.onMessage),this.transport.bind("closed",this.onClosed)}unbindListeners(){this.transport.unbind("message",this.onMessage),this.transport.unbind("closed",this.onClosed)}finish(t,e){this.callback(v({transport:this.transport,action:t},e))}}class Z{constructor(t,e){this.timeline=t,this.options=e||{}}send(t,e){this.timeline.isEmpty()||this.timeline.send(ae.TimelineTransport.getAgent(this,t),e)}}class tt extends Error{constructor(t){super(t),Object.setPrototypeOf(this,new.target.prototype)}}class et extends Error{constructor(t){super(t),Object.setPrototypeOf(this,new.target.prototype)}}Error;class nt extends Error{constructor(t){super(t),Object.setPrototypeOf(this,new.target.prototype)}}class it extends Error{constructor(t){super(t),Object.setPrototypeOf(this,new.target.prototype)}}class st extends Error{constructor(t){super(t),Object.setPrototypeOf(this,new.target.prototype)}}class rt extends Error{constructor(t){super(t),Object.setPrototypeOf(this,new.target.prototype)}}class ot extends Error{constructor(t){super(t),Object.setPrototypeOf(this,new.target.prototype)}}class at extends Error{constructor(t,e){super(e),this.status=t,Object.setPrototypeOf(this,new.target.prototype)}}const ct={baseUrl:"https://pusher.com",urls:{authenticationEndpoint:{path:"/docs/channels/server_api/authenticating_users"},authorizationEndpoint:{path:"/docs/channels/server_api/authorizing-users/"},javascriptQuickStart:{path:"/docs/javascript_quick_start"},triggeringClientEvents:{path:"/docs/client_api_guide/client_events#trigger-events"},encryptedChannelSupport:{fullUrl:"https://github.com/pusher/pusher-js/tree/cc491015371a4bde5743d1c87a0fbac0feb53195#encrypted-channel-support"}}};var ht=function(t){const e=ct.urls[t];if(!e)return"";let n;return e.fullUrl?n=e.fullUrl:e.path&&(n=ct.baseUrl+e.path),n?"See: "+n:""};class ut extends H{constructor(t,e){super((function(e,n){M.debug("No callbacks on "+t+" for "+e)})),this.name=t,this.pusher=e,this.subscribed=!1,this.subscriptionPending=!1,this.subscriptionCancelled=!1}authorize(t,e){return e(null,{auth:""})}trigger(t,e){if(0!==t.indexOf("client-"))throw new tt("Event '"+t+"' does not start with 'client-'");if(!this.subscribed){var n=ht("triggeringClientEvents");M.warn("Client event triggered before channel 'subscription_succeeded' event . "+n)}return this.pusher.send_event(t,e,this.name)}disconnect(){this.subscribed=!1,this.subscriptionPending=!1}handleEvent(t){var e=t.event,n=t.data;if("pusher_internal:subscription_succeeded"===e)this.handleSubscriptionSucceededEvent(t);else if("pusher_internal:subscription_count"===e)this.handleSubscriptionCountEvent(t);else if(0!==e.indexOf("pusher_internal:")){this.emit(e,n,{})}}handleSubscriptionSucceededEvent(t){this.subscriptionPending=!1,this.subscribed=!0,this.subscriptionCancelled?this.pusher.unsubscribe(this.name):this.emit("pusher:subscription_succeeded",t.data)}handleSubscriptionCountEvent(t){t.data.subscription_count&&(this.subscriptionCount=t.data.subscription_count),this.emit("pusher:subscription_count",t.data)}subscribe(){this.subscribed||(this.subscriptionPending=!0,this.subscriptionCancelled=!1,this.authorize(this.pusher.connection.socket_id,(t,e)=>{t?(this.subscriptionPending=!1,M.error(t.toString()),this.emit("pusher:subscription_error",Object.assign({},{type:"AuthError",error:t.message},t instanceof at?{status:t.status}:{}))):this.pusher.send_event("pusher:subscribe",{auth:e.auth,channel_data:e.channel_data,channel:this.name})}))}unsubscribe(){this.subscribed=!1,this.pusher.send_event("pusher:unsubscribe",{channel:this.name})}cancelSubscription(){this.subscriptionCancelled=!0}reinstateSubscription(){this.subscriptionCancelled=!1}}class lt extends ut{authorize(t,e){return this.pusher.config.channelAuthorizer({channelName:this.name,socketId:t},e)}}class dt{constructor(){this.reset()}get(t){return Object.prototype.hasOwnProperty.call(this.members,t)?{id:t,info:this.members[t]}:null}each(t){_(this.members,(e,n)=>{t(this.get(n))})}setMyID(t){this.myID=t}onSubscription(t){this.members=t.presence.hash,this.count=t.presence.count,this.me=this.get(this.myID)}addMember(t){return null===this.get(t.user_id)&&this.count++,this.members[t.user_id]=t.user_info,this.get(t.user_id)}removeMember(t){var e=this.get(t.user_id);return e&&(delete this.members[t.user_id],this.count--),e}reset(){this.members={},this.count=0,this.myID=null,this.me=null}}var pt=function(t,e,n,i){return new(n||(n=Promise))((function(s,r){function o(t){try{c(i.next(t))}catch(t){r(t)}}function a(t){try{c(i.throw(t))}catch(t){r(t)}}function c(t){var e;t.done?s(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(o,a)}c((i=i.apply(t,e||[])).next())}))};class ft extends lt{constructor(t,e){super(t,e),this.members=new dt}authorize(t,e){super.authorize(t,(t,n)=>pt(this,void 0,void 0,(function*(){if(!t)if(null!=(n=n).channel_data){var i=JSON.parse(n.channel_data);this.members.setMyID(i.user_id)}else{if(yield this.pusher.user.signinDonePromise,null==this.pusher.user.user_data){let t=ht("authorizationEndpoint");return M.error(`Invalid auth response for channel '${this.name}', expected 'channel_data' field. ${t}, or the user should be signed in.`),void e("Invalid auth response")}this.members.setMyID(this.pusher.user.user_data.id)}e(t,n)})))}handleEvent(t){var e=t.event;if(0===e.indexOf("pusher_internal:"))this.handleInternalEvent(t);else{var n=t.data,i={};t.user_id&&(i.user_id=t.user_id),this.emit(e,n,i)}}handleInternalEvent(t){var e=t.event,n=t.data;switch(e){case"pusher_internal:subscription_succeeded":this.handleSubscriptionSucceededEvent(t);break;case"pusher_internal:subscription_count":this.handleSubscriptionCountEvent(t);break;case"pusher_internal:member_added":var i=this.members.addMember(n);this.emit("pusher:member_added",i);break;case"pusher_internal:member_removed":var s=this.members.removeMember(n);s&&this.emit("pusher:member_removed",s)}}handleSubscriptionSucceededEvent(t){this.subscriptionPending=!1,this.subscribed=!0,this.subscriptionCancelled?this.pusher.unsubscribe(this.name):(this.members.onSubscription(t.data),this.emit("pusher:subscription_succeeded",this.members))}disconnect(){this.members.reset(),super.disconnect()}}var gt=n(1),bt=n(0);class mt extends lt{constructor(t,e,n){super(t,e),this.key=null,this.nacl=n}authorize(t,e){super.authorize(t,(t,n)=>{if(t)return void e(t,n);let i=n.shared_secret;i?(this.key=Object(bt.decode)(i),delete n.shared_secret,e(null,n)):e(new Error("No shared_secret key in auth payload for encrypted channel: "+this.name),null)})}trigger(t,e){throw new st("Client events are not currently supported for encrypted channels")}handleEvent(t){var e=t.event,n=t.data;0!==e.indexOf("pusher_internal:")&&0!==e.indexOf("pusher:")?this.handleEncryptedEvent(e,n):super.handleEvent(t)}handleEncryptedEvent(t,e){if(!this.key)return void M.debug("Received encrypted event before key has been retrieved from the authEndpoint");if(!e.ciphertext||!e.nonce)return void M.error("Unexpected format for encrypted event, expected object with `ciphertext` and `nonce` fields, got: "+e);let n=Object(bt.decode)(e.ciphertext);if(n.length{e?M.error(`Failed to make a request to the authEndpoint: ${r}. Unable to fetch new key, so dropping encrypted event`):(s=this.nacl.secretbox.open(n,i,this.key),null!==s?this.emit(t,this.getDataToEmit(s)):M.error("Failed to decrypt event with new key. Dropping encrypted event"))});this.emit(t,this.getDataToEmit(s))}getDataToEmit(t){let e=Object(gt.decode)(t);try{return JSON.parse(e)}catch(t){return e}}}class vt extends H{constructor(t,e){super(),this.state="initialized",this.connection=null,this.key=t,this.options=e,this.timeline=this.options.timeline,this.usingTLS=this.options.useTLS,this.errorCallbacks=this.buildErrorCallbacks(),this.connectionCallbacks=this.buildConnectionCallbacks(this.errorCallbacks),this.handshakeCallbacks=this.buildHandshakeCallbacks(this.errorCallbacks);var n=ae.getNetwork();n.bind("online",()=>{this.timeline.info({netinfo:"online"}),"connecting"!==this.state&&"unavailable"!==this.state||this.retryIn(0)}),n.bind("offline",()=>{this.timeline.info({netinfo:"offline"}),this.connection&&this.sendActivityCheck()}),this.updateStrategy()}switchCluster(t){this.key=t,this.updateStrategy(),this.retryIn(0)}connect(){this.connection||this.runner||(this.strategy.isSupported()?(this.updateState("connecting"),this.startConnecting(),this.setUnavailableTimer()):this.updateState("failed"))}send(t){return!!this.connection&&this.connection.send(t)}send_event(t,e,n){return!!this.connection&&this.connection.send_event(t,e,n)}disconnect(){this.disconnectInternally(),this.updateState("disconnected")}isUsingTLS(){return this.usingTLS}startConnecting(){var t=(e,n)=>{e?this.runner=this.strategy.connect(0,t):"error"===n.action?(this.emit("error",{type:"HandshakeError",error:n.error}),this.timeline.error({handshakeError:n.error})):(this.abortConnecting(),this.handshakeCallbacks[n.action](n))};this.runner=this.strategy.connect(0,t)}abortConnecting(){this.runner&&(this.runner.abort(),this.runner=null)}disconnectInternally(){(this.abortConnecting(),this.clearRetryTimer(),this.clearUnavailableTimer(),this.connection)&&this.abandonConnection().close()}updateStrategy(){this.strategy=this.options.getStrategy({key:this.key,timeline:this.timeline,useTLS:this.usingTLS})}retryIn(t){this.timeline.info({action:"retry",delay:t}),t>0&&this.emit("connecting_in",Math.round(t/1e3)),this.retryTimer=new g(t||0,()=>{this.disconnectInternally(),this.connect()})}clearRetryTimer(){this.retryTimer&&(this.retryTimer.ensureAborted(),this.retryTimer=null)}setUnavailableTimer(){this.unavailableTimer=new g(this.options.unavailableTimeout,()=>{this.updateState("unavailable")})}clearUnavailableTimer(){this.unavailableTimer&&this.unavailableTimer.ensureAborted()}sendActivityCheck(){this.stopActivityCheck(),this.connection.ping(),this.activityTimer=new g(this.options.pongTimeout,()=>{this.timeline.error({pong_timed_out:this.options.pongTimeout}),this.retryIn(0)})}resetActivityCheck(){this.stopActivityCheck(),this.connection&&!this.connection.handlesActivityChecks()&&(this.activityTimer=new g(this.activityTimeout,()=>{this.sendActivityCheck()}))}stopActivityCheck(){this.activityTimer&&this.activityTimer.ensureAborted()}buildConnectionCallbacks(t){return v({},t,{message:t=>{this.resetActivityCheck(),this.emit("message",t)},ping:()=>{this.send_event("pusher:pong",{})},activity:()=>{this.resetActivityCheck()},error:t=>{this.emit("error",t)},closed:()=>{this.abandonConnection(),this.shouldRetry()&&this.retryIn(1e3)}})}buildHandshakeCallbacks(t){return v({},t,{connected:t=>{this.activityTimeout=Math.min(this.options.activityTimeout,t.activityTimeout,t.connection.activityTimeout||1/0),this.clearUnavailableTimer(),this.setConnection(t.connection),this.socket_id=this.connection.id,this.updateState("connected",{socket_id:this.socket_id})}})}buildErrorCallbacks(){let t=t=>e=>{e.error&&this.emit("error",{type:"WebSocketError",error:e.error}),t(e)};return{tls_only:t(()=>{this.usingTLS=!0,this.updateStrategy(),this.retryIn(0)}),refused:t(()=>{this.disconnect()}),backoff:t(()=>{this.retryIn(1e3)}),retry:t(()=>{this.retryIn(0)})}}setConnection(t){for(var e in this.connection=t,this.connectionCallbacks)this.connection.bind(e,this.connectionCallbacks[e]);this.resetActivityCheck()}abandonConnection(){if(this.connection){for(var t in this.stopActivityCheck(),this.connectionCallbacks)this.connection.unbind(t,this.connectionCallbacks[t]);var e=this.connection;return this.connection=null,e}}updateState(t,e){var n=this.state;if(this.state=t,n!==t){var i=t;"connected"===i&&(i+=" with new socket ID "+e.socket_id),M.debug("State changed",n+" -> "+i),this.timeline.info({state:t,params:e}),this.emit("state_change",{previous:n,current:t}),this.emit(t,e)}}shouldRetry(){return"connecting"===this.state||"connected"===this.state}}class yt{constructor(){this.channels={}}add(t,e){return this.channels[t]||(this.channels[t]=function(t,e){if(0===t.indexOf("private-encrypted-")){if(e.config.nacl)return St.createEncryptedChannel(t,e,e.config.nacl);let n="Tried to subscribe to a private-encrypted- channel but no nacl implementation available",i=ht("encryptedChannelSupport");throw new st(`${n}. ${i}`)}if(0===t.indexOf("private-"))return St.createPrivateChannel(t,e);if(0===t.indexOf("presence-"))return St.createPresenceChannel(t,e);if(0===t.indexOf("#"))throw new et('Cannot create a channel with name "'+t+'".');return St.createChannel(t,e)}(t,e)),this.channels[t]}all(){return function(t){var e=[];return _(t,(function(t){e.push(t)})),e}(this.channels)}find(t){return this.channels[t]}remove(t){var e=this.channels[t];return delete this.channels[t],e}disconnect(){_(this.channels,(function(t){t.disconnect()}))}}var St={createChannels:()=>new yt,createConnectionManager:(t,e)=>new vt(t,e),createChannel:(t,e)=>new ut(t,e),createPrivateChannel:(t,e)=>new lt(t,e),createPresenceChannel:(t,e)=>new ft(t,e),createEncryptedChannel:(t,e,n)=>new mt(t,e,n),createTimelineSender:(t,e)=>new Z(t,e),createHandshake:(t,e)=>new Q(t,e),createAssistantToTheTransportManager:(t,e,n)=>new G(t,e,n)};class _t{constructor(t){this.options=t||{},this.livesLeft=this.options.lives||1/0}getAssistant(t){return St.createAssistantToTheTransportManager(this,t,{minPingDelay:this.options.minPingDelay,maxPingDelay:this.options.maxPingDelay})}isAlive(){return this.livesLeft>0}reportDeath(){this.livesLeft-=1}}class wt{constructor(t,e){this.strategies=t,this.loop=Boolean(e.loop),this.failFast=Boolean(e.failFast),this.timeout=e.timeout,this.timeoutLimit=e.timeoutLimit}isSupported(){return O(this.strategies,m.method("isSupported"))}connect(t,e){var n=this.strategies,i=0,s=this.timeout,r=null,o=(a,c)=>{c?e(null,c):(i+=1,this.loop&&(i%=n.length),i0&&(s=new g(n.timeout,(function(){r.abort(),i(!0)}))),r=t.connect(e,(function(t,e){t&&s&&s.isRunning()&&!n.failFast||(s&&s.ensureAborted(),i(t,e))})),{abort:function(){s&&s.ensureAborted(),r.abort()},forceMinPriority:function(t){r.forceMinPriority(t)}}}}class Ct{constructor(t){this.strategies=t}isSupported(){return O(this.strategies,m.method("isSupported"))}connect(t,e){return function(t,e,n){var i=k(t,(function(t,i,s,r){return t.connect(e,n(i,r))}));return{abort:function(){C(i,kt)},forceMinPriority:function(t){C(i,(function(e){e.forceMinPriority(t)}))}}}(this.strategies,t,(function(t,n){return function(i,s){n[t].error=i,i?function(t){return function(t,e){for(var n=0;n=m.now()){var o=this.transports[i.transport];o&&(["ws","wss"].includes(i.transport)||s>3?(this.timeline.info({cached:!0,transport:i.transport,latency:i.latency}),r.push(new wt([o],{timeout:2*i.latency+1e3,failFast:!0}))):s++)}var a=m.now(),c=r.pop().connect(t,(function i(o,h){o?(Ot(n),r.length>0?(a=m.now(),c=r.pop().connect(t,i)):e(o)):(!function(t,e,n,i){var s=ae.getLocalStorage();if(s)try{s[Pt(t)]=L({timestamp:m.now(),transport:e,latency:n,cacheSkipCount:i})}catch(t){}}(n,h.transport.name,m.now()-a,s),e(null,h))}));return{abort:function(){c.abort()},forceMinPriority:function(e){t=e,c&&c.forceMinPriority(e)}}}}function Pt(t){return"pusherTransport"+(t?"TLS":"NonTLS")}function Ot(t){var e=ae.getLocalStorage();if(e)try{delete e[Pt(t)]}catch(t){}}class Et{constructor(t,{delay:e}){this.strategy=t,this.options={delay:e}}isSupported(){return this.strategy.isSupported()}connect(t,e){var n,i=this.strategy,s=new g(this.options.delay,(function(){n=i.connect(t,e)}));return{abort:function(){s.ensureAborted(),n&&n.abort()},forceMinPriority:function(e){t=e,n&&n.forceMinPriority(e)}}}}class xt{constructor(t,e,n){this.test=t,this.trueBranch=e,this.falseBranch=n}isSupported(){return(this.test()?this.trueBranch:this.falseBranch).isSupported()}connect(t,e){return(this.test()?this.trueBranch:this.falseBranch).connect(t,e)}}class Lt{constructor(t){this.strategy=t}isSupported(){return this.strategy.isSupported()}connect(t,e){var n=this.strategy.connect(t,(function(t,i){i&&n.abort(),e(t,i)}));return n}}function At(t){return function(){return t.isSupported()}}var Rt=function(t,e,n){var i={};function s(e,s,r,o,a){var c=n(t,e,s,r,o,a);return i[e]=c,c}var r,o=Object.assign({},e,{hostNonTLS:t.wsHost+":"+t.wsPort,hostTLS:t.wsHost+":"+t.wssPort,httpPath:t.wsPath}),a=v({},o,{useTLS:!0}),c=Object.assign({},e,{hostNonTLS:t.httpHost+":"+t.httpPort,hostTLS:t.httpHost+":"+t.httpsPort,httpPath:t.httpPath}),h={loop:!0,timeout:15e3,timeoutLimit:6e4},u=new _t({minPingDelay:1e4,maxPingDelay:t.activityTimeout}),l=new _t({lives:2,minPingDelay:1e4,maxPingDelay:t.activityTimeout}),d=s("ws","ws",3,o,u),p=s("wss","ws",3,a,u),f=s("xhr_streaming","xhr_streaming",1,c,l),g=s("xhr_polling","xhr_polling",1,c),b=new wt([d],h),m=new wt([p],h),y=new wt([f],h),S=new wt([g],h),_=new wt([new xt(At(y),new Ct([y,new Et(S,{delay:4e3})]),S)],h);return r=e.useTLS?new Ct([b,new Et(_,{delay:2e3})]):new Ct([b,new Et(m,{delay:2e3}),new Et(_,{delay:5e3})]),new Tt(new Lt(new xt(At(d),r,_)),i,{ttl:18e5,timeline:e.timeline,useTLS:e.useTLS})};class It extends H{constructor(t,e,n){super(),this.hooks=t,this.method=e,this.url=n}start(t){this.position=0,this.xhr=this.hooks.getRequest(this),this.unloader=()=>{this.close()},ae.addUnloadListener(this.unloader),this.xhr.open(this.method,this.url,!0),this.xhr.setRequestHeader&&this.xhr.setRequestHeader("Content-Type","application/json"),this.xhr.send(t)}close(){this.unloader&&(ae.removeUnloadListener(this.unloader),this.unloader=null),this.xhr&&(this.hooks.abortRequest(this.xhr),this.xhr=null)}onChunk(t,e){for(;;){var n=this.advanceBuffer(e);if(!n)break;this.emit("chunk",{status:t,data:n})}this.isBufferTooLong(e)&&this.emit("buffer_too_long")}advanceBuffer(t){var e=t.slice(this.position),n=e.indexOf("\n");return-1!==n?(this.position+=n+1,e.slice(0,n)):null}isBufferTooLong(t){return this.position===t.length&&t.length>262144}}var jt;!function(t){t[t.CONNECTING=0]="CONNECTING",t[t.OPEN=1]="OPEN",t[t.CLOSED=3]="CLOSED"}(jt||(jt={}));var Dt=jt,Nt=1;function Ut(t){var e=-1===t.indexOf("?")?"?":"&";return t+e+"t="+ +new Date+"&n="+Nt++}function Ht(t){return ae.randomInt(t)}var Mt=class{constructor(t,e){this.hooks=t,this.session=Ht(1e3)+"/"+function(t){for(var e=[],n=0;n{this.onChunk(t)}),this.stream.bind("finished",t=>{this.hooks.onFinished(this,t)}),this.stream.bind("buffer_too_long",()=>{this.reconnect()});try{this.stream.start()}catch(t){m.defer(()=>{this.onError(t),this.onClose(1006,"Could not start streaming",!1)})}}closeStream(){this.stream&&(this.stream.unbind_all(),this.stream.close(),this.stream=null)}},zt={getReceiveURL:function(t,e){return t.base+"/"+e+"/xhr_streaming"+t.queryString},onHeartbeat:function(t){t.sendRaw("[]")},sendHeartbeat:function(t){t.sendRaw("[]")},onFinished:function(t,e){t.onClose(1006,"Connection interrupted ("+e+")",!1)}},Bt={getReceiveURL:function(t,e){return t.base+"/"+e+"/xhr"+t.queryString},onHeartbeat:function(){},sendHeartbeat:function(t){t.sendRaw("[]")},onFinished:function(t,e){200===e?t.reconnect():t.onClose(1006,"Connection interrupted ("+e+")",!1)}},qt={getRequest:function(t){var e=new(ae.getXHRAPI());return e.onreadystatechange=e.onprogress=function(){switch(e.readyState){case 3:e.responseText&&e.responseText.length>0&&t.onChunk(e.status,e.responseText);break;case 4:e.responseText&&e.responseText.length>0&&t.onChunk(e.status,e.responseText),t.emit("finished",e.status),t.close()}},e},abortRequest:function(t){t.onreadystatechange=null,t.abort()}},Ft={getDefaultStrategy:Rt,Transports:X,transportConnectionInitializer:function(){this.timeline.info(this.buildTimelineMessage({transport:this.name+(this.options.useTLS?"s":"")})),this.hooks.isInitialized()?this.changeState("initialized"):this.onClose()},HTTPFactory:{createStreamingSocket(t){return this.createSocket(zt,t)},createPollingSocket(t){return this.createSocket(Bt,t)},createSocket:(t,e)=>new Mt(t,e),createXHR(t,e){return this.createRequest(qt,t,e)},createRequest:(t,e,n)=>new It(t,e,n)},setup(t){t.ready()},getLocalStorage(){},getClientFeatures:()=>w(P({ws:X.ws},(function(t){return t.isSupported({})}))),getProtocol:()=>"http:",isXHRSupported:()=>!0,createSocketRequest(t,e){if(this.isXHRSupported())return this.HTTPFactory.createXHR(t,e);throw"Cross-origin HTTP requests are not supported"},createXHR(){return new(this.getXHRAPI())},createWebSocket(t){return new(this.getWebSocketAPI())(t)},addUnloadListener(t){},removeUnloadListener(t){}};var $t=new class extends H{isOnline(){return!0}},Jt=function(t,e,n,i,s){var r=new Headers;for(var o in r.set("Content-Type","application/x-www-form-urlencoded"),n.headers)r.set(o,n.headers[o]);if(null!=n.headersProvider){const t=n.headersProvider();for(var o in t)r.set(o,t[o])}var a=e,c=new Request(n.endpoint,{headers:r,body:a,credentials:"same-origin",method:"POST"});return fetch(c).then(t=>{let{status:e}=t;if(200===e)return t.text();throw new at(e,`Could not get ${i.toString()} info from your auth endpoint, status: ${e}`)}).then(t=>{let e;try{e=JSON.parse(t)}catch(e){throw new at(200,`JSON returned from ${i.toString()} endpoint was invalid, yet status code was 200. Data was: ${t}`)}s(null,e)}).catch(t=>{s(t,null)})},Wt={name:"xhr",getAgent:function(t,e){return function(n,i){var s="http"+(e?"s":"")+"://"+(t.host||t.options.host)+t.options.path,r=x(n);fetch(s+="/2?"+r).then(t=>{if(200!==t.status)throw`received ${t.status} from stats.pusher.com`;return t.json()}).then(({host:e})=>{e&&(t.host=e)}).catch(t=>{M.debug("TimelineSender Error: ",t)})}}};const{getDefaultStrategy:Xt,Transports:Gt,setup:Vt,getProtocol:Yt,isXHRSupported:Kt,getLocalStorage:Qt,createXHR:Zt,createWebSocket:te,addUnloadListener:ee,removeUnloadListener:ne,transportConnectionInitializer:ie,createSocketRequest:se,HTTPFactory:re}=Ft;var oe,ae={getDefaultStrategy:Xt,Transports:Gt,setup:Vt,getProtocol:Yt,isXHRSupported:Kt,getLocalStorage:Qt,createXHR:Zt,createWebSocket:te,addUnloadListener:ee,removeUnloadListener:ne,transportConnectionInitializer:ie,createSocketRequest:se,HTTPFactory:re,TimelineTransport:Wt,getAuthorizers:()=>({ajax:Jt}),getWebSocketAPI:()=>WebSocket,getXHRAPI:()=>XMLHttpRequest,getNetwork:()=>$t,randomInt:t=>Math.floor((globalThis.crypto||globalThis.msCrypto).getRandomValues(new Uint32Array(1))[0]/Math.pow(2,32)*t)};!function(t){t[t.ERROR=3]="ERROR",t[t.INFO=6]="INFO",t[t.DEBUG=7]="DEBUG"}(oe||(oe={}));var ce=oe;class he{constructor(t,e,n){this.key=t,this.session=e,this.events=[],this.options=n||{},this.sent=0,this.uniqueID=0}log(t,e){t<=this.options.level&&(this.events.push(v({},e,{timestamp:m.now()})),this.options.limit&&this.events.length>this.options.limit&&this.events.shift())}error(t){this.log(ce.ERROR,t)}info(t){this.log(ce.INFO,t)}debug(t){this.log(ce.DEBUG,t)}isEmpty(){return 0===this.events.length}send(t,e){var n=v({session:this.session,bundle:this.sent+1,key:this.key,lib:"js",version:this.options.version,cluster:this.options.cluster,features:this.options.features,timeline:this.events},this.options.params);return this.events=[],t(n,(t,n)=>{t||this.sent++,e&&e(t,n)}),!0}generateUniqueID(){return this.uniqueID++,this.uniqueID}}class ue{constructor(t,e,n,i){this.name=t,this.priority=e,this.transport=n,this.options=i||{}}isSupported(){return this.transport.isSupported({useTLS:this.options.useTLS})}connect(t,e){if(!this.isSupported())return le(new ot,e);if(this.priority{n||(h(),s?s.close():i.close())},forceMinPriority:t=>{n||this.priority{if(void 0===ae.getAuthorizers()[t.transport])throw`'${t.transport}' is not a recognized auth transport`;return(e,n)=>{const i=((t,e)=>{var n="socket_id="+encodeURIComponent(t.socketId);for(var i in e.params)n+="&"+encodeURIComponent(i)+"="+encodeURIComponent(e.params[i]);if(null!=e.paramsProvider){let t=e.paramsProvider();for(var i in t)n+="&"+encodeURIComponent(i)+"="+encodeURIComponent(t[i])}return n})(e,t);ae.getAuthorizers()[t.transport](ae,i,t,pe.UserAuthentication,n)}};var me=t=>{if(void 0===ae.getAuthorizers()[t.transport])throw`'${t.transport}' is not a recognized auth transport`;return(e,n)=>{const i=((t,e)=>{var n="socket_id="+encodeURIComponent(t.socketId);for(var i in n+="&channel_name="+encodeURIComponent(t.channelName),e.params)n+="&"+encodeURIComponent(i)+"="+encodeURIComponent(e.params[i]);if(null!=e.paramsProvider){let t=e.paramsProvider();for(var i in t)n+="&"+encodeURIComponent(i)+"="+encodeURIComponent(t[i])}return n})(e,t);ae.getAuthorizers()[t.transport](ae,i,t,pe.ChannelAuthorization,n)}};function ve(t,e){let n={activityTimeout:t.activityTimeout||A.activityTimeout,cluster:t.cluster,httpPath:t.httpPath||A.httpPath,httpPort:t.httpPort||A.httpPort,httpsPort:t.httpsPort||A.httpsPort,pongTimeout:t.pongTimeout||A.pongTimeout,statsHost:t.statsHost||A.stats_host,unavailableTimeout:t.unavailableTimeout||A.unavailableTimeout,wsPath:t.wsPath||A.wsPath,wsPort:t.wsPort||A.wsPort,wssPort:t.wssPort||A.wssPort,enableStats:we(t),httpHost:ye(t),useTLS:_e(t),wsHost:Se(t),userAuthenticator:Ce(t),channelAuthorizer:ke(t,e)};return"disabledTransports"in t&&(n.disabledTransports=t.disabledTransports),"enabledTransports"in t&&(n.enabledTransports=t.enabledTransports),"ignoreNullOrigin"in t&&(n.ignoreNullOrigin=t.ignoreNullOrigin),"timelineParams"in t&&(n.timelineParams=t.timelineParams),"nacl"in t&&(n.nacl=t.nacl),n}function ye(t){return t.httpHost?t.httpHost:t.cluster?`sockjs-${t.cluster}.pusher.com`:A.httpHost}function Se(t){return t.wsHost?t.wsHost:`ws-${t.cluster}.pusher.com`}function _e(t){return"https:"===ae.getProtocol()||!1!==t.forceTLS}function we(t){return"enableStats"in t?t.enableStats:"disableStats"in t&&!t.disableStats}function Ce(t){const e=Object.assign(Object.assign({},A.userAuthentication),t.userAuthentication);return"customHandler"in e&&null!=e.customHandler?e.customHandler:be(e)}function ke(t,e){const n=function(t,e){let n;return"channelAuthorization"in t?n=Object.assign(Object.assign({},A.channelAuthorization),t.channelAuthorization):(n={transport:t.authTransport||A.authTransport,endpoint:t.authEndpoint||A.authEndpoint},"auth"in t&&("params"in t.auth&&(n.params=t.auth.params),"headers"in t.auth&&(n.headers=t.auth.headers)),"authorizer"in t&&(n.customHandler=((t,e,n)=>{const i={authTransport:e.transport,authEndpoint:e.endpoint,auth:{params:e.params,headers:e.headers}};return(e,s)=>{const r=t.channel(e.channelName);n(r,i).authorize(e.socketId,s)}})(e,n,t.authorizer))),n}(t,e);return"customHandler"in n&&null!=n.customHandler?n.customHandler:me(n)}class Te extends H{constructor(t){super((function(t,e){M.debug("No callbacks on watchlist events for "+t)})),this.pusher=t,this.bindWatchlistInternalEvent()}handleEvent(t){t.data.events.forEach(t=>{this.emit(t.name,t)})}bindWatchlistInternalEvent(){this.pusher.connection.bind("message",t=>{"pusher_internal:watchlist_events"===t.event&&this.handleEvent(t)})}}var Pe=function(){let t,e;return{promise:new Promise((n,i)=>{t=n,e=i}),resolve:t,reject:e}};class Oe extends H{constructor(t){super((function(t,e){M.debug("No callbacks on user for "+t)})),this.signin_requested=!1,this.user_data=null,this.serverToUserChannel=null,this.signinDonePromise=null,this._signinDoneResolve=null,this._onAuthorize=(t,e)=>{if(t)return M.warn("Error during signin: "+t),void this._cleanup();this.pusher.send_event("pusher:signin",{auth:e.auth,user_data:e.user_data})},this.pusher=t,this.pusher.connection.bind("state_change",({previous:t,current:e})=>{"connected"!==t&&"connected"===e&&this._signin(),"connected"===t&&"connected"!==e&&(this._cleanup(),this._newSigninPromiseIfNeeded())}),this.watchlist=new Te(t),this.pusher.connection.bind("message",t=>{"pusher:signin_success"===t.event&&this._onSigninSuccess(t.data),this.serverToUserChannel&&this.serverToUserChannel.name===t.channel&&this.serverToUserChannel.handleEvent(t)})}signin(){this.signin_requested||(this.signin_requested=!0,this._signin())}_signin(){this.signin_requested&&(this._newSigninPromiseIfNeeded(),"connected"===this.pusher.connection.state&&this.pusher.config.userAuthenticator({socketId:this.pusher.connection.socket_id},this._onAuthorize))}_onSigninSuccess(t){try{this.user_data=JSON.parse(t.user_data)}catch(e){return M.error("Failed parsing user data after signin: "+t.user_data),void this._cleanup()}if("string"!=typeof this.user_data.id||""===this.user_data.id)return M.error("user_data doesn't contain an id. user_data: "+this.user_data),void this._cleanup();this._signinDoneResolve(),this._subscribeChannels()}_subscribeChannels(){this.serverToUserChannel=new ut("#server-to-user-"+this.user_data.id,this.pusher),this.serverToUserChannel.bind_global((t,e)=>{0!==t.indexOf("pusher_internal:")&&0!==t.indexOf("pusher:")&&this.emit(t,e)}),(t=>{t.subscriptionPending&&t.subscriptionCancelled?t.reinstateSubscription():t.subscriptionPending||"connected"!==this.pusher.connection.state||t.subscribe()})(this.serverToUserChannel)}_cleanup(){this.user_data=null,this.serverToUserChannel&&(this.serverToUserChannel.unbind_all(),this.serverToUserChannel.disconnect(),this.serverToUserChannel=null),this.signin_requested&&this._signinDoneResolve()}_newSigninPromiseIfNeeded(){if(!this.signin_requested)return;if(this.signinDonePromise&&!this.signinDonePromise.done)return;const{promise:t,resolve:e,reject:n}=Pe();t.done=!1;const i=()=>{t.done=!0};t.then(i).catch(i),this.signinDonePromise=t,this._signinDoneResolve=e}}class Ee{static ready(){Ee.isReady=!0;for(var t=0,e=Ee.instances.length;tae.getDefaultStrategy(this.config,t,fe),timeline:this.timeline,activityTimeout:this.config.activityTimeout,pongTimeout:this.config.pongTimeout,unavailableTimeout:this.config.unavailableTimeout,useTLS:Boolean(this.config.useTLS)}),this.connection.bind("connected",()=>{this.subscribeAll(),this.timelineSender&&this.timelineSender.send(this.connection.isUsingTLS())}),this.connection.bind("message",t=>{var e=0===t.event.indexOf("pusher_internal:");if(t.channel){var n=this.channel(t.channel);n&&n.handleEvent(t)}e||this.global_emitter.emit(t.event,t.data)}),this.connection.bind("connecting",()=>{this.channels.disconnect()}),this.connection.bind("disconnected",()=>{this.channels.disconnect()}),this.connection.bind("error",t=>{M.warn(t)}),Ee.instances.push(this),this.timeline.info({instances:Ee.instances.length}),this.user=new Oe(this),Ee.isReady&&this.connect()}switchCluster(t){const{appKey:e,cluster:n}=t;this.key=e,this.options=Object.assign(Object.assign({},this.options),{cluster:n}),this.config=ve(this.options,this),this.connection.switchCluster(this.key)}channel(t){return this.channels.find(t)}allChannels(){return this.channels.all()}connect(){if(this.connection.connect(),this.timelineSender&&!this.timelineSenderTimer){var t=this.connection.isUsingTLS(),e=this.timelineSender;this.timelineSenderTimer=new b(6e4,(function(){e.send(t)}))}}disconnect(){this.connection.disconnect(),this.timelineSenderTimer&&(this.timelineSenderTimer.ensureAborted(),this.timelineSenderTimer=null)}bind(t,e,n){return this.global_emitter.bind(t,e,n),this}unbind(t,e,n){return this.global_emitter.unbind(t,e,n),this}bind_global(t){return this.global_emitter.bind_global(t),this}unbind_global(t){return this.global_emitter.unbind_global(t),this}unbind_all(t){return this.global_emitter.unbind_all(),this}subscribeAll(){var t;for(t in this.channels.channels)this.channels.channels.hasOwnProperty(t)&&this.subscribe(t)}subscribe(t){var e=this.channels.add(t,this);return e.subscriptionPending&&e.subscriptionCancelled?e.reinstateSubscription():e.subscriptionPending||"connected"!==this.connection.state||e.subscribe(),e}unsubscribe(t){var e=this.channels.find(t);e&&e.subscriptionPending?e.cancelSubscription():(e=this.channels.remove(t))&&e.subscribed&&e.unsubscribe()}send_event(t,e,n){return this.connection.send_event(t,e,n)}shouldUseTLS(){return this.config.useTLS}signin(){this.user.signin()}}Ee.instances=[],Ee.isReady=!1,Ee.logToConsole=!1,Ee.Runtime=ae,Ee.ScriptReceivers=ae.ScriptReceivers,Ee.DependenciesReceivers=ae.DependenciesReceivers,Ee.auth_callbacks=ae.auth_callbacks;var xe=e.default=Ee;ae.setup(Ee)}])})); +!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.Pusher=e():t.Pusher=e()}(this,(function(){return function(t){var e={};function n(i){if(e[i])return e[i].exports;var s=e[i]={i:i,l:!1,exports:{}};return t[i].call(s.exports,s,s.exports,n),s.l=!0,s.exports}return n.m=t,n.c=e,n.d=function(t,e,i){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:i})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var i=Object.create(null);if(n.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var s in t)n.d(i,s,function(e){return t[e]}.bind(null,s));return i},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=2)}([function(t,e,n){"use strict";var i,s=this&&this.__extends||(i=function(t,e){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)},function(t,e){function n(){this.constructor=t}i(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)});Object.defineProperty(e,"__esModule",{value:!0});var r=function(){function t(t){void 0===t&&(t="="),this._paddingCharacter=t}return t.prototype.encodedLength=function(t){return this._paddingCharacter?(t+2)/3*4|0:(8*t+5)/6|0},t.prototype.encode=function(t){for(var e="",n=0;n>>18&63),e+=this._encodeByte(i>>>12&63),e+=this._encodeByte(i>>>6&63),e+=this._encodeByte(i>>>0&63)}var s=t.length-n;if(s>0){i=t[n]<<16|(2===s?t[n+1]<<8:0);e+=this._encodeByte(i>>>18&63),e+=this._encodeByte(i>>>12&63),e+=2===s?this._encodeByte(i>>>6&63):this._paddingCharacter||"",e+=this._paddingCharacter||""}return e},t.prototype.maxDecodedLength=function(t){return this._paddingCharacter?t/4*3|0:(6*t+7)/8|0},t.prototype.decodedLength=function(t){return this.maxDecodedLength(t.length-this._getPaddingLength(t))},t.prototype.decode=function(t){if(0===t.length)return new Uint8Array(0);for(var e=this._getPaddingLength(t),n=t.length-e,i=new Uint8Array(this.maxDecodedLength(n)),s=0,r=0,o=0,a=0,c=0,h=0,u=0;r>>4,i[s++]=c<<4|h>>>2,i[s++]=h<<6|u,o|=256&a,o|=256&c,o|=256&h,o|=256&u;if(r>>4,o|=256&a,o|=256&c),r>>2,o|=256&h),r>>8&6,e+=51-t>>>8&-75,e+=61-t>>>8&-15,e+=62-t>>>8&3,String.fromCharCode(e)},t.prototype._decodeChar=function(t){var e=256;return e+=(42-t&t-44)>>>8&-256+t-43+62,e+=(46-t&t-48)>>>8&-256+t-47+63,e+=(47-t&t-58)>>>8&-256+t-48+52,e+=(64-t&t-91)>>>8&-256+t-65+0,e+=(96-t&t-123)>>>8&-256+t-97+26},t.prototype._getPaddingLength=function(t){var e=0;if(this._paddingCharacter){for(var n=t.length-1;n>=0&&t[n]===this._paddingCharacter;n--)e++;if(t.length<4||e>2)throw new Error("Base64Coder: incorrect padding")}return e},t}();e.Coder=r;var o=new r;e.encode=function(t){return o.encode(t)},e.decode=function(t){return o.decode(t)};var a=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return s(e,t),e.prototype._encodeByte=function(t){var e=t;return e+=65,e+=25-t>>>8&6,e+=51-t>>>8&-75,e+=61-t>>>8&-13,e+=62-t>>>8&49,String.fromCharCode(e)},e.prototype._decodeChar=function(t){var e=256;return e+=(44-t&t-46)>>>8&-256+t-45+62,e+=(94-t&t-96)>>>8&-256+t-95+63,e+=(47-t&t-58)>>>8&-256+t-48+52,e+=(64-t&t-91)>>>8&-256+t-65+0,e+=(96-t&t-123)>>>8&-256+t-97+26},e}(r);e.URLSafeCoder=a;var c=new a;e.encodeURLSafe=function(t){return c.encode(t)},e.decodeURLSafe=function(t){return c.decode(t)},e.encodedLength=function(t){return o.encodedLength(t)},e.maxDecodedLength=function(t){return o.maxDecodedLength(t)},e.decodedLength=function(t){return o.decodedLength(t)}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i="utf8: invalid source encoding";function s(t){for(var e=0,n=0;n=t.length-1)throw new Error("utf8: invalid string");n++,e+=4}}return e}e.encode=function(t){for(var e=new Uint8Array(s(t)),n=0,i=0;i>6,e[n++]=128|63&r):r<55296?(e[n++]=224|r>>12,e[n++]=128|r>>6&63,e[n++]=128|63&r):(i++,r=(1023&r)<<10,r|=1023&t.charCodeAt(i),r+=65536,e[n++]=240|r>>18,e[n++]=128|r>>12&63,e[n++]=128|r>>6&63,e[n++]=128|63&r)}return e},e.encodedLength=s,e.decode=function(t){for(var e=[],n=0;n=t.length)throw new Error(i);if(128!=(192&(o=t[++n])))throw new Error(i);s=(31&s)<<6|63&o,r=128}else if(s<240){if(n>=t.length-1)throw new Error(i);var o=t[++n],a=t[++n];if(128!=(192&o)||128!=(192&a))throw new Error(i);s=(15&s)<<12|(63&o)<<6|63&a,r=2048}else{if(!(s<248))throw new Error(i);if(n>=t.length-2)throw new Error(i);o=t[++n],a=t[++n];var c=t[++n];if(128!=(192&o)||128!=(192&a)||128!=(192&c))throw new Error(i);s=(15&s)<<18|(63&o)<<12|(63&a)<<6|63&c,r=65536}if(s=55296&&s<=57343)throw new Error(i);if(s>=65536){if(s>1114111)throw new Error(i);s-=65536,e.push(String.fromCharCode(55296|s>>10)),s=56320|1023&s}}e.push(String.fromCharCode(s))}return e.join("")}},function(t,e,n){t.exports=n(3).default},function(t,e,n){"use strict";n.r(e);for(var i=String.fromCharCode,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",r={},o=0,a=s.length;o>>6)+i(128|63&e):i(224|e>>>12&15)+i(128|e>>>6&63)+i(128|63&e)},h=function(t){return t.replace(/[^\x00-\x7F]/g,c)},u=function(t){var e=[0,2,1][t.length%3],n=t.charCodeAt(0)<<16|(t.length>1?t.charCodeAt(1):0)<<8|(t.length>2?t.charCodeAt(2):0);return[s.charAt(n>>>18),s.charAt(n>>>12&63),e>=2?"=":s.charAt(n>>>6&63),e>=1?"=":s.charAt(63&n)].join("")},l=self.btoa||function(t){return t.replace(/[\s\S]{1,3}/g,u)};var d=class{constructor(t,e,n,i){this.clear=e,this.timer=t(()=>{this.timer&&(this.timer=i(this.timer))},n)}isRunning(){return null!==this.timer}ensureAborted(){this.timer&&(this.clear(this.timer),this.timer=null)}};function p(t){self.clearTimeout(t)}function f(t){self.clearInterval(t)}class g extends d{constructor(t,e){super(setTimeout,p,t,(function(t){return e(),null}))}}class b extends d{constructor(t,e){super(setInterval,f,t,(function(t){return e(),t}))}}var m={now:()=>Date.now?Date.now():(new Date).valueOf(),defer:t=>new g(0,t),method(t,...e){var n=Array.prototype.slice.call(arguments,1);return function(e){return e[t].apply(e,n.concat(arguments))}}};function v(t,...e){for(var n=0;ne!==t),this):(this.global_callbacks=[],this)}unbind_all(){return this.unbind(),this.unbind_global(),this}emit(t,e,n){for(var i=0;i0)for(i=0;i{self.console&&self.console.log&&self.console.log(t)}}debug(...t){this.log(this.globalLog,t)}warn(...t){this.log(this.globalLogWarn,t)}error(...t){this.log(this.globalLogError,t)}globalLogWarn(t){self.console&&self.console.warn?self.console.warn(t):this.globalLog(t)}globalLogError(t){self.console&&self.console.error?self.console.error(t):this.globalLogWarn(t)}log(t,...e){var n=y.apply(this,arguments);if(xe.log)xe.log(n);else if(xe.logToConsole){t.bind(this)(n)}}};class z extends H{constructor(t,e,n,i,s){super(),this.initialize=ae.transportConnectionInitializer,this.hooks=t,this.name=e,this.priority=n,this.key=i,this.options=s,this.state="new",this.timeline=s.timeline,this.activityTimeout=s.activityTimeout,this.id=this.timeline.generateUniqueID()}handlesActivityChecks(){return Boolean(this.hooks.handlesActivityChecks)}supportsPing(){return Boolean(this.hooks.supportsPing)}connect(){if(this.socket||"initialized"!==this.state)return!1;var t=this.hooks.urls.getInitial(this.key,this.options);try{this.socket=this.hooks.getSocket(t,this.options)}catch(t){return m.defer(()=>{this.onError(t),this.changeState("closed")}),!1}return this.bindListeners(),M.debug("Connecting",{transport:this.name,url:t}),this.changeState("connecting"),!0}close(){return!!this.socket&&(this.socket.close(),!0)}send(t){return"open"===this.state&&(m.defer(()=>{this.socket&&this.socket.send(t)}),!0)}ping(){"open"===this.state&&this.supportsPing()&&this.socket.ping()}onOpen(){this.hooks.beforeOpen&&this.hooks.beforeOpen(this.socket,this.hooks.urls.getPath(this.key,this.options)),this.changeState("open"),this.socket.onopen=void 0}onError(t){this.emit("error",{type:"WebSocketError",error:t}),this.timeline.error(this.buildTimelineMessage({error:t.toString()}))}onClose(t){t?this.changeState("closed",{code:t.code,reason:t.reason,wasClean:t.wasClean}):this.changeState("closed"),this.unbindListeners(),this.socket=void 0}onMessage(t){this.emit("message",t)}onActivity(){this.emit("activity")}bindListeners(){this.socket.onopen=()=>{this.onOpen()},this.socket.onerror=t=>{this.onError(t)},this.socket.onclose=t=>{this.onClose(t)},this.socket.onmessage=t=>{this.onMessage(t)},this.supportsPing()&&(this.socket.onactivity=()=>{this.onActivity()})}unbindListeners(){this.socket&&(this.socket.onopen=void 0,this.socket.onerror=void 0,this.socket.onclose=void 0,this.socket.onmessage=void 0,this.supportsPing()&&(this.socket.onactivity=void 0))}changeState(t,e){this.state=t,this.timeline.info(this.buildTimelineMessage({state:t,params:e})),this.emit(t,e)}buildTimelineMessage(t){return v({cid:this.id},t)}}class B{constructor(t){this.hooks=t}isSupported(t){return this.hooks.isSupported(t)}createConnection(t,e,n,i){return new z(this.hooks,t,e,n,i)}}var q=new B({urls:j,handlesActivityChecks:!1,supportsPing:!1,isInitialized:function(){return Boolean(ae.getWebSocketAPI())},isSupported:function(){return Boolean(ae.getWebSocketAPI())},getSocket:function(t){return ae.createWebSocket(t)}}),F={urls:D,handlesActivityChecks:!1,supportsPing:!0,isInitialized:function(){return!0}},$=v({getSocket:function(t){return ae.HTTPFactory.createStreamingSocket(t)}},F),J=v({getSocket:function(t){return ae.HTTPFactory.createPollingSocket(t)}},F),W={isSupported:function(){return ae.isXHRSupported()}},X={ws:q,xhr_streaming:new B(v({},$,W)),xhr_polling:new B(v({},J,W))};class G{constructor(t,e,n){this.manager=t,this.transport=e,this.minPingDelay=n.minPingDelay,this.maxPingDelay=n.maxPingDelay,this.pingDelay=void 0}createConnection(t,e,n,i){i=v({},i,{activityTimeout:this.pingDelay});var s=this.transport.createConnection(t,e,n,i),r=null,o=function(){s.unbind("open",o),s.bind("closed",a),r=m.now()},a=t=>{if(s.unbind("closed",a),1002===t.code||1003===t.code)this.manager.reportDeath();else if(!t.wasClean&&r){var e=m.now()-r;e<2*this.maxPingDelay&&(this.manager.reportDeath(),this.pingDelay=Math.max(e/2,this.minPingDelay))}};return s.bind("open",o),s}isSupported(t){return this.manager.isAlive()&&this.transport.isSupported(t)}}const V={decodeMessage:function(t){try{var e=JSON.parse(t.data),n=e.data;if("string"==typeof n)try{n=JSON.parse(e.data)}catch(t){}var i={event:e.event,channel:e.channel,data:n};return e.user_id&&(i.user_id=e.user_id),i}catch(e){throw{type:"MessageParseError",error:e,data:t.data}}},encodeMessage:function(t){return JSON.stringify(t)},processHandshake:function(t){var e=V.decodeMessage(t);if("pusher:connection_established"===e.event){if(!e.data.activity_timeout)throw"No activity timeout specified in handshake";return{action:"connected",id:e.data.socket_id,activityTimeout:1e3*e.data.activity_timeout}}if("pusher:error"===e.event)return{action:this.getCloseAction(e.data),error:this.getCloseError(e.data)};throw"Invalid handshake"},getCloseAction:function(t){return t.code<4e3?t.code>=1002&&t.code<=1004?"backoff":null:4e3===t.code?"tls_only":t.code<4100?"refused":t.code<4200?"backoff":t.code<4300?"retry":"refused"},getCloseError:function(t){return 1e3!==t.code&&1001!==t.code?{type:"PusherError",data:{code:t.code,message:t.reason||t.message}}:null}};var Y=V;class K extends H{constructor(t,e){super(),this.id=t,this.transport=e,this.activityTimeout=e.activityTimeout,this.bindListeners()}handlesActivityChecks(){return this.transport.handlesActivityChecks()}send(t){return this.transport.send(t)}send_event(t,e,n){var i={event:t,data:e};return n&&(i.channel=n),M.debug("Event sent",i),this.send(Y.encodeMessage(i))}ping(){this.transport.supportsPing()?this.transport.ping():this.send_event("pusher:ping",{})}close(){this.transport.close()}bindListeners(){var t={message:t=>{var e;try{e=Y.decodeMessage(t)}catch(e){this.emit("error",{type:"MessageParseError",error:e,data:t.data})}if(void 0!==e){switch(M.debug("Event recd",e),e.event){case"pusher:error":this.emit("error",{type:"PusherError",data:e.data});break;case"pusher:ping":this.emit("ping");break;case"pusher:pong":this.emit("pong")}this.emit("message",e)}},activity:()=>{this.emit("activity")},error:t=>{this.emit("error",t)},closed:t=>{e(),t&&t.code&&this.handleCloseEvent(t),this.transport=null,this.emit("closed")}},e=()=>{_(t,(t,e)=>{this.transport.unbind(e,t)})};_(t,(t,e)=>{this.transport.bind(e,t)})}handleCloseEvent(t){var e=Y.getCloseAction(t),n=Y.getCloseError(t);n&&this.emit("error",n),e&&this.emit(e,{action:e,error:n})}}class Q{constructor(t,e){this.transport=t,this.callback=e,this.bindListeners()}close(){this.unbindListeners(),this.transport.close()}bindListeners(){this.onMessage=t=>{var e;this.unbindListeners();try{e=Y.processHandshake(t)}catch(t){return this.finish("error",{error:t}),void this.transport.close()}"connected"===e.action?this.finish("connected",{connection:new K(e.id,this.transport),activityTimeout:e.activityTimeout}):(this.finish(e.action,{error:e.error}),this.transport.close())},this.onClosed=t=>{this.unbindListeners();var e=Y.getCloseAction(t)||"backoff",n=Y.getCloseError(t);this.finish(e,{error:n})},this.transport.bind("message",this.onMessage),this.transport.bind("closed",this.onClosed)}unbindListeners(){this.transport.unbind("message",this.onMessage),this.transport.unbind("closed",this.onClosed)}finish(t,e){this.callback(v({transport:this.transport,action:t},e))}}class Z{constructor(t,e){this.timeline=t,this.options=e||{}}send(t,e){this.timeline.isEmpty()||this.timeline.send(ae.TimelineTransport.getAgent(this,t),e)}}class tt extends Error{constructor(t){super(t),Object.setPrototypeOf(this,new.target.prototype)}}class et extends Error{constructor(t){super(t),Object.setPrototypeOf(this,new.target.prototype)}}Error;class nt extends Error{constructor(t){super(t),Object.setPrototypeOf(this,new.target.prototype)}}class it extends Error{constructor(t){super(t),Object.setPrototypeOf(this,new.target.prototype)}}class st extends Error{constructor(t){super(t),Object.setPrototypeOf(this,new.target.prototype)}}class rt extends Error{constructor(t){super(t),Object.setPrototypeOf(this,new.target.prototype)}}class ot extends Error{constructor(t){super(t),Object.setPrototypeOf(this,new.target.prototype)}}class at extends Error{constructor(t,e){super(e),this.status=t,Object.setPrototypeOf(this,new.target.prototype)}}const ct={baseUrl:"https://pusher.com",urls:{authenticationEndpoint:{path:"/docs/channels/server_api/authenticating_users"},authorizationEndpoint:{path:"/docs/channels/server_api/authorizing-users/"},javascriptQuickStart:{path:"/docs/javascript_quick_start"},triggeringClientEvents:{path:"/docs/client_api_guide/client_events#trigger-events"},encryptedChannelSupport:{fullUrl:"https://github.com/pusher/pusher-js/tree/cc491015371a4bde5743d1c87a0fbac0feb53195#encrypted-channel-support"}}};var ht=function(t){const e=ct.urls[t];if(!e)return"";let n;return e.fullUrl?n=e.fullUrl:e.path&&(n=ct.baseUrl+e.path),n?"See: "+n:""};class ut extends H{constructor(t,e){super((function(e,n){M.debug("No callbacks on "+t+" for "+e)})),this.name=t,this.pusher=e,this.subscribed=!1,this.subscriptionPending=!1,this.subscriptionCancelled=!1}authorize(t,e){return e(null,{auth:""})}trigger(t,e){if(0!==t.indexOf("client-"))throw new tt("Event '"+t+"' does not start with 'client-'");if(!this.subscribed){var n=ht("triggeringClientEvents");M.warn("Client event triggered before channel 'subscription_succeeded' event . "+n)}return this.pusher.send_event(t,e,this.name)}disconnect(){this.subscribed=!1,this.subscriptionPending=!1}handleEvent(t){var e=t.event,n=t.data;if("pusher_internal:subscription_succeeded"===e)this.handleSubscriptionSucceededEvent(t);else if("pusher_internal:subscription_count"===e)this.handleSubscriptionCountEvent(t);else if(0!==e.indexOf("pusher_internal:")){this.emit(e,n,{})}}handleSubscriptionSucceededEvent(t){this.subscriptionPending=!1,this.subscribed=!0,this.subscriptionCancelled?this.pusher.unsubscribe(this.name):this.emit("pusher:subscription_succeeded",t.data)}handleSubscriptionCountEvent(t){t.data.subscription_count&&(this.subscriptionCount=t.data.subscription_count),this.emit("pusher:subscription_count",t.data)}subscribe(){this.subscribed||(this.subscriptionPending=!0,this.subscriptionCancelled=!1,this.authorize(this.pusher.connection.socket_id,(t,e)=>{t?(this.subscriptionPending=!1,M.error(t.toString()),this.emit("pusher:subscription_error",Object.assign({},{type:"AuthError",error:t.message},t instanceof at?{status:t.status}:{}))):this.pusher.send_event("pusher:subscribe",{auth:e.auth,channel_data:e.channel_data,channel:this.name})}))}unsubscribe(){this.subscribed=!1,this.pusher.send_event("pusher:unsubscribe",{channel:this.name})}cancelSubscription(){this.subscriptionCancelled=!0}reinstateSubscription(){this.subscriptionCancelled=!1}}class lt extends ut{authorize(t,e){return this.pusher.config.channelAuthorizer({channelName:this.name,socketId:t},e)}}class dt{constructor(){this.reset()}get(t){return Object.prototype.hasOwnProperty.call(this.members,t)?{id:t,info:this.members[t]}:null}each(t){_(this.members,(e,n)=>{t(this.get(n))})}setMyID(t){this.myID=t}onSubscription(t){this.members=t.presence.hash,this.count=t.presence.count,this.me=this.get(this.myID)}addMember(t){return null===this.get(t.user_id)&&this.count++,this.members[t.user_id]=t.user_info,this.get(t.user_id)}removeMember(t){var e=this.get(t.user_id);return e&&(delete this.members[t.user_id],this.count--),e}reset(){this.members={},this.count=0,this.myID=null,this.me=null}}var pt=function(t,e,n,i){return new(n||(n=Promise))((function(s,r){function o(t){try{c(i.next(t))}catch(t){r(t)}}function a(t){try{c(i.throw(t))}catch(t){r(t)}}function c(t){var e;t.done?s(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(o,a)}c((i=i.apply(t,e||[])).next())}))};class ft extends lt{constructor(t,e){super(t,e),this.members=new dt}authorize(t,e){super.authorize(t,(t,n)=>pt(this,void 0,void 0,(function*(){if(!t)if(null!=(n=n).channel_data){var i=JSON.parse(n.channel_data);this.members.setMyID(i.user_id)}else{if(yield this.pusher.user.signinDonePromise,null==this.pusher.user.user_data){let t=ht("authorizationEndpoint");return M.error(`Invalid auth response for channel '${this.name}', expected 'channel_data' field. ${t}, or the user should be signed in.`),void e("Invalid auth response")}this.members.setMyID(this.pusher.user.user_data.id)}e(t,n)})))}handleEvent(t){var e=t.event;if(0===e.indexOf("pusher_internal:"))this.handleInternalEvent(t);else{var n=t.data,i={};t.user_id&&(i.user_id=t.user_id),this.emit(e,n,i)}}handleInternalEvent(t){var e=t.event,n=t.data;switch(e){case"pusher_internal:subscription_succeeded":this.handleSubscriptionSucceededEvent(t);break;case"pusher_internal:subscription_count":this.handleSubscriptionCountEvent(t);break;case"pusher_internal:member_added":var i=this.members.addMember(n);this.emit("pusher:member_added",i);break;case"pusher_internal:member_removed":var s=this.members.removeMember(n);s&&this.emit("pusher:member_removed",s)}}handleSubscriptionSucceededEvent(t){this.subscriptionPending=!1,this.subscribed=!0,this.subscriptionCancelled?this.pusher.unsubscribe(this.name):(this.members.onSubscription(t.data),this.emit("pusher:subscription_succeeded",this.members))}disconnect(){this.members.reset(),super.disconnect()}}var gt=n(1),bt=n(0);class mt extends lt{constructor(t,e,n){super(t,e),this.key=null,this.nacl=n}authorize(t,e){super.authorize(t,(t,n)=>{if(t)return void e(t,n);let i=n.shared_secret;i?(this.key=Object(bt.decode)(i),delete n.shared_secret,e(null,n)):e(new Error("No shared_secret key in auth payload for encrypted channel: "+this.name),null)})}trigger(t,e){throw new st("Client events are not currently supported for encrypted channels")}handleEvent(t){var e=t.event,n=t.data;0!==e.indexOf("pusher_internal:")&&0!==e.indexOf("pusher:")?this.handleEncryptedEvent(e,n):super.handleEvent(t)}handleEncryptedEvent(t,e){if(!this.key)return void M.debug("Received encrypted event before key has been retrieved from the authEndpoint");if(!e.ciphertext||!e.nonce)return void M.error("Unexpected format for encrypted event, expected object with `ciphertext` and `nonce` fields, got: "+e);let n=Object(bt.decode)(e.ciphertext);if(n.length{e?M.error(`Failed to make a request to the authEndpoint: ${r}. Unable to fetch new key, so dropping encrypted event`):(s=this.nacl.secretbox.open(n,i,this.key),null!==s?this.emit(t,this.getDataToEmit(s)):M.error("Failed to decrypt event with new key. Dropping encrypted event"))});this.emit(t,this.getDataToEmit(s))}getDataToEmit(t){let e=Object(gt.decode)(t);try{return JSON.parse(e)}catch(t){return e}}}class vt extends H{constructor(t,e){super(),this.state="initialized",this.connection=null,this.key=t,this.options=e,this.timeline=this.options.timeline,this.usingTLS=this.options.useTLS,this.errorCallbacks=this.buildErrorCallbacks(),this.connectionCallbacks=this.buildConnectionCallbacks(this.errorCallbacks),this.handshakeCallbacks=this.buildHandshakeCallbacks(this.errorCallbacks);var n=ae.getNetwork();n.bind("online",()=>{this.timeline.info({netinfo:"online"}),"connecting"!==this.state&&"unavailable"!==this.state||this.retryIn(0)}),n.bind("offline",()=>{this.timeline.info({netinfo:"offline"}),this.connection&&this.sendActivityCheck()}),this.updateStrategy()}switchCluster(t){this.key=t,this.updateStrategy(),this.retryIn(0)}connect(){this.connection||this.runner||(this.strategy.isSupported()?(this.updateState("connecting"),this.startConnecting(),this.setUnavailableTimer()):this.updateState("failed"))}send(t){return!!this.connection&&this.connection.send(t)}send_event(t,e,n){return!!this.connection&&this.connection.send_event(t,e,n)}disconnect(){this.disconnectInternally(),this.updateState("disconnected")}isUsingTLS(){return this.usingTLS}startConnecting(){var t=(e,n)=>{e?this.runner=this.strategy.connect(0,t):"error"===n.action?(this.emit("error",{type:"HandshakeError",error:n.error}),this.timeline.error({handshakeError:n.error})):(this.abortConnecting(),this.handshakeCallbacks[n.action](n))};this.runner=this.strategy.connect(0,t)}abortConnecting(){this.runner&&(this.runner.abort(),this.runner=null)}disconnectInternally(){(this.abortConnecting(),this.clearRetryTimer(),this.clearUnavailableTimer(),this.connection)&&this.abandonConnection().close()}updateStrategy(){this.strategy=this.options.getStrategy({key:this.key,timeline:this.timeline,useTLS:this.usingTLS})}retryIn(t){this.timeline.info({action:"retry",delay:t}),t>0&&this.emit("connecting_in",Math.round(t/1e3)),this.retryTimer=new g(t||0,()=>{this.disconnectInternally(),this.connect()})}clearRetryTimer(){this.retryTimer&&(this.retryTimer.ensureAborted(),this.retryTimer=null)}setUnavailableTimer(){this.unavailableTimer=new g(this.options.unavailableTimeout,()=>{this.updateState("unavailable")})}clearUnavailableTimer(){this.unavailableTimer&&this.unavailableTimer.ensureAborted()}sendActivityCheck(){this.stopActivityCheck(),this.connection.ping(),this.activityTimer=new g(this.options.pongTimeout,()=>{this.timeline.error({pong_timed_out:this.options.pongTimeout}),this.retryIn(0)})}resetActivityCheck(){this.stopActivityCheck(),this.connection&&!this.connection.handlesActivityChecks()&&(this.activityTimer=new g(this.activityTimeout,()=>{this.sendActivityCheck()}))}stopActivityCheck(){this.activityTimer&&this.activityTimer.ensureAborted()}buildConnectionCallbacks(t){return v({},t,{message:t=>{this.resetActivityCheck(),this.emit("message",t)},ping:()=>{this.send_event("pusher:pong",{})},activity:()=>{this.resetActivityCheck()},error:t=>{this.emit("error",t)},closed:()=>{this.abandonConnection(),this.shouldRetry()&&this.retryIn(1e3)}})}buildHandshakeCallbacks(t){return v({},t,{connected:t=>{this.activityTimeout=Math.min(this.options.activityTimeout,t.activityTimeout,t.connection.activityTimeout||1/0),this.clearUnavailableTimer(),this.setConnection(t.connection),this.socket_id=this.connection.id,this.updateState("connected",{socket_id:this.socket_id})}})}buildErrorCallbacks(){let t=t=>e=>{e.error&&this.emit("error",{type:"WebSocketError",error:e.error}),t(e)};return{tls_only:t(()=>{this.usingTLS=!0,this.updateStrategy(),this.retryIn(0)}),refused:t(()=>{this.disconnect()}),backoff:t(()=>{this.retryIn(1e3)}),retry:t(()=>{this.retryIn(0)})}}setConnection(t){for(var e in this.connection=t,this.connectionCallbacks)this.connection.bind(e,this.connectionCallbacks[e]);this.resetActivityCheck()}abandonConnection(){if(this.connection){for(var t in this.stopActivityCheck(),this.connectionCallbacks)this.connection.unbind(t,this.connectionCallbacks[t]);var e=this.connection;return this.connection=null,e}}updateState(t,e){var n=this.state;if(this.state=t,n!==t){var i=t;"connected"===i&&(i+=" with new socket ID "+e.socket_id),M.debug("State changed",n+" -> "+i),this.timeline.info({state:t,params:e}),this.emit("state_change",{previous:n,current:t}),this.emit(t,e)}}shouldRetry(){return"connecting"===this.state||"connected"===this.state}}class yt{constructor(){this.channels={}}add(t,e){return this.channels[t]||(this.channels[t]=function(t,e){if(0===t.indexOf("private-encrypted-")){if(e.config.nacl)return St.createEncryptedChannel(t,e,e.config.nacl);let n="Tried to subscribe to a private-encrypted- channel but no nacl implementation available",i=ht("encryptedChannelSupport");throw new st(`${n}. ${i}`)}if(0===t.indexOf("private-"))return St.createPrivateChannel(t,e);if(0===t.indexOf("presence-"))return St.createPresenceChannel(t,e);if(0===t.indexOf("#"))throw new et('Cannot create a channel with name "'+t+'".');return St.createChannel(t,e)}(t,e)),this.channels[t]}all(){return function(t){var e=[];return _(t,(function(t){e.push(t)})),e}(this.channels)}find(t){return this.channels[t]}remove(t){var e=this.channels[t];return delete this.channels[t],e}disconnect(){_(this.channels,(function(t){t.disconnect()}))}}var St={createChannels:()=>new yt,createConnectionManager:(t,e)=>new vt(t,e),createChannel:(t,e)=>new ut(t,e),createPrivateChannel:(t,e)=>new lt(t,e),createPresenceChannel:(t,e)=>new ft(t,e),createEncryptedChannel:(t,e,n)=>new mt(t,e,n),createTimelineSender:(t,e)=>new Z(t,e),createHandshake:(t,e)=>new Q(t,e),createAssistantToTheTransportManager:(t,e,n)=>new G(t,e,n)};class _t{constructor(t){this.options=t||{},this.livesLeft=this.options.lives||1/0}getAssistant(t){return St.createAssistantToTheTransportManager(this,t,{minPingDelay:this.options.minPingDelay,maxPingDelay:this.options.maxPingDelay})}isAlive(){return this.livesLeft>0}reportDeath(){this.livesLeft-=1}}class wt{constructor(t,e){this.strategies=t,this.loop=Boolean(e.loop),this.failFast=Boolean(e.failFast),this.timeout=e.timeout,this.timeoutLimit=e.timeoutLimit}isSupported(){return O(this.strategies,m.method("isSupported"))}connect(t,e){var n=this.strategies,i=0,s=this.timeout,r=null,o=(a,c)=>{c?e(null,c):(i+=1,this.loop&&(i%=n.length),i0&&(s=new g(n.timeout,(function(){r.abort(),i(!0)}))),r=t.connect(e,(function(t,e){t&&s&&s.isRunning()&&!n.failFast||(s&&s.ensureAborted(),i(t,e))})),{abort:function(){s&&s.ensureAborted(),r.abort()},forceMinPriority:function(t){r.forceMinPriority(t)}}}}class Ct{constructor(t){this.strategies=t}isSupported(){return O(this.strategies,m.method("isSupported"))}connect(t,e){return function(t,e,n){var i=k(t,(function(t,i,s,r){return t.connect(e,n(i,r))}));return{abort:function(){C(i,kt)},forceMinPriority:function(t){C(i,(function(e){e.forceMinPriority(t)}))}}}(this.strategies,t,(function(t,n){return function(i,s){n[t].error=i,i?function(t){return function(t,e){for(var n=0;n=m.now()){var o=this.transports[i.transport];o&&(["ws","wss"].includes(i.transport)||s>3?(this.timeline.info({cached:!0,transport:i.transport,latency:i.latency}),r.push(new wt([o],{timeout:2*i.latency+1e3,failFast:!0}))):s++)}var a=m.now(),c=r.pop().connect(t,(function i(o,h){o?(Ot(n),r.length>0?(a=m.now(),c=r.pop().connect(t,i)):e(o)):(!function(t,e,n,i){var s=ae.getLocalStorage();if(s)try{s[Pt(t)]=L({timestamp:m.now(),transport:e,latency:n,cacheSkipCount:i})}catch(t){}}(n,h.transport.name,m.now()-a,s),e(null,h))}));return{abort:function(){c.abort()},forceMinPriority:function(e){t=e,c&&c.forceMinPriority(e)}}}}function Pt(t){return"pusherTransport"+(t?"TLS":"NonTLS")}function Ot(t){var e=ae.getLocalStorage();if(e)try{delete e[Pt(t)]}catch(t){}}class Et{constructor(t,{delay:e}){this.strategy=t,this.options={delay:e}}isSupported(){return this.strategy.isSupported()}connect(t,e){var n,i=this.strategy,s=new g(this.options.delay,(function(){n=i.connect(t,e)}));return{abort:function(){s.ensureAborted(),n&&n.abort()},forceMinPriority:function(e){t=e,n&&n.forceMinPriority(e)}}}}class xt{constructor(t,e,n){this.test=t,this.trueBranch=e,this.falseBranch=n}isSupported(){return(this.test()?this.trueBranch:this.falseBranch).isSupported()}connect(t,e){return(this.test()?this.trueBranch:this.falseBranch).connect(t,e)}}class Lt{constructor(t){this.strategy=t}isSupported(){return this.strategy.isSupported()}connect(t,e){var n=this.strategy.connect(t,(function(t,i){i&&n.abort(),e(t,i)}));return n}}function At(t){return function(){return t.isSupported()}}var Rt=function(t,e,n){var i={};function s(e,s,r,o,a){var c=n(t,e,s,r,o,a);return i[e]=c,c}var r,o=Object.assign({},e,{hostNonTLS:t.wsHost+":"+t.wsPort,hostTLS:t.wsHost+":"+t.wssPort,httpPath:t.wsPath}),a=v({},o,{useTLS:!0}),c=Object.assign({},e,{hostNonTLS:t.httpHost+":"+t.httpPort,hostTLS:t.httpHost+":"+t.httpsPort,httpPath:t.httpPath}),h={loop:!0,timeout:15e3,timeoutLimit:6e4},u=new _t({minPingDelay:1e4,maxPingDelay:t.activityTimeout}),l=new _t({lives:2,minPingDelay:1e4,maxPingDelay:t.activityTimeout}),d=s("ws","ws",3,o,u),p=s("wss","ws",3,a,u),f=s("xhr_streaming","xhr_streaming",1,c,l),g=s("xhr_polling","xhr_polling",1,c),b=new wt([d],h),m=new wt([p],h),y=new wt([f],h),S=new wt([g],h),_=new wt([new xt(At(y),new Ct([y,new Et(S,{delay:4e3})]),S)],h);return r=e.useTLS?new Ct([b,new Et(_,{delay:2e3})]):new Ct([b,new Et(m,{delay:2e3}),new Et(_,{delay:5e3})]),new Tt(new Lt(new xt(At(d),r,_)),i,{ttl:18e5,timeline:e.timeline,useTLS:e.useTLS})};class It extends H{constructor(t,e,n){super(),this.hooks=t,this.method=e,this.url=n}start(t){this.position=0,this.xhr=this.hooks.getRequest(this),this.unloader=()=>{this.close()},ae.addUnloadListener(this.unloader),this.xhr.open(this.method,this.url,!0),this.xhr.setRequestHeader&&this.xhr.setRequestHeader("Content-Type","application/json"),this.xhr.send(t)}close(){this.unloader&&(ae.removeUnloadListener(this.unloader),this.unloader=null),this.xhr&&(this.hooks.abortRequest(this.xhr),this.xhr=null)}onChunk(t,e){for(;;){var n=this.advanceBuffer(e);if(!n)break;this.emit("chunk",{status:t,data:n})}this.isBufferTooLong(e)&&this.emit("buffer_too_long")}advanceBuffer(t){var e=t.slice(this.position),n=e.indexOf("\n");return-1!==n?(this.position+=n+1,e.slice(0,n)):null}isBufferTooLong(t){return this.position===t.length&&t.length>262144}}var jt;!function(t){t[t.CONNECTING=0]="CONNECTING",t[t.OPEN=1]="OPEN",t[t.CLOSED=3]="CLOSED"}(jt||(jt={}));var Dt=jt,Nt=1;function Ut(t){var e=-1===t.indexOf("?")?"?":"&";return t+e+"t="+ +new Date+"&n="+Nt++}function Ht(t){return ae.randomInt(t)}var Mt=class{constructor(t,e){this.hooks=t,this.session=Ht(1e3)+"/"+function(t){for(var e=[],n=0;n{this.onChunk(t)}),this.stream.bind("finished",t=>{this.hooks.onFinished(this,t)}),this.stream.bind("buffer_too_long",()=>{this.reconnect()});try{this.stream.start()}catch(t){m.defer(()=>{this.onError(t),this.onClose(1006,"Could not start streaming",!1)})}}closeStream(){this.stream&&(this.stream.unbind_all(),this.stream.close(),this.stream=null)}},zt={getReceiveURL:function(t,e){return t.base+"/"+e+"/xhr_streaming"+t.queryString},onHeartbeat:function(t){t.sendRaw("[]")},sendHeartbeat:function(t){t.sendRaw("[]")},onFinished:function(t,e){t.onClose(1006,"Connection interrupted ("+e+")",!1)}},Bt={getReceiveURL:function(t,e){return t.base+"/"+e+"/xhr"+t.queryString},onHeartbeat:function(){},sendHeartbeat:function(t){t.sendRaw("[]")},onFinished:function(t,e){200===e?t.reconnect():t.onClose(1006,"Connection interrupted ("+e+")",!1)}},qt={getRequest:function(t){var e=new(ae.getXHRAPI());return e.onreadystatechange=e.onprogress=function(){switch(e.readyState){case 3:e.responseText&&e.responseText.length>0&&t.onChunk(e.status,e.responseText);break;case 4:e.responseText&&e.responseText.length>0&&t.onChunk(e.status,e.responseText),t.emit("finished",e.status),t.close()}},e},abortRequest:function(t){t.onreadystatechange=null,t.abort()}},Ft={getDefaultStrategy:Rt,Transports:X,transportConnectionInitializer:function(){this.timeline.info(this.buildTimelineMessage({transport:this.name+(this.options.useTLS?"s":"")})),this.hooks.isInitialized()?this.changeState("initialized"):this.onClose()},HTTPFactory:{createStreamingSocket(t){return this.createSocket(zt,t)},createPollingSocket(t){return this.createSocket(Bt,t)},createSocket:(t,e)=>new Mt(t,e),createXHR(t,e){return this.createRequest(qt,t,e)},createRequest:(t,e,n)=>new It(t,e,n)},setup(t){t.ready()},getLocalStorage(){},getClientFeatures:()=>w(P({ws:X.ws},(function(t){return t.isSupported({})}))),getProtocol:()=>"http:",isXHRSupported:()=>!0,createSocketRequest(t,e){if(this.isXHRSupported())return this.HTTPFactory.createXHR(t,e);throw"Cross-origin HTTP requests are not supported"},createXHR(){return new(this.getXHRAPI())},createWebSocket(t){return new(this.getWebSocketAPI())(t)},addUnloadListener(t){},removeUnloadListener(t){}};var $t=new class extends H{isOnline(){return!0}},Jt=function(t,e,n,i,s){var r=new Headers;for(var o in r.set("Content-Type","application/x-www-form-urlencoded"),n.headers)r.set(o,n.headers[o]);if(null!=n.headersProvider){const t=n.headersProvider();for(var o in t)r.set(o,t[o])}var a=e,c=new Request(n.endpoint,{headers:r,body:a,credentials:"same-origin",method:"POST"});return fetch(c).then(t=>{let{status:e}=t;if(200===e)return t.text();throw new at(e,`Could not get ${i.toString()} info from your auth endpoint, status: ${e}`)}).then(t=>{let e;try{e=JSON.parse(t)}catch(e){throw new at(200,`JSON returned from ${i.toString()} endpoint was invalid, yet status code was 200. Data was: ${t}`)}s(null,e)}).catch(t=>{s(t,null)})},Wt={name:"xhr",getAgent:function(t,e){return function(n,i){var s="http"+(e?"s":"")+"://"+(t.host||t.options.host)+t.options.path,r=x(n);fetch(s+="/2?"+r).then(t=>{if(200!==t.status)throw`received ${t.status} from stats.pusher.com`;return t.json()}).then(({host:e})=>{e&&(t.host=e)}).catch(t=>{M.debug("TimelineSender Error: ",t)})}}};const{getDefaultStrategy:Xt,Transports:Gt,setup:Vt,getProtocol:Yt,isXHRSupported:Kt,getLocalStorage:Qt,createXHR:Zt,createWebSocket:te,addUnloadListener:ee,removeUnloadListener:ne,transportConnectionInitializer:ie,createSocketRequest:se,HTTPFactory:re}=Ft;var oe,ae={getDefaultStrategy:Xt,Transports:Gt,setup:Vt,getProtocol:Yt,isXHRSupported:Kt,getLocalStorage:Qt,createXHR:Zt,createWebSocket:te,addUnloadListener:ee,removeUnloadListener:ne,transportConnectionInitializer:ie,createSocketRequest:se,HTTPFactory:re,TimelineTransport:Wt,getAuthorizers:()=>({ajax:Jt}),getWebSocketAPI:()=>WebSocket,getXHRAPI:()=>XMLHttpRequest,getNetwork:()=>$t,randomInt:t=>Math.floor((globalThis.crypto||globalThis.msCrypto).getRandomValues(new Uint32Array(1))[0]/Math.pow(2,32)*t)};!function(t){t[t.ERROR=3]="ERROR",t[t.INFO=6]="INFO",t[t.DEBUG=7]="DEBUG"}(oe||(oe={}));var ce=oe;class he{constructor(t,e,n){this.key=t,this.session=e,this.events=[],this.options=n||{},this.sent=0,this.uniqueID=0}log(t,e){t<=this.options.level&&(this.events.push(v({},e,{timestamp:m.now()})),this.options.limit&&this.events.length>this.options.limit&&this.events.shift())}error(t){this.log(ce.ERROR,t)}info(t){this.log(ce.INFO,t)}debug(t){this.log(ce.DEBUG,t)}isEmpty(){return 0===this.events.length}send(t,e){var n=v({session:this.session,bundle:this.sent+1,key:this.key,lib:"js",version:this.options.version,cluster:this.options.cluster,features:this.options.features,timeline:this.events},this.options.params);return this.events=[],t(n,(t,n)=>{t||this.sent++,e&&e(t,n)}),!0}generateUniqueID(){return this.uniqueID++,this.uniqueID}}class ue{constructor(t,e,n,i){this.name=t,this.priority=e,this.transport=n,this.options=i||{}}isSupported(){return this.transport.isSupported({useTLS:this.options.useTLS})}connect(t,e){if(!this.isSupported())return le(new ot,e);if(this.priority{n||(h(),s?s.close():i.close())},forceMinPriority:t=>{n||this.priority{if(void 0===ae.getAuthorizers()[t.transport])throw`'${t.transport}' is not a recognized auth transport`;return(e,n)=>{const i=((t,e)=>{var n="socket_id="+encodeURIComponent(t.socketId);for(var i in e.params)n+="&"+encodeURIComponent(i)+"="+encodeURIComponent(e.params[i]);if(null!=e.paramsProvider){let t=e.paramsProvider();for(var i in t)n+="&"+encodeURIComponent(i)+"="+encodeURIComponent(t[i])}return n})(e,t);ae.getAuthorizers()[t.transport](ae,i,t,pe.UserAuthentication,n)}};var me=t=>{if(void 0===ae.getAuthorizers()[t.transport])throw`'${t.transport}' is not a recognized auth transport`;return(e,n)=>{const i=((t,e)=>{var n="socket_id="+encodeURIComponent(t.socketId);for(var i in n+="&channel_name="+encodeURIComponent(t.channelName),e.params)n+="&"+encodeURIComponent(i)+"="+encodeURIComponent(e.params[i]);if(null!=e.paramsProvider){let t=e.paramsProvider();for(var i in t)n+="&"+encodeURIComponent(i)+"="+encodeURIComponent(t[i])}return n})(e,t);ae.getAuthorizers()[t.transport](ae,i,t,pe.ChannelAuthorization,n)}};function ve(t,e){let n={activityTimeout:t.activityTimeout||A.activityTimeout,cluster:t.cluster,httpPath:t.httpPath||A.httpPath,httpPort:t.httpPort||A.httpPort,httpsPort:t.httpsPort||A.httpsPort,pongTimeout:t.pongTimeout||A.pongTimeout,statsHost:t.statsHost||A.stats_host,unavailableTimeout:t.unavailableTimeout||A.unavailableTimeout,wsPath:t.wsPath||A.wsPath,wsPort:t.wsPort||A.wsPort,wssPort:t.wssPort||A.wssPort,enableStats:we(t),httpHost:ye(t),useTLS:_e(t),wsHost:Se(t),userAuthenticator:Ce(t),channelAuthorizer:ke(t,e)};return"disabledTransports"in t&&(n.disabledTransports=t.disabledTransports),"enabledTransports"in t&&(n.enabledTransports=t.enabledTransports),"ignoreNullOrigin"in t&&(n.ignoreNullOrigin=t.ignoreNullOrigin),"timelineParams"in t&&(n.timelineParams=t.timelineParams),"nacl"in t&&(n.nacl=t.nacl),n}function ye(t){return t.httpHost?t.httpHost:t.cluster?`sockjs-${t.cluster}.pusher.com`:A.httpHost}function Se(t){return t.wsHost?t.wsHost:`ws-${t.cluster}.pusher.com`}function _e(t){return"https:"===ae.getProtocol()||!1!==t.forceTLS}function we(t){return"enableStats"in t?t.enableStats:"disableStats"in t&&!t.disableStats}function Ce(t){const e=Object.assign(Object.assign({},A.userAuthentication),t.userAuthentication);return"customHandler"in e&&null!=e.customHandler?e.customHandler:be(e)}function ke(t,e){const n=function(t,e){let n;return"channelAuthorization"in t?n=Object.assign(Object.assign({},A.channelAuthorization),t.channelAuthorization):(n={transport:t.authTransport||A.authTransport,endpoint:t.authEndpoint||A.authEndpoint},"auth"in t&&("params"in t.auth&&(n.params=t.auth.params),"headers"in t.auth&&(n.headers=t.auth.headers)),"authorizer"in t&&(n.customHandler=((t,e,n)=>{const i={authTransport:e.transport,authEndpoint:e.endpoint,auth:{params:e.params,headers:e.headers}};return(e,s)=>{const r=t.channel(e.channelName);n(r,i).authorize(e.socketId,s)}})(e,n,t.authorizer))),n}(t,e);return"customHandler"in n&&null!=n.customHandler?n.customHandler:me(n)}class Te extends H{constructor(t){super((function(t,e){M.debug("No callbacks on watchlist events for "+t)})),this.pusher=t,this.bindWatchlistInternalEvent()}handleEvent(t){t.data.events.forEach(t=>{this.emit(t.name,t)})}bindWatchlistInternalEvent(){this.pusher.connection.bind("message",t=>{"pusher_internal:watchlist_events"===t.event&&this.handleEvent(t)})}}var Pe=function(){let t,e;return{promise:new Promise((n,i)=>{t=n,e=i}),resolve:t,reject:e}};class Oe extends H{constructor(t){super((function(t,e){M.debug("No callbacks on user for "+t)})),this.signin_requested=!1,this.user_data=null,this.serverToUserChannel=null,this.signinDonePromise=null,this._signinDoneResolve=null,this._onAuthorize=(t,e)=>{if(t)return M.warn("Error during signin: "+t),void this._cleanup();this.pusher.send_event("pusher:signin",{auth:e.auth,user_data:e.user_data})},this.pusher=t,this.pusher.connection.bind("state_change",({previous:t,current:e})=>{"connected"!==t&&"connected"===e&&this._signin(),"connected"===t&&"connected"!==e&&(this._cleanup(),this._newSigninPromiseIfNeeded())}),this.watchlist=new Te(t),this.pusher.connection.bind("message",t=>{"pusher:signin_success"===t.event&&this._onSigninSuccess(t.data),this.serverToUserChannel&&this.serverToUserChannel.name===t.channel&&this.serverToUserChannel.handleEvent(t)})}signin(){this.signin_requested||(this.signin_requested=!0,this._signin())}_signin(){this.signin_requested&&(this._newSigninPromiseIfNeeded(),"connected"===this.pusher.connection.state&&this.pusher.config.userAuthenticator({socketId:this.pusher.connection.socket_id},this._onAuthorize))}_onSigninSuccess(t){try{this.user_data=JSON.parse(t.user_data)}catch(e){return M.error("Failed parsing user data after signin: "+t.user_data),void this._cleanup()}if("string"!=typeof this.user_data.id||""===this.user_data.id)return M.error("user_data doesn't contain an id. user_data: "+this.user_data),void this._cleanup();this._signinDoneResolve(),this._subscribeChannels()}_subscribeChannels(){this.serverToUserChannel=new ut("#server-to-user-"+this.user_data.id,this.pusher),this.serverToUserChannel.bind_global((t,e)=>{0!==t.indexOf("pusher_internal:")&&0!==t.indexOf("pusher:")&&this.emit(t,e)}),(t=>{t.subscriptionPending&&t.subscriptionCancelled?t.reinstateSubscription():t.subscriptionPending||"connected"!==this.pusher.connection.state||t.subscribe()})(this.serverToUserChannel)}_cleanup(){this.user_data=null,this.serverToUserChannel&&(this.serverToUserChannel.unbind_all(),this.serverToUserChannel.disconnect(),this.serverToUserChannel=null),this.signin_requested&&this._signinDoneResolve()}_newSigninPromiseIfNeeded(){if(!this.signin_requested)return;if(this.signinDonePromise&&!this.signinDonePromise.done)return;const{promise:t,resolve:e,reject:n}=Pe();t.done=!1;const i=()=>{t.done=!0};t.then(i).catch(i),this.signinDonePromise=t,this._signinDoneResolve=e}}class Ee{static ready(){Ee.isReady=!0;for(var t=0,e=Ee.instances.length;tae.getDefaultStrategy(this.config,t,fe),timeline:this.timeline,activityTimeout:this.config.activityTimeout,pongTimeout:this.config.pongTimeout,unavailableTimeout:this.config.unavailableTimeout,useTLS:Boolean(this.config.useTLS)}),this.connection.bind("connected",()=>{this.subscribeAll(),this.timelineSender&&this.timelineSender.send(this.connection.isUsingTLS())}),this.connection.bind("message",t=>{var e=0===t.event.indexOf("pusher_internal:");if(t.channel){var n=this.channel(t.channel);n&&n.handleEvent(t)}e||this.global_emitter.emit(t.event,t.data)}),this.connection.bind("connecting",()=>{this.channels.disconnect()}),this.connection.bind("disconnected",()=>{this.channels.disconnect()}),this.connection.bind("error",t=>{M.warn(t)}),Ee.instances.push(this),this.timeline.info({instances:Ee.instances.length}),this.user=new Oe(this),Ee.isReady&&this.connect()}switchCluster(t){const{appKey:e,cluster:n}=t;this.key=e,this.options=Object.assign(Object.assign({},this.options),{cluster:n}),this.config=ve(this.options,this),this.connection.switchCluster(this.key)}channel(t){return this.channels.find(t)}allChannels(){return this.channels.all()}connect(){if(this.connection.connect(),this.timelineSender&&!this.timelineSenderTimer){var t=this.connection.isUsingTLS(),e=this.timelineSender;this.timelineSenderTimer=new b(6e4,(function(){e.send(t)}))}}disconnect(){this.connection.disconnect(),this.timelineSenderTimer&&(this.timelineSenderTimer.ensureAborted(),this.timelineSenderTimer=null)}bind(t,e,n){return this.global_emitter.bind(t,e,n),this}unbind(t,e,n){return this.global_emitter.unbind(t,e,n),this}bind_global(t){return this.global_emitter.bind_global(t),this}unbind_global(t){return this.global_emitter.unbind_global(t),this}unbind_all(t){return this.global_emitter.unbind_all(),this}subscribeAll(){var t;for(t in this.channels.channels)this.channels.channels.hasOwnProperty(t)&&this.subscribe(t)}subscribe(t){var e=this.channels.add(t,this);return e.subscriptionPending&&e.subscriptionCancelled?e.reinstateSubscription():e.subscriptionPending||"connected"!==this.connection.state||e.subscribe(),e}unsubscribe(t){var e=this.channels.find(t);e&&e.subscriptionPending?e.cancelSubscription():(e=this.channels.remove(t))&&e.subscribed&&e.unsubscribe()}send_event(t,e,n){return this.connection.send_event(t,e,n)}shouldUseTLS(){return this.config.useTLS}signin(){this.user.signin()}}Ee.instances=[],Ee.isReady=!1,Ee.logToConsole=!1,Ee.Runtime=ae,Ee.ScriptReceivers=ae.ScriptReceivers,Ee.DependenciesReceivers=ae.DependenciesReceivers,Ee.auth_callbacks=ae.auth_callbacks;var xe=e.default=Ee;ae.setup(Ee)}])})); //# sourceMappingURL=pusher.worker.min.js.map \ No newline at end of file diff --git a/dist/worker/pusher.worker.min.js.map b/dist/worker/pusher.worker.min.js.map index 23e573e31..676f9e479 100644 --- a/dist/worker/pusher.worker.min.js.map +++ b/dist/worker/pusher.worker.min.js.map @@ -1 +1 @@ -{"version":3,"sources":["webpack://Pusher/webpack/universalModuleDefinition","webpack://Pusher/webpack/bootstrap","webpack://Pusher/./node_modules/@stablelib/base64/base64.ts","webpack://Pusher/./node_modules/@stablelib/utf8/utf8.ts","webpack://Pusher/./src/core/pusher.js","webpack://Pusher/./src/core/base64.ts","webpack://Pusher/./src/core/utils/timers/abstract_timer.ts","webpack://Pusher/./src/core/utils/timers/index.ts","webpack://Pusher/./src/core/util.ts","webpack://Pusher/./src/core/utils/collections.ts","webpack://Pusher/./src/core/defaults.ts","webpack://Pusher/./src/core/transports/url_schemes.ts","webpack://Pusher/./src/core/events/callback_registry.ts","webpack://Pusher/./src/core/events/dispatcher.ts","webpack://Pusher/./src/core/logger.ts","webpack://Pusher/./src/core/transports/transport_connection.ts","webpack://Pusher/./src/core/transports/transport.ts","webpack://Pusher/./src/runtimes/isomorphic/transports/transports.ts","webpack://Pusher/./src/core/transports/assistant_to_the_transport_manager.ts","webpack://Pusher/./src/core/connection/protocol/protocol.ts","webpack://Pusher/./src/core/connection/connection.ts","webpack://Pusher/./src/core/connection/handshake/index.ts","webpack://Pusher/./src/core/timeline/timeline_sender.ts","webpack://Pusher/./src/core/errors.ts","webpack://Pusher/./src/core/utils/url_store.ts","webpack://Pusher/./src/core/channels/channel.ts","webpack://Pusher/./src/core/channels/private_channel.ts","webpack://Pusher/./src/core/channels/members.ts","webpack://Pusher/./src/core/channels/presence_channel.ts","webpack://Pusher/./src/core/channels/encrypted_channel.ts","webpack://Pusher/./src/core/connection/connection_manager.ts","webpack://Pusher/./src/core/channels/channels.ts","webpack://Pusher/./src/core/utils/factory.ts","webpack://Pusher/./src/core/transports/transport_manager.ts","webpack://Pusher/./src/core/strategies/sequential_strategy.ts","webpack://Pusher/./src/core/strategies/best_connected_ever_strategy.ts","webpack://Pusher/./src/core/strategies/websocket_prioritized_cached_strategy.ts","webpack://Pusher/./src/core/strategies/delayed_strategy.ts","webpack://Pusher/./src/core/strategies/if_strategy.ts","webpack://Pusher/./src/core/strategies/first_connected_strategy.ts","webpack://Pusher/./src/runtimes/isomorphic/default_strategy.ts","webpack://Pusher/./src/core/http/http_request.ts","webpack://Pusher/./src/core/http/state.ts","webpack://Pusher/./src/core/http/http_socket.ts","webpack://Pusher/./src/core/http/http_streaming_socket.ts","webpack://Pusher/./src/core/http/http_polling_socket.ts","webpack://Pusher/./src/runtimes/isomorphic/http/http_xhr_request.ts","webpack://Pusher/./src/runtimes/isomorphic/runtime.ts","webpack://Pusher/./src/runtimes/isomorphic/transports/transport_connection_initializer.ts","webpack://Pusher/./src/runtimes/isomorphic/http/http.ts","webpack://Pusher/./src/runtimes/worker/net_info.ts","webpack://Pusher/./src/runtimes/worker/auth/fetch_auth.ts","webpack://Pusher/./src/runtimes/worker/timeline/fetch_timeline.ts","webpack://Pusher/./src/runtimes/worker/runtime.ts","webpack://Pusher/./src/core/timeline/level.ts","webpack://Pusher/./src/core/timeline/timeline.ts","webpack://Pusher/./src/core/strategies/transport_strategy.ts","webpack://Pusher/./src/core/strategies/strategy_builder.ts","webpack://Pusher/./src/core/auth/options.ts","webpack://Pusher/./src/core/auth/user_authenticator.ts","webpack://Pusher/./src/core/auth/channel_authorizer.ts","webpack://Pusher/./src/core/config.ts","webpack://Pusher/./src/core/auth/deprecated_channel_authorizer.ts","webpack://Pusher/./src/core/watchlist.ts","webpack://Pusher/./src/core/utils/flat_promise.ts","webpack://Pusher/./src/core/user.ts","webpack://Pusher/./src/core/pusher.ts","webpack://Pusher/./src/core/options.ts"],"names":["root","factory","exports","module","define","amd","this","installedModules","__webpack_require__","moduleId","i","l","modules","call","m","c","d","name","getter","o","Object","defineProperty","enumerable","get","r","Symbol","toStringTag","value","t","mode","__esModule","ns","create","key","bind","n","object","property","prototype","hasOwnProperty","p","s","_paddingCharacter","encodedLength","length","encode","data","out","_encodeByte","left","maxDecodedLength","decodedLength","_getPaddingLength","decode","Uint8Array","paddingLength","op","haveBad","v0","v1","v2","v3","_decodeChar","charCodeAt","Error","b","result","String","fromCharCode","Coder","stdCoder","URLSafeCoder","urlSafeCoder","INVALID_UTF8","arr","pos","chars","min","n1","n2","n3","push","join","default","b64chars","b64tab","charAt","cb_utob","cc","utob","u","replace","cb_encode","ccc","padlen","ord","btoa","set","clear","delay","callback","timer","clearTimeout","clearInterval","super","setTimeout","setInterval","now","Date","valueOf","defer","args","boundArguments","Array","slice","arguments","apply","concat","extend","target","sources","extensions","constructor","stringify","safeJSONStringify","arrayIndexOf","array","item","nativeIndexOf","indexOf","objectApply","f","keys","_","context","map","filter","test","filterObject","Boolean","any","encodeParamsObject","encodeURIComponent","toString","buildQueryString","params","undefined","method","source","JSON","e","objects","paths","derez","path","nu","$ref","VERSION","PROTOCOL","wsPort","wssPort","wsPath","httpHost","httpPort","httpsPort","httpPath","stats_host","authEndpoint","authTransport","activityTimeout","pongTimeout","unavailableTimeout","userAuthentication","endpoint","transport","channelAuthorization","cdn_http","cdn_https","dependency_suffix","getGenericURL","baseScheme","useTLS","hostTLS","hostNonTLS","getGenericPath","queryString","ws","getInitial","http","_callbacks","prefix","prefixedEventName","fn","names","removeCallback","removeAllCallbacks","binding","failThrough","callbacks","global_callbacks","eventName","add","remove","unbind","unbind_global","metadata","globalLog","message","console","log","globalLogWarn","globalLogError","warn","error","defaultLoggingFunction","logToConsole","hooks","priority","options","initialize","transportConnectionInitializer","state","timeline","id","generateUniqueID","handlesActivityChecks","supportsPing","socket","url","urls","getSocket","onError","changeState","bindListeners","debug","close","send","ping","beforeOpen","getPath","onopen","emit","type","buildTimelineMessage","closeEvent","code","reason","wasClean","unbindListeners","onOpen","onerror","onclose","onClose","onmessage","onMessage","onactivity","onActivity","info","cid","environment","isSupported","WSTransport","isInitialized","getWebSocketAPI","createWebSocket","httpConfiguration","streamingConfiguration","HTTPFactory","createStreamingSocket","pollingConfiguration","createPollingSocket","xhrConfiguration","isXHRSupported","xhr_streaming","xhr_polling","manager","minPingDelay","maxPingDelay","pingDelay","connection","createConnection","openTimestamp","onClosed","reportDeath","lifespan","Math","max","isAlive","Protocol","decodeMessage","messageEvent","messageData","parse","pusherEventData","pusherEvent","event","channel","user_id","encodeMessage","processHandshake","activity_timeout","action","socket_id","getCloseAction","getCloseError","send_event","listeners","activity","closed","handleCloseEvent","listener","finish","isEmpty","TimelineTransport","getAgent","BadEventName","msg","setPrototypeOf","BadChannelName","TransportPriorityTooLow","TransportClosed","UnsupportedFeature","UnsupportedTransport","UnsupportedStrategy","HTTPAuthError","status","urlStore","baseUrl","authenticationEndpoint","authorizationEndpoint","javascriptQuickStart","triggeringClientEvents","encryptedChannelSupport","fullUrl","urlObj","pusher","subscribed","subscriptionPending","subscriptionCancelled","socketId","auth","suffix","handleSubscriptionSucceededEvent","handleSubscriptionCountEvent","unsubscribe","subscription_count","subscriptionCount","authorize","assign","channel_data","config","channelAuthorizer","channelName","reset","members","member","myID","subscriptionData","presence","hash","count","me","memberData","user_info","authData","channelData","setMyID","user","signinDonePromise","user_data","handleInternalEvent","addedMember","addMember","removedMember","removeMember","onSubscription","disconnect","nacl","sharedSecret","handleEncryptedEvent","handleEvent","ciphertext","nonce","cipherText","secretbox","overheadLength","nonceLength","bytes","open","getDataToEmit","raw","usingTLS","errorCallbacks","buildErrorCallbacks","connectionCallbacks","buildConnectionCallbacks","handshakeCallbacks","buildHandshakeCallbacks","Network","getNetwork","netinfo","retryIn","sendActivityCheck","updateStrategy","runner","strategy","updateState","startConnecting","setUnavailableTimer","disconnectInternally","handshake","connect","handshakeError","abortConnecting","abort","clearRetryTimer","clearUnavailableTimer","abandonConnection","getStrategy","round","retryTimer","ensureAborted","unavailableTimer","stopActivityCheck","activityTimer","pong_timed_out","resetActivityCheck","shouldRetry","connected","Infinity","setConnection","withErrorEmitted","tls_only","refused","backoff","retry","newState","previousState","newStateDescription","previous","current","channels","createEncryptedChannel","errMsg","createPrivateChannel","createPresenceChannel","createChannel","values","createChannels","createConnectionManager","createTimelineSender","createHandshake","createAssistantToTheTransportManager","livesLeft","lives","strategies","loop","failFast","timeout","timeoutLimit","minPriority","tryNextStrategy","tryStrategy","forceMinPriority","isRunning","callbackBuilder","runners","rs","abortRunner","allRunnersFailed","aborted","transports","ttl","storage","getLocalStorage","serializedCache","getTransportCacheKey","flushTransportCache","fetchTransportCache","cacheSkipCount","timestamp","includes","cached","latency","startTimestamp","pop","cb","storeTransportCache","number","IfStrategy","trueBranch","falseBranch","FirstConnectedStrategy","testSupportsStrategy","baseOptions","defineTransport","definedTransports","defineTransportStrategy","wsStrategy","ws_options","wsHost","wss_options","http_options","timeouts","ws_manager","streaming_manager","ws_transport","wss_transport","xhr_streaming_transport","xhr_polling_transport","ws_loop","wss_loop","streaming_loop","polling_loop","http_loop","payload","position","xhr","getRequest","unloader","addUnloadListener","setRequestHeader","removeUnloadListener","abortRequest","chunk","advanceBuffer","isBufferTooLong","buffer","unreadData","endOfLinePosition","State","autoIncrement","getUniqueURL","separator","randomNumber","randomInt","session","randomString","location","parts","exec","base","getLocation","readyState","CONNECTING","openStream","sendRaw","sendHeartbeat","OPEN","createSocketRequest","start","closeStream","CLOSED","onEvent","onHeartbeat","hostname","urlParts","stream","getReceiveURL","onChunk","onFinished","reconnect","unbind_all","getXHRAPI","onreadystatechange","onprogress","responseText","getDefaultStrategy","Transports","createSocket","createRequest","PusherClass","ready","getClientFeatures","getProtocol","createXHR","query","authOptions","authRequestType","headers","Headers","headerName","headersProvider","dynamicHeaders","body","request","Request","credentials","fetch","then","response","text","parsedData","catch","err","sender","host","json","setup","TimelineLevel","getAuthorizers","ajax","WebSocket","XMLHttpRequest","floor","globalThis","crypto","getRandomValues","Uint32Array","events","sent","uniqueID","level","limit","shift","ERROR","INFO","DEBUG","sendfn","bundle","lib","version","cluster","features","failAttempt","onInitialized","serializedTransport","AuthRequestType","transportClass","enabledTransports","disabledTransports","ignoreNullOrigin","getAssistant","deferred","paramsProvider","dynamicParams","composeChannelQuery","UserAuthentication","ChannelAuthorization","getConfig","opts","statsHost","enableStats","getEnableStatsConfig","getHttpHost","shouldUseTLS","getWebsocketHost","userAuthenticator","buildUserAuthenticator","buildChannelAuthorizer","timelineParams","forceTLS","disableStats","customHandler","channelAuthorizerGenerator","deprecatedAuthorizerOptions","ChannelAuthorizerProxy","authorizer","buildChannelAuth","bindWatchlistInternalEvent","forEach","watchlistEvent","resolve","reject","promise","Promise","res","rej","signin_requested","serverToUserChannel","_signinDoneResolve","_onAuthorize","_cleanup","_signin","_newSigninPromiseIfNeeded","watchlist","_onSigninSuccess","_subscribeChannels","bind_global","reinstateSubscription","subscribe","ensure_subscribed","done","setDone","isReady","instances","app_key","checkAppKey","validateOptions","global_emitter","sessionID","timelineSender","subscribeAll","isUsingTLS","internal","appKey","switchCluster","find","all","timelineSenderTimer","event_name","channel_name","cancelSubscription","signin","Runtime","ScriptReceivers","DependenciesReceivers","auth_callbacks"],"mappings":";;;;;;;CAAA,SAA2CA,EAAMC,GAC1B,iBAAZC,SAA0C,iBAAXC,OACxCA,OAAOD,QAAUD,IACQ,mBAAXG,QAAyBA,OAAOC,IAC9CD,OAAO,GAAIH,GACe,iBAAZC,QACdA,QAAgB,OAAID,IAEpBD,EAAa,OAAIC,IARnB,CASGK,MAAM,WACT,O,YCTE,IAAIC,EAAmB,GAGvB,SAASC,EAAoBC,GAG5B,GAAGF,EAAiBE,GACnB,OAAOF,EAAiBE,GAAUP,QAGnC,IAAIC,EAASI,EAAiBE,GAAY,CACz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AAQ7G,MAAM","file":"pusher.worker.min.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"Pusher\"] = factory();\n\telse\n\t\troot[\"Pusher\"] = factory();\n})(this, function() {\nreturn "," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 2);\n","// Copyright (C) 2016 Dmitry Chestnykh\n// MIT License. See LICENSE file for details.\n\n/**\n * Package base64 implements Base64 encoding and decoding.\n */\n\n// Invalid character used in decoding to indicate\n// that the character to decode is out of range of\n// alphabet and cannot be decoded.\nconst INVALID_BYTE = 256;\n\n/**\n * Implements standard Base64 encoding.\n *\n * Operates in constant time.\n */\nexport class Coder {\n // TODO(dchest): methods to encode chunk-by-chunk.\n\n constructor(private _paddingCharacter = \"=\") { }\n\n encodedLength(length: number): number {\n if (!this._paddingCharacter) {\n return (length * 8 + 5) / 6 | 0;\n }\n return (length + 2) / 3 * 4 | 0;\n }\n\n encode(data: Uint8Array): string {\n let out = \"\";\n\n let i = 0;\n for (; i < data.length - 2; i += 3) {\n let c = (data[i] << 16) | (data[i + 1] << 8) | (data[i + 2]);\n out += this._encodeByte((c >>> 3 * 6) & 63);\n out += this._encodeByte((c >>> 2 * 6) & 63);\n out += this._encodeByte((c >>> 1 * 6) & 63);\n out += this._encodeByte((c >>> 0 * 6) & 63);\n }\n\n const left = data.length - i;\n if (left > 0) {\n let c = (data[i] << 16) | (left === 2 ? data[i + 1] << 8 : 0);\n out += this._encodeByte((c >>> 3 * 6) & 63);\n out += this._encodeByte((c >>> 2 * 6) & 63);\n if (left === 2) {\n out += this._encodeByte((c >>> 1 * 6) & 63);\n } else {\n out += this._paddingCharacter || \"\";\n }\n out += this._paddingCharacter || \"\";\n }\n\n return out;\n }\n\n maxDecodedLength(length: number): number {\n if (!this._paddingCharacter) {\n return (length * 6 + 7) / 8 | 0;\n }\n return length / 4 * 3 | 0;\n }\n\n decodedLength(s: string): number {\n return this.maxDecodedLength(s.length - this._getPaddingLength(s));\n }\n\n decode(s: string): Uint8Array {\n if (s.length === 0) {\n return new Uint8Array(0);\n }\n const paddingLength = this._getPaddingLength(s);\n const length = s.length - paddingLength;\n const out = new Uint8Array(this.maxDecodedLength(length));\n let op = 0;\n let i = 0;\n let haveBad = 0;\n let v0 = 0, v1 = 0, v2 = 0, v3 = 0;\n for (; i < length - 4; i += 4) {\n v0 = this._decodeChar(s.charCodeAt(i + 0));\n v1 = this._decodeChar(s.charCodeAt(i + 1));\n v2 = this._decodeChar(s.charCodeAt(i + 2));\n v3 = this._decodeChar(s.charCodeAt(i + 3));\n out[op++] = (v0 << 2) | (v1 >>> 4);\n out[op++] = (v1 << 4) | (v2 >>> 2);\n out[op++] = (v2 << 6) | v3;\n haveBad |= v0 & INVALID_BYTE;\n haveBad |= v1 & INVALID_BYTE;\n haveBad |= v2 & INVALID_BYTE;\n haveBad |= v3 & INVALID_BYTE;\n }\n if (i < length - 1) {\n v0 = this._decodeChar(s.charCodeAt(i));\n v1 = this._decodeChar(s.charCodeAt(i + 1));\n out[op++] = (v0 << 2) | (v1 >>> 4);\n haveBad |= v0 & INVALID_BYTE;\n haveBad |= v1 & INVALID_BYTE;\n }\n if (i < length - 2) {\n v2 = this._decodeChar(s.charCodeAt(i + 2));\n out[op++] = (v1 << 4) | (v2 >>> 2);\n haveBad |= v2 & INVALID_BYTE;\n }\n if (i < length - 3) {\n v3 = this._decodeChar(s.charCodeAt(i + 3));\n out[op++] = (v2 << 6) | v3;\n haveBad |= v3 & INVALID_BYTE;\n }\n if (haveBad !== 0) {\n throw new Error(\"Base64Coder: incorrect characters for decoding\");\n }\n return out;\n }\n\n // Standard encoding have the following encoded/decoded ranges,\n // which we need to convert between.\n //\n // ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 0123456789 + /\n // Index: 0 - 25 26 - 51 52 - 61 62 63\n // ASCII: 65 - 90 97 - 122 48 - 57 43 47\n //\n\n // Encode 6 bits in b into a new character.\n protected _encodeByte(b: number): string {\n // Encoding uses constant time operations as follows:\n //\n // 1. Define comparison of A with B using (A - B) >>> 8:\n // if A > B, then result is positive integer\n // if A <= B, then result is 0\n //\n // 2. Define selection of C or 0 using bitwise AND: X & C:\n // if X == 0, then result is 0\n // if X != 0, then result is C\n //\n // 3. Start with the smallest comparison (b >= 0), which is always\n // true, so set the result to the starting ASCII value (65).\n //\n // 4. Continue comparing b to higher ASCII values, and selecting\n // zero if comparison isn't true, otherwise selecting a value\n // to add to result, which:\n //\n // a) undoes the previous addition\n // b) provides new value to add\n //\n let result = b;\n // b >= 0\n result += 65;\n // b > 25\n result += ((25 - b) >>> 8) & ((0 - 65) - 26 + 97);\n // b > 51\n result += ((51 - b) >>> 8) & ((26 - 97) - 52 + 48);\n // b > 61\n result += ((61 - b) >>> 8) & ((52 - 48) - 62 + 43);\n // b > 62\n result += ((62 - b) >>> 8) & ((62 - 43) - 63 + 47);\n\n return String.fromCharCode(result);\n }\n\n // Decode a character code into a byte.\n // Must return 256 if character is out of alphabet range.\n protected _decodeChar(c: number): number {\n // Decoding works similar to encoding: using the same comparison\n // function, but now it works on ranges: result is always incremented\n // by value, but this value becomes zero if the range is not\n // satisfied.\n //\n // Decoding starts with invalid value, 256, which is then\n // subtracted when the range is satisfied. If none of the ranges\n // apply, the function returns 256, which is then checked by\n // the caller to throw error.\n let result = INVALID_BYTE; // start with invalid character\n\n // c == 43 (c > 42 and c < 44)\n result += (((42 - c) & (c - 44)) >>> 8) & (-INVALID_BYTE + c - 43 + 62);\n // c == 47 (c > 46 and c < 48)\n result += (((46 - c) & (c - 48)) >>> 8) & (-INVALID_BYTE + c - 47 + 63);\n // c > 47 and c < 58\n result += (((47 - c) & (c - 58)) >>> 8) & (-INVALID_BYTE + c - 48 + 52);\n // c > 64 and c < 91\n result += (((64 - c) & (c - 91)) >>> 8) & (-INVALID_BYTE + c - 65 + 0);\n // c > 96 and c < 123\n result += (((96 - c) & (c - 123)) >>> 8) & (-INVALID_BYTE + c - 97 + 26);\n\n return result;\n }\n\n private _getPaddingLength(s: string): number {\n let paddingLength = 0;\n if (this._paddingCharacter) {\n for (let i = s.length - 1; i >= 0; i--) {\n if (s[i] !== this._paddingCharacter) {\n break;\n }\n paddingLength++;\n }\n if (s.length < 4 || paddingLength > 2) {\n throw new Error(\"Base64Coder: incorrect padding\");\n }\n }\n return paddingLength;\n }\n\n}\n\nconst stdCoder = new Coder();\n\nexport function encode(data: Uint8Array): string {\n return stdCoder.encode(data);\n}\n\nexport function decode(s: string): Uint8Array {\n return stdCoder.decode(s);\n}\n\n/**\n * Implements URL-safe Base64 encoding.\n * (Same as Base64, but '+' is replaced with '-', and '/' with '_').\n *\n * Operates in constant time.\n */\nexport class URLSafeCoder extends Coder {\n // URL-safe encoding have the following encoded/decoded ranges:\n //\n // ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 0123456789 - _\n // Index: 0 - 25 26 - 51 52 - 61 62 63\n // ASCII: 65 - 90 97 - 122 48 - 57 45 95\n //\n\n protected _encodeByte(b: number): string {\n let result = b;\n // b >= 0\n result += 65;\n // b > 25\n result += ((25 - b) >>> 8) & ((0 - 65) - 26 + 97);\n // b > 51\n result += ((51 - b) >>> 8) & ((26 - 97) - 52 + 48);\n // b > 61\n result += ((61 - b) >>> 8) & ((52 - 48) - 62 + 45);\n // b > 62\n result += ((62 - b) >>> 8) & ((62 - 45) - 63 + 95);\n\n return String.fromCharCode(result);\n }\n\n protected _decodeChar(c: number): number {\n let result = INVALID_BYTE;\n\n // c == 45 (c > 44 and c < 46)\n result += (((44 - c) & (c - 46)) >>> 8) & (-INVALID_BYTE + c - 45 + 62);\n // c == 95 (c > 94 and c < 96)\n result += (((94 - c) & (c - 96)) >>> 8) & (-INVALID_BYTE + c - 95 + 63);\n // c > 47 and c < 58\n result += (((47 - c) & (c - 58)) >>> 8) & (-INVALID_BYTE + c - 48 + 52);\n // c > 64 and c < 91\n result += (((64 - c) & (c - 91)) >>> 8) & (-INVALID_BYTE + c - 65 + 0);\n // c > 96 and c < 123\n result += (((96 - c) & (c - 123)) >>> 8) & (-INVALID_BYTE + c - 97 + 26);\n\n return result;\n }\n}\n\nconst urlSafeCoder = new URLSafeCoder();\n\nexport function encodeURLSafe(data: Uint8Array): string {\n return urlSafeCoder.encode(data);\n}\n\nexport function decodeURLSafe(s: string): Uint8Array {\n return urlSafeCoder.decode(s);\n}\n\n\nexport const encodedLength = (length: number) =>\n stdCoder.encodedLength(length);\n\nexport const maxDecodedLength = (length: number) =>\n stdCoder.maxDecodedLength(length);\n\nexport const decodedLength = (s: string) =>\n stdCoder.decodedLength(s);\n","// Copyright (C) 2016 Dmitry Chestnykh\n// MIT License. See LICENSE file for details.\n\n/**\n * Package utf8 implements UTF-8 encoding and decoding.\n */\n\nconst INVALID_UTF16 = \"utf8: invalid string\";\nconst INVALID_UTF8 = \"utf8: invalid source encoding\";\n\n/**\n * Encodes the given string into UTF-8 byte array.\n * Throws if the source string has invalid UTF-16 encoding.\n */\nexport function encode(s: string): Uint8Array {\n // Calculate result length and allocate output array.\n // encodedLength() also validates string and throws errors,\n // so we don't need repeat validation here.\n const arr = new Uint8Array(encodedLength(s));\n\n let pos = 0;\n for (let i = 0; i < s.length; i++) {\n let c = s.charCodeAt(i);\n if (c < 0x80) {\n arr[pos++] = c;\n } else if (c < 0x800) {\n arr[pos++] = 0xc0 | c >> 6;\n arr[pos++] = 0x80 | c & 0x3f;\n } else if (c < 0xd800) {\n arr[pos++] = 0xe0 | c >> 12;\n arr[pos++] = 0x80 | (c >> 6) & 0x3f;\n arr[pos++] = 0x80 | c & 0x3f;\n } else {\n i++; // get one more character\n c = (c & 0x3ff) << 10;\n c |= s.charCodeAt(i) & 0x3ff;\n c += 0x10000;\n\n arr[pos++] = 0xf0 | c >> 18;\n arr[pos++] = 0x80 | (c >> 12) & 0x3f;\n arr[pos++] = 0x80 | (c >> 6) & 0x3f;\n arr[pos++] = 0x80 | c & 0x3f;\n }\n }\n return arr;\n}\n\n/**\n * Returns the number of bytes required to encode the given string into UTF-8.\n * Throws if the source string has invalid UTF-16 encoding.\n */\nexport function encodedLength(s: string): number {\n let result = 0;\n for (let i = 0; i < s.length; i++) {\n const c = s.charCodeAt(i);\n if (c < 0x80) {\n result += 1;\n } else if (c < 0x800) {\n result += 2;\n } else if (c < 0xd800) {\n result += 3;\n } else if (c <= 0xdfff) {\n if (i >= s.length - 1) {\n throw new Error(INVALID_UTF16);\n }\n i++; // \"eat\" next character\n result += 4;\n } else {\n throw new Error(INVALID_UTF16);\n }\n }\n return result;\n}\n\n/**\n * Decodes the given byte array from UTF-8 into a string.\n * Throws if encoding is invalid.\n */\nexport function decode(arr: Uint8Array): string {\n const chars: string[] = [];\n for (let i = 0; i < arr.length; i++) {\n let b = arr[i];\n\n if (b & 0x80) {\n let min;\n if (b < 0xe0) {\n // Need 1 more byte.\n if (i >= arr.length) {\n throw new Error(INVALID_UTF8);\n }\n const n1 = arr[++i];\n if ((n1 & 0xc0) !== 0x80) {\n throw new Error(INVALID_UTF8);\n }\n b = (b & 0x1f) << 6 | (n1 & 0x3f);\n min = 0x80;\n } else if (b < 0xf0) {\n // Need 2 more bytes.\n if (i >= arr.length - 1) {\n throw new Error(INVALID_UTF8);\n }\n const n1 = arr[++i];\n const n2 = arr[++i];\n if ((n1 & 0xc0) !== 0x80 || (n2 & 0xc0) !== 0x80) {\n throw new Error(INVALID_UTF8);\n }\n b = (b & 0x0f) << 12 | (n1 & 0x3f) << 6 | (n2 & 0x3f);\n min = 0x800;\n } else if (b < 0xf8) {\n // Need 3 more bytes.\n if (i >= arr.length - 2) {\n throw new Error(INVALID_UTF8);\n }\n const n1 = arr[++i];\n const n2 = arr[++i];\n const n3 = arr[++i];\n if ((n1 & 0xc0) !== 0x80 || (n2 & 0xc0) !== 0x80 || (n3 & 0xc0) !== 0x80) {\n throw new Error(INVALID_UTF8);\n }\n b = (b & 0x0f) << 18 | (n1 & 0x3f) << 12 | (n2 & 0x3f) << 6 | (n3 & 0x3f);\n min = 0x10000;\n } else {\n throw new Error(INVALID_UTF8);\n }\n\n if (b < min || (b >= 0xd800 && b <= 0xdfff)) {\n throw new Error(INVALID_UTF8);\n }\n\n if (b >= 0x10000) {\n // Surrogate pair.\n if (b > 0x10ffff) {\n throw new Error(INVALID_UTF8);\n }\n b -= 0x10000;\n chars.push(String.fromCharCode(0xd800 | (b >> 10)));\n b = 0xdc00 | (b & 0x3ff);\n }\n }\n\n chars.push(String.fromCharCode(b));\n }\n return chars.join(\"\");\n}\n","// required so we don't have to do require('pusher').default etc.\nmodule.exports = require('./pusher').default;\n","export default function encode(s: any): string {\n return btoa(utob(s));\n}\n\nvar fromCharCode = String.fromCharCode;\n\nvar b64chars =\n 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';\nvar b64tab = {};\n\nfor (var i = 0, l = b64chars.length; i < l; i++) {\n b64tab[b64chars.charAt(i)] = i;\n}\n\nvar cb_utob = function(c) {\n var cc = c.charCodeAt(0);\n return cc < 0x80\n ? c\n : cc < 0x800\n ? fromCharCode(0xc0 | (cc >>> 6)) + fromCharCode(0x80 | (cc & 0x3f))\n : fromCharCode(0xe0 | ((cc >>> 12) & 0x0f)) +\n fromCharCode(0x80 | ((cc >>> 6) & 0x3f)) +\n fromCharCode(0x80 | (cc & 0x3f));\n};\n\nvar utob = function(u) {\n return u.replace(/[^\\x00-\\x7F]/g, cb_utob);\n};\n\nvar cb_encode = function(ccc) {\n var padlen = [0, 2, 1][ccc.length % 3];\n var ord =\n (ccc.charCodeAt(0) << 16) |\n ((ccc.length > 1 ? ccc.charCodeAt(1) : 0) << 8) |\n (ccc.length > 2 ? ccc.charCodeAt(2) : 0);\n var chars = [\n b64chars.charAt(ord >>> 18),\n b64chars.charAt((ord >>> 12) & 63),\n padlen >= 2 ? '=' : b64chars.charAt((ord >>> 6) & 63),\n padlen >= 1 ? '=' : b64chars.charAt(ord & 63)\n ];\n return chars.join('');\n};\n\nvar btoa =\n global.btoa ||\n function(b) {\n return b.replace(/[\\s\\S]{1,3}/g, cb_encode);\n };\n","import TimedCallback from './timed_callback';\nimport { Delay, Scheduler, Canceller } from './scheduling';\n\nabstract class Timer {\n protected clear: Canceller;\n protected timer: number | void;\n\n constructor(\n set: Scheduler,\n clear: Canceller,\n delay: Delay,\n callback: TimedCallback\n ) {\n this.clear = clear;\n this.timer = set(() => {\n if (this.timer) {\n this.timer = callback(this.timer);\n }\n }, delay);\n }\n\n /** Returns whether the timer is still running.\n *\n * @return {Boolean}\n */\n isRunning(): boolean {\n return this.timer !== null;\n }\n\n /** Aborts a timer when it's running. */\n ensureAborted() {\n if (this.timer) {\n this.clear(this.timer);\n this.timer = null;\n }\n }\n}\n\nexport default Timer;\n","import Timer from './abstract_timer';\nimport TimedCallback from './timed_callback';\nimport { Delay } from './scheduling';\n\n// We need to bind clear functions this way to avoid exceptions on IE8\nfunction clearTimeout(timer) {\n global.clearTimeout(timer);\n}\nfunction clearInterval(timer) {\n global.clearInterval(timer);\n}\n\n/** Cross-browser compatible one-off timer abstraction.\n *\n * @param {Number} delay\n * @param {Function} callback\n */\nexport class OneOffTimer extends Timer {\n constructor(delay: Delay, callback: TimedCallback) {\n super(setTimeout, clearTimeout, delay, function(timer) {\n callback();\n return null;\n });\n }\n}\n\n/** Cross-browser compatible periodic timer abstraction.\n *\n * @param {Number} delay\n * @param {Function} callback\n */\nexport class PeriodicTimer extends Timer {\n constructor(delay: Delay, callback: TimedCallback) {\n super(setInterval, clearInterval, delay, function(timer) {\n callback();\n return timer;\n });\n }\n}\n","import * as Collections from './utils/collections';\nimport TimedCallback from './utils/timers/timed_callback';\nimport { OneOffTimer, PeriodicTimer } from './utils/timers';\n\nvar Util = {\n now(): number {\n if (Date.now) {\n return Date.now();\n } else {\n return new Date().valueOf();\n }\n },\n\n defer(callback: TimedCallback): OneOffTimer {\n return new OneOffTimer(0, callback);\n },\n\n /** Builds a function that will proxy a method call to its first argument.\n *\n * Allows partial application of arguments, so additional arguments are\n * prepended to the argument list.\n *\n * @param {String} name method name\n * @return {Function} proxy function\n */\n method(name: string, ...args: any[]): Function {\n var boundArguments = Array.prototype.slice.call(arguments, 1);\n return function(object) {\n return object[name].apply(object, boundArguments.concat(arguments));\n };\n }\n};\n\nexport default Util;\n","import base64encode from '../base64';\nimport Util from '../util';\n\n/** Merges multiple objects into the target argument.\n *\n * For properties that are plain Objects, performs a deep-merge. For the\n * rest it just copies the value of the property.\n *\n * To extend prototypes use it as following:\n * Pusher.Util.extend(Target.prototype, Base.prototype)\n *\n * You can also use it to merge objects without altering them:\n * Pusher.Util.extend({}, object1, object2)\n *\n * @param {Object} target\n * @return {Object} the target argument\n */\nexport function extend(target: any, ...sources: any[]): T {\n for (var i = 0; i < sources.length; i++) {\n var extensions = sources[i];\n for (var property in extensions) {\n if (\n extensions[property] &&\n extensions[property].constructor &&\n extensions[property].constructor === Object\n ) {\n target[property] = extend(target[property] || {}, extensions[property]);\n } else {\n target[property] = extensions[property];\n }\n }\n }\n return target;\n}\n\nexport function stringify(): string {\n var m = ['Pusher'];\n for (var i = 0; i < arguments.length; i++) {\n if (typeof arguments[i] === 'string') {\n m.push(arguments[i]);\n } else {\n m.push(safeJSONStringify(arguments[i]));\n }\n }\n return m.join(' : ');\n}\n\nexport function arrayIndexOf(array: any[], item: any): number {\n // MSIE doesn't have array.indexOf\n var nativeIndexOf = Array.prototype.indexOf;\n if (array === null) {\n return -1;\n }\n if (nativeIndexOf && array.indexOf === nativeIndexOf) {\n return array.indexOf(item);\n }\n for (var i = 0, l = array.length; i < l; i++) {\n if (array[i] === item) {\n return i;\n }\n }\n return -1;\n}\n\n/** Applies a function f to all properties of an object.\n *\n * Function f gets 3 arguments passed:\n * - element from the object\n * - key of the element\n * - reference to the object\n *\n * @param {Object} object\n * @param {Function} f\n */\nexport function objectApply(object: any, f: Function) {\n for (var key in object) {\n if (Object.prototype.hasOwnProperty.call(object, key)) {\n f(object[key], key, object);\n }\n }\n}\n\n/** Return a list of objects own proerty keys\n *\n * @param {Object} object\n * @returns {Array}\n */\nexport function keys(object: any): string[] {\n var keys = [];\n objectApply(object, function(_, key) {\n keys.push(key);\n });\n return keys;\n}\n\n/** Return a list of object's own property values\n *\n * @param {Object} object\n * @returns {Array}\n */\nexport function values(object: any): any[] {\n var values = [];\n objectApply(object, function(value) {\n values.push(value);\n });\n return values;\n}\n\n/** Applies a function f to all elements of an array.\n *\n * Function f gets 3 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function apply(array: any[], f: Function, context?: any) {\n for (var i = 0; i < array.length; i++) {\n f.call(context || global, array[i], i, array);\n }\n}\n\n/** Maps all elements of the array and returns the result.\n *\n * Function f gets 4 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n * - reference to the destination array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function map(array: any[], f: Function): any[] {\n var result = [];\n for (var i = 0; i < array.length; i++) {\n result.push(f(array[i], i, array, result));\n }\n return result;\n}\n\n/** Maps all elements of the object and returns the result.\n *\n * Function f gets 4 arguments passed:\n * - element from the object\n * - key of the element\n * - reference to the source object\n * - reference to the destination object\n *\n * @param {Object} object\n * @param {Function} f\n */\nexport function mapObject(object: any, f: Function): any {\n var result = {};\n objectApply(object, function(value, key) {\n result[key] = f(value);\n });\n return result;\n}\n\n/** Filters elements of the array using a test function.\n *\n * Function test gets 4 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n * - reference to the destination array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function filter(array: any[], test: Function): any[] {\n test =\n test ||\n function(value) {\n return !!value;\n };\n\n var result = [];\n for (var i = 0; i < array.length; i++) {\n if (test(array[i], i, array, result)) {\n result.push(array[i]);\n }\n }\n return result;\n}\n\n/** Filters properties of the object using a test function.\n *\n * Function test gets 4 arguments passed:\n * - element from the object\n * - key of the element\n * - reference to the source object\n * - reference to the destination object\n *\n * @param {Object} object\n * @param {Function} f\n */\nexport function filterObject(object: Object, test: Function) {\n var result = {};\n objectApply(object, function(value, key) {\n if ((test && test(value, key, object, result)) || Boolean(value)) {\n result[key] = value;\n }\n });\n return result;\n}\n\n/** Flattens an object into a two-dimensional array.\n *\n * @param {Object} object\n * @return {Array} resulting array of [key, value] pairs\n */\nexport function flatten(object: Object): any[] {\n var result = [];\n objectApply(object, function(value, key) {\n result.push([key, value]);\n });\n return result;\n}\n\n/** Checks whether any element of the array passes the test.\n *\n * Function test gets 3 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function any(array: any[], test: Function): boolean {\n for (var i = 0; i < array.length; i++) {\n if (test(array[i], i, array)) {\n return true;\n }\n }\n return false;\n}\n\n/** Checks whether all elements of the array pass the test.\n *\n * Function test gets 3 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function all(array: any[], test: Function): boolean {\n for (var i = 0; i < array.length; i++) {\n if (!test(array[i], i, array)) {\n return false;\n }\n }\n return true;\n}\n\nexport function encodeParamsObject(data): string {\n return mapObject(data, function(value) {\n if (typeof value === 'object') {\n value = safeJSONStringify(value);\n }\n return encodeURIComponent(base64encode(value.toString()));\n });\n}\n\nexport function buildQueryString(data: any): string {\n var params = filterObject(data, function(value) {\n return value !== undefined;\n });\n\n var query = map(\n flatten(encodeParamsObject(params)),\n Util.method('join', '=')\n ).join('&');\n\n return query;\n}\n\n/**\n * See https://github.com/douglascrockford/JSON-js/blob/master/cycle.js\n *\n * Remove circular references from an object. Required for JSON.stringify in\n * React Native, which tends to blow up a lot.\n *\n * @param {any} object\n * @return {any} Decycled object\n */\nexport function decycleObject(object: any): any {\n var objects = [],\n paths = [];\n\n return (function derez(value, path) {\n var i, name, nu;\n\n switch (typeof value) {\n case 'object':\n if (!value) {\n return null;\n }\n for (i = 0; i < objects.length; i += 1) {\n if (objects[i] === value) {\n return { $ref: paths[i] };\n }\n }\n\n objects.push(value);\n paths.push(path);\n\n if (Object.prototype.toString.apply(value) === '[object Array]') {\n nu = [];\n for (i = 0; i < value.length; i += 1) {\n nu[i] = derez(value[i], path + '[' + i + ']');\n }\n } else {\n nu = {};\n for (name in value) {\n if (Object.prototype.hasOwnProperty.call(value, name)) {\n nu[name] = derez(\n value[name],\n path + '[' + JSON.stringify(name) + ']'\n );\n }\n }\n }\n return nu;\n case 'number':\n case 'string':\n case 'boolean':\n return value;\n }\n })(object, '$');\n}\n\n/**\n * Provides a cross-browser and cross-platform way to safely stringify objects\n * into JSON. This is particularly necessary for ReactNative, where circular JSON\n * structures throw an exception.\n *\n * @param {any} source The object to stringify\n * @return {string} The serialized output.\n */\nexport function safeJSONStringify(source: any): string {\n try {\n return JSON.stringify(source);\n } catch (e) {\n return JSON.stringify(decycleObject(source));\n }\n}\n","import {\n ChannelAuthorizationOptions,\n UserAuthenticationOptions\n} from './auth/options';\nimport { AuthTransport } from './config';\n\nexport interface DefaultConfig {\n VERSION: string;\n PROTOCOL: number;\n wsPort: number;\n wssPort: number;\n wsPath: string;\n httpHost: string;\n httpPort: number;\n httpsPort: number;\n httpPath: string;\n stats_host: string;\n authEndpoint: string;\n authTransport: AuthTransport;\n activityTimeout: number;\n pongTimeout: number;\n unavailableTimeout: number;\n userAuthentication: UserAuthenticationOptions;\n channelAuthorization: ChannelAuthorizationOptions;\n\n cdn_http?: string;\n cdn_https?: string;\n dependency_suffix?: string;\n}\n\nvar Defaults: DefaultConfig = {\n VERSION: VERSION,\n PROTOCOL: 7,\n\n wsPort: 80,\n wssPort: 443,\n wsPath: '',\n // DEPRECATED: SockJS fallback parameters\n httpHost: 'sockjs.pusher.com',\n httpPort: 80,\n httpsPort: 443,\n httpPath: '/pusher',\n // DEPRECATED: Stats\n stats_host: 'stats.pusher.com',\n // DEPRECATED: Other settings\n authEndpoint: '/pusher/auth',\n authTransport: 'ajax',\n activityTimeout: 120000,\n pongTimeout: 30000,\n unavailableTimeout: 10000,\n userAuthentication: {\n endpoint: '/pusher/user-auth',\n transport: 'ajax'\n },\n channelAuthorization: {\n endpoint: '/pusher/auth',\n transport: 'ajax'\n },\n\n // CDN configuration\n cdn_http: CDN_HTTP,\n cdn_https: CDN_HTTPS,\n dependency_suffix: DEPENDENCY_SUFFIX\n};\n\nexport default Defaults;\n","import Defaults from '../defaults';\nimport { default as URLScheme, URLSchemeParams } from './url_scheme';\n\nfunction getGenericURL(\n baseScheme: string,\n params: URLSchemeParams,\n path: string\n): string {\n var scheme = baseScheme + (params.useTLS ? 's' : '');\n var host = params.useTLS ? params.hostTLS : params.hostNonTLS;\n return scheme + '://' + host + path;\n}\n\nfunction getGenericPath(key: string, queryString?: string): string {\n var path = '/app/' + key;\n var query =\n '?protocol=' +\n Defaults.PROTOCOL +\n '&client=js' +\n '&version=' +\n Defaults.VERSION +\n (queryString ? '&' + queryString : '');\n return path + query;\n}\n\nexport var ws: URLScheme = {\n getInitial: function(key: string, params: URLSchemeParams): string {\n var path = (params.httpPath || '') + getGenericPath(key, 'flash=false');\n return getGenericURL('ws', params, path);\n }\n};\n\nexport var http: URLScheme = {\n getInitial: function(key: string, params: URLSchemeParams): string {\n var path = (params.httpPath || '/pusher') + getGenericPath(key);\n return getGenericURL('http', params, path);\n }\n};\n\nexport var sockjs: URLScheme = {\n getInitial: function(key: string, params: URLSchemeParams): string {\n return getGenericURL('http', params, params.httpPath || '/pusher');\n },\n getPath: function(key: string, params: URLSchemeParams): string {\n return getGenericPath(key);\n }\n};\n","import Callback from './callback';\nimport * as Collections from '../utils/collections';\nimport CallbackTable from './callback_table';\n\nexport default class CallbackRegistry {\n _callbacks: CallbackTable;\n\n constructor() {\n this._callbacks = {};\n }\n\n get(name: string): Callback[] {\n return this._callbacks[prefix(name)];\n }\n\n add(name: string, callback: Function, context: any) {\n var prefixedEventName = prefix(name);\n this._callbacks[prefixedEventName] =\n this._callbacks[prefixedEventName] || [];\n this._callbacks[prefixedEventName].push({\n fn: callback,\n context: context\n });\n }\n\n remove(name?: string, callback?: Function, context?: any) {\n if (!name && !callback && !context) {\n this._callbacks = {};\n return;\n }\n\n var names = name ? [prefix(name)] : Collections.keys(this._callbacks);\n\n if (callback || context) {\n this.removeCallback(names, callback, context);\n } else {\n this.removeAllCallbacks(names);\n }\n }\n\n private removeCallback(names: string[], callback: Function, context: any) {\n Collections.apply(\n names,\n function(name) {\n this._callbacks[name] = Collections.filter(\n this._callbacks[name] || [],\n function(binding) {\n return (\n (callback && callback !== binding.fn) ||\n (context && context !== binding.context)\n );\n }\n );\n if (this._callbacks[name].length === 0) {\n delete this._callbacks[name];\n }\n },\n this\n );\n }\n\n private removeAllCallbacks(names: string[]) {\n Collections.apply(\n names,\n function(name) {\n delete this._callbacks[name];\n },\n this\n );\n }\n}\n\nfunction prefix(name: string): string {\n return '_' + name;\n}\n","import * as Collections from '../utils/collections';\nimport Callback from './callback';\nimport Metadata from '../channels/metadata';\nimport CallbackRegistry from './callback_registry';\n\n/** Manages callback bindings and event emitting.\n *\n * @param Function failThrough called when no listeners are bound to an event\n */\nexport default class Dispatcher {\n callbacks: CallbackRegistry;\n global_callbacks: Function[];\n failThrough: Function;\n\n constructor(failThrough?: Function) {\n this.callbacks = new CallbackRegistry();\n this.global_callbacks = [];\n this.failThrough = failThrough;\n }\n\n bind(eventName: string, callback: Function, context?: any) {\n this.callbacks.add(eventName, callback, context);\n return this;\n }\n\n bind_global(callback: Function) {\n this.global_callbacks.push(callback);\n return this;\n }\n\n unbind(eventName?: string, callback?: Function, context?: any) {\n this.callbacks.remove(eventName, callback, context);\n return this;\n }\n\n unbind_global(callback?: Function) {\n if (!callback) {\n this.global_callbacks = [];\n return this;\n }\n\n this.global_callbacks = Collections.filter(\n this.global_callbacks || [],\n c => c !== callback\n );\n\n return this;\n }\n\n unbind_all() {\n this.unbind();\n this.unbind_global();\n return this;\n }\n\n emit(eventName: string, data?: any, metadata?: Metadata): Dispatcher {\n for (var i = 0; i < this.global_callbacks.length; i++) {\n this.global_callbacks[i](eventName, data);\n }\n\n var callbacks = this.callbacks.get(eventName);\n var args = [];\n\n if (metadata) {\n // if there's a metadata argument, we need to call the callback with both\n // data and metadata regardless of whether data is undefined\n args.push(data, metadata);\n } else if (data) {\n // metadata is undefined, so we only need to call the callback with data\n // if data exists\n args.push(data);\n }\n\n if (callbacks && callbacks.length > 0) {\n for (var i = 0; i < callbacks.length; i++) {\n callbacks[i].fn.apply(callbacks[i].context || global, args);\n }\n } else if (this.failThrough) {\n this.failThrough(eventName, data);\n }\n\n return this;\n }\n}\n","import { stringify } from './utils/collections';\nimport Pusher from './pusher';\n\nclass Logger {\n debug(...args: any[]) {\n this.log(this.globalLog, args);\n }\n\n warn(...args: any[]) {\n this.log(this.globalLogWarn, args);\n }\n\n error(...args: any[]) {\n this.log(this.globalLogError, args);\n }\n\n private globalLog = (message: string) => {\n if (global.console && global.console.log) {\n global.console.log(message);\n }\n };\n\n private globalLogWarn(message: string) {\n if (global.console && global.console.warn) {\n global.console.warn(message);\n } else {\n this.globalLog(message);\n }\n }\n\n private globalLogError(message: string) {\n if (global.console && global.console.error) {\n global.console.error(message);\n } else {\n this.globalLogWarn(message);\n }\n }\n\n private log(\n defaultLoggingFunction: (message: string) => void,\n ...args: any[]\n ) {\n var message = stringify.apply(this, arguments);\n if (Pusher.log) {\n Pusher.log(message);\n } else if (Pusher.logToConsole) {\n const log = defaultLoggingFunction.bind(this);\n log(message);\n }\n }\n}\n\nexport default new Logger();\n","import Util from '../util';\nimport * as Collections from '../utils/collections';\nimport { default as EventsDispatcher } from '../events/dispatcher';\nimport Logger from '../logger';\nimport TransportHooks from './transport_hooks';\nimport Socket from '../socket';\nimport Runtime from 'runtime';\nimport Timeline from '../timeline/timeline';\nimport TransportConnectionOptions from './transport_connection_options';\n\n/** Provides universal API for transport connections.\n *\n * Transport connection is a low-level object that wraps a connection method\n * and exposes a simple evented interface for the connection state and\n * messaging. It does not implement Pusher-specific WebSocket protocol.\n *\n * Additionally, it fetches resources needed for transport to work and exposes\n * an interface for querying transport features.\n *\n * States:\n * - new - initial state after constructing the object\n * - initializing - during initialization phase, usually fetching resources\n * - intialized - ready to establish a connection\n * - connection - when connection is being established\n * - open - when connection ready to be used\n * - closed - after connection was closed be either side\n *\n * Emits:\n * - error - after the connection raised an error\n *\n * Options:\n * - useTLS - whether connection should be over TLS\n * - hostTLS - host to connect to when connection is over TLS\n * - hostNonTLS - host to connect to when connection is over TLS\n *\n * @param {String} key application key\n * @param {Object} options\n */\nexport default class TransportConnection extends EventsDispatcher {\n hooks: TransportHooks;\n name: string;\n priority: number;\n key: string;\n options: TransportConnectionOptions;\n state: string;\n timeline: Timeline;\n activityTimeout: number;\n id: number;\n socket: Socket;\n beforeOpen: Function;\n initialize: Function;\n\n constructor(\n hooks: TransportHooks,\n name: string,\n priority: number,\n key: string,\n options: TransportConnectionOptions\n ) {\n super();\n this.initialize = Runtime.transportConnectionInitializer;\n this.hooks = hooks;\n this.name = name;\n this.priority = priority;\n this.key = key;\n this.options = options;\n\n this.state = 'new';\n this.timeline = options.timeline;\n this.activityTimeout = options.activityTimeout;\n this.id = this.timeline.generateUniqueID();\n }\n\n /** Checks whether the transport handles activity checks by itself.\n *\n * @return {Boolean}\n */\n handlesActivityChecks(): boolean {\n return Boolean(this.hooks.handlesActivityChecks);\n }\n\n /** Checks whether the transport supports the ping/pong API.\n *\n * @return {Boolean}\n */\n supportsPing(): boolean {\n return Boolean(this.hooks.supportsPing);\n }\n\n /** Tries to establish a connection.\n *\n * @returns {Boolean} false if transport is in invalid state\n */\n connect(): boolean {\n if (this.socket || this.state !== 'initialized') {\n return false;\n }\n\n var url = this.hooks.urls.getInitial(this.key, this.options);\n try {\n this.socket = this.hooks.getSocket(url, this.options);\n } catch (e) {\n Util.defer(() => {\n this.onError(e);\n this.changeState('closed');\n });\n return false;\n }\n\n this.bindListeners();\n\n Logger.debug('Connecting', { transport: this.name, url });\n this.changeState('connecting');\n return true;\n }\n\n /** Closes the connection.\n *\n * @return {Boolean} true if there was a connection to close\n */\n close(): boolean {\n if (this.socket) {\n this.socket.close();\n return true;\n } else {\n return false;\n }\n }\n\n /** Sends data over the open connection.\n *\n * @param {String} data\n * @return {Boolean} true only when in the \"open\" state\n */\n send(data: any): boolean {\n if (this.state === 'open') {\n // Workaround for MobileSafari bug (see https://gist.github.com/2052006)\n Util.defer(() => {\n if (this.socket) {\n this.socket.send(data);\n }\n });\n return true;\n } else {\n return false;\n }\n }\n\n /** Sends a ping if the connection is open and transport supports it. */\n ping() {\n if (this.state === 'open' && this.supportsPing()) {\n this.socket.ping();\n }\n }\n\n private onOpen() {\n if (this.hooks.beforeOpen) {\n this.hooks.beforeOpen(\n this.socket,\n this.hooks.urls.getPath(this.key, this.options)\n );\n }\n this.changeState('open');\n this.socket.onopen = undefined;\n }\n\n private onError(error) {\n this.emit('error', { type: 'WebSocketError', error: error });\n this.timeline.error(this.buildTimelineMessage({ error: error.toString() }));\n }\n\n private onClose(closeEvent?: any) {\n if (closeEvent) {\n this.changeState('closed', {\n code: closeEvent.code,\n reason: closeEvent.reason,\n wasClean: closeEvent.wasClean\n });\n } else {\n this.changeState('closed');\n }\n this.unbindListeners();\n this.socket = undefined;\n }\n\n private onMessage(message) {\n this.emit('message', message);\n }\n\n private onActivity() {\n this.emit('activity');\n }\n\n private bindListeners() {\n this.socket.onopen = () => {\n this.onOpen();\n };\n this.socket.onerror = error => {\n this.onError(error);\n };\n this.socket.onclose = closeEvent => {\n this.onClose(closeEvent);\n };\n this.socket.onmessage = message => {\n this.onMessage(message);\n };\n\n if (this.supportsPing()) {\n this.socket.onactivity = () => {\n this.onActivity();\n };\n }\n }\n\n private unbindListeners() {\n if (this.socket) {\n this.socket.onopen = undefined;\n this.socket.onerror = undefined;\n this.socket.onclose = undefined;\n this.socket.onmessage = undefined;\n if (this.supportsPing()) {\n this.socket.onactivity = undefined;\n }\n }\n }\n\n private changeState(state: string, params?: any) {\n this.state = state;\n this.timeline.info(\n this.buildTimelineMessage({\n state: state,\n params: params\n })\n );\n this.emit(state, params);\n }\n\n buildTimelineMessage(message): any {\n return Collections.extend({ cid: this.id }, message);\n }\n}\n","import Factory from '../utils/factory';\nimport TransportHooks from './transport_hooks';\nimport TransportConnection from './transport_connection';\nimport TransportConnectionOptions from './transport_connection_options';\n\n/** Provides interface for transport connection instantiation.\n *\n * Takes transport-specific hooks as the only argument, which allow checking\n * for transport support and creating its connections.\n *\n * Supported hooks: * - file - the name of the file to be fetched during initialization\n * - urls - URL scheme to be used by transport\n * - handlesActivityCheck - true when the transport handles activity checks\n * - supportsPing - true when the transport has a ping/activity API\n * - isSupported - tells whether the transport is supported in the environment\n * - getSocket - creates a WebSocket-compatible transport socket\n *\n * See transports.js for specific implementations.\n *\n * @param {Object} hooks object containing all needed transport hooks\n */\nexport default class Transport {\n hooks: TransportHooks;\n\n constructor(hooks: TransportHooks) {\n this.hooks = hooks;\n }\n\n /** Returns whether the transport is supported in the environment.\n *\n * @param {Object} envronment te environment details (encryption, settings)\n * @returns {Boolean} true when the transport is supported\n */\n isSupported(environment: any): boolean {\n return this.hooks.isSupported(environment);\n }\n\n /** Creates a transport connection.\n *\n * @param {String} name\n * @param {Number} priority\n * @param {String} key the application key\n * @param {Object} options\n * @returns {TransportConnection}\n */\n createConnection(\n name: string,\n priority: number,\n key: string,\n options: any\n ): TransportConnection {\n return new TransportConnection(this.hooks, name, priority, key, options);\n }\n}\n","import * as URLSchemes from 'core/transports/url_schemes';\nimport URLScheme from 'core/transports/url_scheme';\nimport Transport from 'core/transports/transport';\nimport Util from 'core/util';\nimport * as Collections from 'core/utils/collections';\nimport TransportHooks from 'core/transports/transport_hooks';\nimport TransportsTable from 'core/transports/transports_table';\nimport Runtime from 'runtime';\n\n/** WebSocket transport.\n *\n * Uses native WebSocket implementation, including MozWebSocket supported by\n * earlier Firefox versions.\n */\nvar WSTransport = new Transport({\n urls: URLSchemes.ws,\n handlesActivityChecks: false,\n supportsPing: false,\n\n isInitialized: function() {\n return Boolean(Runtime.getWebSocketAPI());\n },\n isSupported: function(): boolean {\n return Boolean(Runtime.getWebSocketAPI());\n },\n getSocket: function(url) {\n return Runtime.createWebSocket(url);\n }\n});\n\nvar httpConfiguration = {\n urls: URLSchemes.http,\n handlesActivityChecks: false,\n supportsPing: true,\n isInitialized: function() {\n return true;\n }\n};\n\nexport var streamingConfiguration = Collections.extend(\n {\n getSocket: function(url) {\n return Runtime.HTTPFactory.createStreamingSocket(url);\n }\n },\n httpConfiguration\n);\nexport var pollingConfiguration = Collections.extend(\n {\n getSocket: function(url) {\n return Runtime.HTTPFactory.createPollingSocket(url);\n }\n },\n httpConfiguration\n);\n\nvar xhrConfiguration = {\n isSupported: function(): boolean {\n return Runtime.isXHRSupported();\n }\n};\n\n/** HTTP streaming transport using CORS-enabled XMLHttpRequest. */\nvar XHRStreamingTransport = new Transport(\n (\n Collections.extend({}, streamingConfiguration, xhrConfiguration)\n )\n);\n\n/** HTTP long-polling transport using CORS-enabled XMLHttpRequest. */\nvar XHRPollingTransport = new Transport(\n Collections.extend({}, pollingConfiguration, xhrConfiguration)\n);\n\nvar Transports: TransportsTable = {\n ws: WSTransport,\n xhr_streaming: XHRStreamingTransport,\n xhr_polling: XHRPollingTransport\n};\n\nexport default Transports;\n","import Util from '../util';\nimport * as Collections from '../utils/collections';\nimport TransportManager from './transport_manager';\nimport TransportConnection from './transport_connection';\nimport Transport from './transport';\nimport PingDelayOptions from './ping_delay_options';\n\n/** Creates transport connections monitored by a transport manager.\n *\n * When a transport is closed, it might mean the environment does not support\n * it. It's possible that messages get stuck in an intermediate buffer or\n * proxies terminate inactive connections. To combat these problems,\n * assistants monitor the connection lifetime, report unclean exits and\n * adjust ping timeouts to keep the connection active. The decision to disable\n * a transport is the manager's responsibility.\n *\n * @param {TransportManager} manager\n * @param {TransportConnection} transport\n * @param {Object} options\n */\nexport default class AssistantToTheTransportManager {\n manager: TransportManager;\n transport: Transport;\n minPingDelay: number;\n maxPingDelay: number;\n pingDelay: number;\n\n constructor(\n manager: TransportManager,\n transport: Transport,\n options: PingDelayOptions\n ) {\n this.manager = manager;\n this.transport = transport;\n this.minPingDelay = options.minPingDelay;\n this.maxPingDelay = options.maxPingDelay;\n this.pingDelay = undefined;\n }\n\n /** Creates a transport connection.\n *\n * This function has the same API as Transport#createConnection.\n *\n * @param {String} name\n * @param {Number} priority\n * @param {String} key the application key\n * @param {Object} options\n * @returns {TransportConnection}\n */\n createConnection(\n name: string,\n priority: number,\n key: string,\n options: Object\n ): TransportConnection {\n options = Collections.extend({}, options, {\n activityTimeout: this.pingDelay\n });\n var connection = this.transport.createConnection(\n name,\n priority,\n key,\n options\n );\n\n var openTimestamp = null;\n\n var onOpen = function() {\n connection.unbind('open', onOpen);\n connection.bind('closed', onClosed);\n openTimestamp = Util.now();\n };\n var onClosed = closeEvent => {\n connection.unbind('closed', onClosed);\n\n if (closeEvent.code === 1002 || closeEvent.code === 1003) {\n // we don't want to use transports not obeying the protocol\n this.manager.reportDeath();\n } else if (!closeEvent.wasClean && openTimestamp) {\n // report deaths only for short-living transport\n var lifespan = Util.now() - openTimestamp;\n if (lifespan < 2 * this.maxPingDelay) {\n this.manager.reportDeath();\n this.pingDelay = Math.max(lifespan / 2, this.minPingDelay);\n }\n }\n };\n\n connection.bind('open', onOpen);\n return connection;\n }\n\n /** Returns whether the transport is supported in the environment.\n *\n * This function has the same API as Transport#isSupported. Might return false\n * when the manager decides to kill the transport.\n *\n * @param {Object} environment the environment details (encryption, settings)\n * @returns {Boolean} true when the transport is supported\n */\n isSupported(environment: string): boolean {\n return this.manager.isAlive() && this.transport.isSupported(environment);\n }\n}\n","import Action from './action';\nimport { PusherEvent } from './message-types';\n/**\n * Provides functions for handling Pusher protocol-specific messages.\n */\n\nconst Protocol = {\n /**\n * Decodes a message in a Pusher format.\n *\n * The MessageEvent we receive from the transport should contain a pusher event\n * (https://pusher.com/docs/pusher_protocol#events) serialized as JSON in the\n * data field\n *\n * The pusher event may contain a data field too, and it may also be\n * serialised as JSON\n *\n * Throws errors when messages are not parse'able.\n *\n * @param {MessageEvent} messageEvent\n * @return {PusherEvent}\n */\n decodeMessage: function(messageEvent: MessageEvent): PusherEvent {\n try {\n var messageData = JSON.parse(messageEvent.data);\n var pusherEventData = messageData.data;\n if (typeof pusherEventData === 'string') {\n try {\n pusherEventData = JSON.parse(messageData.data);\n } catch (e) {}\n }\n var pusherEvent: PusherEvent = {\n event: messageData.event,\n channel: messageData.channel,\n data: pusherEventData\n };\n if (messageData.user_id) {\n pusherEvent.user_id = messageData.user_id;\n }\n return pusherEvent;\n } catch (e) {\n throw { type: 'MessageParseError', error: e, data: messageEvent.data };\n }\n },\n\n /**\n * Encodes a message to be sent.\n *\n * @param {PusherEvent} event\n * @return {String}\n */\n encodeMessage: function(event: PusherEvent): string {\n return JSON.stringify(event);\n },\n\n /**\n * Processes a handshake message and returns appropriate actions.\n *\n * Returns an object with an 'action' and other action-specific properties.\n *\n * There are three outcomes when calling this function. First is a successful\n * connection attempt, when pusher:connection_established is received, which\n * results in a 'connected' action with an 'id' property. When passed a\n * pusher:error event, it returns a result with action appropriate to the\n * close code and an error. Otherwise, it raises an exception.\n *\n * @param {String} message\n * @result Object\n */\n processHandshake: function(messageEvent: MessageEvent): Action {\n var message = Protocol.decodeMessage(messageEvent);\n\n if (message.event === 'pusher:connection_established') {\n if (!message.data.activity_timeout) {\n throw 'No activity timeout specified in handshake';\n }\n return {\n action: 'connected',\n id: message.data.socket_id,\n activityTimeout: message.data.activity_timeout * 1000\n };\n } else if (message.event === 'pusher:error') {\n // From protocol 6 close codes are sent only once, so this only\n // happens when connection does not support close codes\n return {\n action: this.getCloseAction(message.data),\n error: this.getCloseError(message.data)\n };\n } else {\n throw 'Invalid handshake';\n }\n },\n\n /**\n * Dispatches the close event and returns an appropriate action name.\n *\n * See:\n * 1. https://developer.mozilla.org/en-US/docs/WebSockets/WebSockets_reference/CloseEvent\n * 2. http://pusher.com/docs/pusher_protocol\n *\n * @param {CloseEvent} closeEvent\n * @return {String} close action name\n */\n getCloseAction: function(closeEvent): string {\n if (closeEvent.code < 4000) {\n // ignore 1000 CLOSE_NORMAL, 1001 CLOSE_GOING_AWAY,\n // 1005 CLOSE_NO_STATUS, 1006 CLOSE_ABNORMAL\n // ignore 1007...3999\n // handle 1002 CLOSE_PROTOCOL_ERROR, 1003 CLOSE_UNSUPPORTED,\n // 1004 CLOSE_TOO_LARGE\n if (closeEvent.code >= 1002 && closeEvent.code <= 1004) {\n return 'backoff';\n } else {\n return null;\n }\n } else if (closeEvent.code === 4000) {\n return 'tls_only';\n } else if (closeEvent.code < 4100) {\n return 'refused';\n } else if (closeEvent.code < 4200) {\n return 'backoff';\n } else if (closeEvent.code < 4300) {\n return 'retry';\n } else {\n // unknown error\n return 'refused';\n }\n },\n\n /**\n * Returns an error or null basing on the close event.\n *\n * Null is returned when connection was closed cleanly. Otherwise, an object\n * with error details is returned.\n *\n * @param {CloseEvent} closeEvent\n * @return {Object} error object\n */\n getCloseError: function(closeEvent): any {\n if (closeEvent.code !== 1000 && closeEvent.code !== 1001) {\n return {\n type: 'PusherError',\n data: {\n code: closeEvent.code,\n message: closeEvent.reason || closeEvent.message\n }\n };\n } else {\n return null;\n }\n }\n};\n\nexport default Protocol;\n","import * as Collections from '../utils/collections';\nimport { default as EventsDispatcher } from '../events/dispatcher';\nimport Protocol from './protocol/protocol';\nimport { PusherEvent } from './protocol/message-types';\nimport Logger from '../logger';\nimport TransportConnection from '../transports/transport_connection';\nimport Socket from '../socket';\n/**\n * Provides Pusher protocol interface for transports.\n *\n * Emits following events:\n * - message - on received messages\n * - ping - on ping requests\n * - pong - on pong responses\n * - error - when the transport emits an error\n * - closed - after closing the transport\n *\n * It also emits more events when connection closes with a code.\n * See Protocol.getCloseAction to get more details.\n *\n * @param {Number} id\n * @param {AbstractTransport} transport\n */\nexport default class Connection extends EventsDispatcher implements Socket {\n id: string;\n transport: TransportConnection;\n activityTimeout: number;\n\n constructor(id: string, transport: TransportConnection) {\n super();\n this.id = id;\n this.transport = transport;\n this.activityTimeout = transport.activityTimeout;\n this.bindListeners();\n }\n\n /** Returns whether used transport handles activity checks by itself\n *\n * @returns {Boolean} true if activity checks are handled by the transport\n */\n handlesActivityChecks() {\n return this.transport.handlesActivityChecks();\n }\n\n /** Sends raw data.\n *\n * @param {String} data\n */\n send(data: any): boolean {\n return this.transport.send(data);\n }\n\n /** Sends an event.\n *\n * @param {String} name\n * @param {String} data\n * @param {String} [channel]\n * @returns {Boolean} whether message was sent or not\n */\n send_event(name: string, data: any, channel?: string): boolean {\n var event: PusherEvent = { event: name, data: data };\n if (channel) {\n event.channel = channel;\n }\n Logger.debug('Event sent', event);\n return this.send(Protocol.encodeMessage(event));\n }\n\n /** Sends a ping message to the server.\n *\n * Basing on the underlying transport, it might send either transport's\n * protocol-specific ping or pusher:ping event.\n */\n ping() {\n if (this.transport.supportsPing()) {\n this.transport.ping();\n } else {\n this.send_event('pusher:ping', {});\n }\n }\n\n /** Closes the connection. */\n close() {\n this.transport.close();\n }\n\n private bindListeners() {\n var listeners = {\n message: (messageEvent: MessageEvent) => {\n var pusherEvent;\n try {\n pusherEvent = Protocol.decodeMessage(messageEvent);\n } catch (e) {\n this.emit('error', {\n type: 'MessageParseError',\n error: e,\n data: messageEvent.data\n });\n }\n\n if (pusherEvent !== undefined) {\n Logger.debug('Event recd', pusherEvent);\n\n switch (pusherEvent.event) {\n case 'pusher:error':\n this.emit('error', {\n type: 'PusherError',\n data: pusherEvent.data\n });\n break;\n case 'pusher:ping':\n this.emit('ping');\n break;\n case 'pusher:pong':\n this.emit('pong');\n break;\n }\n this.emit('message', pusherEvent);\n }\n },\n activity: () => {\n this.emit('activity');\n },\n error: error => {\n this.emit('error', error);\n },\n closed: closeEvent => {\n unbindListeners();\n\n if (closeEvent && closeEvent.code) {\n this.handleCloseEvent(closeEvent);\n }\n\n this.transport = null;\n this.emit('closed');\n }\n };\n\n var unbindListeners = () => {\n Collections.objectApply(listeners, (listener, event) => {\n this.transport.unbind(event, listener);\n });\n };\n\n Collections.objectApply(listeners, (listener, event) => {\n this.transport.bind(event, listener);\n });\n }\n\n private handleCloseEvent(closeEvent: any) {\n var action = Protocol.getCloseAction(closeEvent);\n var error = Protocol.getCloseError(closeEvent);\n if (error) {\n this.emit('error', error);\n }\n if (action) {\n this.emit(action, { action: action, error: error });\n }\n }\n}\n","import Util from '../../util';\nimport * as Collections from '../../utils/collections';\nimport Protocol from '../protocol/protocol';\nimport Connection from '../connection';\nimport TransportConnection from '../../transports/transport_connection';\nimport HandshakePayload from './handshake_payload';\n\n/**\n * Handles Pusher protocol handshakes for transports.\n *\n * Calls back with a result object after handshake is completed. Results\n * always have two fields:\n * - action - string describing action to be taken after the handshake\n * - transport - the transport object passed to the constructor\n *\n * Different actions can set different additional properties on the result.\n * In the case of 'connected' action, there will be a 'connection' property\n * containing a Connection object for the transport. Other actions should\n * carry an 'error' property.\n *\n * @param {AbstractTransport} transport\n * @param {Function} callback\n */\nexport default class Handshake {\n transport: TransportConnection;\n callback: (HandshakePayload) => void;\n onMessage: Function;\n onClosed: Function;\n\n constructor(\n transport: TransportConnection,\n callback: (HandshakePayload) => void\n ) {\n this.transport = transport;\n this.callback = callback;\n this.bindListeners();\n }\n\n close() {\n this.unbindListeners();\n this.transport.close();\n }\n\n private bindListeners() {\n this.onMessage = m => {\n this.unbindListeners();\n\n var result;\n try {\n result = Protocol.processHandshake(m);\n } catch (e) {\n this.finish('error', { error: e });\n this.transport.close();\n return;\n }\n\n if (result.action === 'connected') {\n this.finish('connected', {\n connection: new Connection(result.id, this.transport),\n activityTimeout: result.activityTimeout\n });\n } else {\n this.finish(result.action, { error: result.error });\n this.transport.close();\n }\n };\n\n this.onClosed = closeEvent => {\n this.unbindListeners();\n\n var action = Protocol.getCloseAction(closeEvent) || 'backoff';\n var error = Protocol.getCloseError(closeEvent);\n this.finish(action, { error: error });\n };\n\n this.transport.bind('message', this.onMessage);\n this.transport.bind('closed', this.onClosed);\n }\n\n private unbindListeners() {\n this.transport.unbind('message', this.onMessage);\n this.transport.unbind('closed', this.onClosed);\n }\n\n private finish(action: string, params: any) {\n this.callback(\n Collections.extend({ transport: this.transport, action: action }, params)\n );\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport base64encode from '../base64';\nimport Timeline from './timeline';\nimport Runtime from 'runtime';\n\nexport interface TimelineSenderOptions {\n host?: string;\n port?: number;\n path?: string;\n}\n\nexport default class TimelineSender {\n timeline: Timeline;\n options: TimelineSenderOptions;\n host: string;\n\n constructor(timeline: Timeline, options: TimelineSenderOptions) {\n this.timeline = timeline;\n this.options = options || {};\n }\n\n send(useTLS: boolean, callback?: Function) {\n if (this.timeline.isEmpty()) {\n return;\n }\n\n this.timeline.send(\n Runtime.TimelineTransport.getAgent(this, useTLS),\n callback\n );\n }\n}\n","/** Error classes used throughout the library. */\n// https://github.com/Microsoft/TypeScript-wiki/blob/master/Breaking-Changes.md#extending-built-ins-like-error-array-and-map-may-no-longer-work\nexport class BadEventName extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\nexport class BadChannelName extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\nexport class RequestTimedOut extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class TransportPriorityTooLow extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class TransportClosed extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class UnsupportedFeature extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class UnsupportedTransport extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class UnsupportedStrategy extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class HTTPAuthError extends Error {\n status: number;\n constructor(status: number, msg?: string) {\n super(msg);\n this.status = status;\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n","/**\n * A place to store help URLs for error messages etc\n */\n\nconst urlStore = {\n baseUrl: 'https://pusher.com',\n urls: {\n authenticationEndpoint: {\n path: '/docs/channels/server_api/authenticating_users'\n },\n authorizationEndpoint: {\n path: '/docs/channels/server_api/authorizing-users/'\n },\n javascriptQuickStart: {\n path: '/docs/javascript_quick_start'\n },\n triggeringClientEvents: {\n path: '/docs/client_api_guide/client_events#trigger-events'\n },\n encryptedChannelSupport: {\n fullUrl:\n 'https://github.com/pusher/pusher-js/tree/cc491015371a4bde5743d1c87a0fbac0feb53195#encrypted-channel-support'\n }\n }\n};\n\n/** Builds a consistent string with links to pusher documentation\n *\n * @param {string} key - relevant key in the url_store.urls object\n * @return {string} suffix string to append to log message\n */\nconst buildLogSuffix = function(key: string): string {\n const urlPrefix = 'See:';\n const urlObj = urlStore.urls[key];\n if (!urlObj) return '';\n\n let url;\n if (urlObj.fullUrl) {\n url = urlObj.fullUrl;\n } else if (urlObj.path) {\n url = urlStore.baseUrl + urlObj.path;\n }\n\n if (!url) return '';\n return `${urlPrefix} ${url}`;\n};\n\nexport default { buildLogSuffix };\n","import { default as EventsDispatcher } from '../events/dispatcher';\nimport * as Errors from '../errors';\nimport Logger from '../logger';\nimport Pusher from '../pusher';\nimport { PusherEvent } from '../connection/protocol/message-types';\nimport Metadata from './metadata';\nimport UrlStore from '../utils/url_store';\nimport {\n ChannelAuthorizationData,\n ChannelAuthorizationCallback\n} from '../auth/options';\nimport { HTTPAuthError } from '../errors';\n\n/** Provides base public channel interface with an event emitter.\n *\n * Emits:\n * - pusher:subscription_succeeded - after subscribing successfully\n * - other non-internal events\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\nexport default class Channel extends EventsDispatcher {\n name: string;\n pusher: Pusher;\n subscribed: boolean;\n subscriptionPending: boolean;\n subscriptionCancelled: boolean;\n subscriptionCount: null;\n\n constructor(name: string, pusher: Pusher) {\n super(function(event, data) {\n Logger.debug('No callbacks on ' + name + ' for ' + event);\n });\n\n this.name = name;\n this.pusher = pusher;\n this.subscribed = false;\n this.subscriptionPending = false;\n this.subscriptionCancelled = false;\n }\n\n /** Skips authorization, since public channels don't require it.\n *\n * @param {Function} callback\n */\n authorize(socketId: string, callback: ChannelAuthorizationCallback) {\n return callback(null, { auth: '' });\n }\n\n /** Triggers an event */\n trigger(event: string, data: any) {\n if (event.indexOf('client-') !== 0) {\n throw new Errors.BadEventName(\n \"Event '\" + event + \"' does not start with 'client-'\"\n );\n }\n if (!this.subscribed) {\n var suffix = UrlStore.buildLogSuffix('triggeringClientEvents');\n Logger.warn(\n `Client event triggered before channel 'subscription_succeeded' event . ${suffix}`\n );\n }\n return this.pusher.send_event(event, data, this.name);\n }\n\n /** Signals disconnection to the channel. For internal use only. */\n disconnect() {\n this.subscribed = false;\n this.subscriptionPending = false;\n }\n\n /** Handles a PusherEvent. For internal use only.\n *\n * @param {PusherEvent} event\n */\n handleEvent(event: PusherEvent) {\n var eventName = event.event;\n var data = event.data;\n if (eventName === 'pusher_internal:subscription_succeeded') {\n this.handleSubscriptionSucceededEvent(event);\n } else if (eventName === 'pusher_internal:subscription_count') {\n this.handleSubscriptionCountEvent(event);\n } else if (eventName.indexOf('pusher_internal:') !== 0) {\n var metadata: Metadata = {};\n this.emit(eventName, data, metadata);\n }\n }\n\n handleSubscriptionSucceededEvent(event: PusherEvent) {\n this.subscriptionPending = false;\n this.subscribed = true;\n if (this.subscriptionCancelled) {\n this.pusher.unsubscribe(this.name);\n } else {\n this.emit('pusher:subscription_succeeded', event.data);\n }\n }\n\n handleSubscriptionCountEvent(event: PusherEvent) {\n if (event.data.subscription_count) {\n this.subscriptionCount = event.data.subscription_count;\n }\n\n this.emit('pusher:subscription_count', event.data);\n }\n\n /** Sends a subscription request. For internal use only. */\n subscribe() {\n if (this.subscribed) {\n return;\n }\n this.subscriptionPending = true;\n this.subscriptionCancelled = false;\n this.authorize(\n this.pusher.connection.socket_id,\n (error: Error | null, data: ChannelAuthorizationData) => {\n if (error) {\n this.subscriptionPending = false;\n // Why not bind to 'pusher:subscription_error' a level up, and log there?\n // Binding to this event would cause the warning about no callbacks being\n // bound (see constructor) to be suppressed, that's not what we want.\n Logger.error(error.toString());\n this.emit(\n 'pusher:subscription_error',\n Object.assign(\n {},\n {\n type: 'AuthError',\n error: error.message\n },\n error instanceof HTTPAuthError ? { status: error.status } : {}\n )\n );\n } else {\n this.pusher.send_event('pusher:subscribe', {\n auth: data.auth,\n channel_data: data.channel_data,\n channel: this.name\n });\n }\n }\n );\n }\n\n /** Sends an unsubscription request. For internal use only. */\n unsubscribe() {\n this.subscribed = false;\n this.pusher.send_event('pusher:unsubscribe', {\n channel: this.name\n });\n }\n\n /** Cancels an in progress subscription. For internal use only. */\n cancelSubscription() {\n this.subscriptionCancelled = true;\n }\n\n /** Reinstates an in progress subscripiton. For internal use only. */\n reinstateSubscription() {\n this.subscriptionCancelled = false;\n }\n}\n","import Factory from '../utils/factory';\nimport Channel from './channel';\nimport { ChannelAuthorizationCallback } from '../auth/options';\n\n/** Extends public channels to provide private channel interface.\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\nexport default class PrivateChannel extends Channel {\n /** Authorizes the connection to use the channel.\n *\n * @param {String} socketId\n * @param {Function} callback\n */\n authorize(socketId: string, callback: ChannelAuthorizationCallback) {\n return this.pusher.config.channelAuthorizer(\n {\n channelName: this.name,\n socketId: socketId\n },\n callback\n );\n }\n}\n","import * as Collections from '../utils/collections';\n\n/** Represents a collection of members of a presence channel. */\nexport default class Members {\n members: any;\n count: number;\n myID: any;\n me: any;\n\n constructor() {\n this.reset();\n }\n\n /** Returns member's info for given id.\n *\n * Resulting object containts two fields - id and info.\n *\n * @param {Number} id\n * @return {Object} member's info or null\n */\n get(id: string): any {\n if (Object.prototype.hasOwnProperty.call(this.members, id)) {\n return {\n id: id,\n info: this.members[id]\n };\n } else {\n return null;\n }\n }\n\n /** Calls back for each member in unspecified order.\n *\n * @param {Function} callback\n */\n each(callback: Function) {\n Collections.objectApply(this.members, (member, id) => {\n callback(this.get(id));\n });\n }\n\n /** Updates the id for connected member. For internal use only. */\n setMyID(id: string) {\n this.myID = id;\n }\n\n /** Handles subscription data. For internal use only. */\n onSubscription(subscriptionData: any) {\n this.members = subscriptionData.presence.hash;\n this.count = subscriptionData.presence.count;\n this.me = this.get(this.myID);\n }\n\n /** Adds a new member to the collection. For internal use only. */\n addMember(memberData: any) {\n if (this.get(memberData.user_id) === null) {\n this.count++;\n }\n this.members[memberData.user_id] = memberData.user_info;\n return this.get(memberData.user_id);\n }\n\n /** Adds a member from the collection. For internal use only. */\n removeMember(memberData: any) {\n var member = this.get(memberData.user_id);\n if (member) {\n delete this.members[memberData.user_id];\n this.count--;\n }\n return member;\n }\n\n /** Resets the collection to the initial state. For internal use only. */\n reset() {\n this.members = {};\n this.count = 0;\n this.myID = null;\n this.me = null;\n }\n}\n","import PrivateChannel from './private_channel';\nimport Logger from '../logger';\nimport Members from './members';\nimport Pusher from '../pusher';\nimport UrlStore from 'core/utils/url_store';\nimport { PusherEvent } from '../connection/protocol/message-types';\nimport Metadata from './metadata';\nimport { ChannelAuthorizationData } from '../auth/options';\n\nexport default class PresenceChannel extends PrivateChannel {\n members: Members;\n\n /** Adds presence channel functionality to private channels.\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\n constructor(name: string, pusher: Pusher) {\n super(name, pusher);\n this.members = new Members();\n }\n\n /** Authorizes the connection as a member of the channel.\n *\n * @param {String} socketId\n * @param {Function} callback\n */\n authorize(socketId: string, callback: Function) {\n super.authorize(socketId, async (error, authData) => {\n if (!error) {\n authData = authData as ChannelAuthorizationData;\n if (authData.channel_data != null) {\n var channelData = JSON.parse(authData.channel_data);\n this.members.setMyID(channelData.user_id);\n } else {\n await this.pusher.user.signinDonePromise;\n if (this.pusher.user.user_data != null) {\n // If the user is signed in, get the id of the authenticated user\n // and allow the presence authorization to continue.\n this.members.setMyID(this.pusher.user.user_data.id);\n } else {\n let suffix = UrlStore.buildLogSuffix('authorizationEndpoint');\n Logger.error(\n `Invalid auth response for channel '${this.name}', ` +\n `expected 'channel_data' field. ${suffix}, ` +\n `or the user should be signed in.`\n );\n callback('Invalid auth response');\n return;\n }\n }\n }\n callback(error, authData);\n });\n }\n\n /** Handles presence and subscription events. For internal use only.\n *\n * @param {PusherEvent} event\n */\n handleEvent(event: PusherEvent) {\n var eventName = event.event;\n if (eventName.indexOf('pusher_internal:') === 0) {\n this.handleInternalEvent(event);\n } else {\n var data = event.data;\n var metadata: Metadata = {};\n if (event.user_id) {\n metadata.user_id = event.user_id;\n }\n this.emit(eventName, data, metadata);\n }\n }\n handleInternalEvent(event: PusherEvent) {\n var eventName = event.event;\n var data = event.data;\n switch (eventName) {\n case 'pusher_internal:subscription_succeeded':\n this.handleSubscriptionSucceededEvent(event);\n break;\n case 'pusher_internal:subscription_count':\n this.handleSubscriptionCountEvent(event);\n break;\n case 'pusher_internal:member_added':\n var addedMember = this.members.addMember(data);\n this.emit('pusher:member_added', addedMember);\n break;\n case 'pusher_internal:member_removed':\n var removedMember = this.members.removeMember(data);\n if (removedMember) {\n this.emit('pusher:member_removed', removedMember);\n }\n break;\n }\n }\n\n handleSubscriptionSucceededEvent(event: PusherEvent) {\n this.subscriptionPending = false;\n this.subscribed = true;\n if (this.subscriptionCancelled) {\n this.pusher.unsubscribe(this.name);\n } else {\n this.members.onSubscription(event.data);\n this.emit('pusher:subscription_succeeded', this.members);\n }\n }\n\n /** Resets the channel state, including members map. For internal use only. */\n disconnect() {\n this.members.reset();\n super.disconnect();\n }\n}\n","import PrivateChannel from './private_channel';\nimport * as Errors from '../errors';\nimport Logger from '../logger';\nimport Pusher from '../pusher';\nimport { decode as encodeUTF8 } from '@stablelib/utf8';\nimport { decode as decodeBase64 } from '@stablelib/base64';\nimport Dispatcher from '../events/dispatcher';\nimport { PusherEvent } from '../connection/protocol/message-types';\nimport {\n ChannelAuthorizationData,\n ChannelAuthorizationCallback\n} from '../auth/options';\nimport * as nacl from 'tweetnacl';\n\n/** Extends private channels to provide encrypted channel interface.\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\nexport default class EncryptedChannel extends PrivateChannel {\n key: Uint8Array = null;\n nacl: nacl;\n\n constructor(name: string, pusher: Pusher, nacl: nacl) {\n super(name, pusher);\n this.nacl = nacl;\n }\n\n /** Authorizes the connection to use the channel.\n *\n * @param {String} socketId\n * @param {Function} callback\n */\n authorize(socketId: string, callback: ChannelAuthorizationCallback) {\n super.authorize(\n socketId,\n (error: Error | null, authData: ChannelAuthorizationData) => {\n if (error) {\n callback(error, authData);\n return;\n }\n let sharedSecret = authData['shared_secret'];\n if (!sharedSecret) {\n callback(\n new Error(\n `No shared_secret key in auth payload for encrypted channel: ${this.name}`\n ),\n null\n );\n return;\n }\n this.key = decodeBase64(sharedSecret);\n delete authData['shared_secret'];\n callback(null, authData);\n }\n );\n }\n\n trigger(event: string, data: any): boolean {\n throw new Errors.UnsupportedFeature(\n 'Client events are not currently supported for encrypted channels'\n );\n }\n\n /** Handles an event. For internal use only.\n *\n * @param {PusherEvent} event\n */\n handleEvent(event: PusherEvent) {\n var eventName = event.event;\n var data = event.data;\n if (\n eventName.indexOf('pusher_internal:') === 0 ||\n eventName.indexOf('pusher:') === 0\n ) {\n super.handleEvent(event);\n return;\n }\n this.handleEncryptedEvent(eventName, data);\n }\n\n private handleEncryptedEvent(event: string, data: any): void {\n if (!this.key) {\n Logger.debug(\n 'Received encrypted event before key has been retrieved from the authEndpoint'\n );\n return;\n }\n if (!data.ciphertext || !data.nonce) {\n Logger.error(\n 'Unexpected format for encrypted event, expected object with `ciphertext` and `nonce` fields, got: ' +\n data\n );\n return;\n }\n let cipherText = decodeBase64(data.ciphertext);\n if (cipherText.length < this.nacl.secretbox.overheadLength) {\n Logger.error(\n `Expected encrypted event ciphertext length to be ${this.nacl.secretbox.overheadLength}, got: ${cipherText.length}`\n );\n return;\n }\n let nonce = decodeBase64(data.nonce);\n if (nonce.length < this.nacl.secretbox.nonceLength) {\n Logger.error(\n `Expected encrypted event nonce length to be ${this.nacl.secretbox.nonceLength}, got: ${nonce.length}`\n );\n return;\n }\n\n let bytes = this.nacl.secretbox.open(cipherText, nonce, this.key);\n if (bytes === null) {\n Logger.debug(\n 'Failed to decrypt an event, probably because it was encrypted with a different key. Fetching a new key from the authEndpoint...'\n );\n // Try a single time to retrieve a new auth key and decrypt the event with it\n // If this fails, a new key will be requested when a new message is received\n this.authorize(this.pusher.connection.socket_id, (error, authData) => {\n if (error) {\n Logger.error(\n `Failed to make a request to the authEndpoint: ${authData}. Unable to fetch new key, so dropping encrypted event`\n );\n return;\n }\n bytes = this.nacl.secretbox.open(cipherText, nonce, this.key);\n if (bytes === null) {\n Logger.error(\n `Failed to decrypt event with new key. Dropping encrypted event`\n );\n return;\n }\n this.emit(event, this.getDataToEmit(bytes));\n return;\n });\n return;\n }\n this.emit(event, this.getDataToEmit(bytes));\n }\n\n // Try and parse the decrypted bytes as JSON. If we can't parse it, just\n // return the utf-8 string\n getDataToEmit(bytes: Uint8Array): string {\n let raw = encodeUTF8(bytes);\n try {\n return JSON.parse(raw);\n } catch {\n return raw;\n }\n }\n}\n","import { default as EventsDispatcher } from '../events/dispatcher';\nimport { OneOffTimer as Timer } from '../utils/timers';\nimport { Config } from '../config';\nimport Logger from '../logger';\nimport HandshakePayload from './handshake/handshake_payload';\nimport Connection from './connection';\nimport Strategy from '../strategies/strategy';\nimport StrategyRunner from '../strategies/strategy_runner';\nimport * as Collections from '../utils/collections';\nimport Timeline from '../timeline/timeline';\nimport ConnectionManagerOptions from './connection_manager_options';\nimport Runtime from 'runtime';\n\nimport {\n ErrorCallbacks,\n HandshakeCallbacks,\n ConnectionCallbacks\n} from './callbacks';\nimport Action from './protocol/action';\n\n/** Manages connection to Pusher.\n *\n * Uses a strategy (currently only default), timers and network availability\n * info to establish a connection and export its state. In case of failures,\n * manages reconnection attempts.\n *\n * Exports state changes as following events:\n * - \"state_change\", { previous: p, current: state }\n * - state\n *\n * States:\n * - initialized - initial state, never transitioned to\n * - connecting - connection is being established\n * - connected - connection has been fully established\n * - disconnected - on requested disconnection\n * - unavailable - after connection timeout or when there's no network\n * - failed - when the connection strategy is not supported\n *\n * Options:\n * - unavailableTimeout - time to transition to unavailable state\n * - activityTimeout - time after which ping message should be sent\n * - pongTimeout - time for Pusher to respond with pong before reconnecting\n *\n * @param {String} key application key\n * @param {Object} options\n */\nexport default class ConnectionManager extends EventsDispatcher {\n key: string;\n options: ConnectionManagerOptions;\n state: string;\n connection: Connection;\n usingTLS: boolean;\n timeline: Timeline;\n socket_id: string;\n unavailableTimer: Timer;\n activityTimer: Timer;\n retryTimer: Timer;\n activityTimeout: number;\n strategy: Strategy;\n runner: StrategyRunner;\n errorCallbacks: ErrorCallbacks;\n handshakeCallbacks: HandshakeCallbacks;\n connectionCallbacks: ConnectionCallbacks;\n\n constructor(key: string, options: ConnectionManagerOptions) {\n super();\n this.state = 'initialized';\n this.connection = null;\n\n this.key = key;\n this.options = options;\n this.timeline = this.options.timeline;\n this.usingTLS = this.options.useTLS;\n\n this.errorCallbacks = this.buildErrorCallbacks();\n this.connectionCallbacks = this.buildConnectionCallbacks(\n this.errorCallbacks\n );\n this.handshakeCallbacks = this.buildHandshakeCallbacks(this.errorCallbacks);\n\n var Network = Runtime.getNetwork();\n\n Network.bind('online', () => {\n this.timeline.info({ netinfo: 'online' });\n if (this.state === 'connecting' || this.state === 'unavailable') {\n this.retryIn(0);\n }\n });\n Network.bind('offline', () => {\n this.timeline.info({ netinfo: 'offline' });\n if (this.connection) {\n this.sendActivityCheck();\n }\n });\n\n this.updateStrategy();\n }\n\n switchCluster(key: string) {\n this.key = key;\n // This ensures that the new config coming from\n // pusher instance are taken into account\n // such as appKey and cluster\n this.updateStrategy();\n this.retryIn(0);\n }\n\n /** Establishes a connection to Pusher.\n *\n * Does nothing when connection is already established. See top-level doc\n * to find events emitted on connection attempts.\n */\n connect() {\n if (this.connection || this.runner) {\n return;\n }\n if (!this.strategy.isSupported()) {\n this.updateState('failed');\n return;\n }\n this.updateState('connecting');\n this.startConnecting();\n this.setUnavailableTimer();\n }\n\n /** Sends raw data.\n *\n * @param {String} data\n */\n send(data) {\n if (this.connection) {\n return this.connection.send(data);\n } else {\n return false;\n }\n }\n\n /** Sends an event.\n *\n * @param {String} name\n * @param {String} data\n * @param {String} [channel]\n * @returns {Boolean} whether message was sent or not\n */\n send_event(name: string, data: any, channel?: string) {\n if (this.connection) {\n return this.connection.send_event(name, data, channel);\n } else {\n return false;\n }\n }\n\n /** Closes the connection. */\n disconnect() {\n this.disconnectInternally();\n this.updateState('disconnected');\n }\n\n isUsingTLS() {\n return this.usingTLS;\n }\n\n private startConnecting() {\n var callback = (error, handshake) => {\n if (error) {\n this.runner = this.strategy.connect(0, callback);\n } else {\n if (handshake.action === 'error') {\n this.emit('error', {\n type: 'HandshakeError',\n error: handshake.error\n });\n this.timeline.error({ handshakeError: handshake.error });\n } else {\n this.abortConnecting(); // we don't support switching connections yet\n this.handshakeCallbacks[handshake.action](handshake);\n }\n }\n };\n this.runner = this.strategy.connect(0, callback);\n }\n\n private abortConnecting() {\n if (this.runner) {\n this.runner.abort();\n this.runner = null;\n }\n }\n\n private disconnectInternally() {\n this.abortConnecting();\n this.clearRetryTimer();\n this.clearUnavailableTimer();\n if (this.connection) {\n var connection = this.abandonConnection();\n connection.close();\n }\n }\n\n private updateStrategy() {\n this.strategy = this.options.getStrategy({\n key: this.key,\n timeline: this.timeline,\n useTLS: this.usingTLS\n });\n }\n\n private retryIn(delay) {\n this.timeline.info({ action: 'retry', delay: delay });\n if (delay > 0) {\n this.emit('connecting_in', Math.round(delay / 1000));\n }\n this.retryTimer = new Timer(delay || 0, () => {\n this.disconnectInternally();\n this.connect();\n });\n }\n\n private clearRetryTimer() {\n if (this.retryTimer) {\n this.retryTimer.ensureAborted();\n this.retryTimer = null;\n }\n }\n\n private setUnavailableTimer() {\n this.unavailableTimer = new Timer(this.options.unavailableTimeout, () => {\n this.updateState('unavailable');\n });\n }\n\n private clearUnavailableTimer() {\n if (this.unavailableTimer) {\n this.unavailableTimer.ensureAborted();\n }\n }\n\n private sendActivityCheck() {\n this.stopActivityCheck();\n this.connection.ping();\n // wait for pong response\n this.activityTimer = new Timer(this.options.pongTimeout, () => {\n this.timeline.error({ pong_timed_out: this.options.pongTimeout });\n this.retryIn(0);\n });\n }\n\n private resetActivityCheck() {\n this.stopActivityCheck();\n // send ping after inactivity\n if (this.connection && !this.connection.handlesActivityChecks()) {\n this.activityTimer = new Timer(this.activityTimeout, () => {\n this.sendActivityCheck();\n });\n }\n }\n\n private stopActivityCheck() {\n if (this.activityTimer) {\n this.activityTimer.ensureAborted();\n }\n }\n\n private buildConnectionCallbacks(\n errorCallbacks: ErrorCallbacks\n ): ConnectionCallbacks {\n return Collections.extend({}, errorCallbacks, {\n message: message => {\n // includes pong messages from server\n this.resetActivityCheck();\n this.emit('message', message);\n },\n ping: () => {\n this.send_event('pusher:pong', {});\n },\n activity: () => {\n this.resetActivityCheck();\n },\n error: error => {\n // just emit error to user - socket will already be closed by browser\n this.emit('error', error);\n },\n closed: () => {\n this.abandonConnection();\n if (this.shouldRetry()) {\n this.retryIn(1000);\n }\n }\n });\n }\n\n private buildHandshakeCallbacks(\n errorCallbacks: ErrorCallbacks\n ): HandshakeCallbacks {\n return Collections.extend({}, errorCallbacks, {\n connected: (handshake: HandshakePayload) => {\n this.activityTimeout = Math.min(\n this.options.activityTimeout,\n handshake.activityTimeout,\n handshake.connection.activityTimeout || Infinity\n );\n this.clearUnavailableTimer();\n this.setConnection(handshake.connection);\n this.socket_id = this.connection.id;\n this.updateState('connected', { socket_id: this.socket_id });\n }\n });\n }\n\n private buildErrorCallbacks(): ErrorCallbacks {\n let withErrorEmitted = callback => {\n return (result: Action | HandshakePayload) => {\n if (result.error) {\n this.emit('error', { type: 'WebSocketError', error: result.error });\n }\n callback(result);\n };\n };\n\n return {\n tls_only: withErrorEmitted(() => {\n this.usingTLS = true;\n this.updateStrategy();\n this.retryIn(0);\n }),\n refused: withErrorEmitted(() => {\n this.disconnect();\n }),\n backoff: withErrorEmitted(() => {\n this.retryIn(1000);\n }),\n retry: withErrorEmitted(() => {\n this.retryIn(0);\n })\n };\n }\n\n private setConnection(connection) {\n this.connection = connection;\n for (var event in this.connectionCallbacks) {\n this.connection.bind(event, this.connectionCallbacks[event]);\n }\n this.resetActivityCheck();\n }\n\n private abandonConnection() {\n if (!this.connection) {\n return;\n }\n this.stopActivityCheck();\n for (var event in this.connectionCallbacks) {\n this.connection.unbind(event, this.connectionCallbacks[event]);\n }\n var connection = this.connection;\n this.connection = null;\n return connection;\n }\n\n private updateState(newState: string, data?: any) {\n var previousState = this.state;\n this.state = newState;\n if (previousState !== newState) {\n var newStateDescription = newState;\n if (newStateDescription === 'connected') {\n newStateDescription += ' with new socket ID ' + data.socket_id;\n }\n Logger.debug(\n 'State changed',\n previousState + ' -> ' + newStateDescription\n );\n this.timeline.info({ state: newState, params: data });\n this.emit('state_change', { previous: previousState, current: newState });\n this.emit(newState, data);\n }\n }\n\n private shouldRetry(): boolean {\n return this.state === 'connecting' || this.state === 'connected';\n }\n}\n","import Channel from './channel';\nimport * as Collections from '../utils/collections';\nimport ChannelTable from './channel_table';\nimport Factory from '../utils/factory';\nimport Pusher from '../pusher';\nimport Logger from '../logger';\nimport * as Errors from '../errors';\nimport urlStore from '../utils/url_store';\n\n/** Handles a channel map. */\nexport default class Channels {\n channels: ChannelTable;\n\n constructor() {\n this.channels = {};\n }\n\n /** Creates or retrieves an existing channel by its name.\n *\n * @param {String} name\n * @param {Pusher} pusher\n * @return {Channel}\n */\n add(name: string, pusher: Pusher) {\n if (!this.channels[name]) {\n this.channels[name] = createChannel(name, pusher);\n }\n return this.channels[name];\n }\n\n /** Returns a list of all channels\n *\n * @return {Array}\n */\n all(): Channel[] {\n return Collections.values(this.channels);\n }\n\n /** Finds a channel by its name.\n *\n * @param {String} name\n * @return {Channel} channel or null if it doesn't exist\n */\n find(name: string) {\n return this.channels[name];\n }\n\n /** Removes a channel from the map.\n *\n * @param {String} name\n */\n remove(name: string) {\n var channel = this.channels[name];\n delete this.channels[name];\n return channel;\n }\n\n /** Proxies disconnection signal to all channels. */\n disconnect() {\n Collections.objectApply(this.channels, function(channel) {\n channel.disconnect();\n });\n }\n}\n\nfunction createChannel(name: string, pusher: Pusher): Channel {\n if (name.indexOf('private-encrypted-') === 0) {\n if (pusher.config.nacl) {\n return Factory.createEncryptedChannel(name, pusher, pusher.config.nacl);\n }\n let errMsg =\n 'Tried to subscribe to a private-encrypted- channel but no nacl implementation available';\n let suffix = urlStore.buildLogSuffix('encryptedChannelSupport');\n throw new Errors.UnsupportedFeature(`${errMsg}. ${suffix}`);\n } else if (name.indexOf('private-') === 0) {\n return Factory.createPrivateChannel(name, pusher);\n } else if (name.indexOf('presence-') === 0) {\n return Factory.createPresenceChannel(name, pusher);\n } else if (name.indexOf('#') === 0) {\n throw new Errors.BadChannelName(\n 'Cannot create a channel with name \"' + name + '\".'\n );\n } else {\n return Factory.createChannel(name, pusher);\n }\n}\n","import AssistantToTheTransportManager from '../transports/assistant_to_the_transport_manager';\nimport PingDelayOptions from '../transports/ping_delay_options';\nimport Transport from '../transports/transport';\nimport TransportManager from '../transports/transport_manager';\nimport Handshake from '../connection/handshake';\nimport TransportConnection from '../transports/transport_connection';\nimport SocketHooks from '../http/socket_hooks';\nimport HTTPSocket from '../http/http_socket';\n\nimport Timeline from '../timeline/timeline';\nimport {\n default as TimelineSender,\n TimelineSenderOptions\n} from '../timeline/timeline_sender';\nimport PresenceChannel from '../channels/presence_channel';\nimport PrivateChannel from '../channels/private_channel';\nimport EncryptedChannel from '../channels/encrypted_channel';\nimport Channel from '../channels/channel';\nimport ConnectionManager from '../connection/connection_manager';\nimport ConnectionManagerOptions from '../connection/connection_manager_options';\nimport Ajax from '../http/ajax';\nimport Channels from '../channels/channels';\nimport Pusher from '../pusher';\nimport { Config } from '../config';\nimport * as nacl from 'tweetnacl';\n\nvar Factory = {\n createChannels(): Channels {\n return new Channels();\n },\n\n createConnectionManager(\n key: string,\n options: ConnectionManagerOptions\n ): ConnectionManager {\n return new ConnectionManager(key, options);\n },\n\n createChannel(name: string, pusher: Pusher): Channel {\n return new Channel(name, pusher);\n },\n\n createPrivateChannel(name: string, pusher: Pusher): PrivateChannel {\n return new PrivateChannel(name, pusher);\n },\n\n createPresenceChannel(name: string, pusher: Pusher): PresenceChannel {\n return new PresenceChannel(name, pusher);\n },\n\n createEncryptedChannel(\n name: string,\n pusher: Pusher,\n nacl: nacl\n ): EncryptedChannel {\n return new EncryptedChannel(name, pusher, nacl);\n },\n\n createTimelineSender(timeline: Timeline, options: TimelineSenderOptions) {\n return new TimelineSender(timeline, options);\n },\n\n createHandshake(\n transport: TransportConnection,\n callback: (HandshakePayload) => void\n ): Handshake {\n return new Handshake(transport, callback);\n },\n\n createAssistantToTheTransportManager(\n manager: TransportManager,\n transport: Transport,\n options: PingDelayOptions\n ): AssistantToTheTransportManager {\n return new AssistantToTheTransportManager(manager, transport, options);\n }\n};\n\nexport default Factory;\n","import AssistantToTheTransportManager from './assistant_to_the_transport_manager';\nimport Transport from './transport';\nimport PingDelayOptions from './ping_delay_options';\nimport Factory from '../utils/factory';\n\nexport interface TransportManagerOptions extends PingDelayOptions {\n lives?: number;\n}\n\n/** Keeps track of the number of lives left for a transport.\n *\n * In the beginning of a session, transports may be assigned a number of\n * lives. When an AssistantToTheTransportManager instance reports a transport\n * connection closed uncleanly, the transport loses a life. When the number\n * of lives drops to zero, the transport gets disabled by its manager.\n *\n * @param {Object} options\n */\nexport default class TransportManager {\n options: TransportManagerOptions;\n livesLeft: number;\n\n constructor(options: TransportManagerOptions) {\n this.options = options || {};\n this.livesLeft = this.options.lives || Infinity;\n }\n\n /** Creates a assistant for the transport.\n *\n * @param {Transport} transport\n * @returns {AssistantToTheTransportManager}\n */\n getAssistant(transport: Transport): AssistantToTheTransportManager {\n return Factory.createAssistantToTheTransportManager(this, transport, {\n minPingDelay: this.options.minPingDelay,\n maxPingDelay: this.options.maxPingDelay\n });\n }\n\n /** Returns whether the transport has any lives left.\n *\n * @returns {Boolean}\n */\n isAlive(): boolean {\n return this.livesLeft > 0;\n }\n\n /** Takes one life from the transport. */\n reportDeath() {\n this.livesLeft -= 1;\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport { OneOffTimer as Timer } from '../utils/timers';\nimport Strategy from './strategy';\nimport StrategyOptions from './strategy_options';\n\n/** Loops through strategies with optional timeouts.\n *\n * Options:\n * - loop - whether it should loop through the substrategy list\n * - timeout - initial timeout for a single substrategy\n * - timeoutLimit - maximum timeout\n *\n * @param {Strategy[]} strategies\n * @param {Object} options\n */\nexport default class SequentialStrategy implements Strategy {\n strategies: Strategy[];\n loop: boolean;\n failFast: boolean;\n timeout: number;\n timeoutLimit: number;\n\n constructor(strategies: Strategy[], options: StrategyOptions) {\n this.strategies = strategies;\n this.loop = Boolean(options.loop);\n this.failFast = Boolean(options.failFast);\n this.timeout = options.timeout;\n this.timeoutLimit = options.timeoutLimit;\n }\n\n isSupported(): boolean {\n return Collections.any(this.strategies, Util.method('isSupported'));\n }\n\n connect(minPriority: number, callback: Function) {\n var strategies = this.strategies;\n var current = 0;\n var timeout = this.timeout;\n var runner = null;\n\n var tryNextStrategy = (error, handshake) => {\n if (handshake) {\n callback(null, handshake);\n } else {\n current = current + 1;\n if (this.loop) {\n current = current % strategies.length;\n }\n\n if (current < strategies.length) {\n if (timeout) {\n timeout = timeout * 2;\n if (this.timeoutLimit) {\n timeout = Math.min(timeout, this.timeoutLimit);\n }\n }\n runner = this.tryStrategy(\n strategies[current],\n minPriority,\n { timeout, failFast: this.failFast },\n tryNextStrategy\n );\n } else {\n callback(true);\n }\n }\n };\n\n runner = this.tryStrategy(\n strategies[current],\n minPriority,\n { timeout: timeout, failFast: this.failFast },\n tryNextStrategy\n );\n\n return {\n abort: function() {\n runner.abort();\n },\n forceMinPriority: function(p) {\n minPriority = p;\n if (runner) {\n runner.forceMinPriority(p);\n }\n }\n };\n }\n\n private tryStrategy(\n strategy: Strategy,\n minPriority: number,\n options: StrategyOptions,\n callback: Function\n ) {\n var timer = null;\n var runner = null;\n\n if (options.timeout > 0) {\n timer = new Timer(options.timeout, function() {\n runner.abort();\n callback(true);\n });\n }\n\n runner = strategy.connect(minPriority, function(error, handshake) {\n if (error && timer && timer.isRunning() && !options.failFast) {\n // advance to the next strategy after the timeout\n return;\n }\n if (timer) {\n timer.ensureAborted();\n }\n callback(error, handshake);\n });\n\n return {\n abort: function() {\n if (timer) {\n timer.ensureAborted();\n }\n runner.abort();\n },\n forceMinPriority: function(p) {\n runner.forceMinPriority(p);\n }\n };\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport Strategy from './strategy';\n\n/** Launches all substrategies and emits prioritized connected transports.\n *\n * @param {Array} strategies\n */\nexport default class BestConnectedEverStrategy implements Strategy {\n strategies: Strategy[];\n\n constructor(strategies: Strategy[]) {\n this.strategies = strategies;\n }\n\n isSupported(): boolean {\n return Collections.any(this.strategies, Util.method('isSupported'));\n }\n\n connect(minPriority: number, callback: Function) {\n return connect(this.strategies, minPriority, function(i, runners) {\n return function(error, handshake) {\n runners[i].error = error;\n if (error) {\n if (allRunnersFailed(runners)) {\n callback(true);\n }\n return;\n }\n Collections.apply(runners, function(runner) {\n runner.forceMinPriority(handshake.transport.priority);\n });\n callback(null, handshake);\n };\n });\n }\n}\n\n/** Connects to all strategies in parallel.\n *\n * Callback builder should be a function that takes two arguments: index\n * and a list of runners. It should return another function that will be\n * passed to the substrategy with given index. Runners can be aborted using\n * abortRunner(s) functions from this class.\n *\n * @param {Array} strategies\n * @param {Function} callbackBuilder\n * @return {Object} strategy runner\n */\nfunction connect(\n strategies: Strategy[],\n minPriority: number,\n callbackBuilder: Function\n) {\n var runners = Collections.map(strategies, function(strategy, i, _, rs) {\n return strategy.connect(minPriority, callbackBuilder(i, rs));\n });\n return {\n abort: function() {\n Collections.apply(runners, abortRunner);\n },\n forceMinPriority: function(p) {\n Collections.apply(runners, function(runner) {\n runner.forceMinPriority(p);\n });\n }\n };\n}\n\nfunction allRunnersFailed(runners): boolean {\n return Collections.all(runners, function(runner) {\n return Boolean(runner.error);\n });\n}\n\nfunction abortRunner(runner) {\n if (!runner.error && !runner.aborted) {\n runner.abort();\n runner.aborted = true;\n }\n}\n","import Util from '../util';\nimport Runtime from 'runtime';\nimport Strategy from './strategy';\nimport SequentialStrategy from './sequential_strategy';\nimport StrategyOptions from './strategy_options';\nimport TransportStrategy from './transport_strategy';\nimport Timeline from '../timeline/timeline';\nimport * as Collections from '../utils/collections';\n\nexport interface TransportStrategyDictionary {\n [key: string]: TransportStrategy;\n}\n\n/** Caches the last successful transport and, after the first few attempts,\n * uses the cached transport for subsequent attempts.\n *\n * @param {Strategy} strategy\n * @param {Object} transports\n * @param {Object} options\n */\nexport default class WebSocketPrioritizedCachedStrategy implements Strategy {\n strategy: Strategy;\n transports: TransportStrategyDictionary;\n ttl: number;\n usingTLS: boolean;\n timeline: Timeline;\n\n constructor(\n strategy: Strategy,\n transports: TransportStrategyDictionary,\n options: StrategyOptions\n ) {\n this.strategy = strategy;\n this.transports = transports;\n this.ttl = options.ttl || 1800 * 1000;\n this.usingTLS = options.useTLS;\n this.timeline = options.timeline;\n }\n\n isSupported(): boolean {\n return this.strategy.isSupported();\n }\n\n connect(minPriority: number, callback: Function) {\n var usingTLS = this.usingTLS;\n var info = fetchTransportCache(usingTLS);\n var cacheSkipCount = info && info.cacheSkipCount ? info.cacheSkipCount : 0;\n\n var strategies = [this.strategy];\n if (info && info.timestamp + this.ttl >= Util.now()) {\n var transport = this.transports[info.transport];\n if (transport) {\n if (['ws', 'wss'].includes(info.transport) || cacheSkipCount > 3) {\n this.timeline.info({\n cached: true,\n transport: info.transport,\n latency: info.latency\n });\n strategies.push(\n new SequentialStrategy([transport], {\n timeout: info.latency * 2 + 1000,\n failFast: true\n })\n );\n } else {\n cacheSkipCount++;\n }\n }\n }\n\n var startTimestamp = Util.now();\n var runner = strategies\n .pop()\n .connect(minPriority, function cb(error, handshake) {\n if (error) {\n flushTransportCache(usingTLS);\n if (strategies.length > 0) {\n startTimestamp = Util.now();\n runner = strategies.pop().connect(minPriority, cb);\n } else {\n callback(error);\n }\n } else {\n storeTransportCache(\n usingTLS,\n handshake.transport.name,\n Util.now() - startTimestamp,\n cacheSkipCount\n );\n callback(null, handshake);\n }\n });\n\n return {\n abort: function() {\n runner.abort();\n },\n forceMinPriority: function(p) {\n minPriority = p;\n if (runner) {\n runner.forceMinPriority(p);\n }\n }\n };\n }\n}\n\nfunction getTransportCacheKey(usingTLS: boolean): string {\n return 'pusherTransport' + (usingTLS ? 'TLS' : 'NonTLS');\n}\n\nfunction fetchTransportCache(usingTLS: boolean): any {\n var storage = Runtime.getLocalStorage();\n if (storage) {\n try {\n var serializedCache = storage[getTransportCacheKey(usingTLS)];\n if (serializedCache) {\n return JSON.parse(serializedCache);\n }\n } catch (e) {\n flushTransportCache(usingTLS);\n }\n }\n return null;\n}\n\nfunction storeTransportCache(\n usingTLS: boolean,\n transport: TransportStrategy,\n latency: number,\n cacheSkipCount: number\n) {\n var storage = Runtime.getLocalStorage();\n if (storage) {\n try {\n storage[getTransportCacheKey(usingTLS)] = Collections.safeJSONStringify({\n timestamp: Util.now(),\n transport: transport,\n latency: latency,\n cacheSkipCount: cacheSkipCount\n });\n } catch (e) {\n // catch over quota exceptions raised by localStorage\n }\n }\n}\n\nfunction flushTransportCache(usingTLS: boolean) {\n var storage = Runtime.getLocalStorage();\n if (storage) {\n try {\n delete storage[getTransportCacheKey(usingTLS)];\n } catch (e) {\n // catch exceptions raised by localStorage\n }\n }\n}\n","import { OneOffTimer as Timer } from '../utils/timers';\nimport Strategy from './strategy';\nimport StrategyOptions from './strategy_options';\n\n/** Runs substrategy after specified delay.\n *\n * Options:\n * - delay - time in miliseconds to delay the substrategy attempt\n *\n * @param {Strategy} strategy\n * @param {Object} options\n */\nexport default class DelayedStrategy implements Strategy {\n strategy: Strategy;\n options: { delay: number };\n\n constructor(strategy: Strategy, { delay: number }) {\n this.strategy = strategy;\n this.options = { delay: number };\n }\n\n isSupported(): boolean {\n return this.strategy.isSupported();\n }\n\n connect(minPriority: number, callback: Function) {\n var strategy = this.strategy;\n var runner;\n var timer = new Timer(this.options.delay, function() {\n runner = strategy.connect(minPriority, callback);\n });\n\n return {\n abort: function() {\n timer.ensureAborted();\n if (runner) {\n runner.abort();\n }\n },\n forceMinPriority: function(p) {\n minPriority = p;\n if (runner) {\n runner.forceMinPriority(p);\n }\n }\n };\n }\n}\n","import Strategy from './strategy';\nimport StrategyRunner from './strategy_runner';\n\n/** Proxies method calls to one of substrategies basing on the test function.\n *\n * @param {Function} test\n * @param {Strategy} trueBranch strategy used when test returns true\n * @param {Strategy} falseBranch strategy used when test returns false\n */\nexport default class IfStrategy implements Strategy {\n test: () => boolean;\n trueBranch: Strategy;\n falseBranch: Strategy;\n\n constructor(\n test: () => boolean,\n trueBranch: Strategy,\n falseBranch: Strategy\n ) {\n this.test = test;\n this.trueBranch = trueBranch;\n this.falseBranch = falseBranch;\n }\n\n isSupported(): boolean {\n var branch = this.test() ? this.trueBranch : this.falseBranch;\n return branch.isSupported();\n }\n\n connect(minPriority: number, callback: Function): StrategyRunner {\n var branch = this.test() ? this.trueBranch : this.falseBranch;\n return branch.connect(minPriority, callback);\n }\n}\n","import Strategy from './strategy';\nimport StrategyRunner from './strategy_runner';\n\n/** Launches the substrategy and terminates on the first open connection.\n *\n * @param {Strategy} strategy\n */\nexport default class FirstConnectedStrategy implements Strategy {\n strategy: Strategy;\n\n constructor(strategy: Strategy) {\n this.strategy = strategy;\n }\n\n isSupported(): boolean {\n return this.strategy.isSupported();\n }\n\n connect(minPriority: number, callback: Function): StrategyRunner {\n var runner = this.strategy.connect(minPriority, function(error, handshake) {\n if (handshake) {\n runner.abort();\n }\n callback(error, handshake);\n });\n return runner;\n }\n}\n","import * as Collections from 'core/utils/collections';\nimport TransportManager from 'core/transports/transport_manager';\nimport Strategy from 'core/strategies/strategy';\nimport SequentialStrategy from 'core/strategies/sequential_strategy';\nimport BestConnectedEverStrategy from 'core/strategies/best_connected_ever_strategy';\nimport WebSocketPrioritizedCachedStrategy, {\n TransportStrategyDictionary\n} from 'core/strategies/websocket_prioritized_cached_strategy';\nimport DelayedStrategy from 'core/strategies/delayed_strategy';\nimport IfStrategy from 'core/strategies/if_strategy';\nimport FirstConnectedStrategy from 'core/strategies/first_connected_strategy';\nimport { Config } from 'core/config';\nimport StrategyOptions from 'core/strategies/strategy_options';\n\nfunction testSupportsStrategy(strategy: Strategy) {\n return function() {\n return strategy.isSupported();\n };\n}\n\nvar getDefaultStrategy = function(\n config: Config,\n baseOptions: StrategyOptions,\n defineTransport: Function\n): Strategy {\n var definedTransports = {};\n\n function defineTransportStrategy(\n name: string,\n type: string,\n priority: number,\n options: StrategyOptions,\n manager?: TransportManager\n ) {\n var transport = defineTransport(\n config,\n name,\n type,\n priority,\n options,\n manager\n );\n\n definedTransports[name] = transport;\n\n return transport;\n }\n\n var ws_options: StrategyOptions = Object.assign({}, baseOptions, {\n hostNonTLS: config.wsHost + ':' + config.wsPort,\n hostTLS: config.wsHost + ':' + config.wssPort,\n httpPath: config.wsPath\n });\n var wss_options: StrategyOptions = Collections.extend({}, ws_options, {\n useTLS: true\n });\n var http_options: StrategyOptions = Object.assign({}, baseOptions, {\n hostNonTLS: config.httpHost + ':' + config.httpPort,\n hostTLS: config.httpHost + ':' + config.httpsPort,\n httpPath: config.httpPath\n });\n var timeouts = {\n loop: true,\n timeout: 15000,\n timeoutLimit: 60000\n };\n\n var ws_manager = new TransportManager({\n minPingDelay: 10000,\n maxPingDelay: config.activityTimeout\n });\n var streaming_manager = new TransportManager({\n lives: 2,\n minPingDelay: 10000,\n maxPingDelay: config.activityTimeout\n });\n\n var ws_transport = defineTransportStrategy(\n 'ws',\n 'ws',\n 3,\n ws_options,\n ws_manager\n );\n var wss_transport = defineTransportStrategy(\n 'wss',\n 'ws',\n 3,\n wss_options,\n ws_manager\n );\n var xhr_streaming_transport = defineTransportStrategy(\n 'xhr_streaming',\n 'xhr_streaming',\n 1,\n http_options,\n streaming_manager\n );\n var xhr_polling_transport = defineTransportStrategy(\n 'xhr_polling',\n 'xhr_polling',\n 1,\n http_options\n );\n\n var ws_loop = new SequentialStrategy([ws_transport], timeouts);\n var wss_loop = new SequentialStrategy([wss_transport], timeouts);\n var streaming_loop = new SequentialStrategy(\n [xhr_streaming_transport],\n timeouts\n );\n var polling_loop = new SequentialStrategy([xhr_polling_transport], timeouts);\n\n var http_loop = new SequentialStrategy(\n [\n new IfStrategy(\n testSupportsStrategy(streaming_loop),\n new BestConnectedEverStrategy([\n streaming_loop,\n new DelayedStrategy(polling_loop, { delay: 4000 })\n ]),\n polling_loop\n )\n ],\n timeouts\n );\n\n var wsStrategy;\n if (baseOptions.useTLS) {\n wsStrategy = new BestConnectedEverStrategy([\n ws_loop,\n new DelayedStrategy(http_loop, { delay: 2000 })\n ]);\n } else {\n wsStrategy = new BestConnectedEverStrategy([\n ws_loop,\n new DelayedStrategy(wss_loop, { delay: 2000 }),\n new DelayedStrategy(http_loop, { delay: 5000 })\n ]);\n }\n\n return new WebSocketPrioritizedCachedStrategy(\n new FirstConnectedStrategy(\n new IfStrategy(testSupportsStrategy(ws_transport), wsStrategy, http_loop)\n ),\n definedTransports,\n {\n ttl: 1800000,\n timeline: baseOptions.timeline,\n useTLS: baseOptions.useTLS\n }\n );\n};\n\nexport default getDefaultStrategy;\n","import Runtime from 'runtime';\nimport RequestHooks from './request_hooks';\nimport Ajax from './ajax';\nimport { default as EventsDispatcher } from '../events/dispatcher';\n\nconst MAX_BUFFER_LENGTH = 256 * 1024;\n\nexport default class HTTPRequest extends EventsDispatcher {\n hooks: RequestHooks;\n method: string;\n url: string;\n position: number;\n xhr: Ajax;\n unloader: Function;\n\n constructor(hooks: RequestHooks, method: string, url: string) {\n super();\n this.hooks = hooks;\n this.method = method;\n this.url = url;\n }\n\n start(payload?: any) {\n this.position = 0;\n this.xhr = this.hooks.getRequest(this);\n\n this.unloader = () => {\n this.close();\n };\n Runtime.addUnloadListener(this.unloader);\n\n this.xhr.open(this.method, this.url, true);\n\n if (this.xhr.setRequestHeader) {\n this.xhr.setRequestHeader('Content-Type', 'application/json'); // ReactNative doesn't set this header by default.\n }\n this.xhr.send(payload);\n }\n\n close() {\n if (this.unloader) {\n Runtime.removeUnloadListener(this.unloader);\n this.unloader = null;\n }\n if (this.xhr) {\n this.hooks.abortRequest(this.xhr);\n this.xhr = null;\n }\n }\n\n onChunk(status: number, data: any) {\n while (true) {\n var chunk = this.advanceBuffer(data);\n if (chunk) {\n this.emit('chunk', { status: status, data: chunk });\n } else {\n break;\n }\n }\n if (this.isBufferTooLong(data)) {\n this.emit('buffer_too_long');\n }\n }\n\n private advanceBuffer(buffer: any[]): any {\n var unreadData = buffer.slice(this.position);\n var endOfLinePosition = unreadData.indexOf('\\n');\n\n if (endOfLinePosition !== -1) {\n this.position += endOfLinePosition + 1;\n return unreadData.slice(0, endOfLinePosition);\n } else {\n // chunk is not finished yet, don't move the buffer pointer\n return null;\n }\n }\n\n private isBufferTooLong(buffer: any): boolean {\n return this.position === buffer.length && buffer.length > MAX_BUFFER_LENGTH;\n }\n}\n","enum State {\n CONNECTING = 0,\n OPEN = 1,\n CLOSED = 3\n}\n\nexport default State;\n","import URLLocation from './url_location';\nimport State from './state';\nimport Socket from '../socket';\nimport SocketHooks from './socket_hooks';\nimport Util from '../util';\nimport Ajax from './ajax';\nimport HTTPRequest from './http_request';\nimport Runtime from 'runtime';\n\nvar autoIncrement = 1;\n\nclass HTTPSocket implements Socket {\n hooks: SocketHooks;\n session: string;\n location: URLLocation;\n readyState: State;\n stream: HTTPRequest;\n\n onopen: () => void;\n onerror: (error: any) => void;\n onclose: (closeEvent: any) => void;\n onmessage: (message: any) => void;\n onactivity: () => void;\n\n constructor(hooks: SocketHooks, url: string) {\n this.hooks = hooks;\n this.session = randomNumber(1000) + '/' + randomString(8);\n this.location = getLocation(url);\n this.readyState = State.CONNECTING;\n this.openStream();\n }\n\n send(payload: any) {\n return this.sendRaw(JSON.stringify([payload]));\n }\n\n ping() {\n this.hooks.sendHeartbeat(this);\n }\n\n close(code: any, reason: any) {\n this.onClose(code, reason, true);\n }\n\n /** For internal use only */\n sendRaw(payload: any): boolean {\n if (this.readyState === State.OPEN) {\n try {\n Runtime.createSocketRequest(\n 'POST',\n getUniqueURL(getSendURL(this.location, this.session))\n ).start(payload);\n return true;\n } catch (e) {\n return false;\n }\n } else {\n return false;\n }\n }\n\n /** For internal use only */\n reconnect() {\n this.closeStream();\n this.openStream();\n }\n\n /** For internal use only */\n onClose(code, reason, wasClean) {\n this.closeStream();\n this.readyState = State.CLOSED;\n if (this.onclose) {\n this.onclose({\n code: code,\n reason: reason,\n wasClean: wasClean\n });\n }\n }\n\n private onChunk(chunk) {\n if (chunk.status !== 200) {\n return;\n }\n if (this.readyState === State.OPEN) {\n this.onActivity();\n }\n\n var payload;\n var type = chunk.data.slice(0, 1);\n switch (type) {\n case 'o':\n payload = JSON.parse(chunk.data.slice(1) || '{}');\n this.onOpen(payload);\n break;\n case 'a':\n payload = JSON.parse(chunk.data.slice(1) || '[]');\n for (var i = 0; i < payload.length; i++) {\n this.onEvent(payload[i]);\n }\n break;\n case 'm':\n payload = JSON.parse(chunk.data.slice(1) || 'null');\n this.onEvent(payload);\n break;\n case 'h':\n this.hooks.onHeartbeat(this);\n break;\n case 'c':\n payload = JSON.parse(chunk.data.slice(1) || '[]');\n this.onClose(payload[0], payload[1], true);\n break;\n }\n }\n\n private onOpen(options) {\n if (this.readyState === State.CONNECTING) {\n if (options && options.hostname) {\n this.location.base = replaceHost(this.location.base, options.hostname);\n }\n this.readyState = State.OPEN;\n\n if (this.onopen) {\n this.onopen();\n }\n } else {\n this.onClose(1006, 'Server lost session', true);\n }\n }\n\n private onEvent(event) {\n if (this.readyState === State.OPEN && this.onmessage) {\n this.onmessage({ data: event });\n }\n }\n\n private onActivity() {\n if (this.onactivity) {\n this.onactivity();\n }\n }\n\n private onError(error) {\n if (this.onerror) {\n this.onerror(error);\n }\n }\n\n private openStream() {\n this.stream = Runtime.createSocketRequest(\n 'POST',\n getUniqueURL(this.hooks.getReceiveURL(this.location, this.session))\n );\n\n this.stream.bind('chunk', chunk => {\n this.onChunk(chunk);\n });\n this.stream.bind('finished', status => {\n this.hooks.onFinished(this, status);\n });\n this.stream.bind('buffer_too_long', () => {\n this.reconnect();\n });\n\n try {\n this.stream.start();\n } catch (error) {\n Util.defer(() => {\n this.onError(error);\n this.onClose(1006, 'Could not start streaming', false);\n });\n }\n }\n\n private closeStream() {\n if (this.stream) {\n this.stream.unbind_all();\n this.stream.close();\n this.stream = null;\n }\n }\n}\n\nfunction getLocation(url): URLLocation {\n var parts = /([^\\?]*)\\/*(\\??.*)/.exec(url);\n return {\n base: parts[1],\n queryString: parts[2]\n };\n}\n\nfunction getSendURL(url: URLLocation, session: string): string {\n return url.base + '/' + session + '/xhr_send';\n}\n\nfunction getUniqueURL(url: string): string {\n var separator = url.indexOf('?') === -1 ? '?' : '&';\n return url + separator + 't=' + +new Date() + '&n=' + autoIncrement++;\n}\n\nfunction replaceHost(url: string, hostname: string): string {\n var urlParts = /(https?:\\/\\/)([^\\/:]+)((\\/|:)?.*)/.exec(url);\n return urlParts[1] + hostname + urlParts[3];\n}\n\nfunction randomNumber(max: number): number {\n return Runtime.randomInt(max);\n}\n\nfunction randomString(length: number): string {\n var result = [];\n\n for (var i = 0; i < length; i++) {\n result.push(randomNumber(32).toString(32));\n }\n\n return result.join('');\n}\n\nexport default HTTPSocket;\n","import SocketHooks from './socket_hooks';\nimport HTTPSocket from './http_socket';\n\nvar hooks: SocketHooks = {\n getReceiveURL: function(url, session) {\n return url.base + '/' + session + '/xhr_streaming' + url.queryString;\n },\n onHeartbeat: function(socket) {\n socket.sendRaw('[]');\n },\n sendHeartbeat: function(socket) {\n socket.sendRaw('[]');\n },\n onFinished: function(socket, status) {\n socket.onClose(1006, 'Connection interrupted (' + status + ')', false);\n }\n};\n\nexport default hooks;\n","import SocketHooks from './socket_hooks';\nimport URLLocation from './url_location';\nimport HTTPSocket from './http_socket';\n\nvar hooks: SocketHooks = {\n getReceiveURL: function(url: URLLocation, session: string): string {\n return url.base + '/' + session + '/xhr' + url.queryString;\n },\n onHeartbeat: function() {\n // next HTTP request will reset server's activity timer\n },\n sendHeartbeat: function(socket) {\n socket.sendRaw('[]');\n },\n onFinished: function(socket, status) {\n if (status === 200) {\n socket.reconnect();\n } else {\n socket.onClose(1006, 'Connection interrupted (' + status + ')', false);\n }\n }\n};\n\nexport default hooks;\n","import HTTPRequest from 'core/http/http_request';\nimport RequestHooks from 'core/http/request_hooks';\nimport Ajax from 'core/http/ajax';\nimport Runtime from 'runtime';\n\nvar hooks: RequestHooks = {\n getRequest: function(socket: HTTPRequest): Ajax {\n var Constructor = Runtime.getXHRAPI();\n var xhr = new Constructor();\n xhr.onreadystatechange = xhr.onprogress = function() {\n switch (xhr.readyState) {\n case 3:\n if (xhr.responseText && xhr.responseText.length > 0) {\n socket.onChunk(xhr.status, xhr.responseText);\n }\n break;\n case 4:\n // this happens only on errors, never after calling close\n if (xhr.responseText && xhr.responseText.length > 0) {\n socket.onChunk(xhr.status, xhr.responseText);\n }\n socket.emit('finished', xhr.status);\n socket.close();\n break;\n }\n };\n return xhr;\n },\n abortRequest: function(xhr: Ajax) {\n xhr.onreadystatechange = null;\n xhr.abort();\n }\n};\n\nexport default hooks;\n","import * as Collections from 'core/utils/collections';\nimport Transports from 'isomorphic/transports/transports';\nimport TimelineSender from 'core/timeline/timeline_sender';\nimport Ajax from 'core/http/ajax';\nimport getDefaultStrategy from './default_strategy';\nimport TransportsTable from 'core/transports/transports_table';\nimport transportConnectionInitializer from './transports/transport_connection_initializer';\nimport HTTPFactory from './http/http';\n\nvar Isomorphic: any = {\n getDefaultStrategy,\n Transports: Transports,\n transportConnectionInitializer,\n HTTPFactory,\n\n setup(PusherClass): void {\n PusherClass.ready();\n },\n\n getLocalStorage(): any {\n return undefined;\n },\n\n getClientFeatures(): any[] {\n return Collections.keys(\n Collections.filterObject({ ws: Transports.ws }, function(t) {\n return t.isSupported({});\n })\n );\n },\n\n getProtocol(): string {\n return 'http:';\n },\n\n isXHRSupported(): boolean {\n return true;\n },\n\n createSocketRequest(method: string, url: string) {\n if (this.isXHRSupported()) {\n return this.HTTPFactory.createXHR(method, url);\n } else {\n throw 'Cross-origin HTTP requests are not supported';\n }\n },\n\n createXHR(): Ajax {\n var Constructor = this.getXHRAPI();\n return new Constructor();\n },\n\n createWebSocket(url: string): any {\n var Constructor = this.getWebSocketAPI();\n return new Constructor(url);\n },\n\n addUnloadListener(listener: any) {},\n removeUnloadListener(listener: any) {}\n};\n\nexport default Isomorphic;\n","/** Initializes the transport.\n *\n * Fetches resources if needed and then transitions to initialized.\n */\nexport default function() {\n var self = this;\n\n self.timeline.info(\n self.buildTimelineMessage({\n transport: self.name + (self.options.useTLS ? 's' : '')\n })\n );\n\n if (self.hooks.isInitialized()) {\n self.changeState('initialized');\n } else {\n self.onClose();\n }\n}\n","import HTTPRequest from 'core/http/http_request';\nimport HTTPSocket from 'core/http/http_socket';\nimport SocketHooks from 'core/http/socket_hooks';\nimport RequestHooks from 'core/http/request_hooks';\nimport streamingHooks from 'core/http/http_streaming_socket';\nimport pollingHooks from 'core/http/http_polling_socket';\nimport xhrHooks from './http_xhr_request';\nimport HTTPFactory from 'core/http/http_factory';\n\nvar HTTP: HTTPFactory = {\n createStreamingSocket(url: string): HTTPSocket {\n return this.createSocket(streamingHooks, url);\n },\n\n createPollingSocket(url: string): HTTPSocket {\n return this.createSocket(pollingHooks, url);\n },\n\n createSocket(hooks: SocketHooks, url: string): HTTPSocket {\n return new HTTPSocket(hooks, url);\n },\n\n createXHR(method: string, url: string): HTTPRequest {\n return this.createRequest(xhrHooks, method, url);\n },\n\n createRequest(hooks: RequestHooks, method: string, url: string): HTTPRequest {\n return new HTTPRequest(hooks, method, url);\n }\n};\n\nexport default HTTP;\n","import { default as EventsDispatcher } from 'core/events/dispatcher';\nimport Reachability from 'core/reachability';\n\nexport class NetInfo extends EventsDispatcher implements Reachability {\n isOnline(): boolean {\n return true;\n }\n}\n\nexport var Network = new NetInfo();\n","import AbstractRuntime from 'runtimes/interface';\nimport { AuthTransport } from 'core/auth/auth_transports';\nimport {\n AuthRequestType,\n AuthTransportCallback,\n InternalAuthOptions\n} from 'core/auth/options';\nimport { HTTPAuthError } from 'core/errors';\n\nvar fetchAuth: AuthTransport = function(\n context: AbstractRuntime,\n query: string,\n authOptions: InternalAuthOptions,\n authRequestType: AuthRequestType,\n callback: AuthTransportCallback\n) {\n var headers = new Headers();\n headers.set('Content-Type', 'application/x-www-form-urlencoded');\n\n for (var headerName in authOptions.headers) {\n headers.set(headerName, authOptions.headers[headerName]);\n }\n\n if (authOptions.headersProvider != null) {\n const dynamicHeaders = authOptions.headersProvider();\n for (var headerName in dynamicHeaders) {\n headers.set(headerName, dynamicHeaders[headerName]);\n }\n }\n\n var body = query;\n var request = new Request(authOptions.endpoint, {\n headers,\n body,\n credentials: 'same-origin',\n method: 'POST'\n });\n\n return fetch(request)\n .then(response => {\n let { status } = response;\n if (status === 200) {\n // manually parse the json so we can provide a more helpful error in\n // failure case\n return response.text();\n }\n throw new HTTPAuthError(\n status,\n `Could not get ${authRequestType.toString()} info from your auth endpoint, status: ${status}`\n );\n })\n .then(data => {\n let parsedData;\n try {\n parsedData = JSON.parse(data);\n } catch (e) {\n throw new HTTPAuthError(\n 200,\n `JSON returned from ${authRequestType.toString()} endpoint was invalid, yet status code was 200. Data was: ${data}`\n );\n }\n callback(null, parsedData);\n })\n .catch(err => {\n callback(err, null);\n });\n};\n\nexport default fetchAuth;\n","import Logger from 'core/logger';\nimport TimelineSender from 'core/timeline/timeline_sender';\nimport * as Collections from 'core/utils/collections';\nimport Util from 'core/util';\nimport Runtime from 'runtime';\nimport TimelineTransport from 'core/timeline/timeline_transport';\n\nvar getAgent = function(sender: TimelineSender, useTLS: boolean) {\n return function(data: any, callback: Function) {\n var scheme = 'http' + (useTLS ? 's' : '') + '://';\n var url =\n scheme + (sender.host || sender.options.host) + sender.options.path;\n var query = Collections.buildQueryString(data);\n url += '/' + 2 + '?' + query;\n\n fetch(url)\n .then(response => {\n if (response.status !== 200) {\n throw `received ${response.status} from stats.pusher.com`;\n }\n return response.json();\n })\n .then(({ host }) => {\n if (host) {\n sender.host = host;\n }\n })\n .catch(err => {\n Logger.debug('TimelineSender Error: ', err);\n });\n };\n};\n\nvar fetchTimeline = {\n name: 'xhr',\n getAgent\n};\n\nexport default fetchTimeline;\n","import Isomorphic from 'isomorphic/runtime';\nimport Runtime from '../interface';\nimport { Network } from './net_info';\nimport fetchAuth from './auth/fetch_auth';\nimport { AuthTransports } from 'core/auth/auth_transports';\nimport fetchTimeline from './timeline/fetch_timeline';\n\n// Very verbose but until unavoidable until\n// TypeScript 2.1, when spread attributes will be\n// supported\nconst {\n getDefaultStrategy,\n Transports,\n setup,\n getProtocol,\n isXHRSupported,\n getLocalStorage,\n createXHR,\n createWebSocket,\n addUnloadListener,\n removeUnloadListener,\n transportConnectionInitializer,\n createSocketRequest,\n HTTPFactory\n} = Isomorphic;\n\nconst Worker: Runtime = {\n getDefaultStrategy,\n Transports,\n setup,\n getProtocol,\n isXHRSupported,\n getLocalStorage,\n createXHR,\n createWebSocket,\n addUnloadListener,\n removeUnloadListener,\n transportConnectionInitializer,\n createSocketRequest,\n HTTPFactory,\n\n TimelineTransport: fetchTimeline,\n\n getAuthorizers(): AuthTransports {\n return { ajax: fetchAuth };\n },\n\n getWebSocketAPI() {\n return WebSocket;\n },\n\n getXHRAPI() {\n return XMLHttpRequest;\n },\n\n getNetwork() {\n return Network;\n },\n\n randomInt(max: number): number {\n /**\n * Return values in the range of [0, 1[\n */\n const random = function() {\n const crypto = globalThis.crypto || globalThis['msCrypto'];\n const random = crypto.getRandomValues(new Uint32Array(1))[0];\n\n return random / 2 ** 32;\n };\n\n return Math.floor(random() * max);\n }\n};\n\nexport default Worker;\n","enum TimelineLevel {\n ERROR = 3,\n INFO = 6,\n DEBUG = 7\n}\n\nexport default TimelineLevel;\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport { default as Level } from './level';\n\nexport interface TimelineOptions {\n level?: Level;\n limit?: number;\n version?: string;\n cluster?: string;\n features?: string[];\n params?: any;\n}\n\nexport default class Timeline {\n key: string;\n session: number;\n events: any[];\n options: TimelineOptions;\n sent: number;\n uniqueID: number;\n\n constructor(key: string, session: number, options: TimelineOptions) {\n this.key = key;\n this.session = session;\n this.events = [];\n this.options = options || {};\n this.sent = 0;\n this.uniqueID = 0;\n }\n\n log(level, event) {\n if (level <= this.options.level) {\n this.events.push(\n Collections.extend({}, event, { timestamp: Util.now() })\n );\n if (this.options.limit && this.events.length > this.options.limit) {\n this.events.shift();\n }\n }\n }\n\n error(event) {\n this.log(Level.ERROR, event);\n }\n\n info(event) {\n this.log(Level.INFO, event);\n }\n\n debug(event) {\n this.log(Level.DEBUG, event);\n }\n\n isEmpty() {\n return this.events.length === 0;\n }\n\n send(sendfn, callback) {\n var data = Collections.extend(\n {\n session: this.session,\n bundle: this.sent + 1,\n key: this.key,\n lib: 'js',\n version: this.options.version,\n cluster: this.options.cluster,\n features: this.options.features,\n timeline: this.events\n },\n this.options.params\n );\n\n this.events = [];\n sendfn(data, (error, result) => {\n if (!error) {\n this.sent++;\n }\n if (callback) {\n callback(error, result);\n }\n });\n\n return true;\n }\n\n generateUniqueID(): number {\n this.uniqueID++;\n return this.uniqueID;\n }\n}\n","import Factory from '../utils/factory';\nimport Util from '../util';\nimport * as Errors from '../errors';\nimport * as Collections from '../utils/collections';\nimport Strategy from './strategy';\nimport Transport from '../transports/transport';\nimport StrategyOptions from './strategy_options';\nimport Handshake from '../connection/handshake';\n\n/** Provides a strategy interface for transports.\n *\n * @param {String} name\n * @param {Number} priority\n * @param {Class} transport\n * @param {Object} options\n */\nexport default class TransportStrategy implements Strategy {\n name: string;\n priority: number;\n transport: Transport;\n options: StrategyOptions;\n\n constructor(\n name: string,\n priority: number,\n transport: Transport,\n options: StrategyOptions\n ) {\n this.name = name;\n this.priority = priority;\n this.transport = transport;\n this.options = options || {};\n }\n\n /** Returns whether the transport is supported in the browser.\n *\n * @returns {Boolean}\n */\n isSupported(): boolean {\n return this.transport.isSupported({\n useTLS: this.options.useTLS\n });\n }\n\n /** Launches a connection attempt and returns a strategy runner.\n *\n * @param {Function} callback\n * @return {Object} strategy runner\n */\n connect(minPriority: number, callback: Function) {\n if (!this.isSupported()) {\n return failAttempt(new Errors.UnsupportedStrategy(), callback);\n } else if (this.priority < minPriority) {\n return failAttempt(new Errors.TransportPriorityTooLow(), callback);\n }\n\n var connected = false;\n var transport = this.transport.createConnection(\n this.name,\n this.priority,\n this.options.key,\n this.options\n );\n var handshake = null;\n\n var onInitialized = function() {\n transport.unbind('initialized', onInitialized);\n transport.connect();\n };\n var onOpen = function() {\n handshake = Factory.createHandshake(transport, function(result) {\n connected = true;\n unbindListeners();\n callback(null, result);\n });\n };\n var onError = function(error) {\n unbindListeners();\n callback(error);\n };\n var onClosed = function() {\n unbindListeners();\n var serializedTransport;\n\n // The reason for this try/catch block is that on React Native\n // the WebSocket object is circular. Therefore transport.socket will\n // throw errors upon stringification. Collections.safeJSONStringify\n // discards circular references when serializing.\n serializedTransport = Collections.safeJSONStringify(transport);\n callback(new Errors.TransportClosed(serializedTransport));\n };\n\n var unbindListeners = function() {\n transport.unbind('initialized', onInitialized);\n transport.unbind('open', onOpen);\n transport.unbind('error', onError);\n transport.unbind('closed', onClosed);\n };\n\n transport.bind('initialized', onInitialized);\n transport.bind('open', onOpen);\n transport.bind('error', onError);\n transport.bind('closed', onClosed);\n\n // connect will be called automatically after initialization\n transport.initialize();\n\n return {\n abort: () => {\n if (connected) {\n return;\n }\n unbindListeners();\n if (handshake) {\n handshake.close();\n } else {\n transport.close();\n }\n },\n forceMinPriority: p => {\n if (connected) {\n return;\n }\n if (this.priority < p) {\n if (handshake) {\n handshake.close();\n } else {\n transport.close();\n }\n }\n }\n };\n }\n}\n\nfunction failAttempt(error: Error, callback: Function) {\n Util.defer(function() {\n callback(error);\n });\n return {\n abort: function() {},\n forceMinPriority: function() {}\n };\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport TransportManager from '../transports/transport_manager';\nimport * as Errors from '../errors';\nimport Strategy from './strategy';\nimport TransportStrategy from './transport_strategy';\nimport StrategyOptions from '../strategies/strategy_options';\nimport { Config } from '../config';\nimport Runtime from 'runtime';\n\nconst { Transports } = Runtime;\n\nexport var defineTransport = function(\n config: Config,\n name: string,\n type: string,\n priority: number,\n options: StrategyOptions,\n manager?: TransportManager\n): Strategy {\n var transportClass = Transports[type];\n if (!transportClass) {\n throw new Errors.UnsupportedTransport(type);\n }\n\n var enabled =\n (!config.enabledTransports ||\n Collections.arrayIndexOf(config.enabledTransports, name) !== -1) &&\n (!config.disabledTransports ||\n Collections.arrayIndexOf(config.disabledTransports, name) === -1);\n\n var transport;\n if (enabled) {\n options = Object.assign(\n { ignoreNullOrigin: config.ignoreNullOrigin },\n options\n );\n\n transport = new TransportStrategy(\n name,\n priority,\n manager ? manager.getAssistant(transportClass) : transportClass,\n options\n );\n } else {\n transport = UnsupportedStrategy;\n }\n\n return transport;\n};\n\nvar UnsupportedStrategy: Strategy = {\n isSupported: function() {\n return false;\n },\n connect: function(_, callback) {\n var deferred = Util.defer(function() {\n callback(new Errors.UnsupportedStrategy());\n });\n return {\n abort: function() {\n deferred.ensureAborted();\n },\n forceMinPriority: function() {}\n };\n }\n};\n","export enum AuthRequestType {\n UserAuthentication = 'user-authentication',\n ChannelAuthorization = 'channel-authorization'\n}\n\nexport interface ChannelAuthorizationData {\n auth: string;\n channel_data?: string;\n shared_secret?: string;\n}\n\nexport type ChannelAuthorizationCallback = (\n error: Error | null,\n authData: ChannelAuthorizationData | null\n) => void;\n\nexport interface ChannelAuthorizationRequestParams {\n socketId: string;\n channelName: string;\n}\n\nexport interface ChannelAuthorizationHandler {\n (\n params: ChannelAuthorizationRequestParams,\n callback: ChannelAuthorizationCallback\n ): void;\n}\n\nexport interface UserAuthenticationData {\n auth: string;\n user_data: string;\n}\n\nexport type UserAuthenticationCallback = (\n error: Error | null,\n authData: UserAuthenticationData | null\n) => void;\n\nexport interface UserAuthenticationRequestParams {\n socketId: string;\n}\n\nexport interface UserAuthenticationHandler {\n (\n params: UserAuthenticationRequestParams,\n callback: UserAuthenticationCallback\n ): void;\n}\n\nexport type AuthTransportCallback =\n | ChannelAuthorizationCallback\n | UserAuthenticationCallback;\n\nexport interface AuthOptionsT {\n transport: 'ajax' | 'jsonp';\n endpoint: string;\n params?: any;\n headers?: any;\n paramsProvider?: () => any;\n headersProvider?: () => any;\n customHandler?: AuthHandler;\n}\n\nexport declare type UserAuthenticationOptions = AuthOptionsT<\n UserAuthenticationHandler\n>;\nexport declare type ChannelAuthorizationOptions = AuthOptionsT<\n ChannelAuthorizationHandler\n>;\n\nexport interface InternalAuthOptions {\n transport: 'ajax' | 'jsonp';\n endpoint: string;\n params?: any;\n headers?: any;\n paramsProvider?: () => any;\n headersProvider?: () => any;\n}\n","import {\n UserAuthenticationCallback,\n InternalAuthOptions,\n UserAuthenticationHandler,\n UserAuthenticationRequestParams,\n AuthRequestType\n} from './options';\n\nimport Runtime from 'runtime';\n\nconst composeChannelQuery = (\n params: UserAuthenticationRequestParams,\n authOptions: InternalAuthOptions\n) => {\n var query = 'socket_id=' + encodeURIComponent(params.socketId);\n\n for (var key in authOptions.params) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(authOptions.params[key]);\n }\n\n if (authOptions.paramsProvider != null) {\n let dynamicParams = authOptions.paramsProvider();\n for (var key in dynamicParams) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(dynamicParams[key]);\n }\n }\n\n return query;\n};\n\nconst UserAuthenticator = (\n authOptions: InternalAuthOptions\n): UserAuthenticationHandler => {\n if (typeof Runtime.getAuthorizers()[authOptions.transport] === 'undefined') {\n throw `'${authOptions.transport}' is not a recognized auth transport`;\n }\n\n return (\n params: UserAuthenticationRequestParams,\n callback: UserAuthenticationCallback\n ) => {\n const query = composeChannelQuery(params, authOptions);\n\n Runtime.getAuthorizers()[authOptions.transport](\n Runtime,\n query,\n authOptions,\n AuthRequestType.UserAuthentication,\n callback\n );\n };\n};\n\nexport default UserAuthenticator;\n","import {\n AuthRequestType,\n InternalAuthOptions,\n ChannelAuthorizationHandler,\n ChannelAuthorizationRequestParams,\n ChannelAuthorizationCallback\n} from './options';\n\nimport Runtime from 'runtime';\n\nconst composeChannelQuery = (\n params: ChannelAuthorizationRequestParams,\n authOptions: InternalAuthOptions\n) => {\n var query = 'socket_id=' + encodeURIComponent(params.socketId);\n\n query += '&channel_name=' + encodeURIComponent(params.channelName);\n\n for (var key in authOptions.params) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(authOptions.params[key]);\n }\n\n if (authOptions.paramsProvider != null) {\n let dynamicParams = authOptions.paramsProvider();\n for (var key in dynamicParams) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(dynamicParams[key]);\n }\n }\n\n return query;\n};\n\nconst ChannelAuthorizer = (\n authOptions: InternalAuthOptions\n): ChannelAuthorizationHandler => {\n if (typeof Runtime.getAuthorizers()[authOptions.transport] === 'undefined') {\n throw `'${authOptions.transport}' is not a recognized auth transport`;\n }\n\n return (\n params: ChannelAuthorizationRequestParams,\n callback: ChannelAuthorizationCallback\n ) => {\n const query = composeChannelQuery(params, authOptions);\n\n Runtime.getAuthorizers()[authOptions.transport](\n Runtime,\n query,\n authOptions,\n AuthRequestType.ChannelAuthorization,\n callback\n );\n };\n};\n\nexport default ChannelAuthorizer;\n","import { Options } from './options';\nimport Defaults from './defaults';\nimport {\n ChannelAuthorizationHandler,\n UserAuthenticationHandler,\n ChannelAuthorizationOptions\n} from './auth/options';\nimport UserAuthenticator from './auth/user_authenticator';\nimport ChannelAuthorizer from './auth/channel_authorizer';\nimport { ChannelAuthorizerProxy } from './auth/deprecated_channel_authorizer';\nimport Runtime from 'runtime';\nimport * as nacl from 'tweetnacl';\n\nexport type AuthTransport = 'ajax' | 'jsonp';\nexport type Transport =\n | 'ws'\n | 'wss'\n | 'xhr_streaming'\n | 'xhr_polling'\n | 'sockjs';\n\nexport interface Config {\n // these are all 'required' config parameters, it's not necessary for the user\n // to set them, but they have configured defaults.\n activityTimeout: number;\n enableStats: boolean;\n httpHost: string;\n httpPath: string;\n httpPort: number;\n httpsPort: number;\n pongTimeout: number;\n statsHost: string;\n unavailableTimeout: number;\n useTLS: boolean;\n wsHost: string;\n wsPath: string;\n wsPort: number;\n wssPort: number;\n userAuthenticator: UserAuthenticationHandler;\n channelAuthorizer: ChannelAuthorizationHandler;\n\n // these are all optional parameters or overrrides. The customer can set these\n // but it's not strictly necessary\n forceTLS?: boolean;\n cluster?: string;\n disabledTransports?: Transport[];\n enabledTransports?: Transport[];\n ignoreNullOrigin?: boolean;\n nacl?: nacl;\n timelineParams?: any;\n}\n\n// getConfig mainly sets the defaults for the options that are not provided\nexport function getConfig(opts: Options, pusher): Config {\n let config: Config = {\n activityTimeout: opts.activityTimeout || Defaults.activityTimeout,\n cluster: opts.cluster,\n httpPath: opts.httpPath || Defaults.httpPath,\n httpPort: opts.httpPort || Defaults.httpPort,\n httpsPort: opts.httpsPort || Defaults.httpsPort,\n pongTimeout: opts.pongTimeout || Defaults.pongTimeout,\n statsHost: opts.statsHost || Defaults.stats_host,\n unavailableTimeout: opts.unavailableTimeout || Defaults.unavailableTimeout,\n wsPath: opts.wsPath || Defaults.wsPath,\n wsPort: opts.wsPort || Defaults.wsPort,\n wssPort: opts.wssPort || Defaults.wssPort,\n\n enableStats: getEnableStatsConfig(opts),\n httpHost: getHttpHost(opts),\n useTLS: shouldUseTLS(opts),\n wsHost: getWebsocketHost(opts),\n\n userAuthenticator: buildUserAuthenticator(opts),\n channelAuthorizer: buildChannelAuthorizer(opts, pusher)\n };\n\n if ('disabledTransports' in opts)\n config.disabledTransports = opts.disabledTransports;\n if ('enabledTransports' in opts)\n config.enabledTransports = opts.enabledTransports;\n if ('ignoreNullOrigin' in opts)\n config.ignoreNullOrigin = opts.ignoreNullOrigin;\n if ('timelineParams' in opts) config.timelineParams = opts.timelineParams;\n if ('nacl' in opts) {\n config.nacl = opts.nacl;\n }\n\n return config;\n}\n\nfunction getHttpHost(opts: Options): string {\n if (opts.httpHost) {\n return opts.httpHost;\n }\n if (opts.cluster) {\n return `sockjs-${opts.cluster}.pusher.com`;\n }\n return Defaults.httpHost;\n}\n\nfunction getWebsocketHost(opts: Options): string {\n if (opts.wsHost) {\n return opts.wsHost;\n }\n return getWebsocketHostFromCluster(opts.cluster);\n}\n\nfunction getWebsocketHostFromCluster(cluster: string): string {\n return `ws-${cluster}.pusher.com`;\n}\n\nfunction shouldUseTLS(opts: Options): boolean {\n if (Runtime.getProtocol() === 'https:') {\n return true;\n } else if (opts.forceTLS === false) {\n return false;\n }\n return true;\n}\n\n// if enableStats is set take the value\n// if disableStats is set take the inverse\n// otherwise default to false\nfunction getEnableStatsConfig(opts: Options): boolean {\n if ('enableStats' in opts) {\n return opts.enableStats;\n }\n if ('disableStats' in opts) {\n return !opts.disableStats;\n }\n return false;\n}\n\nfunction buildUserAuthenticator(opts: Options): UserAuthenticationHandler {\n const userAuthentication = {\n ...Defaults.userAuthentication,\n ...opts.userAuthentication\n };\n if (\n 'customHandler' in userAuthentication &&\n userAuthentication['customHandler'] != null\n ) {\n return userAuthentication['customHandler'];\n }\n\n return UserAuthenticator(userAuthentication);\n}\n\nfunction buildChannelAuth(opts: Options, pusher): ChannelAuthorizationOptions {\n let channelAuthorization: ChannelAuthorizationOptions;\n if ('channelAuthorization' in opts) {\n channelAuthorization = {\n ...Defaults.channelAuthorization,\n ...opts.channelAuthorization\n };\n } else {\n channelAuthorization = {\n transport: opts.authTransport || Defaults.authTransport,\n endpoint: opts.authEndpoint || Defaults.authEndpoint\n };\n if ('auth' in opts) {\n if ('params' in opts.auth) channelAuthorization.params = opts.auth.params;\n if ('headers' in opts.auth)\n channelAuthorization.headers = opts.auth.headers;\n }\n if ('authorizer' in opts)\n channelAuthorization.customHandler = ChannelAuthorizerProxy(\n pusher,\n channelAuthorization,\n opts.authorizer\n );\n }\n return channelAuthorization;\n}\n\nfunction buildChannelAuthorizer(\n opts: Options,\n pusher\n): ChannelAuthorizationHandler {\n const channelAuthorization = buildChannelAuth(opts, pusher);\n if (\n 'customHandler' in channelAuthorization &&\n channelAuthorization['customHandler'] != null\n ) {\n return channelAuthorization['customHandler'];\n }\n\n return ChannelAuthorizer(channelAuthorization);\n}\n","import Channel from '../channels/channel';\nimport {\n ChannelAuthorizationCallback,\n ChannelAuthorizationHandler,\n ChannelAuthorizationRequestParams,\n InternalAuthOptions\n} from './options';\n\nexport interface DeprecatedChannelAuthorizer {\n authorize(socketId: string, callback: ChannelAuthorizationCallback): void;\n}\n\nexport interface ChannelAuthorizerGenerator {\n (\n channel: Channel,\n options: DeprecatedAuthorizerOptions\n ): DeprecatedChannelAuthorizer;\n}\n\nexport interface DeprecatedAuthOptions {\n params?: any;\n headers?: any;\n}\n\nexport interface DeprecatedAuthorizerOptions {\n authTransport: 'ajax' | 'jsonp';\n authEndpoint: string;\n auth?: DeprecatedAuthOptions;\n}\n\nexport const ChannelAuthorizerProxy = (\n pusher,\n authOptions: InternalAuthOptions,\n channelAuthorizerGenerator: ChannelAuthorizerGenerator\n): ChannelAuthorizationHandler => {\n const deprecatedAuthorizerOptions: DeprecatedAuthorizerOptions = {\n authTransport: authOptions.transport,\n authEndpoint: authOptions.endpoint,\n auth: {\n params: authOptions.params,\n headers: authOptions.headers\n }\n };\n return (\n params: ChannelAuthorizationRequestParams,\n callback: ChannelAuthorizationCallback\n ) => {\n const channel = pusher.channel(params.channelName);\n // This line creates a new channel authorizer every time.\n // In the past, this was only done once per channel and reused.\n // We can do that again if we want to keep this behavior intact.\n const channelAuthorizer: DeprecatedChannelAuthorizer = channelAuthorizerGenerator(\n channel,\n deprecatedAuthorizerOptions\n );\n channelAuthorizer.authorize(params.socketId, callback);\n };\n};\n","import Logger from './logger';\nimport Pusher from './pusher';\nimport EventsDispatcher from './events/dispatcher';\n\nexport default class WatchlistFacade extends EventsDispatcher {\n private pusher: Pusher;\n\n public constructor(pusher: Pusher) {\n super(function(eventName, data) {\n Logger.debug(`No callbacks on watchlist events for ${eventName}`);\n });\n\n this.pusher = pusher;\n this.bindWatchlistInternalEvent();\n }\n\n handleEvent(pusherEvent) {\n pusherEvent.data.events.forEach(watchlistEvent => {\n this.emit(watchlistEvent.name, watchlistEvent);\n });\n }\n\n private bindWatchlistInternalEvent() {\n this.pusher.connection.bind('message', pusherEvent => {\n var eventName = pusherEvent.event;\n if (eventName === 'pusher_internal:watchlist_events') {\n this.handleEvent(pusherEvent);\n }\n });\n }\n}\n","function flatPromise() {\n let resolve, reject;\n const promise = new Promise((res, rej) => {\n resolve = res;\n reject = rej;\n });\n return { promise, resolve, reject };\n}\n\nexport default flatPromise;\n","import Pusher from './pusher';\nimport Logger from './logger';\nimport {\n UserAuthenticationData,\n UserAuthenticationCallback\n} from './auth/options';\nimport Channel from './channels/channel';\nimport WatchlistFacade from './watchlist';\nimport EventsDispatcher from './events/dispatcher';\nimport flatPromise from './utils/flat_promise';\n\nexport default class UserFacade extends EventsDispatcher {\n pusher: Pusher;\n signin_requested: boolean = false;\n user_data: any = null;\n serverToUserChannel: Channel = null;\n signinDonePromise: Promise = null;\n watchlist: WatchlistFacade;\n private _signinDoneResolve: Function = null;\n\n public constructor(pusher: Pusher) {\n super(function(eventName, data) {\n Logger.debug('No callbacks on user for ' + eventName);\n });\n this.pusher = pusher;\n this.pusher.connection.bind('state_change', ({ previous, current }) => {\n if (previous !== 'connected' && current === 'connected') {\n this._signin();\n }\n if (previous === 'connected' && current !== 'connected') {\n this._cleanup();\n this._newSigninPromiseIfNeeded();\n }\n });\n\n this.watchlist = new WatchlistFacade(pusher);\n\n this.pusher.connection.bind('message', event => {\n var eventName = event.event;\n if (eventName === 'pusher:signin_success') {\n this._onSigninSuccess(event.data);\n }\n if (\n this.serverToUserChannel &&\n this.serverToUserChannel.name === event.channel\n ) {\n this.serverToUserChannel.handleEvent(event);\n }\n });\n }\n\n public signin() {\n if (this.signin_requested) {\n return;\n }\n\n this.signin_requested = true;\n this._signin();\n }\n\n private _signin() {\n if (!this.signin_requested) {\n return;\n }\n\n this._newSigninPromiseIfNeeded();\n\n if (this.pusher.connection.state !== 'connected') {\n // Signin will be attempted when the connection is connected\n return;\n }\n\n this.pusher.config.userAuthenticator(\n {\n socketId: this.pusher.connection.socket_id\n },\n this._onAuthorize\n );\n }\n\n private _onAuthorize: UserAuthenticationCallback = (\n err,\n authData: UserAuthenticationData\n ) => {\n if (err) {\n Logger.warn(`Error during signin: ${err}`);\n this._cleanup();\n return;\n }\n\n this.pusher.send_event('pusher:signin', {\n auth: authData.auth,\n user_data: authData.user_data\n });\n\n // Later when we get pusher:singin_success event, the user will be marked as signed in\n };\n\n private _onSigninSuccess(data: any) {\n try {\n this.user_data = JSON.parse(data.user_data);\n } catch (e) {\n Logger.error(`Failed parsing user data after signin: ${data.user_data}`);\n this._cleanup();\n return;\n }\n\n if (typeof this.user_data.id !== 'string' || this.user_data.id === '') {\n Logger.error(\n `user_data doesn't contain an id. user_data: ${this.user_data}`\n );\n this._cleanup();\n return;\n }\n\n // Signin succeeded\n this._signinDoneResolve();\n this._subscribeChannels();\n }\n\n private _subscribeChannels() {\n const ensure_subscribed = channel => {\n if (channel.subscriptionPending && channel.subscriptionCancelled) {\n channel.reinstateSubscription();\n } else if (\n !channel.subscriptionPending &&\n this.pusher.connection.state === 'connected'\n ) {\n channel.subscribe();\n }\n };\n\n this.serverToUserChannel = new Channel(\n `#server-to-user-${this.user_data.id}`,\n this.pusher\n );\n this.serverToUserChannel.bind_global((eventName, data) => {\n if (\n eventName.indexOf('pusher_internal:') === 0 ||\n eventName.indexOf('pusher:') === 0\n ) {\n // ignore internal events\n return;\n }\n this.emit(eventName, data);\n });\n ensure_subscribed(this.serverToUserChannel);\n }\n\n private _cleanup() {\n this.user_data = null;\n if (this.serverToUserChannel) {\n this.serverToUserChannel.unbind_all();\n this.serverToUserChannel.disconnect();\n this.serverToUserChannel = null;\n }\n\n if (this.signin_requested) {\n // If signin is in progress and cleanup is called,\n // Mark the current signin process as done.\n this._signinDoneResolve();\n }\n }\n\n private _newSigninPromiseIfNeeded() {\n if (!this.signin_requested) {\n return;\n }\n\n // If there is a promise and it is not resolved, return without creating a new one.\n if (this.signinDonePromise && !(this.signinDonePromise as any).done) {\n return;\n }\n\n // This promise is never rejected.\n // It gets resolved when the signin process is done whether it failed or succeeded\n const { promise, resolve, reject: _ } = flatPromise();\n (promise as any).done = false;\n const setDone = () => {\n (promise as any).done = true;\n };\n promise.then(setDone).catch(setDone);\n this.signinDonePromise = promise;\n this._signinDoneResolve = resolve;\n }\n}\n","import AbstractRuntime from '../runtimes/interface';\nimport Runtime from 'runtime';\nimport * as Collections from './utils/collections';\nimport Channels from './channels/channels';\nimport Channel from './channels/channel';\nimport { default as EventsDispatcher } from './events/dispatcher';\nimport Timeline from './timeline/timeline';\nimport TimelineSender from './timeline/timeline_sender';\nimport TimelineLevel from './timeline/level';\nimport { defineTransport } from './strategies/strategy_builder';\nimport ConnectionManager from './connection/connection_manager';\nimport { PeriodicTimer } from './utils/timers';\nimport Defaults from './defaults';\nimport Logger from './logger';\nimport Factory from './utils/factory';\nimport { Options, ClusterOptions, validateOptions } from './options';\nimport { Config, getConfig } from './config';\nimport StrategyOptions from './strategies/strategy_options';\nimport UserFacade from './user';\n\nexport default class Pusher {\n /* STATIC PROPERTIES */\n static instances: Pusher[] = [];\n static isReady: boolean = false;\n static logToConsole: boolean = false;\n\n // for jsonp\n static Runtime: AbstractRuntime = Runtime;\n static ScriptReceivers: any = (Runtime).ScriptReceivers;\n static DependenciesReceivers: any = (Runtime).DependenciesReceivers;\n static auth_callbacks: any = (Runtime).auth_callbacks;\n\n static ready() {\n Pusher.isReady = true;\n for (var i = 0, l = Pusher.instances.length; i < l; i++) {\n Pusher.instances[i].connect();\n }\n }\n\n static log: (message: any) => void;\n\n private static getClientFeatures(): string[] {\n return Collections.keys(\n Collections.filterObject({ ws: Runtime.Transports.ws }, function(t) {\n return t.isSupported({});\n })\n );\n }\n\n /* INSTANCE PROPERTIES */\n key: string;\n options: Options;\n config: Config;\n channels: Channels;\n global_emitter: EventsDispatcher;\n sessionID: number;\n timeline: Timeline;\n timelineSender: TimelineSender;\n connection: ConnectionManager;\n timelineSenderTimer: PeriodicTimer;\n user: UserFacade;\n constructor(app_key: string, options: Options) {\n checkAppKey(app_key);\n validateOptions(options);\n this.key = app_key;\n this.config = getConfig(options, this);\n\n this.channels = Factory.createChannels();\n this.global_emitter = new EventsDispatcher();\n this.sessionID = Runtime.randomInt(1000000000);\n\n this.timeline = new Timeline(this.key, this.sessionID, {\n cluster: this.config.cluster,\n features: Pusher.getClientFeatures(),\n params: this.config.timelineParams || {},\n limit: 50,\n level: TimelineLevel.INFO,\n version: Defaults.VERSION\n });\n if (this.config.enableStats) {\n this.timelineSender = Factory.createTimelineSender(this.timeline, {\n host: this.config.statsHost,\n path: '/timeline/v2/' + Runtime.TimelineTransport.name\n });\n }\n\n var getStrategy = (options: StrategyOptions) => {\n return Runtime.getDefaultStrategy(this.config, options, defineTransport);\n };\n\n this.connection = Factory.createConnectionManager(this.key, {\n getStrategy: getStrategy,\n timeline: this.timeline,\n activityTimeout: this.config.activityTimeout,\n pongTimeout: this.config.pongTimeout,\n unavailableTimeout: this.config.unavailableTimeout,\n useTLS: Boolean(this.config.useTLS)\n });\n\n this.connection.bind('connected', () => {\n this.subscribeAll();\n if (this.timelineSender) {\n this.timelineSender.send(this.connection.isUsingTLS());\n }\n });\n\n this.connection.bind('message', event => {\n var eventName = event.event;\n var internal = eventName.indexOf('pusher_internal:') === 0;\n if (event.channel) {\n var channel = this.channel(event.channel);\n if (channel) {\n channel.handleEvent(event);\n }\n }\n // Emit globally [deprecated]\n if (!internal) {\n this.global_emitter.emit(event.event, event.data);\n }\n });\n this.connection.bind('connecting', () => {\n this.channels.disconnect();\n });\n this.connection.bind('disconnected', () => {\n this.channels.disconnect();\n });\n this.connection.bind('error', err => {\n Logger.warn(err);\n });\n\n Pusher.instances.push(this);\n this.timeline.info({ instances: Pusher.instances.length });\n\n this.user = new UserFacade(this);\n\n if (Pusher.isReady) {\n this.connect();\n }\n }\n\n /**\n * Allows you to switch Pusher cluster without\n * losing all the channels/subscription binding\n * as this is internally managed by the SDK.\n */\n switchCluster(options: ClusterOptions) {\n const { appKey, cluster } = options;\n this.key = appKey;\n this.options = { ...this.options, cluster };\n this.config = getConfig(this.options, this);\n this.connection.switchCluster(this.key);\n }\n\n channel(name: string): Channel {\n return this.channels.find(name);\n }\n\n allChannels(): Channel[] {\n return this.channels.all();\n }\n\n connect() {\n this.connection.connect();\n\n if (this.timelineSender) {\n if (!this.timelineSenderTimer) {\n var usingTLS = this.connection.isUsingTLS();\n var timelineSender = this.timelineSender;\n this.timelineSenderTimer = new PeriodicTimer(60000, function() {\n timelineSender.send(usingTLS);\n });\n }\n }\n }\n\n disconnect() {\n this.connection.disconnect();\n\n if (this.timelineSenderTimer) {\n this.timelineSenderTimer.ensureAborted();\n this.timelineSenderTimer = null;\n }\n }\n\n bind(event_name: string, callback: Function, context?: any): Pusher {\n this.global_emitter.bind(event_name, callback, context);\n return this;\n }\n\n unbind(event_name?: string, callback?: Function, context?: any): Pusher {\n this.global_emitter.unbind(event_name, callback, context);\n return this;\n }\n\n bind_global(callback: Function): Pusher {\n this.global_emitter.bind_global(callback);\n return this;\n }\n\n unbind_global(callback?: Function): Pusher {\n this.global_emitter.unbind_global(callback);\n return this;\n }\n\n unbind_all(callback?: Function): Pusher {\n this.global_emitter.unbind_all();\n return this;\n }\n\n subscribeAll() {\n var channelName;\n for (channelName in this.channels.channels) {\n if (this.channels.channels.hasOwnProperty(channelName)) {\n this.subscribe(channelName);\n }\n }\n }\n\n subscribe(channel_name: string) {\n var channel = this.channels.add(channel_name, this);\n if (channel.subscriptionPending && channel.subscriptionCancelled) {\n channel.reinstateSubscription();\n } else if (\n !channel.subscriptionPending &&\n this.connection.state === 'connected'\n ) {\n channel.subscribe();\n }\n return channel;\n }\n\n unsubscribe(channel_name: string) {\n var channel = this.channels.find(channel_name);\n if (channel && channel.subscriptionPending) {\n channel.cancelSubscription();\n } else {\n channel = this.channels.remove(channel_name);\n if (channel && channel.subscribed) {\n channel.unsubscribe();\n }\n }\n }\n\n send_event(event_name: string, data: any, channel?: string) {\n return this.connection.send_event(event_name, data, channel);\n }\n\n shouldUseTLS(): boolean {\n return this.config.useTLS;\n }\n\n signin() {\n this.user.signin();\n }\n}\n\nfunction checkAppKey(key) {\n if (key === null || key === undefined) {\n throw 'You must pass your app key when you instantiate Pusher.';\n }\n}\n\nRuntime.setup(Pusher);\n","import ConnectionManager from './connection/connection_manager';\nimport {\n ChannelAuthorizationOptions,\n UserAuthenticationOptions\n} from './auth/options';\nimport {\n ChannelAuthorizerGenerator,\n DeprecatedAuthOptions\n} from './auth/deprecated_channel_authorizer';\nimport { AuthTransport, Transport } from './config';\nimport * as nacl from 'tweetnacl';\nimport Logger from './logger';\n\nexport interface Options {\n activityTimeout?: number;\n\n auth?: DeprecatedAuthOptions; // DEPRECATED use channelAuthorization instead\n authEndpoint?: string; // DEPRECATED use channelAuthorization instead\n authTransport?: AuthTransport; // DEPRECATED use channelAuthorization instead\n authorizer?: ChannelAuthorizerGenerator; // DEPRECATED use channelAuthorization instead\n\n channelAuthorization?: ChannelAuthorizationOptions;\n userAuthentication?: UserAuthenticationOptions;\n\n cluster: string;\n enableStats?: boolean;\n disableStats?: boolean;\n disabledTransports?: Transport[];\n enabledTransports?: Transport[];\n forceTLS?: boolean;\n httpHost?: string;\n httpPath?: string;\n httpPort?: number;\n httpsPort?: number;\n ignoreNullOrigin?: boolean;\n nacl?: nacl;\n pongTimeout?: number;\n statsHost?: string;\n timelineParams?: any;\n unavailableTimeout?: number;\n wsHost?: string;\n wsPath?: string;\n wsPort?: number;\n wssPort?: number;\n}\n\nexport interface ClusterOptions {\n appKey: string;\n cluster: string;\n}\n\nexport function validateOptions(options) {\n if (options == null) {\n throw 'You must pass an options object';\n }\n if (options.cluster == null) {\n throw 'Options object must provide a cluster';\n }\n if ('disableStats' in options) {\n Logger.warn(\n 'The disableStats option is deprecated in favor of enableStats'\n );\n }\n}\n"],"sourceRoot":""} \ No newline at end of file +{"version":3,"sources":["webpack://Pusher/webpack/universalModuleDefinition","webpack://Pusher/webpack/bootstrap","webpack://Pusher/./node_modules/@stablelib/base64/base64.ts","webpack://Pusher/./node_modules/@stablelib/utf8/utf8.ts","webpack://Pusher/./src/core/pusher.js","webpack://Pusher/./src/core/base64.ts","webpack://Pusher/./src/core/utils/timers/abstract_timer.ts","webpack://Pusher/./src/core/utils/timers/index.ts","webpack://Pusher/./src/core/util.ts","webpack://Pusher/./src/core/utils/collections.ts","webpack://Pusher/./src/core/defaults.ts","webpack://Pusher/./src/core/transports/url_schemes.ts","webpack://Pusher/./src/core/events/callback_registry.ts","webpack://Pusher/./src/core/events/dispatcher.ts","webpack://Pusher/./src/core/logger.ts","webpack://Pusher/./src/core/transports/transport_connection.ts","webpack://Pusher/./src/core/transports/transport.ts","webpack://Pusher/./src/runtimes/isomorphic/transports/transports.ts","webpack://Pusher/./src/core/transports/assistant_to_the_transport_manager.ts","webpack://Pusher/./src/core/connection/protocol/protocol.ts","webpack://Pusher/./src/core/connection/connection.ts","webpack://Pusher/./src/core/connection/handshake/index.ts","webpack://Pusher/./src/core/timeline/timeline_sender.ts","webpack://Pusher/./src/core/errors.ts","webpack://Pusher/./src/core/utils/url_store.ts","webpack://Pusher/./src/core/channels/channel.ts","webpack://Pusher/./src/core/channels/private_channel.ts","webpack://Pusher/./src/core/channels/members.ts","webpack://Pusher/./src/core/channels/presence_channel.ts","webpack://Pusher/./src/core/channels/encrypted_channel.ts","webpack://Pusher/./src/core/connection/connection_manager.ts","webpack://Pusher/./src/core/channels/channels.ts","webpack://Pusher/./src/core/utils/factory.ts","webpack://Pusher/./src/core/transports/transport_manager.ts","webpack://Pusher/./src/core/strategies/sequential_strategy.ts","webpack://Pusher/./src/core/strategies/best_connected_ever_strategy.ts","webpack://Pusher/./src/core/strategies/websocket_prioritized_cached_strategy.ts","webpack://Pusher/./src/core/strategies/delayed_strategy.ts","webpack://Pusher/./src/core/strategies/if_strategy.ts","webpack://Pusher/./src/core/strategies/first_connected_strategy.ts","webpack://Pusher/./src/runtimes/isomorphic/default_strategy.ts","webpack://Pusher/./src/core/http/http_request.ts","webpack://Pusher/./src/core/http/state.ts","webpack://Pusher/./src/core/http/http_socket.ts","webpack://Pusher/./src/core/http/http_streaming_socket.ts","webpack://Pusher/./src/core/http/http_polling_socket.ts","webpack://Pusher/./src/runtimes/isomorphic/http/http_xhr_request.ts","webpack://Pusher/./src/runtimes/isomorphic/runtime.ts","webpack://Pusher/./src/runtimes/isomorphic/transports/transport_connection_initializer.ts","webpack://Pusher/./src/runtimes/isomorphic/http/http.ts","webpack://Pusher/./src/runtimes/worker/net_info.ts","webpack://Pusher/./src/runtimes/worker/auth/fetch_auth.ts","webpack://Pusher/./src/runtimes/worker/timeline/fetch_timeline.ts","webpack://Pusher/./src/runtimes/worker/runtime.ts","webpack://Pusher/./src/core/timeline/level.ts","webpack://Pusher/./src/core/timeline/timeline.ts","webpack://Pusher/./src/core/strategies/transport_strategy.ts","webpack://Pusher/./src/core/strategies/strategy_builder.ts","webpack://Pusher/./src/core/auth/options.ts","webpack://Pusher/./src/core/auth/user_authenticator.ts","webpack://Pusher/./src/core/auth/channel_authorizer.ts","webpack://Pusher/./src/core/config.ts","webpack://Pusher/./src/core/auth/deprecated_channel_authorizer.ts","webpack://Pusher/./src/core/watchlist.ts","webpack://Pusher/./src/core/utils/flat_promise.ts","webpack://Pusher/./src/core/user.ts","webpack://Pusher/./src/core/pusher.ts","webpack://Pusher/./src/core/options.ts"],"names":["root","factory","exports","module","define","amd","this","installedModules","__webpack_require__","moduleId","i","l","modules","call","m","c","d","name","getter","o","Object","defineProperty","enumerable","get","r","Symbol","toStringTag","value","t","mode","__esModule","ns","create","key","bind","n","object","property","prototype","hasOwnProperty","p","s","_paddingCharacter","encodedLength","length","encode","data","out","_encodeByte","left","maxDecodedLength","decodedLength","_getPaddingLength","decode","Uint8Array","paddingLength","op","haveBad","v0","v1","v2","v3","_decodeChar","charCodeAt","Error","b","result","String","fromCharCode","Coder","stdCoder","URLSafeCoder","urlSafeCoder","INVALID_UTF8","arr","pos","chars","min","n1","n2","n3","push","join","default","b64chars","b64tab","charAt","cb_utob","cc","utob","u","replace","cb_encode","ccc","padlen","ord","btoa","set","clear","delay","callback","timer","clearTimeout","clearInterval","super","setTimeout","setInterval","now","Date","valueOf","defer","args","boundArguments","Array","slice","arguments","apply","concat","extend","target","sources","extensions","constructor","stringify","safeJSONStringify","arrayIndexOf","array","item","nativeIndexOf","indexOf","objectApply","f","keys","_","context","map","filter","test","filterObject","Boolean","any","encodeParamsObject","encodeURIComponent","toString","buildQueryString","params","undefined","method","source","JSON","e","objects","paths","derez","path","nu","$ref","VERSION","PROTOCOL","wsPort","wssPort","wsPath","httpHost","httpPort","httpsPort","httpPath","stats_host","authEndpoint","authTransport","activityTimeout","pongTimeout","unavailableTimeout","userAuthentication","endpoint","transport","channelAuthorization","cdn_http","cdn_https","dependency_suffix","getGenericURL","baseScheme","useTLS","hostTLS","hostNonTLS","getGenericPath","queryString","ws","getInitial","http","_callbacks","prefix","prefixedEventName","fn","names","removeCallback","removeAllCallbacks","binding","failThrough","callbacks","global_callbacks","eventName","add","remove","unbind","unbind_global","metadata","globalLog","message","console","log","globalLogWarn","globalLogError","warn","error","defaultLoggingFunction","logToConsole","hooks","priority","options","initialize","transportConnectionInitializer","state","timeline","id","generateUniqueID","handlesActivityChecks","supportsPing","socket","url","urls","getSocket","onError","changeState","bindListeners","debug","close","send","ping","beforeOpen","getPath","onopen","emit","type","buildTimelineMessage","closeEvent","code","reason","wasClean","unbindListeners","onOpen","onerror","onclose","onClose","onmessage","onMessage","onactivity","onActivity","info","cid","environment","isSupported","WSTransport","isInitialized","getWebSocketAPI","createWebSocket","httpConfiguration","streamingConfiguration","HTTPFactory","createStreamingSocket","pollingConfiguration","createPollingSocket","xhrConfiguration","isXHRSupported","xhr_streaming","xhr_polling","manager","minPingDelay","maxPingDelay","pingDelay","connection","createConnection","openTimestamp","onClosed","reportDeath","lifespan","Math","max","isAlive","Protocol","decodeMessage","messageEvent","messageData","parse","pusherEventData","pusherEvent","event","channel","user_id","encodeMessage","processHandshake","activity_timeout","action","socket_id","getCloseAction","getCloseError","send_event","listeners","activity","closed","handleCloseEvent","listener","finish","isEmpty","TimelineTransport","getAgent","BadEventName","msg","setPrototypeOf","BadChannelName","TransportPriorityTooLow","TransportClosed","UnsupportedFeature","UnsupportedTransport","UnsupportedStrategy","HTTPAuthError","status","urlStore","baseUrl","authenticationEndpoint","authorizationEndpoint","javascriptQuickStart","triggeringClientEvents","encryptedChannelSupport","fullUrl","urlObj","pusher","subscribed","subscriptionPending","subscriptionCancelled","socketId","auth","suffix","handleSubscriptionSucceededEvent","handleSubscriptionCountEvent","unsubscribe","subscription_count","subscriptionCount","authorize","assign","channel_data","config","channelAuthorizer","channelName","reset","members","member","myID","subscriptionData","presence","hash","count","me","memberData","user_info","authData","channelData","setMyID","user","signinDonePromise","user_data","handleInternalEvent","addedMember","addMember","removedMember","removeMember","onSubscription","disconnect","nacl","sharedSecret","handleEncryptedEvent","handleEvent","ciphertext","nonce","cipherText","secretbox","overheadLength","nonceLength","bytes","open","getDataToEmit","raw","usingTLS","errorCallbacks","buildErrorCallbacks","connectionCallbacks","buildConnectionCallbacks","handshakeCallbacks","buildHandshakeCallbacks","Network","getNetwork","netinfo","retryIn","sendActivityCheck","updateStrategy","runner","strategy","updateState","startConnecting","setUnavailableTimer","disconnectInternally","handshake","connect","handshakeError","abortConnecting","abort","clearRetryTimer","clearUnavailableTimer","abandonConnection","getStrategy","round","retryTimer","ensureAborted","unavailableTimer","stopActivityCheck","activityTimer","pong_timed_out","resetActivityCheck","shouldRetry","connected","Infinity","setConnection","withErrorEmitted","tls_only","refused","backoff","retry","newState","previousState","newStateDescription","previous","current","channels","createEncryptedChannel","errMsg","createPrivateChannel","createPresenceChannel","createChannel","values","createChannels","createConnectionManager","createTimelineSender","createHandshake","createAssistantToTheTransportManager","livesLeft","lives","strategies","loop","failFast","timeout","timeoutLimit","minPriority","tryNextStrategy","tryStrategy","forceMinPriority","isRunning","callbackBuilder","runners","rs","abortRunner","allRunnersFailed","aborted","transports","ttl","storage","getLocalStorage","serializedCache","getTransportCacheKey","flushTransportCache","fetchTransportCache","cacheSkipCount","timestamp","includes","cached","latency","startTimestamp","pop","cb","storeTransportCache","number","IfStrategy","trueBranch","falseBranch","FirstConnectedStrategy","testSupportsStrategy","baseOptions","defineTransport","definedTransports","defineTransportStrategy","wsStrategy","ws_options","wsHost","wss_options","http_options","timeouts","ws_manager","streaming_manager","ws_transport","wss_transport","xhr_streaming_transport","xhr_polling_transport","ws_loop","wss_loop","streaming_loop","polling_loop","http_loop","payload","position","xhr","getRequest","unloader","addUnloadListener","setRequestHeader","removeUnloadListener","abortRequest","chunk","advanceBuffer","isBufferTooLong","buffer","unreadData","endOfLinePosition","State","autoIncrement","getUniqueURL","separator","randomNumber","randomInt","session","randomString","location","parts","exec","base","getLocation","readyState","CONNECTING","openStream","sendRaw","sendHeartbeat","OPEN","createSocketRequest","start","closeStream","CLOSED","onEvent","onHeartbeat","hostname","urlParts","stream","getReceiveURL","onChunk","onFinished","reconnect","unbind_all","getXHRAPI","onreadystatechange","onprogress","responseText","getDefaultStrategy","Transports","createSocket","createRequest","PusherClass","ready","getClientFeatures","getProtocol","createXHR","query","authOptions","authRequestType","headers","Headers","headerName","headersProvider","dynamicHeaders","body","request","Request","credentials","fetch","then","response","text","parsedData","catch","err","sender","host","json","setup","TimelineLevel","getAuthorizers","ajax","WebSocket","XMLHttpRequest","floor","globalThis","crypto","getRandomValues","Uint32Array","events","sent","uniqueID","level","limit","shift","ERROR","INFO","DEBUG","sendfn","bundle","lib","version","cluster","features","failAttempt","onInitialized","serializedTransport","AuthRequestType","transportClass","enabledTransports","disabledTransports","ignoreNullOrigin","getAssistant","deferred","paramsProvider","dynamicParams","composeChannelQuery","UserAuthentication","ChannelAuthorization","getConfig","opts","statsHost","enableStats","getEnableStatsConfig","getHttpHost","shouldUseTLS","getWebsocketHost","userAuthenticator","buildUserAuthenticator","buildChannelAuthorizer","timelineParams","forceTLS","disableStats","customHandler","channelAuthorizerGenerator","deprecatedAuthorizerOptions","ChannelAuthorizerProxy","authorizer","buildChannelAuth","bindWatchlistInternalEvent","forEach","watchlistEvent","resolve","reject","promise","Promise","res","rej","signin_requested","serverToUserChannel","_signinDoneResolve","_onAuthorize","_cleanup","_signin","_newSigninPromiseIfNeeded","watchlist","_onSigninSuccess","_subscribeChannels","bind_global","reinstateSubscription","subscribe","ensure_subscribed","done","setDone","isReady","instances","app_key","checkAppKey","validateOptions","global_emitter","sessionID","timelineSender","subscribeAll","isUsingTLS","internal","appKey","switchCluster","find","all","timelineSenderTimer","event_name","channel_name","cancelSubscription","signin","Runtime","ScriptReceivers","DependenciesReceivers","auth_callbacks"],"mappings":";;;;;;;CAAA,SAA2CA,EAAMC,GAC1B,iBAAZC,SAA0C,iBAAXC,OACxCA,OAAOD,QAAUD,IACQ,mBAAXG,QAAyBA,OAAOC,IAC9CD,OAAO,GAAIH,GACe,iBAAZC,QACdA,QAAgB,OAAID,IAEpBD,EAAa,OAAIC,IARnB,CASGK,MAAM,WACT,O,YCTE,IAAIC,EAAmB,GAGvB,SAASC,EAAoBC,GAG5B,GAAGF,EAAiBE,GACnB,OAAOF,EAAiBE,GAAUP,QAGnC,IAAIC,EAASI,EAAiBE,GAAY,CACzCC,EAAGD,EACHE,GAAG,EACHT,QAAS,IAUV,OANAU,EAAQH,GAAUI,KAAKV,EAAOD,QAASC,EAAQA,EAAOD,QAASM,GAG/DL,EAAOQ,GAAI,EAGJR,EAAOD,QA0Df,OArDAM,EAAoBM,EAAIF,EAGxBJ,EAAoBO,EAAIR,EAGxBC,EAAoBQ,EAAI,SAASd,EAASe,EAAMC,GAC3CV,EAAoBW,EAAEjB,EAASe,IAClCG,OAAOC,eAAenB,EAASe,EAAM,CAAEK,YAAY,EAAMC,IAAKL,KAKhEV,EAAoBgB,EAAI,SAAStB,GACX,oBAAXuB,QAA0BA,OAAOC,aAC1CN,OAAOC,eAAenB,EAASuB,OAAOC,YAAa,CAAEC,MAAO,WAE7DP,OAAOC,eAAenB,EAAS,aAAc,CAAEyB,OAAO,KAQvDnB,EAAoBoB,EAAI,SAASD,EAAOE,GAEvC,GADU,EAAPA,IAAUF,EAAQnB,EAAoBmB,IAC/B,EAAPE,EAAU,OAAOF,EACpB,GAAW,EAAPE,GAA8B,iBAAVF,GAAsBA,GAASA,EAAMG,WAAY,OAAOH,EAChF,IAAII,EAAKX,OAAOY,OAAO,MAGvB,GAFAxB,EAAoBgB,EAAEO,GACtBX,OAAOC,eAAeU,EAAI,UAAW,CAAET,YAAY,EAAMK,MAAOA,IACtD,EAAPE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UlS,KAAKmb,SAAS/O,OAAOmf,KAChBrZ,EAAQwC,YACrBxC,EAAQgD,cAKd,WAAWoW,EAAoB9oB,EAAW0P,GACxC,OAAOlS,KAAKiR,WAAW0B,WAAW2Y,EAAY9oB,EAAM0P,GAGtD,eACE,OAAOlS,KAAKwV,OAAOzK,OAGrB,SACE/K,KAAKyW,KAAKgV,UAtOL,GAAAlB,UAAsB,GACtB,GAAAD,SAAmB,EACnB,GAAArd,cAAwB,EAGxB,GAAAye,QAA2B,GAC3B,GAAAC,gBAA6B,GAASA,gBACtC,GAAAC,sBAAmC,GAASA,sBAC5C,GAAAC,eAA4B,GAASA,eAVzB,oBAkPrB,GAAQ7G,MAAM","file":"pusher.worker.min.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"Pusher\"] = factory();\n\telse\n\t\troot[\"Pusher\"] = factory();\n})(this, function() {\nreturn "," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 2);\n","// Copyright (C) 2016 Dmitry Chestnykh\n// MIT License. See LICENSE file for details.\n\n/**\n * Package base64 implements Base64 encoding and decoding.\n */\n\n// Invalid character used in decoding to indicate\n// that the character to decode is out of range of\n// alphabet and cannot be decoded.\nconst INVALID_BYTE = 256;\n\n/**\n * Implements standard Base64 encoding.\n *\n * Operates in constant time.\n */\nexport class Coder {\n // TODO(dchest): methods to encode chunk-by-chunk.\n\n constructor(private _paddingCharacter = \"=\") { }\n\n encodedLength(length: number): number {\n if (!this._paddingCharacter) {\n return (length * 8 + 5) / 6 | 0;\n }\n return (length + 2) / 3 * 4 | 0;\n }\n\n encode(data: Uint8Array): string {\n let out = \"\";\n\n let i = 0;\n for (; i < data.length - 2; i += 3) {\n let c = (data[i] << 16) | (data[i + 1] << 8) | (data[i + 2]);\n out += this._encodeByte((c >>> 3 * 6) & 63);\n out += this._encodeByte((c >>> 2 * 6) & 63);\n out += this._encodeByte((c >>> 1 * 6) & 63);\n out += this._encodeByte((c >>> 0 * 6) & 63);\n }\n\n const left = data.length - i;\n if (left > 0) {\n let c = (data[i] << 16) | (left === 2 ? data[i + 1] << 8 : 0);\n out += this._encodeByte((c >>> 3 * 6) & 63);\n out += this._encodeByte((c >>> 2 * 6) & 63);\n if (left === 2) {\n out += this._encodeByte((c >>> 1 * 6) & 63);\n } else {\n out += this._paddingCharacter || \"\";\n }\n out += this._paddingCharacter || \"\";\n }\n\n return out;\n }\n\n maxDecodedLength(length: number): number {\n if (!this._paddingCharacter) {\n return (length * 6 + 7) / 8 | 0;\n }\n return length / 4 * 3 | 0;\n }\n\n decodedLength(s: string): number {\n return this.maxDecodedLength(s.length - this._getPaddingLength(s));\n }\n\n decode(s: string): Uint8Array {\n if (s.length === 0) {\n return new Uint8Array(0);\n }\n const paddingLength = this._getPaddingLength(s);\n const length = s.length - paddingLength;\n const out = new Uint8Array(this.maxDecodedLength(length));\n let op = 0;\n let i = 0;\n let haveBad = 0;\n let v0 = 0, v1 = 0, v2 = 0, v3 = 0;\n for (; i < length - 4; i += 4) {\n v0 = this._decodeChar(s.charCodeAt(i + 0));\n v1 = this._decodeChar(s.charCodeAt(i + 1));\n v2 = this._decodeChar(s.charCodeAt(i + 2));\n v3 = this._decodeChar(s.charCodeAt(i + 3));\n out[op++] = (v0 << 2) | (v1 >>> 4);\n out[op++] = (v1 << 4) | (v2 >>> 2);\n out[op++] = (v2 << 6) | v3;\n haveBad |= v0 & INVALID_BYTE;\n haveBad |= v1 & INVALID_BYTE;\n haveBad |= v2 & INVALID_BYTE;\n haveBad |= v3 & INVALID_BYTE;\n }\n if (i < length - 1) {\n v0 = this._decodeChar(s.charCodeAt(i));\n v1 = this._decodeChar(s.charCodeAt(i + 1));\n out[op++] = (v0 << 2) | (v1 >>> 4);\n haveBad |= v0 & INVALID_BYTE;\n haveBad |= v1 & INVALID_BYTE;\n }\n if (i < length - 2) {\n v2 = this._decodeChar(s.charCodeAt(i + 2));\n out[op++] = (v1 << 4) | (v2 >>> 2);\n haveBad |= v2 & INVALID_BYTE;\n }\n if (i < length - 3) {\n v3 = this._decodeChar(s.charCodeAt(i + 3));\n out[op++] = (v2 << 6) | v3;\n haveBad |= v3 & INVALID_BYTE;\n }\n if (haveBad !== 0) {\n throw new Error(\"Base64Coder: incorrect characters for decoding\");\n }\n return out;\n }\n\n // Standard encoding have the following encoded/decoded ranges,\n // which we need to convert between.\n //\n // ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 0123456789 + /\n // Index: 0 - 25 26 - 51 52 - 61 62 63\n // ASCII: 65 - 90 97 - 122 48 - 57 43 47\n //\n\n // Encode 6 bits in b into a new character.\n protected _encodeByte(b: number): string {\n // Encoding uses constant time operations as follows:\n //\n // 1. Define comparison of A with B using (A - B) >>> 8:\n // if A > B, then result is positive integer\n // if A <= B, then result is 0\n //\n // 2. Define selection of C or 0 using bitwise AND: X & C:\n // if X == 0, then result is 0\n // if X != 0, then result is C\n //\n // 3. Start with the smallest comparison (b >= 0), which is always\n // true, so set the result to the starting ASCII value (65).\n //\n // 4. Continue comparing b to higher ASCII values, and selecting\n // zero if comparison isn't true, otherwise selecting a value\n // to add to result, which:\n //\n // a) undoes the previous addition\n // b) provides new value to add\n //\n let result = b;\n // b >= 0\n result += 65;\n // b > 25\n result += ((25 - b) >>> 8) & ((0 - 65) - 26 + 97);\n // b > 51\n result += ((51 - b) >>> 8) & ((26 - 97) - 52 + 48);\n // b > 61\n result += ((61 - b) >>> 8) & ((52 - 48) - 62 + 43);\n // b > 62\n result += ((62 - b) >>> 8) & ((62 - 43) - 63 + 47);\n\n return String.fromCharCode(result);\n }\n\n // Decode a character code into a byte.\n // Must return 256 if character is out of alphabet range.\n protected _decodeChar(c: number): number {\n // Decoding works similar to encoding: using the same comparison\n // function, but now it works on ranges: result is always incremented\n // by value, but this value becomes zero if the range is not\n // satisfied.\n //\n // Decoding starts with invalid value, 256, which is then\n // subtracted when the range is satisfied. If none of the ranges\n // apply, the function returns 256, which is then checked by\n // the caller to throw error.\n let result = INVALID_BYTE; // start with invalid character\n\n // c == 43 (c > 42 and c < 44)\n result += (((42 - c) & (c - 44)) >>> 8) & (-INVALID_BYTE + c - 43 + 62);\n // c == 47 (c > 46 and c < 48)\n result += (((46 - c) & (c - 48)) >>> 8) & (-INVALID_BYTE + c - 47 + 63);\n // c > 47 and c < 58\n result += (((47 - c) & (c - 58)) >>> 8) & (-INVALID_BYTE + c - 48 + 52);\n // c > 64 and c < 91\n result += (((64 - c) & (c - 91)) >>> 8) & (-INVALID_BYTE + c - 65 + 0);\n // c > 96 and c < 123\n result += (((96 - c) & (c - 123)) >>> 8) & (-INVALID_BYTE + c - 97 + 26);\n\n return result;\n }\n\n private _getPaddingLength(s: string): number {\n let paddingLength = 0;\n if (this._paddingCharacter) {\n for (let i = s.length - 1; i >= 0; i--) {\n if (s[i] !== this._paddingCharacter) {\n break;\n }\n paddingLength++;\n }\n if (s.length < 4 || paddingLength > 2) {\n throw new Error(\"Base64Coder: incorrect padding\");\n }\n }\n return paddingLength;\n }\n\n}\n\nconst stdCoder = new Coder();\n\nexport function encode(data: Uint8Array): string {\n return stdCoder.encode(data);\n}\n\nexport function decode(s: string): Uint8Array {\n return stdCoder.decode(s);\n}\n\n/**\n * Implements URL-safe Base64 encoding.\n * (Same as Base64, but '+' is replaced with '-', and '/' with '_').\n *\n * Operates in constant time.\n */\nexport class URLSafeCoder extends Coder {\n // URL-safe encoding have the following encoded/decoded ranges:\n //\n // ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 0123456789 - _\n // Index: 0 - 25 26 - 51 52 - 61 62 63\n // ASCII: 65 - 90 97 - 122 48 - 57 45 95\n //\n\n protected _encodeByte(b: number): string {\n let result = b;\n // b >= 0\n result += 65;\n // b > 25\n result += ((25 - b) >>> 8) & ((0 - 65) - 26 + 97);\n // b > 51\n result += ((51 - b) >>> 8) & ((26 - 97) - 52 + 48);\n // b > 61\n result += ((61 - b) >>> 8) & ((52 - 48) - 62 + 45);\n // b > 62\n result += ((62 - b) >>> 8) & ((62 - 45) - 63 + 95);\n\n return String.fromCharCode(result);\n }\n\n protected _decodeChar(c: number): number {\n let result = INVALID_BYTE;\n\n // c == 45 (c > 44 and c < 46)\n result += (((44 - c) & (c - 46)) >>> 8) & (-INVALID_BYTE + c - 45 + 62);\n // c == 95 (c > 94 and c < 96)\n result += (((94 - c) & (c - 96)) >>> 8) & (-INVALID_BYTE + c - 95 + 63);\n // c > 47 and c < 58\n result += (((47 - c) & (c - 58)) >>> 8) & (-INVALID_BYTE + c - 48 + 52);\n // c > 64 and c < 91\n result += (((64 - c) & (c - 91)) >>> 8) & (-INVALID_BYTE + c - 65 + 0);\n // c > 96 and c < 123\n result += (((96 - c) & (c - 123)) >>> 8) & (-INVALID_BYTE + c - 97 + 26);\n\n return result;\n }\n}\n\nconst urlSafeCoder = new URLSafeCoder();\n\nexport function encodeURLSafe(data: Uint8Array): string {\n return urlSafeCoder.encode(data);\n}\n\nexport function decodeURLSafe(s: string): Uint8Array {\n return urlSafeCoder.decode(s);\n}\n\n\nexport const encodedLength = (length: number) =>\n stdCoder.encodedLength(length);\n\nexport const maxDecodedLength = (length: number) =>\n stdCoder.maxDecodedLength(length);\n\nexport const decodedLength = (s: string) =>\n stdCoder.decodedLength(s);\n","// Copyright (C) 2016 Dmitry Chestnykh\n// MIT License. See LICENSE file for details.\n\n/**\n * Package utf8 implements UTF-8 encoding and decoding.\n */\n\nconst INVALID_UTF16 = \"utf8: invalid string\";\nconst INVALID_UTF8 = \"utf8: invalid source encoding\";\n\n/**\n * Encodes the given string into UTF-8 byte array.\n * Throws if the source string has invalid UTF-16 encoding.\n */\nexport function encode(s: string): Uint8Array {\n // Calculate result length and allocate output array.\n // encodedLength() also validates string and throws errors,\n // so we don't need repeat validation here.\n const arr = new Uint8Array(encodedLength(s));\n\n let pos = 0;\n for (let i = 0; i < s.length; i++) {\n let c = s.charCodeAt(i);\n if (c < 0x80) {\n arr[pos++] = c;\n } else if (c < 0x800) {\n arr[pos++] = 0xc0 | c >> 6;\n arr[pos++] = 0x80 | c & 0x3f;\n } else if (c < 0xd800) {\n arr[pos++] = 0xe0 | c >> 12;\n arr[pos++] = 0x80 | (c >> 6) & 0x3f;\n arr[pos++] = 0x80 | c & 0x3f;\n } else {\n i++; // get one more character\n c = (c & 0x3ff) << 10;\n c |= s.charCodeAt(i) & 0x3ff;\n c += 0x10000;\n\n arr[pos++] = 0xf0 | c >> 18;\n arr[pos++] = 0x80 | (c >> 12) & 0x3f;\n arr[pos++] = 0x80 | (c >> 6) & 0x3f;\n arr[pos++] = 0x80 | c & 0x3f;\n }\n }\n return arr;\n}\n\n/**\n * Returns the number of bytes required to encode the given string into UTF-8.\n * Throws if the source string has invalid UTF-16 encoding.\n */\nexport function encodedLength(s: string): number {\n let result = 0;\n for (let i = 0; i < s.length; i++) {\n const c = s.charCodeAt(i);\n if (c < 0x80) {\n result += 1;\n } else if (c < 0x800) {\n result += 2;\n } else if (c < 0xd800) {\n result += 3;\n } else if (c <= 0xdfff) {\n if (i >= s.length - 1) {\n throw new Error(INVALID_UTF16);\n }\n i++; // \"eat\" next character\n result += 4;\n } else {\n throw new Error(INVALID_UTF16);\n }\n }\n return result;\n}\n\n/**\n * Decodes the given byte array from UTF-8 into a string.\n * Throws if encoding is invalid.\n */\nexport function decode(arr: Uint8Array): string {\n const chars: string[] = [];\n for (let i = 0; i < arr.length; i++) {\n let b = arr[i];\n\n if (b & 0x80) {\n let min;\n if (b < 0xe0) {\n // Need 1 more byte.\n if (i >= arr.length) {\n throw new Error(INVALID_UTF8);\n }\n const n1 = arr[++i];\n if ((n1 & 0xc0) !== 0x80) {\n throw new Error(INVALID_UTF8);\n }\n b = (b & 0x1f) << 6 | (n1 & 0x3f);\n min = 0x80;\n } else if (b < 0xf0) {\n // Need 2 more bytes.\n if (i >= arr.length - 1) {\n throw new Error(INVALID_UTF8);\n }\n const n1 = arr[++i];\n const n2 = arr[++i];\n if ((n1 & 0xc0) !== 0x80 || (n2 & 0xc0) !== 0x80) {\n throw new Error(INVALID_UTF8);\n }\n b = (b & 0x0f) << 12 | (n1 & 0x3f) << 6 | (n2 & 0x3f);\n min = 0x800;\n } else if (b < 0xf8) {\n // Need 3 more bytes.\n if (i >= arr.length - 2) {\n throw new Error(INVALID_UTF8);\n }\n const n1 = arr[++i];\n const n2 = arr[++i];\n const n3 = arr[++i];\n if ((n1 & 0xc0) !== 0x80 || (n2 & 0xc0) !== 0x80 || (n3 & 0xc0) !== 0x80) {\n throw new Error(INVALID_UTF8);\n }\n b = (b & 0x0f) << 18 | (n1 & 0x3f) << 12 | (n2 & 0x3f) << 6 | (n3 & 0x3f);\n min = 0x10000;\n } else {\n throw new Error(INVALID_UTF8);\n }\n\n if (b < min || (b >= 0xd800 && b <= 0xdfff)) {\n throw new Error(INVALID_UTF8);\n }\n\n if (b >= 0x10000) {\n // Surrogate pair.\n if (b > 0x10ffff) {\n throw new Error(INVALID_UTF8);\n }\n b -= 0x10000;\n chars.push(String.fromCharCode(0xd800 | (b >> 10)));\n b = 0xdc00 | (b & 0x3ff);\n }\n }\n\n chars.push(String.fromCharCode(b));\n }\n return chars.join(\"\");\n}\n","// required so we don't have to do require('pusher').default etc.\nmodule.exports = require('./pusher').default;\n","export default function encode(s: any): string {\n return btoa(utob(s));\n}\n\nvar fromCharCode = String.fromCharCode;\n\nvar b64chars =\n 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';\nvar b64tab = {};\n\nfor (var i = 0, l = b64chars.length; i < l; i++) {\n b64tab[b64chars.charAt(i)] = i;\n}\n\nvar cb_utob = function(c) {\n var cc = c.charCodeAt(0);\n return cc < 0x80\n ? c\n : cc < 0x800\n ? fromCharCode(0xc0 | (cc >>> 6)) + fromCharCode(0x80 | (cc & 0x3f))\n : fromCharCode(0xe0 | ((cc >>> 12) & 0x0f)) +\n fromCharCode(0x80 | ((cc >>> 6) & 0x3f)) +\n fromCharCode(0x80 | (cc & 0x3f));\n};\n\nvar utob = function(u) {\n return u.replace(/[^\\x00-\\x7F]/g, cb_utob);\n};\n\nvar cb_encode = function(ccc) {\n var padlen = [0, 2, 1][ccc.length % 3];\n var ord =\n (ccc.charCodeAt(0) << 16) |\n ((ccc.length > 1 ? ccc.charCodeAt(1) : 0) << 8) |\n (ccc.length > 2 ? ccc.charCodeAt(2) : 0);\n var chars = [\n b64chars.charAt(ord >>> 18),\n b64chars.charAt((ord >>> 12) & 63),\n padlen >= 2 ? '=' : b64chars.charAt((ord >>> 6) & 63),\n padlen >= 1 ? '=' : b64chars.charAt(ord & 63)\n ];\n return chars.join('');\n};\n\nvar btoa =\n global.btoa ||\n function(b) {\n return b.replace(/[\\s\\S]{1,3}/g, cb_encode);\n };\n","import TimedCallback from './timed_callback';\nimport { Delay, Scheduler, Canceller } from './scheduling';\n\nabstract class Timer {\n protected clear: Canceller;\n protected timer: number | void;\n\n constructor(\n set: Scheduler,\n clear: Canceller,\n delay: Delay,\n callback: TimedCallback\n ) {\n this.clear = clear;\n this.timer = set(() => {\n if (this.timer) {\n this.timer = callback(this.timer);\n }\n }, delay);\n }\n\n /** Returns whether the timer is still running.\n *\n * @return {Boolean}\n */\n isRunning(): boolean {\n return this.timer !== null;\n }\n\n /** Aborts a timer when it's running. */\n ensureAborted() {\n if (this.timer) {\n this.clear(this.timer);\n this.timer = null;\n }\n }\n}\n\nexport default Timer;\n","import Timer from './abstract_timer';\nimport TimedCallback from './timed_callback';\nimport { Delay } from './scheduling';\n\n// We need to bind clear functions this way to avoid exceptions on IE8\nfunction clearTimeout(timer) {\n global.clearTimeout(timer);\n}\nfunction clearInterval(timer) {\n global.clearInterval(timer);\n}\n\n/** Cross-browser compatible one-off timer abstraction.\n *\n * @param {Number} delay\n * @param {Function} callback\n */\nexport class OneOffTimer extends Timer {\n constructor(delay: Delay, callback: TimedCallback) {\n super(setTimeout, clearTimeout, delay, function(timer) {\n callback();\n return null;\n });\n }\n}\n\n/** Cross-browser compatible periodic timer abstraction.\n *\n * @param {Number} delay\n * @param {Function} callback\n */\nexport class PeriodicTimer extends Timer {\n constructor(delay: Delay, callback: TimedCallback) {\n super(setInterval, clearInterval, delay, function(timer) {\n callback();\n return timer;\n });\n }\n}\n","import * as Collections from './utils/collections';\nimport TimedCallback from './utils/timers/timed_callback';\nimport { OneOffTimer, PeriodicTimer } from './utils/timers';\n\nvar Util = {\n now(): number {\n if (Date.now) {\n return Date.now();\n } else {\n return new Date().valueOf();\n }\n },\n\n defer(callback: TimedCallback): OneOffTimer {\n return new OneOffTimer(0, callback);\n },\n\n /** Builds a function that will proxy a method call to its first argument.\n *\n * Allows partial application of arguments, so additional arguments are\n * prepended to the argument list.\n *\n * @param {String} name method name\n * @return {Function} proxy function\n */\n method(name: string, ...args: any[]): Function {\n var boundArguments = Array.prototype.slice.call(arguments, 1);\n return function(object) {\n return object[name].apply(object, boundArguments.concat(arguments));\n };\n }\n};\n\nexport default Util;\n","import base64encode from '../base64';\nimport Util from '../util';\n\n/** Merges multiple objects into the target argument.\n *\n * For properties that are plain Objects, performs a deep-merge. For the\n * rest it just copies the value of the property.\n *\n * To extend prototypes use it as following:\n * Pusher.Util.extend(Target.prototype, Base.prototype)\n *\n * You can also use it to merge objects without altering them:\n * Pusher.Util.extend({}, object1, object2)\n *\n * @param {Object} target\n * @return {Object} the target argument\n */\nexport function extend(target: any, ...sources: any[]): T {\n for (var i = 0; i < sources.length; i++) {\n var extensions = sources[i];\n for (var property in extensions) {\n if (\n extensions[property] &&\n extensions[property].constructor &&\n extensions[property].constructor === Object\n ) {\n target[property] = extend(target[property] || {}, extensions[property]);\n } else {\n target[property] = extensions[property];\n }\n }\n }\n return target;\n}\n\nexport function stringify(): string {\n var m = ['Pusher'];\n for (var i = 0; i < arguments.length; i++) {\n if (typeof arguments[i] === 'string') {\n m.push(arguments[i]);\n } else {\n m.push(safeJSONStringify(arguments[i]));\n }\n }\n return m.join(' : ');\n}\n\nexport function arrayIndexOf(array: any[], item: any): number {\n // MSIE doesn't have array.indexOf\n var nativeIndexOf = Array.prototype.indexOf;\n if (array === null) {\n return -1;\n }\n if (nativeIndexOf && array.indexOf === nativeIndexOf) {\n return array.indexOf(item);\n }\n for (var i = 0, l = array.length; i < l; i++) {\n if (array[i] === item) {\n return i;\n }\n }\n return -1;\n}\n\n/** Applies a function f to all properties of an object.\n *\n * Function f gets 3 arguments passed:\n * - element from the object\n * - key of the element\n * - reference to the object\n *\n * @param {Object} object\n * @param {Function} f\n */\nexport function objectApply(object: any, f: Function) {\n for (var key in object) {\n if (Object.prototype.hasOwnProperty.call(object, key)) {\n f(object[key], key, object);\n }\n }\n}\n\n/** Return a list of objects own proerty keys\n *\n * @param {Object} object\n * @returns {Array}\n */\nexport function keys(object: any): string[] {\n var keys = [];\n objectApply(object, function(_, key) {\n keys.push(key);\n });\n return keys;\n}\n\n/** Return a list of object's own property values\n *\n * @param {Object} object\n * @returns {Array}\n */\nexport function values(object: any): any[] {\n var values = [];\n objectApply(object, function(value) {\n values.push(value);\n });\n return values;\n}\n\n/** Applies a function f to all elements of an array.\n *\n * Function f gets 3 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function apply(array: any[], f: Function, context?: any) {\n for (var i = 0; i < array.length; i++) {\n f.call(context || global, array[i], i, array);\n }\n}\n\n/** Maps all elements of the array and returns the result.\n *\n * Function f gets 4 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n * - reference to the destination array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function map(array: any[], f: Function): any[] {\n var result = [];\n for (var i = 0; i < array.length; i++) {\n result.push(f(array[i], i, array, result));\n }\n return result;\n}\n\n/** Maps all elements of the object and returns the result.\n *\n * Function f gets 4 arguments passed:\n * - element from the object\n * - key of the element\n * - reference to the source object\n * - reference to the destination object\n *\n * @param {Object} object\n * @param {Function} f\n */\nexport function mapObject(object: any, f: Function): any {\n var result = {};\n objectApply(object, function(value, key) {\n result[key] = f(value);\n });\n return result;\n}\n\n/** Filters elements of the array using a test function.\n *\n * Function test gets 4 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n * - reference to the destination array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function filter(array: any[], test: Function): any[] {\n test =\n test ||\n function(value) {\n return !!value;\n };\n\n var result = [];\n for (var i = 0; i < array.length; i++) {\n if (test(array[i], i, array, result)) {\n result.push(array[i]);\n }\n }\n return result;\n}\n\n/** Filters properties of the object using a test function.\n *\n * Function test gets 4 arguments passed:\n * - element from the object\n * - key of the element\n * - reference to the source object\n * - reference to the destination object\n *\n * @param {Object} object\n * @param {Function} f\n */\nexport function filterObject(object: Object, test: Function) {\n var result = {};\n objectApply(object, function(value, key) {\n if ((test && test(value, key, object, result)) || Boolean(value)) {\n result[key] = value;\n }\n });\n return result;\n}\n\n/** Flattens an object into a two-dimensional array.\n *\n * @param {Object} object\n * @return {Array} resulting array of [key, value] pairs\n */\nexport function flatten(object: Object): any[] {\n var result = [];\n objectApply(object, function(value, key) {\n result.push([key, value]);\n });\n return result;\n}\n\n/** Checks whether any element of the array passes the test.\n *\n * Function test gets 3 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function any(array: any[], test: Function): boolean {\n for (var i = 0; i < array.length; i++) {\n if (test(array[i], i, array)) {\n return true;\n }\n }\n return false;\n}\n\n/** Checks whether all elements of the array pass the test.\n *\n * Function test gets 3 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function all(array: any[], test: Function): boolean {\n for (var i = 0; i < array.length; i++) {\n if (!test(array[i], i, array)) {\n return false;\n }\n }\n return true;\n}\n\nexport function encodeParamsObject(data): string {\n return mapObject(data, function(value) {\n if (typeof value === 'object') {\n value = safeJSONStringify(value);\n }\n return encodeURIComponent(base64encode(value.toString()));\n });\n}\n\nexport function buildQueryString(data: any): string {\n var params = filterObject(data, function(value) {\n return value !== undefined;\n });\n\n var query = map(\n flatten(encodeParamsObject(params)),\n Util.method('join', '=')\n ).join('&');\n\n return query;\n}\n\n/**\n * See https://github.com/douglascrockford/JSON-js/blob/master/cycle.js\n *\n * Remove circular references from an object. Required for JSON.stringify in\n * React Native, which tends to blow up a lot.\n *\n * @param {any} object\n * @return {any} Decycled object\n */\nexport function decycleObject(object: any): any {\n var objects = [],\n paths = [];\n\n return (function derez(value, path) {\n var i, name, nu;\n\n switch (typeof value) {\n case 'object':\n if (!value) {\n return null;\n }\n for (i = 0; i < objects.length; i += 1) {\n if (objects[i] === value) {\n return { $ref: paths[i] };\n }\n }\n\n objects.push(value);\n paths.push(path);\n\n if (Object.prototype.toString.apply(value) === '[object Array]') {\n nu = [];\n for (i = 0; i < value.length; i += 1) {\n nu[i] = derez(value[i], path + '[' + i + ']');\n }\n } else {\n nu = {};\n for (name in value) {\n if (Object.prototype.hasOwnProperty.call(value, name)) {\n nu[name] = derez(\n value[name],\n path + '[' + JSON.stringify(name) + ']'\n );\n }\n }\n }\n return nu;\n case 'number':\n case 'string':\n case 'boolean':\n return value;\n }\n })(object, '$');\n}\n\n/**\n * Provides a cross-browser and cross-platform way to safely stringify objects\n * into JSON. This is particularly necessary for ReactNative, where circular JSON\n * structures throw an exception.\n *\n * @param {any} source The object to stringify\n * @return {string} The serialized output.\n */\nexport function safeJSONStringify(source: any): string {\n try {\n return JSON.stringify(source);\n } catch (e) {\n return JSON.stringify(decycleObject(source));\n }\n}\n","import {\n ChannelAuthorizationOptions,\n UserAuthenticationOptions\n} from './auth/options';\nimport { AuthTransport } from './config';\n\nexport interface DefaultConfig {\n VERSION: string;\n PROTOCOL: number;\n wsPort: number;\n wssPort: number;\n wsPath: string;\n httpHost: string;\n httpPort: number;\n httpsPort: number;\n httpPath: string;\n stats_host: string;\n authEndpoint: string;\n authTransport: AuthTransport;\n activityTimeout: number;\n pongTimeout: number;\n unavailableTimeout: number;\n userAuthentication: UserAuthenticationOptions;\n channelAuthorization: ChannelAuthorizationOptions;\n\n cdn_http?: string;\n cdn_https?: string;\n dependency_suffix?: string;\n}\n\nvar Defaults: DefaultConfig = {\n VERSION: VERSION,\n PROTOCOL: 7,\n\n wsPort: 80,\n wssPort: 443,\n wsPath: '',\n // DEPRECATED: SockJS fallback parameters\n httpHost: 'sockjs.pusher.com',\n httpPort: 80,\n httpsPort: 443,\n httpPath: '/pusher',\n // DEPRECATED: Stats\n stats_host: 'stats.pusher.com',\n // DEPRECATED: Other settings\n authEndpoint: '/pusher/auth',\n authTransport: 'ajax',\n activityTimeout: 120000,\n pongTimeout: 30000,\n unavailableTimeout: 10000,\n userAuthentication: {\n endpoint: '/pusher/user-auth',\n transport: 'ajax'\n },\n channelAuthorization: {\n endpoint: '/pusher/auth',\n transport: 'ajax'\n },\n\n // CDN configuration\n cdn_http: CDN_HTTP,\n cdn_https: CDN_HTTPS,\n dependency_suffix: DEPENDENCY_SUFFIX\n};\n\nexport default Defaults;\n","import Defaults from '../defaults';\nimport { default as URLScheme, URLSchemeParams } from './url_scheme';\n\nfunction getGenericURL(\n baseScheme: string,\n params: URLSchemeParams,\n path: string\n): string {\n var scheme = baseScheme + (params.useTLS ? 's' : '');\n var host = params.useTLS ? params.hostTLS : params.hostNonTLS;\n return scheme + '://' + host + path;\n}\n\nfunction getGenericPath(key: string, queryString?: string): string {\n var path = '/app/' + key;\n var query =\n '?protocol=' +\n Defaults.PROTOCOL +\n '&client=js' +\n '&version=' +\n Defaults.VERSION +\n (queryString ? '&' + queryString : '');\n return path + query;\n}\n\nexport var ws: URLScheme = {\n getInitial: function(key: string, params: URLSchemeParams): string {\n var path = (params.httpPath || '') + getGenericPath(key, 'flash=false');\n return getGenericURL('ws', params, path);\n }\n};\n\nexport var http: URLScheme = {\n getInitial: function(key: string, params: URLSchemeParams): string {\n var path = (params.httpPath || '/pusher') + getGenericPath(key);\n return getGenericURL('http', params, path);\n }\n};\n\nexport var sockjs: URLScheme = {\n getInitial: function(key: string, params: URLSchemeParams): string {\n return getGenericURL('http', params, params.httpPath || '/pusher');\n },\n getPath: function(key: string, params: URLSchemeParams): string {\n return getGenericPath(key);\n }\n};\n","import Callback from './callback';\nimport * as Collections from '../utils/collections';\nimport CallbackTable from './callback_table';\n\nexport default class CallbackRegistry {\n _callbacks: CallbackTable;\n\n constructor() {\n this._callbacks = {};\n }\n\n get(name: string): Callback[] {\n return this._callbacks[prefix(name)];\n }\n\n add(name: string, callback: Function, context: any) {\n var prefixedEventName = prefix(name);\n this._callbacks[prefixedEventName] =\n this._callbacks[prefixedEventName] || [];\n this._callbacks[prefixedEventName].push({\n fn: callback,\n context: context\n });\n }\n\n remove(name?: string, callback?: Function, context?: any) {\n if (!name && !callback && !context) {\n this._callbacks = {};\n return;\n }\n\n var names = name ? [prefix(name)] : Collections.keys(this._callbacks);\n\n if (callback || context) {\n this.removeCallback(names, callback, context);\n } else {\n this.removeAllCallbacks(names);\n }\n }\n\n private removeCallback(names: string[], callback: Function, context: any) {\n Collections.apply(\n names,\n function(name) {\n this._callbacks[name] = Collections.filter(\n this._callbacks[name] || [],\n function(binding) {\n return (\n (callback && callback !== binding.fn) ||\n (context && context !== binding.context)\n );\n }\n );\n if (this._callbacks[name].length === 0) {\n delete this._callbacks[name];\n }\n },\n this\n );\n }\n\n private removeAllCallbacks(names: string[]) {\n Collections.apply(\n names,\n function(name) {\n delete this._callbacks[name];\n },\n this\n );\n }\n}\n\nfunction prefix(name: string): string {\n return '_' + name;\n}\n","import * as Collections from '../utils/collections';\nimport Callback from './callback';\nimport Metadata from '../channels/metadata';\nimport CallbackRegistry from './callback_registry';\n\n/** Manages callback bindings and event emitting.\n *\n * @param Function failThrough called when no listeners are bound to an event\n */\nexport default class Dispatcher {\n callbacks: CallbackRegistry;\n global_callbacks: Function[];\n failThrough: Function;\n\n constructor(failThrough?: Function) {\n this.callbacks = new CallbackRegistry();\n this.global_callbacks = [];\n this.failThrough = failThrough;\n }\n\n bind(eventName: string, callback: Function, context?: any) {\n this.callbacks.add(eventName, callback, context);\n return this;\n }\n\n bind_global(callback: Function) {\n this.global_callbacks.push(callback);\n return this;\n }\n\n unbind(eventName?: string, callback?: Function, context?: any) {\n this.callbacks.remove(eventName, callback, context);\n return this;\n }\n\n unbind_global(callback?: Function) {\n if (!callback) {\n this.global_callbacks = [];\n return this;\n }\n\n this.global_callbacks = Collections.filter(\n this.global_callbacks || [],\n c => c !== callback\n );\n\n return this;\n }\n\n unbind_all() {\n this.unbind();\n this.unbind_global();\n return this;\n }\n\n emit(eventName: string, data?: any, metadata?: Metadata): Dispatcher {\n for (var i = 0; i < this.global_callbacks.length; i++) {\n this.global_callbacks[i](eventName, data);\n }\n\n var callbacks = this.callbacks.get(eventName);\n var args = [];\n\n if (metadata) {\n // if there's a metadata argument, we need to call the callback with both\n // data and metadata regardless of whether data is undefined\n args.push(data, metadata);\n } else if (data) {\n // metadata is undefined, so we only need to call the callback with data\n // if data exists\n args.push(data);\n }\n\n if (callbacks && callbacks.length > 0) {\n for (var i = 0; i < callbacks.length; i++) {\n callbacks[i].fn.apply(callbacks[i].context || global, args);\n }\n } else if (this.failThrough) {\n this.failThrough(eventName, data);\n }\n\n return this;\n }\n}\n","import { stringify } from './utils/collections';\nimport Pusher from './pusher';\n\nclass Logger {\n debug(...args: any[]) {\n this.log(this.globalLog, args);\n }\n\n warn(...args: any[]) {\n this.log(this.globalLogWarn, args);\n }\n\n error(...args: any[]) {\n this.log(this.globalLogError, args);\n }\n\n private globalLog = (message: string) => {\n if (global.console && global.console.log) {\n global.console.log(message);\n }\n };\n\n private globalLogWarn(message: string) {\n if (global.console && global.console.warn) {\n global.console.warn(message);\n } else {\n this.globalLog(message);\n }\n }\n\n private globalLogError(message: string) {\n if (global.console && global.console.error) {\n global.console.error(message);\n } else {\n this.globalLogWarn(message);\n }\n }\n\n private log(\n defaultLoggingFunction: (message: string) => void,\n ...args: any[]\n ) {\n var message = stringify.apply(this, arguments);\n if (Pusher.log) {\n Pusher.log(message);\n } else if (Pusher.logToConsole) {\n const log = defaultLoggingFunction.bind(this);\n log(message);\n }\n }\n}\n\nexport default new Logger();\n","import Util from '../util';\nimport * as Collections from '../utils/collections';\nimport { default as EventsDispatcher } from '../events/dispatcher';\nimport Logger from '../logger';\nimport TransportHooks from './transport_hooks';\nimport Socket from '../socket';\nimport Runtime from 'runtime';\nimport Timeline from '../timeline/timeline';\nimport TransportConnectionOptions from './transport_connection_options';\n\n/** Provides universal API for transport connections.\n *\n * Transport connection is a low-level object that wraps a connection method\n * and exposes a simple evented interface for the connection state and\n * messaging. It does not implement Pusher-specific WebSocket protocol.\n *\n * Additionally, it fetches resources needed for transport to work and exposes\n * an interface for querying transport features.\n *\n * States:\n * - new - initial state after constructing the object\n * - initializing - during initialization phase, usually fetching resources\n * - intialized - ready to establish a connection\n * - connection - when connection is being established\n * - open - when connection ready to be used\n * - closed - after connection was closed be either side\n *\n * Emits:\n * - error - after the connection raised an error\n *\n * Options:\n * - useTLS - whether connection should be over TLS\n * - hostTLS - host to connect to when connection is over TLS\n * - hostNonTLS - host to connect to when connection is over TLS\n *\n * @param {String} key application key\n * @param {Object} options\n */\nexport default class TransportConnection extends EventsDispatcher {\n hooks: TransportHooks;\n name: string;\n priority: number;\n key: string;\n options: TransportConnectionOptions;\n state: string;\n timeline: Timeline;\n activityTimeout: number;\n id: number;\n socket: Socket;\n beforeOpen: Function;\n initialize: Function;\n\n constructor(\n hooks: TransportHooks,\n name: string,\n priority: number,\n key: string,\n options: TransportConnectionOptions\n ) {\n super();\n this.initialize = Runtime.transportConnectionInitializer;\n this.hooks = hooks;\n this.name = name;\n this.priority = priority;\n this.key = key;\n this.options = options;\n\n this.state = 'new';\n this.timeline = options.timeline;\n this.activityTimeout = options.activityTimeout;\n this.id = this.timeline.generateUniqueID();\n }\n\n /** Checks whether the transport handles activity checks by itself.\n *\n * @return {Boolean}\n */\n handlesActivityChecks(): boolean {\n return Boolean(this.hooks.handlesActivityChecks);\n }\n\n /** Checks whether the transport supports the ping/pong API.\n *\n * @return {Boolean}\n */\n supportsPing(): boolean {\n return Boolean(this.hooks.supportsPing);\n }\n\n /** Tries to establish a connection.\n *\n * @returns {Boolean} false if transport is in invalid state\n */\n connect(): boolean {\n if (this.socket || this.state !== 'initialized') {\n return false;\n }\n\n var url = this.hooks.urls.getInitial(this.key, this.options);\n try {\n this.socket = this.hooks.getSocket(url, this.options);\n } catch (e) {\n Util.defer(() => {\n this.onError(e);\n this.changeState('closed');\n });\n return false;\n }\n\n this.bindListeners();\n\n Logger.debug('Connecting', { transport: this.name, url });\n this.changeState('connecting');\n return true;\n }\n\n /** Closes the connection.\n *\n * @return {Boolean} true if there was a connection to close\n */\n close(): boolean {\n if (this.socket) {\n this.socket.close();\n return true;\n } else {\n return false;\n }\n }\n\n /** Sends data over the open connection.\n *\n * @param {String} data\n * @return {Boolean} true only when in the \"open\" state\n */\n send(data: any): boolean {\n if (this.state === 'open') {\n // Workaround for MobileSafari bug (see https://gist.github.com/2052006)\n Util.defer(() => {\n if (this.socket) {\n this.socket.send(data);\n }\n });\n return true;\n } else {\n return false;\n }\n }\n\n /** Sends a ping if the connection is open and transport supports it. */\n ping() {\n if (this.state === 'open' && this.supportsPing()) {\n this.socket.ping();\n }\n }\n\n private onOpen() {\n if (this.hooks.beforeOpen) {\n this.hooks.beforeOpen(\n this.socket,\n this.hooks.urls.getPath(this.key, this.options)\n );\n }\n this.changeState('open');\n this.socket.onopen = undefined;\n }\n\n private onError(error) {\n this.emit('error', { type: 'WebSocketError', error: error });\n this.timeline.error(this.buildTimelineMessage({ error: error.toString() }));\n }\n\n private onClose(closeEvent?: any) {\n if (closeEvent) {\n this.changeState('closed', {\n code: closeEvent.code,\n reason: closeEvent.reason,\n wasClean: closeEvent.wasClean\n });\n } else {\n this.changeState('closed');\n }\n this.unbindListeners();\n this.socket = undefined;\n }\n\n private onMessage(message) {\n this.emit('message', message);\n }\n\n private onActivity() {\n this.emit('activity');\n }\n\n private bindListeners() {\n this.socket.onopen = () => {\n this.onOpen();\n };\n this.socket.onerror = error => {\n this.onError(error);\n };\n this.socket.onclose = closeEvent => {\n this.onClose(closeEvent);\n };\n this.socket.onmessage = message => {\n this.onMessage(message);\n };\n\n if (this.supportsPing()) {\n this.socket.onactivity = () => {\n this.onActivity();\n };\n }\n }\n\n private unbindListeners() {\n if (this.socket) {\n this.socket.onopen = undefined;\n this.socket.onerror = undefined;\n this.socket.onclose = undefined;\n this.socket.onmessage = undefined;\n if (this.supportsPing()) {\n this.socket.onactivity = undefined;\n }\n }\n }\n\n private changeState(state: string, params?: any) {\n this.state = state;\n this.timeline.info(\n this.buildTimelineMessage({\n state: state,\n params: params\n })\n );\n this.emit(state, params);\n }\n\n buildTimelineMessage(message): any {\n return Collections.extend({ cid: this.id }, message);\n }\n}\n","import Factory from '../utils/factory';\nimport TransportHooks from './transport_hooks';\nimport TransportConnection from './transport_connection';\nimport TransportConnectionOptions from './transport_connection_options';\n\n/** Provides interface for transport connection instantiation.\n *\n * Takes transport-specific hooks as the only argument, which allow checking\n * for transport support and creating its connections.\n *\n * Supported hooks: * - file - the name of the file to be fetched during initialization\n * - urls - URL scheme to be used by transport\n * - handlesActivityCheck - true when the transport handles activity checks\n * - supportsPing - true when the transport has a ping/activity API\n * - isSupported - tells whether the transport is supported in the environment\n * - getSocket - creates a WebSocket-compatible transport socket\n *\n * See transports.js for specific implementations.\n *\n * @param {Object} hooks object containing all needed transport hooks\n */\nexport default class Transport {\n hooks: TransportHooks;\n\n constructor(hooks: TransportHooks) {\n this.hooks = hooks;\n }\n\n /** Returns whether the transport is supported in the environment.\n *\n * @param {Object} envronment te environment details (encryption, settings)\n * @returns {Boolean} true when the transport is supported\n */\n isSupported(environment: any): boolean {\n return this.hooks.isSupported(environment);\n }\n\n /** Creates a transport connection.\n *\n * @param {String} name\n * @param {Number} priority\n * @param {String} key the application key\n * @param {Object} options\n * @returns {TransportConnection}\n */\n createConnection(\n name: string,\n priority: number,\n key: string,\n options: any\n ): TransportConnection {\n return new TransportConnection(this.hooks, name, priority, key, options);\n }\n}\n","import * as URLSchemes from 'core/transports/url_schemes';\nimport URLScheme from 'core/transports/url_scheme';\nimport Transport from 'core/transports/transport';\nimport Util from 'core/util';\nimport * as Collections from 'core/utils/collections';\nimport TransportHooks from 'core/transports/transport_hooks';\nimport TransportsTable from 'core/transports/transports_table';\nimport Runtime from 'runtime';\n\n/** WebSocket transport.\n *\n * Uses native WebSocket implementation, including MozWebSocket supported by\n * earlier Firefox versions.\n */\nvar WSTransport = new Transport({\n urls: URLSchemes.ws,\n handlesActivityChecks: false,\n supportsPing: false,\n\n isInitialized: function() {\n return Boolean(Runtime.getWebSocketAPI());\n },\n isSupported: function(): boolean {\n return Boolean(Runtime.getWebSocketAPI());\n },\n getSocket: function(url) {\n return Runtime.createWebSocket(url);\n }\n});\n\nvar httpConfiguration = {\n urls: URLSchemes.http,\n handlesActivityChecks: false,\n supportsPing: true,\n isInitialized: function() {\n return true;\n }\n};\n\nexport var streamingConfiguration = Collections.extend(\n {\n getSocket: function(url) {\n return Runtime.HTTPFactory.createStreamingSocket(url);\n }\n },\n httpConfiguration\n);\nexport var pollingConfiguration = Collections.extend(\n {\n getSocket: function(url) {\n return Runtime.HTTPFactory.createPollingSocket(url);\n }\n },\n httpConfiguration\n);\n\nvar xhrConfiguration = {\n isSupported: function(): boolean {\n return Runtime.isXHRSupported();\n }\n};\n\n/** HTTP streaming transport using CORS-enabled XMLHttpRequest. */\nvar XHRStreamingTransport = new Transport(\n (\n Collections.extend({}, streamingConfiguration, xhrConfiguration)\n )\n);\n\n/** HTTP long-polling transport using CORS-enabled XMLHttpRequest. */\nvar XHRPollingTransport = new Transport(\n Collections.extend({}, pollingConfiguration, xhrConfiguration)\n);\n\nvar Transports: TransportsTable = {\n ws: WSTransport,\n xhr_streaming: XHRStreamingTransport,\n xhr_polling: XHRPollingTransport\n};\n\nexport default Transports;\n","import Util from '../util';\nimport * as Collections from '../utils/collections';\nimport TransportManager from './transport_manager';\nimport TransportConnection from './transport_connection';\nimport Transport from './transport';\nimport PingDelayOptions from './ping_delay_options';\n\n/** Creates transport connections monitored by a transport manager.\n *\n * When a transport is closed, it might mean the environment does not support\n * it. It's possible that messages get stuck in an intermediate buffer or\n * proxies terminate inactive connections. To combat these problems,\n * assistants monitor the connection lifetime, report unclean exits and\n * adjust ping timeouts to keep the connection active. The decision to disable\n * a transport is the manager's responsibility.\n *\n * @param {TransportManager} manager\n * @param {TransportConnection} transport\n * @param {Object} options\n */\nexport default class AssistantToTheTransportManager {\n manager: TransportManager;\n transport: Transport;\n minPingDelay: number;\n maxPingDelay: number;\n pingDelay: number;\n\n constructor(\n manager: TransportManager,\n transport: Transport,\n options: PingDelayOptions\n ) {\n this.manager = manager;\n this.transport = transport;\n this.minPingDelay = options.minPingDelay;\n this.maxPingDelay = options.maxPingDelay;\n this.pingDelay = undefined;\n }\n\n /** Creates a transport connection.\n *\n * This function has the same API as Transport#createConnection.\n *\n * @param {String} name\n * @param {Number} priority\n * @param {String} key the application key\n * @param {Object} options\n * @returns {TransportConnection}\n */\n createConnection(\n name: string,\n priority: number,\n key: string,\n options: Object\n ): TransportConnection {\n options = Collections.extend({}, options, {\n activityTimeout: this.pingDelay\n });\n var connection = this.transport.createConnection(\n name,\n priority,\n key,\n options\n );\n\n var openTimestamp = null;\n\n var onOpen = function() {\n connection.unbind('open', onOpen);\n connection.bind('closed', onClosed);\n openTimestamp = Util.now();\n };\n var onClosed = closeEvent => {\n connection.unbind('closed', onClosed);\n\n if (closeEvent.code === 1002 || closeEvent.code === 1003) {\n // we don't want to use transports not obeying the protocol\n this.manager.reportDeath();\n } else if (!closeEvent.wasClean && openTimestamp) {\n // report deaths only for short-living transport\n var lifespan = Util.now() - openTimestamp;\n if (lifespan < 2 * this.maxPingDelay) {\n this.manager.reportDeath();\n this.pingDelay = Math.max(lifespan / 2, this.minPingDelay);\n }\n }\n };\n\n connection.bind('open', onOpen);\n return connection;\n }\n\n /** Returns whether the transport is supported in the environment.\n *\n * This function has the same API as Transport#isSupported. Might return false\n * when the manager decides to kill the transport.\n *\n * @param {Object} environment the environment details (encryption, settings)\n * @returns {Boolean} true when the transport is supported\n */\n isSupported(environment: string): boolean {\n return this.manager.isAlive() && this.transport.isSupported(environment);\n }\n}\n","import Action from './action';\nimport { PusherEvent } from './message-types';\n/**\n * Provides functions for handling Pusher protocol-specific messages.\n */\n\nconst Protocol = {\n /**\n * Decodes a message in a Pusher format.\n *\n * The MessageEvent we receive from the transport should contain a pusher event\n * (https://pusher.com/docs/pusher_protocol#events) serialized as JSON in the\n * data field\n *\n * The pusher event may contain a data field too, and it may also be\n * serialised as JSON\n *\n * Throws errors when messages are not parse'able.\n *\n * @param {MessageEvent} messageEvent\n * @return {PusherEvent}\n */\n decodeMessage: function(messageEvent: MessageEvent): PusherEvent {\n try {\n var messageData = JSON.parse(messageEvent.data);\n var pusherEventData = messageData.data;\n if (typeof pusherEventData === 'string') {\n try {\n pusherEventData = JSON.parse(messageData.data);\n } catch (e) {}\n }\n var pusherEvent: PusherEvent = {\n event: messageData.event,\n channel: messageData.channel,\n data: pusherEventData\n };\n if (messageData.user_id) {\n pusherEvent.user_id = messageData.user_id;\n }\n return pusherEvent;\n } catch (e) {\n throw { type: 'MessageParseError', error: e, data: messageEvent.data };\n }\n },\n\n /**\n * Encodes a message to be sent.\n *\n * @param {PusherEvent} event\n * @return {String}\n */\n encodeMessage: function(event: PusherEvent): string {\n return JSON.stringify(event);\n },\n\n /**\n * Processes a handshake message and returns appropriate actions.\n *\n * Returns an object with an 'action' and other action-specific properties.\n *\n * There are three outcomes when calling this function. First is a successful\n * connection attempt, when pusher:connection_established is received, which\n * results in a 'connected' action with an 'id' property. When passed a\n * pusher:error event, it returns a result with action appropriate to the\n * close code and an error. Otherwise, it raises an exception.\n *\n * @param {String} message\n * @result Object\n */\n processHandshake: function(messageEvent: MessageEvent): Action {\n var message = Protocol.decodeMessage(messageEvent);\n\n if (message.event === 'pusher:connection_established') {\n if (!message.data.activity_timeout) {\n throw 'No activity timeout specified in handshake';\n }\n return {\n action: 'connected',\n id: message.data.socket_id,\n activityTimeout: message.data.activity_timeout * 1000\n };\n } else if (message.event === 'pusher:error') {\n // From protocol 6 close codes are sent only once, so this only\n // happens when connection does not support close codes\n return {\n action: this.getCloseAction(message.data),\n error: this.getCloseError(message.data)\n };\n } else {\n throw 'Invalid handshake';\n }\n },\n\n /**\n * Dispatches the close event and returns an appropriate action name.\n *\n * See:\n * 1. https://developer.mozilla.org/en-US/docs/WebSockets/WebSockets_reference/CloseEvent\n * 2. http://pusher.com/docs/pusher_protocol\n *\n * @param {CloseEvent} closeEvent\n * @return {String} close action name\n */\n getCloseAction: function(closeEvent): string {\n if (closeEvent.code < 4000) {\n // ignore 1000 CLOSE_NORMAL, 1001 CLOSE_GOING_AWAY,\n // 1005 CLOSE_NO_STATUS, 1006 CLOSE_ABNORMAL\n // ignore 1007...3999\n // handle 1002 CLOSE_PROTOCOL_ERROR, 1003 CLOSE_UNSUPPORTED,\n // 1004 CLOSE_TOO_LARGE\n if (closeEvent.code >= 1002 && closeEvent.code <= 1004) {\n return 'backoff';\n } else {\n return null;\n }\n } else if (closeEvent.code === 4000) {\n return 'tls_only';\n } else if (closeEvent.code < 4100) {\n return 'refused';\n } else if (closeEvent.code < 4200) {\n return 'backoff';\n } else if (closeEvent.code < 4300) {\n return 'retry';\n } else {\n // unknown error\n return 'refused';\n }\n },\n\n /**\n * Returns an error or null basing on the close event.\n *\n * Null is returned when connection was closed cleanly. Otherwise, an object\n * with error details is returned.\n *\n * @param {CloseEvent} closeEvent\n * @return {Object} error object\n */\n getCloseError: function(closeEvent): any {\n if (closeEvent.code !== 1000 && closeEvent.code !== 1001) {\n return {\n type: 'PusherError',\n data: {\n code: closeEvent.code,\n message: closeEvent.reason || closeEvent.message\n }\n };\n } else {\n return null;\n }\n }\n};\n\nexport default Protocol;\n","import * as Collections from '../utils/collections';\nimport { default as EventsDispatcher } from '../events/dispatcher';\nimport Protocol from './protocol/protocol';\nimport { PusherEvent } from './protocol/message-types';\nimport Logger from '../logger';\nimport TransportConnection from '../transports/transport_connection';\nimport Socket from '../socket';\n/**\n * Provides Pusher protocol interface for transports.\n *\n * Emits following events:\n * - message - on received messages\n * - ping - on ping requests\n * - pong - on pong responses\n * - error - when the transport emits an error\n * - closed - after closing the transport\n *\n * It also emits more events when connection closes with a code.\n * See Protocol.getCloseAction to get more details.\n *\n * @param {Number} id\n * @param {AbstractTransport} transport\n */\nexport default class Connection extends EventsDispatcher implements Socket {\n id: string;\n transport: TransportConnection;\n activityTimeout: number;\n\n constructor(id: string, transport: TransportConnection) {\n super();\n this.id = id;\n this.transport = transport;\n this.activityTimeout = transport.activityTimeout;\n this.bindListeners();\n }\n\n /** Returns whether used transport handles activity checks by itself\n *\n * @returns {Boolean} true if activity checks are handled by the transport\n */\n handlesActivityChecks() {\n return this.transport.handlesActivityChecks();\n }\n\n /** Sends raw data.\n *\n * @param {String} data\n */\n send(data: any): boolean {\n return this.transport.send(data);\n }\n\n /** Sends an event.\n *\n * @param {String} name\n * @param {String} data\n * @param {String} [channel]\n * @returns {Boolean} whether message was sent or not\n */\n send_event(name: string, data: any, channel?: string): boolean {\n var event: PusherEvent = { event: name, data: data };\n if (channel) {\n event.channel = channel;\n }\n Logger.debug('Event sent', event);\n return this.send(Protocol.encodeMessage(event));\n }\n\n /** Sends a ping message to the server.\n *\n * Basing on the underlying transport, it might send either transport's\n * protocol-specific ping or pusher:ping event.\n */\n ping() {\n if (this.transport.supportsPing()) {\n this.transport.ping();\n } else {\n this.send_event('pusher:ping', {});\n }\n }\n\n /** Closes the connection. */\n close() {\n this.transport.close();\n }\n\n private bindListeners() {\n var listeners = {\n message: (messageEvent: MessageEvent) => {\n var pusherEvent;\n try {\n pusherEvent = Protocol.decodeMessage(messageEvent);\n } catch (e) {\n this.emit('error', {\n type: 'MessageParseError',\n error: e,\n data: messageEvent.data\n });\n }\n\n if (pusherEvent !== undefined) {\n Logger.debug('Event recd', pusherEvent);\n\n switch (pusherEvent.event) {\n case 'pusher:error':\n this.emit('error', {\n type: 'PusherError',\n data: pusherEvent.data\n });\n break;\n case 'pusher:ping':\n this.emit('ping');\n break;\n case 'pusher:pong':\n this.emit('pong');\n break;\n }\n this.emit('message', pusherEvent);\n }\n },\n activity: () => {\n this.emit('activity');\n },\n error: error => {\n this.emit('error', error);\n },\n closed: closeEvent => {\n unbindListeners();\n\n if (closeEvent && closeEvent.code) {\n this.handleCloseEvent(closeEvent);\n }\n\n this.transport = null;\n this.emit('closed');\n }\n };\n\n var unbindListeners = () => {\n Collections.objectApply(listeners, (listener, event) => {\n this.transport.unbind(event, listener);\n });\n };\n\n Collections.objectApply(listeners, (listener, event) => {\n this.transport.bind(event, listener);\n });\n }\n\n private handleCloseEvent(closeEvent: any) {\n var action = Protocol.getCloseAction(closeEvent);\n var error = Protocol.getCloseError(closeEvent);\n if (error) {\n this.emit('error', error);\n }\n if (action) {\n this.emit(action, { action: action, error: error });\n }\n }\n}\n","import Util from '../../util';\nimport * as Collections from '../../utils/collections';\nimport Protocol from '../protocol/protocol';\nimport Connection from '../connection';\nimport TransportConnection from '../../transports/transport_connection';\nimport HandshakePayload from './handshake_payload';\n\n/**\n * Handles Pusher protocol handshakes for transports.\n *\n * Calls back with a result object after handshake is completed. Results\n * always have two fields:\n * - action - string describing action to be taken after the handshake\n * - transport - the transport object passed to the constructor\n *\n * Different actions can set different additional properties on the result.\n * In the case of 'connected' action, there will be a 'connection' property\n * containing a Connection object for the transport. Other actions should\n * carry an 'error' property.\n *\n * @param {AbstractTransport} transport\n * @param {Function} callback\n */\nexport default class Handshake {\n transport: TransportConnection;\n callback: (HandshakePayload) => void;\n onMessage: Function;\n onClosed: Function;\n\n constructor(\n transport: TransportConnection,\n callback: (HandshakePayload) => void\n ) {\n this.transport = transport;\n this.callback = callback;\n this.bindListeners();\n }\n\n close() {\n this.unbindListeners();\n this.transport.close();\n }\n\n private bindListeners() {\n this.onMessage = m => {\n this.unbindListeners();\n\n var result;\n try {\n result = Protocol.processHandshake(m);\n } catch (e) {\n this.finish('error', { error: e });\n this.transport.close();\n return;\n }\n\n if (result.action === 'connected') {\n this.finish('connected', {\n connection: new Connection(result.id, this.transport),\n activityTimeout: result.activityTimeout\n });\n } else {\n this.finish(result.action, { error: result.error });\n this.transport.close();\n }\n };\n\n this.onClosed = closeEvent => {\n this.unbindListeners();\n\n var action = Protocol.getCloseAction(closeEvent) || 'backoff';\n var error = Protocol.getCloseError(closeEvent);\n this.finish(action, { error: error });\n };\n\n this.transport.bind('message', this.onMessage);\n this.transport.bind('closed', this.onClosed);\n }\n\n private unbindListeners() {\n this.transport.unbind('message', this.onMessage);\n this.transport.unbind('closed', this.onClosed);\n }\n\n private finish(action: string, params: any) {\n this.callback(\n Collections.extend({ transport: this.transport, action: action }, params)\n );\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport base64encode from '../base64';\nimport Timeline from './timeline';\nimport Runtime from 'runtime';\n\nexport interface TimelineSenderOptions {\n host?: string;\n port?: number;\n path?: string;\n}\n\nexport default class TimelineSender {\n timeline: Timeline;\n options: TimelineSenderOptions;\n host: string;\n\n constructor(timeline: Timeline, options: TimelineSenderOptions) {\n this.timeline = timeline;\n this.options = options || {};\n }\n\n send(useTLS: boolean, callback?: Function) {\n if (this.timeline.isEmpty()) {\n return;\n }\n\n this.timeline.send(\n Runtime.TimelineTransport.getAgent(this, useTLS),\n callback\n );\n }\n}\n","/** Error classes used throughout the library. */\n// https://github.com/Microsoft/TypeScript-wiki/blob/master/Breaking-Changes.md#extending-built-ins-like-error-array-and-map-may-no-longer-work\nexport class BadEventName extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\nexport class BadChannelName extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\nexport class RequestTimedOut extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class TransportPriorityTooLow extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class TransportClosed extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class UnsupportedFeature extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class UnsupportedTransport extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class UnsupportedStrategy extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class HTTPAuthError extends Error {\n status: number;\n constructor(status: number, msg?: string) {\n super(msg);\n this.status = status;\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n","/**\n * A place to store help URLs for error messages etc\n */\n\nconst urlStore = {\n baseUrl: 'https://pusher.com',\n urls: {\n authenticationEndpoint: {\n path: '/docs/channels/server_api/authenticating_users'\n },\n authorizationEndpoint: {\n path: '/docs/channels/server_api/authorizing-users/'\n },\n javascriptQuickStart: {\n path: '/docs/javascript_quick_start'\n },\n triggeringClientEvents: {\n path: '/docs/client_api_guide/client_events#trigger-events'\n },\n encryptedChannelSupport: {\n fullUrl:\n 'https://github.com/pusher/pusher-js/tree/cc491015371a4bde5743d1c87a0fbac0feb53195#encrypted-channel-support'\n }\n }\n};\n\n/** Builds a consistent string with links to pusher documentation\n *\n * @param {string} key - relevant key in the url_store.urls object\n * @return {string} suffix string to append to log message\n */\nconst buildLogSuffix = function(key: string): string {\n const urlPrefix = 'See:';\n const urlObj = urlStore.urls[key];\n if (!urlObj) return '';\n\n let url;\n if (urlObj.fullUrl) {\n url = urlObj.fullUrl;\n } else if (urlObj.path) {\n url = urlStore.baseUrl + urlObj.path;\n }\n\n if (!url) return '';\n return `${urlPrefix} ${url}`;\n};\n\nexport default { buildLogSuffix };\n","import { default as EventsDispatcher } from '../events/dispatcher';\nimport * as Errors from '../errors';\nimport Logger from '../logger';\nimport Pusher from '../pusher';\nimport { PusherEvent } from '../connection/protocol/message-types';\nimport Metadata from './metadata';\nimport UrlStore from '../utils/url_store';\nimport {\n ChannelAuthorizationData,\n ChannelAuthorizationCallback\n} from '../auth/options';\nimport { HTTPAuthError } from '../errors';\n\n/** Provides base public channel interface with an event emitter.\n *\n * Emits:\n * - pusher:subscription_succeeded - after subscribing successfully\n * - other non-internal events\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\nexport default class Channel extends EventsDispatcher {\n name: string;\n pusher: Pusher;\n subscribed: boolean;\n subscriptionPending: boolean;\n subscriptionCancelled: boolean;\n subscriptionCount: null;\n\n constructor(name: string, pusher: Pusher) {\n super(function(event, data) {\n Logger.debug('No callbacks on ' + name + ' for ' + event);\n });\n\n this.name = name;\n this.pusher = pusher;\n this.subscribed = false;\n this.subscriptionPending = false;\n this.subscriptionCancelled = false;\n }\n\n /** Skips authorization, since public channels don't require it.\n *\n * @param {Function} callback\n */\n authorize(socketId: string, callback: ChannelAuthorizationCallback) {\n return callback(null, { auth: '' });\n }\n\n /** Triggers an event */\n trigger(event: string, data: any) {\n if (event.indexOf('client-') !== 0) {\n throw new Errors.BadEventName(\n \"Event '\" + event + \"' does not start with 'client-'\"\n );\n }\n if (!this.subscribed) {\n var suffix = UrlStore.buildLogSuffix('triggeringClientEvents');\n Logger.warn(\n `Client event triggered before channel 'subscription_succeeded' event . ${suffix}`\n );\n }\n return this.pusher.send_event(event, data, this.name);\n }\n\n /** Signals disconnection to the channel. For internal use only. */\n disconnect() {\n this.subscribed = false;\n this.subscriptionPending = false;\n }\n\n /** Handles a PusherEvent. For internal use only.\n *\n * @param {PusherEvent} event\n */\n handleEvent(event: PusherEvent) {\n var eventName = event.event;\n var data = event.data;\n if (eventName === 'pusher_internal:subscription_succeeded') {\n this.handleSubscriptionSucceededEvent(event);\n } else if (eventName === 'pusher_internal:subscription_count') {\n this.handleSubscriptionCountEvent(event);\n } else if (eventName.indexOf('pusher_internal:') !== 0) {\n var metadata: Metadata = {};\n this.emit(eventName, data, metadata);\n }\n }\n\n handleSubscriptionSucceededEvent(event: PusherEvent) {\n this.subscriptionPending = false;\n this.subscribed = true;\n if (this.subscriptionCancelled) {\n this.pusher.unsubscribe(this.name);\n } else {\n this.emit('pusher:subscription_succeeded', event.data);\n }\n }\n\n handleSubscriptionCountEvent(event: PusherEvent) {\n if (event.data.subscription_count) {\n this.subscriptionCount = event.data.subscription_count;\n }\n\n this.emit('pusher:subscription_count', event.data);\n }\n\n /** Sends a subscription request. For internal use only. */\n subscribe() {\n if (this.subscribed) {\n return;\n }\n this.subscriptionPending = true;\n this.subscriptionCancelled = false;\n this.authorize(\n this.pusher.connection.socket_id,\n (error: Error | null, data: ChannelAuthorizationData) => {\n if (error) {\n this.subscriptionPending = false;\n // Why not bind to 'pusher:subscription_error' a level up, and log there?\n // Binding to this event would cause the warning about no callbacks being\n // bound (see constructor) to be suppressed, that's not what we want.\n Logger.error(error.toString());\n this.emit(\n 'pusher:subscription_error',\n Object.assign(\n {},\n {\n type: 'AuthError',\n error: error.message\n },\n error instanceof HTTPAuthError ? { status: error.status } : {}\n )\n );\n } else {\n this.pusher.send_event('pusher:subscribe', {\n auth: data.auth,\n channel_data: data.channel_data,\n channel: this.name\n });\n }\n }\n );\n }\n\n /** Sends an unsubscription request. For internal use only. */\n unsubscribe() {\n this.subscribed = false;\n this.pusher.send_event('pusher:unsubscribe', {\n channel: this.name\n });\n }\n\n /** Cancels an in progress subscription. For internal use only. */\n cancelSubscription() {\n this.subscriptionCancelled = true;\n }\n\n /** Reinstates an in progress subscripiton. For internal use only. */\n reinstateSubscription() {\n this.subscriptionCancelled = false;\n }\n}\n","import Factory from '../utils/factory';\nimport Channel from './channel';\nimport { ChannelAuthorizationCallback } from '../auth/options';\n\n/** Extends public channels to provide private channel interface.\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\nexport default class PrivateChannel extends Channel {\n /** Authorizes the connection to use the channel.\n *\n * @param {String} socketId\n * @param {Function} callback\n */\n authorize(socketId: string, callback: ChannelAuthorizationCallback) {\n return this.pusher.config.channelAuthorizer(\n {\n channelName: this.name,\n socketId: socketId\n },\n callback\n );\n }\n}\n","import * as Collections from '../utils/collections';\n\n/** Represents a collection of members of a presence channel. */\nexport default class Members {\n members: any;\n count: number;\n myID: any;\n me: any;\n\n constructor() {\n this.reset();\n }\n\n /** Returns member's info for given id.\n *\n * Resulting object containts two fields - id and info.\n *\n * @param {Number} id\n * @return {Object} member's info or null\n */\n get(id: string): any {\n if (Object.prototype.hasOwnProperty.call(this.members, id)) {\n return {\n id: id,\n info: this.members[id]\n };\n } else {\n return null;\n }\n }\n\n /** Calls back for each member in unspecified order.\n *\n * @param {Function} callback\n */\n each(callback: Function) {\n Collections.objectApply(this.members, (member, id) => {\n callback(this.get(id));\n });\n }\n\n /** Updates the id for connected member. For internal use only. */\n setMyID(id: string) {\n this.myID = id;\n }\n\n /** Handles subscription data. For internal use only. */\n onSubscription(subscriptionData: any) {\n this.members = subscriptionData.presence.hash;\n this.count = subscriptionData.presence.count;\n this.me = this.get(this.myID);\n }\n\n /** Adds a new member to the collection. For internal use only. */\n addMember(memberData: any) {\n if (this.get(memberData.user_id) === null) {\n this.count++;\n }\n this.members[memberData.user_id] = memberData.user_info;\n return this.get(memberData.user_id);\n }\n\n /** Adds a member from the collection. For internal use only. */\n removeMember(memberData: any) {\n var member = this.get(memberData.user_id);\n if (member) {\n delete this.members[memberData.user_id];\n this.count--;\n }\n return member;\n }\n\n /** Resets the collection to the initial state. For internal use only. */\n reset() {\n this.members = {};\n this.count = 0;\n this.myID = null;\n this.me = null;\n }\n}\n","import PrivateChannel from './private_channel';\nimport Logger from '../logger';\nimport Members from './members';\nimport Pusher from '../pusher';\nimport UrlStore from 'core/utils/url_store';\nimport { PusherEvent } from '../connection/protocol/message-types';\nimport Metadata from './metadata';\nimport { ChannelAuthorizationData } from '../auth/options';\n\nexport default class PresenceChannel extends PrivateChannel {\n members: Members;\n\n /** Adds presence channel functionality to private channels.\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\n constructor(name: string, pusher: Pusher) {\n super(name, pusher);\n this.members = new Members();\n }\n\n /** Authorizes the connection as a member of the channel.\n *\n * @param {String} socketId\n * @param {Function} callback\n */\n authorize(socketId: string, callback: Function) {\n super.authorize(socketId, async (error, authData) => {\n if (!error) {\n authData = authData as ChannelAuthorizationData;\n if (authData.channel_data != null) {\n var channelData = JSON.parse(authData.channel_data);\n this.members.setMyID(channelData.user_id);\n } else {\n await this.pusher.user.signinDonePromise;\n if (this.pusher.user.user_data != null) {\n // If the user is signed in, get the id of the authenticated user\n // and allow the presence authorization to continue.\n this.members.setMyID(this.pusher.user.user_data.id);\n } else {\n let suffix = UrlStore.buildLogSuffix('authorizationEndpoint');\n Logger.error(\n `Invalid auth response for channel '${this.name}', ` +\n `expected 'channel_data' field. ${suffix}, ` +\n `or the user should be signed in.`\n );\n callback('Invalid auth response');\n return;\n }\n }\n }\n callback(error, authData);\n });\n }\n\n /** Handles presence and subscription events. For internal use only.\n *\n * @param {PusherEvent} event\n */\n handleEvent(event: PusherEvent) {\n var eventName = event.event;\n if (eventName.indexOf('pusher_internal:') === 0) {\n this.handleInternalEvent(event);\n } else {\n var data = event.data;\n var metadata: Metadata = {};\n if (event.user_id) {\n metadata.user_id = event.user_id;\n }\n this.emit(eventName, data, metadata);\n }\n }\n handleInternalEvent(event: PusherEvent) {\n var eventName = event.event;\n var data = event.data;\n switch (eventName) {\n case 'pusher_internal:subscription_succeeded':\n this.handleSubscriptionSucceededEvent(event);\n break;\n case 'pusher_internal:subscription_count':\n this.handleSubscriptionCountEvent(event);\n break;\n case 'pusher_internal:member_added':\n var addedMember = this.members.addMember(data);\n this.emit('pusher:member_added', addedMember);\n break;\n case 'pusher_internal:member_removed':\n var removedMember = this.members.removeMember(data);\n if (removedMember) {\n this.emit('pusher:member_removed', removedMember);\n }\n break;\n }\n }\n\n handleSubscriptionSucceededEvent(event: PusherEvent) {\n this.subscriptionPending = false;\n this.subscribed = true;\n if (this.subscriptionCancelled) {\n this.pusher.unsubscribe(this.name);\n } else {\n this.members.onSubscription(event.data);\n this.emit('pusher:subscription_succeeded', this.members);\n }\n }\n\n /** Resets the channel state, including members map. For internal use only. */\n disconnect() {\n this.members.reset();\n super.disconnect();\n }\n}\n","import PrivateChannel from './private_channel';\nimport * as Errors from '../errors';\nimport Logger from '../logger';\nimport Pusher from '../pusher';\nimport { decode as encodeUTF8 } from '@stablelib/utf8';\nimport { decode as decodeBase64 } from '@stablelib/base64';\nimport Dispatcher from '../events/dispatcher';\nimport { PusherEvent } from '../connection/protocol/message-types';\nimport {\n ChannelAuthorizationData,\n ChannelAuthorizationCallback\n} from '../auth/options';\nimport * as nacl from 'tweetnacl';\n\n/** Extends private channels to provide encrypted channel interface.\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\nexport default class EncryptedChannel extends PrivateChannel {\n key: Uint8Array = null;\n nacl: nacl;\n\n constructor(name: string, pusher: Pusher, nacl: nacl) {\n super(name, pusher);\n this.nacl = nacl;\n }\n\n /** Authorizes the connection to use the channel.\n *\n * @param {String} socketId\n * @param {Function} callback\n */\n authorize(socketId: string, callback: ChannelAuthorizationCallback) {\n super.authorize(\n socketId,\n (error: Error | null, authData: ChannelAuthorizationData) => {\n if (error) {\n callback(error, authData);\n return;\n }\n let sharedSecret = authData['shared_secret'];\n if (!sharedSecret) {\n callback(\n new Error(\n `No shared_secret key in auth payload for encrypted channel: ${this.name}`\n ),\n null\n );\n return;\n }\n this.key = decodeBase64(sharedSecret);\n delete authData['shared_secret'];\n callback(null, authData);\n }\n );\n }\n\n trigger(event: string, data: any): boolean {\n throw new Errors.UnsupportedFeature(\n 'Client events are not currently supported for encrypted channels'\n );\n }\n\n /** Handles an event. For internal use only.\n *\n * @param {PusherEvent} event\n */\n handleEvent(event: PusherEvent) {\n var eventName = event.event;\n var data = event.data;\n if (\n eventName.indexOf('pusher_internal:') === 0 ||\n eventName.indexOf('pusher:') === 0\n ) {\n super.handleEvent(event);\n return;\n }\n this.handleEncryptedEvent(eventName, data);\n }\n\n private handleEncryptedEvent(event: string, data: any): void {\n if (!this.key) {\n Logger.debug(\n 'Received encrypted event before key has been retrieved from the authEndpoint'\n );\n return;\n }\n if (!data.ciphertext || !data.nonce) {\n Logger.error(\n 'Unexpected format for encrypted event, expected object with `ciphertext` and `nonce` fields, got: ' +\n data\n );\n return;\n }\n let cipherText = decodeBase64(data.ciphertext);\n if (cipherText.length < this.nacl.secretbox.overheadLength) {\n Logger.error(\n `Expected encrypted event ciphertext length to be ${this.nacl.secretbox.overheadLength}, got: ${cipherText.length}`\n );\n return;\n }\n let nonce = decodeBase64(data.nonce);\n if (nonce.length < this.nacl.secretbox.nonceLength) {\n Logger.error(\n `Expected encrypted event nonce length to be ${this.nacl.secretbox.nonceLength}, got: ${nonce.length}`\n );\n return;\n }\n\n let bytes = this.nacl.secretbox.open(cipherText, nonce, this.key);\n if (bytes === null) {\n Logger.debug(\n 'Failed to decrypt an event, probably because it was encrypted with a different key. Fetching a new key from the authEndpoint...'\n );\n // Try a single time to retrieve a new auth key and decrypt the event with it\n // If this fails, a new key will be requested when a new message is received\n this.authorize(this.pusher.connection.socket_id, (error, authData) => {\n if (error) {\n Logger.error(\n `Failed to make a request to the authEndpoint: ${authData}. Unable to fetch new key, so dropping encrypted event`\n );\n return;\n }\n bytes = this.nacl.secretbox.open(cipherText, nonce, this.key);\n if (bytes === null) {\n Logger.error(\n `Failed to decrypt event with new key. Dropping encrypted event`\n );\n return;\n }\n this.emit(event, this.getDataToEmit(bytes));\n return;\n });\n return;\n }\n this.emit(event, this.getDataToEmit(bytes));\n }\n\n // Try and parse the decrypted bytes as JSON. If we can't parse it, just\n // return the utf-8 string\n getDataToEmit(bytes: Uint8Array): string {\n let raw = encodeUTF8(bytes);\n try {\n return JSON.parse(raw);\n } catch {\n return raw;\n }\n }\n}\n","import { default as EventsDispatcher } from '../events/dispatcher';\nimport { OneOffTimer as Timer } from '../utils/timers';\nimport { Config } from '../config';\nimport Logger from '../logger';\nimport HandshakePayload from './handshake/handshake_payload';\nimport Connection from './connection';\nimport Strategy from '../strategies/strategy';\nimport StrategyRunner from '../strategies/strategy_runner';\nimport * as Collections from '../utils/collections';\nimport Timeline from '../timeline/timeline';\nimport ConnectionManagerOptions from './connection_manager_options';\nimport Runtime from 'runtime';\n\nimport {\n ErrorCallbacks,\n HandshakeCallbacks,\n ConnectionCallbacks\n} from './callbacks';\nimport Action from './protocol/action';\n\n/** Manages connection to Pusher.\n *\n * Uses a strategy (currently only default), timers and network availability\n * info to establish a connection and export its state. In case of failures,\n * manages reconnection attempts.\n *\n * Exports state changes as following events:\n * - \"state_change\", { previous: p, current: state }\n * - state\n *\n * States:\n * - initialized - initial state, never transitioned to\n * - connecting - connection is being established\n * - connected - connection has been fully established\n * - disconnected - on requested disconnection\n * - unavailable - after connection timeout or when there's no network\n * - failed - when the connection strategy is not supported\n *\n * Options:\n * - unavailableTimeout - time to transition to unavailable state\n * - activityTimeout - time after which ping message should be sent\n * - pongTimeout - time for Pusher to respond with pong before reconnecting\n *\n * @param {String} key application key\n * @param {Object} options\n */\nexport default class ConnectionManager extends EventsDispatcher {\n key: string;\n options: ConnectionManagerOptions;\n state: string;\n connection: Connection;\n usingTLS: boolean;\n timeline: Timeline;\n socket_id: string;\n unavailableTimer: Timer;\n activityTimer: Timer;\n retryTimer: Timer;\n activityTimeout: number;\n strategy: Strategy;\n runner: StrategyRunner;\n errorCallbacks: ErrorCallbacks;\n handshakeCallbacks: HandshakeCallbacks;\n connectionCallbacks: ConnectionCallbacks;\n\n constructor(key: string, options: ConnectionManagerOptions) {\n super();\n this.state = 'initialized';\n this.connection = null;\n\n this.key = key;\n this.options = options;\n this.timeline = this.options.timeline;\n this.usingTLS = this.options.useTLS;\n\n this.errorCallbacks = this.buildErrorCallbacks();\n this.connectionCallbacks = this.buildConnectionCallbacks(\n this.errorCallbacks\n );\n this.handshakeCallbacks = this.buildHandshakeCallbacks(this.errorCallbacks);\n\n var Network = Runtime.getNetwork();\n\n Network.bind('online', () => {\n this.timeline.info({ netinfo: 'online' });\n if (this.state === 'connecting' || this.state === 'unavailable') {\n this.retryIn(0);\n }\n });\n Network.bind('offline', () => {\n this.timeline.info({ netinfo: 'offline' });\n if (this.connection) {\n this.sendActivityCheck();\n }\n });\n\n this.updateStrategy();\n }\n\n switchCluster(key: string) {\n this.key = key;\n // This ensures that the new config coming from\n // pusher instance are taken into account\n // such as appKey and cluster\n this.updateStrategy();\n this.retryIn(0);\n }\n\n /** Establishes a connection to Pusher.\n *\n * Does nothing when connection is already established. See top-level doc\n * to find events emitted on connection attempts.\n */\n connect() {\n if (this.connection || this.runner) {\n return;\n }\n if (!this.strategy.isSupported()) {\n this.updateState('failed');\n return;\n }\n this.updateState('connecting');\n this.startConnecting();\n this.setUnavailableTimer();\n }\n\n /** Sends raw data.\n *\n * @param {String} data\n */\n send(data) {\n if (this.connection) {\n return this.connection.send(data);\n } else {\n return false;\n }\n }\n\n /** Sends an event.\n *\n * @param {String} name\n * @param {String} data\n * @param {String} [channel]\n * @returns {Boolean} whether message was sent or not\n */\n send_event(name: string, data: any, channel?: string) {\n if (this.connection) {\n return this.connection.send_event(name, data, channel);\n } else {\n return false;\n }\n }\n\n /** Closes the connection. */\n disconnect() {\n this.disconnectInternally();\n this.updateState('disconnected');\n }\n\n isUsingTLS() {\n return this.usingTLS;\n }\n\n private startConnecting() {\n var callback = (error, handshake) => {\n if (error) {\n this.runner = this.strategy.connect(0, callback);\n } else {\n if (handshake.action === 'error') {\n this.emit('error', {\n type: 'HandshakeError',\n error: handshake.error\n });\n this.timeline.error({ handshakeError: handshake.error });\n } else {\n this.abortConnecting(); // we don't support switching connections yet\n this.handshakeCallbacks[handshake.action](handshake);\n }\n }\n };\n this.runner = this.strategy.connect(0, callback);\n }\n\n private abortConnecting() {\n if (this.runner) {\n this.runner.abort();\n this.runner = null;\n }\n }\n\n private disconnectInternally() {\n this.abortConnecting();\n this.clearRetryTimer();\n this.clearUnavailableTimer();\n if (this.connection) {\n var connection = this.abandonConnection();\n connection.close();\n }\n }\n\n private updateStrategy() {\n this.strategy = this.options.getStrategy({\n key: this.key,\n timeline: this.timeline,\n useTLS: this.usingTLS\n });\n }\n\n private retryIn(delay) {\n this.timeline.info({ action: 'retry', delay: delay });\n if (delay > 0) {\n this.emit('connecting_in', Math.round(delay / 1000));\n }\n this.retryTimer = new Timer(delay || 0, () => {\n this.disconnectInternally();\n this.connect();\n });\n }\n\n private clearRetryTimer() {\n if (this.retryTimer) {\n this.retryTimer.ensureAborted();\n this.retryTimer = null;\n }\n }\n\n private setUnavailableTimer() {\n this.unavailableTimer = new Timer(this.options.unavailableTimeout, () => {\n this.updateState('unavailable');\n });\n }\n\n private clearUnavailableTimer() {\n if (this.unavailableTimer) {\n this.unavailableTimer.ensureAborted();\n }\n }\n\n private sendActivityCheck() {\n this.stopActivityCheck();\n this.connection.ping();\n // wait for pong response\n this.activityTimer = new Timer(this.options.pongTimeout, () => {\n this.timeline.error({ pong_timed_out: this.options.pongTimeout });\n this.retryIn(0);\n });\n }\n\n private resetActivityCheck() {\n this.stopActivityCheck();\n // send ping after inactivity\n if (this.connection && !this.connection.handlesActivityChecks()) {\n this.activityTimer = new Timer(this.activityTimeout, () => {\n this.sendActivityCheck();\n });\n }\n }\n\n private stopActivityCheck() {\n if (this.activityTimer) {\n this.activityTimer.ensureAborted();\n }\n }\n\n private buildConnectionCallbacks(\n errorCallbacks: ErrorCallbacks\n ): ConnectionCallbacks {\n return Collections.extend({}, errorCallbacks, {\n message: message => {\n // includes pong messages from server\n this.resetActivityCheck();\n this.emit('message', message);\n },\n ping: () => {\n this.send_event('pusher:pong', {});\n },\n activity: () => {\n this.resetActivityCheck();\n },\n error: error => {\n // just emit error to user - socket will already be closed by browser\n this.emit('error', error);\n },\n closed: () => {\n this.abandonConnection();\n if (this.shouldRetry()) {\n this.retryIn(1000);\n }\n }\n });\n }\n\n private buildHandshakeCallbacks(\n errorCallbacks: ErrorCallbacks\n ): HandshakeCallbacks {\n return Collections.extend({}, errorCallbacks, {\n connected: (handshake: HandshakePayload) => {\n this.activityTimeout = Math.min(\n this.options.activityTimeout,\n handshake.activityTimeout,\n handshake.connection.activityTimeout || Infinity\n );\n this.clearUnavailableTimer();\n this.setConnection(handshake.connection);\n this.socket_id = this.connection.id;\n this.updateState('connected', { socket_id: this.socket_id });\n }\n });\n }\n\n private buildErrorCallbacks(): ErrorCallbacks {\n let withErrorEmitted = callback => {\n return (result: Action | HandshakePayload) => {\n if (result.error) {\n this.emit('error', { type: 'WebSocketError', error: result.error });\n }\n callback(result);\n };\n };\n\n return {\n tls_only: withErrorEmitted(() => {\n this.usingTLS = true;\n this.updateStrategy();\n this.retryIn(0);\n }),\n refused: withErrorEmitted(() => {\n this.disconnect();\n }),\n backoff: withErrorEmitted(() => {\n this.retryIn(1000);\n }),\n retry: withErrorEmitted(() => {\n this.retryIn(0);\n })\n };\n }\n\n private setConnection(connection) {\n this.connection = connection;\n for (var event in this.connectionCallbacks) {\n this.connection.bind(event, this.connectionCallbacks[event]);\n }\n this.resetActivityCheck();\n }\n\n private abandonConnection() {\n if (!this.connection) {\n return;\n }\n this.stopActivityCheck();\n for (var event in this.connectionCallbacks) {\n this.connection.unbind(event, this.connectionCallbacks[event]);\n }\n var connection = this.connection;\n this.connection = null;\n return connection;\n }\n\n private updateState(newState: string, data?: any) {\n var previousState = this.state;\n this.state = newState;\n if (previousState !== newState) {\n var newStateDescription = newState;\n if (newStateDescription === 'connected') {\n newStateDescription += ' with new socket ID ' + data.socket_id;\n }\n Logger.debug(\n 'State changed',\n previousState + ' -> ' + newStateDescription\n );\n this.timeline.info({ state: newState, params: data });\n this.emit('state_change', { previous: previousState, current: newState });\n this.emit(newState, data);\n }\n }\n\n private shouldRetry(): boolean {\n return this.state === 'connecting' || this.state === 'connected';\n }\n}\n","import Channel from './channel';\nimport * as Collections from '../utils/collections';\nimport ChannelTable from './channel_table';\nimport Factory from '../utils/factory';\nimport Pusher from '../pusher';\nimport Logger from '../logger';\nimport * as Errors from '../errors';\nimport urlStore from '../utils/url_store';\n\n/** Handles a channel map. */\nexport default class Channels {\n channels: ChannelTable;\n\n constructor() {\n this.channels = {};\n }\n\n /** Creates or retrieves an existing channel by its name.\n *\n * @param {String} name\n * @param {Pusher} pusher\n * @return {Channel}\n */\n add(name: string, pusher: Pusher) {\n if (!this.channels[name]) {\n this.channels[name] = createChannel(name, pusher);\n }\n return this.channels[name];\n }\n\n /** Returns a list of all channels\n *\n * @return {Array}\n */\n all(): Channel[] {\n return Collections.values(this.channels);\n }\n\n /** Finds a channel by its name.\n *\n * @param {String} name\n * @return {Channel} channel or null if it doesn't exist\n */\n find(name: string) {\n return this.channels[name];\n }\n\n /** Removes a channel from the map.\n *\n * @param {String} name\n */\n remove(name: string) {\n var channel = this.channels[name];\n delete this.channels[name];\n return channel;\n }\n\n /** Proxies disconnection signal to all channels. */\n disconnect() {\n Collections.objectApply(this.channels, function(channel) {\n channel.disconnect();\n });\n }\n}\n\nfunction createChannel(name: string, pusher: Pusher): Channel {\n if (name.indexOf('private-encrypted-') === 0) {\n if (pusher.config.nacl) {\n return Factory.createEncryptedChannel(name, pusher, pusher.config.nacl);\n }\n let errMsg =\n 'Tried to subscribe to a private-encrypted- channel but no nacl implementation available';\n let suffix = urlStore.buildLogSuffix('encryptedChannelSupport');\n throw new Errors.UnsupportedFeature(`${errMsg}. ${suffix}`);\n } else if (name.indexOf('private-') === 0) {\n return Factory.createPrivateChannel(name, pusher);\n } else if (name.indexOf('presence-') === 0) {\n return Factory.createPresenceChannel(name, pusher);\n } else if (name.indexOf('#') === 0) {\n throw new Errors.BadChannelName(\n 'Cannot create a channel with name \"' + name + '\".'\n );\n } else {\n return Factory.createChannel(name, pusher);\n }\n}\n","import AssistantToTheTransportManager from '../transports/assistant_to_the_transport_manager';\nimport PingDelayOptions from '../transports/ping_delay_options';\nimport Transport from '../transports/transport';\nimport TransportManager from '../transports/transport_manager';\nimport Handshake from '../connection/handshake';\nimport TransportConnection from '../transports/transport_connection';\nimport SocketHooks from '../http/socket_hooks';\nimport HTTPSocket from '../http/http_socket';\n\nimport Timeline from '../timeline/timeline';\nimport {\n default as TimelineSender,\n TimelineSenderOptions\n} from '../timeline/timeline_sender';\nimport PresenceChannel from '../channels/presence_channel';\nimport PrivateChannel from '../channels/private_channel';\nimport EncryptedChannel from '../channels/encrypted_channel';\nimport Channel from '../channels/channel';\nimport ConnectionManager from '../connection/connection_manager';\nimport ConnectionManagerOptions from '../connection/connection_manager_options';\nimport Ajax from '../http/ajax';\nimport Channels from '../channels/channels';\nimport Pusher from '../pusher';\nimport { Config } from '../config';\nimport * as nacl from 'tweetnacl';\n\nvar Factory = {\n createChannels(): Channels {\n return new Channels();\n },\n\n createConnectionManager(\n key: string,\n options: ConnectionManagerOptions\n ): ConnectionManager {\n return new ConnectionManager(key, options);\n },\n\n createChannel(name: string, pusher: Pusher): Channel {\n return new Channel(name, pusher);\n },\n\n createPrivateChannel(name: string, pusher: Pusher): PrivateChannel {\n return new PrivateChannel(name, pusher);\n },\n\n createPresenceChannel(name: string, pusher: Pusher): PresenceChannel {\n return new PresenceChannel(name, pusher);\n },\n\n createEncryptedChannel(\n name: string,\n pusher: Pusher,\n nacl: nacl\n ): EncryptedChannel {\n return new EncryptedChannel(name, pusher, nacl);\n },\n\n createTimelineSender(timeline: Timeline, options: TimelineSenderOptions) {\n return new TimelineSender(timeline, options);\n },\n\n createHandshake(\n transport: TransportConnection,\n callback: (HandshakePayload) => void\n ): Handshake {\n return new Handshake(transport, callback);\n },\n\n createAssistantToTheTransportManager(\n manager: TransportManager,\n transport: Transport,\n options: PingDelayOptions\n ): AssistantToTheTransportManager {\n return new AssistantToTheTransportManager(manager, transport, options);\n }\n};\n\nexport default Factory;\n","import AssistantToTheTransportManager from './assistant_to_the_transport_manager';\nimport Transport from './transport';\nimport PingDelayOptions from './ping_delay_options';\nimport Factory from '../utils/factory';\n\nexport interface TransportManagerOptions extends PingDelayOptions {\n lives?: number;\n}\n\n/** Keeps track of the number of lives left for a transport.\n *\n * In the beginning of a session, transports may be assigned a number of\n * lives. When an AssistantToTheTransportManager instance reports a transport\n * connection closed uncleanly, the transport loses a life. When the number\n * of lives drops to zero, the transport gets disabled by its manager.\n *\n * @param {Object} options\n */\nexport default class TransportManager {\n options: TransportManagerOptions;\n livesLeft: number;\n\n constructor(options: TransportManagerOptions) {\n this.options = options || {};\n this.livesLeft = this.options.lives || Infinity;\n }\n\n /** Creates a assistant for the transport.\n *\n * @param {Transport} transport\n * @returns {AssistantToTheTransportManager}\n */\n getAssistant(transport: Transport): AssistantToTheTransportManager {\n return Factory.createAssistantToTheTransportManager(this, transport, {\n minPingDelay: this.options.minPingDelay,\n maxPingDelay: this.options.maxPingDelay\n });\n }\n\n /** Returns whether the transport has any lives left.\n *\n * @returns {Boolean}\n */\n isAlive(): boolean {\n return this.livesLeft > 0;\n }\n\n /** Takes one life from the transport. */\n reportDeath() {\n this.livesLeft -= 1;\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport { OneOffTimer as Timer } from '../utils/timers';\nimport Strategy from './strategy';\nimport StrategyOptions from './strategy_options';\n\n/** Loops through strategies with optional timeouts.\n *\n * Options:\n * - loop - whether it should loop through the substrategy list\n * - timeout - initial timeout for a single substrategy\n * - timeoutLimit - maximum timeout\n *\n * @param {Strategy[]} strategies\n * @param {Object} options\n */\nexport default class SequentialStrategy implements Strategy {\n strategies: Strategy[];\n loop: boolean;\n failFast: boolean;\n timeout: number;\n timeoutLimit: number;\n\n constructor(strategies: Strategy[], options: StrategyOptions) {\n this.strategies = strategies;\n this.loop = Boolean(options.loop);\n this.failFast = Boolean(options.failFast);\n this.timeout = options.timeout;\n this.timeoutLimit = options.timeoutLimit;\n }\n\n isSupported(): boolean {\n return Collections.any(this.strategies, Util.method('isSupported'));\n }\n\n connect(minPriority: number, callback: Function) {\n var strategies = this.strategies;\n var current = 0;\n var timeout = this.timeout;\n var runner = null;\n\n var tryNextStrategy = (error, handshake) => {\n if (handshake) {\n callback(null, handshake);\n } else {\n current = current + 1;\n if (this.loop) {\n current = current % strategies.length;\n }\n\n if (current < strategies.length) {\n if (timeout) {\n timeout = timeout * 2;\n if (this.timeoutLimit) {\n timeout = Math.min(timeout, this.timeoutLimit);\n }\n }\n runner = this.tryStrategy(\n strategies[current],\n minPriority,\n { timeout, failFast: this.failFast },\n tryNextStrategy\n );\n } else {\n callback(true);\n }\n }\n };\n\n runner = this.tryStrategy(\n strategies[current],\n minPriority,\n { timeout: timeout, failFast: this.failFast },\n tryNextStrategy\n );\n\n return {\n abort: function() {\n runner.abort();\n },\n forceMinPriority: function(p) {\n minPriority = p;\n if (runner) {\n runner.forceMinPriority(p);\n }\n }\n };\n }\n\n private tryStrategy(\n strategy: Strategy,\n minPriority: number,\n options: StrategyOptions,\n callback: Function\n ) {\n var timer = null;\n var runner = null;\n\n if (options.timeout > 0) {\n timer = new Timer(options.timeout, function() {\n runner.abort();\n callback(true);\n });\n }\n\n runner = strategy.connect(minPriority, function(error, handshake) {\n if (error && timer && timer.isRunning() && !options.failFast) {\n // advance to the next strategy after the timeout\n return;\n }\n if (timer) {\n timer.ensureAborted();\n }\n callback(error, handshake);\n });\n\n return {\n abort: function() {\n if (timer) {\n timer.ensureAborted();\n }\n runner.abort();\n },\n forceMinPriority: function(p) {\n runner.forceMinPriority(p);\n }\n };\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport Strategy from './strategy';\n\n/** Launches all substrategies and emits prioritized connected transports.\n *\n * @param {Array} strategies\n */\nexport default class BestConnectedEverStrategy implements Strategy {\n strategies: Strategy[];\n\n constructor(strategies: Strategy[]) {\n this.strategies = strategies;\n }\n\n isSupported(): boolean {\n return Collections.any(this.strategies, Util.method('isSupported'));\n }\n\n connect(minPriority: number, callback: Function) {\n return connect(this.strategies, minPriority, function(i, runners) {\n return function(error, handshake) {\n runners[i].error = error;\n if (error) {\n if (allRunnersFailed(runners)) {\n callback(true);\n }\n return;\n }\n Collections.apply(runners, function(runner) {\n runner.forceMinPriority(handshake.transport.priority);\n });\n callback(null, handshake);\n };\n });\n }\n}\n\n/** Connects to all strategies in parallel.\n *\n * Callback builder should be a function that takes two arguments: index\n * and a list of runners. It should return another function that will be\n * passed to the substrategy with given index. Runners can be aborted using\n * abortRunner(s) functions from this class.\n *\n * @param {Array} strategies\n * @param {Function} callbackBuilder\n * @return {Object} strategy runner\n */\nfunction connect(\n strategies: Strategy[],\n minPriority: number,\n callbackBuilder: Function\n) {\n var runners = Collections.map(strategies, function(strategy, i, _, rs) {\n return strategy.connect(minPriority, callbackBuilder(i, rs));\n });\n return {\n abort: function() {\n Collections.apply(runners, abortRunner);\n },\n forceMinPriority: function(p) {\n Collections.apply(runners, function(runner) {\n runner.forceMinPriority(p);\n });\n }\n };\n}\n\nfunction allRunnersFailed(runners): boolean {\n return Collections.all(runners, function(runner) {\n return Boolean(runner.error);\n });\n}\n\nfunction abortRunner(runner) {\n if (!runner.error && !runner.aborted) {\n runner.abort();\n runner.aborted = true;\n }\n}\n","import Util from '../util';\nimport Runtime from 'runtime';\nimport Strategy from './strategy';\nimport SequentialStrategy from './sequential_strategy';\nimport StrategyOptions from './strategy_options';\nimport TransportStrategy from './transport_strategy';\nimport Timeline from '../timeline/timeline';\nimport * as Collections from '../utils/collections';\n\nexport interface TransportStrategyDictionary {\n [key: string]: TransportStrategy;\n}\n\n/** Caches the last successful transport and, after the first few attempts,\n * uses the cached transport for subsequent attempts.\n *\n * @param {Strategy} strategy\n * @param {Object} transports\n * @param {Object} options\n */\nexport default class WebSocketPrioritizedCachedStrategy implements Strategy {\n strategy: Strategy;\n transports: TransportStrategyDictionary;\n ttl: number;\n usingTLS: boolean;\n timeline: Timeline;\n\n constructor(\n strategy: Strategy,\n transports: TransportStrategyDictionary,\n options: StrategyOptions\n ) {\n this.strategy = strategy;\n this.transports = transports;\n this.ttl = options.ttl || 1800 * 1000;\n this.usingTLS = options.useTLS;\n this.timeline = options.timeline;\n }\n\n isSupported(): boolean {\n return this.strategy.isSupported();\n }\n\n connect(minPriority: number, callback: Function) {\n var usingTLS = this.usingTLS;\n var info = fetchTransportCache(usingTLS);\n var cacheSkipCount = info && info.cacheSkipCount ? info.cacheSkipCount : 0;\n\n var strategies = [this.strategy];\n if (info && info.timestamp + this.ttl >= Util.now()) {\n var transport = this.transports[info.transport];\n if (transport) {\n if (['ws', 'wss'].includes(info.transport) || cacheSkipCount > 3) {\n this.timeline.info({\n cached: true,\n transport: info.transport,\n latency: info.latency\n });\n strategies.push(\n new SequentialStrategy([transport], {\n timeout: info.latency * 2 + 1000,\n failFast: true\n })\n );\n } else {\n cacheSkipCount++;\n }\n }\n }\n\n var startTimestamp = Util.now();\n var runner = strategies\n .pop()\n .connect(minPriority, function cb(error, handshake) {\n if (error) {\n flushTransportCache(usingTLS);\n if (strategies.length > 0) {\n startTimestamp = Util.now();\n runner = strategies.pop().connect(minPriority, cb);\n } else {\n callback(error);\n }\n } else {\n storeTransportCache(\n usingTLS,\n handshake.transport.name,\n Util.now() - startTimestamp,\n cacheSkipCount\n );\n callback(null, handshake);\n }\n });\n\n return {\n abort: function() {\n runner.abort();\n },\n forceMinPriority: function(p) {\n minPriority = p;\n if (runner) {\n runner.forceMinPriority(p);\n }\n }\n };\n }\n}\n\nfunction getTransportCacheKey(usingTLS: boolean): string {\n return 'pusherTransport' + (usingTLS ? 'TLS' : 'NonTLS');\n}\n\nfunction fetchTransportCache(usingTLS: boolean): any {\n var storage = Runtime.getLocalStorage();\n if (storage) {\n try {\n var serializedCache = storage[getTransportCacheKey(usingTLS)];\n if (serializedCache) {\n return JSON.parse(serializedCache);\n }\n } catch (e) {\n flushTransportCache(usingTLS);\n }\n }\n return null;\n}\n\nfunction storeTransportCache(\n usingTLS: boolean,\n transport: TransportStrategy,\n latency: number,\n cacheSkipCount: number\n) {\n var storage = Runtime.getLocalStorage();\n if (storage) {\n try {\n storage[getTransportCacheKey(usingTLS)] = Collections.safeJSONStringify({\n timestamp: Util.now(),\n transport: transport,\n latency: latency,\n cacheSkipCount: cacheSkipCount\n });\n } catch (e) {\n // catch over quota exceptions raised by localStorage\n }\n }\n}\n\nfunction flushTransportCache(usingTLS: boolean) {\n var storage = Runtime.getLocalStorage();\n if (storage) {\n try {\n delete storage[getTransportCacheKey(usingTLS)];\n } catch (e) {\n // catch exceptions raised by localStorage\n }\n }\n}\n","import { OneOffTimer as Timer } from '../utils/timers';\nimport Strategy from './strategy';\nimport StrategyOptions from './strategy_options';\n\n/** Runs substrategy after specified delay.\n *\n * Options:\n * - delay - time in miliseconds to delay the substrategy attempt\n *\n * @param {Strategy} strategy\n * @param {Object} options\n */\nexport default class DelayedStrategy implements Strategy {\n strategy: Strategy;\n options: { delay: number };\n\n constructor(strategy: Strategy, { delay: number }) {\n this.strategy = strategy;\n this.options = { delay: number };\n }\n\n isSupported(): boolean {\n return this.strategy.isSupported();\n }\n\n connect(minPriority: number, callback: Function) {\n var strategy = this.strategy;\n var runner;\n var timer = new Timer(this.options.delay, function() {\n runner = strategy.connect(minPriority, callback);\n });\n\n return {\n abort: function() {\n timer.ensureAborted();\n if (runner) {\n runner.abort();\n }\n },\n forceMinPriority: function(p) {\n minPriority = p;\n if (runner) {\n runner.forceMinPriority(p);\n }\n }\n };\n }\n}\n","import Strategy from './strategy';\nimport StrategyRunner from './strategy_runner';\n\n/** Proxies method calls to one of substrategies basing on the test function.\n *\n * @param {Function} test\n * @param {Strategy} trueBranch strategy used when test returns true\n * @param {Strategy} falseBranch strategy used when test returns false\n */\nexport default class IfStrategy implements Strategy {\n test: () => boolean;\n trueBranch: Strategy;\n falseBranch: Strategy;\n\n constructor(\n test: () => boolean,\n trueBranch: Strategy,\n falseBranch: Strategy\n ) {\n this.test = test;\n this.trueBranch = trueBranch;\n this.falseBranch = falseBranch;\n }\n\n isSupported(): boolean {\n var branch = this.test() ? this.trueBranch : this.falseBranch;\n return branch.isSupported();\n }\n\n connect(minPriority: number, callback: Function): StrategyRunner {\n var branch = this.test() ? this.trueBranch : this.falseBranch;\n return branch.connect(minPriority, callback);\n }\n}\n","import Strategy from './strategy';\nimport StrategyRunner from './strategy_runner';\n\n/** Launches the substrategy and terminates on the first open connection.\n *\n * @param {Strategy} strategy\n */\nexport default class FirstConnectedStrategy implements Strategy {\n strategy: Strategy;\n\n constructor(strategy: Strategy) {\n this.strategy = strategy;\n }\n\n isSupported(): boolean {\n return this.strategy.isSupported();\n }\n\n connect(minPriority: number, callback: Function): StrategyRunner {\n var runner = this.strategy.connect(minPriority, function(error, handshake) {\n if (handshake) {\n runner.abort();\n }\n callback(error, handshake);\n });\n return runner;\n }\n}\n","import * as Collections from 'core/utils/collections';\nimport TransportManager from 'core/transports/transport_manager';\nimport Strategy from 'core/strategies/strategy';\nimport SequentialStrategy from 'core/strategies/sequential_strategy';\nimport BestConnectedEverStrategy from 'core/strategies/best_connected_ever_strategy';\nimport WebSocketPrioritizedCachedStrategy, {\n TransportStrategyDictionary\n} from 'core/strategies/websocket_prioritized_cached_strategy';\nimport DelayedStrategy from 'core/strategies/delayed_strategy';\nimport IfStrategy from 'core/strategies/if_strategy';\nimport FirstConnectedStrategy from 'core/strategies/first_connected_strategy';\nimport { Config } from 'core/config';\nimport StrategyOptions from 'core/strategies/strategy_options';\n\nfunction testSupportsStrategy(strategy: Strategy) {\n return function() {\n return strategy.isSupported();\n };\n}\n\nvar getDefaultStrategy = function(\n config: Config,\n baseOptions: StrategyOptions,\n defineTransport: Function\n): Strategy {\n var definedTransports = {};\n\n function defineTransportStrategy(\n name: string,\n type: string,\n priority: number,\n options: StrategyOptions,\n manager?: TransportManager\n ) {\n var transport = defineTransport(\n config,\n name,\n type,\n priority,\n options,\n manager\n );\n\n definedTransports[name] = transport;\n\n return transport;\n }\n\n var ws_options: StrategyOptions = Object.assign({}, baseOptions, {\n hostNonTLS: config.wsHost + ':' + config.wsPort,\n hostTLS: config.wsHost + ':' + config.wssPort,\n httpPath: config.wsPath\n });\n var wss_options: StrategyOptions = Collections.extend({}, ws_options, {\n useTLS: true\n });\n var http_options: StrategyOptions = Object.assign({}, baseOptions, {\n hostNonTLS: config.httpHost + ':' + config.httpPort,\n hostTLS: config.httpHost + ':' + config.httpsPort,\n httpPath: config.httpPath\n });\n var timeouts = {\n loop: true,\n timeout: 15000,\n timeoutLimit: 60000\n };\n\n var ws_manager = new TransportManager({\n minPingDelay: 10000,\n maxPingDelay: config.activityTimeout\n });\n var streaming_manager = new TransportManager({\n lives: 2,\n minPingDelay: 10000,\n maxPingDelay: config.activityTimeout\n });\n\n var ws_transport = defineTransportStrategy(\n 'ws',\n 'ws',\n 3,\n ws_options,\n ws_manager\n );\n var wss_transport = defineTransportStrategy(\n 'wss',\n 'ws',\n 3,\n wss_options,\n ws_manager\n );\n var xhr_streaming_transport = defineTransportStrategy(\n 'xhr_streaming',\n 'xhr_streaming',\n 1,\n http_options,\n streaming_manager\n );\n var xhr_polling_transport = defineTransportStrategy(\n 'xhr_polling',\n 'xhr_polling',\n 1,\n http_options\n );\n\n var ws_loop = new SequentialStrategy([ws_transport], timeouts);\n var wss_loop = new SequentialStrategy([wss_transport], timeouts);\n var streaming_loop = new SequentialStrategy(\n [xhr_streaming_transport],\n timeouts\n );\n var polling_loop = new SequentialStrategy([xhr_polling_transport], timeouts);\n\n var http_loop = new SequentialStrategy(\n [\n new IfStrategy(\n testSupportsStrategy(streaming_loop),\n new BestConnectedEverStrategy([\n streaming_loop,\n new DelayedStrategy(polling_loop, { delay: 4000 })\n ]),\n polling_loop\n )\n ],\n timeouts\n );\n\n var wsStrategy;\n if (baseOptions.useTLS) {\n wsStrategy = new BestConnectedEverStrategy([\n ws_loop,\n new DelayedStrategy(http_loop, { delay: 2000 })\n ]);\n } else {\n wsStrategy = new BestConnectedEverStrategy([\n ws_loop,\n new DelayedStrategy(wss_loop, { delay: 2000 }),\n new DelayedStrategy(http_loop, { delay: 5000 })\n ]);\n }\n\n return new WebSocketPrioritizedCachedStrategy(\n new FirstConnectedStrategy(\n new IfStrategy(testSupportsStrategy(ws_transport), wsStrategy, http_loop)\n ),\n definedTransports,\n {\n ttl: 1800000,\n timeline: baseOptions.timeline,\n useTLS: baseOptions.useTLS\n }\n );\n};\n\nexport default getDefaultStrategy;\n","import Runtime from 'runtime';\nimport RequestHooks from './request_hooks';\nimport Ajax from './ajax';\nimport { default as EventsDispatcher } from '../events/dispatcher';\n\nconst MAX_BUFFER_LENGTH = 256 * 1024;\n\nexport default class HTTPRequest extends EventsDispatcher {\n hooks: RequestHooks;\n method: string;\n url: string;\n position: number;\n xhr: Ajax;\n unloader: Function;\n\n constructor(hooks: RequestHooks, method: string, url: string) {\n super();\n this.hooks = hooks;\n this.method = method;\n this.url = url;\n }\n\n start(payload?: any) {\n this.position = 0;\n this.xhr = this.hooks.getRequest(this);\n\n this.unloader = () => {\n this.close();\n };\n Runtime.addUnloadListener(this.unloader);\n\n this.xhr.open(this.method, this.url, true);\n\n if (this.xhr.setRequestHeader) {\n this.xhr.setRequestHeader('Content-Type', 'application/json'); // ReactNative doesn't set this header by default.\n }\n this.xhr.send(payload);\n }\n\n close() {\n if (this.unloader) {\n Runtime.removeUnloadListener(this.unloader);\n this.unloader = null;\n }\n if (this.xhr) {\n this.hooks.abortRequest(this.xhr);\n this.xhr = null;\n }\n }\n\n onChunk(status: number, data: any) {\n while (true) {\n var chunk = this.advanceBuffer(data);\n if (chunk) {\n this.emit('chunk', { status: status, data: chunk });\n } else {\n break;\n }\n }\n if (this.isBufferTooLong(data)) {\n this.emit('buffer_too_long');\n }\n }\n\n private advanceBuffer(buffer: any[]): any {\n var unreadData = buffer.slice(this.position);\n var endOfLinePosition = unreadData.indexOf('\\n');\n\n if (endOfLinePosition !== -1) {\n this.position += endOfLinePosition + 1;\n return unreadData.slice(0, endOfLinePosition);\n } else {\n // chunk is not finished yet, don't move the buffer pointer\n return null;\n }\n }\n\n private isBufferTooLong(buffer: any): boolean {\n return this.position === buffer.length && buffer.length > MAX_BUFFER_LENGTH;\n }\n}\n","enum State {\n CONNECTING = 0,\n OPEN = 1,\n CLOSED = 3\n}\n\nexport default State;\n","import URLLocation from './url_location';\nimport State from './state';\nimport Socket from '../socket';\nimport SocketHooks from './socket_hooks';\nimport Util from '../util';\nimport Ajax from './ajax';\nimport HTTPRequest from './http_request';\nimport Runtime from 'runtime';\n\nvar autoIncrement = 1;\n\nclass HTTPSocket implements Socket {\n hooks: SocketHooks;\n session: string;\n location: URLLocation;\n readyState: State;\n stream: HTTPRequest;\n\n onopen: () => void;\n onerror: (error: any) => void;\n onclose: (closeEvent: any) => void;\n onmessage: (message: any) => void;\n onactivity: () => void;\n\n constructor(hooks: SocketHooks, url: string) {\n this.hooks = hooks;\n this.session = randomNumber(1000) + '/' + randomString(8);\n this.location = getLocation(url);\n this.readyState = State.CONNECTING;\n this.openStream();\n }\n\n send(payload: any) {\n return this.sendRaw(JSON.stringify([payload]));\n }\n\n ping() {\n this.hooks.sendHeartbeat(this);\n }\n\n close(code: any, reason: any) {\n this.onClose(code, reason, true);\n }\n\n /** For internal use only */\n sendRaw(payload: any): boolean {\n if (this.readyState === State.OPEN) {\n try {\n Runtime.createSocketRequest(\n 'POST',\n getUniqueURL(getSendURL(this.location, this.session))\n ).start(payload);\n return true;\n } catch (e) {\n return false;\n }\n } else {\n return false;\n }\n }\n\n /** For internal use only */\n reconnect() {\n this.closeStream();\n this.openStream();\n }\n\n /** For internal use only */\n onClose(code, reason, wasClean) {\n this.closeStream();\n this.readyState = State.CLOSED;\n if (this.onclose) {\n this.onclose({\n code: code,\n reason: reason,\n wasClean: wasClean\n });\n }\n }\n\n private onChunk(chunk) {\n if (chunk.status !== 200) {\n return;\n }\n if (this.readyState === State.OPEN) {\n this.onActivity();\n }\n\n var payload;\n var type = chunk.data.slice(0, 1);\n switch (type) {\n case 'o':\n payload = JSON.parse(chunk.data.slice(1) || '{}');\n this.onOpen(payload);\n break;\n case 'a':\n payload = JSON.parse(chunk.data.slice(1) || '[]');\n for (var i = 0; i < payload.length; i++) {\n this.onEvent(payload[i]);\n }\n break;\n case 'm':\n payload = JSON.parse(chunk.data.slice(1) || 'null');\n this.onEvent(payload);\n break;\n case 'h':\n this.hooks.onHeartbeat(this);\n break;\n case 'c':\n payload = JSON.parse(chunk.data.slice(1) || '[]');\n this.onClose(payload[0], payload[1], true);\n break;\n }\n }\n\n private onOpen(options) {\n if (this.readyState === State.CONNECTING) {\n if (options && options.hostname) {\n this.location.base = replaceHost(this.location.base, options.hostname);\n }\n this.readyState = State.OPEN;\n\n if (this.onopen) {\n this.onopen();\n }\n } else {\n this.onClose(1006, 'Server lost session', true);\n }\n }\n\n private onEvent(event) {\n if (this.readyState === State.OPEN && this.onmessage) {\n this.onmessage({ data: event });\n }\n }\n\n private onActivity() {\n if (this.onactivity) {\n this.onactivity();\n }\n }\n\n private onError(error) {\n if (this.onerror) {\n this.onerror(error);\n }\n }\n\n private openStream() {\n this.stream = Runtime.createSocketRequest(\n 'POST',\n getUniqueURL(this.hooks.getReceiveURL(this.location, this.session))\n );\n\n this.stream.bind('chunk', chunk => {\n this.onChunk(chunk);\n });\n this.stream.bind('finished', status => {\n this.hooks.onFinished(this, status);\n });\n this.stream.bind('buffer_too_long', () => {\n this.reconnect();\n });\n\n try {\n this.stream.start();\n } catch (error) {\n Util.defer(() => {\n this.onError(error);\n this.onClose(1006, 'Could not start streaming', false);\n });\n }\n }\n\n private closeStream() {\n if (this.stream) {\n this.stream.unbind_all();\n this.stream.close();\n this.stream = null;\n }\n }\n}\n\nfunction getLocation(url): URLLocation {\n var parts = /([^\\?]*)\\/*(\\??.*)/.exec(url);\n return {\n base: parts[1],\n queryString: parts[2]\n };\n}\n\nfunction getSendURL(url: URLLocation, session: string): string {\n return url.base + '/' + session + '/xhr_send';\n}\n\nfunction getUniqueURL(url: string): string {\n var separator = url.indexOf('?') === -1 ? '?' : '&';\n return url + separator + 't=' + +new Date() + '&n=' + autoIncrement++;\n}\n\nfunction replaceHost(url: string, hostname: string): string {\n var urlParts = /(https?:\\/\\/)([^\\/:]+)((\\/|:)?.*)/.exec(url);\n return urlParts[1] + hostname + urlParts[3];\n}\n\nfunction randomNumber(max: number): number {\n return Runtime.randomInt(max);\n}\n\nfunction randomString(length: number): string {\n var result = [];\n\n for (var i = 0; i < length; i++) {\n result.push(randomNumber(32).toString(32));\n }\n\n return result.join('');\n}\n\nexport default HTTPSocket;\n","import SocketHooks from './socket_hooks';\nimport HTTPSocket from './http_socket';\n\nvar hooks: SocketHooks = {\n getReceiveURL: function(url, session) {\n return url.base + '/' + session + '/xhr_streaming' + url.queryString;\n },\n onHeartbeat: function(socket) {\n socket.sendRaw('[]');\n },\n sendHeartbeat: function(socket) {\n socket.sendRaw('[]');\n },\n onFinished: function(socket, status) {\n socket.onClose(1006, 'Connection interrupted (' + status + ')', false);\n }\n};\n\nexport default hooks;\n","import SocketHooks from './socket_hooks';\nimport URLLocation from './url_location';\nimport HTTPSocket from './http_socket';\n\nvar hooks: SocketHooks = {\n getReceiveURL: function(url: URLLocation, session: string): string {\n return url.base + '/' + session + '/xhr' + url.queryString;\n },\n onHeartbeat: function() {\n // next HTTP request will reset server's activity timer\n },\n sendHeartbeat: function(socket) {\n socket.sendRaw('[]');\n },\n onFinished: function(socket, status) {\n if (status === 200) {\n socket.reconnect();\n } else {\n socket.onClose(1006, 'Connection interrupted (' + status + ')', false);\n }\n }\n};\n\nexport default hooks;\n","import HTTPRequest from 'core/http/http_request';\nimport RequestHooks from 'core/http/request_hooks';\nimport Ajax from 'core/http/ajax';\nimport Runtime from 'runtime';\n\nvar hooks: RequestHooks = {\n getRequest: function(socket: HTTPRequest): Ajax {\n var Constructor = Runtime.getXHRAPI();\n var xhr = new Constructor();\n xhr.onreadystatechange = xhr.onprogress = function() {\n switch (xhr.readyState) {\n case 3:\n if (xhr.responseText && xhr.responseText.length > 0) {\n socket.onChunk(xhr.status, xhr.responseText);\n }\n break;\n case 4:\n // this happens only on errors, never after calling close\n if (xhr.responseText && xhr.responseText.length > 0) {\n socket.onChunk(xhr.status, xhr.responseText);\n }\n socket.emit('finished', xhr.status);\n socket.close();\n break;\n }\n };\n return xhr;\n },\n abortRequest: function(xhr: Ajax) {\n xhr.onreadystatechange = null;\n xhr.abort();\n }\n};\n\nexport default hooks;\n","import * as Collections from 'core/utils/collections';\nimport Transports from 'isomorphic/transports/transports';\nimport TimelineSender from 'core/timeline/timeline_sender';\nimport Ajax from 'core/http/ajax';\nimport getDefaultStrategy from './default_strategy';\nimport TransportsTable from 'core/transports/transports_table';\nimport transportConnectionInitializer from './transports/transport_connection_initializer';\nimport HTTPFactory from './http/http';\n\nvar Isomorphic: any = {\n getDefaultStrategy,\n Transports: Transports,\n transportConnectionInitializer,\n HTTPFactory,\n\n setup(PusherClass): void {\n PusherClass.ready();\n },\n\n getLocalStorage(): any {\n return undefined;\n },\n\n getClientFeatures(): any[] {\n return Collections.keys(\n Collections.filterObject({ ws: Transports.ws }, function(t) {\n return t.isSupported({});\n })\n );\n },\n\n getProtocol(): string {\n return 'http:';\n },\n\n isXHRSupported(): boolean {\n return true;\n },\n\n createSocketRequest(method: string, url: string) {\n if (this.isXHRSupported()) {\n return this.HTTPFactory.createXHR(method, url);\n } else {\n throw 'Cross-origin HTTP requests are not supported';\n }\n },\n\n createXHR(): Ajax {\n var Constructor = this.getXHRAPI();\n return new Constructor();\n },\n\n createWebSocket(url: string): any {\n var Constructor = this.getWebSocketAPI();\n return new Constructor(url);\n },\n\n addUnloadListener(listener: any) {},\n removeUnloadListener(listener: any) {}\n};\n\nexport default Isomorphic;\n","/** Initializes the transport.\n *\n * Fetches resources if needed and then transitions to initialized.\n */\nexport default function() {\n var self = this;\n\n self.timeline.info(\n self.buildTimelineMessage({\n transport: self.name + (self.options.useTLS ? 's' : '')\n })\n );\n\n if (self.hooks.isInitialized()) {\n self.changeState('initialized');\n } else {\n self.onClose();\n }\n}\n","import HTTPRequest from 'core/http/http_request';\nimport HTTPSocket from 'core/http/http_socket';\nimport SocketHooks from 'core/http/socket_hooks';\nimport RequestHooks from 'core/http/request_hooks';\nimport streamingHooks from 'core/http/http_streaming_socket';\nimport pollingHooks from 'core/http/http_polling_socket';\nimport xhrHooks from './http_xhr_request';\nimport HTTPFactory from 'core/http/http_factory';\n\nvar HTTP: HTTPFactory = {\n createStreamingSocket(url: string): HTTPSocket {\n return this.createSocket(streamingHooks, url);\n },\n\n createPollingSocket(url: string): HTTPSocket {\n return this.createSocket(pollingHooks, url);\n },\n\n createSocket(hooks: SocketHooks, url: string): HTTPSocket {\n return new HTTPSocket(hooks, url);\n },\n\n createXHR(method: string, url: string): HTTPRequest {\n return this.createRequest(xhrHooks, method, url);\n },\n\n createRequest(hooks: RequestHooks, method: string, url: string): HTTPRequest {\n return new HTTPRequest(hooks, method, url);\n }\n};\n\nexport default HTTP;\n","import { default as EventsDispatcher } from 'core/events/dispatcher';\nimport Reachability from 'core/reachability';\n\nexport class NetInfo extends EventsDispatcher implements Reachability {\n isOnline(): boolean {\n return true;\n }\n}\n\nexport var Network = new NetInfo();\n","import AbstractRuntime from 'runtimes/interface';\nimport { AuthTransport } from 'core/auth/auth_transports';\nimport {\n AuthRequestType,\n AuthTransportCallback,\n InternalAuthOptions\n} from 'core/auth/options';\nimport { HTTPAuthError } from 'core/errors';\n\nvar fetchAuth: AuthTransport = function(\n context: AbstractRuntime,\n query: string,\n authOptions: InternalAuthOptions,\n authRequestType: AuthRequestType,\n callback: AuthTransportCallback\n) {\n var headers = new Headers();\n headers.set('Content-Type', 'application/x-www-form-urlencoded');\n\n for (var headerName in authOptions.headers) {\n headers.set(headerName, authOptions.headers[headerName]);\n }\n\n if (authOptions.headersProvider != null) {\n const dynamicHeaders = authOptions.headersProvider();\n for (var headerName in dynamicHeaders) {\n headers.set(headerName, dynamicHeaders[headerName]);\n }\n }\n\n var body = query;\n var request = new Request(authOptions.endpoint, {\n headers,\n body,\n credentials: 'same-origin',\n method: 'POST'\n });\n\n return fetch(request)\n .then(response => {\n let { status } = response;\n if (status === 200) {\n // manually parse the json so we can provide a more helpful error in\n // failure case\n return response.text();\n }\n throw new HTTPAuthError(\n status,\n `Could not get ${authRequestType.toString()} info from your auth endpoint, status: ${status}`\n );\n })\n .then(data => {\n let parsedData;\n try {\n parsedData = JSON.parse(data);\n } catch (e) {\n throw new HTTPAuthError(\n 200,\n `JSON returned from ${authRequestType.toString()} endpoint was invalid, yet status code was 200. Data was: ${data}`\n );\n }\n callback(null, parsedData);\n })\n .catch(err => {\n callback(err, null);\n });\n};\n\nexport default fetchAuth;\n","import Logger from 'core/logger';\nimport TimelineSender from 'core/timeline/timeline_sender';\nimport * as Collections from 'core/utils/collections';\nimport Util from 'core/util';\nimport Runtime from 'runtime';\nimport TimelineTransport from 'core/timeline/timeline_transport';\n\nvar getAgent = function(sender: TimelineSender, useTLS: boolean) {\n return function(data: any, callback: Function) {\n var scheme = 'http' + (useTLS ? 's' : '') + '://';\n var url =\n scheme + (sender.host || sender.options.host) + sender.options.path;\n var query = Collections.buildQueryString(data);\n url += '/' + 2 + '?' + query;\n\n fetch(url)\n .then(response => {\n if (response.status !== 200) {\n throw `received ${response.status} from stats.pusher.com`;\n }\n return response.json();\n })\n .then(({ host }) => {\n if (host) {\n sender.host = host;\n }\n })\n .catch(err => {\n Logger.debug('TimelineSender Error: ', err);\n });\n };\n};\n\nvar fetchTimeline = {\n name: 'xhr',\n getAgent\n};\n\nexport default fetchTimeline;\n","import Isomorphic from 'isomorphic/runtime';\nimport Runtime from '../interface';\nimport { Network } from './net_info';\nimport fetchAuth from './auth/fetch_auth';\nimport { AuthTransports } from 'core/auth/auth_transports';\nimport fetchTimeline from './timeline/fetch_timeline';\n\n// Very verbose but until unavoidable until\n// TypeScript 2.1, when spread attributes will be\n// supported\nconst {\n getDefaultStrategy,\n Transports,\n setup,\n getProtocol,\n isXHRSupported,\n getLocalStorage,\n createXHR,\n createWebSocket,\n addUnloadListener,\n removeUnloadListener,\n transportConnectionInitializer,\n createSocketRequest,\n HTTPFactory\n} = Isomorphic;\n\nconst Worker: Runtime = {\n getDefaultStrategy,\n Transports,\n setup,\n getProtocol,\n isXHRSupported,\n getLocalStorage,\n createXHR,\n createWebSocket,\n addUnloadListener,\n removeUnloadListener,\n transportConnectionInitializer,\n createSocketRequest,\n HTTPFactory,\n\n TimelineTransport: fetchTimeline,\n\n getAuthorizers(): AuthTransports {\n return { ajax: fetchAuth };\n },\n\n getWebSocketAPI() {\n return WebSocket;\n },\n\n getXHRAPI() {\n return XMLHttpRequest;\n },\n\n getNetwork() {\n return Network;\n },\n\n randomInt(max: number): number {\n /**\n * Return values in the range of [0, 1[\n */\n const random = function() {\n const crypto = globalThis.crypto || globalThis['msCrypto'];\n const random = crypto.getRandomValues(new Uint32Array(1))[0];\n\n return random / 2 ** 32;\n };\n\n return Math.floor(random() * max);\n }\n};\n\nexport default Worker;\n","enum TimelineLevel {\n ERROR = 3,\n INFO = 6,\n DEBUG = 7\n}\n\nexport default TimelineLevel;\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport { default as Level } from './level';\n\nexport interface TimelineOptions {\n level?: Level;\n limit?: number;\n version?: string;\n cluster?: string;\n features?: string[];\n params?: any;\n}\n\nexport default class Timeline {\n key: string;\n session: number;\n events: any[];\n options: TimelineOptions;\n sent: number;\n uniqueID: number;\n\n constructor(key: string, session: number, options: TimelineOptions) {\n this.key = key;\n this.session = session;\n this.events = [];\n this.options = options || {};\n this.sent = 0;\n this.uniqueID = 0;\n }\n\n log(level, event) {\n if (level <= this.options.level) {\n this.events.push(\n Collections.extend({}, event, { timestamp: Util.now() })\n );\n if (this.options.limit && this.events.length > this.options.limit) {\n this.events.shift();\n }\n }\n }\n\n error(event) {\n this.log(Level.ERROR, event);\n }\n\n info(event) {\n this.log(Level.INFO, event);\n }\n\n debug(event) {\n this.log(Level.DEBUG, event);\n }\n\n isEmpty() {\n return this.events.length === 0;\n }\n\n send(sendfn, callback) {\n var data = Collections.extend(\n {\n session: this.session,\n bundle: this.sent + 1,\n key: this.key,\n lib: 'js',\n version: this.options.version,\n cluster: this.options.cluster,\n features: this.options.features,\n timeline: this.events\n },\n this.options.params\n );\n\n this.events = [];\n sendfn(data, (error, result) => {\n if (!error) {\n this.sent++;\n }\n if (callback) {\n callback(error, result);\n }\n });\n\n return true;\n }\n\n generateUniqueID(): number {\n this.uniqueID++;\n return this.uniqueID;\n }\n}\n","import Factory from '../utils/factory';\nimport Util from '../util';\nimport * as Errors from '../errors';\nimport * as Collections from '../utils/collections';\nimport Strategy from './strategy';\nimport Transport from '../transports/transport';\nimport StrategyOptions from './strategy_options';\nimport Handshake from '../connection/handshake';\n\n/** Provides a strategy interface for transports.\n *\n * @param {String} name\n * @param {Number} priority\n * @param {Class} transport\n * @param {Object} options\n */\nexport default class TransportStrategy implements Strategy {\n name: string;\n priority: number;\n transport: Transport;\n options: StrategyOptions;\n\n constructor(\n name: string,\n priority: number,\n transport: Transport,\n options: StrategyOptions\n ) {\n this.name = name;\n this.priority = priority;\n this.transport = transport;\n this.options = options || {};\n }\n\n /** Returns whether the transport is supported in the browser.\n *\n * @returns {Boolean}\n */\n isSupported(): boolean {\n return this.transport.isSupported({\n useTLS: this.options.useTLS\n });\n }\n\n /** Launches a connection attempt and returns a strategy runner.\n *\n * @param {Function} callback\n * @return {Object} strategy runner\n */\n connect(minPriority: number, callback: Function) {\n if (!this.isSupported()) {\n return failAttempt(new Errors.UnsupportedStrategy(), callback);\n } else if (this.priority < minPriority) {\n return failAttempt(new Errors.TransportPriorityTooLow(), callback);\n }\n\n var connected = false;\n var transport = this.transport.createConnection(\n this.name,\n this.priority,\n this.options.key,\n this.options\n );\n var handshake = null;\n\n var onInitialized = function() {\n transport.unbind('initialized', onInitialized);\n transport.connect();\n };\n var onOpen = function() {\n handshake = Factory.createHandshake(transport, function(result) {\n connected = true;\n unbindListeners();\n callback(null, result);\n });\n };\n var onError = function(error) {\n unbindListeners();\n callback(error);\n };\n var onClosed = function() {\n unbindListeners();\n var serializedTransport;\n\n // The reason for this try/catch block is that on React Native\n // the WebSocket object is circular. Therefore transport.socket will\n // throw errors upon stringification. Collections.safeJSONStringify\n // discards circular references when serializing.\n serializedTransport = Collections.safeJSONStringify(transport);\n callback(new Errors.TransportClosed(serializedTransport));\n };\n\n var unbindListeners = function() {\n transport.unbind('initialized', onInitialized);\n transport.unbind('open', onOpen);\n transport.unbind('error', onError);\n transport.unbind('closed', onClosed);\n };\n\n transport.bind('initialized', onInitialized);\n transport.bind('open', onOpen);\n transport.bind('error', onError);\n transport.bind('closed', onClosed);\n\n // connect will be called automatically after initialization\n transport.initialize();\n\n return {\n abort: () => {\n if (connected) {\n return;\n }\n unbindListeners();\n if (handshake) {\n handshake.close();\n } else {\n transport.close();\n }\n },\n forceMinPriority: p => {\n if (connected) {\n return;\n }\n if (this.priority < p) {\n if (handshake) {\n handshake.close();\n } else {\n transport.close();\n }\n }\n }\n };\n }\n}\n\nfunction failAttempt(error: Error, callback: Function) {\n Util.defer(function() {\n callback(error);\n });\n return {\n abort: function() {},\n forceMinPriority: function() {}\n };\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport TransportManager from '../transports/transport_manager';\nimport * as Errors from '../errors';\nimport Strategy from './strategy';\nimport TransportStrategy from './transport_strategy';\nimport StrategyOptions from '../strategies/strategy_options';\nimport { Config } from '../config';\nimport Runtime from 'runtime';\n\nconst { Transports } = Runtime;\n\nexport var defineTransport = function(\n config: Config,\n name: string,\n type: string,\n priority: number,\n options: StrategyOptions,\n manager?: TransportManager\n): Strategy {\n var transportClass = Transports[type];\n if (!transportClass) {\n throw new Errors.UnsupportedTransport(type);\n }\n\n var enabled =\n (!config.enabledTransports ||\n Collections.arrayIndexOf(config.enabledTransports, name) !== -1) &&\n (!config.disabledTransports ||\n Collections.arrayIndexOf(config.disabledTransports, name) === -1);\n\n var transport;\n if (enabled) {\n options = Object.assign(\n { ignoreNullOrigin: config.ignoreNullOrigin },\n options\n );\n\n transport = new TransportStrategy(\n name,\n priority,\n manager ? manager.getAssistant(transportClass) : transportClass,\n options\n );\n } else {\n transport = UnsupportedStrategy;\n }\n\n return transport;\n};\n\nvar UnsupportedStrategy: Strategy = {\n isSupported: function() {\n return false;\n },\n connect: function(_, callback) {\n var deferred = Util.defer(function() {\n callback(new Errors.UnsupportedStrategy());\n });\n return {\n abort: function() {\n deferred.ensureAborted();\n },\n forceMinPriority: function() {}\n };\n }\n};\n","export enum AuthRequestType {\n UserAuthentication = 'user-authentication',\n ChannelAuthorization = 'channel-authorization'\n}\n\nexport interface ChannelAuthorizationData {\n auth: string;\n channel_data?: string;\n shared_secret?: string;\n}\n\nexport type ChannelAuthorizationCallback = (\n error: Error | null,\n authData: ChannelAuthorizationData | null\n) => void;\n\nexport interface ChannelAuthorizationRequestParams {\n socketId: string;\n channelName: string;\n}\n\nexport interface ChannelAuthorizationHandler {\n (\n params: ChannelAuthorizationRequestParams,\n callback: ChannelAuthorizationCallback\n ): void;\n}\n\nexport interface UserAuthenticationData {\n auth: string;\n user_data: string;\n}\n\nexport type UserAuthenticationCallback = (\n error: Error | null,\n authData: UserAuthenticationData | null\n) => void;\n\nexport interface UserAuthenticationRequestParams {\n socketId: string;\n}\n\nexport interface UserAuthenticationHandler {\n (\n params: UserAuthenticationRequestParams,\n callback: UserAuthenticationCallback\n ): void;\n}\n\nexport type AuthTransportCallback =\n | ChannelAuthorizationCallback\n | UserAuthenticationCallback;\n\nexport interface AuthOptionsT {\n transport: 'ajax' | 'jsonp';\n endpoint: string;\n params?: any;\n headers?: any;\n paramsProvider?: () => any;\n headersProvider?: () => any;\n customHandler?: AuthHandler;\n}\n\nexport declare type UserAuthenticationOptions = AuthOptionsT<\n UserAuthenticationHandler\n>;\nexport declare type ChannelAuthorizationOptions = AuthOptionsT<\n ChannelAuthorizationHandler\n>;\n\nexport interface InternalAuthOptions {\n transport: 'ajax' | 'jsonp';\n endpoint: string;\n params?: any;\n headers?: any;\n paramsProvider?: () => any;\n headersProvider?: () => any;\n}\n","import {\n UserAuthenticationCallback,\n InternalAuthOptions,\n UserAuthenticationHandler,\n UserAuthenticationRequestParams,\n AuthRequestType\n} from './options';\n\nimport Runtime from 'runtime';\n\nconst composeChannelQuery = (\n params: UserAuthenticationRequestParams,\n authOptions: InternalAuthOptions\n) => {\n var query = 'socket_id=' + encodeURIComponent(params.socketId);\n\n for (var key in authOptions.params) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(authOptions.params[key]);\n }\n\n if (authOptions.paramsProvider != null) {\n let dynamicParams = authOptions.paramsProvider();\n for (var key in dynamicParams) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(dynamicParams[key]);\n }\n }\n\n return query;\n};\n\nconst UserAuthenticator = (\n authOptions: InternalAuthOptions\n): UserAuthenticationHandler => {\n if (typeof Runtime.getAuthorizers()[authOptions.transport] === 'undefined') {\n throw `'${authOptions.transport}' is not a recognized auth transport`;\n }\n\n return (\n params: UserAuthenticationRequestParams,\n callback: UserAuthenticationCallback\n ) => {\n const query = composeChannelQuery(params, authOptions);\n\n Runtime.getAuthorizers()[authOptions.transport](\n Runtime,\n query,\n authOptions,\n AuthRequestType.UserAuthentication,\n callback\n );\n };\n};\n\nexport default UserAuthenticator;\n","import {\n AuthRequestType,\n InternalAuthOptions,\n ChannelAuthorizationHandler,\n ChannelAuthorizationRequestParams,\n ChannelAuthorizationCallback\n} from './options';\n\nimport Runtime from 'runtime';\n\nconst composeChannelQuery = (\n params: ChannelAuthorizationRequestParams,\n authOptions: InternalAuthOptions\n) => {\n var query = 'socket_id=' + encodeURIComponent(params.socketId);\n\n query += '&channel_name=' + encodeURIComponent(params.channelName);\n\n for (var key in authOptions.params) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(authOptions.params[key]);\n }\n\n if (authOptions.paramsProvider != null) {\n let dynamicParams = authOptions.paramsProvider();\n for (var key in dynamicParams) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(dynamicParams[key]);\n }\n }\n\n return query;\n};\n\nconst ChannelAuthorizer = (\n authOptions: InternalAuthOptions\n): ChannelAuthorizationHandler => {\n if (typeof Runtime.getAuthorizers()[authOptions.transport] === 'undefined') {\n throw `'${authOptions.transport}' is not a recognized auth transport`;\n }\n\n return (\n params: ChannelAuthorizationRequestParams,\n callback: ChannelAuthorizationCallback\n ) => {\n const query = composeChannelQuery(params, authOptions);\n\n Runtime.getAuthorizers()[authOptions.transport](\n Runtime,\n query,\n authOptions,\n AuthRequestType.ChannelAuthorization,\n callback\n );\n };\n};\n\nexport default ChannelAuthorizer;\n","import { Options } from './options';\nimport Defaults from './defaults';\nimport {\n ChannelAuthorizationHandler,\n UserAuthenticationHandler,\n ChannelAuthorizationOptions\n} from './auth/options';\nimport UserAuthenticator from './auth/user_authenticator';\nimport ChannelAuthorizer from './auth/channel_authorizer';\nimport { ChannelAuthorizerProxy } from './auth/deprecated_channel_authorizer';\nimport Runtime from 'runtime';\nimport * as nacl from 'tweetnacl';\n\nexport type AuthTransport = 'ajax' | 'jsonp';\nexport type Transport =\n | 'ws'\n | 'wss'\n | 'xhr_streaming'\n | 'xhr_polling'\n | 'sockjs';\n\nexport interface Config {\n // these are all 'required' config parameters, it's not necessary for the user\n // to set them, but they have configured defaults.\n activityTimeout: number;\n enableStats: boolean;\n httpHost: string;\n httpPath: string;\n httpPort: number;\n httpsPort: number;\n pongTimeout: number;\n statsHost: string;\n unavailableTimeout: number;\n useTLS: boolean;\n wsHost: string;\n wsPath: string;\n wsPort: number;\n wssPort: number;\n userAuthenticator: UserAuthenticationHandler;\n channelAuthorizer: ChannelAuthorizationHandler;\n\n // these are all optional parameters or overrrides. The customer can set these\n // but it's not strictly necessary\n forceTLS?: boolean;\n cluster?: string;\n disabledTransports?: Transport[];\n enabledTransports?: Transport[];\n ignoreNullOrigin?: boolean;\n nacl?: nacl;\n timelineParams?: any;\n}\n\n// getConfig mainly sets the defaults for the options that are not provided\nexport function getConfig(opts: Options, pusher): Config {\n let config: Config = {\n activityTimeout: opts.activityTimeout || Defaults.activityTimeout,\n cluster: opts.cluster,\n httpPath: opts.httpPath || Defaults.httpPath,\n httpPort: opts.httpPort || Defaults.httpPort,\n httpsPort: opts.httpsPort || Defaults.httpsPort,\n pongTimeout: opts.pongTimeout || Defaults.pongTimeout,\n statsHost: opts.statsHost || Defaults.stats_host,\n unavailableTimeout: opts.unavailableTimeout || Defaults.unavailableTimeout,\n wsPath: opts.wsPath || Defaults.wsPath,\n wsPort: opts.wsPort || Defaults.wsPort,\n wssPort: opts.wssPort || Defaults.wssPort,\n\n enableStats: getEnableStatsConfig(opts),\n httpHost: getHttpHost(opts),\n useTLS: shouldUseTLS(opts),\n wsHost: getWebsocketHost(opts),\n\n userAuthenticator: buildUserAuthenticator(opts),\n channelAuthorizer: buildChannelAuthorizer(opts, pusher)\n };\n\n if ('disabledTransports' in opts)\n config.disabledTransports = opts.disabledTransports;\n if ('enabledTransports' in opts)\n config.enabledTransports = opts.enabledTransports;\n if ('ignoreNullOrigin' in opts)\n config.ignoreNullOrigin = opts.ignoreNullOrigin;\n if ('timelineParams' in opts) config.timelineParams = opts.timelineParams;\n if ('nacl' in opts) {\n config.nacl = opts.nacl;\n }\n\n return config;\n}\n\nfunction getHttpHost(opts: Options): string {\n if (opts.httpHost) {\n return opts.httpHost;\n }\n if (opts.cluster) {\n return `sockjs-${opts.cluster}.pusher.com`;\n }\n return Defaults.httpHost;\n}\n\nfunction getWebsocketHost(opts: Options): string {\n if (opts.wsHost) {\n return opts.wsHost;\n }\n return getWebsocketHostFromCluster(opts.cluster);\n}\n\nfunction getWebsocketHostFromCluster(cluster: string): string {\n return `ws-${cluster}.pusher.com`;\n}\n\nfunction shouldUseTLS(opts: Options): boolean {\n if (Runtime.getProtocol() === 'https:') {\n return true;\n } else if (opts.forceTLS === false) {\n return false;\n }\n return true;\n}\n\n// if enableStats is set take the value\n// if disableStats is set take the inverse\n// otherwise default to false\nfunction getEnableStatsConfig(opts: Options): boolean {\n if ('enableStats' in opts) {\n return opts.enableStats;\n }\n if ('disableStats' in opts) {\n return !opts.disableStats;\n }\n return false;\n}\n\nfunction buildUserAuthenticator(opts: Options): UserAuthenticationHandler {\n const userAuthentication = {\n ...Defaults.userAuthentication,\n ...opts.userAuthentication\n };\n if (\n 'customHandler' in userAuthentication &&\n userAuthentication['customHandler'] != null\n ) {\n return userAuthentication['customHandler'];\n }\n\n return UserAuthenticator(userAuthentication);\n}\n\nfunction buildChannelAuth(opts: Options, pusher): ChannelAuthorizationOptions {\n let channelAuthorization: ChannelAuthorizationOptions;\n if ('channelAuthorization' in opts) {\n channelAuthorization = {\n ...Defaults.channelAuthorization,\n ...opts.channelAuthorization\n };\n } else {\n channelAuthorization = {\n transport: opts.authTransport || Defaults.authTransport,\n endpoint: opts.authEndpoint || Defaults.authEndpoint\n };\n if ('auth' in opts) {\n if ('params' in opts.auth) channelAuthorization.params = opts.auth.params;\n if ('headers' in opts.auth)\n channelAuthorization.headers = opts.auth.headers;\n }\n if ('authorizer' in opts)\n channelAuthorization.customHandler = ChannelAuthorizerProxy(\n pusher,\n channelAuthorization,\n opts.authorizer\n );\n }\n return channelAuthorization;\n}\n\nfunction buildChannelAuthorizer(\n opts: Options,\n pusher\n): ChannelAuthorizationHandler {\n const channelAuthorization = buildChannelAuth(opts, pusher);\n if (\n 'customHandler' in channelAuthorization &&\n channelAuthorization['customHandler'] != null\n ) {\n return channelAuthorization['customHandler'];\n }\n\n return ChannelAuthorizer(channelAuthorization);\n}\n","import Channel from '../channels/channel';\nimport {\n ChannelAuthorizationCallback,\n ChannelAuthorizationHandler,\n ChannelAuthorizationRequestParams,\n InternalAuthOptions\n} from './options';\n\nexport interface DeprecatedChannelAuthorizer {\n authorize(socketId: string, callback: ChannelAuthorizationCallback): void;\n}\n\nexport interface ChannelAuthorizerGenerator {\n (\n channel: Channel,\n options: DeprecatedAuthorizerOptions\n ): DeprecatedChannelAuthorizer;\n}\n\nexport interface DeprecatedAuthOptions {\n params?: any;\n headers?: any;\n}\n\nexport interface DeprecatedAuthorizerOptions {\n authTransport: 'ajax' | 'jsonp';\n authEndpoint: string;\n auth?: DeprecatedAuthOptions;\n}\n\nexport const ChannelAuthorizerProxy = (\n pusher,\n authOptions: InternalAuthOptions,\n channelAuthorizerGenerator: ChannelAuthorizerGenerator\n): ChannelAuthorizationHandler => {\n const deprecatedAuthorizerOptions: DeprecatedAuthorizerOptions = {\n authTransport: authOptions.transport,\n authEndpoint: authOptions.endpoint,\n auth: {\n params: authOptions.params,\n headers: authOptions.headers\n }\n };\n return (\n params: ChannelAuthorizationRequestParams,\n callback: ChannelAuthorizationCallback\n ) => {\n const channel = pusher.channel(params.channelName);\n // This line creates a new channel authorizer every time.\n // In the past, this was only done once per channel and reused.\n // We can do that again if we want to keep this behavior intact.\n const channelAuthorizer: DeprecatedChannelAuthorizer = channelAuthorizerGenerator(\n channel,\n deprecatedAuthorizerOptions\n );\n channelAuthorizer.authorize(params.socketId, callback);\n };\n};\n","import Logger from './logger';\nimport Pusher from './pusher';\nimport EventsDispatcher from './events/dispatcher';\n\nexport default class WatchlistFacade extends EventsDispatcher {\n private pusher: Pusher;\n\n public constructor(pusher: Pusher) {\n super(function(eventName, data) {\n Logger.debug(`No callbacks on watchlist events for ${eventName}`);\n });\n\n this.pusher = pusher;\n this.bindWatchlistInternalEvent();\n }\n\n handleEvent(pusherEvent) {\n pusherEvent.data.events.forEach(watchlistEvent => {\n this.emit(watchlistEvent.name, watchlistEvent);\n });\n }\n\n private bindWatchlistInternalEvent() {\n this.pusher.connection.bind('message', pusherEvent => {\n var eventName = pusherEvent.event;\n if (eventName === 'pusher_internal:watchlist_events') {\n this.handleEvent(pusherEvent);\n }\n });\n }\n}\n","function flatPromise() {\n let resolve, reject;\n const promise = new Promise((res, rej) => {\n resolve = res;\n reject = rej;\n });\n return { promise, resolve, reject };\n}\n\nexport default flatPromise;\n","import Pusher from './pusher';\nimport Logger from './logger';\nimport {\n UserAuthenticationData,\n UserAuthenticationCallback\n} from './auth/options';\nimport Channel from './channels/channel';\nimport WatchlistFacade from './watchlist';\nimport EventsDispatcher from './events/dispatcher';\nimport flatPromise from './utils/flat_promise';\n\nexport default class UserFacade extends EventsDispatcher {\n pusher: Pusher;\n signin_requested: boolean = false;\n user_data: any = null;\n serverToUserChannel: Channel = null;\n signinDonePromise: Promise = null;\n watchlist: WatchlistFacade;\n private _signinDoneResolve: Function = null;\n\n public constructor(pusher: Pusher) {\n super(function(eventName, data) {\n Logger.debug('No callbacks on user for ' + eventName);\n });\n this.pusher = pusher;\n this.pusher.connection.bind('state_change', ({ previous, current }) => {\n if (previous !== 'connected' && current === 'connected') {\n this._signin();\n }\n if (previous === 'connected' && current !== 'connected') {\n this._cleanup();\n this._newSigninPromiseIfNeeded();\n }\n });\n\n this.watchlist = new WatchlistFacade(pusher);\n\n this.pusher.connection.bind('message', event => {\n var eventName = event.event;\n if (eventName === 'pusher:signin_success') {\n this._onSigninSuccess(event.data);\n }\n if (\n this.serverToUserChannel &&\n this.serverToUserChannel.name === event.channel\n ) {\n this.serverToUserChannel.handleEvent(event);\n }\n });\n }\n\n public signin() {\n if (this.signin_requested) {\n return;\n }\n\n this.signin_requested = true;\n this._signin();\n }\n\n private _signin() {\n if (!this.signin_requested) {\n return;\n }\n\n this._newSigninPromiseIfNeeded();\n\n if (this.pusher.connection.state !== 'connected') {\n // Signin will be attempted when the connection is connected\n return;\n }\n\n this.pusher.config.userAuthenticator(\n {\n socketId: this.pusher.connection.socket_id\n },\n this._onAuthorize\n );\n }\n\n private _onAuthorize: UserAuthenticationCallback = (\n err,\n authData: UserAuthenticationData\n ) => {\n if (err) {\n Logger.warn(`Error during signin: ${err}`);\n this._cleanup();\n return;\n }\n\n this.pusher.send_event('pusher:signin', {\n auth: authData.auth,\n user_data: authData.user_data\n });\n\n // Later when we get pusher:singin_success event, the user will be marked as signed in\n };\n\n private _onSigninSuccess(data: any) {\n try {\n this.user_data = JSON.parse(data.user_data);\n } catch (e) {\n Logger.error(`Failed parsing user data after signin: ${data.user_data}`);\n this._cleanup();\n return;\n }\n\n if (typeof this.user_data.id !== 'string' || this.user_data.id === '') {\n Logger.error(\n `user_data doesn't contain an id. user_data: ${this.user_data}`\n );\n this._cleanup();\n return;\n }\n\n // Signin succeeded\n this._signinDoneResolve();\n this._subscribeChannels();\n }\n\n private _subscribeChannels() {\n const ensure_subscribed = channel => {\n if (channel.subscriptionPending && channel.subscriptionCancelled) {\n channel.reinstateSubscription();\n } else if (\n !channel.subscriptionPending &&\n this.pusher.connection.state === 'connected'\n ) {\n channel.subscribe();\n }\n };\n\n this.serverToUserChannel = new Channel(\n `#server-to-user-${this.user_data.id}`,\n this.pusher\n );\n this.serverToUserChannel.bind_global((eventName, data) => {\n if (\n eventName.indexOf('pusher_internal:') === 0 ||\n eventName.indexOf('pusher:') === 0\n ) {\n // ignore internal events\n return;\n }\n this.emit(eventName, data);\n });\n ensure_subscribed(this.serverToUserChannel);\n }\n\n private _cleanup() {\n this.user_data = null;\n if (this.serverToUserChannel) {\n this.serverToUserChannel.unbind_all();\n this.serverToUserChannel.disconnect();\n this.serverToUserChannel = null;\n }\n\n if (this.signin_requested) {\n // If signin is in progress and cleanup is called,\n // Mark the current signin process as done.\n this._signinDoneResolve();\n }\n }\n\n private _newSigninPromiseIfNeeded() {\n if (!this.signin_requested) {\n return;\n }\n\n // If there is a promise and it is not resolved, return without creating a new one.\n if (this.signinDonePromise && !(this.signinDonePromise as any).done) {\n return;\n }\n\n // This promise is never rejected.\n // It gets resolved when the signin process is done whether it failed or succeeded\n const { promise, resolve, reject: _ } = flatPromise();\n (promise as any).done = false;\n const setDone = () => {\n (promise as any).done = true;\n };\n promise.then(setDone).catch(setDone);\n this.signinDonePromise = promise;\n this._signinDoneResolve = resolve;\n }\n}\n","import AbstractRuntime from '../runtimes/interface';\nimport Runtime from 'runtime';\nimport * as Collections from './utils/collections';\nimport Channels from './channels/channels';\nimport Channel from './channels/channel';\nimport { default as EventsDispatcher } from './events/dispatcher';\nimport Timeline from './timeline/timeline';\nimport TimelineSender from './timeline/timeline_sender';\nimport TimelineLevel from './timeline/level';\nimport { defineTransport } from './strategies/strategy_builder';\nimport ConnectionManager from './connection/connection_manager';\nimport { PeriodicTimer } from './utils/timers';\nimport Defaults from './defaults';\nimport Logger from './logger';\nimport Factory from './utils/factory';\nimport { Options, ClusterOptions, validateOptions } from './options';\nimport { Config, getConfig } from './config';\nimport StrategyOptions from './strategies/strategy_options';\nimport UserFacade from './user';\n\nexport default class Pusher {\n /* STATIC PROPERTIES */\n static instances: Pusher[] = [];\n static isReady: boolean = false;\n static logToConsole: boolean = false;\n\n // for jsonp\n static Runtime: AbstractRuntime = Runtime;\n static ScriptReceivers: any = (Runtime).ScriptReceivers;\n static DependenciesReceivers: any = (Runtime).DependenciesReceivers;\n static auth_callbacks: any = (Runtime).auth_callbacks;\n\n static ready() {\n Pusher.isReady = true;\n for (var i = 0, l = Pusher.instances.length; i < l; i++) {\n Pusher.instances[i].connect();\n }\n }\n\n static log: (message: any) => void;\n\n private static getClientFeatures(): string[] {\n return Collections.keys(\n Collections.filterObject({ ws: Runtime.Transports.ws }, function(t) {\n return t.isSupported({});\n })\n );\n }\n\n /* INSTANCE PROPERTIES */\n key: string;\n options: Options;\n config: Config;\n channels: Channels;\n global_emitter: EventsDispatcher;\n sessionID: number;\n timeline: Timeline;\n timelineSender: TimelineSender;\n connection: ConnectionManager;\n timelineSenderTimer: PeriodicTimer;\n user: UserFacade;\n constructor(app_key: string, options: Options) {\n checkAppKey(app_key);\n validateOptions(options);\n this.key = app_key;\n this.config = getConfig(options, this);\n\n this.channels = Factory.createChannels();\n this.global_emitter = new EventsDispatcher();\n this.sessionID = Runtime.randomInt(1000000000);\n\n this.timeline = new Timeline(this.key, this.sessionID, {\n cluster: this.config.cluster,\n features: Pusher.getClientFeatures(),\n params: this.config.timelineParams || {},\n limit: 50,\n level: TimelineLevel.INFO,\n version: Defaults.VERSION\n });\n if (this.config.enableStats) {\n this.timelineSender = Factory.createTimelineSender(this.timeline, {\n host: this.config.statsHost,\n path: '/timeline/v2/' + Runtime.TimelineTransport.name\n });\n }\n\n var getStrategy = (options: StrategyOptions) => {\n return Runtime.getDefaultStrategy(this.config, options, defineTransport);\n };\n\n this.connection = Factory.createConnectionManager(this.key, {\n getStrategy: getStrategy,\n timeline: this.timeline,\n activityTimeout: this.config.activityTimeout,\n pongTimeout: this.config.pongTimeout,\n unavailableTimeout: this.config.unavailableTimeout,\n useTLS: Boolean(this.config.useTLS)\n });\n\n this.connection.bind('connected', () => {\n this.subscribeAll();\n if (this.timelineSender) {\n this.timelineSender.send(this.connection.isUsingTLS());\n }\n });\n\n this.connection.bind('message', event => {\n var eventName = event.event;\n var internal = eventName.indexOf('pusher_internal:') === 0;\n if (event.channel) {\n var channel = this.channel(event.channel);\n if (channel) {\n channel.handleEvent(event);\n }\n }\n // Emit globally [deprecated]\n if (!internal) {\n this.global_emitter.emit(event.event, event.data);\n }\n });\n this.connection.bind('connecting', () => {\n this.channels.disconnect();\n });\n this.connection.bind('disconnected', () => {\n this.channels.disconnect();\n });\n this.connection.bind('error', err => {\n Logger.warn(err);\n });\n\n Pusher.instances.push(this);\n this.timeline.info({ instances: Pusher.instances.length });\n\n this.user = new UserFacade(this);\n\n if (Pusher.isReady) {\n this.connect();\n }\n }\n\n /**\n * Allows you to switch Pusher cluster without\n * losing all the channels/subscription binding\n * as this is internally managed by the SDK.\n */\n switchCluster(options: ClusterOptions) {\n const { appKey, cluster } = options;\n this.key = appKey;\n this.options = { ...this.options, cluster };\n this.config = getConfig(this.options, this);\n this.connection.switchCluster(this.key);\n }\n\n channel(name: string): Channel {\n return this.channels.find(name);\n }\n\n allChannels(): Channel[] {\n return this.channels.all();\n }\n\n connect() {\n this.connection.connect();\n\n if (this.timelineSender) {\n if (!this.timelineSenderTimer) {\n var usingTLS = this.connection.isUsingTLS();\n var timelineSender = this.timelineSender;\n this.timelineSenderTimer = new PeriodicTimer(60000, function() {\n timelineSender.send(usingTLS);\n });\n }\n }\n }\n\n disconnect() {\n this.connection.disconnect();\n\n if (this.timelineSenderTimer) {\n this.timelineSenderTimer.ensureAborted();\n this.timelineSenderTimer = null;\n }\n }\n\n bind(event_name: string, callback: Function, context?: any): Pusher {\n this.global_emitter.bind(event_name, callback, context);\n return this;\n }\n\n unbind(event_name?: string, callback?: Function, context?: any): Pusher {\n this.global_emitter.unbind(event_name, callback, context);\n return this;\n }\n\n bind_global(callback: Function): Pusher {\n this.global_emitter.bind_global(callback);\n return this;\n }\n\n unbind_global(callback?: Function): Pusher {\n this.global_emitter.unbind_global(callback);\n return this;\n }\n\n unbind_all(callback?: Function): Pusher {\n this.global_emitter.unbind_all();\n return this;\n }\n\n subscribeAll() {\n var channelName;\n for (channelName in this.channels.channels) {\n if (this.channels.channels.hasOwnProperty(channelName)) {\n this.subscribe(channelName);\n }\n }\n }\n\n subscribe(channel_name: string) {\n var channel = this.channels.add(channel_name, this);\n if (channel.subscriptionPending && channel.subscriptionCancelled) {\n channel.reinstateSubscription();\n } else if (\n !channel.subscriptionPending &&\n this.connection.state === 'connected'\n ) {\n channel.subscribe();\n }\n return channel;\n }\n\n unsubscribe(channel_name: string) {\n var channel = this.channels.find(channel_name);\n if (channel && channel.subscriptionPending) {\n channel.cancelSubscription();\n } else {\n channel = this.channels.remove(channel_name);\n if (channel && channel.subscribed) {\n channel.unsubscribe();\n }\n }\n }\n\n send_event(event_name: string, data: any, channel?: string) {\n return this.connection.send_event(event_name, data, channel);\n }\n\n shouldUseTLS(): boolean {\n return this.config.useTLS;\n }\n\n signin() {\n this.user.signin();\n }\n}\n\nfunction checkAppKey(key) {\n if (key === null || key === undefined) {\n throw 'You must pass your app key when you instantiate Pusher.';\n }\n}\n\nRuntime.setup(Pusher);\n","import ConnectionManager from './connection/connection_manager';\nimport {\n ChannelAuthorizationOptions,\n UserAuthenticationOptions\n} from './auth/options';\nimport {\n ChannelAuthorizerGenerator,\n DeprecatedAuthOptions\n} from './auth/deprecated_channel_authorizer';\nimport { AuthTransport, Transport } from './config';\nimport * as nacl from 'tweetnacl';\nimport Logger from './logger';\n\nexport interface Options {\n activityTimeout?: number;\n\n auth?: DeprecatedAuthOptions; // DEPRECATED use channelAuthorization instead\n authEndpoint?: string; // DEPRECATED use channelAuthorization instead\n authTransport?: AuthTransport; // DEPRECATED use channelAuthorization instead\n authorizer?: ChannelAuthorizerGenerator; // DEPRECATED use channelAuthorization instead\n\n channelAuthorization?: ChannelAuthorizationOptions;\n userAuthentication?: UserAuthenticationOptions;\n\n cluster: string;\n enableStats?: boolean;\n disableStats?: boolean;\n disabledTransports?: Transport[];\n enabledTransports?: Transport[];\n forceTLS?: boolean;\n httpHost?: string;\n httpPath?: string;\n httpPort?: number;\n httpsPort?: number;\n ignoreNullOrigin?: boolean;\n nacl?: nacl;\n pongTimeout?: number;\n statsHost?: string;\n timelineParams?: any;\n unavailableTimeout?: number;\n wsHost?: string;\n wsPath?: string;\n wsPort?: number;\n wssPort?: number;\n}\n\nexport interface ClusterOptions {\n appKey: string;\n cluster: string;\n}\n\nexport function validateOptions(options) {\n if (options == null) {\n throw 'You must pass an options object';\n }\n if (options.cluster == null) {\n throw 'Options object must provide a cluster';\n }\n if ('disableStats' in options) {\n Logger.warn(\n 'The disableStats option is deprecated in favor of enableStats'\n );\n }\n}\n"],"sourceRoot":""} \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index b7ea0c54c..888e0e6e6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "pusher-js", - "version": "8.3.0", + "version": "8.4.0-rc1", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "pusher-js", - "version": "8.3.0", + "version": "8.4.0-rc1", "license": "MIT", "dependencies": { "tweetnacl": "^1.0.3" diff --git a/package.json b/package.json index 1c3203033..bb331796a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "pusher-js", - "version": "8.4.0", + "version": "8.4.0-rc1", "description": "Pusher Channels JavaScript library for browsers, React Native, NodeJS and web workers", "main": "dist/node/pusher.js", "browser": "dist/web/pusher.js", From 504e77f9a5cd9abdeab0ed6d605d088da4586e31 Mon Sep 17 00:00:00 2001 From: Meena Alfons Date: Wed, 29 Nov 2023 09:48:27 +0100 Subject: [PATCH 05/15] Enable release on rc tags --- .github/workflows/release.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index ee71ea573..46347f40d 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,6 +1,9 @@ on: push: branches: [ master ] + tags: + # Pushing a tag that starts with v and ends with rc will trigger a release + - v*rc jobs: check-release-tag: From c84c7107afea4cad68abb83b4ca9835a701267f3 Mon Sep 17 00:00:00 2001 From: Meena Alfons Date: Wed, 29 Nov 2023 10:15:35 +0100 Subject: [PATCH 06/15] Fix changelog to say 8.4.0-rc1 --- CHANGELOG.md | 44 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c9058fa85..8232ce385 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,33 +1,33 @@ -# Changelog - -## 8.4.0 - +# Changelog + +## 8.4.0-rc1 + - [Added] Introduce a new method to switch the Pusher client to a different cluster and re-establish all existing subscriptions and channel bindings. - -## 8.3.0 - + +## 8.3.0 + - [CHANGED] Update cached re-connect strategy to prioritize WebSocket - -## 8.2.0 - + +## 8.2.0 + - [CHANGED] Remove WebSocket retry limit. - -## 8.1.0 - + +## 8.1.0 + - [CHANGED] Move @types dependencies to devDependencies - [CHANGED] Upgrade typescript to 5.1.3 - -## 8.0.2 - + +## 8.0.2 + - [CHANGED] Fix React Native support. - -## 8.0.1 - + +## 8.0.1 + - [FIXED] Fix 'window is not defined' error in the worker context - [FIXED] Specify the right status when an error is thrown for the pusher worker instance - -## 8.0.0 - + +## 8.0.0 + - [CHANGED] Specifying a cluster when instantiating the Pusher object is now mandatory. An exception is thrown if the cluster setting is missing. ## 7.6.0 From 5f5f367266075ff17013f6edb4347e8dce8c4378 Mon Sep 17 00:00:00 2001 From: Meena Alfons Date: Wed, 29 Nov 2023 13:39:16 +0100 Subject: [PATCH 07/15] Fix integration tests by running HTTP tests before HTTPS --- spec/javascripts/integration/index.web.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/spec/javascripts/integration/index.web.js b/spec/javascripts/integration/index.web.js index 0540ee022..7f72c86f7 100644 --- a/spec/javascripts/integration/index.web.js +++ b/spec/javascripts/integration/index.web.js @@ -59,5 +59,19 @@ function getTestConfigs() { testConfigs.push({ transport: "sockjs", forceTLS: true}) testConfigs.push({ transport: "sockjs", forceTLS: false}) } + + // Test all forceTLS: false before forceTLS: true + // Because browsers prevent a URL from downgrading from HTTPS to HTTP + // This is probably the result of Strict-Transport-Security header returned when calling the HTTPS endpoint. + testConfigs.sort((a, b) => { + if (a.forceTLS == false && b.forceTLS == true) { + return -1; + } else if (a.forceTLS == true && b.forceTLS == false) { + return 1; + } else { + return 0; + } + }) + return testConfigs } From 37f784c3fe764bdd37fa121c5beb1b6cf94741bf Mon Sep 17 00:00:00 2001 From: Meena Alfons Date: Wed, 29 Nov 2023 14:40:06 +0100 Subject: [PATCH 08/15] Run release on tags like v*-rc* --- .github/workflows/release.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 46347f40d..16e2ba7e7 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -2,8 +2,8 @@ on: push: branches: [ master ] tags: - # Pushing a tag that starts with v and ends with rc will trigger a release - - v*rc + # Pushing a tag that starts with v and has -rc in the middle will trigger a release + - v*-rc* jobs: check-release-tag: From 211370c1547024317ef8cd671231f84654bba76e Mon Sep 17 00:00:00 2001 From: Meena Alfons Date: Wed, 29 Nov 2023 14:52:41 +0100 Subject: [PATCH 09/15] Deploy release on labeled PR deploy-release --- .github/workflows/release.yml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 16e2ba7e7..e9c9e05f7 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,12 +1,13 @@ on: push: - branches: [ master ] - tags: - # Pushing a tag that starts with v and has -rc in the middle will trigger a release - - v*-rc* + types: [ labeled ] + branches: + - master + - releases/* jobs: check-release-tag: + if: ${{ github.event.label.name == 'deploy-release' }} runs-on: ubuntu-latest steps: - name: Checkout code From 5498e430e296b322bc6d374d4f1f8df021f289af Mon Sep 17 00:00:00 2001 From: Meena Alfons Date: Wed, 29 Nov 2023 15:02:45 +0100 Subject: [PATCH 10/15] Another fix for workflow trigger --- .github/workflows/release.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index e9c9e05f7..0026bd95a 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,9 +1,10 @@ on: push: + branches: [ master ] + pull_request: types: [ labeled ] - branches: - - master - - releases/* + branches: + - master jobs: check-release-tag: From de375430e0cad0f67f1afa975b29e4b152b8fbec Mon Sep 17 00:00:00 2001 From: Meena Alfons Date: Wed, 29 Nov 2023 15:09:52 +0100 Subject: [PATCH 11/15] One more fix to workflow. --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 0026bd95a..d83f5cb3f 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -8,7 +8,7 @@ on: jobs: check-release-tag: - if: ${{ github.event.label.name == 'deploy-release' }} + if: ${{ github.head_ref == 'master' || github.event.label.name == 'deploy-release' }} runs-on: ubuntu-latest steps: - name: Checkout code From 3fc566ea7d0c65acbcef6781b52079e519248d62 Mon Sep 17 00:00:00 2001 From: Kamal Bennani Date: Wed, 29 Nov 2023 23:00:12 +0100 Subject: [PATCH 12/15] fix: persist previous options --- spec/javascripts/unit/core/pusher_spec.js | 17 +++++++++++++++++ src/core/pusher.ts | 3 ++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/spec/javascripts/unit/core/pusher_spec.js b/spec/javascripts/unit/core/pusher_spec.js index 28cfd73f9..6993243ad 100644 --- a/spec/javascripts/unit/core/pusher_spec.js +++ b/spec/javascripts/unit/core/pusher_spec.js @@ -346,6 +346,23 @@ describe("Pusher", function() { "channel" ); }); + + it('should keep the persist the previous options', () => { + var authorizeSpy = jasmine.createSpy("authorizeSpy"); + const options = { + cluster: "mt1", + enableStats: true, + channelAuthorization: { + customHandler: authorizeSpy + } + }; + + var pusher = new Pusher("foo", options); + pusher.connect(); + pusher.switchCluster({ appKey: 'bar', cluster: 'us3' }); + + expect(pusher.options).toEqual({ ...options, cluster: 'us3' }); + }) }) describe("#unsubscribe", function() { diff --git a/src/core/pusher.ts b/src/core/pusher.ts index b1ffc8ed1..19d48ef96 100644 --- a/src/core/pusher.ts +++ b/src/core/pusher.ts @@ -63,7 +63,8 @@ export default class Pusher { checkAppKey(app_key); validateOptions(options); this.key = app_key; - this.config = getConfig(options, this); + this.options = options; + this.config = getConfig(this.options, this); this.channels = Factory.createChannels(); this.global_emitter = new EventsDispatcher(); From f59dac48c29c7db0a1f855aaa9bed9cecd40c553 Mon Sep 17 00:00:00 2001 From: Kamal Bennani Date: Wed, 29 Nov 2023 23:05:41 +0100 Subject: [PATCH 13/15] fix(typing): fix misleading authorizer typing --- src/core/auth/options.ts | 18 ++++++---------- src/core/config.ts | 37 +++++++++++++++++++------------- types/src/core/auth/options.d.ts | 15 +++++-------- 3 files changed, 34 insertions(+), 36 deletions(-) diff --git a/src/core/auth/options.ts b/src/core/auth/options.ts index 26bf62c86..da0eaf295 100644 --- a/src/core/auth/options.ts +++ b/src/core/auth/options.ts @@ -51,28 +51,24 @@ export type AuthTransportCallback = | ChannelAuthorizationCallback | UserAuthenticationCallback; -export interface AuthOptionsT { +export interface InternalAuthOptions { transport: 'ajax' | 'jsonp'; endpoint: string; params?: any; headers?: any; paramsProvider?: () => any; headersProvider?: () => any; - customHandler?: AuthHandler; } +export type CustomAuthOptions = { + customHandler: AuthHandler; +} + +export type AuthOptionsT = InternalAuthOptions | CustomAuthOptions + export declare type UserAuthenticationOptions = AuthOptionsT< UserAuthenticationHandler >; export declare type ChannelAuthorizationOptions = AuthOptionsT< ChannelAuthorizationHandler >; - -export interface InternalAuthOptions { - transport: 'ajax' | 'jsonp'; - endpoint: string; - params?: any; - headers?: any; - paramsProvider?: () => any; - headersProvider?: () => any; -} diff --git a/src/core/config.ts b/src/core/config.ts index e5860f3c9..acfa5df83 100644 --- a/src/core/config.ts +++ b/src/core/config.ts @@ -3,7 +3,9 @@ import Defaults from './defaults'; import { ChannelAuthorizationHandler, UserAuthenticationHandler, - ChannelAuthorizationOptions + ChannelAuthorizationOptions, + AuthOptionsT, + CustomAuthOptions } from './auth/options'; import UserAuthenticator from './auth/user_authenticator'; import ChannelAuthorizer from './auth/channel_authorizer'; @@ -131,15 +133,17 @@ function getEnableStatsConfig(opts: Options): boolean { return false; } +const hasCustomHandler = (auth: AuthOptionsT): auth is CustomAuthOptions => { + return 'customHandler' in auth && auth['customHandler'] != null; +} + function buildUserAuthenticator(opts: Options): UserAuthenticationHandler { const userAuthentication = { ...Defaults.userAuthentication, ...opts.userAuthentication }; - if ( - 'customHandler' in userAuthentication && - userAuthentication['customHandler'] != null - ) { + + if (hasCustomHandler(userAuthentication)) { return userAuthentication['customHandler']; } @@ -158,17 +162,22 @@ function buildChannelAuth(opts: Options, pusher): ChannelAuthorizationOptions { transport: opts.authTransport || Defaults.authTransport, endpoint: opts.authEndpoint || Defaults.authEndpoint }; + if ('auth' in opts) { if ('params' in opts.auth) channelAuthorization.params = opts.auth.params; if ('headers' in opts.auth) channelAuthorization.headers = opts.auth.headers; } - if ('authorizer' in opts) - channelAuthorization.customHandler = ChannelAuthorizerProxy( - pusher, - channelAuthorization, - opts.authorizer - ); + + if ('authorizer' in opts) { + return { + customHandler: ChannelAuthorizerProxy( + pusher, + channelAuthorization, + opts.authorizer + ) + } + } } return channelAuthorization; } @@ -178,10 +187,8 @@ function buildChannelAuthorizer( pusher ): ChannelAuthorizationHandler { const channelAuthorization = buildChannelAuth(opts, pusher); - if ( - 'customHandler' in channelAuthorization && - channelAuthorization['customHandler'] != null - ) { + + if (hasCustomHandler(channelAuthorization)) { return channelAuthorization['customHandler']; } diff --git a/types/src/core/auth/options.d.ts b/types/src/core/auth/options.d.ts index 5ff6deef3..a82e6bf8f 100644 --- a/types/src/core/auth/options.d.ts +++ b/types/src/core/auth/options.d.ts @@ -27,22 +27,17 @@ export interface UserAuthenticationHandler { (params: UserAuthenticationRequestParams, callback: UserAuthenticationCallback): void; } export type AuthTransportCallback = ChannelAuthorizationCallback | UserAuthenticationCallback; -export interface AuthOptionsT { +export interface InternalAuthOptions { transport: 'ajax' | 'jsonp'; endpoint: string; params?: any; headers?: any; paramsProvider?: () => any; headersProvider?: () => any; - customHandler?: AuthHandler; } +export type CustomAuthOptions = { + customHandler: AuthHandler; +}; +export type AuthOptionsT = InternalAuthOptions | CustomAuthOptions; export declare type UserAuthenticationOptions = AuthOptionsT; export declare type ChannelAuthorizationOptions = AuthOptionsT; -export interface InternalAuthOptions { - transport: 'ajax' | 'jsonp'; - endpoint: string; - params?: any; - headers?: any; - paramsProvider?: () => any; - headersProvider?: () => any; -} From 0a788cc2c4c5d7d726a246ce18872dbc0e16b5d7 Mon Sep 17 00:00:00 2001 From: Meena Alfons Date: Fri, 1 Dec 2023 15:00:13 +0100 Subject: [PATCH 14/15] npm run format --- src/core/auth/options.ts | 6 ++++-- src/core/config.ts | 10 ++++++---- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/core/auth/options.ts b/src/core/auth/options.ts index da0eaf295..530f42ccf 100644 --- a/src/core/auth/options.ts +++ b/src/core/auth/options.ts @@ -62,9 +62,11 @@ export interface InternalAuthOptions { export type CustomAuthOptions = { customHandler: AuthHandler; -} +}; -export type AuthOptionsT = InternalAuthOptions | CustomAuthOptions +export type AuthOptionsT = + | InternalAuthOptions + | CustomAuthOptions; export declare type UserAuthenticationOptions = AuthOptionsT< UserAuthenticationHandler diff --git a/src/core/config.ts b/src/core/config.ts index acfa5df83..d3b367d5b 100644 --- a/src/core/config.ts +++ b/src/core/config.ts @@ -133,9 +133,11 @@ function getEnableStatsConfig(opts: Options): boolean { return false; } -const hasCustomHandler = (auth: AuthOptionsT): auth is CustomAuthOptions => { - return 'customHandler' in auth && auth['customHandler'] != null; -} +const hasCustomHandler = ( + auth: AuthOptionsT +): auth is CustomAuthOptions => { + return 'customHandler' in auth && auth['customHandler'] != null; +}; function buildUserAuthenticator(opts: Options): UserAuthenticationHandler { const userAuthentication = { @@ -176,7 +178,7 @@ function buildChannelAuth(opts: Options, pusher): ChannelAuthorizationOptions { channelAuthorization, opts.authorizer ) - } + }; } } return channelAuthorization; From 5c4c47435b2d9df38c3e3c4b4c1e7332f7544875 Mon Sep 17 00:00:00 2001 From: Meena Alfons Date: Fri, 1 Dec 2023 15:11:59 +0100 Subject: [PATCH 15/15] Build v8.4.0-rc2 --- CHANGELOG.md | 5 ++++ dist/node/pusher.js | 23 +++++++++++-------- dist/node/pusher.js.map | 2 +- dist/react-native/pusher.js | 4 ++-- dist/react-native/pusher.js.map | 2 +- dist/web/pusher-with-encryption.js | 23 +++++++++++-------- dist/web/pusher-with-encryption.js.map | 2 +- dist/web/pusher-with-encryption.min.js | 4 ++-- dist/web/pusher-with-encryption.min.js.map | 2 +- dist/web/pusher.js | 23 +++++++++++-------- dist/web/pusher.js.map | 2 +- dist/web/pusher.min.js | 4 ++-- dist/web/pusher.min.js.map | 2 +- dist/worker/pusher-with-encryption.worker.js | 23 +++++++++++-------- .../pusher-with-encryption.worker.js.map | 2 +- .../pusher-with-encryption.worker.min.js | 4 ++-- .../pusher-with-encryption.worker.min.js.map | 2 +- dist/worker/pusher.worker.js | 23 +++++++++++-------- dist/worker/pusher.worker.js.map | 2 +- dist/worker/pusher.worker.min.js | 4 ++-- dist/worker/pusher.worker.min.js.map | 2 +- package-lock.json | 4 ++-- package.json | 2 +- 23 files changed, 98 insertions(+), 68 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8232ce385..03b3cbe31 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Changelog +## 8.4.0-rc2 + +- [FIXED] Persist Initial Pusher Options +- [FIXED] Authorization Custom Handler typing https://github.com/pusher/pusher-js/issues/715 + ## 8.4.0-rc1 - [Added] Introduce a new method to switch the Pusher client to a different cluster and re-establish all existing subscriptions and channel bindings. diff --git a/dist/node/pusher.js b/dist/node/pusher.js index 21d7bc74c..09da9b9be 100644 --- a/dist/node/pusher.js +++ b/dist/node/pusher.js @@ -1,5 +1,5 @@ /*! - * Pusher JavaScript Library v8.4.0-rc1 + * Pusher JavaScript Library v8.4.0-rc2 * https://pusher.com/ * * Copyright 2020, Pusher @@ -7499,7 +7499,7 @@ function safeJSONStringify(source) { // CONCATENATED MODULE: ./src/core/defaults.ts var Defaults = { - VERSION: "8.4.0-rc1", + VERSION: "8.4.0-rc2", PROTOCOL: 7, wsPort: 80, wssPort: 443, @@ -10448,10 +10448,12 @@ function getEnableStatsConfig(opts) { } return false; } +const hasCustomHandler = (auth) => { + return 'customHandler' in auth && auth['customHandler'] != null; +}; function buildUserAuthenticator(opts) { const userAuthentication = Object.assign(Object.assign({}, defaults.userAuthentication), opts.userAuthentication); - if ('customHandler' in userAuthentication && - userAuthentication['customHandler'] != null) { + if (hasCustomHandler(userAuthentication)) { return userAuthentication['customHandler']; } return user_authenticator(userAuthentication); @@ -10472,15 +10474,17 @@ function buildChannelAuth(opts, pusher) { if ('headers' in opts.auth) channelAuthorization.headers = opts.auth.headers; } - if ('authorizer' in opts) - channelAuthorization.customHandler = ChannelAuthorizerProxy(pusher, channelAuthorization, opts.authorizer); + if ('authorizer' in opts) { + return { + customHandler: ChannelAuthorizerProxy(pusher, channelAuthorization, opts.authorizer) + }; + } } return channelAuthorization; } function buildChannelAuthorizer(opts, pusher) { const channelAuthorization = buildChannelAuth(opts, pusher); - if ('customHandler' in channelAuthorization && - channelAuthorization['customHandler'] != null) { + if (hasCustomHandler(channelAuthorization)) { return channelAuthorization['customHandler']; } return channel_authorizer(channelAuthorization); @@ -10687,7 +10691,8 @@ class pusher_Pusher { checkAppKey(app_key); validateOptions(options); this.key = app_key; - this.config = getConfig(options, this); + this.options = options; + this.config = getConfig(this.options, this); this.channels = factory.createChannels(); this.global_emitter = new dispatcher_Dispatcher(); this.sessionID = node_runtime.randomInt(1000000000); diff --git a/dist/node/pusher.js.map b/dist/node/pusher.js.map index 3402c0cc7..9bd914ed8 100644 --- a/dist/node/pusher.js.map +++ b/dist/node/pusher.js.map @@ -1 +1 @@ -{"version":3,"sources":["webpack://Pusher/webpack/bootstrap","webpack://Pusher/external \"util\"","webpack://Pusher/./node_modules/safe-buffer/index.js","webpack://Pusher/./node_modules/websocket-driver/lib/websocket/driver/base.js","webpack://Pusher/external \"crypto\"","webpack://Pusher/./node_modules/websocket-driver/lib/websocket/driver.js","webpack://Pusher/external \"stream\"","webpack://Pusher/external \"url\"","webpack://Pusher/./node_modules/faye-websocket/lib/faye/websocket/api/event.js","webpack://Pusher/./node_modules/@stablelib/base64/base64.ts","webpack://Pusher/./node_modules/websocket-driver/lib/websocket/driver/headers.js","webpack://Pusher/./node_modules/websocket-driver/lib/websocket/http_parser.js","webpack://Pusher/./node_modules/faye-websocket/lib/faye/websocket/api.js","webpack://Pusher/./node_modules/websocket-driver/lib/websocket/driver/hybi.js","webpack://Pusher/./node_modules/websocket-extensions/lib/pipeline/ring_buffer.js","webpack://Pusher/./node_modules/websocket-extensions/lib/pipeline/pledge.js","webpack://Pusher/./node_modules/websocket-driver/lib/websocket/driver/draft75.js","webpack://Pusher/./node_modules/faye-websocket/lib/faye/websocket/api/event_target.js","webpack://Pusher/./node_modules/@stablelib/utf8/utf8.ts","webpack://Pusher/./node_modules/faye-websocket/lib/faye/websocket.js","webpack://Pusher/./node_modules/xmlhttprequest/lib/XMLHttpRequest.js","webpack://Pusher/./node_modules/tweetnacl/nacl-fast.js","webpack://Pusher/./src/core/pusher-with-encryption.js","webpack://Pusher/external \"buffer\"","webpack://Pusher/external \"events\"","webpack://Pusher/./node_modules/websocket-driver/lib/websocket/streams.js","webpack://Pusher/./node_modules/websocket-driver/lib/websocket/driver/stream_reader.js","webpack://Pusher/./node_modules/websocket-driver/lib/websocket/driver/client.js","webpack://Pusher/./node_modules/http-parser-js/http-parser.js","webpack://Pusher/external \"assert\"","webpack://Pusher/./node_modules/websocket-extensions/lib/websocket_extensions.js","webpack://Pusher/./node_modules/websocket-extensions/lib/parser.js","webpack://Pusher/./node_modules/websocket-extensions/lib/pipeline/index.js","webpack://Pusher/./node_modules/websocket-extensions/lib/pipeline/cell.js","webpack://Pusher/./node_modules/websocket-extensions/lib/pipeline/functor.js","webpack://Pusher/./node_modules/websocket-driver/lib/websocket/driver/hybi/frame.js","webpack://Pusher/./node_modules/websocket-driver/lib/websocket/driver/hybi/message.js","webpack://Pusher/./node_modules/websocket-driver/lib/websocket/driver/proxy.js","webpack://Pusher/./node_modules/websocket-driver/lib/websocket/driver/server.js","webpack://Pusher/./node_modules/websocket-driver/lib/websocket/driver/draft76.js","webpack://Pusher/./node_modules/faye-websocket/lib/faye/websocket/client.js","webpack://Pusher/external \"net\"","webpack://Pusher/external \"tls\"","webpack://Pusher/./node_modules/faye-websocket/lib/faye/eventsource.js","webpack://Pusher/external \"child_process\"","webpack://Pusher/external \"fs\"","webpack://Pusher/external \"http\"","webpack://Pusher/external \"https\"","webpack://Pusher/./src/core/base64.ts","webpack://Pusher/./src/core/utils/timers/abstract_timer.ts","webpack://Pusher/./src/core/utils/timers/index.ts","webpack://Pusher/./src/core/util.ts","webpack://Pusher/./src/core/utils/collections.ts","webpack://Pusher/./src/core/defaults.ts","webpack://Pusher/./src/core/transports/url_schemes.ts","webpack://Pusher/./src/core/events/callback_registry.ts","webpack://Pusher/./src/core/events/dispatcher.ts","webpack://Pusher/./src/core/logger.ts","webpack://Pusher/./src/core/transports/transport_connection.ts","webpack://Pusher/./src/core/transports/transport.ts","webpack://Pusher/./src/runtimes/isomorphic/transports/transports.ts","webpack://Pusher/./src/core/transports/assistant_to_the_transport_manager.ts","webpack://Pusher/./src/core/connection/protocol/protocol.ts","webpack://Pusher/./src/core/connection/connection.ts","webpack://Pusher/./src/core/connection/handshake/index.ts","webpack://Pusher/./src/core/timeline/timeline_sender.ts","webpack://Pusher/./src/core/errors.ts","webpack://Pusher/./src/core/utils/url_store.ts","webpack://Pusher/./src/core/channels/channel.ts","webpack://Pusher/./src/core/channels/private_channel.ts","webpack://Pusher/./src/core/channels/members.ts","webpack://Pusher/./src/core/channels/presence_channel.ts","webpack://Pusher/./src/core/channels/encrypted_channel.ts","webpack://Pusher/./src/core/connection/connection_manager.ts","webpack://Pusher/./src/core/channels/channels.ts","webpack://Pusher/./src/core/utils/factory.ts","webpack://Pusher/./src/core/transports/transport_manager.ts","webpack://Pusher/./src/core/strategies/sequential_strategy.ts","webpack://Pusher/./src/core/strategies/best_connected_ever_strategy.ts","webpack://Pusher/./src/core/strategies/websocket_prioritized_cached_strategy.ts","webpack://Pusher/./src/core/strategies/delayed_strategy.ts","webpack://Pusher/./src/core/strategies/if_strategy.ts","webpack://Pusher/./src/core/strategies/first_connected_strategy.ts","webpack://Pusher/./src/runtimes/isomorphic/default_strategy.ts","webpack://Pusher/./src/runtimes/isomorphic/transports/transport_connection_initializer.ts","webpack://Pusher/./src/core/http/http_request.ts","webpack://Pusher/./src/core/http/state.ts","webpack://Pusher/./src/core/http/http_socket.ts","webpack://Pusher/./src/core/http/http_streaming_socket.ts","webpack://Pusher/./src/core/http/http_polling_socket.ts","webpack://Pusher/./src/runtimes/isomorphic/http/http_xhr_request.ts","webpack://Pusher/./src/runtimes/isomorphic/http/http.ts","webpack://Pusher/./src/runtimes/isomorphic/runtime.ts","webpack://Pusher/./src/runtimes/node/net_info.ts","webpack://Pusher/./src/core/auth/options.ts","webpack://Pusher/./src/runtimes/isomorphic/auth/xhr_auth.ts","webpack://Pusher/./src/runtimes/isomorphic/timeline/xhr_timeline.ts","webpack://Pusher/./src/runtimes/node/runtime.ts","webpack://Pusher/./src/core/timeline/level.ts","webpack://Pusher/./src/core/timeline/timeline.ts","webpack://Pusher/./src/core/strategies/transport_strategy.ts","webpack://Pusher/./src/core/strategies/strategy_builder.ts","webpack://Pusher/./src/core/options.ts","webpack://Pusher/./src/core/auth/user_authenticator.ts","webpack://Pusher/./src/core/auth/channel_authorizer.ts","webpack://Pusher/./src/core/auth/deprecated_channel_authorizer.ts","webpack://Pusher/./src/core/config.ts","webpack://Pusher/./src/core/watchlist.ts","webpack://Pusher/./src/core/utils/flat_promise.ts","webpack://Pusher/./src/core/user.ts","webpack://Pusher/./src/core/pusher.ts","webpack://Pusher/./src/core/pusher-with-encryption.ts"],"names":[],"mappings":";;;;;;;;;;QAAA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;;QAEA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;;;QAGA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;QACA,0CAA0C,gCAAgC;QAC1E;QACA;;QAEA;QACA;QACA;QACA,wDAAwD,kBAAkB;QAC1E;QACA,iDAAiD,cAAc;QAC/D;;QAEA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA,yCAAyC,iCAAiC;QAC1E,gHAAgH,mBAAmB,EAAE;QACrI;QACA;;QAEA;QACA;QACA;QACA,2BAA2B,0BAA0B,EAAE;QACvD,iCAAiC,eAAe;QAChD;QACA;QACA;;QAEA;QACA,sDAAsD,+DAA+D;;QAErH;QACA;;;QAGA;QACA;;;;;;;AClFA,iC;;;;;;ACAA;AACA,aAAa,mBAAO,CAAC,EAAQ;AAC7B;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AACD;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;;;;;;;AC7Da;;AAEb,cAAc,mBAAO,CAAC,CAAa;AACnC,cAAc,mBAAO,CAAC,EAAQ;AAC9B,cAAc,mBAAO,CAAC,CAAM;AAC5B,cAAc,mBAAO,CAAC,EAAY;AAClC,cAAc,mBAAO,CAAC,CAAW;AACjC,cAAc,mBAAO,CAAC,EAAiB;;AAEvC;AACA;AACA,oCAAoC;;AAEpC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA,2CAA2C;;AAE3C;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA,KAAK;AACL,GAAG;;AAEH;AACA;AACA,GAAG;;AAEH;AACA;AACA,GAAG;;AAEH;AACA;AACA;A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AAa,GAAG,UAAC,CAAS;IACnC,eAAQ,CAAC,aAAa,CAAC,CAAC,CAAC;AAAzB,CAAyB,CAAC;;;;;;;;AC1RjB;;AAEb;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;;;;;;;;AClCa;;AAEb,qBAAqB,mBAAO,CAAC,EAAgB;AAC7C,qBAAqB,mBAAO,CAAC,CAAa;;AAE1C;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;;AAEA,mDAAmD,OAAO;AAC1D;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,sDAAsD,yBAAyB;AAC/E;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;;;;;;;;ACtIa;;AAEb,kBAAkB,mBAAO,CAAC,CAAQ;AAClC,kBAAkB,mBAAO,CAAC,CAAM;AAChC,kBAAkB,mBAAO,CAAC,CAAkB;AAC5C,kBAAkB,mBAAO,CAAC,EAAoB;AAC9C,kBAAkB,mBAAO,CAAC,CAAa;;AAEvC;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;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EA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA;AACA,+CAA+C,mCAAmC;AAClF;;AAEA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;;AAEA,8CAA8C,OAAO;AACrD;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA;;AAEA;AACA,8GAA8G,EAAE,uDAAuD,EAAE,wBAAwB,EAAE,4BAA4B,EAAE;;AAEjO;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA,yCAAyC,oCAAoC;AAC7E;AACA,KAAK;AACL;AACA;AACA,GAAG;;AAEH;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;;AAEA;AACA,GAAG;;AAEH;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,KAAK;AACL;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;AACA,GAAG;;AAEH;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA,GAAG;;AAEH;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL,GAAG;;AAEH;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA,KAAK;;AAEL;;AAEA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;;AAEA;AACA;AACA,GAAG;;AAEH;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA,GAAG;;AAEH;AACA;;AAEA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA,GAAG;;AAEH;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA,KAAK;AACL,GAAG;;AAEH;AACA;AACA;AACA;AACA,KAAK;AACL;AACA,GAAG;;AAEH;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;;;;;;;;AClea;;AAEb;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA,GAAG;AACH;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;;AAEA;;;;;;;;ACjEa;;AAEb,iBAAiB,mBAAO,CAAC,EAAe;;AAExC;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA,GAAG;AACH;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;;;;;;;;ACpCa;;AAEb,aAAa,mBAAO,CAAC,CAAa;AAClC,aAAa,mBAAO,CAAC,CAAQ;AAC7B,aAAa,mBAAO,CAAC,CAAM;;AAE3B;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;;AAEH;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa;AACb;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL,GAAG;;AAEH;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA,GAAG;;AAEH;AACA;AACA;;AAEA;AACA,GAAG;;AAEH;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;;;;;;;;AC1Ha;;AAEb,YAAY,mBAAO,CAAC,CAAS;;AAE7B;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,GAAG;;AAEH;AACA;AACA,GAAG;;AAEH;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;;;;;;;;;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AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,WAAW;AACX;AACA;AACA;AACA;AACA,SAAS;AACT,OAAO;AACP;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,KAAK;AACL;;AAEA;AACA,8CAA8C;AAC9C;AACA,KAAK;AACL;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;;AAET;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;;AAET;AACA;AACA,SAAS;AACT;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;;AAEA;AACA,KAAK,OAAO;AACZ;AACA;AACA;AACA;AACA;AACA,iGAAiG;AACjG,gEAAgE;AAChE,yDAAyD;AACzD,iCAAiC;AACjC,4DAA4D;AAC5D,wCAAwC;AACxC,gDAAgD;AAChD,mCAAmC;AACnC,YAAY,EAAE;AACd,0CAA0C;AAC1C,mEAAmE,kBAAkB,gFAAgF,WAAW;AAChL,6CAA6C;AAC7C,YAAY,EAAE;AACd,iDAAiD;AACjD,mEAAmE,WAAW,WAAW;AACzF,6CAA6C;AAC7C,YAAY,EAAE;AACd,YAAY,+BAA+B;AAC3C,mEAAmE,WAAW,WAAW;AACzF,6CAA6C;AAC7C,YAAY,EAAE;AACd,8FAA8F;AAC9F,qBAAqB;AACrB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,OAAO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,oDAAoD,SAAS;AAC7D;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;AC3mBA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,uBAAuB,iBAAiB;AACxC;AACA;;AAEA;AACA,wCAAwC,4BAA4B;;AAEpE;AACA,4BAA4B;;AAE5B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa,OAAO;AACpB;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,aAAa,QAAQ;AACrB,aAAa,OAAO;AACpB;AACA;AACA,eAAe,QAAQ;AACvB;AACA,eAAe,QAAQ;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB;AACA;AACA;;AAEA;AACA;AACA;AACA,aAAa,QAAQ;AACrB,aAAa,OAAO;AACpB;AACA;AACA,eAAe,QAAQ;AACvB;AACA,eAAe,QAAQ;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,iBAAiB,OAAO;AACxB;AACA;;AAEA;AACA;AACA;AACA;AACA,iBAAiB,OAAO;AACxB;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA,8CAA8C;AAC9C,8CAA8C;AAC9C,8CAA8C;AAC9C,8CAA8C;AAC9C,8CAA8C;AAC9C;AACA,8CAA8C;AAC9C,8CAA8C;AAC9C,8CAA8C;AAC9C;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,sDAAsD;AACtD,sDAAsD;AACtD,sDAAsD;AACtD,sDAAsD;AACtD,sDAAsD;AACtD;AACA,sDAAsD;AACtD,sDAAsD;AACtD,sDAAsD;AACtD;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA,qBAAqB;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA,qBAAqB;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA,qBAAqB;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA,qBAAqB;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA,qBAAqB;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA,qBAAqB;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA,qBAAqB;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA,qBAAqB;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA,qBAAqB;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA,qBAAqB;;AAErB;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA,UAAU,QAAQ;AAClB;AACA;AACA;;AAEA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA;AACA;;AAEA;AACA,aAAa,QAAQ;AACrB;AACA,aAAa,QAAQ;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa,OAAO;AACpB;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,UAAU;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,eAAe,WAAW;AAC1B;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;;AAEA;AACA;AACA,aAAa,QAAQ;AACrB;;AAEA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA,aAAa,OAAO;AACpB;AACA,eAAe,QAAQ;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;;AAEA;AACA,iBAAiB,QAAQ;AACzB;;AAEA;AACA,iBAAiB,QAAQ;AACzB;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD;;AAEA;AACA;AACA,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA,aAAa,QAAQ;AACrB,eAAe,QAAQ;AACvB;AACA;AACA;AACA,aAAa,QAAQ;AACrB;;AAEA;AACA;AACA;AACA,aAAa,QAAQ;AACrB,eAAe,QAAQ;AACvB;AACA;AACA;AACA,aAAa,QAAQ;AACrB;;AAEA;AACA;AACA;AACA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA;AACA,aAAa,MAAM;AACnB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,eAAe,QAAQ;AACvB;AACA;AACA;AACA;AACA,eAAe,QAAQ;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA,qBAAqB;AACrB,qBAAqB;;AAErB;AACA;AACA;;AAEA,sBAAsB;AACtB,sBAAsB;;AAEtB;AACA;AACA;;AAEA,sBAAsB;AACtB,sBAAsB;;AAEtB;AACA;AACA;;AAEA,sBAAsB;AACtB,sBAAsB;;AAEtB;AACA;AACA;;AAEA,sBAAsB;AACtB,sBAAsB;;AAEtB;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA,qBAAqB;AACrB,qBAAqB;;AAErB;AACA;AACA;;AAEA,sBAAsB;AACtB,sBAAsB;;AAEtB;AACA;AACA;;AAEA,sBAAsB;AACtB,sBAAsB;;AAEtB;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA,qBAAqB;AACrB,qBAAqB;;AAErB;AACA;;AAEA,sBAAsB;AACtB,sBAAsB;;AAEtB;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,mBAAmB,QAAQ;AAC3B;AACA;AACA;;AAEA,yBAAyB;AACzB,yBAAyB;;AAEzB;AACA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AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA,aAAa,OAAO;AACpB;;AAEA;AACA;AACA;AACA;;AAEA,aAAa,OAAO;;AAEpB;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa,OAAO;AACpB;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,QAAQ;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA,aAAa,QAAQ;AACrB;AACA;;AAEA;;AAEA;AACA;AACA,cAAc,SAAS;AACvB;AACA,gCAAgC,OAAO;AACvC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA;AACA,aAAa,QAAQ;AACrB,aAAa,QAAQ;AACrB;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa,QAAQ;AACrB,aAAa,QAAQ;AACrB;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA,aAAa,OAAO;AACpB,aAAa,QAAQ;;AAErB;AACA;AACA;AACA;;AAEA,cAAc,QAAQ;AACtB;AACA;;AAEA,aAAa,QAAQ;AACrB,aAAa,QAAQ;AACrB,aAAa,QAAQ;AACrB,eAAe,QAAQ;AACvB;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;;AAEA,aAAa,OAAO;AACpB,aAAa,QAAQ;AACrB;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA,eAAe,OAAO;AACtB;AACA;;AAEA,aAAa,OAAO;AACpB;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA,iBAAiB,sBAAsB;AACvC;AACA;AACA;AACA;;AAEA;AACA,iBAAiB,gBAAgB;AACjC;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,iBAAiB,gBAAgB;AACjC;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,iBAAiB,gBAAgB;AACjC;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA,UAAU;AACV;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,UAAU;AACV;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAiB,cAAc;AAC/B;AACA;;AAEA;AACA;AACA;AACA,iBAAiB,gBAAgB;AACjC;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa,uBAAuB;AACpC,aAAa,gBAAgB;AAC7B;AACA;;AAEA;AACA;AACA;AACA;AACA,UAAU;AACV;;AAEA;AACA;AACA;AACA;AACA;AACA,iBAAiB,eAAe;AAChC,UAAU;AACV;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAiB,QAAQ;AACzB;AACA,UAAU;AACV;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAiB,OAAO;AACxB;AACA;AACA,iBAAiB,OAAO;AACxB;AACA,KAAK;AACL,GAAG,UAAU,IAA8B;AAC3C;AACA,aAAa,mBAAO,CAAC,CAAQ;AAC7B;AACA;AACA;AACA,mBAAmB,OAAO;AAC1B;AACA,OAAO;AACP;AACA;AACA,CAAC;;AAED,CAAC,EAAE,KAA6B,kEAAkE;;;;;;;ACt1ElG,iBAAiB,mBAAO,CAAC,EAA0B;;;;;;;ACAnD,mC;;;;;;ACAA,mC;;;;;;;ACAa;;AAEb;;AAEA;AACA;;AAEA;AACA;;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AAGA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;;AAGA,aAAa,mBAAO,CAAC,CAAQ;AAC7B,aAAa,mBAAO,CAAC,CAAM;;;AAG3B;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;;AAGA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;;AAGA;AACA;;;;;;;;ACjJa;;AAEb,aAAa,mBAAO,CAAC,CAAa;;AAElC;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;;AAEA,mCAAmC,OAAO;AAC1C;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;;;;;;;ACpEa;;AAEb,iBAAiB,mBAAO,CAAC,CAAa;AACtC,iBAAiB,mBAAO,CAAC,CAAQ;AACjC,iBAAiB,mBAAO,CAAC,CAAK;AAC9B,iBAAiB,mBAAO,CAAC,CAAM;AAC/B,iBAAiB,mBAAO,CAAC,EAAgB;AACzC,iBAAiB,mBAAO,CAAC,CAAQ;AACjC,iBAAiB,mBAAO,CAAC,EAAQ;AACjC,iBAAiB,mBAAO,CAAC,EAAS;;AAElC;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA,GAAG;;AAEH;AACA;AACA;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;;AAEA;AACA;;AAEA;;;;;;;AC7IA;;AAEA,aAAa,mBAAO,CAAC,EAAQ;;AAE7B;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,sBAAsB;AACtB;AACA;AACA;AACA;;AAEA;AACA,qCAAqC;AACrC;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,8CAA8C,UAAU;;AAExD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,2BAA2B,SAAS;AACpC,4BAA4B;AAC5B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,UAAU;AACV;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,yCAAyC,EAAE;AAC3C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA,mDAAmD;AACnD;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA,mBAAmB,oBAAoB;AACvC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW;AACX;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA,KAAK;AACL;AACA;AACA,kCAAkC;AAClC;AACA,KAAK;AACL;AACA,KAAK;AACL;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH,CAAC;;AAED;AACA;AACA;AACA;AACA;;;;;;;AC9cA,mC;;;;;;;ACAa;;AAEb,eAAe,mBAAO,CAAC,EAAU;AACjC,eAAe,mBAAO,CAAC,EAAY;;AAEnC;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA,OAAO;AACP,KAAK;;AAEL;AACA;;AAEA;AACA,GAAG;;AAEH;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA,KAAK;;AAEL;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,KAAK;;AAEL;AACA;;AAEA;AACA,GAAG;;AAEH;AACA,mBAAmB,wCAAwC;AAC3D;;AAEA;AACA,gDAAgD,OAAO;AACvD;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA,GAAG;;AAEH;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;;;;;;;;ACjKa;;AAEb;AACA;AACA;AACA;AACA,gDAAgD;AAChD;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA,SAAS;AACT;AACA,SAAS;AACT;AACA;AACA;;AAEA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA,OAAO;AACP;AACA,KAAK;;AAEL;AACA,GAAG;;AAEH;AACA;;AAEA;AACA;AACA,mCAAmC,gBAAgB;AACnD,OAAO;AACP;AACA,OAAO;AACP;AACA,OAAO;AACP;AACA,OAAO;AACP;AACA;AACA;;AAEA;;AAEA,wCAAwC;AACxC;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA,sBAAsB,6BAA6B;AACnD;;AAEA;AACA;AACA,kCAAkC,OAAO;AACzC;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;;;;;;;;ACtGa;;AAEb,aAAa,mBAAO,CAAC,EAAQ;AAC7B,aAAa,mBAAO,CAAC,EAAU;;AAE/B;AACA,kDAAkD,2BAA2B;AAC7E,mBAAmB;AACnB;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA,mBAAmB;;AAEnB,4CAA4C,mBAAmB;AAC/D;AACA,wCAAwC,yBAAyB;AACjE;;AAEA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;;AAEA;;;;;;;;AC9Ca;;AAEb,cAAc,mBAAO,CAAC,EAAW;AACjC,cAAc,mBAAO,CAAC,EAAU;;AAEhC;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;;;;;;;;ACpDa;;AAEb,iBAAiB,mBAAO,CAAC,EAAe;;AAExC;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA,gBAAgB,oFAAoF;AACpG;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA,GAAG;AACH;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;;AAEA;;;;;;;;ACvEa;;AAEb;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;;;;;;;;ACpBa;;AAEb,aAAa,mBAAO,CAAC,CAAa;;AAElC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;;;;;;;;ACjCa;;AAEb,iBAAiB,mBAAO,CAAC,CAAa;AACtC,iBAAiB,mBAAO,CAAC,CAAQ;AACjC,iBAAiB,mBAAO,CAAC,CAAK;AAC9B,iBAAiB,mBAAO,CAAC,CAAM;AAC/B,iBAAiB,mBAAO,CAAC,CAAQ;AACjC,iBAAiB,mBAAO,CAAC,CAAW;AACpC,iBAAiB,mBAAO,CAAC,EAAgB;;AAEzC,aAAa;;AAEb;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;;AAEA;AACA;AACA;;AAEA;;AAEA;AACA;AACA,GAAG;;AAEH;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA,GAAG;;AAEH;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA;;AAEA;AACA;;AA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AAQ,CAAC,eAAe,CAAC;AACtD,mCAAqB,GAAc,YAAQ,CAAC,qBAAqB,CAAC;AAClE,4BAAc,GAAc,YAAQ,CAAC,cAAc,CAAC;AAVxC,6DAAM;AA4O3B,SAAS,WAAW,CAAC,GAAG;IACtB,IAAI,GAAG,KAAK,IAAI,IAAI,GAAG,KAAK,SAAS,EAAE;QACrC,MAAM,yDAAyD,CAAC;KACjE;AACH,CAAC;AAED,YAAO,CAAC,KAAK,CAAC,aAAM,CAAC,CAAC;;;;;;ACtQQ;AACuB;AACnB;AAEnB,MAAM,2CAAqB,SAAQ,WAAM;IACtD,YAAY,OAAe,EAAE,OAAgB;QAC3C,WAAM,CAAC,YAAY,GAAG,2CAAoB,CAAC,YAAY,CAAC;QACxD,WAAM,CAAC,GAAG,GAAG,2CAAoB,CAAC,GAAG,CAAC;QAEtC,eAAe,CAAC,OAAO,CAAC,CAAC;QACzB,OAAO,CAAC,IAAI,GAAG,SAAI,CAAC;QACpB,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAC1B,CAAC;CACF","file":"pusher.js","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 21);\n","module.exports = require(\"util\");","/* eslint-disable node/no-deprecated-api */\nvar buffer = require('buffer')\nvar Buffer = buffer.Buffer\n\n// alternative to using Object.keys for old browsers\nfunction copyProps (src, dst) {\n for (var key in src) {\n dst[key] = src[key]\n }\n}\nif (Buffer.from && Buffer.alloc && Buffer.allocUnsafe && Buffer.allocUnsafeSlow) {\n module.exports = buffer\n} else {\n // Copy properties from require('buffer')\n copyProps(buffer, exports)\n exports.Buffer = SafeBuffer\n}\n\nfunction SafeBuffer (arg, encodingOrOffset, length) {\n return Buffer(arg, encodingOrOffset, length)\n}\n\n// Copy static methods from Buffer\ncopyProps(Buffer, SafeBuffer)\n\nSafeBuffer.from = function (arg, encodingOrOffset, length) {\n if (typeof arg === 'number') {\n throw new TypeError('Argument must not be a number')\n }\n return Buffer(arg, encodingOrOffset, length)\n}\n\nSafeBuffer.alloc = function (size, fill, encoding) {\n if (typeof size !== 'number') {\n throw new TypeError('Argument must be a number')\n }\n var buf = Buffer(size)\n if (fill !== undefined) {\n if (typeof encoding === 'string') {\n buf.fill(fill, encoding)\n } else {\n buf.fill(fill)\n }\n } else {\n buf.fill(0)\n }\n return buf\n}\n\nSafeBuffer.allocUnsafe = function (size) {\n if (typeof size !== 'number') {\n throw new TypeError('Argument must be a number')\n }\n return Buffer(size)\n}\n\nSafeBuffer.allocUnsafeSlow = function (size) {\n if (typeof size !== 'number') {\n throw new TypeError('Argument must be a number')\n }\n return buffer.SlowBuffer(size)\n}\n","'use strict';\n\nvar Buffer = require('safe-buffer').Buffer,\n Emitter = require('events').EventEmitter,\n util = require('util'),\n streams = require('../streams'),\n Headers = require('./headers'),\n Reader = require('./stream_reader');\n\nvar Base = function(request, url, options) {\n Emitter.call(this);\n Base.validateOptions(options || {}, ['maxLength', 'masking', 'requireMasking', 'protocols']);\n\n this._request = request;\n this._reader = new Reader();\n this._options = options || {};\n this._maxLength = this._options.maxLength || this.MAX_LENGTH;\n this._headers = new Headers();\n this.__queue = [];\n this.readyState = 0;\n this.url = url;\n\n this.io = new streams.IO(this);\n this.messages = new streams.Messages(this);\n this._bindEventListeners();\n};\nutil.inherits(Base, Emitter);\n\nBase.isWebSocket = function(request) {\n var connection = request.headers.connection || '',\n upgrade = request.headers.upgrade || '';\n\n return request.method === 'GET' &&\n connection.toLowerCase().split(/ *, */).indexOf('upgrade') >= 0 &&\n upgrade.toLowerCase() === 'websocket';\n};\n\nBase.validateOptions = function(options, validKeys) {\n for (var key in options) {\n if (validKeys.indexOf(key) < 0)\n throw new Error('Unrecognized option: ' + key);\n }\n};\n\nvar instance = {\n // This is 64MB, small enough for an average VPS to handle without\n // crashing from process out of memory\n MAX_LENGTH: 0x3ffffff,\n\n STATES: ['connecting', 'open', 'closing', 'closed'],\n\n _bindEventListeners: function() {\n var self = this;\n\n // Protocol errors are informational and do not have to be handled\n this.messages.on('error', function() {});\n\n this.on('message', function(event) {\n var messages = self.messages;\n if (messages.readable) messages.emit('data', event.data);\n });\n\n this.on('error', function(error) {\n var messages = self.messages;\n if (messages.readable) messages.emit('error', error);\n });\n\n this.on('close', function() {\n var messages = self.messages;\n if (!messages.readable) return;\n messages.readable = messages.writable = false;\n messages.emit('end');\n });\n },\n\n getState: function() {\n return this.STATES[this.readyState] || null;\n },\n\n addExtension: function(extension) {\n return false;\n },\n\n setHeader: function(name, value) {\n if (this.readyState > 0) return false;\n this._headers.set(name, value);\n return true;\n },\n\n start: function() {\n if (this.readyState !== 0) return false;\n\n if (!Base.isWebSocket(this._request))\n return this._failHandshake(new Error('Not a WebSocket request'));\n\n var response;\n\n try {\n response = this._handshakeResponse();\n } catch (error) {\n return this._failHandshake(error);\n }\n\n this._write(response);\n if (this._stage !== -1) this._open();\n return true;\n },\n\n _failHandshake: function(error) {\n var headers = new Headers();\n headers.set('Content-Type', 'text/plain');\n headers.set('Content-Length', Buffer.byteLength(error.message, 'utf8'));\n\n headers = ['HTTP/1.1 400 Bad Request', headers.toString(), error.message];\n this._write(Buffer.from(headers.join('\\r\\n'), 'utf8'));\n this._fail('protocol_error', error.message);\n\n return false;\n },\n\n text: function(message) {\n return this.frame(message);\n },\n\n binary: function(message) {\n return false;\n },\n\n ping: function() {\n return false;\n },\n\n pong: function() {\n return false;\n },\n\n close: function(reason, code) {\n if (this.readyState !== 1) return false;\n this.readyState = 3;\n this.emit('close', new Base.CloseEvent(null, null));\n return true;\n },\n\n _open: function() {\n this.readyState = 1;\n this.__queue.forEach(function(args) { this.frame.apply(this, args) }, this);\n this.__queue = [];\n this.emit('open', new Base.OpenEvent());\n },\n\n _queue: function(message) {\n this.__queue.push(message);\n return true;\n },\n\n _write: function(chunk) {\n var io = this.io;\n if (io.readable) io.emit('data', chunk);\n },\n\n _fail: function(type, message) {\n this.readyState = 2;\n this.emit('error', new Error(message));\n this.close();\n }\n};\n\nfor (var key in instance)\n Base.prototype[key] = instance[key];\n\n\nBase.ConnectEvent = function() {};\n\nBase.OpenEvent = function() {};\n\nBase.CloseEvent = function(code, reason) {\n this.code = code;\n this.reason = reason;\n};\n\nBase.MessageEvent = function(data) {\n this.data = data;\n};\n\nBase.PingEvent = function(data) {\n this.data = data;\n};\n\nBase.PongEvent = function(data) {\n this.data = data;\n};\n\nmodule.exports = Base;\n","module.exports = require(\"crypto\");","'use strict';\n\n// Protocol references:\n//\n// * http://tools.ietf.org/html/draft-hixie-thewebsocketprotocol-75\n// * http://tools.ietf.org/html/draft-hixie-thewebsocketprotocol-76\n// * http://tools.ietf.org/html/draft-ietf-hybi-thewebsocketprotocol-17\n\nvar Base = require('./driver/base'),\n Client = require('./driver/client'),\n Server = require('./driver/server');\n\nvar Driver = {\n client: function(url, options) {\n options = options || {};\n if (options.masking === undefined) options.masking = true;\n return new Client(url, options);\n },\n\n server: function(options) {\n options = options || {};\n if (options.requireMasking === undefined) options.requireMasking = true;\n return new Server(options);\n },\n\n http: function() {\n return Server.http.apply(Server, arguments);\n },\n\n isSecureRequest: function(request) {\n return Server.isSecureRequest(request);\n },\n\n isWebSocket: function(request) {\n return Base.isWebSocket(request);\n },\n\n validateOptions: function(options, validKeys) {\n Base.validateOptions(options, validKeys);\n }\n};\n\nmodule.exports = Driver;\n","module.exports = require(\"stream\");","module.exports = require(\"url\");","'use strict';\n\nvar Event = function(eventType, options) {\n this.type = eventType;\n for (var key in options)\n this[key] = options[key];\n};\n\nEvent.prototype.initEvent = function(eventType, canBubble, cancelable) {\n this.type = eventType;\n this.bubbles = canBubble;\n this.cancelable = cancelable;\n};\n\nEvent.prototype.stopPropagation = function() {};\nEvent.prototype.preventDefault = function() {};\n\nEvent.CAPTURING_PHASE = 1;\nEvent.AT_TARGET = 2;\nEvent.BUBBLING_PHASE = 3;\n\nmodule.exports = Event;\n","// Copyright (C) 2016 Dmitry Chestnykh\n// MIT License. See LICENSE file for details.\n\n/**\n * Package base64 implements Base64 encoding and decoding.\n */\n\n// Invalid character used in decoding to indicate\n// that the character to decode is out of range of\n// alphabet and cannot be decoded.\nconst INVALID_BYTE = 256;\n\n/**\n * Implements standard Base64 encoding.\n *\n * Operates in constant time.\n */\nexport class Coder {\n // TODO(dchest): methods to encode chunk-by-chunk.\n\n constructor(private _paddingCharacter = \"=\") { }\n\n encodedLength(length: number): number {\n if (!this._paddingCharacter) {\n return (length * 8 + 5) / 6 | 0;\n }\n return (length + 2) / 3 * 4 | 0;\n }\n\n encode(data: Uint8Array): string {\n let out = \"\";\n\n let i = 0;\n for (; i < data.length - 2; i += 3) {\n let c = (data[i] << 16) | (data[i + 1] << 8) | (data[i + 2]);\n out += this._encodeByte((c >>> 3 * 6) & 63);\n out += this._encodeByte((c >>> 2 * 6) & 63);\n out += this._encodeByte((c >>> 1 * 6) & 63);\n out += this._encodeByte((c >>> 0 * 6) & 63);\n }\n\n const left = data.length - i;\n if (left > 0) {\n let c = (data[i] << 16) | (left === 2 ? data[i + 1] << 8 : 0);\n out += this._encodeByte((c >>> 3 * 6) & 63);\n out += this._encodeByte((c >>> 2 * 6) & 63);\n if (left === 2) {\n out += this._encodeByte((c >>> 1 * 6) & 63);\n } else {\n out += this._paddingCharacter || \"\";\n }\n out += this._paddingCharacter || \"\";\n }\n\n return out;\n }\n\n maxDecodedLength(length: number): number {\n if (!this._paddingCharacter) {\n return (length * 6 + 7) / 8 | 0;\n }\n return length / 4 * 3 | 0;\n }\n\n decodedLength(s: string): number {\n return this.maxDecodedLength(s.length - this._getPaddingLength(s));\n }\n\n decode(s: string): Uint8Array {\n if (s.length === 0) {\n return new Uint8Array(0);\n }\n const paddingLength = this._getPaddingLength(s);\n const length = s.length - paddingLength;\n const out = new Uint8Array(this.maxDecodedLength(length));\n let op = 0;\n let i = 0;\n let haveBad = 0;\n let v0 = 0, v1 = 0, v2 = 0, v3 = 0;\n for (; i < length - 4; i += 4) {\n v0 = this._decodeChar(s.charCodeAt(i + 0));\n v1 = this._decodeChar(s.charCodeAt(i + 1));\n v2 = this._decodeChar(s.charCodeAt(i + 2));\n v3 = this._decodeChar(s.charCodeAt(i + 3));\n out[op++] = (v0 << 2) | (v1 >>> 4);\n out[op++] = (v1 << 4) | (v2 >>> 2);\n out[op++] = (v2 << 6) | v3;\n haveBad |= v0 & INVALID_BYTE;\n haveBad |= v1 & INVALID_BYTE;\n haveBad |= v2 & INVALID_BYTE;\n haveBad |= v3 & INVALID_BYTE;\n }\n if (i < length - 1) {\n v0 = this._decodeChar(s.charCodeAt(i));\n v1 = this._decodeChar(s.charCodeAt(i + 1));\n out[op++] = (v0 << 2) | (v1 >>> 4);\n haveBad |= v0 & INVALID_BYTE;\n haveBad |= v1 & INVALID_BYTE;\n }\n if (i < length - 2) {\n v2 = this._decodeChar(s.charCodeAt(i + 2));\n out[op++] = (v1 << 4) | (v2 >>> 2);\n haveBad |= v2 & INVALID_BYTE;\n }\n if (i < length - 3) {\n v3 = this._decodeChar(s.charCodeAt(i + 3));\n out[op++] = (v2 << 6) | v3;\n haveBad |= v3 & INVALID_BYTE;\n }\n if (haveBad !== 0) {\n throw new Error(\"Base64Coder: incorrect characters for decoding\");\n }\n return out;\n }\n\n // Standard encoding have the following encoded/decoded ranges,\n // which we need to convert between.\n //\n // ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 0123456789 + /\n // Index: 0 - 25 26 - 51 52 - 61 62 63\n // ASCII: 65 - 90 97 - 122 48 - 57 43 47\n //\n\n // Encode 6 bits in b into a new character.\n protected _encodeByte(b: number): string {\n // Encoding uses constant time operations as follows:\n //\n // 1. Define comparison of A with B using (A - B) >>> 8:\n // if A > B, then result is positive integer\n // if A <= B, then result is 0\n //\n // 2. Define selection of C or 0 using bitwise AND: X & C:\n // if X == 0, then result is 0\n // if X != 0, then result is C\n //\n // 3. Start with the smallest comparison (b >= 0), which is always\n // true, so set the result to the starting ASCII value (65).\n //\n // 4. Continue comparing b to higher ASCII values, and selecting\n // zero if comparison isn't true, otherwise selecting a value\n // to add to result, which:\n //\n // a) undoes the previous addition\n // b) provides new value to add\n //\n let result = b;\n // b >= 0\n result += 65;\n // b > 25\n result += ((25 - b) >>> 8) & ((0 - 65) - 26 + 97);\n // b > 51\n result += ((51 - b) >>> 8) & ((26 - 97) - 52 + 48);\n // b > 61\n result += ((61 - b) >>> 8) & ((52 - 48) - 62 + 43);\n // b > 62\n result += ((62 - b) >>> 8) & ((62 - 43) - 63 + 47);\n\n return String.fromCharCode(result);\n }\n\n // Decode a character code into a byte.\n // Must return 256 if character is out of alphabet range.\n protected _decodeChar(c: number): number {\n // Decoding works similar to encoding: using the same comparison\n // function, but now it works on ranges: result is always incremented\n // by value, but this value becomes zero if the range is not\n // satisfied.\n //\n // Decoding starts with invalid value, 256, which is then\n // subtracted when the range is satisfied. If none of the ranges\n // apply, the function returns 256, which is then checked by\n // the caller to throw error.\n let result = INVALID_BYTE; // start with invalid character\n\n // c == 43 (c > 42 and c < 44)\n result += (((42 - c) & (c - 44)) >>> 8) & (-INVALID_BYTE + c - 43 + 62);\n // c == 47 (c > 46 and c < 48)\n result += (((46 - c) & (c - 48)) >>> 8) & (-INVALID_BYTE + c - 47 + 63);\n // c > 47 and c < 58\n result += (((47 - c) & (c - 58)) >>> 8) & (-INVALID_BYTE + c - 48 + 52);\n // c > 64 and c < 91\n result += (((64 - c) & (c - 91)) >>> 8) & (-INVALID_BYTE + c - 65 + 0);\n // c > 96 and c < 123\n result += (((96 - c) & (c - 123)) >>> 8) & (-INVALID_BYTE + c - 97 + 26);\n\n return result;\n }\n\n private _getPaddingLength(s: string): number {\n let paddingLength = 0;\n if (this._paddingCharacter) {\n for (let i = s.length - 1; i >= 0; i--) {\n if (s[i] !== this._paddingCharacter) {\n break;\n }\n paddingLength++;\n }\n if (s.length < 4 || paddingLength > 2) {\n throw new Error(\"Base64Coder: incorrect padding\");\n }\n }\n return paddingLength;\n }\n\n}\n\nconst stdCoder = new Coder();\n\nexport function encode(data: Uint8Array): string {\n return stdCoder.encode(data);\n}\n\nexport function decode(s: string): Uint8Array {\n return stdCoder.decode(s);\n}\n\n/**\n * Implements URL-safe Base64 encoding.\n * (Same as Base64, but '+' is replaced with '-', and '/' with '_').\n *\n * Operates in constant time.\n */\nexport class URLSafeCoder extends Coder {\n // URL-safe encoding have the following encoded/decoded ranges:\n //\n // ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 0123456789 - _\n // Index: 0 - 25 26 - 51 52 - 61 62 63\n // ASCII: 65 - 90 97 - 122 48 - 57 45 95\n //\n\n protected _encodeByte(b: number): string {\n let result = b;\n // b >= 0\n result += 65;\n // b > 25\n result += ((25 - b) >>> 8) & ((0 - 65) - 26 + 97);\n // b > 51\n result += ((51 - b) >>> 8) & ((26 - 97) - 52 + 48);\n // b > 61\n result += ((61 - b) >>> 8) & ((52 - 48) - 62 + 45);\n // b > 62\n result += ((62 - b) >>> 8) & ((62 - 45) - 63 + 95);\n\n return String.fromCharCode(result);\n }\n\n protected _decodeChar(c: number): number {\n let result = INVALID_BYTE;\n\n // c == 45 (c > 44 and c < 46)\n result += (((44 - c) & (c - 46)) >>> 8) & (-INVALID_BYTE + c - 45 + 62);\n // c == 95 (c > 94 and c < 96)\n result += (((94 - c) & (c - 96)) >>> 8) & (-INVALID_BYTE + c - 95 + 63);\n // c > 47 and c < 58\n result += (((47 - c) & (c - 58)) >>> 8) & (-INVALID_BYTE + c - 48 + 52);\n // c > 64 and c < 91\n result += (((64 - c) & (c - 91)) >>> 8) & (-INVALID_BYTE + c - 65 + 0);\n // c > 96 and c < 123\n result += (((96 - c) & (c - 123)) >>> 8) & (-INVALID_BYTE + c - 97 + 26);\n\n return result;\n }\n}\n\nconst urlSafeCoder = new URLSafeCoder();\n\nexport function encodeURLSafe(data: Uint8Array): string {\n return urlSafeCoder.encode(data);\n}\n\nexport function decodeURLSafe(s: string): Uint8Array {\n return urlSafeCoder.decode(s);\n}\n\n\nexport const encodedLength = (length: number) =>\n stdCoder.encodedLength(length);\n\nexport const maxDecodedLength = (length: number) =>\n stdCoder.maxDecodedLength(length);\n\nexport const decodedLength = (s: string) =>\n stdCoder.decodedLength(s);\n","'use strict';\n\nvar Headers = function() {\n this.clear();\n};\n\nHeaders.prototype.ALLOWED_DUPLICATES = ['set-cookie', 'set-cookie2', 'warning', 'www-authenticate'];\n\nHeaders.prototype.clear = function() {\n this._sent = {};\n this._lines = [];\n};\n\nHeaders.prototype.set = function(name, value) {\n if (value === undefined) return;\n\n name = this._strip(name);\n value = this._strip(value);\n\n var key = name.toLowerCase();\n if (!this._sent.hasOwnProperty(key) || this.ALLOWED_DUPLICATES.indexOf(key) >= 0) {\n this._sent[key] = true;\n this._lines.push(name + ': ' + value + '\\r\\n');\n }\n};\n\nHeaders.prototype.toString = function() {\n return this._lines.join('');\n};\n\nHeaders.prototype._strip = function(string) {\n return string.toString().replace(/^ */, '').replace(/ *$/, '');\n};\n\nmodule.exports = Headers;\n","'use strict';\n\nvar NodeHTTPParser = require('http-parser-js').HTTPParser,\n Buffer = require('safe-buffer').Buffer;\n\nvar TYPES = {\n request: NodeHTTPParser.REQUEST || 'request',\n response: NodeHTTPParser.RESPONSE || 'response'\n};\n\nvar HttpParser = function(type) {\n this._type = type;\n this._parser = new NodeHTTPParser(TYPES[type]);\n this._complete = false;\n this.headers = {};\n\n var current = null,\n self = this;\n\n this._parser.onHeaderField = function(b, start, length) {\n current = b.toString('utf8', start, start + length).toLowerCase();\n };\n\n this._parser.onHeaderValue = function(b, start, length) {\n var value = b.toString('utf8', start, start + length);\n\n if (self.headers.hasOwnProperty(current))\n self.headers[current] += ', ' + value;\n else\n self.headers[current] = value;\n };\n\n this._parser.onHeadersComplete = this._parser[NodeHTTPParser.kOnHeadersComplete] =\n function(majorVersion, minorVersion, headers, method, pathname, statusCode) {\n var info = arguments[0];\n\n if (typeof info === 'object') {\n method = info.method;\n pathname = info.url;\n statusCode = info.statusCode;\n headers = info.headers;\n }\n\n self.method = (typeof method === 'number') ? HttpParser.METHODS[method] : method;\n self.statusCode = statusCode;\n self.url = pathname;\n\n if (!headers) return;\n\n for (var i = 0, n = headers.length, key, value; i < n; i += 2) {\n key = headers[i].toLowerCase();\n value = headers[i+1];\n if (self.headers.hasOwnProperty(key))\n self.headers[key] += ', ' + value;\n else\n self.headers[key] = value;\n }\n\n self._complete = true;\n };\n};\n\nHttpParser.METHODS = {\n 0: 'DELETE',\n 1: 'GET',\n 2: 'HEAD',\n 3: 'POST',\n 4: 'PUT',\n 5: 'CONNECT',\n 6: 'OPTIONS',\n 7: 'TRACE',\n 8: 'COPY',\n 9: 'LOCK',\n 10: 'MKCOL',\n 11: 'MOVE',\n 12: 'PROPFIND',\n 13: 'PROPPATCH',\n 14: 'SEARCH',\n 15: 'UNLOCK',\n 16: 'BIND',\n 17: 'REBIND',\n 18: 'UNBIND',\n 19: 'ACL',\n 20: 'REPORT',\n 21: 'MKACTIVITY',\n 22: 'CHECKOUT',\n 23: 'MERGE',\n 24: 'M-SEARCH',\n 25: 'NOTIFY',\n 26: 'SUBSCRIBE',\n 27: 'UNSUBSCRIBE',\n 28: 'PATCH',\n 29: 'PURGE',\n 30: 'MKCALENDAR',\n 31: 'LINK',\n 32: 'UNLINK'\n};\n\nvar VERSION = process.version\n ? process.version.match(/[0-9]+/g).map(function(n) { return parseInt(n, 10) })\n : [];\n\nif (VERSION[0] === 0 && VERSION[1] === 12) {\n HttpParser.METHODS[16] = 'REPORT';\n HttpParser.METHODS[17] = 'MKACTIVITY';\n HttpParser.METHODS[18] = 'CHECKOUT';\n HttpParser.METHODS[19] = 'MERGE';\n HttpParser.METHODS[20] = 'M-SEARCH';\n HttpParser.METHODS[21] = 'NOTIFY';\n HttpParser.METHODS[22] = 'SUBSCRIBE';\n HttpParser.METHODS[23] = 'UNSUBSCRIBE';\n HttpParser.METHODS[24] = 'PATCH';\n HttpParser.METHODS[25] = 'PURGE';\n}\n\nHttpParser.prototype.isComplete = function() {\n return this._complete;\n};\n\nHttpParser.prototype.parse = function(chunk) {\n var consumed = this._parser.execute(chunk, 0, chunk.length);\n\n if (typeof consumed !== 'number') {\n this.error = consumed;\n this._complete = true;\n return;\n }\n\n if (this._complete)\n this.body = (consumed < chunk.length)\n ? chunk.slice(consumed)\n : Buffer.alloc(0);\n};\n\nmodule.exports = HttpParser;\n","'use strict';\n\nvar Stream = require('stream').Stream,\n util = require('util'),\n driver = require('websocket-driver'),\n EventTarget = require('./api/event_target'),\n Event = require('./api/event');\n\nvar API = function(options) {\n options = options || {};\n driver.validateOptions(options, ['headers', 'extensions', 'maxLength', 'ping', 'proxy', 'tls', 'ca']);\n\n this.readable = this.writable = true;\n\n var headers = options.headers;\n if (headers) {\n for (var name in headers) this._driver.setHeader(name, headers[name]);\n }\n\n var extensions = options.extensions;\n if (extensions) {\n [].concat(extensions).forEach(this._driver.addExtension, this._driver);\n }\n\n this._ping = options.ping;\n this._pingId = 0;\n this.readyState = API.CONNECTING;\n this.bufferedAmount = 0;\n this.protocol = '';\n this.url = this._driver.url;\n this.version = this._driver.version;\n\n var self = this;\n\n this._driver.on('open', function(e) { self._open() });\n this._driver.on('message', function(e) { self._receiveMessage(e.data) });\n this._driver.on('close', function(e) { self._beginClose(e.reason, e.code) });\n\n this._driver.on('error', function(error) {\n self._emitError(error.message);\n });\n this.on('error', function() {});\n\n this._driver.messages.on('drain', function() {\n self.emit('drain');\n });\n\n if (this._ping)\n this._pingTimer = setInterval(function() {\n self._pingId += 1;\n self.ping(self._pingId.toString());\n }, this._ping * 1000);\n\n this._configureStream();\n\n if (!this._proxy) {\n this._stream.pipe(this._driver.io);\n this._driver.io.pipe(this._stream);\n }\n};\nutil.inherits(API, Stream);\n\nAPI.CONNECTING = 0;\nAPI.OPEN = 1;\nAPI.CLOSING = 2;\nAPI.CLOSED = 3;\n\nAPI.CLOSE_TIMEOUT = 30000;\n\nvar instance = {\n write: function(data) {\n return this.send(data);\n },\n\n end: function(data) {\n if (data !== undefined) this.send(data);\n this.close();\n },\n\n pause: function() {\n return this._driver.messages.pause();\n },\n\n resume: function() {\n return this._driver.messages.resume();\n },\n\n send: function(data) {\n if (this.readyState > API.OPEN) return false;\n if (!(data instanceof Buffer)) data = String(data);\n return this._driver.messages.write(data);\n },\n\n ping: function(message, callback) {\n if (this.readyState > API.OPEN) return false;\n return this._driver.ping(message, callback);\n },\n\n close: function(code, reason) {\n if (code === undefined) code = 1000;\n if (reason === undefined) reason = '';\n\n if (code !== 1000 && (code < 3000 || code > 4999))\n throw new Error(\"Failed to execute 'close' on WebSocket: \" +\n \"The code must be either 1000, or between 3000 and 4999. \" +\n code + \" is neither.\");\n\n if (this.readyState !== API.CLOSED) this.readyState = API.CLOSING;\n var self = this;\n\n this._closeTimer = setTimeout(function() {\n self._beginClose('', 1006);\n }, API.CLOSE_TIMEOUT);\n\n this._driver.close(reason, code);\n },\n\n _configureStream: function() {\n var self = this;\n\n this._stream.setTimeout(0);\n this._stream.setNoDelay(true);\n\n ['close', 'end'].forEach(function(event) {\n this._stream.on(event, function() { self._finalizeClose() });\n }, this);\n\n this._stream.on('error', function(error) {\n self._emitError('Network error: ' + self.url + ': ' + error.message);\n self._finalizeClose();\n });\n },\n\n _open: function() {\n if (this.readyState !== API.CONNECTING) return;\n\n this.readyState = API.OPEN;\n this.protocol = this._driver.protocol || '';\n\n var event = new Event('open');\n event.initEvent('open', false, false);\n this.dispatchEvent(event);\n },\n\n _receiveMessage: function(data) {\n if (this.readyState > API.OPEN) return false;\n\n if (this.readable) this.emit('data', data);\n\n var event = new Event('message', {data: data});\n event.initEvent('message', false, false);\n this.dispatchEvent(event);\n },\n\n _emitError: function(message) {\n if (this.readyState >= API.CLOSING) return;\n\n var event = new Event('error', {message: message});\n event.initEvent('error', false, false);\n this.dispatchEvent(event);\n },\n\n _beginClose: function(reason, code) {\n if (this.readyState === API.CLOSED) return;\n this.readyState = API.CLOSING;\n this._closeParams = [reason, code];\n\n if (this._stream) {\n this._stream.destroy();\n if (!this._stream.readable) this._finalizeClose();\n }\n },\n\n _finalizeClose: function() {\n if (this.readyState === API.CLOSED) return;\n this.readyState = API.CLOSED;\n\n if (this._closeTimer) clearTimeout(this._closeTimer);\n if (this._pingTimer) clearInterval(this._pingTimer);\n if (this._stream) this._stream.end();\n\n if (this.readable) this.emit('end');\n this.readable = this.writable = false;\n\n var reason = this._closeParams ? this._closeParams[0] : '',\n code = this._closeParams ? this._closeParams[1] : 1006;\n\n var event = new Event('close', {code: code, reason: reason});\n event.initEvent('close', false, false);\n this.dispatchEvent(event);\n }\n};\n\nfor (var method in instance) API.prototype[method] = instance[method];\nfor (var key in EventTarget) API.prototype[key] = EventTarget[key];\n\nmodule.exports = API;\n","'use strict';\n\nvar Buffer = require('safe-buffer').Buffer,\n crypto = require('crypto'),\n util = require('util'),\n Extensions = require('websocket-extensions'),\n Base = require('./base'),\n Frame = require('./hybi/frame'),\n Message = require('./hybi/message');\n\nvar Hybi = function(request, url, options) {\n Base.apply(this, arguments);\n\n this._extensions = new Extensions();\n this._stage = 0;\n this._masking = this._options.masking;\n this._protocols = this._options.protocols || [];\n this._requireMasking = this._options.requireMasking;\n this._pingCallbacks = {};\n\n if (typeof this._protocols === 'string')\n this._protocols = this._protocols.split(/ *, */);\n\n if (!this._request) return;\n\n var protos = this._request.headers['sec-websocket-protocol'],\n supported = this._protocols;\n\n if (protos !== undefined) {\n if (typeof protos === 'string') protos = protos.split(/ *, */);\n this.protocol = protos.filter(function(p) { return supported.indexOf(p) >= 0 })[0];\n }\n\n this.version = 'hybi-' + Hybi.VERSION;\n};\nutil.inherits(Hybi, Base);\n\nHybi.VERSION = '13';\n\nHybi.mask = function(payload, mask, offset) {\n if (!mask || mask.length === 0) return payload;\n offset = offset || 0;\n\n for (var i = 0, n = payload.length - offset; i < n; i++) {\n payload[offset + i] = payload[offset + i] ^ mask[i % 4];\n }\n return payload;\n};\n\nHybi.generateAccept = function(key) {\n var sha1 = crypto.createHash('sha1');\n sha1.update(key + Hybi.GUID);\n return sha1.digest('base64');\n};\n\nHybi.GUID = '258EAFA5-E914-47DA-95CA-C5AB0DC85B11';\n\nvar instance = {\n FIN: 0x80,\n MASK: 0x80,\n RSV1: 0x40,\n RSV2: 0x20,\n RSV3: 0x10,\n OPCODE: 0x0F,\n LENGTH: 0x7F,\n\n OPCODES: {\n continuation: 0,\n text: 1,\n binary: 2,\n close: 8,\n ping: 9,\n pong: 10\n },\n\n OPCODE_CODES: [0, 1, 2, 8, 9, 10],\n MESSAGE_OPCODES: [0, 1, 2],\n OPENING_OPCODES: [1, 2],\n\n ERRORS: {\n normal_closure: 1000,\n going_away: 1001,\n protocol_error: 1002,\n unacceptable: 1003,\n encoding_error: 1007,\n policy_violation: 1008,\n too_large: 1009,\n extension_error: 1010,\n unexpected_condition: 1011\n },\n\n ERROR_CODES: [1000, 1001, 1002, 1003, 1007, 1008, 1009, 1010, 1011],\n DEFAULT_ERROR_CODE: 1000,\n MIN_RESERVED_ERROR: 3000,\n MAX_RESERVED_ERROR: 4999,\n\n // http://www.w3.org/International/questions/qa-forms-utf-8.en.php\n UTF8_MATCH: /^([\\x00-\\x7F]|[\\xC2-\\xDF][\\x80-\\xBF]|\\xE0[\\xA0-\\xBF][\\x80-\\xBF]|[\\xE1-\\xEC\\xEE\\xEF][\\x80-\\xBF]{2}|\\xED[\\x80-\\x9F][\\x80-\\xBF]|\\xF0[\\x90-\\xBF][\\x80-\\xBF]{2}|[\\xF1-\\xF3][\\x80-\\xBF]{3}|\\xF4[\\x80-\\x8F][\\x80-\\xBF]{2})*$/,\n\n addExtension: function(extension) {\n this._extensions.add(extension);\n return true;\n },\n\n parse: function(chunk) {\n this._reader.put(chunk);\n var buffer = true;\n while (buffer) {\n switch (this._stage) {\n case 0:\n buffer = this._reader.read(1);\n if (buffer) this._parseOpcode(buffer[0]);\n break;\n\n case 1:\n buffer = this._reader.read(1);\n if (buffer) this._parseLength(buffer[0]);\n break;\n\n case 2:\n buffer = this._reader.read(this._frame.lengthBytes);\n if (buffer) this._parseExtendedLength(buffer);\n break;\n\n case 3:\n buffer = this._reader.read(4);\n if (buffer) {\n this._stage = 4;\n this._frame.maskingKey = buffer;\n }\n break;\n\n case 4:\n buffer = this._reader.read(this._frame.length);\n if (buffer) {\n this._stage = 0;\n this._emitFrame(buffer);\n }\n break;\n\n default:\n buffer = null;\n }\n }\n },\n\n text: function(message) {\n if (this.readyState > 1) return false;\n return this.frame(message, 'text');\n },\n\n binary: function(message) {\n if (this.readyState > 1) return false;\n return this.frame(message, 'binary');\n },\n\n ping: function(message, callback) {\n if (this.readyState > 1) return false;\n message = message || '';\n if (callback) this._pingCallbacks[message] = callback;\n return this.frame(message, 'ping');\n },\n\n pong: function(message) {\n if (this.readyState > 1) return false;\n message = message ||'';\n return this.frame(message, 'pong');\n },\n\n close: function(reason, code) {\n reason = reason || '';\n code = code || this.ERRORS.normal_closure;\n\n if (this.readyState <= 0) {\n this.readyState = 3;\n this.emit('close', new Base.CloseEvent(code, reason));\n return true;\n } else if (this.readyState === 1) {\n this.readyState = 2;\n this._extensions.close(function() { this.frame(reason, 'close', code) }, this);\n return true;\n } else {\n return false;\n }\n },\n\n frame: function(buffer, type, code) {\n if (this.readyState <= 0) return this._queue([buffer, type, code]);\n if (this.readyState > 2) return false;\n\n if (buffer instanceof Array) buffer = Buffer.from(buffer);\n if (typeof buffer === 'number') buffer = buffer.toString();\n\n var message = new Message(),\n isText = (typeof buffer === 'string'),\n payload, copy;\n\n message.rsv1 = message.rsv2 = message.rsv3 = false;\n message.opcode = this.OPCODES[type || (isText ? 'text' : 'binary')];\n\n payload = isText ? Buffer.from(buffer, 'utf8') : buffer;\n\n if (code) {\n copy = payload;\n payload = Buffer.allocUnsafe(2 + copy.length);\n payload.writeUInt16BE(code, 0);\n copy.copy(payload, 2);\n }\n message.data = payload;\n\n var onMessageReady = function(message) {\n var frame = new Frame();\n\n frame.final = true;\n frame.rsv1 = message.rsv1;\n frame.rsv2 = message.rsv2;\n frame.rsv3 = message.rsv3;\n frame.opcode = message.opcode;\n frame.masked = !!this._masking;\n frame.length = message.data.length;\n frame.payload = message.data;\n\n if (frame.masked) frame.maskingKey = crypto.randomBytes(4);\n\n this._sendFrame(frame);\n };\n\n if (this.MESSAGE_OPCODES.indexOf(message.opcode) >= 0)\n this._extensions.processOutgoingMessage(message, function(error, message) {\n if (error) return this._fail('extension_error', error.message);\n onMessageReady.call(this, message);\n }, this);\n else\n onMessageReady.call(this, message);\n\n return true;\n },\n\n _sendFrame: function(frame) {\n var length = frame.length,\n header = (length <= 125) ? 2 : (length <= 65535 ? 4 : 10),\n offset = header + (frame.masked ? 4 : 0),\n buffer = Buffer.allocUnsafe(offset + length),\n masked = frame.masked ? this.MASK : 0;\n\n buffer[0] = (frame.final ? this.FIN : 0) |\n (frame.rsv1 ? this.RSV1 : 0) |\n (frame.rsv2 ? this.RSV2 : 0) |\n (frame.rsv3 ? this.RSV3 : 0) |\n frame.opcode;\n\n if (length <= 125) {\n buffer[1] = masked | length;\n } else if (length <= 65535) {\n buffer[1] = masked | 126;\n buffer.writeUInt16BE(length, 2);\n } else {\n buffer[1] = masked | 127;\n buffer.writeUInt32BE(Math.floor(length / 0x100000000), 2);\n buffer.writeUInt32BE(length % 0x100000000, 6);\n }\n\n frame.payload.copy(buffer, offset);\n\n if (frame.masked) {\n frame.maskingKey.copy(buffer, header);\n Hybi.mask(buffer, frame.maskingKey, offset);\n }\n\n this._write(buffer);\n },\n\n _handshakeResponse: function() {\n var secKey = this._request.headers['sec-websocket-key'],\n version = this._request.headers['sec-websocket-version'];\n\n if (version !== Hybi.VERSION)\n throw new Error('Unsupported WebSocket version: ' + version);\n\n if (typeof secKey !== 'string')\n throw new Error('Missing handshake request header: Sec-WebSocket-Key');\n\n this._headers.set('Upgrade', 'websocket');\n this._headers.set('Connection', 'Upgrade');\n this._headers.set('Sec-WebSocket-Accept', Hybi.generateAccept(secKey));\n\n if (this.protocol) this._headers.set('Sec-WebSocket-Protocol', this.protocol);\n\n var extensions = this._extensions.generateResponse(this._request.headers['sec-websocket-extensions']);\n if (extensions) this._headers.set('Sec-WebSocket-Extensions', extensions);\n\n var start = 'HTTP/1.1 101 Switching Protocols',\n headers = [start, this._headers.toString(), ''];\n\n return Buffer.from(headers.join('\\r\\n'), 'utf8');\n },\n\n _shutdown: function(code, reason, error) {\n delete this._frame;\n delete this._message;\n this._stage = 5;\n\n var sendCloseFrame = (this.readyState === 1);\n this.readyState = 2;\n\n this._extensions.close(function() {\n if (sendCloseFrame) this.frame(reason, 'close', code);\n this.readyState = 3;\n if (error) this.emit('error', new Error(reason));\n this.emit('close', new Base.CloseEvent(code, reason));\n }, this);\n },\n\n _fail: function(type, message) {\n if (this.readyState > 1) return;\n this._shutdown(this.ERRORS[type], message, true);\n },\n\n _parseOpcode: function(octet) {\n var rsvs = [this.RSV1, this.RSV2, this.RSV3].map(function(rsv) {\n return (octet & rsv) === rsv;\n });\n\n var frame = this._frame = new Frame();\n\n frame.final = (octet & this.FIN) === this.FIN;\n frame.rsv1 = rsvs[0];\n frame.rsv2 = rsvs[1];\n frame.rsv3 = rsvs[2];\n frame.opcode = (octet & this.OPCODE);\n\n this._stage = 1;\n\n if (!this._extensions.validFrameRsv(frame))\n return this._fail('protocol_error',\n 'One or more reserved bits are on: reserved1 = ' + (frame.rsv1 ? 1 : 0) +\n ', reserved2 = ' + (frame.rsv2 ? 1 : 0) +\n ', reserved3 = ' + (frame.rsv3 ? 1 : 0));\n\n if (this.OPCODE_CODES.indexOf(frame.opcode) < 0)\n return this._fail('protocol_error', 'Unrecognized frame opcode: ' + frame.opcode);\n\n if (this.MESSAGE_OPCODES.indexOf(frame.opcode) < 0 && !frame.final)\n return this._fail('protocol_error', 'Received fragmented control frame: opcode = ' + frame.opcode);\n\n if (this._message && this.OPENING_OPCODES.indexOf(frame.opcode) >= 0)\n return this._fail('protocol_error', 'Received new data frame but previous continuous frame is unfinished');\n },\n\n _parseLength: function(octet) {\n var frame = this._frame;\n frame.masked = (octet & this.MASK) === this.MASK;\n frame.length = (octet & this.LENGTH);\n\n if (frame.length >= 0 && frame.length <= 125) {\n this._stage = frame.masked ? 3 : 4;\n if (!this._checkFrameLength()) return;\n } else {\n this._stage = 2;\n frame.lengthBytes = (frame.length === 126 ? 2 : 8);\n }\n\n if (this._requireMasking && !frame.masked)\n return this._fail('unacceptable', 'Received unmasked frame but masking is required');\n },\n\n _parseExtendedLength: function(buffer) {\n var frame = this._frame;\n frame.length = this._readUInt(buffer);\n\n this._stage = frame.masked ? 3 : 4;\n\n if (this.MESSAGE_OPCODES.indexOf(frame.opcode) < 0 && frame.length > 125)\n return this._fail('protocol_error', 'Received control frame having too long payload: ' + frame.length);\n\n if (!this._checkFrameLength()) return;\n },\n\n _checkFrameLength: function() {\n var length = this._message ? this._message.length : 0;\n\n if (length + this._frame.length > this._maxLength) {\n this._fail('too_large', 'WebSocket frame length too large');\n return false;\n } else {\n return true;\n }\n },\n\n _emitFrame: function(buffer) {\n var frame = this._frame,\n payload = frame.payload = Hybi.mask(buffer, frame.maskingKey),\n opcode = frame.opcode,\n message,\n code, reason,\n callbacks, callback;\n\n delete this._frame;\n\n if (opcode === this.OPCODES.continuation) {\n if (!this._message) return this._fail('protocol_error', 'Received unexpected continuation frame');\n this._message.pushFrame(frame);\n }\n\n if (opcode === this.OPCODES.text || opcode === this.OPCODES.binary) {\n this._message = new Message();\n this._message.pushFrame(frame);\n }\n\n if (frame.final && this.MESSAGE_OPCODES.indexOf(opcode) >= 0)\n return this._emitMessage(this._message);\n\n if (opcode === this.OPCODES.close) {\n code = (payload.length >= 2) ? payload.readUInt16BE(0) : null;\n reason = (payload.length > 2) ? this._encode(payload.slice(2)) : null;\n\n if (!(payload.length === 0) &&\n !(code !== null && code >= this.MIN_RESERVED_ERROR && code <= this.MAX_RESERVED_ERROR) &&\n this.ERROR_CODES.indexOf(code) < 0)\n code = this.ERRORS.protocol_error;\n\n if (payload.length > 125 || (payload.length > 2 && !reason))\n code = this.ERRORS.protocol_error;\n\n this._shutdown(code || this.DEFAULT_ERROR_CODE, reason || '');\n }\n\n if (opcode === this.OPCODES.ping) {\n this.frame(payload, 'pong');\n this.emit('ping', new Base.PingEvent(payload.toString()))\n }\n\n if (opcode === this.OPCODES.pong) {\n callbacks = this._pingCallbacks;\n message = this._encode(payload);\n callback = callbacks[message];\n\n delete callbacks[message];\n if (callback) callback()\n\n this.emit('pong', new Base.PongEvent(payload.toString()))\n }\n },\n\n _emitMessage: function(message) {\n var message = this._message;\n message.read();\n\n delete this._message;\n\n this._extensions.processIncomingMessage(message, function(error, message) {\n if (error) return this._fail('extension_error', error.message);\n\n var payload = message.data;\n if (message.opcode === this.OPCODES.text) payload = this._encode(payload);\n\n if (payload === null)\n return this._fail('encoding_error', 'Could not decode a text frame as UTF-8');\n else\n this.emit('message', new Base.MessageEvent(payload));\n }, this);\n },\n\n _encode: function(buffer) {\n try {\n var string = buffer.toString('binary', 0, buffer.length);\n if (!this.UTF8_MATCH.test(string)) return null;\n } catch (e) {}\n return buffer.toString('utf8', 0, buffer.length);\n },\n\n _readUInt: function(buffer) {\n if (buffer.length === 2) return buffer.readUInt16BE(0);\n\n return buffer.readUInt32BE(0) * 0x100000000 +\n buffer.readUInt32BE(4);\n }\n};\n\nfor (var key in instance)\n Hybi.prototype[key] = instance[key];\n\nmodule.exports = Hybi;\n","'use strict';\n\nvar RingBuffer = function(bufferSize) {\n this._bufferSize = bufferSize;\n this.clear();\n};\n\nRingBuffer.prototype.clear = function() {\n this._buffer = new Array(this._bufferSize);\n this._ringOffset = 0;\n this._ringSize = this._bufferSize;\n this._head = 0;\n this._tail = 0;\n this.length = 0;\n};\n\nRingBuffer.prototype.push = function(value) {\n var expandBuffer = false,\n expandRing = false;\n\n if (this._ringSize < this._bufferSize) {\n expandBuffer = (this._tail === 0);\n } else if (this._ringOffset === this._ringSize) {\n expandBuffer = true;\n expandRing = (this._tail === 0);\n }\n\n if (expandBuffer) {\n this._tail = this._bufferSize;\n this._buffer = this._buffer.concat(new Array(this._bufferSize));\n this._bufferSize = this._buffer.length;\n\n if (expandRing)\n this._ringSize = this._bufferSize;\n }\n\n this._buffer[this._tail] = value;\n this.length += 1;\n if (this._tail < this._ringSize) this._ringOffset += 1;\n this._tail = (this._tail + 1) % this._bufferSize;\n};\n\nRingBuffer.prototype.peek = function() {\n if (this.length === 0) return void 0;\n return this._buffer[this._head];\n};\n\nRingBuffer.prototype.shift = function() {\n if (this.length === 0) return void 0;\n\n var value = this._buffer[this._head];\n this._buffer[this._head] = void 0;\n this.length -= 1;\n this._ringOffset -= 1;\n\n if (this._ringOffset === 0 && this.length > 0) {\n this._head = this._ringSize;\n this._ringOffset = this.length;\n this._ringSize = this._bufferSize;\n } else {\n this._head = (this._head + 1) % this._ringSize;\n }\n return value;\n};\n\nmodule.exports = RingBuffer;\n","'use strict';\n\nvar RingBuffer = require('./ring_buffer');\n\nvar Pledge = function() {\n this._complete = false;\n this._callbacks = new RingBuffer(Pledge.QUEUE_SIZE);\n};\n\nPledge.QUEUE_SIZE = 4;\n\nPledge.all = function(list) {\n var pledge = new Pledge(),\n pending = list.length,\n n = pending;\n\n if (pending === 0) pledge.done();\n\n while (n--) list[n].then(function() {\n pending -= 1;\n if (pending === 0) pledge.done();\n });\n return pledge;\n};\n\nPledge.prototype.then = function(callback) {\n if (this._complete) callback();\n else this._callbacks.push(callback);\n};\n\nPledge.prototype.done = function() {\n this._complete = true;\n var callbacks = this._callbacks, callback;\n while (callback = callbacks.shift()) callback();\n};\n\nmodule.exports = Pledge;\n","'use strict';\n\nvar Buffer = require('safe-buffer').Buffer,\n Base = require('./base'),\n util = require('util');\n\nvar Draft75 = function(request, url, options) {\n Base.apply(this, arguments);\n this._stage = 0;\n this.version = 'hixie-75';\n\n this._headers.set('Upgrade', 'WebSocket');\n this._headers.set('Connection', 'Upgrade');\n this._headers.set('WebSocket-Origin', this._request.headers.origin);\n this._headers.set('WebSocket-Location', this.url);\n};\nutil.inherits(Draft75, Base);\n\nvar instance = {\n close: function() {\n if (this.readyState === 3) return false;\n this.readyState = 3;\n this.emit('close', new Base.CloseEvent(null, null));\n return true;\n },\n\n parse: function(chunk) {\n if (this.readyState > 1) return;\n\n this._reader.put(chunk);\n\n this._reader.eachByte(function(octet) {\n var message;\n\n switch (this._stage) {\n case -1:\n this._body.push(octet);\n this._sendHandshakeBody();\n break;\n\n case 0:\n this._parseLeadingByte(octet);\n break;\n\n case 1:\n this._length = (octet & 0x7F) + 128 * this._length;\n\n if (this._closing && this._length === 0) {\n return this.close();\n }\n else if ((octet & 0x80) !== 0x80) {\n if (this._length === 0) {\n this._stage = 0;\n }\n else {\n this._skipped = 0;\n this._stage = 2;\n }\n }\n break;\n\n case 2:\n if (octet === 0xFF) {\n this._stage = 0;\n message = Buffer.from(this._buffer).toString('utf8', 0, this._buffer.length);\n this.emit('message', new Base.MessageEvent(message));\n }\n else {\n if (this._length) {\n this._skipped += 1;\n if (this._skipped === this._length)\n this._stage = 0;\n } else {\n this._buffer.push(octet);\n if (this._buffer.length > this._maxLength) return this.close();\n }\n }\n break;\n }\n }, this);\n },\n\n frame: function(buffer) {\n if (this.readyState === 0) return this._queue([buffer]);\n if (this.readyState > 1) return false;\n\n if (typeof buffer !== 'string') buffer = buffer.toString();\n\n var length = Buffer.byteLength(buffer),\n frame = Buffer.allocUnsafe(length + 2);\n\n frame[0] = 0x00;\n frame.write(buffer, 1);\n frame[frame.length - 1] = 0xFF;\n\n this._write(frame);\n return true;\n },\n\n _handshakeResponse: function() {\n var start = 'HTTP/1.1 101 Web Socket Protocol Handshake',\n headers = [start, this._headers.toString(), ''];\n\n return Buffer.from(headers.join('\\r\\n'), 'utf8');\n },\n\n _parseLeadingByte: function(octet) {\n if ((octet & 0x80) === 0x80) {\n this._length = 0;\n this._stage = 1;\n } else {\n delete this._length;\n delete this._skipped;\n this._buffer = [];\n this._stage = 2;\n }\n }\n};\n\nfor (var key in instance)\n Draft75.prototype[key] = instance[key];\n\nmodule.exports = Draft75;\n","'use strict';\n\nvar Event = require('./event');\n\nvar EventTarget = {\n onopen: null,\n onmessage: null,\n onerror: null,\n onclose: null,\n\n addEventListener: function(eventType, listener, useCapture) {\n this.on(eventType, listener);\n },\n\n removeEventListener: function(eventType, listener, useCapture) {\n this.removeListener(eventType, listener);\n },\n\n dispatchEvent: function(event) {\n event.target = event.currentTarget = this;\n event.eventPhase = Event.AT_TARGET;\n\n if (this['on' + event.type])\n this['on' + event.type](event);\n\n this.emit(event.type, event);\n }\n};\n\nmodule.exports = EventTarget;\n","// Copyright (C) 2016 Dmitry Chestnykh\n// MIT License. See LICENSE file for details.\n\n/**\n * Package utf8 implements UTF-8 encoding and decoding.\n */\n\nconst INVALID_UTF16 = \"utf8: invalid string\";\nconst INVALID_UTF8 = \"utf8: invalid source encoding\";\n\n/**\n * Encodes the given string into UTF-8 byte array.\n * Throws if the source string has invalid UTF-16 encoding.\n */\nexport function encode(s: string): Uint8Array {\n // Calculate result length and allocate output array.\n // encodedLength() also validates string and throws errors,\n // so we don't need repeat validation here.\n const arr = new Uint8Array(encodedLength(s));\n\n let pos = 0;\n for (let i = 0; i < s.length; i++) {\n let c = s.charCodeAt(i);\n if (c < 0x80) {\n arr[pos++] = c;\n } else if (c < 0x800) {\n arr[pos++] = 0xc0 | c >> 6;\n arr[pos++] = 0x80 | c & 0x3f;\n } else if (c < 0xd800) {\n arr[pos++] = 0xe0 | c >> 12;\n arr[pos++] = 0x80 | (c >> 6) & 0x3f;\n arr[pos++] = 0x80 | c & 0x3f;\n } else {\n i++; // get one more character\n c = (c & 0x3ff) << 10;\n c |= s.charCodeAt(i) & 0x3ff;\n c += 0x10000;\n\n arr[pos++] = 0xf0 | c >> 18;\n arr[pos++] = 0x80 | (c >> 12) & 0x3f;\n arr[pos++] = 0x80 | (c >> 6) & 0x3f;\n arr[pos++] = 0x80 | c & 0x3f;\n }\n }\n return arr;\n}\n\n/**\n * Returns the number of bytes required to encode the given string into UTF-8.\n * Throws if the source string has invalid UTF-16 encoding.\n */\nexport function encodedLength(s: string): number {\n let result = 0;\n for (let i = 0; i < s.length; i++) {\n const c = s.charCodeAt(i);\n if (c < 0x80) {\n result += 1;\n } else if (c < 0x800) {\n result += 2;\n } else if (c < 0xd800) {\n result += 3;\n } else if (c <= 0xdfff) {\n if (i >= s.length - 1) {\n throw new Error(INVALID_UTF16);\n }\n i++; // \"eat\" next character\n result += 4;\n } else {\n throw new Error(INVALID_UTF16);\n }\n }\n return result;\n}\n\n/**\n * Decodes the given byte array from UTF-8 into a string.\n * Throws if encoding is invalid.\n */\nexport function decode(arr: Uint8Array): string {\n const chars: string[] = [];\n for (let i = 0; i < arr.length; i++) {\n let b = arr[i];\n\n if (b & 0x80) {\n let min;\n if (b < 0xe0) {\n // Need 1 more byte.\n if (i >= arr.length) {\n throw new Error(INVALID_UTF8);\n }\n const n1 = arr[++i];\n if ((n1 & 0xc0) !== 0x80) {\n throw new Error(INVALID_UTF8);\n }\n b = (b & 0x1f) << 6 | (n1 & 0x3f);\n min = 0x80;\n } else if (b < 0xf0) {\n // Need 2 more bytes.\n if (i >= arr.length - 1) {\n throw new Error(INVALID_UTF8);\n }\n const n1 = arr[++i];\n const n2 = arr[++i];\n if ((n1 & 0xc0) !== 0x80 || (n2 & 0xc0) !== 0x80) {\n throw new Error(INVALID_UTF8);\n }\n b = (b & 0x0f) << 12 | (n1 & 0x3f) << 6 | (n2 & 0x3f);\n min = 0x800;\n } else if (b < 0xf8) {\n // Need 3 more bytes.\n if (i >= arr.length - 2) {\n throw new Error(INVALID_UTF8);\n }\n const n1 = arr[++i];\n const n2 = arr[++i];\n const n3 = arr[++i];\n if ((n1 & 0xc0) !== 0x80 || (n2 & 0xc0) !== 0x80 || (n3 & 0xc0) !== 0x80) {\n throw new Error(INVALID_UTF8);\n }\n b = (b & 0x0f) << 18 | (n1 & 0x3f) << 12 | (n2 & 0x3f) << 6 | (n3 & 0x3f);\n min = 0x10000;\n } else {\n throw new Error(INVALID_UTF8);\n }\n\n if (b < min || (b >= 0xd800 && b <= 0xdfff)) {\n throw new Error(INVALID_UTF8);\n }\n\n if (b >= 0x10000) {\n // Surrogate pair.\n if (b > 0x10ffff) {\n throw new Error(INVALID_UTF8);\n }\n b -= 0x10000;\n chars.push(String.fromCharCode(0xd800 | (b >> 10)));\n b = 0xdc00 | (b & 0x3ff);\n }\n }\n\n chars.push(String.fromCharCode(b));\n }\n return chars.join(\"\");\n}\n","// API references:\n//\n// * https://html.spec.whatwg.org/multipage/comms.html#network\n// * https://dom.spec.whatwg.org/#interface-eventtarget\n// * https://dom.spec.whatwg.org/#interface-event\n\n'use strict';\n\nvar util = require('util'),\n driver = require('websocket-driver'),\n API = require('./websocket/api');\n\nvar WebSocket = function(request, socket, body, protocols, options) {\n options = options || {};\n\n this._stream = socket;\n this._driver = driver.http(request, {maxLength: options.maxLength, protocols: protocols});\n\n var self = this;\n if (!this._stream || !this._stream.writable) return;\n if (!this._stream.readable) return this._stream.end();\n\n var catchup = function() { self._stream.removeListener('data', catchup) };\n this._stream.on('data', catchup);\n\n API.call(this, options);\n\n process.nextTick(function() {\n self._driver.start();\n self._driver.io.write(body);\n });\n};\nutil.inherits(WebSocket, API);\n\nWebSocket.isWebSocket = function(request) {\n return driver.isWebSocket(request);\n};\n\nWebSocket.validateOptions = function(options, validKeys) {\n driver.validateOptions(options, validKeys);\n};\n\nWebSocket.WebSocket = WebSocket;\nWebSocket.Client = require('./websocket/client');\nWebSocket.EventSource = require('./eventsource');\n\nmodule.exports = WebSocket;\n","/**\n * Wrapper for built-in http.js to emulate the browser XMLHttpRequest object.\n *\n * This can be used with JS designed for browsers to improve reuse of code and\n * allow the use of existing libraries.\n *\n * Usage: include(\"XMLHttpRequest.js\") and use XMLHttpRequest per W3C specs.\n *\n * @author Dan DeFelippi \n * @contributor David Ellis \n * @license MIT\n */\n\nvar Url = require(\"url\");\nvar spawn = require(\"child_process\").spawn;\nvar fs = require(\"fs\");\n\nexports.XMLHttpRequest = function() {\n \"use strict\";\n\n /**\n * Private variables\n */\n var self = this;\n var http = require(\"http\");\n var https = require(\"https\");\n\n // Holds http.js objects\n var request;\n var response;\n\n // Request settings\n var settings = {};\n\n // Disable header blacklist.\n // Not part of XHR specs.\n var disableHeaderCheck = false;\n\n // Set some default headers\n var defaultHeaders = {\n \"User-Agent\": \"node-XMLHttpRequest\",\n \"Accept\": \"*/*\",\n };\n\n var headers = {};\n var headersCase = {};\n\n // These headers are not user setable.\n // The following are allowed but banned in the spec:\n // * user-agent\n var forbiddenRequestHeaders = [\n \"accept-charset\",\n \"accept-encoding\",\n \"access-control-request-headers\",\n \"access-control-request-method\",\n \"connection\",\n \"content-length\",\n \"content-transfer-encoding\",\n \"cookie\",\n \"cookie2\",\n \"date\",\n \"expect\",\n \"host\",\n \"keep-alive\",\n \"origin\",\n \"referer\",\n \"te\",\n \"trailer\",\n \"transfer-encoding\",\n \"upgrade\",\n \"via\"\n ];\n\n // These request methods are not allowed\n var forbiddenRequestMethods = [\n \"TRACE\",\n \"TRACK\",\n \"CONNECT\"\n ];\n\n // Send flag\n var sendFlag = false;\n // Error flag, used when errors occur or abort is called\n var errorFlag = false;\n\n // Event listeners\n var listeners = {};\n\n /**\n * Constants\n */\n\n this.UNSENT = 0;\n this.OPENED = 1;\n this.HEADERS_RECEIVED = 2;\n this.LOADING = 3;\n this.DONE = 4;\n\n /**\n * Public vars\n */\n\n // Current state\n this.readyState = this.UNSENT;\n\n // default ready state change handler in case one is not set or is set late\n this.onreadystatechange = null;\n\n // Result & response\n this.responseText = \"\";\n this.responseXML = \"\";\n this.status = null;\n this.statusText = null;\n \n // Whether cross-site Access-Control requests should be made using\n // credentials such as cookies or authorization headers\n this.withCredentials = false;\n\n /**\n * Private methods\n */\n\n /**\n * Check if the specified header is allowed.\n *\n * @param string header Header to validate\n * @return boolean False if not allowed, otherwise true\n */\n var isAllowedHttpHeader = function(header) {\n return disableHeaderCheck || (header && forbiddenRequestHeaders.indexOf(header.toLowerCase()) === -1);\n };\n\n /**\n * Check if the specified method is allowed.\n *\n * @param string method Request method to validate\n * @return boolean False if not allowed, otherwise true\n */\n var isAllowedHttpMethod = function(method) {\n return (method && forbiddenRequestMethods.indexOf(method) === -1);\n };\n\n /**\n * Public methods\n */\n\n /**\n * Open the connection. Currently supports local server requests.\n *\n * @param string method Connection method (eg GET, POST)\n * @param string url URL for the connection.\n * @param boolean async Asynchronous connection. Default is true.\n * @param string user Username for basic authentication (optional)\n * @param string password Password for basic authentication (optional)\n */\n this.open = function(method, url, async, user, password) {\n this.abort();\n errorFlag = false;\n\n // Check for valid request method\n if (!isAllowedHttpMethod(method)) {\n throw new Error(\"SecurityError: Request method not allowed\");\n }\n\n settings = {\n \"method\": method,\n \"url\": url.toString(),\n \"async\": (typeof async !== \"boolean\" ? true : async),\n \"user\": user || null,\n \"password\": password || null\n };\n\n setState(this.OPENED);\n };\n\n /**\n * Disables or enables isAllowedHttpHeader() check the request. Enabled by default.\n * This does not conform to the W3C spec.\n *\n * @param boolean state Enable or disable header checking.\n */\n this.setDisableHeaderCheck = function(state) {\n disableHeaderCheck = state;\n };\n\n /**\n * Sets a header for the request or appends the value if one is already set.\n *\n * @param string header Header name\n * @param string value Header value\n */\n this.setRequestHeader = function(header, value) {\n if (this.readyState !== this.OPENED) {\n throw new Error(\"INVALID_STATE_ERR: setRequestHeader can only be called when state is OPEN\");\n }\n if (!isAllowedHttpHeader(header)) {\n console.warn(\"Refused to set unsafe header \\\"\" + header + \"\\\"\");\n return;\n }\n if (sendFlag) {\n throw new Error(\"INVALID_STATE_ERR: send flag is true\");\n }\n header = headersCase[header.toLowerCase()] || header;\n headersCase[header.toLowerCase()] = header;\n headers[header] = headers[header] ? headers[header] + ', ' + value : value;\n };\n\n /**\n * Gets a header from the server response.\n *\n * @param string header Name of header to get.\n * @return string Text of the header or null if it doesn't exist.\n */\n this.getResponseHeader = function(header) {\n if (typeof header === \"string\"\n && this.readyState > this.OPENED\n && response\n && response.headers\n && response.headers[header.toLowerCase()]\n && !errorFlag\n ) {\n return response.headers[header.toLowerCase()];\n }\n\n return null;\n };\n\n /**\n * Gets all the response headers.\n *\n * @return string A string with all response headers separated by CR+LF\n */\n this.getAllResponseHeaders = function() {\n if (this.readyState < this.HEADERS_RECEIVED || errorFlag) {\n return \"\";\n }\n var result = \"\";\n\n for (var i in response.headers) {\n // Cookie headers are excluded\n if (i !== \"set-cookie\" && i !== \"set-cookie2\") {\n result += i + \": \" + response.headers[i] + \"\\r\\n\";\n }\n }\n return result.substr(0, result.length - 2);\n };\n\n /**\n * Gets a request header\n *\n * @param string name Name of header to get\n * @return string Returns the request header or empty string if not set\n */\n this.getRequestHeader = function(name) {\n if (typeof name === \"string\" && headersCase[name.toLowerCase()]) {\n return headers[headersCase[name.toLowerCase()]];\n }\n\n return \"\";\n };\n\n /**\n * Sends the request to the server.\n *\n * @param string data Optional data to send as request body.\n */\n this.send = function(data) {\n if (this.readyState !== this.OPENED) {\n throw new Error(\"INVALID_STATE_ERR: connection must be opened before send() is called\");\n }\n\n if (sendFlag) {\n throw new Error(\"INVALID_STATE_ERR: send has already been called\");\n }\n\n var ssl = false, local = false;\n var url = Url.parse(settings.url);\n var host;\n // Determine the server\n switch (url.protocol) {\n case \"https:\":\n ssl = true;\n // SSL & non-SSL both need host, no break here.\n case \"http:\":\n host = url.hostname;\n break;\n\n case \"file:\":\n local = true;\n break;\n\n case undefined:\n case null:\n case \"\":\n host = \"localhost\";\n break;\n\n default:\n throw new Error(\"Protocol not supported.\");\n }\n\n // Load files off the local filesystem (file://)\n if (local) {\n if (settings.method !== \"GET\") {\n throw new Error(\"XMLHttpRequest: Only GET method is supported\");\n }\n\n if (settings.async) {\n fs.readFile(url.pathname, \"utf8\", function(error, data) {\n if (error) {\n self.handleError(error);\n } else {\n self.status = 200;\n self.responseText = data;\n setState(self.DONE);\n }\n });\n } else {\n try {\n this.responseText = fs.readFileSync(url.pathname, \"utf8\");\n this.status = 200;\n setState(self.DONE);\n } catch(e) {\n this.handleError(e);\n }\n }\n\n return;\n }\n\n // Default to port 80. If accessing localhost on another port be sure\n // to use http://localhost:port/path\n var port = url.port || (ssl ? 443 : 80);\n // Add query string if one is used\n var uri = url.pathname + (url.search ? url.search : \"\");\n\n // Set the defaults if they haven't been set\n for (var name in defaultHeaders) {\n if (!headersCase[name.toLowerCase()]) {\n headers[name] = defaultHeaders[name];\n }\n }\n\n // Set the Host header or the server may reject the request\n headers.Host = host;\n if (!((ssl && port === 443) || port === 80)) {\n headers.Host += \":\" + url.port;\n }\n\n // Set Basic Auth if necessary\n if (settings.user) {\n if (typeof settings.password === \"undefined\") {\n settings.password = \"\";\n }\n var authBuf = new Buffer(settings.user + \":\" + settings.password);\n headers.Authorization = \"Basic \" + authBuf.toString(\"base64\");\n }\n\n // Set content length header\n if (settings.method === \"GET\" || settings.method === \"HEAD\") {\n data = null;\n } else if (data) {\n headers[\"Content-Length\"] = Buffer.isBuffer(data) ? data.length : Buffer.byteLength(data);\n\n if (!headers[\"Content-Type\"]) {\n headers[\"Content-Type\"] = \"text/plain;charset=UTF-8\";\n }\n } else if (settings.method === \"POST\") {\n // For a post with no data set Content-Length: 0.\n // This is required by buggy servers that don't meet the specs.\n headers[\"Content-Length\"] = 0;\n }\n\n var options = {\n host: host,\n port: port,\n path: uri,\n method: settings.method,\n headers: headers,\n agent: false,\n withCredentials: self.withCredentials\n };\n\n // Reset error flag\n errorFlag = false;\n\n // Handle async requests\n if (settings.async) {\n // Use the proper protocol\n var doRequest = ssl ? https.request : http.request;\n\n // Request is being sent, set send flag\n sendFlag = true;\n\n // As per spec, this is called here for historical reasons.\n self.dispatchEvent(\"readystatechange\");\n\n // Handler for the response\n var responseHandler = function responseHandler(resp) {\n // Set response var to the response we got back\n // This is so it remains accessable outside this scope\n response = resp;\n // Check for redirect\n // @TODO Prevent looped redirects\n if (response.statusCode === 301 || response.statusCode === 302 || response.statusCode === 303 || response.statusCode === 307) {\n // Change URL to the redirect location\n settings.url = response.headers.location;\n var url = Url.parse(settings.url);\n // Set host var in case it's used later\n host = url.hostname;\n // Options for the new request\n var newOptions = {\n hostname: url.hostname,\n port: url.port,\n path: url.path,\n method: response.statusCode === 303 ? \"GET\" : settings.method,\n headers: headers,\n withCredentials: self.withCredentials\n };\n\n // Issue the new request\n request = doRequest(newOptions, responseHandler).on(\"error\", errorHandler);\n request.end();\n // @TODO Check if an XHR event needs to be fired here\n return;\n }\n\n response.setEncoding(\"utf8\");\n\n setState(self.HEADERS_RECEIVED);\n self.status = response.statusCode;\n\n response.on(\"data\", function(chunk) {\n // Make sure there's some data\n if (chunk) {\n self.responseText += chunk;\n }\n // Don't emit state changes if the connection has been aborted.\n if (sendFlag) {\n setState(self.LOADING);\n }\n });\n\n response.on(\"end\", function() {\n if (sendFlag) {\n // Discard the end event if the connection has been aborted\n setState(self.DONE);\n sendFlag = false;\n }\n });\n\n response.on(\"error\", function(error) {\n self.handleError(error);\n });\n };\n\n // Error handler for the request\n var errorHandler = function errorHandler(error) {\n self.handleError(error);\n };\n\n // Create the request\n request = doRequest(options, responseHandler).on(\"error\", errorHandler);\n\n // Node 0.4 and later won't accept empty data. Make sure it's needed.\n if (data) {\n request.write(data);\n }\n\n request.end();\n\n self.dispatchEvent(\"loadstart\");\n } else { // Synchronous\n // Create a temporary file for communication with the other Node process\n var contentFile = \".node-xmlhttprequest-content-\" + process.pid;\n var syncFile = \".node-xmlhttprequest-sync-\" + process.pid;\n fs.writeFileSync(syncFile, \"\", \"utf8\");\n // The async request the other Node process executes\n var execString = \"var http = require('http'), https = require('https'), fs = require('fs');\"\n + \"var doRequest = http\" + (ssl ? \"s\" : \"\") + \".request;\"\n + \"var options = \" + JSON.stringify(options) + \";\"\n + \"var responseText = '';\"\n + \"var req = doRequest(options, function(response) {\"\n + \"response.setEncoding('utf8');\"\n + \"response.on('data', function(chunk) {\"\n + \" responseText += chunk;\"\n + \"});\"\n + \"response.on('end', function() {\"\n + \"fs.writeFileSync('\" + contentFile + \"', JSON.stringify({err: null, data: {statusCode: response.statusCode, headers: response.headers, text: responseText}}), 'utf8');\"\n + \"fs.unlinkSync('\" + syncFile + \"');\"\n + \"});\"\n + \"response.on('error', function(error) {\"\n + \"fs.writeFileSync('\" + contentFile + \"', JSON.stringify({err: error}), 'utf8');\"\n + \"fs.unlinkSync('\" + syncFile + \"');\"\n + \"});\"\n + \"}).on('error', function(error) {\"\n + \"fs.writeFileSync('\" + contentFile + \"', JSON.stringify({err: error}), 'utf8');\"\n + \"fs.unlinkSync('\" + syncFile + \"');\"\n + \"});\"\n + (data ? \"req.write('\" + JSON.stringify(data).slice(1,-1).replace(/'/g, \"\\\\'\") + \"');\":\"\")\n + \"req.end();\";\n // Start the other Node Process, executing this string\n var syncProc = spawn(process.argv[0], [\"-e\", execString]);\n while(fs.existsSync(syncFile)) {\n // Wait while the sync file is empty\n }\n var resp = JSON.parse(fs.readFileSync(contentFile, 'utf8'));\n // Kill the child process once the file has data\n syncProc.stdin.end();\n // Remove the temporary file\n fs.unlinkSync(contentFile);\n\n if (resp.err) {\n self.handleError(resp.err);\n } else {\n response = resp.data;\n self.status = resp.data.statusCode;\n self.responseText = resp.data.text;\n setState(self.DONE);\n }\n }\n };\n\n /**\n * Called when an error is encountered to deal with it.\n */\n this.handleError = function(error) {\n this.status = 0;\n this.statusText = error;\n this.responseText = error.stack;\n errorFlag = true;\n setState(this.DONE);\n this.dispatchEvent('error');\n };\n\n /**\n * Aborts a request.\n */\n this.abort = function() {\n if (request) {\n request.abort();\n request = null;\n }\n\n headers = defaultHeaders;\n this.status = 0;\n this.responseText = \"\";\n this.responseXML = \"\";\n\n errorFlag = true;\n\n if (this.readyState !== this.UNSENT\n && (this.readyState !== this.OPENED || sendFlag)\n && this.readyState !== this.DONE) {\n sendFlag = false;\n setState(this.DONE);\n }\n this.readyState = this.UNSENT;\n this.dispatchEvent('abort');\n };\n\n /**\n * Adds an event listener. Preferred method of binding to events.\n */\n this.addEventListener = function(event, callback) {\n if (!(event in listeners)) {\n listeners[event] = [];\n }\n // Currently allows duplicate callbacks. Should it?\n listeners[event].push(callback);\n };\n\n /**\n * Remove an event callback that has already been bound.\n * Only works on the matching funciton, cannot be a copy.\n */\n this.removeEventListener = function(event, callback) {\n if (event in listeners) {\n // Filter will return a new array with the callback removed\n listeners[event] = listeners[event].filter(function(ev) {\n return ev !== callback;\n });\n }\n };\n\n /**\n * Dispatch any events, including both \"on\" methods and events attached using addEventListener.\n */\n this.dispatchEvent = function(event) {\n if (typeof self[\"on\" + event] === \"function\") {\n self[\"on\" + event]();\n }\n if (event in listeners) {\n for (var i = 0, len = listeners[event].length; i < len; i++) {\n listeners[event][i].call(self);\n }\n }\n };\n\n /**\n * Changes readyState and calls onreadystatechange.\n *\n * @param int state New state\n */\n var setState = function(state) {\n if (state == self.LOADING || self.readyState !== state) {\n self.readyState = state;\n\n if (settings.async || self.readyState < self.OPENED || self.readyState === self.DONE) {\n self.dispatchEvent(\"readystatechange\");\n }\n\n if (self.readyState === self.DONE && !errorFlag) {\n self.dispatchEvent(\"load\");\n // @TODO figure out InspectorInstrumentation::didLoadXHR(cookie)\n self.dispatchEvent(\"loadend\");\n }\n }\n };\n};\n","(function(nacl) {\n'use strict';\n\n// Ported in 2014 by Dmitry Chestnykh and Devi Mandiri.\n// Public domain.\n//\n// Implementation derived from TweetNaCl version 20140427.\n// See for details: http://tweetnacl.cr.yp.to/\n\nvar gf = function(init) {\n var i, r = new Float64Array(16);\n if (init) for (i = 0; i < init.length; i++) r[i] = init[i];\n return r;\n};\n\n// Pluggable, initialized in high-level API below.\nvar randombytes = function(/* x, n */) { throw new Error('no PRNG'); };\n\nvar _0 = new Uint8Array(16);\nvar _9 = new Uint8Array(32); _9[0] = 9;\n\nvar gf0 = gf(),\n gf1 = gf([1]),\n _121665 = gf([0xdb41, 1]),\n D = gf([0x78a3, 0x1359, 0x4dca, 0x75eb, 0xd8ab, 0x4141, 0x0a4d, 0x0070, 0xe898, 0x7779, 0x4079, 0x8cc7, 0xfe73, 0x2b6f, 0x6cee, 0x5203]),\n D2 = gf([0xf159, 0x26b2, 0x9b94, 0xebd6, 0xb156, 0x8283, 0x149a, 0x00e0, 0xd130, 0xeef3, 0x80f2, 0x198e, 0xfce7, 0x56df, 0xd9dc, 0x2406]),\n X = gf([0xd51a, 0x8f25, 0x2d60, 0xc956, 0xa7b2, 0x9525, 0xc760, 0x692c, 0xdc5c, 0xfdd6, 0xe231, 0xc0a4, 0x53fe, 0xcd6e, 0x36d3, 0x2169]),\n Y = gf([0x6658, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666]),\n I = gf([0xa0b0, 0x4a0e, 0x1b27, 0xc4ee, 0xe478, 0xad2f, 0x1806, 0x2f43, 0xd7a7, 0x3dfb, 0x0099, 0x2b4d, 0xdf0b, 0x4fc1, 0x2480, 0x2b83]);\n\nfunction ts64(x, i, h, l) {\n x[i] = (h >> 24) & 0xff;\n x[i+1] = (h >> 16) & 0xff;\n x[i+2] = (h >> 8) & 0xff;\n x[i+3] = h & 0xff;\n x[i+4] = (l >> 24) & 0xff;\n x[i+5] = (l >> 16) & 0xff;\n x[i+6] = (l >> 8) & 0xff;\n x[i+7] = l & 0xff;\n}\n\nfunction vn(x, xi, y, yi, n) {\n var i,d = 0;\n for (i = 0; i < n; i++) d |= x[xi+i]^y[yi+i];\n return (1 & ((d - 1) >>> 8)) - 1;\n}\n\nfunction crypto_verify_16(x, xi, y, yi) {\n return vn(x,xi,y,yi,16);\n}\n\nfunction crypto_verify_32(x, xi, y, yi) {\n return vn(x,xi,y,yi,32);\n}\n\nfunction core_salsa20(o, p, k, c) {\n var j0 = c[ 0] & 0xff | (c[ 1] & 0xff)<<8 | (c[ 2] & 0xff)<<16 | (c[ 3] & 0xff)<<24,\n j1 = k[ 0] & 0xff | (k[ 1] & 0xff)<<8 | (k[ 2] & 0xff)<<16 | (k[ 3] & 0xff)<<24,\n j2 = k[ 4] & 0xff | (k[ 5] & 0xff)<<8 | (k[ 6] & 0xff)<<16 | (k[ 7] & 0xff)<<24,\n j3 = k[ 8] & 0xff | (k[ 9] & 0xff)<<8 | (k[10] & 0xff)<<16 | (k[11] & 0xff)<<24,\n j4 = k[12] & 0xff | (k[13] & 0xff)<<8 | (k[14] & 0xff)<<16 | (k[15] & 0xff)<<24,\n j5 = c[ 4] & 0xff | (c[ 5] & 0xff)<<8 | (c[ 6] & 0xff)<<16 | (c[ 7] & 0xff)<<24,\n j6 = p[ 0] & 0xff | (p[ 1] & 0xff)<<8 | (p[ 2] & 0xff)<<16 | (p[ 3] & 0xff)<<24,\n j7 = p[ 4] & 0xff | (p[ 5] & 0xff)<<8 | (p[ 6] & 0xff)<<16 | (p[ 7] & 0xff)<<24,\n j8 = p[ 8] & 0xff | (p[ 9] & 0xff)<<8 | (p[10] & 0xff)<<16 | (p[11] & 0xff)<<24,\n j9 = p[12] & 0xff | (p[13] & 0xff)<<8 | (p[14] & 0xff)<<16 | (p[15] & 0xff)<<24,\n j10 = c[ 8] & 0xff | (c[ 9] & 0xff)<<8 | (c[10] & 0xff)<<16 | (c[11] & 0xff)<<24,\n j11 = k[16] & 0xff | (k[17] & 0xff)<<8 | (k[18] & 0xff)<<16 | (k[19] & 0xff)<<24,\n j12 = k[20] & 0xff | (k[21] & 0xff)<<8 | (k[22] & 0xff)<<16 | (k[23] & 0xff)<<24,\n j13 = k[24] & 0xff | (k[25] & 0xff)<<8 | (k[26] & 0xff)<<16 | (k[27] & 0xff)<<24,\n j14 = k[28] & 0xff | (k[29] & 0xff)<<8 | (k[30] & 0xff)<<16 | (k[31] & 0xff)<<24,\n j15 = c[12] & 0xff | (c[13] & 0xff)<<8 | (c[14] & 0xff)<<16 | (c[15] & 0xff)<<24;\n\n var x0 = j0, x1 = j1, x2 = j2, x3 = j3, x4 = j4, x5 = j5, x6 = j6, x7 = j7,\n x8 = j8, x9 = j9, x10 = j10, x11 = j11, x12 = j12, x13 = j13, x14 = j14,\n x15 = j15, u;\n\n for (var i = 0; i < 20; i += 2) {\n u = x0 + x12 | 0;\n x4 ^= u<<7 | u>>>(32-7);\n u = x4 + x0 | 0;\n x8 ^= u<<9 | u>>>(32-9);\n u = x8 + x4 | 0;\n x12 ^= u<<13 | u>>>(32-13);\n u = x12 + x8 | 0;\n x0 ^= u<<18 | u>>>(32-18);\n\n u = x5 + x1 | 0;\n x9 ^= u<<7 | u>>>(32-7);\n u = x9 + x5 | 0;\n x13 ^= u<<9 | u>>>(32-9);\n u = x13 + x9 | 0;\n x1 ^= u<<13 | u>>>(32-13);\n u = x1 + x13 | 0;\n x5 ^= u<<18 | u>>>(32-18);\n\n u = x10 + x6 | 0;\n x14 ^= u<<7 | u>>>(32-7);\n u = x14 + x10 | 0;\n x2 ^= u<<9 | u>>>(32-9);\n u = x2 + x14 | 0;\n x6 ^= u<<13 | u>>>(32-13);\n u = x6 + x2 | 0;\n x10 ^= u<<18 | u>>>(32-18);\n\n u = x15 + x11 | 0;\n x3 ^= u<<7 | u>>>(32-7);\n u = x3 + x15 | 0;\n x7 ^= u<<9 | u>>>(32-9);\n u = x7 + x3 | 0;\n x11 ^= u<<13 | u>>>(32-13);\n u = x11 + x7 | 0;\n x15 ^= u<<18 | u>>>(32-18);\n\n u = x0 + x3 | 0;\n x1 ^= u<<7 | u>>>(32-7);\n u = x1 + x0 | 0;\n x2 ^= u<<9 | u>>>(32-9);\n u = x2 + x1 | 0;\n x3 ^= u<<13 | u>>>(32-13);\n u = x3 + x2 | 0;\n x0 ^= u<<18 | u>>>(32-18);\n\n u = x5 + x4 | 0;\n x6 ^= u<<7 | u>>>(32-7);\n u = x6 + x5 | 0;\n x7 ^= u<<9 | u>>>(32-9);\n u = x7 + x6 | 0;\n x4 ^= u<<13 | u>>>(32-13);\n u = x4 + x7 | 0;\n x5 ^= u<<18 | u>>>(32-18);\n\n u = x10 + x9 | 0;\n x11 ^= u<<7 | u>>>(32-7);\n u = x11 + x10 | 0;\n x8 ^= u<<9 | u>>>(32-9);\n u = x8 + x11 | 0;\n x9 ^= u<<13 | u>>>(32-13);\n u = x9 + x8 | 0;\n x10 ^= u<<18 | u>>>(32-18);\n\n u = x15 + x14 | 0;\n x12 ^= u<<7 | u>>>(32-7);\n u = x12 + x15 | 0;\n x13 ^= u<<9 | u>>>(32-9);\n u = x13 + x12 | 0;\n x14 ^= u<<13 | u>>>(32-13);\n u = x14 + x13 | 0;\n x15 ^= u<<18 | u>>>(32-18);\n }\n x0 = x0 + j0 | 0;\n x1 = x1 + j1 | 0;\n x2 = x2 + j2 | 0;\n x3 = x3 + j3 | 0;\n x4 = x4 + j4 | 0;\n x5 = x5 + j5 | 0;\n x6 = x6 + j6 | 0;\n x7 = x7 + j7 | 0;\n x8 = x8 + j8 | 0;\n x9 = x9 + j9 | 0;\n x10 = x10 + j10 | 0;\n x11 = x11 + j11 | 0;\n x12 = x12 + j12 | 0;\n x13 = x13 + j13 | 0;\n x14 = x14 + j14 | 0;\n x15 = x15 + j15 | 0;\n\n o[ 0] = x0 >>> 0 & 0xff;\n o[ 1] = x0 >>> 8 & 0xff;\n o[ 2] = x0 >>> 16 & 0xff;\n o[ 3] = x0 >>> 24 & 0xff;\n\n o[ 4] = x1 >>> 0 & 0xff;\n o[ 5] = x1 >>> 8 & 0xff;\n o[ 6] = x1 >>> 16 & 0xff;\n o[ 7] = x1 >>> 24 & 0xff;\n\n o[ 8] = x2 >>> 0 & 0xff;\n o[ 9] = x2 >>> 8 & 0xff;\n o[10] = x2 >>> 16 & 0xff;\n o[11] = x2 >>> 24 & 0xff;\n\n o[12] = x3 >>> 0 & 0xff;\n o[13] = x3 >>> 8 & 0xff;\n o[14] = x3 >>> 16 & 0xff;\n o[15] = x3 >>> 24 & 0xff;\n\n o[16] = x4 >>> 0 & 0xff;\n o[17] = x4 >>> 8 & 0xff;\n o[18] = x4 >>> 16 & 0xff;\n o[19] = x4 >>> 24 & 0xff;\n\n o[20] = x5 >>> 0 & 0xff;\n o[21] = x5 >>> 8 & 0xff;\n o[22] = x5 >>> 16 & 0xff;\n o[23] = x5 >>> 24 & 0xff;\n\n o[24] = x6 >>> 0 & 0xff;\n o[25] = x6 >>> 8 & 0xff;\n o[26] = x6 >>> 16 & 0xff;\n o[27] = x6 >>> 24 & 0xff;\n\n o[28] = x7 >>> 0 & 0xff;\n o[29] = x7 >>> 8 & 0xff;\n o[30] = x7 >>> 16 & 0xff;\n o[31] = x7 >>> 24 & 0xff;\n\n o[32] = x8 >>> 0 & 0xff;\n o[33] = x8 >>> 8 & 0xff;\n o[34] = x8 >>> 16 & 0xff;\n o[35] = x8 >>> 24 & 0xff;\n\n o[36] = x9 >>> 0 & 0xff;\n o[37] = x9 >>> 8 & 0xff;\n o[38] = x9 >>> 16 & 0xff;\n o[39] = x9 >>> 24 & 0xff;\n\n o[40] = x10 >>> 0 & 0xff;\n o[41] = x10 >>> 8 & 0xff;\n o[42] = x10 >>> 16 & 0xff;\n o[43] = x10 >>> 24 & 0xff;\n\n o[44] = x11 >>> 0 & 0xff;\n o[45] = x11 >>> 8 & 0xff;\n o[46] = x11 >>> 16 & 0xff;\n o[47] = x11 >>> 24 & 0xff;\n\n o[48] = x12 >>> 0 & 0xff;\n o[49] = x12 >>> 8 & 0xff;\n o[50] = x12 >>> 16 & 0xff;\n o[51] = x12 >>> 24 & 0xff;\n\n o[52] = x13 >>> 0 & 0xff;\n o[53] = x13 >>> 8 & 0xff;\n o[54] = x13 >>> 16 & 0xff;\n o[55] = x13 >>> 24 & 0xff;\n\n o[56] = x14 >>> 0 & 0xff;\n o[57] = x14 >>> 8 & 0xff;\n o[58] = x14 >>> 16 & 0xff;\n o[59] = x14 >>> 24 & 0xff;\n\n o[60] = x15 >>> 0 & 0xff;\n o[61] = x15 >>> 8 & 0xff;\n o[62] = x15 >>> 16 & 0xff;\n o[63] = x15 >>> 24 & 0xff;\n}\n\nfunction core_hsalsa20(o,p,k,c) {\n var j0 = c[ 0] & 0xff | (c[ 1] & 0xff)<<8 | (c[ 2] & 0xff)<<16 | (c[ 3] & 0xff)<<24,\n j1 = k[ 0] & 0xff | (k[ 1] & 0xff)<<8 | (k[ 2] & 0xff)<<16 | (k[ 3] & 0xff)<<24,\n j2 = k[ 4] & 0xff | (k[ 5] & 0xff)<<8 | (k[ 6] & 0xff)<<16 | (k[ 7] & 0xff)<<24,\n j3 = k[ 8] & 0xff | (k[ 9] & 0xff)<<8 | (k[10] & 0xff)<<16 | (k[11] & 0xff)<<24,\n j4 = k[12] & 0xff | (k[13] & 0xff)<<8 | (k[14] & 0xff)<<16 | (k[15] & 0xff)<<24,\n j5 = c[ 4] & 0xff | (c[ 5] & 0xff)<<8 | (c[ 6] & 0xff)<<16 | (c[ 7] & 0xff)<<24,\n j6 = p[ 0] & 0xff | (p[ 1] & 0xff)<<8 | (p[ 2] & 0xff)<<16 | (p[ 3] & 0xff)<<24,\n j7 = p[ 4] & 0xff | (p[ 5] & 0xff)<<8 | (p[ 6] & 0xff)<<16 | (p[ 7] & 0xff)<<24,\n j8 = p[ 8] & 0xff | (p[ 9] & 0xff)<<8 | (p[10] & 0xff)<<16 | (p[11] & 0xff)<<24,\n j9 = p[12] & 0xff | (p[13] & 0xff)<<8 | (p[14] & 0xff)<<16 | (p[15] & 0xff)<<24,\n j10 = c[ 8] & 0xff | (c[ 9] & 0xff)<<8 | (c[10] & 0xff)<<16 | (c[11] & 0xff)<<24,\n j11 = k[16] & 0xff | (k[17] & 0xff)<<8 | (k[18] & 0xff)<<16 | (k[19] & 0xff)<<24,\n j12 = k[20] & 0xff | (k[21] & 0xff)<<8 | (k[22] & 0xff)<<16 | (k[23] & 0xff)<<24,\n j13 = k[24] & 0xff | (k[25] & 0xff)<<8 | (k[26] & 0xff)<<16 | (k[27] & 0xff)<<24,\n j14 = k[28] & 0xff | (k[29] & 0xff)<<8 | (k[30] & 0xff)<<16 | (k[31] & 0xff)<<24,\n j15 = c[12] & 0xff | (c[13] & 0xff)<<8 | (c[14] & 0xff)<<16 | (c[15] & 0xff)<<24;\n\n var x0 = j0, x1 = j1, x2 = j2, x3 = j3, x4 = j4, x5 = j5, x6 = j6, x7 = j7,\n x8 = j8, x9 = j9, x10 = j10, x11 = j11, x12 = j12, x13 = j13, x14 = j14,\n x15 = j15, u;\n\n for (var i = 0; i < 20; i += 2) {\n u = x0 + x12 | 0;\n x4 ^= u<<7 | u>>>(32-7);\n u = x4 + x0 | 0;\n x8 ^= u<<9 | u>>>(32-9);\n u = x8 + x4 | 0;\n x12 ^= u<<13 | u>>>(32-13);\n u = x12 + x8 | 0;\n x0 ^= u<<18 | u>>>(32-18);\n\n u = x5 + x1 | 0;\n x9 ^= u<<7 | u>>>(32-7);\n u = x9 + x5 | 0;\n x13 ^= u<<9 | u>>>(32-9);\n u = x13 + x9 | 0;\n x1 ^= u<<13 | u>>>(32-13);\n u = x1 + x13 | 0;\n x5 ^= u<<18 | u>>>(32-18);\n\n u = x10 + x6 | 0;\n x14 ^= u<<7 | u>>>(32-7);\n u = x14 + x10 | 0;\n x2 ^= u<<9 | u>>>(32-9);\n u = x2 + x14 | 0;\n x6 ^= u<<13 | u>>>(32-13);\n u = x6 + x2 | 0;\n x10 ^= u<<18 | u>>>(32-18);\n\n u = x15 + x11 | 0;\n x3 ^= u<<7 | u>>>(32-7);\n u = x3 + x15 | 0;\n x7 ^= u<<9 | u>>>(32-9);\n u = x7 + x3 | 0;\n x11 ^= u<<13 | u>>>(32-13);\n u = x11 + x7 | 0;\n x15 ^= u<<18 | u>>>(32-18);\n\n u = x0 + x3 | 0;\n x1 ^= u<<7 | u>>>(32-7);\n u = x1 + x0 | 0;\n x2 ^= u<<9 | u>>>(32-9);\n u = x2 + x1 | 0;\n x3 ^= u<<13 | u>>>(32-13);\n u = x3 + x2 | 0;\n x0 ^= u<<18 | u>>>(32-18);\n\n u = x5 + x4 | 0;\n x6 ^= u<<7 | u>>>(32-7);\n u = x6 + x5 | 0;\n x7 ^= u<<9 | u>>>(32-9);\n u = x7 + x6 | 0;\n x4 ^= u<<13 | u>>>(32-13);\n u = x4 + x7 | 0;\n x5 ^= u<<18 | u>>>(32-18);\n\n u = x10 + x9 | 0;\n x11 ^= u<<7 | u>>>(32-7);\n u = x11 + x10 | 0;\n x8 ^= u<<9 | u>>>(32-9);\n u = x8 + x11 | 0;\n x9 ^= u<<13 | u>>>(32-13);\n u = x9 + x8 | 0;\n x10 ^= u<<18 | u>>>(32-18);\n\n u = x15 + x14 | 0;\n x12 ^= u<<7 | u>>>(32-7);\n u = x12 + x15 | 0;\n x13 ^= u<<9 | u>>>(32-9);\n u = x13 + x12 | 0;\n x14 ^= u<<13 | u>>>(32-13);\n u = x14 + x13 | 0;\n x15 ^= u<<18 | u>>>(32-18);\n }\n\n o[ 0] = x0 >>> 0 & 0xff;\n o[ 1] = x0 >>> 8 & 0xff;\n o[ 2] = x0 >>> 16 & 0xff;\n o[ 3] = x0 >>> 24 & 0xff;\n\n o[ 4] = x5 >>> 0 & 0xff;\n o[ 5] = x5 >>> 8 & 0xff;\n o[ 6] = x5 >>> 16 & 0xff;\n o[ 7] = x5 >>> 24 & 0xff;\n\n o[ 8] = x10 >>> 0 & 0xff;\n o[ 9] = x10 >>> 8 & 0xff;\n o[10] = x10 >>> 16 & 0xff;\n o[11] = x10 >>> 24 & 0xff;\n\n o[12] = x15 >>> 0 & 0xff;\n o[13] = x15 >>> 8 & 0xff;\n o[14] = x15 >>> 16 & 0xff;\n o[15] = x15 >>> 24 & 0xff;\n\n o[16] = x6 >>> 0 & 0xff;\n o[17] = x6 >>> 8 & 0xff;\n o[18] = x6 >>> 16 & 0xff;\n o[19] = x6 >>> 24 & 0xff;\n\n o[20] = x7 >>> 0 & 0xff;\n o[21] = x7 >>> 8 & 0xff;\n o[22] = x7 >>> 16 & 0xff;\n o[23] = x7 >>> 24 & 0xff;\n\n o[24] = x8 >>> 0 & 0xff;\n o[25] = x8 >>> 8 & 0xff;\n o[26] = x8 >>> 16 & 0xff;\n o[27] = x8 >>> 24 & 0xff;\n\n o[28] = x9 >>> 0 & 0xff;\n o[29] = x9 >>> 8 & 0xff;\n o[30] = x9 >>> 16 & 0xff;\n o[31] = x9 >>> 24 & 0xff;\n}\n\nfunction crypto_core_salsa20(out,inp,k,c) {\n core_salsa20(out,inp,k,c);\n}\n\nfunction crypto_core_hsalsa20(out,inp,k,c) {\n core_hsalsa20(out,inp,k,c);\n}\n\nvar sigma = new Uint8Array([101, 120, 112, 97, 110, 100, 32, 51, 50, 45, 98, 121, 116, 101, 32, 107]);\n // \"expand 32-byte k\"\n\nfunction crypto_stream_salsa20_xor(c,cpos,m,mpos,b,n,k) {\n var z = new Uint8Array(16), x = new Uint8Array(64);\n var u, i;\n for (i = 0; i < 16; i++) z[i] = 0;\n for (i = 0; i < 8; i++) z[i] = n[i];\n while (b >= 64) {\n crypto_core_salsa20(x,z,k,sigma);\n for (i = 0; i < 64; i++) c[cpos+i] = m[mpos+i] ^ x[i];\n u = 1;\n for (i = 8; i < 16; i++) {\n u = u + (z[i] & 0xff) | 0;\n z[i] = u & 0xff;\n u >>>= 8;\n }\n b -= 64;\n cpos += 64;\n mpos += 64;\n }\n if (b > 0) {\n crypto_core_salsa20(x,z,k,sigma);\n for (i = 0; i < b; i++) c[cpos+i] = m[mpos+i] ^ x[i];\n }\n return 0;\n}\n\nfunction crypto_stream_salsa20(c,cpos,b,n,k) {\n var z = new Uint8Array(16), x = new Uint8Array(64);\n var u, i;\n for (i = 0; i < 16; i++) z[i] = 0;\n for (i = 0; i < 8; i++) z[i] = n[i];\n while (b >= 64) {\n crypto_core_salsa20(x,z,k,sigma);\n for (i = 0; i < 64; i++) c[cpos+i] = x[i];\n u = 1;\n for (i = 8; i < 16; i++) {\n u = u + (z[i] & 0xff) | 0;\n z[i] = u & 0xff;\n u >>>= 8;\n }\n b -= 64;\n cpos += 64;\n }\n if (b > 0) {\n crypto_core_salsa20(x,z,k,sigma);\n for (i = 0; i < b; i++) c[cpos+i] = x[i];\n }\n return 0;\n}\n\nfunction crypto_stream(c,cpos,d,n,k) {\n var s = new Uint8Array(32);\n crypto_core_hsalsa20(s,n,k,sigma);\n var sn = new Uint8Array(8);\n for (var i = 0; i < 8; i++) sn[i] = n[i+16];\n return crypto_stream_salsa20(c,cpos,d,sn,s);\n}\n\nfunction crypto_stream_xor(c,cpos,m,mpos,d,n,k) {\n var s = new Uint8Array(32);\n crypto_core_hsalsa20(s,n,k,sigma);\n var sn = new Uint8Array(8);\n for (var i = 0; i < 8; i++) sn[i] = n[i+16];\n return crypto_stream_salsa20_xor(c,cpos,m,mpos,d,sn,s);\n}\n\n/*\n* Port of Andrew Moon's Poly1305-donna-16. Public domain.\n* https://github.com/floodyberry/poly1305-donna\n*/\n\nvar poly1305 = function(key) {\n this.buffer = new Uint8Array(16);\n this.r = new Uint16Array(10);\n this.h = new Uint16Array(10);\n this.pad = new Uint16Array(8);\n this.leftover = 0;\n this.fin = 0;\n\n var t0, t1, t2, t3, t4, t5, t6, t7;\n\n t0 = key[ 0] & 0xff | (key[ 1] & 0xff) << 8; this.r[0] = ( t0 ) & 0x1fff;\n t1 = key[ 2] & 0xff | (key[ 3] & 0xff) << 8; this.r[1] = ((t0 >>> 13) | (t1 << 3)) & 0x1fff;\n t2 = key[ 4] & 0xff | (key[ 5] & 0xff) << 8; this.r[2] = ((t1 >>> 10) | (t2 << 6)) & 0x1f03;\n t3 = key[ 6] & 0xff | (key[ 7] & 0xff) << 8; this.r[3] = ((t2 >>> 7) | (t3 << 9)) & 0x1fff;\n t4 = key[ 8] & 0xff | (key[ 9] & 0xff) << 8; this.r[4] = ((t3 >>> 4) | (t4 << 12)) & 0x00ff;\n this.r[5] = ((t4 >>> 1)) & 0x1ffe;\n t5 = key[10] & 0xff | (key[11] & 0xff) << 8; this.r[6] = ((t4 >>> 14) | (t5 << 2)) & 0x1fff;\n t6 = key[12] & 0xff | (key[13] & 0xff) << 8; this.r[7] = ((t5 >>> 11) | (t6 << 5)) & 0x1f81;\n t7 = key[14] & 0xff | (key[15] & 0xff) << 8; this.r[8] = ((t6 >>> 8) | (t7 << 8)) & 0x1fff;\n this.r[9] = ((t7 >>> 5)) & 0x007f;\n\n this.pad[0] = key[16] & 0xff | (key[17] & 0xff) << 8;\n this.pad[1] = key[18] & 0xff | (key[19] & 0xff) << 8;\n this.pad[2] = key[20] & 0xff | (key[21] & 0xff) << 8;\n this.pad[3] = key[22] & 0xff | (key[23] & 0xff) << 8;\n this.pad[4] = key[24] & 0xff | (key[25] & 0xff) << 8;\n this.pad[5] = key[26] & 0xff | (key[27] & 0xff) << 8;\n this.pad[6] = key[28] & 0xff | (key[29] & 0xff) << 8;\n this.pad[7] = key[30] & 0xff | (key[31] & 0xff) << 8;\n};\n\npoly1305.prototype.blocks = function(m, mpos, bytes) {\n var hibit = this.fin ? 0 : (1 << 11);\n var t0, t1, t2, t3, t4, t5, t6, t7, c;\n var d0, d1, d2, d3, d4, d5, d6, d7, d8, d9;\n\n var h0 = this.h[0],\n h1 = this.h[1],\n h2 = this.h[2],\n h3 = this.h[3],\n h4 = this.h[4],\n h5 = this.h[5],\n h6 = this.h[6],\n h7 = this.h[7],\n h8 = this.h[8],\n h9 = this.h[9];\n\n var r0 = this.r[0],\n r1 = this.r[1],\n r2 = this.r[2],\n r3 = this.r[3],\n r4 = this.r[4],\n r5 = this.r[5],\n r6 = this.r[6],\n r7 = this.r[7],\n r8 = this.r[8],\n r9 = this.r[9];\n\n while (bytes >= 16) {\n t0 = m[mpos+ 0] & 0xff | (m[mpos+ 1] & 0xff) << 8; h0 += ( t0 ) & 0x1fff;\n t1 = m[mpos+ 2] & 0xff | (m[mpos+ 3] & 0xff) << 8; h1 += ((t0 >>> 13) | (t1 << 3)) & 0x1fff;\n t2 = m[mpos+ 4] & 0xff | (m[mpos+ 5] & 0xff) << 8; h2 += ((t1 >>> 10) | (t2 << 6)) & 0x1fff;\n t3 = m[mpos+ 6] & 0xff | (m[mpos+ 7] & 0xff) << 8; h3 += ((t2 >>> 7) | (t3 << 9)) & 0x1fff;\n t4 = m[mpos+ 8] & 0xff | (m[mpos+ 9] & 0xff) << 8; h4 += ((t3 >>> 4) | (t4 << 12)) & 0x1fff;\n h5 += ((t4 >>> 1)) & 0x1fff;\n t5 = m[mpos+10] & 0xff | (m[mpos+11] & 0xff) << 8; h6 += ((t4 >>> 14) | (t5 << 2)) & 0x1fff;\n t6 = m[mpos+12] & 0xff | (m[mpos+13] & 0xff) << 8; h7 += ((t5 >>> 11) | (t6 << 5)) & 0x1fff;\n t7 = m[mpos+14] & 0xff | (m[mpos+15] & 0xff) << 8; h8 += ((t6 >>> 8) | (t7 << 8)) & 0x1fff;\n h9 += ((t7 >>> 5)) | hibit;\n\n c = 0;\n\n d0 = c;\n d0 += h0 * r0;\n d0 += h1 * (5 * r9);\n d0 += h2 * (5 * r8);\n d0 += h3 * (5 * r7);\n d0 += h4 * (5 * r6);\n c = (d0 >>> 13); d0 &= 0x1fff;\n d0 += h5 * (5 * r5);\n d0 += h6 * (5 * r4);\n d0 += h7 * (5 * r3);\n d0 += h8 * (5 * r2);\n d0 += h9 * (5 * r1);\n c += (d0 >>> 13); d0 &= 0x1fff;\n\n d1 = c;\n d1 += h0 * r1;\n d1 += h1 * r0;\n d1 += h2 * (5 * r9);\n d1 += h3 * (5 * r8);\n d1 += h4 * (5 * r7);\n c = (d1 >>> 13); d1 &= 0x1fff;\n d1 += h5 * (5 * r6);\n d1 += h6 * (5 * r5);\n d1 += h7 * (5 * r4);\n d1 += h8 * (5 * r3);\n d1 += h9 * (5 * r2);\n c += (d1 >>> 13); d1 &= 0x1fff;\n\n d2 = c;\n d2 += h0 * r2;\n d2 += h1 * r1;\n d2 += h2 * r0;\n d2 += h3 * (5 * r9);\n d2 += h4 * (5 * r8);\n c = (d2 >>> 13); d2 &= 0x1fff;\n d2 += h5 * (5 * r7);\n d2 += h6 * (5 * r6);\n d2 += h7 * (5 * r5);\n d2 += h8 * (5 * r4);\n d2 += h9 * (5 * r3);\n c += (d2 >>> 13); d2 &= 0x1fff;\n\n d3 = c;\n d3 += h0 * r3;\n d3 += h1 * r2;\n d3 += h2 * r1;\n d3 += h3 * r0;\n d3 += h4 * (5 * r9);\n c = (d3 >>> 13); d3 &= 0x1fff;\n d3 += h5 * (5 * r8);\n d3 += h6 * (5 * r7);\n d3 += h7 * (5 * r6);\n d3 += h8 * (5 * r5);\n d3 += h9 * (5 * r4);\n c += (d3 >>> 13); d3 &= 0x1fff;\n\n d4 = c;\n d4 += h0 * r4;\n d4 += h1 * r3;\n d4 += h2 * r2;\n d4 += h3 * r1;\n d4 += h4 * r0;\n c = (d4 >>> 13); d4 &= 0x1fff;\n d4 += h5 * (5 * r9);\n d4 += h6 * (5 * r8);\n d4 += h7 * (5 * r7);\n d4 += h8 * (5 * r6);\n d4 += h9 * (5 * r5);\n c += (d4 >>> 13); d4 &= 0x1fff;\n\n d5 = c;\n d5 += h0 * r5;\n d5 += h1 * r4;\n d5 += h2 * r3;\n d5 += h3 * r2;\n d5 += h4 * r1;\n c = (d5 >>> 13); d5 &= 0x1fff;\n d5 += h5 * r0;\n d5 += h6 * (5 * r9);\n d5 += h7 * (5 * r8);\n d5 += h8 * (5 * r7);\n d5 += h9 * (5 * r6);\n c += (d5 >>> 13); d5 &= 0x1fff;\n\n d6 = c;\n d6 += h0 * r6;\n d6 += h1 * r5;\n d6 += h2 * r4;\n d6 += h3 * r3;\n d6 += h4 * r2;\n c = (d6 >>> 13); d6 &= 0x1fff;\n d6 += h5 * r1;\n d6 += h6 * r0;\n d6 += h7 * (5 * r9);\n d6 += h8 * (5 * r8);\n d6 += h9 * (5 * r7);\n c += (d6 >>> 13); d6 &= 0x1fff;\n\n d7 = c;\n d7 += h0 * r7;\n d7 += h1 * r6;\n d7 += h2 * r5;\n d7 += h3 * r4;\n d7 += h4 * r3;\n c = (d7 >>> 13); d7 &= 0x1fff;\n d7 += h5 * r2;\n d7 += h6 * r1;\n d7 += h7 * r0;\n d7 += h8 * (5 * r9);\n d7 += h9 * (5 * r8);\n c += (d7 >>> 13); d7 &= 0x1fff;\n\n d8 = c;\n d8 += h0 * r8;\n d8 += h1 * r7;\n d8 += h2 * r6;\n d8 += h3 * r5;\n d8 += h4 * r4;\n c = (d8 >>> 13); d8 &= 0x1fff;\n d8 += h5 * r3;\n d8 += h6 * r2;\n d8 += h7 * r1;\n d8 += h8 * r0;\n d8 += h9 * (5 * r9);\n c += (d8 >>> 13); d8 &= 0x1fff;\n\n d9 = c;\n d9 += h0 * r9;\n d9 += h1 * r8;\n d9 += h2 * r7;\n d9 += h3 * r6;\n d9 += h4 * r5;\n c = (d9 >>> 13); d9 &= 0x1fff;\n d9 += h5 * r4;\n d9 += h6 * r3;\n d9 += h7 * r2;\n d9 += h8 * r1;\n d9 += h9 * r0;\n c += (d9 >>> 13); d9 &= 0x1fff;\n\n c = (((c << 2) + c)) | 0;\n c = (c + d0) | 0;\n d0 = c & 0x1fff;\n c = (c >>> 13);\n d1 += c;\n\n h0 = d0;\n h1 = d1;\n h2 = d2;\n h3 = d3;\n h4 = d4;\n h5 = d5;\n h6 = d6;\n h7 = d7;\n h8 = d8;\n h9 = d9;\n\n mpos += 16;\n bytes -= 16;\n }\n this.h[0] = h0;\n this.h[1] = h1;\n this.h[2] = h2;\n this.h[3] = h3;\n this.h[4] = h4;\n this.h[5] = h5;\n this.h[6] = h6;\n this.h[7] = h7;\n this.h[8] = h8;\n this.h[9] = h9;\n};\n\npoly1305.prototype.finish = function(mac, macpos) {\n var g = new Uint16Array(10);\n var c, mask, f, i;\n\n if (this.leftover) {\n i = this.leftover;\n this.buffer[i++] = 1;\n for (; i < 16; i++) this.buffer[i] = 0;\n this.fin = 1;\n this.blocks(this.buffer, 0, 16);\n }\n\n c = this.h[1] >>> 13;\n this.h[1] &= 0x1fff;\n for (i = 2; i < 10; i++) {\n this.h[i] += c;\n c = this.h[i] >>> 13;\n this.h[i] &= 0x1fff;\n }\n this.h[0] += (c * 5);\n c = this.h[0] >>> 13;\n this.h[0] &= 0x1fff;\n this.h[1] += c;\n c = this.h[1] >>> 13;\n this.h[1] &= 0x1fff;\n this.h[2] += c;\n\n g[0] = this.h[0] + 5;\n c = g[0] >>> 13;\n g[0] &= 0x1fff;\n for (i = 1; i < 10; i++) {\n g[i] = this.h[i] + c;\n c = g[i] >>> 13;\n g[i] &= 0x1fff;\n }\n g[9] -= (1 << 13);\n\n mask = (c ^ 1) - 1;\n for (i = 0; i < 10; i++) g[i] &= mask;\n mask = ~mask;\n for (i = 0; i < 10; i++) this.h[i] = (this.h[i] & mask) | g[i];\n\n this.h[0] = ((this.h[0] ) | (this.h[1] << 13) ) & 0xffff;\n this.h[1] = ((this.h[1] >>> 3) | (this.h[2] << 10) ) & 0xffff;\n this.h[2] = ((this.h[2] >>> 6) | (this.h[3] << 7) ) & 0xffff;\n this.h[3] = ((this.h[3] >>> 9) | (this.h[4] << 4) ) & 0xffff;\n this.h[4] = ((this.h[4] >>> 12) | (this.h[5] << 1) | (this.h[6] << 14)) & 0xffff;\n this.h[5] = ((this.h[6] >>> 2) | (this.h[7] << 11) ) & 0xffff;\n this.h[6] = ((this.h[7] >>> 5) | (this.h[8] << 8) ) & 0xffff;\n this.h[7] = ((this.h[8] >>> 8) | (this.h[9] << 5) ) & 0xffff;\n\n f = this.h[0] + this.pad[0];\n this.h[0] = f & 0xffff;\n for (i = 1; i < 8; i++) {\n f = (((this.h[i] + this.pad[i]) | 0) + (f >>> 16)) | 0;\n this.h[i] = f & 0xffff;\n }\n\n mac[macpos+ 0] = (this.h[0] >>> 0) & 0xff;\n mac[macpos+ 1] = (this.h[0] >>> 8) & 0xff;\n mac[macpos+ 2] = (this.h[1] >>> 0) & 0xff;\n mac[macpos+ 3] = (this.h[1] >>> 8) & 0xff;\n mac[macpos+ 4] = (this.h[2] >>> 0) & 0xff;\n mac[macpos+ 5] = (this.h[2] >>> 8) & 0xff;\n mac[macpos+ 6] = (this.h[3] >>> 0) & 0xff;\n mac[macpos+ 7] = (this.h[3] >>> 8) & 0xff;\n mac[macpos+ 8] = (this.h[4] >>> 0) & 0xff;\n mac[macpos+ 9] = (this.h[4] >>> 8) & 0xff;\n mac[macpos+10] = (this.h[5] >>> 0) & 0xff;\n mac[macpos+11] = (this.h[5] >>> 8) & 0xff;\n mac[macpos+12] = (this.h[6] >>> 0) & 0xff;\n mac[macpos+13] = (this.h[6] >>> 8) & 0xff;\n mac[macpos+14] = (this.h[7] >>> 0) & 0xff;\n mac[macpos+15] = (this.h[7] >>> 8) & 0xff;\n};\n\npoly1305.prototype.update = function(m, mpos, bytes) {\n var i, want;\n\n if (this.leftover) {\n want = (16 - this.leftover);\n if (want > bytes)\n want = bytes;\n for (i = 0; i < want; i++)\n this.buffer[this.leftover + i] = m[mpos+i];\n bytes -= want;\n mpos += want;\n this.leftover += want;\n if (this.leftover < 16)\n return;\n this.blocks(this.buffer, 0, 16);\n this.leftover = 0;\n }\n\n if (bytes >= 16) {\n want = bytes - (bytes % 16);\n this.blocks(m, mpos, want);\n mpos += want;\n bytes -= want;\n }\n\n if (bytes) {\n for (i = 0; i < bytes; i++)\n this.buffer[this.leftover + i] = m[mpos+i];\n this.leftover += bytes;\n }\n};\n\nfunction crypto_onetimeauth(out, outpos, m, mpos, n, k) {\n var s = new poly1305(k);\n s.update(m, mpos, n);\n s.finish(out, outpos);\n return 0;\n}\n\nfunction crypto_onetimeauth_verify(h, hpos, m, mpos, n, k) {\n var x = new Uint8Array(16);\n crypto_onetimeauth(x,0,m,mpos,n,k);\n return crypto_verify_16(h,hpos,x,0);\n}\n\nfunction crypto_secretbox(c,m,d,n,k) {\n var i;\n if (d < 32) return -1;\n crypto_stream_xor(c,0,m,0,d,n,k);\n crypto_onetimeauth(c, 16, c, 32, d - 32, c);\n for (i = 0; i < 16; i++) c[i] = 0;\n return 0;\n}\n\nfunction crypto_secretbox_open(m,c,d,n,k) {\n var i;\n var x = new Uint8Array(32);\n if (d < 32) return -1;\n crypto_stream(x,0,32,n,k);\n if (crypto_onetimeauth_verify(c, 16,c, 32,d - 32,x) !== 0) return -1;\n crypto_stream_xor(m,0,c,0,d,n,k);\n for (i = 0; i < 32; i++) m[i] = 0;\n return 0;\n}\n\nfunction set25519(r, a) {\n var i;\n for (i = 0; i < 16; i++) r[i] = a[i]|0;\n}\n\nfunction car25519(o) {\n var i, v, c = 1;\n for (i = 0; i < 16; i++) {\n v = o[i] + c + 65535;\n c = Math.floor(v / 65536);\n o[i] = v - c * 65536;\n }\n o[0] += c-1 + 37 * (c-1);\n}\n\nfunction sel25519(p, q, b) {\n var t, c = ~(b-1);\n for (var i = 0; i < 16; i++) {\n t = c & (p[i] ^ q[i]);\n p[i] ^= t;\n q[i] ^= t;\n }\n}\n\nfunction pack25519(o, n) {\n var i, j, b;\n var m = gf(), t = gf();\n for (i = 0; i < 16; i++) t[i] = n[i];\n car25519(t);\n car25519(t);\n car25519(t);\n for (j = 0; j < 2; j++) {\n m[0] = t[0] - 0xffed;\n for (i = 1; i < 15; i++) {\n m[i] = t[i] - 0xffff - ((m[i-1]>>16) & 1);\n m[i-1] &= 0xffff;\n }\n m[15] = t[15] - 0x7fff - ((m[14]>>16) & 1);\n b = (m[15]>>16) & 1;\n m[14] &= 0xffff;\n sel25519(t, m, 1-b);\n }\n for (i = 0; i < 16; i++) {\n o[2*i] = t[i] & 0xff;\n o[2*i+1] = t[i]>>8;\n }\n}\n\nfunction neq25519(a, b) {\n var c = new Uint8Array(32), d = new Uint8Array(32);\n pack25519(c, a);\n pack25519(d, b);\n return crypto_verify_32(c, 0, d, 0);\n}\n\nfunction par25519(a) {\n var d = new Uint8Array(32);\n pack25519(d, a);\n return d[0] & 1;\n}\n\nfunction unpack25519(o, n) {\n var i;\n for (i = 0; i < 16; i++) o[i] = n[2*i] + (n[2*i+1] << 8);\n o[15] &= 0x7fff;\n}\n\nfunction A(o, a, b) {\n for (var i = 0; i < 16; i++) o[i] = a[i] + b[i];\n}\n\nfunction Z(o, a, b) {\n for (var i = 0; i < 16; i++) o[i] = a[i] - b[i];\n}\n\nfunction M(o, a, b) {\n var v, c,\n t0 = 0, t1 = 0, t2 = 0, t3 = 0, t4 = 0, t5 = 0, t6 = 0, t7 = 0,\n t8 = 0, t9 = 0, t10 = 0, t11 = 0, t12 = 0, t13 = 0, t14 = 0, t15 = 0,\n t16 = 0, t17 = 0, t18 = 0, t19 = 0, t20 = 0, t21 = 0, t22 = 0, t23 = 0,\n t24 = 0, t25 = 0, t26 = 0, t27 = 0, t28 = 0, t29 = 0, t30 = 0,\n b0 = b[0],\n b1 = b[1],\n b2 = b[2],\n b3 = b[3],\n b4 = b[4],\n b5 = b[5],\n b6 = b[6],\n b7 = b[7],\n b8 = b[8],\n b9 = b[9],\n b10 = b[10],\n b11 = b[11],\n b12 = b[12],\n b13 = b[13],\n b14 = b[14],\n b15 = b[15];\n\n v = a[0];\n t0 += v * b0;\n t1 += v * b1;\n t2 += v * b2;\n t3 += v * b3;\n t4 += v * b4;\n t5 += v * b5;\n t6 += v * b6;\n t7 += v * b7;\n t8 += v * b8;\n t9 += v * b9;\n t10 += v * b10;\n t11 += v * b11;\n t12 += v * b12;\n t13 += v * b13;\n t14 += v * b14;\n t15 += v * b15;\n v = a[1];\n t1 += v * b0;\n t2 += v * b1;\n t3 += v * b2;\n t4 += v * b3;\n t5 += v * b4;\n t6 += v * b5;\n t7 += v * b6;\n t8 += v * b7;\n t9 += v * b8;\n t10 += v * b9;\n t11 += v * b10;\n t12 += v * b11;\n t13 += v * b12;\n t14 += v * b13;\n t15 += v * b14;\n t16 += v * b15;\n v = a[2];\n t2 += v * b0;\n t3 += v * b1;\n t4 += v * b2;\n t5 += v * b3;\n t6 += v * b4;\n t7 += v * b5;\n t8 += v * b6;\n t9 += v * b7;\n t10 += v * b8;\n t11 += v * b9;\n t12 += v * b10;\n t13 += v * b11;\n t14 += v * b12;\n t15 += v * b13;\n t16 += v * b14;\n t17 += v * b15;\n v = a[3];\n t3 += v * b0;\n t4 += v * b1;\n t5 += v * b2;\n t6 += v * b3;\n t7 += v * b4;\n t8 += v * b5;\n t9 += v * b6;\n t10 += v * b7;\n t11 += v * b8;\n t12 += v * b9;\n t13 += v * b10;\n t14 += v * b11;\n t15 += v * b12;\n t16 += v * b13;\n t17 += v * b14;\n t18 += v * b15;\n v = a[4];\n t4 += v * b0;\n t5 += v * b1;\n t6 += v * b2;\n t7 += v * b3;\n t8 += v * b4;\n t9 += v * b5;\n t10 += v * b6;\n t11 += v * b7;\n t12 += v * b8;\n t13 += v * b9;\n t14 += v * b10;\n t15 += v * b11;\n t16 += v * b12;\n t17 += v * b13;\n t18 += v * b14;\n t19 += v * b15;\n v = a[5];\n t5 += v * b0;\n t6 += v * b1;\n t7 += v * b2;\n t8 += v * b3;\n t9 += v * b4;\n t10 += v * b5;\n t11 += v * b6;\n t12 += v * b7;\n t13 += v * b8;\n t14 += v * b9;\n t15 += v * b10;\n t16 += v * b11;\n t17 += v * b12;\n t18 += v * b13;\n t19 += v * b14;\n t20 += v * b15;\n v = a[6];\n t6 += v * b0;\n t7 += v * b1;\n t8 += v * b2;\n t9 += v * b3;\n t10 += v * b4;\n t11 += v * b5;\n t12 += v * b6;\n t13 += v * b7;\n t14 += v * b8;\n t15 += v * b9;\n t16 += v * b10;\n t17 += v * b11;\n t18 += v * b12;\n t19 += v * b13;\n t20 += v * b14;\n t21 += v * b15;\n v = a[7];\n t7 += v * b0;\n t8 += v * b1;\n t9 += v * b2;\n t10 += v * b3;\n t11 += v * b4;\n t12 += v * b5;\n t13 += v * b6;\n t14 += v * b7;\n t15 += v * b8;\n t16 += v * b9;\n t17 += v * b10;\n t18 += v * b11;\n t19 += v * b12;\n t20 += v * b13;\n t21 += v * b14;\n t22 += v * b15;\n v = a[8];\n t8 += v * b0;\n t9 += v * b1;\n t10 += v * b2;\n t11 += v * b3;\n t12 += v * b4;\n t13 += v * b5;\n t14 += v * b6;\n t15 += v * b7;\n t16 += v * b8;\n t17 += v * b9;\n t18 += v * b10;\n t19 += v * b11;\n t20 += v * b12;\n t21 += v * b13;\n t22 += v * b14;\n t23 += v * b15;\n v = a[9];\n t9 += v * b0;\n t10 += v * b1;\n t11 += v * b2;\n t12 += v * b3;\n t13 += v * b4;\n t14 += v * b5;\n t15 += v * b6;\n t16 += v * b7;\n t17 += v * b8;\n t18 += v * b9;\n t19 += v * b10;\n t20 += v * b11;\n t21 += v * b12;\n t22 += v * b13;\n t23 += v * b14;\n t24 += v * b15;\n v = a[10];\n t10 += v * b0;\n t11 += v * b1;\n t12 += v * b2;\n t13 += v * b3;\n t14 += v * b4;\n t15 += v * b5;\n t16 += v * b6;\n t17 += v * b7;\n t18 += v * b8;\n t19 += v * b9;\n t20 += v * b10;\n t21 += v * b11;\n t22 += v * b12;\n t23 += v * b13;\n t24 += v * b14;\n t25 += v * b15;\n v = a[11];\n t11 += v * b0;\n t12 += v * b1;\n t13 += v * b2;\n t14 += v * b3;\n t15 += v * b4;\n t16 += v * b5;\n t17 += v * b6;\n t18 += v * b7;\n t19 += v * b8;\n t20 += v * b9;\n t21 += v * b10;\n t22 += v * b11;\n t23 += v * b12;\n t24 += v * b13;\n t25 += v * b14;\n t26 += v * b15;\n v = a[12];\n t12 += v * b0;\n t13 += v * b1;\n t14 += v * b2;\n t15 += v * b3;\n t16 += v * b4;\n t17 += v * b5;\n t18 += v * b6;\n t19 += v * b7;\n t20 += v * b8;\n t21 += v * b9;\n t22 += v * b10;\n t23 += v * b11;\n t24 += v * b12;\n t25 += v * b13;\n t26 += v * b14;\n t27 += v * b15;\n v = a[13];\n t13 += v * b0;\n t14 += v * b1;\n t15 += v * b2;\n t16 += v * b3;\n t17 += v * b4;\n t18 += v * b5;\n t19 += v * b6;\n t20 += v * b7;\n t21 += v * b8;\n t22 += v * b9;\n t23 += v * b10;\n t24 += v * b11;\n t25 += v * b12;\n t26 += v * b13;\n t27 += v * b14;\n t28 += v * b15;\n v = a[14];\n t14 += v * b0;\n t15 += v * b1;\n t16 += v * b2;\n t17 += v * b3;\n t18 += v * b4;\n t19 += v * b5;\n t20 += v * b6;\n t21 += v * b7;\n t22 += v * b8;\n t23 += v * b9;\n t24 += v * b10;\n t25 += v * b11;\n t26 += v * b12;\n t27 += v * b13;\n t28 += v * b14;\n t29 += v * b15;\n v = a[15];\n t15 += v * b0;\n t16 += v * b1;\n t17 += v * b2;\n t18 += v * b3;\n t19 += v * b4;\n t20 += v * b5;\n t21 += v * b6;\n t22 += v * b7;\n t23 += v * b8;\n t24 += v * b9;\n t25 += v * b10;\n t26 += v * b11;\n t27 += v * b12;\n t28 += v * b13;\n t29 += v * b14;\n t30 += v * b15;\n\n t0 += 38 * t16;\n t1 += 38 * t17;\n t2 += 38 * t18;\n t3 += 38 * t19;\n t4 += 38 * t20;\n t5 += 38 * t21;\n t6 += 38 * t22;\n t7 += 38 * t23;\n t8 += 38 * t24;\n t9 += 38 * t25;\n t10 += 38 * t26;\n t11 += 38 * t27;\n t12 += 38 * t28;\n t13 += 38 * t29;\n t14 += 38 * t30;\n // t15 left as is\n\n // first car\n c = 1;\n v = t0 + c + 65535; c = Math.floor(v / 65536); t0 = v - c * 65536;\n v = t1 + c + 65535; c = Math.floor(v / 65536); t1 = v - c * 65536;\n v = t2 + c + 65535; c = Math.floor(v / 65536); t2 = v - c * 65536;\n v = t3 + c + 65535; c = Math.floor(v / 65536); t3 = v - c * 65536;\n v = t4 + c + 65535; c = Math.floor(v / 65536); t4 = v - c * 65536;\n v = t5 + c + 65535; c = Math.floor(v / 65536); t5 = v - c * 65536;\n v = t6 + c + 65535; c = Math.floor(v / 65536); t6 = v - c * 65536;\n v = t7 + c + 65535; c = Math.floor(v / 65536); t7 = v - c * 65536;\n v = t8 + c + 65535; c = Math.floor(v / 65536); t8 = v - c * 65536;\n v = t9 + c + 65535; c = Math.floor(v / 65536); t9 = v - c * 65536;\n v = t10 + c + 65535; c = Math.floor(v / 65536); t10 = v - c * 65536;\n v = t11 + c + 65535; c = Math.floor(v / 65536); t11 = v - c * 65536;\n v = t12 + c + 65535; c = Math.floor(v / 65536); t12 = v - c * 65536;\n v = t13 + c + 65535; c = Math.floor(v / 65536); t13 = v - c * 65536;\n v = t14 + c + 65535; c = Math.floor(v / 65536); t14 = v - c * 65536;\n v = t15 + c + 65535; c = Math.floor(v / 65536); t15 = v - c * 65536;\n t0 += c-1 + 37 * (c-1);\n\n // second car\n c = 1;\n v = t0 + c + 65535; c = Math.floor(v / 65536); t0 = v - c * 65536;\n v = t1 + c + 65535; c = Math.floor(v / 65536); t1 = v - c * 65536;\n v = t2 + c + 65535; c = Math.floor(v / 65536); t2 = v - c * 65536;\n v = t3 + c + 65535; c = Math.floor(v / 65536); t3 = v - c * 65536;\n v = t4 + c + 65535; c = Math.floor(v / 65536); t4 = v - c * 65536;\n v = t5 + c + 65535; c = Math.floor(v / 65536); t5 = v - c * 65536;\n v = t6 + c + 65535; c = Math.floor(v / 65536); t6 = v - c * 65536;\n v = t7 + c + 65535; c = Math.floor(v / 65536); t7 = v - c * 65536;\n v = t8 + c + 65535; c = Math.floor(v / 65536); t8 = v - c * 65536;\n v = t9 + c + 65535; c = Math.floor(v / 65536); t9 = v - c * 65536;\n v = t10 + c + 65535; c = Math.floor(v / 65536); t10 = v - c * 65536;\n v = t11 + c + 65535; c = Math.floor(v / 65536); t11 = v - c * 65536;\n v = t12 + c + 65535; c = Math.floor(v / 65536); t12 = v - c * 65536;\n v = t13 + c + 65535; c = Math.floor(v / 65536); t13 = v - c * 65536;\n v = t14 + c + 65535; c = Math.floor(v / 65536); t14 = v - c * 65536;\n v = t15 + c + 65535; c = Math.floor(v / 65536); t15 = v - c * 65536;\n t0 += c-1 + 37 * (c-1);\n\n o[ 0] = t0;\n o[ 1] = t1;\n o[ 2] = t2;\n o[ 3] = t3;\n o[ 4] = t4;\n o[ 5] = t5;\n o[ 6] = t6;\n o[ 7] = t7;\n o[ 8] = t8;\n o[ 9] = t9;\n o[10] = t10;\n o[11] = t11;\n o[12] = t12;\n o[13] = t13;\n o[14] = t14;\n o[15] = t15;\n}\n\nfunction S(o, a) {\n M(o, a, a);\n}\n\nfunction inv25519(o, i) {\n var c = gf();\n var a;\n for (a = 0; a < 16; a++) c[a] = i[a];\n for (a = 253; a >= 0; a--) {\n S(c, c);\n if(a !== 2 && a !== 4) M(c, c, i);\n }\n for (a = 0; a < 16; a++) o[a] = c[a];\n}\n\nfunction pow2523(o, i) {\n var c = gf();\n var a;\n for (a = 0; a < 16; a++) c[a] = i[a];\n for (a = 250; a >= 0; a--) {\n S(c, c);\n if(a !== 1) M(c, c, i);\n }\n for (a = 0; a < 16; a++) o[a] = c[a];\n}\n\nfunction crypto_scalarmult(q, n, p) {\n var z = new Uint8Array(32);\n var x = new Float64Array(80), r, i;\n var a = gf(), b = gf(), c = gf(),\n d = gf(), e = gf(), f = gf();\n for (i = 0; i < 31; i++) z[i] = n[i];\n z[31]=(n[31]&127)|64;\n z[0]&=248;\n unpack25519(x,p);\n for (i = 0; i < 16; i++) {\n b[i]=x[i];\n d[i]=a[i]=c[i]=0;\n }\n a[0]=d[0]=1;\n for (i=254; i>=0; --i) {\n r=(z[i>>>3]>>>(i&7))&1;\n sel25519(a,b,r);\n sel25519(c,d,r);\n A(e,a,c);\n Z(a,a,c);\n A(c,b,d);\n Z(b,b,d);\n S(d,e);\n S(f,a);\n M(a,c,a);\n M(c,b,e);\n A(e,a,c);\n Z(a,a,c);\n S(b,a);\n Z(c,d,f);\n M(a,c,_121665);\n A(a,a,d);\n M(c,c,a);\n M(a,d,f);\n M(d,b,x);\n S(b,e);\n sel25519(a,b,r);\n sel25519(c,d,r);\n }\n for (i = 0; i < 16; i++) {\n x[i+16]=a[i];\n x[i+32]=c[i];\n x[i+48]=b[i];\n x[i+64]=d[i];\n }\n var x32 = x.subarray(32);\n var x16 = x.subarray(16);\n inv25519(x32,x32);\n M(x16,x16,x32);\n pack25519(q,x16);\n return 0;\n}\n\nfunction crypto_scalarmult_base(q, n) {\n return crypto_scalarmult(q, n, _9);\n}\n\nfunction crypto_box_keypair(y, x) {\n randombytes(x, 32);\n return crypto_scalarmult_base(y, x);\n}\n\nfunction crypto_box_beforenm(k, y, x) {\n var s = new Uint8Array(32);\n crypto_scalarmult(s, x, y);\n return crypto_core_hsalsa20(k, _0, s, sigma);\n}\n\nvar crypto_box_afternm = crypto_secretbox;\nvar crypto_box_open_afternm = crypto_secretbox_open;\n\nfunction crypto_box(c, m, d, n, y, x) {\n var k = new Uint8Array(32);\n crypto_box_beforenm(k, y, x);\n return crypto_box_afternm(c, m, d, n, k);\n}\n\nfunction crypto_box_open(m, c, d, n, y, x) {\n var k = new Uint8Array(32);\n crypto_box_beforenm(k, y, x);\n return crypto_box_open_afternm(m, c, d, n, k);\n}\n\nvar K = [\n 0x428a2f98, 0xd728ae22, 0x71374491, 0x23ef65cd,\n 0xb5c0fbcf, 0xec4d3b2f, 0xe9b5dba5, 0x8189dbbc,\n 0x3956c25b, 0xf348b538, 0x59f111f1, 0xb605d019,\n 0x923f82a4, 0xaf194f9b, 0xab1c5ed5, 0xda6d8118,\n 0xd807aa98, 0xa3030242, 0x12835b01, 0x45706fbe,\n 0x243185be, 0x4ee4b28c, 0x550c7dc3, 0xd5ffb4e2,\n 0x72be5d74, 0xf27b896f, 0x80deb1fe, 0x3b1696b1,\n 0x9bdc06a7, 0x25c71235, 0xc19bf174, 0xcf692694,\n 0xe49b69c1, 0x9ef14ad2, 0xefbe4786, 0x384f25e3,\n 0x0fc19dc6, 0x8b8cd5b5, 0x240ca1cc, 0x77ac9c65,\n 0x2de92c6f, 0x592b0275, 0x4a7484aa, 0x6ea6e483,\n 0x5cb0a9dc, 0xbd41fbd4, 0x76f988da, 0x831153b5,\n 0x983e5152, 0xee66dfab, 0xa831c66d, 0x2db43210,\n 0xb00327c8, 0x98fb213f, 0xbf597fc7, 0xbeef0ee4,\n 0xc6e00bf3, 0x3da88fc2, 0xd5a79147, 0x930aa725,\n 0x06ca6351, 0xe003826f, 0x14292967, 0x0a0e6e70,\n 0x27b70a85, 0x46d22ffc, 0x2e1b2138, 0x5c26c926,\n 0x4d2c6dfc, 0x5ac42aed, 0x53380d13, 0x9d95b3df,\n 0x650a7354, 0x8baf63de, 0x766a0abb, 0x3c77b2a8,\n 0x81c2c92e, 0x47edaee6, 0x92722c85, 0x1482353b,\n 0xa2bfe8a1, 0x4cf10364, 0xa81a664b, 0xbc423001,\n 0xc24b8b70, 0xd0f89791, 0xc76c51a3, 0x0654be30,\n 0xd192e819, 0xd6ef5218, 0xd6990624, 0x5565a910,\n 0xf40e3585, 0x5771202a, 0x106aa070, 0x32bbd1b8,\n 0x19a4c116, 0xb8d2d0c8, 0x1e376c08, 0x5141ab53,\n 0x2748774c, 0xdf8eeb99, 0x34b0bcb5, 0xe19b48a8,\n 0x391c0cb3, 0xc5c95a63, 0x4ed8aa4a, 0xe3418acb,\n 0x5b9cca4f, 0x7763e373, 0x682e6ff3, 0xd6b2b8a3,\n 0x748f82ee, 0x5defb2fc, 0x78a5636f, 0x43172f60,\n 0x84c87814, 0xa1f0ab72, 0x8cc70208, 0x1a6439ec,\n 0x90befffa, 0x23631e28, 0xa4506ceb, 0xde82bde9,\n 0xbef9a3f7, 0xb2c67915, 0xc67178f2, 0xe372532b,\n 0xca273ece, 0xea26619c, 0xd186b8c7, 0x21c0c207,\n 0xeada7dd6, 0xcde0eb1e, 0xf57d4f7f, 0xee6ed178,\n 0x06f067aa, 0x72176fba, 0x0a637dc5, 0xa2c898a6,\n 0x113f9804, 0xbef90dae, 0x1b710b35, 0x131c471b,\n 0x28db77f5, 0x23047d84, 0x32caab7b, 0x40c72493,\n 0x3c9ebe0a, 0x15c9bebc, 0x431d67c4, 0x9c100d4c,\n 0x4cc5d4be, 0xcb3e42b6, 0x597f299c, 0xfc657e2a,\n 0x5fcb6fab, 0x3ad6faec, 0x6c44198c, 0x4a475817\n];\n\nfunction crypto_hashblocks_hl(hh, hl, m, n) {\n var wh = new Int32Array(16), wl = new Int32Array(16),\n bh0, bh1, bh2, bh3, bh4, bh5, bh6, bh7,\n bl0, bl1, bl2, bl3, bl4, bl5, bl6, bl7,\n th, tl, i, j, h, l, a, b, c, d;\n\n var ah0 = hh[0],\n ah1 = hh[1],\n ah2 = hh[2],\n ah3 = hh[3],\n ah4 = hh[4],\n ah5 = hh[5],\n ah6 = hh[6],\n ah7 = hh[7],\n\n al0 = hl[0],\n al1 = hl[1],\n al2 = hl[2],\n al3 = hl[3],\n al4 = hl[4],\n al5 = hl[5],\n al6 = hl[6],\n al7 = hl[7];\n\n var pos = 0;\n while (n >= 128) {\n for (i = 0; i < 16; i++) {\n j = 8 * i + pos;\n wh[i] = (m[j+0] << 24) | (m[j+1] << 16) | (m[j+2] << 8) | m[j+3];\n wl[i] = (m[j+4] << 24) | (m[j+5] << 16) | (m[j+6] << 8) | m[j+7];\n }\n for (i = 0; i < 80; i++) {\n bh0 = ah0;\n bh1 = ah1;\n bh2 = ah2;\n bh3 = ah3;\n bh4 = ah4;\n bh5 = ah5;\n bh6 = ah6;\n bh7 = ah7;\n\n bl0 = al0;\n bl1 = al1;\n bl2 = al2;\n bl3 = al3;\n bl4 = al4;\n bl5 = al5;\n bl6 = al6;\n bl7 = al7;\n\n // add\n h = ah7;\n l = al7;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n // Sigma1\n h = ((ah4 >>> 14) | (al4 << (32-14))) ^ ((ah4 >>> 18) | (al4 << (32-18))) ^ ((al4 >>> (41-32)) | (ah4 << (32-(41-32))));\n l = ((al4 >>> 14) | (ah4 << (32-14))) ^ ((al4 >>> 18) | (ah4 << (32-18))) ^ ((ah4 >>> (41-32)) | (al4 << (32-(41-32))));\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // Ch\n h = (ah4 & ah5) ^ (~ah4 & ah6);\n l = (al4 & al5) ^ (~al4 & al6);\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // K\n h = K[i*2];\n l = K[i*2+1];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // w\n h = wh[i%16];\n l = wl[i%16];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n th = c & 0xffff | d << 16;\n tl = a & 0xffff | b << 16;\n\n // add\n h = th;\n l = tl;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n // Sigma0\n h = ((ah0 >>> 28) | (al0 << (32-28))) ^ ((al0 >>> (34-32)) | (ah0 << (32-(34-32)))) ^ ((al0 >>> (39-32)) | (ah0 << (32-(39-32))));\n l = ((al0 >>> 28) | (ah0 << (32-28))) ^ ((ah0 >>> (34-32)) | (al0 << (32-(34-32)))) ^ ((ah0 >>> (39-32)) | (al0 << (32-(39-32))));\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // Maj\n h = (ah0 & ah1) ^ (ah0 & ah2) ^ (ah1 & ah2);\n l = (al0 & al1) ^ (al0 & al2) ^ (al1 & al2);\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n bh7 = (c & 0xffff) | (d << 16);\n bl7 = (a & 0xffff) | (b << 16);\n\n // add\n h = bh3;\n l = bl3;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = th;\n l = tl;\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n bh3 = (c & 0xffff) | (d << 16);\n bl3 = (a & 0xffff) | (b << 16);\n\n ah1 = bh0;\n ah2 = bh1;\n ah3 = bh2;\n ah4 = bh3;\n ah5 = bh4;\n ah6 = bh5;\n ah7 = bh6;\n ah0 = bh7;\n\n al1 = bl0;\n al2 = bl1;\n al3 = bl2;\n al4 = bl3;\n al5 = bl4;\n al6 = bl5;\n al7 = bl6;\n al0 = bl7;\n\n if (i%16 === 15) {\n for (j = 0; j < 16; j++) {\n // add\n h = wh[j];\n l = wl[j];\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = wh[(j+9)%16];\n l = wl[(j+9)%16];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // sigma0\n th = wh[(j+1)%16];\n tl = wl[(j+1)%16];\n h = ((th >>> 1) | (tl << (32-1))) ^ ((th >>> 8) | (tl << (32-8))) ^ (th >>> 7);\n l = ((tl >>> 1) | (th << (32-1))) ^ ((tl >>> 8) | (th << (32-8))) ^ ((tl >>> 7) | (th << (32-7)));\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // sigma1\n th = wh[(j+14)%16];\n tl = wl[(j+14)%16];\n h = ((th >>> 19) | (tl << (32-19))) ^ ((tl >>> (61-32)) | (th << (32-(61-32)))) ^ (th >>> 6);\n l = ((tl >>> 19) | (th << (32-19))) ^ ((th >>> (61-32)) | (tl << (32-(61-32)))) ^ ((tl >>> 6) | (th << (32-6)));\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n wh[j] = (c & 0xffff) | (d << 16);\n wl[j] = (a & 0xffff) | (b << 16);\n }\n }\n }\n\n // add\n h = ah0;\n l = al0;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[0];\n l = hl[0];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[0] = ah0 = (c & 0xffff) | (d << 16);\n hl[0] = al0 = (a & 0xffff) | (b << 16);\n\n h = ah1;\n l = al1;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[1];\n l = hl[1];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[1] = ah1 = (c & 0xffff) | (d << 16);\n hl[1] = al1 = (a & 0xffff) | (b << 16);\n\n h = ah2;\n l = al2;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[2];\n l = hl[2];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[2] = ah2 = (c & 0xffff) | (d << 16);\n hl[2] = al2 = (a & 0xffff) | (b << 16);\n\n h = ah3;\n l = al3;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[3];\n l = hl[3];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[3] = ah3 = (c & 0xffff) | (d << 16);\n hl[3] = al3 = (a & 0xffff) | (b << 16);\n\n h = ah4;\n l = al4;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[4];\n l = hl[4];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[4] = ah4 = (c & 0xffff) | (d << 16);\n hl[4] = al4 = (a & 0xffff) | (b << 16);\n\n h = ah5;\n l = al5;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[5];\n l = hl[5];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[5] = ah5 = (c & 0xffff) | (d << 16);\n hl[5] = al5 = (a & 0xffff) | (b << 16);\n\n h = ah6;\n l = al6;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[6];\n l = hl[6];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[6] = ah6 = (c & 0xffff) | (d << 16);\n hl[6] = al6 = (a & 0xffff) | (b << 16);\n\n h = ah7;\n l = al7;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[7];\n l = hl[7];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[7] = ah7 = (c & 0xffff) | (d << 16);\n hl[7] = al7 = (a & 0xffff) | (b << 16);\n\n pos += 128;\n n -= 128;\n }\n\n return n;\n}\n\nfunction crypto_hash(out, m, n) {\n var hh = new Int32Array(8),\n hl = new Int32Array(8),\n x = new Uint8Array(256),\n i, b = n;\n\n hh[0] = 0x6a09e667;\n hh[1] = 0xbb67ae85;\n hh[2] = 0x3c6ef372;\n hh[3] = 0xa54ff53a;\n hh[4] = 0x510e527f;\n hh[5] = 0x9b05688c;\n hh[6] = 0x1f83d9ab;\n hh[7] = 0x5be0cd19;\n\n hl[0] = 0xf3bcc908;\n hl[1] = 0x84caa73b;\n hl[2] = 0xfe94f82b;\n hl[3] = 0x5f1d36f1;\n hl[4] = 0xade682d1;\n hl[5] = 0x2b3e6c1f;\n hl[6] = 0xfb41bd6b;\n hl[7] = 0x137e2179;\n\n crypto_hashblocks_hl(hh, hl, m, n);\n n %= 128;\n\n for (i = 0; i < n; i++) x[i] = m[b-n+i];\n x[n] = 128;\n\n n = 256-128*(n<112?1:0);\n x[n-9] = 0;\n ts64(x, n-8, (b / 0x20000000) | 0, b << 3);\n crypto_hashblocks_hl(hh, hl, x, n);\n\n for (i = 0; i < 8; i++) ts64(out, 8*i, hh[i], hl[i]);\n\n return 0;\n}\n\nfunction add(p, q) {\n var a = gf(), b = gf(), c = gf(),\n d = gf(), e = gf(), f = gf(),\n g = gf(), h = gf(), t = gf();\n\n Z(a, p[1], p[0]);\n Z(t, q[1], q[0]);\n M(a, a, t);\n A(b, p[0], p[1]);\n A(t, q[0], q[1]);\n M(b, b, t);\n M(c, p[3], q[3]);\n M(c, c, D2);\n M(d, p[2], q[2]);\n A(d, d, d);\n Z(e, b, a);\n Z(f, d, c);\n A(g, d, c);\n A(h, b, a);\n\n M(p[0], e, f);\n M(p[1], h, g);\n M(p[2], g, f);\n M(p[3], e, h);\n}\n\nfunction cswap(p, q, b) {\n var i;\n for (i = 0; i < 4; i++) {\n sel25519(p[i], q[i], b);\n }\n}\n\nfunction pack(r, p) {\n var tx = gf(), ty = gf(), zi = gf();\n inv25519(zi, p[2]);\n M(tx, p[0], zi);\n M(ty, p[1], zi);\n pack25519(r, ty);\n r[31] ^= par25519(tx) << 7;\n}\n\nfunction scalarmult(p, q, s) {\n var b, i;\n set25519(p[0], gf0);\n set25519(p[1], gf1);\n set25519(p[2], gf1);\n set25519(p[3], gf0);\n for (i = 255; i >= 0; --i) {\n b = (s[(i/8)|0] >> (i&7)) & 1;\n cswap(p, q, b);\n add(q, p);\n add(p, p);\n cswap(p, q, b);\n }\n}\n\nfunction scalarbase(p, s) {\n var q = [gf(), gf(), gf(), gf()];\n set25519(q[0], X);\n set25519(q[1], Y);\n set25519(q[2], gf1);\n M(q[3], X, Y);\n scalarmult(p, q, s);\n}\n\nfunction crypto_sign_keypair(pk, sk, seeded) {\n var d = new Uint8Array(64);\n var p = [gf(), gf(), gf(), gf()];\n var i;\n\n if (!seeded) randombytes(sk, 32);\n crypto_hash(d, sk, 32);\n d[0] &= 248;\n d[31] &= 127;\n d[31] |= 64;\n\n scalarbase(p, d);\n pack(pk, p);\n\n for (i = 0; i < 32; i++) sk[i+32] = pk[i];\n return 0;\n}\n\nvar L = new Float64Array([0xed, 0xd3, 0xf5, 0x5c, 0x1a, 0x63, 0x12, 0x58, 0xd6, 0x9c, 0xf7, 0xa2, 0xde, 0xf9, 0xde, 0x14, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x10]);\n\nfunction modL(r, x) {\n var carry, i, j, k;\n for (i = 63; i >= 32; --i) {\n carry = 0;\n for (j = i - 32, k = i - 12; j < k; ++j) {\n x[j] += carry - 16 * x[i] * L[j - (i - 32)];\n carry = Math.floor((x[j] + 128) / 256);\n x[j] -= carry * 256;\n }\n x[j] += carry;\n x[i] = 0;\n }\n carry = 0;\n for (j = 0; j < 32; j++) {\n x[j] += carry - (x[31] >> 4) * L[j];\n carry = x[j] >> 8;\n x[j] &= 255;\n }\n for (j = 0; j < 32; j++) x[j] -= carry * L[j];\n for (i = 0; i < 32; i++) {\n x[i+1] += x[i] >> 8;\n r[i] = x[i] & 255;\n }\n}\n\nfunction reduce(r) {\n var x = new Float64Array(64), i;\n for (i = 0; i < 64; i++) x[i] = r[i];\n for (i = 0; i < 64; i++) r[i] = 0;\n modL(r, x);\n}\n\n// Note: difference from C - smlen returned, not passed as argument.\nfunction crypto_sign(sm, m, n, sk) {\n var d = new Uint8Array(64), h = new Uint8Array(64), r = new Uint8Array(64);\n var i, j, x = new Float64Array(64);\n var p = [gf(), gf(), gf(), gf()];\n\n crypto_hash(d, sk, 32);\n d[0] &= 248;\n d[31] &= 127;\n d[31] |= 64;\n\n var smlen = n + 64;\n for (i = 0; i < n; i++) sm[64 + i] = m[i];\n for (i = 0; i < 32; i++) sm[32 + i] = d[32 + i];\n\n crypto_hash(r, sm.subarray(32), n+32);\n reduce(r);\n scalarbase(p, r);\n pack(sm, p);\n\n for (i = 32; i < 64; i++) sm[i] = sk[i];\n crypto_hash(h, sm, n + 64);\n reduce(h);\n\n for (i = 0; i < 64; i++) x[i] = 0;\n for (i = 0; i < 32; i++) x[i] = r[i];\n for (i = 0; i < 32; i++) {\n for (j = 0; j < 32; j++) {\n x[i+j] += h[i] * d[j];\n }\n }\n\n modL(sm.subarray(32), x);\n return smlen;\n}\n\nfunction unpackneg(r, p) {\n var t = gf(), chk = gf(), num = gf(),\n den = gf(), den2 = gf(), den4 = gf(),\n den6 = gf();\n\n set25519(r[2], gf1);\n unpack25519(r[1], p);\n S(num, r[1]);\n M(den, num, D);\n Z(num, num, r[2]);\n A(den, r[2], den);\n\n S(den2, den);\n S(den4, den2);\n M(den6, den4, den2);\n M(t, den6, num);\n M(t, t, den);\n\n pow2523(t, t);\n M(t, t, num);\n M(t, t, den);\n M(t, t, den);\n M(r[0], t, den);\n\n S(chk, r[0]);\n M(chk, chk, den);\n if (neq25519(chk, num)) M(r[0], r[0], I);\n\n S(chk, r[0]);\n M(chk, chk, den);\n if (neq25519(chk, num)) return -1;\n\n if (par25519(r[0]) === (p[31]>>7)) Z(r[0], gf0, r[0]);\n\n M(r[3], r[0], r[1]);\n return 0;\n}\n\nfunction crypto_sign_open(m, sm, n, pk) {\n var i;\n var t = new Uint8Array(32), h = new Uint8Array(64);\n var p = [gf(), gf(), gf(), gf()],\n q = [gf(), gf(), gf(), gf()];\n\n if (n < 64) return -1;\n\n if (unpackneg(q, pk)) return -1;\n\n for (i = 0; i < n; i++) m[i] = sm[i];\n for (i = 0; i < 32; i++) m[i+32] = pk[i];\n crypto_hash(h, m, n);\n reduce(h);\n scalarmult(p, q, h);\n\n scalarbase(q, sm.subarray(32));\n add(p, q);\n pack(t, p);\n\n n -= 64;\n if (crypto_verify_32(sm, 0, t, 0)) {\n for (i = 0; i < n; i++) m[i] = 0;\n return -1;\n }\n\n for (i = 0; i < n; i++) m[i] = sm[i + 64];\n return n;\n}\n\nvar crypto_secretbox_KEYBYTES = 32,\n crypto_secretbox_NONCEBYTES = 24,\n crypto_secretbox_ZEROBYTES = 32,\n crypto_secretbox_BOXZEROBYTES = 16,\n crypto_scalarmult_BYTES = 32,\n crypto_scalarmult_SCALARBYTES = 32,\n crypto_box_PUBLICKEYBYTES = 32,\n crypto_box_SECRETKEYBYTES = 32,\n crypto_box_BEFORENMBYTES = 32,\n crypto_box_NONCEBYTES = crypto_secretbox_NONCEBYTES,\n crypto_box_ZEROBYTES = crypto_secretbox_ZEROBYTES,\n crypto_box_BOXZEROBYTES = crypto_secretbox_BOXZEROBYTES,\n crypto_sign_BYTES = 64,\n crypto_sign_PUBLICKEYBYTES = 32,\n crypto_sign_SECRETKEYBYTES = 64,\n crypto_sign_SEEDBYTES = 32,\n crypto_hash_BYTES = 64;\n\nnacl.lowlevel = {\n crypto_core_hsalsa20: crypto_core_hsalsa20,\n crypto_stream_xor: crypto_stream_xor,\n crypto_stream: crypto_stream,\n crypto_stream_salsa20_xor: crypto_stream_salsa20_xor,\n crypto_stream_salsa20: crypto_stream_salsa20,\n crypto_onetimeauth: crypto_onetimeauth,\n crypto_onetimeauth_verify: crypto_onetimeauth_verify,\n crypto_verify_16: crypto_verify_16,\n crypto_verify_32: crypto_verify_32,\n crypto_secretbox: crypto_secretbox,\n crypto_secretbox_open: crypto_secretbox_open,\n crypto_scalarmult: crypto_scalarmult,\n crypto_scalarmult_base: crypto_scalarmult_base,\n crypto_box_beforenm: crypto_box_beforenm,\n crypto_box_afternm: crypto_box_afternm,\n crypto_box: crypto_box,\n crypto_box_open: crypto_box_open,\n crypto_box_keypair: crypto_box_keypair,\n crypto_hash: crypto_hash,\n crypto_sign: crypto_sign,\n crypto_sign_keypair: crypto_sign_keypair,\n crypto_sign_open: crypto_sign_open,\n\n crypto_secretbox_KEYBYTES: crypto_secretbox_KEYBYTES,\n crypto_secretbox_NONCEBYTES: crypto_secretbox_NONCEBYTES,\n crypto_secretbox_ZEROBYTES: crypto_secretbox_ZEROBYTES,\n crypto_secretbox_BOXZEROBYTES: crypto_secretbox_BOXZEROBYTES,\n crypto_scalarmult_BYTES: crypto_scalarmult_BYTES,\n crypto_scalarmult_SCALARBYTES: crypto_scalarmult_SCALARBYTES,\n crypto_box_PUBLICKEYBYTES: crypto_box_PUBLICKEYBYTES,\n crypto_box_SECRETKEYBYTES: crypto_box_SECRETKEYBYTES,\n crypto_box_BEFORENMBYTES: crypto_box_BEFORENMBYTES,\n crypto_box_NONCEBYTES: crypto_box_NONCEBYTES,\n crypto_box_ZEROBYTES: crypto_box_ZEROBYTES,\n crypto_box_BOXZEROBYTES: crypto_box_BOXZEROBYTES,\n crypto_sign_BYTES: crypto_sign_BYTES,\n crypto_sign_PUBLICKEYBYTES: crypto_sign_PUBLICKEYBYTES,\n crypto_sign_SECRETKEYBYTES: crypto_sign_SECRETKEYBYTES,\n crypto_sign_SEEDBYTES: crypto_sign_SEEDBYTES,\n crypto_hash_BYTES: crypto_hash_BYTES,\n\n gf: gf,\n D: D,\n L: L,\n pack25519: pack25519,\n unpack25519: unpack25519,\n M: M,\n A: A,\n S: S,\n Z: Z,\n pow2523: pow2523,\n add: add,\n set25519: set25519,\n modL: modL,\n scalarmult: scalarmult,\n scalarbase: scalarbase,\n};\n\n/* High-level API */\n\nfunction checkLengths(k, n) {\n if (k.length !== crypto_secretbox_KEYBYTES) throw new Error('bad key size');\n if (n.length !== crypto_secretbox_NONCEBYTES) throw new Error('bad nonce size');\n}\n\nfunction checkBoxLengths(pk, sk) {\n if (pk.length !== crypto_box_PUBLICKEYBYTES) throw new Error('bad public key size');\n if (sk.length !== crypto_box_SECRETKEYBYTES) throw new Error('bad secret key size');\n}\n\nfunction checkArrayTypes() {\n for (var i = 0; i < arguments.length; i++) {\n if (!(arguments[i] instanceof Uint8Array))\n throw new TypeError('unexpected type, use Uint8Array');\n }\n}\n\nfunction cleanup(arr) {\n for (var i = 0; i < arr.length; i++) arr[i] = 0;\n}\n\nnacl.randomBytes = function(n) {\n var b = new Uint8Array(n);\n randombytes(b, n);\n return b;\n};\n\nnacl.secretbox = function(msg, nonce, key) {\n checkArrayTypes(msg, nonce, key);\n checkLengths(key, nonce);\n var m = new Uint8Array(crypto_secretbox_ZEROBYTES + msg.length);\n var c = new Uint8Array(m.length);\n for (var i = 0; i < msg.length; i++) m[i+crypto_secretbox_ZEROBYTES] = msg[i];\n crypto_secretbox(c, m, m.length, nonce, key);\n return c.subarray(crypto_secretbox_BOXZEROBYTES);\n};\n\nnacl.secretbox.open = function(box, nonce, key) {\n checkArrayTypes(box, nonce, key);\n checkLengths(key, nonce);\n var c = new Uint8Array(crypto_secretbox_BOXZEROBYTES + box.length);\n var m = new Uint8Array(c.length);\n for (var i = 0; i < box.length; i++) c[i+crypto_secretbox_BOXZEROBYTES] = box[i];\n if (c.length < 32) return null;\n if (crypto_secretbox_open(m, c, c.length, nonce, key) !== 0) return null;\n return m.subarray(crypto_secretbox_ZEROBYTES);\n};\n\nnacl.secretbox.keyLength = crypto_secretbox_KEYBYTES;\nnacl.secretbox.nonceLength = crypto_secretbox_NONCEBYTES;\nnacl.secretbox.overheadLength = crypto_secretbox_BOXZEROBYTES;\n\nnacl.scalarMult = function(n, p) {\n checkArrayTypes(n, p);\n if (n.length !== crypto_scalarmult_SCALARBYTES) throw new Error('bad n size');\n if (p.length !== crypto_scalarmult_BYTES) throw new Error('bad p size');\n var q = new Uint8Array(crypto_scalarmult_BYTES);\n crypto_scalarmult(q, n, p);\n return q;\n};\n\nnacl.scalarMult.base = function(n) {\n checkArrayTypes(n);\n if (n.length !== crypto_scalarmult_SCALARBYTES) throw new Error('bad n size');\n var q = new Uint8Array(crypto_scalarmult_BYTES);\n crypto_scalarmult_base(q, n);\n return q;\n};\n\nnacl.scalarMult.scalarLength = crypto_scalarmult_SCALARBYTES;\nnacl.scalarMult.groupElementLength = crypto_scalarmult_BYTES;\n\nnacl.box = function(msg, nonce, publicKey, secretKey) {\n var k = nacl.box.before(publicKey, secretKey);\n return nacl.secretbox(msg, nonce, k);\n};\n\nnacl.box.before = function(publicKey, secretKey) {\n checkArrayTypes(publicKey, secretKey);\n checkBoxLengths(publicKey, secretKey);\n var k = new Uint8Array(crypto_box_BEFORENMBYTES);\n crypto_box_beforenm(k, publicKey, secretKey);\n return k;\n};\n\nnacl.box.after = nacl.secretbox;\n\nnacl.box.open = function(msg, nonce, publicKey, secretKey) {\n var k = nacl.box.before(publicKey, secretKey);\n return nacl.secretbox.open(msg, nonce, k);\n};\n\nnacl.box.open.after = nacl.secretbox.open;\n\nnacl.box.keyPair = function() {\n var pk = new Uint8Array(crypto_box_PUBLICKEYBYTES);\n var sk = new Uint8Array(crypto_box_SECRETKEYBYTES);\n crypto_box_keypair(pk, sk);\n return {publicKey: pk, secretKey: sk};\n};\n\nnacl.box.keyPair.fromSecretKey = function(secretKey) {\n checkArrayTypes(secretKey);\n if (secretKey.length !== crypto_box_SECRETKEYBYTES)\n throw new Error('bad secret key size');\n var pk = new Uint8Array(crypto_box_PUBLICKEYBYTES);\n crypto_scalarmult_base(pk, secretKey);\n return {publicKey: pk, secretKey: new Uint8Array(secretKey)};\n};\n\nnacl.box.publicKeyLength = crypto_box_PUBLICKEYBYTES;\nnacl.box.secretKeyLength = crypto_box_SECRETKEYBYTES;\nnacl.box.sharedKeyLength = crypto_box_BEFORENMBYTES;\nnacl.box.nonceLength = crypto_box_NONCEBYTES;\nnacl.box.overheadLength = nacl.secretbox.overheadLength;\n\nnacl.sign = function(msg, secretKey) {\n checkArrayTypes(msg, secretKey);\n if (secretKey.length !== crypto_sign_SECRETKEYBYTES)\n throw new Error('bad secret key size');\n var signedMsg = new Uint8Array(crypto_sign_BYTES+msg.length);\n crypto_sign(signedMsg, msg, msg.length, secretKey);\n return signedMsg;\n};\n\nnacl.sign.open = function(signedMsg, publicKey) {\n checkArrayTypes(signedMsg, publicKey);\n if (publicKey.length !== crypto_sign_PUBLICKEYBYTES)\n throw new Error('bad public key size');\n var tmp = new Uint8Array(signedMsg.length);\n var mlen = crypto_sign_open(tmp, signedMsg, signedMsg.length, publicKey);\n if (mlen < 0) return null;\n var m = new Uint8Array(mlen);\n for (var i = 0; i < m.length; i++) m[i] = tmp[i];\n return m;\n};\n\nnacl.sign.detached = function(msg, secretKey) {\n var signedMsg = nacl.sign(msg, secretKey);\n var sig = new Uint8Array(crypto_sign_BYTES);\n for (var i = 0; i < sig.length; i++) sig[i] = signedMsg[i];\n return sig;\n};\n\nnacl.sign.detached.verify = function(msg, sig, publicKey) {\n checkArrayTypes(msg, sig, publicKey);\n if (sig.length !== crypto_sign_BYTES)\n throw new Error('bad signature size');\n if (publicKey.length !== crypto_sign_PUBLICKEYBYTES)\n throw new Error('bad public key size');\n var sm = new Uint8Array(crypto_sign_BYTES + msg.length);\n var m = new Uint8Array(crypto_sign_BYTES + msg.length);\n var i;\n for (i = 0; i < crypto_sign_BYTES; i++) sm[i] = sig[i];\n for (i = 0; i < msg.length; i++) sm[i+crypto_sign_BYTES] = msg[i];\n return (crypto_sign_open(m, sm, sm.length, publicKey) >= 0);\n};\n\nnacl.sign.keyPair = function() {\n var pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);\n var sk = new Uint8Array(crypto_sign_SECRETKEYBYTES);\n crypto_sign_keypair(pk, sk);\n return {publicKey: pk, secretKey: sk};\n};\n\nnacl.sign.keyPair.fromSecretKey = function(secretKey) {\n checkArrayTypes(secretKey);\n if (secretKey.length !== crypto_sign_SECRETKEYBYTES)\n throw new Error('bad secret key size');\n var pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);\n for (var i = 0; i < pk.length; i++) pk[i] = secretKey[32+i];\n return {publicKey: pk, secretKey: new Uint8Array(secretKey)};\n};\n\nnacl.sign.keyPair.fromSeed = function(seed) {\n checkArrayTypes(seed);\n if (seed.length !== crypto_sign_SEEDBYTES)\n throw new Error('bad seed size');\n var pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);\n var sk = new Uint8Array(crypto_sign_SECRETKEYBYTES);\n for (var i = 0; i < 32; i++) sk[i] = seed[i];\n crypto_sign_keypair(pk, sk, true);\n return {publicKey: pk, secretKey: sk};\n};\n\nnacl.sign.publicKeyLength = crypto_sign_PUBLICKEYBYTES;\nnacl.sign.secretKeyLength = crypto_sign_SECRETKEYBYTES;\nnacl.sign.seedLength = crypto_sign_SEEDBYTES;\nnacl.sign.signatureLength = crypto_sign_BYTES;\n\nnacl.hash = function(msg) {\n checkArrayTypes(msg);\n var h = new Uint8Array(crypto_hash_BYTES);\n crypto_hash(h, msg, msg.length);\n return h;\n};\n\nnacl.hash.hashLength = crypto_hash_BYTES;\n\nnacl.verify = function(x, y) {\n checkArrayTypes(x, y);\n // Zero length arguments are considered not equal.\n if (x.length === 0 || y.length === 0) return false;\n if (x.length !== y.length) return false;\n return (vn(x, 0, y, 0, x.length) === 0) ? true : false;\n};\n\nnacl.setPRNG = function(fn) {\n randombytes = fn;\n};\n\n(function() {\n // Initialize PRNG if environment provides CSPRNG.\n // If not, methods calling randombytes will throw.\n var crypto = typeof self !== 'undefined' ? (self.crypto || self.msCrypto) : null;\n if (crypto && crypto.getRandomValues) {\n // Browsers.\n var QUOTA = 65536;\n nacl.setPRNG(function(x, n) {\n var i, v = new Uint8Array(n);\n for (i = 0; i < n; i += QUOTA) {\n crypto.getRandomValues(v.subarray(i, i + Math.min(n - i, QUOTA)));\n }\n for (i = 0; i < n; i++) x[i] = v[i];\n cleanup(v);\n });\n } else if (typeof require !== 'undefined') {\n // Node.js.\n crypto = require('crypto');\n if (crypto && crypto.randomBytes) {\n nacl.setPRNG(function(x, n) {\n var i, v = crypto.randomBytes(n);\n for (i = 0; i < n; i++) x[i] = v[i];\n cleanup(v);\n });\n }\n }\n})();\n\n})(typeof module !== 'undefined' && module.exports ? module.exports : (self.nacl = self.nacl || {}));\n","module.exports = require('./pusher-with-encryption').default;\n","module.exports = require(\"buffer\");","module.exports = require(\"events\");","'use strict';\n\n/**\n\nStreams in a WebSocket connection\n---------------------------------\n\nWe model a WebSocket as two duplex streams: one stream is for the wire protocol\nover an I/O socket, and the other is for incoming/outgoing messages.\n\n\n +----------+ +---------+ +----------+\n [1] write(chunk) -->| ~~~~~~~~ +----->| parse() +----->| ~~~~~~~~ +--> emit('data') [2]\n | | +----+----+ | |\n | | | | |\n | IO | | [5] | Messages |\n | | V | |\n | | +---------+ | |\n [4] emit('data') <--+ ~~~~~~~~ |<-----+ frame() |<-----+ ~~~~~~~~ |<-- write(chunk) [3]\n +----------+ +---------+ +----------+\n\n\nMessage transfer in each direction is simple: IO receives a byte stream [1] and\nsends this stream for parsing. The parser will periodically emit a complete\nmessage text on the Messages stream [2]. Similarly, when messages are written\nto the Messages stream [3], they are framed using the WebSocket wire format and\nemitted via IO [4].\n\nThere is a feedback loop via [5] since some input from [1] will be things like\nping, pong and close frames. In these cases the protocol responds by emitting\nresponses directly back to [4] rather than emitting messages via [2].\n\nFor the purposes of flow control, we consider the sources of each Readable\nstream to be as follows:\n\n* [2] receives input from [1]\n* [4] receives input from [1] and [3]\n\nThe classes below express the relationships described above without prescribing\nanything about how parse() and frame() work, other than assuming they emit\n'data' events to the IO and Messages streams. They will work with any protocol\ndriver having these two methods.\n**/\n\n\nvar Stream = require('stream').Stream,\n util = require('util');\n\n\nvar IO = function(driver) {\n this.readable = this.writable = true;\n this._paused = false;\n this._driver = driver;\n};\nutil.inherits(IO, Stream);\n\n// The IO pause() and resume() methods will be called when the socket we are\n// piping to gets backed up and drains. Since IO output [4] comes from IO input\n// [1] and Messages input [3], we need to tell both of those to return false\n// from write() when this stream is paused.\n\nIO.prototype.pause = function() {\n this._paused = true;\n this._driver.messages._paused = true;\n};\n\nIO.prototype.resume = function() {\n this._paused = false;\n this.emit('drain');\n\n var messages = this._driver.messages;\n messages._paused = false;\n messages.emit('drain');\n};\n\n// When we receive input from a socket, send it to the parser and tell the\n// source whether to back off.\nIO.prototype.write = function(chunk) {\n if (!this.writable) return false;\n this._driver.parse(chunk);\n return !this._paused;\n};\n\n// The IO end() method will be called when the socket piping into it emits\n// 'close' or 'end', i.e. the socket is closed. In this situation the Messages\n// stream will not emit any more data so we emit 'end'.\nIO.prototype.end = function(chunk) {\n if (!this.writable) return;\n if (chunk !== undefined) this.write(chunk);\n this.writable = false;\n\n var messages = this._driver.messages;\n if (messages.readable) {\n messages.readable = messages.writable = false;\n messages.emit('end');\n }\n};\n\nIO.prototype.destroy = function() {\n this.end();\n};\n\n\nvar Messages = function(driver) {\n this.readable = this.writable = true;\n this._paused = false;\n this._driver = driver;\n};\nutil.inherits(Messages, Stream);\n\n// The Messages pause() and resume() methods will be called when the app that's\n// processing the messages gets backed up and drains. If we're emitting\n// messages too fast we should tell the source to slow down. Message output [2]\n// comes from IO input [1].\n\nMessages.prototype.pause = function() {\n this._driver.io._paused = true;\n};\n\nMessages.prototype.resume = function() {\n this._driver.io._paused = false;\n this._driver.io.emit('drain');\n};\n\n// When we receive messages from the user, send them to the formatter and tell\n// the source whether to back off.\nMessages.prototype.write = function(message) {\n if (!this.writable) return false;\n if (typeof message === 'string') this._driver.text(message);\n else this._driver.binary(message);\n return !this._paused;\n};\n\n// The Messages end() method will be called when a stream piping into it emits\n// 'end'. Many streams may be piped into the WebSocket and one of them ending\n// does not mean the whole socket is done, so just process the input and move\n// on leaving the socket open.\nMessages.prototype.end = function(message) {\n if (message !== undefined) this.write(message);\n};\n\nMessages.prototype.destroy = function() {};\n\n\nexports.IO = IO;\nexports.Messages = Messages;\n","'use strict';\n\nvar Buffer = require('safe-buffer').Buffer;\n\nvar StreamReader = function() {\n this._queue = [];\n this._queueSize = 0;\n this._offset = 0;\n};\n\nStreamReader.prototype.put = function(buffer) {\n if (!buffer || buffer.length === 0) return;\n if (!Buffer.isBuffer(buffer)) buffer = Buffer.from(buffer);\n this._queue.push(buffer);\n this._queueSize += buffer.length;\n};\n\nStreamReader.prototype.read = function(length) {\n if (length > this._queueSize) return null;\n if (length === 0) return Buffer.alloc(0);\n\n this._queueSize -= length;\n\n var queue = this._queue,\n remain = length,\n first = queue[0],\n buffers, buffer;\n\n if (first.length >= length) {\n if (first.length === length) {\n return queue.shift();\n } else {\n buffer = first.slice(0, length);\n queue[0] = first.slice(length);\n return buffer;\n }\n }\n\n for (var i = 0, n = queue.length; i < n; i++) {\n if (remain < queue[i].length) break;\n remain -= queue[i].length;\n }\n buffers = queue.splice(0, i);\n\n if (remain > 0 && queue.length > 0) {\n buffers.push(queue[0].slice(0, remain));\n queue[0] = queue[0].slice(remain);\n }\n return Buffer.concat(buffers, length);\n};\n\nStreamReader.prototype.eachByte = function(callback, context) {\n var buffer, n, index;\n\n while (this._queue.length > 0) {\n buffer = this._queue[0];\n n = buffer.length;\n\n while (this._offset < n) {\n index = this._offset;\n this._offset += 1;\n callback.call(context, buffer[index]);\n }\n this._offset = 0;\n this._queue.shift();\n }\n};\n\nmodule.exports = StreamReader;\n","'use strict';\n\nvar Buffer = require('safe-buffer').Buffer,\n crypto = require('crypto'),\n url = require('url'),\n util = require('util'),\n HttpParser = require('../http_parser'),\n Base = require('./base'),\n Hybi = require('./hybi'),\n Proxy = require('./proxy');\n\nvar Client = function(_url, options) {\n this.version = 'hybi-' + Hybi.VERSION;\n Hybi.call(this, null, _url, options);\n\n this.readyState = -1;\n this._key = Client.generateKey();\n this._accept = Hybi.generateAccept(this._key);\n this._http = new HttpParser('response');\n\n var uri = url.parse(this.url),\n auth = uri.auth && Buffer.from(uri.auth, 'utf8').toString('base64');\n\n if (this.VALID_PROTOCOLS.indexOf(uri.protocol) < 0)\n throw new Error(this.url + ' is not a valid WebSocket URL');\n\n this._pathname = (uri.pathname || '/') + (uri.search || '');\n\n this._headers.set('Host', uri.host);\n this._headers.set('Upgrade', 'websocket');\n this._headers.set('Connection', 'Upgrade');\n this._headers.set('Sec-WebSocket-Key', this._key);\n this._headers.set('Sec-WebSocket-Version', Hybi.VERSION);\n\n if (this._protocols.length > 0)\n this._headers.set('Sec-WebSocket-Protocol', this._protocols.join(', '));\n\n if (auth)\n this._headers.set('Authorization', 'Basic ' + auth);\n};\nutil.inherits(Client, Hybi);\n\nClient.generateKey = function() {\n return crypto.randomBytes(16).toString('base64');\n};\n\nvar instance = {\n VALID_PROTOCOLS: ['ws:', 'wss:'],\n\n proxy: function(origin, options) {\n return new Proxy(this, origin, options);\n },\n\n start: function() {\n if (this.readyState !== -1) return false;\n this._write(this._handshakeRequest());\n this.readyState = 0;\n return true;\n },\n\n parse: function(chunk) {\n if (this.readyState === 3) return;\n if (this.readyState > 0) return Hybi.prototype.parse.call(this, chunk);\n\n this._http.parse(chunk);\n if (!this._http.isComplete()) return;\n\n this._validateHandshake();\n if (this.readyState === 3) return;\n\n this._open();\n this.parse(this._http.body);\n },\n\n _handshakeRequest: function() {\n var extensions = this._extensions.generateOffer();\n if (extensions)\n this._headers.set('Sec-WebSocket-Extensions', extensions);\n\n var start = 'GET ' + this._pathname + ' HTTP/1.1',\n headers = [start, this._headers.toString(), ''];\n\n return Buffer.from(headers.join('\\r\\n'), 'utf8');\n },\n\n _failHandshake: function(message) {\n message = 'Error during WebSocket handshake: ' + message;\n this.readyState = 3;\n this.emit('error', new Error(message));\n this.emit('close', new Base.CloseEvent(this.ERRORS.protocol_error, message));\n },\n\n _validateHandshake: function() {\n this.statusCode = this._http.statusCode;\n this.headers = this._http.headers;\n\n if (this._http.error)\n return this._failHandshake(this._http.error.message);\n\n if (this._http.statusCode !== 101)\n return this._failHandshake('Unexpected response code: ' + this._http.statusCode);\n\n var headers = this._http.headers,\n upgrade = headers['upgrade'] || '',\n connection = headers['connection'] || '',\n accept = headers['sec-websocket-accept'] || '',\n protocol = headers['sec-websocket-protocol'] || '';\n\n if (upgrade === '')\n return this._failHandshake(\"'Upgrade' header is missing\");\n if (upgrade.toLowerCase() !== 'websocket')\n return this._failHandshake(\"'Upgrade' header value is not 'WebSocket'\");\n\n if (connection === '')\n return this._failHandshake(\"'Connection' header is missing\");\n if (connection.toLowerCase() !== 'upgrade')\n return this._failHandshake(\"'Connection' header value is not 'Upgrade'\");\n\n if (accept !== this._accept)\n return this._failHandshake('Sec-WebSocket-Accept mismatch');\n\n this.protocol = null;\n\n if (protocol !== '') {\n if (this._protocols.indexOf(protocol) < 0)\n return this._failHandshake('Sec-WebSocket-Protocol mismatch');\n else\n this.protocol = protocol;\n }\n\n try {\n this._extensions.activate(this.headers['sec-websocket-extensions']);\n } catch (e) {\n return this._failHandshake(e.message);\n }\n }\n};\n\nfor (var key in instance)\n Client.prototype[key] = instance[key];\n\nmodule.exports = Client;\n","/*jshint node:true */\n\nvar assert = require('assert');\n\nexports.HTTPParser = HTTPParser;\nfunction HTTPParser(type) {\n assert.ok(type === HTTPParser.REQUEST || type === HTTPParser.RESPONSE || type === undefined);\n if (type === undefined) {\n // Node v12+\n } else {\n this.initialize(type);\n }\n this.maxHeaderSize=HTTPParser.maxHeaderSize\n}\nHTTPParser.prototype.initialize = function (type, async_resource) {\n assert.ok(type === HTTPParser.REQUEST || type === HTTPParser.RESPONSE);\n this.type = type;\n this.state = type + '_LINE';\n this.info = {\n headers: [],\n upgrade: false\n };\n this.trailers = [];\n this.line = '';\n this.isChunked = false;\n this.connection = '';\n this.headerSize = 0; // for preventing too big headers\n this.body_bytes = null;\n this.isUserCall = false;\n this.hadError = false;\n};\n\nHTTPParser.encoding = 'ascii';\nHTTPParser.maxHeaderSize = 80 * 1024; // maxHeaderSize (in bytes) is configurable, but 80kb by default;\nHTTPParser.REQUEST = 'REQUEST';\nHTTPParser.RESPONSE = 'RESPONSE';\n\n// Note: *not* starting with kOnHeaders=0 line the Node parser, because any\n// newly added constants (kOnTimeout in Node v12.19.0) will overwrite 0!\nvar kOnHeaders = HTTPParser.kOnHeaders = 1;\nvar kOnHeadersComplete = HTTPParser.kOnHeadersComplete = 2;\nvar kOnBody = HTTPParser.kOnBody = 3;\nvar kOnMessageComplete = HTTPParser.kOnMessageComplete = 4;\n\n// Some handler stubs, needed for compatibility\nHTTPParser.prototype[kOnHeaders] =\nHTTPParser.prototype[kOnHeadersComplete] =\nHTTPParser.prototype[kOnBody] =\nHTTPParser.prototype[kOnMessageComplete] = function () {};\n\nvar compatMode0_12 = true;\nObject.defineProperty(HTTPParser, 'kOnExecute', {\n get: function () {\n // hack for backward compatibility\n compatMode0_12 = false;\n return 99;\n }\n });\n\nvar methods = exports.methods = HTTPParser.methods = [\n 'DELETE',\n 'GET',\n 'HEAD',\n 'POST',\n 'PUT',\n 'CONNECT',\n 'OPTIONS',\n 'TRACE',\n 'COPY',\n 'LOCK',\n 'MKCOL',\n 'MOVE',\n 'PROPFIND',\n 'PROPPATCH',\n 'SEARCH',\n 'UNLOCK',\n 'BIND',\n 'REBIND',\n 'UNBIND',\n 'ACL',\n 'REPORT',\n 'MKACTIVITY',\n 'CHECKOUT',\n 'MERGE',\n 'M-SEARCH',\n 'NOTIFY',\n 'SUBSCRIBE',\n 'UNSUBSCRIBE',\n 'PATCH',\n 'PURGE',\n 'MKCALENDAR',\n 'LINK',\n 'UNLINK',\n 'SOURCE',\n];\nvar method_connect = methods.indexOf('CONNECT');\nHTTPParser.prototype.reinitialize = HTTPParser;\nHTTPParser.prototype.close =\nHTTPParser.prototype.pause =\nHTTPParser.prototype.resume =\nHTTPParser.prototype.free = function () {};\nHTTPParser.prototype._compatMode0_11 = false;\nHTTPParser.prototype.getAsyncId = function() { return 0; };\n\nvar headerState = {\n REQUEST_LINE: true,\n RESPONSE_LINE: true,\n HEADER: true\n};\nHTTPParser.prototype.execute = function (chunk, start, length) {\n if (!(this instanceof HTTPParser)) {\n throw new TypeError('not a HTTPParser');\n }\n\n // backward compat to node < 0.11.4\n // Note: the start and length params were removed in newer version\n start = start || 0;\n length = typeof length === 'number' ? length : chunk.length;\n\n this.chunk = chunk;\n this.offset = start;\n var end = this.end = start + length;\n try {\n while (this.offset < end) {\n if (this[this.state]()) {\n break;\n }\n }\n } catch (err) {\n if (this.isUserCall) {\n throw err;\n }\n this.hadError = true;\n return err;\n }\n this.chunk = null;\n length = this.offset - start;\n if (headerState[this.state]) {\n this.headerSize += length;\n if (this.headerSize > (this.maxHeaderSize||HTTPParser.maxHeaderSize)) {\n return new Error('max header size exceeded');\n }\n }\n return length;\n};\n\nvar stateFinishAllowed = {\n REQUEST_LINE: true,\n RESPONSE_LINE: true,\n BODY_RAW: true\n};\nHTTPParser.prototype.finish = function () {\n if (this.hadError) {\n return;\n }\n if (!stateFinishAllowed[this.state]) {\n return new Error('invalid state for EOF');\n }\n if (this.state === 'BODY_RAW') {\n this.userCall()(this[kOnMessageComplete]());\n }\n};\n\n// These three methods are used for an internal speed optimization, and it also\n// works if theses are noops. Basically consume() asks us to read the bytes\n// ourselves, but if we don't do it we get them through execute().\nHTTPParser.prototype.consume =\nHTTPParser.prototype.unconsume =\nHTTPParser.prototype.getCurrentBuffer = function () {};\n\n//For correct error handling - see HTTPParser#execute\n//Usage: this.userCall()(userFunction('arg'));\nHTTPParser.prototype.userCall = function () {\n this.isUserCall = true;\n var self = this;\n return function (ret) {\n self.isUserCall = false;\n return ret;\n };\n};\n\nHTTPParser.prototype.nextRequest = function () {\n this.userCall()(this[kOnMessageComplete]());\n this.reinitialize(this.type);\n};\n\nHTTPParser.prototype.consumeLine = function () {\n var end = this.end,\n chunk = this.chunk;\n for (var i = this.offset; i < end; i++) {\n if (chunk[i] === 0x0a) { // \\n\n var line = this.line + chunk.toString(HTTPParser.encoding, this.offset, i);\n if (line.charAt(line.length - 1) === '\\r') {\n line = line.substr(0, line.length - 1);\n }\n this.line = '';\n this.offset = i + 1;\n return line;\n }\n }\n //line split over multiple chunks\n this.line += chunk.toString(HTTPParser.encoding, this.offset, this.end);\n this.offset = this.end;\n};\n\nvar headerExp = /^([^: \\t]+):[ \\t]*((?:.*[^ \\t])|)/;\nvar headerContinueExp = /^[ \\t]+(.*[^ \\t])/;\nHTTPParser.prototype.parseHeader = function (line, headers) {\n if (line.indexOf('\\r') !== -1) {\n throw parseErrorCode('HPE_LF_EXPECTED');\n }\n\n var match = headerExp.exec(line);\n var k = match && match[1];\n if (k) { // skip empty string (malformed header)\n headers.push(k);\n headers.push(match[2]);\n } else {\n var matchContinue = headerContinueExp.exec(line);\n if (matchContinue && headers.length) {\n if (headers[headers.length - 1]) {\n headers[headers.length - 1] += ' ';\n }\n headers[headers.length - 1] += matchContinue[1];\n }\n }\n};\n\nvar requestExp = /^([A-Z-]+) ([^ ]+) HTTP\\/(\\d)\\.(\\d)$/;\nHTTPParser.prototype.REQUEST_LINE = function () {\n var line = this.consumeLine();\n if (!line) {\n return;\n }\n var match = requestExp.exec(line);\n if (match === null) {\n throw parseErrorCode('HPE_INVALID_CONSTANT');\n }\n this.info.method = this._compatMode0_11 ? match[1] : methods.indexOf(match[1]);\n if (this.info.method === -1) {\n throw new Error('invalid request method');\n }\n this.info.url = match[2];\n this.info.versionMajor = +match[3];\n this.info.versionMinor = +match[4];\n this.body_bytes = 0;\n this.state = 'HEADER';\n};\n\nvar responseExp = /^HTTP\\/(\\d)\\.(\\d) (\\d{3}) ?(.*)$/;\nHTTPParser.prototype.RESPONSE_LINE = function () {\n var line = this.consumeLine();\n if (!line) {\n return;\n }\n var match = responseExp.exec(line);\n if (match === null) {\n throw parseErrorCode('HPE_INVALID_CONSTANT');\n }\n this.info.versionMajor = +match[1];\n this.info.versionMinor = +match[2];\n var statusCode = this.info.statusCode = +match[3];\n this.info.statusMessage = match[4];\n // Implied zero length.\n if ((statusCode / 100 | 0) === 1 || statusCode === 204 || statusCode === 304) {\n this.body_bytes = 0;\n }\n this.state = 'HEADER';\n};\n\nHTTPParser.prototype.shouldKeepAlive = function () {\n if (this.info.versionMajor > 0 && this.info.versionMinor > 0) {\n if (this.connection.indexOf('close') !== -1) {\n return false;\n }\n } else if (this.connection.indexOf('keep-alive') === -1) {\n return false;\n }\n if (this.body_bytes !== null || this.isChunked) { // || skipBody\n return true;\n }\n return false;\n};\n\nHTTPParser.prototype.HEADER = function () {\n var line = this.consumeLine();\n if (line === undefined) {\n return;\n }\n var info = this.info;\n if (line) {\n this.parseHeader(line, info.headers);\n } else {\n var headers = info.headers;\n var hasContentLength = false;\n var currentContentLengthValue;\n var hasUpgradeHeader = false;\n for (var i = 0; i < headers.length; i += 2) {\n switch (headers[i].toLowerCase()) {\n case 'transfer-encoding':\n this.isChunked = headers[i + 1].toLowerCase() === 'chunked';\n break;\n case 'content-length':\n currentContentLengthValue = +headers[i + 1];\n if (hasContentLength) {\n // Fix duplicate Content-Length header with same values.\n // Throw error only if values are different.\n // Known issues:\n // https://github.com/request/request/issues/2091#issuecomment-328715113\n // https://github.com/nodejs/node/issues/6517#issuecomment-216263771\n if (currentContentLengthValue !== this.body_bytes) {\n throw parseErrorCode('HPE_UNEXPECTED_CONTENT_LENGTH');\n }\n } else {\n hasContentLength = true;\n this.body_bytes = currentContentLengthValue;\n }\n break;\n case 'connection':\n this.connection += headers[i + 1].toLowerCase();\n break;\n case 'upgrade':\n hasUpgradeHeader = true;\n break;\n }\n }\n\n // if both isChunked and hasContentLength, isChunked wins\n // This is required so the body is parsed using the chunked method, and matches\n // Chrome's behavior. We could, maybe, ignore them both (would get chunked\n // encoding into the body), and/or disable shouldKeepAlive to be more\n // resilient.\n if (this.isChunked && hasContentLength) {\n hasContentLength = false;\n this.body_bytes = null;\n }\n\n // Logic from https://github.com/nodejs/http-parser/blob/921d5585515a153fa00e411cf144280c59b41f90/http_parser.c#L1727-L1737\n // \"For responses, \"Upgrade: foo\" and \"Connection: upgrade\" are\n // mandatory only when it is a 101 Switching Protocols response,\n // otherwise it is purely informational, to announce support.\n if (hasUpgradeHeader && this.connection.indexOf('upgrade') != -1) {\n info.upgrade = this.type === HTTPParser.REQUEST || info.statusCode === 101;\n } else {\n info.upgrade = info.method === method_connect;\n }\n\n if (this.isChunked && info.upgrade) {\n this.isChunked = false;\n }\n\n info.shouldKeepAlive = this.shouldKeepAlive();\n //problem which also exists in original node: we should know skipBody before calling onHeadersComplete\n var skipBody;\n if (compatMode0_12) {\n skipBody = this.userCall()(this[kOnHeadersComplete](info));\n } else {\n skipBody = this.userCall()(this[kOnHeadersComplete](info.versionMajor,\n info.versionMinor, info.headers, info.method, info.url, info.statusCode,\n info.statusMessage, info.upgrade, info.shouldKeepAlive));\n }\n if (skipBody === 2) {\n this.nextRequest();\n return true;\n } else if (this.isChunked && !skipBody) {\n this.state = 'BODY_CHUNKHEAD';\n } else if (skipBody || this.body_bytes === 0) {\n this.nextRequest();\n // For older versions of node (v6.x and older?), that return skipBody=1 or skipBody=true,\n // need this \"return true;\" if it's an upgrade request.\n return info.upgrade;\n } else if (this.body_bytes === null) {\n this.state = 'BODY_RAW';\n } else {\n this.state = 'BODY_SIZED';\n }\n }\n};\n\nHTTPParser.prototype.BODY_CHUNKHEAD = function () {\n var line = this.consumeLine();\n if (line === undefined) {\n return;\n }\n this.body_bytes = parseInt(line, 16);\n if (!this.body_bytes) {\n this.state = 'BODY_CHUNKTRAILERS';\n } else {\n this.state = 'BODY_CHUNK';\n }\n};\n\nHTTPParser.prototype.BODY_CHUNK = function () {\n var length = Math.min(this.end - this.offset, this.body_bytes);\n this.userCall()(this[kOnBody](this.chunk, this.offset, length));\n this.offset += length;\n this.body_bytes -= length;\n if (!this.body_bytes) {\n this.state = 'BODY_CHUNKEMPTYLINE';\n }\n};\n\nHTTPParser.prototype.BODY_CHUNKEMPTYLINE = function () {\n var line = this.consumeLine();\n if (line === undefined) {\n return;\n }\n assert.equal(line, '');\n this.state = 'BODY_CHUNKHEAD';\n};\n\nHTTPParser.prototype.BODY_CHUNKTRAILERS = function () {\n var line = this.consumeLine();\n if (line === undefined) {\n return;\n }\n if (line) {\n this.parseHeader(line, this.trailers);\n } else {\n if (this.trailers.length) {\n this.userCall()(this[kOnHeaders](this.trailers, ''));\n }\n this.nextRequest();\n }\n};\n\nHTTPParser.prototype.BODY_RAW = function () {\n var length = this.end - this.offset;\n this.userCall()(this[kOnBody](this.chunk, this.offset, length));\n this.offset = this.end;\n};\n\nHTTPParser.prototype.BODY_SIZED = function () {\n var length = Math.min(this.end - this.offset, this.body_bytes);\n this.userCall()(this[kOnBody](this.chunk, this.offset, length));\n this.offset += length;\n this.body_bytes -= length;\n if (!this.body_bytes) {\n this.nextRequest();\n }\n};\n\n// backward compat to node < 0.11.6\n['Headers', 'HeadersComplete', 'Body', 'MessageComplete'].forEach(function (name) {\n var k = HTTPParser['kOn' + name];\n Object.defineProperty(HTTPParser.prototype, 'on' + name, {\n get: function () {\n return this[k];\n },\n set: function (to) {\n // hack for backward compatibility\n this._compatMode0_11 = true;\n method_connect = 'CONNECT';\n return (this[k] = to);\n }\n });\n});\n\nfunction parseErrorCode(code) {\n var err = new Error('Parse Error');\n err.code = code;\n return err;\n}\n","module.exports = require(\"assert\");","'use strict';\n\nvar Parser = require('./parser'),\n Pipeline = require('./pipeline');\n\nvar Extensions = function() {\n this._rsv1 = this._rsv2 = this._rsv3 = null;\n\n this._byName = {};\n this._inOrder = [];\n this._sessions = [];\n this._index = {};\n};\n\nExtensions.MESSAGE_OPCODES = [1, 2];\n\nvar instance = {\n add: function(ext) {\n if (typeof ext.name !== 'string') throw new TypeError('extension.name must be a string');\n if (ext.type !== 'permessage') throw new TypeError('extension.type must be \"permessage\"');\n\n if (typeof ext.rsv1 !== 'boolean') throw new TypeError('extension.rsv1 must be true or false');\n if (typeof ext.rsv2 !== 'boolean') throw new TypeError('extension.rsv2 must be true or false');\n if (typeof ext.rsv3 !== 'boolean') throw new TypeError('extension.rsv3 must be true or false');\n\n if (this._byName.hasOwnProperty(ext.name))\n throw new TypeError('An extension with name \"' + ext.name + '\" is already registered');\n\n this._byName[ext.name] = ext;\n this._inOrder.push(ext);\n },\n\n generateOffer: function() {\n var sessions = [],\n offer = [],\n index = {};\n\n this._inOrder.forEach(function(ext) {\n var session = ext.createClientSession();\n if (!session) return;\n\n var record = [ext, session];\n sessions.push(record);\n index[ext.name] = record;\n\n var offers = session.generateOffer();\n offers = offers ? [].concat(offers) : [];\n\n offers.forEach(function(off) {\n offer.push(Parser.serializeParams(ext.name, off));\n }, this);\n }, this);\n\n this._sessions = sessions;\n this._index = index;\n\n return offer.length > 0 ? offer.join(', ') : null;\n },\n\n activate: function(header) {\n var responses = Parser.parseHeader(header),\n sessions = [];\n\n responses.eachOffer(function(name, params) {\n var record = this._index[name];\n\n if (!record)\n throw new Error('Server sent an extension response for unknown extension \"' + name + '\"');\n\n var ext = record[0],\n session = record[1],\n reserved = this._reserved(ext);\n\n if (reserved)\n throw new Error('Server sent two extension responses that use the RSV' +\n reserved[0] + ' bit: \"' +\n reserved[1] + '\" and \"' + ext.name + '\"');\n\n if (session.activate(params) !== true)\n throw new Error('Server sent unacceptable extension parameters: ' +\n Parser.serializeParams(name, params));\n\n this._reserve(ext);\n sessions.push(record);\n }, this);\n\n this._sessions = sessions;\n this._pipeline = new Pipeline(sessions);\n },\n\n generateResponse: function(header) {\n var sessions = [],\n response = [],\n offers = Parser.parseHeader(header);\n\n this._inOrder.forEach(function(ext) {\n var offer = offers.byName(ext.name);\n if (offer.length === 0 || this._reserved(ext)) return;\n\n var session = ext.createServerSession(offer);\n if (!session) return;\n\n this._reserve(ext);\n sessions.push([ext, session]);\n response.push(Parser.serializeParams(ext.name, session.generateResponse()));\n }, this);\n\n this._sessions = sessions;\n this._pipeline = new Pipeline(sessions);\n\n return response.length > 0 ? response.join(', ') : null;\n },\n\n validFrameRsv: function(frame) {\n var allowed = { rsv1: false, rsv2: false, rsv3: false },\n ext;\n\n if (Extensions.MESSAGE_OPCODES.indexOf(frame.opcode) >= 0) {\n for (var i = 0, n = this._sessions.length; i < n; i++) {\n ext = this._sessions[i][0];\n allowed.rsv1 = allowed.rsv1 || ext.rsv1;\n allowed.rsv2 = allowed.rsv2 || ext.rsv2;\n allowed.rsv3 = allowed.rsv3 || ext.rsv3;\n }\n }\n\n return (allowed.rsv1 || !frame.rsv1) &&\n (allowed.rsv2 || !frame.rsv2) &&\n (allowed.rsv3 || !frame.rsv3);\n },\n\n processIncomingMessage: function(message, callback, context) {\n this._pipeline.processIncomingMessage(message, callback, context);\n },\n\n processOutgoingMessage: function(message, callback, context) {\n this._pipeline.processOutgoingMessage(message, callback, context);\n },\n\n close: function(callback, context) {\n if (!this._pipeline) return callback.call(context);\n this._pipeline.close(callback, context);\n },\n\n _reserve: function(ext) {\n this._rsv1 = this._rsv1 || (ext.rsv1 && ext.name);\n this._rsv2 = this._rsv2 || (ext.rsv2 && ext.name);\n this._rsv3 = this._rsv3 || (ext.rsv3 && ext.name);\n },\n\n _reserved: function(ext) {\n if (this._rsv1 && ext.rsv1) return [1, this._rsv1];\n if (this._rsv2 && ext.rsv2) return [2, this._rsv2];\n if (this._rsv3 && ext.rsv3) return [3, this._rsv3];\n return false;\n }\n};\n\nfor (var key in instance)\n Extensions.prototype[key] = instance[key];\n\nmodule.exports = Extensions;\n","'use strict';\n\nvar TOKEN = /([!#\\$%&'\\*\\+\\-\\.\\^_`\\|~0-9A-Za-z]+)/,\n NOTOKEN = /([^!#\\$%&'\\*\\+\\-\\.\\^_`\\|~0-9A-Za-z])/g,\n QUOTED = /\"((?:\\\\[\\x00-\\x7f]|[^\\x00-\\x08\\x0a-\\x1f\\x7f\"\\\\])*)\"/,\n PARAM = new RegExp(TOKEN.source + '(?:=(?:' + TOKEN.source + '|' + QUOTED.source + '))?'),\n EXT = new RegExp(TOKEN.source + '(?: *; *' + PARAM.source + ')*', 'g'),\n EXT_LIST = new RegExp('^' + EXT.source + '(?: *, *' + EXT.source + ')*$'),\n NUMBER = /^-?(0|[1-9][0-9]*)(\\.[0-9]+)?$/;\n\nvar hasOwnProperty = Object.prototype.hasOwnProperty;\n\nvar Parser = {\n parseHeader: function(header) {\n var offers = new Offers();\n if (header === '' || header === undefined) return offers;\n\n if (!EXT_LIST.test(header))\n throw new SyntaxError('Invalid Sec-WebSocket-Extensions header: ' + header);\n\n var values = header.match(EXT);\n\n values.forEach(function(value) {\n var params = value.match(new RegExp(PARAM.source, 'g')),\n name = params.shift(),\n offer = {};\n\n params.forEach(function(param) {\n var args = param.match(PARAM), key = args[1], data;\n\n if (args[2] !== undefined) {\n data = args[2];\n } else if (args[3] !== undefined) {\n data = args[3].replace(/\\\\/g, '');\n } else {\n data = true;\n }\n if (NUMBER.test(data)) data = parseFloat(data);\n\n if (hasOwnProperty.call(offer, key)) {\n offer[key] = [].concat(offer[key]);\n offer[key].push(data);\n } else {\n offer[key] = data;\n }\n }, this);\n offers.push(name, offer);\n }, this);\n\n return offers;\n },\n\n serializeParams: function(name, params) {\n var values = [];\n\n var print = function(key, value) {\n if (value instanceof Array) {\n value.forEach(function(v) { print(key, v) });\n } else if (value === true) {\n values.push(key);\n } else if (typeof value === 'number') {\n values.push(key + '=' + value);\n } else if (NOTOKEN.test(value)) {\n values.push(key + '=\"' + value.replace(/\"/g, '\\\\\"') + '\"');\n } else {\n values.push(key + '=' + value);\n }\n };\n\n for (var key in params) print(key, params[key]);\n\n return [name].concat(values).join('; ');\n }\n};\n\nvar Offers = function() {\n this._byName = {};\n this._inOrder = [];\n};\n\nOffers.prototype.push = function(name, params) {\n if (!hasOwnProperty.call(this._byName, name))\n this._byName[name] = [];\n\n this._byName[name].push(params);\n this._inOrder.push({ name: name, params: params });\n};\n\nOffers.prototype.eachOffer = function(callback, context) {\n var list = this._inOrder;\n for (var i = 0, n = list.length; i < n; i++)\n callback.call(context, list[i].name, list[i].params);\n};\n\nOffers.prototype.byName = function(name) {\n return this._byName[name] || [];\n};\n\nOffers.prototype.toArray = function() {\n return this._inOrder.slice();\n};\n\nmodule.exports = Parser;\n","'use strict';\n\nvar Cell = require('./cell'),\n Pledge = require('./pledge');\n\nvar Pipeline = function(sessions) {\n this._cells = sessions.map(function(session) { return new Cell(session) });\n this._stopped = { incoming: false, outgoing: false };\n};\n\nPipeline.prototype.processIncomingMessage = function(message, callback, context) {\n if (this._stopped.incoming) return;\n this._loop('incoming', this._cells.length - 1, -1, -1, message, callback, context);\n};\n\nPipeline.prototype.processOutgoingMessage = function(message, callback, context) {\n if (this._stopped.outgoing) return;\n this._loop('outgoing', 0, this._cells.length, 1, message, callback, context);\n};\n\nPipeline.prototype.close = function(callback, context) {\n this._stopped = { incoming: true, outgoing: true };\n\n var closed = this._cells.map(function(a) { return a.close() });\n if (callback)\n Pledge.all(closed).then(function() { callback.call(context) });\n};\n\nPipeline.prototype._loop = function(direction, start, end, step, message, callback, context) {\n var cells = this._cells,\n n = cells.length,\n self = this;\n\n while (n--) cells[n].pending(direction);\n\n var pipe = function(index, error, msg) {\n if (index === end) return callback.call(context, error, msg);\n\n cells[index][direction](error, msg, function(err, m) {\n if (err) self._stopped[direction] = true;\n pipe(index + step, err, m);\n });\n };\n pipe(start, null, message);\n};\n\nmodule.exports = Pipeline;\n","'use strict';\n\nvar Functor = require('./functor'),\n Pledge = require('./pledge');\n\nvar Cell = function(tuple) {\n this._ext = tuple[0];\n this._session = tuple[1];\n\n this._functors = {\n incoming: new Functor(this._session, 'processIncomingMessage'),\n outgoing: new Functor(this._session, 'processOutgoingMessage')\n };\n};\n\nCell.prototype.pending = function(direction) {\n var functor = this._functors[direction];\n if (!functor._stopped) functor.pending += 1;\n};\n\nCell.prototype.incoming = function(error, message, callback, context) {\n this._exec('incoming', error, message, callback, context);\n};\n\nCell.prototype.outgoing = function(error, message, callback, context) {\n this._exec('outgoing', error, message, callback, context);\n};\n\nCell.prototype.close = function() {\n this._closed = this._closed || new Pledge();\n this._doClose();\n return this._closed;\n};\n\nCell.prototype._exec = function(direction, error, message, callback, context) {\n this._functors[direction].call(error, message, function(err, msg) {\n if (err) err.message = this._ext.name + ': ' + err.message;\n callback.call(context, err, msg);\n this._doClose();\n }, this);\n};\n\nCell.prototype._doClose = function() {\n var fin = this._functors.incoming,\n fout = this._functors.outgoing;\n\n if (!this._closed || fin.pending + fout.pending !== 0) return;\n if (this._session) this._session.close();\n this._session = null;\n this._closed.done();\n};\n\nmodule.exports = Cell;\n","'use strict';\n\nvar RingBuffer = require('./ring_buffer');\n\nvar Functor = function(session, method) {\n this._session = session;\n this._method = method;\n this._queue = new RingBuffer(Functor.QUEUE_SIZE);\n this._stopped = false;\n this.pending = 0;\n};\n\nFunctor.QUEUE_SIZE = 8;\n\nFunctor.prototype.call = function(error, message, callback, context) {\n if (this._stopped) return;\n\n var record = { error: error, message: message, callback: callback, context: context, done: false },\n called = false,\n self = this;\n\n this._queue.push(record);\n\n if (record.error) {\n record.done = true;\n this._stop();\n return this._flushQueue();\n }\n\n var handler = function(err, msg) {\n if (!(called ^ (called = true))) return;\n\n if (err) {\n self._stop();\n record.error = err;\n record.message = null;\n } else {\n record.message = msg;\n }\n\n record.done = true;\n self._flushQueue();\n };\n\n try {\n this._session[this._method](message, handler);\n } catch (err) {\n handler(err);\n }\n};\n\nFunctor.prototype._stop = function() {\n this.pending = this._queue.length;\n this._stopped = true;\n};\n\nFunctor.prototype._flushQueue = function() {\n var queue = this._queue, record;\n\n while (queue.length > 0 && queue.peek().done) {\n record = queue.shift();\n if (record.error) {\n this.pending = 0;\n queue.clear();\n } else {\n this.pending -= 1;\n }\n record.callback.call(record.context, record.error, record.message);\n }\n};\n\nmodule.exports = Functor;\n","'use strict';\n\nvar Frame = function() {};\n\nvar instance = {\n final: false,\n rsv1: false,\n rsv2: false,\n rsv3: false,\n opcode: null,\n masked: false,\n maskingKey: null,\n lengthBytes: 1,\n length: 0,\n payload: null\n};\n\nfor (var key in instance)\n Frame.prototype[key] = instance[key];\n\nmodule.exports = Frame;\n","'use strict';\n\nvar Buffer = require('safe-buffer').Buffer;\n\nvar Message = function() {\n this.rsv1 = false;\n this.rsv2 = false;\n this.rsv3 = false;\n this.opcode = null;\n this.length = 0;\n this._chunks = [];\n};\n\nvar instance = {\n read: function() {\n return this.data = this.data || Buffer.concat(this._chunks, this.length);\n },\n\n pushFrame: function(frame) {\n this.rsv1 = this.rsv1 || frame.rsv1;\n this.rsv2 = this.rsv2 || frame.rsv2;\n this.rsv3 = this.rsv3 || frame.rsv3;\n\n if (this.opcode === null) this.opcode = frame.opcode;\n\n this._chunks.push(frame.payload);\n this.length += frame.length;\n }\n};\n\nfor (var key in instance)\n Message.prototype[key] = instance[key];\n\nmodule.exports = Message;\n","'use strict';\n\nvar Buffer = require('safe-buffer').Buffer,\n Stream = require('stream').Stream,\n url = require('url'),\n util = require('util'),\n Base = require('./base'),\n Headers = require('./headers'),\n HttpParser = require('../http_parser');\n\nvar PORTS = { 'ws:': 80, 'wss:': 443 };\n\nvar Proxy = function(client, origin, options) {\n this._client = client;\n this._http = new HttpParser('response');\n this._origin = (typeof client.url === 'object') ? client.url : url.parse(client.url);\n this._url = (typeof origin === 'object') ? origin : url.parse(origin);\n this._options = options || {};\n this._state = 0;\n\n this.readable = this.writable = true;\n this._paused = false;\n\n this._headers = new Headers();\n this._headers.set('Host', this._origin.host);\n this._headers.set('Connection', 'keep-alive');\n this._headers.set('Proxy-Connection', 'keep-alive');\n\n var auth = this._url.auth && Buffer.from(this._url.auth, 'utf8').toString('base64');\n if (auth) this._headers.set('Proxy-Authorization', 'Basic ' + auth);\n};\nutil.inherits(Proxy, Stream);\n\nvar instance = {\n setHeader: function(name, value) {\n if (this._state !== 0) return false;\n this._headers.set(name, value);\n return true;\n },\n\n start: function() {\n if (this._state !== 0) return false;\n this._state = 1;\n\n var origin = this._origin,\n port = origin.port || PORTS[origin.protocol],\n start = 'CONNECT ' + origin.hostname + ':' + port + ' HTTP/1.1';\n\n var headers = [start, this._headers.toString(), ''];\n\n this.emit('data', Buffer.from(headers.join('\\r\\n'), 'utf8'));\n return true;\n },\n\n pause: function() {\n this._paused = true;\n },\n\n resume: function() {\n this._paused = false;\n this.emit('drain');\n },\n\n write: function(chunk) {\n if (!this.writable) return false;\n\n this._http.parse(chunk);\n if (!this._http.isComplete()) return !this._paused;\n\n this.statusCode = this._http.statusCode;\n this.headers = this._http.headers;\n\n if (this.statusCode === 200) {\n this.emit('connect', new Base.ConnectEvent());\n } else {\n var message = \"Can't establish a connection to the server at \" + this._origin.href;\n this.emit('error', new Error(message));\n }\n this.end();\n return !this._paused;\n },\n\n end: function(chunk) {\n if (!this.writable) return;\n if (chunk !== undefined) this.write(chunk);\n this.readable = this.writable = false;\n this.emit('close');\n this.emit('end');\n },\n\n destroy: function() {\n this.end();\n }\n};\n\nfor (var key in instance)\n Proxy.prototype[key] = instance[key];\n\nmodule.exports = Proxy;\n","'use strict';\n\nvar util = require('util'),\n HttpParser = require('../http_parser'),\n Base = require('./base'),\n Draft75 = require('./draft75'),\n Draft76 = require('./draft76'),\n Hybi = require('./hybi');\n\nvar Server = function(options) {\n Base.call(this, null, null, options);\n this._http = new HttpParser('request');\n};\nutil.inherits(Server, Base);\n\nvar instance = {\n EVENTS: ['open', 'message', 'error', 'close', 'ping', 'pong'],\n\n _bindEventListeners: function() {\n this.messages.on('error', function() {});\n this.on('error', function() {});\n },\n\n parse: function(chunk) {\n if (this._delegate) return this._delegate.parse(chunk);\n\n this._http.parse(chunk);\n if (!this._http.isComplete()) return;\n\n this.method = this._http.method;\n this.url = this._http.url;\n this.headers = this._http.headers;\n this.body = this._http.body;\n\n var self = this;\n this._delegate = Server.http(this, this._options);\n this._delegate.messages = this.messages;\n this._delegate.io = this.io;\n this._open();\n\n this.EVENTS.forEach(function(event) {\n this._delegate.on(event, function(e) { self.emit(event, e) });\n }, this);\n\n this.protocol = this._delegate.protocol;\n this.version = this._delegate.version;\n\n this.parse(this._http.body);\n this.emit('connect', new Base.ConnectEvent());\n },\n\n _open: function() {\n this.__queue.forEach(function(msg) {\n this._delegate[msg[0]].apply(this._delegate, msg[1]);\n }, this);\n this.__queue = [];\n }\n};\n\n['addExtension', 'setHeader', 'start', 'frame', 'text', 'binary', 'ping', 'close'].forEach(function(method) {\n instance[method] = function() {\n if (this._delegate) {\n return this._delegate[method].apply(this._delegate, arguments);\n } else {\n this.__queue.push([method, arguments]);\n return true;\n }\n };\n});\n\nfor (var key in instance)\n Server.prototype[key] = instance[key];\n\nServer.isSecureRequest = function(request) {\n if (request.connection && request.connection.authorized !== undefined) return true;\n if (request.socket && request.socket.secure) return true;\n\n var headers = request.headers;\n if (!headers) return false;\n if (headers['https'] === 'on') return true;\n if (headers['x-forwarded-ssl'] === 'on') return true;\n if (headers['x-forwarded-scheme'] === 'https') return true;\n if (headers['x-forwarded-proto'] === 'https') return true;\n\n return false;\n};\n\nServer.determineUrl = function(request) {\n var scheme = this.isSecureRequest(request) ? 'wss:' : 'ws:';\n return scheme + '//' + request.headers.host + request.url;\n};\n\nServer.http = function(request, options) {\n options = options || {};\n if (options.requireMasking === undefined) options.requireMasking = true;\n\n var headers = request.headers,\n version = headers['sec-websocket-version'],\n key = headers['sec-websocket-key'],\n key1 = headers['sec-websocket-key1'],\n key2 = headers['sec-websocket-key2'],\n url = this.determineUrl(request);\n\n if (version || key)\n return new Hybi(request, url, options);\n else if (key1 || key2)\n return new Draft76(request, url, options);\n else\n return new Draft75(request, url, options);\n};\n\nmodule.exports = Server;\n","'use strict';\n\nvar Buffer = require('safe-buffer').Buffer,\n Base = require('./base'),\n Draft75 = require('./draft75'),\n crypto = require('crypto'),\n util = require('util');\n\n\nvar numberFromKey = function(key) {\n return parseInt((key.match(/[0-9]/g) || []).join(''), 10);\n};\n\nvar spacesInKey = function(key) {\n return (key.match(/ /g) || []).length;\n};\n\n\nvar Draft76 = function(request, url, options) {\n Draft75.apply(this, arguments);\n this._stage = -1;\n this._body = [];\n this.version = 'hixie-76';\n\n this._headers.clear();\n\n this._headers.set('Upgrade', 'WebSocket');\n this._headers.set('Connection', 'Upgrade');\n this._headers.set('Sec-WebSocket-Origin', this._request.headers.origin);\n this._headers.set('Sec-WebSocket-Location', this.url);\n};\nutil.inherits(Draft76, Draft75);\n\nvar instance = {\n BODY_SIZE: 8,\n\n start: function() {\n if (!Draft75.prototype.start.call(this)) return false;\n this._started = true;\n this._sendHandshakeBody();\n return true;\n },\n\n close: function() {\n if (this.readyState === 3) return false;\n if (this.readyState === 1) this._write(Buffer.from([0xFF, 0x00]));\n this.readyState = 3;\n this.emit('close', new Base.CloseEvent(null, null));\n return true;\n },\n\n _handshakeResponse: function() {\n var headers = this._request.headers,\n key1 = headers['sec-websocket-key1'],\n key2 = headers['sec-websocket-key2'];\n\n if (!key1) throw new Error('Missing required header: Sec-WebSocket-Key1');\n if (!key2) throw new Error('Missing required header: Sec-WebSocket-Key2');\n\n var number1 = numberFromKey(key1),\n spaces1 = spacesInKey(key1),\n\n number2 = numberFromKey(key2),\n spaces2 = spacesInKey(key2);\n\n if (number1 % spaces1 !== 0 || number2 % spaces2 !== 0)\n throw new Error('Client sent invalid Sec-WebSocket-Key headers');\n\n this._keyValues = [number1 / spaces1, number2 / spaces2];\n\n var start = 'HTTP/1.1 101 WebSocket Protocol Handshake',\n headers = [start, this._headers.toString(), ''];\n\n return Buffer.from(headers.join('\\r\\n'), 'binary');\n },\n\n _handshakeSignature: function() {\n if (this._body.length < this.BODY_SIZE) return null;\n\n var md5 = crypto.createHash('md5'),\n buffer = Buffer.allocUnsafe(8 + this.BODY_SIZE);\n\n buffer.writeUInt32BE(this._keyValues[0], 0);\n buffer.writeUInt32BE(this._keyValues[1], 4);\n Buffer.from(this._body).copy(buffer, 8, 0, this.BODY_SIZE);\n\n md5.update(buffer);\n return Buffer.from(md5.digest('binary'), 'binary');\n },\n\n _sendHandshakeBody: function() {\n if (!this._started) return;\n var signature = this._handshakeSignature();\n if (!signature) return;\n\n this._write(signature);\n this._stage = 0;\n this._open();\n\n if (this._body.length > this.BODY_SIZE)\n this.parse(this._body.slice(this.BODY_SIZE));\n },\n\n _parseLeadingByte: function(octet) {\n if (octet !== 0xFF)\n return Draft75.prototype._parseLeadingByte.call(this, octet);\n\n this._closing = true;\n this._length = 0;\n this._stage = 1;\n }\n};\n\nfor (var key in instance)\n Draft76.prototype[key] = instance[key];\n\nmodule.exports = Draft76;\n","'use strict';\n\nvar util = require('util'),\n net = require('net'),\n tls = require('tls'),\n url = require('url'),\n driver = require('websocket-driver'),\n API = require('./api'),\n Event = require('./api/event');\n\nvar DEFAULT_PORTS = {'http:': 80, 'https:': 443, 'ws:':80, 'wss:': 443},\n SECURE_PROTOCOLS = ['https:', 'wss:'];\n\nvar Client = function(_url, protocols, options) {\n options = options || {};\n\n this.url = _url;\n this._driver = driver.client(this.url, {maxLength: options.maxLength, protocols: protocols});\n\n ['open', 'error'].forEach(function(event) {\n this._driver.on(event, function() {\n self.headers = self._driver.headers;\n self.statusCode = self._driver.statusCode;\n });\n }, this);\n\n var proxy = options.proxy || {},\n endpoint = url.parse(proxy.origin || this.url),\n port = endpoint.port || DEFAULT_PORTS[endpoint.protocol],\n secure = SECURE_PROTOCOLS.indexOf(endpoint.protocol) >= 0,\n onConnect = function() { self._onConnect() },\n netOptions = options.net || {},\n originTLS = options.tls || {},\n socketTLS = proxy.origin ? (proxy.tls || {}) : originTLS,\n self = this;\n\n netOptions.host = socketTLS.host = endpoint.hostname;\n netOptions.port = socketTLS.port = port;\n\n originTLS.ca = originTLS.ca || options.ca;\n socketTLS.servername = socketTLS.servername || endpoint.hostname;\n\n this._stream = secure\n ? tls.connect(socketTLS, onConnect)\n : net.connect(netOptions, onConnect);\n\n if (proxy.origin) this._configureProxy(proxy, originTLS);\n\n API.call(this, options);\n};\nutil.inherits(Client, API);\n\nClient.prototype._onConnect = function() {\n var worker = this._proxy || this._driver;\n worker.start();\n};\n\nClient.prototype._configureProxy = function(proxy, originTLS) {\n var uri = url.parse(this.url),\n secure = SECURE_PROTOCOLS.indexOf(uri.protocol) >= 0,\n self = this,\n name;\n\n this._proxy = this._driver.proxy(proxy.origin);\n\n if (proxy.headers) {\n for (name in proxy.headers) this._proxy.setHeader(name, proxy.headers[name]);\n }\n\n this._proxy.pipe(this._stream, {end: false});\n this._stream.pipe(this._proxy);\n\n this._proxy.on('connect', function() {\n if (secure) {\n var options = {socket: self._stream, servername: uri.hostname};\n for (name in originTLS) options[name] = originTLS[name];\n self._stream = tls.connect(options);\n self._configureStream();\n }\n self._driver.io.pipe(self._stream);\n self._stream.pipe(self._driver.io);\n self._driver.start();\n });\n\n this._proxy.on('error', function(error) {\n self._driver.emit('error', error);\n });\n};\n\nmodule.exports = Client;\n","module.exports = require(\"net\");","module.exports = require(\"tls\");","'use strict';\n\nvar Stream = require('stream').Stream,\n util = require('util'),\n driver = require('websocket-driver'),\n Headers = require('websocket-driver/lib/websocket/driver/headers'),\n API = require('./websocket/api'),\n EventTarget = require('./websocket/api/event_target'),\n Event = require('./websocket/api/event');\n\nvar EventSource = function(request, response, options) {\n this.writable = true;\n options = options || {};\n\n this._stream = response.socket;\n this._ping = options.ping || this.DEFAULT_PING;\n this._retry = options.retry || this.DEFAULT_RETRY;\n\n var scheme = driver.isSecureRequest(request) ? 'https:' : 'http:';\n this.url = scheme + '//' + request.headers.host + request.url;\n this.lastEventId = request.headers['last-event-id'] || '';\n this.readyState = API.CONNECTING;\n\n var headers = new Headers(),\n self = this;\n\n if (options.headers) {\n for (var key in options.headers) headers.set(key, options.headers[key]);\n }\n\n if (!this._stream || !this._stream.writable) return;\n process.nextTick(function() { self._open() });\n\n this._stream.setTimeout(0);\n this._stream.setNoDelay(true);\n\n var handshake = 'HTTP/1.1 200 OK\\r\\n' +\n 'Content-Type: text/event-stream\\r\\n' +\n 'Cache-Control: no-cache, no-store\\r\\n' +\n 'Connection: close\\r\\n' +\n headers.toString() +\n '\\r\\n' +\n 'retry: ' + Math.floor(this._retry * 1000) + '\\r\\n\\r\\n';\n\n this._write(handshake);\n\n this._stream.on('drain', function() { self.emit('drain') });\n\n if (this._ping)\n this._pingTimer = setInterval(function() { self.ping() }, this._ping * 1000);\n\n ['error', 'end'].forEach(function(event) {\n self._stream.on(event, function() { self.close() });\n });\n};\nutil.inherits(EventSource, Stream);\n\nEventSource.isEventSource = function(request) {\n if (request.method !== 'GET') return false;\n var accept = (request.headers.accept || '').split(/\\s*,\\s*/);\n return accept.indexOf('text/event-stream') >= 0;\n};\n\nvar instance = {\n DEFAULT_PING: 10,\n DEFAULT_RETRY: 5,\n\n _write: function(chunk) {\n if (!this.writable) return false;\n try {\n return this._stream.write(chunk, 'utf8');\n } catch (e) {\n return false;\n }\n },\n\n _open: function() {\n if (this.readyState !== API.CONNECTING) return;\n\n this.readyState = API.OPEN;\n\n var event = new Event('open');\n event.initEvent('open', false, false);\n this.dispatchEvent(event);\n },\n\n write: function(message) {\n return this.send(message);\n },\n\n end: function(message) {\n if (message !== undefined) this.write(message);\n this.close();\n },\n\n send: function(message, options) {\n if (this.readyState > API.OPEN) return false;\n\n message = String(message).replace(/(\\r\\n|\\r|\\n)/g, '$1data: ');\n options = options || {};\n\n var frame = '';\n if (options.event) frame += 'event: ' + options.event + '\\r\\n';\n if (options.id) frame += 'id: ' + options.id + '\\r\\n';\n frame += 'data: ' + message + '\\r\\n\\r\\n';\n\n return this._write(frame);\n },\n\n ping: function() {\n return this._write(':\\r\\n\\r\\n');\n },\n\n close: function() {\n if (this.readyState > API.OPEN) return false;\n\n this.readyState = API.CLOSED;\n this.writable = false;\n if (this._pingTimer) clearInterval(this._pingTimer);\n if (this._stream) this._stream.end();\n\n var event = new Event('close');\n event.initEvent('close', false, false);\n this.dispatchEvent(event);\n\n return true;\n }\n};\n\nfor (var method in instance) EventSource.prototype[method] = instance[method];\nfor (var key in EventTarget) EventSource.prototype[key] = EventTarget[key];\n\nmodule.exports = EventSource;\n","module.exports = require(\"child_process\");","module.exports = require(\"fs\");","module.exports = require(\"http\");","module.exports = require(\"https\");","export default function encode(s: any): string {\n return btoa(utob(s));\n}\n\nvar fromCharCode = String.fromCharCode;\n\nvar b64chars =\n 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';\nvar b64tab = {};\n\nfor (var i = 0, l = b64chars.length; i < l; i++) {\n b64tab[b64chars.charAt(i)] = i;\n}\n\nvar cb_utob = function(c) {\n var cc = c.charCodeAt(0);\n return cc < 0x80\n ? c\n : cc < 0x800\n ? fromCharCode(0xc0 | (cc >>> 6)) + fromCharCode(0x80 | (cc & 0x3f))\n : fromCharCode(0xe0 | ((cc >>> 12) & 0x0f)) +\n fromCharCode(0x80 | ((cc >>> 6) & 0x3f)) +\n fromCharCode(0x80 | (cc & 0x3f));\n};\n\nvar utob = function(u) {\n return u.replace(/[^\\x00-\\x7F]/g, cb_utob);\n};\n\nvar cb_encode = function(ccc) {\n var padlen = [0, 2, 1][ccc.length % 3];\n var ord =\n (ccc.charCodeAt(0) << 16) |\n ((ccc.length > 1 ? ccc.charCodeAt(1) : 0) << 8) |\n (ccc.length > 2 ? ccc.charCodeAt(2) : 0);\n var chars = [\n b64chars.charAt(ord >>> 18),\n b64chars.charAt((ord >>> 12) & 63),\n padlen >= 2 ? '=' : b64chars.charAt((ord >>> 6) & 63),\n padlen >= 1 ? '=' : b64chars.charAt(ord & 63)\n ];\n return chars.join('');\n};\n\nvar btoa =\n global.btoa ||\n function(b) {\n return b.replace(/[\\s\\S]{1,3}/g, cb_encode);\n };\n","import TimedCallback from './timed_callback';\nimport { Delay, Scheduler, Canceller } from './scheduling';\n\nabstract class Timer {\n protected clear: Canceller;\n protected timer: number | void;\n\n constructor(\n set: Scheduler,\n clear: Canceller,\n delay: Delay,\n callback: TimedCallback\n ) {\n this.clear = clear;\n this.timer = set(() => {\n if (this.timer) {\n this.timer = callback(this.timer);\n }\n }, delay);\n }\n\n /** Returns whether the timer is still running.\n *\n * @return {Boolean}\n */\n isRunning(): boolean {\n return this.timer !== null;\n }\n\n /** Aborts a timer when it's running. */\n ensureAborted() {\n if (this.timer) {\n this.clear(this.timer);\n this.timer = null;\n }\n }\n}\n\nexport default Timer;\n","import Timer from './abstract_timer';\nimport TimedCallback from './timed_callback';\nimport { Delay } from './scheduling';\n\n// We need to bind clear functions this way to avoid exceptions on IE8\nfunction clearTimeout(timer) {\n global.clearTimeout(timer);\n}\nfunction clearInterval(timer) {\n global.clearInterval(timer);\n}\n\n/** Cross-browser compatible one-off timer abstraction.\n *\n * @param {Number} delay\n * @param {Function} callback\n */\nexport class OneOffTimer extends Timer {\n constructor(delay: Delay, callback: TimedCallback) {\n super(setTimeout, clearTimeout, delay, function(timer) {\n callback();\n return null;\n });\n }\n}\n\n/** Cross-browser compatible periodic timer abstraction.\n *\n * @param {Number} delay\n * @param {Function} callback\n */\nexport class PeriodicTimer extends Timer {\n constructor(delay: Delay, callback: TimedCallback) {\n super(setInterval, clearInterval, delay, function(timer) {\n callback();\n return timer;\n });\n }\n}\n","import * as Collections from './utils/collections';\nimport TimedCallback from './utils/timers/timed_callback';\nimport { OneOffTimer, PeriodicTimer } from './utils/timers';\n\nvar Util = {\n now(): number {\n if (Date.now) {\n return Date.now();\n } else {\n return new Date().valueOf();\n }\n },\n\n defer(callback: TimedCallback): OneOffTimer {\n return new OneOffTimer(0, callback);\n },\n\n /** Builds a function that will proxy a method call to its first argument.\n *\n * Allows partial application of arguments, so additional arguments are\n * prepended to the argument list.\n *\n * @param {String} name method name\n * @return {Function} proxy function\n */\n method(name: string, ...args: any[]): Function {\n var boundArguments = Array.prototype.slice.call(arguments, 1);\n return function(object) {\n return object[name].apply(object, boundArguments.concat(arguments));\n };\n }\n};\n\nexport default Util;\n","import base64encode from '../base64';\nimport Util from '../util';\n\n/** Merges multiple objects into the target argument.\n *\n * For properties that are plain Objects, performs a deep-merge. For the\n * rest it just copies the value of the property.\n *\n * To extend prototypes use it as following:\n * Pusher.Util.extend(Target.prototype, Base.prototype)\n *\n * You can also use it to merge objects without altering them:\n * Pusher.Util.extend({}, object1, object2)\n *\n * @param {Object} target\n * @return {Object} the target argument\n */\nexport function extend(target: any, ...sources: any[]): T {\n for (var i = 0; i < sources.length; i++) {\n var extensions = sources[i];\n for (var property in extensions) {\n if (\n extensions[property] &&\n extensions[property].constructor &&\n extensions[property].constructor === Object\n ) {\n target[property] = extend(target[property] || {}, extensions[property]);\n } else {\n target[property] = extensions[property];\n }\n }\n }\n return target;\n}\n\nexport function stringify(): string {\n var m = ['Pusher'];\n for (var i = 0; i < arguments.length; i++) {\n if (typeof arguments[i] === 'string') {\n m.push(arguments[i]);\n } else {\n m.push(safeJSONStringify(arguments[i]));\n }\n }\n return m.join(' : ');\n}\n\nexport function arrayIndexOf(array: any[], item: any): number {\n // MSIE doesn't have array.indexOf\n var nativeIndexOf = Array.prototype.indexOf;\n if (array === null) {\n return -1;\n }\n if (nativeIndexOf && array.indexOf === nativeIndexOf) {\n return array.indexOf(item);\n }\n for (var i = 0, l = array.length; i < l; i++) {\n if (array[i] === item) {\n return i;\n }\n }\n return -1;\n}\n\n/** Applies a function f to all properties of an object.\n *\n * Function f gets 3 arguments passed:\n * - element from the object\n * - key of the element\n * - reference to the object\n *\n * @param {Object} object\n * @param {Function} f\n */\nexport function objectApply(object: any, f: Function) {\n for (var key in object) {\n if (Object.prototype.hasOwnProperty.call(object, key)) {\n f(object[key], key, object);\n }\n }\n}\n\n/** Return a list of objects own proerty keys\n *\n * @param {Object} object\n * @returns {Array}\n */\nexport function keys(object: any): string[] {\n var keys = [];\n objectApply(object, function(_, key) {\n keys.push(key);\n });\n return keys;\n}\n\n/** Return a list of object's own property values\n *\n * @param {Object} object\n * @returns {Array}\n */\nexport function values(object: any): any[] {\n var values = [];\n objectApply(object, function(value) {\n values.push(value);\n });\n return values;\n}\n\n/** Applies a function f to all elements of an array.\n *\n * Function f gets 3 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function apply(array: any[], f: Function, context?: any) {\n for (var i = 0; i < array.length; i++) {\n f.call(context || global, array[i], i, array);\n }\n}\n\n/** Maps all elements of the array and returns the result.\n *\n * Function f gets 4 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n * - reference to the destination array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function map(array: any[], f: Function): any[] {\n var result = [];\n for (var i = 0; i < array.length; i++) {\n result.push(f(array[i], i, array, result));\n }\n return result;\n}\n\n/** Maps all elements of the object and returns the result.\n *\n * Function f gets 4 arguments passed:\n * - element from the object\n * - key of the element\n * - reference to the source object\n * - reference to the destination object\n *\n * @param {Object} object\n * @param {Function} f\n */\nexport function mapObject(object: any, f: Function): any {\n var result = {};\n objectApply(object, function(value, key) {\n result[key] = f(value);\n });\n return result;\n}\n\n/** Filters elements of the array using a test function.\n *\n * Function test gets 4 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n * - reference to the destination array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function filter(array: any[], test: Function): any[] {\n test =\n test ||\n function(value) {\n return !!value;\n };\n\n var result = [];\n for (var i = 0; i < array.length; i++) {\n if (test(array[i], i, array, result)) {\n result.push(array[i]);\n }\n }\n return result;\n}\n\n/** Filters properties of the object using a test function.\n *\n * Function test gets 4 arguments passed:\n * - element from the object\n * - key of the element\n * - reference to the source object\n * - reference to the destination object\n *\n * @param {Object} object\n * @param {Function} f\n */\nexport function filterObject(object: Object, test: Function) {\n var result = {};\n objectApply(object, function(value, key) {\n if ((test && test(value, key, object, result)) || Boolean(value)) {\n result[key] = value;\n }\n });\n return result;\n}\n\n/** Flattens an object into a two-dimensional array.\n *\n * @param {Object} object\n * @return {Array} resulting array of [key, value] pairs\n */\nexport function flatten(object: Object): any[] {\n var result = [];\n objectApply(object, function(value, key) {\n result.push([key, value]);\n });\n return result;\n}\n\n/** Checks whether any element of the array passes the test.\n *\n * Function test gets 3 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function any(array: any[], test: Function): boolean {\n for (var i = 0; i < array.length; i++) {\n if (test(array[i], i, array)) {\n return true;\n }\n }\n return false;\n}\n\n/** Checks whether all elements of the array pass the test.\n *\n * Function test gets 3 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function all(array: any[], test: Function): boolean {\n for (var i = 0; i < array.length; i++) {\n if (!test(array[i], i, array)) {\n return false;\n }\n }\n return true;\n}\n\nexport function encodeParamsObject(data): string {\n return mapObject(data, function(value) {\n if (typeof value === 'object') {\n value = safeJSONStringify(value);\n }\n return encodeURIComponent(base64encode(value.toString()));\n });\n}\n\nexport function buildQueryString(data: any): string {\n var params = filterObject(data, function(value) {\n return value !== undefined;\n });\n\n var query = map(\n flatten(encodeParamsObject(params)),\n Util.method('join', '=')\n ).join('&');\n\n return query;\n}\n\n/**\n * See https://github.com/douglascrockford/JSON-js/blob/master/cycle.js\n *\n * Remove circular references from an object. Required for JSON.stringify in\n * React Native, which tends to blow up a lot.\n *\n * @param {any} object\n * @return {any} Decycled object\n */\nexport function decycleObject(object: any): any {\n var objects = [],\n paths = [];\n\n return (function derez(value, path) {\n var i, name, nu;\n\n switch (typeof value) {\n case 'object':\n if (!value) {\n return null;\n }\n for (i = 0; i < objects.length; i += 1) {\n if (objects[i] === value) {\n return { $ref: paths[i] };\n }\n }\n\n objects.push(value);\n paths.push(path);\n\n if (Object.prototype.toString.apply(value) === '[object Array]') {\n nu = [];\n for (i = 0; i < value.length; i += 1) {\n nu[i] = derez(value[i], path + '[' + i + ']');\n }\n } else {\n nu = {};\n for (name in value) {\n if (Object.prototype.hasOwnProperty.call(value, name)) {\n nu[name] = derez(\n value[name],\n path + '[' + JSON.stringify(name) + ']'\n );\n }\n }\n }\n return nu;\n case 'number':\n case 'string':\n case 'boolean':\n return value;\n }\n })(object, '$');\n}\n\n/**\n * Provides a cross-browser and cross-platform way to safely stringify objects\n * into JSON. This is particularly necessary for ReactNative, where circular JSON\n * structures throw an exception.\n *\n * @param {any} source The object to stringify\n * @return {string} The serialized output.\n */\nexport function safeJSONStringify(source: any): string {\n try {\n return JSON.stringify(source);\n } catch (e) {\n return JSON.stringify(decycleObject(source));\n }\n}\n","import {\n ChannelAuthorizationOptions,\n UserAuthenticationOptions\n} from './auth/options';\nimport { AuthTransport } from './config';\n\nexport interface DefaultConfig {\n VERSION: string;\n PROTOCOL: number;\n wsPort: number;\n wssPort: number;\n wsPath: string;\n httpHost: string;\n httpPort: number;\n httpsPort: number;\n httpPath: string;\n stats_host: string;\n authEndpoint: string;\n authTransport: AuthTransport;\n activityTimeout: number;\n pongTimeout: number;\n unavailableTimeout: number;\n userAuthentication: UserAuthenticationOptions;\n channelAuthorization: ChannelAuthorizationOptions;\n\n cdn_http?: string;\n cdn_https?: string;\n dependency_suffix?: string;\n}\n\nvar Defaults: DefaultConfig = {\n VERSION: VERSION,\n PROTOCOL: 7,\n\n wsPort: 80,\n wssPort: 443,\n wsPath: '',\n // DEPRECATED: SockJS fallback parameters\n httpHost: 'sockjs.pusher.com',\n httpPort: 80,\n httpsPort: 443,\n httpPath: '/pusher',\n // DEPRECATED: Stats\n stats_host: 'stats.pusher.com',\n // DEPRECATED: Other settings\n authEndpoint: '/pusher/auth',\n authTransport: 'ajax',\n activityTimeout: 120000,\n pongTimeout: 30000,\n unavailableTimeout: 10000,\n userAuthentication: {\n endpoint: '/pusher/user-auth',\n transport: 'ajax'\n },\n channelAuthorization: {\n endpoint: '/pusher/auth',\n transport: 'ajax'\n },\n\n // CDN configuration\n cdn_http: CDN_HTTP,\n cdn_https: CDN_HTTPS,\n dependency_suffix: DEPENDENCY_SUFFIX\n};\n\nexport default Defaults;\n","import Defaults from '../defaults';\nimport { default as URLScheme, URLSchemeParams } from './url_scheme';\n\nfunction getGenericURL(\n baseScheme: string,\n params: URLSchemeParams,\n path: string\n): string {\n var scheme = baseScheme + (params.useTLS ? 's' : '');\n var host = params.useTLS ? params.hostTLS : params.hostNonTLS;\n return scheme + '://' + host + path;\n}\n\nfunction getGenericPath(key: string, queryString?: string): string {\n var path = '/app/' + key;\n var query =\n '?protocol=' +\n Defaults.PROTOCOL +\n '&client=js' +\n '&version=' +\n Defaults.VERSION +\n (queryString ? '&' + queryString : '');\n return path + query;\n}\n\nexport var ws: URLScheme = {\n getInitial: function(key: string, params: URLSchemeParams): string {\n var path = (params.httpPath || '') + getGenericPath(key, 'flash=false');\n return getGenericURL('ws', params, path);\n }\n};\n\nexport var http: URLScheme = {\n getInitial: function(key: string, params: URLSchemeParams): string {\n var path = (params.httpPath || '/pusher') + getGenericPath(key);\n return getGenericURL('http', params, path);\n }\n};\n\nexport var sockjs: URLScheme = {\n getInitial: function(key: string, params: URLSchemeParams): string {\n return getGenericURL('http', params, params.httpPath || '/pusher');\n },\n getPath: function(key: string, params: URLSchemeParams): string {\n return getGenericPath(key);\n }\n};\n","import Callback from './callback';\nimport * as Collections from '../utils/collections';\nimport CallbackTable from './callback_table';\n\nexport default class CallbackRegistry {\n _callbacks: CallbackTable;\n\n constructor() {\n this._callbacks = {};\n }\n\n get(name: string): Callback[] {\n return this._callbacks[prefix(name)];\n }\n\n add(name: string, callback: Function, context: any) {\n var prefixedEventName = prefix(name);\n this._callbacks[prefixedEventName] =\n this._callbacks[prefixedEventName] || [];\n this._callbacks[prefixedEventName].push({\n fn: callback,\n context: context\n });\n }\n\n remove(name?: string, callback?: Function, context?: any) {\n if (!name && !callback && !context) {\n this._callbacks = {};\n return;\n }\n\n var names = name ? [prefix(name)] : Collections.keys(this._callbacks);\n\n if (callback || context) {\n this.removeCallback(names, callback, context);\n } else {\n this.removeAllCallbacks(names);\n }\n }\n\n private removeCallback(names: string[], callback: Function, context: any) {\n Collections.apply(\n names,\n function(name) {\n this._callbacks[name] = Collections.filter(\n this._callbacks[name] || [],\n function(binding) {\n return (\n (callback && callback !== binding.fn) ||\n (context && context !== binding.context)\n );\n }\n );\n if (this._callbacks[name].length === 0) {\n delete this._callbacks[name];\n }\n },\n this\n );\n }\n\n private removeAllCallbacks(names: string[]) {\n Collections.apply(\n names,\n function(name) {\n delete this._callbacks[name];\n },\n this\n );\n }\n}\n\nfunction prefix(name: string): string {\n return '_' + name;\n}\n","import * as Collections from '../utils/collections';\nimport Callback from './callback';\nimport Metadata from '../channels/metadata';\nimport CallbackRegistry from './callback_registry';\n\n/** Manages callback bindings and event emitting.\n *\n * @param Function failThrough called when no listeners are bound to an event\n */\nexport default class Dispatcher {\n callbacks: CallbackRegistry;\n global_callbacks: Function[];\n failThrough: Function;\n\n constructor(failThrough?: Function) {\n this.callbacks = new CallbackRegistry();\n this.global_callbacks = [];\n this.failThrough = failThrough;\n }\n\n bind(eventName: string, callback: Function, context?: any) {\n this.callbacks.add(eventName, callback, context);\n return this;\n }\n\n bind_global(callback: Function) {\n this.global_callbacks.push(callback);\n return this;\n }\n\n unbind(eventName?: string, callback?: Function, context?: any) {\n this.callbacks.remove(eventName, callback, context);\n return this;\n }\n\n unbind_global(callback?: Function) {\n if (!callback) {\n this.global_callbacks = [];\n return this;\n }\n\n this.global_callbacks = Collections.filter(\n this.global_callbacks || [],\n c => c !== callback\n );\n\n return this;\n }\n\n unbind_all() {\n this.unbind();\n this.unbind_global();\n return this;\n }\n\n emit(eventName: string, data?: any, metadata?: Metadata): Dispatcher {\n for (var i = 0; i < this.global_callbacks.length; i++) {\n this.global_callbacks[i](eventName, data);\n }\n\n var callbacks = this.callbacks.get(eventName);\n var args = [];\n\n if (metadata) {\n // if there's a metadata argument, we need to call the callback with both\n // data and metadata regardless of whether data is undefined\n args.push(data, metadata);\n } else if (data) {\n // metadata is undefined, so we only need to call the callback with data\n // if data exists\n args.push(data);\n }\n\n if (callbacks && callbacks.length > 0) {\n for (var i = 0; i < callbacks.length; i++) {\n callbacks[i].fn.apply(callbacks[i].context || global, args);\n }\n } else if (this.failThrough) {\n this.failThrough(eventName, data);\n }\n\n return this;\n }\n}\n","import { stringify } from './utils/collections';\nimport Pusher from './pusher';\n\nclass Logger {\n debug(...args: any[]) {\n this.log(this.globalLog, args);\n }\n\n warn(...args: any[]) {\n this.log(this.globalLogWarn, args);\n }\n\n error(...args: any[]) {\n this.log(this.globalLogError, args);\n }\n\n private globalLog = (message: string) => {\n if (global.console && global.console.log) {\n global.console.log(message);\n }\n };\n\n private globalLogWarn(message: string) {\n if (global.console && global.console.warn) {\n global.console.warn(message);\n } else {\n this.globalLog(message);\n }\n }\n\n private globalLogError(message: string) {\n if (global.console && global.console.error) {\n global.console.error(message);\n } else {\n this.globalLogWarn(message);\n }\n }\n\n private log(\n defaultLoggingFunction: (message: string) => void,\n ...args: any[]\n ) {\n var message = stringify.apply(this, arguments);\n if (Pusher.log) {\n Pusher.log(message);\n } else if (Pusher.logToConsole) {\n const log = defaultLoggingFunction.bind(this);\n log(message);\n }\n }\n}\n\nexport default new Logger();\n","import Util from '../util';\nimport * as Collections from '../utils/collections';\nimport { default as EventsDispatcher } from '../events/dispatcher';\nimport Logger from '../logger';\nimport TransportHooks from './transport_hooks';\nimport Socket from '../socket';\nimport Runtime from 'runtime';\nimport Timeline from '../timeline/timeline';\nimport TransportConnectionOptions from './transport_connection_options';\n\n/** Provides universal API for transport connections.\n *\n * Transport connection is a low-level object that wraps a connection method\n * and exposes a simple evented interface for the connection state and\n * messaging. It does not implement Pusher-specific WebSocket protocol.\n *\n * Additionally, it fetches resources needed for transport to work and exposes\n * an interface for querying transport features.\n *\n * States:\n * - new - initial state after constructing the object\n * - initializing - during initialization phase, usually fetching resources\n * - intialized - ready to establish a connection\n * - connection - when connection is being established\n * - open - when connection ready to be used\n * - closed - after connection was closed be either side\n *\n * Emits:\n * - error - after the connection raised an error\n *\n * Options:\n * - useTLS - whether connection should be over TLS\n * - hostTLS - host to connect to when connection is over TLS\n * - hostNonTLS - host to connect to when connection is over TLS\n *\n * @param {String} key application key\n * @param {Object} options\n */\nexport default class TransportConnection extends EventsDispatcher {\n hooks: TransportHooks;\n name: string;\n priority: number;\n key: string;\n options: TransportConnectionOptions;\n state: string;\n timeline: Timeline;\n activityTimeout: number;\n id: number;\n socket: Socket;\n beforeOpen: Function;\n initialize: Function;\n\n constructor(\n hooks: TransportHooks,\n name: string,\n priority: number,\n key: string,\n options: TransportConnectionOptions\n ) {\n super();\n this.initialize = Runtime.transportConnectionInitializer;\n this.hooks = hooks;\n this.name = name;\n this.priority = priority;\n this.key = key;\n this.options = options;\n\n this.state = 'new';\n this.timeline = options.timeline;\n this.activityTimeout = options.activityTimeout;\n this.id = this.timeline.generateUniqueID();\n }\n\n /** Checks whether the transport handles activity checks by itself.\n *\n * @return {Boolean}\n */\n handlesActivityChecks(): boolean {\n return Boolean(this.hooks.handlesActivityChecks);\n }\n\n /** Checks whether the transport supports the ping/pong API.\n *\n * @return {Boolean}\n */\n supportsPing(): boolean {\n return Boolean(this.hooks.supportsPing);\n }\n\n /** Tries to establish a connection.\n *\n * @returns {Boolean} false if transport is in invalid state\n */\n connect(): boolean {\n if (this.socket || this.state !== 'initialized') {\n return false;\n }\n\n var url = this.hooks.urls.getInitial(this.key, this.options);\n try {\n this.socket = this.hooks.getSocket(url, this.options);\n } catch (e) {\n Util.defer(() => {\n this.onError(e);\n this.changeState('closed');\n });\n return false;\n }\n\n this.bindListeners();\n\n Logger.debug('Connecting', { transport: this.name, url });\n this.changeState('connecting');\n return true;\n }\n\n /** Closes the connection.\n *\n * @return {Boolean} true if there was a connection to close\n */\n close(): boolean {\n if (this.socket) {\n this.socket.close();\n return true;\n } else {\n return false;\n }\n }\n\n /** Sends data over the open connection.\n *\n * @param {String} data\n * @return {Boolean} true only when in the \"open\" state\n */\n send(data: any): boolean {\n if (this.state === 'open') {\n // Workaround for MobileSafari bug (see https://gist.github.com/2052006)\n Util.defer(() => {\n if (this.socket) {\n this.socket.send(data);\n }\n });\n return true;\n } else {\n return false;\n }\n }\n\n /** Sends a ping if the connection is open and transport supports it. */\n ping() {\n if (this.state === 'open' && this.supportsPing()) {\n this.socket.ping();\n }\n }\n\n private onOpen() {\n if (this.hooks.beforeOpen) {\n this.hooks.beforeOpen(\n this.socket,\n this.hooks.urls.getPath(this.key, this.options)\n );\n }\n this.changeState('open');\n this.socket.onopen = undefined;\n }\n\n private onError(error) {\n this.emit('error', { type: 'WebSocketError', error: error });\n this.timeline.error(this.buildTimelineMessage({ error: error.toString() }));\n }\n\n private onClose(closeEvent?: any) {\n if (closeEvent) {\n this.changeState('closed', {\n code: closeEvent.code,\n reason: closeEvent.reason,\n wasClean: closeEvent.wasClean\n });\n } else {\n this.changeState('closed');\n }\n this.unbindListeners();\n this.socket = undefined;\n }\n\n private onMessage(message) {\n this.emit('message', message);\n }\n\n private onActivity() {\n this.emit('activity');\n }\n\n private bindListeners() {\n this.socket.onopen = () => {\n this.onOpen();\n };\n this.socket.onerror = error => {\n this.onError(error);\n };\n this.socket.onclose = closeEvent => {\n this.onClose(closeEvent);\n };\n this.socket.onmessage = message => {\n this.onMessage(message);\n };\n\n if (this.supportsPing()) {\n this.socket.onactivity = () => {\n this.onActivity();\n };\n }\n }\n\n private unbindListeners() {\n if (this.socket) {\n this.socket.onopen = undefined;\n this.socket.onerror = undefined;\n this.socket.onclose = undefined;\n this.socket.onmessage = undefined;\n if (this.supportsPing()) {\n this.socket.onactivity = undefined;\n }\n }\n }\n\n private changeState(state: string, params?: any) {\n this.state = state;\n this.timeline.info(\n this.buildTimelineMessage({\n state: state,\n params: params\n })\n );\n this.emit(state, params);\n }\n\n buildTimelineMessage(message): any {\n return Collections.extend({ cid: this.id }, message);\n }\n}\n","import Factory from '../utils/factory';\nimport TransportHooks from './transport_hooks';\nimport TransportConnection from './transport_connection';\nimport TransportConnectionOptions from './transport_connection_options';\n\n/** Provides interface for transport connection instantiation.\n *\n * Takes transport-specific hooks as the only argument, which allow checking\n * for transport support and creating its connections.\n *\n * Supported hooks: * - file - the name of the file to be fetched during initialization\n * - urls - URL scheme to be used by transport\n * - handlesActivityCheck - true when the transport handles activity checks\n * - supportsPing - true when the transport has a ping/activity API\n * - isSupported - tells whether the transport is supported in the environment\n * - getSocket - creates a WebSocket-compatible transport socket\n *\n * See transports.js for specific implementations.\n *\n * @param {Object} hooks object containing all needed transport hooks\n */\nexport default class Transport {\n hooks: TransportHooks;\n\n constructor(hooks: TransportHooks) {\n this.hooks = hooks;\n }\n\n /** Returns whether the transport is supported in the environment.\n *\n * @param {Object} envronment te environment details (encryption, settings)\n * @returns {Boolean} true when the transport is supported\n */\n isSupported(environment: any): boolean {\n return this.hooks.isSupported(environment);\n }\n\n /** Creates a transport connection.\n *\n * @param {String} name\n * @param {Number} priority\n * @param {String} key the application key\n * @param {Object} options\n * @returns {TransportConnection}\n */\n createConnection(\n name: string,\n priority: number,\n key: string,\n options: any\n ): TransportConnection {\n return new TransportConnection(this.hooks, name, priority, key, options);\n }\n}\n","import * as URLSchemes from 'core/transports/url_schemes';\nimport URLScheme from 'core/transports/url_scheme';\nimport Transport from 'core/transports/transport';\nimport Util from 'core/util';\nimport * as Collections from 'core/utils/collections';\nimport TransportHooks from 'core/transports/transport_hooks';\nimport TransportsTable from 'core/transports/transports_table';\nimport Runtime from 'runtime';\n\n/** WebSocket transport.\n *\n * Uses native WebSocket implementation, including MozWebSocket supported by\n * earlier Firefox versions.\n */\nvar WSTransport = new Transport({\n urls: URLSchemes.ws,\n handlesActivityChecks: false,\n supportsPing: false,\n\n isInitialized: function() {\n return Boolean(Runtime.getWebSocketAPI());\n },\n isSupported: function(): boolean {\n return Boolean(Runtime.getWebSocketAPI());\n },\n getSocket: function(url) {\n return Runtime.createWebSocket(url);\n }\n});\n\nvar httpConfiguration = {\n urls: URLSchemes.http,\n handlesActivityChecks: false,\n supportsPing: true,\n isInitialized: function() {\n return true;\n }\n};\n\nexport var streamingConfiguration = Collections.extend(\n {\n getSocket: function(url) {\n return Runtime.HTTPFactory.createStreamingSocket(url);\n }\n },\n httpConfiguration\n);\nexport var pollingConfiguration = Collections.extend(\n {\n getSocket: function(url) {\n return Runtime.HTTPFactory.createPollingSocket(url);\n }\n },\n httpConfiguration\n);\n\nvar xhrConfiguration = {\n isSupported: function(): boolean {\n return Runtime.isXHRSupported();\n }\n};\n\n/** HTTP streaming transport using CORS-enabled XMLHttpRequest. */\nvar XHRStreamingTransport = new Transport(\n (\n Collections.extend({}, streamingConfiguration, xhrConfiguration)\n )\n);\n\n/** HTTP long-polling transport using CORS-enabled XMLHttpRequest. */\nvar XHRPollingTransport = new Transport(\n Collections.extend({}, pollingConfiguration, xhrConfiguration)\n);\n\nvar Transports: TransportsTable = {\n ws: WSTransport,\n xhr_streaming: XHRStreamingTransport,\n xhr_polling: XHRPollingTransport\n};\n\nexport default Transports;\n","import Util from '../util';\nimport * as Collections from '../utils/collections';\nimport TransportManager from './transport_manager';\nimport TransportConnection from './transport_connection';\nimport Transport from './transport';\nimport PingDelayOptions from './ping_delay_options';\n\n/** Creates transport connections monitored by a transport manager.\n *\n * When a transport is closed, it might mean the environment does not support\n * it. It's possible that messages get stuck in an intermediate buffer or\n * proxies terminate inactive connections. To combat these problems,\n * assistants monitor the connection lifetime, report unclean exits and\n * adjust ping timeouts to keep the connection active. The decision to disable\n * a transport is the manager's responsibility.\n *\n * @param {TransportManager} manager\n * @param {TransportConnection} transport\n * @param {Object} options\n */\nexport default class AssistantToTheTransportManager {\n manager: TransportManager;\n transport: Transport;\n minPingDelay: number;\n maxPingDelay: number;\n pingDelay: number;\n\n constructor(\n manager: TransportManager,\n transport: Transport,\n options: PingDelayOptions\n ) {\n this.manager = manager;\n this.transport = transport;\n this.minPingDelay = options.minPingDelay;\n this.maxPingDelay = options.maxPingDelay;\n this.pingDelay = undefined;\n }\n\n /** Creates a transport connection.\n *\n * This function has the same API as Transport#createConnection.\n *\n * @param {String} name\n * @param {Number} priority\n * @param {String} key the application key\n * @param {Object} options\n * @returns {TransportConnection}\n */\n createConnection(\n name: string,\n priority: number,\n key: string,\n options: Object\n ): TransportConnection {\n options = Collections.extend({}, options, {\n activityTimeout: this.pingDelay\n });\n var connection = this.transport.createConnection(\n name,\n priority,\n key,\n options\n );\n\n var openTimestamp = null;\n\n var onOpen = function() {\n connection.unbind('open', onOpen);\n connection.bind('closed', onClosed);\n openTimestamp = Util.now();\n };\n var onClosed = closeEvent => {\n connection.unbind('closed', onClosed);\n\n if (closeEvent.code === 1002 || closeEvent.code === 1003) {\n // we don't want to use transports not obeying the protocol\n this.manager.reportDeath();\n } else if (!closeEvent.wasClean && openTimestamp) {\n // report deaths only for short-living transport\n var lifespan = Util.now() - openTimestamp;\n if (lifespan < 2 * this.maxPingDelay) {\n this.manager.reportDeath();\n this.pingDelay = Math.max(lifespan / 2, this.minPingDelay);\n }\n }\n };\n\n connection.bind('open', onOpen);\n return connection;\n }\n\n /** Returns whether the transport is supported in the environment.\n *\n * This function has the same API as Transport#isSupported. Might return false\n * when the manager decides to kill the transport.\n *\n * @param {Object} environment the environment details (encryption, settings)\n * @returns {Boolean} true when the transport is supported\n */\n isSupported(environment: string): boolean {\n return this.manager.isAlive() && this.transport.isSupported(environment);\n }\n}\n","import Action from './action';\nimport { PusherEvent } from './message-types';\n/**\n * Provides functions for handling Pusher protocol-specific messages.\n */\n\nconst Protocol = {\n /**\n * Decodes a message in a Pusher format.\n *\n * The MessageEvent we receive from the transport should contain a pusher event\n * (https://pusher.com/docs/pusher_protocol#events) serialized as JSON in the\n * data field\n *\n * The pusher event may contain a data field too, and it may also be\n * serialised as JSON\n *\n * Throws errors when messages are not parse'able.\n *\n * @param {MessageEvent} messageEvent\n * @return {PusherEvent}\n */\n decodeMessage: function(messageEvent: MessageEvent): PusherEvent {\n try {\n var messageData = JSON.parse(messageEvent.data);\n var pusherEventData = messageData.data;\n if (typeof pusherEventData === 'string') {\n try {\n pusherEventData = JSON.parse(messageData.data);\n } catch (e) {}\n }\n var pusherEvent: PusherEvent = {\n event: messageData.event,\n channel: messageData.channel,\n data: pusherEventData\n };\n if (messageData.user_id) {\n pusherEvent.user_id = messageData.user_id;\n }\n return pusherEvent;\n } catch (e) {\n throw { type: 'MessageParseError', error: e, data: messageEvent.data };\n }\n },\n\n /**\n * Encodes a message to be sent.\n *\n * @param {PusherEvent} event\n * @return {String}\n */\n encodeMessage: function(event: PusherEvent): string {\n return JSON.stringify(event);\n },\n\n /**\n * Processes a handshake message and returns appropriate actions.\n *\n * Returns an object with an 'action' and other action-specific properties.\n *\n * There are three outcomes when calling this function. First is a successful\n * connection attempt, when pusher:connection_established is received, which\n * results in a 'connected' action with an 'id' property. When passed a\n * pusher:error event, it returns a result with action appropriate to the\n * close code and an error. Otherwise, it raises an exception.\n *\n * @param {String} message\n * @result Object\n */\n processHandshake: function(messageEvent: MessageEvent): Action {\n var message = Protocol.decodeMessage(messageEvent);\n\n if (message.event === 'pusher:connection_established') {\n if (!message.data.activity_timeout) {\n throw 'No activity timeout specified in handshake';\n }\n return {\n action: 'connected',\n id: message.data.socket_id,\n activityTimeout: message.data.activity_timeout * 1000\n };\n } else if (message.event === 'pusher:error') {\n // From protocol 6 close codes are sent only once, so this only\n // happens when connection does not support close codes\n return {\n action: this.getCloseAction(message.data),\n error: this.getCloseError(message.data)\n };\n } else {\n throw 'Invalid handshake';\n }\n },\n\n /**\n * Dispatches the close event and returns an appropriate action name.\n *\n * See:\n * 1. https://developer.mozilla.org/en-US/docs/WebSockets/WebSockets_reference/CloseEvent\n * 2. http://pusher.com/docs/pusher_protocol\n *\n * @param {CloseEvent} closeEvent\n * @return {String} close action name\n */\n getCloseAction: function(closeEvent): string {\n if (closeEvent.code < 4000) {\n // ignore 1000 CLOSE_NORMAL, 1001 CLOSE_GOING_AWAY,\n // 1005 CLOSE_NO_STATUS, 1006 CLOSE_ABNORMAL\n // ignore 1007...3999\n // handle 1002 CLOSE_PROTOCOL_ERROR, 1003 CLOSE_UNSUPPORTED,\n // 1004 CLOSE_TOO_LARGE\n if (closeEvent.code >= 1002 && closeEvent.code <= 1004) {\n return 'backoff';\n } else {\n return null;\n }\n } else if (closeEvent.code === 4000) {\n return 'tls_only';\n } else if (closeEvent.code < 4100) {\n return 'refused';\n } else if (closeEvent.code < 4200) {\n return 'backoff';\n } else if (closeEvent.code < 4300) {\n return 'retry';\n } else {\n // unknown error\n return 'refused';\n }\n },\n\n /**\n * Returns an error or null basing on the close event.\n *\n * Null is returned when connection was closed cleanly. Otherwise, an object\n * with error details is returned.\n *\n * @param {CloseEvent} closeEvent\n * @return {Object} error object\n */\n getCloseError: function(closeEvent): any {\n if (closeEvent.code !== 1000 && closeEvent.code !== 1001) {\n return {\n type: 'PusherError',\n data: {\n code: closeEvent.code,\n message: closeEvent.reason || closeEvent.message\n }\n };\n } else {\n return null;\n }\n }\n};\n\nexport default Protocol;\n","import * as Collections from '../utils/collections';\nimport { default as EventsDispatcher } from '../events/dispatcher';\nimport Protocol from './protocol/protocol';\nimport { PusherEvent } from './protocol/message-types';\nimport Logger from '../logger';\nimport TransportConnection from '../transports/transport_connection';\nimport Socket from '../socket';\n/**\n * Provides Pusher protocol interface for transports.\n *\n * Emits following events:\n * - message - on received messages\n * - ping - on ping requests\n * - pong - on pong responses\n * - error - when the transport emits an error\n * - closed - after closing the transport\n *\n * It also emits more events when connection closes with a code.\n * See Protocol.getCloseAction to get more details.\n *\n * @param {Number} id\n * @param {AbstractTransport} transport\n */\nexport default class Connection extends EventsDispatcher implements Socket {\n id: string;\n transport: TransportConnection;\n activityTimeout: number;\n\n constructor(id: string, transport: TransportConnection) {\n super();\n this.id = id;\n this.transport = transport;\n this.activityTimeout = transport.activityTimeout;\n this.bindListeners();\n }\n\n /** Returns whether used transport handles activity checks by itself\n *\n * @returns {Boolean} true if activity checks are handled by the transport\n */\n handlesActivityChecks() {\n return this.transport.handlesActivityChecks();\n }\n\n /** Sends raw data.\n *\n * @param {String} data\n */\n send(data: any): boolean {\n return this.transport.send(data);\n }\n\n /** Sends an event.\n *\n * @param {String} name\n * @param {String} data\n * @param {String} [channel]\n * @returns {Boolean} whether message was sent or not\n */\n send_event(name: string, data: any, channel?: string): boolean {\n var event: PusherEvent = { event: name, data: data };\n if (channel) {\n event.channel = channel;\n }\n Logger.debug('Event sent', event);\n return this.send(Protocol.encodeMessage(event));\n }\n\n /** Sends a ping message to the server.\n *\n * Basing on the underlying transport, it might send either transport's\n * protocol-specific ping or pusher:ping event.\n */\n ping() {\n if (this.transport.supportsPing()) {\n this.transport.ping();\n } else {\n this.send_event('pusher:ping', {});\n }\n }\n\n /** Closes the connection. */\n close() {\n this.transport.close();\n }\n\n private bindListeners() {\n var listeners = {\n message: (messageEvent: MessageEvent) => {\n var pusherEvent;\n try {\n pusherEvent = Protocol.decodeMessage(messageEvent);\n } catch (e) {\n this.emit('error', {\n type: 'MessageParseError',\n error: e,\n data: messageEvent.data\n });\n }\n\n if (pusherEvent !== undefined) {\n Logger.debug('Event recd', pusherEvent);\n\n switch (pusherEvent.event) {\n case 'pusher:error':\n this.emit('error', {\n type: 'PusherError',\n data: pusherEvent.data\n });\n break;\n case 'pusher:ping':\n this.emit('ping');\n break;\n case 'pusher:pong':\n this.emit('pong');\n break;\n }\n this.emit('message', pusherEvent);\n }\n },\n activity: () => {\n this.emit('activity');\n },\n error: error => {\n this.emit('error', error);\n },\n closed: closeEvent => {\n unbindListeners();\n\n if (closeEvent && closeEvent.code) {\n this.handleCloseEvent(closeEvent);\n }\n\n this.transport = null;\n this.emit('closed');\n }\n };\n\n var unbindListeners = () => {\n Collections.objectApply(listeners, (listener, event) => {\n this.transport.unbind(event, listener);\n });\n };\n\n Collections.objectApply(listeners, (listener, event) => {\n this.transport.bind(event, listener);\n });\n }\n\n private handleCloseEvent(closeEvent: any) {\n var action = Protocol.getCloseAction(closeEvent);\n var error = Protocol.getCloseError(closeEvent);\n if (error) {\n this.emit('error', error);\n }\n if (action) {\n this.emit(action, { action: action, error: error });\n }\n }\n}\n","import Util from '../../util';\nimport * as Collections from '../../utils/collections';\nimport Protocol from '../protocol/protocol';\nimport Connection from '../connection';\nimport TransportConnection from '../../transports/transport_connection';\nimport HandshakePayload from './handshake_payload';\n\n/**\n * Handles Pusher protocol handshakes for transports.\n *\n * Calls back with a result object after handshake is completed. Results\n * always have two fields:\n * - action - string describing action to be taken after the handshake\n * - transport - the transport object passed to the constructor\n *\n * Different actions can set different additional properties on the result.\n * In the case of 'connected' action, there will be a 'connection' property\n * containing a Connection object for the transport. Other actions should\n * carry an 'error' property.\n *\n * @param {AbstractTransport} transport\n * @param {Function} callback\n */\nexport default class Handshake {\n transport: TransportConnection;\n callback: (HandshakePayload) => void;\n onMessage: Function;\n onClosed: Function;\n\n constructor(\n transport: TransportConnection,\n callback: (HandshakePayload) => void\n ) {\n this.transport = transport;\n this.callback = callback;\n this.bindListeners();\n }\n\n close() {\n this.unbindListeners();\n this.transport.close();\n }\n\n private bindListeners() {\n this.onMessage = m => {\n this.unbindListeners();\n\n var result;\n try {\n result = Protocol.processHandshake(m);\n } catch (e) {\n this.finish('error', { error: e });\n this.transport.close();\n return;\n }\n\n if (result.action === 'connected') {\n this.finish('connected', {\n connection: new Connection(result.id, this.transport),\n activityTimeout: result.activityTimeout\n });\n } else {\n this.finish(result.action, { error: result.error });\n this.transport.close();\n }\n };\n\n this.onClosed = closeEvent => {\n this.unbindListeners();\n\n var action = Protocol.getCloseAction(closeEvent) || 'backoff';\n var error = Protocol.getCloseError(closeEvent);\n this.finish(action, { error: error });\n };\n\n this.transport.bind('message', this.onMessage);\n this.transport.bind('closed', this.onClosed);\n }\n\n private unbindListeners() {\n this.transport.unbind('message', this.onMessage);\n this.transport.unbind('closed', this.onClosed);\n }\n\n private finish(action: string, params: any) {\n this.callback(\n Collections.extend({ transport: this.transport, action: action }, params)\n );\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport base64encode from '../base64';\nimport Timeline from './timeline';\nimport Runtime from 'runtime';\n\nexport interface TimelineSenderOptions {\n host?: string;\n port?: number;\n path?: string;\n}\n\nexport default class TimelineSender {\n timeline: Timeline;\n options: TimelineSenderOptions;\n host: string;\n\n constructor(timeline: Timeline, options: TimelineSenderOptions) {\n this.timeline = timeline;\n this.options = options || {};\n }\n\n send(useTLS: boolean, callback?: Function) {\n if (this.timeline.isEmpty()) {\n return;\n }\n\n this.timeline.send(\n Runtime.TimelineTransport.getAgent(this, useTLS),\n callback\n );\n }\n}\n","/** Error classes used throughout the library. */\n// https://github.com/Microsoft/TypeScript-wiki/blob/master/Breaking-Changes.md#extending-built-ins-like-error-array-and-map-may-no-longer-work\nexport class BadEventName extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\nexport class BadChannelName extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\nexport class RequestTimedOut extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class TransportPriorityTooLow extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class TransportClosed extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class UnsupportedFeature extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class UnsupportedTransport extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class UnsupportedStrategy extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class HTTPAuthError extends Error {\n status: number;\n constructor(status: number, msg?: string) {\n super(msg);\n this.status = status;\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n","/**\n * A place to store help URLs for error messages etc\n */\n\nconst urlStore = {\n baseUrl: 'https://pusher.com',\n urls: {\n authenticationEndpoint: {\n path: '/docs/channels/server_api/authenticating_users'\n },\n authorizationEndpoint: {\n path: '/docs/channels/server_api/authorizing-users/'\n },\n javascriptQuickStart: {\n path: '/docs/javascript_quick_start'\n },\n triggeringClientEvents: {\n path: '/docs/client_api_guide/client_events#trigger-events'\n },\n encryptedChannelSupport: {\n fullUrl:\n 'https://github.com/pusher/pusher-js/tree/cc491015371a4bde5743d1c87a0fbac0feb53195#encrypted-channel-support'\n }\n }\n};\n\n/** Builds a consistent string with links to pusher documentation\n *\n * @param {string} key - relevant key in the url_store.urls object\n * @return {string} suffix string to append to log message\n */\nconst buildLogSuffix = function(key: string): string {\n const urlPrefix = 'See:';\n const urlObj = urlStore.urls[key];\n if (!urlObj) return '';\n\n let url;\n if (urlObj.fullUrl) {\n url = urlObj.fullUrl;\n } else if (urlObj.path) {\n url = urlStore.baseUrl + urlObj.path;\n }\n\n if (!url) return '';\n return `${urlPrefix} ${url}`;\n};\n\nexport default { buildLogSuffix };\n","import { default as EventsDispatcher } from '../events/dispatcher';\nimport * as Errors from '../errors';\nimport Logger from '../logger';\nimport Pusher from '../pusher';\nimport { PusherEvent } from '../connection/protocol/message-types';\nimport Metadata from './metadata';\nimport UrlStore from '../utils/url_store';\nimport {\n ChannelAuthorizationData,\n ChannelAuthorizationCallback\n} from '../auth/options';\nimport { HTTPAuthError } from '../errors';\n\n/** Provides base public channel interface with an event emitter.\n *\n * Emits:\n * - pusher:subscription_succeeded - after subscribing successfully\n * - other non-internal events\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\nexport default class Channel extends EventsDispatcher {\n name: string;\n pusher: Pusher;\n subscribed: boolean;\n subscriptionPending: boolean;\n subscriptionCancelled: boolean;\n subscriptionCount: null;\n\n constructor(name: string, pusher: Pusher) {\n super(function(event, data) {\n Logger.debug('No callbacks on ' + name + ' for ' + event);\n });\n\n this.name = name;\n this.pusher = pusher;\n this.subscribed = false;\n this.subscriptionPending = false;\n this.subscriptionCancelled = false;\n }\n\n /** Skips authorization, since public channels don't require it.\n *\n * @param {Function} callback\n */\n authorize(socketId: string, callback: ChannelAuthorizationCallback) {\n return callback(null, { auth: '' });\n }\n\n /** Triggers an event */\n trigger(event: string, data: any) {\n if (event.indexOf('client-') !== 0) {\n throw new Errors.BadEventName(\n \"Event '\" + event + \"' does not start with 'client-'\"\n );\n }\n if (!this.subscribed) {\n var suffix = UrlStore.buildLogSuffix('triggeringClientEvents');\n Logger.warn(\n `Client event triggered before channel 'subscription_succeeded' event . ${suffix}`\n );\n }\n return this.pusher.send_event(event, data, this.name);\n }\n\n /** Signals disconnection to the channel. For internal use only. */\n disconnect() {\n this.subscribed = false;\n this.subscriptionPending = false;\n }\n\n /** Handles a PusherEvent. For internal use only.\n *\n * @param {PusherEvent} event\n */\n handleEvent(event: PusherEvent) {\n var eventName = event.event;\n var data = event.data;\n if (eventName === 'pusher_internal:subscription_succeeded') {\n this.handleSubscriptionSucceededEvent(event);\n } else if (eventName === 'pusher_internal:subscription_count') {\n this.handleSubscriptionCountEvent(event);\n } else if (eventName.indexOf('pusher_internal:') !== 0) {\n var metadata: Metadata = {};\n this.emit(eventName, data, metadata);\n }\n }\n\n handleSubscriptionSucceededEvent(event: PusherEvent) {\n this.subscriptionPending = false;\n this.subscribed = true;\n if (this.subscriptionCancelled) {\n this.pusher.unsubscribe(this.name);\n } else {\n this.emit('pusher:subscription_succeeded', event.data);\n }\n }\n\n handleSubscriptionCountEvent(event: PusherEvent) {\n if (event.data.subscription_count) {\n this.subscriptionCount = event.data.subscription_count;\n }\n\n this.emit('pusher:subscription_count', event.data);\n }\n\n /** Sends a subscription request. For internal use only. */\n subscribe() {\n if (this.subscribed) {\n return;\n }\n this.subscriptionPending = true;\n this.subscriptionCancelled = false;\n this.authorize(\n this.pusher.connection.socket_id,\n (error: Error | null, data: ChannelAuthorizationData) => {\n if (error) {\n this.subscriptionPending = false;\n // Why not bind to 'pusher:subscription_error' a level up, and log there?\n // Binding to this event would cause the warning about no callbacks being\n // bound (see constructor) to be suppressed, that's not what we want.\n Logger.error(error.toString());\n this.emit(\n 'pusher:subscription_error',\n Object.assign(\n {},\n {\n type: 'AuthError',\n error: error.message\n },\n error instanceof HTTPAuthError ? { status: error.status } : {}\n )\n );\n } else {\n this.pusher.send_event('pusher:subscribe', {\n auth: data.auth,\n channel_data: data.channel_data,\n channel: this.name\n });\n }\n }\n );\n }\n\n /** Sends an unsubscription request. For internal use only. */\n unsubscribe() {\n this.subscribed = false;\n this.pusher.send_event('pusher:unsubscribe', {\n channel: this.name\n });\n }\n\n /** Cancels an in progress subscription. For internal use only. */\n cancelSubscription() {\n this.subscriptionCancelled = true;\n }\n\n /** Reinstates an in progress subscripiton. For internal use only. */\n reinstateSubscription() {\n this.subscriptionCancelled = false;\n }\n}\n","import Factory from '../utils/factory';\nimport Channel from './channel';\nimport { ChannelAuthorizationCallback } from '../auth/options';\n\n/** Extends public channels to provide private channel interface.\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\nexport default class PrivateChannel extends Channel {\n /** Authorizes the connection to use the channel.\n *\n * @param {String} socketId\n * @param {Function} callback\n */\n authorize(socketId: string, callback: ChannelAuthorizationCallback) {\n return this.pusher.config.channelAuthorizer(\n {\n channelName: this.name,\n socketId: socketId\n },\n callback\n );\n }\n}\n","import * as Collections from '../utils/collections';\n\n/** Represents a collection of members of a presence channel. */\nexport default class Members {\n members: any;\n count: number;\n myID: any;\n me: any;\n\n constructor() {\n this.reset();\n }\n\n /** Returns member's info for given id.\n *\n * Resulting object containts two fields - id and info.\n *\n * @param {Number} id\n * @return {Object} member's info or null\n */\n get(id: string): any {\n if (Object.prototype.hasOwnProperty.call(this.members, id)) {\n return {\n id: id,\n info: this.members[id]\n };\n } else {\n return null;\n }\n }\n\n /** Calls back for each member in unspecified order.\n *\n * @param {Function} callback\n */\n each(callback: Function) {\n Collections.objectApply(this.members, (member, id) => {\n callback(this.get(id));\n });\n }\n\n /** Updates the id for connected member. For internal use only. */\n setMyID(id: string) {\n this.myID = id;\n }\n\n /** Handles subscription data. For internal use only. */\n onSubscription(subscriptionData: any) {\n this.members = subscriptionData.presence.hash;\n this.count = subscriptionData.presence.count;\n this.me = this.get(this.myID);\n }\n\n /** Adds a new member to the collection. For internal use only. */\n addMember(memberData: any) {\n if (this.get(memberData.user_id) === null) {\n this.count++;\n }\n this.members[memberData.user_id] = memberData.user_info;\n return this.get(memberData.user_id);\n }\n\n /** Adds a member from the collection. For internal use only. */\n removeMember(memberData: any) {\n var member = this.get(memberData.user_id);\n if (member) {\n delete this.members[memberData.user_id];\n this.count--;\n }\n return member;\n }\n\n /** Resets the collection to the initial state. For internal use only. */\n reset() {\n this.members = {};\n this.count = 0;\n this.myID = null;\n this.me = null;\n }\n}\n","import PrivateChannel from './private_channel';\nimport Logger from '../logger';\nimport Members from './members';\nimport Pusher from '../pusher';\nimport UrlStore from 'core/utils/url_store';\nimport { PusherEvent } from '../connection/protocol/message-types';\nimport Metadata from './metadata';\nimport { ChannelAuthorizationData } from '../auth/options';\n\nexport default class PresenceChannel extends PrivateChannel {\n members: Members;\n\n /** Adds presence channel functionality to private channels.\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\n constructor(name: string, pusher: Pusher) {\n super(name, pusher);\n this.members = new Members();\n }\n\n /** Authorizes the connection as a member of the channel.\n *\n * @param {String} socketId\n * @param {Function} callback\n */\n authorize(socketId: string, callback: Function) {\n super.authorize(socketId, async (error, authData) => {\n if (!error) {\n authData = authData as ChannelAuthorizationData;\n if (authData.channel_data != null) {\n var channelData = JSON.parse(authData.channel_data);\n this.members.setMyID(channelData.user_id);\n } else {\n await this.pusher.user.signinDonePromise;\n if (this.pusher.user.user_data != null) {\n // If the user is signed in, get the id of the authenticated user\n // and allow the presence authorization to continue.\n this.members.setMyID(this.pusher.user.user_data.id);\n } else {\n let suffix = UrlStore.buildLogSuffix('authorizationEndpoint');\n Logger.error(\n `Invalid auth response for channel '${this.name}', ` +\n `expected 'channel_data' field. ${suffix}, ` +\n `or the user should be signed in.`\n );\n callback('Invalid auth response');\n return;\n }\n }\n }\n callback(error, authData);\n });\n }\n\n /** Handles presence and subscription events. For internal use only.\n *\n * @param {PusherEvent} event\n */\n handleEvent(event: PusherEvent) {\n var eventName = event.event;\n if (eventName.indexOf('pusher_internal:') === 0) {\n this.handleInternalEvent(event);\n } else {\n var data = event.data;\n var metadata: Metadata = {};\n if (event.user_id) {\n metadata.user_id = event.user_id;\n }\n this.emit(eventName, data, metadata);\n }\n }\n handleInternalEvent(event: PusherEvent) {\n var eventName = event.event;\n var data = event.data;\n switch (eventName) {\n case 'pusher_internal:subscription_succeeded':\n this.handleSubscriptionSucceededEvent(event);\n break;\n case 'pusher_internal:subscription_count':\n this.handleSubscriptionCountEvent(event);\n break;\n case 'pusher_internal:member_added':\n var addedMember = this.members.addMember(data);\n this.emit('pusher:member_added', addedMember);\n break;\n case 'pusher_internal:member_removed':\n var removedMember = this.members.removeMember(data);\n if (removedMember) {\n this.emit('pusher:member_removed', removedMember);\n }\n break;\n }\n }\n\n handleSubscriptionSucceededEvent(event: PusherEvent) {\n this.subscriptionPending = false;\n this.subscribed = true;\n if (this.subscriptionCancelled) {\n this.pusher.unsubscribe(this.name);\n } else {\n this.members.onSubscription(event.data);\n this.emit('pusher:subscription_succeeded', this.members);\n }\n }\n\n /** Resets the channel state, including members map. For internal use only. */\n disconnect() {\n this.members.reset();\n super.disconnect();\n }\n}\n","import PrivateChannel from './private_channel';\nimport * as Errors from '../errors';\nimport Logger from '../logger';\nimport Pusher from '../pusher';\nimport { decode as encodeUTF8 } from '@stablelib/utf8';\nimport { decode as decodeBase64 } from '@stablelib/base64';\nimport Dispatcher from '../events/dispatcher';\nimport { PusherEvent } from '../connection/protocol/message-types';\nimport {\n ChannelAuthorizationData,\n ChannelAuthorizationCallback\n} from '../auth/options';\nimport * as nacl from 'tweetnacl';\n\n/** Extends private channels to provide encrypted channel interface.\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\nexport default class EncryptedChannel extends PrivateChannel {\n key: Uint8Array = null;\n nacl: nacl;\n\n constructor(name: string, pusher: Pusher, nacl: nacl) {\n super(name, pusher);\n this.nacl = nacl;\n }\n\n /** Authorizes the connection to use the channel.\n *\n * @param {String} socketId\n * @param {Function} callback\n */\n authorize(socketId: string, callback: ChannelAuthorizationCallback) {\n super.authorize(\n socketId,\n (error: Error | null, authData: ChannelAuthorizationData) => {\n if (error) {\n callback(error, authData);\n return;\n }\n let sharedSecret = authData['shared_secret'];\n if (!sharedSecret) {\n callback(\n new Error(\n `No shared_secret key in auth payload for encrypted channel: ${this.name}`\n ),\n null\n );\n return;\n }\n this.key = decodeBase64(sharedSecret);\n delete authData['shared_secret'];\n callback(null, authData);\n }\n );\n }\n\n trigger(event: string, data: any): boolean {\n throw new Errors.UnsupportedFeature(\n 'Client events are not currently supported for encrypted channels'\n );\n }\n\n /** Handles an event. For internal use only.\n *\n * @param {PusherEvent} event\n */\n handleEvent(event: PusherEvent) {\n var eventName = event.event;\n var data = event.data;\n if (\n eventName.indexOf('pusher_internal:') === 0 ||\n eventName.indexOf('pusher:') === 0\n ) {\n super.handleEvent(event);\n return;\n }\n this.handleEncryptedEvent(eventName, data);\n }\n\n private handleEncryptedEvent(event: string, data: any): void {\n if (!this.key) {\n Logger.debug(\n 'Received encrypted event before key has been retrieved from the authEndpoint'\n );\n return;\n }\n if (!data.ciphertext || !data.nonce) {\n Logger.error(\n 'Unexpected format for encrypted event, expected object with `ciphertext` and `nonce` fields, got: ' +\n data\n );\n return;\n }\n let cipherText = decodeBase64(data.ciphertext);\n if (cipherText.length < this.nacl.secretbox.overheadLength) {\n Logger.error(\n `Expected encrypted event ciphertext length to be ${this.nacl.secretbox.overheadLength}, got: ${cipherText.length}`\n );\n return;\n }\n let nonce = decodeBase64(data.nonce);\n if (nonce.length < this.nacl.secretbox.nonceLength) {\n Logger.error(\n `Expected encrypted event nonce length to be ${this.nacl.secretbox.nonceLength}, got: ${nonce.length}`\n );\n return;\n }\n\n let bytes = this.nacl.secretbox.open(cipherText, nonce, this.key);\n if (bytes === null) {\n Logger.debug(\n 'Failed to decrypt an event, probably because it was encrypted with a different key. Fetching a new key from the authEndpoint...'\n );\n // Try a single time to retrieve a new auth key and decrypt the event with it\n // If this fails, a new key will be requested when a new message is received\n this.authorize(this.pusher.connection.socket_id, (error, authData) => {\n if (error) {\n Logger.error(\n `Failed to make a request to the authEndpoint: ${authData}. Unable to fetch new key, so dropping encrypted event`\n );\n return;\n }\n bytes = this.nacl.secretbox.open(cipherText, nonce, this.key);\n if (bytes === null) {\n Logger.error(\n `Failed to decrypt event with new key. Dropping encrypted event`\n );\n return;\n }\n this.emit(event, this.getDataToEmit(bytes));\n return;\n });\n return;\n }\n this.emit(event, this.getDataToEmit(bytes));\n }\n\n // Try and parse the decrypted bytes as JSON. If we can't parse it, just\n // return the utf-8 string\n getDataToEmit(bytes: Uint8Array): string {\n let raw = encodeUTF8(bytes);\n try {\n return JSON.parse(raw);\n } catch {\n return raw;\n }\n }\n}\n","import { default as EventsDispatcher } from '../events/dispatcher';\nimport { OneOffTimer as Timer } from '../utils/timers';\nimport { Config } from '../config';\nimport Logger from '../logger';\nimport HandshakePayload from './handshake/handshake_payload';\nimport Connection from './connection';\nimport Strategy from '../strategies/strategy';\nimport StrategyRunner from '../strategies/strategy_runner';\nimport * as Collections from '../utils/collections';\nimport Timeline from '../timeline/timeline';\nimport ConnectionManagerOptions from './connection_manager_options';\nimport Runtime from 'runtime';\n\nimport {\n ErrorCallbacks,\n HandshakeCallbacks,\n ConnectionCallbacks\n} from './callbacks';\nimport Action from './protocol/action';\n\n/** Manages connection to Pusher.\n *\n * Uses a strategy (currently only default), timers and network availability\n * info to establish a connection and export its state. In case of failures,\n * manages reconnection attempts.\n *\n * Exports state changes as following events:\n * - \"state_change\", { previous: p, current: state }\n * - state\n *\n * States:\n * - initialized - initial state, never transitioned to\n * - connecting - connection is being established\n * - connected - connection has been fully established\n * - disconnected - on requested disconnection\n * - unavailable - after connection timeout or when there's no network\n * - failed - when the connection strategy is not supported\n *\n * Options:\n * - unavailableTimeout - time to transition to unavailable state\n * - activityTimeout - time after which ping message should be sent\n * - pongTimeout - time for Pusher to respond with pong before reconnecting\n *\n * @param {String} key application key\n * @param {Object} options\n */\nexport default class ConnectionManager extends EventsDispatcher {\n key: string;\n options: ConnectionManagerOptions;\n state: string;\n connection: Connection;\n usingTLS: boolean;\n timeline: Timeline;\n socket_id: string;\n unavailableTimer: Timer;\n activityTimer: Timer;\n retryTimer: Timer;\n activityTimeout: number;\n strategy: Strategy;\n runner: StrategyRunner;\n errorCallbacks: ErrorCallbacks;\n handshakeCallbacks: HandshakeCallbacks;\n connectionCallbacks: ConnectionCallbacks;\n\n constructor(key: string, options: ConnectionManagerOptions) {\n super();\n this.state = 'initialized';\n this.connection = null;\n\n this.key = key;\n this.options = options;\n this.timeline = this.options.timeline;\n this.usingTLS = this.options.useTLS;\n\n this.errorCallbacks = this.buildErrorCallbacks();\n this.connectionCallbacks = this.buildConnectionCallbacks(\n this.errorCallbacks\n );\n this.handshakeCallbacks = this.buildHandshakeCallbacks(this.errorCallbacks);\n\n var Network = Runtime.getNetwork();\n\n Network.bind('online', () => {\n this.timeline.info({ netinfo: 'online' });\n if (this.state === 'connecting' || this.state === 'unavailable') {\n this.retryIn(0);\n }\n });\n Network.bind('offline', () => {\n this.timeline.info({ netinfo: 'offline' });\n if (this.connection) {\n this.sendActivityCheck();\n }\n });\n\n this.updateStrategy();\n }\n\n switchCluster(key: string) {\n this.key = key;\n // This ensures that the new config coming from\n // pusher instance are taken into account\n // such as appKey and cluster\n this.updateStrategy();\n this.retryIn(0);\n }\n\n /** Establishes a connection to Pusher.\n *\n * Does nothing when connection is already established. See top-level doc\n * to find events emitted on connection attempts.\n */\n connect() {\n if (this.connection || this.runner) {\n return;\n }\n if (!this.strategy.isSupported()) {\n this.updateState('failed');\n return;\n }\n this.updateState('connecting');\n this.startConnecting();\n this.setUnavailableTimer();\n }\n\n /** Sends raw data.\n *\n * @param {String} data\n */\n send(data) {\n if (this.connection) {\n return this.connection.send(data);\n } else {\n return false;\n }\n }\n\n /** Sends an event.\n *\n * @param {String} name\n * @param {String} data\n * @param {String} [channel]\n * @returns {Boolean} whether message was sent or not\n */\n send_event(name: string, data: any, channel?: string) {\n if (this.connection) {\n return this.connection.send_event(name, data, channel);\n } else {\n return false;\n }\n }\n\n /** Closes the connection. */\n disconnect() {\n this.disconnectInternally();\n this.updateState('disconnected');\n }\n\n isUsingTLS() {\n return this.usingTLS;\n }\n\n private startConnecting() {\n var callback = (error, handshake) => {\n if (error) {\n this.runner = this.strategy.connect(0, callback);\n } else {\n if (handshake.action === 'error') {\n this.emit('error', {\n type: 'HandshakeError',\n error: handshake.error\n });\n this.timeline.error({ handshakeError: handshake.error });\n } else {\n this.abortConnecting(); // we don't support switching connections yet\n this.handshakeCallbacks[handshake.action](handshake);\n }\n }\n };\n this.runner = this.strategy.connect(0, callback);\n }\n\n private abortConnecting() {\n if (this.runner) {\n this.runner.abort();\n this.runner = null;\n }\n }\n\n private disconnectInternally() {\n this.abortConnecting();\n this.clearRetryTimer();\n this.clearUnavailableTimer();\n if (this.connection) {\n var connection = this.abandonConnection();\n connection.close();\n }\n }\n\n private updateStrategy() {\n this.strategy = this.options.getStrategy({\n key: this.key,\n timeline: this.timeline,\n useTLS: this.usingTLS\n });\n }\n\n private retryIn(delay) {\n this.timeline.info({ action: 'retry', delay: delay });\n if (delay > 0) {\n this.emit('connecting_in', Math.round(delay / 1000));\n }\n this.retryTimer = new Timer(delay || 0, () => {\n this.disconnectInternally();\n this.connect();\n });\n }\n\n private clearRetryTimer() {\n if (this.retryTimer) {\n this.retryTimer.ensureAborted();\n this.retryTimer = null;\n }\n }\n\n private setUnavailableTimer() {\n this.unavailableTimer = new Timer(this.options.unavailableTimeout, () => {\n this.updateState('unavailable');\n });\n }\n\n private clearUnavailableTimer() {\n if (this.unavailableTimer) {\n this.unavailableTimer.ensureAborted();\n }\n }\n\n private sendActivityCheck() {\n this.stopActivityCheck();\n this.connection.ping();\n // wait for pong response\n this.activityTimer = new Timer(this.options.pongTimeout, () => {\n this.timeline.error({ pong_timed_out: this.options.pongTimeout });\n this.retryIn(0);\n });\n }\n\n private resetActivityCheck() {\n this.stopActivityCheck();\n // send ping after inactivity\n if (this.connection && !this.connection.handlesActivityChecks()) {\n this.activityTimer = new Timer(this.activityTimeout, () => {\n this.sendActivityCheck();\n });\n }\n }\n\n private stopActivityCheck() {\n if (this.activityTimer) {\n this.activityTimer.ensureAborted();\n }\n }\n\n private buildConnectionCallbacks(\n errorCallbacks: ErrorCallbacks\n ): ConnectionCallbacks {\n return Collections.extend({}, errorCallbacks, {\n message: message => {\n // includes pong messages from server\n this.resetActivityCheck();\n this.emit('message', message);\n },\n ping: () => {\n this.send_event('pusher:pong', {});\n },\n activity: () => {\n this.resetActivityCheck();\n },\n error: error => {\n // just emit error to user - socket will already be closed by browser\n this.emit('error', error);\n },\n closed: () => {\n this.abandonConnection();\n if (this.shouldRetry()) {\n this.retryIn(1000);\n }\n }\n });\n }\n\n private buildHandshakeCallbacks(\n errorCallbacks: ErrorCallbacks\n ): HandshakeCallbacks {\n return Collections.extend({}, errorCallbacks, {\n connected: (handshake: HandshakePayload) => {\n this.activityTimeout = Math.min(\n this.options.activityTimeout,\n handshake.activityTimeout,\n handshake.connection.activityTimeout || Infinity\n );\n this.clearUnavailableTimer();\n this.setConnection(handshake.connection);\n this.socket_id = this.connection.id;\n this.updateState('connected', { socket_id: this.socket_id });\n }\n });\n }\n\n private buildErrorCallbacks(): ErrorCallbacks {\n let withErrorEmitted = callback => {\n return (result: Action | HandshakePayload) => {\n if (result.error) {\n this.emit('error', { type: 'WebSocketError', error: result.error });\n }\n callback(result);\n };\n };\n\n return {\n tls_only: withErrorEmitted(() => {\n this.usingTLS = true;\n this.updateStrategy();\n this.retryIn(0);\n }),\n refused: withErrorEmitted(() => {\n this.disconnect();\n }),\n backoff: withErrorEmitted(() => {\n this.retryIn(1000);\n }),\n retry: withErrorEmitted(() => {\n this.retryIn(0);\n })\n };\n }\n\n private setConnection(connection) {\n this.connection = connection;\n for (var event in this.connectionCallbacks) {\n this.connection.bind(event, this.connectionCallbacks[event]);\n }\n this.resetActivityCheck();\n }\n\n private abandonConnection() {\n if (!this.connection) {\n return;\n }\n this.stopActivityCheck();\n for (var event in this.connectionCallbacks) {\n this.connection.unbind(event, this.connectionCallbacks[event]);\n }\n var connection = this.connection;\n this.connection = null;\n return connection;\n }\n\n private updateState(newState: string, data?: any) {\n var previousState = this.state;\n this.state = newState;\n if (previousState !== newState) {\n var newStateDescription = newState;\n if (newStateDescription === 'connected') {\n newStateDescription += ' with new socket ID ' + data.socket_id;\n }\n Logger.debug(\n 'State changed',\n previousState + ' -> ' + newStateDescription\n );\n this.timeline.info({ state: newState, params: data });\n this.emit('state_change', { previous: previousState, current: newState });\n this.emit(newState, data);\n }\n }\n\n private shouldRetry(): boolean {\n return this.state === 'connecting' || this.state === 'connected';\n }\n}\n","import Channel from './channel';\nimport * as Collections from '../utils/collections';\nimport ChannelTable from './channel_table';\nimport Factory from '../utils/factory';\nimport Pusher from '../pusher';\nimport Logger from '../logger';\nimport * as Errors from '../errors';\nimport urlStore from '../utils/url_store';\n\n/** Handles a channel map. */\nexport default class Channels {\n channels: ChannelTable;\n\n constructor() {\n this.channels = {};\n }\n\n /** Creates or retrieves an existing channel by its name.\n *\n * @param {String} name\n * @param {Pusher} pusher\n * @return {Channel}\n */\n add(name: string, pusher: Pusher) {\n if (!this.channels[name]) {\n this.channels[name] = createChannel(name, pusher);\n }\n return this.channels[name];\n }\n\n /** Returns a list of all channels\n *\n * @return {Array}\n */\n all(): Channel[] {\n return Collections.values(this.channels);\n }\n\n /** Finds a channel by its name.\n *\n * @param {String} name\n * @return {Channel} channel or null if it doesn't exist\n */\n find(name: string) {\n return this.channels[name];\n }\n\n /** Removes a channel from the map.\n *\n * @param {String} name\n */\n remove(name: string) {\n var channel = this.channels[name];\n delete this.channels[name];\n return channel;\n }\n\n /** Proxies disconnection signal to all channels. */\n disconnect() {\n Collections.objectApply(this.channels, function(channel) {\n channel.disconnect();\n });\n }\n}\n\nfunction createChannel(name: string, pusher: Pusher): Channel {\n if (name.indexOf('private-encrypted-') === 0) {\n if (pusher.config.nacl) {\n return Factory.createEncryptedChannel(name, pusher, pusher.config.nacl);\n }\n let errMsg =\n 'Tried to subscribe to a private-encrypted- channel but no nacl implementation available';\n let suffix = urlStore.buildLogSuffix('encryptedChannelSupport');\n throw new Errors.UnsupportedFeature(`${errMsg}. ${suffix}`);\n } else if (name.indexOf('private-') === 0) {\n return Factory.createPrivateChannel(name, pusher);\n } else if (name.indexOf('presence-') === 0) {\n return Factory.createPresenceChannel(name, pusher);\n } else if (name.indexOf('#') === 0) {\n throw new Errors.BadChannelName(\n 'Cannot create a channel with name \"' + name + '\".'\n );\n } else {\n return Factory.createChannel(name, pusher);\n }\n}\n","import AssistantToTheTransportManager from '../transports/assistant_to_the_transport_manager';\nimport PingDelayOptions from '../transports/ping_delay_options';\nimport Transport from '../transports/transport';\nimport TransportManager from '../transports/transport_manager';\nimport Handshake from '../connection/handshake';\nimport TransportConnection from '../transports/transport_connection';\nimport SocketHooks from '../http/socket_hooks';\nimport HTTPSocket from '../http/http_socket';\n\nimport Timeline from '../timeline/timeline';\nimport {\n default as TimelineSender,\n TimelineSenderOptions\n} from '../timeline/timeline_sender';\nimport PresenceChannel from '../channels/presence_channel';\nimport PrivateChannel from '../channels/private_channel';\nimport EncryptedChannel from '../channels/encrypted_channel';\nimport Channel from '../channels/channel';\nimport ConnectionManager from '../connection/connection_manager';\nimport ConnectionManagerOptions from '../connection/connection_manager_options';\nimport Ajax from '../http/ajax';\nimport Channels from '../channels/channels';\nimport Pusher from '../pusher';\nimport { Config } from '../config';\nimport * as nacl from 'tweetnacl';\n\nvar Factory = {\n createChannels(): Channels {\n return new Channels();\n },\n\n createConnectionManager(\n key: string,\n options: ConnectionManagerOptions\n ): ConnectionManager {\n return new ConnectionManager(key, options);\n },\n\n createChannel(name: string, pusher: Pusher): Channel {\n return new Channel(name, pusher);\n },\n\n createPrivateChannel(name: string, pusher: Pusher): PrivateChannel {\n return new PrivateChannel(name, pusher);\n },\n\n createPresenceChannel(name: string, pusher: Pusher): PresenceChannel {\n return new PresenceChannel(name, pusher);\n },\n\n createEncryptedChannel(\n name: string,\n pusher: Pusher,\n nacl: nacl\n ): EncryptedChannel {\n return new EncryptedChannel(name, pusher, nacl);\n },\n\n createTimelineSender(timeline: Timeline, options: TimelineSenderOptions) {\n return new TimelineSender(timeline, options);\n },\n\n createHandshake(\n transport: TransportConnection,\n callback: (HandshakePayload) => void\n ): Handshake {\n return new Handshake(transport, callback);\n },\n\n createAssistantToTheTransportManager(\n manager: TransportManager,\n transport: Transport,\n options: PingDelayOptions\n ): AssistantToTheTransportManager {\n return new AssistantToTheTransportManager(manager, transport, options);\n }\n};\n\nexport default Factory;\n","import AssistantToTheTransportManager from './assistant_to_the_transport_manager';\nimport Transport from './transport';\nimport PingDelayOptions from './ping_delay_options';\nimport Factory from '../utils/factory';\n\nexport interface TransportManagerOptions extends PingDelayOptions {\n lives?: number;\n}\n\n/** Keeps track of the number of lives left for a transport.\n *\n * In the beginning of a session, transports may be assigned a number of\n * lives. When an AssistantToTheTransportManager instance reports a transport\n * connection closed uncleanly, the transport loses a life. When the number\n * of lives drops to zero, the transport gets disabled by its manager.\n *\n * @param {Object} options\n */\nexport default class TransportManager {\n options: TransportManagerOptions;\n livesLeft: number;\n\n constructor(options: TransportManagerOptions) {\n this.options = options || {};\n this.livesLeft = this.options.lives || Infinity;\n }\n\n /** Creates a assistant for the transport.\n *\n * @param {Transport} transport\n * @returns {AssistantToTheTransportManager}\n */\n getAssistant(transport: Transport): AssistantToTheTransportManager {\n return Factory.createAssistantToTheTransportManager(this, transport, {\n minPingDelay: this.options.minPingDelay,\n maxPingDelay: this.options.maxPingDelay\n });\n }\n\n /** Returns whether the transport has any lives left.\n *\n * @returns {Boolean}\n */\n isAlive(): boolean {\n return this.livesLeft > 0;\n }\n\n /** Takes one life from the transport. */\n reportDeath() {\n this.livesLeft -= 1;\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport { OneOffTimer as Timer } from '../utils/timers';\nimport Strategy from './strategy';\nimport StrategyOptions from './strategy_options';\n\n/** Loops through strategies with optional timeouts.\n *\n * Options:\n * - loop - whether it should loop through the substrategy list\n * - timeout - initial timeout for a single substrategy\n * - timeoutLimit - maximum timeout\n *\n * @param {Strategy[]} strategies\n * @param {Object} options\n */\nexport default class SequentialStrategy implements Strategy {\n strategies: Strategy[];\n loop: boolean;\n failFast: boolean;\n timeout: number;\n timeoutLimit: number;\n\n constructor(strategies: Strategy[], options: StrategyOptions) {\n this.strategies = strategies;\n this.loop = Boolean(options.loop);\n this.failFast = Boolean(options.failFast);\n this.timeout = options.timeout;\n this.timeoutLimit = options.timeoutLimit;\n }\n\n isSupported(): boolean {\n return Collections.any(this.strategies, Util.method('isSupported'));\n }\n\n connect(minPriority: number, callback: Function) {\n var strategies = this.strategies;\n var current = 0;\n var timeout = this.timeout;\n var runner = null;\n\n var tryNextStrategy = (error, handshake) => {\n if (handshake) {\n callback(null, handshake);\n } else {\n current = current + 1;\n if (this.loop) {\n current = current % strategies.length;\n }\n\n if (current < strategies.length) {\n if (timeout) {\n timeout = timeout * 2;\n if (this.timeoutLimit) {\n timeout = Math.min(timeout, this.timeoutLimit);\n }\n }\n runner = this.tryStrategy(\n strategies[current],\n minPriority,\n { timeout, failFast: this.failFast },\n tryNextStrategy\n );\n } else {\n callback(true);\n }\n }\n };\n\n runner = this.tryStrategy(\n strategies[current],\n minPriority,\n { timeout: timeout, failFast: this.failFast },\n tryNextStrategy\n );\n\n return {\n abort: function() {\n runner.abort();\n },\n forceMinPriority: function(p) {\n minPriority = p;\n if (runner) {\n runner.forceMinPriority(p);\n }\n }\n };\n }\n\n private tryStrategy(\n strategy: Strategy,\n minPriority: number,\n options: StrategyOptions,\n callback: Function\n ) {\n var timer = null;\n var runner = null;\n\n if (options.timeout > 0) {\n timer = new Timer(options.timeout, function() {\n runner.abort();\n callback(true);\n });\n }\n\n runner = strategy.connect(minPriority, function(error, handshake) {\n if (error && timer && timer.isRunning() && !options.failFast) {\n // advance to the next strategy after the timeout\n return;\n }\n if (timer) {\n timer.ensureAborted();\n }\n callback(error, handshake);\n });\n\n return {\n abort: function() {\n if (timer) {\n timer.ensureAborted();\n }\n runner.abort();\n },\n forceMinPriority: function(p) {\n runner.forceMinPriority(p);\n }\n };\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport Strategy from './strategy';\n\n/** Launches all substrategies and emits prioritized connected transports.\n *\n * @param {Array} strategies\n */\nexport default class BestConnectedEverStrategy implements Strategy {\n strategies: Strategy[];\n\n constructor(strategies: Strategy[]) {\n this.strategies = strategies;\n }\n\n isSupported(): boolean {\n return Collections.any(this.strategies, Util.method('isSupported'));\n }\n\n connect(minPriority: number, callback: Function) {\n return connect(this.strategies, minPriority, function(i, runners) {\n return function(error, handshake) {\n runners[i].error = error;\n if (error) {\n if (allRunnersFailed(runners)) {\n callback(true);\n }\n return;\n }\n Collections.apply(runners, function(runner) {\n runner.forceMinPriority(handshake.transport.priority);\n });\n callback(null, handshake);\n };\n });\n }\n}\n\n/** Connects to all strategies in parallel.\n *\n * Callback builder should be a function that takes two arguments: index\n * and a list of runners. It should return another function that will be\n * passed to the substrategy with given index. Runners can be aborted using\n * abortRunner(s) functions from this class.\n *\n * @param {Array} strategies\n * @param {Function} callbackBuilder\n * @return {Object} strategy runner\n */\nfunction connect(\n strategies: Strategy[],\n minPriority: number,\n callbackBuilder: Function\n) {\n var runners = Collections.map(strategies, function(strategy, i, _, rs) {\n return strategy.connect(minPriority, callbackBuilder(i, rs));\n });\n return {\n abort: function() {\n Collections.apply(runners, abortRunner);\n },\n forceMinPriority: function(p) {\n Collections.apply(runners, function(runner) {\n runner.forceMinPriority(p);\n });\n }\n };\n}\n\nfunction allRunnersFailed(runners): boolean {\n return Collections.all(runners, function(runner) {\n return Boolean(runner.error);\n });\n}\n\nfunction abortRunner(runner) {\n if (!runner.error && !runner.aborted) {\n runner.abort();\n runner.aborted = true;\n }\n}\n","import Util from '../util';\nimport Runtime from 'runtime';\nimport Strategy from './strategy';\nimport SequentialStrategy from './sequential_strategy';\nimport StrategyOptions from './strategy_options';\nimport TransportStrategy from './transport_strategy';\nimport Timeline from '../timeline/timeline';\nimport * as Collections from '../utils/collections';\n\nexport interface TransportStrategyDictionary {\n [key: string]: TransportStrategy;\n}\n\n/** Caches the last successful transport and, after the first few attempts,\n * uses the cached transport for subsequent attempts.\n *\n * @param {Strategy} strategy\n * @param {Object} transports\n * @param {Object} options\n */\nexport default class WebSocketPrioritizedCachedStrategy implements Strategy {\n strategy: Strategy;\n transports: TransportStrategyDictionary;\n ttl: number;\n usingTLS: boolean;\n timeline: Timeline;\n\n constructor(\n strategy: Strategy,\n transports: TransportStrategyDictionary,\n options: StrategyOptions\n ) {\n this.strategy = strategy;\n this.transports = transports;\n this.ttl = options.ttl || 1800 * 1000;\n this.usingTLS = options.useTLS;\n this.timeline = options.timeline;\n }\n\n isSupported(): boolean {\n return this.strategy.isSupported();\n }\n\n connect(minPriority: number, callback: Function) {\n var usingTLS = this.usingTLS;\n var info = fetchTransportCache(usingTLS);\n var cacheSkipCount = info && info.cacheSkipCount ? info.cacheSkipCount : 0;\n\n var strategies = [this.strategy];\n if (info && info.timestamp + this.ttl >= Util.now()) {\n var transport = this.transports[info.transport];\n if (transport) {\n if (['ws', 'wss'].includes(info.transport) || cacheSkipCount > 3) {\n this.timeline.info({\n cached: true,\n transport: info.transport,\n latency: info.latency\n });\n strategies.push(\n new SequentialStrategy([transport], {\n timeout: info.latency * 2 + 1000,\n failFast: true\n })\n );\n } else {\n cacheSkipCount++;\n }\n }\n }\n\n var startTimestamp = Util.now();\n var runner = strategies\n .pop()\n .connect(minPriority, function cb(error, handshake) {\n if (error) {\n flushTransportCache(usingTLS);\n if (strategies.length > 0) {\n startTimestamp = Util.now();\n runner = strategies.pop().connect(minPriority, cb);\n } else {\n callback(error);\n }\n } else {\n storeTransportCache(\n usingTLS,\n handshake.transport.name,\n Util.now() - startTimestamp,\n cacheSkipCount\n );\n callback(null, handshake);\n }\n });\n\n return {\n abort: function() {\n runner.abort();\n },\n forceMinPriority: function(p) {\n minPriority = p;\n if (runner) {\n runner.forceMinPriority(p);\n }\n }\n };\n }\n}\n\nfunction getTransportCacheKey(usingTLS: boolean): string {\n return 'pusherTransport' + (usingTLS ? 'TLS' : 'NonTLS');\n}\n\nfunction fetchTransportCache(usingTLS: boolean): any {\n var storage = Runtime.getLocalStorage();\n if (storage) {\n try {\n var serializedCache = storage[getTransportCacheKey(usingTLS)];\n if (serializedCache) {\n return JSON.parse(serializedCache);\n }\n } catch (e) {\n flushTransportCache(usingTLS);\n }\n }\n return null;\n}\n\nfunction storeTransportCache(\n usingTLS: boolean,\n transport: TransportStrategy,\n latency: number,\n cacheSkipCount: number\n) {\n var storage = Runtime.getLocalStorage();\n if (storage) {\n try {\n storage[getTransportCacheKey(usingTLS)] = Collections.safeJSONStringify({\n timestamp: Util.now(),\n transport: transport,\n latency: latency,\n cacheSkipCount: cacheSkipCount\n });\n } catch (e) {\n // catch over quota exceptions raised by localStorage\n }\n }\n}\n\nfunction flushTransportCache(usingTLS: boolean) {\n var storage = Runtime.getLocalStorage();\n if (storage) {\n try {\n delete storage[getTransportCacheKey(usingTLS)];\n } catch (e) {\n // catch exceptions raised by localStorage\n }\n }\n}\n","import { OneOffTimer as Timer } from '../utils/timers';\nimport Strategy from './strategy';\nimport StrategyOptions from './strategy_options';\n\n/** Runs substrategy after specified delay.\n *\n * Options:\n * - delay - time in miliseconds to delay the substrategy attempt\n *\n * @param {Strategy} strategy\n * @param {Object} options\n */\nexport default class DelayedStrategy implements Strategy {\n strategy: Strategy;\n options: { delay: number };\n\n constructor(strategy: Strategy, { delay: number }) {\n this.strategy = strategy;\n this.options = { delay: number };\n }\n\n isSupported(): boolean {\n return this.strategy.isSupported();\n }\n\n connect(minPriority: number, callback: Function) {\n var strategy = this.strategy;\n var runner;\n var timer = new Timer(this.options.delay, function() {\n runner = strategy.connect(minPriority, callback);\n });\n\n return {\n abort: function() {\n timer.ensureAborted();\n if (runner) {\n runner.abort();\n }\n },\n forceMinPriority: function(p) {\n minPriority = p;\n if (runner) {\n runner.forceMinPriority(p);\n }\n }\n };\n }\n}\n","import Strategy from './strategy';\nimport StrategyRunner from './strategy_runner';\n\n/** Proxies method calls to one of substrategies basing on the test function.\n *\n * @param {Function} test\n * @param {Strategy} trueBranch strategy used when test returns true\n * @param {Strategy} falseBranch strategy used when test returns false\n */\nexport default class IfStrategy implements Strategy {\n test: () => boolean;\n trueBranch: Strategy;\n falseBranch: Strategy;\n\n constructor(\n test: () => boolean,\n trueBranch: Strategy,\n falseBranch: Strategy\n ) {\n this.test = test;\n this.trueBranch = trueBranch;\n this.falseBranch = falseBranch;\n }\n\n isSupported(): boolean {\n var branch = this.test() ? this.trueBranch : this.falseBranch;\n return branch.isSupported();\n }\n\n connect(minPriority: number, callback: Function): StrategyRunner {\n var branch = this.test() ? this.trueBranch : this.falseBranch;\n return branch.connect(minPriority, callback);\n }\n}\n","import Strategy from './strategy';\nimport StrategyRunner from './strategy_runner';\n\n/** Launches the substrategy and terminates on the first open connection.\n *\n * @param {Strategy} strategy\n */\nexport default class FirstConnectedStrategy implements Strategy {\n strategy: Strategy;\n\n constructor(strategy: Strategy) {\n this.strategy = strategy;\n }\n\n isSupported(): boolean {\n return this.strategy.isSupported();\n }\n\n connect(minPriority: number, callback: Function): StrategyRunner {\n var runner = this.strategy.connect(minPriority, function(error, handshake) {\n if (handshake) {\n runner.abort();\n }\n callback(error, handshake);\n });\n return runner;\n }\n}\n","import * as Collections from 'core/utils/collections';\nimport TransportManager from 'core/transports/transport_manager';\nimport Strategy from 'core/strategies/strategy';\nimport SequentialStrategy from 'core/strategies/sequential_strategy';\nimport BestConnectedEverStrategy from 'core/strategies/best_connected_ever_strategy';\nimport WebSocketPrioritizedCachedStrategy, {\n TransportStrategyDictionary\n} from 'core/strategies/websocket_prioritized_cached_strategy';\nimport DelayedStrategy from 'core/strategies/delayed_strategy';\nimport IfStrategy from 'core/strategies/if_strategy';\nimport FirstConnectedStrategy from 'core/strategies/first_connected_strategy';\nimport { Config } from 'core/config';\nimport StrategyOptions from 'core/strategies/strategy_options';\n\nfunction testSupportsStrategy(strategy: Strategy) {\n return function() {\n return strategy.isSupported();\n };\n}\n\nvar getDefaultStrategy = function(\n config: Config,\n baseOptions: StrategyOptions,\n defineTransport: Function\n): Strategy {\n var definedTransports = {};\n\n function defineTransportStrategy(\n name: string,\n type: string,\n priority: number,\n options: StrategyOptions,\n manager?: TransportManager\n ) {\n var transport = defineTransport(\n config,\n name,\n type,\n priority,\n options,\n manager\n );\n\n definedTransports[name] = transport;\n\n return transport;\n }\n\n var ws_options: StrategyOptions = Object.assign({}, baseOptions, {\n hostNonTLS: config.wsHost + ':' + config.wsPort,\n hostTLS: config.wsHost + ':' + config.wssPort,\n httpPath: config.wsPath\n });\n var wss_options: StrategyOptions = Collections.extend({}, ws_options, {\n useTLS: true\n });\n var http_options: StrategyOptions = Object.assign({}, baseOptions, {\n hostNonTLS: config.httpHost + ':' + config.httpPort,\n hostTLS: config.httpHost + ':' + config.httpsPort,\n httpPath: config.httpPath\n });\n var timeouts = {\n loop: true,\n timeout: 15000,\n timeoutLimit: 60000\n };\n\n var ws_manager = new TransportManager({\n minPingDelay: 10000,\n maxPingDelay: config.activityTimeout\n });\n var streaming_manager = new TransportManager({\n lives: 2,\n minPingDelay: 10000,\n maxPingDelay: config.activityTimeout\n });\n\n var ws_transport = defineTransportStrategy(\n 'ws',\n 'ws',\n 3,\n ws_options,\n ws_manager\n );\n var wss_transport = defineTransportStrategy(\n 'wss',\n 'ws',\n 3,\n wss_options,\n ws_manager\n );\n var xhr_streaming_transport = defineTransportStrategy(\n 'xhr_streaming',\n 'xhr_streaming',\n 1,\n http_options,\n streaming_manager\n );\n var xhr_polling_transport = defineTransportStrategy(\n 'xhr_polling',\n 'xhr_polling',\n 1,\n http_options\n );\n\n var ws_loop = new SequentialStrategy([ws_transport], timeouts);\n var wss_loop = new SequentialStrategy([wss_transport], timeouts);\n var streaming_loop = new SequentialStrategy(\n [xhr_streaming_transport],\n timeouts\n );\n var polling_loop = new SequentialStrategy([xhr_polling_transport], timeouts);\n\n var http_loop = new SequentialStrategy(\n [\n new IfStrategy(\n testSupportsStrategy(streaming_loop),\n new BestConnectedEverStrategy([\n streaming_loop,\n new DelayedStrategy(polling_loop, { delay: 4000 })\n ]),\n polling_loop\n )\n ],\n timeouts\n );\n\n var wsStrategy;\n if (baseOptions.useTLS) {\n wsStrategy = new BestConnectedEverStrategy([\n ws_loop,\n new DelayedStrategy(http_loop, { delay: 2000 })\n ]);\n } else {\n wsStrategy = new BestConnectedEverStrategy([\n ws_loop,\n new DelayedStrategy(wss_loop, { delay: 2000 }),\n new DelayedStrategy(http_loop, { delay: 5000 })\n ]);\n }\n\n return new WebSocketPrioritizedCachedStrategy(\n new FirstConnectedStrategy(\n new IfStrategy(testSupportsStrategy(ws_transport), wsStrategy, http_loop)\n ),\n definedTransports,\n {\n ttl: 1800000,\n timeline: baseOptions.timeline,\n useTLS: baseOptions.useTLS\n }\n );\n};\n\nexport default getDefaultStrategy;\n","/** Initializes the transport.\n *\n * Fetches resources if needed and then transitions to initialized.\n */\nexport default function() {\n var self = this;\n\n self.timeline.info(\n self.buildTimelineMessage({\n transport: self.name + (self.options.useTLS ? 's' : '')\n })\n );\n\n if (self.hooks.isInitialized()) {\n self.changeState('initialized');\n } else {\n self.onClose();\n }\n}\n","import Runtime from 'runtime';\nimport RequestHooks from './request_hooks';\nimport Ajax from './ajax';\nimport { default as EventsDispatcher } from '../events/dispatcher';\n\nconst MAX_BUFFER_LENGTH = 256 * 1024;\n\nexport default class HTTPRequest extends EventsDispatcher {\n hooks: RequestHooks;\n method: string;\n url: string;\n position: number;\n xhr: Ajax;\n unloader: Function;\n\n constructor(hooks: RequestHooks, method: string, url: string) {\n super();\n this.hooks = hooks;\n this.method = method;\n this.url = url;\n }\n\n start(payload?: any) {\n this.position = 0;\n this.xhr = this.hooks.getRequest(this);\n\n this.unloader = () => {\n this.close();\n };\n Runtime.addUnloadListener(this.unloader);\n\n this.xhr.open(this.method, this.url, true);\n\n if (this.xhr.setRequestHeader) {\n this.xhr.setRequestHeader('Content-Type', 'application/json'); // ReactNative doesn't set this header by default.\n }\n this.xhr.send(payload);\n }\n\n close() {\n if (this.unloader) {\n Runtime.removeUnloadListener(this.unloader);\n this.unloader = null;\n }\n if (this.xhr) {\n this.hooks.abortRequest(this.xhr);\n this.xhr = null;\n }\n }\n\n onChunk(status: number, data: any) {\n while (true) {\n var chunk = this.advanceBuffer(data);\n if (chunk) {\n this.emit('chunk', { status: status, data: chunk });\n } else {\n break;\n }\n }\n if (this.isBufferTooLong(data)) {\n this.emit('buffer_too_long');\n }\n }\n\n private advanceBuffer(buffer: any[]): any {\n var unreadData = buffer.slice(this.position);\n var endOfLinePosition = unreadData.indexOf('\\n');\n\n if (endOfLinePosition !== -1) {\n this.position += endOfLinePosition + 1;\n return unreadData.slice(0, endOfLinePosition);\n } else {\n // chunk is not finished yet, don't move the buffer pointer\n return null;\n }\n }\n\n private isBufferTooLong(buffer: any): boolean {\n return this.position === buffer.length && buffer.length > MAX_BUFFER_LENGTH;\n }\n}\n","enum State {\n CONNECTING = 0,\n OPEN = 1,\n CLOSED = 3\n}\n\nexport default State;\n","import URLLocation from './url_location';\nimport State from './state';\nimport Socket from '../socket';\nimport SocketHooks from './socket_hooks';\nimport Util from '../util';\nimport Ajax from './ajax';\nimport HTTPRequest from './http_request';\nimport Runtime from 'runtime';\n\nvar autoIncrement = 1;\n\nclass HTTPSocket implements Socket {\n hooks: SocketHooks;\n session: string;\n location: URLLocation;\n readyState: State;\n stream: HTTPRequest;\n\n onopen: () => void;\n onerror: (error: any) => void;\n onclose: (closeEvent: any) => void;\n onmessage: (message: any) => void;\n onactivity: () => void;\n\n constructor(hooks: SocketHooks, url: string) {\n this.hooks = hooks;\n this.session = randomNumber(1000) + '/' + randomString(8);\n this.location = getLocation(url);\n this.readyState = State.CONNECTING;\n this.openStream();\n }\n\n send(payload: any) {\n return this.sendRaw(JSON.stringify([payload]));\n }\n\n ping() {\n this.hooks.sendHeartbeat(this);\n }\n\n close(code: any, reason: any) {\n this.onClose(code, reason, true);\n }\n\n /** For internal use only */\n sendRaw(payload: any): boolean {\n if (this.readyState === State.OPEN) {\n try {\n Runtime.createSocketRequest(\n 'POST',\n getUniqueURL(getSendURL(this.location, this.session))\n ).start(payload);\n return true;\n } catch (e) {\n return false;\n }\n } else {\n return false;\n }\n }\n\n /** For internal use only */\n reconnect() {\n this.closeStream();\n this.openStream();\n }\n\n /** For internal use only */\n onClose(code, reason, wasClean) {\n this.closeStream();\n this.readyState = State.CLOSED;\n if (this.onclose) {\n this.onclose({\n code: code,\n reason: reason,\n wasClean: wasClean\n });\n }\n }\n\n private onChunk(chunk) {\n if (chunk.status !== 200) {\n return;\n }\n if (this.readyState === State.OPEN) {\n this.onActivity();\n }\n\n var payload;\n var type = chunk.data.slice(0, 1);\n switch (type) {\n case 'o':\n payload = JSON.parse(chunk.data.slice(1) || '{}');\n this.onOpen(payload);\n break;\n case 'a':\n payload = JSON.parse(chunk.data.slice(1) || '[]');\n for (var i = 0; i < payload.length; i++) {\n this.onEvent(payload[i]);\n }\n break;\n case 'm':\n payload = JSON.parse(chunk.data.slice(1) || 'null');\n this.onEvent(payload);\n break;\n case 'h':\n this.hooks.onHeartbeat(this);\n break;\n case 'c':\n payload = JSON.parse(chunk.data.slice(1) || '[]');\n this.onClose(payload[0], payload[1], true);\n break;\n }\n }\n\n private onOpen(options) {\n if (this.readyState === State.CONNECTING) {\n if (options && options.hostname) {\n this.location.base = replaceHost(this.location.base, options.hostname);\n }\n this.readyState = State.OPEN;\n\n if (this.onopen) {\n this.onopen();\n }\n } else {\n this.onClose(1006, 'Server lost session', true);\n }\n }\n\n private onEvent(event) {\n if (this.readyState === State.OPEN && this.onmessage) {\n this.onmessage({ data: event });\n }\n }\n\n private onActivity() {\n if (this.onactivity) {\n this.onactivity();\n }\n }\n\n private onError(error) {\n if (this.onerror) {\n this.onerror(error);\n }\n }\n\n private openStream() {\n this.stream = Runtime.createSocketRequest(\n 'POST',\n getUniqueURL(this.hooks.getReceiveURL(this.location, this.session))\n );\n\n this.stream.bind('chunk', chunk => {\n this.onChunk(chunk);\n });\n this.stream.bind('finished', status => {\n this.hooks.onFinished(this, status);\n });\n this.stream.bind('buffer_too_long', () => {\n this.reconnect();\n });\n\n try {\n this.stream.start();\n } catch (error) {\n Util.defer(() => {\n this.onError(error);\n this.onClose(1006, 'Could not start streaming', false);\n });\n }\n }\n\n private closeStream() {\n if (this.stream) {\n this.stream.unbind_all();\n this.stream.close();\n this.stream = null;\n }\n }\n}\n\nfunction getLocation(url): URLLocation {\n var parts = /([^\\?]*)\\/*(\\??.*)/.exec(url);\n return {\n base: parts[1],\n queryString: parts[2]\n };\n}\n\nfunction getSendURL(url: URLLocation, session: string): string {\n return url.base + '/' + session + '/xhr_send';\n}\n\nfunction getUniqueURL(url: string): string {\n var separator = url.indexOf('?') === -1 ? '?' : '&';\n return url + separator + 't=' + +new Date() + '&n=' + autoIncrement++;\n}\n\nfunction replaceHost(url: string, hostname: string): string {\n var urlParts = /(https?:\\/\\/)([^\\/:]+)((\\/|:)?.*)/.exec(url);\n return urlParts[1] + hostname + urlParts[3];\n}\n\nfunction randomNumber(max: number): number {\n return Runtime.randomInt(max);\n}\n\nfunction randomString(length: number): string {\n var result = [];\n\n for (var i = 0; i < length; i++) {\n result.push(randomNumber(32).toString(32));\n }\n\n return result.join('');\n}\n\nexport default HTTPSocket;\n","import SocketHooks from './socket_hooks';\nimport HTTPSocket from './http_socket';\n\nvar hooks: SocketHooks = {\n getReceiveURL: function(url, session) {\n return url.base + '/' + session + '/xhr_streaming' + url.queryString;\n },\n onHeartbeat: function(socket) {\n socket.sendRaw('[]');\n },\n sendHeartbeat: function(socket) {\n socket.sendRaw('[]');\n },\n onFinished: function(socket, status) {\n socket.onClose(1006, 'Connection interrupted (' + status + ')', false);\n }\n};\n\nexport default hooks;\n","import SocketHooks from './socket_hooks';\nimport URLLocation from './url_location';\nimport HTTPSocket from './http_socket';\n\nvar hooks: SocketHooks = {\n getReceiveURL: function(url: URLLocation, session: string): string {\n return url.base + '/' + session + '/xhr' + url.queryString;\n },\n onHeartbeat: function() {\n // next HTTP request will reset server's activity timer\n },\n sendHeartbeat: function(socket) {\n socket.sendRaw('[]');\n },\n onFinished: function(socket, status) {\n if (status === 200) {\n socket.reconnect();\n } else {\n socket.onClose(1006, 'Connection interrupted (' + status + ')', false);\n }\n }\n};\n\nexport default hooks;\n","import HTTPRequest from 'core/http/http_request';\nimport RequestHooks from 'core/http/request_hooks';\nimport Ajax from 'core/http/ajax';\nimport Runtime from 'runtime';\n\nvar hooks: RequestHooks = {\n getRequest: function(socket: HTTPRequest): Ajax {\n var Constructor = Runtime.getXHRAPI();\n var xhr = new Constructor();\n xhr.onreadystatechange = xhr.onprogress = function() {\n switch (xhr.readyState) {\n case 3:\n if (xhr.responseText && xhr.responseText.length > 0) {\n socket.onChunk(xhr.status, xhr.responseText);\n }\n break;\n case 4:\n // this happens only on errors, never after calling close\n if (xhr.responseText && xhr.responseText.length > 0) {\n socket.onChunk(xhr.status, xhr.responseText);\n }\n socket.emit('finished', xhr.status);\n socket.close();\n break;\n }\n };\n return xhr;\n },\n abortRequest: function(xhr: Ajax) {\n xhr.onreadystatechange = null;\n xhr.abort();\n }\n};\n\nexport default hooks;\n","import HTTPRequest from 'core/http/http_request';\nimport HTTPSocket from 'core/http/http_socket';\nimport SocketHooks from 'core/http/socket_hooks';\nimport RequestHooks from 'core/http/request_hooks';\nimport streamingHooks from 'core/http/http_streaming_socket';\nimport pollingHooks from 'core/http/http_polling_socket';\nimport xhrHooks from './http_xhr_request';\nimport HTTPFactory from 'core/http/http_factory';\n\nvar HTTP: HTTPFactory = {\n createStreamingSocket(url: string): HTTPSocket {\n return this.createSocket(streamingHooks, url);\n },\n\n createPollingSocket(url: string): HTTPSocket {\n return this.createSocket(pollingHooks, url);\n },\n\n createSocket(hooks: SocketHooks, url: string): HTTPSocket {\n return new HTTPSocket(hooks, url);\n },\n\n createXHR(method: string, url: string): HTTPRequest {\n return this.createRequest(xhrHooks, method, url);\n },\n\n createRequest(hooks: RequestHooks, method: string, url: string): HTTPRequest {\n return new HTTPRequest(hooks, method, url);\n }\n};\n\nexport default HTTP;\n","import * as Collections from 'core/utils/collections';\nimport Transports from 'isomorphic/transports/transports';\nimport TimelineSender from 'core/timeline/timeline_sender';\nimport Ajax from 'core/http/ajax';\nimport getDefaultStrategy from './default_strategy';\nimport TransportsTable from 'core/transports/transports_table';\nimport transportConnectionInitializer from './transports/transport_connection_initializer';\nimport HTTPFactory from './http/http';\n\nvar Isomorphic: any = {\n getDefaultStrategy,\n Transports: Transports,\n transportConnectionInitializer,\n HTTPFactory,\n\n setup(PusherClass): void {\n PusherClass.ready();\n },\n\n getLocalStorage(): any {\n return undefined;\n },\n\n getClientFeatures(): any[] {\n return Collections.keys(\n Collections.filterObject({ ws: Transports.ws }, function(t) {\n return t.isSupported({});\n })\n );\n },\n\n getProtocol(): string {\n return 'http:';\n },\n\n isXHRSupported(): boolean {\n return true;\n },\n\n createSocketRequest(method: string, url: string) {\n if (this.isXHRSupported()) {\n return this.HTTPFactory.createXHR(method, url);\n } else {\n throw 'Cross-origin HTTP requests are not supported';\n }\n },\n\n createXHR(): Ajax {\n var Constructor = this.getXHRAPI();\n return new Constructor();\n },\n\n createWebSocket(url: string): any {\n var Constructor = this.getWebSocketAPI();\n return new Constructor(url);\n },\n\n addUnloadListener(listener: any) {},\n removeUnloadListener(listener: any) {}\n};\n\nexport default Isomorphic;\n","import { default as EventsDispatcher } from 'core/events/dispatcher';\nimport Reachability from 'core/reachability';\n\nexport class NetInfo extends EventsDispatcher implements Reachability {\n isOnline(): boolean {\n return true;\n }\n}\n\nexport var Network = new NetInfo();\n","export enum AuthRequestType {\n UserAuthentication = 'user-authentication',\n ChannelAuthorization = 'channel-authorization'\n}\n\nexport interface ChannelAuthorizationData {\n auth: string;\n channel_data?: string;\n shared_secret?: string;\n}\n\nexport type ChannelAuthorizationCallback = (\n error: Error | null,\n authData: ChannelAuthorizationData | null\n) => void;\n\nexport interface ChannelAuthorizationRequestParams {\n socketId: string;\n channelName: string;\n}\n\nexport interface ChannelAuthorizationHandler {\n (\n params: ChannelAuthorizationRequestParams,\n callback: ChannelAuthorizationCallback\n ): void;\n}\n\nexport interface UserAuthenticationData {\n auth: string;\n user_data: string;\n}\n\nexport type UserAuthenticationCallback = (\n error: Error | null,\n authData: UserAuthenticationData | null\n) => void;\n\nexport interface UserAuthenticationRequestParams {\n socketId: string;\n}\n\nexport interface UserAuthenticationHandler {\n (\n params: UserAuthenticationRequestParams,\n callback: UserAuthenticationCallback\n ): void;\n}\n\nexport type AuthTransportCallback =\n | ChannelAuthorizationCallback\n | UserAuthenticationCallback;\n\nexport interface AuthOptionsT {\n transport: 'ajax' | 'jsonp';\n endpoint: string;\n params?: any;\n headers?: any;\n paramsProvider?: () => any;\n headersProvider?: () => any;\n customHandler?: AuthHandler;\n}\n\nexport declare type UserAuthenticationOptions = AuthOptionsT<\n UserAuthenticationHandler\n>;\nexport declare type ChannelAuthorizationOptions = AuthOptionsT<\n ChannelAuthorizationHandler\n>;\n\nexport interface InternalAuthOptions {\n transport: 'ajax' | 'jsonp';\n endpoint: string;\n params?: any;\n headers?: any;\n paramsProvider?: () => any;\n headersProvider?: () => any;\n}\n","import TimelineSender from 'core/timeline/timeline_sender';\nimport * as Collections from 'core/utils/collections';\nimport Util from 'core/util';\nimport Runtime from 'runtime';\nimport { AuthTransport } from 'core/auth/auth_transports';\nimport AbstractRuntime from 'runtimes/interface';\nimport UrlStore from 'core/utils/url_store';\nimport {\n AuthRequestType,\n AuthTransportCallback,\n InternalAuthOptions\n} from 'core/auth/options';\nimport { HTTPAuthError } from 'core/errors';\n\nconst ajax: AuthTransport = function(\n context: AbstractRuntime,\n query: string,\n authOptions: InternalAuthOptions,\n authRequestType: AuthRequestType,\n callback: AuthTransportCallback\n) {\n const xhr = Runtime.createXHR();\n xhr.open('POST', authOptions.endpoint, true);\n\n // add request headers\n xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');\n for (var headerName in authOptions.headers) {\n xhr.setRequestHeader(headerName, authOptions.headers[headerName]);\n }\n if (authOptions.headersProvider != null) {\n let dynamicHeaders = authOptions.headersProvider();\n for (var headerName in dynamicHeaders) {\n xhr.setRequestHeader(headerName, dynamicHeaders[headerName]);\n }\n }\n\n xhr.onreadystatechange = function() {\n if (xhr.readyState === 4) {\n if (xhr.status === 200) {\n let data;\n let parsed = false;\n\n try {\n data = JSON.parse(xhr.responseText);\n parsed = true;\n } catch (e) {\n callback(\n new HTTPAuthError(\n 200,\n `JSON returned from ${authRequestType.toString()} endpoint was invalid, yet status code was 200. Data was: ${\n xhr.responseText\n }`\n ),\n null\n );\n }\n\n if (parsed) {\n // prevents double execution.\n callback(null, data);\n }\n } else {\n let suffix = '';\n switch (authRequestType) {\n case AuthRequestType.UserAuthentication:\n suffix = UrlStore.buildLogSuffix('authenticationEndpoint');\n break;\n case AuthRequestType.ChannelAuthorization:\n suffix = `Clients must be authorized to join private or presence channels. ${UrlStore.buildLogSuffix(\n 'authorizationEndpoint'\n )}`;\n break;\n }\n callback(\n new HTTPAuthError(\n xhr.status,\n `Unable to retrieve auth string from ${authRequestType.toString()} endpoint - ` +\n `received status: ${xhr.status} from ${authOptions.endpoint}. ${suffix}`\n ),\n null\n );\n }\n }\n };\n\n xhr.send(query);\n return xhr;\n};\n\nexport default ajax;\n","import Logger from 'core/logger';\nimport TimelineSender from 'core/timeline/timeline_sender';\nimport * as Collections from 'core/utils/collections';\nimport Util from 'core/util';\nimport Runtime from 'runtime';\nimport TimelineTransport from 'core/timeline/timeline_transport';\n\nvar getAgent = function(sender: TimelineSender, useTLS: boolean) {\n return function(data: any, callback: Function) {\n var scheme = 'http' + (useTLS ? 's' : '') + '://';\n var url =\n scheme + (sender.host || sender.options.host) + sender.options.path;\n var query = Collections.buildQueryString(data);\n\n url += '/' + 2 + '?' + query;\n\n var xhr = Runtime.createXHR();\n xhr.open('GET', url, true);\n\n xhr.onreadystatechange = function() {\n if (xhr.readyState === 4) {\n let { status, responseText } = xhr;\n if (status !== 200) {\n Logger.debug(\n `TimelineSender Error: received ${status} from stats.pusher.com`\n );\n return;\n }\n\n try {\n var { host } = JSON.parse(responseText);\n } catch (e) {\n Logger.debug(`TimelineSenderError: invalid response ${responseText}`);\n }\n if (host) {\n sender.host = host;\n }\n }\n };\n\n xhr.send();\n };\n};\n\nvar xhr = {\n name: 'xhr',\n getAgent\n};\n\nexport default xhr;\n","import Isomorphic from 'isomorphic/runtime';\nimport { Client as WebSocket } from 'faye-websocket';\nimport { XMLHttpRequest } from 'xmlhttprequest';\nimport Runtime from '../interface';\nimport { Network } from './net_info';\nimport xhrAuth from 'isomorphic/auth/xhr_auth';\nimport { AuthTransports } from 'core/auth/auth_transports';\nimport xhrTimeline from 'isomorphic/timeline/xhr_timeline';\nimport { randomInt } from 'crypto';\n\n// Very verbose but until unavoidable until\n// TypeScript 2.1, when spread attributes will be\n// supported\nconst {\n getDefaultStrategy,\n Transports,\n setup,\n getProtocol,\n isXHRSupported,\n getLocalStorage,\n createXHR,\n createWebSocket,\n addUnloadListener,\n removeUnloadListener,\n transportConnectionInitializer,\n createSocketRequest,\n HTTPFactory\n} = Isomorphic;\n\nconst NodeJS: Runtime = {\n getDefaultStrategy,\n Transports,\n setup,\n getProtocol,\n isXHRSupported,\n createSocketRequest,\n getLocalStorage,\n createXHR,\n createWebSocket,\n addUnloadListener,\n removeUnloadListener,\n transportConnectionInitializer,\n HTTPFactory,\n\n TimelineTransport: xhrTimeline,\n\n getAuthorizers(): AuthTransports {\n return { ajax: xhrAuth };\n },\n\n getWebSocketAPI() {\n return WebSocket;\n },\n\n getXHRAPI() {\n return XMLHttpRequest;\n },\n\n getNetwork() {\n return Network;\n },\n\n randomInt(max: number): number {\n return randomInt(max);\n }\n};\n\nexport default NodeJS;\n","enum TimelineLevel {\n ERROR = 3,\n INFO = 6,\n DEBUG = 7\n}\n\nexport default TimelineLevel;\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport { default as Level } from './level';\n\nexport interface TimelineOptions {\n level?: Level;\n limit?: number;\n version?: string;\n cluster?: string;\n features?: string[];\n params?: any;\n}\n\nexport default class Timeline {\n key: string;\n session: number;\n events: any[];\n options: TimelineOptions;\n sent: number;\n uniqueID: number;\n\n constructor(key: string, session: number, options: TimelineOptions) {\n this.key = key;\n this.session = session;\n this.events = [];\n this.options = options || {};\n this.sent = 0;\n this.uniqueID = 0;\n }\n\n log(level, event) {\n if (level <= this.options.level) {\n this.events.push(\n Collections.extend({}, event, { timestamp: Util.now() })\n );\n if (this.options.limit && this.events.length > this.options.limit) {\n this.events.shift();\n }\n }\n }\n\n error(event) {\n this.log(Level.ERROR, event);\n }\n\n info(event) {\n this.log(Level.INFO, event);\n }\n\n debug(event) {\n this.log(Level.DEBUG, event);\n }\n\n isEmpty() {\n return this.events.length === 0;\n }\n\n send(sendfn, callback) {\n var data = Collections.extend(\n {\n session: this.session,\n bundle: this.sent + 1,\n key: this.key,\n lib: 'js',\n version: this.options.version,\n cluster: this.options.cluster,\n features: this.options.features,\n timeline: this.events\n },\n this.options.params\n );\n\n this.events = [];\n sendfn(data, (error, result) => {\n if (!error) {\n this.sent++;\n }\n if (callback) {\n callback(error, result);\n }\n });\n\n return true;\n }\n\n generateUniqueID(): number {\n this.uniqueID++;\n return this.uniqueID;\n }\n}\n","import Factory from '../utils/factory';\nimport Util from '../util';\nimport * as Errors from '../errors';\nimport * as Collections from '../utils/collections';\nimport Strategy from './strategy';\nimport Transport from '../transports/transport';\nimport StrategyOptions from './strategy_options';\nimport Handshake from '../connection/handshake';\n\n/** Provides a strategy interface for transports.\n *\n * @param {String} name\n * @param {Number} priority\n * @param {Class} transport\n * @param {Object} options\n */\nexport default class TransportStrategy implements Strategy {\n name: string;\n priority: number;\n transport: Transport;\n options: StrategyOptions;\n\n constructor(\n name: string,\n priority: number,\n transport: Transport,\n options: StrategyOptions\n ) {\n this.name = name;\n this.priority = priority;\n this.transport = transport;\n this.options = options || {};\n }\n\n /** Returns whether the transport is supported in the browser.\n *\n * @returns {Boolean}\n */\n isSupported(): boolean {\n return this.transport.isSupported({\n useTLS: this.options.useTLS\n });\n }\n\n /** Launches a connection attempt and returns a strategy runner.\n *\n * @param {Function} callback\n * @return {Object} strategy runner\n */\n connect(minPriority: number, callback: Function) {\n if (!this.isSupported()) {\n return failAttempt(new Errors.UnsupportedStrategy(), callback);\n } else if (this.priority < minPriority) {\n return failAttempt(new Errors.TransportPriorityTooLow(), callback);\n }\n\n var connected = false;\n var transport = this.transport.createConnection(\n this.name,\n this.priority,\n this.options.key,\n this.options\n );\n var handshake = null;\n\n var onInitialized = function() {\n transport.unbind('initialized', onInitialized);\n transport.connect();\n };\n var onOpen = function() {\n handshake = Factory.createHandshake(transport, function(result) {\n connected = true;\n unbindListeners();\n callback(null, result);\n });\n };\n var onError = function(error) {\n unbindListeners();\n callback(error);\n };\n var onClosed = function() {\n unbindListeners();\n var serializedTransport;\n\n // The reason for this try/catch block is that on React Native\n // the WebSocket object is circular. Therefore transport.socket will\n // throw errors upon stringification. Collections.safeJSONStringify\n // discards circular references when serializing.\n serializedTransport = Collections.safeJSONStringify(transport);\n callback(new Errors.TransportClosed(serializedTransport));\n };\n\n var unbindListeners = function() {\n transport.unbind('initialized', onInitialized);\n transport.unbind('open', onOpen);\n transport.unbind('error', onError);\n transport.unbind('closed', onClosed);\n };\n\n transport.bind('initialized', onInitialized);\n transport.bind('open', onOpen);\n transport.bind('error', onError);\n transport.bind('closed', onClosed);\n\n // connect will be called automatically after initialization\n transport.initialize();\n\n return {\n abort: () => {\n if (connected) {\n return;\n }\n unbindListeners();\n if (handshake) {\n handshake.close();\n } else {\n transport.close();\n }\n },\n forceMinPriority: p => {\n if (connected) {\n return;\n }\n if (this.priority < p) {\n if (handshake) {\n handshake.close();\n } else {\n transport.close();\n }\n }\n }\n };\n }\n}\n\nfunction failAttempt(error: Error, callback: Function) {\n Util.defer(function() {\n callback(error);\n });\n return {\n abort: function() {},\n forceMinPriority: function() {}\n };\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport TransportManager from '../transports/transport_manager';\nimport * as Errors from '../errors';\nimport Strategy from './strategy';\nimport TransportStrategy from './transport_strategy';\nimport StrategyOptions from '../strategies/strategy_options';\nimport { Config } from '../config';\nimport Runtime from 'runtime';\n\nconst { Transports } = Runtime;\n\nexport var defineTransport = function(\n config: Config,\n name: string,\n type: string,\n priority: number,\n options: StrategyOptions,\n manager?: TransportManager\n): Strategy {\n var transportClass = Transports[type];\n if (!transportClass) {\n throw new Errors.UnsupportedTransport(type);\n }\n\n var enabled =\n (!config.enabledTransports ||\n Collections.arrayIndexOf(config.enabledTransports, name) !== -1) &&\n (!config.disabledTransports ||\n Collections.arrayIndexOf(config.disabledTransports, name) === -1);\n\n var transport;\n if (enabled) {\n options = Object.assign(\n { ignoreNullOrigin: config.ignoreNullOrigin },\n options\n );\n\n transport = new TransportStrategy(\n name,\n priority,\n manager ? manager.getAssistant(transportClass) : transportClass,\n options\n );\n } else {\n transport = UnsupportedStrategy;\n }\n\n return transport;\n};\n\nvar UnsupportedStrategy: Strategy = {\n isSupported: function() {\n return false;\n },\n connect: function(_, callback) {\n var deferred = Util.defer(function() {\n callback(new Errors.UnsupportedStrategy());\n });\n return {\n abort: function() {\n deferred.ensureAborted();\n },\n forceMinPriority: function() {}\n };\n }\n};\n","import ConnectionManager from './connection/connection_manager';\nimport {\n ChannelAuthorizationOptions,\n UserAuthenticationOptions\n} from './auth/options';\nimport {\n ChannelAuthorizerGenerator,\n DeprecatedAuthOptions\n} from './auth/deprecated_channel_authorizer';\nimport { AuthTransport, Transport } from './config';\nimport * as nacl from 'tweetnacl';\nimport Logger from './logger';\n\nexport interface Options {\n activityTimeout?: number;\n\n auth?: DeprecatedAuthOptions; // DEPRECATED use channelAuthorization instead\n authEndpoint?: string; // DEPRECATED use channelAuthorization instead\n authTransport?: AuthTransport; // DEPRECATED use channelAuthorization instead\n authorizer?: ChannelAuthorizerGenerator; // DEPRECATED use channelAuthorization instead\n\n channelAuthorization?: ChannelAuthorizationOptions;\n userAuthentication?: UserAuthenticationOptions;\n\n cluster: string;\n enableStats?: boolean;\n disableStats?: boolean;\n disabledTransports?: Transport[];\n enabledTransports?: Transport[];\n forceTLS?: boolean;\n httpHost?: string;\n httpPath?: string;\n httpPort?: number;\n httpsPort?: number;\n ignoreNullOrigin?: boolean;\n nacl?: nacl;\n pongTimeout?: number;\n statsHost?: string;\n timelineParams?: any;\n unavailableTimeout?: number;\n wsHost?: string;\n wsPath?: string;\n wsPort?: number;\n wssPort?: number;\n}\n\nexport interface ClusterOptions {\n appKey: string;\n cluster: string;\n}\n\nexport function validateOptions(options) {\n if (options == null) {\n throw 'You must pass an options object';\n }\n if (options.cluster == null) {\n throw 'Options object must provide a cluster';\n }\n if ('disableStats' in options) {\n Logger.warn(\n 'The disableStats option is deprecated in favor of enableStats'\n );\n }\n}\n","import {\n UserAuthenticationCallback,\n InternalAuthOptions,\n UserAuthenticationHandler,\n UserAuthenticationRequestParams,\n AuthRequestType\n} from './options';\n\nimport Runtime from 'runtime';\n\nconst composeChannelQuery = (\n params: UserAuthenticationRequestParams,\n authOptions: InternalAuthOptions\n) => {\n var query = 'socket_id=' + encodeURIComponent(params.socketId);\n\n for (var key in authOptions.params) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(authOptions.params[key]);\n }\n\n if (authOptions.paramsProvider != null) {\n let dynamicParams = authOptions.paramsProvider();\n for (var key in dynamicParams) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(dynamicParams[key]);\n }\n }\n\n return query;\n};\n\nconst UserAuthenticator = (\n authOptions: InternalAuthOptions\n): UserAuthenticationHandler => {\n if (typeof Runtime.getAuthorizers()[authOptions.transport] === 'undefined') {\n throw `'${authOptions.transport}' is not a recognized auth transport`;\n }\n\n return (\n params: UserAuthenticationRequestParams,\n callback: UserAuthenticationCallback\n ) => {\n const query = composeChannelQuery(params, authOptions);\n\n Runtime.getAuthorizers()[authOptions.transport](\n Runtime,\n query,\n authOptions,\n AuthRequestType.UserAuthentication,\n callback\n );\n };\n};\n\nexport default UserAuthenticator;\n","import {\n AuthRequestType,\n InternalAuthOptions,\n ChannelAuthorizationHandler,\n ChannelAuthorizationRequestParams,\n ChannelAuthorizationCallback\n} from './options';\n\nimport Runtime from 'runtime';\n\nconst composeChannelQuery = (\n params: ChannelAuthorizationRequestParams,\n authOptions: InternalAuthOptions\n) => {\n var query = 'socket_id=' + encodeURIComponent(params.socketId);\n\n query += '&channel_name=' + encodeURIComponent(params.channelName);\n\n for (var key in authOptions.params) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(authOptions.params[key]);\n }\n\n if (authOptions.paramsProvider != null) {\n let dynamicParams = authOptions.paramsProvider();\n for (var key in dynamicParams) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(dynamicParams[key]);\n }\n }\n\n return query;\n};\n\nconst ChannelAuthorizer = (\n authOptions: InternalAuthOptions\n): ChannelAuthorizationHandler => {\n if (typeof Runtime.getAuthorizers()[authOptions.transport] === 'undefined') {\n throw `'${authOptions.transport}' is not a recognized auth transport`;\n }\n\n return (\n params: ChannelAuthorizationRequestParams,\n callback: ChannelAuthorizationCallback\n ) => {\n const query = composeChannelQuery(params, authOptions);\n\n Runtime.getAuthorizers()[authOptions.transport](\n Runtime,\n query,\n authOptions,\n AuthRequestType.ChannelAuthorization,\n callback\n );\n };\n};\n\nexport default ChannelAuthorizer;\n","import Channel from '../channels/channel';\nimport {\n ChannelAuthorizationCallback,\n ChannelAuthorizationHandler,\n ChannelAuthorizationRequestParams,\n InternalAuthOptions\n} from './options';\n\nexport interface DeprecatedChannelAuthorizer {\n authorize(socketId: string, callback: ChannelAuthorizationCallback): void;\n}\n\nexport interface ChannelAuthorizerGenerator {\n (\n channel: Channel,\n options: DeprecatedAuthorizerOptions\n ): DeprecatedChannelAuthorizer;\n}\n\nexport interface DeprecatedAuthOptions {\n params?: any;\n headers?: any;\n}\n\nexport interface DeprecatedAuthorizerOptions {\n authTransport: 'ajax' | 'jsonp';\n authEndpoint: string;\n auth?: DeprecatedAuthOptions;\n}\n\nexport const ChannelAuthorizerProxy = (\n pusher,\n authOptions: InternalAuthOptions,\n channelAuthorizerGenerator: ChannelAuthorizerGenerator\n): ChannelAuthorizationHandler => {\n const deprecatedAuthorizerOptions: DeprecatedAuthorizerOptions = {\n authTransport: authOptions.transport,\n authEndpoint: authOptions.endpoint,\n auth: {\n params: authOptions.params,\n headers: authOptions.headers\n }\n };\n return (\n params: ChannelAuthorizationRequestParams,\n callback: ChannelAuthorizationCallback\n ) => {\n const channel = pusher.channel(params.channelName);\n // This line creates a new channel authorizer every time.\n // In the past, this was only done once per channel and reused.\n // We can do that again if we want to keep this behavior intact.\n const channelAuthorizer: DeprecatedChannelAuthorizer = channelAuthorizerGenerator(\n channel,\n deprecatedAuthorizerOptions\n );\n channelAuthorizer.authorize(params.socketId, callback);\n };\n};\n","import { Options } from './options';\nimport Defaults from './defaults';\nimport {\n ChannelAuthorizationHandler,\n UserAuthenticationHandler,\n ChannelAuthorizationOptions\n} from './auth/options';\nimport UserAuthenticator from './auth/user_authenticator';\nimport ChannelAuthorizer from './auth/channel_authorizer';\nimport { ChannelAuthorizerProxy } from './auth/deprecated_channel_authorizer';\nimport Runtime from 'runtime';\nimport * as nacl from 'tweetnacl';\n\nexport type AuthTransport = 'ajax' | 'jsonp';\nexport type Transport =\n | 'ws'\n | 'wss'\n | 'xhr_streaming'\n | 'xhr_polling'\n | 'sockjs';\n\nexport interface Config {\n // these are all 'required' config parameters, it's not necessary for the user\n // to set them, but they have configured defaults.\n activityTimeout: number;\n enableStats: boolean;\n httpHost: string;\n httpPath: string;\n httpPort: number;\n httpsPort: number;\n pongTimeout: number;\n statsHost: string;\n unavailableTimeout: number;\n useTLS: boolean;\n wsHost: string;\n wsPath: string;\n wsPort: number;\n wssPort: number;\n userAuthenticator: UserAuthenticationHandler;\n channelAuthorizer: ChannelAuthorizationHandler;\n\n // these are all optional parameters or overrrides. The customer can set these\n // but it's not strictly necessary\n forceTLS?: boolean;\n cluster?: string;\n disabledTransports?: Transport[];\n enabledTransports?: Transport[];\n ignoreNullOrigin?: boolean;\n nacl?: nacl;\n timelineParams?: any;\n}\n\n// getConfig mainly sets the defaults for the options that are not provided\nexport function getConfig(opts: Options, pusher): Config {\n let config: Config = {\n activityTimeout: opts.activityTimeout || Defaults.activityTimeout,\n cluster: opts.cluster,\n httpPath: opts.httpPath || Defaults.httpPath,\n httpPort: opts.httpPort || Defaults.httpPort,\n httpsPort: opts.httpsPort || Defaults.httpsPort,\n pongTimeout: opts.pongTimeout || Defaults.pongTimeout,\n statsHost: opts.statsHost || Defaults.stats_host,\n unavailableTimeout: opts.unavailableTimeout || Defaults.unavailableTimeout,\n wsPath: opts.wsPath || Defaults.wsPath,\n wsPort: opts.wsPort || Defaults.wsPort,\n wssPort: opts.wssPort || Defaults.wssPort,\n\n enableStats: getEnableStatsConfig(opts),\n httpHost: getHttpHost(opts),\n useTLS: shouldUseTLS(opts),\n wsHost: getWebsocketHost(opts),\n\n userAuthenticator: buildUserAuthenticator(opts),\n channelAuthorizer: buildChannelAuthorizer(opts, pusher)\n };\n\n if ('disabledTransports' in opts)\n config.disabledTransports = opts.disabledTransports;\n if ('enabledTransports' in opts)\n config.enabledTransports = opts.enabledTransports;\n if ('ignoreNullOrigin' in opts)\n config.ignoreNullOrigin = opts.ignoreNullOrigin;\n if ('timelineParams' in opts) config.timelineParams = opts.timelineParams;\n if ('nacl' in opts) {\n config.nacl = opts.nacl;\n }\n\n return config;\n}\n\nfunction getHttpHost(opts: Options): string {\n if (opts.httpHost) {\n return opts.httpHost;\n }\n if (opts.cluster) {\n return `sockjs-${opts.cluster}.pusher.com`;\n }\n return Defaults.httpHost;\n}\n\nfunction getWebsocketHost(opts: Options): string {\n if (opts.wsHost) {\n return opts.wsHost;\n }\n return getWebsocketHostFromCluster(opts.cluster);\n}\n\nfunction getWebsocketHostFromCluster(cluster: string): string {\n return `ws-${cluster}.pusher.com`;\n}\n\nfunction shouldUseTLS(opts: Options): boolean {\n if (Runtime.getProtocol() === 'https:') {\n return true;\n } else if (opts.forceTLS === false) {\n return false;\n }\n return true;\n}\n\n// if enableStats is set take the value\n// if disableStats is set take the inverse\n// otherwise default to false\nfunction getEnableStatsConfig(opts: Options): boolean {\n if ('enableStats' in opts) {\n return opts.enableStats;\n }\n if ('disableStats' in opts) {\n return !opts.disableStats;\n }\n return false;\n}\n\nfunction buildUserAuthenticator(opts: Options): UserAuthenticationHandler {\n const userAuthentication = {\n ...Defaults.userAuthentication,\n ...opts.userAuthentication\n };\n if (\n 'customHandler' in userAuthentication &&\n userAuthentication['customHandler'] != null\n ) {\n return userAuthentication['customHandler'];\n }\n\n return UserAuthenticator(userAuthentication);\n}\n\nfunction buildChannelAuth(opts: Options, pusher): ChannelAuthorizationOptions {\n let channelAuthorization: ChannelAuthorizationOptions;\n if ('channelAuthorization' in opts) {\n channelAuthorization = {\n ...Defaults.channelAuthorization,\n ...opts.channelAuthorization\n };\n } else {\n channelAuthorization = {\n transport: opts.authTransport || Defaults.authTransport,\n endpoint: opts.authEndpoint || Defaults.authEndpoint\n };\n if ('auth' in opts) {\n if ('params' in opts.auth) channelAuthorization.params = opts.auth.params;\n if ('headers' in opts.auth)\n channelAuthorization.headers = opts.auth.headers;\n }\n if ('authorizer' in opts)\n channelAuthorization.customHandler = ChannelAuthorizerProxy(\n pusher,\n channelAuthorization,\n opts.authorizer\n );\n }\n return channelAuthorization;\n}\n\nfunction buildChannelAuthorizer(\n opts: Options,\n pusher\n): ChannelAuthorizationHandler {\n const channelAuthorization = buildChannelAuth(opts, pusher);\n if (\n 'customHandler' in channelAuthorization &&\n channelAuthorization['customHandler'] != null\n ) {\n return channelAuthorization['customHandler'];\n }\n\n return ChannelAuthorizer(channelAuthorization);\n}\n","import Logger from './logger';\nimport Pusher from './pusher';\nimport EventsDispatcher from './events/dispatcher';\n\nexport default class WatchlistFacade extends EventsDispatcher {\n private pusher: Pusher;\n\n public constructor(pusher: Pusher) {\n super(function(eventName, data) {\n Logger.debug(`No callbacks on watchlist events for ${eventName}`);\n });\n\n this.pusher = pusher;\n this.bindWatchlistInternalEvent();\n }\n\n handleEvent(pusherEvent) {\n pusherEvent.data.events.forEach(watchlistEvent => {\n this.emit(watchlistEvent.name, watchlistEvent);\n });\n }\n\n private bindWatchlistInternalEvent() {\n this.pusher.connection.bind('message', pusherEvent => {\n var eventName = pusherEvent.event;\n if (eventName === 'pusher_internal:watchlist_events') {\n this.handleEvent(pusherEvent);\n }\n });\n }\n}\n","function flatPromise() {\n let resolve, reject;\n const promise = new Promise((res, rej) => {\n resolve = res;\n reject = rej;\n });\n return { promise, resolve, reject };\n}\n\nexport default flatPromise;\n","import Pusher from './pusher';\nimport Logger from './logger';\nimport {\n UserAuthenticationData,\n UserAuthenticationCallback\n} from './auth/options';\nimport Channel from './channels/channel';\nimport WatchlistFacade from './watchlist';\nimport EventsDispatcher from './events/dispatcher';\nimport flatPromise from './utils/flat_promise';\n\nexport default class UserFacade extends EventsDispatcher {\n pusher: Pusher;\n signin_requested: boolean = false;\n user_data: any = null;\n serverToUserChannel: Channel = null;\n signinDonePromise: Promise = null;\n watchlist: WatchlistFacade;\n private _signinDoneResolve: Function = null;\n\n public constructor(pusher: Pusher) {\n super(function(eventName, data) {\n Logger.debug('No callbacks on user for ' + eventName);\n });\n this.pusher = pusher;\n this.pusher.connection.bind('state_change', ({ previous, current }) => {\n if (previous !== 'connected' && current === 'connected') {\n this._signin();\n }\n if (previous === 'connected' && current !== 'connected') {\n this._cleanup();\n this._newSigninPromiseIfNeeded();\n }\n });\n\n this.watchlist = new WatchlistFacade(pusher);\n\n this.pusher.connection.bind('message', event => {\n var eventName = event.event;\n if (eventName === 'pusher:signin_success') {\n this._onSigninSuccess(event.data);\n }\n if (\n this.serverToUserChannel &&\n this.serverToUserChannel.name === event.channel\n ) {\n this.serverToUserChannel.handleEvent(event);\n }\n });\n }\n\n public signin() {\n if (this.signin_requested) {\n return;\n }\n\n this.signin_requested = true;\n this._signin();\n }\n\n private _signin() {\n if (!this.signin_requested) {\n return;\n }\n\n this._newSigninPromiseIfNeeded();\n\n if (this.pusher.connection.state !== 'connected') {\n // Signin will be attempted when the connection is connected\n return;\n }\n\n this.pusher.config.userAuthenticator(\n {\n socketId: this.pusher.connection.socket_id\n },\n this._onAuthorize\n );\n }\n\n private _onAuthorize: UserAuthenticationCallback = (\n err,\n authData: UserAuthenticationData\n ) => {\n if (err) {\n Logger.warn(`Error during signin: ${err}`);\n this._cleanup();\n return;\n }\n\n this.pusher.send_event('pusher:signin', {\n auth: authData.auth,\n user_data: authData.user_data\n });\n\n // Later when we get pusher:singin_success event, the user will be marked as signed in\n };\n\n private _onSigninSuccess(data: any) {\n try {\n this.user_data = JSON.parse(data.user_data);\n } catch (e) {\n Logger.error(`Failed parsing user data after signin: ${data.user_data}`);\n this._cleanup();\n return;\n }\n\n if (typeof this.user_data.id !== 'string' || this.user_data.id === '') {\n Logger.error(\n `user_data doesn't contain an id. user_data: ${this.user_data}`\n );\n this._cleanup();\n return;\n }\n\n // Signin succeeded\n this._signinDoneResolve();\n this._subscribeChannels();\n }\n\n private _subscribeChannels() {\n const ensure_subscribed = channel => {\n if (channel.subscriptionPending && channel.subscriptionCancelled) {\n channel.reinstateSubscription();\n } else if (\n !channel.subscriptionPending &&\n this.pusher.connection.state === 'connected'\n ) {\n channel.subscribe();\n }\n };\n\n this.serverToUserChannel = new Channel(\n `#server-to-user-${this.user_data.id}`,\n this.pusher\n );\n this.serverToUserChannel.bind_global((eventName, data) => {\n if (\n eventName.indexOf('pusher_internal:') === 0 ||\n eventName.indexOf('pusher:') === 0\n ) {\n // ignore internal events\n return;\n }\n this.emit(eventName, data);\n });\n ensure_subscribed(this.serverToUserChannel);\n }\n\n private _cleanup() {\n this.user_data = null;\n if (this.serverToUserChannel) {\n this.serverToUserChannel.unbind_all();\n this.serverToUserChannel.disconnect();\n this.serverToUserChannel = null;\n }\n\n if (this.signin_requested) {\n // If signin is in progress and cleanup is called,\n // Mark the current signin process as done.\n this._signinDoneResolve();\n }\n }\n\n private _newSigninPromiseIfNeeded() {\n if (!this.signin_requested) {\n return;\n }\n\n // If there is a promise and it is not resolved, return without creating a new one.\n if (this.signinDonePromise && !(this.signinDonePromise as any).done) {\n return;\n }\n\n // This promise is never rejected.\n // It gets resolved when the signin process is done whether it failed or succeeded\n const { promise, resolve, reject: _ } = flatPromise();\n (promise as any).done = false;\n const setDone = () => {\n (promise as any).done = true;\n };\n promise.then(setDone).catch(setDone);\n this.signinDonePromise = promise;\n this._signinDoneResolve = resolve;\n }\n}\n","import AbstractRuntime from '../runtimes/interface';\nimport Runtime from 'runtime';\nimport * as Collections from './utils/collections';\nimport Channels from './channels/channels';\nimport Channel from './channels/channel';\nimport { default as EventsDispatcher } from './events/dispatcher';\nimport Timeline from './timeline/timeline';\nimport TimelineSender from './timeline/timeline_sender';\nimport TimelineLevel from './timeline/level';\nimport { defineTransport } from './strategies/strategy_builder';\nimport ConnectionManager from './connection/connection_manager';\nimport { PeriodicTimer } from './utils/timers';\nimport Defaults from './defaults';\nimport Logger from './logger';\nimport Factory from './utils/factory';\nimport { Options, ClusterOptions, validateOptions } from './options';\nimport { Config, getConfig } from './config';\nimport StrategyOptions from './strategies/strategy_options';\nimport UserFacade from './user';\n\nexport default class Pusher {\n /* STATIC PROPERTIES */\n static instances: Pusher[] = [];\n static isReady: boolean = false;\n static logToConsole: boolean = false;\n\n // for jsonp\n static Runtime: AbstractRuntime = Runtime;\n static ScriptReceivers: any = (Runtime).ScriptReceivers;\n static DependenciesReceivers: any = (Runtime).DependenciesReceivers;\n static auth_callbacks: any = (Runtime).auth_callbacks;\n\n static ready() {\n Pusher.isReady = true;\n for (var i = 0, l = Pusher.instances.length; i < l; i++) {\n Pusher.instances[i].connect();\n }\n }\n\n static log: (message: any) => void;\n\n private static getClientFeatures(): string[] {\n return Collections.keys(\n Collections.filterObject({ ws: Runtime.Transports.ws }, function(t) {\n return t.isSupported({});\n })\n );\n }\n\n /* INSTANCE PROPERTIES */\n key: string;\n options: Options;\n config: Config;\n channels: Channels;\n global_emitter: EventsDispatcher;\n sessionID: number;\n timeline: Timeline;\n timelineSender: TimelineSender;\n connection: ConnectionManager;\n timelineSenderTimer: PeriodicTimer;\n user: UserFacade;\n constructor(app_key: string, options: Options) {\n checkAppKey(app_key);\n validateOptions(options);\n this.key = app_key;\n this.config = getConfig(options, this);\n\n this.channels = Factory.createChannels();\n this.global_emitter = new EventsDispatcher();\n this.sessionID = Runtime.randomInt(1000000000);\n\n this.timeline = new Timeline(this.key, this.sessionID, {\n cluster: this.config.cluster,\n features: Pusher.getClientFeatures(),\n params: this.config.timelineParams || {},\n limit: 50,\n level: TimelineLevel.INFO,\n version: Defaults.VERSION\n });\n if (this.config.enableStats) {\n this.timelineSender = Factory.createTimelineSender(this.timeline, {\n host: this.config.statsHost,\n path: '/timeline/v2/' + Runtime.TimelineTransport.name\n });\n }\n\n var getStrategy = (options: StrategyOptions) => {\n return Runtime.getDefaultStrategy(this.config, options, defineTransport);\n };\n\n this.connection = Factory.createConnectionManager(this.key, {\n getStrategy: getStrategy,\n timeline: this.timeline,\n activityTimeout: this.config.activityTimeout,\n pongTimeout: this.config.pongTimeout,\n unavailableTimeout: this.config.unavailableTimeout,\n useTLS: Boolean(this.config.useTLS)\n });\n\n this.connection.bind('connected', () => {\n this.subscribeAll();\n if (this.timelineSender) {\n this.timelineSender.send(this.connection.isUsingTLS());\n }\n });\n\n this.connection.bind('message', event => {\n var eventName = event.event;\n var internal = eventName.indexOf('pusher_internal:') === 0;\n if (event.channel) {\n var channel = this.channel(event.channel);\n if (channel) {\n channel.handleEvent(event);\n }\n }\n // Emit globally [deprecated]\n if (!internal) {\n this.global_emitter.emit(event.event, event.data);\n }\n });\n this.connection.bind('connecting', () => {\n this.channels.disconnect();\n });\n this.connection.bind('disconnected', () => {\n this.channels.disconnect();\n });\n this.connection.bind('error', err => {\n Logger.warn(err);\n });\n\n Pusher.instances.push(this);\n this.timeline.info({ instances: Pusher.instances.length });\n\n this.user = new UserFacade(this);\n\n if (Pusher.isReady) {\n this.connect();\n }\n }\n\n /**\n * Allows you to switch Pusher cluster without\n * losing all the channels/subscription binding\n * as this is internally managed by the SDK.\n */\n switchCluster(options: ClusterOptions) {\n const { appKey, cluster } = options;\n this.key = appKey;\n this.options = { ...this.options, cluster };\n this.config = getConfig(this.options, this);\n this.connection.switchCluster(this.key);\n }\n\n channel(name: string): Channel {\n return this.channels.find(name);\n }\n\n allChannels(): Channel[] {\n return this.channels.all();\n }\n\n connect() {\n this.connection.connect();\n\n if (this.timelineSender) {\n if (!this.timelineSenderTimer) {\n var usingTLS = this.connection.isUsingTLS();\n var timelineSender = this.timelineSender;\n this.timelineSenderTimer = new PeriodicTimer(60000, function() {\n timelineSender.send(usingTLS);\n });\n }\n }\n }\n\n disconnect() {\n this.connection.disconnect();\n\n if (this.timelineSenderTimer) {\n this.timelineSenderTimer.ensureAborted();\n this.timelineSenderTimer = null;\n }\n }\n\n bind(event_name: string, callback: Function, context?: any): Pusher {\n this.global_emitter.bind(event_name, callback, context);\n return this;\n }\n\n unbind(event_name?: string, callback?: Function, context?: any): Pusher {\n this.global_emitter.unbind(event_name, callback, context);\n return this;\n }\n\n bind_global(callback: Function): Pusher {\n this.global_emitter.bind_global(callback);\n return this;\n }\n\n unbind_global(callback?: Function): Pusher {\n this.global_emitter.unbind_global(callback);\n return this;\n }\n\n unbind_all(callback?: Function): Pusher {\n this.global_emitter.unbind_all();\n return this;\n }\n\n subscribeAll() {\n var channelName;\n for (channelName in this.channels.channels) {\n if (this.channels.channels.hasOwnProperty(channelName)) {\n this.subscribe(channelName);\n }\n }\n }\n\n subscribe(channel_name: string) {\n var channel = this.channels.add(channel_name, this);\n if (channel.subscriptionPending && channel.subscriptionCancelled) {\n channel.reinstateSubscription();\n } else if (\n !channel.subscriptionPending &&\n this.connection.state === 'connected'\n ) {\n channel.subscribe();\n }\n return channel;\n }\n\n unsubscribe(channel_name: string) {\n var channel = this.channels.find(channel_name);\n if (channel && channel.subscriptionPending) {\n channel.cancelSubscription();\n } else {\n channel = this.channels.remove(channel_name);\n if (channel && channel.subscribed) {\n channel.unsubscribe();\n }\n }\n }\n\n send_event(event_name: string, data: any, channel?: string) {\n return this.connection.send_event(event_name, data, channel);\n }\n\n shouldUseTLS(): boolean {\n return this.config.useTLS;\n }\n\n signin() {\n this.user.signin();\n }\n}\n\nfunction checkAppKey(key) {\n if (key === null || key === undefined) {\n throw 'You must pass your app key when you instantiate Pusher.';\n }\n}\n\nRuntime.setup(Pusher);\n","import Pusher from './pusher';\nimport { Options, validateOptions } from './options';\nimport * as nacl from 'tweetnacl';\n\nexport default class PusherWithEncryption extends Pusher {\n constructor(app_key: string, options: Options) {\n Pusher.logToConsole = PusherWithEncryption.logToConsole;\n Pusher.log = PusherWithEncryption.log;\n\n validateOptions(options);\n options.nacl = nacl;\n super(app_key, options);\n }\n}\n"],"sourceRoot":""} \ No newline at end of file +{"version":3,"sources":["webpack://Pusher/webpack/bootstrap","webpack://Pusher/external \"util\"","webpack://Pusher/./node_modules/safe-buffer/index.js","webpack://Pusher/./node_modules/websocket-driver/lib/websocket/driver/base.js","webpack://Pusher/external \"crypto\"","webpack://Pusher/./node_modules/websocket-driver/lib/websocket/driver.js","webpack://Pusher/external \"stream\"","webpack://Pusher/external \"url\"","webpack://Pusher/./node_modules/faye-websocket/lib/faye/websocket/api/event.js","webpack://Pusher/./node_modules/@stablelib/base64/base64.ts","webpack://Pusher/./node_modules/websocket-driver/lib/websocket/driver/headers.js","webpack://Pusher/./node_modules/websocket-driver/lib/websocket/http_parser.js","webpack://Pusher/./node_modules/faye-websocket/lib/faye/websocket/api.js","webpack://Pusher/./node_modules/websocket-driver/lib/websocket/driver/hybi.js","webpack://Pusher/./node_modules/websocket-extensions/lib/pipeline/ring_buffer.js","webpack://Pusher/./node_modules/websocket-extensions/lib/pipeline/pledge.js","webpack://Pusher/./node_modules/websocket-driver/lib/websocket/driver/draft75.js","webpack://Pusher/./node_modules/faye-websocket/lib/faye/websocket/api/event_target.js","webpack://Pusher/./node_modules/@stablelib/utf8/utf8.ts","webpack://Pusher/./node_modules/faye-websocket/lib/faye/websocket.js","webpack://Pusher/./node_modules/xmlhttprequest/lib/XMLHttpRequest.js","webpack://Pusher/./node_modules/tweetnacl/nacl-fast.js","webpack://Pusher/./src/core/pusher-with-encryption.js","webpack://Pusher/external \"buffer\"","webpack://Pusher/external \"events\"","webpack://Pusher/./node_modules/websocket-driver/lib/websocket/streams.js","webpack://Pusher/./node_modules/websocket-driver/lib/websocket/driver/stream_reader.js","webpack://Pusher/./node_modules/websocket-driver/lib/websocket/driver/client.js","webpack://Pusher/./node_modules/http-parser-js/http-parser.js","webpack://Pusher/external \"assert\"","webpack://Pusher/./node_modules/websocket-extensions/lib/websocket_extensions.js","webpack://Pusher/./node_modules/websocket-extensions/lib/parser.js","webpack://Pusher/./node_modules/websocket-extensions/lib/pipeline/index.js","webpack://Pusher/./node_modules/websocket-extensions/lib/pipeline/cell.js","webpack://Pusher/./node_modules/websocket-extensions/lib/pipeline/functor.js","webpack://Pusher/./node_modules/websocket-driver/lib/websocket/driver/hybi/frame.js","webpack://Pusher/./node_modules/websocket-driver/lib/websocket/driver/hybi/message.js","webpack://Pusher/./node_modules/websocket-driver/lib/websocket/driver/proxy.js","webpack://Pusher/./node_modules/websocket-driver/lib/websocket/driver/server.js","webpack://Pusher/./node_modules/websocket-driver/lib/websocket/driver/draft76.js","webpack://Pusher/./node_modules/faye-websocket/lib/faye/websocket/client.js","webpack://Pusher/external \"net\"","webpack://Pusher/external \"tls\"","webpack://Pusher/./node_modules/faye-websocket/lib/faye/eventsource.js","webpack://Pusher/external \"child_process\"","webpack://Pusher/external \"fs\"","webpack://Pusher/external \"http\"","webpack://Pusher/external \"https\"","webpack://Pusher/./src/core/base64.ts","webpack://Pusher/./src/core/utils/timers/abstract_timer.ts","webpack://Pusher/./src/core/utils/timers/index.ts","webpack://Pusher/./src/core/util.ts","webpack://Pusher/./src/core/utils/collections.ts","webpack://Pusher/./src/core/defaults.ts","webpack://Pusher/./src/core/transports/url_schemes.ts","webpack://Pusher/./src/core/events/callback_registry.ts","webpack://Pusher/./src/core/events/dispatcher.ts","webpack://Pusher/./src/core/logger.ts","webpack://Pusher/./src/core/transports/transport_connection.ts","webpack://Pusher/./src/core/transports/transport.ts","webpack://Pusher/./src/runtimes/isomorphic/transports/transports.ts","webpack://Pusher/./src/core/transports/assistant_to_the_transport_manager.ts","webpack://Pusher/./src/core/connection/protocol/protocol.ts","webpack://Pusher/./src/core/connection/connection.ts","webpack://Pusher/./src/core/connection/handshake/index.ts","webpack://Pusher/./src/core/timeline/timeline_sender.ts","webpack://Pusher/./src/core/errors.ts","webpack://Pusher/./src/core/utils/url_store.ts","webpack://Pusher/./src/core/channels/channel.ts","webpack://Pusher/./src/core/channels/private_channel.ts","webpack://Pusher/./src/core/channels/members.ts","webpack://Pusher/./src/core/channels/presence_channel.ts","webpack://Pusher/./src/core/channels/encrypted_channel.ts","webpack://Pusher/./src/core/connection/connection_manager.ts","webpack://Pusher/./src/core/channels/channels.ts","webpack://Pusher/./src/core/utils/factory.ts","webpack://Pusher/./src/core/transports/transport_manager.ts","webpack://Pusher/./src/core/strategies/sequential_strategy.ts","webpack://Pusher/./src/core/strategies/best_connected_ever_strategy.ts","webpack://Pusher/./src/core/strategies/websocket_prioritized_cached_strategy.ts","webpack://Pusher/./src/core/strategies/delayed_strategy.ts","webpack://Pusher/./src/core/strategies/if_strategy.ts","webpack://Pusher/./src/core/strategies/first_connected_strategy.ts","webpack://Pusher/./src/runtimes/isomorphic/default_strategy.ts","webpack://Pusher/./src/runtimes/isomorphic/transports/transport_connection_initializer.ts","webpack://Pusher/./src/core/http/http_request.ts","webpack://Pusher/./src/core/http/state.ts","webpack://Pusher/./src/core/http/http_socket.ts","webpack://Pusher/./src/core/http/http_streaming_socket.ts","webpack://Pusher/./src/core/http/http_polling_socket.ts","webpack://Pusher/./src/runtimes/isomorphic/http/http_xhr_request.ts","webpack://Pusher/./src/runtimes/isomorphic/http/http.ts","webpack://Pusher/./src/runtimes/isomorphic/runtime.ts","webpack://Pusher/./src/runtimes/node/net_info.ts","webpack://Pusher/./src/core/auth/options.ts","webpack://Pusher/./src/runtimes/isomorphic/auth/xhr_auth.ts","webpack://Pusher/./src/runtimes/isomorphic/timeline/xhr_timeline.ts","webpack://Pusher/./src/runtimes/node/runtime.ts","webpack://Pusher/./src/core/timeline/level.ts","webpack://Pusher/./src/core/timeline/timeline.ts","webpack://Pusher/./src/core/strategies/transport_strategy.ts","webpack://Pusher/./src/core/strategies/strategy_builder.ts","webpack://Pusher/./src/core/options.ts","webpack://Pusher/./src/core/auth/user_authenticator.ts","webpack://Pusher/./src/core/auth/channel_authorizer.ts","webpack://Pusher/./src/core/auth/deprecated_channel_authorizer.ts","webpack://Pusher/./src/core/config.ts","webpack://Pusher/./src/core/watchlist.ts","webpack://Pusher/./src/core/utils/flat_promise.ts","webpack://Pusher/./src/core/user.ts","webpack://Pusher/./src/core/pusher.ts","webpack://Pusher/./src/core/pusher-with-encryption.ts"],"names":[],"mappings":";;;;;;;;;;QAAA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;;QAEA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;;;QAGA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;QACA,0CAA0C,gCAAgC;QAC1E;QACA;;QAEA;QACA;QACA;QACA,wDAAwD,kBAAkB;QAC1E;QACA,iDAAiD,cAAc;QAC/D;;QAEA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA,yCAAyC,iCAAiC;QAC1E,gHAAgH,mBAAmB,EAAE;QACrI;QACA;;QAEA;QACA;QACA;QACA,2BAA2B,0BAA0B,EAAE;QACvD,iCAAiC,eAAe;QAChD;QACA;QACA;;QAEA;QACA,sDAAsD,+DAA+D;;QAErH;QACA;;;QAGA;QACA;;;;;;;AClFA,iC;;;;;;ACAA;AACA,aAAa,mBAAO,CAAC,EAAQ;AAC7B;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AACD;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;;;;;;;AC7Da;;AAEb,cAAc,mBAAO,CAAC,CAAa;AACnC,cAAc,mBAAO,CAAC,EAAQ;AAC9B,cAAc,mBAAO,CAAC,CAAM;AAC5B,cAAc,mBAAO,CAAC,EAAY;AAClC,cAAc,mBAAO,CAAC,CAAW;AACjC,cAAc,mBAAO,CAAC,EAAiB;;AAEvC;AACA;AACA,oCAAoC;;AAEpC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA,2CAA2C;;AAE3C;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA,KAAK;AACL,GAAG;;AAEH;AACA;AACA,GAAG;;AAEH;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA;AACA,GAAG;;AAEH;AACA;;AAEA;AACA;;AAEA;;AAEA;AACA;AACA,KAAK;AACL;AACA;;AAEA;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA,GAAG;;AAEH;AACA;AACA,GAAG;;AAEH;AACA;AACA,GAAG;;AAEH;AACA;AACA,GAAG;;AAEH;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA,yCAAyC,+BAA+B;AACxE;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;;AAGA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;;;;;;;AChMA,mC;;;;;;;ACAa;;AAEb;AACA;AACA;AACA;AACA;;AAEA,aAAa,mBAAO,CAAC,CAAe;AACpC,aAAa,mBAAO,CAAC,EAAiB;AACtC,aAAa,mBAAO,CAAC,EAAiB;;AAEtC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;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,sDAAsD,yBAAyB;AAC/E;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;;;;;;;;ACtIa;;AAEb,kBAAkB,mBAAO,CAAC,CAAQ;AAClC,kBAAkB,mBAAO,CAAC,CAAM;AAChC,kBAAkB,mBAAO,CAAC,CAAkB;AAC5C,kBAAkB,mBAAO,CAAC,EAAoB;AAC9C,kBAAkB,mBAAO,CAAC,CAAa;;AAEvC;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA,0CAA0C,eAAe;AACzD,0CAA0C,+BAA+B;AACzE,0CAA0C,qCAAqC;;AAE/E;AACA;AACA,GAAG;AACH,gCAAgC;;AAEhC;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA;AACA,KAAK;;AAEL;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA,GAAG;;AAEH;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA,KAAK;;AAEL;AACA,GAAG;;AAEH;AACA;;AAEA;AACA;;AAEA;AACA,yCAAyC,wBAAwB;AACjE,KAAK;;AAEL;AACA;AACA;AACA,KAAK;AACL,GAAG;;AAEH;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,GAAG;;AAEH;AACA;;AAEA;;AAEA,sCAAsC,WAAW;AACjD;AACA;AACA,GAAG;;AAEH;AACA;;AAEA,oCAAoC,iBAAiB;AACrD;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA,oCAAoC,2BAA2B;AAC/D;AACA;AACA;AACA;;AAEA;AACA;;AAEA;;;;;;;;ACpMa;;AAEb,iBAAiB,mBAAO,CAAC,CAAa;AACtC,iBAAiB,mBAAO,CAAC,CAAQ;AACjC,iBAAiB,mBAAO,CAAC,CAAM;AAC/B,iBAAiB,mBAAO,CAAC,EAAsB;AAC/C,iBAAiB,mBAAO,CAAC,CAAQ;AACjC,iBAAiB,mBAAO,CAAC,EAAc;AACvC,iBAAiB,mBAAO,CAAC,EAAgB;;AAEzC;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA;AACA,+CAA+C,mCAAmC;AAClF;;AAEA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;;AAEA,8CAA8C,OAAO;AACrD;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA;;AAEA;AACA,8GAA8G,EAAE,uDAAuD,EAAE,wBAAwB,EAAE,4BAA4B,EAAE;;AAEjO;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA,yCAAyC,oCAAoC;AAC7E;AACA,KAAK;AACL;AACA;AACA,GAAG;;AAEH;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;;AAEA;AACA,GAAG;;AAEH;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,KAAK;AACL;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;AACA,GAAG;;AAEH;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA,GAAG;;AAEH;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL,GAAG;;AAEH;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA,KAAK;;AAEL;;AAEA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;;AAEA;AACA;AACA,GAAG;;AAEH;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA,GAAG;;AAEH;AACA;;AAEA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA,GAAG;;AAEH;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA,KAAK;AACL,GAAG;;AAEH;AACA;AACA;AACA;AACA,KAAK;AACL;AACA,GAAG;;AAEH;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;;;;;;;;AClea;;AAEb;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA,GAAG;AACH;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;;AAEA;;;;;;;;ACjEa;;AAEb,iBAAiB,mBAAO,CAAC,EAAe;;AAExC;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA,GAAG;AACH;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;;;;;;;;ACpCa;;AAEb,aAAa,mBAAO,CAAC,CAAa;AAClC,aAAa,mBAAO,CAAC,CAAQ;AAC7B,aAAa,mBAAO,CAAC,CAAM;;AAE3B;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;;AAEH;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;A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ACA;;AAEA;AACA,uCAAuC,mDAAmD;;AAE1F;AACA;AACA;;AAEA,4BAA4B;AAC5B;;AAEA;;AAEA;AACA;AACA;AACA,GAAG;AACH;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA,wBAAwB,mBAAO,CAAC,EAAoB;AACpD,wBAAwB,mBAAO,CAAC,EAAe;;AAE/C;;;;;;;AC9CA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,UAAU,mBAAO,CAAC,CAAK;AACvB,YAAY,mBAAO,CAAC,EAAe;AACnC,SAAS,mBAAO,CAAC,EAAI;;AAErB;AACA;;AAEA;AACA;AACA;AACA;AACA,aAAa,mBAAO,CAAC,EAAM;AAC3B,cAAc,mBAAO,CAAC,EAAO;;AAE7B;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,WAAW;AACX;AACA;AACA;AACA;AACA,SAAS;AACT,OAAO;AACP;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,KAAK;AACL;;AAEA;AACA,8CAA8C;AAC9C;AACA,KAAK;AACL;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;;AAET;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;;AAET;AACA;AACA,SAAS;AACT;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;;AAEA;AACA,KAAK,OAAO;AACZ;AACA;AACA;AACA;AACA;AACA,iGAAiG;AACjG,gEAAgE;AAChE,yDAAyD;AACzD,iCAAiC;AACjC,4DAA4D;AAC5D,wCAAwC;AACxC,gDAAgD;AAChD,mCAAmC;AACnC,YAAY,EAAE;AACd,0CAA0C;AAC1C,mEAAmE,kBAAkB,gFAAgF,WAAW;AAChL,6CAA6C;AAC7C,YAAY,EAAE;AACd,iDAAiD;AACjD,mEAAmE,WAAW,WAAW;AACzF,6CAA6C;AAC7C,YAAY,EAAE;AACd,YAAY,+BAA+B;AAC3C,mEAAmE,WAAW,WAAW;AACzF,6CAA6C;AAC7C,YAAY,EAAE;AACd,8FAA8F;AAC9F,qBAAqB;AACrB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,OAAO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,oDAAoD,SAAS;AAC7D;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;AC3mBA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,uBAAuB,iBAAiB;AACxC;AACA;;AAEA;AACA,wCAAwC,4BAA4B;;AAEpE;AACA,4BAA4B;;AAE5B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa,OAAO;AACpB;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,aAAa,QAAQ;AACrB,aAAa,OAAO;AACpB;AACA;AACA,eAAe,QAAQ;AACvB;AACA,eAAe,QAAQ;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB;AACA;AACA;;AAEA;AACA;AACA;AACA,aAAa,QAAQ;AACrB,aAAa,OAAO;AACpB;AACA;AACA,eAAe,QAAQ;AACvB;AACA,eAAe,QAAQ;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,iBAAiB,OAAO;AACxB;AACA;;AAEA;AACA;AACA;AACA;AACA,iBAAiB,OAAO;AACxB;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA,8CAA8C;AAC9C,8CAA8C;AAC9C,8CAA8C;AAC9C,8CAA8C;AAC9C,8CAA8C;AAC9C;AACA,8CAA8C;AAC9C,8CAA8C;AAC9C,8CAA8C;AAC9C;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,sDAAsD;AACtD,sDAAsD;AACtD,sDAAsD;AACtD,sDAAsD;AACtD,sDAAsD;AACtD;AACA,sDAAsD;AACtD,sDAAsD;AACtD,sDAAsD;AACtD;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA,qBAAqB;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA,qBAAqB;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA,qBAAqB;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA,qBAAqB;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA,qBAAqB;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA,qBAAqB;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA,qBAAqB;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA,qBAAqB;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA,qBAAqB;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA,qBAAqB;;AAErB;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA,UAAU,QAAQ;AAClB;AACA;AACA;;AAEA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA;AACA;;AAEA;AACA,aAAa,QAAQ;AACrB;AACA,aAAa,QAAQ;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa,OAAO;AACpB;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,UAAU;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,eAAe,WAAW;AAC1B;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;;AAEA;AACA;AACA,aAAa,QAAQ;AACrB;;AAEA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA,aAAa,OAAO;AACpB;AACA,eAAe,QAAQ;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;;AAEA;AACA,iBAAiB,QAAQ;AACzB;;AAEA;AACA,iBAAiB,QAAQ;AACzB;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD;;AAEA;AACA;AACA,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA,aAAa,QAAQ;AACrB,eAAe,QAAQ;AACvB;AACA;AACA;AACA,aAAa,QAAQ;AACrB;;AAEA;AACA;AACA;AACA,aAAa,QAAQ;AACrB,eAAe,QAAQ;AACvB;AACA;AACA;AACA,aAAa,QAAQ;AACrB;;AAEA;AACA;AACA;AACA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA;AACA,aAAa,MAAM;AACnB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,eAAe,QAAQ;AACvB;AACA;AACA;AACA;AACA,eAAe,QAAQ;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA,qBAAqB;AACrB,qBAAqB;;AAErB;AACA;AACA;;AAEA,sBAAsB;AACtB,sBAAsB;;AAEtB;AACA;AACA;;AAEA,sBAAsB;AACtB,sBAAsB;;AAEtB;AACA;AACA;;AAEA,sBAAsB;AACtB,sBAAsB;;AAEtB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B;;AAEnB;AACA;;AAEA,oBAAoB;AACpB,oBAAoB;;AAEpB;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA,mBAAmB;AACnB,mBAAmB;;AAEnB;AACA;;AAEA,oBAAoB;AACpB,oBAAoB;;AAEpB;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA,mBAAmB;AACnB,mBAAmB;;AAEnB;AACA;;AAEA,oBAAoB;AACpB,oBAAoB;;AAEpB;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA,mBAAmB;AACnB,mBAAmB;;AAEnB;AACA;;AAEA,oBAAoB;AACpB,oBAAoB;;AAEpB;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA,aAAa,OAAO;AACpB;;AAEA;AACA;AACA;AACA;;AAEA,aAAa,OAAO;;AAEpB;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa,OAAO;AACpB;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,QAAQ;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA,aAAa,QAAQ;AACrB;AACA;;AAEA;;AAEA;AACA;AACA,cAAc,SAAS;AACvB;AACA,gCAAgC,OAAO;AACvC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA;AACA,aAAa,QAAQ;AACrB,aAAa,QAAQ;AACrB;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa,QAAQ;AACrB,aAAa,QAAQ;AACrB;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA,aAAa,OAAO;AACpB,aAAa,QAAQ;;AAErB;AACA;AACA;AACA;;AAEA,cAAc,QAAQ;AACtB;AACA;;AAEA,aAAa,QAAQ;AACrB,aAAa,QAAQ;AACrB,aAAa,QAAQ;AACrB,eAAe,QAAQ;AACvB;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;;AAEA,aAAa,OAAO;AACpB,aAAa,QAAQ;AACrB;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA,eAAe,OAAO;AACtB;AACA;;AAEA,aAAa,OAAO;AACpB;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA,iBAAiB,sBAAsB;AACvC;AACA;AACA;AACA;;AAEA;AACA,iBAAiB,gBAAgB;AACjC;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,iBAAiB,gBAAgB;AACjC;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,iBAAiB,gBAAgB;AACjC;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA,UAAU;AACV;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,UAAU;AACV;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAiB,cAAc;AAC/B;AACA;;AAEA;AACA;AACA;AACA,iBAAiB,gBAAgB;AACjC;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa,uBAAuB;AACpC,aAAa,gBAAgB;AAC7B;AACA;;AAEA;AACA;AACA;AACA;AACA,UAAU;AACV;;AAEA;AACA;AACA;AACA;AACA;AACA,iBAAiB,eAAe;AAChC,UAAU;AACV;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAiB,QAAQ;AACzB;AACA,UAAU;AACV;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAiB,OAAO;AACxB;AACA;AACA,iBAAiB,OAAO;AACxB;AACA,KAAK;AACL,GAAG,UAAU,IAA8B;AAC3C;AACA,aAAa,mBAAO,CAAC,CAAQ;AAC7B;AACA;AACA;AACA,mBAAmB,OAAO;AAC1B;AACA,OAAO;AACP;AACA;AACA,CAAC;;AAED,CAAC,EAAE,KAA6B,kEAAkE;;;;;;;ACt1ElG,iBAAiB,mBAAO,CAAC,EAA0B;;;;;;;ACAnD,mC;;;;;;ACAA,mC;;;;;;;ACAa;;AAEb;;AAEA;AACA;;AAEA;AACA;;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AAGA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;;AAGA,aAAa,mBAAO,CAAC,CAAQ;AAC7B,aAAa,mBAAO,CAAC,CAAM;;;AAG3B;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;;AAGA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;;AAGA;AACA;;;;;;;;ACjJa;;AAEb,aAAa,mBAAO,CAAC,CAAa;;AAElC;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;;AAEA,mCAAmC,OAAO;AAC1C;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;;;;;;;ACpEa;;AAEb,iBAAiB,mBAAO,CAAC,CAAa;AACtC,iBAAiB,mBAAO,CAAC,CAAQ;AACjC,iBAAiB,mBAAO,CAAC,CAAK;AAC9B,iBAAiB,mBAAO,CAAC,CAAM;AAC/B,iBAAiB,mBAAO,CAAC,EAAgB;AACzC,iBAAiB,mBAAO,CAAC,CAAQ;AACjC,iBAAiB,mBAAO,CAAC,EAAQ;AACjC,iBAAiB,mBAAO,CAAC,EAAS;;AAElC;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA,GAAG;;AAEH;AACA;AACA;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;;AAEA;AACA;;AAEA;;;;;;;AC7IA;;AAEA,aAAa,mBAAO,CAAC,EAAQ;;AAE7B;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,sBAAsB;AACtB;AACA;AACA;AACA;;AAEA;AACA,qCAAqC;AACrC;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,8CAA8C,UAAU;;AAExD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,2BAA2B,SAAS;AACpC,4BAA4B;AAC5B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,UAAU;AACV;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,yCAAyC,EAAE;AAC3C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA,mDAAmD;AACnD;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA,mBAAmB,oBAAoB;AACvC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW;AACX;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA,KAAK;AACL;AACA;AACA,kCAAkC;AAClC;AACA,KAAK;AACL;AACA,KAAK;AACL;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH,CAAC;;AAED;AACA;AACA;AACA;AACA;;;;;;;AC9cA,mC;;;;;;;ACAa;;AAEb,eAAe,mBAAO,CAAC,EAAU;AACjC,eAAe,mBAAO,CAAC,EAAY;;AAEnC;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA,OAAO;AACP,KAAK;;AAEL;AACA;;AAEA;AACA,GAAG;;AAEH;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA,KAAK;;AAEL;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,KAAK;;AAEL;AACA;;AAEA;AACA,GAAG;;AAEH;AACA,mBAAmB,wCAAwC;AAC3D;;AAEA;AACA,gDAAgD,OAAO;AACvD;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA,GAAG;;AAEH;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;;;;;;;;ACjKa;;AAEb;AACA;AACA;AACA;AACA,gDAAgD;AAChD;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA,SAAS;AACT;AACA,SAAS;AACT;AACA;AACA;;AAEA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA,OAAO;AACP;AACA,KAAK;;AAEL;AACA,GAAG;;AAEH;AACA;;AAEA;AACA;AACA,mCAAmC,gBAAgB;AACnD,OAAO;AACP;AACA,OAAO;AACP;AACA,OAAO;AACP;AACA,OAAO;AACP;AACA;AACA;;AAEA;;AAEA,wCAAwC;AACxC;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA,sBAAsB,6BAA6B;AACnD;;AAEA;AACA;AACA,kCAAkC,OAAO;AACzC;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;;;;;;;;ACtGa;;AAEb,aAAa,mBAAO,CAAC,EAAQ;AAC7B,aAAa,mBAAO,CAAC,EAAU;;AAE/B;AACA,kDAAkD,2BAA2B;AAC7E,mBAAmB;AACnB;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA,mBAAmB;;AAEnB,4CAA4C,mBAAmB;AAC/D;AACA,wCAAwC,yBAAyB;AACjE;;AAEA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;;AAEA;;;;;;;;AC9Ca;;AAEb,cAAc,mBAAO,CAAC,EAAW;AACjC,cAAc,mBAAO,CAAC,EAAU;;AAEhC;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;;;;;;;;ACpDa;;AAEb,iBAAiB,mBAAO,CAAC,EAAe;;AAExC;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA,gBAAgB,oFAAoF;AACpG;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA,GAAG;AACH;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;;AAEA;;;;;;;;ACvEa;;AAEb;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;;;;;;;;ACpBa;;AAEb,aAAa,mBAAO,CAAC,CAAa;;AAElC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;;;;;;;;ACjCa;;AAEb,iBAAiB,mBAAO,CAAC,CAAa;AACtC,iBAAiB,mBAAO,CAAC,CAAQ;AACjC,iBAAiB,mBAAO,CAAC,CAAK;AAC9B,iBAAiB,mBAAO,CAAC,CAAM;AAC/B,iBAAiB,mBAAO,CAAC,CAAQ;AACjC,iBAAiB,mBAAO,CAAC,CAAW;AACpC,iBAAiB,mBAAO,CAAC,EAAgB;;AAEzC,aAAa;;AAEb;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;;AAEA;AACA;AACA;;AAEA;;AAEA;AACA;AACA,GAAG;;AAEH;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA,GAAG;;AAEH;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA;;AAEA;AACA;;AAEA;;;;;;;;AClGa;;AAEb,iBAAiB,mBAAO,CAAC,CAAM;AAC/B,iBAAiB,mBAAO,CAAC,EAAgB;AACzC,iBAAiB,mBAAO,CAAC,CAAQ;AACjC,iBAAiB,mBAAO,CAAC,EAAW;AACpC,iBAAiB,mBAAO,CAAC,EAAW;AACpC,iBAAiB,mBAAO,CAAC,EAAQ;;AAEjC;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA,2CAA2C;AAC3C,kCAAkC;AAClC,GAAG;;AAEH;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA,4CAA4C,sBAAsB;AAClE,KAAK;;AAEL;AACA;;AAEA;AACA;AACA,GAAG;;AAEH;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA,CAAC;;AAED;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA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AAC;QACzB,OAAO,CAAC,IAAI,GAAG,SAAI,CAAC;QACpB,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAC1B,CAAC;CACF","file":"pusher.js","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 21);\n","module.exports = require(\"util\");","/* eslint-disable node/no-deprecated-api */\nvar buffer = require('buffer')\nvar Buffer = buffer.Buffer\n\n// alternative to using Object.keys for old browsers\nfunction copyProps (src, dst) {\n for (var key in src) {\n dst[key] = src[key]\n }\n}\nif (Buffer.from && Buffer.alloc && Buffer.allocUnsafe && Buffer.allocUnsafeSlow) {\n module.exports = buffer\n} else {\n // Copy properties from require('buffer')\n copyProps(buffer, exports)\n exports.Buffer = SafeBuffer\n}\n\nfunction SafeBuffer (arg, encodingOrOffset, length) {\n return Buffer(arg, encodingOrOffset, length)\n}\n\n// Copy static methods from Buffer\ncopyProps(Buffer, SafeBuffer)\n\nSafeBuffer.from = function (arg, encodingOrOffset, length) {\n if (typeof arg === 'number') {\n throw new TypeError('Argument must not be a number')\n }\n return Buffer(arg, encodingOrOffset, length)\n}\n\nSafeBuffer.alloc = function (size, fill, encoding) {\n if (typeof size !== 'number') {\n throw new TypeError('Argument must be a number')\n }\n var buf = Buffer(size)\n if (fill !== undefined) {\n if (typeof encoding === 'string') {\n buf.fill(fill, encoding)\n } else {\n buf.fill(fill)\n }\n } else {\n buf.fill(0)\n }\n return buf\n}\n\nSafeBuffer.allocUnsafe = function (size) {\n if (typeof size !== 'number') {\n throw new TypeError('Argument must be a number')\n }\n return Buffer(size)\n}\n\nSafeBuffer.allocUnsafeSlow = function (size) {\n if (typeof size !== 'number') {\n throw new TypeError('Argument must be a number')\n }\n return buffer.SlowBuffer(size)\n}\n","'use strict';\n\nvar Buffer = require('safe-buffer').Buffer,\n Emitter = require('events').EventEmitter,\n util = require('util'),\n streams = require('../streams'),\n Headers = require('./headers'),\n Reader = require('./stream_reader');\n\nvar Base = function(request, url, options) {\n Emitter.call(this);\n Base.validateOptions(options || {}, ['maxLength', 'masking', 'requireMasking', 'protocols']);\n\n this._request = request;\n this._reader = new Reader();\n this._options = options || {};\n this._maxLength = this._options.maxLength || this.MAX_LENGTH;\n this._headers = new Headers();\n this.__queue = [];\n this.readyState = 0;\n this.url = url;\n\n this.io = new streams.IO(this);\n this.messages = new streams.Messages(this);\n this._bindEventListeners();\n};\nutil.inherits(Base, Emitter);\n\nBase.isWebSocket = function(request) {\n var connection = request.headers.connection || '',\n upgrade = request.headers.upgrade || '';\n\n return request.method === 'GET' &&\n connection.toLowerCase().split(/ *, */).indexOf('upgrade') >= 0 &&\n upgrade.toLowerCase() === 'websocket';\n};\n\nBase.validateOptions = function(options, validKeys) {\n for (var key in options) {\n if (validKeys.indexOf(key) < 0)\n throw new Error('Unrecognized option: ' + key);\n }\n};\n\nvar instance = {\n // This is 64MB, small enough for an average VPS to handle without\n // crashing from process out of memory\n MAX_LENGTH: 0x3ffffff,\n\n STATES: ['connecting', 'open', 'closing', 'closed'],\n\n _bindEventListeners: function() {\n var self = this;\n\n // Protocol errors are informational and do not have to be handled\n this.messages.on('error', function() {});\n\n this.on('message', function(event) {\n var messages = self.messages;\n if (messages.readable) messages.emit('data', event.data);\n });\n\n this.on('error', function(error) {\n var messages = self.messages;\n if (messages.readable) messages.emit('error', error);\n });\n\n this.on('close', function() {\n var messages = self.messages;\n if (!messages.readable) return;\n messages.readable = messages.writable = false;\n messages.emit('end');\n });\n },\n\n getState: function() {\n return this.STATES[this.readyState] || null;\n },\n\n addExtension: function(extension) {\n return false;\n },\n\n setHeader: function(name, value) {\n if (this.readyState > 0) return false;\n this._headers.set(name, value);\n return true;\n },\n\n start: function() {\n if (this.readyState !== 0) return false;\n\n if (!Base.isWebSocket(this._request))\n return this._failHandshake(new Error('Not a WebSocket request'));\n\n var response;\n\n try {\n response = this._handshakeResponse();\n } catch (error) {\n return this._failHandshake(error);\n }\n\n this._write(response);\n if (this._stage !== -1) this._open();\n return true;\n },\n\n _failHandshake: function(error) {\n var headers = new Headers();\n headers.set('Content-Type', 'text/plain');\n headers.set('Content-Length', Buffer.byteLength(error.message, 'utf8'));\n\n headers = ['HTTP/1.1 400 Bad Request', headers.toString(), error.message];\n this._write(Buffer.from(headers.join('\\r\\n'), 'utf8'));\n this._fail('protocol_error', error.message);\n\n return false;\n },\n\n text: function(message) {\n return this.frame(message);\n },\n\n binary: function(message) {\n return false;\n },\n\n ping: function() {\n return false;\n },\n\n pong: function() {\n return false;\n },\n\n close: function(reason, code) {\n if (this.readyState !== 1) return false;\n this.readyState = 3;\n this.emit('close', new Base.CloseEvent(null, null));\n return true;\n },\n\n _open: function() {\n this.readyState = 1;\n this.__queue.forEach(function(args) { this.frame.apply(this, args) }, this);\n this.__queue = [];\n this.emit('open', new Base.OpenEvent());\n },\n\n _queue: function(message) {\n this.__queue.push(message);\n return true;\n },\n\n _write: function(chunk) {\n var io = this.io;\n if (io.readable) io.emit('data', chunk);\n },\n\n _fail: function(type, message) {\n this.readyState = 2;\n this.emit('error', new Error(message));\n this.close();\n }\n};\n\nfor (var key in instance)\n Base.prototype[key] = instance[key];\n\n\nBase.ConnectEvent = function() {};\n\nBase.OpenEvent = function() {};\n\nBase.CloseEvent = function(code, reason) {\n this.code = code;\n this.reason = reason;\n};\n\nBase.MessageEvent = function(data) {\n this.data = data;\n};\n\nBase.PingEvent = function(data) {\n this.data = data;\n};\n\nBase.PongEvent = function(data) {\n this.data = data;\n};\n\nmodule.exports = Base;\n","module.exports = require(\"crypto\");","'use strict';\n\n// Protocol references:\n//\n// * http://tools.ietf.org/html/draft-hixie-thewebsocketprotocol-75\n// * http://tools.ietf.org/html/draft-hixie-thewebsocketprotocol-76\n// * http://tools.ietf.org/html/draft-ietf-hybi-thewebsocketprotocol-17\n\nvar Base = require('./driver/base'),\n Client = require('./driver/client'),\n Server = require('./driver/server');\n\nvar Driver = {\n client: function(url, options) {\n options = options || {};\n if (options.masking === undefined) options.masking = true;\n return new Client(url, options);\n },\n\n server: function(options) {\n options = options || {};\n if (options.requireMasking === undefined) options.requireMasking = true;\n return new Server(options);\n },\n\n http: function() {\n return Server.http.apply(Server, arguments);\n },\n\n isSecureRequest: function(request) {\n return Server.isSecureRequest(request);\n },\n\n isWebSocket: function(request) {\n return Base.isWebSocket(request);\n },\n\n validateOptions: function(options, validKeys) {\n Base.validateOptions(options, validKeys);\n }\n};\n\nmodule.exports = Driver;\n","module.exports = require(\"stream\");","module.exports = require(\"url\");","'use strict';\n\nvar Event = function(eventType, options) {\n this.type = eventType;\n for (var key in options)\n this[key] = options[key];\n};\n\nEvent.prototype.initEvent = function(eventType, canBubble, cancelable) {\n this.type = eventType;\n this.bubbles = canBubble;\n this.cancelable = cancelable;\n};\n\nEvent.prototype.stopPropagation = function() {};\nEvent.prototype.preventDefault = function() {};\n\nEvent.CAPTURING_PHASE = 1;\nEvent.AT_TARGET = 2;\nEvent.BUBBLING_PHASE = 3;\n\nmodule.exports = Event;\n","// Copyright (C) 2016 Dmitry Chestnykh\n// MIT License. See LICENSE file for details.\n\n/**\n * Package base64 implements Base64 encoding and decoding.\n */\n\n// Invalid character used in decoding to indicate\n// that the character to decode is out of range of\n// alphabet and cannot be decoded.\nconst INVALID_BYTE = 256;\n\n/**\n * Implements standard Base64 encoding.\n *\n * Operates in constant time.\n */\nexport class Coder {\n // TODO(dchest): methods to encode chunk-by-chunk.\n\n constructor(private _paddingCharacter = \"=\") { }\n\n encodedLength(length: number): number {\n if (!this._paddingCharacter) {\n return (length * 8 + 5) / 6 | 0;\n }\n return (length + 2) / 3 * 4 | 0;\n }\n\n encode(data: Uint8Array): string {\n let out = \"\";\n\n let i = 0;\n for (; i < data.length - 2; i += 3) {\n let c = (data[i] << 16) | (data[i + 1] << 8) | (data[i + 2]);\n out += this._encodeByte((c >>> 3 * 6) & 63);\n out += this._encodeByte((c >>> 2 * 6) & 63);\n out += this._encodeByte((c >>> 1 * 6) & 63);\n out += this._encodeByte((c >>> 0 * 6) & 63);\n }\n\n const left = data.length - i;\n if (left > 0) {\n let c = (data[i] << 16) | (left === 2 ? data[i + 1] << 8 : 0);\n out += this._encodeByte((c >>> 3 * 6) & 63);\n out += this._encodeByte((c >>> 2 * 6) & 63);\n if (left === 2) {\n out += this._encodeByte((c >>> 1 * 6) & 63);\n } else {\n out += this._paddingCharacter || \"\";\n }\n out += this._paddingCharacter || \"\";\n }\n\n return out;\n }\n\n maxDecodedLength(length: number): number {\n if (!this._paddingCharacter) {\n return (length * 6 + 7) / 8 | 0;\n }\n return length / 4 * 3 | 0;\n }\n\n decodedLength(s: string): number {\n return this.maxDecodedLength(s.length - this._getPaddingLength(s));\n }\n\n decode(s: string): Uint8Array {\n if (s.length === 0) {\n return new Uint8Array(0);\n }\n const paddingLength = this._getPaddingLength(s);\n const length = s.length - paddingLength;\n const out = new Uint8Array(this.maxDecodedLength(length));\n let op = 0;\n let i = 0;\n let haveBad = 0;\n let v0 = 0, v1 = 0, v2 = 0, v3 = 0;\n for (; i < length - 4; i += 4) {\n v0 = this._decodeChar(s.charCodeAt(i + 0));\n v1 = this._decodeChar(s.charCodeAt(i + 1));\n v2 = this._decodeChar(s.charCodeAt(i + 2));\n v3 = this._decodeChar(s.charCodeAt(i + 3));\n out[op++] = (v0 << 2) | (v1 >>> 4);\n out[op++] = (v1 << 4) | (v2 >>> 2);\n out[op++] = (v2 << 6) | v3;\n haveBad |= v0 & INVALID_BYTE;\n haveBad |= v1 & INVALID_BYTE;\n haveBad |= v2 & INVALID_BYTE;\n haveBad |= v3 & INVALID_BYTE;\n }\n if (i < length - 1) {\n v0 = this._decodeChar(s.charCodeAt(i));\n v1 = this._decodeChar(s.charCodeAt(i + 1));\n out[op++] = (v0 << 2) | (v1 >>> 4);\n haveBad |= v0 & INVALID_BYTE;\n haveBad |= v1 & INVALID_BYTE;\n }\n if (i < length - 2) {\n v2 = this._decodeChar(s.charCodeAt(i + 2));\n out[op++] = (v1 << 4) | (v2 >>> 2);\n haveBad |= v2 & INVALID_BYTE;\n }\n if (i < length - 3) {\n v3 = this._decodeChar(s.charCodeAt(i + 3));\n out[op++] = (v2 << 6) | v3;\n haveBad |= v3 & INVALID_BYTE;\n }\n if (haveBad !== 0) {\n throw new Error(\"Base64Coder: incorrect characters for decoding\");\n }\n return out;\n }\n\n // Standard encoding have the following encoded/decoded ranges,\n // which we need to convert between.\n //\n // ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 0123456789 + /\n // Index: 0 - 25 26 - 51 52 - 61 62 63\n // ASCII: 65 - 90 97 - 122 48 - 57 43 47\n //\n\n // Encode 6 bits in b into a new character.\n protected _encodeByte(b: number): string {\n // Encoding uses constant time operations as follows:\n //\n // 1. Define comparison of A with B using (A - B) >>> 8:\n // if A > B, then result is positive integer\n // if A <= B, then result is 0\n //\n // 2. Define selection of C or 0 using bitwise AND: X & C:\n // if X == 0, then result is 0\n // if X != 0, then result is C\n //\n // 3. Start with the smallest comparison (b >= 0), which is always\n // true, so set the result to the starting ASCII value (65).\n //\n // 4. Continue comparing b to higher ASCII values, and selecting\n // zero if comparison isn't true, otherwise selecting a value\n // to add to result, which:\n //\n // a) undoes the previous addition\n // b) provides new value to add\n //\n let result = b;\n // b >= 0\n result += 65;\n // b > 25\n result += ((25 - b) >>> 8) & ((0 - 65) - 26 + 97);\n // b > 51\n result += ((51 - b) >>> 8) & ((26 - 97) - 52 + 48);\n // b > 61\n result += ((61 - b) >>> 8) & ((52 - 48) - 62 + 43);\n // b > 62\n result += ((62 - b) >>> 8) & ((62 - 43) - 63 + 47);\n\n return String.fromCharCode(result);\n }\n\n // Decode a character code into a byte.\n // Must return 256 if character is out of alphabet range.\n protected _decodeChar(c: number): number {\n // Decoding works similar to encoding: using the same comparison\n // function, but now it works on ranges: result is always incremented\n // by value, but this value becomes zero if the range is not\n // satisfied.\n //\n // Decoding starts with invalid value, 256, which is then\n // subtracted when the range is satisfied. If none of the ranges\n // apply, the function returns 256, which is then checked by\n // the caller to throw error.\n let result = INVALID_BYTE; // start with invalid character\n\n // c == 43 (c > 42 and c < 44)\n result += (((42 - c) & (c - 44)) >>> 8) & (-INVALID_BYTE + c - 43 + 62);\n // c == 47 (c > 46 and c < 48)\n result += (((46 - c) & (c - 48)) >>> 8) & (-INVALID_BYTE + c - 47 + 63);\n // c > 47 and c < 58\n result += (((47 - c) & (c - 58)) >>> 8) & (-INVALID_BYTE + c - 48 + 52);\n // c > 64 and c < 91\n result += (((64 - c) & (c - 91)) >>> 8) & (-INVALID_BYTE + c - 65 + 0);\n // c > 96 and c < 123\n result += (((96 - c) & (c - 123)) >>> 8) & (-INVALID_BYTE + c - 97 + 26);\n\n return result;\n }\n\n private _getPaddingLength(s: string): number {\n let paddingLength = 0;\n if (this._paddingCharacter) {\n for (let i = s.length - 1; i >= 0; i--) {\n if (s[i] !== this._paddingCharacter) {\n break;\n }\n paddingLength++;\n }\n if (s.length < 4 || paddingLength > 2) {\n throw new Error(\"Base64Coder: incorrect padding\");\n }\n }\n return paddingLength;\n }\n\n}\n\nconst stdCoder = new Coder();\n\nexport function encode(data: Uint8Array): string {\n return stdCoder.encode(data);\n}\n\nexport function decode(s: string): Uint8Array {\n return stdCoder.decode(s);\n}\n\n/**\n * Implements URL-safe Base64 encoding.\n * (Same as Base64, but '+' is replaced with '-', and '/' with '_').\n *\n * Operates in constant time.\n */\nexport class URLSafeCoder extends Coder {\n // URL-safe encoding have the following encoded/decoded ranges:\n //\n // ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 0123456789 - _\n // Index: 0 - 25 26 - 51 52 - 61 62 63\n // ASCII: 65 - 90 97 - 122 48 - 57 45 95\n //\n\n protected _encodeByte(b: number): string {\n let result = b;\n // b >= 0\n result += 65;\n // b > 25\n result += ((25 - b) >>> 8) & ((0 - 65) - 26 + 97);\n // b > 51\n result += ((51 - b) >>> 8) & ((26 - 97) - 52 + 48);\n // b > 61\n result += ((61 - b) >>> 8) & ((52 - 48) - 62 + 45);\n // b > 62\n result += ((62 - b) >>> 8) & ((62 - 45) - 63 + 95);\n\n return String.fromCharCode(result);\n }\n\n protected _decodeChar(c: number): number {\n let result = INVALID_BYTE;\n\n // c == 45 (c > 44 and c < 46)\n result += (((44 - c) & (c - 46)) >>> 8) & (-INVALID_BYTE + c - 45 + 62);\n // c == 95 (c > 94 and c < 96)\n result += (((94 - c) & (c - 96)) >>> 8) & (-INVALID_BYTE + c - 95 + 63);\n // c > 47 and c < 58\n result += (((47 - c) & (c - 58)) >>> 8) & (-INVALID_BYTE + c - 48 + 52);\n // c > 64 and c < 91\n result += (((64 - c) & (c - 91)) >>> 8) & (-INVALID_BYTE + c - 65 + 0);\n // c > 96 and c < 123\n result += (((96 - c) & (c - 123)) >>> 8) & (-INVALID_BYTE + c - 97 + 26);\n\n return result;\n }\n}\n\nconst urlSafeCoder = new URLSafeCoder();\n\nexport function encodeURLSafe(data: Uint8Array): string {\n return urlSafeCoder.encode(data);\n}\n\nexport function decodeURLSafe(s: string): Uint8Array {\n return urlSafeCoder.decode(s);\n}\n\n\nexport const encodedLength = (length: number) =>\n stdCoder.encodedLength(length);\n\nexport const maxDecodedLength = (length: number) =>\n stdCoder.maxDecodedLength(length);\n\nexport const decodedLength = (s: string) =>\n stdCoder.decodedLength(s);\n","'use strict';\n\nvar Headers = function() {\n this.clear();\n};\n\nHeaders.prototype.ALLOWED_DUPLICATES = ['set-cookie', 'set-cookie2', 'warning', 'www-authenticate'];\n\nHeaders.prototype.clear = function() {\n this._sent = {};\n this._lines = [];\n};\n\nHeaders.prototype.set = function(name, value) {\n if (value === undefined) return;\n\n name = this._strip(name);\n value = this._strip(value);\n\n var key = name.toLowerCase();\n if (!this._sent.hasOwnProperty(key) || this.ALLOWED_DUPLICATES.indexOf(key) >= 0) {\n this._sent[key] = true;\n this._lines.push(name + ': ' + value + '\\r\\n');\n }\n};\n\nHeaders.prototype.toString = function() {\n return this._lines.join('');\n};\n\nHeaders.prototype._strip = function(string) {\n return string.toString().replace(/^ */, '').replace(/ *$/, '');\n};\n\nmodule.exports = Headers;\n","'use strict';\n\nvar NodeHTTPParser = require('http-parser-js').HTTPParser,\n Buffer = require('safe-buffer').Buffer;\n\nvar TYPES = {\n request: NodeHTTPParser.REQUEST || 'request',\n response: NodeHTTPParser.RESPONSE || 'response'\n};\n\nvar HttpParser = function(type) {\n this._type = type;\n this._parser = new NodeHTTPParser(TYPES[type]);\n this._complete = false;\n this.headers = {};\n\n var current = null,\n self = this;\n\n this._parser.onHeaderField = function(b, start, length) {\n current = b.toString('utf8', start, start + length).toLowerCase();\n };\n\n this._parser.onHeaderValue = function(b, start, length) {\n var value = b.toString('utf8', start, start + length);\n\n if (self.headers.hasOwnProperty(current))\n self.headers[current] += ', ' + value;\n else\n self.headers[current] = value;\n };\n\n this._parser.onHeadersComplete = this._parser[NodeHTTPParser.kOnHeadersComplete] =\n function(majorVersion, minorVersion, headers, method, pathname, statusCode) {\n var info = arguments[0];\n\n if (typeof info === 'object') {\n method = info.method;\n pathname = info.url;\n statusCode = info.statusCode;\n headers = info.headers;\n }\n\n self.method = (typeof method === 'number') ? HttpParser.METHODS[method] : method;\n self.statusCode = statusCode;\n self.url = pathname;\n\n if (!headers) return;\n\n for (var i = 0, n = headers.length, key, value; i < n; i += 2) {\n key = headers[i].toLowerCase();\n value = headers[i+1];\n if (self.headers.hasOwnProperty(key))\n self.headers[key] += ', ' + value;\n else\n self.headers[key] = value;\n }\n\n self._complete = true;\n };\n};\n\nHttpParser.METHODS = {\n 0: 'DELETE',\n 1: 'GET',\n 2: 'HEAD',\n 3: 'POST',\n 4: 'PUT',\n 5: 'CONNECT',\n 6: 'OPTIONS',\n 7: 'TRACE',\n 8: 'COPY',\n 9: 'LOCK',\n 10: 'MKCOL',\n 11: 'MOVE',\n 12: 'PROPFIND',\n 13: 'PROPPATCH',\n 14: 'SEARCH',\n 15: 'UNLOCK',\n 16: 'BIND',\n 17: 'REBIND',\n 18: 'UNBIND',\n 19: 'ACL',\n 20: 'REPORT',\n 21: 'MKACTIVITY',\n 22: 'CHECKOUT',\n 23: 'MERGE',\n 24: 'M-SEARCH',\n 25: 'NOTIFY',\n 26: 'SUBSCRIBE',\n 27: 'UNSUBSCRIBE',\n 28: 'PATCH',\n 29: 'PURGE',\n 30: 'MKCALENDAR',\n 31: 'LINK',\n 32: 'UNLINK'\n};\n\nvar VERSION = process.version\n ? process.version.match(/[0-9]+/g).map(function(n) { return parseInt(n, 10) })\n : [];\n\nif (VERSION[0] === 0 && VERSION[1] === 12) {\n HttpParser.METHODS[16] = 'REPORT';\n HttpParser.METHODS[17] = 'MKACTIVITY';\n HttpParser.METHODS[18] = 'CHECKOUT';\n HttpParser.METHODS[19] = 'MERGE';\n HttpParser.METHODS[20] = 'M-SEARCH';\n HttpParser.METHODS[21] = 'NOTIFY';\n HttpParser.METHODS[22] = 'SUBSCRIBE';\n HttpParser.METHODS[23] = 'UNSUBSCRIBE';\n HttpParser.METHODS[24] = 'PATCH';\n HttpParser.METHODS[25] = 'PURGE';\n}\n\nHttpParser.prototype.isComplete = function() {\n return this._complete;\n};\n\nHttpParser.prototype.parse = function(chunk) {\n var consumed = this._parser.execute(chunk, 0, chunk.length);\n\n if (typeof consumed !== 'number') {\n this.error = consumed;\n this._complete = true;\n return;\n }\n\n if (this._complete)\n this.body = (consumed < chunk.length)\n ? chunk.slice(consumed)\n : Buffer.alloc(0);\n};\n\nmodule.exports = HttpParser;\n","'use strict';\n\nvar Stream = require('stream').Stream,\n util = require('util'),\n driver = require('websocket-driver'),\n EventTarget = require('./api/event_target'),\n Event = require('./api/event');\n\nvar API = function(options) {\n options = options || {};\n driver.validateOptions(options, ['headers', 'extensions', 'maxLength', 'ping', 'proxy', 'tls', 'ca']);\n\n this.readable = this.writable = true;\n\n var headers = options.headers;\n if (headers) {\n for (var name in headers) this._driver.setHeader(name, headers[name]);\n }\n\n var extensions = options.extensions;\n if (extensions) {\n [].concat(extensions).forEach(this._driver.addExtension, this._driver);\n }\n\n this._ping = options.ping;\n this._pingId = 0;\n this.readyState = API.CONNECTING;\n this.bufferedAmount = 0;\n this.protocol = '';\n this.url = this._driver.url;\n this.version = this._driver.version;\n\n var self = this;\n\n this._driver.on('open', function(e) { self._open() });\n this._driver.on('message', function(e) { self._receiveMessage(e.data) });\n this._driver.on('close', function(e) { self._beginClose(e.reason, e.code) });\n\n this._driver.on('error', function(error) {\n self._emitError(error.message);\n });\n this.on('error', function() {});\n\n this._driver.messages.on('drain', function() {\n self.emit('drain');\n });\n\n if (this._ping)\n this._pingTimer = setInterval(function() {\n self._pingId += 1;\n self.ping(self._pingId.toString());\n }, this._ping * 1000);\n\n this._configureStream();\n\n if (!this._proxy) {\n this._stream.pipe(this._driver.io);\n this._driver.io.pipe(this._stream);\n }\n};\nutil.inherits(API, Stream);\n\nAPI.CONNECTING = 0;\nAPI.OPEN = 1;\nAPI.CLOSING = 2;\nAPI.CLOSED = 3;\n\nAPI.CLOSE_TIMEOUT = 30000;\n\nvar instance = {\n write: function(data) {\n return this.send(data);\n },\n\n end: function(data) {\n if (data !== undefined) this.send(data);\n this.close();\n },\n\n pause: function() {\n return this._driver.messages.pause();\n },\n\n resume: function() {\n return this._driver.messages.resume();\n },\n\n send: function(data) {\n if (this.readyState > API.OPEN) return false;\n if (!(data instanceof Buffer)) data = String(data);\n return this._driver.messages.write(data);\n },\n\n ping: function(message, callback) {\n if (this.readyState > API.OPEN) return false;\n return this._driver.ping(message, callback);\n },\n\n close: function(code, reason) {\n if (code === undefined) code = 1000;\n if (reason === undefined) reason = '';\n\n if (code !== 1000 && (code < 3000 || code > 4999))\n throw new Error(\"Failed to execute 'close' on WebSocket: \" +\n \"The code must be either 1000, or between 3000 and 4999. \" +\n code + \" is neither.\");\n\n if (this.readyState !== API.CLOSED) this.readyState = API.CLOSING;\n var self = this;\n\n this._closeTimer = setTimeout(function() {\n self._beginClose('', 1006);\n }, API.CLOSE_TIMEOUT);\n\n this._driver.close(reason, code);\n },\n\n _configureStream: function() {\n var self = this;\n\n this._stream.setTimeout(0);\n this._stream.setNoDelay(true);\n\n ['close', 'end'].forEach(function(event) {\n this._stream.on(event, function() { self._finalizeClose() });\n }, this);\n\n this._stream.on('error', function(error) {\n self._emitError('Network error: ' + self.url + ': ' + error.message);\n self._finalizeClose();\n });\n },\n\n _open: function() {\n if (this.readyState !== API.CONNECTING) return;\n\n this.readyState = API.OPEN;\n this.protocol = this._driver.protocol || '';\n\n var event = new Event('open');\n event.initEvent('open', false, false);\n this.dispatchEvent(event);\n },\n\n _receiveMessage: function(data) {\n if (this.readyState > API.OPEN) return false;\n\n if (this.readable) this.emit('data', data);\n\n var event = new Event('message', {data: data});\n event.initEvent('message', false, false);\n this.dispatchEvent(event);\n },\n\n _emitError: function(message) {\n if (this.readyState >= API.CLOSING) return;\n\n var event = new Event('error', {message: message});\n event.initEvent('error', false, false);\n this.dispatchEvent(event);\n },\n\n _beginClose: function(reason, code) {\n if (this.readyState === API.CLOSED) return;\n this.readyState = API.CLOSING;\n this._closeParams = [reason, code];\n\n if (this._stream) {\n this._stream.destroy();\n if (!this._stream.readable) this._finalizeClose();\n }\n },\n\n _finalizeClose: function() {\n if (this.readyState === API.CLOSED) return;\n this.readyState = API.CLOSED;\n\n if (this._closeTimer) clearTimeout(this._closeTimer);\n if (this._pingTimer) clearInterval(this._pingTimer);\n if (this._stream) this._stream.end();\n\n if (this.readable) this.emit('end');\n this.readable = this.writable = false;\n\n var reason = this._closeParams ? this._closeParams[0] : '',\n code = this._closeParams ? this._closeParams[1] : 1006;\n\n var event = new Event('close', {code: code, reason: reason});\n event.initEvent('close', false, false);\n this.dispatchEvent(event);\n }\n};\n\nfor (var method in instance) API.prototype[method] = instance[method];\nfor (var key in EventTarget) API.prototype[key] = EventTarget[key];\n\nmodule.exports = API;\n","'use strict';\n\nvar Buffer = require('safe-buffer').Buffer,\n crypto = require('crypto'),\n util = require('util'),\n Extensions = require('websocket-extensions'),\n Base = require('./base'),\n Frame = require('./hybi/frame'),\n Message = require('./hybi/message');\n\nvar Hybi = function(request, url, options) {\n Base.apply(this, arguments);\n\n this._extensions = new Extensions();\n this._stage = 0;\n this._masking = this._options.masking;\n this._protocols = this._options.protocols || [];\n this._requireMasking = this._options.requireMasking;\n this._pingCallbacks = {};\n\n if (typeof this._protocols === 'string')\n this._protocols = this._protocols.split(/ *, */);\n\n if (!this._request) return;\n\n var protos = this._request.headers['sec-websocket-protocol'],\n supported = this._protocols;\n\n if (protos !== undefined) {\n if (typeof protos === 'string') protos = protos.split(/ *, */);\n this.protocol = protos.filter(function(p) { return supported.indexOf(p) >= 0 })[0];\n }\n\n this.version = 'hybi-' + Hybi.VERSION;\n};\nutil.inherits(Hybi, Base);\n\nHybi.VERSION = '13';\n\nHybi.mask = function(payload, mask, offset) {\n if (!mask || mask.length === 0) return payload;\n offset = offset || 0;\n\n for (var i = 0, n = payload.length - offset; i < n; i++) {\n payload[offset + i] = payload[offset + i] ^ mask[i % 4];\n }\n return payload;\n};\n\nHybi.generateAccept = function(key) {\n var sha1 = crypto.createHash('sha1');\n sha1.update(key + Hybi.GUID);\n return sha1.digest('base64');\n};\n\nHybi.GUID = '258EAFA5-E914-47DA-95CA-C5AB0DC85B11';\n\nvar instance = {\n FIN: 0x80,\n MASK: 0x80,\n RSV1: 0x40,\n RSV2: 0x20,\n RSV3: 0x10,\n OPCODE: 0x0F,\n LENGTH: 0x7F,\n\n OPCODES: {\n continuation: 0,\n text: 1,\n binary: 2,\n close: 8,\n ping: 9,\n pong: 10\n },\n\n OPCODE_CODES: [0, 1, 2, 8, 9, 10],\n MESSAGE_OPCODES: [0, 1, 2],\n OPENING_OPCODES: [1, 2],\n\n ERRORS: {\n normal_closure: 1000,\n going_away: 1001,\n protocol_error: 1002,\n unacceptable: 1003,\n encoding_error: 1007,\n policy_violation: 1008,\n too_large: 1009,\n extension_error: 1010,\n unexpected_condition: 1011\n },\n\n ERROR_CODES: [1000, 1001, 1002, 1003, 1007, 1008, 1009, 1010, 1011],\n DEFAULT_ERROR_CODE: 1000,\n MIN_RESERVED_ERROR: 3000,\n MAX_RESERVED_ERROR: 4999,\n\n // http://www.w3.org/International/questions/qa-forms-utf-8.en.php\n UTF8_MATCH: /^([\\x00-\\x7F]|[\\xC2-\\xDF][\\x80-\\xBF]|\\xE0[\\xA0-\\xBF][\\x80-\\xBF]|[\\xE1-\\xEC\\xEE\\xEF][\\x80-\\xBF]{2}|\\xED[\\x80-\\x9F][\\x80-\\xBF]|\\xF0[\\x90-\\xBF][\\x80-\\xBF]{2}|[\\xF1-\\xF3][\\x80-\\xBF]{3}|\\xF4[\\x80-\\x8F][\\x80-\\xBF]{2})*$/,\n\n addExtension: function(extension) {\n this._extensions.add(extension);\n return true;\n },\n\n parse: function(chunk) {\n this._reader.put(chunk);\n var buffer = true;\n while (buffer) {\n switch (this._stage) {\n case 0:\n buffer = this._reader.read(1);\n if (buffer) this._parseOpcode(buffer[0]);\n break;\n\n case 1:\n buffer = this._reader.read(1);\n if (buffer) this._parseLength(buffer[0]);\n break;\n\n case 2:\n buffer = this._reader.read(this._frame.lengthBytes);\n if (buffer) this._parseExtendedLength(buffer);\n break;\n\n case 3:\n buffer = this._reader.read(4);\n if (buffer) {\n this._stage = 4;\n this._frame.maskingKey = buffer;\n }\n break;\n\n case 4:\n buffer = this._reader.read(this._frame.length);\n if (buffer) {\n this._stage = 0;\n this._emitFrame(buffer);\n }\n break;\n\n default:\n buffer = null;\n }\n }\n },\n\n text: function(message) {\n if (this.readyState > 1) return false;\n return this.frame(message, 'text');\n },\n\n binary: function(message) {\n if (this.readyState > 1) return false;\n return this.frame(message, 'binary');\n },\n\n ping: function(message, callback) {\n if (this.readyState > 1) return false;\n message = message || '';\n if (callback) this._pingCallbacks[message] = callback;\n return this.frame(message, 'ping');\n },\n\n pong: function(message) {\n if (this.readyState > 1) return false;\n message = message ||'';\n return this.frame(message, 'pong');\n },\n\n close: function(reason, code) {\n reason = reason || '';\n code = code || this.ERRORS.normal_closure;\n\n if (this.readyState <= 0) {\n this.readyState = 3;\n this.emit('close', new Base.CloseEvent(code, reason));\n return true;\n } else if (this.readyState === 1) {\n this.readyState = 2;\n this._extensions.close(function() { this.frame(reason, 'close', code) }, this);\n return true;\n } else {\n return false;\n }\n },\n\n frame: function(buffer, type, code) {\n if (this.readyState <= 0) return this._queue([buffer, type, code]);\n if (this.readyState > 2) return false;\n\n if (buffer instanceof Array) buffer = Buffer.from(buffer);\n if (typeof buffer === 'number') buffer = buffer.toString();\n\n var message = new Message(),\n isText = (typeof buffer === 'string'),\n payload, copy;\n\n message.rsv1 = message.rsv2 = message.rsv3 = false;\n message.opcode = this.OPCODES[type || (isText ? 'text' : 'binary')];\n\n payload = isText ? Buffer.from(buffer, 'utf8') : buffer;\n\n if (code) {\n copy = payload;\n payload = Buffer.allocUnsafe(2 + copy.length);\n payload.writeUInt16BE(code, 0);\n copy.copy(payload, 2);\n }\n message.data = payload;\n\n var onMessageReady = function(message) {\n var frame = new Frame();\n\n frame.final = true;\n frame.rsv1 = message.rsv1;\n frame.rsv2 = message.rsv2;\n frame.rsv3 = message.rsv3;\n frame.opcode = message.opcode;\n frame.masked = !!this._masking;\n frame.length = message.data.length;\n frame.payload = message.data;\n\n if (frame.masked) frame.maskingKey = crypto.randomBytes(4);\n\n this._sendFrame(frame);\n };\n\n if (this.MESSAGE_OPCODES.indexOf(message.opcode) >= 0)\n this._extensions.processOutgoingMessage(message, function(error, message) {\n if (error) return this._fail('extension_error', error.message);\n onMessageReady.call(this, message);\n }, this);\n else\n onMessageReady.call(this, message);\n\n return true;\n },\n\n _sendFrame: function(frame) {\n var length = frame.length,\n header = (length <= 125) ? 2 : (length <= 65535 ? 4 : 10),\n offset = header + (frame.masked ? 4 : 0),\n buffer = Buffer.allocUnsafe(offset + length),\n masked = frame.masked ? this.MASK : 0;\n\n buffer[0] = (frame.final ? this.FIN : 0) |\n (frame.rsv1 ? this.RSV1 : 0) |\n (frame.rsv2 ? this.RSV2 : 0) |\n (frame.rsv3 ? this.RSV3 : 0) |\n frame.opcode;\n\n if (length <= 125) {\n buffer[1] = masked | length;\n } else if (length <= 65535) {\n buffer[1] = masked | 126;\n buffer.writeUInt16BE(length, 2);\n } else {\n buffer[1] = masked | 127;\n buffer.writeUInt32BE(Math.floor(length / 0x100000000), 2);\n buffer.writeUInt32BE(length % 0x100000000, 6);\n }\n\n frame.payload.copy(buffer, offset);\n\n if (frame.masked) {\n frame.maskingKey.copy(buffer, header);\n Hybi.mask(buffer, frame.maskingKey, offset);\n }\n\n this._write(buffer);\n },\n\n _handshakeResponse: function() {\n var secKey = this._request.headers['sec-websocket-key'],\n version = this._request.headers['sec-websocket-version'];\n\n if (version !== Hybi.VERSION)\n throw new Error('Unsupported WebSocket version: ' + version);\n\n if (typeof secKey !== 'string')\n throw new Error('Missing handshake request header: Sec-WebSocket-Key');\n\n this._headers.set('Upgrade', 'websocket');\n this._headers.set('Connection', 'Upgrade');\n this._headers.set('Sec-WebSocket-Accept', Hybi.generateAccept(secKey));\n\n if (this.protocol) this._headers.set('Sec-WebSocket-Protocol', this.protocol);\n\n var extensions = this._extensions.generateResponse(this._request.headers['sec-websocket-extensions']);\n if (extensions) this._headers.set('Sec-WebSocket-Extensions', extensions);\n\n var start = 'HTTP/1.1 101 Switching Protocols',\n headers = [start, this._headers.toString(), ''];\n\n return Buffer.from(headers.join('\\r\\n'), 'utf8');\n },\n\n _shutdown: function(code, reason, error) {\n delete this._frame;\n delete this._message;\n this._stage = 5;\n\n var sendCloseFrame = (this.readyState === 1);\n this.readyState = 2;\n\n this._extensions.close(function() {\n if (sendCloseFrame) this.frame(reason, 'close', code);\n this.readyState = 3;\n if (error) this.emit('error', new Error(reason));\n this.emit('close', new Base.CloseEvent(code, reason));\n }, this);\n },\n\n _fail: function(type, message) {\n if (this.readyState > 1) return;\n this._shutdown(this.ERRORS[type], message, true);\n },\n\n _parseOpcode: function(octet) {\n var rsvs = [this.RSV1, this.RSV2, this.RSV3].map(function(rsv) {\n return (octet & rsv) === rsv;\n });\n\n var frame = this._frame = new Frame();\n\n frame.final = (octet & this.FIN) === this.FIN;\n frame.rsv1 = rsvs[0];\n frame.rsv2 = rsvs[1];\n frame.rsv3 = rsvs[2];\n frame.opcode = (octet & this.OPCODE);\n\n this._stage = 1;\n\n if (!this._extensions.validFrameRsv(frame))\n return this._fail('protocol_error',\n 'One or more reserved bits are on: reserved1 = ' + (frame.rsv1 ? 1 : 0) +\n ', reserved2 = ' + (frame.rsv2 ? 1 : 0) +\n ', reserved3 = ' + (frame.rsv3 ? 1 : 0));\n\n if (this.OPCODE_CODES.indexOf(frame.opcode) < 0)\n return this._fail('protocol_error', 'Unrecognized frame opcode: ' + frame.opcode);\n\n if (this.MESSAGE_OPCODES.indexOf(frame.opcode) < 0 && !frame.final)\n return this._fail('protocol_error', 'Received fragmented control frame: opcode = ' + frame.opcode);\n\n if (this._message && this.OPENING_OPCODES.indexOf(frame.opcode) >= 0)\n return this._fail('protocol_error', 'Received new data frame but previous continuous frame is unfinished');\n },\n\n _parseLength: function(octet) {\n var frame = this._frame;\n frame.masked = (octet & this.MASK) === this.MASK;\n frame.length = (octet & this.LENGTH);\n\n if (frame.length >= 0 && frame.length <= 125) {\n this._stage = frame.masked ? 3 : 4;\n if (!this._checkFrameLength()) return;\n } else {\n this._stage = 2;\n frame.lengthBytes = (frame.length === 126 ? 2 : 8);\n }\n\n if (this._requireMasking && !frame.masked)\n return this._fail('unacceptable', 'Received unmasked frame but masking is required');\n },\n\n _parseExtendedLength: function(buffer) {\n var frame = this._frame;\n frame.length = this._readUInt(buffer);\n\n this._stage = frame.masked ? 3 : 4;\n\n if (this.MESSAGE_OPCODES.indexOf(frame.opcode) < 0 && frame.length > 125)\n return this._fail('protocol_error', 'Received control frame having too long payload: ' + frame.length);\n\n if (!this._checkFrameLength()) return;\n },\n\n _checkFrameLength: function() {\n var length = this._message ? this._message.length : 0;\n\n if (length + this._frame.length > this._maxLength) {\n this._fail('too_large', 'WebSocket frame length too large');\n return false;\n } else {\n return true;\n }\n },\n\n _emitFrame: function(buffer) {\n var frame = this._frame,\n payload = frame.payload = Hybi.mask(buffer, frame.maskingKey),\n opcode = frame.opcode,\n message,\n code, reason,\n callbacks, callback;\n\n delete this._frame;\n\n if (opcode === this.OPCODES.continuation) {\n if (!this._message) return this._fail('protocol_error', 'Received unexpected continuation frame');\n this._message.pushFrame(frame);\n }\n\n if (opcode === this.OPCODES.text || opcode === this.OPCODES.binary) {\n this._message = new Message();\n this._message.pushFrame(frame);\n }\n\n if (frame.final && this.MESSAGE_OPCODES.indexOf(opcode) >= 0)\n return this._emitMessage(this._message);\n\n if (opcode === this.OPCODES.close) {\n code = (payload.length >= 2) ? payload.readUInt16BE(0) : null;\n reason = (payload.length > 2) ? this._encode(payload.slice(2)) : null;\n\n if (!(payload.length === 0) &&\n !(code !== null && code >= this.MIN_RESERVED_ERROR && code <= this.MAX_RESERVED_ERROR) &&\n this.ERROR_CODES.indexOf(code) < 0)\n code = this.ERRORS.protocol_error;\n\n if (payload.length > 125 || (payload.length > 2 && !reason))\n code = this.ERRORS.protocol_error;\n\n this._shutdown(code || this.DEFAULT_ERROR_CODE, reason || '');\n }\n\n if (opcode === this.OPCODES.ping) {\n this.frame(payload, 'pong');\n this.emit('ping', new Base.PingEvent(payload.toString()))\n }\n\n if (opcode === this.OPCODES.pong) {\n callbacks = this._pingCallbacks;\n message = this._encode(payload);\n callback = callbacks[message];\n\n delete callbacks[message];\n if (callback) callback()\n\n this.emit('pong', new Base.PongEvent(payload.toString()))\n }\n },\n\n _emitMessage: function(message) {\n var message = this._message;\n message.read();\n\n delete this._message;\n\n this._extensions.processIncomingMessage(message, function(error, message) {\n if (error) return this._fail('extension_error', error.message);\n\n var payload = message.data;\n if (message.opcode === this.OPCODES.text) payload = this._encode(payload);\n\n if (payload === null)\n return this._fail('encoding_error', 'Could not decode a text frame as UTF-8');\n else\n this.emit('message', new Base.MessageEvent(payload));\n }, this);\n },\n\n _encode: function(buffer) {\n try {\n var string = buffer.toString('binary', 0, buffer.length);\n if (!this.UTF8_MATCH.test(string)) return null;\n } catch (e) {}\n return buffer.toString('utf8', 0, buffer.length);\n },\n\n _readUInt: function(buffer) {\n if (buffer.length === 2) return buffer.readUInt16BE(0);\n\n return buffer.readUInt32BE(0) * 0x100000000 +\n buffer.readUInt32BE(4);\n }\n};\n\nfor (var key in instance)\n Hybi.prototype[key] = instance[key];\n\nmodule.exports = Hybi;\n","'use strict';\n\nvar RingBuffer = function(bufferSize) {\n this._bufferSize = bufferSize;\n this.clear();\n};\n\nRingBuffer.prototype.clear = function() {\n this._buffer = new Array(this._bufferSize);\n this._ringOffset = 0;\n this._ringSize = this._bufferSize;\n this._head = 0;\n this._tail = 0;\n this.length = 0;\n};\n\nRingBuffer.prototype.push = function(value) {\n var expandBuffer = false,\n expandRing = false;\n\n if (this._ringSize < this._bufferSize) {\n expandBuffer = (this._tail === 0);\n } else if (this._ringOffset === this._ringSize) {\n expandBuffer = true;\n expandRing = (this._tail === 0);\n }\n\n if (expandBuffer) {\n this._tail = this._bufferSize;\n this._buffer = this._buffer.concat(new Array(this._bufferSize));\n this._bufferSize = this._buffer.length;\n\n if (expandRing)\n this._ringSize = this._bufferSize;\n }\n\n this._buffer[this._tail] = value;\n this.length += 1;\n if (this._tail < this._ringSize) this._ringOffset += 1;\n this._tail = (this._tail + 1) % this._bufferSize;\n};\n\nRingBuffer.prototype.peek = function() {\n if (this.length === 0) return void 0;\n return this._buffer[this._head];\n};\n\nRingBuffer.prototype.shift = function() {\n if (this.length === 0) return void 0;\n\n var value = this._buffer[this._head];\n this._buffer[this._head] = void 0;\n this.length -= 1;\n this._ringOffset -= 1;\n\n if (this._ringOffset === 0 && this.length > 0) {\n this._head = this._ringSize;\n this._ringOffset = this.length;\n this._ringSize = this._bufferSize;\n } else {\n this._head = (this._head + 1) % this._ringSize;\n }\n return value;\n};\n\nmodule.exports = RingBuffer;\n","'use strict';\n\nvar RingBuffer = require('./ring_buffer');\n\nvar Pledge = function() {\n this._complete = false;\n this._callbacks = new RingBuffer(Pledge.QUEUE_SIZE);\n};\n\nPledge.QUEUE_SIZE = 4;\n\nPledge.all = function(list) {\n var pledge = new Pledge(),\n pending = list.length,\n n = pending;\n\n if (pending === 0) pledge.done();\n\n while (n--) list[n].then(function() {\n pending -= 1;\n if (pending === 0) pledge.done();\n });\n return pledge;\n};\n\nPledge.prototype.then = function(callback) {\n if (this._complete) callback();\n else this._callbacks.push(callback);\n};\n\nPledge.prototype.done = function() {\n this._complete = true;\n var callbacks = this._callbacks, callback;\n while (callback = callbacks.shift()) callback();\n};\n\nmodule.exports = Pledge;\n","'use strict';\n\nvar Buffer = require('safe-buffer').Buffer,\n Base = require('./base'),\n util = require('util');\n\nvar Draft75 = function(request, url, options) {\n Base.apply(this, arguments);\n this._stage = 0;\n this.version = 'hixie-75';\n\n this._headers.set('Upgrade', 'WebSocket');\n this._headers.set('Connection', 'Upgrade');\n this._headers.set('WebSocket-Origin', this._request.headers.origin);\n this._headers.set('WebSocket-Location', this.url);\n};\nutil.inherits(Draft75, Base);\n\nvar instance = {\n close: function() {\n if (this.readyState === 3) return false;\n this.readyState = 3;\n this.emit('close', new Base.CloseEvent(null, null));\n return true;\n },\n\n parse: function(chunk) {\n if (this.readyState > 1) return;\n\n this._reader.put(chunk);\n\n this._reader.eachByte(function(octet) {\n var message;\n\n switch (this._stage) {\n case -1:\n this._body.push(octet);\n this._sendHandshakeBody();\n break;\n\n case 0:\n this._parseLeadingByte(octet);\n break;\n\n case 1:\n this._length = (octet & 0x7F) + 128 * this._length;\n\n if (this._closing && this._length === 0) {\n return this.close();\n }\n else if ((octet & 0x80) !== 0x80) {\n if (this._length === 0) {\n this._stage = 0;\n }\n else {\n this._skipped = 0;\n this._stage = 2;\n }\n }\n break;\n\n case 2:\n if (octet === 0xFF) {\n this._stage = 0;\n message = Buffer.from(this._buffer).toString('utf8', 0, this._buffer.length);\n this.emit('message', new Base.MessageEvent(message));\n }\n else {\n if (this._length) {\n this._skipped += 1;\n if (this._skipped === this._length)\n this._stage = 0;\n } else {\n this._buffer.push(octet);\n if (this._buffer.length > this._maxLength) return this.close();\n }\n }\n break;\n }\n }, this);\n },\n\n frame: function(buffer) {\n if (this.readyState === 0) return this._queue([buffer]);\n if (this.readyState > 1) return false;\n\n if (typeof buffer !== 'string') buffer = buffer.toString();\n\n var length = Buffer.byteLength(buffer),\n frame = Buffer.allocUnsafe(length + 2);\n\n frame[0] = 0x00;\n frame.write(buffer, 1);\n frame[frame.length - 1] = 0xFF;\n\n this._write(frame);\n return true;\n },\n\n _handshakeResponse: function() {\n var start = 'HTTP/1.1 101 Web Socket Protocol Handshake',\n headers = [start, this._headers.toString(), ''];\n\n return Buffer.from(headers.join('\\r\\n'), 'utf8');\n },\n\n _parseLeadingByte: function(octet) {\n if ((octet & 0x80) === 0x80) {\n this._length = 0;\n this._stage = 1;\n } else {\n delete this._length;\n delete this._skipped;\n this._buffer = [];\n this._stage = 2;\n }\n }\n};\n\nfor (var key in instance)\n Draft75.prototype[key] = instance[key];\n\nmodule.exports = Draft75;\n","'use strict';\n\nvar Event = require('./event');\n\nvar EventTarget = {\n onopen: null,\n onmessage: null,\n onerror: null,\n onclose: null,\n\n addEventListener: function(eventType, listener, useCapture) {\n this.on(eventType, listener);\n },\n\n removeEventListener: function(eventType, listener, useCapture) {\n this.removeListener(eventType, listener);\n },\n\n dispatchEvent: function(event) {\n event.target = event.currentTarget = this;\n event.eventPhase = Event.AT_TARGET;\n\n if (this['on' + event.type])\n this['on' + event.type](event);\n\n this.emit(event.type, event);\n }\n};\n\nmodule.exports = EventTarget;\n","// Copyright (C) 2016 Dmitry Chestnykh\n// MIT License. See LICENSE file for details.\n\n/**\n * Package utf8 implements UTF-8 encoding and decoding.\n */\n\nconst INVALID_UTF16 = \"utf8: invalid string\";\nconst INVALID_UTF8 = \"utf8: invalid source encoding\";\n\n/**\n * Encodes the given string into UTF-8 byte array.\n * Throws if the source string has invalid UTF-16 encoding.\n */\nexport function encode(s: string): Uint8Array {\n // Calculate result length and allocate output array.\n // encodedLength() also validates string and throws errors,\n // so we don't need repeat validation here.\n const arr = new Uint8Array(encodedLength(s));\n\n let pos = 0;\n for (let i = 0; i < s.length; i++) {\n let c = s.charCodeAt(i);\n if (c < 0x80) {\n arr[pos++] = c;\n } else if (c < 0x800) {\n arr[pos++] = 0xc0 | c >> 6;\n arr[pos++] = 0x80 | c & 0x3f;\n } else if (c < 0xd800) {\n arr[pos++] = 0xe0 | c >> 12;\n arr[pos++] = 0x80 | (c >> 6) & 0x3f;\n arr[pos++] = 0x80 | c & 0x3f;\n } else {\n i++; // get one more character\n c = (c & 0x3ff) << 10;\n c |= s.charCodeAt(i) & 0x3ff;\n c += 0x10000;\n\n arr[pos++] = 0xf0 | c >> 18;\n arr[pos++] = 0x80 | (c >> 12) & 0x3f;\n arr[pos++] = 0x80 | (c >> 6) & 0x3f;\n arr[pos++] = 0x80 | c & 0x3f;\n }\n }\n return arr;\n}\n\n/**\n * Returns the number of bytes required to encode the given string into UTF-8.\n * Throws if the source string has invalid UTF-16 encoding.\n */\nexport function encodedLength(s: string): number {\n let result = 0;\n for (let i = 0; i < s.length; i++) {\n const c = s.charCodeAt(i);\n if (c < 0x80) {\n result += 1;\n } else if (c < 0x800) {\n result += 2;\n } else if (c < 0xd800) {\n result += 3;\n } else if (c <= 0xdfff) {\n if (i >= s.length - 1) {\n throw new Error(INVALID_UTF16);\n }\n i++; // \"eat\" next character\n result += 4;\n } else {\n throw new Error(INVALID_UTF16);\n }\n }\n return result;\n}\n\n/**\n * Decodes the given byte array from UTF-8 into a string.\n * Throws if encoding is invalid.\n */\nexport function decode(arr: Uint8Array): string {\n const chars: string[] = [];\n for (let i = 0; i < arr.length; i++) {\n let b = arr[i];\n\n if (b & 0x80) {\n let min;\n if (b < 0xe0) {\n // Need 1 more byte.\n if (i >= arr.length) {\n throw new Error(INVALID_UTF8);\n }\n const n1 = arr[++i];\n if ((n1 & 0xc0) !== 0x80) {\n throw new Error(INVALID_UTF8);\n }\n b = (b & 0x1f) << 6 | (n1 & 0x3f);\n min = 0x80;\n } else if (b < 0xf0) {\n // Need 2 more bytes.\n if (i >= arr.length - 1) {\n throw new Error(INVALID_UTF8);\n }\n const n1 = arr[++i];\n const n2 = arr[++i];\n if ((n1 & 0xc0) !== 0x80 || (n2 & 0xc0) !== 0x80) {\n throw new Error(INVALID_UTF8);\n }\n b = (b & 0x0f) << 12 | (n1 & 0x3f) << 6 | (n2 & 0x3f);\n min = 0x800;\n } else if (b < 0xf8) {\n // Need 3 more bytes.\n if (i >= arr.length - 2) {\n throw new Error(INVALID_UTF8);\n }\n const n1 = arr[++i];\n const n2 = arr[++i];\n const n3 = arr[++i];\n if ((n1 & 0xc0) !== 0x80 || (n2 & 0xc0) !== 0x80 || (n3 & 0xc0) !== 0x80) {\n throw new Error(INVALID_UTF8);\n }\n b = (b & 0x0f) << 18 | (n1 & 0x3f) << 12 | (n2 & 0x3f) << 6 | (n3 & 0x3f);\n min = 0x10000;\n } else {\n throw new Error(INVALID_UTF8);\n }\n\n if (b < min || (b >= 0xd800 && b <= 0xdfff)) {\n throw new Error(INVALID_UTF8);\n }\n\n if (b >= 0x10000) {\n // Surrogate pair.\n if (b > 0x10ffff) {\n throw new Error(INVALID_UTF8);\n }\n b -= 0x10000;\n chars.push(String.fromCharCode(0xd800 | (b >> 10)));\n b = 0xdc00 | (b & 0x3ff);\n }\n }\n\n chars.push(String.fromCharCode(b));\n }\n return chars.join(\"\");\n}\n","// API references:\n//\n// * https://html.spec.whatwg.org/multipage/comms.html#network\n// * https://dom.spec.whatwg.org/#interface-eventtarget\n// * https://dom.spec.whatwg.org/#interface-event\n\n'use strict';\n\nvar util = require('util'),\n driver = require('websocket-driver'),\n API = require('./websocket/api');\n\nvar WebSocket = function(request, socket, body, protocols, options) {\n options = options || {};\n\n this._stream = socket;\n this._driver = driver.http(request, {maxLength: options.maxLength, protocols: protocols});\n\n var self = this;\n if (!this._stream || !this._stream.writable) return;\n if (!this._stream.readable) return this._stream.end();\n\n var catchup = function() { self._stream.removeListener('data', catchup) };\n this._stream.on('data', catchup);\n\n API.call(this, options);\n\n process.nextTick(function() {\n self._driver.start();\n self._driver.io.write(body);\n });\n};\nutil.inherits(WebSocket, API);\n\nWebSocket.isWebSocket = function(request) {\n return driver.isWebSocket(request);\n};\n\nWebSocket.validateOptions = function(options, validKeys) {\n driver.validateOptions(options, validKeys);\n};\n\nWebSocket.WebSocket = WebSocket;\nWebSocket.Client = require('./websocket/client');\nWebSocket.EventSource = require('./eventsource');\n\nmodule.exports = WebSocket;\n","/**\n * Wrapper for built-in http.js to emulate the browser XMLHttpRequest object.\n *\n * This can be used with JS designed for browsers to improve reuse of code and\n * allow the use of existing libraries.\n *\n * Usage: include(\"XMLHttpRequest.js\") and use XMLHttpRequest per W3C specs.\n *\n * @author Dan DeFelippi \n * @contributor David Ellis \n * @license MIT\n */\n\nvar Url = require(\"url\");\nvar spawn = require(\"child_process\").spawn;\nvar fs = require(\"fs\");\n\nexports.XMLHttpRequest = function() {\n \"use strict\";\n\n /**\n * Private variables\n */\n var self = this;\n var http = require(\"http\");\n var https = require(\"https\");\n\n // Holds http.js objects\n var request;\n var response;\n\n // Request settings\n var settings = {};\n\n // Disable header blacklist.\n // Not part of XHR specs.\n var disableHeaderCheck = false;\n\n // Set some default headers\n var defaultHeaders = {\n \"User-Agent\": \"node-XMLHttpRequest\",\n \"Accept\": \"*/*\",\n };\n\n var headers = {};\n var headersCase = {};\n\n // These headers are not user setable.\n // The following are allowed but banned in the spec:\n // * user-agent\n var forbiddenRequestHeaders = [\n \"accept-charset\",\n \"accept-encoding\",\n \"access-control-request-headers\",\n \"access-control-request-method\",\n \"connection\",\n \"content-length\",\n \"content-transfer-encoding\",\n \"cookie\",\n \"cookie2\",\n \"date\",\n \"expect\",\n \"host\",\n \"keep-alive\",\n \"origin\",\n \"referer\",\n \"te\",\n \"trailer\",\n \"transfer-encoding\",\n \"upgrade\",\n \"via\"\n ];\n\n // These request methods are not allowed\n var forbiddenRequestMethods = [\n \"TRACE\",\n \"TRACK\",\n \"CONNECT\"\n ];\n\n // Send flag\n var sendFlag = false;\n // Error flag, used when errors occur or abort is called\n var errorFlag = false;\n\n // Event listeners\n var listeners = {};\n\n /**\n * Constants\n */\n\n this.UNSENT = 0;\n this.OPENED = 1;\n this.HEADERS_RECEIVED = 2;\n this.LOADING = 3;\n this.DONE = 4;\n\n /**\n * Public vars\n */\n\n // Current state\n this.readyState = this.UNSENT;\n\n // default ready state change handler in case one is not set or is set late\n this.onreadystatechange = null;\n\n // Result & response\n this.responseText = \"\";\n this.responseXML = \"\";\n this.status = null;\n this.statusText = null;\n \n // Whether cross-site Access-Control requests should be made using\n // credentials such as cookies or authorization headers\n this.withCredentials = false;\n\n /**\n * Private methods\n */\n\n /**\n * Check if the specified header is allowed.\n *\n * @param string header Header to validate\n * @return boolean False if not allowed, otherwise true\n */\n var isAllowedHttpHeader = function(header) {\n return disableHeaderCheck || (header && forbiddenRequestHeaders.indexOf(header.toLowerCase()) === -1);\n };\n\n /**\n * Check if the specified method is allowed.\n *\n * @param string method Request method to validate\n * @return boolean False if not allowed, otherwise true\n */\n var isAllowedHttpMethod = function(method) {\n return (method && forbiddenRequestMethods.indexOf(method) === -1);\n };\n\n /**\n * Public methods\n */\n\n /**\n * Open the connection. Currently supports local server requests.\n *\n * @param string method Connection method (eg GET, POST)\n * @param string url URL for the connection.\n * @param boolean async Asynchronous connection. Default is true.\n * @param string user Username for basic authentication (optional)\n * @param string password Password for basic authentication (optional)\n */\n this.open = function(method, url, async, user, password) {\n this.abort();\n errorFlag = false;\n\n // Check for valid request method\n if (!isAllowedHttpMethod(method)) {\n throw new Error(\"SecurityError: Request method not allowed\");\n }\n\n settings = {\n \"method\": method,\n \"url\": url.toString(),\n \"async\": (typeof async !== \"boolean\" ? true : async),\n \"user\": user || null,\n \"password\": password || null\n };\n\n setState(this.OPENED);\n };\n\n /**\n * Disables or enables isAllowedHttpHeader() check the request. Enabled by default.\n * This does not conform to the W3C spec.\n *\n * @param boolean state Enable or disable header checking.\n */\n this.setDisableHeaderCheck = function(state) {\n disableHeaderCheck = state;\n };\n\n /**\n * Sets a header for the request or appends the value if one is already set.\n *\n * @param string header Header name\n * @param string value Header value\n */\n this.setRequestHeader = function(header, value) {\n if (this.readyState !== this.OPENED) {\n throw new Error(\"INVALID_STATE_ERR: setRequestHeader can only be called when state is OPEN\");\n }\n if (!isAllowedHttpHeader(header)) {\n console.warn(\"Refused to set unsafe header \\\"\" + header + \"\\\"\");\n return;\n }\n if (sendFlag) {\n throw new Error(\"INVALID_STATE_ERR: send flag is true\");\n }\n header = headersCase[header.toLowerCase()] || header;\n headersCase[header.toLowerCase()] = header;\n headers[header] = headers[header] ? headers[header] + ', ' + value : value;\n };\n\n /**\n * Gets a header from the server response.\n *\n * @param string header Name of header to get.\n * @return string Text of the header or null if it doesn't exist.\n */\n this.getResponseHeader = function(header) {\n if (typeof header === \"string\"\n && this.readyState > this.OPENED\n && response\n && response.headers\n && response.headers[header.toLowerCase()]\n && !errorFlag\n ) {\n return response.headers[header.toLowerCase()];\n }\n\n return null;\n };\n\n /**\n * Gets all the response headers.\n *\n * @return string A string with all response headers separated by CR+LF\n */\n this.getAllResponseHeaders = function() {\n if (this.readyState < this.HEADERS_RECEIVED || errorFlag) {\n return \"\";\n }\n var result = \"\";\n\n for (var i in response.headers) {\n // Cookie headers are excluded\n if (i !== \"set-cookie\" && i !== \"set-cookie2\") {\n result += i + \": \" + response.headers[i] + \"\\r\\n\";\n }\n }\n return result.substr(0, result.length - 2);\n };\n\n /**\n * Gets a request header\n *\n * @param string name Name of header to get\n * @return string Returns the request header or empty string if not set\n */\n this.getRequestHeader = function(name) {\n if (typeof name === \"string\" && headersCase[name.toLowerCase()]) {\n return headers[headersCase[name.toLowerCase()]];\n }\n\n return \"\";\n };\n\n /**\n * Sends the request to the server.\n *\n * @param string data Optional data to send as request body.\n */\n this.send = function(data) {\n if (this.readyState !== this.OPENED) {\n throw new Error(\"INVALID_STATE_ERR: connection must be opened before send() is called\");\n }\n\n if (sendFlag) {\n throw new Error(\"INVALID_STATE_ERR: send has already been called\");\n }\n\n var ssl = false, local = false;\n var url = Url.parse(settings.url);\n var host;\n // Determine the server\n switch (url.protocol) {\n case \"https:\":\n ssl = true;\n // SSL & non-SSL both need host, no break here.\n case \"http:\":\n host = url.hostname;\n break;\n\n case \"file:\":\n local = true;\n break;\n\n case undefined:\n case null:\n case \"\":\n host = \"localhost\";\n break;\n\n default:\n throw new Error(\"Protocol not supported.\");\n }\n\n // Load files off the local filesystem (file://)\n if (local) {\n if (settings.method !== \"GET\") {\n throw new Error(\"XMLHttpRequest: Only GET method is supported\");\n }\n\n if (settings.async) {\n fs.readFile(url.pathname, \"utf8\", function(error, data) {\n if (error) {\n self.handleError(error);\n } else {\n self.status = 200;\n self.responseText = data;\n setState(self.DONE);\n }\n });\n } else {\n try {\n this.responseText = fs.readFileSync(url.pathname, \"utf8\");\n this.status = 200;\n setState(self.DONE);\n } catch(e) {\n this.handleError(e);\n }\n }\n\n return;\n }\n\n // Default to port 80. If accessing localhost on another port be sure\n // to use http://localhost:port/path\n var port = url.port || (ssl ? 443 : 80);\n // Add query string if one is used\n var uri = url.pathname + (url.search ? url.search : \"\");\n\n // Set the defaults if they haven't been set\n for (var name in defaultHeaders) {\n if (!headersCase[name.toLowerCase()]) {\n headers[name] = defaultHeaders[name];\n }\n }\n\n // Set the Host header or the server may reject the request\n headers.Host = host;\n if (!((ssl && port === 443) || port === 80)) {\n headers.Host += \":\" + url.port;\n }\n\n // Set Basic Auth if necessary\n if (settings.user) {\n if (typeof settings.password === \"undefined\") {\n settings.password = \"\";\n }\n var authBuf = new Buffer(settings.user + \":\" + settings.password);\n headers.Authorization = \"Basic \" + authBuf.toString(\"base64\");\n }\n\n // Set content length header\n if (settings.method === \"GET\" || settings.method === \"HEAD\") {\n data = null;\n } else if (data) {\n headers[\"Content-Length\"] = Buffer.isBuffer(data) ? data.length : Buffer.byteLength(data);\n\n if (!headers[\"Content-Type\"]) {\n headers[\"Content-Type\"] = \"text/plain;charset=UTF-8\";\n }\n } else if (settings.method === \"POST\") {\n // For a post with no data set Content-Length: 0.\n // This is required by buggy servers that don't meet the specs.\n headers[\"Content-Length\"] = 0;\n }\n\n var options = {\n host: host,\n port: port,\n path: uri,\n method: settings.method,\n headers: headers,\n agent: false,\n withCredentials: self.withCredentials\n };\n\n // Reset error flag\n errorFlag = false;\n\n // Handle async requests\n if (settings.async) {\n // Use the proper protocol\n var doRequest = ssl ? https.request : http.request;\n\n // Request is being sent, set send flag\n sendFlag = true;\n\n // As per spec, this is called here for historical reasons.\n self.dispatchEvent(\"readystatechange\");\n\n // Handler for the response\n var responseHandler = function responseHandler(resp) {\n // Set response var to the response we got back\n // This is so it remains accessable outside this scope\n response = resp;\n // Check for redirect\n // @TODO Prevent looped redirects\n if (response.statusCode === 301 || response.statusCode === 302 || response.statusCode === 303 || response.statusCode === 307) {\n // Change URL to the redirect location\n settings.url = response.headers.location;\n var url = Url.parse(settings.url);\n // Set host var in case it's used later\n host = url.hostname;\n // Options for the new request\n var newOptions = {\n hostname: url.hostname,\n port: url.port,\n path: url.path,\n method: response.statusCode === 303 ? \"GET\" : settings.method,\n headers: headers,\n withCredentials: self.withCredentials\n };\n\n // Issue the new request\n request = doRequest(newOptions, responseHandler).on(\"error\", errorHandler);\n request.end();\n // @TODO Check if an XHR event needs to be fired here\n return;\n }\n\n response.setEncoding(\"utf8\");\n\n setState(self.HEADERS_RECEIVED);\n self.status = response.statusCode;\n\n response.on(\"data\", function(chunk) {\n // Make sure there's some data\n if (chunk) {\n self.responseText += chunk;\n }\n // Don't emit state changes if the connection has been aborted.\n if (sendFlag) {\n setState(self.LOADING);\n }\n });\n\n response.on(\"end\", function() {\n if (sendFlag) {\n // Discard the end event if the connection has been aborted\n setState(self.DONE);\n sendFlag = false;\n }\n });\n\n response.on(\"error\", function(error) {\n self.handleError(error);\n });\n };\n\n // Error handler for the request\n var errorHandler = function errorHandler(error) {\n self.handleError(error);\n };\n\n // Create the request\n request = doRequest(options, responseHandler).on(\"error\", errorHandler);\n\n // Node 0.4 and later won't accept empty data. Make sure it's needed.\n if (data) {\n request.write(data);\n }\n\n request.end();\n\n self.dispatchEvent(\"loadstart\");\n } else { // Synchronous\n // Create a temporary file for communication with the other Node process\n var contentFile = \".node-xmlhttprequest-content-\" + process.pid;\n var syncFile = \".node-xmlhttprequest-sync-\" + process.pid;\n fs.writeFileSync(syncFile, \"\", \"utf8\");\n // The async request the other Node process executes\n var execString = \"var http = require('http'), https = require('https'), fs = require('fs');\"\n + \"var doRequest = http\" + (ssl ? \"s\" : \"\") + \".request;\"\n + \"var options = \" + JSON.stringify(options) + \";\"\n + \"var responseText = '';\"\n + \"var req = doRequest(options, function(response) {\"\n + \"response.setEncoding('utf8');\"\n + \"response.on('data', function(chunk) {\"\n + \" responseText += chunk;\"\n + \"});\"\n + \"response.on('end', function() {\"\n + \"fs.writeFileSync('\" + contentFile + \"', JSON.stringify({err: null, data: {statusCode: response.statusCode, headers: response.headers, text: responseText}}), 'utf8');\"\n + \"fs.unlinkSync('\" + syncFile + \"');\"\n + \"});\"\n + \"response.on('error', function(error) {\"\n + \"fs.writeFileSync('\" + contentFile + \"', JSON.stringify({err: error}), 'utf8');\"\n + \"fs.unlinkSync('\" + syncFile + \"');\"\n + \"});\"\n + \"}).on('error', function(error) {\"\n + \"fs.writeFileSync('\" + contentFile + \"', JSON.stringify({err: error}), 'utf8');\"\n + \"fs.unlinkSync('\" + syncFile + \"');\"\n + \"});\"\n + (data ? \"req.write('\" + JSON.stringify(data).slice(1,-1).replace(/'/g, \"\\\\'\") + \"');\":\"\")\n + \"req.end();\";\n // Start the other Node Process, executing this string\n var syncProc = spawn(process.argv[0], [\"-e\", execString]);\n while(fs.existsSync(syncFile)) {\n // Wait while the sync file is empty\n }\n var resp = JSON.parse(fs.readFileSync(contentFile, 'utf8'));\n // Kill the child process once the file has data\n syncProc.stdin.end();\n // Remove the temporary file\n fs.unlinkSync(contentFile);\n\n if (resp.err) {\n self.handleError(resp.err);\n } else {\n response = resp.data;\n self.status = resp.data.statusCode;\n self.responseText = resp.data.text;\n setState(self.DONE);\n }\n }\n };\n\n /**\n * Called when an error is encountered to deal with it.\n */\n this.handleError = function(error) {\n this.status = 0;\n this.statusText = error;\n this.responseText = error.stack;\n errorFlag = true;\n setState(this.DONE);\n this.dispatchEvent('error');\n };\n\n /**\n * Aborts a request.\n */\n this.abort = function() {\n if (request) {\n request.abort();\n request = null;\n }\n\n headers = defaultHeaders;\n this.status = 0;\n this.responseText = \"\";\n this.responseXML = \"\";\n\n errorFlag = true;\n\n if (this.readyState !== this.UNSENT\n && (this.readyState !== this.OPENED || sendFlag)\n && this.readyState !== this.DONE) {\n sendFlag = false;\n setState(this.DONE);\n }\n this.readyState = this.UNSENT;\n this.dispatchEvent('abort');\n };\n\n /**\n * Adds an event listener. Preferred method of binding to events.\n */\n this.addEventListener = function(event, callback) {\n if (!(event in listeners)) {\n listeners[event] = [];\n }\n // Currently allows duplicate callbacks. Should it?\n listeners[event].push(callback);\n };\n\n /**\n * Remove an event callback that has already been bound.\n * Only works on the matching funciton, cannot be a copy.\n */\n this.removeEventListener = function(event, callback) {\n if (event in listeners) {\n // Filter will return a new array with the callback removed\n listeners[event] = listeners[event].filter(function(ev) {\n return ev !== callback;\n });\n }\n };\n\n /**\n * Dispatch any events, including both \"on\" methods and events attached using addEventListener.\n */\n this.dispatchEvent = function(event) {\n if (typeof self[\"on\" + event] === \"function\") {\n self[\"on\" + event]();\n }\n if (event in listeners) {\n for (var i = 0, len = listeners[event].length; i < len; i++) {\n listeners[event][i].call(self);\n }\n }\n };\n\n /**\n * Changes readyState and calls onreadystatechange.\n *\n * @param int state New state\n */\n var setState = function(state) {\n if (state == self.LOADING || self.readyState !== state) {\n self.readyState = state;\n\n if (settings.async || self.readyState < self.OPENED || self.readyState === self.DONE) {\n self.dispatchEvent(\"readystatechange\");\n }\n\n if (self.readyState === self.DONE && !errorFlag) {\n self.dispatchEvent(\"load\");\n // @TODO figure out InspectorInstrumentation::didLoadXHR(cookie)\n self.dispatchEvent(\"loadend\");\n }\n }\n };\n};\n","(function(nacl) {\n'use strict';\n\n// Ported in 2014 by Dmitry Chestnykh and Devi Mandiri.\n// Public domain.\n//\n// Implementation derived from TweetNaCl version 20140427.\n// See for details: http://tweetnacl.cr.yp.to/\n\nvar gf = function(init) {\n var i, r = new Float64Array(16);\n if (init) for (i = 0; i < init.length; i++) r[i] = init[i];\n return r;\n};\n\n// Pluggable, initialized in high-level API below.\nvar randombytes = function(/* x, n */) { throw new Error('no PRNG'); };\n\nvar _0 = new Uint8Array(16);\nvar _9 = new Uint8Array(32); _9[0] = 9;\n\nvar gf0 = gf(),\n gf1 = gf([1]),\n _121665 = gf([0xdb41, 1]),\n D = gf([0x78a3, 0x1359, 0x4dca, 0x75eb, 0xd8ab, 0x4141, 0x0a4d, 0x0070, 0xe898, 0x7779, 0x4079, 0x8cc7, 0xfe73, 0x2b6f, 0x6cee, 0x5203]),\n D2 = gf([0xf159, 0x26b2, 0x9b94, 0xebd6, 0xb156, 0x8283, 0x149a, 0x00e0, 0xd130, 0xeef3, 0x80f2, 0x198e, 0xfce7, 0x56df, 0xd9dc, 0x2406]),\n X = gf([0xd51a, 0x8f25, 0x2d60, 0xc956, 0xa7b2, 0x9525, 0xc760, 0x692c, 0xdc5c, 0xfdd6, 0xe231, 0xc0a4, 0x53fe, 0xcd6e, 0x36d3, 0x2169]),\n Y = gf([0x6658, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666]),\n I = gf([0xa0b0, 0x4a0e, 0x1b27, 0xc4ee, 0xe478, 0xad2f, 0x1806, 0x2f43, 0xd7a7, 0x3dfb, 0x0099, 0x2b4d, 0xdf0b, 0x4fc1, 0x2480, 0x2b83]);\n\nfunction ts64(x, i, h, l) {\n x[i] = (h >> 24) & 0xff;\n x[i+1] = (h >> 16) & 0xff;\n x[i+2] = (h >> 8) & 0xff;\n x[i+3] = h & 0xff;\n x[i+4] = (l >> 24) & 0xff;\n x[i+5] = (l >> 16) & 0xff;\n x[i+6] = (l >> 8) & 0xff;\n x[i+7] = l & 0xff;\n}\n\nfunction vn(x, xi, y, yi, n) {\n var i,d = 0;\n for (i = 0; i < n; i++) d |= x[xi+i]^y[yi+i];\n return (1 & ((d - 1) >>> 8)) - 1;\n}\n\nfunction crypto_verify_16(x, xi, y, yi) {\n return vn(x,xi,y,yi,16);\n}\n\nfunction crypto_verify_32(x, xi, y, yi) {\n return vn(x,xi,y,yi,32);\n}\n\nfunction core_salsa20(o, p, k, c) {\n var j0 = c[ 0] & 0xff | (c[ 1] & 0xff)<<8 | (c[ 2] & 0xff)<<16 | (c[ 3] & 0xff)<<24,\n j1 = k[ 0] & 0xff | (k[ 1] & 0xff)<<8 | (k[ 2] & 0xff)<<16 | (k[ 3] & 0xff)<<24,\n j2 = k[ 4] & 0xff | (k[ 5] & 0xff)<<8 | (k[ 6] & 0xff)<<16 | (k[ 7] & 0xff)<<24,\n j3 = k[ 8] & 0xff | (k[ 9] & 0xff)<<8 | (k[10] & 0xff)<<16 | (k[11] & 0xff)<<24,\n j4 = k[12] & 0xff | (k[13] & 0xff)<<8 | (k[14] & 0xff)<<16 | (k[15] & 0xff)<<24,\n j5 = c[ 4] & 0xff | (c[ 5] & 0xff)<<8 | (c[ 6] & 0xff)<<16 | (c[ 7] & 0xff)<<24,\n j6 = p[ 0] & 0xff | (p[ 1] & 0xff)<<8 | (p[ 2] & 0xff)<<16 | (p[ 3] & 0xff)<<24,\n j7 = p[ 4] & 0xff | (p[ 5] & 0xff)<<8 | (p[ 6] & 0xff)<<16 | (p[ 7] & 0xff)<<24,\n j8 = p[ 8] & 0xff | (p[ 9] & 0xff)<<8 | (p[10] & 0xff)<<16 | (p[11] & 0xff)<<24,\n j9 = p[12] & 0xff | (p[13] & 0xff)<<8 | (p[14] & 0xff)<<16 | (p[15] & 0xff)<<24,\n j10 = c[ 8] & 0xff | (c[ 9] & 0xff)<<8 | (c[10] & 0xff)<<16 | (c[11] & 0xff)<<24,\n j11 = k[16] & 0xff | (k[17] & 0xff)<<8 | (k[18] & 0xff)<<16 | (k[19] & 0xff)<<24,\n j12 = k[20] & 0xff | (k[21] & 0xff)<<8 | (k[22] & 0xff)<<16 | (k[23] & 0xff)<<24,\n j13 = k[24] & 0xff | (k[25] & 0xff)<<8 | (k[26] & 0xff)<<16 | (k[27] & 0xff)<<24,\n j14 = k[28] & 0xff | (k[29] & 0xff)<<8 | (k[30] & 0xff)<<16 | (k[31] & 0xff)<<24,\n j15 = c[12] & 0xff | (c[13] & 0xff)<<8 | (c[14] & 0xff)<<16 | (c[15] & 0xff)<<24;\n\n var x0 = j0, x1 = j1, x2 = j2, x3 = j3, x4 = j4, x5 = j5, x6 = j6, x7 = j7,\n x8 = j8, x9 = j9, x10 = j10, x11 = j11, x12 = j12, x13 = j13, x14 = j14,\n x15 = j15, u;\n\n for (var i = 0; i < 20; i += 2) {\n u = x0 + x12 | 0;\n x4 ^= u<<7 | u>>>(32-7);\n u = x4 + x0 | 0;\n x8 ^= u<<9 | u>>>(32-9);\n u = x8 + x4 | 0;\n x12 ^= u<<13 | u>>>(32-13);\n u = x12 + x8 | 0;\n x0 ^= u<<18 | u>>>(32-18);\n\n u = x5 + x1 | 0;\n x9 ^= u<<7 | u>>>(32-7);\n u = x9 + x5 | 0;\n x13 ^= u<<9 | u>>>(32-9);\n u = x13 + x9 | 0;\n x1 ^= u<<13 | u>>>(32-13);\n u = x1 + x13 | 0;\n x5 ^= u<<18 | u>>>(32-18);\n\n u = x10 + x6 | 0;\n x14 ^= u<<7 | u>>>(32-7);\n u = x14 + x10 | 0;\n x2 ^= u<<9 | u>>>(32-9);\n u = x2 + x14 | 0;\n x6 ^= u<<13 | u>>>(32-13);\n u = x6 + x2 | 0;\n x10 ^= u<<18 | u>>>(32-18);\n\n u = x15 + x11 | 0;\n x3 ^= u<<7 | u>>>(32-7);\n u = x3 + x15 | 0;\n x7 ^= u<<9 | u>>>(32-9);\n u = x7 + x3 | 0;\n x11 ^= u<<13 | u>>>(32-13);\n u = x11 + x7 | 0;\n x15 ^= u<<18 | u>>>(32-18);\n\n u = x0 + x3 | 0;\n x1 ^= u<<7 | u>>>(32-7);\n u = x1 + x0 | 0;\n x2 ^= u<<9 | u>>>(32-9);\n u = x2 + x1 | 0;\n x3 ^= u<<13 | u>>>(32-13);\n u = x3 + x2 | 0;\n x0 ^= u<<18 | u>>>(32-18);\n\n u = x5 + x4 | 0;\n x6 ^= u<<7 | u>>>(32-7);\n u = x6 + x5 | 0;\n x7 ^= u<<9 | u>>>(32-9);\n u = x7 + x6 | 0;\n x4 ^= u<<13 | u>>>(32-13);\n u = x4 + x7 | 0;\n x5 ^= u<<18 | u>>>(32-18);\n\n u = x10 + x9 | 0;\n x11 ^= u<<7 | u>>>(32-7);\n u = x11 + x10 | 0;\n x8 ^= u<<9 | u>>>(32-9);\n u = x8 + x11 | 0;\n x9 ^= u<<13 | u>>>(32-13);\n u = x9 + x8 | 0;\n x10 ^= u<<18 | u>>>(32-18);\n\n u = x15 + x14 | 0;\n x12 ^= u<<7 | u>>>(32-7);\n u = x12 + x15 | 0;\n x13 ^= u<<9 | u>>>(32-9);\n u = x13 + x12 | 0;\n x14 ^= u<<13 | u>>>(32-13);\n u = x14 + x13 | 0;\n x15 ^= u<<18 | u>>>(32-18);\n }\n x0 = x0 + j0 | 0;\n x1 = x1 + j1 | 0;\n x2 = x2 + j2 | 0;\n x3 = x3 + j3 | 0;\n x4 = x4 + j4 | 0;\n x5 = x5 + j5 | 0;\n x6 = x6 + j6 | 0;\n x7 = x7 + j7 | 0;\n x8 = x8 + j8 | 0;\n x9 = x9 + j9 | 0;\n x10 = x10 + j10 | 0;\n x11 = x11 + j11 | 0;\n x12 = x12 + j12 | 0;\n x13 = x13 + j13 | 0;\n x14 = x14 + j14 | 0;\n x15 = x15 + j15 | 0;\n\n o[ 0] = x0 >>> 0 & 0xff;\n o[ 1] = x0 >>> 8 & 0xff;\n o[ 2] = x0 >>> 16 & 0xff;\n o[ 3] = x0 >>> 24 & 0xff;\n\n o[ 4] = x1 >>> 0 & 0xff;\n o[ 5] = x1 >>> 8 & 0xff;\n o[ 6] = x1 >>> 16 & 0xff;\n o[ 7] = x1 >>> 24 & 0xff;\n\n o[ 8] = x2 >>> 0 & 0xff;\n o[ 9] = x2 >>> 8 & 0xff;\n o[10] = x2 >>> 16 & 0xff;\n o[11] = x2 >>> 24 & 0xff;\n\n o[12] = x3 >>> 0 & 0xff;\n o[13] = x3 >>> 8 & 0xff;\n o[14] = x3 >>> 16 & 0xff;\n o[15] = x3 >>> 24 & 0xff;\n\n o[16] = x4 >>> 0 & 0xff;\n o[17] = x4 >>> 8 & 0xff;\n o[18] = x4 >>> 16 & 0xff;\n o[19] = x4 >>> 24 & 0xff;\n\n o[20] = x5 >>> 0 & 0xff;\n o[21] = x5 >>> 8 & 0xff;\n o[22] = x5 >>> 16 & 0xff;\n o[23] = x5 >>> 24 & 0xff;\n\n o[24] = x6 >>> 0 & 0xff;\n o[25] = x6 >>> 8 & 0xff;\n o[26] = x6 >>> 16 & 0xff;\n o[27] = x6 >>> 24 & 0xff;\n\n o[28] = x7 >>> 0 & 0xff;\n o[29] = x7 >>> 8 & 0xff;\n o[30] = x7 >>> 16 & 0xff;\n o[31] = x7 >>> 24 & 0xff;\n\n o[32] = x8 >>> 0 & 0xff;\n o[33] = x8 >>> 8 & 0xff;\n o[34] = x8 >>> 16 & 0xff;\n o[35] = x8 >>> 24 & 0xff;\n\n o[36] = x9 >>> 0 & 0xff;\n o[37] = x9 >>> 8 & 0xff;\n o[38] = x9 >>> 16 & 0xff;\n o[39] = x9 >>> 24 & 0xff;\n\n o[40] = x10 >>> 0 & 0xff;\n o[41] = x10 >>> 8 & 0xff;\n o[42] = x10 >>> 16 & 0xff;\n o[43] = x10 >>> 24 & 0xff;\n\n o[44] = x11 >>> 0 & 0xff;\n o[45] = x11 >>> 8 & 0xff;\n o[46] = x11 >>> 16 & 0xff;\n o[47] = x11 >>> 24 & 0xff;\n\n o[48] = x12 >>> 0 & 0xff;\n o[49] = x12 >>> 8 & 0xff;\n o[50] = x12 >>> 16 & 0xff;\n o[51] = x12 >>> 24 & 0xff;\n\n o[52] = x13 >>> 0 & 0xff;\n o[53] = x13 >>> 8 & 0xff;\n o[54] = x13 >>> 16 & 0xff;\n o[55] = x13 >>> 24 & 0xff;\n\n o[56] = x14 >>> 0 & 0xff;\n o[57] = x14 >>> 8 & 0xff;\n o[58] = x14 >>> 16 & 0xff;\n o[59] = x14 >>> 24 & 0xff;\n\n o[60] = x15 >>> 0 & 0xff;\n o[61] = x15 >>> 8 & 0xff;\n o[62] = x15 >>> 16 & 0xff;\n o[63] = x15 >>> 24 & 0xff;\n}\n\nfunction core_hsalsa20(o,p,k,c) {\n var j0 = c[ 0] & 0xff | (c[ 1] & 0xff)<<8 | (c[ 2] & 0xff)<<16 | (c[ 3] & 0xff)<<24,\n j1 = k[ 0] & 0xff | (k[ 1] & 0xff)<<8 | (k[ 2] & 0xff)<<16 | (k[ 3] & 0xff)<<24,\n j2 = k[ 4] & 0xff | (k[ 5] & 0xff)<<8 | (k[ 6] & 0xff)<<16 | (k[ 7] & 0xff)<<24,\n j3 = k[ 8] & 0xff | (k[ 9] & 0xff)<<8 | (k[10] & 0xff)<<16 | (k[11] & 0xff)<<24,\n j4 = k[12] & 0xff | (k[13] & 0xff)<<8 | (k[14] & 0xff)<<16 | (k[15] & 0xff)<<24,\n j5 = c[ 4] & 0xff | (c[ 5] & 0xff)<<8 | (c[ 6] & 0xff)<<16 | (c[ 7] & 0xff)<<24,\n j6 = p[ 0] & 0xff | (p[ 1] & 0xff)<<8 | (p[ 2] & 0xff)<<16 | (p[ 3] & 0xff)<<24,\n j7 = p[ 4] & 0xff | (p[ 5] & 0xff)<<8 | (p[ 6] & 0xff)<<16 | (p[ 7] & 0xff)<<24,\n j8 = p[ 8] & 0xff | (p[ 9] & 0xff)<<8 | (p[10] & 0xff)<<16 | (p[11] & 0xff)<<24,\n j9 = p[12] & 0xff | (p[13] & 0xff)<<8 | (p[14] & 0xff)<<16 | (p[15] & 0xff)<<24,\n j10 = c[ 8] & 0xff | (c[ 9] & 0xff)<<8 | (c[10] & 0xff)<<16 | (c[11] & 0xff)<<24,\n j11 = k[16] & 0xff | (k[17] & 0xff)<<8 | (k[18] & 0xff)<<16 | (k[19] & 0xff)<<24,\n j12 = k[20] & 0xff | (k[21] & 0xff)<<8 | (k[22] & 0xff)<<16 | (k[23] & 0xff)<<24,\n j13 = k[24] & 0xff | (k[25] & 0xff)<<8 | (k[26] & 0xff)<<16 | (k[27] & 0xff)<<24,\n j14 = k[28] & 0xff | (k[29] & 0xff)<<8 | (k[30] & 0xff)<<16 | (k[31] & 0xff)<<24,\n j15 = c[12] & 0xff | (c[13] & 0xff)<<8 | (c[14] & 0xff)<<16 | (c[15] & 0xff)<<24;\n\n var x0 = j0, x1 = j1, x2 = j2, x3 = j3, x4 = j4, x5 = j5, x6 = j6, x7 = j7,\n x8 = j8, x9 = j9, x10 = j10, x11 = j11, x12 = j12, x13 = j13, x14 = j14,\n x15 = j15, u;\n\n for (var i = 0; i < 20; i += 2) {\n u = x0 + x12 | 0;\n x4 ^= u<<7 | u>>>(32-7);\n u = x4 + x0 | 0;\n x8 ^= u<<9 | u>>>(32-9);\n u = x8 + x4 | 0;\n x12 ^= u<<13 | u>>>(32-13);\n u = x12 + x8 | 0;\n x0 ^= u<<18 | u>>>(32-18);\n\n u = x5 + x1 | 0;\n x9 ^= u<<7 | u>>>(32-7);\n u = x9 + x5 | 0;\n x13 ^= u<<9 | u>>>(32-9);\n u = x13 + x9 | 0;\n x1 ^= u<<13 | u>>>(32-13);\n u = x1 + x13 | 0;\n x5 ^= u<<18 | u>>>(32-18);\n\n u = x10 + x6 | 0;\n x14 ^= u<<7 | u>>>(32-7);\n u = x14 + x10 | 0;\n x2 ^= u<<9 | u>>>(32-9);\n u = x2 + x14 | 0;\n x6 ^= u<<13 | u>>>(32-13);\n u = x6 + x2 | 0;\n x10 ^= u<<18 | u>>>(32-18);\n\n u = x15 + x11 | 0;\n x3 ^= u<<7 | u>>>(32-7);\n u = x3 + x15 | 0;\n x7 ^= u<<9 | u>>>(32-9);\n u = x7 + x3 | 0;\n x11 ^= u<<13 | u>>>(32-13);\n u = x11 + x7 | 0;\n x15 ^= u<<18 | u>>>(32-18);\n\n u = x0 + x3 | 0;\n x1 ^= u<<7 | u>>>(32-7);\n u = x1 + x0 | 0;\n x2 ^= u<<9 | u>>>(32-9);\n u = x2 + x1 | 0;\n x3 ^= u<<13 | u>>>(32-13);\n u = x3 + x2 | 0;\n x0 ^= u<<18 | u>>>(32-18);\n\n u = x5 + x4 | 0;\n x6 ^= u<<7 | u>>>(32-7);\n u = x6 + x5 | 0;\n x7 ^= u<<9 | u>>>(32-9);\n u = x7 + x6 | 0;\n x4 ^= u<<13 | u>>>(32-13);\n u = x4 + x7 | 0;\n x5 ^= u<<18 | u>>>(32-18);\n\n u = x10 + x9 | 0;\n x11 ^= u<<7 | u>>>(32-7);\n u = x11 + x10 | 0;\n x8 ^= u<<9 | u>>>(32-9);\n u = x8 + x11 | 0;\n x9 ^= u<<13 | u>>>(32-13);\n u = x9 + x8 | 0;\n x10 ^= u<<18 | u>>>(32-18);\n\n u = x15 + x14 | 0;\n x12 ^= u<<7 | u>>>(32-7);\n u = x12 + x15 | 0;\n x13 ^= u<<9 | u>>>(32-9);\n u = x13 + x12 | 0;\n x14 ^= u<<13 | u>>>(32-13);\n u = x14 + x13 | 0;\n x15 ^= u<<18 | u>>>(32-18);\n }\n\n o[ 0] = x0 >>> 0 & 0xff;\n o[ 1] = x0 >>> 8 & 0xff;\n o[ 2] = x0 >>> 16 & 0xff;\n o[ 3] = x0 >>> 24 & 0xff;\n\n o[ 4] = x5 >>> 0 & 0xff;\n o[ 5] = x5 >>> 8 & 0xff;\n o[ 6] = x5 >>> 16 & 0xff;\n o[ 7] = x5 >>> 24 & 0xff;\n\n o[ 8] = x10 >>> 0 & 0xff;\n o[ 9] = x10 >>> 8 & 0xff;\n o[10] = x10 >>> 16 & 0xff;\n o[11] = x10 >>> 24 & 0xff;\n\n o[12] = x15 >>> 0 & 0xff;\n o[13] = x15 >>> 8 & 0xff;\n o[14] = x15 >>> 16 & 0xff;\n o[15] = x15 >>> 24 & 0xff;\n\n o[16] = x6 >>> 0 & 0xff;\n o[17] = x6 >>> 8 & 0xff;\n o[18] = x6 >>> 16 & 0xff;\n o[19] = x6 >>> 24 & 0xff;\n\n o[20] = x7 >>> 0 & 0xff;\n o[21] = x7 >>> 8 & 0xff;\n o[22] = x7 >>> 16 & 0xff;\n o[23] = x7 >>> 24 & 0xff;\n\n o[24] = x8 >>> 0 & 0xff;\n o[25] = x8 >>> 8 & 0xff;\n o[26] = x8 >>> 16 & 0xff;\n o[27] = x8 >>> 24 & 0xff;\n\n o[28] = x9 >>> 0 & 0xff;\n o[29] = x9 >>> 8 & 0xff;\n o[30] = x9 >>> 16 & 0xff;\n o[31] = x9 >>> 24 & 0xff;\n}\n\nfunction crypto_core_salsa20(out,inp,k,c) {\n core_salsa20(out,inp,k,c);\n}\n\nfunction crypto_core_hsalsa20(out,inp,k,c) {\n core_hsalsa20(out,inp,k,c);\n}\n\nvar sigma = new Uint8Array([101, 120, 112, 97, 110, 100, 32, 51, 50, 45, 98, 121, 116, 101, 32, 107]);\n // \"expand 32-byte k\"\n\nfunction crypto_stream_salsa20_xor(c,cpos,m,mpos,b,n,k) {\n var z = new Uint8Array(16), x = new Uint8Array(64);\n var u, i;\n for (i = 0; i < 16; i++) z[i] = 0;\n for (i = 0; i < 8; i++) z[i] = n[i];\n while (b >= 64) {\n crypto_core_salsa20(x,z,k,sigma);\n for (i = 0; i < 64; i++) c[cpos+i] = m[mpos+i] ^ x[i];\n u = 1;\n for (i = 8; i < 16; i++) {\n u = u + (z[i] & 0xff) | 0;\n z[i] = u & 0xff;\n u >>>= 8;\n }\n b -= 64;\n cpos += 64;\n mpos += 64;\n }\n if (b > 0) {\n crypto_core_salsa20(x,z,k,sigma);\n for (i = 0; i < b; i++) c[cpos+i] = m[mpos+i] ^ x[i];\n }\n return 0;\n}\n\nfunction crypto_stream_salsa20(c,cpos,b,n,k) {\n var z = new Uint8Array(16), x = new Uint8Array(64);\n var u, i;\n for (i = 0; i < 16; i++) z[i] = 0;\n for (i = 0; i < 8; i++) z[i] = n[i];\n while (b >= 64) {\n crypto_core_salsa20(x,z,k,sigma);\n for (i = 0; i < 64; i++) c[cpos+i] = x[i];\n u = 1;\n for (i = 8; i < 16; i++) {\n u = u + (z[i] & 0xff) | 0;\n z[i] = u & 0xff;\n u >>>= 8;\n }\n b -= 64;\n cpos += 64;\n }\n if (b > 0) {\n crypto_core_salsa20(x,z,k,sigma);\n for (i = 0; i < b; i++) c[cpos+i] = x[i];\n }\n return 0;\n}\n\nfunction crypto_stream(c,cpos,d,n,k) {\n var s = new Uint8Array(32);\n crypto_core_hsalsa20(s,n,k,sigma);\n var sn = new Uint8Array(8);\n for (var i = 0; i < 8; i++) sn[i] = n[i+16];\n return crypto_stream_salsa20(c,cpos,d,sn,s);\n}\n\nfunction crypto_stream_xor(c,cpos,m,mpos,d,n,k) {\n var s = new Uint8Array(32);\n crypto_core_hsalsa20(s,n,k,sigma);\n var sn = new Uint8Array(8);\n for (var i = 0; i < 8; i++) sn[i] = n[i+16];\n return crypto_stream_salsa20_xor(c,cpos,m,mpos,d,sn,s);\n}\n\n/*\n* Port of Andrew Moon's Poly1305-donna-16. Public domain.\n* https://github.com/floodyberry/poly1305-donna\n*/\n\nvar poly1305 = function(key) {\n this.buffer = new Uint8Array(16);\n this.r = new Uint16Array(10);\n this.h = new Uint16Array(10);\n this.pad = new Uint16Array(8);\n this.leftover = 0;\n this.fin = 0;\n\n var t0, t1, t2, t3, t4, t5, t6, t7;\n\n t0 = key[ 0] & 0xff | (key[ 1] & 0xff) << 8; this.r[0] = ( t0 ) & 0x1fff;\n t1 = key[ 2] & 0xff | (key[ 3] & 0xff) << 8; this.r[1] = ((t0 >>> 13) | (t1 << 3)) & 0x1fff;\n t2 = key[ 4] & 0xff | (key[ 5] & 0xff) << 8; this.r[2] = ((t1 >>> 10) | (t2 << 6)) & 0x1f03;\n t3 = key[ 6] & 0xff | (key[ 7] & 0xff) << 8; this.r[3] = ((t2 >>> 7) | (t3 << 9)) & 0x1fff;\n t4 = key[ 8] & 0xff | (key[ 9] & 0xff) << 8; this.r[4] = ((t3 >>> 4) | (t4 << 12)) & 0x00ff;\n this.r[5] = ((t4 >>> 1)) & 0x1ffe;\n t5 = key[10] & 0xff | (key[11] & 0xff) << 8; this.r[6] = ((t4 >>> 14) | (t5 << 2)) & 0x1fff;\n t6 = key[12] & 0xff | (key[13] & 0xff) << 8; this.r[7] = ((t5 >>> 11) | (t6 << 5)) & 0x1f81;\n t7 = key[14] & 0xff | (key[15] & 0xff) << 8; this.r[8] = ((t6 >>> 8) | (t7 << 8)) & 0x1fff;\n this.r[9] = ((t7 >>> 5)) & 0x007f;\n\n this.pad[0] = key[16] & 0xff | (key[17] & 0xff) << 8;\n this.pad[1] = key[18] & 0xff | (key[19] & 0xff) << 8;\n this.pad[2] = key[20] & 0xff | (key[21] & 0xff) << 8;\n this.pad[3] = key[22] & 0xff | (key[23] & 0xff) << 8;\n this.pad[4] = key[24] & 0xff | (key[25] & 0xff) << 8;\n this.pad[5] = key[26] & 0xff | (key[27] & 0xff) << 8;\n this.pad[6] = key[28] & 0xff | (key[29] & 0xff) << 8;\n this.pad[7] = key[30] & 0xff | (key[31] & 0xff) << 8;\n};\n\npoly1305.prototype.blocks = function(m, mpos, bytes) {\n var hibit = this.fin ? 0 : (1 << 11);\n var t0, t1, t2, t3, t4, t5, t6, t7, c;\n var d0, d1, d2, d3, d4, d5, d6, d7, d8, d9;\n\n var h0 = this.h[0],\n h1 = this.h[1],\n h2 = this.h[2],\n h3 = this.h[3],\n h4 = this.h[4],\n h5 = this.h[5],\n h6 = this.h[6],\n h7 = this.h[7],\n h8 = this.h[8],\n h9 = this.h[9];\n\n var r0 = this.r[0],\n r1 = this.r[1],\n r2 = this.r[2],\n r3 = this.r[3],\n r4 = this.r[4],\n r5 = this.r[5],\n r6 = this.r[6],\n r7 = this.r[7],\n r8 = this.r[8],\n r9 = this.r[9];\n\n while (bytes >= 16) {\n t0 = m[mpos+ 0] & 0xff | (m[mpos+ 1] & 0xff) << 8; h0 += ( t0 ) & 0x1fff;\n t1 = m[mpos+ 2] & 0xff | (m[mpos+ 3] & 0xff) << 8; h1 += ((t0 >>> 13) | (t1 << 3)) & 0x1fff;\n t2 = m[mpos+ 4] & 0xff | (m[mpos+ 5] & 0xff) << 8; h2 += ((t1 >>> 10) | (t2 << 6)) & 0x1fff;\n t3 = m[mpos+ 6] & 0xff | (m[mpos+ 7] & 0xff) << 8; h3 += ((t2 >>> 7) | (t3 << 9)) & 0x1fff;\n t4 = m[mpos+ 8] & 0xff | (m[mpos+ 9] & 0xff) << 8; h4 += ((t3 >>> 4) | (t4 << 12)) & 0x1fff;\n h5 += ((t4 >>> 1)) & 0x1fff;\n t5 = m[mpos+10] & 0xff | (m[mpos+11] & 0xff) << 8; h6 += ((t4 >>> 14) | (t5 << 2)) & 0x1fff;\n t6 = m[mpos+12] & 0xff | (m[mpos+13] & 0xff) << 8; h7 += ((t5 >>> 11) | (t6 << 5)) & 0x1fff;\n t7 = m[mpos+14] & 0xff | (m[mpos+15] & 0xff) << 8; h8 += ((t6 >>> 8) | (t7 << 8)) & 0x1fff;\n h9 += ((t7 >>> 5)) | hibit;\n\n c = 0;\n\n d0 = c;\n d0 += h0 * r0;\n d0 += h1 * (5 * r9);\n d0 += h2 * (5 * r8);\n d0 += h3 * (5 * r7);\n d0 += h4 * (5 * r6);\n c = (d0 >>> 13); d0 &= 0x1fff;\n d0 += h5 * (5 * r5);\n d0 += h6 * (5 * r4);\n d0 += h7 * (5 * r3);\n d0 += h8 * (5 * r2);\n d0 += h9 * (5 * r1);\n c += (d0 >>> 13); d0 &= 0x1fff;\n\n d1 = c;\n d1 += h0 * r1;\n d1 += h1 * r0;\n d1 += h2 * (5 * r9);\n d1 += h3 * (5 * r8);\n d1 += h4 * (5 * r7);\n c = (d1 >>> 13); d1 &= 0x1fff;\n d1 += h5 * (5 * r6);\n d1 += h6 * (5 * r5);\n d1 += h7 * (5 * r4);\n d1 += h8 * (5 * r3);\n d1 += h9 * (5 * r2);\n c += (d1 >>> 13); d1 &= 0x1fff;\n\n d2 = c;\n d2 += h0 * r2;\n d2 += h1 * r1;\n d2 += h2 * r0;\n d2 += h3 * (5 * r9);\n d2 += h4 * (5 * r8);\n c = (d2 >>> 13); d2 &= 0x1fff;\n d2 += h5 * (5 * r7);\n d2 += h6 * (5 * r6);\n d2 += h7 * (5 * r5);\n d2 += h8 * (5 * r4);\n d2 += h9 * (5 * r3);\n c += (d2 >>> 13); d2 &= 0x1fff;\n\n d3 = c;\n d3 += h0 * r3;\n d3 += h1 * r2;\n d3 += h2 * r1;\n d3 += h3 * r0;\n d3 += h4 * (5 * r9);\n c = (d3 >>> 13); d3 &= 0x1fff;\n d3 += h5 * (5 * r8);\n d3 += h6 * (5 * r7);\n d3 += h7 * (5 * r6);\n d3 += h8 * (5 * r5);\n d3 += h9 * (5 * r4);\n c += (d3 >>> 13); d3 &= 0x1fff;\n\n d4 = c;\n d4 += h0 * r4;\n d4 += h1 * r3;\n d4 += h2 * r2;\n d4 += h3 * r1;\n d4 += h4 * r0;\n c = (d4 >>> 13); d4 &= 0x1fff;\n d4 += h5 * (5 * r9);\n d4 += h6 * (5 * r8);\n d4 += h7 * (5 * r7);\n d4 += h8 * (5 * r6);\n d4 += h9 * (5 * r5);\n c += (d4 >>> 13); d4 &= 0x1fff;\n\n d5 = c;\n d5 += h0 * r5;\n d5 += h1 * r4;\n d5 += h2 * r3;\n d5 += h3 * r2;\n d5 += h4 * r1;\n c = (d5 >>> 13); d5 &= 0x1fff;\n d5 += h5 * r0;\n d5 += h6 * (5 * r9);\n d5 += h7 * (5 * r8);\n d5 += h8 * (5 * r7);\n d5 += h9 * (5 * r6);\n c += (d5 >>> 13); d5 &= 0x1fff;\n\n d6 = c;\n d6 += h0 * r6;\n d6 += h1 * r5;\n d6 += h2 * r4;\n d6 += h3 * r3;\n d6 += h4 * r2;\n c = (d6 >>> 13); d6 &= 0x1fff;\n d6 += h5 * r1;\n d6 += h6 * r0;\n d6 += h7 * (5 * r9);\n d6 += h8 * (5 * r8);\n d6 += h9 * (5 * r7);\n c += (d6 >>> 13); d6 &= 0x1fff;\n\n d7 = c;\n d7 += h0 * r7;\n d7 += h1 * r6;\n d7 += h2 * r5;\n d7 += h3 * r4;\n d7 += h4 * r3;\n c = (d7 >>> 13); d7 &= 0x1fff;\n d7 += h5 * r2;\n d7 += h6 * r1;\n d7 += h7 * r0;\n d7 += h8 * (5 * r9);\n d7 += h9 * (5 * r8);\n c += (d7 >>> 13); d7 &= 0x1fff;\n\n d8 = c;\n d8 += h0 * r8;\n d8 += h1 * r7;\n d8 += h2 * r6;\n d8 += h3 * r5;\n d8 += h4 * r4;\n c = (d8 >>> 13); d8 &= 0x1fff;\n d8 += h5 * r3;\n d8 += h6 * r2;\n d8 += h7 * r1;\n d8 += h8 * r0;\n d8 += h9 * (5 * r9);\n c += (d8 >>> 13); d8 &= 0x1fff;\n\n d9 = c;\n d9 += h0 * r9;\n d9 += h1 * r8;\n d9 += h2 * r7;\n d9 += h3 * r6;\n d9 += h4 * r5;\n c = (d9 >>> 13); d9 &= 0x1fff;\n d9 += h5 * r4;\n d9 += h6 * r3;\n d9 += h7 * r2;\n d9 += h8 * r1;\n d9 += h9 * r0;\n c += (d9 >>> 13); d9 &= 0x1fff;\n\n c = (((c << 2) + c)) | 0;\n c = (c + d0) | 0;\n d0 = c & 0x1fff;\n c = (c >>> 13);\n d1 += c;\n\n h0 = d0;\n h1 = d1;\n h2 = d2;\n h3 = d3;\n h4 = d4;\n h5 = d5;\n h6 = d6;\n h7 = d7;\n h8 = d8;\n h9 = d9;\n\n mpos += 16;\n bytes -= 16;\n }\n this.h[0] = h0;\n this.h[1] = h1;\n this.h[2] = h2;\n this.h[3] = h3;\n this.h[4] = h4;\n this.h[5] = h5;\n this.h[6] = h6;\n this.h[7] = h7;\n this.h[8] = h8;\n this.h[9] = h9;\n};\n\npoly1305.prototype.finish = function(mac, macpos) {\n var g = new Uint16Array(10);\n var c, mask, f, i;\n\n if (this.leftover) {\n i = this.leftover;\n this.buffer[i++] = 1;\n for (; i < 16; i++) this.buffer[i] = 0;\n this.fin = 1;\n this.blocks(this.buffer, 0, 16);\n }\n\n c = this.h[1] >>> 13;\n this.h[1] &= 0x1fff;\n for (i = 2; i < 10; i++) {\n this.h[i] += c;\n c = this.h[i] >>> 13;\n this.h[i] &= 0x1fff;\n }\n this.h[0] += (c * 5);\n c = this.h[0] >>> 13;\n this.h[0] &= 0x1fff;\n this.h[1] += c;\n c = this.h[1] >>> 13;\n this.h[1] &= 0x1fff;\n this.h[2] += c;\n\n g[0] = this.h[0] + 5;\n c = g[0] >>> 13;\n g[0] &= 0x1fff;\n for (i = 1; i < 10; i++) {\n g[i] = this.h[i] + c;\n c = g[i] >>> 13;\n g[i] &= 0x1fff;\n }\n g[9] -= (1 << 13);\n\n mask = (c ^ 1) - 1;\n for (i = 0; i < 10; i++) g[i] &= mask;\n mask = ~mask;\n for (i = 0; i < 10; i++) this.h[i] = (this.h[i] & mask) | g[i];\n\n this.h[0] = ((this.h[0] ) | (this.h[1] << 13) ) & 0xffff;\n this.h[1] = ((this.h[1] >>> 3) | (this.h[2] << 10) ) & 0xffff;\n this.h[2] = ((this.h[2] >>> 6) | (this.h[3] << 7) ) & 0xffff;\n this.h[3] = ((this.h[3] >>> 9) | (this.h[4] << 4) ) & 0xffff;\n this.h[4] = ((this.h[4] >>> 12) | (this.h[5] << 1) | (this.h[6] << 14)) & 0xffff;\n this.h[5] = ((this.h[6] >>> 2) | (this.h[7] << 11) ) & 0xffff;\n this.h[6] = ((this.h[7] >>> 5) | (this.h[8] << 8) ) & 0xffff;\n this.h[7] = ((this.h[8] >>> 8) | (this.h[9] << 5) ) & 0xffff;\n\n f = this.h[0] + this.pad[0];\n this.h[0] = f & 0xffff;\n for (i = 1; i < 8; i++) {\n f = (((this.h[i] + this.pad[i]) | 0) + (f >>> 16)) | 0;\n this.h[i] = f & 0xffff;\n }\n\n mac[macpos+ 0] = (this.h[0] >>> 0) & 0xff;\n mac[macpos+ 1] = (this.h[0] >>> 8) & 0xff;\n mac[macpos+ 2] = (this.h[1] >>> 0) & 0xff;\n mac[macpos+ 3] = (this.h[1] >>> 8) & 0xff;\n mac[macpos+ 4] = (this.h[2] >>> 0) & 0xff;\n mac[macpos+ 5] = (this.h[2] >>> 8) & 0xff;\n mac[macpos+ 6] = (this.h[3] >>> 0) & 0xff;\n mac[macpos+ 7] = (this.h[3] >>> 8) & 0xff;\n mac[macpos+ 8] = (this.h[4] >>> 0) & 0xff;\n mac[macpos+ 9] = (this.h[4] >>> 8) & 0xff;\n mac[macpos+10] = (this.h[5] >>> 0) & 0xff;\n mac[macpos+11] = (this.h[5] >>> 8) & 0xff;\n mac[macpos+12] = (this.h[6] >>> 0) & 0xff;\n mac[macpos+13] = (this.h[6] >>> 8) & 0xff;\n mac[macpos+14] = (this.h[7] >>> 0) & 0xff;\n mac[macpos+15] = (this.h[7] >>> 8) & 0xff;\n};\n\npoly1305.prototype.update = function(m, mpos, bytes) {\n var i, want;\n\n if (this.leftover) {\n want = (16 - this.leftover);\n if (want > bytes)\n want = bytes;\n for (i = 0; i < want; i++)\n this.buffer[this.leftover + i] = m[mpos+i];\n bytes -= want;\n mpos += want;\n this.leftover += want;\n if (this.leftover < 16)\n return;\n this.blocks(this.buffer, 0, 16);\n this.leftover = 0;\n }\n\n if (bytes >= 16) {\n want = bytes - (bytes % 16);\n this.blocks(m, mpos, want);\n mpos += want;\n bytes -= want;\n }\n\n if (bytes) {\n for (i = 0; i < bytes; i++)\n this.buffer[this.leftover + i] = m[mpos+i];\n this.leftover += bytes;\n }\n};\n\nfunction crypto_onetimeauth(out, outpos, m, mpos, n, k) {\n var s = new poly1305(k);\n s.update(m, mpos, n);\n s.finish(out, outpos);\n return 0;\n}\n\nfunction crypto_onetimeauth_verify(h, hpos, m, mpos, n, k) {\n var x = new Uint8Array(16);\n crypto_onetimeauth(x,0,m,mpos,n,k);\n return crypto_verify_16(h,hpos,x,0);\n}\n\nfunction crypto_secretbox(c,m,d,n,k) {\n var i;\n if (d < 32) return -1;\n crypto_stream_xor(c,0,m,0,d,n,k);\n crypto_onetimeauth(c, 16, c, 32, d - 32, c);\n for (i = 0; i < 16; i++) c[i] = 0;\n return 0;\n}\n\nfunction crypto_secretbox_open(m,c,d,n,k) {\n var i;\n var x = new Uint8Array(32);\n if (d < 32) return -1;\n crypto_stream(x,0,32,n,k);\n if (crypto_onetimeauth_verify(c, 16,c, 32,d - 32,x) !== 0) return -1;\n crypto_stream_xor(m,0,c,0,d,n,k);\n for (i = 0; i < 32; i++) m[i] = 0;\n return 0;\n}\n\nfunction set25519(r, a) {\n var i;\n for (i = 0; i < 16; i++) r[i] = a[i]|0;\n}\n\nfunction car25519(o) {\n var i, v, c = 1;\n for (i = 0; i < 16; i++) {\n v = o[i] + c + 65535;\n c = Math.floor(v / 65536);\n o[i] = v - c * 65536;\n }\n o[0] += c-1 + 37 * (c-1);\n}\n\nfunction sel25519(p, q, b) {\n var t, c = ~(b-1);\n for (var i = 0; i < 16; i++) {\n t = c & (p[i] ^ q[i]);\n p[i] ^= t;\n q[i] ^= t;\n }\n}\n\nfunction pack25519(o, n) {\n var i, j, b;\n var m = gf(), t = gf();\n for (i = 0; i < 16; i++) t[i] = n[i];\n car25519(t);\n car25519(t);\n car25519(t);\n for (j = 0; j < 2; j++) {\n m[0] = t[0] - 0xffed;\n for (i = 1; i < 15; i++) {\n m[i] = t[i] - 0xffff - ((m[i-1]>>16) & 1);\n m[i-1] &= 0xffff;\n }\n m[15] = t[15] - 0x7fff - ((m[14]>>16) & 1);\n b = (m[15]>>16) & 1;\n m[14] &= 0xffff;\n sel25519(t, m, 1-b);\n }\n for (i = 0; i < 16; i++) {\n o[2*i] = t[i] & 0xff;\n o[2*i+1] = t[i]>>8;\n }\n}\n\nfunction neq25519(a, b) {\n var c = new Uint8Array(32), d = new Uint8Array(32);\n pack25519(c, a);\n pack25519(d, b);\n return crypto_verify_32(c, 0, d, 0);\n}\n\nfunction par25519(a) {\n var d = new Uint8Array(32);\n pack25519(d, a);\n return d[0] & 1;\n}\n\nfunction unpack25519(o, n) {\n var i;\n for (i = 0; i < 16; i++) o[i] = n[2*i] + (n[2*i+1] << 8);\n o[15] &= 0x7fff;\n}\n\nfunction A(o, a, b) {\n for (var i = 0; i < 16; i++) o[i] = a[i] + b[i];\n}\n\nfunction Z(o, a, b) {\n for (var i = 0; i < 16; i++) o[i] = a[i] - b[i];\n}\n\nfunction M(o, a, b) {\n var v, c,\n t0 = 0, t1 = 0, t2 = 0, t3 = 0, t4 = 0, t5 = 0, t6 = 0, t7 = 0,\n t8 = 0, t9 = 0, t10 = 0, t11 = 0, t12 = 0, t13 = 0, t14 = 0, t15 = 0,\n t16 = 0, t17 = 0, t18 = 0, t19 = 0, t20 = 0, t21 = 0, t22 = 0, t23 = 0,\n t24 = 0, t25 = 0, t26 = 0, t27 = 0, t28 = 0, t29 = 0, t30 = 0,\n b0 = b[0],\n b1 = b[1],\n b2 = b[2],\n b3 = b[3],\n b4 = b[4],\n b5 = b[5],\n b6 = b[6],\n b7 = b[7],\n b8 = b[8],\n b9 = b[9],\n b10 = b[10],\n b11 = b[11],\n b12 = b[12],\n b13 = b[13],\n b14 = b[14],\n b15 = b[15];\n\n v = a[0];\n t0 += v * b0;\n t1 += v * b1;\n t2 += v * b2;\n t3 += v * b3;\n t4 += v * b4;\n t5 += v * b5;\n t6 += v * b6;\n t7 += v * b7;\n t8 += v * b8;\n t9 += v * b9;\n t10 += v * b10;\n t11 += v * b11;\n t12 += v * b12;\n t13 += v * b13;\n t14 += v * b14;\n t15 += v * b15;\n v = a[1];\n t1 += v * b0;\n t2 += v * b1;\n t3 += v * b2;\n t4 += v * b3;\n t5 += v * b4;\n t6 += v * b5;\n t7 += v * b6;\n t8 += v * b7;\n t9 += v * b8;\n t10 += v * b9;\n t11 += v * b10;\n t12 += v * b11;\n t13 += v * b12;\n t14 += v * b13;\n t15 += v * b14;\n t16 += v * b15;\n v = a[2];\n t2 += v * b0;\n t3 += v * b1;\n t4 += v * b2;\n t5 += v * b3;\n t6 += v * b4;\n t7 += v * b5;\n t8 += v * b6;\n t9 += v * b7;\n t10 += v * b8;\n t11 += v * b9;\n t12 += v * b10;\n t13 += v * b11;\n t14 += v * b12;\n t15 += v * b13;\n t16 += v * b14;\n t17 += v * b15;\n v = a[3];\n t3 += v * b0;\n t4 += v * b1;\n t5 += v * b2;\n t6 += v * b3;\n t7 += v * b4;\n t8 += v * b5;\n t9 += v * b6;\n t10 += v * b7;\n t11 += v * b8;\n t12 += v * b9;\n t13 += v * b10;\n t14 += v * b11;\n t15 += v * b12;\n t16 += v * b13;\n t17 += v * b14;\n t18 += v * b15;\n v = a[4];\n t4 += v * b0;\n t5 += v * b1;\n t6 += v * b2;\n t7 += v * b3;\n t8 += v * b4;\n t9 += v * b5;\n t10 += v * b6;\n t11 += v * b7;\n t12 += v * b8;\n t13 += v * b9;\n t14 += v * b10;\n t15 += v * b11;\n t16 += v * b12;\n t17 += v * b13;\n t18 += v * b14;\n t19 += v * b15;\n v = a[5];\n t5 += v * b0;\n t6 += v * b1;\n t7 += v * b2;\n t8 += v * b3;\n t9 += v * b4;\n t10 += v * b5;\n t11 += v * b6;\n t12 += v * b7;\n t13 += v * b8;\n t14 += v * b9;\n t15 += v * b10;\n t16 += v * b11;\n t17 += v * b12;\n t18 += v * b13;\n t19 += v * b14;\n t20 += v * b15;\n v = a[6];\n t6 += v * b0;\n t7 += v * b1;\n t8 += v * b2;\n t9 += v * b3;\n t10 += v * b4;\n t11 += v * b5;\n t12 += v * b6;\n t13 += v * b7;\n t14 += v * b8;\n t15 += v * b9;\n t16 += v * b10;\n t17 += v * b11;\n t18 += v * b12;\n t19 += v * b13;\n t20 += v * b14;\n t21 += v * b15;\n v = a[7];\n t7 += v * b0;\n t8 += v * b1;\n t9 += v * b2;\n t10 += v * b3;\n t11 += v * b4;\n t12 += v * b5;\n t13 += v * b6;\n t14 += v * b7;\n t15 += v * b8;\n t16 += v * b9;\n t17 += v * b10;\n t18 += v * b11;\n t19 += v * b12;\n t20 += v * b13;\n t21 += v * b14;\n t22 += v * b15;\n v = a[8];\n t8 += v * b0;\n t9 += v * b1;\n t10 += v * b2;\n t11 += v * b3;\n t12 += v * b4;\n t13 += v * b5;\n t14 += v * b6;\n t15 += v * b7;\n t16 += v * b8;\n t17 += v * b9;\n t18 += v * b10;\n t19 += v * b11;\n t20 += v * b12;\n t21 += v * b13;\n t22 += v * b14;\n t23 += v * b15;\n v = a[9];\n t9 += v * b0;\n t10 += v * b1;\n t11 += v * b2;\n t12 += v * b3;\n t13 += v * b4;\n t14 += v * b5;\n t15 += v * b6;\n t16 += v * b7;\n t17 += v * b8;\n t18 += v * b9;\n t19 += v * b10;\n t20 += v * b11;\n t21 += v * b12;\n t22 += v * b13;\n t23 += v * b14;\n t24 += v * b15;\n v = a[10];\n t10 += v * b0;\n t11 += v * b1;\n t12 += v * b2;\n t13 += v * b3;\n t14 += v * b4;\n t15 += v * b5;\n t16 += v * b6;\n t17 += v * b7;\n t18 += v * b8;\n t19 += v * b9;\n t20 += v * b10;\n t21 += v * b11;\n t22 += v * b12;\n t23 += v * b13;\n t24 += v * b14;\n t25 += v * b15;\n v = a[11];\n t11 += v * b0;\n t12 += v * b1;\n t13 += v * b2;\n t14 += v * b3;\n t15 += v * b4;\n t16 += v * b5;\n t17 += v * b6;\n t18 += v * b7;\n t19 += v * b8;\n t20 += v * b9;\n t21 += v * b10;\n t22 += v * b11;\n t23 += v * b12;\n t24 += v * b13;\n t25 += v * b14;\n t26 += v * b15;\n v = a[12];\n t12 += v * b0;\n t13 += v * b1;\n t14 += v * b2;\n t15 += v * b3;\n t16 += v * b4;\n t17 += v * b5;\n t18 += v * b6;\n t19 += v * b7;\n t20 += v * b8;\n t21 += v * b9;\n t22 += v * b10;\n t23 += v * b11;\n t24 += v * b12;\n t25 += v * b13;\n t26 += v * b14;\n t27 += v * b15;\n v = a[13];\n t13 += v * b0;\n t14 += v * b1;\n t15 += v * b2;\n t16 += v * b3;\n t17 += v * b4;\n t18 += v * b5;\n t19 += v * b6;\n t20 += v * b7;\n t21 += v * b8;\n t22 += v * b9;\n t23 += v * b10;\n t24 += v * b11;\n t25 += v * b12;\n t26 += v * b13;\n t27 += v * b14;\n t28 += v * b15;\n v = a[14];\n t14 += v * b0;\n t15 += v * b1;\n t16 += v * b2;\n t17 += v * b3;\n t18 += v * b4;\n t19 += v * b5;\n t20 += v * b6;\n t21 += v * b7;\n t22 += v * b8;\n t23 += v * b9;\n t24 += v * b10;\n t25 += v * b11;\n t26 += v * b12;\n t27 += v * b13;\n t28 += v * b14;\n t29 += v * b15;\n v = a[15];\n t15 += v * b0;\n t16 += v * b1;\n t17 += v * b2;\n t18 += v * b3;\n t19 += v * b4;\n t20 += v * b5;\n t21 += v * b6;\n t22 += v * b7;\n t23 += v * b8;\n t24 += v * b9;\n t25 += v * b10;\n t26 += v * b11;\n t27 += v * b12;\n t28 += v * b13;\n t29 += v * b14;\n t30 += v * b15;\n\n t0 += 38 * t16;\n t1 += 38 * t17;\n t2 += 38 * t18;\n t3 += 38 * t19;\n t4 += 38 * t20;\n t5 += 38 * t21;\n t6 += 38 * t22;\n t7 += 38 * t23;\n t8 += 38 * t24;\n t9 += 38 * t25;\n t10 += 38 * t26;\n t11 += 38 * t27;\n t12 += 38 * t28;\n t13 += 38 * t29;\n t14 += 38 * t30;\n // t15 left as is\n\n // first car\n c = 1;\n v = t0 + c + 65535; c = Math.floor(v / 65536); t0 = v - c * 65536;\n v = t1 + c + 65535; c = Math.floor(v / 65536); t1 = v - c * 65536;\n v = t2 + c + 65535; c = Math.floor(v / 65536); t2 = v - c * 65536;\n v = t3 + c + 65535; c = Math.floor(v / 65536); t3 = v - c * 65536;\n v = t4 + c + 65535; c = Math.floor(v / 65536); t4 = v - c * 65536;\n v = t5 + c + 65535; c = Math.floor(v / 65536); t5 = v - c * 65536;\n v = t6 + c + 65535; c = Math.floor(v / 65536); t6 = v - c * 65536;\n v = t7 + c + 65535; c = Math.floor(v / 65536); t7 = v - c * 65536;\n v = t8 + c + 65535; c = Math.floor(v / 65536); t8 = v - c * 65536;\n v = t9 + c + 65535; c = Math.floor(v / 65536); t9 = v - c * 65536;\n v = t10 + c + 65535; c = Math.floor(v / 65536); t10 = v - c * 65536;\n v = t11 + c + 65535; c = Math.floor(v / 65536); t11 = v - c * 65536;\n v = t12 + c + 65535; c = Math.floor(v / 65536); t12 = v - c * 65536;\n v = t13 + c + 65535; c = Math.floor(v / 65536); t13 = v - c * 65536;\n v = t14 + c + 65535; c = Math.floor(v / 65536); t14 = v - c * 65536;\n v = t15 + c + 65535; c = Math.floor(v / 65536); t15 = v - c * 65536;\n t0 += c-1 + 37 * (c-1);\n\n // second car\n c = 1;\n v = t0 + c + 65535; c = Math.floor(v / 65536); t0 = v - c * 65536;\n v = t1 + c + 65535; c = Math.floor(v / 65536); t1 = v - c * 65536;\n v = t2 + c + 65535; c = Math.floor(v / 65536); t2 = v - c * 65536;\n v = t3 + c + 65535; c = Math.floor(v / 65536); t3 = v - c * 65536;\n v = t4 + c + 65535; c = Math.floor(v / 65536); t4 = v - c * 65536;\n v = t5 + c + 65535; c = Math.floor(v / 65536); t5 = v - c * 65536;\n v = t6 + c + 65535; c = Math.floor(v / 65536); t6 = v - c * 65536;\n v = t7 + c + 65535; c = Math.floor(v / 65536); t7 = v - c * 65536;\n v = t8 + c + 65535; c = Math.floor(v / 65536); t8 = v - c * 65536;\n v = t9 + c + 65535; c = Math.floor(v / 65536); t9 = v - c * 65536;\n v = t10 + c + 65535; c = Math.floor(v / 65536); t10 = v - c * 65536;\n v = t11 + c + 65535; c = Math.floor(v / 65536); t11 = v - c * 65536;\n v = t12 + c + 65535; c = Math.floor(v / 65536); t12 = v - c * 65536;\n v = t13 + c + 65535; c = Math.floor(v / 65536); t13 = v - c * 65536;\n v = t14 + c + 65535; c = Math.floor(v / 65536); t14 = v - c * 65536;\n v = t15 + c + 65535; c = Math.floor(v / 65536); t15 = v - c * 65536;\n t0 += c-1 + 37 * (c-1);\n\n o[ 0] = t0;\n o[ 1] = t1;\n o[ 2] = t2;\n o[ 3] = t3;\n o[ 4] = t4;\n o[ 5] = t5;\n o[ 6] = t6;\n o[ 7] = t7;\n o[ 8] = t8;\n o[ 9] = t9;\n o[10] = t10;\n o[11] = t11;\n o[12] = t12;\n o[13] = t13;\n o[14] = t14;\n o[15] = t15;\n}\n\nfunction S(o, a) {\n M(o, a, a);\n}\n\nfunction inv25519(o, i) {\n var c = gf();\n var a;\n for (a = 0; a < 16; a++) c[a] = i[a];\n for (a = 253; a >= 0; a--) {\n S(c, c);\n if(a !== 2 && a !== 4) M(c, c, i);\n }\n for (a = 0; a < 16; a++) o[a] = c[a];\n}\n\nfunction pow2523(o, i) {\n var c = gf();\n var a;\n for (a = 0; a < 16; a++) c[a] = i[a];\n for (a = 250; a >= 0; a--) {\n S(c, c);\n if(a !== 1) M(c, c, i);\n }\n for (a = 0; a < 16; a++) o[a] = c[a];\n}\n\nfunction crypto_scalarmult(q, n, p) {\n var z = new Uint8Array(32);\n var x = new Float64Array(80), r, i;\n var a = gf(), b = gf(), c = gf(),\n d = gf(), e = gf(), f = gf();\n for (i = 0; i < 31; i++) z[i] = n[i];\n z[31]=(n[31]&127)|64;\n z[0]&=248;\n unpack25519(x,p);\n for (i = 0; i < 16; i++) {\n b[i]=x[i];\n d[i]=a[i]=c[i]=0;\n }\n a[0]=d[0]=1;\n for (i=254; i>=0; --i) {\n r=(z[i>>>3]>>>(i&7))&1;\n sel25519(a,b,r);\n sel25519(c,d,r);\n A(e,a,c);\n Z(a,a,c);\n A(c,b,d);\n Z(b,b,d);\n S(d,e);\n S(f,a);\n M(a,c,a);\n M(c,b,e);\n A(e,a,c);\n Z(a,a,c);\n S(b,a);\n Z(c,d,f);\n M(a,c,_121665);\n A(a,a,d);\n M(c,c,a);\n M(a,d,f);\n M(d,b,x);\n S(b,e);\n sel25519(a,b,r);\n sel25519(c,d,r);\n }\n for (i = 0; i < 16; i++) {\n x[i+16]=a[i];\n x[i+32]=c[i];\n x[i+48]=b[i];\n x[i+64]=d[i];\n }\n var x32 = x.subarray(32);\n var x16 = x.subarray(16);\n inv25519(x32,x32);\n M(x16,x16,x32);\n pack25519(q,x16);\n return 0;\n}\n\nfunction crypto_scalarmult_base(q, n) {\n return crypto_scalarmult(q, n, _9);\n}\n\nfunction crypto_box_keypair(y, x) {\n randombytes(x, 32);\n return crypto_scalarmult_base(y, x);\n}\n\nfunction crypto_box_beforenm(k, y, x) {\n var s = new Uint8Array(32);\n crypto_scalarmult(s, x, y);\n return crypto_core_hsalsa20(k, _0, s, sigma);\n}\n\nvar crypto_box_afternm = crypto_secretbox;\nvar crypto_box_open_afternm = crypto_secretbox_open;\n\nfunction crypto_box(c, m, d, n, y, x) {\n var k = new Uint8Array(32);\n crypto_box_beforenm(k, y, x);\n return crypto_box_afternm(c, m, d, n, k);\n}\n\nfunction crypto_box_open(m, c, d, n, y, x) {\n var k = new Uint8Array(32);\n crypto_box_beforenm(k, y, x);\n return crypto_box_open_afternm(m, c, d, n, k);\n}\n\nvar K = [\n 0x428a2f98, 0xd728ae22, 0x71374491, 0x23ef65cd,\n 0xb5c0fbcf, 0xec4d3b2f, 0xe9b5dba5, 0x8189dbbc,\n 0x3956c25b, 0xf348b538, 0x59f111f1, 0xb605d019,\n 0x923f82a4, 0xaf194f9b, 0xab1c5ed5, 0xda6d8118,\n 0xd807aa98, 0xa3030242, 0x12835b01, 0x45706fbe,\n 0x243185be, 0x4ee4b28c, 0x550c7dc3, 0xd5ffb4e2,\n 0x72be5d74, 0xf27b896f, 0x80deb1fe, 0x3b1696b1,\n 0x9bdc06a7, 0x25c71235, 0xc19bf174, 0xcf692694,\n 0xe49b69c1, 0x9ef14ad2, 0xefbe4786, 0x384f25e3,\n 0x0fc19dc6, 0x8b8cd5b5, 0x240ca1cc, 0x77ac9c65,\n 0x2de92c6f, 0x592b0275, 0x4a7484aa, 0x6ea6e483,\n 0x5cb0a9dc, 0xbd41fbd4, 0x76f988da, 0x831153b5,\n 0x983e5152, 0xee66dfab, 0xa831c66d, 0x2db43210,\n 0xb00327c8, 0x98fb213f, 0xbf597fc7, 0xbeef0ee4,\n 0xc6e00bf3, 0x3da88fc2, 0xd5a79147, 0x930aa725,\n 0x06ca6351, 0xe003826f, 0x14292967, 0x0a0e6e70,\n 0x27b70a85, 0x46d22ffc, 0x2e1b2138, 0x5c26c926,\n 0x4d2c6dfc, 0x5ac42aed, 0x53380d13, 0x9d95b3df,\n 0x650a7354, 0x8baf63de, 0x766a0abb, 0x3c77b2a8,\n 0x81c2c92e, 0x47edaee6, 0x92722c85, 0x1482353b,\n 0xa2bfe8a1, 0x4cf10364, 0xa81a664b, 0xbc423001,\n 0xc24b8b70, 0xd0f89791, 0xc76c51a3, 0x0654be30,\n 0xd192e819, 0xd6ef5218, 0xd6990624, 0x5565a910,\n 0xf40e3585, 0x5771202a, 0x106aa070, 0x32bbd1b8,\n 0x19a4c116, 0xb8d2d0c8, 0x1e376c08, 0x5141ab53,\n 0x2748774c, 0xdf8eeb99, 0x34b0bcb5, 0xe19b48a8,\n 0x391c0cb3, 0xc5c95a63, 0x4ed8aa4a, 0xe3418acb,\n 0x5b9cca4f, 0x7763e373, 0x682e6ff3, 0xd6b2b8a3,\n 0x748f82ee, 0x5defb2fc, 0x78a5636f, 0x43172f60,\n 0x84c87814, 0xa1f0ab72, 0x8cc70208, 0x1a6439ec,\n 0x90befffa, 0x23631e28, 0xa4506ceb, 0xde82bde9,\n 0xbef9a3f7, 0xb2c67915, 0xc67178f2, 0xe372532b,\n 0xca273ece, 0xea26619c, 0xd186b8c7, 0x21c0c207,\n 0xeada7dd6, 0xcde0eb1e, 0xf57d4f7f, 0xee6ed178,\n 0x06f067aa, 0x72176fba, 0x0a637dc5, 0xa2c898a6,\n 0x113f9804, 0xbef90dae, 0x1b710b35, 0x131c471b,\n 0x28db77f5, 0x23047d84, 0x32caab7b, 0x40c72493,\n 0x3c9ebe0a, 0x15c9bebc, 0x431d67c4, 0x9c100d4c,\n 0x4cc5d4be, 0xcb3e42b6, 0x597f299c, 0xfc657e2a,\n 0x5fcb6fab, 0x3ad6faec, 0x6c44198c, 0x4a475817\n];\n\nfunction crypto_hashblocks_hl(hh, hl, m, n) {\n var wh = new Int32Array(16), wl = new Int32Array(16),\n bh0, bh1, bh2, bh3, bh4, bh5, bh6, bh7,\n bl0, bl1, bl2, bl3, bl4, bl5, bl6, bl7,\n th, tl, i, j, h, l, a, b, c, d;\n\n var ah0 = hh[0],\n ah1 = hh[1],\n ah2 = hh[2],\n ah3 = hh[3],\n ah4 = hh[4],\n ah5 = hh[5],\n ah6 = hh[6],\n ah7 = hh[7],\n\n al0 = hl[0],\n al1 = hl[1],\n al2 = hl[2],\n al3 = hl[3],\n al4 = hl[4],\n al5 = hl[5],\n al6 = hl[6],\n al7 = hl[7];\n\n var pos = 0;\n while (n >= 128) {\n for (i = 0; i < 16; i++) {\n j = 8 * i + pos;\n wh[i] = (m[j+0] << 24) | (m[j+1] << 16) | (m[j+2] << 8) | m[j+3];\n wl[i] = (m[j+4] << 24) | (m[j+5] << 16) | (m[j+6] << 8) | m[j+7];\n }\n for (i = 0; i < 80; i++) {\n bh0 = ah0;\n bh1 = ah1;\n bh2 = ah2;\n bh3 = ah3;\n bh4 = ah4;\n bh5 = ah5;\n bh6 = ah6;\n bh7 = ah7;\n\n bl0 = al0;\n bl1 = al1;\n bl2 = al2;\n bl3 = al3;\n bl4 = al4;\n bl5 = al5;\n bl6 = al6;\n bl7 = al7;\n\n // add\n h = ah7;\n l = al7;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n // Sigma1\n h = ((ah4 >>> 14) | (al4 << (32-14))) ^ ((ah4 >>> 18) | (al4 << (32-18))) ^ ((al4 >>> (41-32)) | (ah4 << (32-(41-32))));\n l = ((al4 >>> 14) | (ah4 << (32-14))) ^ ((al4 >>> 18) | (ah4 << (32-18))) ^ ((ah4 >>> (41-32)) | (al4 << (32-(41-32))));\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // Ch\n h = (ah4 & ah5) ^ (~ah4 & ah6);\n l = (al4 & al5) ^ (~al4 & al6);\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // K\n h = K[i*2];\n l = K[i*2+1];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // w\n h = wh[i%16];\n l = wl[i%16];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n th = c & 0xffff | d << 16;\n tl = a & 0xffff | b << 16;\n\n // add\n h = th;\n l = tl;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n // Sigma0\n h = ((ah0 >>> 28) | (al0 << (32-28))) ^ ((al0 >>> (34-32)) | (ah0 << (32-(34-32)))) ^ ((al0 >>> (39-32)) | (ah0 << (32-(39-32))));\n l = ((al0 >>> 28) | (ah0 << (32-28))) ^ ((ah0 >>> (34-32)) | (al0 << (32-(34-32)))) ^ ((ah0 >>> (39-32)) | (al0 << (32-(39-32))));\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // Maj\n h = (ah0 & ah1) ^ (ah0 & ah2) ^ (ah1 & ah2);\n l = (al0 & al1) ^ (al0 & al2) ^ (al1 & al2);\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n bh7 = (c & 0xffff) | (d << 16);\n bl7 = (a & 0xffff) | (b << 16);\n\n // add\n h = bh3;\n l = bl3;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = th;\n l = tl;\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n bh3 = (c & 0xffff) | (d << 16);\n bl3 = (a & 0xffff) | (b << 16);\n\n ah1 = bh0;\n ah2 = bh1;\n ah3 = bh2;\n ah4 = bh3;\n ah5 = bh4;\n ah6 = bh5;\n ah7 = bh6;\n ah0 = bh7;\n\n al1 = bl0;\n al2 = bl1;\n al3 = bl2;\n al4 = bl3;\n al5 = bl4;\n al6 = bl5;\n al7 = bl6;\n al0 = bl7;\n\n if (i%16 === 15) {\n for (j = 0; j < 16; j++) {\n // add\n h = wh[j];\n l = wl[j];\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = wh[(j+9)%16];\n l = wl[(j+9)%16];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // sigma0\n th = wh[(j+1)%16];\n tl = wl[(j+1)%16];\n h = ((th >>> 1) | (tl << (32-1))) ^ ((th >>> 8) | (tl << (32-8))) ^ (th >>> 7);\n l = ((tl >>> 1) | (th << (32-1))) ^ ((tl >>> 8) | (th << (32-8))) ^ ((tl >>> 7) | (th << (32-7)));\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // sigma1\n th = wh[(j+14)%16];\n tl = wl[(j+14)%16];\n h = ((th >>> 19) | (tl << (32-19))) ^ ((tl >>> (61-32)) | (th << (32-(61-32)))) ^ (th >>> 6);\n l = ((tl >>> 19) | (th << (32-19))) ^ ((th >>> (61-32)) | (tl << (32-(61-32)))) ^ ((tl >>> 6) | (th << (32-6)));\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n wh[j] = (c & 0xffff) | (d << 16);\n wl[j] = (a & 0xffff) | (b << 16);\n }\n }\n }\n\n // add\n h = ah0;\n l = al0;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[0];\n l = hl[0];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[0] = ah0 = (c & 0xffff) | (d << 16);\n hl[0] = al0 = (a & 0xffff) | (b << 16);\n\n h = ah1;\n l = al1;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[1];\n l = hl[1];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[1] = ah1 = (c & 0xffff) | (d << 16);\n hl[1] = al1 = (a & 0xffff) | (b << 16);\n\n h = ah2;\n l = al2;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[2];\n l = hl[2];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[2] = ah2 = (c & 0xffff) | (d << 16);\n hl[2] = al2 = (a & 0xffff) | (b << 16);\n\n h = ah3;\n l = al3;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[3];\n l = hl[3];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[3] = ah3 = (c & 0xffff) | (d << 16);\n hl[3] = al3 = (a & 0xffff) | (b << 16);\n\n h = ah4;\n l = al4;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[4];\n l = hl[4];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[4] = ah4 = (c & 0xffff) | (d << 16);\n hl[4] = al4 = (a & 0xffff) | (b << 16);\n\n h = ah5;\n l = al5;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[5];\n l = hl[5];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[5] = ah5 = (c & 0xffff) | (d << 16);\n hl[5] = al5 = (a & 0xffff) | (b << 16);\n\n h = ah6;\n l = al6;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[6];\n l = hl[6];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[6] = ah6 = (c & 0xffff) | (d << 16);\n hl[6] = al6 = (a & 0xffff) | (b << 16);\n\n h = ah7;\n l = al7;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[7];\n l = hl[7];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[7] = ah7 = (c & 0xffff) | (d << 16);\n hl[7] = al7 = (a & 0xffff) | (b << 16);\n\n pos += 128;\n n -= 128;\n }\n\n return n;\n}\n\nfunction crypto_hash(out, m, n) {\n var hh = new Int32Array(8),\n hl = new Int32Array(8),\n x = new Uint8Array(256),\n i, b = n;\n\n hh[0] = 0x6a09e667;\n hh[1] = 0xbb67ae85;\n hh[2] = 0x3c6ef372;\n hh[3] = 0xa54ff53a;\n hh[4] = 0x510e527f;\n hh[5] = 0x9b05688c;\n hh[6] = 0x1f83d9ab;\n hh[7] = 0x5be0cd19;\n\n hl[0] = 0xf3bcc908;\n hl[1] = 0x84caa73b;\n hl[2] = 0xfe94f82b;\n hl[3] = 0x5f1d36f1;\n hl[4] = 0xade682d1;\n hl[5] = 0x2b3e6c1f;\n hl[6] = 0xfb41bd6b;\n hl[7] = 0x137e2179;\n\n crypto_hashblocks_hl(hh, hl, m, n);\n n %= 128;\n\n for (i = 0; i < n; i++) x[i] = m[b-n+i];\n x[n] = 128;\n\n n = 256-128*(n<112?1:0);\n x[n-9] = 0;\n ts64(x, n-8, (b / 0x20000000) | 0, b << 3);\n crypto_hashblocks_hl(hh, hl, x, n);\n\n for (i = 0; i < 8; i++) ts64(out, 8*i, hh[i], hl[i]);\n\n return 0;\n}\n\nfunction add(p, q) {\n var a = gf(), b = gf(), c = gf(),\n d = gf(), e = gf(), f = gf(),\n g = gf(), h = gf(), t = gf();\n\n Z(a, p[1], p[0]);\n Z(t, q[1], q[0]);\n M(a, a, t);\n A(b, p[0], p[1]);\n A(t, q[0], q[1]);\n M(b, b, t);\n M(c, p[3], q[3]);\n M(c, c, D2);\n M(d, p[2], q[2]);\n A(d, d, d);\n Z(e, b, a);\n Z(f, d, c);\n A(g, d, c);\n A(h, b, a);\n\n M(p[0], e, f);\n M(p[1], h, g);\n M(p[2], g, f);\n M(p[3], e, h);\n}\n\nfunction cswap(p, q, b) {\n var i;\n for (i = 0; i < 4; i++) {\n sel25519(p[i], q[i], b);\n }\n}\n\nfunction pack(r, p) {\n var tx = gf(), ty = gf(), zi = gf();\n inv25519(zi, p[2]);\n M(tx, p[0], zi);\n M(ty, p[1], zi);\n pack25519(r, ty);\n r[31] ^= par25519(tx) << 7;\n}\n\nfunction scalarmult(p, q, s) {\n var b, i;\n set25519(p[0], gf0);\n set25519(p[1], gf1);\n set25519(p[2], gf1);\n set25519(p[3], gf0);\n for (i = 255; i >= 0; --i) {\n b = (s[(i/8)|0] >> (i&7)) & 1;\n cswap(p, q, b);\n add(q, p);\n add(p, p);\n cswap(p, q, b);\n }\n}\n\nfunction scalarbase(p, s) {\n var q = [gf(), gf(), gf(), gf()];\n set25519(q[0], X);\n set25519(q[1], Y);\n set25519(q[2], gf1);\n M(q[3], X, Y);\n scalarmult(p, q, s);\n}\n\nfunction crypto_sign_keypair(pk, sk, seeded) {\n var d = new Uint8Array(64);\n var p = [gf(), gf(), gf(), gf()];\n var i;\n\n if (!seeded) randombytes(sk, 32);\n crypto_hash(d, sk, 32);\n d[0] &= 248;\n d[31] &= 127;\n d[31] |= 64;\n\n scalarbase(p, d);\n pack(pk, p);\n\n for (i = 0; i < 32; i++) sk[i+32] = pk[i];\n return 0;\n}\n\nvar L = new Float64Array([0xed, 0xd3, 0xf5, 0x5c, 0x1a, 0x63, 0x12, 0x58, 0xd6, 0x9c, 0xf7, 0xa2, 0xde, 0xf9, 0xde, 0x14, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x10]);\n\nfunction modL(r, x) {\n var carry, i, j, k;\n for (i = 63; i >= 32; --i) {\n carry = 0;\n for (j = i - 32, k = i - 12; j < k; ++j) {\n x[j] += carry - 16 * x[i] * L[j - (i - 32)];\n carry = Math.floor((x[j] + 128) / 256);\n x[j] -= carry * 256;\n }\n x[j] += carry;\n x[i] = 0;\n }\n carry = 0;\n for (j = 0; j < 32; j++) {\n x[j] += carry - (x[31] >> 4) * L[j];\n carry = x[j] >> 8;\n x[j] &= 255;\n }\n for (j = 0; j < 32; j++) x[j] -= carry * L[j];\n for (i = 0; i < 32; i++) {\n x[i+1] += x[i] >> 8;\n r[i] = x[i] & 255;\n }\n}\n\nfunction reduce(r) {\n var x = new Float64Array(64), i;\n for (i = 0; i < 64; i++) x[i] = r[i];\n for (i = 0; i < 64; i++) r[i] = 0;\n modL(r, x);\n}\n\n// Note: difference from C - smlen returned, not passed as argument.\nfunction crypto_sign(sm, m, n, sk) {\n var d = new Uint8Array(64), h = new Uint8Array(64), r = new Uint8Array(64);\n var i, j, x = new Float64Array(64);\n var p = [gf(), gf(), gf(), gf()];\n\n crypto_hash(d, sk, 32);\n d[0] &= 248;\n d[31] &= 127;\n d[31] |= 64;\n\n var smlen = n + 64;\n for (i = 0; i < n; i++) sm[64 + i] = m[i];\n for (i = 0; i < 32; i++) sm[32 + i] = d[32 + i];\n\n crypto_hash(r, sm.subarray(32), n+32);\n reduce(r);\n scalarbase(p, r);\n pack(sm, p);\n\n for (i = 32; i < 64; i++) sm[i] = sk[i];\n crypto_hash(h, sm, n + 64);\n reduce(h);\n\n for (i = 0; i < 64; i++) x[i] = 0;\n for (i = 0; i < 32; i++) x[i] = r[i];\n for (i = 0; i < 32; i++) {\n for (j = 0; j < 32; j++) {\n x[i+j] += h[i] * d[j];\n }\n }\n\n modL(sm.subarray(32), x);\n return smlen;\n}\n\nfunction unpackneg(r, p) {\n var t = gf(), chk = gf(), num = gf(),\n den = gf(), den2 = gf(), den4 = gf(),\n den6 = gf();\n\n set25519(r[2], gf1);\n unpack25519(r[1], p);\n S(num, r[1]);\n M(den, num, D);\n Z(num, num, r[2]);\n A(den, r[2], den);\n\n S(den2, den);\n S(den4, den2);\n M(den6, den4, den2);\n M(t, den6, num);\n M(t, t, den);\n\n pow2523(t, t);\n M(t, t, num);\n M(t, t, den);\n M(t, t, den);\n M(r[0], t, den);\n\n S(chk, r[0]);\n M(chk, chk, den);\n if (neq25519(chk, num)) M(r[0], r[0], I);\n\n S(chk, r[0]);\n M(chk, chk, den);\n if (neq25519(chk, num)) return -1;\n\n if (par25519(r[0]) === (p[31]>>7)) Z(r[0], gf0, r[0]);\n\n M(r[3], r[0], r[1]);\n return 0;\n}\n\nfunction crypto_sign_open(m, sm, n, pk) {\n var i;\n var t = new Uint8Array(32), h = new Uint8Array(64);\n var p = [gf(), gf(), gf(), gf()],\n q = [gf(), gf(), gf(), gf()];\n\n if (n < 64) return -1;\n\n if (unpackneg(q, pk)) return -1;\n\n for (i = 0; i < n; i++) m[i] = sm[i];\n for (i = 0; i < 32; i++) m[i+32] = pk[i];\n crypto_hash(h, m, n);\n reduce(h);\n scalarmult(p, q, h);\n\n scalarbase(q, sm.subarray(32));\n add(p, q);\n pack(t, p);\n\n n -= 64;\n if (crypto_verify_32(sm, 0, t, 0)) {\n for (i = 0; i < n; i++) m[i] = 0;\n return -1;\n }\n\n for (i = 0; i < n; i++) m[i] = sm[i + 64];\n return n;\n}\n\nvar crypto_secretbox_KEYBYTES = 32,\n crypto_secretbox_NONCEBYTES = 24,\n crypto_secretbox_ZEROBYTES = 32,\n crypto_secretbox_BOXZEROBYTES = 16,\n crypto_scalarmult_BYTES = 32,\n crypto_scalarmult_SCALARBYTES = 32,\n crypto_box_PUBLICKEYBYTES = 32,\n crypto_box_SECRETKEYBYTES = 32,\n crypto_box_BEFORENMBYTES = 32,\n crypto_box_NONCEBYTES = crypto_secretbox_NONCEBYTES,\n crypto_box_ZEROBYTES = crypto_secretbox_ZEROBYTES,\n crypto_box_BOXZEROBYTES = crypto_secretbox_BOXZEROBYTES,\n crypto_sign_BYTES = 64,\n crypto_sign_PUBLICKEYBYTES = 32,\n crypto_sign_SECRETKEYBYTES = 64,\n crypto_sign_SEEDBYTES = 32,\n crypto_hash_BYTES = 64;\n\nnacl.lowlevel = {\n crypto_core_hsalsa20: crypto_core_hsalsa20,\n crypto_stream_xor: crypto_stream_xor,\n crypto_stream: crypto_stream,\n crypto_stream_salsa20_xor: crypto_stream_salsa20_xor,\n crypto_stream_salsa20: crypto_stream_salsa20,\n crypto_onetimeauth: crypto_onetimeauth,\n crypto_onetimeauth_verify: crypto_onetimeauth_verify,\n crypto_verify_16: crypto_verify_16,\n crypto_verify_32: crypto_verify_32,\n crypto_secretbox: crypto_secretbox,\n crypto_secretbox_open: crypto_secretbox_open,\n crypto_scalarmult: crypto_scalarmult,\n crypto_scalarmult_base: crypto_scalarmult_base,\n crypto_box_beforenm: crypto_box_beforenm,\n crypto_box_afternm: crypto_box_afternm,\n crypto_box: crypto_box,\n crypto_box_open: crypto_box_open,\n crypto_box_keypair: crypto_box_keypair,\n crypto_hash: crypto_hash,\n crypto_sign: crypto_sign,\n crypto_sign_keypair: crypto_sign_keypair,\n crypto_sign_open: crypto_sign_open,\n\n crypto_secretbox_KEYBYTES: crypto_secretbox_KEYBYTES,\n crypto_secretbox_NONCEBYTES: crypto_secretbox_NONCEBYTES,\n crypto_secretbox_ZEROBYTES: crypto_secretbox_ZEROBYTES,\n crypto_secretbox_BOXZEROBYTES: crypto_secretbox_BOXZEROBYTES,\n crypto_scalarmult_BYTES: crypto_scalarmult_BYTES,\n crypto_scalarmult_SCALARBYTES: crypto_scalarmult_SCALARBYTES,\n crypto_box_PUBLICKEYBYTES: crypto_box_PUBLICKEYBYTES,\n crypto_box_SECRETKEYBYTES: crypto_box_SECRETKEYBYTES,\n crypto_box_BEFORENMBYTES: crypto_box_BEFORENMBYTES,\n crypto_box_NONCEBYTES: crypto_box_NONCEBYTES,\n crypto_box_ZEROBYTES: crypto_box_ZEROBYTES,\n crypto_box_BOXZEROBYTES: crypto_box_BOXZEROBYTES,\n crypto_sign_BYTES: crypto_sign_BYTES,\n crypto_sign_PUBLICKEYBYTES: crypto_sign_PUBLICKEYBYTES,\n crypto_sign_SECRETKEYBYTES: crypto_sign_SECRETKEYBYTES,\n crypto_sign_SEEDBYTES: crypto_sign_SEEDBYTES,\n crypto_hash_BYTES: crypto_hash_BYTES,\n\n gf: gf,\n D: D,\n L: L,\n pack25519: pack25519,\n unpack25519: unpack25519,\n M: M,\n A: A,\n S: S,\n Z: Z,\n pow2523: pow2523,\n add: add,\n set25519: set25519,\n modL: modL,\n scalarmult: scalarmult,\n scalarbase: scalarbase,\n};\n\n/* High-level API */\n\nfunction checkLengths(k, n) {\n if (k.length !== crypto_secretbox_KEYBYTES) throw new Error('bad key size');\n if (n.length !== crypto_secretbox_NONCEBYTES) throw new Error('bad nonce size');\n}\n\nfunction checkBoxLengths(pk, sk) {\n if (pk.length !== crypto_box_PUBLICKEYBYTES) throw new Error('bad public key size');\n if (sk.length !== crypto_box_SECRETKEYBYTES) throw new Error('bad secret key size');\n}\n\nfunction checkArrayTypes() {\n for (var i = 0; i < arguments.length; i++) {\n if (!(arguments[i] instanceof Uint8Array))\n throw new TypeError('unexpected type, use Uint8Array');\n }\n}\n\nfunction cleanup(arr) {\n for (var i = 0; i < arr.length; i++) arr[i] = 0;\n}\n\nnacl.randomBytes = function(n) {\n var b = new Uint8Array(n);\n randombytes(b, n);\n return b;\n};\n\nnacl.secretbox = function(msg, nonce, key) {\n checkArrayTypes(msg, nonce, key);\n checkLengths(key, nonce);\n var m = new Uint8Array(crypto_secretbox_ZEROBYTES + msg.length);\n var c = new Uint8Array(m.length);\n for (var i = 0; i < msg.length; i++) m[i+crypto_secretbox_ZEROBYTES] = msg[i];\n crypto_secretbox(c, m, m.length, nonce, key);\n return c.subarray(crypto_secretbox_BOXZEROBYTES);\n};\n\nnacl.secretbox.open = function(box, nonce, key) {\n checkArrayTypes(box, nonce, key);\n checkLengths(key, nonce);\n var c = new Uint8Array(crypto_secretbox_BOXZEROBYTES + box.length);\n var m = new Uint8Array(c.length);\n for (var i = 0; i < box.length; i++) c[i+crypto_secretbox_BOXZEROBYTES] = box[i];\n if (c.length < 32) return null;\n if (crypto_secretbox_open(m, c, c.length, nonce, key) !== 0) return null;\n return m.subarray(crypto_secretbox_ZEROBYTES);\n};\n\nnacl.secretbox.keyLength = crypto_secretbox_KEYBYTES;\nnacl.secretbox.nonceLength = crypto_secretbox_NONCEBYTES;\nnacl.secretbox.overheadLength = crypto_secretbox_BOXZEROBYTES;\n\nnacl.scalarMult = function(n, p) {\n checkArrayTypes(n, p);\n if (n.length !== crypto_scalarmult_SCALARBYTES) throw new Error('bad n size');\n if (p.length !== crypto_scalarmult_BYTES) throw new Error('bad p size');\n var q = new Uint8Array(crypto_scalarmult_BYTES);\n crypto_scalarmult(q, n, p);\n return q;\n};\n\nnacl.scalarMult.base = function(n) {\n checkArrayTypes(n);\n if (n.length !== crypto_scalarmult_SCALARBYTES) throw new Error('bad n size');\n var q = new Uint8Array(crypto_scalarmult_BYTES);\n crypto_scalarmult_base(q, n);\n return q;\n};\n\nnacl.scalarMult.scalarLength = crypto_scalarmult_SCALARBYTES;\nnacl.scalarMult.groupElementLength = crypto_scalarmult_BYTES;\n\nnacl.box = function(msg, nonce, publicKey, secretKey) {\n var k = nacl.box.before(publicKey, secretKey);\n return nacl.secretbox(msg, nonce, k);\n};\n\nnacl.box.before = function(publicKey, secretKey) {\n checkArrayTypes(publicKey, secretKey);\n checkBoxLengths(publicKey, secretKey);\n var k = new Uint8Array(crypto_box_BEFORENMBYTES);\n crypto_box_beforenm(k, publicKey, secretKey);\n return k;\n};\n\nnacl.box.after = nacl.secretbox;\n\nnacl.box.open = function(msg, nonce, publicKey, secretKey) {\n var k = nacl.box.before(publicKey, secretKey);\n return nacl.secretbox.open(msg, nonce, k);\n};\n\nnacl.box.open.after = nacl.secretbox.open;\n\nnacl.box.keyPair = function() {\n var pk = new Uint8Array(crypto_box_PUBLICKEYBYTES);\n var sk = new Uint8Array(crypto_box_SECRETKEYBYTES);\n crypto_box_keypair(pk, sk);\n return {publicKey: pk, secretKey: sk};\n};\n\nnacl.box.keyPair.fromSecretKey = function(secretKey) {\n checkArrayTypes(secretKey);\n if (secretKey.length !== crypto_box_SECRETKEYBYTES)\n throw new Error('bad secret key size');\n var pk = new Uint8Array(crypto_box_PUBLICKEYBYTES);\n crypto_scalarmult_base(pk, secretKey);\n return {publicKey: pk, secretKey: new Uint8Array(secretKey)};\n};\n\nnacl.box.publicKeyLength = crypto_box_PUBLICKEYBYTES;\nnacl.box.secretKeyLength = crypto_box_SECRETKEYBYTES;\nnacl.box.sharedKeyLength = crypto_box_BEFORENMBYTES;\nnacl.box.nonceLength = crypto_box_NONCEBYTES;\nnacl.box.overheadLength = nacl.secretbox.overheadLength;\n\nnacl.sign = function(msg, secretKey) {\n checkArrayTypes(msg, secretKey);\n if (secretKey.length !== crypto_sign_SECRETKEYBYTES)\n throw new Error('bad secret key size');\n var signedMsg = new Uint8Array(crypto_sign_BYTES+msg.length);\n crypto_sign(signedMsg, msg, msg.length, secretKey);\n return signedMsg;\n};\n\nnacl.sign.open = function(signedMsg, publicKey) {\n checkArrayTypes(signedMsg, publicKey);\n if (publicKey.length !== crypto_sign_PUBLICKEYBYTES)\n throw new Error('bad public key size');\n var tmp = new Uint8Array(signedMsg.length);\n var mlen = crypto_sign_open(tmp, signedMsg, signedMsg.length, publicKey);\n if (mlen < 0) return null;\n var m = new Uint8Array(mlen);\n for (var i = 0; i < m.length; i++) m[i] = tmp[i];\n return m;\n};\n\nnacl.sign.detached = function(msg, secretKey) {\n var signedMsg = nacl.sign(msg, secretKey);\n var sig = new Uint8Array(crypto_sign_BYTES);\n for (var i = 0; i < sig.length; i++) sig[i] = signedMsg[i];\n return sig;\n};\n\nnacl.sign.detached.verify = function(msg, sig, publicKey) {\n checkArrayTypes(msg, sig, publicKey);\n if (sig.length !== crypto_sign_BYTES)\n throw new Error('bad signature size');\n if (publicKey.length !== crypto_sign_PUBLICKEYBYTES)\n throw new Error('bad public key size');\n var sm = new Uint8Array(crypto_sign_BYTES + msg.length);\n var m = new Uint8Array(crypto_sign_BYTES + msg.length);\n var i;\n for (i = 0; i < crypto_sign_BYTES; i++) sm[i] = sig[i];\n for (i = 0; i < msg.length; i++) sm[i+crypto_sign_BYTES] = msg[i];\n return (crypto_sign_open(m, sm, sm.length, publicKey) >= 0);\n};\n\nnacl.sign.keyPair = function() {\n var pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);\n var sk = new Uint8Array(crypto_sign_SECRETKEYBYTES);\n crypto_sign_keypair(pk, sk);\n return {publicKey: pk, secretKey: sk};\n};\n\nnacl.sign.keyPair.fromSecretKey = function(secretKey) {\n checkArrayTypes(secretKey);\n if (secretKey.length !== crypto_sign_SECRETKEYBYTES)\n throw new Error('bad secret key size');\n var pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);\n for (var i = 0; i < pk.length; i++) pk[i] = secretKey[32+i];\n return {publicKey: pk, secretKey: new Uint8Array(secretKey)};\n};\n\nnacl.sign.keyPair.fromSeed = function(seed) {\n checkArrayTypes(seed);\n if (seed.length !== crypto_sign_SEEDBYTES)\n throw new Error('bad seed size');\n var pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);\n var sk = new Uint8Array(crypto_sign_SECRETKEYBYTES);\n for (var i = 0; i < 32; i++) sk[i] = seed[i];\n crypto_sign_keypair(pk, sk, true);\n return {publicKey: pk, secretKey: sk};\n};\n\nnacl.sign.publicKeyLength = crypto_sign_PUBLICKEYBYTES;\nnacl.sign.secretKeyLength = crypto_sign_SECRETKEYBYTES;\nnacl.sign.seedLength = crypto_sign_SEEDBYTES;\nnacl.sign.signatureLength = crypto_sign_BYTES;\n\nnacl.hash = function(msg) {\n checkArrayTypes(msg);\n var h = new Uint8Array(crypto_hash_BYTES);\n crypto_hash(h, msg, msg.length);\n return h;\n};\n\nnacl.hash.hashLength = crypto_hash_BYTES;\n\nnacl.verify = function(x, y) {\n checkArrayTypes(x, y);\n // Zero length arguments are considered not equal.\n if (x.length === 0 || y.length === 0) return false;\n if (x.length !== y.length) return false;\n return (vn(x, 0, y, 0, x.length) === 0) ? true : false;\n};\n\nnacl.setPRNG = function(fn) {\n randombytes = fn;\n};\n\n(function() {\n // Initialize PRNG if environment provides CSPRNG.\n // If not, methods calling randombytes will throw.\n var crypto = typeof self !== 'undefined' ? (self.crypto || self.msCrypto) : null;\n if (crypto && crypto.getRandomValues) {\n // Browsers.\n var QUOTA = 65536;\n nacl.setPRNG(function(x, n) {\n var i, v = new Uint8Array(n);\n for (i = 0; i < n; i += QUOTA) {\n crypto.getRandomValues(v.subarray(i, i + Math.min(n - i, QUOTA)));\n }\n for (i = 0; i < n; i++) x[i] = v[i];\n cleanup(v);\n });\n } else if (typeof require !== 'undefined') {\n // Node.js.\n crypto = require('crypto');\n if (crypto && crypto.randomBytes) {\n nacl.setPRNG(function(x, n) {\n var i, v = crypto.randomBytes(n);\n for (i = 0; i < n; i++) x[i] = v[i];\n cleanup(v);\n });\n }\n }\n})();\n\n})(typeof module !== 'undefined' && module.exports ? module.exports : (self.nacl = self.nacl || {}));\n","module.exports = require('./pusher-with-encryption').default;\n","module.exports = require(\"buffer\");","module.exports = require(\"events\");","'use strict';\n\n/**\n\nStreams in a WebSocket connection\n---------------------------------\n\nWe model a WebSocket as two duplex streams: one stream is for the wire protocol\nover an I/O socket, and the other is for incoming/outgoing messages.\n\n\n +----------+ +---------+ +----------+\n [1] write(chunk) -->| ~~~~~~~~ +----->| parse() +----->| ~~~~~~~~ +--> emit('data') [2]\n | | +----+----+ | |\n | | | | |\n | IO | | [5] | Messages |\n | | V | |\n | | +---------+ | |\n [4] emit('data') <--+ ~~~~~~~~ |<-----+ frame() |<-----+ ~~~~~~~~ |<-- write(chunk) [3]\n +----------+ +---------+ +----------+\n\n\nMessage transfer in each direction is simple: IO receives a byte stream [1] and\nsends this stream for parsing. The parser will periodically emit a complete\nmessage text on the Messages stream [2]. Similarly, when messages are written\nto the Messages stream [3], they are framed using the WebSocket wire format and\nemitted via IO [4].\n\nThere is a feedback loop via [5] since some input from [1] will be things like\nping, pong and close frames. In these cases the protocol responds by emitting\nresponses directly back to [4] rather than emitting messages via [2].\n\nFor the purposes of flow control, we consider the sources of each Readable\nstream to be as follows:\n\n* [2] receives input from [1]\n* [4] receives input from [1] and [3]\n\nThe classes below express the relationships described above without prescribing\nanything about how parse() and frame() work, other than assuming they emit\n'data' events to the IO and Messages streams. They will work with any protocol\ndriver having these two methods.\n**/\n\n\nvar Stream = require('stream').Stream,\n util = require('util');\n\n\nvar IO = function(driver) {\n this.readable = this.writable = true;\n this._paused = false;\n this._driver = driver;\n};\nutil.inherits(IO, Stream);\n\n// The IO pause() and resume() methods will be called when the socket we are\n// piping to gets backed up and drains. Since IO output [4] comes from IO input\n// [1] and Messages input [3], we need to tell both of those to return false\n// from write() when this stream is paused.\n\nIO.prototype.pause = function() {\n this._paused = true;\n this._driver.messages._paused = true;\n};\n\nIO.prototype.resume = function() {\n this._paused = false;\n this.emit('drain');\n\n var messages = this._driver.messages;\n messages._paused = false;\n messages.emit('drain');\n};\n\n// When we receive input from a socket, send it to the parser and tell the\n// source whether to back off.\nIO.prototype.write = function(chunk) {\n if (!this.writable) return false;\n this._driver.parse(chunk);\n return !this._paused;\n};\n\n// The IO end() method will be called when the socket piping into it emits\n// 'close' or 'end', i.e. the socket is closed. In this situation the Messages\n// stream will not emit any more data so we emit 'end'.\nIO.prototype.end = function(chunk) {\n if (!this.writable) return;\n if (chunk !== undefined) this.write(chunk);\n this.writable = false;\n\n var messages = this._driver.messages;\n if (messages.readable) {\n messages.readable = messages.writable = false;\n messages.emit('end');\n }\n};\n\nIO.prototype.destroy = function() {\n this.end();\n};\n\n\nvar Messages = function(driver) {\n this.readable = this.writable = true;\n this._paused = false;\n this._driver = driver;\n};\nutil.inherits(Messages, Stream);\n\n// The Messages pause() and resume() methods will be called when the app that's\n// processing the messages gets backed up and drains. If we're emitting\n// messages too fast we should tell the source to slow down. Message output [2]\n// comes from IO input [1].\n\nMessages.prototype.pause = function() {\n this._driver.io._paused = true;\n};\n\nMessages.prototype.resume = function() {\n this._driver.io._paused = false;\n this._driver.io.emit('drain');\n};\n\n// When we receive messages from the user, send them to the formatter and tell\n// the source whether to back off.\nMessages.prototype.write = function(message) {\n if (!this.writable) return false;\n if (typeof message === 'string') this._driver.text(message);\n else this._driver.binary(message);\n return !this._paused;\n};\n\n// The Messages end() method will be called when a stream piping into it emits\n// 'end'. Many streams may be piped into the WebSocket and one of them ending\n// does not mean the whole socket is done, so just process the input and move\n// on leaving the socket open.\nMessages.prototype.end = function(message) {\n if (message !== undefined) this.write(message);\n};\n\nMessages.prototype.destroy = function() {};\n\n\nexports.IO = IO;\nexports.Messages = Messages;\n","'use strict';\n\nvar Buffer = require('safe-buffer').Buffer;\n\nvar StreamReader = function() {\n this._queue = [];\n this._queueSize = 0;\n this._offset = 0;\n};\n\nStreamReader.prototype.put = function(buffer) {\n if (!buffer || buffer.length === 0) return;\n if (!Buffer.isBuffer(buffer)) buffer = Buffer.from(buffer);\n this._queue.push(buffer);\n this._queueSize += buffer.length;\n};\n\nStreamReader.prototype.read = function(length) {\n if (length > this._queueSize) return null;\n if (length === 0) return Buffer.alloc(0);\n\n this._queueSize -= length;\n\n var queue = this._queue,\n remain = length,\n first = queue[0],\n buffers, buffer;\n\n if (first.length >= length) {\n if (first.length === length) {\n return queue.shift();\n } else {\n buffer = first.slice(0, length);\n queue[0] = first.slice(length);\n return buffer;\n }\n }\n\n for (var i = 0, n = queue.length; i < n; i++) {\n if (remain < queue[i].length) break;\n remain -= queue[i].length;\n }\n buffers = queue.splice(0, i);\n\n if (remain > 0 && queue.length > 0) {\n buffers.push(queue[0].slice(0, remain));\n queue[0] = queue[0].slice(remain);\n }\n return Buffer.concat(buffers, length);\n};\n\nStreamReader.prototype.eachByte = function(callback, context) {\n var buffer, n, index;\n\n while (this._queue.length > 0) {\n buffer = this._queue[0];\n n = buffer.length;\n\n while (this._offset < n) {\n index = this._offset;\n this._offset += 1;\n callback.call(context, buffer[index]);\n }\n this._offset = 0;\n this._queue.shift();\n }\n};\n\nmodule.exports = StreamReader;\n","'use strict';\n\nvar Buffer = require('safe-buffer').Buffer,\n crypto = require('crypto'),\n url = require('url'),\n util = require('util'),\n HttpParser = require('../http_parser'),\n Base = require('./base'),\n Hybi = require('./hybi'),\n Proxy = require('./proxy');\n\nvar Client = function(_url, options) {\n this.version = 'hybi-' + Hybi.VERSION;\n Hybi.call(this, null, _url, options);\n\n this.readyState = -1;\n this._key = Client.generateKey();\n this._accept = Hybi.generateAccept(this._key);\n this._http = new HttpParser('response');\n\n var uri = url.parse(this.url),\n auth = uri.auth && Buffer.from(uri.auth, 'utf8').toString('base64');\n\n if (this.VALID_PROTOCOLS.indexOf(uri.protocol) < 0)\n throw new Error(this.url + ' is not a valid WebSocket URL');\n\n this._pathname = (uri.pathname || '/') + (uri.search || '');\n\n this._headers.set('Host', uri.host);\n this._headers.set('Upgrade', 'websocket');\n this._headers.set('Connection', 'Upgrade');\n this._headers.set('Sec-WebSocket-Key', this._key);\n this._headers.set('Sec-WebSocket-Version', Hybi.VERSION);\n\n if (this._protocols.length > 0)\n this._headers.set('Sec-WebSocket-Protocol', this._protocols.join(', '));\n\n if (auth)\n this._headers.set('Authorization', 'Basic ' + auth);\n};\nutil.inherits(Client, Hybi);\n\nClient.generateKey = function() {\n return crypto.randomBytes(16).toString('base64');\n};\n\nvar instance = {\n VALID_PROTOCOLS: ['ws:', 'wss:'],\n\n proxy: function(origin, options) {\n return new Proxy(this, origin, options);\n },\n\n start: function() {\n if (this.readyState !== -1) return false;\n this._write(this._handshakeRequest());\n this.readyState = 0;\n return true;\n },\n\n parse: function(chunk) {\n if (this.readyState === 3) return;\n if (this.readyState > 0) return Hybi.prototype.parse.call(this, chunk);\n\n this._http.parse(chunk);\n if (!this._http.isComplete()) return;\n\n this._validateHandshake();\n if (this.readyState === 3) return;\n\n this._open();\n this.parse(this._http.body);\n },\n\n _handshakeRequest: function() {\n var extensions = this._extensions.generateOffer();\n if (extensions)\n this._headers.set('Sec-WebSocket-Extensions', extensions);\n\n var start = 'GET ' + this._pathname + ' HTTP/1.1',\n headers = [start, this._headers.toString(), ''];\n\n return Buffer.from(headers.join('\\r\\n'), 'utf8');\n },\n\n _failHandshake: function(message) {\n message = 'Error during WebSocket handshake: ' + message;\n this.readyState = 3;\n this.emit('error', new Error(message));\n this.emit('close', new Base.CloseEvent(this.ERRORS.protocol_error, message));\n },\n\n _validateHandshake: function() {\n this.statusCode = this._http.statusCode;\n this.headers = this._http.headers;\n\n if (this._http.error)\n return this._failHandshake(this._http.error.message);\n\n if (this._http.statusCode !== 101)\n return this._failHandshake('Unexpected response code: ' + this._http.statusCode);\n\n var headers = this._http.headers,\n upgrade = headers['upgrade'] || '',\n connection = headers['connection'] || '',\n accept = headers['sec-websocket-accept'] || '',\n protocol = headers['sec-websocket-protocol'] || '';\n\n if (upgrade === '')\n return this._failHandshake(\"'Upgrade' header is missing\");\n if (upgrade.toLowerCase() !== 'websocket')\n return this._failHandshake(\"'Upgrade' header value is not 'WebSocket'\");\n\n if (connection === '')\n return this._failHandshake(\"'Connection' header is missing\");\n if (connection.toLowerCase() !== 'upgrade')\n return this._failHandshake(\"'Connection' header value is not 'Upgrade'\");\n\n if (accept !== this._accept)\n return this._failHandshake('Sec-WebSocket-Accept mismatch');\n\n this.protocol = null;\n\n if (protocol !== '') {\n if (this._protocols.indexOf(protocol) < 0)\n return this._failHandshake('Sec-WebSocket-Protocol mismatch');\n else\n this.protocol = protocol;\n }\n\n try {\n this._extensions.activate(this.headers['sec-websocket-extensions']);\n } catch (e) {\n return this._failHandshake(e.message);\n }\n }\n};\n\nfor (var key in instance)\n Client.prototype[key] = instance[key];\n\nmodule.exports = Client;\n","/*jshint node:true */\n\nvar assert = require('assert');\n\nexports.HTTPParser = HTTPParser;\nfunction HTTPParser(type) {\n assert.ok(type === HTTPParser.REQUEST || type === HTTPParser.RESPONSE || type === undefined);\n if (type === undefined) {\n // Node v12+\n } else {\n this.initialize(type);\n }\n this.maxHeaderSize=HTTPParser.maxHeaderSize\n}\nHTTPParser.prototype.initialize = function (type, async_resource) {\n assert.ok(type === HTTPParser.REQUEST || type === HTTPParser.RESPONSE);\n this.type = type;\n this.state = type + '_LINE';\n this.info = {\n headers: [],\n upgrade: false\n };\n this.trailers = [];\n this.line = '';\n this.isChunked = false;\n this.connection = '';\n this.headerSize = 0; // for preventing too big headers\n this.body_bytes = null;\n this.isUserCall = false;\n this.hadError = false;\n};\n\nHTTPParser.encoding = 'ascii';\nHTTPParser.maxHeaderSize = 80 * 1024; // maxHeaderSize (in bytes) is configurable, but 80kb by default;\nHTTPParser.REQUEST = 'REQUEST';\nHTTPParser.RESPONSE = 'RESPONSE';\n\n// Note: *not* starting with kOnHeaders=0 line the Node parser, because any\n// newly added constants (kOnTimeout in Node v12.19.0) will overwrite 0!\nvar kOnHeaders = HTTPParser.kOnHeaders = 1;\nvar kOnHeadersComplete = HTTPParser.kOnHeadersComplete = 2;\nvar kOnBody = HTTPParser.kOnBody = 3;\nvar kOnMessageComplete = HTTPParser.kOnMessageComplete = 4;\n\n// Some handler stubs, needed for compatibility\nHTTPParser.prototype[kOnHeaders] =\nHTTPParser.prototype[kOnHeadersComplete] =\nHTTPParser.prototype[kOnBody] =\nHTTPParser.prototype[kOnMessageComplete] = function () {};\n\nvar compatMode0_12 = true;\nObject.defineProperty(HTTPParser, 'kOnExecute', {\n get: function () {\n // hack for backward compatibility\n compatMode0_12 = false;\n return 99;\n }\n });\n\nvar methods = exports.methods = HTTPParser.methods = [\n 'DELETE',\n 'GET',\n 'HEAD',\n 'POST',\n 'PUT',\n 'CONNECT',\n 'OPTIONS',\n 'TRACE',\n 'COPY',\n 'LOCK',\n 'MKCOL',\n 'MOVE',\n 'PROPFIND',\n 'PROPPATCH',\n 'SEARCH',\n 'UNLOCK',\n 'BIND',\n 'REBIND',\n 'UNBIND',\n 'ACL',\n 'REPORT',\n 'MKACTIVITY',\n 'CHECKOUT',\n 'MERGE',\n 'M-SEARCH',\n 'NOTIFY',\n 'SUBSCRIBE',\n 'UNSUBSCRIBE',\n 'PATCH',\n 'PURGE',\n 'MKCALENDAR',\n 'LINK',\n 'UNLINK',\n 'SOURCE',\n];\nvar method_connect = methods.indexOf('CONNECT');\nHTTPParser.prototype.reinitialize = HTTPParser;\nHTTPParser.prototype.close =\nHTTPParser.prototype.pause =\nHTTPParser.prototype.resume =\nHTTPParser.prototype.free = function () {};\nHTTPParser.prototype._compatMode0_11 = false;\nHTTPParser.prototype.getAsyncId = function() { return 0; };\n\nvar headerState = {\n REQUEST_LINE: true,\n RESPONSE_LINE: true,\n HEADER: true\n};\nHTTPParser.prototype.execute = function (chunk, start, length) {\n if (!(this instanceof HTTPParser)) {\n throw new TypeError('not a HTTPParser');\n }\n\n // backward compat to node < 0.11.4\n // Note: the start and length params were removed in newer version\n start = start || 0;\n length = typeof length === 'number' ? length : chunk.length;\n\n this.chunk = chunk;\n this.offset = start;\n var end = this.end = start + length;\n try {\n while (this.offset < end) {\n if (this[this.state]()) {\n break;\n }\n }\n } catch (err) {\n if (this.isUserCall) {\n throw err;\n }\n this.hadError = true;\n return err;\n }\n this.chunk = null;\n length = this.offset - start;\n if (headerState[this.state]) {\n this.headerSize += length;\n if (this.headerSize > (this.maxHeaderSize||HTTPParser.maxHeaderSize)) {\n return new Error('max header size exceeded');\n }\n }\n return length;\n};\n\nvar stateFinishAllowed = {\n REQUEST_LINE: true,\n RESPONSE_LINE: true,\n BODY_RAW: true\n};\nHTTPParser.prototype.finish = function () {\n if (this.hadError) {\n return;\n }\n if (!stateFinishAllowed[this.state]) {\n return new Error('invalid state for EOF');\n }\n if (this.state === 'BODY_RAW') {\n this.userCall()(this[kOnMessageComplete]());\n }\n};\n\n// These three methods are used for an internal speed optimization, and it also\n// works if theses are noops. Basically consume() asks us to read the bytes\n// ourselves, but if we don't do it we get them through execute().\nHTTPParser.prototype.consume =\nHTTPParser.prototype.unconsume =\nHTTPParser.prototype.getCurrentBuffer = function () {};\n\n//For correct error handling - see HTTPParser#execute\n//Usage: this.userCall()(userFunction('arg'));\nHTTPParser.prototype.userCall = function () {\n this.isUserCall = true;\n var self = this;\n return function (ret) {\n self.isUserCall = false;\n return ret;\n };\n};\n\nHTTPParser.prototype.nextRequest = function () {\n this.userCall()(this[kOnMessageComplete]());\n this.reinitialize(this.type);\n};\n\nHTTPParser.prototype.consumeLine = function () {\n var end = this.end,\n chunk = this.chunk;\n for (var i = this.offset; i < end; i++) {\n if (chunk[i] === 0x0a) { // \\n\n var line = this.line + chunk.toString(HTTPParser.encoding, this.offset, i);\n if (line.charAt(line.length - 1) === '\\r') {\n line = line.substr(0, line.length - 1);\n }\n this.line = '';\n this.offset = i + 1;\n return line;\n }\n }\n //line split over multiple chunks\n this.line += chunk.toString(HTTPParser.encoding, this.offset, this.end);\n this.offset = this.end;\n};\n\nvar headerExp = /^([^: \\t]+):[ \\t]*((?:.*[^ \\t])|)/;\nvar headerContinueExp = /^[ \\t]+(.*[^ \\t])/;\nHTTPParser.prototype.parseHeader = function (line, headers) {\n if (line.indexOf('\\r') !== -1) {\n throw parseErrorCode('HPE_LF_EXPECTED');\n }\n\n var match = headerExp.exec(line);\n var k = match && match[1];\n if (k) { // skip empty string (malformed header)\n headers.push(k);\n headers.push(match[2]);\n } else {\n var matchContinue = headerContinueExp.exec(line);\n if (matchContinue && headers.length) {\n if (headers[headers.length - 1]) {\n headers[headers.length - 1] += ' ';\n }\n headers[headers.length - 1] += matchContinue[1];\n }\n }\n};\n\nvar requestExp = /^([A-Z-]+) ([^ ]+) HTTP\\/(\\d)\\.(\\d)$/;\nHTTPParser.prototype.REQUEST_LINE = function () {\n var line = this.consumeLine();\n if (!line) {\n return;\n }\n var match = requestExp.exec(line);\n if (match === null) {\n throw parseErrorCode('HPE_INVALID_CONSTANT');\n }\n this.info.method = this._compatMode0_11 ? match[1] : methods.indexOf(match[1]);\n if (this.info.method === -1) {\n throw new Error('invalid request method');\n }\n this.info.url = match[2];\n this.info.versionMajor = +match[3];\n this.info.versionMinor = +match[4];\n this.body_bytes = 0;\n this.state = 'HEADER';\n};\n\nvar responseExp = /^HTTP\\/(\\d)\\.(\\d) (\\d{3}) ?(.*)$/;\nHTTPParser.prototype.RESPONSE_LINE = function () {\n var line = this.consumeLine();\n if (!line) {\n return;\n }\n var match = responseExp.exec(line);\n if (match === null) {\n throw parseErrorCode('HPE_INVALID_CONSTANT');\n }\n this.info.versionMajor = +match[1];\n this.info.versionMinor = +match[2];\n var statusCode = this.info.statusCode = +match[3];\n this.info.statusMessage = match[4];\n // Implied zero length.\n if ((statusCode / 100 | 0) === 1 || statusCode === 204 || statusCode === 304) {\n this.body_bytes = 0;\n }\n this.state = 'HEADER';\n};\n\nHTTPParser.prototype.shouldKeepAlive = function () {\n if (this.info.versionMajor > 0 && this.info.versionMinor > 0) {\n if (this.connection.indexOf('close') !== -1) {\n return false;\n }\n } else if (this.connection.indexOf('keep-alive') === -1) {\n return false;\n }\n if (this.body_bytes !== null || this.isChunked) { // || skipBody\n return true;\n }\n return false;\n};\n\nHTTPParser.prototype.HEADER = function () {\n var line = this.consumeLine();\n if (line === undefined) {\n return;\n }\n var info = this.info;\n if (line) {\n this.parseHeader(line, info.headers);\n } else {\n var headers = info.headers;\n var hasContentLength = false;\n var currentContentLengthValue;\n var hasUpgradeHeader = false;\n for (var i = 0; i < headers.length; i += 2) {\n switch (headers[i].toLowerCase()) {\n case 'transfer-encoding':\n this.isChunked = headers[i + 1].toLowerCase() === 'chunked';\n break;\n case 'content-length':\n currentContentLengthValue = +headers[i + 1];\n if (hasContentLength) {\n // Fix duplicate Content-Length header with same values.\n // Throw error only if values are different.\n // Known issues:\n // https://github.com/request/request/issues/2091#issuecomment-328715113\n // https://github.com/nodejs/node/issues/6517#issuecomment-216263771\n if (currentContentLengthValue !== this.body_bytes) {\n throw parseErrorCode('HPE_UNEXPECTED_CONTENT_LENGTH');\n }\n } else {\n hasContentLength = true;\n this.body_bytes = currentContentLengthValue;\n }\n break;\n case 'connection':\n this.connection += headers[i + 1].toLowerCase();\n break;\n case 'upgrade':\n hasUpgradeHeader = true;\n break;\n }\n }\n\n // if both isChunked and hasContentLength, isChunked wins\n // This is required so the body is parsed using the chunked method, and matches\n // Chrome's behavior. We could, maybe, ignore them both (would get chunked\n // encoding into the body), and/or disable shouldKeepAlive to be more\n // resilient.\n if (this.isChunked && hasContentLength) {\n hasContentLength = false;\n this.body_bytes = null;\n }\n\n // Logic from https://github.com/nodejs/http-parser/blob/921d5585515a153fa00e411cf144280c59b41f90/http_parser.c#L1727-L1737\n // \"For responses, \"Upgrade: foo\" and \"Connection: upgrade\" are\n // mandatory only when it is a 101 Switching Protocols response,\n // otherwise it is purely informational, to announce support.\n if (hasUpgradeHeader && this.connection.indexOf('upgrade') != -1) {\n info.upgrade = this.type === HTTPParser.REQUEST || info.statusCode === 101;\n } else {\n info.upgrade = info.method === method_connect;\n }\n\n if (this.isChunked && info.upgrade) {\n this.isChunked = false;\n }\n\n info.shouldKeepAlive = this.shouldKeepAlive();\n //problem which also exists in original node: we should know skipBody before calling onHeadersComplete\n var skipBody;\n if (compatMode0_12) {\n skipBody = this.userCall()(this[kOnHeadersComplete](info));\n } else {\n skipBody = this.userCall()(this[kOnHeadersComplete](info.versionMajor,\n info.versionMinor, info.headers, info.method, info.url, info.statusCode,\n info.statusMessage, info.upgrade, info.shouldKeepAlive));\n }\n if (skipBody === 2) {\n this.nextRequest();\n return true;\n } else if (this.isChunked && !skipBody) {\n this.state = 'BODY_CHUNKHEAD';\n } else if (skipBody || this.body_bytes === 0) {\n this.nextRequest();\n // For older versions of node (v6.x and older?), that return skipBody=1 or skipBody=true,\n // need this \"return true;\" if it's an upgrade request.\n return info.upgrade;\n } else if (this.body_bytes === null) {\n this.state = 'BODY_RAW';\n } else {\n this.state = 'BODY_SIZED';\n }\n }\n};\n\nHTTPParser.prototype.BODY_CHUNKHEAD = function () {\n var line = this.consumeLine();\n if (line === undefined) {\n return;\n }\n this.body_bytes = parseInt(line, 16);\n if (!this.body_bytes) {\n this.state = 'BODY_CHUNKTRAILERS';\n } else {\n this.state = 'BODY_CHUNK';\n }\n};\n\nHTTPParser.prototype.BODY_CHUNK = function () {\n var length = Math.min(this.end - this.offset, this.body_bytes);\n this.userCall()(this[kOnBody](this.chunk, this.offset, length));\n this.offset += length;\n this.body_bytes -= length;\n if (!this.body_bytes) {\n this.state = 'BODY_CHUNKEMPTYLINE';\n }\n};\n\nHTTPParser.prototype.BODY_CHUNKEMPTYLINE = function () {\n var line = this.consumeLine();\n if (line === undefined) {\n return;\n }\n assert.equal(line, '');\n this.state = 'BODY_CHUNKHEAD';\n};\n\nHTTPParser.prototype.BODY_CHUNKTRAILERS = function () {\n var line = this.consumeLine();\n if (line === undefined) {\n return;\n }\n if (line) {\n this.parseHeader(line, this.trailers);\n } else {\n if (this.trailers.length) {\n this.userCall()(this[kOnHeaders](this.trailers, ''));\n }\n this.nextRequest();\n }\n};\n\nHTTPParser.prototype.BODY_RAW = function () {\n var length = this.end - this.offset;\n this.userCall()(this[kOnBody](this.chunk, this.offset, length));\n this.offset = this.end;\n};\n\nHTTPParser.prototype.BODY_SIZED = function () {\n var length = Math.min(this.end - this.offset, this.body_bytes);\n this.userCall()(this[kOnBody](this.chunk, this.offset, length));\n this.offset += length;\n this.body_bytes -= length;\n if (!this.body_bytes) {\n this.nextRequest();\n }\n};\n\n// backward compat to node < 0.11.6\n['Headers', 'HeadersComplete', 'Body', 'MessageComplete'].forEach(function (name) {\n var k = HTTPParser['kOn' + name];\n Object.defineProperty(HTTPParser.prototype, 'on' + name, {\n get: function () {\n return this[k];\n },\n set: function (to) {\n // hack for backward compatibility\n this._compatMode0_11 = true;\n method_connect = 'CONNECT';\n return (this[k] = to);\n }\n });\n});\n\nfunction parseErrorCode(code) {\n var err = new Error('Parse Error');\n err.code = code;\n return err;\n}\n","module.exports = require(\"assert\");","'use strict';\n\nvar Parser = require('./parser'),\n Pipeline = require('./pipeline');\n\nvar Extensions = function() {\n this._rsv1 = this._rsv2 = this._rsv3 = null;\n\n this._byName = {};\n this._inOrder = [];\n this._sessions = [];\n this._index = {};\n};\n\nExtensions.MESSAGE_OPCODES = [1, 2];\n\nvar instance = {\n add: function(ext) {\n if (typeof ext.name !== 'string') throw new TypeError('extension.name must be a string');\n if (ext.type !== 'permessage') throw new TypeError('extension.type must be \"permessage\"');\n\n if (typeof ext.rsv1 !== 'boolean') throw new TypeError('extension.rsv1 must be true or false');\n if (typeof ext.rsv2 !== 'boolean') throw new TypeError('extension.rsv2 must be true or false');\n if (typeof ext.rsv3 !== 'boolean') throw new TypeError('extension.rsv3 must be true or false');\n\n if (this._byName.hasOwnProperty(ext.name))\n throw new TypeError('An extension with name \"' + ext.name + '\" is already registered');\n\n this._byName[ext.name] = ext;\n this._inOrder.push(ext);\n },\n\n generateOffer: function() {\n var sessions = [],\n offer = [],\n index = {};\n\n this._inOrder.forEach(function(ext) {\n var session = ext.createClientSession();\n if (!session) return;\n\n var record = [ext, session];\n sessions.push(record);\n index[ext.name] = record;\n\n var offers = session.generateOffer();\n offers = offers ? [].concat(offers) : [];\n\n offers.forEach(function(off) {\n offer.push(Parser.serializeParams(ext.name, off));\n }, this);\n }, this);\n\n this._sessions = sessions;\n this._index = index;\n\n return offer.length > 0 ? offer.join(', ') : null;\n },\n\n activate: function(header) {\n var responses = Parser.parseHeader(header),\n sessions = [];\n\n responses.eachOffer(function(name, params) {\n var record = this._index[name];\n\n if (!record)\n throw new Error('Server sent an extension response for unknown extension \"' + name + '\"');\n\n var ext = record[0],\n session = record[1],\n reserved = this._reserved(ext);\n\n if (reserved)\n throw new Error('Server sent two extension responses that use the RSV' +\n reserved[0] + ' bit: \"' +\n reserved[1] + '\" and \"' + ext.name + '\"');\n\n if (session.activate(params) !== true)\n throw new Error('Server sent unacceptable extension parameters: ' +\n Parser.serializeParams(name, params));\n\n this._reserve(ext);\n sessions.push(record);\n }, this);\n\n this._sessions = sessions;\n this._pipeline = new Pipeline(sessions);\n },\n\n generateResponse: function(header) {\n var sessions = [],\n response = [],\n offers = Parser.parseHeader(header);\n\n this._inOrder.forEach(function(ext) {\n var offer = offers.byName(ext.name);\n if (offer.length === 0 || this._reserved(ext)) return;\n\n var session = ext.createServerSession(offer);\n if (!session) return;\n\n this._reserve(ext);\n sessions.push([ext, session]);\n response.push(Parser.serializeParams(ext.name, session.generateResponse()));\n }, this);\n\n this._sessions = sessions;\n this._pipeline = new Pipeline(sessions);\n\n return response.length > 0 ? response.join(', ') : null;\n },\n\n validFrameRsv: function(frame) {\n var allowed = { rsv1: false, rsv2: false, rsv3: false },\n ext;\n\n if (Extensions.MESSAGE_OPCODES.indexOf(frame.opcode) >= 0) {\n for (var i = 0, n = this._sessions.length; i < n; i++) {\n ext = this._sessions[i][0];\n allowed.rsv1 = allowed.rsv1 || ext.rsv1;\n allowed.rsv2 = allowed.rsv2 || ext.rsv2;\n allowed.rsv3 = allowed.rsv3 || ext.rsv3;\n }\n }\n\n return (allowed.rsv1 || !frame.rsv1) &&\n (allowed.rsv2 || !frame.rsv2) &&\n (allowed.rsv3 || !frame.rsv3);\n },\n\n processIncomingMessage: function(message, callback, context) {\n this._pipeline.processIncomingMessage(message, callback, context);\n },\n\n processOutgoingMessage: function(message, callback, context) {\n this._pipeline.processOutgoingMessage(message, callback, context);\n },\n\n close: function(callback, context) {\n if (!this._pipeline) return callback.call(context);\n this._pipeline.close(callback, context);\n },\n\n _reserve: function(ext) {\n this._rsv1 = this._rsv1 || (ext.rsv1 && ext.name);\n this._rsv2 = this._rsv2 || (ext.rsv2 && ext.name);\n this._rsv3 = this._rsv3 || (ext.rsv3 && ext.name);\n },\n\n _reserved: function(ext) {\n if (this._rsv1 && ext.rsv1) return [1, this._rsv1];\n if (this._rsv2 && ext.rsv2) return [2, this._rsv2];\n if (this._rsv3 && ext.rsv3) return [3, this._rsv3];\n return false;\n }\n};\n\nfor (var key in instance)\n Extensions.prototype[key] = instance[key];\n\nmodule.exports = Extensions;\n","'use strict';\n\nvar TOKEN = /([!#\\$%&'\\*\\+\\-\\.\\^_`\\|~0-9A-Za-z]+)/,\n NOTOKEN = /([^!#\\$%&'\\*\\+\\-\\.\\^_`\\|~0-9A-Za-z])/g,\n QUOTED = /\"((?:\\\\[\\x00-\\x7f]|[^\\x00-\\x08\\x0a-\\x1f\\x7f\"\\\\])*)\"/,\n PARAM = new RegExp(TOKEN.source + '(?:=(?:' + TOKEN.source + '|' + QUOTED.source + '))?'),\n EXT = new RegExp(TOKEN.source + '(?: *; *' + PARAM.source + ')*', 'g'),\n EXT_LIST = new RegExp('^' + EXT.source + '(?: *, *' + EXT.source + ')*$'),\n NUMBER = /^-?(0|[1-9][0-9]*)(\\.[0-9]+)?$/;\n\nvar hasOwnProperty = Object.prototype.hasOwnProperty;\n\nvar Parser = {\n parseHeader: function(header) {\n var offers = new Offers();\n if (header === '' || header === undefined) return offers;\n\n if (!EXT_LIST.test(header))\n throw new SyntaxError('Invalid Sec-WebSocket-Extensions header: ' + header);\n\n var values = header.match(EXT);\n\n values.forEach(function(value) {\n var params = value.match(new RegExp(PARAM.source, 'g')),\n name = params.shift(),\n offer = {};\n\n params.forEach(function(param) {\n var args = param.match(PARAM), key = args[1], data;\n\n if (args[2] !== undefined) {\n data = args[2];\n } else if (args[3] !== undefined) {\n data = args[3].replace(/\\\\/g, '');\n } else {\n data = true;\n }\n if (NUMBER.test(data)) data = parseFloat(data);\n\n if (hasOwnProperty.call(offer, key)) {\n offer[key] = [].concat(offer[key]);\n offer[key].push(data);\n } else {\n offer[key] = data;\n }\n }, this);\n offers.push(name, offer);\n }, this);\n\n return offers;\n },\n\n serializeParams: function(name, params) {\n var values = [];\n\n var print = function(key, value) {\n if (value instanceof Array) {\n value.forEach(function(v) { print(key, v) });\n } else if (value === true) {\n values.push(key);\n } else if (typeof value === 'number') {\n values.push(key + '=' + value);\n } else if (NOTOKEN.test(value)) {\n values.push(key + '=\"' + value.replace(/\"/g, '\\\\\"') + '\"');\n } else {\n values.push(key + '=' + value);\n }\n };\n\n for (var key in params) print(key, params[key]);\n\n return [name].concat(values).join('; ');\n }\n};\n\nvar Offers = function() {\n this._byName = {};\n this._inOrder = [];\n};\n\nOffers.prototype.push = function(name, params) {\n if (!hasOwnProperty.call(this._byName, name))\n this._byName[name] = [];\n\n this._byName[name].push(params);\n this._inOrder.push({ name: name, params: params });\n};\n\nOffers.prototype.eachOffer = function(callback, context) {\n var list = this._inOrder;\n for (var i = 0, n = list.length; i < n; i++)\n callback.call(context, list[i].name, list[i].params);\n};\n\nOffers.prototype.byName = function(name) {\n return this._byName[name] || [];\n};\n\nOffers.prototype.toArray = function() {\n return this._inOrder.slice();\n};\n\nmodule.exports = Parser;\n","'use strict';\n\nvar Cell = require('./cell'),\n Pledge = require('./pledge');\n\nvar Pipeline = function(sessions) {\n this._cells = sessions.map(function(session) { return new Cell(session) });\n this._stopped = { incoming: false, outgoing: false };\n};\n\nPipeline.prototype.processIncomingMessage = function(message, callback, context) {\n if (this._stopped.incoming) return;\n this._loop('incoming', this._cells.length - 1, -1, -1, message, callback, context);\n};\n\nPipeline.prototype.processOutgoingMessage = function(message, callback, context) {\n if (this._stopped.outgoing) return;\n this._loop('outgoing', 0, this._cells.length, 1, message, callback, context);\n};\n\nPipeline.prototype.close = function(callback, context) {\n this._stopped = { incoming: true, outgoing: true };\n\n var closed = this._cells.map(function(a) { return a.close() });\n if (callback)\n Pledge.all(closed).then(function() { callback.call(context) });\n};\n\nPipeline.prototype._loop = function(direction, start, end, step, message, callback, context) {\n var cells = this._cells,\n n = cells.length,\n self = this;\n\n while (n--) cells[n].pending(direction);\n\n var pipe = function(index, error, msg) {\n if (index === end) return callback.call(context, error, msg);\n\n cells[index][direction](error, msg, function(err, m) {\n if (err) self._stopped[direction] = true;\n pipe(index + step, err, m);\n });\n };\n pipe(start, null, message);\n};\n\nmodule.exports = Pipeline;\n","'use strict';\n\nvar Functor = require('./functor'),\n Pledge = require('./pledge');\n\nvar Cell = function(tuple) {\n this._ext = tuple[0];\n this._session = tuple[1];\n\n this._functors = {\n incoming: new Functor(this._session, 'processIncomingMessage'),\n outgoing: new Functor(this._session, 'processOutgoingMessage')\n };\n};\n\nCell.prototype.pending = function(direction) {\n var functor = this._functors[direction];\n if (!functor._stopped) functor.pending += 1;\n};\n\nCell.prototype.incoming = function(error, message, callback, context) {\n this._exec('incoming', error, message, callback, context);\n};\n\nCell.prototype.outgoing = function(error, message, callback, context) {\n this._exec('outgoing', error, message, callback, context);\n};\n\nCell.prototype.close = function() {\n this._closed = this._closed || new Pledge();\n this._doClose();\n return this._closed;\n};\n\nCell.prototype._exec = function(direction, error, message, callback, context) {\n this._functors[direction].call(error, message, function(err, msg) {\n if (err) err.message = this._ext.name + ': ' + err.message;\n callback.call(context, err, msg);\n this._doClose();\n }, this);\n};\n\nCell.prototype._doClose = function() {\n var fin = this._functors.incoming,\n fout = this._functors.outgoing;\n\n if (!this._closed || fin.pending + fout.pending !== 0) return;\n if (this._session) this._session.close();\n this._session = null;\n this._closed.done();\n};\n\nmodule.exports = Cell;\n","'use strict';\n\nvar RingBuffer = require('./ring_buffer');\n\nvar Functor = function(session, method) {\n this._session = session;\n this._method = method;\n this._queue = new RingBuffer(Functor.QUEUE_SIZE);\n this._stopped = false;\n this.pending = 0;\n};\n\nFunctor.QUEUE_SIZE = 8;\n\nFunctor.prototype.call = function(error, message, callback, context) {\n if (this._stopped) return;\n\n var record = { error: error, message: message, callback: callback, context: context, done: false },\n called = false,\n self = this;\n\n this._queue.push(record);\n\n if (record.error) {\n record.done = true;\n this._stop();\n return this._flushQueue();\n }\n\n var handler = function(err, msg) {\n if (!(called ^ (called = true))) return;\n\n if (err) {\n self._stop();\n record.error = err;\n record.message = null;\n } else {\n record.message = msg;\n }\n\n record.done = true;\n self._flushQueue();\n };\n\n try {\n this._session[this._method](message, handler);\n } catch (err) {\n handler(err);\n }\n};\n\nFunctor.prototype._stop = function() {\n this.pending = this._queue.length;\n this._stopped = true;\n};\n\nFunctor.prototype._flushQueue = function() {\n var queue = this._queue, record;\n\n while (queue.length > 0 && queue.peek().done) {\n record = queue.shift();\n if (record.error) {\n this.pending = 0;\n queue.clear();\n } else {\n this.pending -= 1;\n }\n record.callback.call(record.context, record.error, record.message);\n }\n};\n\nmodule.exports = Functor;\n","'use strict';\n\nvar Frame = function() {};\n\nvar instance = {\n final: false,\n rsv1: false,\n rsv2: false,\n rsv3: false,\n opcode: null,\n masked: false,\n maskingKey: null,\n lengthBytes: 1,\n length: 0,\n payload: null\n};\n\nfor (var key in instance)\n Frame.prototype[key] = instance[key];\n\nmodule.exports = Frame;\n","'use strict';\n\nvar Buffer = require('safe-buffer').Buffer;\n\nvar Message = function() {\n this.rsv1 = false;\n this.rsv2 = false;\n this.rsv3 = false;\n this.opcode = null;\n this.length = 0;\n this._chunks = [];\n};\n\nvar instance = {\n read: function() {\n return this.data = this.data || Buffer.concat(this._chunks, this.length);\n },\n\n pushFrame: function(frame) {\n this.rsv1 = this.rsv1 || frame.rsv1;\n this.rsv2 = this.rsv2 || frame.rsv2;\n this.rsv3 = this.rsv3 || frame.rsv3;\n\n if (this.opcode === null) this.opcode = frame.opcode;\n\n this._chunks.push(frame.payload);\n this.length += frame.length;\n }\n};\n\nfor (var key in instance)\n Message.prototype[key] = instance[key];\n\nmodule.exports = Message;\n","'use strict';\n\nvar Buffer = require('safe-buffer').Buffer,\n Stream = require('stream').Stream,\n url = require('url'),\n util = require('util'),\n Base = require('./base'),\n Headers = require('./headers'),\n HttpParser = require('../http_parser');\n\nvar PORTS = { 'ws:': 80, 'wss:': 443 };\n\nvar Proxy = function(client, origin, options) {\n this._client = client;\n this._http = new HttpParser('response');\n this._origin = (typeof client.url === 'object') ? client.url : url.parse(client.url);\n this._url = (typeof origin === 'object') ? origin : url.parse(origin);\n this._options = options || {};\n this._state = 0;\n\n this.readable = this.writable = true;\n this._paused = false;\n\n this._headers = new Headers();\n this._headers.set('Host', this._origin.host);\n this._headers.set('Connection', 'keep-alive');\n this._headers.set('Proxy-Connection', 'keep-alive');\n\n var auth = this._url.auth && Buffer.from(this._url.auth, 'utf8').toString('base64');\n if (auth) this._headers.set('Proxy-Authorization', 'Basic ' + auth);\n};\nutil.inherits(Proxy, Stream);\n\nvar instance = {\n setHeader: function(name, value) {\n if (this._state !== 0) return false;\n this._headers.set(name, value);\n return true;\n },\n\n start: function() {\n if (this._state !== 0) return false;\n this._state = 1;\n\n var origin = this._origin,\n port = origin.port || PORTS[origin.protocol],\n start = 'CONNECT ' + origin.hostname + ':' + port + ' HTTP/1.1';\n\n var headers = [start, this._headers.toString(), ''];\n\n this.emit('data', Buffer.from(headers.join('\\r\\n'), 'utf8'));\n return true;\n },\n\n pause: function() {\n this._paused = true;\n },\n\n resume: function() {\n this._paused = false;\n this.emit('drain');\n },\n\n write: function(chunk) {\n if (!this.writable) return false;\n\n this._http.parse(chunk);\n if (!this._http.isComplete()) return !this._paused;\n\n this.statusCode = this._http.statusCode;\n this.headers = this._http.headers;\n\n if (this.statusCode === 200) {\n this.emit('connect', new Base.ConnectEvent());\n } else {\n var message = \"Can't establish a connection to the server at \" + this._origin.href;\n this.emit('error', new Error(message));\n }\n this.end();\n return !this._paused;\n },\n\n end: function(chunk) {\n if (!this.writable) return;\n if (chunk !== undefined) this.write(chunk);\n this.readable = this.writable = false;\n this.emit('close');\n this.emit('end');\n },\n\n destroy: function() {\n this.end();\n }\n};\n\nfor (var key in instance)\n Proxy.prototype[key] = instance[key];\n\nmodule.exports = Proxy;\n","'use strict';\n\nvar util = require('util'),\n HttpParser = require('../http_parser'),\n Base = require('./base'),\n Draft75 = require('./draft75'),\n Draft76 = require('./draft76'),\n Hybi = require('./hybi');\n\nvar Server = function(options) {\n Base.call(this, null, null, options);\n this._http = new HttpParser('request');\n};\nutil.inherits(Server, Base);\n\nvar instance = {\n EVENTS: ['open', 'message', 'error', 'close', 'ping', 'pong'],\n\n _bindEventListeners: function() {\n this.messages.on('error', function() {});\n this.on('error', function() {});\n },\n\n parse: function(chunk) {\n if (this._delegate) return this._delegate.parse(chunk);\n\n this._http.parse(chunk);\n if (!this._http.isComplete()) return;\n\n this.method = this._http.method;\n this.url = this._http.url;\n this.headers = this._http.headers;\n this.body = this._http.body;\n\n var self = this;\n this._delegate = Server.http(this, this._options);\n this._delegate.messages = this.messages;\n this._delegate.io = this.io;\n this._open();\n\n this.EVENTS.forEach(function(event) {\n this._delegate.on(event, function(e) { self.emit(event, e) });\n }, this);\n\n this.protocol = this._delegate.protocol;\n this.version = this._delegate.version;\n\n this.parse(this._http.body);\n this.emit('connect', new Base.ConnectEvent());\n },\n\n _open: function() {\n this.__queue.forEach(function(msg) {\n this._delegate[msg[0]].apply(this._delegate, msg[1]);\n }, this);\n this.__queue = [];\n }\n};\n\n['addExtension', 'setHeader', 'start', 'frame', 'text', 'binary', 'ping', 'close'].forEach(function(method) {\n instance[method] = function() {\n if (this._delegate) {\n return this._delegate[method].apply(this._delegate, arguments);\n } else {\n this.__queue.push([method, arguments]);\n return true;\n }\n };\n});\n\nfor (var key in instance)\n Server.prototype[key] = instance[key];\n\nServer.isSecureRequest = function(request) {\n if (request.connection && request.connection.authorized !== undefined) return true;\n if (request.socket && request.socket.secure) return true;\n\n var headers = request.headers;\n if (!headers) return false;\n if (headers['https'] === 'on') return true;\n if (headers['x-forwarded-ssl'] === 'on') return true;\n if (headers['x-forwarded-scheme'] === 'https') return true;\n if (headers['x-forwarded-proto'] === 'https') return true;\n\n return false;\n};\n\nServer.determineUrl = function(request) {\n var scheme = this.isSecureRequest(request) ? 'wss:' : 'ws:';\n return scheme + '//' + request.headers.host + request.url;\n};\n\nServer.http = function(request, options) {\n options = options || {};\n if (options.requireMasking === undefined) options.requireMasking = true;\n\n var headers = request.headers,\n version = headers['sec-websocket-version'],\n key = headers['sec-websocket-key'],\n key1 = headers['sec-websocket-key1'],\n key2 = headers['sec-websocket-key2'],\n url = this.determineUrl(request);\n\n if (version || key)\n return new Hybi(request, url, options);\n else if (key1 || key2)\n return new Draft76(request, url, options);\n else\n return new Draft75(request, url, options);\n};\n\nmodule.exports = Server;\n","'use strict';\n\nvar Buffer = require('safe-buffer').Buffer,\n Base = require('./base'),\n Draft75 = require('./draft75'),\n crypto = require('crypto'),\n util = require('util');\n\n\nvar numberFromKey = function(key) {\n return parseInt((key.match(/[0-9]/g) || []).join(''), 10);\n};\n\nvar spacesInKey = function(key) {\n return (key.match(/ /g) || []).length;\n};\n\n\nvar Draft76 = function(request, url, options) {\n Draft75.apply(this, arguments);\n this._stage = -1;\n this._body = [];\n this.version = 'hixie-76';\n\n this._headers.clear();\n\n this._headers.set('Upgrade', 'WebSocket');\n this._headers.set('Connection', 'Upgrade');\n this._headers.set('Sec-WebSocket-Origin', this._request.headers.origin);\n this._headers.set('Sec-WebSocket-Location', this.url);\n};\nutil.inherits(Draft76, Draft75);\n\nvar instance = {\n BODY_SIZE: 8,\n\n start: function() {\n if (!Draft75.prototype.start.call(this)) return false;\n this._started = true;\n this._sendHandshakeBody();\n return true;\n },\n\n close: function() {\n if (this.readyState === 3) return false;\n if (this.readyState === 1) this._write(Buffer.from([0xFF, 0x00]));\n this.readyState = 3;\n this.emit('close', new Base.CloseEvent(null, null));\n return true;\n },\n\n _handshakeResponse: function() {\n var headers = this._request.headers,\n key1 = headers['sec-websocket-key1'],\n key2 = headers['sec-websocket-key2'];\n\n if (!key1) throw new Error('Missing required header: Sec-WebSocket-Key1');\n if (!key2) throw new Error('Missing required header: Sec-WebSocket-Key2');\n\n var number1 = numberFromKey(key1),\n spaces1 = spacesInKey(key1),\n\n number2 = numberFromKey(key2),\n spaces2 = spacesInKey(key2);\n\n if (number1 % spaces1 !== 0 || number2 % spaces2 !== 0)\n throw new Error('Client sent invalid Sec-WebSocket-Key headers');\n\n this._keyValues = [number1 / spaces1, number2 / spaces2];\n\n var start = 'HTTP/1.1 101 WebSocket Protocol Handshake',\n headers = [start, this._headers.toString(), ''];\n\n return Buffer.from(headers.join('\\r\\n'), 'binary');\n },\n\n _handshakeSignature: function() {\n if (this._body.length < this.BODY_SIZE) return null;\n\n var md5 = crypto.createHash('md5'),\n buffer = Buffer.allocUnsafe(8 + this.BODY_SIZE);\n\n buffer.writeUInt32BE(this._keyValues[0], 0);\n buffer.writeUInt32BE(this._keyValues[1], 4);\n Buffer.from(this._body).copy(buffer, 8, 0, this.BODY_SIZE);\n\n md5.update(buffer);\n return Buffer.from(md5.digest('binary'), 'binary');\n },\n\n _sendHandshakeBody: function() {\n if (!this._started) return;\n var signature = this._handshakeSignature();\n if (!signature) return;\n\n this._write(signature);\n this._stage = 0;\n this._open();\n\n if (this._body.length > this.BODY_SIZE)\n this.parse(this._body.slice(this.BODY_SIZE));\n },\n\n _parseLeadingByte: function(octet) {\n if (octet !== 0xFF)\n return Draft75.prototype._parseLeadingByte.call(this, octet);\n\n this._closing = true;\n this._length = 0;\n this._stage = 1;\n }\n};\n\nfor (var key in instance)\n Draft76.prototype[key] = instance[key];\n\nmodule.exports = Draft76;\n","'use strict';\n\nvar util = require('util'),\n net = require('net'),\n tls = require('tls'),\n url = require('url'),\n driver = require('websocket-driver'),\n API = require('./api'),\n Event = require('./api/event');\n\nvar DEFAULT_PORTS = {'http:': 80, 'https:': 443, 'ws:':80, 'wss:': 443},\n SECURE_PROTOCOLS = ['https:', 'wss:'];\n\nvar Client = function(_url, protocols, options) {\n options = options || {};\n\n this.url = _url;\n this._driver = driver.client(this.url, {maxLength: options.maxLength, protocols: protocols});\n\n ['open', 'error'].forEach(function(event) {\n this._driver.on(event, function() {\n self.headers = self._driver.headers;\n self.statusCode = self._driver.statusCode;\n });\n }, this);\n\n var proxy = options.proxy || {},\n endpoint = url.parse(proxy.origin || this.url),\n port = endpoint.port || DEFAULT_PORTS[endpoint.protocol],\n secure = SECURE_PROTOCOLS.indexOf(endpoint.protocol) >= 0,\n onConnect = function() { self._onConnect() },\n netOptions = options.net || {},\n originTLS = options.tls || {},\n socketTLS = proxy.origin ? (proxy.tls || {}) : originTLS,\n self = this;\n\n netOptions.host = socketTLS.host = endpoint.hostname;\n netOptions.port = socketTLS.port = port;\n\n originTLS.ca = originTLS.ca || options.ca;\n socketTLS.servername = socketTLS.servername || endpoint.hostname;\n\n this._stream = secure\n ? tls.connect(socketTLS, onConnect)\n : net.connect(netOptions, onConnect);\n\n if (proxy.origin) this._configureProxy(proxy, originTLS);\n\n API.call(this, options);\n};\nutil.inherits(Client, API);\n\nClient.prototype._onConnect = function() {\n var worker = this._proxy || this._driver;\n worker.start();\n};\n\nClient.prototype._configureProxy = function(proxy, originTLS) {\n var uri = url.parse(this.url),\n secure = SECURE_PROTOCOLS.indexOf(uri.protocol) >= 0,\n self = this,\n name;\n\n this._proxy = this._driver.proxy(proxy.origin);\n\n if (proxy.headers) {\n for (name in proxy.headers) this._proxy.setHeader(name, proxy.headers[name]);\n }\n\n this._proxy.pipe(this._stream, {end: false});\n this._stream.pipe(this._proxy);\n\n this._proxy.on('connect', function() {\n if (secure) {\n var options = {socket: self._stream, servername: uri.hostname};\n for (name in originTLS) options[name] = originTLS[name];\n self._stream = tls.connect(options);\n self._configureStream();\n }\n self._driver.io.pipe(self._stream);\n self._stream.pipe(self._driver.io);\n self._driver.start();\n });\n\n this._proxy.on('error', function(error) {\n self._driver.emit('error', error);\n });\n};\n\nmodule.exports = Client;\n","module.exports = require(\"net\");","module.exports = require(\"tls\");","'use strict';\n\nvar Stream = require('stream').Stream,\n util = require('util'),\n driver = require('websocket-driver'),\n Headers = require('websocket-driver/lib/websocket/driver/headers'),\n API = require('./websocket/api'),\n EventTarget = require('./websocket/api/event_target'),\n Event = require('./websocket/api/event');\n\nvar EventSource = function(request, response, options) {\n this.writable = true;\n options = options || {};\n\n this._stream = response.socket;\n this._ping = options.ping || this.DEFAULT_PING;\n this._retry = options.retry || this.DEFAULT_RETRY;\n\n var scheme = driver.isSecureRequest(request) ? 'https:' : 'http:';\n this.url = scheme + '//' + request.headers.host + request.url;\n this.lastEventId = request.headers['last-event-id'] || '';\n this.readyState = API.CONNECTING;\n\n var headers = new Headers(),\n self = this;\n\n if (options.headers) {\n for (var key in options.headers) headers.set(key, options.headers[key]);\n }\n\n if (!this._stream || !this._stream.writable) return;\n process.nextTick(function() { self._open() });\n\n this._stream.setTimeout(0);\n this._stream.setNoDelay(true);\n\n var handshake = 'HTTP/1.1 200 OK\\r\\n' +\n 'Content-Type: text/event-stream\\r\\n' +\n 'Cache-Control: no-cache, no-store\\r\\n' +\n 'Connection: close\\r\\n' +\n headers.toString() +\n '\\r\\n' +\n 'retry: ' + Math.floor(this._retry * 1000) + '\\r\\n\\r\\n';\n\n this._write(handshake);\n\n this._stream.on('drain', function() { self.emit('drain') });\n\n if (this._ping)\n this._pingTimer = setInterval(function() { self.ping() }, this._ping * 1000);\n\n ['error', 'end'].forEach(function(event) {\n self._stream.on(event, function() { self.close() });\n });\n};\nutil.inherits(EventSource, Stream);\n\nEventSource.isEventSource = function(request) {\n if (request.method !== 'GET') return false;\n var accept = (request.headers.accept || '').split(/\\s*,\\s*/);\n return accept.indexOf('text/event-stream') >= 0;\n};\n\nvar instance = {\n DEFAULT_PING: 10,\n DEFAULT_RETRY: 5,\n\n _write: function(chunk) {\n if (!this.writable) return false;\n try {\n return this._stream.write(chunk, 'utf8');\n } catch (e) {\n return false;\n }\n },\n\n _open: function() {\n if (this.readyState !== API.CONNECTING) return;\n\n this.readyState = API.OPEN;\n\n var event = new Event('open');\n event.initEvent('open', false, false);\n this.dispatchEvent(event);\n },\n\n write: function(message) {\n return this.send(message);\n },\n\n end: function(message) {\n if (message !== undefined) this.write(message);\n this.close();\n },\n\n send: function(message, options) {\n if (this.readyState > API.OPEN) return false;\n\n message = String(message).replace(/(\\r\\n|\\r|\\n)/g, '$1data: ');\n options = options || {};\n\n var frame = '';\n if (options.event) frame += 'event: ' + options.event + '\\r\\n';\n if (options.id) frame += 'id: ' + options.id + '\\r\\n';\n frame += 'data: ' + message + '\\r\\n\\r\\n';\n\n return this._write(frame);\n },\n\n ping: function() {\n return this._write(':\\r\\n\\r\\n');\n },\n\n close: function() {\n if (this.readyState > API.OPEN) return false;\n\n this.readyState = API.CLOSED;\n this.writable = false;\n if (this._pingTimer) clearInterval(this._pingTimer);\n if (this._stream) this._stream.end();\n\n var event = new Event('close');\n event.initEvent('close', false, false);\n this.dispatchEvent(event);\n\n return true;\n }\n};\n\nfor (var method in instance) EventSource.prototype[method] = instance[method];\nfor (var key in EventTarget) EventSource.prototype[key] = EventTarget[key];\n\nmodule.exports = EventSource;\n","module.exports = require(\"child_process\");","module.exports = require(\"fs\");","module.exports = require(\"http\");","module.exports = require(\"https\");","export default function encode(s: any): string {\n return btoa(utob(s));\n}\n\nvar fromCharCode = String.fromCharCode;\n\nvar b64chars =\n 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';\nvar b64tab = {};\n\nfor (var i = 0, l = b64chars.length; i < l; i++) {\n b64tab[b64chars.charAt(i)] = i;\n}\n\nvar cb_utob = function(c) {\n var cc = c.charCodeAt(0);\n return cc < 0x80\n ? c\n : cc < 0x800\n ? fromCharCode(0xc0 | (cc >>> 6)) + fromCharCode(0x80 | (cc & 0x3f))\n : fromCharCode(0xe0 | ((cc >>> 12) & 0x0f)) +\n fromCharCode(0x80 | ((cc >>> 6) & 0x3f)) +\n fromCharCode(0x80 | (cc & 0x3f));\n};\n\nvar utob = function(u) {\n return u.replace(/[^\\x00-\\x7F]/g, cb_utob);\n};\n\nvar cb_encode = function(ccc) {\n var padlen = [0, 2, 1][ccc.length % 3];\n var ord =\n (ccc.charCodeAt(0) << 16) |\n ((ccc.length > 1 ? ccc.charCodeAt(1) : 0) << 8) |\n (ccc.length > 2 ? ccc.charCodeAt(2) : 0);\n var chars = [\n b64chars.charAt(ord >>> 18),\n b64chars.charAt((ord >>> 12) & 63),\n padlen >= 2 ? '=' : b64chars.charAt((ord >>> 6) & 63),\n padlen >= 1 ? '=' : b64chars.charAt(ord & 63)\n ];\n return chars.join('');\n};\n\nvar btoa =\n global.btoa ||\n function(b) {\n return b.replace(/[\\s\\S]{1,3}/g, cb_encode);\n };\n","import TimedCallback from './timed_callback';\nimport { Delay, Scheduler, Canceller } from './scheduling';\n\nabstract class Timer {\n protected clear: Canceller;\n protected timer: number | void;\n\n constructor(\n set: Scheduler,\n clear: Canceller,\n delay: Delay,\n callback: TimedCallback\n ) {\n this.clear = clear;\n this.timer = set(() => {\n if (this.timer) {\n this.timer = callback(this.timer);\n }\n }, delay);\n }\n\n /** Returns whether the timer is still running.\n *\n * @return {Boolean}\n */\n isRunning(): boolean {\n return this.timer !== null;\n }\n\n /** Aborts a timer when it's running. */\n ensureAborted() {\n if (this.timer) {\n this.clear(this.timer);\n this.timer = null;\n }\n }\n}\n\nexport default Timer;\n","import Timer from './abstract_timer';\nimport TimedCallback from './timed_callback';\nimport { Delay } from './scheduling';\n\n// We need to bind clear functions this way to avoid exceptions on IE8\nfunction clearTimeout(timer) {\n global.clearTimeout(timer);\n}\nfunction clearInterval(timer) {\n global.clearInterval(timer);\n}\n\n/** Cross-browser compatible one-off timer abstraction.\n *\n * @param {Number} delay\n * @param {Function} callback\n */\nexport class OneOffTimer extends Timer {\n constructor(delay: Delay, callback: TimedCallback) {\n super(setTimeout, clearTimeout, delay, function(timer) {\n callback();\n return null;\n });\n }\n}\n\n/** Cross-browser compatible periodic timer abstraction.\n *\n * @param {Number} delay\n * @param {Function} callback\n */\nexport class PeriodicTimer extends Timer {\n constructor(delay: Delay, callback: TimedCallback) {\n super(setInterval, clearInterval, delay, function(timer) {\n callback();\n return timer;\n });\n }\n}\n","import * as Collections from './utils/collections';\nimport TimedCallback from './utils/timers/timed_callback';\nimport { OneOffTimer, PeriodicTimer } from './utils/timers';\n\nvar Util = {\n now(): number {\n if (Date.now) {\n return Date.now();\n } else {\n return new Date().valueOf();\n }\n },\n\n defer(callback: TimedCallback): OneOffTimer {\n return new OneOffTimer(0, callback);\n },\n\n /** Builds a function that will proxy a method call to its first argument.\n *\n * Allows partial application of arguments, so additional arguments are\n * prepended to the argument list.\n *\n * @param {String} name method name\n * @return {Function} proxy function\n */\n method(name: string, ...args: any[]): Function {\n var boundArguments = Array.prototype.slice.call(arguments, 1);\n return function(object) {\n return object[name].apply(object, boundArguments.concat(arguments));\n };\n }\n};\n\nexport default Util;\n","import base64encode from '../base64';\nimport Util from '../util';\n\n/** Merges multiple objects into the target argument.\n *\n * For properties that are plain Objects, performs a deep-merge. For the\n * rest it just copies the value of the property.\n *\n * To extend prototypes use it as following:\n * Pusher.Util.extend(Target.prototype, Base.prototype)\n *\n * You can also use it to merge objects without altering them:\n * Pusher.Util.extend({}, object1, object2)\n *\n * @param {Object} target\n * @return {Object} the target argument\n */\nexport function extend(target: any, ...sources: any[]): T {\n for (var i = 0; i < sources.length; i++) {\n var extensions = sources[i];\n for (var property in extensions) {\n if (\n extensions[property] &&\n extensions[property].constructor &&\n extensions[property].constructor === Object\n ) {\n target[property] = extend(target[property] || {}, extensions[property]);\n } else {\n target[property] = extensions[property];\n }\n }\n }\n return target;\n}\n\nexport function stringify(): string {\n var m = ['Pusher'];\n for (var i = 0; i < arguments.length; i++) {\n if (typeof arguments[i] === 'string') {\n m.push(arguments[i]);\n } else {\n m.push(safeJSONStringify(arguments[i]));\n }\n }\n return m.join(' : ');\n}\n\nexport function arrayIndexOf(array: any[], item: any): number {\n // MSIE doesn't have array.indexOf\n var nativeIndexOf = Array.prototype.indexOf;\n if (array === null) {\n return -1;\n }\n if (nativeIndexOf && array.indexOf === nativeIndexOf) {\n return array.indexOf(item);\n }\n for (var i = 0, l = array.length; i < l; i++) {\n if (array[i] === item) {\n return i;\n }\n }\n return -1;\n}\n\n/** Applies a function f to all properties of an object.\n *\n * Function f gets 3 arguments passed:\n * - element from the object\n * - key of the element\n * - reference to the object\n *\n * @param {Object} object\n * @param {Function} f\n */\nexport function objectApply(object: any, f: Function) {\n for (var key in object) {\n if (Object.prototype.hasOwnProperty.call(object, key)) {\n f(object[key], key, object);\n }\n }\n}\n\n/** Return a list of objects own proerty keys\n *\n * @param {Object} object\n * @returns {Array}\n */\nexport function keys(object: any): string[] {\n var keys = [];\n objectApply(object, function(_, key) {\n keys.push(key);\n });\n return keys;\n}\n\n/** Return a list of object's own property values\n *\n * @param {Object} object\n * @returns {Array}\n */\nexport function values(object: any): any[] {\n var values = [];\n objectApply(object, function(value) {\n values.push(value);\n });\n return values;\n}\n\n/** Applies a function f to all elements of an array.\n *\n * Function f gets 3 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function apply(array: any[], f: Function, context?: any) {\n for (var i = 0; i < array.length; i++) {\n f.call(context || global, array[i], i, array);\n }\n}\n\n/** Maps all elements of the array and returns the result.\n *\n * Function f gets 4 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n * - reference to the destination array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function map(array: any[], f: Function): any[] {\n var result = [];\n for (var i = 0; i < array.length; i++) {\n result.push(f(array[i], i, array, result));\n }\n return result;\n}\n\n/** Maps all elements of the object and returns the result.\n *\n * Function f gets 4 arguments passed:\n * - element from the object\n * - key of the element\n * - reference to the source object\n * - reference to the destination object\n *\n * @param {Object} object\n * @param {Function} f\n */\nexport function mapObject(object: any, f: Function): any {\n var result = {};\n objectApply(object, function(value, key) {\n result[key] = f(value);\n });\n return result;\n}\n\n/** Filters elements of the array using a test function.\n *\n * Function test gets 4 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n * - reference to the destination array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function filter(array: any[], test: Function): any[] {\n test =\n test ||\n function(value) {\n return !!value;\n };\n\n var result = [];\n for (var i = 0; i < array.length; i++) {\n if (test(array[i], i, array, result)) {\n result.push(array[i]);\n }\n }\n return result;\n}\n\n/** Filters properties of the object using a test function.\n *\n * Function test gets 4 arguments passed:\n * - element from the object\n * - key of the element\n * - reference to the source object\n * - reference to the destination object\n *\n * @param {Object} object\n * @param {Function} f\n */\nexport function filterObject(object: Object, test: Function) {\n var result = {};\n objectApply(object, function(value, key) {\n if ((test && test(value, key, object, result)) || Boolean(value)) {\n result[key] = value;\n }\n });\n return result;\n}\n\n/** Flattens an object into a two-dimensional array.\n *\n * @param {Object} object\n * @return {Array} resulting array of [key, value] pairs\n */\nexport function flatten(object: Object): any[] {\n var result = [];\n objectApply(object, function(value, key) {\n result.push([key, value]);\n });\n return result;\n}\n\n/** Checks whether any element of the array passes the test.\n *\n * Function test gets 3 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function any(array: any[], test: Function): boolean {\n for (var i = 0; i < array.length; i++) {\n if (test(array[i], i, array)) {\n return true;\n }\n }\n return false;\n}\n\n/** Checks whether all elements of the array pass the test.\n *\n * Function test gets 3 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function all(array: any[], test: Function): boolean {\n for (var i = 0; i < array.length; i++) {\n if (!test(array[i], i, array)) {\n return false;\n }\n }\n return true;\n}\n\nexport function encodeParamsObject(data): string {\n return mapObject(data, function(value) {\n if (typeof value === 'object') {\n value = safeJSONStringify(value);\n }\n return encodeURIComponent(base64encode(value.toString()));\n });\n}\n\nexport function buildQueryString(data: any): string {\n var params = filterObject(data, function(value) {\n return value !== undefined;\n });\n\n var query = map(\n flatten(encodeParamsObject(params)),\n Util.method('join', '=')\n ).join('&');\n\n return query;\n}\n\n/**\n * See https://github.com/douglascrockford/JSON-js/blob/master/cycle.js\n *\n * Remove circular references from an object. Required for JSON.stringify in\n * React Native, which tends to blow up a lot.\n *\n * @param {any} object\n * @return {any} Decycled object\n */\nexport function decycleObject(object: any): any {\n var objects = [],\n paths = [];\n\n return (function derez(value, path) {\n var i, name, nu;\n\n switch (typeof value) {\n case 'object':\n if (!value) {\n return null;\n }\n for (i = 0; i < objects.length; i += 1) {\n if (objects[i] === value) {\n return { $ref: paths[i] };\n }\n }\n\n objects.push(value);\n paths.push(path);\n\n if (Object.prototype.toString.apply(value) === '[object Array]') {\n nu = [];\n for (i = 0; i < value.length; i += 1) {\n nu[i] = derez(value[i], path + '[' + i + ']');\n }\n } else {\n nu = {};\n for (name in value) {\n if (Object.prototype.hasOwnProperty.call(value, name)) {\n nu[name] = derez(\n value[name],\n path + '[' + JSON.stringify(name) + ']'\n );\n }\n }\n }\n return nu;\n case 'number':\n case 'string':\n case 'boolean':\n return value;\n }\n })(object, '$');\n}\n\n/**\n * Provides a cross-browser and cross-platform way to safely stringify objects\n * into JSON. This is particularly necessary for ReactNative, where circular JSON\n * structures throw an exception.\n *\n * @param {any} source The object to stringify\n * @return {string} The serialized output.\n */\nexport function safeJSONStringify(source: any): string {\n try {\n return JSON.stringify(source);\n } catch (e) {\n return JSON.stringify(decycleObject(source));\n }\n}\n","import {\n ChannelAuthorizationOptions,\n UserAuthenticationOptions\n} from './auth/options';\nimport { AuthTransport } from './config';\n\nexport interface DefaultConfig {\n VERSION: string;\n PROTOCOL: number;\n wsPort: number;\n wssPort: number;\n wsPath: string;\n httpHost: string;\n httpPort: number;\n httpsPort: number;\n httpPath: string;\n stats_host: string;\n authEndpoint: string;\n authTransport: AuthTransport;\n activityTimeout: number;\n pongTimeout: number;\n unavailableTimeout: number;\n userAuthentication: UserAuthenticationOptions;\n channelAuthorization: ChannelAuthorizationOptions;\n\n cdn_http?: string;\n cdn_https?: string;\n dependency_suffix?: string;\n}\n\nvar Defaults: DefaultConfig = {\n VERSION: VERSION,\n PROTOCOL: 7,\n\n wsPort: 80,\n wssPort: 443,\n wsPath: '',\n // DEPRECATED: SockJS fallback parameters\n httpHost: 'sockjs.pusher.com',\n httpPort: 80,\n httpsPort: 443,\n httpPath: '/pusher',\n // DEPRECATED: Stats\n stats_host: 'stats.pusher.com',\n // DEPRECATED: Other settings\n authEndpoint: '/pusher/auth',\n authTransport: 'ajax',\n activityTimeout: 120000,\n pongTimeout: 30000,\n unavailableTimeout: 10000,\n userAuthentication: {\n endpoint: '/pusher/user-auth',\n transport: 'ajax'\n },\n channelAuthorization: {\n endpoint: '/pusher/auth',\n transport: 'ajax'\n },\n\n // CDN configuration\n cdn_http: CDN_HTTP,\n cdn_https: CDN_HTTPS,\n dependency_suffix: DEPENDENCY_SUFFIX\n};\n\nexport default Defaults;\n","import Defaults from '../defaults';\nimport { default as URLScheme, URLSchemeParams } from './url_scheme';\n\nfunction getGenericURL(\n baseScheme: string,\n params: URLSchemeParams,\n path: string\n): string {\n var scheme = baseScheme + (params.useTLS ? 's' : '');\n var host = params.useTLS ? params.hostTLS : params.hostNonTLS;\n return scheme + '://' + host + path;\n}\n\nfunction getGenericPath(key: string, queryString?: string): string {\n var path = '/app/' + key;\n var query =\n '?protocol=' +\n Defaults.PROTOCOL +\n '&client=js' +\n '&version=' +\n Defaults.VERSION +\n (queryString ? '&' + queryString : '');\n return path + query;\n}\n\nexport var ws: URLScheme = {\n getInitial: function(key: string, params: URLSchemeParams): string {\n var path = (params.httpPath || '') + getGenericPath(key, 'flash=false');\n return getGenericURL('ws', params, path);\n }\n};\n\nexport var http: URLScheme = {\n getInitial: function(key: string, params: URLSchemeParams): string {\n var path = (params.httpPath || '/pusher') + getGenericPath(key);\n return getGenericURL('http', params, path);\n }\n};\n\nexport var sockjs: URLScheme = {\n getInitial: function(key: string, params: URLSchemeParams): string {\n return getGenericURL('http', params, params.httpPath || '/pusher');\n },\n getPath: function(key: string, params: URLSchemeParams): string {\n return getGenericPath(key);\n }\n};\n","import Callback from './callback';\nimport * as Collections from '../utils/collections';\nimport CallbackTable from './callback_table';\n\nexport default class CallbackRegistry {\n _callbacks: CallbackTable;\n\n constructor() {\n this._callbacks = {};\n }\n\n get(name: string): Callback[] {\n return this._callbacks[prefix(name)];\n }\n\n add(name: string, callback: Function, context: any) {\n var prefixedEventName = prefix(name);\n this._callbacks[prefixedEventName] =\n this._callbacks[prefixedEventName] || [];\n this._callbacks[prefixedEventName].push({\n fn: callback,\n context: context\n });\n }\n\n remove(name?: string, callback?: Function, context?: any) {\n if (!name && !callback && !context) {\n this._callbacks = {};\n return;\n }\n\n var names = name ? [prefix(name)] : Collections.keys(this._callbacks);\n\n if (callback || context) {\n this.removeCallback(names, callback, context);\n } else {\n this.removeAllCallbacks(names);\n }\n }\n\n private removeCallback(names: string[], callback: Function, context: any) {\n Collections.apply(\n names,\n function(name) {\n this._callbacks[name] = Collections.filter(\n this._callbacks[name] || [],\n function(binding) {\n return (\n (callback && callback !== binding.fn) ||\n (context && context !== binding.context)\n );\n }\n );\n if (this._callbacks[name].length === 0) {\n delete this._callbacks[name];\n }\n },\n this\n );\n }\n\n private removeAllCallbacks(names: string[]) {\n Collections.apply(\n names,\n function(name) {\n delete this._callbacks[name];\n },\n this\n );\n }\n}\n\nfunction prefix(name: string): string {\n return '_' + name;\n}\n","import * as Collections from '../utils/collections';\nimport Callback from './callback';\nimport Metadata from '../channels/metadata';\nimport CallbackRegistry from './callback_registry';\n\n/** Manages callback bindings and event emitting.\n *\n * @param Function failThrough called when no listeners are bound to an event\n */\nexport default class Dispatcher {\n callbacks: CallbackRegistry;\n global_callbacks: Function[];\n failThrough: Function;\n\n constructor(failThrough?: Function) {\n this.callbacks = new CallbackRegistry();\n this.global_callbacks = [];\n this.failThrough = failThrough;\n }\n\n bind(eventName: string, callback: Function, context?: any) {\n this.callbacks.add(eventName, callback, context);\n return this;\n }\n\n bind_global(callback: Function) {\n this.global_callbacks.push(callback);\n return this;\n }\n\n unbind(eventName?: string, callback?: Function, context?: any) {\n this.callbacks.remove(eventName, callback, context);\n return this;\n }\n\n unbind_global(callback?: Function) {\n if (!callback) {\n this.global_callbacks = [];\n return this;\n }\n\n this.global_callbacks = Collections.filter(\n this.global_callbacks || [],\n c => c !== callback\n );\n\n return this;\n }\n\n unbind_all() {\n this.unbind();\n this.unbind_global();\n return this;\n }\n\n emit(eventName: string, data?: any, metadata?: Metadata): Dispatcher {\n for (var i = 0; i < this.global_callbacks.length; i++) {\n this.global_callbacks[i](eventName, data);\n }\n\n var callbacks = this.callbacks.get(eventName);\n var args = [];\n\n if (metadata) {\n // if there's a metadata argument, we need to call the callback with both\n // data and metadata regardless of whether data is undefined\n args.push(data, metadata);\n } else if (data) {\n // metadata is undefined, so we only need to call the callback with data\n // if data exists\n args.push(data);\n }\n\n if (callbacks && callbacks.length > 0) {\n for (var i = 0; i < callbacks.length; i++) {\n callbacks[i].fn.apply(callbacks[i].context || global, args);\n }\n } else if (this.failThrough) {\n this.failThrough(eventName, data);\n }\n\n return this;\n }\n}\n","import { stringify } from './utils/collections';\nimport Pusher from './pusher';\n\nclass Logger {\n debug(...args: any[]) {\n this.log(this.globalLog, args);\n }\n\n warn(...args: any[]) {\n this.log(this.globalLogWarn, args);\n }\n\n error(...args: any[]) {\n this.log(this.globalLogError, args);\n }\n\n private globalLog = (message: string) => {\n if (global.console && global.console.log) {\n global.console.log(message);\n }\n };\n\n private globalLogWarn(message: string) {\n if (global.console && global.console.warn) {\n global.console.warn(message);\n } else {\n this.globalLog(message);\n }\n }\n\n private globalLogError(message: string) {\n if (global.console && global.console.error) {\n global.console.error(message);\n } else {\n this.globalLogWarn(message);\n }\n }\n\n private log(\n defaultLoggingFunction: (message: string) => void,\n ...args: any[]\n ) {\n var message = stringify.apply(this, arguments);\n if (Pusher.log) {\n Pusher.log(message);\n } else if (Pusher.logToConsole) {\n const log = defaultLoggingFunction.bind(this);\n log(message);\n }\n }\n}\n\nexport default new Logger();\n","import Util from '../util';\nimport * as Collections from '../utils/collections';\nimport { default as EventsDispatcher } from '../events/dispatcher';\nimport Logger from '../logger';\nimport TransportHooks from './transport_hooks';\nimport Socket from '../socket';\nimport Runtime from 'runtime';\nimport Timeline from '../timeline/timeline';\nimport TransportConnectionOptions from './transport_connection_options';\n\n/** Provides universal API for transport connections.\n *\n * Transport connection is a low-level object that wraps a connection method\n * and exposes a simple evented interface for the connection state and\n * messaging. It does not implement Pusher-specific WebSocket protocol.\n *\n * Additionally, it fetches resources needed for transport to work and exposes\n * an interface for querying transport features.\n *\n * States:\n * - new - initial state after constructing the object\n * - initializing - during initialization phase, usually fetching resources\n * - intialized - ready to establish a connection\n * - connection - when connection is being established\n * - open - when connection ready to be used\n * - closed - after connection was closed be either side\n *\n * Emits:\n * - error - after the connection raised an error\n *\n * Options:\n * - useTLS - whether connection should be over TLS\n * - hostTLS - host to connect to when connection is over TLS\n * - hostNonTLS - host to connect to when connection is over TLS\n *\n * @param {String} key application key\n * @param {Object} options\n */\nexport default class TransportConnection extends EventsDispatcher {\n hooks: TransportHooks;\n name: string;\n priority: number;\n key: string;\n options: TransportConnectionOptions;\n state: string;\n timeline: Timeline;\n activityTimeout: number;\n id: number;\n socket: Socket;\n beforeOpen: Function;\n initialize: Function;\n\n constructor(\n hooks: TransportHooks,\n name: string,\n priority: number,\n key: string,\n options: TransportConnectionOptions\n ) {\n super();\n this.initialize = Runtime.transportConnectionInitializer;\n this.hooks = hooks;\n this.name = name;\n this.priority = priority;\n this.key = key;\n this.options = options;\n\n this.state = 'new';\n this.timeline = options.timeline;\n this.activityTimeout = options.activityTimeout;\n this.id = this.timeline.generateUniqueID();\n }\n\n /** Checks whether the transport handles activity checks by itself.\n *\n * @return {Boolean}\n */\n handlesActivityChecks(): boolean {\n return Boolean(this.hooks.handlesActivityChecks);\n }\n\n /** Checks whether the transport supports the ping/pong API.\n *\n * @return {Boolean}\n */\n supportsPing(): boolean {\n return Boolean(this.hooks.supportsPing);\n }\n\n /** Tries to establish a connection.\n *\n * @returns {Boolean} false if transport is in invalid state\n */\n connect(): boolean {\n if (this.socket || this.state !== 'initialized') {\n return false;\n }\n\n var url = this.hooks.urls.getInitial(this.key, this.options);\n try {\n this.socket = this.hooks.getSocket(url, this.options);\n } catch (e) {\n Util.defer(() => {\n this.onError(e);\n this.changeState('closed');\n });\n return false;\n }\n\n this.bindListeners();\n\n Logger.debug('Connecting', { transport: this.name, url });\n this.changeState('connecting');\n return true;\n }\n\n /** Closes the connection.\n *\n * @return {Boolean} true if there was a connection to close\n */\n close(): boolean {\n if (this.socket) {\n this.socket.close();\n return true;\n } else {\n return false;\n }\n }\n\n /** Sends data over the open connection.\n *\n * @param {String} data\n * @return {Boolean} true only when in the \"open\" state\n */\n send(data: any): boolean {\n if (this.state === 'open') {\n // Workaround for MobileSafari bug (see https://gist.github.com/2052006)\n Util.defer(() => {\n if (this.socket) {\n this.socket.send(data);\n }\n });\n return true;\n } else {\n return false;\n }\n }\n\n /** Sends a ping if the connection is open and transport supports it. */\n ping() {\n if (this.state === 'open' && this.supportsPing()) {\n this.socket.ping();\n }\n }\n\n private onOpen() {\n if (this.hooks.beforeOpen) {\n this.hooks.beforeOpen(\n this.socket,\n this.hooks.urls.getPath(this.key, this.options)\n );\n }\n this.changeState('open');\n this.socket.onopen = undefined;\n }\n\n private onError(error) {\n this.emit('error', { type: 'WebSocketError', error: error });\n this.timeline.error(this.buildTimelineMessage({ error: error.toString() }));\n }\n\n private onClose(closeEvent?: any) {\n if (closeEvent) {\n this.changeState('closed', {\n code: closeEvent.code,\n reason: closeEvent.reason,\n wasClean: closeEvent.wasClean\n });\n } else {\n this.changeState('closed');\n }\n this.unbindListeners();\n this.socket = undefined;\n }\n\n private onMessage(message) {\n this.emit('message', message);\n }\n\n private onActivity() {\n this.emit('activity');\n }\n\n private bindListeners() {\n this.socket.onopen = () => {\n this.onOpen();\n };\n this.socket.onerror = error => {\n this.onError(error);\n };\n this.socket.onclose = closeEvent => {\n this.onClose(closeEvent);\n };\n this.socket.onmessage = message => {\n this.onMessage(message);\n };\n\n if (this.supportsPing()) {\n this.socket.onactivity = () => {\n this.onActivity();\n };\n }\n }\n\n private unbindListeners() {\n if (this.socket) {\n this.socket.onopen = undefined;\n this.socket.onerror = undefined;\n this.socket.onclose = undefined;\n this.socket.onmessage = undefined;\n if (this.supportsPing()) {\n this.socket.onactivity = undefined;\n }\n }\n }\n\n private changeState(state: string, params?: any) {\n this.state = state;\n this.timeline.info(\n this.buildTimelineMessage({\n state: state,\n params: params\n })\n );\n this.emit(state, params);\n }\n\n buildTimelineMessage(message): any {\n return Collections.extend({ cid: this.id }, message);\n }\n}\n","import Factory from '../utils/factory';\nimport TransportHooks from './transport_hooks';\nimport TransportConnection from './transport_connection';\nimport TransportConnectionOptions from './transport_connection_options';\n\n/** Provides interface for transport connection instantiation.\n *\n * Takes transport-specific hooks as the only argument, which allow checking\n * for transport support and creating its connections.\n *\n * Supported hooks: * - file - the name of the file to be fetched during initialization\n * - urls - URL scheme to be used by transport\n * - handlesActivityCheck - true when the transport handles activity checks\n * - supportsPing - true when the transport has a ping/activity API\n * - isSupported - tells whether the transport is supported in the environment\n * - getSocket - creates a WebSocket-compatible transport socket\n *\n * See transports.js for specific implementations.\n *\n * @param {Object} hooks object containing all needed transport hooks\n */\nexport default class Transport {\n hooks: TransportHooks;\n\n constructor(hooks: TransportHooks) {\n this.hooks = hooks;\n }\n\n /** Returns whether the transport is supported in the environment.\n *\n * @param {Object} envronment te environment details (encryption, settings)\n * @returns {Boolean} true when the transport is supported\n */\n isSupported(environment: any): boolean {\n return this.hooks.isSupported(environment);\n }\n\n /** Creates a transport connection.\n *\n * @param {String} name\n * @param {Number} priority\n * @param {String} key the application key\n * @param {Object} options\n * @returns {TransportConnection}\n */\n createConnection(\n name: string,\n priority: number,\n key: string,\n options: any\n ): TransportConnection {\n return new TransportConnection(this.hooks, name, priority, key, options);\n }\n}\n","import * as URLSchemes from 'core/transports/url_schemes';\nimport URLScheme from 'core/transports/url_scheme';\nimport Transport from 'core/transports/transport';\nimport Util from 'core/util';\nimport * as Collections from 'core/utils/collections';\nimport TransportHooks from 'core/transports/transport_hooks';\nimport TransportsTable from 'core/transports/transports_table';\nimport Runtime from 'runtime';\n\n/** WebSocket transport.\n *\n * Uses native WebSocket implementation, including MozWebSocket supported by\n * earlier Firefox versions.\n */\nvar WSTransport = new Transport({\n urls: URLSchemes.ws,\n handlesActivityChecks: false,\n supportsPing: false,\n\n isInitialized: function() {\n return Boolean(Runtime.getWebSocketAPI());\n },\n isSupported: function(): boolean {\n return Boolean(Runtime.getWebSocketAPI());\n },\n getSocket: function(url) {\n return Runtime.createWebSocket(url);\n }\n});\n\nvar httpConfiguration = {\n urls: URLSchemes.http,\n handlesActivityChecks: false,\n supportsPing: true,\n isInitialized: function() {\n return true;\n }\n};\n\nexport var streamingConfiguration = Collections.extend(\n {\n getSocket: function(url) {\n return Runtime.HTTPFactory.createStreamingSocket(url);\n }\n },\n httpConfiguration\n);\nexport var pollingConfiguration = Collections.extend(\n {\n getSocket: function(url) {\n return Runtime.HTTPFactory.createPollingSocket(url);\n }\n },\n httpConfiguration\n);\n\nvar xhrConfiguration = {\n isSupported: function(): boolean {\n return Runtime.isXHRSupported();\n }\n};\n\n/** HTTP streaming transport using CORS-enabled XMLHttpRequest. */\nvar XHRStreamingTransport = new Transport(\n (\n Collections.extend({}, streamingConfiguration, xhrConfiguration)\n )\n);\n\n/** HTTP long-polling transport using CORS-enabled XMLHttpRequest. */\nvar XHRPollingTransport = new Transport(\n Collections.extend({}, pollingConfiguration, xhrConfiguration)\n);\n\nvar Transports: TransportsTable = {\n ws: WSTransport,\n xhr_streaming: XHRStreamingTransport,\n xhr_polling: XHRPollingTransport\n};\n\nexport default Transports;\n","import Util from '../util';\nimport * as Collections from '../utils/collections';\nimport TransportManager from './transport_manager';\nimport TransportConnection from './transport_connection';\nimport Transport from './transport';\nimport PingDelayOptions from './ping_delay_options';\n\n/** Creates transport connections monitored by a transport manager.\n *\n * When a transport is closed, it might mean the environment does not support\n * it. It's possible that messages get stuck in an intermediate buffer or\n * proxies terminate inactive connections. To combat these problems,\n * assistants monitor the connection lifetime, report unclean exits and\n * adjust ping timeouts to keep the connection active. The decision to disable\n * a transport is the manager's responsibility.\n *\n * @param {TransportManager} manager\n * @param {TransportConnection} transport\n * @param {Object} options\n */\nexport default class AssistantToTheTransportManager {\n manager: TransportManager;\n transport: Transport;\n minPingDelay: number;\n maxPingDelay: number;\n pingDelay: number;\n\n constructor(\n manager: TransportManager,\n transport: Transport,\n options: PingDelayOptions\n ) {\n this.manager = manager;\n this.transport = transport;\n this.minPingDelay = options.minPingDelay;\n this.maxPingDelay = options.maxPingDelay;\n this.pingDelay = undefined;\n }\n\n /** Creates a transport connection.\n *\n * This function has the same API as Transport#createConnection.\n *\n * @param {String} name\n * @param {Number} priority\n * @param {String} key the application key\n * @param {Object} options\n * @returns {TransportConnection}\n */\n createConnection(\n name: string,\n priority: number,\n key: string,\n options: Object\n ): TransportConnection {\n options = Collections.extend({}, options, {\n activityTimeout: this.pingDelay\n });\n var connection = this.transport.createConnection(\n name,\n priority,\n key,\n options\n );\n\n var openTimestamp = null;\n\n var onOpen = function() {\n connection.unbind('open', onOpen);\n connection.bind('closed', onClosed);\n openTimestamp = Util.now();\n };\n var onClosed = closeEvent => {\n connection.unbind('closed', onClosed);\n\n if (closeEvent.code === 1002 || closeEvent.code === 1003) {\n // we don't want to use transports not obeying the protocol\n this.manager.reportDeath();\n } else if (!closeEvent.wasClean && openTimestamp) {\n // report deaths only for short-living transport\n var lifespan = Util.now() - openTimestamp;\n if (lifespan < 2 * this.maxPingDelay) {\n this.manager.reportDeath();\n this.pingDelay = Math.max(lifespan / 2, this.minPingDelay);\n }\n }\n };\n\n connection.bind('open', onOpen);\n return connection;\n }\n\n /** Returns whether the transport is supported in the environment.\n *\n * This function has the same API as Transport#isSupported. Might return false\n * when the manager decides to kill the transport.\n *\n * @param {Object} environment the environment details (encryption, settings)\n * @returns {Boolean} true when the transport is supported\n */\n isSupported(environment: string): boolean {\n return this.manager.isAlive() && this.transport.isSupported(environment);\n }\n}\n","import Action from './action';\nimport { PusherEvent } from './message-types';\n/**\n * Provides functions for handling Pusher protocol-specific messages.\n */\n\nconst Protocol = {\n /**\n * Decodes a message in a Pusher format.\n *\n * The MessageEvent we receive from the transport should contain a pusher event\n * (https://pusher.com/docs/pusher_protocol#events) serialized as JSON in the\n * data field\n *\n * The pusher event may contain a data field too, and it may also be\n * serialised as JSON\n *\n * Throws errors when messages are not parse'able.\n *\n * @param {MessageEvent} messageEvent\n * @return {PusherEvent}\n */\n decodeMessage: function(messageEvent: MessageEvent): PusherEvent {\n try {\n var messageData = JSON.parse(messageEvent.data);\n var pusherEventData = messageData.data;\n if (typeof pusherEventData === 'string') {\n try {\n pusherEventData = JSON.parse(messageData.data);\n } catch (e) {}\n }\n var pusherEvent: PusherEvent = {\n event: messageData.event,\n channel: messageData.channel,\n data: pusherEventData\n };\n if (messageData.user_id) {\n pusherEvent.user_id = messageData.user_id;\n }\n return pusherEvent;\n } catch (e) {\n throw { type: 'MessageParseError', error: e, data: messageEvent.data };\n }\n },\n\n /**\n * Encodes a message to be sent.\n *\n * @param {PusherEvent} event\n * @return {String}\n */\n encodeMessage: function(event: PusherEvent): string {\n return JSON.stringify(event);\n },\n\n /**\n * Processes a handshake message and returns appropriate actions.\n *\n * Returns an object with an 'action' and other action-specific properties.\n *\n * There are three outcomes when calling this function. First is a successful\n * connection attempt, when pusher:connection_established is received, which\n * results in a 'connected' action with an 'id' property. When passed a\n * pusher:error event, it returns a result with action appropriate to the\n * close code and an error. Otherwise, it raises an exception.\n *\n * @param {String} message\n * @result Object\n */\n processHandshake: function(messageEvent: MessageEvent): Action {\n var message = Protocol.decodeMessage(messageEvent);\n\n if (message.event === 'pusher:connection_established') {\n if (!message.data.activity_timeout) {\n throw 'No activity timeout specified in handshake';\n }\n return {\n action: 'connected',\n id: message.data.socket_id,\n activityTimeout: message.data.activity_timeout * 1000\n };\n } else if (message.event === 'pusher:error') {\n // From protocol 6 close codes are sent only once, so this only\n // happens when connection does not support close codes\n return {\n action: this.getCloseAction(message.data),\n error: this.getCloseError(message.data)\n };\n } else {\n throw 'Invalid handshake';\n }\n },\n\n /**\n * Dispatches the close event and returns an appropriate action name.\n *\n * See:\n * 1. https://developer.mozilla.org/en-US/docs/WebSockets/WebSockets_reference/CloseEvent\n * 2. http://pusher.com/docs/pusher_protocol\n *\n * @param {CloseEvent} closeEvent\n * @return {String} close action name\n */\n getCloseAction: function(closeEvent): string {\n if (closeEvent.code < 4000) {\n // ignore 1000 CLOSE_NORMAL, 1001 CLOSE_GOING_AWAY,\n // 1005 CLOSE_NO_STATUS, 1006 CLOSE_ABNORMAL\n // ignore 1007...3999\n // handle 1002 CLOSE_PROTOCOL_ERROR, 1003 CLOSE_UNSUPPORTED,\n // 1004 CLOSE_TOO_LARGE\n if (closeEvent.code >= 1002 && closeEvent.code <= 1004) {\n return 'backoff';\n } else {\n return null;\n }\n } else if (closeEvent.code === 4000) {\n return 'tls_only';\n } else if (closeEvent.code < 4100) {\n return 'refused';\n } else if (closeEvent.code < 4200) {\n return 'backoff';\n } else if (closeEvent.code < 4300) {\n return 'retry';\n } else {\n // unknown error\n return 'refused';\n }\n },\n\n /**\n * Returns an error or null basing on the close event.\n *\n * Null is returned when connection was closed cleanly. Otherwise, an object\n * with error details is returned.\n *\n * @param {CloseEvent} closeEvent\n * @return {Object} error object\n */\n getCloseError: function(closeEvent): any {\n if (closeEvent.code !== 1000 && closeEvent.code !== 1001) {\n return {\n type: 'PusherError',\n data: {\n code: closeEvent.code,\n message: closeEvent.reason || closeEvent.message\n }\n };\n } else {\n return null;\n }\n }\n};\n\nexport default Protocol;\n","import * as Collections from '../utils/collections';\nimport { default as EventsDispatcher } from '../events/dispatcher';\nimport Protocol from './protocol/protocol';\nimport { PusherEvent } from './protocol/message-types';\nimport Logger from '../logger';\nimport TransportConnection from '../transports/transport_connection';\nimport Socket from '../socket';\n/**\n * Provides Pusher protocol interface for transports.\n *\n * Emits following events:\n * - message - on received messages\n * - ping - on ping requests\n * - pong - on pong responses\n * - error - when the transport emits an error\n * - closed - after closing the transport\n *\n * It also emits more events when connection closes with a code.\n * See Protocol.getCloseAction to get more details.\n *\n * @param {Number} id\n * @param {AbstractTransport} transport\n */\nexport default class Connection extends EventsDispatcher implements Socket {\n id: string;\n transport: TransportConnection;\n activityTimeout: number;\n\n constructor(id: string, transport: TransportConnection) {\n super();\n this.id = id;\n this.transport = transport;\n this.activityTimeout = transport.activityTimeout;\n this.bindListeners();\n }\n\n /** Returns whether used transport handles activity checks by itself\n *\n * @returns {Boolean} true if activity checks are handled by the transport\n */\n handlesActivityChecks() {\n return this.transport.handlesActivityChecks();\n }\n\n /** Sends raw data.\n *\n * @param {String} data\n */\n send(data: any): boolean {\n return this.transport.send(data);\n }\n\n /** Sends an event.\n *\n * @param {String} name\n * @param {String} data\n * @param {String} [channel]\n * @returns {Boolean} whether message was sent or not\n */\n send_event(name: string, data: any, channel?: string): boolean {\n var event: PusherEvent = { event: name, data: data };\n if (channel) {\n event.channel = channel;\n }\n Logger.debug('Event sent', event);\n return this.send(Protocol.encodeMessage(event));\n }\n\n /** Sends a ping message to the server.\n *\n * Basing on the underlying transport, it might send either transport's\n * protocol-specific ping or pusher:ping event.\n */\n ping() {\n if (this.transport.supportsPing()) {\n this.transport.ping();\n } else {\n this.send_event('pusher:ping', {});\n }\n }\n\n /** Closes the connection. */\n close() {\n this.transport.close();\n }\n\n private bindListeners() {\n var listeners = {\n message: (messageEvent: MessageEvent) => {\n var pusherEvent;\n try {\n pusherEvent = Protocol.decodeMessage(messageEvent);\n } catch (e) {\n this.emit('error', {\n type: 'MessageParseError',\n error: e,\n data: messageEvent.data\n });\n }\n\n if (pusherEvent !== undefined) {\n Logger.debug('Event recd', pusherEvent);\n\n switch (pusherEvent.event) {\n case 'pusher:error':\n this.emit('error', {\n type: 'PusherError',\n data: pusherEvent.data\n });\n break;\n case 'pusher:ping':\n this.emit('ping');\n break;\n case 'pusher:pong':\n this.emit('pong');\n break;\n }\n this.emit('message', pusherEvent);\n }\n },\n activity: () => {\n this.emit('activity');\n },\n error: error => {\n this.emit('error', error);\n },\n closed: closeEvent => {\n unbindListeners();\n\n if (closeEvent && closeEvent.code) {\n this.handleCloseEvent(closeEvent);\n }\n\n this.transport = null;\n this.emit('closed');\n }\n };\n\n var unbindListeners = () => {\n Collections.objectApply(listeners, (listener, event) => {\n this.transport.unbind(event, listener);\n });\n };\n\n Collections.objectApply(listeners, (listener, event) => {\n this.transport.bind(event, listener);\n });\n }\n\n private handleCloseEvent(closeEvent: any) {\n var action = Protocol.getCloseAction(closeEvent);\n var error = Protocol.getCloseError(closeEvent);\n if (error) {\n this.emit('error', error);\n }\n if (action) {\n this.emit(action, { action: action, error: error });\n }\n }\n}\n","import Util from '../../util';\nimport * as Collections from '../../utils/collections';\nimport Protocol from '../protocol/protocol';\nimport Connection from '../connection';\nimport TransportConnection from '../../transports/transport_connection';\nimport HandshakePayload from './handshake_payload';\n\n/**\n * Handles Pusher protocol handshakes for transports.\n *\n * Calls back with a result object after handshake is completed. Results\n * always have two fields:\n * - action - string describing action to be taken after the handshake\n * - transport - the transport object passed to the constructor\n *\n * Different actions can set different additional properties on the result.\n * In the case of 'connected' action, there will be a 'connection' property\n * containing a Connection object for the transport. Other actions should\n * carry an 'error' property.\n *\n * @param {AbstractTransport} transport\n * @param {Function} callback\n */\nexport default class Handshake {\n transport: TransportConnection;\n callback: (HandshakePayload) => void;\n onMessage: Function;\n onClosed: Function;\n\n constructor(\n transport: TransportConnection,\n callback: (HandshakePayload) => void\n ) {\n this.transport = transport;\n this.callback = callback;\n this.bindListeners();\n }\n\n close() {\n this.unbindListeners();\n this.transport.close();\n }\n\n private bindListeners() {\n this.onMessage = m => {\n this.unbindListeners();\n\n var result;\n try {\n result = Protocol.processHandshake(m);\n } catch (e) {\n this.finish('error', { error: e });\n this.transport.close();\n return;\n }\n\n if (result.action === 'connected') {\n this.finish('connected', {\n connection: new Connection(result.id, this.transport),\n activityTimeout: result.activityTimeout\n });\n } else {\n this.finish(result.action, { error: result.error });\n this.transport.close();\n }\n };\n\n this.onClosed = closeEvent => {\n this.unbindListeners();\n\n var action = Protocol.getCloseAction(closeEvent) || 'backoff';\n var error = Protocol.getCloseError(closeEvent);\n this.finish(action, { error: error });\n };\n\n this.transport.bind('message', this.onMessage);\n this.transport.bind('closed', this.onClosed);\n }\n\n private unbindListeners() {\n this.transport.unbind('message', this.onMessage);\n this.transport.unbind('closed', this.onClosed);\n }\n\n private finish(action: string, params: any) {\n this.callback(\n Collections.extend({ transport: this.transport, action: action }, params)\n );\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport base64encode from '../base64';\nimport Timeline from './timeline';\nimport Runtime from 'runtime';\n\nexport interface TimelineSenderOptions {\n host?: string;\n port?: number;\n path?: string;\n}\n\nexport default class TimelineSender {\n timeline: Timeline;\n options: TimelineSenderOptions;\n host: string;\n\n constructor(timeline: Timeline, options: TimelineSenderOptions) {\n this.timeline = timeline;\n this.options = options || {};\n }\n\n send(useTLS: boolean, callback?: Function) {\n if (this.timeline.isEmpty()) {\n return;\n }\n\n this.timeline.send(\n Runtime.TimelineTransport.getAgent(this, useTLS),\n callback\n );\n }\n}\n","/** Error classes used throughout the library. */\n// https://github.com/Microsoft/TypeScript-wiki/blob/master/Breaking-Changes.md#extending-built-ins-like-error-array-and-map-may-no-longer-work\nexport class BadEventName extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\nexport class BadChannelName extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\nexport class RequestTimedOut extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class TransportPriorityTooLow extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class TransportClosed extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class UnsupportedFeature extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class UnsupportedTransport extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class UnsupportedStrategy extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class HTTPAuthError extends Error {\n status: number;\n constructor(status: number, msg?: string) {\n super(msg);\n this.status = status;\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n","/**\n * A place to store help URLs for error messages etc\n */\n\nconst urlStore = {\n baseUrl: 'https://pusher.com',\n urls: {\n authenticationEndpoint: {\n path: '/docs/channels/server_api/authenticating_users'\n },\n authorizationEndpoint: {\n path: '/docs/channels/server_api/authorizing-users/'\n },\n javascriptQuickStart: {\n path: '/docs/javascript_quick_start'\n },\n triggeringClientEvents: {\n path: '/docs/client_api_guide/client_events#trigger-events'\n },\n encryptedChannelSupport: {\n fullUrl:\n 'https://github.com/pusher/pusher-js/tree/cc491015371a4bde5743d1c87a0fbac0feb53195#encrypted-channel-support'\n }\n }\n};\n\n/** Builds a consistent string with links to pusher documentation\n *\n * @param {string} key - relevant key in the url_store.urls object\n * @return {string} suffix string to append to log message\n */\nconst buildLogSuffix = function(key: string): string {\n const urlPrefix = 'See:';\n const urlObj = urlStore.urls[key];\n if (!urlObj) return '';\n\n let url;\n if (urlObj.fullUrl) {\n url = urlObj.fullUrl;\n } else if (urlObj.path) {\n url = urlStore.baseUrl + urlObj.path;\n }\n\n if (!url) return '';\n return `${urlPrefix} ${url}`;\n};\n\nexport default { buildLogSuffix };\n","import { default as EventsDispatcher } from '../events/dispatcher';\nimport * as Errors from '../errors';\nimport Logger from '../logger';\nimport Pusher from '../pusher';\nimport { PusherEvent } from '../connection/protocol/message-types';\nimport Metadata from './metadata';\nimport UrlStore from '../utils/url_store';\nimport {\n ChannelAuthorizationData,\n ChannelAuthorizationCallback\n} from '../auth/options';\nimport { HTTPAuthError } from '../errors';\n\n/** Provides base public channel interface with an event emitter.\n *\n * Emits:\n * - pusher:subscription_succeeded - after subscribing successfully\n * - other non-internal events\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\nexport default class Channel extends EventsDispatcher {\n name: string;\n pusher: Pusher;\n subscribed: boolean;\n subscriptionPending: boolean;\n subscriptionCancelled: boolean;\n subscriptionCount: null;\n\n constructor(name: string, pusher: Pusher) {\n super(function(event, data) {\n Logger.debug('No callbacks on ' + name + ' for ' + event);\n });\n\n this.name = name;\n this.pusher = pusher;\n this.subscribed = false;\n this.subscriptionPending = false;\n this.subscriptionCancelled = false;\n }\n\n /** Skips authorization, since public channels don't require it.\n *\n * @param {Function} callback\n */\n authorize(socketId: string, callback: ChannelAuthorizationCallback) {\n return callback(null, { auth: '' });\n }\n\n /** Triggers an event */\n trigger(event: string, data: any) {\n if (event.indexOf('client-') !== 0) {\n throw new Errors.BadEventName(\n \"Event '\" + event + \"' does not start with 'client-'\"\n );\n }\n if (!this.subscribed) {\n var suffix = UrlStore.buildLogSuffix('triggeringClientEvents');\n Logger.warn(\n `Client event triggered before channel 'subscription_succeeded' event . ${suffix}`\n );\n }\n return this.pusher.send_event(event, data, this.name);\n }\n\n /** Signals disconnection to the channel. For internal use only. */\n disconnect() {\n this.subscribed = false;\n this.subscriptionPending = false;\n }\n\n /** Handles a PusherEvent. For internal use only.\n *\n * @param {PusherEvent} event\n */\n handleEvent(event: PusherEvent) {\n var eventName = event.event;\n var data = event.data;\n if (eventName === 'pusher_internal:subscription_succeeded') {\n this.handleSubscriptionSucceededEvent(event);\n } else if (eventName === 'pusher_internal:subscription_count') {\n this.handleSubscriptionCountEvent(event);\n } else if (eventName.indexOf('pusher_internal:') !== 0) {\n var metadata: Metadata = {};\n this.emit(eventName, data, metadata);\n }\n }\n\n handleSubscriptionSucceededEvent(event: PusherEvent) {\n this.subscriptionPending = false;\n this.subscribed = true;\n if (this.subscriptionCancelled) {\n this.pusher.unsubscribe(this.name);\n } else {\n this.emit('pusher:subscription_succeeded', event.data);\n }\n }\n\n handleSubscriptionCountEvent(event: PusherEvent) {\n if (event.data.subscription_count) {\n this.subscriptionCount = event.data.subscription_count;\n }\n\n this.emit('pusher:subscription_count', event.data);\n }\n\n /** Sends a subscription request. For internal use only. */\n subscribe() {\n if (this.subscribed) {\n return;\n }\n this.subscriptionPending = true;\n this.subscriptionCancelled = false;\n this.authorize(\n this.pusher.connection.socket_id,\n (error: Error | null, data: ChannelAuthorizationData) => {\n if (error) {\n this.subscriptionPending = false;\n // Why not bind to 'pusher:subscription_error' a level up, and log there?\n // Binding to this event would cause the warning about no callbacks being\n // bound (see constructor) to be suppressed, that's not what we want.\n Logger.error(error.toString());\n this.emit(\n 'pusher:subscription_error',\n Object.assign(\n {},\n {\n type: 'AuthError',\n error: error.message\n },\n error instanceof HTTPAuthError ? { status: error.status } : {}\n )\n );\n } else {\n this.pusher.send_event('pusher:subscribe', {\n auth: data.auth,\n channel_data: data.channel_data,\n channel: this.name\n });\n }\n }\n );\n }\n\n /** Sends an unsubscription request. For internal use only. */\n unsubscribe() {\n this.subscribed = false;\n this.pusher.send_event('pusher:unsubscribe', {\n channel: this.name\n });\n }\n\n /** Cancels an in progress subscription. For internal use only. */\n cancelSubscription() {\n this.subscriptionCancelled = true;\n }\n\n /** Reinstates an in progress subscripiton. For internal use only. */\n reinstateSubscription() {\n this.subscriptionCancelled = false;\n }\n}\n","import Factory from '../utils/factory';\nimport Channel from './channel';\nimport { ChannelAuthorizationCallback } from '../auth/options';\n\n/** Extends public channels to provide private channel interface.\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\nexport default class PrivateChannel extends Channel {\n /** Authorizes the connection to use the channel.\n *\n * @param {String} socketId\n * @param {Function} callback\n */\n authorize(socketId: string, callback: ChannelAuthorizationCallback) {\n return this.pusher.config.channelAuthorizer(\n {\n channelName: this.name,\n socketId: socketId\n },\n callback\n );\n }\n}\n","import * as Collections from '../utils/collections';\n\n/** Represents a collection of members of a presence channel. */\nexport default class Members {\n members: any;\n count: number;\n myID: any;\n me: any;\n\n constructor() {\n this.reset();\n }\n\n /** Returns member's info for given id.\n *\n * Resulting object containts two fields - id and info.\n *\n * @param {Number} id\n * @return {Object} member's info or null\n */\n get(id: string): any {\n if (Object.prototype.hasOwnProperty.call(this.members, id)) {\n return {\n id: id,\n info: this.members[id]\n };\n } else {\n return null;\n }\n }\n\n /** Calls back for each member in unspecified order.\n *\n * @param {Function} callback\n */\n each(callback: Function) {\n Collections.objectApply(this.members, (member, id) => {\n callback(this.get(id));\n });\n }\n\n /** Updates the id for connected member. For internal use only. */\n setMyID(id: string) {\n this.myID = id;\n }\n\n /** Handles subscription data. For internal use only. */\n onSubscription(subscriptionData: any) {\n this.members = subscriptionData.presence.hash;\n this.count = subscriptionData.presence.count;\n this.me = this.get(this.myID);\n }\n\n /** Adds a new member to the collection. For internal use only. */\n addMember(memberData: any) {\n if (this.get(memberData.user_id) === null) {\n this.count++;\n }\n this.members[memberData.user_id] = memberData.user_info;\n return this.get(memberData.user_id);\n }\n\n /** Adds a member from the collection. For internal use only. */\n removeMember(memberData: any) {\n var member = this.get(memberData.user_id);\n if (member) {\n delete this.members[memberData.user_id];\n this.count--;\n }\n return member;\n }\n\n /** Resets the collection to the initial state. For internal use only. */\n reset() {\n this.members = {};\n this.count = 0;\n this.myID = null;\n this.me = null;\n }\n}\n","import PrivateChannel from './private_channel';\nimport Logger from '../logger';\nimport Members from './members';\nimport Pusher from '../pusher';\nimport UrlStore from 'core/utils/url_store';\nimport { PusherEvent } from '../connection/protocol/message-types';\nimport Metadata from './metadata';\nimport { ChannelAuthorizationData } from '../auth/options';\n\nexport default class PresenceChannel extends PrivateChannel {\n members: Members;\n\n /** Adds presence channel functionality to private channels.\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\n constructor(name: string, pusher: Pusher) {\n super(name, pusher);\n this.members = new Members();\n }\n\n /** Authorizes the connection as a member of the channel.\n *\n * @param {String} socketId\n * @param {Function} callback\n */\n authorize(socketId: string, callback: Function) {\n super.authorize(socketId, async (error, authData) => {\n if (!error) {\n authData = authData as ChannelAuthorizationData;\n if (authData.channel_data != null) {\n var channelData = JSON.parse(authData.channel_data);\n this.members.setMyID(channelData.user_id);\n } else {\n await this.pusher.user.signinDonePromise;\n if (this.pusher.user.user_data != null) {\n // If the user is signed in, get the id of the authenticated user\n // and allow the presence authorization to continue.\n this.members.setMyID(this.pusher.user.user_data.id);\n } else {\n let suffix = UrlStore.buildLogSuffix('authorizationEndpoint');\n Logger.error(\n `Invalid auth response for channel '${this.name}', ` +\n `expected 'channel_data' field. ${suffix}, ` +\n `or the user should be signed in.`\n );\n callback('Invalid auth response');\n return;\n }\n }\n }\n callback(error, authData);\n });\n }\n\n /** Handles presence and subscription events. For internal use only.\n *\n * @param {PusherEvent} event\n */\n handleEvent(event: PusherEvent) {\n var eventName = event.event;\n if (eventName.indexOf('pusher_internal:') === 0) {\n this.handleInternalEvent(event);\n } else {\n var data = event.data;\n var metadata: Metadata = {};\n if (event.user_id) {\n metadata.user_id = event.user_id;\n }\n this.emit(eventName, data, metadata);\n }\n }\n handleInternalEvent(event: PusherEvent) {\n var eventName = event.event;\n var data = event.data;\n switch (eventName) {\n case 'pusher_internal:subscription_succeeded':\n this.handleSubscriptionSucceededEvent(event);\n break;\n case 'pusher_internal:subscription_count':\n this.handleSubscriptionCountEvent(event);\n break;\n case 'pusher_internal:member_added':\n var addedMember = this.members.addMember(data);\n this.emit('pusher:member_added', addedMember);\n break;\n case 'pusher_internal:member_removed':\n var removedMember = this.members.removeMember(data);\n if (removedMember) {\n this.emit('pusher:member_removed', removedMember);\n }\n break;\n }\n }\n\n handleSubscriptionSucceededEvent(event: PusherEvent) {\n this.subscriptionPending = false;\n this.subscribed = true;\n if (this.subscriptionCancelled) {\n this.pusher.unsubscribe(this.name);\n } else {\n this.members.onSubscription(event.data);\n this.emit('pusher:subscription_succeeded', this.members);\n }\n }\n\n /** Resets the channel state, including members map. For internal use only. */\n disconnect() {\n this.members.reset();\n super.disconnect();\n }\n}\n","import PrivateChannel from './private_channel';\nimport * as Errors from '../errors';\nimport Logger from '../logger';\nimport Pusher from '../pusher';\nimport { decode as encodeUTF8 } from '@stablelib/utf8';\nimport { decode as decodeBase64 } from '@stablelib/base64';\nimport Dispatcher from '../events/dispatcher';\nimport { PusherEvent } from '../connection/protocol/message-types';\nimport {\n ChannelAuthorizationData,\n ChannelAuthorizationCallback\n} from '../auth/options';\nimport * as nacl from 'tweetnacl';\n\n/** Extends private channels to provide encrypted channel interface.\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\nexport default class EncryptedChannel extends PrivateChannel {\n key: Uint8Array = null;\n nacl: nacl;\n\n constructor(name: string, pusher: Pusher, nacl: nacl) {\n super(name, pusher);\n this.nacl = nacl;\n }\n\n /** Authorizes the connection to use the channel.\n *\n * @param {String} socketId\n * @param {Function} callback\n */\n authorize(socketId: string, callback: ChannelAuthorizationCallback) {\n super.authorize(\n socketId,\n (error: Error | null, authData: ChannelAuthorizationData) => {\n if (error) {\n callback(error, authData);\n return;\n }\n let sharedSecret = authData['shared_secret'];\n if (!sharedSecret) {\n callback(\n new Error(\n `No shared_secret key in auth payload for encrypted channel: ${this.name}`\n ),\n null\n );\n return;\n }\n this.key = decodeBase64(sharedSecret);\n delete authData['shared_secret'];\n callback(null, authData);\n }\n );\n }\n\n trigger(event: string, data: any): boolean {\n throw new Errors.UnsupportedFeature(\n 'Client events are not currently supported for encrypted channels'\n );\n }\n\n /** Handles an event. For internal use only.\n *\n * @param {PusherEvent} event\n */\n handleEvent(event: PusherEvent) {\n var eventName = event.event;\n var data = event.data;\n if (\n eventName.indexOf('pusher_internal:') === 0 ||\n eventName.indexOf('pusher:') === 0\n ) {\n super.handleEvent(event);\n return;\n }\n this.handleEncryptedEvent(eventName, data);\n }\n\n private handleEncryptedEvent(event: string, data: any): void {\n if (!this.key) {\n Logger.debug(\n 'Received encrypted event before key has been retrieved from the authEndpoint'\n );\n return;\n }\n if (!data.ciphertext || !data.nonce) {\n Logger.error(\n 'Unexpected format for encrypted event, expected object with `ciphertext` and `nonce` fields, got: ' +\n data\n );\n return;\n }\n let cipherText = decodeBase64(data.ciphertext);\n if (cipherText.length < this.nacl.secretbox.overheadLength) {\n Logger.error(\n `Expected encrypted event ciphertext length to be ${this.nacl.secretbox.overheadLength}, got: ${cipherText.length}`\n );\n return;\n }\n let nonce = decodeBase64(data.nonce);\n if (nonce.length < this.nacl.secretbox.nonceLength) {\n Logger.error(\n `Expected encrypted event nonce length to be ${this.nacl.secretbox.nonceLength}, got: ${nonce.length}`\n );\n return;\n }\n\n let bytes = this.nacl.secretbox.open(cipherText, nonce, this.key);\n if (bytes === null) {\n Logger.debug(\n 'Failed to decrypt an event, probably because it was encrypted with a different key. Fetching a new key from the authEndpoint...'\n );\n // Try a single time to retrieve a new auth key and decrypt the event with it\n // If this fails, a new key will be requested when a new message is received\n this.authorize(this.pusher.connection.socket_id, (error, authData) => {\n if (error) {\n Logger.error(\n `Failed to make a request to the authEndpoint: ${authData}. Unable to fetch new key, so dropping encrypted event`\n );\n return;\n }\n bytes = this.nacl.secretbox.open(cipherText, nonce, this.key);\n if (bytes === null) {\n Logger.error(\n `Failed to decrypt event with new key. Dropping encrypted event`\n );\n return;\n }\n this.emit(event, this.getDataToEmit(bytes));\n return;\n });\n return;\n }\n this.emit(event, this.getDataToEmit(bytes));\n }\n\n // Try and parse the decrypted bytes as JSON. If we can't parse it, just\n // return the utf-8 string\n getDataToEmit(bytes: Uint8Array): string {\n let raw = encodeUTF8(bytes);\n try {\n return JSON.parse(raw);\n } catch {\n return raw;\n }\n }\n}\n","import { default as EventsDispatcher } from '../events/dispatcher';\nimport { OneOffTimer as Timer } from '../utils/timers';\nimport { Config } from '../config';\nimport Logger from '../logger';\nimport HandshakePayload from './handshake/handshake_payload';\nimport Connection from './connection';\nimport Strategy from '../strategies/strategy';\nimport StrategyRunner from '../strategies/strategy_runner';\nimport * as Collections from '../utils/collections';\nimport Timeline from '../timeline/timeline';\nimport ConnectionManagerOptions from './connection_manager_options';\nimport Runtime from 'runtime';\n\nimport {\n ErrorCallbacks,\n HandshakeCallbacks,\n ConnectionCallbacks\n} from './callbacks';\nimport Action from './protocol/action';\n\n/** Manages connection to Pusher.\n *\n * Uses a strategy (currently only default), timers and network availability\n * info to establish a connection and export its state. In case of failures,\n * manages reconnection attempts.\n *\n * Exports state changes as following events:\n * - \"state_change\", { previous: p, current: state }\n * - state\n *\n * States:\n * - initialized - initial state, never transitioned to\n * - connecting - connection is being established\n * - connected - connection has been fully established\n * - disconnected - on requested disconnection\n * - unavailable - after connection timeout or when there's no network\n * - failed - when the connection strategy is not supported\n *\n * Options:\n * - unavailableTimeout - time to transition to unavailable state\n * - activityTimeout - time after which ping message should be sent\n * - pongTimeout - time for Pusher to respond with pong before reconnecting\n *\n * @param {String} key application key\n * @param {Object} options\n */\nexport default class ConnectionManager extends EventsDispatcher {\n key: string;\n options: ConnectionManagerOptions;\n state: string;\n connection: Connection;\n usingTLS: boolean;\n timeline: Timeline;\n socket_id: string;\n unavailableTimer: Timer;\n activityTimer: Timer;\n retryTimer: Timer;\n activityTimeout: number;\n strategy: Strategy;\n runner: StrategyRunner;\n errorCallbacks: ErrorCallbacks;\n handshakeCallbacks: HandshakeCallbacks;\n connectionCallbacks: ConnectionCallbacks;\n\n constructor(key: string, options: ConnectionManagerOptions) {\n super();\n this.state = 'initialized';\n this.connection = null;\n\n this.key = key;\n this.options = options;\n this.timeline = this.options.timeline;\n this.usingTLS = this.options.useTLS;\n\n this.errorCallbacks = this.buildErrorCallbacks();\n this.connectionCallbacks = this.buildConnectionCallbacks(\n this.errorCallbacks\n );\n this.handshakeCallbacks = this.buildHandshakeCallbacks(this.errorCallbacks);\n\n var Network = Runtime.getNetwork();\n\n Network.bind('online', () => {\n this.timeline.info({ netinfo: 'online' });\n if (this.state === 'connecting' || this.state === 'unavailable') {\n this.retryIn(0);\n }\n });\n Network.bind('offline', () => {\n this.timeline.info({ netinfo: 'offline' });\n if (this.connection) {\n this.sendActivityCheck();\n }\n });\n\n this.updateStrategy();\n }\n\n switchCluster(key: string) {\n this.key = key;\n // This ensures that the new config coming from\n // pusher instance are taken into account\n // such as appKey and cluster\n this.updateStrategy();\n this.retryIn(0);\n }\n\n /** Establishes a connection to Pusher.\n *\n * Does nothing when connection is already established. See top-level doc\n * to find events emitted on connection attempts.\n */\n connect() {\n if (this.connection || this.runner) {\n return;\n }\n if (!this.strategy.isSupported()) {\n this.updateState('failed');\n return;\n }\n this.updateState('connecting');\n this.startConnecting();\n this.setUnavailableTimer();\n }\n\n /** Sends raw data.\n *\n * @param {String} data\n */\n send(data) {\n if (this.connection) {\n return this.connection.send(data);\n } else {\n return false;\n }\n }\n\n /** Sends an event.\n *\n * @param {String} name\n * @param {String} data\n * @param {String} [channel]\n * @returns {Boolean} whether message was sent or not\n */\n send_event(name: string, data: any, channel?: string) {\n if (this.connection) {\n return this.connection.send_event(name, data, channel);\n } else {\n return false;\n }\n }\n\n /** Closes the connection. */\n disconnect() {\n this.disconnectInternally();\n this.updateState('disconnected');\n }\n\n isUsingTLS() {\n return this.usingTLS;\n }\n\n private startConnecting() {\n var callback = (error, handshake) => {\n if (error) {\n this.runner = this.strategy.connect(0, callback);\n } else {\n if (handshake.action === 'error') {\n this.emit('error', {\n type: 'HandshakeError',\n error: handshake.error\n });\n this.timeline.error({ handshakeError: handshake.error });\n } else {\n this.abortConnecting(); // we don't support switching connections yet\n this.handshakeCallbacks[handshake.action](handshake);\n }\n }\n };\n this.runner = this.strategy.connect(0, callback);\n }\n\n private abortConnecting() {\n if (this.runner) {\n this.runner.abort();\n this.runner = null;\n }\n }\n\n private disconnectInternally() {\n this.abortConnecting();\n this.clearRetryTimer();\n this.clearUnavailableTimer();\n if (this.connection) {\n var connection = this.abandonConnection();\n connection.close();\n }\n }\n\n private updateStrategy() {\n this.strategy = this.options.getStrategy({\n key: this.key,\n timeline: this.timeline,\n useTLS: this.usingTLS\n });\n }\n\n private retryIn(delay) {\n this.timeline.info({ action: 'retry', delay: delay });\n if (delay > 0) {\n this.emit('connecting_in', Math.round(delay / 1000));\n }\n this.retryTimer = new Timer(delay || 0, () => {\n this.disconnectInternally();\n this.connect();\n });\n }\n\n private clearRetryTimer() {\n if (this.retryTimer) {\n this.retryTimer.ensureAborted();\n this.retryTimer = null;\n }\n }\n\n private setUnavailableTimer() {\n this.unavailableTimer = new Timer(this.options.unavailableTimeout, () => {\n this.updateState('unavailable');\n });\n }\n\n private clearUnavailableTimer() {\n if (this.unavailableTimer) {\n this.unavailableTimer.ensureAborted();\n }\n }\n\n private sendActivityCheck() {\n this.stopActivityCheck();\n this.connection.ping();\n // wait for pong response\n this.activityTimer = new Timer(this.options.pongTimeout, () => {\n this.timeline.error({ pong_timed_out: this.options.pongTimeout });\n this.retryIn(0);\n });\n }\n\n private resetActivityCheck() {\n this.stopActivityCheck();\n // send ping after inactivity\n if (this.connection && !this.connection.handlesActivityChecks()) {\n this.activityTimer = new Timer(this.activityTimeout, () => {\n this.sendActivityCheck();\n });\n }\n }\n\n private stopActivityCheck() {\n if (this.activityTimer) {\n this.activityTimer.ensureAborted();\n }\n }\n\n private buildConnectionCallbacks(\n errorCallbacks: ErrorCallbacks\n ): ConnectionCallbacks {\n return Collections.extend({}, errorCallbacks, {\n message: message => {\n // includes pong messages from server\n this.resetActivityCheck();\n this.emit('message', message);\n },\n ping: () => {\n this.send_event('pusher:pong', {});\n },\n activity: () => {\n this.resetActivityCheck();\n },\n error: error => {\n // just emit error to user - socket will already be closed by browser\n this.emit('error', error);\n },\n closed: () => {\n this.abandonConnection();\n if (this.shouldRetry()) {\n this.retryIn(1000);\n }\n }\n });\n }\n\n private buildHandshakeCallbacks(\n errorCallbacks: ErrorCallbacks\n ): HandshakeCallbacks {\n return Collections.extend({}, errorCallbacks, {\n connected: (handshake: HandshakePayload) => {\n this.activityTimeout = Math.min(\n this.options.activityTimeout,\n handshake.activityTimeout,\n handshake.connection.activityTimeout || Infinity\n );\n this.clearUnavailableTimer();\n this.setConnection(handshake.connection);\n this.socket_id = this.connection.id;\n this.updateState('connected', { socket_id: this.socket_id });\n }\n });\n }\n\n private buildErrorCallbacks(): ErrorCallbacks {\n let withErrorEmitted = callback => {\n return (result: Action | HandshakePayload) => {\n if (result.error) {\n this.emit('error', { type: 'WebSocketError', error: result.error });\n }\n callback(result);\n };\n };\n\n return {\n tls_only: withErrorEmitted(() => {\n this.usingTLS = true;\n this.updateStrategy();\n this.retryIn(0);\n }),\n refused: withErrorEmitted(() => {\n this.disconnect();\n }),\n backoff: withErrorEmitted(() => {\n this.retryIn(1000);\n }),\n retry: withErrorEmitted(() => {\n this.retryIn(0);\n })\n };\n }\n\n private setConnection(connection) {\n this.connection = connection;\n for (var event in this.connectionCallbacks) {\n this.connection.bind(event, this.connectionCallbacks[event]);\n }\n this.resetActivityCheck();\n }\n\n private abandonConnection() {\n if (!this.connection) {\n return;\n }\n this.stopActivityCheck();\n for (var event in this.connectionCallbacks) {\n this.connection.unbind(event, this.connectionCallbacks[event]);\n }\n var connection = this.connection;\n this.connection = null;\n return connection;\n }\n\n private updateState(newState: string, data?: any) {\n var previousState = this.state;\n this.state = newState;\n if (previousState !== newState) {\n var newStateDescription = newState;\n if (newStateDescription === 'connected') {\n newStateDescription += ' with new socket ID ' + data.socket_id;\n }\n Logger.debug(\n 'State changed',\n previousState + ' -> ' + newStateDescription\n );\n this.timeline.info({ state: newState, params: data });\n this.emit('state_change', { previous: previousState, current: newState });\n this.emit(newState, data);\n }\n }\n\n private shouldRetry(): boolean {\n return this.state === 'connecting' || this.state === 'connected';\n }\n}\n","import Channel from './channel';\nimport * as Collections from '../utils/collections';\nimport ChannelTable from './channel_table';\nimport Factory from '../utils/factory';\nimport Pusher from '../pusher';\nimport Logger from '../logger';\nimport * as Errors from '../errors';\nimport urlStore from '../utils/url_store';\n\n/** Handles a channel map. */\nexport default class Channels {\n channels: ChannelTable;\n\n constructor() {\n this.channels = {};\n }\n\n /** Creates or retrieves an existing channel by its name.\n *\n * @param {String} name\n * @param {Pusher} pusher\n * @return {Channel}\n */\n add(name: string, pusher: Pusher) {\n if (!this.channels[name]) {\n this.channels[name] = createChannel(name, pusher);\n }\n return this.channels[name];\n }\n\n /** Returns a list of all channels\n *\n * @return {Array}\n */\n all(): Channel[] {\n return Collections.values(this.channels);\n }\n\n /** Finds a channel by its name.\n *\n * @param {String} name\n * @return {Channel} channel or null if it doesn't exist\n */\n find(name: string) {\n return this.channels[name];\n }\n\n /** Removes a channel from the map.\n *\n * @param {String} name\n */\n remove(name: string) {\n var channel = this.channels[name];\n delete this.channels[name];\n return channel;\n }\n\n /** Proxies disconnection signal to all channels. */\n disconnect() {\n Collections.objectApply(this.channels, function(channel) {\n channel.disconnect();\n });\n }\n}\n\nfunction createChannel(name: string, pusher: Pusher): Channel {\n if (name.indexOf('private-encrypted-') === 0) {\n if (pusher.config.nacl) {\n return Factory.createEncryptedChannel(name, pusher, pusher.config.nacl);\n }\n let errMsg =\n 'Tried to subscribe to a private-encrypted- channel but no nacl implementation available';\n let suffix = urlStore.buildLogSuffix('encryptedChannelSupport');\n throw new Errors.UnsupportedFeature(`${errMsg}. ${suffix}`);\n } else if (name.indexOf('private-') === 0) {\n return Factory.createPrivateChannel(name, pusher);\n } else if (name.indexOf('presence-') === 0) {\n return Factory.createPresenceChannel(name, pusher);\n } else if (name.indexOf('#') === 0) {\n throw new Errors.BadChannelName(\n 'Cannot create a channel with name \"' + name + '\".'\n );\n } else {\n return Factory.createChannel(name, pusher);\n }\n}\n","import AssistantToTheTransportManager from '../transports/assistant_to_the_transport_manager';\nimport PingDelayOptions from '../transports/ping_delay_options';\nimport Transport from '../transports/transport';\nimport TransportManager from '../transports/transport_manager';\nimport Handshake from '../connection/handshake';\nimport TransportConnection from '../transports/transport_connection';\nimport SocketHooks from '../http/socket_hooks';\nimport HTTPSocket from '../http/http_socket';\n\nimport Timeline from '../timeline/timeline';\nimport {\n default as TimelineSender,\n TimelineSenderOptions\n} from '../timeline/timeline_sender';\nimport PresenceChannel from '../channels/presence_channel';\nimport PrivateChannel from '../channels/private_channel';\nimport EncryptedChannel from '../channels/encrypted_channel';\nimport Channel from '../channels/channel';\nimport ConnectionManager from '../connection/connection_manager';\nimport ConnectionManagerOptions from '../connection/connection_manager_options';\nimport Ajax from '../http/ajax';\nimport Channels from '../channels/channels';\nimport Pusher from '../pusher';\nimport { Config } from '../config';\nimport * as nacl from 'tweetnacl';\n\nvar Factory = {\n createChannels(): Channels {\n return new Channels();\n },\n\n createConnectionManager(\n key: string,\n options: ConnectionManagerOptions\n ): ConnectionManager {\n return new ConnectionManager(key, options);\n },\n\n createChannel(name: string, pusher: Pusher): Channel {\n return new Channel(name, pusher);\n },\n\n createPrivateChannel(name: string, pusher: Pusher): PrivateChannel {\n return new PrivateChannel(name, pusher);\n },\n\n createPresenceChannel(name: string, pusher: Pusher): PresenceChannel {\n return new PresenceChannel(name, pusher);\n },\n\n createEncryptedChannel(\n name: string,\n pusher: Pusher,\n nacl: nacl\n ): EncryptedChannel {\n return new EncryptedChannel(name, pusher, nacl);\n },\n\n createTimelineSender(timeline: Timeline, options: TimelineSenderOptions) {\n return new TimelineSender(timeline, options);\n },\n\n createHandshake(\n transport: TransportConnection,\n callback: (HandshakePayload) => void\n ): Handshake {\n return new Handshake(transport, callback);\n },\n\n createAssistantToTheTransportManager(\n manager: TransportManager,\n transport: Transport,\n options: PingDelayOptions\n ): AssistantToTheTransportManager {\n return new AssistantToTheTransportManager(manager, transport, options);\n }\n};\n\nexport default Factory;\n","import AssistantToTheTransportManager from './assistant_to_the_transport_manager';\nimport Transport from './transport';\nimport PingDelayOptions from './ping_delay_options';\nimport Factory from '../utils/factory';\n\nexport interface TransportManagerOptions extends PingDelayOptions {\n lives?: number;\n}\n\n/** Keeps track of the number of lives left for a transport.\n *\n * In the beginning of a session, transports may be assigned a number of\n * lives. When an AssistantToTheTransportManager instance reports a transport\n * connection closed uncleanly, the transport loses a life. When the number\n * of lives drops to zero, the transport gets disabled by its manager.\n *\n * @param {Object} options\n */\nexport default class TransportManager {\n options: TransportManagerOptions;\n livesLeft: number;\n\n constructor(options: TransportManagerOptions) {\n this.options = options || {};\n this.livesLeft = this.options.lives || Infinity;\n }\n\n /** Creates a assistant for the transport.\n *\n * @param {Transport} transport\n * @returns {AssistantToTheTransportManager}\n */\n getAssistant(transport: Transport): AssistantToTheTransportManager {\n return Factory.createAssistantToTheTransportManager(this, transport, {\n minPingDelay: this.options.minPingDelay,\n maxPingDelay: this.options.maxPingDelay\n });\n }\n\n /** Returns whether the transport has any lives left.\n *\n * @returns {Boolean}\n */\n isAlive(): boolean {\n return this.livesLeft > 0;\n }\n\n /** Takes one life from the transport. */\n reportDeath() {\n this.livesLeft -= 1;\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport { OneOffTimer as Timer } from '../utils/timers';\nimport Strategy from './strategy';\nimport StrategyOptions from './strategy_options';\n\n/** Loops through strategies with optional timeouts.\n *\n * Options:\n * - loop - whether it should loop through the substrategy list\n * - timeout - initial timeout for a single substrategy\n * - timeoutLimit - maximum timeout\n *\n * @param {Strategy[]} strategies\n * @param {Object} options\n */\nexport default class SequentialStrategy implements Strategy {\n strategies: Strategy[];\n loop: boolean;\n failFast: boolean;\n timeout: number;\n timeoutLimit: number;\n\n constructor(strategies: Strategy[], options: StrategyOptions) {\n this.strategies = strategies;\n this.loop = Boolean(options.loop);\n this.failFast = Boolean(options.failFast);\n this.timeout = options.timeout;\n this.timeoutLimit = options.timeoutLimit;\n }\n\n isSupported(): boolean {\n return Collections.any(this.strategies, Util.method('isSupported'));\n }\n\n connect(minPriority: number, callback: Function) {\n var strategies = this.strategies;\n var current = 0;\n var timeout = this.timeout;\n var runner = null;\n\n var tryNextStrategy = (error, handshake) => {\n if (handshake) {\n callback(null, handshake);\n } else {\n current = current + 1;\n if (this.loop) {\n current = current % strategies.length;\n }\n\n if (current < strategies.length) {\n if (timeout) {\n timeout = timeout * 2;\n if (this.timeoutLimit) {\n timeout = Math.min(timeout, this.timeoutLimit);\n }\n }\n runner = this.tryStrategy(\n strategies[current],\n minPriority,\n { timeout, failFast: this.failFast },\n tryNextStrategy\n );\n } else {\n callback(true);\n }\n }\n };\n\n runner = this.tryStrategy(\n strategies[current],\n minPriority,\n { timeout: timeout, failFast: this.failFast },\n tryNextStrategy\n );\n\n return {\n abort: function() {\n runner.abort();\n },\n forceMinPriority: function(p) {\n minPriority = p;\n if (runner) {\n runner.forceMinPriority(p);\n }\n }\n };\n }\n\n private tryStrategy(\n strategy: Strategy,\n minPriority: number,\n options: StrategyOptions,\n callback: Function\n ) {\n var timer = null;\n var runner = null;\n\n if (options.timeout > 0) {\n timer = new Timer(options.timeout, function() {\n runner.abort();\n callback(true);\n });\n }\n\n runner = strategy.connect(minPriority, function(error, handshake) {\n if (error && timer && timer.isRunning() && !options.failFast) {\n // advance to the next strategy after the timeout\n return;\n }\n if (timer) {\n timer.ensureAborted();\n }\n callback(error, handshake);\n });\n\n return {\n abort: function() {\n if (timer) {\n timer.ensureAborted();\n }\n runner.abort();\n },\n forceMinPriority: function(p) {\n runner.forceMinPriority(p);\n }\n };\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport Strategy from './strategy';\n\n/** Launches all substrategies and emits prioritized connected transports.\n *\n * @param {Array} strategies\n */\nexport default class BestConnectedEverStrategy implements Strategy {\n strategies: Strategy[];\n\n constructor(strategies: Strategy[]) {\n this.strategies = strategies;\n }\n\n isSupported(): boolean {\n return Collections.any(this.strategies, Util.method('isSupported'));\n }\n\n connect(minPriority: number, callback: Function) {\n return connect(this.strategies, minPriority, function(i, runners) {\n return function(error, handshake) {\n runners[i].error = error;\n if (error) {\n if (allRunnersFailed(runners)) {\n callback(true);\n }\n return;\n }\n Collections.apply(runners, function(runner) {\n runner.forceMinPriority(handshake.transport.priority);\n });\n callback(null, handshake);\n };\n });\n }\n}\n\n/** Connects to all strategies in parallel.\n *\n * Callback builder should be a function that takes two arguments: index\n * and a list of runners. It should return another function that will be\n * passed to the substrategy with given index. Runners can be aborted using\n * abortRunner(s) functions from this class.\n *\n * @param {Array} strategies\n * @param {Function} callbackBuilder\n * @return {Object} strategy runner\n */\nfunction connect(\n strategies: Strategy[],\n minPriority: number,\n callbackBuilder: Function\n) {\n var runners = Collections.map(strategies, function(strategy, i, _, rs) {\n return strategy.connect(minPriority, callbackBuilder(i, rs));\n });\n return {\n abort: function() {\n Collections.apply(runners, abortRunner);\n },\n forceMinPriority: function(p) {\n Collections.apply(runners, function(runner) {\n runner.forceMinPriority(p);\n });\n }\n };\n}\n\nfunction allRunnersFailed(runners): boolean {\n return Collections.all(runners, function(runner) {\n return Boolean(runner.error);\n });\n}\n\nfunction abortRunner(runner) {\n if (!runner.error && !runner.aborted) {\n runner.abort();\n runner.aborted = true;\n }\n}\n","import Util from '../util';\nimport Runtime from 'runtime';\nimport Strategy from './strategy';\nimport SequentialStrategy from './sequential_strategy';\nimport StrategyOptions from './strategy_options';\nimport TransportStrategy from './transport_strategy';\nimport Timeline from '../timeline/timeline';\nimport * as Collections from '../utils/collections';\n\nexport interface TransportStrategyDictionary {\n [key: string]: TransportStrategy;\n}\n\n/** Caches the last successful transport and, after the first few attempts,\n * uses the cached transport for subsequent attempts.\n *\n * @param {Strategy} strategy\n * @param {Object} transports\n * @param {Object} options\n */\nexport default class WebSocketPrioritizedCachedStrategy implements Strategy {\n strategy: Strategy;\n transports: TransportStrategyDictionary;\n ttl: number;\n usingTLS: boolean;\n timeline: Timeline;\n\n constructor(\n strategy: Strategy,\n transports: TransportStrategyDictionary,\n options: StrategyOptions\n ) {\n this.strategy = strategy;\n this.transports = transports;\n this.ttl = options.ttl || 1800 * 1000;\n this.usingTLS = options.useTLS;\n this.timeline = options.timeline;\n }\n\n isSupported(): boolean {\n return this.strategy.isSupported();\n }\n\n connect(minPriority: number, callback: Function) {\n var usingTLS = this.usingTLS;\n var info = fetchTransportCache(usingTLS);\n var cacheSkipCount = info && info.cacheSkipCount ? info.cacheSkipCount : 0;\n\n var strategies = [this.strategy];\n if (info && info.timestamp + this.ttl >= Util.now()) {\n var transport = this.transports[info.transport];\n if (transport) {\n if (['ws', 'wss'].includes(info.transport) || cacheSkipCount > 3) {\n this.timeline.info({\n cached: true,\n transport: info.transport,\n latency: info.latency\n });\n strategies.push(\n new SequentialStrategy([transport], {\n timeout: info.latency * 2 + 1000,\n failFast: true\n })\n );\n } else {\n cacheSkipCount++;\n }\n }\n }\n\n var startTimestamp = Util.now();\n var runner = strategies\n .pop()\n .connect(minPriority, function cb(error, handshake) {\n if (error) {\n flushTransportCache(usingTLS);\n if (strategies.length > 0) {\n startTimestamp = Util.now();\n runner = strategies.pop().connect(minPriority, cb);\n } else {\n callback(error);\n }\n } else {\n storeTransportCache(\n usingTLS,\n handshake.transport.name,\n Util.now() - startTimestamp,\n cacheSkipCount\n );\n callback(null, handshake);\n }\n });\n\n return {\n abort: function() {\n runner.abort();\n },\n forceMinPriority: function(p) {\n minPriority = p;\n if (runner) {\n runner.forceMinPriority(p);\n }\n }\n };\n }\n}\n\nfunction getTransportCacheKey(usingTLS: boolean): string {\n return 'pusherTransport' + (usingTLS ? 'TLS' : 'NonTLS');\n}\n\nfunction fetchTransportCache(usingTLS: boolean): any {\n var storage = Runtime.getLocalStorage();\n if (storage) {\n try {\n var serializedCache = storage[getTransportCacheKey(usingTLS)];\n if (serializedCache) {\n return JSON.parse(serializedCache);\n }\n } catch (e) {\n flushTransportCache(usingTLS);\n }\n }\n return null;\n}\n\nfunction storeTransportCache(\n usingTLS: boolean,\n transport: TransportStrategy,\n latency: number,\n cacheSkipCount: number\n) {\n var storage = Runtime.getLocalStorage();\n if (storage) {\n try {\n storage[getTransportCacheKey(usingTLS)] = Collections.safeJSONStringify({\n timestamp: Util.now(),\n transport: transport,\n latency: latency,\n cacheSkipCount: cacheSkipCount\n });\n } catch (e) {\n // catch over quota exceptions raised by localStorage\n }\n }\n}\n\nfunction flushTransportCache(usingTLS: boolean) {\n var storage = Runtime.getLocalStorage();\n if (storage) {\n try {\n delete storage[getTransportCacheKey(usingTLS)];\n } catch (e) {\n // catch exceptions raised by localStorage\n }\n }\n}\n","import { OneOffTimer as Timer } from '../utils/timers';\nimport Strategy from './strategy';\nimport StrategyOptions from './strategy_options';\n\n/** Runs substrategy after specified delay.\n *\n * Options:\n * - delay - time in miliseconds to delay the substrategy attempt\n *\n * @param {Strategy} strategy\n * @param {Object} options\n */\nexport default class DelayedStrategy implements Strategy {\n strategy: Strategy;\n options: { delay: number };\n\n constructor(strategy: Strategy, { delay: number }) {\n this.strategy = strategy;\n this.options = { delay: number };\n }\n\n isSupported(): boolean {\n return this.strategy.isSupported();\n }\n\n connect(minPriority: number, callback: Function) {\n var strategy = this.strategy;\n var runner;\n var timer = new Timer(this.options.delay, function() {\n runner = strategy.connect(minPriority, callback);\n });\n\n return {\n abort: function() {\n timer.ensureAborted();\n if (runner) {\n runner.abort();\n }\n },\n forceMinPriority: function(p) {\n minPriority = p;\n if (runner) {\n runner.forceMinPriority(p);\n }\n }\n };\n }\n}\n","import Strategy from './strategy';\nimport StrategyRunner from './strategy_runner';\n\n/** Proxies method calls to one of substrategies basing on the test function.\n *\n * @param {Function} test\n * @param {Strategy} trueBranch strategy used when test returns true\n * @param {Strategy} falseBranch strategy used when test returns false\n */\nexport default class IfStrategy implements Strategy {\n test: () => boolean;\n trueBranch: Strategy;\n falseBranch: Strategy;\n\n constructor(\n test: () => boolean,\n trueBranch: Strategy,\n falseBranch: Strategy\n ) {\n this.test = test;\n this.trueBranch = trueBranch;\n this.falseBranch = falseBranch;\n }\n\n isSupported(): boolean {\n var branch = this.test() ? this.trueBranch : this.falseBranch;\n return branch.isSupported();\n }\n\n connect(minPriority: number, callback: Function): StrategyRunner {\n var branch = this.test() ? this.trueBranch : this.falseBranch;\n return branch.connect(minPriority, callback);\n }\n}\n","import Strategy from './strategy';\nimport StrategyRunner from './strategy_runner';\n\n/** Launches the substrategy and terminates on the first open connection.\n *\n * @param {Strategy} strategy\n */\nexport default class FirstConnectedStrategy implements Strategy {\n strategy: Strategy;\n\n constructor(strategy: Strategy) {\n this.strategy = strategy;\n }\n\n isSupported(): boolean {\n return this.strategy.isSupported();\n }\n\n connect(minPriority: number, callback: Function): StrategyRunner {\n var runner = this.strategy.connect(minPriority, function(error, handshake) {\n if (handshake) {\n runner.abort();\n }\n callback(error, handshake);\n });\n return runner;\n }\n}\n","import * as Collections from 'core/utils/collections';\nimport TransportManager from 'core/transports/transport_manager';\nimport Strategy from 'core/strategies/strategy';\nimport SequentialStrategy from 'core/strategies/sequential_strategy';\nimport BestConnectedEverStrategy from 'core/strategies/best_connected_ever_strategy';\nimport WebSocketPrioritizedCachedStrategy, {\n TransportStrategyDictionary\n} from 'core/strategies/websocket_prioritized_cached_strategy';\nimport DelayedStrategy from 'core/strategies/delayed_strategy';\nimport IfStrategy from 'core/strategies/if_strategy';\nimport FirstConnectedStrategy from 'core/strategies/first_connected_strategy';\nimport { Config } from 'core/config';\nimport StrategyOptions from 'core/strategies/strategy_options';\n\nfunction testSupportsStrategy(strategy: Strategy) {\n return function() {\n return strategy.isSupported();\n };\n}\n\nvar getDefaultStrategy = function(\n config: Config,\n baseOptions: StrategyOptions,\n defineTransport: Function\n): Strategy {\n var definedTransports = {};\n\n function defineTransportStrategy(\n name: string,\n type: string,\n priority: number,\n options: StrategyOptions,\n manager?: TransportManager\n ) {\n var transport = defineTransport(\n config,\n name,\n type,\n priority,\n options,\n manager\n );\n\n definedTransports[name] = transport;\n\n return transport;\n }\n\n var ws_options: StrategyOptions = Object.assign({}, baseOptions, {\n hostNonTLS: config.wsHost + ':' + config.wsPort,\n hostTLS: config.wsHost + ':' + config.wssPort,\n httpPath: config.wsPath\n });\n var wss_options: StrategyOptions = Collections.extend({}, ws_options, {\n useTLS: true\n });\n var http_options: StrategyOptions = Object.assign({}, baseOptions, {\n hostNonTLS: config.httpHost + ':' + config.httpPort,\n hostTLS: config.httpHost + ':' + config.httpsPort,\n httpPath: config.httpPath\n });\n var timeouts = {\n loop: true,\n timeout: 15000,\n timeoutLimit: 60000\n };\n\n var ws_manager = new TransportManager({\n minPingDelay: 10000,\n maxPingDelay: config.activityTimeout\n });\n var streaming_manager = new TransportManager({\n lives: 2,\n minPingDelay: 10000,\n maxPingDelay: config.activityTimeout\n });\n\n var ws_transport = defineTransportStrategy(\n 'ws',\n 'ws',\n 3,\n ws_options,\n ws_manager\n );\n var wss_transport = defineTransportStrategy(\n 'wss',\n 'ws',\n 3,\n wss_options,\n ws_manager\n );\n var xhr_streaming_transport = defineTransportStrategy(\n 'xhr_streaming',\n 'xhr_streaming',\n 1,\n http_options,\n streaming_manager\n );\n var xhr_polling_transport = defineTransportStrategy(\n 'xhr_polling',\n 'xhr_polling',\n 1,\n http_options\n );\n\n var ws_loop = new SequentialStrategy([ws_transport], timeouts);\n var wss_loop = new SequentialStrategy([wss_transport], timeouts);\n var streaming_loop = new SequentialStrategy(\n [xhr_streaming_transport],\n timeouts\n );\n var polling_loop = new SequentialStrategy([xhr_polling_transport], timeouts);\n\n var http_loop = new SequentialStrategy(\n [\n new IfStrategy(\n testSupportsStrategy(streaming_loop),\n new BestConnectedEverStrategy([\n streaming_loop,\n new DelayedStrategy(polling_loop, { delay: 4000 })\n ]),\n polling_loop\n )\n ],\n timeouts\n );\n\n var wsStrategy;\n if (baseOptions.useTLS) {\n wsStrategy = new BestConnectedEverStrategy([\n ws_loop,\n new DelayedStrategy(http_loop, { delay: 2000 })\n ]);\n } else {\n wsStrategy = new BestConnectedEverStrategy([\n ws_loop,\n new DelayedStrategy(wss_loop, { delay: 2000 }),\n new DelayedStrategy(http_loop, { delay: 5000 })\n ]);\n }\n\n return new WebSocketPrioritizedCachedStrategy(\n new FirstConnectedStrategy(\n new IfStrategy(testSupportsStrategy(ws_transport), wsStrategy, http_loop)\n ),\n definedTransports,\n {\n ttl: 1800000,\n timeline: baseOptions.timeline,\n useTLS: baseOptions.useTLS\n }\n );\n};\n\nexport default getDefaultStrategy;\n","/** Initializes the transport.\n *\n * Fetches resources if needed and then transitions to initialized.\n */\nexport default function() {\n var self = this;\n\n self.timeline.info(\n self.buildTimelineMessage({\n transport: self.name + (self.options.useTLS ? 's' : '')\n })\n );\n\n if (self.hooks.isInitialized()) {\n self.changeState('initialized');\n } else {\n self.onClose();\n }\n}\n","import Runtime from 'runtime';\nimport RequestHooks from './request_hooks';\nimport Ajax from './ajax';\nimport { default as EventsDispatcher } from '../events/dispatcher';\n\nconst MAX_BUFFER_LENGTH = 256 * 1024;\n\nexport default class HTTPRequest extends EventsDispatcher {\n hooks: RequestHooks;\n method: string;\n url: string;\n position: number;\n xhr: Ajax;\n unloader: Function;\n\n constructor(hooks: RequestHooks, method: string, url: string) {\n super();\n this.hooks = hooks;\n this.method = method;\n this.url = url;\n }\n\n start(payload?: any) {\n this.position = 0;\n this.xhr = this.hooks.getRequest(this);\n\n this.unloader = () => {\n this.close();\n };\n Runtime.addUnloadListener(this.unloader);\n\n this.xhr.open(this.method, this.url, true);\n\n if (this.xhr.setRequestHeader) {\n this.xhr.setRequestHeader('Content-Type', 'application/json'); // ReactNative doesn't set this header by default.\n }\n this.xhr.send(payload);\n }\n\n close() {\n if (this.unloader) {\n Runtime.removeUnloadListener(this.unloader);\n this.unloader = null;\n }\n if (this.xhr) {\n this.hooks.abortRequest(this.xhr);\n this.xhr = null;\n }\n }\n\n onChunk(status: number, data: any) {\n while (true) {\n var chunk = this.advanceBuffer(data);\n if (chunk) {\n this.emit('chunk', { status: status, data: chunk });\n } else {\n break;\n }\n }\n if (this.isBufferTooLong(data)) {\n this.emit('buffer_too_long');\n }\n }\n\n private advanceBuffer(buffer: any[]): any {\n var unreadData = buffer.slice(this.position);\n var endOfLinePosition = unreadData.indexOf('\\n');\n\n if (endOfLinePosition !== -1) {\n this.position += endOfLinePosition + 1;\n return unreadData.slice(0, endOfLinePosition);\n } else {\n // chunk is not finished yet, don't move the buffer pointer\n return null;\n }\n }\n\n private isBufferTooLong(buffer: any): boolean {\n return this.position === buffer.length && buffer.length > MAX_BUFFER_LENGTH;\n }\n}\n","enum State {\n CONNECTING = 0,\n OPEN = 1,\n CLOSED = 3\n}\n\nexport default State;\n","import URLLocation from './url_location';\nimport State from './state';\nimport Socket from '../socket';\nimport SocketHooks from './socket_hooks';\nimport Util from '../util';\nimport Ajax from './ajax';\nimport HTTPRequest from './http_request';\nimport Runtime from 'runtime';\n\nvar autoIncrement = 1;\n\nclass HTTPSocket implements Socket {\n hooks: SocketHooks;\n session: string;\n location: URLLocation;\n readyState: State;\n stream: HTTPRequest;\n\n onopen: () => void;\n onerror: (error: any) => void;\n onclose: (closeEvent: any) => void;\n onmessage: (message: any) => void;\n onactivity: () => void;\n\n constructor(hooks: SocketHooks, url: string) {\n this.hooks = hooks;\n this.session = randomNumber(1000) + '/' + randomString(8);\n this.location = getLocation(url);\n this.readyState = State.CONNECTING;\n this.openStream();\n }\n\n send(payload: any) {\n return this.sendRaw(JSON.stringify([payload]));\n }\n\n ping() {\n this.hooks.sendHeartbeat(this);\n }\n\n close(code: any, reason: any) {\n this.onClose(code, reason, true);\n }\n\n /** For internal use only */\n sendRaw(payload: any): boolean {\n if (this.readyState === State.OPEN) {\n try {\n Runtime.createSocketRequest(\n 'POST',\n getUniqueURL(getSendURL(this.location, this.session))\n ).start(payload);\n return true;\n } catch (e) {\n return false;\n }\n } else {\n return false;\n }\n }\n\n /** For internal use only */\n reconnect() {\n this.closeStream();\n this.openStream();\n }\n\n /** For internal use only */\n onClose(code, reason, wasClean) {\n this.closeStream();\n this.readyState = State.CLOSED;\n if (this.onclose) {\n this.onclose({\n code: code,\n reason: reason,\n wasClean: wasClean\n });\n }\n }\n\n private onChunk(chunk) {\n if (chunk.status !== 200) {\n return;\n }\n if (this.readyState === State.OPEN) {\n this.onActivity();\n }\n\n var payload;\n var type = chunk.data.slice(0, 1);\n switch (type) {\n case 'o':\n payload = JSON.parse(chunk.data.slice(1) || '{}');\n this.onOpen(payload);\n break;\n case 'a':\n payload = JSON.parse(chunk.data.slice(1) || '[]');\n for (var i = 0; i < payload.length; i++) {\n this.onEvent(payload[i]);\n }\n break;\n case 'm':\n payload = JSON.parse(chunk.data.slice(1) || 'null');\n this.onEvent(payload);\n break;\n case 'h':\n this.hooks.onHeartbeat(this);\n break;\n case 'c':\n payload = JSON.parse(chunk.data.slice(1) || '[]');\n this.onClose(payload[0], payload[1], true);\n break;\n }\n }\n\n private onOpen(options) {\n if (this.readyState === State.CONNECTING) {\n if (options && options.hostname) {\n this.location.base = replaceHost(this.location.base, options.hostname);\n }\n this.readyState = State.OPEN;\n\n if (this.onopen) {\n this.onopen();\n }\n } else {\n this.onClose(1006, 'Server lost session', true);\n }\n }\n\n private onEvent(event) {\n if (this.readyState === State.OPEN && this.onmessage) {\n this.onmessage({ data: event });\n }\n }\n\n private onActivity() {\n if (this.onactivity) {\n this.onactivity();\n }\n }\n\n private onError(error) {\n if (this.onerror) {\n this.onerror(error);\n }\n }\n\n private openStream() {\n this.stream = Runtime.createSocketRequest(\n 'POST',\n getUniqueURL(this.hooks.getReceiveURL(this.location, this.session))\n );\n\n this.stream.bind('chunk', chunk => {\n this.onChunk(chunk);\n });\n this.stream.bind('finished', status => {\n this.hooks.onFinished(this, status);\n });\n this.stream.bind('buffer_too_long', () => {\n this.reconnect();\n });\n\n try {\n this.stream.start();\n } catch (error) {\n Util.defer(() => {\n this.onError(error);\n this.onClose(1006, 'Could not start streaming', false);\n });\n }\n }\n\n private closeStream() {\n if (this.stream) {\n this.stream.unbind_all();\n this.stream.close();\n this.stream = null;\n }\n }\n}\n\nfunction getLocation(url): URLLocation {\n var parts = /([^\\?]*)\\/*(\\??.*)/.exec(url);\n return {\n base: parts[1],\n queryString: parts[2]\n };\n}\n\nfunction getSendURL(url: URLLocation, session: string): string {\n return url.base + '/' + session + '/xhr_send';\n}\n\nfunction getUniqueURL(url: string): string {\n var separator = url.indexOf('?') === -1 ? '?' : '&';\n return url + separator + 't=' + +new Date() + '&n=' + autoIncrement++;\n}\n\nfunction replaceHost(url: string, hostname: string): string {\n var urlParts = /(https?:\\/\\/)([^\\/:]+)((\\/|:)?.*)/.exec(url);\n return urlParts[1] + hostname + urlParts[3];\n}\n\nfunction randomNumber(max: number): number {\n return Runtime.randomInt(max);\n}\n\nfunction randomString(length: number): string {\n var result = [];\n\n for (var i = 0; i < length; i++) {\n result.push(randomNumber(32).toString(32));\n }\n\n return result.join('');\n}\n\nexport default HTTPSocket;\n","import SocketHooks from './socket_hooks';\nimport HTTPSocket from './http_socket';\n\nvar hooks: SocketHooks = {\n getReceiveURL: function(url, session) {\n return url.base + '/' + session + '/xhr_streaming' + url.queryString;\n },\n onHeartbeat: function(socket) {\n socket.sendRaw('[]');\n },\n sendHeartbeat: function(socket) {\n socket.sendRaw('[]');\n },\n onFinished: function(socket, status) {\n socket.onClose(1006, 'Connection interrupted (' + status + ')', false);\n }\n};\n\nexport default hooks;\n","import SocketHooks from './socket_hooks';\nimport URLLocation from './url_location';\nimport HTTPSocket from './http_socket';\n\nvar hooks: SocketHooks = {\n getReceiveURL: function(url: URLLocation, session: string): string {\n return url.base + '/' + session + '/xhr' + url.queryString;\n },\n onHeartbeat: function() {\n // next HTTP request will reset server's activity timer\n },\n sendHeartbeat: function(socket) {\n socket.sendRaw('[]');\n },\n onFinished: function(socket, status) {\n if (status === 200) {\n socket.reconnect();\n } else {\n socket.onClose(1006, 'Connection interrupted (' + status + ')', false);\n }\n }\n};\n\nexport default hooks;\n","import HTTPRequest from 'core/http/http_request';\nimport RequestHooks from 'core/http/request_hooks';\nimport Ajax from 'core/http/ajax';\nimport Runtime from 'runtime';\n\nvar hooks: RequestHooks = {\n getRequest: function(socket: HTTPRequest): Ajax {\n var Constructor = Runtime.getXHRAPI();\n var xhr = new Constructor();\n xhr.onreadystatechange = xhr.onprogress = function() {\n switch (xhr.readyState) {\n case 3:\n if (xhr.responseText && xhr.responseText.length > 0) {\n socket.onChunk(xhr.status, xhr.responseText);\n }\n break;\n case 4:\n // this happens only on errors, never after calling close\n if (xhr.responseText && xhr.responseText.length > 0) {\n socket.onChunk(xhr.status, xhr.responseText);\n }\n socket.emit('finished', xhr.status);\n socket.close();\n break;\n }\n };\n return xhr;\n },\n abortRequest: function(xhr: Ajax) {\n xhr.onreadystatechange = null;\n xhr.abort();\n }\n};\n\nexport default hooks;\n","import HTTPRequest from 'core/http/http_request';\nimport HTTPSocket from 'core/http/http_socket';\nimport SocketHooks from 'core/http/socket_hooks';\nimport RequestHooks from 'core/http/request_hooks';\nimport streamingHooks from 'core/http/http_streaming_socket';\nimport pollingHooks from 'core/http/http_polling_socket';\nimport xhrHooks from './http_xhr_request';\nimport HTTPFactory from 'core/http/http_factory';\n\nvar HTTP: HTTPFactory = {\n createStreamingSocket(url: string): HTTPSocket {\n return this.createSocket(streamingHooks, url);\n },\n\n createPollingSocket(url: string): HTTPSocket {\n return this.createSocket(pollingHooks, url);\n },\n\n createSocket(hooks: SocketHooks, url: string): HTTPSocket {\n return new HTTPSocket(hooks, url);\n },\n\n createXHR(method: string, url: string): HTTPRequest {\n return this.createRequest(xhrHooks, method, url);\n },\n\n createRequest(hooks: RequestHooks, method: string, url: string): HTTPRequest {\n return new HTTPRequest(hooks, method, url);\n }\n};\n\nexport default HTTP;\n","import * as Collections from 'core/utils/collections';\nimport Transports from 'isomorphic/transports/transports';\nimport TimelineSender from 'core/timeline/timeline_sender';\nimport Ajax from 'core/http/ajax';\nimport getDefaultStrategy from './default_strategy';\nimport TransportsTable from 'core/transports/transports_table';\nimport transportConnectionInitializer from './transports/transport_connection_initializer';\nimport HTTPFactory from './http/http';\n\nvar Isomorphic: any = {\n getDefaultStrategy,\n Transports: Transports,\n transportConnectionInitializer,\n HTTPFactory,\n\n setup(PusherClass): void {\n PusherClass.ready();\n },\n\n getLocalStorage(): any {\n return undefined;\n },\n\n getClientFeatures(): any[] {\n return Collections.keys(\n Collections.filterObject({ ws: Transports.ws }, function(t) {\n return t.isSupported({});\n })\n );\n },\n\n getProtocol(): string {\n return 'http:';\n },\n\n isXHRSupported(): boolean {\n return true;\n },\n\n createSocketRequest(method: string, url: string) {\n if (this.isXHRSupported()) {\n return this.HTTPFactory.createXHR(method, url);\n } else {\n throw 'Cross-origin HTTP requests are not supported';\n }\n },\n\n createXHR(): Ajax {\n var Constructor = this.getXHRAPI();\n return new Constructor();\n },\n\n createWebSocket(url: string): any {\n var Constructor = this.getWebSocketAPI();\n return new Constructor(url);\n },\n\n addUnloadListener(listener: any) {},\n removeUnloadListener(listener: any) {}\n};\n\nexport default Isomorphic;\n","import { default as EventsDispatcher } from 'core/events/dispatcher';\nimport Reachability from 'core/reachability';\n\nexport class NetInfo extends EventsDispatcher implements Reachability {\n isOnline(): boolean {\n return true;\n }\n}\n\nexport var Network = new NetInfo();\n","export enum AuthRequestType {\n UserAuthentication = 'user-authentication',\n ChannelAuthorization = 'channel-authorization'\n}\n\nexport interface ChannelAuthorizationData {\n auth: string;\n channel_data?: string;\n shared_secret?: string;\n}\n\nexport type ChannelAuthorizationCallback = (\n error: Error | null,\n authData: ChannelAuthorizationData | null\n) => void;\n\nexport interface ChannelAuthorizationRequestParams {\n socketId: string;\n channelName: string;\n}\n\nexport interface ChannelAuthorizationHandler {\n (\n params: ChannelAuthorizationRequestParams,\n callback: ChannelAuthorizationCallback\n ): void;\n}\n\nexport interface UserAuthenticationData {\n auth: string;\n user_data: string;\n}\n\nexport type UserAuthenticationCallback = (\n error: Error | null,\n authData: UserAuthenticationData | null\n) => void;\n\nexport interface UserAuthenticationRequestParams {\n socketId: string;\n}\n\nexport interface UserAuthenticationHandler {\n (\n params: UserAuthenticationRequestParams,\n callback: UserAuthenticationCallback\n ): void;\n}\n\nexport type AuthTransportCallback =\n | ChannelAuthorizationCallback\n | UserAuthenticationCallback;\n\nexport interface InternalAuthOptions {\n transport: 'ajax' | 'jsonp';\n endpoint: string;\n params?: any;\n headers?: any;\n paramsProvider?: () => any;\n headersProvider?: () => any;\n}\n\nexport type CustomAuthOptions = {\n customHandler: AuthHandler;\n};\n\nexport type AuthOptionsT =\n | InternalAuthOptions\n | CustomAuthOptions;\n\nexport declare type UserAuthenticationOptions = AuthOptionsT<\n UserAuthenticationHandler\n>;\nexport declare type ChannelAuthorizationOptions = AuthOptionsT<\n ChannelAuthorizationHandler\n>;\n","import TimelineSender from 'core/timeline/timeline_sender';\nimport * as Collections from 'core/utils/collections';\nimport Util from 'core/util';\nimport Runtime from 'runtime';\nimport { AuthTransport } from 'core/auth/auth_transports';\nimport AbstractRuntime from 'runtimes/interface';\nimport UrlStore from 'core/utils/url_store';\nimport {\n AuthRequestType,\n AuthTransportCallback,\n InternalAuthOptions\n} from 'core/auth/options';\nimport { HTTPAuthError } from 'core/errors';\n\nconst ajax: AuthTransport = function(\n context: AbstractRuntime,\n query: string,\n authOptions: InternalAuthOptions,\n authRequestType: AuthRequestType,\n callback: AuthTransportCallback\n) {\n const xhr = Runtime.createXHR();\n xhr.open('POST', authOptions.endpoint, true);\n\n // add request headers\n xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');\n for (var headerName in authOptions.headers) {\n xhr.setRequestHeader(headerName, authOptions.headers[headerName]);\n }\n if (authOptions.headersProvider != null) {\n let dynamicHeaders = authOptions.headersProvider();\n for (var headerName in dynamicHeaders) {\n xhr.setRequestHeader(headerName, dynamicHeaders[headerName]);\n }\n }\n\n xhr.onreadystatechange = function() {\n if (xhr.readyState === 4) {\n if (xhr.status === 200) {\n let data;\n let parsed = false;\n\n try {\n data = JSON.parse(xhr.responseText);\n parsed = true;\n } catch (e) {\n callback(\n new HTTPAuthError(\n 200,\n `JSON returned from ${authRequestType.toString()} endpoint was invalid, yet status code was 200. Data was: ${\n xhr.responseText\n }`\n ),\n null\n );\n }\n\n if (parsed) {\n // prevents double execution.\n callback(null, data);\n }\n } else {\n let suffix = '';\n switch (authRequestType) {\n case AuthRequestType.UserAuthentication:\n suffix = UrlStore.buildLogSuffix('authenticationEndpoint');\n break;\n case AuthRequestType.ChannelAuthorization:\n suffix = `Clients must be authorized to join private or presence channels. ${UrlStore.buildLogSuffix(\n 'authorizationEndpoint'\n )}`;\n break;\n }\n callback(\n new HTTPAuthError(\n xhr.status,\n `Unable to retrieve auth string from ${authRequestType.toString()} endpoint - ` +\n `received status: ${xhr.status} from ${authOptions.endpoint}. ${suffix}`\n ),\n null\n );\n }\n }\n };\n\n xhr.send(query);\n return xhr;\n};\n\nexport default ajax;\n","import Logger from 'core/logger';\nimport TimelineSender from 'core/timeline/timeline_sender';\nimport * as Collections from 'core/utils/collections';\nimport Util from 'core/util';\nimport Runtime from 'runtime';\nimport TimelineTransport from 'core/timeline/timeline_transport';\n\nvar getAgent = function(sender: TimelineSender, useTLS: boolean) {\n return function(data: any, callback: Function) {\n var scheme = 'http' + (useTLS ? 's' : '') + '://';\n var url =\n scheme + (sender.host || sender.options.host) + sender.options.path;\n var query = Collections.buildQueryString(data);\n\n url += '/' + 2 + '?' + query;\n\n var xhr = Runtime.createXHR();\n xhr.open('GET', url, true);\n\n xhr.onreadystatechange = function() {\n if (xhr.readyState === 4) {\n let { status, responseText } = xhr;\n if (status !== 200) {\n Logger.debug(\n `TimelineSender Error: received ${status} from stats.pusher.com`\n );\n return;\n }\n\n try {\n var { host } = JSON.parse(responseText);\n } catch (e) {\n Logger.debug(`TimelineSenderError: invalid response ${responseText}`);\n }\n if (host) {\n sender.host = host;\n }\n }\n };\n\n xhr.send();\n };\n};\n\nvar xhr = {\n name: 'xhr',\n getAgent\n};\n\nexport default xhr;\n","import Isomorphic from 'isomorphic/runtime';\nimport { Client as WebSocket } from 'faye-websocket';\nimport { XMLHttpRequest } from 'xmlhttprequest';\nimport Runtime from '../interface';\nimport { Network } from './net_info';\nimport xhrAuth from 'isomorphic/auth/xhr_auth';\nimport { AuthTransports } from 'core/auth/auth_transports';\nimport xhrTimeline from 'isomorphic/timeline/xhr_timeline';\nimport { randomInt } from 'crypto';\n\n// Very verbose but until unavoidable until\n// TypeScript 2.1, when spread attributes will be\n// supported\nconst {\n getDefaultStrategy,\n Transports,\n setup,\n getProtocol,\n isXHRSupported,\n getLocalStorage,\n createXHR,\n createWebSocket,\n addUnloadListener,\n removeUnloadListener,\n transportConnectionInitializer,\n createSocketRequest,\n HTTPFactory\n} = Isomorphic;\n\nconst NodeJS: Runtime = {\n getDefaultStrategy,\n Transports,\n setup,\n getProtocol,\n isXHRSupported,\n createSocketRequest,\n getLocalStorage,\n createXHR,\n createWebSocket,\n addUnloadListener,\n removeUnloadListener,\n transportConnectionInitializer,\n HTTPFactory,\n\n TimelineTransport: xhrTimeline,\n\n getAuthorizers(): AuthTransports {\n return { ajax: xhrAuth };\n },\n\n getWebSocketAPI() {\n return WebSocket;\n },\n\n getXHRAPI() {\n return XMLHttpRequest;\n },\n\n getNetwork() {\n return Network;\n },\n\n randomInt(max: number): number {\n return randomInt(max);\n }\n};\n\nexport default NodeJS;\n","enum TimelineLevel {\n ERROR = 3,\n INFO = 6,\n DEBUG = 7\n}\n\nexport default TimelineLevel;\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport { default as Level } from './level';\n\nexport interface TimelineOptions {\n level?: Level;\n limit?: number;\n version?: string;\n cluster?: string;\n features?: string[];\n params?: any;\n}\n\nexport default class Timeline {\n key: string;\n session: number;\n events: any[];\n options: TimelineOptions;\n sent: number;\n uniqueID: number;\n\n constructor(key: string, session: number, options: TimelineOptions) {\n this.key = key;\n this.session = session;\n this.events = [];\n this.options = options || {};\n this.sent = 0;\n this.uniqueID = 0;\n }\n\n log(level, event) {\n if (level <= this.options.level) {\n this.events.push(\n Collections.extend({}, event, { timestamp: Util.now() })\n );\n if (this.options.limit && this.events.length > this.options.limit) {\n this.events.shift();\n }\n }\n }\n\n error(event) {\n this.log(Level.ERROR, event);\n }\n\n info(event) {\n this.log(Level.INFO, event);\n }\n\n debug(event) {\n this.log(Level.DEBUG, event);\n }\n\n isEmpty() {\n return this.events.length === 0;\n }\n\n send(sendfn, callback) {\n var data = Collections.extend(\n {\n session: this.session,\n bundle: this.sent + 1,\n key: this.key,\n lib: 'js',\n version: this.options.version,\n cluster: this.options.cluster,\n features: this.options.features,\n timeline: this.events\n },\n this.options.params\n );\n\n this.events = [];\n sendfn(data, (error, result) => {\n if (!error) {\n this.sent++;\n }\n if (callback) {\n callback(error, result);\n }\n });\n\n return true;\n }\n\n generateUniqueID(): number {\n this.uniqueID++;\n return this.uniqueID;\n }\n}\n","import Factory from '../utils/factory';\nimport Util from '../util';\nimport * as Errors from '../errors';\nimport * as Collections from '../utils/collections';\nimport Strategy from './strategy';\nimport Transport from '../transports/transport';\nimport StrategyOptions from './strategy_options';\nimport Handshake from '../connection/handshake';\n\n/** Provides a strategy interface for transports.\n *\n * @param {String} name\n * @param {Number} priority\n * @param {Class} transport\n * @param {Object} options\n */\nexport default class TransportStrategy implements Strategy {\n name: string;\n priority: number;\n transport: Transport;\n options: StrategyOptions;\n\n constructor(\n name: string,\n priority: number,\n transport: Transport,\n options: StrategyOptions\n ) {\n this.name = name;\n this.priority = priority;\n this.transport = transport;\n this.options = options || {};\n }\n\n /** Returns whether the transport is supported in the browser.\n *\n * @returns {Boolean}\n */\n isSupported(): boolean {\n return this.transport.isSupported({\n useTLS: this.options.useTLS\n });\n }\n\n /** Launches a connection attempt and returns a strategy runner.\n *\n * @param {Function} callback\n * @return {Object} strategy runner\n */\n connect(minPriority: number, callback: Function) {\n if (!this.isSupported()) {\n return failAttempt(new Errors.UnsupportedStrategy(), callback);\n } else if (this.priority < minPriority) {\n return failAttempt(new Errors.TransportPriorityTooLow(), callback);\n }\n\n var connected = false;\n var transport = this.transport.createConnection(\n this.name,\n this.priority,\n this.options.key,\n this.options\n );\n var handshake = null;\n\n var onInitialized = function() {\n transport.unbind('initialized', onInitialized);\n transport.connect();\n };\n var onOpen = function() {\n handshake = Factory.createHandshake(transport, function(result) {\n connected = true;\n unbindListeners();\n callback(null, result);\n });\n };\n var onError = function(error) {\n unbindListeners();\n callback(error);\n };\n var onClosed = function() {\n unbindListeners();\n var serializedTransport;\n\n // The reason for this try/catch block is that on React Native\n // the WebSocket object is circular. Therefore transport.socket will\n // throw errors upon stringification. Collections.safeJSONStringify\n // discards circular references when serializing.\n serializedTransport = Collections.safeJSONStringify(transport);\n callback(new Errors.TransportClosed(serializedTransport));\n };\n\n var unbindListeners = function() {\n transport.unbind('initialized', onInitialized);\n transport.unbind('open', onOpen);\n transport.unbind('error', onError);\n transport.unbind('closed', onClosed);\n };\n\n transport.bind('initialized', onInitialized);\n transport.bind('open', onOpen);\n transport.bind('error', onError);\n transport.bind('closed', onClosed);\n\n // connect will be called automatically after initialization\n transport.initialize();\n\n return {\n abort: () => {\n if (connected) {\n return;\n }\n unbindListeners();\n if (handshake) {\n handshake.close();\n } else {\n transport.close();\n }\n },\n forceMinPriority: p => {\n if (connected) {\n return;\n }\n if (this.priority < p) {\n if (handshake) {\n handshake.close();\n } else {\n transport.close();\n }\n }\n }\n };\n }\n}\n\nfunction failAttempt(error: Error, callback: Function) {\n Util.defer(function() {\n callback(error);\n });\n return {\n abort: function() {},\n forceMinPriority: function() {}\n };\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport TransportManager from '../transports/transport_manager';\nimport * as Errors from '../errors';\nimport Strategy from './strategy';\nimport TransportStrategy from './transport_strategy';\nimport StrategyOptions from '../strategies/strategy_options';\nimport { Config } from '../config';\nimport Runtime from 'runtime';\n\nconst { Transports } = Runtime;\n\nexport var defineTransport = function(\n config: Config,\n name: string,\n type: string,\n priority: number,\n options: StrategyOptions,\n manager?: TransportManager\n): Strategy {\n var transportClass = Transports[type];\n if (!transportClass) {\n throw new Errors.UnsupportedTransport(type);\n }\n\n var enabled =\n (!config.enabledTransports ||\n Collections.arrayIndexOf(config.enabledTransports, name) !== -1) &&\n (!config.disabledTransports ||\n Collections.arrayIndexOf(config.disabledTransports, name) === -1);\n\n var transport;\n if (enabled) {\n options = Object.assign(\n { ignoreNullOrigin: config.ignoreNullOrigin },\n options\n );\n\n transport = new TransportStrategy(\n name,\n priority,\n manager ? manager.getAssistant(transportClass) : transportClass,\n options\n );\n } else {\n transport = UnsupportedStrategy;\n }\n\n return transport;\n};\n\nvar UnsupportedStrategy: Strategy = {\n isSupported: function() {\n return false;\n },\n connect: function(_, callback) {\n var deferred = Util.defer(function() {\n callback(new Errors.UnsupportedStrategy());\n });\n return {\n abort: function() {\n deferred.ensureAborted();\n },\n forceMinPriority: function() {}\n };\n }\n};\n","import ConnectionManager from './connection/connection_manager';\nimport {\n ChannelAuthorizationOptions,\n UserAuthenticationOptions\n} from './auth/options';\nimport {\n ChannelAuthorizerGenerator,\n DeprecatedAuthOptions\n} from './auth/deprecated_channel_authorizer';\nimport { AuthTransport, Transport } from './config';\nimport * as nacl from 'tweetnacl';\nimport Logger from './logger';\n\nexport interface Options {\n activityTimeout?: number;\n\n auth?: DeprecatedAuthOptions; // DEPRECATED use channelAuthorization instead\n authEndpoint?: string; // DEPRECATED use channelAuthorization instead\n authTransport?: AuthTransport; // DEPRECATED use channelAuthorization instead\n authorizer?: ChannelAuthorizerGenerator; // DEPRECATED use channelAuthorization instead\n\n channelAuthorization?: ChannelAuthorizationOptions;\n userAuthentication?: UserAuthenticationOptions;\n\n cluster: string;\n enableStats?: boolean;\n disableStats?: boolean;\n disabledTransports?: Transport[];\n enabledTransports?: Transport[];\n forceTLS?: boolean;\n httpHost?: string;\n httpPath?: string;\n httpPort?: number;\n httpsPort?: number;\n ignoreNullOrigin?: boolean;\n nacl?: nacl;\n pongTimeout?: number;\n statsHost?: string;\n timelineParams?: any;\n unavailableTimeout?: number;\n wsHost?: string;\n wsPath?: string;\n wsPort?: number;\n wssPort?: number;\n}\n\nexport interface ClusterOptions {\n appKey: string;\n cluster: string;\n}\n\nexport function validateOptions(options) {\n if (options == null) {\n throw 'You must pass an options object';\n }\n if (options.cluster == null) {\n throw 'Options object must provide a cluster';\n }\n if ('disableStats' in options) {\n Logger.warn(\n 'The disableStats option is deprecated in favor of enableStats'\n );\n }\n}\n","import {\n UserAuthenticationCallback,\n InternalAuthOptions,\n UserAuthenticationHandler,\n UserAuthenticationRequestParams,\n AuthRequestType\n} from './options';\n\nimport Runtime from 'runtime';\n\nconst composeChannelQuery = (\n params: UserAuthenticationRequestParams,\n authOptions: InternalAuthOptions\n) => {\n var query = 'socket_id=' + encodeURIComponent(params.socketId);\n\n for (var key in authOptions.params) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(authOptions.params[key]);\n }\n\n if (authOptions.paramsProvider != null) {\n let dynamicParams = authOptions.paramsProvider();\n for (var key in dynamicParams) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(dynamicParams[key]);\n }\n }\n\n return query;\n};\n\nconst UserAuthenticator = (\n authOptions: InternalAuthOptions\n): UserAuthenticationHandler => {\n if (typeof Runtime.getAuthorizers()[authOptions.transport] === 'undefined') {\n throw `'${authOptions.transport}' is not a recognized auth transport`;\n }\n\n return (\n params: UserAuthenticationRequestParams,\n callback: UserAuthenticationCallback\n ) => {\n const query = composeChannelQuery(params, authOptions);\n\n Runtime.getAuthorizers()[authOptions.transport](\n Runtime,\n query,\n authOptions,\n AuthRequestType.UserAuthentication,\n callback\n );\n };\n};\n\nexport default UserAuthenticator;\n","import {\n AuthRequestType,\n InternalAuthOptions,\n ChannelAuthorizationHandler,\n ChannelAuthorizationRequestParams,\n ChannelAuthorizationCallback\n} from './options';\n\nimport Runtime from 'runtime';\n\nconst composeChannelQuery = (\n params: ChannelAuthorizationRequestParams,\n authOptions: InternalAuthOptions\n) => {\n var query = 'socket_id=' + encodeURIComponent(params.socketId);\n\n query += '&channel_name=' + encodeURIComponent(params.channelName);\n\n for (var key in authOptions.params) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(authOptions.params[key]);\n }\n\n if (authOptions.paramsProvider != null) {\n let dynamicParams = authOptions.paramsProvider();\n for (var key in dynamicParams) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(dynamicParams[key]);\n }\n }\n\n return query;\n};\n\nconst ChannelAuthorizer = (\n authOptions: InternalAuthOptions\n): ChannelAuthorizationHandler => {\n if (typeof Runtime.getAuthorizers()[authOptions.transport] === 'undefined') {\n throw `'${authOptions.transport}' is not a recognized auth transport`;\n }\n\n return (\n params: ChannelAuthorizationRequestParams,\n callback: ChannelAuthorizationCallback\n ) => {\n const query = composeChannelQuery(params, authOptions);\n\n Runtime.getAuthorizers()[authOptions.transport](\n Runtime,\n query,\n authOptions,\n AuthRequestType.ChannelAuthorization,\n callback\n );\n };\n};\n\nexport default ChannelAuthorizer;\n","import Channel from '../channels/channel';\nimport {\n ChannelAuthorizationCallback,\n ChannelAuthorizationHandler,\n ChannelAuthorizationRequestParams,\n InternalAuthOptions\n} from './options';\n\nexport interface DeprecatedChannelAuthorizer {\n authorize(socketId: string, callback: ChannelAuthorizationCallback): void;\n}\n\nexport interface ChannelAuthorizerGenerator {\n (\n channel: Channel,\n options: DeprecatedAuthorizerOptions\n ): DeprecatedChannelAuthorizer;\n}\n\nexport interface DeprecatedAuthOptions {\n params?: any;\n headers?: any;\n}\n\nexport interface DeprecatedAuthorizerOptions {\n authTransport: 'ajax' | 'jsonp';\n authEndpoint: string;\n auth?: DeprecatedAuthOptions;\n}\n\nexport const ChannelAuthorizerProxy = (\n pusher,\n authOptions: InternalAuthOptions,\n channelAuthorizerGenerator: ChannelAuthorizerGenerator\n): ChannelAuthorizationHandler => {\n const deprecatedAuthorizerOptions: DeprecatedAuthorizerOptions = {\n authTransport: authOptions.transport,\n authEndpoint: authOptions.endpoint,\n auth: {\n params: authOptions.params,\n headers: authOptions.headers\n }\n };\n return (\n params: ChannelAuthorizationRequestParams,\n callback: ChannelAuthorizationCallback\n ) => {\n const channel = pusher.channel(params.channelName);\n // This line creates a new channel authorizer every time.\n // In the past, this was only done once per channel and reused.\n // We can do that again if we want to keep this behavior intact.\n const channelAuthorizer: DeprecatedChannelAuthorizer = channelAuthorizerGenerator(\n channel,\n deprecatedAuthorizerOptions\n );\n channelAuthorizer.authorize(params.socketId, callback);\n };\n};\n","import { Options } from './options';\nimport Defaults from './defaults';\nimport {\n ChannelAuthorizationHandler,\n UserAuthenticationHandler,\n ChannelAuthorizationOptions,\n AuthOptionsT,\n CustomAuthOptions\n} from './auth/options';\nimport UserAuthenticator from './auth/user_authenticator';\nimport ChannelAuthorizer from './auth/channel_authorizer';\nimport { ChannelAuthorizerProxy } from './auth/deprecated_channel_authorizer';\nimport Runtime from 'runtime';\nimport * as nacl from 'tweetnacl';\n\nexport type AuthTransport = 'ajax' | 'jsonp';\nexport type Transport =\n | 'ws'\n | 'wss'\n | 'xhr_streaming'\n | 'xhr_polling'\n | 'sockjs';\n\nexport interface Config {\n // these are all 'required' config parameters, it's not necessary for the user\n // to set them, but they have configured defaults.\n activityTimeout: number;\n enableStats: boolean;\n httpHost: string;\n httpPath: string;\n httpPort: number;\n httpsPort: number;\n pongTimeout: number;\n statsHost: string;\n unavailableTimeout: number;\n useTLS: boolean;\n wsHost: string;\n wsPath: string;\n wsPort: number;\n wssPort: number;\n userAuthenticator: UserAuthenticationHandler;\n channelAuthorizer: ChannelAuthorizationHandler;\n\n // these are all optional parameters or overrrides. The customer can set these\n // but it's not strictly necessary\n forceTLS?: boolean;\n cluster?: string;\n disabledTransports?: Transport[];\n enabledTransports?: Transport[];\n ignoreNullOrigin?: boolean;\n nacl?: nacl;\n timelineParams?: any;\n}\n\n// getConfig mainly sets the defaults for the options that are not provided\nexport function getConfig(opts: Options, pusher): Config {\n let config: Config = {\n activityTimeout: opts.activityTimeout || Defaults.activityTimeout,\n cluster: opts.cluster,\n httpPath: opts.httpPath || Defaults.httpPath,\n httpPort: opts.httpPort || Defaults.httpPort,\n httpsPort: opts.httpsPort || Defaults.httpsPort,\n pongTimeout: opts.pongTimeout || Defaults.pongTimeout,\n statsHost: opts.statsHost || Defaults.stats_host,\n unavailableTimeout: opts.unavailableTimeout || Defaults.unavailableTimeout,\n wsPath: opts.wsPath || Defaults.wsPath,\n wsPort: opts.wsPort || Defaults.wsPort,\n wssPort: opts.wssPort || Defaults.wssPort,\n\n enableStats: getEnableStatsConfig(opts),\n httpHost: getHttpHost(opts),\n useTLS: shouldUseTLS(opts),\n wsHost: getWebsocketHost(opts),\n\n userAuthenticator: buildUserAuthenticator(opts),\n channelAuthorizer: buildChannelAuthorizer(opts, pusher)\n };\n\n if ('disabledTransports' in opts)\n config.disabledTransports = opts.disabledTransports;\n if ('enabledTransports' in opts)\n config.enabledTransports = opts.enabledTransports;\n if ('ignoreNullOrigin' in opts)\n config.ignoreNullOrigin = opts.ignoreNullOrigin;\n if ('timelineParams' in opts) config.timelineParams = opts.timelineParams;\n if ('nacl' in opts) {\n config.nacl = opts.nacl;\n }\n\n return config;\n}\n\nfunction getHttpHost(opts: Options): string {\n if (opts.httpHost) {\n return opts.httpHost;\n }\n if (opts.cluster) {\n return `sockjs-${opts.cluster}.pusher.com`;\n }\n return Defaults.httpHost;\n}\n\nfunction getWebsocketHost(opts: Options): string {\n if (opts.wsHost) {\n return opts.wsHost;\n }\n return getWebsocketHostFromCluster(opts.cluster);\n}\n\nfunction getWebsocketHostFromCluster(cluster: string): string {\n return `ws-${cluster}.pusher.com`;\n}\n\nfunction shouldUseTLS(opts: Options): boolean {\n if (Runtime.getProtocol() === 'https:') {\n return true;\n } else if (opts.forceTLS === false) {\n return false;\n }\n return true;\n}\n\n// if enableStats is set take the value\n// if disableStats is set take the inverse\n// otherwise default to false\nfunction getEnableStatsConfig(opts: Options): boolean {\n if ('enableStats' in opts) {\n return opts.enableStats;\n }\n if ('disableStats' in opts) {\n return !opts.disableStats;\n }\n return false;\n}\n\nconst hasCustomHandler = (\n auth: AuthOptionsT\n): auth is CustomAuthOptions => {\n return 'customHandler' in auth && auth['customHandler'] != null;\n};\n\nfunction buildUserAuthenticator(opts: Options): UserAuthenticationHandler {\n const userAuthentication = {\n ...Defaults.userAuthentication,\n ...opts.userAuthentication\n };\n\n if (hasCustomHandler(userAuthentication)) {\n return userAuthentication['customHandler'];\n }\n\n return UserAuthenticator(userAuthentication);\n}\n\nfunction buildChannelAuth(opts: Options, pusher): ChannelAuthorizationOptions {\n let channelAuthorization: ChannelAuthorizationOptions;\n if ('channelAuthorization' in opts) {\n channelAuthorization = {\n ...Defaults.channelAuthorization,\n ...opts.channelAuthorization\n };\n } else {\n channelAuthorization = {\n transport: opts.authTransport || Defaults.authTransport,\n endpoint: opts.authEndpoint || Defaults.authEndpoint\n };\n\n if ('auth' in opts) {\n if ('params' in opts.auth) channelAuthorization.params = opts.auth.params;\n if ('headers' in opts.auth)\n channelAuthorization.headers = opts.auth.headers;\n }\n\n if ('authorizer' in opts) {\n return {\n customHandler: ChannelAuthorizerProxy(\n pusher,\n channelAuthorization,\n opts.authorizer\n )\n };\n }\n }\n return channelAuthorization;\n}\n\nfunction buildChannelAuthorizer(\n opts: Options,\n pusher\n): ChannelAuthorizationHandler {\n const channelAuthorization = buildChannelAuth(opts, pusher);\n\n if (hasCustomHandler(channelAuthorization)) {\n return channelAuthorization['customHandler'];\n }\n\n return ChannelAuthorizer(channelAuthorization);\n}\n","import Logger from './logger';\nimport Pusher from './pusher';\nimport EventsDispatcher from './events/dispatcher';\n\nexport default class WatchlistFacade extends EventsDispatcher {\n private pusher: Pusher;\n\n public constructor(pusher: Pusher) {\n super(function(eventName, data) {\n Logger.debug(`No callbacks on watchlist events for ${eventName}`);\n });\n\n this.pusher = pusher;\n this.bindWatchlistInternalEvent();\n }\n\n handleEvent(pusherEvent) {\n pusherEvent.data.events.forEach(watchlistEvent => {\n this.emit(watchlistEvent.name, watchlistEvent);\n });\n }\n\n private bindWatchlistInternalEvent() {\n this.pusher.connection.bind('message', pusherEvent => {\n var eventName = pusherEvent.event;\n if (eventName === 'pusher_internal:watchlist_events') {\n this.handleEvent(pusherEvent);\n }\n });\n }\n}\n","function flatPromise() {\n let resolve, reject;\n const promise = new Promise((res, rej) => {\n resolve = res;\n reject = rej;\n });\n return { promise, resolve, reject };\n}\n\nexport default flatPromise;\n","import Pusher from './pusher';\nimport Logger from './logger';\nimport {\n UserAuthenticationData,\n UserAuthenticationCallback\n} from './auth/options';\nimport Channel from './channels/channel';\nimport WatchlistFacade from './watchlist';\nimport EventsDispatcher from './events/dispatcher';\nimport flatPromise from './utils/flat_promise';\n\nexport default class UserFacade extends EventsDispatcher {\n pusher: Pusher;\n signin_requested: boolean = false;\n user_data: any = null;\n serverToUserChannel: Channel = null;\n signinDonePromise: Promise = null;\n watchlist: WatchlistFacade;\n private _signinDoneResolve: Function = null;\n\n public constructor(pusher: Pusher) {\n super(function(eventName, data) {\n Logger.debug('No callbacks on user for ' + eventName);\n });\n this.pusher = pusher;\n this.pusher.connection.bind('state_change', ({ previous, current }) => {\n if (previous !== 'connected' && current === 'connected') {\n this._signin();\n }\n if (previous === 'connected' && current !== 'connected') {\n this._cleanup();\n this._newSigninPromiseIfNeeded();\n }\n });\n\n this.watchlist = new WatchlistFacade(pusher);\n\n this.pusher.connection.bind('message', event => {\n var eventName = event.event;\n if (eventName === 'pusher:signin_success') {\n this._onSigninSuccess(event.data);\n }\n if (\n this.serverToUserChannel &&\n this.serverToUserChannel.name === event.channel\n ) {\n this.serverToUserChannel.handleEvent(event);\n }\n });\n }\n\n public signin() {\n if (this.signin_requested) {\n return;\n }\n\n this.signin_requested = true;\n this._signin();\n }\n\n private _signin() {\n if (!this.signin_requested) {\n return;\n }\n\n this._newSigninPromiseIfNeeded();\n\n if (this.pusher.connection.state !== 'connected') {\n // Signin will be attempted when the connection is connected\n return;\n }\n\n this.pusher.config.userAuthenticator(\n {\n socketId: this.pusher.connection.socket_id\n },\n this._onAuthorize\n );\n }\n\n private _onAuthorize: UserAuthenticationCallback = (\n err,\n authData: UserAuthenticationData\n ) => {\n if (err) {\n Logger.warn(`Error during signin: ${err}`);\n this._cleanup();\n return;\n }\n\n this.pusher.send_event('pusher:signin', {\n auth: authData.auth,\n user_data: authData.user_data\n });\n\n // Later when we get pusher:singin_success event, the user will be marked as signed in\n };\n\n private _onSigninSuccess(data: any) {\n try {\n this.user_data = JSON.parse(data.user_data);\n } catch (e) {\n Logger.error(`Failed parsing user data after signin: ${data.user_data}`);\n this._cleanup();\n return;\n }\n\n if (typeof this.user_data.id !== 'string' || this.user_data.id === '') {\n Logger.error(\n `user_data doesn't contain an id. user_data: ${this.user_data}`\n );\n this._cleanup();\n return;\n }\n\n // Signin succeeded\n this._signinDoneResolve();\n this._subscribeChannels();\n }\n\n private _subscribeChannels() {\n const ensure_subscribed = channel => {\n if (channel.subscriptionPending && channel.subscriptionCancelled) {\n channel.reinstateSubscription();\n } else if (\n !channel.subscriptionPending &&\n this.pusher.connection.state === 'connected'\n ) {\n channel.subscribe();\n }\n };\n\n this.serverToUserChannel = new Channel(\n `#server-to-user-${this.user_data.id}`,\n this.pusher\n );\n this.serverToUserChannel.bind_global((eventName, data) => {\n if (\n eventName.indexOf('pusher_internal:') === 0 ||\n eventName.indexOf('pusher:') === 0\n ) {\n // ignore internal events\n return;\n }\n this.emit(eventName, data);\n });\n ensure_subscribed(this.serverToUserChannel);\n }\n\n private _cleanup() {\n this.user_data = null;\n if (this.serverToUserChannel) {\n this.serverToUserChannel.unbind_all();\n this.serverToUserChannel.disconnect();\n this.serverToUserChannel = null;\n }\n\n if (this.signin_requested) {\n // If signin is in progress and cleanup is called,\n // Mark the current signin process as done.\n this._signinDoneResolve();\n }\n }\n\n private _newSigninPromiseIfNeeded() {\n if (!this.signin_requested) {\n return;\n }\n\n // If there is a promise and it is not resolved, return without creating a new one.\n if (this.signinDonePromise && !(this.signinDonePromise as any).done) {\n return;\n }\n\n // This promise is never rejected.\n // It gets resolved when the signin process is done whether it failed or succeeded\n const { promise, resolve, reject: _ } = flatPromise();\n (promise as any).done = false;\n const setDone = () => {\n (promise as any).done = true;\n };\n promise.then(setDone).catch(setDone);\n this.signinDonePromise = promise;\n this._signinDoneResolve = resolve;\n }\n}\n","import AbstractRuntime from '../runtimes/interface';\nimport Runtime from 'runtime';\nimport * as Collections from './utils/collections';\nimport Channels from './channels/channels';\nimport Channel from './channels/channel';\nimport { default as EventsDispatcher } from './events/dispatcher';\nimport Timeline from './timeline/timeline';\nimport TimelineSender from './timeline/timeline_sender';\nimport TimelineLevel from './timeline/level';\nimport { defineTransport } from './strategies/strategy_builder';\nimport ConnectionManager from './connection/connection_manager';\nimport { PeriodicTimer } from './utils/timers';\nimport Defaults from './defaults';\nimport Logger from './logger';\nimport Factory from './utils/factory';\nimport { Options, ClusterOptions, validateOptions } from './options';\nimport { Config, getConfig } from './config';\nimport StrategyOptions from './strategies/strategy_options';\nimport UserFacade from './user';\n\nexport default class Pusher {\n /* STATIC PROPERTIES */\n static instances: Pusher[] = [];\n static isReady: boolean = false;\n static logToConsole: boolean = false;\n\n // for jsonp\n static Runtime: AbstractRuntime = Runtime;\n static ScriptReceivers: any = (Runtime).ScriptReceivers;\n static DependenciesReceivers: any = (Runtime).DependenciesReceivers;\n static auth_callbacks: any = (Runtime).auth_callbacks;\n\n static ready() {\n Pusher.isReady = true;\n for (var i = 0, l = Pusher.instances.length; i < l; i++) {\n Pusher.instances[i].connect();\n }\n }\n\n static log: (message: any) => void;\n\n private static getClientFeatures(): string[] {\n return Collections.keys(\n Collections.filterObject({ ws: Runtime.Transports.ws }, function(t) {\n return t.isSupported({});\n })\n );\n }\n\n /* INSTANCE PROPERTIES */\n key: string;\n options: Options;\n config: Config;\n channels: Channels;\n global_emitter: EventsDispatcher;\n sessionID: number;\n timeline: Timeline;\n timelineSender: TimelineSender;\n connection: ConnectionManager;\n timelineSenderTimer: PeriodicTimer;\n user: UserFacade;\n constructor(app_key: string, options: Options) {\n checkAppKey(app_key);\n validateOptions(options);\n this.key = app_key;\n this.options = options;\n this.config = getConfig(this.options, this);\n\n this.channels = Factory.createChannels();\n this.global_emitter = new EventsDispatcher();\n this.sessionID = Runtime.randomInt(1000000000);\n\n this.timeline = new Timeline(this.key, this.sessionID, {\n cluster: this.config.cluster,\n features: Pusher.getClientFeatures(),\n params: this.config.timelineParams || {},\n limit: 50,\n level: TimelineLevel.INFO,\n version: Defaults.VERSION\n });\n if (this.config.enableStats) {\n this.timelineSender = Factory.createTimelineSender(this.timeline, {\n host: this.config.statsHost,\n path: '/timeline/v2/' + Runtime.TimelineTransport.name\n });\n }\n\n var getStrategy = (options: StrategyOptions) => {\n return Runtime.getDefaultStrategy(this.config, options, defineTransport);\n };\n\n this.connection = Factory.createConnectionManager(this.key, {\n getStrategy: getStrategy,\n timeline: this.timeline,\n activityTimeout: this.config.activityTimeout,\n pongTimeout: this.config.pongTimeout,\n unavailableTimeout: this.config.unavailableTimeout,\n useTLS: Boolean(this.config.useTLS)\n });\n\n this.connection.bind('connected', () => {\n this.subscribeAll();\n if (this.timelineSender) {\n this.timelineSender.send(this.connection.isUsingTLS());\n }\n });\n\n this.connection.bind('message', event => {\n var eventName = event.event;\n var internal = eventName.indexOf('pusher_internal:') === 0;\n if (event.channel) {\n var channel = this.channel(event.channel);\n if (channel) {\n channel.handleEvent(event);\n }\n }\n // Emit globally [deprecated]\n if (!internal) {\n this.global_emitter.emit(event.event, event.data);\n }\n });\n this.connection.bind('connecting', () => {\n this.channels.disconnect();\n });\n this.connection.bind('disconnected', () => {\n this.channels.disconnect();\n });\n this.connection.bind('error', err => {\n Logger.warn(err);\n });\n\n Pusher.instances.push(this);\n this.timeline.info({ instances: Pusher.instances.length });\n\n this.user = new UserFacade(this);\n\n if (Pusher.isReady) {\n this.connect();\n }\n }\n\n /**\n * Allows you to switch Pusher cluster without\n * losing all the channels/subscription binding\n * as this is internally managed by the SDK.\n */\n switchCluster(options: ClusterOptions) {\n const { appKey, cluster } = options;\n this.key = appKey;\n this.options = { ...this.options, cluster };\n this.config = getConfig(this.options, this);\n this.connection.switchCluster(this.key);\n }\n\n channel(name: string): Channel {\n return this.channels.find(name);\n }\n\n allChannels(): Channel[] {\n return this.channels.all();\n }\n\n connect() {\n this.connection.connect();\n\n if (this.timelineSender) {\n if (!this.timelineSenderTimer) {\n var usingTLS = this.connection.isUsingTLS();\n var timelineSender = this.timelineSender;\n this.timelineSenderTimer = new PeriodicTimer(60000, function() {\n timelineSender.send(usingTLS);\n });\n }\n }\n }\n\n disconnect() {\n this.connection.disconnect();\n\n if (this.timelineSenderTimer) {\n this.timelineSenderTimer.ensureAborted();\n this.timelineSenderTimer = null;\n }\n }\n\n bind(event_name: string, callback: Function, context?: any): Pusher {\n this.global_emitter.bind(event_name, callback, context);\n return this;\n }\n\n unbind(event_name?: string, callback?: Function, context?: any): Pusher {\n this.global_emitter.unbind(event_name, callback, context);\n return this;\n }\n\n bind_global(callback: Function): Pusher {\n this.global_emitter.bind_global(callback);\n return this;\n }\n\n unbind_global(callback?: Function): Pusher {\n this.global_emitter.unbind_global(callback);\n return this;\n }\n\n unbind_all(callback?: Function): Pusher {\n this.global_emitter.unbind_all();\n return this;\n }\n\n subscribeAll() {\n var channelName;\n for (channelName in this.channels.channels) {\n if (this.channels.channels.hasOwnProperty(channelName)) {\n this.subscribe(channelName);\n }\n }\n }\n\n subscribe(channel_name: string) {\n var channel = this.channels.add(channel_name, this);\n if (channel.subscriptionPending && channel.subscriptionCancelled) {\n channel.reinstateSubscription();\n } else if (\n !channel.subscriptionPending &&\n this.connection.state === 'connected'\n ) {\n channel.subscribe();\n }\n return channel;\n }\n\n unsubscribe(channel_name: string) {\n var channel = this.channels.find(channel_name);\n if (channel && channel.subscriptionPending) {\n channel.cancelSubscription();\n } else {\n channel = this.channels.remove(channel_name);\n if (channel && channel.subscribed) {\n channel.unsubscribe();\n }\n }\n }\n\n send_event(event_name: string, data: any, channel?: string) {\n return this.connection.send_event(event_name, data, channel);\n }\n\n shouldUseTLS(): boolean {\n return this.config.useTLS;\n }\n\n signin() {\n this.user.signin();\n }\n}\n\nfunction checkAppKey(key) {\n if (key === null || key === undefined) {\n throw 'You must pass your app key when you instantiate Pusher.';\n }\n}\n\nRuntime.setup(Pusher);\n","import Pusher from './pusher';\nimport { Options, validateOptions } from './options';\nimport * as nacl from 'tweetnacl';\n\nexport default class PusherWithEncryption extends Pusher {\n constructor(app_key: string, options: Options) {\n Pusher.logToConsole = PusherWithEncryption.logToConsole;\n Pusher.log = PusherWithEncryption.log;\n\n validateOptions(options);\n options.nacl = nacl;\n super(app_key, options);\n }\n}\n"],"sourceRoot":""} \ No newline at end of file diff --git a/dist/react-native/pusher.js b/dist/react-native/pusher.js index 8aa114231..cfc9cf158 100644 --- a/dist/react-native/pusher.js +++ b/dist/react-native/pusher.js @@ -1,9 +1,9 @@ /*! - * Pusher JavaScript Library v8.4.0-rc1 + * Pusher JavaScript Library v8.4.0-rc2 * https://pusher.com/ * * Copyright 2020, Pusher * Released under the MIT licence. */ -module.exports=function(t){var e={};function n(r){if(e[r])return e[r].exports;var i=e[r]={i:r,l:!1,exports:{}};return t[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)n.d(r,i,function(e){return t[e]}.bind(null,i));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=15)}([function(t,e,n){"use strict";(function(t){n.d(e,"f",(function(){return s})),n.d(e,"m",(function(){return o})),n.d(e,"d",(function(){return a})),n.d(e,"k",(function(){return h})),n.d(e,"i",(function(){return c})),n.d(e,"n",(function(){return u})),n.d(e,"c",(function(){return l})),n.d(e,"j",(function(){return d})),n.d(e,"g",(function(){return f})),n.d(e,"h",(function(){return p})),n.d(e,"b",(function(){return g})),n.d(e,"a",(function(){return b})),n.d(e,"e",(function(){return y})),n.d(e,"l",(function(){return m}));var r=n(11),i=n(2);function s(t,...e){for(var n=0;n{t.console&&t.console.log&&t.console.log(e)}}debug(...t){this.log(this.globalLog,t)}warn(...t){this.log(this.globalLogWarn,t)}error(...t){this.log(this.globalLogError,t)}globalLogWarn(e){t.console&&t.console.warn?t.console.warn(e):this.globalLog(e)}globalLogError(e){t.console&&t.console.error?t.console.error(e):this.globalLogWarn(e)}log(t,...e){var n=r.m.apply(this,arguments);if(i.a.log)i.a.log(n);else if(i.a.logToConsole){t.bind(this)(n)}}}}).call(this,n(6))},function(t,e,n){"use strict";var r=n(4),i={now:()=>Date.now?Date.now():(new Date).valueOf(),defer:t=>new r.a(0,t),method(t,...e){var n=Array.prototype.slice.call(arguments,1);return function(e){return e[t].apply(e,n.concat(arguments))}}};e.a=i},function(t,e,n){"use strict";(function(t){n.d(e,"a",(function(){return s}));var r=n(0),i=n(12);class s{constructor(t){this.callbacks=new i.a,this.global_callbacks=[],this.failThrough=t}bind(t,e,n){return this.callbacks.add(t,e,n),this}bind_global(t){return this.global_callbacks.push(t),this}unbind(t,e,n){return this.callbacks.remove(t,e,n),this}unbind_global(t){return t?(this.global_callbacks=r.g(this.global_callbacks||[],e=>e!==t),this):(this.global_callbacks=[],this)}unbind_all(){return this.unbind(),this.unbind_global(),this}emit(e,n,r){for(var i=0;i0)for(i=0;i{this.onError(t),this.changeState("closed")}),!1}return this.bindListeners(),l.a.debug("Connecting",{transport:this.name,url:t}),this.changeState("connecting"),!0}close(){return!!this.socket&&(this.socket.close(),!0)}send(t){return"open"===this.state&&(c.a.defer(()=>{this.socket&&this.socket.send(t)}),!0)}ping(){"open"===this.state&&this.supportsPing()&&this.socket.ping()}onOpen(){this.hooks.beforeOpen&&this.hooks.beforeOpen(this.socket,this.hooks.urls.getPath(this.key,this.options)),this.changeState("open"),this.socket.onopen=void 0}onError(t){this.emit("error",{type:"WebSocketError",error:t}),this.timeline.error(this.buildTimelineMessage({error:t.toString()}))}onClose(t){t?this.changeState("closed",{code:t.code,reason:t.reason,wasClean:t.wasClean}):this.changeState("closed"),this.unbindListeners(),this.socket=void 0}onMessage(t){this.emit("message",t)}onActivity(){this.emit("activity")}bindListeners(){this.socket.onopen=()=>{this.onOpen()},this.socket.onerror=t=>{this.onError(t)},this.socket.onclose=t=>{this.onClose(t)},this.socket.onmessage=t=>{this.onMessage(t)},this.supportsPing()&&(this.socket.onactivity=()=>{this.onActivity()})}unbindListeners(){this.socket&&(this.socket.onopen=void 0,this.socket.onerror=void 0,this.socket.onclose=void 0,this.socket.onmessage=void 0,this.supportsPing()&&(this.socket.onactivity=void 0))}changeState(t,e){this.state=t,this.timeline.info(this.buildTimelineMessage({state:t,params:e})),this.emit(t,e)}buildTimelineMessage(t){return r.f({cid:this.id},t)}}class f{constructor(t){this.hooks=t}isSupported(t){return this.hooks.isSupported(t)}createConnection(t,e,n,r){return new d(this.hooks,t,e,n,r)}}var p=new f({urls:a,handlesActivityChecks:!1,supportsPing:!1,isInitialized:function(){return Boolean(zt.getWebSocketAPI())},isSupported:function(){return Boolean(zt.getWebSocketAPI())},getSocket:function(t){return zt.createWebSocket(t)}}),g={urls:h,handlesActivityChecks:!1,supportsPing:!0,isInitialized:function(){return!0}},b=r.f({getSocket:function(t){return zt.HTTPFactory.createStreamingSocket(t)}},g),v=r.f({getSocket:function(t){return zt.HTTPFactory.createPollingSocket(t)}},g),y={isSupported:function(){return zt.isXHRSupported()}},m={ws:p,xhr_streaming:new f(r.f({},b,y)),xhr_polling:new f(r.f({},v,y))};class w{constructor(t,e,n){this.manager=t,this.transport=e,this.minPingDelay=n.minPingDelay,this.maxPingDelay=n.maxPingDelay,this.pingDelay=void 0}createConnection(t,e,n,i){i=r.f({},i,{activityTimeout:this.pingDelay});var s=this.transport.createConnection(t,e,n,i),o=null,a=function(){s.unbind("open",a),s.bind("closed",h),o=c.a.now()},h=t=>{if(s.unbind("closed",h),1002===t.code||1003===t.code)this.manager.reportDeath();else if(!t.wasClean&&o){var e=c.a.now()-o;e<2*this.maxPingDelay&&(this.manager.reportDeath(),this.pingDelay=Math.max(e/2,this.minPingDelay))}};return s.bind("open",a),s}isSupported(t){return this.manager.isAlive()&&this.transport.isSupported(t)}}const _={decodeMessage:function(t){try{var e=JSON.parse(t.data),n=e.data;if("string"==typeof n)try{n=JSON.parse(e.data)}catch(t){}var r={event:e.event,channel:e.channel,data:n};return e.user_id&&(r.user_id=e.user_id),r}catch(e){throw{type:"MessageParseError",error:e,data:t.data}}},encodeMessage:function(t){return JSON.stringify(t)},processHandshake:function(t){var e=_.decodeMessage(t);if("pusher:connection_established"===e.event){if(!e.data.activity_timeout)throw"No activity timeout specified in handshake";return{action:"connected",id:e.data.socket_id,activityTimeout:1e3*e.data.activity_timeout}}if("pusher:error"===e.event)return{action:this.getCloseAction(e.data),error:this.getCloseError(e.data)};throw"Invalid handshake"},getCloseAction:function(t){return t.code<4e3?t.code>=1002&&t.code<=1004?"backoff":null:4e3===t.code?"tls_only":t.code<4100?"refused":t.code<4200?"backoff":t.code<4300?"retry":"refused"},getCloseError:function(t){return 1e3!==t.code&&1001!==t.code?{type:"PusherError",data:{code:t.code,message:t.reason||t.message}}:null}};var S=_;class k extends u.a{constructor(t,e){super(),this.id=t,this.transport=e,this.activityTimeout=e.activityTimeout,this.bindListeners()}handlesActivityChecks(){return this.transport.handlesActivityChecks()}send(t){return this.transport.send(t)}send_event(t,e,n){var r={event:t,data:e};return n&&(r.channel=n),l.a.debug("Event sent",r),this.send(S.encodeMessage(r))}ping(){this.transport.supportsPing()?this.transport.ping():this.send_event("pusher:ping",{})}close(){this.transport.close()}bindListeners(){var t={message:t=>{var e;try{e=S.decodeMessage(t)}catch(e){this.emit("error",{type:"MessageParseError",error:e,data:t.data})}if(void 0!==e){switch(l.a.debug("Event recd",e),e.event){case"pusher:error":this.emit("error",{type:"PusherError",data:e.data});break;case"pusher:ping":this.emit("ping");break;case"pusher:pong":this.emit("pong")}this.emit("message",e)}},activity:()=>{this.emit("activity")},error:t=>{this.emit("error",t)},closed:t=>{e(),t&&t.code&&this.handleCloseEvent(t),this.transport=null,this.emit("closed")}},e=()=>{r.k(t,(t,e)=>{this.transport.unbind(e,t)})};r.k(t,(t,e)=>{this.transport.bind(e,t)})}handleCloseEvent(t){var e=S.getCloseAction(t),n=S.getCloseError(t);n&&this.emit("error",n),e&&this.emit(e,{action:e,error:n})}}class C{constructor(t,e){this.transport=t,this.callback=e,this.bindListeners()}close(){this.unbindListeners(),this.transport.close()}bindListeners(){this.onMessage=t=>{var e;this.unbindListeners();try{e=S.processHandshake(t)}catch(t){return this.finish("error",{error:t}),void this.transport.close()}"connected"===e.action?this.finish("connected",{connection:new k(e.id,this.transport),activityTimeout:e.activityTimeout}):(this.finish(e.action,{error:e.error}),this.transport.close())},this.onClosed=t=>{this.unbindListeners();var e=S.getCloseAction(t)||"backoff",n=S.getCloseError(t);this.finish(e,{error:n})},this.transport.bind("message",this.onMessage),this.transport.bind("closed",this.onClosed)}unbindListeners(){this.transport.unbind("message",this.onMessage),this.transport.unbind("closed",this.onClosed)}finish(t,e){this.callback(r.f({transport:this.transport,action:t},e))}}class T{constructor(t,e){this.timeline=t,this.options=e||{}}send(t,e){this.timeline.isEmpty()||this.timeline.send(zt.TimelineTransport.getAgent(this,t),e)}}class E extends Error{constructor(t){super(t),Object.setPrototypeOf(this,new.target.prototype)}}class A extends Error{constructor(t){super(t),Object.setPrototypeOf(this,new.target.prototype)}}Error;class P extends Error{constructor(t){super(t),Object.setPrototypeOf(this,new.target.prototype)}}class x extends Error{constructor(t){super(t),Object.setPrototypeOf(this,new.target.prototype)}}class O extends Error{constructor(t){super(t),Object.setPrototypeOf(this,new.target.prototype)}}class L extends Error{constructor(t){super(t),Object.setPrototypeOf(this,new.target.prototype)}}class U extends Error{constructor(t){super(t),Object.setPrototypeOf(this,new.target.prototype)}}class R extends Error{constructor(t,e){super(e),this.status=t,Object.setPrototypeOf(this,new.target.prototype)}}const M={baseUrl:"https://pusher.com",urls:{authenticationEndpoint:{path:"/docs/channels/server_api/authenticating_users"},authorizationEndpoint:{path:"/docs/channels/server_api/authorizing-users/"},javascriptQuickStart:{path:"/docs/javascript_quick_start"},triggeringClientEvents:{path:"/docs/client_api_guide/client_events#trigger-events"},encryptedChannelSupport:{fullUrl:"https://github.com/pusher/pusher-js/tree/cc491015371a4bde5743d1c87a0fbac0feb53195#encrypted-channel-support"}}};var I=function(t){const e=M.urls[t];if(!e)return"";let n;return e.fullUrl?n=e.fullUrl:e.path&&(n=M.baseUrl+e.path),n?"See: "+n:""};class N extends u.a{constructor(t,e){super((function(e,n){l.a.debug("No callbacks on "+t+" for "+e)})),this.name=t,this.pusher=e,this.subscribed=!1,this.subscriptionPending=!1,this.subscriptionCancelled=!1}authorize(t,e){return e(null,{auth:""})}trigger(t,e){if(0!==t.indexOf("client-"))throw new E("Event '"+t+"' does not start with 'client-'");if(!this.subscribed){var n=I("triggeringClientEvents");l.a.warn("Client event triggered before channel 'subscription_succeeded' event . "+n)}return this.pusher.send_event(t,e,this.name)}disconnect(){this.subscribed=!1,this.subscriptionPending=!1}handleEvent(t){var e=t.event,n=t.data;if("pusher_internal:subscription_succeeded"===e)this.handleSubscriptionSucceededEvent(t);else if("pusher_internal:subscription_count"===e)this.handleSubscriptionCountEvent(t);else if(0!==e.indexOf("pusher_internal:")){this.emit(e,n,{})}}handleSubscriptionSucceededEvent(t){this.subscriptionPending=!1,this.subscribed=!0,this.subscriptionCancelled?this.pusher.unsubscribe(this.name):this.emit("pusher:subscription_succeeded",t.data)}handleSubscriptionCountEvent(t){t.data.subscription_count&&(this.subscriptionCount=t.data.subscription_count),this.emit("pusher:subscription_count",t.data)}subscribe(){this.subscribed||(this.subscriptionPending=!0,this.subscriptionCancelled=!1,this.authorize(this.pusher.connection.socket_id,(t,e)=>{t?(this.subscriptionPending=!1,l.a.error(t.toString()),this.emit("pusher:subscription_error",Object.assign({},{type:"AuthError",error:t.message},t instanceof R?{status:t.status}:{}))):this.pusher.send_event("pusher:subscribe",{auth:e.auth,channel_data:e.channel_data,channel:this.name})}))}unsubscribe(){this.subscribed=!1,this.pusher.send_event("pusher:unsubscribe",{channel:this.name})}cancelSubscription(){this.subscriptionCancelled=!0}reinstateSubscription(){this.subscriptionCancelled=!1}}class j extends N{authorize(t,e){return this.pusher.config.channelAuthorizer({channelName:this.name,socketId:t},e)}}class D{constructor(){this.reset()}get(t){return Object.prototype.hasOwnProperty.call(this.members,t)?{id:t,info:this.members[t]}:null}each(t){r.k(this.members,(e,n)=>{t(this.get(n))})}setMyID(t){this.myID=t}onSubscription(t){this.members=t.presence.hash,this.count=t.presence.count,this.me=this.get(this.myID)}addMember(t){return null===this.get(t.user_id)&&this.count++,this.members[t.user_id]=t.user_info,this.get(t.user_id)}removeMember(t){var e=this.get(t.user_id);return e&&(delete this.members[t.user_id],this.count--),e}reset(){this.members={},this.count=0,this.myID=null,this.me=null}}var z=function(t,e,n,r){return new(n||(n=Promise))((function(i,s){function o(t){try{h(r.next(t))}catch(t){s(t)}}function a(t){try{h(r.throw(t))}catch(t){s(t)}}function h(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(o,a)}h((r=r.apply(t,e||[])).next())}))};class H extends j{constructor(t,e){super(t,e),this.members=new D}authorize(t,e){super.authorize(t,(t,n)=>z(this,void 0,void 0,(function*(){if(!t)if(null!=(n=n).channel_data){var r=JSON.parse(n.channel_data);this.members.setMyID(r.user_id)}else{if(yield this.pusher.user.signinDonePromise,null==this.pusher.user.user_data){let t=I("authorizationEndpoint");return l.a.error(`Invalid auth response for channel '${this.name}', expected 'channel_data' field. ${t}, or the user should be signed in.`),void e("Invalid auth response")}this.members.setMyID(this.pusher.user.user_data.id)}e(t,n)})))}handleEvent(t){var e=t.event;if(0===e.indexOf("pusher_internal:"))this.handleInternalEvent(t);else{var n=t.data,r={};t.user_id&&(r.user_id=t.user_id),this.emit(e,n,r)}}handleInternalEvent(t){var e=t.event,n=t.data;switch(e){case"pusher_internal:subscription_succeeded":this.handleSubscriptionSucceededEvent(t);break;case"pusher_internal:subscription_count":this.handleSubscriptionCountEvent(t);break;case"pusher_internal:member_added":var r=this.members.addMember(n);this.emit("pusher:member_added",r);break;case"pusher_internal:member_removed":var i=this.members.removeMember(n);i&&this.emit("pusher:member_removed",i)}}handleSubscriptionSucceededEvent(t){this.subscriptionPending=!1,this.subscribed=!0,this.subscriptionCancelled?this.pusher.unsubscribe(this.name):(this.members.onSubscription(t.data),this.emit("pusher:subscription_succeeded",this.members))}disconnect(){this.members.reset(),super.disconnect()}}var B=n(13),F=n(8);class q extends j{constructor(t,e,n){super(t,e),this.key=null,this.nacl=n}authorize(t,e){super.authorize(t,(t,n)=>{if(t)return void e(t,n);let r=n.shared_secret;r?(this.key=Object(F.decode)(r),delete n.shared_secret,e(null,n)):e(new Error("No shared_secret key in auth payload for encrypted channel: "+this.name),null)})}trigger(t,e){throw new O("Client events are not currently supported for encrypted channels")}handleEvent(t){var e=t.event,n=t.data;0!==e.indexOf("pusher_internal:")&&0!==e.indexOf("pusher:")?this.handleEncryptedEvent(e,n):super.handleEvent(t)}handleEncryptedEvent(t,e){if(!this.key)return void l.a.debug("Received encrypted event before key has been retrieved from the authEndpoint");if(!e.ciphertext||!e.nonce)return void l.a.error("Unexpected format for encrypted event, expected object with `ciphertext` and `nonce` fields, got: "+e);let n=Object(F.decode)(e.ciphertext);if(n.length{e?l.a.error(`Failed to make a request to the authEndpoint: ${s}. Unable to fetch new key, so dropping encrypted event`):(i=this.nacl.secretbox.open(n,r,this.key),null!==i?this.emit(t,this.getDataToEmit(i)):l.a.error("Failed to decrypt event with new key. Dropping encrypted event"))});this.emit(t,this.getDataToEmit(i))}getDataToEmit(t){let e=Object(B.decode)(t);try{return JSON.parse(e)}catch(t){return e}}}var Y=n(4);class K extends u.a{constructor(t,e){super(),this.state="initialized",this.connection=null,this.key=t,this.options=e,this.timeline=this.options.timeline,this.usingTLS=this.options.useTLS,this.errorCallbacks=this.buildErrorCallbacks(),this.connectionCallbacks=this.buildConnectionCallbacks(this.errorCallbacks),this.handshakeCallbacks=this.buildHandshakeCallbacks(this.errorCallbacks);var n=zt.getNetwork();n.bind("online",()=>{this.timeline.info({netinfo:"online"}),"connecting"!==this.state&&"unavailable"!==this.state||this.retryIn(0)}),n.bind("offline",()=>{this.timeline.info({netinfo:"offline"}),this.connection&&this.sendActivityCheck()}),this.updateStrategy()}switchCluster(t){this.key=t,this.updateStrategy(),this.retryIn(0)}connect(){this.connection||this.runner||(this.strategy.isSupported()?(this.updateState("connecting"),this.startConnecting(),this.setUnavailableTimer()):this.updateState("failed"))}send(t){return!!this.connection&&this.connection.send(t)}send_event(t,e,n){return!!this.connection&&this.connection.send_event(t,e,n)}disconnect(){this.disconnectInternally(),this.updateState("disconnected")}isUsingTLS(){return this.usingTLS}startConnecting(){var t=(e,n)=>{e?this.runner=this.strategy.connect(0,t):"error"===n.action?(this.emit("error",{type:"HandshakeError",error:n.error}),this.timeline.error({handshakeError:n.error})):(this.abortConnecting(),this.handshakeCallbacks[n.action](n))};this.runner=this.strategy.connect(0,t)}abortConnecting(){this.runner&&(this.runner.abort(),this.runner=null)}disconnectInternally(){(this.abortConnecting(),this.clearRetryTimer(),this.clearUnavailableTimer(),this.connection)&&this.abandonConnection().close()}updateStrategy(){this.strategy=this.options.getStrategy({key:this.key,timeline:this.timeline,useTLS:this.usingTLS})}retryIn(t){this.timeline.info({action:"retry",delay:t}),t>0&&this.emit("connecting_in",Math.round(t/1e3)),this.retryTimer=new Y.a(t||0,()=>{this.disconnectInternally(),this.connect()})}clearRetryTimer(){this.retryTimer&&(this.retryTimer.ensureAborted(),this.retryTimer=null)}setUnavailableTimer(){this.unavailableTimer=new Y.a(this.options.unavailableTimeout,()=>{this.updateState("unavailable")})}clearUnavailableTimer(){this.unavailableTimer&&this.unavailableTimer.ensureAborted()}sendActivityCheck(){this.stopActivityCheck(),this.connection.ping(),this.activityTimer=new Y.a(this.options.pongTimeout,()=>{this.timeline.error({pong_timed_out:this.options.pongTimeout}),this.retryIn(0)})}resetActivityCheck(){this.stopActivityCheck(),this.connection&&!this.connection.handlesActivityChecks()&&(this.activityTimer=new Y.a(this.activityTimeout,()=>{this.sendActivityCheck()}))}stopActivityCheck(){this.activityTimer&&this.activityTimer.ensureAborted()}buildConnectionCallbacks(t){return r.f({},t,{message:t=>{this.resetActivityCheck(),this.emit("message",t)},ping:()=>{this.send_event("pusher:pong",{})},activity:()=>{this.resetActivityCheck()},error:t=>{this.emit("error",t)},closed:()=>{this.abandonConnection(),this.shouldRetry()&&this.retryIn(1e3)}})}buildHandshakeCallbacks(t){return r.f({},t,{connected:t=>{this.activityTimeout=Math.min(this.options.activityTimeout,t.activityTimeout,t.connection.activityTimeout||1/0),this.clearUnavailableTimer(),this.setConnection(t.connection),this.socket_id=this.connection.id,this.updateState("connected",{socket_id:this.socket_id})}})}buildErrorCallbacks(){let t=t=>e=>{e.error&&this.emit("error",{type:"WebSocketError",error:e.error}),t(e)};return{tls_only:t(()=>{this.usingTLS=!0,this.updateStrategy(),this.retryIn(0)}),refused:t(()=>{this.disconnect()}),backoff:t(()=>{this.retryIn(1e3)}),retry:t(()=>{this.retryIn(0)})}}setConnection(t){for(var e in this.connection=t,this.connectionCallbacks)this.connection.bind(e,this.connectionCallbacks[e]);this.resetActivityCheck()}abandonConnection(){if(this.connection){for(var t in this.stopActivityCheck(),this.connectionCallbacks)this.connection.unbind(t,this.connectionCallbacks[t]);var e=this.connection;return this.connection=null,e}}updateState(t,e){var n=this.state;if(this.state=t,n!==t){var r=t;"connected"===r&&(r+=" with new socket ID "+e.socket_id),l.a.debug("State changed",n+" -> "+r),this.timeline.info({state:t,params:e}),this.emit("state_change",{previous:n,current:t}),this.emit(t,e)}}shouldRetry(){return"connecting"===this.state||"connected"===this.state}}class ${constructor(){this.channels={}}add(t,e){return this.channels[t]||(this.channels[t]=function(t,e){if(0===t.indexOf("private-encrypted-")){if(e.config.nacl)return J.createEncryptedChannel(t,e,e.config.nacl);let n="Tried to subscribe to a private-encrypted- channel but no nacl implementation available",r=I("encryptedChannelSupport");throw new O(`${n}. ${r}`)}if(0===t.indexOf("private-"))return J.createPrivateChannel(t,e);if(0===t.indexOf("presence-"))return J.createPresenceChannel(t,e);if(0===t.indexOf("#"))throw new A('Cannot create a channel with name "'+t+'".');return J.createChannel(t,e)}(t,e)),this.channels[t]}all(){return r.n(this.channels)}find(t){return this.channels[t]}remove(t){var e=this.channels[t];return delete this.channels[t],e}disconnect(){r.k(this.channels,(function(t){t.disconnect()}))}}var J={createChannels:()=>new $,createConnectionManager:(t,e)=>new K(t,e),createChannel:(t,e)=>new N(t,e),createPrivateChannel:(t,e)=>new j(t,e),createPresenceChannel:(t,e)=>new H(t,e),createEncryptedChannel:(t,e,n)=>new q(t,e,n),createTimelineSender:(t,e)=>new T(t,e),createHandshake:(t,e)=>new C(t,e),createAssistantToTheTransportManager:(t,e,n)=>new w(t,e,n)};class X{constructor(t){this.options=t||{},this.livesLeft=this.options.lives||1/0}getAssistant(t){return J.createAssistantToTheTransportManager(this,t,{minPingDelay:this.options.minPingDelay,maxPingDelay:this.options.maxPingDelay})}isAlive(){return this.livesLeft>0}reportDeath(){this.livesLeft-=1}}class W{constructor(t,e){this.strategies=t,this.loop=Boolean(e.loop),this.failFast=Boolean(e.failFast),this.timeout=e.timeout,this.timeoutLimit=e.timeoutLimit}isSupported(){return r.b(this.strategies,c.a.method("isSupported"))}connect(t,e){var n=this.strategies,r=0,i=this.timeout,s=null,o=(a,h)=>{h?e(null,h):(r+=1,this.loop&&(r%=n.length),r0&&(i=new Y.a(n.timeout,(function(){s.abort(),r(!0)}))),s=t.connect(e,(function(t,e){t&&i&&i.isRunning()&&!n.failFast||(i&&i.ensureAborted(),r(t,e))})),{abort:function(){i&&i.ensureAborted(),s.abort()},forceMinPriority:function(t){s.forceMinPriority(t)}}}}class G{constructor(t){this.strategies=t}isSupported(){return r.b(this.strategies,c.a.method("isSupported"))}connect(t,e){return function(t,e,n){var i=r.j(t,(function(t,r,i,s){return t.connect(e,n(r,s))}));return{abort:function(){r.c(i,V)},forceMinPriority:function(t){r.c(i,(function(e){e.forceMinPriority(t)}))}}}(this.strategies,t,(function(t,n){return function(i,s){n[t].error=i,i?function(t){return r.a(t,(function(t){return Boolean(t.error)}))}(n)&&e(!0):(r.c(n,(function(t){t.forceMinPriority(s.transport.priority)})),e(null,s))}}))}}function V(t){t.error||t.aborted||(t.abort(),t.aborted=!0)}class Z{constructor(t,e,n){this.strategy=t,this.transports=e,this.ttl=n.ttl||18e5,this.usingTLS=n.useTLS,this.timeline=n.timeline}isSupported(){return this.strategy.isSupported()}connect(t,e){var n=this.usingTLS,i=function(t){var e=zt.getLocalStorage();if(e)try{var n=e[Q(t)];if(n)return JSON.parse(n)}catch(e){tt(t)}return null}(n),s=i&&i.cacheSkipCount?i.cacheSkipCount:0,o=[this.strategy];if(i&&i.timestamp+this.ttl>=c.a.now()){var a=this.transports[i.transport];a&&(["ws","wss"].includes(i.transport)||s>3?(this.timeline.info({cached:!0,transport:i.transport,latency:i.latency}),o.push(new W([a],{timeout:2*i.latency+1e3,failFast:!0}))):s++)}var h=c.a.now(),u=o.pop().connect(t,(function i(a,l){a?(tt(n),o.length>0?(h=c.a.now(),u=o.pop().connect(t,i)):e(a)):(!function(t,e,n,i){var s=zt.getLocalStorage();if(s)try{s[Q(t)]=r.l({timestamp:c.a.now(),transport:e,latency:n,cacheSkipCount:i})}catch(t){}}(n,l.transport.name,c.a.now()-h,s),e(null,l))}));return{abort:function(){u.abort()},forceMinPriority:function(e){t=e,u&&u.forceMinPriority(e)}}}}function Q(t){return"pusherTransport"+(t?"TLS":"NonTLS")}function tt(t){var e=zt.getLocalStorage();if(e)try{delete e[Q(t)]}catch(t){}}class et{constructor(t,{delay:e}){this.strategy=t,this.options={delay:e}}isSupported(){return this.strategy.isSupported()}connect(t,e){var n,r=this.strategy,i=new Y.a(this.options.delay,(function(){n=r.connect(t,e)}));return{abort:function(){i.ensureAborted(),n&&n.abort()},forceMinPriority:function(e){t=e,n&&n.forceMinPriority(e)}}}}class nt{constructor(t,e,n){this.test=t,this.trueBranch=e,this.falseBranch=n}isSupported(){return(this.test()?this.trueBranch:this.falseBranch).isSupported()}connect(t,e){return(this.test()?this.trueBranch:this.falseBranch).connect(t,e)}}class rt{constructor(t){this.strategy=t}isSupported(){return this.strategy.isSupported()}connect(t,e){var n=this.strategy.connect(t,(function(t,r){r&&n.abort(),e(t,r)}));return n}}function it(t){return function(){return t.isSupported()}}var st=function(t,e,n){var i={};function s(e,r,s,o,a){var h=n(t,e,r,s,o,a);return i[e]=h,h}var o,a=Object.assign({},e,{hostNonTLS:t.wsHost+":"+t.wsPort,hostTLS:t.wsHost+":"+t.wssPort,httpPath:t.wsPath}),h=r.f({},a,{useTLS:!0}),c=Object.assign({},e,{hostNonTLS:t.httpHost+":"+t.httpPort,hostTLS:t.httpHost+":"+t.httpsPort,httpPath:t.httpPath}),u={loop:!0,timeout:15e3,timeoutLimit:6e4},l=new X({minPingDelay:1e4,maxPingDelay:t.activityTimeout}),d=new X({lives:2,minPingDelay:1e4,maxPingDelay:t.activityTimeout}),f=s("ws","ws",3,a,l),p=s("wss","ws",3,h,l),g=s("xhr_streaming","xhr_streaming",1,c,d),b=s("xhr_polling","xhr_polling",1,c),v=new W([f],u),y=new W([p],u),m=new W([g],u),w=new W([b],u),_=new W([new nt(it(m),new G([m,new et(w,{delay:4e3})]),w)],u);return o=e.useTLS?new G([v,new et(_,{delay:2e3})]):new G([v,new et(y,{delay:2e3}),new et(_,{delay:5e3})]),new Z(new rt(new nt(it(f),o,_)),i,{ttl:18e5,timeline:e.timeline,useTLS:e.useTLS})};class ot extends u.a{constructor(t,e,n){super(),this.hooks=t,this.method=e,this.url=n}start(t){this.position=0,this.xhr=this.hooks.getRequest(this),this.unloader=()=>{this.close()},zt.addUnloadListener(this.unloader),this.xhr.open(this.method,this.url,!0),this.xhr.setRequestHeader&&this.xhr.setRequestHeader("Content-Type","application/json"),this.xhr.send(t)}close(){this.unloader&&(zt.removeUnloadListener(this.unloader),this.unloader=null),this.xhr&&(this.hooks.abortRequest(this.xhr),this.xhr=null)}onChunk(t,e){for(;;){var n=this.advanceBuffer(e);if(!n)break;this.emit("chunk",{status:t,data:n})}this.isBufferTooLong(e)&&this.emit("buffer_too_long")}advanceBuffer(t){var e=t.slice(this.position),n=e.indexOf("\n");return-1!==n?(this.position+=n+1,e.slice(0,n)):null}isBufferTooLong(t){return this.position===t.length&&t.length>262144}}var at;!function(t){t[t.CONNECTING=0]="CONNECTING",t[t.OPEN=1]="OPEN",t[t.CLOSED=3]="CLOSED"}(at||(at={}));var ht=at,ct=1;function ut(t){var e=-1===t.indexOf("?")?"?":"&";return t+e+"t="+ +new Date+"&n="+ct++}function lt(t){return zt.randomInt(t)}var dt=class{constructor(t,e){this.hooks=t,this.session=lt(1e3)+"/"+function(t){for(var e=[],n=0;n{this.onChunk(t)}),this.stream.bind("finished",t=>{this.hooks.onFinished(this,t)}),this.stream.bind("buffer_too_long",()=>{this.reconnect()});try{this.stream.start()}catch(t){c.a.defer(()=>{this.onError(t),this.onClose(1006,"Could not start streaming",!1)})}}closeStream(){this.stream&&(this.stream.unbind_all(),this.stream.close(),this.stream=null)}},ft={getReceiveURL:function(t,e){return t.base+"/"+e+"/xhr_streaming"+t.queryString},onHeartbeat:function(t){t.sendRaw("[]")},sendHeartbeat:function(t){t.sendRaw("[]")},onFinished:function(t,e){t.onClose(1006,"Connection interrupted ("+e+")",!1)}},pt={getReceiveURL:function(t,e){return t.base+"/"+e+"/xhr"+t.queryString},onHeartbeat:function(){},sendHeartbeat:function(t){t.sendRaw("[]")},onFinished:function(t,e){200===e?t.reconnect():t.onClose(1006,"Connection interrupted ("+e+")",!1)}},gt={getRequest:function(t){var e=new(zt.getXHRAPI());return e.onreadystatechange=e.onprogress=function(){switch(e.readyState){case 3:e.responseText&&e.responseText.length>0&&t.onChunk(e.status,e.responseText);break;case 4:e.responseText&&e.responseText.length>0&&t.onChunk(e.status,e.responseText),t.emit("finished",e.status),t.close()}},e},abortRequest:function(t){t.onreadystatechange=null,t.abort()}},bt={getDefaultStrategy:st,Transports:m,transportConnectionInitializer:function(){this.timeline.info(this.buildTimelineMessage({transport:this.name+(this.options.useTLS?"s":"")})),this.hooks.isInitialized()?this.changeState("initialized"):this.onClose()},HTTPFactory:{createStreamingSocket(t){return this.createSocket(ft,t)},createPollingSocket(t){return this.createSocket(pt,t)},createSocket:(t,e)=>new dt(t,e),createXHR(t,e){return this.createRequest(gt,t,e)},createRequest:(t,e,n)=>new ot(t,e,n)},setup(t){t.ready()},getLocalStorage(){},getClientFeatures:()=>r.i(r.h({ws:m.ws},(function(t){return t.isSupported({})}))),getProtocol:()=>"http:",isXHRSupported:()=>!0,createSocketRequest(t,e){if(this.isXHRSupported())return this.HTTPFactory.createXHR(t,e);throw"Cross-origin HTTP requests are not supported"},createXHR(){return new(this.getXHRAPI())},createWebSocket(t){return new(this.getWebSocketAPI())(t)},addUnloadListener(t){},removeUnloadListener(t){}},vt=n(10),yt=n.n(vt);function mt(t){return"none"!==t.type.toLowerCase()}class wt extends u.a{constructor(){super(),this.online=!0,yt.a.fetch().then(t=>{this.online=mt(t)}),yt.a.addEventListener(t=>{var e=mt(t);this.online!==e&&(this.online=e,this.online?this.emit("online"):this.emit("offline"))})}isOnline(){return this.online}}var _t,St=new wt;!function(t){t.UserAuthentication="user-authentication",t.ChannelAuthorization="channel-authorization"}(_t||(_t={}));var kt=function(t,e,n,r,i){const s=zt.createXHR();for(var o in s.open("POST",n.endpoint,!0),s.setRequestHeader("Content-Type","application/x-www-form-urlencoded"),n.headers)s.setRequestHeader(o,n.headers[o]);if(null!=n.headersProvider){let t=n.headersProvider();for(var o in t)s.setRequestHeader(o,t[o])}return s.onreadystatechange=function(){if(4===s.readyState)if(200===s.status){let t,e=!1;try{t=JSON.parse(s.responseText),e=!0}catch(t){i(new R(200,`JSON returned from ${r.toString()} endpoint was invalid, yet status code was 200. Data was: ${s.responseText}`),null)}e&&i(null,t)}else{let t="";switch(r){case _t.UserAuthentication:t=I("authenticationEndpoint");break;case _t.ChannelAuthorization:t="Clients must be authorized to join private or presence channels. "+I("authorizationEndpoint")}i(new R(s.status,`Unable to retrieve auth string from ${r.toString()} endpoint - received status: ${s.status} from ${n.endpoint}. ${t}`),null)}},s.send(e),s},Ct={name:"xhr",getAgent:function(t,e){return function(n,i){var s="http"+(e?"s":"")+"://"+(t.host||t.options.host)+t.options.path;s+="/2?"+r.e(n);var o=zt.createXHR();o.open("GET",s,!0),o.onreadystatechange=function(){if(4===o.readyState){let{status:n,responseText:r}=o;if(200!==n)return void l.a.debug(`TimelineSender Error: received ${n} from stats.pusher.com`);try{var{host:e}=JSON.parse(r)}catch(t){l.a.debug("TimelineSenderError: invalid response "+r)}e&&(t.host=e)}},o.send()}}};const{getDefaultStrategy:Tt,Transports:Et,setup:At,getProtocol:Pt,isXHRSupported:xt,getLocalStorage:Ot,createXHR:Lt,createWebSocket:Ut,addUnloadListener:Rt,removeUnloadListener:Mt,transportConnectionInitializer:It,createSocketRequest:Nt,HTTPFactory:jt}=bt;var Dt,zt={getDefaultStrategy:Tt,Transports:Et,setup:At,getProtocol:Pt,isXHRSupported:xt,getLocalStorage:Ot,createXHR:Lt,createWebSocket:Ut,addUnloadListener:Rt,removeUnloadListener:Mt,transportConnectionInitializer:It,createSocketRequest:Nt,HTTPFactory:jt,TimelineTransport:Ct,getAuthorizers:()=>({ajax:kt}),getWebSocketAPI:()=>WebSocket,getXHRAPI:()=>XMLHttpRequest,getNetwork:()=>St,randomInt:t=>Math.floor(Math.random()*t)};!function(t){t[t.ERROR=3]="ERROR",t[t.INFO=6]="INFO",t[t.DEBUG=7]="DEBUG"}(Dt||(Dt={}));var Ht=Dt;class Bt{constructor(t,e,n){this.key=t,this.session=e,this.events=[],this.options=n||{},this.sent=0,this.uniqueID=0}log(t,e){t<=this.options.level&&(this.events.push(r.f({},e,{timestamp:c.a.now()})),this.options.limit&&this.events.length>this.options.limit&&this.events.shift())}error(t){this.log(Ht.ERROR,t)}info(t){this.log(Ht.INFO,t)}debug(t){this.log(Ht.DEBUG,t)}isEmpty(){return 0===this.events.length}send(t,e){var n=r.f({session:this.session,bundle:this.sent+1,key:this.key,lib:"js",version:this.options.version,cluster:this.options.cluster,features:this.options.features,timeline:this.events},this.options.params);return this.events=[],t(n,(t,n)=>{t||this.sent++,e&&e(t,n)}),!0}generateUniqueID(){return this.uniqueID++,this.uniqueID}}class Ft{constructor(t,e,n,r){this.name=t,this.priority=e,this.transport=n,this.options=r||{}}isSupported(){return this.transport.isSupported({useTLS:this.options.useTLS})}connect(t,e){if(!this.isSupported())return qt(new U,e);if(this.priority{n||(u(),s?s.close():i.close())},forceMinPriority:t=>{n||this.priority{if(void 0===zt.getAuthorizers()[t.transport])throw`'${t.transport}' is not a recognized auth transport`;return(e,n)=>{const r=((t,e)=>{var n="socket_id="+encodeURIComponent(t.socketId);for(var r in e.params)n+="&"+encodeURIComponent(r)+"="+encodeURIComponent(e.params[r]);if(null!=e.paramsProvider){let t=e.paramsProvider();for(var r in t)n+="&"+encodeURIComponent(r)+"="+encodeURIComponent(t[r])}return n})(e,t);zt.getAuthorizers()[t.transport](zt,r,t,_t.UserAuthentication,n)}};var Wt=t=>{if(void 0===zt.getAuthorizers()[t.transport])throw`'${t.transport}' is not a recognized auth transport`;return(e,n)=>{const r=((t,e)=>{var n="socket_id="+encodeURIComponent(t.socketId);for(var r in n+="&channel_name="+encodeURIComponent(t.channelName),e.params)n+="&"+encodeURIComponent(r)+"="+encodeURIComponent(e.params[r]);if(null!=e.paramsProvider){let t=e.paramsProvider();for(var r in t)n+="&"+encodeURIComponent(r)+"="+encodeURIComponent(t[r])}return n})(e,t);zt.getAuthorizers()[t.transport](zt,r,t,_t.ChannelAuthorization,n)}};function Gt(t,e){let n={activityTimeout:t.activityTimeout||i.activityTimeout,cluster:t.cluster,httpPath:t.httpPath||i.httpPath,httpPort:t.httpPort||i.httpPort,httpsPort:t.httpsPort||i.httpsPort,pongTimeout:t.pongTimeout||i.pongTimeout,statsHost:t.statsHost||i.stats_host,unavailableTimeout:t.unavailableTimeout||i.unavailableTimeout,wsPath:t.wsPath||i.wsPath,wsPort:t.wsPort||i.wsPort,wssPort:t.wssPort||i.wssPort,enableStats:te(t),httpHost:Vt(t),useTLS:Qt(t),wsHost:Zt(t),userAuthenticator:ee(t),channelAuthorizer:ne(t,e)};return"disabledTransports"in t&&(n.disabledTransports=t.disabledTransports),"enabledTransports"in t&&(n.enabledTransports=t.enabledTransports),"ignoreNullOrigin"in t&&(n.ignoreNullOrigin=t.ignoreNullOrigin),"timelineParams"in t&&(n.timelineParams=t.timelineParams),"nacl"in t&&(n.nacl=t.nacl),n}function Vt(t){return t.httpHost?t.httpHost:t.cluster?`sockjs-${t.cluster}.pusher.com`:i.httpHost}function Zt(t){return t.wsHost?t.wsHost:`ws-${t.cluster}.pusher.com`}function Qt(t){return"https:"===zt.getProtocol()||!1!==t.forceTLS}function te(t){return"enableStats"in t?t.enableStats:"disableStats"in t&&!t.disableStats}function ee(t){const e=Object.assign(Object.assign({},i.userAuthentication),t.userAuthentication);return"customHandler"in e&&null!=e.customHandler?e.customHandler:Xt(e)}function ne(t,e){const n=function(t,e){let n;return"channelAuthorization"in t?n=Object.assign(Object.assign({},i.channelAuthorization),t.channelAuthorization):(n={transport:t.authTransport||i.authTransport,endpoint:t.authEndpoint||i.authEndpoint},"auth"in t&&("params"in t.auth&&(n.params=t.auth.params),"headers"in t.auth&&(n.headers=t.auth.headers)),"authorizer"in t&&(n.customHandler=((t,e,n)=>{const r={authTransport:e.transport,authEndpoint:e.endpoint,auth:{params:e.params,headers:e.headers}};return(e,i)=>{const s=t.channel(e.channelName);n(s,r).authorize(e.socketId,i)}})(e,n,t.authorizer))),n}(t,e);return"customHandler"in n&&null!=n.customHandler?n.customHandler:Wt(n)}class re extends u.a{constructor(t){super((function(t,e){l.a.debug("No callbacks on watchlist events for "+t)})),this.pusher=t,this.bindWatchlistInternalEvent()}handleEvent(t){t.data.events.forEach(t=>{this.emit(t.name,t)})}bindWatchlistInternalEvent(){this.pusher.connection.bind("message",t=>{"pusher_internal:watchlist_events"===t.event&&this.handleEvent(t)})}}var ie=function(){let t,e;return{promise:new Promise((n,r)=>{t=n,e=r}),resolve:t,reject:e}};class se extends u.a{constructor(t){super((function(t,e){l.a.debug("No callbacks on user for "+t)})),this.signin_requested=!1,this.user_data=null,this.serverToUserChannel=null,this.signinDonePromise=null,this._signinDoneResolve=null,this._onAuthorize=(t,e)=>{if(t)return l.a.warn("Error during signin: "+t),void this._cleanup();this.pusher.send_event("pusher:signin",{auth:e.auth,user_data:e.user_data})},this.pusher=t,this.pusher.connection.bind("state_change",({previous:t,current:e})=>{"connected"!==t&&"connected"===e&&this._signin(),"connected"===t&&"connected"!==e&&(this._cleanup(),this._newSigninPromiseIfNeeded())}),this.watchlist=new re(t),this.pusher.connection.bind("message",t=>{"pusher:signin_success"===t.event&&this._onSigninSuccess(t.data),this.serverToUserChannel&&this.serverToUserChannel.name===t.channel&&this.serverToUserChannel.handleEvent(t)})}signin(){this.signin_requested||(this.signin_requested=!0,this._signin())}_signin(){this.signin_requested&&(this._newSigninPromiseIfNeeded(),"connected"===this.pusher.connection.state&&this.pusher.config.userAuthenticator({socketId:this.pusher.connection.socket_id},this._onAuthorize))}_onSigninSuccess(t){try{this.user_data=JSON.parse(t.user_data)}catch(e){return l.a.error("Failed parsing user data after signin: "+t.user_data),void this._cleanup()}if("string"!=typeof this.user_data.id||""===this.user_data.id)return l.a.error("user_data doesn't contain an id. user_data: "+this.user_data),void this._cleanup();this._signinDoneResolve(),this._subscribeChannels()}_subscribeChannels(){this.serverToUserChannel=new N("#server-to-user-"+this.user_data.id,this.pusher),this.serverToUserChannel.bind_global((t,e)=>{0!==t.indexOf("pusher_internal:")&&0!==t.indexOf("pusher:")&&this.emit(t,e)}),(t=>{t.subscriptionPending&&t.subscriptionCancelled?t.reinstateSubscription():t.subscriptionPending||"connected"!==this.pusher.connection.state||t.subscribe()})(this.serverToUserChannel)}_cleanup(){this.user_data=null,this.serverToUserChannel&&(this.serverToUserChannel.unbind_all(),this.serverToUserChannel.disconnect(),this.serverToUserChannel=null),this.signin_requested&&this._signinDoneResolve()}_newSigninPromiseIfNeeded(){if(!this.signin_requested)return;if(this.signinDonePromise&&!this.signinDonePromise.done)return;const{promise:t,resolve:e,reject:n}=ie();t.done=!1;const r=()=>{t.done=!0};t.then(r).catch(r),this.signinDonePromise=t,this._signinDoneResolve=e}}class oe{static ready(){oe.isReady=!0;for(var t=0,e=oe.instances.length;tzt.getDefaultStrategy(this.config,t,Kt),timeline:this.timeline,activityTimeout:this.config.activityTimeout,pongTimeout:this.config.pongTimeout,unavailableTimeout:this.config.unavailableTimeout,useTLS:Boolean(this.config.useTLS)}),this.connection.bind("connected",()=>{this.subscribeAll(),this.timelineSender&&this.timelineSender.send(this.connection.isUsingTLS())}),this.connection.bind("message",t=>{var e=0===t.event.indexOf("pusher_internal:");if(t.channel){var n=this.channel(t.channel);n&&n.handleEvent(t)}e||this.global_emitter.emit(t.event,t.data)}),this.connection.bind("connecting",()=>{this.channels.disconnect()}),this.connection.bind("disconnected",()=>{this.channels.disconnect()}),this.connection.bind("error",t=>{l.a.warn(t)}),oe.instances.push(this),this.timeline.info({instances:oe.instances.length}),this.user=new se(this),oe.isReady&&this.connect()}switchCluster(t){const{appKey:e,cluster:n}=t;this.key=e,this.options=Object.assign(Object.assign({},this.options),{cluster:n}),this.config=Gt(this.options,this),this.connection.switchCluster(this.key)}channel(t){return this.channels.find(t)}allChannels(){return this.channels.all()}connect(){if(this.connection.connect(),this.timelineSender&&!this.timelineSenderTimer){var t=this.connection.isUsingTLS(),e=this.timelineSender;this.timelineSenderTimer=new Y.b(6e4,(function(){e.send(t)}))}}disconnect(){this.connection.disconnect(),this.timelineSenderTimer&&(this.timelineSenderTimer.ensureAborted(),this.timelineSenderTimer=null)}bind(t,e,n){return this.global_emitter.bind(t,e,n),this}unbind(t,e,n){return this.global_emitter.unbind(t,e,n),this}bind_global(t){return this.global_emitter.bind_global(t),this}unbind_global(t){return this.global_emitter.unbind_global(t),this}unbind_all(t){return this.global_emitter.unbind_all(),this}subscribeAll(){var t;for(t in this.channels.channels)this.channels.channels.hasOwnProperty(t)&&this.subscribe(t)}subscribe(t){var e=this.channels.add(t,this);return e.subscriptionPending&&e.subscriptionCancelled?e.reinstateSubscription():e.subscriptionPending||"connected"!==this.connection.state||e.subscribe(),e}unsubscribe(t){var e=this.channels.find(t);e&&e.subscriptionPending?e.cancelSubscription():(e=this.channels.remove(t))&&e.subscribed&&e.unsubscribe()}send_event(t,e,n){return this.connection.send_event(t,e,n)}shouldUseTLS(){return this.config.useTLS}signin(){this.user.signin()}}oe.instances=[],oe.isReady=!1,oe.logToConsole=!1,oe.Runtime=zt,oe.ScriptReceivers=zt.ScriptReceivers,oe.DependenciesReceivers=zt.DependenciesReceivers,oe.auth_callbacks=zt.auth_callbacks;e.a=oe;zt.setup(oe)},function(t,e){var n;n=function(){return this}();try{n=n||new Function("return this")()}catch(t){"object"==typeof window&&(n=window)}t.exports=n},function(t,e,n){"use strict";n.d(e,"a",(function(){return i}));var r=n(1);function i(t){if(null==t)throw"You must pass an options object";if(null==t.cluster)throw"Options object must provide a cluster";"disableStats"in t&&r.a.warn("The disableStats option is deprecated in favor of enableStats")}},function(t,e,n){"use strict";var r,i=this&&this.__extends||(r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)},function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)});Object.defineProperty(e,"__esModule",{value:!0});var s=function(){function t(t){void 0===t&&(t="="),this._paddingCharacter=t}return t.prototype.encodedLength=function(t){return this._paddingCharacter?(t+2)/3*4|0:(8*t+5)/6|0},t.prototype.encode=function(t){for(var e="",n=0;n>>18&63),e+=this._encodeByte(r>>>12&63),e+=this._encodeByte(r>>>6&63),e+=this._encodeByte(r>>>0&63)}var i=t.length-n;if(i>0){r=t[n]<<16|(2===i?t[n+1]<<8:0);e+=this._encodeByte(r>>>18&63),e+=this._encodeByte(r>>>12&63),e+=2===i?this._encodeByte(r>>>6&63):this._paddingCharacter||"",e+=this._paddingCharacter||""}return e},t.prototype.maxDecodedLength=function(t){return this._paddingCharacter?t/4*3|0:(6*t+7)/8|0},t.prototype.decodedLength=function(t){return this.maxDecodedLength(t.length-this._getPaddingLength(t))},t.prototype.decode=function(t){if(0===t.length)return new Uint8Array(0);for(var e=this._getPaddingLength(t),n=t.length-e,r=new Uint8Array(this.maxDecodedLength(n)),i=0,s=0,o=0,a=0,h=0,c=0,u=0;s>>4,r[i++]=h<<4|c>>>2,r[i++]=c<<6|u,o|=256&a,o|=256&h,o|=256&c,o|=256&u;if(s>>4,o|=256&a,o|=256&h),s>>2,o|=256&c),s>>8&6,e+=51-t>>>8&-75,e+=61-t>>>8&-15,e+=62-t>>>8&3,String.fromCharCode(e)},t.prototype._decodeChar=function(t){var e=256;return e+=(42-t&t-44)>>>8&-256+t-43+62,e+=(46-t&t-48)>>>8&-256+t-47+63,e+=(47-t&t-58)>>>8&-256+t-48+52,e+=(64-t&t-91)>>>8&-256+t-65+0,e+=(96-t&t-123)>>>8&-256+t-97+26},t.prototype._getPaddingLength=function(t){var e=0;if(this._paddingCharacter){for(var n=t.length-1;n>=0&&t[n]===this._paddingCharacter;n--)e++;if(t.length<4||e>2)throw new Error("Base64Coder: incorrect padding")}return e},t}();e.Coder=s;var o=new s;e.encode=function(t){return o.encode(t)},e.decode=function(t){return o.decode(t)};var a=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return i(e,t),e.prototype._encodeByte=function(t){var e=t;return e+=65,e+=25-t>>>8&6,e+=51-t>>>8&-75,e+=61-t>>>8&-13,e+=62-t>>>8&49,String.fromCharCode(e)},e.prototype._decodeChar=function(t){var e=256;return e+=(44-t&t-46)>>>8&-256+t-45+62,e+=(94-t&t-96)>>>8&-256+t-95+63,e+=(47-t&t-58)>>>8&-256+t-48+52,e+=(64-t&t-91)>>>8&-256+t-65+0,e+=(96-t&t-123)>>>8&-256+t-97+26},e}(s);e.URLSafeCoder=a;var h=new a;e.encodeURLSafe=function(t){return h.encode(t)},e.decodeURLSafe=function(t){return h.decode(t)},e.encodedLength=function(t){return o.encodedLength(t)},e.maxDecodedLength=function(t){return o.maxDecodedLength(t)},e.decodedLength=function(t){return o.decodedLength(t)}},function(t,e,n){"use strict";e.a=class{constructor(t,e,n,r){this.clear=e,this.timer=t(()=>{this.timer&&(this.timer=r(this.timer))},n)}isRunning(){return null!==this.timer}ensureAborted(){this.timer&&(this.clear(this.timer),this.timer=null)}}},function(t,e){t.exports=require("@react-native-community/netinfo")},function(t,e,n){"use strict";(function(t){function r(t){return d(u(t))}n.d(e,"a",(function(){return r}));for(var i=String.fromCharCode,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",o={},a=0,h=s.length;a>>6)+i(128|63&e):i(224|e>>>12&15)+i(128|e>>>6&63)+i(128|63&e)},u=function(t){return t.replace(/[^\x00-\x7F]/g,c)},l=function(t){var e=[0,2,1][t.length%3],n=t.charCodeAt(0)<<16|(t.length>1?t.charCodeAt(1):0)<<8|(t.length>2?t.charCodeAt(2):0);return[s.charAt(n>>>18),s.charAt(n>>>12&63),e>=2?"=":s.charAt(n>>>6&63),e>=1?"=":s.charAt(63&n)].join("")},d=t.btoa||function(t){return t.replace(/[\s\S]{1,3}/g,l)}}).call(this,n(6))},function(t,e,n){"use strict";n.d(e,"a",(function(){return i}));var r=n(0);class i{constructor(){this._callbacks={}}get(t){return this._callbacks[s(t)]}add(t,e,n){var r=s(t);this._callbacks[r]=this._callbacks[r]||[],this._callbacks[r].push({fn:e,context:n})}remove(t,e,n){if(t||e||n){var i=t?[s(t)]:r.i(this._callbacks);e||n?this.removeCallback(i,e,n):this.removeAllCallbacks(i)}else this._callbacks={}}removeCallback(t,e,n){r.c(t,(function(t){this._callbacks[t]=r.g(this._callbacks[t]||[],(function(t){return e&&e!==t.fn||n&&n!==t.context})),0===this._callbacks[t].length&&delete this._callbacks[t]}),this)}removeAllCallbacks(t){r.c(t,(function(t){delete this._callbacks[t]}),this)}}function s(t){return"_"+t}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r="utf8: invalid source encoding";function i(t){for(var e=0,n=0;n=t.length-1)throw new Error("utf8: invalid string");n++,e+=4}}return e}e.encode=function(t){for(var e=new Uint8Array(i(t)),n=0,r=0;r>6,e[n++]=128|63&s):s<55296?(e[n++]=224|s>>12,e[n++]=128|s>>6&63,e[n++]=128|63&s):(r++,s=(1023&s)<<10,s|=1023&t.charCodeAt(r),s+=65536,e[n++]=240|s>>18,e[n++]=128|s>>12&63,e[n++]=128|s>>6&63,e[n++]=128|63&s)}return e},e.encodedLength=i,e.decode=function(t){for(var e=[],n=0;n=t.length)throw new Error(r);if(128!=(192&(o=t[++n])))throw new Error(r);i=(31&i)<<6|63&o,s=128}else if(i<240){if(n>=t.length-1)throw new Error(r);var o=t[++n],a=t[++n];if(128!=(192&o)||128!=(192&a))throw new Error(r);i=(15&i)<<12|(63&o)<<6|63&a,s=2048}else{if(!(i<248))throw new Error(r);if(n>=t.length-2)throw new Error(r);o=t[++n],a=t[++n];var h=t[++n];if(128!=(192&o)||128!=(192&a)||128!=(192&h))throw new Error(r);i=(15&i)<<18|(63&o)<<12|(63&a)<<6|63&h,s=65536}if(i=55296&&i<=57343)throw new Error(r);if(i>=65536){if(i>1114111)throw new Error(r);i-=65536,e.push(String.fromCharCode(55296|i>>10)),i=56320|1023&i}}e.push(String.fromCharCode(i))}return e.join("")}},function(t,e,n){!function(t){"use strict";var e=function(t){var e,n=new Float64Array(16);if(t)for(e=0;e>24&255,t[e+1]=n>>16&255,t[e+2]=n>>8&255,t[e+3]=255&n,t[e+4]=r>>24&255,t[e+5]=r>>16&255,t[e+6]=r>>8&255,t[e+7]=255&r}function g(t,e,n,r,i){var s,o=0;for(s=0;s>>8)-1}function b(t,e,n,r){return g(t,e,n,r,16)}function v(t,e,n,r){return g(t,e,n,r,32)}function y(t,e,n,r){!function(t,e,n,r){for(var i,s=255&r[0]|(255&r[1])<<8|(255&r[2])<<16|(255&r[3])<<24,o=255&n[0]|(255&n[1])<<8|(255&n[2])<<16|(255&n[3])<<24,a=255&n[4]|(255&n[5])<<8|(255&n[6])<<16|(255&n[7])<<24,h=255&n[8]|(255&n[9])<<8|(255&n[10])<<16|(255&n[11])<<24,c=255&n[12]|(255&n[13])<<8|(255&n[14])<<16|(255&n[15])<<24,u=255&r[4]|(255&r[5])<<8|(255&r[6])<<16|(255&r[7])<<24,l=255&e[0]|(255&e[1])<<8|(255&e[2])<<16|(255&e[3])<<24,d=255&e[4]|(255&e[5])<<8|(255&e[6])<<16|(255&e[7])<<24,f=255&e[8]|(255&e[9])<<8|(255&e[10])<<16|(255&e[11])<<24,p=255&e[12]|(255&e[13])<<8|(255&e[14])<<16|(255&e[15])<<24,g=255&r[8]|(255&r[9])<<8|(255&r[10])<<16|(255&r[11])<<24,b=255&n[16]|(255&n[17])<<8|(255&n[18])<<16|(255&n[19])<<24,v=255&n[20]|(255&n[21])<<8|(255&n[22])<<16|(255&n[23])<<24,y=255&n[24]|(255&n[25])<<8|(255&n[26])<<16|(255&n[27])<<24,m=255&n[28]|(255&n[29])<<8|(255&n[30])<<16|(255&n[31])<<24,w=255&r[12]|(255&r[13])<<8|(255&r[14])<<16|(255&r[15])<<24,_=s,S=o,k=a,C=h,T=c,E=u,A=l,P=d,x=f,O=p,L=g,U=b,R=v,M=y,I=m,N=w,j=0;j<20;j+=2)_^=(i=(R^=(i=(x^=(i=(T^=(i=_+R|0)<<7|i>>>25)+_|0)<<9|i>>>23)+T|0)<<13|i>>>19)+x|0)<<18|i>>>14,E^=(i=(S^=(i=(M^=(i=(O^=(i=E+S|0)<<7|i>>>25)+E|0)<<9|i>>>23)+O|0)<<13|i>>>19)+M|0)<<18|i>>>14,L^=(i=(A^=(i=(k^=(i=(I^=(i=L+A|0)<<7|i>>>25)+L|0)<<9|i>>>23)+I|0)<<13|i>>>19)+k|0)<<18|i>>>14,N^=(i=(U^=(i=(P^=(i=(C^=(i=N+U|0)<<7|i>>>25)+N|0)<<9|i>>>23)+C|0)<<13|i>>>19)+P|0)<<18|i>>>14,_^=(i=(C^=(i=(k^=(i=(S^=(i=_+C|0)<<7|i>>>25)+_|0)<<9|i>>>23)+S|0)<<13|i>>>19)+k|0)<<18|i>>>14,E^=(i=(T^=(i=(P^=(i=(A^=(i=E+T|0)<<7|i>>>25)+E|0)<<9|i>>>23)+A|0)<<13|i>>>19)+P|0)<<18|i>>>14,L^=(i=(O^=(i=(x^=(i=(U^=(i=L+O|0)<<7|i>>>25)+L|0)<<9|i>>>23)+U|0)<<13|i>>>19)+x|0)<<18|i>>>14,N^=(i=(I^=(i=(M^=(i=(R^=(i=N+I|0)<<7|i>>>25)+N|0)<<9|i>>>23)+R|0)<<13|i>>>19)+M|0)<<18|i>>>14;_=_+s|0,S=S+o|0,k=k+a|0,C=C+h|0,T=T+c|0,E=E+u|0,A=A+l|0,P=P+d|0,x=x+f|0,O=O+p|0,L=L+g|0,U=U+b|0,R=R+v|0,M=M+y|0,I=I+m|0,N=N+w|0,t[0]=_>>>0&255,t[1]=_>>>8&255,t[2]=_>>>16&255,t[3]=_>>>24&255,t[4]=S>>>0&255,t[5]=S>>>8&255,t[6]=S>>>16&255,t[7]=S>>>24&255,t[8]=k>>>0&255,t[9]=k>>>8&255,t[10]=k>>>16&255,t[11]=k>>>24&255,t[12]=C>>>0&255,t[13]=C>>>8&255,t[14]=C>>>16&255,t[15]=C>>>24&255,t[16]=T>>>0&255,t[17]=T>>>8&255,t[18]=T>>>16&255,t[19]=T>>>24&255,t[20]=E>>>0&255,t[21]=E>>>8&255,t[22]=E>>>16&255,t[23]=E>>>24&255,t[24]=A>>>0&255,t[25]=A>>>8&255,t[26]=A>>>16&255,t[27]=A>>>24&255,t[28]=P>>>0&255,t[29]=P>>>8&255,t[30]=P>>>16&255,t[31]=P>>>24&255,t[32]=x>>>0&255,t[33]=x>>>8&255,t[34]=x>>>16&255,t[35]=x>>>24&255,t[36]=O>>>0&255,t[37]=O>>>8&255,t[38]=O>>>16&255,t[39]=O>>>24&255,t[40]=L>>>0&255,t[41]=L>>>8&255,t[42]=L>>>16&255,t[43]=L>>>24&255,t[44]=U>>>0&255,t[45]=U>>>8&255,t[46]=U>>>16&255,t[47]=U>>>24&255,t[48]=R>>>0&255,t[49]=R>>>8&255,t[50]=R>>>16&255,t[51]=R>>>24&255,t[52]=M>>>0&255,t[53]=M>>>8&255,t[54]=M>>>16&255,t[55]=M>>>24&255,t[56]=I>>>0&255,t[57]=I>>>8&255,t[58]=I>>>16&255,t[59]=I>>>24&255,t[60]=N>>>0&255,t[61]=N>>>8&255,t[62]=N>>>16&255,t[63]=N>>>24&255}(t,e,n,r)}function m(t,e,n,r){!function(t,e,n,r){for(var i,s=255&r[0]|(255&r[1])<<8|(255&r[2])<<16|(255&r[3])<<24,o=255&n[0]|(255&n[1])<<8|(255&n[2])<<16|(255&n[3])<<24,a=255&n[4]|(255&n[5])<<8|(255&n[6])<<16|(255&n[7])<<24,h=255&n[8]|(255&n[9])<<8|(255&n[10])<<16|(255&n[11])<<24,c=255&n[12]|(255&n[13])<<8|(255&n[14])<<16|(255&n[15])<<24,u=255&r[4]|(255&r[5])<<8|(255&r[6])<<16|(255&r[7])<<24,l=255&e[0]|(255&e[1])<<8|(255&e[2])<<16|(255&e[3])<<24,d=255&e[4]|(255&e[5])<<8|(255&e[6])<<16|(255&e[7])<<24,f=255&e[8]|(255&e[9])<<8|(255&e[10])<<16|(255&e[11])<<24,p=255&e[12]|(255&e[13])<<8|(255&e[14])<<16|(255&e[15])<<24,g=255&r[8]|(255&r[9])<<8|(255&r[10])<<16|(255&r[11])<<24,b=255&n[16]|(255&n[17])<<8|(255&n[18])<<16|(255&n[19])<<24,v=255&n[20]|(255&n[21])<<8|(255&n[22])<<16|(255&n[23])<<24,y=255&n[24]|(255&n[25])<<8|(255&n[26])<<16|(255&n[27])<<24,m=255&n[28]|(255&n[29])<<8|(255&n[30])<<16|(255&n[31])<<24,w=255&r[12]|(255&r[13])<<8|(255&r[14])<<16|(255&r[15])<<24,_=0;_<20;_+=2)s^=(i=(v^=(i=(f^=(i=(c^=(i=s+v|0)<<7|i>>>25)+s|0)<<9|i>>>23)+c|0)<<13|i>>>19)+f|0)<<18|i>>>14,u^=(i=(o^=(i=(y^=(i=(p^=(i=u+o|0)<<7|i>>>25)+u|0)<<9|i>>>23)+p|0)<<13|i>>>19)+y|0)<<18|i>>>14,g^=(i=(l^=(i=(a^=(i=(m^=(i=g+l|0)<<7|i>>>25)+g|0)<<9|i>>>23)+m|0)<<13|i>>>19)+a|0)<<18|i>>>14,w^=(i=(b^=(i=(d^=(i=(h^=(i=w+b|0)<<7|i>>>25)+w|0)<<9|i>>>23)+h|0)<<13|i>>>19)+d|0)<<18|i>>>14,s^=(i=(h^=(i=(a^=(i=(o^=(i=s+h|0)<<7|i>>>25)+s|0)<<9|i>>>23)+o|0)<<13|i>>>19)+a|0)<<18|i>>>14,u^=(i=(c^=(i=(d^=(i=(l^=(i=u+c|0)<<7|i>>>25)+u|0)<<9|i>>>23)+l|0)<<13|i>>>19)+d|0)<<18|i>>>14,g^=(i=(p^=(i=(f^=(i=(b^=(i=g+p|0)<<7|i>>>25)+g|0)<<9|i>>>23)+b|0)<<13|i>>>19)+f|0)<<18|i>>>14,w^=(i=(m^=(i=(y^=(i=(v^=(i=w+m|0)<<7|i>>>25)+w|0)<<9|i>>>23)+v|0)<<13|i>>>19)+y|0)<<18|i>>>14;t[0]=s>>>0&255,t[1]=s>>>8&255,t[2]=s>>>16&255,t[3]=s>>>24&255,t[4]=u>>>0&255,t[5]=u>>>8&255,t[6]=u>>>16&255,t[7]=u>>>24&255,t[8]=g>>>0&255,t[9]=g>>>8&255,t[10]=g>>>16&255,t[11]=g>>>24&255,t[12]=w>>>0&255,t[13]=w>>>8&255,t[14]=w>>>16&255,t[15]=w>>>24&255,t[16]=l>>>0&255,t[17]=l>>>8&255,t[18]=l>>>16&255,t[19]=l>>>24&255,t[20]=d>>>0&255,t[21]=d>>>8&255,t[22]=d>>>16&255,t[23]=d>>>24&255,t[24]=f>>>0&255,t[25]=f>>>8&255,t[26]=f>>>16&255,t[27]=f>>>24&255,t[28]=p>>>0&255,t[29]=p>>>8&255,t[30]=p>>>16&255,t[31]=p>>>24&255}(t,e,n,r)}var w=new Uint8Array([101,120,112,97,110,100,32,51,50,45,98,121,116,101,32,107]);function _(t,e,n,r,i,s,o){var a,h,c=new Uint8Array(16),u=new Uint8Array(64);for(h=0;h<16;h++)c[h]=0;for(h=0;h<8;h++)c[h]=s[h];for(;i>=64;){for(y(u,c,o,w),h=0;h<64;h++)t[e+h]=n[r+h]^u[h];for(a=1,h=8;h<16;h++)a=a+(255&c[h])|0,c[h]=255&a,a>>>=8;i-=64,e+=64,r+=64}if(i>0)for(y(u,c,o,w),h=0;h=64;){for(y(h,a,i,w),o=0;o<64;o++)t[e+o]=h[o];for(s=1,o=8;o<16;o++)s=s+(255&a[o])|0,a[o]=255&s,s>>>=8;n-=64,e+=64}if(n>0)for(y(h,a,i,w),o=0;o>>13|n<<3),r=255&t[4]|(255&t[5])<<8,this.r[2]=7939&(n>>>10|r<<6),i=255&t[6]|(255&t[7])<<8,this.r[3]=8191&(r>>>7|i<<9),s=255&t[8]|(255&t[9])<<8,this.r[4]=255&(i>>>4|s<<12),this.r[5]=s>>>1&8190,o=255&t[10]|(255&t[11])<<8,this.r[6]=8191&(s>>>14|o<<2),a=255&t[12]|(255&t[13])<<8,this.r[7]=8065&(o>>>11|a<<5),h=255&t[14]|(255&t[15])<<8,this.r[8]=8191&(a>>>8|h<<8),this.r[9]=h>>>5&127,this.pad[0]=255&t[16]|(255&t[17])<<8,this.pad[1]=255&t[18]|(255&t[19])<<8,this.pad[2]=255&t[20]|(255&t[21])<<8,this.pad[3]=255&t[22]|(255&t[23])<<8,this.pad[4]=255&t[24]|(255&t[25])<<8,this.pad[5]=255&t[26]|(255&t[27])<<8,this.pad[6]=255&t[28]|(255&t[29])<<8,this.pad[7]=255&t[30]|(255&t[31])<<8};function E(t,e,n,r,i,s){var o=new T(s);return o.update(n,r,i),o.finish(t,e),0}function A(t,e,n,r,i,s){var o=new Uint8Array(16);return E(o,0,n,r,i,s),b(t,e,o,0)}function P(t,e,n,r,i){var s;if(n<32)return-1;for(C(t,0,e,0,n,r,i),E(t,16,t,32,n-32,t),s=0;s<16;s++)t[s]=0;return 0}function x(t,e,n,r,i){var s,o=new Uint8Array(32);if(n<32)return-1;if(k(o,0,32,r,i),0!==A(e,16,e,32,n-32,o))return-1;for(C(t,0,e,0,n,r,i),s=0;s<32;s++)t[s]=0;return 0}function O(t,e){var n;for(n=0;n<16;n++)t[n]=0|e[n]}function L(t){var e,n,r=1;for(e=0;e<16;e++)n=t[e]+r+65535,r=Math.floor(n/65536),t[e]=n-65536*r;t[0]+=r-1+37*(r-1)}function U(t,e,n){for(var r,i=~(n-1),s=0;s<16;s++)r=i&(t[s]^e[s]),t[s]^=r,e[s]^=r}function R(t,n){var r,i,s,o=e(),a=e();for(r=0;r<16;r++)a[r]=n[r];for(L(a),L(a),L(a),i=0;i<2;i++){for(o[0]=a[0]-65517,r=1;r<15;r++)o[r]=a[r]-65535-(o[r-1]>>16&1),o[r-1]&=65535;o[15]=a[15]-32767-(o[14]>>16&1),s=o[15]>>16&1,o[14]&=65535,U(a,o,1-s)}for(r=0;r<16;r++)t[2*r]=255&a[r],t[2*r+1]=a[r]>>8}function M(t,e){var n=new Uint8Array(32),r=new Uint8Array(32);return R(n,t),R(r,e),v(n,0,r,0)}function I(t){var e=new Uint8Array(32);return R(e,t),1&e[0]}function N(t,e){var n;for(n=0;n<16;n++)t[n]=e[2*n]+(e[2*n+1]<<8);t[15]&=32767}function j(t,e,n){for(var r=0;r<16;r++)t[r]=e[r]+n[r]}function D(t,e,n){for(var r=0;r<16;r++)t[r]=e[r]-n[r]}function z(t,e,n){var r,i,s=0,o=0,a=0,h=0,c=0,u=0,l=0,d=0,f=0,p=0,g=0,b=0,v=0,y=0,m=0,w=0,_=0,S=0,k=0,C=0,T=0,E=0,A=0,P=0,x=0,O=0,L=0,U=0,R=0,M=0,I=0,N=n[0],j=n[1],D=n[2],z=n[3],H=n[4],B=n[5],F=n[6],q=n[7],Y=n[8],K=n[9],$=n[10],J=n[11],X=n[12],W=n[13],G=n[14],V=n[15];s+=(r=e[0])*N,o+=r*j,a+=r*D,h+=r*z,c+=r*H,u+=r*B,l+=r*F,d+=r*q,f+=r*Y,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65536)),c=(r=c+i+65535)-65536*(i=Math.floor(r/65536)),u=(r=u+i+65535)-65536*(i=Math.floor(r/65536)),l=(r=l+i+65535)-65536*(i=Math.floor(r/65536)),d=(r=d+i+65535)-65536*(i=Math.floor(r/65536)),f=(r=f+i+65535)-65536*(i=Math.floor(r/65536)),p=(r=p+i+65535)-65536*(i=Math.floor(r/65536)),g=(r=g+i+65535)-65536*(i=Math.floor(r/65536)),b=(r=b+i+65535)-65536*(i=Math.floor(r/65536)),v=(r=v+i+65535)-65536*(i=Math.floor(r/65536)),y=(r=y+i+65535)-65536*(i=Math.floor(r/65536)),m=(r=m+i+65535)-65536*(i=Math.floor(r/65536)),w=(r=w+i+65535)-65536*(i=Math.floor(r/65536)),s=(r=(s+=i-1+37*(i-1))+(i=1)+65535)-65536*(i=Math.floor(r/65536)),o=(r=o+i+65535)-65536*(i=Math.floor(r/65536)),a=(r=a+i+65535)-65536*(i=Math.floor(r/65536)),h=(r=h+i+65535)-65536*(i=Math.floor(r/65536)),c=(r=c+i+65535)-65536*(i=Math.floor(r/65536)),u=(r=u+i+65535)-65536*(i=Math.floor(r/65536)),l=(r=l+i+65535)-65536*(i=Math.floor(r/65536)),d=(r=d+i+65535)-65536*(i=Math.floor(r/65536)),f=(r=f+i+65535)-65536*(i=Math.floor(r/65536)),p=(r=p+i+65535)-65536*(i=Math.floor(r/65536)),g=(r=g+i+65535)-65536*(i=Math.floor(r/65536)),b=(r=b+i+65535)-65536*(i=Math.floor(r/65536)),v=(r=v+i+65535)-65536*(i=Math.floor(r/65536)),y=(r=y+i+65535)-65536*(i=Math.floor(r/65536)),m=(r=m+i+65535)-65536*(i=Math.floor(r/65536)),w=(r=w+i+65535)-65536*(i=Math.floor(r/65536)),s+=i-1+37*(i-1),t[0]=s,t[1]=o,t[2]=a,t[3]=h,t[4]=c,t[5]=u,t[6]=l,t[7]=d,t[8]=f,t[9]=p,t[10]=g,t[11]=b,t[12]=v,t[13]=y,t[14]=m,t[15]=w}function H(t,e){z(t,e,e)}function B(t,n){var r,i=e();for(r=0;r<16;r++)i[r]=n[r];for(r=253;r>=0;r--)H(i,i),2!==r&&4!==r&&z(i,i,n);for(r=0;r<16;r++)t[r]=i[r]}function F(t,n){var r,i=e();for(r=0;r<16;r++)i[r]=n[r];for(r=250;r>=0;r--)H(i,i),1!==r&&z(i,i,n);for(r=0;r<16;r++)t[r]=i[r]}function q(t,n,r){var i,s,o=new Uint8Array(32),a=new Float64Array(80),c=e(),u=e(),l=e(),d=e(),f=e(),p=e();for(s=0;s<31;s++)o[s]=n[s];for(o[31]=127&n[31]|64,o[0]&=248,N(a,r),s=0;s<16;s++)u[s]=a[s],d[s]=c[s]=l[s]=0;for(c[0]=d[0]=1,s=254;s>=0;--s)U(c,u,i=o[s>>>3]>>>(7&s)&1),U(l,d,i),j(f,c,l),D(c,c,l),j(l,u,d),D(u,u,d),H(d,f),H(p,c),z(c,l,c),z(l,u,f),j(f,c,l),D(c,c,l),H(u,c),D(l,d,p),z(c,l,h),j(c,c,d),z(l,l,c),z(c,d,p),z(d,u,a),H(u,f),U(c,u,i),U(l,d,i);for(s=0;s<16;s++)a[s+16]=c[s],a[s+32]=l[s],a[s+48]=u[s],a[s+64]=d[s];var g=a.subarray(32),b=a.subarray(16);return B(g,g),z(b,b,g),R(t,b),0}function Y(t,e){return q(t,e,s)}function K(t,e){return r(e,32),Y(t,e)}function $(t,e,n){var r=new Uint8Array(32);return q(r,n,e),m(t,i,r,w)}T.prototype.blocks=function(t,e,n){for(var r,i,s,o,a,h,c,u,l,d,f,p,g,b,v,y,m,w,_,S=this.fin?0:2048,k=this.h[0],C=this.h[1],T=this.h[2],E=this.h[3],A=this.h[4],P=this.h[5],x=this.h[6],O=this.h[7],L=this.h[8],U=this.h[9],R=this.r[0],M=this.r[1],I=this.r[2],N=this.r[3],j=this.r[4],D=this.r[5],z=this.r[6],H=this.r[7],B=this.r[8],F=this.r[9];n>=16;)d=l=0,d+=(k+=8191&(r=255&t[e+0]|(255&t[e+1])<<8))*R,d+=(C+=8191&(r>>>13|(i=255&t[e+2]|(255&t[e+3])<<8)<<3))*(5*F),d+=(T+=8191&(i>>>10|(s=255&t[e+4]|(255&t[e+5])<<8)<<6))*(5*B),d+=(E+=8191&(s>>>7|(o=255&t[e+6]|(255&t[e+7])<<8)<<9))*(5*H),l=(d+=(A+=8191&(o>>>4|(a=255&t[e+8]|(255&t[e+9])<<8)<<12))*(5*z))>>>13,d&=8191,d+=(P+=a>>>1&8191)*(5*D),d+=(x+=8191&(a>>>14|(h=255&t[e+10]|(255&t[e+11])<<8)<<2))*(5*j),d+=(O+=8191&(h>>>11|(c=255&t[e+12]|(255&t[e+13])<<8)<<5))*(5*N),d+=(L+=8191&(c>>>8|(u=255&t[e+14]|(255&t[e+15])<<8)<<8))*(5*I),f=l+=(d+=(U+=u>>>5|S)*(5*M))>>>13,f+=k*M,f+=C*R,f+=T*(5*F),f+=E*(5*B),l=(f+=A*(5*H))>>>13,f&=8191,f+=P*(5*z),f+=x*(5*D),f+=O*(5*j),f+=L*(5*N),l+=(f+=U*(5*I))>>>13,f&=8191,p=l,p+=k*I,p+=C*M,p+=T*R,p+=E*(5*F),l=(p+=A*(5*B))>>>13,p&=8191,p+=P*(5*H),p+=x*(5*z),p+=O*(5*D),p+=L*(5*j),g=l+=(p+=U*(5*N))>>>13,g+=k*N,g+=C*I,g+=T*M,g+=E*R,l=(g+=A*(5*F))>>>13,g&=8191,g+=P*(5*B),g+=x*(5*H),g+=O*(5*z),g+=L*(5*D),b=l+=(g+=U*(5*j))>>>13,b+=k*j,b+=C*N,b+=T*I,b+=E*M,l=(b+=A*R)>>>13,b&=8191,b+=P*(5*F),b+=x*(5*B),b+=O*(5*H),b+=L*(5*z),v=l+=(b+=U*(5*D))>>>13,v+=k*D,v+=C*j,v+=T*N,v+=E*I,l=(v+=A*M)>>>13,v&=8191,v+=P*R,v+=x*(5*F),v+=O*(5*B),v+=L*(5*H),y=l+=(v+=U*(5*z))>>>13,y+=k*z,y+=C*D,y+=T*j,y+=E*N,l=(y+=A*I)>>>13,y&=8191,y+=P*M,y+=x*R,y+=O*(5*F),y+=L*(5*B),m=l+=(y+=U*(5*H))>>>13,m+=k*H,m+=C*z,m+=T*D,m+=E*j,l=(m+=A*N)>>>13,m&=8191,m+=P*I,m+=x*M,m+=O*R,m+=L*(5*F),w=l+=(m+=U*(5*B))>>>13,w+=k*B,w+=C*H,w+=T*z,w+=E*D,l=(w+=A*j)>>>13,w&=8191,w+=P*N,w+=x*I,w+=O*M,w+=L*R,_=l+=(w+=U*(5*F))>>>13,_+=k*F,_+=C*B,_+=T*H,_+=E*z,l=(_+=A*D)>>>13,_&=8191,_+=P*j,_+=x*N,_+=O*I,_+=L*M,k=d=8191&(l=(l=((l+=(_+=U*R)>>>13)<<2)+l|0)+(d&=8191)|0),C=f+=l>>>=13,T=p&=8191,E=g&=8191,A=b&=8191,P=v&=8191,x=y&=8191,O=m&=8191,L=w&=8191,U=_&=8191,e+=16,n-=16;this.h[0]=k,this.h[1]=C,this.h[2]=T,this.h[3]=E,this.h[4]=A,this.h[5]=P,this.h[6]=x,this.h[7]=O,this.h[8]=L,this.h[9]=U},T.prototype.finish=function(t,e){var n,r,i,s,o=new Uint16Array(10);if(this.leftover){for(s=this.leftover,this.buffer[s++]=1;s<16;s++)this.buffer[s]=0;this.fin=1,this.blocks(this.buffer,0,16)}for(n=this.h[1]>>>13,this.h[1]&=8191,s=2;s<10;s++)this.h[s]+=n,n=this.h[s]>>>13,this.h[s]&=8191;for(this.h[0]+=5*n,n=this.h[0]>>>13,this.h[0]&=8191,this.h[1]+=n,n=this.h[1]>>>13,this.h[1]&=8191,this.h[2]+=n,o[0]=this.h[0]+5,n=o[0]>>>13,o[0]&=8191,s=1;s<10;s++)o[s]=this.h[s]+n,n=o[s]>>>13,o[s]&=8191;for(o[9]-=8192,r=(1^n)-1,s=0;s<10;s++)o[s]&=r;for(r=~r,s=0;s<10;s++)this.h[s]=this.h[s]&r|o[s];for(this.h[0]=65535&(this.h[0]|this.h[1]<<13),this.h[1]=65535&(this.h[1]>>>3|this.h[2]<<10),this.h[2]=65535&(this.h[2]>>>6|this.h[3]<<7),this.h[3]=65535&(this.h[3]>>>9|this.h[4]<<4),this.h[4]=65535&(this.h[4]>>>12|this.h[5]<<1|this.h[6]<<14),this.h[5]=65535&(this.h[6]>>>2|this.h[7]<<11),this.h[6]=65535&(this.h[7]>>>5|this.h[8]<<8),this.h[7]=65535&(this.h[8]>>>8|this.h[9]<<5),i=this.h[0]+this.pad[0],this.h[0]=65535&i,s=1;s<8;s++)i=(this.h[s]+this.pad[s]|0)+(i>>>16)|0,this.h[s]=65535&i;t[e+0]=this.h[0]>>>0&255,t[e+1]=this.h[0]>>>8&255,t[e+2]=this.h[1]>>>0&255,t[e+3]=this.h[1]>>>8&255,t[e+4]=this.h[2]>>>0&255,t[e+5]=this.h[2]>>>8&255,t[e+6]=this.h[3]>>>0&255,t[e+7]=this.h[3]>>>8&255,t[e+8]=this.h[4]>>>0&255,t[e+9]=this.h[4]>>>8&255,t[e+10]=this.h[5]>>>0&255,t[e+11]=this.h[5]>>>8&255,t[e+12]=this.h[6]>>>0&255,t[e+13]=this.h[6]>>>8&255,t[e+14]=this.h[7]>>>0&255,t[e+15]=this.h[7]>>>8&255},T.prototype.update=function(t,e,n){var r,i;if(this.leftover){for((i=16-this.leftover)>n&&(i=n),r=0;r=16&&(i=n-n%16,this.blocks(t,e,i),e+=i,n-=i),n){for(r=0;r=128;){for(S=0;S<16;S++)k=8*S+X,O[S]=n[k+0]<<24|n[k+1]<<16|n[k+2]<<8|n[k+3],L[S]=n[k+4]<<24|n[k+5]<<16|n[k+6]<<8|n[k+7];for(S=0;S<80;S++)if(i=U,s=R,o=M,a=I,h=N,c=j,u=D,z,d=H,f=B,p=F,g=q,b=Y,v=K,y=$,J,E=65535&(T=J),A=T>>>16,P=65535&(C=z),x=C>>>16,E+=65535&(T=(Y>>>14|N<<18)^(Y>>>18|N<<14)^(N>>>9|Y<<23)),A+=T>>>16,P+=65535&(C=(N>>>14|Y<<18)^(N>>>18|Y<<14)^(Y>>>9|N<<23)),x+=C>>>16,E+=65535&(T=Y&K^~Y&$),A+=T>>>16,P+=65535&(C=N&j^~N&D),x+=C>>>16,E+=65535&(T=W[2*S+1]),A+=T>>>16,P+=65535&(C=W[2*S]),x+=C>>>16,C=O[S%16],A+=(T=L[S%16])>>>16,P+=65535&C,x+=C>>>16,P+=(A+=(E+=65535&T)>>>16)>>>16,E=65535&(T=_=65535&E|A<<16),A=T>>>16,P=65535&(C=w=65535&P|(x+=P>>>16)<<16),x=C>>>16,E+=65535&(T=(H>>>28|U<<4)^(U>>>2|H<<30)^(U>>>7|H<<25)),A+=T>>>16,P+=65535&(C=(U>>>28|H<<4)^(H>>>2|U<<30)^(H>>>7|U<<25)),x+=C>>>16,A+=(T=H&B^H&F^B&F)>>>16,P+=65535&(C=U&R^U&M^R&M),x+=C>>>16,l=65535&(P+=(A+=(E+=65535&T)>>>16)>>>16)|(x+=P>>>16)<<16,m=65535&E|A<<16,E=65535&(T=g),A=T>>>16,P=65535&(C=a),x=C>>>16,A+=(T=_)>>>16,P+=65535&(C=w),x+=C>>>16,R=i,M=s,I=o,N=a=65535&(P+=(A+=(E+=65535&T)>>>16)>>>16)|(x+=P>>>16)<<16,j=h,D=c,z=u,U=l,B=d,F=f,q=p,Y=g=65535&E|A<<16,K=b,$=v,J=y,H=m,S%16==15)for(k=0;k<16;k++)C=O[k],E=65535&(T=L[k]),A=T>>>16,P=65535&C,x=C>>>16,C=O[(k+9)%16],E+=65535&(T=L[(k+9)%16]),A+=T>>>16,P+=65535&C,x+=C>>>16,w=O[(k+1)%16],E+=65535&(T=((_=L[(k+1)%16])>>>1|w<<31)^(_>>>8|w<<24)^(_>>>7|w<<25)),A+=T>>>16,P+=65535&(C=(w>>>1|_<<31)^(w>>>8|_<<24)^w>>>7),x+=C>>>16,w=O[(k+14)%16],A+=(T=((_=L[(k+14)%16])>>>19|w<<13)^(w>>>29|_<<3)^(_>>>6|w<<26))>>>16,P+=65535&(C=(w>>>19|_<<13)^(_>>>29|w<<3)^w>>>6),x+=C>>>16,x+=(P+=(A+=(E+=65535&T)>>>16)>>>16)>>>16,O[k]=65535&P|x<<16,L[k]=65535&E|A<<16;E=65535&(T=H),A=T>>>16,P=65535&(C=U),x=C>>>16,C=t[0],A+=(T=e[0])>>>16,P+=65535&C,x+=C>>>16,x+=(P+=(A+=(E+=65535&T)>>>16)>>>16)>>>16,t[0]=U=65535&P|x<<16,e[0]=H=65535&E|A<<16,E=65535&(T=B),A=T>>>16,P=65535&(C=R),x=C>>>16,C=t[1],A+=(T=e[1])>>>16,P+=65535&C,x+=C>>>16,x+=(P+=(A+=(E+=65535&T)>>>16)>>>16)>>>16,t[1]=R=65535&P|x<<16,e[1]=B=65535&E|A<<16,E=65535&(T=F),A=T>>>16,P=65535&(C=M),x=C>>>16,C=t[2],A+=(T=e[2])>>>16,P+=65535&C,x+=C>>>16,x+=(P+=(A+=(E+=65535&T)>>>16)>>>16)>>>16,t[2]=M=65535&P|x<<16,e[2]=F=65535&E|A<<16,E=65535&(T=q),A=T>>>16,P=65535&(C=I),x=C>>>16,C=t[3],A+=(T=e[3])>>>16,P+=65535&C,x+=C>>>16,x+=(P+=(A+=(E+=65535&T)>>>16)>>>16)>>>16,t[3]=I=65535&P|x<<16,e[3]=q=65535&E|A<<16,E=65535&(T=Y),A=T>>>16,P=65535&(C=N),x=C>>>16,C=t[4],A+=(T=e[4])>>>16,P+=65535&C,x+=C>>>16,x+=(P+=(A+=(E+=65535&T)>>>16)>>>16)>>>16,t[4]=N=65535&P|x<<16,e[4]=Y=65535&E|A<<16,E=65535&(T=K),A=T>>>16,P=65535&(C=j),x=C>>>16,C=t[5],A+=(T=e[5])>>>16,P+=65535&C,x+=C>>>16,x+=(P+=(A+=(E+=65535&T)>>>16)>>>16)>>>16,t[5]=j=65535&P|x<<16,e[5]=K=65535&E|A<<16,E=65535&(T=$),A=T>>>16,P=65535&(C=D),x=C>>>16,C=t[6],A+=(T=e[6])>>>16,P+=65535&C,x+=C>>>16,x+=(P+=(A+=(E+=65535&T)>>>16)>>>16)>>>16,t[6]=D=65535&P|x<<16,e[6]=$=65535&E|A<<16,E=65535&(T=J),A=T>>>16,P=65535&(C=z),x=C>>>16,C=t[7],A+=(T=e[7])>>>16,P+=65535&C,x+=C>>>16,x+=(P+=(A+=(E+=65535&T)>>>16)>>>16)>>>16,t[7]=z=65535&P|x<<16,e[7]=J=65535&E|A<<16,X+=128,r-=128}return r}function V(t,e,n){var r,i=new Int32Array(8),s=new Int32Array(8),o=new Uint8Array(256),a=n;for(i[0]=1779033703,i[1]=3144134277,i[2]=1013904242,i[3]=2773480762,i[4]=1359893119,i[5]=2600822924,i[6]=528734635,i[7]=1541459225,s[0]=4089235720,s[1]=2227873595,s[2]=4271175723,s[3]=1595750129,s[4]=2917565137,s[5]=725511199,s[6]=4215389547,s[7]=327033209,G(i,s,e,n),n%=128,r=0;r=0;--i)Q(t,e,r=n[i/8|0]>>(7&i)&1),Z(e,t),Z(t,t),Q(t,e,r)}function nt(t,n){var r=[e(),e(),e(),e()];O(r[0],l),O(r[1],d),O(r[2],a),z(r[3],l,d),et(t,r,n)}function rt(t,n,i){var s,o=new Uint8Array(64),a=[e(),e(),e(),e()];for(i||r(n,32),V(o,n,32),o[0]&=248,o[31]&=127,o[31]|=64,nt(a,o),tt(t,a),s=0;s<32;s++)n[s+32]=t[s];return 0}var it=new Float64Array([237,211,245,92,26,99,18,88,214,156,247,162,222,249,222,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16]);function st(t,e){var n,r,i,s;for(r=63;r>=32;--r){for(n=0,i=r-32,s=r-12;i>4)*it[i],n=e[i]>>8,e[i]&=255;for(i=0;i<32;i++)e[i]-=n*it[i];for(r=0;r<32;r++)e[r+1]+=e[r]>>8,t[r]=255&e[r]}function ot(t){var e,n=new Float64Array(64);for(e=0;e<64;e++)n[e]=t[e];for(e=0;e<64;e++)t[e]=0;st(t,n)}function at(t,n,r,i){var s,o,a=new Uint8Array(64),h=new Uint8Array(64),c=new Uint8Array(64),u=new Float64Array(64),l=[e(),e(),e(),e()];V(a,i,32),a[0]&=248,a[31]&=127,a[31]|=64;var d=r+64;for(s=0;s>7&&D(t[0],o,t[0]),z(t[3],t[0],t[1]),0)}(d,i))return-1;for(s=0;s=0},t.sign.keyPair=function(){var t=new Uint8Array(32),e=new Uint8Array(64);return rt(t,e),{publicKey:t,secretKey:e}},t.sign.keyPair.fromSecretKey=function(t){if(ut(t),64!==t.length)throw new Error("bad secret key size");for(var e=new Uint8Array(32),n=0;n{t.console&&t.console.log&&t.console.log(e)}}debug(...t){this.log(this.globalLog,t)}warn(...t){this.log(this.globalLogWarn,t)}error(...t){this.log(this.globalLogError,t)}globalLogWarn(e){t.console&&t.console.warn?t.console.warn(e):this.globalLog(e)}globalLogError(e){t.console&&t.console.error?t.console.error(e):this.globalLogWarn(e)}log(t,...e){var n=r.m.apply(this,arguments);if(i.a.log)i.a.log(n);else if(i.a.logToConsole){t.bind(this)(n)}}}}).call(this,n(6))},function(t,e,n){"use strict";var r=n(4),i={now:()=>Date.now?Date.now():(new Date).valueOf(),defer:t=>new r.a(0,t),method(t,...e){var n=Array.prototype.slice.call(arguments,1);return function(e){return e[t].apply(e,n.concat(arguments))}}};e.a=i},function(t,e,n){"use strict";(function(t){n.d(e,"a",(function(){return s}));var r=n(0),i=n(12);class s{constructor(t){this.callbacks=new i.a,this.global_callbacks=[],this.failThrough=t}bind(t,e,n){return this.callbacks.add(t,e,n),this}bind_global(t){return this.global_callbacks.push(t),this}unbind(t,e,n){return this.callbacks.remove(t,e,n),this}unbind_global(t){return t?(this.global_callbacks=r.g(this.global_callbacks||[],e=>e!==t),this):(this.global_callbacks=[],this)}unbind_all(){return this.unbind(),this.unbind_global(),this}emit(e,n,r){for(var i=0;i0)for(i=0;i{this.onError(t),this.changeState("closed")}),!1}return this.bindListeners(),l.a.debug("Connecting",{transport:this.name,url:t}),this.changeState("connecting"),!0}close(){return!!this.socket&&(this.socket.close(),!0)}send(t){return"open"===this.state&&(c.a.defer(()=>{this.socket&&this.socket.send(t)}),!0)}ping(){"open"===this.state&&this.supportsPing()&&this.socket.ping()}onOpen(){this.hooks.beforeOpen&&this.hooks.beforeOpen(this.socket,this.hooks.urls.getPath(this.key,this.options)),this.changeState("open"),this.socket.onopen=void 0}onError(t){this.emit("error",{type:"WebSocketError",error:t}),this.timeline.error(this.buildTimelineMessage({error:t.toString()}))}onClose(t){t?this.changeState("closed",{code:t.code,reason:t.reason,wasClean:t.wasClean}):this.changeState("closed"),this.unbindListeners(),this.socket=void 0}onMessage(t){this.emit("message",t)}onActivity(){this.emit("activity")}bindListeners(){this.socket.onopen=()=>{this.onOpen()},this.socket.onerror=t=>{this.onError(t)},this.socket.onclose=t=>{this.onClose(t)},this.socket.onmessage=t=>{this.onMessage(t)},this.supportsPing()&&(this.socket.onactivity=()=>{this.onActivity()})}unbindListeners(){this.socket&&(this.socket.onopen=void 0,this.socket.onerror=void 0,this.socket.onclose=void 0,this.socket.onmessage=void 0,this.supportsPing()&&(this.socket.onactivity=void 0))}changeState(t,e){this.state=t,this.timeline.info(this.buildTimelineMessage({state:t,params:e})),this.emit(t,e)}buildTimelineMessage(t){return r.f({cid:this.id},t)}}class f{constructor(t){this.hooks=t}isSupported(t){return this.hooks.isSupported(t)}createConnection(t,e,n,r){return new d(this.hooks,t,e,n,r)}}var p=new f({urls:a,handlesActivityChecks:!1,supportsPing:!1,isInitialized:function(){return Boolean(zt.getWebSocketAPI())},isSupported:function(){return Boolean(zt.getWebSocketAPI())},getSocket:function(t){return zt.createWebSocket(t)}}),g={urls:h,handlesActivityChecks:!1,supportsPing:!0,isInitialized:function(){return!0}},b=r.f({getSocket:function(t){return zt.HTTPFactory.createStreamingSocket(t)}},g),v=r.f({getSocket:function(t){return zt.HTTPFactory.createPollingSocket(t)}},g),y={isSupported:function(){return zt.isXHRSupported()}},m={ws:p,xhr_streaming:new f(r.f({},b,y)),xhr_polling:new f(r.f({},v,y))};class w{constructor(t,e,n){this.manager=t,this.transport=e,this.minPingDelay=n.minPingDelay,this.maxPingDelay=n.maxPingDelay,this.pingDelay=void 0}createConnection(t,e,n,i){i=r.f({},i,{activityTimeout:this.pingDelay});var s=this.transport.createConnection(t,e,n,i),o=null,a=function(){s.unbind("open",a),s.bind("closed",h),o=c.a.now()},h=t=>{if(s.unbind("closed",h),1002===t.code||1003===t.code)this.manager.reportDeath();else if(!t.wasClean&&o){var e=c.a.now()-o;e<2*this.maxPingDelay&&(this.manager.reportDeath(),this.pingDelay=Math.max(e/2,this.minPingDelay))}};return s.bind("open",a),s}isSupported(t){return this.manager.isAlive()&&this.transport.isSupported(t)}}const _={decodeMessage:function(t){try{var e=JSON.parse(t.data),n=e.data;if("string"==typeof n)try{n=JSON.parse(e.data)}catch(t){}var r={event:e.event,channel:e.channel,data:n};return e.user_id&&(r.user_id=e.user_id),r}catch(e){throw{type:"MessageParseError",error:e,data:t.data}}},encodeMessage:function(t){return JSON.stringify(t)},processHandshake:function(t){var e=_.decodeMessage(t);if("pusher:connection_established"===e.event){if(!e.data.activity_timeout)throw"No activity timeout specified in handshake";return{action:"connected",id:e.data.socket_id,activityTimeout:1e3*e.data.activity_timeout}}if("pusher:error"===e.event)return{action:this.getCloseAction(e.data),error:this.getCloseError(e.data)};throw"Invalid handshake"},getCloseAction:function(t){return t.code<4e3?t.code>=1002&&t.code<=1004?"backoff":null:4e3===t.code?"tls_only":t.code<4100?"refused":t.code<4200?"backoff":t.code<4300?"retry":"refused"},getCloseError:function(t){return 1e3!==t.code&&1001!==t.code?{type:"PusherError",data:{code:t.code,message:t.reason||t.message}}:null}};var S=_;class k extends u.a{constructor(t,e){super(),this.id=t,this.transport=e,this.activityTimeout=e.activityTimeout,this.bindListeners()}handlesActivityChecks(){return this.transport.handlesActivityChecks()}send(t){return this.transport.send(t)}send_event(t,e,n){var r={event:t,data:e};return n&&(r.channel=n),l.a.debug("Event sent",r),this.send(S.encodeMessage(r))}ping(){this.transport.supportsPing()?this.transport.ping():this.send_event("pusher:ping",{})}close(){this.transport.close()}bindListeners(){var t={message:t=>{var e;try{e=S.decodeMessage(t)}catch(e){this.emit("error",{type:"MessageParseError",error:e,data:t.data})}if(void 0!==e){switch(l.a.debug("Event recd",e),e.event){case"pusher:error":this.emit("error",{type:"PusherError",data:e.data});break;case"pusher:ping":this.emit("ping");break;case"pusher:pong":this.emit("pong")}this.emit("message",e)}},activity:()=>{this.emit("activity")},error:t=>{this.emit("error",t)},closed:t=>{e(),t&&t.code&&this.handleCloseEvent(t),this.transport=null,this.emit("closed")}},e=()=>{r.k(t,(t,e)=>{this.transport.unbind(e,t)})};r.k(t,(t,e)=>{this.transport.bind(e,t)})}handleCloseEvent(t){var e=S.getCloseAction(t),n=S.getCloseError(t);n&&this.emit("error",n),e&&this.emit(e,{action:e,error:n})}}class C{constructor(t,e){this.transport=t,this.callback=e,this.bindListeners()}close(){this.unbindListeners(),this.transport.close()}bindListeners(){this.onMessage=t=>{var e;this.unbindListeners();try{e=S.processHandshake(t)}catch(t){return this.finish("error",{error:t}),void this.transport.close()}"connected"===e.action?this.finish("connected",{connection:new k(e.id,this.transport),activityTimeout:e.activityTimeout}):(this.finish(e.action,{error:e.error}),this.transport.close())},this.onClosed=t=>{this.unbindListeners();var e=S.getCloseAction(t)||"backoff",n=S.getCloseError(t);this.finish(e,{error:n})},this.transport.bind("message",this.onMessage),this.transport.bind("closed",this.onClosed)}unbindListeners(){this.transport.unbind("message",this.onMessage),this.transport.unbind("closed",this.onClosed)}finish(t,e){this.callback(r.f({transport:this.transport,action:t},e))}}class T{constructor(t,e){this.timeline=t,this.options=e||{}}send(t,e){this.timeline.isEmpty()||this.timeline.send(zt.TimelineTransport.getAgent(this,t),e)}}class E extends Error{constructor(t){super(t),Object.setPrototypeOf(this,new.target.prototype)}}class A extends Error{constructor(t){super(t),Object.setPrototypeOf(this,new.target.prototype)}}Error;class P extends Error{constructor(t){super(t),Object.setPrototypeOf(this,new.target.prototype)}}class x extends Error{constructor(t){super(t),Object.setPrototypeOf(this,new.target.prototype)}}class O extends Error{constructor(t){super(t),Object.setPrototypeOf(this,new.target.prototype)}}class L extends Error{constructor(t){super(t),Object.setPrototypeOf(this,new.target.prototype)}}class U extends Error{constructor(t){super(t),Object.setPrototypeOf(this,new.target.prototype)}}class R extends Error{constructor(t,e){super(e),this.status=t,Object.setPrototypeOf(this,new.target.prototype)}}const M={baseUrl:"https://pusher.com",urls:{authenticationEndpoint:{path:"/docs/channels/server_api/authenticating_users"},authorizationEndpoint:{path:"/docs/channels/server_api/authorizing-users/"},javascriptQuickStart:{path:"/docs/javascript_quick_start"},triggeringClientEvents:{path:"/docs/client_api_guide/client_events#trigger-events"},encryptedChannelSupport:{fullUrl:"https://github.com/pusher/pusher-js/tree/cc491015371a4bde5743d1c87a0fbac0feb53195#encrypted-channel-support"}}};var I=function(t){const e=M.urls[t];if(!e)return"";let n;return e.fullUrl?n=e.fullUrl:e.path&&(n=M.baseUrl+e.path),n?"See: "+n:""};class N extends u.a{constructor(t,e){super((function(e,n){l.a.debug("No callbacks on "+t+" for "+e)})),this.name=t,this.pusher=e,this.subscribed=!1,this.subscriptionPending=!1,this.subscriptionCancelled=!1}authorize(t,e){return e(null,{auth:""})}trigger(t,e){if(0!==t.indexOf("client-"))throw new E("Event '"+t+"' does not start with 'client-'");if(!this.subscribed){var n=I("triggeringClientEvents");l.a.warn("Client event triggered before channel 'subscription_succeeded' event . "+n)}return this.pusher.send_event(t,e,this.name)}disconnect(){this.subscribed=!1,this.subscriptionPending=!1}handleEvent(t){var e=t.event,n=t.data;if("pusher_internal:subscription_succeeded"===e)this.handleSubscriptionSucceededEvent(t);else if("pusher_internal:subscription_count"===e)this.handleSubscriptionCountEvent(t);else if(0!==e.indexOf("pusher_internal:")){this.emit(e,n,{})}}handleSubscriptionSucceededEvent(t){this.subscriptionPending=!1,this.subscribed=!0,this.subscriptionCancelled?this.pusher.unsubscribe(this.name):this.emit("pusher:subscription_succeeded",t.data)}handleSubscriptionCountEvent(t){t.data.subscription_count&&(this.subscriptionCount=t.data.subscription_count),this.emit("pusher:subscription_count",t.data)}subscribe(){this.subscribed||(this.subscriptionPending=!0,this.subscriptionCancelled=!1,this.authorize(this.pusher.connection.socket_id,(t,e)=>{t?(this.subscriptionPending=!1,l.a.error(t.toString()),this.emit("pusher:subscription_error",Object.assign({},{type:"AuthError",error:t.message},t instanceof R?{status:t.status}:{}))):this.pusher.send_event("pusher:subscribe",{auth:e.auth,channel_data:e.channel_data,channel:this.name})}))}unsubscribe(){this.subscribed=!1,this.pusher.send_event("pusher:unsubscribe",{channel:this.name})}cancelSubscription(){this.subscriptionCancelled=!0}reinstateSubscription(){this.subscriptionCancelled=!1}}class j extends N{authorize(t,e){return this.pusher.config.channelAuthorizer({channelName:this.name,socketId:t},e)}}class D{constructor(){this.reset()}get(t){return Object.prototype.hasOwnProperty.call(this.members,t)?{id:t,info:this.members[t]}:null}each(t){r.k(this.members,(e,n)=>{t(this.get(n))})}setMyID(t){this.myID=t}onSubscription(t){this.members=t.presence.hash,this.count=t.presence.count,this.me=this.get(this.myID)}addMember(t){return null===this.get(t.user_id)&&this.count++,this.members[t.user_id]=t.user_info,this.get(t.user_id)}removeMember(t){var e=this.get(t.user_id);return e&&(delete this.members[t.user_id],this.count--),e}reset(){this.members={},this.count=0,this.myID=null,this.me=null}}var z=function(t,e,n,r){return new(n||(n=Promise))((function(i,s){function o(t){try{h(r.next(t))}catch(t){s(t)}}function a(t){try{h(r.throw(t))}catch(t){s(t)}}function h(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(o,a)}h((r=r.apply(t,e||[])).next())}))};class H extends j{constructor(t,e){super(t,e),this.members=new D}authorize(t,e){super.authorize(t,(t,n)=>z(this,void 0,void 0,(function*(){if(!t)if(null!=(n=n).channel_data){var r=JSON.parse(n.channel_data);this.members.setMyID(r.user_id)}else{if(yield this.pusher.user.signinDonePromise,null==this.pusher.user.user_data){let t=I("authorizationEndpoint");return l.a.error(`Invalid auth response for channel '${this.name}', expected 'channel_data' field. ${t}, or the user should be signed in.`),void e("Invalid auth response")}this.members.setMyID(this.pusher.user.user_data.id)}e(t,n)})))}handleEvent(t){var e=t.event;if(0===e.indexOf("pusher_internal:"))this.handleInternalEvent(t);else{var n=t.data,r={};t.user_id&&(r.user_id=t.user_id),this.emit(e,n,r)}}handleInternalEvent(t){var e=t.event,n=t.data;switch(e){case"pusher_internal:subscription_succeeded":this.handleSubscriptionSucceededEvent(t);break;case"pusher_internal:subscription_count":this.handleSubscriptionCountEvent(t);break;case"pusher_internal:member_added":var r=this.members.addMember(n);this.emit("pusher:member_added",r);break;case"pusher_internal:member_removed":var i=this.members.removeMember(n);i&&this.emit("pusher:member_removed",i)}}handleSubscriptionSucceededEvent(t){this.subscriptionPending=!1,this.subscribed=!0,this.subscriptionCancelled?this.pusher.unsubscribe(this.name):(this.members.onSubscription(t.data),this.emit("pusher:subscription_succeeded",this.members))}disconnect(){this.members.reset(),super.disconnect()}}var B=n(13),F=n(8);class q extends j{constructor(t,e,n){super(t,e),this.key=null,this.nacl=n}authorize(t,e){super.authorize(t,(t,n)=>{if(t)return void e(t,n);let r=n.shared_secret;r?(this.key=Object(F.decode)(r),delete n.shared_secret,e(null,n)):e(new Error("No shared_secret key in auth payload for encrypted channel: "+this.name),null)})}trigger(t,e){throw new O("Client events are not currently supported for encrypted channels")}handleEvent(t){var e=t.event,n=t.data;0!==e.indexOf("pusher_internal:")&&0!==e.indexOf("pusher:")?this.handleEncryptedEvent(e,n):super.handleEvent(t)}handleEncryptedEvent(t,e){if(!this.key)return void l.a.debug("Received encrypted event before key has been retrieved from the authEndpoint");if(!e.ciphertext||!e.nonce)return void l.a.error("Unexpected format for encrypted event, expected object with `ciphertext` and `nonce` fields, got: "+e);let n=Object(F.decode)(e.ciphertext);if(n.length{e?l.a.error(`Failed to make a request to the authEndpoint: ${s}. Unable to fetch new key, so dropping encrypted event`):(i=this.nacl.secretbox.open(n,r,this.key),null!==i?this.emit(t,this.getDataToEmit(i)):l.a.error("Failed to decrypt event with new key. Dropping encrypted event"))});this.emit(t,this.getDataToEmit(i))}getDataToEmit(t){let e=Object(B.decode)(t);try{return JSON.parse(e)}catch(t){return e}}}var Y=n(4);class K extends u.a{constructor(t,e){super(),this.state="initialized",this.connection=null,this.key=t,this.options=e,this.timeline=this.options.timeline,this.usingTLS=this.options.useTLS,this.errorCallbacks=this.buildErrorCallbacks(),this.connectionCallbacks=this.buildConnectionCallbacks(this.errorCallbacks),this.handshakeCallbacks=this.buildHandshakeCallbacks(this.errorCallbacks);var n=zt.getNetwork();n.bind("online",()=>{this.timeline.info({netinfo:"online"}),"connecting"!==this.state&&"unavailable"!==this.state||this.retryIn(0)}),n.bind("offline",()=>{this.timeline.info({netinfo:"offline"}),this.connection&&this.sendActivityCheck()}),this.updateStrategy()}switchCluster(t){this.key=t,this.updateStrategy(),this.retryIn(0)}connect(){this.connection||this.runner||(this.strategy.isSupported()?(this.updateState("connecting"),this.startConnecting(),this.setUnavailableTimer()):this.updateState("failed"))}send(t){return!!this.connection&&this.connection.send(t)}send_event(t,e,n){return!!this.connection&&this.connection.send_event(t,e,n)}disconnect(){this.disconnectInternally(),this.updateState("disconnected")}isUsingTLS(){return this.usingTLS}startConnecting(){var t=(e,n)=>{e?this.runner=this.strategy.connect(0,t):"error"===n.action?(this.emit("error",{type:"HandshakeError",error:n.error}),this.timeline.error({handshakeError:n.error})):(this.abortConnecting(),this.handshakeCallbacks[n.action](n))};this.runner=this.strategy.connect(0,t)}abortConnecting(){this.runner&&(this.runner.abort(),this.runner=null)}disconnectInternally(){(this.abortConnecting(),this.clearRetryTimer(),this.clearUnavailableTimer(),this.connection)&&this.abandonConnection().close()}updateStrategy(){this.strategy=this.options.getStrategy({key:this.key,timeline:this.timeline,useTLS:this.usingTLS})}retryIn(t){this.timeline.info({action:"retry",delay:t}),t>0&&this.emit("connecting_in",Math.round(t/1e3)),this.retryTimer=new Y.a(t||0,()=>{this.disconnectInternally(),this.connect()})}clearRetryTimer(){this.retryTimer&&(this.retryTimer.ensureAborted(),this.retryTimer=null)}setUnavailableTimer(){this.unavailableTimer=new Y.a(this.options.unavailableTimeout,()=>{this.updateState("unavailable")})}clearUnavailableTimer(){this.unavailableTimer&&this.unavailableTimer.ensureAborted()}sendActivityCheck(){this.stopActivityCheck(),this.connection.ping(),this.activityTimer=new Y.a(this.options.pongTimeout,()=>{this.timeline.error({pong_timed_out:this.options.pongTimeout}),this.retryIn(0)})}resetActivityCheck(){this.stopActivityCheck(),this.connection&&!this.connection.handlesActivityChecks()&&(this.activityTimer=new Y.a(this.activityTimeout,()=>{this.sendActivityCheck()}))}stopActivityCheck(){this.activityTimer&&this.activityTimer.ensureAborted()}buildConnectionCallbacks(t){return r.f({},t,{message:t=>{this.resetActivityCheck(),this.emit("message",t)},ping:()=>{this.send_event("pusher:pong",{})},activity:()=>{this.resetActivityCheck()},error:t=>{this.emit("error",t)},closed:()=>{this.abandonConnection(),this.shouldRetry()&&this.retryIn(1e3)}})}buildHandshakeCallbacks(t){return r.f({},t,{connected:t=>{this.activityTimeout=Math.min(this.options.activityTimeout,t.activityTimeout,t.connection.activityTimeout||1/0),this.clearUnavailableTimer(),this.setConnection(t.connection),this.socket_id=this.connection.id,this.updateState("connected",{socket_id:this.socket_id})}})}buildErrorCallbacks(){let t=t=>e=>{e.error&&this.emit("error",{type:"WebSocketError",error:e.error}),t(e)};return{tls_only:t(()=>{this.usingTLS=!0,this.updateStrategy(),this.retryIn(0)}),refused:t(()=>{this.disconnect()}),backoff:t(()=>{this.retryIn(1e3)}),retry:t(()=>{this.retryIn(0)})}}setConnection(t){for(var e in this.connection=t,this.connectionCallbacks)this.connection.bind(e,this.connectionCallbacks[e]);this.resetActivityCheck()}abandonConnection(){if(this.connection){for(var t in this.stopActivityCheck(),this.connectionCallbacks)this.connection.unbind(t,this.connectionCallbacks[t]);var e=this.connection;return this.connection=null,e}}updateState(t,e){var n=this.state;if(this.state=t,n!==t){var r=t;"connected"===r&&(r+=" with new socket ID "+e.socket_id),l.a.debug("State changed",n+" -> "+r),this.timeline.info({state:t,params:e}),this.emit("state_change",{previous:n,current:t}),this.emit(t,e)}}shouldRetry(){return"connecting"===this.state||"connected"===this.state}}class ${constructor(){this.channels={}}add(t,e){return this.channels[t]||(this.channels[t]=function(t,e){if(0===t.indexOf("private-encrypted-")){if(e.config.nacl)return J.createEncryptedChannel(t,e,e.config.nacl);let n="Tried to subscribe to a private-encrypted- channel but no nacl implementation available",r=I("encryptedChannelSupport");throw new O(`${n}. ${r}`)}if(0===t.indexOf("private-"))return J.createPrivateChannel(t,e);if(0===t.indexOf("presence-"))return J.createPresenceChannel(t,e);if(0===t.indexOf("#"))throw new A('Cannot create a channel with name "'+t+'".');return J.createChannel(t,e)}(t,e)),this.channels[t]}all(){return r.n(this.channels)}find(t){return this.channels[t]}remove(t){var e=this.channels[t];return delete this.channels[t],e}disconnect(){r.k(this.channels,(function(t){t.disconnect()}))}}var J={createChannels:()=>new $,createConnectionManager:(t,e)=>new K(t,e),createChannel:(t,e)=>new N(t,e),createPrivateChannel:(t,e)=>new j(t,e),createPresenceChannel:(t,e)=>new H(t,e),createEncryptedChannel:(t,e,n)=>new q(t,e,n),createTimelineSender:(t,e)=>new T(t,e),createHandshake:(t,e)=>new C(t,e),createAssistantToTheTransportManager:(t,e,n)=>new w(t,e,n)};class X{constructor(t){this.options=t||{},this.livesLeft=this.options.lives||1/0}getAssistant(t){return J.createAssistantToTheTransportManager(this,t,{minPingDelay:this.options.minPingDelay,maxPingDelay:this.options.maxPingDelay})}isAlive(){return this.livesLeft>0}reportDeath(){this.livesLeft-=1}}class W{constructor(t,e){this.strategies=t,this.loop=Boolean(e.loop),this.failFast=Boolean(e.failFast),this.timeout=e.timeout,this.timeoutLimit=e.timeoutLimit}isSupported(){return r.b(this.strategies,c.a.method("isSupported"))}connect(t,e){var n=this.strategies,r=0,i=this.timeout,s=null,o=(a,h)=>{h?e(null,h):(r+=1,this.loop&&(r%=n.length),r0&&(i=new Y.a(n.timeout,(function(){s.abort(),r(!0)}))),s=t.connect(e,(function(t,e){t&&i&&i.isRunning()&&!n.failFast||(i&&i.ensureAborted(),r(t,e))})),{abort:function(){i&&i.ensureAborted(),s.abort()},forceMinPriority:function(t){s.forceMinPriority(t)}}}}class G{constructor(t){this.strategies=t}isSupported(){return r.b(this.strategies,c.a.method("isSupported"))}connect(t,e){return function(t,e,n){var i=r.j(t,(function(t,r,i,s){return t.connect(e,n(r,s))}));return{abort:function(){r.c(i,V)},forceMinPriority:function(t){r.c(i,(function(e){e.forceMinPriority(t)}))}}}(this.strategies,t,(function(t,n){return function(i,s){n[t].error=i,i?function(t){return r.a(t,(function(t){return Boolean(t.error)}))}(n)&&e(!0):(r.c(n,(function(t){t.forceMinPriority(s.transport.priority)})),e(null,s))}}))}}function V(t){t.error||t.aborted||(t.abort(),t.aborted=!0)}class Z{constructor(t,e,n){this.strategy=t,this.transports=e,this.ttl=n.ttl||18e5,this.usingTLS=n.useTLS,this.timeline=n.timeline}isSupported(){return this.strategy.isSupported()}connect(t,e){var n=this.usingTLS,i=function(t){var e=zt.getLocalStorage();if(e)try{var n=e[Q(t)];if(n)return JSON.parse(n)}catch(e){tt(t)}return null}(n),s=i&&i.cacheSkipCount?i.cacheSkipCount:0,o=[this.strategy];if(i&&i.timestamp+this.ttl>=c.a.now()){var a=this.transports[i.transport];a&&(["ws","wss"].includes(i.transport)||s>3?(this.timeline.info({cached:!0,transport:i.transport,latency:i.latency}),o.push(new W([a],{timeout:2*i.latency+1e3,failFast:!0}))):s++)}var h=c.a.now(),u=o.pop().connect(t,(function i(a,l){a?(tt(n),o.length>0?(h=c.a.now(),u=o.pop().connect(t,i)):e(a)):(!function(t,e,n,i){var s=zt.getLocalStorage();if(s)try{s[Q(t)]=r.l({timestamp:c.a.now(),transport:e,latency:n,cacheSkipCount:i})}catch(t){}}(n,l.transport.name,c.a.now()-h,s),e(null,l))}));return{abort:function(){u.abort()},forceMinPriority:function(e){t=e,u&&u.forceMinPriority(e)}}}}function Q(t){return"pusherTransport"+(t?"TLS":"NonTLS")}function tt(t){var e=zt.getLocalStorage();if(e)try{delete e[Q(t)]}catch(t){}}class et{constructor(t,{delay:e}){this.strategy=t,this.options={delay:e}}isSupported(){return this.strategy.isSupported()}connect(t,e){var n,r=this.strategy,i=new Y.a(this.options.delay,(function(){n=r.connect(t,e)}));return{abort:function(){i.ensureAborted(),n&&n.abort()},forceMinPriority:function(e){t=e,n&&n.forceMinPriority(e)}}}}class nt{constructor(t,e,n){this.test=t,this.trueBranch=e,this.falseBranch=n}isSupported(){return(this.test()?this.trueBranch:this.falseBranch).isSupported()}connect(t,e){return(this.test()?this.trueBranch:this.falseBranch).connect(t,e)}}class rt{constructor(t){this.strategy=t}isSupported(){return this.strategy.isSupported()}connect(t,e){var n=this.strategy.connect(t,(function(t,r){r&&n.abort(),e(t,r)}));return n}}function it(t){return function(){return t.isSupported()}}var st=function(t,e,n){var i={};function s(e,r,s,o,a){var h=n(t,e,r,s,o,a);return i[e]=h,h}var o,a=Object.assign({},e,{hostNonTLS:t.wsHost+":"+t.wsPort,hostTLS:t.wsHost+":"+t.wssPort,httpPath:t.wsPath}),h=r.f({},a,{useTLS:!0}),c=Object.assign({},e,{hostNonTLS:t.httpHost+":"+t.httpPort,hostTLS:t.httpHost+":"+t.httpsPort,httpPath:t.httpPath}),u={loop:!0,timeout:15e3,timeoutLimit:6e4},l=new X({minPingDelay:1e4,maxPingDelay:t.activityTimeout}),d=new X({lives:2,minPingDelay:1e4,maxPingDelay:t.activityTimeout}),f=s("ws","ws",3,a,l),p=s("wss","ws",3,h,l),g=s("xhr_streaming","xhr_streaming",1,c,d),b=s("xhr_polling","xhr_polling",1,c),v=new W([f],u),y=new W([p],u),m=new W([g],u),w=new W([b],u),_=new W([new nt(it(m),new G([m,new et(w,{delay:4e3})]),w)],u);return o=e.useTLS?new G([v,new et(_,{delay:2e3})]):new G([v,new et(y,{delay:2e3}),new et(_,{delay:5e3})]),new Z(new rt(new nt(it(f),o,_)),i,{ttl:18e5,timeline:e.timeline,useTLS:e.useTLS})};class ot extends u.a{constructor(t,e,n){super(),this.hooks=t,this.method=e,this.url=n}start(t){this.position=0,this.xhr=this.hooks.getRequest(this),this.unloader=()=>{this.close()},zt.addUnloadListener(this.unloader),this.xhr.open(this.method,this.url,!0),this.xhr.setRequestHeader&&this.xhr.setRequestHeader("Content-Type","application/json"),this.xhr.send(t)}close(){this.unloader&&(zt.removeUnloadListener(this.unloader),this.unloader=null),this.xhr&&(this.hooks.abortRequest(this.xhr),this.xhr=null)}onChunk(t,e){for(;;){var n=this.advanceBuffer(e);if(!n)break;this.emit("chunk",{status:t,data:n})}this.isBufferTooLong(e)&&this.emit("buffer_too_long")}advanceBuffer(t){var e=t.slice(this.position),n=e.indexOf("\n");return-1!==n?(this.position+=n+1,e.slice(0,n)):null}isBufferTooLong(t){return this.position===t.length&&t.length>262144}}var at;!function(t){t[t.CONNECTING=0]="CONNECTING",t[t.OPEN=1]="OPEN",t[t.CLOSED=3]="CLOSED"}(at||(at={}));var ht=at,ct=1;function ut(t){var e=-1===t.indexOf("?")?"?":"&";return t+e+"t="+ +new Date+"&n="+ct++}function lt(t){return zt.randomInt(t)}var dt=class{constructor(t,e){this.hooks=t,this.session=lt(1e3)+"/"+function(t){for(var e=[],n=0;n{this.onChunk(t)}),this.stream.bind("finished",t=>{this.hooks.onFinished(this,t)}),this.stream.bind("buffer_too_long",()=>{this.reconnect()});try{this.stream.start()}catch(t){c.a.defer(()=>{this.onError(t),this.onClose(1006,"Could not start streaming",!1)})}}closeStream(){this.stream&&(this.stream.unbind_all(),this.stream.close(),this.stream=null)}},ft={getReceiveURL:function(t,e){return t.base+"/"+e+"/xhr_streaming"+t.queryString},onHeartbeat:function(t){t.sendRaw("[]")},sendHeartbeat:function(t){t.sendRaw("[]")},onFinished:function(t,e){t.onClose(1006,"Connection interrupted ("+e+")",!1)}},pt={getReceiveURL:function(t,e){return t.base+"/"+e+"/xhr"+t.queryString},onHeartbeat:function(){},sendHeartbeat:function(t){t.sendRaw("[]")},onFinished:function(t,e){200===e?t.reconnect():t.onClose(1006,"Connection interrupted ("+e+")",!1)}},gt={getRequest:function(t){var e=new(zt.getXHRAPI());return e.onreadystatechange=e.onprogress=function(){switch(e.readyState){case 3:e.responseText&&e.responseText.length>0&&t.onChunk(e.status,e.responseText);break;case 4:e.responseText&&e.responseText.length>0&&t.onChunk(e.status,e.responseText),t.emit("finished",e.status),t.close()}},e},abortRequest:function(t){t.onreadystatechange=null,t.abort()}},bt={getDefaultStrategy:st,Transports:m,transportConnectionInitializer:function(){this.timeline.info(this.buildTimelineMessage({transport:this.name+(this.options.useTLS?"s":"")})),this.hooks.isInitialized()?this.changeState("initialized"):this.onClose()},HTTPFactory:{createStreamingSocket(t){return this.createSocket(ft,t)},createPollingSocket(t){return this.createSocket(pt,t)},createSocket:(t,e)=>new dt(t,e),createXHR(t,e){return this.createRequest(gt,t,e)},createRequest:(t,e,n)=>new ot(t,e,n)},setup(t){t.ready()},getLocalStorage(){},getClientFeatures:()=>r.i(r.h({ws:m.ws},(function(t){return t.isSupported({})}))),getProtocol:()=>"http:",isXHRSupported:()=>!0,createSocketRequest(t,e){if(this.isXHRSupported())return this.HTTPFactory.createXHR(t,e);throw"Cross-origin HTTP requests are not supported"},createXHR(){return new(this.getXHRAPI())},createWebSocket(t){return new(this.getWebSocketAPI())(t)},addUnloadListener(t){},removeUnloadListener(t){}},vt=n(10),yt=n.n(vt);function mt(t){return"none"!==t.type.toLowerCase()}class wt extends u.a{constructor(){super(),this.online=!0,yt.a.fetch().then(t=>{this.online=mt(t)}),yt.a.addEventListener(t=>{var e=mt(t);this.online!==e&&(this.online=e,this.online?this.emit("online"):this.emit("offline"))})}isOnline(){return this.online}}var _t,St=new wt;!function(t){t.UserAuthentication="user-authentication",t.ChannelAuthorization="channel-authorization"}(_t||(_t={}));var kt=function(t,e,n,r,i){const s=zt.createXHR();for(var o in s.open("POST",n.endpoint,!0),s.setRequestHeader("Content-Type","application/x-www-form-urlencoded"),n.headers)s.setRequestHeader(o,n.headers[o]);if(null!=n.headersProvider){let t=n.headersProvider();for(var o in t)s.setRequestHeader(o,t[o])}return s.onreadystatechange=function(){if(4===s.readyState)if(200===s.status){let t,e=!1;try{t=JSON.parse(s.responseText),e=!0}catch(t){i(new R(200,`JSON returned from ${r.toString()} endpoint was invalid, yet status code was 200. Data was: ${s.responseText}`),null)}e&&i(null,t)}else{let t="";switch(r){case _t.UserAuthentication:t=I("authenticationEndpoint");break;case _t.ChannelAuthorization:t="Clients must be authorized to join private or presence channels. "+I("authorizationEndpoint")}i(new R(s.status,`Unable to retrieve auth string from ${r.toString()} endpoint - received status: ${s.status} from ${n.endpoint}. ${t}`),null)}},s.send(e),s},Ct={name:"xhr",getAgent:function(t,e){return function(n,i){var s="http"+(e?"s":"")+"://"+(t.host||t.options.host)+t.options.path;s+="/2?"+r.e(n);var o=zt.createXHR();o.open("GET",s,!0),o.onreadystatechange=function(){if(4===o.readyState){let{status:n,responseText:r}=o;if(200!==n)return void l.a.debug(`TimelineSender Error: received ${n} from stats.pusher.com`);try{var{host:e}=JSON.parse(r)}catch(t){l.a.debug("TimelineSenderError: invalid response "+r)}e&&(t.host=e)}},o.send()}}};const{getDefaultStrategy:Tt,Transports:Et,setup:At,getProtocol:Pt,isXHRSupported:xt,getLocalStorage:Ot,createXHR:Lt,createWebSocket:Ut,addUnloadListener:Rt,removeUnloadListener:Mt,transportConnectionInitializer:It,createSocketRequest:Nt,HTTPFactory:jt}=bt;var Dt,zt={getDefaultStrategy:Tt,Transports:Et,setup:At,getProtocol:Pt,isXHRSupported:xt,getLocalStorage:Ot,createXHR:Lt,createWebSocket:Ut,addUnloadListener:Rt,removeUnloadListener:Mt,transportConnectionInitializer:It,createSocketRequest:Nt,HTTPFactory:jt,TimelineTransport:Ct,getAuthorizers:()=>({ajax:kt}),getWebSocketAPI:()=>WebSocket,getXHRAPI:()=>XMLHttpRequest,getNetwork:()=>St,randomInt:t=>Math.floor(Math.random()*t)};!function(t){t[t.ERROR=3]="ERROR",t[t.INFO=6]="INFO",t[t.DEBUG=7]="DEBUG"}(Dt||(Dt={}));var Ht=Dt;class Bt{constructor(t,e,n){this.key=t,this.session=e,this.events=[],this.options=n||{},this.sent=0,this.uniqueID=0}log(t,e){t<=this.options.level&&(this.events.push(r.f({},e,{timestamp:c.a.now()})),this.options.limit&&this.events.length>this.options.limit&&this.events.shift())}error(t){this.log(Ht.ERROR,t)}info(t){this.log(Ht.INFO,t)}debug(t){this.log(Ht.DEBUG,t)}isEmpty(){return 0===this.events.length}send(t,e){var n=r.f({session:this.session,bundle:this.sent+1,key:this.key,lib:"js",version:this.options.version,cluster:this.options.cluster,features:this.options.features,timeline:this.events},this.options.params);return this.events=[],t(n,(t,n)=>{t||this.sent++,e&&e(t,n)}),!0}generateUniqueID(){return this.uniqueID++,this.uniqueID}}class Ft{constructor(t,e,n,r){this.name=t,this.priority=e,this.transport=n,this.options=r||{}}isSupported(){return this.transport.isSupported({useTLS:this.options.useTLS})}connect(t,e){if(!this.isSupported())return qt(new U,e);if(this.priority{n||(u(),s?s.close():i.close())},forceMinPriority:t=>{n||this.priority{if(void 0===zt.getAuthorizers()[t.transport])throw`'${t.transport}' is not a recognized auth transport`;return(e,n)=>{const r=((t,e)=>{var n="socket_id="+encodeURIComponent(t.socketId);for(var r in e.params)n+="&"+encodeURIComponent(r)+"="+encodeURIComponent(e.params[r]);if(null!=e.paramsProvider){let t=e.paramsProvider();for(var r in t)n+="&"+encodeURIComponent(r)+"="+encodeURIComponent(t[r])}return n})(e,t);zt.getAuthorizers()[t.transport](zt,r,t,_t.UserAuthentication,n)}};var Wt=t=>{if(void 0===zt.getAuthorizers()[t.transport])throw`'${t.transport}' is not a recognized auth transport`;return(e,n)=>{const r=((t,e)=>{var n="socket_id="+encodeURIComponent(t.socketId);for(var r in n+="&channel_name="+encodeURIComponent(t.channelName),e.params)n+="&"+encodeURIComponent(r)+"="+encodeURIComponent(e.params[r]);if(null!=e.paramsProvider){let t=e.paramsProvider();for(var r in t)n+="&"+encodeURIComponent(r)+"="+encodeURIComponent(t[r])}return n})(e,t);zt.getAuthorizers()[t.transport](zt,r,t,_t.ChannelAuthorization,n)}};const Gt=(t,e,n)=>{const r={authTransport:e.transport,authEndpoint:e.endpoint,auth:{params:e.params,headers:e.headers}};return(e,i)=>{const s=t.channel(e.channelName);n(s,r).authorize(e.socketId,i)}};function Vt(t,e){let n={activityTimeout:t.activityTimeout||i.activityTimeout,cluster:t.cluster,httpPath:t.httpPath||i.httpPath,httpPort:t.httpPort||i.httpPort,httpsPort:t.httpsPort||i.httpsPort,pongTimeout:t.pongTimeout||i.pongTimeout,statsHost:t.statsHost||i.stats_host,unavailableTimeout:t.unavailableTimeout||i.unavailableTimeout,wsPath:t.wsPath||i.wsPath,wsPort:t.wsPort||i.wsPort,wssPort:t.wssPort||i.wssPort,enableStats:ee(t),httpHost:Zt(t),useTLS:te(t),wsHost:Qt(t),userAuthenticator:re(t),channelAuthorizer:ie(t,e)};return"disabledTransports"in t&&(n.disabledTransports=t.disabledTransports),"enabledTransports"in t&&(n.enabledTransports=t.enabledTransports),"ignoreNullOrigin"in t&&(n.ignoreNullOrigin=t.ignoreNullOrigin),"timelineParams"in t&&(n.timelineParams=t.timelineParams),"nacl"in t&&(n.nacl=t.nacl),n}function Zt(t){return t.httpHost?t.httpHost:t.cluster?`sockjs-${t.cluster}.pusher.com`:i.httpHost}function Qt(t){return t.wsHost?t.wsHost:`ws-${t.cluster}.pusher.com`}function te(t){return"https:"===zt.getProtocol()||!1!==t.forceTLS}function ee(t){return"enableStats"in t?t.enableStats:"disableStats"in t&&!t.disableStats}const ne=t=>"customHandler"in t&&null!=t.customHandler;function re(t){const e=Object.assign(Object.assign({},i.userAuthentication),t.userAuthentication);return ne(e)?e.customHandler:Xt(e)}function ie(t,e){const n=function(t,e){let n;if("channelAuthorization"in t)n=Object.assign(Object.assign({},i.channelAuthorization),t.channelAuthorization);else if(n={transport:t.authTransport||i.authTransport,endpoint:t.authEndpoint||i.authEndpoint},"auth"in t&&("params"in t.auth&&(n.params=t.auth.params),"headers"in t.auth&&(n.headers=t.auth.headers)),"authorizer"in t)return{customHandler:Gt(e,n,t.authorizer)};return n}(t,e);return ne(n)?n.customHandler:Wt(n)}class se extends u.a{constructor(t){super((function(t,e){l.a.debug("No callbacks on watchlist events for "+t)})),this.pusher=t,this.bindWatchlistInternalEvent()}handleEvent(t){t.data.events.forEach(t=>{this.emit(t.name,t)})}bindWatchlistInternalEvent(){this.pusher.connection.bind("message",t=>{"pusher_internal:watchlist_events"===t.event&&this.handleEvent(t)})}}var oe=function(){let t,e;return{promise:new Promise((n,r)=>{t=n,e=r}),resolve:t,reject:e}};class ae extends u.a{constructor(t){super((function(t,e){l.a.debug("No callbacks on user for "+t)})),this.signin_requested=!1,this.user_data=null,this.serverToUserChannel=null,this.signinDonePromise=null,this._signinDoneResolve=null,this._onAuthorize=(t,e)=>{if(t)return l.a.warn("Error during signin: "+t),void this._cleanup();this.pusher.send_event("pusher:signin",{auth:e.auth,user_data:e.user_data})},this.pusher=t,this.pusher.connection.bind("state_change",({previous:t,current:e})=>{"connected"!==t&&"connected"===e&&this._signin(),"connected"===t&&"connected"!==e&&(this._cleanup(),this._newSigninPromiseIfNeeded())}),this.watchlist=new se(t),this.pusher.connection.bind("message",t=>{"pusher:signin_success"===t.event&&this._onSigninSuccess(t.data),this.serverToUserChannel&&this.serverToUserChannel.name===t.channel&&this.serverToUserChannel.handleEvent(t)})}signin(){this.signin_requested||(this.signin_requested=!0,this._signin())}_signin(){this.signin_requested&&(this._newSigninPromiseIfNeeded(),"connected"===this.pusher.connection.state&&this.pusher.config.userAuthenticator({socketId:this.pusher.connection.socket_id},this._onAuthorize))}_onSigninSuccess(t){try{this.user_data=JSON.parse(t.user_data)}catch(e){return l.a.error("Failed parsing user data after signin: "+t.user_data),void this._cleanup()}if("string"!=typeof this.user_data.id||""===this.user_data.id)return l.a.error("user_data doesn't contain an id. user_data: "+this.user_data),void this._cleanup();this._signinDoneResolve(),this._subscribeChannels()}_subscribeChannels(){this.serverToUserChannel=new N("#server-to-user-"+this.user_data.id,this.pusher),this.serverToUserChannel.bind_global((t,e)=>{0!==t.indexOf("pusher_internal:")&&0!==t.indexOf("pusher:")&&this.emit(t,e)}),(t=>{t.subscriptionPending&&t.subscriptionCancelled?t.reinstateSubscription():t.subscriptionPending||"connected"!==this.pusher.connection.state||t.subscribe()})(this.serverToUserChannel)}_cleanup(){this.user_data=null,this.serverToUserChannel&&(this.serverToUserChannel.unbind_all(),this.serverToUserChannel.disconnect(),this.serverToUserChannel=null),this.signin_requested&&this._signinDoneResolve()}_newSigninPromiseIfNeeded(){if(!this.signin_requested)return;if(this.signinDonePromise&&!this.signinDonePromise.done)return;const{promise:t,resolve:e,reject:n}=oe();t.done=!1;const r=()=>{t.done=!0};t.then(r).catch(r),this.signinDonePromise=t,this._signinDoneResolve=e}}class he{static ready(){he.isReady=!0;for(var t=0,e=he.instances.length;tzt.getDefaultStrategy(this.config,t,Kt),timeline:this.timeline,activityTimeout:this.config.activityTimeout,pongTimeout:this.config.pongTimeout,unavailableTimeout:this.config.unavailableTimeout,useTLS:Boolean(this.config.useTLS)}),this.connection.bind("connected",()=>{this.subscribeAll(),this.timelineSender&&this.timelineSender.send(this.connection.isUsingTLS())}),this.connection.bind("message",t=>{var e=0===t.event.indexOf("pusher_internal:");if(t.channel){var n=this.channel(t.channel);n&&n.handleEvent(t)}e||this.global_emitter.emit(t.event,t.data)}),this.connection.bind("connecting",()=>{this.channels.disconnect()}),this.connection.bind("disconnected",()=>{this.channels.disconnect()}),this.connection.bind("error",t=>{l.a.warn(t)}),he.instances.push(this),this.timeline.info({instances:he.instances.length}),this.user=new ae(this),he.isReady&&this.connect()}switchCluster(t){const{appKey:e,cluster:n}=t;this.key=e,this.options=Object.assign(Object.assign({},this.options),{cluster:n}),this.config=Vt(this.options,this),this.connection.switchCluster(this.key)}channel(t){return this.channels.find(t)}allChannels(){return this.channels.all()}connect(){if(this.connection.connect(),this.timelineSender&&!this.timelineSenderTimer){var t=this.connection.isUsingTLS(),e=this.timelineSender;this.timelineSenderTimer=new Y.b(6e4,(function(){e.send(t)}))}}disconnect(){this.connection.disconnect(),this.timelineSenderTimer&&(this.timelineSenderTimer.ensureAborted(),this.timelineSenderTimer=null)}bind(t,e,n){return this.global_emitter.bind(t,e,n),this}unbind(t,e,n){return this.global_emitter.unbind(t,e,n),this}bind_global(t){return this.global_emitter.bind_global(t),this}unbind_global(t){return this.global_emitter.unbind_global(t),this}unbind_all(t){return this.global_emitter.unbind_all(),this}subscribeAll(){var t;for(t in this.channels.channels)this.channels.channels.hasOwnProperty(t)&&this.subscribe(t)}subscribe(t){var e=this.channels.add(t,this);return e.subscriptionPending&&e.subscriptionCancelled?e.reinstateSubscription():e.subscriptionPending||"connected"!==this.connection.state||e.subscribe(),e}unsubscribe(t){var e=this.channels.find(t);e&&e.subscriptionPending?e.cancelSubscription():(e=this.channels.remove(t))&&e.subscribed&&e.unsubscribe()}send_event(t,e,n){return this.connection.send_event(t,e,n)}shouldUseTLS(){return this.config.useTLS}signin(){this.user.signin()}}he.instances=[],he.isReady=!1,he.logToConsole=!1,he.Runtime=zt,he.ScriptReceivers=zt.ScriptReceivers,he.DependenciesReceivers=zt.DependenciesReceivers,he.auth_callbacks=zt.auth_callbacks;e.a=he;zt.setup(he)},function(t,e){var n;n=function(){return this}();try{n=n||new Function("return this")()}catch(t){"object"==typeof window&&(n=window)}t.exports=n},function(t,e,n){"use strict";n.d(e,"a",(function(){return i}));var r=n(1);function i(t){if(null==t)throw"You must pass an options object";if(null==t.cluster)throw"Options object must provide a cluster";"disableStats"in t&&r.a.warn("The disableStats option is deprecated in favor of enableStats")}},function(t,e,n){"use strict";var r,i=this&&this.__extends||(r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)},function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)});Object.defineProperty(e,"__esModule",{value:!0});var s=function(){function t(t){void 0===t&&(t="="),this._paddingCharacter=t}return t.prototype.encodedLength=function(t){return this._paddingCharacter?(t+2)/3*4|0:(8*t+5)/6|0},t.prototype.encode=function(t){for(var e="",n=0;n>>18&63),e+=this._encodeByte(r>>>12&63),e+=this._encodeByte(r>>>6&63),e+=this._encodeByte(r>>>0&63)}var i=t.length-n;if(i>0){r=t[n]<<16|(2===i?t[n+1]<<8:0);e+=this._encodeByte(r>>>18&63),e+=this._encodeByte(r>>>12&63),e+=2===i?this._encodeByte(r>>>6&63):this._paddingCharacter||"",e+=this._paddingCharacter||""}return e},t.prototype.maxDecodedLength=function(t){return this._paddingCharacter?t/4*3|0:(6*t+7)/8|0},t.prototype.decodedLength=function(t){return this.maxDecodedLength(t.length-this._getPaddingLength(t))},t.prototype.decode=function(t){if(0===t.length)return new Uint8Array(0);for(var e=this._getPaddingLength(t),n=t.length-e,r=new Uint8Array(this.maxDecodedLength(n)),i=0,s=0,o=0,a=0,h=0,c=0,u=0;s>>4,r[i++]=h<<4|c>>>2,r[i++]=c<<6|u,o|=256&a,o|=256&h,o|=256&c,o|=256&u;if(s>>4,o|=256&a,o|=256&h),s>>2,o|=256&c),s>>8&6,e+=51-t>>>8&-75,e+=61-t>>>8&-15,e+=62-t>>>8&3,String.fromCharCode(e)},t.prototype._decodeChar=function(t){var e=256;return e+=(42-t&t-44)>>>8&-256+t-43+62,e+=(46-t&t-48)>>>8&-256+t-47+63,e+=(47-t&t-58)>>>8&-256+t-48+52,e+=(64-t&t-91)>>>8&-256+t-65+0,e+=(96-t&t-123)>>>8&-256+t-97+26},t.prototype._getPaddingLength=function(t){var e=0;if(this._paddingCharacter){for(var n=t.length-1;n>=0&&t[n]===this._paddingCharacter;n--)e++;if(t.length<4||e>2)throw new Error("Base64Coder: incorrect padding")}return e},t}();e.Coder=s;var o=new s;e.encode=function(t){return o.encode(t)},e.decode=function(t){return o.decode(t)};var a=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return i(e,t),e.prototype._encodeByte=function(t){var e=t;return e+=65,e+=25-t>>>8&6,e+=51-t>>>8&-75,e+=61-t>>>8&-13,e+=62-t>>>8&49,String.fromCharCode(e)},e.prototype._decodeChar=function(t){var e=256;return e+=(44-t&t-46)>>>8&-256+t-45+62,e+=(94-t&t-96)>>>8&-256+t-95+63,e+=(47-t&t-58)>>>8&-256+t-48+52,e+=(64-t&t-91)>>>8&-256+t-65+0,e+=(96-t&t-123)>>>8&-256+t-97+26},e}(s);e.URLSafeCoder=a;var h=new a;e.encodeURLSafe=function(t){return h.encode(t)},e.decodeURLSafe=function(t){return h.decode(t)},e.encodedLength=function(t){return o.encodedLength(t)},e.maxDecodedLength=function(t){return o.maxDecodedLength(t)},e.decodedLength=function(t){return o.decodedLength(t)}},function(t,e,n){"use strict";e.a=class{constructor(t,e,n,r){this.clear=e,this.timer=t(()=>{this.timer&&(this.timer=r(this.timer))},n)}isRunning(){return null!==this.timer}ensureAborted(){this.timer&&(this.clear(this.timer),this.timer=null)}}},function(t,e){t.exports=require("@react-native-community/netinfo")},function(t,e,n){"use strict";(function(t){function r(t){return d(u(t))}n.d(e,"a",(function(){return r}));for(var i=String.fromCharCode,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",o={},a=0,h=s.length;a>>6)+i(128|63&e):i(224|e>>>12&15)+i(128|e>>>6&63)+i(128|63&e)},u=function(t){return t.replace(/[^\x00-\x7F]/g,c)},l=function(t){var e=[0,2,1][t.length%3],n=t.charCodeAt(0)<<16|(t.length>1?t.charCodeAt(1):0)<<8|(t.length>2?t.charCodeAt(2):0);return[s.charAt(n>>>18),s.charAt(n>>>12&63),e>=2?"=":s.charAt(n>>>6&63),e>=1?"=":s.charAt(63&n)].join("")},d=t.btoa||function(t){return t.replace(/[\s\S]{1,3}/g,l)}}).call(this,n(6))},function(t,e,n){"use strict";n.d(e,"a",(function(){return i}));var r=n(0);class i{constructor(){this._callbacks={}}get(t){return this._callbacks[s(t)]}add(t,e,n){var r=s(t);this._callbacks[r]=this._callbacks[r]||[],this._callbacks[r].push({fn:e,context:n})}remove(t,e,n){if(t||e||n){var i=t?[s(t)]:r.i(this._callbacks);e||n?this.removeCallback(i,e,n):this.removeAllCallbacks(i)}else this._callbacks={}}removeCallback(t,e,n){r.c(t,(function(t){this._callbacks[t]=r.g(this._callbacks[t]||[],(function(t){return e&&e!==t.fn||n&&n!==t.context})),0===this._callbacks[t].length&&delete this._callbacks[t]}),this)}removeAllCallbacks(t){r.c(t,(function(t){delete this._callbacks[t]}),this)}}function s(t){return"_"+t}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r="utf8: invalid source encoding";function i(t){for(var e=0,n=0;n=t.length-1)throw new Error("utf8: invalid string");n++,e+=4}}return e}e.encode=function(t){for(var e=new Uint8Array(i(t)),n=0,r=0;r>6,e[n++]=128|63&s):s<55296?(e[n++]=224|s>>12,e[n++]=128|s>>6&63,e[n++]=128|63&s):(r++,s=(1023&s)<<10,s|=1023&t.charCodeAt(r),s+=65536,e[n++]=240|s>>18,e[n++]=128|s>>12&63,e[n++]=128|s>>6&63,e[n++]=128|63&s)}return e},e.encodedLength=i,e.decode=function(t){for(var e=[],n=0;n=t.length)throw new Error(r);if(128!=(192&(o=t[++n])))throw new Error(r);i=(31&i)<<6|63&o,s=128}else if(i<240){if(n>=t.length-1)throw new Error(r);var o=t[++n],a=t[++n];if(128!=(192&o)||128!=(192&a))throw new Error(r);i=(15&i)<<12|(63&o)<<6|63&a,s=2048}else{if(!(i<248))throw new Error(r);if(n>=t.length-2)throw new Error(r);o=t[++n],a=t[++n];var h=t[++n];if(128!=(192&o)||128!=(192&a)||128!=(192&h))throw new Error(r);i=(15&i)<<18|(63&o)<<12|(63&a)<<6|63&h,s=65536}if(i=55296&&i<=57343)throw new Error(r);if(i>=65536){if(i>1114111)throw new Error(r);i-=65536,e.push(String.fromCharCode(55296|i>>10)),i=56320|1023&i}}e.push(String.fromCharCode(i))}return e.join("")}},function(t,e,n){!function(t){"use strict";var e=function(t){var e,n=new Float64Array(16);if(t)for(e=0;e>24&255,t[e+1]=n>>16&255,t[e+2]=n>>8&255,t[e+3]=255&n,t[e+4]=r>>24&255,t[e+5]=r>>16&255,t[e+6]=r>>8&255,t[e+7]=255&r}function g(t,e,n,r,i){var s,o=0;for(s=0;s>>8)-1}function b(t,e,n,r){return g(t,e,n,r,16)}function v(t,e,n,r){return g(t,e,n,r,32)}function y(t,e,n,r){!function(t,e,n,r){for(var i,s=255&r[0]|(255&r[1])<<8|(255&r[2])<<16|(255&r[3])<<24,o=255&n[0]|(255&n[1])<<8|(255&n[2])<<16|(255&n[3])<<24,a=255&n[4]|(255&n[5])<<8|(255&n[6])<<16|(255&n[7])<<24,h=255&n[8]|(255&n[9])<<8|(255&n[10])<<16|(255&n[11])<<24,c=255&n[12]|(255&n[13])<<8|(255&n[14])<<16|(255&n[15])<<24,u=255&r[4]|(255&r[5])<<8|(255&r[6])<<16|(255&r[7])<<24,l=255&e[0]|(255&e[1])<<8|(255&e[2])<<16|(255&e[3])<<24,d=255&e[4]|(255&e[5])<<8|(255&e[6])<<16|(255&e[7])<<24,f=255&e[8]|(255&e[9])<<8|(255&e[10])<<16|(255&e[11])<<24,p=255&e[12]|(255&e[13])<<8|(255&e[14])<<16|(255&e[15])<<24,g=255&r[8]|(255&r[9])<<8|(255&r[10])<<16|(255&r[11])<<24,b=255&n[16]|(255&n[17])<<8|(255&n[18])<<16|(255&n[19])<<24,v=255&n[20]|(255&n[21])<<8|(255&n[22])<<16|(255&n[23])<<24,y=255&n[24]|(255&n[25])<<8|(255&n[26])<<16|(255&n[27])<<24,m=255&n[28]|(255&n[29])<<8|(255&n[30])<<16|(255&n[31])<<24,w=255&r[12]|(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S>>>16&255,t[7]=S>>>24&255,t[8]=k>>>0&255,t[9]=k>>>8&255,t[10]=k>>>16&255,t[11]=k>>>24&255,t[12]=C>>>0&255,t[13]=C>>>8&255,t[14]=C>>>16&255,t[15]=C>>>24&255,t[16]=T>>>0&255,t[17]=T>>>8&255,t[18]=T>>>16&255,t[19]=T>>>24&255,t[20]=E>>>0&255,t[21]=E>>>8&255,t[22]=E>>>16&255,t[23]=E>>>24&255,t[24]=A>>>0&255,t[25]=A>>>8&255,t[26]=A>>>16&255,t[27]=A>>>24&255,t[28]=P>>>0&255,t[29]=P>>>8&255,t[30]=P>>>16&255,t[31]=P>>>24&255,t[32]=x>>>0&255,t[33]=x>>>8&255,t[34]=x>>>16&255,t[35]=x>>>24&255,t[36]=O>>>0&255,t[37]=O>>>8&255,t[38]=O>>>16&255,t[39]=O>>>24&255,t[40]=L>>>0&255,t[41]=L>>>8&255,t[42]=L>>>16&255,t[43]=L>>>24&255,t[44]=U>>>0&255,t[45]=U>>>8&255,t[46]=U>>>16&255,t[47]=U>>>24&255,t[48]=R>>>0&255,t[49]=R>>>8&255,t[50]=R>>>16&255,t[51]=R>>>24&255,t[52]=M>>>0&255,t[53]=M>>>8&255,t[54]=M>>>16&255,t[55]=M>>>24&255,t[56]=I>>>0&255,t[57]=I>>>8&255,t[58]=I>>>16&255,t[59]=I>>>24&255,t[60]=N>>>0&255,t[61]=N>>>8&255,t[62]=N>>>16&255,t[63]=N>>>24&255}(t,e,n,r)}function m(t,e,n,r){!function(t,e,n,r){for(var i,s=255&r[0]|(255&r[1])<<8|(255&r[2])<<16|(255&r[3])<<24,o=255&n[0]|(255&n[1])<<8|(255&n[2])<<16|(255&n[3])<<24,a=255&n[4]|(255&n[5])<<8|(255&n[6])<<16|(255&n[7])<<24,h=255&n[8]|(255&n[9])<<8|(255&n[10])<<16|(255&n[11])<<24,c=255&n[12]|(255&n[13])<<8|(255&n[14])<<16|(255&n[15])<<24,u=255&r[4]|(255&r[5])<<8|(255&r[6])<<16|(255&r[7])<<24,l=255&e[0]|(255&e[1])<<8|(255&e[2])<<16|(255&e[3])<<24,d=255&e[4]|(255&e[5])<<8|(255&e[6])<<16|(255&e[7])<<24,f=255&e[8]|(255&e[9])<<8|(255&e[10])<<16|(255&e[11])<<24,p=255&e[12]|(255&e[13])<<8|(255&e[14])<<16|(255&e[15])<<24,g=255&r[8]|(255&r[9])<<8|(255&r[10])<<16|(255&r[11])<<24,b=255&n[16]|(255&n[17])<<8|(255&n[18])<<16|(255&n[19])<<24,v=255&n[20]|(255&n[21])<<8|(255&n[22])<<16|(255&n[23])<<24,y=255&n[24]|(255&n[25])<<8|(255&n[26])<<16|(255&n[27])<<24,m=255&n[28]|(255&n[29])<<8|(255&n[30])<<16|(255&n[31])<<24,w=255&r[12]|(255&r[13])<<8|(255&r[14])<<16|(255&r[15])<<24,_=0;_<20;_+=2)s^=(i=(v^=(i=(f^=(i=(c^=(i=s+v|0)<<7|i>>>25)+s|0)<<9|i>>>23)+c|0)<<13|i>>>19)+f|0)<<18|i>>>14,u^=(i=(o^=(i=(y^=(i=(p^=(i=u+o|0)<<7|i>>>25)+u|0)<<9|i>>>23)+p|0)<<13|i>>>19)+y|0)<<18|i>>>14,g^=(i=(l^=(i=(a^=(i=(m^=(i=g+l|0)<<7|i>>>25)+g|0)<<9|i>>>23)+m|0)<<13|i>>>19)+a|0)<<18|i>>>14,w^=(i=(b^=(i=(d^=(i=(h^=(i=w+b|0)<<7|i>>>25)+w|0)<<9|i>>>23)+h|0)<<13|i>>>19)+d|0)<<18|i>>>14,s^=(i=(h^=(i=(a^=(i=(o^=(i=s+h|0)<<7|i>>>25)+s|0)<<9|i>>>23)+o|0)<<13|i>>>19)+a|0)<<18|i>>>14,u^=(i=(c^=(i=(d^=(i=(l^=(i=u+c|0)<<7|i>>>25)+u|0)<<9|i>>>23)+l|0)<<13|i>>>19)+d|0)<<18|i>>>14,g^=(i=(p^=(i=(f^=(i=(b^=(i=g+p|0)<<7|i>>>25)+g|0)<<9|i>>>23)+b|0)<<13|i>>>19)+f|0)<<18|i>>>14,w^=(i=(m^=(i=(y^=(i=(v^=(i=w+m|0)<<7|i>>>25)+w|0)<<9|i>>>23)+v|0)<<13|i>>>19)+y|0)<<18|i>>>14;t[0]=s>>>0&255,t[1]=s>>>8&255,t[2]=s>>>16&255,t[3]=s>>>24&255,t[4]=u>>>0&255,t[5]=u>>>8&255,t[6]=u>>>16&255,t[7]=u>>>24&255,t[8]=g>>>0&255,t[9]=g>>>8&255,t[10]=g>>>16&255,t[11]=g>>>24&255,t[12]=w>>>0&255,t[13]=w>>>8&255,t[14]=w>>>16&255,t[15]=w>>>24&255,t[16]=l>>>0&255,t[17]=l>>>8&255,t[18]=l>>>16&255,t[19]=l>>>24&255,t[20]=d>>>0&255,t[21]=d>>>8&255,t[22]=d>>>16&255,t[23]=d>>>24&255,t[24]=f>>>0&255,t[25]=f>>>8&255,t[26]=f>>>16&255,t[27]=f>>>24&255,t[28]=p>>>0&255,t[29]=p>>>8&255,t[30]=p>>>16&255,t[31]=p>>>24&255}(t,e,n,r)}var w=new Uint8Array([101,120,112,97,110,100,32,51,50,45,98,121,116,101,32,107]);function _(t,e,n,r,i,s,o){var a,h,c=new Uint8Array(16),u=new Uint8Array(64);for(h=0;h<16;h++)c[h]=0;for(h=0;h<8;h++)c[h]=s[h];for(;i>=64;){for(y(u,c,o,w),h=0;h<64;h++)t[e+h]=n[r+h]^u[h];for(a=1,h=8;h<16;h++)a=a+(255&c[h])|0,c[h]=255&a,a>>>=8;i-=64,e+=64,r+=64}if(i>0)for(y(u,c,o,w),h=0;h=64;){for(y(h,a,i,w),o=0;o<64;o++)t[e+o]=h[o];for(s=1,o=8;o<16;o++)s=s+(255&a[o])|0,a[o]=255&s,s>>>=8;n-=64,e+=64}if(n>0)for(y(h,a,i,w),o=0;o>>13|n<<3),r=255&t[4]|(255&t[5])<<8,this.r[2]=7939&(n>>>10|r<<6),i=255&t[6]|(255&t[7])<<8,this.r[3]=8191&(r>>>7|i<<9),s=255&t[8]|(255&t[9])<<8,this.r[4]=255&(i>>>4|s<<12),this.r[5]=s>>>1&8190,o=255&t[10]|(255&t[11])<<8,this.r[6]=8191&(s>>>14|o<<2),a=255&t[12]|(255&t[13])<<8,this.r[7]=8065&(o>>>11|a<<5),h=255&t[14]|(255&t[15])<<8,this.r[8]=8191&(a>>>8|h<<8),this.r[9]=h>>>5&127,this.pad[0]=255&t[16]|(255&t[17])<<8,this.pad[1]=255&t[18]|(255&t[19])<<8,this.pad[2]=255&t[20]|(255&t[21])<<8,this.pad[3]=255&t[22]|(255&t[23])<<8,this.pad[4]=255&t[24]|(255&t[25])<<8,this.pad[5]=255&t[26]|(255&t[27])<<8,this.pad[6]=255&t[28]|(255&t[29])<<8,this.pad[7]=255&t[30]|(255&t[31])<<8};function E(t,e,n,r,i,s){var o=new T(s);return o.update(n,r,i),o.finish(t,e),0}function A(t,e,n,r,i,s){var o=new Uint8Array(16);return E(o,0,n,r,i,s),b(t,e,o,0)}function P(t,e,n,r,i){var s;if(n<32)return-1;for(C(t,0,e,0,n,r,i),E(t,16,t,32,n-32,t),s=0;s<16;s++)t[s]=0;return 0}function x(t,e,n,r,i){var s,o=new Uint8Array(32);if(n<32)return-1;if(k(o,0,32,r,i),0!==A(e,16,e,32,n-32,o))return-1;for(C(t,0,e,0,n,r,i),s=0;s<32;s++)t[s]=0;return 0}function O(t,e){var n;for(n=0;n<16;n++)t[n]=0|e[n]}function L(t){var e,n,r=1;for(e=0;e<16;e++)n=t[e]+r+65535,r=Math.floor(n/65536),t[e]=n-65536*r;t[0]+=r-1+37*(r-1)}function U(t,e,n){for(var r,i=~(n-1),s=0;s<16;s++)r=i&(t[s]^e[s]),t[s]^=r,e[s]^=r}function R(t,n){var r,i,s,o=e(),a=e();for(r=0;r<16;r++)a[r]=n[r];for(L(a),L(a),L(a),i=0;i<2;i++){for(o[0]=a[0]-65517,r=1;r<15;r++)o[r]=a[r]-65535-(o[r-1]>>16&1),o[r-1]&=65535;o[15]=a[15]-32767-(o[14]>>16&1),s=o[15]>>16&1,o[14]&=65535,U(a,o,1-s)}for(r=0;r<16;r++)t[2*r]=255&a[r],t[2*r+1]=a[r]>>8}function M(t,e){var n=new Uint8Array(32),r=new Uint8Array(32);return R(n,t),R(r,e),v(n,0,r,0)}function I(t){var e=new Uint8Array(32);return R(e,t),1&e[0]}function N(t,e){var n;for(n=0;n<16;n++)t[n]=e[2*n]+(e[2*n+1]<<8);t[15]&=32767}function j(t,e,n){for(var r=0;r<16;r++)t[r]=e[r]+n[r]}function D(t,e,n){for(var r=0;r<16;r++)t[r]=e[r]-n[r]}function z(t,e,n){var r,i,s=0,o=0,a=0,h=0,c=0,u=0,l=0,d=0,f=0,p=0,g=0,b=0,v=0,y=0,m=0,w=0,_=0,S=0,k=0,C=0,T=0,E=0,A=0,P=0,x=0,O=0,L=0,U=0,R=0,M=0,I=0,N=n[0],j=n[1],D=n[2],z=n[3],H=n[4],B=n[5],F=n[6],q=n[7],Y=n[8],K=n[9],$=n[10],J=n[11],X=n[12],W=n[13],G=n[14],V=n[15];s+=(r=e[0])*N,o+=r*j,a+=r*D,h+=r*z,c+=r*H,u+=r*B,l+=r*F,d+=r*q,f+=r*Y,p+=r*K,g+=r*$,b+=r*J,v+=r*X,y+=r*W,m+=r*G,w+=r*V,o+=(r=e[1])*N,a+=r*j,h+=r*D,c+=r*z,u+=r*H,l+=r*B,d+=r*F,f+=r*q,p+=r*Y,g+=r*K,b+=r*$,v+=r*J,y+=r*X,m+=r*W,w+=r*G,_+=r*V,a+=(r=e[2])*N,h+=r*j,c+=r*D,u+=r*z,l+=r*H,d+=r*B,f+=r*F,p+=r*q,g+=r*Y,b+=r*K,v+=r*$,y+=r*J,m+=r*X,w+=r*W,_+=r*G,S+=r*V,h+=(r=e[3])*N,c+=r*j,u+=r*D,l+=r*z,d+=r*H,f+=r*B,p+=r*F,g+=r*q,b+=r*Y,v+=r*K,y+=r*$,m+=r*J,w+=r*X,_+=r*W,S+=r*G,k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*Y,E+=r*K,A+=r*$,P+=r*J,x+=r*X,O+=r*W,L+=r*G,U+=r*V,y+=(r=e[13])*N,m+=r*j,w+=r*D,_+=r*z,S+=r*H,k+=r*B,C+=r*F,T+=r*q,E+=r*Y,A+=r*K,P+=r*$,x+=r*J,O+=r*X,L+=r*W,U+=r*G,R+=r*V,m+=(r=e[14])*N,w+=r*j,_+=r*D,S+=r*z,k+=r*H,C+=r*B,T+=r*F,E+=r*q,A+=r*Y,P+=r*K,x+=r*$,O+=r*J,L+=r*X,U+=r*W,R+=r*G,M+=r*V,w+=(r=e[15])*N,o+=38*(S+=r*D),a+=38*(k+=r*z),h+=38*(C+=r*H),c+=38*(T+=r*B),u+=38*(E+=r*F),l+=38*(A+=r*q),d+=38*(P+=r*Y),f+=38*(x+=r*K),p+=38*(O+=r*$),g+=38*(L+=r*J),b+=38*(U+=r*X),v+=38*(R+=r*W),y+=38*(M+=r*G),m+=38*(I+=r*V),s=(r=(s+=38*(_+=r*j))+(i=1)+65535)-65536*(i=Math.floor(r/65536)),o=(r=o+i+65535)-65536*(i=Math.floor(r/65536)),a=(r=a+i+65535)-65536*(i=Math.floor(r/65536)),h=(r=h+i+65535)-65536*(i=Math.floor(r/65536)),c=(r=c+i+65535)-65536*(i=Math.floor(r/65536)),u=(r=u+i+65535)-65536*(i=Math.floor(r/65536)),l=(r=l+i+65535)-65536*(i=Math.floor(r/65536)),d=(r=d+i+65535)-65536*(i=Math.floor(r/65536)),f=(r=f+i+65535)-65536*(i=Math.floor(r/65536)),p=(r=p+i+65535)-65536*(i=Math.floor(r/65536)),g=(r=g+i+65535)-65536*(i=Math.floor(r/65536)),b=(r=b+i+65535)-65536*(i=Math.floor(r/65536)),v=(r=v+i+65535)-65536*(i=Math.floor(r/65536)),y=(r=y+i+65535)-65536*(i=Math.floor(r/65536)),m=(r=m+i+65535)-65536*(i=Math.floor(r/65536)),w=(r=w+i+65535)-65536*(i=Math.floor(r/65536)),s=(r=(s+=i-1+37*(i-1))+(i=1)+65535)-65536*(i=Math.floor(r/65536)),o=(r=o+i+65535)-65536*(i=Math.floor(r/65536)),a=(r=a+i+65535)-65536*(i=Math.floor(r/65536)),h=(r=h+i+65535)-65536*(i=Math.floor(r/65536)),c=(r=c+i+65535)-65536*(i=Math.floor(r/65536)),u=(r=u+i+65535)-65536*(i=Math.floor(r/65536)),l=(r=l+i+65535)-65536*(i=Math.floor(r/65536)),d=(r=d+i+65535)-65536*(i=Math.floor(r/65536)),f=(r=f+i+65535)-65536*(i=Math.floor(r/65536)),p=(r=p+i+65535)-65536*(i=Math.floor(r/65536)),g=(r=g+i+65535)-65536*(i=Math.floor(r/65536)),b=(r=b+i+65535)-65536*(i=Math.floor(r/65536)),v=(r=v+i+65535)-65536*(i=Math.floor(r/65536)),y=(r=y+i+65535)-65536*(i=Math.floor(r/65536)),m=(r=m+i+65535)-65536*(i=Math.floor(r/65536)),w=(r=w+i+65535)-65536*(i=Math.floor(r/65536)),s+=i-1+37*(i-1),t[0]=s,t[1]=o,t[2]=a,t[3]=h,t[4]=c,t[5]=u,t[6]=l,t[7]=d,t[8]=f,t[9]=p,t[10]=g,t[11]=b,t[12]=v,t[13]=y,t[14]=m,t[15]=w}function H(t,e){z(t,e,e)}function B(t,n){var r,i=e();for(r=0;r<16;r++)i[r]=n[r];for(r=253;r>=0;r--)H(i,i),2!==r&&4!==r&&z(i,i,n);for(r=0;r<16;r++)t[r]=i[r]}function F(t,n){var r,i=e();for(r=0;r<16;r++)i[r]=n[r];for(r=250;r>=0;r--)H(i,i),1!==r&&z(i,i,n);for(r=0;r<16;r++)t[r]=i[r]}function q(t,n,r){var i,s,o=new Uint8Array(32),a=new Float64Array(80),c=e(),u=e(),l=e(),d=e(),f=e(),p=e();for(s=0;s<31;s++)o[s]=n[s];for(o[31]=127&n[31]|64,o[0]&=248,N(a,r),s=0;s<16;s++)u[s]=a[s],d[s]=c[s]=l[s]=0;for(c[0]=d[0]=1,s=254;s>=0;--s)U(c,u,i=o[s>>>3]>>>(7&s)&1),U(l,d,i),j(f,c,l),D(c,c,l),j(l,u,d),D(u,u,d),H(d,f),H(p,c),z(c,l,c),z(l,u,f),j(f,c,l),D(c,c,l),H(u,c),D(l,d,p),z(c,l,h),j(c,c,d),z(l,l,c),z(c,d,p),z(d,u,a),H(u,f),U(c,u,i),U(l,d,i);for(s=0;s<16;s++)a[s+16]=c[s],a[s+32]=l[s],a[s+48]=u[s],a[s+64]=d[s];var g=a.subarray(32),b=a.subarray(16);return B(g,g),z(b,b,g),R(t,b),0}function Y(t,e){return q(t,e,s)}function K(t,e){return r(e,32),Y(t,e)}function $(t,e,n){var r=new Uint8Array(32);return q(r,n,e),m(t,i,r,w)}T.prototype.blocks=function(t,e,n){for(var r,i,s,o,a,h,c,u,l,d,f,p,g,b,v,y,m,w,_,S=this.fin?0:2048,k=this.h[0],C=this.h[1],T=this.h[2],E=this.h[3],A=this.h[4],P=this.h[5],x=this.h[6],O=this.h[7],L=this.h[8],U=this.h[9],R=this.r[0],M=this.r[1],I=this.r[2],N=this.r[3],j=this.r[4],D=this.r[5],z=this.r[6],H=this.r[7],B=this.r[8],F=this.r[9];n>=16;)d=l=0,d+=(k+=8191&(r=255&t[e+0]|(255&t[e+1])<<8))*R,d+=(C+=8191&(r>>>13|(i=255&t[e+2]|(255&t[e+3])<<8)<<3))*(5*F),d+=(T+=8191&(i>>>10|(s=255&t[e+4]|(255&t[e+5])<<8)<<6))*(5*B),d+=(E+=8191&(s>>>7|(o=255&t[e+6]|(255&t[e+7])<<8)<<9))*(5*H),l=(d+=(A+=8191&(o>>>4|(a=255&t[e+8]|(255&t[e+9])<<8)<<12))*(5*z))>>>13,d&=8191,d+=(P+=a>>>1&8191)*(5*D),d+=(x+=8191&(a>>>14|(h=255&t[e+10]|(255&t[e+11])<<8)<<2))*(5*j),d+=(O+=8191&(h>>>11|(c=255&t[e+12]|(255&t[e+13])<<8)<<5))*(5*N),d+=(L+=8191&(c>>>8|(u=255&t[e+14]|(255&t[e+15])<<8)<<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<2)+l|0)+(d&=8191)|0),C=f+=l>>>=13,T=p&=8191,E=g&=8191,A=b&=8191,P=v&=8191,x=y&=8191,O=m&=8191,L=w&=8191,U=_&=8191,e+=16,n-=16;this.h[0]=k,this.h[1]=C,this.h[2]=T,this.h[3]=E,this.h[4]=A,this.h[5]=P,this.h[6]=x,this.h[7]=O,this.h[8]=L,this.h[9]=U},T.prototype.finish=function(t,e){var n,r,i,s,o=new Uint16Array(10);if(this.leftover){for(s=this.leftover,this.buffer[s++]=1;s<16;s++)this.buffer[s]=0;this.fin=1,this.blocks(this.buffer,0,16)}for(n=this.h[1]>>>13,this.h[1]&=8191,s=2;s<10;s++)this.h[s]+=n,n=this.h[s]>>>13,this.h[s]&=8191;for(this.h[0]+=5*n,n=this.h[0]>>>13,this.h[0]&=8191,this.h[1]+=n,n=this.h[1]>>>13,this.h[1]&=8191,this.h[2]+=n,o[0]=this.h[0]+5,n=o[0]>>>13,o[0]&=8191,s=1;s<10;s++)o[s]=this.h[s]+n,n=o[s]>>>13,o[s]&=8191;for(o[9]-=8192,r=(1^n)-1,s=0;s<10;s++)o[s]&=r;for(r=~r,s=0;s<10;s++)this.h[s]=this.h[s]&r|o[s];for(this.h[0]=65535&(this.h[0]|this.h[1]<<13),this.h[1]=65535&(this.h[1]>>>3|this.h[2]<<10),this.h[2]=65535&(this.h[2]>>>6|this.h[3]<<7),this.h[3]=65535&(this.h[3]>>>9|this.h[4]<<4),this.h[4]=65535&(this.h[4]>>>12|this.h[5]<<1|this.h[6]<<14),this.h[5]=65535&(this.h[6]>>>2|this.h[7]<<11),this.h[6]=65535&(this.h[7]>>>5|this.h[8]<<8),this.h[7]=65535&(this.h[8]>>>8|this.h[9]<<5),i=this.h[0]+this.pad[0],this.h[0]=65535&i,s=1;s<8;s++)i=(this.h[s]+this.pad[s]|0)+(i>>>16)|0,this.h[s]=65535&i;t[e+0]=this.h[0]>>>0&255,t[e+1]=this.h[0]>>>8&255,t[e+2]=this.h[1]>>>0&255,t[e+3]=this.h[1]>>>8&255,t[e+4]=this.h[2]>>>0&255,t[e+5]=this.h[2]>>>8&255,t[e+6]=this.h[3]>>>0&255,t[e+7]=this.h[3]>>>8&255,t[e+8]=this.h[4]>>>0&255,t[e+9]=this.h[4]>>>8&255,t[e+10]=this.h[5]>>>0&255,t[e+11]=this.h[5]>>>8&255,t[e+12]=this.h[6]>>>0&255,t[e+13]=this.h[6]>>>8&255,t[e+14]=this.h[7]>>>0&255,t[e+15]=this.h[7]>>>8&255},T.prototype.update=function(t,e,n){var r,i;if(this.leftover){for((i=16-this.leftover)>n&&(i=n),r=0;r=16&&(i=n-n%16,this.blocks(t,e,i),e+=i,n-=i),n){for(r=0;r=128;){for(S=0;S<16;S++)k=8*S+X,O[S]=n[k+0]<<24|n[k+1]<<16|n[k+2]<<8|n[k+3],L[S]=n[k+4]<<24|n[k+5]<<16|n[k+6]<<8|n[k+7];for(S=0;S<80;S++)if(i=U,s=R,o=M,a=I,h=N,c=j,u=D,z,d=H,f=B,p=F,g=q,b=Y,v=K,y=$,J,E=65535&(T=J),A=T>>>16,P=65535&(C=z),x=C>>>16,E+=65535&(T=(Y>>>14|N<<18)^(Y>>>18|N<<14)^(N>>>9|Y<<23)),A+=T>>>16,P+=65535&(C=(N>>>14|Y<<18)^(N>>>18|Y<<14)^(Y>>>9|N<<23)),x+=C>>>16,E+=65535&(T=Y&K^~Y&$),A+=T>>>16,P+=65535&(C=N&j^~N&D),x+=C>>>16,E+=65535&(T=W[2*S+1]),A+=T>>>16,P+=65535&(C=W[2*S]),x+=C>>>16,C=O[S%16],A+=(T=L[S%16])>>>16,P+=65535&C,x+=C>>>16,P+=(A+=(E+=65535&T)>>>16)>>>16,E=65535&(T=_=65535&E|A<<16),A=T>>>16,P=65535&(C=w=65535&P|(x+=P>>>16)<<16),x=C>>>16,E+=65535&(T=(H>>>28|U<<4)^(U>>>2|H<<30)^(U>>>7|H<<25)),A+=T>>>16,P+=65535&(C=(U>>>28|H<<4)^(H>>>2|U<<30)^(H>>>7|U<<25)),x+=C>>>16,A+=(T=H&B^H&F^B&F)>>>16,P+=65535&(C=U&R^U&M^R&M),x+=C>>>16,l=65535&(P+=(A+=(E+=65535&T)>>>16)>>>16)|(x+=P>>>16)<<16,m=65535&E|A<<16,E=65535&(T=g),A=T>>>16,P=65535&(C=a),x=C>>>16,A+=(T=_)>>>16,P+=65535&(C=w),x+=C>>>16,R=i,M=s,I=o,N=a=65535&(P+=(A+=(E+=65535&T)>>>16)>>>16)|(x+=P>>>16)<<16,j=h,D=c,z=u,U=l,B=d,F=f,q=p,Y=g=65535&E|A<<16,K=b,$=v,J=y,H=m,S%16==15)for(k=0;k<16;k++)C=O[k],E=65535&(T=L[k]),A=T>>>16,P=65535&C,x=C>>>16,C=O[(k+9)%16],E+=65535&(T=L[(k+9)%16]),A+=T>>>16,P+=65535&C,x+=C>>>16,w=O[(k+1)%16],E+=65535&(T=((_=L[(k+1)%16])>>>1|w<<31)^(_>>>8|w<<24)^(_>>>7|w<<25)),A+=T>>>16,P+=65535&(C=(w>>>1|_<<31)^(w>>>8|_<<24)^w>>>7),x+=C>>>16,w=O[(k+14)%16],A+=(T=((_=L[(k+14)%16])>>>19|w<<13)^(w>>>29|_<<3)^(_>>>6|w<<26))>>>16,P+=65535&(C=(w>>>19|_<<13)^(_>>>29|w<<3)^w>>>6),x+=C>>>16,x+=(P+=(A+=(E+=65535&T)>>>16)>>>16)>>>16,O[k]=65535&P|x<<16,L[k]=65535&E|A<<16;E=65535&(T=H),A=T>>>16,P=65535&(C=U),x=C>>>16,C=t[0],A+=(T=e[0])>>>16,P+=65535&C,x+=C>>>16,x+=(P+=(A+=(E+=65535&T)>>>16)>>>16)>>>16,t[0]=U=65535&P|x<<16,e[0]=H=65535&E|A<<16,E=65535&(T=B),A=T>>>16,P=65535&(C=R),x=C>>>16,C=t[1],A+=(T=e[1])>>>16,P+=65535&C,x+=C>>>16,x+=(P+=(A+=(E+=65535&T)>>>16)>>>16)>>>16,t[1]=R=65535&P|x<<16,e[1]=B=65535&E|A<<16,E=65535&(T=F),A=T>>>16,P=65535&(C=M),x=C>>>16,C=t[2],A+=(T=e[2])>>>16,P+=65535&C,x+=C>>>16,x+=(P+=(A+=(E+=65535&T)>>>16)>>>16)>>>16,t[2]=M=65535&P|x<<16,e[2]=F=65535&E|A<<16,E=65535&(T=q),A=T>>>16,P=65535&(C=I),x=C>>>16,C=t[3],A+=(T=e[3])>>>16,P+=65535&C,x+=C>>>16,x+=(P+=(A+=(E+=65535&T)>>>16)>>>16)>>>16,t[3]=I=65535&P|x<<16,e[3]=q=65535&E|A<<16,E=65535&(T=Y),A=T>>>16,P=65535&(C=N),x=C>>>16,C=t[4],A+=(T=e[4])>>>16,P+=65535&C,x+=C>>>16,x+=(P+=(A+=(E+=65535&T)>>>16)>>>16)>>>16,t[4]=N=65535&P|x<<16,e[4]=Y=65535&E|A<<16,E=65535&(T=K),A=T>>>16,P=65535&(C=j),x=C>>>16,C=t[5],A+=(T=e[5])>>>16,P+=65535&C,x+=C>>>16,x+=(P+=(A+=(E+=65535&T)>>>16)>>>16)>>>16,t[5]=j=65535&P|x<<16,e[5]=K=65535&E|A<<16,E=65535&(T=$),A=T>>>16,P=65535&(C=D),x=C>>>16,C=t[6],A+=(T=e[6])>>>16,P+=65535&C,x+=C>>>16,x+=(P+=(A+=(E+=65535&T)>>>16)>>>16)>>>16,t[6]=D=65535&P|x<<16,e[6]=$=65535&E|A<<16,E=65535&(T=J),A=T>>>16,P=65535&(C=z),x=C>>>16,C=t[7],A+=(T=e[7])>>>16,P+=65535&C,x+=C>>>16,x+=(P+=(A+=(E+=65535&T)>>>16)>>>16)>>>16,t[7]=z=65535&P|x<<16,e[7]=J=65535&E|A<<16,X+=128,r-=128}return r}function V(t,e,n){var r,i=new Int32Array(8),s=new Int32Array(8),o=new Uint8Array(256),a=n;for(i[0]=1779033703,i[1]=3144134277,i[2]=1013904242,i[3]=2773480762,i[4]=1359893119,i[5]=2600822924,i[6]=528734635,i[7]=1541459225,s[0]=4089235720,s[1]=2227873595,s[2]=4271175723,s[3]=1595750129,s[4]=2917565137,s[5]=725511199,s[6]=4215389547,s[7]=327033209,G(i,s,e,n),n%=128,r=0;r=0;--i)Q(t,e,r=n[i/8|0]>>(7&i)&1),Z(e,t),Z(t,t),Q(t,e,r)}function nt(t,n){var r=[e(),e(),e(),e()];O(r[0],l),O(r[1],d),O(r[2],a),z(r[3],l,d),et(t,r,n)}function rt(t,n,i){var s,o=new Uint8Array(64),a=[e(),e(),e(),e()];for(i||r(n,32),V(o,n,32),o[0]&=248,o[31]&=127,o[31]|=64,nt(a,o),tt(t,a),s=0;s<32;s++)n[s+32]=t[s];return 0}var it=new Float64Array([237,211,245,92,26,99,18,88,214,156,247,162,222,249,222,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16]);function st(t,e){var n,r,i,s;for(r=63;r>=32;--r){for(n=0,i=r-32,s=r-12;i>4)*it[i],n=e[i]>>8,e[i]&=255;for(i=0;i<32;i++)e[i]-=n*it[i];for(r=0;r<32;r++)e[r+1]+=e[r]>>8,t[r]=255&e[r]}function ot(t){var e,n=new Float64Array(64);for(e=0;e<64;e++)n[e]=t[e];for(e=0;e<64;e++)t[e]=0;st(t,n)}function at(t,n,r,i){var s,o,a=new Uint8Array(64),h=new Uint8Array(64),c=new Uint8Array(64),u=new Float64Array(64),l=[e(),e(),e(),e()];V(a,i,32),a[0]&=248,a[31]&=127,a[31]|=64;var d=r+64;for(s=0;s>7&&D(t[0],o,t[0]),z(t[3],t[0],t[1]),0)}(d,i))return-1;for(s=0;s=0},t.sign.keyPair=function(){var t=new Uint8Array(32),e=new Uint8Array(64);return rt(t,e),{publicKey:t,secretKey:e}},t.sign.keyPair.fromSecretKey=function(t){if(ut(t),64!==t.length)throw new Error("bad secret key size");for(var e=new Uint8Array(32),n=0;n(target: any, ...sources: any[]): T {\n for (var i = 0; i < sources.length; i++) {\n var extensions = sources[i];\n for (var property in extensions) {\n if (\n extensions[property] &&\n extensions[property].constructor &&\n extensions[property].constructor === Object\n ) {\n target[property] = extend(target[property] || {}, extensions[property]);\n } else {\n target[property] = extensions[property];\n }\n }\n }\n return target;\n}\n\nexport function stringify(): string {\n var m = ['Pusher'];\n for (var i = 0; i < arguments.length; i++) {\n if (typeof arguments[i] === 'string') {\n m.push(arguments[i]);\n } else {\n m.push(safeJSONStringify(arguments[i]));\n }\n }\n return m.join(' : ');\n}\n\nexport function arrayIndexOf(array: any[], item: any): number {\n // MSIE doesn't have array.indexOf\n var nativeIndexOf = Array.prototype.indexOf;\n if (array === null) {\n return -1;\n }\n if (nativeIndexOf && array.indexOf === nativeIndexOf) {\n return array.indexOf(item);\n }\n for (var i = 0, l = array.length; i < l; i++) {\n if (array[i] === item) {\n return i;\n }\n }\n return -1;\n}\n\n/** Applies a function f to all properties of an object.\n *\n * Function f gets 3 arguments passed:\n * - element from the object\n * - key of the element\n * - reference to the object\n *\n * @param {Object} object\n * @param {Function} f\n */\nexport function objectApply(object: any, f: Function) {\n for (var key in object) {\n if (Object.prototype.hasOwnProperty.call(object, key)) {\n f(object[key], key, object);\n }\n }\n}\n\n/** Return a list of objects own proerty keys\n *\n * @param {Object} object\n * @returns {Array}\n */\nexport function keys(object: any): string[] {\n var keys = [];\n objectApply(object, function(_, key) {\n keys.push(key);\n });\n return keys;\n}\n\n/** Return a list of object's own property values\n *\n * @param {Object} object\n * @returns {Array}\n */\nexport function values(object: any): any[] {\n var values = [];\n objectApply(object, function(value) {\n values.push(value);\n });\n return values;\n}\n\n/** Applies a function f to all elements of an array.\n *\n * Function f gets 3 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function apply(array: any[], f: Function, context?: any) {\n for (var i = 0; i < array.length; i++) {\n f.call(context || global, array[i], i, array);\n }\n}\n\n/** Maps all elements of the array and returns the result.\n *\n * Function f gets 4 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n * - reference to the destination array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function map(array: any[], f: Function): any[] {\n var result = [];\n for (var i = 0; i < array.length; i++) {\n result.push(f(array[i], i, array, result));\n }\n return result;\n}\n\n/** Maps all elements of the object and returns the result.\n *\n * Function f gets 4 arguments passed:\n * - element from the object\n * - key of the element\n * - reference to the source object\n * - reference to the destination object\n *\n * @param {Object} object\n * @param {Function} f\n */\nexport function mapObject(object: any, f: Function): any {\n var result = {};\n objectApply(object, function(value, key) {\n result[key] = f(value);\n });\n return result;\n}\n\n/** Filters elements of the array using a test function.\n *\n * Function test gets 4 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n * - reference to the destination array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function filter(array: any[], test: Function): any[] {\n test =\n test ||\n function(value) {\n return !!value;\n };\n\n var result = [];\n for (var i = 0; i < array.length; i++) {\n if (test(array[i], i, array, result)) {\n result.push(array[i]);\n }\n }\n return result;\n}\n\n/** Filters properties of the object using a test function.\n *\n * Function test gets 4 arguments passed:\n * - element from the object\n * - key of the element\n * - reference to the source object\n * - reference to the destination object\n *\n * @param {Object} object\n * @param {Function} f\n */\nexport function filterObject(object: Object, test: Function) {\n var result = {};\n objectApply(object, function(value, key) {\n if ((test && test(value, key, object, result)) || Boolean(value)) {\n result[key] = value;\n }\n });\n return result;\n}\n\n/** Flattens an object into a two-dimensional array.\n *\n * @param {Object} object\n * @return {Array} resulting array of [key, value] pairs\n */\nexport function flatten(object: Object): any[] {\n var result = [];\n objectApply(object, function(value, key) {\n result.push([key, value]);\n });\n return result;\n}\n\n/** Checks whether any element of the array passes the test.\n *\n * Function test gets 3 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function any(array: any[], test: Function): boolean {\n for (var i = 0; i < array.length; i++) {\n if (test(array[i], i, array)) {\n return true;\n }\n }\n return false;\n}\n\n/** Checks whether all elements of the array pass the test.\n *\n * Function test gets 3 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function all(array: any[], test: Function): boolean {\n for (var i = 0; i < array.length; i++) {\n if (!test(array[i], i, array)) {\n return false;\n }\n }\n return true;\n}\n\nexport function encodeParamsObject(data): string {\n return mapObject(data, function(value) {\n if (typeof value === 'object') {\n value = safeJSONStringify(value);\n }\n return encodeURIComponent(base64encode(value.toString()));\n });\n}\n\nexport function buildQueryString(data: any): string {\n var params = filterObject(data, function(value) {\n return value !== undefined;\n });\n\n var query = map(\n flatten(encodeParamsObject(params)),\n Util.method('join', '=')\n ).join('&');\n\n return query;\n}\n\n/**\n * See https://github.com/douglascrockford/JSON-js/blob/master/cycle.js\n *\n * Remove circular references from an object. Required for JSON.stringify in\n * React Native, which tends to blow up a lot.\n *\n * @param {any} object\n * @return {any} Decycled object\n */\nexport function decycleObject(object: any): any {\n var objects = [],\n paths = [];\n\n return (function derez(value, path) {\n var i, name, nu;\n\n switch (typeof value) {\n case 'object':\n if (!value) {\n return null;\n }\n for (i = 0; i < objects.length; i += 1) {\n if (objects[i] === value) {\n return { $ref: paths[i] };\n }\n }\n\n objects.push(value);\n paths.push(path);\n\n if (Object.prototype.toString.apply(value) === '[object Array]') {\n nu = [];\n for (i = 0; i < value.length; i += 1) {\n nu[i] = derez(value[i], path + '[' + i + ']');\n }\n } else {\n nu = {};\n for (name in value) {\n if (Object.prototype.hasOwnProperty.call(value, name)) {\n nu[name] = derez(\n value[name],\n path + '[' + JSON.stringify(name) + ']'\n );\n }\n }\n }\n return nu;\n case 'number':\n case 'string':\n case 'boolean':\n return value;\n }\n })(object, '$');\n}\n\n/**\n * Provides a cross-browser and cross-platform way to safely stringify objects\n * into JSON. This is particularly necessary for ReactNative, where circular JSON\n * structures throw an exception.\n *\n * @param {any} source The object to stringify\n * @return {string} The serialized output.\n */\nexport function safeJSONStringify(source: any): string {\n try {\n return JSON.stringify(source);\n } catch (e) {\n return JSON.stringify(decycleObject(source));\n }\n}\n","import { stringify } from './utils/collections';\nimport Pusher from './pusher';\n\nclass Logger {\n debug(...args: any[]) {\n this.log(this.globalLog, args);\n }\n\n warn(...args: any[]) {\n this.log(this.globalLogWarn, args);\n }\n\n error(...args: any[]) {\n this.log(this.globalLogError, args);\n }\n\n private globalLog = (message: string) => {\n if (global.console && global.console.log) {\n global.console.log(message);\n }\n };\n\n private globalLogWarn(message: string) {\n if (global.console && global.console.warn) {\n global.console.warn(message);\n } else {\n this.globalLog(message);\n }\n }\n\n private globalLogError(message: string) {\n if (global.console && global.console.error) {\n global.console.error(message);\n } else {\n this.globalLogWarn(message);\n }\n }\n\n private log(\n defaultLoggingFunction: (message: string) => void,\n ...args: any[]\n ) {\n var message = stringify.apply(this, arguments);\n if (Pusher.log) {\n Pusher.log(message);\n } else if (Pusher.logToConsole) {\n const log = defaultLoggingFunction.bind(this);\n log(message);\n }\n }\n}\n\nexport default new Logger();\n","import * as Collections from './utils/collections';\nimport TimedCallback from './utils/timers/timed_callback';\nimport { OneOffTimer, PeriodicTimer } from './utils/timers';\n\nvar Util = {\n now(): number {\n if (Date.now) {\n return Date.now();\n } else {\n return new Date().valueOf();\n }\n },\n\n defer(callback: TimedCallback): OneOffTimer {\n return new OneOffTimer(0, callback);\n },\n\n /** Builds a function that will proxy a method call to its first argument.\n *\n * Allows partial application of arguments, so additional arguments are\n * prepended to the argument list.\n *\n * @param {String} name method name\n * @return {Function} proxy function\n */\n method(name: string, ...args: any[]): Function {\n var boundArguments = Array.prototype.slice.call(arguments, 1);\n return function(object) {\n return object[name].apply(object, boundArguments.concat(arguments));\n };\n }\n};\n\nexport default Util;\n","import * as Collections from '../utils/collections';\nimport Callback from './callback';\nimport Metadata from '../channels/metadata';\nimport CallbackRegistry from './callback_registry';\n\n/** Manages callback bindings and event emitting.\n *\n * @param Function failThrough called when no listeners are bound to an event\n */\nexport default class Dispatcher {\n callbacks: CallbackRegistry;\n global_callbacks: Function[];\n failThrough: Function;\n\n constructor(failThrough?: Function) {\n this.callbacks = new CallbackRegistry();\n this.global_callbacks = [];\n this.failThrough = failThrough;\n }\n\n bind(eventName: string, callback: Function, context?: any) {\n this.callbacks.add(eventName, callback, context);\n return this;\n }\n\n bind_global(callback: Function) {\n this.global_callbacks.push(callback);\n return this;\n }\n\n unbind(eventName?: string, callback?: Function, context?: any) {\n this.callbacks.remove(eventName, callback, context);\n return this;\n }\n\n unbind_global(callback?: Function) {\n if (!callback) {\n this.global_callbacks = [];\n return this;\n }\n\n this.global_callbacks = Collections.filter(\n this.global_callbacks || [],\n c => c !== callback\n );\n\n return this;\n }\n\n unbind_all() {\n this.unbind();\n this.unbind_global();\n return this;\n }\n\n emit(eventName: string, data?: any, metadata?: Metadata): Dispatcher {\n for (var i = 0; i < this.global_callbacks.length; i++) {\n this.global_callbacks[i](eventName, data);\n }\n\n var callbacks = this.callbacks.get(eventName);\n var args = [];\n\n if (metadata) {\n // if there's a metadata argument, we need to call the callback with both\n // data and metadata regardless of whether data is undefined\n args.push(data, metadata);\n } else if (data) {\n // metadata is undefined, so we only need to call the callback with data\n // if data exists\n args.push(data);\n }\n\n if (callbacks && callbacks.length > 0) {\n for (var i = 0; i < callbacks.length; i++) {\n callbacks[i].fn.apply(callbacks[i].context || global, args);\n }\n } else if (this.failThrough) {\n this.failThrough(eventName, data);\n }\n\n return this;\n }\n}\n","import Timer from './abstract_timer';\nimport TimedCallback from './timed_callback';\nimport { Delay } from './scheduling';\n\n// We need to bind clear functions this way to avoid exceptions on IE8\nfunction clearTimeout(timer) {\n global.clearTimeout(timer);\n}\nfunction clearInterval(timer) {\n global.clearInterval(timer);\n}\n\n/** Cross-browser compatible one-off timer abstraction.\n *\n * @param {Number} delay\n * @param {Function} callback\n */\nexport class OneOffTimer extends Timer {\n constructor(delay: Delay, callback: TimedCallback) {\n super(setTimeout, clearTimeout, delay, function(timer) {\n callback();\n return null;\n });\n }\n}\n\n/** Cross-browser compatible periodic timer abstraction.\n *\n * @param {Number} delay\n * @param {Function} callback\n */\nexport class PeriodicTimer extends Timer {\n constructor(delay: Delay, callback: TimedCallback) {\n super(setInterval, clearInterval, delay, function(timer) {\n callback();\n return timer;\n });\n }\n}\n","import {\n ChannelAuthorizationOptions,\n UserAuthenticationOptions\n} from './auth/options';\nimport { AuthTransport } from './config';\n\nexport interface DefaultConfig {\n VERSION: string;\n PROTOCOL: number;\n wsPort: number;\n wssPort: number;\n wsPath: string;\n httpHost: string;\n httpPort: number;\n httpsPort: number;\n httpPath: string;\n stats_host: string;\n authEndpoint: string;\n authTransport: AuthTransport;\n activityTimeout: number;\n pongTimeout: number;\n unavailableTimeout: number;\n userAuthentication: UserAuthenticationOptions;\n channelAuthorization: ChannelAuthorizationOptions;\n\n cdn_http?: string;\n cdn_https?: string;\n dependency_suffix?: string;\n}\n\nvar Defaults: DefaultConfig = {\n VERSION: VERSION,\n PROTOCOL: 7,\n\n wsPort: 80,\n wssPort: 443,\n wsPath: '',\n // DEPRECATED: SockJS fallback parameters\n httpHost: 'sockjs.pusher.com',\n httpPort: 80,\n httpsPort: 443,\n httpPath: '/pusher',\n // DEPRECATED: Stats\n stats_host: 'stats.pusher.com',\n // DEPRECATED: Other settings\n authEndpoint: '/pusher/auth',\n authTransport: 'ajax',\n activityTimeout: 120000,\n pongTimeout: 30000,\n unavailableTimeout: 10000,\n userAuthentication: {\n endpoint: '/pusher/user-auth',\n transport: 'ajax'\n },\n channelAuthorization: {\n endpoint: '/pusher/auth',\n transport: 'ajax'\n },\n\n // CDN configuration\n cdn_http: CDN_HTTP,\n cdn_https: CDN_HTTPS,\n dependency_suffix: DEPENDENCY_SUFFIX\n};\n\nexport default Defaults;\n","import Defaults from '../defaults';\nimport { default as URLScheme, URLSchemeParams } from './url_scheme';\n\nfunction getGenericURL(\n baseScheme: string,\n params: URLSchemeParams,\n path: string\n): string {\n var scheme = baseScheme + (params.useTLS ? 's' : '');\n var host = params.useTLS ? params.hostTLS : params.hostNonTLS;\n return scheme + '://' + host + path;\n}\n\nfunction getGenericPath(key: string, queryString?: string): string {\n var path = '/app/' + key;\n var query =\n '?protocol=' +\n Defaults.PROTOCOL +\n '&client=js' +\n '&version=' +\n Defaults.VERSION +\n (queryString ? '&' + queryString : '');\n return path + query;\n}\n\nexport var ws: URLScheme = {\n getInitial: function(key: string, params: URLSchemeParams): string {\n var path = (params.httpPath || '') + getGenericPath(key, 'flash=false');\n return getGenericURL('ws', params, path);\n }\n};\n\nexport var http: URLScheme = {\n getInitial: function(key: string, params: URLSchemeParams): string {\n var path = (params.httpPath || '/pusher') + getGenericPath(key);\n return getGenericURL('http', params, path);\n }\n};\n\nexport var sockjs: URLScheme = {\n getInitial: function(key: string, params: URLSchemeParams): string {\n return getGenericURL('http', params, params.httpPath || '/pusher');\n },\n getPath: function(key: string, params: URLSchemeParams): string {\n return getGenericPath(key);\n }\n};\n","import Util from '../util';\nimport * as Collections from '../utils/collections';\nimport { default as EventsDispatcher } from '../events/dispatcher';\nimport Logger from '../logger';\nimport TransportHooks from './transport_hooks';\nimport Socket from '../socket';\nimport Runtime from 'runtime';\nimport Timeline from '../timeline/timeline';\nimport TransportConnectionOptions from './transport_connection_options';\n\n/** Provides universal API for transport connections.\n *\n * Transport connection is a low-level object that wraps a connection method\n * and exposes a simple evented interface for the connection state and\n * messaging. It does not implement Pusher-specific WebSocket protocol.\n *\n * Additionally, it fetches resources needed for transport to work and exposes\n * an interface for querying transport features.\n *\n * States:\n * - new - initial state after constructing the object\n * - initializing - during initialization phase, usually fetching resources\n * - intialized - ready to establish a connection\n * - connection - when connection is being established\n * - open - when connection ready to be used\n * - closed - after connection was closed be either side\n *\n * Emits:\n * - error - after the connection raised an error\n *\n * Options:\n * - useTLS - whether connection should be over TLS\n * - hostTLS - host to connect to when connection is over TLS\n * - hostNonTLS - host to connect to when connection is over TLS\n *\n * @param {String} key application key\n * @param {Object} options\n */\nexport default class TransportConnection extends EventsDispatcher {\n hooks: TransportHooks;\n name: string;\n priority: number;\n key: string;\n options: TransportConnectionOptions;\n state: string;\n timeline: Timeline;\n activityTimeout: number;\n id: number;\n socket: Socket;\n beforeOpen: Function;\n initialize: Function;\n\n constructor(\n hooks: TransportHooks,\n name: string,\n priority: number,\n key: string,\n options: TransportConnectionOptions\n ) {\n super();\n this.initialize = Runtime.transportConnectionInitializer;\n this.hooks = hooks;\n this.name = name;\n this.priority = priority;\n this.key = key;\n this.options = options;\n\n this.state = 'new';\n this.timeline = options.timeline;\n this.activityTimeout = options.activityTimeout;\n this.id = this.timeline.generateUniqueID();\n }\n\n /** Checks whether the transport handles activity checks by itself.\n *\n * @return {Boolean}\n */\n handlesActivityChecks(): boolean {\n return Boolean(this.hooks.handlesActivityChecks);\n }\n\n /** Checks whether the transport supports the ping/pong API.\n *\n * @return {Boolean}\n */\n supportsPing(): boolean {\n return Boolean(this.hooks.supportsPing);\n }\n\n /** Tries to establish a connection.\n *\n * @returns {Boolean} false if transport is in invalid state\n */\n connect(): boolean {\n if (this.socket || this.state !== 'initialized') {\n return false;\n }\n\n var url = this.hooks.urls.getInitial(this.key, this.options);\n try {\n this.socket = this.hooks.getSocket(url, this.options);\n } catch (e) {\n Util.defer(() => {\n this.onError(e);\n this.changeState('closed');\n });\n return false;\n }\n\n this.bindListeners();\n\n Logger.debug('Connecting', { transport: this.name, url });\n this.changeState('connecting');\n return true;\n }\n\n /** Closes the connection.\n *\n * @return {Boolean} true if there was a connection to close\n */\n close(): boolean {\n if (this.socket) {\n this.socket.close();\n return true;\n } else {\n return false;\n }\n }\n\n /** Sends data over the open connection.\n *\n * @param {String} data\n * @return {Boolean} true only when in the \"open\" state\n */\n send(data: any): boolean {\n if (this.state === 'open') {\n // Workaround for MobileSafari bug (see https://gist.github.com/2052006)\n Util.defer(() => {\n if (this.socket) {\n this.socket.send(data);\n }\n });\n return true;\n } else {\n return false;\n }\n }\n\n /** Sends a ping if the connection is open and transport supports it. */\n ping() {\n if (this.state === 'open' && this.supportsPing()) {\n this.socket.ping();\n }\n }\n\n private onOpen() {\n if (this.hooks.beforeOpen) {\n this.hooks.beforeOpen(\n this.socket,\n this.hooks.urls.getPath(this.key, this.options)\n );\n }\n this.changeState('open');\n this.socket.onopen = undefined;\n }\n\n private onError(error) {\n this.emit('error', { type: 'WebSocketError', error: error });\n this.timeline.error(this.buildTimelineMessage({ error: error.toString() }));\n }\n\n private onClose(closeEvent?: any) {\n if (closeEvent) {\n this.changeState('closed', {\n code: closeEvent.code,\n reason: closeEvent.reason,\n wasClean: closeEvent.wasClean\n });\n } else {\n this.changeState('closed');\n }\n this.unbindListeners();\n this.socket = undefined;\n }\n\n private onMessage(message) {\n this.emit('message', message);\n }\n\n private onActivity() {\n this.emit('activity');\n }\n\n private bindListeners() {\n this.socket.onopen = () => {\n this.onOpen();\n };\n this.socket.onerror = error => {\n this.onError(error);\n };\n this.socket.onclose = closeEvent => {\n this.onClose(closeEvent);\n };\n this.socket.onmessage = message => {\n this.onMessage(message);\n };\n\n if (this.supportsPing()) {\n this.socket.onactivity = () => {\n this.onActivity();\n };\n }\n }\n\n private unbindListeners() {\n if (this.socket) {\n this.socket.onopen = undefined;\n this.socket.onerror = undefined;\n this.socket.onclose = undefined;\n this.socket.onmessage = undefined;\n if (this.supportsPing()) {\n this.socket.onactivity = undefined;\n }\n }\n }\n\n private changeState(state: string, params?: any) {\n this.state = state;\n this.timeline.info(\n this.buildTimelineMessage({\n state: state,\n params: params\n })\n );\n this.emit(state, params);\n }\n\n buildTimelineMessage(message): any {\n return Collections.extend({ cid: this.id }, message);\n }\n}\n","import Factory from '../utils/factory';\nimport TransportHooks from './transport_hooks';\nimport TransportConnection from './transport_connection';\nimport TransportConnectionOptions from './transport_connection_options';\n\n/** Provides interface for transport connection instantiation.\n *\n * Takes transport-specific hooks as the only argument, which allow checking\n * for transport support and creating its connections.\n *\n * Supported hooks: * - file - the name of the file to be fetched during initialization\n * - urls - URL scheme to be used by transport\n * - handlesActivityCheck - true when the transport handles activity checks\n * - supportsPing - true when the transport has a ping/activity API\n * - isSupported - tells whether the transport is supported in the environment\n * - getSocket - creates a WebSocket-compatible transport socket\n *\n * See transports.js for specific implementations.\n *\n * @param {Object} hooks object containing all needed transport hooks\n */\nexport default class Transport {\n hooks: TransportHooks;\n\n constructor(hooks: TransportHooks) {\n this.hooks = hooks;\n }\n\n /** Returns whether the transport is supported in the environment.\n *\n * @param {Object} envronment te environment details (encryption, settings)\n * @returns {Boolean} true when the transport is supported\n */\n isSupported(environment: any): boolean {\n return this.hooks.isSupported(environment);\n }\n\n /** Creates a transport connection.\n *\n * @param {String} name\n * @param {Number} priority\n * @param {String} key the application key\n * @param {Object} options\n * @returns {TransportConnection}\n */\n createConnection(\n name: string,\n priority: number,\n key: string,\n options: any\n ): TransportConnection {\n return new TransportConnection(this.hooks, name, priority, key, options);\n }\n}\n","import * as URLSchemes from 'core/transports/url_schemes';\nimport URLScheme from 'core/transports/url_scheme';\nimport Transport from 'core/transports/transport';\nimport Util from 'core/util';\nimport * as Collections from 'core/utils/collections';\nimport TransportHooks from 'core/transports/transport_hooks';\nimport TransportsTable from 'core/transports/transports_table';\nimport Runtime from 'runtime';\n\n/** WebSocket transport.\n *\n * Uses native WebSocket implementation, including MozWebSocket supported by\n * earlier Firefox versions.\n */\nvar WSTransport = new Transport({\n urls: URLSchemes.ws,\n handlesActivityChecks: false,\n supportsPing: false,\n\n isInitialized: function() {\n return Boolean(Runtime.getWebSocketAPI());\n },\n isSupported: function(): boolean {\n return Boolean(Runtime.getWebSocketAPI());\n },\n getSocket: function(url) {\n return Runtime.createWebSocket(url);\n }\n});\n\nvar httpConfiguration = {\n urls: URLSchemes.http,\n handlesActivityChecks: false,\n supportsPing: true,\n isInitialized: function() {\n return true;\n }\n};\n\nexport var streamingConfiguration = Collections.extend(\n {\n getSocket: function(url) {\n return Runtime.HTTPFactory.createStreamingSocket(url);\n }\n },\n httpConfiguration\n);\nexport var pollingConfiguration = Collections.extend(\n {\n getSocket: function(url) {\n return Runtime.HTTPFactory.createPollingSocket(url);\n }\n },\n httpConfiguration\n);\n\nvar xhrConfiguration = {\n isSupported: function(): boolean {\n return Runtime.isXHRSupported();\n }\n};\n\n/** HTTP streaming transport using CORS-enabled XMLHttpRequest. */\nvar XHRStreamingTransport = new Transport(\n (\n Collections.extend({}, streamingConfiguration, xhrConfiguration)\n )\n);\n\n/** HTTP long-polling transport using CORS-enabled XMLHttpRequest. */\nvar XHRPollingTransport = new Transport(\n Collections.extend({}, pollingConfiguration, xhrConfiguration)\n);\n\nvar Transports: TransportsTable = {\n ws: WSTransport,\n xhr_streaming: XHRStreamingTransport,\n xhr_polling: XHRPollingTransport\n};\n\nexport default Transports;\n","import Util from '../util';\nimport * as Collections from '../utils/collections';\nimport TransportManager from './transport_manager';\nimport TransportConnection from './transport_connection';\nimport Transport from './transport';\nimport PingDelayOptions from './ping_delay_options';\n\n/** Creates transport connections monitored by a transport manager.\n *\n * When a transport is closed, it might mean the environment does not support\n * it. It's possible that messages get stuck in an intermediate buffer or\n * proxies terminate inactive connections. To combat these problems,\n * assistants monitor the connection lifetime, report unclean exits and\n * adjust ping timeouts to keep the connection active. The decision to disable\n * a transport is the manager's responsibility.\n *\n * @param {TransportManager} manager\n * @param {TransportConnection} transport\n * @param {Object} options\n */\nexport default class AssistantToTheTransportManager {\n manager: TransportManager;\n transport: Transport;\n minPingDelay: number;\n maxPingDelay: number;\n pingDelay: number;\n\n constructor(\n manager: TransportManager,\n transport: Transport,\n options: PingDelayOptions\n ) {\n this.manager = manager;\n this.transport = transport;\n this.minPingDelay = options.minPingDelay;\n this.maxPingDelay = options.maxPingDelay;\n this.pingDelay = undefined;\n }\n\n /** Creates a transport connection.\n *\n * This function has the same API as Transport#createConnection.\n *\n * @param {String} name\n * @param {Number} priority\n * @param {String} key the application key\n * @param {Object} options\n * @returns {TransportConnection}\n */\n createConnection(\n name: string,\n priority: number,\n key: string,\n options: Object\n ): TransportConnection {\n options = Collections.extend({}, options, {\n activityTimeout: this.pingDelay\n });\n var connection = this.transport.createConnection(\n name,\n priority,\n key,\n options\n );\n\n var openTimestamp = null;\n\n var onOpen = function() {\n connection.unbind('open', onOpen);\n connection.bind('closed', onClosed);\n openTimestamp = Util.now();\n };\n var onClosed = closeEvent => {\n connection.unbind('closed', onClosed);\n\n if (closeEvent.code === 1002 || closeEvent.code === 1003) {\n // we don't want to use transports not obeying the protocol\n this.manager.reportDeath();\n } else if (!closeEvent.wasClean && openTimestamp) {\n // report deaths only for short-living transport\n var lifespan = Util.now() - openTimestamp;\n if (lifespan < 2 * this.maxPingDelay) {\n this.manager.reportDeath();\n this.pingDelay = Math.max(lifespan / 2, this.minPingDelay);\n }\n }\n };\n\n connection.bind('open', onOpen);\n return connection;\n }\n\n /** Returns whether the transport is supported in the environment.\n *\n * This function has the same API as Transport#isSupported. Might return false\n * when the manager decides to kill the transport.\n *\n * @param {Object} environment the environment details (encryption, settings)\n * @returns {Boolean} true when the transport is supported\n */\n isSupported(environment: string): boolean {\n return this.manager.isAlive() && this.transport.isSupported(environment);\n }\n}\n","import Action from './action';\nimport { PusherEvent } from './message-types';\n/**\n * Provides functions for handling Pusher protocol-specific messages.\n */\n\nconst Protocol = {\n /**\n * Decodes a message in a Pusher format.\n *\n * The MessageEvent we receive from the transport should contain a pusher event\n * (https://pusher.com/docs/pusher_protocol#events) serialized as JSON in the\n * data field\n *\n * The pusher event may contain a data field too, and it may also be\n * serialised as JSON\n *\n * Throws errors when messages are not parse'able.\n *\n * @param {MessageEvent} messageEvent\n * @return {PusherEvent}\n */\n decodeMessage: function(messageEvent: MessageEvent): PusherEvent {\n try {\n var messageData = JSON.parse(messageEvent.data);\n var pusherEventData = messageData.data;\n if (typeof pusherEventData === 'string') {\n try {\n pusherEventData = JSON.parse(messageData.data);\n } catch (e) {}\n }\n var pusherEvent: PusherEvent = {\n event: messageData.event,\n channel: messageData.channel,\n data: pusherEventData\n };\n if (messageData.user_id) {\n pusherEvent.user_id = messageData.user_id;\n }\n return pusherEvent;\n } catch (e) {\n throw { type: 'MessageParseError', error: e, data: messageEvent.data };\n }\n },\n\n /**\n * Encodes a message to be sent.\n *\n * @param {PusherEvent} event\n * @return {String}\n */\n encodeMessage: function(event: PusherEvent): string {\n return JSON.stringify(event);\n },\n\n /**\n * Processes a handshake message and returns appropriate actions.\n *\n * Returns an object with an 'action' and other action-specific properties.\n *\n * There are three outcomes when calling this function. First is a successful\n * connection attempt, when pusher:connection_established is received, which\n * results in a 'connected' action with an 'id' property. When passed a\n * pusher:error event, it returns a result with action appropriate to the\n * close code and an error. Otherwise, it raises an exception.\n *\n * @param {String} message\n * @result Object\n */\n processHandshake: function(messageEvent: MessageEvent): Action {\n var message = Protocol.decodeMessage(messageEvent);\n\n if (message.event === 'pusher:connection_established') {\n if (!message.data.activity_timeout) {\n throw 'No activity timeout specified in handshake';\n }\n return {\n action: 'connected',\n id: message.data.socket_id,\n activityTimeout: message.data.activity_timeout * 1000\n };\n } else if (message.event === 'pusher:error') {\n // From protocol 6 close codes are sent only once, so this only\n // happens when connection does not support close codes\n return {\n action: this.getCloseAction(message.data),\n error: this.getCloseError(message.data)\n };\n } else {\n throw 'Invalid handshake';\n }\n },\n\n /**\n * Dispatches the close event and returns an appropriate action name.\n *\n * See:\n * 1. https://developer.mozilla.org/en-US/docs/WebSockets/WebSockets_reference/CloseEvent\n * 2. http://pusher.com/docs/pusher_protocol\n *\n * @param {CloseEvent} closeEvent\n * @return {String} close action name\n */\n getCloseAction: function(closeEvent): string {\n if (closeEvent.code < 4000) {\n // ignore 1000 CLOSE_NORMAL, 1001 CLOSE_GOING_AWAY,\n // 1005 CLOSE_NO_STATUS, 1006 CLOSE_ABNORMAL\n // ignore 1007...3999\n // handle 1002 CLOSE_PROTOCOL_ERROR, 1003 CLOSE_UNSUPPORTED,\n // 1004 CLOSE_TOO_LARGE\n if (closeEvent.code >= 1002 && closeEvent.code <= 1004) {\n return 'backoff';\n } else {\n return null;\n }\n } else if (closeEvent.code === 4000) {\n return 'tls_only';\n } else if (closeEvent.code < 4100) {\n return 'refused';\n } else if (closeEvent.code < 4200) {\n return 'backoff';\n } else if (closeEvent.code < 4300) {\n return 'retry';\n } else {\n // unknown error\n return 'refused';\n }\n },\n\n /**\n * Returns an error or null basing on the close event.\n *\n * Null is returned when connection was closed cleanly. Otherwise, an object\n * with error details is returned.\n *\n * @param {CloseEvent} closeEvent\n * @return {Object} error object\n */\n getCloseError: function(closeEvent): any {\n if (closeEvent.code !== 1000 && closeEvent.code !== 1001) {\n return {\n type: 'PusherError',\n data: {\n code: closeEvent.code,\n message: closeEvent.reason || closeEvent.message\n }\n };\n } else {\n return null;\n }\n }\n};\n\nexport default Protocol;\n","import * as Collections from '../utils/collections';\nimport { default as EventsDispatcher } from '../events/dispatcher';\nimport Protocol from './protocol/protocol';\nimport { PusherEvent } from './protocol/message-types';\nimport Logger from '../logger';\nimport TransportConnection from '../transports/transport_connection';\nimport Socket from '../socket';\n/**\n * Provides Pusher protocol interface for transports.\n *\n * Emits following events:\n * - message - on received messages\n * - ping - on ping requests\n * - pong - on pong responses\n * - error - when the transport emits an error\n * - closed - after closing the transport\n *\n * It also emits more events when connection closes with a code.\n * See Protocol.getCloseAction to get more details.\n *\n * @param {Number} id\n * @param {AbstractTransport} transport\n */\nexport default class Connection extends EventsDispatcher implements Socket {\n id: string;\n transport: TransportConnection;\n activityTimeout: number;\n\n constructor(id: string, transport: TransportConnection) {\n super();\n this.id = id;\n this.transport = transport;\n this.activityTimeout = transport.activityTimeout;\n this.bindListeners();\n }\n\n /** Returns whether used transport handles activity checks by itself\n *\n * @returns {Boolean} true if activity checks are handled by the transport\n */\n handlesActivityChecks() {\n return this.transport.handlesActivityChecks();\n }\n\n /** Sends raw data.\n *\n * @param {String} data\n */\n send(data: any): boolean {\n return this.transport.send(data);\n }\n\n /** Sends an event.\n *\n * @param {String} name\n * @param {String} data\n * @param {String} [channel]\n * @returns {Boolean} whether message was sent or not\n */\n send_event(name: string, data: any, channel?: string): boolean {\n var event: PusherEvent = { event: name, data: data };\n if (channel) {\n event.channel = channel;\n }\n Logger.debug('Event sent', event);\n return this.send(Protocol.encodeMessage(event));\n }\n\n /** Sends a ping message to the server.\n *\n * Basing on the underlying transport, it might send either transport's\n * protocol-specific ping or pusher:ping event.\n */\n ping() {\n if (this.transport.supportsPing()) {\n this.transport.ping();\n } else {\n this.send_event('pusher:ping', {});\n }\n }\n\n /** Closes the connection. */\n close() {\n this.transport.close();\n }\n\n private bindListeners() {\n var listeners = {\n message: (messageEvent: MessageEvent) => {\n var pusherEvent;\n try {\n pusherEvent = Protocol.decodeMessage(messageEvent);\n } catch (e) {\n this.emit('error', {\n type: 'MessageParseError',\n error: e,\n data: messageEvent.data\n });\n }\n\n if (pusherEvent !== undefined) {\n Logger.debug('Event recd', pusherEvent);\n\n switch (pusherEvent.event) {\n case 'pusher:error':\n this.emit('error', {\n type: 'PusherError',\n data: pusherEvent.data\n });\n break;\n case 'pusher:ping':\n this.emit('ping');\n break;\n case 'pusher:pong':\n this.emit('pong');\n break;\n }\n this.emit('message', pusherEvent);\n }\n },\n activity: () => {\n this.emit('activity');\n },\n error: error => {\n this.emit('error', error);\n },\n closed: closeEvent => {\n unbindListeners();\n\n if (closeEvent && closeEvent.code) {\n this.handleCloseEvent(closeEvent);\n }\n\n this.transport = null;\n this.emit('closed');\n }\n };\n\n var unbindListeners = () => {\n Collections.objectApply(listeners, (listener, event) => {\n this.transport.unbind(event, listener);\n });\n };\n\n Collections.objectApply(listeners, (listener, event) => {\n this.transport.bind(event, listener);\n });\n }\n\n private handleCloseEvent(closeEvent: any) {\n var action = Protocol.getCloseAction(closeEvent);\n var error = Protocol.getCloseError(closeEvent);\n if (error) {\n this.emit('error', error);\n }\n if (action) {\n this.emit(action, { action: action, error: error });\n }\n }\n}\n","import Util from '../../util';\nimport * as Collections from '../../utils/collections';\nimport Protocol from '../protocol/protocol';\nimport Connection from '../connection';\nimport TransportConnection from '../../transports/transport_connection';\nimport HandshakePayload from './handshake_payload';\n\n/**\n * Handles Pusher protocol handshakes for transports.\n *\n * Calls back with a result object after handshake is completed. Results\n * always have two fields:\n * - action - string describing action to be taken after the handshake\n * - transport - the transport object passed to the constructor\n *\n * Different actions can set different additional properties on the result.\n * In the case of 'connected' action, there will be a 'connection' property\n * containing a Connection object for the transport. Other actions should\n * carry an 'error' property.\n *\n * @param {AbstractTransport} transport\n * @param {Function} callback\n */\nexport default class Handshake {\n transport: TransportConnection;\n callback: (HandshakePayload) => void;\n onMessage: Function;\n onClosed: Function;\n\n constructor(\n transport: TransportConnection,\n callback: (HandshakePayload) => void\n ) {\n this.transport = transport;\n this.callback = callback;\n this.bindListeners();\n }\n\n close() {\n this.unbindListeners();\n this.transport.close();\n }\n\n private bindListeners() {\n this.onMessage = m => {\n this.unbindListeners();\n\n var result;\n try {\n result = Protocol.processHandshake(m);\n } catch (e) {\n this.finish('error', { error: e });\n this.transport.close();\n return;\n }\n\n if (result.action === 'connected') {\n this.finish('connected', {\n connection: new Connection(result.id, this.transport),\n activityTimeout: result.activityTimeout\n });\n } else {\n this.finish(result.action, { error: result.error });\n this.transport.close();\n }\n };\n\n this.onClosed = closeEvent => {\n this.unbindListeners();\n\n var action = Protocol.getCloseAction(closeEvent) || 'backoff';\n var error = Protocol.getCloseError(closeEvent);\n this.finish(action, { error: error });\n };\n\n this.transport.bind('message', this.onMessage);\n this.transport.bind('closed', this.onClosed);\n }\n\n private unbindListeners() {\n this.transport.unbind('message', this.onMessage);\n this.transport.unbind('closed', this.onClosed);\n }\n\n private finish(action: string, params: any) {\n this.callback(\n Collections.extend({ transport: this.transport, action: action }, params)\n );\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport base64encode from '../base64';\nimport Timeline from './timeline';\nimport Runtime from 'runtime';\n\nexport interface TimelineSenderOptions {\n host?: string;\n port?: number;\n path?: string;\n}\n\nexport default class TimelineSender {\n timeline: Timeline;\n options: TimelineSenderOptions;\n host: string;\n\n constructor(timeline: Timeline, options: TimelineSenderOptions) {\n this.timeline = timeline;\n this.options = options || {};\n }\n\n send(useTLS: boolean, callback?: Function) {\n if (this.timeline.isEmpty()) {\n return;\n }\n\n this.timeline.send(\n Runtime.TimelineTransport.getAgent(this, useTLS),\n callback\n );\n }\n}\n","/** Error classes used throughout the library. */\n// https://github.com/Microsoft/TypeScript-wiki/blob/master/Breaking-Changes.md#extending-built-ins-like-error-array-and-map-may-no-longer-work\nexport class BadEventName extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\nexport class BadChannelName extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\nexport class RequestTimedOut extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class TransportPriorityTooLow extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class TransportClosed extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class UnsupportedFeature extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class UnsupportedTransport extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class UnsupportedStrategy extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class HTTPAuthError extends Error {\n status: number;\n constructor(status: number, msg?: string) {\n super(msg);\n this.status = status;\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n","/**\n * A place to store help URLs for error messages etc\n */\n\nconst urlStore = {\n baseUrl: 'https://pusher.com',\n urls: {\n authenticationEndpoint: {\n path: '/docs/channels/server_api/authenticating_users'\n },\n authorizationEndpoint: {\n path: '/docs/channels/server_api/authorizing-users/'\n },\n javascriptQuickStart: {\n path: '/docs/javascript_quick_start'\n },\n triggeringClientEvents: {\n path: '/docs/client_api_guide/client_events#trigger-events'\n },\n encryptedChannelSupport: {\n fullUrl:\n 'https://github.com/pusher/pusher-js/tree/cc491015371a4bde5743d1c87a0fbac0feb53195#encrypted-channel-support'\n }\n }\n};\n\n/** Builds a consistent string with links to pusher documentation\n *\n * @param {string} key - relevant key in the url_store.urls object\n * @return {string} suffix string to append to log message\n */\nconst buildLogSuffix = function(key: string): string {\n const urlPrefix = 'See:';\n const urlObj = urlStore.urls[key];\n if (!urlObj) return '';\n\n let url;\n if (urlObj.fullUrl) {\n url = urlObj.fullUrl;\n } else if (urlObj.path) {\n url = urlStore.baseUrl + urlObj.path;\n }\n\n if (!url) return '';\n return `${urlPrefix} ${url}`;\n};\n\nexport default { buildLogSuffix };\n","import { default as EventsDispatcher } from '../events/dispatcher';\nimport * as Errors from '../errors';\nimport Logger from '../logger';\nimport Pusher from '../pusher';\nimport { PusherEvent } from '../connection/protocol/message-types';\nimport Metadata from './metadata';\nimport UrlStore from '../utils/url_store';\nimport {\n ChannelAuthorizationData,\n ChannelAuthorizationCallback\n} from '../auth/options';\nimport { HTTPAuthError } from '../errors';\n\n/** Provides base public channel interface with an event emitter.\n *\n * Emits:\n * - pusher:subscription_succeeded - after subscribing successfully\n * - other non-internal events\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\nexport default class Channel extends EventsDispatcher {\n name: string;\n pusher: Pusher;\n subscribed: boolean;\n subscriptionPending: boolean;\n subscriptionCancelled: boolean;\n subscriptionCount: null;\n\n constructor(name: string, pusher: Pusher) {\n super(function(event, data) {\n Logger.debug('No callbacks on ' + name + ' for ' + event);\n });\n\n this.name = name;\n this.pusher = pusher;\n this.subscribed = false;\n this.subscriptionPending = false;\n this.subscriptionCancelled = false;\n }\n\n /** Skips authorization, since public channels don't require it.\n *\n * @param {Function} callback\n */\n authorize(socketId: string, callback: ChannelAuthorizationCallback) {\n return callback(null, { auth: '' });\n }\n\n /** Triggers an event */\n trigger(event: string, data: any) {\n if (event.indexOf('client-') !== 0) {\n throw new Errors.BadEventName(\n \"Event '\" + event + \"' does not start with 'client-'\"\n );\n }\n if (!this.subscribed) {\n var suffix = UrlStore.buildLogSuffix('triggeringClientEvents');\n Logger.warn(\n `Client event triggered before channel 'subscription_succeeded' event . ${suffix}`\n );\n }\n return this.pusher.send_event(event, data, this.name);\n }\n\n /** Signals disconnection to the channel. For internal use only. */\n disconnect() {\n this.subscribed = false;\n this.subscriptionPending = false;\n }\n\n /** Handles a PusherEvent. For internal use only.\n *\n * @param {PusherEvent} event\n */\n handleEvent(event: PusherEvent) {\n var eventName = event.event;\n var data = event.data;\n if (eventName === 'pusher_internal:subscription_succeeded') {\n this.handleSubscriptionSucceededEvent(event);\n } else if (eventName === 'pusher_internal:subscription_count') {\n this.handleSubscriptionCountEvent(event);\n } else if (eventName.indexOf('pusher_internal:') !== 0) {\n var metadata: Metadata = {};\n this.emit(eventName, data, metadata);\n }\n }\n\n handleSubscriptionSucceededEvent(event: PusherEvent) {\n this.subscriptionPending = false;\n this.subscribed = true;\n if (this.subscriptionCancelled) {\n this.pusher.unsubscribe(this.name);\n } else {\n this.emit('pusher:subscription_succeeded', event.data);\n }\n }\n\n handleSubscriptionCountEvent(event: PusherEvent) {\n if (event.data.subscription_count) {\n this.subscriptionCount = event.data.subscription_count;\n }\n\n this.emit('pusher:subscription_count', event.data);\n }\n\n /** Sends a subscription request. For internal use only. */\n subscribe() {\n if (this.subscribed) {\n return;\n }\n this.subscriptionPending = true;\n this.subscriptionCancelled = false;\n this.authorize(\n this.pusher.connection.socket_id,\n (error: Error | null, data: ChannelAuthorizationData) => {\n if (error) {\n this.subscriptionPending = false;\n // Why not bind to 'pusher:subscription_error' a level up, and log there?\n // Binding to this event would cause the warning about no callbacks being\n // bound (see constructor) to be suppressed, that's not what we want.\n Logger.error(error.toString());\n this.emit(\n 'pusher:subscription_error',\n Object.assign(\n {},\n {\n type: 'AuthError',\n error: error.message\n },\n error instanceof HTTPAuthError ? { status: error.status } : {}\n )\n );\n } else {\n this.pusher.send_event('pusher:subscribe', {\n auth: data.auth,\n channel_data: data.channel_data,\n channel: this.name\n });\n }\n }\n );\n }\n\n /** Sends an unsubscription request. For internal use only. */\n unsubscribe() {\n this.subscribed = false;\n this.pusher.send_event('pusher:unsubscribe', {\n channel: this.name\n });\n }\n\n /** Cancels an in progress subscription. For internal use only. */\n cancelSubscription() {\n this.subscriptionCancelled = true;\n }\n\n /** Reinstates an in progress subscripiton. For internal use only. */\n reinstateSubscription() {\n this.subscriptionCancelled = false;\n }\n}\n","import Factory from '../utils/factory';\nimport Channel from './channel';\nimport { ChannelAuthorizationCallback } from '../auth/options';\n\n/** Extends public channels to provide private channel interface.\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\nexport default class PrivateChannel extends Channel {\n /** Authorizes the connection to use the channel.\n *\n * @param {String} socketId\n * @param {Function} callback\n */\n authorize(socketId: string, callback: ChannelAuthorizationCallback) {\n return this.pusher.config.channelAuthorizer(\n {\n channelName: this.name,\n socketId: socketId\n },\n callback\n );\n }\n}\n","import * as Collections from '../utils/collections';\n\n/** Represents a collection of members of a presence channel. */\nexport default class Members {\n members: any;\n count: number;\n myID: any;\n me: any;\n\n constructor() {\n this.reset();\n }\n\n /** Returns member's info for given id.\n *\n * Resulting object containts two fields - id and info.\n *\n * @param {Number} id\n * @return {Object} member's info or null\n */\n get(id: string): any {\n if (Object.prototype.hasOwnProperty.call(this.members, id)) {\n return {\n id: id,\n info: this.members[id]\n };\n } else {\n return null;\n }\n }\n\n /** Calls back for each member in unspecified order.\n *\n * @param {Function} callback\n */\n each(callback: Function) {\n Collections.objectApply(this.members, (member, id) => {\n callback(this.get(id));\n });\n }\n\n /** Updates the id for connected member. For internal use only. */\n setMyID(id: string) {\n this.myID = id;\n }\n\n /** Handles subscription data. For internal use only. */\n onSubscription(subscriptionData: any) {\n this.members = subscriptionData.presence.hash;\n this.count = subscriptionData.presence.count;\n this.me = this.get(this.myID);\n }\n\n /** Adds a new member to the collection. For internal use only. */\n addMember(memberData: any) {\n if (this.get(memberData.user_id) === null) {\n this.count++;\n }\n this.members[memberData.user_id] = memberData.user_info;\n return this.get(memberData.user_id);\n }\n\n /** Adds a member from the collection. For internal use only. */\n removeMember(memberData: any) {\n var member = this.get(memberData.user_id);\n if (member) {\n delete this.members[memberData.user_id];\n this.count--;\n }\n return member;\n }\n\n /** Resets the collection to the initial state. For internal use only. */\n reset() {\n this.members = {};\n this.count = 0;\n this.myID = null;\n this.me = null;\n }\n}\n","import PrivateChannel from './private_channel';\nimport Logger from '../logger';\nimport Members from './members';\nimport Pusher from '../pusher';\nimport UrlStore from 'core/utils/url_store';\nimport { PusherEvent } from '../connection/protocol/message-types';\nimport Metadata from './metadata';\nimport { ChannelAuthorizationData } from '../auth/options';\n\nexport default class PresenceChannel extends PrivateChannel {\n members: Members;\n\n /** Adds presence channel functionality to private channels.\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\n constructor(name: string, pusher: Pusher) {\n super(name, pusher);\n this.members = new Members();\n }\n\n /** Authorizes the connection as a member of the channel.\n *\n * @param {String} socketId\n * @param {Function} callback\n */\n authorize(socketId: string, callback: Function) {\n super.authorize(socketId, async (error, authData) => {\n if (!error) {\n authData = authData as ChannelAuthorizationData;\n if (authData.channel_data != null) {\n var channelData = JSON.parse(authData.channel_data);\n this.members.setMyID(channelData.user_id);\n } else {\n await this.pusher.user.signinDonePromise;\n if (this.pusher.user.user_data != null) {\n // If the user is signed in, get the id of the authenticated user\n // and allow the presence authorization to continue.\n this.members.setMyID(this.pusher.user.user_data.id);\n } else {\n let suffix = UrlStore.buildLogSuffix('authorizationEndpoint');\n Logger.error(\n `Invalid auth response for channel '${this.name}', ` +\n `expected 'channel_data' field. ${suffix}, ` +\n `or the user should be signed in.`\n );\n callback('Invalid auth response');\n return;\n }\n }\n }\n callback(error, authData);\n });\n }\n\n /** Handles presence and subscription events. For internal use only.\n *\n * @param {PusherEvent} event\n */\n handleEvent(event: PusherEvent) {\n var eventName = event.event;\n if (eventName.indexOf('pusher_internal:') === 0) {\n this.handleInternalEvent(event);\n } else {\n var data = event.data;\n var metadata: Metadata = {};\n if (event.user_id) {\n metadata.user_id = event.user_id;\n }\n this.emit(eventName, data, metadata);\n }\n }\n handleInternalEvent(event: PusherEvent) {\n var eventName = event.event;\n var data = event.data;\n switch (eventName) {\n case 'pusher_internal:subscription_succeeded':\n this.handleSubscriptionSucceededEvent(event);\n break;\n case 'pusher_internal:subscription_count':\n this.handleSubscriptionCountEvent(event);\n break;\n case 'pusher_internal:member_added':\n var addedMember = this.members.addMember(data);\n this.emit('pusher:member_added', addedMember);\n break;\n case 'pusher_internal:member_removed':\n var removedMember = this.members.removeMember(data);\n if (removedMember) {\n this.emit('pusher:member_removed', removedMember);\n }\n break;\n }\n }\n\n handleSubscriptionSucceededEvent(event: PusherEvent) {\n this.subscriptionPending = false;\n this.subscribed = true;\n if (this.subscriptionCancelled) {\n this.pusher.unsubscribe(this.name);\n } else {\n this.members.onSubscription(event.data);\n this.emit('pusher:subscription_succeeded', this.members);\n }\n }\n\n /** Resets the channel state, including members map. For internal use only. */\n disconnect() {\n this.members.reset();\n super.disconnect();\n }\n}\n","import PrivateChannel from './private_channel';\nimport * as Errors from '../errors';\nimport Logger from '../logger';\nimport Pusher from '../pusher';\nimport { decode as encodeUTF8 } from '@stablelib/utf8';\nimport { decode as decodeBase64 } from '@stablelib/base64';\nimport Dispatcher from '../events/dispatcher';\nimport { PusherEvent } from '../connection/protocol/message-types';\nimport {\n ChannelAuthorizationData,\n ChannelAuthorizationCallback\n} from '../auth/options';\nimport * as nacl from 'tweetnacl';\n\n/** Extends private channels to provide encrypted channel interface.\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\nexport default class EncryptedChannel extends PrivateChannel {\n key: Uint8Array = null;\n nacl: nacl;\n\n constructor(name: string, pusher: Pusher, nacl: nacl) {\n super(name, pusher);\n this.nacl = nacl;\n }\n\n /** Authorizes the connection to use the channel.\n *\n * @param {String} socketId\n * @param {Function} callback\n */\n authorize(socketId: string, callback: ChannelAuthorizationCallback) {\n super.authorize(\n socketId,\n (error: Error | null, authData: ChannelAuthorizationData) => {\n if (error) {\n callback(error, authData);\n return;\n }\n let sharedSecret = authData['shared_secret'];\n if (!sharedSecret) {\n callback(\n new Error(\n `No shared_secret key in auth payload for encrypted channel: ${this.name}`\n ),\n null\n );\n return;\n }\n this.key = decodeBase64(sharedSecret);\n delete authData['shared_secret'];\n callback(null, authData);\n }\n );\n }\n\n trigger(event: string, data: any): boolean {\n throw new Errors.UnsupportedFeature(\n 'Client events are not currently supported for encrypted channels'\n );\n }\n\n /** Handles an event. For internal use only.\n *\n * @param {PusherEvent} event\n */\n handleEvent(event: PusherEvent) {\n var eventName = event.event;\n var data = event.data;\n if (\n eventName.indexOf('pusher_internal:') === 0 ||\n eventName.indexOf('pusher:') === 0\n ) {\n super.handleEvent(event);\n return;\n }\n this.handleEncryptedEvent(eventName, data);\n }\n\n private handleEncryptedEvent(event: string, data: any): void {\n if (!this.key) {\n Logger.debug(\n 'Received encrypted event before key has been retrieved from the authEndpoint'\n );\n return;\n }\n if (!data.ciphertext || !data.nonce) {\n Logger.error(\n 'Unexpected format for encrypted event, expected object with `ciphertext` and `nonce` fields, got: ' +\n data\n );\n return;\n }\n let cipherText = decodeBase64(data.ciphertext);\n if (cipherText.length < this.nacl.secretbox.overheadLength) {\n Logger.error(\n `Expected encrypted event ciphertext length to be ${this.nacl.secretbox.overheadLength}, got: ${cipherText.length}`\n );\n return;\n }\n let nonce = decodeBase64(data.nonce);\n if (nonce.length < this.nacl.secretbox.nonceLength) {\n Logger.error(\n `Expected encrypted event nonce length to be ${this.nacl.secretbox.nonceLength}, got: ${nonce.length}`\n );\n return;\n }\n\n let bytes = this.nacl.secretbox.open(cipherText, nonce, this.key);\n if (bytes === null) {\n Logger.debug(\n 'Failed to decrypt an event, probably because it was encrypted with a different key. Fetching a new key from the authEndpoint...'\n );\n // Try a single time to retrieve a new auth key and decrypt the event with it\n // If this fails, a new key will be requested when a new message is received\n this.authorize(this.pusher.connection.socket_id, (error, authData) => {\n if (error) {\n Logger.error(\n `Failed to make a request to the authEndpoint: ${authData}. Unable to fetch new key, so dropping encrypted event`\n );\n return;\n }\n bytes = this.nacl.secretbox.open(cipherText, nonce, this.key);\n if (bytes === null) {\n Logger.error(\n `Failed to decrypt event with new key. Dropping encrypted event`\n );\n return;\n }\n this.emit(event, this.getDataToEmit(bytes));\n return;\n });\n return;\n }\n this.emit(event, this.getDataToEmit(bytes));\n }\n\n // Try and parse the decrypted bytes as JSON. If we can't parse it, just\n // return the utf-8 string\n getDataToEmit(bytes: Uint8Array): string {\n let raw = encodeUTF8(bytes);\n try {\n return JSON.parse(raw);\n } catch {\n return raw;\n }\n }\n}\n","import { default as EventsDispatcher } from '../events/dispatcher';\nimport { OneOffTimer as Timer } from '../utils/timers';\nimport { Config } from '../config';\nimport Logger from '../logger';\nimport HandshakePayload from './handshake/handshake_payload';\nimport Connection from './connection';\nimport Strategy from '../strategies/strategy';\nimport StrategyRunner from '../strategies/strategy_runner';\nimport * as Collections from '../utils/collections';\nimport Timeline from '../timeline/timeline';\nimport ConnectionManagerOptions from './connection_manager_options';\nimport Runtime from 'runtime';\n\nimport {\n ErrorCallbacks,\n HandshakeCallbacks,\n ConnectionCallbacks\n} from './callbacks';\nimport Action from './protocol/action';\n\n/** Manages connection to Pusher.\n *\n * Uses a strategy (currently only default), timers and network availability\n * info to establish a connection and export its state. In case of failures,\n * manages reconnection attempts.\n *\n * Exports state changes as following events:\n * - \"state_change\", { previous: p, current: state }\n * - state\n *\n * States:\n * - initialized - initial state, never transitioned to\n * - connecting - connection is being established\n * - connected - connection has been fully established\n * - disconnected - on requested disconnection\n * - unavailable - after connection timeout or when there's no network\n * - failed - when the connection strategy is not supported\n *\n * Options:\n * - unavailableTimeout - time to transition to unavailable state\n * - activityTimeout - time after which ping message should be sent\n * - pongTimeout - time for Pusher to respond with pong before reconnecting\n *\n * @param {String} key application key\n * @param {Object} options\n */\nexport default class ConnectionManager extends EventsDispatcher {\n key: string;\n options: ConnectionManagerOptions;\n state: string;\n connection: Connection;\n usingTLS: boolean;\n timeline: Timeline;\n socket_id: string;\n unavailableTimer: Timer;\n activityTimer: Timer;\n retryTimer: Timer;\n activityTimeout: number;\n strategy: Strategy;\n runner: StrategyRunner;\n errorCallbacks: ErrorCallbacks;\n handshakeCallbacks: HandshakeCallbacks;\n connectionCallbacks: ConnectionCallbacks;\n\n constructor(key: string, options: ConnectionManagerOptions) {\n super();\n this.state = 'initialized';\n this.connection = null;\n\n this.key = key;\n this.options = options;\n this.timeline = this.options.timeline;\n this.usingTLS = this.options.useTLS;\n\n this.errorCallbacks = this.buildErrorCallbacks();\n this.connectionCallbacks = this.buildConnectionCallbacks(\n this.errorCallbacks\n );\n this.handshakeCallbacks = this.buildHandshakeCallbacks(this.errorCallbacks);\n\n var Network = Runtime.getNetwork();\n\n Network.bind('online', () => {\n this.timeline.info({ netinfo: 'online' });\n if (this.state === 'connecting' || this.state === 'unavailable') {\n this.retryIn(0);\n }\n });\n Network.bind('offline', () => {\n this.timeline.info({ netinfo: 'offline' });\n if (this.connection) {\n this.sendActivityCheck();\n }\n });\n\n this.updateStrategy();\n }\n\n switchCluster(key: string) {\n this.key = key;\n // This ensures that the new config coming from\n // pusher instance are taken into account\n // such as appKey and cluster\n this.updateStrategy();\n this.retryIn(0);\n }\n\n /** Establishes a connection to Pusher.\n *\n * Does nothing when connection is already established. See top-level doc\n * to find events emitted on connection attempts.\n */\n connect() {\n if (this.connection || this.runner) {\n return;\n }\n if (!this.strategy.isSupported()) {\n this.updateState('failed');\n return;\n }\n this.updateState('connecting');\n this.startConnecting();\n this.setUnavailableTimer();\n }\n\n /** Sends raw data.\n *\n * @param {String} data\n */\n send(data) {\n if (this.connection) {\n return this.connection.send(data);\n } else {\n return false;\n }\n }\n\n /** Sends an event.\n *\n * @param {String} name\n * @param {String} data\n * @param {String} [channel]\n * @returns {Boolean} whether message was sent or not\n */\n send_event(name: string, data: any, channel?: string) {\n if (this.connection) {\n return this.connection.send_event(name, data, channel);\n } else {\n return false;\n }\n }\n\n /** Closes the connection. */\n disconnect() {\n this.disconnectInternally();\n this.updateState('disconnected');\n }\n\n isUsingTLS() {\n return this.usingTLS;\n }\n\n private startConnecting() {\n var callback = (error, handshake) => {\n if (error) {\n this.runner = this.strategy.connect(0, callback);\n } else {\n if (handshake.action === 'error') {\n this.emit('error', {\n type: 'HandshakeError',\n error: handshake.error\n });\n this.timeline.error({ handshakeError: handshake.error });\n } else {\n this.abortConnecting(); // we don't support switching connections yet\n this.handshakeCallbacks[handshake.action](handshake);\n }\n }\n };\n this.runner = this.strategy.connect(0, callback);\n }\n\n private abortConnecting() {\n if (this.runner) {\n this.runner.abort();\n this.runner = null;\n }\n }\n\n private disconnectInternally() {\n this.abortConnecting();\n this.clearRetryTimer();\n this.clearUnavailableTimer();\n if (this.connection) {\n var connection = this.abandonConnection();\n connection.close();\n }\n }\n\n private updateStrategy() {\n this.strategy = this.options.getStrategy({\n key: this.key,\n timeline: this.timeline,\n useTLS: this.usingTLS\n });\n }\n\n private retryIn(delay) {\n this.timeline.info({ action: 'retry', delay: delay });\n if (delay > 0) {\n this.emit('connecting_in', Math.round(delay / 1000));\n }\n this.retryTimer = new Timer(delay || 0, () => {\n this.disconnectInternally();\n this.connect();\n });\n }\n\n private clearRetryTimer() {\n if (this.retryTimer) {\n this.retryTimer.ensureAborted();\n this.retryTimer = null;\n }\n }\n\n private setUnavailableTimer() {\n this.unavailableTimer = new Timer(this.options.unavailableTimeout, () => {\n this.updateState('unavailable');\n });\n }\n\n private clearUnavailableTimer() {\n if (this.unavailableTimer) {\n this.unavailableTimer.ensureAborted();\n }\n }\n\n private sendActivityCheck() {\n this.stopActivityCheck();\n this.connection.ping();\n // wait for pong response\n this.activityTimer = new Timer(this.options.pongTimeout, () => {\n this.timeline.error({ pong_timed_out: this.options.pongTimeout });\n this.retryIn(0);\n });\n }\n\n private resetActivityCheck() {\n this.stopActivityCheck();\n // send ping after inactivity\n if (this.connection && !this.connection.handlesActivityChecks()) {\n this.activityTimer = new Timer(this.activityTimeout, () => {\n this.sendActivityCheck();\n });\n }\n }\n\n private stopActivityCheck() {\n if (this.activityTimer) {\n this.activityTimer.ensureAborted();\n }\n }\n\n private buildConnectionCallbacks(\n errorCallbacks: ErrorCallbacks\n ): ConnectionCallbacks {\n return Collections.extend({}, errorCallbacks, {\n message: message => {\n // includes pong messages from server\n this.resetActivityCheck();\n this.emit('message', message);\n },\n ping: () => {\n this.send_event('pusher:pong', {});\n },\n activity: () => {\n this.resetActivityCheck();\n },\n error: error => {\n // just emit error to user - socket will already be closed by browser\n this.emit('error', error);\n },\n closed: () => {\n this.abandonConnection();\n if (this.shouldRetry()) {\n this.retryIn(1000);\n }\n }\n });\n }\n\n private buildHandshakeCallbacks(\n errorCallbacks: ErrorCallbacks\n ): HandshakeCallbacks {\n return Collections.extend({}, errorCallbacks, {\n connected: (handshake: HandshakePayload) => {\n this.activityTimeout = Math.min(\n this.options.activityTimeout,\n handshake.activityTimeout,\n handshake.connection.activityTimeout || Infinity\n );\n this.clearUnavailableTimer();\n this.setConnection(handshake.connection);\n this.socket_id = this.connection.id;\n this.updateState('connected', { socket_id: this.socket_id });\n }\n });\n }\n\n private buildErrorCallbacks(): ErrorCallbacks {\n let withErrorEmitted = callback => {\n return (result: Action | HandshakePayload) => {\n if (result.error) {\n this.emit('error', { type: 'WebSocketError', error: result.error });\n }\n callback(result);\n };\n };\n\n return {\n tls_only: withErrorEmitted(() => {\n this.usingTLS = true;\n this.updateStrategy();\n this.retryIn(0);\n }),\n refused: withErrorEmitted(() => {\n this.disconnect();\n }),\n backoff: withErrorEmitted(() => {\n this.retryIn(1000);\n }),\n retry: withErrorEmitted(() => {\n this.retryIn(0);\n })\n };\n }\n\n private setConnection(connection) {\n this.connection = connection;\n for (var event in this.connectionCallbacks) {\n this.connection.bind(event, this.connectionCallbacks[event]);\n }\n this.resetActivityCheck();\n }\n\n private abandonConnection() {\n if (!this.connection) {\n return;\n }\n this.stopActivityCheck();\n for (var event in this.connectionCallbacks) {\n this.connection.unbind(event, this.connectionCallbacks[event]);\n }\n var connection = this.connection;\n this.connection = null;\n return connection;\n }\n\n private updateState(newState: string, data?: any) {\n var previousState = this.state;\n this.state = newState;\n if (previousState !== newState) {\n var newStateDescription = newState;\n if (newStateDescription === 'connected') {\n newStateDescription += ' with new socket ID ' + data.socket_id;\n }\n Logger.debug(\n 'State changed',\n previousState + ' -> ' + newStateDescription\n );\n this.timeline.info({ state: newState, params: data });\n this.emit('state_change', { previous: previousState, current: newState });\n this.emit(newState, data);\n }\n }\n\n private shouldRetry(): boolean {\n return this.state === 'connecting' || this.state === 'connected';\n }\n}\n","import Channel from './channel';\nimport * as Collections from '../utils/collections';\nimport ChannelTable from './channel_table';\nimport Factory from '../utils/factory';\nimport Pusher from '../pusher';\nimport Logger from '../logger';\nimport * as Errors from '../errors';\nimport urlStore from '../utils/url_store';\n\n/** Handles a channel map. */\nexport default class Channels {\n channels: ChannelTable;\n\n constructor() {\n this.channels = {};\n }\n\n /** Creates or retrieves an existing channel by its name.\n *\n * @param {String} name\n * @param {Pusher} pusher\n * @return {Channel}\n */\n add(name: string, pusher: Pusher) {\n if (!this.channels[name]) {\n this.channels[name] = createChannel(name, pusher);\n }\n return this.channels[name];\n }\n\n /** Returns a list of all channels\n *\n * @return {Array}\n */\n all(): Channel[] {\n return Collections.values(this.channels);\n }\n\n /** Finds a channel by its name.\n *\n * @param {String} name\n * @return {Channel} channel or null if it doesn't exist\n */\n find(name: string) {\n return this.channels[name];\n }\n\n /** Removes a channel from the map.\n *\n * @param {String} name\n */\n remove(name: string) {\n var channel = this.channels[name];\n delete this.channels[name];\n return channel;\n }\n\n /** Proxies disconnection signal to all channels. */\n disconnect() {\n Collections.objectApply(this.channels, function(channel) {\n channel.disconnect();\n });\n }\n}\n\nfunction createChannel(name: string, pusher: Pusher): Channel {\n if (name.indexOf('private-encrypted-') === 0) {\n if (pusher.config.nacl) {\n return Factory.createEncryptedChannel(name, pusher, pusher.config.nacl);\n }\n let errMsg =\n 'Tried to subscribe to a private-encrypted- channel but no nacl implementation available';\n let suffix = urlStore.buildLogSuffix('encryptedChannelSupport');\n throw new Errors.UnsupportedFeature(`${errMsg}. ${suffix}`);\n } else if (name.indexOf('private-') === 0) {\n return Factory.createPrivateChannel(name, pusher);\n } else if (name.indexOf('presence-') === 0) {\n return Factory.createPresenceChannel(name, pusher);\n } else if (name.indexOf('#') === 0) {\n throw new Errors.BadChannelName(\n 'Cannot create a channel with name \"' + name + '\".'\n );\n } else {\n return Factory.createChannel(name, pusher);\n }\n}\n","import AssistantToTheTransportManager from '../transports/assistant_to_the_transport_manager';\nimport PingDelayOptions from '../transports/ping_delay_options';\nimport Transport from '../transports/transport';\nimport TransportManager from '../transports/transport_manager';\nimport Handshake from '../connection/handshake';\nimport TransportConnection from '../transports/transport_connection';\nimport SocketHooks from '../http/socket_hooks';\nimport HTTPSocket from '../http/http_socket';\n\nimport Timeline from '../timeline/timeline';\nimport {\n default as TimelineSender,\n TimelineSenderOptions\n} from '../timeline/timeline_sender';\nimport PresenceChannel from '../channels/presence_channel';\nimport PrivateChannel from '../channels/private_channel';\nimport EncryptedChannel from '../channels/encrypted_channel';\nimport Channel from '../channels/channel';\nimport ConnectionManager from '../connection/connection_manager';\nimport ConnectionManagerOptions from '../connection/connection_manager_options';\nimport Ajax from '../http/ajax';\nimport Channels from '../channels/channels';\nimport Pusher from '../pusher';\nimport { Config } from '../config';\nimport * as nacl from 'tweetnacl';\n\nvar Factory = {\n createChannels(): Channels {\n return new Channels();\n },\n\n createConnectionManager(\n key: string,\n options: ConnectionManagerOptions\n ): ConnectionManager {\n return new ConnectionManager(key, options);\n },\n\n createChannel(name: string, pusher: Pusher): Channel {\n return new Channel(name, pusher);\n },\n\n createPrivateChannel(name: string, pusher: Pusher): PrivateChannel {\n return new PrivateChannel(name, pusher);\n },\n\n createPresenceChannel(name: string, pusher: Pusher): PresenceChannel {\n return new PresenceChannel(name, pusher);\n },\n\n createEncryptedChannel(\n name: string,\n pusher: Pusher,\n nacl: nacl\n ): EncryptedChannel {\n return new EncryptedChannel(name, pusher, nacl);\n },\n\n createTimelineSender(timeline: Timeline, options: TimelineSenderOptions) {\n return new TimelineSender(timeline, options);\n },\n\n createHandshake(\n transport: TransportConnection,\n callback: (HandshakePayload) => void\n ): Handshake {\n return new Handshake(transport, callback);\n },\n\n createAssistantToTheTransportManager(\n manager: TransportManager,\n transport: Transport,\n options: PingDelayOptions\n ): AssistantToTheTransportManager {\n return new AssistantToTheTransportManager(manager, transport, options);\n }\n};\n\nexport default Factory;\n","import AssistantToTheTransportManager from './assistant_to_the_transport_manager';\nimport Transport from './transport';\nimport PingDelayOptions from './ping_delay_options';\nimport Factory from '../utils/factory';\n\nexport interface TransportManagerOptions extends PingDelayOptions {\n lives?: number;\n}\n\n/** Keeps track of the number of lives left for a transport.\n *\n * In the beginning of a session, transports may be assigned a number of\n * lives. When an AssistantToTheTransportManager instance reports a transport\n * connection closed uncleanly, the transport loses a life. When the number\n * of lives drops to zero, the transport gets disabled by its manager.\n *\n * @param {Object} options\n */\nexport default class TransportManager {\n options: TransportManagerOptions;\n livesLeft: number;\n\n constructor(options: TransportManagerOptions) {\n this.options = options || {};\n this.livesLeft = this.options.lives || Infinity;\n }\n\n /** Creates a assistant for the transport.\n *\n * @param {Transport} transport\n * @returns {AssistantToTheTransportManager}\n */\n getAssistant(transport: Transport): AssistantToTheTransportManager {\n return Factory.createAssistantToTheTransportManager(this, transport, {\n minPingDelay: this.options.minPingDelay,\n maxPingDelay: this.options.maxPingDelay\n });\n }\n\n /** Returns whether the transport has any lives left.\n *\n * @returns {Boolean}\n */\n isAlive(): boolean {\n return this.livesLeft > 0;\n }\n\n /** Takes one life from the transport. */\n reportDeath() {\n this.livesLeft -= 1;\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport { OneOffTimer as Timer } from '../utils/timers';\nimport Strategy from './strategy';\nimport StrategyOptions from './strategy_options';\n\n/** Loops through strategies with optional timeouts.\n *\n * Options:\n * - loop - whether it should loop through the substrategy list\n * - timeout - initial timeout for a single substrategy\n * - timeoutLimit - maximum timeout\n *\n * @param {Strategy[]} strategies\n * @param {Object} options\n */\nexport default class SequentialStrategy implements Strategy {\n strategies: Strategy[];\n loop: boolean;\n failFast: boolean;\n timeout: number;\n timeoutLimit: number;\n\n constructor(strategies: Strategy[], options: StrategyOptions) {\n this.strategies = strategies;\n this.loop = Boolean(options.loop);\n this.failFast = Boolean(options.failFast);\n this.timeout = options.timeout;\n this.timeoutLimit = options.timeoutLimit;\n }\n\n isSupported(): boolean {\n return Collections.any(this.strategies, Util.method('isSupported'));\n }\n\n connect(minPriority: number, callback: Function) {\n var strategies = this.strategies;\n var current = 0;\n var timeout = this.timeout;\n var runner = null;\n\n var tryNextStrategy = (error, handshake) => {\n if (handshake) {\n callback(null, handshake);\n } else {\n current = current + 1;\n if (this.loop) {\n current = current % strategies.length;\n }\n\n if (current < strategies.length) {\n if (timeout) {\n timeout = timeout * 2;\n if (this.timeoutLimit) {\n timeout = Math.min(timeout, this.timeoutLimit);\n }\n }\n runner = this.tryStrategy(\n strategies[current],\n minPriority,\n { timeout, failFast: this.failFast },\n tryNextStrategy\n );\n } else {\n callback(true);\n }\n }\n };\n\n runner = this.tryStrategy(\n strategies[current],\n minPriority,\n { timeout: timeout, failFast: this.failFast },\n tryNextStrategy\n );\n\n return {\n abort: function() {\n runner.abort();\n },\n forceMinPriority: function(p) {\n minPriority = p;\n if (runner) {\n runner.forceMinPriority(p);\n }\n }\n };\n }\n\n private tryStrategy(\n strategy: Strategy,\n minPriority: number,\n options: StrategyOptions,\n callback: Function\n ) {\n var timer = null;\n var runner = null;\n\n if (options.timeout > 0) {\n timer = new Timer(options.timeout, function() {\n runner.abort();\n callback(true);\n });\n }\n\n runner = strategy.connect(minPriority, function(error, handshake) {\n if (error && timer && timer.isRunning() && !options.failFast) {\n // advance to the next strategy after the timeout\n return;\n }\n if (timer) {\n timer.ensureAborted();\n }\n callback(error, handshake);\n });\n\n return {\n abort: function() {\n if (timer) {\n timer.ensureAborted();\n }\n runner.abort();\n },\n forceMinPriority: function(p) {\n runner.forceMinPriority(p);\n }\n };\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport Strategy from './strategy';\n\n/** Launches all substrategies and emits prioritized connected transports.\n *\n * @param {Array} strategies\n */\nexport default class BestConnectedEverStrategy implements Strategy {\n strategies: Strategy[];\n\n constructor(strategies: Strategy[]) {\n this.strategies = strategies;\n }\n\n isSupported(): boolean {\n return Collections.any(this.strategies, Util.method('isSupported'));\n }\n\n connect(minPriority: number, callback: Function) {\n return connect(this.strategies, minPriority, function(i, runners) {\n return function(error, handshake) {\n runners[i].error = error;\n if (error) {\n if (allRunnersFailed(runners)) {\n callback(true);\n }\n return;\n }\n Collections.apply(runners, function(runner) {\n runner.forceMinPriority(handshake.transport.priority);\n });\n callback(null, handshake);\n };\n });\n }\n}\n\n/** Connects to all strategies in parallel.\n *\n * Callback builder should be a function that takes two arguments: index\n * and a list of runners. It should return another function that will be\n * passed to the substrategy with given index. Runners can be aborted using\n * abortRunner(s) functions from this class.\n *\n * @param {Array} strategies\n * @param {Function} callbackBuilder\n * @return {Object} strategy runner\n */\nfunction connect(\n strategies: Strategy[],\n minPriority: number,\n callbackBuilder: Function\n) {\n var runners = Collections.map(strategies, function(strategy, i, _, rs) {\n return strategy.connect(minPriority, callbackBuilder(i, rs));\n });\n return {\n abort: function() {\n Collections.apply(runners, abortRunner);\n },\n forceMinPriority: function(p) {\n Collections.apply(runners, function(runner) {\n runner.forceMinPriority(p);\n });\n }\n };\n}\n\nfunction allRunnersFailed(runners): boolean {\n return Collections.all(runners, function(runner) {\n return Boolean(runner.error);\n });\n}\n\nfunction abortRunner(runner) {\n if (!runner.error && !runner.aborted) {\n runner.abort();\n runner.aborted = true;\n }\n}\n","import Util from '../util';\nimport Runtime from 'runtime';\nimport Strategy from './strategy';\nimport SequentialStrategy from './sequential_strategy';\nimport StrategyOptions from './strategy_options';\nimport TransportStrategy from './transport_strategy';\nimport Timeline from '../timeline/timeline';\nimport * as Collections from '../utils/collections';\n\nexport interface TransportStrategyDictionary {\n [key: string]: TransportStrategy;\n}\n\n/** Caches the last successful transport and, after the first few attempts,\n * uses the cached transport for subsequent attempts.\n *\n * @param {Strategy} strategy\n * @param {Object} transports\n * @param {Object} options\n */\nexport default class WebSocketPrioritizedCachedStrategy implements Strategy {\n strategy: Strategy;\n transports: TransportStrategyDictionary;\n ttl: number;\n usingTLS: boolean;\n timeline: Timeline;\n\n constructor(\n strategy: Strategy,\n transports: TransportStrategyDictionary,\n options: StrategyOptions\n ) {\n this.strategy = strategy;\n this.transports = transports;\n this.ttl = options.ttl || 1800 * 1000;\n this.usingTLS = options.useTLS;\n this.timeline = options.timeline;\n }\n\n isSupported(): boolean {\n return this.strategy.isSupported();\n }\n\n connect(minPriority: number, callback: Function) {\n var usingTLS = this.usingTLS;\n var info = fetchTransportCache(usingTLS);\n var cacheSkipCount = info && info.cacheSkipCount ? info.cacheSkipCount : 0;\n\n var strategies = [this.strategy];\n if (info && info.timestamp + this.ttl >= Util.now()) {\n var transport = this.transports[info.transport];\n if (transport) {\n if (['ws', 'wss'].includes(info.transport) || cacheSkipCount > 3) {\n this.timeline.info({\n cached: true,\n transport: info.transport,\n latency: info.latency\n });\n strategies.push(\n new SequentialStrategy([transport], {\n timeout: info.latency * 2 + 1000,\n failFast: true\n })\n );\n } else {\n cacheSkipCount++;\n }\n }\n }\n\n var startTimestamp = Util.now();\n var runner = strategies\n .pop()\n .connect(minPriority, function cb(error, handshake) {\n if (error) {\n flushTransportCache(usingTLS);\n if (strategies.length > 0) {\n startTimestamp = Util.now();\n runner = strategies.pop().connect(minPriority, cb);\n } else {\n callback(error);\n }\n } else {\n storeTransportCache(\n usingTLS,\n handshake.transport.name,\n Util.now() - startTimestamp,\n cacheSkipCount\n );\n callback(null, handshake);\n }\n });\n\n return {\n abort: function() {\n runner.abort();\n },\n forceMinPriority: function(p) {\n minPriority = p;\n if (runner) {\n runner.forceMinPriority(p);\n }\n }\n };\n }\n}\n\nfunction getTransportCacheKey(usingTLS: boolean): string {\n return 'pusherTransport' + (usingTLS ? 'TLS' : 'NonTLS');\n}\n\nfunction fetchTransportCache(usingTLS: boolean): any {\n var storage = Runtime.getLocalStorage();\n if (storage) {\n try {\n var serializedCache = storage[getTransportCacheKey(usingTLS)];\n if (serializedCache) {\n return JSON.parse(serializedCache);\n }\n } catch (e) {\n flushTransportCache(usingTLS);\n }\n }\n return null;\n}\n\nfunction storeTransportCache(\n usingTLS: boolean,\n transport: TransportStrategy,\n latency: number,\n cacheSkipCount: number\n) {\n var storage = Runtime.getLocalStorage();\n if (storage) {\n try {\n storage[getTransportCacheKey(usingTLS)] = Collections.safeJSONStringify({\n timestamp: Util.now(),\n transport: transport,\n latency: latency,\n cacheSkipCount: cacheSkipCount\n });\n } catch (e) {\n // catch over quota exceptions raised by localStorage\n }\n }\n}\n\nfunction flushTransportCache(usingTLS: boolean) {\n var storage = Runtime.getLocalStorage();\n if (storage) {\n try {\n delete storage[getTransportCacheKey(usingTLS)];\n } catch (e) {\n // catch exceptions raised by localStorage\n }\n }\n}\n","import { OneOffTimer as Timer } from '../utils/timers';\nimport Strategy from './strategy';\nimport StrategyOptions from './strategy_options';\n\n/** Runs substrategy after specified delay.\n *\n * Options:\n * - delay - time in miliseconds to delay the substrategy attempt\n *\n * @param {Strategy} strategy\n * @param {Object} options\n */\nexport default class DelayedStrategy implements Strategy {\n strategy: Strategy;\n options: { delay: number };\n\n constructor(strategy: Strategy, { delay: number }) {\n this.strategy = strategy;\n this.options = { delay: number };\n }\n\n isSupported(): boolean {\n return this.strategy.isSupported();\n }\n\n connect(minPriority: number, callback: Function) {\n var strategy = this.strategy;\n var runner;\n var timer = new Timer(this.options.delay, function() {\n runner = strategy.connect(minPriority, callback);\n });\n\n return {\n abort: function() {\n timer.ensureAborted();\n if (runner) {\n runner.abort();\n }\n },\n forceMinPriority: function(p) {\n minPriority = p;\n if (runner) {\n runner.forceMinPriority(p);\n }\n }\n };\n }\n}\n","import Strategy from './strategy';\nimport StrategyRunner from './strategy_runner';\n\n/** Proxies method calls to one of substrategies basing on the test function.\n *\n * @param {Function} test\n * @param {Strategy} trueBranch strategy used when test returns true\n * @param {Strategy} falseBranch strategy used when test returns false\n */\nexport default class IfStrategy implements Strategy {\n test: () => boolean;\n trueBranch: Strategy;\n falseBranch: Strategy;\n\n constructor(\n test: () => boolean,\n trueBranch: Strategy,\n falseBranch: Strategy\n ) {\n this.test = test;\n this.trueBranch = trueBranch;\n this.falseBranch = falseBranch;\n }\n\n isSupported(): boolean {\n var branch = this.test() ? this.trueBranch : this.falseBranch;\n return branch.isSupported();\n }\n\n connect(minPriority: number, callback: Function): StrategyRunner {\n var branch = this.test() ? this.trueBranch : this.falseBranch;\n return branch.connect(minPriority, callback);\n }\n}\n","import Strategy from './strategy';\nimport StrategyRunner from './strategy_runner';\n\n/** Launches the substrategy and terminates on the first open connection.\n *\n * @param {Strategy} strategy\n */\nexport default class FirstConnectedStrategy implements Strategy {\n strategy: Strategy;\n\n constructor(strategy: Strategy) {\n this.strategy = strategy;\n }\n\n isSupported(): boolean {\n return this.strategy.isSupported();\n }\n\n connect(minPriority: number, callback: Function): StrategyRunner {\n var runner = this.strategy.connect(minPriority, function(error, handshake) {\n if (handshake) {\n runner.abort();\n }\n callback(error, handshake);\n });\n return runner;\n }\n}\n","import * as Collections from 'core/utils/collections';\nimport TransportManager from 'core/transports/transport_manager';\nimport Strategy from 'core/strategies/strategy';\nimport SequentialStrategy from 'core/strategies/sequential_strategy';\nimport BestConnectedEverStrategy from 'core/strategies/best_connected_ever_strategy';\nimport WebSocketPrioritizedCachedStrategy, {\n TransportStrategyDictionary\n} from 'core/strategies/websocket_prioritized_cached_strategy';\nimport DelayedStrategy from 'core/strategies/delayed_strategy';\nimport IfStrategy from 'core/strategies/if_strategy';\nimport FirstConnectedStrategy from 'core/strategies/first_connected_strategy';\nimport { Config } from 'core/config';\nimport StrategyOptions from 'core/strategies/strategy_options';\n\nfunction testSupportsStrategy(strategy: Strategy) {\n return function() {\n return strategy.isSupported();\n };\n}\n\nvar getDefaultStrategy = function(\n config: Config,\n baseOptions: StrategyOptions,\n defineTransport: Function\n): Strategy {\n var definedTransports = {};\n\n function defineTransportStrategy(\n name: string,\n type: string,\n priority: number,\n options: StrategyOptions,\n manager?: TransportManager\n ) {\n var transport = defineTransport(\n config,\n name,\n type,\n priority,\n options,\n manager\n );\n\n definedTransports[name] = transport;\n\n return transport;\n }\n\n var ws_options: StrategyOptions = Object.assign({}, baseOptions, {\n hostNonTLS: config.wsHost + ':' + config.wsPort,\n hostTLS: config.wsHost + ':' + config.wssPort,\n httpPath: config.wsPath\n });\n var wss_options: StrategyOptions = Collections.extend({}, ws_options, {\n useTLS: true\n });\n var http_options: StrategyOptions = Object.assign({}, baseOptions, {\n hostNonTLS: config.httpHost + ':' + config.httpPort,\n hostTLS: config.httpHost + ':' + config.httpsPort,\n httpPath: config.httpPath\n });\n var timeouts = {\n loop: true,\n timeout: 15000,\n timeoutLimit: 60000\n };\n\n var ws_manager = new TransportManager({\n minPingDelay: 10000,\n maxPingDelay: config.activityTimeout\n });\n var streaming_manager = new TransportManager({\n lives: 2,\n minPingDelay: 10000,\n maxPingDelay: config.activityTimeout\n });\n\n var ws_transport = defineTransportStrategy(\n 'ws',\n 'ws',\n 3,\n ws_options,\n ws_manager\n );\n var wss_transport = defineTransportStrategy(\n 'wss',\n 'ws',\n 3,\n wss_options,\n ws_manager\n );\n var xhr_streaming_transport = defineTransportStrategy(\n 'xhr_streaming',\n 'xhr_streaming',\n 1,\n http_options,\n streaming_manager\n );\n var xhr_polling_transport = defineTransportStrategy(\n 'xhr_polling',\n 'xhr_polling',\n 1,\n http_options\n );\n\n var ws_loop = new SequentialStrategy([ws_transport], timeouts);\n var wss_loop = new SequentialStrategy([wss_transport], timeouts);\n var streaming_loop = new SequentialStrategy(\n [xhr_streaming_transport],\n timeouts\n );\n var polling_loop = new SequentialStrategy([xhr_polling_transport], timeouts);\n\n var http_loop = new SequentialStrategy(\n [\n new IfStrategy(\n testSupportsStrategy(streaming_loop),\n new BestConnectedEverStrategy([\n streaming_loop,\n new DelayedStrategy(polling_loop, { delay: 4000 })\n ]),\n polling_loop\n )\n ],\n timeouts\n );\n\n var wsStrategy;\n if (baseOptions.useTLS) {\n wsStrategy = new BestConnectedEverStrategy([\n ws_loop,\n new DelayedStrategy(http_loop, { delay: 2000 })\n ]);\n } else {\n wsStrategy = new BestConnectedEverStrategy([\n ws_loop,\n new DelayedStrategy(wss_loop, { delay: 2000 }),\n new DelayedStrategy(http_loop, { delay: 5000 })\n ]);\n }\n\n return new WebSocketPrioritizedCachedStrategy(\n new FirstConnectedStrategy(\n new IfStrategy(testSupportsStrategy(ws_transport), wsStrategy, http_loop)\n ),\n definedTransports,\n {\n ttl: 1800000,\n timeline: baseOptions.timeline,\n useTLS: baseOptions.useTLS\n }\n );\n};\n\nexport default getDefaultStrategy;\n","import Runtime from 'runtime';\nimport RequestHooks from './request_hooks';\nimport Ajax from './ajax';\nimport { default as EventsDispatcher } from '../events/dispatcher';\n\nconst MAX_BUFFER_LENGTH = 256 * 1024;\n\nexport default class HTTPRequest extends EventsDispatcher {\n hooks: RequestHooks;\n method: string;\n url: string;\n position: number;\n xhr: Ajax;\n unloader: Function;\n\n constructor(hooks: RequestHooks, method: string, url: string) {\n super();\n this.hooks = hooks;\n this.method = method;\n this.url = url;\n }\n\n start(payload?: any) {\n this.position = 0;\n this.xhr = this.hooks.getRequest(this);\n\n this.unloader = () => {\n this.close();\n };\n Runtime.addUnloadListener(this.unloader);\n\n this.xhr.open(this.method, this.url, true);\n\n if (this.xhr.setRequestHeader) {\n this.xhr.setRequestHeader('Content-Type', 'application/json'); // ReactNative doesn't set this header by default.\n }\n this.xhr.send(payload);\n }\n\n close() {\n if (this.unloader) {\n Runtime.removeUnloadListener(this.unloader);\n this.unloader = null;\n }\n if (this.xhr) {\n this.hooks.abortRequest(this.xhr);\n this.xhr = null;\n }\n }\n\n onChunk(status: number, data: any) {\n while (true) {\n var chunk = this.advanceBuffer(data);\n if (chunk) {\n this.emit('chunk', { status: status, data: chunk });\n } else {\n break;\n }\n }\n if (this.isBufferTooLong(data)) {\n this.emit('buffer_too_long');\n }\n }\n\n private advanceBuffer(buffer: any[]): any {\n var unreadData = buffer.slice(this.position);\n var endOfLinePosition = unreadData.indexOf('\\n');\n\n if (endOfLinePosition !== -1) {\n this.position += endOfLinePosition + 1;\n return unreadData.slice(0, endOfLinePosition);\n } else {\n // chunk is not finished yet, don't move the buffer pointer\n return null;\n }\n }\n\n private isBufferTooLong(buffer: any): boolean {\n return this.position === buffer.length && buffer.length > MAX_BUFFER_LENGTH;\n }\n}\n","enum State {\n CONNECTING = 0,\n OPEN = 1,\n CLOSED = 3\n}\n\nexport default State;\n","import URLLocation from './url_location';\nimport State from './state';\nimport Socket from '../socket';\nimport SocketHooks from './socket_hooks';\nimport Util from '../util';\nimport Ajax from './ajax';\nimport HTTPRequest from './http_request';\nimport Runtime from 'runtime';\n\nvar autoIncrement = 1;\n\nclass HTTPSocket implements Socket {\n hooks: SocketHooks;\n session: string;\n location: URLLocation;\n readyState: State;\n stream: HTTPRequest;\n\n onopen: () => void;\n onerror: (error: any) => void;\n onclose: (closeEvent: any) => void;\n onmessage: (message: any) => void;\n onactivity: () => void;\n\n constructor(hooks: SocketHooks, url: string) {\n this.hooks = hooks;\n this.session = randomNumber(1000) + '/' + randomString(8);\n this.location = getLocation(url);\n this.readyState = State.CONNECTING;\n this.openStream();\n }\n\n send(payload: any) {\n return this.sendRaw(JSON.stringify([payload]));\n }\n\n ping() {\n this.hooks.sendHeartbeat(this);\n }\n\n close(code: any, reason: any) {\n this.onClose(code, reason, true);\n }\n\n /** For internal use only */\n sendRaw(payload: any): boolean {\n if (this.readyState === State.OPEN) {\n try {\n Runtime.createSocketRequest(\n 'POST',\n getUniqueURL(getSendURL(this.location, this.session))\n ).start(payload);\n return true;\n } catch (e) {\n return false;\n }\n } else {\n return false;\n }\n }\n\n /** For internal use only */\n reconnect() {\n this.closeStream();\n this.openStream();\n }\n\n /** For internal use only */\n onClose(code, reason, wasClean) {\n this.closeStream();\n this.readyState = State.CLOSED;\n if (this.onclose) {\n this.onclose({\n code: code,\n reason: reason,\n wasClean: wasClean\n });\n }\n }\n\n private onChunk(chunk) {\n if (chunk.status !== 200) {\n return;\n }\n if (this.readyState === State.OPEN) {\n this.onActivity();\n }\n\n var payload;\n var type = chunk.data.slice(0, 1);\n switch (type) {\n case 'o':\n payload = JSON.parse(chunk.data.slice(1) || '{}');\n this.onOpen(payload);\n break;\n case 'a':\n payload = JSON.parse(chunk.data.slice(1) || '[]');\n for (var i = 0; i < payload.length; i++) {\n this.onEvent(payload[i]);\n }\n break;\n case 'm':\n payload = JSON.parse(chunk.data.slice(1) || 'null');\n this.onEvent(payload);\n break;\n case 'h':\n this.hooks.onHeartbeat(this);\n break;\n case 'c':\n payload = JSON.parse(chunk.data.slice(1) || '[]');\n this.onClose(payload[0], payload[1], true);\n break;\n }\n }\n\n private onOpen(options) {\n if (this.readyState === State.CONNECTING) {\n if (options && options.hostname) {\n this.location.base = replaceHost(this.location.base, options.hostname);\n }\n this.readyState = State.OPEN;\n\n if (this.onopen) {\n this.onopen();\n }\n } else {\n this.onClose(1006, 'Server lost session', true);\n }\n }\n\n private onEvent(event) {\n if (this.readyState === State.OPEN && this.onmessage) {\n this.onmessage({ data: event });\n }\n }\n\n private onActivity() {\n if (this.onactivity) {\n this.onactivity();\n }\n }\n\n private onError(error) {\n if (this.onerror) {\n this.onerror(error);\n }\n }\n\n private openStream() {\n this.stream = Runtime.createSocketRequest(\n 'POST',\n getUniqueURL(this.hooks.getReceiveURL(this.location, this.session))\n );\n\n this.stream.bind('chunk', chunk => {\n this.onChunk(chunk);\n });\n this.stream.bind('finished', status => {\n this.hooks.onFinished(this, status);\n });\n this.stream.bind('buffer_too_long', () => {\n this.reconnect();\n });\n\n try {\n this.stream.start();\n } catch (error) {\n Util.defer(() => {\n this.onError(error);\n this.onClose(1006, 'Could not start streaming', false);\n });\n }\n }\n\n private closeStream() {\n if (this.stream) {\n this.stream.unbind_all();\n this.stream.close();\n this.stream = null;\n }\n }\n}\n\nfunction getLocation(url): URLLocation {\n var parts = /([^\\?]*)\\/*(\\??.*)/.exec(url);\n return {\n base: parts[1],\n queryString: parts[2]\n };\n}\n\nfunction getSendURL(url: URLLocation, session: string): string {\n return url.base + '/' + session + '/xhr_send';\n}\n\nfunction getUniqueURL(url: string): string {\n var separator = url.indexOf('?') === -1 ? '?' : '&';\n return url + separator + 't=' + +new Date() + '&n=' + autoIncrement++;\n}\n\nfunction replaceHost(url: string, hostname: string): string {\n var urlParts = /(https?:\\/\\/)([^\\/:]+)((\\/|:)?.*)/.exec(url);\n return urlParts[1] + hostname + urlParts[3];\n}\n\nfunction randomNumber(max: number): number {\n return Runtime.randomInt(max);\n}\n\nfunction randomString(length: number): string {\n var result = [];\n\n for (var i = 0; i < length; i++) {\n result.push(randomNumber(32).toString(32));\n }\n\n return result.join('');\n}\n\nexport default HTTPSocket;\n","import SocketHooks from './socket_hooks';\nimport HTTPSocket from './http_socket';\n\nvar hooks: SocketHooks = {\n getReceiveURL: function(url, session) {\n return url.base + '/' + session + '/xhr_streaming' + url.queryString;\n },\n onHeartbeat: function(socket) {\n socket.sendRaw('[]');\n },\n sendHeartbeat: function(socket) {\n socket.sendRaw('[]');\n },\n onFinished: function(socket, status) {\n socket.onClose(1006, 'Connection interrupted (' + status + ')', false);\n }\n};\n\nexport default hooks;\n","import SocketHooks from './socket_hooks';\nimport URLLocation from './url_location';\nimport HTTPSocket from './http_socket';\n\nvar hooks: SocketHooks = {\n getReceiveURL: function(url: URLLocation, session: string): string {\n return url.base + '/' + session + '/xhr' + url.queryString;\n },\n onHeartbeat: function() {\n // next HTTP request will reset server's activity timer\n },\n sendHeartbeat: function(socket) {\n socket.sendRaw('[]');\n },\n onFinished: function(socket, status) {\n if (status === 200) {\n socket.reconnect();\n } else {\n socket.onClose(1006, 'Connection interrupted (' + status + ')', false);\n }\n }\n};\n\nexport default hooks;\n","import HTTPRequest from 'core/http/http_request';\nimport RequestHooks from 'core/http/request_hooks';\nimport Ajax from 'core/http/ajax';\nimport Runtime from 'runtime';\n\nvar hooks: RequestHooks = {\n getRequest: function(socket: HTTPRequest): Ajax {\n var Constructor = Runtime.getXHRAPI();\n var xhr = new Constructor();\n xhr.onreadystatechange = xhr.onprogress = function() {\n switch (xhr.readyState) {\n case 3:\n if (xhr.responseText && xhr.responseText.length > 0) {\n socket.onChunk(xhr.status, xhr.responseText);\n }\n break;\n case 4:\n // this happens only on errors, never after calling close\n if (xhr.responseText && xhr.responseText.length > 0) {\n socket.onChunk(xhr.status, xhr.responseText);\n }\n socket.emit('finished', xhr.status);\n socket.close();\n break;\n }\n };\n return xhr;\n },\n abortRequest: function(xhr: Ajax) {\n xhr.onreadystatechange = null;\n xhr.abort();\n }\n};\n\nexport default hooks;\n","import * as Collections from 'core/utils/collections';\nimport Transports from 'isomorphic/transports/transports';\nimport TimelineSender from 'core/timeline/timeline_sender';\nimport Ajax from 'core/http/ajax';\nimport getDefaultStrategy from './default_strategy';\nimport TransportsTable from 'core/transports/transports_table';\nimport transportConnectionInitializer from './transports/transport_connection_initializer';\nimport HTTPFactory from './http/http';\n\nvar Isomorphic: any = {\n getDefaultStrategy,\n Transports: Transports,\n transportConnectionInitializer,\n HTTPFactory,\n\n setup(PusherClass): void {\n PusherClass.ready();\n },\n\n getLocalStorage(): any {\n return undefined;\n },\n\n getClientFeatures(): any[] {\n return Collections.keys(\n Collections.filterObject({ ws: Transports.ws }, function(t) {\n return t.isSupported({});\n })\n );\n },\n\n getProtocol(): string {\n return 'http:';\n },\n\n isXHRSupported(): boolean {\n return true;\n },\n\n createSocketRequest(method: string, url: string) {\n if (this.isXHRSupported()) {\n return this.HTTPFactory.createXHR(method, url);\n } else {\n throw 'Cross-origin HTTP requests are not supported';\n }\n },\n\n createXHR(): Ajax {\n var Constructor = this.getXHRAPI();\n return new Constructor();\n },\n\n createWebSocket(url: string): any {\n var Constructor = this.getWebSocketAPI();\n return new Constructor(url);\n },\n\n addUnloadListener(listener: any) {},\n removeUnloadListener(listener: any) {}\n};\n\nexport default Isomorphic;\n","/** Initializes the transport.\n *\n * Fetches resources if needed and then transitions to initialized.\n */\nexport default function() {\n var self = this;\n\n self.timeline.info(\n self.buildTimelineMessage({\n transport: self.name + (self.options.useTLS ? 's' : '')\n })\n );\n\n if (self.hooks.isInitialized()) {\n self.changeState('initialized');\n } else {\n self.onClose();\n }\n}\n","import HTTPRequest from 'core/http/http_request';\nimport HTTPSocket from 'core/http/http_socket';\nimport SocketHooks from 'core/http/socket_hooks';\nimport RequestHooks from 'core/http/request_hooks';\nimport streamingHooks from 'core/http/http_streaming_socket';\nimport pollingHooks from 'core/http/http_polling_socket';\nimport xhrHooks from './http_xhr_request';\nimport HTTPFactory from 'core/http/http_factory';\n\nvar HTTP: HTTPFactory = {\n createStreamingSocket(url: string): HTTPSocket {\n return this.createSocket(streamingHooks, url);\n },\n\n createPollingSocket(url: string): HTTPSocket {\n return this.createSocket(pollingHooks, url);\n },\n\n createSocket(hooks: SocketHooks, url: string): HTTPSocket {\n return new HTTPSocket(hooks, url);\n },\n\n createXHR(method: string, url: string): HTTPRequest {\n return this.createRequest(xhrHooks, method, url);\n },\n\n createRequest(hooks: RequestHooks, method: string, url: string): HTTPRequest {\n return new HTTPRequest(hooks, method, url);\n }\n};\n\nexport default HTTP;\n","import { default as NativeNetInfo } from '@react-native-community/netinfo';\nimport EventsDispatcher from 'core/events/dispatcher';\nimport Util from 'core/util';\nimport Reachability from 'core/reachability';\n\nfunction hasOnlineConnectionState(connectionState): boolean {\n return connectionState.type.toLowerCase() !== 'none';\n}\n\nexport class NetInfo extends EventsDispatcher implements Reachability {\n online: boolean;\n\n constructor() {\n super();\n this.online = true;\n\n NativeNetInfo.fetch().then(connectionState => {\n this.online = hasOnlineConnectionState(connectionState);\n });\n\n NativeNetInfo.addEventListener(connectionState => {\n var isNowOnline = hasOnlineConnectionState(connectionState);\n\n // React Native counts the switch from Wi-Fi to Cellular\n // as a state change. Return if current and previous states\n // are both online/offline\n if (this.online === isNowOnline) return;\n this.online = isNowOnline;\n if (this.online) {\n this.emit('online');\n } else {\n this.emit('offline');\n }\n });\n }\n\n isOnline(): boolean {\n return this.online;\n }\n}\n\nexport var Network = new NetInfo();\n","export enum AuthRequestType {\n UserAuthentication = 'user-authentication',\n ChannelAuthorization = 'channel-authorization'\n}\n\nexport interface ChannelAuthorizationData {\n auth: string;\n channel_data?: string;\n shared_secret?: string;\n}\n\nexport type ChannelAuthorizationCallback = (\n error: Error | null,\n authData: ChannelAuthorizationData | null\n) => void;\n\nexport interface ChannelAuthorizationRequestParams {\n socketId: string;\n channelName: string;\n}\n\nexport interface ChannelAuthorizationHandler {\n (\n params: ChannelAuthorizationRequestParams,\n callback: ChannelAuthorizationCallback\n ): void;\n}\n\nexport interface UserAuthenticationData {\n auth: string;\n user_data: string;\n}\n\nexport type UserAuthenticationCallback = (\n error: Error | null,\n authData: UserAuthenticationData | null\n) => void;\n\nexport interface UserAuthenticationRequestParams {\n socketId: string;\n}\n\nexport interface UserAuthenticationHandler {\n (\n params: UserAuthenticationRequestParams,\n callback: UserAuthenticationCallback\n ): void;\n}\n\nexport type AuthTransportCallback =\n | ChannelAuthorizationCallback\n | UserAuthenticationCallback;\n\nexport interface AuthOptionsT {\n transport: 'ajax' | 'jsonp';\n endpoint: string;\n params?: any;\n headers?: any;\n paramsProvider?: () => any;\n headersProvider?: () => any;\n customHandler?: AuthHandler;\n}\n\nexport declare type UserAuthenticationOptions = AuthOptionsT<\n UserAuthenticationHandler\n>;\nexport declare type ChannelAuthorizationOptions = AuthOptionsT<\n ChannelAuthorizationHandler\n>;\n\nexport interface InternalAuthOptions {\n transport: 'ajax' | 'jsonp';\n endpoint: string;\n params?: any;\n headers?: any;\n paramsProvider?: () => any;\n headersProvider?: () => any;\n}\n","import TimelineSender from 'core/timeline/timeline_sender';\nimport * as Collections from 'core/utils/collections';\nimport Util from 'core/util';\nimport Runtime from 'runtime';\nimport { AuthTransport } from 'core/auth/auth_transports';\nimport AbstractRuntime from 'runtimes/interface';\nimport UrlStore from 'core/utils/url_store';\nimport {\n AuthRequestType,\n AuthTransportCallback,\n InternalAuthOptions\n} from 'core/auth/options';\nimport { HTTPAuthError } from 'core/errors';\n\nconst ajax: AuthTransport = function(\n context: AbstractRuntime,\n query: string,\n authOptions: InternalAuthOptions,\n authRequestType: AuthRequestType,\n callback: AuthTransportCallback\n) {\n const xhr = Runtime.createXHR();\n xhr.open('POST', authOptions.endpoint, true);\n\n // add request headers\n xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');\n for (var headerName in authOptions.headers) {\n xhr.setRequestHeader(headerName, authOptions.headers[headerName]);\n }\n if (authOptions.headersProvider != null) {\n let dynamicHeaders = authOptions.headersProvider();\n for (var headerName in dynamicHeaders) {\n xhr.setRequestHeader(headerName, dynamicHeaders[headerName]);\n }\n }\n\n xhr.onreadystatechange = function() {\n if (xhr.readyState === 4) {\n if (xhr.status === 200) {\n let data;\n let parsed = false;\n\n try {\n data = JSON.parse(xhr.responseText);\n parsed = true;\n } catch (e) {\n callback(\n new HTTPAuthError(\n 200,\n `JSON returned from ${authRequestType.toString()} endpoint was invalid, yet status code was 200. Data was: ${\n xhr.responseText\n }`\n ),\n null\n );\n }\n\n if (parsed) {\n // prevents double execution.\n callback(null, data);\n }\n } else {\n let suffix = '';\n switch (authRequestType) {\n case AuthRequestType.UserAuthentication:\n suffix = UrlStore.buildLogSuffix('authenticationEndpoint');\n break;\n case AuthRequestType.ChannelAuthorization:\n suffix = `Clients must be authorized to join private or presence channels. ${UrlStore.buildLogSuffix(\n 'authorizationEndpoint'\n )}`;\n break;\n }\n callback(\n new HTTPAuthError(\n xhr.status,\n `Unable to retrieve auth string from ${authRequestType.toString()} endpoint - ` +\n `received status: ${xhr.status} from ${authOptions.endpoint}. ${suffix}`\n ),\n null\n );\n }\n }\n };\n\n xhr.send(query);\n return xhr;\n};\n\nexport default ajax;\n","import Logger from 'core/logger';\nimport TimelineSender from 'core/timeline/timeline_sender';\nimport * as Collections from 'core/utils/collections';\nimport Util from 'core/util';\nimport Runtime from 'runtime';\nimport TimelineTransport from 'core/timeline/timeline_transport';\n\nvar getAgent = function(sender: TimelineSender, useTLS: boolean) {\n return function(data: any, callback: Function) {\n var scheme = 'http' + (useTLS ? 's' : '') + '://';\n var url =\n scheme + (sender.host || sender.options.host) + sender.options.path;\n var query = Collections.buildQueryString(data);\n\n url += '/' + 2 + '?' + query;\n\n var xhr = Runtime.createXHR();\n xhr.open('GET', url, true);\n\n xhr.onreadystatechange = function() {\n if (xhr.readyState === 4) {\n let { status, responseText } = xhr;\n if (status !== 200) {\n Logger.debug(\n `TimelineSender Error: received ${status} from stats.pusher.com`\n );\n return;\n }\n\n try {\n var { host } = JSON.parse(responseText);\n } catch (e) {\n Logger.debug(`TimelineSenderError: invalid response ${responseText}`);\n }\n if (host) {\n sender.host = host;\n }\n }\n };\n\n xhr.send();\n };\n};\n\nvar xhr = {\n name: 'xhr',\n getAgent\n};\n\nexport default xhr;\n","import Isomorphic from 'isomorphic/runtime';\nimport Runtime from '../interface';\nimport { Network } from './net_info';\nimport xhrAuth from 'isomorphic/auth/xhr_auth';\nimport { AuthTransports } from 'core/auth/auth_transports';\nimport xhrTimeline from 'isomorphic/timeline/xhr_timeline';\n\n// Very verbose but until unavoidable until\n// TypeScript 2.1, when spread attributes will be\n// supported\nconst {\n getDefaultStrategy,\n Transports,\n setup,\n getProtocol,\n isXHRSupported,\n getLocalStorage,\n createXHR,\n createWebSocket,\n addUnloadListener,\n removeUnloadListener,\n transportConnectionInitializer,\n createSocketRequest,\n HTTPFactory\n} = Isomorphic;\n\nconst ReactNative: Runtime = {\n getDefaultStrategy,\n Transports,\n setup,\n getProtocol,\n isXHRSupported,\n getLocalStorage,\n createXHR,\n createWebSocket,\n addUnloadListener,\n removeUnloadListener,\n transportConnectionInitializer,\n createSocketRequest,\n HTTPFactory,\n\n TimelineTransport: xhrTimeline,\n\n getAuthorizers(): AuthTransports {\n return { ajax: xhrAuth };\n },\n\n getWebSocketAPI() {\n return WebSocket;\n },\n\n getXHRAPI() {\n return XMLHttpRequest;\n },\n\n getNetwork() {\n return Network;\n },\n\n randomInt(max: number): number {\n return Math.floor(Math.random() * max);\n }\n};\n\nexport default ReactNative;\n","enum TimelineLevel {\n ERROR = 3,\n INFO = 6,\n DEBUG = 7\n}\n\nexport default TimelineLevel;\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport { default as Level } from './level';\n\nexport interface TimelineOptions {\n level?: Level;\n limit?: number;\n version?: string;\n cluster?: string;\n features?: string[];\n params?: any;\n}\n\nexport default class Timeline {\n key: string;\n session: number;\n events: any[];\n options: TimelineOptions;\n sent: number;\n uniqueID: number;\n\n constructor(key: string, session: number, options: TimelineOptions) {\n this.key = key;\n this.session = session;\n this.events = [];\n this.options = options || {};\n this.sent = 0;\n this.uniqueID = 0;\n }\n\n log(level, event) {\n if (level <= this.options.level) {\n this.events.push(\n Collections.extend({}, event, { timestamp: Util.now() })\n );\n if (this.options.limit && this.events.length > this.options.limit) {\n this.events.shift();\n }\n }\n }\n\n error(event) {\n this.log(Level.ERROR, event);\n }\n\n info(event) {\n this.log(Level.INFO, event);\n }\n\n debug(event) {\n this.log(Level.DEBUG, event);\n }\n\n isEmpty() {\n return this.events.length === 0;\n }\n\n send(sendfn, callback) {\n var data = Collections.extend(\n {\n session: this.session,\n bundle: this.sent + 1,\n key: this.key,\n lib: 'js',\n version: this.options.version,\n cluster: this.options.cluster,\n features: this.options.features,\n timeline: this.events\n },\n this.options.params\n );\n\n this.events = [];\n sendfn(data, (error, result) => {\n if (!error) {\n this.sent++;\n }\n if (callback) {\n callback(error, result);\n }\n });\n\n return true;\n }\n\n generateUniqueID(): number {\n this.uniqueID++;\n return this.uniqueID;\n }\n}\n","import Factory from '../utils/factory';\nimport Util from '../util';\nimport * as Errors from '../errors';\nimport * as Collections from '../utils/collections';\nimport Strategy from './strategy';\nimport Transport from '../transports/transport';\nimport StrategyOptions from './strategy_options';\nimport Handshake from '../connection/handshake';\n\n/** Provides a strategy interface for transports.\n *\n * @param {String} name\n * @param {Number} priority\n * @param {Class} transport\n * @param {Object} options\n */\nexport default class TransportStrategy implements Strategy {\n name: string;\n priority: number;\n transport: Transport;\n options: StrategyOptions;\n\n constructor(\n name: string,\n priority: number,\n transport: Transport,\n options: StrategyOptions\n ) {\n this.name = name;\n this.priority = priority;\n this.transport = transport;\n this.options = options || {};\n }\n\n /** Returns whether the transport is supported in the browser.\n *\n * @returns {Boolean}\n */\n isSupported(): boolean {\n return this.transport.isSupported({\n useTLS: this.options.useTLS\n });\n }\n\n /** Launches a connection attempt and returns a strategy runner.\n *\n * @param {Function} callback\n * @return {Object} strategy runner\n */\n connect(minPriority: number, callback: Function) {\n if (!this.isSupported()) {\n return failAttempt(new Errors.UnsupportedStrategy(), callback);\n } else if (this.priority < minPriority) {\n return failAttempt(new Errors.TransportPriorityTooLow(), callback);\n }\n\n var connected = false;\n var transport = this.transport.createConnection(\n this.name,\n this.priority,\n this.options.key,\n this.options\n );\n var handshake = null;\n\n var onInitialized = function() {\n transport.unbind('initialized', onInitialized);\n transport.connect();\n };\n var onOpen = function() {\n handshake = Factory.createHandshake(transport, function(result) {\n connected = true;\n unbindListeners();\n callback(null, result);\n });\n };\n var onError = function(error) {\n unbindListeners();\n callback(error);\n };\n var onClosed = function() {\n unbindListeners();\n var serializedTransport;\n\n // The reason for this try/catch block is that on React Native\n // the WebSocket object is circular. Therefore transport.socket will\n // throw errors upon stringification. Collections.safeJSONStringify\n // discards circular references when serializing.\n serializedTransport = Collections.safeJSONStringify(transport);\n callback(new Errors.TransportClosed(serializedTransport));\n };\n\n var unbindListeners = function() {\n transport.unbind('initialized', onInitialized);\n transport.unbind('open', onOpen);\n transport.unbind('error', onError);\n transport.unbind('closed', onClosed);\n };\n\n transport.bind('initialized', onInitialized);\n transport.bind('open', onOpen);\n transport.bind('error', onError);\n transport.bind('closed', onClosed);\n\n // connect will be called automatically after initialization\n transport.initialize();\n\n return {\n abort: () => {\n if (connected) {\n return;\n }\n unbindListeners();\n if (handshake) {\n handshake.close();\n } else {\n transport.close();\n }\n },\n forceMinPriority: p => {\n if (connected) {\n return;\n }\n if (this.priority < p) {\n if (handshake) {\n handshake.close();\n } else {\n transport.close();\n }\n }\n }\n };\n }\n}\n\nfunction failAttempt(error: Error, callback: Function) {\n Util.defer(function() {\n callback(error);\n });\n return {\n abort: function() {},\n forceMinPriority: function() {}\n };\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport TransportManager from '../transports/transport_manager';\nimport * as Errors from '../errors';\nimport Strategy from './strategy';\nimport TransportStrategy from './transport_strategy';\nimport StrategyOptions from '../strategies/strategy_options';\nimport { Config } from '../config';\nimport Runtime from 'runtime';\n\nconst { Transports } = Runtime;\n\nexport var defineTransport = function(\n config: Config,\n name: string,\n type: string,\n priority: number,\n options: StrategyOptions,\n manager?: TransportManager\n): Strategy {\n var transportClass = Transports[type];\n if (!transportClass) {\n throw new Errors.UnsupportedTransport(type);\n }\n\n var enabled =\n (!config.enabledTransports ||\n Collections.arrayIndexOf(config.enabledTransports, name) !== -1) &&\n (!config.disabledTransports ||\n Collections.arrayIndexOf(config.disabledTransports, name) === -1);\n\n var transport;\n if (enabled) {\n options = Object.assign(\n { ignoreNullOrigin: config.ignoreNullOrigin },\n options\n );\n\n transport = new TransportStrategy(\n name,\n priority,\n manager ? manager.getAssistant(transportClass) : transportClass,\n options\n );\n } else {\n transport = UnsupportedStrategy;\n }\n\n return transport;\n};\n\nvar UnsupportedStrategy: Strategy = {\n isSupported: function() {\n return false;\n },\n connect: function(_, callback) {\n var deferred = Util.defer(function() {\n callback(new Errors.UnsupportedStrategy());\n });\n return {\n abort: function() {\n deferred.ensureAborted();\n },\n forceMinPriority: function() {}\n };\n }\n};\n","import {\n UserAuthenticationCallback,\n InternalAuthOptions,\n UserAuthenticationHandler,\n UserAuthenticationRequestParams,\n AuthRequestType\n} from './options';\n\nimport Runtime from 'runtime';\n\nconst composeChannelQuery = (\n params: UserAuthenticationRequestParams,\n authOptions: InternalAuthOptions\n) => {\n var query = 'socket_id=' + encodeURIComponent(params.socketId);\n\n for (var key in authOptions.params) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(authOptions.params[key]);\n }\n\n if (authOptions.paramsProvider != null) {\n let dynamicParams = authOptions.paramsProvider();\n for (var key in dynamicParams) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(dynamicParams[key]);\n }\n }\n\n return query;\n};\n\nconst UserAuthenticator = (\n authOptions: InternalAuthOptions\n): UserAuthenticationHandler => {\n if (typeof Runtime.getAuthorizers()[authOptions.transport] === 'undefined') {\n throw `'${authOptions.transport}' is not a recognized auth transport`;\n }\n\n return (\n params: UserAuthenticationRequestParams,\n callback: UserAuthenticationCallback\n ) => {\n const query = composeChannelQuery(params, authOptions);\n\n Runtime.getAuthorizers()[authOptions.transport](\n Runtime,\n query,\n authOptions,\n AuthRequestType.UserAuthentication,\n callback\n );\n };\n};\n\nexport default UserAuthenticator;\n","import {\n AuthRequestType,\n InternalAuthOptions,\n ChannelAuthorizationHandler,\n ChannelAuthorizationRequestParams,\n ChannelAuthorizationCallback\n} from './options';\n\nimport Runtime from 'runtime';\n\nconst composeChannelQuery = (\n params: ChannelAuthorizationRequestParams,\n authOptions: InternalAuthOptions\n) => {\n var query = 'socket_id=' + encodeURIComponent(params.socketId);\n\n query += '&channel_name=' + encodeURIComponent(params.channelName);\n\n for (var key in authOptions.params) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(authOptions.params[key]);\n }\n\n if (authOptions.paramsProvider != null) {\n let dynamicParams = authOptions.paramsProvider();\n for (var key in dynamicParams) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(dynamicParams[key]);\n }\n }\n\n return query;\n};\n\nconst ChannelAuthorizer = (\n authOptions: InternalAuthOptions\n): ChannelAuthorizationHandler => {\n if (typeof Runtime.getAuthorizers()[authOptions.transport] === 'undefined') {\n throw `'${authOptions.transport}' is not a recognized auth transport`;\n }\n\n return (\n params: ChannelAuthorizationRequestParams,\n callback: ChannelAuthorizationCallback\n ) => {\n const query = composeChannelQuery(params, authOptions);\n\n Runtime.getAuthorizers()[authOptions.transport](\n Runtime,\n query,\n authOptions,\n AuthRequestType.ChannelAuthorization,\n callback\n );\n };\n};\n\nexport default ChannelAuthorizer;\n","import { Options } from './options';\nimport Defaults from './defaults';\nimport {\n ChannelAuthorizationHandler,\n UserAuthenticationHandler,\n ChannelAuthorizationOptions\n} from './auth/options';\nimport UserAuthenticator from './auth/user_authenticator';\nimport ChannelAuthorizer from './auth/channel_authorizer';\nimport { ChannelAuthorizerProxy } from './auth/deprecated_channel_authorizer';\nimport Runtime from 'runtime';\nimport * as nacl from 'tweetnacl';\n\nexport type AuthTransport = 'ajax' | 'jsonp';\nexport type Transport =\n | 'ws'\n | 'wss'\n | 'xhr_streaming'\n | 'xhr_polling'\n | 'sockjs';\n\nexport interface Config {\n // these are all 'required' config parameters, it's not necessary for the user\n // to set them, but they have configured defaults.\n activityTimeout: number;\n enableStats: boolean;\n httpHost: string;\n httpPath: string;\n httpPort: number;\n httpsPort: number;\n pongTimeout: number;\n statsHost: string;\n unavailableTimeout: number;\n useTLS: boolean;\n wsHost: string;\n wsPath: string;\n wsPort: number;\n wssPort: number;\n userAuthenticator: UserAuthenticationHandler;\n channelAuthorizer: ChannelAuthorizationHandler;\n\n // these are all optional parameters or overrrides. The customer can set these\n // but it's not strictly necessary\n forceTLS?: boolean;\n cluster?: string;\n disabledTransports?: Transport[];\n enabledTransports?: Transport[];\n ignoreNullOrigin?: boolean;\n nacl?: nacl;\n timelineParams?: any;\n}\n\n// getConfig mainly sets the defaults for the options that are not provided\nexport function getConfig(opts: Options, pusher): Config {\n let config: Config = {\n activityTimeout: opts.activityTimeout || Defaults.activityTimeout,\n cluster: opts.cluster,\n httpPath: opts.httpPath || Defaults.httpPath,\n httpPort: opts.httpPort || Defaults.httpPort,\n httpsPort: opts.httpsPort || Defaults.httpsPort,\n pongTimeout: opts.pongTimeout || Defaults.pongTimeout,\n statsHost: opts.statsHost || Defaults.stats_host,\n unavailableTimeout: opts.unavailableTimeout || Defaults.unavailableTimeout,\n wsPath: opts.wsPath || Defaults.wsPath,\n wsPort: opts.wsPort || Defaults.wsPort,\n wssPort: opts.wssPort || Defaults.wssPort,\n\n enableStats: getEnableStatsConfig(opts),\n httpHost: getHttpHost(opts),\n useTLS: shouldUseTLS(opts),\n wsHost: getWebsocketHost(opts),\n\n userAuthenticator: buildUserAuthenticator(opts),\n channelAuthorizer: buildChannelAuthorizer(opts, pusher)\n };\n\n if ('disabledTransports' in opts)\n config.disabledTransports = opts.disabledTransports;\n if ('enabledTransports' in opts)\n config.enabledTransports = opts.enabledTransports;\n if ('ignoreNullOrigin' in opts)\n config.ignoreNullOrigin = opts.ignoreNullOrigin;\n if ('timelineParams' in opts) config.timelineParams = opts.timelineParams;\n if ('nacl' in opts) {\n config.nacl = opts.nacl;\n }\n\n return config;\n}\n\nfunction getHttpHost(opts: Options): string {\n if (opts.httpHost) {\n return opts.httpHost;\n }\n if (opts.cluster) {\n return `sockjs-${opts.cluster}.pusher.com`;\n }\n return Defaults.httpHost;\n}\n\nfunction getWebsocketHost(opts: Options): string {\n if (opts.wsHost) {\n return opts.wsHost;\n }\n return getWebsocketHostFromCluster(opts.cluster);\n}\n\nfunction getWebsocketHostFromCluster(cluster: string): string {\n return `ws-${cluster}.pusher.com`;\n}\n\nfunction shouldUseTLS(opts: Options): boolean {\n if (Runtime.getProtocol() === 'https:') {\n return true;\n } else if (opts.forceTLS === false) {\n return false;\n }\n return true;\n}\n\n// if enableStats is set take the value\n// if disableStats is set take the inverse\n// otherwise default to false\nfunction getEnableStatsConfig(opts: Options): boolean {\n if ('enableStats' in opts) {\n return opts.enableStats;\n }\n if ('disableStats' in opts) {\n return !opts.disableStats;\n }\n return false;\n}\n\nfunction buildUserAuthenticator(opts: Options): UserAuthenticationHandler {\n const userAuthentication = {\n ...Defaults.userAuthentication,\n ...opts.userAuthentication\n };\n if (\n 'customHandler' in userAuthentication &&\n userAuthentication['customHandler'] != null\n ) {\n return userAuthentication['customHandler'];\n }\n\n return UserAuthenticator(userAuthentication);\n}\n\nfunction buildChannelAuth(opts: Options, pusher): ChannelAuthorizationOptions {\n let channelAuthorization: ChannelAuthorizationOptions;\n if ('channelAuthorization' in opts) {\n channelAuthorization = {\n ...Defaults.channelAuthorization,\n ...opts.channelAuthorization\n };\n } else {\n channelAuthorization = {\n transport: opts.authTransport || Defaults.authTransport,\n endpoint: opts.authEndpoint || Defaults.authEndpoint\n };\n if ('auth' in opts) {\n if ('params' in opts.auth) channelAuthorization.params = opts.auth.params;\n if ('headers' in opts.auth)\n channelAuthorization.headers = opts.auth.headers;\n }\n if ('authorizer' in opts)\n channelAuthorization.customHandler = ChannelAuthorizerProxy(\n pusher,\n channelAuthorization,\n opts.authorizer\n );\n }\n return channelAuthorization;\n}\n\nfunction buildChannelAuthorizer(\n opts: Options,\n pusher\n): ChannelAuthorizationHandler {\n const channelAuthorization = buildChannelAuth(opts, pusher);\n if (\n 'customHandler' in channelAuthorization &&\n channelAuthorization['customHandler'] != null\n ) {\n return channelAuthorization['customHandler'];\n }\n\n return ChannelAuthorizer(channelAuthorization);\n}\n","import Channel from '../channels/channel';\nimport {\n ChannelAuthorizationCallback,\n ChannelAuthorizationHandler,\n ChannelAuthorizationRequestParams,\n InternalAuthOptions\n} from './options';\n\nexport interface DeprecatedChannelAuthorizer {\n authorize(socketId: string, callback: ChannelAuthorizationCallback): void;\n}\n\nexport interface ChannelAuthorizerGenerator {\n (\n channel: Channel,\n options: DeprecatedAuthorizerOptions\n ): DeprecatedChannelAuthorizer;\n}\n\nexport interface DeprecatedAuthOptions {\n params?: any;\n headers?: any;\n}\n\nexport interface DeprecatedAuthorizerOptions {\n authTransport: 'ajax' | 'jsonp';\n authEndpoint: string;\n auth?: DeprecatedAuthOptions;\n}\n\nexport const ChannelAuthorizerProxy = (\n pusher,\n authOptions: InternalAuthOptions,\n channelAuthorizerGenerator: ChannelAuthorizerGenerator\n): ChannelAuthorizationHandler => {\n const deprecatedAuthorizerOptions: DeprecatedAuthorizerOptions = {\n authTransport: authOptions.transport,\n authEndpoint: authOptions.endpoint,\n auth: {\n params: authOptions.params,\n headers: authOptions.headers\n }\n };\n return (\n params: ChannelAuthorizationRequestParams,\n callback: ChannelAuthorizationCallback\n ) => {\n const channel = pusher.channel(params.channelName);\n // This line creates a new channel authorizer every time.\n // In the past, this was only done once per channel and reused.\n // We can do that again if we want to keep this behavior intact.\n const channelAuthorizer: DeprecatedChannelAuthorizer = channelAuthorizerGenerator(\n channel,\n deprecatedAuthorizerOptions\n );\n channelAuthorizer.authorize(params.socketId, callback);\n };\n};\n","import Logger from './logger';\nimport Pusher from './pusher';\nimport EventsDispatcher from './events/dispatcher';\n\nexport default class WatchlistFacade extends EventsDispatcher {\n private pusher: Pusher;\n\n public constructor(pusher: Pusher) {\n super(function(eventName, data) {\n Logger.debug(`No callbacks on watchlist events for ${eventName}`);\n });\n\n this.pusher = pusher;\n this.bindWatchlistInternalEvent();\n }\n\n handleEvent(pusherEvent) {\n pusherEvent.data.events.forEach(watchlistEvent => {\n this.emit(watchlistEvent.name, watchlistEvent);\n });\n }\n\n private bindWatchlistInternalEvent() {\n this.pusher.connection.bind('message', pusherEvent => {\n var eventName = pusherEvent.event;\n if (eventName === 'pusher_internal:watchlist_events') {\n this.handleEvent(pusherEvent);\n }\n });\n }\n}\n","function flatPromise() {\n let resolve, reject;\n const promise = new Promise((res, rej) => {\n resolve = res;\n reject = rej;\n });\n return { promise, resolve, reject };\n}\n\nexport default flatPromise;\n","import Pusher from './pusher';\nimport Logger from './logger';\nimport {\n UserAuthenticationData,\n UserAuthenticationCallback\n} from './auth/options';\nimport Channel from './channels/channel';\nimport WatchlistFacade from './watchlist';\nimport EventsDispatcher from './events/dispatcher';\nimport flatPromise from './utils/flat_promise';\n\nexport default class UserFacade extends EventsDispatcher {\n pusher: Pusher;\n signin_requested: boolean = false;\n user_data: any = null;\n serverToUserChannel: Channel = null;\n signinDonePromise: Promise = null;\n watchlist: WatchlistFacade;\n private _signinDoneResolve: Function = null;\n\n public constructor(pusher: Pusher) {\n super(function(eventName, data) {\n Logger.debug('No callbacks on user for ' + eventName);\n });\n this.pusher = pusher;\n this.pusher.connection.bind('state_change', ({ previous, current }) => {\n if (previous !== 'connected' && current === 'connected') {\n this._signin();\n }\n if (previous === 'connected' && current !== 'connected') {\n this._cleanup();\n this._newSigninPromiseIfNeeded();\n }\n });\n\n this.watchlist = new WatchlistFacade(pusher);\n\n this.pusher.connection.bind('message', event => {\n var eventName = event.event;\n if (eventName === 'pusher:signin_success') {\n this._onSigninSuccess(event.data);\n }\n if (\n this.serverToUserChannel &&\n this.serverToUserChannel.name === event.channel\n ) {\n this.serverToUserChannel.handleEvent(event);\n }\n });\n }\n\n public signin() {\n if (this.signin_requested) {\n return;\n }\n\n this.signin_requested = true;\n this._signin();\n }\n\n private _signin() {\n if (!this.signin_requested) {\n return;\n }\n\n this._newSigninPromiseIfNeeded();\n\n if (this.pusher.connection.state !== 'connected') {\n // Signin will be attempted when the connection is connected\n return;\n }\n\n this.pusher.config.userAuthenticator(\n {\n socketId: this.pusher.connection.socket_id\n },\n this._onAuthorize\n );\n }\n\n private _onAuthorize: UserAuthenticationCallback = (\n err,\n authData: UserAuthenticationData\n ) => {\n if (err) {\n Logger.warn(`Error during signin: ${err}`);\n this._cleanup();\n return;\n }\n\n this.pusher.send_event('pusher:signin', {\n auth: authData.auth,\n user_data: authData.user_data\n });\n\n // Later when we get pusher:singin_success event, the user will be marked as signed in\n };\n\n private _onSigninSuccess(data: any) {\n try {\n this.user_data = JSON.parse(data.user_data);\n } catch (e) {\n Logger.error(`Failed parsing user data after signin: ${data.user_data}`);\n this._cleanup();\n return;\n }\n\n if (typeof this.user_data.id !== 'string' || this.user_data.id === '') {\n Logger.error(\n `user_data doesn't contain an id. user_data: ${this.user_data}`\n );\n this._cleanup();\n return;\n }\n\n // Signin succeeded\n this._signinDoneResolve();\n this._subscribeChannels();\n }\n\n private _subscribeChannels() {\n const ensure_subscribed = channel => {\n if (channel.subscriptionPending && channel.subscriptionCancelled) {\n channel.reinstateSubscription();\n } else if (\n !channel.subscriptionPending &&\n this.pusher.connection.state === 'connected'\n ) {\n channel.subscribe();\n }\n };\n\n this.serverToUserChannel = new Channel(\n `#server-to-user-${this.user_data.id}`,\n this.pusher\n );\n this.serverToUserChannel.bind_global((eventName, data) => {\n if (\n eventName.indexOf('pusher_internal:') === 0 ||\n eventName.indexOf('pusher:') === 0\n ) {\n // ignore internal events\n return;\n }\n this.emit(eventName, data);\n });\n ensure_subscribed(this.serverToUserChannel);\n }\n\n private _cleanup() {\n this.user_data = null;\n if (this.serverToUserChannel) {\n this.serverToUserChannel.unbind_all();\n this.serverToUserChannel.disconnect();\n this.serverToUserChannel = null;\n }\n\n if (this.signin_requested) {\n // If signin is in progress and cleanup is called,\n // Mark the current signin process as done.\n this._signinDoneResolve();\n }\n }\n\n private _newSigninPromiseIfNeeded() {\n if (!this.signin_requested) {\n return;\n }\n\n // If there is a promise and it is not resolved, return without creating a new one.\n if (this.signinDonePromise && !(this.signinDonePromise as any).done) {\n return;\n }\n\n // This promise is never rejected.\n // It gets resolved when the signin process is done whether it failed or succeeded\n const { promise, resolve, reject: _ } = flatPromise();\n (promise as any).done = false;\n const setDone = () => {\n (promise as any).done = true;\n };\n promise.then(setDone).catch(setDone);\n this.signinDonePromise = promise;\n this._signinDoneResolve = resolve;\n }\n}\n","import AbstractRuntime from '../runtimes/interface';\nimport Runtime from 'runtime';\nimport * as Collections from './utils/collections';\nimport Channels from './channels/channels';\nimport Channel from './channels/channel';\nimport { default as EventsDispatcher } from './events/dispatcher';\nimport Timeline from './timeline/timeline';\nimport TimelineSender from './timeline/timeline_sender';\nimport TimelineLevel from './timeline/level';\nimport { defineTransport } from './strategies/strategy_builder';\nimport ConnectionManager from './connection/connection_manager';\nimport { PeriodicTimer } from './utils/timers';\nimport Defaults from './defaults';\nimport Logger from './logger';\nimport Factory from './utils/factory';\nimport { Options, ClusterOptions, validateOptions } from './options';\nimport { Config, getConfig } from './config';\nimport StrategyOptions from './strategies/strategy_options';\nimport UserFacade from './user';\n\nexport default class Pusher {\n /* STATIC PROPERTIES */\n static instances: Pusher[] = [];\n static isReady: boolean = false;\n static logToConsole: boolean = false;\n\n // for jsonp\n static Runtime: AbstractRuntime = Runtime;\n static ScriptReceivers: any = (Runtime).ScriptReceivers;\n static DependenciesReceivers: any = (Runtime).DependenciesReceivers;\n static auth_callbacks: any = (Runtime).auth_callbacks;\n\n static ready() {\n Pusher.isReady = true;\n for (var i = 0, l = Pusher.instances.length; i < l; i++) {\n Pusher.instances[i].connect();\n }\n }\n\n static log: (message: any) => void;\n\n private static getClientFeatures(): string[] {\n return Collections.keys(\n Collections.filterObject({ ws: Runtime.Transports.ws }, function(t) {\n return t.isSupported({});\n })\n );\n }\n\n /* INSTANCE PROPERTIES */\n key: string;\n options: Options;\n config: Config;\n channels: Channels;\n global_emitter: EventsDispatcher;\n sessionID: number;\n timeline: Timeline;\n timelineSender: TimelineSender;\n connection: ConnectionManager;\n timelineSenderTimer: PeriodicTimer;\n user: UserFacade;\n constructor(app_key: string, options: Options) {\n checkAppKey(app_key);\n validateOptions(options);\n this.key = app_key;\n this.config = getConfig(options, this);\n\n this.channels = Factory.createChannels();\n this.global_emitter = new EventsDispatcher();\n this.sessionID = Runtime.randomInt(1000000000);\n\n this.timeline = new Timeline(this.key, this.sessionID, {\n cluster: this.config.cluster,\n features: Pusher.getClientFeatures(),\n params: this.config.timelineParams || {},\n limit: 50,\n level: TimelineLevel.INFO,\n version: Defaults.VERSION\n });\n if (this.config.enableStats) {\n this.timelineSender = Factory.createTimelineSender(this.timeline, {\n host: this.config.statsHost,\n path: '/timeline/v2/' + Runtime.TimelineTransport.name\n });\n }\n\n var getStrategy = (options: StrategyOptions) => {\n return Runtime.getDefaultStrategy(this.config, options, defineTransport);\n };\n\n this.connection = Factory.createConnectionManager(this.key, {\n getStrategy: getStrategy,\n timeline: this.timeline,\n activityTimeout: this.config.activityTimeout,\n pongTimeout: this.config.pongTimeout,\n unavailableTimeout: this.config.unavailableTimeout,\n useTLS: Boolean(this.config.useTLS)\n });\n\n this.connection.bind('connected', () => {\n this.subscribeAll();\n if (this.timelineSender) {\n this.timelineSender.send(this.connection.isUsingTLS());\n }\n });\n\n this.connection.bind('message', event => {\n var eventName = event.event;\n var internal = eventName.indexOf('pusher_internal:') === 0;\n if (event.channel) {\n var channel = this.channel(event.channel);\n if (channel) {\n channel.handleEvent(event);\n }\n }\n // Emit globally [deprecated]\n if (!internal) {\n this.global_emitter.emit(event.event, event.data);\n }\n });\n this.connection.bind('connecting', () => {\n this.channels.disconnect();\n });\n this.connection.bind('disconnected', () => {\n this.channels.disconnect();\n });\n this.connection.bind('error', err => {\n Logger.warn(err);\n });\n\n Pusher.instances.push(this);\n this.timeline.info({ instances: Pusher.instances.length });\n\n this.user = new UserFacade(this);\n\n if (Pusher.isReady) {\n this.connect();\n }\n }\n\n /**\n * Allows you to switch Pusher cluster without\n * losing all the channels/subscription binding\n * as this is internally managed by the SDK.\n */\n switchCluster(options: ClusterOptions) {\n const { appKey, cluster } = options;\n this.key = appKey;\n this.options = { ...this.options, cluster };\n this.config = getConfig(this.options, this);\n this.connection.switchCluster(this.key);\n }\n\n channel(name: string): Channel {\n return this.channels.find(name);\n }\n\n allChannels(): Channel[] {\n return this.channels.all();\n }\n\n connect() {\n this.connection.connect();\n\n if (this.timelineSender) {\n if (!this.timelineSenderTimer) {\n var usingTLS = this.connection.isUsingTLS();\n var timelineSender = this.timelineSender;\n this.timelineSenderTimer = new PeriodicTimer(60000, function() {\n timelineSender.send(usingTLS);\n });\n }\n }\n }\n\n disconnect() {\n this.connection.disconnect();\n\n if (this.timelineSenderTimer) {\n this.timelineSenderTimer.ensureAborted();\n this.timelineSenderTimer = null;\n }\n }\n\n bind(event_name: string, callback: Function, context?: any): Pusher {\n this.global_emitter.bind(event_name, callback, context);\n return this;\n }\n\n unbind(event_name?: string, callback?: Function, context?: any): Pusher {\n this.global_emitter.unbind(event_name, callback, context);\n return this;\n }\n\n bind_global(callback: Function): Pusher {\n this.global_emitter.bind_global(callback);\n return this;\n }\n\n unbind_global(callback?: Function): Pusher {\n this.global_emitter.unbind_global(callback);\n return this;\n }\n\n unbind_all(callback?: Function): Pusher {\n this.global_emitter.unbind_all();\n return this;\n }\n\n subscribeAll() {\n var channelName;\n for (channelName in this.channels.channels) {\n if (this.channels.channels.hasOwnProperty(channelName)) {\n this.subscribe(channelName);\n }\n }\n }\n\n subscribe(channel_name: string) {\n var channel = this.channels.add(channel_name, this);\n if (channel.subscriptionPending && channel.subscriptionCancelled) {\n channel.reinstateSubscription();\n } else if (\n !channel.subscriptionPending &&\n this.connection.state === 'connected'\n ) {\n channel.subscribe();\n }\n return channel;\n }\n\n unsubscribe(channel_name: string) {\n var channel = this.channels.find(channel_name);\n if (channel && channel.subscriptionPending) {\n channel.cancelSubscription();\n } else {\n channel = this.channels.remove(channel_name);\n if (channel && channel.subscribed) {\n channel.unsubscribe();\n }\n }\n }\n\n send_event(event_name: string, data: any, channel?: string) {\n return this.connection.send_event(event_name, data, channel);\n }\n\n shouldUseTLS(): boolean {\n return this.config.useTLS;\n }\n\n signin() {\n this.user.signin();\n }\n}\n\nfunction checkAppKey(key) {\n if (key === null || key === undefined) {\n throw 'You must pass your app key when you instantiate Pusher.';\n }\n}\n\nRuntime.setup(Pusher);\n","var g;\n\n// This works in non-strict mode\ng = (function() {\n\treturn this;\n})();\n\ntry {\n\t// This works if eval is allowed (see CSP)\n\tg = g || new Function(\"return this\")();\n} catch (e) {\n\t// This works if the window reference is available\n\tif (typeof window === \"object\") g = window;\n}\n\n// g can still be undefined, but nothing to do about it...\n// We return undefined, instead of nothing here, so it's\n// easier to handle this case. if(!global) { ...}\n\nmodule.exports = g;\n","import ConnectionManager from './connection/connection_manager';\nimport {\n ChannelAuthorizationOptions,\n UserAuthenticationOptions\n} from './auth/options';\nimport {\n ChannelAuthorizerGenerator,\n DeprecatedAuthOptions\n} from './auth/deprecated_channel_authorizer';\nimport { AuthTransport, Transport } from './config';\nimport * as nacl from 'tweetnacl';\nimport Logger from './logger';\n\nexport interface Options {\n activityTimeout?: number;\n\n auth?: DeprecatedAuthOptions; // DEPRECATED use channelAuthorization instead\n authEndpoint?: string; // DEPRECATED use channelAuthorization instead\n authTransport?: AuthTransport; // DEPRECATED use channelAuthorization instead\n authorizer?: ChannelAuthorizerGenerator; // DEPRECATED use channelAuthorization instead\n\n channelAuthorization?: ChannelAuthorizationOptions;\n userAuthentication?: UserAuthenticationOptions;\n\n cluster: string;\n enableStats?: boolean;\n disableStats?: boolean;\n disabledTransports?: Transport[];\n enabledTransports?: Transport[];\n forceTLS?: boolean;\n httpHost?: string;\n httpPath?: string;\n httpPort?: number;\n httpsPort?: number;\n ignoreNullOrigin?: boolean;\n nacl?: nacl;\n pongTimeout?: number;\n statsHost?: string;\n timelineParams?: any;\n unavailableTimeout?: number;\n wsHost?: string;\n wsPath?: string;\n wsPort?: number;\n wssPort?: number;\n}\n\nexport interface ClusterOptions {\n appKey: string;\n cluster: string;\n}\n\nexport function validateOptions(options) {\n if (options == null) {\n throw 'You must pass an options object';\n }\n if (options.cluster == null) {\n throw 'Options object must provide a cluster';\n }\n if ('disableStats' in options) {\n Logger.warn(\n 'The disableStats option is deprecated in favor of enableStats'\n );\n }\n}\n","// Copyright (C) 2016 Dmitry Chestnykh\n// MIT License. See LICENSE file for details.\n\n/**\n * Package base64 implements Base64 encoding and decoding.\n */\n\n// Invalid character used in decoding to indicate\n// that the character to decode is out of range of\n// alphabet and cannot be decoded.\nconst INVALID_BYTE = 256;\n\n/**\n * Implements standard Base64 encoding.\n *\n * Operates in constant time.\n */\nexport class Coder {\n // TODO(dchest): methods to encode chunk-by-chunk.\n\n constructor(private _paddingCharacter = \"=\") { }\n\n encodedLength(length: number): number {\n if (!this._paddingCharacter) {\n return (length * 8 + 5) / 6 | 0;\n }\n return (length + 2) / 3 * 4 | 0;\n }\n\n encode(data: Uint8Array): string {\n let out = \"\";\n\n let i = 0;\n for (; i < data.length - 2; i += 3) {\n let c = (data[i] << 16) | (data[i + 1] << 8) | (data[i + 2]);\n out += this._encodeByte((c >>> 3 * 6) & 63);\n out += this._encodeByte((c >>> 2 * 6) & 63);\n out += this._encodeByte((c >>> 1 * 6) & 63);\n out += this._encodeByte((c >>> 0 * 6) & 63);\n }\n\n const left = data.length - i;\n if (left > 0) {\n let c = (data[i] << 16) | (left === 2 ? data[i + 1] << 8 : 0);\n out += this._encodeByte((c >>> 3 * 6) & 63);\n out += this._encodeByte((c >>> 2 * 6) & 63);\n if (left === 2) {\n out += this._encodeByte((c >>> 1 * 6) & 63);\n } else {\n out += this._paddingCharacter || \"\";\n }\n out += this._paddingCharacter || \"\";\n }\n\n return out;\n }\n\n maxDecodedLength(length: number): number {\n if (!this._paddingCharacter) {\n return (length * 6 + 7) / 8 | 0;\n }\n return length / 4 * 3 | 0;\n }\n\n decodedLength(s: string): number {\n return this.maxDecodedLength(s.length - this._getPaddingLength(s));\n }\n\n decode(s: string): Uint8Array {\n if (s.length === 0) {\n return new Uint8Array(0);\n }\n const paddingLength = this._getPaddingLength(s);\n const length = s.length - paddingLength;\n const out = new Uint8Array(this.maxDecodedLength(length));\n let op = 0;\n let i = 0;\n let haveBad = 0;\n let v0 = 0, v1 = 0, v2 = 0, v3 = 0;\n for (; i < length - 4; i += 4) {\n v0 = this._decodeChar(s.charCodeAt(i + 0));\n v1 = this._decodeChar(s.charCodeAt(i + 1));\n v2 = this._decodeChar(s.charCodeAt(i + 2));\n v3 = this._decodeChar(s.charCodeAt(i + 3));\n out[op++] = (v0 << 2) | (v1 >>> 4);\n out[op++] = (v1 << 4) | (v2 >>> 2);\n out[op++] = (v2 << 6) | v3;\n haveBad |= v0 & INVALID_BYTE;\n haveBad |= v1 & INVALID_BYTE;\n haveBad |= v2 & INVALID_BYTE;\n haveBad |= v3 & INVALID_BYTE;\n }\n if (i < length - 1) {\n v0 = this._decodeChar(s.charCodeAt(i));\n v1 = this._decodeChar(s.charCodeAt(i + 1));\n out[op++] = (v0 << 2) | (v1 >>> 4);\n haveBad |= v0 & INVALID_BYTE;\n haveBad |= v1 & INVALID_BYTE;\n }\n if (i < length - 2) {\n v2 = this._decodeChar(s.charCodeAt(i + 2));\n out[op++] = (v1 << 4) | (v2 >>> 2);\n haveBad |= v2 & INVALID_BYTE;\n }\n if (i < length - 3) {\n v3 = this._decodeChar(s.charCodeAt(i + 3));\n out[op++] = (v2 << 6) | v3;\n haveBad |= v3 & INVALID_BYTE;\n }\n if (haveBad !== 0) {\n throw new Error(\"Base64Coder: incorrect characters for decoding\");\n }\n return out;\n }\n\n // Standard encoding have the following encoded/decoded ranges,\n // which we need to convert between.\n //\n // ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 0123456789 + /\n // Index: 0 - 25 26 - 51 52 - 61 62 63\n // ASCII: 65 - 90 97 - 122 48 - 57 43 47\n //\n\n // Encode 6 bits in b into a new character.\n protected _encodeByte(b: number): string {\n // Encoding uses constant time operations as follows:\n //\n // 1. Define comparison of A with B using (A - B) >>> 8:\n // if A > B, then result is positive integer\n // if A <= B, then result is 0\n //\n // 2. Define selection of C or 0 using bitwise AND: X & C:\n // if X == 0, then result is 0\n // if X != 0, then result is C\n //\n // 3. Start with the smallest comparison (b >= 0), which is always\n // true, so set the result to the starting ASCII value (65).\n //\n // 4. Continue comparing b to higher ASCII values, and selecting\n // zero if comparison isn't true, otherwise selecting a value\n // to add to result, which:\n //\n // a) undoes the previous addition\n // b) provides new value to add\n //\n let result = b;\n // b >= 0\n result += 65;\n // b > 25\n result += ((25 - b) >>> 8) & ((0 - 65) - 26 + 97);\n // b > 51\n result += ((51 - b) >>> 8) & ((26 - 97) - 52 + 48);\n // b > 61\n result += ((61 - b) >>> 8) & ((52 - 48) - 62 + 43);\n // b > 62\n result += ((62 - b) >>> 8) & ((62 - 43) - 63 + 47);\n\n return String.fromCharCode(result);\n }\n\n // Decode a character code into a byte.\n // Must return 256 if character is out of alphabet range.\n protected _decodeChar(c: number): number {\n // Decoding works similar to encoding: using the same comparison\n // function, but now it works on ranges: result is always incremented\n // by value, but this value becomes zero if the range is not\n // satisfied.\n //\n // Decoding starts with invalid value, 256, which is then\n // subtracted when the range is satisfied. If none of the ranges\n // apply, the function returns 256, which is then checked by\n // the caller to throw error.\n let result = INVALID_BYTE; // start with invalid character\n\n // c == 43 (c > 42 and c < 44)\n result += (((42 - c) & (c - 44)) >>> 8) & (-INVALID_BYTE + c - 43 + 62);\n // c == 47 (c > 46 and c < 48)\n result += (((46 - c) & (c - 48)) >>> 8) & (-INVALID_BYTE + c - 47 + 63);\n // c > 47 and c < 58\n result += (((47 - c) & (c - 58)) >>> 8) & (-INVALID_BYTE + c - 48 + 52);\n // c > 64 and c < 91\n result += (((64 - c) & (c - 91)) >>> 8) & (-INVALID_BYTE + c - 65 + 0);\n // c > 96 and c < 123\n result += (((96 - c) & (c - 123)) >>> 8) & (-INVALID_BYTE + c - 97 + 26);\n\n return result;\n }\n\n private _getPaddingLength(s: string): number {\n let paddingLength = 0;\n if (this._paddingCharacter) {\n for (let i = s.length - 1; i >= 0; i--) {\n if (s[i] !== this._paddingCharacter) {\n break;\n }\n paddingLength++;\n }\n if (s.length < 4 || paddingLength > 2) {\n throw new Error(\"Base64Coder: incorrect padding\");\n }\n }\n return paddingLength;\n }\n\n}\n\nconst stdCoder = new Coder();\n\nexport function encode(data: Uint8Array): string {\n return stdCoder.encode(data);\n}\n\nexport function decode(s: string): Uint8Array {\n return stdCoder.decode(s);\n}\n\n/**\n * Implements URL-safe Base64 encoding.\n * (Same as Base64, but '+' is replaced with '-', and '/' with '_').\n *\n * Operates in constant time.\n */\nexport class URLSafeCoder extends Coder {\n // URL-safe encoding have the following encoded/decoded ranges:\n //\n // ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 0123456789 - _\n // Index: 0 - 25 26 - 51 52 - 61 62 63\n // ASCII: 65 - 90 97 - 122 48 - 57 45 95\n //\n\n protected _encodeByte(b: number): string {\n let result = b;\n // b >= 0\n result += 65;\n // b > 25\n result += ((25 - b) >>> 8) & ((0 - 65) - 26 + 97);\n // b > 51\n result += ((51 - b) >>> 8) & ((26 - 97) - 52 + 48);\n // b > 61\n result += ((61 - b) >>> 8) & ((52 - 48) - 62 + 45);\n // b > 62\n result += ((62 - b) >>> 8) & ((62 - 45) - 63 + 95);\n\n return String.fromCharCode(result);\n }\n\n protected _decodeChar(c: number): number {\n let result = INVALID_BYTE;\n\n // c == 45 (c > 44 and c < 46)\n result += (((44 - c) & (c - 46)) >>> 8) & (-INVALID_BYTE + c - 45 + 62);\n // c == 95 (c > 94 and c < 96)\n result += (((94 - c) & (c - 96)) >>> 8) & (-INVALID_BYTE + c - 95 + 63);\n // c > 47 and c < 58\n result += (((47 - c) & (c - 58)) >>> 8) & (-INVALID_BYTE + c - 48 + 52);\n // c > 64 and c < 91\n result += (((64 - c) & (c - 91)) >>> 8) & (-INVALID_BYTE + c - 65 + 0);\n // c > 96 and c < 123\n result += (((96 - c) & (c - 123)) >>> 8) & (-INVALID_BYTE + c - 97 + 26);\n\n return result;\n }\n}\n\nconst urlSafeCoder = new URLSafeCoder();\n\nexport function encodeURLSafe(data: Uint8Array): string {\n return urlSafeCoder.encode(data);\n}\n\nexport function decodeURLSafe(s: string): Uint8Array {\n return urlSafeCoder.decode(s);\n}\n\n\nexport const encodedLength = (length: number) =>\n stdCoder.encodedLength(length);\n\nexport const maxDecodedLength = (length: number) =>\n stdCoder.maxDecodedLength(length);\n\nexport const decodedLength = (s: string) =>\n stdCoder.decodedLength(s);\n","import TimedCallback from './timed_callback';\nimport { Delay, Scheduler, Canceller } from './scheduling';\n\nabstract class Timer {\n protected clear: Canceller;\n protected timer: number | void;\n\n constructor(\n set: Scheduler,\n clear: Canceller,\n delay: Delay,\n callback: TimedCallback\n ) {\n this.clear = clear;\n this.timer = set(() => {\n if (this.timer) {\n this.timer = callback(this.timer);\n }\n }, delay);\n }\n\n /** Returns whether the timer is still running.\n *\n * @return {Boolean}\n */\n isRunning(): boolean {\n return this.timer !== null;\n }\n\n /** Aborts a timer when it's running. */\n ensureAborted() {\n if (this.timer) {\n this.clear(this.timer);\n this.timer = null;\n }\n }\n}\n\nexport default Timer;\n","module.exports = require(\"@react-native-community/netinfo\");","export default function encode(s: any): string {\n return btoa(utob(s));\n}\n\nvar fromCharCode = String.fromCharCode;\n\nvar b64chars =\n 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';\nvar b64tab = {};\n\nfor (var i = 0, l = b64chars.length; i < l; i++) {\n b64tab[b64chars.charAt(i)] = i;\n}\n\nvar cb_utob = function(c) {\n var cc = c.charCodeAt(0);\n return cc < 0x80\n ? c\n : cc < 0x800\n ? fromCharCode(0xc0 | (cc >>> 6)) + fromCharCode(0x80 | (cc & 0x3f))\n : fromCharCode(0xe0 | ((cc >>> 12) & 0x0f)) +\n fromCharCode(0x80 | ((cc >>> 6) & 0x3f)) +\n fromCharCode(0x80 | (cc & 0x3f));\n};\n\nvar utob = function(u) {\n return u.replace(/[^\\x00-\\x7F]/g, cb_utob);\n};\n\nvar cb_encode = function(ccc) {\n var padlen = [0, 2, 1][ccc.length % 3];\n var ord =\n (ccc.charCodeAt(0) << 16) |\n ((ccc.length > 1 ? ccc.charCodeAt(1) : 0) << 8) |\n (ccc.length > 2 ? ccc.charCodeAt(2) : 0);\n var chars = [\n b64chars.charAt(ord >>> 18),\n b64chars.charAt((ord >>> 12) & 63),\n padlen >= 2 ? '=' : b64chars.charAt((ord >>> 6) & 63),\n padlen >= 1 ? '=' : b64chars.charAt(ord & 63)\n ];\n return chars.join('');\n};\n\nvar btoa =\n global.btoa ||\n function(b) {\n return b.replace(/[\\s\\S]{1,3}/g, cb_encode);\n };\n","import Callback from './callback';\nimport * as Collections from '../utils/collections';\nimport CallbackTable from './callback_table';\n\nexport default class CallbackRegistry {\n _callbacks: CallbackTable;\n\n constructor() {\n this._callbacks = {};\n }\n\n get(name: string): Callback[] {\n return this._callbacks[prefix(name)];\n }\n\n add(name: string, callback: Function, context: any) {\n var prefixedEventName = prefix(name);\n this._callbacks[prefixedEventName] =\n this._callbacks[prefixedEventName] || [];\n this._callbacks[prefixedEventName].push({\n fn: callback,\n context: context\n });\n }\n\n remove(name?: string, callback?: Function, context?: any) {\n if (!name && !callback && !context) {\n this._callbacks = {};\n return;\n }\n\n var names = name ? [prefix(name)] : Collections.keys(this._callbacks);\n\n if (callback || context) {\n this.removeCallback(names, callback, context);\n } else {\n this.removeAllCallbacks(names);\n }\n }\n\n private removeCallback(names: string[], callback: Function, context: any) {\n Collections.apply(\n names,\n function(name) {\n this._callbacks[name] = Collections.filter(\n this._callbacks[name] || [],\n function(binding) {\n return (\n (callback && callback !== binding.fn) ||\n (context && context !== binding.context)\n );\n }\n );\n if (this._callbacks[name].length === 0) {\n delete this._callbacks[name];\n }\n },\n this\n );\n }\n\n private removeAllCallbacks(names: string[]) {\n Collections.apply(\n names,\n function(name) {\n delete this._callbacks[name];\n },\n this\n );\n }\n}\n\nfunction prefix(name: string): string {\n return '_' + name;\n}\n","// Copyright (C) 2016 Dmitry Chestnykh\n// MIT License. See LICENSE file for details.\n\n/**\n * Package utf8 implements UTF-8 encoding and decoding.\n */\n\nconst INVALID_UTF16 = \"utf8: invalid string\";\nconst INVALID_UTF8 = \"utf8: invalid source encoding\";\n\n/**\n * Encodes the given string into UTF-8 byte array.\n * Throws if the source string has invalid UTF-16 encoding.\n */\nexport function encode(s: string): Uint8Array {\n // Calculate result length and allocate output array.\n // encodedLength() also validates string and throws errors,\n // so we don't need repeat validation here.\n const arr = new Uint8Array(encodedLength(s));\n\n let pos = 0;\n for (let i = 0; i < s.length; i++) {\n let c = s.charCodeAt(i);\n if (c < 0x80) {\n arr[pos++] = c;\n } else if (c < 0x800) {\n arr[pos++] = 0xc0 | c >> 6;\n arr[pos++] = 0x80 | c & 0x3f;\n } else if (c < 0xd800) {\n arr[pos++] = 0xe0 | c >> 12;\n arr[pos++] = 0x80 | (c >> 6) & 0x3f;\n arr[pos++] = 0x80 | c & 0x3f;\n } else {\n i++; // get one more character\n c = (c & 0x3ff) << 10;\n c |= s.charCodeAt(i) & 0x3ff;\n c += 0x10000;\n\n arr[pos++] = 0xf0 | c >> 18;\n arr[pos++] = 0x80 | (c >> 12) & 0x3f;\n arr[pos++] = 0x80 | (c >> 6) & 0x3f;\n arr[pos++] = 0x80 | c & 0x3f;\n }\n }\n return arr;\n}\n\n/**\n * Returns the number of bytes required to encode the given string into UTF-8.\n * Throws if the source string has invalid UTF-16 encoding.\n */\nexport function encodedLength(s: string): number {\n let result = 0;\n for (let i = 0; i < s.length; i++) {\n const c = s.charCodeAt(i);\n if (c < 0x80) {\n result += 1;\n } else if (c < 0x800) {\n result += 2;\n } else if (c < 0xd800) {\n result += 3;\n } else if (c <= 0xdfff) {\n if (i >= s.length - 1) {\n throw new Error(INVALID_UTF16);\n }\n i++; // \"eat\" next character\n result += 4;\n } else {\n throw new Error(INVALID_UTF16);\n }\n }\n return result;\n}\n\n/**\n * Decodes the given byte array from UTF-8 into a string.\n * Throws if encoding is invalid.\n */\nexport function decode(arr: Uint8Array): string {\n const chars: string[] = [];\n for (let i = 0; i < arr.length; i++) {\n let b = arr[i];\n\n if (b & 0x80) {\n let min;\n if (b < 0xe0) {\n // Need 1 more byte.\n if (i >= arr.length) {\n throw new Error(INVALID_UTF8);\n }\n const n1 = arr[++i];\n if ((n1 & 0xc0) !== 0x80) {\n throw new Error(INVALID_UTF8);\n }\n b = (b & 0x1f) << 6 | (n1 & 0x3f);\n min = 0x80;\n } else if (b < 0xf0) {\n // Need 2 more bytes.\n if (i >= arr.length - 1) {\n throw new Error(INVALID_UTF8);\n }\n const n1 = arr[++i];\n const n2 = arr[++i];\n if ((n1 & 0xc0) !== 0x80 || (n2 & 0xc0) !== 0x80) {\n throw new Error(INVALID_UTF8);\n }\n b = (b & 0x0f) << 12 | (n1 & 0x3f) << 6 | (n2 & 0x3f);\n min = 0x800;\n } else if (b < 0xf8) {\n // Need 3 more bytes.\n if (i >= arr.length - 2) {\n throw new Error(INVALID_UTF8);\n }\n const n1 = arr[++i];\n const n2 = arr[++i];\n const n3 = arr[++i];\n if ((n1 & 0xc0) !== 0x80 || (n2 & 0xc0) !== 0x80 || (n3 & 0xc0) !== 0x80) {\n throw new Error(INVALID_UTF8);\n }\n b = (b & 0x0f) << 18 | (n1 & 0x3f) << 12 | (n2 & 0x3f) << 6 | (n3 & 0x3f);\n min = 0x10000;\n } else {\n throw new Error(INVALID_UTF8);\n }\n\n if (b < min || (b >= 0xd800 && b <= 0xdfff)) {\n throw new Error(INVALID_UTF8);\n }\n\n if (b >= 0x10000) {\n // Surrogate pair.\n if (b > 0x10ffff) {\n throw new Error(INVALID_UTF8);\n }\n b -= 0x10000;\n chars.push(String.fromCharCode(0xd800 | (b >> 10)));\n b = 0xdc00 | (b & 0x3ff);\n }\n }\n\n chars.push(String.fromCharCode(b));\n }\n return chars.join(\"\");\n}\n","(function(nacl) {\n'use strict';\n\n// Ported in 2014 by Dmitry Chestnykh and Devi Mandiri.\n// Public domain.\n//\n// Implementation derived from TweetNaCl version 20140427.\n// See for details: http://tweetnacl.cr.yp.to/\n\nvar gf = function(init) {\n var i, r = new Float64Array(16);\n if (init) for (i = 0; i < init.length; i++) r[i] = init[i];\n return r;\n};\n\n// Pluggable, initialized in high-level API below.\nvar randombytes = function(/* x, n */) { throw new Error('no PRNG'); };\n\nvar _0 = new Uint8Array(16);\nvar _9 = new Uint8Array(32); _9[0] = 9;\n\nvar gf0 = gf(),\n gf1 = gf([1]),\n _121665 = gf([0xdb41, 1]),\n D = gf([0x78a3, 0x1359, 0x4dca, 0x75eb, 0xd8ab, 0x4141, 0x0a4d, 0x0070, 0xe898, 0x7779, 0x4079, 0x8cc7, 0xfe73, 0x2b6f, 0x6cee, 0x5203]),\n D2 = gf([0xf159, 0x26b2, 0x9b94, 0xebd6, 0xb156, 0x8283, 0x149a, 0x00e0, 0xd130, 0xeef3, 0x80f2, 0x198e, 0xfce7, 0x56df, 0xd9dc, 0x2406]),\n X = gf([0xd51a, 0x8f25, 0x2d60, 0xc956, 0xa7b2, 0x9525, 0xc760, 0x692c, 0xdc5c, 0xfdd6, 0xe231, 0xc0a4, 0x53fe, 0xcd6e, 0x36d3, 0x2169]),\n Y = gf([0x6658, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666]),\n I = gf([0xa0b0, 0x4a0e, 0x1b27, 0xc4ee, 0xe478, 0xad2f, 0x1806, 0x2f43, 0xd7a7, 0x3dfb, 0x0099, 0x2b4d, 0xdf0b, 0x4fc1, 0x2480, 0x2b83]);\n\nfunction ts64(x, i, h, l) {\n x[i] = (h >> 24) & 0xff;\n x[i+1] = (h >> 16) & 0xff;\n x[i+2] = (h >> 8) & 0xff;\n x[i+3] = h & 0xff;\n x[i+4] = (l >> 24) & 0xff;\n x[i+5] = (l >> 16) & 0xff;\n x[i+6] = (l >> 8) & 0xff;\n x[i+7] = l & 0xff;\n}\n\nfunction vn(x, xi, y, yi, n) {\n var i,d = 0;\n for (i = 0; i < n; i++) d |= x[xi+i]^y[yi+i];\n return (1 & ((d - 1) >>> 8)) - 1;\n}\n\nfunction crypto_verify_16(x, xi, y, yi) {\n return vn(x,xi,y,yi,16);\n}\n\nfunction crypto_verify_32(x, xi, y, yi) {\n return vn(x,xi,y,yi,32);\n}\n\nfunction core_salsa20(o, p, k, c) {\n var j0 = c[ 0] & 0xff | (c[ 1] & 0xff)<<8 | (c[ 2] & 0xff)<<16 | (c[ 3] & 0xff)<<24,\n j1 = k[ 0] & 0xff | (k[ 1] & 0xff)<<8 | (k[ 2] & 0xff)<<16 | (k[ 3] & 0xff)<<24,\n j2 = k[ 4] & 0xff | (k[ 5] & 0xff)<<8 | (k[ 6] & 0xff)<<16 | (k[ 7] & 0xff)<<24,\n j3 = k[ 8] & 0xff | (k[ 9] & 0xff)<<8 | (k[10] & 0xff)<<16 | (k[11] & 0xff)<<24,\n j4 = k[12] & 0xff | (k[13] & 0xff)<<8 | (k[14] & 0xff)<<16 | (k[15] & 0xff)<<24,\n j5 = c[ 4] & 0xff | (c[ 5] & 0xff)<<8 | (c[ 6] & 0xff)<<16 | (c[ 7] & 0xff)<<24,\n j6 = p[ 0] & 0xff | (p[ 1] & 0xff)<<8 | (p[ 2] & 0xff)<<16 | (p[ 3] & 0xff)<<24,\n j7 = p[ 4] & 0xff | (p[ 5] & 0xff)<<8 | (p[ 6] & 0xff)<<16 | (p[ 7] & 0xff)<<24,\n j8 = p[ 8] & 0xff | (p[ 9] & 0xff)<<8 | (p[10] & 0xff)<<16 | (p[11] & 0xff)<<24,\n j9 = p[12] & 0xff | (p[13] & 0xff)<<8 | (p[14] & 0xff)<<16 | (p[15] & 0xff)<<24,\n j10 = c[ 8] & 0xff | (c[ 9] & 0xff)<<8 | (c[10] & 0xff)<<16 | (c[11] & 0xff)<<24,\n j11 = k[16] & 0xff | (k[17] & 0xff)<<8 | (k[18] & 0xff)<<16 | (k[19] & 0xff)<<24,\n j12 = k[20] & 0xff | (k[21] & 0xff)<<8 | (k[22] & 0xff)<<16 | (k[23] & 0xff)<<24,\n j13 = k[24] & 0xff | (k[25] & 0xff)<<8 | (k[26] & 0xff)<<16 | (k[27] & 0xff)<<24,\n j14 = k[28] & 0xff | (k[29] & 0xff)<<8 | (k[30] & 0xff)<<16 | (k[31] & 0xff)<<24,\n j15 = c[12] & 0xff | (c[13] & 0xff)<<8 | (c[14] & 0xff)<<16 | (c[15] & 0xff)<<24;\n\n var x0 = j0, x1 = j1, x2 = j2, x3 = j3, x4 = j4, x5 = j5, x6 = j6, x7 = j7,\n x8 = j8, x9 = j9, x10 = j10, x11 = j11, x12 = j12, x13 = j13, x14 = j14,\n x15 = j15, u;\n\n for (var i = 0; i < 20; i += 2) {\n u = x0 + x12 | 0;\n x4 ^= u<<7 | u>>>(32-7);\n u = x4 + x0 | 0;\n x8 ^= u<<9 | u>>>(32-9);\n u = x8 + x4 | 0;\n x12 ^= u<<13 | u>>>(32-13);\n u = x12 + x8 | 0;\n x0 ^= u<<18 | u>>>(32-18);\n\n u = x5 + x1 | 0;\n x9 ^= u<<7 | u>>>(32-7);\n u = x9 + x5 | 0;\n x13 ^= u<<9 | u>>>(32-9);\n u = x13 + x9 | 0;\n x1 ^= u<<13 | u>>>(32-13);\n u = x1 + x13 | 0;\n x5 ^= u<<18 | u>>>(32-18);\n\n u = x10 + x6 | 0;\n x14 ^= u<<7 | u>>>(32-7);\n u = x14 + x10 | 0;\n x2 ^= u<<9 | u>>>(32-9);\n u = x2 + x14 | 0;\n x6 ^= u<<13 | u>>>(32-13);\n u = x6 + x2 | 0;\n x10 ^= u<<18 | u>>>(32-18);\n\n u = x15 + x11 | 0;\n x3 ^= u<<7 | u>>>(32-7);\n u = x3 + x15 | 0;\n x7 ^= u<<9 | u>>>(32-9);\n u = x7 + x3 | 0;\n x11 ^= u<<13 | u>>>(32-13);\n u = x11 + x7 | 0;\n x15 ^= u<<18 | u>>>(32-18);\n\n u = x0 + x3 | 0;\n x1 ^= u<<7 | u>>>(32-7);\n u = x1 + x0 | 0;\n x2 ^= u<<9 | u>>>(32-9);\n u = x2 + x1 | 0;\n x3 ^= u<<13 | u>>>(32-13);\n u = x3 + x2 | 0;\n x0 ^= u<<18 | u>>>(32-18);\n\n u = x5 + x4 | 0;\n x6 ^= u<<7 | u>>>(32-7);\n u = x6 + x5 | 0;\n x7 ^= u<<9 | u>>>(32-9);\n u = x7 + x6 | 0;\n x4 ^= u<<13 | u>>>(32-13);\n u = x4 + x7 | 0;\n x5 ^= u<<18 | u>>>(32-18);\n\n u = x10 + x9 | 0;\n x11 ^= u<<7 | u>>>(32-7);\n u = x11 + x10 | 0;\n x8 ^= u<<9 | u>>>(32-9);\n u = x8 + x11 | 0;\n x9 ^= u<<13 | u>>>(32-13);\n u = x9 + x8 | 0;\n x10 ^= u<<18 | u>>>(32-18);\n\n u = x15 + x14 | 0;\n x12 ^= u<<7 | u>>>(32-7);\n u = x12 + x15 | 0;\n x13 ^= u<<9 | u>>>(32-9);\n u = x13 + x12 | 0;\n x14 ^= u<<13 | u>>>(32-13);\n u = x14 + x13 | 0;\n x15 ^= u<<18 | u>>>(32-18);\n }\n x0 = x0 + j0 | 0;\n x1 = x1 + j1 | 0;\n x2 = x2 + j2 | 0;\n x3 = x3 + j3 | 0;\n x4 = x4 + j4 | 0;\n x5 = x5 + j5 | 0;\n x6 = x6 + j6 | 0;\n x7 = x7 + j7 | 0;\n x8 = x8 + j8 | 0;\n x9 = x9 + j9 | 0;\n x10 = x10 + j10 | 0;\n x11 = x11 + j11 | 0;\n x12 = x12 + j12 | 0;\n x13 = x13 + j13 | 0;\n x14 = x14 + j14 | 0;\n x15 = x15 + j15 | 0;\n\n o[ 0] = x0 >>> 0 & 0xff;\n o[ 1] = x0 >>> 8 & 0xff;\n o[ 2] = x0 >>> 16 & 0xff;\n o[ 3] = x0 >>> 24 & 0xff;\n\n o[ 4] = x1 >>> 0 & 0xff;\n o[ 5] = x1 >>> 8 & 0xff;\n o[ 6] = x1 >>> 16 & 0xff;\n o[ 7] = x1 >>> 24 & 0xff;\n\n o[ 8] = x2 >>> 0 & 0xff;\n o[ 9] = x2 >>> 8 & 0xff;\n o[10] = x2 >>> 16 & 0xff;\n o[11] = x2 >>> 24 & 0xff;\n\n o[12] = x3 >>> 0 & 0xff;\n o[13] = x3 >>> 8 & 0xff;\n o[14] = x3 >>> 16 & 0xff;\n o[15] = x3 >>> 24 & 0xff;\n\n o[16] = x4 >>> 0 & 0xff;\n o[17] = x4 >>> 8 & 0xff;\n o[18] = x4 >>> 16 & 0xff;\n o[19] = x4 >>> 24 & 0xff;\n\n o[20] = x5 >>> 0 & 0xff;\n o[21] = x5 >>> 8 & 0xff;\n o[22] = x5 >>> 16 & 0xff;\n o[23] = x5 >>> 24 & 0xff;\n\n o[24] = x6 >>> 0 & 0xff;\n o[25] = x6 >>> 8 & 0xff;\n o[26] = x6 >>> 16 & 0xff;\n o[27] = x6 >>> 24 & 0xff;\n\n o[28] = x7 >>> 0 & 0xff;\n o[29] = x7 >>> 8 & 0xff;\n o[30] = x7 >>> 16 & 0xff;\n o[31] = x7 >>> 24 & 0xff;\n\n o[32] = x8 >>> 0 & 0xff;\n o[33] = x8 >>> 8 & 0xff;\n o[34] = x8 >>> 16 & 0xff;\n o[35] = x8 >>> 24 & 0xff;\n\n o[36] = x9 >>> 0 & 0xff;\n o[37] = x9 >>> 8 & 0xff;\n o[38] = x9 >>> 16 & 0xff;\n o[39] = x9 >>> 24 & 0xff;\n\n o[40] = x10 >>> 0 & 0xff;\n o[41] = x10 >>> 8 & 0xff;\n o[42] = x10 >>> 16 & 0xff;\n o[43] = x10 >>> 24 & 0xff;\n\n o[44] = x11 >>> 0 & 0xff;\n o[45] = x11 >>> 8 & 0xff;\n o[46] = x11 >>> 16 & 0xff;\n o[47] = x11 >>> 24 & 0xff;\n\n o[48] = x12 >>> 0 & 0xff;\n o[49] = x12 >>> 8 & 0xff;\n o[50] = x12 >>> 16 & 0xff;\n o[51] = x12 >>> 24 & 0xff;\n\n o[52] = x13 >>> 0 & 0xff;\n o[53] = x13 >>> 8 & 0xff;\n o[54] = x13 >>> 16 & 0xff;\n o[55] = x13 >>> 24 & 0xff;\n\n o[56] = x14 >>> 0 & 0xff;\n o[57] = x14 >>> 8 & 0xff;\n o[58] = x14 >>> 16 & 0xff;\n o[59] = x14 >>> 24 & 0xff;\n\n o[60] = x15 >>> 0 & 0xff;\n o[61] = x15 >>> 8 & 0xff;\n o[62] = x15 >>> 16 & 0xff;\n o[63] = x15 >>> 24 & 0xff;\n}\n\nfunction core_hsalsa20(o,p,k,c) {\n var j0 = c[ 0] & 0xff | (c[ 1] & 0xff)<<8 | (c[ 2] & 0xff)<<16 | (c[ 3] & 0xff)<<24,\n j1 = k[ 0] & 0xff | (k[ 1] & 0xff)<<8 | (k[ 2] & 0xff)<<16 | (k[ 3] & 0xff)<<24,\n j2 = k[ 4] & 0xff | (k[ 5] & 0xff)<<8 | (k[ 6] & 0xff)<<16 | (k[ 7] & 0xff)<<24,\n j3 = k[ 8] & 0xff | (k[ 9] & 0xff)<<8 | (k[10] & 0xff)<<16 | (k[11] & 0xff)<<24,\n j4 = k[12] & 0xff | (k[13] & 0xff)<<8 | (k[14] & 0xff)<<16 | (k[15] & 0xff)<<24,\n j5 = c[ 4] & 0xff | (c[ 5] & 0xff)<<8 | (c[ 6] & 0xff)<<16 | (c[ 7] & 0xff)<<24,\n j6 = p[ 0] & 0xff | (p[ 1] & 0xff)<<8 | (p[ 2] & 0xff)<<16 | (p[ 3] & 0xff)<<24,\n j7 = p[ 4] & 0xff | (p[ 5] & 0xff)<<8 | (p[ 6] & 0xff)<<16 | (p[ 7] & 0xff)<<24,\n j8 = p[ 8] & 0xff | (p[ 9] & 0xff)<<8 | (p[10] & 0xff)<<16 | (p[11] & 0xff)<<24,\n j9 = p[12] & 0xff | (p[13] & 0xff)<<8 | (p[14] & 0xff)<<16 | (p[15] & 0xff)<<24,\n j10 = c[ 8] & 0xff | (c[ 9] & 0xff)<<8 | (c[10] & 0xff)<<16 | (c[11] & 0xff)<<24,\n j11 = k[16] & 0xff | (k[17] & 0xff)<<8 | (k[18] & 0xff)<<16 | (k[19] & 0xff)<<24,\n j12 = k[20] & 0xff | (k[21] & 0xff)<<8 | (k[22] & 0xff)<<16 | (k[23] & 0xff)<<24,\n j13 = k[24] & 0xff | (k[25] & 0xff)<<8 | (k[26] & 0xff)<<16 | (k[27] & 0xff)<<24,\n j14 = k[28] & 0xff | (k[29] & 0xff)<<8 | (k[30] & 0xff)<<16 | (k[31] & 0xff)<<24,\n j15 = c[12] & 0xff | (c[13] & 0xff)<<8 | (c[14] & 0xff)<<16 | (c[15] & 0xff)<<24;\n\n var x0 = j0, x1 = j1, x2 = j2, x3 = j3, x4 = j4, x5 = j5, x6 = j6, x7 = j7,\n x8 = j8, x9 = j9, x10 = j10, x11 = j11, x12 = j12, x13 = j13, x14 = j14,\n x15 = j15, u;\n\n for (var i = 0; i < 20; i += 2) {\n u = x0 + x12 | 0;\n x4 ^= u<<7 | u>>>(32-7);\n u = x4 + x0 | 0;\n x8 ^= u<<9 | u>>>(32-9);\n u = x8 + x4 | 0;\n x12 ^= u<<13 | u>>>(32-13);\n u = x12 + x8 | 0;\n x0 ^= u<<18 | u>>>(32-18);\n\n u = x5 + x1 | 0;\n x9 ^= u<<7 | u>>>(32-7);\n u = x9 + x5 | 0;\n x13 ^= u<<9 | u>>>(32-9);\n u = x13 + x9 | 0;\n x1 ^= u<<13 | u>>>(32-13);\n u = x1 + x13 | 0;\n x5 ^= u<<18 | u>>>(32-18);\n\n u = x10 + x6 | 0;\n x14 ^= u<<7 | u>>>(32-7);\n u = x14 + x10 | 0;\n x2 ^= u<<9 | u>>>(32-9);\n u = x2 + x14 | 0;\n x6 ^= u<<13 | u>>>(32-13);\n u = x6 + x2 | 0;\n x10 ^= u<<18 | u>>>(32-18);\n\n u = x15 + x11 | 0;\n x3 ^= u<<7 | u>>>(32-7);\n u = x3 + x15 | 0;\n x7 ^= u<<9 | u>>>(32-9);\n u = x7 + x3 | 0;\n x11 ^= u<<13 | u>>>(32-13);\n u = x11 + x7 | 0;\n x15 ^= u<<18 | u>>>(32-18);\n\n u = x0 + x3 | 0;\n x1 ^= u<<7 | u>>>(32-7);\n u = x1 + x0 | 0;\n x2 ^= u<<9 | u>>>(32-9);\n u = x2 + x1 | 0;\n x3 ^= u<<13 | u>>>(32-13);\n u = x3 + x2 | 0;\n x0 ^= u<<18 | u>>>(32-18);\n\n u = x5 + x4 | 0;\n x6 ^= u<<7 | u>>>(32-7);\n u = x6 + x5 | 0;\n x7 ^= u<<9 | u>>>(32-9);\n u = x7 + x6 | 0;\n x4 ^= u<<13 | u>>>(32-13);\n u = x4 + x7 | 0;\n x5 ^= u<<18 | u>>>(32-18);\n\n u = x10 + x9 | 0;\n x11 ^= u<<7 | u>>>(32-7);\n u = x11 + x10 | 0;\n x8 ^= u<<9 | u>>>(32-9);\n u = x8 + x11 | 0;\n x9 ^= u<<13 | u>>>(32-13);\n u = x9 + x8 | 0;\n x10 ^= u<<18 | u>>>(32-18);\n\n u = x15 + x14 | 0;\n x12 ^= u<<7 | u>>>(32-7);\n u = x12 + x15 | 0;\n x13 ^= u<<9 | u>>>(32-9);\n u = x13 + x12 | 0;\n x14 ^= u<<13 | u>>>(32-13);\n u = x14 + x13 | 0;\n x15 ^= u<<18 | u>>>(32-18);\n }\n\n o[ 0] = x0 >>> 0 & 0xff;\n o[ 1] = x0 >>> 8 & 0xff;\n o[ 2] = x0 >>> 16 & 0xff;\n o[ 3] = x0 >>> 24 & 0xff;\n\n o[ 4] = x5 >>> 0 & 0xff;\n o[ 5] = x5 >>> 8 & 0xff;\n o[ 6] = x5 >>> 16 & 0xff;\n o[ 7] = x5 >>> 24 & 0xff;\n\n o[ 8] = x10 >>> 0 & 0xff;\n o[ 9] = x10 >>> 8 & 0xff;\n o[10] = x10 >>> 16 & 0xff;\n o[11] = x10 >>> 24 & 0xff;\n\n o[12] = x15 >>> 0 & 0xff;\n o[13] = x15 >>> 8 & 0xff;\n o[14] = x15 >>> 16 & 0xff;\n o[15] = x15 >>> 24 & 0xff;\n\n o[16] = x6 >>> 0 & 0xff;\n o[17] = x6 >>> 8 & 0xff;\n o[18] = x6 >>> 16 & 0xff;\n o[19] = x6 >>> 24 & 0xff;\n\n o[20] = x7 >>> 0 & 0xff;\n o[21] = x7 >>> 8 & 0xff;\n o[22] = x7 >>> 16 & 0xff;\n o[23] = x7 >>> 24 & 0xff;\n\n o[24] = x8 >>> 0 & 0xff;\n o[25] = x8 >>> 8 & 0xff;\n o[26] = x8 >>> 16 & 0xff;\n o[27] = x8 >>> 24 & 0xff;\n\n o[28] = x9 >>> 0 & 0xff;\n o[29] = x9 >>> 8 & 0xff;\n o[30] = x9 >>> 16 & 0xff;\n o[31] = x9 >>> 24 & 0xff;\n}\n\nfunction crypto_core_salsa20(out,inp,k,c) {\n core_salsa20(out,inp,k,c);\n}\n\nfunction crypto_core_hsalsa20(out,inp,k,c) {\n core_hsalsa20(out,inp,k,c);\n}\n\nvar sigma = new Uint8Array([101, 120, 112, 97, 110, 100, 32, 51, 50, 45, 98, 121, 116, 101, 32, 107]);\n // \"expand 32-byte k\"\n\nfunction crypto_stream_salsa20_xor(c,cpos,m,mpos,b,n,k) {\n var z = new Uint8Array(16), x = new Uint8Array(64);\n var u, i;\n for (i = 0; i < 16; i++) z[i] = 0;\n for (i = 0; i < 8; i++) z[i] = n[i];\n while (b >= 64) {\n crypto_core_salsa20(x,z,k,sigma);\n for (i = 0; i < 64; i++) c[cpos+i] = m[mpos+i] ^ x[i];\n u = 1;\n for (i = 8; i < 16; i++) {\n u = u + (z[i] & 0xff) | 0;\n z[i] = u & 0xff;\n u >>>= 8;\n }\n b -= 64;\n cpos += 64;\n mpos += 64;\n }\n if (b > 0) {\n crypto_core_salsa20(x,z,k,sigma);\n for (i = 0; i < b; i++) c[cpos+i] = m[mpos+i] ^ x[i];\n }\n return 0;\n}\n\nfunction crypto_stream_salsa20(c,cpos,b,n,k) {\n var z = new Uint8Array(16), x = new Uint8Array(64);\n var u, i;\n for (i = 0; i < 16; i++) z[i] = 0;\n for (i = 0; i < 8; i++) z[i] = n[i];\n while (b >= 64) {\n crypto_core_salsa20(x,z,k,sigma);\n for (i = 0; i < 64; i++) c[cpos+i] = x[i];\n u = 1;\n for (i = 8; i < 16; i++) {\n u = u + (z[i] & 0xff) | 0;\n z[i] = u & 0xff;\n u >>>= 8;\n }\n b -= 64;\n cpos += 64;\n }\n if (b > 0) {\n crypto_core_salsa20(x,z,k,sigma);\n for (i = 0; i < b; i++) c[cpos+i] = x[i];\n }\n return 0;\n}\n\nfunction crypto_stream(c,cpos,d,n,k) {\n var s = new Uint8Array(32);\n crypto_core_hsalsa20(s,n,k,sigma);\n var sn = new Uint8Array(8);\n for (var i = 0; i < 8; i++) sn[i] = n[i+16];\n return crypto_stream_salsa20(c,cpos,d,sn,s);\n}\n\nfunction crypto_stream_xor(c,cpos,m,mpos,d,n,k) {\n var s = new Uint8Array(32);\n crypto_core_hsalsa20(s,n,k,sigma);\n var sn = new Uint8Array(8);\n for (var i = 0; i < 8; i++) sn[i] = n[i+16];\n return crypto_stream_salsa20_xor(c,cpos,m,mpos,d,sn,s);\n}\n\n/*\n* Port of Andrew Moon's Poly1305-donna-16. Public domain.\n* https://github.com/floodyberry/poly1305-donna\n*/\n\nvar poly1305 = function(key) {\n this.buffer = new Uint8Array(16);\n this.r = new Uint16Array(10);\n this.h = new Uint16Array(10);\n this.pad = new Uint16Array(8);\n this.leftover = 0;\n this.fin = 0;\n\n var t0, t1, t2, t3, t4, t5, t6, t7;\n\n t0 = key[ 0] & 0xff | (key[ 1] & 0xff) << 8; this.r[0] = ( t0 ) & 0x1fff;\n t1 = key[ 2] & 0xff | (key[ 3] & 0xff) << 8; this.r[1] = ((t0 >>> 13) | (t1 << 3)) & 0x1fff;\n t2 = key[ 4] & 0xff | (key[ 5] & 0xff) << 8; this.r[2] = ((t1 >>> 10) | (t2 << 6)) & 0x1f03;\n t3 = key[ 6] & 0xff | (key[ 7] & 0xff) << 8; this.r[3] = ((t2 >>> 7) | (t3 << 9)) & 0x1fff;\n t4 = key[ 8] & 0xff | (key[ 9] & 0xff) << 8; this.r[4] = ((t3 >>> 4) | (t4 << 12)) & 0x00ff;\n this.r[5] = ((t4 >>> 1)) & 0x1ffe;\n t5 = key[10] & 0xff | (key[11] & 0xff) << 8; this.r[6] = ((t4 >>> 14) | (t5 << 2)) & 0x1fff;\n t6 = key[12] & 0xff | (key[13] & 0xff) << 8; this.r[7] = ((t5 >>> 11) | (t6 << 5)) & 0x1f81;\n t7 = key[14] & 0xff | (key[15] & 0xff) << 8; this.r[8] = ((t6 >>> 8) | (t7 << 8)) & 0x1fff;\n this.r[9] = ((t7 >>> 5)) & 0x007f;\n\n this.pad[0] = key[16] & 0xff | (key[17] & 0xff) << 8;\n this.pad[1] = key[18] & 0xff | (key[19] & 0xff) << 8;\n this.pad[2] = key[20] & 0xff | (key[21] & 0xff) << 8;\n this.pad[3] = key[22] & 0xff | (key[23] & 0xff) << 8;\n this.pad[4] = key[24] & 0xff | (key[25] & 0xff) << 8;\n this.pad[5] = key[26] & 0xff | (key[27] & 0xff) << 8;\n this.pad[6] = key[28] & 0xff | (key[29] & 0xff) << 8;\n this.pad[7] = key[30] & 0xff | (key[31] & 0xff) << 8;\n};\n\npoly1305.prototype.blocks = function(m, mpos, bytes) {\n var hibit = this.fin ? 0 : (1 << 11);\n var t0, t1, t2, t3, t4, t5, t6, t7, c;\n var d0, d1, d2, d3, d4, d5, d6, d7, d8, d9;\n\n var h0 = this.h[0],\n h1 = this.h[1],\n h2 = this.h[2],\n h3 = this.h[3],\n h4 = this.h[4],\n h5 = this.h[5],\n h6 = this.h[6],\n h7 = this.h[7],\n h8 = this.h[8],\n h9 = this.h[9];\n\n var r0 = this.r[0],\n r1 = this.r[1],\n r2 = this.r[2],\n r3 = this.r[3],\n r4 = this.r[4],\n r5 = this.r[5],\n r6 = this.r[6],\n r7 = this.r[7],\n r8 = this.r[8],\n r9 = this.r[9];\n\n while (bytes >= 16) {\n t0 = m[mpos+ 0] & 0xff | (m[mpos+ 1] & 0xff) << 8; h0 += ( t0 ) & 0x1fff;\n t1 = m[mpos+ 2] & 0xff | (m[mpos+ 3] & 0xff) << 8; h1 += ((t0 >>> 13) | (t1 << 3)) & 0x1fff;\n t2 = m[mpos+ 4] & 0xff | (m[mpos+ 5] & 0xff) << 8; h2 += ((t1 >>> 10) | (t2 << 6)) & 0x1fff;\n t3 = m[mpos+ 6] & 0xff | (m[mpos+ 7] & 0xff) << 8; h3 += ((t2 >>> 7) | (t3 << 9)) & 0x1fff;\n t4 = m[mpos+ 8] & 0xff | (m[mpos+ 9] & 0xff) << 8; h4 += ((t3 >>> 4) | (t4 << 12)) & 0x1fff;\n h5 += ((t4 >>> 1)) & 0x1fff;\n t5 = m[mpos+10] & 0xff | (m[mpos+11] & 0xff) << 8; h6 += ((t4 >>> 14) | (t5 << 2)) & 0x1fff;\n t6 = m[mpos+12] & 0xff | (m[mpos+13] & 0xff) << 8; h7 += ((t5 >>> 11) | (t6 << 5)) & 0x1fff;\n t7 = m[mpos+14] & 0xff | (m[mpos+15] & 0xff) << 8; h8 += ((t6 >>> 8) | (t7 << 8)) & 0x1fff;\n h9 += ((t7 >>> 5)) | hibit;\n\n c = 0;\n\n d0 = c;\n d0 += h0 * r0;\n d0 += h1 * (5 * r9);\n d0 += h2 * (5 * r8);\n d0 += h3 * (5 * r7);\n d0 += h4 * (5 * r6);\n c = (d0 >>> 13); d0 &= 0x1fff;\n d0 += h5 * (5 * r5);\n d0 += h6 * (5 * r4);\n d0 += h7 * (5 * r3);\n d0 += h8 * (5 * r2);\n d0 += h9 * (5 * r1);\n c += (d0 >>> 13); d0 &= 0x1fff;\n\n d1 = c;\n d1 += h0 * r1;\n d1 += h1 * r0;\n d1 += h2 * (5 * r9);\n d1 += h3 * (5 * r8);\n d1 += h4 * (5 * r7);\n c = (d1 >>> 13); d1 &= 0x1fff;\n d1 += h5 * (5 * r6);\n d1 += h6 * (5 * r5);\n d1 += h7 * (5 * r4);\n d1 += h8 * (5 * r3);\n d1 += h9 * (5 * r2);\n c += (d1 >>> 13); d1 &= 0x1fff;\n\n d2 = c;\n d2 += h0 * r2;\n d2 += h1 * r1;\n d2 += h2 * r0;\n d2 += h3 * (5 * r9);\n d2 += h4 * (5 * r8);\n c = (d2 >>> 13); d2 &= 0x1fff;\n d2 += h5 * (5 * r7);\n d2 += h6 * (5 * r6);\n d2 += h7 * (5 * r5);\n d2 += h8 * (5 * r4);\n d2 += h9 * (5 * r3);\n c += (d2 >>> 13); d2 &= 0x1fff;\n\n d3 = c;\n d3 += h0 * r3;\n d3 += h1 * r2;\n d3 += h2 * r1;\n d3 += h3 * r0;\n d3 += h4 * (5 * r9);\n c = (d3 >>> 13); d3 &= 0x1fff;\n d3 += h5 * (5 * r8);\n d3 += h6 * (5 * r7);\n d3 += h7 * (5 * r6);\n d3 += h8 * (5 * r5);\n d3 += h9 * (5 * r4);\n c += (d3 >>> 13); d3 &= 0x1fff;\n\n d4 = c;\n d4 += h0 * r4;\n d4 += h1 * r3;\n d4 += h2 * r2;\n d4 += h3 * r1;\n d4 += h4 * r0;\n c = (d4 >>> 13); d4 &= 0x1fff;\n d4 += h5 * (5 * r9);\n d4 += h6 * (5 * r8);\n d4 += h7 * (5 * r7);\n d4 += h8 * (5 * r6);\n d4 += h9 * (5 * r5);\n c += (d4 >>> 13); d4 &= 0x1fff;\n\n d5 = c;\n d5 += h0 * r5;\n d5 += h1 * r4;\n d5 += h2 * r3;\n d5 += h3 * r2;\n d5 += h4 * r1;\n c = (d5 >>> 13); d5 &= 0x1fff;\n d5 += h5 * r0;\n d5 += h6 * (5 * r9);\n d5 += h7 * (5 * r8);\n d5 += h8 * (5 * r7);\n d5 += h9 * (5 * r6);\n c += (d5 >>> 13); d5 &= 0x1fff;\n\n d6 = c;\n d6 += h0 * r6;\n d6 += h1 * r5;\n d6 += h2 * r4;\n d6 += h3 * r3;\n d6 += h4 * r2;\n c = (d6 >>> 13); d6 &= 0x1fff;\n d6 += h5 * r1;\n d6 += h6 * r0;\n d6 += h7 * (5 * r9);\n d6 += h8 * (5 * r8);\n d6 += h9 * (5 * r7);\n c += (d6 >>> 13); d6 &= 0x1fff;\n\n d7 = c;\n d7 += h0 * r7;\n d7 += h1 * r6;\n d7 += h2 * r5;\n d7 += h3 * r4;\n d7 += h4 * r3;\n c = (d7 >>> 13); d7 &= 0x1fff;\n d7 += h5 * r2;\n d7 += h6 * r1;\n d7 += h7 * r0;\n d7 += h8 * (5 * r9);\n d7 += h9 * (5 * r8);\n c += (d7 >>> 13); d7 &= 0x1fff;\n\n d8 = c;\n d8 += h0 * r8;\n d8 += h1 * r7;\n d8 += h2 * r6;\n d8 += h3 * r5;\n d8 += h4 * r4;\n c = (d8 >>> 13); d8 &= 0x1fff;\n d8 += h5 * r3;\n d8 += h6 * r2;\n d8 += h7 * r1;\n d8 += h8 * r0;\n d8 += h9 * (5 * r9);\n c += (d8 >>> 13); d8 &= 0x1fff;\n\n d9 = c;\n d9 += h0 * r9;\n d9 += h1 * r8;\n d9 += h2 * r7;\n d9 += h3 * r6;\n d9 += h4 * r5;\n c = (d9 >>> 13); d9 &= 0x1fff;\n d9 += h5 * r4;\n d9 += h6 * r3;\n d9 += h7 * r2;\n d9 += h8 * r1;\n d9 += h9 * r0;\n c += (d9 >>> 13); d9 &= 0x1fff;\n\n c = (((c << 2) + c)) | 0;\n c = (c + d0) | 0;\n d0 = c & 0x1fff;\n c = (c >>> 13);\n d1 += c;\n\n h0 = d0;\n h1 = d1;\n h2 = d2;\n h3 = d3;\n h4 = d4;\n h5 = d5;\n h6 = d6;\n h7 = d7;\n h8 = d8;\n h9 = d9;\n\n mpos += 16;\n bytes -= 16;\n }\n this.h[0] = h0;\n this.h[1] = h1;\n this.h[2] = h2;\n this.h[3] = h3;\n this.h[4] = h4;\n this.h[5] = h5;\n this.h[6] = h6;\n this.h[7] = h7;\n this.h[8] = h8;\n this.h[9] = h9;\n};\n\npoly1305.prototype.finish = function(mac, macpos) {\n var g = new Uint16Array(10);\n var c, mask, f, i;\n\n if (this.leftover) {\n i = this.leftover;\n this.buffer[i++] = 1;\n for (; i < 16; i++) this.buffer[i] = 0;\n this.fin = 1;\n this.blocks(this.buffer, 0, 16);\n }\n\n c = this.h[1] >>> 13;\n this.h[1] &= 0x1fff;\n for (i = 2; i < 10; i++) {\n this.h[i] += c;\n c = this.h[i] >>> 13;\n this.h[i] &= 0x1fff;\n }\n this.h[0] += (c * 5);\n c = this.h[0] >>> 13;\n this.h[0] &= 0x1fff;\n this.h[1] += c;\n c = this.h[1] >>> 13;\n this.h[1] &= 0x1fff;\n this.h[2] += c;\n\n g[0] = this.h[0] + 5;\n c = g[0] >>> 13;\n g[0] &= 0x1fff;\n for (i = 1; i < 10; i++) {\n g[i] = this.h[i] + c;\n c = g[i] >>> 13;\n g[i] &= 0x1fff;\n }\n g[9] -= (1 << 13);\n\n mask = (c ^ 1) - 1;\n for (i = 0; i < 10; i++) g[i] &= mask;\n mask = ~mask;\n for (i = 0; i < 10; i++) this.h[i] = (this.h[i] & mask) | g[i];\n\n this.h[0] = ((this.h[0] ) | (this.h[1] << 13) ) & 0xffff;\n this.h[1] = ((this.h[1] >>> 3) | (this.h[2] << 10) ) & 0xffff;\n this.h[2] = ((this.h[2] >>> 6) | (this.h[3] << 7) ) & 0xffff;\n this.h[3] = ((this.h[3] >>> 9) | (this.h[4] << 4) ) & 0xffff;\n this.h[4] = ((this.h[4] >>> 12) | (this.h[5] << 1) | (this.h[6] << 14)) & 0xffff;\n this.h[5] = ((this.h[6] >>> 2) | (this.h[7] << 11) ) & 0xffff;\n this.h[6] = ((this.h[7] >>> 5) | (this.h[8] << 8) ) & 0xffff;\n this.h[7] = ((this.h[8] >>> 8) | (this.h[9] << 5) ) & 0xffff;\n\n f = this.h[0] + this.pad[0];\n this.h[0] = f & 0xffff;\n for (i = 1; i < 8; i++) {\n f = (((this.h[i] + this.pad[i]) | 0) + (f >>> 16)) | 0;\n this.h[i] = f & 0xffff;\n }\n\n mac[macpos+ 0] = (this.h[0] >>> 0) & 0xff;\n mac[macpos+ 1] = (this.h[0] >>> 8) & 0xff;\n mac[macpos+ 2] = (this.h[1] >>> 0) & 0xff;\n mac[macpos+ 3] = (this.h[1] >>> 8) & 0xff;\n mac[macpos+ 4] = (this.h[2] >>> 0) & 0xff;\n mac[macpos+ 5] = (this.h[2] >>> 8) & 0xff;\n mac[macpos+ 6] = (this.h[3] >>> 0) & 0xff;\n mac[macpos+ 7] = (this.h[3] >>> 8) & 0xff;\n mac[macpos+ 8] = (this.h[4] >>> 0) & 0xff;\n mac[macpos+ 9] = (this.h[4] >>> 8) & 0xff;\n mac[macpos+10] = (this.h[5] >>> 0) & 0xff;\n mac[macpos+11] = (this.h[5] >>> 8) & 0xff;\n mac[macpos+12] = (this.h[6] >>> 0) & 0xff;\n mac[macpos+13] = (this.h[6] >>> 8) & 0xff;\n mac[macpos+14] = (this.h[7] >>> 0) & 0xff;\n mac[macpos+15] = (this.h[7] >>> 8) & 0xff;\n};\n\npoly1305.prototype.update = function(m, mpos, bytes) {\n var i, want;\n\n if (this.leftover) {\n want = (16 - this.leftover);\n if (want > bytes)\n want = bytes;\n for (i = 0; i < want; i++)\n this.buffer[this.leftover + i] = m[mpos+i];\n bytes -= want;\n mpos += want;\n this.leftover += want;\n if (this.leftover < 16)\n return;\n this.blocks(this.buffer, 0, 16);\n this.leftover = 0;\n }\n\n if (bytes >= 16) {\n want = bytes - (bytes % 16);\n this.blocks(m, mpos, want);\n mpos += want;\n bytes -= want;\n }\n\n if (bytes) {\n for (i = 0; i < bytes; i++)\n this.buffer[this.leftover + i] = m[mpos+i];\n this.leftover += bytes;\n }\n};\n\nfunction crypto_onetimeauth(out, outpos, m, mpos, n, k) {\n var s = new poly1305(k);\n s.update(m, mpos, n);\n s.finish(out, outpos);\n return 0;\n}\n\nfunction crypto_onetimeauth_verify(h, hpos, m, mpos, n, k) {\n var x = new Uint8Array(16);\n crypto_onetimeauth(x,0,m,mpos,n,k);\n return crypto_verify_16(h,hpos,x,0);\n}\n\nfunction crypto_secretbox(c,m,d,n,k) {\n var i;\n if (d < 32) return -1;\n crypto_stream_xor(c,0,m,0,d,n,k);\n crypto_onetimeauth(c, 16, c, 32, d - 32, c);\n for (i = 0; i < 16; i++) c[i] = 0;\n return 0;\n}\n\nfunction crypto_secretbox_open(m,c,d,n,k) {\n var i;\n var x = new Uint8Array(32);\n if (d < 32) return -1;\n crypto_stream(x,0,32,n,k);\n if (crypto_onetimeauth_verify(c, 16,c, 32,d - 32,x) !== 0) return -1;\n crypto_stream_xor(m,0,c,0,d,n,k);\n for (i = 0; i < 32; i++) m[i] = 0;\n return 0;\n}\n\nfunction set25519(r, a) {\n var i;\n for (i = 0; i < 16; i++) r[i] = a[i]|0;\n}\n\nfunction car25519(o) {\n var i, v, c = 1;\n for (i = 0; i < 16; i++) {\n v = o[i] + c + 65535;\n c = Math.floor(v / 65536);\n o[i] = v - c * 65536;\n }\n o[0] += c-1 + 37 * (c-1);\n}\n\nfunction sel25519(p, q, b) {\n var t, c = ~(b-1);\n for (var i = 0; i < 16; i++) {\n t = c & (p[i] ^ q[i]);\n p[i] ^= t;\n q[i] ^= t;\n }\n}\n\nfunction pack25519(o, n) {\n var i, j, b;\n var m = gf(), t = gf();\n for (i = 0; i < 16; i++) t[i] = n[i];\n car25519(t);\n car25519(t);\n car25519(t);\n for (j = 0; j < 2; j++) {\n m[0] = t[0] - 0xffed;\n for (i = 1; i < 15; i++) {\n m[i] = t[i] - 0xffff - ((m[i-1]>>16) & 1);\n m[i-1] &= 0xffff;\n }\n m[15] = t[15] - 0x7fff - ((m[14]>>16) & 1);\n b = (m[15]>>16) & 1;\n m[14] &= 0xffff;\n sel25519(t, m, 1-b);\n }\n for (i = 0; i < 16; i++) {\n o[2*i] = t[i] & 0xff;\n o[2*i+1] = t[i]>>8;\n }\n}\n\nfunction neq25519(a, b) {\n var c = new Uint8Array(32), d = new Uint8Array(32);\n pack25519(c, a);\n pack25519(d, b);\n return crypto_verify_32(c, 0, d, 0);\n}\n\nfunction par25519(a) {\n var d = new Uint8Array(32);\n pack25519(d, a);\n return d[0] & 1;\n}\n\nfunction unpack25519(o, n) {\n var i;\n for (i = 0; i < 16; i++) o[i] = n[2*i] + (n[2*i+1] << 8);\n o[15] &= 0x7fff;\n}\n\nfunction A(o, a, b) {\n for (var i = 0; i < 16; i++) o[i] = a[i] + b[i];\n}\n\nfunction Z(o, a, b) {\n for (var i = 0; i < 16; i++) o[i] = a[i] - b[i];\n}\n\nfunction M(o, a, b) {\n var v, c,\n t0 = 0, t1 = 0, t2 = 0, t3 = 0, t4 = 0, t5 = 0, t6 = 0, t7 = 0,\n t8 = 0, t9 = 0, t10 = 0, t11 = 0, t12 = 0, t13 = 0, t14 = 0, t15 = 0,\n t16 = 0, t17 = 0, t18 = 0, t19 = 0, t20 = 0, t21 = 0, t22 = 0, t23 = 0,\n t24 = 0, t25 = 0, t26 = 0, t27 = 0, t28 = 0, t29 = 0, t30 = 0,\n b0 = b[0],\n b1 = b[1],\n b2 = b[2],\n b3 = b[3],\n b4 = b[4],\n b5 = b[5],\n b6 = b[6],\n b7 = b[7],\n b8 = b[8],\n b9 = b[9],\n b10 = b[10],\n b11 = b[11],\n b12 = b[12],\n b13 = b[13],\n b14 = b[14],\n b15 = b[15];\n\n v = a[0];\n t0 += v * b0;\n t1 += v * b1;\n t2 += v * b2;\n t3 += v * b3;\n t4 += v * b4;\n t5 += v * b5;\n t6 += v * b6;\n t7 += v * b7;\n t8 += v * b8;\n t9 += v * b9;\n t10 += v * b10;\n t11 += v * b11;\n t12 += v * b12;\n t13 += v * b13;\n t14 += v * b14;\n t15 += v * b15;\n v = a[1];\n t1 += v * b0;\n t2 += v * b1;\n t3 += v * b2;\n t4 += v * b3;\n t5 += v * b4;\n t6 += v * b5;\n t7 += v * b6;\n t8 += v * b7;\n t9 += v * b8;\n t10 += v * b9;\n t11 += v * b10;\n t12 += v * b11;\n t13 += v * b12;\n t14 += v * b13;\n t15 += v * b14;\n t16 += v * b15;\n v = a[2];\n t2 += v * b0;\n t3 += v * b1;\n t4 += v * b2;\n t5 += v * b3;\n t6 += v * b4;\n t7 += v * b5;\n t8 += v * b6;\n t9 += v * b7;\n t10 += v * b8;\n t11 += v * b9;\n t12 += v * b10;\n t13 += v * b11;\n t14 += v * b12;\n t15 += v * b13;\n t16 += v * b14;\n t17 += v * b15;\n v = a[3];\n t3 += v * b0;\n t4 += v * b1;\n t5 += v * b2;\n t6 += v * b3;\n t7 += v * b4;\n t8 += v * b5;\n t9 += v * b6;\n t10 += v * b7;\n t11 += v * b8;\n t12 += v * b9;\n t13 += v * b10;\n t14 += v * b11;\n t15 += v * b12;\n t16 += v * b13;\n t17 += v * b14;\n t18 += v * b15;\n v = a[4];\n t4 += v * b0;\n t5 += v * b1;\n t6 += v * b2;\n t7 += v * b3;\n t8 += v * b4;\n t9 += v * b5;\n t10 += v * b6;\n t11 += v * b7;\n t12 += v * b8;\n t13 += v * b9;\n t14 += v * b10;\n t15 += v * b11;\n t16 += v * b12;\n t17 += v * b13;\n t18 += v * b14;\n t19 += v * b15;\n v = a[5];\n t5 += v * b0;\n t6 += v * b1;\n t7 += v * b2;\n t8 += v * b3;\n t9 += v * b4;\n t10 += v * b5;\n t11 += v * b6;\n t12 += v * b7;\n t13 += v * b8;\n t14 += v * b9;\n t15 += v * b10;\n t16 += v * b11;\n t17 += v * b12;\n t18 += v * b13;\n t19 += v * b14;\n t20 += v * b15;\n v = a[6];\n t6 += v * b0;\n t7 += v * b1;\n t8 += v * b2;\n t9 += v * b3;\n t10 += v * b4;\n t11 += v * b5;\n t12 += v * b6;\n t13 += v * b7;\n t14 += v * b8;\n t15 += v * b9;\n t16 += v * b10;\n t17 += v * b11;\n t18 += v * b12;\n t19 += v * b13;\n t20 += v * b14;\n t21 += v * b15;\n v = a[7];\n t7 += v * b0;\n t8 += v * b1;\n t9 += v * b2;\n t10 += v * b3;\n t11 += v * b4;\n t12 += v * b5;\n t13 += v * b6;\n t14 += v * b7;\n t15 += v * b8;\n t16 += v * b9;\n t17 += v * b10;\n t18 += v * b11;\n t19 += v * b12;\n t20 += v * b13;\n t21 += v * b14;\n t22 += v * b15;\n v = a[8];\n t8 += v * b0;\n t9 += v * b1;\n t10 += v * b2;\n t11 += v * b3;\n t12 += v * b4;\n t13 += v * b5;\n t14 += v * b6;\n t15 += v * b7;\n t16 += v * b8;\n t17 += v * b9;\n t18 += v * b10;\n t19 += v * b11;\n t20 += v * b12;\n t21 += v * b13;\n t22 += v * b14;\n t23 += v * b15;\n v = a[9];\n t9 += v * b0;\n t10 += v * b1;\n t11 += v * b2;\n t12 += v * b3;\n t13 += v * b4;\n t14 += v * b5;\n t15 += v * b6;\n t16 += v * b7;\n t17 += v * b8;\n t18 += v * b9;\n t19 += v * b10;\n t20 += v * b11;\n t21 += v * b12;\n t22 += v * b13;\n t23 += v * b14;\n t24 += v * b15;\n v = a[10];\n t10 += v * b0;\n t11 += v * b1;\n t12 += v * b2;\n t13 += v * b3;\n t14 += v * b4;\n t15 += v * b5;\n t16 += v * b6;\n t17 += v * b7;\n t18 += v * b8;\n t19 += v * b9;\n t20 += v * b10;\n t21 += v * b11;\n t22 += v * b12;\n t23 += v * b13;\n t24 += v * b14;\n t25 += v * b15;\n v = a[11];\n t11 += v * b0;\n t12 += v * b1;\n t13 += v * b2;\n t14 += v * b3;\n t15 += v * b4;\n t16 += v * b5;\n t17 += v * b6;\n t18 += v * b7;\n t19 += v * b8;\n t20 += v * b9;\n t21 += v * b10;\n t22 += v * b11;\n t23 += v * b12;\n t24 += v * b13;\n t25 += v * b14;\n t26 += v * b15;\n v = a[12];\n t12 += v * b0;\n t13 += v * b1;\n t14 += v * b2;\n t15 += v * b3;\n t16 += v * b4;\n t17 += v * b5;\n t18 += v * b6;\n t19 += v * b7;\n t20 += v * b8;\n t21 += v * b9;\n t22 += v * b10;\n t23 += v * b11;\n t24 += v * b12;\n t25 += v * b13;\n t26 += v * b14;\n t27 += v * b15;\n v = a[13];\n t13 += v * b0;\n t14 += v * b1;\n t15 += v * b2;\n t16 += v * b3;\n t17 += v * b4;\n t18 += v * b5;\n t19 += v * b6;\n t20 += v * b7;\n t21 += v * b8;\n t22 += v * b9;\n t23 += v * b10;\n t24 += v * b11;\n t25 += v * b12;\n t26 += v * b13;\n t27 += v * b14;\n t28 += v * b15;\n v = a[14];\n t14 += v * b0;\n t15 += v * b1;\n t16 += v * b2;\n t17 += v * b3;\n t18 += v * b4;\n t19 += v * b5;\n t20 += v * b6;\n t21 += v * b7;\n t22 += v * b8;\n t23 += v * b9;\n t24 += v * b10;\n t25 += v * b11;\n t26 += v * b12;\n t27 += v * b13;\n t28 += v * b14;\n t29 += v * b15;\n v = a[15];\n t15 += v * b0;\n t16 += v * b1;\n t17 += v * b2;\n t18 += v * b3;\n t19 += v * b4;\n t20 += v * b5;\n t21 += v * b6;\n t22 += v * b7;\n t23 += v * b8;\n t24 += v * b9;\n t25 += v * b10;\n t26 += v * b11;\n t27 += v * b12;\n t28 += v * b13;\n t29 += v * b14;\n t30 += v * b15;\n\n t0 += 38 * t16;\n t1 += 38 * t17;\n t2 += 38 * t18;\n t3 += 38 * t19;\n t4 += 38 * t20;\n t5 += 38 * t21;\n t6 += 38 * t22;\n t7 += 38 * t23;\n t8 += 38 * t24;\n t9 += 38 * t25;\n t10 += 38 * t26;\n t11 += 38 * t27;\n t12 += 38 * t28;\n t13 += 38 * t29;\n t14 += 38 * t30;\n // t15 left as is\n\n // first car\n c = 1;\n v = t0 + c + 65535; c = Math.floor(v / 65536); t0 = v - c * 65536;\n v = t1 + c + 65535; c = Math.floor(v / 65536); t1 = v - c * 65536;\n v = t2 + c + 65535; c = Math.floor(v / 65536); t2 = v - c * 65536;\n v = t3 + c + 65535; c = Math.floor(v / 65536); t3 = v - c * 65536;\n v = t4 + c + 65535; c = Math.floor(v / 65536); t4 = v - c * 65536;\n v = t5 + c + 65535; c = Math.floor(v / 65536); t5 = v - c * 65536;\n v = t6 + c + 65535; c = Math.floor(v / 65536); t6 = v - c * 65536;\n v = t7 + c + 65535; c = Math.floor(v / 65536); t7 = v - c * 65536;\n v = t8 + c + 65535; c = Math.floor(v / 65536); t8 = v - c * 65536;\n v = t9 + c + 65535; c = Math.floor(v / 65536); t9 = v - c * 65536;\n v = t10 + c + 65535; c = Math.floor(v / 65536); t10 = v - c * 65536;\n v = t11 + c + 65535; c = Math.floor(v / 65536); t11 = v - c * 65536;\n v = t12 + c + 65535; c = Math.floor(v / 65536); t12 = v - c * 65536;\n v = t13 + c + 65535; c = Math.floor(v / 65536); t13 = v - c * 65536;\n v = t14 + c + 65535; c = Math.floor(v / 65536); t14 = v - c * 65536;\n v = t15 + c + 65535; c = Math.floor(v / 65536); t15 = v - c * 65536;\n t0 += c-1 + 37 * (c-1);\n\n // second car\n c = 1;\n v = t0 + c + 65535; c = Math.floor(v / 65536); t0 = v - c * 65536;\n v = t1 + c + 65535; c = Math.floor(v / 65536); t1 = v - c * 65536;\n v = t2 + c + 65535; c = Math.floor(v / 65536); t2 = v - c * 65536;\n v = t3 + c + 65535; c = Math.floor(v / 65536); t3 = v - c * 65536;\n v = t4 + c + 65535; c = Math.floor(v / 65536); t4 = v - c * 65536;\n v = t5 + c + 65535; c = Math.floor(v / 65536); t5 = v - c * 65536;\n v = t6 + c + 65535; c = Math.floor(v / 65536); t6 = v - c * 65536;\n v = t7 + c + 65535; c = Math.floor(v / 65536); t7 = v - c * 65536;\n v = t8 + c + 65535; c = Math.floor(v / 65536); t8 = v - c * 65536;\n v = t9 + c + 65535; c = Math.floor(v / 65536); t9 = v - c * 65536;\n v = t10 + c + 65535; c = Math.floor(v / 65536); t10 = v - c * 65536;\n v = t11 + c + 65535; c = Math.floor(v / 65536); t11 = v - c * 65536;\n v = t12 + c + 65535; c = Math.floor(v / 65536); t12 = v - c * 65536;\n v = t13 + c + 65535; c = Math.floor(v / 65536); t13 = v - c * 65536;\n v = t14 + c + 65535; c = Math.floor(v / 65536); t14 = v - c * 65536;\n v = t15 + c + 65535; c = Math.floor(v / 65536); t15 = v - c * 65536;\n t0 += c-1 + 37 * (c-1);\n\n o[ 0] = t0;\n o[ 1] = t1;\n o[ 2] = t2;\n o[ 3] = t3;\n o[ 4] = t4;\n o[ 5] = t5;\n o[ 6] = t6;\n o[ 7] = t7;\n o[ 8] = t8;\n o[ 9] = t9;\n o[10] = t10;\n o[11] = t11;\n o[12] = t12;\n o[13] = t13;\n o[14] = t14;\n o[15] = t15;\n}\n\nfunction S(o, a) {\n M(o, a, a);\n}\n\nfunction inv25519(o, i) {\n var c = gf();\n var a;\n for (a = 0; a < 16; a++) c[a] = i[a];\n for (a = 253; a >= 0; a--) {\n S(c, c);\n if(a !== 2 && a !== 4) M(c, c, i);\n }\n for (a = 0; a < 16; a++) o[a] = c[a];\n}\n\nfunction pow2523(o, i) {\n var c = gf();\n var a;\n for (a = 0; a < 16; a++) c[a] = i[a];\n for (a = 250; a >= 0; a--) {\n S(c, c);\n if(a !== 1) M(c, c, i);\n }\n for (a = 0; a < 16; a++) o[a] = c[a];\n}\n\nfunction crypto_scalarmult(q, n, p) {\n var z = new Uint8Array(32);\n var x = new Float64Array(80), r, i;\n var a = gf(), b = gf(), c = gf(),\n d = gf(), e = gf(), f = gf();\n for (i = 0; i < 31; i++) z[i] = n[i];\n z[31]=(n[31]&127)|64;\n z[0]&=248;\n unpack25519(x,p);\n for (i = 0; i < 16; i++) {\n b[i]=x[i];\n d[i]=a[i]=c[i]=0;\n }\n a[0]=d[0]=1;\n for (i=254; i>=0; --i) {\n r=(z[i>>>3]>>>(i&7))&1;\n sel25519(a,b,r);\n sel25519(c,d,r);\n A(e,a,c);\n Z(a,a,c);\n A(c,b,d);\n Z(b,b,d);\n S(d,e);\n S(f,a);\n M(a,c,a);\n M(c,b,e);\n A(e,a,c);\n Z(a,a,c);\n S(b,a);\n Z(c,d,f);\n M(a,c,_121665);\n A(a,a,d);\n M(c,c,a);\n M(a,d,f);\n M(d,b,x);\n S(b,e);\n sel25519(a,b,r);\n sel25519(c,d,r);\n }\n for (i = 0; i < 16; i++) {\n x[i+16]=a[i];\n x[i+32]=c[i];\n x[i+48]=b[i];\n x[i+64]=d[i];\n }\n var x32 = x.subarray(32);\n var x16 = x.subarray(16);\n inv25519(x32,x32);\n M(x16,x16,x32);\n pack25519(q,x16);\n return 0;\n}\n\nfunction crypto_scalarmult_base(q, n) {\n return crypto_scalarmult(q, n, _9);\n}\n\nfunction crypto_box_keypair(y, x) {\n randombytes(x, 32);\n return crypto_scalarmult_base(y, x);\n}\n\nfunction crypto_box_beforenm(k, y, x) {\n var s = new Uint8Array(32);\n crypto_scalarmult(s, x, y);\n return crypto_core_hsalsa20(k, _0, s, sigma);\n}\n\nvar crypto_box_afternm = crypto_secretbox;\nvar crypto_box_open_afternm = crypto_secretbox_open;\n\nfunction crypto_box(c, m, d, n, y, x) {\n var k = new Uint8Array(32);\n crypto_box_beforenm(k, y, x);\n return crypto_box_afternm(c, m, d, n, k);\n}\n\nfunction crypto_box_open(m, c, d, n, y, x) {\n var k = new Uint8Array(32);\n crypto_box_beforenm(k, y, x);\n return crypto_box_open_afternm(m, c, d, n, k);\n}\n\nvar K = [\n 0x428a2f98, 0xd728ae22, 0x71374491, 0x23ef65cd,\n 0xb5c0fbcf, 0xec4d3b2f, 0xe9b5dba5, 0x8189dbbc,\n 0x3956c25b, 0xf348b538, 0x59f111f1, 0xb605d019,\n 0x923f82a4, 0xaf194f9b, 0xab1c5ed5, 0xda6d8118,\n 0xd807aa98, 0xa3030242, 0x12835b01, 0x45706fbe,\n 0x243185be, 0x4ee4b28c, 0x550c7dc3, 0xd5ffb4e2,\n 0x72be5d74, 0xf27b896f, 0x80deb1fe, 0x3b1696b1,\n 0x9bdc06a7, 0x25c71235, 0xc19bf174, 0xcf692694,\n 0xe49b69c1, 0x9ef14ad2, 0xefbe4786, 0x384f25e3,\n 0x0fc19dc6, 0x8b8cd5b5, 0x240ca1cc, 0x77ac9c65,\n 0x2de92c6f, 0x592b0275, 0x4a7484aa, 0x6ea6e483,\n 0x5cb0a9dc, 0xbd41fbd4, 0x76f988da, 0x831153b5,\n 0x983e5152, 0xee66dfab, 0xa831c66d, 0x2db43210,\n 0xb00327c8, 0x98fb213f, 0xbf597fc7, 0xbeef0ee4,\n 0xc6e00bf3, 0x3da88fc2, 0xd5a79147, 0x930aa725,\n 0x06ca6351, 0xe003826f, 0x14292967, 0x0a0e6e70,\n 0x27b70a85, 0x46d22ffc, 0x2e1b2138, 0x5c26c926,\n 0x4d2c6dfc, 0x5ac42aed, 0x53380d13, 0x9d95b3df,\n 0x650a7354, 0x8baf63de, 0x766a0abb, 0x3c77b2a8,\n 0x81c2c92e, 0x47edaee6, 0x92722c85, 0x1482353b,\n 0xa2bfe8a1, 0x4cf10364, 0xa81a664b, 0xbc423001,\n 0xc24b8b70, 0xd0f89791, 0xc76c51a3, 0x0654be30,\n 0xd192e819, 0xd6ef5218, 0xd6990624, 0x5565a910,\n 0xf40e3585, 0x5771202a, 0x106aa070, 0x32bbd1b8,\n 0x19a4c116, 0xb8d2d0c8, 0x1e376c08, 0x5141ab53,\n 0x2748774c, 0xdf8eeb99, 0x34b0bcb5, 0xe19b48a8,\n 0x391c0cb3, 0xc5c95a63, 0x4ed8aa4a, 0xe3418acb,\n 0x5b9cca4f, 0x7763e373, 0x682e6ff3, 0xd6b2b8a3,\n 0x748f82ee, 0x5defb2fc, 0x78a5636f, 0x43172f60,\n 0x84c87814, 0xa1f0ab72, 0x8cc70208, 0x1a6439ec,\n 0x90befffa, 0x23631e28, 0xa4506ceb, 0xde82bde9,\n 0xbef9a3f7, 0xb2c67915, 0xc67178f2, 0xe372532b,\n 0xca273ece, 0xea26619c, 0xd186b8c7, 0x21c0c207,\n 0xeada7dd6, 0xcde0eb1e, 0xf57d4f7f, 0xee6ed178,\n 0x06f067aa, 0x72176fba, 0x0a637dc5, 0xa2c898a6,\n 0x113f9804, 0xbef90dae, 0x1b710b35, 0x131c471b,\n 0x28db77f5, 0x23047d84, 0x32caab7b, 0x40c72493,\n 0x3c9ebe0a, 0x15c9bebc, 0x431d67c4, 0x9c100d4c,\n 0x4cc5d4be, 0xcb3e42b6, 0x597f299c, 0xfc657e2a,\n 0x5fcb6fab, 0x3ad6faec, 0x6c44198c, 0x4a475817\n];\n\nfunction crypto_hashblocks_hl(hh, hl, m, n) {\n var wh = new Int32Array(16), wl = new Int32Array(16),\n bh0, bh1, bh2, bh3, bh4, bh5, bh6, bh7,\n bl0, bl1, bl2, bl3, bl4, bl5, bl6, bl7,\n th, tl, i, j, h, l, a, b, c, d;\n\n var ah0 = hh[0],\n ah1 = hh[1],\n ah2 = hh[2],\n ah3 = hh[3],\n ah4 = hh[4],\n ah5 = hh[5],\n ah6 = hh[6],\n ah7 = hh[7],\n\n al0 = hl[0],\n al1 = hl[1],\n al2 = hl[2],\n al3 = hl[3],\n al4 = hl[4],\n al5 = hl[5],\n al6 = hl[6],\n al7 = hl[7];\n\n var pos = 0;\n while (n >= 128) {\n for (i = 0; i < 16; i++) {\n j = 8 * i + pos;\n wh[i] = (m[j+0] << 24) | (m[j+1] << 16) | (m[j+2] << 8) | m[j+3];\n wl[i] = (m[j+4] << 24) | (m[j+5] << 16) | (m[j+6] << 8) | m[j+7];\n }\n for (i = 0; i < 80; i++) {\n bh0 = ah0;\n bh1 = ah1;\n bh2 = ah2;\n bh3 = ah3;\n bh4 = ah4;\n bh5 = ah5;\n bh6 = ah6;\n bh7 = ah7;\n\n bl0 = al0;\n bl1 = al1;\n bl2 = al2;\n bl3 = al3;\n bl4 = al4;\n bl5 = al5;\n bl6 = al6;\n bl7 = al7;\n\n // add\n h = ah7;\n l = al7;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n // Sigma1\n h = ((ah4 >>> 14) | (al4 << (32-14))) ^ ((ah4 >>> 18) | (al4 << (32-18))) ^ ((al4 >>> (41-32)) | (ah4 << (32-(41-32))));\n l = ((al4 >>> 14) | (ah4 << (32-14))) ^ ((al4 >>> 18) | (ah4 << (32-18))) ^ ((ah4 >>> (41-32)) | (al4 << (32-(41-32))));\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // Ch\n h = (ah4 & ah5) ^ (~ah4 & ah6);\n l = (al4 & al5) ^ (~al4 & al6);\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // K\n h = K[i*2];\n l = K[i*2+1];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // w\n h = wh[i%16];\n l = wl[i%16];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n th = c & 0xffff | d << 16;\n tl = a & 0xffff | b << 16;\n\n // add\n h = th;\n l = tl;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n // Sigma0\n h = ((ah0 >>> 28) | (al0 << (32-28))) ^ ((al0 >>> (34-32)) | (ah0 << (32-(34-32)))) ^ ((al0 >>> (39-32)) | (ah0 << (32-(39-32))));\n l = ((al0 >>> 28) | (ah0 << (32-28))) ^ ((ah0 >>> (34-32)) | (al0 << (32-(34-32)))) ^ ((ah0 >>> (39-32)) | (al0 << (32-(39-32))));\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // Maj\n h = (ah0 & ah1) ^ (ah0 & ah2) ^ (ah1 & ah2);\n l = (al0 & al1) ^ (al0 & al2) ^ (al1 & al2);\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n bh7 = (c & 0xffff) | (d << 16);\n bl7 = (a & 0xffff) | (b << 16);\n\n // add\n h = bh3;\n l = bl3;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = th;\n l = tl;\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n bh3 = (c & 0xffff) | (d << 16);\n bl3 = (a & 0xffff) | (b << 16);\n\n ah1 = bh0;\n ah2 = bh1;\n ah3 = bh2;\n ah4 = bh3;\n ah5 = bh4;\n ah6 = bh5;\n ah7 = bh6;\n ah0 = bh7;\n\n al1 = bl0;\n al2 = bl1;\n al3 = bl2;\n al4 = bl3;\n al5 = bl4;\n al6 = bl5;\n al7 = bl6;\n al0 = bl7;\n\n if (i%16 === 15) {\n for (j = 0; j < 16; j++) {\n // add\n h = wh[j];\n l = wl[j];\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = wh[(j+9)%16];\n l = wl[(j+9)%16];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // sigma0\n th = wh[(j+1)%16];\n tl = wl[(j+1)%16];\n h = ((th >>> 1) | (tl << (32-1))) ^ ((th >>> 8) | (tl << (32-8))) ^ (th >>> 7);\n l = ((tl >>> 1) | (th << (32-1))) ^ ((tl >>> 8) | (th << (32-8))) ^ ((tl >>> 7) | (th << (32-7)));\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // sigma1\n th = wh[(j+14)%16];\n tl = wl[(j+14)%16];\n h = ((th >>> 19) | (tl << (32-19))) ^ ((tl >>> (61-32)) | (th << (32-(61-32)))) ^ (th >>> 6);\n l = ((tl >>> 19) | (th << (32-19))) ^ ((th >>> (61-32)) | (tl << (32-(61-32)))) ^ ((tl >>> 6) | (th << (32-6)));\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n wh[j] = (c & 0xffff) | (d << 16);\n wl[j] = (a & 0xffff) | (b << 16);\n }\n }\n }\n\n // add\n h = ah0;\n l = al0;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[0];\n l = hl[0];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[0] = ah0 = (c & 0xffff) | (d << 16);\n hl[0] = al0 = (a & 0xffff) | (b << 16);\n\n h = ah1;\n l = al1;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[1];\n l = hl[1];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[1] = ah1 = (c & 0xffff) | (d << 16);\n hl[1] = al1 = (a & 0xffff) | (b << 16);\n\n h = ah2;\n l = al2;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[2];\n l = hl[2];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[2] = ah2 = (c & 0xffff) | (d << 16);\n hl[2] = al2 = (a & 0xffff) | (b << 16);\n\n h = ah3;\n l = al3;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[3];\n l = hl[3];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[3] = ah3 = (c & 0xffff) | (d << 16);\n hl[3] = al3 = (a & 0xffff) | (b << 16);\n\n h = ah4;\n l = al4;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[4];\n l = hl[4];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[4] = ah4 = (c & 0xffff) | (d << 16);\n hl[4] = al4 = (a & 0xffff) | (b << 16);\n\n h = ah5;\n l = al5;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[5];\n l = hl[5];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[5] = ah5 = (c & 0xffff) | (d << 16);\n hl[5] = al5 = (a & 0xffff) | (b << 16);\n\n h = ah6;\n l = al6;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[6];\n l = hl[6];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[6] = ah6 = (c & 0xffff) | (d << 16);\n hl[6] = al6 = (a & 0xffff) | (b << 16);\n\n h = ah7;\n l = al7;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[7];\n l = hl[7];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[7] = ah7 = (c & 0xffff) | (d << 16);\n hl[7] = al7 = (a & 0xffff) | (b << 16);\n\n pos += 128;\n n -= 128;\n }\n\n return n;\n}\n\nfunction crypto_hash(out, m, n) {\n var hh = new Int32Array(8),\n hl = new Int32Array(8),\n x = new Uint8Array(256),\n i, b = n;\n\n hh[0] = 0x6a09e667;\n hh[1] = 0xbb67ae85;\n hh[2] = 0x3c6ef372;\n hh[3] = 0xa54ff53a;\n hh[4] = 0x510e527f;\n hh[5] = 0x9b05688c;\n hh[6] = 0x1f83d9ab;\n hh[7] = 0x5be0cd19;\n\n hl[0] = 0xf3bcc908;\n hl[1] = 0x84caa73b;\n hl[2] = 0xfe94f82b;\n hl[3] = 0x5f1d36f1;\n hl[4] = 0xade682d1;\n hl[5] = 0x2b3e6c1f;\n hl[6] = 0xfb41bd6b;\n hl[7] = 0x137e2179;\n\n crypto_hashblocks_hl(hh, hl, m, n);\n n %= 128;\n\n for (i = 0; i < n; i++) x[i] = m[b-n+i];\n x[n] = 128;\n\n n = 256-128*(n<112?1:0);\n x[n-9] = 0;\n ts64(x, n-8, (b / 0x20000000) | 0, b << 3);\n crypto_hashblocks_hl(hh, hl, x, n);\n\n for (i = 0; i < 8; i++) ts64(out, 8*i, hh[i], hl[i]);\n\n return 0;\n}\n\nfunction add(p, q) {\n var a = gf(), b = gf(), c = gf(),\n d = gf(), e = gf(), f = gf(),\n g = gf(), h = gf(), t = gf();\n\n Z(a, p[1], p[0]);\n Z(t, q[1], q[0]);\n M(a, a, t);\n A(b, p[0], p[1]);\n A(t, q[0], q[1]);\n M(b, b, t);\n M(c, p[3], q[3]);\n M(c, c, D2);\n M(d, p[2], q[2]);\n A(d, d, d);\n Z(e, b, a);\n Z(f, d, c);\n A(g, d, c);\n A(h, b, a);\n\n M(p[0], e, f);\n M(p[1], h, g);\n M(p[2], g, f);\n M(p[3], e, h);\n}\n\nfunction cswap(p, q, b) {\n var i;\n for (i = 0; i < 4; i++) {\n sel25519(p[i], q[i], b);\n }\n}\n\nfunction pack(r, p) {\n var tx = gf(), ty = gf(), zi = gf();\n inv25519(zi, p[2]);\n M(tx, p[0], zi);\n M(ty, p[1], zi);\n pack25519(r, ty);\n r[31] ^= par25519(tx) << 7;\n}\n\nfunction scalarmult(p, q, s) {\n var b, i;\n set25519(p[0], gf0);\n set25519(p[1], gf1);\n set25519(p[2], gf1);\n set25519(p[3], gf0);\n for (i = 255; i >= 0; --i) {\n b = (s[(i/8)|0] >> (i&7)) & 1;\n cswap(p, q, b);\n add(q, p);\n add(p, p);\n cswap(p, q, b);\n }\n}\n\nfunction scalarbase(p, s) {\n var q = [gf(), gf(), gf(), gf()];\n set25519(q[0], X);\n set25519(q[1], Y);\n set25519(q[2], gf1);\n M(q[3], X, Y);\n scalarmult(p, q, s);\n}\n\nfunction crypto_sign_keypair(pk, sk, seeded) {\n var d = new Uint8Array(64);\n var p = [gf(), gf(), gf(), gf()];\n var i;\n\n if (!seeded) randombytes(sk, 32);\n crypto_hash(d, sk, 32);\n d[0] &= 248;\n d[31] &= 127;\n d[31] |= 64;\n\n scalarbase(p, d);\n pack(pk, p);\n\n for (i = 0; i < 32; i++) sk[i+32] = pk[i];\n return 0;\n}\n\nvar L = new Float64Array([0xed, 0xd3, 0xf5, 0x5c, 0x1a, 0x63, 0x12, 0x58, 0xd6, 0x9c, 0xf7, 0xa2, 0xde, 0xf9, 0xde, 0x14, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x10]);\n\nfunction modL(r, x) {\n var carry, i, j, k;\n for (i = 63; i >= 32; --i) {\n carry = 0;\n for (j = i - 32, k = i - 12; j < k; ++j) {\n x[j] += carry - 16 * x[i] * L[j - (i - 32)];\n carry = Math.floor((x[j] + 128) / 256);\n x[j] -= carry * 256;\n }\n x[j] += carry;\n x[i] = 0;\n }\n carry = 0;\n for (j = 0; j < 32; j++) {\n x[j] += carry - (x[31] >> 4) * L[j];\n carry = x[j] >> 8;\n x[j] &= 255;\n }\n for (j = 0; j < 32; j++) x[j] -= carry * L[j];\n for (i = 0; i < 32; i++) {\n x[i+1] += x[i] >> 8;\n r[i] = x[i] & 255;\n }\n}\n\nfunction reduce(r) {\n var x = new Float64Array(64), i;\n for (i = 0; i < 64; i++) x[i] = r[i];\n for (i = 0; i < 64; i++) r[i] = 0;\n modL(r, x);\n}\n\n// Note: difference from C - smlen returned, not passed as argument.\nfunction crypto_sign(sm, m, n, sk) {\n var d = new Uint8Array(64), h = new Uint8Array(64), r = new Uint8Array(64);\n var i, j, x = new Float64Array(64);\n var p = [gf(), gf(), gf(), gf()];\n\n crypto_hash(d, sk, 32);\n d[0] &= 248;\n d[31] &= 127;\n d[31] |= 64;\n\n var smlen = n + 64;\n for (i = 0; i < n; i++) sm[64 + i] = m[i];\n for (i = 0; i < 32; i++) sm[32 + i] = d[32 + i];\n\n crypto_hash(r, sm.subarray(32), n+32);\n reduce(r);\n scalarbase(p, r);\n pack(sm, p);\n\n for (i = 32; i < 64; i++) sm[i] = sk[i];\n crypto_hash(h, sm, n + 64);\n reduce(h);\n\n for (i = 0; i < 64; i++) x[i] = 0;\n for (i = 0; i < 32; i++) x[i] = r[i];\n for (i = 0; i < 32; i++) {\n for (j = 0; j < 32; j++) {\n x[i+j] += h[i] * d[j];\n }\n }\n\n modL(sm.subarray(32), x);\n return smlen;\n}\n\nfunction unpackneg(r, p) {\n var t = gf(), chk = gf(), num = gf(),\n den = gf(), den2 = gf(), den4 = gf(),\n den6 = gf();\n\n set25519(r[2], gf1);\n unpack25519(r[1], p);\n S(num, r[1]);\n M(den, num, D);\n Z(num, num, r[2]);\n A(den, r[2], den);\n\n S(den2, den);\n S(den4, den2);\n M(den6, den4, den2);\n M(t, den6, num);\n M(t, t, den);\n\n pow2523(t, t);\n M(t, t, num);\n M(t, t, den);\n M(t, t, den);\n M(r[0], t, den);\n\n S(chk, r[0]);\n M(chk, chk, den);\n if (neq25519(chk, num)) M(r[0], r[0], I);\n\n S(chk, r[0]);\n M(chk, chk, den);\n if (neq25519(chk, num)) return -1;\n\n if (par25519(r[0]) === (p[31]>>7)) Z(r[0], gf0, r[0]);\n\n M(r[3], r[0], r[1]);\n return 0;\n}\n\nfunction crypto_sign_open(m, sm, n, pk) {\n var i;\n var t = new Uint8Array(32), h = new Uint8Array(64);\n var p = [gf(), gf(), gf(), gf()],\n q = [gf(), gf(), gf(), gf()];\n\n if (n < 64) return -1;\n\n if (unpackneg(q, pk)) return -1;\n\n for (i = 0; i < n; i++) m[i] = sm[i];\n for (i = 0; i < 32; i++) m[i+32] = pk[i];\n crypto_hash(h, m, n);\n reduce(h);\n scalarmult(p, q, h);\n\n scalarbase(q, sm.subarray(32));\n add(p, q);\n pack(t, p);\n\n n -= 64;\n if (crypto_verify_32(sm, 0, t, 0)) {\n for (i = 0; i < n; i++) m[i] = 0;\n return -1;\n }\n\n for (i = 0; i < n; i++) m[i] = sm[i + 64];\n return n;\n}\n\nvar crypto_secretbox_KEYBYTES = 32,\n crypto_secretbox_NONCEBYTES = 24,\n crypto_secretbox_ZEROBYTES = 32,\n crypto_secretbox_BOXZEROBYTES = 16,\n crypto_scalarmult_BYTES = 32,\n crypto_scalarmult_SCALARBYTES = 32,\n crypto_box_PUBLICKEYBYTES = 32,\n crypto_box_SECRETKEYBYTES = 32,\n crypto_box_BEFORENMBYTES = 32,\n crypto_box_NONCEBYTES = crypto_secretbox_NONCEBYTES,\n crypto_box_ZEROBYTES = crypto_secretbox_ZEROBYTES,\n crypto_box_BOXZEROBYTES = crypto_secretbox_BOXZEROBYTES,\n crypto_sign_BYTES = 64,\n crypto_sign_PUBLICKEYBYTES = 32,\n crypto_sign_SECRETKEYBYTES = 64,\n crypto_sign_SEEDBYTES = 32,\n crypto_hash_BYTES = 64;\n\nnacl.lowlevel = {\n crypto_core_hsalsa20: crypto_core_hsalsa20,\n crypto_stream_xor: crypto_stream_xor,\n crypto_stream: crypto_stream,\n crypto_stream_salsa20_xor: crypto_stream_salsa20_xor,\n crypto_stream_salsa20: crypto_stream_salsa20,\n crypto_onetimeauth: crypto_onetimeauth,\n crypto_onetimeauth_verify: crypto_onetimeauth_verify,\n crypto_verify_16: crypto_verify_16,\n crypto_verify_32: crypto_verify_32,\n crypto_secretbox: crypto_secretbox,\n crypto_secretbox_open: crypto_secretbox_open,\n crypto_scalarmult: crypto_scalarmult,\n crypto_scalarmult_base: crypto_scalarmult_base,\n crypto_box_beforenm: crypto_box_beforenm,\n crypto_box_afternm: crypto_box_afternm,\n crypto_box: crypto_box,\n crypto_box_open: crypto_box_open,\n crypto_box_keypair: crypto_box_keypair,\n crypto_hash: crypto_hash,\n crypto_sign: crypto_sign,\n crypto_sign_keypair: crypto_sign_keypair,\n crypto_sign_open: crypto_sign_open,\n\n crypto_secretbox_KEYBYTES: crypto_secretbox_KEYBYTES,\n crypto_secretbox_NONCEBYTES: crypto_secretbox_NONCEBYTES,\n crypto_secretbox_ZEROBYTES: crypto_secretbox_ZEROBYTES,\n crypto_secretbox_BOXZEROBYTES: crypto_secretbox_BOXZEROBYTES,\n crypto_scalarmult_BYTES: crypto_scalarmult_BYTES,\n crypto_scalarmult_SCALARBYTES: crypto_scalarmult_SCALARBYTES,\n crypto_box_PUBLICKEYBYTES: crypto_box_PUBLICKEYBYTES,\n crypto_box_SECRETKEYBYTES: crypto_box_SECRETKEYBYTES,\n crypto_box_BEFORENMBYTES: crypto_box_BEFORENMBYTES,\n crypto_box_NONCEBYTES: crypto_box_NONCEBYTES,\n crypto_box_ZEROBYTES: crypto_box_ZEROBYTES,\n crypto_box_BOXZEROBYTES: crypto_box_BOXZEROBYTES,\n crypto_sign_BYTES: crypto_sign_BYTES,\n crypto_sign_PUBLICKEYBYTES: crypto_sign_PUBLICKEYBYTES,\n crypto_sign_SECRETKEYBYTES: crypto_sign_SECRETKEYBYTES,\n crypto_sign_SEEDBYTES: crypto_sign_SEEDBYTES,\n crypto_hash_BYTES: crypto_hash_BYTES,\n\n gf: gf,\n D: D,\n L: L,\n pack25519: pack25519,\n unpack25519: unpack25519,\n M: M,\n A: A,\n S: S,\n Z: Z,\n pow2523: pow2523,\n add: add,\n set25519: set25519,\n modL: modL,\n scalarmult: scalarmult,\n scalarbase: scalarbase,\n};\n\n/* High-level API */\n\nfunction checkLengths(k, n) {\n if (k.length !== crypto_secretbox_KEYBYTES) throw new Error('bad key size');\n if (n.length !== crypto_secretbox_NONCEBYTES) throw new Error('bad nonce size');\n}\n\nfunction checkBoxLengths(pk, sk) {\n if (pk.length !== crypto_box_PUBLICKEYBYTES) throw new Error('bad public key size');\n if (sk.length !== crypto_box_SECRETKEYBYTES) throw new Error('bad secret key size');\n}\n\nfunction checkArrayTypes() {\n for (var i = 0; i < arguments.length; i++) {\n if (!(arguments[i] instanceof Uint8Array))\n throw new TypeError('unexpected type, use Uint8Array');\n }\n}\n\nfunction cleanup(arr) {\n for (var i = 0; i < arr.length; i++) arr[i] = 0;\n}\n\nnacl.randomBytes = function(n) {\n var b = new Uint8Array(n);\n randombytes(b, n);\n return b;\n};\n\nnacl.secretbox = function(msg, nonce, key) {\n checkArrayTypes(msg, nonce, key);\n checkLengths(key, nonce);\n var m = new Uint8Array(crypto_secretbox_ZEROBYTES + msg.length);\n var c = new Uint8Array(m.length);\n for (var i = 0; i < msg.length; i++) m[i+crypto_secretbox_ZEROBYTES] = msg[i];\n crypto_secretbox(c, m, m.length, nonce, key);\n return c.subarray(crypto_secretbox_BOXZEROBYTES);\n};\n\nnacl.secretbox.open = function(box, nonce, key) {\n checkArrayTypes(box, nonce, key);\n checkLengths(key, nonce);\n var c = new Uint8Array(crypto_secretbox_BOXZEROBYTES + box.length);\n var m = new Uint8Array(c.length);\n for (var i = 0; i < box.length; i++) c[i+crypto_secretbox_BOXZEROBYTES] = box[i];\n if (c.length < 32) return null;\n if (crypto_secretbox_open(m, c, c.length, nonce, key) !== 0) return null;\n return m.subarray(crypto_secretbox_ZEROBYTES);\n};\n\nnacl.secretbox.keyLength = crypto_secretbox_KEYBYTES;\nnacl.secretbox.nonceLength = crypto_secretbox_NONCEBYTES;\nnacl.secretbox.overheadLength = crypto_secretbox_BOXZEROBYTES;\n\nnacl.scalarMult = function(n, p) {\n checkArrayTypes(n, p);\n if (n.length !== crypto_scalarmult_SCALARBYTES) throw new Error('bad n size');\n if (p.length !== crypto_scalarmult_BYTES) throw new Error('bad p size');\n var q = new Uint8Array(crypto_scalarmult_BYTES);\n crypto_scalarmult(q, n, p);\n return q;\n};\n\nnacl.scalarMult.base = function(n) {\n checkArrayTypes(n);\n if (n.length !== crypto_scalarmult_SCALARBYTES) throw new Error('bad n size');\n var q = new Uint8Array(crypto_scalarmult_BYTES);\n crypto_scalarmult_base(q, n);\n return q;\n};\n\nnacl.scalarMult.scalarLength = crypto_scalarmult_SCALARBYTES;\nnacl.scalarMult.groupElementLength = crypto_scalarmult_BYTES;\n\nnacl.box = function(msg, nonce, publicKey, secretKey) {\n var k = nacl.box.before(publicKey, secretKey);\n return nacl.secretbox(msg, nonce, k);\n};\n\nnacl.box.before = function(publicKey, secretKey) {\n checkArrayTypes(publicKey, secretKey);\n checkBoxLengths(publicKey, secretKey);\n var k = new Uint8Array(crypto_box_BEFORENMBYTES);\n crypto_box_beforenm(k, publicKey, secretKey);\n return k;\n};\n\nnacl.box.after = nacl.secretbox;\n\nnacl.box.open = function(msg, nonce, publicKey, secretKey) {\n var k = nacl.box.before(publicKey, secretKey);\n return nacl.secretbox.open(msg, nonce, k);\n};\n\nnacl.box.open.after = nacl.secretbox.open;\n\nnacl.box.keyPair = function() {\n var pk = new Uint8Array(crypto_box_PUBLICKEYBYTES);\n var sk = new Uint8Array(crypto_box_SECRETKEYBYTES);\n crypto_box_keypair(pk, sk);\n return {publicKey: pk, secretKey: sk};\n};\n\nnacl.box.keyPair.fromSecretKey = function(secretKey) {\n checkArrayTypes(secretKey);\n if (secretKey.length !== crypto_box_SECRETKEYBYTES)\n throw new Error('bad secret key size');\n var pk = new Uint8Array(crypto_box_PUBLICKEYBYTES);\n crypto_scalarmult_base(pk, secretKey);\n return {publicKey: pk, secretKey: new Uint8Array(secretKey)};\n};\n\nnacl.box.publicKeyLength = crypto_box_PUBLICKEYBYTES;\nnacl.box.secretKeyLength = crypto_box_SECRETKEYBYTES;\nnacl.box.sharedKeyLength = crypto_box_BEFORENMBYTES;\nnacl.box.nonceLength = crypto_box_NONCEBYTES;\nnacl.box.overheadLength = nacl.secretbox.overheadLength;\n\nnacl.sign = function(msg, secretKey) {\n checkArrayTypes(msg, secretKey);\n if (secretKey.length !== crypto_sign_SECRETKEYBYTES)\n throw new Error('bad secret key size');\n var signedMsg = new Uint8Array(crypto_sign_BYTES+msg.length);\n crypto_sign(signedMsg, msg, msg.length, secretKey);\n return signedMsg;\n};\n\nnacl.sign.open = function(signedMsg, publicKey) {\n checkArrayTypes(signedMsg, publicKey);\n if (publicKey.length !== crypto_sign_PUBLICKEYBYTES)\n throw new Error('bad public key size');\n var tmp = new Uint8Array(signedMsg.length);\n var mlen = crypto_sign_open(tmp, signedMsg, signedMsg.length, publicKey);\n if (mlen < 0) return null;\n var m = new Uint8Array(mlen);\n for (var i = 0; i < m.length; i++) m[i] = tmp[i];\n return m;\n};\n\nnacl.sign.detached = function(msg, secretKey) {\n var signedMsg = nacl.sign(msg, secretKey);\n var sig = new Uint8Array(crypto_sign_BYTES);\n for (var i = 0; i < sig.length; i++) sig[i] = signedMsg[i];\n return sig;\n};\n\nnacl.sign.detached.verify = function(msg, sig, publicKey) {\n checkArrayTypes(msg, sig, publicKey);\n if (sig.length !== crypto_sign_BYTES)\n throw new Error('bad signature size');\n if (publicKey.length !== crypto_sign_PUBLICKEYBYTES)\n throw new Error('bad public key size');\n var sm = new Uint8Array(crypto_sign_BYTES + msg.length);\n var m = new Uint8Array(crypto_sign_BYTES + msg.length);\n var i;\n for (i = 0; i < crypto_sign_BYTES; i++) sm[i] = sig[i];\n for (i = 0; i < msg.length; i++) sm[i+crypto_sign_BYTES] = msg[i];\n return (crypto_sign_open(m, sm, sm.length, publicKey) >= 0);\n};\n\nnacl.sign.keyPair = function() {\n var pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);\n var sk = new Uint8Array(crypto_sign_SECRETKEYBYTES);\n crypto_sign_keypair(pk, sk);\n return {publicKey: pk, secretKey: sk};\n};\n\nnacl.sign.keyPair.fromSecretKey = function(secretKey) {\n checkArrayTypes(secretKey);\n if (secretKey.length !== crypto_sign_SECRETKEYBYTES)\n throw new Error('bad secret key size');\n var pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);\n for (var i = 0; i < pk.length; i++) pk[i] = secretKey[32+i];\n return {publicKey: pk, secretKey: new Uint8Array(secretKey)};\n};\n\nnacl.sign.keyPair.fromSeed = function(seed) {\n checkArrayTypes(seed);\n if (seed.length !== crypto_sign_SEEDBYTES)\n throw new Error('bad seed size');\n var pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);\n var sk = new Uint8Array(crypto_sign_SECRETKEYBYTES);\n for (var i = 0; i < 32; i++) sk[i] = seed[i];\n crypto_sign_keypair(pk, sk, true);\n return {publicKey: pk, secretKey: sk};\n};\n\nnacl.sign.publicKeyLength = crypto_sign_PUBLICKEYBYTES;\nnacl.sign.secretKeyLength = crypto_sign_SECRETKEYBYTES;\nnacl.sign.seedLength = crypto_sign_SEEDBYTES;\nnacl.sign.signatureLength = crypto_sign_BYTES;\n\nnacl.hash = function(msg) {\n checkArrayTypes(msg);\n var h = new Uint8Array(crypto_hash_BYTES);\n crypto_hash(h, msg, msg.length);\n return h;\n};\n\nnacl.hash.hashLength = crypto_hash_BYTES;\n\nnacl.verify = function(x, y) {\n checkArrayTypes(x, y);\n // Zero length arguments are considered not equal.\n if (x.length === 0 || y.length === 0) return false;\n if (x.length !== y.length) return false;\n return (vn(x, 0, y, 0, x.length) === 0) ? true : false;\n};\n\nnacl.setPRNG = function(fn) {\n randombytes = fn;\n};\n\n(function() {\n // Initialize PRNG if environment provides CSPRNG.\n // If not, methods calling randombytes will throw.\n var crypto = typeof self !== 'undefined' ? (self.crypto || self.msCrypto) : null;\n if (crypto && crypto.getRandomValues) {\n // Browsers.\n var QUOTA = 65536;\n nacl.setPRNG(function(x, n) {\n var i, v = new Uint8Array(n);\n for (i = 0; i < n; i += QUOTA) {\n crypto.getRandomValues(v.subarray(i, i + Math.min(n - i, QUOTA)));\n }\n for (i = 0; i < n; i++) x[i] = v[i];\n cleanup(v);\n });\n } else if (typeof require !== 'undefined') {\n // Node.js.\n crypto = require('crypto');\n if (crypto && crypto.randomBytes) {\n nacl.setPRNG(function(x, n) {\n var i, v = crypto.randomBytes(n);\n for (i = 0; i < n; i++) x[i] = v[i];\n cleanup(v);\n });\n }\n }\n})();\n\n})(typeof module !== 'undefined' && module.exports ? module.exports : (self.nacl = self.nacl || {}));\n","module.exports = require('./pusher-with-encryption').default;\n","import Pusher from './pusher';\nimport { Options, validateOptions } from './options';\nimport * as nacl from 'tweetnacl';\n\nexport default class PusherWithEncryption extends Pusher {\n constructor(app_key: string, options: Options) {\n Pusher.logToConsole = PusherWithEncryption.logToConsole;\n Pusher.log = PusherWithEncryption.log;\n\n validateOptions(options);\n options.nacl = nacl;\n super(app_key, options);\n }\n}\n"],"sourceRoot":""} \ No newline at end of file +{"version":3,"sources":["webpack://Pusher/webpack/bootstrap","webpack://Pusher/./src/core/utils/collections.ts","webpack://Pusher/./src/core/logger.ts","webpack://Pusher/./src/core/util.ts","webpack://Pusher/./src/core/events/dispatcher.ts","webpack://Pusher/./src/core/utils/timers/index.ts","webpack://Pusher/./src/core/defaults.ts","webpack://Pusher/./src/core/transports/url_schemes.ts","webpack://Pusher/./src/core/transports/transport_connection.ts","webpack://Pusher/./src/core/transports/transport.ts","webpack://Pusher/./src/runtimes/isomorphic/transports/transports.ts","webpack://Pusher/./src/core/transports/assistant_to_the_transport_manager.ts","webpack://Pusher/./src/core/connection/protocol/protocol.ts","webpack://Pusher/./src/core/connection/connection.ts","webpack://Pusher/./src/core/connection/handshake/index.ts","webpack://Pusher/./src/core/timeline/timeline_sender.ts","webpack://Pusher/./src/core/errors.ts","webpack://Pusher/./src/core/utils/url_store.ts","webpack://Pusher/./src/core/channels/channel.ts","webpack://Pusher/./src/core/channels/private_channel.ts","webpack://Pusher/./src/core/channels/members.ts","webpack://Pusher/./src/core/channels/presence_channel.ts","webpack://Pusher/./src/core/channels/encrypted_channel.ts","webpack://Pusher/./src/core/connection/connection_manager.ts","webpack://Pusher/./src/core/channels/channels.ts","webpack://Pusher/./src/core/utils/factory.ts","webpack://Pusher/./src/core/transports/transport_manager.ts","webpack://Pusher/./src/core/strategies/sequential_strategy.ts","webpack://Pusher/./src/core/strategies/best_connected_ever_strategy.ts","webpack://Pusher/./src/core/strategies/websocket_prioritized_cached_strategy.ts","webpack://Pusher/./src/core/strategies/delayed_strategy.ts","webpack://Pusher/./src/core/strategies/if_strategy.ts","webpack://Pusher/./src/core/strategies/first_connected_strategy.ts","webpack://Pusher/./src/runtimes/isomorphic/default_strategy.ts","webpack://Pusher/./src/core/http/http_request.ts","webpack://Pusher/./src/core/http/state.ts","webpack://Pusher/./src/core/http/http_socket.ts","webpack://Pusher/./src/core/http/http_streaming_socket.ts","webpack://Pusher/./src/core/http/http_polling_socket.ts","webpack://Pusher/./src/runtimes/isomorphic/http/http_xhr_request.ts","webpack://Pusher/./src/runtimes/isomorphic/runtime.ts","webpack://Pusher/./src/runtimes/isomorphic/transports/transport_connection_initializer.ts","webpack://Pusher/./src/runtimes/isomorphic/http/http.ts","webpack://Pusher/./src/runtimes/react-native/net_info.ts","webpack://Pusher/./src/core/auth/options.ts","webpack://Pusher/./src/runtimes/isomorphic/auth/xhr_auth.ts","webpack://Pusher/./src/runtimes/isomorphic/timeline/xhr_timeline.ts","webpack://Pusher/./src/runtimes/react-native/runtime.ts","webpack://Pusher/./src/core/timeline/level.ts","webpack://Pusher/./src/core/timeline/timeline.ts","webpack://Pusher/./src/core/strategies/transport_strategy.ts","webpack://Pusher/./src/core/strategies/strategy_builder.ts","webpack://Pusher/./src/core/auth/user_authenticator.ts","webpack://Pusher/./src/core/auth/channel_authorizer.ts","webpack://Pusher/./src/core/auth/deprecated_channel_authorizer.ts","webpack://Pusher/./src/core/config.ts","webpack://Pusher/./src/core/watchlist.ts","webpack://Pusher/./src/core/utils/flat_promise.ts","webpack://Pusher/./src/core/user.ts","webpack://Pusher/./src/core/pusher.ts","webpack://Pusher/(webpack)/buildin/global.js","webpack://Pusher/./src/core/options.ts","webpack://Pusher/./node_modules/@stablelib/base64/base64.ts","webpack://Pusher/./src/core/utils/timers/abstract_timer.ts","webpack://Pusher/external \"@react-native-community/netinfo\"","webpack://Pusher/./src/core/base64.ts","webpack://Pusher/./src/core/events/callback_registry.ts","webpack://Pusher/./node_modules/@stablelib/utf8/utf8.ts","webpack://Pusher/./node_modules/tweetnacl/nacl-fast.js","webpack://Pusher/./src/core/pusher-with-encryption.js","webpack://Pusher/./src/core/pusher-with-encryption.ts"],"names":["installedModules","__webpack_require__","moduleId","exports","module","i","l","modules","call","m","c","d","name","getter","o","Object","defineProperty","enumerable","get","r","Symbol","toStringTag","value","t","mode","__esModule","ns","create","key","bind","n","object","property","prototype","hasOwnProperty","p","s","extend","target","sources","length","extensions","constructor","stringify","arguments","push","safeJSONStringify","join","arrayIndexOf","array","item","nativeIndexOf","Array","indexOf","objectApply","f","keys","_","values","apply","context","global","map","result","filter","test","filterObject","Boolean","any","all","encodeParamsObject","data","encodeURIComponent","toString","buildQueryString","params","undefined","method","source","JSON","e","objects","paths","derez","path","nu","$ref","globalLog","message","console","log","args","this","globalLogWarn","globalLogError","warn","error","defaultLoggingFunction","logToConsole","Util","now","Date","valueOf","defer","callback","boundArguments","slice","concat","Dispatcher","failThrough","callbacks","global_callbacks","eventName","add","remove","unbind","unbind_global","metadata","fn","clearTimeout","timer","clearInterval","OneOffTimer","delay","super","setTimeout","PeriodicTimer","setInterval","VERSION","PROTOCOL","wsPort","wssPort","wsPath","httpHost","httpPort","httpsPort","httpPath","stats_host","authEndpoint","authTransport","activityTimeout","pongTimeout","unavailableTimeout","userAuthentication","endpoint","transport","channelAuthorization","cdn_http","cdn_https","dependency_suffix","getGenericURL","baseScheme","useTLS","hostTLS","hostNonTLS","getGenericPath","queryString","ws","getInitial","http","hooks","priority","options","initialize","transportConnectionInitializer","state","timeline","id","generateUniqueID","handlesActivityChecks","supportsPing","socket","url","urls","getSocket","onError","changeState","bindListeners","debug","close","send","ping","beforeOpen","getPath","onopen","emit","type","buildTimelineMessage","closeEvent","code","reason","wasClean","unbindListeners","onOpen","onerror","onclose","onClose","onmessage","onMessage","onactivity","onActivity","info","cid","environment","isSupported","WSTransport","isInitialized","getWebSocketAPI","createWebSocket","httpConfiguration","streamingConfiguration","HTTPFactory","createStreamingSocket","pollingConfiguration","createPollingSocket","xhrConfiguration","isXHRSupported","xhr_streaming","xhr_polling","manager","minPingDelay","maxPingDelay","pingDelay","connection","createConnection","openTimestamp","onClosed","reportDeath","lifespan","Math","max","isAlive","Protocol","decodeMessage","messageEvent","messageData","parse","pusherEventData","pusherEvent","event","channel","user_id","encodeMessage","processHandshake","activity_timeout","action","socket_id","getCloseAction","getCloseError","send_event","listeners","activity","closed","handleCloseEvent","listener","finish","isEmpty","TimelineTransport","getAgent","BadEventName","Error","msg","setPrototypeOf","BadChannelName","TransportPriorityTooLow","TransportClosed","UnsupportedFeature","UnsupportedTransport","UnsupportedStrategy","HTTPAuthError","status","urlStore","baseUrl","authenticationEndpoint","authorizationEndpoint","javascriptQuickStart","triggeringClientEvents","encryptedChannelSupport","fullUrl","urlObj","pusher","subscribed","subscriptionPending","subscriptionCancelled","socketId","auth","suffix","handleSubscriptionSucceededEvent","handleSubscriptionCountEvent","unsubscribe","subscription_count","subscriptionCount","authorize","assign","channel_data","config","channelAuthorizer","channelName","reset","members","member","myID","subscriptionData","presence","hash","count","me","memberData","user_info","authData","channelData","setMyID","user","signinDonePromise","user_data","handleInternalEvent","addedMember","addMember","removedMember","removeMember","onSubscription","disconnect","nacl","sharedSecret","handleEncryptedEvent","handleEvent","ciphertext","nonce","cipherText","secretbox","overheadLength","nonceLength","bytes","open","getDataToEmit","raw","usingTLS","errorCallbacks","buildErrorCallbacks","connectionCallbacks","buildConnectionCallbacks","handshakeCallbacks","buildHandshakeCallbacks","Network","getNetwork","netinfo","retryIn","sendActivityCheck","updateStrategy","runner","strategy","updateState","startConnecting","setUnavailableTimer","disconnectInternally","handshake","connect","handshakeError","abortConnecting","abort","clearRetryTimer","clearUnavailableTimer","abandonConnection","getStrategy","round","retryTimer","ensureAborted","unavailableTimer","stopActivityCheck","activityTimer","pong_timed_out","resetActivityCheck","shouldRetry","connected","min","Infinity","setConnection","withErrorEmitted","tls_only","refused","backoff","retry","newState","previousState","newStateDescription","previous","current","channels","createEncryptedChannel","errMsg","createPrivateChannel","createPresenceChannel","createChannel","createChannels","createConnectionManager","createTimelineSender","createHandshake","createAssistantToTheTransportManager","livesLeft","lives","strategies","loop","failFast","timeout","timeoutLimit","minPriority","tryNextStrategy","tryStrategy","forceMinPriority","isRunning","callbackBuilder","runners","rs","abortRunner","allRunnersFailed","aborted","transports","ttl","storage","getLocalStorage","serializedCache","getTransportCacheKey","flushTransportCache","fetchTransportCache","cacheSkipCount","timestamp","includes","cached","latency","startTimestamp","pop","cb","storeTransportCache","number","IfStrategy","trueBranch","falseBranch","FirstConnectedStrategy","testSupportsStrategy","baseOptions","defineTransport","definedTransports","defineTransportStrategy","wsStrategy","ws_options","wsHost","wss_options","http_options","timeouts","ws_manager","streaming_manager","ws_transport","wss_transport","xhr_streaming_transport","xhr_polling_transport","ws_loop","wss_loop","streaming_loop","polling_loop","http_loop","payload","position","xhr","getRequest","unloader","addUnloadListener","setRequestHeader","removeUnloadListener","abortRequest","chunk","advanceBuffer","isBufferTooLong","buffer","unreadData","endOfLinePosition","State","autoIncrement","getUniqueURL","separator","randomNumber","randomInt","session","randomString","location","parts","exec","base","getLocation","readyState","CONNECTING","openStream","sendRaw","sendHeartbeat","OPEN","createSocketRequest","start","closeStream","CLOSED","onEvent","onHeartbeat","hostname","urlParts","stream","getReceiveURL","onChunk","onFinished","reconnect","unbind_all","getXHRAPI","onreadystatechange","onprogress","responseText","getDefaultStrategy","Transports","createSocket","createRequest","PusherClass","ready","getClientFeatures","getProtocol","createXHR","hasOnlineConnectionState","connectionState","toLowerCase","online","fetch","then","addEventListener","isNowOnline","AuthRequestType","query","authOptions","authRequestType","headerName","headers","headersProvider","dynamicHeaders","parsed","UserAuthentication","ChannelAuthorization","sender","host","setup","TimelineLevel","getAuthorizers","ajax","WebSocket","XMLHttpRequest","floor","random","events","sent","uniqueID","level","limit","shift","ERROR","INFO","DEBUG","sendfn","bundle","lib","version","cluster","features","failAttempt","onInitialized","serializedTransport","transportClass","enabledTransports","disabledTransports","ignoreNullOrigin","getAssistant","deferred","paramsProvider","dynamicParams","composeChannelQuery","ChannelAuthorizerProxy","channelAuthorizerGenerator","deprecatedAuthorizerOptions","getConfig","opts","statsHost","enableStats","getEnableStatsConfig","getHttpHost","shouldUseTLS","getWebsocketHost","userAuthenticator","buildUserAuthenticator","buildChannelAuthorizer","timelineParams","forceTLS","disableStats","hasCustomHandler","customHandler","authorizer","buildChannelAuth","bindWatchlistInternalEvent","forEach","watchlistEvent","resolve","reject","promise","Promise","res","rej","signin_requested","serverToUserChannel","_signinDoneResolve","_onAuthorize","err","_cleanup","_signin","_newSigninPromiseIfNeeded","watchlist","_onSigninSuccess","_subscribeChannels","bind_global","reinstateSubscription","subscribe","ensure_subscribed","done","setDone","catch","isReady","instances","app_key","checkAppKey","global_emitter","sessionID","timelineSender","subscribeAll","isUsingTLS","internal","appKey","switchCluster","find","timelineSenderTimer","event_name","channel_name","cancelSubscription","signin","Runtime","ScriptReceivers","DependenciesReceivers","auth_callbacks","g","Function","window","validateOptions","_paddingCharacter","encodedLength","encode","out","_encodeByte","left","maxDecodedLength","decodedLength","_getPaddingLength","decode","Uint8Array","paddingLength","op","haveBad","v0","v1","v2","v3","_decodeChar","charCodeAt","b","String","fromCharCode","Coder","stdCoder","URLSafeCoder","urlSafeCoder","set","clear","require","btoa","utob","b64chars","b64tab","charAt","cb_utob","cc","u","replace","cb_encode","ccc","padlen","ord","CallbackRegistry","_callbacks","prefix","prefixedEventName","names","removeCallback","removeAllCallbacks","binding","INVALID_UTF8","arr","pos","chars","n1","n2","n3","gf","init","Float64Array","randombytes","_0","_9","gf0","gf1","_121665","D","D2","X","Y","I","ts64","x","h","vn","xi","y","yi","crypto_verify_16","crypto_verify_32","crypto_core_salsa20","inp","k","j0","j1","j2","j3","j4","j5","j6","j7","j8","j9","j10","j11","j12","j13","j14","j15","x0","x1","x2","x3","x4","x5","x6","x7","x8","x9","x10","x11","x12","x13","x14","x15","core_salsa20","crypto_core_hsalsa20","core_hsalsa20","sigma","crypto_stream_salsa20_xor","cpos","mpos","z","crypto_stream_salsa20","crypto_stream","sn","crypto_stream_xor","poly1305","t0","t1","t2","t3","t4","t5","t6","t7","Uint16Array","pad","leftover","fin","crypto_onetimeauth","outpos","update","crypto_onetimeauth_verify","hpos","crypto_secretbox","crypto_secretbox_open","set25519","a","car25519","v","sel25519","q","pack25519","j","neq25519","par25519","unpack25519","A","Z","M","t8","t9","t10","t11","t12","t13","t14","t15","t16","t17","t18","t19","t20","t21","t22","t23","t24","t25","t26","t27","t28","t29","t30","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","b10","b11","b12","b13","b14","b15","S","inv25519","pow2523","crypto_scalarmult","x32","subarray","x16","crypto_scalarmult_base","crypto_box_keypair","crypto_box_beforenm","blocks","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","hibit","h0","h1","h2","h3","h4","h5","h6","h7","h8","h9","r0","r1","r2","r3","r4","r5","r6","r7","r8","r9","mac","macpos","mask","want","crypto_box_afternm","crypto_box_open_afternm","K","crypto_hashblocks_hl","hh","hl","bh0","bh1","bh2","bh3","bh4","bh5","bh6","bh7","bl0","bl1","bl2","bl3","bl4","bl5","bl6","bl7","th","tl","wh","Int32Array","wl","ah0","ah1","ah2","ah3","ah4","ah5","ah6","ah7","al0","al1","al2","al3","al4","al5","al6","al7","crypto_hash","cswap","pack","tx","ty","zi","scalarmult","scalarbase","crypto_sign_keypair","pk","sk","seeded","L","modL","carry","reduce","crypto_sign","sm","smlen","crypto_sign_open","chk","num","den","den2","den4","den6","unpackneg","checkLengths","checkArrayTypes","TypeError","cleanup","lowlevel","crypto_box","crypto_box_open","crypto_secretbox_KEYBYTES","crypto_secretbox_NONCEBYTES","crypto_secretbox_ZEROBYTES","crypto_secretbox_BOXZEROBYTES","crypto_scalarmult_BYTES","crypto_scalarmult_SCALARBYTES","crypto_box_PUBLICKEYBYTES","crypto_box_SECRETKEYBYTES","crypto_box_BEFORENMBYTES","crypto_box_NONCEBYTES","crypto_box_ZEROBYTES","crypto_box_BOXZEROBYTES","crypto_sign_BYTES","crypto_sign_PUBLICKEYBYTES","crypto_sign_SECRETKEYBYTES","crypto_sign_SEEDBYTES","crypto_hash_BYTES","randomBytes","box","keyLength","scalarMult","scalarLength","groupElementLength","publicKey","secretKey","before","checkBoxLengths","after","keyPair","fromSecretKey","publicKeyLength","secretKeyLength","sharedKeyLength","sign","signedMsg","tmp","mlen","detached","sig","verify","fromSeed","seed","seedLength","signatureLength","hashLength","setPRNG","crypto","self","msCrypto","getRandomValues","default","PusherWithEncryption"],"mappings":";;;;;;;2BACE,IAAIA,EAAmB,GAGvB,SAASC,EAAoBC,GAG5B,GAAGF,EAAiBE,GACnB,OAAOF,EAAiBE,GAAUC,QAGnC,IAAIC,EAASJ,EAAiBE,GAAY,CACzCG,EAAGH,EACHI,GAAG,EACHH,QAAS,IAUV,OANAI,EAAQL,GAAUM,KAAKJ,EAAOD,QAASC,EAAQA,EAAOD,QAASF,GAG/DG,EAAOE,GAAI,EAGJF,EAAOD,QA0Df,OArDAF,EAAoBQ,EAAIF,EAGxBN,EAAoBS,EAAIV,EAGxBC,EAAoBU,EAAI,SAASR,EAASS,EAAMC,GAC3CZ,EAAoBa,EAAEX,EAASS,IAClCG,OAAOC,eAAeb,EAASS,EAAM,CAAEK,YAAY,EAAMC,IAAKL,KAKhEZ,EAAoBkB,EAAI,SAAShB,GACX,oBAAXiB,QAA0BA,OAAOC,aAC1CN,OAAOC,eAAeb,EAASiB,OAAOC,YAAa,CAAEC,MAAO,WAE7DP,OAAOC,eAAeb,EAAS,aAAc,CAAEmB,OAAO,KAQvDrB,EAAoBsB,EAAI,SAASD,EAAOE,GAEvC,GADU,EAAPA,IAAUF,EAAQrB,EAAoBqB,IAC/B,EAAPE,EAAU,OAAOF,EACpB,GAAW,EAAPE,GAA8B,iBAAVF,GAAsBA,GAASA,EAAMG,WAAY,OAAOH,EAChF,IAAII,EAAKX,OAAOY,OAAO,MAGvB,GAFA1B,EAAoBkB,EAAEO,GACtBX,OAAOC,eAAeU,EAAI,UAAW,CAAET,YAAY,EAAMK,MAAOA,IACtD,EAAPE,GAA4B,iBAATF,EAAmB,IAAI,IAAIM,KAAON,EAAOrB,EAAoBU,EAAEe,EAAIE,EAAK,SAASA,GAAO,OAAON,EAAMM,IAAQC,KAAK,KAAMD,IAC9I,OAAOF,GAIRzB,EAAoB6B,EAAI,SAAS1B,GAChC,IAAIS,EAAST,GAA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0rB,SAAQ,SAASxS,EAAGtrB,GACvB,IAAIzB,EAAG6xB,EAAI2N,EAAO7B,YAAYl8B,GAC9B,IAAKzB,EAAI,EAAGA,EAAIyB,EAAGzB,IAAK+sB,EAAE/sB,GAAK6xB,EAAE7xB,GACjCs8B,GAAQzK,MAtBhB,GA1zEA,CAs1EoC9xB,EAAOD,QAAUC,EAAOD,QAAW2/B,KAAK5rB,KAAO4rB,KAAK5rB,MAAQ,K,gBCt1EhG9T,EAAOD,QAAU,EAAQ,IAA4B8/B,S,6BCArD,yEAIe,MAAMC,UAA6B,IAChD,YAAY/Y,EAAiBjd,GAC3B,IAAOhE,aAAeg6B,EAAqBh6B,aAC3C,IAAOR,IAAMw6B,EAAqBx6B,IAElC,YAAgBwE,GAChBA,EAAQgK,KAAO,EACftM,MAAMuf,EAASjd,M","file":"pusher.js","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 15);\n","import base64encode from '../base64';\nimport Util from '../util';\n\n/** Merges multiple objects into the target argument.\n *\n * For properties that are plain Objects, performs a deep-merge. For the\n * rest it just copies the value of the property.\n *\n * To extend prototypes use it as following:\n * Pusher.Util.extend(Target.prototype, Base.prototype)\n *\n * You can also use it to merge objects without altering them:\n * Pusher.Util.extend({}, object1, object2)\n *\n * @param {Object} target\n * @return {Object} the target argument\n */\nexport function extend(target: any, ...sources: any[]): T {\n for (var i = 0; i < sources.length; i++) {\n var extensions = sources[i];\n for (var property in extensions) {\n if (\n extensions[property] &&\n extensions[property].constructor &&\n extensions[property].constructor === Object\n ) {\n target[property] = extend(target[property] || {}, extensions[property]);\n } else {\n target[property] = extensions[property];\n }\n }\n }\n return target;\n}\n\nexport function stringify(): string {\n var m = ['Pusher'];\n for (var i = 0; i < arguments.length; i++) {\n if (typeof arguments[i] === 'string') {\n m.push(arguments[i]);\n } else {\n m.push(safeJSONStringify(arguments[i]));\n }\n }\n return m.join(' : ');\n}\n\nexport function arrayIndexOf(array: any[], item: any): number {\n // MSIE doesn't have array.indexOf\n var nativeIndexOf = Array.prototype.indexOf;\n if (array === null) {\n return -1;\n }\n if (nativeIndexOf && array.indexOf === nativeIndexOf) {\n return array.indexOf(item);\n }\n for (var i = 0, l = array.length; i < l; i++) {\n if (array[i] === item) {\n return i;\n }\n }\n return -1;\n}\n\n/** Applies a function f to all properties of an object.\n *\n * Function f gets 3 arguments passed:\n * - element from the object\n * - key of the element\n * - reference to the object\n *\n * @param {Object} object\n * @param {Function} f\n */\nexport function objectApply(object: any, f: Function) {\n for (var key in object) {\n if (Object.prototype.hasOwnProperty.call(object, key)) {\n f(object[key], key, object);\n }\n }\n}\n\n/** Return a list of objects own proerty keys\n *\n * @param {Object} object\n * @returns {Array}\n */\nexport function keys(object: any): string[] {\n var keys = [];\n objectApply(object, function(_, key) {\n keys.push(key);\n });\n return keys;\n}\n\n/** Return a list of object's own property values\n *\n * @param {Object} object\n * @returns {Array}\n */\nexport function values(object: any): any[] {\n var values = [];\n objectApply(object, function(value) {\n values.push(value);\n });\n return values;\n}\n\n/** Applies a function f to all elements of an array.\n *\n * Function f gets 3 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function apply(array: any[], f: Function, context?: any) {\n for (var i = 0; i < array.length; i++) {\n f.call(context || global, array[i], i, array);\n }\n}\n\n/** Maps all elements of the array and returns the result.\n *\n * Function f gets 4 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n * - reference to the destination array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function map(array: any[], f: Function): any[] {\n var result = [];\n for (var i = 0; i < array.length; i++) {\n result.push(f(array[i], i, array, result));\n }\n return result;\n}\n\n/** Maps all elements of the object and returns the result.\n *\n * Function f gets 4 arguments passed:\n * - element from the object\n * - key of the element\n * - reference to the source object\n * - reference to the destination object\n *\n * @param {Object} object\n * @param {Function} f\n */\nexport function mapObject(object: any, f: Function): any {\n var result = {};\n objectApply(object, function(value, key) {\n result[key] = f(value);\n });\n return result;\n}\n\n/** Filters elements of the array using a test function.\n *\n * Function test gets 4 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n * - reference to the destination array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function filter(array: any[], test: Function): any[] {\n test =\n test ||\n function(value) {\n return !!value;\n };\n\n var result = [];\n for (var i = 0; i < array.length; i++) {\n if (test(array[i], i, array, result)) {\n result.push(array[i]);\n }\n }\n return result;\n}\n\n/** Filters properties of the object using a test function.\n *\n * Function test gets 4 arguments passed:\n * - element from the object\n * - key of the element\n * - reference to the source object\n * - reference to the destination object\n *\n * @param {Object} object\n * @param {Function} f\n */\nexport function filterObject(object: Object, test: Function) {\n var result = {};\n objectApply(object, function(value, key) {\n if ((test && test(value, key, object, result)) || Boolean(value)) {\n result[key] = value;\n }\n });\n return result;\n}\n\n/** Flattens an object into a two-dimensional array.\n *\n * @param {Object} object\n * @return {Array} resulting array of [key, value] pairs\n */\nexport function flatten(object: Object): any[] {\n var result = [];\n objectApply(object, function(value, key) {\n result.push([key, value]);\n });\n return result;\n}\n\n/** Checks whether any element of the array passes the test.\n *\n * Function test gets 3 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function any(array: any[], test: Function): boolean {\n for (var i = 0; i < array.length; i++) {\n if (test(array[i], i, array)) {\n return true;\n }\n }\n return false;\n}\n\n/** Checks whether all elements of the array pass the test.\n *\n * Function test gets 3 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function all(array: any[], test: Function): boolean {\n for (var i = 0; i < array.length; i++) {\n if (!test(array[i], i, array)) {\n return false;\n }\n }\n return true;\n}\n\nexport function encodeParamsObject(data): string {\n return mapObject(data, function(value) {\n if (typeof value === 'object') {\n value = safeJSONStringify(value);\n }\n return encodeURIComponent(base64encode(value.toString()));\n });\n}\n\nexport function buildQueryString(data: any): string {\n var params = filterObject(data, function(value) {\n return value !== undefined;\n });\n\n var query = map(\n flatten(encodeParamsObject(params)),\n Util.method('join', '=')\n ).join('&');\n\n return query;\n}\n\n/**\n * See https://github.com/douglascrockford/JSON-js/blob/master/cycle.js\n *\n * Remove circular references from an object. Required for JSON.stringify in\n * React Native, which tends to blow up a lot.\n *\n * @param {any} object\n * @return {any} Decycled object\n */\nexport function decycleObject(object: any): any {\n var objects = [],\n paths = [];\n\n return (function derez(value, path) {\n var i, name, nu;\n\n switch (typeof value) {\n case 'object':\n if (!value) {\n return null;\n }\n for (i = 0; i < objects.length; i += 1) {\n if (objects[i] === value) {\n return { $ref: paths[i] };\n }\n }\n\n objects.push(value);\n paths.push(path);\n\n if (Object.prototype.toString.apply(value) === '[object Array]') {\n nu = [];\n for (i = 0; i < value.length; i += 1) {\n nu[i] = derez(value[i], path + '[' + i + ']');\n }\n } else {\n nu = {};\n for (name in value) {\n if (Object.prototype.hasOwnProperty.call(value, name)) {\n nu[name] = derez(\n value[name],\n path + '[' + JSON.stringify(name) + ']'\n );\n }\n }\n }\n return nu;\n case 'number':\n case 'string':\n case 'boolean':\n return value;\n }\n })(object, '$');\n}\n\n/**\n * Provides a cross-browser and cross-platform way to safely stringify objects\n * into JSON. This is particularly necessary for ReactNative, where circular JSON\n * structures throw an exception.\n *\n * @param {any} source The object to stringify\n * @return {string} The serialized output.\n */\nexport function safeJSONStringify(source: any): string {\n try {\n return JSON.stringify(source);\n } catch (e) {\n return JSON.stringify(decycleObject(source));\n }\n}\n","import { stringify } from './utils/collections';\nimport Pusher from './pusher';\n\nclass Logger {\n debug(...args: any[]) {\n this.log(this.globalLog, args);\n }\n\n warn(...args: any[]) {\n this.log(this.globalLogWarn, args);\n }\n\n error(...args: any[]) {\n this.log(this.globalLogError, args);\n }\n\n private globalLog = (message: string) => {\n if (global.console && global.console.log) {\n global.console.log(message);\n }\n };\n\n private globalLogWarn(message: string) {\n if (global.console && global.console.warn) {\n global.console.warn(message);\n } else {\n this.globalLog(message);\n }\n }\n\n private globalLogError(message: string) {\n if (global.console && global.console.error) {\n global.console.error(message);\n } else {\n this.globalLogWarn(message);\n }\n }\n\n private log(\n defaultLoggingFunction: (message: string) => void,\n ...args: any[]\n ) {\n var message = stringify.apply(this, arguments);\n if (Pusher.log) {\n Pusher.log(message);\n } else if (Pusher.logToConsole) {\n const log = defaultLoggingFunction.bind(this);\n log(message);\n }\n }\n}\n\nexport default new Logger();\n","import * as Collections from './utils/collections';\nimport TimedCallback from './utils/timers/timed_callback';\nimport { OneOffTimer, PeriodicTimer } from './utils/timers';\n\nvar Util = {\n now(): number {\n if (Date.now) {\n return Date.now();\n } else {\n return new Date().valueOf();\n }\n },\n\n defer(callback: TimedCallback): OneOffTimer {\n return new OneOffTimer(0, callback);\n },\n\n /** Builds a function that will proxy a method call to its first argument.\n *\n * Allows partial application of arguments, so additional arguments are\n * prepended to the argument list.\n *\n * @param {String} name method name\n * @return {Function} proxy function\n */\n method(name: string, ...args: any[]): Function {\n var boundArguments = Array.prototype.slice.call(arguments, 1);\n return function(object) {\n return object[name].apply(object, boundArguments.concat(arguments));\n };\n }\n};\n\nexport default Util;\n","import * as Collections from '../utils/collections';\nimport Callback from './callback';\nimport Metadata from '../channels/metadata';\nimport CallbackRegistry from './callback_registry';\n\n/** Manages callback bindings and event emitting.\n *\n * @param Function failThrough called when no listeners are bound to an event\n */\nexport default class Dispatcher {\n callbacks: CallbackRegistry;\n global_callbacks: Function[];\n failThrough: Function;\n\n constructor(failThrough?: Function) {\n this.callbacks = new CallbackRegistry();\n this.global_callbacks = [];\n this.failThrough = failThrough;\n }\n\n bind(eventName: string, callback: Function, context?: any) {\n this.callbacks.add(eventName, callback, context);\n return this;\n }\n\n bind_global(callback: Function) {\n this.global_callbacks.push(callback);\n return this;\n }\n\n unbind(eventName?: string, callback?: Function, context?: any) {\n this.callbacks.remove(eventName, callback, context);\n return this;\n }\n\n unbind_global(callback?: Function) {\n if (!callback) {\n this.global_callbacks = [];\n return this;\n }\n\n this.global_callbacks = Collections.filter(\n this.global_callbacks || [],\n c => c !== callback\n );\n\n return this;\n }\n\n unbind_all() {\n this.unbind();\n this.unbind_global();\n return this;\n }\n\n emit(eventName: string, data?: any, metadata?: Metadata): Dispatcher {\n for (var i = 0; i < this.global_callbacks.length; i++) {\n this.global_callbacks[i](eventName, data);\n }\n\n var callbacks = this.callbacks.get(eventName);\n var args = [];\n\n if (metadata) {\n // if there's a metadata argument, we need to call the callback with both\n // data and metadata regardless of whether data is undefined\n args.push(data, metadata);\n } else if (data) {\n // metadata is undefined, so we only need to call the callback with data\n // if data exists\n args.push(data);\n }\n\n if (callbacks && callbacks.length > 0) {\n for (var i = 0; i < callbacks.length; i++) {\n callbacks[i].fn.apply(callbacks[i].context || global, args);\n }\n } else if (this.failThrough) {\n this.failThrough(eventName, data);\n }\n\n return this;\n }\n}\n","import Timer from './abstract_timer';\nimport TimedCallback from './timed_callback';\nimport { Delay } from './scheduling';\n\n// We need to bind clear functions this way to avoid exceptions on IE8\nfunction clearTimeout(timer) {\n global.clearTimeout(timer);\n}\nfunction clearInterval(timer) {\n global.clearInterval(timer);\n}\n\n/** Cross-browser compatible one-off timer abstraction.\n *\n * @param {Number} delay\n * @param {Function} callback\n */\nexport class OneOffTimer extends Timer {\n constructor(delay: Delay, callback: TimedCallback) {\n super(setTimeout, clearTimeout, delay, function(timer) {\n callback();\n return null;\n });\n }\n}\n\n/** Cross-browser compatible periodic timer abstraction.\n *\n * @param {Number} delay\n * @param {Function} callback\n */\nexport class PeriodicTimer extends Timer {\n constructor(delay: Delay, callback: TimedCallback) {\n super(setInterval, clearInterval, delay, function(timer) {\n callback();\n return timer;\n });\n }\n}\n","import {\n ChannelAuthorizationOptions,\n UserAuthenticationOptions\n} from './auth/options';\nimport { AuthTransport } from './config';\n\nexport interface DefaultConfig {\n VERSION: string;\n PROTOCOL: number;\n wsPort: number;\n wssPort: number;\n wsPath: string;\n httpHost: string;\n httpPort: number;\n httpsPort: number;\n httpPath: string;\n stats_host: string;\n authEndpoint: string;\n authTransport: AuthTransport;\n activityTimeout: number;\n pongTimeout: number;\n unavailableTimeout: number;\n userAuthentication: UserAuthenticationOptions;\n channelAuthorization: ChannelAuthorizationOptions;\n\n cdn_http?: string;\n cdn_https?: string;\n dependency_suffix?: string;\n}\n\nvar Defaults: DefaultConfig = {\n VERSION: VERSION,\n PROTOCOL: 7,\n\n wsPort: 80,\n wssPort: 443,\n wsPath: '',\n // DEPRECATED: SockJS fallback parameters\n httpHost: 'sockjs.pusher.com',\n httpPort: 80,\n httpsPort: 443,\n httpPath: '/pusher',\n // DEPRECATED: Stats\n stats_host: 'stats.pusher.com',\n // DEPRECATED: Other settings\n authEndpoint: '/pusher/auth',\n authTransport: 'ajax',\n activityTimeout: 120000,\n pongTimeout: 30000,\n unavailableTimeout: 10000,\n userAuthentication: {\n endpoint: '/pusher/user-auth',\n transport: 'ajax'\n },\n channelAuthorization: {\n endpoint: '/pusher/auth',\n transport: 'ajax'\n },\n\n // CDN configuration\n cdn_http: CDN_HTTP,\n cdn_https: CDN_HTTPS,\n dependency_suffix: DEPENDENCY_SUFFIX\n};\n\nexport default Defaults;\n","import Defaults from '../defaults';\nimport { default as URLScheme, URLSchemeParams } from './url_scheme';\n\nfunction getGenericURL(\n baseScheme: string,\n params: URLSchemeParams,\n path: string\n): string {\n var scheme = baseScheme + (params.useTLS ? 's' : '');\n var host = params.useTLS ? params.hostTLS : params.hostNonTLS;\n return scheme + '://' + host + path;\n}\n\nfunction getGenericPath(key: string, queryString?: string): string {\n var path = '/app/' + key;\n var query =\n '?protocol=' +\n Defaults.PROTOCOL +\n '&client=js' +\n '&version=' +\n Defaults.VERSION +\n (queryString ? '&' + queryString : '');\n return path + query;\n}\n\nexport var ws: URLScheme = {\n getInitial: function(key: string, params: URLSchemeParams): string {\n var path = (params.httpPath || '') + getGenericPath(key, 'flash=false');\n return getGenericURL('ws', params, path);\n }\n};\n\nexport var http: URLScheme = {\n getInitial: function(key: string, params: URLSchemeParams): string {\n var path = (params.httpPath || '/pusher') + getGenericPath(key);\n return getGenericURL('http', params, path);\n }\n};\n\nexport var sockjs: URLScheme = {\n getInitial: function(key: string, params: URLSchemeParams): string {\n return getGenericURL('http', params, params.httpPath || '/pusher');\n },\n getPath: function(key: string, params: URLSchemeParams): string {\n return getGenericPath(key);\n }\n};\n","import Util from '../util';\nimport * as Collections from '../utils/collections';\nimport { default as EventsDispatcher } from '../events/dispatcher';\nimport Logger from '../logger';\nimport TransportHooks from './transport_hooks';\nimport Socket from '../socket';\nimport Runtime from 'runtime';\nimport Timeline from '../timeline/timeline';\nimport TransportConnectionOptions from './transport_connection_options';\n\n/** Provides universal API for transport connections.\n *\n * Transport connection is a low-level object that wraps a connection method\n * and exposes a simple evented interface for the connection state and\n * messaging. It does not implement Pusher-specific WebSocket protocol.\n *\n * Additionally, it fetches resources needed for transport to work and exposes\n * an interface for querying transport features.\n *\n * States:\n * - new - initial state after constructing the object\n * - initializing - during initialization phase, usually fetching resources\n * - intialized - ready to establish a connection\n * - connection - when connection is being established\n * - open - when connection ready to be used\n * - closed - after connection was closed be either side\n *\n * Emits:\n * - error - after the connection raised an error\n *\n * Options:\n * - useTLS - whether connection should be over TLS\n * - hostTLS - host to connect to when connection is over TLS\n * - hostNonTLS - host to connect to when connection is over TLS\n *\n * @param {String} key application key\n * @param {Object} options\n */\nexport default class TransportConnection extends EventsDispatcher {\n hooks: TransportHooks;\n name: string;\n priority: number;\n key: string;\n options: TransportConnectionOptions;\n state: string;\n timeline: Timeline;\n activityTimeout: number;\n id: number;\n socket: Socket;\n beforeOpen: Function;\n initialize: Function;\n\n constructor(\n hooks: TransportHooks,\n name: string,\n priority: number,\n key: string,\n options: TransportConnectionOptions\n ) {\n super();\n this.initialize = Runtime.transportConnectionInitializer;\n this.hooks = hooks;\n this.name = name;\n this.priority = priority;\n this.key = key;\n this.options = options;\n\n this.state = 'new';\n this.timeline = options.timeline;\n this.activityTimeout = options.activityTimeout;\n this.id = this.timeline.generateUniqueID();\n }\n\n /** Checks whether the transport handles activity checks by itself.\n *\n * @return {Boolean}\n */\n handlesActivityChecks(): boolean {\n return Boolean(this.hooks.handlesActivityChecks);\n }\n\n /** Checks whether the transport supports the ping/pong API.\n *\n * @return {Boolean}\n */\n supportsPing(): boolean {\n return Boolean(this.hooks.supportsPing);\n }\n\n /** Tries to establish a connection.\n *\n * @returns {Boolean} false if transport is in invalid state\n */\n connect(): boolean {\n if (this.socket || this.state !== 'initialized') {\n return false;\n }\n\n var url = this.hooks.urls.getInitial(this.key, this.options);\n try {\n this.socket = this.hooks.getSocket(url, this.options);\n } catch (e) {\n Util.defer(() => {\n this.onError(e);\n this.changeState('closed');\n });\n return false;\n }\n\n this.bindListeners();\n\n Logger.debug('Connecting', { transport: this.name, url });\n this.changeState('connecting');\n return true;\n }\n\n /** Closes the connection.\n *\n * @return {Boolean} true if there was a connection to close\n */\n close(): boolean {\n if (this.socket) {\n this.socket.close();\n return true;\n } else {\n return false;\n }\n }\n\n /** Sends data over the open connection.\n *\n * @param {String} data\n * @return {Boolean} true only when in the \"open\" state\n */\n send(data: any): boolean {\n if (this.state === 'open') {\n // Workaround for MobileSafari bug (see https://gist.github.com/2052006)\n Util.defer(() => {\n if (this.socket) {\n this.socket.send(data);\n }\n });\n return true;\n } else {\n return false;\n }\n }\n\n /** Sends a ping if the connection is open and transport supports it. */\n ping() {\n if (this.state === 'open' && this.supportsPing()) {\n this.socket.ping();\n }\n }\n\n private onOpen() {\n if (this.hooks.beforeOpen) {\n this.hooks.beforeOpen(\n this.socket,\n this.hooks.urls.getPath(this.key, this.options)\n );\n }\n this.changeState('open');\n this.socket.onopen = undefined;\n }\n\n private onError(error) {\n this.emit('error', { type: 'WebSocketError', error: error });\n this.timeline.error(this.buildTimelineMessage({ error: error.toString() }));\n }\n\n private onClose(closeEvent?: any) {\n if (closeEvent) {\n this.changeState('closed', {\n code: closeEvent.code,\n reason: closeEvent.reason,\n wasClean: closeEvent.wasClean\n });\n } else {\n this.changeState('closed');\n }\n this.unbindListeners();\n this.socket = undefined;\n }\n\n private onMessage(message) {\n this.emit('message', message);\n }\n\n private onActivity() {\n this.emit('activity');\n }\n\n private bindListeners() {\n this.socket.onopen = () => {\n this.onOpen();\n };\n this.socket.onerror = error => {\n this.onError(error);\n };\n this.socket.onclose = closeEvent => {\n this.onClose(closeEvent);\n };\n this.socket.onmessage = message => {\n this.onMessage(message);\n };\n\n if (this.supportsPing()) {\n this.socket.onactivity = () => {\n this.onActivity();\n };\n }\n }\n\n private unbindListeners() {\n if (this.socket) {\n this.socket.onopen = undefined;\n this.socket.onerror = undefined;\n this.socket.onclose = undefined;\n this.socket.onmessage = undefined;\n if (this.supportsPing()) {\n this.socket.onactivity = undefined;\n }\n }\n }\n\n private changeState(state: string, params?: any) {\n this.state = state;\n this.timeline.info(\n this.buildTimelineMessage({\n state: state,\n params: params\n })\n );\n this.emit(state, params);\n }\n\n buildTimelineMessage(message): any {\n return Collections.extend({ cid: this.id }, message);\n }\n}\n","import Factory from '../utils/factory';\nimport TransportHooks from './transport_hooks';\nimport TransportConnection from './transport_connection';\nimport TransportConnectionOptions from './transport_connection_options';\n\n/** Provides interface for transport connection instantiation.\n *\n * Takes transport-specific hooks as the only argument, which allow checking\n * for transport support and creating its connections.\n *\n * Supported hooks: * - file - the name of the file to be fetched during initialization\n * - urls - URL scheme to be used by transport\n * - handlesActivityCheck - true when the transport handles activity checks\n * - supportsPing - true when the transport has a ping/activity API\n * - isSupported - tells whether the transport is supported in the environment\n * - getSocket - creates a WebSocket-compatible transport socket\n *\n * See transports.js for specific implementations.\n *\n * @param {Object} hooks object containing all needed transport hooks\n */\nexport default class Transport {\n hooks: TransportHooks;\n\n constructor(hooks: TransportHooks) {\n this.hooks = hooks;\n }\n\n /** Returns whether the transport is supported in the environment.\n *\n * @param {Object} envronment te environment details (encryption, settings)\n * @returns {Boolean} true when the transport is supported\n */\n isSupported(environment: any): boolean {\n return this.hooks.isSupported(environment);\n }\n\n /** Creates a transport connection.\n *\n * @param {String} name\n * @param {Number} priority\n * @param {String} key the application key\n * @param {Object} options\n * @returns {TransportConnection}\n */\n createConnection(\n name: string,\n priority: number,\n key: string,\n options: any\n ): TransportConnection {\n return new TransportConnection(this.hooks, name, priority, key, options);\n }\n}\n","import * as URLSchemes from 'core/transports/url_schemes';\nimport URLScheme from 'core/transports/url_scheme';\nimport Transport from 'core/transports/transport';\nimport Util from 'core/util';\nimport * as Collections from 'core/utils/collections';\nimport TransportHooks from 'core/transports/transport_hooks';\nimport TransportsTable from 'core/transports/transports_table';\nimport Runtime from 'runtime';\n\n/** WebSocket transport.\n *\n * Uses native WebSocket implementation, including MozWebSocket supported by\n * earlier Firefox versions.\n */\nvar WSTransport = new Transport({\n urls: URLSchemes.ws,\n handlesActivityChecks: false,\n supportsPing: false,\n\n isInitialized: function() {\n return Boolean(Runtime.getWebSocketAPI());\n },\n isSupported: function(): boolean {\n return Boolean(Runtime.getWebSocketAPI());\n },\n getSocket: function(url) {\n return Runtime.createWebSocket(url);\n }\n});\n\nvar httpConfiguration = {\n urls: URLSchemes.http,\n handlesActivityChecks: false,\n supportsPing: true,\n isInitialized: function() {\n return true;\n }\n};\n\nexport var streamingConfiguration = Collections.extend(\n {\n getSocket: function(url) {\n return Runtime.HTTPFactory.createStreamingSocket(url);\n }\n },\n httpConfiguration\n);\nexport var pollingConfiguration = Collections.extend(\n {\n getSocket: function(url) {\n return Runtime.HTTPFactory.createPollingSocket(url);\n }\n },\n httpConfiguration\n);\n\nvar xhrConfiguration = {\n isSupported: function(): boolean {\n return Runtime.isXHRSupported();\n }\n};\n\n/** HTTP streaming transport using CORS-enabled XMLHttpRequest. */\nvar XHRStreamingTransport = new Transport(\n (\n Collections.extend({}, streamingConfiguration, xhrConfiguration)\n )\n);\n\n/** HTTP long-polling transport using CORS-enabled XMLHttpRequest. */\nvar XHRPollingTransport = new Transport(\n Collections.extend({}, pollingConfiguration, xhrConfiguration)\n);\n\nvar Transports: TransportsTable = {\n ws: WSTransport,\n xhr_streaming: XHRStreamingTransport,\n xhr_polling: XHRPollingTransport\n};\n\nexport default Transports;\n","import Util from '../util';\nimport * as Collections from '../utils/collections';\nimport TransportManager from './transport_manager';\nimport TransportConnection from './transport_connection';\nimport Transport from './transport';\nimport PingDelayOptions from './ping_delay_options';\n\n/** Creates transport connections monitored by a transport manager.\n *\n * When a transport is closed, it might mean the environment does not support\n * it. It's possible that messages get stuck in an intermediate buffer or\n * proxies terminate inactive connections. To combat these problems,\n * assistants monitor the connection lifetime, report unclean exits and\n * adjust ping timeouts to keep the connection active. The decision to disable\n * a transport is the manager's responsibility.\n *\n * @param {TransportManager} manager\n * @param {TransportConnection} transport\n * @param {Object} options\n */\nexport default class AssistantToTheTransportManager {\n manager: TransportManager;\n transport: Transport;\n minPingDelay: number;\n maxPingDelay: number;\n pingDelay: number;\n\n constructor(\n manager: TransportManager,\n transport: Transport,\n options: PingDelayOptions\n ) {\n this.manager = manager;\n this.transport = transport;\n this.minPingDelay = options.minPingDelay;\n this.maxPingDelay = options.maxPingDelay;\n this.pingDelay = undefined;\n }\n\n /** Creates a transport connection.\n *\n * This function has the same API as Transport#createConnection.\n *\n * @param {String} name\n * @param {Number} priority\n * @param {String} key the application key\n * @param {Object} options\n * @returns {TransportConnection}\n */\n createConnection(\n name: string,\n priority: number,\n key: string,\n options: Object\n ): TransportConnection {\n options = Collections.extend({}, options, {\n activityTimeout: this.pingDelay\n });\n var connection = this.transport.createConnection(\n name,\n priority,\n key,\n options\n );\n\n var openTimestamp = null;\n\n var onOpen = function() {\n connection.unbind('open', onOpen);\n connection.bind('closed', onClosed);\n openTimestamp = Util.now();\n };\n var onClosed = closeEvent => {\n connection.unbind('closed', onClosed);\n\n if (closeEvent.code === 1002 || closeEvent.code === 1003) {\n // we don't want to use transports not obeying the protocol\n this.manager.reportDeath();\n } else if (!closeEvent.wasClean && openTimestamp) {\n // report deaths only for short-living transport\n var lifespan = Util.now() - openTimestamp;\n if (lifespan < 2 * this.maxPingDelay) {\n this.manager.reportDeath();\n this.pingDelay = Math.max(lifespan / 2, this.minPingDelay);\n }\n }\n };\n\n connection.bind('open', onOpen);\n return connection;\n }\n\n /** Returns whether the transport is supported in the environment.\n *\n * This function has the same API as Transport#isSupported. Might return false\n * when the manager decides to kill the transport.\n *\n * @param {Object} environment the environment details (encryption, settings)\n * @returns {Boolean} true when the transport is supported\n */\n isSupported(environment: string): boolean {\n return this.manager.isAlive() && this.transport.isSupported(environment);\n }\n}\n","import Action from './action';\nimport { PusherEvent } from './message-types';\n/**\n * Provides functions for handling Pusher protocol-specific messages.\n */\n\nconst Protocol = {\n /**\n * Decodes a message in a Pusher format.\n *\n * The MessageEvent we receive from the transport should contain a pusher event\n * (https://pusher.com/docs/pusher_protocol#events) serialized as JSON in the\n * data field\n *\n * The pusher event may contain a data field too, and it may also be\n * serialised as JSON\n *\n * Throws errors when messages are not parse'able.\n *\n * @param {MessageEvent} messageEvent\n * @return {PusherEvent}\n */\n decodeMessage: function(messageEvent: MessageEvent): PusherEvent {\n try {\n var messageData = JSON.parse(messageEvent.data);\n var pusherEventData = messageData.data;\n if (typeof pusherEventData === 'string') {\n try {\n pusherEventData = JSON.parse(messageData.data);\n } catch (e) {}\n }\n var pusherEvent: PusherEvent = {\n event: messageData.event,\n channel: messageData.channel,\n data: pusherEventData\n };\n if (messageData.user_id) {\n pusherEvent.user_id = messageData.user_id;\n }\n return pusherEvent;\n } catch (e) {\n throw { type: 'MessageParseError', error: e, data: messageEvent.data };\n }\n },\n\n /**\n * Encodes a message to be sent.\n *\n * @param {PusherEvent} event\n * @return {String}\n */\n encodeMessage: function(event: PusherEvent): string {\n return JSON.stringify(event);\n },\n\n /**\n * Processes a handshake message and returns appropriate actions.\n *\n * Returns an object with an 'action' and other action-specific properties.\n *\n * There are three outcomes when calling this function. First is a successful\n * connection attempt, when pusher:connection_established is received, which\n * results in a 'connected' action with an 'id' property. When passed a\n * pusher:error event, it returns a result with action appropriate to the\n * close code and an error. Otherwise, it raises an exception.\n *\n * @param {String} message\n * @result Object\n */\n processHandshake: function(messageEvent: MessageEvent): Action {\n var message = Protocol.decodeMessage(messageEvent);\n\n if (message.event === 'pusher:connection_established') {\n if (!message.data.activity_timeout) {\n throw 'No activity timeout specified in handshake';\n }\n return {\n action: 'connected',\n id: message.data.socket_id,\n activityTimeout: message.data.activity_timeout * 1000\n };\n } else if (message.event === 'pusher:error') {\n // From protocol 6 close codes are sent only once, so this only\n // happens when connection does not support close codes\n return {\n action: this.getCloseAction(message.data),\n error: this.getCloseError(message.data)\n };\n } else {\n throw 'Invalid handshake';\n }\n },\n\n /**\n * Dispatches the close event and returns an appropriate action name.\n *\n * See:\n * 1. https://developer.mozilla.org/en-US/docs/WebSockets/WebSockets_reference/CloseEvent\n * 2. http://pusher.com/docs/pusher_protocol\n *\n * @param {CloseEvent} closeEvent\n * @return {String} close action name\n */\n getCloseAction: function(closeEvent): string {\n if (closeEvent.code < 4000) {\n // ignore 1000 CLOSE_NORMAL, 1001 CLOSE_GOING_AWAY,\n // 1005 CLOSE_NO_STATUS, 1006 CLOSE_ABNORMAL\n // ignore 1007...3999\n // handle 1002 CLOSE_PROTOCOL_ERROR, 1003 CLOSE_UNSUPPORTED,\n // 1004 CLOSE_TOO_LARGE\n if (closeEvent.code >= 1002 && closeEvent.code <= 1004) {\n return 'backoff';\n } else {\n return null;\n }\n } else if (closeEvent.code === 4000) {\n return 'tls_only';\n } else if (closeEvent.code < 4100) {\n return 'refused';\n } else if (closeEvent.code < 4200) {\n return 'backoff';\n } else if (closeEvent.code < 4300) {\n return 'retry';\n } else {\n // unknown error\n return 'refused';\n }\n },\n\n /**\n * Returns an error or null basing on the close event.\n *\n * Null is returned when connection was closed cleanly. Otherwise, an object\n * with error details is returned.\n *\n * @param {CloseEvent} closeEvent\n * @return {Object} error object\n */\n getCloseError: function(closeEvent): any {\n if (closeEvent.code !== 1000 && closeEvent.code !== 1001) {\n return {\n type: 'PusherError',\n data: {\n code: closeEvent.code,\n message: closeEvent.reason || closeEvent.message\n }\n };\n } else {\n return null;\n }\n }\n};\n\nexport default Protocol;\n","import * as Collections from '../utils/collections';\nimport { default as EventsDispatcher } from '../events/dispatcher';\nimport Protocol from './protocol/protocol';\nimport { PusherEvent } from './protocol/message-types';\nimport Logger from '../logger';\nimport TransportConnection from '../transports/transport_connection';\nimport Socket from '../socket';\n/**\n * Provides Pusher protocol interface for transports.\n *\n * Emits following events:\n * - message - on received messages\n * - ping - on ping requests\n * - pong - on pong responses\n * - error - when the transport emits an error\n * - closed - after closing the transport\n *\n * It also emits more events when connection closes with a code.\n * See Protocol.getCloseAction to get more details.\n *\n * @param {Number} id\n * @param {AbstractTransport} transport\n */\nexport default class Connection extends EventsDispatcher implements Socket {\n id: string;\n transport: TransportConnection;\n activityTimeout: number;\n\n constructor(id: string, transport: TransportConnection) {\n super();\n this.id = id;\n this.transport = transport;\n this.activityTimeout = transport.activityTimeout;\n this.bindListeners();\n }\n\n /** Returns whether used transport handles activity checks by itself\n *\n * @returns {Boolean} true if activity checks are handled by the transport\n */\n handlesActivityChecks() {\n return this.transport.handlesActivityChecks();\n }\n\n /** Sends raw data.\n *\n * @param {String} data\n */\n send(data: any): boolean {\n return this.transport.send(data);\n }\n\n /** Sends an event.\n *\n * @param {String} name\n * @param {String} data\n * @param {String} [channel]\n * @returns {Boolean} whether message was sent or not\n */\n send_event(name: string, data: any, channel?: string): boolean {\n var event: PusherEvent = { event: name, data: data };\n if (channel) {\n event.channel = channel;\n }\n Logger.debug('Event sent', event);\n return this.send(Protocol.encodeMessage(event));\n }\n\n /** Sends a ping message to the server.\n *\n * Basing on the underlying transport, it might send either transport's\n * protocol-specific ping or pusher:ping event.\n */\n ping() {\n if (this.transport.supportsPing()) {\n this.transport.ping();\n } else {\n this.send_event('pusher:ping', {});\n }\n }\n\n /** Closes the connection. */\n close() {\n this.transport.close();\n }\n\n private bindListeners() {\n var listeners = {\n message: (messageEvent: MessageEvent) => {\n var pusherEvent;\n try {\n pusherEvent = Protocol.decodeMessage(messageEvent);\n } catch (e) {\n this.emit('error', {\n type: 'MessageParseError',\n error: e,\n data: messageEvent.data\n });\n }\n\n if (pusherEvent !== undefined) {\n Logger.debug('Event recd', pusherEvent);\n\n switch (pusherEvent.event) {\n case 'pusher:error':\n this.emit('error', {\n type: 'PusherError',\n data: pusherEvent.data\n });\n break;\n case 'pusher:ping':\n this.emit('ping');\n break;\n case 'pusher:pong':\n this.emit('pong');\n break;\n }\n this.emit('message', pusherEvent);\n }\n },\n activity: () => {\n this.emit('activity');\n },\n error: error => {\n this.emit('error', error);\n },\n closed: closeEvent => {\n unbindListeners();\n\n if (closeEvent && closeEvent.code) {\n this.handleCloseEvent(closeEvent);\n }\n\n this.transport = null;\n this.emit('closed');\n }\n };\n\n var unbindListeners = () => {\n Collections.objectApply(listeners, (listener, event) => {\n this.transport.unbind(event, listener);\n });\n };\n\n Collections.objectApply(listeners, (listener, event) => {\n this.transport.bind(event, listener);\n });\n }\n\n private handleCloseEvent(closeEvent: any) {\n var action = Protocol.getCloseAction(closeEvent);\n var error = Protocol.getCloseError(closeEvent);\n if (error) {\n this.emit('error', error);\n }\n if (action) {\n this.emit(action, { action: action, error: error });\n }\n }\n}\n","import Util from '../../util';\nimport * as Collections from '../../utils/collections';\nimport Protocol from '../protocol/protocol';\nimport Connection from '../connection';\nimport TransportConnection from '../../transports/transport_connection';\nimport HandshakePayload from './handshake_payload';\n\n/**\n * Handles Pusher protocol handshakes for transports.\n *\n * Calls back with a result object after handshake is completed. Results\n * always have two fields:\n * - action - string describing action to be taken after the handshake\n * - transport - the transport object passed to the constructor\n *\n * Different actions can set different additional properties on the result.\n * In the case of 'connected' action, there will be a 'connection' property\n * containing a Connection object for the transport. Other actions should\n * carry an 'error' property.\n *\n * @param {AbstractTransport} transport\n * @param {Function} callback\n */\nexport default class Handshake {\n transport: TransportConnection;\n callback: (HandshakePayload) => void;\n onMessage: Function;\n onClosed: Function;\n\n constructor(\n transport: TransportConnection,\n callback: (HandshakePayload) => void\n ) {\n this.transport = transport;\n this.callback = callback;\n this.bindListeners();\n }\n\n close() {\n this.unbindListeners();\n this.transport.close();\n }\n\n private bindListeners() {\n this.onMessage = m => {\n this.unbindListeners();\n\n var result;\n try {\n result = Protocol.processHandshake(m);\n } catch (e) {\n this.finish('error', { error: e });\n this.transport.close();\n return;\n }\n\n if (result.action === 'connected') {\n this.finish('connected', {\n connection: new Connection(result.id, this.transport),\n activityTimeout: result.activityTimeout\n });\n } else {\n this.finish(result.action, { error: result.error });\n this.transport.close();\n }\n };\n\n this.onClosed = closeEvent => {\n this.unbindListeners();\n\n var action = Protocol.getCloseAction(closeEvent) || 'backoff';\n var error = Protocol.getCloseError(closeEvent);\n this.finish(action, { error: error });\n };\n\n this.transport.bind('message', this.onMessage);\n this.transport.bind('closed', this.onClosed);\n }\n\n private unbindListeners() {\n this.transport.unbind('message', this.onMessage);\n this.transport.unbind('closed', this.onClosed);\n }\n\n private finish(action: string, params: any) {\n this.callback(\n Collections.extend({ transport: this.transport, action: action }, params)\n );\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport base64encode from '../base64';\nimport Timeline from './timeline';\nimport Runtime from 'runtime';\n\nexport interface TimelineSenderOptions {\n host?: string;\n port?: number;\n path?: string;\n}\n\nexport default class TimelineSender {\n timeline: Timeline;\n options: TimelineSenderOptions;\n host: string;\n\n constructor(timeline: Timeline, options: TimelineSenderOptions) {\n this.timeline = timeline;\n this.options = options || {};\n }\n\n send(useTLS: boolean, callback?: Function) {\n if (this.timeline.isEmpty()) {\n return;\n }\n\n this.timeline.send(\n Runtime.TimelineTransport.getAgent(this, useTLS),\n callback\n );\n }\n}\n","/** Error classes used throughout the library. */\n// https://github.com/Microsoft/TypeScript-wiki/blob/master/Breaking-Changes.md#extending-built-ins-like-error-array-and-map-may-no-longer-work\nexport class BadEventName extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\nexport class BadChannelName extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\nexport class RequestTimedOut extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class TransportPriorityTooLow extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class TransportClosed extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class UnsupportedFeature extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class UnsupportedTransport extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class UnsupportedStrategy extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class HTTPAuthError extends Error {\n status: number;\n constructor(status: number, msg?: string) {\n super(msg);\n this.status = status;\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n","/**\n * A place to store help URLs for error messages etc\n */\n\nconst urlStore = {\n baseUrl: 'https://pusher.com',\n urls: {\n authenticationEndpoint: {\n path: '/docs/channels/server_api/authenticating_users'\n },\n authorizationEndpoint: {\n path: '/docs/channels/server_api/authorizing-users/'\n },\n javascriptQuickStart: {\n path: '/docs/javascript_quick_start'\n },\n triggeringClientEvents: {\n path: '/docs/client_api_guide/client_events#trigger-events'\n },\n encryptedChannelSupport: {\n fullUrl:\n 'https://github.com/pusher/pusher-js/tree/cc491015371a4bde5743d1c87a0fbac0feb53195#encrypted-channel-support'\n }\n }\n};\n\n/** Builds a consistent string with links to pusher documentation\n *\n * @param {string} key - relevant key in the url_store.urls object\n * @return {string} suffix string to append to log message\n */\nconst buildLogSuffix = function(key: string): string {\n const urlPrefix = 'See:';\n const urlObj = urlStore.urls[key];\n if (!urlObj) return '';\n\n let url;\n if (urlObj.fullUrl) {\n url = urlObj.fullUrl;\n } else if (urlObj.path) {\n url = urlStore.baseUrl + urlObj.path;\n }\n\n if (!url) return '';\n return `${urlPrefix} ${url}`;\n};\n\nexport default { buildLogSuffix };\n","import { default as EventsDispatcher } from '../events/dispatcher';\nimport * as Errors from '../errors';\nimport Logger from '../logger';\nimport Pusher from '../pusher';\nimport { PusherEvent } from '../connection/protocol/message-types';\nimport Metadata from './metadata';\nimport UrlStore from '../utils/url_store';\nimport {\n ChannelAuthorizationData,\n ChannelAuthorizationCallback\n} from '../auth/options';\nimport { HTTPAuthError } from '../errors';\n\n/** Provides base public channel interface with an event emitter.\n *\n * Emits:\n * - pusher:subscription_succeeded - after subscribing successfully\n * - other non-internal events\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\nexport default class Channel extends EventsDispatcher {\n name: string;\n pusher: Pusher;\n subscribed: boolean;\n subscriptionPending: boolean;\n subscriptionCancelled: boolean;\n subscriptionCount: null;\n\n constructor(name: string, pusher: Pusher) {\n super(function(event, data) {\n Logger.debug('No callbacks on ' + name + ' for ' + event);\n });\n\n this.name = name;\n this.pusher = pusher;\n this.subscribed = false;\n this.subscriptionPending = false;\n this.subscriptionCancelled = false;\n }\n\n /** Skips authorization, since public channels don't require it.\n *\n * @param {Function} callback\n */\n authorize(socketId: string, callback: ChannelAuthorizationCallback) {\n return callback(null, { auth: '' });\n }\n\n /** Triggers an event */\n trigger(event: string, data: any) {\n if (event.indexOf('client-') !== 0) {\n throw new Errors.BadEventName(\n \"Event '\" + event + \"' does not start with 'client-'\"\n );\n }\n if (!this.subscribed) {\n var suffix = UrlStore.buildLogSuffix('triggeringClientEvents');\n Logger.warn(\n `Client event triggered before channel 'subscription_succeeded' event . ${suffix}`\n );\n }\n return this.pusher.send_event(event, data, this.name);\n }\n\n /** Signals disconnection to the channel. For internal use only. */\n disconnect() {\n this.subscribed = false;\n this.subscriptionPending = false;\n }\n\n /** Handles a PusherEvent. For internal use only.\n *\n * @param {PusherEvent} event\n */\n handleEvent(event: PusherEvent) {\n var eventName = event.event;\n var data = event.data;\n if (eventName === 'pusher_internal:subscription_succeeded') {\n this.handleSubscriptionSucceededEvent(event);\n } else if (eventName === 'pusher_internal:subscription_count') {\n this.handleSubscriptionCountEvent(event);\n } else if (eventName.indexOf('pusher_internal:') !== 0) {\n var metadata: Metadata = {};\n this.emit(eventName, data, metadata);\n }\n }\n\n handleSubscriptionSucceededEvent(event: PusherEvent) {\n this.subscriptionPending = false;\n this.subscribed = true;\n if (this.subscriptionCancelled) {\n this.pusher.unsubscribe(this.name);\n } else {\n this.emit('pusher:subscription_succeeded', event.data);\n }\n }\n\n handleSubscriptionCountEvent(event: PusherEvent) {\n if (event.data.subscription_count) {\n this.subscriptionCount = event.data.subscription_count;\n }\n\n this.emit('pusher:subscription_count', event.data);\n }\n\n /** Sends a subscription request. For internal use only. */\n subscribe() {\n if (this.subscribed) {\n return;\n }\n this.subscriptionPending = true;\n this.subscriptionCancelled = false;\n this.authorize(\n this.pusher.connection.socket_id,\n (error: Error | null, data: ChannelAuthorizationData) => {\n if (error) {\n this.subscriptionPending = false;\n // Why not bind to 'pusher:subscription_error' a level up, and log there?\n // Binding to this event would cause the warning about no callbacks being\n // bound (see constructor) to be suppressed, that's not what we want.\n Logger.error(error.toString());\n this.emit(\n 'pusher:subscription_error',\n Object.assign(\n {},\n {\n type: 'AuthError',\n error: error.message\n },\n error instanceof HTTPAuthError ? { status: error.status } : {}\n )\n );\n } else {\n this.pusher.send_event('pusher:subscribe', {\n auth: data.auth,\n channel_data: data.channel_data,\n channel: this.name\n });\n }\n }\n );\n }\n\n /** Sends an unsubscription request. For internal use only. */\n unsubscribe() {\n this.subscribed = false;\n this.pusher.send_event('pusher:unsubscribe', {\n channel: this.name\n });\n }\n\n /** Cancels an in progress subscription. For internal use only. */\n cancelSubscription() {\n this.subscriptionCancelled = true;\n }\n\n /** Reinstates an in progress subscripiton. For internal use only. */\n reinstateSubscription() {\n this.subscriptionCancelled = false;\n }\n}\n","import Factory from '../utils/factory';\nimport Channel from './channel';\nimport { ChannelAuthorizationCallback } from '../auth/options';\n\n/** Extends public channels to provide private channel interface.\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\nexport default class PrivateChannel extends Channel {\n /** Authorizes the connection to use the channel.\n *\n * @param {String} socketId\n * @param {Function} callback\n */\n authorize(socketId: string, callback: ChannelAuthorizationCallback) {\n return this.pusher.config.channelAuthorizer(\n {\n channelName: this.name,\n socketId: socketId\n },\n callback\n );\n }\n}\n","import * as Collections from '../utils/collections';\n\n/** Represents a collection of members of a presence channel. */\nexport default class Members {\n members: any;\n count: number;\n myID: any;\n me: any;\n\n constructor() {\n this.reset();\n }\n\n /** Returns member's info for given id.\n *\n * Resulting object containts two fields - id and info.\n *\n * @param {Number} id\n * @return {Object} member's info or null\n */\n get(id: string): any {\n if (Object.prototype.hasOwnProperty.call(this.members, id)) {\n return {\n id: id,\n info: this.members[id]\n };\n } else {\n return null;\n }\n }\n\n /** Calls back for each member in unspecified order.\n *\n * @param {Function} callback\n */\n each(callback: Function) {\n Collections.objectApply(this.members, (member, id) => {\n callback(this.get(id));\n });\n }\n\n /** Updates the id for connected member. For internal use only. */\n setMyID(id: string) {\n this.myID = id;\n }\n\n /** Handles subscription data. For internal use only. */\n onSubscription(subscriptionData: any) {\n this.members = subscriptionData.presence.hash;\n this.count = subscriptionData.presence.count;\n this.me = this.get(this.myID);\n }\n\n /** Adds a new member to the collection. For internal use only. */\n addMember(memberData: any) {\n if (this.get(memberData.user_id) === null) {\n this.count++;\n }\n this.members[memberData.user_id] = memberData.user_info;\n return this.get(memberData.user_id);\n }\n\n /** Adds a member from the collection. For internal use only. */\n removeMember(memberData: any) {\n var member = this.get(memberData.user_id);\n if (member) {\n delete this.members[memberData.user_id];\n this.count--;\n }\n return member;\n }\n\n /** Resets the collection to the initial state. For internal use only. */\n reset() {\n this.members = {};\n this.count = 0;\n this.myID = null;\n this.me = null;\n }\n}\n","import PrivateChannel from './private_channel';\nimport Logger from '../logger';\nimport Members from './members';\nimport Pusher from '../pusher';\nimport UrlStore from 'core/utils/url_store';\nimport { PusherEvent } from '../connection/protocol/message-types';\nimport Metadata from './metadata';\nimport { ChannelAuthorizationData } from '../auth/options';\n\nexport default class PresenceChannel extends PrivateChannel {\n members: Members;\n\n /** Adds presence channel functionality to private channels.\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\n constructor(name: string, pusher: Pusher) {\n super(name, pusher);\n this.members = new Members();\n }\n\n /** Authorizes the connection as a member of the channel.\n *\n * @param {String} socketId\n * @param {Function} callback\n */\n authorize(socketId: string, callback: Function) {\n super.authorize(socketId, async (error, authData) => {\n if (!error) {\n authData = authData as ChannelAuthorizationData;\n if (authData.channel_data != null) {\n var channelData = JSON.parse(authData.channel_data);\n this.members.setMyID(channelData.user_id);\n } else {\n await this.pusher.user.signinDonePromise;\n if (this.pusher.user.user_data != null) {\n // If the user is signed in, get the id of the authenticated user\n // and allow the presence authorization to continue.\n this.members.setMyID(this.pusher.user.user_data.id);\n } else {\n let suffix = UrlStore.buildLogSuffix('authorizationEndpoint');\n Logger.error(\n `Invalid auth response for channel '${this.name}', ` +\n `expected 'channel_data' field. ${suffix}, ` +\n `or the user should be signed in.`\n );\n callback('Invalid auth response');\n return;\n }\n }\n }\n callback(error, authData);\n });\n }\n\n /** Handles presence and subscription events. For internal use only.\n *\n * @param {PusherEvent} event\n */\n handleEvent(event: PusherEvent) {\n var eventName = event.event;\n if (eventName.indexOf('pusher_internal:') === 0) {\n this.handleInternalEvent(event);\n } else {\n var data = event.data;\n var metadata: Metadata = {};\n if (event.user_id) {\n metadata.user_id = event.user_id;\n }\n this.emit(eventName, data, metadata);\n }\n }\n handleInternalEvent(event: PusherEvent) {\n var eventName = event.event;\n var data = event.data;\n switch (eventName) {\n case 'pusher_internal:subscription_succeeded':\n this.handleSubscriptionSucceededEvent(event);\n break;\n case 'pusher_internal:subscription_count':\n this.handleSubscriptionCountEvent(event);\n break;\n case 'pusher_internal:member_added':\n var addedMember = this.members.addMember(data);\n this.emit('pusher:member_added', addedMember);\n break;\n case 'pusher_internal:member_removed':\n var removedMember = this.members.removeMember(data);\n if (removedMember) {\n this.emit('pusher:member_removed', removedMember);\n }\n break;\n }\n }\n\n handleSubscriptionSucceededEvent(event: PusherEvent) {\n this.subscriptionPending = false;\n this.subscribed = true;\n if (this.subscriptionCancelled) {\n this.pusher.unsubscribe(this.name);\n } else {\n this.members.onSubscription(event.data);\n this.emit('pusher:subscription_succeeded', this.members);\n }\n }\n\n /** Resets the channel state, including members map. For internal use only. */\n disconnect() {\n this.members.reset();\n super.disconnect();\n }\n}\n","import PrivateChannel from './private_channel';\nimport * as Errors from '../errors';\nimport Logger from '../logger';\nimport Pusher from '../pusher';\nimport { decode as encodeUTF8 } from '@stablelib/utf8';\nimport { decode as decodeBase64 } from '@stablelib/base64';\nimport Dispatcher from '../events/dispatcher';\nimport { PusherEvent } from '../connection/protocol/message-types';\nimport {\n ChannelAuthorizationData,\n ChannelAuthorizationCallback\n} from '../auth/options';\nimport * as nacl from 'tweetnacl';\n\n/** Extends private channels to provide encrypted channel interface.\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\nexport default class EncryptedChannel extends PrivateChannel {\n key: Uint8Array = null;\n nacl: nacl;\n\n constructor(name: string, pusher: Pusher, nacl: nacl) {\n super(name, pusher);\n this.nacl = nacl;\n }\n\n /** Authorizes the connection to use the channel.\n *\n * @param {String} socketId\n * @param {Function} callback\n */\n authorize(socketId: string, callback: ChannelAuthorizationCallback) {\n super.authorize(\n socketId,\n (error: Error | null, authData: ChannelAuthorizationData) => {\n if (error) {\n callback(error, authData);\n return;\n }\n let sharedSecret = authData['shared_secret'];\n if (!sharedSecret) {\n callback(\n new Error(\n `No shared_secret key in auth payload for encrypted channel: ${this.name}`\n ),\n null\n );\n return;\n }\n this.key = decodeBase64(sharedSecret);\n delete authData['shared_secret'];\n callback(null, authData);\n }\n );\n }\n\n trigger(event: string, data: any): boolean {\n throw new Errors.UnsupportedFeature(\n 'Client events are not currently supported for encrypted channels'\n );\n }\n\n /** Handles an event. For internal use only.\n *\n * @param {PusherEvent} event\n */\n handleEvent(event: PusherEvent) {\n var eventName = event.event;\n var data = event.data;\n if (\n eventName.indexOf('pusher_internal:') === 0 ||\n eventName.indexOf('pusher:') === 0\n ) {\n super.handleEvent(event);\n return;\n }\n this.handleEncryptedEvent(eventName, data);\n }\n\n private handleEncryptedEvent(event: string, data: any): void {\n if (!this.key) {\n Logger.debug(\n 'Received encrypted event before key has been retrieved from the authEndpoint'\n );\n return;\n }\n if (!data.ciphertext || !data.nonce) {\n Logger.error(\n 'Unexpected format for encrypted event, expected object with `ciphertext` and `nonce` fields, got: ' +\n data\n );\n return;\n }\n let cipherText = decodeBase64(data.ciphertext);\n if (cipherText.length < this.nacl.secretbox.overheadLength) {\n Logger.error(\n `Expected encrypted event ciphertext length to be ${this.nacl.secretbox.overheadLength}, got: ${cipherText.length}`\n );\n return;\n }\n let nonce = decodeBase64(data.nonce);\n if (nonce.length < this.nacl.secretbox.nonceLength) {\n Logger.error(\n `Expected encrypted event nonce length to be ${this.nacl.secretbox.nonceLength}, got: ${nonce.length}`\n );\n return;\n }\n\n let bytes = this.nacl.secretbox.open(cipherText, nonce, this.key);\n if (bytes === null) {\n Logger.debug(\n 'Failed to decrypt an event, probably because it was encrypted with a different key. Fetching a new key from the authEndpoint...'\n );\n // Try a single time to retrieve a new auth key and decrypt the event with it\n // If this fails, a new key will be requested when a new message is received\n this.authorize(this.pusher.connection.socket_id, (error, authData) => {\n if (error) {\n Logger.error(\n `Failed to make a request to the authEndpoint: ${authData}. Unable to fetch new key, so dropping encrypted event`\n );\n return;\n }\n bytes = this.nacl.secretbox.open(cipherText, nonce, this.key);\n if (bytes === null) {\n Logger.error(\n `Failed to decrypt event with new key. Dropping encrypted event`\n );\n return;\n }\n this.emit(event, this.getDataToEmit(bytes));\n return;\n });\n return;\n }\n this.emit(event, this.getDataToEmit(bytes));\n }\n\n // Try and parse the decrypted bytes as JSON. If we can't parse it, just\n // return the utf-8 string\n getDataToEmit(bytes: Uint8Array): string {\n let raw = encodeUTF8(bytes);\n try {\n return JSON.parse(raw);\n } catch {\n return raw;\n }\n }\n}\n","import { default as EventsDispatcher } from '../events/dispatcher';\nimport { OneOffTimer as Timer } from '../utils/timers';\nimport { Config } from '../config';\nimport Logger from '../logger';\nimport HandshakePayload from './handshake/handshake_payload';\nimport Connection from './connection';\nimport Strategy from '../strategies/strategy';\nimport StrategyRunner from '../strategies/strategy_runner';\nimport * as Collections from '../utils/collections';\nimport Timeline from '../timeline/timeline';\nimport ConnectionManagerOptions from './connection_manager_options';\nimport Runtime from 'runtime';\n\nimport {\n ErrorCallbacks,\n HandshakeCallbacks,\n ConnectionCallbacks\n} from './callbacks';\nimport Action from './protocol/action';\n\n/** Manages connection to Pusher.\n *\n * Uses a strategy (currently only default), timers and network availability\n * info to establish a connection and export its state. In case of failures,\n * manages reconnection attempts.\n *\n * Exports state changes as following events:\n * - \"state_change\", { previous: p, current: state }\n * - state\n *\n * States:\n * - initialized - initial state, never transitioned to\n * - connecting - connection is being established\n * - connected - connection has been fully established\n * - disconnected - on requested disconnection\n * - unavailable - after connection timeout or when there's no network\n * - failed - when the connection strategy is not supported\n *\n * Options:\n * - unavailableTimeout - time to transition to unavailable state\n * - activityTimeout - time after which ping message should be sent\n * - pongTimeout - time for Pusher to respond with pong before reconnecting\n *\n * @param {String} key application key\n * @param {Object} options\n */\nexport default class ConnectionManager extends EventsDispatcher {\n key: string;\n options: ConnectionManagerOptions;\n state: string;\n connection: Connection;\n usingTLS: boolean;\n timeline: Timeline;\n socket_id: string;\n unavailableTimer: Timer;\n activityTimer: Timer;\n retryTimer: Timer;\n activityTimeout: number;\n strategy: Strategy;\n runner: StrategyRunner;\n errorCallbacks: ErrorCallbacks;\n handshakeCallbacks: HandshakeCallbacks;\n connectionCallbacks: ConnectionCallbacks;\n\n constructor(key: string, options: ConnectionManagerOptions) {\n super();\n this.state = 'initialized';\n this.connection = null;\n\n this.key = key;\n this.options = options;\n this.timeline = this.options.timeline;\n this.usingTLS = this.options.useTLS;\n\n this.errorCallbacks = this.buildErrorCallbacks();\n this.connectionCallbacks = this.buildConnectionCallbacks(\n this.errorCallbacks\n );\n this.handshakeCallbacks = this.buildHandshakeCallbacks(this.errorCallbacks);\n\n var Network = Runtime.getNetwork();\n\n Network.bind('online', () => {\n this.timeline.info({ netinfo: 'online' });\n if (this.state === 'connecting' || this.state === 'unavailable') {\n this.retryIn(0);\n }\n });\n Network.bind('offline', () => {\n this.timeline.info({ netinfo: 'offline' });\n if (this.connection) {\n this.sendActivityCheck();\n }\n });\n\n this.updateStrategy();\n }\n\n switchCluster(key: string) {\n this.key = key;\n // This ensures that the new config coming from\n // pusher instance are taken into account\n // such as appKey and cluster\n this.updateStrategy();\n this.retryIn(0);\n }\n\n /** Establishes a connection to Pusher.\n *\n * Does nothing when connection is already established. See top-level doc\n * to find events emitted on connection attempts.\n */\n connect() {\n if (this.connection || this.runner) {\n return;\n }\n if (!this.strategy.isSupported()) {\n this.updateState('failed');\n return;\n }\n this.updateState('connecting');\n this.startConnecting();\n this.setUnavailableTimer();\n }\n\n /** Sends raw data.\n *\n * @param {String} data\n */\n send(data) {\n if (this.connection) {\n return this.connection.send(data);\n } else {\n return false;\n }\n }\n\n /** Sends an event.\n *\n * @param {String} name\n * @param {String} data\n * @param {String} [channel]\n * @returns {Boolean} whether message was sent or not\n */\n send_event(name: string, data: any, channel?: string) {\n if (this.connection) {\n return this.connection.send_event(name, data, channel);\n } else {\n return false;\n }\n }\n\n /** Closes the connection. */\n disconnect() {\n this.disconnectInternally();\n this.updateState('disconnected');\n }\n\n isUsingTLS() {\n return this.usingTLS;\n }\n\n private startConnecting() {\n var callback = (error, handshake) => {\n if (error) {\n this.runner = this.strategy.connect(0, callback);\n } else {\n if (handshake.action === 'error') {\n this.emit('error', {\n type: 'HandshakeError',\n error: handshake.error\n });\n this.timeline.error({ handshakeError: handshake.error });\n } else {\n this.abortConnecting(); // we don't support switching connections yet\n this.handshakeCallbacks[handshake.action](handshake);\n }\n }\n };\n this.runner = this.strategy.connect(0, callback);\n }\n\n private abortConnecting() {\n if (this.runner) {\n this.runner.abort();\n this.runner = null;\n }\n }\n\n private disconnectInternally() {\n this.abortConnecting();\n this.clearRetryTimer();\n this.clearUnavailableTimer();\n if (this.connection) {\n var connection = this.abandonConnection();\n connection.close();\n }\n }\n\n private updateStrategy() {\n this.strategy = this.options.getStrategy({\n key: this.key,\n timeline: this.timeline,\n useTLS: this.usingTLS\n });\n }\n\n private retryIn(delay) {\n this.timeline.info({ action: 'retry', delay: delay });\n if (delay > 0) {\n this.emit('connecting_in', Math.round(delay / 1000));\n }\n this.retryTimer = new Timer(delay || 0, () => {\n this.disconnectInternally();\n this.connect();\n });\n }\n\n private clearRetryTimer() {\n if (this.retryTimer) {\n this.retryTimer.ensureAborted();\n this.retryTimer = null;\n }\n }\n\n private setUnavailableTimer() {\n this.unavailableTimer = new Timer(this.options.unavailableTimeout, () => {\n this.updateState('unavailable');\n });\n }\n\n private clearUnavailableTimer() {\n if (this.unavailableTimer) {\n this.unavailableTimer.ensureAborted();\n }\n }\n\n private sendActivityCheck() {\n this.stopActivityCheck();\n this.connection.ping();\n // wait for pong response\n this.activityTimer = new Timer(this.options.pongTimeout, () => {\n this.timeline.error({ pong_timed_out: this.options.pongTimeout });\n this.retryIn(0);\n });\n }\n\n private resetActivityCheck() {\n this.stopActivityCheck();\n // send ping after inactivity\n if (this.connection && !this.connection.handlesActivityChecks()) {\n this.activityTimer = new Timer(this.activityTimeout, () => {\n this.sendActivityCheck();\n });\n }\n }\n\n private stopActivityCheck() {\n if (this.activityTimer) {\n this.activityTimer.ensureAborted();\n }\n }\n\n private buildConnectionCallbacks(\n errorCallbacks: ErrorCallbacks\n ): ConnectionCallbacks {\n return Collections.extend({}, errorCallbacks, {\n message: message => {\n // includes pong messages from server\n this.resetActivityCheck();\n this.emit('message', message);\n },\n ping: () => {\n this.send_event('pusher:pong', {});\n },\n activity: () => {\n this.resetActivityCheck();\n },\n error: error => {\n // just emit error to user - socket will already be closed by browser\n this.emit('error', error);\n },\n closed: () => {\n this.abandonConnection();\n if (this.shouldRetry()) {\n this.retryIn(1000);\n }\n }\n });\n }\n\n private buildHandshakeCallbacks(\n errorCallbacks: ErrorCallbacks\n ): HandshakeCallbacks {\n return Collections.extend({}, errorCallbacks, {\n connected: (handshake: HandshakePayload) => {\n this.activityTimeout = Math.min(\n this.options.activityTimeout,\n handshake.activityTimeout,\n handshake.connection.activityTimeout || Infinity\n );\n this.clearUnavailableTimer();\n this.setConnection(handshake.connection);\n this.socket_id = this.connection.id;\n this.updateState('connected', { socket_id: this.socket_id });\n }\n });\n }\n\n private buildErrorCallbacks(): ErrorCallbacks {\n let withErrorEmitted = callback => {\n return (result: Action | HandshakePayload) => {\n if (result.error) {\n this.emit('error', { type: 'WebSocketError', error: result.error });\n }\n callback(result);\n };\n };\n\n return {\n tls_only: withErrorEmitted(() => {\n this.usingTLS = true;\n this.updateStrategy();\n this.retryIn(0);\n }),\n refused: withErrorEmitted(() => {\n this.disconnect();\n }),\n backoff: withErrorEmitted(() => {\n this.retryIn(1000);\n }),\n retry: withErrorEmitted(() => {\n this.retryIn(0);\n })\n };\n }\n\n private setConnection(connection) {\n this.connection = connection;\n for (var event in this.connectionCallbacks) {\n this.connection.bind(event, this.connectionCallbacks[event]);\n }\n this.resetActivityCheck();\n }\n\n private abandonConnection() {\n if (!this.connection) {\n return;\n }\n this.stopActivityCheck();\n for (var event in this.connectionCallbacks) {\n this.connection.unbind(event, this.connectionCallbacks[event]);\n }\n var connection = this.connection;\n this.connection = null;\n return connection;\n }\n\n private updateState(newState: string, data?: any) {\n var previousState = this.state;\n this.state = newState;\n if (previousState !== newState) {\n var newStateDescription = newState;\n if (newStateDescription === 'connected') {\n newStateDescription += ' with new socket ID ' + data.socket_id;\n }\n Logger.debug(\n 'State changed',\n previousState + ' -> ' + newStateDescription\n );\n this.timeline.info({ state: newState, params: data });\n this.emit('state_change', { previous: previousState, current: newState });\n this.emit(newState, data);\n }\n }\n\n private shouldRetry(): boolean {\n return this.state === 'connecting' || this.state === 'connected';\n }\n}\n","import Channel from './channel';\nimport * as Collections from '../utils/collections';\nimport ChannelTable from './channel_table';\nimport Factory from '../utils/factory';\nimport Pusher from '../pusher';\nimport Logger from '../logger';\nimport * as Errors from '../errors';\nimport urlStore from '../utils/url_store';\n\n/** Handles a channel map. */\nexport default class Channels {\n channels: ChannelTable;\n\n constructor() {\n this.channels = {};\n }\n\n /** Creates or retrieves an existing channel by its name.\n *\n * @param {String} name\n * @param {Pusher} pusher\n * @return {Channel}\n */\n add(name: string, pusher: Pusher) {\n if (!this.channels[name]) {\n this.channels[name] = createChannel(name, pusher);\n }\n return this.channels[name];\n }\n\n /** Returns a list of all channels\n *\n * @return {Array}\n */\n all(): Channel[] {\n return Collections.values(this.channels);\n }\n\n /** Finds a channel by its name.\n *\n * @param {String} name\n * @return {Channel} channel or null if it doesn't exist\n */\n find(name: string) {\n return this.channels[name];\n }\n\n /** Removes a channel from the map.\n *\n * @param {String} name\n */\n remove(name: string) {\n var channel = this.channels[name];\n delete this.channels[name];\n return channel;\n }\n\n /** Proxies disconnection signal to all channels. */\n disconnect() {\n Collections.objectApply(this.channels, function(channel) {\n channel.disconnect();\n });\n }\n}\n\nfunction createChannel(name: string, pusher: Pusher): Channel {\n if (name.indexOf('private-encrypted-') === 0) {\n if (pusher.config.nacl) {\n return Factory.createEncryptedChannel(name, pusher, pusher.config.nacl);\n }\n let errMsg =\n 'Tried to subscribe to a private-encrypted- channel but no nacl implementation available';\n let suffix = urlStore.buildLogSuffix('encryptedChannelSupport');\n throw new Errors.UnsupportedFeature(`${errMsg}. ${suffix}`);\n } else if (name.indexOf('private-') === 0) {\n return Factory.createPrivateChannel(name, pusher);\n } else if (name.indexOf('presence-') === 0) {\n return Factory.createPresenceChannel(name, pusher);\n } else if (name.indexOf('#') === 0) {\n throw new Errors.BadChannelName(\n 'Cannot create a channel with name \"' + name + '\".'\n );\n } else {\n return Factory.createChannel(name, pusher);\n }\n}\n","import AssistantToTheTransportManager from '../transports/assistant_to_the_transport_manager';\nimport PingDelayOptions from '../transports/ping_delay_options';\nimport Transport from '../transports/transport';\nimport TransportManager from '../transports/transport_manager';\nimport Handshake from '../connection/handshake';\nimport TransportConnection from '../transports/transport_connection';\nimport SocketHooks from '../http/socket_hooks';\nimport HTTPSocket from '../http/http_socket';\n\nimport Timeline from '../timeline/timeline';\nimport {\n default as TimelineSender,\n TimelineSenderOptions\n} from '../timeline/timeline_sender';\nimport PresenceChannel from '../channels/presence_channel';\nimport PrivateChannel from '../channels/private_channel';\nimport EncryptedChannel from '../channels/encrypted_channel';\nimport Channel from '../channels/channel';\nimport ConnectionManager from '../connection/connection_manager';\nimport ConnectionManagerOptions from '../connection/connection_manager_options';\nimport Ajax from '../http/ajax';\nimport Channels from '../channels/channels';\nimport Pusher from '../pusher';\nimport { Config } from '../config';\nimport * as nacl from 'tweetnacl';\n\nvar Factory = {\n createChannels(): Channels {\n return new Channels();\n },\n\n createConnectionManager(\n key: string,\n options: ConnectionManagerOptions\n ): ConnectionManager {\n return new ConnectionManager(key, options);\n },\n\n createChannel(name: string, pusher: Pusher): Channel {\n return new Channel(name, pusher);\n },\n\n createPrivateChannel(name: string, pusher: Pusher): PrivateChannel {\n return new PrivateChannel(name, pusher);\n },\n\n createPresenceChannel(name: string, pusher: Pusher): PresenceChannel {\n return new PresenceChannel(name, pusher);\n },\n\n createEncryptedChannel(\n name: string,\n pusher: Pusher,\n nacl: nacl\n ): EncryptedChannel {\n return new EncryptedChannel(name, pusher, nacl);\n },\n\n createTimelineSender(timeline: Timeline, options: TimelineSenderOptions) {\n return new TimelineSender(timeline, options);\n },\n\n createHandshake(\n transport: TransportConnection,\n callback: (HandshakePayload) => void\n ): Handshake {\n return new Handshake(transport, callback);\n },\n\n createAssistantToTheTransportManager(\n manager: TransportManager,\n transport: Transport,\n options: PingDelayOptions\n ): AssistantToTheTransportManager {\n return new AssistantToTheTransportManager(manager, transport, options);\n }\n};\n\nexport default Factory;\n","import AssistantToTheTransportManager from './assistant_to_the_transport_manager';\nimport Transport from './transport';\nimport PingDelayOptions from './ping_delay_options';\nimport Factory from '../utils/factory';\n\nexport interface TransportManagerOptions extends PingDelayOptions {\n lives?: number;\n}\n\n/** Keeps track of the number of lives left for a transport.\n *\n * In the beginning of a session, transports may be assigned a number of\n * lives. When an AssistantToTheTransportManager instance reports a transport\n * connection closed uncleanly, the transport loses a life. When the number\n * of lives drops to zero, the transport gets disabled by its manager.\n *\n * @param {Object} options\n */\nexport default class TransportManager {\n options: TransportManagerOptions;\n livesLeft: number;\n\n constructor(options: TransportManagerOptions) {\n this.options = options || {};\n this.livesLeft = this.options.lives || Infinity;\n }\n\n /** Creates a assistant for the transport.\n *\n * @param {Transport} transport\n * @returns {AssistantToTheTransportManager}\n */\n getAssistant(transport: Transport): AssistantToTheTransportManager {\n return Factory.createAssistantToTheTransportManager(this, transport, {\n minPingDelay: this.options.minPingDelay,\n maxPingDelay: this.options.maxPingDelay\n });\n }\n\n /** Returns whether the transport has any lives left.\n *\n * @returns {Boolean}\n */\n isAlive(): boolean {\n return this.livesLeft > 0;\n }\n\n /** Takes one life from the transport. */\n reportDeath() {\n this.livesLeft -= 1;\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport { OneOffTimer as Timer } from '../utils/timers';\nimport Strategy from './strategy';\nimport StrategyOptions from './strategy_options';\n\n/** Loops through strategies with optional timeouts.\n *\n * Options:\n * - loop - whether it should loop through the substrategy list\n * - timeout - initial timeout for a single substrategy\n * - timeoutLimit - maximum timeout\n *\n * @param {Strategy[]} strategies\n * @param {Object} options\n */\nexport default class SequentialStrategy implements Strategy {\n strategies: Strategy[];\n loop: boolean;\n failFast: boolean;\n timeout: number;\n timeoutLimit: number;\n\n constructor(strategies: Strategy[], options: StrategyOptions) {\n this.strategies = strategies;\n this.loop = Boolean(options.loop);\n this.failFast = Boolean(options.failFast);\n this.timeout = options.timeout;\n this.timeoutLimit = options.timeoutLimit;\n }\n\n isSupported(): boolean {\n return Collections.any(this.strategies, Util.method('isSupported'));\n }\n\n connect(minPriority: number, callback: Function) {\n var strategies = this.strategies;\n var current = 0;\n var timeout = this.timeout;\n var runner = null;\n\n var tryNextStrategy = (error, handshake) => {\n if (handshake) {\n callback(null, handshake);\n } else {\n current = current + 1;\n if (this.loop) {\n current = current % strategies.length;\n }\n\n if (current < strategies.length) {\n if (timeout) {\n timeout = timeout * 2;\n if (this.timeoutLimit) {\n timeout = Math.min(timeout, this.timeoutLimit);\n }\n }\n runner = this.tryStrategy(\n strategies[current],\n minPriority,\n { timeout, failFast: this.failFast },\n tryNextStrategy\n );\n } else {\n callback(true);\n }\n }\n };\n\n runner = this.tryStrategy(\n strategies[current],\n minPriority,\n { timeout: timeout, failFast: this.failFast },\n tryNextStrategy\n );\n\n return {\n abort: function() {\n runner.abort();\n },\n forceMinPriority: function(p) {\n minPriority = p;\n if (runner) {\n runner.forceMinPriority(p);\n }\n }\n };\n }\n\n private tryStrategy(\n strategy: Strategy,\n minPriority: number,\n options: StrategyOptions,\n callback: Function\n ) {\n var timer = null;\n var runner = null;\n\n if (options.timeout > 0) {\n timer = new Timer(options.timeout, function() {\n runner.abort();\n callback(true);\n });\n }\n\n runner = strategy.connect(minPriority, function(error, handshake) {\n if (error && timer && timer.isRunning() && !options.failFast) {\n // advance to the next strategy after the timeout\n return;\n }\n if (timer) {\n timer.ensureAborted();\n }\n callback(error, handshake);\n });\n\n return {\n abort: function() {\n if (timer) {\n timer.ensureAborted();\n }\n runner.abort();\n },\n forceMinPriority: function(p) {\n runner.forceMinPriority(p);\n }\n };\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport Strategy from './strategy';\n\n/** Launches all substrategies and emits prioritized connected transports.\n *\n * @param {Array} strategies\n */\nexport default class BestConnectedEverStrategy implements Strategy {\n strategies: Strategy[];\n\n constructor(strategies: Strategy[]) {\n this.strategies = strategies;\n }\n\n isSupported(): boolean {\n return Collections.any(this.strategies, Util.method('isSupported'));\n }\n\n connect(minPriority: number, callback: Function) {\n return connect(this.strategies, minPriority, function(i, runners) {\n return function(error, handshake) {\n runners[i].error = error;\n if (error) {\n if (allRunnersFailed(runners)) {\n callback(true);\n }\n return;\n }\n Collections.apply(runners, function(runner) {\n runner.forceMinPriority(handshake.transport.priority);\n });\n callback(null, handshake);\n };\n });\n }\n}\n\n/** Connects to all strategies in parallel.\n *\n * Callback builder should be a function that takes two arguments: index\n * and a list of runners. It should return another function that will be\n * passed to the substrategy with given index. Runners can be aborted using\n * abortRunner(s) functions from this class.\n *\n * @param {Array} strategies\n * @param {Function} callbackBuilder\n * @return {Object} strategy runner\n */\nfunction connect(\n strategies: Strategy[],\n minPriority: number,\n callbackBuilder: Function\n) {\n var runners = Collections.map(strategies, function(strategy, i, _, rs) {\n return strategy.connect(minPriority, callbackBuilder(i, rs));\n });\n return {\n abort: function() {\n Collections.apply(runners, abortRunner);\n },\n forceMinPriority: function(p) {\n Collections.apply(runners, function(runner) {\n runner.forceMinPriority(p);\n });\n }\n };\n}\n\nfunction allRunnersFailed(runners): boolean {\n return Collections.all(runners, function(runner) {\n return Boolean(runner.error);\n });\n}\n\nfunction abortRunner(runner) {\n if (!runner.error && !runner.aborted) {\n runner.abort();\n runner.aborted = true;\n }\n}\n","import Util from '../util';\nimport Runtime from 'runtime';\nimport Strategy from './strategy';\nimport SequentialStrategy from './sequential_strategy';\nimport StrategyOptions from './strategy_options';\nimport TransportStrategy from './transport_strategy';\nimport Timeline from '../timeline/timeline';\nimport * as Collections from '../utils/collections';\n\nexport interface TransportStrategyDictionary {\n [key: string]: TransportStrategy;\n}\n\n/** Caches the last successful transport and, after the first few attempts,\n * uses the cached transport for subsequent attempts.\n *\n * @param {Strategy} strategy\n * @param {Object} transports\n * @param {Object} options\n */\nexport default class WebSocketPrioritizedCachedStrategy implements Strategy {\n strategy: Strategy;\n transports: TransportStrategyDictionary;\n ttl: number;\n usingTLS: boolean;\n timeline: Timeline;\n\n constructor(\n strategy: Strategy,\n transports: TransportStrategyDictionary,\n options: StrategyOptions\n ) {\n this.strategy = strategy;\n this.transports = transports;\n this.ttl = options.ttl || 1800 * 1000;\n this.usingTLS = options.useTLS;\n this.timeline = options.timeline;\n }\n\n isSupported(): boolean {\n return this.strategy.isSupported();\n }\n\n connect(minPriority: number, callback: Function) {\n var usingTLS = this.usingTLS;\n var info = fetchTransportCache(usingTLS);\n var cacheSkipCount = info && info.cacheSkipCount ? info.cacheSkipCount : 0;\n\n var strategies = [this.strategy];\n if (info && info.timestamp + this.ttl >= Util.now()) {\n var transport = this.transports[info.transport];\n if (transport) {\n if (['ws', 'wss'].includes(info.transport) || cacheSkipCount > 3) {\n this.timeline.info({\n cached: true,\n transport: info.transport,\n latency: info.latency\n });\n strategies.push(\n new SequentialStrategy([transport], {\n timeout: info.latency * 2 + 1000,\n failFast: true\n })\n );\n } else {\n cacheSkipCount++;\n }\n }\n }\n\n var startTimestamp = Util.now();\n var runner = strategies\n .pop()\n .connect(minPriority, function cb(error, handshake) {\n if (error) {\n flushTransportCache(usingTLS);\n if (strategies.length > 0) {\n startTimestamp = Util.now();\n runner = strategies.pop().connect(minPriority, cb);\n } else {\n callback(error);\n }\n } else {\n storeTransportCache(\n usingTLS,\n handshake.transport.name,\n Util.now() - startTimestamp,\n cacheSkipCount\n );\n callback(null, handshake);\n }\n });\n\n return {\n abort: function() {\n runner.abort();\n },\n forceMinPriority: function(p) {\n minPriority = p;\n if (runner) {\n runner.forceMinPriority(p);\n }\n }\n };\n }\n}\n\nfunction getTransportCacheKey(usingTLS: boolean): string {\n return 'pusherTransport' + (usingTLS ? 'TLS' : 'NonTLS');\n}\n\nfunction fetchTransportCache(usingTLS: boolean): any {\n var storage = Runtime.getLocalStorage();\n if (storage) {\n try {\n var serializedCache = storage[getTransportCacheKey(usingTLS)];\n if (serializedCache) {\n return JSON.parse(serializedCache);\n }\n } catch (e) {\n flushTransportCache(usingTLS);\n }\n }\n return null;\n}\n\nfunction storeTransportCache(\n usingTLS: boolean,\n transport: TransportStrategy,\n latency: number,\n cacheSkipCount: number\n) {\n var storage = Runtime.getLocalStorage();\n if (storage) {\n try {\n storage[getTransportCacheKey(usingTLS)] = Collections.safeJSONStringify({\n timestamp: Util.now(),\n transport: transport,\n latency: latency,\n cacheSkipCount: cacheSkipCount\n });\n } catch (e) {\n // catch over quota exceptions raised by localStorage\n }\n }\n}\n\nfunction flushTransportCache(usingTLS: boolean) {\n var storage = Runtime.getLocalStorage();\n if (storage) {\n try {\n delete storage[getTransportCacheKey(usingTLS)];\n } catch (e) {\n // catch exceptions raised by localStorage\n }\n }\n}\n","import { OneOffTimer as Timer } from '../utils/timers';\nimport Strategy from './strategy';\nimport StrategyOptions from './strategy_options';\n\n/** Runs substrategy after specified delay.\n *\n * Options:\n * - delay - time in miliseconds to delay the substrategy attempt\n *\n * @param {Strategy} strategy\n * @param {Object} options\n */\nexport default class DelayedStrategy implements Strategy {\n strategy: Strategy;\n options: { delay: number };\n\n constructor(strategy: Strategy, { delay: number }) {\n this.strategy = strategy;\n this.options = { delay: number };\n }\n\n isSupported(): boolean {\n return this.strategy.isSupported();\n }\n\n connect(minPriority: number, callback: Function) {\n var strategy = this.strategy;\n var runner;\n var timer = new Timer(this.options.delay, function() {\n runner = strategy.connect(minPriority, callback);\n });\n\n return {\n abort: function() {\n timer.ensureAborted();\n if (runner) {\n runner.abort();\n }\n },\n forceMinPriority: function(p) {\n minPriority = p;\n if (runner) {\n runner.forceMinPriority(p);\n }\n }\n };\n }\n}\n","import Strategy from './strategy';\nimport StrategyRunner from './strategy_runner';\n\n/** Proxies method calls to one of substrategies basing on the test function.\n *\n * @param {Function} test\n * @param {Strategy} trueBranch strategy used when test returns true\n * @param {Strategy} falseBranch strategy used when test returns false\n */\nexport default class IfStrategy implements Strategy {\n test: () => boolean;\n trueBranch: Strategy;\n falseBranch: Strategy;\n\n constructor(\n test: () => boolean,\n trueBranch: Strategy,\n falseBranch: Strategy\n ) {\n this.test = test;\n this.trueBranch = trueBranch;\n this.falseBranch = falseBranch;\n }\n\n isSupported(): boolean {\n var branch = this.test() ? this.trueBranch : this.falseBranch;\n return branch.isSupported();\n }\n\n connect(minPriority: number, callback: Function): StrategyRunner {\n var branch = this.test() ? this.trueBranch : this.falseBranch;\n return branch.connect(minPriority, callback);\n }\n}\n","import Strategy from './strategy';\nimport StrategyRunner from './strategy_runner';\n\n/** Launches the substrategy and terminates on the first open connection.\n *\n * @param {Strategy} strategy\n */\nexport default class FirstConnectedStrategy implements Strategy {\n strategy: Strategy;\n\n constructor(strategy: Strategy) {\n this.strategy = strategy;\n }\n\n isSupported(): boolean {\n return this.strategy.isSupported();\n }\n\n connect(minPriority: number, callback: Function): StrategyRunner {\n var runner = this.strategy.connect(minPriority, function(error, handshake) {\n if (handshake) {\n runner.abort();\n }\n callback(error, handshake);\n });\n return runner;\n }\n}\n","import * as Collections from 'core/utils/collections';\nimport TransportManager from 'core/transports/transport_manager';\nimport Strategy from 'core/strategies/strategy';\nimport SequentialStrategy from 'core/strategies/sequential_strategy';\nimport BestConnectedEverStrategy from 'core/strategies/best_connected_ever_strategy';\nimport WebSocketPrioritizedCachedStrategy, {\n TransportStrategyDictionary\n} from 'core/strategies/websocket_prioritized_cached_strategy';\nimport DelayedStrategy from 'core/strategies/delayed_strategy';\nimport IfStrategy from 'core/strategies/if_strategy';\nimport FirstConnectedStrategy from 'core/strategies/first_connected_strategy';\nimport { Config } from 'core/config';\nimport StrategyOptions from 'core/strategies/strategy_options';\n\nfunction testSupportsStrategy(strategy: Strategy) {\n return function() {\n return strategy.isSupported();\n };\n}\n\nvar getDefaultStrategy = function(\n config: Config,\n baseOptions: StrategyOptions,\n defineTransport: Function\n): Strategy {\n var definedTransports = {};\n\n function defineTransportStrategy(\n name: string,\n type: string,\n priority: number,\n options: StrategyOptions,\n manager?: TransportManager\n ) {\n var transport = defineTransport(\n config,\n name,\n type,\n priority,\n options,\n manager\n );\n\n definedTransports[name] = transport;\n\n return transport;\n }\n\n var ws_options: StrategyOptions = Object.assign({}, baseOptions, {\n hostNonTLS: config.wsHost + ':' + config.wsPort,\n hostTLS: config.wsHost + ':' + config.wssPort,\n httpPath: config.wsPath\n });\n var wss_options: StrategyOptions = Collections.extend({}, ws_options, {\n useTLS: true\n });\n var http_options: StrategyOptions = Object.assign({}, baseOptions, {\n hostNonTLS: config.httpHost + ':' + config.httpPort,\n hostTLS: config.httpHost + ':' + config.httpsPort,\n httpPath: config.httpPath\n });\n var timeouts = {\n loop: true,\n timeout: 15000,\n timeoutLimit: 60000\n };\n\n var ws_manager = new TransportManager({\n minPingDelay: 10000,\n maxPingDelay: config.activityTimeout\n });\n var streaming_manager = new TransportManager({\n lives: 2,\n minPingDelay: 10000,\n maxPingDelay: config.activityTimeout\n });\n\n var ws_transport = defineTransportStrategy(\n 'ws',\n 'ws',\n 3,\n ws_options,\n ws_manager\n );\n var wss_transport = defineTransportStrategy(\n 'wss',\n 'ws',\n 3,\n wss_options,\n ws_manager\n );\n var xhr_streaming_transport = defineTransportStrategy(\n 'xhr_streaming',\n 'xhr_streaming',\n 1,\n http_options,\n streaming_manager\n );\n var xhr_polling_transport = defineTransportStrategy(\n 'xhr_polling',\n 'xhr_polling',\n 1,\n http_options\n );\n\n var ws_loop = new SequentialStrategy([ws_transport], timeouts);\n var wss_loop = new SequentialStrategy([wss_transport], timeouts);\n var streaming_loop = new SequentialStrategy(\n [xhr_streaming_transport],\n timeouts\n );\n var polling_loop = new SequentialStrategy([xhr_polling_transport], timeouts);\n\n var http_loop = new SequentialStrategy(\n [\n new IfStrategy(\n testSupportsStrategy(streaming_loop),\n new BestConnectedEverStrategy([\n streaming_loop,\n new DelayedStrategy(polling_loop, { delay: 4000 })\n ]),\n polling_loop\n )\n ],\n timeouts\n );\n\n var wsStrategy;\n if (baseOptions.useTLS) {\n wsStrategy = new BestConnectedEverStrategy([\n ws_loop,\n new DelayedStrategy(http_loop, { delay: 2000 })\n ]);\n } else {\n wsStrategy = new BestConnectedEverStrategy([\n ws_loop,\n new DelayedStrategy(wss_loop, { delay: 2000 }),\n new DelayedStrategy(http_loop, { delay: 5000 })\n ]);\n }\n\n return new WebSocketPrioritizedCachedStrategy(\n new FirstConnectedStrategy(\n new IfStrategy(testSupportsStrategy(ws_transport), wsStrategy, http_loop)\n ),\n definedTransports,\n {\n ttl: 1800000,\n timeline: baseOptions.timeline,\n useTLS: baseOptions.useTLS\n }\n );\n};\n\nexport default getDefaultStrategy;\n","import Runtime from 'runtime';\nimport RequestHooks from './request_hooks';\nimport Ajax from './ajax';\nimport { default as EventsDispatcher } from '../events/dispatcher';\n\nconst MAX_BUFFER_LENGTH = 256 * 1024;\n\nexport default class HTTPRequest extends EventsDispatcher {\n hooks: RequestHooks;\n method: string;\n url: string;\n position: number;\n xhr: Ajax;\n unloader: Function;\n\n constructor(hooks: RequestHooks, method: string, url: string) {\n super();\n this.hooks = hooks;\n this.method = method;\n this.url = url;\n }\n\n start(payload?: any) {\n this.position = 0;\n this.xhr = this.hooks.getRequest(this);\n\n this.unloader = () => {\n this.close();\n };\n Runtime.addUnloadListener(this.unloader);\n\n this.xhr.open(this.method, this.url, true);\n\n if (this.xhr.setRequestHeader) {\n this.xhr.setRequestHeader('Content-Type', 'application/json'); // ReactNative doesn't set this header by default.\n }\n this.xhr.send(payload);\n }\n\n close() {\n if (this.unloader) {\n Runtime.removeUnloadListener(this.unloader);\n this.unloader = null;\n }\n if (this.xhr) {\n this.hooks.abortRequest(this.xhr);\n this.xhr = null;\n }\n }\n\n onChunk(status: number, data: any) {\n while (true) {\n var chunk = this.advanceBuffer(data);\n if (chunk) {\n this.emit('chunk', { status: status, data: chunk });\n } else {\n break;\n }\n }\n if (this.isBufferTooLong(data)) {\n this.emit('buffer_too_long');\n }\n }\n\n private advanceBuffer(buffer: any[]): any {\n var unreadData = buffer.slice(this.position);\n var endOfLinePosition = unreadData.indexOf('\\n');\n\n if (endOfLinePosition !== -1) {\n this.position += endOfLinePosition + 1;\n return unreadData.slice(0, endOfLinePosition);\n } else {\n // chunk is not finished yet, don't move the buffer pointer\n return null;\n }\n }\n\n private isBufferTooLong(buffer: any): boolean {\n return this.position === buffer.length && buffer.length > MAX_BUFFER_LENGTH;\n }\n}\n","enum State {\n CONNECTING = 0,\n OPEN = 1,\n CLOSED = 3\n}\n\nexport default State;\n","import URLLocation from './url_location';\nimport State from './state';\nimport Socket from '../socket';\nimport SocketHooks from './socket_hooks';\nimport Util from '../util';\nimport Ajax from './ajax';\nimport HTTPRequest from './http_request';\nimport Runtime from 'runtime';\n\nvar autoIncrement = 1;\n\nclass HTTPSocket implements Socket {\n hooks: SocketHooks;\n session: string;\n location: URLLocation;\n readyState: State;\n stream: HTTPRequest;\n\n onopen: () => void;\n onerror: (error: any) => void;\n onclose: (closeEvent: any) => void;\n onmessage: (message: any) => void;\n onactivity: () => void;\n\n constructor(hooks: SocketHooks, url: string) {\n this.hooks = hooks;\n this.session = randomNumber(1000) + '/' + randomString(8);\n this.location = getLocation(url);\n this.readyState = State.CONNECTING;\n this.openStream();\n }\n\n send(payload: any) {\n return this.sendRaw(JSON.stringify([payload]));\n }\n\n ping() {\n this.hooks.sendHeartbeat(this);\n }\n\n close(code: any, reason: any) {\n this.onClose(code, reason, true);\n }\n\n /** For internal use only */\n sendRaw(payload: any): boolean {\n if (this.readyState === State.OPEN) {\n try {\n Runtime.createSocketRequest(\n 'POST',\n getUniqueURL(getSendURL(this.location, this.session))\n ).start(payload);\n return true;\n } catch (e) {\n return false;\n }\n } else {\n return false;\n }\n }\n\n /** For internal use only */\n reconnect() {\n this.closeStream();\n this.openStream();\n }\n\n /** For internal use only */\n onClose(code, reason, wasClean) {\n this.closeStream();\n this.readyState = State.CLOSED;\n if (this.onclose) {\n this.onclose({\n code: code,\n reason: reason,\n wasClean: wasClean\n });\n }\n }\n\n private onChunk(chunk) {\n if (chunk.status !== 200) {\n return;\n }\n if (this.readyState === State.OPEN) {\n this.onActivity();\n }\n\n var payload;\n var type = chunk.data.slice(0, 1);\n switch (type) {\n case 'o':\n payload = JSON.parse(chunk.data.slice(1) || '{}');\n this.onOpen(payload);\n break;\n case 'a':\n payload = JSON.parse(chunk.data.slice(1) || '[]');\n for (var i = 0; i < payload.length; i++) {\n this.onEvent(payload[i]);\n }\n break;\n case 'm':\n payload = JSON.parse(chunk.data.slice(1) || 'null');\n this.onEvent(payload);\n break;\n case 'h':\n this.hooks.onHeartbeat(this);\n break;\n case 'c':\n payload = JSON.parse(chunk.data.slice(1) || '[]');\n this.onClose(payload[0], payload[1], true);\n break;\n }\n }\n\n private onOpen(options) {\n if (this.readyState === State.CONNECTING) {\n if (options && options.hostname) {\n this.location.base = replaceHost(this.location.base, options.hostname);\n }\n this.readyState = State.OPEN;\n\n if (this.onopen) {\n this.onopen();\n }\n } else {\n this.onClose(1006, 'Server lost session', true);\n }\n }\n\n private onEvent(event) {\n if (this.readyState === State.OPEN && this.onmessage) {\n this.onmessage({ data: event });\n }\n }\n\n private onActivity() {\n if (this.onactivity) {\n this.onactivity();\n }\n }\n\n private onError(error) {\n if (this.onerror) {\n this.onerror(error);\n }\n }\n\n private openStream() {\n this.stream = Runtime.createSocketRequest(\n 'POST',\n getUniqueURL(this.hooks.getReceiveURL(this.location, this.session))\n );\n\n this.stream.bind('chunk', chunk => {\n this.onChunk(chunk);\n });\n this.stream.bind('finished', status => {\n this.hooks.onFinished(this, status);\n });\n this.stream.bind('buffer_too_long', () => {\n this.reconnect();\n });\n\n try {\n this.stream.start();\n } catch (error) {\n Util.defer(() => {\n this.onError(error);\n this.onClose(1006, 'Could not start streaming', false);\n });\n }\n }\n\n private closeStream() {\n if (this.stream) {\n this.stream.unbind_all();\n this.stream.close();\n this.stream = null;\n }\n }\n}\n\nfunction getLocation(url): URLLocation {\n var parts = /([^\\?]*)\\/*(\\??.*)/.exec(url);\n return {\n base: parts[1],\n queryString: parts[2]\n };\n}\n\nfunction getSendURL(url: URLLocation, session: string): string {\n return url.base + '/' + session + '/xhr_send';\n}\n\nfunction getUniqueURL(url: string): string {\n var separator = url.indexOf('?') === -1 ? '?' : '&';\n return url + separator + 't=' + +new Date() + '&n=' + autoIncrement++;\n}\n\nfunction replaceHost(url: string, hostname: string): string {\n var urlParts = /(https?:\\/\\/)([^\\/:]+)((\\/|:)?.*)/.exec(url);\n return urlParts[1] + hostname + urlParts[3];\n}\n\nfunction randomNumber(max: number): number {\n return Runtime.randomInt(max);\n}\n\nfunction randomString(length: number): string {\n var result = [];\n\n for (var i = 0; i < length; i++) {\n result.push(randomNumber(32).toString(32));\n }\n\n return result.join('');\n}\n\nexport default HTTPSocket;\n","import SocketHooks from './socket_hooks';\nimport HTTPSocket from './http_socket';\n\nvar hooks: SocketHooks = {\n getReceiveURL: function(url, session) {\n return url.base + '/' + session + '/xhr_streaming' + url.queryString;\n },\n onHeartbeat: function(socket) {\n socket.sendRaw('[]');\n },\n sendHeartbeat: function(socket) {\n socket.sendRaw('[]');\n },\n onFinished: function(socket, status) {\n socket.onClose(1006, 'Connection interrupted (' + status + ')', false);\n }\n};\n\nexport default hooks;\n","import SocketHooks from './socket_hooks';\nimport URLLocation from './url_location';\nimport HTTPSocket from './http_socket';\n\nvar hooks: SocketHooks = {\n getReceiveURL: function(url: URLLocation, session: string): string {\n return url.base + '/' + session + '/xhr' + url.queryString;\n },\n onHeartbeat: function() {\n // next HTTP request will reset server's activity timer\n },\n sendHeartbeat: function(socket) {\n socket.sendRaw('[]');\n },\n onFinished: function(socket, status) {\n if (status === 200) {\n socket.reconnect();\n } else {\n socket.onClose(1006, 'Connection interrupted (' + status + ')', false);\n }\n }\n};\n\nexport default hooks;\n","import HTTPRequest from 'core/http/http_request';\nimport RequestHooks from 'core/http/request_hooks';\nimport Ajax from 'core/http/ajax';\nimport Runtime from 'runtime';\n\nvar hooks: RequestHooks = {\n getRequest: function(socket: HTTPRequest): Ajax {\n var Constructor = Runtime.getXHRAPI();\n var xhr = new Constructor();\n xhr.onreadystatechange = xhr.onprogress = function() {\n switch (xhr.readyState) {\n case 3:\n if (xhr.responseText && xhr.responseText.length > 0) {\n socket.onChunk(xhr.status, xhr.responseText);\n }\n break;\n case 4:\n // this happens only on errors, never after calling close\n if (xhr.responseText && xhr.responseText.length > 0) {\n socket.onChunk(xhr.status, xhr.responseText);\n }\n socket.emit('finished', xhr.status);\n socket.close();\n break;\n }\n };\n return xhr;\n },\n abortRequest: function(xhr: Ajax) {\n xhr.onreadystatechange = null;\n xhr.abort();\n }\n};\n\nexport default hooks;\n","import * as Collections from 'core/utils/collections';\nimport Transports from 'isomorphic/transports/transports';\nimport TimelineSender from 'core/timeline/timeline_sender';\nimport Ajax from 'core/http/ajax';\nimport getDefaultStrategy from './default_strategy';\nimport TransportsTable from 'core/transports/transports_table';\nimport transportConnectionInitializer from './transports/transport_connection_initializer';\nimport HTTPFactory from './http/http';\n\nvar Isomorphic: any = {\n getDefaultStrategy,\n Transports: Transports,\n transportConnectionInitializer,\n HTTPFactory,\n\n setup(PusherClass): void {\n PusherClass.ready();\n },\n\n getLocalStorage(): any {\n return undefined;\n },\n\n getClientFeatures(): any[] {\n return Collections.keys(\n Collections.filterObject({ ws: Transports.ws }, function(t) {\n return t.isSupported({});\n })\n );\n },\n\n getProtocol(): string {\n return 'http:';\n },\n\n isXHRSupported(): boolean {\n return true;\n },\n\n createSocketRequest(method: string, url: string) {\n if (this.isXHRSupported()) {\n return this.HTTPFactory.createXHR(method, url);\n } else {\n throw 'Cross-origin HTTP requests are not supported';\n }\n },\n\n createXHR(): Ajax {\n var Constructor = this.getXHRAPI();\n return new Constructor();\n },\n\n createWebSocket(url: string): any {\n var Constructor = this.getWebSocketAPI();\n return new Constructor(url);\n },\n\n addUnloadListener(listener: any) {},\n removeUnloadListener(listener: any) {}\n};\n\nexport default Isomorphic;\n","/** Initializes the transport.\n *\n * Fetches resources if needed and then transitions to initialized.\n */\nexport default function() {\n var self = this;\n\n self.timeline.info(\n self.buildTimelineMessage({\n transport: self.name + (self.options.useTLS ? 's' : '')\n })\n );\n\n if (self.hooks.isInitialized()) {\n self.changeState('initialized');\n } else {\n self.onClose();\n }\n}\n","import HTTPRequest from 'core/http/http_request';\nimport HTTPSocket from 'core/http/http_socket';\nimport SocketHooks from 'core/http/socket_hooks';\nimport RequestHooks from 'core/http/request_hooks';\nimport streamingHooks from 'core/http/http_streaming_socket';\nimport pollingHooks from 'core/http/http_polling_socket';\nimport xhrHooks from './http_xhr_request';\nimport HTTPFactory from 'core/http/http_factory';\n\nvar HTTP: HTTPFactory = {\n createStreamingSocket(url: string): HTTPSocket {\n return this.createSocket(streamingHooks, url);\n },\n\n createPollingSocket(url: string): HTTPSocket {\n return this.createSocket(pollingHooks, url);\n },\n\n createSocket(hooks: SocketHooks, url: string): HTTPSocket {\n return new HTTPSocket(hooks, url);\n },\n\n createXHR(method: string, url: string): HTTPRequest {\n return this.createRequest(xhrHooks, method, url);\n },\n\n createRequest(hooks: RequestHooks, method: string, url: string): HTTPRequest {\n return new HTTPRequest(hooks, method, url);\n }\n};\n\nexport default HTTP;\n","import { default as NativeNetInfo } from '@react-native-community/netinfo';\nimport EventsDispatcher from 'core/events/dispatcher';\nimport Util from 'core/util';\nimport Reachability from 'core/reachability';\n\nfunction hasOnlineConnectionState(connectionState): boolean {\n return connectionState.type.toLowerCase() !== 'none';\n}\n\nexport class NetInfo extends EventsDispatcher implements Reachability {\n online: boolean;\n\n constructor() {\n super();\n this.online = true;\n\n NativeNetInfo.fetch().then(connectionState => {\n this.online = hasOnlineConnectionState(connectionState);\n });\n\n NativeNetInfo.addEventListener(connectionState => {\n var isNowOnline = hasOnlineConnectionState(connectionState);\n\n // React Native counts the switch from Wi-Fi to Cellular\n // as a state change. Return if current and previous states\n // are both online/offline\n if (this.online === isNowOnline) return;\n this.online = isNowOnline;\n if (this.online) {\n this.emit('online');\n } else {\n this.emit('offline');\n }\n });\n }\n\n isOnline(): boolean {\n return this.online;\n }\n}\n\nexport var Network = new NetInfo();\n","export enum AuthRequestType {\n UserAuthentication = 'user-authentication',\n ChannelAuthorization = 'channel-authorization'\n}\n\nexport interface ChannelAuthorizationData {\n auth: string;\n channel_data?: string;\n shared_secret?: string;\n}\n\nexport type ChannelAuthorizationCallback = (\n error: Error | null,\n authData: ChannelAuthorizationData | null\n) => void;\n\nexport interface ChannelAuthorizationRequestParams {\n socketId: string;\n channelName: string;\n}\n\nexport interface ChannelAuthorizationHandler {\n (\n params: ChannelAuthorizationRequestParams,\n callback: ChannelAuthorizationCallback\n ): void;\n}\n\nexport interface UserAuthenticationData {\n auth: string;\n user_data: string;\n}\n\nexport type UserAuthenticationCallback = (\n error: Error | null,\n authData: UserAuthenticationData | null\n) => void;\n\nexport interface UserAuthenticationRequestParams {\n socketId: string;\n}\n\nexport interface UserAuthenticationHandler {\n (\n params: UserAuthenticationRequestParams,\n callback: UserAuthenticationCallback\n ): void;\n}\n\nexport type AuthTransportCallback =\n | ChannelAuthorizationCallback\n | UserAuthenticationCallback;\n\nexport interface InternalAuthOptions {\n transport: 'ajax' | 'jsonp';\n endpoint: string;\n params?: any;\n headers?: any;\n paramsProvider?: () => any;\n headersProvider?: () => any;\n}\n\nexport type CustomAuthOptions = {\n customHandler: AuthHandler;\n};\n\nexport type AuthOptionsT =\n | InternalAuthOptions\n | CustomAuthOptions;\n\nexport declare type UserAuthenticationOptions = AuthOptionsT<\n UserAuthenticationHandler\n>;\nexport declare type ChannelAuthorizationOptions = AuthOptionsT<\n ChannelAuthorizationHandler\n>;\n","import TimelineSender from 'core/timeline/timeline_sender';\nimport * as Collections from 'core/utils/collections';\nimport Util from 'core/util';\nimport Runtime from 'runtime';\nimport { AuthTransport } from 'core/auth/auth_transports';\nimport AbstractRuntime from 'runtimes/interface';\nimport UrlStore from 'core/utils/url_store';\nimport {\n AuthRequestType,\n AuthTransportCallback,\n InternalAuthOptions\n} from 'core/auth/options';\nimport { HTTPAuthError } from 'core/errors';\n\nconst ajax: AuthTransport = function(\n context: AbstractRuntime,\n query: string,\n authOptions: InternalAuthOptions,\n authRequestType: AuthRequestType,\n callback: AuthTransportCallback\n) {\n const xhr = Runtime.createXHR();\n xhr.open('POST', authOptions.endpoint, true);\n\n // add request headers\n xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');\n for (var headerName in authOptions.headers) {\n xhr.setRequestHeader(headerName, authOptions.headers[headerName]);\n }\n if (authOptions.headersProvider != null) {\n let dynamicHeaders = authOptions.headersProvider();\n for (var headerName in dynamicHeaders) {\n xhr.setRequestHeader(headerName, dynamicHeaders[headerName]);\n }\n }\n\n xhr.onreadystatechange = function() {\n if (xhr.readyState === 4) {\n if (xhr.status === 200) {\n let data;\n let parsed = false;\n\n try {\n data = JSON.parse(xhr.responseText);\n parsed = true;\n } catch (e) {\n callback(\n new HTTPAuthError(\n 200,\n `JSON returned from ${authRequestType.toString()} endpoint was invalid, yet status code was 200. Data was: ${\n xhr.responseText\n }`\n ),\n null\n );\n }\n\n if (parsed) {\n // prevents double execution.\n callback(null, data);\n }\n } else {\n let suffix = '';\n switch (authRequestType) {\n case AuthRequestType.UserAuthentication:\n suffix = UrlStore.buildLogSuffix('authenticationEndpoint');\n break;\n case AuthRequestType.ChannelAuthorization:\n suffix = `Clients must be authorized to join private or presence channels. ${UrlStore.buildLogSuffix(\n 'authorizationEndpoint'\n )}`;\n break;\n }\n callback(\n new HTTPAuthError(\n xhr.status,\n `Unable to retrieve auth string from ${authRequestType.toString()} endpoint - ` +\n `received status: ${xhr.status} from ${authOptions.endpoint}. ${suffix}`\n ),\n null\n );\n }\n }\n };\n\n xhr.send(query);\n return xhr;\n};\n\nexport default ajax;\n","import Logger from 'core/logger';\nimport TimelineSender from 'core/timeline/timeline_sender';\nimport * as Collections from 'core/utils/collections';\nimport Util from 'core/util';\nimport Runtime from 'runtime';\nimport TimelineTransport from 'core/timeline/timeline_transport';\n\nvar getAgent = function(sender: TimelineSender, useTLS: boolean) {\n return function(data: any, callback: Function) {\n var scheme = 'http' + (useTLS ? 's' : '') + '://';\n var url =\n scheme + (sender.host || sender.options.host) + sender.options.path;\n var query = Collections.buildQueryString(data);\n\n url += '/' + 2 + '?' + query;\n\n var xhr = Runtime.createXHR();\n xhr.open('GET', url, true);\n\n xhr.onreadystatechange = function() {\n if (xhr.readyState === 4) {\n let { status, responseText } = xhr;\n if (status !== 200) {\n Logger.debug(\n `TimelineSender Error: received ${status} from stats.pusher.com`\n );\n return;\n }\n\n try {\n var { host } = JSON.parse(responseText);\n } catch (e) {\n Logger.debug(`TimelineSenderError: invalid response ${responseText}`);\n }\n if (host) {\n sender.host = host;\n }\n }\n };\n\n xhr.send();\n };\n};\n\nvar xhr = {\n name: 'xhr',\n getAgent\n};\n\nexport default xhr;\n","import Isomorphic from 'isomorphic/runtime';\nimport Runtime from '../interface';\nimport { Network } from './net_info';\nimport xhrAuth from 'isomorphic/auth/xhr_auth';\nimport { AuthTransports } from 'core/auth/auth_transports';\nimport xhrTimeline from 'isomorphic/timeline/xhr_timeline';\n\n// Very verbose but until unavoidable until\n// TypeScript 2.1, when spread attributes will be\n// supported\nconst {\n getDefaultStrategy,\n Transports,\n setup,\n getProtocol,\n isXHRSupported,\n getLocalStorage,\n createXHR,\n createWebSocket,\n addUnloadListener,\n removeUnloadListener,\n transportConnectionInitializer,\n createSocketRequest,\n HTTPFactory\n} = Isomorphic;\n\nconst ReactNative: Runtime = {\n getDefaultStrategy,\n Transports,\n setup,\n getProtocol,\n isXHRSupported,\n getLocalStorage,\n createXHR,\n createWebSocket,\n addUnloadListener,\n removeUnloadListener,\n transportConnectionInitializer,\n createSocketRequest,\n HTTPFactory,\n\n TimelineTransport: xhrTimeline,\n\n getAuthorizers(): AuthTransports {\n return { ajax: xhrAuth };\n },\n\n getWebSocketAPI() {\n return WebSocket;\n },\n\n getXHRAPI() {\n return XMLHttpRequest;\n },\n\n getNetwork() {\n return Network;\n },\n\n randomInt(max: number): number {\n return Math.floor(Math.random() * max);\n }\n};\n\nexport default ReactNative;\n","enum TimelineLevel {\n ERROR = 3,\n INFO = 6,\n DEBUG = 7\n}\n\nexport default TimelineLevel;\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport { default as Level } from './level';\n\nexport interface TimelineOptions {\n level?: Level;\n limit?: number;\n version?: string;\n cluster?: string;\n features?: string[];\n params?: any;\n}\n\nexport default class Timeline {\n key: string;\n session: number;\n events: any[];\n options: TimelineOptions;\n sent: number;\n uniqueID: number;\n\n constructor(key: string, session: number, options: TimelineOptions) {\n this.key = key;\n this.session = session;\n this.events = [];\n this.options = options || {};\n this.sent = 0;\n this.uniqueID = 0;\n }\n\n log(level, event) {\n if (level <= this.options.level) {\n this.events.push(\n Collections.extend({}, event, { timestamp: Util.now() })\n );\n if (this.options.limit && this.events.length > this.options.limit) {\n this.events.shift();\n }\n }\n }\n\n error(event) {\n this.log(Level.ERROR, event);\n }\n\n info(event) {\n this.log(Level.INFO, event);\n }\n\n debug(event) {\n this.log(Level.DEBUG, event);\n }\n\n isEmpty() {\n return this.events.length === 0;\n }\n\n send(sendfn, callback) {\n var data = Collections.extend(\n {\n session: this.session,\n bundle: this.sent + 1,\n key: this.key,\n lib: 'js',\n version: this.options.version,\n cluster: this.options.cluster,\n features: this.options.features,\n timeline: this.events\n },\n this.options.params\n );\n\n this.events = [];\n sendfn(data, (error, result) => {\n if (!error) {\n this.sent++;\n }\n if (callback) {\n callback(error, result);\n }\n });\n\n return true;\n }\n\n generateUniqueID(): number {\n this.uniqueID++;\n return this.uniqueID;\n }\n}\n","import Factory from '../utils/factory';\nimport Util from '../util';\nimport * as Errors from '../errors';\nimport * as Collections from '../utils/collections';\nimport Strategy from './strategy';\nimport Transport from '../transports/transport';\nimport StrategyOptions from './strategy_options';\nimport Handshake from '../connection/handshake';\n\n/** Provides a strategy interface for transports.\n *\n * @param {String} name\n * @param {Number} priority\n * @param {Class} transport\n * @param {Object} options\n */\nexport default class TransportStrategy implements Strategy {\n name: string;\n priority: number;\n transport: Transport;\n options: StrategyOptions;\n\n constructor(\n name: string,\n priority: number,\n transport: Transport,\n options: StrategyOptions\n ) {\n this.name = name;\n this.priority = priority;\n this.transport = transport;\n this.options = options || {};\n }\n\n /** Returns whether the transport is supported in the browser.\n *\n * @returns {Boolean}\n */\n isSupported(): boolean {\n return this.transport.isSupported({\n useTLS: this.options.useTLS\n });\n }\n\n /** Launches a connection attempt and returns a strategy runner.\n *\n * @param {Function} callback\n * @return {Object} strategy runner\n */\n connect(minPriority: number, callback: Function) {\n if (!this.isSupported()) {\n return failAttempt(new Errors.UnsupportedStrategy(), callback);\n } else if (this.priority < minPriority) {\n return failAttempt(new Errors.TransportPriorityTooLow(), callback);\n }\n\n var connected = false;\n var transport = this.transport.createConnection(\n this.name,\n this.priority,\n this.options.key,\n this.options\n );\n var handshake = null;\n\n var onInitialized = function() {\n transport.unbind('initialized', onInitialized);\n transport.connect();\n };\n var onOpen = function() {\n handshake = Factory.createHandshake(transport, function(result) {\n connected = true;\n unbindListeners();\n callback(null, result);\n });\n };\n var onError = function(error) {\n unbindListeners();\n callback(error);\n };\n var onClosed = function() {\n unbindListeners();\n var serializedTransport;\n\n // The reason for this try/catch block is that on React Native\n // the WebSocket object is circular. Therefore transport.socket will\n // throw errors upon stringification. Collections.safeJSONStringify\n // discards circular references when serializing.\n serializedTransport = Collections.safeJSONStringify(transport);\n callback(new Errors.TransportClosed(serializedTransport));\n };\n\n var unbindListeners = function() {\n transport.unbind('initialized', onInitialized);\n transport.unbind('open', onOpen);\n transport.unbind('error', onError);\n transport.unbind('closed', onClosed);\n };\n\n transport.bind('initialized', onInitialized);\n transport.bind('open', onOpen);\n transport.bind('error', onError);\n transport.bind('closed', onClosed);\n\n // connect will be called automatically after initialization\n transport.initialize();\n\n return {\n abort: () => {\n if (connected) {\n return;\n }\n unbindListeners();\n if (handshake) {\n handshake.close();\n } else {\n transport.close();\n }\n },\n forceMinPriority: p => {\n if (connected) {\n return;\n }\n if (this.priority < p) {\n if (handshake) {\n handshake.close();\n } else {\n transport.close();\n }\n }\n }\n };\n }\n}\n\nfunction failAttempt(error: Error, callback: Function) {\n Util.defer(function() {\n callback(error);\n });\n return {\n abort: function() {},\n forceMinPriority: function() {}\n };\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport TransportManager from '../transports/transport_manager';\nimport * as Errors from '../errors';\nimport Strategy from './strategy';\nimport TransportStrategy from './transport_strategy';\nimport StrategyOptions from '../strategies/strategy_options';\nimport { Config } from '../config';\nimport Runtime from 'runtime';\n\nconst { Transports } = Runtime;\n\nexport var defineTransport = function(\n config: Config,\n name: string,\n type: string,\n priority: number,\n options: StrategyOptions,\n manager?: TransportManager\n): Strategy {\n var transportClass = Transports[type];\n if (!transportClass) {\n throw new Errors.UnsupportedTransport(type);\n }\n\n var enabled =\n (!config.enabledTransports ||\n Collections.arrayIndexOf(config.enabledTransports, name) !== -1) &&\n (!config.disabledTransports ||\n Collections.arrayIndexOf(config.disabledTransports, name) === -1);\n\n var transport;\n if (enabled) {\n options = Object.assign(\n { ignoreNullOrigin: config.ignoreNullOrigin },\n options\n );\n\n transport = new TransportStrategy(\n name,\n priority,\n manager ? manager.getAssistant(transportClass) : transportClass,\n options\n );\n } else {\n transport = UnsupportedStrategy;\n }\n\n return transport;\n};\n\nvar UnsupportedStrategy: Strategy = {\n isSupported: function() {\n return false;\n },\n connect: function(_, callback) {\n var deferred = Util.defer(function() {\n callback(new Errors.UnsupportedStrategy());\n });\n return {\n abort: function() {\n deferred.ensureAborted();\n },\n forceMinPriority: function() {}\n };\n }\n};\n","import {\n UserAuthenticationCallback,\n InternalAuthOptions,\n UserAuthenticationHandler,\n UserAuthenticationRequestParams,\n AuthRequestType\n} from './options';\n\nimport Runtime from 'runtime';\n\nconst composeChannelQuery = (\n params: UserAuthenticationRequestParams,\n authOptions: InternalAuthOptions\n) => {\n var query = 'socket_id=' + encodeURIComponent(params.socketId);\n\n for (var key in authOptions.params) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(authOptions.params[key]);\n }\n\n if (authOptions.paramsProvider != null) {\n let dynamicParams = authOptions.paramsProvider();\n for (var key in dynamicParams) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(dynamicParams[key]);\n }\n }\n\n return query;\n};\n\nconst UserAuthenticator = (\n authOptions: InternalAuthOptions\n): UserAuthenticationHandler => {\n if (typeof Runtime.getAuthorizers()[authOptions.transport] === 'undefined') {\n throw `'${authOptions.transport}' is not a recognized auth transport`;\n }\n\n return (\n params: UserAuthenticationRequestParams,\n callback: UserAuthenticationCallback\n ) => {\n const query = composeChannelQuery(params, authOptions);\n\n Runtime.getAuthorizers()[authOptions.transport](\n Runtime,\n query,\n authOptions,\n AuthRequestType.UserAuthentication,\n callback\n );\n };\n};\n\nexport default UserAuthenticator;\n","import {\n AuthRequestType,\n InternalAuthOptions,\n ChannelAuthorizationHandler,\n ChannelAuthorizationRequestParams,\n ChannelAuthorizationCallback\n} from './options';\n\nimport Runtime from 'runtime';\n\nconst composeChannelQuery = (\n params: ChannelAuthorizationRequestParams,\n authOptions: InternalAuthOptions\n) => {\n var query = 'socket_id=' + encodeURIComponent(params.socketId);\n\n query += '&channel_name=' + encodeURIComponent(params.channelName);\n\n for (var key in authOptions.params) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(authOptions.params[key]);\n }\n\n if (authOptions.paramsProvider != null) {\n let dynamicParams = authOptions.paramsProvider();\n for (var key in dynamicParams) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(dynamicParams[key]);\n }\n }\n\n return query;\n};\n\nconst ChannelAuthorizer = (\n authOptions: InternalAuthOptions\n): ChannelAuthorizationHandler => {\n if (typeof Runtime.getAuthorizers()[authOptions.transport] === 'undefined') {\n throw `'${authOptions.transport}' is not a recognized auth transport`;\n }\n\n return (\n params: ChannelAuthorizationRequestParams,\n callback: ChannelAuthorizationCallback\n ) => {\n const query = composeChannelQuery(params, authOptions);\n\n Runtime.getAuthorizers()[authOptions.transport](\n Runtime,\n query,\n authOptions,\n AuthRequestType.ChannelAuthorization,\n callback\n );\n };\n};\n\nexport default ChannelAuthorizer;\n","import Channel from '../channels/channel';\nimport {\n ChannelAuthorizationCallback,\n ChannelAuthorizationHandler,\n ChannelAuthorizationRequestParams,\n InternalAuthOptions\n} from './options';\n\nexport interface DeprecatedChannelAuthorizer {\n authorize(socketId: string, callback: ChannelAuthorizationCallback): void;\n}\n\nexport interface ChannelAuthorizerGenerator {\n (\n channel: Channel,\n options: DeprecatedAuthorizerOptions\n ): DeprecatedChannelAuthorizer;\n}\n\nexport interface DeprecatedAuthOptions {\n params?: any;\n headers?: any;\n}\n\nexport interface DeprecatedAuthorizerOptions {\n authTransport: 'ajax' | 'jsonp';\n authEndpoint: string;\n auth?: DeprecatedAuthOptions;\n}\n\nexport const ChannelAuthorizerProxy = (\n pusher,\n authOptions: InternalAuthOptions,\n channelAuthorizerGenerator: ChannelAuthorizerGenerator\n): ChannelAuthorizationHandler => {\n const deprecatedAuthorizerOptions: DeprecatedAuthorizerOptions = {\n authTransport: authOptions.transport,\n authEndpoint: authOptions.endpoint,\n auth: {\n params: authOptions.params,\n headers: authOptions.headers\n }\n };\n return (\n params: ChannelAuthorizationRequestParams,\n callback: ChannelAuthorizationCallback\n ) => {\n const channel = pusher.channel(params.channelName);\n // This line creates a new channel authorizer every time.\n // In the past, this was only done once per channel and reused.\n // We can do that again if we want to keep this behavior intact.\n const channelAuthorizer: DeprecatedChannelAuthorizer = channelAuthorizerGenerator(\n channel,\n deprecatedAuthorizerOptions\n );\n channelAuthorizer.authorize(params.socketId, callback);\n };\n};\n","import { Options } from './options';\nimport Defaults from './defaults';\nimport {\n ChannelAuthorizationHandler,\n UserAuthenticationHandler,\n ChannelAuthorizationOptions,\n AuthOptionsT,\n CustomAuthOptions\n} from './auth/options';\nimport UserAuthenticator from './auth/user_authenticator';\nimport ChannelAuthorizer from './auth/channel_authorizer';\nimport { ChannelAuthorizerProxy } from './auth/deprecated_channel_authorizer';\nimport Runtime from 'runtime';\nimport * as nacl from 'tweetnacl';\n\nexport type AuthTransport = 'ajax' | 'jsonp';\nexport type Transport =\n | 'ws'\n | 'wss'\n | 'xhr_streaming'\n | 'xhr_polling'\n | 'sockjs';\n\nexport interface Config {\n // these are all 'required' config parameters, it's not necessary for the user\n // to set them, but they have configured defaults.\n activityTimeout: number;\n enableStats: boolean;\n httpHost: string;\n httpPath: string;\n httpPort: number;\n httpsPort: number;\n pongTimeout: number;\n statsHost: string;\n unavailableTimeout: number;\n useTLS: boolean;\n wsHost: string;\n wsPath: string;\n wsPort: number;\n wssPort: number;\n userAuthenticator: UserAuthenticationHandler;\n channelAuthorizer: ChannelAuthorizationHandler;\n\n // these are all optional parameters or overrrides. The customer can set these\n // but it's not strictly necessary\n forceTLS?: boolean;\n cluster?: string;\n disabledTransports?: Transport[];\n enabledTransports?: Transport[];\n ignoreNullOrigin?: boolean;\n nacl?: nacl;\n timelineParams?: any;\n}\n\n// getConfig mainly sets the defaults for the options that are not provided\nexport function getConfig(opts: Options, pusher): Config {\n let config: Config = {\n activityTimeout: opts.activityTimeout || Defaults.activityTimeout,\n cluster: opts.cluster,\n httpPath: opts.httpPath || Defaults.httpPath,\n httpPort: opts.httpPort || Defaults.httpPort,\n httpsPort: opts.httpsPort || Defaults.httpsPort,\n pongTimeout: opts.pongTimeout || Defaults.pongTimeout,\n statsHost: opts.statsHost || Defaults.stats_host,\n unavailableTimeout: opts.unavailableTimeout || Defaults.unavailableTimeout,\n wsPath: opts.wsPath || Defaults.wsPath,\n wsPort: opts.wsPort || Defaults.wsPort,\n wssPort: opts.wssPort || Defaults.wssPort,\n\n enableStats: getEnableStatsConfig(opts),\n httpHost: getHttpHost(opts),\n useTLS: shouldUseTLS(opts),\n wsHost: getWebsocketHost(opts),\n\n userAuthenticator: buildUserAuthenticator(opts),\n channelAuthorizer: buildChannelAuthorizer(opts, pusher)\n };\n\n if ('disabledTransports' in opts)\n config.disabledTransports = opts.disabledTransports;\n if ('enabledTransports' in opts)\n config.enabledTransports = opts.enabledTransports;\n if ('ignoreNullOrigin' in opts)\n config.ignoreNullOrigin = opts.ignoreNullOrigin;\n if ('timelineParams' in opts) config.timelineParams = opts.timelineParams;\n if ('nacl' in opts) {\n config.nacl = opts.nacl;\n }\n\n return config;\n}\n\nfunction getHttpHost(opts: Options): string {\n if (opts.httpHost) {\n return opts.httpHost;\n }\n if (opts.cluster) {\n return `sockjs-${opts.cluster}.pusher.com`;\n }\n return Defaults.httpHost;\n}\n\nfunction getWebsocketHost(opts: Options): string {\n if (opts.wsHost) {\n return opts.wsHost;\n }\n return getWebsocketHostFromCluster(opts.cluster);\n}\n\nfunction getWebsocketHostFromCluster(cluster: string): string {\n return `ws-${cluster}.pusher.com`;\n}\n\nfunction shouldUseTLS(opts: Options): boolean {\n if (Runtime.getProtocol() === 'https:') {\n return true;\n } else if (opts.forceTLS === false) {\n return false;\n }\n return true;\n}\n\n// if enableStats is set take the value\n// if disableStats is set take the inverse\n// otherwise default to false\nfunction getEnableStatsConfig(opts: Options): boolean {\n if ('enableStats' in opts) {\n return opts.enableStats;\n }\n if ('disableStats' in opts) {\n return !opts.disableStats;\n }\n return false;\n}\n\nconst hasCustomHandler = (\n auth: AuthOptionsT\n): auth is CustomAuthOptions => {\n return 'customHandler' in auth && auth['customHandler'] != null;\n};\n\nfunction buildUserAuthenticator(opts: Options): UserAuthenticationHandler {\n const userAuthentication = {\n ...Defaults.userAuthentication,\n ...opts.userAuthentication\n };\n\n if (hasCustomHandler(userAuthentication)) {\n return userAuthentication['customHandler'];\n }\n\n return UserAuthenticator(userAuthentication);\n}\n\nfunction buildChannelAuth(opts: Options, pusher): ChannelAuthorizationOptions {\n let channelAuthorization: ChannelAuthorizationOptions;\n if ('channelAuthorization' in opts) {\n channelAuthorization = {\n ...Defaults.channelAuthorization,\n ...opts.channelAuthorization\n };\n } else {\n channelAuthorization = {\n transport: opts.authTransport || Defaults.authTransport,\n endpoint: opts.authEndpoint || Defaults.authEndpoint\n };\n\n if ('auth' in opts) {\n if ('params' in opts.auth) channelAuthorization.params = opts.auth.params;\n if ('headers' in opts.auth)\n channelAuthorization.headers = opts.auth.headers;\n }\n\n if ('authorizer' in opts) {\n return {\n customHandler: ChannelAuthorizerProxy(\n pusher,\n channelAuthorization,\n opts.authorizer\n )\n };\n }\n }\n return channelAuthorization;\n}\n\nfunction buildChannelAuthorizer(\n opts: Options,\n pusher\n): ChannelAuthorizationHandler {\n const channelAuthorization = buildChannelAuth(opts, pusher);\n\n if (hasCustomHandler(channelAuthorization)) {\n return channelAuthorization['customHandler'];\n }\n\n return ChannelAuthorizer(channelAuthorization);\n}\n","import Logger from './logger';\nimport Pusher from './pusher';\nimport EventsDispatcher from './events/dispatcher';\n\nexport default class WatchlistFacade extends EventsDispatcher {\n private pusher: Pusher;\n\n public constructor(pusher: Pusher) {\n super(function(eventName, data) {\n Logger.debug(`No callbacks on watchlist events for ${eventName}`);\n });\n\n this.pusher = pusher;\n this.bindWatchlistInternalEvent();\n }\n\n handleEvent(pusherEvent) {\n pusherEvent.data.events.forEach(watchlistEvent => {\n this.emit(watchlistEvent.name, watchlistEvent);\n });\n }\n\n private bindWatchlistInternalEvent() {\n this.pusher.connection.bind('message', pusherEvent => {\n var eventName = pusherEvent.event;\n if (eventName === 'pusher_internal:watchlist_events') {\n this.handleEvent(pusherEvent);\n }\n });\n }\n}\n","function flatPromise() {\n let resolve, reject;\n const promise = new Promise((res, rej) => {\n resolve = res;\n reject = rej;\n });\n return { promise, resolve, reject };\n}\n\nexport default flatPromise;\n","import Pusher from './pusher';\nimport Logger from './logger';\nimport {\n UserAuthenticationData,\n UserAuthenticationCallback\n} from './auth/options';\nimport Channel from './channels/channel';\nimport WatchlistFacade from './watchlist';\nimport EventsDispatcher from './events/dispatcher';\nimport flatPromise from './utils/flat_promise';\n\nexport default class UserFacade extends EventsDispatcher {\n pusher: Pusher;\n signin_requested: boolean = false;\n user_data: any = null;\n serverToUserChannel: Channel = null;\n signinDonePromise: Promise = null;\n watchlist: WatchlistFacade;\n private _signinDoneResolve: Function = null;\n\n public constructor(pusher: Pusher) {\n super(function(eventName, data) {\n Logger.debug('No callbacks on user for ' + eventName);\n });\n this.pusher = pusher;\n this.pusher.connection.bind('state_change', ({ previous, current }) => {\n if (previous !== 'connected' && current === 'connected') {\n this._signin();\n }\n if (previous === 'connected' && current !== 'connected') {\n this._cleanup();\n this._newSigninPromiseIfNeeded();\n }\n });\n\n this.watchlist = new WatchlistFacade(pusher);\n\n this.pusher.connection.bind('message', event => {\n var eventName = event.event;\n if (eventName === 'pusher:signin_success') {\n this._onSigninSuccess(event.data);\n }\n if (\n this.serverToUserChannel &&\n this.serverToUserChannel.name === event.channel\n ) {\n this.serverToUserChannel.handleEvent(event);\n }\n });\n }\n\n public signin() {\n if (this.signin_requested) {\n return;\n }\n\n this.signin_requested = true;\n this._signin();\n }\n\n private _signin() {\n if (!this.signin_requested) {\n return;\n }\n\n this._newSigninPromiseIfNeeded();\n\n if (this.pusher.connection.state !== 'connected') {\n // Signin will be attempted when the connection is connected\n return;\n }\n\n this.pusher.config.userAuthenticator(\n {\n socketId: this.pusher.connection.socket_id\n },\n this._onAuthorize\n );\n }\n\n private _onAuthorize: UserAuthenticationCallback = (\n err,\n authData: UserAuthenticationData\n ) => {\n if (err) {\n Logger.warn(`Error during signin: ${err}`);\n this._cleanup();\n return;\n }\n\n this.pusher.send_event('pusher:signin', {\n auth: authData.auth,\n user_data: authData.user_data\n });\n\n // Later when we get pusher:singin_success event, the user will be marked as signed in\n };\n\n private _onSigninSuccess(data: any) {\n try {\n this.user_data = JSON.parse(data.user_data);\n } catch (e) {\n Logger.error(`Failed parsing user data after signin: ${data.user_data}`);\n this._cleanup();\n return;\n }\n\n if (typeof this.user_data.id !== 'string' || this.user_data.id === '') {\n Logger.error(\n `user_data doesn't contain an id. user_data: ${this.user_data}`\n );\n this._cleanup();\n return;\n }\n\n // Signin succeeded\n this._signinDoneResolve();\n this._subscribeChannels();\n }\n\n private _subscribeChannels() {\n const ensure_subscribed = channel => {\n if (channel.subscriptionPending && channel.subscriptionCancelled) {\n channel.reinstateSubscription();\n } else if (\n !channel.subscriptionPending &&\n this.pusher.connection.state === 'connected'\n ) {\n channel.subscribe();\n }\n };\n\n this.serverToUserChannel = new Channel(\n `#server-to-user-${this.user_data.id}`,\n this.pusher\n );\n this.serverToUserChannel.bind_global((eventName, data) => {\n if (\n eventName.indexOf('pusher_internal:') === 0 ||\n eventName.indexOf('pusher:') === 0\n ) {\n // ignore internal events\n return;\n }\n this.emit(eventName, data);\n });\n ensure_subscribed(this.serverToUserChannel);\n }\n\n private _cleanup() {\n this.user_data = null;\n if (this.serverToUserChannel) {\n this.serverToUserChannel.unbind_all();\n this.serverToUserChannel.disconnect();\n this.serverToUserChannel = null;\n }\n\n if (this.signin_requested) {\n // If signin is in progress and cleanup is called,\n // Mark the current signin process as done.\n this._signinDoneResolve();\n }\n }\n\n private _newSigninPromiseIfNeeded() {\n if (!this.signin_requested) {\n return;\n }\n\n // If there is a promise and it is not resolved, return without creating a new one.\n if (this.signinDonePromise && !(this.signinDonePromise as any).done) {\n return;\n }\n\n // This promise is never rejected.\n // It gets resolved when the signin process is done whether it failed or succeeded\n const { promise, resolve, reject: _ } = flatPromise();\n (promise as any).done = false;\n const setDone = () => {\n (promise as any).done = true;\n };\n promise.then(setDone).catch(setDone);\n this.signinDonePromise = promise;\n this._signinDoneResolve = resolve;\n }\n}\n","import AbstractRuntime from '../runtimes/interface';\nimport Runtime from 'runtime';\nimport * as Collections from './utils/collections';\nimport Channels from './channels/channels';\nimport Channel from './channels/channel';\nimport { default as EventsDispatcher } from './events/dispatcher';\nimport Timeline from './timeline/timeline';\nimport TimelineSender from './timeline/timeline_sender';\nimport TimelineLevel from './timeline/level';\nimport { defineTransport } from './strategies/strategy_builder';\nimport ConnectionManager from './connection/connection_manager';\nimport { PeriodicTimer } from './utils/timers';\nimport Defaults from './defaults';\nimport Logger from './logger';\nimport Factory from './utils/factory';\nimport { Options, ClusterOptions, validateOptions } from './options';\nimport { Config, getConfig } from './config';\nimport StrategyOptions from './strategies/strategy_options';\nimport UserFacade from './user';\n\nexport default class Pusher {\n /* STATIC PROPERTIES */\n static instances: Pusher[] = [];\n static isReady: boolean = false;\n static logToConsole: boolean = false;\n\n // for jsonp\n static Runtime: AbstractRuntime = Runtime;\n static ScriptReceivers: any = (Runtime).ScriptReceivers;\n static DependenciesReceivers: any = (Runtime).DependenciesReceivers;\n static auth_callbacks: any = (Runtime).auth_callbacks;\n\n static ready() {\n Pusher.isReady = true;\n for (var i = 0, l = Pusher.instances.length; i < l; i++) {\n Pusher.instances[i].connect();\n }\n }\n\n static log: (message: any) => void;\n\n private static getClientFeatures(): string[] {\n return Collections.keys(\n Collections.filterObject({ ws: Runtime.Transports.ws }, function(t) {\n return t.isSupported({});\n })\n );\n }\n\n /* INSTANCE PROPERTIES */\n key: string;\n options: Options;\n config: Config;\n channels: Channels;\n global_emitter: EventsDispatcher;\n sessionID: number;\n timeline: Timeline;\n timelineSender: TimelineSender;\n connection: ConnectionManager;\n timelineSenderTimer: PeriodicTimer;\n user: UserFacade;\n constructor(app_key: string, options: Options) {\n checkAppKey(app_key);\n validateOptions(options);\n this.key = app_key;\n this.options = options;\n this.config = getConfig(this.options, this);\n\n this.channels = Factory.createChannels();\n this.global_emitter = new EventsDispatcher();\n this.sessionID = Runtime.randomInt(1000000000);\n\n this.timeline = new Timeline(this.key, this.sessionID, {\n cluster: this.config.cluster,\n features: Pusher.getClientFeatures(),\n params: this.config.timelineParams || {},\n limit: 50,\n level: TimelineLevel.INFO,\n version: Defaults.VERSION\n });\n if (this.config.enableStats) {\n this.timelineSender = Factory.createTimelineSender(this.timeline, {\n host: this.config.statsHost,\n path: '/timeline/v2/' + Runtime.TimelineTransport.name\n });\n }\n\n var getStrategy = (options: StrategyOptions) => {\n return Runtime.getDefaultStrategy(this.config, options, defineTransport);\n };\n\n this.connection = Factory.createConnectionManager(this.key, {\n getStrategy: getStrategy,\n timeline: this.timeline,\n activityTimeout: this.config.activityTimeout,\n pongTimeout: this.config.pongTimeout,\n unavailableTimeout: this.config.unavailableTimeout,\n useTLS: Boolean(this.config.useTLS)\n });\n\n this.connection.bind('connected', () => {\n this.subscribeAll();\n if (this.timelineSender) {\n this.timelineSender.send(this.connection.isUsingTLS());\n }\n });\n\n this.connection.bind('message', event => {\n var eventName = event.event;\n var internal = eventName.indexOf('pusher_internal:') === 0;\n if (event.channel) {\n var channel = this.channel(event.channel);\n if (channel) {\n channel.handleEvent(event);\n }\n }\n // Emit globally [deprecated]\n if (!internal) {\n this.global_emitter.emit(event.event, event.data);\n }\n });\n this.connection.bind('connecting', () => {\n this.channels.disconnect();\n });\n this.connection.bind('disconnected', () => {\n this.channels.disconnect();\n });\n this.connection.bind('error', err => {\n Logger.warn(err);\n });\n\n Pusher.instances.push(this);\n this.timeline.info({ instances: Pusher.instances.length });\n\n this.user = new UserFacade(this);\n\n if (Pusher.isReady) {\n this.connect();\n }\n }\n\n /**\n * Allows you to switch Pusher cluster without\n * losing all the channels/subscription binding\n * as this is internally managed by the SDK.\n */\n switchCluster(options: ClusterOptions) {\n const { appKey, cluster } = options;\n this.key = appKey;\n this.options = { ...this.options, cluster };\n this.config = getConfig(this.options, this);\n this.connection.switchCluster(this.key);\n }\n\n channel(name: string): Channel {\n return this.channels.find(name);\n }\n\n allChannels(): Channel[] {\n return this.channels.all();\n }\n\n connect() {\n this.connection.connect();\n\n if (this.timelineSender) {\n if (!this.timelineSenderTimer) {\n var usingTLS = this.connection.isUsingTLS();\n var timelineSender = this.timelineSender;\n this.timelineSenderTimer = new PeriodicTimer(60000, function() {\n timelineSender.send(usingTLS);\n });\n }\n }\n }\n\n disconnect() {\n this.connection.disconnect();\n\n if (this.timelineSenderTimer) {\n this.timelineSenderTimer.ensureAborted();\n this.timelineSenderTimer = null;\n }\n }\n\n bind(event_name: string, callback: Function, context?: any): Pusher {\n this.global_emitter.bind(event_name, callback, context);\n return this;\n }\n\n unbind(event_name?: string, callback?: Function, context?: any): Pusher {\n this.global_emitter.unbind(event_name, callback, context);\n return this;\n }\n\n bind_global(callback: Function): Pusher {\n this.global_emitter.bind_global(callback);\n return this;\n }\n\n unbind_global(callback?: Function): Pusher {\n this.global_emitter.unbind_global(callback);\n return this;\n }\n\n unbind_all(callback?: Function): Pusher {\n this.global_emitter.unbind_all();\n return this;\n }\n\n subscribeAll() {\n var channelName;\n for (channelName in this.channels.channels) {\n if (this.channels.channels.hasOwnProperty(channelName)) {\n this.subscribe(channelName);\n }\n }\n }\n\n subscribe(channel_name: string) {\n var channel = this.channels.add(channel_name, this);\n if (channel.subscriptionPending && channel.subscriptionCancelled) {\n channel.reinstateSubscription();\n } else if (\n !channel.subscriptionPending &&\n this.connection.state === 'connected'\n ) {\n channel.subscribe();\n }\n return channel;\n }\n\n unsubscribe(channel_name: string) {\n var channel = this.channels.find(channel_name);\n if (channel && channel.subscriptionPending) {\n channel.cancelSubscription();\n } else {\n channel = this.channels.remove(channel_name);\n if (channel && channel.subscribed) {\n channel.unsubscribe();\n }\n }\n }\n\n send_event(event_name: string, data: any, channel?: string) {\n return this.connection.send_event(event_name, data, channel);\n }\n\n shouldUseTLS(): boolean {\n return this.config.useTLS;\n }\n\n signin() {\n this.user.signin();\n }\n}\n\nfunction checkAppKey(key) {\n if (key === null || key === undefined) {\n throw 'You must pass your app key when you instantiate Pusher.';\n }\n}\n\nRuntime.setup(Pusher);\n","var g;\n\n// This works in non-strict mode\ng = (function() {\n\treturn this;\n})();\n\ntry {\n\t// This works if eval is allowed (see CSP)\n\tg = g || new Function(\"return this\")();\n} catch (e) {\n\t// This works if the window reference is available\n\tif (typeof window === \"object\") g = window;\n}\n\n// g can still be undefined, but nothing to do about it...\n// We return undefined, instead of nothing here, so it's\n// easier to handle this case. if(!global) { ...}\n\nmodule.exports = g;\n","import ConnectionManager from './connection/connection_manager';\nimport {\n ChannelAuthorizationOptions,\n UserAuthenticationOptions\n} from './auth/options';\nimport {\n ChannelAuthorizerGenerator,\n DeprecatedAuthOptions\n} from './auth/deprecated_channel_authorizer';\nimport { AuthTransport, Transport } from './config';\nimport * as nacl from 'tweetnacl';\nimport Logger from './logger';\n\nexport interface Options {\n activityTimeout?: number;\n\n auth?: DeprecatedAuthOptions; // DEPRECATED use channelAuthorization instead\n authEndpoint?: string; // DEPRECATED use channelAuthorization instead\n authTransport?: AuthTransport; // DEPRECATED use channelAuthorization instead\n authorizer?: ChannelAuthorizerGenerator; // DEPRECATED use channelAuthorization instead\n\n channelAuthorization?: ChannelAuthorizationOptions;\n userAuthentication?: UserAuthenticationOptions;\n\n cluster: string;\n enableStats?: boolean;\n disableStats?: boolean;\n disabledTransports?: Transport[];\n enabledTransports?: Transport[];\n forceTLS?: boolean;\n httpHost?: string;\n httpPath?: string;\n httpPort?: number;\n httpsPort?: number;\n ignoreNullOrigin?: boolean;\n nacl?: nacl;\n pongTimeout?: number;\n statsHost?: string;\n timelineParams?: any;\n unavailableTimeout?: number;\n wsHost?: string;\n wsPath?: string;\n wsPort?: number;\n wssPort?: number;\n}\n\nexport interface ClusterOptions {\n appKey: string;\n cluster: string;\n}\n\nexport function validateOptions(options) {\n if (options == null) {\n throw 'You must pass an options object';\n }\n if (options.cluster == null) {\n throw 'Options object must provide a cluster';\n }\n if ('disableStats' in options) {\n Logger.warn(\n 'The disableStats option is deprecated in favor of enableStats'\n );\n }\n}\n","// Copyright (C) 2016 Dmitry Chestnykh\n// MIT License. See LICENSE file for details.\n\n/**\n * Package base64 implements Base64 encoding and decoding.\n */\n\n// Invalid character used in decoding to indicate\n// that the character to decode is out of range of\n// alphabet and cannot be decoded.\nconst INVALID_BYTE = 256;\n\n/**\n * Implements standard Base64 encoding.\n *\n * Operates in constant time.\n */\nexport class Coder {\n // TODO(dchest): methods to encode chunk-by-chunk.\n\n constructor(private _paddingCharacter = \"=\") { }\n\n encodedLength(length: number): number {\n if (!this._paddingCharacter) {\n return (length * 8 + 5) / 6 | 0;\n }\n return (length + 2) / 3 * 4 | 0;\n }\n\n encode(data: Uint8Array): string {\n let out = \"\";\n\n let i = 0;\n for (; i < data.length - 2; i += 3) {\n let c = (data[i] << 16) | (data[i + 1] << 8) | (data[i + 2]);\n out += this._encodeByte((c >>> 3 * 6) & 63);\n out += this._encodeByte((c >>> 2 * 6) & 63);\n out += this._encodeByte((c >>> 1 * 6) & 63);\n out += this._encodeByte((c >>> 0 * 6) & 63);\n }\n\n const left = data.length - i;\n if (left > 0) {\n let c = (data[i] << 16) | (left === 2 ? data[i + 1] << 8 : 0);\n out += this._encodeByte((c >>> 3 * 6) & 63);\n out += this._encodeByte((c >>> 2 * 6) & 63);\n if (left === 2) {\n out += this._encodeByte((c >>> 1 * 6) & 63);\n } else {\n out += this._paddingCharacter || \"\";\n }\n out += this._paddingCharacter || \"\";\n }\n\n return out;\n }\n\n maxDecodedLength(length: number): number {\n if (!this._paddingCharacter) {\n return (length * 6 + 7) / 8 | 0;\n }\n return length / 4 * 3 | 0;\n }\n\n decodedLength(s: string): number {\n return this.maxDecodedLength(s.length - this._getPaddingLength(s));\n }\n\n decode(s: string): Uint8Array {\n if (s.length === 0) {\n return new Uint8Array(0);\n }\n const paddingLength = this._getPaddingLength(s);\n const length = s.length - paddingLength;\n const out = new Uint8Array(this.maxDecodedLength(length));\n let op = 0;\n let i = 0;\n let haveBad = 0;\n let v0 = 0, v1 = 0, v2 = 0, v3 = 0;\n for (; i < length - 4; i += 4) {\n v0 = this._decodeChar(s.charCodeAt(i + 0));\n v1 = this._decodeChar(s.charCodeAt(i + 1));\n v2 = this._decodeChar(s.charCodeAt(i + 2));\n v3 = this._decodeChar(s.charCodeAt(i + 3));\n out[op++] = (v0 << 2) | (v1 >>> 4);\n out[op++] = (v1 << 4) | (v2 >>> 2);\n out[op++] = (v2 << 6) | v3;\n haveBad |= v0 & INVALID_BYTE;\n haveBad |= v1 & INVALID_BYTE;\n haveBad |= v2 & INVALID_BYTE;\n haveBad |= v3 & INVALID_BYTE;\n }\n if (i < length - 1) {\n v0 = this._decodeChar(s.charCodeAt(i));\n v1 = this._decodeChar(s.charCodeAt(i + 1));\n out[op++] = (v0 << 2) | (v1 >>> 4);\n haveBad |= v0 & INVALID_BYTE;\n haveBad |= v1 & INVALID_BYTE;\n }\n if (i < length - 2) {\n v2 = this._decodeChar(s.charCodeAt(i + 2));\n out[op++] = (v1 << 4) | (v2 >>> 2);\n haveBad |= v2 & INVALID_BYTE;\n }\n if (i < length - 3) {\n v3 = this._decodeChar(s.charCodeAt(i + 3));\n out[op++] = (v2 << 6) | v3;\n haveBad |= v3 & INVALID_BYTE;\n }\n if (haveBad !== 0) {\n throw new Error(\"Base64Coder: incorrect characters for decoding\");\n }\n return out;\n }\n\n // Standard encoding have the following encoded/decoded ranges,\n // which we need to convert between.\n //\n // ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 0123456789 + /\n // Index: 0 - 25 26 - 51 52 - 61 62 63\n // ASCII: 65 - 90 97 - 122 48 - 57 43 47\n //\n\n // Encode 6 bits in b into a new character.\n protected _encodeByte(b: number): string {\n // Encoding uses constant time operations as follows:\n //\n // 1. Define comparison of A with B using (A - B) >>> 8:\n // if A > B, then result is positive integer\n // if A <= B, then result is 0\n //\n // 2. Define selection of C or 0 using bitwise AND: X & C:\n // if X == 0, then result is 0\n // if X != 0, then result is C\n //\n // 3. Start with the smallest comparison (b >= 0), which is always\n // true, so set the result to the starting ASCII value (65).\n //\n // 4. Continue comparing b to higher ASCII values, and selecting\n // zero if comparison isn't true, otherwise selecting a value\n // to add to result, which:\n //\n // a) undoes the previous addition\n // b) provides new value to add\n //\n let result = b;\n // b >= 0\n result += 65;\n // b > 25\n result += ((25 - b) >>> 8) & ((0 - 65) - 26 + 97);\n // b > 51\n result += ((51 - b) >>> 8) & ((26 - 97) - 52 + 48);\n // b > 61\n result += ((61 - b) >>> 8) & ((52 - 48) - 62 + 43);\n // b > 62\n result += ((62 - b) >>> 8) & ((62 - 43) - 63 + 47);\n\n return String.fromCharCode(result);\n }\n\n // Decode a character code into a byte.\n // Must return 256 if character is out of alphabet range.\n protected _decodeChar(c: number): number {\n // Decoding works similar to encoding: using the same comparison\n // function, but now it works on ranges: result is always incremented\n // by value, but this value becomes zero if the range is not\n // satisfied.\n //\n // Decoding starts with invalid value, 256, which is then\n // subtracted when the range is satisfied. If none of the ranges\n // apply, the function returns 256, which is then checked by\n // the caller to throw error.\n let result = INVALID_BYTE; // start with invalid character\n\n // c == 43 (c > 42 and c < 44)\n result += (((42 - c) & (c - 44)) >>> 8) & (-INVALID_BYTE + c - 43 + 62);\n // c == 47 (c > 46 and c < 48)\n result += (((46 - c) & (c - 48)) >>> 8) & (-INVALID_BYTE + c - 47 + 63);\n // c > 47 and c < 58\n result += (((47 - c) & (c - 58)) >>> 8) & (-INVALID_BYTE + c - 48 + 52);\n // c > 64 and c < 91\n result += (((64 - c) & (c - 91)) >>> 8) & (-INVALID_BYTE + c - 65 + 0);\n // c > 96 and c < 123\n result += (((96 - c) & (c - 123)) >>> 8) & (-INVALID_BYTE + c - 97 + 26);\n\n return result;\n }\n\n private _getPaddingLength(s: string): number {\n let paddingLength = 0;\n if (this._paddingCharacter) {\n for (let i = s.length - 1; i >= 0; i--) {\n if (s[i] !== this._paddingCharacter) {\n break;\n }\n paddingLength++;\n }\n if (s.length < 4 || paddingLength > 2) {\n throw new Error(\"Base64Coder: incorrect padding\");\n }\n }\n return paddingLength;\n }\n\n}\n\nconst stdCoder = new Coder();\n\nexport function encode(data: Uint8Array): string {\n return stdCoder.encode(data);\n}\n\nexport function decode(s: string): Uint8Array {\n return stdCoder.decode(s);\n}\n\n/**\n * Implements URL-safe Base64 encoding.\n * (Same as Base64, but '+' is replaced with '-', and '/' with '_').\n *\n * Operates in constant time.\n */\nexport class URLSafeCoder extends Coder {\n // URL-safe encoding have the following encoded/decoded ranges:\n //\n // ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 0123456789 - _\n // Index: 0 - 25 26 - 51 52 - 61 62 63\n // ASCII: 65 - 90 97 - 122 48 - 57 45 95\n //\n\n protected _encodeByte(b: number): string {\n let result = b;\n // b >= 0\n result += 65;\n // b > 25\n result += ((25 - b) >>> 8) & ((0 - 65) - 26 + 97);\n // b > 51\n result += ((51 - b) >>> 8) & ((26 - 97) - 52 + 48);\n // b > 61\n result += ((61 - b) >>> 8) & ((52 - 48) - 62 + 45);\n // b > 62\n result += ((62 - b) >>> 8) & ((62 - 45) - 63 + 95);\n\n return String.fromCharCode(result);\n }\n\n protected _decodeChar(c: number): number {\n let result = INVALID_BYTE;\n\n // c == 45 (c > 44 and c < 46)\n result += (((44 - c) & (c - 46)) >>> 8) & (-INVALID_BYTE + c - 45 + 62);\n // c == 95 (c > 94 and c < 96)\n result += (((94 - c) & (c - 96)) >>> 8) & (-INVALID_BYTE + c - 95 + 63);\n // c > 47 and c < 58\n result += (((47 - c) & (c - 58)) >>> 8) & (-INVALID_BYTE + c - 48 + 52);\n // c > 64 and c < 91\n result += (((64 - c) & (c - 91)) >>> 8) & (-INVALID_BYTE + c - 65 + 0);\n // c > 96 and c < 123\n result += (((96 - c) & (c - 123)) >>> 8) & (-INVALID_BYTE + c - 97 + 26);\n\n return result;\n }\n}\n\nconst urlSafeCoder = new URLSafeCoder();\n\nexport function encodeURLSafe(data: Uint8Array): string {\n return urlSafeCoder.encode(data);\n}\n\nexport function decodeURLSafe(s: string): Uint8Array {\n return urlSafeCoder.decode(s);\n}\n\n\nexport const encodedLength = (length: number) =>\n stdCoder.encodedLength(length);\n\nexport const maxDecodedLength = (length: number) =>\n stdCoder.maxDecodedLength(length);\n\nexport const decodedLength = (s: string) =>\n stdCoder.decodedLength(s);\n","import TimedCallback from './timed_callback';\nimport { Delay, Scheduler, Canceller } from './scheduling';\n\nabstract class Timer {\n protected clear: Canceller;\n protected timer: number | void;\n\n constructor(\n set: Scheduler,\n clear: Canceller,\n delay: Delay,\n callback: TimedCallback\n ) {\n this.clear = clear;\n this.timer = set(() => {\n if (this.timer) {\n this.timer = callback(this.timer);\n }\n }, delay);\n }\n\n /** Returns whether the timer is still running.\n *\n * @return {Boolean}\n */\n isRunning(): boolean {\n return this.timer !== null;\n }\n\n /** Aborts a timer when it's running. */\n ensureAborted() {\n if (this.timer) {\n this.clear(this.timer);\n this.timer = null;\n }\n }\n}\n\nexport default Timer;\n","module.exports = require(\"@react-native-community/netinfo\");","export default function encode(s: any): string {\n return btoa(utob(s));\n}\n\nvar fromCharCode = String.fromCharCode;\n\nvar b64chars =\n 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';\nvar b64tab = {};\n\nfor (var i = 0, l = b64chars.length; i < l; i++) {\n b64tab[b64chars.charAt(i)] = i;\n}\n\nvar cb_utob = function(c) {\n var cc = c.charCodeAt(0);\n return cc < 0x80\n ? c\n : cc < 0x800\n ? fromCharCode(0xc0 | (cc >>> 6)) + fromCharCode(0x80 | (cc & 0x3f))\n : fromCharCode(0xe0 | ((cc >>> 12) & 0x0f)) +\n fromCharCode(0x80 | ((cc >>> 6) & 0x3f)) +\n fromCharCode(0x80 | (cc & 0x3f));\n};\n\nvar utob = function(u) {\n return u.replace(/[^\\x00-\\x7F]/g, cb_utob);\n};\n\nvar cb_encode = function(ccc) {\n var padlen = [0, 2, 1][ccc.length % 3];\n var ord =\n (ccc.charCodeAt(0) << 16) |\n ((ccc.length > 1 ? ccc.charCodeAt(1) : 0) << 8) |\n (ccc.length > 2 ? ccc.charCodeAt(2) : 0);\n var chars = [\n b64chars.charAt(ord >>> 18),\n b64chars.charAt((ord >>> 12) & 63),\n padlen >= 2 ? '=' : b64chars.charAt((ord >>> 6) & 63),\n padlen >= 1 ? '=' : b64chars.charAt(ord & 63)\n ];\n return chars.join('');\n};\n\nvar btoa =\n global.btoa ||\n function(b) {\n return b.replace(/[\\s\\S]{1,3}/g, cb_encode);\n };\n","import Callback from './callback';\nimport * as Collections from '../utils/collections';\nimport CallbackTable from './callback_table';\n\nexport default class CallbackRegistry {\n _callbacks: CallbackTable;\n\n constructor() {\n this._callbacks = {};\n }\n\n get(name: string): Callback[] {\n return this._callbacks[prefix(name)];\n }\n\n add(name: string, callback: Function, context: any) {\n var prefixedEventName = prefix(name);\n this._callbacks[prefixedEventName] =\n this._callbacks[prefixedEventName] || [];\n this._callbacks[prefixedEventName].push({\n fn: callback,\n context: context\n });\n }\n\n remove(name?: string, callback?: Function, context?: any) {\n if (!name && !callback && !context) {\n this._callbacks = {};\n return;\n }\n\n var names = name ? [prefix(name)] : Collections.keys(this._callbacks);\n\n if (callback || context) {\n this.removeCallback(names, callback, context);\n } else {\n this.removeAllCallbacks(names);\n }\n }\n\n private removeCallback(names: string[], callback: Function, context: any) {\n Collections.apply(\n names,\n function(name) {\n this._callbacks[name] = Collections.filter(\n this._callbacks[name] || [],\n function(binding) {\n return (\n (callback && callback !== binding.fn) ||\n (context && context !== binding.context)\n );\n }\n );\n if (this._callbacks[name].length === 0) {\n delete this._callbacks[name];\n }\n },\n this\n );\n }\n\n private removeAllCallbacks(names: string[]) {\n Collections.apply(\n names,\n function(name) {\n delete this._callbacks[name];\n },\n this\n );\n }\n}\n\nfunction prefix(name: string): string {\n return '_' + name;\n}\n","// Copyright (C) 2016 Dmitry Chestnykh\n// MIT License. See LICENSE file for details.\n\n/**\n * Package utf8 implements UTF-8 encoding and decoding.\n */\n\nconst INVALID_UTF16 = \"utf8: invalid string\";\nconst INVALID_UTF8 = \"utf8: invalid source encoding\";\n\n/**\n * Encodes the given string into UTF-8 byte array.\n * Throws if the source string has invalid UTF-16 encoding.\n */\nexport function encode(s: string): Uint8Array {\n // Calculate result length and allocate output array.\n // encodedLength() also validates string and throws errors,\n // so we don't need repeat validation here.\n const arr = new Uint8Array(encodedLength(s));\n\n let pos = 0;\n for (let i = 0; i < s.length; i++) {\n let c = s.charCodeAt(i);\n if (c < 0x80) {\n arr[pos++] = c;\n } else if (c < 0x800) {\n arr[pos++] = 0xc0 | c >> 6;\n arr[pos++] = 0x80 | c & 0x3f;\n } else if (c < 0xd800) {\n arr[pos++] = 0xe0 | c >> 12;\n arr[pos++] = 0x80 | (c >> 6) & 0x3f;\n arr[pos++] = 0x80 | c & 0x3f;\n } else {\n i++; // get one more character\n c = (c & 0x3ff) << 10;\n c |= s.charCodeAt(i) & 0x3ff;\n c += 0x10000;\n\n arr[pos++] = 0xf0 | c >> 18;\n arr[pos++] = 0x80 | (c >> 12) & 0x3f;\n arr[pos++] = 0x80 | (c >> 6) & 0x3f;\n arr[pos++] = 0x80 | c & 0x3f;\n }\n }\n return arr;\n}\n\n/**\n * Returns the number of bytes required to encode the given string into UTF-8.\n * Throws if the source string has invalid UTF-16 encoding.\n */\nexport function encodedLength(s: string): number {\n let result = 0;\n for (let i = 0; i < s.length; i++) {\n const c = s.charCodeAt(i);\n if (c < 0x80) {\n result += 1;\n } else if (c < 0x800) {\n result += 2;\n } else if (c < 0xd800) {\n result += 3;\n } else if (c <= 0xdfff) {\n if (i >= s.length - 1) {\n throw new Error(INVALID_UTF16);\n }\n i++; // \"eat\" next character\n result += 4;\n } else {\n throw new Error(INVALID_UTF16);\n }\n }\n return result;\n}\n\n/**\n * Decodes the given byte array from UTF-8 into a string.\n * Throws if encoding is invalid.\n */\nexport function decode(arr: Uint8Array): string {\n const chars: string[] = [];\n for (let i = 0; i < arr.length; i++) {\n let b = arr[i];\n\n if (b & 0x80) {\n let min;\n if (b < 0xe0) {\n // Need 1 more byte.\n if (i >= arr.length) {\n throw new Error(INVALID_UTF8);\n }\n const n1 = arr[++i];\n if ((n1 & 0xc0) !== 0x80) {\n throw new Error(INVALID_UTF8);\n }\n b = (b & 0x1f) << 6 | (n1 & 0x3f);\n min = 0x80;\n } else if (b < 0xf0) {\n // Need 2 more bytes.\n if (i >= arr.length - 1) {\n throw new Error(INVALID_UTF8);\n }\n const n1 = arr[++i];\n const n2 = arr[++i];\n if ((n1 & 0xc0) !== 0x80 || (n2 & 0xc0) !== 0x80) {\n throw new Error(INVALID_UTF8);\n }\n b = (b & 0x0f) << 12 | (n1 & 0x3f) << 6 | (n2 & 0x3f);\n min = 0x800;\n } else if (b < 0xf8) {\n // Need 3 more bytes.\n if (i >= arr.length - 2) {\n throw new Error(INVALID_UTF8);\n }\n const n1 = arr[++i];\n const n2 = arr[++i];\n const n3 = arr[++i];\n if ((n1 & 0xc0) !== 0x80 || (n2 & 0xc0) !== 0x80 || (n3 & 0xc0) !== 0x80) {\n throw new Error(INVALID_UTF8);\n }\n b = (b & 0x0f) << 18 | (n1 & 0x3f) << 12 | (n2 & 0x3f) << 6 | (n3 & 0x3f);\n min = 0x10000;\n } else {\n throw new Error(INVALID_UTF8);\n }\n\n if (b < min || (b >= 0xd800 && b <= 0xdfff)) {\n throw new Error(INVALID_UTF8);\n }\n\n if (b >= 0x10000) {\n // Surrogate pair.\n if (b > 0x10ffff) {\n throw new Error(INVALID_UTF8);\n }\n b -= 0x10000;\n chars.push(String.fromCharCode(0xd800 | (b >> 10)));\n b = 0xdc00 | (b & 0x3ff);\n }\n }\n\n chars.push(String.fromCharCode(b));\n }\n return chars.join(\"\");\n}\n","(function(nacl) {\n'use strict';\n\n// Ported in 2014 by Dmitry Chestnykh and Devi Mandiri.\n// Public domain.\n//\n// Implementation derived from TweetNaCl version 20140427.\n// See for details: http://tweetnacl.cr.yp.to/\n\nvar gf = function(init) {\n var i, r = new Float64Array(16);\n if (init) for (i = 0; i < init.length; i++) r[i] = init[i];\n return r;\n};\n\n// Pluggable, initialized in high-level API below.\nvar randombytes = function(/* x, n */) { throw new Error('no PRNG'); };\n\nvar _0 = new Uint8Array(16);\nvar _9 = new Uint8Array(32); _9[0] = 9;\n\nvar gf0 = gf(),\n gf1 = gf([1]),\n _121665 = gf([0xdb41, 1]),\n D = gf([0x78a3, 0x1359, 0x4dca, 0x75eb, 0xd8ab, 0x4141, 0x0a4d, 0x0070, 0xe898, 0x7779, 0x4079, 0x8cc7, 0xfe73, 0x2b6f, 0x6cee, 0x5203]),\n D2 = gf([0xf159, 0x26b2, 0x9b94, 0xebd6, 0xb156, 0x8283, 0x149a, 0x00e0, 0xd130, 0xeef3, 0x80f2, 0x198e, 0xfce7, 0x56df, 0xd9dc, 0x2406]),\n X = gf([0xd51a, 0x8f25, 0x2d60, 0xc956, 0xa7b2, 0x9525, 0xc760, 0x692c, 0xdc5c, 0xfdd6, 0xe231, 0xc0a4, 0x53fe, 0xcd6e, 0x36d3, 0x2169]),\n Y = gf([0x6658, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666]),\n I = gf([0xa0b0, 0x4a0e, 0x1b27, 0xc4ee, 0xe478, 0xad2f, 0x1806, 0x2f43, 0xd7a7, 0x3dfb, 0x0099, 0x2b4d, 0xdf0b, 0x4fc1, 0x2480, 0x2b83]);\n\nfunction ts64(x, i, h, l) {\n x[i] = (h >> 24) & 0xff;\n x[i+1] = (h >> 16) & 0xff;\n x[i+2] = (h >> 8) & 0xff;\n x[i+3] = h & 0xff;\n x[i+4] = (l >> 24) & 0xff;\n x[i+5] = (l >> 16) & 0xff;\n x[i+6] = (l >> 8) & 0xff;\n x[i+7] = l & 0xff;\n}\n\nfunction vn(x, xi, y, yi, n) {\n var i,d = 0;\n for (i = 0; i < n; i++) d |= x[xi+i]^y[yi+i];\n return (1 & ((d - 1) >>> 8)) - 1;\n}\n\nfunction crypto_verify_16(x, xi, y, yi) {\n return vn(x,xi,y,yi,16);\n}\n\nfunction crypto_verify_32(x, xi, y, yi) {\n return vn(x,xi,y,yi,32);\n}\n\nfunction core_salsa20(o, p, k, c) {\n var j0 = c[ 0] & 0xff | (c[ 1] & 0xff)<<8 | (c[ 2] & 0xff)<<16 | (c[ 3] & 0xff)<<24,\n j1 = k[ 0] & 0xff | (k[ 1] & 0xff)<<8 | (k[ 2] & 0xff)<<16 | (k[ 3] & 0xff)<<24,\n j2 = k[ 4] & 0xff | (k[ 5] & 0xff)<<8 | (k[ 6] & 0xff)<<16 | (k[ 7] & 0xff)<<24,\n j3 = k[ 8] & 0xff | (k[ 9] & 0xff)<<8 | (k[10] & 0xff)<<16 | (k[11] & 0xff)<<24,\n j4 = k[12] & 0xff | (k[13] & 0xff)<<8 | (k[14] & 0xff)<<16 | (k[15] & 0xff)<<24,\n j5 = c[ 4] & 0xff | (c[ 5] & 0xff)<<8 | (c[ 6] & 0xff)<<16 | (c[ 7] & 0xff)<<24,\n j6 = p[ 0] & 0xff | (p[ 1] & 0xff)<<8 | (p[ 2] & 0xff)<<16 | (p[ 3] & 0xff)<<24,\n j7 = p[ 4] & 0xff | (p[ 5] & 0xff)<<8 | (p[ 6] & 0xff)<<16 | (p[ 7] & 0xff)<<24,\n j8 = p[ 8] & 0xff | (p[ 9] & 0xff)<<8 | (p[10] & 0xff)<<16 | (p[11] & 0xff)<<24,\n j9 = p[12] & 0xff | (p[13] & 0xff)<<8 | (p[14] & 0xff)<<16 | (p[15] & 0xff)<<24,\n j10 = c[ 8] & 0xff | (c[ 9] & 0xff)<<8 | (c[10] & 0xff)<<16 | (c[11] & 0xff)<<24,\n j11 = k[16] & 0xff | (k[17] & 0xff)<<8 | (k[18] & 0xff)<<16 | (k[19] & 0xff)<<24,\n j12 = k[20] & 0xff | (k[21] & 0xff)<<8 | (k[22] & 0xff)<<16 | (k[23] & 0xff)<<24,\n j13 = k[24] & 0xff | (k[25] & 0xff)<<8 | (k[26] & 0xff)<<16 | (k[27] & 0xff)<<24,\n j14 = k[28] & 0xff | (k[29] & 0xff)<<8 | (k[30] & 0xff)<<16 | (k[31] & 0xff)<<24,\n j15 = c[12] & 0xff | (c[13] & 0xff)<<8 | (c[14] & 0xff)<<16 | (c[15] & 0xff)<<24;\n\n var x0 = j0, x1 = j1, x2 = j2, x3 = j3, x4 = j4, x5 = j5, x6 = j6, x7 = j7,\n x8 = j8, x9 = j9, x10 = j10, x11 = j11, x12 = j12, x13 = j13, x14 = j14,\n x15 = j15, u;\n\n for (var i = 0; i < 20; i += 2) {\n u = x0 + x12 | 0;\n x4 ^= u<<7 | u>>>(32-7);\n u = x4 + x0 | 0;\n x8 ^= u<<9 | u>>>(32-9);\n u = x8 + x4 | 0;\n x12 ^= u<<13 | u>>>(32-13);\n u = x12 + x8 | 0;\n x0 ^= u<<18 | u>>>(32-18);\n\n u = x5 + x1 | 0;\n x9 ^= u<<7 | u>>>(32-7);\n u = x9 + x5 | 0;\n x13 ^= u<<9 | u>>>(32-9);\n u = x13 + x9 | 0;\n x1 ^= u<<13 | u>>>(32-13);\n u = x1 + x13 | 0;\n x5 ^= u<<18 | u>>>(32-18);\n\n u = x10 + x6 | 0;\n x14 ^= u<<7 | u>>>(32-7);\n u = x14 + x10 | 0;\n x2 ^= u<<9 | u>>>(32-9);\n u = x2 + x14 | 0;\n x6 ^= u<<13 | u>>>(32-13);\n u = x6 + x2 | 0;\n x10 ^= u<<18 | u>>>(32-18);\n\n u = x15 + x11 | 0;\n x3 ^= u<<7 | u>>>(32-7);\n u = x3 + x15 | 0;\n x7 ^= u<<9 | u>>>(32-9);\n u = x7 + x3 | 0;\n x11 ^= u<<13 | u>>>(32-13);\n u = x11 + x7 | 0;\n x15 ^= u<<18 | u>>>(32-18);\n\n u = x0 + x3 | 0;\n x1 ^= u<<7 | u>>>(32-7);\n u = x1 + x0 | 0;\n x2 ^= u<<9 | u>>>(32-9);\n u = x2 + x1 | 0;\n x3 ^= u<<13 | u>>>(32-13);\n u = x3 + x2 | 0;\n x0 ^= u<<18 | u>>>(32-18);\n\n u = x5 + x4 | 0;\n x6 ^= u<<7 | u>>>(32-7);\n u = x6 + x5 | 0;\n x7 ^= u<<9 | u>>>(32-9);\n u = x7 + x6 | 0;\n x4 ^= u<<13 | u>>>(32-13);\n u = x4 + x7 | 0;\n x5 ^= u<<18 | u>>>(32-18);\n\n u = x10 + x9 | 0;\n x11 ^= u<<7 | u>>>(32-7);\n u = x11 + x10 | 0;\n x8 ^= u<<9 | u>>>(32-9);\n u = x8 + x11 | 0;\n x9 ^= u<<13 | u>>>(32-13);\n u = x9 + x8 | 0;\n x10 ^= u<<18 | u>>>(32-18);\n\n u = x15 + x14 | 0;\n x12 ^= u<<7 | u>>>(32-7);\n u = x12 + x15 | 0;\n x13 ^= u<<9 | u>>>(32-9);\n u = x13 + x12 | 0;\n x14 ^= u<<13 | u>>>(32-13);\n u = x14 + x13 | 0;\n x15 ^= u<<18 | u>>>(32-18);\n }\n x0 = x0 + j0 | 0;\n x1 = x1 + j1 | 0;\n x2 = x2 + j2 | 0;\n x3 = x3 + j3 | 0;\n x4 = x4 + j4 | 0;\n x5 = x5 + j5 | 0;\n x6 = x6 + j6 | 0;\n x7 = x7 + j7 | 0;\n x8 = x8 + j8 | 0;\n x9 = x9 + j9 | 0;\n x10 = x10 + j10 | 0;\n x11 = x11 + j11 | 0;\n x12 = x12 + j12 | 0;\n x13 = x13 + j13 | 0;\n x14 = x14 + j14 | 0;\n x15 = x15 + j15 | 0;\n\n o[ 0] = x0 >>> 0 & 0xff;\n o[ 1] = x0 >>> 8 & 0xff;\n o[ 2] = x0 >>> 16 & 0xff;\n o[ 3] = x0 >>> 24 & 0xff;\n\n o[ 4] = x1 >>> 0 & 0xff;\n o[ 5] = x1 >>> 8 & 0xff;\n o[ 6] = x1 >>> 16 & 0xff;\n o[ 7] = x1 >>> 24 & 0xff;\n\n o[ 8] = x2 >>> 0 & 0xff;\n o[ 9] = x2 >>> 8 & 0xff;\n o[10] = x2 >>> 16 & 0xff;\n o[11] = x2 >>> 24 & 0xff;\n\n o[12] = x3 >>> 0 & 0xff;\n o[13] = x3 >>> 8 & 0xff;\n o[14] = x3 >>> 16 & 0xff;\n o[15] = x3 >>> 24 & 0xff;\n\n o[16] = x4 >>> 0 & 0xff;\n o[17] = x4 >>> 8 & 0xff;\n o[18] = x4 >>> 16 & 0xff;\n o[19] = x4 >>> 24 & 0xff;\n\n o[20] = x5 >>> 0 & 0xff;\n o[21] = x5 >>> 8 & 0xff;\n o[22] = x5 >>> 16 & 0xff;\n o[23] = x5 >>> 24 & 0xff;\n\n o[24] = x6 >>> 0 & 0xff;\n o[25] = x6 >>> 8 & 0xff;\n o[26] = x6 >>> 16 & 0xff;\n o[27] = x6 >>> 24 & 0xff;\n\n o[28] = x7 >>> 0 & 0xff;\n o[29] = x7 >>> 8 & 0xff;\n o[30] = x7 >>> 16 & 0xff;\n o[31] = x7 >>> 24 & 0xff;\n\n o[32] = x8 >>> 0 & 0xff;\n o[33] = x8 >>> 8 & 0xff;\n o[34] = x8 >>> 16 & 0xff;\n o[35] = x8 >>> 24 & 0xff;\n\n o[36] = x9 >>> 0 & 0xff;\n o[37] = x9 >>> 8 & 0xff;\n o[38] = x9 >>> 16 & 0xff;\n o[39] = x9 >>> 24 & 0xff;\n\n o[40] = x10 >>> 0 & 0xff;\n o[41] = x10 >>> 8 & 0xff;\n o[42] = x10 >>> 16 & 0xff;\n o[43] = x10 >>> 24 & 0xff;\n\n o[44] = x11 >>> 0 & 0xff;\n o[45] = x11 >>> 8 & 0xff;\n o[46] = x11 >>> 16 & 0xff;\n o[47] = x11 >>> 24 & 0xff;\n\n o[48] = x12 >>> 0 & 0xff;\n o[49] = x12 >>> 8 & 0xff;\n o[50] = x12 >>> 16 & 0xff;\n o[51] = x12 >>> 24 & 0xff;\n\n o[52] = x13 >>> 0 & 0xff;\n o[53] = x13 >>> 8 & 0xff;\n o[54] = x13 >>> 16 & 0xff;\n o[55] = x13 >>> 24 & 0xff;\n\n o[56] = x14 >>> 0 & 0xff;\n o[57] = x14 >>> 8 & 0xff;\n o[58] = x14 >>> 16 & 0xff;\n o[59] = x14 >>> 24 & 0xff;\n\n o[60] = x15 >>> 0 & 0xff;\n o[61] = x15 >>> 8 & 0xff;\n o[62] = x15 >>> 16 & 0xff;\n o[63] = x15 >>> 24 & 0xff;\n}\n\nfunction core_hsalsa20(o,p,k,c) {\n var j0 = c[ 0] & 0xff | (c[ 1] & 0xff)<<8 | (c[ 2] & 0xff)<<16 | (c[ 3] & 0xff)<<24,\n j1 = k[ 0] & 0xff | (k[ 1] & 0xff)<<8 | (k[ 2] & 0xff)<<16 | (k[ 3] & 0xff)<<24,\n j2 = k[ 4] & 0xff | (k[ 5] & 0xff)<<8 | (k[ 6] & 0xff)<<16 | (k[ 7] & 0xff)<<24,\n j3 = k[ 8] & 0xff | (k[ 9] & 0xff)<<8 | (k[10] & 0xff)<<16 | (k[11] & 0xff)<<24,\n j4 = k[12] & 0xff | (k[13] & 0xff)<<8 | (k[14] & 0xff)<<16 | (k[15] & 0xff)<<24,\n j5 = c[ 4] & 0xff | (c[ 5] & 0xff)<<8 | (c[ 6] & 0xff)<<16 | (c[ 7] & 0xff)<<24,\n j6 = p[ 0] & 0xff | (p[ 1] & 0xff)<<8 | (p[ 2] & 0xff)<<16 | (p[ 3] & 0xff)<<24,\n j7 = p[ 4] & 0xff | (p[ 5] & 0xff)<<8 | (p[ 6] & 0xff)<<16 | (p[ 7] & 0xff)<<24,\n j8 = p[ 8] & 0xff | (p[ 9] & 0xff)<<8 | (p[10] & 0xff)<<16 | (p[11] & 0xff)<<24,\n j9 = p[12] & 0xff | (p[13] & 0xff)<<8 | (p[14] & 0xff)<<16 | (p[15] & 0xff)<<24,\n j10 = c[ 8] & 0xff | (c[ 9] & 0xff)<<8 | (c[10] & 0xff)<<16 | (c[11] & 0xff)<<24,\n j11 = k[16] & 0xff | (k[17] & 0xff)<<8 | (k[18] & 0xff)<<16 | (k[19] & 0xff)<<24,\n j12 = k[20] & 0xff | (k[21] & 0xff)<<8 | (k[22] & 0xff)<<16 | (k[23] & 0xff)<<24,\n j13 = k[24] & 0xff | (k[25] & 0xff)<<8 | (k[26] & 0xff)<<16 | (k[27] & 0xff)<<24,\n j14 = k[28] & 0xff | (k[29] & 0xff)<<8 | (k[30] & 0xff)<<16 | (k[31] & 0xff)<<24,\n j15 = c[12] & 0xff | (c[13] & 0xff)<<8 | (c[14] & 0xff)<<16 | (c[15] & 0xff)<<24;\n\n var x0 = j0, x1 = j1, x2 = j2, x3 = j3, x4 = j4, x5 = j5, x6 = j6, x7 = j7,\n x8 = j8, x9 = j9, x10 = j10, x11 = j11, x12 = j12, x13 = j13, x14 = j14,\n x15 = j15, u;\n\n for (var i = 0; i < 20; i += 2) {\n u = x0 + x12 | 0;\n x4 ^= u<<7 | u>>>(32-7);\n u = x4 + x0 | 0;\n x8 ^= u<<9 | u>>>(32-9);\n u = x8 + x4 | 0;\n x12 ^= u<<13 | u>>>(32-13);\n u = x12 + x8 | 0;\n x0 ^= u<<18 | u>>>(32-18);\n\n u = x5 + x1 | 0;\n x9 ^= u<<7 | u>>>(32-7);\n u = x9 + x5 | 0;\n x13 ^= u<<9 | u>>>(32-9);\n u = x13 + x9 | 0;\n x1 ^= u<<13 | u>>>(32-13);\n u = x1 + x13 | 0;\n x5 ^= u<<18 | u>>>(32-18);\n\n u = x10 + x6 | 0;\n x14 ^= u<<7 | u>>>(32-7);\n u = x14 + x10 | 0;\n x2 ^= u<<9 | u>>>(32-9);\n u = x2 + x14 | 0;\n x6 ^= u<<13 | u>>>(32-13);\n u = x6 + x2 | 0;\n x10 ^= u<<18 | u>>>(32-18);\n\n u = x15 + x11 | 0;\n x3 ^= u<<7 | u>>>(32-7);\n u = x3 + x15 | 0;\n x7 ^= u<<9 | u>>>(32-9);\n u = x7 + x3 | 0;\n x11 ^= u<<13 | u>>>(32-13);\n u = x11 + x7 | 0;\n x15 ^= u<<18 | u>>>(32-18);\n\n u = x0 + x3 | 0;\n x1 ^= u<<7 | u>>>(32-7);\n u = x1 + x0 | 0;\n x2 ^= u<<9 | u>>>(32-9);\n u = x2 + x1 | 0;\n x3 ^= u<<13 | u>>>(32-13);\n u = x3 + x2 | 0;\n x0 ^= u<<18 | u>>>(32-18);\n\n u = x5 + x4 | 0;\n x6 ^= u<<7 | u>>>(32-7);\n u = x6 + x5 | 0;\n x7 ^= u<<9 | u>>>(32-9);\n u = x7 + x6 | 0;\n x4 ^= u<<13 | u>>>(32-13);\n u = x4 + x7 | 0;\n x5 ^= u<<18 | u>>>(32-18);\n\n u = x10 + x9 | 0;\n x11 ^= u<<7 | u>>>(32-7);\n u = x11 + x10 | 0;\n x8 ^= u<<9 | u>>>(32-9);\n u = x8 + x11 | 0;\n x9 ^= u<<13 | u>>>(32-13);\n u = x9 + x8 | 0;\n x10 ^= u<<18 | u>>>(32-18);\n\n u = x15 + x14 | 0;\n x12 ^= u<<7 | u>>>(32-7);\n u = x12 + x15 | 0;\n x13 ^= u<<9 | u>>>(32-9);\n u = x13 + x12 | 0;\n x14 ^= u<<13 | u>>>(32-13);\n u = x14 + x13 | 0;\n x15 ^= u<<18 | u>>>(32-18);\n }\n\n o[ 0] = x0 >>> 0 & 0xff;\n o[ 1] = x0 >>> 8 & 0xff;\n o[ 2] = x0 >>> 16 & 0xff;\n o[ 3] = x0 >>> 24 & 0xff;\n\n o[ 4] = x5 >>> 0 & 0xff;\n o[ 5] = x5 >>> 8 & 0xff;\n o[ 6] = x5 >>> 16 & 0xff;\n o[ 7] = x5 >>> 24 & 0xff;\n\n o[ 8] = x10 >>> 0 & 0xff;\n o[ 9] = x10 >>> 8 & 0xff;\n o[10] = x10 >>> 16 & 0xff;\n o[11] = x10 >>> 24 & 0xff;\n\n o[12] = x15 >>> 0 & 0xff;\n o[13] = x15 >>> 8 & 0xff;\n o[14] = x15 >>> 16 & 0xff;\n o[15] = x15 >>> 24 & 0xff;\n\n o[16] = x6 >>> 0 & 0xff;\n o[17] = x6 >>> 8 & 0xff;\n o[18] = x6 >>> 16 & 0xff;\n o[19] = x6 >>> 24 & 0xff;\n\n o[20] = x7 >>> 0 & 0xff;\n o[21] = x7 >>> 8 & 0xff;\n o[22] = x7 >>> 16 & 0xff;\n o[23] = x7 >>> 24 & 0xff;\n\n o[24] = x8 >>> 0 & 0xff;\n o[25] = x8 >>> 8 & 0xff;\n o[26] = x8 >>> 16 & 0xff;\n o[27] = x8 >>> 24 & 0xff;\n\n o[28] = x9 >>> 0 & 0xff;\n o[29] = x9 >>> 8 & 0xff;\n o[30] = x9 >>> 16 & 0xff;\n o[31] = x9 >>> 24 & 0xff;\n}\n\nfunction crypto_core_salsa20(out,inp,k,c) {\n core_salsa20(out,inp,k,c);\n}\n\nfunction crypto_core_hsalsa20(out,inp,k,c) {\n core_hsalsa20(out,inp,k,c);\n}\n\nvar sigma = new Uint8Array([101, 120, 112, 97, 110, 100, 32, 51, 50, 45, 98, 121, 116, 101, 32, 107]);\n // \"expand 32-byte k\"\n\nfunction crypto_stream_salsa20_xor(c,cpos,m,mpos,b,n,k) {\n var z = new Uint8Array(16), x = new Uint8Array(64);\n var u, i;\n for (i = 0; i < 16; i++) z[i] = 0;\n for (i = 0; i < 8; i++) z[i] = n[i];\n while (b >= 64) {\n crypto_core_salsa20(x,z,k,sigma);\n for (i = 0; i < 64; i++) c[cpos+i] = m[mpos+i] ^ x[i];\n u = 1;\n for (i = 8; i < 16; i++) {\n u = u + (z[i] & 0xff) | 0;\n z[i] = u & 0xff;\n u >>>= 8;\n }\n b -= 64;\n cpos += 64;\n mpos += 64;\n }\n if (b > 0) {\n crypto_core_salsa20(x,z,k,sigma);\n for (i = 0; i < b; i++) c[cpos+i] = m[mpos+i] ^ x[i];\n }\n return 0;\n}\n\nfunction crypto_stream_salsa20(c,cpos,b,n,k) {\n var z = new Uint8Array(16), x = new Uint8Array(64);\n var u, i;\n for (i = 0; i < 16; i++) z[i] = 0;\n for (i = 0; i < 8; i++) z[i] = n[i];\n while (b >= 64) {\n crypto_core_salsa20(x,z,k,sigma);\n for (i = 0; i < 64; i++) c[cpos+i] = x[i];\n u = 1;\n for (i = 8; i < 16; i++) {\n u = u + (z[i] & 0xff) | 0;\n z[i] = u & 0xff;\n u >>>= 8;\n }\n b -= 64;\n cpos += 64;\n }\n if (b > 0) {\n crypto_core_salsa20(x,z,k,sigma);\n for (i = 0; i < b; i++) c[cpos+i] = x[i];\n }\n return 0;\n}\n\nfunction crypto_stream(c,cpos,d,n,k) {\n var s = new Uint8Array(32);\n crypto_core_hsalsa20(s,n,k,sigma);\n var sn = new Uint8Array(8);\n for (var i = 0; i < 8; i++) sn[i] = n[i+16];\n return crypto_stream_salsa20(c,cpos,d,sn,s);\n}\n\nfunction crypto_stream_xor(c,cpos,m,mpos,d,n,k) {\n var s = new Uint8Array(32);\n crypto_core_hsalsa20(s,n,k,sigma);\n var sn = new Uint8Array(8);\n for (var i = 0; i < 8; i++) sn[i] = n[i+16];\n return crypto_stream_salsa20_xor(c,cpos,m,mpos,d,sn,s);\n}\n\n/*\n* Port of Andrew Moon's Poly1305-donna-16. Public domain.\n* https://github.com/floodyberry/poly1305-donna\n*/\n\nvar poly1305 = function(key) {\n this.buffer = new Uint8Array(16);\n this.r = new Uint16Array(10);\n this.h = new Uint16Array(10);\n this.pad = new Uint16Array(8);\n this.leftover = 0;\n this.fin = 0;\n\n var t0, t1, t2, t3, t4, t5, t6, t7;\n\n t0 = key[ 0] & 0xff | (key[ 1] & 0xff) << 8; this.r[0] = ( t0 ) & 0x1fff;\n t1 = key[ 2] & 0xff | (key[ 3] & 0xff) << 8; this.r[1] = ((t0 >>> 13) | (t1 << 3)) & 0x1fff;\n t2 = key[ 4] & 0xff | (key[ 5] & 0xff) << 8; this.r[2] = ((t1 >>> 10) | (t2 << 6)) & 0x1f03;\n t3 = key[ 6] & 0xff | (key[ 7] & 0xff) << 8; this.r[3] = ((t2 >>> 7) | (t3 << 9)) & 0x1fff;\n t4 = key[ 8] & 0xff | (key[ 9] & 0xff) << 8; this.r[4] = ((t3 >>> 4) | (t4 << 12)) & 0x00ff;\n this.r[5] = ((t4 >>> 1)) & 0x1ffe;\n t5 = key[10] & 0xff | (key[11] & 0xff) << 8; this.r[6] = ((t4 >>> 14) | (t5 << 2)) & 0x1fff;\n t6 = key[12] & 0xff | (key[13] & 0xff) << 8; this.r[7] = ((t5 >>> 11) | (t6 << 5)) & 0x1f81;\n t7 = key[14] & 0xff | (key[15] & 0xff) << 8; this.r[8] = ((t6 >>> 8) | (t7 << 8)) & 0x1fff;\n this.r[9] = ((t7 >>> 5)) & 0x007f;\n\n this.pad[0] = key[16] & 0xff | (key[17] & 0xff) << 8;\n this.pad[1] = key[18] & 0xff | (key[19] & 0xff) << 8;\n this.pad[2] = key[20] & 0xff | (key[21] & 0xff) << 8;\n this.pad[3] = key[22] & 0xff | (key[23] & 0xff) << 8;\n this.pad[4] = key[24] & 0xff | (key[25] & 0xff) << 8;\n this.pad[5] = key[26] & 0xff | (key[27] & 0xff) << 8;\n this.pad[6] = key[28] & 0xff | (key[29] & 0xff) << 8;\n this.pad[7] = key[30] & 0xff | (key[31] & 0xff) << 8;\n};\n\npoly1305.prototype.blocks = function(m, mpos, bytes) {\n var hibit = this.fin ? 0 : (1 << 11);\n var t0, t1, t2, t3, t4, t5, t6, t7, c;\n var d0, d1, d2, d3, d4, d5, d6, d7, d8, d9;\n\n var h0 = this.h[0],\n h1 = this.h[1],\n h2 = this.h[2],\n h3 = this.h[3],\n h4 = this.h[4],\n h5 = this.h[5],\n h6 = this.h[6],\n h7 = this.h[7],\n h8 = this.h[8],\n h9 = this.h[9];\n\n var r0 = this.r[0],\n r1 = this.r[1],\n r2 = this.r[2],\n r3 = this.r[3],\n r4 = this.r[4],\n r5 = this.r[5],\n r6 = this.r[6],\n r7 = this.r[7],\n r8 = this.r[8],\n r9 = this.r[9];\n\n while (bytes >= 16) {\n t0 = m[mpos+ 0] & 0xff | (m[mpos+ 1] & 0xff) << 8; h0 += ( t0 ) & 0x1fff;\n t1 = m[mpos+ 2] & 0xff | (m[mpos+ 3] & 0xff) << 8; h1 += ((t0 >>> 13) | (t1 << 3)) & 0x1fff;\n t2 = m[mpos+ 4] & 0xff | (m[mpos+ 5] & 0xff) << 8; h2 += ((t1 >>> 10) | (t2 << 6)) & 0x1fff;\n t3 = m[mpos+ 6] & 0xff | (m[mpos+ 7] & 0xff) << 8; h3 += ((t2 >>> 7) | (t3 << 9)) & 0x1fff;\n t4 = m[mpos+ 8] & 0xff | (m[mpos+ 9] & 0xff) << 8; h4 += ((t3 >>> 4) | (t4 << 12)) & 0x1fff;\n h5 += ((t4 >>> 1)) & 0x1fff;\n t5 = m[mpos+10] & 0xff | (m[mpos+11] & 0xff) << 8; h6 += ((t4 >>> 14) | (t5 << 2)) & 0x1fff;\n t6 = m[mpos+12] & 0xff | (m[mpos+13] & 0xff) << 8; h7 += ((t5 >>> 11) | (t6 << 5)) & 0x1fff;\n t7 = m[mpos+14] & 0xff | (m[mpos+15] & 0xff) << 8; h8 += ((t6 >>> 8) | (t7 << 8)) & 0x1fff;\n h9 += ((t7 >>> 5)) | hibit;\n\n c = 0;\n\n d0 = c;\n d0 += h0 * r0;\n d0 += h1 * (5 * r9);\n d0 += h2 * (5 * r8);\n d0 += h3 * (5 * r7);\n d0 += h4 * (5 * r6);\n c = (d0 >>> 13); d0 &= 0x1fff;\n d0 += h5 * (5 * r5);\n d0 += h6 * (5 * r4);\n d0 += h7 * (5 * r3);\n d0 += h8 * (5 * r2);\n d0 += h9 * (5 * r1);\n c += (d0 >>> 13); d0 &= 0x1fff;\n\n d1 = c;\n d1 += h0 * r1;\n d1 += h1 * r0;\n d1 += h2 * (5 * r9);\n d1 += h3 * (5 * r8);\n d1 += h4 * (5 * r7);\n c = (d1 >>> 13); d1 &= 0x1fff;\n d1 += h5 * (5 * r6);\n d1 += h6 * (5 * r5);\n d1 += h7 * (5 * r4);\n d1 += h8 * (5 * r3);\n d1 += h9 * (5 * r2);\n c += (d1 >>> 13); d1 &= 0x1fff;\n\n d2 = c;\n d2 += h0 * r2;\n d2 += h1 * r1;\n d2 += h2 * r0;\n d2 += h3 * (5 * r9);\n d2 += h4 * (5 * r8);\n c = (d2 >>> 13); d2 &= 0x1fff;\n d2 += h5 * (5 * r7);\n d2 += h6 * (5 * r6);\n d2 += h7 * (5 * r5);\n d2 += h8 * (5 * r4);\n d2 += h9 * (5 * r3);\n c += (d2 >>> 13); d2 &= 0x1fff;\n\n d3 = c;\n d3 += h0 * r3;\n d3 += h1 * r2;\n d3 += h2 * r1;\n d3 += h3 * r0;\n d3 += h4 * (5 * r9);\n c = (d3 >>> 13); d3 &= 0x1fff;\n d3 += h5 * (5 * r8);\n d3 += h6 * (5 * r7);\n d3 += h7 * (5 * r6);\n d3 += h8 * (5 * r5);\n d3 += h9 * (5 * r4);\n c += (d3 >>> 13); d3 &= 0x1fff;\n\n d4 = c;\n d4 += h0 * r4;\n d4 += h1 * r3;\n d4 += h2 * r2;\n d4 += h3 * r1;\n d4 += h4 * r0;\n c = (d4 >>> 13); d4 &= 0x1fff;\n d4 += h5 * (5 * r9);\n d4 += h6 * (5 * r8);\n d4 += h7 * (5 * r7);\n d4 += h8 * (5 * r6);\n d4 += h9 * (5 * r5);\n c += (d4 >>> 13); d4 &= 0x1fff;\n\n d5 = c;\n d5 += h0 * r5;\n d5 += h1 * r4;\n d5 += h2 * r3;\n d5 += h3 * r2;\n d5 += h4 * r1;\n c = (d5 >>> 13); d5 &= 0x1fff;\n d5 += h5 * r0;\n d5 += h6 * (5 * r9);\n d5 += h7 * (5 * r8);\n d5 += h8 * (5 * r7);\n d5 += h9 * (5 * r6);\n c += (d5 >>> 13); d5 &= 0x1fff;\n\n d6 = c;\n d6 += h0 * r6;\n d6 += h1 * r5;\n d6 += h2 * r4;\n d6 += h3 * r3;\n d6 += h4 * r2;\n c = (d6 >>> 13); d6 &= 0x1fff;\n d6 += h5 * r1;\n d6 += h6 * r0;\n d6 += h7 * (5 * r9);\n d6 += h8 * (5 * r8);\n d6 += h9 * (5 * r7);\n c += (d6 >>> 13); d6 &= 0x1fff;\n\n d7 = c;\n d7 += h0 * r7;\n d7 += h1 * r6;\n d7 += h2 * r5;\n d7 += h3 * r4;\n d7 += h4 * r3;\n c = (d7 >>> 13); d7 &= 0x1fff;\n d7 += h5 * r2;\n d7 += h6 * r1;\n d7 += h7 * r0;\n d7 += h8 * (5 * r9);\n d7 += h9 * (5 * r8);\n c += (d7 >>> 13); d7 &= 0x1fff;\n\n d8 = c;\n d8 += h0 * r8;\n d8 += h1 * r7;\n d8 += h2 * r6;\n d8 += h3 * r5;\n d8 += h4 * r4;\n c = (d8 >>> 13); d8 &= 0x1fff;\n d8 += h5 * r3;\n d8 += h6 * r2;\n d8 += h7 * r1;\n d8 += h8 * r0;\n d8 += h9 * (5 * r9);\n c += (d8 >>> 13); d8 &= 0x1fff;\n\n d9 = c;\n d9 += h0 * r9;\n d9 += h1 * r8;\n d9 += h2 * r7;\n d9 += h3 * r6;\n d9 += h4 * r5;\n c = (d9 >>> 13); d9 &= 0x1fff;\n d9 += h5 * r4;\n d9 += h6 * r3;\n d9 += h7 * r2;\n d9 += h8 * r1;\n d9 += h9 * r0;\n c += (d9 >>> 13); d9 &= 0x1fff;\n\n c = (((c << 2) + c)) | 0;\n c = (c + d0) | 0;\n d0 = c & 0x1fff;\n c = (c >>> 13);\n d1 += c;\n\n h0 = d0;\n h1 = d1;\n h2 = d2;\n h3 = d3;\n h4 = d4;\n h5 = d5;\n h6 = d6;\n h7 = d7;\n h8 = d8;\n h9 = d9;\n\n mpos += 16;\n bytes -= 16;\n }\n this.h[0] = h0;\n this.h[1] = h1;\n this.h[2] = h2;\n this.h[3] = h3;\n this.h[4] = h4;\n this.h[5] = h5;\n this.h[6] = h6;\n this.h[7] = h7;\n this.h[8] = h8;\n this.h[9] = h9;\n};\n\npoly1305.prototype.finish = function(mac, macpos) {\n var g = new Uint16Array(10);\n var c, mask, f, i;\n\n if (this.leftover) {\n i = this.leftover;\n this.buffer[i++] = 1;\n for (; i < 16; i++) this.buffer[i] = 0;\n this.fin = 1;\n this.blocks(this.buffer, 0, 16);\n }\n\n c = this.h[1] >>> 13;\n this.h[1] &= 0x1fff;\n for (i = 2; i < 10; i++) {\n this.h[i] += c;\n c = this.h[i] >>> 13;\n this.h[i] &= 0x1fff;\n }\n this.h[0] += (c * 5);\n c = this.h[0] >>> 13;\n this.h[0] &= 0x1fff;\n this.h[1] += c;\n c = this.h[1] >>> 13;\n this.h[1] &= 0x1fff;\n this.h[2] += c;\n\n g[0] = this.h[0] + 5;\n c = g[0] >>> 13;\n g[0] &= 0x1fff;\n for (i = 1; i < 10; i++) {\n g[i] = this.h[i] + c;\n c = g[i] >>> 13;\n g[i] &= 0x1fff;\n }\n g[9] -= (1 << 13);\n\n mask = (c ^ 1) - 1;\n for (i = 0; i < 10; i++) g[i] &= mask;\n mask = ~mask;\n for (i = 0; i < 10; i++) this.h[i] = (this.h[i] & mask) | g[i];\n\n this.h[0] = ((this.h[0] ) | (this.h[1] << 13) ) & 0xffff;\n this.h[1] = ((this.h[1] >>> 3) | (this.h[2] << 10) ) & 0xffff;\n this.h[2] = ((this.h[2] >>> 6) | (this.h[3] << 7) ) & 0xffff;\n this.h[3] = ((this.h[3] >>> 9) | (this.h[4] << 4) ) & 0xffff;\n this.h[4] = ((this.h[4] >>> 12) | (this.h[5] << 1) | (this.h[6] << 14)) & 0xffff;\n this.h[5] = ((this.h[6] >>> 2) | (this.h[7] << 11) ) & 0xffff;\n this.h[6] = ((this.h[7] >>> 5) | (this.h[8] << 8) ) & 0xffff;\n this.h[7] = ((this.h[8] >>> 8) | (this.h[9] << 5) ) & 0xffff;\n\n f = this.h[0] + this.pad[0];\n this.h[0] = f & 0xffff;\n for (i = 1; i < 8; i++) {\n f = (((this.h[i] + this.pad[i]) | 0) + (f >>> 16)) | 0;\n this.h[i] = f & 0xffff;\n }\n\n mac[macpos+ 0] = (this.h[0] >>> 0) & 0xff;\n mac[macpos+ 1] = (this.h[0] >>> 8) & 0xff;\n mac[macpos+ 2] = (this.h[1] >>> 0) & 0xff;\n mac[macpos+ 3] = (this.h[1] >>> 8) & 0xff;\n mac[macpos+ 4] = (this.h[2] >>> 0) & 0xff;\n mac[macpos+ 5] = (this.h[2] >>> 8) & 0xff;\n mac[macpos+ 6] = (this.h[3] >>> 0) & 0xff;\n mac[macpos+ 7] = (this.h[3] >>> 8) & 0xff;\n mac[macpos+ 8] = (this.h[4] >>> 0) & 0xff;\n mac[macpos+ 9] = (this.h[4] >>> 8) & 0xff;\n mac[macpos+10] = (this.h[5] >>> 0) & 0xff;\n mac[macpos+11] = (this.h[5] >>> 8) & 0xff;\n mac[macpos+12] = (this.h[6] >>> 0) & 0xff;\n mac[macpos+13] = (this.h[6] >>> 8) & 0xff;\n mac[macpos+14] = (this.h[7] >>> 0) & 0xff;\n mac[macpos+15] = (this.h[7] >>> 8) & 0xff;\n};\n\npoly1305.prototype.update = function(m, mpos, bytes) {\n var i, want;\n\n if (this.leftover) {\n want = (16 - this.leftover);\n if (want > bytes)\n want = bytes;\n for (i = 0; i < want; i++)\n this.buffer[this.leftover + i] = m[mpos+i];\n bytes -= want;\n mpos += want;\n this.leftover += want;\n if (this.leftover < 16)\n return;\n this.blocks(this.buffer, 0, 16);\n this.leftover = 0;\n }\n\n if (bytes >= 16) {\n want = bytes - (bytes % 16);\n this.blocks(m, mpos, want);\n mpos += want;\n bytes -= want;\n }\n\n if (bytes) {\n for (i = 0; i < bytes; i++)\n this.buffer[this.leftover + i] = m[mpos+i];\n this.leftover += bytes;\n }\n};\n\nfunction crypto_onetimeauth(out, outpos, m, mpos, n, k) {\n var s = new poly1305(k);\n s.update(m, mpos, n);\n s.finish(out, outpos);\n return 0;\n}\n\nfunction crypto_onetimeauth_verify(h, hpos, m, mpos, n, k) {\n var x = new Uint8Array(16);\n crypto_onetimeauth(x,0,m,mpos,n,k);\n return crypto_verify_16(h,hpos,x,0);\n}\n\nfunction crypto_secretbox(c,m,d,n,k) {\n var i;\n if (d < 32) return -1;\n crypto_stream_xor(c,0,m,0,d,n,k);\n crypto_onetimeauth(c, 16, c, 32, d - 32, c);\n for (i = 0; i < 16; i++) c[i] = 0;\n return 0;\n}\n\nfunction crypto_secretbox_open(m,c,d,n,k) {\n var i;\n var x = new Uint8Array(32);\n if (d < 32) return -1;\n crypto_stream(x,0,32,n,k);\n if (crypto_onetimeauth_verify(c, 16,c, 32,d - 32,x) !== 0) return -1;\n crypto_stream_xor(m,0,c,0,d,n,k);\n for (i = 0; i < 32; i++) m[i] = 0;\n return 0;\n}\n\nfunction set25519(r, a) {\n var i;\n for (i = 0; i < 16; i++) r[i] = a[i]|0;\n}\n\nfunction car25519(o) {\n var i, v, c = 1;\n for (i = 0; i < 16; i++) {\n v = o[i] + c + 65535;\n c = Math.floor(v / 65536);\n o[i] = v - c * 65536;\n }\n o[0] += c-1 + 37 * (c-1);\n}\n\nfunction sel25519(p, q, b) {\n var t, c = ~(b-1);\n for (var i = 0; i < 16; i++) {\n t = c & (p[i] ^ q[i]);\n p[i] ^= t;\n q[i] ^= t;\n }\n}\n\nfunction pack25519(o, n) {\n var i, j, b;\n var m = gf(), t = gf();\n for (i = 0; i < 16; i++) t[i] = n[i];\n car25519(t);\n car25519(t);\n car25519(t);\n for (j = 0; j < 2; j++) {\n m[0] = t[0] - 0xffed;\n for (i = 1; i < 15; i++) {\n m[i] = t[i] - 0xffff - ((m[i-1]>>16) & 1);\n m[i-1] &= 0xffff;\n }\n m[15] = t[15] - 0x7fff - ((m[14]>>16) & 1);\n b = (m[15]>>16) & 1;\n m[14] &= 0xffff;\n sel25519(t, m, 1-b);\n }\n for (i = 0; i < 16; i++) {\n o[2*i] = t[i] & 0xff;\n o[2*i+1] = t[i]>>8;\n }\n}\n\nfunction neq25519(a, b) {\n var c = new Uint8Array(32), d = new Uint8Array(32);\n pack25519(c, a);\n pack25519(d, b);\n return crypto_verify_32(c, 0, d, 0);\n}\n\nfunction par25519(a) {\n var d = new Uint8Array(32);\n pack25519(d, a);\n return d[0] & 1;\n}\n\nfunction unpack25519(o, n) {\n var i;\n for (i = 0; i < 16; i++) o[i] = n[2*i] + (n[2*i+1] << 8);\n o[15] &= 0x7fff;\n}\n\nfunction A(o, a, b) {\n for (var i = 0; i < 16; i++) o[i] = a[i] + b[i];\n}\n\nfunction Z(o, a, b) {\n for (var i = 0; i < 16; i++) o[i] = a[i] - b[i];\n}\n\nfunction M(o, a, b) {\n var v, c,\n t0 = 0, t1 = 0, t2 = 0, t3 = 0, t4 = 0, t5 = 0, t6 = 0, t7 = 0,\n t8 = 0, t9 = 0, t10 = 0, t11 = 0, t12 = 0, t13 = 0, t14 = 0, t15 = 0,\n t16 = 0, t17 = 0, t18 = 0, t19 = 0, t20 = 0, t21 = 0, t22 = 0, t23 = 0,\n t24 = 0, t25 = 0, t26 = 0, t27 = 0, t28 = 0, t29 = 0, t30 = 0,\n b0 = b[0],\n b1 = b[1],\n b2 = b[2],\n b3 = b[3],\n b4 = b[4],\n b5 = b[5],\n b6 = b[6],\n b7 = b[7],\n b8 = b[8],\n b9 = b[9],\n b10 = b[10],\n b11 = b[11],\n b12 = b[12],\n b13 = b[13],\n b14 = b[14],\n b15 = b[15];\n\n v = a[0];\n t0 += v * b0;\n t1 += v * b1;\n t2 += v * b2;\n t3 += v * b3;\n t4 += v * b4;\n t5 += v * b5;\n t6 += v * b6;\n t7 += v * b7;\n t8 += v * b8;\n t9 += v * b9;\n t10 += v * b10;\n t11 += v * b11;\n t12 += v * b12;\n t13 += v * b13;\n t14 += v * b14;\n t15 += v * b15;\n v = a[1];\n t1 += v * b0;\n t2 += v * b1;\n t3 += v * b2;\n t4 += v * b3;\n t5 += v * b4;\n t6 += v * b5;\n t7 += v * b6;\n t8 += v * b7;\n t9 += v * b8;\n t10 += v * b9;\n t11 += v * b10;\n t12 += v * b11;\n t13 += v * b12;\n t14 += v * b13;\n t15 += v * b14;\n t16 += v * b15;\n v = a[2];\n t2 += v * b0;\n t3 += v * b1;\n t4 += v * b2;\n t5 += v * b3;\n t6 += v * b4;\n t7 += v * b5;\n t8 += v * b6;\n t9 += v * b7;\n t10 += v * b8;\n t11 += v * b9;\n t12 += v * b10;\n t13 += v * b11;\n t14 += v * b12;\n t15 += v * b13;\n t16 += v * b14;\n t17 += v * b15;\n v = a[3];\n t3 += v * b0;\n t4 += v * b1;\n t5 += v * b2;\n t6 += v * b3;\n t7 += v * b4;\n t8 += v * b5;\n t9 += v * b6;\n t10 += v * b7;\n t11 += v * b8;\n t12 += v * b9;\n t13 += v * b10;\n t14 += v * b11;\n t15 += v * b12;\n t16 += v * b13;\n t17 += v * b14;\n t18 += v * b15;\n v = a[4];\n t4 += v * b0;\n t5 += v * b1;\n t6 += v * b2;\n t7 += v * b3;\n t8 += v * b4;\n t9 += v * b5;\n t10 += v * b6;\n t11 += v * b7;\n t12 += v * b8;\n t13 += v * b9;\n t14 += v * b10;\n t15 += v * b11;\n t16 += v * b12;\n t17 += v * b13;\n t18 += v * b14;\n t19 += v * b15;\n v = a[5];\n t5 += v * b0;\n t6 += v * b1;\n t7 += v * b2;\n t8 += v * b3;\n t9 += v * b4;\n t10 += v * b5;\n t11 += v * b6;\n t12 += v * b7;\n t13 += v * b8;\n t14 += v * b9;\n t15 += v * b10;\n t16 += v * b11;\n t17 += v * b12;\n t18 += v * b13;\n t19 += v * b14;\n t20 += v * b15;\n v = a[6];\n t6 += v * b0;\n t7 += v * b1;\n t8 += v * b2;\n t9 += v * b3;\n t10 += v * b4;\n t11 += v * b5;\n t12 += v * b6;\n t13 += v * b7;\n t14 += v * b8;\n t15 += v * b9;\n t16 += v * b10;\n t17 += v * b11;\n t18 += v * b12;\n t19 += v * b13;\n t20 += v * b14;\n t21 += v * b15;\n v = a[7];\n t7 += v * b0;\n t8 += v * b1;\n t9 += v * b2;\n t10 += v * b3;\n t11 += v * b4;\n t12 += v * b5;\n t13 += v * b6;\n t14 += v * b7;\n t15 += v * b8;\n t16 += v * b9;\n t17 += v * b10;\n t18 += v * b11;\n t19 += v * b12;\n t20 += v * b13;\n t21 += v * b14;\n t22 += v * b15;\n v = a[8];\n t8 += v * b0;\n t9 += v * b1;\n t10 += v * b2;\n t11 += v * b3;\n t12 += v * b4;\n t13 += v * b5;\n t14 += v * b6;\n t15 += v * b7;\n t16 += v * b8;\n t17 += v * b9;\n t18 += v * b10;\n t19 += v * b11;\n t20 += v * b12;\n t21 += v * b13;\n t22 += v * b14;\n t23 += v * b15;\n v = a[9];\n t9 += v * b0;\n t10 += v * b1;\n t11 += v * b2;\n t12 += v * b3;\n t13 += v * b4;\n t14 += v * b5;\n t15 += v * b6;\n t16 += v * b7;\n t17 += v * b8;\n t18 += v * b9;\n t19 += v * b10;\n t20 += v * b11;\n t21 += v * b12;\n t22 += v * b13;\n t23 += v * b14;\n t24 += v * b15;\n v = a[10];\n t10 += v * b0;\n t11 += v * b1;\n t12 += v * b2;\n t13 += v * b3;\n t14 += v * b4;\n t15 += v * b5;\n t16 += v * b6;\n t17 += v * b7;\n t18 += v * b8;\n t19 += v * b9;\n t20 += v * b10;\n t21 += v * b11;\n t22 += v * b12;\n t23 += v * b13;\n t24 += v * b14;\n t25 += v * b15;\n v = a[11];\n t11 += v * b0;\n t12 += v * b1;\n t13 += v * b2;\n t14 += v * b3;\n t15 += v * b4;\n t16 += v * b5;\n t17 += v * b6;\n t18 += v * b7;\n t19 += v * b8;\n t20 += v * b9;\n t21 += v * b10;\n t22 += v * b11;\n t23 += v * b12;\n t24 += v * b13;\n t25 += v * b14;\n t26 += v * b15;\n v = a[12];\n t12 += v * b0;\n t13 += v * b1;\n t14 += v * b2;\n t15 += v * b3;\n t16 += v * b4;\n t17 += v * b5;\n t18 += v * b6;\n t19 += v * b7;\n t20 += v * b8;\n t21 += v * b9;\n t22 += v * b10;\n t23 += v * b11;\n t24 += v * b12;\n t25 += v * b13;\n t26 += v * b14;\n t27 += v * b15;\n v = a[13];\n t13 += v * b0;\n t14 += v * b1;\n t15 += v * b2;\n t16 += v * b3;\n t17 += v * b4;\n t18 += v * b5;\n t19 += v * b6;\n t20 += v * b7;\n t21 += v * b8;\n t22 += v * b9;\n t23 += v * b10;\n t24 += v * b11;\n t25 += v * b12;\n t26 += v * b13;\n t27 += v * b14;\n t28 += v * b15;\n v = a[14];\n t14 += v * b0;\n t15 += v * b1;\n t16 += v * b2;\n t17 += v * b3;\n t18 += v * b4;\n t19 += v * b5;\n t20 += v * b6;\n t21 += v * b7;\n t22 += v * b8;\n t23 += v * b9;\n t24 += v * b10;\n t25 += v * b11;\n t26 += v * b12;\n t27 += v * b13;\n t28 += v * b14;\n t29 += v * b15;\n v = a[15];\n t15 += v * b0;\n t16 += v * b1;\n t17 += v * b2;\n t18 += v * b3;\n t19 += v * b4;\n t20 += v * b5;\n t21 += v * b6;\n t22 += v * b7;\n t23 += v * b8;\n t24 += v * b9;\n t25 += v * b10;\n t26 += v * b11;\n t27 += v * b12;\n t28 += v * b13;\n t29 += v * b14;\n t30 += v * b15;\n\n t0 += 38 * t16;\n t1 += 38 * t17;\n t2 += 38 * t18;\n t3 += 38 * t19;\n t4 += 38 * t20;\n t5 += 38 * t21;\n t6 += 38 * t22;\n t7 += 38 * t23;\n t8 += 38 * t24;\n t9 += 38 * t25;\n t10 += 38 * t26;\n t11 += 38 * t27;\n t12 += 38 * t28;\n t13 += 38 * t29;\n t14 += 38 * t30;\n // t15 left as is\n\n // first car\n c = 1;\n v = t0 + c + 65535; c = Math.floor(v / 65536); t0 = v - c * 65536;\n v = t1 + c + 65535; c = Math.floor(v / 65536); t1 = v - c * 65536;\n v = t2 + c + 65535; c = Math.floor(v / 65536); t2 = v - c * 65536;\n v = t3 + c + 65535; c = Math.floor(v / 65536); t3 = v - c * 65536;\n v = t4 + c + 65535; c = Math.floor(v / 65536); t4 = v - c * 65536;\n v = t5 + c + 65535; c = Math.floor(v / 65536); t5 = v - c * 65536;\n v = t6 + c + 65535; c = Math.floor(v / 65536); t6 = v - c * 65536;\n v = t7 + c + 65535; c = Math.floor(v / 65536); t7 = v - c * 65536;\n v = t8 + c + 65535; c = Math.floor(v / 65536); t8 = v - c * 65536;\n v = t9 + c + 65535; c = Math.floor(v / 65536); t9 = v - c * 65536;\n v = t10 + c + 65535; c = Math.floor(v / 65536); t10 = v - c * 65536;\n v = t11 + c + 65535; c = Math.floor(v / 65536); t11 = v - c * 65536;\n v = t12 + c + 65535; c = Math.floor(v / 65536); t12 = v - c * 65536;\n v = t13 + c + 65535; c = Math.floor(v / 65536); t13 = v - c * 65536;\n v = t14 + c + 65535; c = Math.floor(v / 65536); t14 = v - c * 65536;\n v = t15 + c + 65535; c = Math.floor(v / 65536); t15 = v - c * 65536;\n t0 += c-1 + 37 * (c-1);\n\n // second car\n c = 1;\n v = t0 + c + 65535; c = Math.floor(v / 65536); t0 = v - c * 65536;\n v = t1 + c + 65535; c = Math.floor(v / 65536); t1 = v - c * 65536;\n v = t2 + c + 65535; c = Math.floor(v / 65536); t2 = v - c * 65536;\n v = t3 + c + 65535; c = Math.floor(v / 65536); t3 = v - c * 65536;\n v = t4 + c + 65535; c = Math.floor(v / 65536); t4 = v - c * 65536;\n v = t5 + c + 65535; c = Math.floor(v / 65536); t5 = v - c * 65536;\n v = t6 + c + 65535; c = Math.floor(v / 65536); t6 = v - c * 65536;\n v = t7 + c + 65535; c = Math.floor(v / 65536); t7 = v - c * 65536;\n v = t8 + c + 65535; c = Math.floor(v / 65536); t8 = v - c * 65536;\n v = t9 + c + 65535; c = Math.floor(v / 65536); t9 = v - c * 65536;\n v = t10 + c + 65535; c = Math.floor(v / 65536); t10 = v - c * 65536;\n v = t11 + c + 65535; c = Math.floor(v / 65536); t11 = v - c * 65536;\n v = t12 + c + 65535; c = Math.floor(v / 65536); t12 = v - c * 65536;\n v = t13 + c + 65535; c = Math.floor(v / 65536); t13 = v - c * 65536;\n v = t14 + c + 65535; c = Math.floor(v / 65536); t14 = v - c * 65536;\n v = t15 + c + 65535; c = Math.floor(v / 65536); t15 = v - c * 65536;\n t0 += c-1 + 37 * (c-1);\n\n o[ 0] = t0;\n o[ 1] = t1;\n o[ 2] = t2;\n o[ 3] = t3;\n o[ 4] = t4;\n o[ 5] = t5;\n o[ 6] = t6;\n o[ 7] = t7;\n o[ 8] = t8;\n o[ 9] = t9;\n o[10] = t10;\n o[11] = t11;\n o[12] = t12;\n o[13] = t13;\n o[14] = t14;\n o[15] = t15;\n}\n\nfunction S(o, a) {\n M(o, a, a);\n}\n\nfunction inv25519(o, i) {\n var c = gf();\n var a;\n for (a = 0; a < 16; a++) c[a] = i[a];\n for (a = 253; a >= 0; a--) {\n S(c, c);\n if(a !== 2 && a !== 4) M(c, c, i);\n }\n for (a = 0; a < 16; a++) o[a] = c[a];\n}\n\nfunction pow2523(o, i) {\n var c = gf();\n var a;\n for (a = 0; a < 16; a++) c[a] = i[a];\n for (a = 250; a >= 0; a--) {\n S(c, c);\n if(a !== 1) M(c, c, i);\n }\n for (a = 0; a < 16; a++) o[a] = c[a];\n}\n\nfunction crypto_scalarmult(q, n, p) {\n var z = new Uint8Array(32);\n var x = new Float64Array(80), r, i;\n var a = gf(), b = gf(), c = gf(),\n d = gf(), e = gf(), f = gf();\n for (i = 0; i < 31; i++) z[i] = n[i];\n z[31]=(n[31]&127)|64;\n z[0]&=248;\n unpack25519(x,p);\n for (i = 0; i < 16; i++) {\n b[i]=x[i];\n d[i]=a[i]=c[i]=0;\n }\n a[0]=d[0]=1;\n for (i=254; i>=0; --i) {\n r=(z[i>>>3]>>>(i&7))&1;\n sel25519(a,b,r);\n sel25519(c,d,r);\n A(e,a,c);\n Z(a,a,c);\n A(c,b,d);\n Z(b,b,d);\n S(d,e);\n S(f,a);\n M(a,c,a);\n M(c,b,e);\n A(e,a,c);\n Z(a,a,c);\n S(b,a);\n Z(c,d,f);\n M(a,c,_121665);\n A(a,a,d);\n M(c,c,a);\n M(a,d,f);\n M(d,b,x);\n S(b,e);\n sel25519(a,b,r);\n sel25519(c,d,r);\n }\n for (i = 0; i < 16; i++) {\n x[i+16]=a[i];\n x[i+32]=c[i];\n x[i+48]=b[i];\n x[i+64]=d[i];\n }\n var x32 = x.subarray(32);\n var x16 = x.subarray(16);\n inv25519(x32,x32);\n M(x16,x16,x32);\n pack25519(q,x16);\n return 0;\n}\n\nfunction crypto_scalarmult_base(q, n) {\n return crypto_scalarmult(q, n, _9);\n}\n\nfunction crypto_box_keypair(y, x) {\n randombytes(x, 32);\n return crypto_scalarmult_base(y, x);\n}\n\nfunction crypto_box_beforenm(k, y, x) {\n var s = new Uint8Array(32);\n crypto_scalarmult(s, x, y);\n return crypto_core_hsalsa20(k, _0, s, sigma);\n}\n\nvar crypto_box_afternm = crypto_secretbox;\nvar crypto_box_open_afternm = crypto_secretbox_open;\n\nfunction crypto_box(c, m, d, n, y, x) {\n var k = new Uint8Array(32);\n crypto_box_beforenm(k, y, x);\n return crypto_box_afternm(c, m, d, n, k);\n}\n\nfunction crypto_box_open(m, c, d, n, y, x) {\n var k = new Uint8Array(32);\n crypto_box_beforenm(k, y, x);\n return crypto_box_open_afternm(m, c, d, n, k);\n}\n\nvar K = [\n 0x428a2f98, 0xd728ae22, 0x71374491, 0x23ef65cd,\n 0xb5c0fbcf, 0xec4d3b2f, 0xe9b5dba5, 0x8189dbbc,\n 0x3956c25b, 0xf348b538, 0x59f111f1, 0xb605d019,\n 0x923f82a4, 0xaf194f9b, 0xab1c5ed5, 0xda6d8118,\n 0xd807aa98, 0xa3030242, 0x12835b01, 0x45706fbe,\n 0x243185be, 0x4ee4b28c, 0x550c7dc3, 0xd5ffb4e2,\n 0x72be5d74, 0xf27b896f, 0x80deb1fe, 0x3b1696b1,\n 0x9bdc06a7, 0x25c71235, 0xc19bf174, 0xcf692694,\n 0xe49b69c1, 0x9ef14ad2, 0xefbe4786, 0x384f25e3,\n 0x0fc19dc6, 0x8b8cd5b5, 0x240ca1cc, 0x77ac9c65,\n 0x2de92c6f, 0x592b0275, 0x4a7484aa, 0x6ea6e483,\n 0x5cb0a9dc, 0xbd41fbd4, 0x76f988da, 0x831153b5,\n 0x983e5152, 0xee66dfab, 0xa831c66d, 0x2db43210,\n 0xb00327c8, 0x98fb213f, 0xbf597fc7, 0xbeef0ee4,\n 0xc6e00bf3, 0x3da88fc2, 0xd5a79147, 0x930aa725,\n 0x06ca6351, 0xe003826f, 0x14292967, 0x0a0e6e70,\n 0x27b70a85, 0x46d22ffc, 0x2e1b2138, 0x5c26c926,\n 0x4d2c6dfc, 0x5ac42aed, 0x53380d13, 0x9d95b3df,\n 0x650a7354, 0x8baf63de, 0x766a0abb, 0x3c77b2a8,\n 0x81c2c92e, 0x47edaee6, 0x92722c85, 0x1482353b,\n 0xa2bfe8a1, 0x4cf10364, 0xa81a664b, 0xbc423001,\n 0xc24b8b70, 0xd0f89791, 0xc76c51a3, 0x0654be30,\n 0xd192e819, 0xd6ef5218, 0xd6990624, 0x5565a910,\n 0xf40e3585, 0x5771202a, 0x106aa070, 0x32bbd1b8,\n 0x19a4c116, 0xb8d2d0c8, 0x1e376c08, 0x5141ab53,\n 0x2748774c, 0xdf8eeb99, 0x34b0bcb5, 0xe19b48a8,\n 0x391c0cb3, 0xc5c95a63, 0x4ed8aa4a, 0xe3418acb,\n 0x5b9cca4f, 0x7763e373, 0x682e6ff3, 0xd6b2b8a3,\n 0x748f82ee, 0x5defb2fc, 0x78a5636f, 0x43172f60,\n 0x84c87814, 0xa1f0ab72, 0x8cc70208, 0x1a6439ec,\n 0x90befffa, 0x23631e28, 0xa4506ceb, 0xde82bde9,\n 0xbef9a3f7, 0xb2c67915, 0xc67178f2, 0xe372532b,\n 0xca273ece, 0xea26619c, 0xd186b8c7, 0x21c0c207,\n 0xeada7dd6, 0xcde0eb1e, 0xf57d4f7f, 0xee6ed178,\n 0x06f067aa, 0x72176fba, 0x0a637dc5, 0xa2c898a6,\n 0x113f9804, 0xbef90dae, 0x1b710b35, 0x131c471b,\n 0x28db77f5, 0x23047d84, 0x32caab7b, 0x40c72493,\n 0x3c9ebe0a, 0x15c9bebc, 0x431d67c4, 0x9c100d4c,\n 0x4cc5d4be, 0xcb3e42b6, 0x597f299c, 0xfc657e2a,\n 0x5fcb6fab, 0x3ad6faec, 0x6c44198c, 0x4a475817\n];\n\nfunction crypto_hashblocks_hl(hh, hl, m, n) {\n var wh = new Int32Array(16), wl = new Int32Array(16),\n bh0, bh1, bh2, bh3, bh4, bh5, bh6, bh7,\n bl0, bl1, bl2, bl3, bl4, bl5, bl6, bl7,\n th, tl, i, j, h, l, a, b, c, d;\n\n var ah0 = hh[0],\n ah1 = hh[1],\n ah2 = hh[2],\n ah3 = hh[3],\n ah4 = hh[4],\n ah5 = hh[5],\n ah6 = hh[6],\n ah7 = hh[7],\n\n al0 = hl[0],\n al1 = hl[1],\n al2 = hl[2],\n al3 = hl[3],\n al4 = hl[4],\n al5 = hl[5],\n al6 = hl[6],\n al7 = hl[7];\n\n var pos = 0;\n while (n >= 128) {\n for (i = 0; i < 16; i++) {\n j = 8 * i + pos;\n wh[i] = (m[j+0] << 24) | (m[j+1] << 16) | (m[j+2] << 8) | m[j+3];\n wl[i] = (m[j+4] << 24) | (m[j+5] << 16) | (m[j+6] << 8) | m[j+7];\n }\n for (i = 0; i < 80; i++) {\n bh0 = ah0;\n bh1 = ah1;\n bh2 = ah2;\n bh3 = ah3;\n bh4 = ah4;\n bh5 = ah5;\n bh6 = ah6;\n bh7 = ah7;\n\n bl0 = al0;\n bl1 = al1;\n bl2 = al2;\n bl3 = al3;\n bl4 = al4;\n bl5 = al5;\n bl6 = al6;\n bl7 = al7;\n\n // add\n h = ah7;\n l = al7;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n // Sigma1\n h = ((ah4 >>> 14) | (al4 << (32-14))) ^ ((ah4 >>> 18) | (al4 << (32-18))) ^ ((al4 >>> (41-32)) | (ah4 << (32-(41-32))));\n l = ((al4 >>> 14) | (ah4 << (32-14))) ^ ((al4 >>> 18) | (ah4 << (32-18))) ^ ((ah4 >>> (41-32)) | (al4 << (32-(41-32))));\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // Ch\n h = (ah4 & ah5) ^ (~ah4 & ah6);\n l = (al4 & al5) ^ (~al4 & al6);\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // K\n h = K[i*2];\n l = K[i*2+1];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // w\n h = wh[i%16];\n l = wl[i%16];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n th = c & 0xffff | d << 16;\n tl = a & 0xffff | b << 16;\n\n // add\n h = th;\n l = tl;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n // Sigma0\n h = ((ah0 >>> 28) | (al0 << (32-28))) ^ ((al0 >>> (34-32)) | (ah0 << (32-(34-32)))) ^ ((al0 >>> (39-32)) | (ah0 << (32-(39-32))));\n l = ((al0 >>> 28) | (ah0 << (32-28))) ^ ((ah0 >>> (34-32)) | (al0 << (32-(34-32)))) ^ ((ah0 >>> (39-32)) | (al0 << (32-(39-32))));\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // Maj\n h = (ah0 & ah1) ^ (ah0 & ah2) ^ (ah1 & ah2);\n l = (al0 & al1) ^ (al0 & al2) ^ (al1 & al2);\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n bh7 = (c & 0xffff) | (d << 16);\n bl7 = (a & 0xffff) | (b << 16);\n\n // add\n h = bh3;\n l = bl3;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = th;\n l = tl;\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n bh3 = (c & 0xffff) | (d << 16);\n bl3 = (a & 0xffff) | (b << 16);\n\n ah1 = bh0;\n ah2 = bh1;\n ah3 = bh2;\n ah4 = bh3;\n ah5 = bh4;\n ah6 = bh5;\n ah7 = bh6;\n ah0 = bh7;\n\n al1 = bl0;\n al2 = bl1;\n al3 = bl2;\n al4 = bl3;\n al5 = bl4;\n al6 = bl5;\n al7 = bl6;\n al0 = bl7;\n\n if (i%16 === 15) {\n for (j = 0; j < 16; j++) {\n // add\n h = wh[j];\n l = wl[j];\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = wh[(j+9)%16];\n l = wl[(j+9)%16];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // sigma0\n th = wh[(j+1)%16];\n tl = wl[(j+1)%16];\n h = ((th >>> 1) | (tl << (32-1))) ^ ((th >>> 8) | (tl << (32-8))) ^ (th >>> 7);\n l = ((tl >>> 1) | (th << (32-1))) ^ ((tl >>> 8) | (th << (32-8))) ^ ((tl >>> 7) | (th << (32-7)));\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // sigma1\n th = wh[(j+14)%16];\n tl = wl[(j+14)%16];\n h = ((th >>> 19) | (tl << (32-19))) ^ ((tl >>> (61-32)) | (th << (32-(61-32)))) ^ (th >>> 6);\n l = ((tl >>> 19) | (th << (32-19))) ^ ((th >>> (61-32)) | (tl << (32-(61-32)))) ^ ((tl >>> 6) | (th << (32-6)));\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n wh[j] = (c & 0xffff) | (d << 16);\n wl[j] = (a & 0xffff) | (b << 16);\n }\n }\n }\n\n // add\n h = ah0;\n l = al0;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[0];\n l = hl[0];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[0] = ah0 = (c & 0xffff) | (d << 16);\n hl[0] = al0 = (a & 0xffff) | (b << 16);\n\n h = ah1;\n l = al1;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[1];\n l = hl[1];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[1] = ah1 = (c & 0xffff) | (d << 16);\n hl[1] = al1 = (a & 0xffff) | (b << 16);\n\n h = ah2;\n l = al2;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[2];\n l = hl[2];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[2] = ah2 = (c & 0xffff) | (d << 16);\n hl[2] = al2 = (a & 0xffff) | (b << 16);\n\n h = ah3;\n l = al3;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[3];\n l = hl[3];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[3] = ah3 = (c & 0xffff) | (d << 16);\n hl[3] = al3 = (a & 0xffff) | (b << 16);\n\n h = ah4;\n l = al4;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[4];\n l = hl[4];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[4] = ah4 = (c & 0xffff) | (d << 16);\n hl[4] = al4 = (a & 0xffff) | (b << 16);\n\n h = ah5;\n l = al5;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[5];\n l = hl[5];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[5] = ah5 = (c & 0xffff) | (d << 16);\n hl[5] = al5 = (a & 0xffff) | (b << 16);\n\n h = ah6;\n l = al6;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[6];\n l = hl[6];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[6] = ah6 = (c & 0xffff) | (d << 16);\n hl[6] = al6 = (a & 0xffff) | (b << 16);\n\n h = ah7;\n l = al7;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[7];\n l = hl[7];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[7] = ah7 = (c & 0xffff) | (d << 16);\n hl[7] = al7 = (a & 0xffff) | (b << 16);\n\n pos += 128;\n n -= 128;\n }\n\n return n;\n}\n\nfunction crypto_hash(out, m, n) {\n var hh = new Int32Array(8),\n hl = new Int32Array(8),\n x = new Uint8Array(256),\n i, b = n;\n\n hh[0] = 0x6a09e667;\n hh[1] = 0xbb67ae85;\n hh[2] = 0x3c6ef372;\n hh[3] = 0xa54ff53a;\n hh[4] = 0x510e527f;\n hh[5] = 0x9b05688c;\n hh[6] = 0x1f83d9ab;\n hh[7] = 0x5be0cd19;\n\n hl[0] = 0xf3bcc908;\n hl[1] = 0x84caa73b;\n hl[2] = 0xfe94f82b;\n hl[3] = 0x5f1d36f1;\n hl[4] = 0xade682d1;\n hl[5] = 0x2b3e6c1f;\n hl[6] = 0xfb41bd6b;\n hl[7] = 0x137e2179;\n\n crypto_hashblocks_hl(hh, hl, m, n);\n n %= 128;\n\n for (i = 0; i < n; i++) x[i] = m[b-n+i];\n x[n] = 128;\n\n n = 256-128*(n<112?1:0);\n x[n-9] = 0;\n ts64(x, n-8, (b / 0x20000000) | 0, b << 3);\n crypto_hashblocks_hl(hh, hl, x, n);\n\n for (i = 0; i < 8; i++) ts64(out, 8*i, hh[i], hl[i]);\n\n return 0;\n}\n\nfunction add(p, q) {\n var a = gf(), b = gf(), c = gf(),\n d = gf(), e = gf(), f = gf(),\n g = gf(), h = gf(), t = gf();\n\n Z(a, p[1], p[0]);\n Z(t, q[1], q[0]);\n M(a, a, t);\n A(b, p[0], p[1]);\n A(t, q[0], q[1]);\n M(b, b, t);\n M(c, p[3], q[3]);\n M(c, c, D2);\n M(d, p[2], q[2]);\n A(d, d, d);\n Z(e, b, a);\n Z(f, d, c);\n A(g, d, c);\n A(h, b, a);\n\n M(p[0], e, f);\n M(p[1], h, g);\n M(p[2], g, f);\n M(p[3], e, h);\n}\n\nfunction cswap(p, q, b) {\n var i;\n for (i = 0; i < 4; i++) {\n sel25519(p[i], q[i], b);\n }\n}\n\nfunction pack(r, p) {\n var tx = gf(), ty = gf(), zi = gf();\n inv25519(zi, p[2]);\n M(tx, p[0], zi);\n M(ty, p[1], zi);\n pack25519(r, ty);\n r[31] ^= par25519(tx) << 7;\n}\n\nfunction scalarmult(p, q, s) {\n var b, i;\n set25519(p[0], gf0);\n set25519(p[1], gf1);\n set25519(p[2], gf1);\n set25519(p[3], gf0);\n for (i = 255; i >= 0; --i) {\n b = (s[(i/8)|0] >> (i&7)) & 1;\n cswap(p, q, b);\n add(q, p);\n add(p, p);\n cswap(p, q, b);\n }\n}\n\nfunction scalarbase(p, s) {\n var q = [gf(), gf(), gf(), gf()];\n set25519(q[0], X);\n set25519(q[1], Y);\n set25519(q[2], gf1);\n M(q[3], X, Y);\n scalarmult(p, q, s);\n}\n\nfunction crypto_sign_keypair(pk, sk, seeded) {\n var d = new Uint8Array(64);\n var p = [gf(), gf(), gf(), gf()];\n var i;\n\n if (!seeded) randombytes(sk, 32);\n crypto_hash(d, sk, 32);\n d[0] &= 248;\n d[31] &= 127;\n d[31] |= 64;\n\n scalarbase(p, d);\n pack(pk, p);\n\n for (i = 0; i < 32; i++) sk[i+32] = pk[i];\n return 0;\n}\n\nvar L = new Float64Array([0xed, 0xd3, 0xf5, 0x5c, 0x1a, 0x63, 0x12, 0x58, 0xd6, 0x9c, 0xf7, 0xa2, 0xde, 0xf9, 0xde, 0x14, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x10]);\n\nfunction modL(r, x) {\n var carry, i, j, k;\n for (i = 63; i >= 32; --i) {\n carry = 0;\n for (j = i - 32, k = i - 12; j < k; ++j) {\n x[j] += carry - 16 * x[i] * L[j - (i - 32)];\n carry = Math.floor((x[j] + 128) / 256);\n x[j] -= carry * 256;\n }\n x[j] += carry;\n x[i] = 0;\n }\n carry = 0;\n for (j = 0; j < 32; j++) {\n x[j] += carry - (x[31] >> 4) * L[j];\n carry = x[j] >> 8;\n x[j] &= 255;\n }\n for (j = 0; j < 32; j++) x[j] -= carry * L[j];\n for (i = 0; i < 32; i++) {\n x[i+1] += x[i] >> 8;\n r[i] = x[i] & 255;\n }\n}\n\nfunction reduce(r) {\n var x = new Float64Array(64), i;\n for (i = 0; i < 64; i++) x[i] = r[i];\n for (i = 0; i < 64; i++) r[i] = 0;\n modL(r, x);\n}\n\n// Note: difference from C - smlen returned, not passed as argument.\nfunction crypto_sign(sm, m, n, sk) {\n var d = new Uint8Array(64), h = new Uint8Array(64), r = new Uint8Array(64);\n var i, j, x = new Float64Array(64);\n var p = [gf(), gf(), gf(), gf()];\n\n crypto_hash(d, sk, 32);\n d[0] &= 248;\n d[31] &= 127;\n d[31] |= 64;\n\n var smlen = n + 64;\n for (i = 0; i < n; i++) sm[64 + i] = m[i];\n for (i = 0; i < 32; i++) sm[32 + i] = d[32 + i];\n\n crypto_hash(r, sm.subarray(32), n+32);\n reduce(r);\n scalarbase(p, r);\n pack(sm, p);\n\n for (i = 32; i < 64; i++) sm[i] = sk[i];\n crypto_hash(h, sm, n + 64);\n reduce(h);\n\n for (i = 0; i < 64; i++) x[i] = 0;\n for (i = 0; i < 32; i++) x[i] = r[i];\n for (i = 0; i < 32; i++) {\n for (j = 0; j < 32; j++) {\n x[i+j] += h[i] * d[j];\n }\n }\n\n modL(sm.subarray(32), x);\n return smlen;\n}\n\nfunction unpackneg(r, p) {\n var t = gf(), chk = gf(), num = gf(),\n den = gf(), den2 = gf(), den4 = gf(),\n den6 = gf();\n\n set25519(r[2], gf1);\n unpack25519(r[1], p);\n S(num, r[1]);\n M(den, num, D);\n Z(num, num, r[2]);\n A(den, r[2], den);\n\n S(den2, den);\n S(den4, den2);\n M(den6, den4, den2);\n M(t, den6, num);\n M(t, t, den);\n\n pow2523(t, t);\n M(t, t, num);\n M(t, t, den);\n M(t, t, den);\n M(r[0], t, den);\n\n S(chk, r[0]);\n M(chk, chk, den);\n if (neq25519(chk, num)) M(r[0], r[0], I);\n\n S(chk, r[0]);\n M(chk, chk, den);\n if (neq25519(chk, num)) return -1;\n\n if (par25519(r[0]) === (p[31]>>7)) Z(r[0], gf0, r[0]);\n\n M(r[3], r[0], r[1]);\n return 0;\n}\n\nfunction crypto_sign_open(m, sm, n, pk) {\n var i;\n var t = new Uint8Array(32), h = new Uint8Array(64);\n var p = [gf(), gf(), gf(), gf()],\n q = [gf(), gf(), gf(), gf()];\n\n if (n < 64) return -1;\n\n if (unpackneg(q, pk)) return -1;\n\n for (i = 0; i < n; i++) m[i] = sm[i];\n for (i = 0; i < 32; i++) m[i+32] = pk[i];\n crypto_hash(h, m, n);\n reduce(h);\n scalarmult(p, q, h);\n\n scalarbase(q, sm.subarray(32));\n add(p, q);\n pack(t, p);\n\n n -= 64;\n if (crypto_verify_32(sm, 0, t, 0)) {\n for (i = 0; i < n; i++) m[i] = 0;\n return -1;\n }\n\n for (i = 0; i < n; i++) m[i] = sm[i + 64];\n return n;\n}\n\nvar crypto_secretbox_KEYBYTES = 32,\n crypto_secretbox_NONCEBYTES = 24,\n crypto_secretbox_ZEROBYTES = 32,\n crypto_secretbox_BOXZEROBYTES = 16,\n crypto_scalarmult_BYTES = 32,\n crypto_scalarmult_SCALARBYTES = 32,\n crypto_box_PUBLICKEYBYTES = 32,\n crypto_box_SECRETKEYBYTES = 32,\n crypto_box_BEFORENMBYTES = 32,\n crypto_box_NONCEBYTES = crypto_secretbox_NONCEBYTES,\n crypto_box_ZEROBYTES = crypto_secretbox_ZEROBYTES,\n crypto_box_BOXZEROBYTES = crypto_secretbox_BOXZEROBYTES,\n crypto_sign_BYTES = 64,\n crypto_sign_PUBLICKEYBYTES = 32,\n crypto_sign_SECRETKEYBYTES = 64,\n crypto_sign_SEEDBYTES = 32,\n crypto_hash_BYTES = 64;\n\nnacl.lowlevel = {\n crypto_core_hsalsa20: crypto_core_hsalsa20,\n crypto_stream_xor: crypto_stream_xor,\n crypto_stream: crypto_stream,\n crypto_stream_salsa20_xor: crypto_stream_salsa20_xor,\n crypto_stream_salsa20: crypto_stream_salsa20,\n crypto_onetimeauth: crypto_onetimeauth,\n crypto_onetimeauth_verify: crypto_onetimeauth_verify,\n crypto_verify_16: crypto_verify_16,\n crypto_verify_32: crypto_verify_32,\n crypto_secretbox: crypto_secretbox,\n crypto_secretbox_open: crypto_secretbox_open,\n crypto_scalarmult: crypto_scalarmult,\n crypto_scalarmult_base: crypto_scalarmult_base,\n crypto_box_beforenm: crypto_box_beforenm,\n crypto_box_afternm: crypto_box_afternm,\n crypto_box: crypto_box,\n crypto_box_open: crypto_box_open,\n crypto_box_keypair: crypto_box_keypair,\n crypto_hash: crypto_hash,\n crypto_sign: crypto_sign,\n crypto_sign_keypair: crypto_sign_keypair,\n crypto_sign_open: crypto_sign_open,\n\n crypto_secretbox_KEYBYTES: crypto_secretbox_KEYBYTES,\n crypto_secretbox_NONCEBYTES: crypto_secretbox_NONCEBYTES,\n crypto_secretbox_ZEROBYTES: crypto_secretbox_ZEROBYTES,\n crypto_secretbox_BOXZEROBYTES: crypto_secretbox_BOXZEROBYTES,\n crypto_scalarmult_BYTES: crypto_scalarmult_BYTES,\n crypto_scalarmult_SCALARBYTES: crypto_scalarmult_SCALARBYTES,\n crypto_box_PUBLICKEYBYTES: crypto_box_PUBLICKEYBYTES,\n crypto_box_SECRETKEYBYTES: crypto_box_SECRETKEYBYTES,\n crypto_box_BEFORENMBYTES: crypto_box_BEFORENMBYTES,\n crypto_box_NONCEBYTES: crypto_box_NONCEBYTES,\n crypto_box_ZEROBYTES: crypto_box_ZEROBYTES,\n crypto_box_BOXZEROBYTES: crypto_box_BOXZEROBYTES,\n crypto_sign_BYTES: crypto_sign_BYTES,\n crypto_sign_PUBLICKEYBYTES: crypto_sign_PUBLICKEYBYTES,\n crypto_sign_SECRETKEYBYTES: crypto_sign_SECRETKEYBYTES,\n crypto_sign_SEEDBYTES: crypto_sign_SEEDBYTES,\n crypto_hash_BYTES: crypto_hash_BYTES,\n\n gf: gf,\n D: D,\n L: L,\n pack25519: pack25519,\n unpack25519: unpack25519,\n M: M,\n A: A,\n S: S,\n Z: Z,\n pow2523: pow2523,\n add: add,\n set25519: set25519,\n modL: modL,\n scalarmult: scalarmult,\n scalarbase: scalarbase,\n};\n\n/* High-level API */\n\nfunction checkLengths(k, n) {\n if (k.length !== crypto_secretbox_KEYBYTES) throw new Error('bad key size');\n if (n.length !== crypto_secretbox_NONCEBYTES) throw new Error('bad nonce size');\n}\n\nfunction checkBoxLengths(pk, sk) {\n if (pk.length !== crypto_box_PUBLICKEYBYTES) throw new Error('bad public key size');\n if (sk.length !== crypto_box_SECRETKEYBYTES) throw new Error('bad secret key size');\n}\n\nfunction checkArrayTypes() {\n for (var i = 0; i < arguments.length; i++) {\n if (!(arguments[i] instanceof Uint8Array))\n throw new TypeError('unexpected type, use Uint8Array');\n }\n}\n\nfunction cleanup(arr) {\n for (var i = 0; i < arr.length; i++) arr[i] = 0;\n}\n\nnacl.randomBytes = function(n) {\n var b = new Uint8Array(n);\n randombytes(b, n);\n return b;\n};\n\nnacl.secretbox = function(msg, nonce, key) {\n checkArrayTypes(msg, nonce, key);\n checkLengths(key, nonce);\n var m = new Uint8Array(crypto_secretbox_ZEROBYTES + msg.length);\n var c = new Uint8Array(m.length);\n for (var i = 0; i < msg.length; i++) m[i+crypto_secretbox_ZEROBYTES] = msg[i];\n crypto_secretbox(c, m, m.length, nonce, key);\n return c.subarray(crypto_secretbox_BOXZEROBYTES);\n};\n\nnacl.secretbox.open = function(box, nonce, key) {\n checkArrayTypes(box, nonce, key);\n checkLengths(key, nonce);\n var c = new Uint8Array(crypto_secretbox_BOXZEROBYTES + box.length);\n var m = new Uint8Array(c.length);\n for (var i = 0; i < box.length; i++) c[i+crypto_secretbox_BOXZEROBYTES] = box[i];\n if (c.length < 32) return null;\n if (crypto_secretbox_open(m, c, c.length, nonce, key) !== 0) return null;\n return m.subarray(crypto_secretbox_ZEROBYTES);\n};\n\nnacl.secretbox.keyLength = crypto_secretbox_KEYBYTES;\nnacl.secretbox.nonceLength = crypto_secretbox_NONCEBYTES;\nnacl.secretbox.overheadLength = crypto_secretbox_BOXZEROBYTES;\n\nnacl.scalarMult = function(n, p) {\n checkArrayTypes(n, p);\n if (n.length !== crypto_scalarmult_SCALARBYTES) throw new Error('bad n size');\n if (p.length !== crypto_scalarmult_BYTES) throw new Error('bad p size');\n var q = new Uint8Array(crypto_scalarmult_BYTES);\n crypto_scalarmult(q, n, p);\n return q;\n};\n\nnacl.scalarMult.base = function(n) {\n checkArrayTypes(n);\n if (n.length !== crypto_scalarmult_SCALARBYTES) throw new Error('bad n size');\n var q = new Uint8Array(crypto_scalarmult_BYTES);\n crypto_scalarmult_base(q, n);\n return q;\n};\n\nnacl.scalarMult.scalarLength = crypto_scalarmult_SCALARBYTES;\nnacl.scalarMult.groupElementLength = crypto_scalarmult_BYTES;\n\nnacl.box = function(msg, nonce, publicKey, secretKey) {\n var k = nacl.box.before(publicKey, secretKey);\n return nacl.secretbox(msg, nonce, k);\n};\n\nnacl.box.before = function(publicKey, secretKey) {\n checkArrayTypes(publicKey, secretKey);\n checkBoxLengths(publicKey, secretKey);\n var k = new Uint8Array(crypto_box_BEFORENMBYTES);\n crypto_box_beforenm(k, publicKey, secretKey);\n return k;\n};\n\nnacl.box.after = nacl.secretbox;\n\nnacl.box.open = function(msg, nonce, publicKey, secretKey) {\n var k = nacl.box.before(publicKey, secretKey);\n return nacl.secretbox.open(msg, nonce, k);\n};\n\nnacl.box.open.after = nacl.secretbox.open;\n\nnacl.box.keyPair = function() {\n var pk = new Uint8Array(crypto_box_PUBLICKEYBYTES);\n var sk = new Uint8Array(crypto_box_SECRETKEYBYTES);\n crypto_box_keypair(pk, sk);\n return {publicKey: pk, secretKey: sk};\n};\n\nnacl.box.keyPair.fromSecretKey = function(secretKey) {\n checkArrayTypes(secretKey);\n if (secretKey.length !== crypto_box_SECRETKEYBYTES)\n throw new Error('bad secret key size');\n var pk = new Uint8Array(crypto_box_PUBLICKEYBYTES);\n crypto_scalarmult_base(pk, secretKey);\n return {publicKey: pk, secretKey: new Uint8Array(secretKey)};\n};\n\nnacl.box.publicKeyLength = crypto_box_PUBLICKEYBYTES;\nnacl.box.secretKeyLength = crypto_box_SECRETKEYBYTES;\nnacl.box.sharedKeyLength = crypto_box_BEFORENMBYTES;\nnacl.box.nonceLength = crypto_box_NONCEBYTES;\nnacl.box.overheadLength = nacl.secretbox.overheadLength;\n\nnacl.sign = function(msg, secretKey) {\n checkArrayTypes(msg, secretKey);\n if (secretKey.length !== crypto_sign_SECRETKEYBYTES)\n throw new Error('bad secret key size');\n var signedMsg = new Uint8Array(crypto_sign_BYTES+msg.length);\n crypto_sign(signedMsg, msg, msg.length, secretKey);\n return signedMsg;\n};\n\nnacl.sign.open = function(signedMsg, publicKey) {\n checkArrayTypes(signedMsg, publicKey);\n if (publicKey.length !== crypto_sign_PUBLICKEYBYTES)\n throw new Error('bad public key size');\n var tmp = new Uint8Array(signedMsg.length);\n var mlen = crypto_sign_open(tmp, signedMsg, signedMsg.length, publicKey);\n if (mlen < 0) return null;\n var m = new Uint8Array(mlen);\n for (var i = 0; i < m.length; i++) m[i] = tmp[i];\n return m;\n};\n\nnacl.sign.detached = function(msg, secretKey) {\n var signedMsg = nacl.sign(msg, secretKey);\n var sig = new Uint8Array(crypto_sign_BYTES);\n for (var i = 0; i < sig.length; i++) sig[i] = signedMsg[i];\n return sig;\n};\n\nnacl.sign.detached.verify = function(msg, sig, publicKey) {\n checkArrayTypes(msg, sig, publicKey);\n if (sig.length !== crypto_sign_BYTES)\n throw new Error('bad signature size');\n if (publicKey.length !== crypto_sign_PUBLICKEYBYTES)\n throw new Error('bad public key size');\n var sm = new Uint8Array(crypto_sign_BYTES + msg.length);\n var m = new Uint8Array(crypto_sign_BYTES + msg.length);\n var i;\n for (i = 0; i < crypto_sign_BYTES; i++) sm[i] = sig[i];\n for (i = 0; i < msg.length; i++) sm[i+crypto_sign_BYTES] = msg[i];\n return (crypto_sign_open(m, sm, sm.length, publicKey) >= 0);\n};\n\nnacl.sign.keyPair = function() {\n var pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);\n var sk = new Uint8Array(crypto_sign_SECRETKEYBYTES);\n crypto_sign_keypair(pk, sk);\n return {publicKey: pk, secretKey: sk};\n};\n\nnacl.sign.keyPair.fromSecretKey = function(secretKey) {\n checkArrayTypes(secretKey);\n if (secretKey.length !== crypto_sign_SECRETKEYBYTES)\n throw new Error('bad secret key size');\n var pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);\n for (var i = 0; i < pk.length; i++) pk[i] = secretKey[32+i];\n return {publicKey: pk, secretKey: new Uint8Array(secretKey)};\n};\n\nnacl.sign.keyPair.fromSeed = function(seed) {\n checkArrayTypes(seed);\n if (seed.length !== crypto_sign_SEEDBYTES)\n throw new Error('bad seed size');\n var pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);\n var sk = new Uint8Array(crypto_sign_SECRETKEYBYTES);\n for (var i = 0; i < 32; i++) sk[i] = seed[i];\n crypto_sign_keypair(pk, sk, true);\n return {publicKey: pk, secretKey: sk};\n};\n\nnacl.sign.publicKeyLength = crypto_sign_PUBLICKEYBYTES;\nnacl.sign.secretKeyLength = crypto_sign_SECRETKEYBYTES;\nnacl.sign.seedLength = crypto_sign_SEEDBYTES;\nnacl.sign.signatureLength = crypto_sign_BYTES;\n\nnacl.hash = function(msg) {\n checkArrayTypes(msg);\n var h = new Uint8Array(crypto_hash_BYTES);\n crypto_hash(h, msg, msg.length);\n return h;\n};\n\nnacl.hash.hashLength = crypto_hash_BYTES;\n\nnacl.verify = function(x, y) {\n checkArrayTypes(x, y);\n // Zero length arguments are considered not equal.\n if (x.length === 0 || y.length === 0) return false;\n if (x.length !== y.length) return false;\n return (vn(x, 0, y, 0, x.length) === 0) ? true : false;\n};\n\nnacl.setPRNG = function(fn) {\n randombytes = fn;\n};\n\n(function() {\n // Initialize PRNG if environment provides CSPRNG.\n // If not, methods calling randombytes will throw.\n var crypto = typeof self !== 'undefined' ? (self.crypto || self.msCrypto) : null;\n if (crypto && crypto.getRandomValues) {\n // Browsers.\n var QUOTA = 65536;\n nacl.setPRNG(function(x, n) {\n var i, v = new Uint8Array(n);\n for (i = 0; i < n; i += QUOTA) {\n crypto.getRandomValues(v.subarray(i, i + Math.min(n - i, QUOTA)));\n }\n for (i = 0; i < n; i++) x[i] = v[i];\n cleanup(v);\n });\n } else if (typeof require !== 'undefined') {\n // Node.js.\n crypto = require('crypto');\n if (crypto && crypto.randomBytes) {\n nacl.setPRNG(function(x, n) {\n var i, v = crypto.randomBytes(n);\n for (i = 0; i < n; i++) x[i] = v[i];\n cleanup(v);\n });\n }\n }\n})();\n\n})(typeof module !== 'undefined' && module.exports ? module.exports : (self.nacl = self.nacl || {}));\n","module.exports = require('./pusher-with-encryption').default;\n","import Pusher from './pusher';\nimport { Options, validateOptions } from './options';\nimport * as nacl from 'tweetnacl';\n\nexport default class PusherWithEncryption extends Pusher {\n constructor(app_key: string, options: Options) {\n Pusher.logToConsole = PusherWithEncryption.logToConsole;\n Pusher.log = PusherWithEncryption.log;\n\n validateOptions(options);\n options.nacl = nacl;\n super(app_key, options);\n }\n}\n"],"sourceRoot":""} \ No newline at end of file diff --git a/dist/web/pusher-with-encryption.js b/dist/web/pusher-with-encryption.js index af3ecae21..11a49e97e 100644 --- a/dist/web/pusher-with-encryption.js +++ b/dist/web/pusher-with-encryption.js @@ -1,5 +1,5 @@ /*! - * Pusher JavaScript Library v8.4.0-rc1 + * Pusher JavaScript Library v8.4.0-rc2 * https://pusher.com/ * * Copyright 2020, Pusher @@ -2996,7 +2996,7 @@ var ScriptReceivers = new ScriptReceiverFactory('_pusher_script_', 'Pusher.Scrip // CONCATENATED MODULE: ./src/core/defaults.ts var Defaults = { - VERSION: "8.4.0-rc1", + VERSION: "8.4.0-rc2", PROTOCOL: 7, wsPort: 80, wssPort: 443, @@ -6586,10 +6586,12 @@ function getEnableStatsConfig(opts) { } return false; } +const hasCustomHandler = (auth) => { + return 'customHandler' in auth && auth['customHandler'] != null; +}; function buildUserAuthenticator(opts) { const userAuthentication = Object.assign(Object.assign({}, defaults.userAuthentication), opts.userAuthentication); - if ('customHandler' in userAuthentication && - userAuthentication['customHandler'] != null) { + if (hasCustomHandler(userAuthentication)) { return userAuthentication['customHandler']; } return user_authenticator(userAuthentication); @@ -6610,15 +6612,17 @@ function buildChannelAuth(opts, pusher) { if ('headers' in opts.auth) channelAuthorization.headers = opts.auth.headers; } - if ('authorizer' in opts) - channelAuthorization.customHandler = ChannelAuthorizerProxy(pusher, channelAuthorization, opts.authorizer); + if ('authorizer' in opts) { + return { + customHandler: ChannelAuthorizerProxy(pusher, channelAuthorization, opts.authorizer) + }; + } } return channelAuthorization; } function buildChannelAuthorizer(opts, pusher) { const channelAuthorization = buildChannelAuth(opts, pusher); - if ('customHandler' in channelAuthorization && - channelAuthorization['customHandler'] != null) { + if (hasCustomHandler(channelAuthorization)) { return channelAuthorization['customHandler']; } return channel_authorizer(channelAuthorization); @@ -6825,7 +6829,8 @@ class pusher_Pusher { checkAppKey(app_key); validateOptions(options); this.key = app_key; - this.config = getConfig(options, this); + this.options = options; + this.config = getConfig(this.options, this); this.channels = factory.createChannels(); this.global_emitter = new dispatcher_Dispatcher(); this.sessionID = runtime.randomInt(1000000000); diff --git a/dist/web/pusher-with-encryption.js.map b/dist/web/pusher-with-encryption.js.map index 7e94ecc07..65e5fb1f0 100644 --- a/dist/web/pusher-with-encryption.js.map +++ b/dist/web/pusher-with-encryption.js.map @@ -1 +1 @@ -{"version":3,"sources":["webpack://Pusher/webpack/universalModuleDefinition","webpack://Pusher/webpack/bootstrap","webpack://Pusher/./node_modules/@stablelib/base64/base64.ts","webpack://Pusher/./node_modules/@stablelib/utf8/utf8.ts","webpack://Pusher/./node_modules/tweetnacl/nacl-fast.js","webpack://Pusher/./src/core/pusher-with-encryption.js","webpack://Pusher/crypto (ignored)","webpack://Pusher/./src/runtimes/web/dom/script_receiver_factory.ts","webpack://Pusher/./src/core/defaults.ts","webpack://Pusher/./src/runtimes/web/dom/dependency_loader.ts","webpack://Pusher/./src/runtimes/web/dom/dependencies.ts","webpack://Pusher/./src/core/utils/url_store.ts","webpack://Pusher/./src/core/auth/options.ts","webpack://Pusher/./src/core/errors.ts","webpack://Pusher/./src/runtimes/isomorphic/auth/xhr_auth.ts","webpack://Pusher/./src/core/base64.ts","webpack://Pusher/./src/core/utils/timers/abstract_timer.ts","webpack://Pusher/./src/core/utils/timers/index.ts","webpack://Pusher/./src/core/util.ts","webpack://Pusher/./src/core/utils/collections.ts","webpack://Pusher/./src/core/logger.ts","webpack://Pusher/./src/runtimes/web/auth/jsonp_auth.ts","webpack://Pusher/./src/runtimes/web/dom/script_request.ts","webpack://Pusher/./src/runtimes/web/dom/jsonp_request.ts","webpack://Pusher/./src/runtimes/web/timeline/jsonp_timeline.ts","webpack://Pusher/./src/core/transports/url_schemes.ts","webpack://Pusher/./src/core/events/callback_registry.ts","webpack://Pusher/./src/core/events/dispatcher.ts","webpack://Pusher/./src/core/transports/transport_connection.ts","webpack://Pusher/./src/core/transports/transport.ts","webpack://Pusher/./src/runtimes/isomorphic/transports/transports.ts","webpack://Pusher/./src/runtimes/web/transports/transports.ts","webpack://Pusher/./src/runtimes/web/net_info.ts","webpack://Pusher/./src/core/transports/assistant_to_the_transport_manager.ts","webpack://Pusher/./src/core/connection/protocol/protocol.ts","webpack://Pusher/./src/core/connection/connection.ts","webpack://Pusher/./src/core/connection/handshake/index.ts","webpack://Pusher/./src/core/timeline/timeline_sender.ts","webpack://Pusher/./src/core/channels/channel.ts","webpack://Pusher/./src/core/channels/private_channel.ts","webpack://Pusher/./src/core/channels/members.ts","webpack://Pusher/./src/core/channels/presence_channel.ts","webpack://Pusher/./src/core/channels/encrypted_channel.ts","webpack://Pusher/./src/core/connection/connection_manager.ts","webpack://Pusher/./src/core/channels/channels.ts","webpack://Pusher/./src/core/utils/factory.ts","webpack://Pusher/./src/core/transports/transport_manager.ts","webpack://Pusher/./src/core/strategies/sequential_strategy.ts","webpack://Pusher/./src/core/strategies/best_connected_ever_strategy.ts","webpack://Pusher/./src/core/strategies/websocket_prioritized_cached_strategy.ts","webpack://Pusher/./src/core/strategies/delayed_strategy.ts","webpack://Pusher/./src/core/strategies/if_strategy.ts","webpack://Pusher/./src/core/strategies/first_connected_strategy.ts","webpack://Pusher/./src/runtimes/web/default_strategy.ts","webpack://Pusher/./src/runtimes/web/transports/transport_connection_initializer.ts","webpack://Pusher/./src/runtimes/web/http/http_xdomain_request.ts","webpack://Pusher/./src/core/http/http_request.ts","webpack://Pusher/./src/core/http/state.ts","webpack://Pusher/./src/core/http/http_socket.ts","webpack://Pusher/./src/core/http/http_streaming_socket.ts","webpack://Pusher/./src/core/http/http_polling_socket.ts","webpack://Pusher/./src/runtimes/isomorphic/http/http_xhr_request.ts","webpack://Pusher/./src/runtimes/isomorphic/http/http.ts","webpack://Pusher/./src/runtimes/web/http/http.ts","webpack://Pusher/./src/runtimes/web/runtime.ts","webpack://Pusher/./src/core/timeline/level.ts","webpack://Pusher/./src/core/timeline/timeline.ts","webpack://Pusher/./src/core/strategies/transport_strategy.ts","webpack://Pusher/./src/core/strategies/strategy_builder.ts","webpack://Pusher/./src/core/options.ts","webpack://Pusher/./src/core/auth/user_authenticator.ts","webpack://Pusher/./src/core/auth/channel_authorizer.ts","webpack://Pusher/./src/core/auth/deprecated_channel_authorizer.ts","webpack://Pusher/./src/core/config.ts","webpack://Pusher/./src/core/watchlist.ts","webpack://Pusher/./src/core/utils/flat_promise.ts","webpack://Pusher/./src/core/user.ts","webpack://Pusher/./src/core/pusher.ts","webpack://Pusher/./src/core/pusher-with-encryption.ts"],"names":[],"mappings":";;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AACD,O;QCVA;QACA;;QAEA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IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC;KACtC;IACD,OAAO,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AAC1B,CAAC;AAjED,wBAiEC;;;;;;;AC/ID;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,uBAAuB,iBAAiB;AACxC;AACA;;AAEA;AACA,wCAAwC,4BAA4B;;AAEpE;AACA,4BAA4B;;AAE5B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa,OAAO;AACpB;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,aAAa,QAAQ;AACrB,aAAa,OAAO;AACpB;AACA;AACA,eAAe,QAAQ;AACvB;AACA,eAAe,QAAQ;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB;AACA;AACA;;AAEA;AACA;AACA;AACA,aAAa,QAAQ;AACrB,aAAa,OAAO;AACpB;AACA;AACA,eAAe,QAAQ;AACvB;AACA,eAAe,QAAQ;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,iBAAiB,OAAO;AACxB;AACA;;AAEA;AACA;AACA;AACA;AACA,iBAAiB,OAAO;AACxB;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA,8CAA8C;AAC9C,8CAA8C;AAC9C,8CAA8C;AAC9C,8CAA8C;AAC9C,8CAA8C;AAC9C;AACA,8CAA8C;AAC9C,8CAA8C;AAC9C,8CAA8C;AAC9C;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,sDAAsD;AACtD,sDAAsD;AACtD,sDAAsD;AACtD,sDAAsD;AACtD,sDAAsD;AACtD;AACA,sDAAsD;AACtD,sDAAsD;AACtD,sDAAsD;AACtD;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA,qBAAqB;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA,qBAAqB;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA,qBAAqB;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA,qBAAqB;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA,qBAAqB;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA,qBAAqB;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA,qBAAqB;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA,qBAAqB;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA,qBAAqB;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA,qBAAqB;;AAErB;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA,UAAU,QAAQ;AAClB;AACA;AACA;;AAEA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA;AACA;;AAEA;AACA,aAAa,QAAQ;AACrB;AACA,aAAa,QAAQ;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa,OAAO;AACpB;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,UAAU;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,eAAe,WAAW;AAC1B;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;;AAEA;AACA;AACA,aAAa,QAAQ;AACrB;;AAEA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA,aAAa,OAAO;AACpB;AACA,eAAe,QAAQ;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;;AAEA;AACA,iBAAiB,QAAQ;AACzB;;AAEA;AACA,iBAAiB,QAAQ;AACzB;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD;;AAEA;AACA;AACA,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA,aAAa,QAAQ;AACrB,eAAe,QAAQ;AACvB;AACA;AACA;AACA,aAAa,QAAQ;AACrB;;AAEA;AACA;AACA;AACA,aAAa,QAAQ;AACrB,eAAe,QAAQ;AACvB;AACA;AACA;AACA,aAAa,QAAQ;AACrB;;AAEA;AACA;AACA;AACA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA;AACA,aAAa,MAAM;AACnB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,eAAe,QAAQ;AACvB;AACA;AACA;AACA;AACA,eAAe,QAAQ;AACv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ACA;;AAEA;AACA;;AAEA,mBAAmB;AACnB,mBAAmB;;AAEnB;AACA;;AAEA,oBAAoB;AACpB,oBAAoB;;AAEpB;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA,mBAAmB;AACnB,mBAAmB;;AAEnB;AACA;;AAEA,oBAAoB;AACpB,oBAAoB;;AAEpB;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA,mBAAmB;AACnB,mBAAmB;;AAEnB;AACA;;AAEA,oBAAoB;AACpB,oBAAoB;;AAEpB;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA,mBAAmB;AACnB,mBAAmB;;AAEnB;AACA;;AAEA,oBAAoB;AACpB,oBAAoB;;AAEpB;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA,mBAAmB;AACnB,mBAAmB;;AAEnB;AACA;;AAEA,oBAAoB;AACpB,oBAAoB;;AAEpB;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA,mBAAmB;AACnB,mBAAmB;;AAEnB;AACA;;AAEA,oBAAoB;AACpB,oBAAoB;;AAEpB;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA,aAAa,OAAO;AACpB;;AAEA;AACA;AACA;AACA;;AAEA,aAAa,OAAO;;AAEpB;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa,OAAO;AACpB;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,QAAQ;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA,aAAa,QAAQ;AACrB;AACA;;AAEA;;AAEA;AACA;AACA,cAAc,SAAS;AACvB;AACA,gCAAgC,OAAO;AACvC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA;AACA,aAAa,QAAQ;AACrB,aAAa,QAAQ;AACrB;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa,QAAQ;AACrB,aAAa,QAAQ;AACrB;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA,aAAa,OAAO;AACpB,aAAa,QAAQ;;AAErB;AACA;AACA;AACA;;AAEA,cAAc,QAAQ;AACtB;AACA;;AAEA,aAAa,QAAQ;AACrB,aAAa,QAAQ;AACrB,aAAa,QAAQ;AACrB,eAAe,QAAQ;AACvB;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;;AAEA,aAAa,OAAO;AACpB,aAAa,QAAQ;AACrB;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA,eAAe,OAAO;AACtB;AACA;;AAEA,aAAa,OAAO;AACpB;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA,iBAAiB,sBAAsB;AACvC;AACA;AACA;AACA;;AAEA;AACA,iBAAiB,gBAAgB;AACjC;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,iBAAiB,gBAAgB;AACjC;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,iBAAiB,gBAAgB;AACjC;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA,UAAU;AACV;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,UAAU;AACV;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAiB,cAAc;AAC/B;AACA;;AAEA;AACA;AACA;AACA,iBAAiB,gBAAgB;AACjC;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa,uBAAuB;AACpC,aAAa,gBAAgB;AAC7B;AACA;;AAEA;AACA;AACA;AACA;AACA,UAAU;AACV;;AAEA;AACA;AACA;AACA;AACA;AACA,iBAAiB,eAAe;AAChC,UAAU;AACV;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAiB,QAAQ;AACzB;AACA,UAAU;AACV;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA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AO,GAAoB,OAAO,CAAC;AACnC,6BAAe,GAAc,OAAQ,CAAC,eAAe,CAAC;AACtD,mCAAqB,GAAc,OAAQ,CAAC,qBAAqB,CAAC;AAClE,4BAAc,GAAc,OAAQ,CAAC,cAAc,CAAC;AAVxC,6DAAM;AA4O3B,SAAS,WAAW,CAAC,GAAG;IACtB,IAAI,GAAG,KAAK,IAAI,IAAI,GAAG,KAAK,SAAS,EAAE;QACrC,MAAM,yDAAyD,CAAC;KACjE;AACH,CAAC;AAED,OAAO,CAAC,KAAK,CAAC,aAAM,CAAC,CAAC;;;;;;ACtQQ;AACuB;AACnB;AAEnB,MAAM,2CAAqB,SAAQ,WAAM;IACtD,YAAY,OAAe,EAAE,OAAgB;QAC3C,WAAM,CAAC,YAAY,GAAG,2CAAoB,CAAC,YAAY,CAAC;QACxD,WAAM,CAAC,GAAG,GAAG,2CAAoB,CAAC,GAAG,CAAC;QAEtC,eAAe,CAAC,OAAO,CAAC,CAAC;QACzB,OAAO,CAAC,IAAI,GAAG,SAAI,CAAC;QACpB,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAC1B,CAAC;CACF","file":"pusher-with-encryption.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"Pusher\"] = factory();\n\telse\n\t\troot[\"Pusher\"] = factory();\n})(window, function() {\nreturn "," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 3);\n","// Copyright (C) 2016 Dmitry Chestnykh\n// MIT License. See LICENSE file for details.\n\n/**\n * Package base64 implements Base64 encoding and decoding.\n */\n\n// Invalid character used in decoding to indicate\n// that the character to decode is out of range of\n// alphabet and cannot be decoded.\nconst INVALID_BYTE = 256;\n\n/**\n * Implements standard Base64 encoding.\n *\n * Operates in constant time.\n */\nexport class Coder {\n // TODO(dchest): methods to encode chunk-by-chunk.\n\n constructor(private _paddingCharacter = \"=\") { }\n\n encodedLength(length: number): number {\n if (!this._paddingCharacter) {\n return (length * 8 + 5) / 6 | 0;\n }\n return (length + 2) / 3 * 4 | 0;\n }\n\n encode(data: Uint8Array): string {\n let out = \"\";\n\n let i = 0;\n for (; i < data.length - 2; i += 3) {\n let c = (data[i] << 16) | (data[i + 1] << 8) | (data[i + 2]);\n out += this._encodeByte((c >>> 3 * 6) & 63);\n out += this._encodeByte((c >>> 2 * 6) & 63);\n out += this._encodeByte((c >>> 1 * 6) & 63);\n out += this._encodeByte((c >>> 0 * 6) & 63);\n }\n\n const left = data.length - i;\n if (left > 0) {\n let c = (data[i] << 16) | (left === 2 ? data[i + 1] << 8 : 0);\n out += this._encodeByte((c >>> 3 * 6) & 63);\n out += this._encodeByte((c >>> 2 * 6) & 63);\n if (left === 2) {\n out += this._encodeByte((c >>> 1 * 6) & 63);\n } else {\n out += this._paddingCharacter || \"\";\n }\n out += this._paddingCharacter || \"\";\n }\n\n return out;\n }\n\n maxDecodedLength(length: number): number {\n if (!this._paddingCharacter) {\n return (length * 6 + 7) / 8 | 0;\n }\n return length / 4 * 3 | 0;\n }\n\n decodedLength(s: string): number {\n return this.maxDecodedLength(s.length - this._getPaddingLength(s));\n }\n\n decode(s: string): Uint8Array {\n if (s.length === 0) {\n return new Uint8Array(0);\n }\n const paddingLength = this._getPaddingLength(s);\n const length = s.length - paddingLength;\n const out = new Uint8Array(this.maxDecodedLength(length));\n let op = 0;\n let i = 0;\n let haveBad = 0;\n let v0 = 0, v1 = 0, v2 = 0, v3 = 0;\n for (; i < length - 4; i += 4) {\n v0 = this._decodeChar(s.charCodeAt(i + 0));\n v1 = this._decodeChar(s.charCodeAt(i + 1));\n v2 = this._decodeChar(s.charCodeAt(i + 2));\n v3 = this._decodeChar(s.charCodeAt(i + 3));\n out[op++] = (v0 << 2) | (v1 >>> 4);\n out[op++] = (v1 << 4) | (v2 >>> 2);\n out[op++] = (v2 << 6) | v3;\n haveBad |= v0 & INVALID_BYTE;\n haveBad |= v1 & INVALID_BYTE;\n haveBad |= v2 & INVALID_BYTE;\n haveBad |= v3 & INVALID_BYTE;\n }\n if (i < length - 1) {\n v0 = this._decodeChar(s.charCodeAt(i));\n v1 = this._decodeChar(s.charCodeAt(i + 1));\n out[op++] = (v0 << 2) | (v1 >>> 4);\n haveBad |= v0 & INVALID_BYTE;\n haveBad |= v1 & INVALID_BYTE;\n }\n if (i < length - 2) {\n v2 = this._decodeChar(s.charCodeAt(i + 2));\n out[op++] = (v1 << 4) | (v2 >>> 2);\n haveBad |= v2 & INVALID_BYTE;\n }\n if (i < length - 3) {\n v3 = this._decodeChar(s.charCodeAt(i + 3));\n out[op++] = (v2 << 6) | v3;\n haveBad |= v3 & INVALID_BYTE;\n }\n if (haveBad !== 0) {\n throw new Error(\"Base64Coder: incorrect characters for decoding\");\n }\n return out;\n }\n\n // Standard encoding have the following encoded/decoded ranges,\n // which we need to convert between.\n //\n // ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 0123456789 + /\n // Index: 0 - 25 26 - 51 52 - 61 62 63\n // ASCII: 65 - 90 97 - 122 48 - 57 43 47\n //\n\n // Encode 6 bits in b into a new character.\n protected _encodeByte(b: number): string {\n // Encoding uses constant time operations as follows:\n //\n // 1. Define comparison of A with B using (A - B) >>> 8:\n // if A > B, then result is positive integer\n // if A <= B, then result is 0\n //\n // 2. Define selection of C or 0 using bitwise AND: X & C:\n // if X == 0, then result is 0\n // if X != 0, then result is C\n //\n // 3. Start with the smallest comparison (b >= 0), which is always\n // true, so set the result to the starting ASCII value (65).\n //\n // 4. Continue comparing b to higher ASCII values, and selecting\n // zero if comparison isn't true, otherwise selecting a value\n // to add to result, which:\n //\n // a) undoes the previous addition\n // b) provides new value to add\n //\n let result = b;\n // b >= 0\n result += 65;\n // b > 25\n result += ((25 - b) >>> 8) & ((0 - 65) - 26 + 97);\n // b > 51\n result += ((51 - b) >>> 8) & ((26 - 97) - 52 + 48);\n // b > 61\n result += ((61 - b) >>> 8) & ((52 - 48) - 62 + 43);\n // b > 62\n result += ((62 - b) >>> 8) & ((62 - 43) - 63 + 47);\n\n return String.fromCharCode(result);\n }\n\n // Decode a character code into a byte.\n // Must return 256 if character is out of alphabet range.\n protected _decodeChar(c: number): number {\n // Decoding works similar to encoding: using the same comparison\n // function, but now it works on ranges: result is always incremented\n // by value, but this value becomes zero if the range is not\n // satisfied.\n //\n // Decoding starts with invalid value, 256, which is then\n // subtracted when the range is satisfied. If none of the ranges\n // apply, the function returns 256, which is then checked by\n // the caller to throw error.\n let result = INVALID_BYTE; // start with invalid character\n\n // c == 43 (c > 42 and c < 44)\n result += (((42 - c) & (c - 44)) >>> 8) & (-INVALID_BYTE + c - 43 + 62);\n // c == 47 (c > 46 and c < 48)\n result += (((46 - c) & (c - 48)) >>> 8) & (-INVALID_BYTE + c - 47 + 63);\n // c > 47 and c < 58\n result += (((47 - c) & (c - 58)) >>> 8) & (-INVALID_BYTE + c - 48 + 52);\n // c > 64 and c < 91\n result += (((64 - c) & (c - 91)) >>> 8) & (-INVALID_BYTE + c - 65 + 0);\n // c > 96 and c < 123\n result += (((96 - c) & (c - 123)) >>> 8) & (-INVALID_BYTE + c - 97 + 26);\n\n return result;\n }\n\n private _getPaddingLength(s: string): number {\n let paddingLength = 0;\n if (this._paddingCharacter) {\n for (let i = s.length - 1; i >= 0; i--) {\n if (s[i] !== this._paddingCharacter) {\n break;\n }\n paddingLength++;\n }\n if (s.length < 4 || paddingLength > 2) {\n throw new Error(\"Base64Coder: incorrect padding\");\n }\n }\n return paddingLength;\n }\n\n}\n\nconst stdCoder = new Coder();\n\nexport function encode(data: Uint8Array): string {\n return stdCoder.encode(data);\n}\n\nexport function decode(s: string): Uint8Array {\n return stdCoder.decode(s);\n}\n\n/**\n * Implements URL-safe Base64 encoding.\n * (Same as Base64, but '+' is replaced with '-', and '/' with '_').\n *\n * Operates in constant time.\n */\nexport class URLSafeCoder extends Coder {\n // URL-safe encoding have the following encoded/decoded ranges:\n //\n // ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 0123456789 - _\n // Index: 0 - 25 26 - 51 52 - 61 62 63\n // ASCII: 65 - 90 97 - 122 48 - 57 45 95\n //\n\n protected _encodeByte(b: number): string {\n let result = b;\n // b >= 0\n result += 65;\n // b > 25\n result += ((25 - b) >>> 8) & ((0 - 65) - 26 + 97);\n // b > 51\n result += ((51 - b) >>> 8) & ((26 - 97) - 52 + 48);\n // b > 61\n result += ((61 - b) >>> 8) & ((52 - 48) - 62 + 45);\n // b > 62\n result += ((62 - b) >>> 8) & ((62 - 45) - 63 + 95);\n\n return String.fromCharCode(result);\n }\n\n protected _decodeChar(c: number): number {\n let result = INVALID_BYTE;\n\n // c == 45 (c > 44 and c < 46)\n result += (((44 - c) & (c - 46)) >>> 8) & (-INVALID_BYTE + c - 45 + 62);\n // c == 95 (c > 94 and c < 96)\n result += (((94 - c) & (c - 96)) >>> 8) & (-INVALID_BYTE + c - 95 + 63);\n // c > 47 and c < 58\n result += (((47 - c) & (c - 58)) >>> 8) & (-INVALID_BYTE + c - 48 + 52);\n // c > 64 and c < 91\n result += (((64 - c) & (c - 91)) >>> 8) & (-INVALID_BYTE + c - 65 + 0);\n // c > 96 and c < 123\n result += (((96 - c) & (c - 123)) >>> 8) & (-INVALID_BYTE + c - 97 + 26);\n\n return result;\n }\n}\n\nconst urlSafeCoder = new URLSafeCoder();\n\nexport function encodeURLSafe(data: Uint8Array): string {\n return urlSafeCoder.encode(data);\n}\n\nexport function decodeURLSafe(s: string): Uint8Array {\n return urlSafeCoder.decode(s);\n}\n\n\nexport const encodedLength = (length: number) =>\n stdCoder.encodedLength(length);\n\nexport const maxDecodedLength = (length: number) =>\n stdCoder.maxDecodedLength(length);\n\nexport const decodedLength = (s: string) =>\n stdCoder.decodedLength(s);\n","// Copyright (C) 2016 Dmitry Chestnykh\n// MIT License. See LICENSE file for details.\n\n/**\n * Package utf8 implements UTF-8 encoding and decoding.\n */\n\nconst INVALID_UTF16 = \"utf8: invalid string\";\nconst INVALID_UTF8 = \"utf8: invalid source encoding\";\n\n/**\n * Encodes the given string into UTF-8 byte array.\n * Throws if the source string has invalid UTF-16 encoding.\n */\nexport function encode(s: string): Uint8Array {\n // Calculate result length and allocate output array.\n // encodedLength() also validates string and throws errors,\n // so we don't need repeat validation here.\n const arr = new Uint8Array(encodedLength(s));\n\n let pos = 0;\n for (let i = 0; i < s.length; i++) {\n let c = s.charCodeAt(i);\n if (c < 0x80) {\n arr[pos++] = c;\n } else if (c < 0x800) {\n arr[pos++] = 0xc0 | c >> 6;\n arr[pos++] = 0x80 | c & 0x3f;\n } else if (c < 0xd800) {\n arr[pos++] = 0xe0 | c >> 12;\n arr[pos++] = 0x80 | (c >> 6) & 0x3f;\n arr[pos++] = 0x80 | c & 0x3f;\n } else {\n i++; // get one more character\n c = (c & 0x3ff) << 10;\n c |= s.charCodeAt(i) & 0x3ff;\n c += 0x10000;\n\n arr[pos++] = 0xf0 | c >> 18;\n arr[pos++] = 0x80 | (c >> 12) & 0x3f;\n arr[pos++] = 0x80 | (c >> 6) & 0x3f;\n arr[pos++] = 0x80 | c & 0x3f;\n }\n }\n return arr;\n}\n\n/**\n * Returns the number of bytes required to encode the given string into UTF-8.\n * Throws if the source string has invalid UTF-16 encoding.\n */\nexport function encodedLength(s: string): number {\n let result = 0;\n for (let i = 0; i < s.length; i++) {\n const c = s.charCodeAt(i);\n if (c < 0x80) {\n result += 1;\n } else if (c < 0x800) {\n result += 2;\n } else if (c < 0xd800) {\n result += 3;\n } else if (c <= 0xdfff) {\n if (i >= s.length - 1) {\n throw new Error(INVALID_UTF16);\n }\n i++; // \"eat\" next character\n result += 4;\n } else {\n throw new Error(INVALID_UTF16);\n }\n }\n return result;\n}\n\n/**\n * Decodes the given byte array from UTF-8 into a string.\n * Throws if encoding is invalid.\n */\nexport function decode(arr: Uint8Array): string {\n const chars: string[] = [];\n for (let i = 0; i < arr.length; i++) {\n let b = arr[i];\n\n if (b & 0x80) {\n let min;\n if (b < 0xe0) {\n // Need 1 more byte.\n if (i >= arr.length) {\n throw new Error(INVALID_UTF8);\n }\n const n1 = arr[++i];\n if ((n1 & 0xc0) !== 0x80) {\n throw new Error(INVALID_UTF8);\n }\n b = (b & 0x1f) << 6 | (n1 & 0x3f);\n min = 0x80;\n } else if (b < 0xf0) {\n // Need 2 more bytes.\n if (i >= arr.length - 1) {\n throw new Error(INVALID_UTF8);\n }\n const n1 = arr[++i];\n const n2 = arr[++i];\n if ((n1 & 0xc0) !== 0x80 || (n2 & 0xc0) !== 0x80) {\n throw new Error(INVALID_UTF8);\n }\n b = (b & 0x0f) << 12 | (n1 & 0x3f) << 6 | (n2 & 0x3f);\n min = 0x800;\n } else if (b < 0xf8) {\n // Need 3 more bytes.\n if (i >= arr.length - 2) {\n throw new Error(INVALID_UTF8);\n }\n const n1 = arr[++i];\n const n2 = arr[++i];\n const n3 = arr[++i];\n if ((n1 & 0xc0) !== 0x80 || (n2 & 0xc0) !== 0x80 || (n3 & 0xc0) !== 0x80) {\n throw new Error(INVALID_UTF8);\n }\n b = (b & 0x0f) << 18 | (n1 & 0x3f) << 12 | (n2 & 0x3f) << 6 | (n3 & 0x3f);\n min = 0x10000;\n } else {\n throw new Error(INVALID_UTF8);\n }\n\n if (b < min || (b >= 0xd800 && b <= 0xdfff)) {\n throw new Error(INVALID_UTF8);\n }\n\n if (b >= 0x10000) {\n // Surrogate pair.\n if (b > 0x10ffff) {\n throw new Error(INVALID_UTF8);\n }\n b -= 0x10000;\n chars.push(String.fromCharCode(0xd800 | (b >> 10)));\n b = 0xdc00 | (b & 0x3ff);\n }\n }\n\n chars.push(String.fromCharCode(b));\n }\n return chars.join(\"\");\n}\n","(function(nacl) {\n'use strict';\n\n// Ported in 2014 by Dmitry Chestnykh and Devi Mandiri.\n// Public domain.\n//\n// Implementation derived from TweetNaCl version 20140427.\n// See for details: http://tweetnacl.cr.yp.to/\n\nvar gf = function(init) {\n var i, r = new Float64Array(16);\n if (init) for (i = 0; i < init.length; i++) r[i] = init[i];\n return r;\n};\n\n// Pluggable, initialized in high-level API below.\nvar randombytes = function(/* x, n */) { throw new Error('no PRNG'); };\n\nvar _0 = new Uint8Array(16);\nvar _9 = new Uint8Array(32); _9[0] = 9;\n\nvar gf0 = gf(),\n gf1 = gf([1]),\n _121665 = gf([0xdb41, 1]),\n D = gf([0x78a3, 0x1359, 0x4dca, 0x75eb, 0xd8ab, 0x4141, 0x0a4d, 0x0070, 0xe898, 0x7779, 0x4079, 0x8cc7, 0xfe73, 0x2b6f, 0x6cee, 0x5203]),\n D2 = gf([0xf159, 0x26b2, 0x9b94, 0xebd6, 0xb156, 0x8283, 0x149a, 0x00e0, 0xd130, 0xeef3, 0x80f2, 0x198e, 0xfce7, 0x56df, 0xd9dc, 0x2406]),\n X = gf([0xd51a, 0x8f25, 0x2d60, 0xc956, 0xa7b2, 0x9525, 0xc760, 0x692c, 0xdc5c, 0xfdd6, 0xe231, 0xc0a4, 0x53fe, 0xcd6e, 0x36d3, 0x2169]),\n Y = gf([0x6658, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666]),\n I = gf([0xa0b0, 0x4a0e, 0x1b27, 0xc4ee, 0xe478, 0xad2f, 0x1806, 0x2f43, 0xd7a7, 0x3dfb, 0x0099, 0x2b4d, 0xdf0b, 0x4fc1, 0x2480, 0x2b83]);\n\nfunction ts64(x, i, h, l) {\n x[i] = (h >> 24) & 0xff;\n x[i+1] = (h >> 16) & 0xff;\n x[i+2] = (h >> 8) & 0xff;\n x[i+3] = h & 0xff;\n x[i+4] = (l >> 24) & 0xff;\n x[i+5] = (l >> 16) & 0xff;\n x[i+6] = (l >> 8) & 0xff;\n x[i+7] = l & 0xff;\n}\n\nfunction vn(x, xi, y, yi, n) {\n var i,d = 0;\n for (i = 0; i < n; i++) d |= x[xi+i]^y[yi+i];\n return (1 & ((d - 1) >>> 8)) - 1;\n}\n\nfunction crypto_verify_16(x, xi, y, yi) {\n return vn(x,xi,y,yi,16);\n}\n\nfunction crypto_verify_32(x, xi, y, yi) {\n return vn(x,xi,y,yi,32);\n}\n\nfunction core_salsa20(o, p, k, c) {\n var j0 = c[ 0] & 0xff | (c[ 1] & 0xff)<<8 | (c[ 2] & 0xff)<<16 | (c[ 3] & 0xff)<<24,\n j1 = k[ 0] & 0xff | (k[ 1] & 0xff)<<8 | (k[ 2] & 0xff)<<16 | (k[ 3] & 0xff)<<24,\n j2 = k[ 4] & 0xff | (k[ 5] & 0xff)<<8 | (k[ 6] & 0xff)<<16 | (k[ 7] & 0xff)<<24,\n j3 = k[ 8] & 0xff | (k[ 9] & 0xff)<<8 | (k[10] & 0xff)<<16 | (k[11] & 0xff)<<24,\n j4 = k[12] & 0xff | (k[13] & 0xff)<<8 | (k[14] & 0xff)<<16 | (k[15] & 0xff)<<24,\n j5 = c[ 4] & 0xff | (c[ 5] & 0xff)<<8 | (c[ 6] & 0xff)<<16 | (c[ 7] & 0xff)<<24,\n j6 = p[ 0] & 0xff | (p[ 1] & 0xff)<<8 | (p[ 2] & 0xff)<<16 | (p[ 3] & 0xff)<<24,\n j7 = p[ 4] & 0xff | (p[ 5] & 0xff)<<8 | (p[ 6] & 0xff)<<16 | (p[ 7] & 0xff)<<24,\n j8 = p[ 8] & 0xff | (p[ 9] & 0xff)<<8 | (p[10] & 0xff)<<16 | (p[11] & 0xff)<<24,\n j9 = p[12] & 0xff | (p[13] & 0xff)<<8 | (p[14] & 0xff)<<16 | (p[15] & 0xff)<<24,\n j10 = c[ 8] & 0xff | (c[ 9] & 0xff)<<8 | (c[10] & 0xff)<<16 | (c[11] & 0xff)<<24,\n j11 = k[16] & 0xff | (k[17] & 0xff)<<8 | (k[18] & 0xff)<<16 | (k[19] & 0xff)<<24,\n j12 = k[20] & 0xff | (k[21] & 0xff)<<8 | (k[22] & 0xff)<<16 | (k[23] & 0xff)<<24,\n j13 = k[24] & 0xff | (k[25] & 0xff)<<8 | (k[26] & 0xff)<<16 | (k[27] & 0xff)<<24,\n j14 = k[28] & 0xff | (k[29] & 0xff)<<8 | (k[30] & 0xff)<<16 | (k[31] & 0xff)<<24,\n j15 = c[12] & 0xff | (c[13] & 0xff)<<8 | (c[14] & 0xff)<<16 | (c[15] & 0xff)<<24;\n\n var x0 = j0, x1 = j1, x2 = j2, x3 = j3, x4 = j4, x5 = j5, x6 = j6, x7 = j7,\n x8 = j8, x9 = j9, x10 = j10, x11 = j11, x12 = j12, x13 = j13, x14 = j14,\n x15 = j15, u;\n\n for (var i = 0; i < 20; i += 2) {\n u = x0 + x12 | 0;\n x4 ^= u<<7 | u>>>(32-7);\n u = x4 + x0 | 0;\n x8 ^= u<<9 | u>>>(32-9);\n u = x8 + x4 | 0;\n x12 ^= u<<13 | u>>>(32-13);\n u = x12 + x8 | 0;\n x0 ^= u<<18 | u>>>(32-18);\n\n u = x5 + x1 | 0;\n x9 ^= u<<7 | u>>>(32-7);\n u = x9 + x5 | 0;\n x13 ^= u<<9 | u>>>(32-9);\n u = x13 + x9 | 0;\n x1 ^= u<<13 | u>>>(32-13);\n u = x1 + x13 | 0;\n x5 ^= u<<18 | u>>>(32-18);\n\n u = x10 + x6 | 0;\n x14 ^= u<<7 | u>>>(32-7);\n u = x14 + x10 | 0;\n x2 ^= u<<9 | u>>>(32-9);\n u = x2 + x14 | 0;\n x6 ^= u<<13 | u>>>(32-13);\n u = x6 + x2 | 0;\n x10 ^= u<<18 | u>>>(32-18);\n\n u = x15 + x11 | 0;\n x3 ^= u<<7 | u>>>(32-7);\n u = x3 + x15 | 0;\n x7 ^= u<<9 | u>>>(32-9);\n u = x7 + x3 | 0;\n x11 ^= u<<13 | u>>>(32-13);\n u = x11 + x7 | 0;\n x15 ^= u<<18 | u>>>(32-18);\n\n u = x0 + x3 | 0;\n x1 ^= u<<7 | u>>>(32-7);\n u = x1 + x0 | 0;\n x2 ^= u<<9 | u>>>(32-9);\n u = x2 + x1 | 0;\n x3 ^= u<<13 | u>>>(32-13);\n u = x3 + x2 | 0;\n x0 ^= u<<18 | u>>>(32-18);\n\n u = x5 + x4 | 0;\n x6 ^= u<<7 | u>>>(32-7);\n u = x6 + x5 | 0;\n x7 ^= u<<9 | u>>>(32-9);\n u = x7 + x6 | 0;\n x4 ^= u<<13 | u>>>(32-13);\n u = x4 + x7 | 0;\n x5 ^= u<<18 | u>>>(32-18);\n\n u = x10 + x9 | 0;\n x11 ^= u<<7 | u>>>(32-7);\n u = x11 + x10 | 0;\n x8 ^= u<<9 | u>>>(32-9);\n u = x8 + x11 | 0;\n x9 ^= u<<13 | u>>>(32-13);\n u = x9 + x8 | 0;\n x10 ^= u<<18 | u>>>(32-18);\n\n u = x15 + x14 | 0;\n x12 ^= u<<7 | u>>>(32-7);\n u = x12 + x15 | 0;\n x13 ^= u<<9 | u>>>(32-9);\n u = x13 + x12 | 0;\n x14 ^= u<<13 | u>>>(32-13);\n u = x14 + x13 | 0;\n x15 ^= u<<18 | u>>>(32-18);\n }\n x0 = x0 + j0 | 0;\n x1 = x1 + j1 | 0;\n x2 = x2 + j2 | 0;\n x3 = x3 + j3 | 0;\n x4 = x4 + j4 | 0;\n x5 = x5 + j5 | 0;\n x6 = x6 + j6 | 0;\n x7 = x7 + j7 | 0;\n x8 = x8 + j8 | 0;\n x9 = x9 + j9 | 0;\n x10 = x10 + j10 | 0;\n x11 = x11 + j11 | 0;\n x12 = x12 + j12 | 0;\n x13 = x13 + j13 | 0;\n x14 = x14 + j14 | 0;\n x15 = x15 + j15 | 0;\n\n o[ 0] = x0 >>> 0 & 0xff;\n o[ 1] = x0 >>> 8 & 0xff;\n o[ 2] = x0 >>> 16 & 0xff;\n o[ 3] = x0 >>> 24 & 0xff;\n\n o[ 4] = x1 >>> 0 & 0xff;\n o[ 5] = x1 >>> 8 & 0xff;\n o[ 6] = x1 >>> 16 & 0xff;\n o[ 7] = x1 >>> 24 & 0xff;\n\n o[ 8] = x2 >>> 0 & 0xff;\n o[ 9] = x2 >>> 8 & 0xff;\n o[10] = x2 >>> 16 & 0xff;\n o[11] = x2 >>> 24 & 0xff;\n\n o[12] = x3 >>> 0 & 0xff;\n o[13] = x3 >>> 8 & 0xff;\n o[14] = x3 >>> 16 & 0xff;\n o[15] = x3 >>> 24 & 0xff;\n\n o[16] = x4 >>> 0 & 0xff;\n o[17] = x4 >>> 8 & 0xff;\n o[18] = x4 >>> 16 & 0xff;\n o[19] = x4 >>> 24 & 0xff;\n\n o[20] = x5 >>> 0 & 0xff;\n o[21] = x5 >>> 8 & 0xff;\n o[22] = x5 >>> 16 & 0xff;\n o[23] = x5 >>> 24 & 0xff;\n\n o[24] = x6 >>> 0 & 0xff;\n o[25] = x6 >>> 8 & 0xff;\n o[26] = x6 >>> 16 & 0xff;\n o[27] = x6 >>> 24 & 0xff;\n\n o[28] = x7 >>> 0 & 0xff;\n o[29] = x7 >>> 8 & 0xff;\n o[30] = x7 >>> 16 & 0xff;\n o[31] = x7 >>> 24 & 0xff;\n\n o[32] = x8 >>> 0 & 0xff;\n o[33] = x8 >>> 8 & 0xff;\n o[34] = x8 >>> 16 & 0xff;\n o[35] = x8 >>> 24 & 0xff;\n\n o[36] = x9 >>> 0 & 0xff;\n o[37] = x9 >>> 8 & 0xff;\n o[38] = x9 >>> 16 & 0xff;\n o[39] = x9 >>> 24 & 0xff;\n\n o[40] = x10 >>> 0 & 0xff;\n o[41] = x10 >>> 8 & 0xff;\n o[42] = x10 >>> 16 & 0xff;\n o[43] = x10 >>> 24 & 0xff;\n\n o[44] = x11 >>> 0 & 0xff;\n o[45] = x11 >>> 8 & 0xff;\n o[46] = x11 >>> 16 & 0xff;\n o[47] = x11 >>> 24 & 0xff;\n\n o[48] = x12 >>> 0 & 0xff;\n o[49] = x12 >>> 8 & 0xff;\n o[50] = x12 >>> 16 & 0xff;\n o[51] = x12 >>> 24 & 0xff;\n\n o[52] = x13 >>> 0 & 0xff;\n o[53] = x13 >>> 8 & 0xff;\n o[54] = x13 >>> 16 & 0xff;\n o[55] = x13 >>> 24 & 0xff;\n\n o[56] = x14 >>> 0 & 0xff;\n o[57] = x14 >>> 8 & 0xff;\n o[58] = x14 >>> 16 & 0xff;\n o[59] = x14 >>> 24 & 0xff;\n\n o[60] = x15 >>> 0 & 0xff;\n o[61] = x15 >>> 8 & 0xff;\n o[62] = x15 >>> 16 & 0xff;\n o[63] = x15 >>> 24 & 0xff;\n}\n\nfunction core_hsalsa20(o,p,k,c) {\n var j0 = c[ 0] & 0xff | (c[ 1] & 0xff)<<8 | (c[ 2] & 0xff)<<16 | (c[ 3] & 0xff)<<24,\n j1 = k[ 0] & 0xff | (k[ 1] & 0xff)<<8 | (k[ 2] & 0xff)<<16 | (k[ 3] & 0xff)<<24,\n j2 = k[ 4] & 0xff | (k[ 5] & 0xff)<<8 | (k[ 6] & 0xff)<<16 | (k[ 7] & 0xff)<<24,\n j3 = k[ 8] & 0xff | (k[ 9] & 0xff)<<8 | (k[10] & 0xff)<<16 | (k[11] & 0xff)<<24,\n j4 = k[12] & 0xff | (k[13] & 0xff)<<8 | (k[14] & 0xff)<<16 | (k[15] & 0xff)<<24,\n j5 = c[ 4] & 0xff | (c[ 5] & 0xff)<<8 | (c[ 6] & 0xff)<<16 | (c[ 7] & 0xff)<<24,\n j6 = p[ 0] & 0xff | (p[ 1] & 0xff)<<8 | (p[ 2] & 0xff)<<16 | (p[ 3] & 0xff)<<24,\n j7 = p[ 4] & 0xff | (p[ 5] & 0xff)<<8 | (p[ 6] & 0xff)<<16 | (p[ 7] & 0xff)<<24,\n j8 = p[ 8] & 0xff | (p[ 9] & 0xff)<<8 | (p[10] & 0xff)<<16 | (p[11] & 0xff)<<24,\n j9 = p[12] & 0xff | (p[13] & 0xff)<<8 | (p[14] & 0xff)<<16 | (p[15] & 0xff)<<24,\n j10 = c[ 8] & 0xff | (c[ 9] & 0xff)<<8 | (c[10] & 0xff)<<16 | (c[11] & 0xff)<<24,\n j11 = k[16] & 0xff | (k[17] & 0xff)<<8 | (k[18] & 0xff)<<16 | (k[19] & 0xff)<<24,\n j12 = k[20] & 0xff | (k[21] & 0xff)<<8 | (k[22] & 0xff)<<16 | (k[23] & 0xff)<<24,\n j13 = k[24] & 0xff | (k[25] & 0xff)<<8 | (k[26] & 0xff)<<16 | (k[27] & 0xff)<<24,\n j14 = k[28] & 0xff | (k[29] & 0xff)<<8 | (k[30] & 0xff)<<16 | (k[31] & 0xff)<<24,\n j15 = c[12] & 0xff | (c[13] & 0xff)<<8 | (c[14] & 0xff)<<16 | (c[15] & 0xff)<<24;\n\n var x0 = j0, x1 = j1, x2 = j2, x3 = j3, x4 = j4, x5 = j5, x6 = j6, x7 = j7,\n x8 = j8, x9 = j9, x10 = j10, x11 = j11, x12 = j12, x13 = j13, x14 = j14,\n x15 = j15, u;\n\n for (var i = 0; i < 20; i += 2) {\n u = x0 + x12 | 0;\n x4 ^= u<<7 | u>>>(32-7);\n u = x4 + x0 | 0;\n x8 ^= u<<9 | u>>>(32-9);\n u = x8 + x4 | 0;\n x12 ^= u<<13 | u>>>(32-13);\n u = x12 + x8 | 0;\n x0 ^= u<<18 | u>>>(32-18);\n\n u = x5 + x1 | 0;\n x9 ^= u<<7 | u>>>(32-7);\n u = x9 + x5 | 0;\n x13 ^= u<<9 | u>>>(32-9);\n u = x13 + x9 | 0;\n x1 ^= u<<13 | u>>>(32-13);\n u = x1 + x13 | 0;\n x5 ^= u<<18 | u>>>(32-18);\n\n u = x10 + x6 | 0;\n x14 ^= u<<7 | u>>>(32-7);\n u = x14 + x10 | 0;\n x2 ^= u<<9 | u>>>(32-9);\n u = x2 + x14 | 0;\n x6 ^= u<<13 | u>>>(32-13);\n u = x6 + x2 | 0;\n x10 ^= u<<18 | u>>>(32-18);\n\n u = x15 + x11 | 0;\n x3 ^= u<<7 | u>>>(32-7);\n u = x3 + x15 | 0;\n x7 ^= u<<9 | u>>>(32-9);\n u = x7 + x3 | 0;\n x11 ^= u<<13 | u>>>(32-13);\n u = x11 + x7 | 0;\n x15 ^= u<<18 | u>>>(32-18);\n\n u = x0 + x3 | 0;\n x1 ^= u<<7 | u>>>(32-7);\n u = x1 + x0 | 0;\n x2 ^= u<<9 | u>>>(32-9);\n u = x2 + x1 | 0;\n x3 ^= u<<13 | u>>>(32-13);\n u = x3 + x2 | 0;\n x0 ^= u<<18 | u>>>(32-18);\n\n u = x5 + x4 | 0;\n x6 ^= u<<7 | u>>>(32-7);\n u = x6 + x5 | 0;\n x7 ^= u<<9 | u>>>(32-9);\n u = x7 + x6 | 0;\n x4 ^= u<<13 | u>>>(32-13);\n u = x4 + x7 | 0;\n x5 ^= u<<18 | u>>>(32-18);\n\n u = x10 + x9 | 0;\n x11 ^= u<<7 | u>>>(32-7);\n u = x11 + x10 | 0;\n x8 ^= u<<9 | u>>>(32-9);\n u = x8 + x11 | 0;\n x9 ^= u<<13 | u>>>(32-13);\n u = x9 + x8 | 0;\n x10 ^= u<<18 | u>>>(32-18);\n\n u = x15 + x14 | 0;\n x12 ^= u<<7 | u>>>(32-7);\n u = x12 + x15 | 0;\n x13 ^= u<<9 | u>>>(32-9);\n u = x13 + x12 | 0;\n x14 ^= u<<13 | u>>>(32-13);\n u = x14 + x13 | 0;\n x15 ^= u<<18 | u>>>(32-18);\n }\n\n o[ 0] = x0 >>> 0 & 0xff;\n o[ 1] = x0 >>> 8 & 0xff;\n o[ 2] = x0 >>> 16 & 0xff;\n o[ 3] = x0 >>> 24 & 0xff;\n\n o[ 4] = x5 >>> 0 & 0xff;\n o[ 5] = x5 >>> 8 & 0xff;\n o[ 6] = x5 >>> 16 & 0xff;\n o[ 7] = x5 >>> 24 & 0xff;\n\n o[ 8] = x10 >>> 0 & 0xff;\n o[ 9] = x10 >>> 8 & 0xff;\n o[10] = x10 >>> 16 & 0xff;\n o[11] = x10 >>> 24 & 0xff;\n\n o[12] = x15 >>> 0 & 0xff;\n o[13] = x15 >>> 8 & 0xff;\n o[14] = x15 >>> 16 & 0xff;\n o[15] = x15 >>> 24 & 0xff;\n\n o[16] = x6 >>> 0 & 0xff;\n o[17] = x6 >>> 8 & 0xff;\n o[18] = x6 >>> 16 & 0xff;\n o[19] = x6 >>> 24 & 0xff;\n\n o[20] = x7 >>> 0 & 0xff;\n o[21] = x7 >>> 8 & 0xff;\n o[22] = x7 >>> 16 & 0xff;\n o[23] = x7 >>> 24 & 0xff;\n\n o[24] = x8 >>> 0 & 0xff;\n o[25] = x8 >>> 8 & 0xff;\n o[26] = x8 >>> 16 & 0xff;\n o[27] = x8 >>> 24 & 0xff;\n\n o[28] = x9 >>> 0 & 0xff;\n o[29] = x9 >>> 8 & 0xff;\n o[30] = x9 >>> 16 & 0xff;\n o[31] = x9 >>> 24 & 0xff;\n}\n\nfunction crypto_core_salsa20(out,inp,k,c) {\n core_salsa20(out,inp,k,c);\n}\n\nfunction crypto_core_hsalsa20(out,inp,k,c) {\n core_hsalsa20(out,inp,k,c);\n}\n\nvar sigma = new Uint8Array([101, 120, 112, 97, 110, 100, 32, 51, 50, 45, 98, 121, 116, 101, 32, 107]);\n // \"expand 32-byte k\"\n\nfunction crypto_stream_salsa20_xor(c,cpos,m,mpos,b,n,k) {\n var z = new Uint8Array(16), x = new Uint8Array(64);\n var u, i;\n for (i = 0; i < 16; i++) z[i] = 0;\n for (i = 0; i < 8; i++) z[i] = n[i];\n while (b >= 64) {\n crypto_core_salsa20(x,z,k,sigma);\n for (i = 0; i < 64; i++) c[cpos+i] = m[mpos+i] ^ x[i];\n u = 1;\n for (i = 8; i < 16; i++) {\n u = u + (z[i] & 0xff) | 0;\n z[i] = u & 0xff;\n u >>>= 8;\n }\n b -= 64;\n cpos += 64;\n mpos += 64;\n }\n if (b > 0) {\n crypto_core_salsa20(x,z,k,sigma);\n for (i = 0; i < b; i++) c[cpos+i] = m[mpos+i] ^ x[i];\n }\n return 0;\n}\n\nfunction crypto_stream_salsa20(c,cpos,b,n,k) {\n var z = new Uint8Array(16), x = new Uint8Array(64);\n var u, i;\n for (i = 0; i < 16; i++) z[i] = 0;\n for (i = 0; i < 8; i++) z[i] = n[i];\n while (b >= 64) {\n crypto_core_salsa20(x,z,k,sigma);\n for (i = 0; i < 64; i++) c[cpos+i] = x[i];\n u = 1;\n for (i = 8; i < 16; i++) {\n u = u + (z[i] & 0xff) | 0;\n z[i] = u & 0xff;\n u >>>= 8;\n }\n b -= 64;\n cpos += 64;\n }\n if (b > 0) {\n crypto_core_salsa20(x,z,k,sigma);\n for (i = 0; i < b; i++) c[cpos+i] = x[i];\n }\n return 0;\n}\n\nfunction crypto_stream(c,cpos,d,n,k) {\n var s = new Uint8Array(32);\n crypto_core_hsalsa20(s,n,k,sigma);\n var sn = new Uint8Array(8);\n for (var i = 0; i < 8; i++) sn[i] = n[i+16];\n return crypto_stream_salsa20(c,cpos,d,sn,s);\n}\n\nfunction crypto_stream_xor(c,cpos,m,mpos,d,n,k) {\n var s = new Uint8Array(32);\n crypto_core_hsalsa20(s,n,k,sigma);\n var sn = new Uint8Array(8);\n for (var i = 0; i < 8; i++) sn[i] = n[i+16];\n return crypto_stream_salsa20_xor(c,cpos,m,mpos,d,sn,s);\n}\n\n/*\n* Port of Andrew Moon's Poly1305-donna-16. Public domain.\n* https://github.com/floodyberry/poly1305-donna\n*/\n\nvar poly1305 = function(key) {\n this.buffer = new Uint8Array(16);\n this.r = new Uint16Array(10);\n this.h = new Uint16Array(10);\n this.pad = new Uint16Array(8);\n this.leftover = 0;\n this.fin = 0;\n\n var t0, t1, t2, t3, t4, t5, t6, t7;\n\n t0 = key[ 0] & 0xff | (key[ 1] & 0xff) << 8; this.r[0] = ( t0 ) & 0x1fff;\n t1 = key[ 2] & 0xff | (key[ 3] & 0xff) << 8; this.r[1] = ((t0 >>> 13) | (t1 << 3)) & 0x1fff;\n t2 = key[ 4] & 0xff | (key[ 5] & 0xff) << 8; this.r[2] = ((t1 >>> 10) | (t2 << 6)) & 0x1f03;\n t3 = key[ 6] & 0xff | (key[ 7] & 0xff) << 8; this.r[3] = ((t2 >>> 7) | (t3 << 9)) & 0x1fff;\n t4 = key[ 8] & 0xff | (key[ 9] & 0xff) << 8; this.r[4] = ((t3 >>> 4) | (t4 << 12)) & 0x00ff;\n this.r[5] = ((t4 >>> 1)) & 0x1ffe;\n t5 = key[10] & 0xff | (key[11] & 0xff) << 8; this.r[6] = ((t4 >>> 14) | (t5 << 2)) & 0x1fff;\n t6 = key[12] & 0xff | (key[13] & 0xff) << 8; this.r[7] = ((t5 >>> 11) | (t6 << 5)) & 0x1f81;\n t7 = key[14] & 0xff | (key[15] & 0xff) << 8; this.r[8] = ((t6 >>> 8) | (t7 << 8)) & 0x1fff;\n this.r[9] = ((t7 >>> 5)) & 0x007f;\n\n this.pad[0] = key[16] & 0xff | (key[17] & 0xff) << 8;\n this.pad[1] = key[18] & 0xff | (key[19] & 0xff) << 8;\n this.pad[2] = key[20] & 0xff | (key[21] & 0xff) << 8;\n this.pad[3] = key[22] & 0xff | (key[23] & 0xff) << 8;\n this.pad[4] = key[24] & 0xff | (key[25] & 0xff) << 8;\n this.pad[5] = key[26] & 0xff | (key[27] & 0xff) << 8;\n this.pad[6] = key[28] & 0xff | (key[29] & 0xff) << 8;\n this.pad[7] = key[30] & 0xff | (key[31] & 0xff) << 8;\n};\n\npoly1305.prototype.blocks = function(m, mpos, bytes) {\n var hibit = this.fin ? 0 : (1 << 11);\n var t0, t1, t2, t3, t4, t5, t6, t7, c;\n var d0, d1, d2, d3, d4, d5, d6, d7, d8, d9;\n\n var h0 = this.h[0],\n h1 = this.h[1],\n h2 = this.h[2],\n h3 = this.h[3],\n h4 = this.h[4],\n h5 = this.h[5],\n h6 = this.h[6],\n h7 = this.h[7],\n h8 = this.h[8],\n h9 = this.h[9];\n\n var r0 = this.r[0],\n r1 = this.r[1],\n r2 = this.r[2],\n r3 = this.r[3],\n r4 = this.r[4],\n r5 = this.r[5],\n r6 = this.r[6],\n r7 = this.r[7],\n r8 = this.r[8],\n r9 = this.r[9];\n\n while (bytes >= 16) {\n t0 = m[mpos+ 0] & 0xff | (m[mpos+ 1] & 0xff) << 8; h0 += ( t0 ) & 0x1fff;\n t1 = m[mpos+ 2] & 0xff | (m[mpos+ 3] & 0xff) << 8; h1 += ((t0 >>> 13) | (t1 << 3)) & 0x1fff;\n t2 = m[mpos+ 4] & 0xff | (m[mpos+ 5] & 0xff) << 8; h2 += ((t1 >>> 10) | (t2 << 6)) & 0x1fff;\n t3 = m[mpos+ 6] & 0xff | (m[mpos+ 7] & 0xff) << 8; h3 += ((t2 >>> 7) | (t3 << 9)) & 0x1fff;\n t4 = m[mpos+ 8] & 0xff | (m[mpos+ 9] & 0xff) << 8; h4 += ((t3 >>> 4) | (t4 << 12)) & 0x1fff;\n h5 += ((t4 >>> 1)) & 0x1fff;\n t5 = m[mpos+10] & 0xff | (m[mpos+11] & 0xff) << 8; h6 += ((t4 >>> 14) | (t5 << 2)) & 0x1fff;\n t6 = m[mpos+12] & 0xff | (m[mpos+13] & 0xff) << 8; h7 += ((t5 >>> 11) | (t6 << 5)) & 0x1fff;\n t7 = m[mpos+14] & 0xff | (m[mpos+15] & 0xff) << 8; h8 += ((t6 >>> 8) | (t7 << 8)) & 0x1fff;\n h9 += ((t7 >>> 5)) | hibit;\n\n c = 0;\n\n d0 = c;\n d0 += h0 * r0;\n d0 += h1 * (5 * r9);\n d0 += h2 * (5 * r8);\n d0 += h3 * (5 * r7);\n d0 += h4 * (5 * r6);\n c = (d0 >>> 13); d0 &= 0x1fff;\n d0 += h5 * (5 * r5);\n d0 += h6 * (5 * r4);\n d0 += h7 * (5 * r3);\n d0 += h8 * (5 * r2);\n d0 += h9 * (5 * r1);\n c += (d0 >>> 13); d0 &= 0x1fff;\n\n d1 = c;\n d1 += h0 * r1;\n d1 += h1 * r0;\n d1 += h2 * (5 * r9);\n d1 += h3 * (5 * r8);\n d1 += h4 * (5 * r7);\n c = (d1 >>> 13); d1 &= 0x1fff;\n d1 += h5 * (5 * r6);\n d1 += h6 * (5 * r5);\n d1 += h7 * (5 * r4);\n d1 += h8 * (5 * r3);\n d1 += h9 * (5 * r2);\n c += (d1 >>> 13); d1 &= 0x1fff;\n\n d2 = c;\n d2 += h0 * r2;\n d2 += h1 * r1;\n d2 += h2 * r0;\n d2 += h3 * (5 * r9);\n d2 += h4 * (5 * r8);\n c = (d2 >>> 13); d2 &= 0x1fff;\n d2 += h5 * (5 * r7);\n d2 += h6 * (5 * r6);\n d2 += h7 * (5 * r5);\n d2 += h8 * (5 * r4);\n d2 += h9 * (5 * r3);\n c += (d2 >>> 13); d2 &= 0x1fff;\n\n d3 = c;\n d3 += h0 * r3;\n d3 += h1 * r2;\n d3 += h2 * r1;\n d3 += h3 * r0;\n d3 += h4 * (5 * r9);\n c = (d3 >>> 13); d3 &= 0x1fff;\n d3 += h5 * (5 * r8);\n d3 += h6 * (5 * r7);\n d3 += h7 * (5 * r6);\n d3 += h8 * (5 * r5);\n d3 += h9 * (5 * r4);\n c += (d3 >>> 13); d3 &= 0x1fff;\n\n d4 = c;\n d4 += h0 * r4;\n d4 += h1 * r3;\n d4 += h2 * r2;\n d4 += h3 * r1;\n d4 += h4 * r0;\n c = (d4 >>> 13); d4 &= 0x1fff;\n d4 += h5 * (5 * r9);\n d4 += h6 * (5 * r8);\n d4 += h7 * (5 * r7);\n d4 += h8 * (5 * r6);\n d4 += h9 * (5 * r5);\n c += (d4 >>> 13); d4 &= 0x1fff;\n\n d5 = c;\n d5 += h0 * r5;\n d5 += h1 * r4;\n d5 += h2 * r3;\n d5 += h3 * r2;\n d5 += h4 * r1;\n c = (d5 >>> 13); d5 &= 0x1fff;\n d5 += h5 * r0;\n d5 += h6 * (5 * r9);\n d5 += h7 * (5 * r8);\n d5 += h8 * (5 * r7);\n d5 += h9 * (5 * r6);\n c += (d5 >>> 13); d5 &= 0x1fff;\n\n d6 = c;\n d6 += h0 * r6;\n d6 += h1 * r5;\n d6 += h2 * r4;\n d6 += h3 * r3;\n d6 += h4 * r2;\n c = (d6 >>> 13); d6 &= 0x1fff;\n d6 += h5 * r1;\n d6 += h6 * r0;\n d6 += h7 * (5 * r9);\n d6 += h8 * (5 * r8);\n d6 += h9 * (5 * r7);\n c += (d6 >>> 13); d6 &= 0x1fff;\n\n d7 = c;\n d7 += h0 * r7;\n d7 += h1 * r6;\n d7 += h2 * r5;\n d7 += h3 * r4;\n d7 += h4 * r3;\n c = (d7 >>> 13); d7 &= 0x1fff;\n d7 += h5 * r2;\n d7 += h6 * r1;\n d7 += h7 * r0;\n d7 += h8 * (5 * r9);\n d7 += h9 * (5 * r8);\n c += (d7 >>> 13); d7 &= 0x1fff;\n\n d8 = c;\n d8 += h0 * r8;\n d8 += h1 * r7;\n d8 += h2 * r6;\n d8 += h3 * r5;\n d8 += h4 * r4;\n c = (d8 >>> 13); d8 &= 0x1fff;\n d8 += h5 * r3;\n d8 += h6 * r2;\n d8 += h7 * r1;\n d8 += h8 * r0;\n d8 += h9 * (5 * r9);\n c += (d8 >>> 13); d8 &= 0x1fff;\n\n d9 = c;\n d9 += h0 * r9;\n d9 += h1 * r8;\n d9 += h2 * r7;\n d9 += h3 * r6;\n d9 += h4 * r5;\n c = (d9 >>> 13); d9 &= 0x1fff;\n d9 += h5 * r4;\n d9 += h6 * r3;\n d9 += h7 * r2;\n d9 += h8 * r1;\n d9 += h9 * r0;\n c += (d9 >>> 13); d9 &= 0x1fff;\n\n c = (((c << 2) + c)) | 0;\n c = (c + d0) | 0;\n d0 = c & 0x1fff;\n c = (c >>> 13);\n d1 += c;\n\n h0 = d0;\n h1 = d1;\n h2 = d2;\n h3 = d3;\n h4 = d4;\n h5 = d5;\n h6 = d6;\n h7 = d7;\n h8 = d8;\n h9 = d9;\n\n mpos += 16;\n bytes -= 16;\n }\n this.h[0] = h0;\n this.h[1] = h1;\n this.h[2] = h2;\n this.h[3] = h3;\n this.h[4] = h4;\n this.h[5] = h5;\n this.h[6] = h6;\n this.h[7] = h7;\n this.h[8] = h8;\n this.h[9] = h9;\n};\n\npoly1305.prototype.finish = function(mac, macpos) {\n var g = new Uint16Array(10);\n var c, mask, f, i;\n\n if (this.leftover) {\n i = this.leftover;\n this.buffer[i++] = 1;\n for (; i < 16; i++) this.buffer[i] = 0;\n this.fin = 1;\n this.blocks(this.buffer, 0, 16);\n }\n\n c = this.h[1] >>> 13;\n this.h[1] &= 0x1fff;\n for (i = 2; i < 10; i++) {\n this.h[i] += c;\n c = this.h[i] >>> 13;\n this.h[i] &= 0x1fff;\n }\n this.h[0] += (c * 5);\n c = this.h[0] >>> 13;\n this.h[0] &= 0x1fff;\n this.h[1] += c;\n c = this.h[1] >>> 13;\n this.h[1] &= 0x1fff;\n this.h[2] += c;\n\n g[0] = this.h[0] + 5;\n c = g[0] >>> 13;\n g[0] &= 0x1fff;\n for (i = 1; i < 10; i++) {\n g[i] = this.h[i] + c;\n c = g[i] >>> 13;\n g[i] &= 0x1fff;\n }\n g[9] -= (1 << 13);\n\n mask = (c ^ 1) - 1;\n for (i = 0; i < 10; i++) g[i] &= mask;\n mask = ~mask;\n for (i = 0; i < 10; i++) this.h[i] = (this.h[i] & mask) | g[i];\n\n this.h[0] = ((this.h[0] ) | (this.h[1] << 13) ) & 0xffff;\n this.h[1] = ((this.h[1] >>> 3) | (this.h[2] << 10) ) & 0xffff;\n this.h[2] = ((this.h[2] >>> 6) | (this.h[3] << 7) ) & 0xffff;\n this.h[3] = ((this.h[3] >>> 9) | (this.h[4] << 4) ) & 0xffff;\n this.h[4] = ((this.h[4] >>> 12) | (this.h[5] << 1) | (this.h[6] << 14)) & 0xffff;\n this.h[5] = ((this.h[6] >>> 2) | (this.h[7] << 11) ) & 0xffff;\n this.h[6] = ((this.h[7] >>> 5) | (this.h[8] << 8) ) & 0xffff;\n this.h[7] = ((this.h[8] >>> 8) | (this.h[9] << 5) ) & 0xffff;\n\n f = this.h[0] + this.pad[0];\n this.h[0] = f & 0xffff;\n for (i = 1; i < 8; i++) {\n f = (((this.h[i] + this.pad[i]) | 0) + (f >>> 16)) | 0;\n this.h[i] = f & 0xffff;\n }\n\n mac[macpos+ 0] = (this.h[0] >>> 0) & 0xff;\n mac[macpos+ 1] = (this.h[0] >>> 8) & 0xff;\n mac[macpos+ 2] = (this.h[1] >>> 0) & 0xff;\n mac[macpos+ 3] = (this.h[1] >>> 8) & 0xff;\n mac[macpos+ 4] = (this.h[2] >>> 0) & 0xff;\n mac[macpos+ 5] = (this.h[2] >>> 8) & 0xff;\n mac[macpos+ 6] = (this.h[3] >>> 0) & 0xff;\n mac[macpos+ 7] = (this.h[3] >>> 8) & 0xff;\n mac[macpos+ 8] = (this.h[4] >>> 0) & 0xff;\n mac[macpos+ 9] = (this.h[4] >>> 8) & 0xff;\n mac[macpos+10] = (this.h[5] >>> 0) & 0xff;\n mac[macpos+11] = (this.h[5] >>> 8) & 0xff;\n mac[macpos+12] = (this.h[6] >>> 0) & 0xff;\n mac[macpos+13] = (this.h[6] >>> 8) & 0xff;\n mac[macpos+14] = (this.h[7] >>> 0) & 0xff;\n mac[macpos+15] = (this.h[7] >>> 8) & 0xff;\n};\n\npoly1305.prototype.update = function(m, mpos, bytes) {\n var i, want;\n\n if (this.leftover) {\n want = (16 - this.leftover);\n if (want > bytes)\n want = bytes;\n for (i = 0; i < want; i++)\n this.buffer[this.leftover + i] = m[mpos+i];\n bytes -= want;\n mpos += want;\n this.leftover += want;\n if (this.leftover < 16)\n return;\n this.blocks(this.buffer, 0, 16);\n this.leftover = 0;\n }\n\n if (bytes >= 16) {\n want = bytes - (bytes % 16);\n this.blocks(m, mpos, want);\n mpos += want;\n bytes -= want;\n }\n\n if (bytes) {\n for (i = 0; i < bytes; i++)\n this.buffer[this.leftover + i] = m[mpos+i];\n this.leftover += bytes;\n }\n};\n\nfunction crypto_onetimeauth(out, outpos, m, mpos, n, k) {\n var s = new poly1305(k);\n s.update(m, mpos, n);\n s.finish(out, outpos);\n return 0;\n}\n\nfunction crypto_onetimeauth_verify(h, hpos, m, mpos, n, k) {\n var x = new Uint8Array(16);\n crypto_onetimeauth(x,0,m,mpos,n,k);\n return crypto_verify_16(h,hpos,x,0);\n}\n\nfunction crypto_secretbox(c,m,d,n,k) {\n var i;\n if (d < 32) return -1;\n crypto_stream_xor(c,0,m,0,d,n,k);\n crypto_onetimeauth(c, 16, c, 32, d - 32, c);\n for (i = 0; i < 16; i++) c[i] = 0;\n return 0;\n}\n\nfunction crypto_secretbox_open(m,c,d,n,k) {\n var i;\n var x = new Uint8Array(32);\n if (d < 32) return -1;\n crypto_stream(x,0,32,n,k);\n if (crypto_onetimeauth_verify(c, 16,c, 32,d - 32,x) !== 0) return -1;\n crypto_stream_xor(m,0,c,0,d,n,k);\n for (i = 0; i < 32; i++) m[i] = 0;\n return 0;\n}\n\nfunction set25519(r, a) {\n var i;\n for (i = 0; i < 16; i++) r[i] = a[i]|0;\n}\n\nfunction car25519(o) {\n var i, v, c = 1;\n for (i = 0; i < 16; i++) {\n v = o[i] + c + 65535;\n c = Math.floor(v / 65536);\n o[i] = v - c * 65536;\n }\n o[0] += c-1 + 37 * (c-1);\n}\n\nfunction sel25519(p, q, b) {\n var t, c = ~(b-1);\n for (var i = 0; i < 16; i++) {\n t = c & (p[i] ^ q[i]);\n p[i] ^= t;\n q[i] ^= t;\n }\n}\n\nfunction pack25519(o, n) {\n var i, j, b;\n var m = gf(), t = gf();\n for (i = 0; i < 16; i++) t[i] = n[i];\n car25519(t);\n car25519(t);\n car25519(t);\n for (j = 0; j < 2; j++) {\n m[0] = t[0] - 0xffed;\n for (i = 1; i < 15; i++) {\n m[i] = t[i] - 0xffff - ((m[i-1]>>16) & 1);\n m[i-1] &= 0xffff;\n }\n m[15] = t[15] - 0x7fff - ((m[14]>>16) & 1);\n b = (m[15]>>16) & 1;\n m[14] &= 0xffff;\n sel25519(t, m, 1-b);\n }\n for (i = 0; i < 16; i++) {\n o[2*i] = t[i] & 0xff;\n o[2*i+1] = t[i]>>8;\n }\n}\n\nfunction neq25519(a, b) {\n var c = new Uint8Array(32), d = new Uint8Array(32);\n pack25519(c, a);\n pack25519(d, b);\n return crypto_verify_32(c, 0, d, 0);\n}\n\nfunction par25519(a) {\n var d = new Uint8Array(32);\n pack25519(d, a);\n return d[0] & 1;\n}\n\nfunction unpack25519(o, n) {\n var i;\n for (i = 0; i < 16; i++) o[i] = n[2*i] + (n[2*i+1] << 8);\n o[15] &= 0x7fff;\n}\n\nfunction A(o, a, b) {\n for (var i = 0; i < 16; i++) o[i] = a[i] + b[i];\n}\n\nfunction Z(o, a, b) {\n for (var i = 0; i < 16; i++) o[i] = a[i] - b[i];\n}\n\nfunction M(o, a, b) {\n var v, c,\n t0 = 0, t1 = 0, t2 = 0, t3 = 0, t4 = 0, t5 = 0, t6 = 0, t7 = 0,\n t8 = 0, t9 = 0, t10 = 0, t11 = 0, t12 = 0, t13 = 0, t14 = 0, t15 = 0,\n t16 = 0, t17 = 0, t18 = 0, t19 = 0, t20 = 0, t21 = 0, t22 = 0, t23 = 0,\n t24 = 0, t25 = 0, t26 = 0, t27 = 0, t28 = 0, t29 = 0, t30 = 0,\n b0 = b[0],\n b1 = b[1],\n b2 = b[2],\n b3 = b[3],\n b4 = b[4],\n b5 = b[5],\n b6 = b[6],\n b7 = b[7],\n b8 = b[8],\n b9 = b[9],\n b10 = b[10],\n b11 = b[11],\n b12 = b[12],\n b13 = b[13],\n b14 = b[14],\n b15 = b[15];\n\n v = a[0];\n t0 += v * b0;\n t1 += v * b1;\n t2 += v * b2;\n t3 += v * b3;\n t4 += v * b4;\n t5 += v * b5;\n t6 += v * b6;\n t7 += v * b7;\n t8 += v * b8;\n t9 += v * b9;\n t10 += v * b10;\n t11 += v * b11;\n t12 += v * b12;\n t13 += v * b13;\n t14 += v * b14;\n t15 += v * b15;\n v = a[1];\n t1 += v * b0;\n t2 += v * b1;\n t3 += v * b2;\n t4 += v * b3;\n t5 += v * b4;\n t6 += v * b5;\n t7 += v * b6;\n t8 += v * b7;\n t9 += v * b8;\n t10 += v * b9;\n t11 += v * b10;\n t12 += v * b11;\n t13 += v * b12;\n t14 += v * b13;\n t15 += v * b14;\n t16 += v * b15;\n v = a[2];\n t2 += v * b0;\n t3 += v * b1;\n t4 += v * b2;\n t5 += v * b3;\n t6 += v * b4;\n t7 += v * b5;\n t8 += v * b6;\n t9 += v * b7;\n t10 += v * b8;\n t11 += v * b9;\n t12 += v * b10;\n t13 += v * b11;\n t14 += v * b12;\n t15 += v * b13;\n t16 += v * b14;\n t17 += v * b15;\n v = a[3];\n t3 += v * b0;\n t4 += v * b1;\n t5 += v * b2;\n t6 += v * b3;\n t7 += v * b4;\n t8 += v * b5;\n t9 += v * b6;\n t10 += v * b7;\n t11 += v * b8;\n t12 += v * b9;\n t13 += v * b10;\n t14 += v * b11;\n t15 += v * b12;\n t16 += v * b13;\n t17 += v * b14;\n t18 += v * b15;\n v = a[4];\n t4 += v * b0;\n t5 += v * b1;\n t6 += v * b2;\n t7 += v * b3;\n t8 += v * b4;\n t9 += v * b5;\n t10 += v * b6;\n t11 += v * b7;\n t12 += v * b8;\n t13 += v * b9;\n t14 += v * b10;\n t15 += v * b11;\n t16 += v * b12;\n t17 += v * b13;\n t18 += v * b14;\n t19 += v * b15;\n v = a[5];\n t5 += v * b0;\n t6 += v * b1;\n t7 += v * b2;\n t8 += v * b3;\n t9 += v * b4;\n t10 += v * b5;\n t11 += v * b6;\n t12 += v * b7;\n t13 += v * b8;\n t14 += v * b9;\n t15 += v * b10;\n t16 += v * b11;\n t17 += v * b12;\n t18 += v * b13;\n t19 += v * b14;\n t20 += v * b15;\n v = a[6];\n t6 += v * b0;\n t7 += v * b1;\n t8 += v * b2;\n t9 += v * b3;\n t10 += v * b4;\n t11 += v * b5;\n t12 += v * b6;\n t13 += v * b7;\n t14 += v * b8;\n t15 += v * b9;\n t16 += v * b10;\n t17 += v * b11;\n t18 += v * b12;\n t19 += v * b13;\n t20 += v * b14;\n t21 += v * b15;\n v = a[7];\n t7 += v * b0;\n t8 += v * b1;\n t9 += v * b2;\n t10 += v * b3;\n t11 += v * b4;\n t12 += v * b5;\n t13 += v * b6;\n t14 += v * b7;\n t15 += v * b8;\n t16 += v * b9;\n t17 += v * b10;\n t18 += v * b11;\n t19 += v * b12;\n t20 += v * b13;\n t21 += v * b14;\n t22 += v * b15;\n v = a[8];\n t8 += v * b0;\n t9 += v * b1;\n t10 += v * b2;\n t11 += v * b3;\n t12 += v * b4;\n t13 += v * b5;\n t14 += v * b6;\n t15 += v * b7;\n t16 += v * b8;\n t17 += v * b9;\n t18 += v * b10;\n t19 += v * b11;\n t20 += v * b12;\n t21 += v * b13;\n t22 += v * b14;\n t23 += v * b15;\n v = a[9];\n t9 += v * b0;\n t10 += v * b1;\n t11 += v * b2;\n t12 += v * b3;\n t13 += v * b4;\n t14 += v * b5;\n t15 += v * b6;\n t16 += v * b7;\n t17 += v * b8;\n t18 += v * b9;\n t19 += v * b10;\n t20 += v * b11;\n t21 += v * b12;\n t22 += v * b13;\n t23 += v * b14;\n t24 += v * b15;\n v = a[10];\n t10 += v * b0;\n t11 += v * b1;\n t12 += v * b2;\n t13 += v * b3;\n t14 += v * b4;\n t15 += v * b5;\n t16 += v * b6;\n t17 += v * b7;\n t18 += v * b8;\n t19 += v * b9;\n t20 += v * b10;\n t21 += v * b11;\n t22 += v * b12;\n t23 += v * b13;\n t24 += v * b14;\n t25 += v * b15;\n v = a[11];\n t11 += v * b0;\n t12 += v * b1;\n t13 += v * b2;\n t14 += v * b3;\n t15 += v * b4;\n t16 += v * b5;\n t17 += v * b6;\n t18 += v * b7;\n t19 += v * b8;\n t20 += v * b9;\n t21 += v * b10;\n t22 += v * b11;\n t23 += v * b12;\n t24 += v * b13;\n t25 += v * b14;\n t26 += v * b15;\n v = a[12];\n t12 += v * b0;\n t13 += v * b1;\n t14 += v * b2;\n t15 += v * b3;\n t16 += v * b4;\n t17 += v * b5;\n t18 += v * b6;\n t19 += v * b7;\n t20 += v * b8;\n t21 += v * b9;\n t22 += v * b10;\n t23 += v * b11;\n t24 += v * b12;\n t25 += v * b13;\n t26 += v * b14;\n t27 += v * b15;\n v = a[13];\n t13 += v * b0;\n t14 += v * b1;\n t15 += v * b2;\n t16 += v * b3;\n t17 += v * b4;\n t18 += v * b5;\n t19 += v * b6;\n t20 += v * b7;\n t21 += v * b8;\n t22 += v * b9;\n t23 += v * b10;\n t24 += v * b11;\n t25 += v * b12;\n t26 += v * b13;\n t27 += v * b14;\n t28 += v * b15;\n v = a[14];\n t14 += v * b0;\n t15 += v * b1;\n t16 += v * b2;\n t17 += v * b3;\n t18 += v * b4;\n t19 += v * b5;\n t20 += v * b6;\n t21 += v * b7;\n t22 += v * b8;\n t23 += v * b9;\n t24 += v * b10;\n t25 += v * b11;\n t26 += v * b12;\n t27 += v * b13;\n t28 += v * b14;\n t29 += v * b15;\n v = a[15];\n t15 += v * b0;\n t16 += v * b1;\n t17 += v * b2;\n t18 += v * b3;\n t19 += v * b4;\n t20 += v * b5;\n t21 += v * b6;\n t22 += v * b7;\n t23 += v * b8;\n t24 += v * b9;\n t25 += v * b10;\n t26 += v * b11;\n t27 += v * b12;\n t28 += v * b13;\n t29 += v * b14;\n t30 += v * b15;\n\n t0 += 38 * t16;\n t1 += 38 * t17;\n t2 += 38 * t18;\n t3 += 38 * t19;\n t4 += 38 * t20;\n t5 += 38 * t21;\n t6 += 38 * t22;\n t7 += 38 * t23;\n t8 += 38 * t24;\n t9 += 38 * t25;\n t10 += 38 * t26;\n t11 += 38 * t27;\n t12 += 38 * t28;\n t13 += 38 * t29;\n t14 += 38 * t30;\n // t15 left as is\n\n // first car\n c = 1;\n v = t0 + c + 65535; c = Math.floor(v / 65536); t0 = v - c * 65536;\n v = t1 + c + 65535; c = Math.floor(v / 65536); t1 = v - c * 65536;\n v = t2 + c + 65535; c = Math.floor(v / 65536); t2 = v - c * 65536;\n v = t3 + c + 65535; c = Math.floor(v / 65536); t3 = v - c * 65536;\n v = t4 + c + 65535; c = Math.floor(v / 65536); t4 = v - c * 65536;\n v = t5 + c + 65535; c = Math.floor(v / 65536); t5 = v - c * 65536;\n v = t6 + c + 65535; c = Math.floor(v / 65536); t6 = v - c * 65536;\n v = t7 + c + 65535; c = Math.floor(v / 65536); t7 = v - c * 65536;\n v = t8 + c + 65535; c = Math.floor(v / 65536); t8 = v - c * 65536;\n v = t9 + c + 65535; c = Math.floor(v / 65536); t9 = v - c * 65536;\n v = t10 + c + 65535; c = Math.floor(v / 65536); t10 = v - c * 65536;\n v = t11 + c + 65535; c = Math.floor(v / 65536); t11 = v - c * 65536;\n v = t12 + c + 65535; c = Math.floor(v / 65536); t12 = v - c * 65536;\n v = t13 + c + 65535; c = Math.floor(v / 65536); t13 = v - c * 65536;\n v = t14 + c + 65535; c = Math.floor(v / 65536); t14 = v - c * 65536;\n v = t15 + c + 65535; c = Math.floor(v / 65536); t15 = v - c * 65536;\n t0 += c-1 + 37 * (c-1);\n\n // second car\n c = 1;\n v = t0 + c + 65535; c = Math.floor(v / 65536); t0 = v - c * 65536;\n v = t1 + c + 65535; c = Math.floor(v / 65536); t1 = v - c * 65536;\n v = t2 + c + 65535; c = Math.floor(v / 65536); t2 = v - c * 65536;\n v = t3 + c + 65535; c = Math.floor(v / 65536); t3 = v - c * 65536;\n v = t4 + c + 65535; c = Math.floor(v / 65536); t4 = v - c * 65536;\n v = t5 + c + 65535; c = Math.floor(v / 65536); t5 = v - c * 65536;\n v = t6 + c + 65535; c = Math.floor(v / 65536); t6 = v - c * 65536;\n v = t7 + c + 65535; c = Math.floor(v / 65536); t7 = v - c * 65536;\n v = t8 + c + 65535; c = Math.floor(v / 65536); t8 = v - c * 65536;\n v = t9 + c + 65535; c = Math.floor(v / 65536); t9 = v - c * 65536;\n v = t10 + c + 65535; c = Math.floor(v / 65536); t10 = v - c * 65536;\n v = t11 + c + 65535; c = Math.floor(v / 65536); t11 = v - c * 65536;\n v = t12 + c + 65535; c = Math.floor(v / 65536); t12 = v - c * 65536;\n v = t13 + c + 65535; c = Math.floor(v / 65536); t13 = v - c * 65536;\n v = t14 + c + 65535; c = Math.floor(v / 65536); t14 = v - c * 65536;\n v = t15 + c + 65535; c = Math.floor(v / 65536); t15 = v - c * 65536;\n t0 += c-1 + 37 * (c-1);\n\n o[ 0] = t0;\n o[ 1] = t1;\n o[ 2] = t2;\n o[ 3] = t3;\n o[ 4] = t4;\n o[ 5] = t5;\n o[ 6] = t6;\n o[ 7] = t7;\n o[ 8] = t8;\n o[ 9] = t9;\n o[10] = t10;\n o[11] = t11;\n o[12] = t12;\n o[13] = t13;\n o[14] = t14;\n o[15] = t15;\n}\n\nfunction S(o, a) {\n M(o, a, a);\n}\n\nfunction inv25519(o, i) {\n var c = gf();\n var a;\n for (a = 0; a < 16; a++) c[a] = i[a];\n for (a = 253; a >= 0; a--) {\n S(c, c);\n if(a !== 2 && a !== 4) M(c, c, i);\n }\n for (a = 0; a < 16; a++) o[a] = c[a];\n}\n\nfunction pow2523(o, i) {\n var c = gf();\n var a;\n for (a = 0; a < 16; a++) c[a] = i[a];\n for (a = 250; a >= 0; a--) {\n S(c, c);\n if(a !== 1) M(c, c, i);\n }\n for (a = 0; a < 16; a++) o[a] = c[a];\n}\n\nfunction crypto_scalarmult(q, n, p) {\n var z = new Uint8Array(32);\n var x = new Float64Array(80), r, i;\n var a = gf(), b = gf(), c = gf(),\n d = gf(), e = gf(), f = gf();\n for (i = 0; i < 31; i++) z[i] = n[i];\n z[31]=(n[31]&127)|64;\n z[0]&=248;\n unpack25519(x,p);\n for (i = 0; i < 16; i++) {\n b[i]=x[i];\n d[i]=a[i]=c[i]=0;\n }\n a[0]=d[0]=1;\n for (i=254; i>=0; --i) {\n r=(z[i>>>3]>>>(i&7))&1;\n sel25519(a,b,r);\n sel25519(c,d,r);\n A(e,a,c);\n Z(a,a,c);\n A(c,b,d);\n Z(b,b,d);\n S(d,e);\n S(f,a);\n M(a,c,a);\n M(c,b,e);\n A(e,a,c);\n Z(a,a,c);\n S(b,a);\n Z(c,d,f);\n M(a,c,_121665);\n A(a,a,d);\n M(c,c,a);\n M(a,d,f);\n M(d,b,x);\n S(b,e);\n sel25519(a,b,r);\n sel25519(c,d,r);\n }\n for (i = 0; i < 16; i++) {\n x[i+16]=a[i];\n x[i+32]=c[i];\n x[i+48]=b[i];\n x[i+64]=d[i];\n }\n var x32 = x.subarray(32);\n var x16 = x.subarray(16);\n inv25519(x32,x32);\n M(x16,x16,x32);\n pack25519(q,x16);\n return 0;\n}\n\nfunction crypto_scalarmult_base(q, n) {\n return crypto_scalarmult(q, n, _9);\n}\n\nfunction crypto_box_keypair(y, x) {\n randombytes(x, 32);\n return crypto_scalarmult_base(y, x);\n}\n\nfunction crypto_box_beforenm(k, y, x) {\n var s = new Uint8Array(32);\n crypto_scalarmult(s, x, y);\n return crypto_core_hsalsa20(k, _0, s, sigma);\n}\n\nvar crypto_box_afternm = crypto_secretbox;\nvar crypto_box_open_afternm = crypto_secretbox_open;\n\nfunction crypto_box(c, m, d, n, y, x) {\n var k = new Uint8Array(32);\n crypto_box_beforenm(k, y, x);\n return crypto_box_afternm(c, m, d, n, k);\n}\n\nfunction crypto_box_open(m, c, d, n, y, x) {\n var k = new Uint8Array(32);\n crypto_box_beforenm(k, y, x);\n return crypto_box_open_afternm(m, c, d, n, k);\n}\n\nvar K = [\n 0x428a2f98, 0xd728ae22, 0x71374491, 0x23ef65cd,\n 0xb5c0fbcf, 0xec4d3b2f, 0xe9b5dba5, 0x8189dbbc,\n 0x3956c25b, 0xf348b538, 0x59f111f1, 0xb605d019,\n 0x923f82a4, 0xaf194f9b, 0xab1c5ed5, 0xda6d8118,\n 0xd807aa98, 0xa3030242, 0x12835b01, 0x45706fbe,\n 0x243185be, 0x4ee4b28c, 0x550c7dc3, 0xd5ffb4e2,\n 0x72be5d74, 0xf27b896f, 0x80deb1fe, 0x3b1696b1,\n 0x9bdc06a7, 0x25c71235, 0xc19bf174, 0xcf692694,\n 0xe49b69c1, 0x9ef14ad2, 0xefbe4786, 0x384f25e3,\n 0x0fc19dc6, 0x8b8cd5b5, 0x240ca1cc, 0x77ac9c65,\n 0x2de92c6f, 0x592b0275, 0x4a7484aa, 0x6ea6e483,\n 0x5cb0a9dc, 0xbd41fbd4, 0x76f988da, 0x831153b5,\n 0x983e5152, 0xee66dfab, 0xa831c66d, 0x2db43210,\n 0xb00327c8, 0x98fb213f, 0xbf597fc7, 0xbeef0ee4,\n 0xc6e00bf3, 0x3da88fc2, 0xd5a79147, 0x930aa725,\n 0x06ca6351, 0xe003826f, 0x14292967, 0x0a0e6e70,\n 0x27b70a85, 0x46d22ffc, 0x2e1b2138, 0x5c26c926,\n 0x4d2c6dfc, 0x5ac42aed, 0x53380d13, 0x9d95b3df,\n 0x650a7354, 0x8baf63de, 0x766a0abb, 0x3c77b2a8,\n 0x81c2c92e, 0x47edaee6, 0x92722c85, 0x1482353b,\n 0xa2bfe8a1, 0x4cf10364, 0xa81a664b, 0xbc423001,\n 0xc24b8b70, 0xd0f89791, 0xc76c51a3, 0x0654be30,\n 0xd192e819, 0xd6ef5218, 0xd6990624, 0x5565a910,\n 0xf40e3585, 0x5771202a, 0x106aa070, 0x32bbd1b8,\n 0x19a4c116, 0xb8d2d0c8, 0x1e376c08, 0x5141ab53,\n 0x2748774c, 0xdf8eeb99, 0x34b0bcb5, 0xe19b48a8,\n 0x391c0cb3, 0xc5c95a63, 0x4ed8aa4a, 0xe3418acb,\n 0x5b9cca4f, 0x7763e373, 0x682e6ff3, 0xd6b2b8a3,\n 0x748f82ee, 0x5defb2fc, 0x78a5636f, 0x43172f60,\n 0x84c87814, 0xa1f0ab72, 0x8cc70208, 0x1a6439ec,\n 0x90befffa, 0x23631e28, 0xa4506ceb, 0xde82bde9,\n 0xbef9a3f7, 0xb2c67915, 0xc67178f2, 0xe372532b,\n 0xca273ece, 0xea26619c, 0xd186b8c7, 0x21c0c207,\n 0xeada7dd6, 0xcde0eb1e, 0xf57d4f7f, 0xee6ed178,\n 0x06f067aa, 0x72176fba, 0x0a637dc5, 0xa2c898a6,\n 0x113f9804, 0xbef90dae, 0x1b710b35, 0x131c471b,\n 0x28db77f5, 0x23047d84, 0x32caab7b, 0x40c72493,\n 0x3c9ebe0a, 0x15c9bebc, 0x431d67c4, 0x9c100d4c,\n 0x4cc5d4be, 0xcb3e42b6, 0x597f299c, 0xfc657e2a,\n 0x5fcb6fab, 0x3ad6faec, 0x6c44198c, 0x4a475817\n];\n\nfunction crypto_hashblocks_hl(hh, hl, m, n) {\n var wh = new Int32Array(16), wl = new Int32Array(16),\n bh0, bh1, bh2, bh3, bh4, bh5, bh6, bh7,\n bl0, bl1, bl2, bl3, bl4, bl5, bl6, bl7,\n th, tl, i, j, h, l, a, b, c, d;\n\n var ah0 = hh[0],\n ah1 = hh[1],\n ah2 = hh[2],\n ah3 = hh[3],\n ah4 = hh[4],\n ah5 = hh[5],\n ah6 = hh[6],\n ah7 = hh[7],\n\n al0 = hl[0],\n al1 = hl[1],\n al2 = hl[2],\n al3 = hl[3],\n al4 = hl[4],\n al5 = hl[5],\n al6 = hl[6],\n al7 = hl[7];\n\n var pos = 0;\n while (n >= 128) {\n for (i = 0; i < 16; i++) {\n j = 8 * i + pos;\n wh[i] = (m[j+0] << 24) | (m[j+1] << 16) | (m[j+2] << 8) | m[j+3];\n wl[i] = (m[j+4] << 24) | (m[j+5] << 16) | (m[j+6] << 8) | m[j+7];\n }\n for (i = 0; i < 80; i++) {\n bh0 = ah0;\n bh1 = ah1;\n bh2 = ah2;\n bh3 = ah3;\n bh4 = ah4;\n bh5 = ah5;\n bh6 = ah6;\n bh7 = ah7;\n\n bl0 = al0;\n bl1 = al1;\n bl2 = al2;\n bl3 = al3;\n bl4 = al4;\n bl5 = al5;\n bl6 = al6;\n bl7 = al7;\n\n // add\n h = ah7;\n l = al7;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n // Sigma1\n h = ((ah4 >>> 14) | (al4 << (32-14))) ^ ((ah4 >>> 18) | (al4 << (32-18))) ^ ((al4 >>> (41-32)) | (ah4 << (32-(41-32))));\n l = ((al4 >>> 14) | (ah4 << (32-14))) ^ ((al4 >>> 18) | (ah4 << (32-18))) ^ ((ah4 >>> (41-32)) | (al4 << (32-(41-32))));\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // Ch\n h = (ah4 & ah5) ^ (~ah4 & ah6);\n l = (al4 & al5) ^ (~al4 & al6);\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // K\n h = K[i*2];\n l = K[i*2+1];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // w\n h = wh[i%16];\n l = wl[i%16];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n th = c & 0xffff | d << 16;\n tl = a & 0xffff | b << 16;\n\n // add\n h = th;\n l = tl;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n // Sigma0\n h = ((ah0 >>> 28) | (al0 << (32-28))) ^ ((al0 >>> (34-32)) | (ah0 << (32-(34-32)))) ^ ((al0 >>> (39-32)) | (ah0 << (32-(39-32))));\n l = ((al0 >>> 28) | (ah0 << (32-28))) ^ ((ah0 >>> (34-32)) | (al0 << (32-(34-32)))) ^ ((ah0 >>> (39-32)) | (al0 << (32-(39-32))));\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // Maj\n h = (ah0 & ah1) ^ (ah0 & ah2) ^ (ah1 & ah2);\n l = (al0 & al1) ^ (al0 & al2) ^ (al1 & al2);\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n bh7 = (c & 0xffff) | (d << 16);\n bl7 = (a & 0xffff) | (b << 16);\n\n // add\n h = bh3;\n l = bl3;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = th;\n l = tl;\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n bh3 = (c & 0xffff) | (d << 16);\n bl3 = (a & 0xffff) | (b << 16);\n\n ah1 = bh0;\n ah2 = bh1;\n ah3 = bh2;\n ah4 = bh3;\n ah5 = bh4;\n ah6 = bh5;\n ah7 = bh6;\n ah0 = bh7;\n\n al1 = bl0;\n al2 = bl1;\n al3 = bl2;\n al4 = bl3;\n al5 = bl4;\n al6 = bl5;\n al7 = bl6;\n al0 = bl7;\n\n if (i%16 === 15) {\n for (j = 0; j < 16; j++) {\n // add\n h = wh[j];\n l = wl[j];\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = wh[(j+9)%16];\n l = wl[(j+9)%16];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // sigma0\n th = wh[(j+1)%16];\n tl = wl[(j+1)%16];\n h = ((th >>> 1) | (tl << (32-1))) ^ ((th >>> 8) | (tl << (32-8))) ^ (th >>> 7);\n l = ((tl >>> 1) | (th << (32-1))) ^ ((tl >>> 8) | (th << (32-8))) ^ ((tl >>> 7) | (th << (32-7)));\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // sigma1\n th = wh[(j+14)%16];\n tl = wl[(j+14)%16];\n h = ((th >>> 19) | (tl << (32-19))) ^ ((tl >>> (61-32)) | (th << (32-(61-32)))) ^ (th >>> 6);\n l = ((tl >>> 19) | (th << (32-19))) ^ ((th >>> (61-32)) | (tl << (32-(61-32)))) ^ ((tl >>> 6) | (th << (32-6)));\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n wh[j] = (c & 0xffff) | (d << 16);\n wl[j] = (a & 0xffff) | (b << 16);\n }\n }\n }\n\n // add\n h = ah0;\n l = al0;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[0];\n l = hl[0];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[0] = ah0 = (c & 0xffff) | (d << 16);\n hl[0] = al0 = (a & 0xffff) | (b << 16);\n\n h = ah1;\n l = al1;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[1];\n l = hl[1];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[1] = ah1 = (c & 0xffff) | (d << 16);\n hl[1] = al1 = (a & 0xffff) | (b << 16);\n\n h = ah2;\n l = al2;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[2];\n l = hl[2];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[2] = ah2 = (c & 0xffff) | (d << 16);\n hl[2] = al2 = (a & 0xffff) | (b << 16);\n\n h = ah3;\n l = al3;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[3];\n l = hl[3];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[3] = ah3 = (c & 0xffff) | (d << 16);\n hl[3] = al3 = (a & 0xffff) | (b << 16);\n\n h = ah4;\n l = al4;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[4];\n l = hl[4];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[4] = ah4 = (c & 0xffff) | (d << 16);\n hl[4] = al4 = (a & 0xffff) | (b << 16);\n\n h = ah5;\n l = al5;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[5];\n l = hl[5];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[5] = ah5 = (c & 0xffff) | (d << 16);\n hl[5] = al5 = (a & 0xffff) | (b << 16);\n\n h = ah6;\n l = al6;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[6];\n l = hl[6];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[6] = ah6 = (c & 0xffff) | (d << 16);\n hl[6] = al6 = (a & 0xffff) | (b << 16);\n\n h = ah7;\n l = al7;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[7];\n l = hl[7];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[7] = ah7 = (c & 0xffff) | (d << 16);\n hl[7] = al7 = (a & 0xffff) | (b << 16);\n\n pos += 128;\n n -= 128;\n }\n\n return n;\n}\n\nfunction crypto_hash(out, m, n) {\n var hh = new Int32Array(8),\n hl = new Int32Array(8),\n x = new Uint8Array(256),\n i, b = n;\n\n hh[0] = 0x6a09e667;\n hh[1] = 0xbb67ae85;\n hh[2] = 0x3c6ef372;\n hh[3] = 0xa54ff53a;\n hh[4] = 0x510e527f;\n hh[5] = 0x9b05688c;\n hh[6] = 0x1f83d9ab;\n hh[7] = 0x5be0cd19;\n\n hl[0] = 0xf3bcc908;\n hl[1] = 0x84caa73b;\n hl[2] = 0xfe94f82b;\n hl[3] = 0x5f1d36f1;\n hl[4] = 0xade682d1;\n hl[5] = 0x2b3e6c1f;\n hl[6] = 0xfb41bd6b;\n hl[7] = 0x137e2179;\n\n crypto_hashblocks_hl(hh, hl, m, n);\n n %= 128;\n\n for (i = 0; i < n; i++) x[i] = m[b-n+i];\n x[n] = 128;\n\n n = 256-128*(n<112?1:0);\n x[n-9] = 0;\n ts64(x, n-8, (b / 0x20000000) | 0, b << 3);\n crypto_hashblocks_hl(hh, hl, x, n);\n\n for (i = 0; i < 8; i++) ts64(out, 8*i, hh[i], hl[i]);\n\n return 0;\n}\n\nfunction add(p, q) {\n var a = gf(), b = gf(), c = gf(),\n d = gf(), e = gf(), f = gf(),\n g = gf(), h = gf(), t = gf();\n\n Z(a, p[1], p[0]);\n Z(t, q[1], q[0]);\n M(a, a, t);\n A(b, p[0], p[1]);\n A(t, q[0], q[1]);\n M(b, b, t);\n M(c, p[3], q[3]);\n M(c, c, D2);\n M(d, p[2], q[2]);\n A(d, d, d);\n Z(e, b, a);\n Z(f, d, c);\n A(g, d, c);\n A(h, b, a);\n\n M(p[0], e, f);\n M(p[1], h, g);\n M(p[2], g, f);\n M(p[3], e, h);\n}\n\nfunction cswap(p, q, b) {\n var i;\n for (i = 0; i < 4; i++) {\n sel25519(p[i], q[i], b);\n }\n}\n\nfunction pack(r, p) {\n var tx = gf(), ty = gf(), zi = gf();\n inv25519(zi, p[2]);\n M(tx, p[0], zi);\n M(ty, p[1], zi);\n pack25519(r, ty);\n r[31] ^= par25519(tx) << 7;\n}\n\nfunction scalarmult(p, q, s) {\n var b, i;\n set25519(p[0], gf0);\n set25519(p[1], gf1);\n set25519(p[2], gf1);\n set25519(p[3], gf0);\n for (i = 255; i >= 0; --i) {\n b = (s[(i/8)|0] >> (i&7)) & 1;\n cswap(p, q, b);\n add(q, p);\n add(p, p);\n cswap(p, q, b);\n }\n}\n\nfunction scalarbase(p, s) {\n var q = [gf(), gf(), gf(), gf()];\n set25519(q[0], X);\n set25519(q[1], Y);\n set25519(q[2], gf1);\n M(q[3], X, Y);\n scalarmult(p, q, s);\n}\n\nfunction crypto_sign_keypair(pk, sk, seeded) {\n var d = new Uint8Array(64);\n var p = [gf(), gf(), gf(), gf()];\n var i;\n\n if (!seeded) randombytes(sk, 32);\n crypto_hash(d, sk, 32);\n d[0] &= 248;\n d[31] &= 127;\n d[31] |= 64;\n\n scalarbase(p, d);\n pack(pk, p);\n\n for (i = 0; i < 32; i++) sk[i+32] = pk[i];\n return 0;\n}\n\nvar L = new Float64Array([0xed, 0xd3, 0xf5, 0x5c, 0x1a, 0x63, 0x12, 0x58, 0xd6, 0x9c, 0xf7, 0xa2, 0xde, 0xf9, 0xde, 0x14, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x10]);\n\nfunction modL(r, x) {\n var carry, i, j, k;\n for (i = 63; i >= 32; --i) {\n carry = 0;\n for (j = i - 32, k = i - 12; j < k; ++j) {\n x[j] += carry - 16 * x[i] * L[j - (i - 32)];\n carry = Math.floor((x[j] + 128) / 256);\n x[j] -= carry * 256;\n }\n x[j] += carry;\n x[i] = 0;\n }\n carry = 0;\n for (j = 0; j < 32; j++) {\n x[j] += carry - (x[31] >> 4) * L[j];\n carry = x[j] >> 8;\n x[j] &= 255;\n }\n for (j = 0; j < 32; j++) x[j] -= carry * L[j];\n for (i = 0; i < 32; i++) {\n x[i+1] += x[i] >> 8;\n r[i] = x[i] & 255;\n }\n}\n\nfunction reduce(r) {\n var x = new Float64Array(64), i;\n for (i = 0; i < 64; i++) x[i] = r[i];\n for (i = 0; i < 64; i++) r[i] = 0;\n modL(r, x);\n}\n\n// Note: difference from C - smlen returned, not passed as argument.\nfunction crypto_sign(sm, m, n, sk) {\n var d = new Uint8Array(64), h = new Uint8Array(64), r = new Uint8Array(64);\n var i, j, x = new Float64Array(64);\n var p = [gf(), gf(), gf(), gf()];\n\n crypto_hash(d, sk, 32);\n d[0] &= 248;\n d[31] &= 127;\n d[31] |= 64;\n\n var smlen = n + 64;\n for (i = 0; i < n; i++) sm[64 + i] = m[i];\n for (i = 0; i < 32; i++) sm[32 + i] = d[32 + i];\n\n crypto_hash(r, sm.subarray(32), n+32);\n reduce(r);\n scalarbase(p, r);\n pack(sm, p);\n\n for (i = 32; i < 64; i++) sm[i] = sk[i];\n crypto_hash(h, sm, n + 64);\n reduce(h);\n\n for (i = 0; i < 64; i++) x[i] = 0;\n for (i = 0; i < 32; i++) x[i] = r[i];\n for (i = 0; i < 32; i++) {\n for (j = 0; j < 32; j++) {\n x[i+j] += h[i] * d[j];\n }\n }\n\n modL(sm.subarray(32), x);\n return smlen;\n}\n\nfunction unpackneg(r, p) {\n var t = gf(), chk = gf(), num = gf(),\n den = gf(), den2 = gf(), den4 = gf(),\n den6 = gf();\n\n set25519(r[2], gf1);\n unpack25519(r[1], p);\n S(num, r[1]);\n M(den, num, D);\n Z(num, num, r[2]);\n A(den, r[2], den);\n\n S(den2, den);\n S(den4, den2);\n M(den6, den4, den2);\n M(t, den6, num);\n M(t, t, den);\n\n pow2523(t, t);\n M(t, t, num);\n M(t, t, den);\n M(t, t, den);\n M(r[0], t, den);\n\n S(chk, r[0]);\n M(chk, chk, den);\n if (neq25519(chk, num)) M(r[0], r[0], I);\n\n S(chk, r[0]);\n M(chk, chk, den);\n if (neq25519(chk, num)) return -1;\n\n if (par25519(r[0]) === (p[31]>>7)) Z(r[0], gf0, r[0]);\n\n M(r[3], r[0], r[1]);\n return 0;\n}\n\nfunction crypto_sign_open(m, sm, n, pk) {\n var i;\n var t = new Uint8Array(32), h = new Uint8Array(64);\n var p = [gf(), gf(), gf(), gf()],\n q = [gf(), gf(), gf(), gf()];\n\n if (n < 64) return -1;\n\n if (unpackneg(q, pk)) return -1;\n\n for (i = 0; i < n; i++) m[i] = sm[i];\n for (i = 0; i < 32; i++) m[i+32] = pk[i];\n crypto_hash(h, m, n);\n reduce(h);\n scalarmult(p, q, h);\n\n scalarbase(q, sm.subarray(32));\n add(p, q);\n pack(t, p);\n\n n -= 64;\n if (crypto_verify_32(sm, 0, t, 0)) {\n for (i = 0; i < n; i++) m[i] = 0;\n return -1;\n }\n\n for (i = 0; i < n; i++) m[i] = sm[i + 64];\n return n;\n}\n\nvar crypto_secretbox_KEYBYTES = 32,\n crypto_secretbox_NONCEBYTES = 24,\n crypto_secretbox_ZEROBYTES = 32,\n crypto_secretbox_BOXZEROBYTES = 16,\n crypto_scalarmult_BYTES = 32,\n crypto_scalarmult_SCALARBYTES = 32,\n crypto_box_PUBLICKEYBYTES = 32,\n crypto_box_SECRETKEYBYTES = 32,\n crypto_box_BEFORENMBYTES = 32,\n crypto_box_NONCEBYTES = crypto_secretbox_NONCEBYTES,\n crypto_box_ZEROBYTES = crypto_secretbox_ZEROBYTES,\n crypto_box_BOXZEROBYTES = crypto_secretbox_BOXZEROBYTES,\n crypto_sign_BYTES = 64,\n crypto_sign_PUBLICKEYBYTES = 32,\n crypto_sign_SECRETKEYBYTES = 64,\n crypto_sign_SEEDBYTES = 32,\n crypto_hash_BYTES = 64;\n\nnacl.lowlevel = {\n crypto_core_hsalsa20: crypto_core_hsalsa20,\n crypto_stream_xor: crypto_stream_xor,\n crypto_stream: crypto_stream,\n crypto_stream_salsa20_xor: crypto_stream_salsa20_xor,\n crypto_stream_salsa20: crypto_stream_salsa20,\n crypto_onetimeauth: crypto_onetimeauth,\n crypto_onetimeauth_verify: crypto_onetimeauth_verify,\n crypto_verify_16: crypto_verify_16,\n crypto_verify_32: crypto_verify_32,\n crypto_secretbox: crypto_secretbox,\n crypto_secretbox_open: crypto_secretbox_open,\n crypto_scalarmult: crypto_scalarmult,\n crypto_scalarmult_base: crypto_scalarmult_base,\n crypto_box_beforenm: crypto_box_beforenm,\n crypto_box_afternm: crypto_box_afternm,\n crypto_box: crypto_box,\n crypto_box_open: crypto_box_open,\n crypto_box_keypair: crypto_box_keypair,\n crypto_hash: crypto_hash,\n crypto_sign: crypto_sign,\n crypto_sign_keypair: crypto_sign_keypair,\n crypto_sign_open: crypto_sign_open,\n\n crypto_secretbox_KEYBYTES: crypto_secretbox_KEYBYTES,\n crypto_secretbox_NONCEBYTES: crypto_secretbox_NONCEBYTES,\n crypto_secretbox_ZEROBYTES: crypto_secretbox_ZEROBYTES,\n crypto_secretbox_BOXZEROBYTES: crypto_secretbox_BOXZEROBYTES,\n crypto_scalarmult_BYTES: crypto_scalarmult_BYTES,\n crypto_scalarmult_SCALARBYTES: crypto_scalarmult_SCALARBYTES,\n crypto_box_PUBLICKEYBYTES: crypto_box_PUBLICKEYBYTES,\n crypto_box_SECRETKEYBYTES: crypto_box_SECRETKEYBYTES,\n crypto_box_BEFORENMBYTES: crypto_box_BEFORENMBYTES,\n crypto_box_NONCEBYTES: crypto_box_NONCEBYTES,\n crypto_box_ZEROBYTES: crypto_box_ZEROBYTES,\n crypto_box_BOXZEROBYTES: crypto_box_BOXZEROBYTES,\n crypto_sign_BYTES: crypto_sign_BYTES,\n crypto_sign_PUBLICKEYBYTES: crypto_sign_PUBLICKEYBYTES,\n crypto_sign_SECRETKEYBYTES: crypto_sign_SECRETKEYBYTES,\n crypto_sign_SEEDBYTES: crypto_sign_SEEDBYTES,\n crypto_hash_BYTES: crypto_hash_BYTES,\n\n gf: gf,\n D: D,\n L: L,\n pack25519: pack25519,\n unpack25519: unpack25519,\n M: M,\n A: A,\n S: S,\n Z: Z,\n pow2523: pow2523,\n add: add,\n set25519: set25519,\n modL: modL,\n scalarmult: scalarmult,\n scalarbase: scalarbase,\n};\n\n/* High-level API */\n\nfunction checkLengths(k, n) {\n if (k.length !== crypto_secretbox_KEYBYTES) throw new Error('bad key size');\n if (n.length !== crypto_secretbox_NONCEBYTES) throw new Error('bad nonce size');\n}\n\nfunction checkBoxLengths(pk, sk) {\n if (pk.length !== crypto_box_PUBLICKEYBYTES) throw new Error('bad public key size');\n if (sk.length !== crypto_box_SECRETKEYBYTES) throw new Error('bad secret key size');\n}\n\nfunction checkArrayTypes() {\n for (var i = 0; i < arguments.length; i++) {\n if (!(arguments[i] instanceof Uint8Array))\n throw new TypeError('unexpected type, use Uint8Array');\n }\n}\n\nfunction cleanup(arr) {\n for (var i = 0; i < arr.length; i++) arr[i] = 0;\n}\n\nnacl.randomBytes = function(n) {\n var b = new Uint8Array(n);\n randombytes(b, n);\n return b;\n};\n\nnacl.secretbox = function(msg, nonce, key) {\n checkArrayTypes(msg, nonce, key);\n checkLengths(key, nonce);\n var m = new Uint8Array(crypto_secretbox_ZEROBYTES + msg.length);\n var c = new Uint8Array(m.length);\n for (var i = 0; i < msg.length; i++) m[i+crypto_secretbox_ZEROBYTES] = msg[i];\n crypto_secretbox(c, m, m.length, nonce, key);\n return c.subarray(crypto_secretbox_BOXZEROBYTES);\n};\n\nnacl.secretbox.open = function(box, nonce, key) {\n checkArrayTypes(box, nonce, key);\n checkLengths(key, nonce);\n var c = new Uint8Array(crypto_secretbox_BOXZEROBYTES + box.length);\n var m = new Uint8Array(c.length);\n for (var i = 0; i < box.length; i++) c[i+crypto_secretbox_BOXZEROBYTES] = box[i];\n if (c.length < 32) return null;\n if (crypto_secretbox_open(m, c, c.length, nonce, key) !== 0) return null;\n return m.subarray(crypto_secretbox_ZEROBYTES);\n};\n\nnacl.secretbox.keyLength = crypto_secretbox_KEYBYTES;\nnacl.secretbox.nonceLength = crypto_secretbox_NONCEBYTES;\nnacl.secretbox.overheadLength = crypto_secretbox_BOXZEROBYTES;\n\nnacl.scalarMult = function(n, p) {\n checkArrayTypes(n, p);\n if (n.length !== crypto_scalarmult_SCALARBYTES) throw new Error('bad n size');\n if (p.length !== crypto_scalarmult_BYTES) throw new Error('bad p size');\n var q = new Uint8Array(crypto_scalarmult_BYTES);\n crypto_scalarmult(q, n, p);\n return q;\n};\n\nnacl.scalarMult.base = function(n) {\n checkArrayTypes(n);\n if (n.length !== crypto_scalarmult_SCALARBYTES) throw new Error('bad n size');\n var q = new Uint8Array(crypto_scalarmult_BYTES);\n crypto_scalarmult_base(q, n);\n return q;\n};\n\nnacl.scalarMult.scalarLength = crypto_scalarmult_SCALARBYTES;\nnacl.scalarMult.groupElementLength = crypto_scalarmult_BYTES;\n\nnacl.box = function(msg, nonce, publicKey, secretKey) {\n var k = nacl.box.before(publicKey, secretKey);\n return nacl.secretbox(msg, nonce, k);\n};\n\nnacl.box.before = function(publicKey, secretKey) {\n checkArrayTypes(publicKey, secretKey);\n checkBoxLengths(publicKey, secretKey);\n var k = new Uint8Array(crypto_box_BEFORENMBYTES);\n crypto_box_beforenm(k, publicKey, secretKey);\n return k;\n};\n\nnacl.box.after = nacl.secretbox;\n\nnacl.box.open = function(msg, nonce, publicKey, secretKey) {\n var k = nacl.box.before(publicKey, secretKey);\n return nacl.secretbox.open(msg, nonce, k);\n};\n\nnacl.box.open.after = nacl.secretbox.open;\n\nnacl.box.keyPair = function() {\n var pk = new Uint8Array(crypto_box_PUBLICKEYBYTES);\n var sk = new Uint8Array(crypto_box_SECRETKEYBYTES);\n crypto_box_keypair(pk, sk);\n return {publicKey: pk, secretKey: sk};\n};\n\nnacl.box.keyPair.fromSecretKey = function(secretKey) {\n checkArrayTypes(secretKey);\n if (secretKey.length !== crypto_box_SECRETKEYBYTES)\n throw new Error('bad secret key size');\n var pk = new Uint8Array(crypto_box_PUBLICKEYBYTES);\n crypto_scalarmult_base(pk, secretKey);\n return {publicKey: pk, secretKey: new Uint8Array(secretKey)};\n};\n\nnacl.box.publicKeyLength = crypto_box_PUBLICKEYBYTES;\nnacl.box.secretKeyLength = crypto_box_SECRETKEYBYTES;\nnacl.box.sharedKeyLength = crypto_box_BEFORENMBYTES;\nnacl.box.nonceLength = crypto_box_NONCEBYTES;\nnacl.box.overheadLength = nacl.secretbox.overheadLength;\n\nnacl.sign = function(msg, secretKey) {\n checkArrayTypes(msg, secretKey);\n if (secretKey.length !== crypto_sign_SECRETKEYBYTES)\n throw new Error('bad secret key size');\n var signedMsg = new Uint8Array(crypto_sign_BYTES+msg.length);\n crypto_sign(signedMsg, msg, msg.length, secretKey);\n return signedMsg;\n};\n\nnacl.sign.open = function(signedMsg, publicKey) {\n checkArrayTypes(signedMsg, publicKey);\n if (publicKey.length !== crypto_sign_PUBLICKEYBYTES)\n throw new Error('bad public key size');\n var tmp = new Uint8Array(signedMsg.length);\n var mlen = crypto_sign_open(tmp, signedMsg, signedMsg.length, publicKey);\n if (mlen < 0) return null;\n var m = new Uint8Array(mlen);\n for (var i = 0; i < m.length; i++) m[i] = tmp[i];\n return m;\n};\n\nnacl.sign.detached = function(msg, secretKey) {\n var signedMsg = nacl.sign(msg, secretKey);\n var sig = new Uint8Array(crypto_sign_BYTES);\n for (var i = 0; i < sig.length; i++) sig[i] = signedMsg[i];\n return sig;\n};\n\nnacl.sign.detached.verify = function(msg, sig, publicKey) {\n checkArrayTypes(msg, sig, publicKey);\n if (sig.length !== crypto_sign_BYTES)\n throw new Error('bad signature size');\n if (publicKey.length !== crypto_sign_PUBLICKEYBYTES)\n throw new Error('bad public key size');\n var sm = new Uint8Array(crypto_sign_BYTES + msg.length);\n var m = new Uint8Array(crypto_sign_BYTES + msg.length);\n var i;\n for (i = 0; i < crypto_sign_BYTES; i++) sm[i] = sig[i];\n for (i = 0; i < msg.length; i++) sm[i+crypto_sign_BYTES] = msg[i];\n return (crypto_sign_open(m, sm, sm.length, publicKey) >= 0);\n};\n\nnacl.sign.keyPair = function() {\n var pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);\n var sk = new Uint8Array(crypto_sign_SECRETKEYBYTES);\n crypto_sign_keypair(pk, sk);\n return {publicKey: pk, secretKey: sk};\n};\n\nnacl.sign.keyPair.fromSecretKey = function(secretKey) {\n checkArrayTypes(secretKey);\n if (secretKey.length !== crypto_sign_SECRETKEYBYTES)\n throw new Error('bad secret key size');\n var pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);\n for (var i = 0; i < pk.length; i++) pk[i] = secretKey[32+i];\n return {publicKey: pk, secretKey: new Uint8Array(secretKey)};\n};\n\nnacl.sign.keyPair.fromSeed = function(seed) {\n checkArrayTypes(seed);\n if (seed.length !== crypto_sign_SEEDBYTES)\n throw new Error('bad seed size');\n var pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);\n var sk = new Uint8Array(crypto_sign_SECRETKEYBYTES);\n for (var i = 0; i < 32; i++) sk[i] = seed[i];\n crypto_sign_keypair(pk, sk, true);\n return {publicKey: pk, secretKey: sk};\n};\n\nnacl.sign.publicKeyLength = crypto_sign_PUBLICKEYBYTES;\nnacl.sign.secretKeyLength = crypto_sign_SECRETKEYBYTES;\nnacl.sign.seedLength = crypto_sign_SEEDBYTES;\nnacl.sign.signatureLength = crypto_sign_BYTES;\n\nnacl.hash = function(msg) {\n checkArrayTypes(msg);\n var h = new Uint8Array(crypto_hash_BYTES);\n crypto_hash(h, msg, msg.length);\n return h;\n};\n\nnacl.hash.hashLength = crypto_hash_BYTES;\n\nnacl.verify = function(x, y) {\n checkArrayTypes(x, y);\n // Zero length arguments are considered not equal.\n if (x.length === 0 || y.length === 0) return false;\n if (x.length !== y.length) return false;\n return (vn(x, 0, y, 0, x.length) === 0) ? true : false;\n};\n\nnacl.setPRNG = function(fn) {\n randombytes = fn;\n};\n\n(function() {\n // Initialize PRNG if environment provides CSPRNG.\n // If not, methods calling randombytes will throw.\n var crypto = typeof self !== 'undefined' ? (self.crypto || self.msCrypto) : null;\n if (crypto && crypto.getRandomValues) {\n // Browsers.\n var QUOTA = 65536;\n nacl.setPRNG(function(x, n) {\n var i, v = new Uint8Array(n);\n for (i = 0; i < n; i += QUOTA) {\n crypto.getRandomValues(v.subarray(i, i + Math.min(n - i, QUOTA)));\n }\n for (i = 0; i < n; i++) x[i] = v[i];\n cleanup(v);\n });\n } else if (typeof require !== 'undefined') {\n // Node.js.\n crypto = require('crypto');\n if (crypto && crypto.randomBytes) {\n nacl.setPRNG(function(x, n) {\n var i, v = crypto.randomBytes(n);\n for (i = 0; i < n; i++) x[i] = v[i];\n cleanup(v);\n });\n }\n }\n})();\n\n})(typeof module !== 'undefined' && module.exports ? module.exports : (self.nacl = self.nacl || {}));\n","module.exports = require('./pusher-with-encryption').default;\n","/* (ignored) */","import ScriptReceiver from './script_receiver';\n\n/** Builds receivers for JSONP and Script requests.\n *\n * Each receiver is an object with following fields:\n * - number - unique (for the factory instance), numerical id of the receiver\n * - id - a string ID that can be used in DOM attributes\n * - name - name of the function triggering the receiver\n * - callback - callback function\n *\n * Receivers are triggered only once, on the first callback call.\n *\n * Receivers can be called by their name or by accessing factory object\n * by the number key.\n *\n * @param {String} prefix the prefix used in ids\n * @param {String} name the name of the object\n */\nexport class ScriptReceiverFactory {\n lastId: number;\n prefix: string;\n name: string;\n\n constructor(prefix: string, name: string) {\n this.lastId = 0;\n this.prefix = prefix;\n this.name = name;\n }\n\n create(callback: Function): ScriptReceiver {\n this.lastId++;\n\n var number = this.lastId;\n var id = this.prefix + number;\n var name = this.name + '[' + number + ']';\n\n var called = false;\n var callbackWrapper = function() {\n if (!called) {\n callback.apply(null, arguments);\n called = true;\n }\n };\n\n this[number] = callbackWrapper;\n return { number: number, id: id, name: name, callback: callbackWrapper };\n }\n\n remove(receiver: ScriptReceiver) {\n delete this[receiver.number];\n }\n}\n\nexport var ScriptReceivers = new ScriptReceiverFactory(\n '_pusher_script_',\n 'Pusher.ScriptReceivers'\n);\n","import {\n ChannelAuthorizationOptions,\n UserAuthenticationOptions\n} from './auth/options';\nimport { AuthTransport } from './config';\n\nexport interface DefaultConfig {\n VERSION: string;\n PROTOCOL: number;\n wsPort: number;\n wssPort: number;\n wsPath: string;\n httpHost: string;\n httpPort: number;\n httpsPort: number;\n httpPath: string;\n stats_host: string;\n authEndpoint: string;\n authTransport: AuthTransport;\n activityTimeout: number;\n pongTimeout: number;\n unavailableTimeout: number;\n userAuthentication: UserAuthenticationOptions;\n channelAuthorization: ChannelAuthorizationOptions;\n\n cdn_http?: string;\n cdn_https?: string;\n dependency_suffix?: string;\n}\n\nvar Defaults: DefaultConfig = {\n VERSION: VERSION,\n PROTOCOL: 7,\n\n wsPort: 80,\n wssPort: 443,\n wsPath: '',\n // DEPRECATED: SockJS fallback parameters\n httpHost: 'sockjs.pusher.com',\n httpPort: 80,\n httpsPort: 443,\n httpPath: '/pusher',\n // DEPRECATED: Stats\n stats_host: 'stats.pusher.com',\n // DEPRECATED: Other settings\n authEndpoint: '/pusher/auth',\n authTransport: 'ajax',\n activityTimeout: 120000,\n pongTimeout: 30000,\n unavailableTimeout: 10000,\n userAuthentication: {\n endpoint: '/pusher/user-auth',\n transport: 'ajax'\n },\n channelAuthorization: {\n endpoint: '/pusher/auth',\n transport: 'ajax'\n },\n\n // CDN configuration\n cdn_http: CDN_HTTP,\n cdn_https: CDN_HTTPS,\n dependency_suffix: DEPENDENCY_SUFFIX\n};\n\nexport default Defaults;\n","import {\n ScriptReceivers,\n ScriptReceiverFactory\n} from './script_receiver_factory';\nimport Runtime from 'runtime';\nimport ScriptRequest from './script_request';\n\n/** Handles loading dependency files.\n *\n * Dependency loaders don't remember whether a resource has been loaded or\n * not. It is caller's responsibility to make sure the resource is not loaded\n * twice. This is because it's impossible to detect resource loading status\n * without knowing its content.\n *\n * Options:\n * - cdn_http - url to HTTP CND\n * - cdn_https - url to HTTPS CDN\n * - version - version of pusher-js\n * - suffix - suffix appended to all names of dependency files\n *\n * @param {Object} options\n */\nexport default class DependencyLoader {\n options: any;\n receivers: ScriptReceiverFactory;\n loading: any;\n\n constructor(options: any) {\n this.options = options;\n this.receivers = options.receivers || ScriptReceivers;\n this.loading = {};\n }\n\n /** Loads the dependency from CDN.\n *\n * @param {String} name\n * @param {Function} callback\n */\n load(name: string, options: any, callback: Function) {\n var self = this;\n\n if (self.loading[name] && self.loading[name].length > 0) {\n self.loading[name].push(callback);\n } else {\n self.loading[name] = [callback];\n\n var request = Runtime.createScriptRequest(self.getPath(name, options));\n var receiver = self.receivers.create(function(error) {\n self.receivers.remove(receiver);\n\n if (self.loading[name]) {\n var callbacks = self.loading[name];\n delete self.loading[name];\n\n var successCallback = function(wasSuccessful) {\n if (!wasSuccessful) {\n request.cleanup();\n }\n };\n for (var i = 0; i < callbacks.length; i++) {\n callbacks[i](error, successCallback);\n }\n }\n });\n request.send(receiver);\n }\n }\n\n /** Returns a root URL for pusher-js CDN.\n *\n * @returns {String}\n */\n getRoot(options: any): string {\n var cdn;\n var protocol = Runtime.getDocument().location.protocol;\n if ((options && options.useTLS) || protocol === 'https:') {\n cdn = this.options.cdn_https;\n } else {\n cdn = this.options.cdn_http;\n }\n // make sure there are no double slashes\n return cdn.replace(/\\/*$/, '') + '/' + this.options.version;\n }\n\n /** Returns a full path to a dependency file.\n *\n * @param {String} name\n * @returns {String}\n */\n getPath(name: string, options: any): string {\n return this.getRoot(options) + '/' + name + this.options.suffix + '.js';\n }\n}\n","import { ScriptReceiverFactory } from './script_receiver_factory';\nimport Defaults from 'core/defaults';\nimport DependencyLoader from './dependency_loader';\n\nexport var DependenciesReceivers = new ScriptReceiverFactory(\n '_pusher_dependencies',\n 'Pusher.DependenciesReceivers'\n);\n\nexport var Dependencies = new DependencyLoader({\n cdn_http: Defaults.cdn_http,\n cdn_https: Defaults.cdn_https,\n version: Defaults.VERSION,\n suffix: Defaults.dependency_suffix,\n receivers: DependenciesReceivers\n});\n","/**\n * A place to store help URLs for error messages etc\n */\n\nconst urlStore = {\n baseUrl: 'https://pusher.com',\n urls: {\n authenticationEndpoint: {\n path: '/docs/channels/server_api/authenticating_users'\n },\n authorizationEndpoint: {\n path: '/docs/channels/server_api/authorizing-users/'\n },\n javascriptQuickStart: {\n path: '/docs/javascript_quick_start'\n },\n triggeringClientEvents: {\n path: '/docs/client_api_guide/client_events#trigger-events'\n },\n encryptedChannelSupport: {\n fullUrl:\n 'https://github.com/pusher/pusher-js/tree/cc491015371a4bde5743d1c87a0fbac0feb53195#encrypted-channel-support'\n }\n }\n};\n\n/** Builds a consistent string with links to pusher documentation\n *\n * @param {string} key - relevant key in the url_store.urls object\n * @return {string} suffix string to append to log message\n */\nconst buildLogSuffix = function(key: string): string {\n const urlPrefix = 'See:';\n const urlObj = urlStore.urls[key];\n if (!urlObj) return '';\n\n let url;\n if (urlObj.fullUrl) {\n url = urlObj.fullUrl;\n } else if (urlObj.path) {\n url = urlStore.baseUrl + urlObj.path;\n }\n\n if (!url) return '';\n return `${urlPrefix} ${url}`;\n};\n\nexport default { buildLogSuffix };\n","export enum AuthRequestType {\n UserAuthentication = 'user-authentication',\n ChannelAuthorization = 'channel-authorization'\n}\n\nexport interface ChannelAuthorizationData {\n auth: string;\n channel_data?: string;\n shared_secret?: string;\n}\n\nexport type ChannelAuthorizationCallback = (\n error: Error | null,\n authData: ChannelAuthorizationData | null\n) => void;\n\nexport interface ChannelAuthorizationRequestParams {\n socketId: string;\n channelName: string;\n}\n\nexport interface ChannelAuthorizationHandler {\n (\n params: ChannelAuthorizationRequestParams,\n callback: ChannelAuthorizationCallback\n ): void;\n}\n\nexport interface UserAuthenticationData {\n auth: string;\n user_data: string;\n}\n\nexport type UserAuthenticationCallback = (\n error: Error | null,\n authData: UserAuthenticationData | null\n) => void;\n\nexport interface UserAuthenticationRequestParams {\n socketId: string;\n}\n\nexport interface UserAuthenticationHandler {\n (\n params: UserAuthenticationRequestParams,\n callback: UserAuthenticationCallback\n ): void;\n}\n\nexport type AuthTransportCallback =\n | ChannelAuthorizationCallback\n | UserAuthenticationCallback;\n\nexport interface AuthOptionsT {\n transport: 'ajax' | 'jsonp';\n endpoint: string;\n params?: any;\n headers?: any;\n paramsProvider?: () => any;\n headersProvider?: () => any;\n customHandler?: AuthHandler;\n}\n\nexport declare type UserAuthenticationOptions = AuthOptionsT<\n UserAuthenticationHandler\n>;\nexport declare type ChannelAuthorizationOptions = AuthOptionsT<\n ChannelAuthorizationHandler\n>;\n\nexport interface InternalAuthOptions {\n transport: 'ajax' | 'jsonp';\n endpoint: string;\n params?: any;\n headers?: any;\n paramsProvider?: () => any;\n headersProvider?: () => any;\n}\n","/** Error classes used throughout the library. */\n// https://github.com/Microsoft/TypeScript-wiki/blob/master/Breaking-Changes.md#extending-built-ins-like-error-array-and-map-may-no-longer-work\nexport class BadEventName extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\nexport class BadChannelName extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\nexport class RequestTimedOut extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class TransportPriorityTooLow extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class TransportClosed extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class UnsupportedFeature extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class UnsupportedTransport extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class UnsupportedStrategy extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class HTTPAuthError extends Error {\n status: number;\n constructor(status: number, msg?: string) {\n super(msg);\n this.status = status;\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n","import TimelineSender from 'core/timeline/timeline_sender';\nimport * as Collections from 'core/utils/collections';\nimport Util from 'core/util';\nimport Runtime from 'runtime';\nimport { AuthTransport } from 'core/auth/auth_transports';\nimport AbstractRuntime from 'runtimes/interface';\nimport UrlStore from 'core/utils/url_store';\nimport {\n AuthRequestType,\n AuthTransportCallback,\n InternalAuthOptions\n} from 'core/auth/options';\nimport { HTTPAuthError } from 'core/errors';\n\nconst ajax: AuthTransport = function(\n context: AbstractRuntime,\n query: string,\n authOptions: InternalAuthOptions,\n authRequestType: AuthRequestType,\n callback: AuthTransportCallback\n) {\n const xhr = Runtime.createXHR();\n xhr.open('POST', authOptions.endpoint, true);\n\n // add request headers\n xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');\n for (var headerName in authOptions.headers) {\n xhr.setRequestHeader(headerName, authOptions.headers[headerName]);\n }\n if (authOptions.headersProvider != null) {\n let dynamicHeaders = authOptions.headersProvider();\n for (var headerName in dynamicHeaders) {\n xhr.setRequestHeader(headerName, dynamicHeaders[headerName]);\n }\n }\n\n xhr.onreadystatechange = function() {\n if (xhr.readyState === 4) {\n if (xhr.status === 200) {\n let data;\n let parsed = false;\n\n try {\n data = JSON.parse(xhr.responseText);\n parsed = true;\n } catch (e) {\n callback(\n new HTTPAuthError(\n 200,\n `JSON returned from ${authRequestType.toString()} endpoint was invalid, yet status code was 200. Data was: ${\n xhr.responseText\n }`\n ),\n null\n );\n }\n\n if (parsed) {\n // prevents double execution.\n callback(null, data);\n }\n } else {\n let suffix = '';\n switch (authRequestType) {\n case AuthRequestType.UserAuthentication:\n suffix = UrlStore.buildLogSuffix('authenticationEndpoint');\n break;\n case AuthRequestType.ChannelAuthorization:\n suffix = `Clients must be authorized to join private or presence channels. ${UrlStore.buildLogSuffix(\n 'authorizationEndpoint'\n )}`;\n break;\n }\n callback(\n new HTTPAuthError(\n xhr.status,\n `Unable to retrieve auth string from ${authRequestType.toString()} endpoint - ` +\n `received status: ${xhr.status} from ${authOptions.endpoint}. ${suffix}`\n ),\n null\n );\n }\n }\n };\n\n xhr.send(query);\n return xhr;\n};\n\nexport default ajax;\n","export default function encode(s: any): string {\n return btoa(utob(s));\n}\n\nvar fromCharCode = String.fromCharCode;\n\nvar b64chars =\n 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';\nvar b64tab = {};\n\nfor (var i = 0, l = b64chars.length; i < l; i++) {\n b64tab[b64chars.charAt(i)] = i;\n}\n\nvar cb_utob = function(c) {\n var cc = c.charCodeAt(0);\n return cc < 0x80\n ? c\n : cc < 0x800\n ? fromCharCode(0xc0 | (cc >>> 6)) + fromCharCode(0x80 | (cc & 0x3f))\n : fromCharCode(0xe0 | ((cc >>> 12) & 0x0f)) +\n fromCharCode(0x80 | ((cc >>> 6) & 0x3f)) +\n fromCharCode(0x80 | (cc & 0x3f));\n};\n\nvar utob = function(u) {\n return u.replace(/[^\\x00-\\x7F]/g, cb_utob);\n};\n\nvar cb_encode = function(ccc) {\n var padlen = [0, 2, 1][ccc.length % 3];\n var ord =\n (ccc.charCodeAt(0) << 16) |\n ((ccc.length > 1 ? ccc.charCodeAt(1) : 0) << 8) |\n (ccc.length > 2 ? ccc.charCodeAt(2) : 0);\n var chars = [\n b64chars.charAt(ord >>> 18),\n b64chars.charAt((ord >>> 12) & 63),\n padlen >= 2 ? '=' : b64chars.charAt((ord >>> 6) & 63),\n padlen >= 1 ? '=' : b64chars.charAt(ord & 63)\n ];\n return chars.join('');\n};\n\nvar btoa =\n global.btoa ||\n function(b) {\n return b.replace(/[\\s\\S]{1,3}/g, cb_encode);\n };\n","import TimedCallback from './timed_callback';\nimport { Delay, Scheduler, Canceller } from './scheduling';\n\nabstract class Timer {\n protected clear: Canceller;\n protected timer: number | void;\n\n constructor(\n set: Scheduler,\n clear: Canceller,\n delay: Delay,\n callback: TimedCallback\n ) {\n this.clear = clear;\n this.timer = set(() => {\n if (this.timer) {\n this.timer = callback(this.timer);\n }\n }, delay);\n }\n\n /** Returns whether the timer is still running.\n *\n * @return {Boolean}\n */\n isRunning(): boolean {\n return this.timer !== null;\n }\n\n /** Aborts a timer when it's running. */\n ensureAborted() {\n if (this.timer) {\n this.clear(this.timer);\n this.timer = null;\n }\n }\n}\n\nexport default Timer;\n","import Timer from './abstract_timer';\nimport TimedCallback from './timed_callback';\nimport { Delay } from './scheduling';\n\n// We need to bind clear functions this way to avoid exceptions on IE8\nfunction clearTimeout(timer) {\n global.clearTimeout(timer);\n}\nfunction clearInterval(timer) {\n global.clearInterval(timer);\n}\n\n/** Cross-browser compatible one-off timer abstraction.\n *\n * @param {Number} delay\n * @param {Function} callback\n */\nexport class OneOffTimer extends Timer {\n constructor(delay: Delay, callback: TimedCallback) {\n super(setTimeout, clearTimeout, delay, function(timer) {\n callback();\n return null;\n });\n }\n}\n\n/** Cross-browser compatible periodic timer abstraction.\n *\n * @param {Number} delay\n * @param {Function} callback\n */\nexport class PeriodicTimer extends Timer {\n constructor(delay: Delay, callback: TimedCallback) {\n super(setInterval, clearInterval, delay, function(timer) {\n callback();\n return timer;\n });\n }\n}\n","import * as Collections from './utils/collections';\nimport TimedCallback from './utils/timers/timed_callback';\nimport { OneOffTimer, PeriodicTimer } from './utils/timers';\n\nvar Util = {\n now(): number {\n if (Date.now) {\n return Date.now();\n } else {\n return new Date().valueOf();\n }\n },\n\n defer(callback: TimedCallback): OneOffTimer {\n return new OneOffTimer(0, callback);\n },\n\n /** Builds a function that will proxy a method call to its first argument.\n *\n * Allows partial application of arguments, so additional arguments are\n * prepended to the argument list.\n *\n * @param {String} name method name\n * @return {Function} proxy function\n */\n method(name: string, ...args: any[]): Function {\n var boundArguments = Array.prototype.slice.call(arguments, 1);\n return function(object) {\n return object[name].apply(object, boundArguments.concat(arguments));\n };\n }\n};\n\nexport default Util;\n","import base64encode from '../base64';\nimport Util from '../util';\n\n/** Merges multiple objects into the target argument.\n *\n * For properties that are plain Objects, performs a deep-merge. For the\n * rest it just copies the value of the property.\n *\n * To extend prototypes use it as following:\n * Pusher.Util.extend(Target.prototype, Base.prototype)\n *\n * You can also use it to merge objects without altering them:\n * Pusher.Util.extend({}, object1, object2)\n *\n * @param {Object} target\n * @return {Object} the target argument\n */\nexport function extend(target: any, ...sources: any[]): T {\n for (var i = 0; i < sources.length; i++) {\n var extensions = sources[i];\n for (var property in extensions) {\n if (\n extensions[property] &&\n extensions[property].constructor &&\n extensions[property].constructor === Object\n ) {\n target[property] = extend(target[property] || {}, extensions[property]);\n } else {\n target[property] = extensions[property];\n }\n }\n }\n return target;\n}\n\nexport function stringify(): string {\n var m = ['Pusher'];\n for (var i = 0; i < arguments.length; i++) {\n if (typeof arguments[i] === 'string') {\n m.push(arguments[i]);\n } else {\n m.push(safeJSONStringify(arguments[i]));\n }\n }\n return m.join(' : ');\n}\n\nexport function arrayIndexOf(array: any[], item: any): number {\n // MSIE doesn't have array.indexOf\n var nativeIndexOf = Array.prototype.indexOf;\n if (array === null) {\n return -1;\n }\n if (nativeIndexOf && array.indexOf === nativeIndexOf) {\n return array.indexOf(item);\n }\n for (var i = 0, l = array.length; i < l; i++) {\n if (array[i] === item) {\n return i;\n }\n }\n return -1;\n}\n\n/** Applies a function f to all properties of an object.\n *\n * Function f gets 3 arguments passed:\n * - element from the object\n * - key of the element\n * - reference to the object\n *\n * @param {Object} object\n * @param {Function} f\n */\nexport function objectApply(object: any, f: Function) {\n for (var key in object) {\n if (Object.prototype.hasOwnProperty.call(object, key)) {\n f(object[key], key, object);\n }\n }\n}\n\n/** Return a list of objects own proerty keys\n *\n * @param {Object} object\n * @returns {Array}\n */\nexport function keys(object: any): string[] {\n var keys = [];\n objectApply(object, function(_, key) {\n keys.push(key);\n });\n return keys;\n}\n\n/** Return a list of object's own property values\n *\n * @param {Object} object\n * @returns {Array}\n */\nexport function values(object: any): any[] {\n var values = [];\n objectApply(object, function(value) {\n values.push(value);\n });\n return values;\n}\n\n/** Applies a function f to all elements of an array.\n *\n * Function f gets 3 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function apply(array: any[], f: Function, context?: any) {\n for (var i = 0; i < array.length; i++) {\n f.call(context || global, array[i], i, array);\n }\n}\n\n/** Maps all elements of the array and returns the result.\n *\n * Function f gets 4 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n * - reference to the destination array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function map(array: any[], f: Function): any[] {\n var result = [];\n for (var i = 0; i < array.length; i++) {\n result.push(f(array[i], i, array, result));\n }\n return result;\n}\n\n/** Maps all elements of the object and returns the result.\n *\n * Function f gets 4 arguments passed:\n * - element from the object\n * - key of the element\n * - reference to the source object\n * - reference to the destination object\n *\n * @param {Object} object\n * @param {Function} f\n */\nexport function mapObject(object: any, f: Function): any {\n var result = {};\n objectApply(object, function(value, key) {\n result[key] = f(value);\n });\n return result;\n}\n\n/** Filters elements of the array using a test function.\n *\n * Function test gets 4 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n * - reference to the destination array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function filter(array: any[], test: Function): any[] {\n test =\n test ||\n function(value) {\n return !!value;\n };\n\n var result = [];\n for (var i = 0; i < array.length; i++) {\n if (test(array[i], i, array, result)) {\n result.push(array[i]);\n }\n }\n return result;\n}\n\n/** Filters properties of the object using a test function.\n *\n * Function test gets 4 arguments passed:\n * - element from the object\n * - key of the element\n * - reference to the source object\n * - reference to the destination object\n *\n * @param {Object} object\n * @param {Function} f\n */\nexport function filterObject(object: Object, test: Function) {\n var result = {};\n objectApply(object, function(value, key) {\n if ((test && test(value, key, object, result)) || Boolean(value)) {\n result[key] = value;\n }\n });\n return result;\n}\n\n/** Flattens an object into a two-dimensional array.\n *\n * @param {Object} object\n * @return {Array} resulting array of [key, value] pairs\n */\nexport function flatten(object: Object): any[] {\n var result = [];\n objectApply(object, function(value, key) {\n result.push([key, value]);\n });\n return result;\n}\n\n/** Checks whether any element of the array passes the test.\n *\n * Function test gets 3 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function any(array: any[], test: Function): boolean {\n for (var i = 0; i < array.length; i++) {\n if (test(array[i], i, array)) {\n return true;\n }\n }\n return false;\n}\n\n/** Checks whether all elements of the array pass the test.\n *\n * Function test gets 3 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function all(array: any[], test: Function): boolean {\n for (var i = 0; i < array.length; i++) {\n if (!test(array[i], i, array)) {\n return false;\n }\n }\n return true;\n}\n\nexport function encodeParamsObject(data): string {\n return mapObject(data, function(value) {\n if (typeof value === 'object') {\n value = safeJSONStringify(value);\n }\n return encodeURIComponent(base64encode(value.toString()));\n });\n}\n\nexport function buildQueryString(data: any): string {\n var params = filterObject(data, function(value) {\n return value !== undefined;\n });\n\n var query = map(\n flatten(encodeParamsObject(params)),\n Util.method('join', '=')\n ).join('&');\n\n return query;\n}\n\n/**\n * See https://github.com/douglascrockford/JSON-js/blob/master/cycle.js\n *\n * Remove circular references from an object. Required for JSON.stringify in\n * React Native, which tends to blow up a lot.\n *\n * @param {any} object\n * @return {any} Decycled object\n */\nexport function decycleObject(object: any): any {\n var objects = [],\n paths = [];\n\n return (function derez(value, path) {\n var i, name, nu;\n\n switch (typeof value) {\n case 'object':\n if (!value) {\n return null;\n }\n for (i = 0; i < objects.length; i += 1) {\n if (objects[i] === value) {\n return { $ref: paths[i] };\n }\n }\n\n objects.push(value);\n paths.push(path);\n\n if (Object.prototype.toString.apply(value) === '[object Array]') {\n nu = [];\n for (i = 0; i < value.length; i += 1) {\n nu[i] = derez(value[i], path + '[' + i + ']');\n }\n } else {\n nu = {};\n for (name in value) {\n if (Object.prototype.hasOwnProperty.call(value, name)) {\n nu[name] = derez(\n value[name],\n path + '[' + JSON.stringify(name) + ']'\n );\n }\n }\n }\n return nu;\n case 'number':\n case 'string':\n case 'boolean':\n return value;\n }\n })(object, '$');\n}\n\n/**\n * Provides a cross-browser and cross-platform way to safely stringify objects\n * into JSON. This is particularly necessary for ReactNative, where circular JSON\n * structures throw an exception.\n *\n * @param {any} source The object to stringify\n * @return {string} The serialized output.\n */\nexport function safeJSONStringify(source: any): string {\n try {\n return JSON.stringify(source);\n } catch (e) {\n return JSON.stringify(decycleObject(source));\n }\n}\n","import { stringify } from './utils/collections';\nimport Pusher from './pusher';\n\nclass Logger {\n debug(...args: any[]) {\n this.log(this.globalLog, args);\n }\n\n warn(...args: any[]) {\n this.log(this.globalLogWarn, args);\n }\n\n error(...args: any[]) {\n this.log(this.globalLogError, args);\n }\n\n private globalLog = (message: string) => {\n if (global.console && global.console.log) {\n global.console.log(message);\n }\n };\n\n private globalLogWarn(message: string) {\n if (global.console && global.console.warn) {\n global.console.warn(message);\n } else {\n this.globalLog(message);\n }\n }\n\n private globalLogError(message: string) {\n if (global.console && global.console.error) {\n global.console.error(message);\n } else {\n this.globalLogWarn(message);\n }\n }\n\n private log(\n defaultLoggingFunction: (message: string) => void,\n ...args: any[]\n ) {\n var message = stringify.apply(this, arguments);\n if (Pusher.log) {\n Pusher.log(message);\n } else if (Pusher.logToConsole) {\n const log = defaultLoggingFunction.bind(this);\n log(message);\n }\n }\n}\n\nexport default new Logger();\n","import Browser from '../browser';\nimport Logger from 'core/logger';\nimport JSONPRequest from '../dom/jsonp_request';\nimport { ScriptReceivers } from '../dom/script_receiver_factory';\nimport { AuthTransport } from 'core/auth/auth_transports';\nimport {\n AuthRequestType,\n AuthTransportCallback,\n InternalAuthOptions\n} from 'core/auth/options';\n\nvar jsonp: AuthTransport = function(\n context: Browser,\n query: string,\n authOptions: InternalAuthOptions,\n authRequestType: AuthRequestType,\n callback: AuthTransportCallback\n) {\n if (\n authOptions.headers !== undefined ||\n authOptions.headersProvider != null\n ) {\n Logger.warn(\n `To send headers with the ${authRequestType.toString()} request, you must use AJAX, rather than JSONP.`\n );\n }\n\n var callbackName = context.nextAuthCallbackID.toString();\n context.nextAuthCallbackID++;\n\n var document = context.getDocument();\n var script = document.createElement('script');\n // Hacked wrapper.\n context.auth_callbacks[callbackName] = function(data) {\n callback(null, data);\n };\n\n var callback_name = \"Pusher.auth_callbacks['\" + callbackName + \"']\";\n script.src =\n authOptions.endpoint +\n '?callback=' +\n encodeURIComponent(callback_name) +\n '&' +\n query;\n\n var head =\n document.getElementsByTagName('head')[0] || document.documentElement;\n head.insertBefore(script, head.firstChild);\n};\n\nexport default jsonp;\n","import ScriptReceiver from './script_receiver';\n\n/** Sends a generic HTTP GET request using a script tag.\n *\n * By constructing URL in a specific way, it can be used for loading\n * JavaScript resources or JSONP requests. It can notify about errors, but\n * only in certain environments. Please take care of monitoring the state of\n * the request yourself.\n *\n * @param {String} src\n */\nexport default class ScriptRequest {\n src: string;\n script: any;\n errorScript: any;\n\n constructor(src: string) {\n this.src = src;\n }\n\n send(receiver: ScriptReceiver) {\n var self = this;\n var errorString = 'Error loading ' + self.src;\n\n self.script = document.createElement('script');\n self.script.id = receiver.id;\n self.script.src = self.src;\n self.script.type = 'text/javascript';\n self.script.charset = 'UTF-8';\n\n if (self.script.addEventListener) {\n self.script.onerror = function() {\n receiver.callback(errorString);\n };\n self.script.onload = function() {\n receiver.callback(null);\n };\n } else {\n self.script.onreadystatechange = function() {\n if (\n self.script.readyState === 'loaded' ||\n self.script.readyState === 'complete'\n ) {\n receiver.callback(null);\n }\n };\n }\n\n // Opera<11.6 hack for missing onerror callback\n if (\n self.script.async === undefined &&\n (document).attachEvent &&\n /opera/i.test(navigator.userAgent)\n ) {\n self.errorScript = document.createElement('script');\n self.errorScript.id = receiver.id + '_error';\n self.errorScript.text = receiver.name + \"('\" + errorString + \"');\";\n self.script.async = self.errorScript.async = false;\n } else {\n self.script.async = true;\n }\n\n var head = document.getElementsByTagName('head')[0];\n head.insertBefore(self.script, head.firstChild);\n if (self.errorScript) {\n head.insertBefore(self.errorScript, self.script.nextSibling);\n }\n }\n\n /** Cleans up the DOM remains of the script request. */\n cleanup() {\n if (this.script) {\n this.script.onload = this.script.onerror = null;\n this.script.onreadystatechange = null;\n }\n if (this.script && this.script.parentNode) {\n this.script.parentNode.removeChild(this.script);\n }\n if (this.errorScript && this.errorScript.parentNode) {\n this.errorScript.parentNode.removeChild(this.errorScript);\n }\n this.script = null;\n this.errorScript = null;\n }\n}\n","import ScriptReceiver from './script_receiver';\nimport ScriptRequest from './script_request';\nimport * as Collections from 'core/utils/collections';\nimport Util from 'core/util';\nimport Runtime from '../runtime';\n\n/** Sends data via JSONP.\n *\n * Data is a key-value map. Its values are JSON-encoded and then passed\n * through base64. Finally, keys and encoded values are appended to the query\n * string.\n *\n * The class itself does not guarantee raising errors on failures, as it's not\n * possible to support such feature on all browsers. Instead, JSONP endpoint\n * should call back in a way that's easy to distinguish from browser calls,\n * for example by passing a second argument to the receiver.\n *\n * @param {String} url\n * @param {Object} data key-value map of data to be submitted\n */\nexport default class JSONPRequest {\n url: string;\n data: any;\n request: ScriptRequest;\n\n constructor(url: string, data: any) {\n this.url = url;\n this.data = data;\n }\n\n /** Sends the actual JSONP request.\n *\n * @param {ScriptReceiver} receiver\n */\n send(receiver: ScriptReceiver) {\n if (this.request) {\n return;\n }\n\n var query = Collections.buildQueryString(this.data);\n var url = this.url + '/' + receiver.number + '?' + query;\n this.request = Runtime.createScriptRequest(url);\n this.request.send(receiver);\n }\n\n /** Cleans up the DOM remains of the JSONP request. */\n cleanup() {\n if (this.request) {\n this.request.cleanup();\n }\n }\n}\n","import TimelineSender from 'core/timeline/timeline_sender';\nimport TimelineTransport from 'core/timeline/timeline_transport';\nimport Browser from 'runtime';\nimport { AuthTransport } from 'core/auth/auth_transports';\nimport { ScriptReceivers } from '../dom/script_receiver_factory';\n\nvar getAgent = function(sender: TimelineSender, useTLS: boolean) {\n return function(data: any, callback: Function) {\n var scheme = 'http' + (useTLS ? 's' : '') + '://';\n var url =\n scheme + (sender.host || sender.options.host) + sender.options.path;\n var request = Browser.createJSONPRequest(url, data);\n\n var receiver = Browser.ScriptReceivers.create(function(error, result) {\n ScriptReceivers.remove(receiver);\n request.cleanup();\n\n if (result && result.host) {\n sender.host = result.host;\n }\n if (callback) {\n callback(error, result);\n }\n });\n request.send(receiver);\n };\n};\n\nvar jsonp = {\n name: 'jsonp',\n getAgent\n};\n\nexport default jsonp;\n","import Defaults from '../defaults';\nimport { default as URLScheme, URLSchemeParams } from './url_scheme';\n\nfunction getGenericURL(\n baseScheme: string,\n params: URLSchemeParams,\n path: string\n): string {\n var scheme = baseScheme + (params.useTLS ? 's' : '');\n var host = params.useTLS ? params.hostTLS : params.hostNonTLS;\n return scheme + '://' + host + path;\n}\n\nfunction getGenericPath(key: string, queryString?: string): string {\n var path = '/app/' + key;\n var query =\n '?protocol=' +\n Defaults.PROTOCOL +\n '&client=js' +\n '&version=' +\n Defaults.VERSION +\n (queryString ? '&' + queryString : '');\n return path + query;\n}\n\nexport var ws: URLScheme = {\n getInitial: function(key: string, params: URLSchemeParams): string {\n var path = (params.httpPath || '') + getGenericPath(key, 'flash=false');\n return getGenericURL('ws', params, path);\n }\n};\n\nexport var http: URLScheme = {\n getInitial: function(key: string, params: URLSchemeParams): string {\n var path = (params.httpPath || '/pusher') + getGenericPath(key);\n return getGenericURL('http', params, path);\n }\n};\n\nexport var sockjs: URLScheme = {\n getInitial: function(key: string, params: URLSchemeParams): string {\n return getGenericURL('http', params, params.httpPath || '/pusher');\n },\n getPath: function(key: string, params: URLSchemeParams): string {\n return getGenericPath(key);\n }\n};\n","import Callback from './callback';\nimport * as Collections from '../utils/collections';\nimport CallbackTable from './callback_table';\n\nexport default class CallbackRegistry {\n _callbacks: CallbackTable;\n\n constructor() {\n this._callbacks = {};\n }\n\n get(name: string): Callback[] {\n return this._callbacks[prefix(name)];\n }\n\n add(name: string, callback: Function, context: any) {\n var prefixedEventName = prefix(name);\n this._callbacks[prefixedEventName] =\n this._callbacks[prefixedEventName] || [];\n this._callbacks[prefixedEventName].push({\n fn: callback,\n context: context\n });\n }\n\n remove(name?: string, callback?: Function, context?: any) {\n if (!name && !callback && !context) {\n this._callbacks = {};\n return;\n }\n\n var names = name ? [prefix(name)] : Collections.keys(this._callbacks);\n\n if (callback || context) {\n this.removeCallback(names, callback, context);\n } else {\n this.removeAllCallbacks(names);\n }\n }\n\n private removeCallback(names: string[], callback: Function, context: any) {\n Collections.apply(\n names,\n function(name) {\n this._callbacks[name] = Collections.filter(\n this._callbacks[name] || [],\n function(binding) {\n return (\n (callback && callback !== binding.fn) ||\n (context && context !== binding.context)\n );\n }\n );\n if (this._callbacks[name].length === 0) {\n delete this._callbacks[name];\n }\n },\n this\n );\n }\n\n private removeAllCallbacks(names: string[]) {\n Collections.apply(\n names,\n function(name) {\n delete this._callbacks[name];\n },\n this\n );\n }\n}\n\nfunction prefix(name: string): string {\n return '_' + name;\n}\n","import * as Collections from '../utils/collections';\nimport Callback from './callback';\nimport Metadata from '../channels/metadata';\nimport CallbackRegistry from './callback_registry';\n\n/** Manages callback bindings and event emitting.\n *\n * @param Function failThrough called when no listeners are bound to an event\n */\nexport default class Dispatcher {\n callbacks: CallbackRegistry;\n global_callbacks: Function[];\n failThrough: Function;\n\n constructor(failThrough?: Function) {\n this.callbacks = new CallbackRegistry();\n this.global_callbacks = [];\n this.failThrough = failThrough;\n }\n\n bind(eventName: string, callback: Function, context?: any) {\n this.callbacks.add(eventName, callback, context);\n return this;\n }\n\n bind_global(callback: Function) {\n this.global_callbacks.push(callback);\n return this;\n }\n\n unbind(eventName?: string, callback?: Function, context?: any) {\n this.callbacks.remove(eventName, callback, context);\n return this;\n }\n\n unbind_global(callback?: Function) {\n if (!callback) {\n this.global_callbacks = [];\n return this;\n }\n\n this.global_callbacks = Collections.filter(\n this.global_callbacks || [],\n c => c !== callback\n );\n\n return this;\n }\n\n unbind_all() {\n this.unbind();\n this.unbind_global();\n return this;\n }\n\n emit(eventName: string, data?: any, metadata?: Metadata): Dispatcher {\n for (var i = 0; i < this.global_callbacks.length; i++) {\n this.global_callbacks[i](eventName, data);\n }\n\n var callbacks = this.callbacks.get(eventName);\n var args = [];\n\n if (metadata) {\n // if there's a metadata argument, we need to call the callback with both\n // data and metadata regardless of whether data is undefined\n args.push(data, metadata);\n } else if (data) {\n // metadata is undefined, so we only need to call the callback with data\n // if data exists\n args.push(data);\n }\n\n if (callbacks && callbacks.length > 0) {\n for (var i = 0; i < callbacks.length; i++) {\n callbacks[i].fn.apply(callbacks[i].context || global, args);\n }\n } else if (this.failThrough) {\n this.failThrough(eventName, data);\n }\n\n return this;\n }\n}\n","import Util from '../util';\nimport * as Collections from '../utils/collections';\nimport { default as EventsDispatcher } from '../events/dispatcher';\nimport Logger from '../logger';\nimport TransportHooks from './transport_hooks';\nimport Socket from '../socket';\nimport Runtime from 'runtime';\nimport Timeline from '../timeline/timeline';\nimport TransportConnectionOptions from './transport_connection_options';\n\n/** Provides universal API for transport connections.\n *\n * Transport connection is a low-level object that wraps a connection method\n * and exposes a simple evented interface for the connection state and\n * messaging. It does not implement Pusher-specific WebSocket protocol.\n *\n * Additionally, it fetches resources needed for transport to work and exposes\n * an interface for querying transport features.\n *\n * States:\n * - new - initial state after constructing the object\n * - initializing - during initialization phase, usually fetching resources\n * - intialized - ready to establish a connection\n * - connection - when connection is being established\n * - open - when connection ready to be used\n * - closed - after connection was closed be either side\n *\n * Emits:\n * - error - after the connection raised an error\n *\n * Options:\n * - useTLS - whether connection should be over TLS\n * - hostTLS - host to connect to when connection is over TLS\n * - hostNonTLS - host to connect to when connection is over TLS\n *\n * @param {String} key application key\n * @param {Object} options\n */\nexport default class TransportConnection extends EventsDispatcher {\n hooks: TransportHooks;\n name: string;\n priority: number;\n key: string;\n options: TransportConnectionOptions;\n state: string;\n timeline: Timeline;\n activityTimeout: number;\n id: number;\n socket: Socket;\n beforeOpen: Function;\n initialize: Function;\n\n constructor(\n hooks: TransportHooks,\n name: string,\n priority: number,\n key: string,\n options: TransportConnectionOptions\n ) {\n super();\n this.initialize = Runtime.transportConnectionInitializer;\n this.hooks = hooks;\n this.name = name;\n this.priority = priority;\n this.key = key;\n this.options = options;\n\n this.state = 'new';\n this.timeline = options.timeline;\n this.activityTimeout = options.activityTimeout;\n this.id = this.timeline.generateUniqueID();\n }\n\n /** Checks whether the transport handles activity checks by itself.\n *\n * @return {Boolean}\n */\n handlesActivityChecks(): boolean {\n return Boolean(this.hooks.handlesActivityChecks);\n }\n\n /** Checks whether the transport supports the ping/pong API.\n *\n * @return {Boolean}\n */\n supportsPing(): boolean {\n return Boolean(this.hooks.supportsPing);\n }\n\n /** Tries to establish a connection.\n *\n * @returns {Boolean} false if transport is in invalid state\n */\n connect(): boolean {\n if (this.socket || this.state !== 'initialized') {\n return false;\n }\n\n var url = this.hooks.urls.getInitial(this.key, this.options);\n try {\n this.socket = this.hooks.getSocket(url, this.options);\n } catch (e) {\n Util.defer(() => {\n this.onError(e);\n this.changeState('closed');\n });\n return false;\n }\n\n this.bindListeners();\n\n Logger.debug('Connecting', { transport: this.name, url });\n this.changeState('connecting');\n return true;\n }\n\n /** Closes the connection.\n *\n * @return {Boolean} true if there was a connection to close\n */\n close(): boolean {\n if (this.socket) {\n this.socket.close();\n return true;\n } else {\n return false;\n }\n }\n\n /** Sends data over the open connection.\n *\n * @param {String} data\n * @return {Boolean} true only when in the \"open\" state\n */\n send(data: any): boolean {\n if (this.state === 'open') {\n // Workaround for MobileSafari bug (see https://gist.github.com/2052006)\n Util.defer(() => {\n if (this.socket) {\n this.socket.send(data);\n }\n });\n return true;\n } else {\n return false;\n }\n }\n\n /** Sends a ping if the connection is open and transport supports it. */\n ping() {\n if (this.state === 'open' && this.supportsPing()) {\n this.socket.ping();\n }\n }\n\n private onOpen() {\n if (this.hooks.beforeOpen) {\n this.hooks.beforeOpen(\n this.socket,\n this.hooks.urls.getPath(this.key, this.options)\n );\n }\n this.changeState('open');\n this.socket.onopen = undefined;\n }\n\n private onError(error) {\n this.emit('error', { type: 'WebSocketError', error: error });\n this.timeline.error(this.buildTimelineMessage({ error: error.toString() }));\n }\n\n private onClose(closeEvent?: any) {\n if (closeEvent) {\n this.changeState('closed', {\n code: closeEvent.code,\n reason: closeEvent.reason,\n wasClean: closeEvent.wasClean\n });\n } else {\n this.changeState('closed');\n }\n this.unbindListeners();\n this.socket = undefined;\n }\n\n private onMessage(message) {\n this.emit('message', message);\n }\n\n private onActivity() {\n this.emit('activity');\n }\n\n private bindListeners() {\n this.socket.onopen = () => {\n this.onOpen();\n };\n this.socket.onerror = error => {\n this.onError(error);\n };\n this.socket.onclose = closeEvent => {\n this.onClose(closeEvent);\n };\n this.socket.onmessage = message => {\n this.onMessage(message);\n };\n\n if (this.supportsPing()) {\n this.socket.onactivity = () => {\n this.onActivity();\n };\n }\n }\n\n private unbindListeners() {\n if (this.socket) {\n this.socket.onopen = undefined;\n this.socket.onerror = undefined;\n this.socket.onclose = undefined;\n this.socket.onmessage = undefined;\n if (this.supportsPing()) {\n this.socket.onactivity = undefined;\n }\n }\n }\n\n private changeState(state: string, params?: any) {\n this.state = state;\n this.timeline.info(\n this.buildTimelineMessage({\n state: state,\n params: params\n })\n );\n this.emit(state, params);\n }\n\n buildTimelineMessage(message): any {\n return Collections.extend({ cid: this.id }, message);\n }\n}\n","import Factory from '../utils/factory';\nimport TransportHooks from './transport_hooks';\nimport TransportConnection from './transport_connection';\nimport TransportConnectionOptions from './transport_connection_options';\n\n/** Provides interface for transport connection instantiation.\n *\n * Takes transport-specific hooks as the only argument, which allow checking\n * for transport support and creating its connections.\n *\n * Supported hooks: * - file - the name of the file to be fetched during initialization\n * - urls - URL scheme to be used by transport\n * - handlesActivityCheck - true when the transport handles activity checks\n * - supportsPing - true when the transport has a ping/activity API\n * - isSupported - tells whether the transport is supported in the environment\n * - getSocket - creates a WebSocket-compatible transport socket\n *\n * See transports.js for specific implementations.\n *\n * @param {Object} hooks object containing all needed transport hooks\n */\nexport default class Transport {\n hooks: TransportHooks;\n\n constructor(hooks: TransportHooks) {\n this.hooks = hooks;\n }\n\n /** Returns whether the transport is supported in the environment.\n *\n * @param {Object} envronment te environment details (encryption, settings)\n * @returns {Boolean} true when the transport is supported\n */\n isSupported(environment: any): boolean {\n return this.hooks.isSupported(environment);\n }\n\n /** Creates a transport connection.\n *\n * @param {String} name\n * @param {Number} priority\n * @param {String} key the application key\n * @param {Object} options\n * @returns {TransportConnection}\n */\n createConnection(\n name: string,\n priority: number,\n key: string,\n options: any\n ): TransportConnection {\n return new TransportConnection(this.hooks, name, priority, key, options);\n }\n}\n","import * as URLSchemes from 'core/transports/url_schemes';\nimport URLScheme from 'core/transports/url_scheme';\nimport Transport from 'core/transports/transport';\nimport Util from 'core/util';\nimport * as Collections from 'core/utils/collections';\nimport TransportHooks from 'core/transports/transport_hooks';\nimport TransportsTable from 'core/transports/transports_table';\nimport Runtime from 'runtime';\n\n/** WebSocket transport.\n *\n * Uses native WebSocket implementation, including MozWebSocket supported by\n * earlier Firefox versions.\n */\nvar WSTransport = new Transport({\n urls: URLSchemes.ws,\n handlesActivityChecks: false,\n supportsPing: false,\n\n isInitialized: function() {\n return Boolean(Runtime.getWebSocketAPI());\n },\n isSupported: function(): boolean {\n return Boolean(Runtime.getWebSocketAPI());\n },\n getSocket: function(url) {\n return Runtime.createWebSocket(url);\n }\n});\n\nvar httpConfiguration = {\n urls: URLSchemes.http,\n handlesActivityChecks: false,\n supportsPing: true,\n isInitialized: function() {\n return true;\n }\n};\n\nexport var streamingConfiguration = Collections.extend(\n {\n getSocket: function(url) {\n return Runtime.HTTPFactory.createStreamingSocket(url);\n }\n },\n httpConfiguration\n);\nexport var pollingConfiguration = Collections.extend(\n {\n getSocket: function(url) {\n return Runtime.HTTPFactory.createPollingSocket(url);\n }\n },\n httpConfiguration\n);\n\nvar xhrConfiguration = {\n isSupported: function(): boolean {\n return Runtime.isXHRSupported();\n }\n};\n\n/** HTTP streaming transport using CORS-enabled XMLHttpRequest. */\nvar XHRStreamingTransport = new Transport(\n (\n Collections.extend({}, streamingConfiguration, xhrConfiguration)\n )\n);\n\n/** HTTP long-polling transport using CORS-enabled XMLHttpRequest. */\nvar XHRPollingTransport = new Transport(\n Collections.extend({}, pollingConfiguration, xhrConfiguration)\n);\n\nvar Transports: TransportsTable = {\n ws: WSTransport,\n xhr_streaming: XHRStreamingTransport,\n xhr_polling: XHRPollingTransport\n};\n\nexport default Transports;\n","import {\n default as Transports,\n streamingConfiguration,\n pollingConfiguration\n} from 'isomorphic/transports/transports';\nimport Transport from 'core/transports/transport';\nimport TransportHooks from 'core/transports/transport_hooks';\nimport * as URLSchemes from 'core/transports/url_schemes';\nimport Runtime from 'runtime';\nimport { Dependencies } from '../dom/dependencies';\nimport * as Collections from 'core/utils/collections';\n\nvar SockJSTransport = new Transport({\n file: 'sockjs',\n urls: URLSchemes.sockjs,\n handlesActivityChecks: true,\n supportsPing: false,\n\n isSupported: function() {\n return true;\n },\n isInitialized: function() {\n return window.SockJS !== undefined;\n },\n getSocket: function(url, options) {\n return new window.SockJS(url, null, {\n js_path: Dependencies.getPath('sockjs', {\n useTLS: options.useTLS\n }),\n ignore_null_origin: options.ignoreNullOrigin\n });\n },\n beforeOpen: function(socket, path) {\n socket.send(\n JSON.stringify({\n path: path\n })\n );\n }\n});\n\nvar xdrConfiguration = {\n isSupported: function(environment): boolean {\n var yes = Runtime.isXDRSupported(environment.useTLS);\n return yes;\n }\n};\n\n/** HTTP streaming transport using XDomainRequest (IE 8,9). */\nvar XDRStreamingTransport = new Transport(\n (\n Collections.extend({}, streamingConfiguration, xdrConfiguration)\n )\n);\n\n/** HTTP long-polling transport using XDomainRequest (IE 8,9). */\nvar XDRPollingTransport = new Transport(\n Collections.extend({}, pollingConfiguration, xdrConfiguration)\n);\n\nTransports.xdr_streaming = XDRStreamingTransport;\nTransports.xdr_polling = XDRPollingTransport;\nTransports.sockjs = SockJSTransport;\n\nexport default Transports;\n","import Reachability from 'core/reachability';\nimport { default as EventsDispatcher } from 'core/events/dispatcher';\n\n/** Really basic interface providing network availability info.\n *\n * Emits:\n * - online - when browser goes online\n * - offline - when browser goes offline\n */\nexport class NetInfo extends EventsDispatcher implements Reachability {\n constructor() {\n super();\n var self = this;\n // This is okay, as IE doesn't support this stuff anyway.\n if (window.addEventListener !== undefined) {\n window.addEventListener(\n 'online',\n function() {\n self.emit('online');\n },\n false\n );\n window.addEventListener(\n 'offline',\n function() {\n self.emit('offline');\n },\n false\n );\n }\n }\n\n /** Returns whether browser is online or not\n *\n * Offline means definitely offline (no connection to router).\n * Inverse does NOT mean definitely online (only currently supported in Safari\n * and even there only means the device has a connection to the router).\n *\n * @return {Boolean}\n */\n isOnline(): boolean {\n if (window.navigator.onLine === undefined) {\n return true;\n } else {\n return window.navigator.onLine;\n }\n }\n}\n\nexport var Network = new NetInfo();\n","import Util from '../util';\nimport * as Collections from '../utils/collections';\nimport TransportManager from './transport_manager';\nimport TransportConnection from './transport_connection';\nimport Transport from './transport';\nimport PingDelayOptions from './ping_delay_options';\n\n/** Creates transport connections monitored by a transport manager.\n *\n * When a transport is closed, it might mean the environment does not support\n * it. It's possible that messages get stuck in an intermediate buffer or\n * proxies terminate inactive connections. To combat these problems,\n * assistants monitor the connection lifetime, report unclean exits and\n * adjust ping timeouts to keep the connection active. The decision to disable\n * a transport is the manager's responsibility.\n *\n * @param {TransportManager} manager\n * @param {TransportConnection} transport\n * @param {Object} options\n */\nexport default class AssistantToTheTransportManager {\n manager: TransportManager;\n transport: Transport;\n minPingDelay: number;\n maxPingDelay: number;\n pingDelay: number;\n\n constructor(\n manager: TransportManager,\n transport: Transport,\n options: PingDelayOptions\n ) {\n this.manager = manager;\n this.transport = transport;\n this.minPingDelay = options.minPingDelay;\n this.maxPingDelay = options.maxPingDelay;\n this.pingDelay = undefined;\n }\n\n /** Creates a transport connection.\n *\n * This function has the same API as Transport#createConnection.\n *\n * @param {String} name\n * @param {Number} priority\n * @param {String} key the application key\n * @param {Object} options\n * @returns {TransportConnection}\n */\n createConnection(\n name: string,\n priority: number,\n key: string,\n options: Object\n ): TransportConnection {\n options = Collections.extend({}, options, {\n activityTimeout: this.pingDelay\n });\n var connection = this.transport.createConnection(\n name,\n priority,\n key,\n options\n );\n\n var openTimestamp = null;\n\n var onOpen = function() {\n connection.unbind('open', onOpen);\n connection.bind('closed', onClosed);\n openTimestamp = Util.now();\n };\n var onClosed = closeEvent => {\n connection.unbind('closed', onClosed);\n\n if (closeEvent.code === 1002 || closeEvent.code === 1003) {\n // we don't want to use transports not obeying the protocol\n this.manager.reportDeath();\n } else if (!closeEvent.wasClean && openTimestamp) {\n // report deaths only for short-living transport\n var lifespan = Util.now() - openTimestamp;\n if (lifespan < 2 * this.maxPingDelay) {\n this.manager.reportDeath();\n this.pingDelay = Math.max(lifespan / 2, this.minPingDelay);\n }\n }\n };\n\n connection.bind('open', onOpen);\n return connection;\n }\n\n /** Returns whether the transport is supported in the environment.\n *\n * This function has the same API as Transport#isSupported. Might return false\n * when the manager decides to kill the transport.\n *\n * @param {Object} environment the environment details (encryption, settings)\n * @returns {Boolean} true when the transport is supported\n */\n isSupported(environment: string): boolean {\n return this.manager.isAlive() && this.transport.isSupported(environment);\n }\n}\n","import Action from './action';\nimport { PusherEvent } from './message-types';\n/**\n * Provides functions for handling Pusher protocol-specific messages.\n */\n\nconst Protocol = {\n /**\n * Decodes a message in a Pusher format.\n *\n * The MessageEvent we receive from the transport should contain a pusher event\n * (https://pusher.com/docs/pusher_protocol#events) serialized as JSON in the\n * data field\n *\n * The pusher event may contain a data field too, and it may also be\n * serialised as JSON\n *\n * Throws errors when messages are not parse'able.\n *\n * @param {MessageEvent} messageEvent\n * @return {PusherEvent}\n */\n decodeMessage: function(messageEvent: MessageEvent): PusherEvent {\n try {\n var messageData = JSON.parse(messageEvent.data);\n var pusherEventData = messageData.data;\n if (typeof pusherEventData === 'string') {\n try {\n pusherEventData = JSON.parse(messageData.data);\n } catch (e) {}\n }\n var pusherEvent: PusherEvent = {\n event: messageData.event,\n channel: messageData.channel,\n data: pusherEventData\n };\n if (messageData.user_id) {\n pusherEvent.user_id = messageData.user_id;\n }\n return pusherEvent;\n } catch (e) {\n throw { type: 'MessageParseError', error: e, data: messageEvent.data };\n }\n },\n\n /**\n * Encodes a message to be sent.\n *\n * @param {PusherEvent} event\n * @return {String}\n */\n encodeMessage: function(event: PusherEvent): string {\n return JSON.stringify(event);\n },\n\n /**\n * Processes a handshake message and returns appropriate actions.\n *\n * Returns an object with an 'action' and other action-specific properties.\n *\n * There are three outcomes when calling this function. First is a successful\n * connection attempt, when pusher:connection_established is received, which\n * results in a 'connected' action with an 'id' property. When passed a\n * pusher:error event, it returns a result with action appropriate to the\n * close code and an error. Otherwise, it raises an exception.\n *\n * @param {String} message\n * @result Object\n */\n processHandshake: function(messageEvent: MessageEvent): Action {\n var message = Protocol.decodeMessage(messageEvent);\n\n if (message.event === 'pusher:connection_established') {\n if (!message.data.activity_timeout) {\n throw 'No activity timeout specified in handshake';\n }\n return {\n action: 'connected',\n id: message.data.socket_id,\n activityTimeout: message.data.activity_timeout * 1000\n };\n } else if (message.event === 'pusher:error') {\n // From protocol 6 close codes are sent only once, so this only\n // happens when connection does not support close codes\n return {\n action: this.getCloseAction(message.data),\n error: this.getCloseError(message.data)\n };\n } else {\n throw 'Invalid handshake';\n }\n },\n\n /**\n * Dispatches the close event and returns an appropriate action name.\n *\n * See:\n * 1. https://developer.mozilla.org/en-US/docs/WebSockets/WebSockets_reference/CloseEvent\n * 2. http://pusher.com/docs/pusher_protocol\n *\n * @param {CloseEvent} closeEvent\n * @return {String} close action name\n */\n getCloseAction: function(closeEvent): string {\n if (closeEvent.code < 4000) {\n // ignore 1000 CLOSE_NORMAL, 1001 CLOSE_GOING_AWAY,\n // 1005 CLOSE_NO_STATUS, 1006 CLOSE_ABNORMAL\n // ignore 1007...3999\n // handle 1002 CLOSE_PROTOCOL_ERROR, 1003 CLOSE_UNSUPPORTED,\n // 1004 CLOSE_TOO_LARGE\n if (closeEvent.code >= 1002 && closeEvent.code <= 1004) {\n return 'backoff';\n } else {\n return null;\n }\n } else if (closeEvent.code === 4000) {\n return 'tls_only';\n } else if (closeEvent.code < 4100) {\n return 'refused';\n } else if (closeEvent.code < 4200) {\n return 'backoff';\n } else if (closeEvent.code < 4300) {\n return 'retry';\n } else {\n // unknown error\n return 'refused';\n }\n },\n\n /**\n * Returns an error or null basing on the close event.\n *\n * Null is returned when connection was closed cleanly. Otherwise, an object\n * with error details is returned.\n *\n * @param {CloseEvent} closeEvent\n * @return {Object} error object\n */\n getCloseError: function(closeEvent): any {\n if (closeEvent.code !== 1000 && closeEvent.code !== 1001) {\n return {\n type: 'PusherError',\n data: {\n code: closeEvent.code,\n message: closeEvent.reason || closeEvent.message\n }\n };\n } else {\n return null;\n }\n }\n};\n\nexport default Protocol;\n","import * as Collections from '../utils/collections';\nimport { default as EventsDispatcher } from '../events/dispatcher';\nimport Protocol from './protocol/protocol';\nimport { PusherEvent } from './protocol/message-types';\nimport Logger from '../logger';\nimport TransportConnection from '../transports/transport_connection';\nimport Socket from '../socket';\n/**\n * Provides Pusher protocol interface for transports.\n *\n * Emits following events:\n * - message - on received messages\n * - ping - on ping requests\n * - pong - on pong responses\n * - error - when the transport emits an error\n * - closed - after closing the transport\n *\n * It also emits more events when connection closes with a code.\n * See Protocol.getCloseAction to get more details.\n *\n * @param {Number} id\n * @param {AbstractTransport} transport\n */\nexport default class Connection extends EventsDispatcher implements Socket {\n id: string;\n transport: TransportConnection;\n activityTimeout: number;\n\n constructor(id: string, transport: TransportConnection) {\n super();\n this.id = id;\n this.transport = transport;\n this.activityTimeout = transport.activityTimeout;\n this.bindListeners();\n }\n\n /** Returns whether used transport handles activity checks by itself\n *\n * @returns {Boolean} true if activity checks are handled by the transport\n */\n handlesActivityChecks() {\n return this.transport.handlesActivityChecks();\n }\n\n /** Sends raw data.\n *\n * @param {String} data\n */\n send(data: any): boolean {\n return this.transport.send(data);\n }\n\n /** Sends an event.\n *\n * @param {String} name\n * @param {String} data\n * @param {String} [channel]\n * @returns {Boolean} whether message was sent or not\n */\n send_event(name: string, data: any, channel?: string): boolean {\n var event: PusherEvent = { event: name, data: data };\n if (channel) {\n event.channel = channel;\n }\n Logger.debug('Event sent', event);\n return this.send(Protocol.encodeMessage(event));\n }\n\n /** Sends a ping message to the server.\n *\n * Basing on the underlying transport, it might send either transport's\n * protocol-specific ping or pusher:ping event.\n */\n ping() {\n if (this.transport.supportsPing()) {\n this.transport.ping();\n } else {\n this.send_event('pusher:ping', {});\n }\n }\n\n /** Closes the connection. */\n close() {\n this.transport.close();\n }\n\n private bindListeners() {\n var listeners = {\n message: (messageEvent: MessageEvent) => {\n var pusherEvent;\n try {\n pusherEvent = Protocol.decodeMessage(messageEvent);\n } catch (e) {\n this.emit('error', {\n type: 'MessageParseError',\n error: e,\n data: messageEvent.data\n });\n }\n\n if (pusherEvent !== undefined) {\n Logger.debug('Event recd', pusherEvent);\n\n switch (pusherEvent.event) {\n case 'pusher:error':\n this.emit('error', {\n type: 'PusherError',\n data: pusherEvent.data\n });\n break;\n case 'pusher:ping':\n this.emit('ping');\n break;\n case 'pusher:pong':\n this.emit('pong');\n break;\n }\n this.emit('message', pusherEvent);\n }\n },\n activity: () => {\n this.emit('activity');\n },\n error: error => {\n this.emit('error', error);\n },\n closed: closeEvent => {\n unbindListeners();\n\n if (closeEvent && closeEvent.code) {\n this.handleCloseEvent(closeEvent);\n }\n\n this.transport = null;\n this.emit('closed');\n }\n };\n\n var unbindListeners = () => {\n Collections.objectApply(listeners, (listener, event) => {\n this.transport.unbind(event, listener);\n });\n };\n\n Collections.objectApply(listeners, (listener, event) => {\n this.transport.bind(event, listener);\n });\n }\n\n private handleCloseEvent(closeEvent: any) {\n var action = Protocol.getCloseAction(closeEvent);\n var error = Protocol.getCloseError(closeEvent);\n if (error) {\n this.emit('error', error);\n }\n if (action) {\n this.emit(action, { action: action, error: error });\n }\n }\n}\n","import Util from '../../util';\nimport * as Collections from '../../utils/collections';\nimport Protocol from '../protocol/protocol';\nimport Connection from '../connection';\nimport TransportConnection from '../../transports/transport_connection';\nimport HandshakePayload from './handshake_payload';\n\n/**\n * Handles Pusher protocol handshakes for transports.\n *\n * Calls back with a result object after handshake is completed. Results\n * always have two fields:\n * - action - string describing action to be taken after the handshake\n * - transport - the transport object passed to the constructor\n *\n * Different actions can set different additional properties on the result.\n * In the case of 'connected' action, there will be a 'connection' property\n * containing a Connection object for the transport. Other actions should\n * carry an 'error' property.\n *\n * @param {AbstractTransport} transport\n * @param {Function} callback\n */\nexport default class Handshake {\n transport: TransportConnection;\n callback: (HandshakePayload) => void;\n onMessage: Function;\n onClosed: Function;\n\n constructor(\n transport: TransportConnection,\n callback: (HandshakePayload) => void\n ) {\n this.transport = transport;\n this.callback = callback;\n this.bindListeners();\n }\n\n close() {\n this.unbindListeners();\n this.transport.close();\n }\n\n private bindListeners() {\n this.onMessage = m => {\n this.unbindListeners();\n\n var result;\n try {\n result = Protocol.processHandshake(m);\n } catch (e) {\n this.finish('error', { error: e });\n this.transport.close();\n return;\n }\n\n if (result.action === 'connected') {\n this.finish('connected', {\n connection: new Connection(result.id, this.transport),\n activityTimeout: result.activityTimeout\n });\n } else {\n this.finish(result.action, { error: result.error });\n this.transport.close();\n }\n };\n\n this.onClosed = closeEvent => {\n this.unbindListeners();\n\n var action = Protocol.getCloseAction(closeEvent) || 'backoff';\n var error = Protocol.getCloseError(closeEvent);\n this.finish(action, { error: error });\n };\n\n this.transport.bind('message', this.onMessage);\n this.transport.bind('closed', this.onClosed);\n }\n\n private unbindListeners() {\n this.transport.unbind('message', this.onMessage);\n this.transport.unbind('closed', this.onClosed);\n }\n\n private finish(action: string, params: any) {\n this.callback(\n Collections.extend({ transport: this.transport, action: action }, params)\n );\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport base64encode from '../base64';\nimport Timeline from './timeline';\nimport Runtime from 'runtime';\n\nexport interface TimelineSenderOptions {\n host?: string;\n port?: number;\n path?: string;\n}\n\nexport default class TimelineSender {\n timeline: Timeline;\n options: TimelineSenderOptions;\n host: string;\n\n constructor(timeline: Timeline, options: TimelineSenderOptions) {\n this.timeline = timeline;\n this.options = options || {};\n }\n\n send(useTLS: boolean, callback?: Function) {\n if (this.timeline.isEmpty()) {\n return;\n }\n\n this.timeline.send(\n Runtime.TimelineTransport.getAgent(this, useTLS),\n callback\n );\n }\n}\n","import { default as EventsDispatcher } from '../events/dispatcher';\nimport * as Errors from '../errors';\nimport Logger from '../logger';\nimport Pusher from '../pusher';\nimport { PusherEvent } from '../connection/protocol/message-types';\nimport Metadata from './metadata';\nimport UrlStore from '../utils/url_store';\nimport {\n ChannelAuthorizationData,\n ChannelAuthorizationCallback\n} from '../auth/options';\nimport { HTTPAuthError } from '../errors';\n\n/** Provides base public channel interface with an event emitter.\n *\n * Emits:\n * - pusher:subscription_succeeded - after subscribing successfully\n * - other non-internal events\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\nexport default class Channel extends EventsDispatcher {\n name: string;\n pusher: Pusher;\n subscribed: boolean;\n subscriptionPending: boolean;\n subscriptionCancelled: boolean;\n subscriptionCount: null;\n\n constructor(name: string, pusher: Pusher) {\n super(function(event, data) {\n Logger.debug('No callbacks on ' + name + ' for ' + event);\n });\n\n this.name = name;\n this.pusher = pusher;\n this.subscribed = false;\n this.subscriptionPending = false;\n this.subscriptionCancelled = false;\n }\n\n /** Skips authorization, since public channels don't require it.\n *\n * @param {Function} callback\n */\n authorize(socketId: string, callback: ChannelAuthorizationCallback) {\n return callback(null, { auth: '' });\n }\n\n /** Triggers an event */\n trigger(event: string, data: any) {\n if (event.indexOf('client-') !== 0) {\n throw new Errors.BadEventName(\n \"Event '\" + event + \"' does not start with 'client-'\"\n );\n }\n if (!this.subscribed) {\n var suffix = UrlStore.buildLogSuffix('triggeringClientEvents');\n Logger.warn(\n `Client event triggered before channel 'subscription_succeeded' event . ${suffix}`\n );\n }\n return this.pusher.send_event(event, data, this.name);\n }\n\n /** Signals disconnection to the channel. For internal use only. */\n disconnect() {\n this.subscribed = false;\n this.subscriptionPending = false;\n }\n\n /** Handles a PusherEvent. For internal use only.\n *\n * @param {PusherEvent} event\n */\n handleEvent(event: PusherEvent) {\n var eventName = event.event;\n var data = event.data;\n if (eventName === 'pusher_internal:subscription_succeeded') {\n this.handleSubscriptionSucceededEvent(event);\n } else if (eventName === 'pusher_internal:subscription_count') {\n this.handleSubscriptionCountEvent(event);\n } else if (eventName.indexOf('pusher_internal:') !== 0) {\n var metadata: Metadata = {};\n this.emit(eventName, data, metadata);\n }\n }\n\n handleSubscriptionSucceededEvent(event: PusherEvent) {\n this.subscriptionPending = false;\n this.subscribed = true;\n if (this.subscriptionCancelled) {\n this.pusher.unsubscribe(this.name);\n } else {\n this.emit('pusher:subscription_succeeded', event.data);\n }\n }\n\n handleSubscriptionCountEvent(event: PusherEvent) {\n if (event.data.subscription_count) {\n this.subscriptionCount = event.data.subscription_count;\n }\n\n this.emit('pusher:subscription_count', event.data);\n }\n\n /** Sends a subscription request. For internal use only. */\n subscribe() {\n if (this.subscribed) {\n return;\n }\n this.subscriptionPending = true;\n this.subscriptionCancelled = false;\n this.authorize(\n this.pusher.connection.socket_id,\n (error: Error | null, data: ChannelAuthorizationData) => {\n if (error) {\n this.subscriptionPending = false;\n // Why not bind to 'pusher:subscription_error' a level up, and log there?\n // Binding to this event would cause the warning about no callbacks being\n // bound (see constructor) to be suppressed, that's not what we want.\n Logger.error(error.toString());\n this.emit(\n 'pusher:subscription_error',\n Object.assign(\n {},\n {\n type: 'AuthError',\n error: error.message\n },\n error instanceof HTTPAuthError ? { status: error.status } : {}\n )\n );\n } else {\n this.pusher.send_event('pusher:subscribe', {\n auth: data.auth,\n channel_data: data.channel_data,\n channel: this.name\n });\n }\n }\n );\n }\n\n /** Sends an unsubscription request. For internal use only. */\n unsubscribe() {\n this.subscribed = false;\n this.pusher.send_event('pusher:unsubscribe', {\n channel: this.name\n });\n }\n\n /** Cancels an in progress subscription. For internal use only. */\n cancelSubscription() {\n this.subscriptionCancelled = true;\n }\n\n /** Reinstates an in progress subscripiton. For internal use only. */\n reinstateSubscription() {\n this.subscriptionCancelled = false;\n }\n}\n","import Factory from '../utils/factory';\nimport Channel from './channel';\nimport { ChannelAuthorizationCallback } from '../auth/options';\n\n/** Extends public channels to provide private channel interface.\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\nexport default class PrivateChannel extends Channel {\n /** Authorizes the connection to use the channel.\n *\n * @param {String} socketId\n * @param {Function} callback\n */\n authorize(socketId: string, callback: ChannelAuthorizationCallback) {\n return this.pusher.config.channelAuthorizer(\n {\n channelName: this.name,\n socketId: socketId\n },\n callback\n );\n }\n}\n","import * as Collections from '../utils/collections';\n\n/** Represents a collection of members of a presence channel. */\nexport default class Members {\n members: any;\n count: number;\n myID: any;\n me: any;\n\n constructor() {\n this.reset();\n }\n\n /** Returns member's info for given id.\n *\n * Resulting object containts two fields - id and info.\n *\n * @param {Number} id\n * @return {Object} member's info or null\n */\n get(id: string): any {\n if (Object.prototype.hasOwnProperty.call(this.members, id)) {\n return {\n id: id,\n info: this.members[id]\n };\n } else {\n return null;\n }\n }\n\n /** Calls back for each member in unspecified order.\n *\n * @param {Function} callback\n */\n each(callback: Function) {\n Collections.objectApply(this.members, (member, id) => {\n callback(this.get(id));\n });\n }\n\n /** Updates the id for connected member. For internal use only. */\n setMyID(id: string) {\n this.myID = id;\n }\n\n /** Handles subscription data. For internal use only. */\n onSubscription(subscriptionData: any) {\n this.members = subscriptionData.presence.hash;\n this.count = subscriptionData.presence.count;\n this.me = this.get(this.myID);\n }\n\n /** Adds a new member to the collection. For internal use only. */\n addMember(memberData: any) {\n if (this.get(memberData.user_id) === null) {\n this.count++;\n }\n this.members[memberData.user_id] = memberData.user_info;\n return this.get(memberData.user_id);\n }\n\n /** Adds a member from the collection. For internal use only. */\n removeMember(memberData: any) {\n var member = this.get(memberData.user_id);\n if (member) {\n delete this.members[memberData.user_id];\n this.count--;\n }\n return member;\n }\n\n /** Resets the collection to the initial state. For internal use only. */\n reset() {\n this.members = {};\n this.count = 0;\n this.myID = null;\n this.me = null;\n }\n}\n","import PrivateChannel from './private_channel';\nimport Logger from '../logger';\nimport Members from './members';\nimport Pusher from '../pusher';\nimport UrlStore from 'core/utils/url_store';\nimport { PusherEvent } from '../connection/protocol/message-types';\nimport Metadata from './metadata';\nimport { ChannelAuthorizationData } from '../auth/options';\n\nexport default class PresenceChannel extends PrivateChannel {\n members: Members;\n\n /** Adds presence channel functionality to private channels.\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\n constructor(name: string, pusher: Pusher) {\n super(name, pusher);\n this.members = new Members();\n }\n\n /** Authorizes the connection as a member of the channel.\n *\n * @param {String} socketId\n * @param {Function} callback\n */\n authorize(socketId: string, callback: Function) {\n super.authorize(socketId, async (error, authData) => {\n if (!error) {\n authData = authData as ChannelAuthorizationData;\n if (authData.channel_data != null) {\n var channelData = JSON.parse(authData.channel_data);\n this.members.setMyID(channelData.user_id);\n } else {\n await this.pusher.user.signinDonePromise;\n if (this.pusher.user.user_data != null) {\n // If the user is signed in, get the id of the authenticated user\n // and allow the presence authorization to continue.\n this.members.setMyID(this.pusher.user.user_data.id);\n } else {\n let suffix = UrlStore.buildLogSuffix('authorizationEndpoint');\n Logger.error(\n `Invalid auth response for channel '${this.name}', ` +\n `expected 'channel_data' field. ${suffix}, ` +\n `or the user should be signed in.`\n );\n callback('Invalid auth response');\n return;\n }\n }\n }\n callback(error, authData);\n });\n }\n\n /** Handles presence and subscription events. For internal use only.\n *\n * @param {PusherEvent} event\n */\n handleEvent(event: PusherEvent) {\n var eventName = event.event;\n if (eventName.indexOf('pusher_internal:') === 0) {\n this.handleInternalEvent(event);\n } else {\n var data = event.data;\n var metadata: Metadata = {};\n if (event.user_id) {\n metadata.user_id = event.user_id;\n }\n this.emit(eventName, data, metadata);\n }\n }\n handleInternalEvent(event: PusherEvent) {\n var eventName = event.event;\n var data = event.data;\n switch (eventName) {\n case 'pusher_internal:subscription_succeeded':\n this.handleSubscriptionSucceededEvent(event);\n break;\n case 'pusher_internal:subscription_count':\n this.handleSubscriptionCountEvent(event);\n break;\n case 'pusher_internal:member_added':\n var addedMember = this.members.addMember(data);\n this.emit('pusher:member_added', addedMember);\n break;\n case 'pusher_internal:member_removed':\n var removedMember = this.members.removeMember(data);\n if (removedMember) {\n this.emit('pusher:member_removed', removedMember);\n }\n break;\n }\n }\n\n handleSubscriptionSucceededEvent(event: PusherEvent) {\n this.subscriptionPending = false;\n this.subscribed = true;\n if (this.subscriptionCancelled) {\n this.pusher.unsubscribe(this.name);\n } else {\n this.members.onSubscription(event.data);\n this.emit('pusher:subscription_succeeded', this.members);\n }\n }\n\n /** Resets the channel state, including members map. For internal use only. */\n disconnect() {\n this.members.reset();\n super.disconnect();\n }\n}\n","import PrivateChannel from './private_channel';\nimport * as Errors from '../errors';\nimport Logger from '../logger';\nimport Pusher from '../pusher';\nimport { decode as encodeUTF8 } from '@stablelib/utf8';\nimport { decode as decodeBase64 } from '@stablelib/base64';\nimport Dispatcher from '../events/dispatcher';\nimport { PusherEvent } from '../connection/protocol/message-types';\nimport {\n ChannelAuthorizationData,\n ChannelAuthorizationCallback\n} from '../auth/options';\nimport * as nacl from 'tweetnacl';\n\n/** Extends private channels to provide encrypted channel interface.\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\nexport default class EncryptedChannel extends PrivateChannel {\n key: Uint8Array = null;\n nacl: nacl;\n\n constructor(name: string, pusher: Pusher, nacl: nacl) {\n super(name, pusher);\n this.nacl = nacl;\n }\n\n /** Authorizes the connection to use the channel.\n *\n * @param {String} socketId\n * @param {Function} callback\n */\n authorize(socketId: string, callback: ChannelAuthorizationCallback) {\n super.authorize(\n socketId,\n (error: Error | null, authData: ChannelAuthorizationData) => {\n if (error) {\n callback(error, authData);\n return;\n }\n let sharedSecret = authData['shared_secret'];\n if (!sharedSecret) {\n callback(\n new Error(\n `No shared_secret key in auth payload for encrypted channel: ${this.name}`\n ),\n null\n );\n return;\n }\n this.key = decodeBase64(sharedSecret);\n delete authData['shared_secret'];\n callback(null, authData);\n }\n );\n }\n\n trigger(event: string, data: any): boolean {\n throw new Errors.UnsupportedFeature(\n 'Client events are not currently supported for encrypted channels'\n );\n }\n\n /** Handles an event. For internal use only.\n *\n * @param {PusherEvent} event\n */\n handleEvent(event: PusherEvent) {\n var eventName = event.event;\n var data = event.data;\n if (\n eventName.indexOf('pusher_internal:') === 0 ||\n eventName.indexOf('pusher:') === 0\n ) {\n super.handleEvent(event);\n return;\n }\n this.handleEncryptedEvent(eventName, data);\n }\n\n private handleEncryptedEvent(event: string, data: any): void {\n if (!this.key) {\n Logger.debug(\n 'Received encrypted event before key has been retrieved from the authEndpoint'\n );\n return;\n }\n if (!data.ciphertext || !data.nonce) {\n Logger.error(\n 'Unexpected format for encrypted event, expected object with `ciphertext` and `nonce` fields, got: ' +\n data\n );\n return;\n }\n let cipherText = decodeBase64(data.ciphertext);\n if (cipherText.length < this.nacl.secretbox.overheadLength) {\n Logger.error(\n `Expected encrypted event ciphertext length to be ${this.nacl.secretbox.overheadLength}, got: ${cipherText.length}`\n );\n return;\n }\n let nonce = decodeBase64(data.nonce);\n if (nonce.length < this.nacl.secretbox.nonceLength) {\n Logger.error(\n `Expected encrypted event nonce length to be ${this.nacl.secretbox.nonceLength}, got: ${nonce.length}`\n );\n return;\n }\n\n let bytes = this.nacl.secretbox.open(cipherText, nonce, this.key);\n if (bytes === null) {\n Logger.debug(\n 'Failed to decrypt an event, probably because it was encrypted with a different key. Fetching a new key from the authEndpoint...'\n );\n // Try a single time to retrieve a new auth key and decrypt the event with it\n // If this fails, a new key will be requested when a new message is received\n this.authorize(this.pusher.connection.socket_id, (error, authData) => {\n if (error) {\n Logger.error(\n `Failed to make a request to the authEndpoint: ${authData}. Unable to fetch new key, so dropping encrypted event`\n );\n return;\n }\n bytes = this.nacl.secretbox.open(cipherText, nonce, this.key);\n if (bytes === null) {\n Logger.error(\n `Failed to decrypt event with new key. Dropping encrypted event`\n );\n return;\n }\n this.emit(event, this.getDataToEmit(bytes));\n return;\n });\n return;\n }\n this.emit(event, this.getDataToEmit(bytes));\n }\n\n // Try and parse the decrypted bytes as JSON. If we can't parse it, just\n // return the utf-8 string\n getDataToEmit(bytes: Uint8Array): string {\n let raw = encodeUTF8(bytes);\n try {\n return JSON.parse(raw);\n } catch {\n return raw;\n }\n }\n}\n","import { default as EventsDispatcher } from '../events/dispatcher';\nimport { OneOffTimer as Timer } from '../utils/timers';\nimport { Config } from '../config';\nimport Logger from '../logger';\nimport HandshakePayload from './handshake/handshake_payload';\nimport Connection from './connection';\nimport Strategy from '../strategies/strategy';\nimport StrategyRunner from '../strategies/strategy_runner';\nimport * as Collections from '../utils/collections';\nimport Timeline from '../timeline/timeline';\nimport ConnectionManagerOptions from './connection_manager_options';\nimport Runtime from 'runtime';\n\nimport {\n ErrorCallbacks,\n HandshakeCallbacks,\n ConnectionCallbacks\n} from './callbacks';\nimport Action from './protocol/action';\n\n/** Manages connection to Pusher.\n *\n * Uses a strategy (currently only default), timers and network availability\n * info to establish a connection and export its state. In case of failures,\n * manages reconnection attempts.\n *\n * Exports state changes as following events:\n * - \"state_change\", { previous: p, current: state }\n * - state\n *\n * States:\n * - initialized - initial state, never transitioned to\n * - connecting - connection is being established\n * - connected - connection has been fully established\n * - disconnected - on requested disconnection\n * - unavailable - after connection timeout or when there's no network\n * - failed - when the connection strategy is not supported\n *\n * Options:\n * - unavailableTimeout - time to transition to unavailable state\n * - activityTimeout - time after which ping message should be sent\n * - pongTimeout - time for Pusher to respond with pong before reconnecting\n *\n * @param {String} key application key\n * @param {Object} options\n */\nexport default class ConnectionManager extends EventsDispatcher {\n key: string;\n options: ConnectionManagerOptions;\n state: string;\n connection: Connection;\n usingTLS: boolean;\n timeline: Timeline;\n socket_id: string;\n unavailableTimer: Timer;\n activityTimer: Timer;\n retryTimer: Timer;\n activityTimeout: number;\n strategy: Strategy;\n runner: StrategyRunner;\n errorCallbacks: ErrorCallbacks;\n handshakeCallbacks: HandshakeCallbacks;\n connectionCallbacks: ConnectionCallbacks;\n\n constructor(key: string, options: ConnectionManagerOptions) {\n super();\n this.state = 'initialized';\n this.connection = null;\n\n this.key = key;\n this.options = options;\n this.timeline = this.options.timeline;\n this.usingTLS = this.options.useTLS;\n\n this.errorCallbacks = this.buildErrorCallbacks();\n this.connectionCallbacks = this.buildConnectionCallbacks(\n this.errorCallbacks\n );\n this.handshakeCallbacks = this.buildHandshakeCallbacks(this.errorCallbacks);\n\n var Network = Runtime.getNetwork();\n\n Network.bind('online', () => {\n this.timeline.info({ netinfo: 'online' });\n if (this.state === 'connecting' || this.state === 'unavailable') {\n this.retryIn(0);\n }\n });\n Network.bind('offline', () => {\n this.timeline.info({ netinfo: 'offline' });\n if (this.connection) {\n this.sendActivityCheck();\n }\n });\n\n this.updateStrategy();\n }\n\n switchCluster(key: string) {\n this.key = key;\n // This ensures that the new config coming from\n // pusher instance are taken into account\n // such as appKey and cluster\n this.updateStrategy();\n this.retryIn(0);\n }\n\n /** Establishes a connection to Pusher.\n *\n * Does nothing when connection is already established. See top-level doc\n * to find events emitted on connection attempts.\n */\n connect() {\n if (this.connection || this.runner) {\n return;\n }\n if (!this.strategy.isSupported()) {\n this.updateState('failed');\n return;\n }\n this.updateState('connecting');\n this.startConnecting();\n this.setUnavailableTimer();\n }\n\n /** Sends raw data.\n *\n * @param {String} data\n */\n send(data) {\n if (this.connection) {\n return this.connection.send(data);\n } else {\n return false;\n }\n }\n\n /** Sends an event.\n *\n * @param {String} name\n * @param {String} data\n * @param {String} [channel]\n * @returns {Boolean} whether message was sent or not\n */\n send_event(name: string, data: any, channel?: string) {\n if (this.connection) {\n return this.connection.send_event(name, data, channel);\n } else {\n return false;\n }\n }\n\n /** Closes the connection. */\n disconnect() {\n this.disconnectInternally();\n this.updateState('disconnected');\n }\n\n isUsingTLS() {\n return this.usingTLS;\n }\n\n private startConnecting() {\n var callback = (error, handshake) => {\n if (error) {\n this.runner = this.strategy.connect(0, callback);\n } else {\n if (handshake.action === 'error') {\n this.emit('error', {\n type: 'HandshakeError',\n error: handshake.error\n });\n this.timeline.error({ handshakeError: handshake.error });\n } else {\n this.abortConnecting(); // we don't support switching connections yet\n this.handshakeCallbacks[handshake.action](handshake);\n }\n }\n };\n this.runner = this.strategy.connect(0, callback);\n }\n\n private abortConnecting() {\n if (this.runner) {\n this.runner.abort();\n this.runner = null;\n }\n }\n\n private disconnectInternally() {\n this.abortConnecting();\n this.clearRetryTimer();\n this.clearUnavailableTimer();\n if (this.connection) {\n var connection = this.abandonConnection();\n connection.close();\n }\n }\n\n private updateStrategy() {\n this.strategy = this.options.getStrategy({\n key: this.key,\n timeline: this.timeline,\n useTLS: this.usingTLS\n });\n }\n\n private retryIn(delay) {\n this.timeline.info({ action: 'retry', delay: delay });\n if (delay > 0) {\n this.emit('connecting_in', Math.round(delay / 1000));\n }\n this.retryTimer = new Timer(delay || 0, () => {\n this.disconnectInternally();\n this.connect();\n });\n }\n\n private clearRetryTimer() {\n if (this.retryTimer) {\n this.retryTimer.ensureAborted();\n this.retryTimer = null;\n }\n }\n\n private setUnavailableTimer() {\n this.unavailableTimer = new Timer(this.options.unavailableTimeout, () => {\n this.updateState('unavailable');\n });\n }\n\n private clearUnavailableTimer() {\n if (this.unavailableTimer) {\n this.unavailableTimer.ensureAborted();\n }\n }\n\n private sendActivityCheck() {\n this.stopActivityCheck();\n this.connection.ping();\n // wait for pong response\n this.activityTimer = new Timer(this.options.pongTimeout, () => {\n this.timeline.error({ pong_timed_out: this.options.pongTimeout });\n this.retryIn(0);\n });\n }\n\n private resetActivityCheck() {\n this.stopActivityCheck();\n // send ping after inactivity\n if (this.connection && !this.connection.handlesActivityChecks()) {\n this.activityTimer = new Timer(this.activityTimeout, () => {\n this.sendActivityCheck();\n });\n }\n }\n\n private stopActivityCheck() {\n if (this.activityTimer) {\n this.activityTimer.ensureAborted();\n }\n }\n\n private buildConnectionCallbacks(\n errorCallbacks: ErrorCallbacks\n ): ConnectionCallbacks {\n return Collections.extend({}, errorCallbacks, {\n message: message => {\n // includes pong messages from server\n this.resetActivityCheck();\n this.emit('message', message);\n },\n ping: () => {\n this.send_event('pusher:pong', {});\n },\n activity: () => {\n this.resetActivityCheck();\n },\n error: error => {\n // just emit error to user - socket will already be closed by browser\n this.emit('error', error);\n },\n closed: () => {\n this.abandonConnection();\n if (this.shouldRetry()) {\n this.retryIn(1000);\n }\n }\n });\n }\n\n private buildHandshakeCallbacks(\n errorCallbacks: ErrorCallbacks\n ): HandshakeCallbacks {\n return Collections.extend({}, errorCallbacks, {\n connected: (handshake: HandshakePayload) => {\n this.activityTimeout = Math.min(\n this.options.activityTimeout,\n handshake.activityTimeout,\n handshake.connection.activityTimeout || Infinity\n );\n this.clearUnavailableTimer();\n this.setConnection(handshake.connection);\n this.socket_id = this.connection.id;\n this.updateState('connected', { socket_id: this.socket_id });\n }\n });\n }\n\n private buildErrorCallbacks(): ErrorCallbacks {\n let withErrorEmitted = callback => {\n return (result: Action | HandshakePayload) => {\n if (result.error) {\n this.emit('error', { type: 'WebSocketError', error: result.error });\n }\n callback(result);\n };\n };\n\n return {\n tls_only: withErrorEmitted(() => {\n this.usingTLS = true;\n this.updateStrategy();\n this.retryIn(0);\n }),\n refused: withErrorEmitted(() => {\n this.disconnect();\n }),\n backoff: withErrorEmitted(() => {\n this.retryIn(1000);\n }),\n retry: withErrorEmitted(() => {\n this.retryIn(0);\n })\n };\n }\n\n private setConnection(connection) {\n this.connection = connection;\n for (var event in this.connectionCallbacks) {\n this.connection.bind(event, this.connectionCallbacks[event]);\n }\n this.resetActivityCheck();\n }\n\n private abandonConnection() {\n if (!this.connection) {\n return;\n }\n this.stopActivityCheck();\n for (var event in this.connectionCallbacks) {\n this.connection.unbind(event, this.connectionCallbacks[event]);\n }\n var connection = this.connection;\n this.connection = null;\n return connection;\n }\n\n private updateState(newState: string, data?: any) {\n var previousState = this.state;\n this.state = newState;\n if (previousState !== newState) {\n var newStateDescription = newState;\n if (newStateDescription === 'connected') {\n newStateDescription += ' with new socket ID ' + data.socket_id;\n }\n Logger.debug(\n 'State changed',\n previousState + ' -> ' + newStateDescription\n );\n this.timeline.info({ state: newState, params: data });\n this.emit('state_change', { previous: previousState, current: newState });\n this.emit(newState, data);\n }\n }\n\n private shouldRetry(): boolean {\n return this.state === 'connecting' || this.state === 'connected';\n }\n}\n","import Channel from './channel';\nimport * as Collections from '../utils/collections';\nimport ChannelTable from './channel_table';\nimport Factory from '../utils/factory';\nimport Pusher from '../pusher';\nimport Logger from '../logger';\nimport * as Errors from '../errors';\nimport urlStore from '../utils/url_store';\n\n/** Handles a channel map. */\nexport default class Channels {\n channels: ChannelTable;\n\n constructor() {\n this.channels = {};\n }\n\n /** Creates or retrieves an existing channel by its name.\n *\n * @param {String} name\n * @param {Pusher} pusher\n * @return {Channel}\n */\n add(name: string, pusher: Pusher) {\n if (!this.channels[name]) {\n this.channels[name] = createChannel(name, pusher);\n }\n return this.channels[name];\n }\n\n /** Returns a list of all channels\n *\n * @return {Array}\n */\n all(): Channel[] {\n return Collections.values(this.channels);\n }\n\n /** Finds a channel by its name.\n *\n * @param {String} name\n * @return {Channel} channel or null if it doesn't exist\n */\n find(name: string) {\n return this.channels[name];\n }\n\n /** Removes a channel from the map.\n *\n * @param {String} name\n */\n remove(name: string) {\n var channel = this.channels[name];\n delete this.channels[name];\n return channel;\n }\n\n /** Proxies disconnection signal to all channels. */\n disconnect() {\n Collections.objectApply(this.channels, function(channel) {\n channel.disconnect();\n });\n }\n}\n\nfunction createChannel(name: string, pusher: Pusher): Channel {\n if (name.indexOf('private-encrypted-') === 0) {\n if (pusher.config.nacl) {\n return Factory.createEncryptedChannel(name, pusher, pusher.config.nacl);\n }\n let errMsg =\n 'Tried to subscribe to a private-encrypted- channel but no nacl implementation available';\n let suffix = urlStore.buildLogSuffix('encryptedChannelSupport');\n throw new Errors.UnsupportedFeature(`${errMsg}. ${suffix}`);\n } else if (name.indexOf('private-') === 0) {\n return Factory.createPrivateChannel(name, pusher);\n } else if (name.indexOf('presence-') === 0) {\n return Factory.createPresenceChannel(name, pusher);\n } else if (name.indexOf('#') === 0) {\n throw new Errors.BadChannelName(\n 'Cannot create a channel with name \"' + name + '\".'\n );\n } else {\n return Factory.createChannel(name, pusher);\n }\n}\n","import AssistantToTheTransportManager from '../transports/assistant_to_the_transport_manager';\nimport PingDelayOptions from '../transports/ping_delay_options';\nimport Transport from '../transports/transport';\nimport TransportManager from '../transports/transport_manager';\nimport Handshake from '../connection/handshake';\nimport TransportConnection from '../transports/transport_connection';\nimport SocketHooks from '../http/socket_hooks';\nimport HTTPSocket from '../http/http_socket';\n\nimport Timeline from '../timeline/timeline';\nimport {\n default as TimelineSender,\n TimelineSenderOptions\n} from '../timeline/timeline_sender';\nimport PresenceChannel from '../channels/presence_channel';\nimport PrivateChannel from '../channels/private_channel';\nimport EncryptedChannel from '../channels/encrypted_channel';\nimport Channel from '../channels/channel';\nimport ConnectionManager from '../connection/connection_manager';\nimport ConnectionManagerOptions from '../connection/connection_manager_options';\nimport Ajax from '../http/ajax';\nimport Channels from '../channels/channels';\nimport Pusher from '../pusher';\nimport { Config } from '../config';\nimport * as nacl from 'tweetnacl';\n\nvar Factory = {\n createChannels(): Channels {\n return new Channels();\n },\n\n createConnectionManager(\n key: string,\n options: ConnectionManagerOptions\n ): ConnectionManager {\n return new ConnectionManager(key, options);\n },\n\n createChannel(name: string, pusher: Pusher): Channel {\n return new Channel(name, pusher);\n },\n\n createPrivateChannel(name: string, pusher: Pusher): PrivateChannel {\n return new PrivateChannel(name, pusher);\n },\n\n createPresenceChannel(name: string, pusher: Pusher): PresenceChannel {\n return new PresenceChannel(name, pusher);\n },\n\n createEncryptedChannel(\n name: string,\n pusher: Pusher,\n nacl: nacl\n ): EncryptedChannel {\n return new EncryptedChannel(name, pusher, nacl);\n },\n\n createTimelineSender(timeline: Timeline, options: TimelineSenderOptions) {\n return new TimelineSender(timeline, options);\n },\n\n createHandshake(\n transport: TransportConnection,\n callback: (HandshakePayload) => void\n ): Handshake {\n return new Handshake(transport, callback);\n },\n\n createAssistantToTheTransportManager(\n manager: TransportManager,\n transport: Transport,\n options: PingDelayOptions\n ): AssistantToTheTransportManager {\n return new AssistantToTheTransportManager(manager, transport, options);\n }\n};\n\nexport default Factory;\n","import AssistantToTheTransportManager from './assistant_to_the_transport_manager';\nimport Transport from './transport';\nimport PingDelayOptions from './ping_delay_options';\nimport Factory from '../utils/factory';\n\nexport interface TransportManagerOptions extends PingDelayOptions {\n lives?: number;\n}\n\n/** Keeps track of the number of lives left for a transport.\n *\n * In the beginning of a session, transports may be assigned a number of\n * lives. When an AssistantToTheTransportManager instance reports a transport\n * connection closed uncleanly, the transport loses a life. When the number\n * of lives drops to zero, the transport gets disabled by its manager.\n *\n * @param {Object} options\n */\nexport default class TransportManager {\n options: TransportManagerOptions;\n livesLeft: number;\n\n constructor(options: TransportManagerOptions) {\n this.options = options || {};\n this.livesLeft = this.options.lives || Infinity;\n }\n\n /** Creates a assistant for the transport.\n *\n * @param {Transport} transport\n * @returns {AssistantToTheTransportManager}\n */\n getAssistant(transport: Transport): AssistantToTheTransportManager {\n return Factory.createAssistantToTheTransportManager(this, transport, {\n minPingDelay: this.options.minPingDelay,\n maxPingDelay: this.options.maxPingDelay\n });\n }\n\n /** Returns whether the transport has any lives left.\n *\n * @returns {Boolean}\n */\n isAlive(): boolean {\n return this.livesLeft > 0;\n }\n\n /** Takes one life from the transport. */\n reportDeath() {\n this.livesLeft -= 1;\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport { OneOffTimer as Timer } from '../utils/timers';\nimport Strategy from './strategy';\nimport StrategyOptions from './strategy_options';\n\n/** Loops through strategies with optional timeouts.\n *\n * Options:\n * - loop - whether it should loop through the substrategy list\n * - timeout - initial timeout for a single substrategy\n * - timeoutLimit - maximum timeout\n *\n * @param {Strategy[]} strategies\n * @param {Object} options\n */\nexport default class SequentialStrategy implements Strategy {\n strategies: Strategy[];\n loop: boolean;\n failFast: boolean;\n timeout: number;\n timeoutLimit: number;\n\n constructor(strategies: Strategy[], options: StrategyOptions) {\n this.strategies = strategies;\n this.loop = Boolean(options.loop);\n this.failFast = Boolean(options.failFast);\n this.timeout = options.timeout;\n this.timeoutLimit = options.timeoutLimit;\n }\n\n isSupported(): boolean {\n return Collections.any(this.strategies, Util.method('isSupported'));\n }\n\n connect(minPriority: number, callback: Function) {\n var strategies = this.strategies;\n var current = 0;\n var timeout = this.timeout;\n var runner = null;\n\n var tryNextStrategy = (error, handshake) => {\n if (handshake) {\n callback(null, handshake);\n } else {\n current = current + 1;\n if (this.loop) {\n current = current % strategies.length;\n }\n\n if (current < strategies.length) {\n if (timeout) {\n timeout = timeout * 2;\n if (this.timeoutLimit) {\n timeout = Math.min(timeout, this.timeoutLimit);\n }\n }\n runner = this.tryStrategy(\n strategies[current],\n minPriority,\n { timeout, failFast: this.failFast },\n tryNextStrategy\n );\n } else {\n callback(true);\n }\n }\n };\n\n runner = this.tryStrategy(\n strategies[current],\n minPriority,\n { timeout: timeout, failFast: this.failFast },\n tryNextStrategy\n );\n\n return {\n abort: function() {\n runner.abort();\n },\n forceMinPriority: function(p) {\n minPriority = p;\n if (runner) {\n runner.forceMinPriority(p);\n }\n }\n };\n }\n\n private tryStrategy(\n strategy: Strategy,\n minPriority: number,\n options: StrategyOptions,\n callback: Function\n ) {\n var timer = null;\n var runner = null;\n\n if (options.timeout > 0) {\n timer = new Timer(options.timeout, function() {\n runner.abort();\n callback(true);\n });\n }\n\n runner = strategy.connect(minPriority, function(error, handshake) {\n if (error && timer && timer.isRunning() && !options.failFast) {\n // advance to the next strategy after the timeout\n return;\n }\n if (timer) {\n timer.ensureAborted();\n }\n callback(error, handshake);\n });\n\n return {\n abort: function() {\n if (timer) {\n timer.ensureAborted();\n }\n runner.abort();\n },\n forceMinPriority: function(p) {\n runner.forceMinPriority(p);\n }\n };\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport Strategy from './strategy';\n\n/** Launches all substrategies and emits prioritized connected transports.\n *\n * @param {Array} strategies\n */\nexport default class BestConnectedEverStrategy implements Strategy {\n strategies: Strategy[];\n\n constructor(strategies: Strategy[]) {\n this.strategies = strategies;\n }\n\n isSupported(): boolean {\n return Collections.any(this.strategies, Util.method('isSupported'));\n }\n\n connect(minPriority: number, callback: Function) {\n return connect(this.strategies, minPriority, function(i, runners) {\n return function(error, handshake) {\n runners[i].error = error;\n if (error) {\n if (allRunnersFailed(runners)) {\n callback(true);\n }\n return;\n }\n Collections.apply(runners, function(runner) {\n runner.forceMinPriority(handshake.transport.priority);\n });\n callback(null, handshake);\n };\n });\n }\n}\n\n/** Connects to all strategies in parallel.\n *\n * Callback builder should be a function that takes two arguments: index\n * and a list of runners. It should return another function that will be\n * passed to the substrategy with given index. Runners can be aborted using\n * abortRunner(s) functions from this class.\n *\n * @param {Array} strategies\n * @param {Function} callbackBuilder\n * @return {Object} strategy runner\n */\nfunction connect(\n strategies: Strategy[],\n minPriority: number,\n callbackBuilder: Function\n) {\n var runners = Collections.map(strategies, function(strategy, i, _, rs) {\n return strategy.connect(minPriority, callbackBuilder(i, rs));\n });\n return {\n abort: function() {\n Collections.apply(runners, abortRunner);\n },\n forceMinPriority: function(p) {\n Collections.apply(runners, function(runner) {\n runner.forceMinPriority(p);\n });\n }\n };\n}\n\nfunction allRunnersFailed(runners): boolean {\n return Collections.all(runners, function(runner) {\n return Boolean(runner.error);\n });\n}\n\nfunction abortRunner(runner) {\n if (!runner.error && !runner.aborted) {\n runner.abort();\n runner.aborted = true;\n }\n}\n","import Util from '../util';\nimport Runtime from 'runtime';\nimport Strategy from './strategy';\nimport SequentialStrategy from './sequential_strategy';\nimport StrategyOptions from './strategy_options';\nimport TransportStrategy from './transport_strategy';\nimport Timeline from '../timeline/timeline';\nimport * as Collections from '../utils/collections';\n\nexport interface TransportStrategyDictionary {\n [key: string]: TransportStrategy;\n}\n\n/** Caches the last successful transport and, after the first few attempts,\n * uses the cached transport for subsequent attempts.\n *\n * @param {Strategy} strategy\n * @param {Object} transports\n * @param {Object} options\n */\nexport default class WebSocketPrioritizedCachedStrategy implements Strategy {\n strategy: Strategy;\n transports: TransportStrategyDictionary;\n ttl: number;\n usingTLS: boolean;\n timeline: Timeline;\n\n constructor(\n strategy: Strategy,\n transports: TransportStrategyDictionary,\n options: StrategyOptions\n ) {\n this.strategy = strategy;\n this.transports = transports;\n this.ttl = options.ttl || 1800 * 1000;\n this.usingTLS = options.useTLS;\n this.timeline = options.timeline;\n }\n\n isSupported(): boolean {\n return this.strategy.isSupported();\n }\n\n connect(minPriority: number, callback: Function) {\n var usingTLS = this.usingTLS;\n var info = fetchTransportCache(usingTLS);\n var cacheSkipCount = info && info.cacheSkipCount ? info.cacheSkipCount : 0;\n\n var strategies = [this.strategy];\n if (info && info.timestamp + this.ttl >= Util.now()) {\n var transport = this.transports[info.transport];\n if (transport) {\n if (['ws', 'wss'].includes(info.transport) || cacheSkipCount > 3) {\n this.timeline.info({\n cached: true,\n transport: info.transport,\n latency: info.latency\n });\n strategies.push(\n new SequentialStrategy([transport], {\n timeout: info.latency * 2 + 1000,\n failFast: true\n })\n );\n } else {\n cacheSkipCount++;\n }\n }\n }\n\n var startTimestamp = Util.now();\n var runner = strategies\n .pop()\n .connect(minPriority, function cb(error, handshake) {\n if (error) {\n flushTransportCache(usingTLS);\n if (strategies.length > 0) {\n startTimestamp = Util.now();\n runner = strategies.pop().connect(minPriority, cb);\n } else {\n callback(error);\n }\n } else {\n storeTransportCache(\n usingTLS,\n handshake.transport.name,\n Util.now() - startTimestamp,\n cacheSkipCount\n );\n callback(null, handshake);\n }\n });\n\n return {\n abort: function() {\n runner.abort();\n },\n forceMinPriority: function(p) {\n minPriority = p;\n if (runner) {\n runner.forceMinPriority(p);\n }\n }\n };\n }\n}\n\nfunction getTransportCacheKey(usingTLS: boolean): string {\n return 'pusherTransport' + (usingTLS ? 'TLS' : 'NonTLS');\n}\n\nfunction fetchTransportCache(usingTLS: boolean): any {\n var storage = Runtime.getLocalStorage();\n if (storage) {\n try {\n var serializedCache = storage[getTransportCacheKey(usingTLS)];\n if (serializedCache) {\n return JSON.parse(serializedCache);\n }\n } catch (e) {\n flushTransportCache(usingTLS);\n }\n }\n return null;\n}\n\nfunction storeTransportCache(\n usingTLS: boolean,\n transport: TransportStrategy,\n latency: number,\n cacheSkipCount: number\n) {\n var storage = Runtime.getLocalStorage();\n if (storage) {\n try {\n storage[getTransportCacheKey(usingTLS)] = Collections.safeJSONStringify({\n timestamp: Util.now(),\n transport: transport,\n latency: latency,\n cacheSkipCount: cacheSkipCount\n });\n } catch (e) {\n // catch over quota exceptions raised by localStorage\n }\n }\n}\n\nfunction flushTransportCache(usingTLS: boolean) {\n var storage = Runtime.getLocalStorage();\n if (storage) {\n try {\n delete storage[getTransportCacheKey(usingTLS)];\n } catch (e) {\n // catch exceptions raised by localStorage\n }\n }\n}\n","import { OneOffTimer as Timer } from '../utils/timers';\nimport Strategy from './strategy';\nimport StrategyOptions from './strategy_options';\n\n/** Runs substrategy after specified delay.\n *\n * Options:\n * - delay - time in miliseconds to delay the substrategy attempt\n *\n * @param {Strategy} strategy\n * @param {Object} options\n */\nexport default class DelayedStrategy implements Strategy {\n strategy: Strategy;\n options: { delay: number };\n\n constructor(strategy: Strategy, { delay: number }) {\n this.strategy = strategy;\n this.options = { delay: number };\n }\n\n isSupported(): boolean {\n return this.strategy.isSupported();\n }\n\n connect(minPriority: number, callback: Function) {\n var strategy = this.strategy;\n var runner;\n var timer = new Timer(this.options.delay, function() {\n runner = strategy.connect(minPriority, callback);\n });\n\n return {\n abort: function() {\n timer.ensureAborted();\n if (runner) {\n runner.abort();\n }\n },\n forceMinPriority: function(p) {\n minPriority = p;\n if (runner) {\n runner.forceMinPriority(p);\n }\n }\n };\n }\n}\n","import Strategy from './strategy';\nimport StrategyRunner from './strategy_runner';\n\n/** Proxies method calls to one of substrategies basing on the test function.\n *\n * @param {Function} test\n * @param {Strategy} trueBranch strategy used when test returns true\n * @param {Strategy} falseBranch strategy used when test returns false\n */\nexport default class IfStrategy implements Strategy {\n test: () => boolean;\n trueBranch: Strategy;\n falseBranch: Strategy;\n\n constructor(\n test: () => boolean,\n trueBranch: Strategy,\n falseBranch: Strategy\n ) {\n this.test = test;\n this.trueBranch = trueBranch;\n this.falseBranch = falseBranch;\n }\n\n isSupported(): boolean {\n var branch = this.test() ? this.trueBranch : this.falseBranch;\n return branch.isSupported();\n }\n\n connect(minPriority: number, callback: Function): StrategyRunner {\n var branch = this.test() ? this.trueBranch : this.falseBranch;\n return branch.connect(minPriority, callback);\n }\n}\n","import Strategy from './strategy';\nimport StrategyRunner from './strategy_runner';\n\n/** Launches the substrategy and terminates on the first open connection.\n *\n * @param {Strategy} strategy\n */\nexport default class FirstConnectedStrategy implements Strategy {\n strategy: Strategy;\n\n constructor(strategy: Strategy) {\n this.strategy = strategy;\n }\n\n isSupported(): boolean {\n return this.strategy.isSupported();\n }\n\n connect(minPriority: number, callback: Function): StrategyRunner {\n var runner = this.strategy.connect(minPriority, function(error, handshake) {\n if (handshake) {\n runner.abort();\n }\n callback(error, handshake);\n });\n return runner;\n }\n}\n","import * as Collections from 'core/utils/collections';\nimport TransportManager from 'core/transports/transport_manager';\nimport Strategy from 'core/strategies/strategy';\nimport StrategyOptions from 'core/strategies/strategy_options';\nimport SequentialStrategy from 'core/strategies/sequential_strategy';\nimport BestConnectedEverStrategy from 'core/strategies/best_connected_ever_strategy';\nimport WebSocketPrioritizedCachedStrategy, {\n TransportStrategyDictionary\n} from 'core/strategies/websocket_prioritized_cached_strategy';\nimport DelayedStrategy from 'core/strategies/delayed_strategy';\nimport IfStrategy from 'core/strategies/if_strategy';\nimport FirstConnectedStrategy from 'core/strategies/first_connected_strategy';\nimport { Config } from 'core/config';\n\nfunction testSupportsStrategy(strategy: Strategy) {\n return function() {\n return strategy.isSupported();\n };\n}\n\nvar getDefaultStrategy = function(\n config: Config,\n baseOptions: StrategyOptions,\n defineTransport: Function\n): Strategy {\n var definedTransports = {};\n\n function defineTransportStrategy(\n name: string,\n type: string,\n priority: number,\n options: StrategyOptions,\n manager?: TransportManager\n ) {\n var transport = defineTransport(\n config,\n name,\n type,\n priority,\n options,\n manager\n );\n\n definedTransports[name] = transport;\n\n return transport;\n }\n\n var ws_options: StrategyOptions = Object.assign({}, baseOptions, {\n hostNonTLS: config.wsHost + ':' + config.wsPort,\n hostTLS: config.wsHost + ':' + config.wssPort,\n httpPath: config.wsPath\n });\n var wss_options: StrategyOptions = Object.assign({}, ws_options, {\n useTLS: true\n });\n var sockjs_options: StrategyOptions = Object.assign({}, baseOptions, {\n hostNonTLS: config.httpHost + ':' + config.httpPort,\n hostTLS: config.httpHost + ':' + config.httpsPort,\n httpPath: config.httpPath\n });\n\n var timeouts = {\n loop: true,\n timeout: 15000,\n timeoutLimit: 60000\n };\n\n var ws_manager = new TransportManager({\n minPingDelay: 10000,\n maxPingDelay: config.activityTimeout\n });\n var streaming_manager = new TransportManager({\n lives: 2,\n minPingDelay: 10000,\n maxPingDelay: config.activityTimeout\n });\n\n var ws_transport = defineTransportStrategy(\n 'ws',\n 'ws',\n 3,\n ws_options,\n ws_manager\n );\n var wss_transport = defineTransportStrategy(\n 'wss',\n 'ws',\n 3,\n wss_options,\n ws_manager\n );\n var sockjs_transport = defineTransportStrategy(\n 'sockjs',\n 'sockjs',\n 1,\n sockjs_options\n );\n var xhr_streaming_transport = defineTransportStrategy(\n 'xhr_streaming',\n 'xhr_streaming',\n 1,\n sockjs_options,\n streaming_manager\n );\n var xdr_streaming_transport = defineTransportStrategy(\n 'xdr_streaming',\n 'xdr_streaming',\n 1,\n sockjs_options,\n streaming_manager\n );\n var xhr_polling_transport = defineTransportStrategy(\n 'xhr_polling',\n 'xhr_polling',\n 1,\n sockjs_options\n );\n var xdr_polling_transport = defineTransportStrategy(\n 'xdr_polling',\n 'xdr_polling',\n 1,\n sockjs_options\n );\n\n var ws_loop = new SequentialStrategy([ws_transport], timeouts);\n var wss_loop = new SequentialStrategy([wss_transport], timeouts);\n var sockjs_loop = new SequentialStrategy([sockjs_transport], timeouts);\n var streaming_loop = new SequentialStrategy(\n [\n new IfStrategy(\n testSupportsStrategy(xhr_streaming_transport),\n xhr_streaming_transport,\n xdr_streaming_transport\n )\n ],\n timeouts\n );\n var polling_loop = new SequentialStrategy(\n [\n new IfStrategy(\n testSupportsStrategy(xhr_polling_transport),\n xhr_polling_transport,\n xdr_polling_transport\n )\n ],\n timeouts\n );\n\n var http_loop = new SequentialStrategy(\n [\n new IfStrategy(\n testSupportsStrategy(streaming_loop),\n new BestConnectedEverStrategy([\n streaming_loop,\n new DelayedStrategy(polling_loop, { delay: 4000 })\n ]),\n polling_loop\n )\n ],\n timeouts\n );\n\n var http_fallback_loop = new IfStrategy(\n testSupportsStrategy(http_loop),\n http_loop,\n sockjs_loop\n );\n\n var wsStrategy;\n if (baseOptions.useTLS) {\n wsStrategy = new BestConnectedEverStrategy([\n ws_loop,\n new DelayedStrategy(http_fallback_loop, { delay: 2000 })\n ]);\n } else {\n wsStrategy = new BestConnectedEverStrategy([\n ws_loop,\n new DelayedStrategy(wss_loop, { delay: 2000 }),\n new DelayedStrategy(http_fallback_loop, { delay: 5000 })\n ]);\n }\n\n return new WebSocketPrioritizedCachedStrategy(\n new FirstConnectedStrategy(\n new IfStrategy(\n testSupportsStrategy(ws_transport),\n wsStrategy,\n http_fallback_loop\n )\n ),\n definedTransports,\n {\n ttl: 1800000,\n timeline: baseOptions.timeline,\n useTLS: baseOptions.useTLS\n }\n );\n};\n\nexport default getDefaultStrategy;\n","import { Dependencies } from '../dom/dependencies';\n\n/** Initializes the transport.\n *\n * Fetches resources if needed and then transitions to initialized.\n */\nexport default function() {\n var self = this;\n\n self.timeline.info(\n self.buildTimelineMessage({\n transport: self.name + (self.options.useTLS ? 's' : '')\n })\n );\n\n if (self.hooks.isInitialized()) {\n self.changeState('initialized');\n } else if (self.hooks.file) {\n self.changeState('initializing');\n Dependencies.load(\n self.hooks.file,\n { useTLS: self.options.useTLS },\n function(error, callback) {\n if (self.hooks.isInitialized()) {\n self.changeState('initialized');\n callback(true);\n } else {\n if (error) {\n self.onError(error);\n }\n self.onClose();\n callback(false);\n }\n }\n );\n } else {\n self.onClose();\n }\n}\n","import HTTPRequest from 'core/http/http_request';\nimport RequestHooks from 'core/http/request_hooks';\nimport Ajax from 'core/http/ajax';\nimport * as Errors from 'core/errors';\n\nvar hooks: RequestHooks = {\n getRequest: function(socket: HTTPRequest): Ajax {\n var xdr = new (window).XDomainRequest();\n xdr.ontimeout = function() {\n socket.emit('error', new Errors.RequestTimedOut());\n socket.close();\n };\n xdr.onerror = function(e) {\n socket.emit('error', e);\n socket.close();\n };\n xdr.onprogress = function() {\n if (xdr.responseText && xdr.responseText.length > 0) {\n socket.onChunk(200, xdr.responseText);\n }\n };\n xdr.onload = function() {\n if (xdr.responseText && xdr.responseText.length > 0) {\n socket.onChunk(200, xdr.responseText);\n }\n socket.emit('finished', 200);\n socket.close();\n };\n return xdr;\n },\n abortRequest: function(xdr: Ajax) {\n xdr.ontimeout = xdr.onerror = xdr.onprogress = xdr.onload = null;\n xdr.abort();\n }\n};\n\nexport default hooks;\n","import Runtime from 'runtime';\nimport RequestHooks from './request_hooks';\nimport Ajax from './ajax';\nimport { default as EventsDispatcher } from '../events/dispatcher';\n\nconst MAX_BUFFER_LENGTH = 256 * 1024;\n\nexport default class HTTPRequest extends EventsDispatcher {\n hooks: RequestHooks;\n method: string;\n url: string;\n position: number;\n xhr: Ajax;\n unloader: Function;\n\n constructor(hooks: RequestHooks, method: string, url: string) {\n super();\n this.hooks = hooks;\n this.method = method;\n this.url = url;\n }\n\n start(payload?: any) {\n this.position = 0;\n this.xhr = this.hooks.getRequest(this);\n\n this.unloader = () => {\n this.close();\n };\n Runtime.addUnloadListener(this.unloader);\n\n this.xhr.open(this.method, this.url, true);\n\n if (this.xhr.setRequestHeader) {\n this.xhr.setRequestHeader('Content-Type', 'application/json'); // ReactNative doesn't set this header by default.\n }\n this.xhr.send(payload);\n }\n\n close() {\n if (this.unloader) {\n Runtime.removeUnloadListener(this.unloader);\n this.unloader = null;\n }\n if (this.xhr) {\n this.hooks.abortRequest(this.xhr);\n this.xhr = null;\n }\n }\n\n onChunk(status: number, data: any) {\n while (true) {\n var chunk = this.advanceBuffer(data);\n if (chunk) {\n this.emit('chunk', { status: status, data: chunk });\n } else {\n break;\n }\n }\n if (this.isBufferTooLong(data)) {\n this.emit('buffer_too_long');\n }\n }\n\n private advanceBuffer(buffer: any[]): any {\n var unreadData = buffer.slice(this.position);\n var endOfLinePosition = unreadData.indexOf('\\n');\n\n if (endOfLinePosition !== -1) {\n this.position += endOfLinePosition + 1;\n return unreadData.slice(0, endOfLinePosition);\n } else {\n // chunk is not finished yet, don't move the buffer pointer\n return null;\n }\n }\n\n private isBufferTooLong(buffer: any): boolean {\n return this.position === buffer.length && buffer.length > MAX_BUFFER_LENGTH;\n }\n}\n","enum State {\n CONNECTING = 0,\n OPEN = 1,\n CLOSED = 3\n}\n\nexport default State;\n","import URLLocation from './url_location';\nimport State from './state';\nimport Socket from '../socket';\nimport SocketHooks from './socket_hooks';\nimport Util from '../util';\nimport Ajax from './ajax';\nimport HTTPRequest from './http_request';\nimport Runtime from 'runtime';\n\nvar autoIncrement = 1;\n\nclass HTTPSocket implements Socket {\n hooks: SocketHooks;\n session: string;\n location: URLLocation;\n readyState: State;\n stream: HTTPRequest;\n\n onopen: () => void;\n onerror: (error: any) => void;\n onclose: (closeEvent: any) => void;\n onmessage: (message: any) => void;\n onactivity: () => void;\n\n constructor(hooks: SocketHooks, url: string) {\n this.hooks = hooks;\n this.session = randomNumber(1000) + '/' + randomString(8);\n this.location = getLocation(url);\n this.readyState = State.CONNECTING;\n this.openStream();\n }\n\n send(payload: any) {\n return this.sendRaw(JSON.stringify([payload]));\n }\n\n ping() {\n this.hooks.sendHeartbeat(this);\n }\n\n close(code: any, reason: any) {\n this.onClose(code, reason, true);\n }\n\n /** For internal use only */\n sendRaw(payload: any): boolean {\n if (this.readyState === State.OPEN) {\n try {\n Runtime.createSocketRequest(\n 'POST',\n getUniqueURL(getSendURL(this.location, this.session))\n ).start(payload);\n return true;\n } catch (e) {\n return false;\n }\n } else {\n return false;\n }\n }\n\n /** For internal use only */\n reconnect() {\n this.closeStream();\n this.openStream();\n }\n\n /** For internal use only */\n onClose(code, reason, wasClean) {\n this.closeStream();\n this.readyState = State.CLOSED;\n if (this.onclose) {\n this.onclose({\n code: code,\n reason: reason,\n wasClean: wasClean\n });\n }\n }\n\n private onChunk(chunk) {\n if (chunk.status !== 200) {\n return;\n }\n if (this.readyState === State.OPEN) {\n this.onActivity();\n }\n\n var payload;\n var type = chunk.data.slice(0, 1);\n switch (type) {\n case 'o':\n payload = JSON.parse(chunk.data.slice(1) || '{}');\n this.onOpen(payload);\n break;\n case 'a':\n payload = JSON.parse(chunk.data.slice(1) || '[]');\n for (var i = 0; i < payload.length; i++) {\n this.onEvent(payload[i]);\n }\n break;\n case 'm':\n payload = JSON.parse(chunk.data.slice(1) || 'null');\n this.onEvent(payload);\n break;\n case 'h':\n this.hooks.onHeartbeat(this);\n break;\n case 'c':\n payload = JSON.parse(chunk.data.slice(1) || '[]');\n this.onClose(payload[0], payload[1], true);\n break;\n }\n }\n\n private onOpen(options) {\n if (this.readyState === State.CONNECTING) {\n if (options && options.hostname) {\n this.location.base = replaceHost(this.location.base, options.hostname);\n }\n this.readyState = State.OPEN;\n\n if (this.onopen) {\n this.onopen();\n }\n } else {\n this.onClose(1006, 'Server lost session', true);\n }\n }\n\n private onEvent(event) {\n if (this.readyState === State.OPEN && this.onmessage) {\n this.onmessage({ data: event });\n }\n }\n\n private onActivity() {\n if (this.onactivity) {\n this.onactivity();\n }\n }\n\n private onError(error) {\n if (this.onerror) {\n this.onerror(error);\n }\n }\n\n private openStream() {\n this.stream = Runtime.createSocketRequest(\n 'POST',\n getUniqueURL(this.hooks.getReceiveURL(this.location, this.session))\n );\n\n this.stream.bind('chunk', chunk => {\n this.onChunk(chunk);\n });\n this.stream.bind('finished', status => {\n this.hooks.onFinished(this, status);\n });\n this.stream.bind('buffer_too_long', () => {\n this.reconnect();\n });\n\n try {\n this.stream.start();\n } catch (error) {\n Util.defer(() => {\n this.onError(error);\n this.onClose(1006, 'Could not start streaming', false);\n });\n }\n }\n\n private closeStream() {\n if (this.stream) {\n this.stream.unbind_all();\n this.stream.close();\n this.stream = null;\n }\n }\n}\n\nfunction getLocation(url): URLLocation {\n var parts = /([^\\?]*)\\/*(\\??.*)/.exec(url);\n return {\n base: parts[1],\n queryString: parts[2]\n };\n}\n\nfunction getSendURL(url: URLLocation, session: string): string {\n return url.base + '/' + session + '/xhr_send';\n}\n\nfunction getUniqueURL(url: string): string {\n var separator = url.indexOf('?') === -1 ? '?' : '&';\n return url + separator + 't=' + +new Date() + '&n=' + autoIncrement++;\n}\n\nfunction replaceHost(url: string, hostname: string): string {\n var urlParts = /(https?:\\/\\/)([^\\/:]+)((\\/|:)?.*)/.exec(url);\n return urlParts[1] + hostname + urlParts[3];\n}\n\nfunction randomNumber(max: number): number {\n return Runtime.randomInt(max);\n}\n\nfunction randomString(length: number): string {\n var result = [];\n\n for (var i = 0; i < length; i++) {\n result.push(randomNumber(32).toString(32));\n }\n\n return result.join('');\n}\n\nexport default HTTPSocket;\n","import SocketHooks from './socket_hooks';\nimport HTTPSocket from './http_socket';\n\nvar hooks: SocketHooks = {\n getReceiveURL: function(url, session) {\n return url.base + '/' + session + '/xhr_streaming' + url.queryString;\n },\n onHeartbeat: function(socket) {\n socket.sendRaw('[]');\n },\n sendHeartbeat: function(socket) {\n socket.sendRaw('[]');\n },\n onFinished: function(socket, status) {\n socket.onClose(1006, 'Connection interrupted (' + status + ')', false);\n }\n};\n\nexport default hooks;\n","import SocketHooks from './socket_hooks';\nimport URLLocation from './url_location';\nimport HTTPSocket from './http_socket';\n\nvar hooks: SocketHooks = {\n getReceiveURL: function(url: URLLocation, session: string): string {\n return url.base + '/' + session + '/xhr' + url.queryString;\n },\n onHeartbeat: function() {\n // next HTTP request will reset server's activity timer\n },\n sendHeartbeat: function(socket) {\n socket.sendRaw('[]');\n },\n onFinished: function(socket, status) {\n if (status === 200) {\n socket.reconnect();\n } else {\n socket.onClose(1006, 'Connection interrupted (' + status + ')', false);\n }\n }\n};\n\nexport default hooks;\n","import HTTPRequest from 'core/http/http_request';\nimport RequestHooks from 'core/http/request_hooks';\nimport Ajax from 'core/http/ajax';\nimport Runtime from 'runtime';\n\nvar hooks: RequestHooks = {\n getRequest: function(socket: HTTPRequest): Ajax {\n var Constructor = Runtime.getXHRAPI();\n var xhr = new Constructor();\n xhr.onreadystatechange = xhr.onprogress = function() {\n switch (xhr.readyState) {\n case 3:\n if (xhr.responseText && xhr.responseText.length > 0) {\n socket.onChunk(xhr.status, xhr.responseText);\n }\n break;\n case 4:\n // this happens only on errors, never after calling close\n if (xhr.responseText && xhr.responseText.length > 0) {\n socket.onChunk(xhr.status, xhr.responseText);\n }\n socket.emit('finished', xhr.status);\n socket.close();\n break;\n }\n };\n return xhr;\n },\n abortRequest: function(xhr: Ajax) {\n xhr.onreadystatechange = null;\n xhr.abort();\n }\n};\n\nexport default hooks;\n","import HTTPRequest from 'core/http/http_request';\nimport HTTPSocket from 'core/http/http_socket';\nimport SocketHooks from 'core/http/socket_hooks';\nimport RequestHooks from 'core/http/request_hooks';\nimport streamingHooks from 'core/http/http_streaming_socket';\nimport pollingHooks from 'core/http/http_polling_socket';\nimport xhrHooks from './http_xhr_request';\nimport HTTPFactory from 'core/http/http_factory';\n\nvar HTTP: HTTPFactory = {\n createStreamingSocket(url: string): HTTPSocket {\n return this.createSocket(streamingHooks, url);\n },\n\n createPollingSocket(url: string): HTTPSocket {\n return this.createSocket(pollingHooks, url);\n },\n\n createSocket(hooks: SocketHooks, url: string): HTTPSocket {\n return new HTTPSocket(hooks, url);\n },\n\n createXHR(method: string, url: string): HTTPRequest {\n return this.createRequest(xhrHooks, method, url);\n },\n\n createRequest(hooks: RequestHooks, method: string, url: string): HTTPRequest {\n return new HTTPRequest(hooks, method, url);\n }\n};\n\nexport default HTTP;\n","import xdrHooks from './http_xdomain_request';\nimport HTTP from 'isomorphic/http/http';\n\nHTTP.createXDR = function(method, url) {\n return this.createRequest(xdrHooks, method, url);\n};\n\nexport default HTTP;\n","import Browser from './browser';\nimport { Dependencies, DependenciesReceivers } from './dom/dependencies';\nimport { AuthTransport, AuthTransports } from 'core/auth/auth_transports';\nimport xhrAuth from 'isomorphic/auth/xhr_auth';\nimport jsonpAuth from './auth/jsonp_auth';\nimport TimelineTransport from 'core/timeline/timeline_transport';\nimport TimelineSender from 'core/timeline/timeline_sender';\nimport ScriptRequest from './dom/script_request';\nimport JSONPRequest from './dom/jsonp_request';\nimport * as Collections from 'core/utils/collections';\nimport { ScriptReceivers } from './dom/script_receiver_factory';\nimport jsonpTimeline from './timeline/jsonp_timeline';\nimport Transports from './transports/transports';\nimport Ajax from 'core/http/ajax';\nimport { Network } from './net_info';\nimport getDefaultStrategy from './default_strategy';\nimport transportConnectionInitializer from './transports/transport_connection_initializer';\nimport HTTPFactory from './http/http';\nimport HTTPRequest from 'core/http/http_request';\n\nvar Runtime: Browser = {\n // for jsonp auth\n nextAuthCallbackID: 1,\n auth_callbacks: {},\n ScriptReceivers,\n DependenciesReceivers,\n getDefaultStrategy,\n Transports,\n transportConnectionInitializer,\n HTTPFactory,\n\n TimelineTransport: jsonpTimeline,\n\n getXHRAPI() {\n return window.XMLHttpRequest;\n },\n\n getWebSocketAPI() {\n return window.WebSocket || window.MozWebSocket;\n },\n\n setup(PusherClass): void {\n (window).Pusher = PusherClass; // JSONp requires Pusher to be in the global scope.\n var initializeOnDocumentBody = () => {\n this.onDocumentBody(PusherClass.ready);\n };\n if (!(window).JSON) {\n Dependencies.load('json2', {}, initializeOnDocumentBody);\n } else {\n initializeOnDocumentBody();\n }\n },\n\n getDocument(): Document {\n return document;\n },\n\n getProtocol(): string {\n return this.getDocument().location.protocol;\n },\n\n getAuthorizers(): AuthTransports {\n return { ajax: xhrAuth, jsonp: jsonpAuth };\n },\n\n onDocumentBody(callback: Function) {\n if (document.body) {\n callback();\n } else {\n setTimeout(() => {\n this.onDocumentBody(callback);\n }, 0);\n }\n },\n\n createJSONPRequest(url: string, data: any): JSONPRequest {\n return new JSONPRequest(url, data);\n },\n\n createScriptRequest(src: string): ScriptRequest {\n return new ScriptRequest(src);\n },\n\n getLocalStorage() {\n try {\n return window.localStorage;\n } catch (e) {\n return undefined;\n }\n },\n\n createXHR(): Ajax {\n if (this.getXHRAPI()) {\n return this.createXMLHttpRequest();\n } else {\n return this.createMicrosoftXHR();\n }\n },\n\n createXMLHttpRequest(): Ajax {\n var Constructor = this.getXHRAPI();\n return new Constructor();\n },\n\n createMicrosoftXHR(): Ajax {\n return new ActiveXObject('Microsoft.XMLHTTP');\n },\n\n getNetwork() {\n return Network;\n },\n\n createWebSocket(url: string): any {\n var Constructor = this.getWebSocketAPI();\n return new Constructor(url);\n },\n\n createSocketRequest(method: string, url: string): HTTPRequest {\n if (this.isXHRSupported()) {\n return this.HTTPFactory.createXHR(method, url);\n } else if (this.isXDRSupported(url.indexOf('https:') === 0)) {\n return this.HTTPFactory.createXDR(method, url);\n } else {\n throw 'Cross-origin HTTP requests are not supported';\n }\n },\n\n isXHRSupported(): boolean {\n var Constructor = this.getXHRAPI();\n return (\n Boolean(Constructor) && new Constructor().withCredentials !== undefined\n );\n },\n\n isXDRSupported(useTLS?: boolean): boolean {\n var protocol = useTLS ? 'https:' : 'http:';\n var documentProtocol = this.getProtocol();\n return (\n Boolean(window['XDomainRequest']) && documentProtocol === protocol\n );\n },\n\n addUnloadListener(listener: any) {\n if (window.addEventListener !== undefined) {\n window.addEventListener('unload', listener, false);\n } else if (window.attachEvent !== undefined) {\n window.attachEvent('onunload', listener);\n }\n },\n\n removeUnloadListener(listener: any) {\n if (window.addEventListener !== undefined) {\n window.removeEventListener('unload', listener, false);\n } else if (window.detachEvent !== undefined) {\n window.detachEvent('onunload', listener);\n }\n },\n\n randomInt(max: number): number {\n /**\n * Return values in the range of [0, 1[\n */\n const random = function() {\n const crypto = window.crypto || window['msCrypto'];\n const random = crypto.getRandomValues(new Uint32Array(1))[0];\n\n return random / 2 ** 32;\n };\n\n return Math.floor(random() * max);\n }\n};\n\nexport default Runtime;\n","enum TimelineLevel {\n ERROR = 3,\n INFO = 6,\n DEBUG = 7\n}\n\nexport default TimelineLevel;\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport { default as Level } from './level';\n\nexport interface TimelineOptions {\n level?: Level;\n limit?: number;\n version?: string;\n cluster?: string;\n features?: string[];\n params?: any;\n}\n\nexport default class Timeline {\n key: string;\n session: number;\n events: any[];\n options: TimelineOptions;\n sent: number;\n uniqueID: number;\n\n constructor(key: string, session: number, options: TimelineOptions) {\n this.key = key;\n this.session = session;\n this.events = [];\n this.options = options || {};\n this.sent = 0;\n this.uniqueID = 0;\n }\n\n log(level, event) {\n if (level <= this.options.level) {\n this.events.push(\n Collections.extend({}, event, { timestamp: Util.now() })\n );\n if (this.options.limit && this.events.length > this.options.limit) {\n this.events.shift();\n }\n }\n }\n\n error(event) {\n this.log(Level.ERROR, event);\n }\n\n info(event) {\n this.log(Level.INFO, event);\n }\n\n debug(event) {\n this.log(Level.DEBUG, event);\n }\n\n isEmpty() {\n return this.events.length === 0;\n }\n\n send(sendfn, callback) {\n var data = Collections.extend(\n {\n session: this.session,\n bundle: this.sent + 1,\n key: this.key,\n lib: 'js',\n version: this.options.version,\n cluster: this.options.cluster,\n features: this.options.features,\n timeline: this.events\n },\n this.options.params\n );\n\n this.events = [];\n sendfn(data, (error, result) => {\n if (!error) {\n this.sent++;\n }\n if (callback) {\n callback(error, result);\n }\n });\n\n return true;\n }\n\n generateUniqueID(): number {\n this.uniqueID++;\n return this.uniqueID;\n }\n}\n","import Factory from '../utils/factory';\nimport Util from '../util';\nimport * as Errors from '../errors';\nimport * as Collections from '../utils/collections';\nimport Strategy from './strategy';\nimport Transport from '../transports/transport';\nimport StrategyOptions from './strategy_options';\nimport Handshake from '../connection/handshake';\n\n/** Provides a strategy interface for transports.\n *\n * @param {String} name\n * @param {Number} priority\n * @param {Class} transport\n * @param {Object} options\n */\nexport default class TransportStrategy implements Strategy {\n name: string;\n priority: number;\n transport: Transport;\n options: StrategyOptions;\n\n constructor(\n name: string,\n priority: number,\n transport: Transport,\n options: StrategyOptions\n ) {\n this.name = name;\n this.priority = priority;\n this.transport = transport;\n this.options = options || {};\n }\n\n /** Returns whether the transport is supported in the browser.\n *\n * @returns {Boolean}\n */\n isSupported(): boolean {\n return this.transport.isSupported({\n useTLS: this.options.useTLS\n });\n }\n\n /** Launches a connection attempt and returns a strategy runner.\n *\n * @param {Function} callback\n * @return {Object} strategy runner\n */\n connect(minPriority: number, callback: Function) {\n if (!this.isSupported()) {\n return failAttempt(new Errors.UnsupportedStrategy(), callback);\n } else if (this.priority < minPriority) {\n return failAttempt(new Errors.TransportPriorityTooLow(), callback);\n }\n\n var connected = false;\n var transport = this.transport.createConnection(\n this.name,\n this.priority,\n this.options.key,\n this.options\n );\n var handshake = null;\n\n var onInitialized = function() {\n transport.unbind('initialized', onInitialized);\n transport.connect();\n };\n var onOpen = function() {\n handshake = Factory.createHandshake(transport, function(result) {\n connected = true;\n unbindListeners();\n callback(null, result);\n });\n };\n var onError = function(error) {\n unbindListeners();\n callback(error);\n };\n var onClosed = function() {\n unbindListeners();\n var serializedTransport;\n\n // The reason for this try/catch block is that on React Native\n // the WebSocket object is circular. Therefore transport.socket will\n // throw errors upon stringification. Collections.safeJSONStringify\n // discards circular references when serializing.\n serializedTransport = Collections.safeJSONStringify(transport);\n callback(new Errors.TransportClosed(serializedTransport));\n };\n\n var unbindListeners = function() {\n transport.unbind('initialized', onInitialized);\n transport.unbind('open', onOpen);\n transport.unbind('error', onError);\n transport.unbind('closed', onClosed);\n };\n\n transport.bind('initialized', onInitialized);\n transport.bind('open', onOpen);\n transport.bind('error', onError);\n transport.bind('closed', onClosed);\n\n // connect will be called automatically after initialization\n transport.initialize();\n\n return {\n abort: () => {\n if (connected) {\n return;\n }\n unbindListeners();\n if (handshake) {\n handshake.close();\n } else {\n transport.close();\n }\n },\n forceMinPriority: p => {\n if (connected) {\n return;\n }\n if (this.priority < p) {\n if (handshake) {\n handshake.close();\n } else {\n transport.close();\n }\n }\n }\n };\n }\n}\n\nfunction failAttempt(error: Error, callback: Function) {\n Util.defer(function() {\n callback(error);\n });\n return {\n abort: function() {},\n forceMinPriority: function() {}\n };\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport TransportManager from '../transports/transport_manager';\nimport * as Errors from '../errors';\nimport Strategy from './strategy';\nimport TransportStrategy from './transport_strategy';\nimport StrategyOptions from '../strategies/strategy_options';\nimport { Config } from '../config';\nimport Runtime from 'runtime';\n\nconst { Transports } = Runtime;\n\nexport var defineTransport = function(\n config: Config,\n name: string,\n type: string,\n priority: number,\n options: StrategyOptions,\n manager?: TransportManager\n): Strategy {\n var transportClass = Transports[type];\n if (!transportClass) {\n throw new Errors.UnsupportedTransport(type);\n }\n\n var enabled =\n (!config.enabledTransports ||\n Collections.arrayIndexOf(config.enabledTransports, name) !== -1) &&\n (!config.disabledTransports ||\n Collections.arrayIndexOf(config.disabledTransports, name) === -1);\n\n var transport;\n if (enabled) {\n options = Object.assign(\n { ignoreNullOrigin: config.ignoreNullOrigin },\n options\n );\n\n transport = new TransportStrategy(\n name,\n priority,\n manager ? manager.getAssistant(transportClass) : transportClass,\n options\n );\n } else {\n transport = UnsupportedStrategy;\n }\n\n return transport;\n};\n\nvar UnsupportedStrategy: Strategy = {\n isSupported: function() {\n return false;\n },\n connect: function(_, callback) {\n var deferred = Util.defer(function() {\n callback(new Errors.UnsupportedStrategy());\n });\n return {\n abort: function() {\n deferred.ensureAborted();\n },\n forceMinPriority: function() {}\n };\n }\n};\n","import ConnectionManager from './connection/connection_manager';\nimport {\n ChannelAuthorizationOptions,\n UserAuthenticationOptions\n} from './auth/options';\nimport {\n ChannelAuthorizerGenerator,\n DeprecatedAuthOptions\n} from './auth/deprecated_channel_authorizer';\nimport { AuthTransport, Transport } from './config';\nimport * as nacl from 'tweetnacl';\nimport Logger from './logger';\n\nexport interface Options {\n activityTimeout?: number;\n\n auth?: DeprecatedAuthOptions; // DEPRECATED use channelAuthorization instead\n authEndpoint?: string; // DEPRECATED use channelAuthorization instead\n authTransport?: AuthTransport; // DEPRECATED use channelAuthorization instead\n authorizer?: ChannelAuthorizerGenerator; // DEPRECATED use channelAuthorization instead\n\n channelAuthorization?: ChannelAuthorizationOptions;\n userAuthentication?: UserAuthenticationOptions;\n\n cluster: string;\n enableStats?: boolean;\n disableStats?: boolean;\n disabledTransports?: Transport[];\n enabledTransports?: Transport[];\n forceTLS?: boolean;\n httpHost?: string;\n httpPath?: string;\n httpPort?: number;\n httpsPort?: number;\n ignoreNullOrigin?: boolean;\n nacl?: nacl;\n pongTimeout?: number;\n statsHost?: string;\n timelineParams?: any;\n unavailableTimeout?: number;\n wsHost?: string;\n wsPath?: string;\n wsPort?: number;\n wssPort?: number;\n}\n\nexport interface ClusterOptions {\n appKey: string;\n cluster: string;\n}\n\nexport function validateOptions(options) {\n if (options == null) {\n throw 'You must pass an options object';\n }\n if (options.cluster == null) {\n throw 'Options object must provide a cluster';\n }\n if ('disableStats' in options) {\n Logger.warn(\n 'The disableStats option is deprecated in favor of enableStats'\n );\n }\n}\n","import {\n UserAuthenticationCallback,\n InternalAuthOptions,\n UserAuthenticationHandler,\n UserAuthenticationRequestParams,\n AuthRequestType\n} from './options';\n\nimport Runtime from 'runtime';\n\nconst composeChannelQuery = (\n params: UserAuthenticationRequestParams,\n authOptions: InternalAuthOptions\n) => {\n var query = 'socket_id=' + encodeURIComponent(params.socketId);\n\n for (var key in authOptions.params) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(authOptions.params[key]);\n }\n\n if (authOptions.paramsProvider != null) {\n let dynamicParams = authOptions.paramsProvider();\n for (var key in dynamicParams) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(dynamicParams[key]);\n }\n }\n\n return query;\n};\n\nconst UserAuthenticator = (\n authOptions: InternalAuthOptions\n): UserAuthenticationHandler => {\n if (typeof Runtime.getAuthorizers()[authOptions.transport] === 'undefined') {\n throw `'${authOptions.transport}' is not a recognized auth transport`;\n }\n\n return (\n params: UserAuthenticationRequestParams,\n callback: UserAuthenticationCallback\n ) => {\n const query = composeChannelQuery(params, authOptions);\n\n Runtime.getAuthorizers()[authOptions.transport](\n Runtime,\n query,\n authOptions,\n AuthRequestType.UserAuthentication,\n callback\n );\n };\n};\n\nexport default UserAuthenticator;\n","import {\n AuthRequestType,\n InternalAuthOptions,\n ChannelAuthorizationHandler,\n ChannelAuthorizationRequestParams,\n ChannelAuthorizationCallback\n} from './options';\n\nimport Runtime from 'runtime';\n\nconst composeChannelQuery = (\n params: ChannelAuthorizationRequestParams,\n authOptions: InternalAuthOptions\n) => {\n var query = 'socket_id=' + encodeURIComponent(params.socketId);\n\n query += '&channel_name=' + encodeURIComponent(params.channelName);\n\n for (var key in authOptions.params) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(authOptions.params[key]);\n }\n\n if (authOptions.paramsProvider != null) {\n let dynamicParams = authOptions.paramsProvider();\n for (var key in dynamicParams) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(dynamicParams[key]);\n }\n }\n\n return query;\n};\n\nconst ChannelAuthorizer = (\n authOptions: InternalAuthOptions\n): ChannelAuthorizationHandler => {\n if (typeof Runtime.getAuthorizers()[authOptions.transport] === 'undefined') {\n throw `'${authOptions.transport}' is not a recognized auth transport`;\n }\n\n return (\n params: ChannelAuthorizationRequestParams,\n callback: ChannelAuthorizationCallback\n ) => {\n const query = composeChannelQuery(params, authOptions);\n\n Runtime.getAuthorizers()[authOptions.transport](\n Runtime,\n query,\n authOptions,\n AuthRequestType.ChannelAuthorization,\n callback\n );\n };\n};\n\nexport default ChannelAuthorizer;\n","import Channel from '../channels/channel';\nimport {\n ChannelAuthorizationCallback,\n ChannelAuthorizationHandler,\n ChannelAuthorizationRequestParams,\n InternalAuthOptions\n} from './options';\n\nexport interface DeprecatedChannelAuthorizer {\n authorize(socketId: string, callback: ChannelAuthorizationCallback): void;\n}\n\nexport interface ChannelAuthorizerGenerator {\n (\n channel: Channel,\n options: DeprecatedAuthorizerOptions\n ): DeprecatedChannelAuthorizer;\n}\n\nexport interface DeprecatedAuthOptions {\n params?: any;\n headers?: any;\n}\n\nexport interface DeprecatedAuthorizerOptions {\n authTransport: 'ajax' | 'jsonp';\n authEndpoint: string;\n auth?: DeprecatedAuthOptions;\n}\n\nexport const ChannelAuthorizerProxy = (\n pusher,\n authOptions: InternalAuthOptions,\n channelAuthorizerGenerator: ChannelAuthorizerGenerator\n): ChannelAuthorizationHandler => {\n const deprecatedAuthorizerOptions: DeprecatedAuthorizerOptions = {\n authTransport: authOptions.transport,\n authEndpoint: authOptions.endpoint,\n auth: {\n params: authOptions.params,\n headers: authOptions.headers\n }\n };\n return (\n params: ChannelAuthorizationRequestParams,\n callback: ChannelAuthorizationCallback\n ) => {\n const channel = pusher.channel(params.channelName);\n // This line creates a new channel authorizer every time.\n // In the past, this was only done once per channel and reused.\n // We can do that again if we want to keep this behavior intact.\n const channelAuthorizer: DeprecatedChannelAuthorizer = channelAuthorizerGenerator(\n channel,\n deprecatedAuthorizerOptions\n );\n channelAuthorizer.authorize(params.socketId, callback);\n };\n};\n","import { Options } from './options';\nimport Defaults from './defaults';\nimport {\n ChannelAuthorizationHandler,\n UserAuthenticationHandler,\n ChannelAuthorizationOptions\n} from './auth/options';\nimport UserAuthenticator from './auth/user_authenticator';\nimport ChannelAuthorizer from './auth/channel_authorizer';\nimport { ChannelAuthorizerProxy } from './auth/deprecated_channel_authorizer';\nimport Runtime from 'runtime';\nimport * as nacl from 'tweetnacl';\n\nexport type AuthTransport = 'ajax' | 'jsonp';\nexport type Transport =\n | 'ws'\n | 'wss'\n | 'xhr_streaming'\n | 'xhr_polling'\n | 'sockjs';\n\nexport interface Config {\n // these are all 'required' config parameters, it's not necessary for the user\n // to set them, but they have configured defaults.\n activityTimeout: number;\n enableStats: boolean;\n httpHost: string;\n httpPath: string;\n httpPort: number;\n httpsPort: number;\n pongTimeout: number;\n statsHost: string;\n unavailableTimeout: number;\n useTLS: boolean;\n wsHost: string;\n wsPath: string;\n wsPort: number;\n wssPort: number;\n userAuthenticator: UserAuthenticationHandler;\n channelAuthorizer: ChannelAuthorizationHandler;\n\n // these are all optional parameters or overrrides. The customer can set these\n // but it's not strictly necessary\n forceTLS?: boolean;\n cluster?: string;\n disabledTransports?: Transport[];\n enabledTransports?: Transport[];\n ignoreNullOrigin?: boolean;\n nacl?: nacl;\n timelineParams?: any;\n}\n\n// getConfig mainly sets the defaults for the options that are not provided\nexport function getConfig(opts: Options, pusher): Config {\n let config: Config = {\n activityTimeout: opts.activityTimeout || Defaults.activityTimeout,\n cluster: opts.cluster,\n httpPath: opts.httpPath || Defaults.httpPath,\n httpPort: opts.httpPort || Defaults.httpPort,\n httpsPort: opts.httpsPort || Defaults.httpsPort,\n pongTimeout: opts.pongTimeout || Defaults.pongTimeout,\n statsHost: opts.statsHost || Defaults.stats_host,\n unavailableTimeout: opts.unavailableTimeout || Defaults.unavailableTimeout,\n wsPath: opts.wsPath || Defaults.wsPath,\n wsPort: opts.wsPort || Defaults.wsPort,\n wssPort: opts.wssPort || Defaults.wssPort,\n\n enableStats: getEnableStatsConfig(opts),\n httpHost: getHttpHost(opts),\n useTLS: shouldUseTLS(opts),\n wsHost: getWebsocketHost(opts),\n\n userAuthenticator: buildUserAuthenticator(opts),\n channelAuthorizer: buildChannelAuthorizer(opts, pusher)\n };\n\n if ('disabledTransports' in opts)\n config.disabledTransports = opts.disabledTransports;\n if ('enabledTransports' in opts)\n config.enabledTransports = opts.enabledTransports;\n if ('ignoreNullOrigin' in opts)\n config.ignoreNullOrigin = opts.ignoreNullOrigin;\n if ('timelineParams' in opts) config.timelineParams = opts.timelineParams;\n if ('nacl' in opts) {\n config.nacl = opts.nacl;\n }\n\n return config;\n}\n\nfunction getHttpHost(opts: Options): string {\n if (opts.httpHost) {\n return opts.httpHost;\n }\n if (opts.cluster) {\n return `sockjs-${opts.cluster}.pusher.com`;\n }\n return Defaults.httpHost;\n}\n\nfunction getWebsocketHost(opts: Options): string {\n if (opts.wsHost) {\n return opts.wsHost;\n }\n return getWebsocketHostFromCluster(opts.cluster);\n}\n\nfunction getWebsocketHostFromCluster(cluster: string): string {\n return `ws-${cluster}.pusher.com`;\n}\n\nfunction shouldUseTLS(opts: Options): boolean {\n if (Runtime.getProtocol() === 'https:') {\n return true;\n } else if (opts.forceTLS === false) {\n return false;\n }\n return true;\n}\n\n// if enableStats is set take the value\n// if disableStats is set take the inverse\n// otherwise default to false\nfunction getEnableStatsConfig(opts: Options): boolean {\n if ('enableStats' in opts) {\n return opts.enableStats;\n }\n if ('disableStats' in opts) {\n return !opts.disableStats;\n }\n return false;\n}\n\nfunction buildUserAuthenticator(opts: Options): UserAuthenticationHandler {\n const userAuthentication = {\n ...Defaults.userAuthentication,\n ...opts.userAuthentication\n };\n if (\n 'customHandler' in userAuthentication &&\n userAuthentication['customHandler'] != null\n ) {\n return userAuthentication['customHandler'];\n }\n\n return UserAuthenticator(userAuthentication);\n}\n\nfunction buildChannelAuth(opts: Options, pusher): ChannelAuthorizationOptions {\n let channelAuthorization: ChannelAuthorizationOptions;\n if ('channelAuthorization' in opts) {\n channelAuthorization = {\n ...Defaults.channelAuthorization,\n ...opts.channelAuthorization\n };\n } else {\n channelAuthorization = {\n transport: opts.authTransport || Defaults.authTransport,\n endpoint: opts.authEndpoint || Defaults.authEndpoint\n };\n if ('auth' in opts) {\n if ('params' in opts.auth) channelAuthorization.params = opts.auth.params;\n if ('headers' in opts.auth)\n channelAuthorization.headers = opts.auth.headers;\n }\n if ('authorizer' in opts)\n channelAuthorization.customHandler = ChannelAuthorizerProxy(\n pusher,\n channelAuthorization,\n opts.authorizer\n );\n }\n return channelAuthorization;\n}\n\nfunction buildChannelAuthorizer(\n opts: Options,\n pusher\n): ChannelAuthorizationHandler {\n const channelAuthorization = buildChannelAuth(opts, pusher);\n if (\n 'customHandler' in channelAuthorization &&\n channelAuthorization['customHandler'] != null\n ) {\n return channelAuthorization['customHandler'];\n }\n\n return ChannelAuthorizer(channelAuthorization);\n}\n","import Logger from './logger';\nimport Pusher from './pusher';\nimport EventsDispatcher from './events/dispatcher';\n\nexport default class WatchlistFacade extends EventsDispatcher {\n private pusher: Pusher;\n\n public constructor(pusher: Pusher) {\n super(function(eventName, data) {\n Logger.debug(`No callbacks on watchlist events for ${eventName}`);\n });\n\n this.pusher = pusher;\n this.bindWatchlistInternalEvent();\n }\n\n handleEvent(pusherEvent) {\n pusherEvent.data.events.forEach(watchlistEvent => {\n this.emit(watchlistEvent.name, watchlistEvent);\n });\n }\n\n private bindWatchlistInternalEvent() {\n this.pusher.connection.bind('message', pusherEvent => {\n var eventName = pusherEvent.event;\n if (eventName === 'pusher_internal:watchlist_events') {\n this.handleEvent(pusherEvent);\n }\n });\n }\n}\n","function flatPromise() {\n let resolve, reject;\n const promise = new Promise((res, rej) => {\n resolve = res;\n reject = rej;\n });\n return { promise, resolve, reject };\n}\n\nexport default flatPromise;\n","import Pusher from './pusher';\nimport Logger from './logger';\nimport {\n UserAuthenticationData,\n UserAuthenticationCallback\n} from './auth/options';\nimport Channel from './channels/channel';\nimport WatchlistFacade from './watchlist';\nimport EventsDispatcher from './events/dispatcher';\nimport flatPromise from './utils/flat_promise';\n\nexport default class UserFacade extends EventsDispatcher {\n pusher: Pusher;\n signin_requested: boolean = false;\n user_data: any = null;\n serverToUserChannel: Channel = null;\n signinDonePromise: Promise = null;\n watchlist: WatchlistFacade;\n private _signinDoneResolve: Function = null;\n\n public constructor(pusher: Pusher) {\n super(function(eventName, data) {\n Logger.debug('No callbacks on user for ' + eventName);\n });\n this.pusher = pusher;\n this.pusher.connection.bind('state_change', ({ previous, current }) => {\n if (previous !== 'connected' && current === 'connected') {\n this._signin();\n }\n if (previous === 'connected' && current !== 'connected') {\n this._cleanup();\n this._newSigninPromiseIfNeeded();\n }\n });\n\n this.watchlist = new WatchlistFacade(pusher);\n\n this.pusher.connection.bind('message', event => {\n var eventName = event.event;\n if (eventName === 'pusher:signin_success') {\n this._onSigninSuccess(event.data);\n }\n if (\n this.serverToUserChannel &&\n this.serverToUserChannel.name === event.channel\n ) {\n this.serverToUserChannel.handleEvent(event);\n }\n });\n }\n\n public signin() {\n if (this.signin_requested) {\n return;\n }\n\n this.signin_requested = true;\n this._signin();\n }\n\n private _signin() {\n if (!this.signin_requested) {\n return;\n }\n\n this._newSigninPromiseIfNeeded();\n\n if (this.pusher.connection.state !== 'connected') {\n // Signin will be attempted when the connection is connected\n return;\n }\n\n this.pusher.config.userAuthenticator(\n {\n socketId: this.pusher.connection.socket_id\n },\n this._onAuthorize\n );\n }\n\n private _onAuthorize: UserAuthenticationCallback = (\n err,\n authData: UserAuthenticationData\n ) => {\n if (err) {\n Logger.warn(`Error during signin: ${err}`);\n this._cleanup();\n return;\n }\n\n this.pusher.send_event('pusher:signin', {\n auth: authData.auth,\n user_data: authData.user_data\n });\n\n // Later when we get pusher:singin_success event, the user will be marked as signed in\n };\n\n private _onSigninSuccess(data: any) {\n try {\n this.user_data = JSON.parse(data.user_data);\n } catch (e) {\n Logger.error(`Failed parsing user data after signin: ${data.user_data}`);\n this._cleanup();\n return;\n }\n\n if (typeof this.user_data.id !== 'string' || this.user_data.id === '') {\n Logger.error(\n `user_data doesn't contain an id. user_data: ${this.user_data}`\n );\n this._cleanup();\n return;\n }\n\n // Signin succeeded\n this._signinDoneResolve();\n this._subscribeChannels();\n }\n\n private _subscribeChannels() {\n const ensure_subscribed = channel => {\n if (channel.subscriptionPending && channel.subscriptionCancelled) {\n channel.reinstateSubscription();\n } else if (\n !channel.subscriptionPending &&\n this.pusher.connection.state === 'connected'\n ) {\n channel.subscribe();\n }\n };\n\n this.serverToUserChannel = new Channel(\n `#server-to-user-${this.user_data.id}`,\n this.pusher\n );\n this.serverToUserChannel.bind_global((eventName, data) => {\n if (\n eventName.indexOf('pusher_internal:') === 0 ||\n eventName.indexOf('pusher:') === 0\n ) {\n // ignore internal events\n return;\n }\n this.emit(eventName, data);\n });\n ensure_subscribed(this.serverToUserChannel);\n }\n\n private _cleanup() {\n this.user_data = null;\n if (this.serverToUserChannel) {\n this.serverToUserChannel.unbind_all();\n this.serverToUserChannel.disconnect();\n this.serverToUserChannel = null;\n }\n\n if (this.signin_requested) {\n // If signin is in progress and cleanup is called,\n // Mark the current signin process as done.\n this._signinDoneResolve();\n }\n }\n\n private _newSigninPromiseIfNeeded() {\n if (!this.signin_requested) {\n return;\n }\n\n // If there is a promise and it is not resolved, return without creating a new one.\n if (this.signinDonePromise && !(this.signinDonePromise as any).done) {\n return;\n }\n\n // This promise is never rejected.\n // It gets resolved when the signin process is done whether it failed or succeeded\n const { promise, resolve, reject: _ } = flatPromise();\n (promise as any).done = false;\n const setDone = () => {\n (promise as any).done = true;\n };\n promise.then(setDone).catch(setDone);\n this.signinDonePromise = promise;\n this._signinDoneResolve = resolve;\n }\n}\n","import AbstractRuntime from '../runtimes/interface';\nimport Runtime from 'runtime';\nimport * as Collections from './utils/collections';\nimport Channels from './channels/channels';\nimport Channel from './channels/channel';\nimport { default as EventsDispatcher } from './events/dispatcher';\nimport Timeline from './timeline/timeline';\nimport TimelineSender from './timeline/timeline_sender';\nimport TimelineLevel from './timeline/level';\nimport { defineTransport } from './strategies/strategy_builder';\nimport ConnectionManager from './connection/connection_manager';\nimport { PeriodicTimer } from './utils/timers';\nimport Defaults from './defaults';\nimport Logger from './logger';\nimport Factory from './utils/factory';\nimport { Options, ClusterOptions, validateOptions } from './options';\nimport { Config, getConfig } from './config';\nimport StrategyOptions from './strategies/strategy_options';\nimport UserFacade from './user';\n\nexport default class Pusher {\n /* STATIC PROPERTIES */\n static instances: Pusher[] = [];\n static isReady: boolean = false;\n static logToConsole: boolean = false;\n\n // for jsonp\n static Runtime: AbstractRuntime = Runtime;\n static ScriptReceivers: any = (Runtime).ScriptReceivers;\n static DependenciesReceivers: any = (Runtime).DependenciesReceivers;\n static auth_callbacks: any = (Runtime).auth_callbacks;\n\n static ready() {\n Pusher.isReady = true;\n for (var i = 0, l = Pusher.instances.length; i < l; i++) {\n Pusher.instances[i].connect();\n }\n }\n\n static log: (message: any) => void;\n\n private static getClientFeatures(): string[] {\n return Collections.keys(\n Collections.filterObject({ ws: Runtime.Transports.ws }, function(t) {\n return t.isSupported({});\n })\n );\n }\n\n /* INSTANCE PROPERTIES */\n key: string;\n options: Options;\n config: Config;\n channels: Channels;\n global_emitter: EventsDispatcher;\n sessionID: number;\n timeline: Timeline;\n timelineSender: TimelineSender;\n connection: ConnectionManager;\n timelineSenderTimer: PeriodicTimer;\n user: UserFacade;\n constructor(app_key: string, options: Options) {\n checkAppKey(app_key);\n validateOptions(options);\n this.key = app_key;\n this.config = getConfig(options, this);\n\n this.channels = Factory.createChannels();\n this.global_emitter = new EventsDispatcher();\n this.sessionID = Runtime.randomInt(1000000000);\n\n this.timeline = new Timeline(this.key, this.sessionID, {\n cluster: this.config.cluster,\n features: Pusher.getClientFeatures(),\n params: this.config.timelineParams || {},\n limit: 50,\n level: TimelineLevel.INFO,\n version: Defaults.VERSION\n });\n if (this.config.enableStats) {\n this.timelineSender = Factory.createTimelineSender(this.timeline, {\n host: this.config.statsHost,\n path: '/timeline/v2/' + Runtime.TimelineTransport.name\n });\n }\n\n var getStrategy = (options: StrategyOptions) => {\n return Runtime.getDefaultStrategy(this.config, options, defineTransport);\n };\n\n this.connection = Factory.createConnectionManager(this.key, {\n getStrategy: getStrategy,\n timeline: this.timeline,\n activityTimeout: this.config.activityTimeout,\n pongTimeout: this.config.pongTimeout,\n unavailableTimeout: this.config.unavailableTimeout,\n useTLS: Boolean(this.config.useTLS)\n });\n\n this.connection.bind('connected', () => {\n this.subscribeAll();\n if (this.timelineSender) {\n this.timelineSender.send(this.connection.isUsingTLS());\n }\n });\n\n this.connection.bind('message', event => {\n var eventName = event.event;\n var internal = eventName.indexOf('pusher_internal:') === 0;\n if (event.channel) {\n var channel = this.channel(event.channel);\n if (channel) {\n channel.handleEvent(event);\n }\n }\n // Emit globally [deprecated]\n if (!internal) {\n this.global_emitter.emit(event.event, event.data);\n }\n });\n this.connection.bind('connecting', () => {\n this.channels.disconnect();\n });\n this.connection.bind('disconnected', () => {\n this.channels.disconnect();\n });\n this.connection.bind('error', err => {\n Logger.warn(err);\n });\n\n Pusher.instances.push(this);\n this.timeline.info({ instances: Pusher.instances.length });\n\n this.user = new UserFacade(this);\n\n if (Pusher.isReady) {\n this.connect();\n }\n }\n\n /**\n * Allows you to switch Pusher cluster without\n * losing all the channels/subscription binding\n * as this is internally managed by the SDK.\n */\n switchCluster(options: ClusterOptions) {\n const { appKey, cluster } = options;\n this.key = appKey;\n this.options = { ...this.options, cluster };\n this.config = getConfig(this.options, this);\n this.connection.switchCluster(this.key);\n }\n\n channel(name: string): Channel {\n return this.channels.find(name);\n }\n\n allChannels(): Channel[] {\n return this.channels.all();\n }\n\n connect() {\n this.connection.connect();\n\n if (this.timelineSender) {\n if (!this.timelineSenderTimer) {\n var usingTLS = this.connection.isUsingTLS();\n var timelineSender = this.timelineSender;\n this.timelineSenderTimer = new PeriodicTimer(60000, function() {\n timelineSender.send(usingTLS);\n });\n }\n }\n }\n\n disconnect() {\n this.connection.disconnect();\n\n if (this.timelineSenderTimer) {\n this.timelineSenderTimer.ensureAborted();\n this.timelineSenderTimer = null;\n }\n }\n\n bind(event_name: string, callback: Function, context?: any): Pusher {\n this.global_emitter.bind(event_name, callback, context);\n return this;\n }\n\n unbind(event_name?: string, callback?: Function, context?: any): Pusher {\n this.global_emitter.unbind(event_name, callback, context);\n return this;\n }\n\n bind_global(callback: Function): Pusher {\n this.global_emitter.bind_global(callback);\n return this;\n }\n\n unbind_global(callback?: Function): Pusher {\n this.global_emitter.unbind_global(callback);\n return this;\n }\n\n unbind_all(callback?: Function): Pusher {\n this.global_emitter.unbind_all();\n return this;\n }\n\n subscribeAll() {\n var channelName;\n for (channelName in this.channels.channels) {\n if (this.channels.channels.hasOwnProperty(channelName)) {\n this.subscribe(channelName);\n }\n }\n }\n\n subscribe(channel_name: string) {\n var channel = this.channels.add(channel_name, this);\n if (channel.subscriptionPending && channel.subscriptionCancelled) {\n channel.reinstateSubscription();\n } else if (\n !channel.subscriptionPending &&\n this.connection.state === 'connected'\n ) {\n channel.subscribe();\n }\n return channel;\n }\n\n unsubscribe(channel_name: string) {\n var channel = this.channels.find(channel_name);\n if (channel && channel.subscriptionPending) {\n channel.cancelSubscription();\n } else {\n channel = this.channels.remove(channel_name);\n if (channel && channel.subscribed) {\n channel.unsubscribe();\n }\n }\n }\n\n send_event(event_name: string, data: any, channel?: string) {\n return this.connection.send_event(event_name, data, channel);\n }\n\n shouldUseTLS(): boolean {\n return this.config.useTLS;\n }\n\n signin() {\n this.user.signin();\n }\n}\n\nfunction checkAppKey(key) {\n if (key === null || key === undefined) {\n throw 'You must pass your app key when you instantiate Pusher.';\n }\n}\n\nRuntime.setup(Pusher);\n","import Pusher from './pusher';\nimport { Options, validateOptions } from './options';\nimport * as nacl from 'tweetnacl';\n\nexport default class PusherWithEncryption extends Pusher {\n constructor(app_key: string, options: Options) {\n Pusher.logToConsole = PusherWithEncryption.logToConsole;\n Pusher.log = PusherWithEncryption.log;\n\n validateOptions(options);\n options.nacl = nacl;\n super(app_key, options);\n }\n}\n"],"sourceRoot":""} \ No newline at end of file +{"version":3,"sources":["webpack://Pusher/webpack/universalModuleDefinition","webpack://Pusher/webpack/bootstrap","webpack://Pusher/./node_modules/@stablelib/base64/base64.ts","webpack://Pusher/./node_modules/@stablelib/utf8/utf8.ts","webpack://Pusher/./node_modules/tweetnacl/nacl-fast.js","webpack://Pusher/./src/core/pusher-with-encryption.js","webpack://Pusher/crypto (ignored)","webpack://Pusher/./src/runtimes/web/dom/script_receiver_factory.ts","webpack://Pusher/./src/core/defaults.ts","webpack://Pusher/./src/runtimes/web/dom/dependency_loader.ts","webpack://Pusher/./src/runtimes/web/dom/dependencies.ts","webpack://Pusher/./src/core/utils/url_store.ts","webpack://Pusher/./src/core/auth/options.ts","webpack://Pusher/./src/core/errors.ts","webpack://Pusher/./src/runtimes/isomorphic/auth/xhr_auth.ts","webpack://Pusher/./src/core/base64.ts","webpack://Pusher/./src/core/utils/timers/abstract_timer.ts","webpack://Pusher/./src/core/utils/timers/index.ts","webpack://Pusher/./src/core/util.ts","webpack://Pusher/./src/core/utils/collections.ts","webpack://Pusher/./src/core/logger.ts","webpack://Pusher/./src/runtimes/web/auth/jsonp_auth.ts","webpack://Pusher/./src/runtimes/web/dom/script_request.ts","webpack://Pusher/./src/runtimes/web/dom/jsonp_request.ts","webpack://Pusher/./src/runtimes/web/timeline/jsonp_timeline.ts","webpack://Pusher/./src/core/transports/url_schemes.ts","webpack://Pusher/./src/core/events/callback_registry.ts","webpack://Pusher/./src/core/events/dispatcher.ts","webpack://Pusher/./src/core/transports/transport_connection.ts","webpack://Pusher/./src/core/transports/transport.ts","webpack://Pusher/./src/runtimes/isomorphic/transports/transports.ts","webpack://Pusher/./src/runtimes/web/transports/transports.ts","webpack://Pusher/./src/runtimes/web/net_info.ts","webpack://Pusher/./src/core/transports/assistant_to_the_transport_manager.ts","webpack://Pusher/./src/core/connection/protocol/protocol.ts","webpack://Pusher/./src/core/connection/connection.ts","webpack://Pusher/./src/core/connection/handshake/index.ts","webpack://Pusher/./src/core/timeline/timeline_sender.ts","webpack://Pusher/./src/core/channels/channel.ts","webpack://Pusher/./src/core/channels/private_channel.ts","webpack://Pusher/./src/core/channels/members.ts","webpack://Pusher/./src/core/channels/presence_channel.ts","webpack://Pusher/./src/core/channels/encrypted_channel.ts","webpack://Pusher/./src/core/connection/connection_manager.ts","webpack://Pusher/./src/core/channels/channels.ts","webpack://Pusher/./src/core/utils/factory.ts","webpack://Pusher/./src/core/transports/transport_manager.ts","webpack://Pusher/./src/core/strategies/sequential_strategy.ts","webpack://Pusher/./src/core/strategies/best_connected_ever_strategy.ts","webpack://Pusher/./src/core/strategies/websocket_prioritized_cached_strategy.ts","webpack://Pusher/./src/core/strategies/delayed_strategy.ts","webpack://Pusher/./src/core/strategies/if_strategy.ts","webpack://Pusher/./src/core/strategies/first_connected_strategy.ts","webpack://Pusher/./src/runtimes/web/default_strategy.ts","webpack://Pusher/./src/runtimes/web/transports/transport_connection_initializer.ts","webpack://Pusher/./src/runtimes/web/http/http_xdomain_request.ts","webpack://Pusher/./src/core/http/http_request.ts","webpack://Pusher/./src/core/http/state.ts","webpack://Pusher/./src/core/http/http_socket.ts","webpack://Pusher/./src/core/http/http_streaming_socket.ts","webpack://Pusher/./src/core/http/http_polling_socket.ts","webpack://Pusher/./src/runtimes/isomorphic/http/http_xhr_request.ts","webpack://Pusher/./src/runtimes/isomorphic/http/http.ts","webpack://Pusher/./src/runtimes/web/http/http.ts","webpack://Pusher/./src/runtimes/web/runtime.ts","webpack://Pusher/./src/core/timeline/level.ts","webpack://Pusher/./src/core/timeline/timeline.ts","webpack://Pusher/./src/core/strategies/transport_strategy.ts","webpack://Pusher/./src/core/strategies/strategy_builder.ts","webpack://Pusher/./src/core/options.ts","webpack://Pusher/./src/core/auth/user_authenticator.ts","webpack://Pusher/./src/core/auth/channel_authorizer.ts","webpack://Pusher/./src/core/auth/deprecated_channel_authorizer.ts","webpack://Pusher/./src/core/config.ts","webpack://Pusher/./src/core/watchlist.ts","webpack://Pusher/./src/core/utils/flat_promise.ts","webpack://Pusher/./src/core/user.ts","webpack://Pusher/./src/core/pusher.ts","webpack://Pusher/./src/core/pusher-with-encryption.ts"],"names":[],"mappings":";;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AACD,O;QCVA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;;QAEA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;;;QAGA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;QACA,0CAA0C,gCAAgC;QAC1E;QACA;;QAEA;QACA;QACA;QACA,wDAAwD,kBAAkB;QAC1E;QACA,iDAAiD,cAAc;QAC/D;;QAEA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA,yCAAyC,iCAAiC;QAC1E,gHAAgH,mB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;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa,OAAO;AACpB;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,aAAa,QAAQ;AACrB,aAAa,OAAO;AACpB;AACA;AACA,eAAe,QAAQ;AACvB;AACA,eAAe,QAAQ;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB;AACA;AACA;;AAEA;AACA;AACA;AACA,aAAa,QAAQ;AACrB,aAAa,OAAO;AACpB;AACA;AACA,eAAe,QAAQ;AACvB;AACA,eAAe,QAAQ;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,iBAAiB,OAAO;AACxB;AACA;;AAEA;AACA;AACA;AACA;AACA,iBAAiB,OAAO;AACxB;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA,8CAA8C;AAC9C,8CAA8C;AAC9C,8CAA8C;AAC9C,8CAA8C;AAC9C,8CAA8C;AAC9C;AACA,8CAA8C;AAC9C,8CAA8C;AAC9C,8CAA8C;AAC9C;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,sDAAsD;AACtD,sDAAsD;AACtD,sDAAsD;AACtD,sDAAsD;AACtD,sDAAsD;AACtD;AACA,sDAAsD;AACtD,sDAAsD;AACtD,sDAAsD;AACtD;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA,qBAAqB;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA,qBAAqB;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA,qBAAqB;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA,qBAAqB;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA,qBAAqB;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA,qBAAqB;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA,qBAAqB;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA,qBAAqB;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA,qBAAqB;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA,qBAAqB;;AAErB;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA,UAAU,QAAQ;AAClB;AACA;AACA;;AAEA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA;AACA;;AAEA;AACA,aAAa,QAAQ;AACrB;AACA,aAAa,QAAQ;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa,OAAO;AACpB;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,UAAU;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,eAAe,WAAW;AAC1B;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;;AAEA;AACA;AACA,aAAa,QAAQ;AACrB;;AAEA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA,aAAa,OAAO;AACpB;AACA,eAAe,QAAQ;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;;AAEA;AACA,iBAAiB,QAAQ;AACzB;;AAEA;AACA,iBAAiB,QAAQ;AACzB;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD;;AAEA;AACA;AACA,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA,aAAa,QAAQ;AACrB,eAAe,QAAQ;AACvB;AACA;AACA;AACA,aAAa,QAAQ;AACrB;;AAEA;AACA;AACA;AACA,aAAa,QAAQ;AACrB,eAAe,QAAQ;AACvB;AACA;AACA;AACA,aAAa,QAAQ;AACrB;;AAEA;AACA;AACA;AACA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA;AACA,aAAa,MAAM;AACnB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,eAAe,QAAQ;AACvB;AACA;AACA;AACA;AACA,eAAe,QAAQ;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA,qBAAqB;AACrB,qBAAqB;;AAErB;AACA;AACA;;AAEA,sBAAsB;AACtB,sBAAsB;;AAEtB;AACA;AACA;;AAEA,sBAAsB;AACtB,sBAAsB;;AAEtB;AACA;AACA;;AAEA,sBAAsB;AACtB,sBAAsB;;AAEtB;AACA;AACA;;AAEA,sBAAsB;AACtB,sBAAsB;;AAEtB;AACA;AACA;;AAEA;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AEA;AACA;;AAEA;AACA;;AAEA,mBAAmB;AACnB,mBAAmB;;AAEnB;AACA;;AAEA,oBAAoB;AACpB,oBAAoB;;AAEpB;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA,mBAAmB;AACnB,mBAAmB;;AAEnB;AACA;;AAEA,oBAAoB;AACpB,oBAAoB;;AAEpB;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA,mBAAmB;AACnB,mBAAmB;;AAEnB;AACA;;AAEA,oBAAoB;AACpB,oBAAoB;;AAEpB;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA,aAAa,OAAO;AACpB;;AAEA;AACA;AACA;AACA;;AAEA,aAAa,OAAO;;AAEpB;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa,OAAO;AACpB;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,QAAQ;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA,aAAa,QAAQ;AACrB;AACA;;AAEA;;AAEA;AACA;AACA,cAAc,SAAS;AACvB;AACA,gCAAgC,OAAO;AACvC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA;AACA,aAAa,QAAQ;AACrB,aAAa,QAAQ;AACrB;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa,QAAQ;AACrB,aAAa,QAAQ;AACrB;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA,aAAa,OAAO;AACpB,aAAa,QAAQ;;AAErB;AACA;AACA;AACA;;AAEA,cAAc,QAAQ;AACtB;AACA;;AAEA,aAAa,QAAQ;AACrB,aAAa,QAAQ;AACrB,aAAa,QAAQ;AACrB,eAAe,QAAQ;AACvB;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;;AAEA,aAAa,OAAO;AACpB,aAAa,QAAQ;AACrB;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA,eAAe,OAAO;AACtB;AACA;;AAEA,aAAa,OAAO;AACpB;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA,iBAAiB,sBAAsB;AACvC;AACA;AACA;AACA;;AAEA;AACA,iBAAiB,gBAAgB;AACjC;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,iBAAiB,gBAAgB;AACjC;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,iBAAiB,gBAAgB;AACjC;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA,UAAU;AACV;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,UAAU;AACV;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAiB,cAAc;AAC/B;AACA;;AAEA;AACA;AACA;AACA,iBAAiB,gBAAgB;AACjC;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa,uBAAuB;AACpC,aAAa,gBAAgB;AAC7B;AACA;;AAEA;AACA;AACA;AACA;AACA,UAAU;AACV;;AAEA;AACA;AACA;AACA;AACA;AACA,iBAAiB,eAAe;AAChC,UAAU;AACV;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAiB,QAAQ;AACzB;AACA,UAAU;AACV;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAiB,OAAO;AACxB;AACA;AACA,iBAAiB,OAAO;AACxB;AACA,KAAK;AACL,GAAG,UAAU,IAA8B;AAC3C;AACA,aAAa,mBAAO,CAAC,CAAQ;AAC7B;AACA;AACA;AACA,mBAAmB,OAAO;AAC1B;AACA,OAAO;AACP;AACA;AACA,CAAC;;AAED,CAAC,EAAE,KAA6B,kEAAkE;;;;;;;ACt1ElG,iBAAiB,mBAAO,CAAC,C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W,CAAC,GAAG;IACtB,IAAI,GAAG,KAAK,IAAI,IAAI,GAAG,KAAK,SAAS,EAAE;QACrC,MAAM,yDAAyD,CAAC;KACjE;AACH,CAAC;AAED,OAAO,CAAC,KAAK,CAAC,aAAM,CAAC,CAAC;;;;;;ACvQQ;AACuB;AACnB;AAEnB,MAAM,2CAAqB,SAAQ,WAAM;IACtD,YAAY,OAAe,EAAE,OAAgB;QAC3C,WAAM,CAAC,YAAY,GAAG,2CAAoB,CAAC,YAAY,CAAC;QACxD,WAAM,CAAC,GAAG,GAAG,2CAAoB,CAAC,GAAG,CAAC;QAEtC,eAAe,CAAC,OAAO,CAAC,CAAC;QACzB,OAAO,CAAC,IAAI,GAAG,SAAI,CAAC;QACpB,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAC1B,CAAC;CACF","file":"pusher-with-encryption.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"Pusher\"] = factory();\n\telse\n\t\troot[\"Pusher\"] = factory();\n})(window, function() {\nreturn "," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 3);\n","// Copyright (C) 2016 Dmitry Chestnykh\n// MIT License. See LICENSE file for details.\n\n/**\n * Package base64 implements Base64 encoding and decoding.\n */\n\n// Invalid character used in decoding to indicate\n// that the character to decode is out of range of\n// alphabet and cannot be decoded.\nconst INVALID_BYTE = 256;\n\n/**\n * Implements standard Base64 encoding.\n *\n * Operates in constant time.\n */\nexport class Coder {\n // TODO(dchest): methods to encode chunk-by-chunk.\n\n constructor(private _paddingCharacter = \"=\") { }\n\n encodedLength(length: number): number {\n if (!this._paddingCharacter) {\n return (length * 8 + 5) / 6 | 0;\n }\n return (length + 2) / 3 * 4 | 0;\n }\n\n encode(data: Uint8Array): string {\n let out = \"\";\n\n let i = 0;\n for (; i < data.length - 2; i += 3) {\n let c = (data[i] << 16) | (data[i + 1] << 8) | (data[i + 2]);\n out += this._encodeByte((c >>> 3 * 6) & 63);\n out += this._encodeByte((c >>> 2 * 6) & 63);\n out += this._encodeByte((c >>> 1 * 6) & 63);\n out += this._encodeByte((c >>> 0 * 6) & 63);\n }\n\n const left = data.length - i;\n if (left > 0) {\n let c = (data[i] << 16) | (left === 2 ? data[i + 1] << 8 : 0);\n out += this._encodeByte((c >>> 3 * 6) & 63);\n out += this._encodeByte((c >>> 2 * 6) & 63);\n if (left === 2) {\n out += this._encodeByte((c >>> 1 * 6) & 63);\n } else {\n out += this._paddingCharacter || \"\";\n }\n out += this._paddingCharacter || \"\";\n }\n\n return out;\n }\n\n maxDecodedLength(length: number): number {\n if (!this._paddingCharacter) {\n return (length * 6 + 7) / 8 | 0;\n }\n return length / 4 * 3 | 0;\n }\n\n decodedLength(s: string): number {\n return this.maxDecodedLength(s.length - this._getPaddingLength(s));\n }\n\n decode(s: string): Uint8Array {\n if (s.length === 0) {\n return new Uint8Array(0);\n }\n const paddingLength = this._getPaddingLength(s);\n const length = s.length - paddingLength;\n const out = new Uint8Array(this.maxDecodedLength(length));\n let op = 0;\n let i = 0;\n let haveBad = 0;\n let v0 = 0, v1 = 0, v2 = 0, v3 = 0;\n for (; i < length - 4; i += 4) {\n v0 = this._decodeChar(s.charCodeAt(i + 0));\n v1 = this._decodeChar(s.charCodeAt(i + 1));\n v2 = this._decodeChar(s.charCodeAt(i + 2));\n v3 = this._decodeChar(s.charCodeAt(i + 3));\n out[op++] = (v0 << 2) | (v1 >>> 4);\n out[op++] = (v1 << 4) | (v2 >>> 2);\n out[op++] = (v2 << 6) | v3;\n haveBad |= v0 & INVALID_BYTE;\n haveBad |= v1 & INVALID_BYTE;\n haveBad |= v2 & INVALID_BYTE;\n haveBad |= v3 & INVALID_BYTE;\n }\n if (i < length - 1) {\n v0 = this._decodeChar(s.charCodeAt(i));\n v1 = this._decodeChar(s.charCodeAt(i + 1));\n out[op++] = (v0 << 2) | (v1 >>> 4);\n haveBad |= v0 & INVALID_BYTE;\n haveBad |= v1 & INVALID_BYTE;\n }\n if (i < length - 2) {\n v2 = this._decodeChar(s.charCodeAt(i + 2));\n out[op++] = (v1 << 4) | (v2 >>> 2);\n haveBad |= v2 & INVALID_BYTE;\n }\n if (i < length - 3) {\n v3 = this._decodeChar(s.charCodeAt(i + 3));\n out[op++] = (v2 << 6) | v3;\n haveBad |= v3 & INVALID_BYTE;\n }\n if (haveBad !== 0) {\n throw new Error(\"Base64Coder: incorrect characters for decoding\");\n }\n return out;\n }\n\n // Standard encoding have the following encoded/decoded ranges,\n // which we need to convert between.\n //\n // ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 0123456789 + /\n // Index: 0 - 25 26 - 51 52 - 61 62 63\n // ASCII: 65 - 90 97 - 122 48 - 57 43 47\n //\n\n // Encode 6 bits in b into a new character.\n protected _encodeByte(b: number): string {\n // Encoding uses constant time operations as follows:\n //\n // 1. Define comparison of A with B using (A - B) >>> 8:\n // if A > B, then result is positive integer\n // if A <= B, then result is 0\n //\n // 2. Define selection of C or 0 using bitwise AND: X & C:\n // if X == 0, then result is 0\n // if X != 0, then result is C\n //\n // 3. Start with the smallest comparison (b >= 0), which is always\n // true, so set the result to the starting ASCII value (65).\n //\n // 4. Continue comparing b to higher ASCII values, and selecting\n // zero if comparison isn't true, otherwise selecting a value\n // to add to result, which:\n //\n // a) undoes the previous addition\n // b) provides new value to add\n //\n let result = b;\n // b >= 0\n result += 65;\n // b > 25\n result += ((25 - b) >>> 8) & ((0 - 65) - 26 + 97);\n // b > 51\n result += ((51 - b) >>> 8) & ((26 - 97) - 52 + 48);\n // b > 61\n result += ((61 - b) >>> 8) & ((52 - 48) - 62 + 43);\n // b > 62\n result += ((62 - b) >>> 8) & ((62 - 43) - 63 + 47);\n\n return String.fromCharCode(result);\n }\n\n // Decode a character code into a byte.\n // Must return 256 if character is out of alphabet range.\n protected _decodeChar(c: number): number {\n // Decoding works similar to encoding: using the same comparison\n // function, but now it works on ranges: result is always incremented\n // by value, but this value becomes zero if the range is not\n // satisfied.\n //\n // Decoding starts with invalid value, 256, which is then\n // subtracted when the range is satisfied. If none of the ranges\n // apply, the function returns 256, which is then checked by\n // the caller to throw error.\n let result = INVALID_BYTE; // start with invalid character\n\n // c == 43 (c > 42 and c < 44)\n result += (((42 - c) & (c - 44)) >>> 8) & (-INVALID_BYTE + c - 43 + 62);\n // c == 47 (c > 46 and c < 48)\n result += (((46 - c) & (c - 48)) >>> 8) & (-INVALID_BYTE + c - 47 + 63);\n // c > 47 and c < 58\n result += (((47 - c) & (c - 58)) >>> 8) & (-INVALID_BYTE + c - 48 + 52);\n // c > 64 and c < 91\n result += (((64 - c) & (c - 91)) >>> 8) & (-INVALID_BYTE + c - 65 + 0);\n // c > 96 and c < 123\n result += (((96 - c) & (c - 123)) >>> 8) & (-INVALID_BYTE + c - 97 + 26);\n\n return result;\n }\n\n private _getPaddingLength(s: string): number {\n let paddingLength = 0;\n if (this._paddingCharacter) {\n for (let i = s.length - 1; i >= 0; i--) {\n if (s[i] !== this._paddingCharacter) {\n break;\n }\n paddingLength++;\n }\n if (s.length < 4 || paddingLength > 2) {\n throw new Error(\"Base64Coder: incorrect padding\");\n }\n }\n return paddingLength;\n }\n\n}\n\nconst stdCoder = new Coder();\n\nexport function encode(data: Uint8Array): string {\n return stdCoder.encode(data);\n}\n\nexport function decode(s: string): Uint8Array {\n return stdCoder.decode(s);\n}\n\n/**\n * Implements URL-safe Base64 encoding.\n * (Same as Base64, but '+' is replaced with '-', and '/' with '_').\n *\n * Operates in constant time.\n */\nexport class URLSafeCoder extends Coder {\n // URL-safe encoding have the following encoded/decoded ranges:\n //\n // ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 0123456789 - _\n // Index: 0 - 25 26 - 51 52 - 61 62 63\n // ASCII: 65 - 90 97 - 122 48 - 57 45 95\n //\n\n protected _encodeByte(b: number): string {\n let result = b;\n // b >= 0\n result += 65;\n // b > 25\n result += ((25 - b) >>> 8) & ((0 - 65) - 26 + 97);\n // b > 51\n result += ((51 - b) >>> 8) & ((26 - 97) - 52 + 48);\n // b > 61\n result += ((61 - b) >>> 8) & ((52 - 48) - 62 + 45);\n // b > 62\n result += ((62 - b) >>> 8) & ((62 - 45) - 63 + 95);\n\n return String.fromCharCode(result);\n }\n\n protected _decodeChar(c: number): number {\n let result = INVALID_BYTE;\n\n // c == 45 (c > 44 and c < 46)\n result += (((44 - c) & (c - 46)) >>> 8) & (-INVALID_BYTE + c - 45 + 62);\n // c == 95 (c > 94 and c < 96)\n result += (((94 - c) & (c - 96)) >>> 8) & (-INVALID_BYTE + c - 95 + 63);\n // c > 47 and c < 58\n result += (((47 - c) & (c - 58)) >>> 8) & (-INVALID_BYTE + c - 48 + 52);\n // c > 64 and c < 91\n result += (((64 - c) & (c - 91)) >>> 8) & (-INVALID_BYTE + c - 65 + 0);\n // c > 96 and c < 123\n result += (((96 - c) & (c - 123)) >>> 8) & (-INVALID_BYTE + c - 97 + 26);\n\n return result;\n }\n}\n\nconst urlSafeCoder = new URLSafeCoder();\n\nexport function encodeURLSafe(data: Uint8Array): string {\n return urlSafeCoder.encode(data);\n}\n\nexport function decodeURLSafe(s: string): Uint8Array {\n return urlSafeCoder.decode(s);\n}\n\n\nexport const encodedLength = (length: number) =>\n stdCoder.encodedLength(length);\n\nexport const maxDecodedLength = (length: number) =>\n stdCoder.maxDecodedLength(length);\n\nexport const decodedLength = (s: string) =>\n stdCoder.decodedLength(s);\n","// Copyright (C) 2016 Dmitry Chestnykh\n// MIT License. See LICENSE file for details.\n\n/**\n * Package utf8 implements UTF-8 encoding and decoding.\n */\n\nconst INVALID_UTF16 = \"utf8: invalid string\";\nconst INVALID_UTF8 = \"utf8: invalid source encoding\";\n\n/**\n * Encodes the given string into UTF-8 byte array.\n * Throws if the source string has invalid UTF-16 encoding.\n */\nexport function encode(s: string): Uint8Array {\n // Calculate result length and allocate output array.\n // encodedLength() also validates string and throws errors,\n // so we don't need repeat validation here.\n const arr = new Uint8Array(encodedLength(s));\n\n let pos = 0;\n for (let i = 0; i < s.length; i++) {\n let c = s.charCodeAt(i);\n if (c < 0x80) {\n arr[pos++] = c;\n } else if (c < 0x800) {\n arr[pos++] = 0xc0 | c >> 6;\n arr[pos++] = 0x80 | c & 0x3f;\n } else if (c < 0xd800) {\n arr[pos++] = 0xe0 | c >> 12;\n arr[pos++] = 0x80 | (c >> 6) & 0x3f;\n arr[pos++] = 0x80 | c & 0x3f;\n } else {\n i++; // get one more character\n c = (c & 0x3ff) << 10;\n c |= s.charCodeAt(i) & 0x3ff;\n c += 0x10000;\n\n arr[pos++] = 0xf0 | c >> 18;\n arr[pos++] = 0x80 | (c >> 12) & 0x3f;\n arr[pos++] = 0x80 | (c >> 6) & 0x3f;\n arr[pos++] = 0x80 | c & 0x3f;\n }\n }\n return arr;\n}\n\n/**\n * Returns the number of bytes required to encode the given string into UTF-8.\n * Throws if the source string has invalid UTF-16 encoding.\n */\nexport function encodedLength(s: string): number {\n let result = 0;\n for (let i = 0; i < s.length; i++) {\n const c = s.charCodeAt(i);\n if (c < 0x80) {\n result += 1;\n } else if (c < 0x800) {\n result += 2;\n } else if (c < 0xd800) {\n result += 3;\n } else if (c <= 0xdfff) {\n if (i >= s.length - 1) {\n throw new Error(INVALID_UTF16);\n }\n i++; // \"eat\" next character\n result += 4;\n } else {\n throw new Error(INVALID_UTF16);\n }\n }\n return result;\n}\n\n/**\n * Decodes the given byte array from UTF-8 into a string.\n * Throws if encoding is invalid.\n */\nexport function decode(arr: Uint8Array): string {\n const chars: string[] = [];\n for (let i = 0; i < arr.length; i++) {\n let b = arr[i];\n\n if (b & 0x80) {\n let min;\n if (b < 0xe0) {\n // Need 1 more byte.\n if (i >= arr.length) {\n throw new Error(INVALID_UTF8);\n }\n const n1 = arr[++i];\n if ((n1 & 0xc0) !== 0x80) {\n throw new Error(INVALID_UTF8);\n }\n b = (b & 0x1f) << 6 | (n1 & 0x3f);\n min = 0x80;\n } else if (b < 0xf0) {\n // Need 2 more bytes.\n if (i >= arr.length - 1) {\n throw new Error(INVALID_UTF8);\n }\n const n1 = arr[++i];\n const n2 = arr[++i];\n if ((n1 & 0xc0) !== 0x80 || (n2 & 0xc0) !== 0x80) {\n throw new Error(INVALID_UTF8);\n }\n b = (b & 0x0f) << 12 | (n1 & 0x3f) << 6 | (n2 & 0x3f);\n min = 0x800;\n } else if (b < 0xf8) {\n // Need 3 more bytes.\n if (i >= arr.length - 2) {\n throw new Error(INVALID_UTF8);\n }\n const n1 = arr[++i];\n const n2 = arr[++i];\n const n3 = arr[++i];\n if ((n1 & 0xc0) !== 0x80 || (n2 & 0xc0) !== 0x80 || (n3 & 0xc0) !== 0x80) {\n throw new Error(INVALID_UTF8);\n }\n b = (b & 0x0f) << 18 | (n1 & 0x3f) << 12 | (n2 & 0x3f) << 6 | (n3 & 0x3f);\n min = 0x10000;\n } else {\n throw new Error(INVALID_UTF8);\n }\n\n if (b < min || (b >= 0xd800 && b <= 0xdfff)) {\n throw new Error(INVALID_UTF8);\n }\n\n if (b >= 0x10000) {\n // Surrogate pair.\n if (b > 0x10ffff) {\n throw new Error(INVALID_UTF8);\n }\n b -= 0x10000;\n chars.push(String.fromCharCode(0xd800 | (b >> 10)));\n b = 0xdc00 | (b & 0x3ff);\n }\n }\n\n chars.push(String.fromCharCode(b));\n }\n return chars.join(\"\");\n}\n","(function(nacl) {\n'use strict';\n\n// Ported in 2014 by Dmitry Chestnykh and Devi Mandiri.\n// Public domain.\n//\n// Implementation derived from TweetNaCl version 20140427.\n// See for details: http://tweetnacl.cr.yp.to/\n\nvar gf = function(init) {\n var i, r = new Float64Array(16);\n if (init) for (i = 0; i < init.length; i++) r[i] = init[i];\n return r;\n};\n\n// Pluggable, initialized in high-level API below.\nvar randombytes = function(/* x, n */) { throw new Error('no PRNG'); };\n\nvar _0 = new Uint8Array(16);\nvar _9 = new Uint8Array(32); _9[0] = 9;\n\nvar gf0 = gf(),\n gf1 = gf([1]),\n _121665 = gf([0xdb41, 1]),\n D = gf([0x78a3, 0x1359, 0x4dca, 0x75eb, 0xd8ab, 0x4141, 0x0a4d, 0x0070, 0xe898, 0x7779, 0x4079, 0x8cc7, 0xfe73, 0x2b6f, 0x6cee, 0x5203]),\n D2 = gf([0xf159, 0x26b2, 0x9b94, 0xebd6, 0xb156, 0x8283, 0x149a, 0x00e0, 0xd130, 0xeef3, 0x80f2, 0x198e, 0xfce7, 0x56df, 0xd9dc, 0x2406]),\n X = gf([0xd51a, 0x8f25, 0x2d60, 0xc956, 0xa7b2, 0x9525, 0xc760, 0x692c, 0xdc5c, 0xfdd6, 0xe231, 0xc0a4, 0x53fe, 0xcd6e, 0x36d3, 0x2169]),\n Y = gf([0x6658, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666]),\n I = gf([0xa0b0, 0x4a0e, 0x1b27, 0xc4ee, 0xe478, 0xad2f, 0x1806, 0x2f43, 0xd7a7, 0x3dfb, 0x0099, 0x2b4d, 0xdf0b, 0x4fc1, 0x2480, 0x2b83]);\n\nfunction ts64(x, i, h, l) {\n x[i] = (h >> 24) & 0xff;\n x[i+1] = (h >> 16) & 0xff;\n x[i+2] = (h >> 8) & 0xff;\n x[i+3] = h & 0xff;\n x[i+4] = (l >> 24) & 0xff;\n x[i+5] = (l >> 16) & 0xff;\n x[i+6] = (l >> 8) & 0xff;\n x[i+7] = l & 0xff;\n}\n\nfunction vn(x, xi, y, yi, n) {\n var i,d = 0;\n for (i = 0; i < n; i++) d |= x[xi+i]^y[yi+i];\n return (1 & ((d - 1) >>> 8)) - 1;\n}\n\nfunction crypto_verify_16(x, xi, y, yi) {\n return vn(x,xi,y,yi,16);\n}\n\nfunction crypto_verify_32(x, xi, y, yi) {\n return vn(x,xi,y,yi,32);\n}\n\nfunction core_salsa20(o, p, k, c) {\n var j0 = c[ 0] & 0xff | (c[ 1] & 0xff)<<8 | (c[ 2] & 0xff)<<16 | (c[ 3] & 0xff)<<24,\n j1 = k[ 0] & 0xff | (k[ 1] & 0xff)<<8 | (k[ 2] & 0xff)<<16 | (k[ 3] & 0xff)<<24,\n j2 = k[ 4] & 0xff | (k[ 5] & 0xff)<<8 | (k[ 6] & 0xff)<<16 | (k[ 7] & 0xff)<<24,\n j3 = k[ 8] & 0xff | (k[ 9] & 0xff)<<8 | (k[10] & 0xff)<<16 | (k[11] & 0xff)<<24,\n j4 = k[12] & 0xff | (k[13] & 0xff)<<8 | (k[14] & 0xff)<<16 | (k[15] & 0xff)<<24,\n j5 = c[ 4] & 0xff | (c[ 5] & 0xff)<<8 | (c[ 6] & 0xff)<<16 | (c[ 7] & 0xff)<<24,\n j6 = p[ 0] & 0xff | (p[ 1] & 0xff)<<8 | (p[ 2] & 0xff)<<16 | (p[ 3] & 0xff)<<24,\n j7 = p[ 4] & 0xff | (p[ 5] & 0xff)<<8 | (p[ 6] & 0xff)<<16 | (p[ 7] & 0xff)<<24,\n j8 = p[ 8] & 0xff | (p[ 9] & 0xff)<<8 | (p[10] & 0xff)<<16 | (p[11] & 0xff)<<24,\n j9 = p[12] & 0xff | (p[13] & 0xff)<<8 | (p[14] & 0xff)<<16 | (p[15] & 0xff)<<24,\n j10 = c[ 8] & 0xff | (c[ 9] & 0xff)<<8 | (c[10] & 0xff)<<16 | (c[11] & 0xff)<<24,\n j11 = k[16] & 0xff | (k[17] & 0xff)<<8 | (k[18] & 0xff)<<16 | (k[19] & 0xff)<<24,\n j12 = k[20] & 0xff | (k[21] & 0xff)<<8 | (k[22] & 0xff)<<16 | (k[23] & 0xff)<<24,\n j13 = k[24] & 0xff | (k[25] & 0xff)<<8 | (k[26] & 0xff)<<16 | (k[27] & 0xff)<<24,\n j14 = k[28] & 0xff | (k[29] & 0xff)<<8 | (k[30] & 0xff)<<16 | (k[31] & 0xff)<<24,\n j15 = c[12] & 0xff | (c[13] & 0xff)<<8 | (c[14] & 0xff)<<16 | (c[15] & 0xff)<<24;\n\n var x0 = j0, x1 = j1, x2 = j2, x3 = j3, x4 = j4, x5 = j5, x6 = j6, x7 = j7,\n x8 = j8, x9 = j9, x10 = j10, x11 = j11, x12 = j12, x13 = j13, x14 = j14,\n x15 = j15, u;\n\n for (var i = 0; i < 20; i += 2) {\n u = x0 + x12 | 0;\n x4 ^= u<<7 | u>>>(32-7);\n u = x4 + x0 | 0;\n x8 ^= u<<9 | u>>>(32-9);\n u = x8 + x4 | 0;\n x12 ^= u<<13 | u>>>(32-13);\n u = x12 + x8 | 0;\n x0 ^= u<<18 | u>>>(32-18);\n\n u = x5 + x1 | 0;\n x9 ^= u<<7 | u>>>(32-7);\n u = x9 + x5 | 0;\n x13 ^= u<<9 | u>>>(32-9);\n u = x13 + x9 | 0;\n x1 ^= u<<13 | u>>>(32-13);\n u = x1 + x13 | 0;\n x5 ^= u<<18 | u>>>(32-18);\n\n u = x10 + x6 | 0;\n x14 ^= u<<7 | u>>>(32-7);\n u = x14 + x10 | 0;\n x2 ^= u<<9 | u>>>(32-9);\n u = x2 + x14 | 0;\n x6 ^= u<<13 | u>>>(32-13);\n u = x6 + x2 | 0;\n x10 ^= u<<18 | u>>>(32-18);\n\n u = x15 + x11 | 0;\n x3 ^= u<<7 | u>>>(32-7);\n u = x3 + x15 | 0;\n x7 ^= u<<9 | u>>>(32-9);\n u = x7 + x3 | 0;\n x11 ^= u<<13 | u>>>(32-13);\n u = x11 + x7 | 0;\n x15 ^= u<<18 | u>>>(32-18);\n\n u = x0 + x3 | 0;\n x1 ^= u<<7 | u>>>(32-7);\n u = x1 + x0 | 0;\n x2 ^= u<<9 | u>>>(32-9);\n u = x2 + x1 | 0;\n x3 ^= u<<13 | u>>>(32-13);\n u = x3 + x2 | 0;\n x0 ^= u<<18 | u>>>(32-18);\n\n u = x5 + x4 | 0;\n x6 ^= u<<7 | u>>>(32-7);\n u = x6 + x5 | 0;\n x7 ^= u<<9 | u>>>(32-9);\n u = x7 + x6 | 0;\n x4 ^= u<<13 | u>>>(32-13);\n u = x4 + x7 | 0;\n x5 ^= u<<18 | u>>>(32-18);\n\n u = x10 + x9 | 0;\n x11 ^= u<<7 | u>>>(32-7);\n u = x11 + x10 | 0;\n x8 ^= u<<9 | u>>>(32-9);\n u = x8 + x11 | 0;\n x9 ^= u<<13 | u>>>(32-13);\n u = x9 + x8 | 0;\n x10 ^= u<<18 | u>>>(32-18);\n\n u = x15 + x14 | 0;\n x12 ^= u<<7 | u>>>(32-7);\n u = x12 + x15 | 0;\n x13 ^= u<<9 | u>>>(32-9);\n u = x13 + x12 | 0;\n x14 ^= u<<13 | u>>>(32-13);\n u = x14 + x13 | 0;\n x15 ^= u<<18 | u>>>(32-18);\n }\n x0 = x0 + j0 | 0;\n x1 = x1 + j1 | 0;\n x2 = x2 + j2 | 0;\n x3 = x3 + j3 | 0;\n x4 = x4 + j4 | 0;\n x5 = x5 + j5 | 0;\n x6 = x6 + j6 | 0;\n x7 = x7 + j7 | 0;\n x8 = x8 + j8 | 0;\n x9 = x9 + j9 | 0;\n x10 = x10 + j10 | 0;\n x11 = x11 + j11 | 0;\n x12 = x12 + j12 | 0;\n x13 = x13 + j13 | 0;\n x14 = x14 + j14 | 0;\n x15 = x15 + j15 | 0;\n\n o[ 0] = x0 >>> 0 & 0xff;\n o[ 1] = x0 >>> 8 & 0xff;\n o[ 2] = x0 >>> 16 & 0xff;\n o[ 3] = x0 >>> 24 & 0xff;\n\n o[ 4] = x1 >>> 0 & 0xff;\n o[ 5] = x1 >>> 8 & 0xff;\n o[ 6] = x1 >>> 16 & 0xff;\n o[ 7] = x1 >>> 24 & 0xff;\n\n o[ 8] = x2 >>> 0 & 0xff;\n o[ 9] = x2 >>> 8 & 0xff;\n o[10] = x2 >>> 16 & 0xff;\n o[11] = x2 >>> 24 & 0xff;\n\n o[12] = x3 >>> 0 & 0xff;\n o[13] = x3 >>> 8 & 0xff;\n o[14] = x3 >>> 16 & 0xff;\n o[15] = x3 >>> 24 & 0xff;\n\n o[16] = x4 >>> 0 & 0xff;\n o[17] = x4 >>> 8 & 0xff;\n o[18] = x4 >>> 16 & 0xff;\n o[19] = x4 >>> 24 & 0xff;\n\n o[20] = x5 >>> 0 & 0xff;\n o[21] = x5 >>> 8 & 0xff;\n o[22] = x5 >>> 16 & 0xff;\n o[23] = x5 >>> 24 & 0xff;\n\n o[24] = x6 >>> 0 & 0xff;\n o[25] = x6 >>> 8 & 0xff;\n o[26] = x6 >>> 16 & 0xff;\n o[27] = x6 >>> 24 & 0xff;\n\n o[28] = x7 >>> 0 & 0xff;\n o[29] = x7 >>> 8 & 0xff;\n o[30] = x7 >>> 16 & 0xff;\n o[31] = x7 >>> 24 & 0xff;\n\n o[32] = x8 >>> 0 & 0xff;\n o[33] = x8 >>> 8 & 0xff;\n o[34] = x8 >>> 16 & 0xff;\n o[35] = x8 >>> 24 & 0xff;\n\n o[36] = x9 >>> 0 & 0xff;\n o[37] = x9 >>> 8 & 0xff;\n o[38] = x9 >>> 16 & 0xff;\n o[39] = x9 >>> 24 & 0xff;\n\n o[40] = x10 >>> 0 & 0xff;\n o[41] = x10 >>> 8 & 0xff;\n o[42] = x10 >>> 16 & 0xff;\n o[43] = x10 >>> 24 & 0xff;\n\n o[44] = x11 >>> 0 & 0xff;\n o[45] = x11 >>> 8 & 0xff;\n o[46] = x11 >>> 16 & 0xff;\n o[47] = x11 >>> 24 & 0xff;\n\n o[48] = x12 >>> 0 & 0xff;\n o[49] = x12 >>> 8 & 0xff;\n o[50] = x12 >>> 16 & 0xff;\n o[51] = x12 >>> 24 & 0xff;\n\n o[52] = x13 >>> 0 & 0xff;\n o[53] = x13 >>> 8 & 0xff;\n o[54] = x13 >>> 16 & 0xff;\n o[55] = x13 >>> 24 & 0xff;\n\n o[56] = x14 >>> 0 & 0xff;\n o[57] = x14 >>> 8 & 0xff;\n o[58] = x14 >>> 16 & 0xff;\n o[59] = x14 >>> 24 & 0xff;\n\n o[60] = x15 >>> 0 & 0xff;\n o[61] = x15 >>> 8 & 0xff;\n o[62] = x15 >>> 16 & 0xff;\n o[63] = x15 >>> 24 & 0xff;\n}\n\nfunction core_hsalsa20(o,p,k,c) {\n var j0 = c[ 0] & 0xff | (c[ 1] & 0xff)<<8 | (c[ 2] & 0xff)<<16 | (c[ 3] & 0xff)<<24,\n j1 = k[ 0] & 0xff | (k[ 1] & 0xff)<<8 | (k[ 2] & 0xff)<<16 | (k[ 3] & 0xff)<<24,\n j2 = k[ 4] & 0xff | (k[ 5] & 0xff)<<8 | (k[ 6] & 0xff)<<16 | (k[ 7] & 0xff)<<24,\n j3 = k[ 8] & 0xff | (k[ 9] & 0xff)<<8 | (k[10] & 0xff)<<16 | (k[11] & 0xff)<<24,\n j4 = k[12] & 0xff | (k[13] & 0xff)<<8 | (k[14] & 0xff)<<16 | (k[15] & 0xff)<<24,\n j5 = c[ 4] & 0xff | (c[ 5] & 0xff)<<8 | (c[ 6] & 0xff)<<16 | (c[ 7] & 0xff)<<24,\n j6 = p[ 0] & 0xff | (p[ 1] & 0xff)<<8 | (p[ 2] & 0xff)<<16 | (p[ 3] & 0xff)<<24,\n j7 = p[ 4] & 0xff | (p[ 5] & 0xff)<<8 | (p[ 6] & 0xff)<<16 | (p[ 7] & 0xff)<<24,\n j8 = p[ 8] & 0xff | (p[ 9] & 0xff)<<8 | (p[10] & 0xff)<<16 | (p[11] & 0xff)<<24,\n j9 = p[12] & 0xff | (p[13] & 0xff)<<8 | (p[14] & 0xff)<<16 | (p[15] & 0xff)<<24,\n j10 = c[ 8] & 0xff | (c[ 9] & 0xff)<<8 | (c[10] & 0xff)<<16 | (c[11] & 0xff)<<24,\n j11 = k[16] & 0xff | (k[17] & 0xff)<<8 | (k[18] & 0xff)<<16 | (k[19] & 0xff)<<24,\n j12 = k[20] & 0xff | (k[21] & 0xff)<<8 | (k[22] & 0xff)<<16 | (k[23] & 0xff)<<24,\n j13 = k[24] & 0xff | (k[25] & 0xff)<<8 | (k[26] & 0xff)<<16 | (k[27] & 0xff)<<24,\n j14 = k[28] & 0xff | (k[29] & 0xff)<<8 | (k[30] & 0xff)<<16 | (k[31] & 0xff)<<24,\n j15 = c[12] & 0xff | (c[13] & 0xff)<<8 | (c[14] & 0xff)<<16 | (c[15] & 0xff)<<24;\n\n var x0 = j0, x1 = j1, x2 = j2, x3 = j3, x4 = j4, x5 = j5, x6 = j6, x7 = j7,\n x8 = j8, x9 = j9, x10 = j10, x11 = j11, x12 = j12, x13 = j13, x14 = j14,\n x15 = j15, u;\n\n for (var i = 0; i < 20; i += 2) {\n u = x0 + x12 | 0;\n x4 ^= u<<7 | u>>>(32-7);\n u = x4 + x0 | 0;\n x8 ^= u<<9 | u>>>(32-9);\n u = x8 + x4 | 0;\n x12 ^= u<<13 | u>>>(32-13);\n u = x12 + x8 | 0;\n x0 ^= u<<18 | u>>>(32-18);\n\n u = x5 + x1 | 0;\n x9 ^= u<<7 | u>>>(32-7);\n u = x9 + x5 | 0;\n x13 ^= u<<9 | u>>>(32-9);\n u = x13 + x9 | 0;\n x1 ^= u<<13 | u>>>(32-13);\n u = x1 + x13 | 0;\n x5 ^= u<<18 | u>>>(32-18);\n\n u = x10 + x6 | 0;\n x14 ^= u<<7 | u>>>(32-7);\n u = x14 + x10 | 0;\n x2 ^= u<<9 | u>>>(32-9);\n u = x2 + x14 | 0;\n x6 ^= u<<13 | u>>>(32-13);\n u = x6 + x2 | 0;\n x10 ^= u<<18 | u>>>(32-18);\n\n u = x15 + x11 | 0;\n x3 ^= u<<7 | u>>>(32-7);\n u = x3 + x15 | 0;\n x7 ^= u<<9 | u>>>(32-9);\n u = x7 + x3 | 0;\n x11 ^= u<<13 | u>>>(32-13);\n u = x11 + x7 | 0;\n x15 ^= u<<18 | u>>>(32-18);\n\n u = x0 + x3 | 0;\n x1 ^= u<<7 | u>>>(32-7);\n u = x1 + x0 | 0;\n x2 ^= u<<9 | u>>>(32-9);\n u = x2 + x1 | 0;\n x3 ^= u<<13 | u>>>(32-13);\n u = x3 + x2 | 0;\n x0 ^= u<<18 | u>>>(32-18);\n\n u = x5 + x4 | 0;\n x6 ^= u<<7 | u>>>(32-7);\n u = x6 + x5 | 0;\n x7 ^= u<<9 | u>>>(32-9);\n u = x7 + x6 | 0;\n x4 ^= u<<13 | u>>>(32-13);\n u = x4 + x7 | 0;\n x5 ^= u<<18 | u>>>(32-18);\n\n u = x10 + x9 | 0;\n x11 ^= u<<7 | u>>>(32-7);\n u = x11 + x10 | 0;\n x8 ^= u<<9 | u>>>(32-9);\n u = x8 + x11 | 0;\n x9 ^= u<<13 | u>>>(32-13);\n u = x9 + x8 | 0;\n x10 ^= u<<18 | u>>>(32-18);\n\n u = x15 + x14 | 0;\n x12 ^= u<<7 | u>>>(32-7);\n u = x12 + x15 | 0;\n x13 ^= u<<9 | u>>>(32-9);\n u = x13 + x12 | 0;\n x14 ^= u<<13 | u>>>(32-13);\n u = x14 + x13 | 0;\n x15 ^= u<<18 | u>>>(32-18);\n }\n\n o[ 0] = x0 >>> 0 & 0xff;\n o[ 1] = x0 >>> 8 & 0xff;\n o[ 2] = x0 >>> 16 & 0xff;\n o[ 3] = x0 >>> 24 & 0xff;\n\n o[ 4] = x5 >>> 0 & 0xff;\n o[ 5] = x5 >>> 8 & 0xff;\n o[ 6] = x5 >>> 16 & 0xff;\n o[ 7] = x5 >>> 24 & 0xff;\n\n o[ 8] = x10 >>> 0 & 0xff;\n o[ 9] = x10 >>> 8 & 0xff;\n o[10] = x10 >>> 16 & 0xff;\n o[11] = x10 >>> 24 & 0xff;\n\n o[12] = x15 >>> 0 & 0xff;\n o[13] = x15 >>> 8 & 0xff;\n o[14] = x15 >>> 16 & 0xff;\n o[15] = x15 >>> 24 & 0xff;\n\n o[16] = x6 >>> 0 & 0xff;\n o[17] = x6 >>> 8 & 0xff;\n o[18] = x6 >>> 16 & 0xff;\n o[19] = x6 >>> 24 & 0xff;\n\n o[20] = x7 >>> 0 & 0xff;\n o[21] = x7 >>> 8 & 0xff;\n o[22] = x7 >>> 16 & 0xff;\n o[23] = x7 >>> 24 & 0xff;\n\n o[24] = x8 >>> 0 & 0xff;\n o[25] = x8 >>> 8 & 0xff;\n o[26] = x8 >>> 16 & 0xff;\n o[27] = x8 >>> 24 & 0xff;\n\n o[28] = x9 >>> 0 & 0xff;\n o[29] = x9 >>> 8 & 0xff;\n o[30] = x9 >>> 16 & 0xff;\n o[31] = x9 >>> 24 & 0xff;\n}\n\nfunction crypto_core_salsa20(out,inp,k,c) {\n core_salsa20(out,inp,k,c);\n}\n\nfunction crypto_core_hsalsa20(out,inp,k,c) {\n core_hsalsa20(out,inp,k,c);\n}\n\nvar sigma = new Uint8Array([101, 120, 112, 97, 110, 100, 32, 51, 50, 45, 98, 121, 116, 101, 32, 107]);\n // \"expand 32-byte k\"\n\nfunction crypto_stream_salsa20_xor(c,cpos,m,mpos,b,n,k) {\n var z = new Uint8Array(16), x = new Uint8Array(64);\n var u, i;\n for (i = 0; i < 16; i++) z[i] = 0;\n for (i = 0; i < 8; i++) z[i] = n[i];\n while (b >= 64) {\n crypto_core_salsa20(x,z,k,sigma);\n for (i = 0; i < 64; i++) c[cpos+i] = m[mpos+i] ^ x[i];\n u = 1;\n for (i = 8; i < 16; i++) {\n u = u + (z[i] & 0xff) | 0;\n z[i] = u & 0xff;\n u >>>= 8;\n }\n b -= 64;\n cpos += 64;\n mpos += 64;\n }\n if (b > 0) {\n crypto_core_salsa20(x,z,k,sigma);\n for (i = 0; i < b; i++) c[cpos+i] = m[mpos+i] ^ x[i];\n }\n return 0;\n}\n\nfunction crypto_stream_salsa20(c,cpos,b,n,k) {\n var z = new Uint8Array(16), x = new Uint8Array(64);\n var u, i;\n for (i = 0; i < 16; i++) z[i] = 0;\n for (i = 0; i < 8; i++) z[i] = n[i];\n while (b >= 64) {\n crypto_core_salsa20(x,z,k,sigma);\n for (i = 0; i < 64; i++) c[cpos+i] = x[i];\n u = 1;\n for (i = 8; i < 16; i++) {\n u = u + (z[i] & 0xff) | 0;\n z[i] = u & 0xff;\n u >>>= 8;\n }\n b -= 64;\n cpos += 64;\n }\n if (b > 0) {\n crypto_core_salsa20(x,z,k,sigma);\n for (i = 0; i < b; i++) c[cpos+i] = x[i];\n }\n return 0;\n}\n\nfunction crypto_stream(c,cpos,d,n,k) {\n var s = new Uint8Array(32);\n crypto_core_hsalsa20(s,n,k,sigma);\n var sn = new Uint8Array(8);\n for (var i = 0; i < 8; i++) sn[i] = n[i+16];\n return crypto_stream_salsa20(c,cpos,d,sn,s);\n}\n\nfunction crypto_stream_xor(c,cpos,m,mpos,d,n,k) {\n var s = new Uint8Array(32);\n crypto_core_hsalsa20(s,n,k,sigma);\n var sn = new Uint8Array(8);\n for (var i = 0; i < 8; i++) sn[i] = n[i+16];\n return crypto_stream_salsa20_xor(c,cpos,m,mpos,d,sn,s);\n}\n\n/*\n* Port of Andrew Moon's Poly1305-donna-16. Public domain.\n* https://github.com/floodyberry/poly1305-donna\n*/\n\nvar poly1305 = function(key) {\n this.buffer = new Uint8Array(16);\n this.r = new Uint16Array(10);\n this.h = new Uint16Array(10);\n this.pad = new Uint16Array(8);\n this.leftover = 0;\n this.fin = 0;\n\n var t0, t1, t2, t3, t4, t5, t6, t7;\n\n t0 = key[ 0] & 0xff | (key[ 1] & 0xff) << 8; this.r[0] = ( t0 ) & 0x1fff;\n t1 = key[ 2] & 0xff | (key[ 3] & 0xff) << 8; this.r[1] = ((t0 >>> 13) | (t1 << 3)) & 0x1fff;\n t2 = key[ 4] & 0xff | (key[ 5] & 0xff) << 8; this.r[2] = ((t1 >>> 10) | (t2 << 6)) & 0x1f03;\n t3 = key[ 6] & 0xff | (key[ 7] & 0xff) << 8; this.r[3] = ((t2 >>> 7) | (t3 << 9)) & 0x1fff;\n t4 = key[ 8] & 0xff | (key[ 9] & 0xff) << 8; this.r[4] = ((t3 >>> 4) | (t4 << 12)) & 0x00ff;\n this.r[5] = ((t4 >>> 1)) & 0x1ffe;\n t5 = key[10] & 0xff | (key[11] & 0xff) << 8; this.r[6] = ((t4 >>> 14) | (t5 << 2)) & 0x1fff;\n t6 = key[12] & 0xff | (key[13] & 0xff) << 8; this.r[7] = ((t5 >>> 11) | (t6 << 5)) & 0x1f81;\n t7 = key[14] & 0xff | (key[15] & 0xff) << 8; this.r[8] = ((t6 >>> 8) | (t7 << 8)) & 0x1fff;\n this.r[9] = ((t7 >>> 5)) & 0x007f;\n\n this.pad[0] = key[16] & 0xff | (key[17] & 0xff) << 8;\n this.pad[1] = key[18] & 0xff | (key[19] & 0xff) << 8;\n this.pad[2] = key[20] & 0xff | (key[21] & 0xff) << 8;\n this.pad[3] = key[22] & 0xff | (key[23] & 0xff) << 8;\n this.pad[4] = key[24] & 0xff | (key[25] & 0xff) << 8;\n this.pad[5] = key[26] & 0xff | (key[27] & 0xff) << 8;\n this.pad[6] = key[28] & 0xff | (key[29] & 0xff) << 8;\n this.pad[7] = key[30] & 0xff | (key[31] & 0xff) << 8;\n};\n\npoly1305.prototype.blocks = function(m, mpos, bytes) {\n var hibit = this.fin ? 0 : (1 << 11);\n var t0, t1, t2, t3, t4, t5, t6, t7, c;\n var d0, d1, d2, d3, d4, d5, d6, d7, d8, d9;\n\n var h0 = this.h[0],\n h1 = this.h[1],\n h2 = this.h[2],\n h3 = this.h[3],\n h4 = this.h[4],\n h5 = this.h[5],\n h6 = this.h[6],\n h7 = this.h[7],\n h8 = this.h[8],\n h9 = this.h[9];\n\n var r0 = this.r[0],\n r1 = this.r[1],\n r2 = this.r[2],\n r3 = this.r[3],\n r4 = this.r[4],\n r5 = this.r[5],\n r6 = this.r[6],\n r7 = this.r[7],\n r8 = this.r[8],\n r9 = this.r[9];\n\n while (bytes >= 16) {\n t0 = m[mpos+ 0] & 0xff | (m[mpos+ 1] & 0xff) << 8; h0 += ( t0 ) & 0x1fff;\n t1 = m[mpos+ 2] & 0xff | (m[mpos+ 3] & 0xff) << 8; h1 += ((t0 >>> 13) | (t1 << 3)) & 0x1fff;\n t2 = m[mpos+ 4] & 0xff | (m[mpos+ 5] & 0xff) << 8; h2 += ((t1 >>> 10) | (t2 << 6)) & 0x1fff;\n t3 = m[mpos+ 6] & 0xff | (m[mpos+ 7] & 0xff) << 8; h3 += ((t2 >>> 7) | (t3 << 9)) & 0x1fff;\n t4 = m[mpos+ 8] & 0xff | (m[mpos+ 9] & 0xff) << 8; h4 += ((t3 >>> 4) | (t4 << 12)) & 0x1fff;\n h5 += ((t4 >>> 1)) & 0x1fff;\n t5 = m[mpos+10] & 0xff | (m[mpos+11] & 0xff) << 8; h6 += ((t4 >>> 14) | (t5 << 2)) & 0x1fff;\n t6 = m[mpos+12] & 0xff | (m[mpos+13] & 0xff) << 8; h7 += ((t5 >>> 11) | (t6 << 5)) & 0x1fff;\n t7 = m[mpos+14] & 0xff | (m[mpos+15] & 0xff) << 8; h8 += ((t6 >>> 8) | (t7 << 8)) & 0x1fff;\n h9 += ((t7 >>> 5)) | hibit;\n\n c = 0;\n\n d0 = c;\n d0 += h0 * r0;\n d0 += h1 * (5 * r9);\n d0 += h2 * (5 * r8);\n d0 += h3 * (5 * r7);\n d0 += h4 * (5 * r6);\n c = (d0 >>> 13); d0 &= 0x1fff;\n d0 += h5 * (5 * r5);\n d0 += h6 * (5 * r4);\n d0 += h7 * (5 * r3);\n d0 += h8 * (5 * r2);\n d0 += h9 * (5 * r1);\n c += (d0 >>> 13); d0 &= 0x1fff;\n\n d1 = c;\n d1 += h0 * r1;\n d1 += h1 * r0;\n d1 += h2 * (5 * r9);\n d1 += h3 * (5 * r8);\n d1 += h4 * (5 * r7);\n c = (d1 >>> 13); d1 &= 0x1fff;\n d1 += h5 * (5 * r6);\n d1 += h6 * (5 * r5);\n d1 += h7 * (5 * r4);\n d1 += h8 * (5 * r3);\n d1 += h9 * (5 * r2);\n c += (d1 >>> 13); d1 &= 0x1fff;\n\n d2 = c;\n d2 += h0 * r2;\n d2 += h1 * r1;\n d2 += h2 * r0;\n d2 += h3 * (5 * r9);\n d2 += h4 * (5 * r8);\n c = (d2 >>> 13); d2 &= 0x1fff;\n d2 += h5 * (5 * r7);\n d2 += h6 * (5 * r6);\n d2 += h7 * (5 * r5);\n d2 += h8 * (5 * r4);\n d2 += h9 * (5 * r3);\n c += (d2 >>> 13); d2 &= 0x1fff;\n\n d3 = c;\n d3 += h0 * r3;\n d3 += h1 * r2;\n d3 += h2 * r1;\n d3 += h3 * r0;\n d3 += h4 * (5 * r9);\n c = (d3 >>> 13); d3 &= 0x1fff;\n d3 += h5 * (5 * r8);\n d3 += h6 * (5 * r7);\n d3 += h7 * (5 * r6);\n d3 += h8 * (5 * r5);\n d3 += h9 * (5 * r4);\n c += (d3 >>> 13); d3 &= 0x1fff;\n\n d4 = c;\n d4 += h0 * r4;\n d4 += h1 * r3;\n d4 += h2 * r2;\n d4 += h3 * r1;\n d4 += h4 * r0;\n c = (d4 >>> 13); d4 &= 0x1fff;\n d4 += h5 * (5 * r9);\n d4 += h6 * (5 * r8);\n d4 += h7 * (5 * r7);\n d4 += h8 * (5 * r6);\n d4 += h9 * (5 * r5);\n c += (d4 >>> 13); d4 &= 0x1fff;\n\n d5 = c;\n d5 += h0 * r5;\n d5 += h1 * r4;\n d5 += h2 * r3;\n d5 += h3 * r2;\n d5 += h4 * r1;\n c = (d5 >>> 13); d5 &= 0x1fff;\n d5 += h5 * r0;\n d5 += h6 * (5 * r9);\n d5 += h7 * (5 * r8);\n d5 += h8 * (5 * r7);\n d5 += h9 * (5 * r6);\n c += (d5 >>> 13); d5 &= 0x1fff;\n\n d6 = c;\n d6 += h0 * r6;\n d6 += h1 * r5;\n d6 += h2 * r4;\n d6 += h3 * r3;\n d6 += h4 * r2;\n c = (d6 >>> 13); d6 &= 0x1fff;\n d6 += h5 * r1;\n d6 += h6 * r0;\n d6 += h7 * (5 * r9);\n d6 += h8 * (5 * r8);\n d6 += h9 * (5 * r7);\n c += (d6 >>> 13); d6 &= 0x1fff;\n\n d7 = c;\n d7 += h0 * r7;\n d7 += h1 * r6;\n d7 += h2 * r5;\n d7 += h3 * r4;\n d7 += h4 * r3;\n c = (d7 >>> 13); d7 &= 0x1fff;\n d7 += h5 * r2;\n d7 += h6 * r1;\n d7 += h7 * r0;\n d7 += h8 * (5 * r9);\n d7 += h9 * (5 * r8);\n c += (d7 >>> 13); d7 &= 0x1fff;\n\n d8 = c;\n d8 += h0 * r8;\n d8 += h1 * r7;\n d8 += h2 * r6;\n d8 += h3 * r5;\n d8 += h4 * r4;\n c = (d8 >>> 13); d8 &= 0x1fff;\n d8 += h5 * r3;\n d8 += h6 * r2;\n d8 += h7 * r1;\n d8 += h8 * r0;\n d8 += h9 * (5 * r9);\n c += (d8 >>> 13); d8 &= 0x1fff;\n\n d9 = c;\n d9 += h0 * r9;\n d9 += h1 * r8;\n d9 += h2 * r7;\n d9 += h3 * r6;\n d9 += h4 * r5;\n c = (d9 >>> 13); d9 &= 0x1fff;\n d9 += h5 * r4;\n d9 += h6 * r3;\n d9 += h7 * r2;\n d9 += h8 * r1;\n d9 += h9 * r0;\n c += (d9 >>> 13); d9 &= 0x1fff;\n\n c = (((c << 2) + c)) | 0;\n c = (c + d0) | 0;\n d0 = c & 0x1fff;\n c = (c >>> 13);\n d1 += c;\n\n h0 = d0;\n h1 = d1;\n h2 = d2;\n h3 = d3;\n h4 = d4;\n h5 = d5;\n h6 = d6;\n h7 = d7;\n h8 = d8;\n h9 = d9;\n\n mpos += 16;\n bytes -= 16;\n }\n this.h[0] = h0;\n this.h[1] = h1;\n this.h[2] = h2;\n this.h[3] = h3;\n this.h[4] = h4;\n this.h[5] = h5;\n this.h[6] = h6;\n this.h[7] = h7;\n this.h[8] = h8;\n this.h[9] = h9;\n};\n\npoly1305.prototype.finish = function(mac, macpos) {\n var g = new Uint16Array(10);\n var c, mask, f, i;\n\n if (this.leftover) {\n i = this.leftover;\n this.buffer[i++] = 1;\n for (; i < 16; i++) this.buffer[i] = 0;\n this.fin = 1;\n this.blocks(this.buffer, 0, 16);\n }\n\n c = this.h[1] >>> 13;\n this.h[1] &= 0x1fff;\n for (i = 2; i < 10; i++) {\n this.h[i] += c;\n c = this.h[i] >>> 13;\n this.h[i] &= 0x1fff;\n }\n this.h[0] += (c * 5);\n c = this.h[0] >>> 13;\n this.h[0] &= 0x1fff;\n this.h[1] += c;\n c = this.h[1] >>> 13;\n this.h[1] &= 0x1fff;\n this.h[2] += c;\n\n g[0] = this.h[0] + 5;\n c = g[0] >>> 13;\n g[0] &= 0x1fff;\n for (i = 1; i < 10; i++) {\n g[i] = this.h[i] + c;\n c = g[i] >>> 13;\n g[i] &= 0x1fff;\n }\n g[9] -= (1 << 13);\n\n mask = (c ^ 1) - 1;\n for (i = 0; i < 10; i++) g[i] &= mask;\n mask = ~mask;\n for (i = 0; i < 10; i++) this.h[i] = (this.h[i] & mask) | g[i];\n\n this.h[0] = ((this.h[0] ) | (this.h[1] << 13) ) & 0xffff;\n this.h[1] = ((this.h[1] >>> 3) | (this.h[2] << 10) ) & 0xffff;\n this.h[2] = ((this.h[2] >>> 6) | (this.h[3] << 7) ) & 0xffff;\n this.h[3] = ((this.h[3] >>> 9) | (this.h[4] << 4) ) & 0xffff;\n this.h[4] = ((this.h[4] >>> 12) | (this.h[5] << 1) | (this.h[6] << 14)) & 0xffff;\n this.h[5] = ((this.h[6] >>> 2) | (this.h[7] << 11) ) & 0xffff;\n this.h[6] = ((this.h[7] >>> 5) | (this.h[8] << 8) ) & 0xffff;\n this.h[7] = ((this.h[8] >>> 8) | (this.h[9] << 5) ) & 0xffff;\n\n f = this.h[0] + this.pad[0];\n this.h[0] = f & 0xffff;\n for (i = 1; i < 8; i++) {\n f = (((this.h[i] + this.pad[i]) | 0) + (f >>> 16)) | 0;\n this.h[i] = f & 0xffff;\n }\n\n mac[macpos+ 0] = (this.h[0] >>> 0) & 0xff;\n mac[macpos+ 1] = (this.h[0] >>> 8) & 0xff;\n mac[macpos+ 2] = (this.h[1] >>> 0) & 0xff;\n mac[macpos+ 3] = (this.h[1] >>> 8) & 0xff;\n mac[macpos+ 4] = (this.h[2] >>> 0) & 0xff;\n mac[macpos+ 5] = (this.h[2] >>> 8) & 0xff;\n mac[macpos+ 6] = (this.h[3] >>> 0) & 0xff;\n mac[macpos+ 7] = (this.h[3] >>> 8) & 0xff;\n mac[macpos+ 8] = (this.h[4] >>> 0) & 0xff;\n mac[macpos+ 9] = (this.h[4] >>> 8) & 0xff;\n mac[macpos+10] = (this.h[5] >>> 0) & 0xff;\n mac[macpos+11] = (this.h[5] >>> 8) & 0xff;\n mac[macpos+12] = (this.h[6] >>> 0) & 0xff;\n mac[macpos+13] = (this.h[6] >>> 8) & 0xff;\n mac[macpos+14] = (this.h[7] >>> 0) & 0xff;\n mac[macpos+15] = (this.h[7] >>> 8) & 0xff;\n};\n\npoly1305.prototype.update = function(m, mpos, bytes) {\n var i, want;\n\n if (this.leftover) {\n want = (16 - this.leftover);\n if (want > bytes)\n want = bytes;\n for (i = 0; i < want; i++)\n this.buffer[this.leftover + i] = m[mpos+i];\n bytes -= want;\n mpos += want;\n this.leftover += want;\n if (this.leftover < 16)\n return;\n this.blocks(this.buffer, 0, 16);\n this.leftover = 0;\n }\n\n if (bytes >= 16) {\n want = bytes - (bytes % 16);\n this.blocks(m, mpos, want);\n mpos += want;\n bytes -= want;\n }\n\n if (bytes) {\n for (i = 0; i < bytes; i++)\n this.buffer[this.leftover + i] = m[mpos+i];\n this.leftover += bytes;\n }\n};\n\nfunction crypto_onetimeauth(out, outpos, m, mpos, n, k) {\n var s = new poly1305(k);\n s.update(m, mpos, n);\n s.finish(out, outpos);\n return 0;\n}\n\nfunction crypto_onetimeauth_verify(h, hpos, m, mpos, n, k) {\n var x = new Uint8Array(16);\n crypto_onetimeauth(x,0,m,mpos,n,k);\n return crypto_verify_16(h,hpos,x,0);\n}\n\nfunction crypto_secretbox(c,m,d,n,k) {\n var i;\n if (d < 32) return -1;\n crypto_stream_xor(c,0,m,0,d,n,k);\n crypto_onetimeauth(c, 16, c, 32, d - 32, c);\n for (i = 0; i < 16; i++) c[i] = 0;\n return 0;\n}\n\nfunction crypto_secretbox_open(m,c,d,n,k) {\n var i;\n var x = new Uint8Array(32);\n if (d < 32) return -1;\n crypto_stream(x,0,32,n,k);\n if (crypto_onetimeauth_verify(c, 16,c, 32,d - 32,x) !== 0) return -1;\n crypto_stream_xor(m,0,c,0,d,n,k);\n for (i = 0; i < 32; i++) m[i] = 0;\n return 0;\n}\n\nfunction set25519(r, a) {\n var i;\n for (i = 0; i < 16; i++) r[i] = a[i]|0;\n}\n\nfunction car25519(o) {\n var i, v, c = 1;\n for (i = 0; i < 16; i++) {\n v = o[i] + c + 65535;\n c = Math.floor(v / 65536);\n o[i] = v - c * 65536;\n }\n o[0] += c-1 + 37 * (c-1);\n}\n\nfunction sel25519(p, q, b) {\n var t, c = ~(b-1);\n for (var i = 0; i < 16; i++) {\n t = c & (p[i] ^ q[i]);\n p[i] ^= t;\n q[i] ^= t;\n }\n}\n\nfunction pack25519(o, n) {\n var i, j, b;\n var m = gf(), t = gf();\n for (i = 0; i < 16; i++) t[i] = n[i];\n car25519(t);\n car25519(t);\n car25519(t);\n for (j = 0; j < 2; j++) {\n m[0] = t[0] - 0xffed;\n for (i = 1; i < 15; i++) {\n m[i] = t[i] - 0xffff - ((m[i-1]>>16) & 1);\n m[i-1] &= 0xffff;\n }\n m[15] = t[15] - 0x7fff - ((m[14]>>16) & 1);\n b = (m[15]>>16) & 1;\n m[14] &= 0xffff;\n sel25519(t, m, 1-b);\n }\n for (i = 0; i < 16; i++) {\n o[2*i] = t[i] & 0xff;\n o[2*i+1] = t[i]>>8;\n }\n}\n\nfunction neq25519(a, b) {\n var c = new Uint8Array(32), d = new Uint8Array(32);\n pack25519(c, a);\n pack25519(d, b);\n return crypto_verify_32(c, 0, d, 0);\n}\n\nfunction par25519(a) {\n var d = new Uint8Array(32);\n pack25519(d, a);\n return d[0] & 1;\n}\n\nfunction unpack25519(o, n) {\n var i;\n for (i = 0; i < 16; i++) o[i] = n[2*i] + (n[2*i+1] << 8);\n o[15] &= 0x7fff;\n}\n\nfunction A(o, a, b) {\n for (var i = 0; i < 16; i++) o[i] = a[i] + b[i];\n}\n\nfunction Z(o, a, b) {\n for (var i = 0; i < 16; i++) o[i] = a[i] - b[i];\n}\n\nfunction M(o, a, b) {\n var v, c,\n t0 = 0, t1 = 0, t2 = 0, t3 = 0, t4 = 0, t5 = 0, t6 = 0, t7 = 0,\n t8 = 0, t9 = 0, t10 = 0, t11 = 0, t12 = 0, t13 = 0, t14 = 0, t15 = 0,\n t16 = 0, t17 = 0, t18 = 0, t19 = 0, t20 = 0, t21 = 0, t22 = 0, t23 = 0,\n t24 = 0, t25 = 0, t26 = 0, t27 = 0, t28 = 0, t29 = 0, t30 = 0,\n b0 = b[0],\n b1 = b[1],\n b2 = b[2],\n b3 = b[3],\n b4 = b[4],\n b5 = b[5],\n b6 = b[6],\n b7 = b[7],\n b8 = b[8],\n b9 = b[9],\n b10 = b[10],\n b11 = b[11],\n b12 = b[12],\n b13 = b[13],\n b14 = b[14],\n b15 = b[15];\n\n v = a[0];\n t0 += v * b0;\n t1 += v * b1;\n t2 += v * b2;\n t3 += v * b3;\n t4 += v * b4;\n t5 += v * b5;\n t6 += v * b6;\n t7 += v * b7;\n t8 += v * b8;\n t9 += v * b9;\n t10 += v * b10;\n t11 += v * b11;\n t12 += v * b12;\n t13 += v * b13;\n t14 += v * b14;\n t15 += v * b15;\n v = a[1];\n t1 += v * b0;\n t2 += v * b1;\n t3 += v * b2;\n t4 += v * b3;\n t5 += v * b4;\n t6 += v * b5;\n t7 += v * b6;\n t8 += v * b7;\n t9 += v * b8;\n t10 += v * b9;\n t11 += v * b10;\n t12 += v * b11;\n t13 += v * b12;\n t14 += v * b13;\n t15 += v * b14;\n t16 += v * b15;\n v = a[2];\n t2 += v * b0;\n t3 += v * b1;\n t4 += v * b2;\n t5 += v * b3;\n t6 += v * b4;\n t7 += v * b5;\n t8 += v * b6;\n t9 += v * b7;\n t10 += v * b8;\n t11 += v * b9;\n t12 += v * b10;\n t13 += v * b11;\n t14 += v * b12;\n t15 += v * b13;\n t16 += v * b14;\n t17 += v * b15;\n v = a[3];\n t3 += v * b0;\n t4 += v * b1;\n t5 += v * b2;\n t6 += v * b3;\n t7 += v * b4;\n t8 += v * b5;\n t9 += v * b6;\n t10 += v * b7;\n t11 += v * b8;\n t12 += v * b9;\n t13 += v * b10;\n t14 += v * b11;\n t15 += v * b12;\n t16 += v * b13;\n t17 += v * b14;\n t18 += v * b15;\n v = a[4];\n t4 += v * b0;\n t5 += v * b1;\n t6 += v * b2;\n t7 += v * b3;\n t8 += v * b4;\n t9 += v * b5;\n t10 += v * b6;\n t11 += v * b7;\n t12 += v * b8;\n t13 += v * b9;\n t14 += v * b10;\n t15 += v * b11;\n t16 += v * b12;\n t17 += v * b13;\n t18 += v * b14;\n t19 += v * b15;\n v = a[5];\n t5 += v * b0;\n t6 += v * b1;\n t7 += v * b2;\n t8 += v * b3;\n t9 += v * b4;\n t10 += v * b5;\n t11 += v * b6;\n t12 += v * b7;\n t13 += v * b8;\n t14 += v * b9;\n t15 += v * b10;\n t16 += v * b11;\n t17 += v * b12;\n t18 += v * b13;\n t19 += v * b14;\n t20 += v * b15;\n v = a[6];\n t6 += v * b0;\n t7 += v * b1;\n t8 += v * b2;\n t9 += v * b3;\n t10 += v * b4;\n t11 += v * b5;\n t12 += v * b6;\n t13 += v * b7;\n t14 += v * b8;\n t15 += v * b9;\n t16 += v * b10;\n t17 += v * b11;\n t18 += v * b12;\n t19 += v * b13;\n t20 += v * b14;\n t21 += v * b15;\n v = a[7];\n t7 += v * b0;\n t8 += v * b1;\n t9 += v * b2;\n t10 += v * b3;\n t11 += v * b4;\n t12 += v * b5;\n t13 += v * b6;\n t14 += v * b7;\n t15 += v * b8;\n t16 += v * b9;\n t17 += v * b10;\n t18 += v * b11;\n t19 += v * b12;\n t20 += v * b13;\n t21 += v * b14;\n t22 += v * b15;\n v = a[8];\n t8 += v * b0;\n t9 += v * b1;\n t10 += v * b2;\n t11 += v * b3;\n t12 += v * b4;\n t13 += v * b5;\n t14 += v * b6;\n t15 += v * b7;\n t16 += v * b8;\n t17 += v * b9;\n t18 += v * b10;\n t19 += v * b11;\n t20 += v * b12;\n t21 += v * b13;\n t22 += v * b14;\n t23 += v * b15;\n v = a[9];\n t9 += v * b0;\n t10 += v * b1;\n t11 += v * b2;\n t12 += v * b3;\n t13 += v * b4;\n t14 += v * b5;\n t15 += v * b6;\n t16 += v * b7;\n t17 += v * b8;\n t18 += v * b9;\n t19 += v * b10;\n t20 += v * b11;\n t21 += v * b12;\n t22 += v * b13;\n t23 += v * b14;\n t24 += v * b15;\n v = a[10];\n t10 += v * b0;\n t11 += v * b1;\n t12 += v * b2;\n t13 += v * b3;\n t14 += v * b4;\n t15 += v * b5;\n t16 += v * b6;\n t17 += v * b7;\n t18 += v * b8;\n t19 += v * b9;\n t20 += v * b10;\n t21 += v * b11;\n t22 += v * b12;\n t23 += v * b13;\n t24 += v * b14;\n t25 += v * b15;\n v = a[11];\n t11 += v * b0;\n t12 += v * b1;\n t13 += v * b2;\n t14 += v * b3;\n t15 += v * b4;\n t16 += v * b5;\n t17 += v * b6;\n t18 += v * b7;\n t19 += v * b8;\n t20 += v * b9;\n t21 += v * b10;\n t22 += v * b11;\n t23 += v * b12;\n t24 += v * b13;\n t25 += v * b14;\n t26 += v * b15;\n v = a[12];\n t12 += v * b0;\n t13 += v * b1;\n t14 += v * b2;\n t15 += v * b3;\n t16 += v * b4;\n t17 += v * b5;\n t18 += v * b6;\n t19 += v * b7;\n t20 += v * b8;\n t21 += v * b9;\n t22 += v * b10;\n t23 += v * b11;\n t24 += v * b12;\n t25 += v * b13;\n t26 += v * b14;\n t27 += v * b15;\n v = a[13];\n t13 += v * b0;\n t14 += v * b1;\n t15 += v * b2;\n t16 += v * b3;\n t17 += v * b4;\n t18 += v * b5;\n t19 += v * b6;\n t20 += v * b7;\n t21 += v * b8;\n t22 += v * b9;\n t23 += v * b10;\n t24 += v * b11;\n t25 += v * b12;\n t26 += v * b13;\n t27 += v * b14;\n t28 += v * b15;\n v = a[14];\n t14 += v * b0;\n t15 += v * b1;\n t16 += v * b2;\n t17 += v * b3;\n t18 += v * b4;\n t19 += v * b5;\n t20 += v * b6;\n t21 += v * b7;\n t22 += v * b8;\n t23 += v * b9;\n t24 += v * b10;\n t25 += v * b11;\n t26 += v * b12;\n t27 += v * b13;\n t28 += v * b14;\n t29 += v * b15;\n v = a[15];\n t15 += v * b0;\n t16 += v * b1;\n t17 += v * b2;\n t18 += v * b3;\n t19 += v * b4;\n t20 += v * b5;\n t21 += v * b6;\n t22 += v * b7;\n t23 += v * b8;\n t24 += v * b9;\n t25 += v * b10;\n t26 += v * b11;\n t27 += v * b12;\n t28 += v * b13;\n t29 += v * b14;\n t30 += v * b15;\n\n t0 += 38 * t16;\n t1 += 38 * t17;\n t2 += 38 * t18;\n t3 += 38 * t19;\n t4 += 38 * t20;\n t5 += 38 * t21;\n t6 += 38 * t22;\n t7 += 38 * t23;\n t8 += 38 * t24;\n t9 += 38 * t25;\n t10 += 38 * t26;\n t11 += 38 * t27;\n t12 += 38 * t28;\n t13 += 38 * t29;\n t14 += 38 * t30;\n // t15 left as is\n\n // first car\n c = 1;\n v = t0 + c + 65535; c = Math.floor(v / 65536); t0 = v - c * 65536;\n v = t1 + c + 65535; c = Math.floor(v / 65536); t1 = v - c * 65536;\n v = t2 + c + 65535; c = Math.floor(v / 65536); t2 = v - c * 65536;\n v = t3 + c + 65535; c = Math.floor(v / 65536); t3 = v - c * 65536;\n v = t4 + c + 65535; c = Math.floor(v / 65536); t4 = v - c * 65536;\n v = t5 + c + 65535; c = Math.floor(v / 65536); t5 = v - c * 65536;\n v = t6 + c + 65535; c = Math.floor(v / 65536); t6 = v - c * 65536;\n v = t7 + c + 65535; c = Math.floor(v / 65536); t7 = v - c * 65536;\n v = t8 + c + 65535; c = Math.floor(v / 65536); t8 = v - c * 65536;\n v = t9 + c + 65535; c = Math.floor(v / 65536); t9 = v - c * 65536;\n v = t10 + c + 65535; c = Math.floor(v / 65536); t10 = v - c * 65536;\n v = t11 + c + 65535; c = Math.floor(v / 65536); t11 = v - c * 65536;\n v = t12 + c + 65535; c = Math.floor(v / 65536); t12 = v - c * 65536;\n v = t13 + c + 65535; c = Math.floor(v / 65536); t13 = v - c * 65536;\n v = t14 + c + 65535; c = Math.floor(v / 65536); t14 = v - c * 65536;\n v = t15 + c + 65535; c = Math.floor(v / 65536); t15 = v - c * 65536;\n t0 += c-1 + 37 * (c-1);\n\n // second car\n c = 1;\n v = t0 + c + 65535; c = Math.floor(v / 65536); t0 = v - c * 65536;\n v = t1 + c + 65535; c = Math.floor(v / 65536); t1 = v - c * 65536;\n v = t2 + c + 65535; c = Math.floor(v / 65536); t2 = v - c * 65536;\n v = t3 + c + 65535; c = Math.floor(v / 65536); t3 = v - c * 65536;\n v = t4 + c + 65535; c = Math.floor(v / 65536); t4 = v - c * 65536;\n v = t5 + c + 65535; c = Math.floor(v / 65536); t5 = v - c * 65536;\n v = t6 + c + 65535; c = Math.floor(v / 65536); t6 = v - c * 65536;\n v = t7 + c + 65535; c = Math.floor(v / 65536); t7 = v - c * 65536;\n v = t8 + c + 65535; c = Math.floor(v / 65536); t8 = v - c * 65536;\n v = t9 + c + 65535; c = Math.floor(v / 65536); t9 = v - c * 65536;\n v = t10 + c + 65535; c = Math.floor(v / 65536); t10 = v - c * 65536;\n v = t11 + c + 65535; c = Math.floor(v / 65536); t11 = v - c * 65536;\n v = t12 + c + 65535; c = Math.floor(v / 65536); t12 = v - c * 65536;\n v = t13 + c + 65535; c = Math.floor(v / 65536); t13 = v - c * 65536;\n v = t14 + c + 65535; c = Math.floor(v / 65536); t14 = v - c * 65536;\n v = t15 + c + 65535; c = Math.floor(v / 65536); t15 = v - c * 65536;\n t0 += c-1 + 37 * (c-1);\n\n o[ 0] = t0;\n o[ 1] = t1;\n o[ 2] = t2;\n o[ 3] = t3;\n o[ 4] = t4;\n o[ 5] = t5;\n o[ 6] = t6;\n o[ 7] = t7;\n o[ 8] = t8;\n o[ 9] = t9;\n o[10] = t10;\n o[11] = t11;\n o[12] = t12;\n o[13] = t13;\n o[14] = t14;\n o[15] = t15;\n}\n\nfunction S(o, a) {\n M(o, a, a);\n}\n\nfunction inv25519(o, i) {\n var c = gf();\n var a;\n for (a = 0; a < 16; a++) c[a] = i[a];\n for (a = 253; a >= 0; a--) {\n S(c, c);\n if(a !== 2 && a !== 4) M(c, c, i);\n }\n for (a = 0; a < 16; a++) o[a] = c[a];\n}\n\nfunction pow2523(o, i) {\n var c = gf();\n var a;\n for (a = 0; a < 16; a++) c[a] = i[a];\n for (a = 250; a >= 0; a--) {\n S(c, c);\n if(a !== 1) M(c, c, i);\n }\n for (a = 0; a < 16; a++) o[a] = c[a];\n}\n\nfunction crypto_scalarmult(q, n, p) {\n var z = new Uint8Array(32);\n var x = new Float64Array(80), r, i;\n var a = gf(), b = gf(), c = gf(),\n d = gf(), e = gf(), f = gf();\n for (i = 0; i < 31; i++) z[i] = n[i];\n z[31]=(n[31]&127)|64;\n z[0]&=248;\n unpack25519(x,p);\n for (i = 0; i < 16; i++) {\n b[i]=x[i];\n d[i]=a[i]=c[i]=0;\n }\n a[0]=d[0]=1;\n for (i=254; i>=0; --i) {\n r=(z[i>>>3]>>>(i&7))&1;\n sel25519(a,b,r);\n sel25519(c,d,r);\n A(e,a,c);\n Z(a,a,c);\n A(c,b,d);\n Z(b,b,d);\n S(d,e);\n S(f,a);\n M(a,c,a);\n M(c,b,e);\n A(e,a,c);\n Z(a,a,c);\n S(b,a);\n Z(c,d,f);\n M(a,c,_121665);\n A(a,a,d);\n M(c,c,a);\n M(a,d,f);\n M(d,b,x);\n S(b,e);\n sel25519(a,b,r);\n sel25519(c,d,r);\n }\n for (i = 0; i < 16; i++) {\n x[i+16]=a[i];\n x[i+32]=c[i];\n x[i+48]=b[i];\n x[i+64]=d[i];\n }\n var x32 = x.subarray(32);\n var x16 = x.subarray(16);\n inv25519(x32,x32);\n M(x16,x16,x32);\n pack25519(q,x16);\n return 0;\n}\n\nfunction crypto_scalarmult_base(q, n) {\n return crypto_scalarmult(q, n, _9);\n}\n\nfunction crypto_box_keypair(y, x) {\n randombytes(x, 32);\n return crypto_scalarmult_base(y, x);\n}\n\nfunction crypto_box_beforenm(k, y, x) {\n var s = new Uint8Array(32);\n crypto_scalarmult(s, x, y);\n return crypto_core_hsalsa20(k, _0, s, sigma);\n}\n\nvar crypto_box_afternm = crypto_secretbox;\nvar crypto_box_open_afternm = crypto_secretbox_open;\n\nfunction crypto_box(c, m, d, n, y, x) {\n var k = new Uint8Array(32);\n crypto_box_beforenm(k, y, x);\n return crypto_box_afternm(c, m, d, n, k);\n}\n\nfunction crypto_box_open(m, c, d, n, y, x) {\n var k = new Uint8Array(32);\n crypto_box_beforenm(k, y, x);\n return crypto_box_open_afternm(m, c, d, n, k);\n}\n\nvar K = [\n 0x428a2f98, 0xd728ae22, 0x71374491, 0x23ef65cd,\n 0xb5c0fbcf, 0xec4d3b2f, 0xe9b5dba5, 0x8189dbbc,\n 0x3956c25b, 0xf348b538, 0x59f111f1, 0xb605d019,\n 0x923f82a4, 0xaf194f9b, 0xab1c5ed5, 0xda6d8118,\n 0xd807aa98, 0xa3030242, 0x12835b01, 0x45706fbe,\n 0x243185be, 0x4ee4b28c, 0x550c7dc3, 0xd5ffb4e2,\n 0x72be5d74, 0xf27b896f, 0x80deb1fe, 0x3b1696b1,\n 0x9bdc06a7, 0x25c71235, 0xc19bf174, 0xcf692694,\n 0xe49b69c1, 0x9ef14ad2, 0xefbe4786, 0x384f25e3,\n 0x0fc19dc6, 0x8b8cd5b5, 0x240ca1cc, 0x77ac9c65,\n 0x2de92c6f, 0x592b0275, 0x4a7484aa, 0x6ea6e483,\n 0x5cb0a9dc, 0xbd41fbd4, 0x76f988da, 0x831153b5,\n 0x983e5152, 0xee66dfab, 0xa831c66d, 0x2db43210,\n 0xb00327c8, 0x98fb213f, 0xbf597fc7, 0xbeef0ee4,\n 0xc6e00bf3, 0x3da88fc2, 0xd5a79147, 0x930aa725,\n 0x06ca6351, 0xe003826f, 0x14292967, 0x0a0e6e70,\n 0x27b70a85, 0x46d22ffc, 0x2e1b2138, 0x5c26c926,\n 0x4d2c6dfc, 0x5ac42aed, 0x53380d13, 0x9d95b3df,\n 0x650a7354, 0x8baf63de, 0x766a0abb, 0x3c77b2a8,\n 0x81c2c92e, 0x47edaee6, 0x92722c85, 0x1482353b,\n 0xa2bfe8a1, 0x4cf10364, 0xa81a664b, 0xbc423001,\n 0xc24b8b70, 0xd0f89791, 0xc76c51a3, 0x0654be30,\n 0xd192e819, 0xd6ef5218, 0xd6990624, 0x5565a910,\n 0xf40e3585, 0x5771202a, 0x106aa070, 0x32bbd1b8,\n 0x19a4c116, 0xb8d2d0c8, 0x1e376c08, 0x5141ab53,\n 0x2748774c, 0xdf8eeb99, 0x34b0bcb5, 0xe19b48a8,\n 0x391c0cb3, 0xc5c95a63, 0x4ed8aa4a, 0xe3418acb,\n 0x5b9cca4f, 0x7763e373, 0x682e6ff3, 0xd6b2b8a3,\n 0x748f82ee, 0x5defb2fc, 0x78a5636f, 0x43172f60,\n 0x84c87814, 0xa1f0ab72, 0x8cc70208, 0x1a6439ec,\n 0x90befffa, 0x23631e28, 0xa4506ceb, 0xde82bde9,\n 0xbef9a3f7, 0xb2c67915, 0xc67178f2, 0xe372532b,\n 0xca273ece, 0xea26619c, 0xd186b8c7, 0x21c0c207,\n 0xeada7dd6, 0xcde0eb1e, 0xf57d4f7f, 0xee6ed178,\n 0x06f067aa, 0x72176fba, 0x0a637dc5, 0xa2c898a6,\n 0x113f9804, 0xbef90dae, 0x1b710b35, 0x131c471b,\n 0x28db77f5, 0x23047d84, 0x32caab7b, 0x40c72493,\n 0x3c9ebe0a, 0x15c9bebc, 0x431d67c4, 0x9c100d4c,\n 0x4cc5d4be, 0xcb3e42b6, 0x597f299c, 0xfc657e2a,\n 0x5fcb6fab, 0x3ad6faec, 0x6c44198c, 0x4a475817\n];\n\nfunction crypto_hashblocks_hl(hh, hl, m, n) {\n var wh = new Int32Array(16), wl = new Int32Array(16),\n bh0, bh1, bh2, bh3, bh4, bh5, bh6, bh7,\n bl0, bl1, bl2, bl3, bl4, bl5, bl6, bl7,\n th, tl, i, j, h, l, a, b, c, d;\n\n var ah0 = hh[0],\n ah1 = hh[1],\n ah2 = hh[2],\n ah3 = hh[3],\n ah4 = hh[4],\n ah5 = hh[5],\n ah6 = hh[6],\n ah7 = hh[7],\n\n al0 = hl[0],\n al1 = hl[1],\n al2 = hl[2],\n al3 = hl[3],\n al4 = hl[4],\n al5 = hl[5],\n al6 = hl[6],\n al7 = hl[7];\n\n var pos = 0;\n while (n >= 128) {\n for (i = 0; i < 16; i++) {\n j = 8 * i + pos;\n wh[i] = (m[j+0] << 24) | (m[j+1] << 16) | (m[j+2] << 8) | m[j+3];\n wl[i] = (m[j+4] << 24) | (m[j+5] << 16) | (m[j+6] << 8) | m[j+7];\n }\n for (i = 0; i < 80; i++) {\n bh0 = ah0;\n bh1 = ah1;\n bh2 = ah2;\n bh3 = ah3;\n bh4 = ah4;\n bh5 = ah5;\n bh6 = ah6;\n bh7 = ah7;\n\n bl0 = al0;\n bl1 = al1;\n bl2 = al2;\n bl3 = al3;\n bl4 = al4;\n bl5 = al5;\n bl6 = al6;\n bl7 = al7;\n\n // add\n h = ah7;\n l = al7;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n // Sigma1\n h = ((ah4 >>> 14) | (al4 << (32-14))) ^ ((ah4 >>> 18) | (al4 << (32-18))) ^ ((al4 >>> (41-32)) | (ah4 << (32-(41-32))));\n l = ((al4 >>> 14) | (ah4 << (32-14))) ^ ((al4 >>> 18) | (ah4 << (32-18))) ^ ((ah4 >>> (41-32)) | (al4 << (32-(41-32))));\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // Ch\n h = (ah4 & ah5) ^ (~ah4 & ah6);\n l = (al4 & al5) ^ (~al4 & al6);\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // K\n h = K[i*2];\n l = K[i*2+1];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // w\n h = wh[i%16];\n l = wl[i%16];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n th = c & 0xffff | d << 16;\n tl = a & 0xffff | b << 16;\n\n // add\n h = th;\n l = tl;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n // Sigma0\n h = ((ah0 >>> 28) | (al0 << (32-28))) ^ ((al0 >>> (34-32)) | (ah0 << (32-(34-32)))) ^ ((al0 >>> (39-32)) | (ah0 << (32-(39-32))));\n l = ((al0 >>> 28) | (ah0 << (32-28))) ^ ((ah0 >>> (34-32)) | (al0 << (32-(34-32)))) ^ ((ah0 >>> (39-32)) | (al0 << (32-(39-32))));\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // Maj\n h = (ah0 & ah1) ^ (ah0 & ah2) ^ (ah1 & ah2);\n l = (al0 & al1) ^ (al0 & al2) ^ (al1 & al2);\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n bh7 = (c & 0xffff) | (d << 16);\n bl7 = (a & 0xffff) | (b << 16);\n\n // add\n h = bh3;\n l = bl3;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = th;\n l = tl;\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n bh3 = (c & 0xffff) | (d << 16);\n bl3 = (a & 0xffff) | (b << 16);\n\n ah1 = bh0;\n ah2 = bh1;\n ah3 = bh2;\n ah4 = bh3;\n ah5 = bh4;\n ah6 = bh5;\n ah7 = bh6;\n ah0 = bh7;\n\n al1 = bl0;\n al2 = bl1;\n al3 = bl2;\n al4 = bl3;\n al5 = bl4;\n al6 = bl5;\n al7 = bl6;\n al0 = bl7;\n\n if (i%16 === 15) {\n for (j = 0; j < 16; j++) {\n // add\n h = wh[j];\n l = wl[j];\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = wh[(j+9)%16];\n l = wl[(j+9)%16];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // sigma0\n th = wh[(j+1)%16];\n tl = wl[(j+1)%16];\n h = ((th >>> 1) | (tl << (32-1))) ^ ((th >>> 8) | (tl << (32-8))) ^ (th >>> 7);\n l = ((tl >>> 1) | (th << (32-1))) ^ ((tl >>> 8) | (th << (32-8))) ^ ((tl >>> 7) | (th << (32-7)));\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // sigma1\n th = wh[(j+14)%16];\n tl = wl[(j+14)%16];\n h = ((th >>> 19) | (tl << (32-19))) ^ ((tl >>> (61-32)) | (th << (32-(61-32)))) ^ (th >>> 6);\n l = ((tl >>> 19) | (th << (32-19))) ^ ((th >>> (61-32)) | (tl << (32-(61-32)))) ^ ((tl >>> 6) | (th << (32-6)));\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n wh[j] = (c & 0xffff) | (d << 16);\n wl[j] = (a & 0xffff) | (b << 16);\n }\n }\n }\n\n // add\n h = ah0;\n l = al0;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[0];\n l = hl[0];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[0] = ah0 = (c & 0xffff) | (d << 16);\n hl[0] = al0 = (a & 0xffff) | (b << 16);\n\n h = ah1;\n l = al1;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[1];\n l = hl[1];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[1] = ah1 = (c & 0xffff) | (d << 16);\n hl[1] = al1 = (a & 0xffff) | (b << 16);\n\n h = ah2;\n l = al2;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[2];\n l = hl[2];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[2] = ah2 = (c & 0xffff) | (d << 16);\n hl[2] = al2 = (a & 0xffff) | (b << 16);\n\n h = ah3;\n l = al3;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[3];\n l = hl[3];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[3] = ah3 = (c & 0xffff) | (d << 16);\n hl[3] = al3 = (a & 0xffff) | (b << 16);\n\n h = ah4;\n l = al4;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[4];\n l = hl[4];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[4] = ah4 = (c & 0xffff) | (d << 16);\n hl[4] = al4 = (a & 0xffff) | (b << 16);\n\n h = ah5;\n l = al5;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[5];\n l = hl[5];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[5] = ah5 = (c & 0xffff) | (d << 16);\n hl[5] = al5 = (a & 0xffff) | (b << 16);\n\n h = ah6;\n l = al6;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[6];\n l = hl[6];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[6] = ah6 = (c & 0xffff) | (d << 16);\n hl[6] = al6 = (a & 0xffff) | (b << 16);\n\n h = ah7;\n l = al7;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[7];\n l = hl[7];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[7] = ah7 = (c & 0xffff) | (d << 16);\n hl[7] = al7 = (a & 0xffff) | (b << 16);\n\n pos += 128;\n n -= 128;\n }\n\n return n;\n}\n\nfunction crypto_hash(out, m, n) {\n var hh = new Int32Array(8),\n hl = new Int32Array(8),\n x = new Uint8Array(256),\n i, b = n;\n\n hh[0] = 0x6a09e667;\n hh[1] = 0xbb67ae85;\n hh[2] = 0x3c6ef372;\n hh[3] = 0xa54ff53a;\n hh[4] = 0x510e527f;\n hh[5] = 0x9b05688c;\n hh[6] = 0x1f83d9ab;\n hh[7] = 0x5be0cd19;\n\n hl[0] = 0xf3bcc908;\n hl[1] = 0x84caa73b;\n hl[2] = 0xfe94f82b;\n hl[3] = 0x5f1d36f1;\n hl[4] = 0xade682d1;\n hl[5] = 0x2b3e6c1f;\n hl[6] = 0xfb41bd6b;\n hl[7] = 0x137e2179;\n\n crypto_hashblocks_hl(hh, hl, m, n);\n n %= 128;\n\n for (i = 0; i < n; i++) x[i] = m[b-n+i];\n x[n] = 128;\n\n n = 256-128*(n<112?1:0);\n x[n-9] = 0;\n ts64(x, n-8, (b / 0x20000000) | 0, b << 3);\n crypto_hashblocks_hl(hh, hl, x, n);\n\n for (i = 0; i < 8; i++) ts64(out, 8*i, hh[i], hl[i]);\n\n return 0;\n}\n\nfunction add(p, q) {\n var a = gf(), b = gf(), c = gf(),\n d = gf(), e = gf(), f = gf(),\n g = gf(), h = gf(), t = gf();\n\n Z(a, p[1], p[0]);\n Z(t, q[1], q[0]);\n M(a, a, t);\n A(b, p[0], p[1]);\n A(t, q[0], q[1]);\n M(b, b, t);\n M(c, p[3], q[3]);\n M(c, c, D2);\n M(d, p[2], q[2]);\n A(d, d, d);\n Z(e, b, a);\n Z(f, d, c);\n A(g, d, c);\n A(h, b, a);\n\n M(p[0], e, f);\n M(p[1], h, g);\n M(p[2], g, f);\n M(p[3], e, h);\n}\n\nfunction cswap(p, q, b) {\n var i;\n for (i = 0; i < 4; i++) {\n sel25519(p[i], q[i], b);\n }\n}\n\nfunction pack(r, p) {\n var tx = gf(), ty = gf(), zi = gf();\n inv25519(zi, p[2]);\n M(tx, p[0], zi);\n M(ty, p[1], zi);\n pack25519(r, ty);\n r[31] ^= par25519(tx) << 7;\n}\n\nfunction scalarmult(p, q, s) {\n var b, i;\n set25519(p[0], gf0);\n set25519(p[1], gf1);\n set25519(p[2], gf1);\n set25519(p[3], gf0);\n for (i = 255; i >= 0; --i) {\n b = (s[(i/8)|0] >> (i&7)) & 1;\n cswap(p, q, b);\n add(q, p);\n add(p, p);\n cswap(p, q, b);\n }\n}\n\nfunction scalarbase(p, s) {\n var q = [gf(), gf(), gf(), gf()];\n set25519(q[0], X);\n set25519(q[1], Y);\n set25519(q[2], gf1);\n M(q[3], X, Y);\n scalarmult(p, q, s);\n}\n\nfunction crypto_sign_keypair(pk, sk, seeded) {\n var d = new Uint8Array(64);\n var p = [gf(), gf(), gf(), gf()];\n var i;\n\n if (!seeded) randombytes(sk, 32);\n crypto_hash(d, sk, 32);\n d[0] &= 248;\n d[31] &= 127;\n d[31] |= 64;\n\n scalarbase(p, d);\n pack(pk, p);\n\n for (i = 0; i < 32; i++) sk[i+32] = pk[i];\n return 0;\n}\n\nvar L = new Float64Array([0xed, 0xd3, 0xf5, 0x5c, 0x1a, 0x63, 0x12, 0x58, 0xd6, 0x9c, 0xf7, 0xa2, 0xde, 0xf9, 0xde, 0x14, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x10]);\n\nfunction modL(r, x) {\n var carry, i, j, k;\n for (i = 63; i >= 32; --i) {\n carry = 0;\n for (j = i - 32, k = i - 12; j < k; ++j) {\n x[j] += carry - 16 * x[i] * L[j - (i - 32)];\n carry = Math.floor((x[j] + 128) / 256);\n x[j] -= carry * 256;\n }\n x[j] += carry;\n x[i] = 0;\n }\n carry = 0;\n for (j = 0; j < 32; j++) {\n x[j] += carry - (x[31] >> 4) * L[j];\n carry = x[j] >> 8;\n x[j] &= 255;\n }\n for (j = 0; j < 32; j++) x[j] -= carry * L[j];\n for (i = 0; i < 32; i++) {\n x[i+1] += x[i] >> 8;\n r[i] = x[i] & 255;\n }\n}\n\nfunction reduce(r) {\n var x = new Float64Array(64), i;\n for (i = 0; i < 64; i++) x[i] = r[i];\n for (i = 0; i < 64; i++) r[i] = 0;\n modL(r, x);\n}\n\n// Note: difference from C - smlen returned, not passed as argument.\nfunction crypto_sign(sm, m, n, sk) {\n var d = new Uint8Array(64), h = new Uint8Array(64), r = new Uint8Array(64);\n var i, j, x = new Float64Array(64);\n var p = [gf(), gf(), gf(), gf()];\n\n crypto_hash(d, sk, 32);\n d[0] &= 248;\n d[31] &= 127;\n d[31] |= 64;\n\n var smlen = n + 64;\n for (i = 0; i < n; i++) sm[64 + i] = m[i];\n for (i = 0; i < 32; i++) sm[32 + i] = d[32 + i];\n\n crypto_hash(r, sm.subarray(32), n+32);\n reduce(r);\n scalarbase(p, r);\n pack(sm, p);\n\n for (i = 32; i < 64; i++) sm[i] = sk[i];\n crypto_hash(h, sm, n + 64);\n reduce(h);\n\n for (i = 0; i < 64; i++) x[i] = 0;\n for (i = 0; i < 32; i++) x[i] = r[i];\n for (i = 0; i < 32; i++) {\n for (j = 0; j < 32; j++) {\n x[i+j] += h[i] * d[j];\n }\n }\n\n modL(sm.subarray(32), x);\n return smlen;\n}\n\nfunction unpackneg(r, p) {\n var t = gf(), chk = gf(), num = gf(),\n den = gf(), den2 = gf(), den4 = gf(),\n den6 = gf();\n\n set25519(r[2], gf1);\n unpack25519(r[1], p);\n S(num, r[1]);\n M(den, num, D);\n Z(num, num, r[2]);\n A(den, r[2], den);\n\n S(den2, den);\n S(den4, den2);\n M(den6, den4, den2);\n M(t, den6, num);\n M(t, t, den);\n\n pow2523(t, t);\n M(t, t, num);\n M(t, t, den);\n M(t, t, den);\n M(r[0], t, den);\n\n S(chk, r[0]);\n M(chk, chk, den);\n if (neq25519(chk, num)) M(r[0], r[0], I);\n\n S(chk, r[0]);\n M(chk, chk, den);\n if (neq25519(chk, num)) return -1;\n\n if (par25519(r[0]) === (p[31]>>7)) Z(r[0], gf0, r[0]);\n\n M(r[3], r[0], r[1]);\n return 0;\n}\n\nfunction crypto_sign_open(m, sm, n, pk) {\n var i;\n var t = new Uint8Array(32), h = new Uint8Array(64);\n var p = [gf(), gf(), gf(), gf()],\n q = [gf(), gf(), gf(), gf()];\n\n if (n < 64) return -1;\n\n if (unpackneg(q, pk)) return -1;\n\n for (i = 0; i < n; i++) m[i] = sm[i];\n for (i = 0; i < 32; i++) m[i+32] = pk[i];\n crypto_hash(h, m, n);\n reduce(h);\n scalarmult(p, q, h);\n\n scalarbase(q, sm.subarray(32));\n add(p, q);\n pack(t, p);\n\n n -= 64;\n if (crypto_verify_32(sm, 0, t, 0)) {\n for (i = 0; i < n; i++) m[i] = 0;\n return -1;\n }\n\n for (i = 0; i < n; i++) m[i] = sm[i + 64];\n return n;\n}\n\nvar crypto_secretbox_KEYBYTES = 32,\n crypto_secretbox_NONCEBYTES = 24,\n crypto_secretbox_ZEROBYTES = 32,\n crypto_secretbox_BOXZEROBYTES = 16,\n crypto_scalarmult_BYTES = 32,\n crypto_scalarmult_SCALARBYTES = 32,\n crypto_box_PUBLICKEYBYTES = 32,\n crypto_box_SECRETKEYBYTES = 32,\n crypto_box_BEFORENMBYTES = 32,\n crypto_box_NONCEBYTES = crypto_secretbox_NONCEBYTES,\n crypto_box_ZEROBYTES = crypto_secretbox_ZEROBYTES,\n crypto_box_BOXZEROBYTES = crypto_secretbox_BOXZEROBYTES,\n crypto_sign_BYTES = 64,\n crypto_sign_PUBLICKEYBYTES = 32,\n crypto_sign_SECRETKEYBYTES = 64,\n crypto_sign_SEEDBYTES = 32,\n crypto_hash_BYTES = 64;\n\nnacl.lowlevel = {\n crypto_core_hsalsa20: crypto_core_hsalsa20,\n crypto_stream_xor: crypto_stream_xor,\n crypto_stream: crypto_stream,\n crypto_stream_salsa20_xor: crypto_stream_salsa20_xor,\n crypto_stream_salsa20: crypto_stream_salsa20,\n crypto_onetimeauth: crypto_onetimeauth,\n crypto_onetimeauth_verify: crypto_onetimeauth_verify,\n crypto_verify_16: crypto_verify_16,\n crypto_verify_32: crypto_verify_32,\n crypto_secretbox: crypto_secretbox,\n crypto_secretbox_open: crypto_secretbox_open,\n crypto_scalarmult: crypto_scalarmult,\n crypto_scalarmult_base: crypto_scalarmult_base,\n crypto_box_beforenm: crypto_box_beforenm,\n crypto_box_afternm: crypto_box_afternm,\n crypto_box: crypto_box,\n crypto_box_open: crypto_box_open,\n crypto_box_keypair: crypto_box_keypair,\n crypto_hash: crypto_hash,\n crypto_sign: crypto_sign,\n crypto_sign_keypair: crypto_sign_keypair,\n crypto_sign_open: crypto_sign_open,\n\n crypto_secretbox_KEYBYTES: crypto_secretbox_KEYBYTES,\n crypto_secretbox_NONCEBYTES: crypto_secretbox_NONCEBYTES,\n crypto_secretbox_ZEROBYTES: crypto_secretbox_ZEROBYTES,\n crypto_secretbox_BOXZEROBYTES: crypto_secretbox_BOXZEROBYTES,\n crypto_scalarmult_BYTES: crypto_scalarmult_BYTES,\n crypto_scalarmult_SCALARBYTES: crypto_scalarmult_SCALARBYTES,\n crypto_box_PUBLICKEYBYTES: crypto_box_PUBLICKEYBYTES,\n crypto_box_SECRETKEYBYTES: crypto_box_SECRETKEYBYTES,\n crypto_box_BEFORENMBYTES: crypto_box_BEFORENMBYTES,\n crypto_box_NONCEBYTES: crypto_box_NONCEBYTES,\n crypto_box_ZEROBYTES: crypto_box_ZEROBYTES,\n crypto_box_BOXZEROBYTES: crypto_box_BOXZEROBYTES,\n crypto_sign_BYTES: crypto_sign_BYTES,\n crypto_sign_PUBLICKEYBYTES: crypto_sign_PUBLICKEYBYTES,\n crypto_sign_SECRETKEYBYTES: crypto_sign_SECRETKEYBYTES,\n crypto_sign_SEEDBYTES: crypto_sign_SEEDBYTES,\n crypto_hash_BYTES: crypto_hash_BYTES,\n\n gf: gf,\n D: D,\n L: L,\n pack25519: pack25519,\n unpack25519: unpack25519,\n M: M,\n A: A,\n S: S,\n Z: Z,\n pow2523: pow2523,\n add: add,\n set25519: set25519,\n modL: modL,\n scalarmult: scalarmult,\n scalarbase: scalarbase,\n};\n\n/* High-level API */\n\nfunction checkLengths(k, n) {\n if (k.length !== crypto_secretbox_KEYBYTES) throw new Error('bad key size');\n if (n.length !== crypto_secretbox_NONCEBYTES) throw new Error('bad nonce size');\n}\n\nfunction checkBoxLengths(pk, sk) {\n if (pk.length !== crypto_box_PUBLICKEYBYTES) throw new Error('bad public key size');\n if (sk.length !== crypto_box_SECRETKEYBYTES) throw new Error('bad secret key size');\n}\n\nfunction checkArrayTypes() {\n for (var i = 0; i < arguments.length; i++) {\n if (!(arguments[i] instanceof Uint8Array))\n throw new TypeError('unexpected type, use Uint8Array');\n }\n}\n\nfunction cleanup(arr) {\n for (var i = 0; i < arr.length; i++) arr[i] = 0;\n}\n\nnacl.randomBytes = function(n) {\n var b = new Uint8Array(n);\n randombytes(b, n);\n return b;\n};\n\nnacl.secretbox = function(msg, nonce, key) {\n checkArrayTypes(msg, nonce, key);\n checkLengths(key, nonce);\n var m = new Uint8Array(crypto_secretbox_ZEROBYTES + msg.length);\n var c = new Uint8Array(m.length);\n for (var i = 0; i < msg.length; i++) m[i+crypto_secretbox_ZEROBYTES] = msg[i];\n crypto_secretbox(c, m, m.length, nonce, key);\n return c.subarray(crypto_secretbox_BOXZEROBYTES);\n};\n\nnacl.secretbox.open = function(box, nonce, key) {\n checkArrayTypes(box, nonce, key);\n checkLengths(key, nonce);\n var c = new Uint8Array(crypto_secretbox_BOXZEROBYTES + box.length);\n var m = new Uint8Array(c.length);\n for (var i = 0; i < box.length; i++) c[i+crypto_secretbox_BOXZEROBYTES] = box[i];\n if (c.length < 32) return null;\n if (crypto_secretbox_open(m, c, c.length, nonce, key) !== 0) return null;\n return m.subarray(crypto_secretbox_ZEROBYTES);\n};\n\nnacl.secretbox.keyLength = crypto_secretbox_KEYBYTES;\nnacl.secretbox.nonceLength = crypto_secretbox_NONCEBYTES;\nnacl.secretbox.overheadLength = crypto_secretbox_BOXZEROBYTES;\n\nnacl.scalarMult = function(n, p) {\n checkArrayTypes(n, p);\n if (n.length !== crypto_scalarmult_SCALARBYTES) throw new Error('bad n size');\n if (p.length !== crypto_scalarmult_BYTES) throw new Error('bad p size');\n var q = new Uint8Array(crypto_scalarmult_BYTES);\n crypto_scalarmult(q, n, p);\n return q;\n};\n\nnacl.scalarMult.base = function(n) {\n checkArrayTypes(n);\n if (n.length !== crypto_scalarmult_SCALARBYTES) throw new Error('bad n size');\n var q = new Uint8Array(crypto_scalarmult_BYTES);\n crypto_scalarmult_base(q, n);\n return q;\n};\n\nnacl.scalarMult.scalarLength = crypto_scalarmult_SCALARBYTES;\nnacl.scalarMult.groupElementLength = crypto_scalarmult_BYTES;\n\nnacl.box = function(msg, nonce, publicKey, secretKey) {\n var k = nacl.box.before(publicKey, secretKey);\n return nacl.secretbox(msg, nonce, k);\n};\n\nnacl.box.before = function(publicKey, secretKey) {\n checkArrayTypes(publicKey, secretKey);\n checkBoxLengths(publicKey, secretKey);\n var k = new Uint8Array(crypto_box_BEFORENMBYTES);\n crypto_box_beforenm(k, publicKey, secretKey);\n return k;\n};\n\nnacl.box.after = nacl.secretbox;\n\nnacl.box.open = function(msg, nonce, publicKey, secretKey) {\n var k = nacl.box.before(publicKey, secretKey);\n return nacl.secretbox.open(msg, nonce, k);\n};\n\nnacl.box.open.after = nacl.secretbox.open;\n\nnacl.box.keyPair = function() {\n var pk = new Uint8Array(crypto_box_PUBLICKEYBYTES);\n var sk = new Uint8Array(crypto_box_SECRETKEYBYTES);\n crypto_box_keypair(pk, sk);\n return {publicKey: pk, secretKey: sk};\n};\n\nnacl.box.keyPair.fromSecretKey = function(secretKey) {\n checkArrayTypes(secretKey);\n if (secretKey.length !== crypto_box_SECRETKEYBYTES)\n throw new Error('bad secret key size');\n var pk = new Uint8Array(crypto_box_PUBLICKEYBYTES);\n crypto_scalarmult_base(pk, secretKey);\n return {publicKey: pk, secretKey: new Uint8Array(secretKey)};\n};\n\nnacl.box.publicKeyLength = crypto_box_PUBLICKEYBYTES;\nnacl.box.secretKeyLength = crypto_box_SECRETKEYBYTES;\nnacl.box.sharedKeyLength = crypto_box_BEFORENMBYTES;\nnacl.box.nonceLength = crypto_box_NONCEBYTES;\nnacl.box.overheadLength = nacl.secretbox.overheadLength;\n\nnacl.sign = function(msg, secretKey) {\n checkArrayTypes(msg, secretKey);\n if (secretKey.length !== crypto_sign_SECRETKEYBYTES)\n throw new Error('bad secret key size');\n var signedMsg = new Uint8Array(crypto_sign_BYTES+msg.length);\n crypto_sign(signedMsg, msg, msg.length, secretKey);\n return signedMsg;\n};\n\nnacl.sign.open = function(signedMsg, publicKey) {\n checkArrayTypes(signedMsg, publicKey);\n if (publicKey.length !== crypto_sign_PUBLICKEYBYTES)\n throw new Error('bad public key size');\n var tmp = new Uint8Array(signedMsg.length);\n var mlen = crypto_sign_open(tmp, signedMsg, signedMsg.length, publicKey);\n if (mlen < 0) return null;\n var m = new Uint8Array(mlen);\n for (var i = 0; i < m.length; i++) m[i] = tmp[i];\n return m;\n};\n\nnacl.sign.detached = function(msg, secretKey) {\n var signedMsg = nacl.sign(msg, secretKey);\n var sig = new Uint8Array(crypto_sign_BYTES);\n for (var i = 0; i < sig.length; i++) sig[i] = signedMsg[i];\n return sig;\n};\n\nnacl.sign.detached.verify = function(msg, sig, publicKey) {\n checkArrayTypes(msg, sig, publicKey);\n if (sig.length !== crypto_sign_BYTES)\n throw new Error('bad signature size');\n if (publicKey.length !== crypto_sign_PUBLICKEYBYTES)\n throw new Error('bad public key size');\n var sm = new Uint8Array(crypto_sign_BYTES + msg.length);\n var m = new Uint8Array(crypto_sign_BYTES + msg.length);\n var i;\n for (i = 0; i < crypto_sign_BYTES; i++) sm[i] = sig[i];\n for (i = 0; i < msg.length; i++) sm[i+crypto_sign_BYTES] = msg[i];\n return (crypto_sign_open(m, sm, sm.length, publicKey) >= 0);\n};\n\nnacl.sign.keyPair = function() {\n var pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);\n var sk = new Uint8Array(crypto_sign_SECRETKEYBYTES);\n crypto_sign_keypair(pk, sk);\n return {publicKey: pk, secretKey: sk};\n};\n\nnacl.sign.keyPair.fromSecretKey = function(secretKey) {\n checkArrayTypes(secretKey);\n if (secretKey.length !== crypto_sign_SECRETKEYBYTES)\n throw new Error('bad secret key size');\n var pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);\n for (var i = 0; i < pk.length; i++) pk[i] = secretKey[32+i];\n return {publicKey: pk, secretKey: new Uint8Array(secretKey)};\n};\n\nnacl.sign.keyPair.fromSeed = function(seed) {\n checkArrayTypes(seed);\n if (seed.length !== crypto_sign_SEEDBYTES)\n throw new Error('bad seed size');\n var pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);\n var sk = new Uint8Array(crypto_sign_SECRETKEYBYTES);\n for (var i = 0; i < 32; i++) sk[i] = seed[i];\n crypto_sign_keypair(pk, sk, true);\n return {publicKey: pk, secretKey: sk};\n};\n\nnacl.sign.publicKeyLength = crypto_sign_PUBLICKEYBYTES;\nnacl.sign.secretKeyLength = crypto_sign_SECRETKEYBYTES;\nnacl.sign.seedLength = crypto_sign_SEEDBYTES;\nnacl.sign.signatureLength = crypto_sign_BYTES;\n\nnacl.hash = function(msg) {\n checkArrayTypes(msg);\n var h = new Uint8Array(crypto_hash_BYTES);\n crypto_hash(h, msg, msg.length);\n return h;\n};\n\nnacl.hash.hashLength = crypto_hash_BYTES;\n\nnacl.verify = function(x, y) {\n checkArrayTypes(x, y);\n // Zero length arguments are considered not equal.\n if (x.length === 0 || y.length === 0) return false;\n if (x.length !== y.length) return false;\n return (vn(x, 0, y, 0, x.length) === 0) ? true : false;\n};\n\nnacl.setPRNG = function(fn) {\n randombytes = fn;\n};\n\n(function() {\n // Initialize PRNG if environment provides CSPRNG.\n // If not, methods calling randombytes will throw.\n var crypto = typeof self !== 'undefined' ? (self.crypto || self.msCrypto) : null;\n if (crypto && crypto.getRandomValues) {\n // Browsers.\n var QUOTA = 65536;\n nacl.setPRNG(function(x, n) {\n var i, v = new Uint8Array(n);\n for (i = 0; i < n; i += QUOTA) {\n crypto.getRandomValues(v.subarray(i, i + Math.min(n - i, QUOTA)));\n }\n for (i = 0; i < n; i++) x[i] = v[i];\n cleanup(v);\n });\n } else if (typeof require !== 'undefined') {\n // Node.js.\n crypto = require('crypto');\n if (crypto && crypto.randomBytes) {\n nacl.setPRNG(function(x, n) {\n var i, v = crypto.randomBytes(n);\n for (i = 0; i < n; i++) x[i] = v[i];\n cleanup(v);\n });\n }\n }\n})();\n\n})(typeof module !== 'undefined' && module.exports ? module.exports : (self.nacl = self.nacl || {}));\n","module.exports = require('./pusher-with-encryption').default;\n","/* (ignored) */","import ScriptReceiver from './script_receiver';\n\n/** Builds receivers for JSONP and Script requests.\n *\n * Each receiver is an object with following fields:\n * - number - unique (for the factory instance), numerical id of the receiver\n * - id - a string ID that can be used in DOM attributes\n * - name - name of the function triggering the receiver\n * - callback - callback function\n *\n * Receivers are triggered only once, on the first callback call.\n *\n * Receivers can be called by their name or by accessing factory object\n * by the number key.\n *\n * @param {String} prefix the prefix used in ids\n * @param {String} name the name of the object\n */\nexport class ScriptReceiverFactory {\n lastId: number;\n prefix: string;\n name: string;\n\n constructor(prefix: string, name: string) {\n this.lastId = 0;\n this.prefix = prefix;\n this.name = name;\n }\n\n create(callback: Function): ScriptReceiver {\n this.lastId++;\n\n var number = this.lastId;\n var id = this.prefix + number;\n var name = this.name + '[' + number + ']';\n\n var called = false;\n var callbackWrapper = function() {\n if (!called) {\n callback.apply(null, arguments);\n called = true;\n }\n };\n\n this[number] = callbackWrapper;\n return { number: number, id: id, name: name, callback: callbackWrapper };\n }\n\n remove(receiver: ScriptReceiver) {\n delete this[receiver.number];\n }\n}\n\nexport var ScriptReceivers = new ScriptReceiverFactory(\n '_pusher_script_',\n 'Pusher.ScriptReceivers'\n);\n","import {\n ChannelAuthorizationOptions,\n UserAuthenticationOptions\n} from './auth/options';\nimport { AuthTransport } from './config';\n\nexport interface DefaultConfig {\n VERSION: string;\n PROTOCOL: number;\n wsPort: number;\n wssPort: number;\n wsPath: string;\n httpHost: string;\n httpPort: number;\n httpsPort: number;\n httpPath: string;\n stats_host: string;\n authEndpoint: string;\n authTransport: AuthTransport;\n activityTimeout: number;\n pongTimeout: number;\n unavailableTimeout: number;\n userAuthentication: UserAuthenticationOptions;\n channelAuthorization: ChannelAuthorizationOptions;\n\n cdn_http?: string;\n cdn_https?: string;\n dependency_suffix?: string;\n}\n\nvar Defaults: DefaultConfig = {\n VERSION: VERSION,\n PROTOCOL: 7,\n\n wsPort: 80,\n wssPort: 443,\n wsPath: '',\n // DEPRECATED: SockJS fallback parameters\n httpHost: 'sockjs.pusher.com',\n httpPort: 80,\n httpsPort: 443,\n httpPath: '/pusher',\n // DEPRECATED: Stats\n stats_host: 'stats.pusher.com',\n // DEPRECATED: Other settings\n authEndpoint: '/pusher/auth',\n authTransport: 'ajax',\n activityTimeout: 120000,\n pongTimeout: 30000,\n unavailableTimeout: 10000,\n userAuthentication: {\n endpoint: '/pusher/user-auth',\n transport: 'ajax'\n },\n channelAuthorization: {\n endpoint: '/pusher/auth',\n transport: 'ajax'\n },\n\n // CDN configuration\n cdn_http: CDN_HTTP,\n cdn_https: CDN_HTTPS,\n dependency_suffix: DEPENDENCY_SUFFIX\n};\n\nexport default Defaults;\n","import {\n ScriptReceivers,\n ScriptReceiverFactory\n} from './script_receiver_factory';\nimport Runtime from 'runtime';\nimport ScriptRequest from './script_request';\n\n/** Handles loading dependency files.\n *\n * Dependency loaders don't remember whether a resource has been loaded or\n * not. It is caller's responsibility to make sure the resource is not loaded\n * twice. This is because it's impossible to detect resource loading status\n * without knowing its content.\n *\n * Options:\n * - cdn_http - url to HTTP CND\n * - cdn_https - url to HTTPS CDN\n * - version - version of pusher-js\n * - suffix - suffix appended to all names of dependency files\n *\n * @param {Object} options\n */\nexport default class DependencyLoader {\n options: any;\n receivers: ScriptReceiverFactory;\n loading: any;\n\n constructor(options: any) {\n this.options = options;\n this.receivers = options.receivers || ScriptReceivers;\n this.loading = {};\n }\n\n /** Loads the dependency from CDN.\n *\n * @param {String} name\n * @param {Function} callback\n */\n load(name: string, options: any, callback: Function) {\n var self = this;\n\n if (self.loading[name] && self.loading[name].length > 0) {\n self.loading[name].push(callback);\n } else {\n self.loading[name] = [callback];\n\n var request = Runtime.createScriptRequest(self.getPath(name, options));\n var receiver = self.receivers.create(function(error) {\n self.receivers.remove(receiver);\n\n if (self.loading[name]) {\n var callbacks = self.loading[name];\n delete self.loading[name];\n\n var successCallback = function(wasSuccessful) {\n if (!wasSuccessful) {\n request.cleanup();\n }\n };\n for (var i = 0; i < callbacks.length; i++) {\n callbacks[i](error, successCallback);\n }\n }\n });\n request.send(receiver);\n }\n }\n\n /** Returns a root URL for pusher-js CDN.\n *\n * @returns {String}\n */\n getRoot(options: any): string {\n var cdn;\n var protocol = Runtime.getDocument().location.protocol;\n if ((options && options.useTLS) || protocol === 'https:') {\n cdn = this.options.cdn_https;\n } else {\n cdn = this.options.cdn_http;\n }\n // make sure there are no double slashes\n return cdn.replace(/\\/*$/, '') + '/' + this.options.version;\n }\n\n /** Returns a full path to a dependency file.\n *\n * @param {String} name\n * @returns {String}\n */\n getPath(name: string, options: any): string {\n return this.getRoot(options) + '/' + name + this.options.suffix + '.js';\n }\n}\n","import { ScriptReceiverFactory } from './script_receiver_factory';\nimport Defaults from 'core/defaults';\nimport DependencyLoader from './dependency_loader';\n\nexport var DependenciesReceivers = new ScriptReceiverFactory(\n '_pusher_dependencies',\n 'Pusher.DependenciesReceivers'\n);\n\nexport var Dependencies = new DependencyLoader({\n cdn_http: Defaults.cdn_http,\n cdn_https: Defaults.cdn_https,\n version: Defaults.VERSION,\n suffix: Defaults.dependency_suffix,\n receivers: DependenciesReceivers\n});\n","/**\n * A place to store help URLs for error messages etc\n */\n\nconst urlStore = {\n baseUrl: 'https://pusher.com',\n urls: {\n authenticationEndpoint: {\n path: '/docs/channels/server_api/authenticating_users'\n },\n authorizationEndpoint: {\n path: '/docs/channels/server_api/authorizing-users/'\n },\n javascriptQuickStart: {\n path: '/docs/javascript_quick_start'\n },\n triggeringClientEvents: {\n path: '/docs/client_api_guide/client_events#trigger-events'\n },\n encryptedChannelSupport: {\n fullUrl:\n 'https://github.com/pusher/pusher-js/tree/cc491015371a4bde5743d1c87a0fbac0feb53195#encrypted-channel-support'\n }\n }\n};\n\n/** Builds a consistent string with links to pusher documentation\n *\n * @param {string} key - relevant key in the url_store.urls object\n * @return {string} suffix string to append to log message\n */\nconst buildLogSuffix = function(key: string): string {\n const urlPrefix = 'See:';\n const urlObj = urlStore.urls[key];\n if (!urlObj) return '';\n\n let url;\n if (urlObj.fullUrl) {\n url = urlObj.fullUrl;\n } else if (urlObj.path) {\n url = urlStore.baseUrl + urlObj.path;\n }\n\n if (!url) return '';\n return `${urlPrefix} ${url}`;\n};\n\nexport default { buildLogSuffix };\n","export enum AuthRequestType {\n UserAuthentication = 'user-authentication',\n ChannelAuthorization = 'channel-authorization'\n}\n\nexport interface ChannelAuthorizationData {\n auth: string;\n channel_data?: string;\n shared_secret?: string;\n}\n\nexport type ChannelAuthorizationCallback = (\n error: Error | null,\n authData: ChannelAuthorizationData | null\n) => void;\n\nexport interface ChannelAuthorizationRequestParams {\n socketId: string;\n channelName: string;\n}\n\nexport interface ChannelAuthorizationHandler {\n (\n params: ChannelAuthorizationRequestParams,\n callback: ChannelAuthorizationCallback\n ): void;\n}\n\nexport interface UserAuthenticationData {\n auth: string;\n user_data: string;\n}\n\nexport type UserAuthenticationCallback = (\n error: Error | null,\n authData: UserAuthenticationData | null\n) => void;\n\nexport interface UserAuthenticationRequestParams {\n socketId: string;\n}\n\nexport interface UserAuthenticationHandler {\n (\n params: UserAuthenticationRequestParams,\n callback: UserAuthenticationCallback\n ): void;\n}\n\nexport type AuthTransportCallback =\n | ChannelAuthorizationCallback\n | UserAuthenticationCallback;\n\nexport interface InternalAuthOptions {\n transport: 'ajax' | 'jsonp';\n endpoint: string;\n params?: any;\n headers?: any;\n paramsProvider?: () => any;\n headersProvider?: () => any;\n}\n\nexport type CustomAuthOptions = {\n customHandler: AuthHandler;\n};\n\nexport type AuthOptionsT =\n | InternalAuthOptions\n | CustomAuthOptions;\n\nexport declare type UserAuthenticationOptions = AuthOptionsT<\n UserAuthenticationHandler\n>;\nexport declare type ChannelAuthorizationOptions = AuthOptionsT<\n ChannelAuthorizationHandler\n>;\n","/** Error classes used throughout the library. */\n// https://github.com/Microsoft/TypeScript-wiki/blob/master/Breaking-Changes.md#extending-built-ins-like-error-array-and-map-may-no-longer-work\nexport class BadEventName extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\nexport class BadChannelName extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\nexport class RequestTimedOut extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class TransportPriorityTooLow extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class TransportClosed extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class UnsupportedFeature extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class UnsupportedTransport extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class UnsupportedStrategy extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class HTTPAuthError extends Error {\n status: number;\n constructor(status: number, msg?: string) {\n super(msg);\n this.status = status;\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n","import TimelineSender from 'core/timeline/timeline_sender';\nimport * as Collections from 'core/utils/collections';\nimport Util from 'core/util';\nimport Runtime from 'runtime';\nimport { AuthTransport } from 'core/auth/auth_transports';\nimport AbstractRuntime from 'runtimes/interface';\nimport UrlStore from 'core/utils/url_store';\nimport {\n AuthRequestType,\n AuthTransportCallback,\n InternalAuthOptions\n} from 'core/auth/options';\nimport { HTTPAuthError } from 'core/errors';\n\nconst ajax: AuthTransport = function(\n context: AbstractRuntime,\n query: string,\n authOptions: InternalAuthOptions,\n authRequestType: AuthRequestType,\n callback: AuthTransportCallback\n) {\n const xhr = Runtime.createXHR();\n xhr.open('POST', authOptions.endpoint, true);\n\n // add request headers\n xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');\n for (var headerName in authOptions.headers) {\n xhr.setRequestHeader(headerName, authOptions.headers[headerName]);\n }\n if (authOptions.headersProvider != null) {\n let dynamicHeaders = authOptions.headersProvider();\n for (var headerName in dynamicHeaders) {\n xhr.setRequestHeader(headerName, dynamicHeaders[headerName]);\n }\n }\n\n xhr.onreadystatechange = function() {\n if (xhr.readyState === 4) {\n if (xhr.status === 200) {\n let data;\n let parsed = false;\n\n try {\n data = JSON.parse(xhr.responseText);\n parsed = true;\n } catch (e) {\n callback(\n new HTTPAuthError(\n 200,\n `JSON returned from ${authRequestType.toString()} endpoint was invalid, yet status code was 200. Data was: ${\n xhr.responseText\n }`\n ),\n null\n );\n }\n\n if (parsed) {\n // prevents double execution.\n callback(null, data);\n }\n } else {\n let suffix = '';\n switch (authRequestType) {\n case AuthRequestType.UserAuthentication:\n suffix = UrlStore.buildLogSuffix('authenticationEndpoint');\n break;\n case AuthRequestType.ChannelAuthorization:\n suffix = `Clients must be authorized to join private or presence channels. ${UrlStore.buildLogSuffix(\n 'authorizationEndpoint'\n )}`;\n break;\n }\n callback(\n new HTTPAuthError(\n xhr.status,\n `Unable to retrieve auth string from ${authRequestType.toString()} endpoint - ` +\n `received status: ${xhr.status} from ${authOptions.endpoint}. ${suffix}`\n ),\n null\n );\n }\n }\n };\n\n xhr.send(query);\n return xhr;\n};\n\nexport default ajax;\n","export default function encode(s: any): string {\n return btoa(utob(s));\n}\n\nvar fromCharCode = String.fromCharCode;\n\nvar b64chars =\n 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';\nvar b64tab = {};\n\nfor (var i = 0, l = b64chars.length; i < l; i++) {\n b64tab[b64chars.charAt(i)] = i;\n}\n\nvar cb_utob = function(c) {\n var cc = c.charCodeAt(0);\n return cc < 0x80\n ? c\n : cc < 0x800\n ? fromCharCode(0xc0 | (cc >>> 6)) + fromCharCode(0x80 | (cc & 0x3f))\n : fromCharCode(0xe0 | ((cc >>> 12) & 0x0f)) +\n fromCharCode(0x80 | ((cc >>> 6) & 0x3f)) +\n fromCharCode(0x80 | (cc & 0x3f));\n};\n\nvar utob = function(u) {\n return u.replace(/[^\\x00-\\x7F]/g, cb_utob);\n};\n\nvar cb_encode = function(ccc) {\n var padlen = [0, 2, 1][ccc.length % 3];\n var ord =\n (ccc.charCodeAt(0) << 16) |\n ((ccc.length > 1 ? ccc.charCodeAt(1) : 0) << 8) |\n (ccc.length > 2 ? ccc.charCodeAt(2) : 0);\n var chars = [\n b64chars.charAt(ord >>> 18),\n b64chars.charAt((ord >>> 12) & 63),\n padlen >= 2 ? '=' : b64chars.charAt((ord >>> 6) & 63),\n padlen >= 1 ? '=' : b64chars.charAt(ord & 63)\n ];\n return chars.join('');\n};\n\nvar btoa =\n global.btoa ||\n function(b) {\n return b.replace(/[\\s\\S]{1,3}/g, cb_encode);\n };\n","import TimedCallback from './timed_callback';\nimport { Delay, Scheduler, Canceller } from './scheduling';\n\nabstract class Timer {\n protected clear: Canceller;\n protected timer: number | void;\n\n constructor(\n set: Scheduler,\n clear: Canceller,\n delay: Delay,\n callback: TimedCallback\n ) {\n this.clear = clear;\n this.timer = set(() => {\n if (this.timer) {\n this.timer = callback(this.timer);\n }\n }, delay);\n }\n\n /** Returns whether the timer is still running.\n *\n * @return {Boolean}\n */\n isRunning(): boolean {\n return this.timer !== null;\n }\n\n /** Aborts a timer when it's running. */\n ensureAborted() {\n if (this.timer) {\n this.clear(this.timer);\n this.timer = null;\n }\n }\n}\n\nexport default Timer;\n","import Timer from './abstract_timer';\nimport TimedCallback from './timed_callback';\nimport { Delay } from './scheduling';\n\n// We need to bind clear functions this way to avoid exceptions on IE8\nfunction clearTimeout(timer) {\n global.clearTimeout(timer);\n}\nfunction clearInterval(timer) {\n global.clearInterval(timer);\n}\n\n/** Cross-browser compatible one-off timer abstraction.\n *\n * @param {Number} delay\n * @param {Function} callback\n */\nexport class OneOffTimer extends Timer {\n constructor(delay: Delay, callback: TimedCallback) {\n super(setTimeout, clearTimeout, delay, function(timer) {\n callback();\n return null;\n });\n }\n}\n\n/** Cross-browser compatible periodic timer abstraction.\n *\n * @param {Number} delay\n * @param {Function} callback\n */\nexport class PeriodicTimer extends Timer {\n constructor(delay: Delay, callback: TimedCallback) {\n super(setInterval, clearInterval, delay, function(timer) {\n callback();\n return timer;\n });\n }\n}\n","import * as Collections from './utils/collections';\nimport TimedCallback from './utils/timers/timed_callback';\nimport { OneOffTimer, PeriodicTimer } from './utils/timers';\n\nvar Util = {\n now(): number {\n if (Date.now) {\n return Date.now();\n } else {\n return new Date().valueOf();\n }\n },\n\n defer(callback: TimedCallback): OneOffTimer {\n return new OneOffTimer(0, callback);\n },\n\n /** Builds a function that will proxy a method call to its first argument.\n *\n * Allows partial application of arguments, so additional arguments are\n * prepended to the argument list.\n *\n * @param {String} name method name\n * @return {Function} proxy function\n */\n method(name: string, ...args: any[]): Function {\n var boundArguments = Array.prototype.slice.call(arguments, 1);\n return function(object) {\n return object[name].apply(object, boundArguments.concat(arguments));\n };\n }\n};\n\nexport default Util;\n","import base64encode from '../base64';\nimport Util from '../util';\n\n/** Merges multiple objects into the target argument.\n *\n * For properties that are plain Objects, performs a deep-merge. For the\n * rest it just copies the value of the property.\n *\n * To extend prototypes use it as following:\n * Pusher.Util.extend(Target.prototype, Base.prototype)\n *\n * You can also use it to merge objects without altering them:\n * Pusher.Util.extend({}, object1, object2)\n *\n * @param {Object} target\n * @return {Object} the target argument\n */\nexport function extend(target: any, ...sources: any[]): T {\n for (var i = 0; i < sources.length; i++) {\n var extensions = sources[i];\n for (var property in extensions) {\n if (\n extensions[property] &&\n extensions[property].constructor &&\n extensions[property].constructor === Object\n ) {\n target[property] = extend(target[property] || {}, extensions[property]);\n } else {\n target[property] = extensions[property];\n }\n }\n }\n return target;\n}\n\nexport function stringify(): string {\n var m = ['Pusher'];\n for (var i = 0; i < arguments.length; i++) {\n if (typeof arguments[i] === 'string') {\n m.push(arguments[i]);\n } else {\n m.push(safeJSONStringify(arguments[i]));\n }\n }\n return m.join(' : ');\n}\n\nexport function arrayIndexOf(array: any[], item: any): number {\n // MSIE doesn't have array.indexOf\n var nativeIndexOf = Array.prototype.indexOf;\n if (array === null) {\n return -1;\n }\n if (nativeIndexOf && array.indexOf === nativeIndexOf) {\n return array.indexOf(item);\n }\n for (var i = 0, l = array.length; i < l; i++) {\n if (array[i] === item) {\n return i;\n }\n }\n return -1;\n}\n\n/** Applies a function f to all properties of an object.\n *\n * Function f gets 3 arguments passed:\n * - element from the object\n * - key of the element\n * - reference to the object\n *\n * @param {Object} object\n * @param {Function} f\n */\nexport function objectApply(object: any, f: Function) {\n for (var key in object) {\n if (Object.prototype.hasOwnProperty.call(object, key)) {\n f(object[key], key, object);\n }\n }\n}\n\n/** Return a list of objects own proerty keys\n *\n * @param {Object} object\n * @returns {Array}\n */\nexport function keys(object: any): string[] {\n var keys = [];\n objectApply(object, function(_, key) {\n keys.push(key);\n });\n return keys;\n}\n\n/** Return a list of object's own property values\n *\n * @param {Object} object\n * @returns {Array}\n */\nexport function values(object: any): any[] {\n var values = [];\n objectApply(object, function(value) {\n values.push(value);\n });\n return values;\n}\n\n/** Applies a function f to all elements of an array.\n *\n * Function f gets 3 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function apply(array: any[], f: Function, context?: any) {\n for (var i = 0; i < array.length; i++) {\n f.call(context || global, array[i], i, array);\n }\n}\n\n/** Maps all elements of the array and returns the result.\n *\n * Function f gets 4 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n * - reference to the destination array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function map(array: any[], f: Function): any[] {\n var result = [];\n for (var i = 0; i < array.length; i++) {\n result.push(f(array[i], i, array, result));\n }\n return result;\n}\n\n/** Maps all elements of the object and returns the result.\n *\n * Function f gets 4 arguments passed:\n * - element from the object\n * - key of the element\n * - reference to the source object\n * - reference to the destination object\n *\n * @param {Object} object\n * @param {Function} f\n */\nexport function mapObject(object: any, f: Function): any {\n var result = {};\n objectApply(object, function(value, key) {\n result[key] = f(value);\n });\n return result;\n}\n\n/** Filters elements of the array using a test function.\n *\n * Function test gets 4 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n * - reference to the destination array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function filter(array: any[], test: Function): any[] {\n test =\n test ||\n function(value) {\n return !!value;\n };\n\n var result = [];\n for (var i = 0; i < array.length; i++) {\n if (test(array[i], i, array, result)) {\n result.push(array[i]);\n }\n }\n return result;\n}\n\n/** Filters properties of the object using a test function.\n *\n * Function test gets 4 arguments passed:\n * - element from the object\n * - key of the element\n * - reference to the source object\n * - reference to the destination object\n *\n * @param {Object} object\n * @param {Function} f\n */\nexport function filterObject(object: Object, test: Function) {\n var result = {};\n objectApply(object, function(value, key) {\n if ((test && test(value, key, object, result)) || Boolean(value)) {\n result[key] = value;\n }\n });\n return result;\n}\n\n/** Flattens an object into a two-dimensional array.\n *\n * @param {Object} object\n * @return {Array} resulting array of [key, value] pairs\n */\nexport function flatten(object: Object): any[] {\n var result = [];\n objectApply(object, function(value, key) {\n result.push([key, value]);\n });\n return result;\n}\n\n/** Checks whether any element of the array passes the test.\n *\n * Function test gets 3 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function any(array: any[], test: Function): boolean {\n for (var i = 0; i < array.length; i++) {\n if (test(array[i], i, array)) {\n return true;\n }\n }\n return false;\n}\n\n/** Checks whether all elements of the array pass the test.\n *\n * Function test gets 3 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function all(array: any[], test: Function): boolean {\n for (var i = 0; i < array.length; i++) {\n if (!test(array[i], i, array)) {\n return false;\n }\n }\n return true;\n}\n\nexport function encodeParamsObject(data): string {\n return mapObject(data, function(value) {\n if (typeof value === 'object') {\n value = safeJSONStringify(value);\n }\n return encodeURIComponent(base64encode(value.toString()));\n });\n}\n\nexport function buildQueryString(data: any): string {\n var params = filterObject(data, function(value) {\n return value !== undefined;\n });\n\n var query = map(\n flatten(encodeParamsObject(params)),\n Util.method('join', '=')\n ).join('&');\n\n return query;\n}\n\n/**\n * See https://github.com/douglascrockford/JSON-js/blob/master/cycle.js\n *\n * Remove circular references from an object. Required for JSON.stringify in\n * React Native, which tends to blow up a lot.\n *\n * @param {any} object\n * @return {any} Decycled object\n */\nexport function decycleObject(object: any): any {\n var objects = [],\n paths = [];\n\n return (function derez(value, path) {\n var i, name, nu;\n\n switch (typeof value) {\n case 'object':\n if (!value) {\n return null;\n }\n for (i = 0; i < objects.length; i += 1) {\n if (objects[i] === value) {\n return { $ref: paths[i] };\n }\n }\n\n objects.push(value);\n paths.push(path);\n\n if (Object.prototype.toString.apply(value) === '[object Array]') {\n nu = [];\n for (i = 0; i < value.length; i += 1) {\n nu[i] = derez(value[i], path + '[' + i + ']');\n }\n } else {\n nu = {};\n for (name in value) {\n if (Object.prototype.hasOwnProperty.call(value, name)) {\n nu[name] = derez(\n value[name],\n path + '[' + JSON.stringify(name) + ']'\n );\n }\n }\n }\n return nu;\n case 'number':\n case 'string':\n case 'boolean':\n return value;\n }\n })(object, '$');\n}\n\n/**\n * Provides a cross-browser and cross-platform way to safely stringify objects\n * into JSON. This is particularly necessary for ReactNative, where circular JSON\n * structures throw an exception.\n *\n * @param {any} source The object to stringify\n * @return {string} The serialized output.\n */\nexport function safeJSONStringify(source: any): string {\n try {\n return JSON.stringify(source);\n } catch (e) {\n return JSON.stringify(decycleObject(source));\n }\n}\n","import { stringify } from './utils/collections';\nimport Pusher from './pusher';\n\nclass Logger {\n debug(...args: any[]) {\n this.log(this.globalLog, args);\n }\n\n warn(...args: any[]) {\n this.log(this.globalLogWarn, args);\n }\n\n error(...args: any[]) {\n this.log(this.globalLogError, args);\n }\n\n private globalLog = (message: string) => {\n if (global.console && global.console.log) {\n global.console.log(message);\n }\n };\n\n private globalLogWarn(message: string) {\n if (global.console && global.console.warn) {\n global.console.warn(message);\n } else {\n this.globalLog(message);\n }\n }\n\n private globalLogError(message: string) {\n if (global.console && global.console.error) {\n global.console.error(message);\n } else {\n this.globalLogWarn(message);\n }\n }\n\n private log(\n defaultLoggingFunction: (message: string) => void,\n ...args: any[]\n ) {\n var message = stringify.apply(this, arguments);\n if (Pusher.log) {\n Pusher.log(message);\n } else if (Pusher.logToConsole) {\n const log = defaultLoggingFunction.bind(this);\n log(message);\n }\n }\n}\n\nexport default new Logger();\n","import Browser from '../browser';\nimport Logger from 'core/logger';\nimport JSONPRequest from '../dom/jsonp_request';\nimport { ScriptReceivers } from '../dom/script_receiver_factory';\nimport { AuthTransport } from 'core/auth/auth_transports';\nimport {\n AuthRequestType,\n AuthTransportCallback,\n InternalAuthOptions\n} from 'core/auth/options';\n\nvar jsonp: AuthTransport = function(\n context: Browser,\n query: string,\n authOptions: InternalAuthOptions,\n authRequestType: AuthRequestType,\n callback: AuthTransportCallback\n) {\n if (\n authOptions.headers !== undefined ||\n authOptions.headersProvider != null\n ) {\n Logger.warn(\n `To send headers with the ${authRequestType.toString()} request, you must use AJAX, rather than JSONP.`\n );\n }\n\n var callbackName = context.nextAuthCallbackID.toString();\n context.nextAuthCallbackID++;\n\n var document = context.getDocument();\n var script = document.createElement('script');\n // Hacked wrapper.\n context.auth_callbacks[callbackName] = function(data) {\n callback(null, data);\n };\n\n var callback_name = \"Pusher.auth_callbacks['\" + callbackName + \"']\";\n script.src =\n authOptions.endpoint +\n '?callback=' +\n encodeURIComponent(callback_name) +\n '&' +\n query;\n\n var head =\n document.getElementsByTagName('head')[0] || document.documentElement;\n head.insertBefore(script, head.firstChild);\n};\n\nexport default jsonp;\n","import ScriptReceiver from './script_receiver';\n\n/** Sends a generic HTTP GET request using a script tag.\n *\n * By constructing URL in a specific way, it can be used for loading\n * JavaScript resources or JSONP requests. It can notify about errors, but\n * only in certain environments. Please take care of monitoring the state of\n * the request yourself.\n *\n * @param {String} src\n */\nexport default class ScriptRequest {\n src: string;\n script: any;\n errorScript: any;\n\n constructor(src: string) {\n this.src = src;\n }\n\n send(receiver: ScriptReceiver) {\n var self = this;\n var errorString = 'Error loading ' + self.src;\n\n self.script = document.createElement('script');\n self.script.id = receiver.id;\n self.script.src = self.src;\n self.script.type = 'text/javascript';\n self.script.charset = 'UTF-8';\n\n if (self.script.addEventListener) {\n self.script.onerror = function() {\n receiver.callback(errorString);\n };\n self.script.onload = function() {\n receiver.callback(null);\n };\n } else {\n self.script.onreadystatechange = function() {\n if (\n self.script.readyState === 'loaded' ||\n self.script.readyState === 'complete'\n ) {\n receiver.callback(null);\n }\n };\n }\n\n // Opera<11.6 hack for missing onerror callback\n if (\n self.script.async === undefined &&\n (document).attachEvent &&\n /opera/i.test(navigator.userAgent)\n ) {\n self.errorScript = document.createElement('script');\n self.errorScript.id = receiver.id + '_error';\n self.errorScript.text = receiver.name + \"('\" + errorString + \"');\";\n self.script.async = self.errorScript.async = false;\n } else {\n self.script.async = true;\n }\n\n var head = document.getElementsByTagName('head')[0];\n head.insertBefore(self.script, head.firstChild);\n if (self.errorScript) {\n head.insertBefore(self.errorScript, self.script.nextSibling);\n }\n }\n\n /** Cleans up the DOM remains of the script request. */\n cleanup() {\n if (this.script) {\n this.script.onload = this.script.onerror = null;\n this.script.onreadystatechange = null;\n }\n if (this.script && this.script.parentNode) {\n this.script.parentNode.removeChild(this.script);\n }\n if (this.errorScript && this.errorScript.parentNode) {\n this.errorScript.parentNode.removeChild(this.errorScript);\n }\n this.script = null;\n this.errorScript = null;\n }\n}\n","import ScriptReceiver from './script_receiver';\nimport ScriptRequest from './script_request';\nimport * as Collections from 'core/utils/collections';\nimport Util from 'core/util';\nimport Runtime from '../runtime';\n\n/** Sends data via JSONP.\n *\n * Data is a key-value map. Its values are JSON-encoded and then passed\n * through base64. Finally, keys and encoded values are appended to the query\n * string.\n *\n * The class itself does not guarantee raising errors on failures, as it's not\n * possible to support such feature on all browsers. Instead, JSONP endpoint\n * should call back in a way that's easy to distinguish from browser calls,\n * for example by passing a second argument to the receiver.\n *\n * @param {String} url\n * @param {Object} data key-value map of data to be submitted\n */\nexport default class JSONPRequest {\n url: string;\n data: any;\n request: ScriptRequest;\n\n constructor(url: string, data: any) {\n this.url = url;\n this.data = data;\n }\n\n /** Sends the actual JSONP request.\n *\n * @param {ScriptReceiver} receiver\n */\n send(receiver: ScriptReceiver) {\n if (this.request) {\n return;\n }\n\n var query = Collections.buildQueryString(this.data);\n var url = this.url + '/' + receiver.number + '?' + query;\n this.request = Runtime.createScriptRequest(url);\n this.request.send(receiver);\n }\n\n /** Cleans up the DOM remains of the JSONP request. */\n cleanup() {\n if (this.request) {\n this.request.cleanup();\n }\n }\n}\n","import TimelineSender from 'core/timeline/timeline_sender';\nimport TimelineTransport from 'core/timeline/timeline_transport';\nimport Browser from 'runtime';\nimport { AuthTransport } from 'core/auth/auth_transports';\nimport { ScriptReceivers } from '../dom/script_receiver_factory';\n\nvar getAgent = function(sender: TimelineSender, useTLS: boolean) {\n return function(data: any, callback: Function) {\n var scheme = 'http' + (useTLS ? 's' : '') + '://';\n var url =\n scheme + (sender.host || sender.options.host) + sender.options.path;\n var request = Browser.createJSONPRequest(url, data);\n\n var receiver = Browser.ScriptReceivers.create(function(error, result) {\n ScriptReceivers.remove(receiver);\n request.cleanup();\n\n if (result && result.host) {\n sender.host = result.host;\n }\n if (callback) {\n callback(error, result);\n }\n });\n request.send(receiver);\n };\n};\n\nvar jsonp = {\n name: 'jsonp',\n getAgent\n};\n\nexport default jsonp;\n","import Defaults from '../defaults';\nimport { default as URLScheme, URLSchemeParams } from './url_scheme';\n\nfunction getGenericURL(\n baseScheme: string,\n params: URLSchemeParams,\n path: string\n): string {\n var scheme = baseScheme + (params.useTLS ? 's' : '');\n var host = params.useTLS ? params.hostTLS : params.hostNonTLS;\n return scheme + '://' + host + path;\n}\n\nfunction getGenericPath(key: string, queryString?: string): string {\n var path = '/app/' + key;\n var query =\n '?protocol=' +\n Defaults.PROTOCOL +\n '&client=js' +\n '&version=' +\n Defaults.VERSION +\n (queryString ? '&' + queryString : '');\n return path + query;\n}\n\nexport var ws: URLScheme = {\n getInitial: function(key: string, params: URLSchemeParams): string {\n var path = (params.httpPath || '') + getGenericPath(key, 'flash=false');\n return getGenericURL('ws', params, path);\n }\n};\n\nexport var http: URLScheme = {\n getInitial: function(key: string, params: URLSchemeParams): string {\n var path = (params.httpPath || '/pusher') + getGenericPath(key);\n return getGenericURL('http', params, path);\n }\n};\n\nexport var sockjs: URLScheme = {\n getInitial: function(key: string, params: URLSchemeParams): string {\n return getGenericURL('http', params, params.httpPath || '/pusher');\n },\n getPath: function(key: string, params: URLSchemeParams): string {\n return getGenericPath(key);\n }\n};\n","import Callback from './callback';\nimport * as Collections from '../utils/collections';\nimport CallbackTable from './callback_table';\n\nexport default class CallbackRegistry {\n _callbacks: CallbackTable;\n\n constructor() {\n this._callbacks = {};\n }\n\n get(name: string): Callback[] {\n return this._callbacks[prefix(name)];\n }\n\n add(name: string, callback: Function, context: any) {\n var prefixedEventName = prefix(name);\n this._callbacks[prefixedEventName] =\n this._callbacks[prefixedEventName] || [];\n this._callbacks[prefixedEventName].push({\n fn: callback,\n context: context\n });\n }\n\n remove(name?: string, callback?: Function, context?: any) {\n if (!name && !callback && !context) {\n this._callbacks = {};\n return;\n }\n\n var names = name ? [prefix(name)] : Collections.keys(this._callbacks);\n\n if (callback || context) {\n this.removeCallback(names, callback, context);\n } else {\n this.removeAllCallbacks(names);\n }\n }\n\n private removeCallback(names: string[], callback: Function, context: any) {\n Collections.apply(\n names,\n function(name) {\n this._callbacks[name] = Collections.filter(\n this._callbacks[name] || [],\n function(binding) {\n return (\n (callback && callback !== binding.fn) ||\n (context && context !== binding.context)\n );\n }\n );\n if (this._callbacks[name].length === 0) {\n delete this._callbacks[name];\n }\n },\n this\n );\n }\n\n private removeAllCallbacks(names: string[]) {\n Collections.apply(\n names,\n function(name) {\n delete this._callbacks[name];\n },\n this\n );\n }\n}\n\nfunction prefix(name: string): string {\n return '_' + name;\n}\n","import * as Collections from '../utils/collections';\nimport Callback from './callback';\nimport Metadata from '../channels/metadata';\nimport CallbackRegistry from './callback_registry';\n\n/** Manages callback bindings and event emitting.\n *\n * @param Function failThrough called when no listeners are bound to an event\n */\nexport default class Dispatcher {\n callbacks: CallbackRegistry;\n global_callbacks: Function[];\n failThrough: Function;\n\n constructor(failThrough?: Function) {\n this.callbacks = new CallbackRegistry();\n this.global_callbacks = [];\n this.failThrough = failThrough;\n }\n\n bind(eventName: string, callback: Function, context?: any) {\n this.callbacks.add(eventName, callback, context);\n return this;\n }\n\n bind_global(callback: Function) {\n this.global_callbacks.push(callback);\n return this;\n }\n\n unbind(eventName?: string, callback?: Function, context?: any) {\n this.callbacks.remove(eventName, callback, context);\n return this;\n }\n\n unbind_global(callback?: Function) {\n if (!callback) {\n this.global_callbacks = [];\n return this;\n }\n\n this.global_callbacks = Collections.filter(\n this.global_callbacks || [],\n c => c !== callback\n );\n\n return this;\n }\n\n unbind_all() {\n this.unbind();\n this.unbind_global();\n return this;\n }\n\n emit(eventName: string, data?: any, metadata?: Metadata): Dispatcher {\n for (var i = 0; i < this.global_callbacks.length; i++) {\n this.global_callbacks[i](eventName, data);\n }\n\n var callbacks = this.callbacks.get(eventName);\n var args = [];\n\n if (metadata) {\n // if there's a metadata argument, we need to call the callback with both\n // data and metadata regardless of whether data is undefined\n args.push(data, metadata);\n } else if (data) {\n // metadata is undefined, so we only need to call the callback with data\n // if data exists\n args.push(data);\n }\n\n if (callbacks && callbacks.length > 0) {\n for (var i = 0; i < callbacks.length; i++) {\n callbacks[i].fn.apply(callbacks[i].context || global, args);\n }\n } else if (this.failThrough) {\n this.failThrough(eventName, data);\n }\n\n return this;\n }\n}\n","import Util from '../util';\nimport * as Collections from '../utils/collections';\nimport { default as EventsDispatcher } from '../events/dispatcher';\nimport Logger from '../logger';\nimport TransportHooks from './transport_hooks';\nimport Socket from '../socket';\nimport Runtime from 'runtime';\nimport Timeline from '../timeline/timeline';\nimport TransportConnectionOptions from './transport_connection_options';\n\n/** Provides universal API for transport connections.\n *\n * Transport connection is a low-level object that wraps a connection method\n * and exposes a simple evented interface for the connection state and\n * messaging. It does not implement Pusher-specific WebSocket protocol.\n *\n * Additionally, it fetches resources needed for transport to work and exposes\n * an interface for querying transport features.\n *\n * States:\n * - new - initial state after constructing the object\n * - initializing - during initialization phase, usually fetching resources\n * - intialized - ready to establish a connection\n * - connection - when connection is being established\n * - open - when connection ready to be used\n * - closed - after connection was closed be either side\n *\n * Emits:\n * - error - after the connection raised an error\n *\n * Options:\n * - useTLS - whether connection should be over TLS\n * - hostTLS - host to connect to when connection is over TLS\n * - hostNonTLS - host to connect to when connection is over TLS\n *\n * @param {String} key application key\n * @param {Object} options\n */\nexport default class TransportConnection extends EventsDispatcher {\n hooks: TransportHooks;\n name: string;\n priority: number;\n key: string;\n options: TransportConnectionOptions;\n state: string;\n timeline: Timeline;\n activityTimeout: number;\n id: number;\n socket: Socket;\n beforeOpen: Function;\n initialize: Function;\n\n constructor(\n hooks: TransportHooks,\n name: string,\n priority: number,\n key: string,\n options: TransportConnectionOptions\n ) {\n super();\n this.initialize = Runtime.transportConnectionInitializer;\n this.hooks = hooks;\n this.name = name;\n this.priority = priority;\n this.key = key;\n this.options = options;\n\n this.state = 'new';\n this.timeline = options.timeline;\n this.activityTimeout = options.activityTimeout;\n this.id = this.timeline.generateUniqueID();\n }\n\n /** Checks whether the transport handles activity checks by itself.\n *\n * @return {Boolean}\n */\n handlesActivityChecks(): boolean {\n return Boolean(this.hooks.handlesActivityChecks);\n }\n\n /** Checks whether the transport supports the ping/pong API.\n *\n * @return {Boolean}\n */\n supportsPing(): boolean {\n return Boolean(this.hooks.supportsPing);\n }\n\n /** Tries to establish a connection.\n *\n * @returns {Boolean} false if transport is in invalid state\n */\n connect(): boolean {\n if (this.socket || this.state !== 'initialized') {\n return false;\n }\n\n var url = this.hooks.urls.getInitial(this.key, this.options);\n try {\n this.socket = this.hooks.getSocket(url, this.options);\n } catch (e) {\n Util.defer(() => {\n this.onError(e);\n this.changeState('closed');\n });\n return false;\n }\n\n this.bindListeners();\n\n Logger.debug('Connecting', { transport: this.name, url });\n this.changeState('connecting');\n return true;\n }\n\n /** Closes the connection.\n *\n * @return {Boolean} true if there was a connection to close\n */\n close(): boolean {\n if (this.socket) {\n this.socket.close();\n return true;\n } else {\n return false;\n }\n }\n\n /** Sends data over the open connection.\n *\n * @param {String} data\n * @return {Boolean} true only when in the \"open\" state\n */\n send(data: any): boolean {\n if (this.state === 'open') {\n // Workaround for MobileSafari bug (see https://gist.github.com/2052006)\n Util.defer(() => {\n if (this.socket) {\n this.socket.send(data);\n }\n });\n return true;\n } else {\n return false;\n }\n }\n\n /** Sends a ping if the connection is open and transport supports it. */\n ping() {\n if (this.state === 'open' && this.supportsPing()) {\n this.socket.ping();\n }\n }\n\n private onOpen() {\n if (this.hooks.beforeOpen) {\n this.hooks.beforeOpen(\n this.socket,\n this.hooks.urls.getPath(this.key, this.options)\n );\n }\n this.changeState('open');\n this.socket.onopen = undefined;\n }\n\n private onError(error) {\n this.emit('error', { type: 'WebSocketError', error: error });\n this.timeline.error(this.buildTimelineMessage({ error: error.toString() }));\n }\n\n private onClose(closeEvent?: any) {\n if (closeEvent) {\n this.changeState('closed', {\n code: closeEvent.code,\n reason: closeEvent.reason,\n wasClean: closeEvent.wasClean\n });\n } else {\n this.changeState('closed');\n }\n this.unbindListeners();\n this.socket = undefined;\n }\n\n private onMessage(message) {\n this.emit('message', message);\n }\n\n private onActivity() {\n this.emit('activity');\n }\n\n private bindListeners() {\n this.socket.onopen = () => {\n this.onOpen();\n };\n this.socket.onerror = error => {\n this.onError(error);\n };\n this.socket.onclose = closeEvent => {\n this.onClose(closeEvent);\n };\n this.socket.onmessage = message => {\n this.onMessage(message);\n };\n\n if (this.supportsPing()) {\n this.socket.onactivity = () => {\n this.onActivity();\n };\n }\n }\n\n private unbindListeners() {\n if (this.socket) {\n this.socket.onopen = undefined;\n this.socket.onerror = undefined;\n this.socket.onclose = undefined;\n this.socket.onmessage = undefined;\n if (this.supportsPing()) {\n this.socket.onactivity = undefined;\n }\n }\n }\n\n private changeState(state: string, params?: any) {\n this.state = state;\n this.timeline.info(\n this.buildTimelineMessage({\n state: state,\n params: params\n })\n );\n this.emit(state, params);\n }\n\n buildTimelineMessage(message): any {\n return Collections.extend({ cid: this.id }, message);\n }\n}\n","import Factory from '../utils/factory';\nimport TransportHooks from './transport_hooks';\nimport TransportConnection from './transport_connection';\nimport TransportConnectionOptions from './transport_connection_options';\n\n/** Provides interface for transport connection instantiation.\n *\n * Takes transport-specific hooks as the only argument, which allow checking\n * for transport support and creating its connections.\n *\n * Supported hooks: * - file - the name of the file to be fetched during initialization\n * - urls - URL scheme to be used by transport\n * - handlesActivityCheck - true when the transport handles activity checks\n * - supportsPing - true when the transport has a ping/activity API\n * - isSupported - tells whether the transport is supported in the environment\n * - getSocket - creates a WebSocket-compatible transport socket\n *\n * See transports.js for specific implementations.\n *\n * @param {Object} hooks object containing all needed transport hooks\n */\nexport default class Transport {\n hooks: TransportHooks;\n\n constructor(hooks: TransportHooks) {\n this.hooks = hooks;\n }\n\n /** Returns whether the transport is supported in the environment.\n *\n * @param {Object} envronment te environment details (encryption, settings)\n * @returns {Boolean} true when the transport is supported\n */\n isSupported(environment: any): boolean {\n return this.hooks.isSupported(environment);\n }\n\n /** Creates a transport connection.\n *\n * @param {String} name\n * @param {Number} priority\n * @param {String} key the application key\n * @param {Object} options\n * @returns {TransportConnection}\n */\n createConnection(\n name: string,\n priority: number,\n key: string,\n options: any\n ): TransportConnection {\n return new TransportConnection(this.hooks, name, priority, key, options);\n }\n}\n","import * as URLSchemes from 'core/transports/url_schemes';\nimport URLScheme from 'core/transports/url_scheme';\nimport Transport from 'core/transports/transport';\nimport Util from 'core/util';\nimport * as Collections from 'core/utils/collections';\nimport TransportHooks from 'core/transports/transport_hooks';\nimport TransportsTable from 'core/transports/transports_table';\nimport Runtime from 'runtime';\n\n/** WebSocket transport.\n *\n * Uses native WebSocket implementation, including MozWebSocket supported by\n * earlier Firefox versions.\n */\nvar WSTransport = new Transport({\n urls: URLSchemes.ws,\n handlesActivityChecks: false,\n supportsPing: false,\n\n isInitialized: function() {\n return Boolean(Runtime.getWebSocketAPI());\n },\n isSupported: function(): boolean {\n return Boolean(Runtime.getWebSocketAPI());\n },\n getSocket: function(url) {\n return Runtime.createWebSocket(url);\n }\n});\n\nvar httpConfiguration = {\n urls: URLSchemes.http,\n handlesActivityChecks: false,\n supportsPing: true,\n isInitialized: function() {\n return true;\n }\n};\n\nexport var streamingConfiguration = Collections.extend(\n {\n getSocket: function(url) {\n return Runtime.HTTPFactory.createStreamingSocket(url);\n }\n },\n httpConfiguration\n);\nexport var pollingConfiguration = Collections.extend(\n {\n getSocket: function(url) {\n return Runtime.HTTPFactory.createPollingSocket(url);\n }\n },\n httpConfiguration\n);\n\nvar xhrConfiguration = {\n isSupported: function(): boolean {\n return Runtime.isXHRSupported();\n }\n};\n\n/** HTTP streaming transport using CORS-enabled XMLHttpRequest. */\nvar XHRStreamingTransport = new Transport(\n (\n Collections.extend({}, streamingConfiguration, xhrConfiguration)\n )\n);\n\n/** HTTP long-polling transport using CORS-enabled XMLHttpRequest. */\nvar XHRPollingTransport = new Transport(\n Collections.extend({}, pollingConfiguration, xhrConfiguration)\n);\n\nvar Transports: TransportsTable = {\n ws: WSTransport,\n xhr_streaming: XHRStreamingTransport,\n xhr_polling: XHRPollingTransport\n};\n\nexport default Transports;\n","import {\n default as Transports,\n streamingConfiguration,\n pollingConfiguration\n} from 'isomorphic/transports/transports';\nimport Transport from 'core/transports/transport';\nimport TransportHooks from 'core/transports/transport_hooks';\nimport * as URLSchemes from 'core/transports/url_schemes';\nimport Runtime from 'runtime';\nimport { Dependencies } from '../dom/dependencies';\nimport * as Collections from 'core/utils/collections';\n\nvar SockJSTransport = new Transport({\n file: 'sockjs',\n urls: URLSchemes.sockjs,\n handlesActivityChecks: true,\n supportsPing: false,\n\n isSupported: function() {\n return true;\n },\n isInitialized: function() {\n return window.SockJS !== undefined;\n },\n getSocket: function(url, options) {\n return new window.SockJS(url, null, {\n js_path: Dependencies.getPath('sockjs', {\n useTLS: options.useTLS\n }),\n ignore_null_origin: options.ignoreNullOrigin\n });\n },\n beforeOpen: function(socket, path) {\n socket.send(\n JSON.stringify({\n path: path\n })\n );\n }\n});\n\nvar xdrConfiguration = {\n isSupported: function(environment): boolean {\n var yes = Runtime.isXDRSupported(environment.useTLS);\n return yes;\n }\n};\n\n/** HTTP streaming transport using XDomainRequest (IE 8,9). */\nvar XDRStreamingTransport = new Transport(\n (\n Collections.extend({}, streamingConfiguration, xdrConfiguration)\n )\n);\n\n/** HTTP long-polling transport using XDomainRequest (IE 8,9). */\nvar XDRPollingTransport = new Transport(\n Collections.extend({}, pollingConfiguration, xdrConfiguration)\n);\n\nTransports.xdr_streaming = XDRStreamingTransport;\nTransports.xdr_polling = XDRPollingTransport;\nTransports.sockjs = SockJSTransport;\n\nexport default Transports;\n","import Reachability from 'core/reachability';\nimport { default as EventsDispatcher } from 'core/events/dispatcher';\n\n/** Really basic interface providing network availability info.\n *\n * Emits:\n * - online - when browser goes online\n * - offline - when browser goes offline\n */\nexport class NetInfo extends EventsDispatcher implements Reachability {\n constructor() {\n super();\n var self = this;\n // This is okay, as IE doesn't support this stuff anyway.\n if (window.addEventListener !== undefined) {\n window.addEventListener(\n 'online',\n function() {\n self.emit('online');\n },\n false\n );\n window.addEventListener(\n 'offline',\n function() {\n self.emit('offline');\n },\n false\n );\n }\n }\n\n /** Returns whether browser is online or not\n *\n * Offline means definitely offline (no connection to router).\n * Inverse does NOT mean definitely online (only currently supported in Safari\n * and even there only means the device has a connection to the router).\n *\n * @return {Boolean}\n */\n isOnline(): boolean {\n if (window.navigator.onLine === undefined) {\n return true;\n } else {\n return window.navigator.onLine;\n }\n }\n}\n\nexport var Network = new NetInfo();\n","import Util from '../util';\nimport * as Collections from '../utils/collections';\nimport TransportManager from './transport_manager';\nimport TransportConnection from './transport_connection';\nimport Transport from './transport';\nimport PingDelayOptions from './ping_delay_options';\n\n/** Creates transport connections monitored by a transport manager.\n *\n * When a transport is closed, it might mean the environment does not support\n * it. It's possible that messages get stuck in an intermediate buffer or\n * proxies terminate inactive connections. To combat these problems,\n * assistants monitor the connection lifetime, report unclean exits and\n * adjust ping timeouts to keep the connection active. The decision to disable\n * a transport is the manager's responsibility.\n *\n * @param {TransportManager} manager\n * @param {TransportConnection} transport\n * @param {Object} options\n */\nexport default class AssistantToTheTransportManager {\n manager: TransportManager;\n transport: Transport;\n minPingDelay: number;\n maxPingDelay: number;\n pingDelay: number;\n\n constructor(\n manager: TransportManager,\n transport: Transport,\n options: PingDelayOptions\n ) {\n this.manager = manager;\n this.transport = transport;\n this.minPingDelay = options.minPingDelay;\n this.maxPingDelay = options.maxPingDelay;\n this.pingDelay = undefined;\n }\n\n /** Creates a transport connection.\n *\n * This function has the same API as Transport#createConnection.\n *\n * @param {String} name\n * @param {Number} priority\n * @param {String} key the application key\n * @param {Object} options\n * @returns {TransportConnection}\n */\n createConnection(\n name: string,\n priority: number,\n key: string,\n options: Object\n ): TransportConnection {\n options = Collections.extend({}, options, {\n activityTimeout: this.pingDelay\n });\n var connection = this.transport.createConnection(\n name,\n priority,\n key,\n options\n );\n\n var openTimestamp = null;\n\n var onOpen = function() {\n connection.unbind('open', onOpen);\n connection.bind('closed', onClosed);\n openTimestamp = Util.now();\n };\n var onClosed = closeEvent => {\n connection.unbind('closed', onClosed);\n\n if (closeEvent.code === 1002 || closeEvent.code === 1003) {\n // we don't want to use transports not obeying the protocol\n this.manager.reportDeath();\n } else if (!closeEvent.wasClean && openTimestamp) {\n // report deaths only for short-living transport\n var lifespan = Util.now() - openTimestamp;\n if (lifespan < 2 * this.maxPingDelay) {\n this.manager.reportDeath();\n this.pingDelay = Math.max(lifespan / 2, this.minPingDelay);\n }\n }\n };\n\n connection.bind('open', onOpen);\n return connection;\n }\n\n /** Returns whether the transport is supported in the environment.\n *\n * This function has the same API as Transport#isSupported. Might return false\n * when the manager decides to kill the transport.\n *\n * @param {Object} environment the environment details (encryption, settings)\n * @returns {Boolean} true when the transport is supported\n */\n isSupported(environment: string): boolean {\n return this.manager.isAlive() && this.transport.isSupported(environment);\n }\n}\n","import Action from './action';\nimport { PusherEvent } from './message-types';\n/**\n * Provides functions for handling Pusher protocol-specific messages.\n */\n\nconst Protocol = {\n /**\n * Decodes a message in a Pusher format.\n *\n * The MessageEvent we receive from the transport should contain a pusher event\n * (https://pusher.com/docs/pusher_protocol#events) serialized as JSON in the\n * data field\n *\n * The pusher event may contain a data field too, and it may also be\n * serialised as JSON\n *\n * Throws errors when messages are not parse'able.\n *\n * @param {MessageEvent} messageEvent\n * @return {PusherEvent}\n */\n decodeMessage: function(messageEvent: MessageEvent): PusherEvent {\n try {\n var messageData = JSON.parse(messageEvent.data);\n var pusherEventData = messageData.data;\n if (typeof pusherEventData === 'string') {\n try {\n pusherEventData = JSON.parse(messageData.data);\n } catch (e) {}\n }\n var pusherEvent: PusherEvent = {\n event: messageData.event,\n channel: messageData.channel,\n data: pusherEventData\n };\n if (messageData.user_id) {\n pusherEvent.user_id = messageData.user_id;\n }\n return pusherEvent;\n } catch (e) {\n throw { type: 'MessageParseError', error: e, data: messageEvent.data };\n }\n },\n\n /**\n * Encodes a message to be sent.\n *\n * @param {PusherEvent} event\n * @return {String}\n */\n encodeMessage: function(event: PusherEvent): string {\n return JSON.stringify(event);\n },\n\n /**\n * Processes a handshake message and returns appropriate actions.\n *\n * Returns an object with an 'action' and other action-specific properties.\n *\n * There are three outcomes when calling this function. First is a successful\n * connection attempt, when pusher:connection_established is received, which\n * results in a 'connected' action with an 'id' property. When passed a\n * pusher:error event, it returns a result with action appropriate to the\n * close code and an error. Otherwise, it raises an exception.\n *\n * @param {String} message\n * @result Object\n */\n processHandshake: function(messageEvent: MessageEvent): Action {\n var message = Protocol.decodeMessage(messageEvent);\n\n if (message.event === 'pusher:connection_established') {\n if (!message.data.activity_timeout) {\n throw 'No activity timeout specified in handshake';\n }\n return {\n action: 'connected',\n id: message.data.socket_id,\n activityTimeout: message.data.activity_timeout * 1000\n };\n } else if (message.event === 'pusher:error') {\n // From protocol 6 close codes are sent only once, so this only\n // happens when connection does not support close codes\n return {\n action: this.getCloseAction(message.data),\n error: this.getCloseError(message.data)\n };\n } else {\n throw 'Invalid handshake';\n }\n },\n\n /**\n * Dispatches the close event and returns an appropriate action name.\n *\n * See:\n * 1. https://developer.mozilla.org/en-US/docs/WebSockets/WebSockets_reference/CloseEvent\n * 2. http://pusher.com/docs/pusher_protocol\n *\n * @param {CloseEvent} closeEvent\n * @return {String} close action name\n */\n getCloseAction: function(closeEvent): string {\n if (closeEvent.code < 4000) {\n // ignore 1000 CLOSE_NORMAL, 1001 CLOSE_GOING_AWAY,\n // 1005 CLOSE_NO_STATUS, 1006 CLOSE_ABNORMAL\n // ignore 1007...3999\n // handle 1002 CLOSE_PROTOCOL_ERROR, 1003 CLOSE_UNSUPPORTED,\n // 1004 CLOSE_TOO_LARGE\n if (closeEvent.code >= 1002 && closeEvent.code <= 1004) {\n return 'backoff';\n } else {\n return null;\n }\n } else if (closeEvent.code === 4000) {\n return 'tls_only';\n } else if (closeEvent.code < 4100) {\n return 'refused';\n } else if (closeEvent.code < 4200) {\n return 'backoff';\n } else if (closeEvent.code < 4300) {\n return 'retry';\n } else {\n // unknown error\n return 'refused';\n }\n },\n\n /**\n * Returns an error or null basing on the close event.\n *\n * Null is returned when connection was closed cleanly. Otherwise, an object\n * with error details is returned.\n *\n * @param {CloseEvent} closeEvent\n * @return {Object} error object\n */\n getCloseError: function(closeEvent): any {\n if (closeEvent.code !== 1000 && closeEvent.code !== 1001) {\n return {\n type: 'PusherError',\n data: {\n code: closeEvent.code,\n message: closeEvent.reason || closeEvent.message\n }\n };\n } else {\n return null;\n }\n }\n};\n\nexport default Protocol;\n","import * as Collections from '../utils/collections';\nimport { default as EventsDispatcher } from '../events/dispatcher';\nimport Protocol from './protocol/protocol';\nimport { PusherEvent } from './protocol/message-types';\nimport Logger from '../logger';\nimport TransportConnection from '../transports/transport_connection';\nimport Socket from '../socket';\n/**\n * Provides Pusher protocol interface for transports.\n *\n * Emits following events:\n * - message - on received messages\n * - ping - on ping requests\n * - pong - on pong responses\n * - error - when the transport emits an error\n * - closed - after closing the transport\n *\n * It also emits more events when connection closes with a code.\n * See Protocol.getCloseAction to get more details.\n *\n * @param {Number} id\n * @param {AbstractTransport} transport\n */\nexport default class Connection extends EventsDispatcher implements Socket {\n id: string;\n transport: TransportConnection;\n activityTimeout: number;\n\n constructor(id: string, transport: TransportConnection) {\n super();\n this.id = id;\n this.transport = transport;\n this.activityTimeout = transport.activityTimeout;\n this.bindListeners();\n }\n\n /** Returns whether used transport handles activity checks by itself\n *\n * @returns {Boolean} true if activity checks are handled by the transport\n */\n handlesActivityChecks() {\n return this.transport.handlesActivityChecks();\n }\n\n /** Sends raw data.\n *\n * @param {String} data\n */\n send(data: any): boolean {\n return this.transport.send(data);\n }\n\n /** Sends an event.\n *\n * @param {String} name\n * @param {String} data\n * @param {String} [channel]\n * @returns {Boolean} whether message was sent or not\n */\n send_event(name: string, data: any, channel?: string): boolean {\n var event: PusherEvent = { event: name, data: data };\n if (channel) {\n event.channel = channel;\n }\n Logger.debug('Event sent', event);\n return this.send(Protocol.encodeMessage(event));\n }\n\n /** Sends a ping message to the server.\n *\n * Basing on the underlying transport, it might send either transport's\n * protocol-specific ping or pusher:ping event.\n */\n ping() {\n if (this.transport.supportsPing()) {\n this.transport.ping();\n } else {\n this.send_event('pusher:ping', {});\n }\n }\n\n /** Closes the connection. */\n close() {\n this.transport.close();\n }\n\n private bindListeners() {\n var listeners = {\n message: (messageEvent: MessageEvent) => {\n var pusherEvent;\n try {\n pusherEvent = Protocol.decodeMessage(messageEvent);\n } catch (e) {\n this.emit('error', {\n type: 'MessageParseError',\n error: e,\n data: messageEvent.data\n });\n }\n\n if (pusherEvent !== undefined) {\n Logger.debug('Event recd', pusherEvent);\n\n switch (pusherEvent.event) {\n case 'pusher:error':\n this.emit('error', {\n type: 'PusherError',\n data: pusherEvent.data\n });\n break;\n case 'pusher:ping':\n this.emit('ping');\n break;\n case 'pusher:pong':\n this.emit('pong');\n break;\n }\n this.emit('message', pusherEvent);\n }\n },\n activity: () => {\n this.emit('activity');\n },\n error: error => {\n this.emit('error', error);\n },\n closed: closeEvent => {\n unbindListeners();\n\n if (closeEvent && closeEvent.code) {\n this.handleCloseEvent(closeEvent);\n }\n\n this.transport = null;\n this.emit('closed');\n }\n };\n\n var unbindListeners = () => {\n Collections.objectApply(listeners, (listener, event) => {\n this.transport.unbind(event, listener);\n });\n };\n\n Collections.objectApply(listeners, (listener, event) => {\n this.transport.bind(event, listener);\n });\n }\n\n private handleCloseEvent(closeEvent: any) {\n var action = Protocol.getCloseAction(closeEvent);\n var error = Protocol.getCloseError(closeEvent);\n if (error) {\n this.emit('error', error);\n }\n if (action) {\n this.emit(action, { action: action, error: error });\n }\n }\n}\n","import Util from '../../util';\nimport * as Collections from '../../utils/collections';\nimport Protocol from '../protocol/protocol';\nimport Connection from '../connection';\nimport TransportConnection from '../../transports/transport_connection';\nimport HandshakePayload from './handshake_payload';\n\n/**\n * Handles Pusher protocol handshakes for transports.\n *\n * Calls back with a result object after handshake is completed. Results\n * always have two fields:\n * - action - string describing action to be taken after the handshake\n * - transport - the transport object passed to the constructor\n *\n * Different actions can set different additional properties on the result.\n * In the case of 'connected' action, there will be a 'connection' property\n * containing a Connection object for the transport. Other actions should\n * carry an 'error' property.\n *\n * @param {AbstractTransport} transport\n * @param {Function} callback\n */\nexport default class Handshake {\n transport: TransportConnection;\n callback: (HandshakePayload) => void;\n onMessage: Function;\n onClosed: Function;\n\n constructor(\n transport: TransportConnection,\n callback: (HandshakePayload) => void\n ) {\n this.transport = transport;\n this.callback = callback;\n this.bindListeners();\n }\n\n close() {\n this.unbindListeners();\n this.transport.close();\n }\n\n private bindListeners() {\n this.onMessage = m => {\n this.unbindListeners();\n\n var result;\n try {\n result = Protocol.processHandshake(m);\n } catch (e) {\n this.finish('error', { error: e });\n this.transport.close();\n return;\n }\n\n if (result.action === 'connected') {\n this.finish('connected', {\n connection: new Connection(result.id, this.transport),\n activityTimeout: result.activityTimeout\n });\n } else {\n this.finish(result.action, { error: result.error });\n this.transport.close();\n }\n };\n\n this.onClosed = closeEvent => {\n this.unbindListeners();\n\n var action = Protocol.getCloseAction(closeEvent) || 'backoff';\n var error = Protocol.getCloseError(closeEvent);\n this.finish(action, { error: error });\n };\n\n this.transport.bind('message', this.onMessage);\n this.transport.bind('closed', this.onClosed);\n }\n\n private unbindListeners() {\n this.transport.unbind('message', this.onMessage);\n this.transport.unbind('closed', this.onClosed);\n }\n\n private finish(action: string, params: any) {\n this.callback(\n Collections.extend({ transport: this.transport, action: action }, params)\n );\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport base64encode from '../base64';\nimport Timeline from './timeline';\nimport Runtime from 'runtime';\n\nexport interface TimelineSenderOptions {\n host?: string;\n port?: number;\n path?: string;\n}\n\nexport default class TimelineSender {\n timeline: Timeline;\n options: TimelineSenderOptions;\n host: string;\n\n constructor(timeline: Timeline, options: TimelineSenderOptions) {\n this.timeline = timeline;\n this.options = options || {};\n }\n\n send(useTLS: boolean, callback?: Function) {\n if (this.timeline.isEmpty()) {\n return;\n }\n\n this.timeline.send(\n Runtime.TimelineTransport.getAgent(this, useTLS),\n callback\n );\n }\n}\n","import { default as EventsDispatcher } from '../events/dispatcher';\nimport * as Errors from '../errors';\nimport Logger from '../logger';\nimport Pusher from '../pusher';\nimport { PusherEvent } from '../connection/protocol/message-types';\nimport Metadata from './metadata';\nimport UrlStore from '../utils/url_store';\nimport {\n ChannelAuthorizationData,\n ChannelAuthorizationCallback\n} from '../auth/options';\nimport { HTTPAuthError } from '../errors';\n\n/** Provides base public channel interface with an event emitter.\n *\n * Emits:\n * - pusher:subscription_succeeded - after subscribing successfully\n * - other non-internal events\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\nexport default class Channel extends EventsDispatcher {\n name: string;\n pusher: Pusher;\n subscribed: boolean;\n subscriptionPending: boolean;\n subscriptionCancelled: boolean;\n subscriptionCount: null;\n\n constructor(name: string, pusher: Pusher) {\n super(function(event, data) {\n Logger.debug('No callbacks on ' + name + ' for ' + event);\n });\n\n this.name = name;\n this.pusher = pusher;\n this.subscribed = false;\n this.subscriptionPending = false;\n this.subscriptionCancelled = false;\n }\n\n /** Skips authorization, since public channels don't require it.\n *\n * @param {Function} callback\n */\n authorize(socketId: string, callback: ChannelAuthorizationCallback) {\n return callback(null, { auth: '' });\n }\n\n /** Triggers an event */\n trigger(event: string, data: any) {\n if (event.indexOf('client-') !== 0) {\n throw new Errors.BadEventName(\n \"Event '\" + event + \"' does not start with 'client-'\"\n );\n }\n if (!this.subscribed) {\n var suffix = UrlStore.buildLogSuffix('triggeringClientEvents');\n Logger.warn(\n `Client event triggered before channel 'subscription_succeeded' event . ${suffix}`\n );\n }\n return this.pusher.send_event(event, data, this.name);\n }\n\n /** Signals disconnection to the channel. For internal use only. */\n disconnect() {\n this.subscribed = false;\n this.subscriptionPending = false;\n }\n\n /** Handles a PusherEvent. For internal use only.\n *\n * @param {PusherEvent} event\n */\n handleEvent(event: PusherEvent) {\n var eventName = event.event;\n var data = event.data;\n if (eventName === 'pusher_internal:subscription_succeeded') {\n this.handleSubscriptionSucceededEvent(event);\n } else if (eventName === 'pusher_internal:subscription_count') {\n this.handleSubscriptionCountEvent(event);\n } else if (eventName.indexOf('pusher_internal:') !== 0) {\n var metadata: Metadata = {};\n this.emit(eventName, data, metadata);\n }\n }\n\n handleSubscriptionSucceededEvent(event: PusherEvent) {\n this.subscriptionPending = false;\n this.subscribed = true;\n if (this.subscriptionCancelled) {\n this.pusher.unsubscribe(this.name);\n } else {\n this.emit('pusher:subscription_succeeded', event.data);\n }\n }\n\n handleSubscriptionCountEvent(event: PusherEvent) {\n if (event.data.subscription_count) {\n this.subscriptionCount = event.data.subscription_count;\n }\n\n this.emit('pusher:subscription_count', event.data);\n }\n\n /** Sends a subscription request. For internal use only. */\n subscribe() {\n if (this.subscribed) {\n return;\n }\n this.subscriptionPending = true;\n this.subscriptionCancelled = false;\n this.authorize(\n this.pusher.connection.socket_id,\n (error: Error | null, data: ChannelAuthorizationData) => {\n if (error) {\n this.subscriptionPending = false;\n // Why not bind to 'pusher:subscription_error' a level up, and log there?\n // Binding to this event would cause the warning about no callbacks being\n // bound (see constructor) to be suppressed, that's not what we want.\n Logger.error(error.toString());\n this.emit(\n 'pusher:subscription_error',\n Object.assign(\n {},\n {\n type: 'AuthError',\n error: error.message\n },\n error instanceof HTTPAuthError ? { status: error.status } : {}\n )\n );\n } else {\n this.pusher.send_event('pusher:subscribe', {\n auth: data.auth,\n channel_data: data.channel_data,\n channel: this.name\n });\n }\n }\n );\n }\n\n /** Sends an unsubscription request. For internal use only. */\n unsubscribe() {\n this.subscribed = false;\n this.pusher.send_event('pusher:unsubscribe', {\n channel: this.name\n });\n }\n\n /** Cancels an in progress subscription. For internal use only. */\n cancelSubscription() {\n this.subscriptionCancelled = true;\n }\n\n /** Reinstates an in progress subscripiton. For internal use only. */\n reinstateSubscription() {\n this.subscriptionCancelled = false;\n }\n}\n","import Factory from '../utils/factory';\nimport Channel from './channel';\nimport { ChannelAuthorizationCallback } from '../auth/options';\n\n/** Extends public channels to provide private channel interface.\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\nexport default class PrivateChannel extends Channel {\n /** Authorizes the connection to use the channel.\n *\n * @param {String} socketId\n * @param {Function} callback\n */\n authorize(socketId: string, callback: ChannelAuthorizationCallback) {\n return this.pusher.config.channelAuthorizer(\n {\n channelName: this.name,\n socketId: socketId\n },\n callback\n );\n }\n}\n","import * as Collections from '../utils/collections';\n\n/** Represents a collection of members of a presence channel. */\nexport default class Members {\n members: any;\n count: number;\n myID: any;\n me: any;\n\n constructor() {\n this.reset();\n }\n\n /** Returns member's info for given id.\n *\n * Resulting object containts two fields - id and info.\n *\n * @param {Number} id\n * @return {Object} member's info or null\n */\n get(id: string): any {\n if (Object.prototype.hasOwnProperty.call(this.members, id)) {\n return {\n id: id,\n info: this.members[id]\n };\n } else {\n return null;\n }\n }\n\n /** Calls back for each member in unspecified order.\n *\n * @param {Function} callback\n */\n each(callback: Function) {\n Collections.objectApply(this.members, (member, id) => {\n callback(this.get(id));\n });\n }\n\n /** Updates the id for connected member. For internal use only. */\n setMyID(id: string) {\n this.myID = id;\n }\n\n /** Handles subscription data. For internal use only. */\n onSubscription(subscriptionData: any) {\n this.members = subscriptionData.presence.hash;\n this.count = subscriptionData.presence.count;\n this.me = this.get(this.myID);\n }\n\n /** Adds a new member to the collection. For internal use only. */\n addMember(memberData: any) {\n if (this.get(memberData.user_id) === null) {\n this.count++;\n }\n this.members[memberData.user_id] = memberData.user_info;\n return this.get(memberData.user_id);\n }\n\n /** Adds a member from the collection. For internal use only. */\n removeMember(memberData: any) {\n var member = this.get(memberData.user_id);\n if (member) {\n delete this.members[memberData.user_id];\n this.count--;\n }\n return member;\n }\n\n /** Resets the collection to the initial state. For internal use only. */\n reset() {\n this.members = {};\n this.count = 0;\n this.myID = null;\n this.me = null;\n }\n}\n","import PrivateChannel from './private_channel';\nimport Logger from '../logger';\nimport Members from './members';\nimport Pusher from '../pusher';\nimport UrlStore from 'core/utils/url_store';\nimport { PusherEvent } from '../connection/protocol/message-types';\nimport Metadata from './metadata';\nimport { ChannelAuthorizationData } from '../auth/options';\n\nexport default class PresenceChannel extends PrivateChannel {\n members: Members;\n\n /** Adds presence channel functionality to private channels.\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\n constructor(name: string, pusher: Pusher) {\n super(name, pusher);\n this.members = new Members();\n }\n\n /** Authorizes the connection as a member of the channel.\n *\n * @param {String} socketId\n * @param {Function} callback\n */\n authorize(socketId: string, callback: Function) {\n super.authorize(socketId, async (error, authData) => {\n if (!error) {\n authData = authData as ChannelAuthorizationData;\n if (authData.channel_data != null) {\n var channelData = JSON.parse(authData.channel_data);\n this.members.setMyID(channelData.user_id);\n } else {\n await this.pusher.user.signinDonePromise;\n if (this.pusher.user.user_data != null) {\n // If the user is signed in, get the id of the authenticated user\n // and allow the presence authorization to continue.\n this.members.setMyID(this.pusher.user.user_data.id);\n } else {\n let suffix = UrlStore.buildLogSuffix('authorizationEndpoint');\n Logger.error(\n `Invalid auth response for channel '${this.name}', ` +\n `expected 'channel_data' field. ${suffix}, ` +\n `or the user should be signed in.`\n );\n callback('Invalid auth response');\n return;\n }\n }\n }\n callback(error, authData);\n });\n }\n\n /** Handles presence and subscription events. For internal use only.\n *\n * @param {PusherEvent} event\n */\n handleEvent(event: PusherEvent) {\n var eventName = event.event;\n if (eventName.indexOf('pusher_internal:') === 0) {\n this.handleInternalEvent(event);\n } else {\n var data = event.data;\n var metadata: Metadata = {};\n if (event.user_id) {\n metadata.user_id = event.user_id;\n }\n this.emit(eventName, data, metadata);\n }\n }\n handleInternalEvent(event: PusherEvent) {\n var eventName = event.event;\n var data = event.data;\n switch (eventName) {\n case 'pusher_internal:subscription_succeeded':\n this.handleSubscriptionSucceededEvent(event);\n break;\n case 'pusher_internal:subscription_count':\n this.handleSubscriptionCountEvent(event);\n break;\n case 'pusher_internal:member_added':\n var addedMember = this.members.addMember(data);\n this.emit('pusher:member_added', addedMember);\n break;\n case 'pusher_internal:member_removed':\n var removedMember = this.members.removeMember(data);\n if (removedMember) {\n this.emit('pusher:member_removed', removedMember);\n }\n break;\n }\n }\n\n handleSubscriptionSucceededEvent(event: PusherEvent) {\n this.subscriptionPending = false;\n this.subscribed = true;\n if (this.subscriptionCancelled) {\n this.pusher.unsubscribe(this.name);\n } else {\n this.members.onSubscription(event.data);\n this.emit('pusher:subscription_succeeded', this.members);\n }\n }\n\n /** Resets the channel state, including members map. For internal use only. */\n disconnect() {\n this.members.reset();\n super.disconnect();\n }\n}\n","import PrivateChannel from './private_channel';\nimport * as Errors from '../errors';\nimport Logger from '../logger';\nimport Pusher from '../pusher';\nimport { decode as encodeUTF8 } from '@stablelib/utf8';\nimport { decode as decodeBase64 } from '@stablelib/base64';\nimport Dispatcher from '../events/dispatcher';\nimport { PusherEvent } from '../connection/protocol/message-types';\nimport {\n ChannelAuthorizationData,\n ChannelAuthorizationCallback\n} from '../auth/options';\nimport * as nacl from 'tweetnacl';\n\n/** Extends private channels to provide encrypted channel interface.\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\nexport default class EncryptedChannel extends PrivateChannel {\n key: Uint8Array = null;\n nacl: nacl;\n\n constructor(name: string, pusher: Pusher, nacl: nacl) {\n super(name, pusher);\n this.nacl = nacl;\n }\n\n /** Authorizes the connection to use the channel.\n *\n * @param {String} socketId\n * @param {Function} callback\n */\n authorize(socketId: string, callback: ChannelAuthorizationCallback) {\n super.authorize(\n socketId,\n (error: Error | null, authData: ChannelAuthorizationData) => {\n if (error) {\n callback(error, authData);\n return;\n }\n let sharedSecret = authData['shared_secret'];\n if (!sharedSecret) {\n callback(\n new Error(\n `No shared_secret key in auth payload for encrypted channel: ${this.name}`\n ),\n null\n );\n return;\n }\n this.key = decodeBase64(sharedSecret);\n delete authData['shared_secret'];\n callback(null, authData);\n }\n );\n }\n\n trigger(event: string, data: any): boolean {\n throw new Errors.UnsupportedFeature(\n 'Client events are not currently supported for encrypted channels'\n );\n }\n\n /** Handles an event. For internal use only.\n *\n * @param {PusherEvent} event\n */\n handleEvent(event: PusherEvent) {\n var eventName = event.event;\n var data = event.data;\n if (\n eventName.indexOf('pusher_internal:') === 0 ||\n eventName.indexOf('pusher:') === 0\n ) {\n super.handleEvent(event);\n return;\n }\n this.handleEncryptedEvent(eventName, data);\n }\n\n private handleEncryptedEvent(event: string, data: any): void {\n if (!this.key) {\n Logger.debug(\n 'Received encrypted event before key has been retrieved from the authEndpoint'\n );\n return;\n }\n if (!data.ciphertext || !data.nonce) {\n Logger.error(\n 'Unexpected format for encrypted event, expected object with `ciphertext` and `nonce` fields, got: ' +\n data\n );\n return;\n }\n let cipherText = decodeBase64(data.ciphertext);\n if (cipherText.length < this.nacl.secretbox.overheadLength) {\n Logger.error(\n `Expected encrypted event ciphertext length to be ${this.nacl.secretbox.overheadLength}, got: ${cipherText.length}`\n );\n return;\n }\n let nonce = decodeBase64(data.nonce);\n if (nonce.length < this.nacl.secretbox.nonceLength) {\n Logger.error(\n `Expected encrypted event nonce length to be ${this.nacl.secretbox.nonceLength}, got: ${nonce.length}`\n );\n return;\n }\n\n let bytes = this.nacl.secretbox.open(cipherText, nonce, this.key);\n if (bytes === null) {\n Logger.debug(\n 'Failed to decrypt an event, probably because it was encrypted with a different key. Fetching a new key from the authEndpoint...'\n );\n // Try a single time to retrieve a new auth key and decrypt the event with it\n // If this fails, a new key will be requested when a new message is received\n this.authorize(this.pusher.connection.socket_id, (error, authData) => {\n if (error) {\n Logger.error(\n `Failed to make a request to the authEndpoint: ${authData}. Unable to fetch new key, so dropping encrypted event`\n );\n return;\n }\n bytes = this.nacl.secretbox.open(cipherText, nonce, this.key);\n if (bytes === null) {\n Logger.error(\n `Failed to decrypt event with new key. Dropping encrypted event`\n );\n return;\n }\n this.emit(event, this.getDataToEmit(bytes));\n return;\n });\n return;\n }\n this.emit(event, this.getDataToEmit(bytes));\n }\n\n // Try and parse the decrypted bytes as JSON. If we can't parse it, just\n // return the utf-8 string\n getDataToEmit(bytes: Uint8Array): string {\n let raw = encodeUTF8(bytes);\n try {\n return JSON.parse(raw);\n } catch {\n return raw;\n }\n }\n}\n","import { default as EventsDispatcher } from '../events/dispatcher';\nimport { OneOffTimer as Timer } from '../utils/timers';\nimport { Config } from '../config';\nimport Logger from '../logger';\nimport HandshakePayload from './handshake/handshake_payload';\nimport Connection from './connection';\nimport Strategy from '../strategies/strategy';\nimport StrategyRunner from '../strategies/strategy_runner';\nimport * as Collections from '../utils/collections';\nimport Timeline from '../timeline/timeline';\nimport ConnectionManagerOptions from './connection_manager_options';\nimport Runtime from 'runtime';\n\nimport {\n ErrorCallbacks,\n HandshakeCallbacks,\n ConnectionCallbacks\n} from './callbacks';\nimport Action from './protocol/action';\n\n/** Manages connection to Pusher.\n *\n * Uses a strategy (currently only default), timers and network availability\n * info to establish a connection and export its state. In case of failures,\n * manages reconnection attempts.\n *\n * Exports state changes as following events:\n * - \"state_change\", { previous: p, current: state }\n * - state\n *\n * States:\n * - initialized - initial state, never transitioned to\n * - connecting - connection is being established\n * - connected - connection has been fully established\n * - disconnected - on requested disconnection\n * - unavailable - after connection timeout or when there's no network\n * - failed - when the connection strategy is not supported\n *\n * Options:\n * - unavailableTimeout - time to transition to unavailable state\n * - activityTimeout - time after which ping message should be sent\n * - pongTimeout - time for Pusher to respond with pong before reconnecting\n *\n * @param {String} key application key\n * @param {Object} options\n */\nexport default class ConnectionManager extends EventsDispatcher {\n key: string;\n options: ConnectionManagerOptions;\n state: string;\n connection: Connection;\n usingTLS: boolean;\n timeline: Timeline;\n socket_id: string;\n unavailableTimer: Timer;\n activityTimer: Timer;\n retryTimer: Timer;\n activityTimeout: number;\n strategy: Strategy;\n runner: StrategyRunner;\n errorCallbacks: ErrorCallbacks;\n handshakeCallbacks: HandshakeCallbacks;\n connectionCallbacks: ConnectionCallbacks;\n\n constructor(key: string, options: ConnectionManagerOptions) {\n super();\n this.state = 'initialized';\n this.connection = null;\n\n this.key = key;\n this.options = options;\n this.timeline = this.options.timeline;\n this.usingTLS = this.options.useTLS;\n\n this.errorCallbacks = this.buildErrorCallbacks();\n this.connectionCallbacks = this.buildConnectionCallbacks(\n this.errorCallbacks\n );\n this.handshakeCallbacks = this.buildHandshakeCallbacks(this.errorCallbacks);\n\n var Network = Runtime.getNetwork();\n\n Network.bind('online', () => {\n this.timeline.info({ netinfo: 'online' });\n if (this.state === 'connecting' || this.state === 'unavailable') {\n this.retryIn(0);\n }\n });\n Network.bind('offline', () => {\n this.timeline.info({ netinfo: 'offline' });\n if (this.connection) {\n this.sendActivityCheck();\n }\n });\n\n this.updateStrategy();\n }\n\n switchCluster(key: string) {\n this.key = key;\n // This ensures that the new config coming from\n // pusher instance are taken into account\n // such as appKey and cluster\n this.updateStrategy();\n this.retryIn(0);\n }\n\n /** Establishes a connection to Pusher.\n *\n * Does nothing when connection is already established. See top-level doc\n * to find events emitted on connection attempts.\n */\n connect() {\n if (this.connection || this.runner) {\n return;\n }\n if (!this.strategy.isSupported()) {\n this.updateState('failed');\n return;\n }\n this.updateState('connecting');\n this.startConnecting();\n this.setUnavailableTimer();\n }\n\n /** Sends raw data.\n *\n * @param {String} data\n */\n send(data) {\n if (this.connection) {\n return this.connection.send(data);\n } else {\n return false;\n }\n }\n\n /** Sends an event.\n *\n * @param {String} name\n * @param {String} data\n * @param {String} [channel]\n * @returns {Boolean} whether message was sent or not\n */\n send_event(name: string, data: any, channel?: string) {\n if (this.connection) {\n return this.connection.send_event(name, data, channel);\n } else {\n return false;\n }\n }\n\n /** Closes the connection. */\n disconnect() {\n this.disconnectInternally();\n this.updateState('disconnected');\n }\n\n isUsingTLS() {\n return this.usingTLS;\n }\n\n private startConnecting() {\n var callback = (error, handshake) => {\n if (error) {\n this.runner = this.strategy.connect(0, callback);\n } else {\n if (handshake.action === 'error') {\n this.emit('error', {\n type: 'HandshakeError',\n error: handshake.error\n });\n this.timeline.error({ handshakeError: handshake.error });\n } else {\n this.abortConnecting(); // we don't support switching connections yet\n this.handshakeCallbacks[handshake.action](handshake);\n }\n }\n };\n this.runner = this.strategy.connect(0, callback);\n }\n\n private abortConnecting() {\n if (this.runner) {\n this.runner.abort();\n this.runner = null;\n }\n }\n\n private disconnectInternally() {\n this.abortConnecting();\n this.clearRetryTimer();\n this.clearUnavailableTimer();\n if (this.connection) {\n var connection = this.abandonConnection();\n connection.close();\n }\n }\n\n private updateStrategy() {\n this.strategy = this.options.getStrategy({\n key: this.key,\n timeline: this.timeline,\n useTLS: this.usingTLS\n });\n }\n\n private retryIn(delay) {\n this.timeline.info({ action: 'retry', delay: delay });\n if (delay > 0) {\n this.emit('connecting_in', Math.round(delay / 1000));\n }\n this.retryTimer = new Timer(delay || 0, () => {\n this.disconnectInternally();\n this.connect();\n });\n }\n\n private clearRetryTimer() {\n if (this.retryTimer) {\n this.retryTimer.ensureAborted();\n this.retryTimer = null;\n }\n }\n\n private setUnavailableTimer() {\n this.unavailableTimer = new Timer(this.options.unavailableTimeout, () => {\n this.updateState('unavailable');\n });\n }\n\n private clearUnavailableTimer() {\n if (this.unavailableTimer) {\n this.unavailableTimer.ensureAborted();\n }\n }\n\n private sendActivityCheck() {\n this.stopActivityCheck();\n this.connection.ping();\n // wait for pong response\n this.activityTimer = new Timer(this.options.pongTimeout, () => {\n this.timeline.error({ pong_timed_out: this.options.pongTimeout });\n this.retryIn(0);\n });\n }\n\n private resetActivityCheck() {\n this.stopActivityCheck();\n // send ping after inactivity\n if (this.connection && !this.connection.handlesActivityChecks()) {\n this.activityTimer = new Timer(this.activityTimeout, () => {\n this.sendActivityCheck();\n });\n }\n }\n\n private stopActivityCheck() {\n if (this.activityTimer) {\n this.activityTimer.ensureAborted();\n }\n }\n\n private buildConnectionCallbacks(\n errorCallbacks: ErrorCallbacks\n ): ConnectionCallbacks {\n return Collections.extend({}, errorCallbacks, {\n message: message => {\n // includes pong messages from server\n this.resetActivityCheck();\n this.emit('message', message);\n },\n ping: () => {\n this.send_event('pusher:pong', {});\n },\n activity: () => {\n this.resetActivityCheck();\n },\n error: error => {\n // just emit error to user - socket will already be closed by browser\n this.emit('error', error);\n },\n closed: () => {\n this.abandonConnection();\n if (this.shouldRetry()) {\n this.retryIn(1000);\n }\n }\n });\n }\n\n private buildHandshakeCallbacks(\n errorCallbacks: ErrorCallbacks\n ): HandshakeCallbacks {\n return Collections.extend({}, errorCallbacks, {\n connected: (handshake: HandshakePayload) => {\n this.activityTimeout = Math.min(\n this.options.activityTimeout,\n handshake.activityTimeout,\n handshake.connection.activityTimeout || Infinity\n );\n this.clearUnavailableTimer();\n this.setConnection(handshake.connection);\n this.socket_id = this.connection.id;\n this.updateState('connected', { socket_id: this.socket_id });\n }\n });\n }\n\n private buildErrorCallbacks(): ErrorCallbacks {\n let withErrorEmitted = callback => {\n return (result: Action | HandshakePayload) => {\n if (result.error) {\n this.emit('error', { type: 'WebSocketError', error: result.error });\n }\n callback(result);\n };\n };\n\n return {\n tls_only: withErrorEmitted(() => {\n this.usingTLS = true;\n this.updateStrategy();\n this.retryIn(0);\n }),\n refused: withErrorEmitted(() => {\n this.disconnect();\n }),\n backoff: withErrorEmitted(() => {\n this.retryIn(1000);\n }),\n retry: withErrorEmitted(() => {\n this.retryIn(0);\n })\n };\n }\n\n private setConnection(connection) {\n this.connection = connection;\n for (var event in this.connectionCallbacks) {\n this.connection.bind(event, this.connectionCallbacks[event]);\n }\n this.resetActivityCheck();\n }\n\n private abandonConnection() {\n if (!this.connection) {\n return;\n }\n this.stopActivityCheck();\n for (var event in this.connectionCallbacks) {\n this.connection.unbind(event, this.connectionCallbacks[event]);\n }\n var connection = this.connection;\n this.connection = null;\n return connection;\n }\n\n private updateState(newState: string, data?: any) {\n var previousState = this.state;\n this.state = newState;\n if (previousState !== newState) {\n var newStateDescription = newState;\n if (newStateDescription === 'connected') {\n newStateDescription += ' with new socket ID ' + data.socket_id;\n }\n Logger.debug(\n 'State changed',\n previousState + ' -> ' + newStateDescription\n );\n this.timeline.info({ state: newState, params: data });\n this.emit('state_change', { previous: previousState, current: newState });\n this.emit(newState, data);\n }\n }\n\n private shouldRetry(): boolean {\n return this.state === 'connecting' || this.state === 'connected';\n }\n}\n","import Channel from './channel';\nimport * as Collections from '../utils/collections';\nimport ChannelTable from './channel_table';\nimport Factory from '../utils/factory';\nimport Pusher from '../pusher';\nimport Logger from '../logger';\nimport * as Errors from '../errors';\nimport urlStore from '../utils/url_store';\n\n/** Handles a channel map. */\nexport default class Channels {\n channels: ChannelTable;\n\n constructor() {\n this.channels = {};\n }\n\n /** Creates or retrieves an existing channel by its name.\n *\n * @param {String} name\n * @param {Pusher} pusher\n * @return {Channel}\n */\n add(name: string, pusher: Pusher) {\n if (!this.channels[name]) {\n this.channels[name] = createChannel(name, pusher);\n }\n return this.channels[name];\n }\n\n /** Returns a list of all channels\n *\n * @return {Array}\n */\n all(): Channel[] {\n return Collections.values(this.channels);\n }\n\n /** Finds a channel by its name.\n *\n * @param {String} name\n * @return {Channel} channel or null if it doesn't exist\n */\n find(name: string) {\n return this.channels[name];\n }\n\n /** Removes a channel from the map.\n *\n * @param {String} name\n */\n remove(name: string) {\n var channel = this.channels[name];\n delete this.channels[name];\n return channel;\n }\n\n /** Proxies disconnection signal to all channels. */\n disconnect() {\n Collections.objectApply(this.channels, function(channel) {\n channel.disconnect();\n });\n }\n}\n\nfunction createChannel(name: string, pusher: Pusher): Channel {\n if (name.indexOf('private-encrypted-') === 0) {\n if (pusher.config.nacl) {\n return Factory.createEncryptedChannel(name, pusher, pusher.config.nacl);\n }\n let errMsg =\n 'Tried to subscribe to a private-encrypted- channel but no nacl implementation available';\n let suffix = urlStore.buildLogSuffix('encryptedChannelSupport');\n throw new Errors.UnsupportedFeature(`${errMsg}. ${suffix}`);\n } else if (name.indexOf('private-') === 0) {\n return Factory.createPrivateChannel(name, pusher);\n } else if (name.indexOf('presence-') === 0) {\n return Factory.createPresenceChannel(name, pusher);\n } else if (name.indexOf('#') === 0) {\n throw new Errors.BadChannelName(\n 'Cannot create a channel with name \"' + name + '\".'\n );\n } else {\n return Factory.createChannel(name, pusher);\n }\n}\n","import AssistantToTheTransportManager from '../transports/assistant_to_the_transport_manager';\nimport PingDelayOptions from '../transports/ping_delay_options';\nimport Transport from '../transports/transport';\nimport TransportManager from '../transports/transport_manager';\nimport Handshake from '../connection/handshake';\nimport TransportConnection from '../transports/transport_connection';\nimport SocketHooks from '../http/socket_hooks';\nimport HTTPSocket from '../http/http_socket';\n\nimport Timeline from '../timeline/timeline';\nimport {\n default as TimelineSender,\n TimelineSenderOptions\n} from '../timeline/timeline_sender';\nimport PresenceChannel from '../channels/presence_channel';\nimport PrivateChannel from '../channels/private_channel';\nimport EncryptedChannel from '../channels/encrypted_channel';\nimport Channel from '../channels/channel';\nimport ConnectionManager from '../connection/connection_manager';\nimport ConnectionManagerOptions from '../connection/connection_manager_options';\nimport Ajax from '../http/ajax';\nimport Channels from '../channels/channels';\nimport Pusher from '../pusher';\nimport { Config } from '../config';\nimport * as nacl from 'tweetnacl';\n\nvar Factory = {\n createChannels(): Channels {\n return new Channels();\n },\n\n createConnectionManager(\n key: string,\n options: ConnectionManagerOptions\n ): ConnectionManager {\n return new ConnectionManager(key, options);\n },\n\n createChannel(name: string, pusher: Pusher): Channel {\n return new Channel(name, pusher);\n },\n\n createPrivateChannel(name: string, pusher: Pusher): PrivateChannel {\n return new PrivateChannel(name, pusher);\n },\n\n createPresenceChannel(name: string, pusher: Pusher): PresenceChannel {\n return new PresenceChannel(name, pusher);\n },\n\n createEncryptedChannel(\n name: string,\n pusher: Pusher,\n nacl: nacl\n ): EncryptedChannel {\n return new EncryptedChannel(name, pusher, nacl);\n },\n\n createTimelineSender(timeline: Timeline, options: TimelineSenderOptions) {\n return new TimelineSender(timeline, options);\n },\n\n createHandshake(\n transport: TransportConnection,\n callback: (HandshakePayload) => void\n ): Handshake {\n return new Handshake(transport, callback);\n },\n\n createAssistantToTheTransportManager(\n manager: TransportManager,\n transport: Transport,\n options: PingDelayOptions\n ): AssistantToTheTransportManager {\n return new AssistantToTheTransportManager(manager, transport, options);\n }\n};\n\nexport default Factory;\n","import AssistantToTheTransportManager from './assistant_to_the_transport_manager';\nimport Transport from './transport';\nimport PingDelayOptions from './ping_delay_options';\nimport Factory from '../utils/factory';\n\nexport interface TransportManagerOptions extends PingDelayOptions {\n lives?: number;\n}\n\n/** Keeps track of the number of lives left for a transport.\n *\n * In the beginning of a session, transports may be assigned a number of\n * lives. When an AssistantToTheTransportManager instance reports a transport\n * connection closed uncleanly, the transport loses a life. When the number\n * of lives drops to zero, the transport gets disabled by its manager.\n *\n * @param {Object} options\n */\nexport default class TransportManager {\n options: TransportManagerOptions;\n livesLeft: number;\n\n constructor(options: TransportManagerOptions) {\n this.options = options || {};\n this.livesLeft = this.options.lives || Infinity;\n }\n\n /** Creates a assistant for the transport.\n *\n * @param {Transport} transport\n * @returns {AssistantToTheTransportManager}\n */\n getAssistant(transport: Transport): AssistantToTheTransportManager {\n return Factory.createAssistantToTheTransportManager(this, transport, {\n minPingDelay: this.options.minPingDelay,\n maxPingDelay: this.options.maxPingDelay\n });\n }\n\n /** Returns whether the transport has any lives left.\n *\n * @returns {Boolean}\n */\n isAlive(): boolean {\n return this.livesLeft > 0;\n }\n\n /** Takes one life from the transport. */\n reportDeath() {\n this.livesLeft -= 1;\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport { OneOffTimer as Timer } from '../utils/timers';\nimport Strategy from './strategy';\nimport StrategyOptions from './strategy_options';\n\n/** Loops through strategies with optional timeouts.\n *\n * Options:\n * - loop - whether it should loop through the substrategy list\n * - timeout - initial timeout for a single substrategy\n * - timeoutLimit - maximum timeout\n *\n * @param {Strategy[]} strategies\n * @param {Object} options\n */\nexport default class SequentialStrategy implements Strategy {\n strategies: Strategy[];\n loop: boolean;\n failFast: boolean;\n timeout: number;\n timeoutLimit: number;\n\n constructor(strategies: Strategy[], options: StrategyOptions) {\n this.strategies = strategies;\n this.loop = Boolean(options.loop);\n this.failFast = Boolean(options.failFast);\n this.timeout = options.timeout;\n this.timeoutLimit = options.timeoutLimit;\n }\n\n isSupported(): boolean {\n return Collections.any(this.strategies, Util.method('isSupported'));\n }\n\n connect(minPriority: number, callback: Function) {\n var strategies = this.strategies;\n var current = 0;\n var timeout = this.timeout;\n var runner = null;\n\n var tryNextStrategy = (error, handshake) => {\n if (handshake) {\n callback(null, handshake);\n } else {\n current = current + 1;\n if (this.loop) {\n current = current % strategies.length;\n }\n\n if (current < strategies.length) {\n if (timeout) {\n timeout = timeout * 2;\n if (this.timeoutLimit) {\n timeout = Math.min(timeout, this.timeoutLimit);\n }\n }\n runner = this.tryStrategy(\n strategies[current],\n minPriority,\n { timeout, failFast: this.failFast },\n tryNextStrategy\n );\n } else {\n callback(true);\n }\n }\n };\n\n runner = this.tryStrategy(\n strategies[current],\n minPriority,\n { timeout: timeout, failFast: this.failFast },\n tryNextStrategy\n );\n\n return {\n abort: function() {\n runner.abort();\n },\n forceMinPriority: function(p) {\n minPriority = p;\n if (runner) {\n runner.forceMinPriority(p);\n }\n }\n };\n }\n\n private tryStrategy(\n strategy: Strategy,\n minPriority: number,\n options: StrategyOptions,\n callback: Function\n ) {\n var timer = null;\n var runner = null;\n\n if (options.timeout > 0) {\n timer = new Timer(options.timeout, function() {\n runner.abort();\n callback(true);\n });\n }\n\n runner = strategy.connect(minPriority, function(error, handshake) {\n if (error && timer && timer.isRunning() && !options.failFast) {\n // advance to the next strategy after the timeout\n return;\n }\n if (timer) {\n timer.ensureAborted();\n }\n callback(error, handshake);\n });\n\n return {\n abort: function() {\n if (timer) {\n timer.ensureAborted();\n }\n runner.abort();\n },\n forceMinPriority: function(p) {\n runner.forceMinPriority(p);\n }\n };\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport Strategy from './strategy';\n\n/** Launches all substrategies and emits prioritized connected transports.\n *\n * @param {Array} strategies\n */\nexport default class BestConnectedEverStrategy implements Strategy {\n strategies: Strategy[];\n\n constructor(strategies: Strategy[]) {\n this.strategies = strategies;\n }\n\n isSupported(): boolean {\n return Collections.any(this.strategies, Util.method('isSupported'));\n }\n\n connect(minPriority: number, callback: Function) {\n return connect(this.strategies, minPriority, function(i, runners) {\n return function(error, handshake) {\n runners[i].error = error;\n if (error) {\n if (allRunnersFailed(runners)) {\n callback(true);\n }\n return;\n }\n Collections.apply(runners, function(runner) {\n runner.forceMinPriority(handshake.transport.priority);\n });\n callback(null, handshake);\n };\n });\n }\n}\n\n/** Connects to all strategies in parallel.\n *\n * Callback builder should be a function that takes two arguments: index\n * and a list of runners. It should return another function that will be\n * passed to the substrategy with given index. Runners can be aborted using\n * abortRunner(s) functions from this class.\n *\n * @param {Array} strategies\n * @param {Function} callbackBuilder\n * @return {Object} strategy runner\n */\nfunction connect(\n strategies: Strategy[],\n minPriority: number,\n callbackBuilder: Function\n) {\n var runners = Collections.map(strategies, function(strategy, i, _, rs) {\n return strategy.connect(minPriority, callbackBuilder(i, rs));\n });\n return {\n abort: function() {\n Collections.apply(runners, abortRunner);\n },\n forceMinPriority: function(p) {\n Collections.apply(runners, function(runner) {\n runner.forceMinPriority(p);\n });\n }\n };\n}\n\nfunction allRunnersFailed(runners): boolean {\n return Collections.all(runners, function(runner) {\n return Boolean(runner.error);\n });\n}\n\nfunction abortRunner(runner) {\n if (!runner.error && !runner.aborted) {\n runner.abort();\n runner.aborted = true;\n }\n}\n","import Util from '../util';\nimport Runtime from 'runtime';\nimport Strategy from './strategy';\nimport SequentialStrategy from './sequential_strategy';\nimport StrategyOptions from './strategy_options';\nimport TransportStrategy from './transport_strategy';\nimport Timeline from '../timeline/timeline';\nimport * as Collections from '../utils/collections';\n\nexport interface TransportStrategyDictionary {\n [key: string]: TransportStrategy;\n}\n\n/** Caches the last successful transport and, after the first few attempts,\n * uses the cached transport for subsequent attempts.\n *\n * @param {Strategy} strategy\n * @param {Object} transports\n * @param {Object} options\n */\nexport default class WebSocketPrioritizedCachedStrategy implements Strategy {\n strategy: Strategy;\n transports: TransportStrategyDictionary;\n ttl: number;\n usingTLS: boolean;\n timeline: Timeline;\n\n constructor(\n strategy: Strategy,\n transports: TransportStrategyDictionary,\n options: StrategyOptions\n ) {\n this.strategy = strategy;\n this.transports = transports;\n this.ttl = options.ttl || 1800 * 1000;\n this.usingTLS = options.useTLS;\n this.timeline = options.timeline;\n }\n\n isSupported(): boolean {\n return this.strategy.isSupported();\n }\n\n connect(minPriority: number, callback: Function) {\n var usingTLS = this.usingTLS;\n var info = fetchTransportCache(usingTLS);\n var cacheSkipCount = info && info.cacheSkipCount ? info.cacheSkipCount : 0;\n\n var strategies = [this.strategy];\n if (info && info.timestamp + this.ttl >= Util.now()) {\n var transport = this.transports[info.transport];\n if (transport) {\n if (['ws', 'wss'].includes(info.transport) || cacheSkipCount > 3) {\n this.timeline.info({\n cached: true,\n transport: info.transport,\n latency: info.latency\n });\n strategies.push(\n new SequentialStrategy([transport], {\n timeout: info.latency * 2 + 1000,\n failFast: true\n })\n );\n } else {\n cacheSkipCount++;\n }\n }\n }\n\n var startTimestamp = Util.now();\n var runner = strategies\n .pop()\n .connect(minPriority, function cb(error, handshake) {\n if (error) {\n flushTransportCache(usingTLS);\n if (strategies.length > 0) {\n startTimestamp = Util.now();\n runner = strategies.pop().connect(minPriority, cb);\n } else {\n callback(error);\n }\n } else {\n storeTransportCache(\n usingTLS,\n handshake.transport.name,\n Util.now() - startTimestamp,\n cacheSkipCount\n );\n callback(null, handshake);\n }\n });\n\n return {\n abort: function() {\n runner.abort();\n },\n forceMinPriority: function(p) {\n minPriority = p;\n if (runner) {\n runner.forceMinPriority(p);\n }\n }\n };\n }\n}\n\nfunction getTransportCacheKey(usingTLS: boolean): string {\n return 'pusherTransport' + (usingTLS ? 'TLS' : 'NonTLS');\n}\n\nfunction fetchTransportCache(usingTLS: boolean): any {\n var storage = Runtime.getLocalStorage();\n if (storage) {\n try {\n var serializedCache = storage[getTransportCacheKey(usingTLS)];\n if (serializedCache) {\n return JSON.parse(serializedCache);\n }\n } catch (e) {\n flushTransportCache(usingTLS);\n }\n }\n return null;\n}\n\nfunction storeTransportCache(\n usingTLS: boolean,\n transport: TransportStrategy,\n latency: number,\n cacheSkipCount: number\n) {\n var storage = Runtime.getLocalStorage();\n if (storage) {\n try {\n storage[getTransportCacheKey(usingTLS)] = Collections.safeJSONStringify({\n timestamp: Util.now(),\n transport: transport,\n latency: latency,\n cacheSkipCount: cacheSkipCount\n });\n } catch (e) {\n // catch over quota exceptions raised by localStorage\n }\n }\n}\n\nfunction flushTransportCache(usingTLS: boolean) {\n var storage = Runtime.getLocalStorage();\n if (storage) {\n try {\n delete storage[getTransportCacheKey(usingTLS)];\n } catch (e) {\n // catch exceptions raised by localStorage\n }\n }\n}\n","import { OneOffTimer as Timer } from '../utils/timers';\nimport Strategy from './strategy';\nimport StrategyOptions from './strategy_options';\n\n/** Runs substrategy after specified delay.\n *\n * Options:\n * - delay - time in miliseconds to delay the substrategy attempt\n *\n * @param {Strategy} strategy\n * @param {Object} options\n */\nexport default class DelayedStrategy implements Strategy {\n strategy: Strategy;\n options: { delay: number };\n\n constructor(strategy: Strategy, { delay: number }) {\n this.strategy = strategy;\n this.options = { delay: number };\n }\n\n isSupported(): boolean {\n return this.strategy.isSupported();\n }\n\n connect(minPriority: number, callback: Function) {\n var strategy = this.strategy;\n var runner;\n var timer = new Timer(this.options.delay, function() {\n runner = strategy.connect(minPriority, callback);\n });\n\n return {\n abort: function() {\n timer.ensureAborted();\n if (runner) {\n runner.abort();\n }\n },\n forceMinPriority: function(p) {\n minPriority = p;\n if (runner) {\n runner.forceMinPriority(p);\n }\n }\n };\n }\n}\n","import Strategy from './strategy';\nimport StrategyRunner from './strategy_runner';\n\n/** Proxies method calls to one of substrategies basing on the test function.\n *\n * @param {Function} test\n * @param {Strategy} trueBranch strategy used when test returns true\n * @param {Strategy} falseBranch strategy used when test returns false\n */\nexport default class IfStrategy implements Strategy {\n test: () => boolean;\n trueBranch: Strategy;\n falseBranch: Strategy;\n\n constructor(\n test: () => boolean,\n trueBranch: Strategy,\n falseBranch: Strategy\n ) {\n this.test = test;\n this.trueBranch = trueBranch;\n this.falseBranch = falseBranch;\n }\n\n isSupported(): boolean {\n var branch = this.test() ? this.trueBranch : this.falseBranch;\n return branch.isSupported();\n }\n\n connect(minPriority: number, callback: Function): StrategyRunner {\n var branch = this.test() ? this.trueBranch : this.falseBranch;\n return branch.connect(minPriority, callback);\n }\n}\n","import Strategy from './strategy';\nimport StrategyRunner from './strategy_runner';\n\n/** Launches the substrategy and terminates on the first open connection.\n *\n * @param {Strategy} strategy\n */\nexport default class FirstConnectedStrategy implements Strategy {\n strategy: Strategy;\n\n constructor(strategy: Strategy) {\n this.strategy = strategy;\n }\n\n isSupported(): boolean {\n return this.strategy.isSupported();\n }\n\n connect(minPriority: number, callback: Function): StrategyRunner {\n var runner = this.strategy.connect(minPriority, function(error, handshake) {\n if (handshake) {\n runner.abort();\n }\n callback(error, handshake);\n });\n return runner;\n }\n}\n","import * as Collections from 'core/utils/collections';\nimport TransportManager from 'core/transports/transport_manager';\nimport Strategy from 'core/strategies/strategy';\nimport StrategyOptions from 'core/strategies/strategy_options';\nimport SequentialStrategy from 'core/strategies/sequential_strategy';\nimport BestConnectedEverStrategy from 'core/strategies/best_connected_ever_strategy';\nimport WebSocketPrioritizedCachedStrategy, {\n TransportStrategyDictionary\n} from 'core/strategies/websocket_prioritized_cached_strategy';\nimport DelayedStrategy from 'core/strategies/delayed_strategy';\nimport IfStrategy from 'core/strategies/if_strategy';\nimport FirstConnectedStrategy from 'core/strategies/first_connected_strategy';\nimport { Config } from 'core/config';\n\nfunction testSupportsStrategy(strategy: Strategy) {\n return function() {\n return strategy.isSupported();\n };\n}\n\nvar getDefaultStrategy = function(\n config: Config,\n baseOptions: StrategyOptions,\n defineTransport: Function\n): Strategy {\n var definedTransports = {};\n\n function defineTransportStrategy(\n name: string,\n type: string,\n priority: number,\n options: StrategyOptions,\n manager?: TransportManager\n ) {\n var transport = defineTransport(\n config,\n name,\n type,\n priority,\n options,\n manager\n );\n\n definedTransports[name] = transport;\n\n return transport;\n }\n\n var ws_options: StrategyOptions = Object.assign({}, baseOptions, {\n hostNonTLS: config.wsHost + ':' + config.wsPort,\n hostTLS: config.wsHost + ':' + config.wssPort,\n httpPath: config.wsPath\n });\n var wss_options: StrategyOptions = Object.assign({}, ws_options, {\n useTLS: true\n });\n var sockjs_options: StrategyOptions = Object.assign({}, baseOptions, {\n hostNonTLS: config.httpHost + ':' + config.httpPort,\n hostTLS: config.httpHost + ':' + config.httpsPort,\n httpPath: config.httpPath\n });\n\n var timeouts = {\n loop: true,\n timeout: 15000,\n timeoutLimit: 60000\n };\n\n var ws_manager = new TransportManager({\n minPingDelay: 10000,\n maxPingDelay: config.activityTimeout\n });\n var streaming_manager = new TransportManager({\n lives: 2,\n minPingDelay: 10000,\n maxPingDelay: config.activityTimeout\n });\n\n var ws_transport = defineTransportStrategy(\n 'ws',\n 'ws',\n 3,\n ws_options,\n ws_manager\n );\n var wss_transport = defineTransportStrategy(\n 'wss',\n 'ws',\n 3,\n wss_options,\n ws_manager\n );\n var sockjs_transport = defineTransportStrategy(\n 'sockjs',\n 'sockjs',\n 1,\n sockjs_options\n );\n var xhr_streaming_transport = defineTransportStrategy(\n 'xhr_streaming',\n 'xhr_streaming',\n 1,\n sockjs_options,\n streaming_manager\n );\n var xdr_streaming_transport = defineTransportStrategy(\n 'xdr_streaming',\n 'xdr_streaming',\n 1,\n sockjs_options,\n streaming_manager\n );\n var xhr_polling_transport = defineTransportStrategy(\n 'xhr_polling',\n 'xhr_polling',\n 1,\n sockjs_options\n );\n var xdr_polling_transport = defineTransportStrategy(\n 'xdr_polling',\n 'xdr_polling',\n 1,\n sockjs_options\n );\n\n var ws_loop = new SequentialStrategy([ws_transport], timeouts);\n var wss_loop = new SequentialStrategy([wss_transport], timeouts);\n var sockjs_loop = new SequentialStrategy([sockjs_transport], timeouts);\n var streaming_loop = new SequentialStrategy(\n [\n new IfStrategy(\n testSupportsStrategy(xhr_streaming_transport),\n xhr_streaming_transport,\n xdr_streaming_transport\n )\n ],\n timeouts\n );\n var polling_loop = new SequentialStrategy(\n [\n new IfStrategy(\n testSupportsStrategy(xhr_polling_transport),\n xhr_polling_transport,\n xdr_polling_transport\n )\n ],\n timeouts\n );\n\n var http_loop = new SequentialStrategy(\n [\n new IfStrategy(\n testSupportsStrategy(streaming_loop),\n new BestConnectedEverStrategy([\n streaming_loop,\n new DelayedStrategy(polling_loop, { delay: 4000 })\n ]),\n polling_loop\n )\n ],\n timeouts\n );\n\n var http_fallback_loop = new IfStrategy(\n testSupportsStrategy(http_loop),\n http_loop,\n sockjs_loop\n );\n\n var wsStrategy;\n if (baseOptions.useTLS) {\n wsStrategy = new BestConnectedEverStrategy([\n ws_loop,\n new DelayedStrategy(http_fallback_loop, { delay: 2000 })\n ]);\n } else {\n wsStrategy = new BestConnectedEverStrategy([\n ws_loop,\n new DelayedStrategy(wss_loop, { delay: 2000 }),\n new DelayedStrategy(http_fallback_loop, { delay: 5000 })\n ]);\n }\n\n return new WebSocketPrioritizedCachedStrategy(\n new FirstConnectedStrategy(\n new IfStrategy(\n testSupportsStrategy(ws_transport),\n wsStrategy,\n http_fallback_loop\n )\n ),\n definedTransports,\n {\n ttl: 1800000,\n timeline: baseOptions.timeline,\n useTLS: baseOptions.useTLS\n }\n );\n};\n\nexport default getDefaultStrategy;\n","import { Dependencies } from '../dom/dependencies';\n\n/** Initializes the transport.\n *\n * Fetches resources if needed and then transitions to initialized.\n */\nexport default function() {\n var self = this;\n\n self.timeline.info(\n self.buildTimelineMessage({\n transport: self.name + (self.options.useTLS ? 's' : '')\n })\n );\n\n if (self.hooks.isInitialized()) {\n self.changeState('initialized');\n } else if (self.hooks.file) {\n self.changeState('initializing');\n Dependencies.load(\n self.hooks.file,\n { useTLS: self.options.useTLS },\n function(error, callback) {\n if (self.hooks.isInitialized()) {\n self.changeState('initialized');\n callback(true);\n } else {\n if (error) {\n self.onError(error);\n }\n self.onClose();\n callback(false);\n }\n }\n );\n } else {\n self.onClose();\n }\n}\n","import HTTPRequest from 'core/http/http_request';\nimport RequestHooks from 'core/http/request_hooks';\nimport Ajax from 'core/http/ajax';\nimport * as Errors from 'core/errors';\n\nvar hooks: RequestHooks = {\n getRequest: function(socket: HTTPRequest): Ajax {\n var xdr = new (window).XDomainRequest();\n xdr.ontimeout = function() {\n socket.emit('error', new Errors.RequestTimedOut());\n socket.close();\n };\n xdr.onerror = function(e) {\n socket.emit('error', e);\n socket.close();\n };\n xdr.onprogress = function() {\n if (xdr.responseText && xdr.responseText.length > 0) {\n socket.onChunk(200, xdr.responseText);\n }\n };\n xdr.onload = function() {\n if (xdr.responseText && xdr.responseText.length > 0) {\n socket.onChunk(200, xdr.responseText);\n }\n socket.emit('finished', 200);\n socket.close();\n };\n return xdr;\n },\n abortRequest: function(xdr: Ajax) {\n xdr.ontimeout = xdr.onerror = xdr.onprogress = xdr.onload = null;\n xdr.abort();\n }\n};\n\nexport default hooks;\n","import Runtime from 'runtime';\nimport RequestHooks from './request_hooks';\nimport Ajax from './ajax';\nimport { default as EventsDispatcher } from '../events/dispatcher';\n\nconst MAX_BUFFER_LENGTH = 256 * 1024;\n\nexport default class HTTPRequest extends EventsDispatcher {\n hooks: RequestHooks;\n method: string;\n url: string;\n position: number;\n xhr: Ajax;\n unloader: Function;\n\n constructor(hooks: RequestHooks, method: string, url: string) {\n super();\n this.hooks = hooks;\n this.method = method;\n this.url = url;\n }\n\n start(payload?: any) {\n this.position = 0;\n this.xhr = this.hooks.getRequest(this);\n\n this.unloader = () => {\n this.close();\n };\n Runtime.addUnloadListener(this.unloader);\n\n this.xhr.open(this.method, this.url, true);\n\n if (this.xhr.setRequestHeader) {\n this.xhr.setRequestHeader('Content-Type', 'application/json'); // ReactNative doesn't set this header by default.\n }\n this.xhr.send(payload);\n }\n\n close() {\n if (this.unloader) {\n Runtime.removeUnloadListener(this.unloader);\n this.unloader = null;\n }\n if (this.xhr) {\n this.hooks.abortRequest(this.xhr);\n this.xhr = null;\n }\n }\n\n onChunk(status: number, data: any) {\n while (true) {\n var chunk = this.advanceBuffer(data);\n if (chunk) {\n this.emit('chunk', { status: status, data: chunk });\n } else {\n break;\n }\n }\n if (this.isBufferTooLong(data)) {\n this.emit('buffer_too_long');\n }\n }\n\n private advanceBuffer(buffer: any[]): any {\n var unreadData = buffer.slice(this.position);\n var endOfLinePosition = unreadData.indexOf('\\n');\n\n if (endOfLinePosition !== -1) {\n this.position += endOfLinePosition + 1;\n return unreadData.slice(0, endOfLinePosition);\n } else {\n // chunk is not finished yet, don't move the buffer pointer\n return null;\n }\n }\n\n private isBufferTooLong(buffer: any): boolean {\n return this.position === buffer.length && buffer.length > MAX_BUFFER_LENGTH;\n }\n}\n","enum State {\n CONNECTING = 0,\n OPEN = 1,\n CLOSED = 3\n}\n\nexport default State;\n","import URLLocation from './url_location';\nimport State from './state';\nimport Socket from '../socket';\nimport SocketHooks from './socket_hooks';\nimport Util from '../util';\nimport Ajax from './ajax';\nimport HTTPRequest from './http_request';\nimport Runtime from 'runtime';\n\nvar autoIncrement = 1;\n\nclass HTTPSocket implements Socket {\n hooks: SocketHooks;\n session: string;\n location: URLLocation;\n readyState: State;\n stream: HTTPRequest;\n\n onopen: () => void;\n onerror: (error: any) => void;\n onclose: (closeEvent: any) => void;\n onmessage: (message: any) => void;\n onactivity: () => void;\n\n constructor(hooks: SocketHooks, url: string) {\n this.hooks = hooks;\n this.session = randomNumber(1000) + '/' + randomString(8);\n this.location = getLocation(url);\n this.readyState = State.CONNECTING;\n this.openStream();\n }\n\n send(payload: any) {\n return this.sendRaw(JSON.stringify([payload]));\n }\n\n ping() {\n this.hooks.sendHeartbeat(this);\n }\n\n close(code: any, reason: any) {\n this.onClose(code, reason, true);\n }\n\n /** For internal use only */\n sendRaw(payload: any): boolean {\n if (this.readyState === State.OPEN) {\n try {\n Runtime.createSocketRequest(\n 'POST',\n getUniqueURL(getSendURL(this.location, this.session))\n ).start(payload);\n return true;\n } catch (e) {\n return false;\n }\n } else {\n return false;\n }\n }\n\n /** For internal use only */\n reconnect() {\n this.closeStream();\n this.openStream();\n }\n\n /** For internal use only */\n onClose(code, reason, wasClean) {\n this.closeStream();\n this.readyState = State.CLOSED;\n if (this.onclose) {\n this.onclose({\n code: code,\n reason: reason,\n wasClean: wasClean\n });\n }\n }\n\n private onChunk(chunk) {\n if (chunk.status !== 200) {\n return;\n }\n if (this.readyState === State.OPEN) {\n this.onActivity();\n }\n\n var payload;\n var type = chunk.data.slice(0, 1);\n switch (type) {\n case 'o':\n payload = JSON.parse(chunk.data.slice(1) || '{}');\n this.onOpen(payload);\n break;\n case 'a':\n payload = JSON.parse(chunk.data.slice(1) || '[]');\n for (var i = 0; i < payload.length; i++) {\n this.onEvent(payload[i]);\n }\n break;\n case 'm':\n payload = JSON.parse(chunk.data.slice(1) || 'null');\n this.onEvent(payload);\n break;\n case 'h':\n this.hooks.onHeartbeat(this);\n break;\n case 'c':\n payload = JSON.parse(chunk.data.slice(1) || '[]');\n this.onClose(payload[0], payload[1], true);\n break;\n }\n }\n\n private onOpen(options) {\n if (this.readyState === State.CONNECTING) {\n if (options && options.hostname) {\n this.location.base = replaceHost(this.location.base, options.hostname);\n }\n this.readyState = State.OPEN;\n\n if (this.onopen) {\n this.onopen();\n }\n } else {\n this.onClose(1006, 'Server lost session', true);\n }\n }\n\n private onEvent(event) {\n if (this.readyState === State.OPEN && this.onmessage) {\n this.onmessage({ data: event });\n }\n }\n\n private onActivity() {\n if (this.onactivity) {\n this.onactivity();\n }\n }\n\n private onError(error) {\n if (this.onerror) {\n this.onerror(error);\n }\n }\n\n private openStream() {\n this.stream = Runtime.createSocketRequest(\n 'POST',\n getUniqueURL(this.hooks.getReceiveURL(this.location, this.session))\n );\n\n this.stream.bind('chunk', chunk => {\n this.onChunk(chunk);\n });\n this.stream.bind('finished', status => {\n this.hooks.onFinished(this, status);\n });\n this.stream.bind('buffer_too_long', () => {\n this.reconnect();\n });\n\n try {\n this.stream.start();\n } catch (error) {\n Util.defer(() => {\n this.onError(error);\n this.onClose(1006, 'Could not start streaming', false);\n });\n }\n }\n\n private closeStream() {\n if (this.stream) {\n this.stream.unbind_all();\n this.stream.close();\n this.stream = null;\n }\n }\n}\n\nfunction getLocation(url): URLLocation {\n var parts = /([^\\?]*)\\/*(\\??.*)/.exec(url);\n return {\n base: parts[1],\n queryString: parts[2]\n };\n}\n\nfunction getSendURL(url: URLLocation, session: string): string {\n return url.base + '/' + session + '/xhr_send';\n}\n\nfunction getUniqueURL(url: string): string {\n var separator = url.indexOf('?') === -1 ? '?' : '&';\n return url + separator + 't=' + +new Date() + '&n=' + autoIncrement++;\n}\n\nfunction replaceHost(url: string, hostname: string): string {\n var urlParts = /(https?:\\/\\/)([^\\/:]+)((\\/|:)?.*)/.exec(url);\n return urlParts[1] + hostname + urlParts[3];\n}\n\nfunction randomNumber(max: number): number {\n return Runtime.randomInt(max);\n}\n\nfunction randomString(length: number): string {\n var result = [];\n\n for (var i = 0; i < length; i++) {\n result.push(randomNumber(32).toString(32));\n }\n\n return result.join('');\n}\n\nexport default HTTPSocket;\n","import SocketHooks from './socket_hooks';\nimport HTTPSocket from './http_socket';\n\nvar hooks: SocketHooks = {\n getReceiveURL: function(url, session) {\n return url.base + '/' + session + '/xhr_streaming' + url.queryString;\n },\n onHeartbeat: function(socket) {\n socket.sendRaw('[]');\n },\n sendHeartbeat: function(socket) {\n socket.sendRaw('[]');\n },\n onFinished: function(socket, status) {\n socket.onClose(1006, 'Connection interrupted (' + status + ')', false);\n }\n};\n\nexport default hooks;\n","import SocketHooks from './socket_hooks';\nimport URLLocation from './url_location';\nimport HTTPSocket from './http_socket';\n\nvar hooks: SocketHooks = {\n getReceiveURL: function(url: URLLocation, session: string): string {\n return url.base + '/' + session + '/xhr' + url.queryString;\n },\n onHeartbeat: function() {\n // next HTTP request will reset server's activity timer\n },\n sendHeartbeat: function(socket) {\n socket.sendRaw('[]');\n },\n onFinished: function(socket, status) {\n if (status === 200) {\n socket.reconnect();\n } else {\n socket.onClose(1006, 'Connection interrupted (' + status + ')', false);\n }\n }\n};\n\nexport default hooks;\n","import HTTPRequest from 'core/http/http_request';\nimport RequestHooks from 'core/http/request_hooks';\nimport Ajax from 'core/http/ajax';\nimport Runtime from 'runtime';\n\nvar hooks: RequestHooks = {\n getRequest: function(socket: HTTPRequest): Ajax {\n var Constructor = Runtime.getXHRAPI();\n var xhr = new Constructor();\n xhr.onreadystatechange = xhr.onprogress = function() {\n switch (xhr.readyState) {\n case 3:\n if (xhr.responseText && xhr.responseText.length > 0) {\n socket.onChunk(xhr.status, xhr.responseText);\n }\n break;\n case 4:\n // this happens only on errors, never after calling close\n if (xhr.responseText && xhr.responseText.length > 0) {\n socket.onChunk(xhr.status, xhr.responseText);\n }\n socket.emit('finished', xhr.status);\n socket.close();\n break;\n }\n };\n return xhr;\n },\n abortRequest: function(xhr: Ajax) {\n xhr.onreadystatechange = null;\n xhr.abort();\n }\n};\n\nexport default hooks;\n","import HTTPRequest from 'core/http/http_request';\nimport HTTPSocket from 'core/http/http_socket';\nimport SocketHooks from 'core/http/socket_hooks';\nimport RequestHooks from 'core/http/request_hooks';\nimport streamingHooks from 'core/http/http_streaming_socket';\nimport pollingHooks from 'core/http/http_polling_socket';\nimport xhrHooks from './http_xhr_request';\nimport HTTPFactory from 'core/http/http_factory';\n\nvar HTTP: HTTPFactory = {\n createStreamingSocket(url: string): HTTPSocket {\n return this.createSocket(streamingHooks, url);\n },\n\n createPollingSocket(url: string): HTTPSocket {\n return this.createSocket(pollingHooks, url);\n },\n\n createSocket(hooks: SocketHooks, url: string): HTTPSocket {\n return new HTTPSocket(hooks, url);\n },\n\n createXHR(method: string, url: string): HTTPRequest {\n return this.createRequest(xhrHooks, method, url);\n },\n\n createRequest(hooks: RequestHooks, method: string, url: string): HTTPRequest {\n return new HTTPRequest(hooks, method, url);\n }\n};\n\nexport default HTTP;\n","import xdrHooks from './http_xdomain_request';\nimport HTTP from 'isomorphic/http/http';\n\nHTTP.createXDR = function(method, url) {\n return this.createRequest(xdrHooks, method, url);\n};\n\nexport default HTTP;\n","import Browser from './browser';\nimport { Dependencies, DependenciesReceivers } from './dom/dependencies';\nimport { AuthTransport, AuthTransports } from 'core/auth/auth_transports';\nimport xhrAuth from 'isomorphic/auth/xhr_auth';\nimport jsonpAuth from './auth/jsonp_auth';\nimport TimelineTransport from 'core/timeline/timeline_transport';\nimport TimelineSender from 'core/timeline/timeline_sender';\nimport ScriptRequest from './dom/script_request';\nimport JSONPRequest from './dom/jsonp_request';\nimport * as Collections from 'core/utils/collections';\nimport { ScriptReceivers } from './dom/script_receiver_factory';\nimport jsonpTimeline from './timeline/jsonp_timeline';\nimport Transports from './transports/transports';\nimport Ajax from 'core/http/ajax';\nimport { Network } from './net_info';\nimport getDefaultStrategy from './default_strategy';\nimport transportConnectionInitializer from './transports/transport_connection_initializer';\nimport HTTPFactory from './http/http';\nimport HTTPRequest from 'core/http/http_request';\n\nvar Runtime: Browser = {\n // for jsonp auth\n nextAuthCallbackID: 1,\n auth_callbacks: {},\n ScriptReceivers,\n DependenciesReceivers,\n getDefaultStrategy,\n Transports,\n transportConnectionInitializer,\n HTTPFactory,\n\n TimelineTransport: jsonpTimeline,\n\n getXHRAPI() {\n return window.XMLHttpRequest;\n },\n\n getWebSocketAPI() {\n return window.WebSocket || window.MozWebSocket;\n },\n\n setup(PusherClass): void {\n (window).Pusher = PusherClass; // JSONp requires Pusher to be in the global scope.\n var initializeOnDocumentBody = () => {\n this.onDocumentBody(PusherClass.ready);\n };\n if (!(window).JSON) {\n Dependencies.load('json2', {}, initializeOnDocumentBody);\n } else {\n initializeOnDocumentBody();\n }\n },\n\n getDocument(): Document {\n return document;\n },\n\n getProtocol(): string {\n return this.getDocument().location.protocol;\n },\n\n getAuthorizers(): AuthTransports {\n return { ajax: xhrAuth, jsonp: jsonpAuth };\n },\n\n onDocumentBody(callback: Function) {\n if (document.body) {\n callback();\n } else {\n setTimeout(() => {\n this.onDocumentBody(callback);\n }, 0);\n }\n },\n\n createJSONPRequest(url: string, data: any): JSONPRequest {\n return new JSONPRequest(url, data);\n },\n\n createScriptRequest(src: string): ScriptRequest {\n return new ScriptRequest(src);\n },\n\n getLocalStorage() {\n try {\n return window.localStorage;\n } catch (e) {\n return undefined;\n }\n },\n\n createXHR(): Ajax {\n if (this.getXHRAPI()) {\n return this.createXMLHttpRequest();\n } else {\n return this.createMicrosoftXHR();\n }\n },\n\n createXMLHttpRequest(): Ajax {\n var Constructor = this.getXHRAPI();\n return new Constructor();\n },\n\n createMicrosoftXHR(): Ajax {\n return new ActiveXObject('Microsoft.XMLHTTP');\n },\n\n getNetwork() {\n return Network;\n },\n\n createWebSocket(url: string): any {\n var Constructor = this.getWebSocketAPI();\n return new Constructor(url);\n },\n\n createSocketRequest(method: string, url: string): HTTPRequest {\n if (this.isXHRSupported()) {\n return this.HTTPFactory.createXHR(method, url);\n } else if (this.isXDRSupported(url.indexOf('https:') === 0)) {\n return this.HTTPFactory.createXDR(method, url);\n } else {\n throw 'Cross-origin HTTP requests are not supported';\n }\n },\n\n isXHRSupported(): boolean {\n var Constructor = this.getXHRAPI();\n return (\n Boolean(Constructor) && new Constructor().withCredentials !== undefined\n );\n },\n\n isXDRSupported(useTLS?: boolean): boolean {\n var protocol = useTLS ? 'https:' : 'http:';\n var documentProtocol = this.getProtocol();\n return (\n Boolean(window['XDomainRequest']) && documentProtocol === protocol\n );\n },\n\n addUnloadListener(listener: any) {\n if (window.addEventListener !== undefined) {\n window.addEventListener('unload', listener, false);\n } else if (window.attachEvent !== undefined) {\n window.attachEvent('onunload', listener);\n }\n },\n\n removeUnloadListener(listener: any) {\n if (window.addEventListener !== undefined) {\n window.removeEventListener('unload', listener, false);\n } else if (window.detachEvent !== undefined) {\n window.detachEvent('onunload', listener);\n }\n },\n\n randomInt(max: number): number {\n /**\n * Return values in the range of [0, 1[\n */\n const random = function() {\n const crypto = window.crypto || window['msCrypto'];\n const random = crypto.getRandomValues(new Uint32Array(1))[0];\n\n return random / 2 ** 32;\n };\n\n return Math.floor(random() * max);\n }\n};\n\nexport default Runtime;\n","enum TimelineLevel {\n ERROR = 3,\n INFO = 6,\n DEBUG = 7\n}\n\nexport default TimelineLevel;\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport { default as Level } from './level';\n\nexport interface TimelineOptions {\n level?: Level;\n limit?: number;\n version?: string;\n cluster?: string;\n features?: string[];\n params?: any;\n}\n\nexport default class Timeline {\n key: string;\n session: number;\n events: any[];\n options: TimelineOptions;\n sent: number;\n uniqueID: number;\n\n constructor(key: string, session: number, options: TimelineOptions) {\n this.key = key;\n this.session = session;\n this.events = [];\n this.options = options || {};\n this.sent = 0;\n this.uniqueID = 0;\n }\n\n log(level, event) {\n if (level <= this.options.level) {\n this.events.push(\n Collections.extend({}, event, { timestamp: Util.now() })\n );\n if (this.options.limit && this.events.length > this.options.limit) {\n this.events.shift();\n }\n }\n }\n\n error(event) {\n this.log(Level.ERROR, event);\n }\n\n info(event) {\n this.log(Level.INFO, event);\n }\n\n debug(event) {\n this.log(Level.DEBUG, event);\n }\n\n isEmpty() {\n return this.events.length === 0;\n }\n\n send(sendfn, callback) {\n var data = Collections.extend(\n {\n session: this.session,\n bundle: this.sent + 1,\n key: this.key,\n lib: 'js',\n version: this.options.version,\n cluster: this.options.cluster,\n features: this.options.features,\n timeline: this.events\n },\n this.options.params\n );\n\n this.events = [];\n sendfn(data, (error, result) => {\n if (!error) {\n this.sent++;\n }\n if (callback) {\n callback(error, result);\n }\n });\n\n return true;\n }\n\n generateUniqueID(): number {\n this.uniqueID++;\n return this.uniqueID;\n }\n}\n","import Factory from '../utils/factory';\nimport Util from '../util';\nimport * as Errors from '../errors';\nimport * as Collections from '../utils/collections';\nimport Strategy from './strategy';\nimport Transport from '../transports/transport';\nimport StrategyOptions from './strategy_options';\nimport Handshake from '../connection/handshake';\n\n/** Provides a strategy interface for transports.\n *\n * @param {String} name\n * @param {Number} priority\n * @param {Class} transport\n * @param {Object} options\n */\nexport default class TransportStrategy implements Strategy {\n name: string;\n priority: number;\n transport: Transport;\n options: StrategyOptions;\n\n constructor(\n name: string,\n priority: number,\n transport: Transport,\n options: StrategyOptions\n ) {\n this.name = name;\n this.priority = priority;\n this.transport = transport;\n this.options = options || {};\n }\n\n /** Returns whether the transport is supported in the browser.\n *\n * @returns {Boolean}\n */\n isSupported(): boolean {\n return this.transport.isSupported({\n useTLS: this.options.useTLS\n });\n }\n\n /** Launches a connection attempt and returns a strategy runner.\n *\n * @param {Function} callback\n * @return {Object} strategy runner\n */\n connect(minPriority: number, callback: Function) {\n if (!this.isSupported()) {\n return failAttempt(new Errors.UnsupportedStrategy(), callback);\n } else if (this.priority < minPriority) {\n return failAttempt(new Errors.TransportPriorityTooLow(), callback);\n }\n\n var connected = false;\n var transport = this.transport.createConnection(\n this.name,\n this.priority,\n this.options.key,\n this.options\n );\n var handshake = null;\n\n var onInitialized = function() {\n transport.unbind('initialized', onInitialized);\n transport.connect();\n };\n var onOpen = function() {\n handshake = Factory.createHandshake(transport, function(result) {\n connected = true;\n unbindListeners();\n callback(null, result);\n });\n };\n var onError = function(error) {\n unbindListeners();\n callback(error);\n };\n var onClosed = function() {\n unbindListeners();\n var serializedTransport;\n\n // The reason for this try/catch block is that on React Native\n // the WebSocket object is circular. Therefore transport.socket will\n // throw errors upon stringification. Collections.safeJSONStringify\n // discards circular references when serializing.\n serializedTransport = Collections.safeJSONStringify(transport);\n callback(new Errors.TransportClosed(serializedTransport));\n };\n\n var unbindListeners = function() {\n transport.unbind('initialized', onInitialized);\n transport.unbind('open', onOpen);\n transport.unbind('error', onError);\n transport.unbind('closed', onClosed);\n };\n\n transport.bind('initialized', onInitialized);\n transport.bind('open', onOpen);\n transport.bind('error', onError);\n transport.bind('closed', onClosed);\n\n // connect will be called automatically after initialization\n transport.initialize();\n\n return {\n abort: () => {\n if (connected) {\n return;\n }\n unbindListeners();\n if (handshake) {\n handshake.close();\n } else {\n transport.close();\n }\n },\n forceMinPriority: p => {\n if (connected) {\n return;\n }\n if (this.priority < p) {\n if (handshake) {\n handshake.close();\n } else {\n transport.close();\n }\n }\n }\n };\n }\n}\n\nfunction failAttempt(error: Error, callback: Function) {\n Util.defer(function() {\n callback(error);\n });\n return {\n abort: function() {},\n forceMinPriority: function() {}\n };\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport TransportManager from '../transports/transport_manager';\nimport * as Errors from '../errors';\nimport Strategy from './strategy';\nimport TransportStrategy from './transport_strategy';\nimport StrategyOptions from '../strategies/strategy_options';\nimport { Config } from '../config';\nimport Runtime from 'runtime';\n\nconst { Transports } = Runtime;\n\nexport var defineTransport = function(\n config: Config,\n name: string,\n type: string,\n priority: number,\n options: StrategyOptions,\n manager?: TransportManager\n): Strategy {\n var transportClass = Transports[type];\n if (!transportClass) {\n throw new Errors.UnsupportedTransport(type);\n }\n\n var enabled =\n (!config.enabledTransports ||\n Collections.arrayIndexOf(config.enabledTransports, name) !== -1) &&\n (!config.disabledTransports ||\n Collections.arrayIndexOf(config.disabledTransports, name) === -1);\n\n var transport;\n if (enabled) {\n options = Object.assign(\n { ignoreNullOrigin: config.ignoreNullOrigin },\n options\n );\n\n transport = new TransportStrategy(\n name,\n priority,\n manager ? manager.getAssistant(transportClass) : transportClass,\n options\n );\n } else {\n transport = UnsupportedStrategy;\n }\n\n return transport;\n};\n\nvar UnsupportedStrategy: Strategy = {\n isSupported: function() {\n return false;\n },\n connect: function(_, callback) {\n var deferred = Util.defer(function() {\n callback(new Errors.UnsupportedStrategy());\n });\n return {\n abort: function() {\n deferred.ensureAborted();\n },\n forceMinPriority: function() {}\n };\n }\n};\n","import ConnectionManager from './connection/connection_manager';\nimport {\n ChannelAuthorizationOptions,\n UserAuthenticationOptions\n} from './auth/options';\nimport {\n ChannelAuthorizerGenerator,\n DeprecatedAuthOptions\n} from './auth/deprecated_channel_authorizer';\nimport { AuthTransport, Transport } from './config';\nimport * as nacl from 'tweetnacl';\nimport Logger from './logger';\n\nexport interface Options {\n activityTimeout?: number;\n\n auth?: DeprecatedAuthOptions; // DEPRECATED use channelAuthorization instead\n authEndpoint?: string; // DEPRECATED use channelAuthorization instead\n authTransport?: AuthTransport; // DEPRECATED use channelAuthorization instead\n authorizer?: ChannelAuthorizerGenerator; // DEPRECATED use channelAuthorization instead\n\n channelAuthorization?: ChannelAuthorizationOptions;\n userAuthentication?: UserAuthenticationOptions;\n\n cluster: string;\n enableStats?: boolean;\n disableStats?: boolean;\n disabledTransports?: Transport[];\n enabledTransports?: Transport[];\n forceTLS?: boolean;\n httpHost?: string;\n httpPath?: string;\n httpPort?: number;\n httpsPort?: number;\n ignoreNullOrigin?: boolean;\n nacl?: nacl;\n pongTimeout?: number;\n statsHost?: string;\n timelineParams?: any;\n unavailableTimeout?: number;\n wsHost?: string;\n wsPath?: string;\n wsPort?: number;\n wssPort?: number;\n}\n\nexport interface ClusterOptions {\n appKey: string;\n cluster: string;\n}\n\nexport function validateOptions(options) {\n if (options == null) {\n throw 'You must pass an options object';\n }\n if (options.cluster == null) {\n throw 'Options object must provide a cluster';\n }\n if ('disableStats' in options) {\n Logger.warn(\n 'The disableStats option is deprecated in favor of enableStats'\n );\n }\n}\n","import {\n UserAuthenticationCallback,\n InternalAuthOptions,\n UserAuthenticationHandler,\n UserAuthenticationRequestParams,\n AuthRequestType\n} from './options';\n\nimport Runtime from 'runtime';\n\nconst composeChannelQuery = (\n params: UserAuthenticationRequestParams,\n authOptions: InternalAuthOptions\n) => {\n var query = 'socket_id=' + encodeURIComponent(params.socketId);\n\n for (var key in authOptions.params) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(authOptions.params[key]);\n }\n\n if (authOptions.paramsProvider != null) {\n let dynamicParams = authOptions.paramsProvider();\n for (var key in dynamicParams) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(dynamicParams[key]);\n }\n }\n\n return query;\n};\n\nconst UserAuthenticator = (\n authOptions: InternalAuthOptions\n): UserAuthenticationHandler => {\n if (typeof Runtime.getAuthorizers()[authOptions.transport] === 'undefined') {\n throw `'${authOptions.transport}' is not a recognized auth transport`;\n }\n\n return (\n params: UserAuthenticationRequestParams,\n callback: UserAuthenticationCallback\n ) => {\n const query = composeChannelQuery(params, authOptions);\n\n Runtime.getAuthorizers()[authOptions.transport](\n Runtime,\n query,\n authOptions,\n AuthRequestType.UserAuthentication,\n callback\n );\n };\n};\n\nexport default UserAuthenticator;\n","import {\n AuthRequestType,\n InternalAuthOptions,\n ChannelAuthorizationHandler,\n ChannelAuthorizationRequestParams,\n ChannelAuthorizationCallback\n} from './options';\n\nimport Runtime from 'runtime';\n\nconst composeChannelQuery = (\n params: ChannelAuthorizationRequestParams,\n authOptions: InternalAuthOptions\n) => {\n var query = 'socket_id=' + encodeURIComponent(params.socketId);\n\n query += '&channel_name=' + encodeURIComponent(params.channelName);\n\n for (var key in authOptions.params) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(authOptions.params[key]);\n }\n\n if (authOptions.paramsProvider != null) {\n let dynamicParams = authOptions.paramsProvider();\n for (var key in dynamicParams) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(dynamicParams[key]);\n }\n }\n\n return query;\n};\n\nconst ChannelAuthorizer = (\n authOptions: InternalAuthOptions\n): ChannelAuthorizationHandler => {\n if (typeof Runtime.getAuthorizers()[authOptions.transport] === 'undefined') {\n throw `'${authOptions.transport}' is not a recognized auth transport`;\n }\n\n return (\n params: ChannelAuthorizationRequestParams,\n callback: ChannelAuthorizationCallback\n ) => {\n const query = composeChannelQuery(params, authOptions);\n\n Runtime.getAuthorizers()[authOptions.transport](\n Runtime,\n query,\n authOptions,\n AuthRequestType.ChannelAuthorization,\n callback\n );\n };\n};\n\nexport default ChannelAuthorizer;\n","import Channel from '../channels/channel';\nimport {\n ChannelAuthorizationCallback,\n ChannelAuthorizationHandler,\n ChannelAuthorizationRequestParams,\n InternalAuthOptions\n} from './options';\n\nexport interface DeprecatedChannelAuthorizer {\n authorize(socketId: string, callback: ChannelAuthorizationCallback): void;\n}\n\nexport interface ChannelAuthorizerGenerator {\n (\n channel: Channel,\n options: DeprecatedAuthorizerOptions\n ): DeprecatedChannelAuthorizer;\n}\n\nexport interface DeprecatedAuthOptions {\n params?: any;\n headers?: any;\n}\n\nexport interface DeprecatedAuthorizerOptions {\n authTransport: 'ajax' | 'jsonp';\n authEndpoint: string;\n auth?: DeprecatedAuthOptions;\n}\n\nexport const ChannelAuthorizerProxy = (\n pusher,\n authOptions: InternalAuthOptions,\n channelAuthorizerGenerator: ChannelAuthorizerGenerator\n): ChannelAuthorizationHandler => {\n const deprecatedAuthorizerOptions: DeprecatedAuthorizerOptions = {\n authTransport: authOptions.transport,\n authEndpoint: authOptions.endpoint,\n auth: {\n params: authOptions.params,\n headers: authOptions.headers\n }\n };\n return (\n params: ChannelAuthorizationRequestParams,\n callback: ChannelAuthorizationCallback\n ) => {\n const channel = pusher.channel(params.channelName);\n // This line creates a new channel authorizer every time.\n // In the past, this was only done once per channel and reused.\n // We can do that again if we want to keep this behavior intact.\n const channelAuthorizer: DeprecatedChannelAuthorizer = channelAuthorizerGenerator(\n channel,\n deprecatedAuthorizerOptions\n );\n channelAuthorizer.authorize(params.socketId, callback);\n };\n};\n","import { Options } from './options';\nimport Defaults from './defaults';\nimport {\n ChannelAuthorizationHandler,\n UserAuthenticationHandler,\n ChannelAuthorizationOptions,\n AuthOptionsT,\n CustomAuthOptions\n} from './auth/options';\nimport UserAuthenticator from './auth/user_authenticator';\nimport ChannelAuthorizer from './auth/channel_authorizer';\nimport { ChannelAuthorizerProxy } from './auth/deprecated_channel_authorizer';\nimport Runtime from 'runtime';\nimport * as nacl from 'tweetnacl';\n\nexport type AuthTransport = 'ajax' | 'jsonp';\nexport type Transport =\n | 'ws'\n | 'wss'\n | 'xhr_streaming'\n | 'xhr_polling'\n | 'sockjs';\n\nexport interface Config {\n // these are all 'required' config parameters, it's not necessary for the user\n // to set them, but they have configured defaults.\n activityTimeout: number;\n enableStats: boolean;\n httpHost: string;\n httpPath: string;\n httpPort: number;\n httpsPort: number;\n pongTimeout: number;\n statsHost: string;\n unavailableTimeout: number;\n useTLS: boolean;\n wsHost: string;\n wsPath: string;\n wsPort: number;\n wssPort: number;\n userAuthenticator: UserAuthenticationHandler;\n channelAuthorizer: ChannelAuthorizationHandler;\n\n // these are all optional parameters or overrrides. The customer can set these\n // but it's not strictly necessary\n forceTLS?: boolean;\n cluster?: string;\n disabledTransports?: Transport[];\n enabledTransports?: Transport[];\n ignoreNullOrigin?: boolean;\n nacl?: nacl;\n timelineParams?: any;\n}\n\n// getConfig mainly sets the defaults for the options that are not provided\nexport function getConfig(opts: Options, pusher): Config {\n let config: Config = {\n activityTimeout: opts.activityTimeout || Defaults.activityTimeout,\n cluster: opts.cluster,\n httpPath: opts.httpPath || Defaults.httpPath,\n httpPort: opts.httpPort || Defaults.httpPort,\n httpsPort: opts.httpsPort || Defaults.httpsPort,\n pongTimeout: opts.pongTimeout || Defaults.pongTimeout,\n statsHost: opts.statsHost || Defaults.stats_host,\n unavailableTimeout: opts.unavailableTimeout || Defaults.unavailableTimeout,\n wsPath: opts.wsPath || Defaults.wsPath,\n wsPort: opts.wsPort || Defaults.wsPort,\n wssPort: opts.wssPort || Defaults.wssPort,\n\n enableStats: getEnableStatsConfig(opts),\n httpHost: getHttpHost(opts),\n useTLS: shouldUseTLS(opts),\n wsHost: getWebsocketHost(opts),\n\n userAuthenticator: buildUserAuthenticator(opts),\n channelAuthorizer: buildChannelAuthorizer(opts, pusher)\n };\n\n if ('disabledTransports' in opts)\n config.disabledTransports = opts.disabledTransports;\n if ('enabledTransports' in opts)\n config.enabledTransports = opts.enabledTransports;\n if ('ignoreNullOrigin' in opts)\n config.ignoreNullOrigin = opts.ignoreNullOrigin;\n if ('timelineParams' in opts) config.timelineParams = opts.timelineParams;\n if ('nacl' in opts) {\n config.nacl = opts.nacl;\n }\n\n return config;\n}\n\nfunction getHttpHost(opts: Options): string {\n if (opts.httpHost) {\n return opts.httpHost;\n }\n if (opts.cluster) {\n return `sockjs-${opts.cluster}.pusher.com`;\n }\n return Defaults.httpHost;\n}\n\nfunction getWebsocketHost(opts: Options): string {\n if (opts.wsHost) {\n return opts.wsHost;\n }\n return getWebsocketHostFromCluster(opts.cluster);\n}\n\nfunction getWebsocketHostFromCluster(cluster: string): string {\n return `ws-${cluster}.pusher.com`;\n}\n\nfunction shouldUseTLS(opts: Options): boolean {\n if (Runtime.getProtocol() === 'https:') {\n return true;\n } else if (opts.forceTLS === false) {\n return false;\n }\n return true;\n}\n\n// if enableStats is set take the value\n// if disableStats is set take the inverse\n// otherwise default to false\nfunction getEnableStatsConfig(opts: Options): boolean {\n if ('enableStats' in opts) {\n return opts.enableStats;\n }\n if ('disableStats' in opts) {\n return !opts.disableStats;\n }\n return false;\n}\n\nconst hasCustomHandler = (\n auth: AuthOptionsT\n): auth is CustomAuthOptions => {\n return 'customHandler' in auth && auth['customHandler'] != null;\n};\n\nfunction buildUserAuthenticator(opts: Options): UserAuthenticationHandler {\n const userAuthentication = {\n ...Defaults.userAuthentication,\n ...opts.userAuthentication\n };\n\n if (hasCustomHandler(userAuthentication)) {\n return userAuthentication['customHandler'];\n }\n\n return UserAuthenticator(userAuthentication);\n}\n\nfunction buildChannelAuth(opts: Options, pusher): ChannelAuthorizationOptions {\n let channelAuthorization: ChannelAuthorizationOptions;\n if ('channelAuthorization' in opts) {\n channelAuthorization = {\n ...Defaults.channelAuthorization,\n ...opts.channelAuthorization\n };\n } else {\n channelAuthorization = {\n transport: opts.authTransport || Defaults.authTransport,\n endpoint: opts.authEndpoint || Defaults.authEndpoint\n };\n\n if ('auth' in opts) {\n if ('params' in opts.auth) channelAuthorization.params = opts.auth.params;\n if ('headers' in opts.auth)\n channelAuthorization.headers = opts.auth.headers;\n }\n\n if ('authorizer' in opts) {\n return {\n customHandler: ChannelAuthorizerProxy(\n pusher,\n channelAuthorization,\n opts.authorizer\n )\n };\n }\n }\n return channelAuthorization;\n}\n\nfunction buildChannelAuthorizer(\n opts: Options,\n pusher\n): ChannelAuthorizationHandler {\n const channelAuthorization = buildChannelAuth(opts, pusher);\n\n if (hasCustomHandler(channelAuthorization)) {\n return channelAuthorization['customHandler'];\n }\n\n return ChannelAuthorizer(channelAuthorization);\n}\n","import Logger from './logger';\nimport Pusher from './pusher';\nimport EventsDispatcher from './events/dispatcher';\n\nexport default class WatchlistFacade extends EventsDispatcher {\n private pusher: Pusher;\n\n public constructor(pusher: Pusher) {\n super(function(eventName, data) {\n Logger.debug(`No callbacks on watchlist events for ${eventName}`);\n });\n\n this.pusher = pusher;\n this.bindWatchlistInternalEvent();\n }\n\n handleEvent(pusherEvent) {\n pusherEvent.data.events.forEach(watchlistEvent => {\n this.emit(watchlistEvent.name, watchlistEvent);\n });\n }\n\n private bindWatchlistInternalEvent() {\n this.pusher.connection.bind('message', pusherEvent => {\n var eventName = pusherEvent.event;\n if (eventName === 'pusher_internal:watchlist_events') {\n this.handleEvent(pusherEvent);\n }\n });\n }\n}\n","function flatPromise() {\n let resolve, reject;\n const promise = new Promise((res, rej) => {\n resolve = res;\n reject = rej;\n });\n return { promise, resolve, reject };\n}\n\nexport default flatPromise;\n","import Pusher from './pusher';\nimport Logger from './logger';\nimport {\n UserAuthenticationData,\n UserAuthenticationCallback\n} from './auth/options';\nimport Channel from './channels/channel';\nimport WatchlistFacade from './watchlist';\nimport EventsDispatcher from './events/dispatcher';\nimport flatPromise from './utils/flat_promise';\n\nexport default class UserFacade extends EventsDispatcher {\n pusher: Pusher;\n signin_requested: boolean = false;\n user_data: any = null;\n serverToUserChannel: Channel = null;\n signinDonePromise: Promise = null;\n watchlist: WatchlistFacade;\n private _signinDoneResolve: Function = null;\n\n public constructor(pusher: Pusher) {\n super(function(eventName, data) {\n Logger.debug('No callbacks on user for ' + eventName);\n });\n this.pusher = pusher;\n this.pusher.connection.bind('state_change', ({ previous, current }) => {\n if (previous !== 'connected' && current === 'connected') {\n this._signin();\n }\n if (previous === 'connected' && current !== 'connected') {\n this._cleanup();\n this._newSigninPromiseIfNeeded();\n }\n });\n\n this.watchlist = new WatchlistFacade(pusher);\n\n this.pusher.connection.bind('message', event => {\n var eventName = event.event;\n if (eventName === 'pusher:signin_success') {\n this._onSigninSuccess(event.data);\n }\n if (\n this.serverToUserChannel &&\n this.serverToUserChannel.name === event.channel\n ) {\n this.serverToUserChannel.handleEvent(event);\n }\n });\n }\n\n public signin() {\n if (this.signin_requested) {\n return;\n }\n\n this.signin_requested = true;\n this._signin();\n }\n\n private _signin() {\n if (!this.signin_requested) {\n return;\n }\n\n this._newSigninPromiseIfNeeded();\n\n if (this.pusher.connection.state !== 'connected') {\n // Signin will be attempted when the connection is connected\n return;\n }\n\n this.pusher.config.userAuthenticator(\n {\n socketId: this.pusher.connection.socket_id\n },\n this._onAuthorize\n );\n }\n\n private _onAuthorize: UserAuthenticationCallback = (\n err,\n authData: UserAuthenticationData\n ) => {\n if (err) {\n Logger.warn(`Error during signin: ${err}`);\n this._cleanup();\n return;\n }\n\n this.pusher.send_event('pusher:signin', {\n auth: authData.auth,\n user_data: authData.user_data\n });\n\n // Later when we get pusher:singin_success event, the user will be marked as signed in\n };\n\n private _onSigninSuccess(data: any) {\n try {\n this.user_data = JSON.parse(data.user_data);\n } catch (e) {\n Logger.error(`Failed parsing user data after signin: ${data.user_data}`);\n this._cleanup();\n return;\n }\n\n if (typeof this.user_data.id !== 'string' || this.user_data.id === '') {\n Logger.error(\n `user_data doesn't contain an id. user_data: ${this.user_data}`\n );\n this._cleanup();\n return;\n }\n\n // Signin succeeded\n this._signinDoneResolve();\n this._subscribeChannels();\n }\n\n private _subscribeChannels() {\n const ensure_subscribed = channel => {\n if (channel.subscriptionPending && channel.subscriptionCancelled) {\n channel.reinstateSubscription();\n } else if (\n !channel.subscriptionPending &&\n this.pusher.connection.state === 'connected'\n ) {\n channel.subscribe();\n }\n };\n\n this.serverToUserChannel = new Channel(\n `#server-to-user-${this.user_data.id}`,\n this.pusher\n );\n this.serverToUserChannel.bind_global((eventName, data) => {\n if (\n eventName.indexOf('pusher_internal:') === 0 ||\n eventName.indexOf('pusher:') === 0\n ) {\n // ignore internal events\n return;\n }\n this.emit(eventName, data);\n });\n ensure_subscribed(this.serverToUserChannel);\n }\n\n private _cleanup() {\n this.user_data = null;\n if (this.serverToUserChannel) {\n this.serverToUserChannel.unbind_all();\n this.serverToUserChannel.disconnect();\n this.serverToUserChannel = null;\n }\n\n if (this.signin_requested) {\n // If signin is in progress and cleanup is called,\n // Mark the current signin process as done.\n this._signinDoneResolve();\n }\n }\n\n private _newSigninPromiseIfNeeded() {\n if (!this.signin_requested) {\n return;\n }\n\n // If there is a promise and it is not resolved, return without creating a new one.\n if (this.signinDonePromise && !(this.signinDonePromise as any).done) {\n return;\n }\n\n // This promise is never rejected.\n // It gets resolved when the signin process is done whether it failed or succeeded\n const { promise, resolve, reject: _ } = flatPromise();\n (promise as any).done = false;\n const setDone = () => {\n (promise as any).done = true;\n };\n promise.then(setDone).catch(setDone);\n this.signinDonePromise = promise;\n this._signinDoneResolve = resolve;\n }\n}\n","import AbstractRuntime from '../runtimes/interface';\nimport Runtime from 'runtime';\nimport * as Collections from './utils/collections';\nimport Channels from './channels/channels';\nimport Channel from './channels/channel';\nimport { default as EventsDispatcher } from './events/dispatcher';\nimport Timeline from './timeline/timeline';\nimport TimelineSender from './timeline/timeline_sender';\nimport TimelineLevel from './timeline/level';\nimport { defineTransport } from './strategies/strategy_builder';\nimport ConnectionManager from './connection/connection_manager';\nimport { PeriodicTimer } from './utils/timers';\nimport Defaults from './defaults';\nimport Logger from './logger';\nimport Factory from './utils/factory';\nimport { Options, ClusterOptions, validateOptions } from './options';\nimport { Config, getConfig } from './config';\nimport StrategyOptions from './strategies/strategy_options';\nimport UserFacade from './user';\n\nexport default class Pusher {\n /* STATIC PROPERTIES */\n static instances: Pusher[] = [];\n static isReady: boolean = false;\n static logToConsole: boolean = false;\n\n // for jsonp\n static Runtime: AbstractRuntime = Runtime;\n static ScriptReceivers: any = (Runtime).ScriptReceivers;\n static DependenciesReceivers: any = (Runtime).DependenciesReceivers;\n static auth_callbacks: any = (Runtime).auth_callbacks;\n\n static ready() {\n Pusher.isReady = true;\n for (var i = 0, l = Pusher.instances.length; i < l; i++) {\n Pusher.instances[i].connect();\n }\n }\n\n static log: (message: any) => void;\n\n private static getClientFeatures(): string[] {\n return Collections.keys(\n Collections.filterObject({ ws: Runtime.Transports.ws }, function(t) {\n return t.isSupported({});\n })\n );\n }\n\n /* INSTANCE PROPERTIES */\n key: string;\n options: Options;\n config: Config;\n channels: Channels;\n global_emitter: EventsDispatcher;\n sessionID: number;\n timeline: Timeline;\n timelineSender: TimelineSender;\n connection: ConnectionManager;\n timelineSenderTimer: PeriodicTimer;\n user: UserFacade;\n constructor(app_key: string, options: Options) {\n checkAppKey(app_key);\n validateOptions(options);\n this.key = app_key;\n this.options = options;\n this.config = getConfig(this.options, this);\n\n this.channels = Factory.createChannels();\n this.global_emitter = new EventsDispatcher();\n this.sessionID = Runtime.randomInt(1000000000);\n\n this.timeline = new Timeline(this.key, this.sessionID, {\n cluster: this.config.cluster,\n features: Pusher.getClientFeatures(),\n params: this.config.timelineParams || {},\n limit: 50,\n level: TimelineLevel.INFO,\n version: Defaults.VERSION\n });\n if (this.config.enableStats) {\n this.timelineSender = Factory.createTimelineSender(this.timeline, {\n host: this.config.statsHost,\n path: '/timeline/v2/' + Runtime.TimelineTransport.name\n });\n }\n\n var getStrategy = (options: StrategyOptions) => {\n return Runtime.getDefaultStrategy(this.config, options, defineTransport);\n };\n\n this.connection = Factory.createConnectionManager(this.key, {\n getStrategy: getStrategy,\n timeline: this.timeline,\n activityTimeout: this.config.activityTimeout,\n pongTimeout: this.config.pongTimeout,\n unavailableTimeout: this.config.unavailableTimeout,\n useTLS: Boolean(this.config.useTLS)\n });\n\n this.connection.bind('connected', () => {\n this.subscribeAll();\n if (this.timelineSender) {\n this.timelineSender.send(this.connection.isUsingTLS());\n }\n });\n\n this.connection.bind('message', event => {\n var eventName = event.event;\n var internal = eventName.indexOf('pusher_internal:') === 0;\n if (event.channel) {\n var channel = this.channel(event.channel);\n if (channel) {\n channel.handleEvent(event);\n }\n }\n // Emit globally [deprecated]\n if (!internal) {\n this.global_emitter.emit(event.event, event.data);\n }\n });\n this.connection.bind('connecting', () => {\n this.channels.disconnect();\n });\n this.connection.bind('disconnected', () => {\n this.channels.disconnect();\n });\n this.connection.bind('error', err => {\n Logger.warn(err);\n });\n\n Pusher.instances.push(this);\n this.timeline.info({ instances: Pusher.instances.length });\n\n this.user = new UserFacade(this);\n\n if (Pusher.isReady) {\n this.connect();\n }\n }\n\n /**\n * Allows you to switch Pusher cluster without\n * losing all the channels/subscription binding\n * as this is internally managed by the SDK.\n */\n switchCluster(options: ClusterOptions) {\n const { appKey, cluster } = options;\n this.key = appKey;\n this.options = { ...this.options, cluster };\n this.config = getConfig(this.options, this);\n this.connection.switchCluster(this.key);\n }\n\n channel(name: string): Channel {\n return this.channels.find(name);\n }\n\n allChannels(): Channel[] {\n return this.channels.all();\n }\n\n connect() {\n this.connection.connect();\n\n if (this.timelineSender) {\n if (!this.timelineSenderTimer) {\n var usingTLS = this.connection.isUsingTLS();\n var timelineSender = this.timelineSender;\n this.timelineSenderTimer = new PeriodicTimer(60000, function() {\n timelineSender.send(usingTLS);\n });\n }\n }\n }\n\n disconnect() {\n this.connection.disconnect();\n\n if (this.timelineSenderTimer) {\n this.timelineSenderTimer.ensureAborted();\n this.timelineSenderTimer = null;\n }\n }\n\n bind(event_name: string, callback: Function, context?: any): Pusher {\n this.global_emitter.bind(event_name, callback, context);\n return this;\n }\n\n unbind(event_name?: string, callback?: Function, context?: any): Pusher {\n this.global_emitter.unbind(event_name, callback, context);\n return this;\n }\n\n bind_global(callback: Function): Pusher {\n this.global_emitter.bind_global(callback);\n return this;\n }\n\n unbind_global(callback?: Function): Pusher {\n this.global_emitter.unbind_global(callback);\n return this;\n }\n\n unbind_all(callback?: Function): Pusher {\n this.global_emitter.unbind_all();\n return this;\n }\n\n subscribeAll() {\n var channelName;\n for (channelName in this.channels.channels) {\n if (this.channels.channels.hasOwnProperty(channelName)) {\n this.subscribe(channelName);\n }\n }\n }\n\n subscribe(channel_name: string) {\n var channel = this.channels.add(channel_name, this);\n if (channel.subscriptionPending && channel.subscriptionCancelled) {\n channel.reinstateSubscription();\n } else if (\n !channel.subscriptionPending &&\n this.connection.state === 'connected'\n ) {\n channel.subscribe();\n }\n return channel;\n }\n\n unsubscribe(channel_name: string) {\n var channel = this.channels.find(channel_name);\n if (channel && channel.subscriptionPending) {\n channel.cancelSubscription();\n } else {\n channel = this.channels.remove(channel_name);\n if (channel && channel.subscribed) {\n channel.unsubscribe();\n }\n }\n }\n\n send_event(event_name: string, data: any, channel?: string) {\n return this.connection.send_event(event_name, data, channel);\n }\n\n shouldUseTLS(): boolean {\n return this.config.useTLS;\n }\n\n signin() {\n this.user.signin();\n }\n}\n\nfunction checkAppKey(key) {\n if (key === null || key === undefined) {\n throw 'You must pass your app key when you instantiate Pusher.';\n }\n}\n\nRuntime.setup(Pusher);\n","import Pusher from './pusher';\nimport { Options, validateOptions } from './options';\nimport * as nacl from 'tweetnacl';\n\nexport default class PusherWithEncryption extends Pusher {\n constructor(app_key: string, options: Options) {\n Pusher.logToConsole = PusherWithEncryption.logToConsole;\n Pusher.log = PusherWithEncryption.log;\n\n validateOptions(options);\n options.nacl = nacl;\n super(app_key, options);\n }\n}\n"],"sourceRoot":""} \ No newline at end of file diff --git a/dist/web/pusher-with-encryption.min.js b/dist/web/pusher-with-encryption.min.js index 8683458b8..f499478ca 100644 --- a/dist/web/pusher-with-encryption.min.js +++ b/dist/web/pusher-with-encryption.min.js @@ -1,9 +1,9 @@ /*! - * Pusher JavaScript Library v8.4.0-rc1 + * Pusher JavaScript Library v8.4.0-rc2 * https://pusher.com/ * * Copyright 2020, Pusher * Released under the MIT licence. */ -!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.Pusher=e():t.Pusher=e()}(window,(function(){return function(t){var e={};function n(r){if(e[r])return e[r].exports;var i=e[r]={i:r,l:!1,exports:{}};return t[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)n.d(r,i,function(e){return t[e]}.bind(null,i));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=3)}([function(t,e,n){"use strict";var r,i=this&&this.__extends||(r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)},function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)});Object.defineProperty(e,"__esModule",{value:!0});var s=function(){function t(t){void 0===t&&(t="="),this._paddingCharacter=t}return t.prototype.encodedLength=function(t){return this._paddingCharacter?(t+2)/3*4|0:(8*t+5)/6|0},t.prototype.encode=function(t){for(var e="",n=0;n>>18&63),e+=this._encodeByte(r>>>12&63),e+=this._encodeByte(r>>>6&63),e+=this._encodeByte(r>>>0&63)}var i=t.length-n;if(i>0){r=t[n]<<16|(2===i?t[n+1]<<8:0);e+=this._encodeByte(r>>>18&63),e+=this._encodeByte(r>>>12&63),e+=2===i?this._encodeByte(r>>>6&63):this._paddingCharacter||"",e+=this._paddingCharacter||""}return e},t.prototype.maxDecodedLength=function(t){return this._paddingCharacter?t/4*3|0:(6*t+7)/8|0},t.prototype.decodedLength=function(t){return this.maxDecodedLength(t.length-this._getPaddingLength(t))},t.prototype.decode=function(t){if(0===t.length)return new Uint8Array(0);for(var e=this._getPaddingLength(t),n=t.length-e,r=new Uint8Array(this.maxDecodedLength(n)),i=0,s=0,o=0,a=0,c=0,h=0,u=0;s>>4,r[i++]=c<<4|h>>>2,r[i++]=h<<6|u,o|=256&a,o|=256&c,o|=256&h,o|=256&u;if(s>>4,o|=256&a,o|=256&c),s>>2,o|=256&h),s>>8&6,e+=51-t>>>8&-75,e+=61-t>>>8&-15,e+=62-t>>>8&3,String.fromCharCode(e)},t.prototype._decodeChar=function(t){var e=256;return e+=(42-t&t-44)>>>8&-256+t-43+62,e+=(46-t&t-48)>>>8&-256+t-47+63,e+=(47-t&t-58)>>>8&-256+t-48+52,e+=(64-t&t-91)>>>8&-256+t-65+0,e+=(96-t&t-123)>>>8&-256+t-97+26},t.prototype._getPaddingLength=function(t){var e=0;if(this._paddingCharacter){for(var n=t.length-1;n>=0&&t[n]===this._paddingCharacter;n--)e++;if(t.length<4||e>2)throw new Error("Base64Coder: incorrect padding")}return e},t}();e.Coder=s;var o=new s;e.encode=function(t){return o.encode(t)},e.decode=function(t){return o.decode(t)};var a=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return i(e,t),e.prototype._encodeByte=function(t){var e=t;return e+=65,e+=25-t>>>8&6,e+=51-t>>>8&-75,e+=61-t>>>8&-13,e+=62-t>>>8&49,String.fromCharCode(e)},e.prototype._decodeChar=function(t){var e=256;return e+=(44-t&t-46)>>>8&-256+t-45+62,e+=(94-t&t-96)>>>8&-256+t-95+63,e+=(47-t&t-58)>>>8&-256+t-48+52,e+=(64-t&t-91)>>>8&-256+t-65+0,e+=(96-t&t-123)>>>8&-256+t-97+26},e}(s);e.URLSafeCoder=a;var c=new a;e.encodeURLSafe=function(t){return c.encode(t)},e.decodeURLSafe=function(t){return c.decode(t)},e.encodedLength=function(t){return o.encodedLength(t)},e.maxDecodedLength=function(t){return o.maxDecodedLength(t)},e.decodedLength=function(t){return o.decodedLength(t)}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r="utf8: invalid source encoding";function i(t){for(var e=0,n=0;n=t.length-1)throw new Error("utf8: invalid string");n++,e+=4}}return e}e.encode=function(t){for(var e=new Uint8Array(i(t)),n=0,r=0;r>6,e[n++]=128|63&s):s<55296?(e[n++]=224|s>>12,e[n++]=128|s>>6&63,e[n++]=128|63&s):(r++,s=(1023&s)<<10,s|=1023&t.charCodeAt(r),s+=65536,e[n++]=240|s>>18,e[n++]=128|s>>12&63,e[n++]=128|s>>6&63,e[n++]=128|63&s)}return e},e.encodedLength=i,e.decode=function(t){for(var e=[],n=0;n=t.length)throw new Error(r);if(128!=(192&(o=t[++n])))throw new Error(r);i=(31&i)<<6|63&o,s=128}else if(i<240){if(n>=t.length-1)throw new Error(r);var o=t[++n],a=t[++n];if(128!=(192&o)||128!=(192&a))throw new Error(r);i=(15&i)<<12|(63&o)<<6|63&a,s=2048}else{if(!(i<248))throw new Error(r);if(n>=t.length-2)throw new Error(r);o=t[++n],a=t[++n];var c=t[++n];if(128!=(192&o)||128!=(192&a)||128!=(192&c))throw new Error(r);i=(15&i)<<18|(63&o)<<12|(63&a)<<6|63&c,s=65536}if(i=55296&&i<=57343)throw new Error(r);if(i>=65536){if(i>1114111)throw new Error(r);i-=65536,e.push(String.fromCharCode(55296|i>>10)),i=56320|1023&i}}e.push(String.fromCharCode(i))}return e.join("")}},function(t,e,n){!function(t){"use strict";var e=function(t){var e,n=new Float64Array(16);if(t)for(e=0;e>24&255,t[e+1]=n>>16&255,t[e+2]=n>>8&255,t[e+3]=255&n,t[e+4]=r>>24&255,t[e+5]=r>>16&255,t[e+6]=r>>8&255,t[e+7]=255&r}function g(t,e,n,r,i){var s,o=0;for(s=0;s>>8)-1}function v(t,e,n,r){return g(t,e,n,r,16)}function b(t,e,n,r){return g(t,e,n,r,32)}function y(t,e,n,r){!function(t,e,n,r){for(var i,s=255&r[0]|(255&r[1])<<8|(255&r[2])<<16|(255&r[3])<<24,o=255&n[0]|(255&n[1])<<8|(255&n[2])<<16|(255&n[3])<<24,a=255&n[4]|(255&n[5])<<8|(255&n[6])<<16|(255&n[7])<<24,c=255&n[8]|(255&n[9])<<8|(255&n[10])<<16|(255&n[11])<<24,h=255&n[12]|(255&n[13])<<8|(255&n[14])<<16|(255&n[15])<<24,u=255&r[4]|(255&r[5])<<8|(255&r[6])<<16|(255&r[7])<<24,l=255&e[0]|(255&e[1])<<8|(255&e[2])<<16|(255&e[3])<<24,d=255&e[4]|(255&e[5])<<8|(255&e[6])<<16|(255&e[7])<<24,p=255&e[8]|(255&e[9])<<8|(255&e[10])<<16|(255&e[11])<<24,f=255&e[12]|(255&e[13])<<8|(255&e[14])<<16|(255&e[15])<<24,g=255&r[8]|(255&r[9])<<8|(255&r[10])<<16|(255&r[11])<<24,v=255&n[16]|(255&n[17])<<8|(255&n[18])<<16|(255&n[19])<<24,b=255&n[20]|(255&n[21])<<8|(255&n[22])<<16|(255&n[23])<<24,y=255&n[24]|(255&n[25])<<8|(255&n[26])<<16|(255&n[27])<<24,m=255&n[28]|(255&n[29])<<8|(255&n[30])<<16|(255&n[31])<<24,w=255&r[12]|(255&r[13])<<8|(255&r[14])<<16|(255&r[15])<<24,_=s,S=o,k=a,C=c,T=h,E=u,P=l,x=d,A=p,O=f,L=g,R=v,U=b,I=y,M=m,D=w,N=0;N<20;N+=2)_^=(i=(U^=(i=(A^=(i=(T^=(i=_+U|0)<<7|i>>>25)+_|0)<<9|i>>>23)+T|0)<<13|i>>>19)+A|0)<<18|i>>>14,E^=(i=(S^=(i=(I^=(i=(O^=(i=E+S|0)<<7|i>>>25)+E|0)<<9|i>>>23)+O|0)<<13|i>>>19)+I|0)<<18|i>>>14,L^=(i=(P^=(i=(k^=(i=(M^=(i=L+P|0)<<7|i>>>25)+L|0)<<9|i>>>23)+M|0)<<13|i>>>19)+k|0)<<18|i>>>14,D^=(i=(R^=(i=(x^=(i=(C^=(i=D+R|0)<<7|i>>>25)+D|0)<<9|i>>>23)+C|0)<<13|i>>>19)+x|0)<<18|i>>>14,_^=(i=(C^=(i=(k^=(i=(S^=(i=_+C|0)<<7|i>>>25)+_|0)<<9|i>>>23)+S|0)<<13|i>>>19)+k|0)<<18|i>>>14,E^=(i=(T^=(i=(x^=(i=(P^=(i=E+T|0)<<7|i>>>25)+E|0)<<9|i>>>23)+P|0)<<13|i>>>19)+x|0)<<18|i>>>14,L^=(i=(O^=(i=(A^=(i=(R^=(i=L+O|0)<<7|i>>>25)+L|0)<<9|i>>>23)+R|0)<<13|i>>>19)+A|0)<<18|i>>>14,D^=(i=(M^=(i=(I^=(i=(U^=(i=D+M|0)<<7|i>>>25)+D|0)<<9|i>>>23)+U|0)<<13|i>>>19)+I|0)<<18|i>>>14;_=_+s|0,S=S+o|0,k=k+a|0,C=C+c|0,T=T+h|0,E=E+u|0,P=P+l|0,x=x+d|0,A=A+p|0,O=O+f|0,L=L+g|0,R=R+v|0,U=U+b|0,I=I+y|0,M=M+m|0,D=D+w|0,t[0]=_>>>0&255,t[1]=_>>>8&255,t[2]=_>>>16&255,t[3]=_>>>24&255,t[4]=S>>>0&255,t[5]=S>>>8&255,t[6]=S>>>16&255,t[7]=S>>>24&255,t[8]=k>>>0&255,t[9]=k>>>8&255,t[10]=k>>>16&255,t[11]=k>>>24&255,t[12]=C>>>0&255,t[13]=C>>>8&255,t[14]=C>>>16&255,t[15]=C>>>24&255,t[16]=T>>>0&255,t[17]=T>>>8&255,t[18]=T>>>16&255,t[19]=T>>>24&255,t[20]=E>>>0&255,t[21]=E>>>8&255,t[22]=E>>>16&255,t[23]=E>>>24&255,t[24]=P>>>0&255,t[25]=P>>>8&255,t[26]=P>>>16&255,t[27]=P>>>24&255,t[28]=x>>>0&255,t[29]=x>>>8&255,t[30]=x>>>16&255,t[31]=x>>>24&255,t[32]=A>>>0&255,t[33]=A>>>8&255,t[34]=A>>>16&255,t[35]=A>>>24&255,t[36]=O>>>0&255,t[37]=O>>>8&255,t[38]=O>>>16&255,t[39]=O>>>24&255,t[40]=L>>>0&255,t[41]=L>>>8&255,t[42]=L>>>16&255,t[43]=L>>>24&255,t[44]=R>>>0&255,t[45]=R>>>8&255,t[46]=R>>>16&255,t[47]=R>>>24&255,t[48]=U>>>0&255,t[49]=U>>>8&255,t[50]=U>>>16&255,t[51]=U>>>24&255,t[52]=I>>>0&255,t[53]=I>>>8&255,t[54]=I>>>16&255,t[55]=I>>>24&255,t[56]=M>>>0&255,t[57]=M>>>8&255,t[58]=M>>>16&255,t[59]=M>>>24&255,t[60]=D>>>0&255,t[61]=D>>>8&255,t[62]=D>>>16&255,t[63]=D>>>24&255}(t,e,n,r)}function m(t,e,n,r){!function(t,e,n,r){for(var i,s=255&r[0]|(255&r[1])<<8|(255&r[2])<<16|(255&r[3])<<24,o=255&n[0]|(255&n[1])<<8|(255&n[2])<<16|(255&n[3])<<24,a=255&n[4]|(255&n[5])<<8|(255&n[6])<<16|(255&n[7])<<24,c=255&n[8]|(255&n[9])<<8|(255&n[10])<<16|(255&n[11])<<24,h=255&n[12]|(255&n[13])<<8|(255&n[14])<<16|(255&n[15])<<24,u=255&r[4]|(255&r[5])<<8|(255&r[6])<<16|(255&r[7])<<24,l=255&e[0]|(255&e[1])<<8|(255&e[2])<<16|(255&e[3])<<24,d=255&e[4]|(255&e[5])<<8|(255&e[6])<<16|(255&e[7])<<24,p=255&e[8]|(255&e[9])<<8|(255&e[10])<<16|(255&e[11])<<24,f=255&e[12]|(255&e[13])<<8|(255&e[14])<<16|(255&e[15])<<24,g=255&r[8]|(255&r[9])<<8|(255&r[10])<<16|(255&r[11])<<24,v=255&n[16]|(255&n[17])<<8|(255&n[18])<<16|(255&n[19])<<24,b=255&n[20]|(255&n[21])<<8|(255&n[22])<<16|(255&n[23])<<24,y=255&n[24]|(255&n[25])<<8|(255&n[26])<<16|(255&n[27])<<24,m=255&n[28]|(255&n[29])<<8|(255&n[30])<<16|(255&n[31])<<24,w=255&r[12]|(255&r[13])<<8|(255&r[14])<<16|(255&r[15])<<24,_=0;_<20;_+=2)s^=(i=(b^=(i=(p^=(i=(h^=(i=s+b|0)<<7|i>>>25)+s|0)<<9|i>>>23)+h|0)<<13|i>>>19)+p|0)<<18|i>>>14,u^=(i=(o^=(i=(y^=(i=(f^=(i=u+o|0)<<7|i>>>25)+u|0)<<9|i>>>23)+f|0)<<13|i>>>19)+y|0)<<18|i>>>14,g^=(i=(l^=(i=(a^=(i=(m^=(i=g+l|0)<<7|i>>>25)+g|0)<<9|i>>>23)+m|0)<<13|i>>>19)+a|0)<<18|i>>>14,w^=(i=(v^=(i=(d^=(i=(c^=(i=w+v|0)<<7|i>>>25)+w|0)<<9|i>>>23)+c|0)<<13|i>>>19)+d|0)<<18|i>>>14,s^=(i=(c^=(i=(a^=(i=(o^=(i=s+c|0)<<7|i>>>25)+s|0)<<9|i>>>23)+o|0)<<13|i>>>19)+a|0)<<18|i>>>14,u^=(i=(h^=(i=(d^=(i=(l^=(i=u+h|0)<<7|i>>>25)+u|0)<<9|i>>>23)+l|0)<<13|i>>>19)+d|0)<<18|i>>>14,g^=(i=(f^=(i=(p^=(i=(v^=(i=g+f|0)<<7|i>>>25)+g|0)<<9|i>>>23)+v|0)<<13|i>>>19)+p|0)<<18|i>>>14,w^=(i=(m^=(i=(y^=(i=(b^=(i=w+m|0)<<7|i>>>25)+w|0)<<9|i>>>23)+b|0)<<13|i>>>19)+y|0)<<18|i>>>14;t[0]=s>>>0&255,t[1]=s>>>8&255,t[2]=s>>>16&255,t[3]=s>>>24&255,t[4]=u>>>0&255,t[5]=u>>>8&255,t[6]=u>>>16&255,t[7]=u>>>24&255,t[8]=g>>>0&255,t[9]=g>>>8&255,t[10]=g>>>16&255,t[11]=g>>>24&255,t[12]=w>>>0&255,t[13]=w>>>8&255,t[14]=w>>>16&255,t[15]=w>>>24&255,t[16]=l>>>0&255,t[17]=l>>>8&255,t[18]=l>>>16&255,t[19]=l>>>24&255,t[20]=d>>>0&255,t[21]=d>>>8&255,t[22]=d>>>16&255,t[23]=d>>>24&255,t[24]=p>>>0&255,t[25]=p>>>8&255,t[26]=p>>>16&255,t[27]=p>>>24&255,t[28]=f>>>0&255,t[29]=f>>>8&255,t[30]=f>>>16&255,t[31]=f>>>24&255}(t,e,n,r)}var w=new Uint8Array([101,120,112,97,110,100,32,51,50,45,98,121,116,101,32,107]);function _(t,e,n,r,i,s,o){var a,c,h=new Uint8Array(16),u=new Uint8Array(64);for(c=0;c<16;c++)h[c]=0;for(c=0;c<8;c++)h[c]=s[c];for(;i>=64;){for(y(u,h,o,w),c=0;c<64;c++)t[e+c]=n[r+c]^u[c];for(a=1,c=8;c<16;c++)a=a+(255&h[c])|0,h[c]=255&a,a>>>=8;i-=64,e+=64,r+=64}if(i>0)for(y(u,h,o,w),c=0;c=64;){for(y(c,a,i,w),o=0;o<64;o++)t[e+o]=c[o];for(s=1,o=8;o<16;o++)s=s+(255&a[o])|0,a[o]=255&s,s>>>=8;n-=64,e+=64}if(n>0)for(y(c,a,i,w),o=0;o>>13|n<<3),r=255&t[4]|(255&t[5])<<8,this.r[2]=7939&(n>>>10|r<<6),i=255&t[6]|(255&t[7])<<8,this.r[3]=8191&(r>>>7|i<<9),s=255&t[8]|(255&t[9])<<8,this.r[4]=255&(i>>>4|s<<12),this.r[5]=s>>>1&8190,o=255&t[10]|(255&t[11])<<8,this.r[6]=8191&(s>>>14|o<<2),a=255&t[12]|(255&t[13])<<8,this.r[7]=8065&(o>>>11|a<<5),c=255&t[14]|(255&t[15])<<8,this.r[8]=8191&(a>>>8|c<<8),this.r[9]=c>>>5&127,this.pad[0]=255&t[16]|(255&t[17])<<8,this.pad[1]=255&t[18]|(255&t[19])<<8,this.pad[2]=255&t[20]|(255&t[21])<<8,this.pad[3]=255&t[22]|(255&t[23])<<8,this.pad[4]=255&t[24]|(255&t[25])<<8,this.pad[5]=255&t[26]|(255&t[27])<<8,this.pad[6]=255&t[28]|(255&t[29])<<8,this.pad[7]=255&t[30]|(255&t[31])<<8};function E(t,e,n,r,i,s){var o=new T(s);return o.update(n,r,i),o.finish(t,e),0}function P(t,e,n,r,i,s){var o=new Uint8Array(16);return E(o,0,n,r,i,s),v(t,e,o,0)}function x(t,e,n,r,i){var s;if(n<32)return-1;for(C(t,0,e,0,n,r,i),E(t,16,t,32,n-32,t),s=0;s<16;s++)t[s]=0;return 0}function A(t,e,n,r,i){var s,o=new Uint8Array(32);if(n<32)return-1;if(k(o,0,32,r,i),0!==P(e,16,e,32,n-32,o))return-1;for(C(t,0,e,0,n,r,i),s=0;s<32;s++)t[s]=0;return 0}function O(t,e){var n;for(n=0;n<16;n++)t[n]=0|e[n]}function L(t){var e,n,r=1;for(e=0;e<16;e++)n=t[e]+r+65535,r=Math.floor(n/65536),t[e]=n-65536*r;t[0]+=r-1+37*(r-1)}function R(t,e,n){for(var r,i=~(n-1),s=0;s<16;s++)r=i&(t[s]^e[s]),t[s]^=r,e[s]^=r}function U(t,n){var r,i,s,o=e(),a=e();for(r=0;r<16;r++)a[r]=n[r];for(L(a),L(a),L(a),i=0;i<2;i++){for(o[0]=a[0]-65517,r=1;r<15;r++)o[r]=a[r]-65535-(o[r-1]>>16&1),o[r-1]&=65535;o[15]=a[15]-32767-(o[14]>>16&1),s=o[15]>>16&1,o[14]&=65535,R(a,o,1-s)}for(r=0;r<16;r++)t[2*r]=255&a[r],t[2*r+1]=a[r]>>8}function I(t,e){var n=new Uint8Array(32),r=new Uint8Array(32);return U(n,t),U(r,e),b(n,0,r,0)}function M(t){var e=new Uint8Array(32);return U(e,t),1&e[0]}function D(t,e){var n;for(n=0;n<16;n++)t[n]=e[2*n]+(e[2*n+1]<<8);t[15]&=32767}function N(t,e,n){for(var r=0;r<16;r++)t[r]=e[r]+n[r]}function j(t,e,n){for(var r=0;r<16;r++)t[r]=e[r]-n[r]}function B(t,e,n){var r,i,s=0,o=0,a=0,c=0,h=0,u=0,l=0,d=0,p=0,f=0,g=0,v=0,b=0,y=0,m=0,w=0,_=0,S=0,k=0,C=0,T=0,E=0,P=0,x=0,A=0,O=0,L=0,R=0,U=0,I=0,M=0,D=n[0],N=n[1],j=n[2],B=n[3],z=n[4],H=n[5],q=n[6],F=n[7],X=n[8],J=n[9],Y=n[10],K=n[11],$=n[12],W=n[13],G=n[14],V=n[15];s+=(r=e[0])*D,o+=r*N,a+=r*j,c+=r*B,h+=r*z,u+=r*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r=c+i+65535)-65536*(i=Math.floor(r/65536)),h=(r=h+i+65535)-65536*(i=Math.floor(r/65536)),u=(r=u+i+65535)-65536*(i=Math.floor(r/65536)),l=(r=l+i+65535)-65536*(i=Math.floor(r/65536)),d=(r=d+i+65535)-65536*(i=Math.floor(r/65536)),p=(r=p+i+65535)-65536*(i=Math.floor(r/65536)),f=(r=f+i+65535)-65536*(i=Math.floor(r/65536)),g=(r=g+i+65535)-65536*(i=Math.floor(r/65536)),v=(r=v+i+65535)-65536*(i=Math.floor(r/65536)),b=(r=b+i+65535)-65536*(i=Math.floor(r/65536)),y=(r=y+i+65535)-65536*(i=Math.floor(r/65536)),m=(r=m+i+65535)-65536*(i=Math.floor(r/65536)),w=(r=w+i+65535)-65536*(i=Math.floor(r/65536)),s=(r=(s+=i-1+37*(i-1))+(i=1)+65535)-65536*(i=Math.floor(r/65536)),o=(r=o+i+65535)-65536*(i=Math.floor(r/65536)),a=(r=a+i+65535)-65536*(i=Math.floor(r/65536)),c=(r=c+i+65535)-65536*(i=Math.floor(r/65536)),h=(r=h+i+65535)-65536*(i=Math.floor(r/65536)),u=(r=u+i+65535)-65536*(i=Math.floor(r/65536)),l=(r=l+i+65535)-65536*(i=Math.floor(r/65536)),d=(r=d+i+65535)-65536*(i=Math.floor(r/65536)),p=(r=p+i+65535)-65536*(i=Math.floor(r/65536)),f=(r=f+i+65535)-65536*(i=Math.floor(r/65536)),g=(r=g+i+65535)-65536*(i=Math.floor(r/65536)),v=(r=v+i+65535)-65536*(i=Math.floor(r/65536)),b=(r=b+i+65535)-65536*(i=Math.floor(r/65536)),y=(r=y+i+65535)-65536*(i=Math.floor(r/65536)),m=(r=m+i+65535)-65536*(i=Math.floor(r/65536)),w=(r=w+i+65535)-65536*(i=Math.floor(r/65536)),s+=i-1+37*(i-1),t[0]=s,t[1]=o,t[2]=a,t[3]=c,t[4]=h,t[5]=u,t[6]=l,t[7]=d,t[8]=p,t[9]=f,t[10]=g,t[11]=v,t[12]=b,t[13]=y,t[14]=m,t[15]=w}function z(t,e){B(t,e,e)}function H(t,n){var r,i=e();for(r=0;r<16;r++)i[r]=n[r];for(r=253;r>=0;r--)z(i,i),2!==r&&4!==r&&B(i,i,n);for(r=0;r<16;r++)t[r]=i[r]}function q(t,n){var r,i=e();for(r=0;r<16;r++)i[r]=n[r];for(r=250;r>=0;r--)z(i,i),1!==r&&B(i,i,n);for(r=0;r<16;r++)t[r]=i[r]}function F(t,n,r){var i,s,o=new Uint8Array(32),a=new Float64Array(80),h=e(),u=e(),l=e(),d=e(),p=e(),f=e();for(s=0;s<31;s++)o[s]=n[s];for(o[31]=127&n[31]|64,o[0]&=248,D(a,r),s=0;s<16;s++)u[s]=a[s],d[s]=h[s]=l[s]=0;for(h[0]=d[0]=1,s=254;s>=0;--s)R(h,u,i=o[s>>>3]>>>(7&s)&1),R(l,d,i),N(p,h,l),j(h,h,l),N(l,u,d),j(u,u,d),z(d,p),z(f,h),B(h,l,h),B(l,u,p),N(p,h,l),j(h,h,l),z(u,h),j(l,d,f),B(h,l,c),N(h,h,d),B(l,l,h),B(h,d,f),B(d,u,a),z(u,p),R(h,u,i),R(l,d,i);for(s=0;s<16;s++)a[s+16]=h[s],a[s+32]=l[s],a[s+48]=u[s],a[s+64]=d[s];var g=a.subarray(32),v=a.subarray(16);return H(g,g),B(v,v,g),U(t,v),0}function X(t,e){return F(t,e,s)}function J(t,e){return r(e,32),X(t,e)}function Y(t,e,n){var r=new Uint8Array(32);return F(r,n,e),m(t,i,r,w)}T.prototype.blocks=function(t,e,n){for(var r,i,s,o,a,c,h,u,l,d,p,f,g,v,b,y,m,w,_,S=this.fin?0:2048,k=this.h[0],C=this.h[1],T=this.h[2],E=this.h[3],P=this.h[4],x=this.h[5],A=this.h[6],O=this.h[7],L=this.h[8],R=this.h[9],U=this.r[0],I=this.r[1],M=this.r[2],D=this.r[3],N=this.r[4],j=this.r[5],B=this.r[6],z=this.r[7],H=this.r[8],q=this.r[9];n>=16;)d=l=0,d+=(k+=8191&(r=255&t[e+0]|(255&t[e+1])<<8))*U,d+=(C+=8191&(r>>>13|(i=255&t[e+2]|(255&t[e+3])<<8)<<3))*(5*q),d+=(T+=8191&(i>>>10|(s=255&t[e+4]|(255&t[e+5])<<8)<<6))*(5*H),d+=(E+=8191&(s>>>7|(o=255&t[e+6]|(255&t[e+7])<<8)<<9))*(5*z),l=(d+=(P+=8191&(o>>>4|(a=255&t[e+8]|(255&t[e+9])<<8)<<12))*(5*B))>>>13,d&=8191,d+=(x+=a>>>1&8191)*(5*j),d+=(A+=8191&(a>>>14|(c=255&t[e+10]|(255&t[e+11])<<8)<<2))*(5*N),d+=(O+=8191&(c>>>11|(h=255&t[e+12]|(255&t[e+13])<<8)<<5))*(5*D),d+=(L+=8191&(h>>>8|(u=255&t[e+14]|(255&t[e+15])<<8)<<8))*(5*M),p=l+=(d+=(R+=u>>>5|S)*(5*I))>>>13,p+=k*I,p+=C*U,p+=T*(5*q),p+=E*(5*H),l=(p+=P*(5*z))>>>13,p&=8191,p+=x*(5*B),p+=A*(5*j),p+=O*(5*N),p+=L*(5*D),l+=(p+=R*(5*M))>>>13,p&=8191,f=l,f+=k*M,f+=C*I,f+=T*U,f+=E*(5*q),l=(f+=P*(5*H))>>>13,f&=8191,f+=x*(5*z),f+=A*(5*B),f+=O*(5*j),f+=L*(5*N),g=l+=(f+=R*(5*D))>>>13,g+=k*D,g+=C*M,g+=T*I,g+=E*U,l=(g+=P*(5*q))>>>13,g&=8191,g+=x*(5*H),g+=A*(5*z),g+=O*(5*B),g+=L*(5*j),v=l+=(g+=R*(5*N))>>>13,v+=k*N,v+=C*D,v+=T*M,v+=E*I,l=(v+=P*U)>>>13,v&=8191,v+=x*(5*q),v+=A*(5*H),v+=O*(5*z),v+=L*(5*B),b=l+=(v+=R*(5*j))>>>13,b+=k*j,b+=C*N,b+=T*D,b+=E*M,l=(b+=P*I)>>>13,b&=8191,b+=x*U,b+=A*(5*q),b+=O*(5*H),b+=L*(5*z),y=l+=(b+=R*(5*B))>>>13,y+=k*B,y+=C*j,y+=T*N,y+=E*D,l=(y+=P*M)>>>13,y&=8191,y+=x*I,y+=A*U,y+=O*(5*q),y+=L*(5*H),m=l+=(y+=R*(5*z))>>>13,m+=k*z,m+=C*B,m+=T*j,m+=E*N,l=(m+=P*D)>>>13,m&=8191,m+=x*M,m+=A*I,m+=O*U,m+=L*(5*q),w=l+=(m+=R*(5*H))>>>13,w+=k*H,w+=C*z,w+=T*B,w+=E*j,l=(w+=P*N)>>>13,w&=8191,w+=x*D,w+=A*M,w+=O*I,w+=L*U,_=l+=(w+=R*(5*q))>>>13,_+=k*q,_+=C*H,_+=T*z,_+=E*B,l=(_+=P*j)>>>13,_&=8191,_+=x*N,_+=A*D,_+=O*M,_+=L*I,k=d=8191&(l=(l=((l+=(_+=R*U)>>>13)<<2)+l|0)+(d&=8191)|0),C=p+=l>>>=13,T=f&=8191,E=g&=8191,P=v&=8191,x=b&=8191,A=y&=8191,O=m&=8191,L=w&=8191,R=_&=8191,e+=16,n-=16;this.h[0]=k,this.h[1]=C,this.h[2]=T,this.h[3]=E,this.h[4]=P,this.h[5]=x,this.h[6]=A,this.h[7]=O,this.h[8]=L,this.h[9]=R},T.prototype.finish=function(t,e){var n,r,i,s,o=new Uint16Array(10);if(this.leftover){for(s=this.leftover,this.buffer[s++]=1;s<16;s++)this.buffer[s]=0;this.fin=1,this.blocks(this.buffer,0,16)}for(n=this.h[1]>>>13,this.h[1]&=8191,s=2;s<10;s++)this.h[s]+=n,n=this.h[s]>>>13,this.h[s]&=8191;for(this.h[0]+=5*n,n=this.h[0]>>>13,this.h[0]&=8191,this.h[1]+=n,n=this.h[1]>>>13,this.h[1]&=8191,this.h[2]+=n,o[0]=this.h[0]+5,n=o[0]>>>13,o[0]&=8191,s=1;s<10;s++)o[s]=this.h[s]+n,n=o[s]>>>13,o[s]&=8191;for(o[9]-=8192,r=(1^n)-1,s=0;s<10;s++)o[s]&=r;for(r=~r,s=0;s<10;s++)this.h[s]=this.h[s]&r|o[s];for(this.h[0]=65535&(this.h[0]|this.h[1]<<13),this.h[1]=65535&(this.h[1]>>>3|this.h[2]<<10),this.h[2]=65535&(this.h[2]>>>6|this.h[3]<<7),this.h[3]=65535&(this.h[3]>>>9|this.h[4]<<4),this.h[4]=65535&(this.h[4]>>>12|this.h[5]<<1|this.h[6]<<14),this.h[5]=65535&(this.h[6]>>>2|this.h[7]<<11),this.h[6]=65535&(this.h[7]>>>5|this.h[8]<<8),this.h[7]=65535&(this.h[8]>>>8|this.h[9]<<5),i=this.h[0]+this.pad[0],this.h[0]=65535&i,s=1;s<8;s++)i=(this.h[s]+this.pad[s]|0)+(i>>>16)|0,this.h[s]=65535&i;t[e+0]=this.h[0]>>>0&255,t[e+1]=this.h[0]>>>8&255,t[e+2]=this.h[1]>>>0&255,t[e+3]=this.h[1]>>>8&255,t[e+4]=this.h[2]>>>0&255,t[e+5]=this.h[2]>>>8&255,t[e+6]=this.h[3]>>>0&255,t[e+7]=this.h[3]>>>8&255,t[e+8]=this.h[4]>>>0&255,t[e+9]=this.h[4]>>>8&255,t[e+10]=this.h[5]>>>0&255,t[e+11]=this.h[5]>>>8&255,t[e+12]=this.h[6]>>>0&255,t[e+13]=this.h[6]>>>8&255,t[e+14]=this.h[7]>>>0&255,t[e+15]=this.h[7]>>>8&255},T.prototype.update=function(t,e,n){var r,i;if(this.leftover){for((i=16-this.leftover)>n&&(i=n),r=0;r=16&&(i=n-n%16,this.blocks(t,e,i),e+=i,n-=i),n){for(r=0;r=128;){for(S=0;S<16;S++)k=8*S+$,O[S]=n[k+0]<<24|n[k+1]<<16|n[k+2]<<8|n[k+3],L[S]=n[k+4]<<24|n[k+5]<<16|n[k+6]<<8|n[k+7];for(S=0;S<80;S++)if(i=R,s=U,o=I,a=M,c=D,h=N,u=j,B,d=z,p=H,f=q,g=F,v=X,b=J,y=Y,K,E=65535&(T=K),P=T>>>16,x=65535&(C=B),A=C>>>16,E+=65535&(T=(X>>>14|D<<18)^(X>>>18|D<<14)^(D>>>9|X<<23)),P+=T>>>16,x+=65535&(C=(D>>>14|X<<18)^(D>>>18|X<<14)^(X>>>9|D<<23)),A+=C>>>16,E+=65535&(T=X&J^~X&Y),P+=T>>>16,x+=65535&(C=D&N^~D&j),A+=C>>>16,E+=65535&(T=W[2*S+1]),P+=T>>>16,x+=65535&(C=W[2*S]),A+=C>>>16,C=O[S%16],P+=(T=L[S%16])>>>16,x+=65535&C,A+=C>>>16,x+=(P+=(E+=65535&T)>>>16)>>>16,E=65535&(T=_=65535&E|P<<16),P=T>>>16,x=65535&(C=w=65535&x|(A+=x>>>16)<<16),A=C>>>16,E+=65535&(T=(z>>>28|R<<4)^(R>>>2|z<<30)^(R>>>7|z<<25)),P+=T>>>16,x+=65535&(C=(R>>>28|z<<4)^(z>>>2|R<<30)^(z>>>7|R<<25)),A+=C>>>16,P+=(T=z&H^z&q^H&q)>>>16,x+=65535&(C=R&U^R&I^U&I),A+=C>>>16,l=65535&(x+=(P+=(E+=65535&T)>>>16)>>>16)|(A+=x>>>16)<<16,m=65535&E|P<<16,E=65535&(T=g),P=T>>>16,x=65535&(C=a),A=C>>>16,P+=(T=_)>>>16,x+=65535&(C=w),A+=C>>>16,U=i,I=s,M=o,D=a=65535&(x+=(P+=(E+=65535&T)>>>16)>>>16)|(A+=x>>>16)<<16,N=c,j=h,B=u,R=l,H=d,q=p,F=f,X=g=65535&E|P<<16,J=v,Y=b,K=y,z=m,S%16==15)for(k=0;k<16;k++)C=O[k],E=65535&(T=L[k]),P=T>>>16,x=65535&C,A=C>>>16,C=O[(k+9)%16],E+=65535&(T=L[(k+9)%16]),P+=T>>>16,x+=65535&C,A+=C>>>16,w=O[(k+1)%16],E+=65535&(T=((_=L[(k+1)%16])>>>1|w<<31)^(_>>>8|w<<24)^(_>>>7|w<<25)),P+=T>>>16,x+=65535&(C=(w>>>1|_<<31)^(w>>>8|_<<24)^w>>>7),A+=C>>>16,w=O[(k+14)%16],P+=(T=((_=L[(k+14)%16])>>>19|w<<13)^(w>>>29|_<<3)^(_>>>6|w<<26))>>>16,x+=65535&(C=(w>>>19|_<<13)^(_>>>29|w<<3)^w>>>6),A+=C>>>16,A+=(x+=(P+=(E+=65535&T)>>>16)>>>16)>>>16,O[k]=65535&x|A<<16,L[k]=65535&E|P<<16;E=65535&(T=z),P=T>>>16,x=65535&(C=R),A=C>>>16,C=t[0],P+=(T=e[0])>>>16,x+=65535&C,A+=C>>>16,A+=(x+=(P+=(E+=65535&T)>>>16)>>>16)>>>16,t[0]=R=65535&x|A<<16,e[0]=z=65535&E|P<<16,E=65535&(T=H),P=T>>>16,x=65535&(C=U),A=C>>>16,C=t[1],P+=(T=e[1])>>>16,x+=65535&C,A+=C>>>16,A+=(x+=(P+=(E+=65535&T)>>>16)>>>16)>>>16,t[1]=U=65535&x|A<<16,e[1]=H=65535&E|P<<16,E=65535&(T=q),P=T>>>16,x=65535&(C=I),A=C>>>16,C=t[2],P+=(T=e[2])>>>16,x+=65535&C,A+=C>>>16,A+=(x+=(P+=(E+=65535&T)>>>16)>>>16)>>>16,t[2]=I=65535&x|A<<16,e[2]=q=65535&E|P<<16,E=65535&(T=F),P=T>>>16,x=65535&(C=M),A=C>>>16,C=t[3],P+=(T=e[3])>>>16,x+=65535&C,A+=C>>>16,A+=(x+=(P+=(E+=65535&T)>>>16)>>>16)>>>16,t[3]=M=65535&x|A<<16,e[3]=F=65535&E|P<<16,E=65535&(T=X),P=T>>>16,x=65535&(C=D),A=C>>>16,C=t[4],P+=(T=e[4])>>>16,x+=65535&C,A+=C>>>16,A+=(x+=(P+=(E+=65535&T)>>>16)>>>16)>>>16,t[4]=D=65535&x|A<<16,e[4]=X=65535&E|P<<16,E=65535&(T=J),P=T>>>16,x=65535&(C=N),A=C>>>16,C=t[5],P+=(T=e[5])>>>16,x+=65535&C,A+=C>>>16,A+=(x+=(P+=(E+=65535&T)>>>16)>>>16)>>>16,t[5]=N=65535&x|A<<16,e[5]=J=65535&E|P<<16,E=65535&(T=Y),P=T>>>16,x=65535&(C=j),A=C>>>16,C=t[6],P+=(T=e[6])>>>16,x+=65535&C,A+=C>>>16,A+=(x+=(P+=(E+=65535&T)>>>16)>>>16)>>>16,t[6]=j=65535&x|A<<16,e[6]=Y=65535&E|P<<16,E=65535&(T=K),P=T>>>16,x=65535&(C=B),A=C>>>16,C=t[7],P+=(T=e[7])>>>16,x+=65535&C,A+=C>>>16,A+=(x+=(P+=(E+=65535&T)>>>16)>>>16)>>>16,t[7]=B=65535&x|A<<16,e[7]=K=65535&E|P<<16,$+=128,r-=128}return r}function V(t,e,n){var r,i=new Int32Array(8),s=new Int32Array(8),o=new Uint8Array(256),a=n;for(i[0]=1779033703,i[1]=3144134277,i[2]=1013904242,i[3]=2773480762,i[4]=1359893119,i[5]=2600822924,i[6]=528734635,i[7]=1541459225,s[0]=4089235720,s[1]=2227873595,s[2]=4271175723,s[3]=1595750129,s[4]=2917565137,s[5]=725511199,s[6]=4215389547,s[7]=327033209,G(i,s,e,n),n%=128,r=0;r=0;--i)Q(t,e,r=n[i/8|0]>>(7&i)&1),Z(e,t),Z(t,t),Q(t,e,r)}function nt(t,n){var r=[e(),e(),e(),e()];O(r[0],l),O(r[1],d),O(r[2],a),B(r[3],l,d),et(t,r,n)}function rt(t,n,i){var s,o=new Uint8Array(64),a=[e(),e(),e(),e()];for(i||r(n,32),V(o,n,32),o[0]&=248,o[31]&=127,o[31]|=64,nt(a,o),tt(t,a),s=0;s<32;s++)n[s+32]=t[s];return 0}var it=new Float64Array([237,211,245,92,26,99,18,88,214,156,247,162,222,249,222,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16]);function st(t,e){var n,r,i,s;for(r=63;r>=32;--r){for(n=0,i=r-32,s=r-12;i>4)*it[i],n=e[i]>>8,e[i]&=255;for(i=0;i<32;i++)e[i]-=n*it[i];for(r=0;r<32;r++)e[r+1]+=e[r]>>8,t[r]=255&e[r]}function ot(t){var e,n=new Float64Array(64);for(e=0;e<64;e++)n[e]=t[e];for(e=0;e<64;e++)t[e]=0;st(t,n)}function at(t,n,r,i){var s,o,a=new Uint8Array(64),c=new Uint8Array(64),h=new Uint8Array(64),u=new Float64Array(64),l=[e(),e(),e(),e()];V(a,i,32),a[0]&=248,a[31]&=127,a[31]|=64;var d=r+64;for(s=0;s>7&&j(t[0],o,t[0]),B(t[3],t[0],t[1]),0)}(d,i))return-1;for(s=0;s=0},t.sign.keyPair=function(){var t=new Uint8Array(32),e=new Uint8Array(64);return rt(t,e),{publicKey:t,secretKey:e}},t.sign.keyPair.fromSecretKey=function(t){if(ut(t),64!==t.length)throw new Error("bad secret key size");for(var e=new Uint8Array(32),n=0;n0)r.loading[t].push(n);else{r.loading[t]=[n];var i=ue.createScriptRequest(r.getPath(t,e)),s=r.receivers.create((function(e){if(r.receivers.remove(s),r.loading[t]){var n=r.loading[t];delete r.loading[t];for(var o=function(t){t||i.cleanup()},a=0;a>>6)+_(128|63&e):_(224|e>>>12&15)+_(128|e>>>6&63)+_(128|63&e)},P=function(t){return t.replace(/[^\x00-\x7F]/g,E)},x=function(t){var e=[0,2,1][t.length%3],n=t.charCodeAt(0)<<16|(t.length>1?t.charCodeAt(1):0)<<8|(t.length>2?t.charCodeAt(2):0);return[S.charAt(n>>>18),S.charAt(n>>>12&63),e>=2?"=":S.charAt(n>>>6&63),e>=1?"=":S.charAt(63&n)].join("")},A=window.btoa||function(t){return t.replace(/[\s\S]{1,3}/g,x)};var O=class{constructor(t,e,n,r){this.clear=e,this.timer=t(()=>{this.timer&&(this.timer=r(this.timer))},n)}isRunning(){return null!==this.timer}ensureAborted(){this.timer&&(this.clear(this.timer),this.timer=null)}};function L(t){window.clearTimeout(t)}function R(t){window.clearInterval(t)}class U extends O{constructor(t,e){super(setTimeout,L,t,(function(t){return e(),null}))}}class I extends O{constructor(t,e){super(setInterval,R,t,(function(t){return e(),t}))}}var M={now:()=>Date.now?Date.now():(new Date).valueOf(),defer:t=>new U(0,t),method(t,...e){var n=Array.prototype.slice.call(arguments,1);return function(e){return e[t].apply(e,n.concat(arguments))}}};function D(t,...e){for(var n=0;n{window.console&&window.console.log&&window.console.log(t)}}debug(...t){this.log(this.globalLog,t)}warn(...t){this.log(this.globalLogWarn,t)}error(...t){this.log(this.globalLogError,t)}globalLogWarn(t){window.console&&window.console.warn?window.console.warn(t):this.globalLog(t)}globalLogError(t){window.console&&window.console.error?window.console.error(t):this.globalLogWarn(t)}log(t,...e){var n=N.apply(this,arguments);if(Re.log)Re.log(n);else if(Re.logToConsole){t.bind(this)(n)}}},G=function(t,e,n,r,i){void 0===n.headers&&null==n.headersProvider||W.warn(`To send headers with the ${r.toString()} request, you must use AJAX, rather than JSONP.`);var s=t.nextAuthCallbackID.toString();t.nextAuthCallbackID++;var o=t.getDocument(),a=o.createElement("script");t.auth_callbacks[s]=function(t){i(null,t)};var c="Pusher.auth_callbacks['"+s+"']";a.src=n.endpoint+"?callback="+encodeURIComponent(c)+"&"+e;var h=o.getElementsByTagName("head")[0]||o.documentElement;h.insertBefore(a,h.firstChild)};class V{constructor(t){this.src=t}send(t){var e=this,n="Error loading "+e.src;e.script=document.createElement("script"),e.script.id=t.id,e.script.src=e.src,e.script.type="text/javascript",e.script.charset="UTF-8",e.script.addEventListener?(e.script.onerror=function(){t.callback(n)},e.script.onload=function(){t.callback(null)}):e.script.onreadystatechange=function(){"loaded"!==e.script.readyState&&"complete"!==e.script.readyState||t.callback(null)},void 0===e.script.async&&document.attachEvent&&/opera/i.test(navigator.userAgent)?(e.errorScript=document.createElement("script"),e.errorScript.id=t.id+"_error",e.errorScript.text=t.name+"('"+n+"');",e.script.async=e.errorScript.async=!1):e.script.async=!0;var r=document.getElementsByTagName("head")[0];r.insertBefore(e.script,r.firstChild),e.errorScript&&r.insertBefore(e.errorScript,e.script.nextSibling)}cleanup(){this.script&&(this.script.onload=this.script.onerror=null,this.script.onreadystatechange=null),this.script&&this.script.parentNode&&this.script.parentNode.removeChild(this.script),this.errorScript&&this.errorScript.parentNode&&this.errorScript.parentNode.removeChild(this.errorScript),this.script=null,this.errorScript=null}}class Z{constructor(t,e){this.url=t,this.data=e}send(t){if(!this.request){var e=K(this.data),n=this.url+"/"+t.number+"?"+e;this.request=ue.createScriptRequest(n),this.request.send(t)}}cleanup(){this.request&&this.request.cleanup()}}var Q={name:"jsonp",getAgent:function(t,e){return function(n,r){var s="http"+(e?"s":"")+"://"+(t.host||t.options.host)+t.options.path,o=ue.createJSONPRequest(s,n),a=ue.ScriptReceivers.create((function(e,n){i.remove(a),o.cleanup(),n&&n.host&&(t.host=n.host),r&&r(e,n)}));o.send(a)}}};function tt(t,e,n){return t+(e.useTLS?"s":"")+"://"+(e.useTLS?e.hostTLS:e.hostNonTLS)+n}function et(t,e){return"/app/"+t+("?protocol="+s.PROTOCOL+"&client=js&version="+s.VERSION+(e?"&"+e:""))}var nt={getInitial:function(t,e){return tt("ws",e,(e.httpPath||"")+et(t,"flash=false"))}},rt={getInitial:function(t,e){return tt("http",e,(e.httpPath||"/pusher")+et(t))}},it={getInitial:function(t,e){return tt("http",e,e.httpPath||"/pusher")},getPath:function(t,e){return et(t)}};class st{constructor(){this._callbacks={}}get(t){return this._callbacks[ot(t)]}add(t,e,n){var r=ot(t);this._callbacks[r]=this._callbacks[r]||[],this._callbacks[r].push({fn:e,context:n})}remove(t,e,n){if(t||e||n){var r=t?[ot(t)]:z(this._callbacks);e||n?this.removeCallback(r,e,n):this.removeAllCallbacks(r)}else this._callbacks={}}removeCallback(t,e,n){H(t,(function(t){this._callbacks[t]=F(this._callbacks[t]||[],(function(t){return e&&e!==t.fn||n&&n!==t.context})),0===this._callbacks[t].length&&delete this._callbacks[t]}),this)}removeAllCallbacks(t){H(t,(function(t){delete this._callbacks[t]}),this)}}function ot(t){return"_"+t}class at{constructor(t){this.callbacks=new st,this.global_callbacks=[],this.failThrough=t}bind(t,e,n){return this.callbacks.add(t,e,n),this}bind_global(t){return this.global_callbacks.push(t),this}unbind(t,e,n){return this.callbacks.remove(t,e,n),this}unbind_global(t){return t?(this.global_callbacks=F(this.global_callbacks||[],e=>e!==t),this):(this.global_callbacks=[],this)}unbind_all(){return this.unbind(),this.unbind_global(),this}emit(t,e,n){for(var r=0;r0)for(r=0;r{this.onError(t),this.changeState("closed")}),!1}return this.bindListeners(),W.debug("Connecting",{transport:this.name,url:t}),this.changeState("connecting"),!0}close(){return!!this.socket&&(this.socket.close(),!0)}send(t){return"open"===this.state&&(M.defer(()=>{this.socket&&this.socket.send(t)}),!0)}ping(){"open"===this.state&&this.supportsPing()&&this.socket.ping()}onOpen(){this.hooks.beforeOpen&&this.hooks.beforeOpen(this.socket,this.hooks.urls.getPath(this.key,this.options)),this.changeState("open"),this.socket.onopen=void 0}onError(t){this.emit("error",{type:"WebSocketError",error:t}),this.timeline.error(this.buildTimelineMessage({error:t.toString()}))}onClose(t){t?this.changeState("closed",{code:t.code,reason:t.reason,wasClean:t.wasClean}):this.changeState("closed"),this.unbindListeners(),this.socket=void 0}onMessage(t){this.emit("message",t)}onActivity(){this.emit("activity")}bindListeners(){this.socket.onopen=()=>{this.onOpen()},this.socket.onerror=t=>{this.onError(t)},this.socket.onclose=t=>{this.onClose(t)},this.socket.onmessage=t=>{this.onMessage(t)},this.supportsPing()&&(this.socket.onactivity=()=>{this.onActivity()})}unbindListeners(){this.socket&&(this.socket.onopen=void 0,this.socket.onerror=void 0,this.socket.onclose=void 0,this.socket.onmessage=void 0,this.supportsPing()&&(this.socket.onactivity=void 0))}changeState(t,e){this.state=t,this.timeline.info(this.buildTimelineMessage({state:t,params:e})),this.emit(t,e)}buildTimelineMessage(t){return D({cid:this.id},t)}}class ht{constructor(t){this.hooks=t}isSupported(t){return this.hooks.isSupported(t)}createConnection(t,e,n,r){return new ct(this.hooks,t,e,n,r)}}var ut=new ht({urls:nt,handlesActivityChecks:!1,supportsPing:!1,isInitialized:function(){return Boolean(ue.getWebSocketAPI())},isSupported:function(){return Boolean(ue.getWebSocketAPI())},getSocket:function(t){return ue.createWebSocket(t)}}),lt={urls:rt,handlesActivityChecks:!1,supportsPing:!0,isInitialized:function(){return!0}},dt=D({getSocket:function(t){return ue.HTTPFactory.createStreamingSocket(t)}},lt),pt=D({getSocket:function(t){return ue.HTTPFactory.createPollingSocket(t)}},lt),ft={isSupported:function(){return ue.isXHRSupported()}},gt={ws:ut,xhr_streaming:new ht(D({},dt,ft)),xhr_polling:new ht(D({},pt,ft))},vt=new ht({file:"sockjs",urls:it,handlesActivityChecks:!0,supportsPing:!1,isSupported:function(){return!0},isInitialized:function(){return void 0!==window.SockJS},getSocket:function(t,e){return new window.SockJS(t,null,{js_path:a.getPath("sockjs",{useTLS:e.useTLS}),ignore_null_origin:e.ignoreNullOrigin})},beforeOpen:function(t,e){t.send(JSON.stringify({path:e}))}}),bt={isSupported:function(t){return ue.isXDRSupported(t.useTLS)}},yt=new ht(D({},dt,bt)),mt=new ht(D({},pt,bt));gt.xdr_streaming=yt,gt.xdr_polling=mt,gt.sockjs=vt;var wt=gt;var _t=new class extends at{constructor(){super();var t=this;void 0!==window.addEventListener&&(window.addEventListener("online",(function(){t.emit("online")}),!1),window.addEventListener("offline",(function(){t.emit("offline")}),!1))}isOnline(){return void 0===window.navigator.onLine||window.navigator.onLine}};class St{constructor(t,e,n){this.manager=t,this.transport=e,this.minPingDelay=n.minPingDelay,this.maxPingDelay=n.maxPingDelay,this.pingDelay=void 0}createConnection(t,e,n,r){r=D({},r,{activityTimeout:this.pingDelay});var i=this.transport.createConnection(t,e,n,r),s=null,o=function(){i.unbind("open",o),i.bind("closed",a),s=M.now()},a=t=>{if(i.unbind("closed",a),1002===t.code||1003===t.code)this.manager.reportDeath();else if(!t.wasClean&&s){var e=M.now()-s;e<2*this.maxPingDelay&&(this.manager.reportDeath(),this.pingDelay=Math.max(e/2,this.minPingDelay))}};return i.bind("open",o),i}isSupported(t){return this.manager.isAlive()&&this.transport.isSupported(t)}}const kt={decodeMessage:function(t){try{var e=JSON.parse(t.data),n=e.data;if("string"==typeof n)try{n=JSON.parse(e.data)}catch(t){}var r={event:e.event,channel:e.channel,data:n};return e.user_id&&(r.user_id=e.user_id),r}catch(e){throw{type:"MessageParseError",error:e,data:t.data}}},encodeMessage:function(t){return JSON.stringify(t)},processHandshake:function(t){var e=kt.decodeMessage(t);if("pusher:connection_established"===e.event){if(!e.data.activity_timeout)throw"No activity timeout specified in handshake";return{action:"connected",id:e.data.socket_id,activityTimeout:1e3*e.data.activity_timeout}}if("pusher:error"===e.event)return{action:this.getCloseAction(e.data),error:this.getCloseError(e.data)};throw"Invalid handshake"},getCloseAction:function(t){return t.code<4e3?t.code>=1002&&t.code<=1004?"backoff":null:4e3===t.code?"tls_only":t.code<4100?"refused":t.code<4200?"backoff":t.code<4300?"retry":"refused"},getCloseError:function(t){return 1e3!==t.code&&1001!==t.code?{type:"PusherError",data:{code:t.code,message:t.reason||t.message}}:null}};var Ct=kt;class Tt extends at{constructor(t,e){super(),this.id=t,this.transport=e,this.activityTimeout=e.activityTimeout,this.bindListeners()}handlesActivityChecks(){return this.transport.handlesActivityChecks()}send(t){return this.transport.send(t)}send_event(t,e,n){var r={event:t,data:e};return n&&(r.channel=n),W.debug("Event sent",r),this.send(Ct.encodeMessage(r))}ping(){this.transport.supportsPing()?this.transport.ping():this.send_event("pusher:ping",{})}close(){this.transport.close()}bindListeners(){var t={message:t=>{var e;try{e=Ct.decodeMessage(t)}catch(e){this.emit("error",{type:"MessageParseError",error:e,data:t.data})}if(void 0!==e){switch(W.debug("Event recd",e),e.event){case"pusher:error":this.emit("error",{type:"PusherError",data:e.data});break;case"pusher:ping":this.emit("ping");break;case"pusher:pong":this.emit("pong")}this.emit("message",e)}},activity:()=>{this.emit("activity")},error:t=>{this.emit("error",t)},closed:t=>{e(),t&&t.code&&this.handleCloseEvent(t),this.transport=null,this.emit("closed")}},e=()=>{B(t,(t,e)=>{this.transport.unbind(e,t)})};B(t,(t,e)=>{this.transport.bind(e,t)})}handleCloseEvent(t){var e=Ct.getCloseAction(t),n=Ct.getCloseError(t);n&&this.emit("error",n),e&&this.emit(e,{action:e,error:n})}}class Et{constructor(t,e){this.transport=t,this.callback=e,this.bindListeners()}close(){this.unbindListeners(),this.transport.close()}bindListeners(){this.onMessage=t=>{var e;this.unbindListeners();try{e=Ct.processHandshake(t)}catch(t){return this.finish("error",{error:t}),void this.transport.close()}"connected"===e.action?this.finish("connected",{connection:new Tt(e.id,this.transport),activityTimeout:e.activityTimeout}):(this.finish(e.action,{error:e.error}),this.transport.close())},this.onClosed=t=>{this.unbindListeners();var e=Ct.getCloseAction(t)||"backoff",n=Ct.getCloseError(t);this.finish(e,{error:n})},this.transport.bind("message",this.onMessage),this.transport.bind("closed",this.onClosed)}unbindListeners(){this.transport.unbind("message",this.onMessage),this.transport.unbind("closed",this.onClosed)}finish(t,e){this.callback(D({transport:this.transport,action:t},e))}}class Pt{constructor(t,e){this.timeline=t,this.options=e||{}}send(t,e){this.timeline.isEmpty()||this.timeline.send(ue.TimelineTransport.getAgent(this,t),e)}}class xt extends at{constructor(t,e){super((function(e,n){W.debug("No callbacks on "+t+" for "+e)})),this.name=t,this.pusher=e,this.subscribed=!1,this.subscriptionPending=!1,this.subscriptionCancelled=!1}authorize(t,e){return e(null,{auth:""})}trigger(t,e){if(0!==t.indexOf("client-"))throw new l("Event '"+t+"' does not start with 'client-'");if(!this.subscribed){var n=u("triggeringClientEvents");W.warn("Client event triggered before channel 'subscription_succeeded' event . "+n)}return this.pusher.send_event(t,e,this.name)}disconnect(){this.subscribed=!1,this.subscriptionPending=!1}handleEvent(t){var e=t.event,n=t.data;if("pusher_internal:subscription_succeeded"===e)this.handleSubscriptionSucceededEvent(t);else if("pusher_internal:subscription_count"===e)this.handleSubscriptionCountEvent(t);else if(0!==e.indexOf("pusher_internal:")){this.emit(e,n,{})}}handleSubscriptionSucceededEvent(t){this.subscriptionPending=!1,this.subscribed=!0,this.subscriptionCancelled?this.pusher.unsubscribe(this.name):this.emit("pusher:subscription_succeeded",t.data)}handleSubscriptionCountEvent(t){t.data.subscription_count&&(this.subscriptionCount=t.data.subscription_count),this.emit("pusher:subscription_count",t.data)}subscribe(){this.subscribed||(this.subscriptionPending=!0,this.subscriptionCancelled=!1,this.authorize(this.pusher.connection.socket_id,(t,e)=>{t?(this.subscriptionPending=!1,W.error(t.toString()),this.emit("pusher:subscription_error",Object.assign({},{type:"AuthError",error:t.message},t instanceof m?{status:t.status}:{}))):this.pusher.send_event("pusher:subscribe",{auth:e.auth,channel_data:e.channel_data,channel:this.name})}))}unsubscribe(){this.subscribed=!1,this.pusher.send_event("pusher:unsubscribe",{channel:this.name})}cancelSubscription(){this.subscriptionCancelled=!0}reinstateSubscription(){this.subscriptionCancelled=!1}}class At extends xt{authorize(t,e){return this.pusher.config.channelAuthorizer({channelName:this.name,socketId:t},e)}}class Ot{constructor(){this.reset()}get(t){return Object.prototype.hasOwnProperty.call(this.members,t)?{id:t,info:this.members[t]}:null}each(t){B(this.members,(e,n)=>{t(this.get(n))})}setMyID(t){this.myID=t}onSubscription(t){this.members=t.presence.hash,this.count=t.presence.count,this.me=this.get(this.myID)}addMember(t){return null===this.get(t.user_id)&&this.count++,this.members[t.user_id]=t.user_info,this.get(t.user_id)}removeMember(t){var e=this.get(t.user_id);return e&&(delete this.members[t.user_id],this.count--),e}reset(){this.members={},this.count=0,this.myID=null,this.me=null}}var Lt=function(t,e,n,r){return new(n||(n=Promise))((function(i,s){function o(t){try{c(r.next(t))}catch(t){s(t)}}function a(t){try{c(r.throw(t))}catch(t){s(t)}}function c(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(o,a)}c((r=r.apply(t,e||[])).next())}))};class Rt extends At{constructor(t,e){super(t,e),this.members=new Ot}authorize(t,e){super.authorize(t,(t,n)=>Lt(this,void 0,void 0,(function*(){if(!t)if(null!=(n=n).channel_data){var r=JSON.parse(n.channel_data);this.members.setMyID(r.user_id)}else{if(yield this.pusher.user.signinDonePromise,null==this.pusher.user.user_data){let t=u("authorizationEndpoint");return W.error(`Invalid auth response for channel '${this.name}', expected 'channel_data' field. ${t}, or the user should be signed in.`),void e("Invalid auth response")}this.members.setMyID(this.pusher.user.user_data.id)}e(t,n)})))}handleEvent(t){var e=t.event;if(0===e.indexOf("pusher_internal:"))this.handleInternalEvent(t);else{var n=t.data,r={};t.user_id&&(r.user_id=t.user_id),this.emit(e,n,r)}}handleInternalEvent(t){var e=t.event,n=t.data;switch(e){case"pusher_internal:subscription_succeeded":this.handleSubscriptionSucceededEvent(t);break;case"pusher_internal:subscription_count":this.handleSubscriptionCountEvent(t);break;case"pusher_internal:member_added":var r=this.members.addMember(n);this.emit("pusher:member_added",r);break;case"pusher_internal:member_removed":var i=this.members.removeMember(n);i&&this.emit("pusher:member_removed",i)}}handleSubscriptionSucceededEvent(t){this.subscriptionPending=!1,this.subscribed=!0,this.subscriptionCancelled?this.pusher.unsubscribe(this.name):(this.members.onSubscription(t.data),this.emit("pusher:subscription_succeeded",this.members))}disconnect(){this.members.reset(),super.disconnect()}}var Ut=n(1),It=n(0);class Mt extends At{constructor(t,e,n){super(t,e),this.key=null,this.nacl=n}authorize(t,e){super.authorize(t,(t,n)=>{if(t)return void e(t,n);let r=n.shared_secret;r?(this.key=Object(It.decode)(r),delete n.shared_secret,e(null,n)):e(new Error("No shared_secret key in auth payload for encrypted channel: "+this.name),null)})}trigger(t,e){throw new v("Client events are not currently supported for encrypted channels")}handleEvent(t){var e=t.event,n=t.data;0!==e.indexOf("pusher_internal:")&&0!==e.indexOf("pusher:")?this.handleEncryptedEvent(e,n):super.handleEvent(t)}handleEncryptedEvent(t,e){if(!this.key)return void W.debug("Received encrypted event before key has been retrieved from the authEndpoint");if(!e.ciphertext||!e.nonce)return void W.error("Unexpected format for encrypted event, expected object with `ciphertext` and `nonce` fields, got: "+e);let n=Object(It.decode)(e.ciphertext);if(n.length{e?W.error(`Failed to make a request to the authEndpoint: ${s}. Unable to fetch new key, so dropping encrypted event`):(i=this.nacl.secretbox.open(n,r,this.key),null!==i?this.emit(t,this.getDataToEmit(i)):W.error("Failed to decrypt event with new key. Dropping encrypted event"))});this.emit(t,this.getDataToEmit(i))}getDataToEmit(t){let e=Object(Ut.decode)(t);try{return JSON.parse(e)}catch(t){return e}}}class Dt extends at{constructor(t,e){super(),this.state="initialized",this.connection=null,this.key=t,this.options=e,this.timeline=this.options.timeline,this.usingTLS=this.options.useTLS,this.errorCallbacks=this.buildErrorCallbacks(),this.connectionCallbacks=this.buildConnectionCallbacks(this.errorCallbacks),this.handshakeCallbacks=this.buildHandshakeCallbacks(this.errorCallbacks);var n=ue.getNetwork();n.bind("online",()=>{this.timeline.info({netinfo:"online"}),"connecting"!==this.state&&"unavailable"!==this.state||this.retryIn(0)}),n.bind("offline",()=>{this.timeline.info({netinfo:"offline"}),this.connection&&this.sendActivityCheck()}),this.updateStrategy()}switchCluster(t){this.key=t,this.updateStrategy(),this.retryIn(0)}connect(){this.connection||this.runner||(this.strategy.isSupported()?(this.updateState("connecting"),this.startConnecting(),this.setUnavailableTimer()):this.updateState("failed"))}send(t){return!!this.connection&&this.connection.send(t)}send_event(t,e,n){return!!this.connection&&this.connection.send_event(t,e,n)}disconnect(){this.disconnectInternally(),this.updateState("disconnected")}isUsingTLS(){return this.usingTLS}startConnecting(){var t=(e,n)=>{e?this.runner=this.strategy.connect(0,t):"error"===n.action?(this.emit("error",{type:"HandshakeError",error:n.error}),this.timeline.error({handshakeError:n.error})):(this.abortConnecting(),this.handshakeCallbacks[n.action](n))};this.runner=this.strategy.connect(0,t)}abortConnecting(){this.runner&&(this.runner.abort(),this.runner=null)}disconnectInternally(){(this.abortConnecting(),this.clearRetryTimer(),this.clearUnavailableTimer(),this.connection)&&this.abandonConnection().close()}updateStrategy(){this.strategy=this.options.getStrategy({key:this.key,timeline:this.timeline,useTLS:this.usingTLS})}retryIn(t){this.timeline.info({action:"retry",delay:t}),t>0&&this.emit("connecting_in",Math.round(t/1e3)),this.retryTimer=new U(t||0,()=>{this.disconnectInternally(),this.connect()})}clearRetryTimer(){this.retryTimer&&(this.retryTimer.ensureAborted(),this.retryTimer=null)}setUnavailableTimer(){this.unavailableTimer=new U(this.options.unavailableTimeout,()=>{this.updateState("unavailable")})}clearUnavailableTimer(){this.unavailableTimer&&this.unavailableTimer.ensureAborted()}sendActivityCheck(){this.stopActivityCheck(),this.connection.ping(),this.activityTimer=new U(this.options.pongTimeout,()=>{this.timeline.error({pong_timed_out:this.options.pongTimeout}),this.retryIn(0)})}resetActivityCheck(){this.stopActivityCheck(),this.connection&&!this.connection.handlesActivityChecks()&&(this.activityTimer=new U(this.activityTimeout,()=>{this.sendActivityCheck()}))}stopActivityCheck(){this.activityTimer&&this.activityTimer.ensureAborted()}buildConnectionCallbacks(t){return D({},t,{message:t=>{this.resetActivityCheck(),this.emit("message",t)},ping:()=>{this.send_event("pusher:pong",{})},activity:()=>{this.resetActivityCheck()},error:t=>{this.emit("error",t)},closed:()=>{this.abandonConnection(),this.shouldRetry()&&this.retryIn(1e3)}})}buildHandshakeCallbacks(t){return D({},t,{connected:t=>{this.activityTimeout=Math.min(this.options.activityTimeout,t.activityTimeout,t.connection.activityTimeout||1/0),this.clearUnavailableTimer(),this.setConnection(t.connection),this.socket_id=this.connection.id,this.updateState("connected",{socket_id:this.socket_id})}})}buildErrorCallbacks(){let t=t=>e=>{e.error&&this.emit("error",{type:"WebSocketError",error:e.error}),t(e)};return{tls_only:t(()=>{this.usingTLS=!0,this.updateStrategy(),this.retryIn(0)}),refused:t(()=>{this.disconnect()}),backoff:t(()=>{this.retryIn(1e3)}),retry:t(()=>{this.retryIn(0)})}}setConnection(t){for(var e in this.connection=t,this.connectionCallbacks)this.connection.bind(e,this.connectionCallbacks[e]);this.resetActivityCheck()}abandonConnection(){if(this.connection){for(var t in this.stopActivityCheck(),this.connectionCallbacks)this.connection.unbind(t,this.connectionCallbacks[t]);var e=this.connection;return this.connection=null,e}}updateState(t,e){var n=this.state;if(this.state=t,n!==t){var r=t;"connected"===r&&(r+=" with new socket ID "+e.socket_id),W.debug("State changed",n+" -> "+r),this.timeline.info({state:t,params:e}),this.emit("state_change",{previous:n,current:t}),this.emit(t,e)}}shouldRetry(){return"connecting"===this.state||"connected"===this.state}}class Nt{constructor(){this.channels={}}add(t,e){return this.channels[t]||(this.channels[t]=function(t,e){if(0===t.indexOf("private-encrypted-")){if(e.config.nacl)return jt.createEncryptedChannel(t,e,e.config.nacl);let n="Tried to subscribe to a private-encrypted- channel but no nacl implementation available",r=u("encryptedChannelSupport");throw new v(`${n}. ${r}`)}if(0===t.indexOf("private-"))return jt.createPrivateChannel(t,e);if(0===t.indexOf("presence-"))return jt.createPresenceChannel(t,e);if(0===t.indexOf("#"))throw new d('Cannot create a channel with name "'+t+'".');return jt.createChannel(t,e)}(t,e)),this.channels[t]}all(){return function(t){var e=[];return B(t,(function(t){e.push(t)})),e}(this.channels)}find(t){return this.channels[t]}remove(t){var e=this.channels[t];return delete this.channels[t],e}disconnect(){B(this.channels,(function(t){t.disconnect()}))}}var jt={createChannels:()=>new Nt,createConnectionManager:(t,e)=>new Dt(t,e),createChannel:(t,e)=>new xt(t,e),createPrivateChannel:(t,e)=>new At(t,e),createPresenceChannel:(t,e)=>new Rt(t,e),createEncryptedChannel:(t,e,n)=>new Mt(t,e,n),createTimelineSender:(t,e)=>new Pt(t,e),createHandshake:(t,e)=>new Et(t,e),createAssistantToTheTransportManager:(t,e,n)=>new St(t,e,n)};class Bt{constructor(t){this.options=t||{},this.livesLeft=this.options.lives||1/0}getAssistant(t){return jt.createAssistantToTheTransportManager(this,t,{minPingDelay:this.options.minPingDelay,maxPingDelay:this.options.maxPingDelay})}isAlive(){return this.livesLeft>0}reportDeath(){this.livesLeft-=1}}class zt{constructor(t,e){this.strategies=t,this.loop=Boolean(e.loop),this.failFast=Boolean(e.failFast),this.timeout=e.timeout,this.timeoutLimit=e.timeoutLimit}isSupported(){return J(this.strategies,M.method("isSupported"))}connect(t,e){var n=this.strategies,r=0,i=this.timeout,s=null,o=(a,c)=>{c?e(null,c):(r+=1,this.loop&&(r%=n.length),r0&&(i=new U(n.timeout,(function(){s.abort(),r(!0)}))),s=t.connect(e,(function(t,e){t&&i&&i.isRunning()&&!n.failFast||(i&&i.ensureAborted(),r(t,e))})),{abort:function(){i&&i.ensureAborted(),s.abort()},forceMinPriority:function(t){s.forceMinPriority(t)}}}}class Ht{constructor(t){this.strategies=t}isSupported(){return J(this.strategies,M.method("isSupported"))}connect(t,e){return function(t,e,n){var r=q(t,(function(t,r,i,s){return t.connect(e,n(r,s))}));return{abort:function(){H(r,qt)},forceMinPriority:function(t){H(r,(function(e){e.forceMinPriority(t)}))}}}(this.strategies,t,(function(t,n){return function(r,i){n[t].error=r,r?function(t){return function(t,e){for(var n=0;n=M.now()){var o=this.transports[r.transport];o&&(["ws","wss"].includes(r.transport)||i>3?(this.timeline.info({cached:!0,transport:r.transport,latency:r.latency}),s.push(new zt([o],{timeout:2*r.latency+1e3,failFast:!0}))):i++)}var a=M.now(),c=s.pop().connect(t,(function r(o,h){o?(Jt(n),s.length>0?(a=M.now(),c=s.pop().connect(t,r)):e(o)):(!function(t,e,n,r){var i=ue.getLocalStorage();if(i)try{i[Xt(t)]=$({timestamp:M.now(),transport:e,latency:n,cacheSkipCount:r})}catch(t){}}(n,h.transport.name,M.now()-a,i),e(null,h))}));return{abort:function(){c.abort()},forceMinPriority:function(e){t=e,c&&c.forceMinPriority(e)}}}}function Xt(t){return"pusherTransport"+(t?"TLS":"NonTLS")}function Jt(t){var e=ue.getLocalStorage();if(e)try{delete e[Xt(t)]}catch(t){}}class Yt{constructor(t,{delay:e}){this.strategy=t,this.options={delay:e}}isSupported(){return this.strategy.isSupported()}connect(t,e){var n,r=this.strategy,i=new U(this.options.delay,(function(){n=r.connect(t,e)}));return{abort:function(){i.ensureAborted(),n&&n.abort()},forceMinPriority:function(e){t=e,n&&n.forceMinPriority(e)}}}}class Kt{constructor(t,e,n){this.test=t,this.trueBranch=e,this.falseBranch=n}isSupported(){return(this.test()?this.trueBranch:this.falseBranch).isSupported()}connect(t,e){return(this.test()?this.trueBranch:this.falseBranch).connect(t,e)}}class $t{constructor(t){this.strategy=t}isSupported(){return this.strategy.isSupported()}connect(t,e){var n=this.strategy.connect(t,(function(t,r){r&&n.abort(),e(t,r)}));return n}}function Wt(t){return function(){return t.isSupported()}}var Gt=function(t,e,n){var r={};function i(e,i,s,o,a){var c=n(t,e,i,s,o,a);return r[e]=c,c}var s,o=Object.assign({},e,{hostNonTLS:t.wsHost+":"+t.wsPort,hostTLS:t.wsHost+":"+t.wssPort,httpPath:t.wsPath}),a=Object.assign({},o,{useTLS:!0}),c=Object.assign({},e,{hostNonTLS:t.httpHost+":"+t.httpPort,hostTLS:t.httpHost+":"+t.httpsPort,httpPath:t.httpPath}),h={loop:!0,timeout:15e3,timeoutLimit:6e4},u=new Bt({minPingDelay:1e4,maxPingDelay:t.activityTimeout}),l=new Bt({lives:2,minPingDelay:1e4,maxPingDelay:t.activityTimeout}),d=i("ws","ws",3,o,u),p=i("wss","ws",3,a,u),f=i("sockjs","sockjs",1,c),g=i("xhr_streaming","xhr_streaming",1,c,l),v=i("xdr_streaming","xdr_streaming",1,c,l),b=i("xhr_polling","xhr_polling",1,c),y=i("xdr_polling","xdr_polling",1,c),m=new zt([d],h),w=new zt([p],h),_=new zt([f],h),S=new zt([new Kt(Wt(g),g,v)],h),k=new zt([new Kt(Wt(b),b,y)],h),C=new zt([new Kt(Wt(S),new Ht([S,new Yt(k,{delay:4e3})]),k)],h),T=new Kt(Wt(C),C,_);return s=e.useTLS?new Ht([m,new Yt(T,{delay:2e3})]):new Ht([m,new Yt(w,{delay:2e3}),new Yt(T,{delay:5e3})]),new Ft(new $t(new Kt(Wt(d),s,T)),r,{ttl:18e5,timeline:e.timeline,useTLS:e.useTLS})},Vt={getRequest:function(t){var e=new window.XDomainRequest;return e.ontimeout=function(){t.emit("error",new p),t.close()},e.onerror=function(e){t.emit("error",e),t.close()},e.onprogress=function(){e.responseText&&e.responseText.length>0&&t.onChunk(200,e.responseText)},e.onload=function(){e.responseText&&e.responseText.length>0&&t.onChunk(200,e.responseText),t.emit("finished",200),t.close()},e},abortRequest:function(t){t.ontimeout=t.onerror=t.onprogress=t.onload=null,t.abort()}};class Zt extends at{constructor(t,e,n){super(),this.hooks=t,this.method=e,this.url=n}start(t){this.position=0,this.xhr=this.hooks.getRequest(this),this.unloader=()=>{this.close()},ue.addUnloadListener(this.unloader),this.xhr.open(this.method,this.url,!0),this.xhr.setRequestHeader&&this.xhr.setRequestHeader("Content-Type","application/json"),this.xhr.send(t)}close(){this.unloader&&(ue.removeUnloadListener(this.unloader),this.unloader=null),this.xhr&&(this.hooks.abortRequest(this.xhr),this.xhr=null)}onChunk(t,e){for(;;){var n=this.advanceBuffer(e);if(!n)break;this.emit("chunk",{status:t,data:n})}this.isBufferTooLong(e)&&this.emit("buffer_too_long")}advanceBuffer(t){var e=t.slice(this.position),n=e.indexOf("\n");return-1!==n?(this.position+=n+1,e.slice(0,n)):null}isBufferTooLong(t){return this.position===t.length&&t.length>262144}}var Qt;!function(t){t[t.CONNECTING=0]="CONNECTING",t[t.OPEN=1]="OPEN",t[t.CLOSED=3]="CLOSED"}(Qt||(Qt={}));var te=Qt,ee=1;function ne(t){var e=-1===t.indexOf("?")?"?":"&";return t+e+"t="+ +new Date+"&n="+ee++}function re(t){return ue.randomInt(t)}var ie,se=class{constructor(t,e){this.hooks=t,this.session=re(1e3)+"/"+function(t){for(var e=[],n=0;n{this.onChunk(t)}),this.stream.bind("finished",t=>{this.hooks.onFinished(this,t)}),this.stream.bind("buffer_too_long",()=>{this.reconnect()});try{this.stream.start()}catch(t){M.defer(()=>{this.onError(t),this.onClose(1006,"Could not start streaming",!1)})}}closeStream(){this.stream&&(this.stream.unbind_all(),this.stream.close(),this.stream=null)}},oe={getReceiveURL:function(t,e){return t.base+"/"+e+"/xhr_streaming"+t.queryString},onHeartbeat:function(t){t.sendRaw("[]")},sendHeartbeat:function(t){t.sendRaw("[]")},onFinished:function(t,e){t.onClose(1006,"Connection interrupted ("+e+")",!1)}},ae={getReceiveURL:function(t,e){return t.base+"/"+e+"/xhr"+t.queryString},onHeartbeat:function(){},sendHeartbeat:function(t){t.sendRaw("[]")},onFinished:function(t,e){200===e?t.reconnect():t.onClose(1006,"Connection interrupted ("+e+")",!1)}},ce={getRequest:function(t){var e=new(ue.getXHRAPI());return e.onreadystatechange=e.onprogress=function(){switch(e.readyState){case 3:e.responseText&&e.responseText.length>0&&t.onChunk(e.status,e.responseText);break;case 4:e.responseText&&e.responseText.length>0&&t.onChunk(e.status,e.responseText),t.emit("finished",e.status),t.close()}},e},abortRequest:function(t){t.onreadystatechange=null,t.abort()}},he={createStreamingSocket(t){return this.createSocket(oe,t)},createPollingSocket(t){return this.createSocket(ae,t)},createSocket:(t,e)=>new se(t,e),createXHR(t,e){return this.createRequest(ce,t,e)},createRequest:(t,e,n)=>new Zt(t,e,n),createXDR:function(t,e){return this.createRequest(Vt,t,e)}},ue={nextAuthCallbackID:1,auth_callbacks:{},ScriptReceivers:i,DependenciesReceivers:o,getDefaultStrategy:Gt,Transports:wt,transportConnectionInitializer:function(){var t=this;t.timeline.info(t.buildTimelineMessage({transport:t.name+(t.options.useTLS?"s":"")})),t.hooks.isInitialized()?t.changeState("initialized"):t.hooks.file?(t.changeState("initializing"),a.load(t.hooks.file,{useTLS:t.options.useTLS},(function(e,n){t.hooks.isInitialized()?(t.changeState("initialized"),n(!0)):(e&&t.onError(e),t.onClose(),n(!1))}))):t.onClose()},HTTPFactory:he,TimelineTransport:Q,getXHRAPI:()=>window.XMLHttpRequest,getWebSocketAPI:()=>window.WebSocket||window.MozWebSocket,setup(t){window.Pusher=t;var e=()=>{this.onDocumentBody(t.ready)};window.JSON?e():a.load("json2",{},e)},getDocument:()=>document,getProtocol(){return this.getDocument().location.protocol},getAuthorizers:()=>({ajax:w,jsonp:G}),onDocumentBody(t){document.body?t():setTimeout(()=>{this.onDocumentBody(t)},0)},createJSONPRequest:(t,e)=>new Z(t,e),createScriptRequest:t=>new V(t),getLocalStorage(){try{return window.localStorage}catch(t){return}},createXHR(){return this.getXHRAPI()?this.createXMLHttpRequest():this.createMicrosoftXHR()},createXMLHttpRequest(){return new(this.getXHRAPI())},createMicrosoftXHR:()=>new ActiveXObject("Microsoft.XMLHTTP"),getNetwork:()=>_t,createWebSocket(t){return new(this.getWebSocketAPI())(t)},createSocketRequest(t,e){if(this.isXHRSupported())return this.HTTPFactory.createXHR(t,e);if(this.isXDRSupported(0===e.indexOf("https:")))return this.HTTPFactory.createXDR(t,e);throw"Cross-origin HTTP requests are not supported"},isXHRSupported(){var t=this.getXHRAPI();return Boolean(t)&&void 0!==(new t).withCredentials},isXDRSupported(t){var e=t?"https:":"http:",n=this.getProtocol();return Boolean(window.XDomainRequest)&&n===e},addUnloadListener(t){void 0!==window.addEventListener?window.addEventListener("unload",t,!1):void 0!==window.attachEvent&&window.attachEvent("onunload",t)},removeUnloadListener(t){void 0!==window.addEventListener?window.removeEventListener("unload",t,!1):void 0!==window.detachEvent&&window.detachEvent("onunload",t)},randomInt:t=>Math.floor((window.crypto||window.msCrypto).getRandomValues(new Uint32Array(1))[0]/Math.pow(2,32)*t)};!function(t){t[t.ERROR=3]="ERROR",t[t.INFO=6]="INFO",t[t.DEBUG=7]="DEBUG"}(ie||(ie={}));var le=ie;class de{constructor(t,e,n){this.key=t,this.session=e,this.events=[],this.options=n||{},this.sent=0,this.uniqueID=0}log(t,e){t<=this.options.level&&(this.events.push(D({},e,{timestamp:M.now()})),this.options.limit&&this.events.length>this.options.limit&&this.events.shift())}error(t){this.log(le.ERROR,t)}info(t){this.log(le.INFO,t)}debug(t){this.log(le.DEBUG,t)}isEmpty(){return 0===this.events.length}send(t,e){var n=D({session:this.session,bundle:this.sent+1,key:this.key,lib:"js",version:this.options.version,cluster:this.options.cluster,features:this.options.features,timeline:this.events},this.options.params);return this.events=[],t(n,(t,n)=>{t||this.sent++,e&&e(t,n)}),!0}generateUniqueID(){return this.uniqueID++,this.uniqueID}}class pe{constructor(t,e,n,r){this.name=t,this.priority=e,this.transport=n,this.options=r||{}}isSupported(){return this.transport.isSupported({useTLS:this.options.useTLS})}connect(t,e){if(!this.isSupported())return fe(new y,e);if(this.priority{n||(h(),i?i.close():r.close())},forceMinPriority:t=>{n||this.priority{if(void 0===ue.getAuthorizers()[t.transport])throw`'${t.transport}' is not a recognized auth transport`;return(e,n)=>{const r=((t,e)=>{var n="socket_id="+encodeURIComponent(t.socketId);for(var r in e.params)n+="&"+encodeURIComponent(r)+"="+encodeURIComponent(e.params[r]);if(null!=e.paramsProvider){let t=e.paramsProvider();for(var r in t)n+="&"+encodeURIComponent(r)+"="+encodeURIComponent(t[r])}return n})(e,t);ue.getAuthorizers()[t.transport](ue,r,t,h.UserAuthentication,n)}};var we=t=>{if(void 0===ue.getAuthorizers()[t.transport])throw`'${t.transport}' is not a recognized auth transport`;return(e,n)=>{const r=((t,e)=>{var n="socket_id="+encodeURIComponent(t.socketId);for(var r in n+="&channel_name="+encodeURIComponent(t.channelName),e.params)n+="&"+encodeURIComponent(r)+"="+encodeURIComponent(e.params[r]);if(null!=e.paramsProvider){let t=e.paramsProvider();for(var r in t)n+="&"+encodeURIComponent(r)+"="+encodeURIComponent(t[r])}return n})(e,t);ue.getAuthorizers()[t.transport](ue,r,t,h.ChannelAuthorization,n)}};function _e(t,e){let n={activityTimeout:t.activityTimeout||s.activityTimeout,cluster:t.cluster,httpPath:t.httpPath||s.httpPath,httpPort:t.httpPort||s.httpPort,httpsPort:t.httpsPort||s.httpsPort,pongTimeout:t.pongTimeout||s.pongTimeout,statsHost:t.statsHost||s.stats_host,unavailableTimeout:t.unavailableTimeout||s.unavailableTimeout,wsPath:t.wsPath||s.wsPath,wsPort:t.wsPort||s.wsPort,wssPort:t.wssPort||s.wssPort,enableStats:Te(t),httpHost:Se(t),useTLS:Ce(t),wsHost:ke(t),userAuthenticator:Ee(t),channelAuthorizer:Pe(t,e)};return"disabledTransports"in t&&(n.disabledTransports=t.disabledTransports),"enabledTransports"in t&&(n.enabledTransports=t.enabledTransports),"ignoreNullOrigin"in t&&(n.ignoreNullOrigin=t.ignoreNullOrigin),"timelineParams"in t&&(n.timelineParams=t.timelineParams),"nacl"in t&&(n.nacl=t.nacl),n}function Se(t){return t.httpHost?t.httpHost:t.cluster?`sockjs-${t.cluster}.pusher.com`:s.httpHost}function ke(t){return t.wsHost?t.wsHost:`ws-${t.cluster}.pusher.com`}function Ce(t){return"https:"===ue.getProtocol()||!1!==t.forceTLS}function Te(t){return"enableStats"in t?t.enableStats:"disableStats"in t&&!t.disableStats}function Ee(t){const e=Object.assign(Object.assign({},s.userAuthentication),t.userAuthentication);return"customHandler"in e&&null!=e.customHandler?e.customHandler:me(e)}function Pe(t,e){const n=function(t,e){let n;return"channelAuthorization"in t?n=Object.assign(Object.assign({},s.channelAuthorization),t.channelAuthorization):(n={transport:t.authTransport||s.authTransport,endpoint:t.authEndpoint||s.authEndpoint},"auth"in t&&("params"in t.auth&&(n.params=t.auth.params),"headers"in t.auth&&(n.headers=t.auth.headers)),"authorizer"in t&&(n.customHandler=((t,e,n)=>{const r={authTransport:e.transport,authEndpoint:e.endpoint,auth:{params:e.params,headers:e.headers}};return(e,i)=>{const s=t.channel(e.channelName);n(s,r).authorize(e.socketId,i)}})(e,n,t.authorizer))),n}(t,e);return"customHandler"in n&&null!=n.customHandler?n.customHandler:we(n)}class xe extends at{constructor(t){super((function(t,e){W.debug("No callbacks on watchlist events for "+t)})),this.pusher=t,this.bindWatchlistInternalEvent()}handleEvent(t){t.data.events.forEach(t=>{this.emit(t.name,t)})}bindWatchlistInternalEvent(){this.pusher.connection.bind("message",t=>{"pusher_internal:watchlist_events"===t.event&&this.handleEvent(t)})}}var Ae=function(){let t,e;return{promise:new Promise((n,r)=>{t=n,e=r}),resolve:t,reject:e}};class Oe extends at{constructor(t){super((function(t,e){W.debug("No callbacks on user for "+t)})),this.signin_requested=!1,this.user_data=null,this.serverToUserChannel=null,this.signinDonePromise=null,this._signinDoneResolve=null,this._onAuthorize=(t,e)=>{if(t)return W.warn("Error during signin: "+t),void this._cleanup();this.pusher.send_event("pusher:signin",{auth:e.auth,user_data:e.user_data})},this.pusher=t,this.pusher.connection.bind("state_change",({previous:t,current:e})=>{"connected"!==t&&"connected"===e&&this._signin(),"connected"===t&&"connected"!==e&&(this._cleanup(),this._newSigninPromiseIfNeeded())}),this.watchlist=new xe(t),this.pusher.connection.bind("message",t=>{"pusher:signin_success"===t.event&&this._onSigninSuccess(t.data),this.serverToUserChannel&&this.serverToUserChannel.name===t.channel&&this.serverToUserChannel.handleEvent(t)})}signin(){this.signin_requested||(this.signin_requested=!0,this._signin())}_signin(){this.signin_requested&&(this._newSigninPromiseIfNeeded(),"connected"===this.pusher.connection.state&&this.pusher.config.userAuthenticator({socketId:this.pusher.connection.socket_id},this._onAuthorize))}_onSigninSuccess(t){try{this.user_data=JSON.parse(t.user_data)}catch(e){return W.error("Failed parsing user data after signin: "+t.user_data),void this._cleanup()}if("string"!=typeof this.user_data.id||""===this.user_data.id)return W.error("user_data doesn't contain an id. user_data: "+this.user_data),void this._cleanup();this._signinDoneResolve(),this._subscribeChannels()}_subscribeChannels(){this.serverToUserChannel=new xt("#server-to-user-"+this.user_data.id,this.pusher),this.serverToUserChannel.bind_global((t,e)=>{0!==t.indexOf("pusher_internal:")&&0!==t.indexOf("pusher:")&&this.emit(t,e)}),(t=>{t.subscriptionPending&&t.subscriptionCancelled?t.reinstateSubscription():t.subscriptionPending||"connected"!==this.pusher.connection.state||t.subscribe()})(this.serverToUserChannel)}_cleanup(){this.user_data=null,this.serverToUserChannel&&(this.serverToUserChannel.unbind_all(),this.serverToUserChannel.disconnect(),this.serverToUserChannel=null),this.signin_requested&&this._signinDoneResolve()}_newSigninPromiseIfNeeded(){if(!this.signin_requested)return;if(this.signinDonePromise&&!this.signinDonePromise.done)return;const{promise:t,resolve:e,reject:n}=Ae();t.done=!1;const r=()=>{t.done=!0};t.then(r).catch(r),this.signinDonePromise=t,this._signinDoneResolve=e}}class Le{static ready(){Le.isReady=!0;for(var t=0,e=Le.instances.length;tue.getDefaultStrategy(this.config,t,ve),timeline:this.timeline,activityTimeout:this.config.activityTimeout,pongTimeout:this.config.pongTimeout,unavailableTimeout:this.config.unavailableTimeout,useTLS:Boolean(this.config.useTLS)}),this.connection.bind("connected",()=>{this.subscribeAll(),this.timelineSender&&this.timelineSender.send(this.connection.isUsingTLS())}),this.connection.bind("message",t=>{var e=0===t.event.indexOf("pusher_internal:");if(t.channel){var n=this.channel(t.channel);n&&n.handleEvent(t)}e||this.global_emitter.emit(t.event,t.data)}),this.connection.bind("connecting",()=>{this.channels.disconnect()}),this.connection.bind("disconnected",()=>{this.channels.disconnect()}),this.connection.bind("error",t=>{W.warn(t)}),Le.instances.push(this),this.timeline.info({instances:Le.instances.length}),this.user=new Oe(this),Le.isReady&&this.connect()}switchCluster(t){const{appKey:e,cluster:n}=t;this.key=e,this.options=Object.assign(Object.assign({},this.options),{cluster:n}),this.config=_e(this.options,this),this.connection.switchCluster(this.key)}channel(t){return this.channels.find(t)}allChannels(){return this.channels.all()}connect(){if(this.connection.connect(),this.timelineSender&&!this.timelineSenderTimer){var t=this.connection.isUsingTLS(),e=this.timelineSender;this.timelineSenderTimer=new I(6e4,(function(){e.send(t)}))}}disconnect(){this.connection.disconnect(),this.timelineSenderTimer&&(this.timelineSenderTimer.ensureAborted(),this.timelineSenderTimer=null)}bind(t,e,n){return this.global_emitter.bind(t,e,n),this}unbind(t,e,n){return this.global_emitter.unbind(t,e,n),this}bind_global(t){return this.global_emitter.bind_global(t),this}unbind_global(t){return this.global_emitter.unbind_global(t),this}unbind_all(t){return this.global_emitter.unbind_all(),this}subscribeAll(){var t;for(t in this.channels.channels)this.channels.channels.hasOwnProperty(t)&&this.subscribe(t)}subscribe(t){var e=this.channels.add(t,this);return e.subscriptionPending&&e.subscriptionCancelled?e.reinstateSubscription():e.subscriptionPending||"connected"!==this.connection.state||e.subscribe(),e}unsubscribe(t){var e=this.channels.find(t);e&&e.subscriptionPending?e.cancelSubscription():(e=this.channels.remove(t))&&e.subscribed&&e.unsubscribe()}send_event(t,e,n){return this.connection.send_event(t,e,n)}shouldUseTLS(){return this.config.useTLS}signin(){this.user.signin()}}Le.instances=[],Le.isReady=!1,Le.logToConsole=!1,Le.Runtime=ue,Le.ScriptReceivers=ue.ScriptReceivers,Le.DependenciesReceivers=ue.DependenciesReceivers,Le.auth_callbacks=ue.auth_callbacks;var Re=Le;ue.setup(Le);var Ue=n(2);class Ie extends Re{constructor(t,e){Re.logToConsole=Ie.logToConsole,Re.log=Ie.log,ye(e),e.nacl=Ue,super(t,e)}}}])})); +!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.Pusher=e():t.Pusher=e()}(window,(function(){return function(t){var e={};function n(r){if(e[r])return e[r].exports;var i=e[r]={i:r,l:!1,exports:{}};return t[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)n.d(r,i,function(e){return t[e]}.bind(null,i));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=3)}([function(t,e,n){"use strict";var r,i=this&&this.__extends||(r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)},function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)});Object.defineProperty(e,"__esModule",{value:!0});var s=function(){function t(t){void 0===t&&(t="="),this._paddingCharacter=t}return t.prototype.encodedLength=function(t){return this._paddingCharacter?(t+2)/3*4|0:(8*t+5)/6|0},t.prototype.encode=function(t){for(var e="",n=0;n>>18&63),e+=this._encodeByte(r>>>12&63),e+=this._encodeByte(r>>>6&63),e+=this._encodeByte(r>>>0&63)}var i=t.length-n;if(i>0){r=t[n]<<16|(2===i?t[n+1]<<8:0);e+=this._encodeByte(r>>>18&63),e+=this._encodeByte(r>>>12&63),e+=2===i?this._encodeByte(r>>>6&63):this._paddingCharacter||"",e+=this._paddingCharacter||""}return e},t.prototype.maxDecodedLength=function(t){return this._paddingCharacter?t/4*3|0:(6*t+7)/8|0},t.prototype.decodedLength=function(t){return this.maxDecodedLength(t.length-this._getPaddingLength(t))},t.prototype.decode=function(t){if(0===t.length)return new Uint8Array(0);for(var e=this._getPaddingLength(t),n=t.length-e,r=new Uint8Array(this.maxDecodedLength(n)),i=0,s=0,o=0,a=0,c=0,h=0,u=0;s>>4,r[i++]=c<<4|h>>>2,r[i++]=h<<6|u,o|=256&a,o|=256&c,o|=256&h,o|=256&u;if(s>>4,o|=256&a,o|=256&c),s>>2,o|=256&h),s>>8&6,e+=51-t>>>8&-75,e+=61-t>>>8&-15,e+=62-t>>>8&3,String.fromCharCode(e)},t.prototype._decodeChar=function(t){var e=256;return e+=(42-t&t-44)>>>8&-256+t-43+62,e+=(46-t&t-48)>>>8&-256+t-47+63,e+=(47-t&t-58)>>>8&-256+t-48+52,e+=(64-t&t-91)>>>8&-256+t-65+0,e+=(96-t&t-123)>>>8&-256+t-97+26},t.prototype._getPaddingLength=function(t){var e=0;if(this._paddingCharacter){for(var n=t.length-1;n>=0&&t[n]===this._paddingCharacter;n--)e++;if(t.length<4||e>2)throw new Error("Base64Coder: incorrect padding")}return e},t}();e.Coder=s;var o=new s;e.encode=function(t){return o.encode(t)},e.decode=function(t){return o.decode(t)};var a=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return i(e,t),e.prototype._encodeByte=function(t){var e=t;return e+=65,e+=25-t>>>8&6,e+=51-t>>>8&-75,e+=61-t>>>8&-13,e+=62-t>>>8&49,String.fromCharCode(e)},e.prototype._decodeChar=function(t){var e=256;return e+=(44-t&t-46)>>>8&-256+t-45+62,e+=(94-t&t-96)>>>8&-256+t-95+63,e+=(47-t&t-58)>>>8&-256+t-48+52,e+=(64-t&t-91)>>>8&-256+t-65+0,e+=(96-t&t-123)>>>8&-256+t-97+26},e}(s);e.URLSafeCoder=a;var c=new a;e.encodeURLSafe=function(t){return c.encode(t)},e.decodeURLSafe=function(t){return c.decode(t)},e.encodedLength=function(t){return o.encodedLength(t)},e.maxDecodedLength=function(t){return o.maxDecodedLength(t)},e.decodedLength=function(t){return o.decodedLength(t)}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r="utf8: invalid source encoding";function i(t){for(var e=0,n=0;n=t.length-1)throw new Error("utf8: invalid string");n++,e+=4}}return e}e.encode=function(t){for(var e=new Uint8Array(i(t)),n=0,r=0;r>6,e[n++]=128|63&s):s<55296?(e[n++]=224|s>>12,e[n++]=128|s>>6&63,e[n++]=128|63&s):(r++,s=(1023&s)<<10,s|=1023&t.charCodeAt(r),s+=65536,e[n++]=240|s>>18,e[n++]=128|s>>12&63,e[n++]=128|s>>6&63,e[n++]=128|63&s)}return e},e.encodedLength=i,e.decode=function(t){for(var e=[],n=0;n=t.length)throw new Error(r);if(128!=(192&(o=t[++n])))throw new Error(r);i=(31&i)<<6|63&o,s=128}else if(i<240){if(n>=t.length-1)throw new Error(r);var o=t[++n],a=t[++n];if(128!=(192&o)||128!=(192&a))throw new Error(r);i=(15&i)<<12|(63&o)<<6|63&a,s=2048}else{if(!(i<248))throw new Error(r);if(n>=t.length-2)throw new Error(r);o=t[++n],a=t[++n];var c=t[++n];if(128!=(192&o)||128!=(192&a)||128!=(192&c))throw new Error(r);i=(15&i)<<18|(63&o)<<12|(63&a)<<6|63&c,s=65536}if(i=55296&&i<=57343)throw new Error(r);if(i>=65536){if(i>1114111)throw new Error(r);i-=65536,e.push(String.fromCharCode(55296|i>>10)),i=56320|1023&i}}e.push(String.fromCharCode(i))}return e.join("")}},function(t,e,n){!function(t){"use strict";var e=function(t){var e,n=new Float64Array(16);if(t)for(e=0;e>24&255,t[e+1]=n>>16&255,t[e+2]=n>>8&255,t[e+3]=255&n,t[e+4]=r>>24&255,t[e+5]=r>>16&255,t[e+6]=r>>8&255,t[e+7]=255&r}function g(t,e,n,r,i){var s,o=0;for(s=0;s>>8)-1}function v(t,e,n,r){return g(t,e,n,r,16)}function b(t,e,n,r){return g(t,e,n,r,32)}function y(t,e,n,r){!function(t,e,n,r){for(var i,s=255&r[0]|(255&r[1])<<8|(255&r[2])<<16|(255&r[3])<<24,o=255&n[0]|(255&n[1])<<8|(255&n[2])<<16|(255&n[3])<<24,a=255&n[4]|(255&n[5])<<8|(255&n[6])<<16|(255&n[7])<<24,c=255&n[8]|(255&n[9])<<8|(255&n[10])<<16|(255&n[11])<<24,h=255&n[12]|(255&n[13])<<8|(255&n[14])<<16|(255&n[15])<<24,u=255&r[4]|(255&r[5])<<8|(255&r[6])<<16|(255&r[7])<<24,l=255&e[0]|(255&e[1])<<8|(255&e[2])<<16|(255&e[3])<<24,d=255&e[4]|(255&e[5])<<8|(255&e[6])<<16|(255&e[7])<<24,p=255&e[8]|(255&e[9])<<8|(255&e[10])<<16|(255&e[11])<<24,f=255&e[12]|(255&e[13])<<8|(255&e[14])<<16|(255&e[15])<<24,g=255&r[8]|(255&r[9])<<8|(255&r[10])<<16|(255&r[11])<<24,v=255&n[16]|(255&n[17])<<8|(255&n[18])<<16|(255&n[19])<<24,b=255&n[20]|(255&n[21])<<8|(255&n[22])<<16|(255&n[23])<<24,y=255&n[24]|(255&n[25])<<8|(255&n[26])<<16|(255&n[27])<<24,m=255&n[28]|(255&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=_>>>24&255,t[4]=S>>>0&255,t[5]=S>>>8&255,t[6]=S>>>16&255,t[7]=S>>>24&255,t[8]=k>>>0&255,t[9]=k>>>8&255,t[10]=k>>>16&255,t[11]=k>>>24&255,t[12]=C>>>0&255,t[13]=C>>>8&255,t[14]=C>>>16&255,t[15]=C>>>24&255,t[16]=T>>>0&255,t[17]=T>>>8&255,t[18]=T>>>16&255,t[19]=T>>>24&255,t[20]=E>>>0&255,t[21]=E>>>8&255,t[22]=E>>>16&255,t[23]=E>>>24&255,t[24]=P>>>0&255,t[25]=P>>>8&255,t[26]=P>>>16&255,t[27]=P>>>24&255,t[28]=x>>>0&255,t[29]=x>>>8&255,t[30]=x>>>16&255,t[31]=x>>>24&255,t[32]=A>>>0&255,t[33]=A>>>8&255,t[34]=A>>>16&255,t[35]=A>>>24&255,t[36]=O>>>0&255,t[37]=O>>>8&255,t[38]=O>>>16&255,t[39]=O>>>24&255,t[40]=L>>>0&255,t[41]=L>>>8&255,t[42]=L>>>16&255,t[43]=L>>>24&255,t[44]=R>>>0&255,t[45]=R>>>8&255,t[46]=R>>>16&255,t[47]=R>>>24&255,t[48]=U>>>0&255,t[49]=U>>>8&255,t[50]=U>>>16&255,t[51]=U>>>24&255,t[52]=I>>>0&255,t[53]=I>>>8&255,t[54]=I>>>16&255,t[55]=I>>>24&255,t[56]=M>>>0&255,t[57]=M>>>8&255,t[58]=M>>>16&255,t[59]=M>>>24&255,t[60]=D>>>0&255,t[61]=D>>>8&255,t[62]=D>>>16&255,t[63]=D>>>24&255}(t,e,n,r)}function m(t,e,n,r){!function(t,e,n,r){for(var i,s=255&r[0]|(255&r[1])<<8|(255&r[2])<<16|(255&r[3])<<24,o=255&n[0]|(255&n[1])<<8|(255&n[2])<<16|(255&n[3])<<24,a=255&n[4]|(255&n[5])<<8|(255&n[6])<<16|(255&n[7])<<24,c=255&n[8]|(255&n[9])<<8|(255&n[10])<<16|(255&n[11])<<24,h=255&n[12]|(255&n[13])<<8|(255&n[14])<<16|(255&n[15])<<24,u=255&r[4]|(255&r[5])<<8|(255&r[6])<<16|(255&r[7])<<24,l=255&e[0]|(255&e[1])<<8|(255&e[2])<<16|(255&e[3])<<24,d=255&e[4]|(255&e[5])<<8|(255&e[6])<<16|(255&e[7])<<24,p=255&e[8]|(255&e[9])<<8|(255&e[10])<<16|(255&e[11])<<24,f=255&e[12]|(255&e[13])<<8|(255&e[14])<<16|(255&e[15])<<24,g=255&r[8]|(255&r[9])<<8|(255&r[10])<<16|(255&r[11])<<24,v=255&n[16]|(255&n[17])<<8|(255&n[18])<<16|(255&n[19])<<24,b=255&n[20]|(255&n[21])<<8|(255&n[22])<<16|(255&n[23])<<24,y=255&n[24]|(255&n[25])<<8|(255&n[26])<<16|(255&n[27])<<24,m=255&n[28]|(255&n[29])<<8|(255&n[30])<<16|(255&n[31])<<24,w=255&r[12]|(255&r[13])<<8|(255&r[14])<<16|(255&r[15])<<24,_=0;_<20;_+=2)s^=(i=(b^=(i=(p^=(i=(h^=(i=s+b|0)<<7|i>>>25)+s|0)<<9|i>>>23)+h|0)<<13|i>>>19)+p|0)<<18|i>>>14,u^=(i=(o^=(i=(y^=(i=(f^=(i=u+o|0)<<7|i>>>25)+u|0)<<9|i>>>23)+f|0)<<13|i>>>19)+y|0)<<18|i>>>14,g^=(i=(l^=(i=(a^=(i=(m^=(i=g+l|0)<<7|i>>>25)+g|0)<<9|i>>>23)+m|0)<<13|i>>>19)+a|0)<<18|i>>>14,w^=(i=(v^=(i=(d^=(i=(c^=(i=w+v|0)<<7|i>>>25)+w|0)<<9|i>>>23)+c|0)<<13|i>>>19)+d|0)<<18|i>>>14,s^=(i=(c^=(i=(a^=(i=(o^=(i=s+c|0)<<7|i>>>25)+s|0)<<9|i>>>23)+o|0)<<13|i>>>19)+a|0)<<18|i>>>14,u^=(i=(h^=(i=(d^=(i=(l^=(i=u+h|0)<<7|i>>>25)+u|0)<<9|i>>>23)+l|0)<<13|i>>>19)+d|0)<<18|i>>>14,g^=(i=(f^=(i=(p^=(i=(v^=(i=g+f|0)<<7|i>>>25)+g|0)<<9|i>>>23)+v|0)<<13|i>>>19)+p|0)<<18|i>>>14,w^=(i=(m^=(i=(y^=(i=(b^=(i=w+m|0)<<7|i>>>25)+w|0)<<9|i>>>23)+b|0)<<13|i>>>19)+y|0)<<18|i>>>14;t[0]=s>>>0&255,t[1]=s>>>8&255,t[2]=s>>>16&255,t[3]=s>>>24&255,t[4]=u>>>0&255,t[5]=u>>>8&255,t[6]=u>>>16&255,t[7]=u>>>24&255,t[8]=g>>>0&255,t[9]=g>>>8&255,t[10]=g>>>16&255,t[11]=g>>>24&255,t[12]=w>>>0&255,t[13]=w>>>8&255,t[14]=w>>>16&255,t[15]=w>>>24&255,t[16]=l>>>0&255,t[17]=l>>>8&255,t[18]=l>>>16&255,t[19]=l>>>24&255,t[20]=d>>>0&255,t[21]=d>>>8&255,t[22]=d>>>16&255,t[23]=d>>>24&255,t[24]=p>>>0&255,t[25]=p>>>8&255,t[26]=p>>>16&255,t[27]=p>>>24&255,t[28]=f>>>0&255,t[29]=f>>>8&255,t[30]=f>>>16&255,t[31]=f>>>24&255}(t,e,n,r)}var w=new Uint8Array([101,120,112,97,110,100,32,51,50,45,98,121,116,101,32,107]);function _(t,e,n,r,i,s,o){var a,c,h=new Uint8Array(16),u=new Uint8Array(64);for(c=0;c<16;c++)h[c]=0;for(c=0;c<8;c++)h[c]=s[c];for(;i>=64;){for(y(u,h,o,w),c=0;c<64;c++)t[e+c]=n[r+c]^u[c];for(a=1,c=8;c<16;c++)a=a+(255&h[c])|0,h[c]=255&a,a>>>=8;i-=64,e+=64,r+=64}if(i>0)for(y(u,h,o,w),c=0;c=64;){for(y(c,a,i,w),o=0;o<64;o++)t[e+o]=c[o];for(s=1,o=8;o<16;o++)s=s+(255&a[o])|0,a[o]=255&s,s>>>=8;n-=64,e+=64}if(n>0)for(y(c,a,i,w),o=0;o>>13|n<<3),r=255&t[4]|(255&t[5])<<8,this.r[2]=7939&(n>>>10|r<<6),i=255&t[6]|(255&t[7])<<8,this.r[3]=8191&(r>>>7|i<<9),s=255&t[8]|(255&t[9])<<8,this.r[4]=255&(i>>>4|s<<12),this.r[5]=s>>>1&8190,o=255&t[10]|(255&t[11])<<8,this.r[6]=8191&(s>>>14|o<<2),a=255&t[12]|(255&t[13])<<8,this.r[7]=8065&(o>>>11|a<<5),c=255&t[14]|(255&t[15])<<8,this.r[8]=8191&(a>>>8|c<<8),this.r[9]=c>>>5&127,this.pad[0]=255&t[16]|(255&t[17])<<8,this.pad[1]=255&t[18]|(255&t[19])<<8,this.pad[2]=255&t[20]|(255&t[21])<<8,this.pad[3]=255&t[22]|(255&t[23])<<8,this.pad[4]=255&t[24]|(255&t[25])<<8,this.pad[5]=255&t[26]|(255&t[27])<<8,this.pad[6]=255&t[28]|(255&t[29])<<8,this.pad[7]=255&t[30]|(255&t[31])<<8};function E(t,e,n,r,i,s){var o=new T(s);return o.update(n,r,i),o.finish(t,e),0}function P(t,e,n,r,i,s){var o=new Uint8Array(16);return E(o,0,n,r,i,s),v(t,e,o,0)}function x(t,e,n,r,i){var s;if(n<32)return-1;for(C(t,0,e,0,n,r,i),E(t,16,t,32,n-32,t),s=0;s<16;s++)t[s]=0;return 0}function A(t,e,n,r,i){var s,o=new Uint8Array(32);if(n<32)return-1;if(k(o,0,32,r,i),0!==P(e,16,e,32,n-32,o))return-1;for(C(t,0,e,0,n,r,i),s=0;s<32;s++)t[s]=0;return 0}function O(t,e){var n;for(n=0;n<16;n++)t[n]=0|e[n]}function L(t){var e,n,r=1;for(e=0;e<16;e++)n=t[e]+r+65535,r=Math.floor(n/65536),t[e]=n-65536*r;t[0]+=r-1+37*(r-1)}function R(t,e,n){for(var r,i=~(n-1),s=0;s<16;s++)r=i&(t[s]^e[s]),t[s]^=r,e[s]^=r}function U(t,n){var r,i,s,o=e(),a=e();for(r=0;r<16;r++)a[r]=n[r];for(L(a),L(a),L(a),i=0;i<2;i++){for(o[0]=a[0]-65517,r=1;r<15;r++)o[r]=a[r]-65535-(o[r-1]>>16&1),o[r-1]&=65535;o[15]=a[15]-32767-(o[14]>>16&1),s=o[15]>>16&1,o[14]&=65535,R(a,o,1-s)}for(r=0;r<16;r++)t[2*r]=255&a[r],t[2*r+1]=a[r]>>8}function I(t,e){var n=new Uint8Array(32),r=new Uint8Array(32);return U(n,t),U(r,e),b(n,0,r,0)}function M(t){var e=new Uint8Array(32);return U(e,t),1&e[0]}function D(t,e){var n;for(n=0;n<16;n++)t[n]=e[2*n]+(e[2*n+1]<<8);t[15]&=32767}function N(t,e,n){for(var r=0;r<16;r++)t[r]=e[r]+n[r]}function j(t,e,n){for(var r=0;r<16;r++)t[r]=e[r]-n[r]}function B(t,e,n){var r,i,s=0,o=0,a=0,c=0,h=0,u=0,l=0,d=0,p=0,f=0,g=0,v=0,b=0,y=0,m=0,w=0,_=0,S=0,k=0,C=0,T=0,E=0,P=0,x=0,A=0,O=0,L=0,R=0,U=0,I=0,M=0,D=n[0],N=n[1],j=n[2],B=n[3],z=n[4],H=n[5],q=n[6],F=n[7],X=n[8],J=n[9],Y=n[10],K=n[11],$=n[12],W=n[13],G=n[14],V=n[15];s+=(r=e[0])*D,o+=r*N,a+=r*j,c+=r*B,h+=r*z,u+=r*H,l+=r*q,d+=r*F,p+=r*X,f+=r*J,g+=r*Y,v+=r*K,b+=r*$,y+=r*W,m+=r*G,w+=r*V,o+=(r=e[1])*D,a+=r*N,c+=r*j,h+=r*B,u+=r*z,l+=r*H,d+=r*q,p+=r*F,f+=r*X,g+=r*J,v+=r*Y,b+=r*K,y+=r*$,m+=r*W,w+=r*G,_+=r*V,a+=(r=e[2])*D,c+=r*N,h+=r*j,u+=r*B,l+=r*z,d+=r*H,p+=r*q,f+=r*F,g+=r*X,v+=r*J,b+=r*Y,y+=r*K,m+=r*$,w+=r*W,_+=r*G,S+=r*V,c+=(r=e[3])*D,h+=r*N,u+=r*j,l+=r*B,d+=r*z,p+=r*H,f+=r*q,g+=r*F,v+=r*X,b+=r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,w+=r*B,_+=r*z,S+=r*H,k+=r*q,C+=r*F,T+=r*X,E+=r*J,P+=r*Y,x+=r*K,A+=r*$,O+=r*W,L+=r*G,R+=r*V,y+=(r=e[13])*D,m+=r*N,w+=r*j,_+=r*B,S+=r*z,k+=r*H,C+=r*q,T+=r*F,E+=r*X,P+=r*J,x+=r*Y,A+=r*K,O+=r*$,L+=r*W,R+=r*G,U+=r*V,m+=(r=e[14])*D,w+=r*N,_+=r*j,S+=r*B,k+=r*z,C+=r*H,T+=r*q,E+=r*F,P+=r*X,x+=r*J,A+=r*Y,O+=r*K,L+=r*$,R+=r*W,U+=r*G,I+=r*V,w+=(r=e[15])*D,o+=38*(S+=r*j),a+=38*(k+=r*B),c+=38*(C+=r*z),h+=38*(T+=r*H),u+=38*(E+=r*q),l+=38*(P+=r*F),d+=38*(x+=r*X),p+=38*(A+=r*J),f+=38*(O+=r*Y),g+=38*(L+=r*K),v+=38*(R+=r*$),b+=38*(U+=r*W),y+=38*(I+=r*G),m+=38*(M+=r*V),s=(r=(s+=38*(_+=r*N))+(i=1)+65535)-65536*(i=Math.floor(r/65536)),o=(r=o+i+65535)-65536*(i=Math.floor(r/65536)),a=(r=a+i+65535)-65536*(i=Math.floor(r/65536)),c=(r=c+i+65535)-65536*(i=Math.floor(r/65536)),h=(r=h+i+65535)-65536*(i=Math.floor(r/65536)),u=(r=u+i+65535)-65536*(i=Math.floor(r/65536)),l=(r=l+i+65535)-65536*(i=Math.floor(r/65536)),d=(r=d+i+65535)-65536*(i=Math.floor(r/65536)),p=(r=p+i+65535)-65536*(i=Math.floor(r/65536)),f=(r=f+i+65535)-65536*(i=Math.floor(r/65536)),g=(r=g+i+65535)-65536*(i=Math.floor(r/65536)),v=(r=v+i+65535)-65536*(i=Math.floor(r/65536)),b=(r=b+i+65535)-65536*(i=Math.floor(r/65536)),y=(r=y+i+65535)-65536*(i=Math.floor(r/65536)),m=(r=m+i+65535)-65536*(i=Math.floor(r/65536)),w=(r=w+i+65535)-65536*(i=Math.floor(r/65536)),s=(r=(s+=i-1+37*(i-1))+(i=1)+65535)-65536*(i=Math.floor(r/65536)),o=(r=o+i+65535)-65536*(i=Math.floor(r/65536)),a=(r=a+i+65535)-65536*(i=Math.floor(r/65536)),c=(r=c+i+65535)-65536*(i=Math.floor(r/65536)),h=(r=h+i+65535)-65536*(i=Math.floor(r/65536)),u=(r=u+i+65535)-65536*(i=Math.floor(r/65536)),l=(r=l+i+65535)-65536*(i=Math.floor(r/65536)),d=(r=d+i+65535)-65536*(i=Math.floor(r/65536)),p=(r=p+i+65535)-65536*(i=Math.floor(r/65536)),f=(r=f+i+65535)-65536*(i=Math.floor(r/65536)),g=(r=g+i+65535)-65536*(i=Math.floor(r/65536)),v=(r=v+i+65535)-65536*(i=Math.floor(r/65536)),b=(r=b+i+65535)-65536*(i=Math.floor(r/65536)),y=(r=y+i+65535)-65536*(i=Math.floor(r/65536)),m=(r=m+i+65535)-65536*(i=Math.floor(r/65536)),w=(r=w+i+65535)-65536*(i=Math.floor(r/65536)),s+=i-1+37*(i-1),t[0]=s,t[1]=o,t[2]=a,t[3]=c,t[4]=h,t[5]=u,t[6]=l,t[7]=d,t[8]=p,t[9]=f,t[10]=g,t[11]=v,t[12]=b,t[13]=y,t[14]=m,t[15]=w}function z(t,e){B(t,e,e)}function H(t,n){var r,i=e();for(r=0;r<16;r++)i[r]=n[r];for(r=253;r>=0;r--)z(i,i),2!==r&&4!==r&&B(i,i,n);for(r=0;r<16;r++)t[r]=i[r]}function q(t,n){var r,i=e();for(r=0;r<16;r++)i[r]=n[r];for(r=250;r>=0;r--)z(i,i),1!==r&&B(i,i,n);for(r=0;r<16;r++)t[r]=i[r]}function F(t,n,r){var i,s,o=new Uint8Array(32),a=new Float64Array(80),h=e(),u=e(),l=e(),d=e(),p=e(),f=e();for(s=0;s<31;s++)o[s]=n[s];for(o[31]=127&n[31]|64,o[0]&=248,D(a,r),s=0;s<16;s++)u[s]=a[s],d[s]=h[s]=l[s]=0;for(h[0]=d[0]=1,s=254;s>=0;--s)R(h,u,i=o[s>>>3]>>>(7&s)&1),R(l,d,i),N(p,h,l),j(h,h,l),N(l,u,d),j(u,u,d),z(d,p),z(f,h),B(h,l,h),B(l,u,p),N(p,h,l),j(h,h,l),z(u,h),j(l,d,f),B(h,l,c),N(h,h,d),B(l,l,h),B(h,d,f),B(d,u,a),z(u,p),R(h,u,i),R(l,d,i);for(s=0;s<16;s++)a[s+16]=h[s],a[s+32]=l[s],a[s+48]=u[s],a[s+64]=d[s];var g=a.subarray(32),v=a.subarray(16);return H(g,g),B(v,v,g),U(t,v),0}function X(t,e){return F(t,e,s)}function J(t,e){return r(e,32),X(t,e)}function Y(t,e,n){var r=new Uint8Array(32);return F(r,n,e),m(t,i,r,w)}T.prototype.blocks=function(t,e,n){for(var r,i,s,o,a,c,h,u,l,d,p,f,g,v,b,y,m,w,_,S=this.fin?0:2048,k=this.h[0],C=this.h[1],T=this.h[2],E=this.h[3],P=this.h[4],x=this.h[5],A=this.h[6],O=this.h[7],L=this.h[8],R=this.h[9],U=this.r[0],I=this.r[1],M=this.r[2],D=this.r[3],N=this.r[4],j=this.r[5],B=this.r[6],z=this.r[7],H=this.r[8],q=this.r[9];n>=16;)d=l=0,d+=(k+=8191&(r=255&t[e+0]|(255&t[e+1])<<8))*U,d+=(C+=8191&(r>>>13|(i=255&t[e+2]|(255&t[e+3])<<8)<<3))*(5*q),d+=(T+=8191&(i>>>10|(s=255&t[e+4]|(255&t[e+5])<<8)<<6))*(5*H),d+=(E+=8191&(s>>>7|(o=255&t[e+6]|(255&t[e+7])<<8)<<9))*(5*z),l=(d+=(P+=8191&(o>>>4|(a=255&t[e+8]|(255&t[e+9])<<8)<<12))*(5*B))>>>13,d&=8191,d+=(x+=a>>>1&8191)*(5*j),d+=(A+=8191&(a>>>14|(c=255&t[e+10]|(255&t[e+11])<<8)<<2))*(5*N),d+=(O+=8191&(c>>>11|(h=255&t[e+12]|(255&t[e+13])<<8)<<5))*(5*D),d+=(L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,_+=L*I,k=d=8191&(l=(l=((l+=(_+=R*U)>>>13)<<2)+l|0)+(d&=8191)|0),C=p+=l>>>=13,T=f&=8191,E=g&=8191,P=v&=8191,x=b&=8191,A=y&=8191,O=m&=8191,L=w&=8191,R=_&=8191,e+=16,n-=16;this.h[0]=k,this.h[1]=C,this.h[2]=T,this.h[3]=E,this.h[4]=P,this.h[5]=x,this.h[6]=A,this.h[7]=O,this.h[8]=L,this.h[9]=R},T.prototype.finish=function(t,e){var n,r,i,s,o=new Uint16Array(10);if(this.leftover){for(s=this.leftover,this.buffer[s++]=1;s<16;s++)this.buffer[s]=0;this.fin=1,this.blocks(this.buffer,0,16)}for(n=this.h[1]>>>13,this.h[1]&=8191,s=2;s<10;s++)this.h[s]+=n,n=this.h[s]>>>13,this.h[s]&=8191;for(this.h[0]+=5*n,n=this.h[0]>>>13,this.h[0]&=8191,this.h[1]+=n,n=this.h[1]>>>13,this.h[1]&=8191,this.h[2]+=n,o[0]=this.h[0]+5,n=o[0]>>>13,o[0]&=8191,s=1;s<10;s++)o[s]=this.h[s]+n,n=o[s]>>>13,o[s]&=8191;for(o[9]-=8192,r=(1^n)-1,s=0;s<10;s++)o[s]&=r;for(r=~r,s=0;s<10;s++)this.h[s]=this.h[s]&r|o[s];for(this.h[0]=65535&(this.h[0]|this.h[1]<<13),this.h[1]=65535&(this.h[1]>>>3|this.h[2]<<10),this.h[2]=65535&(this.h[2]>>>6|this.h[3]<<7),this.h[3]=65535&(this.h[3]>>>9|this.h[4]<<4),this.h[4]=65535&(this.h[4]>>>12|this.h[5]<<1|this.h[6]<<14),this.h[5]=65535&(this.h[6]>>>2|this.h[7]<<11),this.h[6]=65535&(this.h[7]>>>5|this.h[8]<<8),this.h[7]=65535&(this.h[8]>>>8|this.h[9]<<5),i=this.h[0]+this.pad[0],this.h[0]=65535&i,s=1;s<8;s++)i=(this.h[s]+this.pad[s]|0)+(i>>>16)|0,this.h[s]=65535&i;t[e+0]=this.h[0]>>>0&255,t[e+1]=this.h[0]>>>8&255,t[e+2]=this.h[1]>>>0&255,t[e+3]=this.h[1]>>>8&255,t[e+4]=this.h[2]>>>0&255,t[e+5]=this.h[2]>>>8&255,t[e+6]=this.h[3]>>>0&255,t[e+7]=this.h[3]>>>8&255,t[e+8]=this.h[4]>>>0&255,t[e+9]=this.h[4]>>>8&255,t[e+10]=this.h[5]>>>0&255,t[e+11]=this.h[5]>>>8&255,t[e+12]=this.h[6]>>>0&255,t[e+13]=this.h[6]>>>8&255,t[e+14]=this.h[7]>>>0&255,t[e+15]=this.h[7]>>>8&255},T.prototype.update=function(t,e,n){var r,i;if(this.leftover){for((i=16-this.leftover)>n&&(i=n),r=0;r=16&&(i=n-n%16,this.blocks(t,e,i),e+=i,n-=i),n){for(r=0;r=128;){for(S=0;S<16;S++)k=8*S+$,O[S]=n[k+0]<<24|n[k+1]<<16|n[k+2]<<8|n[k+3],L[S]=n[k+4]<<24|n[k+5]<<16|n[k+6]<<8|n[k+7];for(S=0;S<80;S++)if(i=R,s=U,o=I,a=M,c=D,h=N,u=j,B,d=z,p=H,f=q,g=F,v=X,b=J,y=Y,K,E=65535&(T=K),P=T>>>16,x=65535&(C=B),A=C>>>16,E+=65535&(T=(X>>>14|D<<18)^(X>>>18|D<<14)^(D>>>9|X<<23)),P+=T>>>16,x+=65535&(C=(D>>>14|X<<18)^(D>>>18|X<<14)^(X>>>9|D<<23)),A+=C>>>16,E+=65535&(T=X&J^~X&Y),P+=T>>>16,x+=65535&(C=D&N^~D&j),A+=C>>>16,E+=65535&(T=W[2*S+1]),P+=T>>>16,x+=65535&(C=W[2*S]),A+=C>>>16,C=O[S%16],P+=(T=L[S%16])>>>16,x+=65535&C,A+=C>>>16,x+=(P+=(E+=65535&T)>>>16)>>>16,E=65535&(T=_=65535&E|P<<16),P=T>>>16,x=65535&(C=w=65535&x|(A+=x>>>16)<<16),A=C>>>16,E+=65535&(T=(z>>>28|R<<4)^(R>>>2|z<<30)^(R>>>7|z<<25)),P+=T>>>16,x+=65535&(C=(R>>>28|z<<4)^(z>>>2|R<<30)^(z>>>7|R<<25)),A+=C>>>16,P+=(T=z&H^z&q^H&q)>>>16,x+=65535&(C=R&U^R&I^U&I),A+=C>>>16,l=65535&(x+=(P+=(E+=65535&T)>>>16)>>>16)|(A+=x>>>16)<<16,m=65535&E|P<<16,E=65535&(T=g),P=T>>>16,x=65535&(C=a),A=C>>>16,P+=(T=_)>>>16,x+=65535&(C=w),A+=C>>>16,U=i,I=s,M=o,D=a=65535&(x+=(P+=(E+=65535&T)>>>16)>>>16)|(A+=x>>>16)<<16,N=c,j=h,B=u,R=l,H=d,q=p,F=f,X=g=65535&E|P<<16,J=v,Y=b,K=y,z=m,S%16==15)for(k=0;k<16;k++)C=O[k],E=65535&(T=L[k]),P=T>>>16,x=65535&C,A=C>>>16,C=O[(k+9)%16],E+=65535&(T=L[(k+9)%16]),P+=T>>>16,x+=65535&C,A+=C>>>16,w=O[(k+1)%16],E+=65535&(T=((_=L[(k+1)%16])>>>1|w<<31)^(_>>>8|w<<24)^(_>>>7|w<<25)),P+=T>>>16,x+=65535&(C=(w>>>1|_<<31)^(w>>>8|_<<24)^w>>>7),A+=C>>>16,w=O[(k+14)%16],P+=(T=((_=L[(k+14)%16])>>>19|w<<13)^(w>>>29|_<<3)^(_>>>6|w<<26))>>>16,x+=65535&(C=(w>>>19|_<<13)^(_>>>29|w<<3)^w>>>6),A+=C>>>16,A+=(x+=(P+=(E+=65535&T)>>>16)>>>16)>>>16,O[k]=65535&x|A<<16,L[k]=65535&E|P<<16;E=65535&(T=z),P=T>>>16,x=65535&(C=R),A=C>>>16,C=t[0],P+=(T=e[0])>>>16,x+=65535&C,A+=C>>>16,A+=(x+=(P+=(E+=65535&T)>>>16)>>>16)>>>16,t[0]=R=65535&x|A<<16,e[0]=z=65535&E|P<<16,E=65535&(T=H),P=T>>>16,x=65535&(C=U),A=C>>>16,C=t[1],P+=(T=e[1])>>>16,x+=65535&C,A+=C>>>16,A+=(x+=(P+=(E+=65535&T)>>>16)>>>16)>>>16,t[1]=U=65535&x|A<<16,e[1]=H=65535&E|P<<16,E=65535&(T=q),P=T>>>16,x=65535&(C=I),A=C>>>16,C=t[2],P+=(T=e[2])>>>16,x+=65535&C,A+=C>>>16,A+=(x+=(P+=(E+=65535&T)>>>16)>>>16)>>>16,t[2]=I=65535&x|A<<16,e[2]=q=65535&E|P<<16,E=65535&(T=F),P=T>>>16,x=65535&(C=M),A=C>>>16,C=t[3],P+=(T=e[3])>>>16,x+=65535&C,A+=C>>>16,A+=(x+=(P+=(E+=65535&T)>>>16)>>>16)>>>16,t[3]=M=65535&x|A<<16,e[3]=F=65535&E|P<<16,E=65535&(T=X),P=T>>>16,x=65535&(C=D),A=C>>>16,C=t[4],P+=(T=e[4])>>>16,x+=65535&C,A+=C>>>16,A+=(x+=(P+=(E+=65535&T)>>>16)>>>16)>>>16,t[4]=D=65535&x|A<<16,e[4]=X=65535&E|P<<16,E=65535&(T=J),P=T>>>16,x=65535&(C=N),A=C>>>16,C=t[5],P+=(T=e[5])>>>16,x+=65535&C,A+=C>>>16,A+=(x+=(P+=(E+=65535&T)>>>16)>>>16)>>>16,t[5]=N=65535&x|A<<16,e[5]=J=65535&E|P<<16,E=65535&(T=Y),P=T>>>16,x=65535&(C=j),A=C>>>16,C=t[6],P+=(T=e[6])>>>16,x+=65535&C,A+=C>>>16,A+=(x+=(P+=(E+=65535&T)>>>16)>>>16)>>>16,t[6]=j=65535&x|A<<16,e[6]=Y=65535&E|P<<16,E=65535&(T=K),P=T>>>16,x=65535&(C=B),A=C>>>16,C=t[7],P+=(T=e[7])>>>16,x+=65535&C,A+=C>>>16,A+=(x+=(P+=(E+=65535&T)>>>16)>>>16)>>>16,t[7]=B=65535&x|A<<16,e[7]=K=65535&E|P<<16,$+=128,r-=128}return r}function V(t,e,n){var r,i=new Int32Array(8),s=new Int32Array(8),o=new Uint8Array(256),a=n;for(i[0]=1779033703,i[1]=3144134277,i[2]=1013904242,i[3]=2773480762,i[4]=1359893119,i[5]=2600822924,i[6]=528734635,i[7]=1541459225,s[0]=4089235720,s[1]=2227873595,s[2]=4271175723,s[3]=1595750129,s[4]=2917565137,s[5]=725511199,s[6]=4215389547,s[7]=327033209,G(i,s,e,n),n%=128,r=0;r=0;--i)Q(t,e,r=n[i/8|0]>>(7&i)&1),Z(e,t),Z(t,t),Q(t,e,r)}function nt(t,n){var r=[e(),e(),e(),e()];O(r[0],l),O(r[1],d),O(r[2],a),B(r[3],l,d),et(t,r,n)}function rt(t,n,i){var s,o=new Uint8Array(64),a=[e(),e(),e(),e()];for(i||r(n,32),V(o,n,32),o[0]&=248,o[31]&=127,o[31]|=64,nt(a,o),tt(t,a),s=0;s<32;s++)n[s+32]=t[s];return 0}var it=new Float64Array([237,211,245,92,26,99,18,88,214,156,247,162,222,249,222,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16]);function st(t,e){var n,r,i,s;for(r=63;r>=32;--r){for(n=0,i=r-32,s=r-12;i>4)*it[i],n=e[i]>>8,e[i]&=255;for(i=0;i<32;i++)e[i]-=n*it[i];for(r=0;r<32;r++)e[r+1]+=e[r]>>8,t[r]=255&e[r]}function ot(t){var e,n=new Float64Array(64);for(e=0;e<64;e++)n[e]=t[e];for(e=0;e<64;e++)t[e]=0;st(t,n)}function at(t,n,r,i){var s,o,a=new Uint8Array(64),c=new Uint8Array(64),h=new Uint8Array(64),u=new Float64Array(64),l=[e(),e(),e(),e()];V(a,i,32),a[0]&=248,a[31]&=127,a[31]|=64;var d=r+64;for(s=0;s>7&&j(t[0],o,t[0]),B(t[3],t[0],t[1]),0)}(d,i))return-1;for(s=0;s=0},t.sign.keyPair=function(){var t=new Uint8Array(32),e=new Uint8Array(64);return rt(t,e),{publicKey:t,secretKey:e}},t.sign.keyPair.fromSecretKey=function(t){if(ut(t),64!==t.length)throw new Error("bad secret key size");for(var e=new Uint8Array(32),n=0;n0)r.loading[t].push(n);else{r.loading[t]=[n];var i=ue.createScriptRequest(r.getPath(t,e)),s=r.receivers.create((function(e){if(r.receivers.remove(s),r.loading[t]){var n=r.loading[t];delete r.loading[t];for(var o=function(t){t||i.cleanup()},a=0;a>>6)+_(128|63&e):_(224|e>>>12&15)+_(128|e>>>6&63)+_(128|63&e)},P=function(t){return t.replace(/[^\x00-\x7F]/g,E)},x=function(t){var e=[0,2,1][t.length%3],n=t.charCodeAt(0)<<16|(t.length>1?t.charCodeAt(1):0)<<8|(t.length>2?t.charCodeAt(2):0);return[S.charAt(n>>>18),S.charAt(n>>>12&63),e>=2?"=":S.charAt(n>>>6&63),e>=1?"=":S.charAt(63&n)].join("")},A=window.btoa||function(t){return t.replace(/[\s\S]{1,3}/g,x)};var O=class{constructor(t,e,n,r){this.clear=e,this.timer=t(()=>{this.timer&&(this.timer=r(this.timer))},n)}isRunning(){return null!==this.timer}ensureAborted(){this.timer&&(this.clear(this.timer),this.timer=null)}};function L(t){window.clearTimeout(t)}function R(t){window.clearInterval(t)}class U extends O{constructor(t,e){super(setTimeout,L,t,(function(t){return e(),null}))}}class I extends O{constructor(t,e){super(setInterval,R,t,(function(t){return e(),t}))}}var M={now:()=>Date.now?Date.now():(new Date).valueOf(),defer:t=>new U(0,t),method(t,...e){var n=Array.prototype.slice.call(arguments,1);return function(e){return e[t].apply(e,n.concat(arguments))}}};function D(t,...e){for(var n=0;n{window.console&&window.console.log&&window.console.log(t)}}debug(...t){this.log(this.globalLog,t)}warn(...t){this.log(this.globalLogWarn,t)}error(...t){this.log(this.globalLogError,t)}globalLogWarn(t){window.console&&window.console.warn?window.console.warn(t):this.globalLog(t)}globalLogError(t){window.console&&window.console.error?window.console.error(t):this.globalLogWarn(t)}log(t,...e){var n=N.apply(this,arguments);if(Ie.log)Ie.log(n);else if(Ie.logToConsole){t.bind(this)(n)}}},G=function(t,e,n,r,i){void 0===n.headers&&null==n.headersProvider||W.warn(`To send headers with the ${r.toString()} request, you must use AJAX, rather than JSONP.`);var s=t.nextAuthCallbackID.toString();t.nextAuthCallbackID++;var o=t.getDocument(),a=o.createElement("script");t.auth_callbacks[s]=function(t){i(null,t)};var c="Pusher.auth_callbacks['"+s+"']";a.src=n.endpoint+"?callback="+encodeURIComponent(c)+"&"+e;var h=o.getElementsByTagName("head")[0]||o.documentElement;h.insertBefore(a,h.firstChild)};class V{constructor(t){this.src=t}send(t){var e=this,n="Error loading "+e.src;e.script=document.createElement("script"),e.script.id=t.id,e.script.src=e.src,e.script.type="text/javascript",e.script.charset="UTF-8",e.script.addEventListener?(e.script.onerror=function(){t.callback(n)},e.script.onload=function(){t.callback(null)}):e.script.onreadystatechange=function(){"loaded"!==e.script.readyState&&"complete"!==e.script.readyState||t.callback(null)},void 0===e.script.async&&document.attachEvent&&/opera/i.test(navigator.userAgent)?(e.errorScript=document.createElement("script"),e.errorScript.id=t.id+"_error",e.errorScript.text=t.name+"('"+n+"');",e.script.async=e.errorScript.async=!1):e.script.async=!0;var r=document.getElementsByTagName("head")[0];r.insertBefore(e.script,r.firstChild),e.errorScript&&r.insertBefore(e.errorScript,e.script.nextSibling)}cleanup(){this.script&&(this.script.onload=this.script.onerror=null,this.script.onreadystatechange=null),this.script&&this.script.parentNode&&this.script.parentNode.removeChild(this.script),this.errorScript&&this.errorScript.parentNode&&this.errorScript.parentNode.removeChild(this.errorScript),this.script=null,this.errorScript=null}}class Z{constructor(t,e){this.url=t,this.data=e}send(t){if(!this.request){var e=K(this.data),n=this.url+"/"+t.number+"?"+e;this.request=ue.createScriptRequest(n),this.request.send(t)}}cleanup(){this.request&&this.request.cleanup()}}var Q={name:"jsonp",getAgent:function(t,e){return function(n,r){var s="http"+(e?"s":"")+"://"+(t.host||t.options.host)+t.options.path,o=ue.createJSONPRequest(s,n),a=ue.ScriptReceivers.create((function(e,n){i.remove(a),o.cleanup(),n&&n.host&&(t.host=n.host),r&&r(e,n)}));o.send(a)}}};function tt(t,e,n){return t+(e.useTLS?"s":"")+"://"+(e.useTLS?e.hostTLS:e.hostNonTLS)+n}function et(t,e){return"/app/"+t+("?protocol="+s.PROTOCOL+"&client=js&version="+s.VERSION+(e?"&"+e:""))}var nt={getInitial:function(t,e){return tt("ws",e,(e.httpPath||"")+et(t,"flash=false"))}},rt={getInitial:function(t,e){return tt("http",e,(e.httpPath||"/pusher")+et(t))}},it={getInitial:function(t,e){return tt("http",e,e.httpPath||"/pusher")},getPath:function(t,e){return et(t)}};class st{constructor(){this._callbacks={}}get(t){return this._callbacks[ot(t)]}add(t,e,n){var r=ot(t);this._callbacks[r]=this._callbacks[r]||[],this._callbacks[r].push({fn:e,context:n})}remove(t,e,n){if(t||e||n){var r=t?[ot(t)]:z(this._callbacks);e||n?this.removeCallback(r,e,n):this.removeAllCallbacks(r)}else this._callbacks={}}removeCallback(t,e,n){H(t,(function(t){this._callbacks[t]=F(this._callbacks[t]||[],(function(t){return e&&e!==t.fn||n&&n!==t.context})),0===this._callbacks[t].length&&delete this._callbacks[t]}),this)}removeAllCallbacks(t){H(t,(function(t){delete this._callbacks[t]}),this)}}function ot(t){return"_"+t}class at{constructor(t){this.callbacks=new st,this.global_callbacks=[],this.failThrough=t}bind(t,e,n){return this.callbacks.add(t,e,n),this}bind_global(t){return this.global_callbacks.push(t),this}unbind(t,e,n){return this.callbacks.remove(t,e,n),this}unbind_global(t){return t?(this.global_callbacks=F(this.global_callbacks||[],e=>e!==t),this):(this.global_callbacks=[],this)}unbind_all(){return this.unbind(),this.unbind_global(),this}emit(t,e,n){for(var r=0;r0)for(r=0;r{this.onError(t),this.changeState("closed")}),!1}return this.bindListeners(),W.debug("Connecting",{transport:this.name,url:t}),this.changeState("connecting"),!0}close(){return!!this.socket&&(this.socket.close(),!0)}send(t){return"open"===this.state&&(M.defer(()=>{this.socket&&this.socket.send(t)}),!0)}ping(){"open"===this.state&&this.supportsPing()&&this.socket.ping()}onOpen(){this.hooks.beforeOpen&&this.hooks.beforeOpen(this.socket,this.hooks.urls.getPath(this.key,this.options)),this.changeState("open"),this.socket.onopen=void 0}onError(t){this.emit("error",{type:"WebSocketError",error:t}),this.timeline.error(this.buildTimelineMessage({error:t.toString()}))}onClose(t){t?this.changeState("closed",{code:t.code,reason:t.reason,wasClean:t.wasClean}):this.changeState("closed"),this.unbindListeners(),this.socket=void 0}onMessage(t){this.emit("message",t)}onActivity(){this.emit("activity")}bindListeners(){this.socket.onopen=()=>{this.onOpen()},this.socket.onerror=t=>{this.onError(t)},this.socket.onclose=t=>{this.onClose(t)},this.socket.onmessage=t=>{this.onMessage(t)},this.supportsPing()&&(this.socket.onactivity=()=>{this.onActivity()})}unbindListeners(){this.socket&&(this.socket.onopen=void 0,this.socket.onerror=void 0,this.socket.onclose=void 0,this.socket.onmessage=void 0,this.supportsPing()&&(this.socket.onactivity=void 0))}changeState(t,e){this.state=t,this.timeline.info(this.buildTimelineMessage({state:t,params:e})),this.emit(t,e)}buildTimelineMessage(t){return D({cid:this.id},t)}}class ht{constructor(t){this.hooks=t}isSupported(t){return this.hooks.isSupported(t)}createConnection(t,e,n,r){return new ct(this.hooks,t,e,n,r)}}var ut=new ht({urls:nt,handlesActivityChecks:!1,supportsPing:!1,isInitialized:function(){return Boolean(ue.getWebSocketAPI())},isSupported:function(){return Boolean(ue.getWebSocketAPI())},getSocket:function(t){return ue.createWebSocket(t)}}),lt={urls:rt,handlesActivityChecks:!1,supportsPing:!0,isInitialized:function(){return!0}},dt=D({getSocket:function(t){return ue.HTTPFactory.createStreamingSocket(t)}},lt),pt=D({getSocket:function(t){return ue.HTTPFactory.createPollingSocket(t)}},lt),ft={isSupported:function(){return ue.isXHRSupported()}},gt={ws:ut,xhr_streaming:new ht(D({},dt,ft)),xhr_polling:new ht(D({},pt,ft))},vt=new ht({file:"sockjs",urls:it,handlesActivityChecks:!0,supportsPing:!1,isSupported:function(){return!0},isInitialized:function(){return void 0!==window.SockJS},getSocket:function(t,e){return new window.SockJS(t,null,{js_path:a.getPath("sockjs",{useTLS:e.useTLS}),ignore_null_origin:e.ignoreNullOrigin})},beforeOpen:function(t,e){t.send(JSON.stringify({path:e}))}}),bt={isSupported:function(t){return ue.isXDRSupported(t.useTLS)}},yt=new ht(D({},dt,bt)),mt=new ht(D({},pt,bt));gt.xdr_streaming=yt,gt.xdr_polling=mt,gt.sockjs=vt;var wt=gt;var _t=new class extends at{constructor(){super();var t=this;void 0!==window.addEventListener&&(window.addEventListener("online",(function(){t.emit("online")}),!1),window.addEventListener("offline",(function(){t.emit("offline")}),!1))}isOnline(){return void 0===window.navigator.onLine||window.navigator.onLine}};class St{constructor(t,e,n){this.manager=t,this.transport=e,this.minPingDelay=n.minPingDelay,this.maxPingDelay=n.maxPingDelay,this.pingDelay=void 0}createConnection(t,e,n,r){r=D({},r,{activityTimeout:this.pingDelay});var i=this.transport.createConnection(t,e,n,r),s=null,o=function(){i.unbind("open",o),i.bind("closed",a),s=M.now()},a=t=>{if(i.unbind("closed",a),1002===t.code||1003===t.code)this.manager.reportDeath();else if(!t.wasClean&&s){var e=M.now()-s;e<2*this.maxPingDelay&&(this.manager.reportDeath(),this.pingDelay=Math.max(e/2,this.minPingDelay))}};return i.bind("open",o),i}isSupported(t){return this.manager.isAlive()&&this.transport.isSupported(t)}}const kt={decodeMessage:function(t){try{var e=JSON.parse(t.data),n=e.data;if("string"==typeof n)try{n=JSON.parse(e.data)}catch(t){}var r={event:e.event,channel:e.channel,data:n};return e.user_id&&(r.user_id=e.user_id),r}catch(e){throw{type:"MessageParseError",error:e,data:t.data}}},encodeMessage:function(t){return JSON.stringify(t)},processHandshake:function(t){var e=kt.decodeMessage(t);if("pusher:connection_established"===e.event){if(!e.data.activity_timeout)throw"No activity timeout specified in handshake";return{action:"connected",id:e.data.socket_id,activityTimeout:1e3*e.data.activity_timeout}}if("pusher:error"===e.event)return{action:this.getCloseAction(e.data),error:this.getCloseError(e.data)};throw"Invalid handshake"},getCloseAction:function(t){return t.code<4e3?t.code>=1002&&t.code<=1004?"backoff":null:4e3===t.code?"tls_only":t.code<4100?"refused":t.code<4200?"backoff":t.code<4300?"retry":"refused"},getCloseError:function(t){return 1e3!==t.code&&1001!==t.code?{type:"PusherError",data:{code:t.code,message:t.reason||t.message}}:null}};var Ct=kt;class Tt extends at{constructor(t,e){super(),this.id=t,this.transport=e,this.activityTimeout=e.activityTimeout,this.bindListeners()}handlesActivityChecks(){return this.transport.handlesActivityChecks()}send(t){return this.transport.send(t)}send_event(t,e,n){var r={event:t,data:e};return n&&(r.channel=n),W.debug("Event sent",r),this.send(Ct.encodeMessage(r))}ping(){this.transport.supportsPing()?this.transport.ping():this.send_event("pusher:ping",{})}close(){this.transport.close()}bindListeners(){var t={message:t=>{var e;try{e=Ct.decodeMessage(t)}catch(e){this.emit("error",{type:"MessageParseError",error:e,data:t.data})}if(void 0!==e){switch(W.debug("Event recd",e),e.event){case"pusher:error":this.emit("error",{type:"PusherError",data:e.data});break;case"pusher:ping":this.emit("ping");break;case"pusher:pong":this.emit("pong")}this.emit("message",e)}},activity:()=>{this.emit("activity")},error:t=>{this.emit("error",t)},closed:t=>{e(),t&&t.code&&this.handleCloseEvent(t),this.transport=null,this.emit("closed")}},e=()=>{B(t,(t,e)=>{this.transport.unbind(e,t)})};B(t,(t,e)=>{this.transport.bind(e,t)})}handleCloseEvent(t){var e=Ct.getCloseAction(t),n=Ct.getCloseError(t);n&&this.emit("error",n),e&&this.emit(e,{action:e,error:n})}}class Et{constructor(t,e){this.transport=t,this.callback=e,this.bindListeners()}close(){this.unbindListeners(),this.transport.close()}bindListeners(){this.onMessage=t=>{var e;this.unbindListeners();try{e=Ct.processHandshake(t)}catch(t){return this.finish("error",{error:t}),void this.transport.close()}"connected"===e.action?this.finish("connected",{connection:new Tt(e.id,this.transport),activityTimeout:e.activityTimeout}):(this.finish(e.action,{error:e.error}),this.transport.close())},this.onClosed=t=>{this.unbindListeners();var e=Ct.getCloseAction(t)||"backoff",n=Ct.getCloseError(t);this.finish(e,{error:n})},this.transport.bind("message",this.onMessage),this.transport.bind("closed",this.onClosed)}unbindListeners(){this.transport.unbind("message",this.onMessage),this.transport.unbind("closed",this.onClosed)}finish(t,e){this.callback(D({transport:this.transport,action:t},e))}}class Pt{constructor(t,e){this.timeline=t,this.options=e||{}}send(t,e){this.timeline.isEmpty()||this.timeline.send(ue.TimelineTransport.getAgent(this,t),e)}}class xt extends at{constructor(t,e){super((function(e,n){W.debug("No callbacks on "+t+" for "+e)})),this.name=t,this.pusher=e,this.subscribed=!1,this.subscriptionPending=!1,this.subscriptionCancelled=!1}authorize(t,e){return e(null,{auth:""})}trigger(t,e){if(0!==t.indexOf("client-"))throw new l("Event '"+t+"' does not start with 'client-'");if(!this.subscribed){var n=u("triggeringClientEvents");W.warn("Client event triggered before channel 'subscription_succeeded' event . "+n)}return this.pusher.send_event(t,e,this.name)}disconnect(){this.subscribed=!1,this.subscriptionPending=!1}handleEvent(t){var e=t.event,n=t.data;if("pusher_internal:subscription_succeeded"===e)this.handleSubscriptionSucceededEvent(t);else if("pusher_internal:subscription_count"===e)this.handleSubscriptionCountEvent(t);else if(0!==e.indexOf("pusher_internal:")){this.emit(e,n,{})}}handleSubscriptionSucceededEvent(t){this.subscriptionPending=!1,this.subscribed=!0,this.subscriptionCancelled?this.pusher.unsubscribe(this.name):this.emit("pusher:subscription_succeeded",t.data)}handleSubscriptionCountEvent(t){t.data.subscription_count&&(this.subscriptionCount=t.data.subscription_count),this.emit("pusher:subscription_count",t.data)}subscribe(){this.subscribed||(this.subscriptionPending=!0,this.subscriptionCancelled=!1,this.authorize(this.pusher.connection.socket_id,(t,e)=>{t?(this.subscriptionPending=!1,W.error(t.toString()),this.emit("pusher:subscription_error",Object.assign({},{type:"AuthError",error:t.message},t instanceof m?{status:t.status}:{}))):this.pusher.send_event("pusher:subscribe",{auth:e.auth,channel_data:e.channel_data,channel:this.name})}))}unsubscribe(){this.subscribed=!1,this.pusher.send_event("pusher:unsubscribe",{channel:this.name})}cancelSubscription(){this.subscriptionCancelled=!0}reinstateSubscription(){this.subscriptionCancelled=!1}}class At extends xt{authorize(t,e){return this.pusher.config.channelAuthorizer({channelName:this.name,socketId:t},e)}}class Ot{constructor(){this.reset()}get(t){return Object.prototype.hasOwnProperty.call(this.members,t)?{id:t,info:this.members[t]}:null}each(t){B(this.members,(e,n)=>{t(this.get(n))})}setMyID(t){this.myID=t}onSubscription(t){this.members=t.presence.hash,this.count=t.presence.count,this.me=this.get(this.myID)}addMember(t){return null===this.get(t.user_id)&&this.count++,this.members[t.user_id]=t.user_info,this.get(t.user_id)}removeMember(t){var e=this.get(t.user_id);return e&&(delete this.members[t.user_id],this.count--),e}reset(){this.members={},this.count=0,this.myID=null,this.me=null}}var Lt=function(t,e,n,r){return new(n||(n=Promise))((function(i,s){function o(t){try{c(r.next(t))}catch(t){s(t)}}function a(t){try{c(r.throw(t))}catch(t){s(t)}}function c(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(o,a)}c((r=r.apply(t,e||[])).next())}))};class Rt extends At{constructor(t,e){super(t,e),this.members=new Ot}authorize(t,e){super.authorize(t,(t,n)=>Lt(this,void 0,void 0,(function*(){if(!t)if(null!=(n=n).channel_data){var r=JSON.parse(n.channel_data);this.members.setMyID(r.user_id)}else{if(yield this.pusher.user.signinDonePromise,null==this.pusher.user.user_data){let t=u("authorizationEndpoint");return W.error(`Invalid auth response for channel '${this.name}', expected 'channel_data' field. ${t}, or the user should be signed in.`),void e("Invalid auth response")}this.members.setMyID(this.pusher.user.user_data.id)}e(t,n)})))}handleEvent(t){var e=t.event;if(0===e.indexOf("pusher_internal:"))this.handleInternalEvent(t);else{var n=t.data,r={};t.user_id&&(r.user_id=t.user_id),this.emit(e,n,r)}}handleInternalEvent(t){var e=t.event,n=t.data;switch(e){case"pusher_internal:subscription_succeeded":this.handleSubscriptionSucceededEvent(t);break;case"pusher_internal:subscription_count":this.handleSubscriptionCountEvent(t);break;case"pusher_internal:member_added":var r=this.members.addMember(n);this.emit("pusher:member_added",r);break;case"pusher_internal:member_removed":var i=this.members.removeMember(n);i&&this.emit("pusher:member_removed",i)}}handleSubscriptionSucceededEvent(t){this.subscriptionPending=!1,this.subscribed=!0,this.subscriptionCancelled?this.pusher.unsubscribe(this.name):(this.members.onSubscription(t.data),this.emit("pusher:subscription_succeeded",this.members))}disconnect(){this.members.reset(),super.disconnect()}}var Ut=n(1),It=n(0);class Mt extends At{constructor(t,e,n){super(t,e),this.key=null,this.nacl=n}authorize(t,e){super.authorize(t,(t,n)=>{if(t)return void e(t,n);let r=n.shared_secret;r?(this.key=Object(It.decode)(r),delete n.shared_secret,e(null,n)):e(new Error("No shared_secret key in auth payload for encrypted channel: "+this.name),null)})}trigger(t,e){throw new v("Client events are not currently supported for encrypted channels")}handleEvent(t){var e=t.event,n=t.data;0!==e.indexOf("pusher_internal:")&&0!==e.indexOf("pusher:")?this.handleEncryptedEvent(e,n):super.handleEvent(t)}handleEncryptedEvent(t,e){if(!this.key)return void W.debug("Received encrypted event before key has been retrieved from the authEndpoint");if(!e.ciphertext||!e.nonce)return void W.error("Unexpected format for encrypted event, expected object with `ciphertext` and `nonce` fields, got: "+e);let n=Object(It.decode)(e.ciphertext);if(n.length{e?W.error(`Failed to make a request to the authEndpoint: ${s}. Unable to fetch new key, so dropping encrypted event`):(i=this.nacl.secretbox.open(n,r,this.key),null!==i?this.emit(t,this.getDataToEmit(i)):W.error("Failed to decrypt event with new key. Dropping encrypted event"))});this.emit(t,this.getDataToEmit(i))}getDataToEmit(t){let e=Object(Ut.decode)(t);try{return JSON.parse(e)}catch(t){return e}}}class Dt extends at{constructor(t,e){super(),this.state="initialized",this.connection=null,this.key=t,this.options=e,this.timeline=this.options.timeline,this.usingTLS=this.options.useTLS,this.errorCallbacks=this.buildErrorCallbacks(),this.connectionCallbacks=this.buildConnectionCallbacks(this.errorCallbacks),this.handshakeCallbacks=this.buildHandshakeCallbacks(this.errorCallbacks);var n=ue.getNetwork();n.bind("online",()=>{this.timeline.info({netinfo:"online"}),"connecting"!==this.state&&"unavailable"!==this.state||this.retryIn(0)}),n.bind("offline",()=>{this.timeline.info({netinfo:"offline"}),this.connection&&this.sendActivityCheck()}),this.updateStrategy()}switchCluster(t){this.key=t,this.updateStrategy(),this.retryIn(0)}connect(){this.connection||this.runner||(this.strategy.isSupported()?(this.updateState("connecting"),this.startConnecting(),this.setUnavailableTimer()):this.updateState("failed"))}send(t){return!!this.connection&&this.connection.send(t)}send_event(t,e,n){return!!this.connection&&this.connection.send_event(t,e,n)}disconnect(){this.disconnectInternally(),this.updateState("disconnected")}isUsingTLS(){return this.usingTLS}startConnecting(){var t=(e,n)=>{e?this.runner=this.strategy.connect(0,t):"error"===n.action?(this.emit("error",{type:"HandshakeError",error:n.error}),this.timeline.error({handshakeError:n.error})):(this.abortConnecting(),this.handshakeCallbacks[n.action](n))};this.runner=this.strategy.connect(0,t)}abortConnecting(){this.runner&&(this.runner.abort(),this.runner=null)}disconnectInternally(){(this.abortConnecting(),this.clearRetryTimer(),this.clearUnavailableTimer(),this.connection)&&this.abandonConnection().close()}updateStrategy(){this.strategy=this.options.getStrategy({key:this.key,timeline:this.timeline,useTLS:this.usingTLS})}retryIn(t){this.timeline.info({action:"retry",delay:t}),t>0&&this.emit("connecting_in",Math.round(t/1e3)),this.retryTimer=new U(t||0,()=>{this.disconnectInternally(),this.connect()})}clearRetryTimer(){this.retryTimer&&(this.retryTimer.ensureAborted(),this.retryTimer=null)}setUnavailableTimer(){this.unavailableTimer=new U(this.options.unavailableTimeout,()=>{this.updateState("unavailable")})}clearUnavailableTimer(){this.unavailableTimer&&this.unavailableTimer.ensureAborted()}sendActivityCheck(){this.stopActivityCheck(),this.connection.ping(),this.activityTimer=new U(this.options.pongTimeout,()=>{this.timeline.error({pong_timed_out:this.options.pongTimeout}),this.retryIn(0)})}resetActivityCheck(){this.stopActivityCheck(),this.connection&&!this.connection.handlesActivityChecks()&&(this.activityTimer=new U(this.activityTimeout,()=>{this.sendActivityCheck()}))}stopActivityCheck(){this.activityTimer&&this.activityTimer.ensureAborted()}buildConnectionCallbacks(t){return D({},t,{message:t=>{this.resetActivityCheck(),this.emit("message",t)},ping:()=>{this.send_event("pusher:pong",{})},activity:()=>{this.resetActivityCheck()},error:t=>{this.emit("error",t)},closed:()=>{this.abandonConnection(),this.shouldRetry()&&this.retryIn(1e3)}})}buildHandshakeCallbacks(t){return D({},t,{connected:t=>{this.activityTimeout=Math.min(this.options.activityTimeout,t.activityTimeout,t.connection.activityTimeout||1/0),this.clearUnavailableTimer(),this.setConnection(t.connection),this.socket_id=this.connection.id,this.updateState("connected",{socket_id:this.socket_id})}})}buildErrorCallbacks(){let t=t=>e=>{e.error&&this.emit("error",{type:"WebSocketError",error:e.error}),t(e)};return{tls_only:t(()=>{this.usingTLS=!0,this.updateStrategy(),this.retryIn(0)}),refused:t(()=>{this.disconnect()}),backoff:t(()=>{this.retryIn(1e3)}),retry:t(()=>{this.retryIn(0)})}}setConnection(t){for(var e in this.connection=t,this.connectionCallbacks)this.connection.bind(e,this.connectionCallbacks[e]);this.resetActivityCheck()}abandonConnection(){if(this.connection){for(var t in this.stopActivityCheck(),this.connectionCallbacks)this.connection.unbind(t,this.connectionCallbacks[t]);var e=this.connection;return this.connection=null,e}}updateState(t,e){var n=this.state;if(this.state=t,n!==t){var r=t;"connected"===r&&(r+=" with new socket ID "+e.socket_id),W.debug("State changed",n+" -> "+r),this.timeline.info({state:t,params:e}),this.emit("state_change",{previous:n,current:t}),this.emit(t,e)}}shouldRetry(){return"connecting"===this.state||"connected"===this.state}}class Nt{constructor(){this.channels={}}add(t,e){return this.channels[t]||(this.channels[t]=function(t,e){if(0===t.indexOf("private-encrypted-")){if(e.config.nacl)return jt.createEncryptedChannel(t,e,e.config.nacl);let n="Tried to subscribe to a private-encrypted- channel but no nacl implementation available",r=u("encryptedChannelSupport");throw new v(`${n}. ${r}`)}if(0===t.indexOf("private-"))return jt.createPrivateChannel(t,e);if(0===t.indexOf("presence-"))return jt.createPresenceChannel(t,e);if(0===t.indexOf("#"))throw new d('Cannot create a channel with name "'+t+'".');return jt.createChannel(t,e)}(t,e)),this.channels[t]}all(){return function(t){var e=[];return B(t,(function(t){e.push(t)})),e}(this.channels)}find(t){return this.channels[t]}remove(t){var e=this.channels[t];return delete this.channels[t],e}disconnect(){B(this.channels,(function(t){t.disconnect()}))}}var jt={createChannels:()=>new Nt,createConnectionManager:(t,e)=>new Dt(t,e),createChannel:(t,e)=>new xt(t,e),createPrivateChannel:(t,e)=>new At(t,e),createPresenceChannel:(t,e)=>new Rt(t,e),createEncryptedChannel:(t,e,n)=>new Mt(t,e,n),createTimelineSender:(t,e)=>new Pt(t,e),createHandshake:(t,e)=>new Et(t,e),createAssistantToTheTransportManager:(t,e,n)=>new St(t,e,n)};class Bt{constructor(t){this.options=t||{},this.livesLeft=this.options.lives||1/0}getAssistant(t){return jt.createAssistantToTheTransportManager(this,t,{minPingDelay:this.options.minPingDelay,maxPingDelay:this.options.maxPingDelay})}isAlive(){return this.livesLeft>0}reportDeath(){this.livesLeft-=1}}class zt{constructor(t,e){this.strategies=t,this.loop=Boolean(e.loop),this.failFast=Boolean(e.failFast),this.timeout=e.timeout,this.timeoutLimit=e.timeoutLimit}isSupported(){return J(this.strategies,M.method("isSupported"))}connect(t,e){var n=this.strategies,r=0,i=this.timeout,s=null,o=(a,c)=>{c?e(null,c):(r+=1,this.loop&&(r%=n.length),r0&&(i=new U(n.timeout,(function(){s.abort(),r(!0)}))),s=t.connect(e,(function(t,e){t&&i&&i.isRunning()&&!n.failFast||(i&&i.ensureAborted(),r(t,e))})),{abort:function(){i&&i.ensureAborted(),s.abort()},forceMinPriority:function(t){s.forceMinPriority(t)}}}}class Ht{constructor(t){this.strategies=t}isSupported(){return J(this.strategies,M.method("isSupported"))}connect(t,e){return function(t,e,n){var r=q(t,(function(t,r,i,s){return t.connect(e,n(r,s))}));return{abort:function(){H(r,qt)},forceMinPriority:function(t){H(r,(function(e){e.forceMinPriority(t)}))}}}(this.strategies,t,(function(t,n){return function(r,i){n[t].error=r,r?function(t){return function(t,e){for(var n=0;n=M.now()){var o=this.transports[r.transport];o&&(["ws","wss"].includes(r.transport)||i>3?(this.timeline.info({cached:!0,transport:r.transport,latency:r.latency}),s.push(new zt([o],{timeout:2*r.latency+1e3,failFast:!0}))):i++)}var a=M.now(),c=s.pop().connect(t,(function r(o,h){o?(Jt(n),s.length>0?(a=M.now(),c=s.pop().connect(t,r)):e(o)):(!function(t,e,n,r){var i=ue.getLocalStorage();if(i)try{i[Xt(t)]=$({timestamp:M.now(),transport:e,latency:n,cacheSkipCount:r})}catch(t){}}(n,h.transport.name,M.now()-a,i),e(null,h))}));return{abort:function(){c.abort()},forceMinPriority:function(e){t=e,c&&c.forceMinPriority(e)}}}}function Xt(t){return"pusherTransport"+(t?"TLS":"NonTLS")}function Jt(t){var e=ue.getLocalStorage();if(e)try{delete e[Xt(t)]}catch(t){}}class Yt{constructor(t,{delay:e}){this.strategy=t,this.options={delay:e}}isSupported(){return this.strategy.isSupported()}connect(t,e){var n,r=this.strategy,i=new U(this.options.delay,(function(){n=r.connect(t,e)}));return{abort:function(){i.ensureAborted(),n&&n.abort()},forceMinPriority:function(e){t=e,n&&n.forceMinPriority(e)}}}}class Kt{constructor(t,e,n){this.test=t,this.trueBranch=e,this.falseBranch=n}isSupported(){return(this.test()?this.trueBranch:this.falseBranch).isSupported()}connect(t,e){return(this.test()?this.trueBranch:this.falseBranch).connect(t,e)}}class $t{constructor(t){this.strategy=t}isSupported(){return this.strategy.isSupported()}connect(t,e){var n=this.strategy.connect(t,(function(t,r){r&&n.abort(),e(t,r)}));return n}}function Wt(t){return function(){return t.isSupported()}}var Gt=function(t,e,n){var r={};function i(e,i,s,o,a){var c=n(t,e,i,s,o,a);return r[e]=c,c}var s,o=Object.assign({},e,{hostNonTLS:t.wsHost+":"+t.wsPort,hostTLS:t.wsHost+":"+t.wssPort,httpPath:t.wsPath}),a=Object.assign({},o,{useTLS:!0}),c=Object.assign({},e,{hostNonTLS:t.httpHost+":"+t.httpPort,hostTLS:t.httpHost+":"+t.httpsPort,httpPath:t.httpPath}),h={loop:!0,timeout:15e3,timeoutLimit:6e4},u=new Bt({minPingDelay:1e4,maxPingDelay:t.activityTimeout}),l=new Bt({lives:2,minPingDelay:1e4,maxPingDelay:t.activityTimeout}),d=i("ws","ws",3,o,u),p=i("wss","ws",3,a,u),f=i("sockjs","sockjs",1,c),g=i("xhr_streaming","xhr_streaming",1,c,l),v=i("xdr_streaming","xdr_streaming",1,c,l),b=i("xhr_polling","xhr_polling",1,c),y=i("xdr_polling","xdr_polling",1,c),m=new zt([d],h),w=new zt([p],h),_=new zt([f],h),S=new zt([new Kt(Wt(g),g,v)],h),k=new zt([new Kt(Wt(b),b,y)],h),C=new zt([new Kt(Wt(S),new Ht([S,new Yt(k,{delay:4e3})]),k)],h),T=new Kt(Wt(C),C,_);return s=e.useTLS?new Ht([m,new Yt(T,{delay:2e3})]):new Ht([m,new Yt(w,{delay:2e3}),new Yt(T,{delay:5e3})]),new Ft(new $t(new Kt(Wt(d),s,T)),r,{ttl:18e5,timeline:e.timeline,useTLS:e.useTLS})},Vt={getRequest:function(t){var e=new window.XDomainRequest;return e.ontimeout=function(){t.emit("error",new p),t.close()},e.onerror=function(e){t.emit("error",e),t.close()},e.onprogress=function(){e.responseText&&e.responseText.length>0&&t.onChunk(200,e.responseText)},e.onload=function(){e.responseText&&e.responseText.length>0&&t.onChunk(200,e.responseText),t.emit("finished",200),t.close()},e},abortRequest:function(t){t.ontimeout=t.onerror=t.onprogress=t.onload=null,t.abort()}};class Zt extends at{constructor(t,e,n){super(),this.hooks=t,this.method=e,this.url=n}start(t){this.position=0,this.xhr=this.hooks.getRequest(this),this.unloader=()=>{this.close()},ue.addUnloadListener(this.unloader),this.xhr.open(this.method,this.url,!0),this.xhr.setRequestHeader&&this.xhr.setRequestHeader("Content-Type","application/json"),this.xhr.send(t)}close(){this.unloader&&(ue.removeUnloadListener(this.unloader),this.unloader=null),this.xhr&&(this.hooks.abortRequest(this.xhr),this.xhr=null)}onChunk(t,e){for(;;){var n=this.advanceBuffer(e);if(!n)break;this.emit("chunk",{status:t,data:n})}this.isBufferTooLong(e)&&this.emit("buffer_too_long")}advanceBuffer(t){var e=t.slice(this.position),n=e.indexOf("\n");return-1!==n?(this.position+=n+1,e.slice(0,n)):null}isBufferTooLong(t){return this.position===t.length&&t.length>262144}}var Qt;!function(t){t[t.CONNECTING=0]="CONNECTING",t[t.OPEN=1]="OPEN",t[t.CLOSED=3]="CLOSED"}(Qt||(Qt={}));var te=Qt,ee=1;function ne(t){var e=-1===t.indexOf("?")?"?":"&";return t+e+"t="+ +new Date+"&n="+ee++}function re(t){return ue.randomInt(t)}var ie,se=class{constructor(t,e){this.hooks=t,this.session=re(1e3)+"/"+function(t){for(var e=[],n=0;n{this.onChunk(t)}),this.stream.bind("finished",t=>{this.hooks.onFinished(this,t)}),this.stream.bind("buffer_too_long",()=>{this.reconnect()});try{this.stream.start()}catch(t){M.defer(()=>{this.onError(t),this.onClose(1006,"Could not start streaming",!1)})}}closeStream(){this.stream&&(this.stream.unbind_all(),this.stream.close(),this.stream=null)}},oe={getReceiveURL:function(t,e){return t.base+"/"+e+"/xhr_streaming"+t.queryString},onHeartbeat:function(t){t.sendRaw("[]")},sendHeartbeat:function(t){t.sendRaw("[]")},onFinished:function(t,e){t.onClose(1006,"Connection interrupted ("+e+")",!1)}},ae={getReceiveURL:function(t,e){return t.base+"/"+e+"/xhr"+t.queryString},onHeartbeat:function(){},sendHeartbeat:function(t){t.sendRaw("[]")},onFinished:function(t,e){200===e?t.reconnect():t.onClose(1006,"Connection interrupted ("+e+")",!1)}},ce={getRequest:function(t){var e=new(ue.getXHRAPI());return e.onreadystatechange=e.onprogress=function(){switch(e.readyState){case 3:e.responseText&&e.responseText.length>0&&t.onChunk(e.status,e.responseText);break;case 4:e.responseText&&e.responseText.length>0&&t.onChunk(e.status,e.responseText),t.emit("finished",e.status),t.close()}},e},abortRequest:function(t){t.onreadystatechange=null,t.abort()}},he={createStreamingSocket(t){return this.createSocket(oe,t)},createPollingSocket(t){return this.createSocket(ae,t)},createSocket:(t,e)=>new se(t,e),createXHR(t,e){return this.createRequest(ce,t,e)},createRequest:(t,e,n)=>new Zt(t,e,n),createXDR:function(t,e){return this.createRequest(Vt,t,e)}},ue={nextAuthCallbackID:1,auth_callbacks:{},ScriptReceivers:i,DependenciesReceivers:o,getDefaultStrategy:Gt,Transports:wt,transportConnectionInitializer:function(){var t=this;t.timeline.info(t.buildTimelineMessage({transport:t.name+(t.options.useTLS?"s":"")})),t.hooks.isInitialized()?t.changeState("initialized"):t.hooks.file?(t.changeState("initializing"),a.load(t.hooks.file,{useTLS:t.options.useTLS},(function(e,n){t.hooks.isInitialized()?(t.changeState("initialized"),n(!0)):(e&&t.onError(e),t.onClose(),n(!1))}))):t.onClose()},HTTPFactory:he,TimelineTransport:Q,getXHRAPI:()=>window.XMLHttpRequest,getWebSocketAPI:()=>window.WebSocket||window.MozWebSocket,setup(t){window.Pusher=t;var e=()=>{this.onDocumentBody(t.ready)};window.JSON?e():a.load("json2",{},e)},getDocument:()=>document,getProtocol(){return this.getDocument().location.protocol},getAuthorizers:()=>({ajax:w,jsonp:G}),onDocumentBody(t){document.body?t():setTimeout(()=>{this.onDocumentBody(t)},0)},createJSONPRequest:(t,e)=>new Z(t,e),createScriptRequest:t=>new V(t),getLocalStorage(){try{return window.localStorage}catch(t){return}},createXHR(){return this.getXHRAPI()?this.createXMLHttpRequest():this.createMicrosoftXHR()},createXMLHttpRequest(){return new(this.getXHRAPI())},createMicrosoftXHR:()=>new ActiveXObject("Microsoft.XMLHTTP"),getNetwork:()=>_t,createWebSocket(t){return new(this.getWebSocketAPI())(t)},createSocketRequest(t,e){if(this.isXHRSupported())return this.HTTPFactory.createXHR(t,e);if(this.isXDRSupported(0===e.indexOf("https:")))return this.HTTPFactory.createXDR(t,e);throw"Cross-origin HTTP requests are not supported"},isXHRSupported(){var t=this.getXHRAPI();return Boolean(t)&&void 0!==(new t).withCredentials},isXDRSupported(t){var e=t?"https:":"http:",n=this.getProtocol();return Boolean(window.XDomainRequest)&&n===e},addUnloadListener(t){void 0!==window.addEventListener?window.addEventListener("unload",t,!1):void 0!==window.attachEvent&&window.attachEvent("onunload",t)},removeUnloadListener(t){void 0!==window.addEventListener?window.removeEventListener("unload",t,!1):void 0!==window.detachEvent&&window.detachEvent("onunload",t)},randomInt:t=>Math.floor((window.crypto||window.msCrypto).getRandomValues(new Uint32Array(1))[0]/Math.pow(2,32)*t)};!function(t){t[t.ERROR=3]="ERROR",t[t.INFO=6]="INFO",t[t.DEBUG=7]="DEBUG"}(ie||(ie={}));var le=ie;class de{constructor(t,e,n){this.key=t,this.session=e,this.events=[],this.options=n||{},this.sent=0,this.uniqueID=0}log(t,e){t<=this.options.level&&(this.events.push(D({},e,{timestamp:M.now()})),this.options.limit&&this.events.length>this.options.limit&&this.events.shift())}error(t){this.log(le.ERROR,t)}info(t){this.log(le.INFO,t)}debug(t){this.log(le.DEBUG,t)}isEmpty(){return 0===this.events.length}send(t,e){var n=D({session:this.session,bundle:this.sent+1,key:this.key,lib:"js",version:this.options.version,cluster:this.options.cluster,features:this.options.features,timeline:this.events},this.options.params);return this.events=[],t(n,(t,n)=>{t||this.sent++,e&&e(t,n)}),!0}generateUniqueID(){return this.uniqueID++,this.uniqueID}}class pe{constructor(t,e,n,r){this.name=t,this.priority=e,this.transport=n,this.options=r||{}}isSupported(){return this.transport.isSupported({useTLS:this.options.useTLS})}connect(t,e){if(!this.isSupported())return fe(new y,e);if(this.priority{n||(h(),i?i.close():r.close())},forceMinPriority:t=>{n||this.priority{if(void 0===ue.getAuthorizers()[t.transport])throw`'${t.transport}' is not a recognized auth transport`;return(e,n)=>{const r=((t,e)=>{var n="socket_id="+encodeURIComponent(t.socketId);for(var r in e.params)n+="&"+encodeURIComponent(r)+"="+encodeURIComponent(e.params[r]);if(null!=e.paramsProvider){let t=e.paramsProvider();for(var r in t)n+="&"+encodeURIComponent(r)+"="+encodeURIComponent(t[r])}return n})(e,t);ue.getAuthorizers()[t.transport](ue,r,t,h.UserAuthentication,n)}};var we=t=>{if(void 0===ue.getAuthorizers()[t.transport])throw`'${t.transport}' is not a recognized auth transport`;return(e,n)=>{const r=((t,e)=>{var n="socket_id="+encodeURIComponent(t.socketId);for(var r in n+="&channel_name="+encodeURIComponent(t.channelName),e.params)n+="&"+encodeURIComponent(r)+"="+encodeURIComponent(e.params[r]);if(null!=e.paramsProvider){let t=e.paramsProvider();for(var r in t)n+="&"+encodeURIComponent(r)+"="+encodeURIComponent(t[r])}return n})(e,t);ue.getAuthorizers()[t.transport](ue,r,t,h.ChannelAuthorization,n)}};const _e=(t,e,n)=>{const r={authTransport:e.transport,authEndpoint:e.endpoint,auth:{params:e.params,headers:e.headers}};return(e,i)=>{const s=t.channel(e.channelName);n(s,r).authorize(e.socketId,i)}};function Se(t,e){let n={activityTimeout:t.activityTimeout||s.activityTimeout,cluster:t.cluster,httpPath:t.httpPath||s.httpPath,httpPort:t.httpPort||s.httpPort,httpsPort:t.httpsPort||s.httpsPort,pongTimeout:t.pongTimeout||s.pongTimeout,statsHost:t.statsHost||s.stats_host,unavailableTimeout:t.unavailableTimeout||s.unavailableTimeout,wsPath:t.wsPath||s.wsPath,wsPort:t.wsPort||s.wsPort,wssPort:t.wssPort||s.wssPort,enableStats:Ee(t),httpHost:ke(t),useTLS:Te(t),wsHost:Ce(t),userAuthenticator:xe(t),channelAuthorizer:Ae(t,e)};return"disabledTransports"in t&&(n.disabledTransports=t.disabledTransports),"enabledTransports"in t&&(n.enabledTransports=t.enabledTransports),"ignoreNullOrigin"in t&&(n.ignoreNullOrigin=t.ignoreNullOrigin),"timelineParams"in t&&(n.timelineParams=t.timelineParams),"nacl"in t&&(n.nacl=t.nacl),n}function ke(t){return t.httpHost?t.httpHost:t.cluster?`sockjs-${t.cluster}.pusher.com`:s.httpHost}function Ce(t){return t.wsHost?t.wsHost:`ws-${t.cluster}.pusher.com`}function Te(t){return"https:"===ue.getProtocol()||!1!==t.forceTLS}function Ee(t){return"enableStats"in t?t.enableStats:"disableStats"in t&&!t.disableStats}const Pe=t=>"customHandler"in t&&null!=t.customHandler;function xe(t){const e=Object.assign(Object.assign({},s.userAuthentication),t.userAuthentication);return Pe(e)?e.customHandler:me(e)}function Ae(t,e){const n=function(t,e){let n;if("channelAuthorization"in t)n=Object.assign(Object.assign({},s.channelAuthorization),t.channelAuthorization);else if(n={transport:t.authTransport||s.authTransport,endpoint:t.authEndpoint||s.authEndpoint},"auth"in t&&("params"in t.auth&&(n.params=t.auth.params),"headers"in t.auth&&(n.headers=t.auth.headers)),"authorizer"in t)return{customHandler:_e(e,n,t.authorizer)};return n}(t,e);return Pe(n)?n.customHandler:we(n)}class Oe extends at{constructor(t){super((function(t,e){W.debug("No callbacks on watchlist events for "+t)})),this.pusher=t,this.bindWatchlistInternalEvent()}handleEvent(t){t.data.events.forEach(t=>{this.emit(t.name,t)})}bindWatchlistInternalEvent(){this.pusher.connection.bind("message",t=>{"pusher_internal:watchlist_events"===t.event&&this.handleEvent(t)})}}var Le=function(){let t,e;return{promise:new Promise((n,r)=>{t=n,e=r}),resolve:t,reject:e}};class Re extends at{constructor(t){super((function(t,e){W.debug("No callbacks on user for "+t)})),this.signin_requested=!1,this.user_data=null,this.serverToUserChannel=null,this.signinDonePromise=null,this._signinDoneResolve=null,this._onAuthorize=(t,e)=>{if(t)return W.warn("Error during signin: "+t),void this._cleanup();this.pusher.send_event("pusher:signin",{auth:e.auth,user_data:e.user_data})},this.pusher=t,this.pusher.connection.bind("state_change",({previous:t,current:e})=>{"connected"!==t&&"connected"===e&&this._signin(),"connected"===t&&"connected"!==e&&(this._cleanup(),this._newSigninPromiseIfNeeded())}),this.watchlist=new Oe(t),this.pusher.connection.bind("message",t=>{"pusher:signin_success"===t.event&&this._onSigninSuccess(t.data),this.serverToUserChannel&&this.serverToUserChannel.name===t.channel&&this.serverToUserChannel.handleEvent(t)})}signin(){this.signin_requested||(this.signin_requested=!0,this._signin())}_signin(){this.signin_requested&&(this._newSigninPromiseIfNeeded(),"connected"===this.pusher.connection.state&&this.pusher.config.userAuthenticator({socketId:this.pusher.connection.socket_id},this._onAuthorize))}_onSigninSuccess(t){try{this.user_data=JSON.parse(t.user_data)}catch(e){return W.error("Failed parsing user data after signin: "+t.user_data),void this._cleanup()}if("string"!=typeof this.user_data.id||""===this.user_data.id)return W.error("user_data doesn't contain an id. user_data: "+this.user_data),void this._cleanup();this._signinDoneResolve(),this._subscribeChannels()}_subscribeChannels(){this.serverToUserChannel=new xt("#server-to-user-"+this.user_data.id,this.pusher),this.serverToUserChannel.bind_global((t,e)=>{0!==t.indexOf("pusher_internal:")&&0!==t.indexOf("pusher:")&&this.emit(t,e)}),(t=>{t.subscriptionPending&&t.subscriptionCancelled?t.reinstateSubscription():t.subscriptionPending||"connected"!==this.pusher.connection.state||t.subscribe()})(this.serverToUserChannel)}_cleanup(){this.user_data=null,this.serverToUserChannel&&(this.serverToUserChannel.unbind_all(),this.serverToUserChannel.disconnect(),this.serverToUserChannel=null),this.signin_requested&&this._signinDoneResolve()}_newSigninPromiseIfNeeded(){if(!this.signin_requested)return;if(this.signinDonePromise&&!this.signinDonePromise.done)return;const{promise:t,resolve:e,reject:n}=Le();t.done=!1;const r=()=>{t.done=!0};t.then(r).catch(r),this.signinDonePromise=t,this._signinDoneResolve=e}}class Ue{static ready(){Ue.isReady=!0;for(var t=0,e=Ue.instances.length;tue.getDefaultStrategy(this.config,t,ve),timeline:this.timeline,activityTimeout:this.config.activityTimeout,pongTimeout:this.config.pongTimeout,unavailableTimeout:this.config.unavailableTimeout,useTLS:Boolean(this.config.useTLS)}),this.connection.bind("connected",()=>{this.subscribeAll(),this.timelineSender&&this.timelineSender.send(this.connection.isUsingTLS())}),this.connection.bind("message",t=>{var e=0===t.event.indexOf("pusher_internal:");if(t.channel){var n=this.channel(t.channel);n&&n.handleEvent(t)}e||this.global_emitter.emit(t.event,t.data)}),this.connection.bind("connecting",()=>{this.channels.disconnect()}),this.connection.bind("disconnected",()=>{this.channels.disconnect()}),this.connection.bind("error",t=>{W.warn(t)}),Ue.instances.push(this),this.timeline.info({instances:Ue.instances.length}),this.user=new Re(this),Ue.isReady&&this.connect()}switchCluster(t){const{appKey:e,cluster:n}=t;this.key=e,this.options=Object.assign(Object.assign({},this.options),{cluster:n}),this.config=Se(this.options,this),this.connection.switchCluster(this.key)}channel(t){return this.channels.find(t)}allChannels(){return this.channels.all()}connect(){if(this.connection.connect(),this.timelineSender&&!this.timelineSenderTimer){var t=this.connection.isUsingTLS(),e=this.timelineSender;this.timelineSenderTimer=new I(6e4,(function(){e.send(t)}))}}disconnect(){this.connection.disconnect(),this.timelineSenderTimer&&(this.timelineSenderTimer.ensureAborted(),this.timelineSenderTimer=null)}bind(t,e,n){return this.global_emitter.bind(t,e,n),this}unbind(t,e,n){return this.global_emitter.unbind(t,e,n),this}bind_global(t){return this.global_emitter.bind_global(t),this}unbind_global(t){return this.global_emitter.unbind_global(t),this}unbind_all(t){return this.global_emitter.unbind_all(),this}subscribeAll(){var t;for(t in this.channels.channels)this.channels.channels.hasOwnProperty(t)&&this.subscribe(t)}subscribe(t){var e=this.channels.add(t,this);return e.subscriptionPending&&e.subscriptionCancelled?e.reinstateSubscription():e.subscriptionPending||"connected"!==this.connection.state||e.subscribe(),e}unsubscribe(t){var e=this.channels.find(t);e&&e.subscriptionPending?e.cancelSubscription():(e=this.channels.remove(t))&&e.subscribed&&e.unsubscribe()}send_event(t,e,n){return this.connection.send_event(t,e,n)}shouldUseTLS(){return this.config.useTLS}signin(){this.user.signin()}}Ue.instances=[],Ue.isReady=!1,Ue.logToConsole=!1,Ue.Runtime=ue,Ue.ScriptReceivers=ue.ScriptReceivers,Ue.DependenciesReceivers=ue.DependenciesReceivers,Ue.auth_callbacks=ue.auth_callbacks;var Ie=Ue;ue.setup(Ue);var Me=n(2);class De extends Ie{constructor(t,e){Ie.logToConsole=De.logToConsole,Ie.log=De.log,ye(e),e.nacl=Me,super(t,e)}}}])})); //# sourceMappingURL=pusher-with-encryption.min.js.map \ No newline at end of file diff --git a/dist/web/pusher-with-encryption.min.js.map b/dist/web/pusher-with-encryption.min.js.map index 4d0695f16..02dd56e4b 100644 --- a/dist/web/pusher-with-encryption.min.js.map +++ b/dist/web/pusher-with-encryption.min.js.map @@ -1 +1 @@ -{"version":3,"sources":["webpack://Pusher/webpack/universalModuleDefinition","webpack://Pusher/webpack/bootstrap","webpack://Pusher/./node_modules/@stablelib/base64/base64.ts","webpack://Pusher/./node_modules/@stablelib/utf8/utf8.ts","webpack://Pusher/./node_modules/tweetnacl/nacl-fast.js","webpack://Pusher/./src/core/pusher-with-encryption.js","webpack://Pusher/./src/runtimes/web/dom/script_receiver_factory.ts","webpack://Pusher/./src/core/defaults.ts","webpack://Pusher/./src/runtimes/web/dom/dependencies.ts","webpack://Pusher/./src/runtimes/web/dom/dependency_loader.ts","webpack://Pusher/./src/core/utils/url_store.ts","webpack://Pusher/./src/core/auth/options.ts","webpack://Pusher/./src/core/errors.ts","webpack://Pusher/./src/runtimes/isomorphic/auth/xhr_auth.ts","webpack://Pusher/./src/core/base64.ts","webpack://Pusher/./src/core/utils/timers/abstract_timer.ts","webpack://Pusher/./src/core/utils/timers/index.ts","webpack://Pusher/./src/core/util.ts","webpack://Pusher/./src/core/utils/collections.ts","webpack://Pusher/./src/core/logger.ts","webpack://Pusher/./src/runtimes/web/auth/jsonp_auth.ts","webpack://Pusher/./src/runtimes/web/dom/script_request.ts","webpack://Pusher/./src/runtimes/web/dom/jsonp_request.ts","webpack://Pusher/./src/runtimes/web/timeline/jsonp_timeline.ts","webpack://Pusher/./src/core/transports/url_schemes.ts","webpack://Pusher/./src/core/events/callback_registry.ts","webpack://Pusher/./src/core/events/dispatcher.ts","webpack://Pusher/./src/core/transports/transport_connection.ts","webpack://Pusher/./src/core/transports/transport.ts","webpack://Pusher/./src/runtimes/isomorphic/transports/transports.ts","webpack://Pusher/./src/runtimes/web/transports/transports.ts","webpack://Pusher/./src/runtimes/web/net_info.ts","webpack://Pusher/./src/core/transports/assistant_to_the_transport_manager.ts","webpack://Pusher/./src/core/connection/protocol/protocol.ts","webpack://Pusher/./src/core/connection/connection.ts","webpack://Pusher/./src/core/connection/handshake/index.ts","webpack://Pusher/./src/core/timeline/timeline_sender.ts","webpack://Pusher/./src/core/channels/channel.ts","webpack://Pusher/./src/core/channels/private_channel.ts","webpack://Pusher/./src/core/channels/members.ts","webpack://Pusher/./src/core/channels/presence_channel.ts","webpack://Pusher/./src/core/channels/encrypted_channel.ts","webpack://Pusher/./src/core/connection/connection_manager.ts","webpack://Pusher/./src/core/channels/channels.ts","webpack://Pusher/./src/core/utils/factory.ts","webpack://Pusher/./src/core/transports/transport_manager.ts","webpack://Pusher/./src/core/strategies/sequential_strategy.ts","webpack://Pusher/./src/core/strategies/best_connected_ever_strategy.ts","webpack://Pusher/./src/core/strategies/websocket_prioritized_cached_strategy.ts","webpack://Pusher/./src/core/strategies/delayed_strategy.ts","webpack://Pusher/./src/core/strategies/if_strategy.ts","webpack://Pusher/./src/core/strategies/first_connected_strategy.ts","webpack://Pusher/./src/runtimes/web/default_strategy.ts","webpack://Pusher/./src/runtimes/web/http/http_xdomain_request.ts","webpack://Pusher/./src/core/http/http_request.ts","webpack://Pusher/./src/core/http/state.ts","webpack://Pusher/./src/core/http/http_socket.ts","webpack://Pusher/./src/core/timeline/level.ts","webpack://Pusher/./src/core/http/http_streaming_socket.ts","webpack://Pusher/./src/core/http/http_polling_socket.ts","webpack://Pusher/./src/runtimes/isomorphic/http/http_xhr_request.ts","webpack://Pusher/./src/runtimes/isomorphic/http/http.ts","webpack://Pusher/./src/runtimes/web/http/http.ts","webpack://Pusher/./src/runtimes/web/runtime.ts","webpack://Pusher/./src/runtimes/web/transports/transport_connection_initializer.ts","webpack://Pusher/./src/core/timeline/timeline.ts","webpack://Pusher/./src/core/strategies/transport_strategy.ts","webpack://Pusher/./src/core/strategies/strategy_builder.ts","webpack://Pusher/./src/core/options.ts","webpack://Pusher/./src/core/auth/user_authenticator.ts","webpack://Pusher/./src/core/auth/channel_authorizer.ts","webpack://Pusher/./src/core/config.ts","webpack://Pusher/./src/core/auth/deprecated_channel_authorizer.ts","webpack://Pusher/./src/core/watchlist.ts","webpack://Pusher/./src/core/utils/flat_promise.ts","webpack://Pusher/./src/core/user.ts","webpack://Pusher/./src/core/pusher.ts","webpack://Pusher/./src/core/pusher-with-encryption.ts"],"names":["root","factory","exports","module","define","amd","window","installedModules","__webpack_require__","moduleId","i","l","modules","call","m","c","d","name","getter","o","Object","defineProperty","enumerable","get","r","Symbol","toStringTag","value","t","mode","__esModule","ns","create","key","bind","n","object","property","prototype","hasOwnProperty","p","s","_paddingCharacter","encodedLength","length","this","encode","data","out","_encodeByte","left","maxDecodedLength","decodedLength","_getPaddingLength","decode","Uint8Array","paddingLength","op","haveBad","v0","v1","v2","v3","_decodeChar","charCodeAt","Error","b","result","String","fromCharCode","Coder","stdCoder","URLSafeCoder","urlSafeCoder","INVALID_UTF8","arr","pos","chars","min","n1","n2","n3","push","join","nacl","gf","init","Float64Array","randombytes","_0","_9","gf0","gf1","_121665","D","D2","X","Y","I","ts64","x","h","vn","xi","y","yi","crypto_verify_16","crypto_verify_32","crypto_core_salsa20","inp","k","u","j0","j1","j2","j3","j4","j5","j6","j7","j8","j9","j10","j11","j12","j13","j14","j15","x0","x1","x2","x3","x4","x5","x6","x7","x8","x9","x10","x11","x12","x13","x14","x15","core_salsa20","crypto_core_hsalsa20","core_hsalsa20","sigma","crypto_stream_salsa20_xor","cpos","mpos","z","crypto_stream_salsa20","crypto_stream","sn","crypto_stream_xor","poly1305","t0","t1","t2","t3","t4","t5","t6","t7","buffer","Uint16Array","pad","leftover","fin","crypto_onetimeauth","outpos","update","finish","crypto_onetimeauth_verify","hpos","crypto_secretbox","crypto_secretbox_open","set25519","a","car25519","v","Math","floor","sel25519","q","pack25519","j","neq25519","par25519","unpack25519","A","Z","M","t8","t9","t10","t11","t12","t13","t14","t15","t16","t17","t18","t19","t20","t21","t22","t23","t24","t25","t26","t27","t28","t29","t30","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","b10","b11","b12","b13","b14","b15","S","inv25519","pow2523","crypto_scalarmult","e","f","x32","subarray","x16","crypto_scalarmult_base","crypto_box_keypair","crypto_box_beforenm","blocks","bytes","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","hibit","h0","h1","h2","h3","h4","h5","h6","h7","h8","h9","r0","r1","r2","r3","r4","r5","r6","r7","r8","r9","mac","macpos","mask","g","want","crypto_box_afternm","crypto_box_open_afternm","K","crypto_hashblocks_hl","hh","hl","bh0","bh1","bh2","bh3","bh4","bh5","bh6","bh7","bl0","bl1","bl2","bl3","bl4","bl5","bl6","bl7","th","tl","wh","Int32Array","wl","ah0","ah1","ah2","ah3","ah4","ah5","ah6","ah7","al0","al1","al2","al3","al4","al5","al6","al7","crypto_hash","add","cswap","pack","tx","ty","zi","scalarmult","scalarbase","crypto_sign_keypair","pk","sk","seeded","L","modL","carry","reduce","crypto_sign","sm","smlen","crypto_sign_open","chk","num","den","den2","den4","den6","unpackneg","checkLengths","checkArrayTypes","arguments","TypeError","cleanup","lowlevel","crypto_box","crypto_box_open","crypto_secretbox_KEYBYTES","crypto_secretbox_NONCEBYTES","crypto_secretbox_ZEROBYTES","crypto_secretbox_BOXZEROBYTES","crypto_scalarmult_BYTES","crypto_scalarmult_SCALARBYTES","crypto_box_PUBLICKEYBYTES","crypto_box_SECRETKEYBYTES","crypto_box_BEFORENMBYTES","crypto_box_NONCEBYTES","crypto_box_ZEROBYTES","crypto_box_BOXZEROBYTES","crypto_sign_BYTES","crypto_sign_PUBLICKEYBYTES","crypto_sign_SECRETKEYBYTES","crypto_sign_SEEDBYTES","crypto_hash_BYTES","randomBytes","secretbox","msg","nonce","open","box","keyLength","nonceLength","overheadLength","scalarMult","base","scalarLength","groupElementLength","publicKey","secretKey","before","checkBoxLengths","after","keyPair","fromSecretKey","publicKeyLength","secretKeyLength","sharedKeyLength","sign","signedMsg","tmp","mlen","detached","sig","verify","fromSeed","seed","seedLength","signatureLength","hash","hashLength","setPRNG","fn","crypto","self","msCrypto","getRandomValues","default","ScriptReceiverFactory","prefix","lastId","callback","number","id","called","callbackWrapper","apply","receiver","ScriptReceivers","VERSION","PROTOCOL","wsPort","wssPort","wsPath","httpHost","httpPort","httpsPort","httpPath","stats_host","authEndpoint","authTransport","activityTimeout","pongTimeout","unavailableTimeout","userAuthentication","endpoint","transport","channelAuthorization","cdn_http","cdn_https","dependency_suffix","DependenciesReceivers","Dependencies","options","receivers","loading","request","createScriptRequest","getPath","error","remove","callbacks","successCallback","wasSuccessful","send","protocol","getDocument","location","useTLS","replace","version","getRoot","suffix","urlStore","baseUrl","urls","authenticationEndpoint","path","authorizationEndpoint","javascriptQuickStart","triggeringClientEvents","encryptedChannelSupport","fullUrl","AuthRequestType","urlObj","url","BadEventName","super","setPrototypeOf","BadChannelName","RequestTimedOut","TransportPriorityTooLow","TransportClosed","UnsupportedFeature","UnsupportedTransport","UnsupportedStrategy","HTTPAuthError","status","context","query","authOptions","authRequestType","xhr","createXHR","headerName","setRequestHeader","headers","headersProvider","dynamicHeaders","onreadystatechange","readyState","parsed","JSON","parse","responseText","toString","UserAuthentication","ChannelAuthorization","b64chars","b64tab","charAt","cb_utob","cc","utob","cb_encode","ccc","padlen","ord","btoa","set","clear","delay","timer","clearTimeout","clearInterval","setTimeout","setInterval","now","Date","valueOf","defer","args","boundArguments","Array","slice","concat","extend","target","sources","extensions","constructor","stringify","safeJSONStringify","arrayIndexOf","array","item","nativeIndexOf","indexOf","objectApply","keys","_","map","filter","test","filterObject","Boolean","any","encodeParamsObject","encodeURIComponent","buildQueryString","params","undefined","method","source","objects","paths","derez","nu","$ref","globalLog","message","console","log","globalLogWarn","globalLogError","warn","defaultLoggingFunction","logToConsole","callbackName","nextAuthCallbackID","document","script","createElement","auth_callbacks","callback_name","src","head","getElementsByTagName","documentElement","insertBefore","firstChild","ScriptRequest","errorString","type","charset","addEventListener","onerror","onload","async","attachEvent","navigator","userAgent","errorScript","text","nextSibling","parentNode","removeChild","getAgent","sender","host","createJSONPRequest","getGenericURL","baseScheme","hostTLS","hostNonTLS","getGenericPath","queryString","ws","getInitial","http","sockjs","_callbacks","prefixedEventName","names","removeCallback","removeAllCallbacks","binding","failThrough","global_callbacks","eventName","unbind","unbind_global","metadata","hooks","priority","initialize","transportConnectionInitializer","state","timeline","generateUniqueID","handlesActivityChecks","supportsPing","socket","getSocket","onError","changeState","bindListeners","debug","close","ping","beforeOpen","onopen","emit","buildTimelineMessage","closeEvent","code","reason","wasClean","unbindListeners","onOpen","onclose","onClose","onmessage","onMessage","onactivity","onActivity","info","cid","environment","isSupported","WSTransport","isInitialized","getWebSocketAPI","createWebSocket","httpConfiguration","streamingConfiguration","HTTPFactory","createStreamingSocket","pollingConfiguration","createPollingSocket","xhrConfiguration","isXHRSupported","xhr_streaming","xhr_polling","SockJSTransport","file","SockJS","js_path","ignore_null_origin","ignoreNullOrigin","xdrConfiguration","isXDRSupported","XDRStreamingTransport","XDRPollingTransport","xdr_streaming","xdr_polling","onLine","manager","minPingDelay","maxPingDelay","pingDelay","connection","createConnection","openTimestamp","onClosed","reportDeath","lifespan","max","isAlive","Protocol","decodeMessage","messageEvent","messageData","pusherEventData","pusherEvent","event","channel","user_id","encodeMessage","processHandshake","activity_timeout","action","socket_id","getCloseAction","getCloseError","send_event","listeners","activity","closed","handleCloseEvent","listener","isEmpty","TimelineTransport","pusher","subscribed","subscriptionPending","subscriptionCancelled","socketId","auth","handleSubscriptionSucceededEvent","handleSubscriptionCountEvent","unsubscribe","subscription_count","subscriptionCount","authorize","assign","channel_data","config","channelAuthorizer","channelName","reset","members","member","myID","subscriptionData","presence","count","me","memberData","user_info","authData","channelData","setMyID","user","signinDonePromise","user_data","handleInternalEvent","addedMember","addMember","removedMember","removeMember","onSubscription","disconnect","sharedSecret","handleEncryptedEvent","handleEvent","ciphertext","cipherText","getDataToEmit","raw","usingTLS","errorCallbacks","buildErrorCallbacks","connectionCallbacks","buildConnectionCallbacks","handshakeCallbacks","buildHandshakeCallbacks","Network","getNetwork","netinfo","retryIn","sendActivityCheck","updateStrategy","runner","strategy","updateState","startConnecting","setUnavailableTimer","disconnectInternally","handshake","connect","handshakeError","abortConnecting","abort","clearRetryTimer","clearUnavailableTimer","abandonConnection","getStrategy","round","retryTimer","ensureAborted","unavailableTimer","stopActivityCheck","activityTimer","pong_timed_out","resetActivityCheck","shouldRetry","connected","Infinity","setConnection","withErrorEmitted","tls_only","refused","backoff","retry","newState","previousState","newStateDescription","previous","current","channels","createEncryptedChannel","errMsg","createPrivateChannel","createPresenceChannel","createChannel","values","createChannels","createConnectionManager","createTimelineSender","createHandshake","createAssistantToTheTransportManager","livesLeft","lives","strategies","loop","failFast","timeout","timeoutLimit","minPriority","tryNextStrategy","tryStrategy","forceMinPriority","isRunning","callbackBuilder","runners","rs","abortRunner","allRunnersFailed","aborted","transports","ttl","storage","getLocalStorage","serializedCache","getTransportCacheKey","flushTransportCache","fetchTransportCache","cacheSkipCount","timestamp","includes","cached","latency","startTimestamp","pop","cb","storeTransportCache","IfStrategy","trueBranch","falseBranch","FirstConnectedStrategy","testSupportsStrategy","baseOptions","defineTransport","definedTransports","defineTransportStrategy","wsStrategy","ws_options","wsHost","wss_options","sockjs_options","timeouts","ws_manager","streaming_manager","ws_transport","wss_transport","sockjs_transport","xhr_streaming_transport","xdr_streaming_transport","xhr_polling_transport","xdr_polling_transport","ws_loop","wss_loop","sockjs_loop","streaming_loop","polling_loop","http_loop","http_fallback_loop","getRequest","xdr","XDomainRequest","ontimeout","onprogress","onChunk","abortRequest","payload","position","unloader","addUnloadListener","removeUnloadListener","chunk","advanceBuffer","isBufferTooLong","unreadData","endOfLinePosition","State","autoIncrement","getUniqueURL","separator","randomNumber","randomInt","TimelineLevel","session","randomString","parts","exec","getLocation","CONNECTING","openStream","sendRaw","sendHeartbeat","OPEN","createSocketRequest","start","closeStream","CLOSED","onEvent","onHeartbeat","hostname","urlParts","stream","getReceiveURL","onFinished","reconnect","unbind_all","getXHRAPI","createSocket","createRequest","getDefaultStrategy","Transports","load","XMLHttpRequest","WebSocket","MozWebSocket","PusherClass","Pusher","initializeOnDocumentBody","onDocumentBody","ready","getAuthorizers","ajax","jsonp","body","localStorage","createXMLHttpRequest","createMicrosoftXHR","ActiveXObject","createXDR","Constructor","withCredentials","documentProtocol","getProtocol","removeEventListener","detachEvent","Uint32Array","events","sent","uniqueID","level","limit","shift","ERROR","INFO","DEBUG","sendfn","bundle","lib","cluster","features","failAttempt","onInitialized","serializedTransport","transportClass","enabledTransports","disabledTransports","getAssistant","deferred","validateOptions","paramsProvider","dynamicParams","composeChannelQuery","getConfig","opts","statsHost","enableStats","getEnableStatsConfig","getHttpHost","shouldUseTLS","getWebsocketHost","userAuthenticator","buildUserAuthenticator","buildChannelAuthorizer","timelineParams","forceTLS","disableStats","customHandler","channelAuthorizerGenerator","deprecatedAuthorizerOptions","ChannelAuthorizerProxy","authorizer","buildChannelAuth","bindWatchlistInternalEvent","forEach","watchlistEvent","resolve","reject","promise","Promise","res","rej","signin_requested","serverToUserChannel","_signinDoneResolve","_onAuthorize","err","_cleanup","_signin","_newSigninPromiseIfNeeded","watchlist","_onSigninSuccess","_subscribeChannels","bind_global","reinstateSubscription","subscribe","ensure_subscribed","done","setDone","then","catch","isReady","instances","app_key","checkAppKey","global_emitter","sessionID","getClientFeatures","timelineSender","subscribeAll","isUsingTLS","internal","appKey","switchCluster","find","all","timelineSenderTimer","event_name","channel_name","cancelSubscription","signin","Runtime","setup"],"mappings":";;;;;;;CAAA,SAA2CA,EAAMC,GAC1B,iBAAZC,SAA0C,iBAAXC,OACxCA,OAAOD,QAAUD,IACQ,mBAAXG,QAAyBA,OAAOC,IAC9CD,OAAO,GAAIH,GACe,iBAAZC,QACdA,QAAgB,OAAID,IAEpBD,EAAa,OAAIC,IARnB,CASGK,QAAQ,WACX,O,YCTE,IAAIC,EAAmB,GAGvB,SAASC,EAAoBC,GAG5B,GAAGF,EAAiBE,GACnB,OAAOF,EAAiBE,GAAUP,QAGnC,IAAIC,EAASI,EAAiBE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SAASA,SAASryB,eAAeotB,IACxC9sB,KAAK8/B,UAAUhT,GAKrB,UAAUuU,GACR,IAAIxW,EAAU7qB,KAAK+xB,SAASrgB,IAAI2vB,EAAcrhC,MAS9C,OARI6qB,EAAQmB,qBAAuBnB,EAAQoB,sBACzCpB,EAAQgV,wBAEPhV,EAAQmB,qBACiB,cAA1BhsB,KAAK8pB,WAAWhE,OAEhB+E,EAAQiV,YAEHjV,EAGT,YAAYwW,GACV,IAAIxW,EAAU7qB,KAAK+xB,SAASkP,KAAKI,GAC7BxW,GAAWA,EAAQmB,oBACrBnB,EAAQyW,sBAERzW,EAAU7qB,KAAK+xB,SAAS5X,OAAOknB,KAChBxW,EAAQkB,YACrBlB,EAAQyB,cAKd,WAAW8U,EAAoBlhC,EAAW2qB,GACxC,OAAO7qB,KAAK8pB,WAAWwB,WAAW8V,EAAYlhC,EAAM2qB,GAGtD,eACE,OAAO7qB,KAAK4sB,OAAOjS,OAGrB,SACE3a,KAAK4tB,KAAK2T,UAtOL,GAAAlB,UAAsB,GACtB,GAAAD,SAAmB,EACnB,GAAAle,cAAwB,EAGxB,GAAAsf,QAA2B,GAC3B,GAAArpB,gBAA6B,GAASA,gBACtC,GAAAuB,sBAAmC,GAASA,sBAC5C,GAAA8I,eAA4B,GAASA,eAVzB,UAkPrB,GAAQif,MAAM,I,YClQC,MAAM,WAA6B,GAChD,YAAYnB,EAAiB1mB,GAC3B,GAAOsI,aAAe,GAAqBA,aAC3C,GAAOL,IAAM,GAAqBA,IAElCmb,GAAgBpjB,GAChBA,EAAQrX,KAAO,GACfuZ,MAAMwkB,EAAS1mB","file":"pusher-with-encryption.min.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"Pusher\"] = factory();\n\telse\n\t\troot[\"Pusher\"] = factory();\n})(window, function() {\nreturn "," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 3);\n","// Copyright (C) 2016 Dmitry Chestnykh\n// MIT License. See LICENSE file for details.\n\n/**\n * Package base64 implements Base64 encoding and decoding.\n */\n\n// Invalid character used in decoding to indicate\n// that the character to decode is out of range of\n// alphabet and cannot be decoded.\nconst INVALID_BYTE = 256;\n\n/**\n * Implements standard Base64 encoding.\n *\n * Operates in constant time.\n */\nexport class Coder {\n // TODO(dchest): methods to encode chunk-by-chunk.\n\n constructor(private _paddingCharacter = \"=\") { }\n\n encodedLength(length: number): number {\n if (!this._paddingCharacter) {\n return (length * 8 + 5) / 6 | 0;\n }\n return (length + 2) / 3 * 4 | 0;\n }\n\n encode(data: Uint8Array): string {\n let out = \"\";\n\n let i = 0;\n for (; i < data.length - 2; i += 3) {\n let c = (data[i] << 16) | (data[i + 1] << 8) | (data[i + 2]);\n out += this._encodeByte((c >>> 3 * 6) & 63);\n out += this._encodeByte((c >>> 2 * 6) & 63);\n out += this._encodeByte((c >>> 1 * 6) & 63);\n out += this._encodeByte((c >>> 0 * 6) & 63);\n }\n\n const left = data.length - i;\n if (left > 0) {\n let c = (data[i] << 16) | (left === 2 ? data[i + 1] << 8 : 0);\n out += this._encodeByte((c >>> 3 * 6) & 63);\n out += this._encodeByte((c >>> 2 * 6) & 63);\n if (left === 2) {\n out += this._encodeByte((c >>> 1 * 6) & 63);\n } else {\n out += this._paddingCharacter || \"\";\n }\n out += this._paddingCharacter || \"\";\n }\n\n return out;\n }\n\n maxDecodedLength(length: number): number {\n if (!this._paddingCharacter) {\n return (length * 6 + 7) / 8 | 0;\n }\n return length / 4 * 3 | 0;\n }\n\n decodedLength(s: string): number {\n return this.maxDecodedLength(s.length - this._getPaddingLength(s));\n }\n\n decode(s: string): Uint8Array {\n if (s.length === 0) {\n return new Uint8Array(0);\n }\n const paddingLength = this._getPaddingLength(s);\n const length = s.length - paddingLength;\n const out = new Uint8Array(this.maxDecodedLength(length));\n let op = 0;\n let i = 0;\n let haveBad = 0;\n let v0 = 0, v1 = 0, v2 = 0, v3 = 0;\n for (; i < length - 4; i += 4) {\n v0 = this._decodeChar(s.charCodeAt(i + 0));\n v1 = this._decodeChar(s.charCodeAt(i + 1));\n v2 = this._decodeChar(s.charCodeAt(i + 2));\n v3 = this._decodeChar(s.charCodeAt(i + 3));\n out[op++] = (v0 << 2) | (v1 >>> 4);\n out[op++] = (v1 << 4) | (v2 >>> 2);\n out[op++] = (v2 << 6) | v3;\n haveBad |= v0 & INVALID_BYTE;\n haveBad |= v1 & INVALID_BYTE;\n haveBad |= v2 & INVALID_BYTE;\n haveBad |= v3 & INVALID_BYTE;\n }\n if (i < length - 1) {\n v0 = this._decodeChar(s.charCodeAt(i));\n v1 = this._decodeChar(s.charCodeAt(i + 1));\n out[op++] = (v0 << 2) | (v1 >>> 4);\n haveBad |= v0 & INVALID_BYTE;\n haveBad |= v1 & INVALID_BYTE;\n }\n if (i < length - 2) {\n v2 = this._decodeChar(s.charCodeAt(i + 2));\n out[op++] = (v1 << 4) | (v2 >>> 2);\n haveBad |= v2 & INVALID_BYTE;\n }\n if (i < length - 3) {\n v3 = this._decodeChar(s.charCodeAt(i + 3));\n out[op++] = (v2 << 6) | v3;\n haveBad |= v3 & INVALID_BYTE;\n }\n if (haveBad !== 0) {\n throw new Error(\"Base64Coder: incorrect characters for decoding\");\n }\n return out;\n }\n\n // Standard encoding have the following encoded/decoded ranges,\n // which we need to convert between.\n //\n // ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 0123456789 + /\n // Index: 0 - 25 26 - 51 52 - 61 62 63\n // ASCII: 65 - 90 97 - 122 48 - 57 43 47\n //\n\n // Encode 6 bits in b into a new character.\n protected _encodeByte(b: number): string {\n // Encoding uses constant time operations as follows:\n //\n // 1. Define comparison of A with B using (A - B) >>> 8:\n // if A > B, then result is positive integer\n // if A <= B, then result is 0\n //\n // 2. Define selection of C or 0 using bitwise AND: X & C:\n // if X == 0, then result is 0\n // if X != 0, then result is C\n //\n // 3. Start with the smallest comparison (b >= 0), which is always\n // true, so set the result to the starting ASCII value (65).\n //\n // 4. Continue comparing b to higher ASCII values, and selecting\n // zero if comparison isn't true, otherwise selecting a value\n // to add to result, which:\n //\n // a) undoes the previous addition\n // b) provides new value to add\n //\n let result = b;\n // b >= 0\n result += 65;\n // b > 25\n result += ((25 - b) >>> 8) & ((0 - 65) - 26 + 97);\n // b > 51\n result += ((51 - b) >>> 8) & ((26 - 97) - 52 + 48);\n // b > 61\n result += ((61 - b) >>> 8) & ((52 - 48) - 62 + 43);\n // b > 62\n result += ((62 - b) >>> 8) & ((62 - 43) - 63 + 47);\n\n return String.fromCharCode(result);\n }\n\n // Decode a character code into a byte.\n // Must return 256 if character is out of alphabet range.\n protected _decodeChar(c: number): number {\n // Decoding works similar to encoding: using the same comparison\n // function, but now it works on ranges: result is always incremented\n // by value, but this value becomes zero if the range is not\n // satisfied.\n //\n // Decoding starts with invalid value, 256, which is then\n // subtracted when the range is satisfied. If none of the ranges\n // apply, the function returns 256, which is then checked by\n // the caller to throw error.\n let result = INVALID_BYTE; // start with invalid character\n\n // c == 43 (c > 42 and c < 44)\n result += (((42 - c) & (c - 44)) >>> 8) & (-INVALID_BYTE + c - 43 + 62);\n // c == 47 (c > 46 and c < 48)\n result += (((46 - c) & (c - 48)) >>> 8) & (-INVALID_BYTE + c - 47 + 63);\n // c > 47 and c < 58\n result += (((47 - c) & (c - 58)) >>> 8) & (-INVALID_BYTE + c - 48 + 52);\n // c > 64 and c < 91\n result += (((64 - c) & (c - 91)) >>> 8) & (-INVALID_BYTE + c - 65 + 0);\n // c > 96 and c < 123\n result += (((96 - c) & (c - 123)) >>> 8) & (-INVALID_BYTE + c - 97 + 26);\n\n return result;\n }\n\n private _getPaddingLength(s: string): number {\n let paddingLength = 0;\n if (this._paddingCharacter) {\n for (let i = s.length - 1; i >= 0; i--) {\n if (s[i] !== this._paddingCharacter) {\n break;\n }\n paddingLength++;\n }\n if (s.length < 4 || paddingLength > 2) {\n throw new Error(\"Base64Coder: incorrect padding\");\n }\n }\n return paddingLength;\n }\n\n}\n\nconst stdCoder = new Coder();\n\nexport function encode(data: Uint8Array): string {\n return stdCoder.encode(data);\n}\n\nexport function decode(s: string): Uint8Array {\n return stdCoder.decode(s);\n}\n\n/**\n * Implements URL-safe Base64 encoding.\n * (Same as Base64, but '+' is replaced with '-', and '/' with '_').\n *\n * Operates in constant time.\n */\nexport class URLSafeCoder extends Coder {\n // URL-safe encoding have the following encoded/decoded ranges:\n //\n // ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 0123456789 - _\n // Index: 0 - 25 26 - 51 52 - 61 62 63\n // ASCII: 65 - 90 97 - 122 48 - 57 45 95\n //\n\n protected _encodeByte(b: number): string {\n let result = b;\n // b >= 0\n result += 65;\n // b > 25\n result += ((25 - b) >>> 8) & ((0 - 65) - 26 + 97);\n // b > 51\n result += ((51 - b) >>> 8) & ((26 - 97) - 52 + 48);\n // b > 61\n result += ((61 - b) >>> 8) & ((52 - 48) - 62 + 45);\n // b > 62\n result += ((62 - b) >>> 8) & ((62 - 45) - 63 + 95);\n\n return String.fromCharCode(result);\n }\n\n protected _decodeChar(c: number): number {\n let result = INVALID_BYTE;\n\n // c == 45 (c > 44 and c < 46)\n result += (((44 - c) & (c - 46)) >>> 8) & (-INVALID_BYTE + c - 45 + 62);\n // c == 95 (c > 94 and c < 96)\n result += (((94 - c) & (c - 96)) >>> 8) & (-INVALID_BYTE + c - 95 + 63);\n // c > 47 and c < 58\n result += (((47 - c) & (c - 58)) >>> 8) & (-INVALID_BYTE + c - 48 + 52);\n // c > 64 and c < 91\n result += (((64 - c) & (c - 91)) >>> 8) & (-INVALID_BYTE + c - 65 + 0);\n // c > 96 and c < 123\n result += (((96 - c) & (c - 123)) >>> 8) & (-INVALID_BYTE + c - 97 + 26);\n\n return result;\n }\n}\n\nconst urlSafeCoder = new URLSafeCoder();\n\nexport function encodeURLSafe(data: Uint8Array): string {\n return urlSafeCoder.encode(data);\n}\n\nexport function decodeURLSafe(s: string): Uint8Array {\n return urlSafeCoder.decode(s);\n}\n\n\nexport const encodedLength = (length: number) =>\n stdCoder.encodedLength(length);\n\nexport const maxDecodedLength = (length: number) =>\n stdCoder.maxDecodedLength(length);\n\nexport const decodedLength = (s: string) =>\n stdCoder.decodedLength(s);\n","// Copyright (C) 2016 Dmitry Chestnykh\n// MIT License. See LICENSE file for details.\n\n/**\n * Package utf8 implements UTF-8 encoding and decoding.\n */\n\nconst INVALID_UTF16 = \"utf8: invalid string\";\nconst INVALID_UTF8 = \"utf8: invalid source encoding\";\n\n/**\n * Encodes the given string into UTF-8 byte array.\n * Throws if the source string has invalid UTF-16 encoding.\n */\nexport function encode(s: string): Uint8Array {\n // Calculate result length and allocate output array.\n // encodedLength() also validates string and throws errors,\n // so we don't need repeat validation here.\n const arr = new Uint8Array(encodedLength(s));\n\n let pos = 0;\n for (let i = 0; i < s.length; i++) {\n let c = s.charCodeAt(i);\n if (c < 0x80) {\n arr[pos++] = c;\n } else if (c < 0x800) {\n arr[pos++] = 0xc0 | c >> 6;\n arr[pos++] = 0x80 | c & 0x3f;\n } else if (c < 0xd800) {\n arr[pos++] = 0xe0 | c >> 12;\n arr[pos++] = 0x80 | (c >> 6) & 0x3f;\n arr[pos++] = 0x80 | c & 0x3f;\n } else {\n i++; // get one more character\n c = (c & 0x3ff) << 10;\n c |= s.charCodeAt(i) & 0x3ff;\n c += 0x10000;\n\n arr[pos++] = 0xf0 | c >> 18;\n arr[pos++] = 0x80 | (c >> 12) & 0x3f;\n arr[pos++] = 0x80 | (c >> 6) & 0x3f;\n arr[pos++] = 0x80 | c & 0x3f;\n }\n }\n return arr;\n}\n\n/**\n * Returns the number of bytes required to encode the given string into UTF-8.\n * Throws if the source string has invalid UTF-16 encoding.\n */\nexport function encodedLength(s: string): number {\n let result = 0;\n for (let i = 0; i < s.length; i++) {\n const c = s.charCodeAt(i);\n if (c < 0x80) {\n result += 1;\n } else if (c < 0x800) {\n result += 2;\n } else if (c < 0xd800) {\n result += 3;\n } else if (c <= 0xdfff) {\n if (i >= s.length - 1) {\n throw new Error(INVALID_UTF16);\n }\n i++; // \"eat\" next character\n result += 4;\n } else {\n throw new Error(INVALID_UTF16);\n }\n }\n return result;\n}\n\n/**\n * Decodes the given byte array from UTF-8 into a string.\n * Throws if encoding is invalid.\n */\nexport function decode(arr: Uint8Array): string {\n const chars: string[] = [];\n for (let i = 0; i < arr.length; i++) {\n let b = arr[i];\n\n if (b & 0x80) {\n let min;\n if (b < 0xe0) {\n // Need 1 more byte.\n if (i >= arr.length) {\n throw new Error(INVALID_UTF8);\n }\n const n1 = arr[++i];\n if ((n1 & 0xc0) !== 0x80) {\n throw new Error(INVALID_UTF8);\n }\n b = (b & 0x1f) << 6 | (n1 & 0x3f);\n min = 0x80;\n } else if (b < 0xf0) {\n // Need 2 more bytes.\n if (i >= arr.length - 1) {\n throw new Error(INVALID_UTF8);\n }\n const n1 = arr[++i];\n const n2 = arr[++i];\n if ((n1 & 0xc0) !== 0x80 || (n2 & 0xc0) !== 0x80) {\n throw new Error(INVALID_UTF8);\n }\n b = (b & 0x0f) << 12 | (n1 & 0x3f) << 6 | (n2 & 0x3f);\n min = 0x800;\n } else if (b < 0xf8) {\n // Need 3 more bytes.\n if (i >= arr.length - 2) {\n throw new Error(INVALID_UTF8);\n }\n const n1 = arr[++i];\n const n2 = arr[++i];\n const n3 = arr[++i];\n if ((n1 & 0xc0) !== 0x80 || (n2 & 0xc0) !== 0x80 || (n3 & 0xc0) !== 0x80) {\n throw new Error(INVALID_UTF8);\n }\n b = (b & 0x0f) << 18 | (n1 & 0x3f) << 12 | (n2 & 0x3f) << 6 | (n3 & 0x3f);\n min = 0x10000;\n } else {\n throw new Error(INVALID_UTF8);\n }\n\n if (b < min || (b >= 0xd800 && b <= 0xdfff)) {\n throw new Error(INVALID_UTF8);\n }\n\n if (b >= 0x10000) {\n // Surrogate pair.\n if (b > 0x10ffff) {\n throw new Error(INVALID_UTF8);\n }\n b -= 0x10000;\n chars.push(String.fromCharCode(0xd800 | (b >> 10)));\n b = 0xdc00 | (b & 0x3ff);\n }\n }\n\n chars.push(String.fromCharCode(b));\n }\n return chars.join(\"\");\n}\n","(function(nacl) {\n'use strict';\n\n// Ported in 2014 by Dmitry Chestnykh and Devi Mandiri.\n// Public domain.\n//\n// Implementation derived from TweetNaCl version 20140427.\n// See for details: http://tweetnacl.cr.yp.to/\n\nvar gf = function(init) {\n var i, r = new Float64Array(16);\n if (init) for (i = 0; i < init.length; i++) r[i] = init[i];\n return r;\n};\n\n// Pluggable, initialized in high-level API below.\nvar randombytes = function(/* x, n */) { throw new Error('no PRNG'); };\n\nvar _0 = new Uint8Array(16);\nvar _9 = new Uint8Array(32); _9[0] = 9;\n\nvar gf0 = gf(),\n gf1 = gf([1]),\n _121665 = gf([0xdb41, 1]),\n D = gf([0x78a3, 0x1359, 0x4dca, 0x75eb, 0xd8ab, 0x4141, 0x0a4d, 0x0070, 0xe898, 0x7779, 0x4079, 0x8cc7, 0xfe73, 0x2b6f, 0x6cee, 0x5203]),\n D2 = gf([0xf159, 0x26b2, 0x9b94, 0xebd6, 0xb156, 0x8283, 0x149a, 0x00e0, 0xd130, 0xeef3, 0x80f2, 0x198e, 0xfce7, 0x56df, 0xd9dc, 0x2406]),\n X = gf([0xd51a, 0x8f25, 0x2d60, 0xc956, 0xa7b2, 0x9525, 0xc760, 0x692c, 0xdc5c, 0xfdd6, 0xe231, 0xc0a4, 0x53fe, 0xcd6e, 0x36d3, 0x2169]),\n Y = gf([0x6658, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666]),\n I = gf([0xa0b0, 0x4a0e, 0x1b27, 0xc4ee, 0xe478, 0xad2f, 0x1806, 0x2f43, 0xd7a7, 0x3dfb, 0x0099, 0x2b4d, 0xdf0b, 0x4fc1, 0x2480, 0x2b83]);\n\nfunction ts64(x, i, h, l) {\n x[i] = (h >> 24) & 0xff;\n x[i+1] = (h >> 16) & 0xff;\n x[i+2] = (h >> 8) & 0xff;\n x[i+3] = h & 0xff;\n x[i+4] = (l >> 24) & 0xff;\n x[i+5] = (l >> 16) & 0xff;\n x[i+6] = (l >> 8) & 0xff;\n x[i+7] = l & 0xff;\n}\n\nfunction vn(x, xi, y, yi, n) {\n var i,d = 0;\n for (i = 0; i < n; i++) d |= x[xi+i]^y[yi+i];\n return (1 & ((d - 1) >>> 8)) - 1;\n}\n\nfunction crypto_verify_16(x, xi, y, yi) {\n return vn(x,xi,y,yi,16);\n}\n\nfunction crypto_verify_32(x, xi, y, yi) {\n return vn(x,xi,y,yi,32);\n}\n\nfunction core_salsa20(o, p, k, c) {\n var j0 = c[ 0] & 0xff | (c[ 1] & 0xff)<<8 | (c[ 2] & 0xff)<<16 | (c[ 3] & 0xff)<<24,\n j1 = k[ 0] & 0xff | (k[ 1] & 0xff)<<8 | (k[ 2] & 0xff)<<16 | (k[ 3] & 0xff)<<24,\n j2 = k[ 4] & 0xff | (k[ 5] & 0xff)<<8 | (k[ 6] & 0xff)<<16 | (k[ 7] & 0xff)<<24,\n j3 = k[ 8] & 0xff | (k[ 9] & 0xff)<<8 | (k[10] & 0xff)<<16 | (k[11] & 0xff)<<24,\n j4 = k[12] & 0xff | (k[13] & 0xff)<<8 | (k[14] & 0xff)<<16 | (k[15] & 0xff)<<24,\n j5 = c[ 4] & 0xff | (c[ 5] & 0xff)<<8 | (c[ 6] & 0xff)<<16 | (c[ 7] & 0xff)<<24,\n j6 = p[ 0] & 0xff | (p[ 1] & 0xff)<<8 | (p[ 2] & 0xff)<<16 | (p[ 3] & 0xff)<<24,\n j7 = p[ 4] & 0xff | (p[ 5] & 0xff)<<8 | (p[ 6] & 0xff)<<16 | (p[ 7] & 0xff)<<24,\n j8 = p[ 8] & 0xff | (p[ 9] & 0xff)<<8 | (p[10] & 0xff)<<16 | (p[11] & 0xff)<<24,\n j9 = p[12] & 0xff | (p[13] & 0xff)<<8 | (p[14] & 0xff)<<16 | (p[15] & 0xff)<<24,\n j10 = c[ 8] & 0xff | (c[ 9] & 0xff)<<8 | (c[10] & 0xff)<<16 | (c[11] & 0xff)<<24,\n j11 = k[16] & 0xff | (k[17] & 0xff)<<8 | (k[18] & 0xff)<<16 | (k[19] & 0xff)<<24,\n j12 = k[20] & 0xff | (k[21] & 0xff)<<8 | (k[22] & 0xff)<<16 | (k[23] & 0xff)<<24,\n j13 = k[24] & 0xff | (k[25] & 0xff)<<8 | (k[26] & 0xff)<<16 | (k[27] & 0xff)<<24,\n j14 = k[28] & 0xff | (k[29] & 0xff)<<8 | (k[30] & 0xff)<<16 | (k[31] & 0xff)<<24,\n j15 = c[12] & 0xff | (c[13] & 0xff)<<8 | (c[14] & 0xff)<<16 | (c[15] & 0xff)<<24;\n\n var x0 = j0, x1 = j1, x2 = j2, x3 = j3, x4 = j4, x5 = j5, x6 = j6, x7 = j7,\n x8 = j8, x9 = j9, x10 = j10, x11 = j11, x12 = j12, x13 = j13, x14 = j14,\n x15 = j15, u;\n\n for (var i = 0; i < 20; i += 2) {\n u = x0 + x12 | 0;\n x4 ^= u<<7 | u>>>(32-7);\n u = x4 + x0 | 0;\n x8 ^= u<<9 | u>>>(32-9);\n u = x8 + x4 | 0;\n x12 ^= u<<13 | u>>>(32-13);\n u = x12 + x8 | 0;\n x0 ^= u<<18 | u>>>(32-18);\n\n u = x5 + x1 | 0;\n x9 ^= u<<7 | u>>>(32-7);\n u = x9 + x5 | 0;\n x13 ^= u<<9 | u>>>(32-9);\n u = x13 + x9 | 0;\n x1 ^= u<<13 | u>>>(32-13);\n u = x1 + x13 | 0;\n x5 ^= u<<18 | u>>>(32-18);\n\n u = x10 + x6 | 0;\n x14 ^= u<<7 | u>>>(32-7);\n u = x14 + x10 | 0;\n x2 ^= u<<9 | u>>>(32-9);\n u = x2 + x14 | 0;\n x6 ^= u<<13 | u>>>(32-13);\n u = x6 + x2 | 0;\n x10 ^= u<<18 | u>>>(32-18);\n\n u = x15 + x11 | 0;\n x3 ^= u<<7 | u>>>(32-7);\n u = x3 + x15 | 0;\n x7 ^= u<<9 | u>>>(32-9);\n u = x7 + x3 | 0;\n x11 ^= u<<13 | u>>>(32-13);\n u = x11 + x7 | 0;\n x15 ^= u<<18 | u>>>(32-18);\n\n u = x0 + x3 | 0;\n x1 ^= u<<7 | u>>>(32-7);\n u = x1 + x0 | 0;\n x2 ^= u<<9 | u>>>(32-9);\n u = x2 + x1 | 0;\n x3 ^= u<<13 | u>>>(32-13);\n u = x3 + x2 | 0;\n x0 ^= u<<18 | u>>>(32-18);\n\n u = x5 + x4 | 0;\n x6 ^= u<<7 | u>>>(32-7);\n u = x6 + x5 | 0;\n x7 ^= u<<9 | u>>>(32-9);\n u = x7 + x6 | 0;\n x4 ^= u<<13 | u>>>(32-13);\n u = x4 + x7 | 0;\n x5 ^= u<<18 | u>>>(32-18);\n\n u = x10 + x9 | 0;\n x11 ^= u<<7 | u>>>(32-7);\n u = x11 + x10 | 0;\n x8 ^= u<<9 | u>>>(32-9);\n u = x8 + x11 | 0;\n x9 ^= u<<13 | u>>>(32-13);\n u = x9 + x8 | 0;\n x10 ^= u<<18 | u>>>(32-18);\n\n u = x15 + x14 | 0;\n x12 ^= u<<7 | u>>>(32-7);\n u = x12 + x15 | 0;\n x13 ^= u<<9 | u>>>(32-9);\n u = x13 + x12 | 0;\n x14 ^= u<<13 | u>>>(32-13);\n u = x14 + x13 | 0;\n x15 ^= u<<18 | u>>>(32-18);\n }\n x0 = x0 + j0 | 0;\n x1 = x1 + j1 | 0;\n x2 = x2 + j2 | 0;\n x3 = x3 + j3 | 0;\n x4 = x4 + j4 | 0;\n x5 = x5 + j5 | 0;\n x6 = x6 + j6 | 0;\n x7 = x7 + j7 | 0;\n x8 = x8 + j8 | 0;\n x9 = x9 + j9 | 0;\n x10 = x10 + j10 | 0;\n x11 = x11 + j11 | 0;\n x12 = x12 + j12 | 0;\n x13 = x13 + j13 | 0;\n x14 = x14 + j14 | 0;\n x15 = x15 + j15 | 0;\n\n o[ 0] = x0 >>> 0 & 0xff;\n o[ 1] = x0 >>> 8 & 0xff;\n o[ 2] = x0 >>> 16 & 0xff;\n o[ 3] = x0 >>> 24 & 0xff;\n\n o[ 4] = x1 >>> 0 & 0xff;\n o[ 5] = x1 >>> 8 & 0xff;\n o[ 6] = x1 >>> 16 & 0xff;\n o[ 7] = x1 >>> 24 & 0xff;\n\n o[ 8] = x2 >>> 0 & 0xff;\n o[ 9] = x2 >>> 8 & 0xff;\n o[10] = x2 >>> 16 & 0xff;\n o[11] = x2 >>> 24 & 0xff;\n\n o[12] = x3 >>> 0 & 0xff;\n o[13] = x3 >>> 8 & 0xff;\n o[14] = x3 >>> 16 & 0xff;\n o[15] = x3 >>> 24 & 0xff;\n\n o[16] = x4 >>> 0 & 0xff;\n o[17] = x4 >>> 8 & 0xff;\n o[18] = x4 >>> 16 & 0xff;\n o[19] = x4 >>> 24 & 0xff;\n\n o[20] = x5 >>> 0 & 0xff;\n o[21] = x5 >>> 8 & 0xff;\n o[22] = x5 >>> 16 & 0xff;\n o[23] = x5 >>> 24 & 0xff;\n\n o[24] = x6 >>> 0 & 0xff;\n o[25] = x6 >>> 8 & 0xff;\n o[26] = x6 >>> 16 & 0xff;\n o[27] = x6 >>> 24 & 0xff;\n\n o[28] = x7 >>> 0 & 0xff;\n o[29] = x7 >>> 8 & 0xff;\n o[30] = x7 >>> 16 & 0xff;\n o[31] = x7 >>> 24 & 0xff;\n\n o[32] = x8 >>> 0 & 0xff;\n o[33] = x8 >>> 8 & 0xff;\n o[34] = x8 >>> 16 & 0xff;\n o[35] = x8 >>> 24 & 0xff;\n\n o[36] = x9 >>> 0 & 0xff;\n o[37] = x9 >>> 8 & 0xff;\n o[38] = x9 >>> 16 & 0xff;\n o[39] = x9 >>> 24 & 0xff;\n\n o[40] = x10 >>> 0 & 0xff;\n o[41] = x10 >>> 8 & 0xff;\n o[42] = x10 >>> 16 & 0xff;\n o[43] = x10 >>> 24 & 0xff;\n\n o[44] = x11 >>> 0 & 0xff;\n o[45] = x11 >>> 8 & 0xff;\n o[46] = x11 >>> 16 & 0xff;\n o[47] = x11 >>> 24 & 0xff;\n\n o[48] = x12 >>> 0 & 0xff;\n o[49] = x12 >>> 8 & 0xff;\n o[50] = x12 >>> 16 & 0xff;\n o[51] = x12 >>> 24 & 0xff;\n\n o[52] = x13 >>> 0 & 0xff;\n o[53] = x13 >>> 8 & 0xff;\n o[54] = x13 >>> 16 & 0xff;\n o[55] = x13 >>> 24 & 0xff;\n\n o[56] = x14 >>> 0 & 0xff;\n o[57] = x14 >>> 8 & 0xff;\n o[58] = x14 >>> 16 & 0xff;\n o[59] = x14 >>> 24 & 0xff;\n\n o[60] = x15 >>> 0 & 0xff;\n o[61] = x15 >>> 8 & 0xff;\n o[62] = x15 >>> 16 & 0xff;\n o[63] = x15 >>> 24 & 0xff;\n}\n\nfunction core_hsalsa20(o,p,k,c) {\n var j0 = c[ 0] & 0xff | (c[ 1] & 0xff)<<8 | (c[ 2] & 0xff)<<16 | (c[ 3] & 0xff)<<24,\n j1 = k[ 0] & 0xff | (k[ 1] & 0xff)<<8 | (k[ 2] & 0xff)<<16 | (k[ 3] & 0xff)<<24,\n j2 = k[ 4] & 0xff | (k[ 5] & 0xff)<<8 | (k[ 6] & 0xff)<<16 | (k[ 7] & 0xff)<<24,\n j3 = k[ 8] & 0xff | (k[ 9] & 0xff)<<8 | (k[10] & 0xff)<<16 | (k[11] & 0xff)<<24,\n j4 = k[12] & 0xff | (k[13] & 0xff)<<8 | (k[14] & 0xff)<<16 | (k[15] & 0xff)<<24,\n j5 = c[ 4] & 0xff | (c[ 5] & 0xff)<<8 | (c[ 6] & 0xff)<<16 | (c[ 7] & 0xff)<<24,\n j6 = p[ 0] & 0xff | (p[ 1] & 0xff)<<8 | (p[ 2] & 0xff)<<16 | (p[ 3] & 0xff)<<24,\n j7 = p[ 4] & 0xff | (p[ 5] & 0xff)<<8 | (p[ 6] & 0xff)<<16 | (p[ 7] & 0xff)<<24,\n j8 = p[ 8] & 0xff | (p[ 9] & 0xff)<<8 | (p[10] & 0xff)<<16 | (p[11] & 0xff)<<24,\n j9 = p[12] & 0xff | (p[13] & 0xff)<<8 | (p[14] & 0xff)<<16 | (p[15] & 0xff)<<24,\n j10 = c[ 8] & 0xff | (c[ 9] & 0xff)<<8 | (c[10] & 0xff)<<16 | (c[11] & 0xff)<<24,\n j11 = k[16] & 0xff | (k[17] & 0xff)<<8 | (k[18] & 0xff)<<16 | (k[19] & 0xff)<<24,\n j12 = k[20] & 0xff | (k[21] & 0xff)<<8 | (k[22] & 0xff)<<16 | (k[23] & 0xff)<<24,\n j13 = k[24] & 0xff | (k[25] & 0xff)<<8 | (k[26] & 0xff)<<16 | (k[27] & 0xff)<<24,\n j14 = k[28] & 0xff | (k[29] & 0xff)<<8 | (k[30] & 0xff)<<16 | (k[31] & 0xff)<<24,\n j15 = c[12] & 0xff | (c[13] & 0xff)<<8 | (c[14] & 0xff)<<16 | (c[15] & 0xff)<<24;\n\n var x0 = j0, x1 = j1, x2 = j2, x3 = j3, x4 = j4, x5 = j5, x6 = j6, x7 = j7,\n x8 = j8, x9 = j9, x10 = j10, x11 = j11, x12 = j12, x13 = j13, x14 = j14,\n x15 = j15, u;\n\n for (var i = 0; i < 20; i += 2) {\n u = x0 + x12 | 0;\n x4 ^= u<<7 | u>>>(32-7);\n u = x4 + x0 | 0;\n x8 ^= u<<9 | u>>>(32-9);\n u = x8 + x4 | 0;\n x12 ^= u<<13 | u>>>(32-13);\n u = x12 + x8 | 0;\n x0 ^= u<<18 | u>>>(32-18);\n\n u = x5 + x1 | 0;\n x9 ^= u<<7 | u>>>(32-7);\n u = x9 + x5 | 0;\n x13 ^= u<<9 | u>>>(32-9);\n u = x13 + x9 | 0;\n x1 ^= u<<13 | u>>>(32-13);\n u = x1 + x13 | 0;\n x5 ^= u<<18 | u>>>(32-18);\n\n u = x10 + x6 | 0;\n x14 ^= u<<7 | u>>>(32-7);\n u = x14 + x10 | 0;\n x2 ^= u<<9 | u>>>(32-9);\n u = x2 + x14 | 0;\n x6 ^= u<<13 | u>>>(32-13);\n u = x6 + x2 | 0;\n x10 ^= u<<18 | u>>>(32-18);\n\n u = x15 + x11 | 0;\n x3 ^= u<<7 | u>>>(32-7);\n u = x3 + x15 | 0;\n x7 ^= u<<9 | u>>>(32-9);\n u = x7 + x3 | 0;\n x11 ^= u<<13 | u>>>(32-13);\n u = x11 + x7 | 0;\n x15 ^= u<<18 | u>>>(32-18);\n\n u = x0 + x3 | 0;\n x1 ^= u<<7 | u>>>(32-7);\n u = x1 + x0 | 0;\n x2 ^= u<<9 | u>>>(32-9);\n u = x2 + x1 | 0;\n x3 ^= u<<13 | u>>>(32-13);\n u = x3 + x2 | 0;\n x0 ^= u<<18 | u>>>(32-18);\n\n u = x5 + x4 | 0;\n x6 ^= u<<7 | u>>>(32-7);\n u = x6 + x5 | 0;\n x7 ^= u<<9 | u>>>(32-9);\n u = x7 + x6 | 0;\n x4 ^= u<<13 | u>>>(32-13);\n u = x4 + x7 | 0;\n x5 ^= u<<18 | u>>>(32-18);\n\n u = x10 + x9 | 0;\n x11 ^= u<<7 | u>>>(32-7);\n u = x11 + x10 | 0;\n x8 ^= u<<9 | u>>>(32-9);\n u = x8 + x11 | 0;\n x9 ^= u<<13 | u>>>(32-13);\n u = x9 + x8 | 0;\n x10 ^= u<<18 | u>>>(32-18);\n\n u = x15 + x14 | 0;\n x12 ^= u<<7 | u>>>(32-7);\n u = x12 + x15 | 0;\n x13 ^= u<<9 | u>>>(32-9);\n u = x13 + x12 | 0;\n x14 ^= u<<13 | u>>>(32-13);\n u = x14 + x13 | 0;\n x15 ^= u<<18 | u>>>(32-18);\n }\n\n o[ 0] = x0 >>> 0 & 0xff;\n o[ 1] = x0 >>> 8 & 0xff;\n o[ 2] = x0 >>> 16 & 0xff;\n o[ 3] = x0 >>> 24 & 0xff;\n\n o[ 4] = x5 >>> 0 & 0xff;\n o[ 5] = x5 >>> 8 & 0xff;\n o[ 6] = x5 >>> 16 & 0xff;\n o[ 7] = x5 >>> 24 & 0xff;\n\n o[ 8] = x10 >>> 0 & 0xff;\n o[ 9] = x10 >>> 8 & 0xff;\n o[10] = x10 >>> 16 & 0xff;\n o[11] = x10 >>> 24 & 0xff;\n\n o[12] = x15 >>> 0 & 0xff;\n o[13] = x15 >>> 8 & 0xff;\n o[14] = x15 >>> 16 & 0xff;\n o[15] = x15 >>> 24 & 0xff;\n\n o[16] = x6 >>> 0 & 0xff;\n o[17] = x6 >>> 8 & 0xff;\n o[18] = x6 >>> 16 & 0xff;\n o[19] = x6 >>> 24 & 0xff;\n\n o[20] = x7 >>> 0 & 0xff;\n o[21] = x7 >>> 8 & 0xff;\n o[22] = x7 >>> 16 & 0xff;\n o[23] = x7 >>> 24 & 0xff;\n\n o[24] = x8 >>> 0 & 0xff;\n o[25] = x8 >>> 8 & 0xff;\n o[26] = x8 >>> 16 & 0xff;\n o[27] = x8 >>> 24 & 0xff;\n\n o[28] = x9 >>> 0 & 0xff;\n o[29] = x9 >>> 8 & 0xff;\n o[30] = x9 >>> 16 & 0xff;\n o[31] = x9 >>> 24 & 0xff;\n}\n\nfunction crypto_core_salsa20(out,inp,k,c) {\n core_salsa20(out,inp,k,c);\n}\n\nfunction crypto_core_hsalsa20(out,inp,k,c) {\n core_hsalsa20(out,inp,k,c);\n}\n\nvar sigma = new Uint8Array([101, 120, 112, 97, 110, 100, 32, 51, 50, 45, 98, 121, 116, 101, 32, 107]);\n // \"expand 32-byte k\"\n\nfunction crypto_stream_salsa20_xor(c,cpos,m,mpos,b,n,k) {\n var z = new Uint8Array(16), x = new Uint8Array(64);\n var u, i;\n for (i = 0; i < 16; i++) z[i] = 0;\n for (i = 0; i < 8; i++) z[i] = n[i];\n while (b >= 64) {\n crypto_core_salsa20(x,z,k,sigma);\n for (i = 0; i < 64; i++) c[cpos+i] = m[mpos+i] ^ x[i];\n u = 1;\n for (i = 8; i < 16; i++) {\n u = u + (z[i] & 0xff) | 0;\n z[i] = u & 0xff;\n u >>>= 8;\n }\n b -= 64;\n cpos += 64;\n mpos += 64;\n }\n if (b > 0) {\n crypto_core_salsa20(x,z,k,sigma);\n for (i = 0; i < b; i++) c[cpos+i] = m[mpos+i] ^ x[i];\n }\n return 0;\n}\n\nfunction crypto_stream_salsa20(c,cpos,b,n,k) {\n var z = new Uint8Array(16), x = new Uint8Array(64);\n var u, i;\n for (i = 0; i < 16; i++) z[i] = 0;\n for (i = 0; i < 8; i++) z[i] = n[i];\n while (b >= 64) {\n crypto_core_salsa20(x,z,k,sigma);\n for (i = 0; i < 64; i++) c[cpos+i] = x[i];\n u = 1;\n for (i = 8; i < 16; i++) {\n u = u + (z[i] & 0xff) | 0;\n z[i] = u & 0xff;\n u >>>= 8;\n }\n b -= 64;\n cpos += 64;\n }\n if (b > 0) {\n crypto_core_salsa20(x,z,k,sigma);\n for (i = 0; i < b; i++) c[cpos+i] = x[i];\n }\n return 0;\n}\n\nfunction crypto_stream(c,cpos,d,n,k) {\n var s = new Uint8Array(32);\n crypto_core_hsalsa20(s,n,k,sigma);\n var sn = new Uint8Array(8);\n for (var i = 0; i < 8; i++) sn[i] = n[i+16];\n return crypto_stream_salsa20(c,cpos,d,sn,s);\n}\n\nfunction crypto_stream_xor(c,cpos,m,mpos,d,n,k) {\n var s = new Uint8Array(32);\n crypto_core_hsalsa20(s,n,k,sigma);\n var sn = new Uint8Array(8);\n for (var i = 0; i < 8; i++) sn[i] = n[i+16];\n return crypto_stream_salsa20_xor(c,cpos,m,mpos,d,sn,s);\n}\n\n/*\n* Port of Andrew Moon's Poly1305-donna-16. Public domain.\n* https://github.com/floodyberry/poly1305-donna\n*/\n\nvar poly1305 = function(key) {\n this.buffer = new Uint8Array(16);\n this.r = new Uint16Array(10);\n this.h = new Uint16Array(10);\n this.pad = new Uint16Array(8);\n this.leftover = 0;\n this.fin = 0;\n\n var t0, t1, t2, t3, t4, t5, t6, t7;\n\n t0 = key[ 0] & 0xff | (key[ 1] & 0xff) << 8; this.r[0] = ( t0 ) & 0x1fff;\n t1 = key[ 2] & 0xff | (key[ 3] & 0xff) << 8; this.r[1] = ((t0 >>> 13) | (t1 << 3)) & 0x1fff;\n t2 = key[ 4] & 0xff | (key[ 5] & 0xff) << 8; this.r[2] = ((t1 >>> 10) | (t2 << 6)) & 0x1f03;\n t3 = key[ 6] & 0xff | (key[ 7] & 0xff) << 8; this.r[3] = ((t2 >>> 7) | (t3 << 9)) & 0x1fff;\n t4 = key[ 8] & 0xff | (key[ 9] & 0xff) << 8; this.r[4] = ((t3 >>> 4) | (t4 << 12)) & 0x00ff;\n this.r[5] = ((t4 >>> 1)) & 0x1ffe;\n t5 = key[10] & 0xff | (key[11] & 0xff) << 8; this.r[6] = ((t4 >>> 14) | (t5 << 2)) & 0x1fff;\n t6 = key[12] & 0xff | (key[13] & 0xff) << 8; this.r[7] = ((t5 >>> 11) | (t6 << 5)) & 0x1f81;\n t7 = key[14] & 0xff | (key[15] & 0xff) << 8; this.r[8] = ((t6 >>> 8) | (t7 << 8)) & 0x1fff;\n this.r[9] = ((t7 >>> 5)) & 0x007f;\n\n this.pad[0] = key[16] & 0xff | (key[17] & 0xff) << 8;\n this.pad[1] = key[18] & 0xff | (key[19] & 0xff) << 8;\n this.pad[2] = key[20] & 0xff | (key[21] & 0xff) << 8;\n this.pad[3] = key[22] & 0xff | (key[23] & 0xff) << 8;\n this.pad[4] = key[24] & 0xff | (key[25] & 0xff) << 8;\n this.pad[5] = key[26] & 0xff | (key[27] & 0xff) << 8;\n this.pad[6] = key[28] & 0xff | (key[29] & 0xff) << 8;\n this.pad[7] = key[30] & 0xff | (key[31] & 0xff) << 8;\n};\n\npoly1305.prototype.blocks = function(m, mpos, bytes) {\n var hibit = this.fin ? 0 : (1 << 11);\n var t0, t1, t2, t3, t4, t5, t6, t7, c;\n var d0, d1, d2, d3, d4, d5, d6, d7, d8, d9;\n\n var h0 = this.h[0],\n h1 = this.h[1],\n h2 = this.h[2],\n h3 = this.h[3],\n h4 = this.h[4],\n h5 = this.h[5],\n h6 = this.h[6],\n h7 = this.h[7],\n h8 = this.h[8],\n h9 = this.h[9];\n\n var r0 = this.r[0],\n r1 = this.r[1],\n r2 = this.r[2],\n r3 = this.r[3],\n r4 = this.r[4],\n r5 = this.r[5],\n r6 = this.r[6],\n r7 = this.r[7],\n r8 = this.r[8],\n r9 = this.r[9];\n\n while (bytes >= 16) {\n t0 = m[mpos+ 0] & 0xff | (m[mpos+ 1] & 0xff) << 8; h0 += ( t0 ) & 0x1fff;\n t1 = m[mpos+ 2] & 0xff | (m[mpos+ 3] & 0xff) << 8; h1 += ((t0 >>> 13) | (t1 << 3)) & 0x1fff;\n t2 = m[mpos+ 4] & 0xff | (m[mpos+ 5] & 0xff) << 8; h2 += ((t1 >>> 10) | (t2 << 6)) & 0x1fff;\n t3 = m[mpos+ 6] & 0xff | (m[mpos+ 7] & 0xff) << 8; h3 += ((t2 >>> 7) | (t3 << 9)) & 0x1fff;\n t4 = m[mpos+ 8] & 0xff | (m[mpos+ 9] & 0xff) << 8; h4 += ((t3 >>> 4) | (t4 << 12)) & 0x1fff;\n h5 += ((t4 >>> 1)) & 0x1fff;\n t5 = m[mpos+10] & 0xff | (m[mpos+11] & 0xff) << 8; h6 += ((t4 >>> 14) | (t5 << 2)) & 0x1fff;\n t6 = m[mpos+12] & 0xff | (m[mpos+13] & 0xff) << 8; h7 += ((t5 >>> 11) | (t6 << 5)) & 0x1fff;\n t7 = m[mpos+14] & 0xff | (m[mpos+15] & 0xff) << 8; h8 += ((t6 >>> 8) | (t7 << 8)) & 0x1fff;\n h9 += ((t7 >>> 5)) | hibit;\n\n c = 0;\n\n d0 = c;\n d0 += h0 * r0;\n d0 += h1 * (5 * r9);\n d0 += h2 * (5 * r8);\n d0 += h3 * (5 * r7);\n d0 += h4 * (5 * r6);\n c = (d0 >>> 13); d0 &= 0x1fff;\n d0 += h5 * (5 * r5);\n d0 += h6 * (5 * r4);\n d0 += h7 * (5 * r3);\n d0 += h8 * (5 * r2);\n d0 += h9 * (5 * r1);\n c += (d0 >>> 13); d0 &= 0x1fff;\n\n d1 = c;\n d1 += h0 * r1;\n d1 += h1 * r0;\n d1 += h2 * (5 * r9);\n d1 += h3 * (5 * r8);\n d1 += h4 * (5 * r7);\n c = (d1 >>> 13); d1 &= 0x1fff;\n d1 += h5 * (5 * r6);\n d1 += h6 * (5 * r5);\n d1 += h7 * (5 * r4);\n d1 += h8 * (5 * r3);\n d1 += h9 * (5 * r2);\n c += (d1 >>> 13); d1 &= 0x1fff;\n\n d2 = c;\n d2 += h0 * r2;\n d2 += h1 * r1;\n d2 += h2 * r0;\n d2 += h3 * (5 * r9);\n d2 += h4 * (5 * r8);\n c = (d2 >>> 13); d2 &= 0x1fff;\n d2 += h5 * (5 * r7);\n d2 += h6 * (5 * r6);\n d2 += h7 * (5 * r5);\n d2 += h8 * (5 * r4);\n d2 += h9 * (5 * r3);\n c += (d2 >>> 13); d2 &= 0x1fff;\n\n d3 = c;\n d3 += h0 * r3;\n d3 += h1 * r2;\n d3 += h2 * r1;\n d3 += h3 * r0;\n d3 += h4 * (5 * r9);\n c = (d3 >>> 13); d3 &= 0x1fff;\n d3 += h5 * (5 * r8);\n d3 += h6 * (5 * r7);\n d3 += h7 * (5 * r6);\n d3 += h8 * (5 * r5);\n d3 += h9 * (5 * r4);\n c += (d3 >>> 13); d3 &= 0x1fff;\n\n d4 = c;\n d4 += h0 * r4;\n d4 += h1 * r3;\n d4 += h2 * r2;\n d4 += h3 * r1;\n d4 += h4 * r0;\n c = (d4 >>> 13); d4 &= 0x1fff;\n d4 += h5 * (5 * r9);\n d4 += h6 * (5 * r8);\n d4 += h7 * (5 * r7);\n d4 += h8 * (5 * r6);\n d4 += h9 * (5 * r5);\n c += (d4 >>> 13); d4 &= 0x1fff;\n\n d5 = c;\n d5 += h0 * r5;\n d5 += h1 * r4;\n d5 += h2 * r3;\n d5 += h3 * r2;\n d5 += h4 * r1;\n c = (d5 >>> 13); d5 &= 0x1fff;\n d5 += h5 * r0;\n d5 += h6 * (5 * r9);\n d5 += h7 * (5 * r8);\n d5 += h8 * (5 * r7);\n d5 += h9 * (5 * r6);\n c += (d5 >>> 13); d5 &= 0x1fff;\n\n d6 = c;\n d6 += h0 * r6;\n d6 += h1 * r5;\n d6 += h2 * r4;\n d6 += h3 * r3;\n d6 += h4 * r2;\n c = (d6 >>> 13); d6 &= 0x1fff;\n d6 += h5 * r1;\n d6 += h6 * r0;\n d6 += h7 * (5 * r9);\n d6 += h8 * (5 * r8);\n d6 += h9 * (5 * r7);\n c += (d6 >>> 13); d6 &= 0x1fff;\n\n d7 = c;\n d7 += h0 * r7;\n d7 += h1 * r6;\n d7 += h2 * r5;\n d7 += h3 * r4;\n d7 += h4 * r3;\n c = (d7 >>> 13); d7 &= 0x1fff;\n d7 += h5 * r2;\n d7 += h6 * r1;\n d7 += h7 * r0;\n d7 += h8 * (5 * r9);\n d7 += h9 * (5 * r8);\n c += (d7 >>> 13); d7 &= 0x1fff;\n\n d8 = c;\n d8 += h0 * r8;\n d8 += h1 * r7;\n d8 += h2 * r6;\n d8 += h3 * r5;\n d8 += h4 * r4;\n c = (d8 >>> 13); d8 &= 0x1fff;\n d8 += h5 * r3;\n d8 += h6 * r2;\n d8 += h7 * r1;\n d8 += h8 * r0;\n d8 += h9 * (5 * r9);\n c += (d8 >>> 13); d8 &= 0x1fff;\n\n d9 = c;\n d9 += h0 * r9;\n d9 += h1 * r8;\n d9 += h2 * r7;\n d9 += h3 * r6;\n d9 += h4 * r5;\n c = (d9 >>> 13); d9 &= 0x1fff;\n d9 += h5 * r4;\n d9 += h6 * r3;\n d9 += h7 * r2;\n d9 += h8 * r1;\n d9 += h9 * r0;\n c += (d9 >>> 13); d9 &= 0x1fff;\n\n c = (((c << 2) + c)) | 0;\n c = (c + d0) | 0;\n d0 = c & 0x1fff;\n c = (c >>> 13);\n d1 += c;\n\n h0 = d0;\n h1 = d1;\n h2 = d2;\n h3 = d3;\n h4 = d4;\n h5 = d5;\n h6 = d6;\n h7 = d7;\n h8 = d8;\n h9 = d9;\n\n mpos += 16;\n bytes -= 16;\n }\n this.h[0] = h0;\n this.h[1] = h1;\n this.h[2] = h2;\n this.h[3] = h3;\n this.h[4] = h4;\n this.h[5] = h5;\n this.h[6] = h6;\n this.h[7] = h7;\n this.h[8] = h8;\n this.h[9] = h9;\n};\n\npoly1305.prototype.finish = function(mac, macpos) {\n var g = new Uint16Array(10);\n var c, mask, f, i;\n\n if (this.leftover) {\n i = this.leftover;\n this.buffer[i++] = 1;\n for (; i < 16; i++) this.buffer[i] = 0;\n this.fin = 1;\n this.blocks(this.buffer, 0, 16);\n }\n\n c = this.h[1] >>> 13;\n this.h[1] &= 0x1fff;\n for (i = 2; i < 10; i++) {\n this.h[i] += c;\n c = this.h[i] >>> 13;\n this.h[i] &= 0x1fff;\n }\n this.h[0] += (c * 5);\n c = this.h[0] >>> 13;\n this.h[0] &= 0x1fff;\n this.h[1] += c;\n c = this.h[1] >>> 13;\n this.h[1] &= 0x1fff;\n this.h[2] += c;\n\n g[0] = this.h[0] + 5;\n c = g[0] >>> 13;\n g[0] &= 0x1fff;\n for (i = 1; i < 10; i++) {\n g[i] = this.h[i] + c;\n c = g[i] >>> 13;\n g[i] &= 0x1fff;\n }\n g[9] -= (1 << 13);\n\n mask = (c ^ 1) - 1;\n for (i = 0; i < 10; i++) g[i] &= mask;\n mask = ~mask;\n for (i = 0; i < 10; i++) this.h[i] = (this.h[i] & mask) | g[i];\n\n this.h[0] = ((this.h[0] ) | (this.h[1] << 13) ) & 0xffff;\n this.h[1] = ((this.h[1] >>> 3) | (this.h[2] << 10) ) & 0xffff;\n this.h[2] = ((this.h[2] >>> 6) | (this.h[3] << 7) ) & 0xffff;\n this.h[3] = ((this.h[3] >>> 9) | (this.h[4] << 4) ) & 0xffff;\n this.h[4] = ((this.h[4] >>> 12) | (this.h[5] << 1) | (this.h[6] << 14)) & 0xffff;\n this.h[5] = ((this.h[6] >>> 2) | (this.h[7] << 11) ) & 0xffff;\n this.h[6] = ((this.h[7] >>> 5) | (this.h[8] << 8) ) & 0xffff;\n this.h[7] = ((this.h[8] >>> 8) | (this.h[9] << 5) ) & 0xffff;\n\n f = this.h[0] + this.pad[0];\n this.h[0] = f & 0xffff;\n for (i = 1; i < 8; i++) {\n f = (((this.h[i] + this.pad[i]) | 0) + (f >>> 16)) | 0;\n this.h[i] = f & 0xffff;\n }\n\n mac[macpos+ 0] = (this.h[0] >>> 0) & 0xff;\n mac[macpos+ 1] = (this.h[0] >>> 8) & 0xff;\n mac[macpos+ 2] = (this.h[1] >>> 0) & 0xff;\n mac[macpos+ 3] = (this.h[1] >>> 8) & 0xff;\n mac[macpos+ 4] = (this.h[2] >>> 0) & 0xff;\n mac[macpos+ 5] = (this.h[2] >>> 8) & 0xff;\n mac[macpos+ 6] = (this.h[3] >>> 0) & 0xff;\n mac[macpos+ 7] = (this.h[3] >>> 8) & 0xff;\n mac[macpos+ 8] = (this.h[4] >>> 0) & 0xff;\n mac[macpos+ 9] = (this.h[4] >>> 8) & 0xff;\n mac[macpos+10] = (this.h[5] >>> 0) & 0xff;\n mac[macpos+11] = (this.h[5] >>> 8) & 0xff;\n mac[macpos+12] = (this.h[6] >>> 0) & 0xff;\n mac[macpos+13] = (this.h[6] >>> 8) & 0xff;\n mac[macpos+14] = (this.h[7] >>> 0) & 0xff;\n mac[macpos+15] = (this.h[7] >>> 8) & 0xff;\n};\n\npoly1305.prototype.update = function(m, mpos, bytes) {\n var i, want;\n\n if (this.leftover) {\n want = (16 - this.leftover);\n if (want > bytes)\n want = bytes;\n for (i = 0; i < want; i++)\n this.buffer[this.leftover + i] = m[mpos+i];\n bytes -= want;\n mpos += want;\n this.leftover += want;\n if (this.leftover < 16)\n return;\n this.blocks(this.buffer, 0, 16);\n this.leftover = 0;\n }\n\n if (bytes >= 16) {\n want = bytes - (bytes % 16);\n this.blocks(m, mpos, want);\n mpos += want;\n bytes -= want;\n }\n\n if (bytes) {\n for (i = 0; i < bytes; i++)\n this.buffer[this.leftover + i] = m[mpos+i];\n this.leftover += bytes;\n }\n};\n\nfunction crypto_onetimeauth(out, outpos, m, mpos, n, k) {\n var s = new poly1305(k);\n s.update(m, mpos, n);\n s.finish(out, outpos);\n return 0;\n}\n\nfunction crypto_onetimeauth_verify(h, hpos, m, mpos, n, k) {\n var x = new Uint8Array(16);\n crypto_onetimeauth(x,0,m,mpos,n,k);\n return crypto_verify_16(h,hpos,x,0);\n}\n\nfunction crypto_secretbox(c,m,d,n,k) {\n var i;\n if (d < 32) return -1;\n crypto_stream_xor(c,0,m,0,d,n,k);\n crypto_onetimeauth(c, 16, c, 32, d - 32, c);\n for (i = 0; i < 16; i++) c[i] = 0;\n return 0;\n}\n\nfunction crypto_secretbox_open(m,c,d,n,k) {\n var i;\n var x = new Uint8Array(32);\n if (d < 32) return -1;\n crypto_stream(x,0,32,n,k);\n if (crypto_onetimeauth_verify(c, 16,c, 32,d - 32,x) !== 0) return -1;\n crypto_stream_xor(m,0,c,0,d,n,k);\n for (i = 0; i < 32; i++) m[i] = 0;\n return 0;\n}\n\nfunction set25519(r, a) {\n var i;\n for (i = 0; i < 16; i++) r[i] = a[i]|0;\n}\n\nfunction car25519(o) {\n var i, v, c = 1;\n for (i = 0; i < 16; i++) {\n v = o[i] + c + 65535;\n c = Math.floor(v / 65536);\n o[i] = v - c * 65536;\n }\n o[0] += c-1 + 37 * (c-1);\n}\n\nfunction sel25519(p, q, b) {\n var t, c = ~(b-1);\n for (var i = 0; i < 16; i++) {\n t = c & (p[i] ^ q[i]);\n p[i] ^= t;\n q[i] ^= t;\n }\n}\n\nfunction pack25519(o, n) {\n var i, j, b;\n var m = gf(), t = gf();\n for (i = 0; i < 16; i++) t[i] = n[i];\n car25519(t);\n car25519(t);\n car25519(t);\n for (j = 0; j < 2; j++) {\n m[0] = t[0] - 0xffed;\n for (i = 1; i < 15; i++) {\n m[i] = t[i] - 0xffff - ((m[i-1]>>16) & 1);\n m[i-1] &= 0xffff;\n }\n m[15] = t[15] - 0x7fff - ((m[14]>>16) & 1);\n b = (m[15]>>16) & 1;\n m[14] &= 0xffff;\n sel25519(t, m, 1-b);\n }\n for (i = 0; i < 16; i++) {\n o[2*i] = t[i] & 0xff;\n o[2*i+1] = t[i]>>8;\n }\n}\n\nfunction neq25519(a, b) {\n var c = new Uint8Array(32), d = new Uint8Array(32);\n pack25519(c, a);\n pack25519(d, b);\n return crypto_verify_32(c, 0, d, 0);\n}\n\nfunction par25519(a) {\n var d = new Uint8Array(32);\n pack25519(d, a);\n return d[0] & 1;\n}\n\nfunction unpack25519(o, n) {\n var i;\n for (i = 0; i < 16; i++) o[i] = n[2*i] + (n[2*i+1] << 8);\n o[15] &= 0x7fff;\n}\n\nfunction A(o, a, b) {\n for (var i = 0; i < 16; i++) o[i] = a[i] + b[i];\n}\n\nfunction Z(o, a, b) {\n for (var i = 0; i < 16; i++) o[i] = a[i] - b[i];\n}\n\nfunction M(o, a, b) {\n var v, c,\n t0 = 0, t1 = 0, t2 = 0, t3 = 0, t4 = 0, t5 = 0, t6 = 0, t7 = 0,\n t8 = 0, t9 = 0, t10 = 0, t11 = 0, t12 = 0, t13 = 0, t14 = 0, t15 = 0,\n t16 = 0, t17 = 0, t18 = 0, t19 = 0, t20 = 0, t21 = 0, t22 = 0, t23 = 0,\n t24 = 0, t25 = 0, t26 = 0, t27 = 0, t28 = 0, t29 = 0, t30 = 0,\n b0 = b[0],\n b1 = b[1],\n b2 = b[2],\n b3 = b[3],\n b4 = b[4],\n b5 = b[5],\n b6 = b[6],\n b7 = b[7],\n b8 = b[8],\n b9 = b[9],\n b10 = b[10],\n b11 = b[11],\n b12 = b[12],\n b13 = b[13],\n b14 = b[14],\n b15 = b[15];\n\n v = a[0];\n t0 += v * b0;\n t1 += v * b1;\n t2 += v * b2;\n t3 += v * b3;\n t4 += v * b4;\n t5 += v * b5;\n t6 += v * b6;\n t7 += v * b7;\n t8 += v * b8;\n t9 += v * b9;\n t10 += v * b10;\n t11 += v * b11;\n t12 += v * b12;\n t13 += v * b13;\n t14 += v * b14;\n t15 += v * b15;\n v = a[1];\n t1 += v * b0;\n t2 += v * b1;\n t3 += v * b2;\n t4 += v * b3;\n t5 += v * b4;\n t6 += v * b5;\n t7 += v * b6;\n t8 += v * b7;\n t9 += v * b8;\n t10 += v * b9;\n t11 += v * b10;\n t12 += v * b11;\n t13 += v * b12;\n t14 += v * b13;\n t15 += v * b14;\n t16 += v * b15;\n v = a[2];\n t2 += v * b0;\n t3 += v * b1;\n t4 += v * b2;\n t5 += v * b3;\n t6 += v * b4;\n t7 += v * b5;\n t8 += v * b6;\n t9 += v * b7;\n t10 += v * b8;\n t11 += v * b9;\n t12 += v * b10;\n t13 += v * b11;\n t14 += v * b12;\n t15 += v * b13;\n t16 += v * b14;\n t17 += v * b15;\n v = a[3];\n t3 += v * b0;\n t4 += v * b1;\n t5 += v * b2;\n t6 += v * b3;\n t7 += v * b4;\n t8 += v * b5;\n t9 += v * b6;\n t10 += v * b7;\n t11 += v * b8;\n t12 += v * b9;\n t13 += v * b10;\n t14 += v * b11;\n t15 += v * b12;\n t16 += v * b13;\n t17 += v * b14;\n t18 += v * b15;\n v = a[4];\n t4 += v * b0;\n t5 += v * b1;\n t6 += v * b2;\n t7 += v * b3;\n t8 += v * b4;\n t9 += v * b5;\n t10 += v * b6;\n t11 += v * b7;\n t12 += v * b8;\n t13 += v * b9;\n t14 += v * b10;\n t15 += v * b11;\n t16 += v * b12;\n t17 += v * b13;\n t18 += v * b14;\n t19 += v * b15;\n v = a[5];\n t5 += v * b0;\n t6 += v * b1;\n t7 += v * b2;\n t8 += v * b3;\n t9 += v * b4;\n t10 += v * b5;\n t11 += v * b6;\n t12 += v * b7;\n t13 += v * b8;\n t14 += v * b9;\n t15 += v * b10;\n t16 += v * b11;\n t17 += v * b12;\n t18 += v * b13;\n t19 += v * b14;\n t20 += v * b15;\n v = a[6];\n t6 += v * b0;\n t7 += v * b1;\n t8 += v * b2;\n t9 += v * b3;\n t10 += v * b4;\n t11 += v * b5;\n t12 += v * b6;\n t13 += v * b7;\n t14 += v * b8;\n t15 += v * b9;\n t16 += v * b10;\n t17 += v * b11;\n t18 += v * b12;\n t19 += v * b13;\n t20 += v * b14;\n t21 += v * b15;\n v = a[7];\n t7 += v * b0;\n t8 += v * b1;\n t9 += v * b2;\n t10 += v * b3;\n t11 += v * b4;\n t12 += v * b5;\n t13 += v * b6;\n t14 += v * b7;\n t15 += v * b8;\n t16 += v * b9;\n t17 += v * b10;\n t18 += v * b11;\n t19 += v * b12;\n t20 += v * b13;\n t21 += v * b14;\n t22 += v * b15;\n v = a[8];\n t8 += v * b0;\n t9 += v * b1;\n t10 += v * b2;\n t11 += v * b3;\n t12 += v * b4;\n t13 += v * b5;\n t14 += v * b6;\n t15 += v * b7;\n t16 += v * b8;\n t17 += v * b9;\n t18 += v * b10;\n t19 += v * b11;\n t20 += v * b12;\n t21 += v * b13;\n t22 += v * b14;\n t23 += v * b15;\n v = a[9];\n t9 += v * b0;\n t10 += v * b1;\n t11 += v * b2;\n t12 += v * b3;\n t13 += v * b4;\n t14 += v * b5;\n t15 += v * b6;\n t16 += v * b7;\n t17 += v * b8;\n t18 += v * b9;\n t19 += v * b10;\n t20 += v * b11;\n t21 += v * b12;\n t22 += v * b13;\n t23 += v * b14;\n t24 += v * b15;\n v = a[10];\n t10 += v * b0;\n t11 += v * b1;\n t12 += v * b2;\n t13 += v * b3;\n t14 += v * b4;\n t15 += v * b5;\n t16 += v * b6;\n t17 += v * b7;\n t18 += v * b8;\n t19 += v * b9;\n t20 += v * b10;\n t21 += v * b11;\n t22 += v * b12;\n t23 += v * b13;\n t24 += v * b14;\n t25 += v * b15;\n v = a[11];\n t11 += v * b0;\n t12 += v * b1;\n t13 += v * b2;\n t14 += v * b3;\n t15 += v * b4;\n t16 += v * b5;\n t17 += v * b6;\n t18 += v * b7;\n t19 += v * b8;\n t20 += v * b9;\n t21 += v * b10;\n t22 += v * b11;\n t23 += v * b12;\n t24 += v * b13;\n t25 += v * b14;\n t26 += v * b15;\n v = a[12];\n t12 += v * b0;\n t13 += v * b1;\n t14 += v * b2;\n t15 += v * b3;\n t16 += v * b4;\n t17 += v * b5;\n t18 += v * b6;\n t19 += v * b7;\n t20 += v * b8;\n t21 += v * b9;\n t22 += v * b10;\n t23 += v * b11;\n t24 += v * b12;\n t25 += v * b13;\n t26 += v * b14;\n t27 += v * b15;\n v = a[13];\n t13 += v * b0;\n t14 += v * b1;\n t15 += v * b2;\n t16 += v * b3;\n t17 += v * b4;\n t18 += v * b5;\n t19 += v * b6;\n t20 += v * b7;\n t21 += v * b8;\n t22 += v * b9;\n t23 += v * b10;\n t24 += v * b11;\n t25 += v * b12;\n t26 += v * b13;\n t27 += v * b14;\n t28 += v * b15;\n v = a[14];\n t14 += v * b0;\n t15 += v * b1;\n t16 += v * b2;\n t17 += v * b3;\n t18 += v * b4;\n t19 += v * b5;\n t20 += v * b6;\n t21 += v * b7;\n t22 += v * b8;\n t23 += v * b9;\n t24 += v * b10;\n t25 += v * b11;\n t26 += v * b12;\n t27 += v * b13;\n t28 += v * b14;\n t29 += v * b15;\n v = a[15];\n t15 += v * b0;\n t16 += v * b1;\n t17 += v * b2;\n t18 += v * b3;\n t19 += v * b4;\n t20 += v * b5;\n t21 += v * b6;\n t22 += v * b7;\n t23 += v * b8;\n t24 += v * b9;\n t25 += v * b10;\n t26 += v * b11;\n t27 += v * b12;\n t28 += v * b13;\n t29 += v * b14;\n t30 += v * b15;\n\n t0 += 38 * t16;\n t1 += 38 * t17;\n t2 += 38 * t18;\n t3 += 38 * t19;\n t4 += 38 * t20;\n t5 += 38 * t21;\n t6 += 38 * t22;\n t7 += 38 * t23;\n t8 += 38 * t24;\n t9 += 38 * t25;\n t10 += 38 * t26;\n t11 += 38 * t27;\n t12 += 38 * t28;\n t13 += 38 * t29;\n t14 += 38 * t30;\n // t15 left as is\n\n // first car\n c = 1;\n v = t0 + c + 65535; c = Math.floor(v / 65536); t0 = v - c * 65536;\n v = t1 + c + 65535; c = Math.floor(v / 65536); t1 = v - c * 65536;\n v = t2 + c + 65535; c = Math.floor(v / 65536); t2 = v - c * 65536;\n v = t3 + c + 65535; c = Math.floor(v / 65536); t3 = v - c * 65536;\n v = t4 + c + 65535; c = Math.floor(v / 65536); t4 = v - c * 65536;\n v = t5 + c + 65535; c = Math.floor(v / 65536); t5 = v - c * 65536;\n v = t6 + c + 65535; c = Math.floor(v / 65536); t6 = v - c * 65536;\n v = t7 + c + 65535; c = Math.floor(v / 65536); t7 = v - c * 65536;\n v = t8 + c + 65535; c = Math.floor(v / 65536); t8 = v - c * 65536;\n v = t9 + c + 65535; c = Math.floor(v / 65536); t9 = v - c * 65536;\n v = t10 + c + 65535; c = Math.floor(v / 65536); t10 = v - c * 65536;\n v = t11 + c + 65535; c = Math.floor(v / 65536); t11 = v - c * 65536;\n v = t12 + c + 65535; c = Math.floor(v / 65536); t12 = v - c * 65536;\n v = t13 + c + 65535; c = Math.floor(v / 65536); t13 = v - c * 65536;\n v = t14 + c + 65535; c = Math.floor(v / 65536); t14 = v - c * 65536;\n v = t15 + c + 65535; c = Math.floor(v / 65536); t15 = v - c * 65536;\n t0 += c-1 + 37 * (c-1);\n\n // second car\n c = 1;\n v = t0 + c + 65535; c = Math.floor(v / 65536); t0 = v - c * 65536;\n v = t1 + c + 65535; c = Math.floor(v / 65536); t1 = v - c * 65536;\n v = t2 + c + 65535; c = Math.floor(v / 65536); t2 = v - c * 65536;\n v = t3 + c + 65535; c = Math.floor(v / 65536); t3 = v - c * 65536;\n v = t4 + c + 65535; c = Math.floor(v / 65536); t4 = v - c * 65536;\n v = t5 + c + 65535; c = Math.floor(v / 65536); t5 = v - c * 65536;\n v = t6 + c + 65535; c = Math.floor(v / 65536); t6 = v - c * 65536;\n v = t7 + c + 65535; c = Math.floor(v / 65536); t7 = v - c * 65536;\n v = t8 + c + 65535; c = Math.floor(v / 65536); t8 = v - c * 65536;\n v = t9 + c + 65535; c = Math.floor(v / 65536); t9 = v - c * 65536;\n v = t10 + c + 65535; c = Math.floor(v / 65536); t10 = v - c * 65536;\n v = t11 + c + 65535; c = Math.floor(v / 65536); t11 = v - c * 65536;\n v = t12 + c + 65535; c = Math.floor(v / 65536); t12 = v - c * 65536;\n v = t13 + c + 65535; c = Math.floor(v / 65536); t13 = v - c * 65536;\n v = t14 + c + 65535; c = Math.floor(v / 65536); t14 = v - c * 65536;\n v = t15 + c + 65535; c = Math.floor(v / 65536); t15 = v - c * 65536;\n t0 += c-1 + 37 * (c-1);\n\n o[ 0] = t0;\n o[ 1] = t1;\n o[ 2] = t2;\n o[ 3] = t3;\n o[ 4] = t4;\n o[ 5] = t5;\n o[ 6] = t6;\n o[ 7] = t7;\n o[ 8] = t8;\n o[ 9] = t9;\n o[10] = t10;\n o[11] = t11;\n o[12] = t12;\n o[13] = t13;\n o[14] = t14;\n o[15] = t15;\n}\n\nfunction S(o, a) {\n M(o, a, a);\n}\n\nfunction inv25519(o, i) {\n var c = gf();\n var a;\n for (a = 0; a < 16; a++) c[a] = i[a];\n for (a = 253; a >= 0; a--) {\n S(c, c);\n if(a !== 2 && a !== 4) M(c, c, i);\n }\n for (a = 0; a < 16; a++) o[a] = c[a];\n}\n\nfunction pow2523(o, i) {\n var c = gf();\n var a;\n for (a = 0; a < 16; a++) c[a] = i[a];\n for (a = 250; a >= 0; a--) {\n S(c, c);\n if(a !== 1) M(c, c, i);\n }\n for (a = 0; a < 16; a++) o[a] = c[a];\n}\n\nfunction crypto_scalarmult(q, n, p) {\n var z = new Uint8Array(32);\n var x = new Float64Array(80), r, i;\n var a = gf(), b = gf(), c = gf(),\n d = gf(), e = gf(), f = gf();\n for (i = 0; i < 31; i++) z[i] = n[i];\n z[31]=(n[31]&127)|64;\n z[0]&=248;\n unpack25519(x,p);\n for (i = 0; i < 16; i++) {\n b[i]=x[i];\n d[i]=a[i]=c[i]=0;\n }\n a[0]=d[0]=1;\n for (i=254; i>=0; --i) {\n r=(z[i>>>3]>>>(i&7))&1;\n sel25519(a,b,r);\n sel25519(c,d,r);\n A(e,a,c);\n Z(a,a,c);\n A(c,b,d);\n Z(b,b,d);\n S(d,e);\n S(f,a);\n M(a,c,a);\n M(c,b,e);\n A(e,a,c);\n Z(a,a,c);\n S(b,a);\n Z(c,d,f);\n M(a,c,_121665);\n A(a,a,d);\n M(c,c,a);\n M(a,d,f);\n M(d,b,x);\n S(b,e);\n sel25519(a,b,r);\n sel25519(c,d,r);\n }\n for (i = 0; i < 16; i++) {\n x[i+16]=a[i];\n x[i+32]=c[i];\n x[i+48]=b[i];\n x[i+64]=d[i];\n }\n var x32 = x.subarray(32);\n var x16 = x.subarray(16);\n inv25519(x32,x32);\n M(x16,x16,x32);\n pack25519(q,x16);\n return 0;\n}\n\nfunction crypto_scalarmult_base(q, n) {\n return crypto_scalarmult(q, n, _9);\n}\n\nfunction crypto_box_keypair(y, x) {\n randombytes(x, 32);\n return crypto_scalarmult_base(y, x);\n}\n\nfunction crypto_box_beforenm(k, y, x) {\n var s = new Uint8Array(32);\n crypto_scalarmult(s, x, y);\n return crypto_core_hsalsa20(k, _0, s, sigma);\n}\n\nvar crypto_box_afternm = crypto_secretbox;\nvar crypto_box_open_afternm = crypto_secretbox_open;\n\nfunction crypto_box(c, m, d, n, y, x) {\n var k = new Uint8Array(32);\n crypto_box_beforenm(k, y, x);\n return crypto_box_afternm(c, m, d, n, k);\n}\n\nfunction crypto_box_open(m, c, d, n, y, x) {\n var k = new Uint8Array(32);\n crypto_box_beforenm(k, y, x);\n return crypto_box_open_afternm(m, c, d, n, k);\n}\n\nvar K = [\n 0x428a2f98, 0xd728ae22, 0x71374491, 0x23ef65cd,\n 0xb5c0fbcf, 0xec4d3b2f, 0xe9b5dba5, 0x8189dbbc,\n 0x3956c25b, 0xf348b538, 0x59f111f1, 0xb605d019,\n 0x923f82a4, 0xaf194f9b, 0xab1c5ed5, 0xda6d8118,\n 0xd807aa98, 0xa3030242, 0x12835b01, 0x45706fbe,\n 0x243185be, 0x4ee4b28c, 0x550c7dc3, 0xd5ffb4e2,\n 0x72be5d74, 0xf27b896f, 0x80deb1fe, 0x3b1696b1,\n 0x9bdc06a7, 0x25c71235, 0xc19bf174, 0xcf692694,\n 0xe49b69c1, 0x9ef14ad2, 0xefbe4786, 0x384f25e3,\n 0x0fc19dc6, 0x8b8cd5b5, 0x240ca1cc, 0x77ac9c65,\n 0x2de92c6f, 0x592b0275, 0x4a7484aa, 0x6ea6e483,\n 0x5cb0a9dc, 0xbd41fbd4, 0x76f988da, 0x831153b5,\n 0x983e5152, 0xee66dfab, 0xa831c66d, 0x2db43210,\n 0xb00327c8, 0x98fb213f, 0xbf597fc7, 0xbeef0ee4,\n 0xc6e00bf3, 0x3da88fc2, 0xd5a79147, 0x930aa725,\n 0x06ca6351, 0xe003826f, 0x14292967, 0x0a0e6e70,\n 0x27b70a85, 0x46d22ffc, 0x2e1b2138, 0x5c26c926,\n 0x4d2c6dfc, 0x5ac42aed, 0x53380d13, 0x9d95b3df,\n 0x650a7354, 0x8baf63de, 0x766a0abb, 0x3c77b2a8,\n 0x81c2c92e, 0x47edaee6, 0x92722c85, 0x1482353b,\n 0xa2bfe8a1, 0x4cf10364, 0xa81a664b, 0xbc423001,\n 0xc24b8b70, 0xd0f89791, 0xc76c51a3, 0x0654be30,\n 0xd192e819, 0xd6ef5218, 0xd6990624, 0x5565a910,\n 0xf40e3585, 0x5771202a, 0x106aa070, 0x32bbd1b8,\n 0x19a4c116, 0xb8d2d0c8, 0x1e376c08, 0x5141ab53,\n 0x2748774c, 0xdf8eeb99, 0x34b0bcb5, 0xe19b48a8,\n 0x391c0cb3, 0xc5c95a63, 0x4ed8aa4a, 0xe3418acb,\n 0x5b9cca4f, 0x7763e373, 0x682e6ff3, 0xd6b2b8a3,\n 0x748f82ee, 0x5defb2fc, 0x78a5636f, 0x43172f60,\n 0x84c87814, 0xa1f0ab72, 0x8cc70208, 0x1a6439ec,\n 0x90befffa, 0x23631e28, 0xa4506ceb, 0xde82bde9,\n 0xbef9a3f7, 0xb2c67915, 0xc67178f2, 0xe372532b,\n 0xca273ece, 0xea26619c, 0xd186b8c7, 0x21c0c207,\n 0xeada7dd6, 0xcde0eb1e, 0xf57d4f7f, 0xee6ed178,\n 0x06f067aa, 0x72176fba, 0x0a637dc5, 0xa2c898a6,\n 0x113f9804, 0xbef90dae, 0x1b710b35, 0x131c471b,\n 0x28db77f5, 0x23047d84, 0x32caab7b, 0x40c72493,\n 0x3c9ebe0a, 0x15c9bebc, 0x431d67c4, 0x9c100d4c,\n 0x4cc5d4be, 0xcb3e42b6, 0x597f299c, 0xfc657e2a,\n 0x5fcb6fab, 0x3ad6faec, 0x6c44198c, 0x4a475817\n];\n\nfunction crypto_hashblocks_hl(hh, hl, m, n) {\n var wh = new Int32Array(16), wl = new Int32Array(16),\n bh0, bh1, bh2, bh3, bh4, bh5, bh6, bh7,\n bl0, bl1, bl2, bl3, bl4, bl5, bl6, bl7,\n th, tl, i, j, h, l, a, b, c, d;\n\n var ah0 = hh[0],\n ah1 = hh[1],\n ah2 = hh[2],\n ah3 = hh[3],\n ah4 = hh[4],\n ah5 = hh[5],\n ah6 = hh[6],\n ah7 = hh[7],\n\n al0 = hl[0],\n al1 = hl[1],\n al2 = hl[2],\n al3 = hl[3],\n al4 = hl[4],\n al5 = hl[5],\n al6 = hl[6],\n al7 = hl[7];\n\n var pos = 0;\n while (n >= 128) {\n for (i = 0; i < 16; i++) {\n j = 8 * i + pos;\n wh[i] = (m[j+0] << 24) | (m[j+1] << 16) | (m[j+2] << 8) | m[j+3];\n wl[i] = (m[j+4] << 24) | (m[j+5] << 16) | (m[j+6] << 8) | m[j+7];\n }\n for (i = 0; i < 80; i++) {\n bh0 = ah0;\n bh1 = ah1;\n bh2 = ah2;\n bh3 = ah3;\n bh4 = ah4;\n bh5 = ah5;\n bh6 = ah6;\n bh7 = ah7;\n\n bl0 = al0;\n bl1 = al1;\n bl2 = al2;\n bl3 = al3;\n bl4 = al4;\n bl5 = al5;\n bl6 = al6;\n bl7 = al7;\n\n // add\n h = ah7;\n l = al7;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n // Sigma1\n h = ((ah4 >>> 14) | (al4 << (32-14))) ^ ((ah4 >>> 18) | (al4 << (32-18))) ^ ((al4 >>> (41-32)) | (ah4 << (32-(41-32))));\n l = ((al4 >>> 14) | (ah4 << (32-14))) ^ ((al4 >>> 18) | (ah4 << (32-18))) ^ ((ah4 >>> (41-32)) | (al4 << (32-(41-32))));\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // Ch\n h = (ah4 & ah5) ^ (~ah4 & ah6);\n l = (al4 & al5) ^ (~al4 & al6);\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // K\n h = K[i*2];\n l = K[i*2+1];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // w\n h = wh[i%16];\n l = wl[i%16];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n th = c & 0xffff | d << 16;\n tl = a & 0xffff | b << 16;\n\n // add\n h = th;\n l = tl;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n // Sigma0\n h = ((ah0 >>> 28) | (al0 << (32-28))) ^ ((al0 >>> (34-32)) | (ah0 << (32-(34-32)))) ^ ((al0 >>> (39-32)) | (ah0 << (32-(39-32))));\n l = ((al0 >>> 28) | (ah0 << (32-28))) ^ ((ah0 >>> (34-32)) | (al0 << (32-(34-32)))) ^ ((ah0 >>> (39-32)) | (al0 << (32-(39-32))));\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // Maj\n h = (ah0 & ah1) ^ (ah0 & ah2) ^ (ah1 & ah2);\n l = (al0 & al1) ^ (al0 & al2) ^ (al1 & al2);\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n bh7 = (c & 0xffff) | (d << 16);\n bl7 = (a & 0xffff) | (b << 16);\n\n // add\n h = bh3;\n l = bl3;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = th;\n l = tl;\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n bh3 = (c & 0xffff) | (d << 16);\n bl3 = (a & 0xffff) | (b << 16);\n\n ah1 = bh0;\n ah2 = bh1;\n ah3 = bh2;\n ah4 = bh3;\n ah5 = bh4;\n ah6 = bh5;\n ah7 = bh6;\n ah0 = bh7;\n\n al1 = bl0;\n al2 = bl1;\n al3 = bl2;\n al4 = bl3;\n al5 = bl4;\n al6 = bl5;\n al7 = bl6;\n al0 = bl7;\n\n if (i%16 === 15) {\n for (j = 0; j < 16; j++) {\n // add\n h = wh[j];\n l = wl[j];\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = wh[(j+9)%16];\n l = wl[(j+9)%16];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // sigma0\n th = wh[(j+1)%16];\n tl = wl[(j+1)%16];\n h = ((th >>> 1) | (tl << (32-1))) ^ ((th >>> 8) | (tl << (32-8))) ^ (th >>> 7);\n l = ((tl >>> 1) | (th << (32-1))) ^ ((tl >>> 8) | (th << (32-8))) ^ ((tl >>> 7) | (th << (32-7)));\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // sigma1\n th = wh[(j+14)%16];\n tl = wl[(j+14)%16];\n h = ((th >>> 19) | (tl << (32-19))) ^ ((tl >>> (61-32)) | (th << (32-(61-32)))) ^ (th >>> 6);\n l = ((tl >>> 19) | (th << (32-19))) ^ ((th >>> (61-32)) | (tl << (32-(61-32)))) ^ ((tl >>> 6) | (th << (32-6)));\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n wh[j] = (c & 0xffff) | (d << 16);\n wl[j] = (a & 0xffff) | (b << 16);\n }\n }\n }\n\n // add\n h = ah0;\n l = al0;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[0];\n l = hl[0];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[0] = ah0 = (c & 0xffff) | (d << 16);\n hl[0] = al0 = (a & 0xffff) | (b << 16);\n\n h = ah1;\n l = al1;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[1];\n l = hl[1];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[1] = ah1 = (c & 0xffff) | (d << 16);\n hl[1] = al1 = (a & 0xffff) | (b << 16);\n\n h = ah2;\n l = al2;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[2];\n l = hl[2];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[2] = ah2 = (c & 0xffff) | (d << 16);\n hl[2] = al2 = (a & 0xffff) | (b << 16);\n\n h = ah3;\n l = al3;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[3];\n l = hl[3];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[3] = ah3 = (c & 0xffff) | (d << 16);\n hl[3] = al3 = (a & 0xffff) | (b << 16);\n\n h = ah4;\n l = al4;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[4];\n l = hl[4];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[4] = ah4 = (c & 0xffff) | (d << 16);\n hl[4] = al4 = (a & 0xffff) | (b << 16);\n\n h = ah5;\n l = al5;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[5];\n l = hl[5];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[5] = ah5 = (c & 0xffff) | (d << 16);\n hl[5] = al5 = (a & 0xffff) | (b << 16);\n\n h = ah6;\n l = al6;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[6];\n l = hl[6];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[6] = ah6 = (c & 0xffff) | (d << 16);\n hl[6] = al6 = (a & 0xffff) | (b << 16);\n\n h = ah7;\n l = al7;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[7];\n l = hl[7];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[7] = ah7 = (c & 0xffff) | (d << 16);\n hl[7] = al7 = (a & 0xffff) | (b << 16);\n\n pos += 128;\n n -= 128;\n }\n\n return n;\n}\n\nfunction crypto_hash(out, m, n) {\n var hh = new Int32Array(8),\n hl = new Int32Array(8),\n x = new Uint8Array(256),\n i, b = n;\n\n hh[0] = 0x6a09e667;\n hh[1] = 0xbb67ae85;\n hh[2] = 0x3c6ef372;\n hh[3] = 0xa54ff53a;\n hh[4] = 0x510e527f;\n hh[5] = 0x9b05688c;\n hh[6] = 0x1f83d9ab;\n hh[7] = 0x5be0cd19;\n\n hl[0] = 0xf3bcc908;\n hl[1] = 0x84caa73b;\n hl[2] = 0xfe94f82b;\n hl[3] = 0x5f1d36f1;\n hl[4] = 0xade682d1;\n hl[5] = 0x2b3e6c1f;\n hl[6] = 0xfb41bd6b;\n hl[7] = 0x137e2179;\n\n crypto_hashblocks_hl(hh, hl, m, n);\n n %= 128;\n\n for (i = 0; i < n; i++) x[i] = m[b-n+i];\n x[n] = 128;\n\n n = 256-128*(n<112?1:0);\n x[n-9] = 0;\n ts64(x, n-8, (b / 0x20000000) | 0, b << 3);\n crypto_hashblocks_hl(hh, hl, x, n);\n\n for (i = 0; i < 8; i++) ts64(out, 8*i, hh[i], hl[i]);\n\n return 0;\n}\n\nfunction add(p, q) {\n var a = gf(), b = gf(), c = gf(),\n d = gf(), e = gf(), f = gf(),\n g = gf(), h = gf(), t = gf();\n\n Z(a, p[1], p[0]);\n Z(t, q[1], q[0]);\n M(a, a, t);\n A(b, p[0], p[1]);\n A(t, q[0], q[1]);\n M(b, b, t);\n M(c, p[3], q[3]);\n M(c, c, D2);\n M(d, p[2], q[2]);\n A(d, d, d);\n Z(e, b, a);\n Z(f, d, c);\n A(g, d, c);\n A(h, b, a);\n\n M(p[0], e, f);\n M(p[1], h, g);\n M(p[2], g, f);\n M(p[3], e, h);\n}\n\nfunction cswap(p, q, b) {\n var i;\n for (i = 0; i < 4; i++) {\n sel25519(p[i], q[i], b);\n }\n}\n\nfunction pack(r, p) {\n var tx = gf(), ty = gf(), zi = gf();\n inv25519(zi, p[2]);\n M(tx, p[0], zi);\n M(ty, p[1], zi);\n pack25519(r, ty);\n r[31] ^= par25519(tx) << 7;\n}\n\nfunction scalarmult(p, q, s) {\n var b, i;\n set25519(p[0], gf0);\n set25519(p[1], gf1);\n set25519(p[2], gf1);\n set25519(p[3], gf0);\n for (i = 255; i >= 0; --i) {\n b = (s[(i/8)|0] >> (i&7)) & 1;\n cswap(p, q, b);\n add(q, p);\n add(p, p);\n cswap(p, q, b);\n }\n}\n\nfunction scalarbase(p, s) {\n var q = [gf(), gf(), gf(), gf()];\n set25519(q[0], X);\n set25519(q[1], Y);\n set25519(q[2], gf1);\n M(q[3], X, Y);\n scalarmult(p, q, s);\n}\n\nfunction crypto_sign_keypair(pk, sk, seeded) {\n var d = new Uint8Array(64);\n var p = [gf(), gf(), gf(), gf()];\n var i;\n\n if (!seeded) randombytes(sk, 32);\n crypto_hash(d, sk, 32);\n d[0] &= 248;\n d[31] &= 127;\n d[31] |= 64;\n\n scalarbase(p, d);\n pack(pk, p);\n\n for (i = 0; i < 32; i++) sk[i+32] = pk[i];\n return 0;\n}\n\nvar L = new Float64Array([0xed, 0xd3, 0xf5, 0x5c, 0x1a, 0x63, 0x12, 0x58, 0xd6, 0x9c, 0xf7, 0xa2, 0xde, 0xf9, 0xde, 0x14, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x10]);\n\nfunction modL(r, x) {\n var carry, i, j, k;\n for (i = 63; i >= 32; --i) {\n carry = 0;\n for (j = i - 32, k = i - 12; j < k; ++j) {\n x[j] += carry - 16 * x[i] * L[j - (i - 32)];\n carry = Math.floor((x[j] + 128) / 256);\n x[j] -= carry * 256;\n }\n x[j] += carry;\n x[i] = 0;\n }\n carry = 0;\n for (j = 0; j < 32; j++) {\n x[j] += carry - (x[31] >> 4) * L[j];\n carry = x[j] >> 8;\n x[j] &= 255;\n }\n for (j = 0; j < 32; j++) x[j] -= carry * L[j];\n for (i = 0; i < 32; i++) {\n x[i+1] += x[i] >> 8;\n r[i] = x[i] & 255;\n }\n}\n\nfunction reduce(r) {\n var x = new Float64Array(64), i;\n for (i = 0; i < 64; i++) x[i] = r[i];\n for (i = 0; i < 64; i++) r[i] = 0;\n modL(r, x);\n}\n\n// Note: difference from C - smlen returned, not passed as argument.\nfunction crypto_sign(sm, m, n, sk) {\n var d = new Uint8Array(64), h = new Uint8Array(64), r = new Uint8Array(64);\n var i, j, x = new Float64Array(64);\n var p = [gf(), gf(), gf(), gf()];\n\n crypto_hash(d, sk, 32);\n d[0] &= 248;\n d[31] &= 127;\n d[31] |= 64;\n\n var smlen = n + 64;\n for (i = 0; i < n; i++) sm[64 + i] = m[i];\n for (i = 0; i < 32; i++) sm[32 + i] = d[32 + i];\n\n crypto_hash(r, sm.subarray(32), n+32);\n reduce(r);\n scalarbase(p, r);\n pack(sm, p);\n\n for (i = 32; i < 64; i++) sm[i] = sk[i];\n crypto_hash(h, sm, n + 64);\n reduce(h);\n\n for (i = 0; i < 64; i++) x[i] = 0;\n for (i = 0; i < 32; i++) x[i] = r[i];\n for (i = 0; i < 32; i++) {\n for (j = 0; j < 32; j++) {\n x[i+j] += h[i] * d[j];\n }\n }\n\n modL(sm.subarray(32), x);\n return smlen;\n}\n\nfunction unpackneg(r, p) {\n var t = gf(), chk = gf(), num = gf(),\n den = gf(), den2 = gf(), den4 = gf(),\n den6 = gf();\n\n set25519(r[2], gf1);\n unpack25519(r[1], p);\n S(num, r[1]);\n M(den, num, D);\n Z(num, num, r[2]);\n A(den, r[2], den);\n\n S(den2, den);\n S(den4, den2);\n M(den6, den4, den2);\n M(t, den6, num);\n M(t, t, den);\n\n pow2523(t, t);\n M(t, t, num);\n M(t, t, den);\n M(t, t, den);\n M(r[0], t, den);\n\n S(chk, r[0]);\n M(chk, chk, den);\n if (neq25519(chk, num)) M(r[0], r[0], I);\n\n S(chk, r[0]);\n M(chk, chk, den);\n if (neq25519(chk, num)) return -1;\n\n if (par25519(r[0]) === (p[31]>>7)) Z(r[0], gf0, r[0]);\n\n M(r[3], r[0], r[1]);\n return 0;\n}\n\nfunction crypto_sign_open(m, sm, n, pk) {\n var i;\n var t = new Uint8Array(32), h = new Uint8Array(64);\n var p = [gf(), gf(), gf(), gf()],\n q = [gf(), gf(), gf(), gf()];\n\n if (n < 64) return -1;\n\n if (unpackneg(q, pk)) return -1;\n\n for (i = 0; i < n; i++) m[i] = sm[i];\n for (i = 0; i < 32; i++) m[i+32] = pk[i];\n crypto_hash(h, m, n);\n reduce(h);\n scalarmult(p, q, h);\n\n scalarbase(q, sm.subarray(32));\n add(p, q);\n pack(t, p);\n\n n -= 64;\n if (crypto_verify_32(sm, 0, t, 0)) {\n for (i = 0; i < n; i++) m[i] = 0;\n return -1;\n }\n\n for (i = 0; i < n; i++) m[i] = sm[i + 64];\n return n;\n}\n\nvar crypto_secretbox_KEYBYTES = 32,\n crypto_secretbox_NONCEBYTES = 24,\n crypto_secretbox_ZEROBYTES = 32,\n crypto_secretbox_BOXZEROBYTES = 16,\n crypto_scalarmult_BYTES = 32,\n crypto_scalarmult_SCALARBYTES = 32,\n crypto_box_PUBLICKEYBYTES = 32,\n crypto_box_SECRETKEYBYTES = 32,\n crypto_box_BEFORENMBYTES = 32,\n crypto_box_NONCEBYTES = crypto_secretbox_NONCEBYTES,\n crypto_box_ZEROBYTES = crypto_secretbox_ZEROBYTES,\n crypto_box_BOXZEROBYTES = crypto_secretbox_BOXZEROBYTES,\n crypto_sign_BYTES = 64,\n crypto_sign_PUBLICKEYBYTES = 32,\n crypto_sign_SECRETKEYBYTES = 64,\n crypto_sign_SEEDBYTES = 32,\n crypto_hash_BYTES = 64;\n\nnacl.lowlevel = {\n crypto_core_hsalsa20: crypto_core_hsalsa20,\n crypto_stream_xor: crypto_stream_xor,\n crypto_stream: crypto_stream,\n crypto_stream_salsa20_xor: crypto_stream_salsa20_xor,\n crypto_stream_salsa20: crypto_stream_salsa20,\n crypto_onetimeauth: crypto_onetimeauth,\n crypto_onetimeauth_verify: crypto_onetimeauth_verify,\n crypto_verify_16: crypto_verify_16,\n crypto_verify_32: crypto_verify_32,\n crypto_secretbox: crypto_secretbox,\n crypto_secretbox_open: crypto_secretbox_open,\n crypto_scalarmult: crypto_scalarmult,\n crypto_scalarmult_base: crypto_scalarmult_base,\n crypto_box_beforenm: crypto_box_beforenm,\n crypto_box_afternm: crypto_box_afternm,\n crypto_box: crypto_box,\n crypto_box_open: crypto_box_open,\n crypto_box_keypair: crypto_box_keypair,\n crypto_hash: crypto_hash,\n crypto_sign: crypto_sign,\n crypto_sign_keypair: crypto_sign_keypair,\n crypto_sign_open: crypto_sign_open,\n\n crypto_secretbox_KEYBYTES: crypto_secretbox_KEYBYTES,\n crypto_secretbox_NONCEBYTES: crypto_secretbox_NONCEBYTES,\n crypto_secretbox_ZEROBYTES: crypto_secretbox_ZEROBYTES,\n crypto_secretbox_BOXZEROBYTES: crypto_secretbox_BOXZEROBYTES,\n crypto_scalarmult_BYTES: crypto_scalarmult_BYTES,\n crypto_scalarmult_SCALARBYTES: crypto_scalarmult_SCALARBYTES,\n crypto_box_PUBLICKEYBYTES: crypto_box_PUBLICKEYBYTES,\n crypto_box_SECRETKEYBYTES: crypto_box_SECRETKEYBYTES,\n crypto_box_BEFORENMBYTES: crypto_box_BEFORENMBYTES,\n crypto_box_NONCEBYTES: crypto_box_NONCEBYTES,\n crypto_box_ZEROBYTES: crypto_box_ZEROBYTES,\n crypto_box_BOXZEROBYTES: crypto_box_BOXZEROBYTES,\n crypto_sign_BYTES: crypto_sign_BYTES,\n crypto_sign_PUBLICKEYBYTES: crypto_sign_PUBLICKEYBYTES,\n crypto_sign_SECRETKEYBYTES: crypto_sign_SECRETKEYBYTES,\n crypto_sign_SEEDBYTES: crypto_sign_SEEDBYTES,\n crypto_hash_BYTES: crypto_hash_BYTES,\n\n gf: gf,\n D: D,\n L: L,\n pack25519: pack25519,\n unpack25519: unpack25519,\n M: M,\n A: A,\n S: S,\n Z: Z,\n pow2523: pow2523,\n add: add,\n set25519: set25519,\n modL: modL,\n scalarmult: scalarmult,\n scalarbase: scalarbase,\n};\n\n/* High-level API */\n\nfunction checkLengths(k, n) {\n if (k.length !== crypto_secretbox_KEYBYTES) throw new Error('bad key size');\n if (n.length !== crypto_secretbox_NONCEBYTES) throw new Error('bad nonce size');\n}\n\nfunction checkBoxLengths(pk, sk) {\n if (pk.length !== crypto_box_PUBLICKEYBYTES) throw new Error('bad public key size');\n if (sk.length !== crypto_box_SECRETKEYBYTES) throw new Error('bad secret key size');\n}\n\nfunction checkArrayTypes() {\n for (var i = 0; i < arguments.length; i++) {\n if (!(arguments[i] instanceof Uint8Array))\n throw new TypeError('unexpected type, use Uint8Array');\n }\n}\n\nfunction cleanup(arr) {\n for (var i = 0; i < arr.length; i++) arr[i] = 0;\n}\n\nnacl.randomBytes = function(n) {\n var b = new Uint8Array(n);\n randombytes(b, n);\n return b;\n};\n\nnacl.secretbox = function(msg, nonce, key) {\n checkArrayTypes(msg, nonce, key);\n checkLengths(key, nonce);\n var m = new Uint8Array(crypto_secretbox_ZEROBYTES + msg.length);\n var c = new Uint8Array(m.length);\n for (var i = 0; i < msg.length; i++) m[i+crypto_secretbox_ZEROBYTES] = msg[i];\n crypto_secretbox(c, m, m.length, nonce, key);\n return c.subarray(crypto_secretbox_BOXZEROBYTES);\n};\n\nnacl.secretbox.open = function(box, nonce, key) {\n checkArrayTypes(box, nonce, key);\n checkLengths(key, nonce);\n var c = new Uint8Array(crypto_secretbox_BOXZEROBYTES + box.length);\n var m = new Uint8Array(c.length);\n for (var i = 0; i < box.length; i++) c[i+crypto_secretbox_BOXZEROBYTES] = box[i];\n if (c.length < 32) return null;\n if (crypto_secretbox_open(m, c, c.length, nonce, key) !== 0) return null;\n return m.subarray(crypto_secretbox_ZEROBYTES);\n};\n\nnacl.secretbox.keyLength = crypto_secretbox_KEYBYTES;\nnacl.secretbox.nonceLength = crypto_secretbox_NONCEBYTES;\nnacl.secretbox.overheadLength = crypto_secretbox_BOXZEROBYTES;\n\nnacl.scalarMult = function(n, p) {\n checkArrayTypes(n, p);\n if (n.length !== crypto_scalarmult_SCALARBYTES) throw new Error('bad n size');\n if (p.length !== crypto_scalarmult_BYTES) throw new Error('bad p size');\n var q = new Uint8Array(crypto_scalarmult_BYTES);\n crypto_scalarmult(q, n, p);\n return q;\n};\n\nnacl.scalarMult.base = function(n) {\n checkArrayTypes(n);\n if (n.length !== crypto_scalarmult_SCALARBYTES) throw new Error('bad n size');\n var q = new Uint8Array(crypto_scalarmult_BYTES);\n crypto_scalarmult_base(q, n);\n return q;\n};\n\nnacl.scalarMult.scalarLength = crypto_scalarmult_SCALARBYTES;\nnacl.scalarMult.groupElementLength = crypto_scalarmult_BYTES;\n\nnacl.box = function(msg, nonce, publicKey, secretKey) {\n var k = nacl.box.before(publicKey, secretKey);\n return nacl.secretbox(msg, nonce, k);\n};\n\nnacl.box.before = function(publicKey, secretKey) {\n checkArrayTypes(publicKey, secretKey);\n checkBoxLengths(publicKey, secretKey);\n var k = new Uint8Array(crypto_box_BEFORENMBYTES);\n crypto_box_beforenm(k, publicKey, secretKey);\n return k;\n};\n\nnacl.box.after = nacl.secretbox;\n\nnacl.box.open = function(msg, nonce, publicKey, secretKey) {\n var k = nacl.box.before(publicKey, secretKey);\n return nacl.secretbox.open(msg, nonce, k);\n};\n\nnacl.box.open.after = nacl.secretbox.open;\n\nnacl.box.keyPair = function() {\n var pk = new Uint8Array(crypto_box_PUBLICKEYBYTES);\n var sk = new Uint8Array(crypto_box_SECRETKEYBYTES);\n crypto_box_keypair(pk, sk);\n return {publicKey: pk, secretKey: sk};\n};\n\nnacl.box.keyPair.fromSecretKey = function(secretKey) {\n checkArrayTypes(secretKey);\n if (secretKey.length !== crypto_box_SECRETKEYBYTES)\n throw new Error('bad secret key size');\n var pk = new Uint8Array(crypto_box_PUBLICKEYBYTES);\n crypto_scalarmult_base(pk, secretKey);\n return {publicKey: pk, secretKey: new Uint8Array(secretKey)};\n};\n\nnacl.box.publicKeyLength = crypto_box_PUBLICKEYBYTES;\nnacl.box.secretKeyLength = crypto_box_SECRETKEYBYTES;\nnacl.box.sharedKeyLength = crypto_box_BEFORENMBYTES;\nnacl.box.nonceLength = crypto_box_NONCEBYTES;\nnacl.box.overheadLength = nacl.secretbox.overheadLength;\n\nnacl.sign = function(msg, secretKey) {\n checkArrayTypes(msg, secretKey);\n if (secretKey.length !== crypto_sign_SECRETKEYBYTES)\n throw new Error('bad secret key size');\n var signedMsg = new Uint8Array(crypto_sign_BYTES+msg.length);\n crypto_sign(signedMsg, msg, msg.length, secretKey);\n return signedMsg;\n};\n\nnacl.sign.open = function(signedMsg, publicKey) {\n checkArrayTypes(signedMsg, publicKey);\n if (publicKey.length !== crypto_sign_PUBLICKEYBYTES)\n throw new Error('bad public key size');\n var tmp = new Uint8Array(signedMsg.length);\n var mlen = crypto_sign_open(tmp, signedMsg, signedMsg.length, publicKey);\n if (mlen < 0) return null;\n var m = new Uint8Array(mlen);\n for (var i = 0; i < m.length; i++) m[i] = tmp[i];\n return m;\n};\n\nnacl.sign.detached = function(msg, secretKey) {\n var signedMsg = nacl.sign(msg, secretKey);\n var sig = new Uint8Array(crypto_sign_BYTES);\n for (var i = 0; i < sig.length; i++) sig[i] = signedMsg[i];\n return sig;\n};\n\nnacl.sign.detached.verify = function(msg, sig, publicKey) {\n checkArrayTypes(msg, sig, publicKey);\n if (sig.length !== crypto_sign_BYTES)\n throw new Error('bad signature size');\n if (publicKey.length !== crypto_sign_PUBLICKEYBYTES)\n throw new Error('bad public key size');\n var sm = new Uint8Array(crypto_sign_BYTES + msg.length);\n var m = new Uint8Array(crypto_sign_BYTES + msg.length);\n var i;\n for (i = 0; i < crypto_sign_BYTES; i++) sm[i] = sig[i];\n for (i = 0; i < msg.length; i++) sm[i+crypto_sign_BYTES] = msg[i];\n return (crypto_sign_open(m, sm, sm.length, publicKey) >= 0);\n};\n\nnacl.sign.keyPair = function() {\n var pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);\n var sk = new Uint8Array(crypto_sign_SECRETKEYBYTES);\n crypto_sign_keypair(pk, sk);\n return {publicKey: pk, secretKey: sk};\n};\n\nnacl.sign.keyPair.fromSecretKey = function(secretKey) {\n checkArrayTypes(secretKey);\n if (secretKey.length !== crypto_sign_SECRETKEYBYTES)\n throw new Error('bad secret key size');\n var pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);\n for (var i = 0; i < pk.length; i++) pk[i] = secretKey[32+i];\n return {publicKey: pk, secretKey: new Uint8Array(secretKey)};\n};\n\nnacl.sign.keyPair.fromSeed = function(seed) {\n checkArrayTypes(seed);\n if (seed.length !== crypto_sign_SEEDBYTES)\n throw new Error('bad seed size');\n var pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);\n var sk = new Uint8Array(crypto_sign_SECRETKEYBYTES);\n for (var i = 0; i < 32; i++) sk[i] = seed[i];\n crypto_sign_keypair(pk, sk, true);\n return {publicKey: pk, secretKey: sk};\n};\n\nnacl.sign.publicKeyLength = crypto_sign_PUBLICKEYBYTES;\nnacl.sign.secretKeyLength = crypto_sign_SECRETKEYBYTES;\nnacl.sign.seedLength = crypto_sign_SEEDBYTES;\nnacl.sign.signatureLength = crypto_sign_BYTES;\n\nnacl.hash = function(msg) {\n checkArrayTypes(msg);\n var h = new Uint8Array(crypto_hash_BYTES);\n crypto_hash(h, msg, msg.length);\n return h;\n};\n\nnacl.hash.hashLength = crypto_hash_BYTES;\n\nnacl.verify = function(x, y) {\n checkArrayTypes(x, y);\n // Zero length arguments are considered not equal.\n if (x.length === 0 || y.length === 0) return false;\n if (x.length !== y.length) return false;\n return (vn(x, 0, y, 0, x.length) === 0) ? true : false;\n};\n\nnacl.setPRNG = function(fn) {\n randombytes = fn;\n};\n\n(function() {\n // Initialize PRNG if environment provides CSPRNG.\n // If not, methods calling randombytes will throw.\n var crypto = typeof self !== 'undefined' ? (self.crypto || self.msCrypto) : null;\n if (crypto && crypto.getRandomValues) {\n // Browsers.\n var QUOTA = 65536;\n nacl.setPRNG(function(x, n) {\n var i, v = new Uint8Array(n);\n for (i = 0; i < n; i += QUOTA) {\n crypto.getRandomValues(v.subarray(i, i + Math.min(n - i, QUOTA)));\n }\n for (i = 0; i < n; i++) x[i] = v[i];\n cleanup(v);\n });\n } else if (typeof require !== 'undefined') {\n // Node.js.\n crypto = require('crypto');\n if (crypto && crypto.randomBytes) {\n nacl.setPRNG(function(x, n) {\n var i, v = crypto.randomBytes(n);\n for (i = 0; i < n; i++) x[i] = v[i];\n cleanup(v);\n });\n }\n }\n})();\n\n})(typeof module !== 'undefined' && module.exports ? module.exports : (self.nacl = self.nacl || {}));\n","module.exports = require('./pusher-with-encryption').default;\n","import ScriptReceiver from './script_receiver';\n\n/** Builds receivers for JSONP and Script requests.\n *\n * Each receiver is an object with following fields:\n * - number - unique (for the factory instance), numerical id of the receiver\n * - id - a string ID that can be used in DOM attributes\n * - name - name of the function triggering the receiver\n * - callback - callback function\n *\n * Receivers are triggered only once, on the first callback call.\n *\n * Receivers can be called by their name or by accessing factory object\n * by the number key.\n *\n * @param {String} prefix the prefix used in ids\n * @param {String} name the name of the object\n */\nexport class ScriptReceiverFactory {\n lastId: number;\n prefix: string;\n name: string;\n\n constructor(prefix: string, name: string) {\n this.lastId = 0;\n this.prefix = prefix;\n this.name = name;\n }\n\n create(callback: Function): ScriptReceiver {\n this.lastId++;\n\n var number = this.lastId;\n var id = this.prefix + number;\n var name = this.name + '[' + number + ']';\n\n var called = false;\n var callbackWrapper = function() {\n if (!called) {\n callback.apply(null, arguments);\n called = true;\n }\n };\n\n this[number] = callbackWrapper;\n return { number: number, id: id, name: name, callback: callbackWrapper };\n }\n\n remove(receiver: ScriptReceiver) {\n delete this[receiver.number];\n }\n}\n\nexport var ScriptReceivers = new ScriptReceiverFactory(\n '_pusher_script_',\n 'Pusher.ScriptReceivers'\n);\n","import {\n ChannelAuthorizationOptions,\n UserAuthenticationOptions\n} from './auth/options';\nimport { AuthTransport } from './config';\n\nexport interface DefaultConfig {\n VERSION: string;\n PROTOCOL: number;\n wsPort: number;\n wssPort: number;\n wsPath: string;\n httpHost: string;\n httpPort: number;\n httpsPort: number;\n httpPath: string;\n stats_host: string;\n authEndpoint: string;\n authTransport: AuthTransport;\n activityTimeout: number;\n pongTimeout: number;\n unavailableTimeout: number;\n userAuthentication: UserAuthenticationOptions;\n channelAuthorization: ChannelAuthorizationOptions;\n\n cdn_http?: string;\n cdn_https?: string;\n dependency_suffix?: string;\n}\n\nvar Defaults: DefaultConfig = {\n VERSION: VERSION,\n PROTOCOL: 7,\n\n wsPort: 80,\n wssPort: 443,\n wsPath: '',\n // DEPRECATED: SockJS fallback parameters\n httpHost: 'sockjs.pusher.com',\n httpPort: 80,\n httpsPort: 443,\n httpPath: '/pusher',\n // DEPRECATED: Stats\n stats_host: 'stats.pusher.com',\n // DEPRECATED: Other settings\n authEndpoint: '/pusher/auth',\n authTransport: 'ajax',\n activityTimeout: 120000,\n pongTimeout: 30000,\n unavailableTimeout: 10000,\n userAuthentication: {\n endpoint: '/pusher/user-auth',\n transport: 'ajax'\n },\n channelAuthorization: {\n endpoint: '/pusher/auth',\n transport: 'ajax'\n },\n\n // CDN configuration\n cdn_http: CDN_HTTP,\n cdn_https: CDN_HTTPS,\n dependency_suffix: DEPENDENCY_SUFFIX\n};\n\nexport default Defaults;\n","import { ScriptReceiverFactory } from './script_receiver_factory';\nimport Defaults from 'core/defaults';\nimport DependencyLoader from './dependency_loader';\n\nexport var DependenciesReceivers = new ScriptReceiverFactory(\n '_pusher_dependencies',\n 'Pusher.DependenciesReceivers'\n);\n\nexport var Dependencies = new DependencyLoader({\n cdn_http: Defaults.cdn_http,\n cdn_https: Defaults.cdn_https,\n version: Defaults.VERSION,\n suffix: Defaults.dependency_suffix,\n receivers: DependenciesReceivers\n});\n","import {\n ScriptReceivers,\n ScriptReceiverFactory\n} from './script_receiver_factory';\nimport Runtime from 'runtime';\nimport ScriptRequest from './script_request';\n\n/** Handles loading dependency files.\n *\n * Dependency loaders don't remember whether a resource has been loaded or\n * not. It is caller's responsibility to make sure the resource is not loaded\n * twice. This is because it's impossible to detect resource loading status\n * without knowing its content.\n *\n * Options:\n * - cdn_http - url to HTTP CND\n * - cdn_https - url to HTTPS CDN\n * - version - version of pusher-js\n * - suffix - suffix appended to all names of dependency files\n *\n * @param {Object} options\n */\nexport default class DependencyLoader {\n options: any;\n receivers: ScriptReceiverFactory;\n loading: any;\n\n constructor(options: any) {\n this.options = options;\n this.receivers = options.receivers || ScriptReceivers;\n this.loading = {};\n }\n\n /** Loads the dependency from CDN.\n *\n * @param {String} name\n * @param {Function} callback\n */\n load(name: string, options: any, callback: Function) {\n var self = this;\n\n if (self.loading[name] && self.loading[name].length > 0) {\n self.loading[name].push(callback);\n } else {\n self.loading[name] = [callback];\n\n var request = Runtime.createScriptRequest(self.getPath(name, options));\n var receiver = self.receivers.create(function(error) {\n self.receivers.remove(receiver);\n\n if (self.loading[name]) {\n var callbacks = self.loading[name];\n delete self.loading[name];\n\n var successCallback = function(wasSuccessful) {\n if (!wasSuccessful) {\n request.cleanup();\n }\n };\n for (var i = 0; i < callbacks.length; i++) {\n callbacks[i](error, successCallback);\n }\n }\n });\n request.send(receiver);\n }\n }\n\n /** Returns a root URL for pusher-js CDN.\n *\n * @returns {String}\n */\n getRoot(options: any): string {\n var cdn;\n var protocol = Runtime.getDocument().location.protocol;\n if ((options && options.useTLS) || protocol === 'https:') {\n cdn = this.options.cdn_https;\n } else {\n cdn = this.options.cdn_http;\n }\n // make sure there are no double slashes\n return cdn.replace(/\\/*$/, '') + '/' + this.options.version;\n }\n\n /** Returns a full path to a dependency file.\n *\n * @param {String} name\n * @returns {String}\n */\n getPath(name: string, options: any): string {\n return this.getRoot(options) + '/' + name + this.options.suffix + '.js';\n }\n}\n","/**\n * A place to store help URLs for error messages etc\n */\n\nconst urlStore = {\n baseUrl: 'https://pusher.com',\n urls: {\n authenticationEndpoint: {\n path: '/docs/channels/server_api/authenticating_users'\n },\n authorizationEndpoint: {\n path: '/docs/channels/server_api/authorizing-users/'\n },\n javascriptQuickStart: {\n path: '/docs/javascript_quick_start'\n },\n triggeringClientEvents: {\n path: '/docs/client_api_guide/client_events#trigger-events'\n },\n encryptedChannelSupport: {\n fullUrl:\n 'https://github.com/pusher/pusher-js/tree/cc491015371a4bde5743d1c87a0fbac0feb53195#encrypted-channel-support'\n }\n }\n};\n\n/** Builds a consistent string with links to pusher documentation\n *\n * @param {string} key - relevant key in the url_store.urls object\n * @return {string} suffix string to append to log message\n */\nconst buildLogSuffix = function(key: string): string {\n const urlPrefix = 'See:';\n const urlObj = urlStore.urls[key];\n if (!urlObj) return '';\n\n let url;\n if (urlObj.fullUrl) {\n url = urlObj.fullUrl;\n } else if (urlObj.path) {\n url = urlStore.baseUrl + urlObj.path;\n }\n\n if (!url) return '';\n return `${urlPrefix} ${url}`;\n};\n\nexport default { buildLogSuffix };\n","export enum AuthRequestType {\n UserAuthentication = 'user-authentication',\n ChannelAuthorization = 'channel-authorization'\n}\n\nexport interface ChannelAuthorizationData {\n auth: string;\n channel_data?: string;\n shared_secret?: string;\n}\n\nexport type ChannelAuthorizationCallback = (\n error: Error | null,\n authData: ChannelAuthorizationData | null\n) => void;\n\nexport interface ChannelAuthorizationRequestParams {\n socketId: string;\n channelName: string;\n}\n\nexport interface ChannelAuthorizationHandler {\n (\n params: ChannelAuthorizationRequestParams,\n callback: ChannelAuthorizationCallback\n ): void;\n}\n\nexport interface UserAuthenticationData {\n auth: string;\n user_data: string;\n}\n\nexport type UserAuthenticationCallback = (\n error: Error | null,\n authData: UserAuthenticationData | null\n) => void;\n\nexport interface UserAuthenticationRequestParams {\n socketId: string;\n}\n\nexport interface UserAuthenticationHandler {\n (\n params: UserAuthenticationRequestParams,\n callback: UserAuthenticationCallback\n ): void;\n}\n\nexport type AuthTransportCallback =\n | ChannelAuthorizationCallback\n | UserAuthenticationCallback;\n\nexport interface AuthOptionsT {\n transport: 'ajax' | 'jsonp';\n endpoint: string;\n params?: any;\n headers?: any;\n paramsProvider?: () => any;\n headersProvider?: () => any;\n customHandler?: AuthHandler;\n}\n\nexport declare type UserAuthenticationOptions = AuthOptionsT<\n UserAuthenticationHandler\n>;\nexport declare type ChannelAuthorizationOptions = AuthOptionsT<\n ChannelAuthorizationHandler\n>;\n\nexport interface InternalAuthOptions {\n transport: 'ajax' | 'jsonp';\n endpoint: string;\n params?: any;\n headers?: any;\n paramsProvider?: () => any;\n headersProvider?: () => any;\n}\n","/** Error classes used throughout the library. */\n// https://github.com/Microsoft/TypeScript-wiki/blob/master/Breaking-Changes.md#extending-built-ins-like-error-array-and-map-may-no-longer-work\nexport class BadEventName extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\nexport class BadChannelName extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\nexport class RequestTimedOut extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class TransportPriorityTooLow extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class TransportClosed extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class UnsupportedFeature extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class UnsupportedTransport extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class UnsupportedStrategy extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class HTTPAuthError extends Error {\n status: number;\n constructor(status: number, msg?: string) {\n super(msg);\n this.status = status;\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n","import TimelineSender from 'core/timeline/timeline_sender';\nimport * as Collections from 'core/utils/collections';\nimport Util from 'core/util';\nimport Runtime from 'runtime';\nimport { AuthTransport } from 'core/auth/auth_transports';\nimport AbstractRuntime from 'runtimes/interface';\nimport UrlStore from 'core/utils/url_store';\nimport {\n AuthRequestType,\n AuthTransportCallback,\n InternalAuthOptions\n} from 'core/auth/options';\nimport { HTTPAuthError } from 'core/errors';\n\nconst ajax: AuthTransport = function(\n context: AbstractRuntime,\n query: string,\n authOptions: InternalAuthOptions,\n authRequestType: AuthRequestType,\n callback: AuthTransportCallback\n) {\n const xhr = Runtime.createXHR();\n xhr.open('POST', authOptions.endpoint, true);\n\n // add request headers\n xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');\n for (var headerName in authOptions.headers) {\n xhr.setRequestHeader(headerName, authOptions.headers[headerName]);\n }\n if (authOptions.headersProvider != null) {\n let dynamicHeaders = authOptions.headersProvider();\n for (var headerName in dynamicHeaders) {\n xhr.setRequestHeader(headerName, dynamicHeaders[headerName]);\n }\n }\n\n xhr.onreadystatechange = function() {\n if (xhr.readyState === 4) {\n if (xhr.status === 200) {\n let data;\n let parsed = false;\n\n try {\n data = JSON.parse(xhr.responseText);\n parsed = true;\n } catch (e) {\n callback(\n new HTTPAuthError(\n 200,\n `JSON returned from ${authRequestType.toString()} endpoint was invalid, yet status code was 200. Data was: ${\n xhr.responseText\n }`\n ),\n null\n );\n }\n\n if (parsed) {\n // prevents double execution.\n callback(null, data);\n }\n } else {\n let suffix = '';\n switch (authRequestType) {\n case AuthRequestType.UserAuthentication:\n suffix = UrlStore.buildLogSuffix('authenticationEndpoint');\n break;\n case AuthRequestType.ChannelAuthorization:\n suffix = `Clients must be authorized to join private or presence channels. ${UrlStore.buildLogSuffix(\n 'authorizationEndpoint'\n )}`;\n break;\n }\n callback(\n new HTTPAuthError(\n xhr.status,\n `Unable to retrieve auth string from ${authRequestType.toString()} endpoint - ` +\n `received status: ${xhr.status} from ${authOptions.endpoint}. ${suffix}`\n ),\n null\n );\n }\n }\n };\n\n xhr.send(query);\n return xhr;\n};\n\nexport default ajax;\n","export default function encode(s: any): string {\n return btoa(utob(s));\n}\n\nvar fromCharCode = String.fromCharCode;\n\nvar b64chars =\n 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';\nvar b64tab = {};\n\nfor (var i = 0, l = b64chars.length; i < l; i++) {\n b64tab[b64chars.charAt(i)] = i;\n}\n\nvar cb_utob = function(c) {\n var cc = c.charCodeAt(0);\n return cc < 0x80\n ? c\n : cc < 0x800\n ? fromCharCode(0xc0 | (cc >>> 6)) + fromCharCode(0x80 | (cc & 0x3f))\n : fromCharCode(0xe0 | ((cc >>> 12) & 0x0f)) +\n fromCharCode(0x80 | ((cc >>> 6) & 0x3f)) +\n fromCharCode(0x80 | (cc & 0x3f));\n};\n\nvar utob = function(u) {\n return u.replace(/[^\\x00-\\x7F]/g, cb_utob);\n};\n\nvar cb_encode = function(ccc) {\n var padlen = [0, 2, 1][ccc.length % 3];\n var ord =\n (ccc.charCodeAt(0) << 16) |\n ((ccc.length > 1 ? ccc.charCodeAt(1) : 0) << 8) |\n (ccc.length > 2 ? ccc.charCodeAt(2) : 0);\n var chars = [\n b64chars.charAt(ord >>> 18),\n b64chars.charAt((ord >>> 12) & 63),\n padlen >= 2 ? '=' : b64chars.charAt((ord >>> 6) & 63),\n padlen >= 1 ? '=' : b64chars.charAt(ord & 63)\n ];\n return chars.join('');\n};\n\nvar btoa =\n global.btoa ||\n function(b) {\n return b.replace(/[\\s\\S]{1,3}/g, cb_encode);\n };\n","import TimedCallback from './timed_callback';\nimport { Delay, Scheduler, Canceller } from './scheduling';\n\nabstract class Timer {\n protected clear: Canceller;\n protected timer: number | void;\n\n constructor(\n set: Scheduler,\n clear: Canceller,\n delay: Delay,\n callback: TimedCallback\n ) {\n this.clear = clear;\n this.timer = set(() => {\n if (this.timer) {\n this.timer = callback(this.timer);\n }\n }, delay);\n }\n\n /** Returns whether the timer is still running.\n *\n * @return {Boolean}\n */\n isRunning(): boolean {\n return this.timer !== null;\n }\n\n /** Aborts a timer when it's running. */\n ensureAborted() {\n if (this.timer) {\n this.clear(this.timer);\n this.timer = null;\n }\n }\n}\n\nexport default Timer;\n","import Timer from './abstract_timer';\nimport TimedCallback from './timed_callback';\nimport { Delay } from './scheduling';\n\n// We need to bind clear functions this way to avoid exceptions on IE8\nfunction clearTimeout(timer) {\n global.clearTimeout(timer);\n}\nfunction clearInterval(timer) {\n global.clearInterval(timer);\n}\n\n/** Cross-browser compatible one-off timer abstraction.\n *\n * @param {Number} delay\n * @param {Function} callback\n */\nexport class OneOffTimer extends Timer {\n constructor(delay: Delay, callback: TimedCallback) {\n super(setTimeout, clearTimeout, delay, function(timer) {\n callback();\n return null;\n });\n }\n}\n\n/** Cross-browser compatible periodic timer abstraction.\n *\n * @param {Number} delay\n * @param {Function} callback\n */\nexport class PeriodicTimer extends Timer {\n constructor(delay: Delay, callback: TimedCallback) {\n super(setInterval, clearInterval, delay, function(timer) {\n callback();\n return timer;\n });\n }\n}\n","import * as Collections from './utils/collections';\nimport TimedCallback from './utils/timers/timed_callback';\nimport { OneOffTimer, PeriodicTimer } from './utils/timers';\n\nvar Util = {\n now(): number {\n if (Date.now) {\n return Date.now();\n } else {\n return new Date().valueOf();\n }\n },\n\n defer(callback: TimedCallback): OneOffTimer {\n return new OneOffTimer(0, callback);\n },\n\n /** Builds a function that will proxy a method call to its first argument.\n *\n * Allows partial application of arguments, so additional arguments are\n * prepended to the argument list.\n *\n * @param {String} name method name\n * @return {Function} proxy function\n */\n method(name: string, ...args: any[]): Function {\n var boundArguments = Array.prototype.slice.call(arguments, 1);\n return function(object) {\n return object[name].apply(object, boundArguments.concat(arguments));\n };\n }\n};\n\nexport default Util;\n","import base64encode from '../base64';\nimport Util from '../util';\n\n/** Merges multiple objects into the target argument.\n *\n * For properties that are plain Objects, performs a deep-merge. For the\n * rest it just copies the value of the property.\n *\n * To extend prototypes use it as following:\n * Pusher.Util.extend(Target.prototype, Base.prototype)\n *\n * You can also use it to merge objects without altering them:\n * Pusher.Util.extend({}, object1, object2)\n *\n * @param {Object} target\n * @return {Object} the target argument\n */\nexport function extend(target: any, ...sources: any[]): T {\n for (var i = 0; i < sources.length; i++) {\n var extensions = sources[i];\n for (var property in extensions) {\n if (\n extensions[property] &&\n extensions[property].constructor &&\n extensions[property].constructor === Object\n ) {\n target[property] = extend(target[property] || {}, extensions[property]);\n } else {\n target[property] = extensions[property];\n }\n }\n }\n return target;\n}\n\nexport function stringify(): string {\n var m = ['Pusher'];\n for (var i = 0; i < arguments.length; i++) {\n if (typeof arguments[i] === 'string') {\n m.push(arguments[i]);\n } else {\n m.push(safeJSONStringify(arguments[i]));\n }\n }\n return m.join(' : ');\n}\n\nexport function arrayIndexOf(array: any[], item: any): number {\n // MSIE doesn't have array.indexOf\n var nativeIndexOf = Array.prototype.indexOf;\n if (array === null) {\n return -1;\n }\n if (nativeIndexOf && array.indexOf === nativeIndexOf) {\n return array.indexOf(item);\n }\n for (var i = 0, l = array.length; i < l; i++) {\n if (array[i] === item) {\n return i;\n }\n }\n return -1;\n}\n\n/** Applies a function f to all properties of an object.\n *\n * Function f gets 3 arguments passed:\n * - element from the object\n * - key of the element\n * - reference to the object\n *\n * @param {Object} object\n * @param {Function} f\n */\nexport function objectApply(object: any, f: Function) {\n for (var key in object) {\n if (Object.prototype.hasOwnProperty.call(object, key)) {\n f(object[key], key, object);\n }\n }\n}\n\n/** Return a list of objects own proerty keys\n *\n * @param {Object} object\n * @returns {Array}\n */\nexport function keys(object: any): string[] {\n var keys = [];\n objectApply(object, function(_, key) {\n keys.push(key);\n });\n return keys;\n}\n\n/** Return a list of object's own property values\n *\n * @param {Object} object\n * @returns {Array}\n */\nexport function values(object: any): any[] {\n var values = [];\n objectApply(object, function(value) {\n values.push(value);\n });\n return values;\n}\n\n/** Applies a function f to all elements of an array.\n *\n * Function f gets 3 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function apply(array: any[], f: Function, context?: any) {\n for (var i = 0; i < array.length; i++) {\n f.call(context || global, array[i], i, array);\n }\n}\n\n/** Maps all elements of the array and returns the result.\n *\n * Function f gets 4 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n * - reference to the destination array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function map(array: any[], f: Function): any[] {\n var result = [];\n for (var i = 0; i < array.length; i++) {\n result.push(f(array[i], i, array, result));\n }\n return result;\n}\n\n/** Maps all elements of the object and returns the result.\n *\n * Function f gets 4 arguments passed:\n * - element from the object\n * - key of the element\n * - reference to the source object\n * - reference to the destination object\n *\n * @param {Object} object\n * @param {Function} f\n */\nexport function mapObject(object: any, f: Function): any {\n var result = {};\n objectApply(object, function(value, key) {\n result[key] = f(value);\n });\n return result;\n}\n\n/** Filters elements of the array using a test function.\n *\n * Function test gets 4 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n * - reference to the destination array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function filter(array: any[], test: Function): any[] {\n test =\n test ||\n function(value) {\n return !!value;\n };\n\n var result = [];\n for (var i = 0; i < array.length; i++) {\n if (test(array[i], i, array, result)) {\n result.push(array[i]);\n }\n }\n return result;\n}\n\n/** Filters properties of the object using a test function.\n *\n * Function test gets 4 arguments passed:\n * - element from the object\n * - key of the element\n * - reference to the source object\n * - reference to the destination object\n *\n * @param {Object} object\n * @param {Function} f\n */\nexport function filterObject(object: Object, test: Function) {\n var result = {};\n objectApply(object, function(value, key) {\n if ((test && test(value, key, object, result)) || Boolean(value)) {\n result[key] = value;\n }\n });\n return result;\n}\n\n/** Flattens an object into a two-dimensional array.\n *\n * @param {Object} object\n * @return {Array} resulting array of [key, value] pairs\n */\nexport function flatten(object: Object): any[] {\n var result = [];\n objectApply(object, function(value, key) {\n result.push([key, value]);\n });\n return result;\n}\n\n/** Checks whether any element of the array passes the test.\n *\n * Function test gets 3 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function any(array: any[], test: Function): boolean {\n for (var i = 0; i < array.length; i++) {\n if (test(array[i], i, array)) {\n return true;\n }\n }\n return false;\n}\n\n/** Checks whether all elements of the array pass the test.\n *\n * Function test gets 3 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function all(array: any[], test: Function): boolean {\n for (var i = 0; i < array.length; i++) {\n if (!test(array[i], i, array)) {\n return false;\n }\n }\n return true;\n}\n\nexport function encodeParamsObject(data): string {\n return mapObject(data, function(value) {\n if (typeof value === 'object') {\n value = safeJSONStringify(value);\n }\n return encodeURIComponent(base64encode(value.toString()));\n });\n}\n\nexport function buildQueryString(data: any): string {\n var params = filterObject(data, function(value) {\n return value !== undefined;\n });\n\n var query = map(\n flatten(encodeParamsObject(params)),\n Util.method('join', '=')\n ).join('&');\n\n return query;\n}\n\n/**\n * See https://github.com/douglascrockford/JSON-js/blob/master/cycle.js\n *\n * Remove circular references from an object. Required for JSON.stringify in\n * React Native, which tends to blow up a lot.\n *\n * @param {any} object\n * @return {any} Decycled object\n */\nexport function decycleObject(object: any): any {\n var objects = [],\n paths = [];\n\n return (function derez(value, path) {\n var i, name, nu;\n\n switch (typeof value) {\n case 'object':\n if (!value) {\n return null;\n }\n for (i = 0; i < objects.length; i += 1) {\n if (objects[i] === value) {\n return { $ref: paths[i] };\n }\n }\n\n objects.push(value);\n paths.push(path);\n\n if (Object.prototype.toString.apply(value) === '[object Array]') {\n nu = [];\n for (i = 0; i < value.length; i += 1) {\n nu[i] = derez(value[i], path + '[' + i + ']');\n }\n } else {\n nu = {};\n for (name in value) {\n if (Object.prototype.hasOwnProperty.call(value, name)) {\n nu[name] = derez(\n value[name],\n path + '[' + JSON.stringify(name) + ']'\n );\n }\n }\n }\n return nu;\n case 'number':\n case 'string':\n case 'boolean':\n return value;\n }\n })(object, '$');\n}\n\n/**\n * Provides a cross-browser and cross-platform way to safely stringify objects\n * into JSON. This is particularly necessary for ReactNative, where circular JSON\n * structures throw an exception.\n *\n * @param {any} source The object to stringify\n * @return {string} The serialized output.\n */\nexport function safeJSONStringify(source: any): string {\n try {\n return JSON.stringify(source);\n } catch (e) {\n return JSON.stringify(decycleObject(source));\n }\n}\n","import { stringify } from './utils/collections';\nimport Pusher from './pusher';\n\nclass Logger {\n debug(...args: any[]) {\n this.log(this.globalLog, args);\n }\n\n warn(...args: any[]) {\n this.log(this.globalLogWarn, args);\n }\n\n error(...args: any[]) {\n this.log(this.globalLogError, args);\n }\n\n private globalLog = (message: string) => {\n if (global.console && global.console.log) {\n global.console.log(message);\n }\n };\n\n private globalLogWarn(message: string) {\n if (global.console && global.console.warn) {\n global.console.warn(message);\n } else {\n this.globalLog(message);\n }\n }\n\n private globalLogError(message: string) {\n if (global.console && global.console.error) {\n global.console.error(message);\n } else {\n this.globalLogWarn(message);\n }\n }\n\n private log(\n defaultLoggingFunction: (message: string) => void,\n ...args: any[]\n ) {\n var message = stringify.apply(this, arguments);\n if (Pusher.log) {\n Pusher.log(message);\n } else if (Pusher.logToConsole) {\n const log = defaultLoggingFunction.bind(this);\n log(message);\n }\n }\n}\n\nexport default new Logger();\n","import Browser from '../browser';\nimport Logger from 'core/logger';\nimport JSONPRequest from '../dom/jsonp_request';\nimport { ScriptReceivers } from '../dom/script_receiver_factory';\nimport { AuthTransport } from 'core/auth/auth_transports';\nimport {\n AuthRequestType,\n AuthTransportCallback,\n InternalAuthOptions\n} from 'core/auth/options';\n\nvar jsonp: AuthTransport = function(\n context: Browser,\n query: string,\n authOptions: InternalAuthOptions,\n authRequestType: AuthRequestType,\n callback: AuthTransportCallback\n) {\n if (\n authOptions.headers !== undefined ||\n authOptions.headersProvider != null\n ) {\n Logger.warn(\n `To send headers with the ${authRequestType.toString()} request, you must use AJAX, rather than JSONP.`\n );\n }\n\n var callbackName = context.nextAuthCallbackID.toString();\n context.nextAuthCallbackID++;\n\n var document = context.getDocument();\n var script = document.createElement('script');\n // Hacked wrapper.\n context.auth_callbacks[callbackName] = function(data) {\n callback(null, data);\n };\n\n var callback_name = \"Pusher.auth_callbacks['\" + callbackName + \"']\";\n script.src =\n authOptions.endpoint +\n '?callback=' +\n encodeURIComponent(callback_name) +\n '&' +\n query;\n\n var head =\n document.getElementsByTagName('head')[0] || document.documentElement;\n head.insertBefore(script, head.firstChild);\n};\n\nexport default jsonp;\n","import ScriptReceiver from './script_receiver';\n\n/** Sends a generic HTTP GET request using a script tag.\n *\n * By constructing URL in a specific way, it can be used for loading\n * JavaScript resources or JSONP requests. It can notify about errors, but\n * only in certain environments. Please take care of monitoring the state of\n * the request yourself.\n *\n * @param {String} src\n */\nexport default class ScriptRequest {\n src: string;\n script: any;\n errorScript: any;\n\n constructor(src: string) {\n this.src = src;\n }\n\n send(receiver: ScriptReceiver) {\n var self = this;\n var errorString = 'Error loading ' + self.src;\n\n self.script = document.createElement('script');\n self.script.id = receiver.id;\n self.script.src = self.src;\n self.script.type = 'text/javascript';\n self.script.charset = 'UTF-8';\n\n if (self.script.addEventListener) {\n self.script.onerror = function() {\n receiver.callback(errorString);\n };\n self.script.onload = function() {\n receiver.callback(null);\n };\n } else {\n self.script.onreadystatechange = function() {\n if (\n self.script.readyState === 'loaded' ||\n self.script.readyState === 'complete'\n ) {\n receiver.callback(null);\n }\n };\n }\n\n // Opera<11.6 hack for missing onerror callback\n if (\n self.script.async === undefined &&\n (document).attachEvent &&\n /opera/i.test(navigator.userAgent)\n ) {\n self.errorScript = document.createElement('script');\n self.errorScript.id = receiver.id + '_error';\n self.errorScript.text = receiver.name + \"('\" + errorString + \"');\";\n self.script.async = self.errorScript.async = false;\n } else {\n self.script.async = true;\n }\n\n var head = document.getElementsByTagName('head')[0];\n head.insertBefore(self.script, head.firstChild);\n if (self.errorScript) {\n head.insertBefore(self.errorScript, self.script.nextSibling);\n }\n }\n\n /** Cleans up the DOM remains of the script request. */\n cleanup() {\n if (this.script) {\n this.script.onload = this.script.onerror = null;\n this.script.onreadystatechange = null;\n }\n if (this.script && this.script.parentNode) {\n this.script.parentNode.removeChild(this.script);\n }\n if (this.errorScript && this.errorScript.parentNode) {\n this.errorScript.parentNode.removeChild(this.errorScript);\n }\n this.script = null;\n this.errorScript = null;\n }\n}\n","import ScriptReceiver from './script_receiver';\nimport ScriptRequest from './script_request';\nimport * as Collections from 'core/utils/collections';\nimport Util from 'core/util';\nimport Runtime from '../runtime';\n\n/** Sends data via JSONP.\n *\n * Data is a key-value map. Its values are JSON-encoded and then passed\n * through base64. Finally, keys and encoded values are appended to the query\n * string.\n *\n * The class itself does not guarantee raising errors on failures, as it's not\n * possible to support such feature on all browsers. Instead, JSONP endpoint\n * should call back in a way that's easy to distinguish from browser calls,\n * for example by passing a second argument to the receiver.\n *\n * @param {String} url\n * @param {Object} data key-value map of data to be submitted\n */\nexport default class JSONPRequest {\n url: string;\n data: any;\n request: ScriptRequest;\n\n constructor(url: string, data: any) {\n this.url = url;\n this.data = data;\n }\n\n /** Sends the actual JSONP request.\n *\n * @param {ScriptReceiver} receiver\n */\n send(receiver: ScriptReceiver) {\n if (this.request) {\n return;\n }\n\n var query = Collections.buildQueryString(this.data);\n var url = this.url + '/' + receiver.number + '?' + query;\n this.request = Runtime.createScriptRequest(url);\n this.request.send(receiver);\n }\n\n /** Cleans up the DOM remains of the JSONP request. */\n cleanup() {\n if (this.request) {\n this.request.cleanup();\n }\n }\n}\n","import TimelineSender from 'core/timeline/timeline_sender';\nimport TimelineTransport from 'core/timeline/timeline_transport';\nimport Browser from 'runtime';\nimport { AuthTransport } from 'core/auth/auth_transports';\nimport { ScriptReceivers } from '../dom/script_receiver_factory';\n\nvar getAgent = function(sender: TimelineSender, useTLS: boolean) {\n return function(data: any, callback: Function) {\n var scheme = 'http' + (useTLS ? 's' : '') + '://';\n var url =\n scheme + (sender.host || sender.options.host) + sender.options.path;\n var request = Browser.createJSONPRequest(url, data);\n\n var receiver = Browser.ScriptReceivers.create(function(error, result) {\n ScriptReceivers.remove(receiver);\n request.cleanup();\n\n if (result && result.host) {\n sender.host = result.host;\n }\n if (callback) {\n callback(error, result);\n }\n });\n request.send(receiver);\n };\n};\n\nvar jsonp = {\n name: 'jsonp',\n getAgent\n};\n\nexport default jsonp;\n","import Defaults from '../defaults';\nimport { default as URLScheme, URLSchemeParams } from './url_scheme';\n\nfunction getGenericURL(\n baseScheme: string,\n params: URLSchemeParams,\n path: string\n): string {\n var scheme = baseScheme + (params.useTLS ? 's' : '');\n var host = params.useTLS ? params.hostTLS : params.hostNonTLS;\n return scheme + '://' + host + path;\n}\n\nfunction getGenericPath(key: string, queryString?: string): string {\n var path = '/app/' + key;\n var query =\n '?protocol=' +\n Defaults.PROTOCOL +\n '&client=js' +\n '&version=' +\n Defaults.VERSION +\n (queryString ? '&' + queryString : '');\n return path + query;\n}\n\nexport var ws: URLScheme = {\n getInitial: function(key: string, params: URLSchemeParams): string {\n var path = (params.httpPath || '') + getGenericPath(key, 'flash=false');\n return getGenericURL('ws', params, path);\n }\n};\n\nexport var http: URLScheme = {\n getInitial: function(key: string, params: URLSchemeParams): string {\n var path = (params.httpPath || '/pusher') + getGenericPath(key);\n return getGenericURL('http', params, path);\n }\n};\n\nexport var sockjs: URLScheme = {\n getInitial: function(key: string, params: URLSchemeParams): string {\n return getGenericURL('http', params, params.httpPath || '/pusher');\n },\n getPath: function(key: string, params: URLSchemeParams): string {\n return getGenericPath(key);\n }\n};\n","import Callback from './callback';\nimport * as Collections from '../utils/collections';\nimport CallbackTable from './callback_table';\n\nexport default class CallbackRegistry {\n _callbacks: CallbackTable;\n\n constructor() {\n this._callbacks = {};\n }\n\n get(name: string): Callback[] {\n return this._callbacks[prefix(name)];\n }\n\n add(name: string, callback: Function, context: any) {\n var prefixedEventName = prefix(name);\n this._callbacks[prefixedEventName] =\n this._callbacks[prefixedEventName] || [];\n this._callbacks[prefixedEventName].push({\n fn: callback,\n context: context\n });\n }\n\n remove(name?: string, callback?: Function, context?: any) {\n if (!name && !callback && !context) {\n this._callbacks = {};\n return;\n }\n\n var names = name ? [prefix(name)] : Collections.keys(this._callbacks);\n\n if (callback || context) {\n this.removeCallback(names, callback, context);\n } else {\n this.removeAllCallbacks(names);\n }\n }\n\n private removeCallback(names: string[], callback: Function, context: any) {\n Collections.apply(\n names,\n function(name) {\n this._callbacks[name] = Collections.filter(\n this._callbacks[name] || [],\n function(binding) {\n return (\n (callback && callback !== binding.fn) ||\n (context && context !== binding.context)\n );\n }\n );\n if (this._callbacks[name].length === 0) {\n delete this._callbacks[name];\n }\n },\n this\n );\n }\n\n private removeAllCallbacks(names: string[]) {\n Collections.apply(\n names,\n function(name) {\n delete this._callbacks[name];\n },\n this\n );\n }\n}\n\nfunction prefix(name: string): string {\n return '_' + name;\n}\n","import * as Collections from '../utils/collections';\nimport Callback from './callback';\nimport Metadata from '../channels/metadata';\nimport CallbackRegistry from './callback_registry';\n\n/** Manages callback bindings and event emitting.\n *\n * @param Function failThrough called when no listeners are bound to an event\n */\nexport default class Dispatcher {\n callbacks: CallbackRegistry;\n global_callbacks: Function[];\n failThrough: Function;\n\n constructor(failThrough?: Function) {\n this.callbacks = new CallbackRegistry();\n this.global_callbacks = [];\n this.failThrough = failThrough;\n }\n\n bind(eventName: string, callback: Function, context?: any) {\n this.callbacks.add(eventName, callback, context);\n return this;\n }\n\n bind_global(callback: Function) {\n this.global_callbacks.push(callback);\n return this;\n }\n\n unbind(eventName?: string, callback?: Function, context?: any) {\n this.callbacks.remove(eventName, callback, context);\n return this;\n }\n\n unbind_global(callback?: Function) {\n if (!callback) {\n this.global_callbacks = [];\n return this;\n }\n\n this.global_callbacks = Collections.filter(\n this.global_callbacks || [],\n c => c !== callback\n );\n\n return this;\n }\n\n unbind_all() {\n this.unbind();\n this.unbind_global();\n return this;\n }\n\n emit(eventName: string, data?: any, metadata?: Metadata): Dispatcher {\n for (var i = 0; i < this.global_callbacks.length; i++) {\n this.global_callbacks[i](eventName, data);\n }\n\n var callbacks = this.callbacks.get(eventName);\n var args = [];\n\n if (metadata) {\n // if there's a metadata argument, we need to call the callback with both\n // data and metadata regardless of whether data is undefined\n args.push(data, metadata);\n } else if (data) {\n // metadata is undefined, so we only need to call the callback with data\n // if data exists\n args.push(data);\n }\n\n if (callbacks && callbacks.length > 0) {\n for (var i = 0; i < callbacks.length; i++) {\n callbacks[i].fn.apply(callbacks[i].context || global, args);\n }\n } else if (this.failThrough) {\n this.failThrough(eventName, data);\n }\n\n return this;\n }\n}\n","import Util from '../util';\nimport * as Collections from '../utils/collections';\nimport { default as EventsDispatcher } from '../events/dispatcher';\nimport Logger from '../logger';\nimport TransportHooks from './transport_hooks';\nimport Socket from '../socket';\nimport Runtime from 'runtime';\nimport Timeline from '../timeline/timeline';\nimport TransportConnectionOptions from './transport_connection_options';\n\n/** Provides universal API for transport connections.\n *\n * Transport connection is a low-level object that wraps a connection method\n * and exposes a simple evented interface for the connection state and\n * messaging. It does not implement Pusher-specific WebSocket protocol.\n *\n * Additionally, it fetches resources needed for transport to work and exposes\n * an interface for querying transport features.\n *\n * States:\n * - new - initial state after constructing the object\n * - initializing - during initialization phase, usually fetching resources\n * - intialized - ready to establish a connection\n * - connection - when connection is being established\n * - open - when connection ready to be used\n * - closed - after connection was closed be either side\n *\n * Emits:\n * - error - after the connection raised an error\n *\n * Options:\n * - useTLS - whether connection should be over TLS\n * - hostTLS - host to connect to when connection is over TLS\n * - hostNonTLS - host to connect to when connection is over TLS\n *\n * @param {String} key application key\n * @param {Object} options\n */\nexport default class TransportConnection extends EventsDispatcher {\n hooks: TransportHooks;\n name: string;\n priority: number;\n key: string;\n options: TransportConnectionOptions;\n state: string;\n timeline: Timeline;\n activityTimeout: number;\n id: number;\n socket: Socket;\n beforeOpen: Function;\n initialize: Function;\n\n constructor(\n hooks: TransportHooks,\n name: string,\n priority: number,\n key: string,\n options: TransportConnectionOptions\n ) {\n super();\n this.initialize = Runtime.transportConnectionInitializer;\n this.hooks = hooks;\n this.name = name;\n this.priority = priority;\n this.key = key;\n this.options = options;\n\n this.state = 'new';\n this.timeline = options.timeline;\n this.activityTimeout = options.activityTimeout;\n this.id = this.timeline.generateUniqueID();\n }\n\n /** Checks whether the transport handles activity checks by itself.\n *\n * @return {Boolean}\n */\n handlesActivityChecks(): boolean {\n return Boolean(this.hooks.handlesActivityChecks);\n }\n\n /** Checks whether the transport supports the ping/pong API.\n *\n * @return {Boolean}\n */\n supportsPing(): boolean {\n return Boolean(this.hooks.supportsPing);\n }\n\n /** Tries to establish a connection.\n *\n * @returns {Boolean} false if transport is in invalid state\n */\n connect(): boolean {\n if (this.socket || this.state !== 'initialized') {\n return false;\n }\n\n var url = this.hooks.urls.getInitial(this.key, this.options);\n try {\n this.socket = this.hooks.getSocket(url, this.options);\n } catch (e) {\n Util.defer(() => {\n this.onError(e);\n this.changeState('closed');\n });\n return false;\n }\n\n this.bindListeners();\n\n Logger.debug('Connecting', { transport: this.name, url });\n this.changeState('connecting');\n return true;\n }\n\n /** Closes the connection.\n *\n * @return {Boolean} true if there was a connection to close\n */\n close(): boolean {\n if (this.socket) {\n this.socket.close();\n return true;\n } else {\n return false;\n }\n }\n\n /** Sends data over the open connection.\n *\n * @param {String} data\n * @return {Boolean} true only when in the \"open\" state\n */\n send(data: any): boolean {\n if (this.state === 'open') {\n // Workaround for MobileSafari bug (see https://gist.github.com/2052006)\n Util.defer(() => {\n if (this.socket) {\n this.socket.send(data);\n }\n });\n return true;\n } else {\n return false;\n }\n }\n\n /** Sends a ping if the connection is open and transport supports it. */\n ping() {\n if (this.state === 'open' && this.supportsPing()) {\n this.socket.ping();\n }\n }\n\n private onOpen() {\n if (this.hooks.beforeOpen) {\n this.hooks.beforeOpen(\n this.socket,\n this.hooks.urls.getPath(this.key, this.options)\n );\n }\n this.changeState('open');\n this.socket.onopen = undefined;\n }\n\n private onError(error) {\n this.emit('error', { type: 'WebSocketError', error: error });\n this.timeline.error(this.buildTimelineMessage({ error: error.toString() }));\n }\n\n private onClose(closeEvent?: any) {\n if (closeEvent) {\n this.changeState('closed', {\n code: closeEvent.code,\n reason: closeEvent.reason,\n wasClean: closeEvent.wasClean\n });\n } else {\n this.changeState('closed');\n }\n this.unbindListeners();\n this.socket = undefined;\n }\n\n private onMessage(message) {\n this.emit('message', message);\n }\n\n private onActivity() {\n this.emit('activity');\n }\n\n private bindListeners() {\n this.socket.onopen = () => {\n this.onOpen();\n };\n this.socket.onerror = error => {\n this.onError(error);\n };\n this.socket.onclose = closeEvent => {\n this.onClose(closeEvent);\n };\n this.socket.onmessage = message => {\n this.onMessage(message);\n };\n\n if (this.supportsPing()) {\n this.socket.onactivity = () => {\n this.onActivity();\n };\n }\n }\n\n private unbindListeners() {\n if (this.socket) {\n this.socket.onopen = undefined;\n this.socket.onerror = undefined;\n this.socket.onclose = undefined;\n this.socket.onmessage = undefined;\n if (this.supportsPing()) {\n this.socket.onactivity = undefined;\n }\n }\n }\n\n private changeState(state: string, params?: any) {\n this.state = state;\n this.timeline.info(\n this.buildTimelineMessage({\n state: state,\n params: params\n })\n );\n this.emit(state, params);\n }\n\n buildTimelineMessage(message): any {\n return Collections.extend({ cid: this.id }, message);\n }\n}\n","import Factory from '../utils/factory';\nimport TransportHooks from './transport_hooks';\nimport TransportConnection from './transport_connection';\nimport TransportConnectionOptions from './transport_connection_options';\n\n/** Provides interface for transport connection instantiation.\n *\n * Takes transport-specific hooks as the only argument, which allow checking\n * for transport support and creating its connections.\n *\n * Supported hooks: * - file - the name of the file to be fetched during initialization\n * - urls - URL scheme to be used by transport\n * - handlesActivityCheck - true when the transport handles activity checks\n * - supportsPing - true when the transport has a ping/activity API\n * - isSupported - tells whether the transport is supported in the environment\n * - getSocket - creates a WebSocket-compatible transport socket\n *\n * See transports.js for specific implementations.\n *\n * @param {Object} hooks object containing all needed transport hooks\n */\nexport default class Transport {\n hooks: TransportHooks;\n\n constructor(hooks: TransportHooks) {\n this.hooks = hooks;\n }\n\n /** Returns whether the transport is supported in the environment.\n *\n * @param {Object} envronment te environment details (encryption, settings)\n * @returns {Boolean} true when the transport is supported\n */\n isSupported(environment: any): boolean {\n return this.hooks.isSupported(environment);\n }\n\n /** Creates a transport connection.\n *\n * @param {String} name\n * @param {Number} priority\n * @param {String} key the application key\n * @param {Object} options\n * @returns {TransportConnection}\n */\n createConnection(\n name: string,\n priority: number,\n key: string,\n options: any\n ): TransportConnection {\n return new TransportConnection(this.hooks, name, priority, key, options);\n }\n}\n","import * as URLSchemes from 'core/transports/url_schemes';\nimport URLScheme from 'core/transports/url_scheme';\nimport Transport from 'core/transports/transport';\nimport Util from 'core/util';\nimport * as Collections from 'core/utils/collections';\nimport TransportHooks from 'core/transports/transport_hooks';\nimport TransportsTable from 'core/transports/transports_table';\nimport Runtime from 'runtime';\n\n/** WebSocket transport.\n *\n * Uses native WebSocket implementation, including MozWebSocket supported by\n * earlier Firefox versions.\n */\nvar WSTransport = new Transport({\n urls: URLSchemes.ws,\n handlesActivityChecks: false,\n supportsPing: false,\n\n isInitialized: function() {\n return Boolean(Runtime.getWebSocketAPI());\n },\n isSupported: function(): boolean {\n return Boolean(Runtime.getWebSocketAPI());\n },\n getSocket: function(url) {\n return Runtime.createWebSocket(url);\n }\n});\n\nvar httpConfiguration = {\n urls: URLSchemes.http,\n handlesActivityChecks: false,\n supportsPing: true,\n isInitialized: function() {\n return true;\n }\n};\n\nexport var streamingConfiguration = Collections.extend(\n {\n getSocket: function(url) {\n return Runtime.HTTPFactory.createStreamingSocket(url);\n }\n },\n httpConfiguration\n);\nexport var pollingConfiguration = Collections.extend(\n {\n getSocket: function(url) {\n return Runtime.HTTPFactory.createPollingSocket(url);\n }\n },\n httpConfiguration\n);\n\nvar xhrConfiguration = {\n isSupported: function(): boolean {\n return Runtime.isXHRSupported();\n }\n};\n\n/** HTTP streaming transport using CORS-enabled XMLHttpRequest. */\nvar XHRStreamingTransport = new Transport(\n (\n Collections.extend({}, streamingConfiguration, xhrConfiguration)\n )\n);\n\n/** HTTP long-polling transport using CORS-enabled XMLHttpRequest. */\nvar XHRPollingTransport = new Transport(\n Collections.extend({}, pollingConfiguration, xhrConfiguration)\n);\n\nvar Transports: TransportsTable = {\n ws: WSTransport,\n xhr_streaming: XHRStreamingTransport,\n xhr_polling: XHRPollingTransport\n};\n\nexport default Transports;\n","import {\n default as Transports,\n streamingConfiguration,\n pollingConfiguration\n} from 'isomorphic/transports/transports';\nimport Transport from 'core/transports/transport';\nimport TransportHooks from 'core/transports/transport_hooks';\nimport * as URLSchemes from 'core/transports/url_schemes';\nimport Runtime from 'runtime';\nimport { Dependencies } from '../dom/dependencies';\nimport * as Collections from 'core/utils/collections';\n\nvar SockJSTransport = new Transport({\n file: 'sockjs',\n urls: URLSchemes.sockjs,\n handlesActivityChecks: true,\n supportsPing: false,\n\n isSupported: function() {\n return true;\n },\n isInitialized: function() {\n return window.SockJS !== undefined;\n },\n getSocket: function(url, options) {\n return new window.SockJS(url, null, {\n js_path: Dependencies.getPath('sockjs', {\n useTLS: options.useTLS\n }),\n ignore_null_origin: options.ignoreNullOrigin\n });\n },\n beforeOpen: function(socket, path) {\n socket.send(\n JSON.stringify({\n path: path\n })\n );\n }\n});\n\nvar xdrConfiguration = {\n isSupported: function(environment): boolean {\n var yes = Runtime.isXDRSupported(environment.useTLS);\n return yes;\n }\n};\n\n/** HTTP streaming transport using XDomainRequest (IE 8,9). */\nvar XDRStreamingTransport = new Transport(\n (\n Collections.extend({}, streamingConfiguration, xdrConfiguration)\n )\n);\n\n/** HTTP long-polling transport using XDomainRequest (IE 8,9). */\nvar XDRPollingTransport = new Transport(\n Collections.extend({}, pollingConfiguration, xdrConfiguration)\n);\n\nTransports.xdr_streaming = XDRStreamingTransport;\nTransports.xdr_polling = XDRPollingTransport;\nTransports.sockjs = SockJSTransport;\n\nexport default Transports;\n","import Reachability from 'core/reachability';\nimport { default as EventsDispatcher } from 'core/events/dispatcher';\n\n/** Really basic interface providing network availability info.\n *\n * Emits:\n * - online - when browser goes online\n * - offline - when browser goes offline\n */\nexport class NetInfo extends EventsDispatcher implements Reachability {\n constructor() {\n super();\n var self = this;\n // This is okay, as IE doesn't support this stuff anyway.\n if (window.addEventListener !== undefined) {\n window.addEventListener(\n 'online',\n function() {\n self.emit('online');\n },\n false\n );\n window.addEventListener(\n 'offline',\n function() {\n self.emit('offline');\n },\n false\n );\n }\n }\n\n /** Returns whether browser is online or not\n *\n * Offline means definitely offline (no connection to router).\n * Inverse does NOT mean definitely online (only currently supported in Safari\n * and even there only means the device has a connection to the router).\n *\n * @return {Boolean}\n */\n isOnline(): boolean {\n if (window.navigator.onLine === undefined) {\n return true;\n } else {\n return window.navigator.onLine;\n }\n }\n}\n\nexport var Network = new NetInfo();\n","import Util from '../util';\nimport * as Collections from '../utils/collections';\nimport TransportManager from './transport_manager';\nimport TransportConnection from './transport_connection';\nimport Transport from './transport';\nimport PingDelayOptions from './ping_delay_options';\n\n/** Creates transport connections monitored by a transport manager.\n *\n * When a transport is closed, it might mean the environment does not support\n * it. It's possible that messages get stuck in an intermediate buffer or\n * proxies terminate inactive connections. To combat these problems,\n * assistants monitor the connection lifetime, report unclean exits and\n * adjust ping timeouts to keep the connection active. The decision to disable\n * a transport is the manager's responsibility.\n *\n * @param {TransportManager} manager\n * @param {TransportConnection} transport\n * @param {Object} options\n */\nexport default class AssistantToTheTransportManager {\n manager: TransportManager;\n transport: Transport;\n minPingDelay: number;\n maxPingDelay: number;\n pingDelay: number;\n\n constructor(\n manager: TransportManager,\n transport: Transport,\n options: PingDelayOptions\n ) {\n this.manager = manager;\n this.transport = transport;\n this.minPingDelay = options.minPingDelay;\n this.maxPingDelay = options.maxPingDelay;\n this.pingDelay = undefined;\n }\n\n /** Creates a transport connection.\n *\n * This function has the same API as Transport#createConnection.\n *\n * @param {String} name\n * @param {Number} priority\n * @param {String} key the application key\n * @param {Object} options\n * @returns {TransportConnection}\n */\n createConnection(\n name: string,\n priority: number,\n key: string,\n options: Object\n ): TransportConnection {\n options = Collections.extend({}, options, {\n activityTimeout: this.pingDelay\n });\n var connection = this.transport.createConnection(\n name,\n priority,\n key,\n options\n );\n\n var openTimestamp = null;\n\n var onOpen = function() {\n connection.unbind('open', onOpen);\n connection.bind('closed', onClosed);\n openTimestamp = Util.now();\n };\n var onClosed = closeEvent => {\n connection.unbind('closed', onClosed);\n\n if (closeEvent.code === 1002 || closeEvent.code === 1003) {\n // we don't want to use transports not obeying the protocol\n this.manager.reportDeath();\n } else if (!closeEvent.wasClean && openTimestamp) {\n // report deaths only for short-living transport\n var lifespan = Util.now() - openTimestamp;\n if (lifespan < 2 * this.maxPingDelay) {\n this.manager.reportDeath();\n this.pingDelay = Math.max(lifespan / 2, this.minPingDelay);\n }\n }\n };\n\n connection.bind('open', onOpen);\n return connection;\n }\n\n /** Returns whether the transport is supported in the environment.\n *\n * This function has the same API as Transport#isSupported. Might return false\n * when the manager decides to kill the transport.\n *\n * @param {Object} environment the environment details (encryption, settings)\n * @returns {Boolean} true when the transport is supported\n */\n isSupported(environment: string): boolean {\n return this.manager.isAlive() && this.transport.isSupported(environment);\n }\n}\n","import Action from './action';\nimport { PusherEvent } from './message-types';\n/**\n * Provides functions for handling Pusher protocol-specific messages.\n */\n\nconst Protocol = {\n /**\n * Decodes a message in a Pusher format.\n *\n * The MessageEvent we receive from the transport should contain a pusher event\n * (https://pusher.com/docs/pusher_protocol#events) serialized as JSON in the\n * data field\n *\n * The pusher event may contain a data field too, and it may also be\n * serialised as JSON\n *\n * Throws errors when messages are not parse'able.\n *\n * @param {MessageEvent} messageEvent\n * @return {PusherEvent}\n */\n decodeMessage: function(messageEvent: MessageEvent): PusherEvent {\n try {\n var messageData = JSON.parse(messageEvent.data);\n var pusherEventData = messageData.data;\n if (typeof pusherEventData === 'string') {\n try {\n pusherEventData = JSON.parse(messageData.data);\n } catch (e) {}\n }\n var pusherEvent: PusherEvent = {\n event: messageData.event,\n channel: messageData.channel,\n data: pusherEventData\n };\n if (messageData.user_id) {\n pusherEvent.user_id = messageData.user_id;\n }\n return pusherEvent;\n } catch (e) {\n throw { type: 'MessageParseError', error: e, data: messageEvent.data };\n }\n },\n\n /**\n * Encodes a message to be sent.\n *\n * @param {PusherEvent} event\n * @return {String}\n */\n encodeMessage: function(event: PusherEvent): string {\n return JSON.stringify(event);\n },\n\n /**\n * Processes a handshake message and returns appropriate actions.\n *\n * Returns an object with an 'action' and other action-specific properties.\n *\n * There are three outcomes when calling this function. First is a successful\n * connection attempt, when pusher:connection_established is received, which\n * results in a 'connected' action with an 'id' property. When passed a\n * pusher:error event, it returns a result with action appropriate to the\n * close code and an error. Otherwise, it raises an exception.\n *\n * @param {String} message\n * @result Object\n */\n processHandshake: function(messageEvent: MessageEvent): Action {\n var message = Protocol.decodeMessage(messageEvent);\n\n if (message.event === 'pusher:connection_established') {\n if (!message.data.activity_timeout) {\n throw 'No activity timeout specified in handshake';\n }\n return {\n action: 'connected',\n id: message.data.socket_id,\n activityTimeout: message.data.activity_timeout * 1000\n };\n } else if (message.event === 'pusher:error') {\n // From protocol 6 close codes are sent only once, so this only\n // happens when connection does not support close codes\n return {\n action: this.getCloseAction(message.data),\n error: this.getCloseError(message.data)\n };\n } else {\n throw 'Invalid handshake';\n }\n },\n\n /**\n * Dispatches the close event and returns an appropriate action name.\n *\n * See:\n * 1. https://developer.mozilla.org/en-US/docs/WebSockets/WebSockets_reference/CloseEvent\n * 2. http://pusher.com/docs/pusher_protocol\n *\n * @param {CloseEvent} closeEvent\n * @return {String} close action name\n */\n getCloseAction: function(closeEvent): string {\n if (closeEvent.code < 4000) {\n // ignore 1000 CLOSE_NORMAL, 1001 CLOSE_GOING_AWAY,\n // 1005 CLOSE_NO_STATUS, 1006 CLOSE_ABNORMAL\n // ignore 1007...3999\n // handle 1002 CLOSE_PROTOCOL_ERROR, 1003 CLOSE_UNSUPPORTED,\n // 1004 CLOSE_TOO_LARGE\n if (closeEvent.code >= 1002 && closeEvent.code <= 1004) {\n return 'backoff';\n } else {\n return null;\n }\n } else if (closeEvent.code === 4000) {\n return 'tls_only';\n } else if (closeEvent.code < 4100) {\n return 'refused';\n } else if (closeEvent.code < 4200) {\n return 'backoff';\n } else if (closeEvent.code < 4300) {\n return 'retry';\n } else {\n // unknown error\n return 'refused';\n }\n },\n\n /**\n * Returns an error or null basing on the close event.\n *\n * Null is returned when connection was closed cleanly. Otherwise, an object\n * with error details is returned.\n *\n * @param {CloseEvent} closeEvent\n * @return {Object} error object\n */\n getCloseError: function(closeEvent): any {\n if (closeEvent.code !== 1000 && closeEvent.code !== 1001) {\n return {\n type: 'PusherError',\n data: {\n code: closeEvent.code,\n message: closeEvent.reason || closeEvent.message\n }\n };\n } else {\n return null;\n }\n }\n};\n\nexport default Protocol;\n","import * as Collections from '../utils/collections';\nimport { default as EventsDispatcher } from '../events/dispatcher';\nimport Protocol from './protocol/protocol';\nimport { PusherEvent } from './protocol/message-types';\nimport Logger from '../logger';\nimport TransportConnection from '../transports/transport_connection';\nimport Socket from '../socket';\n/**\n * Provides Pusher protocol interface for transports.\n *\n * Emits following events:\n * - message - on received messages\n * - ping - on ping requests\n * - pong - on pong responses\n * - error - when the transport emits an error\n * - closed - after closing the transport\n *\n * It also emits more events when connection closes with a code.\n * See Protocol.getCloseAction to get more details.\n *\n * @param {Number} id\n * @param {AbstractTransport} transport\n */\nexport default class Connection extends EventsDispatcher implements Socket {\n id: string;\n transport: TransportConnection;\n activityTimeout: number;\n\n constructor(id: string, transport: TransportConnection) {\n super();\n this.id = id;\n this.transport = transport;\n this.activityTimeout = transport.activityTimeout;\n this.bindListeners();\n }\n\n /** Returns whether used transport handles activity checks by itself\n *\n * @returns {Boolean} true if activity checks are handled by the transport\n */\n handlesActivityChecks() {\n return this.transport.handlesActivityChecks();\n }\n\n /** Sends raw data.\n *\n * @param {String} data\n */\n send(data: any): boolean {\n return this.transport.send(data);\n }\n\n /** Sends an event.\n *\n * @param {String} name\n * @param {String} data\n * @param {String} [channel]\n * @returns {Boolean} whether message was sent or not\n */\n send_event(name: string, data: any, channel?: string): boolean {\n var event: PusherEvent = { event: name, data: data };\n if (channel) {\n event.channel = channel;\n }\n Logger.debug('Event sent', event);\n return this.send(Protocol.encodeMessage(event));\n }\n\n /** Sends a ping message to the server.\n *\n * Basing on the underlying transport, it might send either transport's\n * protocol-specific ping or pusher:ping event.\n */\n ping() {\n if (this.transport.supportsPing()) {\n this.transport.ping();\n } else {\n this.send_event('pusher:ping', {});\n }\n }\n\n /** Closes the connection. */\n close() {\n this.transport.close();\n }\n\n private bindListeners() {\n var listeners = {\n message: (messageEvent: MessageEvent) => {\n var pusherEvent;\n try {\n pusherEvent = Protocol.decodeMessage(messageEvent);\n } catch (e) {\n this.emit('error', {\n type: 'MessageParseError',\n error: e,\n data: messageEvent.data\n });\n }\n\n if (pusherEvent !== undefined) {\n Logger.debug('Event recd', pusherEvent);\n\n switch (pusherEvent.event) {\n case 'pusher:error':\n this.emit('error', {\n type: 'PusherError',\n data: pusherEvent.data\n });\n break;\n case 'pusher:ping':\n this.emit('ping');\n break;\n case 'pusher:pong':\n this.emit('pong');\n break;\n }\n this.emit('message', pusherEvent);\n }\n },\n activity: () => {\n this.emit('activity');\n },\n error: error => {\n this.emit('error', error);\n },\n closed: closeEvent => {\n unbindListeners();\n\n if (closeEvent && closeEvent.code) {\n this.handleCloseEvent(closeEvent);\n }\n\n this.transport = null;\n this.emit('closed');\n }\n };\n\n var unbindListeners = () => {\n Collections.objectApply(listeners, (listener, event) => {\n this.transport.unbind(event, listener);\n });\n };\n\n Collections.objectApply(listeners, (listener, event) => {\n this.transport.bind(event, listener);\n });\n }\n\n private handleCloseEvent(closeEvent: any) {\n var action = Protocol.getCloseAction(closeEvent);\n var error = Protocol.getCloseError(closeEvent);\n if (error) {\n this.emit('error', error);\n }\n if (action) {\n this.emit(action, { action: action, error: error });\n }\n }\n}\n","import Util from '../../util';\nimport * as Collections from '../../utils/collections';\nimport Protocol from '../protocol/protocol';\nimport Connection from '../connection';\nimport TransportConnection from '../../transports/transport_connection';\nimport HandshakePayload from './handshake_payload';\n\n/**\n * Handles Pusher protocol handshakes for transports.\n *\n * Calls back with a result object after handshake is completed. Results\n * always have two fields:\n * - action - string describing action to be taken after the handshake\n * - transport - the transport object passed to the constructor\n *\n * Different actions can set different additional properties on the result.\n * In the case of 'connected' action, there will be a 'connection' property\n * containing a Connection object for the transport. Other actions should\n * carry an 'error' property.\n *\n * @param {AbstractTransport} transport\n * @param {Function} callback\n */\nexport default class Handshake {\n transport: TransportConnection;\n callback: (HandshakePayload) => void;\n onMessage: Function;\n onClosed: Function;\n\n constructor(\n transport: TransportConnection,\n callback: (HandshakePayload) => void\n ) {\n this.transport = transport;\n this.callback = callback;\n this.bindListeners();\n }\n\n close() {\n this.unbindListeners();\n this.transport.close();\n }\n\n private bindListeners() {\n this.onMessage = m => {\n this.unbindListeners();\n\n var result;\n try {\n result = Protocol.processHandshake(m);\n } catch (e) {\n this.finish('error', { error: e });\n this.transport.close();\n return;\n }\n\n if (result.action === 'connected') {\n this.finish('connected', {\n connection: new Connection(result.id, this.transport),\n activityTimeout: result.activityTimeout\n });\n } else {\n this.finish(result.action, { error: result.error });\n this.transport.close();\n }\n };\n\n this.onClosed = closeEvent => {\n this.unbindListeners();\n\n var action = Protocol.getCloseAction(closeEvent) || 'backoff';\n var error = Protocol.getCloseError(closeEvent);\n this.finish(action, { error: error });\n };\n\n this.transport.bind('message', this.onMessage);\n this.transport.bind('closed', this.onClosed);\n }\n\n private unbindListeners() {\n this.transport.unbind('message', this.onMessage);\n this.transport.unbind('closed', this.onClosed);\n }\n\n private finish(action: string, params: any) {\n this.callback(\n Collections.extend({ transport: this.transport, action: action }, params)\n );\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport base64encode from '../base64';\nimport Timeline from './timeline';\nimport Runtime from 'runtime';\n\nexport interface TimelineSenderOptions {\n host?: string;\n port?: number;\n path?: string;\n}\n\nexport default class TimelineSender {\n timeline: Timeline;\n options: TimelineSenderOptions;\n host: string;\n\n constructor(timeline: Timeline, options: TimelineSenderOptions) {\n this.timeline = timeline;\n this.options = options || {};\n }\n\n send(useTLS: boolean, callback?: Function) {\n if (this.timeline.isEmpty()) {\n return;\n }\n\n this.timeline.send(\n Runtime.TimelineTransport.getAgent(this, useTLS),\n callback\n );\n }\n}\n","import { default as EventsDispatcher } from '../events/dispatcher';\nimport * as Errors from '../errors';\nimport Logger from '../logger';\nimport Pusher from '../pusher';\nimport { PusherEvent } from '../connection/protocol/message-types';\nimport Metadata from './metadata';\nimport UrlStore from '../utils/url_store';\nimport {\n ChannelAuthorizationData,\n ChannelAuthorizationCallback\n} from '../auth/options';\nimport { HTTPAuthError } from '../errors';\n\n/** Provides base public channel interface with an event emitter.\n *\n * Emits:\n * - pusher:subscription_succeeded - after subscribing successfully\n * - other non-internal events\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\nexport default class Channel extends EventsDispatcher {\n name: string;\n pusher: Pusher;\n subscribed: boolean;\n subscriptionPending: boolean;\n subscriptionCancelled: boolean;\n subscriptionCount: null;\n\n constructor(name: string, pusher: Pusher) {\n super(function(event, data) {\n Logger.debug('No callbacks on ' + name + ' for ' + event);\n });\n\n this.name = name;\n this.pusher = pusher;\n this.subscribed = false;\n this.subscriptionPending = false;\n this.subscriptionCancelled = false;\n }\n\n /** Skips authorization, since public channels don't require it.\n *\n * @param {Function} callback\n */\n authorize(socketId: string, callback: ChannelAuthorizationCallback) {\n return callback(null, { auth: '' });\n }\n\n /** Triggers an event */\n trigger(event: string, data: any) {\n if (event.indexOf('client-') !== 0) {\n throw new Errors.BadEventName(\n \"Event '\" + event + \"' does not start with 'client-'\"\n );\n }\n if (!this.subscribed) {\n var suffix = UrlStore.buildLogSuffix('triggeringClientEvents');\n Logger.warn(\n `Client event triggered before channel 'subscription_succeeded' event . ${suffix}`\n );\n }\n return this.pusher.send_event(event, data, this.name);\n }\n\n /** Signals disconnection to the channel. For internal use only. */\n disconnect() {\n this.subscribed = false;\n this.subscriptionPending = false;\n }\n\n /** Handles a PusherEvent. For internal use only.\n *\n * @param {PusherEvent} event\n */\n handleEvent(event: PusherEvent) {\n var eventName = event.event;\n var data = event.data;\n if (eventName === 'pusher_internal:subscription_succeeded') {\n this.handleSubscriptionSucceededEvent(event);\n } else if (eventName === 'pusher_internal:subscription_count') {\n this.handleSubscriptionCountEvent(event);\n } else if (eventName.indexOf('pusher_internal:') !== 0) {\n var metadata: Metadata = {};\n this.emit(eventName, data, metadata);\n }\n }\n\n handleSubscriptionSucceededEvent(event: PusherEvent) {\n this.subscriptionPending = false;\n this.subscribed = true;\n if (this.subscriptionCancelled) {\n this.pusher.unsubscribe(this.name);\n } else {\n this.emit('pusher:subscription_succeeded', event.data);\n }\n }\n\n handleSubscriptionCountEvent(event: PusherEvent) {\n if (event.data.subscription_count) {\n this.subscriptionCount = event.data.subscription_count;\n }\n\n this.emit('pusher:subscription_count', event.data);\n }\n\n /** Sends a subscription request. For internal use only. */\n subscribe() {\n if (this.subscribed) {\n return;\n }\n this.subscriptionPending = true;\n this.subscriptionCancelled = false;\n this.authorize(\n this.pusher.connection.socket_id,\n (error: Error | null, data: ChannelAuthorizationData) => {\n if (error) {\n this.subscriptionPending = false;\n // Why not bind to 'pusher:subscription_error' a level up, and log there?\n // Binding to this event would cause the warning about no callbacks being\n // bound (see constructor) to be suppressed, that's not what we want.\n Logger.error(error.toString());\n this.emit(\n 'pusher:subscription_error',\n Object.assign(\n {},\n {\n type: 'AuthError',\n error: error.message\n },\n error instanceof HTTPAuthError ? { status: error.status } : {}\n )\n );\n } else {\n this.pusher.send_event('pusher:subscribe', {\n auth: data.auth,\n channel_data: data.channel_data,\n channel: this.name\n });\n }\n }\n );\n }\n\n /** Sends an unsubscription request. For internal use only. */\n unsubscribe() {\n this.subscribed = false;\n this.pusher.send_event('pusher:unsubscribe', {\n channel: this.name\n });\n }\n\n /** Cancels an in progress subscription. For internal use only. */\n cancelSubscription() {\n this.subscriptionCancelled = true;\n }\n\n /** Reinstates an in progress subscripiton. For internal use only. */\n reinstateSubscription() {\n this.subscriptionCancelled = false;\n }\n}\n","import Factory from '../utils/factory';\nimport Channel from './channel';\nimport { ChannelAuthorizationCallback } from '../auth/options';\n\n/** Extends public channels to provide private channel interface.\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\nexport default class PrivateChannel extends Channel {\n /** Authorizes the connection to use the channel.\n *\n * @param {String} socketId\n * @param {Function} callback\n */\n authorize(socketId: string, callback: ChannelAuthorizationCallback) {\n return this.pusher.config.channelAuthorizer(\n {\n channelName: this.name,\n socketId: socketId\n },\n callback\n );\n }\n}\n","import * as Collections from '../utils/collections';\n\n/** Represents a collection of members of a presence channel. */\nexport default class Members {\n members: any;\n count: number;\n myID: any;\n me: any;\n\n constructor() {\n this.reset();\n }\n\n /** Returns member's info for given id.\n *\n * Resulting object containts two fields - id and info.\n *\n * @param {Number} id\n * @return {Object} member's info or null\n */\n get(id: string): any {\n if (Object.prototype.hasOwnProperty.call(this.members, id)) {\n return {\n id: id,\n info: this.members[id]\n };\n } else {\n return null;\n }\n }\n\n /** Calls back for each member in unspecified order.\n *\n * @param {Function} callback\n */\n each(callback: Function) {\n Collections.objectApply(this.members, (member, id) => {\n callback(this.get(id));\n });\n }\n\n /** Updates the id for connected member. For internal use only. */\n setMyID(id: string) {\n this.myID = id;\n }\n\n /** Handles subscription data. For internal use only. */\n onSubscription(subscriptionData: any) {\n this.members = subscriptionData.presence.hash;\n this.count = subscriptionData.presence.count;\n this.me = this.get(this.myID);\n }\n\n /** Adds a new member to the collection. For internal use only. */\n addMember(memberData: any) {\n if (this.get(memberData.user_id) === null) {\n this.count++;\n }\n this.members[memberData.user_id] = memberData.user_info;\n return this.get(memberData.user_id);\n }\n\n /** Adds a member from the collection. For internal use only. */\n removeMember(memberData: any) {\n var member = this.get(memberData.user_id);\n if (member) {\n delete this.members[memberData.user_id];\n this.count--;\n }\n return member;\n }\n\n /** Resets the collection to the initial state. For internal use only. */\n reset() {\n this.members = {};\n this.count = 0;\n this.myID = null;\n this.me = null;\n }\n}\n","import PrivateChannel from './private_channel';\nimport Logger from '../logger';\nimport Members from './members';\nimport Pusher from '../pusher';\nimport UrlStore from 'core/utils/url_store';\nimport { PusherEvent } from '../connection/protocol/message-types';\nimport Metadata from './metadata';\nimport { ChannelAuthorizationData } from '../auth/options';\n\nexport default class PresenceChannel extends PrivateChannel {\n members: Members;\n\n /** Adds presence channel functionality to private channels.\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\n constructor(name: string, pusher: Pusher) {\n super(name, pusher);\n this.members = new Members();\n }\n\n /** Authorizes the connection as a member of the channel.\n *\n * @param {String} socketId\n * @param {Function} callback\n */\n authorize(socketId: string, callback: Function) {\n super.authorize(socketId, async (error, authData) => {\n if (!error) {\n authData = authData as ChannelAuthorizationData;\n if (authData.channel_data != null) {\n var channelData = JSON.parse(authData.channel_data);\n this.members.setMyID(channelData.user_id);\n } else {\n await this.pusher.user.signinDonePromise;\n if (this.pusher.user.user_data != null) {\n // If the user is signed in, get the id of the authenticated user\n // and allow the presence authorization to continue.\n this.members.setMyID(this.pusher.user.user_data.id);\n } else {\n let suffix = UrlStore.buildLogSuffix('authorizationEndpoint');\n Logger.error(\n `Invalid auth response for channel '${this.name}', ` +\n `expected 'channel_data' field. ${suffix}, ` +\n `or the user should be signed in.`\n );\n callback('Invalid auth response');\n return;\n }\n }\n }\n callback(error, authData);\n });\n }\n\n /** Handles presence and subscription events. For internal use only.\n *\n * @param {PusherEvent} event\n */\n handleEvent(event: PusherEvent) {\n var eventName = event.event;\n if (eventName.indexOf('pusher_internal:') === 0) {\n this.handleInternalEvent(event);\n } else {\n var data = event.data;\n var metadata: Metadata = {};\n if (event.user_id) {\n metadata.user_id = event.user_id;\n }\n this.emit(eventName, data, metadata);\n }\n }\n handleInternalEvent(event: PusherEvent) {\n var eventName = event.event;\n var data = event.data;\n switch (eventName) {\n case 'pusher_internal:subscription_succeeded':\n this.handleSubscriptionSucceededEvent(event);\n break;\n case 'pusher_internal:subscription_count':\n this.handleSubscriptionCountEvent(event);\n break;\n case 'pusher_internal:member_added':\n var addedMember = this.members.addMember(data);\n this.emit('pusher:member_added', addedMember);\n break;\n case 'pusher_internal:member_removed':\n var removedMember = this.members.removeMember(data);\n if (removedMember) {\n this.emit('pusher:member_removed', removedMember);\n }\n break;\n }\n }\n\n handleSubscriptionSucceededEvent(event: PusherEvent) {\n this.subscriptionPending = false;\n this.subscribed = true;\n if (this.subscriptionCancelled) {\n this.pusher.unsubscribe(this.name);\n } else {\n this.members.onSubscription(event.data);\n this.emit('pusher:subscription_succeeded', this.members);\n }\n }\n\n /** Resets the channel state, including members map. For internal use only. */\n disconnect() {\n this.members.reset();\n super.disconnect();\n }\n}\n","import PrivateChannel from './private_channel';\nimport * as Errors from '../errors';\nimport Logger from '../logger';\nimport Pusher from '../pusher';\nimport { decode as encodeUTF8 } from '@stablelib/utf8';\nimport { decode as decodeBase64 } from '@stablelib/base64';\nimport Dispatcher from '../events/dispatcher';\nimport { PusherEvent } from '../connection/protocol/message-types';\nimport {\n ChannelAuthorizationData,\n ChannelAuthorizationCallback\n} from '../auth/options';\nimport * as nacl from 'tweetnacl';\n\n/** Extends private channels to provide encrypted channel interface.\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\nexport default class EncryptedChannel extends PrivateChannel {\n key: Uint8Array = null;\n nacl: nacl;\n\n constructor(name: string, pusher: Pusher, nacl: nacl) {\n super(name, pusher);\n this.nacl = nacl;\n }\n\n /** Authorizes the connection to use the channel.\n *\n * @param {String} socketId\n * @param {Function} callback\n */\n authorize(socketId: string, callback: ChannelAuthorizationCallback) {\n super.authorize(\n socketId,\n (error: Error | null, authData: ChannelAuthorizationData) => {\n if (error) {\n callback(error, authData);\n return;\n }\n let sharedSecret = authData['shared_secret'];\n if (!sharedSecret) {\n callback(\n new Error(\n `No shared_secret key in auth payload for encrypted channel: ${this.name}`\n ),\n null\n );\n return;\n }\n this.key = decodeBase64(sharedSecret);\n delete authData['shared_secret'];\n callback(null, authData);\n }\n );\n }\n\n trigger(event: string, data: any): boolean {\n throw new Errors.UnsupportedFeature(\n 'Client events are not currently supported for encrypted channels'\n );\n }\n\n /** Handles an event. For internal use only.\n *\n * @param {PusherEvent} event\n */\n handleEvent(event: PusherEvent) {\n var eventName = event.event;\n var data = event.data;\n if (\n eventName.indexOf('pusher_internal:') === 0 ||\n eventName.indexOf('pusher:') === 0\n ) {\n super.handleEvent(event);\n return;\n }\n this.handleEncryptedEvent(eventName, data);\n }\n\n private handleEncryptedEvent(event: string, data: any): void {\n if (!this.key) {\n Logger.debug(\n 'Received encrypted event before key has been retrieved from the authEndpoint'\n );\n return;\n }\n if (!data.ciphertext || !data.nonce) {\n Logger.error(\n 'Unexpected format for encrypted event, expected object with `ciphertext` and `nonce` fields, got: ' +\n data\n );\n return;\n }\n let cipherText = decodeBase64(data.ciphertext);\n if (cipherText.length < this.nacl.secretbox.overheadLength) {\n Logger.error(\n `Expected encrypted event ciphertext length to be ${this.nacl.secretbox.overheadLength}, got: ${cipherText.length}`\n );\n return;\n }\n let nonce = decodeBase64(data.nonce);\n if (nonce.length < this.nacl.secretbox.nonceLength) {\n Logger.error(\n `Expected encrypted event nonce length to be ${this.nacl.secretbox.nonceLength}, got: ${nonce.length}`\n );\n return;\n }\n\n let bytes = this.nacl.secretbox.open(cipherText, nonce, this.key);\n if (bytes === null) {\n Logger.debug(\n 'Failed to decrypt an event, probably because it was encrypted with a different key. Fetching a new key from the authEndpoint...'\n );\n // Try a single time to retrieve a new auth key and decrypt the event with it\n // If this fails, a new key will be requested when a new message is received\n this.authorize(this.pusher.connection.socket_id, (error, authData) => {\n if (error) {\n Logger.error(\n `Failed to make a request to the authEndpoint: ${authData}. Unable to fetch new key, so dropping encrypted event`\n );\n return;\n }\n bytes = this.nacl.secretbox.open(cipherText, nonce, this.key);\n if (bytes === null) {\n Logger.error(\n `Failed to decrypt event with new key. Dropping encrypted event`\n );\n return;\n }\n this.emit(event, this.getDataToEmit(bytes));\n return;\n });\n return;\n }\n this.emit(event, this.getDataToEmit(bytes));\n }\n\n // Try and parse the decrypted bytes as JSON. If we can't parse it, just\n // return the utf-8 string\n getDataToEmit(bytes: Uint8Array): string {\n let raw = encodeUTF8(bytes);\n try {\n return JSON.parse(raw);\n } catch {\n return raw;\n }\n }\n}\n","import { default as EventsDispatcher } from '../events/dispatcher';\nimport { OneOffTimer as Timer } from '../utils/timers';\nimport { Config } from '../config';\nimport Logger from '../logger';\nimport HandshakePayload from './handshake/handshake_payload';\nimport Connection from './connection';\nimport Strategy from '../strategies/strategy';\nimport StrategyRunner from '../strategies/strategy_runner';\nimport * as Collections from '../utils/collections';\nimport Timeline from '../timeline/timeline';\nimport ConnectionManagerOptions from './connection_manager_options';\nimport Runtime from 'runtime';\n\nimport {\n ErrorCallbacks,\n HandshakeCallbacks,\n ConnectionCallbacks\n} from './callbacks';\nimport Action from './protocol/action';\n\n/** Manages connection to Pusher.\n *\n * Uses a strategy (currently only default), timers and network availability\n * info to establish a connection and export its state. In case of failures,\n * manages reconnection attempts.\n *\n * Exports state changes as following events:\n * - \"state_change\", { previous: p, current: state }\n * - state\n *\n * States:\n * - initialized - initial state, never transitioned to\n * - connecting - connection is being established\n * - connected - connection has been fully established\n * - disconnected - on requested disconnection\n * - unavailable - after connection timeout or when there's no network\n * - failed - when the connection strategy is not supported\n *\n * Options:\n * - unavailableTimeout - time to transition to unavailable state\n * - activityTimeout - time after which ping message should be sent\n * - pongTimeout - time for Pusher to respond with pong before reconnecting\n *\n * @param {String} key application key\n * @param {Object} options\n */\nexport default class ConnectionManager extends EventsDispatcher {\n key: string;\n options: ConnectionManagerOptions;\n state: string;\n connection: Connection;\n usingTLS: boolean;\n timeline: Timeline;\n socket_id: string;\n unavailableTimer: Timer;\n activityTimer: Timer;\n retryTimer: Timer;\n activityTimeout: number;\n strategy: Strategy;\n runner: StrategyRunner;\n errorCallbacks: ErrorCallbacks;\n handshakeCallbacks: HandshakeCallbacks;\n connectionCallbacks: ConnectionCallbacks;\n\n constructor(key: string, options: ConnectionManagerOptions) {\n super();\n this.state = 'initialized';\n this.connection = null;\n\n this.key = key;\n this.options = options;\n this.timeline = this.options.timeline;\n this.usingTLS = this.options.useTLS;\n\n this.errorCallbacks = this.buildErrorCallbacks();\n this.connectionCallbacks = this.buildConnectionCallbacks(\n this.errorCallbacks\n );\n this.handshakeCallbacks = this.buildHandshakeCallbacks(this.errorCallbacks);\n\n var Network = Runtime.getNetwork();\n\n Network.bind('online', () => {\n this.timeline.info({ netinfo: 'online' });\n if (this.state === 'connecting' || this.state === 'unavailable') {\n this.retryIn(0);\n }\n });\n Network.bind('offline', () => {\n this.timeline.info({ netinfo: 'offline' });\n if (this.connection) {\n this.sendActivityCheck();\n }\n });\n\n this.updateStrategy();\n }\n\n switchCluster(key: string) {\n this.key = key;\n // This ensures that the new config coming from\n // pusher instance are taken into account\n // such as appKey and cluster\n this.updateStrategy();\n this.retryIn(0);\n }\n\n /** Establishes a connection to Pusher.\n *\n * Does nothing when connection is already established. See top-level doc\n * to find events emitted on connection attempts.\n */\n connect() {\n if (this.connection || this.runner) {\n return;\n }\n if (!this.strategy.isSupported()) {\n this.updateState('failed');\n return;\n }\n this.updateState('connecting');\n this.startConnecting();\n this.setUnavailableTimer();\n }\n\n /** Sends raw data.\n *\n * @param {String} data\n */\n send(data) {\n if (this.connection) {\n return this.connection.send(data);\n } else {\n return false;\n }\n }\n\n /** Sends an event.\n *\n * @param {String} name\n * @param {String} data\n * @param {String} [channel]\n * @returns {Boolean} whether message was sent or not\n */\n send_event(name: string, data: any, channel?: string) {\n if (this.connection) {\n return this.connection.send_event(name, data, channel);\n } else {\n return false;\n }\n }\n\n /** Closes the connection. */\n disconnect() {\n this.disconnectInternally();\n this.updateState('disconnected');\n }\n\n isUsingTLS() {\n return this.usingTLS;\n }\n\n private startConnecting() {\n var callback = (error, handshake) => {\n if (error) {\n this.runner = this.strategy.connect(0, callback);\n } else {\n if (handshake.action === 'error') {\n this.emit('error', {\n type: 'HandshakeError',\n error: handshake.error\n });\n this.timeline.error({ handshakeError: handshake.error });\n } else {\n this.abortConnecting(); // we don't support switching connections yet\n this.handshakeCallbacks[handshake.action](handshake);\n }\n }\n };\n this.runner = this.strategy.connect(0, callback);\n }\n\n private abortConnecting() {\n if (this.runner) {\n this.runner.abort();\n this.runner = null;\n }\n }\n\n private disconnectInternally() {\n this.abortConnecting();\n this.clearRetryTimer();\n this.clearUnavailableTimer();\n if (this.connection) {\n var connection = this.abandonConnection();\n connection.close();\n }\n }\n\n private updateStrategy() {\n this.strategy = this.options.getStrategy({\n key: this.key,\n timeline: this.timeline,\n useTLS: this.usingTLS\n });\n }\n\n private retryIn(delay) {\n this.timeline.info({ action: 'retry', delay: delay });\n if (delay > 0) {\n this.emit('connecting_in', Math.round(delay / 1000));\n }\n this.retryTimer = new Timer(delay || 0, () => {\n this.disconnectInternally();\n this.connect();\n });\n }\n\n private clearRetryTimer() {\n if (this.retryTimer) {\n this.retryTimer.ensureAborted();\n this.retryTimer = null;\n }\n }\n\n private setUnavailableTimer() {\n this.unavailableTimer = new Timer(this.options.unavailableTimeout, () => {\n this.updateState('unavailable');\n });\n }\n\n private clearUnavailableTimer() {\n if (this.unavailableTimer) {\n this.unavailableTimer.ensureAborted();\n }\n }\n\n private sendActivityCheck() {\n this.stopActivityCheck();\n this.connection.ping();\n // wait for pong response\n this.activityTimer = new Timer(this.options.pongTimeout, () => {\n this.timeline.error({ pong_timed_out: this.options.pongTimeout });\n this.retryIn(0);\n });\n }\n\n private resetActivityCheck() {\n this.stopActivityCheck();\n // send ping after inactivity\n if (this.connection && !this.connection.handlesActivityChecks()) {\n this.activityTimer = new Timer(this.activityTimeout, () => {\n this.sendActivityCheck();\n });\n }\n }\n\n private stopActivityCheck() {\n if (this.activityTimer) {\n this.activityTimer.ensureAborted();\n }\n }\n\n private buildConnectionCallbacks(\n errorCallbacks: ErrorCallbacks\n ): ConnectionCallbacks {\n return Collections.extend({}, errorCallbacks, {\n message: message => {\n // includes pong messages from server\n this.resetActivityCheck();\n this.emit('message', message);\n },\n ping: () => {\n this.send_event('pusher:pong', {});\n },\n activity: () => {\n this.resetActivityCheck();\n },\n error: error => {\n // just emit error to user - socket will already be closed by browser\n this.emit('error', error);\n },\n closed: () => {\n this.abandonConnection();\n if (this.shouldRetry()) {\n this.retryIn(1000);\n }\n }\n });\n }\n\n private buildHandshakeCallbacks(\n errorCallbacks: ErrorCallbacks\n ): HandshakeCallbacks {\n return Collections.extend({}, errorCallbacks, {\n connected: (handshake: HandshakePayload) => {\n this.activityTimeout = Math.min(\n this.options.activityTimeout,\n handshake.activityTimeout,\n handshake.connection.activityTimeout || Infinity\n );\n this.clearUnavailableTimer();\n this.setConnection(handshake.connection);\n this.socket_id = this.connection.id;\n this.updateState('connected', { socket_id: this.socket_id });\n }\n });\n }\n\n private buildErrorCallbacks(): ErrorCallbacks {\n let withErrorEmitted = callback => {\n return (result: Action | HandshakePayload) => {\n if (result.error) {\n this.emit('error', { type: 'WebSocketError', error: result.error });\n }\n callback(result);\n };\n };\n\n return {\n tls_only: withErrorEmitted(() => {\n this.usingTLS = true;\n this.updateStrategy();\n this.retryIn(0);\n }),\n refused: withErrorEmitted(() => {\n this.disconnect();\n }),\n backoff: withErrorEmitted(() => {\n this.retryIn(1000);\n }),\n retry: withErrorEmitted(() => {\n this.retryIn(0);\n })\n };\n }\n\n private setConnection(connection) {\n this.connection = connection;\n for (var event in this.connectionCallbacks) {\n this.connection.bind(event, this.connectionCallbacks[event]);\n }\n this.resetActivityCheck();\n }\n\n private abandonConnection() {\n if (!this.connection) {\n return;\n }\n this.stopActivityCheck();\n for (var event in this.connectionCallbacks) {\n this.connection.unbind(event, this.connectionCallbacks[event]);\n }\n var connection = this.connection;\n this.connection = null;\n return connection;\n }\n\n private updateState(newState: string, data?: any) {\n var previousState = this.state;\n this.state = newState;\n if (previousState !== newState) {\n var newStateDescription = newState;\n if (newStateDescription === 'connected') {\n newStateDescription += ' with new socket ID ' + data.socket_id;\n }\n Logger.debug(\n 'State changed',\n previousState + ' -> ' + newStateDescription\n );\n this.timeline.info({ state: newState, params: data });\n this.emit('state_change', { previous: previousState, current: newState });\n this.emit(newState, data);\n }\n }\n\n private shouldRetry(): boolean {\n return this.state === 'connecting' || this.state === 'connected';\n }\n}\n","import Channel from './channel';\nimport * as Collections from '../utils/collections';\nimport ChannelTable from './channel_table';\nimport Factory from '../utils/factory';\nimport Pusher from '../pusher';\nimport Logger from '../logger';\nimport * as Errors from '../errors';\nimport urlStore from '../utils/url_store';\n\n/** Handles a channel map. */\nexport default class Channels {\n channels: ChannelTable;\n\n constructor() {\n this.channels = {};\n }\n\n /** Creates or retrieves an existing channel by its name.\n *\n * @param {String} name\n * @param {Pusher} pusher\n * @return {Channel}\n */\n add(name: string, pusher: Pusher) {\n if (!this.channels[name]) {\n this.channels[name] = createChannel(name, pusher);\n }\n return this.channels[name];\n }\n\n /** Returns a list of all channels\n *\n * @return {Array}\n */\n all(): Channel[] {\n return Collections.values(this.channels);\n }\n\n /** Finds a channel by its name.\n *\n * @param {String} name\n * @return {Channel} channel or null if it doesn't exist\n */\n find(name: string) {\n return this.channels[name];\n }\n\n /** Removes a channel from the map.\n *\n * @param {String} name\n */\n remove(name: string) {\n var channel = this.channels[name];\n delete this.channels[name];\n return channel;\n }\n\n /** Proxies disconnection signal to all channels. */\n disconnect() {\n Collections.objectApply(this.channels, function(channel) {\n channel.disconnect();\n });\n }\n}\n\nfunction createChannel(name: string, pusher: Pusher): Channel {\n if (name.indexOf('private-encrypted-') === 0) {\n if (pusher.config.nacl) {\n return Factory.createEncryptedChannel(name, pusher, pusher.config.nacl);\n }\n let errMsg =\n 'Tried to subscribe to a private-encrypted- channel but no nacl implementation available';\n let suffix = urlStore.buildLogSuffix('encryptedChannelSupport');\n throw new Errors.UnsupportedFeature(`${errMsg}. ${suffix}`);\n } else if (name.indexOf('private-') === 0) {\n return Factory.createPrivateChannel(name, pusher);\n } else if (name.indexOf('presence-') === 0) {\n return Factory.createPresenceChannel(name, pusher);\n } else if (name.indexOf('#') === 0) {\n throw new Errors.BadChannelName(\n 'Cannot create a channel with name \"' + name + '\".'\n );\n } else {\n return Factory.createChannel(name, pusher);\n }\n}\n","import AssistantToTheTransportManager from '../transports/assistant_to_the_transport_manager';\nimport PingDelayOptions from '../transports/ping_delay_options';\nimport Transport from '../transports/transport';\nimport TransportManager from '../transports/transport_manager';\nimport Handshake from '../connection/handshake';\nimport TransportConnection from '../transports/transport_connection';\nimport SocketHooks from '../http/socket_hooks';\nimport HTTPSocket from '../http/http_socket';\n\nimport Timeline from '../timeline/timeline';\nimport {\n default as TimelineSender,\n TimelineSenderOptions\n} from '../timeline/timeline_sender';\nimport PresenceChannel from '../channels/presence_channel';\nimport PrivateChannel from '../channels/private_channel';\nimport EncryptedChannel from '../channels/encrypted_channel';\nimport Channel from '../channels/channel';\nimport ConnectionManager from '../connection/connection_manager';\nimport ConnectionManagerOptions from '../connection/connection_manager_options';\nimport Ajax from '../http/ajax';\nimport Channels from '../channels/channels';\nimport Pusher from '../pusher';\nimport { Config } from '../config';\nimport * as nacl from 'tweetnacl';\n\nvar Factory = {\n createChannels(): Channels {\n return new Channels();\n },\n\n createConnectionManager(\n key: string,\n options: ConnectionManagerOptions\n ): ConnectionManager {\n return new ConnectionManager(key, options);\n },\n\n createChannel(name: string, pusher: Pusher): Channel {\n return new Channel(name, pusher);\n },\n\n createPrivateChannel(name: string, pusher: Pusher): PrivateChannel {\n return new PrivateChannel(name, pusher);\n },\n\n createPresenceChannel(name: string, pusher: Pusher): PresenceChannel {\n return new PresenceChannel(name, pusher);\n },\n\n createEncryptedChannel(\n name: string,\n pusher: Pusher,\n nacl: nacl\n ): EncryptedChannel {\n return new EncryptedChannel(name, pusher, nacl);\n },\n\n createTimelineSender(timeline: Timeline, options: TimelineSenderOptions) {\n return new TimelineSender(timeline, options);\n },\n\n createHandshake(\n transport: TransportConnection,\n callback: (HandshakePayload) => void\n ): Handshake {\n return new Handshake(transport, callback);\n },\n\n createAssistantToTheTransportManager(\n manager: TransportManager,\n transport: Transport,\n options: PingDelayOptions\n ): AssistantToTheTransportManager {\n return new AssistantToTheTransportManager(manager, transport, options);\n }\n};\n\nexport default Factory;\n","import AssistantToTheTransportManager from './assistant_to_the_transport_manager';\nimport Transport from './transport';\nimport PingDelayOptions from './ping_delay_options';\nimport Factory from '../utils/factory';\n\nexport interface TransportManagerOptions extends PingDelayOptions {\n lives?: number;\n}\n\n/** Keeps track of the number of lives left for a transport.\n *\n * In the beginning of a session, transports may be assigned a number of\n * lives. When an AssistantToTheTransportManager instance reports a transport\n * connection closed uncleanly, the transport loses a life. When the number\n * of lives drops to zero, the transport gets disabled by its manager.\n *\n * @param {Object} options\n */\nexport default class TransportManager {\n options: TransportManagerOptions;\n livesLeft: number;\n\n constructor(options: TransportManagerOptions) {\n this.options = options || {};\n this.livesLeft = this.options.lives || Infinity;\n }\n\n /** Creates a assistant for the transport.\n *\n * @param {Transport} transport\n * @returns {AssistantToTheTransportManager}\n */\n getAssistant(transport: Transport): AssistantToTheTransportManager {\n return Factory.createAssistantToTheTransportManager(this, transport, {\n minPingDelay: this.options.minPingDelay,\n maxPingDelay: this.options.maxPingDelay\n });\n }\n\n /** Returns whether the transport has any lives left.\n *\n * @returns {Boolean}\n */\n isAlive(): boolean {\n return this.livesLeft > 0;\n }\n\n /** Takes one life from the transport. */\n reportDeath() {\n this.livesLeft -= 1;\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport { OneOffTimer as Timer } from '../utils/timers';\nimport Strategy from './strategy';\nimport StrategyOptions from './strategy_options';\n\n/** Loops through strategies with optional timeouts.\n *\n * Options:\n * - loop - whether it should loop through the substrategy list\n * - timeout - initial timeout for a single substrategy\n * - timeoutLimit - maximum timeout\n *\n * @param {Strategy[]} strategies\n * @param {Object} options\n */\nexport default class SequentialStrategy implements Strategy {\n strategies: Strategy[];\n loop: boolean;\n failFast: boolean;\n timeout: number;\n timeoutLimit: number;\n\n constructor(strategies: Strategy[], options: StrategyOptions) {\n this.strategies = strategies;\n this.loop = Boolean(options.loop);\n this.failFast = Boolean(options.failFast);\n this.timeout = options.timeout;\n this.timeoutLimit = options.timeoutLimit;\n }\n\n isSupported(): boolean {\n return Collections.any(this.strategies, Util.method('isSupported'));\n }\n\n connect(minPriority: number, callback: Function) {\n var strategies = this.strategies;\n var current = 0;\n var timeout = this.timeout;\n var runner = null;\n\n var tryNextStrategy = (error, handshake) => {\n if (handshake) {\n callback(null, handshake);\n } else {\n current = current + 1;\n if (this.loop) {\n current = current % strategies.length;\n }\n\n if (current < strategies.length) {\n if (timeout) {\n timeout = timeout * 2;\n if (this.timeoutLimit) {\n timeout = Math.min(timeout, this.timeoutLimit);\n }\n }\n runner = this.tryStrategy(\n strategies[current],\n minPriority,\n { timeout, failFast: this.failFast },\n tryNextStrategy\n );\n } else {\n callback(true);\n }\n }\n };\n\n runner = this.tryStrategy(\n strategies[current],\n minPriority,\n { timeout: timeout, failFast: this.failFast },\n tryNextStrategy\n );\n\n return {\n abort: function() {\n runner.abort();\n },\n forceMinPriority: function(p) {\n minPriority = p;\n if (runner) {\n runner.forceMinPriority(p);\n }\n }\n };\n }\n\n private tryStrategy(\n strategy: Strategy,\n minPriority: number,\n options: StrategyOptions,\n callback: Function\n ) {\n var timer = null;\n var runner = null;\n\n if (options.timeout > 0) {\n timer = new Timer(options.timeout, function() {\n runner.abort();\n callback(true);\n });\n }\n\n runner = strategy.connect(minPriority, function(error, handshake) {\n if (error && timer && timer.isRunning() && !options.failFast) {\n // advance to the next strategy after the timeout\n return;\n }\n if (timer) {\n timer.ensureAborted();\n }\n callback(error, handshake);\n });\n\n return {\n abort: function() {\n if (timer) {\n timer.ensureAborted();\n }\n runner.abort();\n },\n forceMinPriority: function(p) {\n runner.forceMinPriority(p);\n }\n };\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport Strategy from './strategy';\n\n/** Launches all substrategies and emits prioritized connected transports.\n *\n * @param {Array} strategies\n */\nexport default class BestConnectedEverStrategy implements Strategy {\n strategies: Strategy[];\n\n constructor(strategies: Strategy[]) {\n this.strategies = strategies;\n }\n\n isSupported(): boolean {\n return Collections.any(this.strategies, Util.method('isSupported'));\n }\n\n connect(minPriority: number, callback: Function) {\n return connect(this.strategies, minPriority, function(i, runners) {\n return function(error, handshake) {\n runners[i].error = error;\n if (error) {\n if (allRunnersFailed(runners)) {\n callback(true);\n }\n return;\n }\n Collections.apply(runners, function(runner) {\n runner.forceMinPriority(handshake.transport.priority);\n });\n callback(null, handshake);\n };\n });\n }\n}\n\n/** Connects to all strategies in parallel.\n *\n * Callback builder should be a function that takes two arguments: index\n * and a list of runners. It should return another function that will be\n * passed to the substrategy with given index. Runners can be aborted using\n * abortRunner(s) functions from this class.\n *\n * @param {Array} strategies\n * @param {Function} callbackBuilder\n * @return {Object} strategy runner\n */\nfunction connect(\n strategies: Strategy[],\n minPriority: number,\n callbackBuilder: Function\n) {\n var runners = Collections.map(strategies, function(strategy, i, _, rs) {\n return strategy.connect(minPriority, callbackBuilder(i, rs));\n });\n return {\n abort: function() {\n Collections.apply(runners, abortRunner);\n },\n forceMinPriority: function(p) {\n Collections.apply(runners, function(runner) {\n runner.forceMinPriority(p);\n });\n }\n };\n}\n\nfunction allRunnersFailed(runners): boolean {\n return Collections.all(runners, function(runner) {\n return Boolean(runner.error);\n });\n}\n\nfunction abortRunner(runner) {\n if (!runner.error && !runner.aborted) {\n runner.abort();\n runner.aborted = true;\n }\n}\n","import Util from '../util';\nimport Runtime from 'runtime';\nimport Strategy from './strategy';\nimport SequentialStrategy from './sequential_strategy';\nimport StrategyOptions from './strategy_options';\nimport TransportStrategy from './transport_strategy';\nimport Timeline from '../timeline/timeline';\nimport * as Collections from '../utils/collections';\n\nexport interface TransportStrategyDictionary {\n [key: string]: TransportStrategy;\n}\n\n/** Caches the last successful transport and, after the first few attempts,\n * uses the cached transport for subsequent attempts.\n *\n * @param {Strategy} strategy\n * @param {Object} transports\n * @param {Object} options\n */\nexport default class WebSocketPrioritizedCachedStrategy implements Strategy {\n strategy: Strategy;\n transports: TransportStrategyDictionary;\n ttl: number;\n usingTLS: boolean;\n timeline: Timeline;\n\n constructor(\n strategy: Strategy,\n transports: TransportStrategyDictionary,\n options: StrategyOptions\n ) {\n this.strategy = strategy;\n this.transports = transports;\n this.ttl = options.ttl || 1800 * 1000;\n this.usingTLS = options.useTLS;\n this.timeline = options.timeline;\n }\n\n isSupported(): boolean {\n return this.strategy.isSupported();\n }\n\n connect(minPriority: number, callback: Function) {\n var usingTLS = this.usingTLS;\n var info = fetchTransportCache(usingTLS);\n var cacheSkipCount = info && info.cacheSkipCount ? info.cacheSkipCount : 0;\n\n var strategies = [this.strategy];\n if (info && info.timestamp + this.ttl >= Util.now()) {\n var transport = this.transports[info.transport];\n if (transport) {\n if (['ws', 'wss'].includes(info.transport) || cacheSkipCount > 3) {\n this.timeline.info({\n cached: true,\n transport: info.transport,\n latency: info.latency\n });\n strategies.push(\n new SequentialStrategy([transport], {\n timeout: info.latency * 2 + 1000,\n failFast: true\n })\n );\n } else {\n cacheSkipCount++;\n }\n }\n }\n\n var startTimestamp = Util.now();\n var runner = strategies\n .pop()\n .connect(minPriority, function cb(error, handshake) {\n if (error) {\n flushTransportCache(usingTLS);\n if (strategies.length > 0) {\n startTimestamp = Util.now();\n runner = strategies.pop().connect(minPriority, cb);\n } else {\n callback(error);\n }\n } else {\n storeTransportCache(\n usingTLS,\n handshake.transport.name,\n Util.now() - startTimestamp,\n cacheSkipCount\n );\n callback(null, handshake);\n }\n });\n\n return {\n abort: function() {\n runner.abort();\n },\n forceMinPriority: function(p) {\n minPriority = p;\n if (runner) {\n runner.forceMinPriority(p);\n }\n }\n };\n }\n}\n\nfunction getTransportCacheKey(usingTLS: boolean): string {\n return 'pusherTransport' + (usingTLS ? 'TLS' : 'NonTLS');\n}\n\nfunction fetchTransportCache(usingTLS: boolean): any {\n var storage = Runtime.getLocalStorage();\n if (storage) {\n try {\n var serializedCache = storage[getTransportCacheKey(usingTLS)];\n if (serializedCache) {\n return JSON.parse(serializedCache);\n }\n } catch (e) {\n flushTransportCache(usingTLS);\n }\n }\n return null;\n}\n\nfunction storeTransportCache(\n usingTLS: boolean,\n transport: TransportStrategy,\n latency: number,\n cacheSkipCount: number\n) {\n var storage = Runtime.getLocalStorage();\n if (storage) {\n try {\n storage[getTransportCacheKey(usingTLS)] = Collections.safeJSONStringify({\n timestamp: Util.now(),\n transport: transport,\n latency: latency,\n cacheSkipCount: cacheSkipCount\n });\n } catch (e) {\n // catch over quota exceptions raised by localStorage\n }\n }\n}\n\nfunction flushTransportCache(usingTLS: boolean) {\n var storage = Runtime.getLocalStorage();\n if (storage) {\n try {\n delete storage[getTransportCacheKey(usingTLS)];\n } catch (e) {\n // catch exceptions raised by localStorage\n }\n }\n}\n","import { OneOffTimer as Timer } from '../utils/timers';\nimport Strategy from './strategy';\nimport StrategyOptions from './strategy_options';\n\n/** Runs substrategy after specified delay.\n *\n * Options:\n * - delay - time in miliseconds to delay the substrategy attempt\n *\n * @param {Strategy} strategy\n * @param {Object} options\n */\nexport default class DelayedStrategy implements Strategy {\n strategy: Strategy;\n options: { delay: number };\n\n constructor(strategy: Strategy, { delay: number }) {\n this.strategy = strategy;\n this.options = { delay: number };\n }\n\n isSupported(): boolean {\n return this.strategy.isSupported();\n }\n\n connect(minPriority: number, callback: Function) {\n var strategy = this.strategy;\n var runner;\n var timer = new Timer(this.options.delay, function() {\n runner = strategy.connect(minPriority, callback);\n });\n\n return {\n abort: function() {\n timer.ensureAborted();\n if (runner) {\n runner.abort();\n }\n },\n forceMinPriority: function(p) {\n minPriority = p;\n if (runner) {\n runner.forceMinPriority(p);\n }\n }\n };\n }\n}\n","import Strategy from './strategy';\nimport StrategyRunner from './strategy_runner';\n\n/** Proxies method calls to one of substrategies basing on the test function.\n *\n * @param {Function} test\n * @param {Strategy} trueBranch strategy used when test returns true\n * @param {Strategy} falseBranch strategy used when test returns false\n */\nexport default class IfStrategy implements Strategy {\n test: () => boolean;\n trueBranch: Strategy;\n falseBranch: Strategy;\n\n constructor(\n test: () => boolean,\n trueBranch: Strategy,\n falseBranch: Strategy\n ) {\n this.test = test;\n this.trueBranch = trueBranch;\n this.falseBranch = falseBranch;\n }\n\n isSupported(): boolean {\n var branch = this.test() ? this.trueBranch : this.falseBranch;\n return branch.isSupported();\n }\n\n connect(minPriority: number, callback: Function): StrategyRunner {\n var branch = this.test() ? this.trueBranch : this.falseBranch;\n return branch.connect(minPriority, callback);\n }\n}\n","import Strategy from './strategy';\nimport StrategyRunner from './strategy_runner';\n\n/** Launches the substrategy and terminates on the first open connection.\n *\n * @param {Strategy} strategy\n */\nexport default class FirstConnectedStrategy implements Strategy {\n strategy: Strategy;\n\n constructor(strategy: Strategy) {\n this.strategy = strategy;\n }\n\n isSupported(): boolean {\n return this.strategy.isSupported();\n }\n\n connect(minPriority: number, callback: Function): StrategyRunner {\n var runner = this.strategy.connect(minPriority, function(error, handshake) {\n if (handshake) {\n runner.abort();\n }\n callback(error, handshake);\n });\n return runner;\n }\n}\n","import * as Collections from 'core/utils/collections';\nimport TransportManager from 'core/transports/transport_manager';\nimport Strategy from 'core/strategies/strategy';\nimport StrategyOptions from 'core/strategies/strategy_options';\nimport SequentialStrategy from 'core/strategies/sequential_strategy';\nimport BestConnectedEverStrategy from 'core/strategies/best_connected_ever_strategy';\nimport WebSocketPrioritizedCachedStrategy, {\n TransportStrategyDictionary\n} from 'core/strategies/websocket_prioritized_cached_strategy';\nimport DelayedStrategy from 'core/strategies/delayed_strategy';\nimport IfStrategy from 'core/strategies/if_strategy';\nimport FirstConnectedStrategy from 'core/strategies/first_connected_strategy';\nimport { Config } from 'core/config';\n\nfunction testSupportsStrategy(strategy: Strategy) {\n return function() {\n return strategy.isSupported();\n };\n}\n\nvar getDefaultStrategy = function(\n config: Config,\n baseOptions: StrategyOptions,\n defineTransport: Function\n): Strategy {\n var definedTransports = {};\n\n function defineTransportStrategy(\n name: string,\n type: string,\n priority: number,\n options: StrategyOptions,\n manager?: TransportManager\n ) {\n var transport = defineTransport(\n config,\n name,\n type,\n priority,\n options,\n manager\n );\n\n definedTransports[name] = transport;\n\n return transport;\n }\n\n var ws_options: StrategyOptions = Object.assign({}, baseOptions, {\n hostNonTLS: config.wsHost + ':' + config.wsPort,\n hostTLS: config.wsHost + ':' + config.wssPort,\n httpPath: config.wsPath\n });\n var wss_options: StrategyOptions = Object.assign({}, ws_options, {\n useTLS: true\n });\n var sockjs_options: StrategyOptions = Object.assign({}, baseOptions, {\n hostNonTLS: config.httpHost + ':' + config.httpPort,\n hostTLS: config.httpHost + ':' + config.httpsPort,\n httpPath: config.httpPath\n });\n\n var timeouts = {\n loop: true,\n timeout: 15000,\n timeoutLimit: 60000\n };\n\n var ws_manager = new TransportManager({\n minPingDelay: 10000,\n maxPingDelay: config.activityTimeout\n });\n var streaming_manager = new TransportManager({\n lives: 2,\n minPingDelay: 10000,\n maxPingDelay: config.activityTimeout\n });\n\n var ws_transport = defineTransportStrategy(\n 'ws',\n 'ws',\n 3,\n ws_options,\n ws_manager\n );\n var wss_transport = defineTransportStrategy(\n 'wss',\n 'ws',\n 3,\n wss_options,\n ws_manager\n );\n var sockjs_transport = defineTransportStrategy(\n 'sockjs',\n 'sockjs',\n 1,\n sockjs_options\n );\n var xhr_streaming_transport = defineTransportStrategy(\n 'xhr_streaming',\n 'xhr_streaming',\n 1,\n sockjs_options,\n streaming_manager\n );\n var xdr_streaming_transport = defineTransportStrategy(\n 'xdr_streaming',\n 'xdr_streaming',\n 1,\n sockjs_options,\n streaming_manager\n );\n var xhr_polling_transport = defineTransportStrategy(\n 'xhr_polling',\n 'xhr_polling',\n 1,\n sockjs_options\n );\n var xdr_polling_transport = defineTransportStrategy(\n 'xdr_polling',\n 'xdr_polling',\n 1,\n sockjs_options\n );\n\n var ws_loop = new SequentialStrategy([ws_transport], timeouts);\n var wss_loop = new SequentialStrategy([wss_transport], timeouts);\n var sockjs_loop = new SequentialStrategy([sockjs_transport], timeouts);\n var streaming_loop = new SequentialStrategy(\n [\n new IfStrategy(\n testSupportsStrategy(xhr_streaming_transport),\n xhr_streaming_transport,\n xdr_streaming_transport\n )\n ],\n timeouts\n );\n var polling_loop = new SequentialStrategy(\n [\n new IfStrategy(\n testSupportsStrategy(xhr_polling_transport),\n xhr_polling_transport,\n xdr_polling_transport\n )\n ],\n timeouts\n );\n\n var http_loop = new SequentialStrategy(\n [\n new IfStrategy(\n testSupportsStrategy(streaming_loop),\n new BestConnectedEverStrategy([\n streaming_loop,\n new DelayedStrategy(polling_loop, { delay: 4000 })\n ]),\n polling_loop\n )\n ],\n timeouts\n );\n\n var http_fallback_loop = new IfStrategy(\n testSupportsStrategy(http_loop),\n http_loop,\n sockjs_loop\n );\n\n var wsStrategy;\n if (baseOptions.useTLS) {\n wsStrategy = new BestConnectedEverStrategy([\n ws_loop,\n new DelayedStrategy(http_fallback_loop, { delay: 2000 })\n ]);\n } else {\n wsStrategy = new BestConnectedEverStrategy([\n ws_loop,\n new DelayedStrategy(wss_loop, { delay: 2000 }),\n new DelayedStrategy(http_fallback_loop, { delay: 5000 })\n ]);\n }\n\n return new WebSocketPrioritizedCachedStrategy(\n new FirstConnectedStrategy(\n new IfStrategy(\n testSupportsStrategy(ws_transport),\n wsStrategy,\n http_fallback_loop\n )\n ),\n definedTransports,\n {\n ttl: 1800000,\n timeline: baseOptions.timeline,\n useTLS: baseOptions.useTLS\n }\n );\n};\n\nexport default getDefaultStrategy;\n","import HTTPRequest from 'core/http/http_request';\nimport RequestHooks from 'core/http/request_hooks';\nimport Ajax from 'core/http/ajax';\nimport * as Errors from 'core/errors';\n\nvar hooks: RequestHooks = {\n getRequest: function(socket: HTTPRequest): Ajax {\n var xdr = new (window).XDomainRequest();\n xdr.ontimeout = function() {\n socket.emit('error', new Errors.RequestTimedOut());\n socket.close();\n };\n xdr.onerror = function(e) {\n socket.emit('error', e);\n socket.close();\n };\n xdr.onprogress = function() {\n if (xdr.responseText && xdr.responseText.length > 0) {\n socket.onChunk(200, xdr.responseText);\n }\n };\n xdr.onload = function() {\n if (xdr.responseText && xdr.responseText.length > 0) {\n socket.onChunk(200, xdr.responseText);\n }\n socket.emit('finished', 200);\n socket.close();\n };\n return xdr;\n },\n abortRequest: function(xdr: Ajax) {\n xdr.ontimeout = xdr.onerror = xdr.onprogress = xdr.onload = null;\n xdr.abort();\n }\n};\n\nexport default hooks;\n","import Runtime from 'runtime';\nimport RequestHooks from './request_hooks';\nimport Ajax from './ajax';\nimport { default as EventsDispatcher } from '../events/dispatcher';\n\nconst MAX_BUFFER_LENGTH = 256 * 1024;\n\nexport default class HTTPRequest extends EventsDispatcher {\n hooks: RequestHooks;\n method: string;\n url: string;\n position: number;\n xhr: Ajax;\n unloader: Function;\n\n constructor(hooks: RequestHooks, method: string, url: string) {\n super();\n this.hooks = hooks;\n this.method = method;\n this.url = url;\n }\n\n start(payload?: any) {\n this.position = 0;\n this.xhr = this.hooks.getRequest(this);\n\n this.unloader = () => {\n this.close();\n };\n Runtime.addUnloadListener(this.unloader);\n\n this.xhr.open(this.method, this.url, true);\n\n if (this.xhr.setRequestHeader) {\n this.xhr.setRequestHeader('Content-Type', 'application/json'); // ReactNative doesn't set this header by default.\n }\n this.xhr.send(payload);\n }\n\n close() {\n if (this.unloader) {\n Runtime.removeUnloadListener(this.unloader);\n this.unloader = null;\n }\n if (this.xhr) {\n this.hooks.abortRequest(this.xhr);\n this.xhr = null;\n }\n }\n\n onChunk(status: number, data: any) {\n while (true) {\n var chunk = this.advanceBuffer(data);\n if (chunk) {\n this.emit('chunk', { status: status, data: chunk });\n } else {\n break;\n }\n }\n if (this.isBufferTooLong(data)) {\n this.emit('buffer_too_long');\n }\n }\n\n private advanceBuffer(buffer: any[]): any {\n var unreadData = buffer.slice(this.position);\n var endOfLinePosition = unreadData.indexOf('\\n');\n\n if (endOfLinePosition !== -1) {\n this.position += endOfLinePosition + 1;\n return unreadData.slice(0, endOfLinePosition);\n } else {\n // chunk is not finished yet, don't move the buffer pointer\n return null;\n }\n }\n\n private isBufferTooLong(buffer: any): boolean {\n return this.position === buffer.length && buffer.length > MAX_BUFFER_LENGTH;\n }\n}\n","enum State {\n CONNECTING = 0,\n OPEN = 1,\n CLOSED = 3\n}\n\nexport default State;\n","import URLLocation from './url_location';\nimport State from './state';\nimport Socket from '../socket';\nimport SocketHooks from './socket_hooks';\nimport Util from '../util';\nimport Ajax from './ajax';\nimport HTTPRequest from './http_request';\nimport Runtime from 'runtime';\n\nvar autoIncrement = 1;\n\nclass HTTPSocket implements Socket {\n hooks: SocketHooks;\n session: string;\n location: URLLocation;\n readyState: State;\n stream: HTTPRequest;\n\n onopen: () => void;\n onerror: (error: any) => void;\n onclose: (closeEvent: any) => void;\n onmessage: (message: any) => void;\n onactivity: () => void;\n\n constructor(hooks: SocketHooks, url: string) {\n this.hooks = hooks;\n this.session = randomNumber(1000) + '/' + randomString(8);\n this.location = getLocation(url);\n this.readyState = State.CONNECTING;\n this.openStream();\n }\n\n send(payload: any) {\n return this.sendRaw(JSON.stringify([payload]));\n }\n\n ping() {\n this.hooks.sendHeartbeat(this);\n }\n\n close(code: any, reason: any) {\n this.onClose(code, reason, true);\n }\n\n /** For internal use only */\n sendRaw(payload: any): boolean {\n if (this.readyState === State.OPEN) {\n try {\n Runtime.createSocketRequest(\n 'POST',\n getUniqueURL(getSendURL(this.location, this.session))\n ).start(payload);\n return true;\n } catch (e) {\n return false;\n }\n } else {\n return false;\n }\n }\n\n /** For internal use only */\n reconnect() {\n this.closeStream();\n this.openStream();\n }\n\n /** For internal use only */\n onClose(code, reason, wasClean) {\n this.closeStream();\n this.readyState = State.CLOSED;\n if (this.onclose) {\n this.onclose({\n code: code,\n reason: reason,\n wasClean: wasClean\n });\n }\n }\n\n private onChunk(chunk) {\n if (chunk.status !== 200) {\n return;\n }\n if (this.readyState === State.OPEN) {\n this.onActivity();\n }\n\n var payload;\n var type = chunk.data.slice(0, 1);\n switch (type) {\n case 'o':\n payload = JSON.parse(chunk.data.slice(1) || '{}');\n this.onOpen(payload);\n break;\n case 'a':\n payload = JSON.parse(chunk.data.slice(1) || '[]');\n for (var i = 0; i < payload.length; i++) {\n this.onEvent(payload[i]);\n }\n break;\n case 'm':\n payload = JSON.parse(chunk.data.slice(1) || 'null');\n this.onEvent(payload);\n break;\n case 'h':\n this.hooks.onHeartbeat(this);\n break;\n case 'c':\n payload = JSON.parse(chunk.data.slice(1) || '[]');\n this.onClose(payload[0], payload[1], true);\n break;\n }\n }\n\n private onOpen(options) {\n if (this.readyState === State.CONNECTING) {\n if (options && options.hostname) {\n this.location.base = replaceHost(this.location.base, options.hostname);\n }\n this.readyState = State.OPEN;\n\n if (this.onopen) {\n this.onopen();\n }\n } else {\n this.onClose(1006, 'Server lost session', true);\n }\n }\n\n private onEvent(event) {\n if (this.readyState === State.OPEN && this.onmessage) {\n this.onmessage({ data: event });\n }\n }\n\n private onActivity() {\n if (this.onactivity) {\n this.onactivity();\n }\n }\n\n private onError(error) {\n if (this.onerror) {\n this.onerror(error);\n }\n }\n\n private openStream() {\n this.stream = Runtime.createSocketRequest(\n 'POST',\n getUniqueURL(this.hooks.getReceiveURL(this.location, this.session))\n );\n\n this.stream.bind('chunk', chunk => {\n this.onChunk(chunk);\n });\n this.stream.bind('finished', status => {\n this.hooks.onFinished(this, status);\n });\n this.stream.bind('buffer_too_long', () => {\n this.reconnect();\n });\n\n try {\n this.stream.start();\n } catch (error) {\n Util.defer(() => {\n this.onError(error);\n this.onClose(1006, 'Could not start streaming', false);\n });\n }\n }\n\n private closeStream() {\n if (this.stream) {\n this.stream.unbind_all();\n this.stream.close();\n this.stream = null;\n }\n }\n}\n\nfunction getLocation(url): URLLocation {\n var parts = /([^\\?]*)\\/*(\\??.*)/.exec(url);\n return {\n base: parts[1],\n queryString: parts[2]\n };\n}\n\nfunction getSendURL(url: URLLocation, session: string): string {\n return url.base + '/' + session + '/xhr_send';\n}\n\nfunction getUniqueURL(url: string): string {\n var separator = url.indexOf('?') === -1 ? '?' : '&';\n return url + separator + 't=' + +new Date() + '&n=' + autoIncrement++;\n}\n\nfunction replaceHost(url: string, hostname: string): string {\n var urlParts = /(https?:\\/\\/)([^\\/:]+)((\\/|:)?.*)/.exec(url);\n return urlParts[1] + hostname + urlParts[3];\n}\n\nfunction randomNumber(max: number): number {\n return Runtime.randomInt(max);\n}\n\nfunction randomString(length: number): string {\n var result = [];\n\n for (var i = 0; i < length; i++) {\n result.push(randomNumber(32).toString(32));\n }\n\n return result.join('');\n}\n\nexport default HTTPSocket;\n","enum TimelineLevel {\n ERROR = 3,\n INFO = 6,\n DEBUG = 7\n}\n\nexport default TimelineLevel;\n","import SocketHooks from './socket_hooks';\nimport HTTPSocket from './http_socket';\n\nvar hooks: SocketHooks = {\n getReceiveURL: function(url, session) {\n return url.base + '/' + session + '/xhr_streaming' + url.queryString;\n },\n onHeartbeat: function(socket) {\n socket.sendRaw('[]');\n },\n sendHeartbeat: function(socket) {\n socket.sendRaw('[]');\n },\n onFinished: function(socket, status) {\n socket.onClose(1006, 'Connection interrupted (' + status + ')', false);\n }\n};\n\nexport default hooks;\n","import SocketHooks from './socket_hooks';\nimport URLLocation from './url_location';\nimport HTTPSocket from './http_socket';\n\nvar hooks: SocketHooks = {\n getReceiveURL: function(url: URLLocation, session: string): string {\n return url.base + '/' + session + '/xhr' + url.queryString;\n },\n onHeartbeat: function() {\n // next HTTP request will reset server's activity timer\n },\n sendHeartbeat: function(socket) {\n socket.sendRaw('[]');\n },\n onFinished: function(socket, status) {\n if (status === 200) {\n socket.reconnect();\n } else {\n socket.onClose(1006, 'Connection interrupted (' + status + ')', false);\n }\n }\n};\n\nexport default hooks;\n","import HTTPRequest from 'core/http/http_request';\nimport RequestHooks from 'core/http/request_hooks';\nimport Ajax from 'core/http/ajax';\nimport Runtime from 'runtime';\n\nvar hooks: RequestHooks = {\n getRequest: function(socket: HTTPRequest): Ajax {\n var Constructor = Runtime.getXHRAPI();\n var xhr = new Constructor();\n xhr.onreadystatechange = xhr.onprogress = function() {\n switch (xhr.readyState) {\n case 3:\n if (xhr.responseText && xhr.responseText.length > 0) {\n socket.onChunk(xhr.status, xhr.responseText);\n }\n break;\n case 4:\n // this happens only on errors, never after calling close\n if (xhr.responseText && xhr.responseText.length > 0) {\n socket.onChunk(xhr.status, xhr.responseText);\n }\n socket.emit('finished', xhr.status);\n socket.close();\n break;\n }\n };\n return xhr;\n },\n abortRequest: function(xhr: Ajax) {\n xhr.onreadystatechange = null;\n xhr.abort();\n }\n};\n\nexport default hooks;\n","import HTTPRequest from 'core/http/http_request';\nimport HTTPSocket from 'core/http/http_socket';\nimport SocketHooks from 'core/http/socket_hooks';\nimport RequestHooks from 'core/http/request_hooks';\nimport streamingHooks from 'core/http/http_streaming_socket';\nimport pollingHooks from 'core/http/http_polling_socket';\nimport xhrHooks from './http_xhr_request';\nimport HTTPFactory from 'core/http/http_factory';\n\nvar HTTP: HTTPFactory = {\n createStreamingSocket(url: string): HTTPSocket {\n return this.createSocket(streamingHooks, url);\n },\n\n createPollingSocket(url: string): HTTPSocket {\n return this.createSocket(pollingHooks, url);\n },\n\n createSocket(hooks: SocketHooks, url: string): HTTPSocket {\n return new HTTPSocket(hooks, url);\n },\n\n createXHR(method: string, url: string): HTTPRequest {\n return this.createRequest(xhrHooks, method, url);\n },\n\n createRequest(hooks: RequestHooks, method: string, url: string): HTTPRequest {\n return new HTTPRequest(hooks, method, url);\n }\n};\n\nexport default HTTP;\n","import xdrHooks from './http_xdomain_request';\nimport HTTP from 'isomorphic/http/http';\n\nHTTP.createXDR = function(method, url) {\n return this.createRequest(xdrHooks, method, url);\n};\n\nexport default HTTP;\n","import Browser from './browser';\nimport { Dependencies, DependenciesReceivers } from './dom/dependencies';\nimport { AuthTransport, AuthTransports } from 'core/auth/auth_transports';\nimport xhrAuth from 'isomorphic/auth/xhr_auth';\nimport jsonpAuth from './auth/jsonp_auth';\nimport TimelineTransport from 'core/timeline/timeline_transport';\nimport TimelineSender from 'core/timeline/timeline_sender';\nimport ScriptRequest from './dom/script_request';\nimport JSONPRequest from './dom/jsonp_request';\nimport * as Collections from 'core/utils/collections';\nimport { ScriptReceivers } from './dom/script_receiver_factory';\nimport jsonpTimeline from './timeline/jsonp_timeline';\nimport Transports from './transports/transports';\nimport Ajax from 'core/http/ajax';\nimport { Network } from './net_info';\nimport getDefaultStrategy from './default_strategy';\nimport transportConnectionInitializer from './transports/transport_connection_initializer';\nimport HTTPFactory from './http/http';\nimport HTTPRequest from 'core/http/http_request';\n\nvar Runtime: Browser = {\n // for jsonp auth\n nextAuthCallbackID: 1,\n auth_callbacks: {},\n ScriptReceivers,\n DependenciesReceivers,\n getDefaultStrategy,\n Transports,\n transportConnectionInitializer,\n HTTPFactory,\n\n TimelineTransport: jsonpTimeline,\n\n getXHRAPI() {\n return window.XMLHttpRequest;\n },\n\n getWebSocketAPI() {\n return window.WebSocket || window.MozWebSocket;\n },\n\n setup(PusherClass): void {\n (window).Pusher = PusherClass; // JSONp requires Pusher to be in the global scope.\n var initializeOnDocumentBody = () => {\n this.onDocumentBody(PusherClass.ready);\n };\n if (!(window).JSON) {\n Dependencies.load('json2', {}, initializeOnDocumentBody);\n } else {\n initializeOnDocumentBody();\n }\n },\n\n getDocument(): Document {\n return document;\n },\n\n getProtocol(): string {\n return this.getDocument().location.protocol;\n },\n\n getAuthorizers(): AuthTransports {\n return { ajax: xhrAuth, jsonp: jsonpAuth };\n },\n\n onDocumentBody(callback: Function) {\n if (document.body) {\n callback();\n } else {\n setTimeout(() => {\n this.onDocumentBody(callback);\n }, 0);\n }\n },\n\n createJSONPRequest(url: string, data: any): JSONPRequest {\n return new JSONPRequest(url, data);\n },\n\n createScriptRequest(src: string): ScriptRequest {\n return new ScriptRequest(src);\n },\n\n getLocalStorage() {\n try {\n return window.localStorage;\n } catch (e) {\n return undefined;\n }\n },\n\n createXHR(): Ajax {\n if (this.getXHRAPI()) {\n return this.createXMLHttpRequest();\n } else {\n return this.createMicrosoftXHR();\n }\n },\n\n createXMLHttpRequest(): Ajax {\n var Constructor = this.getXHRAPI();\n return new Constructor();\n },\n\n createMicrosoftXHR(): Ajax {\n return new ActiveXObject('Microsoft.XMLHTTP');\n },\n\n getNetwork() {\n return Network;\n },\n\n createWebSocket(url: string): any {\n var Constructor = this.getWebSocketAPI();\n return new Constructor(url);\n },\n\n createSocketRequest(method: string, url: string): HTTPRequest {\n if (this.isXHRSupported()) {\n return this.HTTPFactory.createXHR(method, url);\n } else if (this.isXDRSupported(url.indexOf('https:') === 0)) {\n return this.HTTPFactory.createXDR(method, url);\n } else {\n throw 'Cross-origin HTTP requests are not supported';\n }\n },\n\n isXHRSupported(): boolean {\n var Constructor = this.getXHRAPI();\n return (\n Boolean(Constructor) && new Constructor().withCredentials !== undefined\n );\n },\n\n isXDRSupported(useTLS?: boolean): boolean {\n var protocol = useTLS ? 'https:' : 'http:';\n var documentProtocol = this.getProtocol();\n return (\n Boolean(window['XDomainRequest']) && documentProtocol === protocol\n );\n },\n\n addUnloadListener(listener: any) {\n if (window.addEventListener !== undefined) {\n window.addEventListener('unload', listener, false);\n } else if (window.attachEvent !== undefined) {\n window.attachEvent('onunload', listener);\n }\n },\n\n removeUnloadListener(listener: any) {\n if (window.addEventListener !== undefined) {\n window.removeEventListener('unload', listener, false);\n } else if (window.detachEvent !== undefined) {\n window.detachEvent('onunload', listener);\n }\n },\n\n randomInt(max: number): number {\n /**\n * Return values in the range of [0, 1[\n */\n const random = function() {\n const crypto = window.crypto || window['msCrypto'];\n const random = crypto.getRandomValues(new Uint32Array(1))[0];\n\n return random / 2 ** 32;\n };\n\n return Math.floor(random() * max);\n }\n};\n\nexport default Runtime;\n","import { Dependencies } from '../dom/dependencies';\n\n/** Initializes the transport.\n *\n * Fetches resources if needed and then transitions to initialized.\n */\nexport default function() {\n var self = this;\n\n self.timeline.info(\n self.buildTimelineMessage({\n transport: self.name + (self.options.useTLS ? 's' : '')\n })\n );\n\n if (self.hooks.isInitialized()) {\n self.changeState('initialized');\n } else if (self.hooks.file) {\n self.changeState('initializing');\n Dependencies.load(\n self.hooks.file,\n { useTLS: self.options.useTLS },\n function(error, callback) {\n if (self.hooks.isInitialized()) {\n self.changeState('initialized');\n callback(true);\n } else {\n if (error) {\n self.onError(error);\n }\n self.onClose();\n callback(false);\n }\n }\n );\n } else {\n self.onClose();\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport { default as Level } from './level';\n\nexport interface TimelineOptions {\n level?: Level;\n limit?: number;\n version?: string;\n cluster?: string;\n features?: string[];\n params?: any;\n}\n\nexport default class Timeline {\n key: string;\n session: number;\n events: any[];\n options: TimelineOptions;\n sent: number;\n uniqueID: number;\n\n constructor(key: string, session: number, options: TimelineOptions) {\n this.key = key;\n this.session = session;\n this.events = [];\n this.options = options || {};\n this.sent = 0;\n this.uniqueID = 0;\n }\n\n log(level, event) {\n if (level <= this.options.level) {\n this.events.push(\n Collections.extend({}, event, { timestamp: Util.now() })\n );\n if (this.options.limit && this.events.length > this.options.limit) {\n this.events.shift();\n }\n }\n }\n\n error(event) {\n this.log(Level.ERROR, event);\n }\n\n info(event) {\n this.log(Level.INFO, event);\n }\n\n debug(event) {\n this.log(Level.DEBUG, event);\n }\n\n isEmpty() {\n return this.events.length === 0;\n }\n\n send(sendfn, callback) {\n var data = Collections.extend(\n {\n session: this.session,\n bundle: this.sent + 1,\n key: this.key,\n lib: 'js',\n version: this.options.version,\n cluster: this.options.cluster,\n features: this.options.features,\n timeline: this.events\n },\n this.options.params\n );\n\n this.events = [];\n sendfn(data, (error, result) => {\n if (!error) {\n this.sent++;\n }\n if (callback) {\n callback(error, result);\n }\n });\n\n return true;\n }\n\n generateUniqueID(): number {\n this.uniqueID++;\n return this.uniqueID;\n }\n}\n","import Factory from '../utils/factory';\nimport Util from '../util';\nimport * as Errors from '../errors';\nimport * as Collections from '../utils/collections';\nimport Strategy from './strategy';\nimport Transport from '../transports/transport';\nimport StrategyOptions from './strategy_options';\nimport Handshake from '../connection/handshake';\n\n/** Provides a strategy interface for transports.\n *\n * @param {String} name\n * @param {Number} priority\n * @param {Class} transport\n * @param {Object} options\n */\nexport default class TransportStrategy implements Strategy {\n name: string;\n priority: number;\n transport: Transport;\n options: StrategyOptions;\n\n constructor(\n name: string,\n priority: number,\n transport: Transport,\n options: StrategyOptions\n ) {\n this.name = name;\n this.priority = priority;\n this.transport = transport;\n this.options = options || {};\n }\n\n /** Returns whether the transport is supported in the browser.\n *\n * @returns {Boolean}\n */\n isSupported(): boolean {\n return this.transport.isSupported({\n useTLS: this.options.useTLS\n });\n }\n\n /** Launches a connection attempt and returns a strategy runner.\n *\n * @param {Function} callback\n * @return {Object} strategy runner\n */\n connect(minPriority: number, callback: Function) {\n if (!this.isSupported()) {\n return failAttempt(new Errors.UnsupportedStrategy(), callback);\n } else if (this.priority < minPriority) {\n return failAttempt(new Errors.TransportPriorityTooLow(), callback);\n }\n\n var connected = false;\n var transport = this.transport.createConnection(\n this.name,\n this.priority,\n this.options.key,\n this.options\n );\n var handshake = null;\n\n var onInitialized = function() {\n transport.unbind('initialized', onInitialized);\n transport.connect();\n };\n var onOpen = function() {\n handshake = Factory.createHandshake(transport, function(result) {\n connected = true;\n unbindListeners();\n callback(null, result);\n });\n };\n var onError = function(error) {\n unbindListeners();\n callback(error);\n };\n var onClosed = function() {\n unbindListeners();\n var serializedTransport;\n\n // The reason for this try/catch block is that on React Native\n // the WebSocket object is circular. Therefore transport.socket will\n // throw errors upon stringification. Collections.safeJSONStringify\n // discards circular references when serializing.\n serializedTransport = Collections.safeJSONStringify(transport);\n callback(new Errors.TransportClosed(serializedTransport));\n };\n\n var unbindListeners = function() {\n transport.unbind('initialized', onInitialized);\n transport.unbind('open', onOpen);\n transport.unbind('error', onError);\n transport.unbind('closed', onClosed);\n };\n\n transport.bind('initialized', onInitialized);\n transport.bind('open', onOpen);\n transport.bind('error', onError);\n transport.bind('closed', onClosed);\n\n // connect will be called automatically after initialization\n transport.initialize();\n\n return {\n abort: () => {\n if (connected) {\n return;\n }\n unbindListeners();\n if (handshake) {\n handshake.close();\n } else {\n transport.close();\n }\n },\n forceMinPriority: p => {\n if (connected) {\n return;\n }\n if (this.priority < p) {\n if (handshake) {\n handshake.close();\n } else {\n transport.close();\n }\n }\n }\n };\n }\n}\n\nfunction failAttempt(error: Error, callback: Function) {\n Util.defer(function() {\n callback(error);\n });\n return {\n abort: function() {},\n forceMinPriority: function() {}\n };\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport TransportManager from '../transports/transport_manager';\nimport * as Errors from '../errors';\nimport Strategy from './strategy';\nimport TransportStrategy from './transport_strategy';\nimport StrategyOptions from '../strategies/strategy_options';\nimport { Config } from '../config';\nimport Runtime from 'runtime';\n\nconst { Transports } = Runtime;\n\nexport var defineTransport = function(\n config: Config,\n name: string,\n type: string,\n priority: number,\n options: StrategyOptions,\n manager?: TransportManager\n): Strategy {\n var transportClass = Transports[type];\n if (!transportClass) {\n throw new Errors.UnsupportedTransport(type);\n }\n\n var enabled =\n (!config.enabledTransports ||\n Collections.arrayIndexOf(config.enabledTransports, name) !== -1) &&\n (!config.disabledTransports ||\n Collections.arrayIndexOf(config.disabledTransports, name) === -1);\n\n var transport;\n if (enabled) {\n options = Object.assign(\n { ignoreNullOrigin: config.ignoreNullOrigin },\n options\n );\n\n transport = new TransportStrategy(\n name,\n priority,\n manager ? manager.getAssistant(transportClass) : transportClass,\n options\n );\n } else {\n transport = UnsupportedStrategy;\n }\n\n return transport;\n};\n\nvar UnsupportedStrategy: Strategy = {\n isSupported: function() {\n return false;\n },\n connect: function(_, callback) {\n var deferred = Util.defer(function() {\n callback(new Errors.UnsupportedStrategy());\n });\n return {\n abort: function() {\n deferred.ensureAborted();\n },\n forceMinPriority: function() {}\n };\n }\n};\n","import ConnectionManager from './connection/connection_manager';\nimport {\n ChannelAuthorizationOptions,\n UserAuthenticationOptions\n} from './auth/options';\nimport {\n ChannelAuthorizerGenerator,\n DeprecatedAuthOptions\n} from './auth/deprecated_channel_authorizer';\nimport { AuthTransport, Transport } from './config';\nimport * as nacl from 'tweetnacl';\nimport Logger from './logger';\n\nexport interface Options {\n activityTimeout?: number;\n\n auth?: DeprecatedAuthOptions; // DEPRECATED use channelAuthorization instead\n authEndpoint?: string; // DEPRECATED use channelAuthorization instead\n authTransport?: AuthTransport; // DEPRECATED use channelAuthorization instead\n authorizer?: ChannelAuthorizerGenerator; // DEPRECATED use channelAuthorization instead\n\n channelAuthorization?: ChannelAuthorizationOptions;\n userAuthentication?: UserAuthenticationOptions;\n\n cluster: string;\n enableStats?: boolean;\n disableStats?: boolean;\n disabledTransports?: Transport[];\n enabledTransports?: Transport[];\n forceTLS?: boolean;\n httpHost?: string;\n httpPath?: string;\n httpPort?: number;\n httpsPort?: number;\n ignoreNullOrigin?: boolean;\n nacl?: nacl;\n pongTimeout?: number;\n statsHost?: string;\n timelineParams?: any;\n unavailableTimeout?: number;\n wsHost?: string;\n wsPath?: string;\n wsPort?: number;\n wssPort?: number;\n}\n\nexport interface ClusterOptions {\n appKey: string;\n cluster: string;\n}\n\nexport function validateOptions(options) {\n if (options == null) {\n throw 'You must pass an options object';\n }\n if (options.cluster == null) {\n throw 'Options object must provide a cluster';\n }\n if ('disableStats' in options) {\n Logger.warn(\n 'The disableStats option is deprecated in favor of enableStats'\n );\n }\n}\n","import {\n UserAuthenticationCallback,\n InternalAuthOptions,\n UserAuthenticationHandler,\n UserAuthenticationRequestParams,\n AuthRequestType\n} from './options';\n\nimport Runtime from 'runtime';\n\nconst composeChannelQuery = (\n params: UserAuthenticationRequestParams,\n authOptions: InternalAuthOptions\n) => {\n var query = 'socket_id=' + encodeURIComponent(params.socketId);\n\n for (var key in authOptions.params) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(authOptions.params[key]);\n }\n\n if (authOptions.paramsProvider != null) {\n let dynamicParams = authOptions.paramsProvider();\n for (var key in dynamicParams) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(dynamicParams[key]);\n }\n }\n\n return query;\n};\n\nconst UserAuthenticator = (\n authOptions: InternalAuthOptions\n): UserAuthenticationHandler => {\n if (typeof Runtime.getAuthorizers()[authOptions.transport] === 'undefined') {\n throw `'${authOptions.transport}' is not a recognized auth transport`;\n }\n\n return (\n params: UserAuthenticationRequestParams,\n callback: UserAuthenticationCallback\n ) => {\n const query = composeChannelQuery(params, authOptions);\n\n Runtime.getAuthorizers()[authOptions.transport](\n Runtime,\n query,\n authOptions,\n AuthRequestType.UserAuthentication,\n callback\n );\n };\n};\n\nexport default UserAuthenticator;\n","import {\n AuthRequestType,\n InternalAuthOptions,\n ChannelAuthorizationHandler,\n ChannelAuthorizationRequestParams,\n ChannelAuthorizationCallback\n} from './options';\n\nimport Runtime from 'runtime';\n\nconst composeChannelQuery = (\n params: ChannelAuthorizationRequestParams,\n authOptions: InternalAuthOptions\n) => {\n var query = 'socket_id=' + encodeURIComponent(params.socketId);\n\n query += '&channel_name=' + encodeURIComponent(params.channelName);\n\n for (var key in authOptions.params) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(authOptions.params[key]);\n }\n\n if (authOptions.paramsProvider != null) {\n let dynamicParams = authOptions.paramsProvider();\n for (var key in dynamicParams) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(dynamicParams[key]);\n }\n }\n\n return query;\n};\n\nconst ChannelAuthorizer = (\n authOptions: InternalAuthOptions\n): ChannelAuthorizationHandler => {\n if (typeof Runtime.getAuthorizers()[authOptions.transport] === 'undefined') {\n throw `'${authOptions.transport}' is not a recognized auth transport`;\n }\n\n return (\n params: ChannelAuthorizationRequestParams,\n callback: ChannelAuthorizationCallback\n ) => {\n const query = composeChannelQuery(params, authOptions);\n\n Runtime.getAuthorizers()[authOptions.transport](\n Runtime,\n query,\n authOptions,\n AuthRequestType.ChannelAuthorization,\n callback\n );\n };\n};\n\nexport default ChannelAuthorizer;\n","import { Options } from './options';\nimport Defaults from './defaults';\nimport {\n ChannelAuthorizationHandler,\n UserAuthenticationHandler,\n ChannelAuthorizationOptions\n} from './auth/options';\nimport UserAuthenticator from './auth/user_authenticator';\nimport ChannelAuthorizer from './auth/channel_authorizer';\nimport { ChannelAuthorizerProxy } from './auth/deprecated_channel_authorizer';\nimport Runtime from 'runtime';\nimport * as nacl from 'tweetnacl';\n\nexport type AuthTransport = 'ajax' | 'jsonp';\nexport type Transport =\n | 'ws'\n | 'wss'\n | 'xhr_streaming'\n | 'xhr_polling'\n | 'sockjs';\n\nexport interface Config {\n // these are all 'required' config parameters, it's not necessary for the user\n // to set them, but they have configured defaults.\n activityTimeout: number;\n enableStats: boolean;\n httpHost: string;\n httpPath: string;\n httpPort: number;\n httpsPort: number;\n pongTimeout: number;\n statsHost: string;\n unavailableTimeout: number;\n useTLS: boolean;\n wsHost: string;\n wsPath: string;\n wsPort: number;\n wssPort: number;\n userAuthenticator: UserAuthenticationHandler;\n channelAuthorizer: ChannelAuthorizationHandler;\n\n // these are all optional parameters or overrrides. The customer can set these\n // but it's not strictly necessary\n forceTLS?: boolean;\n cluster?: string;\n disabledTransports?: Transport[];\n enabledTransports?: Transport[];\n ignoreNullOrigin?: boolean;\n nacl?: nacl;\n timelineParams?: any;\n}\n\n// getConfig mainly sets the defaults for the options that are not provided\nexport function getConfig(opts: Options, pusher): Config {\n let config: Config = {\n activityTimeout: opts.activityTimeout || Defaults.activityTimeout,\n cluster: opts.cluster,\n httpPath: opts.httpPath || Defaults.httpPath,\n httpPort: opts.httpPort || Defaults.httpPort,\n httpsPort: opts.httpsPort || Defaults.httpsPort,\n pongTimeout: opts.pongTimeout || Defaults.pongTimeout,\n statsHost: opts.statsHost || Defaults.stats_host,\n unavailableTimeout: opts.unavailableTimeout || Defaults.unavailableTimeout,\n wsPath: opts.wsPath || Defaults.wsPath,\n wsPort: opts.wsPort || Defaults.wsPort,\n wssPort: opts.wssPort || Defaults.wssPort,\n\n enableStats: getEnableStatsConfig(opts),\n httpHost: getHttpHost(opts),\n useTLS: shouldUseTLS(opts),\n wsHost: getWebsocketHost(opts),\n\n userAuthenticator: buildUserAuthenticator(opts),\n channelAuthorizer: buildChannelAuthorizer(opts, pusher)\n };\n\n if ('disabledTransports' in opts)\n config.disabledTransports = opts.disabledTransports;\n if ('enabledTransports' in opts)\n config.enabledTransports = opts.enabledTransports;\n if ('ignoreNullOrigin' in opts)\n config.ignoreNullOrigin = opts.ignoreNullOrigin;\n if ('timelineParams' in opts) config.timelineParams = opts.timelineParams;\n if ('nacl' in opts) {\n config.nacl = opts.nacl;\n }\n\n return config;\n}\n\nfunction getHttpHost(opts: Options): string {\n if (opts.httpHost) {\n return opts.httpHost;\n }\n if (opts.cluster) {\n return `sockjs-${opts.cluster}.pusher.com`;\n }\n return Defaults.httpHost;\n}\n\nfunction getWebsocketHost(opts: Options): string {\n if (opts.wsHost) {\n return opts.wsHost;\n }\n return getWebsocketHostFromCluster(opts.cluster);\n}\n\nfunction getWebsocketHostFromCluster(cluster: string): string {\n return `ws-${cluster}.pusher.com`;\n}\n\nfunction shouldUseTLS(opts: Options): boolean {\n if (Runtime.getProtocol() === 'https:') {\n return true;\n } else if (opts.forceTLS === false) {\n return false;\n }\n return true;\n}\n\n// if enableStats is set take the value\n// if disableStats is set take the inverse\n// otherwise default to false\nfunction getEnableStatsConfig(opts: Options): boolean {\n if ('enableStats' in opts) {\n return opts.enableStats;\n }\n if ('disableStats' in opts) {\n return !opts.disableStats;\n }\n return false;\n}\n\nfunction buildUserAuthenticator(opts: Options): UserAuthenticationHandler {\n const userAuthentication = {\n ...Defaults.userAuthentication,\n ...opts.userAuthentication\n };\n if (\n 'customHandler' in userAuthentication &&\n userAuthentication['customHandler'] != null\n ) {\n return userAuthentication['customHandler'];\n }\n\n return UserAuthenticator(userAuthentication);\n}\n\nfunction buildChannelAuth(opts: Options, pusher): ChannelAuthorizationOptions {\n let channelAuthorization: ChannelAuthorizationOptions;\n if ('channelAuthorization' in opts) {\n channelAuthorization = {\n ...Defaults.channelAuthorization,\n ...opts.channelAuthorization\n };\n } else {\n channelAuthorization = {\n transport: opts.authTransport || Defaults.authTransport,\n endpoint: opts.authEndpoint || Defaults.authEndpoint\n };\n if ('auth' in opts) {\n if ('params' in opts.auth) channelAuthorization.params = opts.auth.params;\n if ('headers' in opts.auth)\n channelAuthorization.headers = opts.auth.headers;\n }\n if ('authorizer' in opts)\n channelAuthorization.customHandler = ChannelAuthorizerProxy(\n pusher,\n channelAuthorization,\n opts.authorizer\n );\n }\n return channelAuthorization;\n}\n\nfunction buildChannelAuthorizer(\n opts: Options,\n pusher\n): ChannelAuthorizationHandler {\n const channelAuthorization = buildChannelAuth(opts, pusher);\n if (\n 'customHandler' in channelAuthorization &&\n channelAuthorization['customHandler'] != null\n ) {\n return channelAuthorization['customHandler'];\n }\n\n return ChannelAuthorizer(channelAuthorization);\n}\n","import Channel from '../channels/channel';\nimport {\n ChannelAuthorizationCallback,\n ChannelAuthorizationHandler,\n ChannelAuthorizationRequestParams,\n InternalAuthOptions\n} from './options';\n\nexport interface DeprecatedChannelAuthorizer {\n authorize(socketId: string, callback: ChannelAuthorizationCallback): void;\n}\n\nexport interface ChannelAuthorizerGenerator {\n (\n channel: Channel,\n options: DeprecatedAuthorizerOptions\n ): DeprecatedChannelAuthorizer;\n}\n\nexport interface DeprecatedAuthOptions {\n params?: any;\n headers?: any;\n}\n\nexport interface DeprecatedAuthorizerOptions {\n authTransport: 'ajax' | 'jsonp';\n authEndpoint: string;\n auth?: DeprecatedAuthOptions;\n}\n\nexport const ChannelAuthorizerProxy = (\n pusher,\n authOptions: InternalAuthOptions,\n channelAuthorizerGenerator: ChannelAuthorizerGenerator\n): ChannelAuthorizationHandler => {\n const deprecatedAuthorizerOptions: DeprecatedAuthorizerOptions = {\n authTransport: authOptions.transport,\n authEndpoint: authOptions.endpoint,\n auth: {\n params: authOptions.params,\n headers: authOptions.headers\n }\n };\n return (\n params: ChannelAuthorizationRequestParams,\n callback: ChannelAuthorizationCallback\n ) => {\n const channel = pusher.channel(params.channelName);\n // This line creates a new channel authorizer every time.\n // In the past, this was only done once per channel and reused.\n // We can do that again if we want to keep this behavior intact.\n const channelAuthorizer: DeprecatedChannelAuthorizer = channelAuthorizerGenerator(\n channel,\n deprecatedAuthorizerOptions\n );\n channelAuthorizer.authorize(params.socketId, callback);\n };\n};\n","import Logger from './logger';\nimport Pusher from './pusher';\nimport EventsDispatcher from './events/dispatcher';\n\nexport default class WatchlistFacade extends EventsDispatcher {\n private pusher: Pusher;\n\n public constructor(pusher: Pusher) {\n super(function(eventName, data) {\n Logger.debug(`No callbacks on watchlist events for ${eventName}`);\n });\n\n this.pusher = pusher;\n this.bindWatchlistInternalEvent();\n }\n\n handleEvent(pusherEvent) {\n pusherEvent.data.events.forEach(watchlistEvent => {\n this.emit(watchlistEvent.name, watchlistEvent);\n });\n }\n\n private bindWatchlistInternalEvent() {\n this.pusher.connection.bind('message', pusherEvent => {\n var eventName = pusherEvent.event;\n if (eventName === 'pusher_internal:watchlist_events') {\n this.handleEvent(pusherEvent);\n }\n });\n }\n}\n","function flatPromise() {\n let resolve, reject;\n const promise = new Promise((res, rej) => {\n resolve = res;\n reject = rej;\n });\n return { promise, resolve, reject };\n}\n\nexport default flatPromise;\n","import Pusher from './pusher';\nimport Logger from './logger';\nimport {\n UserAuthenticationData,\n UserAuthenticationCallback\n} from './auth/options';\nimport Channel from './channels/channel';\nimport WatchlistFacade from './watchlist';\nimport EventsDispatcher from './events/dispatcher';\nimport flatPromise from './utils/flat_promise';\n\nexport default class UserFacade extends EventsDispatcher {\n pusher: Pusher;\n signin_requested: boolean = false;\n user_data: any = null;\n serverToUserChannel: Channel = null;\n signinDonePromise: Promise = null;\n watchlist: WatchlistFacade;\n private _signinDoneResolve: Function = null;\n\n public constructor(pusher: Pusher) {\n super(function(eventName, data) {\n Logger.debug('No callbacks on user for ' + eventName);\n });\n this.pusher = pusher;\n this.pusher.connection.bind('state_change', ({ previous, current }) => {\n if (previous !== 'connected' && current === 'connected') {\n this._signin();\n }\n if (previous === 'connected' && current !== 'connected') {\n this._cleanup();\n this._newSigninPromiseIfNeeded();\n }\n });\n\n this.watchlist = new WatchlistFacade(pusher);\n\n this.pusher.connection.bind('message', event => {\n var eventName = event.event;\n if (eventName === 'pusher:signin_success') {\n this._onSigninSuccess(event.data);\n }\n if (\n this.serverToUserChannel &&\n this.serverToUserChannel.name === event.channel\n ) {\n this.serverToUserChannel.handleEvent(event);\n }\n });\n }\n\n public signin() {\n if (this.signin_requested) {\n return;\n }\n\n this.signin_requested = true;\n this._signin();\n }\n\n private _signin() {\n if (!this.signin_requested) {\n return;\n }\n\n this._newSigninPromiseIfNeeded();\n\n if (this.pusher.connection.state !== 'connected') {\n // Signin will be attempted when the connection is connected\n return;\n }\n\n this.pusher.config.userAuthenticator(\n {\n socketId: this.pusher.connection.socket_id\n },\n this._onAuthorize\n );\n }\n\n private _onAuthorize: UserAuthenticationCallback = (\n err,\n authData: UserAuthenticationData\n ) => {\n if (err) {\n Logger.warn(`Error during signin: ${err}`);\n this._cleanup();\n return;\n }\n\n this.pusher.send_event('pusher:signin', {\n auth: authData.auth,\n user_data: authData.user_data\n });\n\n // Later when we get pusher:singin_success event, the user will be marked as signed in\n };\n\n private _onSigninSuccess(data: any) {\n try {\n this.user_data = JSON.parse(data.user_data);\n } catch (e) {\n Logger.error(`Failed parsing user data after signin: ${data.user_data}`);\n this._cleanup();\n return;\n }\n\n if (typeof this.user_data.id !== 'string' || this.user_data.id === '') {\n Logger.error(\n `user_data doesn't contain an id. user_data: ${this.user_data}`\n );\n this._cleanup();\n return;\n }\n\n // Signin succeeded\n this._signinDoneResolve();\n this._subscribeChannels();\n }\n\n private _subscribeChannels() {\n const ensure_subscribed = channel => {\n if (channel.subscriptionPending && channel.subscriptionCancelled) {\n channel.reinstateSubscription();\n } else if (\n !channel.subscriptionPending &&\n this.pusher.connection.state === 'connected'\n ) {\n channel.subscribe();\n }\n };\n\n this.serverToUserChannel = new Channel(\n `#server-to-user-${this.user_data.id}`,\n this.pusher\n );\n this.serverToUserChannel.bind_global((eventName, data) => {\n if (\n eventName.indexOf('pusher_internal:') === 0 ||\n eventName.indexOf('pusher:') === 0\n ) {\n // ignore internal events\n return;\n }\n this.emit(eventName, data);\n });\n ensure_subscribed(this.serverToUserChannel);\n }\n\n private _cleanup() {\n this.user_data = null;\n if (this.serverToUserChannel) {\n this.serverToUserChannel.unbind_all();\n this.serverToUserChannel.disconnect();\n this.serverToUserChannel = null;\n }\n\n if (this.signin_requested) {\n // If signin is in progress and cleanup is called,\n // Mark the current signin process as done.\n this._signinDoneResolve();\n }\n }\n\n private _newSigninPromiseIfNeeded() {\n if (!this.signin_requested) {\n return;\n }\n\n // If there is a promise and it is not resolved, return without creating a new one.\n if (this.signinDonePromise && !(this.signinDonePromise as any).done) {\n return;\n }\n\n // This promise is never rejected.\n // It gets resolved when the signin process is done whether it failed or succeeded\n const { promise, resolve, reject: _ } = flatPromise();\n (promise as any).done = false;\n const setDone = () => {\n (promise as any).done = true;\n };\n promise.then(setDone).catch(setDone);\n this.signinDonePromise = promise;\n this._signinDoneResolve = resolve;\n }\n}\n","import AbstractRuntime from '../runtimes/interface';\nimport Runtime from 'runtime';\nimport * as Collections from './utils/collections';\nimport Channels from './channels/channels';\nimport Channel from './channels/channel';\nimport { default as EventsDispatcher } from './events/dispatcher';\nimport Timeline from './timeline/timeline';\nimport TimelineSender from './timeline/timeline_sender';\nimport TimelineLevel from './timeline/level';\nimport { defineTransport } from './strategies/strategy_builder';\nimport ConnectionManager from './connection/connection_manager';\nimport { PeriodicTimer } from './utils/timers';\nimport Defaults from './defaults';\nimport Logger from './logger';\nimport Factory from './utils/factory';\nimport { Options, ClusterOptions, validateOptions } from './options';\nimport { Config, getConfig } from './config';\nimport StrategyOptions from './strategies/strategy_options';\nimport UserFacade from './user';\n\nexport default class Pusher {\n /* STATIC PROPERTIES */\n static instances: Pusher[] = [];\n static isReady: boolean = false;\n static logToConsole: boolean = false;\n\n // for jsonp\n static Runtime: AbstractRuntime = Runtime;\n static ScriptReceivers: any = (Runtime).ScriptReceivers;\n static DependenciesReceivers: any = (Runtime).DependenciesReceivers;\n static auth_callbacks: any = (Runtime).auth_callbacks;\n\n static ready() {\n Pusher.isReady = true;\n for (var i = 0, l = Pusher.instances.length; i < l; i++) {\n Pusher.instances[i].connect();\n }\n }\n\n static log: (message: any) => void;\n\n private static getClientFeatures(): string[] {\n return Collections.keys(\n Collections.filterObject({ ws: Runtime.Transports.ws }, function(t) {\n return t.isSupported({});\n })\n );\n }\n\n /* INSTANCE PROPERTIES */\n key: string;\n options: Options;\n config: Config;\n channels: Channels;\n global_emitter: EventsDispatcher;\n sessionID: number;\n timeline: Timeline;\n timelineSender: TimelineSender;\n connection: ConnectionManager;\n timelineSenderTimer: PeriodicTimer;\n user: UserFacade;\n constructor(app_key: string, options: Options) {\n checkAppKey(app_key);\n validateOptions(options);\n this.key = app_key;\n this.config = getConfig(options, this);\n\n this.channels = Factory.createChannels();\n this.global_emitter = new EventsDispatcher();\n this.sessionID = Runtime.randomInt(1000000000);\n\n this.timeline = new Timeline(this.key, this.sessionID, {\n cluster: this.config.cluster,\n features: Pusher.getClientFeatures(),\n params: this.config.timelineParams || {},\n limit: 50,\n level: TimelineLevel.INFO,\n version: Defaults.VERSION\n });\n if (this.config.enableStats) {\n this.timelineSender = Factory.createTimelineSender(this.timeline, {\n host: this.config.statsHost,\n path: '/timeline/v2/' + Runtime.TimelineTransport.name\n });\n }\n\n var getStrategy = (options: StrategyOptions) => {\n return Runtime.getDefaultStrategy(this.config, options, defineTransport);\n };\n\n this.connection = Factory.createConnectionManager(this.key, {\n getStrategy: getStrategy,\n timeline: this.timeline,\n activityTimeout: this.config.activityTimeout,\n pongTimeout: this.config.pongTimeout,\n unavailableTimeout: this.config.unavailableTimeout,\n useTLS: Boolean(this.config.useTLS)\n });\n\n this.connection.bind('connected', () => {\n this.subscribeAll();\n if (this.timelineSender) {\n this.timelineSender.send(this.connection.isUsingTLS());\n }\n });\n\n this.connection.bind('message', event => {\n var eventName = event.event;\n var internal = eventName.indexOf('pusher_internal:') === 0;\n if (event.channel) {\n var channel = this.channel(event.channel);\n if (channel) {\n channel.handleEvent(event);\n }\n }\n // Emit globally [deprecated]\n if (!internal) {\n this.global_emitter.emit(event.event, event.data);\n }\n });\n this.connection.bind('connecting', () => {\n this.channels.disconnect();\n });\n this.connection.bind('disconnected', () => {\n this.channels.disconnect();\n });\n this.connection.bind('error', err => {\n Logger.warn(err);\n });\n\n Pusher.instances.push(this);\n this.timeline.info({ instances: Pusher.instances.length });\n\n this.user = new UserFacade(this);\n\n if (Pusher.isReady) {\n this.connect();\n }\n }\n\n /**\n * Allows you to switch Pusher cluster without\n * losing all the channels/subscription binding\n * as this is internally managed by the SDK.\n */\n switchCluster(options: ClusterOptions) {\n const { appKey, cluster } = options;\n this.key = appKey;\n this.options = { ...this.options, cluster };\n this.config = getConfig(this.options, this);\n this.connection.switchCluster(this.key);\n }\n\n channel(name: string): Channel {\n return this.channels.find(name);\n }\n\n allChannels(): Channel[] {\n return this.channels.all();\n }\n\n connect() {\n this.connection.connect();\n\n if (this.timelineSender) {\n if (!this.timelineSenderTimer) {\n var usingTLS = this.connection.isUsingTLS();\n var timelineSender = this.timelineSender;\n this.timelineSenderTimer = new PeriodicTimer(60000, function() {\n timelineSender.send(usingTLS);\n });\n }\n }\n }\n\n disconnect() {\n this.connection.disconnect();\n\n if (this.timelineSenderTimer) {\n this.timelineSenderTimer.ensureAborted();\n this.timelineSenderTimer = null;\n }\n }\n\n bind(event_name: string, callback: Function, context?: any): Pusher {\n this.global_emitter.bind(event_name, callback, context);\n return this;\n }\n\n unbind(event_name?: string, callback?: Function, context?: any): Pusher {\n this.global_emitter.unbind(event_name, callback, context);\n return this;\n }\n\n bind_global(callback: Function): Pusher {\n this.global_emitter.bind_global(callback);\n return this;\n }\n\n unbind_global(callback?: Function): Pusher {\n this.global_emitter.unbind_global(callback);\n return this;\n }\n\n unbind_all(callback?: Function): Pusher {\n this.global_emitter.unbind_all();\n return this;\n }\n\n subscribeAll() {\n var channelName;\n for (channelName in this.channels.channels) {\n if (this.channels.channels.hasOwnProperty(channelName)) {\n this.subscribe(channelName);\n }\n }\n }\n\n subscribe(channel_name: string) {\n var channel = this.channels.add(channel_name, this);\n if (channel.subscriptionPending && channel.subscriptionCancelled) {\n channel.reinstateSubscription();\n } else if (\n !channel.subscriptionPending &&\n this.connection.state === 'connected'\n ) {\n channel.subscribe();\n }\n return channel;\n }\n\n unsubscribe(channel_name: string) {\n var channel = this.channels.find(channel_name);\n if (channel && channel.subscriptionPending) {\n channel.cancelSubscription();\n } else {\n channel = this.channels.remove(channel_name);\n if (channel && channel.subscribed) {\n channel.unsubscribe();\n }\n }\n }\n\n send_event(event_name: string, data: any, channel?: string) {\n return this.connection.send_event(event_name, data, channel);\n }\n\n shouldUseTLS(): boolean {\n return this.config.useTLS;\n }\n\n signin() {\n this.user.signin();\n }\n}\n\nfunction checkAppKey(key) {\n if (key === null || key === undefined) {\n throw 'You must pass your app key when you instantiate Pusher.';\n }\n}\n\nRuntime.setup(Pusher);\n","import Pusher from './pusher';\nimport { Options, validateOptions } from './options';\nimport * as nacl from 'tweetnacl';\n\nexport default class PusherWithEncryption extends Pusher {\n constructor(app_key: string, options: Options) {\n Pusher.logToConsole = PusherWithEncryption.logToConsole;\n Pusher.log = PusherWithEncryption.log;\n\n validateOptions(options);\n options.nacl = nacl;\n super(app_key, options);\n }\n}\n"],"sourceRoot":""} \ No newline at end of file +{"version":3,"sources":["webpack://Pusher/webpack/universalModuleDefinition","webpack://Pusher/webpack/bootstrap","webpack://Pusher/./node_modules/@stablelib/base64/base64.ts","webpack://Pusher/./node_modules/@stablelib/utf8/utf8.ts","webpack://Pusher/./node_modules/tweetnacl/nacl-fast.js","webpack://Pusher/./src/core/pusher-with-encryption.js","webpack://Pusher/./src/runtimes/web/dom/script_receiver_factory.ts","webpack://Pusher/./src/core/defaults.ts","webpack://Pusher/./src/runtimes/web/dom/dependencies.ts","webpack://Pusher/./src/runtimes/web/dom/dependency_loader.ts","webpack://Pusher/./src/core/utils/url_store.ts","webpack://Pusher/./src/core/auth/options.ts","webpack://Pusher/./src/core/errors.ts","webpack://Pusher/./src/runtimes/isomorphic/auth/xhr_auth.ts","webpack://Pusher/./src/core/base64.ts","webpack://Pusher/./src/core/utils/timers/abstract_timer.ts","webpack://Pusher/./src/core/utils/timers/index.ts","webpack://Pusher/./src/core/util.ts","webpack://Pusher/./src/core/utils/collections.ts","webpack://Pusher/./src/core/logger.ts","webpack://Pusher/./src/runtimes/web/auth/jsonp_auth.ts","webpack://Pusher/./src/runtimes/web/dom/script_request.ts","webpack://Pusher/./src/runtimes/web/dom/jsonp_request.ts","webpack://Pusher/./src/runtimes/web/timeline/jsonp_timeline.ts","webpack://Pusher/./src/core/transports/url_schemes.ts","webpack://Pusher/./src/core/events/callback_registry.ts","webpack://Pusher/./src/core/events/dispatcher.ts","webpack://Pusher/./src/core/transports/transport_connection.ts","webpack://Pusher/./src/core/transports/transport.ts","webpack://Pusher/./src/runtimes/isomorphic/transports/transports.ts","webpack://Pusher/./src/runtimes/web/transports/transports.ts","webpack://Pusher/./src/runtimes/web/net_info.ts","webpack://Pusher/./src/core/transports/assistant_to_the_transport_manager.ts","webpack://Pusher/./src/core/connection/protocol/protocol.ts","webpack://Pusher/./src/core/connection/connection.ts","webpack://Pusher/./src/core/connection/handshake/index.ts","webpack://Pusher/./src/core/timeline/timeline_sender.ts","webpack://Pusher/./src/core/channels/channel.ts","webpack://Pusher/./src/core/channels/private_channel.ts","webpack://Pusher/./src/core/channels/members.ts","webpack://Pusher/./src/core/channels/presence_channel.ts","webpack://Pusher/./src/core/channels/encrypted_channel.ts","webpack://Pusher/./src/core/connection/connection_manager.ts","webpack://Pusher/./src/core/channels/channels.ts","webpack://Pusher/./src/core/utils/factory.ts","webpack://Pusher/./src/core/transports/transport_manager.ts","webpack://Pusher/./src/core/strategies/sequential_strategy.ts","webpack://Pusher/./src/core/strategies/best_connected_ever_strategy.ts","webpack://Pusher/./src/core/strategies/websocket_prioritized_cached_strategy.ts","webpack://Pusher/./src/core/strategies/delayed_strategy.ts","webpack://Pusher/./src/core/strategies/if_strategy.ts","webpack://Pusher/./src/core/strategies/first_connected_strategy.ts","webpack://Pusher/./src/runtimes/web/default_strategy.ts","webpack://Pusher/./src/runtimes/web/http/http_xdomain_request.ts","webpack://Pusher/./src/core/http/http_request.ts","webpack://Pusher/./src/core/http/state.ts","webpack://Pusher/./src/core/http/http_socket.ts","webpack://Pusher/./src/core/timeline/level.ts","webpack://Pusher/./src/core/http/http_streaming_socket.ts","webpack://Pusher/./src/core/http/http_polling_socket.ts","webpack://Pusher/./src/runtimes/isomorphic/http/http_xhr_request.ts","webpack://Pusher/./src/runtimes/isomorphic/http/http.ts","webpack://Pusher/./src/runtimes/web/http/http.ts","webpack://Pusher/./src/runtimes/web/runtime.ts","webpack://Pusher/./src/runtimes/web/transports/transport_connection_initializer.ts","webpack://Pusher/./src/core/timeline/timeline.ts","webpack://Pusher/./src/core/strategies/transport_strategy.ts","webpack://Pusher/./src/core/strategies/strategy_builder.ts","webpack://Pusher/./src/core/options.ts","webpack://Pusher/./src/core/auth/user_authenticator.ts","webpack://Pusher/./src/core/auth/channel_authorizer.ts","webpack://Pusher/./src/core/auth/deprecated_channel_authorizer.ts","webpack://Pusher/./src/core/config.ts","webpack://Pusher/./src/core/watchlist.ts","webpack://Pusher/./src/core/utils/flat_promise.ts","webpack://Pusher/./src/core/user.ts","webpack://Pusher/./src/core/pusher.ts","webpack://Pusher/./src/core/pusher-with-encryption.ts"],"names":["root","factory","exports","module","define","amd","window","installedModules","__webpack_require__","moduleId","i","l","modules","call","m","c","d","name","getter","o","Object","defineProperty","enumerable","get","r","Symbol","toStringTag","value","t","mode","__esModule","ns","create","key","bind","n","object","property","prototype","hasOwnProperty","p","s","_paddingCharacter","encodedLength","length","this","encode","data","out","_encodeByte","left","maxDecodedLength","decodedLength","_getPaddingLength","decode","Uint8Array","paddingLength","op","haveBad","v0","v1","v2","v3","_decodeChar","charCodeAt","Error","b","result","String","fromCharCode","Coder","stdCoder","URLSafeCoder","urlSafeCoder","INVALID_UTF8","arr","pos","chars","min","n1","n2","n3","push","join","nacl","gf","init","Float64Array","randombytes","_0","_9","gf0","gf1","_121665","D","D2","X","Y","I","ts64","x","h","vn","xi","y","yi","crypto_verify_16","crypto_verify_32","crypto_core_salsa20","inp","k","u","j0","j1","j2","j3","j4","j5","j6","j7","j8","j9","j10","j11","j12","j13","j14","j15","x0","x1","x2","x3","x4","x5","x6","x7","x8","x9","x10","x11","x12","x13","x14","x15","core_salsa20","crypto_core_hsalsa20","core_hsalsa20","sigma","crypto_stream_salsa20_xor","cpos","mpos","z","crypto_stream_salsa20","crypto_stream","sn","crypto_stream_xor","poly1305","t0","t1","t2","t3","t4","t5","t6","t7","buffer","Uint16Array","pad","leftover","fin","crypto_onetimeauth","outpos","update","finish","crypto_onetimeauth_verify","hpos","crypto_secretbox","crypto_secretbox_open","set25519","a","car25519","v","Math","floor","sel25519","q","pack25519","j","neq25519","par25519","unpack25519","A","Z","M","t8","t9","t10","t11","t12","t13","t14","t15","t16","t17","t18","t19","t20","t21","t22","t23","t24","t25","t26","t27","t28","t29","t30","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","b10","b11","b12","b13","b14","b15","S","inv25519","pow2523","crypto_scalarmult","e","f","x32","subarray","x16","crypto_scalarmult_base","crypto_box_keypair","crypto_box_beforenm","blocks","bytes","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","hibit","h0","h1","h2","h3","h4","h5","h6","h7","h8","h9","r0","r1","r2","r3","r4","r5","r6","r7","r8","r9","mac","macpos","mask","g","want","crypto_box_afternm","crypto_box_open_afternm","K","crypto_hashblocks_hl","hh","hl","bh0","bh1","bh2","bh3","bh4","bh5","bh6","bh7","bl0","bl1","bl2","bl3","bl4","bl5","bl6","bl7","th","tl","wh","Int32Array","wl","ah0","ah1","ah2","ah3","ah4","ah5","ah6","ah7","al0","al1","al2","al3","al4","al5","al6","al7","crypto_hash","add","cswap","pack","tx","ty","zi","scalarmult","scalarbase","crypto_sign_keypair","pk","sk","seeded","L","modL","carry","reduce","crypto_sign","sm","smlen","crypto_sign_open","chk","num","den","den2","den4","den6","unpackneg","checkLengths","checkArrayTypes","arguments","TypeError","cleanup","lowlevel","crypto_box","crypto_box_open","crypto_secretbox_KEYBYTES","crypto_secretbox_NONCEBYTES","crypto_secretbox_ZEROBYTES","crypto_secretbox_BOXZEROBYTES","crypto_scalarmult_BYTES","crypto_scalarmult_SCALARBYTES","crypto_box_PUBLICKEYBYTES","crypto_box_SECRETKEYBYTES","crypto_box_BEFORENMBYTES","crypto_box_NONCEBYTES","crypto_box_ZEROBYTES","crypto_box_BOXZEROBYTES","crypto_sign_BYTES","crypto_sign_PUBLICKEYBYTES","crypto_sign_SECRETKEYBYTES","crypto_sign_SEEDBYTES","crypto_hash_BYTES","randomBytes","secretbox","msg","nonce","open","box","keyLength","nonceLength","overheadLength","scalarMult","base","scalarLength","groupElementLength","publicKey","secretKey","before","checkBoxLengths","after","keyPair","fromSecretKey","publicKeyLength","secretKeyLength","sharedKeyLength","sign","signedMsg","tmp","mlen","detached","sig","verify","fromSeed","seed","seedLength","signatureLength","hash","hashLength","setPRNG","fn","crypto","self","msCrypto","getRandomValues","default","ScriptReceiverFactory","prefix","lastId","callback","number","id","called","callbackWrapper","apply","receiver","ScriptReceivers","VERSION","PROTOCOL","wsPort","wssPort","wsPath","httpHost","httpPort","httpsPort","httpPath","stats_host","authEndpoint","authTransport","activityTimeout","pongTimeout","unavailableTimeout","userAuthentication","endpoint","transport","channelAuthorization","cdn_http","cdn_https","dependency_suffix","DependenciesReceivers","Dependencies","options","receivers","loading","request","createScriptRequest","getPath","error","remove","callbacks","successCallback","wasSuccessful","send","protocol","getDocument","location","useTLS","replace","version","getRoot","suffix","urlStore","baseUrl","urls","authenticationEndpoint","path","authorizationEndpoint","javascriptQuickStart","triggeringClientEvents","encryptedChannelSupport","fullUrl","AuthRequestType","urlObj","url","BadEventName","super","setPrototypeOf","BadChannelName","RequestTimedOut","TransportPriorityTooLow","TransportClosed","UnsupportedFeature","UnsupportedTransport","UnsupportedStrategy","HTTPAuthError","status","context","query","authOptions","authRequestType","xhr","createXHR","headerName","setRequestHeader","headers","headersProvider","dynamicHeaders","onreadystatechange","readyState","parsed","JSON","parse","responseText","toString","UserAuthentication","ChannelAuthorization","b64chars","b64tab","charAt","cb_utob","cc","utob","cb_encode","ccc","padlen","ord","btoa","set","clear","delay","timer","clearTimeout","clearInterval","setTimeout","setInterval","now","Date","valueOf","defer","args","boundArguments","Array","slice","concat","extend","target","sources","extensions","constructor","stringify","safeJSONStringify","arrayIndexOf","array","item","nativeIndexOf","indexOf","objectApply","keys","_","map","filter","test","filterObject","Boolean","any","encodeParamsObject","encodeURIComponent","buildQueryString","params","undefined","method","source","objects","paths","derez","nu","$ref","globalLog","message","console","log","globalLogWarn","globalLogError","warn","defaultLoggingFunction","logToConsole","callbackName","nextAuthCallbackID","document","script","createElement","auth_callbacks","callback_name","src","head","getElementsByTagName","documentElement","insertBefore","firstChild","ScriptRequest","errorString","type","charset","addEventListener","onerror","onload","async","attachEvent","navigator","userAgent","errorScript","text","nextSibling","parentNode","removeChild","getAgent","sender","host","createJSONPRequest","getGenericURL","baseScheme","hostTLS","hostNonTLS","getGenericPath","queryString","ws","getInitial","http","sockjs","_callbacks","prefixedEventName","names","removeCallback","removeAllCallbacks","binding","failThrough","global_callbacks","eventName","unbind","unbind_global","metadata","hooks","priority","initialize","transportConnectionInitializer","state","timeline","generateUniqueID","handlesActivityChecks","supportsPing","socket","getSocket","onError","changeState","bindListeners","debug","close","ping","beforeOpen","onopen","emit","buildTimelineMessage","closeEvent","code","reason","wasClean","unbindListeners","onOpen","onclose","onClose","onmessage","onMessage","onactivity","onActivity","info","cid","environment","isSupported","WSTransport","isInitialized","getWebSocketAPI","createWebSocket","httpConfiguration","streamingConfiguration","HTTPFactory","createStreamingSocket","pollingConfiguration","createPollingSocket","xhrConfiguration","isXHRSupported","xhr_streaming","xhr_polling","SockJSTransport","file","SockJS","js_path","ignore_null_origin","ignoreNullOrigin","xdrConfiguration","isXDRSupported","XDRStreamingTransport","XDRPollingTransport","xdr_streaming","xdr_polling","onLine","manager","minPingDelay","maxPingDelay","pingDelay","connection","createConnection","openTimestamp","onClosed","reportDeath","lifespan","max","isAlive","Protocol","decodeMessage","messageEvent","messageData","pusherEventData","pusherEvent","event","channel","user_id","encodeMessage","processHandshake","activity_timeout","action","socket_id","getCloseAction","getCloseError","send_event","listeners","activity","closed","handleCloseEvent","listener","isEmpty","TimelineTransport","pusher","subscribed","subscriptionPending","subscriptionCancelled","socketId","auth","handleSubscriptionSucceededEvent","handleSubscriptionCountEvent","unsubscribe","subscription_count","subscriptionCount","authorize","assign","channel_data","config","channelAuthorizer","channelName","reset","members","member","myID","subscriptionData","presence","count","me","memberData","user_info","authData","channelData","setMyID","user","signinDonePromise","user_data","handleInternalEvent","addedMember","addMember","removedMember","removeMember","onSubscription","disconnect","sharedSecret","handleEncryptedEvent","handleEvent","ciphertext","cipherText","getDataToEmit","raw","usingTLS","errorCallbacks","buildErrorCallbacks","connectionCallbacks","buildConnectionCallbacks","handshakeCallbacks","buildHandshakeCallbacks","Network","getNetwork","netinfo","retryIn","sendActivityCheck","updateStrategy","runner","strategy","updateState","startConnecting","setUnavailableTimer","disconnectInternally","handshake","connect","handshakeError","abortConnecting","abort","clearRetryTimer","clearUnavailableTimer","abandonConnection","getStrategy","round","retryTimer","ensureAborted","unavailableTimer","stopActivityCheck","activityTimer","pong_timed_out","resetActivityCheck","shouldRetry","connected","Infinity","setConnection","withErrorEmitted","tls_only","refused","backoff","retry","newState","previousState","newStateDescription","previous","current","channels","createEncryptedChannel","errMsg","createPrivateChannel","createPresenceChannel","createChannel","values","createChannels","createConnectionManager","createTimelineSender","createHandshake","createAssistantToTheTransportManager","livesLeft","lives","strategies","loop","failFast","timeout","timeoutLimit","minPriority","tryNextStrategy","tryStrategy","forceMinPriority","isRunning","callbackBuilder","runners","rs","abortRunner","allRunnersFailed","aborted","transports","ttl","storage","getLocalStorage","serializedCache","getTransportCacheKey","flushTransportCache","fetchTransportCache","cacheSkipCount","timestamp","includes","cached","latency","startTimestamp","pop","cb","storeTransportCache","IfStrategy","trueBranch","falseBranch","FirstConnectedStrategy","testSupportsStrategy","baseOptions","defineTransport","definedTransports","defineTransportStrategy","wsStrategy","ws_options","wsHost","wss_options","sockjs_options","timeouts","ws_manager","streaming_manager","ws_transport","wss_transport","sockjs_transport","xhr_streaming_transport","xdr_streaming_transport","xhr_polling_transport","xdr_polling_transport","ws_loop","wss_loop","sockjs_loop","streaming_loop","polling_loop","http_loop","http_fallback_loop","getRequest","xdr","XDomainRequest","ontimeout","onprogress","onChunk","abortRequest","payload","position","unloader","addUnloadListener","removeUnloadListener","chunk","advanceBuffer","isBufferTooLong","unreadData","endOfLinePosition","State","autoIncrement","getUniqueURL","separator","randomNumber","randomInt","TimelineLevel","session","randomString","parts","exec","getLocation","CONNECTING","openStream","sendRaw","sendHeartbeat","OPEN","createSocketRequest","start","closeStream","CLOSED","onEvent","onHeartbeat","hostname","urlParts","stream","getReceiveURL","onFinished","reconnect","unbind_all","getXHRAPI","createSocket","createRequest","getDefaultStrategy","Transports","load","XMLHttpRequest","WebSocket","MozWebSocket","PusherClass","Pusher","initializeOnDocumentBody","onDocumentBody","ready","getAuthorizers","ajax","jsonp","body","localStorage","createXMLHttpRequest","createMicrosoftXHR","ActiveXObject","createXDR","Constructor","withCredentials","documentProtocol","getProtocol","removeEventListener","detachEvent","Uint32Array","events","sent","uniqueID","level","limit","shift","ERROR","INFO","DEBUG","sendfn","bundle","lib","cluster","features","failAttempt","onInitialized","serializedTransport","transportClass","enabledTransports","disabledTransports","getAssistant","deferred","validateOptions","paramsProvider","dynamicParams","composeChannelQuery","ChannelAuthorizerProxy","channelAuthorizerGenerator","deprecatedAuthorizerOptions","getConfig","opts","statsHost","enableStats","getEnableStatsConfig","getHttpHost","shouldUseTLS","getWebsocketHost","userAuthenticator","buildUserAuthenticator","buildChannelAuthorizer","timelineParams","forceTLS","disableStats","hasCustomHandler","customHandler","authorizer","buildChannelAuth","bindWatchlistInternalEvent","forEach","watchlistEvent","resolve","reject","promise","Promise","res","rej","signin_requested","serverToUserChannel","_signinDoneResolve","_onAuthorize","err","_cleanup","_signin","_newSigninPromiseIfNeeded","watchlist","_onSigninSuccess","_subscribeChannels","bind_global","reinstateSubscription","subscribe","ensure_subscribed","done","setDone","then","catch","isReady","instances","app_key","checkAppKey","global_emitter","sessionID","getClientFeatures","timelineSender","subscribeAll","isUsingTLS","internal","appKey","switchCluster","find","all","timelineSenderTimer","event_name","channel_name","cancelSubscription","signin","Runtime","setup"],"mappings":";;;;;;;CAAA,SAA2CA,EAAMC,GAC1B,iBAAZC,SAA0C,iBAAXC,OACxCA,OAAOD,QAAUD,IACQ,mBAAXG,QAAyBA,OAAOC,IAC9CD,OAAO,GAAIH,GACe,iBAAZC,QACdA,QAAgB,OAAID,IAEpBD,EAAa,OAAIC,IARnB,CASGK,QAAQ,WACX,O,YCTE,IAAIC,EAAmB,GAGvB,SAASC,EAAoBC,GAG5B,GAAGF,EAAiBE,GACnB,OAAOF,EAAiBE,GAAUP,QAGnC,IAAIC,EAASI,EAAiBE,GAAY,CACzCC,EAAGD,EACHE,GAAG,EACHT,QAAS,IAUV,OANAU,EAAQH,GAAUI,KAAKV,EAAOD,QAASC,EAAQA,EAAOD,QAASM,GAG/DL,EAAOQ,GAAI,EAGJR,EAAOD,QA0Df,OArDAM,EAAoBM,EAAIF,EAGxBJ,EAAoBO,EAAIR,EAGxBC,EAAoBQ,EAAI,SAASd,EAASe,EAAMC,GAC3CV,EAAoBW,EAAEjB,EAASe,IAClCG,OAAOC,eAAenB,EAASe,EAAM,CAAEK,YAAY,EAAMC,IAAKL,KAKhEV,EAA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AIzW,EAAU7qB,KAAK+xB,SAASmP,KAAKI,GAC7BzW,GAAWA,EAAQmB,oBACrBnB,EAAQ0W,sBAER1W,EAAU7qB,KAAK+xB,SAAS5X,OAAOmnB,KAChBzW,EAAQkB,YACrBlB,EAAQyB,cAKd,WAAW+U,EAAoBnhC,EAAW2qB,GACxC,OAAO7qB,KAAK8pB,WAAWwB,WAAW+V,EAAYnhC,EAAM2qB,GAGtD,eACE,OAAO7qB,KAAK4sB,OAAOjS,OAGrB,SACE3a,KAAK4tB,KAAK4T,UAvOL,GAAAlB,UAAsB,GACtB,GAAAD,SAAmB,EACnB,GAAAne,cAAwB,EAGxB,GAAAuf,QAA2B,GAC3B,GAAAtpB,gBAA6B,GAASA,gBACtC,GAAAuB,sBAAmC,GAASA,sBAC5C,GAAA8I,eAA4B,GAASA,eAVzB,UAmPrB,GAAQkf,MAAM,I,YCnQC,MAAM,WAA6B,GAChD,YAAYnB,EAAiB3mB,GAC3B,GAAOsI,aAAe,GAAqBA,aAC3C,GAAOL,IAAM,GAAqBA,IAElCmb,GAAgBpjB,GAChBA,EAAQrX,KAAO,GACfuZ,MAAMykB,EAAS3mB","file":"pusher-with-encryption.min.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"Pusher\"] = factory();\n\telse\n\t\troot[\"Pusher\"] = factory();\n})(window, function() {\nreturn "," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 3);\n","// Copyright (C) 2016 Dmitry Chestnykh\n// MIT License. See LICENSE file for details.\n\n/**\n * Package base64 implements Base64 encoding and decoding.\n */\n\n// Invalid character used in decoding to indicate\n// that the character to decode is out of range of\n// alphabet and cannot be decoded.\nconst INVALID_BYTE = 256;\n\n/**\n * Implements standard Base64 encoding.\n *\n * Operates in constant time.\n */\nexport class Coder {\n // TODO(dchest): methods to encode chunk-by-chunk.\n\n constructor(private _paddingCharacter = \"=\") { }\n\n encodedLength(length: number): number {\n if (!this._paddingCharacter) {\n return (length * 8 + 5) / 6 | 0;\n }\n return (length + 2) / 3 * 4 | 0;\n }\n\n encode(data: Uint8Array): string {\n let out = \"\";\n\n let i = 0;\n for (; i < data.length - 2; i += 3) {\n let c = (data[i] << 16) | (data[i + 1] << 8) | (data[i + 2]);\n out += this._encodeByte((c >>> 3 * 6) & 63);\n out += this._encodeByte((c >>> 2 * 6) & 63);\n out += this._encodeByte((c >>> 1 * 6) & 63);\n out += this._encodeByte((c >>> 0 * 6) & 63);\n }\n\n const left = data.length - i;\n if (left > 0) {\n let c = (data[i] << 16) | (left === 2 ? data[i + 1] << 8 : 0);\n out += this._encodeByte((c >>> 3 * 6) & 63);\n out += this._encodeByte((c >>> 2 * 6) & 63);\n if (left === 2) {\n out += this._encodeByte((c >>> 1 * 6) & 63);\n } else {\n out += this._paddingCharacter || \"\";\n }\n out += this._paddingCharacter || \"\";\n }\n\n return out;\n }\n\n maxDecodedLength(length: number): number {\n if (!this._paddingCharacter) {\n return (length * 6 + 7) / 8 | 0;\n }\n return length / 4 * 3 | 0;\n }\n\n decodedLength(s: string): number {\n return this.maxDecodedLength(s.length - this._getPaddingLength(s));\n }\n\n decode(s: string): Uint8Array {\n if (s.length === 0) {\n return new Uint8Array(0);\n }\n const paddingLength = this._getPaddingLength(s);\n const length = s.length - paddingLength;\n const out = new Uint8Array(this.maxDecodedLength(length));\n let op = 0;\n let i = 0;\n let haveBad = 0;\n let v0 = 0, v1 = 0, v2 = 0, v3 = 0;\n for (; i < length - 4; i += 4) {\n v0 = this._decodeChar(s.charCodeAt(i + 0));\n v1 = this._decodeChar(s.charCodeAt(i + 1));\n v2 = this._decodeChar(s.charCodeAt(i + 2));\n v3 = this._decodeChar(s.charCodeAt(i + 3));\n out[op++] = (v0 << 2) | (v1 >>> 4);\n out[op++] = (v1 << 4) | (v2 >>> 2);\n out[op++] = (v2 << 6) | v3;\n haveBad |= v0 & INVALID_BYTE;\n haveBad |= v1 & INVALID_BYTE;\n haveBad |= v2 & INVALID_BYTE;\n haveBad |= v3 & INVALID_BYTE;\n }\n if (i < length - 1) {\n v0 = this._decodeChar(s.charCodeAt(i));\n v1 = this._decodeChar(s.charCodeAt(i + 1));\n out[op++] = (v0 << 2) | (v1 >>> 4);\n haveBad |= v0 & INVALID_BYTE;\n haveBad |= v1 & INVALID_BYTE;\n }\n if (i < length - 2) {\n v2 = this._decodeChar(s.charCodeAt(i + 2));\n out[op++] = (v1 << 4) | (v2 >>> 2);\n haveBad |= v2 & INVALID_BYTE;\n }\n if (i < length - 3) {\n v3 = this._decodeChar(s.charCodeAt(i + 3));\n out[op++] = (v2 << 6) | v3;\n haveBad |= v3 & INVALID_BYTE;\n }\n if (haveBad !== 0) {\n throw new Error(\"Base64Coder: incorrect characters for decoding\");\n }\n return out;\n }\n\n // Standard encoding have the following encoded/decoded ranges,\n // which we need to convert between.\n //\n // ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 0123456789 + /\n // Index: 0 - 25 26 - 51 52 - 61 62 63\n // ASCII: 65 - 90 97 - 122 48 - 57 43 47\n //\n\n // Encode 6 bits in b into a new character.\n protected _encodeByte(b: number): string {\n // Encoding uses constant time operations as follows:\n //\n // 1. Define comparison of A with B using (A - B) >>> 8:\n // if A > B, then result is positive integer\n // if A <= B, then result is 0\n //\n // 2. Define selection of C or 0 using bitwise AND: X & C:\n // if X == 0, then result is 0\n // if X != 0, then result is C\n //\n // 3. Start with the smallest comparison (b >= 0), which is always\n // true, so set the result to the starting ASCII value (65).\n //\n // 4. Continue comparing b to higher ASCII values, and selecting\n // zero if comparison isn't true, otherwise selecting a value\n // to add to result, which:\n //\n // a) undoes the previous addition\n // b) provides new value to add\n //\n let result = b;\n // b >= 0\n result += 65;\n // b > 25\n result += ((25 - b) >>> 8) & ((0 - 65) - 26 + 97);\n // b > 51\n result += ((51 - b) >>> 8) & ((26 - 97) - 52 + 48);\n // b > 61\n result += ((61 - b) >>> 8) & ((52 - 48) - 62 + 43);\n // b > 62\n result += ((62 - b) >>> 8) & ((62 - 43) - 63 + 47);\n\n return String.fromCharCode(result);\n }\n\n // Decode a character code into a byte.\n // Must return 256 if character is out of alphabet range.\n protected _decodeChar(c: number): number {\n // Decoding works similar to encoding: using the same comparison\n // function, but now it works on ranges: result is always incremented\n // by value, but this value becomes zero if the range is not\n // satisfied.\n //\n // Decoding starts with invalid value, 256, which is then\n // subtracted when the range is satisfied. If none of the ranges\n // apply, the function returns 256, which is then checked by\n // the caller to throw error.\n let result = INVALID_BYTE; // start with invalid character\n\n // c == 43 (c > 42 and c < 44)\n result += (((42 - c) & (c - 44)) >>> 8) & (-INVALID_BYTE + c - 43 + 62);\n // c == 47 (c > 46 and c < 48)\n result += (((46 - c) & (c - 48)) >>> 8) & (-INVALID_BYTE + c - 47 + 63);\n // c > 47 and c < 58\n result += (((47 - c) & (c - 58)) >>> 8) & (-INVALID_BYTE + c - 48 + 52);\n // c > 64 and c < 91\n result += (((64 - c) & (c - 91)) >>> 8) & (-INVALID_BYTE + c - 65 + 0);\n // c > 96 and c < 123\n result += (((96 - c) & (c - 123)) >>> 8) & (-INVALID_BYTE + c - 97 + 26);\n\n return result;\n }\n\n private _getPaddingLength(s: string): number {\n let paddingLength = 0;\n if (this._paddingCharacter) {\n for (let i = s.length - 1; i >= 0; i--) {\n if (s[i] !== this._paddingCharacter) {\n break;\n }\n paddingLength++;\n }\n if (s.length < 4 || paddingLength > 2) {\n throw new Error(\"Base64Coder: incorrect padding\");\n }\n }\n return paddingLength;\n }\n\n}\n\nconst stdCoder = new Coder();\n\nexport function encode(data: Uint8Array): string {\n return stdCoder.encode(data);\n}\n\nexport function decode(s: string): Uint8Array {\n return stdCoder.decode(s);\n}\n\n/**\n * Implements URL-safe Base64 encoding.\n * (Same as Base64, but '+' is replaced with '-', and '/' with '_').\n *\n * Operates in constant time.\n */\nexport class URLSafeCoder extends Coder {\n // URL-safe encoding have the following encoded/decoded ranges:\n //\n // ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 0123456789 - _\n // Index: 0 - 25 26 - 51 52 - 61 62 63\n // ASCII: 65 - 90 97 - 122 48 - 57 45 95\n //\n\n protected _encodeByte(b: number): string {\n let result = b;\n // b >= 0\n result += 65;\n // b > 25\n result += ((25 - b) >>> 8) & ((0 - 65) - 26 + 97);\n // b > 51\n result += ((51 - b) >>> 8) & ((26 - 97) - 52 + 48);\n // b > 61\n result += ((61 - b) >>> 8) & ((52 - 48) - 62 + 45);\n // b > 62\n result += ((62 - b) >>> 8) & ((62 - 45) - 63 + 95);\n\n return String.fromCharCode(result);\n }\n\n protected _decodeChar(c: number): number {\n let result = INVALID_BYTE;\n\n // c == 45 (c > 44 and c < 46)\n result += (((44 - c) & (c - 46)) >>> 8) & (-INVALID_BYTE + c - 45 + 62);\n // c == 95 (c > 94 and c < 96)\n result += (((94 - c) & (c - 96)) >>> 8) & (-INVALID_BYTE + c - 95 + 63);\n // c > 47 and c < 58\n result += (((47 - c) & (c - 58)) >>> 8) & (-INVALID_BYTE + c - 48 + 52);\n // c > 64 and c < 91\n result += (((64 - c) & (c - 91)) >>> 8) & (-INVALID_BYTE + c - 65 + 0);\n // c > 96 and c < 123\n result += (((96 - c) & (c - 123)) >>> 8) & (-INVALID_BYTE + c - 97 + 26);\n\n return result;\n }\n}\n\nconst urlSafeCoder = new URLSafeCoder();\n\nexport function encodeURLSafe(data: Uint8Array): string {\n return urlSafeCoder.encode(data);\n}\n\nexport function decodeURLSafe(s: string): Uint8Array {\n return urlSafeCoder.decode(s);\n}\n\n\nexport const encodedLength = (length: number) =>\n stdCoder.encodedLength(length);\n\nexport const maxDecodedLength = (length: number) =>\n stdCoder.maxDecodedLength(length);\n\nexport const decodedLength = (s: string) =>\n stdCoder.decodedLength(s);\n","// Copyright (C) 2016 Dmitry Chestnykh\n// MIT License. See LICENSE file for details.\n\n/**\n * Package utf8 implements UTF-8 encoding and decoding.\n */\n\nconst INVALID_UTF16 = \"utf8: invalid string\";\nconst INVALID_UTF8 = \"utf8: invalid source encoding\";\n\n/**\n * Encodes the given string into UTF-8 byte array.\n * Throws if the source string has invalid UTF-16 encoding.\n */\nexport function encode(s: string): Uint8Array {\n // Calculate result length and allocate output array.\n // encodedLength() also validates string and throws errors,\n // so we don't need repeat validation here.\n const arr = new Uint8Array(encodedLength(s));\n\n let pos = 0;\n for (let i = 0; i < s.length; i++) {\n let c = s.charCodeAt(i);\n if (c < 0x80) {\n arr[pos++] = c;\n } else if (c < 0x800) {\n arr[pos++] = 0xc0 | c >> 6;\n arr[pos++] = 0x80 | c & 0x3f;\n } else if (c < 0xd800) {\n arr[pos++] = 0xe0 | c >> 12;\n arr[pos++] = 0x80 | (c >> 6) & 0x3f;\n arr[pos++] = 0x80 | c & 0x3f;\n } else {\n i++; // get one more character\n c = (c & 0x3ff) << 10;\n c |= s.charCodeAt(i) & 0x3ff;\n c += 0x10000;\n\n arr[pos++] = 0xf0 | c >> 18;\n arr[pos++] = 0x80 | (c >> 12) & 0x3f;\n arr[pos++] = 0x80 | (c >> 6) & 0x3f;\n arr[pos++] = 0x80 | c & 0x3f;\n }\n }\n return arr;\n}\n\n/**\n * Returns the number of bytes required to encode the given string into UTF-8.\n * Throws if the source string has invalid UTF-16 encoding.\n */\nexport function encodedLength(s: string): number {\n let result = 0;\n for (let i = 0; i < s.length; i++) {\n const c = s.charCodeAt(i);\n if (c < 0x80) {\n result += 1;\n } else if (c < 0x800) {\n result += 2;\n } else if (c < 0xd800) {\n result += 3;\n } else if (c <= 0xdfff) {\n if (i >= s.length - 1) {\n throw new Error(INVALID_UTF16);\n }\n i++; // \"eat\" next character\n result += 4;\n } else {\n throw new Error(INVALID_UTF16);\n }\n }\n return result;\n}\n\n/**\n * Decodes the given byte array from UTF-8 into a string.\n * Throws if encoding is invalid.\n */\nexport function decode(arr: Uint8Array): string {\n const chars: string[] = [];\n for (let i = 0; i < arr.length; i++) {\n let b = arr[i];\n\n if (b & 0x80) {\n let min;\n if (b < 0xe0) {\n // Need 1 more byte.\n if (i >= arr.length) {\n throw new Error(INVALID_UTF8);\n }\n const n1 = arr[++i];\n if ((n1 & 0xc0) !== 0x80) {\n throw new Error(INVALID_UTF8);\n }\n b = (b & 0x1f) << 6 | (n1 & 0x3f);\n min = 0x80;\n } else if (b < 0xf0) {\n // Need 2 more bytes.\n if (i >= arr.length - 1) {\n throw new Error(INVALID_UTF8);\n }\n const n1 = arr[++i];\n const n2 = arr[++i];\n if ((n1 & 0xc0) !== 0x80 || (n2 & 0xc0) !== 0x80) {\n throw new Error(INVALID_UTF8);\n }\n b = (b & 0x0f) << 12 | (n1 & 0x3f) << 6 | (n2 & 0x3f);\n min = 0x800;\n } else if (b < 0xf8) {\n // Need 3 more bytes.\n if (i >= arr.length - 2) {\n throw new Error(INVALID_UTF8);\n }\n const n1 = arr[++i];\n const n2 = arr[++i];\n const n3 = arr[++i];\n if ((n1 & 0xc0) !== 0x80 || (n2 & 0xc0) !== 0x80 || (n3 & 0xc0) !== 0x80) {\n throw new Error(INVALID_UTF8);\n }\n b = (b & 0x0f) << 18 | (n1 & 0x3f) << 12 | (n2 & 0x3f) << 6 | (n3 & 0x3f);\n min = 0x10000;\n } else {\n throw new Error(INVALID_UTF8);\n }\n\n if (b < min || (b >= 0xd800 && b <= 0xdfff)) {\n throw new Error(INVALID_UTF8);\n }\n\n if (b >= 0x10000) {\n // Surrogate pair.\n if (b > 0x10ffff) {\n throw new Error(INVALID_UTF8);\n }\n b -= 0x10000;\n chars.push(String.fromCharCode(0xd800 | (b >> 10)));\n b = 0xdc00 | (b & 0x3ff);\n }\n }\n\n chars.push(String.fromCharCode(b));\n }\n return chars.join(\"\");\n}\n","(function(nacl) {\n'use strict';\n\n// Ported in 2014 by Dmitry Chestnykh and Devi Mandiri.\n// Public domain.\n//\n// Implementation derived from TweetNaCl version 20140427.\n// See for details: http://tweetnacl.cr.yp.to/\n\nvar gf = function(init) {\n var i, r = new Float64Array(16);\n if (init) for (i = 0; i < init.length; i++) r[i] = init[i];\n return r;\n};\n\n// Pluggable, initialized in high-level API below.\nvar randombytes = function(/* x, n */) { throw new Error('no PRNG'); };\n\nvar _0 = new Uint8Array(16);\nvar _9 = new Uint8Array(32); _9[0] = 9;\n\nvar gf0 = gf(),\n gf1 = gf([1]),\n _121665 = gf([0xdb41, 1]),\n D = gf([0x78a3, 0x1359, 0x4dca, 0x75eb, 0xd8ab, 0x4141, 0x0a4d, 0x0070, 0xe898, 0x7779, 0x4079, 0x8cc7, 0xfe73, 0x2b6f, 0x6cee, 0x5203]),\n D2 = gf([0xf159, 0x26b2, 0x9b94, 0xebd6, 0xb156, 0x8283, 0x149a, 0x00e0, 0xd130, 0xeef3, 0x80f2, 0x198e, 0xfce7, 0x56df, 0xd9dc, 0x2406]),\n X = gf([0xd51a, 0x8f25, 0x2d60, 0xc956, 0xa7b2, 0x9525, 0xc760, 0x692c, 0xdc5c, 0xfdd6, 0xe231, 0xc0a4, 0x53fe, 0xcd6e, 0x36d3, 0x2169]),\n Y = gf([0x6658, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666]),\n I = gf([0xa0b0, 0x4a0e, 0x1b27, 0xc4ee, 0xe478, 0xad2f, 0x1806, 0x2f43, 0xd7a7, 0x3dfb, 0x0099, 0x2b4d, 0xdf0b, 0x4fc1, 0x2480, 0x2b83]);\n\nfunction ts64(x, i, h, l) {\n x[i] = (h >> 24) & 0xff;\n x[i+1] = (h >> 16) & 0xff;\n x[i+2] = (h >> 8) & 0xff;\n x[i+3] = h & 0xff;\n x[i+4] = (l >> 24) & 0xff;\n x[i+5] = (l >> 16) & 0xff;\n x[i+6] = (l >> 8) & 0xff;\n x[i+7] = l & 0xff;\n}\n\nfunction vn(x, xi, y, yi, n) {\n var i,d = 0;\n for (i = 0; i < n; i++) d |= x[xi+i]^y[yi+i];\n return (1 & ((d - 1) >>> 8)) - 1;\n}\n\nfunction crypto_verify_16(x, xi, y, yi) {\n return vn(x,xi,y,yi,16);\n}\n\nfunction crypto_verify_32(x, xi, y, yi) {\n return vn(x,xi,y,yi,32);\n}\n\nfunction core_salsa20(o, p, k, c) {\n var j0 = c[ 0] & 0xff | (c[ 1] & 0xff)<<8 | (c[ 2] & 0xff)<<16 | (c[ 3] & 0xff)<<24,\n j1 = k[ 0] & 0xff | (k[ 1] & 0xff)<<8 | (k[ 2] & 0xff)<<16 | (k[ 3] & 0xff)<<24,\n j2 = k[ 4] & 0xff | (k[ 5] & 0xff)<<8 | (k[ 6] & 0xff)<<16 | (k[ 7] & 0xff)<<24,\n j3 = k[ 8] & 0xff | (k[ 9] & 0xff)<<8 | (k[10] & 0xff)<<16 | (k[11] & 0xff)<<24,\n j4 = k[12] & 0xff | (k[13] & 0xff)<<8 | (k[14] & 0xff)<<16 | (k[15] & 0xff)<<24,\n j5 = c[ 4] & 0xff | (c[ 5] & 0xff)<<8 | (c[ 6] & 0xff)<<16 | (c[ 7] & 0xff)<<24,\n j6 = p[ 0] & 0xff | (p[ 1] & 0xff)<<8 | (p[ 2] & 0xff)<<16 | (p[ 3] & 0xff)<<24,\n j7 = p[ 4] & 0xff | (p[ 5] & 0xff)<<8 | (p[ 6] & 0xff)<<16 | (p[ 7] & 0xff)<<24,\n j8 = p[ 8] & 0xff | (p[ 9] & 0xff)<<8 | (p[10] & 0xff)<<16 | (p[11] & 0xff)<<24,\n j9 = p[12] & 0xff | (p[13] & 0xff)<<8 | (p[14] & 0xff)<<16 | (p[15] & 0xff)<<24,\n j10 = c[ 8] & 0xff | (c[ 9] & 0xff)<<8 | (c[10] & 0xff)<<16 | (c[11] & 0xff)<<24,\n j11 = k[16] & 0xff | (k[17] & 0xff)<<8 | (k[18] & 0xff)<<16 | (k[19] & 0xff)<<24,\n j12 = k[20] & 0xff | (k[21] & 0xff)<<8 | (k[22] & 0xff)<<16 | (k[23] & 0xff)<<24,\n j13 = k[24] & 0xff | (k[25] & 0xff)<<8 | (k[26] & 0xff)<<16 | (k[27] & 0xff)<<24,\n j14 = k[28] & 0xff | (k[29] & 0xff)<<8 | (k[30] & 0xff)<<16 | (k[31] & 0xff)<<24,\n j15 = c[12] & 0xff | (c[13] & 0xff)<<8 | (c[14] & 0xff)<<16 | (c[15] & 0xff)<<24;\n\n var x0 = j0, x1 = j1, x2 = j2, x3 = j3, x4 = j4, x5 = j5, x6 = j6, x7 = j7,\n x8 = j8, x9 = j9, x10 = j10, x11 = j11, x12 = j12, x13 = j13, x14 = j14,\n x15 = j15, u;\n\n for (var i = 0; i < 20; i += 2) {\n u = x0 + x12 | 0;\n x4 ^= u<<7 | u>>>(32-7);\n u = x4 + x0 | 0;\n x8 ^= u<<9 | u>>>(32-9);\n u = x8 + x4 | 0;\n x12 ^= u<<13 | u>>>(32-13);\n u = x12 + x8 | 0;\n x0 ^= u<<18 | u>>>(32-18);\n\n u = x5 + x1 | 0;\n x9 ^= u<<7 | u>>>(32-7);\n u = x9 + x5 | 0;\n x13 ^= u<<9 | u>>>(32-9);\n u = x13 + x9 | 0;\n x1 ^= u<<13 | u>>>(32-13);\n u = x1 + x13 | 0;\n x5 ^= u<<18 | u>>>(32-18);\n\n u = x10 + x6 | 0;\n x14 ^= u<<7 | u>>>(32-7);\n u = x14 + x10 | 0;\n x2 ^= u<<9 | u>>>(32-9);\n u = x2 + x14 | 0;\n x6 ^= u<<13 | u>>>(32-13);\n u = x6 + x2 | 0;\n x10 ^= u<<18 | u>>>(32-18);\n\n u = x15 + x11 | 0;\n x3 ^= u<<7 | u>>>(32-7);\n u = x3 + x15 | 0;\n x7 ^= u<<9 | u>>>(32-9);\n u = x7 + x3 | 0;\n x11 ^= u<<13 | u>>>(32-13);\n u = x11 + x7 | 0;\n x15 ^= u<<18 | u>>>(32-18);\n\n u = x0 + x3 | 0;\n x1 ^= u<<7 | u>>>(32-7);\n u = x1 + x0 | 0;\n x2 ^= u<<9 | u>>>(32-9);\n u = x2 + x1 | 0;\n x3 ^= u<<13 | u>>>(32-13);\n u = x3 + x2 | 0;\n x0 ^= u<<18 | u>>>(32-18);\n\n u = x5 + x4 | 0;\n x6 ^= u<<7 | u>>>(32-7);\n u = x6 + x5 | 0;\n x7 ^= u<<9 | u>>>(32-9);\n u = x7 + x6 | 0;\n x4 ^= u<<13 | u>>>(32-13);\n u = x4 + x7 | 0;\n x5 ^= u<<18 | u>>>(32-18);\n\n u = x10 + x9 | 0;\n x11 ^= u<<7 | u>>>(32-7);\n u = x11 + x10 | 0;\n x8 ^= u<<9 | u>>>(32-9);\n u = x8 + x11 | 0;\n x9 ^= u<<13 | u>>>(32-13);\n u = x9 + x8 | 0;\n x10 ^= u<<18 | u>>>(32-18);\n\n u = x15 + x14 | 0;\n x12 ^= u<<7 | u>>>(32-7);\n u = x12 + x15 | 0;\n x13 ^= u<<9 | u>>>(32-9);\n u = x13 + x12 | 0;\n x14 ^= u<<13 | u>>>(32-13);\n u = x14 + x13 | 0;\n x15 ^= u<<18 | u>>>(32-18);\n }\n x0 = x0 + j0 | 0;\n x1 = x1 + j1 | 0;\n x2 = x2 + j2 | 0;\n x3 = x3 + j3 | 0;\n x4 = x4 + j4 | 0;\n x5 = x5 + j5 | 0;\n x6 = x6 + j6 | 0;\n x7 = x7 + j7 | 0;\n x8 = x8 + j8 | 0;\n x9 = x9 + j9 | 0;\n x10 = x10 + j10 | 0;\n x11 = x11 + j11 | 0;\n x12 = x12 + j12 | 0;\n x13 = x13 + j13 | 0;\n x14 = x14 + j14 | 0;\n x15 = x15 + j15 | 0;\n\n o[ 0] = x0 >>> 0 & 0xff;\n o[ 1] = x0 >>> 8 & 0xff;\n o[ 2] = x0 >>> 16 & 0xff;\n o[ 3] = x0 >>> 24 & 0xff;\n\n o[ 4] = x1 >>> 0 & 0xff;\n o[ 5] = x1 >>> 8 & 0xff;\n o[ 6] = x1 >>> 16 & 0xff;\n o[ 7] = x1 >>> 24 & 0xff;\n\n o[ 8] = x2 >>> 0 & 0xff;\n o[ 9] = x2 >>> 8 & 0xff;\n o[10] = x2 >>> 16 & 0xff;\n o[11] = x2 >>> 24 & 0xff;\n\n o[12] = x3 >>> 0 & 0xff;\n o[13] = x3 >>> 8 & 0xff;\n o[14] = x3 >>> 16 & 0xff;\n o[15] = x3 >>> 24 & 0xff;\n\n o[16] = x4 >>> 0 & 0xff;\n o[17] = x4 >>> 8 & 0xff;\n o[18] = x4 >>> 16 & 0xff;\n o[19] = x4 >>> 24 & 0xff;\n\n o[20] = x5 >>> 0 & 0xff;\n o[21] = x5 >>> 8 & 0xff;\n o[22] = x5 >>> 16 & 0xff;\n o[23] = x5 >>> 24 & 0xff;\n\n o[24] = x6 >>> 0 & 0xff;\n o[25] = x6 >>> 8 & 0xff;\n o[26] = x6 >>> 16 & 0xff;\n o[27] = x6 >>> 24 & 0xff;\n\n o[28] = x7 >>> 0 & 0xff;\n o[29] = x7 >>> 8 & 0xff;\n o[30] = x7 >>> 16 & 0xff;\n o[31] = x7 >>> 24 & 0xff;\n\n o[32] = x8 >>> 0 & 0xff;\n o[33] = x8 >>> 8 & 0xff;\n o[34] = x8 >>> 16 & 0xff;\n o[35] = x8 >>> 24 & 0xff;\n\n o[36] = x9 >>> 0 & 0xff;\n o[37] = x9 >>> 8 & 0xff;\n o[38] = x9 >>> 16 & 0xff;\n o[39] = x9 >>> 24 & 0xff;\n\n o[40] = x10 >>> 0 & 0xff;\n o[41] = x10 >>> 8 & 0xff;\n o[42] = x10 >>> 16 & 0xff;\n o[43] = x10 >>> 24 & 0xff;\n\n o[44] = x11 >>> 0 & 0xff;\n o[45] = x11 >>> 8 & 0xff;\n o[46] = x11 >>> 16 & 0xff;\n o[47] = x11 >>> 24 & 0xff;\n\n o[48] = x12 >>> 0 & 0xff;\n o[49] = x12 >>> 8 & 0xff;\n o[50] = x12 >>> 16 & 0xff;\n o[51] = x12 >>> 24 & 0xff;\n\n o[52] = x13 >>> 0 & 0xff;\n o[53] = x13 >>> 8 & 0xff;\n o[54] = x13 >>> 16 & 0xff;\n o[55] = x13 >>> 24 & 0xff;\n\n o[56] = x14 >>> 0 & 0xff;\n o[57] = x14 >>> 8 & 0xff;\n o[58] = x14 >>> 16 & 0xff;\n o[59] = x14 >>> 24 & 0xff;\n\n o[60] = x15 >>> 0 & 0xff;\n o[61] = x15 >>> 8 & 0xff;\n o[62] = x15 >>> 16 & 0xff;\n o[63] = x15 >>> 24 & 0xff;\n}\n\nfunction core_hsalsa20(o,p,k,c) {\n var j0 = c[ 0] & 0xff | (c[ 1] & 0xff)<<8 | (c[ 2] & 0xff)<<16 | (c[ 3] & 0xff)<<24,\n j1 = k[ 0] & 0xff | (k[ 1] & 0xff)<<8 | (k[ 2] & 0xff)<<16 | (k[ 3] & 0xff)<<24,\n j2 = k[ 4] & 0xff | (k[ 5] & 0xff)<<8 | (k[ 6] & 0xff)<<16 | (k[ 7] & 0xff)<<24,\n j3 = k[ 8] & 0xff | (k[ 9] & 0xff)<<8 | (k[10] & 0xff)<<16 | (k[11] & 0xff)<<24,\n j4 = k[12] & 0xff | (k[13] & 0xff)<<8 | (k[14] & 0xff)<<16 | (k[15] & 0xff)<<24,\n j5 = c[ 4] & 0xff | (c[ 5] & 0xff)<<8 | (c[ 6] & 0xff)<<16 | (c[ 7] & 0xff)<<24,\n j6 = p[ 0] & 0xff | (p[ 1] & 0xff)<<8 | (p[ 2] & 0xff)<<16 | (p[ 3] & 0xff)<<24,\n j7 = p[ 4] & 0xff | (p[ 5] & 0xff)<<8 | (p[ 6] & 0xff)<<16 | (p[ 7] & 0xff)<<24,\n j8 = p[ 8] & 0xff | (p[ 9] & 0xff)<<8 | (p[10] & 0xff)<<16 | (p[11] & 0xff)<<24,\n j9 = p[12] & 0xff | (p[13] & 0xff)<<8 | (p[14] & 0xff)<<16 | (p[15] & 0xff)<<24,\n j10 = c[ 8] & 0xff | (c[ 9] & 0xff)<<8 | (c[10] & 0xff)<<16 | (c[11] & 0xff)<<24,\n j11 = k[16] & 0xff | (k[17] & 0xff)<<8 | (k[18] & 0xff)<<16 | (k[19] & 0xff)<<24,\n j12 = k[20] & 0xff | (k[21] & 0xff)<<8 | (k[22] & 0xff)<<16 | (k[23] & 0xff)<<24,\n j13 = k[24] & 0xff | (k[25] & 0xff)<<8 | (k[26] & 0xff)<<16 | (k[27] & 0xff)<<24,\n j14 = k[28] & 0xff | (k[29] & 0xff)<<8 | (k[30] & 0xff)<<16 | (k[31] & 0xff)<<24,\n j15 = c[12] & 0xff | (c[13] & 0xff)<<8 | (c[14] & 0xff)<<16 | (c[15] & 0xff)<<24;\n\n var x0 = j0, x1 = j1, x2 = j2, x3 = j3, x4 = j4, x5 = j5, x6 = j6, x7 = j7,\n x8 = j8, x9 = j9, x10 = j10, x11 = j11, x12 = j12, x13 = j13, x14 = j14,\n x15 = j15, u;\n\n for (var i = 0; i < 20; i += 2) {\n u = x0 + x12 | 0;\n x4 ^= u<<7 | u>>>(32-7);\n u = x4 + x0 | 0;\n x8 ^= u<<9 | u>>>(32-9);\n u = x8 + x4 | 0;\n x12 ^= u<<13 | u>>>(32-13);\n u = x12 + x8 | 0;\n x0 ^= u<<18 | u>>>(32-18);\n\n u = x5 + x1 | 0;\n x9 ^= u<<7 | u>>>(32-7);\n u = x9 + x5 | 0;\n x13 ^= u<<9 | u>>>(32-9);\n u = x13 + x9 | 0;\n x1 ^= u<<13 | u>>>(32-13);\n u = x1 + x13 | 0;\n x5 ^= u<<18 | u>>>(32-18);\n\n u = x10 + x6 | 0;\n x14 ^= u<<7 | u>>>(32-7);\n u = x14 + x10 | 0;\n x2 ^= u<<9 | u>>>(32-9);\n u = x2 + x14 | 0;\n x6 ^= u<<13 | u>>>(32-13);\n u = x6 + x2 | 0;\n x10 ^= u<<18 | u>>>(32-18);\n\n u = x15 + x11 | 0;\n x3 ^= u<<7 | u>>>(32-7);\n u = x3 + x15 | 0;\n x7 ^= u<<9 | u>>>(32-9);\n u = x7 + x3 | 0;\n x11 ^= u<<13 | u>>>(32-13);\n u = x11 + x7 | 0;\n x15 ^= u<<18 | u>>>(32-18);\n\n u = x0 + x3 | 0;\n x1 ^= u<<7 | u>>>(32-7);\n u = x1 + x0 | 0;\n x2 ^= u<<9 | u>>>(32-9);\n u = x2 + x1 | 0;\n x3 ^= u<<13 | u>>>(32-13);\n u = x3 + x2 | 0;\n x0 ^= u<<18 | u>>>(32-18);\n\n u = x5 + x4 | 0;\n x6 ^= u<<7 | u>>>(32-7);\n u = x6 + x5 | 0;\n x7 ^= u<<9 | u>>>(32-9);\n u = x7 + x6 | 0;\n x4 ^= u<<13 | u>>>(32-13);\n u = x4 + x7 | 0;\n x5 ^= u<<18 | u>>>(32-18);\n\n u = x10 + x9 | 0;\n x11 ^= u<<7 | u>>>(32-7);\n u = x11 + x10 | 0;\n x8 ^= u<<9 | u>>>(32-9);\n u = x8 + x11 | 0;\n x9 ^= u<<13 | u>>>(32-13);\n u = x9 + x8 | 0;\n x10 ^= u<<18 | u>>>(32-18);\n\n u = x15 + x14 | 0;\n x12 ^= u<<7 | u>>>(32-7);\n u = x12 + x15 | 0;\n x13 ^= u<<9 | u>>>(32-9);\n u = x13 + x12 | 0;\n x14 ^= u<<13 | u>>>(32-13);\n u = x14 + x13 | 0;\n x15 ^= u<<18 | u>>>(32-18);\n }\n\n o[ 0] = x0 >>> 0 & 0xff;\n o[ 1] = x0 >>> 8 & 0xff;\n o[ 2] = x0 >>> 16 & 0xff;\n o[ 3] = x0 >>> 24 & 0xff;\n\n o[ 4] = x5 >>> 0 & 0xff;\n o[ 5] = x5 >>> 8 & 0xff;\n o[ 6] = x5 >>> 16 & 0xff;\n o[ 7] = x5 >>> 24 & 0xff;\n\n o[ 8] = x10 >>> 0 & 0xff;\n o[ 9] = x10 >>> 8 & 0xff;\n o[10] = x10 >>> 16 & 0xff;\n o[11] = x10 >>> 24 & 0xff;\n\n o[12] = x15 >>> 0 & 0xff;\n o[13] = x15 >>> 8 & 0xff;\n o[14] = x15 >>> 16 & 0xff;\n o[15] = x15 >>> 24 & 0xff;\n\n o[16] = x6 >>> 0 & 0xff;\n o[17] = x6 >>> 8 & 0xff;\n o[18] = x6 >>> 16 & 0xff;\n o[19] = x6 >>> 24 & 0xff;\n\n o[20] = x7 >>> 0 & 0xff;\n o[21] = x7 >>> 8 & 0xff;\n o[22] = x7 >>> 16 & 0xff;\n o[23] = x7 >>> 24 & 0xff;\n\n o[24] = x8 >>> 0 & 0xff;\n o[25] = x8 >>> 8 & 0xff;\n o[26] = x8 >>> 16 & 0xff;\n o[27] = x8 >>> 24 & 0xff;\n\n o[28] = x9 >>> 0 & 0xff;\n o[29] = x9 >>> 8 & 0xff;\n o[30] = x9 >>> 16 & 0xff;\n o[31] = x9 >>> 24 & 0xff;\n}\n\nfunction crypto_core_salsa20(out,inp,k,c) {\n core_salsa20(out,inp,k,c);\n}\n\nfunction crypto_core_hsalsa20(out,inp,k,c) {\n core_hsalsa20(out,inp,k,c);\n}\n\nvar sigma = new Uint8Array([101, 120, 112, 97, 110, 100, 32, 51, 50, 45, 98, 121, 116, 101, 32, 107]);\n // \"expand 32-byte k\"\n\nfunction crypto_stream_salsa20_xor(c,cpos,m,mpos,b,n,k) {\n var z = new Uint8Array(16), x = new Uint8Array(64);\n var u, i;\n for (i = 0; i < 16; i++) z[i] = 0;\n for (i = 0; i < 8; i++) z[i] = n[i];\n while (b >= 64) {\n crypto_core_salsa20(x,z,k,sigma);\n for (i = 0; i < 64; i++) c[cpos+i] = m[mpos+i] ^ x[i];\n u = 1;\n for (i = 8; i < 16; i++) {\n u = u + (z[i] & 0xff) | 0;\n z[i] = u & 0xff;\n u >>>= 8;\n }\n b -= 64;\n cpos += 64;\n mpos += 64;\n }\n if (b > 0) {\n crypto_core_salsa20(x,z,k,sigma);\n for (i = 0; i < b; i++) c[cpos+i] = m[mpos+i] ^ x[i];\n }\n return 0;\n}\n\nfunction crypto_stream_salsa20(c,cpos,b,n,k) {\n var z = new Uint8Array(16), x = new Uint8Array(64);\n var u, i;\n for (i = 0; i < 16; i++) z[i] = 0;\n for (i = 0; i < 8; i++) z[i] = n[i];\n while (b >= 64) {\n crypto_core_salsa20(x,z,k,sigma);\n for (i = 0; i < 64; i++) c[cpos+i] = x[i];\n u = 1;\n for (i = 8; i < 16; i++) {\n u = u + (z[i] & 0xff) | 0;\n z[i] = u & 0xff;\n u >>>= 8;\n }\n b -= 64;\n cpos += 64;\n }\n if (b > 0) {\n crypto_core_salsa20(x,z,k,sigma);\n for (i = 0; i < b; i++) c[cpos+i] = x[i];\n }\n return 0;\n}\n\nfunction crypto_stream(c,cpos,d,n,k) {\n var s = new Uint8Array(32);\n crypto_core_hsalsa20(s,n,k,sigma);\n var sn = new Uint8Array(8);\n for (var i = 0; i < 8; i++) sn[i] = n[i+16];\n return crypto_stream_salsa20(c,cpos,d,sn,s);\n}\n\nfunction crypto_stream_xor(c,cpos,m,mpos,d,n,k) {\n var s = new Uint8Array(32);\n crypto_core_hsalsa20(s,n,k,sigma);\n var sn = new Uint8Array(8);\n for (var i = 0; i < 8; i++) sn[i] = n[i+16];\n return crypto_stream_salsa20_xor(c,cpos,m,mpos,d,sn,s);\n}\n\n/*\n* Port of Andrew Moon's Poly1305-donna-16. Public domain.\n* https://github.com/floodyberry/poly1305-donna\n*/\n\nvar poly1305 = function(key) {\n this.buffer = new Uint8Array(16);\n this.r = new Uint16Array(10);\n this.h = new Uint16Array(10);\n this.pad = new Uint16Array(8);\n this.leftover = 0;\n this.fin = 0;\n\n var t0, t1, t2, t3, t4, t5, t6, t7;\n\n t0 = key[ 0] & 0xff | (key[ 1] & 0xff) << 8; this.r[0] = ( t0 ) & 0x1fff;\n t1 = key[ 2] & 0xff | (key[ 3] & 0xff) << 8; this.r[1] = ((t0 >>> 13) | (t1 << 3)) & 0x1fff;\n t2 = key[ 4] & 0xff | (key[ 5] & 0xff) << 8; this.r[2] = ((t1 >>> 10) | (t2 << 6)) & 0x1f03;\n t3 = key[ 6] & 0xff | (key[ 7] & 0xff) << 8; this.r[3] = ((t2 >>> 7) | (t3 << 9)) & 0x1fff;\n t4 = key[ 8] & 0xff | (key[ 9] & 0xff) << 8; this.r[4] = ((t3 >>> 4) | (t4 << 12)) & 0x00ff;\n this.r[5] = ((t4 >>> 1)) & 0x1ffe;\n t5 = key[10] & 0xff | (key[11] & 0xff) << 8; this.r[6] = ((t4 >>> 14) | (t5 << 2)) & 0x1fff;\n t6 = key[12] & 0xff | (key[13] & 0xff) << 8; this.r[7] = ((t5 >>> 11) | (t6 << 5)) & 0x1f81;\n t7 = key[14] & 0xff | (key[15] & 0xff) << 8; this.r[8] = ((t6 >>> 8) | (t7 << 8)) & 0x1fff;\n this.r[9] = ((t7 >>> 5)) & 0x007f;\n\n this.pad[0] = key[16] & 0xff | (key[17] & 0xff) << 8;\n this.pad[1] = key[18] & 0xff | (key[19] & 0xff) << 8;\n this.pad[2] = key[20] & 0xff | (key[21] & 0xff) << 8;\n this.pad[3] = key[22] & 0xff | (key[23] & 0xff) << 8;\n this.pad[4] = key[24] & 0xff | (key[25] & 0xff) << 8;\n this.pad[5] = key[26] & 0xff | (key[27] & 0xff) << 8;\n this.pad[6] = key[28] & 0xff | (key[29] & 0xff) << 8;\n this.pad[7] = key[30] & 0xff | (key[31] & 0xff) << 8;\n};\n\npoly1305.prototype.blocks = function(m, mpos, bytes) {\n var hibit = this.fin ? 0 : (1 << 11);\n var t0, t1, t2, t3, t4, t5, t6, t7, c;\n var d0, d1, d2, d3, d4, d5, d6, d7, d8, d9;\n\n var h0 = this.h[0],\n h1 = this.h[1],\n h2 = this.h[2],\n h3 = this.h[3],\n h4 = this.h[4],\n h5 = this.h[5],\n h6 = this.h[6],\n h7 = this.h[7],\n h8 = this.h[8],\n h9 = this.h[9];\n\n var r0 = this.r[0],\n r1 = this.r[1],\n r2 = this.r[2],\n r3 = this.r[3],\n r4 = this.r[4],\n r5 = this.r[5],\n r6 = this.r[6],\n r7 = this.r[7],\n r8 = this.r[8],\n r9 = this.r[9];\n\n while (bytes >= 16) {\n t0 = m[mpos+ 0] & 0xff | (m[mpos+ 1] & 0xff) << 8; h0 += ( t0 ) & 0x1fff;\n t1 = m[mpos+ 2] & 0xff | (m[mpos+ 3] & 0xff) << 8; h1 += ((t0 >>> 13) | (t1 << 3)) & 0x1fff;\n t2 = m[mpos+ 4] & 0xff | (m[mpos+ 5] & 0xff) << 8; h2 += ((t1 >>> 10) | (t2 << 6)) & 0x1fff;\n t3 = m[mpos+ 6] & 0xff | (m[mpos+ 7] & 0xff) << 8; h3 += ((t2 >>> 7) | (t3 << 9)) & 0x1fff;\n t4 = m[mpos+ 8] & 0xff | (m[mpos+ 9] & 0xff) << 8; h4 += ((t3 >>> 4) | (t4 << 12)) & 0x1fff;\n h5 += ((t4 >>> 1)) & 0x1fff;\n t5 = m[mpos+10] & 0xff | (m[mpos+11] & 0xff) << 8; h6 += ((t4 >>> 14) | (t5 << 2)) & 0x1fff;\n t6 = m[mpos+12] & 0xff | (m[mpos+13] & 0xff) << 8; h7 += ((t5 >>> 11) | (t6 << 5)) & 0x1fff;\n t7 = m[mpos+14] & 0xff | (m[mpos+15] & 0xff) << 8; h8 += ((t6 >>> 8) | (t7 << 8)) & 0x1fff;\n h9 += ((t7 >>> 5)) | hibit;\n\n c = 0;\n\n d0 = c;\n d0 += h0 * r0;\n d0 += h1 * (5 * r9);\n d0 += h2 * (5 * r8);\n d0 += h3 * (5 * r7);\n d0 += h4 * (5 * r6);\n c = (d0 >>> 13); d0 &= 0x1fff;\n d0 += h5 * (5 * r5);\n d0 += h6 * (5 * r4);\n d0 += h7 * (5 * r3);\n d0 += h8 * (5 * r2);\n d0 += h9 * (5 * r1);\n c += (d0 >>> 13); d0 &= 0x1fff;\n\n d1 = c;\n d1 += h0 * r1;\n d1 += h1 * r0;\n d1 += h2 * (5 * r9);\n d1 += h3 * (5 * r8);\n d1 += h4 * (5 * r7);\n c = (d1 >>> 13); d1 &= 0x1fff;\n d1 += h5 * (5 * r6);\n d1 += h6 * (5 * r5);\n d1 += h7 * (5 * r4);\n d1 += h8 * (5 * r3);\n d1 += h9 * (5 * r2);\n c += (d1 >>> 13); d1 &= 0x1fff;\n\n d2 = c;\n d2 += h0 * r2;\n d2 += h1 * r1;\n d2 += h2 * r0;\n d2 += h3 * (5 * r9);\n d2 += h4 * (5 * r8);\n c = (d2 >>> 13); d2 &= 0x1fff;\n d2 += h5 * (5 * r7);\n d2 += h6 * (5 * r6);\n d2 += h7 * (5 * r5);\n d2 += h8 * (5 * r4);\n d2 += h9 * (5 * r3);\n c += (d2 >>> 13); d2 &= 0x1fff;\n\n d3 = c;\n d3 += h0 * r3;\n d3 += h1 * r2;\n d3 += h2 * r1;\n d3 += h3 * r0;\n d3 += h4 * (5 * r9);\n c = (d3 >>> 13); d3 &= 0x1fff;\n d3 += h5 * (5 * r8);\n d3 += h6 * (5 * r7);\n d3 += h7 * (5 * r6);\n d3 += h8 * (5 * r5);\n d3 += h9 * (5 * r4);\n c += (d3 >>> 13); d3 &= 0x1fff;\n\n d4 = c;\n d4 += h0 * r4;\n d4 += h1 * r3;\n d4 += h2 * r2;\n d4 += h3 * r1;\n d4 += h4 * r0;\n c = (d4 >>> 13); d4 &= 0x1fff;\n d4 += h5 * (5 * r9);\n d4 += h6 * (5 * r8);\n d4 += h7 * (5 * r7);\n d4 += h8 * (5 * r6);\n d4 += h9 * (5 * r5);\n c += (d4 >>> 13); d4 &= 0x1fff;\n\n d5 = c;\n d5 += h0 * r5;\n d5 += h1 * r4;\n d5 += h2 * r3;\n d5 += h3 * r2;\n d5 += h4 * r1;\n c = (d5 >>> 13); d5 &= 0x1fff;\n d5 += h5 * r0;\n d5 += h6 * (5 * r9);\n d5 += h7 * (5 * r8);\n d5 += h8 * (5 * r7);\n d5 += h9 * (5 * r6);\n c += (d5 >>> 13); d5 &= 0x1fff;\n\n d6 = c;\n d6 += h0 * r6;\n d6 += h1 * r5;\n d6 += h2 * r4;\n d6 += h3 * r3;\n d6 += h4 * r2;\n c = (d6 >>> 13); d6 &= 0x1fff;\n d6 += h5 * r1;\n d6 += h6 * r0;\n d6 += h7 * (5 * r9);\n d6 += h8 * (5 * r8);\n d6 += h9 * (5 * r7);\n c += (d6 >>> 13); d6 &= 0x1fff;\n\n d7 = c;\n d7 += h0 * r7;\n d7 += h1 * r6;\n d7 += h2 * r5;\n d7 += h3 * r4;\n d7 += h4 * r3;\n c = (d7 >>> 13); d7 &= 0x1fff;\n d7 += h5 * r2;\n d7 += h6 * r1;\n d7 += h7 * r0;\n d7 += h8 * (5 * r9);\n d7 += h9 * (5 * r8);\n c += (d7 >>> 13); d7 &= 0x1fff;\n\n d8 = c;\n d8 += h0 * r8;\n d8 += h1 * r7;\n d8 += h2 * r6;\n d8 += h3 * r5;\n d8 += h4 * r4;\n c = (d8 >>> 13); d8 &= 0x1fff;\n d8 += h5 * r3;\n d8 += h6 * r2;\n d8 += h7 * r1;\n d8 += h8 * r0;\n d8 += h9 * (5 * r9);\n c += (d8 >>> 13); d8 &= 0x1fff;\n\n d9 = c;\n d9 += h0 * r9;\n d9 += h1 * r8;\n d9 += h2 * r7;\n d9 += h3 * r6;\n d9 += h4 * r5;\n c = (d9 >>> 13); d9 &= 0x1fff;\n d9 += h5 * r4;\n d9 += h6 * r3;\n d9 += h7 * r2;\n d9 += h8 * r1;\n d9 += h9 * r0;\n c += (d9 >>> 13); d9 &= 0x1fff;\n\n c = (((c << 2) + c)) | 0;\n c = (c + d0) | 0;\n d0 = c & 0x1fff;\n c = (c >>> 13);\n d1 += c;\n\n h0 = d0;\n h1 = d1;\n h2 = d2;\n h3 = d3;\n h4 = d4;\n h5 = d5;\n h6 = d6;\n h7 = d7;\n h8 = d8;\n h9 = d9;\n\n mpos += 16;\n bytes -= 16;\n }\n this.h[0] = h0;\n this.h[1] = h1;\n this.h[2] = h2;\n this.h[3] = h3;\n this.h[4] = h4;\n this.h[5] = h5;\n this.h[6] = h6;\n this.h[7] = h7;\n this.h[8] = h8;\n this.h[9] = h9;\n};\n\npoly1305.prototype.finish = function(mac, macpos) {\n var g = new Uint16Array(10);\n var c, mask, f, i;\n\n if (this.leftover) {\n i = this.leftover;\n this.buffer[i++] = 1;\n for (; i < 16; i++) this.buffer[i] = 0;\n this.fin = 1;\n this.blocks(this.buffer, 0, 16);\n }\n\n c = this.h[1] >>> 13;\n this.h[1] &= 0x1fff;\n for (i = 2; i < 10; i++) {\n this.h[i] += c;\n c = this.h[i] >>> 13;\n this.h[i] &= 0x1fff;\n }\n this.h[0] += (c * 5);\n c = this.h[0] >>> 13;\n this.h[0] &= 0x1fff;\n this.h[1] += c;\n c = this.h[1] >>> 13;\n this.h[1] &= 0x1fff;\n this.h[2] += c;\n\n g[0] = this.h[0] + 5;\n c = g[0] >>> 13;\n g[0] &= 0x1fff;\n for (i = 1; i < 10; i++) {\n g[i] = this.h[i] + c;\n c = g[i] >>> 13;\n g[i] &= 0x1fff;\n }\n g[9] -= (1 << 13);\n\n mask = (c ^ 1) - 1;\n for (i = 0; i < 10; i++) g[i] &= mask;\n mask = ~mask;\n for (i = 0; i < 10; i++) this.h[i] = (this.h[i] & mask) | g[i];\n\n this.h[0] = ((this.h[0] ) | (this.h[1] << 13) ) & 0xffff;\n this.h[1] = ((this.h[1] >>> 3) | (this.h[2] << 10) ) & 0xffff;\n this.h[2] = ((this.h[2] >>> 6) | (this.h[3] << 7) ) & 0xffff;\n this.h[3] = ((this.h[3] >>> 9) | (this.h[4] << 4) ) & 0xffff;\n this.h[4] = ((this.h[4] >>> 12) | (this.h[5] << 1) | (this.h[6] << 14)) & 0xffff;\n this.h[5] = ((this.h[6] >>> 2) | (this.h[7] << 11) ) & 0xffff;\n this.h[6] = ((this.h[7] >>> 5) | (this.h[8] << 8) ) & 0xffff;\n this.h[7] = ((this.h[8] >>> 8) | (this.h[9] << 5) ) & 0xffff;\n\n f = this.h[0] + this.pad[0];\n this.h[0] = f & 0xffff;\n for (i = 1; i < 8; i++) {\n f = (((this.h[i] + this.pad[i]) | 0) + (f >>> 16)) | 0;\n this.h[i] = f & 0xffff;\n }\n\n mac[macpos+ 0] = (this.h[0] >>> 0) & 0xff;\n mac[macpos+ 1] = (this.h[0] >>> 8) & 0xff;\n mac[macpos+ 2] = (this.h[1] >>> 0) & 0xff;\n mac[macpos+ 3] = (this.h[1] >>> 8) & 0xff;\n mac[macpos+ 4] = (this.h[2] >>> 0) & 0xff;\n mac[macpos+ 5] = (this.h[2] >>> 8) & 0xff;\n mac[macpos+ 6] = (this.h[3] >>> 0) & 0xff;\n mac[macpos+ 7] = (this.h[3] >>> 8) & 0xff;\n mac[macpos+ 8] = (this.h[4] >>> 0) & 0xff;\n mac[macpos+ 9] = (this.h[4] >>> 8) & 0xff;\n mac[macpos+10] = (this.h[5] >>> 0) & 0xff;\n mac[macpos+11] = (this.h[5] >>> 8) & 0xff;\n mac[macpos+12] = (this.h[6] >>> 0) & 0xff;\n mac[macpos+13] = (this.h[6] >>> 8) & 0xff;\n mac[macpos+14] = (this.h[7] >>> 0) & 0xff;\n mac[macpos+15] = (this.h[7] >>> 8) & 0xff;\n};\n\npoly1305.prototype.update = function(m, mpos, bytes) {\n var i, want;\n\n if (this.leftover) {\n want = (16 - this.leftover);\n if (want > bytes)\n want = bytes;\n for (i = 0; i < want; i++)\n this.buffer[this.leftover + i] = m[mpos+i];\n bytes -= want;\n mpos += want;\n this.leftover += want;\n if (this.leftover < 16)\n return;\n this.blocks(this.buffer, 0, 16);\n this.leftover = 0;\n }\n\n if (bytes >= 16) {\n want = bytes - (bytes % 16);\n this.blocks(m, mpos, want);\n mpos += want;\n bytes -= want;\n }\n\n if (bytes) {\n for (i = 0; i < bytes; i++)\n this.buffer[this.leftover + i] = m[mpos+i];\n this.leftover += bytes;\n }\n};\n\nfunction crypto_onetimeauth(out, outpos, m, mpos, n, k) {\n var s = new poly1305(k);\n s.update(m, mpos, n);\n s.finish(out, outpos);\n return 0;\n}\n\nfunction crypto_onetimeauth_verify(h, hpos, m, mpos, n, k) {\n var x = new Uint8Array(16);\n crypto_onetimeauth(x,0,m,mpos,n,k);\n return crypto_verify_16(h,hpos,x,0);\n}\n\nfunction crypto_secretbox(c,m,d,n,k) {\n var i;\n if (d < 32) return -1;\n crypto_stream_xor(c,0,m,0,d,n,k);\n crypto_onetimeauth(c, 16, c, 32, d - 32, c);\n for (i = 0; i < 16; i++) c[i] = 0;\n return 0;\n}\n\nfunction crypto_secretbox_open(m,c,d,n,k) {\n var i;\n var x = new Uint8Array(32);\n if (d < 32) return -1;\n crypto_stream(x,0,32,n,k);\n if (crypto_onetimeauth_verify(c, 16,c, 32,d - 32,x) !== 0) return -1;\n crypto_stream_xor(m,0,c,0,d,n,k);\n for (i = 0; i < 32; i++) m[i] = 0;\n return 0;\n}\n\nfunction set25519(r, a) {\n var i;\n for (i = 0; i < 16; i++) r[i] = a[i]|0;\n}\n\nfunction car25519(o) {\n var i, v, c = 1;\n for (i = 0; i < 16; i++) {\n v = o[i] + c + 65535;\n c = Math.floor(v / 65536);\n o[i] = v - c * 65536;\n }\n o[0] += c-1 + 37 * (c-1);\n}\n\nfunction sel25519(p, q, b) {\n var t, c = ~(b-1);\n for (var i = 0; i < 16; i++) {\n t = c & (p[i] ^ q[i]);\n p[i] ^= t;\n q[i] ^= t;\n }\n}\n\nfunction pack25519(o, n) {\n var i, j, b;\n var m = gf(), t = gf();\n for (i = 0; i < 16; i++) t[i] = n[i];\n car25519(t);\n car25519(t);\n car25519(t);\n for (j = 0; j < 2; j++) {\n m[0] = t[0] - 0xffed;\n for (i = 1; i < 15; i++) {\n m[i] = t[i] - 0xffff - ((m[i-1]>>16) & 1);\n m[i-1] &= 0xffff;\n }\n m[15] = t[15] - 0x7fff - ((m[14]>>16) & 1);\n b = (m[15]>>16) & 1;\n m[14] &= 0xffff;\n sel25519(t, m, 1-b);\n }\n for (i = 0; i < 16; i++) {\n o[2*i] = t[i] & 0xff;\n o[2*i+1] = t[i]>>8;\n }\n}\n\nfunction neq25519(a, b) {\n var c = new Uint8Array(32), d = new Uint8Array(32);\n pack25519(c, a);\n pack25519(d, b);\n return crypto_verify_32(c, 0, d, 0);\n}\n\nfunction par25519(a) {\n var d = new Uint8Array(32);\n pack25519(d, a);\n return d[0] & 1;\n}\n\nfunction unpack25519(o, n) {\n var i;\n for (i = 0; i < 16; i++) o[i] = n[2*i] + (n[2*i+1] << 8);\n o[15] &= 0x7fff;\n}\n\nfunction A(o, a, b) {\n for (var i = 0; i < 16; i++) o[i] = a[i] + b[i];\n}\n\nfunction Z(o, a, b) {\n for (var i = 0; i < 16; i++) o[i] = a[i] - b[i];\n}\n\nfunction M(o, a, b) {\n var v, c,\n t0 = 0, t1 = 0, t2 = 0, t3 = 0, t4 = 0, t5 = 0, t6 = 0, t7 = 0,\n t8 = 0, t9 = 0, t10 = 0, t11 = 0, t12 = 0, t13 = 0, t14 = 0, t15 = 0,\n t16 = 0, t17 = 0, t18 = 0, t19 = 0, t20 = 0, t21 = 0, t22 = 0, t23 = 0,\n t24 = 0, t25 = 0, t26 = 0, t27 = 0, t28 = 0, t29 = 0, t30 = 0,\n b0 = b[0],\n b1 = b[1],\n b2 = b[2],\n b3 = b[3],\n b4 = b[4],\n b5 = b[5],\n b6 = b[6],\n b7 = b[7],\n b8 = b[8],\n b9 = b[9],\n b10 = b[10],\n b11 = b[11],\n b12 = b[12],\n b13 = b[13],\n b14 = b[14],\n b15 = b[15];\n\n v = a[0];\n t0 += v * b0;\n t1 += v * b1;\n t2 += v * b2;\n t3 += v * b3;\n t4 += v * b4;\n t5 += v * b5;\n t6 += v * b6;\n t7 += v * b7;\n t8 += v * b8;\n t9 += v * b9;\n t10 += v * b10;\n t11 += v * b11;\n t12 += v * b12;\n t13 += v * b13;\n t14 += v * b14;\n t15 += v * b15;\n v = a[1];\n t1 += v * b0;\n t2 += v * b1;\n t3 += v * b2;\n t4 += v * b3;\n t5 += v * b4;\n t6 += v * b5;\n t7 += v * b6;\n t8 += v * b7;\n t9 += v * b8;\n t10 += v * b9;\n t11 += v * b10;\n t12 += v * b11;\n t13 += v * b12;\n t14 += v * b13;\n t15 += v * b14;\n t16 += v * b15;\n v = a[2];\n t2 += v * b0;\n t3 += v * b1;\n t4 += v * b2;\n t5 += v * b3;\n t6 += v * b4;\n t7 += v * b5;\n t8 += v * b6;\n t9 += v * b7;\n t10 += v * b8;\n t11 += v * b9;\n t12 += v * b10;\n t13 += v * b11;\n t14 += v * b12;\n t15 += v * b13;\n t16 += v * b14;\n t17 += v * b15;\n v = a[3];\n t3 += v * b0;\n t4 += v * b1;\n t5 += v * b2;\n t6 += v * b3;\n t7 += v * b4;\n t8 += v * b5;\n t9 += v * b6;\n t10 += v * b7;\n t11 += v * b8;\n t12 += v * b9;\n t13 += v * b10;\n t14 += v * b11;\n t15 += v * b12;\n t16 += v * b13;\n t17 += v * b14;\n t18 += v * b15;\n v = a[4];\n t4 += v * b0;\n t5 += v * b1;\n t6 += v * b2;\n t7 += v * b3;\n t8 += v * b4;\n t9 += v * b5;\n t10 += v * b6;\n t11 += v * b7;\n t12 += v * b8;\n t13 += v * b9;\n t14 += v * b10;\n t15 += v * b11;\n t16 += v * b12;\n t17 += v * b13;\n t18 += v * b14;\n t19 += v * b15;\n v = a[5];\n t5 += v * b0;\n t6 += v * b1;\n t7 += v * b2;\n t8 += v * b3;\n t9 += v * b4;\n t10 += v * b5;\n t11 += v * b6;\n t12 += v * b7;\n t13 += v * b8;\n t14 += v * b9;\n t15 += v * b10;\n t16 += v * b11;\n t17 += v * b12;\n t18 += v * b13;\n t19 += v * b14;\n t20 += v * b15;\n v = a[6];\n t6 += v * b0;\n t7 += v * b1;\n t8 += v * b2;\n t9 += v * b3;\n t10 += v * b4;\n t11 += v * b5;\n t12 += v * b6;\n t13 += v * b7;\n t14 += v * b8;\n t15 += v * b9;\n t16 += v * b10;\n t17 += v * b11;\n t18 += v * b12;\n t19 += v * b13;\n t20 += v * b14;\n t21 += v * b15;\n v = a[7];\n t7 += v * b0;\n t8 += v * b1;\n t9 += v * b2;\n t10 += v * b3;\n t11 += v * b4;\n t12 += v * b5;\n t13 += v * b6;\n t14 += v * b7;\n t15 += v * b8;\n t16 += v * b9;\n t17 += v * b10;\n t18 += v * b11;\n t19 += v * b12;\n t20 += v * b13;\n t21 += v * b14;\n t22 += v * b15;\n v = a[8];\n t8 += v * b0;\n t9 += v * b1;\n t10 += v * b2;\n t11 += v * b3;\n t12 += v * b4;\n t13 += v * b5;\n t14 += v * b6;\n t15 += v * b7;\n t16 += v * b8;\n t17 += v * b9;\n t18 += v * b10;\n t19 += v * b11;\n t20 += v * b12;\n t21 += v * b13;\n t22 += v * b14;\n t23 += v * b15;\n v = a[9];\n t9 += v * b0;\n t10 += v * b1;\n t11 += v * b2;\n t12 += v * b3;\n t13 += v * b4;\n t14 += v * b5;\n t15 += v * b6;\n t16 += v * b7;\n t17 += v * b8;\n t18 += v * b9;\n t19 += v * b10;\n t20 += v * b11;\n t21 += v * b12;\n t22 += v * b13;\n t23 += v * b14;\n t24 += v * b15;\n v = a[10];\n t10 += v * b0;\n t11 += v * b1;\n t12 += v * b2;\n t13 += v * b3;\n t14 += v * b4;\n t15 += v * b5;\n t16 += v * b6;\n t17 += v * b7;\n t18 += v * b8;\n t19 += v * b9;\n t20 += v * b10;\n t21 += v * b11;\n t22 += v * b12;\n t23 += v * b13;\n t24 += v * b14;\n t25 += v * b15;\n v = a[11];\n t11 += v * b0;\n t12 += v * b1;\n t13 += v * b2;\n t14 += v * b3;\n t15 += v * b4;\n t16 += v * b5;\n t17 += v * b6;\n t18 += v * b7;\n t19 += v * b8;\n t20 += v * b9;\n t21 += v * b10;\n t22 += v * b11;\n t23 += v * b12;\n t24 += v * b13;\n t25 += v * b14;\n t26 += v * b15;\n v = a[12];\n t12 += v * b0;\n t13 += v * b1;\n t14 += v * b2;\n t15 += v * b3;\n t16 += v * b4;\n t17 += v * b5;\n t18 += v * b6;\n t19 += v * b7;\n t20 += v * b8;\n t21 += v * b9;\n t22 += v * b10;\n t23 += v * b11;\n t24 += v * b12;\n t25 += v * b13;\n t26 += v * b14;\n t27 += v * b15;\n v = a[13];\n t13 += v * b0;\n t14 += v * b1;\n t15 += v * b2;\n t16 += v * b3;\n t17 += v * b4;\n t18 += v * b5;\n t19 += v * b6;\n t20 += v * b7;\n t21 += v * b8;\n t22 += v * b9;\n t23 += v * b10;\n t24 += v * b11;\n t25 += v * b12;\n t26 += v * b13;\n t27 += v * b14;\n t28 += v * b15;\n v = a[14];\n t14 += v * b0;\n t15 += v * b1;\n t16 += v * b2;\n t17 += v * b3;\n t18 += v * b4;\n t19 += v * b5;\n t20 += v * b6;\n t21 += v * b7;\n t22 += v * b8;\n t23 += v * b9;\n t24 += v * b10;\n t25 += v * b11;\n t26 += v * b12;\n t27 += v * b13;\n t28 += v * b14;\n t29 += v * b15;\n v = a[15];\n t15 += v * b0;\n t16 += v * b1;\n t17 += v * b2;\n t18 += v * b3;\n t19 += v * b4;\n t20 += v * b5;\n t21 += v * b6;\n t22 += v * b7;\n t23 += v * b8;\n t24 += v * b9;\n t25 += v * b10;\n t26 += v * b11;\n t27 += v * b12;\n t28 += v * b13;\n t29 += v * b14;\n t30 += v * b15;\n\n t0 += 38 * t16;\n t1 += 38 * t17;\n t2 += 38 * t18;\n t3 += 38 * t19;\n t4 += 38 * t20;\n t5 += 38 * t21;\n t6 += 38 * t22;\n t7 += 38 * t23;\n t8 += 38 * t24;\n t9 += 38 * t25;\n t10 += 38 * t26;\n t11 += 38 * t27;\n t12 += 38 * t28;\n t13 += 38 * t29;\n t14 += 38 * t30;\n // t15 left as is\n\n // first car\n c = 1;\n v = t0 + c + 65535; c = Math.floor(v / 65536); t0 = v - c * 65536;\n v = t1 + c + 65535; c = Math.floor(v / 65536); t1 = v - c * 65536;\n v = t2 + c + 65535; c = Math.floor(v / 65536); t2 = v - c * 65536;\n v = t3 + c + 65535; c = Math.floor(v / 65536); t3 = v - c * 65536;\n v = t4 + c + 65535; c = Math.floor(v / 65536); t4 = v - c * 65536;\n v = t5 + c + 65535; c = Math.floor(v / 65536); t5 = v - c * 65536;\n v = t6 + c + 65535; c = Math.floor(v / 65536); t6 = v - c * 65536;\n v = t7 + c + 65535; c = Math.floor(v / 65536); t7 = v - c * 65536;\n v = t8 + c + 65535; c = Math.floor(v / 65536); t8 = v - c * 65536;\n v = t9 + c + 65535; c = Math.floor(v / 65536); t9 = v - c * 65536;\n v = t10 + c + 65535; c = Math.floor(v / 65536); t10 = v - c * 65536;\n v = t11 + c + 65535; c = Math.floor(v / 65536); t11 = v - c * 65536;\n v = t12 + c + 65535; c = Math.floor(v / 65536); t12 = v - c * 65536;\n v = t13 + c + 65535; c = Math.floor(v / 65536); t13 = v - c * 65536;\n v = t14 + c + 65535; c = Math.floor(v / 65536); t14 = v - c * 65536;\n v = t15 + c + 65535; c = Math.floor(v / 65536); t15 = v - c * 65536;\n t0 += c-1 + 37 * (c-1);\n\n // second car\n c = 1;\n v = t0 + c + 65535; c = Math.floor(v / 65536); t0 = v - c * 65536;\n v = t1 + c + 65535; c = Math.floor(v / 65536); t1 = v - c * 65536;\n v = t2 + c + 65535; c = Math.floor(v / 65536); t2 = v - c * 65536;\n v = t3 + c + 65535; c = Math.floor(v / 65536); t3 = v - c * 65536;\n v = t4 + c + 65535; c = Math.floor(v / 65536); t4 = v - c * 65536;\n v = t5 + c + 65535; c = Math.floor(v / 65536); t5 = v - c * 65536;\n v = t6 + c + 65535; c = Math.floor(v / 65536); t6 = v - c * 65536;\n v = t7 + c + 65535; c = Math.floor(v / 65536); t7 = v - c * 65536;\n v = t8 + c + 65535; c = Math.floor(v / 65536); t8 = v - c * 65536;\n v = t9 + c + 65535; c = Math.floor(v / 65536); t9 = v - c * 65536;\n v = t10 + c + 65535; c = Math.floor(v / 65536); t10 = v - c * 65536;\n v = t11 + c + 65535; c = Math.floor(v / 65536); t11 = v - c * 65536;\n v = t12 + c + 65535; c = Math.floor(v / 65536); t12 = v - c * 65536;\n v = t13 + c + 65535; c = Math.floor(v / 65536); t13 = v - c * 65536;\n v = t14 + c + 65535; c = Math.floor(v / 65536); t14 = v - c * 65536;\n v = t15 + c + 65535; c = Math.floor(v / 65536); t15 = v - c * 65536;\n t0 += c-1 + 37 * (c-1);\n\n o[ 0] = t0;\n o[ 1] = t1;\n o[ 2] = t2;\n o[ 3] = t3;\n o[ 4] = t4;\n o[ 5] = t5;\n o[ 6] = t6;\n o[ 7] = t7;\n o[ 8] = t8;\n o[ 9] = t9;\n o[10] = t10;\n o[11] = t11;\n o[12] = t12;\n o[13] = t13;\n o[14] = t14;\n o[15] = t15;\n}\n\nfunction S(o, a) {\n M(o, a, a);\n}\n\nfunction inv25519(o, i) {\n var c = gf();\n var a;\n for (a = 0; a < 16; a++) c[a] = i[a];\n for (a = 253; a >= 0; a--) {\n S(c, c);\n if(a !== 2 && a !== 4) M(c, c, i);\n }\n for (a = 0; a < 16; a++) o[a] = c[a];\n}\n\nfunction pow2523(o, i) {\n var c = gf();\n var a;\n for (a = 0; a < 16; a++) c[a] = i[a];\n for (a = 250; a >= 0; a--) {\n S(c, c);\n if(a !== 1) M(c, c, i);\n }\n for (a = 0; a < 16; a++) o[a] = c[a];\n}\n\nfunction crypto_scalarmult(q, n, p) {\n var z = new Uint8Array(32);\n var x = new Float64Array(80), r, i;\n var a = gf(), b = gf(), c = gf(),\n d = gf(), e = gf(), f = gf();\n for (i = 0; i < 31; i++) z[i] = n[i];\n z[31]=(n[31]&127)|64;\n z[0]&=248;\n unpack25519(x,p);\n for (i = 0; i < 16; i++) {\n b[i]=x[i];\n d[i]=a[i]=c[i]=0;\n }\n a[0]=d[0]=1;\n for (i=254; i>=0; --i) {\n r=(z[i>>>3]>>>(i&7))&1;\n sel25519(a,b,r);\n sel25519(c,d,r);\n A(e,a,c);\n Z(a,a,c);\n A(c,b,d);\n Z(b,b,d);\n S(d,e);\n S(f,a);\n M(a,c,a);\n M(c,b,e);\n A(e,a,c);\n Z(a,a,c);\n S(b,a);\n Z(c,d,f);\n M(a,c,_121665);\n A(a,a,d);\n M(c,c,a);\n M(a,d,f);\n M(d,b,x);\n S(b,e);\n sel25519(a,b,r);\n sel25519(c,d,r);\n }\n for (i = 0; i < 16; i++) {\n x[i+16]=a[i];\n x[i+32]=c[i];\n x[i+48]=b[i];\n x[i+64]=d[i];\n }\n var x32 = x.subarray(32);\n var x16 = x.subarray(16);\n inv25519(x32,x32);\n M(x16,x16,x32);\n pack25519(q,x16);\n return 0;\n}\n\nfunction crypto_scalarmult_base(q, n) {\n return crypto_scalarmult(q, n, _9);\n}\n\nfunction crypto_box_keypair(y, x) {\n randombytes(x, 32);\n return crypto_scalarmult_base(y, x);\n}\n\nfunction crypto_box_beforenm(k, y, x) {\n var s = new Uint8Array(32);\n crypto_scalarmult(s, x, y);\n return crypto_core_hsalsa20(k, _0, s, sigma);\n}\n\nvar crypto_box_afternm = crypto_secretbox;\nvar crypto_box_open_afternm = crypto_secretbox_open;\n\nfunction crypto_box(c, m, d, n, y, x) {\n var k = new Uint8Array(32);\n crypto_box_beforenm(k, y, x);\n return crypto_box_afternm(c, m, d, n, k);\n}\n\nfunction crypto_box_open(m, c, d, n, y, x) {\n var k = new Uint8Array(32);\n crypto_box_beforenm(k, y, x);\n return crypto_box_open_afternm(m, c, d, n, k);\n}\n\nvar K = [\n 0x428a2f98, 0xd728ae22, 0x71374491, 0x23ef65cd,\n 0xb5c0fbcf, 0xec4d3b2f, 0xe9b5dba5, 0x8189dbbc,\n 0x3956c25b, 0xf348b538, 0x59f111f1, 0xb605d019,\n 0x923f82a4, 0xaf194f9b, 0xab1c5ed5, 0xda6d8118,\n 0xd807aa98, 0xa3030242, 0x12835b01, 0x45706fbe,\n 0x243185be, 0x4ee4b28c, 0x550c7dc3, 0xd5ffb4e2,\n 0x72be5d74, 0xf27b896f, 0x80deb1fe, 0x3b1696b1,\n 0x9bdc06a7, 0x25c71235, 0xc19bf174, 0xcf692694,\n 0xe49b69c1, 0x9ef14ad2, 0xefbe4786, 0x384f25e3,\n 0x0fc19dc6, 0x8b8cd5b5, 0x240ca1cc, 0x77ac9c65,\n 0x2de92c6f, 0x592b0275, 0x4a7484aa, 0x6ea6e483,\n 0x5cb0a9dc, 0xbd41fbd4, 0x76f988da, 0x831153b5,\n 0x983e5152, 0xee66dfab, 0xa831c66d, 0x2db43210,\n 0xb00327c8, 0x98fb213f, 0xbf597fc7, 0xbeef0ee4,\n 0xc6e00bf3, 0x3da88fc2, 0xd5a79147, 0x930aa725,\n 0x06ca6351, 0xe003826f, 0x14292967, 0x0a0e6e70,\n 0x27b70a85, 0x46d22ffc, 0x2e1b2138, 0x5c26c926,\n 0x4d2c6dfc, 0x5ac42aed, 0x53380d13, 0x9d95b3df,\n 0x650a7354, 0x8baf63de, 0x766a0abb, 0x3c77b2a8,\n 0x81c2c92e, 0x47edaee6, 0x92722c85, 0x1482353b,\n 0xa2bfe8a1, 0x4cf10364, 0xa81a664b, 0xbc423001,\n 0xc24b8b70, 0xd0f89791, 0xc76c51a3, 0x0654be30,\n 0xd192e819, 0xd6ef5218, 0xd6990624, 0x5565a910,\n 0xf40e3585, 0x5771202a, 0x106aa070, 0x32bbd1b8,\n 0x19a4c116, 0xb8d2d0c8, 0x1e376c08, 0x5141ab53,\n 0x2748774c, 0xdf8eeb99, 0x34b0bcb5, 0xe19b48a8,\n 0x391c0cb3, 0xc5c95a63, 0x4ed8aa4a, 0xe3418acb,\n 0x5b9cca4f, 0x7763e373, 0x682e6ff3, 0xd6b2b8a3,\n 0x748f82ee, 0x5defb2fc, 0x78a5636f, 0x43172f60,\n 0x84c87814, 0xa1f0ab72, 0x8cc70208, 0x1a6439ec,\n 0x90befffa, 0x23631e28, 0xa4506ceb, 0xde82bde9,\n 0xbef9a3f7, 0xb2c67915, 0xc67178f2, 0xe372532b,\n 0xca273ece, 0xea26619c, 0xd186b8c7, 0x21c0c207,\n 0xeada7dd6, 0xcde0eb1e, 0xf57d4f7f, 0xee6ed178,\n 0x06f067aa, 0x72176fba, 0x0a637dc5, 0xa2c898a6,\n 0x113f9804, 0xbef90dae, 0x1b710b35, 0x131c471b,\n 0x28db77f5, 0x23047d84, 0x32caab7b, 0x40c72493,\n 0x3c9ebe0a, 0x15c9bebc, 0x431d67c4, 0x9c100d4c,\n 0x4cc5d4be, 0xcb3e42b6, 0x597f299c, 0xfc657e2a,\n 0x5fcb6fab, 0x3ad6faec, 0x6c44198c, 0x4a475817\n];\n\nfunction crypto_hashblocks_hl(hh, hl, m, n) {\n var wh = new Int32Array(16), wl = new Int32Array(16),\n bh0, bh1, bh2, bh3, bh4, bh5, bh6, bh7,\n bl0, bl1, bl2, bl3, bl4, bl5, bl6, bl7,\n th, tl, i, j, h, l, a, b, c, d;\n\n var ah0 = hh[0],\n ah1 = hh[1],\n ah2 = hh[2],\n ah3 = hh[3],\n ah4 = hh[4],\n ah5 = hh[5],\n ah6 = hh[6],\n ah7 = hh[7],\n\n al0 = hl[0],\n al1 = hl[1],\n al2 = hl[2],\n al3 = hl[3],\n al4 = hl[4],\n al5 = hl[5],\n al6 = hl[6],\n al7 = hl[7];\n\n var pos = 0;\n while (n >= 128) {\n for (i = 0; i < 16; i++) {\n j = 8 * i + pos;\n wh[i] = (m[j+0] << 24) | (m[j+1] << 16) | (m[j+2] << 8) | m[j+3];\n wl[i] = (m[j+4] << 24) | (m[j+5] << 16) | (m[j+6] << 8) | m[j+7];\n }\n for (i = 0; i < 80; i++) {\n bh0 = ah0;\n bh1 = ah1;\n bh2 = ah2;\n bh3 = ah3;\n bh4 = ah4;\n bh5 = ah5;\n bh6 = ah6;\n bh7 = ah7;\n\n bl0 = al0;\n bl1 = al1;\n bl2 = al2;\n bl3 = al3;\n bl4 = al4;\n bl5 = al5;\n bl6 = al6;\n bl7 = al7;\n\n // add\n h = ah7;\n l = al7;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n // Sigma1\n h = ((ah4 >>> 14) | (al4 << (32-14))) ^ ((ah4 >>> 18) | (al4 << (32-18))) ^ ((al4 >>> (41-32)) | (ah4 << (32-(41-32))));\n l = ((al4 >>> 14) | (ah4 << (32-14))) ^ ((al4 >>> 18) | (ah4 << (32-18))) ^ ((ah4 >>> (41-32)) | (al4 << (32-(41-32))));\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // Ch\n h = (ah4 & ah5) ^ (~ah4 & ah6);\n l = (al4 & al5) ^ (~al4 & al6);\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // K\n h = K[i*2];\n l = K[i*2+1];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // w\n h = wh[i%16];\n l = wl[i%16];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n th = c & 0xffff | d << 16;\n tl = a & 0xffff | b << 16;\n\n // add\n h = th;\n l = tl;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n // Sigma0\n h = ((ah0 >>> 28) | (al0 << (32-28))) ^ ((al0 >>> (34-32)) | (ah0 << (32-(34-32)))) ^ ((al0 >>> (39-32)) | (ah0 << (32-(39-32))));\n l = ((al0 >>> 28) | (ah0 << (32-28))) ^ ((ah0 >>> (34-32)) | (al0 << (32-(34-32)))) ^ ((ah0 >>> (39-32)) | (al0 << (32-(39-32))));\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // Maj\n h = (ah0 & ah1) ^ (ah0 & ah2) ^ (ah1 & ah2);\n l = (al0 & al1) ^ (al0 & al2) ^ (al1 & al2);\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n bh7 = (c & 0xffff) | (d << 16);\n bl7 = (a & 0xffff) | (b << 16);\n\n // add\n h = bh3;\n l = bl3;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = th;\n l = tl;\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n bh3 = (c & 0xffff) | (d << 16);\n bl3 = (a & 0xffff) | (b << 16);\n\n ah1 = bh0;\n ah2 = bh1;\n ah3 = bh2;\n ah4 = bh3;\n ah5 = bh4;\n ah6 = bh5;\n ah7 = bh6;\n ah0 = bh7;\n\n al1 = bl0;\n al2 = bl1;\n al3 = bl2;\n al4 = bl3;\n al5 = bl4;\n al6 = bl5;\n al7 = bl6;\n al0 = bl7;\n\n if (i%16 === 15) {\n for (j = 0; j < 16; j++) {\n // add\n h = wh[j];\n l = wl[j];\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = wh[(j+9)%16];\n l = wl[(j+9)%16];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // sigma0\n th = wh[(j+1)%16];\n tl = wl[(j+1)%16];\n h = ((th >>> 1) | (tl << (32-1))) ^ ((th >>> 8) | (tl << (32-8))) ^ (th >>> 7);\n l = ((tl >>> 1) | (th << (32-1))) ^ ((tl >>> 8) | (th << (32-8))) ^ ((tl >>> 7) | (th << (32-7)));\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // sigma1\n th = wh[(j+14)%16];\n tl = wl[(j+14)%16];\n h = ((th >>> 19) | (tl << (32-19))) ^ ((tl >>> (61-32)) | (th << (32-(61-32)))) ^ (th >>> 6);\n l = ((tl >>> 19) | (th << (32-19))) ^ ((th >>> (61-32)) | (tl << (32-(61-32)))) ^ ((tl >>> 6) | (th << (32-6)));\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n wh[j] = (c & 0xffff) | (d << 16);\n wl[j] = (a & 0xffff) | (b << 16);\n }\n }\n }\n\n // add\n h = ah0;\n l = al0;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[0];\n l = hl[0];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[0] = ah0 = (c & 0xffff) | (d << 16);\n hl[0] = al0 = (a & 0xffff) | (b << 16);\n\n h = ah1;\n l = al1;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[1];\n l = hl[1];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[1] = ah1 = (c & 0xffff) | (d << 16);\n hl[1] = al1 = (a & 0xffff) | (b << 16);\n\n h = ah2;\n l = al2;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[2];\n l = hl[2];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[2] = ah2 = (c & 0xffff) | (d << 16);\n hl[2] = al2 = (a & 0xffff) | (b << 16);\n\n h = ah3;\n l = al3;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[3];\n l = hl[3];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[3] = ah3 = (c & 0xffff) | (d << 16);\n hl[3] = al3 = (a & 0xffff) | (b << 16);\n\n h = ah4;\n l = al4;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[4];\n l = hl[4];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[4] = ah4 = (c & 0xffff) | (d << 16);\n hl[4] = al4 = (a & 0xffff) | (b << 16);\n\n h = ah5;\n l = al5;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[5];\n l = hl[5];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[5] = ah5 = (c & 0xffff) | (d << 16);\n hl[5] = al5 = (a & 0xffff) | (b << 16);\n\n h = ah6;\n l = al6;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[6];\n l = hl[6];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[6] = ah6 = (c & 0xffff) | (d << 16);\n hl[6] = al6 = (a & 0xffff) | (b << 16);\n\n h = ah7;\n l = al7;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[7];\n l = hl[7];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[7] = ah7 = (c & 0xffff) | (d << 16);\n hl[7] = al7 = (a & 0xffff) | (b << 16);\n\n pos += 128;\n n -= 128;\n }\n\n return n;\n}\n\nfunction crypto_hash(out, m, n) {\n var hh = new Int32Array(8),\n hl = new Int32Array(8),\n x = new Uint8Array(256),\n i, b = n;\n\n hh[0] = 0x6a09e667;\n hh[1] = 0xbb67ae85;\n hh[2] = 0x3c6ef372;\n hh[3] = 0xa54ff53a;\n hh[4] = 0x510e527f;\n hh[5] = 0x9b05688c;\n hh[6] = 0x1f83d9ab;\n hh[7] = 0x5be0cd19;\n\n hl[0] = 0xf3bcc908;\n hl[1] = 0x84caa73b;\n hl[2] = 0xfe94f82b;\n hl[3] = 0x5f1d36f1;\n hl[4] = 0xade682d1;\n hl[5] = 0x2b3e6c1f;\n hl[6] = 0xfb41bd6b;\n hl[7] = 0x137e2179;\n\n crypto_hashblocks_hl(hh, hl, m, n);\n n %= 128;\n\n for (i = 0; i < n; i++) x[i] = m[b-n+i];\n x[n] = 128;\n\n n = 256-128*(n<112?1:0);\n x[n-9] = 0;\n ts64(x, n-8, (b / 0x20000000) | 0, b << 3);\n crypto_hashblocks_hl(hh, hl, x, n);\n\n for (i = 0; i < 8; i++) ts64(out, 8*i, hh[i], hl[i]);\n\n return 0;\n}\n\nfunction add(p, q) {\n var a = gf(), b = gf(), c = gf(),\n d = gf(), e = gf(), f = gf(),\n g = gf(), h = gf(), t = gf();\n\n Z(a, p[1], p[0]);\n Z(t, q[1], q[0]);\n M(a, a, t);\n A(b, p[0], p[1]);\n A(t, q[0], q[1]);\n M(b, b, t);\n M(c, p[3], q[3]);\n M(c, c, D2);\n M(d, p[2], q[2]);\n A(d, d, d);\n Z(e, b, a);\n Z(f, d, c);\n A(g, d, c);\n A(h, b, a);\n\n M(p[0], e, f);\n M(p[1], h, g);\n M(p[2], g, f);\n M(p[3], e, h);\n}\n\nfunction cswap(p, q, b) {\n var i;\n for (i = 0; i < 4; i++) {\n sel25519(p[i], q[i], b);\n }\n}\n\nfunction pack(r, p) {\n var tx = gf(), ty = gf(), zi = gf();\n inv25519(zi, p[2]);\n M(tx, p[0], zi);\n M(ty, p[1], zi);\n pack25519(r, ty);\n r[31] ^= par25519(tx) << 7;\n}\n\nfunction scalarmult(p, q, s) {\n var b, i;\n set25519(p[0], gf0);\n set25519(p[1], gf1);\n set25519(p[2], gf1);\n set25519(p[3], gf0);\n for (i = 255; i >= 0; --i) {\n b = (s[(i/8)|0] >> (i&7)) & 1;\n cswap(p, q, b);\n add(q, p);\n add(p, p);\n cswap(p, q, b);\n }\n}\n\nfunction scalarbase(p, s) {\n var q = [gf(), gf(), gf(), gf()];\n set25519(q[0], X);\n set25519(q[1], Y);\n set25519(q[2], gf1);\n M(q[3], X, Y);\n scalarmult(p, q, s);\n}\n\nfunction crypto_sign_keypair(pk, sk, seeded) {\n var d = new Uint8Array(64);\n var p = [gf(), gf(), gf(), gf()];\n var i;\n\n if (!seeded) randombytes(sk, 32);\n crypto_hash(d, sk, 32);\n d[0] &= 248;\n d[31] &= 127;\n d[31] |= 64;\n\n scalarbase(p, d);\n pack(pk, p);\n\n for (i = 0; i < 32; i++) sk[i+32] = pk[i];\n return 0;\n}\n\nvar L = new Float64Array([0xed, 0xd3, 0xf5, 0x5c, 0x1a, 0x63, 0x12, 0x58, 0xd6, 0x9c, 0xf7, 0xa2, 0xde, 0xf9, 0xde, 0x14, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x10]);\n\nfunction modL(r, x) {\n var carry, i, j, k;\n for (i = 63; i >= 32; --i) {\n carry = 0;\n for (j = i - 32, k = i - 12; j < k; ++j) {\n x[j] += carry - 16 * x[i] * L[j - (i - 32)];\n carry = Math.floor((x[j] + 128) / 256);\n x[j] -= carry * 256;\n }\n x[j] += carry;\n x[i] = 0;\n }\n carry = 0;\n for (j = 0; j < 32; j++) {\n x[j] += carry - (x[31] >> 4) * L[j];\n carry = x[j] >> 8;\n x[j] &= 255;\n }\n for (j = 0; j < 32; j++) x[j] -= carry * L[j];\n for (i = 0; i < 32; i++) {\n x[i+1] += x[i] >> 8;\n r[i] = x[i] & 255;\n }\n}\n\nfunction reduce(r) {\n var x = new Float64Array(64), i;\n for (i = 0; i < 64; i++) x[i] = r[i];\n for (i = 0; i < 64; i++) r[i] = 0;\n modL(r, x);\n}\n\n// Note: difference from C - smlen returned, not passed as argument.\nfunction crypto_sign(sm, m, n, sk) {\n var d = new Uint8Array(64), h = new Uint8Array(64), r = new Uint8Array(64);\n var i, j, x = new Float64Array(64);\n var p = [gf(), gf(), gf(), gf()];\n\n crypto_hash(d, sk, 32);\n d[0] &= 248;\n d[31] &= 127;\n d[31] |= 64;\n\n var smlen = n + 64;\n for (i = 0; i < n; i++) sm[64 + i] = m[i];\n for (i = 0; i < 32; i++) sm[32 + i] = d[32 + i];\n\n crypto_hash(r, sm.subarray(32), n+32);\n reduce(r);\n scalarbase(p, r);\n pack(sm, p);\n\n for (i = 32; i < 64; i++) sm[i] = sk[i];\n crypto_hash(h, sm, n + 64);\n reduce(h);\n\n for (i = 0; i < 64; i++) x[i] = 0;\n for (i = 0; i < 32; i++) x[i] = r[i];\n for (i = 0; i < 32; i++) {\n for (j = 0; j < 32; j++) {\n x[i+j] += h[i] * d[j];\n }\n }\n\n modL(sm.subarray(32), x);\n return smlen;\n}\n\nfunction unpackneg(r, p) {\n var t = gf(), chk = gf(), num = gf(),\n den = gf(), den2 = gf(), den4 = gf(),\n den6 = gf();\n\n set25519(r[2], gf1);\n unpack25519(r[1], p);\n S(num, r[1]);\n M(den, num, D);\n Z(num, num, r[2]);\n A(den, r[2], den);\n\n S(den2, den);\n S(den4, den2);\n M(den6, den4, den2);\n M(t, den6, num);\n M(t, t, den);\n\n pow2523(t, t);\n M(t, t, num);\n M(t, t, den);\n M(t, t, den);\n M(r[0], t, den);\n\n S(chk, r[0]);\n M(chk, chk, den);\n if (neq25519(chk, num)) M(r[0], r[0], I);\n\n S(chk, r[0]);\n M(chk, chk, den);\n if (neq25519(chk, num)) return -1;\n\n if (par25519(r[0]) === (p[31]>>7)) Z(r[0], gf0, r[0]);\n\n M(r[3], r[0], r[1]);\n return 0;\n}\n\nfunction crypto_sign_open(m, sm, n, pk) {\n var i;\n var t = new Uint8Array(32), h = new Uint8Array(64);\n var p = [gf(), gf(), gf(), gf()],\n q = [gf(), gf(), gf(), gf()];\n\n if (n < 64) return -1;\n\n if (unpackneg(q, pk)) return -1;\n\n for (i = 0; i < n; i++) m[i] = sm[i];\n for (i = 0; i < 32; i++) m[i+32] = pk[i];\n crypto_hash(h, m, n);\n reduce(h);\n scalarmult(p, q, h);\n\n scalarbase(q, sm.subarray(32));\n add(p, q);\n pack(t, p);\n\n n -= 64;\n if (crypto_verify_32(sm, 0, t, 0)) {\n for (i = 0; i < n; i++) m[i] = 0;\n return -1;\n }\n\n for (i = 0; i < n; i++) m[i] = sm[i + 64];\n return n;\n}\n\nvar crypto_secretbox_KEYBYTES = 32,\n crypto_secretbox_NONCEBYTES = 24,\n crypto_secretbox_ZEROBYTES = 32,\n crypto_secretbox_BOXZEROBYTES = 16,\n crypto_scalarmult_BYTES = 32,\n crypto_scalarmult_SCALARBYTES = 32,\n crypto_box_PUBLICKEYBYTES = 32,\n crypto_box_SECRETKEYBYTES = 32,\n crypto_box_BEFORENMBYTES = 32,\n crypto_box_NONCEBYTES = crypto_secretbox_NONCEBYTES,\n crypto_box_ZEROBYTES = crypto_secretbox_ZEROBYTES,\n crypto_box_BOXZEROBYTES = crypto_secretbox_BOXZEROBYTES,\n crypto_sign_BYTES = 64,\n crypto_sign_PUBLICKEYBYTES = 32,\n crypto_sign_SECRETKEYBYTES = 64,\n crypto_sign_SEEDBYTES = 32,\n crypto_hash_BYTES = 64;\n\nnacl.lowlevel = {\n crypto_core_hsalsa20: crypto_core_hsalsa20,\n crypto_stream_xor: crypto_stream_xor,\n crypto_stream: crypto_stream,\n crypto_stream_salsa20_xor: crypto_stream_salsa20_xor,\n crypto_stream_salsa20: crypto_stream_salsa20,\n crypto_onetimeauth: crypto_onetimeauth,\n crypto_onetimeauth_verify: crypto_onetimeauth_verify,\n crypto_verify_16: crypto_verify_16,\n crypto_verify_32: crypto_verify_32,\n crypto_secretbox: crypto_secretbox,\n crypto_secretbox_open: crypto_secretbox_open,\n crypto_scalarmult: crypto_scalarmult,\n crypto_scalarmult_base: crypto_scalarmult_base,\n crypto_box_beforenm: crypto_box_beforenm,\n crypto_box_afternm: crypto_box_afternm,\n crypto_box: crypto_box,\n crypto_box_open: crypto_box_open,\n crypto_box_keypair: crypto_box_keypair,\n crypto_hash: crypto_hash,\n crypto_sign: crypto_sign,\n crypto_sign_keypair: crypto_sign_keypair,\n crypto_sign_open: crypto_sign_open,\n\n crypto_secretbox_KEYBYTES: crypto_secretbox_KEYBYTES,\n crypto_secretbox_NONCEBYTES: crypto_secretbox_NONCEBYTES,\n crypto_secretbox_ZEROBYTES: crypto_secretbox_ZEROBYTES,\n crypto_secretbox_BOXZEROBYTES: crypto_secretbox_BOXZEROBYTES,\n crypto_scalarmult_BYTES: crypto_scalarmult_BYTES,\n crypto_scalarmult_SCALARBYTES: crypto_scalarmult_SCALARBYTES,\n crypto_box_PUBLICKEYBYTES: crypto_box_PUBLICKEYBYTES,\n crypto_box_SECRETKEYBYTES: crypto_box_SECRETKEYBYTES,\n crypto_box_BEFORENMBYTES: crypto_box_BEFORENMBYTES,\n crypto_box_NONCEBYTES: crypto_box_NONCEBYTES,\n crypto_box_ZEROBYTES: crypto_box_ZEROBYTES,\n crypto_box_BOXZEROBYTES: crypto_box_BOXZEROBYTES,\n crypto_sign_BYTES: crypto_sign_BYTES,\n crypto_sign_PUBLICKEYBYTES: crypto_sign_PUBLICKEYBYTES,\n crypto_sign_SECRETKEYBYTES: crypto_sign_SECRETKEYBYTES,\n crypto_sign_SEEDBYTES: crypto_sign_SEEDBYTES,\n crypto_hash_BYTES: crypto_hash_BYTES,\n\n gf: gf,\n D: D,\n L: L,\n pack25519: pack25519,\n unpack25519: unpack25519,\n M: M,\n A: A,\n S: S,\n Z: Z,\n pow2523: pow2523,\n add: add,\n set25519: set25519,\n modL: modL,\n scalarmult: scalarmult,\n scalarbase: scalarbase,\n};\n\n/* High-level API */\n\nfunction checkLengths(k, n) {\n if (k.length !== crypto_secretbox_KEYBYTES) throw new Error('bad key size');\n if (n.length !== crypto_secretbox_NONCEBYTES) throw new Error('bad nonce size');\n}\n\nfunction checkBoxLengths(pk, sk) {\n if (pk.length !== crypto_box_PUBLICKEYBYTES) throw new Error('bad public key size');\n if (sk.length !== crypto_box_SECRETKEYBYTES) throw new Error('bad secret key size');\n}\n\nfunction checkArrayTypes() {\n for (var i = 0; i < arguments.length; i++) {\n if (!(arguments[i] instanceof Uint8Array))\n throw new TypeError('unexpected type, use Uint8Array');\n }\n}\n\nfunction cleanup(arr) {\n for (var i = 0; i < arr.length; i++) arr[i] = 0;\n}\n\nnacl.randomBytes = function(n) {\n var b = new Uint8Array(n);\n randombytes(b, n);\n return b;\n};\n\nnacl.secretbox = function(msg, nonce, key) {\n checkArrayTypes(msg, nonce, key);\n checkLengths(key, nonce);\n var m = new Uint8Array(crypto_secretbox_ZEROBYTES + msg.length);\n var c = new Uint8Array(m.length);\n for (var i = 0; i < msg.length; i++) m[i+crypto_secretbox_ZEROBYTES] = msg[i];\n crypto_secretbox(c, m, m.length, nonce, key);\n return c.subarray(crypto_secretbox_BOXZEROBYTES);\n};\n\nnacl.secretbox.open = function(box, nonce, key) {\n checkArrayTypes(box, nonce, key);\n checkLengths(key, nonce);\n var c = new Uint8Array(crypto_secretbox_BOXZEROBYTES + box.length);\n var m = new Uint8Array(c.length);\n for (var i = 0; i < box.length; i++) c[i+crypto_secretbox_BOXZEROBYTES] = box[i];\n if (c.length < 32) return null;\n if (crypto_secretbox_open(m, c, c.length, nonce, key) !== 0) return null;\n return m.subarray(crypto_secretbox_ZEROBYTES);\n};\n\nnacl.secretbox.keyLength = crypto_secretbox_KEYBYTES;\nnacl.secretbox.nonceLength = crypto_secretbox_NONCEBYTES;\nnacl.secretbox.overheadLength = crypto_secretbox_BOXZEROBYTES;\n\nnacl.scalarMult = function(n, p) {\n checkArrayTypes(n, p);\n if (n.length !== crypto_scalarmult_SCALARBYTES) throw new Error('bad n size');\n if (p.length !== crypto_scalarmult_BYTES) throw new Error('bad p size');\n var q = new Uint8Array(crypto_scalarmult_BYTES);\n crypto_scalarmult(q, n, p);\n return q;\n};\n\nnacl.scalarMult.base = function(n) {\n checkArrayTypes(n);\n if (n.length !== crypto_scalarmult_SCALARBYTES) throw new Error('bad n size');\n var q = new Uint8Array(crypto_scalarmult_BYTES);\n crypto_scalarmult_base(q, n);\n return q;\n};\n\nnacl.scalarMult.scalarLength = crypto_scalarmult_SCALARBYTES;\nnacl.scalarMult.groupElementLength = crypto_scalarmult_BYTES;\n\nnacl.box = function(msg, nonce, publicKey, secretKey) {\n var k = nacl.box.before(publicKey, secretKey);\n return nacl.secretbox(msg, nonce, k);\n};\n\nnacl.box.before = function(publicKey, secretKey) {\n checkArrayTypes(publicKey, secretKey);\n checkBoxLengths(publicKey, secretKey);\n var k = new Uint8Array(crypto_box_BEFORENMBYTES);\n crypto_box_beforenm(k, publicKey, secretKey);\n return k;\n};\n\nnacl.box.after = nacl.secretbox;\n\nnacl.box.open = function(msg, nonce, publicKey, secretKey) {\n var k = nacl.box.before(publicKey, secretKey);\n return nacl.secretbox.open(msg, nonce, k);\n};\n\nnacl.box.open.after = nacl.secretbox.open;\n\nnacl.box.keyPair = function() {\n var pk = new Uint8Array(crypto_box_PUBLICKEYBYTES);\n var sk = new Uint8Array(crypto_box_SECRETKEYBYTES);\n crypto_box_keypair(pk, sk);\n return {publicKey: pk, secretKey: sk};\n};\n\nnacl.box.keyPair.fromSecretKey = function(secretKey) {\n checkArrayTypes(secretKey);\n if (secretKey.length !== crypto_box_SECRETKEYBYTES)\n throw new Error('bad secret key size');\n var pk = new Uint8Array(crypto_box_PUBLICKEYBYTES);\n crypto_scalarmult_base(pk, secretKey);\n return {publicKey: pk, secretKey: new Uint8Array(secretKey)};\n};\n\nnacl.box.publicKeyLength = crypto_box_PUBLICKEYBYTES;\nnacl.box.secretKeyLength = crypto_box_SECRETKEYBYTES;\nnacl.box.sharedKeyLength = crypto_box_BEFORENMBYTES;\nnacl.box.nonceLength = crypto_box_NONCEBYTES;\nnacl.box.overheadLength = nacl.secretbox.overheadLength;\n\nnacl.sign = function(msg, secretKey) {\n checkArrayTypes(msg, secretKey);\n if (secretKey.length !== crypto_sign_SECRETKEYBYTES)\n throw new Error('bad secret key size');\n var signedMsg = new Uint8Array(crypto_sign_BYTES+msg.length);\n crypto_sign(signedMsg, msg, msg.length, secretKey);\n return signedMsg;\n};\n\nnacl.sign.open = function(signedMsg, publicKey) {\n checkArrayTypes(signedMsg, publicKey);\n if (publicKey.length !== crypto_sign_PUBLICKEYBYTES)\n throw new Error('bad public key size');\n var tmp = new Uint8Array(signedMsg.length);\n var mlen = crypto_sign_open(tmp, signedMsg, signedMsg.length, publicKey);\n if (mlen < 0) return null;\n var m = new Uint8Array(mlen);\n for (var i = 0; i < m.length; i++) m[i] = tmp[i];\n return m;\n};\n\nnacl.sign.detached = function(msg, secretKey) {\n var signedMsg = nacl.sign(msg, secretKey);\n var sig = new Uint8Array(crypto_sign_BYTES);\n for (var i = 0; i < sig.length; i++) sig[i] = signedMsg[i];\n return sig;\n};\n\nnacl.sign.detached.verify = function(msg, sig, publicKey) {\n checkArrayTypes(msg, sig, publicKey);\n if (sig.length !== crypto_sign_BYTES)\n throw new Error('bad signature size');\n if (publicKey.length !== crypto_sign_PUBLICKEYBYTES)\n throw new Error('bad public key size');\n var sm = new Uint8Array(crypto_sign_BYTES + msg.length);\n var m = new Uint8Array(crypto_sign_BYTES + msg.length);\n var i;\n for (i = 0; i < crypto_sign_BYTES; i++) sm[i] = sig[i];\n for (i = 0; i < msg.length; i++) sm[i+crypto_sign_BYTES] = msg[i];\n return (crypto_sign_open(m, sm, sm.length, publicKey) >= 0);\n};\n\nnacl.sign.keyPair = function() {\n var pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);\n var sk = new Uint8Array(crypto_sign_SECRETKEYBYTES);\n crypto_sign_keypair(pk, sk);\n return {publicKey: pk, secretKey: sk};\n};\n\nnacl.sign.keyPair.fromSecretKey = function(secretKey) {\n checkArrayTypes(secretKey);\n if (secretKey.length !== crypto_sign_SECRETKEYBYTES)\n throw new Error('bad secret key size');\n var pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);\n for (var i = 0; i < pk.length; i++) pk[i] = secretKey[32+i];\n return {publicKey: pk, secretKey: new Uint8Array(secretKey)};\n};\n\nnacl.sign.keyPair.fromSeed = function(seed) {\n checkArrayTypes(seed);\n if (seed.length !== crypto_sign_SEEDBYTES)\n throw new Error('bad seed size');\n var pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);\n var sk = new Uint8Array(crypto_sign_SECRETKEYBYTES);\n for (var i = 0; i < 32; i++) sk[i] = seed[i];\n crypto_sign_keypair(pk, sk, true);\n return {publicKey: pk, secretKey: sk};\n};\n\nnacl.sign.publicKeyLength = crypto_sign_PUBLICKEYBYTES;\nnacl.sign.secretKeyLength = crypto_sign_SECRETKEYBYTES;\nnacl.sign.seedLength = crypto_sign_SEEDBYTES;\nnacl.sign.signatureLength = crypto_sign_BYTES;\n\nnacl.hash = function(msg) {\n checkArrayTypes(msg);\n var h = new Uint8Array(crypto_hash_BYTES);\n crypto_hash(h, msg, msg.length);\n return h;\n};\n\nnacl.hash.hashLength = crypto_hash_BYTES;\n\nnacl.verify = function(x, y) {\n checkArrayTypes(x, y);\n // Zero length arguments are considered not equal.\n if (x.length === 0 || y.length === 0) return false;\n if (x.length !== y.length) return false;\n return (vn(x, 0, y, 0, x.length) === 0) ? true : false;\n};\n\nnacl.setPRNG = function(fn) {\n randombytes = fn;\n};\n\n(function() {\n // Initialize PRNG if environment provides CSPRNG.\n // If not, methods calling randombytes will throw.\n var crypto = typeof self !== 'undefined' ? (self.crypto || self.msCrypto) : null;\n if (crypto && crypto.getRandomValues) {\n // Browsers.\n var QUOTA = 65536;\n nacl.setPRNG(function(x, n) {\n var i, v = new Uint8Array(n);\n for (i = 0; i < n; i += QUOTA) {\n crypto.getRandomValues(v.subarray(i, i + Math.min(n - i, QUOTA)));\n }\n for (i = 0; i < n; i++) x[i] = v[i];\n cleanup(v);\n });\n } else if (typeof require !== 'undefined') {\n // Node.js.\n crypto = require('crypto');\n if (crypto && crypto.randomBytes) {\n nacl.setPRNG(function(x, n) {\n var i, v = crypto.randomBytes(n);\n for (i = 0; i < n; i++) x[i] = v[i];\n cleanup(v);\n });\n }\n }\n})();\n\n})(typeof module !== 'undefined' && module.exports ? module.exports : (self.nacl = self.nacl || {}));\n","module.exports = require('./pusher-with-encryption').default;\n","import ScriptReceiver from './script_receiver';\n\n/** Builds receivers for JSONP and Script requests.\n *\n * Each receiver is an object with following fields:\n * - number - unique (for the factory instance), numerical id of the receiver\n * - id - a string ID that can be used in DOM attributes\n * - name - name of the function triggering the receiver\n * - callback - callback function\n *\n * Receivers are triggered only once, on the first callback call.\n *\n * Receivers can be called by their name or by accessing factory object\n * by the number key.\n *\n * @param {String} prefix the prefix used in ids\n * @param {String} name the name of the object\n */\nexport class ScriptReceiverFactory {\n lastId: number;\n prefix: string;\n name: string;\n\n constructor(prefix: string, name: string) {\n this.lastId = 0;\n this.prefix = prefix;\n this.name = name;\n }\n\n create(callback: Function): ScriptReceiver {\n this.lastId++;\n\n var number = this.lastId;\n var id = this.prefix + number;\n var name = this.name + '[' + number + ']';\n\n var called = false;\n var callbackWrapper = function() {\n if (!called) {\n callback.apply(null, arguments);\n called = true;\n }\n };\n\n this[number] = callbackWrapper;\n return { number: number, id: id, name: name, callback: callbackWrapper };\n }\n\n remove(receiver: ScriptReceiver) {\n delete this[receiver.number];\n }\n}\n\nexport var ScriptReceivers = new ScriptReceiverFactory(\n '_pusher_script_',\n 'Pusher.ScriptReceivers'\n);\n","import {\n ChannelAuthorizationOptions,\n UserAuthenticationOptions\n} from './auth/options';\nimport { AuthTransport } from './config';\n\nexport interface DefaultConfig {\n VERSION: string;\n PROTOCOL: number;\n wsPort: number;\n wssPort: number;\n wsPath: string;\n httpHost: string;\n httpPort: number;\n httpsPort: number;\n httpPath: string;\n stats_host: string;\n authEndpoint: string;\n authTransport: AuthTransport;\n activityTimeout: number;\n pongTimeout: number;\n unavailableTimeout: number;\n userAuthentication: UserAuthenticationOptions;\n channelAuthorization: ChannelAuthorizationOptions;\n\n cdn_http?: string;\n cdn_https?: string;\n dependency_suffix?: string;\n}\n\nvar Defaults: DefaultConfig = {\n VERSION: VERSION,\n PROTOCOL: 7,\n\n wsPort: 80,\n wssPort: 443,\n wsPath: '',\n // DEPRECATED: SockJS fallback parameters\n httpHost: 'sockjs.pusher.com',\n httpPort: 80,\n httpsPort: 443,\n httpPath: '/pusher',\n // DEPRECATED: Stats\n stats_host: 'stats.pusher.com',\n // DEPRECATED: Other settings\n authEndpoint: '/pusher/auth',\n authTransport: 'ajax',\n activityTimeout: 120000,\n pongTimeout: 30000,\n unavailableTimeout: 10000,\n userAuthentication: {\n endpoint: '/pusher/user-auth',\n transport: 'ajax'\n },\n channelAuthorization: {\n endpoint: '/pusher/auth',\n transport: 'ajax'\n },\n\n // CDN configuration\n cdn_http: CDN_HTTP,\n cdn_https: CDN_HTTPS,\n dependency_suffix: DEPENDENCY_SUFFIX\n};\n\nexport default Defaults;\n","import { ScriptReceiverFactory } from './script_receiver_factory';\nimport Defaults from 'core/defaults';\nimport DependencyLoader from './dependency_loader';\n\nexport var DependenciesReceivers = new ScriptReceiverFactory(\n '_pusher_dependencies',\n 'Pusher.DependenciesReceivers'\n);\n\nexport var Dependencies = new DependencyLoader({\n cdn_http: Defaults.cdn_http,\n cdn_https: Defaults.cdn_https,\n version: Defaults.VERSION,\n suffix: Defaults.dependency_suffix,\n receivers: DependenciesReceivers\n});\n","import {\n ScriptReceivers,\n ScriptReceiverFactory\n} from './script_receiver_factory';\nimport Runtime from 'runtime';\nimport ScriptRequest from './script_request';\n\n/** Handles loading dependency files.\n *\n * Dependency loaders don't remember whether a resource has been loaded or\n * not. It is caller's responsibility to make sure the resource is not loaded\n * twice. This is because it's impossible to detect resource loading status\n * without knowing its content.\n *\n * Options:\n * - cdn_http - url to HTTP CND\n * - cdn_https - url to HTTPS CDN\n * - version - version of pusher-js\n * - suffix - suffix appended to all names of dependency files\n *\n * @param {Object} options\n */\nexport default class DependencyLoader {\n options: any;\n receivers: ScriptReceiverFactory;\n loading: any;\n\n constructor(options: any) {\n this.options = options;\n this.receivers = options.receivers || ScriptReceivers;\n this.loading = {};\n }\n\n /** Loads the dependency from CDN.\n *\n * @param {String} name\n * @param {Function} callback\n */\n load(name: string, options: any, callback: Function) {\n var self = this;\n\n if (self.loading[name] && self.loading[name].length > 0) {\n self.loading[name].push(callback);\n } else {\n self.loading[name] = [callback];\n\n var request = Runtime.createScriptRequest(self.getPath(name, options));\n var receiver = self.receivers.create(function(error) {\n self.receivers.remove(receiver);\n\n if (self.loading[name]) {\n var callbacks = self.loading[name];\n delete self.loading[name];\n\n var successCallback = function(wasSuccessful) {\n if (!wasSuccessful) {\n request.cleanup();\n }\n };\n for (var i = 0; i < callbacks.length; i++) {\n callbacks[i](error, successCallback);\n }\n }\n });\n request.send(receiver);\n }\n }\n\n /** Returns a root URL for pusher-js CDN.\n *\n * @returns {String}\n */\n getRoot(options: any): string {\n var cdn;\n var protocol = Runtime.getDocument().location.protocol;\n if ((options && options.useTLS) || protocol === 'https:') {\n cdn = this.options.cdn_https;\n } else {\n cdn = this.options.cdn_http;\n }\n // make sure there are no double slashes\n return cdn.replace(/\\/*$/, '') + '/' + this.options.version;\n }\n\n /** Returns a full path to a dependency file.\n *\n * @param {String} name\n * @returns {String}\n */\n getPath(name: string, options: any): string {\n return this.getRoot(options) + '/' + name + this.options.suffix + '.js';\n }\n}\n","/**\n * A place to store help URLs for error messages etc\n */\n\nconst urlStore = {\n baseUrl: 'https://pusher.com',\n urls: {\n authenticationEndpoint: {\n path: '/docs/channels/server_api/authenticating_users'\n },\n authorizationEndpoint: {\n path: '/docs/channels/server_api/authorizing-users/'\n },\n javascriptQuickStart: {\n path: '/docs/javascript_quick_start'\n },\n triggeringClientEvents: {\n path: '/docs/client_api_guide/client_events#trigger-events'\n },\n encryptedChannelSupport: {\n fullUrl:\n 'https://github.com/pusher/pusher-js/tree/cc491015371a4bde5743d1c87a0fbac0feb53195#encrypted-channel-support'\n }\n }\n};\n\n/** Builds a consistent string with links to pusher documentation\n *\n * @param {string} key - relevant key in the url_store.urls object\n * @return {string} suffix string to append to log message\n */\nconst buildLogSuffix = function(key: string): string {\n const urlPrefix = 'See:';\n const urlObj = urlStore.urls[key];\n if (!urlObj) return '';\n\n let url;\n if (urlObj.fullUrl) {\n url = urlObj.fullUrl;\n } else if (urlObj.path) {\n url = urlStore.baseUrl + urlObj.path;\n }\n\n if (!url) return '';\n return `${urlPrefix} ${url}`;\n};\n\nexport default { buildLogSuffix };\n","export enum AuthRequestType {\n UserAuthentication = 'user-authentication',\n ChannelAuthorization = 'channel-authorization'\n}\n\nexport interface ChannelAuthorizationData {\n auth: string;\n channel_data?: string;\n shared_secret?: string;\n}\n\nexport type ChannelAuthorizationCallback = (\n error: Error | null,\n authData: ChannelAuthorizationData | null\n) => void;\n\nexport interface ChannelAuthorizationRequestParams {\n socketId: string;\n channelName: string;\n}\n\nexport interface ChannelAuthorizationHandler {\n (\n params: ChannelAuthorizationRequestParams,\n callback: ChannelAuthorizationCallback\n ): void;\n}\n\nexport interface UserAuthenticationData {\n auth: string;\n user_data: string;\n}\n\nexport type UserAuthenticationCallback = (\n error: Error | null,\n authData: UserAuthenticationData | null\n) => void;\n\nexport interface UserAuthenticationRequestParams {\n socketId: string;\n}\n\nexport interface UserAuthenticationHandler {\n (\n params: UserAuthenticationRequestParams,\n callback: UserAuthenticationCallback\n ): void;\n}\n\nexport type AuthTransportCallback =\n | ChannelAuthorizationCallback\n | UserAuthenticationCallback;\n\nexport interface InternalAuthOptions {\n transport: 'ajax' | 'jsonp';\n endpoint: string;\n params?: any;\n headers?: any;\n paramsProvider?: () => any;\n headersProvider?: () => any;\n}\n\nexport type CustomAuthOptions = {\n customHandler: AuthHandler;\n};\n\nexport type AuthOptionsT =\n | InternalAuthOptions\n | CustomAuthOptions;\n\nexport declare type UserAuthenticationOptions = AuthOptionsT<\n UserAuthenticationHandler\n>;\nexport declare type ChannelAuthorizationOptions = AuthOptionsT<\n ChannelAuthorizationHandler\n>;\n","/** Error classes used throughout the library. */\n// https://github.com/Microsoft/TypeScript-wiki/blob/master/Breaking-Changes.md#extending-built-ins-like-error-array-and-map-may-no-longer-work\nexport class BadEventName extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\nexport class BadChannelName extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\nexport class RequestTimedOut extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class TransportPriorityTooLow extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class TransportClosed extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class UnsupportedFeature extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class UnsupportedTransport extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class UnsupportedStrategy extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class HTTPAuthError extends Error {\n status: number;\n constructor(status: number, msg?: string) {\n super(msg);\n this.status = status;\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n","import TimelineSender from 'core/timeline/timeline_sender';\nimport * as Collections from 'core/utils/collections';\nimport Util from 'core/util';\nimport Runtime from 'runtime';\nimport { AuthTransport } from 'core/auth/auth_transports';\nimport AbstractRuntime from 'runtimes/interface';\nimport UrlStore from 'core/utils/url_store';\nimport {\n AuthRequestType,\n AuthTransportCallback,\n InternalAuthOptions\n} from 'core/auth/options';\nimport { HTTPAuthError } from 'core/errors';\n\nconst ajax: AuthTransport = function(\n context: AbstractRuntime,\n query: string,\n authOptions: InternalAuthOptions,\n authRequestType: AuthRequestType,\n callback: AuthTransportCallback\n) {\n const xhr = Runtime.createXHR();\n xhr.open('POST', authOptions.endpoint, true);\n\n // add request headers\n xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');\n for (var headerName in authOptions.headers) {\n xhr.setRequestHeader(headerName, authOptions.headers[headerName]);\n }\n if (authOptions.headersProvider != null) {\n let dynamicHeaders = authOptions.headersProvider();\n for (var headerName in dynamicHeaders) {\n xhr.setRequestHeader(headerName, dynamicHeaders[headerName]);\n }\n }\n\n xhr.onreadystatechange = function() {\n if (xhr.readyState === 4) {\n if (xhr.status === 200) {\n let data;\n let parsed = false;\n\n try {\n data = JSON.parse(xhr.responseText);\n parsed = true;\n } catch (e) {\n callback(\n new HTTPAuthError(\n 200,\n `JSON returned from ${authRequestType.toString()} endpoint was invalid, yet status code was 200. Data was: ${\n xhr.responseText\n }`\n ),\n null\n );\n }\n\n if (parsed) {\n // prevents double execution.\n callback(null, data);\n }\n } else {\n let suffix = '';\n switch (authRequestType) {\n case AuthRequestType.UserAuthentication:\n suffix = UrlStore.buildLogSuffix('authenticationEndpoint');\n break;\n case AuthRequestType.ChannelAuthorization:\n suffix = `Clients must be authorized to join private or presence channels. ${UrlStore.buildLogSuffix(\n 'authorizationEndpoint'\n )}`;\n break;\n }\n callback(\n new HTTPAuthError(\n xhr.status,\n `Unable to retrieve auth string from ${authRequestType.toString()} endpoint - ` +\n `received status: ${xhr.status} from ${authOptions.endpoint}. ${suffix}`\n ),\n null\n );\n }\n }\n };\n\n xhr.send(query);\n return xhr;\n};\n\nexport default ajax;\n","export default function encode(s: any): string {\n return btoa(utob(s));\n}\n\nvar fromCharCode = String.fromCharCode;\n\nvar b64chars =\n 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';\nvar b64tab = {};\n\nfor (var i = 0, l = b64chars.length; i < l; i++) {\n b64tab[b64chars.charAt(i)] = i;\n}\n\nvar cb_utob = function(c) {\n var cc = c.charCodeAt(0);\n return cc < 0x80\n ? c\n : cc < 0x800\n ? fromCharCode(0xc0 | (cc >>> 6)) + fromCharCode(0x80 | (cc & 0x3f))\n : fromCharCode(0xe0 | ((cc >>> 12) & 0x0f)) +\n fromCharCode(0x80 | ((cc >>> 6) & 0x3f)) +\n fromCharCode(0x80 | (cc & 0x3f));\n};\n\nvar utob = function(u) {\n return u.replace(/[^\\x00-\\x7F]/g, cb_utob);\n};\n\nvar cb_encode = function(ccc) {\n var padlen = [0, 2, 1][ccc.length % 3];\n var ord =\n (ccc.charCodeAt(0) << 16) |\n ((ccc.length > 1 ? ccc.charCodeAt(1) : 0) << 8) |\n (ccc.length > 2 ? ccc.charCodeAt(2) : 0);\n var chars = [\n b64chars.charAt(ord >>> 18),\n b64chars.charAt((ord >>> 12) & 63),\n padlen >= 2 ? '=' : b64chars.charAt((ord >>> 6) & 63),\n padlen >= 1 ? '=' : b64chars.charAt(ord & 63)\n ];\n return chars.join('');\n};\n\nvar btoa =\n global.btoa ||\n function(b) {\n return b.replace(/[\\s\\S]{1,3}/g, cb_encode);\n };\n","import TimedCallback from './timed_callback';\nimport { Delay, Scheduler, Canceller } from './scheduling';\n\nabstract class Timer {\n protected clear: Canceller;\n protected timer: number | void;\n\n constructor(\n set: Scheduler,\n clear: Canceller,\n delay: Delay,\n callback: TimedCallback\n ) {\n this.clear = clear;\n this.timer = set(() => {\n if (this.timer) {\n this.timer = callback(this.timer);\n }\n }, delay);\n }\n\n /** Returns whether the timer is still running.\n *\n * @return {Boolean}\n */\n isRunning(): boolean {\n return this.timer !== null;\n }\n\n /** Aborts a timer when it's running. */\n ensureAborted() {\n if (this.timer) {\n this.clear(this.timer);\n this.timer = null;\n }\n }\n}\n\nexport default Timer;\n","import Timer from './abstract_timer';\nimport TimedCallback from './timed_callback';\nimport { Delay } from './scheduling';\n\n// We need to bind clear functions this way to avoid exceptions on IE8\nfunction clearTimeout(timer) {\n global.clearTimeout(timer);\n}\nfunction clearInterval(timer) {\n global.clearInterval(timer);\n}\n\n/** Cross-browser compatible one-off timer abstraction.\n *\n * @param {Number} delay\n * @param {Function} callback\n */\nexport class OneOffTimer extends Timer {\n constructor(delay: Delay, callback: TimedCallback) {\n super(setTimeout, clearTimeout, delay, function(timer) {\n callback();\n return null;\n });\n }\n}\n\n/** Cross-browser compatible periodic timer abstraction.\n *\n * @param {Number} delay\n * @param {Function} callback\n */\nexport class PeriodicTimer extends Timer {\n constructor(delay: Delay, callback: TimedCallback) {\n super(setInterval, clearInterval, delay, function(timer) {\n callback();\n return timer;\n });\n }\n}\n","import * as Collections from './utils/collections';\nimport TimedCallback from './utils/timers/timed_callback';\nimport { OneOffTimer, PeriodicTimer } from './utils/timers';\n\nvar Util = {\n now(): number {\n if (Date.now) {\n return Date.now();\n } else {\n return new Date().valueOf();\n }\n },\n\n defer(callback: TimedCallback): OneOffTimer {\n return new OneOffTimer(0, callback);\n },\n\n /** Builds a function that will proxy a method call to its first argument.\n *\n * Allows partial application of arguments, so additional arguments are\n * prepended to the argument list.\n *\n * @param {String} name method name\n * @return {Function} proxy function\n */\n method(name: string, ...args: any[]): Function {\n var boundArguments = Array.prototype.slice.call(arguments, 1);\n return function(object) {\n return object[name].apply(object, boundArguments.concat(arguments));\n };\n }\n};\n\nexport default Util;\n","import base64encode from '../base64';\nimport Util from '../util';\n\n/** Merges multiple objects into the target argument.\n *\n * For properties that are plain Objects, performs a deep-merge. For the\n * rest it just copies the value of the property.\n *\n * To extend prototypes use it as following:\n * Pusher.Util.extend(Target.prototype, Base.prototype)\n *\n * You can also use it to merge objects without altering them:\n * Pusher.Util.extend({}, object1, object2)\n *\n * @param {Object} target\n * @return {Object} the target argument\n */\nexport function extend(target: any, ...sources: any[]): T {\n for (var i = 0; i < sources.length; i++) {\n var extensions = sources[i];\n for (var property in extensions) {\n if (\n extensions[property] &&\n extensions[property].constructor &&\n extensions[property].constructor === Object\n ) {\n target[property] = extend(target[property] || {}, extensions[property]);\n } else {\n target[property] = extensions[property];\n }\n }\n }\n return target;\n}\n\nexport function stringify(): string {\n var m = ['Pusher'];\n for (var i = 0; i < arguments.length; i++) {\n if (typeof arguments[i] === 'string') {\n m.push(arguments[i]);\n } else {\n m.push(safeJSONStringify(arguments[i]));\n }\n }\n return m.join(' : ');\n}\n\nexport function arrayIndexOf(array: any[], item: any): number {\n // MSIE doesn't have array.indexOf\n var nativeIndexOf = Array.prototype.indexOf;\n if (array === null) {\n return -1;\n }\n if (nativeIndexOf && array.indexOf === nativeIndexOf) {\n return array.indexOf(item);\n }\n for (var i = 0, l = array.length; i < l; i++) {\n if (array[i] === item) {\n return i;\n }\n }\n return -1;\n}\n\n/** Applies a function f to all properties of an object.\n *\n * Function f gets 3 arguments passed:\n * - element from the object\n * - key of the element\n * - reference to the object\n *\n * @param {Object} object\n * @param {Function} f\n */\nexport function objectApply(object: any, f: Function) {\n for (var key in object) {\n if (Object.prototype.hasOwnProperty.call(object, key)) {\n f(object[key], key, object);\n }\n }\n}\n\n/** Return a list of objects own proerty keys\n *\n * @param {Object} object\n * @returns {Array}\n */\nexport function keys(object: any): string[] {\n var keys = [];\n objectApply(object, function(_, key) {\n keys.push(key);\n });\n return keys;\n}\n\n/** Return a list of object's own property values\n *\n * @param {Object} object\n * @returns {Array}\n */\nexport function values(object: any): any[] {\n var values = [];\n objectApply(object, function(value) {\n values.push(value);\n });\n return values;\n}\n\n/** Applies a function f to all elements of an array.\n *\n * Function f gets 3 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function apply(array: any[], f: Function, context?: any) {\n for (var i = 0; i < array.length; i++) {\n f.call(context || global, array[i], i, array);\n }\n}\n\n/** Maps all elements of the array and returns the result.\n *\n * Function f gets 4 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n * - reference to the destination array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function map(array: any[], f: Function): any[] {\n var result = [];\n for (var i = 0; i < array.length; i++) {\n result.push(f(array[i], i, array, result));\n }\n return result;\n}\n\n/** Maps all elements of the object and returns the result.\n *\n * Function f gets 4 arguments passed:\n * - element from the object\n * - key of the element\n * - reference to the source object\n * - reference to the destination object\n *\n * @param {Object} object\n * @param {Function} f\n */\nexport function mapObject(object: any, f: Function): any {\n var result = {};\n objectApply(object, function(value, key) {\n result[key] = f(value);\n });\n return result;\n}\n\n/** Filters elements of the array using a test function.\n *\n * Function test gets 4 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n * - reference to the destination array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function filter(array: any[], test: Function): any[] {\n test =\n test ||\n function(value) {\n return !!value;\n };\n\n var result = [];\n for (var i = 0; i < array.length; i++) {\n if (test(array[i], i, array, result)) {\n result.push(array[i]);\n }\n }\n return result;\n}\n\n/** Filters properties of the object using a test function.\n *\n * Function test gets 4 arguments passed:\n * - element from the object\n * - key of the element\n * - reference to the source object\n * - reference to the destination object\n *\n * @param {Object} object\n * @param {Function} f\n */\nexport function filterObject(object: Object, test: Function) {\n var result = {};\n objectApply(object, function(value, key) {\n if ((test && test(value, key, object, result)) || Boolean(value)) {\n result[key] = value;\n }\n });\n return result;\n}\n\n/** Flattens an object into a two-dimensional array.\n *\n * @param {Object} object\n * @return {Array} resulting array of [key, value] pairs\n */\nexport function flatten(object: Object): any[] {\n var result = [];\n objectApply(object, function(value, key) {\n result.push([key, value]);\n });\n return result;\n}\n\n/** Checks whether any element of the array passes the test.\n *\n * Function test gets 3 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function any(array: any[], test: Function): boolean {\n for (var i = 0; i < array.length; i++) {\n if (test(array[i], i, array)) {\n return true;\n }\n }\n return false;\n}\n\n/** Checks whether all elements of the array pass the test.\n *\n * Function test gets 3 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function all(array: any[], test: Function): boolean {\n for (var i = 0; i < array.length; i++) {\n if (!test(array[i], i, array)) {\n return false;\n }\n }\n return true;\n}\n\nexport function encodeParamsObject(data): string {\n return mapObject(data, function(value) {\n if (typeof value === 'object') {\n value = safeJSONStringify(value);\n }\n return encodeURIComponent(base64encode(value.toString()));\n });\n}\n\nexport function buildQueryString(data: any): string {\n var params = filterObject(data, function(value) {\n return value !== undefined;\n });\n\n var query = map(\n flatten(encodeParamsObject(params)),\n Util.method('join', '=')\n ).join('&');\n\n return query;\n}\n\n/**\n * See https://github.com/douglascrockford/JSON-js/blob/master/cycle.js\n *\n * Remove circular references from an object. Required for JSON.stringify in\n * React Native, which tends to blow up a lot.\n *\n * @param {any} object\n * @return {any} Decycled object\n */\nexport function decycleObject(object: any): any {\n var objects = [],\n paths = [];\n\n return (function derez(value, path) {\n var i, name, nu;\n\n switch (typeof value) {\n case 'object':\n if (!value) {\n return null;\n }\n for (i = 0; i < objects.length; i += 1) {\n if (objects[i] === value) {\n return { $ref: paths[i] };\n }\n }\n\n objects.push(value);\n paths.push(path);\n\n if (Object.prototype.toString.apply(value) === '[object Array]') {\n nu = [];\n for (i = 0; i < value.length; i += 1) {\n nu[i] = derez(value[i], path + '[' + i + ']');\n }\n } else {\n nu = {};\n for (name in value) {\n if (Object.prototype.hasOwnProperty.call(value, name)) {\n nu[name] = derez(\n value[name],\n path + '[' + JSON.stringify(name) + ']'\n );\n }\n }\n }\n return nu;\n case 'number':\n case 'string':\n case 'boolean':\n return value;\n }\n })(object, '$');\n}\n\n/**\n * Provides a cross-browser and cross-platform way to safely stringify objects\n * into JSON. This is particularly necessary for ReactNative, where circular JSON\n * structures throw an exception.\n *\n * @param {any} source The object to stringify\n * @return {string} The serialized output.\n */\nexport function safeJSONStringify(source: any): string {\n try {\n return JSON.stringify(source);\n } catch (e) {\n return JSON.stringify(decycleObject(source));\n }\n}\n","import { stringify } from './utils/collections';\nimport Pusher from './pusher';\n\nclass Logger {\n debug(...args: any[]) {\n this.log(this.globalLog, args);\n }\n\n warn(...args: any[]) {\n this.log(this.globalLogWarn, args);\n }\n\n error(...args: any[]) {\n this.log(this.globalLogError, args);\n }\n\n private globalLog = (message: string) => {\n if (global.console && global.console.log) {\n global.console.log(message);\n }\n };\n\n private globalLogWarn(message: string) {\n if (global.console && global.console.warn) {\n global.console.warn(message);\n } else {\n this.globalLog(message);\n }\n }\n\n private globalLogError(message: string) {\n if (global.console && global.console.error) {\n global.console.error(message);\n } else {\n this.globalLogWarn(message);\n }\n }\n\n private log(\n defaultLoggingFunction: (message: string) => void,\n ...args: any[]\n ) {\n var message = stringify.apply(this, arguments);\n if (Pusher.log) {\n Pusher.log(message);\n } else if (Pusher.logToConsole) {\n const log = defaultLoggingFunction.bind(this);\n log(message);\n }\n }\n}\n\nexport default new Logger();\n","import Browser from '../browser';\nimport Logger from 'core/logger';\nimport JSONPRequest from '../dom/jsonp_request';\nimport { ScriptReceivers } from '../dom/script_receiver_factory';\nimport { AuthTransport } from 'core/auth/auth_transports';\nimport {\n AuthRequestType,\n AuthTransportCallback,\n InternalAuthOptions\n} from 'core/auth/options';\n\nvar jsonp: AuthTransport = function(\n context: Browser,\n query: string,\n authOptions: InternalAuthOptions,\n authRequestType: AuthRequestType,\n callback: AuthTransportCallback\n) {\n if (\n authOptions.headers !== undefined ||\n authOptions.headersProvider != null\n ) {\n Logger.warn(\n `To send headers with the ${authRequestType.toString()} request, you must use AJAX, rather than JSONP.`\n );\n }\n\n var callbackName = context.nextAuthCallbackID.toString();\n context.nextAuthCallbackID++;\n\n var document = context.getDocument();\n var script = document.createElement('script');\n // Hacked wrapper.\n context.auth_callbacks[callbackName] = function(data) {\n callback(null, data);\n };\n\n var callback_name = \"Pusher.auth_callbacks['\" + callbackName + \"']\";\n script.src =\n authOptions.endpoint +\n '?callback=' +\n encodeURIComponent(callback_name) +\n '&' +\n query;\n\n var head =\n document.getElementsByTagName('head')[0] || document.documentElement;\n head.insertBefore(script, head.firstChild);\n};\n\nexport default jsonp;\n","import ScriptReceiver from './script_receiver';\n\n/** Sends a generic HTTP GET request using a script tag.\n *\n * By constructing URL in a specific way, it can be used for loading\n * JavaScript resources or JSONP requests. It can notify about errors, but\n * only in certain environments. Please take care of monitoring the state of\n * the request yourself.\n *\n * @param {String} src\n */\nexport default class ScriptRequest {\n src: string;\n script: any;\n errorScript: any;\n\n constructor(src: string) {\n this.src = src;\n }\n\n send(receiver: ScriptReceiver) {\n var self = this;\n var errorString = 'Error loading ' + self.src;\n\n self.script = document.createElement('script');\n self.script.id = receiver.id;\n self.script.src = self.src;\n self.script.type = 'text/javascript';\n self.script.charset = 'UTF-8';\n\n if (self.script.addEventListener) {\n self.script.onerror = function() {\n receiver.callback(errorString);\n };\n self.script.onload = function() {\n receiver.callback(null);\n };\n } else {\n self.script.onreadystatechange = function() {\n if (\n self.script.readyState === 'loaded' ||\n self.script.readyState === 'complete'\n ) {\n receiver.callback(null);\n }\n };\n }\n\n // Opera<11.6 hack for missing onerror callback\n if (\n self.script.async === undefined &&\n (document).attachEvent &&\n /opera/i.test(navigator.userAgent)\n ) {\n self.errorScript = document.createElement('script');\n self.errorScript.id = receiver.id + '_error';\n self.errorScript.text = receiver.name + \"('\" + errorString + \"');\";\n self.script.async = self.errorScript.async = false;\n } else {\n self.script.async = true;\n }\n\n var head = document.getElementsByTagName('head')[0];\n head.insertBefore(self.script, head.firstChild);\n if (self.errorScript) {\n head.insertBefore(self.errorScript, self.script.nextSibling);\n }\n }\n\n /** Cleans up the DOM remains of the script request. */\n cleanup() {\n if (this.script) {\n this.script.onload = this.script.onerror = null;\n this.script.onreadystatechange = null;\n }\n if (this.script && this.script.parentNode) {\n this.script.parentNode.removeChild(this.script);\n }\n if (this.errorScript && this.errorScript.parentNode) {\n this.errorScript.parentNode.removeChild(this.errorScript);\n }\n this.script = null;\n this.errorScript = null;\n }\n}\n","import ScriptReceiver from './script_receiver';\nimport ScriptRequest from './script_request';\nimport * as Collections from 'core/utils/collections';\nimport Util from 'core/util';\nimport Runtime from '../runtime';\n\n/** Sends data via JSONP.\n *\n * Data is a key-value map. Its values are JSON-encoded and then passed\n * through base64. Finally, keys and encoded values are appended to the query\n * string.\n *\n * The class itself does not guarantee raising errors on failures, as it's not\n * possible to support such feature on all browsers. Instead, JSONP endpoint\n * should call back in a way that's easy to distinguish from browser calls,\n * for example by passing a second argument to the receiver.\n *\n * @param {String} url\n * @param {Object} data key-value map of data to be submitted\n */\nexport default class JSONPRequest {\n url: string;\n data: any;\n request: ScriptRequest;\n\n constructor(url: string, data: any) {\n this.url = url;\n this.data = data;\n }\n\n /** Sends the actual JSONP request.\n *\n * @param {ScriptReceiver} receiver\n */\n send(receiver: ScriptReceiver) {\n if (this.request) {\n return;\n }\n\n var query = Collections.buildQueryString(this.data);\n var url = this.url + '/' + receiver.number + '?' + query;\n this.request = Runtime.createScriptRequest(url);\n this.request.send(receiver);\n }\n\n /** Cleans up the DOM remains of the JSONP request. */\n cleanup() {\n if (this.request) {\n this.request.cleanup();\n }\n }\n}\n","import TimelineSender from 'core/timeline/timeline_sender';\nimport TimelineTransport from 'core/timeline/timeline_transport';\nimport Browser from 'runtime';\nimport { AuthTransport } from 'core/auth/auth_transports';\nimport { ScriptReceivers } from '../dom/script_receiver_factory';\n\nvar getAgent = function(sender: TimelineSender, useTLS: boolean) {\n return function(data: any, callback: Function) {\n var scheme = 'http' + (useTLS ? 's' : '') + '://';\n var url =\n scheme + (sender.host || sender.options.host) + sender.options.path;\n var request = Browser.createJSONPRequest(url, data);\n\n var receiver = Browser.ScriptReceivers.create(function(error, result) {\n ScriptReceivers.remove(receiver);\n request.cleanup();\n\n if (result && result.host) {\n sender.host = result.host;\n }\n if (callback) {\n callback(error, result);\n }\n });\n request.send(receiver);\n };\n};\n\nvar jsonp = {\n name: 'jsonp',\n getAgent\n};\n\nexport default jsonp;\n","import Defaults from '../defaults';\nimport { default as URLScheme, URLSchemeParams } from './url_scheme';\n\nfunction getGenericURL(\n baseScheme: string,\n params: URLSchemeParams,\n path: string\n): string {\n var scheme = baseScheme + (params.useTLS ? 's' : '');\n var host = params.useTLS ? params.hostTLS : params.hostNonTLS;\n return scheme + '://' + host + path;\n}\n\nfunction getGenericPath(key: string, queryString?: string): string {\n var path = '/app/' + key;\n var query =\n '?protocol=' +\n Defaults.PROTOCOL +\n '&client=js' +\n '&version=' +\n Defaults.VERSION +\n (queryString ? '&' + queryString : '');\n return path + query;\n}\n\nexport var ws: URLScheme = {\n getInitial: function(key: string, params: URLSchemeParams): string {\n var path = (params.httpPath || '') + getGenericPath(key, 'flash=false');\n return getGenericURL('ws', params, path);\n }\n};\n\nexport var http: URLScheme = {\n getInitial: function(key: string, params: URLSchemeParams): string {\n var path = (params.httpPath || '/pusher') + getGenericPath(key);\n return getGenericURL('http', params, path);\n }\n};\n\nexport var sockjs: URLScheme = {\n getInitial: function(key: string, params: URLSchemeParams): string {\n return getGenericURL('http', params, params.httpPath || '/pusher');\n },\n getPath: function(key: string, params: URLSchemeParams): string {\n return getGenericPath(key);\n }\n};\n","import Callback from './callback';\nimport * as Collections from '../utils/collections';\nimport CallbackTable from './callback_table';\n\nexport default class CallbackRegistry {\n _callbacks: CallbackTable;\n\n constructor() {\n this._callbacks = {};\n }\n\n get(name: string): Callback[] {\n return this._callbacks[prefix(name)];\n }\n\n add(name: string, callback: Function, context: any) {\n var prefixedEventName = prefix(name);\n this._callbacks[prefixedEventName] =\n this._callbacks[prefixedEventName] || [];\n this._callbacks[prefixedEventName].push({\n fn: callback,\n context: context\n });\n }\n\n remove(name?: string, callback?: Function, context?: any) {\n if (!name && !callback && !context) {\n this._callbacks = {};\n return;\n }\n\n var names = name ? [prefix(name)] : Collections.keys(this._callbacks);\n\n if (callback || context) {\n this.removeCallback(names, callback, context);\n } else {\n this.removeAllCallbacks(names);\n }\n }\n\n private removeCallback(names: string[], callback: Function, context: any) {\n Collections.apply(\n names,\n function(name) {\n this._callbacks[name] = Collections.filter(\n this._callbacks[name] || [],\n function(binding) {\n return (\n (callback && callback !== binding.fn) ||\n (context && context !== binding.context)\n );\n }\n );\n if (this._callbacks[name].length === 0) {\n delete this._callbacks[name];\n }\n },\n this\n );\n }\n\n private removeAllCallbacks(names: string[]) {\n Collections.apply(\n names,\n function(name) {\n delete this._callbacks[name];\n },\n this\n );\n }\n}\n\nfunction prefix(name: string): string {\n return '_' + name;\n}\n","import * as Collections from '../utils/collections';\nimport Callback from './callback';\nimport Metadata from '../channels/metadata';\nimport CallbackRegistry from './callback_registry';\n\n/** Manages callback bindings and event emitting.\n *\n * @param Function failThrough called when no listeners are bound to an event\n */\nexport default class Dispatcher {\n callbacks: CallbackRegistry;\n global_callbacks: Function[];\n failThrough: Function;\n\n constructor(failThrough?: Function) {\n this.callbacks = new CallbackRegistry();\n this.global_callbacks = [];\n this.failThrough = failThrough;\n }\n\n bind(eventName: string, callback: Function, context?: any) {\n this.callbacks.add(eventName, callback, context);\n return this;\n }\n\n bind_global(callback: Function) {\n this.global_callbacks.push(callback);\n return this;\n }\n\n unbind(eventName?: string, callback?: Function, context?: any) {\n this.callbacks.remove(eventName, callback, context);\n return this;\n }\n\n unbind_global(callback?: Function) {\n if (!callback) {\n this.global_callbacks = [];\n return this;\n }\n\n this.global_callbacks = Collections.filter(\n this.global_callbacks || [],\n c => c !== callback\n );\n\n return this;\n }\n\n unbind_all() {\n this.unbind();\n this.unbind_global();\n return this;\n }\n\n emit(eventName: string, data?: any, metadata?: Metadata): Dispatcher {\n for (var i = 0; i < this.global_callbacks.length; i++) {\n this.global_callbacks[i](eventName, data);\n }\n\n var callbacks = this.callbacks.get(eventName);\n var args = [];\n\n if (metadata) {\n // if there's a metadata argument, we need to call the callback with both\n // data and metadata regardless of whether data is undefined\n args.push(data, metadata);\n } else if (data) {\n // metadata is undefined, so we only need to call the callback with data\n // if data exists\n args.push(data);\n }\n\n if (callbacks && callbacks.length > 0) {\n for (var i = 0; i < callbacks.length; i++) {\n callbacks[i].fn.apply(callbacks[i].context || global, args);\n }\n } else if (this.failThrough) {\n this.failThrough(eventName, data);\n }\n\n return this;\n }\n}\n","import Util from '../util';\nimport * as Collections from '../utils/collections';\nimport { default as EventsDispatcher } from '../events/dispatcher';\nimport Logger from '../logger';\nimport TransportHooks from './transport_hooks';\nimport Socket from '../socket';\nimport Runtime from 'runtime';\nimport Timeline from '../timeline/timeline';\nimport TransportConnectionOptions from './transport_connection_options';\n\n/** Provides universal API for transport connections.\n *\n * Transport connection is a low-level object that wraps a connection method\n * and exposes a simple evented interface for the connection state and\n * messaging. It does not implement Pusher-specific WebSocket protocol.\n *\n * Additionally, it fetches resources needed for transport to work and exposes\n * an interface for querying transport features.\n *\n * States:\n * - new - initial state after constructing the object\n * - initializing - during initialization phase, usually fetching resources\n * - intialized - ready to establish a connection\n * - connection - when connection is being established\n * - open - when connection ready to be used\n * - closed - after connection was closed be either side\n *\n * Emits:\n * - error - after the connection raised an error\n *\n * Options:\n * - useTLS - whether connection should be over TLS\n * - hostTLS - host to connect to when connection is over TLS\n * - hostNonTLS - host to connect to when connection is over TLS\n *\n * @param {String} key application key\n * @param {Object} options\n */\nexport default class TransportConnection extends EventsDispatcher {\n hooks: TransportHooks;\n name: string;\n priority: number;\n key: string;\n options: TransportConnectionOptions;\n state: string;\n timeline: Timeline;\n activityTimeout: number;\n id: number;\n socket: Socket;\n beforeOpen: Function;\n initialize: Function;\n\n constructor(\n hooks: TransportHooks,\n name: string,\n priority: number,\n key: string,\n options: TransportConnectionOptions\n ) {\n super();\n this.initialize = Runtime.transportConnectionInitializer;\n this.hooks = hooks;\n this.name = name;\n this.priority = priority;\n this.key = key;\n this.options = options;\n\n this.state = 'new';\n this.timeline = options.timeline;\n this.activityTimeout = options.activityTimeout;\n this.id = this.timeline.generateUniqueID();\n }\n\n /** Checks whether the transport handles activity checks by itself.\n *\n * @return {Boolean}\n */\n handlesActivityChecks(): boolean {\n return Boolean(this.hooks.handlesActivityChecks);\n }\n\n /** Checks whether the transport supports the ping/pong API.\n *\n * @return {Boolean}\n */\n supportsPing(): boolean {\n return Boolean(this.hooks.supportsPing);\n }\n\n /** Tries to establish a connection.\n *\n * @returns {Boolean} false if transport is in invalid state\n */\n connect(): boolean {\n if (this.socket || this.state !== 'initialized') {\n return false;\n }\n\n var url = this.hooks.urls.getInitial(this.key, this.options);\n try {\n this.socket = this.hooks.getSocket(url, this.options);\n } catch (e) {\n Util.defer(() => {\n this.onError(e);\n this.changeState('closed');\n });\n return false;\n }\n\n this.bindListeners();\n\n Logger.debug('Connecting', { transport: this.name, url });\n this.changeState('connecting');\n return true;\n }\n\n /** Closes the connection.\n *\n * @return {Boolean} true if there was a connection to close\n */\n close(): boolean {\n if (this.socket) {\n this.socket.close();\n return true;\n } else {\n return false;\n }\n }\n\n /** Sends data over the open connection.\n *\n * @param {String} data\n * @return {Boolean} true only when in the \"open\" state\n */\n send(data: any): boolean {\n if (this.state === 'open') {\n // Workaround for MobileSafari bug (see https://gist.github.com/2052006)\n Util.defer(() => {\n if (this.socket) {\n this.socket.send(data);\n }\n });\n return true;\n } else {\n return false;\n }\n }\n\n /** Sends a ping if the connection is open and transport supports it. */\n ping() {\n if (this.state === 'open' && this.supportsPing()) {\n this.socket.ping();\n }\n }\n\n private onOpen() {\n if (this.hooks.beforeOpen) {\n this.hooks.beforeOpen(\n this.socket,\n this.hooks.urls.getPath(this.key, this.options)\n );\n }\n this.changeState('open');\n this.socket.onopen = undefined;\n }\n\n private onError(error) {\n this.emit('error', { type: 'WebSocketError', error: error });\n this.timeline.error(this.buildTimelineMessage({ error: error.toString() }));\n }\n\n private onClose(closeEvent?: any) {\n if (closeEvent) {\n this.changeState('closed', {\n code: closeEvent.code,\n reason: closeEvent.reason,\n wasClean: closeEvent.wasClean\n });\n } else {\n this.changeState('closed');\n }\n this.unbindListeners();\n this.socket = undefined;\n }\n\n private onMessage(message) {\n this.emit('message', message);\n }\n\n private onActivity() {\n this.emit('activity');\n }\n\n private bindListeners() {\n this.socket.onopen = () => {\n this.onOpen();\n };\n this.socket.onerror = error => {\n this.onError(error);\n };\n this.socket.onclose = closeEvent => {\n this.onClose(closeEvent);\n };\n this.socket.onmessage = message => {\n this.onMessage(message);\n };\n\n if (this.supportsPing()) {\n this.socket.onactivity = () => {\n this.onActivity();\n };\n }\n }\n\n private unbindListeners() {\n if (this.socket) {\n this.socket.onopen = undefined;\n this.socket.onerror = undefined;\n this.socket.onclose = undefined;\n this.socket.onmessage = undefined;\n if (this.supportsPing()) {\n this.socket.onactivity = undefined;\n }\n }\n }\n\n private changeState(state: string, params?: any) {\n this.state = state;\n this.timeline.info(\n this.buildTimelineMessage({\n state: state,\n params: params\n })\n );\n this.emit(state, params);\n }\n\n buildTimelineMessage(message): any {\n return Collections.extend({ cid: this.id }, message);\n }\n}\n","import Factory from '../utils/factory';\nimport TransportHooks from './transport_hooks';\nimport TransportConnection from './transport_connection';\nimport TransportConnectionOptions from './transport_connection_options';\n\n/** Provides interface for transport connection instantiation.\n *\n * Takes transport-specific hooks as the only argument, which allow checking\n * for transport support and creating its connections.\n *\n * Supported hooks: * - file - the name of the file to be fetched during initialization\n * - urls - URL scheme to be used by transport\n * - handlesActivityCheck - true when the transport handles activity checks\n * - supportsPing - true when the transport has a ping/activity API\n * - isSupported - tells whether the transport is supported in the environment\n * - getSocket - creates a WebSocket-compatible transport socket\n *\n * See transports.js for specific implementations.\n *\n * @param {Object} hooks object containing all needed transport hooks\n */\nexport default class Transport {\n hooks: TransportHooks;\n\n constructor(hooks: TransportHooks) {\n this.hooks = hooks;\n }\n\n /** Returns whether the transport is supported in the environment.\n *\n * @param {Object} envronment te environment details (encryption, settings)\n * @returns {Boolean} true when the transport is supported\n */\n isSupported(environment: any): boolean {\n return this.hooks.isSupported(environment);\n }\n\n /** Creates a transport connection.\n *\n * @param {String} name\n * @param {Number} priority\n * @param {String} key the application key\n * @param {Object} options\n * @returns {TransportConnection}\n */\n createConnection(\n name: string,\n priority: number,\n key: string,\n options: any\n ): TransportConnection {\n return new TransportConnection(this.hooks, name, priority, key, options);\n }\n}\n","import * as URLSchemes from 'core/transports/url_schemes';\nimport URLScheme from 'core/transports/url_scheme';\nimport Transport from 'core/transports/transport';\nimport Util from 'core/util';\nimport * as Collections from 'core/utils/collections';\nimport TransportHooks from 'core/transports/transport_hooks';\nimport TransportsTable from 'core/transports/transports_table';\nimport Runtime from 'runtime';\n\n/** WebSocket transport.\n *\n * Uses native WebSocket implementation, including MozWebSocket supported by\n * earlier Firefox versions.\n */\nvar WSTransport = new Transport({\n urls: URLSchemes.ws,\n handlesActivityChecks: false,\n supportsPing: false,\n\n isInitialized: function() {\n return Boolean(Runtime.getWebSocketAPI());\n },\n isSupported: function(): boolean {\n return Boolean(Runtime.getWebSocketAPI());\n },\n getSocket: function(url) {\n return Runtime.createWebSocket(url);\n }\n});\n\nvar httpConfiguration = {\n urls: URLSchemes.http,\n handlesActivityChecks: false,\n supportsPing: true,\n isInitialized: function() {\n return true;\n }\n};\n\nexport var streamingConfiguration = Collections.extend(\n {\n getSocket: function(url) {\n return Runtime.HTTPFactory.createStreamingSocket(url);\n }\n },\n httpConfiguration\n);\nexport var pollingConfiguration = Collections.extend(\n {\n getSocket: function(url) {\n return Runtime.HTTPFactory.createPollingSocket(url);\n }\n },\n httpConfiguration\n);\n\nvar xhrConfiguration = {\n isSupported: function(): boolean {\n return Runtime.isXHRSupported();\n }\n};\n\n/** HTTP streaming transport using CORS-enabled XMLHttpRequest. */\nvar XHRStreamingTransport = new Transport(\n (\n Collections.extend({}, streamingConfiguration, xhrConfiguration)\n )\n);\n\n/** HTTP long-polling transport using CORS-enabled XMLHttpRequest. */\nvar XHRPollingTransport = new Transport(\n Collections.extend({}, pollingConfiguration, xhrConfiguration)\n);\n\nvar Transports: TransportsTable = {\n ws: WSTransport,\n xhr_streaming: XHRStreamingTransport,\n xhr_polling: XHRPollingTransport\n};\n\nexport default Transports;\n","import {\n default as Transports,\n streamingConfiguration,\n pollingConfiguration\n} from 'isomorphic/transports/transports';\nimport Transport from 'core/transports/transport';\nimport TransportHooks from 'core/transports/transport_hooks';\nimport * as URLSchemes from 'core/transports/url_schemes';\nimport Runtime from 'runtime';\nimport { Dependencies } from '../dom/dependencies';\nimport * as Collections from 'core/utils/collections';\n\nvar SockJSTransport = new Transport({\n file: 'sockjs',\n urls: URLSchemes.sockjs,\n handlesActivityChecks: true,\n supportsPing: false,\n\n isSupported: function() {\n return true;\n },\n isInitialized: function() {\n return window.SockJS !== undefined;\n },\n getSocket: function(url, options) {\n return new window.SockJS(url, null, {\n js_path: Dependencies.getPath('sockjs', {\n useTLS: options.useTLS\n }),\n ignore_null_origin: options.ignoreNullOrigin\n });\n },\n beforeOpen: function(socket, path) {\n socket.send(\n JSON.stringify({\n path: path\n })\n );\n }\n});\n\nvar xdrConfiguration = {\n isSupported: function(environment): boolean {\n var yes = Runtime.isXDRSupported(environment.useTLS);\n return yes;\n }\n};\n\n/** HTTP streaming transport using XDomainRequest (IE 8,9). */\nvar XDRStreamingTransport = new Transport(\n (\n Collections.extend({}, streamingConfiguration, xdrConfiguration)\n )\n);\n\n/** HTTP long-polling transport using XDomainRequest (IE 8,9). */\nvar XDRPollingTransport = new Transport(\n Collections.extend({}, pollingConfiguration, xdrConfiguration)\n);\n\nTransports.xdr_streaming = XDRStreamingTransport;\nTransports.xdr_polling = XDRPollingTransport;\nTransports.sockjs = SockJSTransport;\n\nexport default Transports;\n","import Reachability from 'core/reachability';\nimport { default as EventsDispatcher } from 'core/events/dispatcher';\n\n/** Really basic interface providing network availability info.\n *\n * Emits:\n * - online - when browser goes online\n * - offline - when browser goes offline\n */\nexport class NetInfo extends EventsDispatcher implements Reachability {\n constructor() {\n super();\n var self = this;\n // This is okay, as IE doesn't support this stuff anyway.\n if (window.addEventListener !== undefined) {\n window.addEventListener(\n 'online',\n function() {\n self.emit('online');\n },\n false\n );\n window.addEventListener(\n 'offline',\n function() {\n self.emit('offline');\n },\n false\n );\n }\n }\n\n /** Returns whether browser is online or not\n *\n * Offline means definitely offline (no connection to router).\n * Inverse does NOT mean definitely online (only currently supported in Safari\n * and even there only means the device has a connection to the router).\n *\n * @return {Boolean}\n */\n isOnline(): boolean {\n if (window.navigator.onLine === undefined) {\n return true;\n } else {\n return window.navigator.onLine;\n }\n }\n}\n\nexport var Network = new NetInfo();\n","import Util from '../util';\nimport * as Collections from '../utils/collections';\nimport TransportManager from './transport_manager';\nimport TransportConnection from './transport_connection';\nimport Transport from './transport';\nimport PingDelayOptions from './ping_delay_options';\n\n/** Creates transport connections monitored by a transport manager.\n *\n * When a transport is closed, it might mean the environment does not support\n * it. It's possible that messages get stuck in an intermediate buffer or\n * proxies terminate inactive connections. To combat these problems,\n * assistants monitor the connection lifetime, report unclean exits and\n * adjust ping timeouts to keep the connection active. The decision to disable\n * a transport is the manager's responsibility.\n *\n * @param {TransportManager} manager\n * @param {TransportConnection} transport\n * @param {Object} options\n */\nexport default class AssistantToTheTransportManager {\n manager: TransportManager;\n transport: Transport;\n minPingDelay: number;\n maxPingDelay: number;\n pingDelay: number;\n\n constructor(\n manager: TransportManager,\n transport: Transport,\n options: PingDelayOptions\n ) {\n this.manager = manager;\n this.transport = transport;\n this.minPingDelay = options.minPingDelay;\n this.maxPingDelay = options.maxPingDelay;\n this.pingDelay = undefined;\n }\n\n /** Creates a transport connection.\n *\n * This function has the same API as Transport#createConnection.\n *\n * @param {String} name\n * @param {Number} priority\n * @param {String} key the application key\n * @param {Object} options\n * @returns {TransportConnection}\n */\n createConnection(\n name: string,\n priority: number,\n key: string,\n options: Object\n ): TransportConnection {\n options = Collections.extend({}, options, {\n activityTimeout: this.pingDelay\n });\n var connection = this.transport.createConnection(\n name,\n priority,\n key,\n options\n );\n\n var openTimestamp = null;\n\n var onOpen = function() {\n connection.unbind('open', onOpen);\n connection.bind('closed', onClosed);\n openTimestamp = Util.now();\n };\n var onClosed = closeEvent => {\n connection.unbind('closed', onClosed);\n\n if (closeEvent.code === 1002 || closeEvent.code === 1003) {\n // we don't want to use transports not obeying the protocol\n this.manager.reportDeath();\n } else if (!closeEvent.wasClean && openTimestamp) {\n // report deaths only for short-living transport\n var lifespan = Util.now() - openTimestamp;\n if (lifespan < 2 * this.maxPingDelay) {\n this.manager.reportDeath();\n this.pingDelay = Math.max(lifespan / 2, this.minPingDelay);\n }\n }\n };\n\n connection.bind('open', onOpen);\n return connection;\n }\n\n /** Returns whether the transport is supported in the environment.\n *\n * This function has the same API as Transport#isSupported. Might return false\n * when the manager decides to kill the transport.\n *\n * @param {Object} environment the environment details (encryption, settings)\n * @returns {Boolean} true when the transport is supported\n */\n isSupported(environment: string): boolean {\n return this.manager.isAlive() && this.transport.isSupported(environment);\n }\n}\n","import Action from './action';\nimport { PusherEvent } from './message-types';\n/**\n * Provides functions for handling Pusher protocol-specific messages.\n */\n\nconst Protocol = {\n /**\n * Decodes a message in a Pusher format.\n *\n * The MessageEvent we receive from the transport should contain a pusher event\n * (https://pusher.com/docs/pusher_protocol#events) serialized as JSON in the\n * data field\n *\n * The pusher event may contain a data field too, and it may also be\n * serialised as JSON\n *\n * Throws errors when messages are not parse'able.\n *\n * @param {MessageEvent} messageEvent\n * @return {PusherEvent}\n */\n decodeMessage: function(messageEvent: MessageEvent): PusherEvent {\n try {\n var messageData = JSON.parse(messageEvent.data);\n var pusherEventData = messageData.data;\n if (typeof pusherEventData === 'string') {\n try {\n pusherEventData = JSON.parse(messageData.data);\n } catch (e) {}\n }\n var pusherEvent: PusherEvent = {\n event: messageData.event,\n channel: messageData.channel,\n data: pusherEventData\n };\n if (messageData.user_id) {\n pusherEvent.user_id = messageData.user_id;\n }\n return pusherEvent;\n } catch (e) {\n throw { type: 'MessageParseError', error: e, data: messageEvent.data };\n }\n },\n\n /**\n * Encodes a message to be sent.\n *\n * @param {PusherEvent} event\n * @return {String}\n */\n encodeMessage: function(event: PusherEvent): string {\n return JSON.stringify(event);\n },\n\n /**\n * Processes a handshake message and returns appropriate actions.\n *\n * Returns an object with an 'action' and other action-specific properties.\n *\n * There are three outcomes when calling this function. First is a successful\n * connection attempt, when pusher:connection_established is received, which\n * results in a 'connected' action with an 'id' property. When passed a\n * pusher:error event, it returns a result with action appropriate to the\n * close code and an error. Otherwise, it raises an exception.\n *\n * @param {String} message\n * @result Object\n */\n processHandshake: function(messageEvent: MessageEvent): Action {\n var message = Protocol.decodeMessage(messageEvent);\n\n if (message.event === 'pusher:connection_established') {\n if (!message.data.activity_timeout) {\n throw 'No activity timeout specified in handshake';\n }\n return {\n action: 'connected',\n id: message.data.socket_id,\n activityTimeout: message.data.activity_timeout * 1000\n };\n } else if (message.event === 'pusher:error') {\n // From protocol 6 close codes are sent only once, so this only\n // happens when connection does not support close codes\n return {\n action: this.getCloseAction(message.data),\n error: this.getCloseError(message.data)\n };\n } else {\n throw 'Invalid handshake';\n }\n },\n\n /**\n * Dispatches the close event and returns an appropriate action name.\n *\n * See:\n * 1. https://developer.mozilla.org/en-US/docs/WebSockets/WebSockets_reference/CloseEvent\n * 2. http://pusher.com/docs/pusher_protocol\n *\n * @param {CloseEvent} closeEvent\n * @return {String} close action name\n */\n getCloseAction: function(closeEvent): string {\n if (closeEvent.code < 4000) {\n // ignore 1000 CLOSE_NORMAL, 1001 CLOSE_GOING_AWAY,\n // 1005 CLOSE_NO_STATUS, 1006 CLOSE_ABNORMAL\n // ignore 1007...3999\n // handle 1002 CLOSE_PROTOCOL_ERROR, 1003 CLOSE_UNSUPPORTED,\n // 1004 CLOSE_TOO_LARGE\n if (closeEvent.code >= 1002 && closeEvent.code <= 1004) {\n return 'backoff';\n } else {\n return null;\n }\n } else if (closeEvent.code === 4000) {\n return 'tls_only';\n } else if (closeEvent.code < 4100) {\n return 'refused';\n } else if (closeEvent.code < 4200) {\n return 'backoff';\n } else if (closeEvent.code < 4300) {\n return 'retry';\n } else {\n // unknown error\n return 'refused';\n }\n },\n\n /**\n * Returns an error or null basing on the close event.\n *\n * Null is returned when connection was closed cleanly. Otherwise, an object\n * with error details is returned.\n *\n * @param {CloseEvent} closeEvent\n * @return {Object} error object\n */\n getCloseError: function(closeEvent): any {\n if (closeEvent.code !== 1000 && closeEvent.code !== 1001) {\n return {\n type: 'PusherError',\n data: {\n code: closeEvent.code,\n message: closeEvent.reason || closeEvent.message\n }\n };\n } else {\n return null;\n }\n }\n};\n\nexport default Protocol;\n","import * as Collections from '../utils/collections';\nimport { default as EventsDispatcher } from '../events/dispatcher';\nimport Protocol from './protocol/protocol';\nimport { PusherEvent } from './protocol/message-types';\nimport Logger from '../logger';\nimport TransportConnection from '../transports/transport_connection';\nimport Socket from '../socket';\n/**\n * Provides Pusher protocol interface for transports.\n *\n * Emits following events:\n * - message - on received messages\n * - ping - on ping requests\n * - pong - on pong responses\n * - error - when the transport emits an error\n * - closed - after closing the transport\n *\n * It also emits more events when connection closes with a code.\n * See Protocol.getCloseAction to get more details.\n *\n * @param {Number} id\n * @param {AbstractTransport} transport\n */\nexport default class Connection extends EventsDispatcher implements Socket {\n id: string;\n transport: TransportConnection;\n activityTimeout: number;\n\n constructor(id: string, transport: TransportConnection) {\n super();\n this.id = id;\n this.transport = transport;\n this.activityTimeout = transport.activityTimeout;\n this.bindListeners();\n }\n\n /** Returns whether used transport handles activity checks by itself\n *\n * @returns {Boolean} true if activity checks are handled by the transport\n */\n handlesActivityChecks() {\n return this.transport.handlesActivityChecks();\n }\n\n /** Sends raw data.\n *\n * @param {String} data\n */\n send(data: any): boolean {\n return this.transport.send(data);\n }\n\n /** Sends an event.\n *\n * @param {String} name\n * @param {String} data\n * @param {String} [channel]\n * @returns {Boolean} whether message was sent or not\n */\n send_event(name: string, data: any, channel?: string): boolean {\n var event: PusherEvent = { event: name, data: data };\n if (channel) {\n event.channel = channel;\n }\n Logger.debug('Event sent', event);\n return this.send(Protocol.encodeMessage(event));\n }\n\n /** Sends a ping message to the server.\n *\n * Basing on the underlying transport, it might send either transport's\n * protocol-specific ping or pusher:ping event.\n */\n ping() {\n if (this.transport.supportsPing()) {\n this.transport.ping();\n } else {\n this.send_event('pusher:ping', {});\n }\n }\n\n /** Closes the connection. */\n close() {\n this.transport.close();\n }\n\n private bindListeners() {\n var listeners = {\n message: (messageEvent: MessageEvent) => {\n var pusherEvent;\n try {\n pusherEvent = Protocol.decodeMessage(messageEvent);\n } catch (e) {\n this.emit('error', {\n type: 'MessageParseError',\n error: e,\n data: messageEvent.data\n });\n }\n\n if (pusherEvent !== undefined) {\n Logger.debug('Event recd', pusherEvent);\n\n switch (pusherEvent.event) {\n case 'pusher:error':\n this.emit('error', {\n type: 'PusherError',\n data: pusherEvent.data\n });\n break;\n case 'pusher:ping':\n this.emit('ping');\n break;\n case 'pusher:pong':\n this.emit('pong');\n break;\n }\n this.emit('message', pusherEvent);\n }\n },\n activity: () => {\n this.emit('activity');\n },\n error: error => {\n this.emit('error', error);\n },\n closed: closeEvent => {\n unbindListeners();\n\n if (closeEvent && closeEvent.code) {\n this.handleCloseEvent(closeEvent);\n }\n\n this.transport = null;\n this.emit('closed');\n }\n };\n\n var unbindListeners = () => {\n Collections.objectApply(listeners, (listener, event) => {\n this.transport.unbind(event, listener);\n });\n };\n\n Collections.objectApply(listeners, (listener, event) => {\n this.transport.bind(event, listener);\n });\n }\n\n private handleCloseEvent(closeEvent: any) {\n var action = Protocol.getCloseAction(closeEvent);\n var error = Protocol.getCloseError(closeEvent);\n if (error) {\n this.emit('error', error);\n }\n if (action) {\n this.emit(action, { action: action, error: error });\n }\n }\n}\n","import Util from '../../util';\nimport * as Collections from '../../utils/collections';\nimport Protocol from '../protocol/protocol';\nimport Connection from '../connection';\nimport TransportConnection from '../../transports/transport_connection';\nimport HandshakePayload from './handshake_payload';\n\n/**\n * Handles Pusher protocol handshakes for transports.\n *\n * Calls back with a result object after handshake is completed. Results\n * always have two fields:\n * - action - string describing action to be taken after the handshake\n * - transport - the transport object passed to the constructor\n *\n * Different actions can set different additional properties on the result.\n * In the case of 'connected' action, there will be a 'connection' property\n * containing a Connection object for the transport. Other actions should\n * carry an 'error' property.\n *\n * @param {AbstractTransport} transport\n * @param {Function} callback\n */\nexport default class Handshake {\n transport: TransportConnection;\n callback: (HandshakePayload) => void;\n onMessage: Function;\n onClosed: Function;\n\n constructor(\n transport: TransportConnection,\n callback: (HandshakePayload) => void\n ) {\n this.transport = transport;\n this.callback = callback;\n this.bindListeners();\n }\n\n close() {\n this.unbindListeners();\n this.transport.close();\n }\n\n private bindListeners() {\n this.onMessage = m => {\n this.unbindListeners();\n\n var result;\n try {\n result = Protocol.processHandshake(m);\n } catch (e) {\n this.finish('error', { error: e });\n this.transport.close();\n return;\n }\n\n if (result.action === 'connected') {\n this.finish('connected', {\n connection: new Connection(result.id, this.transport),\n activityTimeout: result.activityTimeout\n });\n } else {\n this.finish(result.action, { error: result.error });\n this.transport.close();\n }\n };\n\n this.onClosed = closeEvent => {\n this.unbindListeners();\n\n var action = Protocol.getCloseAction(closeEvent) || 'backoff';\n var error = Protocol.getCloseError(closeEvent);\n this.finish(action, { error: error });\n };\n\n this.transport.bind('message', this.onMessage);\n this.transport.bind('closed', this.onClosed);\n }\n\n private unbindListeners() {\n this.transport.unbind('message', this.onMessage);\n this.transport.unbind('closed', this.onClosed);\n }\n\n private finish(action: string, params: any) {\n this.callback(\n Collections.extend({ transport: this.transport, action: action }, params)\n );\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport base64encode from '../base64';\nimport Timeline from './timeline';\nimport Runtime from 'runtime';\n\nexport interface TimelineSenderOptions {\n host?: string;\n port?: number;\n path?: string;\n}\n\nexport default class TimelineSender {\n timeline: Timeline;\n options: TimelineSenderOptions;\n host: string;\n\n constructor(timeline: Timeline, options: TimelineSenderOptions) {\n this.timeline = timeline;\n this.options = options || {};\n }\n\n send(useTLS: boolean, callback?: Function) {\n if (this.timeline.isEmpty()) {\n return;\n }\n\n this.timeline.send(\n Runtime.TimelineTransport.getAgent(this, useTLS),\n callback\n );\n }\n}\n","import { default as EventsDispatcher } from '../events/dispatcher';\nimport * as Errors from '../errors';\nimport Logger from '../logger';\nimport Pusher from '../pusher';\nimport { PusherEvent } from '../connection/protocol/message-types';\nimport Metadata from './metadata';\nimport UrlStore from '../utils/url_store';\nimport {\n ChannelAuthorizationData,\n ChannelAuthorizationCallback\n} from '../auth/options';\nimport { HTTPAuthError } from '../errors';\n\n/** Provides base public channel interface with an event emitter.\n *\n * Emits:\n * - pusher:subscription_succeeded - after subscribing successfully\n * - other non-internal events\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\nexport default class Channel extends EventsDispatcher {\n name: string;\n pusher: Pusher;\n subscribed: boolean;\n subscriptionPending: boolean;\n subscriptionCancelled: boolean;\n subscriptionCount: null;\n\n constructor(name: string, pusher: Pusher) {\n super(function(event, data) {\n Logger.debug('No callbacks on ' + name + ' for ' + event);\n });\n\n this.name = name;\n this.pusher = pusher;\n this.subscribed = false;\n this.subscriptionPending = false;\n this.subscriptionCancelled = false;\n }\n\n /** Skips authorization, since public channels don't require it.\n *\n * @param {Function} callback\n */\n authorize(socketId: string, callback: ChannelAuthorizationCallback) {\n return callback(null, { auth: '' });\n }\n\n /** Triggers an event */\n trigger(event: string, data: any) {\n if (event.indexOf('client-') !== 0) {\n throw new Errors.BadEventName(\n \"Event '\" + event + \"' does not start with 'client-'\"\n );\n }\n if (!this.subscribed) {\n var suffix = UrlStore.buildLogSuffix('triggeringClientEvents');\n Logger.warn(\n `Client event triggered before channel 'subscription_succeeded' event . ${suffix}`\n );\n }\n return this.pusher.send_event(event, data, this.name);\n }\n\n /** Signals disconnection to the channel. For internal use only. */\n disconnect() {\n this.subscribed = false;\n this.subscriptionPending = false;\n }\n\n /** Handles a PusherEvent. For internal use only.\n *\n * @param {PusherEvent} event\n */\n handleEvent(event: PusherEvent) {\n var eventName = event.event;\n var data = event.data;\n if (eventName === 'pusher_internal:subscription_succeeded') {\n this.handleSubscriptionSucceededEvent(event);\n } else if (eventName === 'pusher_internal:subscription_count') {\n this.handleSubscriptionCountEvent(event);\n } else if (eventName.indexOf('pusher_internal:') !== 0) {\n var metadata: Metadata = {};\n this.emit(eventName, data, metadata);\n }\n }\n\n handleSubscriptionSucceededEvent(event: PusherEvent) {\n this.subscriptionPending = false;\n this.subscribed = true;\n if (this.subscriptionCancelled) {\n this.pusher.unsubscribe(this.name);\n } else {\n this.emit('pusher:subscription_succeeded', event.data);\n }\n }\n\n handleSubscriptionCountEvent(event: PusherEvent) {\n if (event.data.subscription_count) {\n this.subscriptionCount = event.data.subscription_count;\n }\n\n this.emit('pusher:subscription_count', event.data);\n }\n\n /** Sends a subscription request. For internal use only. */\n subscribe() {\n if (this.subscribed) {\n return;\n }\n this.subscriptionPending = true;\n this.subscriptionCancelled = false;\n this.authorize(\n this.pusher.connection.socket_id,\n (error: Error | null, data: ChannelAuthorizationData) => {\n if (error) {\n this.subscriptionPending = false;\n // Why not bind to 'pusher:subscription_error' a level up, and log there?\n // Binding to this event would cause the warning about no callbacks being\n // bound (see constructor) to be suppressed, that's not what we want.\n Logger.error(error.toString());\n this.emit(\n 'pusher:subscription_error',\n Object.assign(\n {},\n {\n type: 'AuthError',\n error: error.message\n },\n error instanceof HTTPAuthError ? { status: error.status } : {}\n )\n );\n } else {\n this.pusher.send_event('pusher:subscribe', {\n auth: data.auth,\n channel_data: data.channel_data,\n channel: this.name\n });\n }\n }\n );\n }\n\n /** Sends an unsubscription request. For internal use only. */\n unsubscribe() {\n this.subscribed = false;\n this.pusher.send_event('pusher:unsubscribe', {\n channel: this.name\n });\n }\n\n /** Cancels an in progress subscription. For internal use only. */\n cancelSubscription() {\n this.subscriptionCancelled = true;\n }\n\n /** Reinstates an in progress subscripiton. For internal use only. */\n reinstateSubscription() {\n this.subscriptionCancelled = false;\n }\n}\n","import Factory from '../utils/factory';\nimport Channel from './channel';\nimport { ChannelAuthorizationCallback } from '../auth/options';\n\n/** Extends public channels to provide private channel interface.\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\nexport default class PrivateChannel extends Channel {\n /** Authorizes the connection to use the channel.\n *\n * @param {String} socketId\n * @param {Function} callback\n */\n authorize(socketId: string, callback: ChannelAuthorizationCallback) {\n return this.pusher.config.channelAuthorizer(\n {\n channelName: this.name,\n socketId: socketId\n },\n callback\n );\n }\n}\n","import * as Collections from '../utils/collections';\n\n/** Represents a collection of members of a presence channel. */\nexport default class Members {\n members: any;\n count: number;\n myID: any;\n me: any;\n\n constructor() {\n this.reset();\n }\n\n /** Returns member's info for given id.\n *\n * Resulting object containts two fields - id and info.\n *\n * @param {Number} id\n * @return {Object} member's info or null\n */\n get(id: string): any {\n if (Object.prototype.hasOwnProperty.call(this.members, id)) {\n return {\n id: id,\n info: this.members[id]\n };\n } else {\n return null;\n }\n }\n\n /** Calls back for each member in unspecified order.\n *\n * @param {Function} callback\n */\n each(callback: Function) {\n Collections.objectApply(this.members, (member, id) => {\n callback(this.get(id));\n });\n }\n\n /** Updates the id for connected member. For internal use only. */\n setMyID(id: string) {\n this.myID = id;\n }\n\n /** Handles subscription data. For internal use only. */\n onSubscription(subscriptionData: any) {\n this.members = subscriptionData.presence.hash;\n this.count = subscriptionData.presence.count;\n this.me = this.get(this.myID);\n }\n\n /** Adds a new member to the collection. For internal use only. */\n addMember(memberData: any) {\n if (this.get(memberData.user_id) === null) {\n this.count++;\n }\n this.members[memberData.user_id] = memberData.user_info;\n return this.get(memberData.user_id);\n }\n\n /** Adds a member from the collection. For internal use only. */\n removeMember(memberData: any) {\n var member = this.get(memberData.user_id);\n if (member) {\n delete this.members[memberData.user_id];\n this.count--;\n }\n return member;\n }\n\n /** Resets the collection to the initial state. For internal use only. */\n reset() {\n this.members = {};\n this.count = 0;\n this.myID = null;\n this.me = null;\n }\n}\n","import PrivateChannel from './private_channel';\nimport Logger from '../logger';\nimport Members from './members';\nimport Pusher from '../pusher';\nimport UrlStore from 'core/utils/url_store';\nimport { PusherEvent } from '../connection/protocol/message-types';\nimport Metadata from './metadata';\nimport { ChannelAuthorizationData } from '../auth/options';\n\nexport default class PresenceChannel extends PrivateChannel {\n members: Members;\n\n /** Adds presence channel functionality to private channels.\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\n constructor(name: string, pusher: Pusher) {\n super(name, pusher);\n this.members = new Members();\n }\n\n /** Authorizes the connection as a member of the channel.\n *\n * @param {String} socketId\n * @param {Function} callback\n */\n authorize(socketId: string, callback: Function) {\n super.authorize(socketId, async (error, authData) => {\n if (!error) {\n authData = authData as ChannelAuthorizationData;\n if (authData.channel_data != null) {\n var channelData = JSON.parse(authData.channel_data);\n this.members.setMyID(channelData.user_id);\n } else {\n await this.pusher.user.signinDonePromise;\n if (this.pusher.user.user_data != null) {\n // If the user is signed in, get the id of the authenticated user\n // and allow the presence authorization to continue.\n this.members.setMyID(this.pusher.user.user_data.id);\n } else {\n let suffix = UrlStore.buildLogSuffix('authorizationEndpoint');\n Logger.error(\n `Invalid auth response for channel '${this.name}', ` +\n `expected 'channel_data' field. ${suffix}, ` +\n `or the user should be signed in.`\n );\n callback('Invalid auth response');\n return;\n }\n }\n }\n callback(error, authData);\n });\n }\n\n /** Handles presence and subscription events. For internal use only.\n *\n * @param {PusherEvent} event\n */\n handleEvent(event: PusherEvent) {\n var eventName = event.event;\n if (eventName.indexOf('pusher_internal:') === 0) {\n this.handleInternalEvent(event);\n } else {\n var data = event.data;\n var metadata: Metadata = {};\n if (event.user_id) {\n metadata.user_id = event.user_id;\n }\n this.emit(eventName, data, metadata);\n }\n }\n handleInternalEvent(event: PusherEvent) {\n var eventName = event.event;\n var data = event.data;\n switch (eventName) {\n case 'pusher_internal:subscription_succeeded':\n this.handleSubscriptionSucceededEvent(event);\n break;\n case 'pusher_internal:subscription_count':\n this.handleSubscriptionCountEvent(event);\n break;\n case 'pusher_internal:member_added':\n var addedMember = this.members.addMember(data);\n this.emit('pusher:member_added', addedMember);\n break;\n case 'pusher_internal:member_removed':\n var removedMember = this.members.removeMember(data);\n if (removedMember) {\n this.emit('pusher:member_removed', removedMember);\n }\n break;\n }\n }\n\n handleSubscriptionSucceededEvent(event: PusherEvent) {\n this.subscriptionPending = false;\n this.subscribed = true;\n if (this.subscriptionCancelled) {\n this.pusher.unsubscribe(this.name);\n } else {\n this.members.onSubscription(event.data);\n this.emit('pusher:subscription_succeeded', this.members);\n }\n }\n\n /** Resets the channel state, including members map. For internal use only. */\n disconnect() {\n this.members.reset();\n super.disconnect();\n }\n}\n","import PrivateChannel from './private_channel';\nimport * as Errors from '../errors';\nimport Logger from '../logger';\nimport Pusher from '../pusher';\nimport { decode as encodeUTF8 } from '@stablelib/utf8';\nimport { decode as decodeBase64 } from '@stablelib/base64';\nimport Dispatcher from '../events/dispatcher';\nimport { PusherEvent } from '../connection/protocol/message-types';\nimport {\n ChannelAuthorizationData,\n ChannelAuthorizationCallback\n} from '../auth/options';\nimport * as nacl from 'tweetnacl';\n\n/** Extends private channels to provide encrypted channel interface.\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\nexport default class EncryptedChannel extends PrivateChannel {\n key: Uint8Array = null;\n nacl: nacl;\n\n constructor(name: string, pusher: Pusher, nacl: nacl) {\n super(name, pusher);\n this.nacl = nacl;\n }\n\n /** Authorizes the connection to use the channel.\n *\n * @param {String} socketId\n * @param {Function} callback\n */\n authorize(socketId: string, callback: ChannelAuthorizationCallback) {\n super.authorize(\n socketId,\n (error: Error | null, authData: ChannelAuthorizationData) => {\n if (error) {\n callback(error, authData);\n return;\n }\n let sharedSecret = authData['shared_secret'];\n if (!sharedSecret) {\n callback(\n new Error(\n `No shared_secret key in auth payload for encrypted channel: ${this.name}`\n ),\n null\n );\n return;\n }\n this.key = decodeBase64(sharedSecret);\n delete authData['shared_secret'];\n callback(null, authData);\n }\n );\n }\n\n trigger(event: string, data: any): boolean {\n throw new Errors.UnsupportedFeature(\n 'Client events are not currently supported for encrypted channels'\n );\n }\n\n /** Handles an event. For internal use only.\n *\n * @param {PusherEvent} event\n */\n handleEvent(event: PusherEvent) {\n var eventName = event.event;\n var data = event.data;\n if (\n eventName.indexOf('pusher_internal:') === 0 ||\n eventName.indexOf('pusher:') === 0\n ) {\n super.handleEvent(event);\n return;\n }\n this.handleEncryptedEvent(eventName, data);\n }\n\n private handleEncryptedEvent(event: string, data: any): void {\n if (!this.key) {\n Logger.debug(\n 'Received encrypted event before key has been retrieved from the authEndpoint'\n );\n return;\n }\n if (!data.ciphertext || !data.nonce) {\n Logger.error(\n 'Unexpected format for encrypted event, expected object with `ciphertext` and `nonce` fields, got: ' +\n data\n );\n return;\n }\n let cipherText = decodeBase64(data.ciphertext);\n if (cipherText.length < this.nacl.secretbox.overheadLength) {\n Logger.error(\n `Expected encrypted event ciphertext length to be ${this.nacl.secretbox.overheadLength}, got: ${cipherText.length}`\n );\n return;\n }\n let nonce = decodeBase64(data.nonce);\n if (nonce.length < this.nacl.secretbox.nonceLength) {\n Logger.error(\n `Expected encrypted event nonce length to be ${this.nacl.secretbox.nonceLength}, got: ${nonce.length}`\n );\n return;\n }\n\n let bytes = this.nacl.secretbox.open(cipherText, nonce, this.key);\n if (bytes === null) {\n Logger.debug(\n 'Failed to decrypt an event, probably because it was encrypted with a different key. Fetching a new key from the authEndpoint...'\n );\n // Try a single time to retrieve a new auth key and decrypt the event with it\n // If this fails, a new key will be requested when a new message is received\n this.authorize(this.pusher.connection.socket_id, (error, authData) => {\n if (error) {\n Logger.error(\n `Failed to make a request to the authEndpoint: ${authData}. Unable to fetch new key, so dropping encrypted event`\n );\n return;\n }\n bytes = this.nacl.secretbox.open(cipherText, nonce, this.key);\n if (bytes === null) {\n Logger.error(\n `Failed to decrypt event with new key. Dropping encrypted event`\n );\n return;\n }\n this.emit(event, this.getDataToEmit(bytes));\n return;\n });\n return;\n }\n this.emit(event, this.getDataToEmit(bytes));\n }\n\n // Try and parse the decrypted bytes as JSON. If we can't parse it, just\n // return the utf-8 string\n getDataToEmit(bytes: Uint8Array): string {\n let raw = encodeUTF8(bytes);\n try {\n return JSON.parse(raw);\n } catch {\n return raw;\n }\n }\n}\n","import { default as EventsDispatcher } from '../events/dispatcher';\nimport { OneOffTimer as Timer } from '../utils/timers';\nimport { Config } from '../config';\nimport Logger from '../logger';\nimport HandshakePayload from './handshake/handshake_payload';\nimport Connection from './connection';\nimport Strategy from '../strategies/strategy';\nimport StrategyRunner from '../strategies/strategy_runner';\nimport * as Collections from '../utils/collections';\nimport Timeline from '../timeline/timeline';\nimport ConnectionManagerOptions from './connection_manager_options';\nimport Runtime from 'runtime';\n\nimport {\n ErrorCallbacks,\n HandshakeCallbacks,\n ConnectionCallbacks\n} from './callbacks';\nimport Action from './protocol/action';\n\n/** Manages connection to Pusher.\n *\n * Uses a strategy (currently only default), timers and network availability\n * info to establish a connection and export its state. In case of failures,\n * manages reconnection attempts.\n *\n * Exports state changes as following events:\n * - \"state_change\", { previous: p, current: state }\n * - state\n *\n * States:\n * - initialized - initial state, never transitioned to\n * - connecting - connection is being established\n * - connected - connection has been fully established\n * - disconnected - on requested disconnection\n * - unavailable - after connection timeout or when there's no network\n * - failed - when the connection strategy is not supported\n *\n * Options:\n * - unavailableTimeout - time to transition to unavailable state\n * - activityTimeout - time after which ping message should be sent\n * - pongTimeout - time for Pusher to respond with pong before reconnecting\n *\n * @param {String} key application key\n * @param {Object} options\n */\nexport default class ConnectionManager extends EventsDispatcher {\n key: string;\n options: ConnectionManagerOptions;\n state: string;\n connection: Connection;\n usingTLS: boolean;\n timeline: Timeline;\n socket_id: string;\n unavailableTimer: Timer;\n activityTimer: Timer;\n retryTimer: Timer;\n activityTimeout: number;\n strategy: Strategy;\n runner: StrategyRunner;\n errorCallbacks: ErrorCallbacks;\n handshakeCallbacks: HandshakeCallbacks;\n connectionCallbacks: ConnectionCallbacks;\n\n constructor(key: string, options: ConnectionManagerOptions) {\n super();\n this.state = 'initialized';\n this.connection = null;\n\n this.key = key;\n this.options = options;\n this.timeline = this.options.timeline;\n this.usingTLS = this.options.useTLS;\n\n this.errorCallbacks = this.buildErrorCallbacks();\n this.connectionCallbacks = this.buildConnectionCallbacks(\n this.errorCallbacks\n );\n this.handshakeCallbacks = this.buildHandshakeCallbacks(this.errorCallbacks);\n\n var Network = Runtime.getNetwork();\n\n Network.bind('online', () => {\n this.timeline.info({ netinfo: 'online' });\n if (this.state === 'connecting' || this.state === 'unavailable') {\n this.retryIn(0);\n }\n });\n Network.bind('offline', () => {\n this.timeline.info({ netinfo: 'offline' });\n if (this.connection) {\n this.sendActivityCheck();\n }\n });\n\n this.updateStrategy();\n }\n\n switchCluster(key: string) {\n this.key = key;\n // This ensures that the new config coming from\n // pusher instance are taken into account\n // such as appKey and cluster\n this.updateStrategy();\n this.retryIn(0);\n }\n\n /** Establishes a connection to Pusher.\n *\n * Does nothing when connection is already established. See top-level doc\n * to find events emitted on connection attempts.\n */\n connect() {\n if (this.connection || this.runner) {\n return;\n }\n if (!this.strategy.isSupported()) {\n this.updateState('failed');\n return;\n }\n this.updateState('connecting');\n this.startConnecting();\n this.setUnavailableTimer();\n }\n\n /** Sends raw data.\n *\n * @param {String} data\n */\n send(data) {\n if (this.connection) {\n return this.connection.send(data);\n } else {\n return false;\n }\n }\n\n /** Sends an event.\n *\n * @param {String} name\n * @param {String} data\n * @param {String} [channel]\n * @returns {Boolean} whether message was sent or not\n */\n send_event(name: string, data: any, channel?: string) {\n if (this.connection) {\n return this.connection.send_event(name, data, channel);\n } else {\n return false;\n }\n }\n\n /** Closes the connection. */\n disconnect() {\n this.disconnectInternally();\n this.updateState('disconnected');\n }\n\n isUsingTLS() {\n return this.usingTLS;\n }\n\n private startConnecting() {\n var callback = (error, handshake) => {\n if (error) {\n this.runner = this.strategy.connect(0, callback);\n } else {\n if (handshake.action === 'error') {\n this.emit('error', {\n type: 'HandshakeError',\n error: handshake.error\n });\n this.timeline.error({ handshakeError: handshake.error });\n } else {\n this.abortConnecting(); // we don't support switching connections yet\n this.handshakeCallbacks[handshake.action](handshake);\n }\n }\n };\n this.runner = this.strategy.connect(0, callback);\n }\n\n private abortConnecting() {\n if (this.runner) {\n this.runner.abort();\n this.runner = null;\n }\n }\n\n private disconnectInternally() {\n this.abortConnecting();\n this.clearRetryTimer();\n this.clearUnavailableTimer();\n if (this.connection) {\n var connection = this.abandonConnection();\n connection.close();\n }\n }\n\n private updateStrategy() {\n this.strategy = this.options.getStrategy({\n key: this.key,\n timeline: this.timeline,\n useTLS: this.usingTLS\n });\n }\n\n private retryIn(delay) {\n this.timeline.info({ action: 'retry', delay: delay });\n if (delay > 0) {\n this.emit('connecting_in', Math.round(delay / 1000));\n }\n this.retryTimer = new Timer(delay || 0, () => {\n this.disconnectInternally();\n this.connect();\n });\n }\n\n private clearRetryTimer() {\n if (this.retryTimer) {\n this.retryTimer.ensureAborted();\n this.retryTimer = null;\n }\n }\n\n private setUnavailableTimer() {\n this.unavailableTimer = new Timer(this.options.unavailableTimeout, () => {\n this.updateState('unavailable');\n });\n }\n\n private clearUnavailableTimer() {\n if (this.unavailableTimer) {\n this.unavailableTimer.ensureAborted();\n }\n }\n\n private sendActivityCheck() {\n this.stopActivityCheck();\n this.connection.ping();\n // wait for pong response\n this.activityTimer = new Timer(this.options.pongTimeout, () => {\n this.timeline.error({ pong_timed_out: this.options.pongTimeout });\n this.retryIn(0);\n });\n }\n\n private resetActivityCheck() {\n this.stopActivityCheck();\n // send ping after inactivity\n if (this.connection && !this.connection.handlesActivityChecks()) {\n this.activityTimer = new Timer(this.activityTimeout, () => {\n this.sendActivityCheck();\n });\n }\n }\n\n private stopActivityCheck() {\n if (this.activityTimer) {\n this.activityTimer.ensureAborted();\n }\n }\n\n private buildConnectionCallbacks(\n errorCallbacks: ErrorCallbacks\n ): ConnectionCallbacks {\n return Collections.extend({}, errorCallbacks, {\n message: message => {\n // includes pong messages from server\n this.resetActivityCheck();\n this.emit('message', message);\n },\n ping: () => {\n this.send_event('pusher:pong', {});\n },\n activity: () => {\n this.resetActivityCheck();\n },\n error: error => {\n // just emit error to user - socket will already be closed by browser\n this.emit('error', error);\n },\n closed: () => {\n this.abandonConnection();\n if (this.shouldRetry()) {\n this.retryIn(1000);\n }\n }\n });\n }\n\n private buildHandshakeCallbacks(\n errorCallbacks: ErrorCallbacks\n ): HandshakeCallbacks {\n return Collections.extend({}, errorCallbacks, {\n connected: (handshake: HandshakePayload) => {\n this.activityTimeout = Math.min(\n this.options.activityTimeout,\n handshake.activityTimeout,\n handshake.connection.activityTimeout || Infinity\n );\n this.clearUnavailableTimer();\n this.setConnection(handshake.connection);\n this.socket_id = this.connection.id;\n this.updateState('connected', { socket_id: this.socket_id });\n }\n });\n }\n\n private buildErrorCallbacks(): ErrorCallbacks {\n let withErrorEmitted = callback => {\n return (result: Action | HandshakePayload) => {\n if (result.error) {\n this.emit('error', { type: 'WebSocketError', error: result.error });\n }\n callback(result);\n };\n };\n\n return {\n tls_only: withErrorEmitted(() => {\n this.usingTLS = true;\n this.updateStrategy();\n this.retryIn(0);\n }),\n refused: withErrorEmitted(() => {\n this.disconnect();\n }),\n backoff: withErrorEmitted(() => {\n this.retryIn(1000);\n }),\n retry: withErrorEmitted(() => {\n this.retryIn(0);\n })\n };\n }\n\n private setConnection(connection) {\n this.connection = connection;\n for (var event in this.connectionCallbacks) {\n this.connection.bind(event, this.connectionCallbacks[event]);\n }\n this.resetActivityCheck();\n }\n\n private abandonConnection() {\n if (!this.connection) {\n return;\n }\n this.stopActivityCheck();\n for (var event in this.connectionCallbacks) {\n this.connection.unbind(event, this.connectionCallbacks[event]);\n }\n var connection = this.connection;\n this.connection = null;\n return connection;\n }\n\n private updateState(newState: string, data?: any) {\n var previousState = this.state;\n this.state = newState;\n if (previousState !== newState) {\n var newStateDescription = newState;\n if (newStateDescription === 'connected') {\n newStateDescription += ' with new socket ID ' + data.socket_id;\n }\n Logger.debug(\n 'State changed',\n previousState + ' -> ' + newStateDescription\n );\n this.timeline.info({ state: newState, params: data });\n this.emit('state_change', { previous: previousState, current: newState });\n this.emit(newState, data);\n }\n }\n\n private shouldRetry(): boolean {\n return this.state === 'connecting' || this.state === 'connected';\n }\n}\n","import Channel from './channel';\nimport * as Collections from '../utils/collections';\nimport ChannelTable from './channel_table';\nimport Factory from '../utils/factory';\nimport Pusher from '../pusher';\nimport Logger from '../logger';\nimport * as Errors from '../errors';\nimport urlStore from '../utils/url_store';\n\n/** Handles a channel map. */\nexport default class Channels {\n channels: ChannelTable;\n\n constructor() {\n this.channels = {};\n }\n\n /** Creates or retrieves an existing channel by its name.\n *\n * @param {String} name\n * @param {Pusher} pusher\n * @return {Channel}\n */\n add(name: string, pusher: Pusher) {\n if (!this.channels[name]) {\n this.channels[name] = createChannel(name, pusher);\n }\n return this.channels[name];\n }\n\n /** Returns a list of all channels\n *\n * @return {Array}\n */\n all(): Channel[] {\n return Collections.values(this.channels);\n }\n\n /** Finds a channel by its name.\n *\n * @param {String} name\n * @return {Channel} channel or null if it doesn't exist\n */\n find(name: string) {\n return this.channels[name];\n }\n\n /** Removes a channel from the map.\n *\n * @param {String} name\n */\n remove(name: string) {\n var channel = this.channels[name];\n delete this.channels[name];\n return channel;\n }\n\n /** Proxies disconnection signal to all channels. */\n disconnect() {\n Collections.objectApply(this.channels, function(channel) {\n channel.disconnect();\n });\n }\n}\n\nfunction createChannel(name: string, pusher: Pusher): Channel {\n if (name.indexOf('private-encrypted-') === 0) {\n if (pusher.config.nacl) {\n return Factory.createEncryptedChannel(name, pusher, pusher.config.nacl);\n }\n let errMsg =\n 'Tried to subscribe to a private-encrypted- channel but no nacl implementation available';\n let suffix = urlStore.buildLogSuffix('encryptedChannelSupport');\n throw new Errors.UnsupportedFeature(`${errMsg}. ${suffix}`);\n } else if (name.indexOf('private-') === 0) {\n return Factory.createPrivateChannel(name, pusher);\n } else if (name.indexOf('presence-') === 0) {\n return Factory.createPresenceChannel(name, pusher);\n } else if (name.indexOf('#') === 0) {\n throw new Errors.BadChannelName(\n 'Cannot create a channel with name \"' + name + '\".'\n );\n } else {\n return Factory.createChannel(name, pusher);\n }\n}\n","import AssistantToTheTransportManager from '../transports/assistant_to_the_transport_manager';\nimport PingDelayOptions from '../transports/ping_delay_options';\nimport Transport from '../transports/transport';\nimport TransportManager from '../transports/transport_manager';\nimport Handshake from '../connection/handshake';\nimport TransportConnection from '../transports/transport_connection';\nimport SocketHooks from '../http/socket_hooks';\nimport HTTPSocket from '../http/http_socket';\n\nimport Timeline from '../timeline/timeline';\nimport {\n default as TimelineSender,\n TimelineSenderOptions\n} from '../timeline/timeline_sender';\nimport PresenceChannel from '../channels/presence_channel';\nimport PrivateChannel from '../channels/private_channel';\nimport EncryptedChannel from '../channels/encrypted_channel';\nimport Channel from '../channels/channel';\nimport ConnectionManager from '../connection/connection_manager';\nimport ConnectionManagerOptions from '../connection/connection_manager_options';\nimport Ajax from '../http/ajax';\nimport Channels from '../channels/channels';\nimport Pusher from '../pusher';\nimport { Config } from '../config';\nimport * as nacl from 'tweetnacl';\n\nvar Factory = {\n createChannels(): Channels {\n return new Channels();\n },\n\n createConnectionManager(\n key: string,\n options: ConnectionManagerOptions\n ): ConnectionManager {\n return new ConnectionManager(key, options);\n },\n\n createChannel(name: string, pusher: Pusher): Channel {\n return new Channel(name, pusher);\n },\n\n createPrivateChannel(name: string, pusher: Pusher): PrivateChannel {\n return new PrivateChannel(name, pusher);\n },\n\n createPresenceChannel(name: string, pusher: Pusher): PresenceChannel {\n return new PresenceChannel(name, pusher);\n },\n\n createEncryptedChannel(\n name: string,\n pusher: Pusher,\n nacl: nacl\n ): EncryptedChannel {\n return new EncryptedChannel(name, pusher, nacl);\n },\n\n createTimelineSender(timeline: Timeline, options: TimelineSenderOptions) {\n return new TimelineSender(timeline, options);\n },\n\n createHandshake(\n transport: TransportConnection,\n callback: (HandshakePayload) => void\n ): Handshake {\n return new Handshake(transport, callback);\n },\n\n createAssistantToTheTransportManager(\n manager: TransportManager,\n transport: Transport,\n options: PingDelayOptions\n ): AssistantToTheTransportManager {\n return new AssistantToTheTransportManager(manager, transport, options);\n }\n};\n\nexport default Factory;\n","import AssistantToTheTransportManager from './assistant_to_the_transport_manager';\nimport Transport from './transport';\nimport PingDelayOptions from './ping_delay_options';\nimport Factory from '../utils/factory';\n\nexport interface TransportManagerOptions extends PingDelayOptions {\n lives?: number;\n}\n\n/** Keeps track of the number of lives left for a transport.\n *\n * In the beginning of a session, transports may be assigned a number of\n * lives. When an AssistantToTheTransportManager instance reports a transport\n * connection closed uncleanly, the transport loses a life. When the number\n * of lives drops to zero, the transport gets disabled by its manager.\n *\n * @param {Object} options\n */\nexport default class TransportManager {\n options: TransportManagerOptions;\n livesLeft: number;\n\n constructor(options: TransportManagerOptions) {\n this.options = options || {};\n this.livesLeft = this.options.lives || Infinity;\n }\n\n /** Creates a assistant for the transport.\n *\n * @param {Transport} transport\n * @returns {AssistantToTheTransportManager}\n */\n getAssistant(transport: Transport): AssistantToTheTransportManager {\n return Factory.createAssistantToTheTransportManager(this, transport, {\n minPingDelay: this.options.minPingDelay,\n maxPingDelay: this.options.maxPingDelay\n });\n }\n\n /** Returns whether the transport has any lives left.\n *\n * @returns {Boolean}\n */\n isAlive(): boolean {\n return this.livesLeft > 0;\n }\n\n /** Takes one life from the transport. */\n reportDeath() {\n this.livesLeft -= 1;\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport { OneOffTimer as Timer } from '../utils/timers';\nimport Strategy from './strategy';\nimport StrategyOptions from './strategy_options';\n\n/** Loops through strategies with optional timeouts.\n *\n * Options:\n * - loop - whether it should loop through the substrategy list\n * - timeout - initial timeout for a single substrategy\n * - timeoutLimit - maximum timeout\n *\n * @param {Strategy[]} strategies\n * @param {Object} options\n */\nexport default class SequentialStrategy implements Strategy {\n strategies: Strategy[];\n loop: boolean;\n failFast: boolean;\n timeout: number;\n timeoutLimit: number;\n\n constructor(strategies: Strategy[], options: StrategyOptions) {\n this.strategies = strategies;\n this.loop = Boolean(options.loop);\n this.failFast = Boolean(options.failFast);\n this.timeout = options.timeout;\n this.timeoutLimit = options.timeoutLimit;\n }\n\n isSupported(): boolean {\n return Collections.any(this.strategies, Util.method('isSupported'));\n }\n\n connect(minPriority: number, callback: Function) {\n var strategies = this.strategies;\n var current = 0;\n var timeout = this.timeout;\n var runner = null;\n\n var tryNextStrategy = (error, handshake) => {\n if (handshake) {\n callback(null, handshake);\n } else {\n current = current + 1;\n if (this.loop) {\n current = current % strategies.length;\n }\n\n if (current < strategies.length) {\n if (timeout) {\n timeout = timeout * 2;\n if (this.timeoutLimit) {\n timeout = Math.min(timeout, this.timeoutLimit);\n }\n }\n runner = this.tryStrategy(\n strategies[current],\n minPriority,\n { timeout, failFast: this.failFast },\n tryNextStrategy\n );\n } else {\n callback(true);\n }\n }\n };\n\n runner = this.tryStrategy(\n strategies[current],\n minPriority,\n { timeout: timeout, failFast: this.failFast },\n tryNextStrategy\n );\n\n return {\n abort: function() {\n runner.abort();\n },\n forceMinPriority: function(p) {\n minPriority = p;\n if (runner) {\n runner.forceMinPriority(p);\n }\n }\n };\n }\n\n private tryStrategy(\n strategy: Strategy,\n minPriority: number,\n options: StrategyOptions,\n callback: Function\n ) {\n var timer = null;\n var runner = null;\n\n if (options.timeout > 0) {\n timer = new Timer(options.timeout, function() {\n runner.abort();\n callback(true);\n });\n }\n\n runner = strategy.connect(minPriority, function(error, handshake) {\n if (error && timer && timer.isRunning() && !options.failFast) {\n // advance to the next strategy after the timeout\n return;\n }\n if (timer) {\n timer.ensureAborted();\n }\n callback(error, handshake);\n });\n\n return {\n abort: function() {\n if (timer) {\n timer.ensureAborted();\n }\n runner.abort();\n },\n forceMinPriority: function(p) {\n runner.forceMinPriority(p);\n }\n };\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport Strategy from './strategy';\n\n/** Launches all substrategies and emits prioritized connected transports.\n *\n * @param {Array} strategies\n */\nexport default class BestConnectedEverStrategy implements Strategy {\n strategies: Strategy[];\n\n constructor(strategies: Strategy[]) {\n this.strategies = strategies;\n }\n\n isSupported(): boolean {\n return Collections.any(this.strategies, Util.method('isSupported'));\n }\n\n connect(minPriority: number, callback: Function) {\n return connect(this.strategies, minPriority, function(i, runners) {\n return function(error, handshake) {\n runners[i].error = error;\n if (error) {\n if (allRunnersFailed(runners)) {\n callback(true);\n }\n return;\n }\n Collections.apply(runners, function(runner) {\n runner.forceMinPriority(handshake.transport.priority);\n });\n callback(null, handshake);\n };\n });\n }\n}\n\n/** Connects to all strategies in parallel.\n *\n * Callback builder should be a function that takes two arguments: index\n * and a list of runners. It should return another function that will be\n * passed to the substrategy with given index. Runners can be aborted using\n * abortRunner(s) functions from this class.\n *\n * @param {Array} strategies\n * @param {Function} callbackBuilder\n * @return {Object} strategy runner\n */\nfunction connect(\n strategies: Strategy[],\n minPriority: number,\n callbackBuilder: Function\n) {\n var runners = Collections.map(strategies, function(strategy, i, _, rs) {\n return strategy.connect(minPriority, callbackBuilder(i, rs));\n });\n return {\n abort: function() {\n Collections.apply(runners, abortRunner);\n },\n forceMinPriority: function(p) {\n Collections.apply(runners, function(runner) {\n runner.forceMinPriority(p);\n });\n }\n };\n}\n\nfunction allRunnersFailed(runners): boolean {\n return Collections.all(runners, function(runner) {\n return Boolean(runner.error);\n });\n}\n\nfunction abortRunner(runner) {\n if (!runner.error && !runner.aborted) {\n runner.abort();\n runner.aborted = true;\n }\n}\n","import Util from '../util';\nimport Runtime from 'runtime';\nimport Strategy from './strategy';\nimport SequentialStrategy from './sequential_strategy';\nimport StrategyOptions from './strategy_options';\nimport TransportStrategy from './transport_strategy';\nimport Timeline from '../timeline/timeline';\nimport * as Collections from '../utils/collections';\n\nexport interface TransportStrategyDictionary {\n [key: string]: TransportStrategy;\n}\n\n/** Caches the last successful transport and, after the first few attempts,\n * uses the cached transport for subsequent attempts.\n *\n * @param {Strategy} strategy\n * @param {Object} transports\n * @param {Object} options\n */\nexport default class WebSocketPrioritizedCachedStrategy implements Strategy {\n strategy: Strategy;\n transports: TransportStrategyDictionary;\n ttl: number;\n usingTLS: boolean;\n timeline: Timeline;\n\n constructor(\n strategy: Strategy,\n transports: TransportStrategyDictionary,\n options: StrategyOptions\n ) {\n this.strategy = strategy;\n this.transports = transports;\n this.ttl = options.ttl || 1800 * 1000;\n this.usingTLS = options.useTLS;\n this.timeline = options.timeline;\n }\n\n isSupported(): boolean {\n return this.strategy.isSupported();\n }\n\n connect(minPriority: number, callback: Function) {\n var usingTLS = this.usingTLS;\n var info = fetchTransportCache(usingTLS);\n var cacheSkipCount = info && info.cacheSkipCount ? info.cacheSkipCount : 0;\n\n var strategies = [this.strategy];\n if (info && info.timestamp + this.ttl >= Util.now()) {\n var transport = this.transports[info.transport];\n if (transport) {\n if (['ws', 'wss'].includes(info.transport) || cacheSkipCount > 3) {\n this.timeline.info({\n cached: true,\n transport: info.transport,\n latency: info.latency\n });\n strategies.push(\n new SequentialStrategy([transport], {\n timeout: info.latency * 2 + 1000,\n failFast: true\n })\n );\n } else {\n cacheSkipCount++;\n }\n }\n }\n\n var startTimestamp = Util.now();\n var runner = strategies\n .pop()\n .connect(minPriority, function cb(error, handshake) {\n if (error) {\n flushTransportCache(usingTLS);\n if (strategies.length > 0) {\n startTimestamp = Util.now();\n runner = strategies.pop().connect(minPriority, cb);\n } else {\n callback(error);\n }\n } else {\n storeTransportCache(\n usingTLS,\n handshake.transport.name,\n Util.now() - startTimestamp,\n cacheSkipCount\n );\n callback(null, handshake);\n }\n });\n\n return {\n abort: function() {\n runner.abort();\n },\n forceMinPriority: function(p) {\n minPriority = p;\n if (runner) {\n runner.forceMinPriority(p);\n }\n }\n };\n }\n}\n\nfunction getTransportCacheKey(usingTLS: boolean): string {\n return 'pusherTransport' + (usingTLS ? 'TLS' : 'NonTLS');\n}\n\nfunction fetchTransportCache(usingTLS: boolean): any {\n var storage = Runtime.getLocalStorage();\n if (storage) {\n try {\n var serializedCache = storage[getTransportCacheKey(usingTLS)];\n if (serializedCache) {\n return JSON.parse(serializedCache);\n }\n } catch (e) {\n flushTransportCache(usingTLS);\n }\n }\n return null;\n}\n\nfunction storeTransportCache(\n usingTLS: boolean,\n transport: TransportStrategy,\n latency: number,\n cacheSkipCount: number\n) {\n var storage = Runtime.getLocalStorage();\n if (storage) {\n try {\n storage[getTransportCacheKey(usingTLS)] = Collections.safeJSONStringify({\n timestamp: Util.now(),\n transport: transport,\n latency: latency,\n cacheSkipCount: cacheSkipCount\n });\n } catch (e) {\n // catch over quota exceptions raised by localStorage\n }\n }\n}\n\nfunction flushTransportCache(usingTLS: boolean) {\n var storage = Runtime.getLocalStorage();\n if (storage) {\n try {\n delete storage[getTransportCacheKey(usingTLS)];\n } catch (e) {\n // catch exceptions raised by localStorage\n }\n }\n}\n","import { OneOffTimer as Timer } from '../utils/timers';\nimport Strategy from './strategy';\nimport StrategyOptions from './strategy_options';\n\n/** Runs substrategy after specified delay.\n *\n * Options:\n * - delay - time in miliseconds to delay the substrategy attempt\n *\n * @param {Strategy} strategy\n * @param {Object} options\n */\nexport default class DelayedStrategy implements Strategy {\n strategy: Strategy;\n options: { delay: number };\n\n constructor(strategy: Strategy, { delay: number }) {\n this.strategy = strategy;\n this.options = { delay: number };\n }\n\n isSupported(): boolean {\n return this.strategy.isSupported();\n }\n\n connect(minPriority: number, callback: Function) {\n var strategy = this.strategy;\n var runner;\n var timer = new Timer(this.options.delay, function() {\n runner = strategy.connect(minPriority, callback);\n });\n\n return {\n abort: function() {\n timer.ensureAborted();\n if (runner) {\n runner.abort();\n }\n },\n forceMinPriority: function(p) {\n minPriority = p;\n if (runner) {\n runner.forceMinPriority(p);\n }\n }\n };\n }\n}\n","import Strategy from './strategy';\nimport StrategyRunner from './strategy_runner';\n\n/** Proxies method calls to one of substrategies basing on the test function.\n *\n * @param {Function} test\n * @param {Strategy} trueBranch strategy used when test returns true\n * @param {Strategy} falseBranch strategy used when test returns false\n */\nexport default class IfStrategy implements Strategy {\n test: () => boolean;\n trueBranch: Strategy;\n falseBranch: Strategy;\n\n constructor(\n test: () => boolean,\n trueBranch: Strategy,\n falseBranch: Strategy\n ) {\n this.test = test;\n this.trueBranch = trueBranch;\n this.falseBranch = falseBranch;\n }\n\n isSupported(): boolean {\n var branch = this.test() ? this.trueBranch : this.falseBranch;\n return branch.isSupported();\n }\n\n connect(minPriority: number, callback: Function): StrategyRunner {\n var branch = this.test() ? this.trueBranch : this.falseBranch;\n return branch.connect(minPriority, callback);\n }\n}\n","import Strategy from './strategy';\nimport StrategyRunner from './strategy_runner';\n\n/** Launches the substrategy and terminates on the first open connection.\n *\n * @param {Strategy} strategy\n */\nexport default class FirstConnectedStrategy implements Strategy {\n strategy: Strategy;\n\n constructor(strategy: Strategy) {\n this.strategy = strategy;\n }\n\n isSupported(): boolean {\n return this.strategy.isSupported();\n }\n\n connect(minPriority: number, callback: Function): StrategyRunner {\n var runner = this.strategy.connect(minPriority, function(error, handshake) {\n if (handshake) {\n runner.abort();\n }\n callback(error, handshake);\n });\n return runner;\n }\n}\n","import * as Collections from 'core/utils/collections';\nimport TransportManager from 'core/transports/transport_manager';\nimport Strategy from 'core/strategies/strategy';\nimport StrategyOptions from 'core/strategies/strategy_options';\nimport SequentialStrategy from 'core/strategies/sequential_strategy';\nimport BestConnectedEverStrategy from 'core/strategies/best_connected_ever_strategy';\nimport WebSocketPrioritizedCachedStrategy, {\n TransportStrategyDictionary\n} from 'core/strategies/websocket_prioritized_cached_strategy';\nimport DelayedStrategy from 'core/strategies/delayed_strategy';\nimport IfStrategy from 'core/strategies/if_strategy';\nimport FirstConnectedStrategy from 'core/strategies/first_connected_strategy';\nimport { Config } from 'core/config';\n\nfunction testSupportsStrategy(strategy: Strategy) {\n return function() {\n return strategy.isSupported();\n };\n}\n\nvar getDefaultStrategy = function(\n config: Config,\n baseOptions: StrategyOptions,\n defineTransport: Function\n): Strategy {\n var definedTransports = {};\n\n function defineTransportStrategy(\n name: string,\n type: string,\n priority: number,\n options: StrategyOptions,\n manager?: TransportManager\n ) {\n var transport = defineTransport(\n config,\n name,\n type,\n priority,\n options,\n manager\n );\n\n definedTransports[name] = transport;\n\n return transport;\n }\n\n var ws_options: StrategyOptions = Object.assign({}, baseOptions, {\n hostNonTLS: config.wsHost + ':' + config.wsPort,\n hostTLS: config.wsHost + ':' + config.wssPort,\n httpPath: config.wsPath\n });\n var wss_options: StrategyOptions = Object.assign({}, ws_options, {\n useTLS: true\n });\n var sockjs_options: StrategyOptions = Object.assign({}, baseOptions, {\n hostNonTLS: config.httpHost + ':' + config.httpPort,\n hostTLS: config.httpHost + ':' + config.httpsPort,\n httpPath: config.httpPath\n });\n\n var timeouts = {\n loop: true,\n timeout: 15000,\n timeoutLimit: 60000\n };\n\n var ws_manager = new TransportManager({\n minPingDelay: 10000,\n maxPingDelay: config.activityTimeout\n });\n var streaming_manager = new TransportManager({\n lives: 2,\n minPingDelay: 10000,\n maxPingDelay: config.activityTimeout\n });\n\n var ws_transport = defineTransportStrategy(\n 'ws',\n 'ws',\n 3,\n ws_options,\n ws_manager\n );\n var wss_transport = defineTransportStrategy(\n 'wss',\n 'ws',\n 3,\n wss_options,\n ws_manager\n );\n var sockjs_transport = defineTransportStrategy(\n 'sockjs',\n 'sockjs',\n 1,\n sockjs_options\n );\n var xhr_streaming_transport = defineTransportStrategy(\n 'xhr_streaming',\n 'xhr_streaming',\n 1,\n sockjs_options,\n streaming_manager\n );\n var xdr_streaming_transport = defineTransportStrategy(\n 'xdr_streaming',\n 'xdr_streaming',\n 1,\n sockjs_options,\n streaming_manager\n );\n var xhr_polling_transport = defineTransportStrategy(\n 'xhr_polling',\n 'xhr_polling',\n 1,\n sockjs_options\n );\n var xdr_polling_transport = defineTransportStrategy(\n 'xdr_polling',\n 'xdr_polling',\n 1,\n sockjs_options\n );\n\n var ws_loop = new SequentialStrategy([ws_transport], timeouts);\n var wss_loop = new SequentialStrategy([wss_transport], timeouts);\n var sockjs_loop = new SequentialStrategy([sockjs_transport], timeouts);\n var streaming_loop = new SequentialStrategy(\n [\n new IfStrategy(\n testSupportsStrategy(xhr_streaming_transport),\n xhr_streaming_transport,\n xdr_streaming_transport\n )\n ],\n timeouts\n );\n var polling_loop = new SequentialStrategy(\n [\n new IfStrategy(\n testSupportsStrategy(xhr_polling_transport),\n xhr_polling_transport,\n xdr_polling_transport\n )\n ],\n timeouts\n );\n\n var http_loop = new SequentialStrategy(\n [\n new IfStrategy(\n testSupportsStrategy(streaming_loop),\n new BestConnectedEverStrategy([\n streaming_loop,\n new DelayedStrategy(polling_loop, { delay: 4000 })\n ]),\n polling_loop\n )\n ],\n timeouts\n );\n\n var http_fallback_loop = new IfStrategy(\n testSupportsStrategy(http_loop),\n http_loop,\n sockjs_loop\n );\n\n var wsStrategy;\n if (baseOptions.useTLS) {\n wsStrategy = new BestConnectedEverStrategy([\n ws_loop,\n new DelayedStrategy(http_fallback_loop, { delay: 2000 })\n ]);\n } else {\n wsStrategy = new BestConnectedEverStrategy([\n ws_loop,\n new DelayedStrategy(wss_loop, { delay: 2000 }),\n new DelayedStrategy(http_fallback_loop, { delay: 5000 })\n ]);\n }\n\n return new WebSocketPrioritizedCachedStrategy(\n new FirstConnectedStrategy(\n new IfStrategy(\n testSupportsStrategy(ws_transport),\n wsStrategy,\n http_fallback_loop\n )\n ),\n definedTransports,\n {\n ttl: 1800000,\n timeline: baseOptions.timeline,\n useTLS: baseOptions.useTLS\n }\n );\n};\n\nexport default getDefaultStrategy;\n","import HTTPRequest from 'core/http/http_request';\nimport RequestHooks from 'core/http/request_hooks';\nimport Ajax from 'core/http/ajax';\nimport * as Errors from 'core/errors';\n\nvar hooks: RequestHooks = {\n getRequest: function(socket: HTTPRequest): Ajax {\n var xdr = new (window).XDomainRequest();\n xdr.ontimeout = function() {\n socket.emit('error', new Errors.RequestTimedOut());\n socket.close();\n };\n xdr.onerror = function(e) {\n socket.emit('error', e);\n socket.close();\n };\n xdr.onprogress = function() {\n if (xdr.responseText && xdr.responseText.length > 0) {\n socket.onChunk(200, xdr.responseText);\n }\n };\n xdr.onload = function() {\n if (xdr.responseText && xdr.responseText.length > 0) {\n socket.onChunk(200, xdr.responseText);\n }\n socket.emit('finished', 200);\n socket.close();\n };\n return xdr;\n },\n abortRequest: function(xdr: Ajax) {\n xdr.ontimeout = xdr.onerror = xdr.onprogress = xdr.onload = null;\n xdr.abort();\n }\n};\n\nexport default hooks;\n","import Runtime from 'runtime';\nimport RequestHooks from './request_hooks';\nimport Ajax from './ajax';\nimport { default as EventsDispatcher } from '../events/dispatcher';\n\nconst MAX_BUFFER_LENGTH = 256 * 1024;\n\nexport default class HTTPRequest extends EventsDispatcher {\n hooks: RequestHooks;\n method: string;\n url: string;\n position: number;\n xhr: Ajax;\n unloader: Function;\n\n constructor(hooks: RequestHooks, method: string, url: string) {\n super();\n this.hooks = hooks;\n this.method = method;\n this.url = url;\n }\n\n start(payload?: any) {\n this.position = 0;\n this.xhr = this.hooks.getRequest(this);\n\n this.unloader = () => {\n this.close();\n };\n Runtime.addUnloadListener(this.unloader);\n\n this.xhr.open(this.method, this.url, true);\n\n if (this.xhr.setRequestHeader) {\n this.xhr.setRequestHeader('Content-Type', 'application/json'); // ReactNative doesn't set this header by default.\n }\n this.xhr.send(payload);\n }\n\n close() {\n if (this.unloader) {\n Runtime.removeUnloadListener(this.unloader);\n this.unloader = null;\n }\n if (this.xhr) {\n this.hooks.abortRequest(this.xhr);\n this.xhr = null;\n }\n }\n\n onChunk(status: number, data: any) {\n while (true) {\n var chunk = this.advanceBuffer(data);\n if (chunk) {\n this.emit('chunk', { status: status, data: chunk });\n } else {\n break;\n }\n }\n if (this.isBufferTooLong(data)) {\n this.emit('buffer_too_long');\n }\n }\n\n private advanceBuffer(buffer: any[]): any {\n var unreadData = buffer.slice(this.position);\n var endOfLinePosition = unreadData.indexOf('\\n');\n\n if (endOfLinePosition !== -1) {\n this.position += endOfLinePosition + 1;\n return unreadData.slice(0, endOfLinePosition);\n } else {\n // chunk is not finished yet, don't move the buffer pointer\n return null;\n }\n }\n\n private isBufferTooLong(buffer: any): boolean {\n return this.position === buffer.length && buffer.length > MAX_BUFFER_LENGTH;\n }\n}\n","enum State {\n CONNECTING = 0,\n OPEN = 1,\n CLOSED = 3\n}\n\nexport default State;\n","import URLLocation from './url_location';\nimport State from './state';\nimport Socket from '../socket';\nimport SocketHooks from './socket_hooks';\nimport Util from '../util';\nimport Ajax from './ajax';\nimport HTTPRequest from './http_request';\nimport Runtime from 'runtime';\n\nvar autoIncrement = 1;\n\nclass HTTPSocket implements Socket {\n hooks: SocketHooks;\n session: string;\n location: URLLocation;\n readyState: State;\n stream: HTTPRequest;\n\n onopen: () => void;\n onerror: (error: any) => void;\n onclose: (closeEvent: any) => void;\n onmessage: (message: any) => void;\n onactivity: () => void;\n\n constructor(hooks: SocketHooks, url: string) {\n this.hooks = hooks;\n this.session = randomNumber(1000) + '/' + randomString(8);\n this.location = getLocation(url);\n this.readyState = State.CONNECTING;\n this.openStream();\n }\n\n send(payload: any) {\n return this.sendRaw(JSON.stringify([payload]));\n }\n\n ping() {\n this.hooks.sendHeartbeat(this);\n }\n\n close(code: any, reason: any) {\n this.onClose(code, reason, true);\n }\n\n /** For internal use only */\n sendRaw(payload: any): boolean {\n if (this.readyState === State.OPEN) {\n try {\n Runtime.createSocketRequest(\n 'POST',\n getUniqueURL(getSendURL(this.location, this.session))\n ).start(payload);\n return true;\n } catch (e) {\n return false;\n }\n } else {\n return false;\n }\n }\n\n /** For internal use only */\n reconnect() {\n this.closeStream();\n this.openStream();\n }\n\n /** For internal use only */\n onClose(code, reason, wasClean) {\n this.closeStream();\n this.readyState = State.CLOSED;\n if (this.onclose) {\n this.onclose({\n code: code,\n reason: reason,\n wasClean: wasClean\n });\n }\n }\n\n private onChunk(chunk) {\n if (chunk.status !== 200) {\n return;\n }\n if (this.readyState === State.OPEN) {\n this.onActivity();\n }\n\n var payload;\n var type = chunk.data.slice(0, 1);\n switch (type) {\n case 'o':\n payload = JSON.parse(chunk.data.slice(1) || '{}');\n this.onOpen(payload);\n break;\n case 'a':\n payload = JSON.parse(chunk.data.slice(1) || '[]');\n for (var i = 0; i < payload.length; i++) {\n this.onEvent(payload[i]);\n }\n break;\n case 'm':\n payload = JSON.parse(chunk.data.slice(1) || 'null');\n this.onEvent(payload);\n break;\n case 'h':\n this.hooks.onHeartbeat(this);\n break;\n case 'c':\n payload = JSON.parse(chunk.data.slice(1) || '[]');\n this.onClose(payload[0], payload[1], true);\n break;\n }\n }\n\n private onOpen(options) {\n if (this.readyState === State.CONNECTING) {\n if (options && options.hostname) {\n this.location.base = replaceHost(this.location.base, options.hostname);\n }\n this.readyState = State.OPEN;\n\n if (this.onopen) {\n this.onopen();\n }\n } else {\n this.onClose(1006, 'Server lost session', true);\n }\n }\n\n private onEvent(event) {\n if (this.readyState === State.OPEN && this.onmessage) {\n this.onmessage({ data: event });\n }\n }\n\n private onActivity() {\n if (this.onactivity) {\n this.onactivity();\n }\n }\n\n private onError(error) {\n if (this.onerror) {\n this.onerror(error);\n }\n }\n\n private openStream() {\n this.stream = Runtime.createSocketRequest(\n 'POST',\n getUniqueURL(this.hooks.getReceiveURL(this.location, this.session))\n );\n\n this.stream.bind('chunk', chunk => {\n this.onChunk(chunk);\n });\n this.stream.bind('finished', status => {\n this.hooks.onFinished(this, status);\n });\n this.stream.bind('buffer_too_long', () => {\n this.reconnect();\n });\n\n try {\n this.stream.start();\n } catch (error) {\n Util.defer(() => {\n this.onError(error);\n this.onClose(1006, 'Could not start streaming', false);\n });\n }\n }\n\n private closeStream() {\n if (this.stream) {\n this.stream.unbind_all();\n this.stream.close();\n this.stream = null;\n }\n }\n}\n\nfunction getLocation(url): URLLocation {\n var parts = /([^\\?]*)\\/*(\\??.*)/.exec(url);\n return {\n base: parts[1],\n queryString: parts[2]\n };\n}\n\nfunction getSendURL(url: URLLocation, session: string): string {\n return url.base + '/' + session + '/xhr_send';\n}\n\nfunction getUniqueURL(url: string): string {\n var separator = url.indexOf('?') === -1 ? '?' : '&';\n return url + separator + 't=' + +new Date() + '&n=' + autoIncrement++;\n}\n\nfunction replaceHost(url: string, hostname: string): string {\n var urlParts = /(https?:\\/\\/)([^\\/:]+)((\\/|:)?.*)/.exec(url);\n return urlParts[1] + hostname + urlParts[3];\n}\n\nfunction randomNumber(max: number): number {\n return Runtime.randomInt(max);\n}\n\nfunction randomString(length: number): string {\n var result = [];\n\n for (var i = 0; i < length; i++) {\n result.push(randomNumber(32).toString(32));\n }\n\n return result.join('');\n}\n\nexport default HTTPSocket;\n","enum TimelineLevel {\n ERROR = 3,\n INFO = 6,\n DEBUG = 7\n}\n\nexport default TimelineLevel;\n","import SocketHooks from './socket_hooks';\nimport HTTPSocket from './http_socket';\n\nvar hooks: SocketHooks = {\n getReceiveURL: function(url, session) {\n return url.base + '/' + session + '/xhr_streaming' + url.queryString;\n },\n onHeartbeat: function(socket) {\n socket.sendRaw('[]');\n },\n sendHeartbeat: function(socket) {\n socket.sendRaw('[]');\n },\n onFinished: function(socket, status) {\n socket.onClose(1006, 'Connection interrupted (' + status + ')', false);\n }\n};\n\nexport default hooks;\n","import SocketHooks from './socket_hooks';\nimport URLLocation from './url_location';\nimport HTTPSocket from './http_socket';\n\nvar hooks: SocketHooks = {\n getReceiveURL: function(url: URLLocation, session: string): string {\n return url.base + '/' + session + '/xhr' + url.queryString;\n },\n onHeartbeat: function() {\n // next HTTP request will reset server's activity timer\n },\n sendHeartbeat: function(socket) {\n socket.sendRaw('[]');\n },\n onFinished: function(socket, status) {\n if (status === 200) {\n socket.reconnect();\n } else {\n socket.onClose(1006, 'Connection interrupted (' + status + ')', false);\n }\n }\n};\n\nexport default hooks;\n","import HTTPRequest from 'core/http/http_request';\nimport RequestHooks from 'core/http/request_hooks';\nimport Ajax from 'core/http/ajax';\nimport Runtime from 'runtime';\n\nvar hooks: RequestHooks = {\n getRequest: function(socket: HTTPRequest): Ajax {\n var Constructor = Runtime.getXHRAPI();\n var xhr = new Constructor();\n xhr.onreadystatechange = xhr.onprogress = function() {\n switch (xhr.readyState) {\n case 3:\n if (xhr.responseText && xhr.responseText.length > 0) {\n socket.onChunk(xhr.status, xhr.responseText);\n }\n break;\n case 4:\n // this happens only on errors, never after calling close\n if (xhr.responseText && xhr.responseText.length > 0) {\n socket.onChunk(xhr.status, xhr.responseText);\n }\n socket.emit('finished', xhr.status);\n socket.close();\n break;\n }\n };\n return xhr;\n },\n abortRequest: function(xhr: Ajax) {\n xhr.onreadystatechange = null;\n xhr.abort();\n }\n};\n\nexport default hooks;\n","import HTTPRequest from 'core/http/http_request';\nimport HTTPSocket from 'core/http/http_socket';\nimport SocketHooks from 'core/http/socket_hooks';\nimport RequestHooks from 'core/http/request_hooks';\nimport streamingHooks from 'core/http/http_streaming_socket';\nimport pollingHooks from 'core/http/http_polling_socket';\nimport xhrHooks from './http_xhr_request';\nimport HTTPFactory from 'core/http/http_factory';\n\nvar HTTP: HTTPFactory = {\n createStreamingSocket(url: string): HTTPSocket {\n return this.createSocket(streamingHooks, url);\n },\n\n createPollingSocket(url: string): HTTPSocket {\n return this.createSocket(pollingHooks, url);\n },\n\n createSocket(hooks: SocketHooks, url: string): HTTPSocket {\n return new HTTPSocket(hooks, url);\n },\n\n createXHR(method: string, url: string): HTTPRequest {\n return this.createRequest(xhrHooks, method, url);\n },\n\n createRequest(hooks: RequestHooks, method: string, url: string): HTTPRequest {\n return new HTTPRequest(hooks, method, url);\n }\n};\n\nexport default HTTP;\n","import xdrHooks from './http_xdomain_request';\nimport HTTP from 'isomorphic/http/http';\n\nHTTP.createXDR = function(method, url) {\n return this.createRequest(xdrHooks, method, url);\n};\n\nexport default HTTP;\n","import Browser from './browser';\nimport { Dependencies, DependenciesReceivers } from './dom/dependencies';\nimport { AuthTransport, AuthTransports } from 'core/auth/auth_transports';\nimport xhrAuth from 'isomorphic/auth/xhr_auth';\nimport jsonpAuth from './auth/jsonp_auth';\nimport TimelineTransport from 'core/timeline/timeline_transport';\nimport TimelineSender from 'core/timeline/timeline_sender';\nimport ScriptRequest from './dom/script_request';\nimport JSONPRequest from './dom/jsonp_request';\nimport * as Collections from 'core/utils/collections';\nimport { ScriptReceivers } from './dom/script_receiver_factory';\nimport jsonpTimeline from './timeline/jsonp_timeline';\nimport Transports from './transports/transports';\nimport Ajax from 'core/http/ajax';\nimport { Network } from './net_info';\nimport getDefaultStrategy from './default_strategy';\nimport transportConnectionInitializer from './transports/transport_connection_initializer';\nimport HTTPFactory from './http/http';\nimport HTTPRequest from 'core/http/http_request';\n\nvar Runtime: Browser = {\n // for jsonp auth\n nextAuthCallbackID: 1,\n auth_callbacks: {},\n ScriptReceivers,\n DependenciesReceivers,\n getDefaultStrategy,\n Transports,\n transportConnectionInitializer,\n HTTPFactory,\n\n TimelineTransport: jsonpTimeline,\n\n getXHRAPI() {\n return window.XMLHttpRequest;\n },\n\n getWebSocketAPI() {\n return window.WebSocket || window.MozWebSocket;\n },\n\n setup(PusherClass): void {\n (window).Pusher = PusherClass; // JSONp requires Pusher to be in the global scope.\n var initializeOnDocumentBody = () => {\n this.onDocumentBody(PusherClass.ready);\n };\n if (!(window).JSON) {\n Dependencies.load('json2', {}, initializeOnDocumentBody);\n } else {\n initializeOnDocumentBody();\n }\n },\n\n getDocument(): Document {\n return document;\n },\n\n getProtocol(): string {\n return this.getDocument().location.protocol;\n },\n\n getAuthorizers(): AuthTransports {\n return { ajax: xhrAuth, jsonp: jsonpAuth };\n },\n\n onDocumentBody(callback: Function) {\n if (document.body) {\n callback();\n } else {\n setTimeout(() => {\n this.onDocumentBody(callback);\n }, 0);\n }\n },\n\n createJSONPRequest(url: string, data: any): JSONPRequest {\n return new JSONPRequest(url, data);\n },\n\n createScriptRequest(src: string): ScriptRequest {\n return new ScriptRequest(src);\n },\n\n getLocalStorage() {\n try {\n return window.localStorage;\n } catch (e) {\n return undefined;\n }\n },\n\n createXHR(): Ajax {\n if (this.getXHRAPI()) {\n return this.createXMLHttpRequest();\n } else {\n return this.createMicrosoftXHR();\n }\n },\n\n createXMLHttpRequest(): Ajax {\n var Constructor = this.getXHRAPI();\n return new Constructor();\n },\n\n createMicrosoftXHR(): Ajax {\n return new ActiveXObject('Microsoft.XMLHTTP');\n },\n\n getNetwork() {\n return Network;\n },\n\n createWebSocket(url: string): any {\n var Constructor = this.getWebSocketAPI();\n return new Constructor(url);\n },\n\n createSocketRequest(method: string, url: string): HTTPRequest {\n if (this.isXHRSupported()) {\n return this.HTTPFactory.createXHR(method, url);\n } else if (this.isXDRSupported(url.indexOf('https:') === 0)) {\n return this.HTTPFactory.createXDR(method, url);\n } else {\n throw 'Cross-origin HTTP requests are not supported';\n }\n },\n\n isXHRSupported(): boolean {\n var Constructor = this.getXHRAPI();\n return (\n Boolean(Constructor) && new Constructor().withCredentials !== undefined\n );\n },\n\n isXDRSupported(useTLS?: boolean): boolean {\n var protocol = useTLS ? 'https:' : 'http:';\n var documentProtocol = this.getProtocol();\n return (\n Boolean(window['XDomainRequest']) && documentProtocol === protocol\n );\n },\n\n addUnloadListener(listener: any) {\n if (window.addEventListener !== undefined) {\n window.addEventListener('unload', listener, false);\n } else if (window.attachEvent !== undefined) {\n window.attachEvent('onunload', listener);\n }\n },\n\n removeUnloadListener(listener: any) {\n if (window.addEventListener !== undefined) {\n window.removeEventListener('unload', listener, false);\n } else if (window.detachEvent !== undefined) {\n window.detachEvent('onunload', listener);\n }\n },\n\n randomInt(max: number): number {\n /**\n * Return values in the range of [0, 1[\n */\n const random = function() {\n const crypto = window.crypto || window['msCrypto'];\n const random = crypto.getRandomValues(new Uint32Array(1))[0];\n\n return random / 2 ** 32;\n };\n\n return Math.floor(random() * max);\n }\n};\n\nexport default Runtime;\n","import { Dependencies } from '../dom/dependencies';\n\n/** Initializes the transport.\n *\n * Fetches resources if needed and then transitions to initialized.\n */\nexport default function() {\n var self = this;\n\n self.timeline.info(\n self.buildTimelineMessage({\n transport: self.name + (self.options.useTLS ? 's' : '')\n })\n );\n\n if (self.hooks.isInitialized()) {\n self.changeState('initialized');\n } else if (self.hooks.file) {\n self.changeState('initializing');\n Dependencies.load(\n self.hooks.file,\n { useTLS: self.options.useTLS },\n function(error, callback) {\n if (self.hooks.isInitialized()) {\n self.changeState('initialized');\n callback(true);\n } else {\n if (error) {\n self.onError(error);\n }\n self.onClose();\n callback(false);\n }\n }\n );\n } else {\n self.onClose();\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport { default as Level } from './level';\n\nexport interface TimelineOptions {\n level?: Level;\n limit?: number;\n version?: string;\n cluster?: string;\n features?: string[];\n params?: any;\n}\n\nexport default class Timeline {\n key: string;\n session: number;\n events: any[];\n options: TimelineOptions;\n sent: number;\n uniqueID: number;\n\n constructor(key: string, session: number, options: TimelineOptions) {\n this.key = key;\n this.session = session;\n this.events = [];\n this.options = options || {};\n this.sent = 0;\n this.uniqueID = 0;\n }\n\n log(level, event) {\n if (level <= this.options.level) {\n this.events.push(\n Collections.extend({}, event, { timestamp: Util.now() })\n );\n if (this.options.limit && this.events.length > this.options.limit) {\n this.events.shift();\n }\n }\n }\n\n error(event) {\n this.log(Level.ERROR, event);\n }\n\n info(event) {\n this.log(Level.INFO, event);\n }\n\n debug(event) {\n this.log(Level.DEBUG, event);\n }\n\n isEmpty() {\n return this.events.length === 0;\n }\n\n send(sendfn, callback) {\n var data = Collections.extend(\n {\n session: this.session,\n bundle: this.sent + 1,\n key: this.key,\n lib: 'js',\n version: this.options.version,\n cluster: this.options.cluster,\n features: this.options.features,\n timeline: this.events\n },\n this.options.params\n );\n\n this.events = [];\n sendfn(data, (error, result) => {\n if (!error) {\n this.sent++;\n }\n if (callback) {\n callback(error, result);\n }\n });\n\n return true;\n }\n\n generateUniqueID(): number {\n this.uniqueID++;\n return this.uniqueID;\n }\n}\n","import Factory from '../utils/factory';\nimport Util from '../util';\nimport * as Errors from '../errors';\nimport * as Collections from '../utils/collections';\nimport Strategy from './strategy';\nimport Transport from '../transports/transport';\nimport StrategyOptions from './strategy_options';\nimport Handshake from '../connection/handshake';\n\n/** Provides a strategy interface for transports.\n *\n * @param {String} name\n * @param {Number} priority\n * @param {Class} transport\n * @param {Object} options\n */\nexport default class TransportStrategy implements Strategy {\n name: string;\n priority: number;\n transport: Transport;\n options: StrategyOptions;\n\n constructor(\n name: string,\n priority: number,\n transport: Transport,\n options: StrategyOptions\n ) {\n this.name = name;\n this.priority = priority;\n this.transport = transport;\n this.options = options || {};\n }\n\n /** Returns whether the transport is supported in the browser.\n *\n * @returns {Boolean}\n */\n isSupported(): boolean {\n return this.transport.isSupported({\n useTLS: this.options.useTLS\n });\n }\n\n /** Launches a connection attempt and returns a strategy runner.\n *\n * @param {Function} callback\n * @return {Object} strategy runner\n */\n connect(minPriority: number, callback: Function) {\n if (!this.isSupported()) {\n return failAttempt(new Errors.UnsupportedStrategy(), callback);\n } else if (this.priority < minPriority) {\n return failAttempt(new Errors.TransportPriorityTooLow(), callback);\n }\n\n var connected = false;\n var transport = this.transport.createConnection(\n this.name,\n this.priority,\n this.options.key,\n this.options\n );\n var handshake = null;\n\n var onInitialized = function() {\n transport.unbind('initialized', onInitialized);\n transport.connect();\n };\n var onOpen = function() {\n handshake = Factory.createHandshake(transport, function(result) {\n connected = true;\n unbindListeners();\n callback(null, result);\n });\n };\n var onError = function(error) {\n unbindListeners();\n callback(error);\n };\n var onClosed = function() {\n unbindListeners();\n var serializedTransport;\n\n // The reason for this try/catch block is that on React Native\n // the WebSocket object is circular. Therefore transport.socket will\n // throw errors upon stringification. Collections.safeJSONStringify\n // discards circular references when serializing.\n serializedTransport = Collections.safeJSONStringify(transport);\n callback(new Errors.TransportClosed(serializedTransport));\n };\n\n var unbindListeners = function() {\n transport.unbind('initialized', onInitialized);\n transport.unbind('open', onOpen);\n transport.unbind('error', onError);\n transport.unbind('closed', onClosed);\n };\n\n transport.bind('initialized', onInitialized);\n transport.bind('open', onOpen);\n transport.bind('error', onError);\n transport.bind('closed', onClosed);\n\n // connect will be called automatically after initialization\n transport.initialize();\n\n return {\n abort: () => {\n if (connected) {\n return;\n }\n unbindListeners();\n if (handshake) {\n handshake.close();\n } else {\n transport.close();\n }\n },\n forceMinPriority: p => {\n if (connected) {\n return;\n }\n if (this.priority < p) {\n if (handshake) {\n handshake.close();\n } else {\n transport.close();\n }\n }\n }\n };\n }\n}\n\nfunction failAttempt(error: Error, callback: Function) {\n Util.defer(function() {\n callback(error);\n });\n return {\n abort: function() {},\n forceMinPriority: function() {}\n };\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport TransportManager from '../transports/transport_manager';\nimport * as Errors from '../errors';\nimport Strategy from './strategy';\nimport TransportStrategy from './transport_strategy';\nimport StrategyOptions from '../strategies/strategy_options';\nimport { Config } from '../config';\nimport Runtime from 'runtime';\n\nconst { Transports } = Runtime;\n\nexport var defineTransport = function(\n config: Config,\n name: string,\n type: string,\n priority: number,\n options: StrategyOptions,\n manager?: TransportManager\n): Strategy {\n var transportClass = Transports[type];\n if (!transportClass) {\n throw new Errors.UnsupportedTransport(type);\n }\n\n var enabled =\n (!config.enabledTransports ||\n Collections.arrayIndexOf(config.enabledTransports, name) !== -1) &&\n (!config.disabledTransports ||\n Collections.arrayIndexOf(config.disabledTransports, name) === -1);\n\n var transport;\n if (enabled) {\n options = Object.assign(\n { ignoreNullOrigin: config.ignoreNullOrigin },\n options\n );\n\n transport = new TransportStrategy(\n name,\n priority,\n manager ? manager.getAssistant(transportClass) : transportClass,\n options\n );\n } else {\n transport = UnsupportedStrategy;\n }\n\n return transport;\n};\n\nvar UnsupportedStrategy: Strategy = {\n isSupported: function() {\n return false;\n },\n connect: function(_, callback) {\n var deferred = Util.defer(function() {\n callback(new Errors.UnsupportedStrategy());\n });\n return {\n abort: function() {\n deferred.ensureAborted();\n },\n forceMinPriority: function() {}\n };\n }\n};\n","import ConnectionManager from './connection/connection_manager';\nimport {\n ChannelAuthorizationOptions,\n UserAuthenticationOptions\n} from './auth/options';\nimport {\n ChannelAuthorizerGenerator,\n DeprecatedAuthOptions\n} from './auth/deprecated_channel_authorizer';\nimport { AuthTransport, Transport } from './config';\nimport * as nacl from 'tweetnacl';\nimport Logger from './logger';\n\nexport interface Options {\n activityTimeout?: number;\n\n auth?: DeprecatedAuthOptions; // DEPRECATED use channelAuthorization instead\n authEndpoint?: string; // DEPRECATED use channelAuthorization instead\n authTransport?: AuthTransport; // DEPRECATED use channelAuthorization instead\n authorizer?: ChannelAuthorizerGenerator; // DEPRECATED use channelAuthorization instead\n\n channelAuthorization?: ChannelAuthorizationOptions;\n userAuthentication?: UserAuthenticationOptions;\n\n cluster: string;\n enableStats?: boolean;\n disableStats?: boolean;\n disabledTransports?: Transport[];\n enabledTransports?: Transport[];\n forceTLS?: boolean;\n httpHost?: string;\n httpPath?: string;\n httpPort?: number;\n httpsPort?: number;\n ignoreNullOrigin?: boolean;\n nacl?: nacl;\n pongTimeout?: number;\n statsHost?: string;\n timelineParams?: any;\n unavailableTimeout?: number;\n wsHost?: string;\n wsPath?: string;\n wsPort?: number;\n wssPort?: number;\n}\n\nexport interface ClusterOptions {\n appKey: string;\n cluster: string;\n}\n\nexport function validateOptions(options) {\n if (options == null) {\n throw 'You must pass an options object';\n }\n if (options.cluster == null) {\n throw 'Options object must provide a cluster';\n }\n if ('disableStats' in options) {\n Logger.warn(\n 'The disableStats option is deprecated in favor of enableStats'\n );\n }\n}\n","import {\n UserAuthenticationCallback,\n InternalAuthOptions,\n UserAuthenticationHandler,\n UserAuthenticationRequestParams,\n AuthRequestType\n} from './options';\n\nimport Runtime from 'runtime';\n\nconst composeChannelQuery = (\n params: UserAuthenticationRequestParams,\n authOptions: InternalAuthOptions\n) => {\n var query = 'socket_id=' + encodeURIComponent(params.socketId);\n\n for (var key in authOptions.params) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(authOptions.params[key]);\n }\n\n if (authOptions.paramsProvider != null) {\n let dynamicParams = authOptions.paramsProvider();\n for (var key in dynamicParams) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(dynamicParams[key]);\n }\n }\n\n return query;\n};\n\nconst UserAuthenticator = (\n authOptions: InternalAuthOptions\n): UserAuthenticationHandler => {\n if (typeof Runtime.getAuthorizers()[authOptions.transport] === 'undefined') {\n throw `'${authOptions.transport}' is not a recognized auth transport`;\n }\n\n return (\n params: UserAuthenticationRequestParams,\n callback: UserAuthenticationCallback\n ) => {\n const query = composeChannelQuery(params, authOptions);\n\n Runtime.getAuthorizers()[authOptions.transport](\n Runtime,\n query,\n authOptions,\n AuthRequestType.UserAuthentication,\n callback\n );\n };\n};\n\nexport default UserAuthenticator;\n","import {\n AuthRequestType,\n InternalAuthOptions,\n ChannelAuthorizationHandler,\n ChannelAuthorizationRequestParams,\n ChannelAuthorizationCallback\n} from './options';\n\nimport Runtime from 'runtime';\n\nconst composeChannelQuery = (\n params: ChannelAuthorizationRequestParams,\n authOptions: InternalAuthOptions\n) => {\n var query = 'socket_id=' + encodeURIComponent(params.socketId);\n\n query += '&channel_name=' + encodeURIComponent(params.channelName);\n\n for (var key in authOptions.params) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(authOptions.params[key]);\n }\n\n if (authOptions.paramsProvider != null) {\n let dynamicParams = authOptions.paramsProvider();\n for (var key in dynamicParams) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(dynamicParams[key]);\n }\n }\n\n return query;\n};\n\nconst ChannelAuthorizer = (\n authOptions: InternalAuthOptions\n): ChannelAuthorizationHandler => {\n if (typeof Runtime.getAuthorizers()[authOptions.transport] === 'undefined') {\n throw `'${authOptions.transport}' is not a recognized auth transport`;\n }\n\n return (\n params: ChannelAuthorizationRequestParams,\n callback: ChannelAuthorizationCallback\n ) => {\n const query = composeChannelQuery(params, authOptions);\n\n Runtime.getAuthorizers()[authOptions.transport](\n Runtime,\n query,\n authOptions,\n AuthRequestType.ChannelAuthorization,\n callback\n );\n };\n};\n\nexport default ChannelAuthorizer;\n","import Channel from '../channels/channel';\nimport {\n ChannelAuthorizationCallback,\n ChannelAuthorizationHandler,\n ChannelAuthorizationRequestParams,\n InternalAuthOptions\n} from './options';\n\nexport interface DeprecatedChannelAuthorizer {\n authorize(socketId: string, callback: ChannelAuthorizationCallback): void;\n}\n\nexport interface ChannelAuthorizerGenerator {\n (\n channel: Channel,\n options: DeprecatedAuthorizerOptions\n ): DeprecatedChannelAuthorizer;\n}\n\nexport interface DeprecatedAuthOptions {\n params?: any;\n headers?: any;\n}\n\nexport interface DeprecatedAuthorizerOptions {\n authTransport: 'ajax' | 'jsonp';\n authEndpoint: string;\n auth?: DeprecatedAuthOptions;\n}\n\nexport const ChannelAuthorizerProxy = (\n pusher,\n authOptions: InternalAuthOptions,\n channelAuthorizerGenerator: ChannelAuthorizerGenerator\n): ChannelAuthorizationHandler => {\n const deprecatedAuthorizerOptions: DeprecatedAuthorizerOptions = {\n authTransport: authOptions.transport,\n authEndpoint: authOptions.endpoint,\n auth: {\n params: authOptions.params,\n headers: authOptions.headers\n }\n };\n return (\n params: ChannelAuthorizationRequestParams,\n callback: ChannelAuthorizationCallback\n ) => {\n const channel = pusher.channel(params.channelName);\n // This line creates a new channel authorizer every time.\n // In the past, this was only done once per channel and reused.\n // We can do that again if we want to keep this behavior intact.\n const channelAuthorizer: DeprecatedChannelAuthorizer = channelAuthorizerGenerator(\n channel,\n deprecatedAuthorizerOptions\n );\n channelAuthorizer.authorize(params.socketId, callback);\n };\n};\n","import { Options } from './options';\nimport Defaults from './defaults';\nimport {\n ChannelAuthorizationHandler,\n UserAuthenticationHandler,\n ChannelAuthorizationOptions,\n AuthOptionsT,\n CustomAuthOptions\n} from './auth/options';\nimport UserAuthenticator from './auth/user_authenticator';\nimport ChannelAuthorizer from './auth/channel_authorizer';\nimport { ChannelAuthorizerProxy } from './auth/deprecated_channel_authorizer';\nimport Runtime from 'runtime';\nimport * as nacl from 'tweetnacl';\n\nexport type AuthTransport = 'ajax' | 'jsonp';\nexport type Transport =\n | 'ws'\n | 'wss'\n | 'xhr_streaming'\n | 'xhr_polling'\n | 'sockjs';\n\nexport interface Config {\n // these are all 'required' config parameters, it's not necessary for the user\n // to set them, but they have configured defaults.\n activityTimeout: number;\n enableStats: boolean;\n httpHost: string;\n httpPath: string;\n httpPort: number;\n httpsPort: number;\n pongTimeout: number;\n statsHost: string;\n unavailableTimeout: number;\n useTLS: boolean;\n wsHost: string;\n wsPath: string;\n wsPort: number;\n wssPort: number;\n userAuthenticator: UserAuthenticationHandler;\n channelAuthorizer: ChannelAuthorizationHandler;\n\n // these are all optional parameters or overrrides. The customer can set these\n // but it's not strictly necessary\n forceTLS?: boolean;\n cluster?: string;\n disabledTransports?: Transport[];\n enabledTransports?: Transport[];\n ignoreNullOrigin?: boolean;\n nacl?: nacl;\n timelineParams?: any;\n}\n\n// getConfig mainly sets the defaults for the options that are not provided\nexport function getConfig(opts: Options, pusher): Config {\n let config: Config = {\n activityTimeout: opts.activityTimeout || Defaults.activityTimeout,\n cluster: opts.cluster,\n httpPath: opts.httpPath || Defaults.httpPath,\n httpPort: opts.httpPort || Defaults.httpPort,\n httpsPort: opts.httpsPort || Defaults.httpsPort,\n pongTimeout: opts.pongTimeout || Defaults.pongTimeout,\n statsHost: opts.statsHost || Defaults.stats_host,\n unavailableTimeout: opts.unavailableTimeout || Defaults.unavailableTimeout,\n wsPath: opts.wsPath || Defaults.wsPath,\n wsPort: opts.wsPort || Defaults.wsPort,\n wssPort: opts.wssPort || Defaults.wssPort,\n\n enableStats: getEnableStatsConfig(opts),\n httpHost: getHttpHost(opts),\n useTLS: shouldUseTLS(opts),\n wsHost: getWebsocketHost(opts),\n\n userAuthenticator: buildUserAuthenticator(opts),\n channelAuthorizer: buildChannelAuthorizer(opts, pusher)\n };\n\n if ('disabledTransports' in opts)\n config.disabledTransports = opts.disabledTransports;\n if ('enabledTransports' in opts)\n config.enabledTransports = opts.enabledTransports;\n if ('ignoreNullOrigin' in opts)\n config.ignoreNullOrigin = opts.ignoreNullOrigin;\n if ('timelineParams' in opts) config.timelineParams = opts.timelineParams;\n if ('nacl' in opts) {\n config.nacl = opts.nacl;\n }\n\n return config;\n}\n\nfunction getHttpHost(opts: Options): string {\n if (opts.httpHost) {\n return opts.httpHost;\n }\n if (opts.cluster) {\n return `sockjs-${opts.cluster}.pusher.com`;\n }\n return Defaults.httpHost;\n}\n\nfunction getWebsocketHost(opts: Options): string {\n if (opts.wsHost) {\n return opts.wsHost;\n }\n return getWebsocketHostFromCluster(opts.cluster);\n}\n\nfunction getWebsocketHostFromCluster(cluster: string): string {\n return `ws-${cluster}.pusher.com`;\n}\n\nfunction shouldUseTLS(opts: Options): boolean {\n if (Runtime.getProtocol() === 'https:') {\n return true;\n } else if (opts.forceTLS === false) {\n return false;\n }\n return true;\n}\n\n// if enableStats is set take the value\n// if disableStats is set take the inverse\n// otherwise default to false\nfunction getEnableStatsConfig(opts: Options): boolean {\n if ('enableStats' in opts) {\n return opts.enableStats;\n }\n if ('disableStats' in opts) {\n return !opts.disableStats;\n }\n return false;\n}\n\nconst hasCustomHandler = (\n auth: AuthOptionsT\n): auth is CustomAuthOptions => {\n return 'customHandler' in auth && auth['customHandler'] != null;\n};\n\nfunction buildUserAuthenticator(opts: Options): UserAuthenticationHandler {\n const userAuthentication = {\n ...Defaults.userAuthentication,\n ...opts.userAuthentication\n };\n\n if (hasCustomHandler(userAuthentication)) {\n return userAuthentication['customHandler'];\n }\n\n return UserAuthenticator(userAuthentication);\n}\n\nfunction buildChannelAuth(opts: Options, pusher): ChannelAuthorizationOptions {\n let channelAuthorization: ChannelAuthorizationOptions;\n if ('channelAuthorization' in opts) {\n channelAuthorization = {\n ...Defaults.channelAuthorization,\n ...opts.channelAuthorization\n };\n } else {\n channelAuthorization = {\n transport: opts.authTransport || Defaults.authTransport,\n endpoint: opts.authEndpoint || Defaults.authEndpoint\n };\n\n if ('auth' in opts) {\n if ('params' in opts.auth) channelAuthorization.params = opts.auth.params;\n if ('headers' in opts.auth)\n channelAuthorization.headers = opts.auth.headers;\n }\n\n if ('authorizer' in opts) {\n return {\n customHandler: ChannelAuthorizerProxy(\n pusher,\n channelAuthorization,\n opts.authorizer\n )\n };\n }\n }\n return channelAuthorization;\n}\n\nfunction buildChannelAuthorizer(\n opts: Options,\n pusher\n): ChannelAuthorizationHandler {\n const channelAuthorization = buildChannelAuth(opts, pusher);\n\n if (hasCustomHandler(channelAuthorization)) {\n return channelAuthorization['customHandler'];\n }\n\n return ChannelAuthorizer(channelAuthorization);\n}\n","import Logger from './logger';\nimport Pusher from './pusher';\nimport EventsDispatcher from './events/dispatcher';\n\nexport default class WatchlistFacade extends EventsDispatcher {\n private pusher: Pusher;\n\n public constructor(pusher: Pusher) {\n super(function(eventName, data) {\n Logger.debug(`No callbacks on watchlist events for ${eventName}`);\n });\n\n this.pusher = pusher;\n this.bindWatchlistInternalEvent();\n }\n\n handleEvent(pusherEvent) {\n pusherEvent.data.events.forEach(watchlistEvent => {\n this.emit(watchlistEvent.name, watchlistEvent);\n });\n }\n\n private bindWatchlistInternalEvent() {\n this.pusher.connection.bind('message', pusherEvent => {\n var eventName = pusherEvent.event;\n if (eventName === 'pusher_internal:watchlist_events') {\n this.handleEvent(pusherEvent);\n }\n });\n }\n}\n","function flatPromise() {\n let resolve, reject;\n const promise = new Promise((res, rej) => {\n resolve = res;\n reject = rej;\n });\n return { promise, resolve, reject };\n}\n\nexport default flatPromise;\n","import Pusher from './pusher';\nimport Logger from './logger';\nimport {\n UserAuthenticationData,\n UserAuthenticationCallback\n} from './auth/options';\nimport Channel from './channels/channel';\nimport WatchlistFacade from './watchlist';\nimport EventsDispatcher from './events/dispatcher';\nimport flatPromise from './utils/flat_promise';\n\nexport default class UserFacade extends EventsDispatcher {\n pusher: Pusher;\n signin_requested: boolean = false;\n user_data: any = null;\n serverToUserChannel: Channel = null;\n signinDonePromise: Promise = null;\n watchlist: WatchlistFacade;\n private _signinDoneResolve: Function = null;\n\n public constructor(pusher: Pusher) {\n super(function(eventName, data) {\n Logger.debug('No callbacks on user for ' + eventName);\n });\n this.pusher = pusher;\n this.pusher.connection.bind('state_change', ({ previous, current }) => {\n if (previous !== 'connected' && current === 'connected') {\n this._signin();\n }\n if (previous === 'connected' && current !== 'connected') {\n this._cleanup();\n this._newSigninPromiseIfNeeded();\n }\n });\n\n this.watchlist = new WatchlistFacade(pusher);\n\n this.pusher.connection.bind('message', event => {\n var eventName = event.event;\n if (eventName === 'pusher:signin_success') {\n this._onSigninSuccess(event.data);\n }\n if (\n this.serverToUserChannel &&\n this.serverToUserChannel.name === event.channel\n ) {\n this.serverToUserChannel.handleEvent(event);\n }\n });\n }\n\n public signin() {\n if (this.signin_requested) {\n return;\n }\n\n this.signin_requested = true;\n this._signin();\n }\n\n private _signin() {\n if (!this.signin_requested) {\n return;\n }\n\n this._newSigninPromiseIfNeeded();\n\n if (this.pusher.connection.state !== 'connected') {\n // Signin will be attempted when the connection is connected\n return;\n }\n\n this.pusher.config.userAuthenticator(\n {\n socketId: this.pusher.connection.socket_id\n },\n this._onAuthorize\n );\n }\n\n private _onAuthorize: UserAuthenticationCallback = (\n err,\n authData: UserAuthenticationData\n ) => {\n if (err) {\n Logger.warn(`Error during signin: ${err}`);\n this._cleanup();\n return;\n }\n\n this.pusher.send_event('pusher:signin', {\n auth: authData.auth,\n user_data: authData.user_data\n });\n\n // Later when we get pusher:singin_success event, the user will be marked as signed in\n };\n\n private _onSigninSuccess(data: any) {\n try {\n this.user_data = JSON.parse(data.user_data);\n } catch (e) {\n Logger.error(`Failed parsing user data after signin: ${data.user_data}`);\n this._cleanup();\n return;\n }\n\n if (typeof this.user_data.id !== 'string' || this.user_data.id === '') {\n Logger.error(\n `user_data doesn't contain an id. user_data: ${this.user_data}`\n );\n this._cleanup();\n return;\n }\n\n // Signin succeeded\n this._signinDoneResolve();\n this._subscribeChannels();\n }\n\n private _subscribeChannels() {\n const ensure_subscribed = channel => {\n if (channel.subscriptionPending && channel.subscriptionCancelled) {\n channel.reinstateSubscription();\n } else if (\n !channel.subscriptionPending &&\n this.pusher.connection.state === 'connected'\n ) {\n channel.subscribe();\n }\n };\n\n this.serverToUserChannel = new Channel(\n `#server-to-user-${this.user_data.id}`,\n this.pusher\n );\n this.serverToUserChannel.bind_global((eventName, data) => {\n if (\n eventName.indexOf('pusher_internal:') === 0 ||\n eventName.indexOf('pusher:') === 0\n ) {\n // ignore internal events\n return;\n }\n this.emit(eventName, data);\n });\n ensure_subscribed(this.serverToUserChannel);\n }\n\n private _cleanup() {\n this.user_data = null;\n if (this.serverToUserChannel) {\n this.serverToUserChannel.unbind_all();\n this.serverToUserChannel.disconnect();\n this.serverToUserChannel = null;\n }\n\n if (this.signin_requested) {\n // If signin is in progress and cleanup is called,\n // Mark the current signin process as done.\n this._signinDoneResolve();\n }\n }\n\n private _newSigninPromiseIfNeeded() {\n if (!this.signin_requested) {\n return;\n }\n\n // If there is a promise and it is not resolved, return without creating a new one.\n if (this.signinDonePromise && !(this.signinDonePromise as any).done) {\n return;\n }\n\n // This promise is never rejected.\n // It gets resolved when the signin process is done whether it failed or succeeded\n const { promise, resolve, reject: _ } = flatPromise();\n (promise as any).done = false;\n const setDone = () => {\n (promise as any).done = true;\n };\n promise.then(setDone).catch(setDone);\n this.signinDonePromise = promise;\n this._signinDoneResolve = resolve;\n }\n}\n","import AbstractRuntime from '../runtimes/interface';\nimport Runtime from 'runtime';\nimport * as Collections from './utils/collections';\nimport Channels from './channels/channels';\nimport Channel from './channels/channel';\nimport { default as EventsDispatcher } from './events/dispatcher';\nimport Timeline from './timeline/timeline';\nimport TimelineSender from './timeline/timeline_sender';\nimport TimelineLevel from './timeline/level';\nimport { defineTransport } from './strategies/strategy_builder';\nimport ConnectionManager from './connection/connection_manager';\nimport { PeriodicTimer } from './utils/timers';\nimport Defaults from './defaults';\nimport Logger from './logger';\nimport Factory from './utils/factory';\nimport { Options, ClusterOptions, validateOptions } from './options';\nimport { Config, getConfig } from './config';\nimport StrategyOptions from './strategies/strategy_options';\nimport UserFacade from './user';\n\nexport default class Pusher {\n /* STATIC PROPERTIES */\n static instances: Pusher[] = [];\n static isReady: boolean = false;\n static logToConsole: boolean = false;\n\n // for jsonp\n static Runtime: AbstractRuntime = Runtime;\n static ScriptReceivers: any = (Runtime).ScriptReceivers;\n static DependenciesReceivers: any = (Runtime).DependenciesReceivers;\n static auth_callbacks: any = (Runtime).auth_callbacks;\n\n static ready() {\n Pusher.isReady = true;\n for (var i = 0, l = Pusher.instances.length; i < l; i++) {\n Pusher.instances[i].connect();\n }\n }\n\n static log: (message: any) => void;\n\n private static getClientFeatures(): string[] {\n return Collections.keys(\n Collections.filterObject({ ws: Runtime.Transports.ws }, function(t) {\n return t.isSupported({});\n })\n );\n }\n\n /* INSTANCE PROPERTIES */\n key: string;\n options: Options;\n config: Config;\n channels: Channels;\n global_emitter: EventsDispatcher;\n sessionID: number;\n timeline: Timeline;\n timelineSender: TimelineSender;\n connection: ConnectionManager;\n timelineSenderTimer: PeriodicTimer;\n user: UserFacade;\n constructor(app_key: string, options: Options) {\n checkAppKey(app_key);\n validateOptions(options);\n this.key = app_key;\n this.options = options;\n this.config = getConfig(this.options, this);\n\n this.channels = Factory.createChannels();\n this.global_emitter = new EventsDispatcher();\n this.sessionID = Runtime.randomInt(1000000000);\n\n this.timeline = new Timeline(this.key, this.sessionID, {\n cluster: this.config.cluster,\n features: Pusher.getClientFeatures(),\n params: this.config.timelineParams || {},\n limit: 50,\n level: TimelineLevel.INFO,\n version: Defaults.VERSION\n });\n if (this.config.enableStats) {\n this.timelineSender = Factory.createTimelineSender(this.timeline, {\n host: this.config.statsHost,\n path: '/timeline/v2/' + Runtime.TimelineTransport.name\n });\n }\n\n var getStrategy = (options: StrategyOptions) => {\n return Runtime.getDefaultStrategy(this.config, options, defineTransport);\n };\n\n this.connection = Factory.createConnectionManager(this.key, {\n getStrategy: getStrategy,\n timeline: this.timeline,\n activityTimeout: this.config.activityTimeout,\n pongTimeout: this.config.pongTimeout,\n unavailableTimeout: this.config.unavailableTimeout,\n useTLS: Boolean(this.config.useTLS)\n });\n\n this.connection.bind('connected', () => {\n this.subscribeAll();\n if (this.timelineSender) {\n this.timelineSender.send(this.connection.isUsingTLS());\n }\n });\n\n this.connection.bind('message', event => {\n var eventName = event.event;\n var internal = eventName.indexOf('pusher_internal:') === 0;\n if (event.channel) {\n var channel = this.channel(event.channel);\n if (channel) {\n channel.handleEvent(event);\n }\n }\n // Emit globally [deprecated]\n if (!internal) {\n this.global_emitter.emit(event.event, event.data);\n }\n });\n this.connection.bind('connecting', () => {\n this.channels.disconnect();\n });\n this.connection.bind('disconnected', () => {\n this.channels.disconnect();\n });\n this.connection.bind('error', err => {\n Logger.warn(err);\n });\n\n Pusher.instances.push(this);\n this.timeline.info({ instances: Pusher.instances.length });\n\n this.user = new UserFacade(this);\n\n if (Pusher.isReady) {\n this.connect();\n }\n }\n\n /**\n * Allows you to switch Pusher cluster without\n * losing all the channels/subscription binding\n * as this is internally managed by the SDK.\n */\n switchCluster(options: ClusterOptions) {\n const { appKey, cluster } = options;\n this.key = appKey;\n this.options = { ...this.options, cluster };\n this.config = getConfig(this.options, this);\n this.connection.switchCluster(this.key);\n }\n\n channel(name: string): Channel {\n return this.channels.find(name);\n }\n\n allChannels(): Channel[] {\n return this.channels.all();\n }\n\n connect() {\n this.connection.connect();\n\n if (this.timelineSender) {\n if (!this.timelineSenderTimer) {\n var usingTLS = this.connection.isUsingTLS();\n var timelineSender = this.timelineSender;\n this.timelineSenderTimer = new PeriodicTimer(60000, function() {\n timelineSender.send(usingTLS);\n });\n }\n }\n }\n\n disconnect() {\n this.connection.disconnect();\n\n if (this.timelineSenderTimer) {\n this.timelineSenderTimer.ensureAborted();\n this.timelineSenderTimer = null;\n }\n }\n\n bind(event_name: string, callback: Function, context?: any): Pusher {\n this.global_emitter.bind(event_name, callback, context);\n return this;\n }\n\n unbind(event_name?: string, callback?: Function, context?: any): Pusher {\n this.global_emitter.unbind(event_name, callback, context);\n return this;\n }\n\n bind_global(callback: Function): Pusher {\n this.global_emitter.bind_global(callback);\n return this;\n }\n\n unbind_global(callback?: Function): Pusher {\n this.global_emitter.unbind_global(callback);\n return this;\n }\n\n unbind_all(callback?: Function): Pusher {\n this.global_emitter.unbind_all();\n return this;\n }\n\n subscribeAll() {\n var channelName;\n for (channelName in this.channels.channels) {\n if (this.channels.channels.hasOwnProperty(channelName)) {\n this.subscribe(channelName);\n }\n }\n }\n\n subscribe(channel_name: string) {\n var channel = this.channels.add(channel_name, this);\n if (channel.subscriptionPending && channel.subscriptionCancelled) {\n channel.reinstateSubscription();\n } else if (\n !channel.subscriptionPending &&\n this.connection.state === 'connected'\n ) {\n channel.subscribe();\n }\n return channel;\n }\n\n unsubscribe(channel_name: string) {\n var channel = this.channels.find(channel_name);\n if (channel && channel.subscriptionPending) {\n channel.cancelSubscription();\n } else {\n channel = this.channels.remove(channel_name);\n if (channel && channel.subscribed) {\n channel.unsubscribe();\n }\n }\n }\n\n send_event(event_name: string, data: any, channel?: string) {\n return this.connection.send_event(event_name, data, channel);\n }\n\n shouldUseTLS(): boolean {\n return this.config.useTLS;\n }\n\n signin() {\n this.user.signin();\n }\n}\n\nfunction checkAppKey(key) {\n if (key === null || key === undefined) {\n throw 'You must pass your app key when you instantiate Pusher.';\n }\n}\n\nRuntime.setup(Pusher);\n","import Pusher from './pusher';\nimport { Options, validateOptions } from './options';\nimport * as nacl from 'tweetnacl';\n\nexport default class PusherWithEncryption extends Pusher {\n constructor(app_key: string, options: Options) {\n Pusher.logToConsole = PusherWithEncryption.logToConsole;\n Pusher.log = PusherWithEncryption.log;\n\n validateOptions(options);\n options.nacl = nacl;\n super(app_key, options);\n }\n}\n"],"sourceRoot":""} \ No newline at end of file diff --git a/dist/web/pusher.js b/dist/web/pusher.js index 71278d861..259cf6e4a 100644 --- a/dist/web/pusher.js +++ b/dist/web/pusher.js @@ -1,5 +1,5 @@ /*! - * Pusher JavaScript Library v8.4.0-rc1 + * Pusher JavaScript Library v8.4.0-rc2 * https://pusher.com/ * * Copyright 2020, Pusher @@ -591,7 +591,7 @@ var ScriptReceivers = new ScriptReceiverFactory('_pusher_script_', 'Pusher.Scrip // CONCATENATED MODULE: ./src/core/defaults.ts var Defaults = { - VERSION: "8.4.0-rc1", + VERSION: "8.4.0-rc2", PROTOCOL: 7, wsPort: 80, wssPort: 443, @@ -4181,10 +4181,12 @@ function getEnableStatsConfig(opts) { } return false; } +const hasCustomHandler = (auth) => { + return 'customHandler' in auth && auth['customHandler'] != null; +}; function buildUserAuthenticator(opts) { const userAuthentication = Object.assign(Object.assign({}, defaults.userAuthentication), opts.userAuthentication); - if ('customHandler' in userAuthentication && - userAuthentication['customHandler'] != null) { + if (hasCustomHandler(userAuthentication)) { return userAuthentication['customHandler']; } return user_authenticator(userAuthentication); @@ -4205,15 +4207,17 @@ function buildChannelAuth(opts, pusher) { if ('headers' in opts.auth) channelAuthorization.headers = opts.auth.headers; } - if ('authorizer' in opts) - channelAuthorization.customHandler = ChannelAuthorizerProxy(pusher, channelAuthorization, opts.authorizer); + if ('authorizer' in opts) { + return { + customHandler: ChannelAuthorizerProxy(pusher, channelAuthorization, opts.authorizer) + }; + } } return channelAuthorization; } function buildChannelAuthorizer(opts, pusher) { const channelAuthorization = buildChannelAuth(opts, pusher); - if ('customHandler' in channelAuthorization && - channelAuthorization['customHandler'] != null) { + if (hasCustomHandler(channelAuthorization)) { return channelAuthorization['customHandler']; } return channel_authorizer(channelAuthorization); @@ -4420,7 +4424,8 @@ class pusher_Pusher { checkAppKey(app_key); validateOptions(options); this.key = app_key; - this.config = getConfig(options, this); + this.options = options; + this.config = getConfig(this.options, this); this.channels = factory.createChannels(); this.global_emitter = new dispatcher_Dispatcher(); this.sessionID = runtime.randomInt(1000000000); diff --git a/dist/web/pusher.js.map b/dist/web/pusher.js.map index 008bb9506..e699f535c 100644 --- a/dist/web/pusher.js.map +++ b/dist/web/pusher.js.map @@ -1 +1 @@ -{"version":3,"sources":["webpack://Pusher/webpack/universalModuleDefinition","webpack://Pusher/webpack/bootstrap","webpack://Pusher/./node_modules/@stablelib/base64/base64.ts","webpack://Pusher/./node_modules/@stablelib/utf8/utf8.ts","webpack://Pusher/./src/core/pusher.js","webpack://Pusher/./src/runtimes/web/dom/script_receiver_factory.ts","webpack://Pusher/./src/core/defaults.ts","webpack://Pusher/./src/runtimes/web/dom/dependency_loader.ts","webpack://Pusher/./src/runtimes/web/dom/dependencies.ts","webpack://Pusher/./src/core/utils/url_store.ts","webpack://Pusher/./src/core/auth/options.ts","webpack://Pusher/./src/core/errors.ts","webpack://Pusher/./src/runtimes/isomorphic/auth/xhr_auth.ts","webpack://Pusher/./src/core/base64.ts","webpack://Pusher/./src/core/utils/timers/abstract_timer.ts","webpack://Pusher/./src/core/utils/timers/index.ts","webpack://Pusher/./src/core/util.ts","webpack://Pusher/./src/core/utils/collections.ts","webpack://Pusher/./src/core/logger.ts","webpack://Pusher/./src/runtimes/web/auth/jsonp_auth.ts","webpack://Pusher/./src/runtimes/web/dom/script_request.ts","webpack://Pusher/./src/runtimes/web/dom/jsonp_request.ts","webpack://Pusher/./src/runtimes/web/timeline/jsonp_timeline.ts","webpack://Pusher/./src/core/transports/url_schemes.ts","webpack://Pusher/./src/core/events/callback_registry.ts","webpack://Pusher/./src/core/events/dispatcher.ts","webpack://Pusher/./src/core/transports/transport_connection.ts","webpack://Pusher/./src/core/transports/transport.ts","webpack://Pusher/./src/runtimes/isomorphic/transports/transports.ts","webpack://Pusher/./src/runtimes/web/transports/transports.ts","webpack://Pusher/./src/runtimes/web/net_info.ts","webpack://Pusher/./src/core/transports/assistant_to_the_transport_manager.ts","webpack://Pusher/./src/core/connection/protocol/protocol.ts","webpack://Pusher/./src/core/connection/connection.ts","webpack://Pusher/./src/core/connection/handshake/index.ts","webpack://Pusher/./src/core/timeline/timeline_sender.ts","webpack://Pusher/./src/core/channels/channel.ts","webpack://Pusher/./src/core/channels/private_channel.ts","webpack://Pusher/./src/core/channels/members.ts","webpack://Pusher/./src/core/channels/presence_channel.ts","webpack://Pusher/./src/core/channels/encrypted_channel.ts","webpack://Pusher/./src/core/connection/connection_manager.ts","webpack://Pusher/./src/core/channels/channels.ts","webpack://Pusher/./src/core/utils/factory.ts","webpack://Pusher/./src/core/transports/transport_manager.ts","webpack://Pusher/./src/core/strategies/sequential_strategy.ts","webpack://Pusher/./src/core/strategies/best_connected_ever_strategy.ts","webpack://Pusher/./src/core/strategies/websocket_prioritized_cached_strategy.ts","webpack://Pusher/./src/core/strategies/delayed_strategy.ts","webpack://Pusher/./src/core/strategies/if_strategy.ts","webpack://Pusher/./src/core/strategies/first_connected_strategy.ts","webpack://Pusher/./src/runtimes/web/default_strategy.ts","webpack://Pusher/./src/runtimes/web/transports/transport_connection_initializer.ts","webpack://Pusher/./src/runtimes/web/http/http_xdomain_request.ts","webpack://Pusher/./src/core/http/http_request.ts","webpack://Pusher/./src/core/http/state.ts","webpack://Pusher/./src/core/http/http_socket.ts","webpack://Pusher/./src/core/http/http_streaming_socket.ts","webpack://Pusher/./src/core/http/http_polling_socket.ts","webpack://Pusher/./src/runtimes/isomorphic/http/http_xhr_request.ts","webpack://Pusher/./src/runtimes/isomorphic/http/http.ts","webpack://Pusher/./src/runtimes/web/http/http.ts","webpack://Pusher/./src/runtimes/web/runtime.ts","webpack://Pusher/./src/core/timeline/level.ts","webpack://Pusher/./src/core/timeline/timeline.ts","webpack://Pusher/./src/core/strategies/transport_strategy.ts","webpack://Pusher/./src/core/strategies/strategy_builder.ts","webpack://Pusher/./src/core/options.ts","webpack://Pusher/./src/core/auth/user_authenticator.ts","webpack://Pusher/./src/core/auth/channel_authorizer.ts","webpack://Pusher/./src/core/auth/deprecated_channel_authorizer.ts","webpack://Pusher/./src/core/config.ts","webpack://Pusher/./src/core/watchlist.ts","webpack://Pusher/./src/core/utils/flat_promise.ts","webpack://Pusher/./src/core/user.ts","webpack://Pusher/./src/core/pusher.ts"],"names":[],"mappings":";;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AACD,O;QCVA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;;QAEA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;;;QAGA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;QACA,0CAA0C,gCAAgC;QAC1E;QACA;;QAEA;QACA;QACA;QACA,wDAAwD,kBAAkB;QAC1E;QACA,iDAAiD,cAAc;QAC/D;;QAEA;QACA;Q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module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"Pusher\"] = factory();\n\telse\n\t\troot[\"Pusher\"] = factory();\n})(window, function() {\nreturn "," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 2);\n","// Copyright (C) 2016 Dmitry Chestnykh\n// MIT License. See LICENSE file for details.\n\n/**\n * Package base64 implements Base64 encoding and decoding.\n */\n\n// Invalid character used in decoding to indicate\n// that the character to decode is out of range of\n// alphabet and cannot be decoded.\nconst INVALID_BYTE = 256;\n\n/**\n * Implements standard Base64 encoding.\n *\n * Operates in constant time.\n */\nexport class Coder {\n // TODO(dchest): methods to encode chunk-by-chunk.\n\n constructor(private _paddingCharacter = \"=\") { }\n\n encodedLength(length: number): number {\n if (!this._paddingCharacter) {\n return (length * 8 + 5) / 6 | 0;\n }\n return (length + 2) / 3 * 4 | 0;\n }\n\n encode(data: Uint8Array): string {\n let out = \"\";\n\n let i = 0;\n for (; i < data.length - 2; i += 3) {\n let c = (data[i] << 16) | (data[i + 1] << 8) | (data[i + 2]);\n out += this._encodeByte((c >>> 3 * 6) & 63);\n out += this._encodeByte((c >>> 2 * 6) & 63);\n out += this._encodeByte((c >>> 1 * 6) & 63);\n out += this._encodeByte((c >>> 0 * 6) & 63);\n }\n\n const left = data.length - i;\n if (left > 0) {\n let c = (data[i] << 16) | (left === 2 ? data[i + 1] << 8 : 0);\n out += this._encodeByte((c >>> 3 * 6) & 63);\n out += this._encodeByte((c >>> 2 * 6) & 63);\n if (left === 2) {\n out += this._encodeByte((c >>> 1 * 6) & 63);\n } else {\n out += this._paddingCharacter || \"\";\n }\n out += this._paddingCharacter || \"\";\n }\n\n return out;\n }\n\n maxDecodedLength(length: number): number {\n if (!this._paddingCharacter) {\n return (length * 6 + 7) / 8 | 0;\n }\n return length / 4 * 3 | 0;\n }\n\n decodedLength(s: string): number {\n return this.maxDecodedLength(s.length - this._getPaddingLength(s));\n }\n\n decode(s: string): Uint8Array {\n if (s.length === 0) {\n return new Uint8Array(0);\n }\n const paddingLength = this._getPaddingLength(s);\n const length = s.length - paddingLength;\n const out = new Uint8Array(this.maxDecodedLength(length));\n let op = 0;\n let i = 0;\n let haveBad = 0;\n let v0 = 0, v1 = 0, v2 = 0, v3 = 0;\n for (; i < length - 4; i += 4) {\n v0 = this._decodeChar(s.charCodeAt(i + 0));\n v1 = this._decodeChar(s.charCodeAt(i + 1));\n v2 = this._decodeChar(s.charCodeAt(i + 2));\n v3 = this._decodeChar(s.charCodeAt(i + 3));\n out[op++] = (v0 << 2) | (v1 >>> 4);\n out[op++] = (v1 << 4) | (v2 >>> 2);\n out[op++] = (v2 << 6) | v3;\n haveBad |= v0 & INVALID_BYTE;\n haveBad |= v1 & INVALID_BYTE;\n haveBad |= v2 & INVALID_BYTE;\n haveBad |= v3 & INVALID_BYTE;\n }\n if (i < length - 1) {\n v0 = this._decodeChar(s.charCodeAt(i));\n v1 = this._decodeChar(s.charCodeAt(i + 1));\n out[op++] = (v0 << 2) | (v1 >>> 4);\n haveBad |= v0 & INVALID_BYTE;\n haveBad |= v1 & INVALID_BYTE;\n }\n if (i < length - 2) {\n v2 = this._decodeChar(s.charCodeAt(i + 2));\n out[op++] = (v1 << 4) | (v2 >>> 2);\n haveBad |= v2 & INVALID_BYTE;\n }\n if (i < length - 3) {\n v3 = this._decodeChar(s.charCodeAt(i + 3));\n out[op++] = (v2 << 6) | v3;\n haveBad |= v3 & INVALID_BYTE;\n }\n if (haveBad !== 0) {\n throw new Error(\"Base64Coder: incorrect characters for decoding\");\n }\n return out;\n }\n\n // Standard encoding have the following encoded/decoded ranges,\n // which we need to convert between.\n //\n // ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 0123456789 + /\n // Index: 0 - 25 26 - 51 52 - 61 62 63\n // ASCII: 65 - 90 97 - 122 48 - 57 43 47\n //\n\n // Encode 6 bits in b into a new character.\n protected _encodeByte(b: number): string {\n // Encoding uses constant time operations as follows:\n //\n // 1. Define comparison of A with B using (A - B) >>> 8:\n // if A > B, then result is positive integer\n // if A <= B, then result is 0\n //\n // 2. Define selection of C or 0 using bitwise AND: X & C:\n // if X == 0, then result is 0\n // if X != 0, then result is C\n //\n // 3. Start with the smallest comparison (b >= 0), which is always\n // true, so set the result to the starting ASCII value (65).\n //\n // 4. Continue comparing b to higher ASCII values, and selecting\n // zero if comparison isn't true, otherwise selecting a value\n // to add to result, which:\n //\n // a) undoes the previous addition\n // b) provides new value to add\n //\n let result = b;\n // b >= 0\n result += 65;\n // b > 25\n result += ((25 - b) >>> 8) & ((0 - 65) - 26 + 97);\n // b > 51\n result += ((51 - b) >>> 8) & ((26 - 97) - 52 + 48);\n // b > 61\n result += ((61 - b) >>> 8) & ((52 - 48) - 62 + 43);\n // b > 62\n result += ((62 - b) >>> 8) & ((62 - 43) - 63 + 47);\n\n return String.fromCharCode(result);\n }\n\n // Decode a character code into a byte.\n // Must return 256 if character is out of alphabet range.\n protected _decodeChar(c: number): number {\n // Decoding works similar to encoding: using the same comparison\n // function, but now it works on ranges: result is always incremented\n // by value, but this value becomes zero if the range is not\n // satisfied.\n //\n // Decoding starts with invalid value, 256, which is then\n // subtracted when the range is satisfied. If none of the ranges\n // apply, the function returns 256, which is then checked by\n // the caller to throw error.\n let result = INVALID_BYTE; // start with invalid character\n\n // c == 43 (c > 42 and c < 44)\n result += (((42 - c) & (c - 44)) >>> 8) & (-INVALID_BYTE + c - 43 + 62);\n // c == 47 (c > 46 and c < 48)\n result += (((46 - c) & (c - 48)) >>> 8) & (-INVALID_BYTE + c - 47 + 63);\n // c > 47 and c < 58\n result += (((47 - c) & (c - 58)) >>> 8) & (-INVALID_BYTE + c - 48 + 52);\n // c > 64 and c < 91\n result += (((64 - c) & (c - 91)) >>> 8) & (-INVALID_BYTE + c - 65 + 0);\n // c > 96 and c < 123\n result += (((96 - c) & (c - 123)) >>> 8) & (-INVALID_BYTE + c - 97 + 26);\n\n return result;\n }\n\n private _getPaddingLength(s: string): number {\n let paddingLength = 0;\n if (this._paddingCharacter) {\n for (let i = s.length - 1; i >= 0; i--) {\n if (s[i] !== this._paddingCharacter) {\n break;\n }\n paddingLength++;\n }\n if (s.length < 4 || paddingLength > 2) {\n throw new Error(\"Base64Coder: incorrect padding\");\n }\n }\n return paddingLength;\n }\n\n}\n\nconst stdCoder = new Coder();\n\nexport function encode(data: Uint8Array): string {\n return stdCoder.encode(data);\n}\n\nexport function decode(s: string): Uint8Array {\n return stdCoder.decode(s);\n}\n\n/**\n * Implements URL-safe Base64 encoding.\n * (Same as Base64, but '+' is replaced with '-', and '/' with '_').\n *\n * Operates in constant time.\n */\nexport class URLSafeCoder extends Coder {\n // URL-safe encoding have the following encoded/decoded ranges:\n //\n // ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 0123456789 - _\n // Index: 0 - 25 26 - 51 52 - 61 62 63\n // ASCII: 65 - 90 97 - 122 48 - 57 45 95\n //\n\n protected _encodeByte(b: number): string {\n let result = b;\n // b >= 0\n result += 65;\n // b > 25\n result += ((25 - b) >>> 8) & ((0 - 65) - 26 + 97);\n // b > 51\n result += ((51 - b) >>> 8) & ((26 - 97) - 52 + 48);\n // b > 61\n result += ((61 - b) >>> 8) & ((52 - 48) - 62 + 45);\n // b > 62\n result += ((62 - b) >>> 8) & ((62 - 45) - 63 + 95);\n\n return String.fromCharCode(result);\n }\n\n protected _decodeChar(c: number): number {\n let result = INVALID_BYTE;\n\n // c == 45 (c > 44 and c < 46)\n result += (((44 - c) & (c - 46)) >>> 8) & (-INVALID_BYTE + c - 45 + 62);\n // c == 95 (c > 94 and c < 96)\n result += (((94 - c) & (c - 96)) >>> 8) & (-INVALID_BYTE + c - 95 + 63);\n // c > 47 and c < 58\n result += (((47 - c) & (c - 58)) >>> 8) & (-INVALID_BYTE + c - 48 + 52);\n // c > 64 and c < 91\n result += (((64 - c) & (c - 91)) >>> 8) & (-INVALID_BYTE + c - 65 + 0);\n // c > 96 and c < 123\n result += (((96 - c) & (c - 123)) >>> 8) & (-INVALID_BYTE + c - 97 + 26);\n\n return result;\n }\n}\n\nconst urlSafeCoder = new URLSafeCoder();\n\nexport function encodeURLSafe(data: Uint8Array): string {\n return urlSafeCoder.encode(data);\n}\n\nexport function decodeURLSafe(s: string): Uint8Array {\n return urlSafeCoder.decode(s);\n}\n\n\nexport const encodedLength = (length: number) =>\n stdCoder.encodedLength(length);\n\nexport const maxDecodedLength = (length: number) =>\n stdCoder.maxDecodedLength(length);\n\nexport const decodedLength = (s: string) =>\n stdCoder.decodedLength(s);\n","// Copyright (C) 2016 Dmitry Chestnykh\n// MIT License. See LICENSE file for details.\n\n/**\n * Package utf8 implements UTF-8 encoding and decoding.\n */\n\nconst INVALID_UTF16 = \"utf8: invalid string\";\nconst INVALID_UTF8 = \"utf8: invalid source encoding\";\n\n/**\n * Encodes the given string into UTF-8 byte array.\n * Throws if the source string has invalid UTF-16 encoding.\n */\nexport function encode(s: string): Uint8Array {\n // Calculate result length and allocate output array.\n // encodedLength() also validates string and throws errors,\n // so we don't need repeat validation here.\n const arr = new Uint8Array(encodedLength(s));\n\n let pos = 0;\n for (let i = 0; i < s.length; i++) {\n let c = s.charCodeAt(i);\n if (c < 0x80) {\n arr[pos++] = c;\n } else if (c < 0x800) {\n arr[pos++] = 0xc0 | c >> 6;\n arr[pos++] = 0x80 | c & 0x3f;\n } else if (c < 0xd800) {\n arr[pos++] = 0xe0 | c >> 12;\n arr[pos++] = 0x80 | (c >> 6) & 0x3f;\n arr[pos++] = 0x80 | c & 0x3f;\n } else {\n i++; // get one more character\n c = (c & 0x3ff) << 10;\n c |= s.charCodeAt(i) & 0x3ff;\n c += 0x10000;\n\n arr[pos++] = 0xf0 | c >> 18;\n arr[pos++] = 0x80 | (c >> 12) & 0x3f;\n arr[pos++] = 0x80 | (c >> 6) & 0x3f;\n arr[pos++] = 0x80 | c & 0x3f;\n }\n }\n return arr;\n}\n\n/**\n * Returns the number of bytes required to encode the given string into UTF-8.\n * Throws if the source string has invalid UTF-16 encoding.\n */\nexport function encodedLength(s: string): number {\n let result = 0;\n for (let i = 0; i < s.length; i++) {\n const c = s.charCodeAt(i);\n if (c < 0x80) {\n result += 1;\n } else if (c < 0x800) {\n result += 2;\n } else if (c < 0xd800) {\n result += 3;\n } else if (c <= 0xdfff) {\n if (i >= s.length - 1) {\n throw new Error(INVALID_UTF16);\n }\n i++; // \"eat\" next character\n result += 4;\n } else {\n throw new Error(INVALID_UTF16);\n }\n }\n return result;\n}\n\n/**\n * Decodes the given byte array from UTF-8 into a string.\n * Throws if encoding is invalid.\n */\nexport function decode(arr: Uint8Array): string {\n const chars: string[] = [];\n for (let i = 0; i < arr.length; i++) {\n let b = arr[i];\n\n if (b & 0x80) {\n let min;\n if (b < 0xe0) {\n // Need 1 more byte.\n if (i >= arr.length) {\n throw new Error(INVALID_UTF8);\n }\n const n1 = arr[++i];\n if ((n1 & 0xc0) !== 0x80) {\n throw new Error(INVALID_UTF8);\n }\n b = (b & 0x1f) << 6 | (n1 & 0x3f);\n min = 0x80;\n } else if (b < 0xf0) {\n // Need 2 more bytes.\n if (i >= arr.length - 1) {\n throw new Error(INVALID_UTF8);\n }\n const n1 = arr[++i];\n const n2 = arr[++i];\n if ((n1 & 0xc0) !== 0x80 || (n2 & 0xc0) !== 0x80) {\n throw new Error(INVALID_UTF8);\n }\n b = (b & 0x0f) << 12 | (n1 & 0x3f) << 6 | (n2 & 0x3f);\n min = 0x800;\n } else if (b < 0xf8) {\n // Need 3 more bytes.\n if (i >= arr.length - 2) {\n throw new Error(INVALID_UTF8);\n }\n const n1 = arr[++i];\n const n2 = arr[++i];\n const n3 = arr[++i];\n if ((n1 & 0xc0) !== 0x80 || (n2 & 0xc0) !== 0x80 || (n3 & 0xc0) !== 0x80) {\n throw new Error(INVALID_UTF8);\n }\n b = (b & 0x0f) << 18 | (n1 & 0x3f) << 12 | (n2 & 0x3f) << 6 | (n3 & 0x3f);\n min = 0x10000;\n } else {\n throw new Error(INVALID_UTF8);\n }\n\n if (b < min || (b >= 0xd800 && b <= 0xdfff)) {\n throw new Error(INVALID_UTF8);\n }\n\n if (b >= 0x10000) {\n // Surrogate pair.\n if (b > 0x10ffff) {\n throw new Error(INVALID_UTF8);\n }\n b -= 0x10000;\n chars.push(String.fromCharCode(0xd800 | (b >> 10)));\n b = 0xdc00 | (b & 0x3ff);\n }\n }\n\n chars.push(String.fromCharCode(b));\n }\n return chars.join(\"\");\n}\n","// required so we don't have to do require('pusher').default etc.\nmodule.exports = require('./pusher').default;\n","import ScriptReceiver from './script_receiver';\n\n/** Builds receivers for JSONP and Script requests.\n *\n * Each receiver is an object with following fields:\n * - number - unique (for the factory instance), numerical id of the receiver\n * - id - a string ID that can be used in DOM attributes\n * - name - name of the function triggering the receiver\n * - callback - callback function\n *\n * Receivers are triggered only once, on the first callback call.\n *\n * Receivers can be called by their name or by accessing factory object\n * by the number key.\n *\n * @param {String} prefix the prefix used in ids\n * @param {String} name the name of the object\n */\nexport class ScriptReceiverFactory {\n lastId: number;\n prefix: string;\n name: string;\n\n constructor(prefix: string, name: string) {\n this.lastId = 0;\n this.prefix = prefix;\n this.name = name;\n }\n\n create(callback: Function): ScriptReceiver {\n this.lastId++;\n\n var number = this.lastId;\n var id = this.prefix + number;\n var name = this.name + '[' + number + ']';\n\n var called = false;\n var callbackWrapper = function() {\n if (!called) {\n callback.apply(null, arguments);\n called = true;\n }\n };\n\n this[number] = callbackWrapper;\n return { number: number, id: id, name: name, callback: callbackWrapper };\n }\n\n remove(receiver: ScriptReceiver) {\n delete this[receiver.number];\n }\n}\n\nexport var ScriptReceivers = new ScriptReceiverFactory(\n '_pusher_script_',\n 'Pusher.ScriptReceivers'\n);\n","import {\n ChannelAuthorizationOptions,\n UserAuthenticationOptions\n} from './auth/options';\nimport { AuthTransport } from './config';\n\nexport interface DefaultConfig {\n VERSION: string;\n PROTOCOL: number;\n wsPort: number;\n wssPort: number;\n wsPath: string;\n httpHost: string;\n httpPort: number;\n httpsPort: number;\n httpPath: string;\n stats_host: string;\n authEndpoint: string;\n authTransport: AuthTransport;\n activityTimeout: number;\n pongTimeout: number;\n unavailableTimeout: number;\n userAuthentication: UserAuthenticationOptions;\n channelAuthorization: ChannelAuthorizationOptions;\n\n cdn_http?: string;\n cdn_https?: string;\n dependency_suffix?: string;\n}\n\nvar Defaults: DefaultConfig = {\n VERSION: VERSION,\n PROTOCOL: 7,\n\n wsPort: 80,\n wssPort: 443,\n wsPath: '',\n // DEPRECATED: SockJS fallback parameters\n httpHost: 'sockjs.pusher.com',\n httpPort: 80,\n httpsPort: 443,\n httpPath: '/pusher',\n // DEPRECATED: Stats\n stats_host: 'stats.pusher.com',\n // DEPRECATED: Other settings\n authEndpoint: '/pusher/auth',\n authTransport: 'ajax',\n activityTimeout: 120000,\n pongTimeout: 30000,\n unavailableTimeout: 10000,\n userAuthentication: {\n endpoint: '/pusher/user-auth',\n transport: 'ajax'\n },\n channelAuthorization: {\n endpoint: '/pusher/auth',\n transport: 'ajax'\n },\n\n // CDN configuration\n cdn_http: CDN_HTTP,\n cdn_https: CDN_HTTPS,\n dependency_suffix: DEPENDENCY_SUFFIX\n};\n\nexport default Defaults;\n","import {\n ScriptReceivers,\n ScriptReceiverFactory\n} from './script_receiver_factory';\nimport Runtime from 'runtime';\nimport ScriptRequest from './script_request';\n\n/** Handles loading dependency files.\n *\n * Dependency loaders don't remember whether a resource has been loaded or\n * not. It is caller's responsibility to make sure the resource is not loaded\n * twice. This is because it's impossible to detect resource loading status\n * without knowing its content.\n *\n * Options:\n * - cdn_http - url to HTTP CND\n * - cdn_https - url to HTTPS CDN\n * - version - version of pusher-js\n * - suffix - suffix appended to all names of dependency files\n *\n * @param {Object} options\n */\nexport default class DependencyLoader {\n options: any;\n receivers: ScriptReceiverFactory;\n loading: any;\n\n constructor(options: any) {\n this.options = options;\n this.receivers = options.receivers || ScriptReceivers;\n this.loading = {};\n }\n\n /** Loads the dependency from CDN.\n *\n * @param {String} name\n * @param {Function} callback\n */\n load(name: string, options: any, callback: Function) {\n var self = this;\n\n if (self.loading[name] && self.loading[name].length > 0) {\n self.loading[name].push(callback);\n } else {\n self.loading[name] = [callback];\n\n var request = Runtime.createScriptRequest(self.getPath(name, options));\n var receiver = self.receivers.create(function(error) {\n self.receivers.remove(receiver);\n\n if (self.loading[name]) {\n var callbacks = self.loading[name];\n delete self.loading[name];\n\n var successCallback = function(wasSuccessful) {\n if (!wasSuccessful) {\n request.cleanup();\n }\n };\n for (var i = 0; i < callbacks.length; i++) {\n callbacks[i](error, successCallback);\n }\n }\n });\n request.send(receiver);\n }\n }\n\n /** Returns a root URL for pusher-js CDN.\n *\n * @returns {String}\n */\n getRoot(options: any): string {\n var cdn;\n var protocol = Runtime.getDocument().location.protocol;\n if ((options && options.useTLS) || protocol === 'https:') {\n cdn = this.options.cdn_https;\n } else {\n cdn = this.options.cdn_http;\n }\n // make sure there are no double slashes\n return cdn.replace(/\\/*$/, '') + '/' + this.options.version;\n }\n\n /** Returns a full path to a dependency file.\n *\n * @param {String} name\n * @returns {String}\n */\n getPath(name: string, options: any): string {\n return this.getRoot(options) + '/' + name + this.options.suffix + '.js';\n }\n}\n","import { ScriptReceiverFactory } from './script_receiver_factory';\nimport Defaults from 'core/defaults';\nimport DependencyLoader from './dependency_loader';\n\nexport var DependenciesReceivers = new ScriptReceiverFactory(\n '_pusher_dependencies',\n 'Pusher.DependenciesReceivers'\n);\n\nexport var Dependencies = new DependencyLoader({\n cdn_http: Defaults.cdn_http,\n cdn_https: Defaults.cdn_https,\n version: Defaults.VERSION,\n suffix: Defaults.dependency_suffix,\n receivers: DependenciesReceivers\n});\n","/**\n * A place to store help URLs for error messages etc\n */\n\nconst urlStore = {\n baseUrl: 'https://pusher.com',\n urls: {\n authenticationEndpoint: {\n path: '/docs/channels/server_api/authenticating_users'\n },\n authorizationEndpoint: {\n path: '/docs/channels/server_api/authorizing-users/'\n },\n javascriptQuickStart: {\n path: '/docs/javascript_quick_start'\n },\n triggeringClientEvents: {\n path: '/docs/client_api_guide/client_events#trigger-events'\n },\n encryptedChannelSupport: {\n fullUrl:\n 'https://github.com/pusher/pusher-js/tree/cc491015371a4bde5743d1c87a0fbac0feb53195#encrypted-channel-support'\n }\n }\n};\n\n/** Builds a consistent string with links to pusher documentation\n *\n * @param {string} key - relevant key in the url_store.urls object\n * @return {string} suffix string to append to log message\n */\nconst buildLogSuffix = function(key: string): string {\n const urlPrefix = 'See:';\n const urlObj = urlStore.urls[key];\n if (!urlObj) return '';\n\n let url;\n if (urlObj.fullUrl) {\n url = urlObj.fullUrl;\n } else if (urlObj.path) {\n url = urlStore.baseUrl + urlObj.path;\n }\n\n if (!url) return '';\n return `${urlPrefix} ${url}`;\n};\n\nexport default { buildLogSuffix };\n","export enum AuthRequestType {\n UserAuthentication = 'user-authentication',\n ChannelAuthorization = 'channel-authorization'\n}\n\nexport interface ChannelAuthorizationData {\n auth: string;\n channel_data?: string;\n shared_secret?: string;\n}\n\nexport type ChannelAuthorizationCallback = (\n error: Error | null,\n authData: ChannelAuthorizationData | null\n) => void;\n\nexport interface ChannelAuthorizationRequestParams {\n socketId: string;\n channelName: string;\n}\n\nexport interface ChannelAuthorizationHandler {\n (\n params: ChannelAuthorizationRequestParams,\n callback: ChannelAuthorizationCallback\n ): void;\n}\n\nexport interface UserAuthenticationData {\n auth: string;\n user_data: string;\n}\n\nexport type UserAuthenticationCallback = (\n error: Error | null,\n authData: UserAuthenticationData | null\n) => void;\n\nexport interface UserAuthenticationRequestParams {\n socketId: string;\n}\n\nexport interface UserAuthenticationHandler {\n (\n params: UserAuthenticationRequestParams,\n callback: UserAuthenticationCallback\n ): void;\n}\n\nexport type AuthTransportCallback =\n | ChannelAuthorizationCallback\n | UserAuthenticationCallback;\n\nexport interface AuthOptionsT {\n transport: 'ajax' | 'jsonp';\n endpoint: string;\n params?: any;\n headers?: any;\n paramsProvider?: () => any;\n headersProvider?: () => any;\n customHandler?: AuthHandler;\n}\n\nexport declare type UserAuthenticationOptions = AuthOptionsT<\n UserAuthenticationHandler\n>;\nexport declare type ChannelAuthorizationOptions = AuthOptionsT<\n ChannelAuthorizationHandler\n>;\n\nexport interface InternalAuthOptions {\n transport: 'ajax' | 'jsonp';\n endpoint: string;\n params?: any;\n headers?: any;\n paramsProvider?: () => any;\n headersProvider?: () => any;\n}\n","/** Error classes used throughout the library. */\n// https://github.com/Microsoft/TypeScript-wiki/blob/master/Breaking-Changes.md#extending-built-ins-like-error-array-and-map-may-no-longer-work\nexport class BadEventName extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\nexport class BadChannelName extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\nexport class RequestTimedOut extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class TransportPriorityTooLow extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class TransportClosed extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class UnsupportedFeature extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class UnsupportedTransport extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class UnsupportedStrategy extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class HTTPAuthError extends Error {\n status: number;\n constructor(status: number, msg?: string) {\n super(msg);\n this.status = status;\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n","import TimelineSender from 'core/timeline/timeline_sender';\nimport * as Collections from 'core/utils/collections';\nimport Util from 'core/util';\nimport Runtime from 'runtime';\nimport { AuthTransport } from 'core/auth/auth_transports';\nimport AbstractRuntime from 'runtimes/interface';\nimport UrlStore from 'core/utils/url_store';\nimport {\n AuthRequestType,\n AuthTransportCallback,\n InternalAuthOptions\n} from 'core/auth/options';\nimport { HTTPAuthError } from 'core/errors';\n\nconst ajax: AuthTransport = function(\n context: AbstractRuntime,\n query: string,\n authOptions: InternalAuthOptions,\n authRequestType: AuthRequestType,\n callback: AuthTransportCallback\n) {\n const xhr = Runtime.createXHR();\n xhr.open('POST', authOptions.endpoint, true);\n\n // add request headers\n xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');\n for (var headerName in authOptions.headers) {\n xhr.setRequestHeader(headerName, authOptions.headers[headerName]);\n }\n if (authOptions.headersProvider != null) {\n let dynamicHeaders = authOptions.headersProvider();\n for (var headerName in dynamicHeaders) {\n xhr.setRequestHeader(headerName, dynamicHeaders[headerName]);\n }\n }\n\n xhr.onreadystatechange = function() {\n if (xhr.readyState === 4) {\n if (xhr.status === 200) {\n let data;\n let parsed = false;\n\n try {\n data = JSON.parse(xhr.responseText);\n parsed = true;\n } catch (e) {\n callback(\n new HTTPAuthError(\n 200,\n `JSON returned from ${authRequestType.toString()} endpoint was invalid, yet status code was 200. Data was: ${\n xhr.responseText\n }`\n ),\n null\n );\n }\n\n if (parsed) {\n // prevents double execution.\n callback(null, data);\n }\n } else {\n let suffix = '';\n switch (authRequestType) {\n case AuthRequestType.UserAuthentication:\n suffix = UrlStore.buildLogSuffix('authenticationEndpoint');\n break;\n case AuthRequestType.ChannelAuthorization:\n suffix = `Clients must be authorized to join private or presence channels. ${UrlStore.buildLogSuffix(\n 'authorizationEndpoint'\n )}`;\n break;\n }\n callback(\n new HTTPAuthError(\n xhr.status,\n `Unable to retrieve auth string from ${authRequestType.toString()} endpoint - ` +\n `received status: ${xhr.status} from ${authOptions.endpoint}. ${suffix}`\n ),\n null\n );\n }\n }\n };\n\n xhr.send(query);\n return xhr;\n};\n\nexport default ajax;\n","export default function encode(s: any): string {\n return btoa(utob(s));\n}\n\nvar fromCharCode = String.fromCharCode;\n\nvar b64chars =\n 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';\nvar b64tab = {};\n\nfor (var i = 0, l = b64chars.length; i < l; i++) {\n b64tab[b64chars.charAt(i)] = i;\n}\n\nvar cb_utob = function(c) {\n var cc = c.charCodeAt(0);\n return cc < 0x80\n ? c\n : cc < 0x800\n ? fromCharCode(0xc0 | (cc >>> 6)) + fromCharCode(0x80 | (cc & 0x3f))\n : fromCharCode(0xe0 | ((cc >>> 12) & 0x0f)) +\n fromCharCode(0x80 | ((cc >>> 6) & 0x3f)) +\n fromCharCode(0x80 | (cc & 0x3f));\n};\n\nvar utob = function(u) {\n return u.replace(/[^\\x00-\\x7F]/g, cb_utob);\n};\n\nvar cb_encode = function(ccc) {\n var padlen = [0, 2, 1][ccc.length % 3];\n var ord =\n (ccc.charCodeAt(0) << 16) |\n ((ccc.length > 1 ? ccc.charCodeAt(1) : 0) << 8) |\n (ccc.length > 2 ? ccc.charCodeAt(2) : 0);\n var chars = [\n b64chars.charAt(ord >>> 18),\n b64chars.charAt((ord >>> 12) & 63),\n padlen >= 2 ? '=' : b64chars.charAt((ord >>> 6) & 63),\n padlen >= 1 ? '=' : b64chars.charAt(ord & 63)\n ];\n return chars.join('');\n};\n\nvar btoa =\n global.btoa ||\n function(b) {\n return b.replace(/[\\s\\S]{1,3}/g, cb_encode);\n };\n","import TimedCallback from './timed_callback';\nimport { Delay, Scheduler, Canceller } from './scheduling';\n\nabstract class Timer {\n protected clear: Canceller;\n protected timer: number | void;\n\n constructor(\n set: Scheduler,\n clear: Canceller,\n delay: Delay,\n callback: TimedCallback\n ) {\n this.clear = clear;\n this.timer = set(() => {\n if (this.timer) {\n this.timer = callback(this.timer);\n }\n }, delay);\n }\n\n /** Returns whether the timer is still running.\n *\n * @return {Boolean}\n */\n isRunning(): boolean {\n return this.timer !== null;\n }\n\n /** Aborts a timer when it's running. */\n ensureAborted() {\n if (this.timer) {\n this.clear(this.timer);\n this.timer = null;\n }\n }\n}\n\nexport default Timer;\n","import Timer from './abstract_timer';\nimport TimedCallback from './timed_callback';\nimport { Delay } from './scheduling';\n\n// We need to bind clear functions this way to avoid exceptions on IE8\nfunction clearTimeout(timer) {\n global.clearTimeout(timer);\n}\nfunction clearInterval(timer) {\n global.clearInterval(timer);\n}\n\n/** Cross-browser compatible one-off timer abstraction.\n *\n * @param {Number} delay\n * @param {Function} callback\n */\nexport class OneOffTimer extends Timer {\n constructor(delay: Delay, callback: TimedCallback) {\n super(setTimeout, clearTimeout, delay, function(timer) {\n callback();\n return null;\n });\n }\n}\n\n/** Cross-browser compatible periodic timer abstraction.\n *\n * @param {Number} delay\n * @param {Function} callback\n */\nexport class PeriodicTimer extends Timer {\n constructor(delay: Delay, callback: TimedCallback) {\n super(setInterval, clearInterval, delay, function(timer) {\n callback();\n return timer;\n });\n }\n}\n","import * as Collections from './utils/collections';\nimport TimedCallback from './utils/timers/timed_callback';\nimport { OneOffTimer, PeriodicTimer } from './utils/timers';\n\nvar Util = {\n now(): number {\n if (Date.now) {\n return Date.now();\n } else {\n return new Date().valueOf();\n }\n },\n\n defer(callback: TimedCallback): OneOffTimer {\n return new OneOffTimer(0, callback);\n },\n\n /** Builds a function that will proxy a method call to its first argument.\n *\n * Allows partial application of arguments, so additional arguments are\n * prepended to the argument list.\n *\n * @param {String} name method name\n * @return {Function} proxy function\n */\n method(name: string, ...args: any[]): Function {\n var boundArguments = Array.prototype.slice.call(arguments, 1);\n return function(object) {\n return object[name].apply(object, boundArguments.concat(arguments));\n };\n }\n};\n\nexport default Util;\n","import base64encode from '../base64';\nimport Util from '../util';\n\n/** Merges multiple objects into the target argument.\n *\n * For properties that are plain Objects, performs a deep-merge. For the\n * rest it just copies the value of the property.\n *\n * To extend prototypes use it as following:\n * Pusher.Util.extend(Target.prototype, Base.prototype)\n *\n * You can also use it to merge objects without altering them:\n * Pusher.Util.extend({}, object1, object2)\n *\n * @param {Object} target\n * @return {Object} the target argument\n */\nexport function extend(target: any, ...sources: any[]): T {\n for (var i = 0; i < sources.length; i++) {\n var extensions = sources[i];\n for (var property in extensions) {\n if (\n extensions[property] &&\n extensions[property].constructor &&\n extensions[property].constructor === Object\n ) {\n target[property] = extend(target[property] || {}, extensions[property]);\n } else {\n target[property] = extensions[property];\n }\n }\n }\n return target;\n}\n\nexport function stringify(): string {\n var m = ['Pusher'];\n for (var i = 0; i < arguments.length; i++) {\n if (typeof arguments[i] === 'string') {\n m.push(arguments[i]);\n } else {\n m.push(safeJSONStringify(arguments[i]));\n }\n }\n return m.join(' : ');\n}\n\nexport function arrayIndexOf(array: any[], item: any): number {\n // MSIE doesn't have array.indexOf\n var nativeIndexOf = Array.prototype.indexOf;\n if (array === null) {\n return -1;\n }\n if (nativeIndexOf && array.indexOf === nativeIndexOf) {\n return array.indexOf(item);\n }\n for (var i = 0, l = array.length; i < l; i++) {\n if (array[i] === item) {\n return i;\n }\n }\n return -1;\n}\n\n/** Applies a function f to all properties of an object.\n *\n * Function f gets 3 arguments passed:\n * - element from the object\n * - key of the element\n * - reference to the object\n *\n * @param {Object} object\n * @param {Function} f\n */\nexport function objectApply(object: any, f: Function) {\n for (var key in object) {\n if (Object.prototype.hasOwnProperty.call(object, key)) {\n f(object[key], key, object);\n }\n }\n}\n\n/** Return a list of objects own proerty keys\n *\n * @param {Object} object\n * @returns {Array}\n */\nexport function keys(object: any): string[] {\n var keys = [];\n objectApply(object, function(_, key) {\n keys.push(key);\n });\n return keys;\n}\n\n/** Return a list of object's own property values\n *\n * @param {Object} object\n * @returns {Array}\n */\nexport function values(object: any): any[] {\n var values = [];\n objectApply(object, function(value) {\n values.push(value);\n });\n return values;\n}\n\n/** Applies a function f to all elements of an array.\n *\n * Function f gets 3 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function apply(array: any[], f: Function, context?: any) {\n for (var i = 0; i < array.length; i++) {\n f.call(context || global, array[i], i, array);\n }\n}\n\n/** Maps all elements of the array and returns the result.\n *\n * Function f gets 4 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n * - reference to the destination array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function map(array: any[], f: Function): any[] {\n var result = [];\n for (var i = 0; i < array.length; i++) {\n result.push(f(array[i], i, array, result));\n }\n return result;\n}\n\n/** Maps all elements of the object and returns the result.\n *\n * Function f gets 4 arguments passed:\n * - element from the object\n * - key of the element\n * - reference to the source object\n * - reference to the destination object\n *\n * @param {Object} object\n * @param {Function} f\n */\nexport function mapObject(object: any, f: Function): any {\n var result = {};\n objectApply(object, function(value, key) {\n result[key] = f(value);\n });\n return result;\n}\n\n/** Filters elements of the array using a test function.\n *\n * Function test gets 4 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n * - reference to the destination array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function filter(array: any[], test: Function): any[] {\n test =\n test ||\n function(value) {\n return !!value;\n };\n\n var result = [];\n for (var i = 0; i < array.length; i++) {\n if (test(array[i], i, array, result)) {\n result.push(array[i]);\n }\n }\n return result;\n}\n\n/** Filters properties of the object using a test function.\n *\n * Function test gets 4 arguments passed:\n * - element from the object\n * - key of the element\n * - reference to the source object\n * - reference to the destination object\n *\n * @param {Object} object\n * @param {Function} f\n */\nexport function filterObject(object: Object, test: Function) {\n var result = {};\n objectApply(object, function(value, key) {\n if ((test && test(value, key, object, result)) || Boolean(value)) {\n result[key] = value;\n }\n });\n return result;\n}\n\n/** Flattens an object into a two-dimensional array.\n *\n * @param {Object} object\n * @return {Array} resulting array of [key, value] pairs\n */\nexport function flatten(object: Object): any[] {\n var result = [];\n objectApply(object, function(value, key) {\n result.push([key, value]);\n });\n return result;\n}\n\n/** Checks whether any element of the array passes the test.\n *\n * Function test gets 3 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function any(array: any[], test: Function): boolean {\n for (var i = 0; i < array.length; i++) {\n if (test(array[i], i, array)) {\n return true;\n }\n }\n return false;\n}\n\n/** Checks whether all elements of the array pass the test.\n *\n * Function test gets 3 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function all(array: any[], test: Function): boolean {\n for (var i = 0; i < array.length; i++) {\n if (!test(array[i], i, array)) {\n return false;\n }\n }\n return true;\n}\n\nexport function encodeParamsObject(data): string {\n return mapObject(data, function(value) {\n if (typeof value === 'object') {\n value = safeJSONStringify(value);\n }\n return encodeURIComponent(base64encode(value.toString()));\n });\n}\n\nexport function buildQueryString(data: any): string {\n var params = filterObject(data, function(value) {\n return value !== undefined;\n });\n\n var query = map(\n flatten(encodeParamsObject(params)),\n Util.method('join', '=')\n ).join('&');\n\n return query;\n}\n\n/**\n * See https://github.com/douglascrockford/JSON-js/blob/master/cycle.js\n *\n * Remove circular references from an object. Required for JSON.stringify in\n * React Native, which tends to blow up a lot.\n *\n * @param {any} object\n * @return {any} Decycled object\n */\nexport function decycleObject(object: any): any {\n var objects = [],\n paths = [];\n\n return (function derez(value, path) {\n var i, name, nu;\n\n switch (typeof value) {\n case 'object':\n if (!value) {\n return null;\n }\n for (i = 0; i < objects.length; i += 1) {\n if (objects[i] === value) {\n return { $ref: paths[i] };\n }\n }\n\n objects.push(value);\n paths.push(path);\n\n if (Object.prototype.toString.apply(value) === '[object Array]') {\n nu = [];\n for (i = 0; i < value.length; i += 1) {\n nu[i] = derez(value[i], path + '[' + i + ']');\n }\n } else {\n nu = {};\n for (name in value) {\n if (Object.prototype.hasOwnProperty.call(value, name)) {\n nu[name] = derez(\n value[name],\n path + '[' + JSON.stringify(name) + ']'\n );\n }\n }\n }\n return nu;\n case 'number':\n case 'string':\n case 'boolean':\n return value;\n }\n })(object, '$');\n}\n\n/**\n * Provides a cross-browser and cross-platform way to safely stringify objects\n * into JSON. This is particularly necessary for ReactNative, where circular JSON\n * structures throw an exception.\n *\n * @param {any} source The object to stringify\n * @return {string} The serialized output.\n */\nexport function safeJSONStringify(source: any): string {\n try {\n return JSON.stringify(source);\n } catch (e) {\n return JSON.stringify(decycleObject(source));\n }\n}\n","import { stringify } from './utils/collections';\nimport Pusher from './pusher';\n\nclass Logger {\n debug(...args: any[]) {\n this.log(this.globalLog, args);\n }\n\n warn(...args: any[]) {\n this.log(this.globalLogWarn, args);\n }\n\n error(...args: any[]) {\n this.log(this.globalLogError, args);\n }\n\n private globalLog = (message: string) => {\n if (global.console && global.console.log) {\n global.console.log(message);\n }\n };\n\n private globalLogWarn(message: string) {\n if (global.console && global.console.warn) {\n global.console.warn(message);\n } else {\n this.globalLog(message);\n }\n }\n\n private globalLogError(message: string) {\n if (global.console && global.console.error) {\n global.console.error(message);\n } else {\n this.globalLogWarn(message);\n }\n }\n\n private log(\n defaultLoggingFunction: (message: string) => void,\n ...args: any[]\n ) {\n var message = stringify.apply(this, arguments);\n if (Pusher.log) {\n Pusher.log(message);\n } else if (Pusher.logToConsole) {\n const log = defaultLoggingFunction.bind(this);\n log(message);\n }\n }\n}\n\nexport default new Logger();\n","import Browser from '../browser';\nimport Logger from 'core/logger';\nimport JSONPRequest from '../dom/jsonp_request';\nimport { ScriptReceivers } from '../dom/script_receiver_factory';\nimport { AuthTransport } from 'core/auth/auth_transports';\nimport {\n AuthRequestType,\n AuthTransportCallback,\n InternalAuthOptions\n} from 'core/auth/options';\n\nvar jsonp: AuthTransport = function(\n context: Browser,\n query: string,\n authOptions: InternalAuthOptions,\n authRequestType: AuthRequestType,\n callback: AuthTransportCallback\n) {\n if (\n authOptions.headers !== undefined ||\n authOptions.headersProvider != null\n ) {\n Logger.warn(\n `To send headers with the ${authRequestType.toString()} request, you must use AJAX, rather than JSONP.`\n );\n }\n\n var callbackName = context.nextAuthCallbackID.toString();\n context.nextAuthCallbackID++;\n\n var document = context.getDocument();\n var script = document.createElement('script');\n // Hacked wrapper.\n context.auth_callbacks[callbackName] = function(data) {\n callback(null, data);\n };\n\n var callback_name = \"Pusher.auth_callbacks['\" + callbackName + \"']\";\n script.src =\n authOptions.endpoint +\n '?callback=' +\n encodeURIComponent(callback_name) +\n '&' +\n query;\n\n var head =\n document.getElementsByTagName('head')[0] || document.documentElement;\n head.insertBefore(script, head.firstChild);\n};\n\nexport default jsonp;\n","import ScriptReceiver from './script_receiver';\n\n/** Sends a generic HTTP GET request using a script tag.\n *\n * By constructing URL in a specific way, it can be used for loading\n * JavaScript resources or JSONP requests. It can notify about errors, but\n * only in certain environments. Please take care of monitoring the state of\n * the request yourself.\n *\n * @param {String} src\n */\nexport default class ScriptRequest {\n src: string;\n script: any;\n errorScript: any;\n\n constructor(src: string) {\n this.src = src;\n }\n\n send(receiver: ScriptReceiver) {\n var self = this;\n var errorString = 'Error loading ' + self.src;\n\n self.script = document.createElement('script');\n self.script.id = receiver.id;\n self.script.src = self.src;\n self.script.type = 'text/javascript';\n self.script.charset = 'UTF-8';\n\n if (self.script.addEventListener) {\n self.script.onerror = function() {\n receiver.callback(errorString);\n };\n self.script.onload = function() {\n receiver.callback(null);\n };\n } else {\n self.script.onreadystatechange = function() {\n if (\n self.script.readyState === 'loaded' ||\n self.script.readyState === 'complete'\n ) {\n receiver.callback(null);\n }\n };\n }\n\n // Opera<11.6 hack for missing onerror callback\n if (\n self.script.async === undefined &&\n (document).attachEvent &&\n /opera/i.test(navigator.userAgent)\n ) {\n self.errorScript = document.createElement('script');\n self.errorScript.id = receiver.id + '_error';\n self.errorScript.text = receiver.name + \"('\" + errorString + \"');\";\n self.script.async = self.errorScript.async = false;\n } else {\n self.script.async = true;\n }\n\n var head = document.getElementsByTagName('head')[0];\n head.insertBefore(self.script, head.firstChild);\n if (self.errorScript) {\n head.insertBefore(self.errorScript, self.script.nextSibling);\n }\n }\n\n /** Cleans up the DOM remains of the script request. */\n cleanup() {\n if (this.script) {\n this.script.onload = this.script.onerror = null;\n this.script.onreadystatechange = null;\n }\n if (this.script && this.script.parentNode) {\n this.script.parentNode.removeChild(this.script);\n }\n if (this.errorScript && this.errorScript.parentNode) {\n this.errorScript.parentNode.removeChild(this.errorScript);\n }\n this.script = null;\n this.errorScript = null;\n }\n}\n","import ScriptReceiver from './script_receiver';\nimport ScriptRequest from './script_request';\nimport * as Collections from 'core/utils/collections';\nimport Util from 'core/util';\nimport Runtime from '../runtime';\n\n/** Sends data via JSONP.\n *\n * Data is a key-value map. Its values are JSON-encoded and then passed\n * through base64. Finally, keys and encoded values are appended to the query\n * string.\n *\n * The class itself does not guarantee raising errors on failures, as it's not\n * possible to support such feature on all browsers. Instead, JSONP endpoint\n * should call back in a way that's easy to distinguish from browser calls,\n * for example by passing a second argument to the receiver.\n *\n * @param {String} url\n * @param {Object} data key-value map of data to be submitted\n */\nexport default class JSONPRequest {\n url: string;\n data: any;\n request: ScriptRequest;\n\n constructor(url: string, data: any) {\n this.url = url;\n this.data = data;\n }\n\n /** Sends the actual JSONP request.\n *\n * @param {ScriptReceiver} receiver\n */\n send(receiver: ScriptReceiver) {\n if (this.request) {\n return;\n }\n\n var query = Collections.buildQueryString(this.data);\n var url = this.url + '/' + receiver.number + '?' + query;\n this.request = Runtime.createScriptRequest(url);\n this.request.send(receiver);\n }\n\n /** Cleans up the DOM remains of the JSONP request. */\n cleanup() {\n if (this.request) {\n this.request.cleanup();\n }\n }\n}\n","import TimelineSender from 'core/timeline/timeline_sender';\nimport TimelineTransport from 'core/timeline/timeline_transport';\nimport Browser from 'runtime';\nimport { AuthTransport } from 'core/auth/auth_transports';\nimport { ScriptReceivers } from '../dom/script_receiver_factory';\n\nvar getAgent = function(sender: TimelineSender, useTLS: boolean) {\n return function(data: any, callback: Function) {\n var scheme = 'http' + (useTLS ? 's' : '') + '://';\n var url =\n scheme + (sender.host || sender.options.host) + sender.options.path;\n var request = Browser.createJSONPRequest(url, data);\n\n var receiver = Browser.ScriptReceivers.create(function(error, result) {\n ScriptReceivers.remove(receiver);\n request.cleanup();\n\n if (result && result.host) {\n sender.host = result.host;\n }\n if (callback) {\n callback(error, result);\n }\n });\n request.send(receiver);\n };\n};\n\nvar jsonp = {\n name: 'jsonp',\n getAgent\n};\n\nexport default jsonp;\n","import Defaults from '../defaults';\nimport { default as URLScheme, URLSchemeParams } from './url_scheme';\n\nfunction getGenericURL(\n baseScheme: string,\n params: URLSchemeParams,\n path: string\n): string {\n var scheme = baseScheme + (params.useTLS ? 's' : '');\n var host = params.useTLS ? params.hostTLS : params.hostNonTLS;\n return scheme + '://' + host + path;\n}\n\nfunction getGenericPath(key: string, queryString?: string): string {\n var path = '/app/' + key;\n var query =\n '?protocol=' +\n Defaults.PROTOCOL +\n '&client=js' +\n '&version=' +\n Defaults.VERSION +\n (queryString ? '&' + queryString : '');\n return path + query;\n}\n\nexport var ws: URLScheme = {\n getInitial: function(key: string, params: URLSchemeParams): string {\n var path = (params.httpPath || '') + getGenericPath(key, 'flash=false');\n return getGenericURL('ws', params, path);\n }\n};\n\nexport var http: URLScheme = {\n getInitial: function(key: string, params: URLSchemeParams): string {\n var path = (params.httpPath || '/pusher') + getGenericPath(key);\n return getGenericURL('http', params, path);\n }\n};\n\nexport var sockjs: URLScheme = {\n getInitial: function(key: string, params: URLSchemeParams): string {\n return getGenericURL('http', params, params.httpPath || '/pusher');\n },\n getPath: function(key: string, params: URLSchemeParams): string {\n return getGenericPath(key);\n }\n};\n","import Callback from './callback';\nimport * as Collections from '../utils/collections';\nimport CallbackTable from './callback_table';\n\nexport default class CallbackRegistry {\n _callbacks: CallbackTable;\n\n constructor() {\n this._callbacks = {};\n }\n\n get(name: string): Callback[] {\n return this._callbacks[prefix(name)];\n }\n\n add(name: string, callback: Function, context: any) {\n var prefixedEventName = prefix(name);\n this._callbacks[prefixedEventName] =\n this._callbacks[prefixedEventName] || [];\n this._callbacks[prefixedEventName].push({\n fn: callback,\n context: context\n });\n }\n\n remove(name?: string, callback?: Function, context?: any) {\n if (!name && !callback && !context) {\n this._callbacks = {};\n return;\n }\n\n var names = name ? [prefix(name)] : Collections.keys(this._callbacks);\n\n if (callback || context) {\n this.removeCallback(names, callback, context);\n } else {\n this.removeAllCallbacks(names);\n }\n }\n\n private removeCallback(names: string[], callback: Function, context: any) {\n Collections.apply(\n names,\n function(name) {\n this._callbacks[name] = Collections.filter(\n this._callbacks[name] || [],\n function(binding) {\n return (\n (callback && callback !== binding.fn) ||\n (context && context !== binding.context)\n );\n }\n );\n if (this._callbacks[name].length === 0) {\n delete this._callbacks[name];\n }\n },\n this\n );\n }\n\n private removeAllCallbacks(names: string[]) {\n Collections.apply(\n names,\n function(name) {\n delete this._callbacks[name];\n },\n this\n );\n }\n}\n\nfunction prefix(name: string): string {\n return '_' + name;\n}\n","import * as Collections from '../utils/collections';\nimport Callback from './callback';\nimport Metadata from '../channels/metadata';\nimport CallbackRegistry from './callback_registry';\n\n/** Manages callback bindings and event emitting.\n *\n * @param Function failThrough called when no listeners are bound to an event\n */\nexport default class Dispatcher {\n callbacks: CallbackRegistry;\n global_callbacks: Function[];\n failThrough: Function;\n\n constructor(failThrough?: Function) {\n this.callbacks = new CallbackRegistry();\n this.global_callbacks = [];\n this.failThrough = failThrough;\n }\n\n bind(eventName: string, callback: Function, context?: any) {\n this.callbacks.add(eventName, callback, context);\n return this;\n }\n\n bind_global(callback: Function) {\n this.global_callbacks.push(callback);\n return this;\n }\n\n unbind(eventName?: string, callback?: Function, context?: any) {\n this.callbacks.remove(eventName, callback, context);\n return this;\n }\n\n unbind_global(callback?: Function) {\n if (!callback) {\n this.global_callbacks = [];\n return this;\n }\n\n this.global_callbacks = Collections.filter(\n this.global_callbacks || [],\n c => c !== callback\n );\n\n return this;\n }\n\n unbind_all() {\n this.unbind();\n this.unbind_global();\n return this;\n }\n\n emit(eventName: string, data?: any, metadata?: Metadata): Dispatcher {\n for (var i = 0; i < this.global_callbacks.length; i++) {\n this.global_callbacks[i](eventName, data);\n }\n\n var callbacks = this.callbacks.get(eventName);\n var args = [];\n\n if (metadata) {\n // if there's a metadata argument, we need to call the callback with both\n // data and metadata regardless of whether data is undefined\n args.push(data, metadata);\n } else if (data) {\n // metadata is undefined, so we only need to call the callback with data\n // if data exists\n args.push(data);\n }\n\n if (callbacks && callbacks.length > 0) {\n for (var i = 0; i < callbacks.length; i++) {\n callbacks[i].fn.apply(callbacks[i].context || global, args);\n }\n } else if (this.failThrough) {\n this.failThrough(eventName, data);\n }\n\n return this;\n }\n}\n","import Util from '../util';\nimport * as Collections from '../utils/collections';\nimport { default as EventsDispatcher } from '../events/dispatcher';\nimport Logger from '../logger';\nimport TransportHooks from './transport_hooks';\nimport Socket from '../socket';\nimport Runtime from 'runtime';\nimport Timeline from '../timeline/timeline';\nimport TransportConnectionOptions from './transport_connection_options';\n\n/** Provides universal API for transport connections.\n *\n * Transport connection is a low-level object that wraps a connection method\n * and exposes a simple evented interface for the connection state and\n * messaging. It does not implement Pusher-specific WebSocket protocol.\n *\n * Additionally, it fetches resources needed for transport to work and exposes\n * an interface for querying transport features.\n *\n * States:\n * - new - initial state after constructing the object\n * - initializing - during initialization phase, usually fetching resources\n * - intialized - ready to establish a connection\n * - connection - when connection is being established\n * - open - when connection ready to be used\n * - closed - after connection was closed be either side\n *\n * Emits:\n * - error - after the connection raised an error\n *\n * Options:\n * - useTLS - whether connection should be over TLS\n * - hostTLS - host to connect to when connection is over TLS\n * - hostNonTLS - host to connect to when connection is over TLS\n *\n * @param {String} key application key\n * @param {Object} options\n */\nexport default class TransportConnection extends EventsDispatcher {\n hooks: TransportHooks;\n name: string;\n priority: number;\n key: string;\n options: TransportConnectionOptions;\n state: string;\n timeline: Timeline;\n activityTimeout: number;\n id: number;\n socket: Socket;\n beforeOpen: Function;\n initialize: Function;\n\n constructor(\n hooks: TransportHooks,\n name: string,\n priority: number,\n key: string,\n options: TransportConnectionOptions\n ) {\n super();\n this.initialize = Runtime.transportConnectionInitializer;\n this.hooks = hooks;\n this.name = name;\n this.priority = priority;\n this.key = key;\n this.options = options;\n\n this.state = 'new';\n this.timeline = options.timeline;\n this.activityTimeout = options.activityTimeout;\n this.id = this.timeline.generateUniqueID();\n }\n\n /** Checks whether the transport handles activity checks by itself.\n *\n * @return {Boolean}\n */\n handlesActivityChecks(): boolean {\n return Boolean(this.hooks.handlesActivityChecks);\n }\n\n /** Checks whether the transport supports the ping/pong API.\n *\n * @return {Boolean}\n */\n supportsPing(): boolean {\n return Boolean(this.hooks.supportsPing);\n }\n\n /** Tries to establish a connection.\n *\n * @returns {Boolean} false if transport is in invalid state\n */\n connect(): boolean {\n if (this.socket || this.state !== 'initialized') {\n return false;\n }\n\n var url = this.hooks.urls.getInitial(this.key, this.options);\n try {\n this.socket = this.hooks.getSocket(url, this.options);\n } catch (e) {\n Util.defer(() => {\n this.onError(e);\n this.changeState('closed');\n });\n return false;\n }\n\n this.bindListeners();\n\n Logger.debug('Connecting', { transport: this.name, url });\n this.changeState('connecting');\n return true;\n }\n\n /** Closes the connection.\n *\n * @return {Boolean} true if there was a connection to close\n */\n close(): boolean {\n if (this.socket) {\n this.socket.close();\n return true;\n } else {\n return false;\n }\n }\n\n /** Sends data over the open connection.\n *\n * @param {String} data\n * @return {Boolean} true only when in the \"open\" state\n */\n send(data: any): boolean {\n if (this.state === 'open') {\n // Workaround for MobileSafari bug (see https://gist.github.com/2052006)\n Util.defer(() => {\n if (this.socket) {\n this.socket.send(data);\n }\n });\n return true;\n } else {\n return false;\n }\n }\n\n /** Sends a ping if the connection is open and transport supports it. */\n ping() {\n if (this.state === 'open' && this.supportsPing()) {\n this.socket.ping();\n }\n }\n\n private onOpen() {\n if (this.hooks.beforeOpen) {\n this.hooks.beforeOpen(\n this.socket,\n this.hooks.urls.getPath(this.key, this.options)\n );\n }\n this.changeState('open');\n this.socket.onopen = undefined;\n }\n\n private onError(error) {\n this.emit('error', { type: 'WebSocketError', error: error });\n this.timeline.error(this.buildTimelineMessage({ error: error.toString() }));\n }\n\n private onClose(closeEvent?: any) {\n if (closeEvent) {\n this.changeState('closed', {\n code: closeEvent.code,\n reason: closeEvent.reason,\n wasClean: closeEvent.wasClean\n });\n } else {\n this.changeState('closed');\n }\n this.unbindListeners();\n this.socket = undefined;\n }\n\n private onMessage(message) {\n this.emit('message', message);\n }\n\n private onActivity() {\n this.emit('activity');\n }\n\n private bindListeners() {\n this.socket.onopen = () => {\n this.onOpen();\n };\n this.socket.onerror = error => {\n this.onError(error);\n };\n this.socket.onclose = closeEvent => {\n this.onClose(closeEvent);\n };\n this.socket.onmessage = message => {\n this.onMessage(message);\n };\n\n if (this.supportsPing()) {\n this.socket.onactivity = () => {\n this.onActivity();\n };\n }\n }\n\n private unbindListeners() {\n if (this.socket) {\n this.socket.onopen = undefined;\n this.socket.onerror = undefined;\n this.socket.onclose = undefined;\n this.socket.onmessage = undefined;\n if (this.supportsPing()) {\n this.socket.onactivity = undefined;\n }\n }\n }\n\n private changeState(state: string, params?: any) {\n this.state = state;\n this.timeline.info(\n this.buildTimelineMessage({\n state: state,\n params: params\n })\n );\n this.emit(state, params);\n }\n\n buildTimelineMessage(message): any {\n return Collections.extend({ cid: this.id }, message);\n }\n}\n","import Factory from '../utils/factory';\nimport TransportHooks from './transport_hooks';\nimport TransportConnection from './transport_connection';\nimport TransportConnectionOptions from './transport_connection_options';\n\n/** Provides interface for transport connection instantiation.\n *\n * Takes transport-specific hooks as the only argument, which allow checking\n * for transport support and creating its connections.\n *\n * Supported hooks: * - file - the name of the file to be fetched during initialization\n * - urls - URL scheme to be used by transport\n * - handlesActivityCheck - true when the transport handles activity checks\n * - supportsPing - true when the transport has a ping/activity API\n * - isSupported - tells whether the transport is supported in the environment\n * - getSocket - creates a WebSocket-compatible transport socket\n *\n * See transports.js for specific implementations.\n *\n * @param {Object} hooks object containing all needed transport hooks\n */\nexport default class Transport {\n hooks: TransportHooks;\n\n constructor(hooks: TransportHooks) {\n this.hooks = hooks;\n }\n\n /** Returns whether the transport is supported in the environment.\n *\n * @param {Object} envronment te environment details (encryption, settings)\n * @returns {Boolean} true when the transport is supported\n */\n isSupported(environment: any): boolean {\n return this.hooks.isSupported(environment);\n }\n\n /** Creates a transport connection.\n *\n * @param {String} name\n * @param {Number} priority\n * @param {String} key the application key\n * @param {Object} options\n * @returns {TransportConnection}\n */\n createConnection(\n name: string,\n priority: number,\n key: string,\n options: any\n ): TransportConnection {\n return new TransportConnection(this.hooks, name, priority, key, options);\n }\n}\n","import * as URLSchemes from 'core/transports/url_schemes';\nimport URLScheme from 'core/transports/url_scheme';\nimport Transport from 'core/transports/transport';\nimport Util from 'core/util';\nimport * as Collections from 'core/utils/collections';\nimport TransportHooks from 'core/transports/transport_hooks';\nimport TransportsTable from 'core/transports/transports_table';\nimport Runtime from 'runtime';\n\n/** WebSocket transport.\n *\n * Uses native WebSocket implementation, including MozWebSocket supported by\n * earlier Firefox versions.\n */\nvar WSTransport = new Transport({\n urls: URLSchemes.ws,\n handlesActivityChecks: false,\n supportsPing: false,\n\n isInitialized: function() {\n return Boolean(Runtime.getWebSocketAPI());\n },\n isSupported: function(): boolean {\n return Boolean(Runtime.getWebSocketAPI());\n },\n getSocket: function(url) {\n return Runtime.createWebSocket(url);\n }\n});\n\nvar httpConfiguration = {\n urls: URLSchemes.http,\n handlesActivityChecks: false,\n supportsPing: true,\n isInitialized: function() {\n return true;\n }\n};\n\nexport var streamingConfiguration = Collections.extend(\n {\n getSocket: function(url) {\n return Runtime.HTTPFactory.createStreamingSocket(url);\n }\n },\n httpConfiguration\n);\nexport var pollingConfiguration = Collections.extend(\n {\n getSocket: function(url) {\n return Runtime.HTTPFactory.createPollingSocket(url);\n }\n },\n httpConfiguration\n);\n\nvar xhrConfiguration = {\n isSupported: function(): boolean {\n return Runtime.isXHRSupported();\n }\n};\n\n/** HTTP streaming transport using CORS-enabled XMLHttpRequest. */\nvar XHRStreamingTransport = new Transport(\n (\n Collections.extend({}, streamingConfiguration, xhrConfiguration)\n )\n);\n\n/** HTTP long-polling transport using CORS-enabled XMLHttpRequest. */\nvar XHRPollingTransport = new Transport(\n Collections.extend({}, pollingConfiguration, xhrConfiguration)\n);\n\nvar Transports: TransportsTable = {\n ws: WSTransport,\n xhr_streaming: XHRStreamingTransport,\n xhr_polling: XHRPollingTransport\n};\n\nexport default Transports;\n","import {\n default as Transports,\n streamingConfiguration,\n pollingConfiguration\n} from 'isomorphic/transports/transports';\nimport Transport from 'core/transports/transport';\nimport TransportHooks from 'core/transports/transport_hooks';\nimport * as URLSchemes from 'core/transports/url_schemes';\nimport Runtime from 'runtime';\nimport { Dependencies } from '../dom/dependencies';\nimport * as Collections from 'core/utils/collections';\n\nvar SockJSTransport = new Transport({\n file: 'sockjs',\n urls: URLSchemes.sockjs,\n handlesActivityChecks: true,\n supportsPing: false,\n\n isSupported: function() {\n return true;\n },\n isInitialized: function() {\n return window.SockJS !== undefined;\n },\n getSocket: function(url, options) {\n return new window.SockJS(url, null, {\n js_path: Dependencies.getPath('sockjs', {\n useTLS: options.useTLS\n }),\n ignore_null_origin: options.ignoreNullOrigin\n });\n },\n beforeOpen: function(socket, path) {\n socket.send(\n JSON.stringify({\n path: path\n })\n );\n }\n});\n\nvar xdrConfiguration = {\n isSupported: function(environment): boolean {\n var yes = Runtime.isXDRSupported(environment.useTLS);\n return yes;\n }\n};\n\n/** HTTP streaming transport using XDomainRequest (IE 8,9). */\nvar XDRStreamingTransport = new Transport(\n (\n Collections.extend({}, streamingConfiguration, xdrConfiguration)\n )\n);\n\n/** HTTP long-polling transport using XDomainRequest (IE 8,9). */\nvar XDRPollingTransport = new Transport(\n Collections.extend({}, pollingConfiguration, xdrConfiguration)\n);\n\nTransports.xdr_streaming = XDRStreamingTransport;\nTransports.xdr_polling = XDRPollingTransport;\nTransports.sockjs = SockJSTransport;\n\nexport default Transports;\n","import Reachability from 'core/reachability';\nimport { default as EventsDispatcher } from 'core/events/dispatcher';\n\n/** Really basic interface providing network availability info.\n *\n * Emits:\n * - online - when browser goes online\n * - offline - when browser goes offline\n */\nexport class NetInfo extends EventsDispatcher implements Reachability {\n constructor() {\n super();\n var self = this;\n // This is okay, as IE doesn't support this stuff anyway.\n if (window.addEventListener !== undefined) {\n window.addEventListener(\n 'online',\n function() {\n self.emit('online');\n },\n false\n );\n window.addEventListener(\n 'offline',\n function() {\n self.emit('offline');\n },\n false\n );\n }\n }\n\n /** Returns whether browser is online or not\n *\n * Offline means definitely offline (no connection to router).\n * Inverse does NOT mean definitely online (only currently supported in Safari\n * and even there only means the device has a connection to the router).\n *\n * @return {Boolean}\n */\n isOnline(): boolean {\n if (window.navigator.onLine === undefined) {\n return true;\n } else {\n return window.navigator.onLine;\n }\n }\n}\n\nexport var Network = new NetInfo();\n","import Util from '../util';\nimport * as Collections from '../utils/collections';\nimport TransportManager from './transport_manager';\nimport TransportConnection from './transport_connection';\nimport Transport from './transport';\nimport PingDelayOptions from './ping_delay_options';\n\n/** Creates transport connections monitored by a transport manager.\n *\n * When a transport is closed, it might mean the environment does not support\n * it. It's possible that messages get stuck in an intermediate buffer or\n * proxies terminate inactive connections. To combat these problems,\n * assistants monitor the connection lifetime, report unclean exits and\n * adjust ping timeouts to keep the connection active. The decision to disable\n * a transport is the manager's responsibility.\n *\n * @param {TransportManager} manager\n * @param {TransportConnection} transport\n * @param {Object} options\n */\nexport default class AssistantToTheTransportManager {\n manager: TransportManager;\n transport: Transport;\n minPingDelay: number;\n maxPingDelay: number;\n pingDelay: number;\n\n constructor(\n manager: TransportManager,\n transport: Transport,\n options: PingDelayOptions\n ) {\n this.manager = manager;\n this.transport = transport;\n this.minPingDelay = options.minPingDelay;\n this.maxPingDelay = options.maxPingDelay;\n this.pingDelay = undefined;\n }\n\n /** Creates a transport connection.\n *\n * This function has the same API as Transport#createConnection.\n *\n * @param {String} name\n * @param {Number} priority\n * @param {String} key the application key\n * @param {Object} options\n * @returns {TransportConnection}\n */\n createConnection(\n name: string,\n priority: number,\n key: string,\n options: Object\n ): TransportConnection {\n options = Collections.extend({}, options, {\n activityTimeout: this.pingDelay\n });\n var connection = this.transport.createConnection(\n name,\n priority,\n key,\n options\n );\n\n var openTimestamp = null;\n\n var onOpen = function() {\n connection.unbind('open', onOpen);\n connection.bind('closed', onClosed);\n openTimestamp = Util.now();\n };\n var onClosed = closeEvent => {\n connection.unbind('closed', onClosed);\n\n if (closeEvent.code === 1002 || closeEvent.code === 1003) {\n // we don't want to use transports not obeying the protocol\n this.manager.reportDeath();\n } else if (!closeEvent.wasClean && openTimestamp) {\n // report deaths only for short-living transport\n var lifespan = Util.now() - openTimestamp;\n if (lifespan < 2 * this.maxPingDelay) {\n this.manager.reportDeath();\n this.pingDelay = Math.max(lifespan / 2, this.minPingDelay);\n }\n }\n };\n\n connection.bind('open', onOpen);\n return connection;\n }\n\n /** Returns whether the transport is supported in the environment.\n *\n * This function has the same API as Transport#isSupported. Might return false\n * when the manager decides to kill the transport.\n *\n * @param {Object} environment the environment details (encryption, settings)\n * @returns {Boolean} true when the transport is supported\n */\n isSupported(environment: string): boolean {\n return this.manager.isAlive() && this.transport.isSupported(environment);\n }\n}\n","import Action from './action';\nimport { PusherEvent } from './message-types';\n/**\n * Provides functions for handling Pusher protocol-specific messages.\n */\n\nconst Protocol = {\n /**\n * Decodes a message in a Pusher format.\n *\n * The MessageEvent we receive from the transport should contain a pusher event\n * (https://pusher.com/docs/pusher_protocol#events) serialized as JSON in the\n * data field\n *\n * The pusher event may contain a data field too, and it may also be\n * serialised as JSON\n *\n * Throws errors when messages are not parse'able.\n *\n * @param {MessageEvent} messageEvent\n * @return {PusherEvent}\n */\n decodeMessage: function(messageEvent: MessageEvent): PusherEvent {\n try {\n var messageData = JSON.parse(messageEvent.data);\n var pusherEventData = messageData.data;\n if (typeof pusherEventData === 'string') {\n try {\n pusherEventData = JSON.parse(messageData.data);\n } catch (e) {}\n }\n var pusherEvent: PusherEvent = {\n event: messageData.event,\n channel: messageData.channel,\n data: pusherEventData\n };\n if (messageData.user_id) {\n pusherEvent.user_id = messageData.user_id;\n }\n return pusherEvent;\n } catch (e) {\n throw { type: 'MessageParseError', error: e, data: messageEvent.data };\n }\n },\n\n /**\n * Encodes a message to be sent.\n *\n * @param {PusherEvent} event\n * @return {String}\n */\n encodeMessage: function(event: PusherEvent): string {\n return JSON.stringify(event);\n },\n\n /**\n * Processes a handshake message and returns appropriate actions.\n *\n * Returns an object with an 'action' and other action-specific properties.\n *\n * There are three outcomes when calling this function. First is a successful\n * connection attempt, when pusher:connection_established is received, which\n * results in a 'connected' action with an 'id' property. When passed a\n * pusher:error event, it returns a result with action appropriate to the\n * close code and an error. Otherwise, it raises an exception.\n *\n * @param {String} message\n * @result Object\n */\n processHandshake: function(messageEvent: MessageEvent): Action {\n var message = Protocol.decodeMessage(messageEvent);\n\n if (message.event === 'pusher:connection_established') {\n if (!message.data.activity_timeout) {\n throw 'No activity timeout specified in handshake';\n }\n return {\n action: 'connected',\n id: message.data.socket_id,\n activityTimeout: message.data.activity_timeout * 1000\n };\n } else if (message.event === 'pusher:error') {\n // From protocol 6 close codes are sent only once, so this only\n // happens when connection does not support close codes\n return {\n action: this.getCloseAction(message.data),\n error: this.getCloseError(message.data)\n };\n } else {\n throw 'Invalid handshake';\n }\n },\n\n /**\n * Dispatches the close event and returns an appropriate action name.\n *\n * See:\n * 1. https://developer.mozilla.org/en-US/docs/WebSockets/WebSockets_reference/CloseEvent\n * 2. http://pusher.com/docs/pusher_protocol\n *\n * @param {CloseEvent} closeEvent\n * @return {String} close action name\n */\n getCloseAction: function(closeEvent): string {\n if (closeEvent.code < 4000) {\n // ignore 1000 CLOSE_NORMAL, 1001 CLOSE_GOING_AWAY,\n // 1005 CLOSE_NO_STATUS, 1006 CLOSE_ABNORMAL\n // ignore 1007...3999\n // handle 1002 CLOSE_PROTOCOL_ERROR, 1003 CLOSE_UNSUPPORTED,\n // 1004 CLOSE_TOO_LARGE\n if (closeEvent.code >= 1002 && closeEvent.code <= 1004) {\n return 'backoff';\n } else {\n return null;\n }\n } else if (closeEvent.code === 4000) {\n return 'tls_only';\n } else if (closeEvent.code < 4100) {\n return 'refused';\n } else if (closeEvent.code < 4200) {\n return 'backoff';\n } else if (closeEvent.code < 4300) {\n return 'retry';\n } else {\n // unknown error\n return 'refused';\n }\n },\n\n /**\n * Returns an error or null basing on the close event.\n *\n * Null is returned when connection was closed cleanly. Otherwise, an object\n * with error details is returned.\n *\n * @param {CloseEvent} closeEvent\n * @return {Object} error object\n */\n getCloseError: function(closeEvent): any {\n if (closeEvent.code !== 1000 && closeEvent.code !== 1001) {\n return {\n type: 'PusherError',\n data: {\n code: closeEvent.code,\n message: closeEvent.reason || closeEvent.message\n }\n };\n } else {\n return null;\n }\n }\n};\n\nexport default Protocol;\n","import * as Collections from '../utils/collections';\nimport { default as EventsDispatcher } from '../events/dispatcher';\nimport Protocol from './protocol/protocol';\nimport { PusherEvent } from './protocol/message-types';\nimport Logger from '../logger';\nimport TransportConnection from '../transports/transport_connection';\nimport Socket from '../socket';\n/**\n * Provides Pusher protocol interface for transports.\n *\n * Emits following events:\n * - message - on received messages\n * - ping - on ping requests\n * - pong - on pong responses\n * - error - when the transport emits an error\n * - closed - after closing the transport\n *\n * It also emits more events when connection closes with a code.\n * See Protocol.getCloseAction to get more details.\n *\n * @param {Number} id\n * @param {AbstractTransport} transport\n */\nexport default class Connection extends EventsDispatcher implements Socket {\n id: string;\n transport: TransportConnection;\n activityTimeout: number;\n\n constructor(id: string, transport: TransportConnection) {\n super();\n this.id = id;\n this.transport = transport;\n this.activityTimeout = transport.activityTimeout;\n this.bindListeners();\n }\n\n /** Returns whether used transport handles activity checks by itself\n *\n * @returns {Boolean} true if activity checks are handled by the transport\n */\n handlesActivityChecks() {\n return this.transport.handlesActivityChecks();\n }\n\n /** Sends raw data.\n *\n * @param {String} data\n */\n send(data: any): boolean {\n return this.transport.send(data);\n }\n\n /** Sends an event.\n *\n * @param {String} name\n * @param {String} data\n * @param {String} [channel]\n * @returns {Boolean} whether message was sent or not\n */\n send_event(name: string, data: any, channel?: string): boolean {\n var event: PusherEvent = { event: name, data: data };\n if (channel) {\n event.channel = channel;\n }\n Logger.debug('Event sent', event);\n return this.send(Protocol.encodeMessage(event));\n }\n\n /** Sends a ping message to the server.\n *\n * Basing on the underlying transport, it might send either transport's\n * protocol-specific ping or pusher:ping event.\n */\n ping() {\n if (this.transport.supportsPing()) {\n this.transport.ping();\n } else {\n this.send_event('pusher:ping', {});\n }\n }\n\n /** Closes the connection. */\n close() {\n this.transport.close();\n }\n\n private bindListeners() {\n var listeners = {\n message: (messageEvent: MessageEvent) => {\n var pusherEvent;\n try {\n pusherEvent = Protocol.decodeMessage(messageEvent);\n } catch (e) {\n this.emit('error', {\n type: 'MessageParseError',\n error: e,\n data: messageEvent.data\n });\n }\n\n if (pusherEvent !== undefined) {\n Logger.debug('Event recd', pusherEvent);\n\n switch (pusherEvent.event) {\n case 'pusher:error':\n this.emit('error', {\n type: 'PusherError',\n data: pusherEvent.data\n });\n break;\n case 'pusher:ping':\n this.emit('ping');\n break;\n case 'pusher:pong':\n this.emit('pong');\n break;\n }\n this.emit('message', pusherEvent);\n }\n },\n activity: () => {\n this.emit('activity');\n },\n error: error => {\n this.emit('error', error);\n },\n closed: closeEvent => {\n unbindListeners();\n\n if (closeEvent && closeEvent.code) {\n this.handleCloseEvent(closeEvent);\n }\n\n this.transport = null;\n this.emit('closed');\n }\n };\n\n var unbindListeners = () => {\n Collections.objectApply(listeners, (listener, event) => {\n this.transport.unbind(event, listener);\n });\n };\n\n Collections.objectApply(listeners, (listener, event) => {\n this.transport.bind(event, listener);\n });\n }\n\n private handleCloseEvent(closeEvent: any) {\n var action = Protocol.getCloseAction(closeEvent);\n var error = Protocol.getCloseError(closeEvent);\n if (error) {\n this.emit('error', error);\n }\n if (action) {\n this.emit(action, { action: action, error: error });\n }\n }\n}\n","import Util from '../../util';\nimport * as Collections from '../../utils/collections';\nimport Protocol from '../protocol/protocol';\nimport Connection from '../connection';\nimport TransportConnection from '../../transports/transport_connection';\nimport HandshakePayload from './handshake_payload';\n\n/**\n * Handles Pusher protocol handshakes for transports.\n *\n * Calls back with a result object after handshake is completed. Results\n * always have two fields:\n * - action - string describing action to be taken after the handshake\n * - transport - the transport object passed to the constructor\n *\n * Different actions can set different additional properties on the result.\n * In the case of 'connected' action, there will be a 'connection' property\n * containing a Connection object for the transport. Other actions should\n * carry an 'error' property.\n *\n * @param {AbstractTransport} transport\n * @param {Function} callback\n */\nexport default class Handshake {\n transport: TransportConnection;\n callback: (HandshakePayload) => void;\n onMessage: Function;\n onClosed: Function;\n\n constructor(\n transport: TransportConnection,\n callback: (HandshakePayload) => void\n ) {\n this.transport = transport;\n this.callback = callback;\n this.bindListeners();\n }\n\n close() {\n this.unbindListeners();\n this.transport.close();\n }\n\n private bindListeners() {\n this.onMessage = m => {\n this.unbindListeners();\n\n var result;\n try {\n result = Protocol.processHandshake(m);\n } catch (e) {\n this.finish('error', { error: e });\n this.transport.close();\n return;\n }\n\n if (result.action === 'connected') {\n this.finish('connected', {\n connection: new Connection(result.id, this.transport),\n activityTimeout: result.activityTimeout\n });\n } else {\n this.finish(result.action, { error: result.error });\n this.transport.close();\n }\n };\n\n this.onClosed = closeEvent => {\n this.unbindListeners();\n\n var action = Protocol.getCloseAction(closeEvent) || 'backoff';\n var error = Protocol.getCloseError(closeEvent);\n this.finish(action, { error: error });\n };\n\n this.transport.bind('message', this.onMessage);\n this.transport.bind('closed', this.onClosed);\n }\n\n private unbindListeners() {\n this.transport.unbind('message', this.onMessage);\n this.transport.unbind('closed', this.onClosed);\n }\n\n private finish(action: string, params: any) {\n this.callback(\n Collections.extend({ transport: this.transport, action: action }, params)\n );\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport base64encode from '../base64';\nimport Timeline from './timeline';\nimport Runtime from 'runtime';\n\nexport interface TimelineSenderOptions {\n host?: string;\n port?: number;\n path?: string;\n}\n\nexport default class TimelineSender {\n timeline: Timeline;\n options: TimelineSenderOptions;\n host: string;\n\n constructor(timeline: Timeline, options: TimelineSenderOptions) {\n this.timeline = timeline;\n this.options = options || {};\n }\n\n send(useTLS: boolean, callback?: Function) {\n if (this.timeline.isEmpty()) {\n return;\n }\n\n this.timeline.send(\n Runtime.TimelineTransport.getAgent(this, useTLS),\n callback\n );\n }\n}\n","import { default as EventsDispatcher } from '../events/dispatcher';\nimport * as Errors from '../errors';\nimport Logger from '../logger';\nimport Pusher from '../pusher';\nimport { PusherEvent } from '../connection/protocol/message-types';\nimport Metadata from './metadata';\nimport UrlStore from '../utils/url_store';\nimport {\n ChannelAuthorizationData,\n ChannelAuthorizationCallback\n} from '../auth/options';\nimport { HTTPAuthError } from '../errors';\n\n/** Provides base public channel interface with an event emitter.\n *\n * Emits:\n * - pusher:subscription_succeeded - after subscribing successfully\n * - other non-internal events\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\nexport default class Channel extends EventsDispatcher {\n name: string;\n pusher: Pusher;\n subscribed: boolean;\n subscriptionPending: boolean;\n subscriptionCancelled: boolean;\n subscriptionCount: null;\n\n constructor(name: string, pusher: Pusher) {\n super(function(event, data) {\n Logger.debug('No callbacks on ' + name + ' for ' + event);\n });\n\n this.name = name;\n this.pusher = pusher;\n this.subscribed = false;\n this.subscriptionPending = false;\n this.subscriptionCancelled = false;\n }\n\n /** Skips authorization, since public channels don't require it.\n *\n * @param {Function} callback\n */\n authorize(socketId: string, callback: ChannelAuthorizationCallback) {\n return callback(null, { auth: '' });\n }\n\n /** Triggers an event */\n trigger(event: string, data: any) {\n if (event.indexOf('client-') !== 0) {\n throw new Errors.BadEventName(\n \"Event '\" + event + \"' does not start with 'client-'\"\n );\n }\n if (!this.subscribed) {\n var suffix = UrlStore.buildLogSuffix('triggeringClientEvents');\n Logger.warn(\n `Client event triggered before channel 'subscription_succeeded' event . ${suffix}`\n );\n }\n return this.pusher.send_event(event, data, this.name);\n }\n\n /** Signals disconnection to the channel. For internal use only. */\n disconnect() {\n this.subscribed = false;\n this.subscriptionPending = false;\n }\n\n /** Handles a PusherEvent. For internal use only.\n *\n * @param {PusherEvent} event\n */\n handleEvent(event: PusherEvent) {\n var eventName = event.event;\n var data = event.data;\n if (eventName === 'pusher_internal:subscription_succeeded') {\n this.handleSubscriptionSucceededEvent(event);\n } else if (eventName === 'pusher_internal:subscription_count') {\n this.handleSubscriptionCountEvent(event);\n } else if (eventName.indexOf('pusher_internal:') !== 0) {\n var metadata: Metadata = {};\n this.emit(eventName, data, metadata);\n }\n }\n\n handleSubscriptionSucceededEvent(event: PusherEvent) {\n this.subscriptionPending = false;\n this.subscribed = true;\n if (this.subscriptionCancelled) {\n this.pusher.unsubscribe(this.name);\n } else {\n this.emit('pusher:subscription_succeeded', event.data);\n }\n }\n\n handleSubscriptionCountEvent(event: PusherEvent) {\n if (event.data.subscription_count) {\n this.subscriptionCount = event.data.subscription_count;\n }\n\n this.emit('pusher:subscription_count', event.data);\n }\n\n /** Sends a subscription request. For internal use only. */\n subscribe() {\n if (this.subscribed) {\n return;\n }\n this.subscriptionPending = true;\n this.subscriptionCancelled = false;\n this.authorize(\n this.pusher.connection.socket_id,\n (error: Error | null, data: ChannelAuthorizationData) => {\n if (error) {\n this.subscriptionPending = false;\n // Why not bind to 'pusher:subscription_error' a level up, and log there?\n // Binding to this event would cause the warning about no callbacks being\n // bound (see constructor) to be suppressed, that's not what we want.\n Logger.error(error.toString());\n this.emit(\n 'pusher:subscription_error',\n Object.assign(\n {},\n {\n type: 'AuthError',\n error: error.message\n },\n error instanceof HTTPAuthError ? { status: error.status } : {}\n )\n );\n } else {\n this.pusher.send_event('pusher:subscribe', {\n auth: data.auth,\n channel_data: data.channel_data,\n channel: this.name\n });\n }\n }\n );\n }\n\n /** Sends an unsubscription request. For internal use only. */\n unsubscribe() {\n this.subscribed = false;\n this.pusher.send_event('pusher:unsubscribe', {\n channel: this.name\n });\n }\n\n /** Cancels an in progress subscription. For internal use only. */\n cancelSubscription() {\n this.subscriptionCancelled = true;\n }\n\n /** Reinstates an in progress subscripiton. For internal use only. */\n reinstateSubscription() {\n this.subscriptionCancelled = false;\n }\n}\n","import Factory from '../utils/factory';\nimport Channel from './channel';\nimport { ChannelAuthorizationCallback } from '../auth/options';\n\n/** Extends public channels to provide private channel interface.\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\nexport default class PrivateChannel extends Channel {\n /** Authorizes the connection to use the channel.\n *\n * @param {String} socketId\n * @param {Function} callback\n */\n authorize(socketId: string, callback: ChannelAuthorizationCallback) {\n return this.pusher.config.channelAuthorizer(\n {\n channelName: this.name,\n socketId: socketId\n },\n callback\n );\n }\n}\n","import * as Collections from '../utils/collections';\n\n/** Represents a collection of members of a presence channel. */\nexport default class Members {\n members: any;\n count: number;\n myID: any;\n me: any;\n\n constructor() {\n this.reset();\n }\n\n /** Returns member's info for given id.\n *\n * Resulting object containts two fields - id and info.\n *\n * @param {Number} id\n * @return {Object} member's info or null\n */\n get(id: string): any {\n if (Object.prototype.hasOwnProperty.call(this.members, id)) {\n return {\n id: id,\n info: this.members[id]\n };\n } else {\n return null;\n }\n }\n\n /** Calls back for each member in unspecified order.\n *\n * @param {Function} callback\n */\n each(callback: Function) {\n Collections.objectApply(this.members, (member, id) => {\n callback(this.get(id));\n });\n }\n\n /** Updates the id for connected member. For internal use only. */\n setMyID(id: string) {\n this.myID = id;\n }\n\n /** Handles subscription data. For internal use only. */\n onSubscription(subscriptionData: any) {\n this.members = subscriptionData.presence.hash;\n this.count = subscriptionData.presence.count;\n this.me = this.get(this.myID);\n }\n\n /** Adds a new member to the collection. For internal use only. */\n addMember(memberData: any) {\n if (this.get(memberData.user_id) === null) {\n this.count++;\n }\n this.members[memberData.user_id] = memberData.user_info;\n return this.get(memberData.user_id);\n }\n\n /** Adds a member from the collection. For internal use only. */\n removeMember(memberData: any) {\n var member = this.get(memberData.user_id);\n if (member) {\n delete this.members[memberData.user_id];\n this.count--;\n }\n return member;\n }\n\n /** Resets the collection to the initial state. For internal use only. */\n reset() {\n this.members = {};\n this.count = 0;\n this.myID = null;\n this.me = null;\n }\n}\n","import PrivateChannel from './private_channel';\nimport Logger from '../logger';\nimport Members from './members';\nimport Pusher from '../pusher';\nimport UrlStore from 'core/utils/url_store';\nimport { PusherEvent } from '../connection/protocol/message-types';\nimport Metadata from './metadata';\nimport { ChannelAuthorizationData } from '../auth/options';\n\nexport default class PresenceChannel extends PrivateChannel {\n members: Members;\n\n /** Adds presence channel functionality to private channels.\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\n constructor(name: string, pusher: Pusher) {\n super(name, pusher);\n this.members = new Members();\n }\n\n /** Authorizes the connection as a member of the channel.\n *\n * @param {String} socketId\n * @param {Function} callback\n */\n authorize(socketId: string, callback: Function) {\n super.authorize(socketId, async (error, authData) => {\n if (!error) {\n authData = authData as ChannelAuthorizationData;\n if (authData.channel_data != null) {\n var channelData = JSON.parse(authData.channel_data);\n this.members.setMyID(channelData.user_id);\n } else {\n await this.pusher.user.signinDonePromise;\n if (this.pusher.user.user_data != null) {\n // If the user is signed in, get the id of the authenticated user\n // and allow the presence authorization to continue.\n this.members.setMyID(this.pusher.user.user_data.id);\n } else {\n let suffix = UrlStore.buildLogSuffix('authorizationEndpoint');\n Logger.error(\n `Invalid auth response for channel '${this.name}', ` +\n `expected 'channel_data' field. ${suffix}, ` +\n `or the user should be signed in.`\n );\n callback('Invalid auth response');\n return;\n }\n }\n }\n callback(error, authData);\n });\n }\n\n /** Handles presence and subscription events. For internal use only.\n *\n * @param {PusherEvent} event\n */\n handleEvent(event: PusherEvent) {\n var eventName = event.event;\n if (eventName.indexOf('pusher_internal:') === 0) {\n this.handleInternalEvent(event);\n } else {\n var data = event.data;\n var metadata: Metadata = {};\n if (event.user_id) {\n metadata.user_id = event.user_id;\n }\n this.emit(eventName, data, metadata);\n }\n }\n handleInternalEvent(event: PusherEvent) {\n var eventName = event.event;\n var data = event.data;\n switch (eventName) {\n case 'pusher_internal:subscription_succeeded':\n this.handleSubscriptionSucceededEvent(event);\n break;\n case 'pusher_internal:subscription_count':\n this.handleSubscriptionCountEvent(event);\n break;\n case 'pusher_internal:member_added':\n var addedMember = this.members.addMember(data);\n this.emit('pusher:member_added', addedMember);\n break;\n case 'pusher_internal:member_removed':\n var removedMember = this.members.removeMember(data);\n if (removedMember) {\n this.emit('pusher:member_removed', removedMember);\n }\n break;\n }\n }\n\n handleSubscriptionSucceededEvent(event: PusherEvent) {\n this.subscriptionPending = false;\n this.subscribed = true;\n if (this.subscriptionCancelled) {\n this.pusher.unsubscribe(this.name);\n } else {\n this.members.onSubscription(event.data);\n this.emit('pusher:subscription_succeeded', this.members);\n }\n }\n\n /** Resets the channel state, including members map. For internal use only. */\n disconnect() {\n this.members.reset();\n super.disconnect();\n }\n}\n","import PrivateChannel from './private_channel';\nimport * as Errors from '../errors';\nimport Logger from '../logger';\nimport Pusher from '../pusher';\nimport { decode as encodeUTF8 } from '@stablelib/utf8';\nimport { decode as decodeBase64 } from '@stablelib/base64';\nimport Dispatcher from '../events/dispatcher';\nimport { PusherEvent } from '../connection/protocol/message-types';\nimport {\n ChannelAuthorizationData,\n ChannelAuthorizationCallback\n} from '../auth/options';\nimport * as nacl from 'tweetnacl';\n\n/** Extends private channels to provide encrypted channel interface.\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\nexport default class EncryptedChannel extends PrivateChannel {\n key: Uint8Array = null;\n nacl: nacl;\n\n constructor(name: string, pusher: Pusher, nacl: nacl) {\n super(name, pusher);\n this.nacl = nacl;\n }\n\n /** Authorizes the connection to use the channel.\n *\n * @param {String} socketId\n * @param {Function} callback\n */\n authorize(socketId: string, callback: ChannelAuthorizationCallback) {\n super.authorize(\n socketId,\n (error: Error | null, authData: ChannelAuthorizationData) => {\n if (error) {\n callback(error, authData);\n return;\n }\n let sharedSecret = authData['shared_secret'];\n if (!sharedSecret) {\n callback(\n new Error(\n `No shared_secret key in auth payload for encrypted channel: ${this.name}`\n ),\n null\n );\n return;\n }\n this.key = decodeBase64(sharedSecret);\n delete authData['shared_secret'];\n callback(null, authData);\n }\n );\n }\n\n trigger(event: string, data: any): boolean {\n throw new Errors.UnsupportedFeature(\n 'Client events are not currently supported for encrypted channels'\n );\n }\n\n /** Handles an event. For internal use only.\n *\n * @param {PusherEvent} event\n */\n handleEvent(event: PusherEvent) {\n var eventName = event.event;\n var data = event.data;\n if (\n eventName.indexOf('pusher_internal:') === 0 ||\n eventName.indexOf('pusher:') === 0\n ) {\n super.handleEvent(event);\n return;\n }\n this.handleEncryptedEvent(eventName, data);\n }\n\n private handleEncryptedEvent(event: string, data: any): void {\n if (!this.key) {\n Logger.debug(\n 'Received encrypted event before key has been retrieved from the authEndpoint'\n );\n return;\n }\n if (!data.ciphertext || !data.nonce) {\n Logger.error(\n 'Unexpected format for encrypted event, expected object with `ciphertext` and `nonce` fields, got: ' +\n data\n );\n return;\n }\n let cipherText = decodeBase64(data.ciphertext);\n if (cipherText.length < this.nacl.secretbox.overheadLength) {\n Logger.error(\n `Expected encrypted event ciphertext length to be ${this.nacl.secretbox.overheadLength}, got: ${cipherText.length}`\n );\n return;\n }\n let nonce = decodeBase64(data.nonce);\n if (nonce.length < this.nacl.secretbox.nonceLength) {\n Logger.error(\n `Expected encrypted event nonce length to be ${this.nacl.secretbox.nonceLength}, got: ${nonce.length}`\n );\n return;\n }\n\n let bytes = this.nacl.secretbox.open(cipherText, nonce, this.key);\n if (bytes === null) {\n Logger.debug(\n 'Failed to decrypt an event, probably because it was encrypted with a different key. Fetching a new key from the authEndpoint...'\n );\n // Try a single time to retrieve a new auth key and decrypt the event with it\n // If this fails, a new key will be requested when a new message is received\n this.authorize(this.pusher.connection.socket_id, (error, authData) => {\n if (error) {\n Logger.error(\n `Failed to make a request to the authEndpoint: ${authData}. Unable to fetch new key, so dropping encrypted event`\n );\n return;\n }\n bytes = this.nacl.secretbox.open(cipherText, nonce, this.key);\n if (bytes === null) {\n Logger.error(\n `Failed to decrypt event with new key. Dropping encrypted event`\n );\n return;\n }\n this.emit(event, this.getDataToEmit(bytes));\n return;\n });\n return;\n }\n this.emit(event, this.getDataToEmit(bytes));\n }\n\n // Try and parse the decrypted bytes as JSON. If we can't parse it, just\n // return the utf-8 string\n getDataToEmit(bytes: Uint8Array): string {\n let raw = encodeUTF8(bytes);\n try {\n return JSON.parse(raw);\n } catch {\n return raw;\n }\n }\n}\n","import { default as EventsDispatcher } from '../events/dispatcher';\nimport { OneOffTimer as Timer } from '../utils/timers';\nimport { Config } from '../config';\nimport Logger from '../logger';\nimport HandshakePayload from './handshake/handshake_payload';\nimport Connection from './connection';\nimport Strategy from '../strategies/strategy';\nimport StrategyRunner from '../strategies/strategy_runner';\nimport * as Collections from '../utils/collections';\nimport Timeline from '../timeline/timeline';\nimport ConnectionManagerOptions from './connection_manager_options';\nimport Runtime from 'runtime';\n\nimport {\n ErrorCallbacks,\n HandshakeCallbacks,\n ConnectionCallbacks\n} from './callbacks';\nimport Action from './protocol/action';\n\n/** Manages connection to Pusher.\n *\n * Uses a strategy (currently only default), timers and network availability\n * info to establish a connection and export its state. In case of failures,\n * manages reconnection attempts.\n *\n * Exports state changes as following events:\n * - \"state_change\", { previous: p, current: state }\n * - state\n *\n * States:\n * - initialized - initial state, never transitioned to\n * - connecting - connection is being established\n * - connected - connection has been fully established\n * - disconnected - on requested disconnection\n * - unavailable - after connection timeout or when there's no network\n * - failed - when the connection strategy is not supported\n *\n * Options:\n * - unavailableTimeout - time to transition to unavailable state\n * - activityTimeout - time after which ping message should be sent\n * - pongTimeout - time for Pusher to respond with pong before reconnecting\n *\n * @param {String} key application key\n * @param {Object} options\n */\nexport default class ConnectionManager extends EventsDispatcher {\n key: string;\n options: ConnectionManagerOptions;\n state: string;\n connection: Connection;\n usingTLS: boolean;\n timeline: Timeline;\n socket_id: string;\n unavailableTimer: Timer;\n activityTimer: Timer;\n retryTimer: Timer;\n activityTimeout: number;\n strategy: Strategy;\n runner: StrategyRunner;\n errorCallbacks: ErrorCallbacks;\n handshakeCallbacks: HandshakeCallbacks;\n connectionCallbacks: ConnectionCallbacks;\n\n constructor(key: string, options: ConnectionManagerOptions) {\n super();\n this.state = 'initialized';\n this.connection = null;\n\n this.key = key;\n this.options = options;\n this.timeline = this.options.timeline;\n this.usingTLS = this.options.useTLS;\n\n this.errorCallbacks = this.buildErrorCallbacks();\n this.connectionCallbacks = this.buildConnectionCallbacks(\n this.errorCallbacks\n );\n this.handshakeCallbacks = this.buildHandshakeCallbacks(this.errorCallbacks);\n\n var Network = Runtime.getNetwork();\n\n Network.bind('online', () => {\n this.timeline.info({ netinfo: 'online' });\n if (this.state === 'connecting' || this.state === 'unavailable') {\n this.retryIn(0);\n }\n });\n Network.bind('offline', () => {\n this.timeline.info({ netinfo: 'offline' });\n if (this.connection) {\n this.sendActivityCheck();\n }\n });\n\n this.updateStrategy();\n }\n\n switchCluster(key: string) {\n this.key = key;\n // This ensures that the new config coming from\n // pusher instance are taken into account\n // such as appKey and cluster\n this.updateStrategy();\n this.retryIn(0);\n }\n\n /** Establishes a connection to Pusher.\n *\n * Does nothing when connection is already established. See top-level doc\n * to find events emitted on connection attempts.\n */\n connect() {\n if (this.connection || this.runner) {\n return;\n }\n if (!this.strategy.isSupported()) {\n this.updateState('failed');\n return;\n }\n this.updateState('connecting');\n this.startConnecting();\n this.setUnavailableTimer();\n }\n\n /** Sends raw data.\n *\n * @param {String} data\n */\n send(data) {\n if (this.connection) {\n return this.connection.send(data);\n } else {\n return false;\n }\n }\n\n /** Sends an event.\n *\n * @param {String} name\n * @param {String} data\n * @param {String} [channel]\n * @returns {Boolean} whether message was sent or not\n */\n send_event(name: string, data: any, channel?: string) {\n if (this.connection) {\n return this.connection.send_event(name, data, channel);\n } else {\n return false;\n }\n }\n\n /** Closes the connection. */\n disconnect() {\n this.disconnectInternally();\n this.updateState('disconnected');\n }\n\n isUsingTLS() {\n return this.usingTLS;\n }\n\n private startConnecting() {\n var callback = (error, handshake) => {\n if (error) {\n this.runner = this.strategy.connect(0, callback);\n } else {\n if (handshake.action === 'error') {\n this.emit('error', {\n type: 'HandshakeError',\n error: handshake.error\n });\n this.timeline.error({ handshakeError: handshake.error });\n } else {\n this.abortConnecting(); // we don't support switching connections yet\n this.handshakeCallbacks[handshake.action](handshake);\n }\n }\n };\n this.runner = this.strategy.connect(0, callback);\n }\n\n private abortConnecting() {\n if (this.runner) {\n this.runner.abort();\n this.runner = null;\n }\n }\n\n private disconnectInternally() {\n this.abortConnecting();\n this.clearRetryTimer();\n this.clearUnavailableTimer();\n if (this.connection) {\n var connection = this.abandonConnection();\n connection.close();\n }\n }\n\n private updateStrategy() {\n this.strategy = this.options.getStrategy({\n key: this.key,\n timeline: this.timeline,\n useTLS: this.usingTLS\n });\n }\n\n private retryIn(delay) {\n this.timeline.info({ action: 'retry', delay: delay });\n if (delay > 0) {\n this.emit('connecting_in', Math.round(delay / 1000));\n }\n this.retryTimer = new Timer(delay || 0, () => {\n this.disconnectInternally();\n this.connect();\n });\n }\n\n private clearRetryTimer() {\n if (this.retryTimer) {\n this.retryTimer.ensureAborted();\n this.retryTimer = null;\n }\n }\n\n private setUnavailableTimer() {\n this.unavailableTimer = new Timer(this.options.unavailableTimeout, () => {\n this.updateState('unavailable');\n });\n }\n\n private clearUnavailableTimer() {\n if (this.unavailableTimer) {\n this.unavailableTimer.ensureAborted();\n }\n }\n\n private sendActivityCheck() {\n this.stopActivityCheck();\n this.connection.ping();\n // wait for pong response\n this.activityTimer = new Timer(this.options.pongTimeout, () => {\n this.timeline.error({ pong_timed_out: this.options.pongTimeout });\n this.retryIn(0);\n });\n }\n\n private resetActivityCheck() {\n this.stopActivityCheck();\n // send ping after inactivity\n if (this.connection && !this.connection.handlesActivityChecks()) {\n this.activityTimer = new Timer(this.activityTimeout, () => {\n this.sendActivityCheck();\n });\n }\n }\n\n private stopActivityCheck() {\n if (this.activityTimer) {\n this.activityTimer.ensureAborted();\n }\n }\n\n private buildConnectionCallbacks(\n errorCallbacks: ErrorCallbacks\n ): ConnectionCallbacks {\n return Collections.extend({}, errorCallbacks, {\n message: message => {\n // includes pong messages from server\n this.resetActivityCheck();\n this.emit('message', message);\n },\n ping: () => {\n this.send_event('pusher:pong', {});\n },\n activity: () => {\n this.resetActivityCheck();\n },\n error: error => {\n // just emit error to user - socket will already be closed by browser\n this.emit('error', error);\n },\n closed: () => {\n this.abandonConnection();\n if (this.shouldRetry()) {\n this.retryIn(1000);\n }\n }\n });\n }\n\n private buildHandshakeCallbacks(\n errorCallbacks: ErrorCallbacks\n ): HandshakeCallbacks {\n return Collections.extend({}, errorCallbacks, {\n connected: (handshake: HandshakePayload) => {\n this.activityTimeout = Math.min(\n this.options.activityTimeout,\n handshake.activityTimeout,\n handshake.connection.activityTimeout || Infinity\n );\n this.clearUnavailableTimer();\n this.setConnection(handshake.connection);\n this.socket_id = this.connection.id;\n this.updateState('connected', { socket_id: this.socket_id });\n }\n });\n }\n\n private buildErrorCallbacks(): ErrorCallbacks {\n let withErrorEmitted = callback => {\n return (result: Action | HandshakePayload) => {\n if (result.error) {\n this.emit('error', { type: 'WebSocketError', error: result.error });\n }\n callback(result);\n };\n };\n\n return {\n tls_only: withErrorEmitted(() => {\n this.usingTLS = true;\n this.updateStrategy();\n this.retryIn(0);\n }),\n refused: withErrorEmitted(() => {\n this.disconnect();\n }),\n backoff: withErrorEmitted(() => {\n this.retryIn(1000);\n }),\n retry: withErrorEmitted(() => {\n this.retryIn(0);\n })\n };\n }\n\n private setConnection(connection) {\n this.connection = connection;\n for (var event in this.connectionCallbacks) {\n this.connection.bind(event, this.connectionCallbacks[event]);\n }\n this.resetActivityCheck();\n }\n\n private abandonConnection() {\n if (!this.connection) {\n return;\n }\n this.stopActivityCheck();\n for (var event in this.connectionCallbacks) {\n this.connection.unbind(event, this.connectionCallbacks[event]);\n }\n var connection = this.connection;\n this.connection = null;\n return connection;\n }\n\n private updateState(newState: string, data?: any) {\n var previousState = this.state;\n this.state = newState;\n if (previousState !== newState) {\n var newStateDescription = newState;\n if (newStateDescription === 'connected') {\n newStateDescription += ' with new socket ID ' + data.socket_id;\n }\n Logger.debug(\n 'State changed',\n previousState + ' -> ' + newStateDescription\n );\n this.timeline.info({ state: newState, params: data });\n this.emit('state_change', { previous: previousState, current: newState });\n this.emit(newState, data);\n }\n }\n\n private shouldRetry(): boolean {\n return this.state === 'connecting' || this.state === 'connected';\n }\n}\n","import Channel from './channel';\nimport * as Collections from '../utils/collections';\nimport ChannelTable from './channel_table';\nimport Factory from '../utils/factory';\nimport Pusher from '../pusher';\nimport Logger from '../logger';\nimport * as Errors from '../errors';\nimport urlStore from '../utils/url_store';\n\n/** Handles a channel map. */\nexport default class Channels {\n channels: ChannelTable;\n\n constructor() {\n this.channels = {};\n }\n\n /** Creates or retrieves an existing channel by its name.\n *\n * @param {String} name\n * @param {Pusher} pusher\n * @return {Channel}\n */\n add(name: string, pusher: Pusher) {\n if (!this.channels[name]) {\n this.channels[name] = createChannel(name, pusher);\n }\n return this.channels[name];\n }\n\n /** Returns a list of all channels\n *\n * @return {Array}\n */\n all(): Channel[] {\n return Collections.values(this.channels);\n }\n\n /** Finds a channel by its name.\n *\n * @param {String} name\n * @return {Channel} channel or null if it doesn't exist\n */\n find(name: string) {\n return this.channels[name];\n }\n\n /** Removes a channel from the map.\n *\n * @param {String} name\n */\n remove(name: string) {\n var channel = this.channels[name];\n delete this.channels[name];\n return channel;\n }\n\n /** Proxies disconnection signal to all channels. */\n disconnect() {\n Collections.objectApply(this.channels, function(channel) {\n channel.disconnect();\n });\n }\n}\n\nfunction createChannel(name: string, pusher: Pusher): Channel {\n if (name.indexOf('private-encrypted-') === 0) {\n if (pusher.config.nacl) {\n return Factory.createEncryptedChannel(name, pusher, pusher.config.nacl);\n }\n let errMsg =\n 'Tried to subscribe to a private-encrypted- channel but no nacl implementation available';\n let suffix = urlStore.buildLogSuffix('encryptedChannelSupport');\n throw new Errors.UnsupportedFeature(`${errMsg}. ${suffix}`);\n } else if (name.indexOf('private-') === 0) {\n return Factory.createPrivateChannel(name, pusher);\n } else if (name.indexOf('presence-') === 0) {\n return Factory.createPresenceChannel(name, pusher);\n } else if (name.indexOf('#') === 0) {\n throw new Errors.BadChannelName(\n 'Cannot create a channel with name \"' + name + '\".'\n );\n } else {\n return Factory.createChannel(name, pusher);\n }\n}\n","import AssistantToTheTransportManager from '../transports/assistant_to_the_transport_manager';\nimport PingDelayOptions from '../transports/ping_delay_options';\nimport Transport from '../transports/transport';\nimport TransportManager from '../transports/transport_manager';\nimport Handshake from '../connection/handshake';\nimport TransportConnection from '../transports/transport_connection';\nimport SocketHooks from '../http/socket_hooks';\nimport HTTPSocket from '../http/http_socket';\n\nimport Timeline from '../timeline/timeline';\nimport {\n default as TimelineSender,\n TimelineSenderOptions\n} from '../timeline/timeline_sender';\nimport PresenceChannel from '../channels/presence_channel';\nimport PrivateChannel from '../channels/private_channel';\nimport EncryptedChannel from '../channels/encrypted_channel';\nimport Channel from '../channels/channel';\nimport ConnectionManager from '../connection/connection_manager';\nimport ConnectionManagerOptions from '../connection/connection_manager_options';\nimport Ajax from '../http/ajax';\nimport Channels from '../channels/channels';\nimport Pusher from '../pusher';\nimport { Config } from '../config';\nimport * as nacl from 'tweetnacl';\n\nvar Factory = {\n createChannels(): Channels {\n return new Channels();\n },\n\n createConnectionManager(\n key: string,\n options: ConnectionManagerOptions\n ): ConnectionManager {\n return new ConnectionManager(key, options);\n },\n\n createChannel(name: string, pusher: Pusher): Channel {\n return new Channel(name, pusher);\n },\n\n createPrivateChannel(name: string, pusher: Pusher): PrivateChannel {\n return new PrivateChannel(name, pusher);\n },\n\n createPresenceChannel(name: string, pusher: Pusher): PresenceChannel {\n return new PresenceChannel(name, pusher);\n },\n\n createEncryptedChannel(\n name: string,\n pusher: Pusher,\n nacl: nacl\n ): EncryptedChannel {\n return new EncryptedChannel(name, pusher, nacl);\n },\n\n createTimelineSender(timeline: Timeline, options: TimelineSenderOptions) {\n return new TimelineSender(timeline, options);\n },\n\n createHandshake(\n transport: TransportConnection,\n callback: (HandshakePayload) => void\n ): Handshake {\n return new Handshake(transport, callback);\n },\n\n createAssistantToTheTransportManager(\n manager: TransportManager,\n transport: Transport,\n options: PingDelayOptions\n ): AssistantToTheTransportManager {\n return new AssistantToTheTransportManager(manager, transport, options);\n }\n};\n\nexport default Factory;\n","import AssistantToTheTransportManager from './assistant_to_the_transport_manager';\nimport Transport from './transport';\nimport PingDelayOptions from './ping_delay_options';\nimport Factory from '../utils/factory';\n\nexport interface TransportManagerOptions extends PingDelayOptions {\n lives?: number;\n}\n\n/** Keeps track of the number of lives left for a transport.\n *\n * In the beginning of a session, transports may be assigned a number of\n * lives. When an AssistantToTheTransportManager instance reports a transport\n * connection closed uncleanly, the transport loses a life. When the number\n * of lives drops to zero, the transport gets disabled by its manager.\n *\n * @param {Object} options\n */\nexport default class TransportManager {\n options: TransportManagerOptions;\n livesLeft: number;\n\n constructor(options: TransportManagerOptions) {\n this.options = options || {};\n this.livesLeft = this.options.lives || Infinity;\n }\n\n /** Creates a assistant for the transport.\n *\n * @param {Transport} transport\n * @returns {AssistantToTheTransportManager}\n */\n getAssistant(transport: Transport): AssistantToTheTransportManager {\n return Factory.createAssistantToTheTransportManager(this, transport, {\n minPingDelay: this.options.minPingDelay,\n maxPingDelay: this.options.maxPingDelay\n });\n }\n\n /** Returns whether the transport has any lives left.\n *\n * @returns {Boolean}\n */\n isAlive(): boolean {\n return this.livesLeft > 0;\n }\n\n /** Takes one life from the transport. */\n reportDeath() {\n this.livesLeft -= 1;\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport { OneOffTimer as Timer } from '../utils/timers';\nimport Strategy from './strategy';\nimport StrategyOptions from './strategy_options';\n\n/** Loops through strategies with optional timeouts.\n *\n * Options:\n * - loop - whether it should loop through the substrategy list\n * - timeout - initial timeout for a single substrategy\n * - timeoutLimit - maximum timeout\n *\n * @param {Strategy[]} strategies\n * @param {Object} options\n */\nexport default class SequentialStrategy implements Strategy {\n strategies: Strategy[];\n loop: boolean;\n failFast: boolean;\n timeout: number;\n timeoutLimit: number;\n\n constructor(strategies: Strategy[], options: StrategyOptions) {\n this.strategies = strategies;\n this.loop = Boolean(options.loop);\n this.failFast = Boolean(options.failFast);\n this.timeout = options.timeout;\n this.timeoutLimit = options.timeoutLimit;\n }\n\n isSupported(): boolean {\n return Collections.any(this.strategies, Util.method('isSupported'));\n }\n\n connect(minPriority: number, callback: Function) {\n var strategies = this.strategies;\n var current = 0;\n var timeout = this.timeout;\n var runner = null;\n\n var tryNextStrategy = (error, handshake) => {\n if (handshake) {\n callback(null, handshake);\n } else {\n current = current + 1;\n if (this.loop) {\n current = current % strategies.length;\n }\n\n if (current < strategies.length) {\n if (timeout) {\n timeout = timeout * 2;\n if (this.timeoutLimit) {\n timeout = Math.min(timeout, this.timeoutLimit);\n }\n }\n runner = this.tryStrategy(\n strategies[current],\n minPriority,\n { timeout, failFast: this.failFast },\n tryNextStrategy\n );\n } else {\n callback(true);\n }\n }\n };\n\n runner = this.tryStrategy(\n strategies[current],\n minPriority,\n { timeout: timeout, failFast: this.failFast },\n tryNextStrategy\n );\n\n return {\n abort: function() {\n runner.abort();\n },\n forceMinPriority: function(p) {\n minPriority = p;\n if (runner) {\n runner.forceMinPriority(p);\n }\n }\n };\n }\n\n private tryStrategy(\n strategy: Strategy,\n minPriority: number,\n options: StrategyOptions,\n callback: Function\n ) {\n var timer = null;\n var runner = null;\n\n if (options.timeout > 0) {\n timer = new Timer(options.timeout, function() {\n runner.abort();\n callback(true);\n });\n }\n\n runner = strategy.connect(minPriority, function(error, handshake) {\n if (error && timer && timer.isRunning() && !options.failFast) {\n // advance to the next strategy after the timeout\n return;\n }\n if (timer) {\n timer.ensureAborted();\n }\n callback(error, handshake);\n });\n\n return {\n abort: function() {\n if (timer) {\n timer.ensureAborted();\n }\n runner.abort();\n },\n forceMinPriority: function(p) {\n runner.forceMinPriority(p);\n }\n };\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport Strategy from './strategy';\n\n/** Launches all substrategies and emits prioritized connected transports.\n *\n * @param {Array} strategies\n */\nexport default class BestConnectedEverStrategy implements Strategy {\n strategies: Strategy[];\n\n constructor(strategies: Strategy[]) {\n this.strategies = strategies;\n }\n\n isSupported(): boolean {\n return Collections.any(this.strategies, Util.method('isSupported'));\n }\n\n connect(minPriority: number, callback: Function) {\n return connect(this.strategies, minPriority, function(i, runners) {\n return function(error, handshake) {\n runners[i].error = error;\n if (error) {\n if (allRunnersFailed(runners)) {\n callback(true);\n }\n return;\n }\n Collections.apply(runners, function(runner) {\n runner.forceMinPriority(handshake.transport.priority);\n });\n callback(null, handshake);\n };\n });\n }\n}\n\n/** Connects to all strategies in parallel.\n *\n * Callback builder should be a function that takes two arguments: index\n * and a list of runners. It should return another function that will be\n * passed to the substrategy with given index. Runners can be aborted using\n * abortRunner(s) functions from this class.\n *\n * @param {Array} strategies\n * @param {Function} callbackBuilder\n * @return {Object} strategy runner\n */\nfunction connect(\n strategies: Strategy[],\n minPriority: number,\n callbackBuilder: Function\n) {\n var runners = Collections.map(strategies, function(strategy, i, _, rs) {\n return strategy.connect(minPriority, callbackBuilder(i, rs));\n });\n return {\n abort: function() {\n Collections.apply(runners, abortRunner);\n },\n forceMinPriority: function(p) {\n Collections.apply(runners, function(runner) {\n runner.forceMinPriority(p);\n });\n }\n };\n}\n\nfunction allRunnersFailed(runners): boolean {\n return Collections.all(runners, function(runner) {\n return Boolean(runner.error);\n });\n}\n\nfunction abortRunner(runner) {\n if (!runner.error && !runner.aborted) {\n runner.abort();\n runner.aborted = true;\n }\n}\n","import Util from '../util';\nimport Runtime from 'runtime';\nimport Strategy from './strategy';\nimport SequentialStrategy from './sequential_strategy';\nimport StrategyOptions from './strategy_options';\nimport TransportStrategy from './transport_strategy';\nimport Timeline from '../timeline/timeline';\nimport * as Collections from '../utils/collections';\n\nexport interface TransportStrategyDictionary {\n [key: string]: TransportStrategy;\n}\n\n/** Caches the last successful transport and, after the first few attempts,\n * uses the cached transport for subsequent attempts.\n *\n * @param {Strategy} strategy\n * @param {Object} transports\n * @param {Object} options\n */\nexport default class WebSocketPrioritizedCachedStrategy implements Strategy {\n strategy: Strategy;\n transports: TransportStrategyDictionary;\n ttl: number;\n usingTLS: boolean;\n timeline: Timeline;\n\n constructor(\n strategy: Strategy,\n transports: TransportStrategyDictionary,\n options: StrategyOptions\n ) {\n this.strategy = strategy;\n this.transports = transports;\n this.ttl = options.ttl || 1800 * 1000;\n this.usingTLS = options.useTLS;\n this.timeline = options.timeline;\n }\n\n isSupported(): boolean {\n return this.strategy.isSupported();\n }\n\n connect(minPriority: number, callback: Function) {\n var usingTLS = this.usingTLS;\n var info = fetchTransportCache(usingTLS);\n var cacheSkipCount = info && info.cacheSkipCount ? info.cacheSkipCount : 0;\n\n var strategies = [this.strategy];\n if (info && info.timestamp + this.ttl >= Util.now()) {\n var transport = this.transports[info.transport];\n if (transport) {\n if (['ws', 'wss'].includes(info.transport) || cacheSkipCount > 3) {\n this.timeline.info({\n cached: true,\n transport: info.transport,\n latency: info.latency\n });\n strategies.push(\n new SequentialStrategy([transport], {\n timeout: info.latency * 2 + 1000,\n failFast: true\n })\n );\n } else {\n cacheSkipCount++;\n }\n }\n }\n\n var startTimestamp = Util.now();\n var runner = strategies\n .pop()\n .connect(minPriority, function cb(error, handshake) {\n if (error) {\n flushTransportCache(usingTLS);\n if (strategies.length > 0) {\n startTimestamp = Util.now();\n runner = strategies.pop().connect(minPriority, cb);\n } else {\n callback(error);\n }\n } else {\n storeTransportCache(\n usingTLS,\n handshake.transport.name,\n Util.now() - startTimestamp,\n cacheSkipCount\n );\n callback(null, handshake);\n }\n });\n\n return {\n abort: function() {\n runner.abort();\n },\n forceMinPriority: function(p) {\n minPriority = p;\n if (runner) {\n runner.forceMinPriority(p);\n }\n }\n };\n }\n}\n\nfunction getTransportCacheKey(usingTLS: boolean): string {\n return 'pusherTransport' + (usingTLS ? 'TLS' : 'NonTLS');\n}\n\nfunction fetchTransportCache(usingTLS: boolean): any {\n var storage = Runtime.getLocalStorage();\n if (storage) {\n try {\n var serializedCache = storage[getTransportCacheKey(usingTLS)];\n if (serializedCache) {\n return JSON.parse(serializedCache);\n }\n } catch (e) {\n flushTransportCache(usingTLS);\n }\n }\n return null;\n}\n\nfunction storeTransportCache(\n usingTLS: boolean,\n transport: TransportStrategy,\n latency: number,\n cacheSkipCount: number\n) {\n var storage = Runtime.getLocalStorage();\n if (storage) {\n try {\n storage[getTransportCacheKey(usingTLS)] = Collections.safeJSONStringify({\n timestamp: Util.now(),\n transport: transport,\n latency: latency,\n cacheSkipCount: cacheSkipCount\n });\n } catch (e) {\n // catch over quota exceptions raised by localStorage\n }\n }\n}\n\nfunction flushTransportCache(usingTLS: boolean) {\n var storage = Runtime.getLocalStorage();\n if (storage) {\n try {\n delete storage[getTransportCacheKey(usingTLS)];\n } catch (e) {\n // catch exceptions raised by localStorage\n }\n }\n}\n","import { OneOffTimer as Timer } from '../utils/timers';\nimport Strategy from './strategy';\nimport StrategyOptions from './strategy_options';\n\n/** Runs substrategy after specified delay.\n *\n * Options:\n * - delay - time in miliseconds to delay the substrategy attempt\n *\n * @param {Strategy} strategy\n * @param {Object} options\n */\nexport default class DelayedStrategy implements Strategy {\n strategy: Strategy;\n options: { delay: number };\n\n constructor(strategy: Strategy, { delay: number }) {\n this.strategy = strategy;\n this.options = { delay: number };\n }\n\n isSupported(): boolean {\n return this.strategy.isSupported();\n }\n\n connect(minPriority: number, callback: Function) {\n var strategy = this.strategy;\n var runner;\n var timer = new Timer(this.options.delay, function() {\n runner = strategy.connect(minPriority, callback);\n });\n\n return {\n abort: function() {\n timer.ensureAborted();\n if (runner) {\n runner.abort();\n }\n },\n forceMinPriority: function(p) {\n minPriority = p;\n if (runner) {\n runner.forceMinPriority(p);\n }\n }\n };\n }\n}\n","import Strategy from './strategy';\nimport StrategyRunner from './strategy_runner';\n\n/** Proxies method calls to one of substrategies basing on the test function.\n *\n * @param {Function} test\n * @param {Strategy} trueBranch strategy used when test returns true\n * @param {Strategy} falseBranch strategy used when test returns false\n */\nexport default class IfStrategy implements Strategy {\n test: () => boolean;\n trueBranch: Strategy;\n falseBranch: Strategy;\n\n constructor(\n test: () => boolean,\n trueBranch: Strategy,\n falseBranch: Strategy\n ) {\n this.test = test;\n this.trueBranch = trueBranch;\n this.falseBranch = falseBranch;\n }\n\n isSupported(): boolean {\n var branch = this.test() ? this.trueBranch : this.falseBranch;\n return branch.isSupported();\n }\n\n connect(minPriority: number, callback: Function): StrategyRunner {\n var branch = this.test() ? this.trueBranch : this.falseBranch;\n return branch.connect(minPriority, callback);\n }\n}\n","import Strategy from './strategy';\nimport StrategyRunner from './strategy_runner';\n\n/** Launches the substrategy and terminates on the first open connection.\n *\n * @param {Strategy} strategy\n */\nexport default class FirstConnectedStrategy implements Strategy {\n strategy: Strategy;\n\n constructor(strategy: Strategy) {\n this.strategy = strategy;\n }\n\n isSupported(): boolean {\n return this.strategy.isSupported();\n }\n\n connect(minPriority: number, callback: Function): StrategyRunner {\n var runner = this.strategy.connect(minPriority, function(error, handshake) {\n if (handshake) {\n runner.abort();\n }\n callback(error, handshake);\n });\n return runner;\n }\n}\n","import * as Collections from 'core/utils/collections';\nimport TransportManager from 'core/transports/transport_manager';\nimport Strategy from 'core/strategies/strategy';\nimport StrategyOptions from 'core/strategies/strategy_options';\nimport SequentialStrategy from 'core/strategies/sequential_strategy';\nimport BestConnectedEverStrategy from 'core/strategies/best_connected_ever_strategy';\nimport WebSocketPrioritizedCachedStrategy, {\n TransportStrategyDictionary\n} from 'core/strategies/websocket_prioritized_cached_strategy';\nimport DelayedStrategy from 'core/strategies/delayed_strategy';\nimport IfStrategy from 'core/strategies/if_strategy';\nimport FirstConnectedStrategy from 'core/strategies/first_connected_strategy';\nimport { Config } from 'core/config';\n\nfunction testSupportsStrategy(strategy: Strategy) {\n return function() {\n return strategy.isSupported();\n };\n}\n\nvar getDefaultStrategy = function(\n config: Config,\n baseOptions: StrategyOptions,\n defineTransport: Function\n): Strategy {\n var definedTransports = {};\n\n function defineTransportStrategy(\n name: string,\n type: string,\n priority: number,\n options: StrategyOptions,\n manager?: TransportManager\n ) {\n var transport = defineTransport(\n config,\n name,\n type,\n priority,\n options,\n manager\n );\n\n definedTransports[name] = transport;\n\n return transport;\n }\n\n var ws_options: StrategyOptions = Object.assign({}, baseOptions, {\n hostNonTLS: config.wsHost + ':' + config.wsPort,\n hostTLS: config.wsHost + ':' + config.wssPort,\n httpPath: config.wsPath\n });\n var wss_options: StrategyOptions = Object.assign({}, ws_options, {\n useTLS: true\n });\n var sockjs_options: StrategyOptions = Object.assign({}, baseOptions, {\n hostNonTLS: config.httpHost + ':' + config.httpPort,\n hostTLS: config.httpHost + ':' + config.httpsPort,\n httpPath: config.httpPath\n });\n\n var timeouts = {\n loop: true,\n timeout: 15000,\n timeoutLimit: 60000\n };\n\n var ws_manager = new TransportManager({\n minPingDelay: 10000,\n maxPingDelay: config.activityTimeout\n });\n var streaming_manager = new TransportManager({\n lives: 2,\n minPingDelay: 10000,\n maxPingDelay: config.activityTimeout\n });\n\n var ws_transport = defineTransportStrategy(\n 'ws',\n 'ws',\n 3,\n ws_options,\n ws_manager\n );\n var wss_transport = defineTransportStrategy(\n 'wss',\n 'ws',\n 3,\n wss_options,\n ws_manager\n );\n var sockjs_transport = defineTransportStrategy(\n 'sockjs',\n 'sockjs',\n 1,\n sockjs_options\n );\n var xhr_streaming_transport = defineTransportStrategy(\n 'xhr_streaming',\n 'xhr_streaming',\n 1,\n sockjs_options,\n streaming_manager\n );\n var xdr_streaming_transport = defineTransportStrategy(\n 'xdr_streaming',\n 'xdr_streaming',\n 1,\n sockjs_options,\n streaming_manager\n );\n var xhr_polling_transport = defineTransportStrategy(\n 'xhr_polling',\n 'xhr_polling',\n 1,\n sockjs_options\n );\n var xdr_polling_transport = defineTransportStrategy(\n 'xdr_polling',\n 'xdr_polling',\n 1,\n sockjs_options\n );\n\n var ws_loop = new SequentialStrategy([ws_transport], timeouts);\n var wss_loop = new SequentialStrategy([wss_transport], timeouts);\n var sockjs_loop = new SequentialStrategy([sockjs_transport], timeouts);\n var streaming_loop = new SequentialStrategy(\n [\n new IfStrategy(\n testSupportsStrategy(xhr_streaming_transport),\n xhr_streaming_transport,\n xdr_streaming_transport\n )\n ],\n timeouts\n );\n var polling_loop = new SequentialStrategy(\n [\n new IfStrategy(\n testSupportsStrategy(xhr_polling_transport),\n xhr_polling_transport,\n xdr_polling_transport\n )\n ],\n timeouts\n );\n\n var http_loop = new SequentialStrategy(\n [\n new IfStrategy(\n testSupportsStrategy(streaming_loop),\n new BestConnectedEverStrategy([\n streaming_loop,\n new DelayedStrategy(polling_loop, { delay: 4000 })\n ]),\n polling_loop\n )\n ],\n timeouts\n );\n\n var http_fallback_loop = new IfStrategy(\n testSupportsStrategy(http_loop),\n http_loop,\n sockjs_loop\n );\n\n var wsStrategy;\n if (baseOptions.useTLS) {\n wsStrategy = new BestConnectedEverStrategy([\n ws_loop,\n new DelayedStrategy(http_fallback_loop, { delay: 2000 })\n ]);\n } else {\n wsStrategy = new BestConnectedEverStrategy([\n ws_loop,\n new DelayedStrategy(wss_loop, { delay: 2000 }),\n new DelayedStrategy(http_fallback_loop, { delay: 5000 })\n ]);\n }\n\n return new WebSocketPrioritizedCachedStrategy(\n new FirstConnectedStrategy(\n new IfStrategy(\n testSupportsStrategy(ws_transport),\n wsStrategy,\n http_fallback_loop\n )\n ),\n definedTransports,\n {\n ttl: 1800000,\n timeline: baseOptions.timeline,\n useTLS: baseOptions.useTLS\n }\n );\n};\n\nexport default getDefaultStrategy;\n","import { Dependencies } from '../dom/dependencies';\n\n/** Initializes the transport.\n *\n * Fetches resources if needed and then transitions to initialized.\n */\nexport default function() {\n var self = this;\n\n self.timeline.info(\n self.buildTimelineMessage({\n transport: self.name + (self.options.useTLS ? 's' : '')\n })\n );\n\n if (self.hooks.isInitialized()) {\n self.changeState('initialized');\n } else if (self.hooks.file) {\n self.changeState('initializing');\n Dependencies.load(\n self.hooks.file,\n { useTLS: self.options.useTLS },\n function(error, callback) {\n if (self.hooks.isInitialized()) {\n self.changeState('initialized');\n callback(true);\n } else {\n if (error) {\n self.onError(error);\n }\n self.onClose();\n callback(false);\n }\n }\n );\n } else {\n self.onClose();\n }\n}\n","import HTTPRequest from 'core/http/http_request';\nimport RequestHooks from 'core/http/request_hooks';\nimport Ajax from 'core/http/ajax';\nimport * as Errors from 'core/errors';\n\nvar hooks: RequestHooks = {\n getRequest: function(socket: HTTPRequest): Ajax {\n var xdr = new (window).XDomainRequest();\n xdr.ontimeout = function() {\n socket.emit('error', new Errors.RequestTimedOut());\n socket.close();\n };\n xdr.onerror = function(e) {\n socket.emit('error', e);\n socket.close();\n };\n xdr.onprogress = function() {\n if (xdr.responseText && xdr.responseText.length > 0) {\n socket.onChunk(200, xdr.responseText);\n }\n };\n xdr.onload = function() {\n if (xdr.responseText && xdr.responseText.length > 0) {\n socket.onChunk(200, xdr.responseText);\n }\n socket.emit('finished', 200);\n socket.close();\n };\n return xdr;\n },\n abortRequest: function(xdr: Ajax) {\n xdr.ontimeout = xdr.onerror = xdr.onprogress = xdr.onload = null;\n xdr.abort();\n }\n};\n\nexport default hooks;\n","import Runtime from 'runtime';\nimport RequestHooks from './request_hooks';\nimport Ajax from './ajax';\nimport { default as EventsDispatcher } from '../events/dispatcher';\n\nconst MAX_BUFFER_LENGTH = 256 * 1024;\n\nexport default class HTTPRequest extends EventsDispatcher {\n hooks: RequestHooks;\n method: string;\n url: string;\n position: number;\n xhr: Ajax;\n unloader: Function;\n\n constructor(hooks: RequestHooks, method: string, url: string) {\n super();\n this.hooks = hooks;\n this.method = method;\n this.url = url;\n }\n\n start(payload?: any) {\n this.position = 0;\n this.xhr = this.hooks.getRequest(this);\n\n this.unloader = () => {\n this.close();\n };\n Runtime.addUnloadListener(this.unloader);\n\n this.xhr.open(this.method, this.url, true);\n\n if (this.xhr.setRequestHeader) {\n this.xhr.setRequestHeader('Content-Type', 'application/json'); // ReactNative doesn't set this header by default.\n }\n this.xhr.send(payload);\n }\n\n close() {\n if (this.unloader) {\n Runtime.removeUnloadListener(this.unloader);\n this.unloader = null;\n }\n if (this.xhr) {\n this.hooks.abortRequest(this.xhr);\n this.xhr = null;\n }\n }\n\n onChunk(status: number, data: any) {\n while (true) {\n var chunk = this.advanceBuffer(data);\n if (chunk) {\n this.emit('chunk', { status: status, data: chunk });\n } else {\n break;\n }\n }\n if (this.isBufferTooLong(data)) {\n this.emit('buffer_too_long');\n }\n }\n\n private advanceBuffer(buffer: any[]): any {\n var unreadData = buffer.slice(this.position);\n var endOfLinePosition = unreadData.indexOf('\\n');\n\n if (endOfLinePosition !== -1) {\n this.position += endOfLinePosition + 1;\n return unreadData.slice(0, endOfLinePosition);\n } else {\n // chunk is not finished yet, don't move the buffer pointer\n return null;\n }\n }\n\n private isBufferTooLong(buffer: any): boolean {\n return this.position === buffer.length && buffer.length > MAX_BUFFER_LENGTH;\n }\n}\n","enum State {\n CONNECTING = 0,\n OPEN = 1,\n CLOSED = 3\n}\n\nexport default State;\n","import URLLocation from './url_location';\nimport State from './state';\nimport Socket from '../socket';\nimport SocketHooks from './socket_hooks';\nimport Util from '../util';\nimport Ajax from './ajax';\nimport HTTPRequest from './http_request';\nimport Runtime from 'runtime';\n\nvar autoIncrement = 1;\n\nclass HTTPSocket implements Socket {\n hooks: SocketHooks;\n session: string;\n location: URLLocation;\n readyState: State;\n stream: HTTPRequest;\n\n onopen: () => void;\n onerror: (error: any) => void;\n onclose: (closeEvent: any) => void;\n onmessage: (message: any) => void;\n onactivity: () => void;\n\n constructor(hooks: SocketHooks, url: string) {\n this.hooks = hooks;\n this.session = randomNumber(1000) + '/' + randomString(8);\n this.location = getLocation(url);\n this.readyState = State.CONNECTING;\n this.openStream();\n }\n\n send(payload: any) {\n return this.sendRaw(JSON.stringify([payload]));\n }\n\n ping() {\n this.hooks.sendHeartbeat(this);\n }\n\n close(code: any, reason: any) {\n this.onClose(code, reason, true);\n }\n\n /** For internal use only */\n sendRaw(payload: any): boolean {\n if (this.readyState === State.OPEN) {\n try {\n Runtime.createSocketRequest(\n 'POST',\n getUniqueURL(getSendURL(this.location, this.session))\n ).start(payload);\n return true;\n } catch (e) {\n return false;\n }\n } else {\n return false;\n }\n }\n\n /** For internal use only */\n reconnect() {\n this.closeStream();\n this.openStream();\n }\n\n /** For internal use only */\n onClose(code, reason, wasClean) {\n this.closeStream();\n this.readyState = State.CLOSED;\n if (this.onclose) {\n this.onclose({\n code: code,\n reason: reason,\n wasClean: wasClean\n });\n }\n }\n\n private onChunk(chunk) {\n if (chunk.status !== 200) {\n return;\n }\n if (this.readyState === State.OPEN) {\n this.onActivity();\n }\n\n var payload;\n var type = chunk.data.slice(0, 1);\n switch (type) {\n case 'o':\n payload = JSON.parse(chunk.data.slice(1) || '{}');\n this.onOpen(payload);\n break;\n case 'a':\n payload = JSON.parse(chunk.data.slice(1) || '[]');\n for (var i = 0; i < payload.length; i++) {\n this.onEvent(payload[i]);\n }\n break;\n case 'm':\n payload = JSON.parse(chunk.data.slice(1) || 'null');\n this.onEvent(payload);\n break;\n case 'h':\n this.hooks.onHeartbeat(this);\n break;\n case 'c':\n payload = JSON.parse(chunk.data.slice(1) || '[]');\n this.onClose(payload[0], payload[1], true);\n break;\n }\n }\n\n private onOpen(options) {\n if (this.readyState === State.CONNECTING) {\n if (options && options.hostname) {\n this.location.base = replaceHost(this.location.base, options.hostname);\n }\n this.readyState = State.OPEN;\n\n if (this.onopen) {\n this.onopen();\n }\n } else {\n this.onClose(1006, 'Server lost session', true);\n }\n }\n\n private onEvent(event) {\n if (this.readyState === State.OPEN && this.onmessage) {\n this.onmessage({ data: event });\n }\n }\n\n private onActivity() {\n if (this.onactivity) {\n this.onactivity();\n }\n }\n\n private onError(error) {\n if (this.onerror) {\n this.onerror(error);\n }\n }\n\n private openStream() {\n this.stream = Runtime.createSocketRequest(\n 'POST',\n getUniqueURL(this.hooks.getReceiveURL(this.location, this.session))\n );\n\n this.stream.bind('chunk', chunk => {\n this.onChunk(chunk);\n });\n this.stream.bind('finished', status => {\n this.hooks.onFinished(this, status);\n });\n this.stream.bind('buffer_too_long', () => {\n this.reconnect();\n });\n\n try {\n this.stream.start();\n } catch (error) {\n Util.defer(() => {\n this.onError(error);\n this.onClose(1006, 'Could not start streaming', false);\n });\n }\n }\n\n private closeStream() {\n if (this.stream) {\n this.stream.unbind_all();\n this.stream.close();\n this.stream = null;\n }\n }\n}\n\nfunction getLocation(url): URLLocation {\n var parts = /([^\\?]*)\\/*(\\??.*)/.exec(url);\n return {\n base: parts[1],\n queryString: parts[2]\n };\n}\n\nfunction getSendURL(url: URLLocation, session: string): string {\n return url.base + '/' + session + '/xhr_send';\n}\n\nfunction getUniqueURL(url: string): string {\n var separator = url.indexOf('?') === -1 ? '?' : '&';\n return url + separator + 't=' + +new Date() + '&n=' + autoIncrement++;\n}\n\nfunction replaceHost(url: string, hostname: string): string {\n var urlParts = /(https?:\\/\\/)([^\\/:]+)((\\/|:)?.*)/.exec(url);\n return urlParts[1] + hostname + urlParts[3];\n}\n\nfunction randomNumber(max: number): number {\n return Runtime.randomInt(max);\n}\n\nfunction randomString(length: number): string {\n var result = [];\n\n for (var i = 0; i < length; i++) {\n result.push(randomNumber(32).toString(32));\n }\n\n return result.join('');\n}\n\nexport default HTTPSocket;\n","import SocketHooks from './socket_hooks';\nimport HTTPSocket from './http_socket';\n\nvar hooks: SocketHooks = {\n getReceiveURL: function(url, session) {\n return url.base + '/' + session + '/xhr_streaming' + url.queryString;\n },\n onHeartbeat: function(socket) {\n socket.sendRaw('[]');\n },\n sendHeartbeat: function(socket) {\n socket.sendRaw('[]');\n },\n onFinished: function(socket, status) {\n socket.onClose(1006, 'Connection interrupted (' + status + ')', false);\n }\n};\n\nexport default hooks;\n","import SocketHooks from './socket_hooks';\nimport URLLocation from './url_location';\nimport HTTPSocket from './http_socket';\n\nvar hooks: SocketHooks = {\n getReceiveURL: function(url: URLLocation, session: string): string {\n return url.base + '/' + session + '/xhr' + url.queryString;\n },\n onHeartbeat: function() {\n // next HTTP request will reset server's activity timer\n },\n sendHeartbeat: function(socket) {\n socket.sendRaw('[]');\n },\n onFinished: function(socket, status) {\n if (status === 200) {\n socket.reconnect();\n } else {\n socket.onClose(1006, 'Connection interrupted (' + status + ')', false);\n }\n }\n};\n\nexport default hooks;\n","import HTTPRequest from 'core/http/http_request';\nimport RequestHooks from 'core/http/request_hooks';\nimport Ajax from 'core/http/ajax';\nimport Runtime from 'runtime';\n\nvar hooks: RequestHooks = {\n getRequest: function(socket: HTTPRequest): Ajax {\n var Constructor = Runtime.getXHRAPI();\n var xhr = new Constructor();\n xhr.onreadystatechange = xhr.onprogress = function() {\n switch (xhr.readyState) {\n case 3:\n if (xhr.responseText && xhr.responseText.length > 0) {\n socket.onChunk(xhr.status, xhr.responseText);\n }\n break;\n case 4:\n // this happens only on errors, never after calling close\n if (xhr.responseText && xhr.responseText.length > 0) {\n socket.onChunk(xhr.status, xhr.responseText);\n }\n socket.emit('finished', xhr.status);\n socket.close();\n break;\n }\n };\n return xhr;\n },\n abortRequest: function(xhr: Ajax) {\n xhr.onreadystatechange = null;\n xhr.abort();\n }\n};\n\nexport default hooks;\n","import HTTPRequest from 'core/http/http_request';\nimport HTTPSocket from 'core/http/http_socket';\nimport SocketHooks from 'core/http/socket_hooks';\nimport RequestHooks from 'core/http/request_hooks';\nimport streamingHooks from 'core/http/http_streaming_socket';\nimport pollingHooks from 'core/http/http_polling_socket';\nimport xhrHooks from './http_xhr_request';\nimport HTTPFactory from 'core/http/http_factory';\n\nvar HTTP: HTTPFactory = {\n createStreamingSocket(url: string): HTTPSocket {\n return this.createSocket(streamingHooks, url);\n },\n\n createPollingSocket(url: string): HTTPSocket {\n return this.createSocket(pollingHooks, url);\n },\n\n createSocket(hooks: SocketHooks, url: string): HTTPSocket {\n return new HTTPSocket(hooks, url);\n },\n\n createXHR(method: string, url: string): HTTPRequest {\n return this.createRequest(xhrHooks, method, url);\n },\n\n createRequest(hooks: RequestHooks, method: string, url: string): HTTPRequest {\n return new HTTPRequest(hooks, method, url);\n }\n};\n\nexport default HTTP;\n","import xdrHooks from './http_xdomain_request';\nimport HTTP from 'isomorphic/http/http';\n\nHTTP.createXDR = function(method, url) {\n return this.createRequest(xdrHooks, method, url);\n};\n\nexport default HTTP;\n","import Browser from './browser';\nimport { Dependencies, DependenciesReceivers } from './dom/dependencies';\nimport { AuthTransport, AuthTransports } from 'core/auth/auth_transports';\nimport xhrAuth from 'isomorphic/auth/xhr_auth';\nimport jsonpAuth from './auth/jsonp_auth';\nimport TimelineTransport from 'core/timeline/timeline_transport';\nimport TimelineSender from 'core/timeline/timeline_sender';\nimport ScriptRequest from './dom/script_request';\nimport JSONPRequest from './dom/jsonp_request';\nimport * as Collections from 'core/utils/collections';\nimport { ScriptReceivers } from './dom/script_receiver_factory';\nimport jsonpTimeline from './timeline/jsonp_timeline';\nimport Transports from './transports/transports';\nimport Ajax from 'core/http/ajax';\nimport { Network } from './net_info';\nimport getDefaultStrategy from './default_strategy';\nimport transportConnectionInitializer from './transports/transport_connection_initializer';\nimport HTTPFactory from './http/http';\nimport HTTPRequest from 'core/http/http_request';\n\nvar Runtime: Browser = {\n // for jsonp auth\n nextAuthCallbackID: 1,\n auth_callbacks: {},\n ScriptReceivers,\n DependenciesReceivers,\n getDefaultStrategy,\n Transports,\n transportConnectionInitializer,\n HTTPFactory,\n\n TimelineTransport: jsonpTimeline,\n\n getXHRAPI() {\n return window.XMLHttpRequest;\n },\n\n getWebSocketAPI() {\n return window.WebSocket || window.MozWebSocket;\n },\n\n setup(PusherClass): void {\n (window).Pusher = PusherClass; // JSONp requires Pusher to be in the global scope.\n var initializeOnDocumentBody = () => {\n this.onDocumentBody(PusherClass.ready);\n };\n if (!(window).JSON) {\n Dependencies.load('json2', {}, initializeOnDocumentBody);\n } else {\n initializeOnDocumentBody();\n }\n },\n\n getDocument(): Document {\n return document;\n },\n\n getProtocol(): string {\n return this.getDocument().location.protocol;\n },\n\n getAuthorizers(): AuthTransports {\n return { ajax: xhrAuth, jsonp: jsonpAuth };\n },\n\n onDocumentBody(callback: Function) {\n if (document.body) {\n callback();\n } else {\n setTimeout(() => {\n this.onDocumentBody(callback);\n }, 0);\n }\n },\n\n createJSONPRequest(url: string, data: any): JSONPRequest {\n return new JSONPRequest(url, data);\n },\n\n createScriptRequest(src: string): ScriptRequest {\n return new ScriptRequest(src);\n },\n\n getLocalStorage() {\n try {\n return window.localStorage;\n } catch (e) {\n return undefined;\n }\n },\n\n createXHR(): Ajax {\n if (this.getXHRAPI()) {\n return this.createXMLHttpRequest();\n } else {\n return this.createMicrosoftXHR();\n }\n },\n\n createXMLHttpRequest(): Ajax {\n var Constructor = this.getXHRAPI();\n return new Constructor();\n },\n\n createMicrosoftXHR(): Ajax {\n return new ActiveXObject('Microsoft.XMLHTTP');\n },\n\n getNetwork() {\n return Network;\n },\n\n createWebSocket(url: string): any {\n var Constructor = this.getWebSocketAPI();\n return new Constructor(url);\n },\n\n createSocketRequest(method: string, url: string): HTTPRequest {\n if (this.isXHRSupported()) {\n return this.HTTPFactory.createXHR(method, url);\n } else if (this.isXDRSupported(url.indexOf('https:') === 0)) {\n return this.HTTPFactory.createXDR(method, url);\n } else {\n throw 'Cross-origin HTTP requests are not supported';\n }\n },\n\n isXHRSupported(): boolean {\n var Constructor = this.getXHRAPI();\n return (\n Boolean(Constructor) && new Constructor().withCredentials !== undefined\n );\n },\n\n isXDRSupported(useTLS?: boolean): boolean {\n var protocol = useTLS ? 'https:' : 'http:';\n var documentProtocol = this.getProtocol();\n return (\n Boolean(window['XDomainRequest']) && documentProtocol === protocol\n );\n },\n\n addUnloadListener(listener: any) {\n if (window.addEventListener !== undefined) {\n window.addEventListener('unload', listener, false);\n } else if (window.attachEvent !== undefined) {\n window.attachEvent('onunload', listener);\n }\n },\n\n removeUnloadListener(listener: any) {\n if (window.addEventListener !== undefined) {\n window.removeEventListener('unload', listener, false);\n } else if (window.detachEvent !== undefined) {\n window.detachEvent('onunload', listener);\n }\n },\n\n randomInt(max: number): number {\n /**\n * Return values in the range of [0, 1[\n */\n const random = function() {\n const crypto = window.crypto || window['msCrypto'];\n const random = crypto.getRandomValues(new Uint32Array(1))[0];\n\n return random / 2 ** 32;\n };\n\n return Math.floor(random() * max);\n }\n};\n\nexport default Runtime;\n","enum TimelineLevel {\n ERROR = 3,\n INFO = 6,\n DEBUG = 7\n}\n\nexport default TimelineLevel;\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport { default as Level } from './level';\n\nexport interface TimelineOptions {\n level?: Level;\n limit?: number;\n version?: string;\n cluster?: string;\n features?: string[];\n params?: any;\n}\n\nexport default class Timeline {\n key: string;\n session: number;\n events: any[];\n options: TimelineOptions;\n sent: number;\n uniqueID: number;\n\n constructor(key: string, session: number, options: TimelineOptions) {\n this.key = key;\n this.session = session;\n this.events = [];\n this.options = options || {};\n this.sent = 0;\n this.uniqueID = 0;\n }\n\n log(level, event) {\n if (level <= this.options.level) {\n this.events.push(\n Collections.extend({}, event, { timestamp: Util.now() })\n );\n if (this.options.limit && this.events.length > this.options.limit) {\n this.events.shift();\n }\n }\n }\n\n error(event) {\n this.log(Level.ERROR, event);\n }\n\n info(event) {\n this.log(Level.INFO, event);\n }\n\n debug(event) {\n this.log(Level.DEBUG, event);\n }\n\n isEmpty() {\n return this.events.length === 0;\n }\n\n send(sendfn, callback) {\n var data = Collections.extend(\n {\n session: this.session,\n bundle: this.sent + 1,\n key: this.key,\n lib: 'js',\n version: this.options.version,\n cluster: this.options.cluster,\n features: this.options.features,\n timeline: this.events\n },\n this.options.params\n );\n\n this.events = [];\n sendfn(data, (error, result) => {\n if (!error) {\n this.sent++;\n }\n if (callback) {\n callback(error, result);\n }\n });\n\n return true;\n }\n\n generateUniqueID(): number {\n this.uniqueID++;\n return this.uniqueID;\n }\n}\n","import Factory from '../utils/factory';\nimport Util from '../util';\nimport * as Errors from '../errors';\nimport * as Collections from '../utils/collections';\nimport Strategy from './strategy';\nimport Transport from '../transports/transport';\nimport StrategyOptions from './strategy_options';\nimport Handshake from '../connection/handshake';\n\n/** Provides a strategy interface for transports.\n *\n * @param {String} name\n * @param {Number} priority\n * @param {Class} transport\n * @param {Object} options\n */\nexport default class TransportStrategy implements Strategy {\n name: string;\n priority: number;\n transport: Transport;\n options: StrategyOptions;\n\n constructor(\n name: string,\n priority: number,\n transport: Transport,\n options: StrategyOptions\n ) {\n this.name = name;\n this.priority = priority;\n this.transport = transport;\n this.options = options || {};\n }\n\n /** Returns whether the transport is supported in the browser.\n *\n * @returns {Boolean}\n */\n isSupported(): boolean {\n return this.transport.isSupported({\n useTLS: this.options.useTLS\n });\n }\n\n /** Launches a connection attempt and returns a strategy runner.\n *\n * @param {Function} callback\n * @return {Object} strategy runner\n */\n connect(minPriority: number, callback: Function) {\n if (!this.isSupported()) {\n return failAttempt(new Errors.UnsupportedStrategy(), callback);\n } else if (this.priority < minPriority) {\n return failAttempt(new Errors.TransportPriorityTooLow(), callback);\n }\n\n var connected = false;\n var transport = this.transport.createConnection(\n this.name,\n this.priority,\n this.options.key,\n this.options\n );\n var handshake = null;\n\n var onInitialized = function() {\n transport.unbind('initialized', onInitialized);\n transport.connect();\n };\n var onOpen = function() {\n handshake = Factory.createHandshake(transport, function(result) {\n connected = true;\n unbindListeners();\n callback(null, result);\n });\n };\n var onError = function(error) {\n unbindListeners();\n callback(error);\n };\n var onClosed = function() {\n unbindListeners();\n var serializedTransport;\n\n // The reason for this try/catch block is that on React Native\n // the WebSocket object is circular. Therefore transport.socket will\n // throw errors upon stringification. Collections.safeJSONStringify\n // discards circular references when serializing.\n serializedTransport = Collections.safeJSONStringify(transport);\n callback(new Errors.TransportClosed(serializedTransport));\n };\n\n var unbindListeners = function() {\n transport.unbind('initialized', onInitialized);\n transport.unbind('open', onOpen);\n transport.unbind('error', onError);\n transport.unbind('closed', onClosed);\n };\n\n transport.bind('initialized', onInitialized);\n transport.bind('open', onOpen);\n transport.bind('error', onError);\n transport.bind('closed', onClosed);\n\n // connect will be called automatically after initialization\n transport.initialize();\n\n return {\n abort: () => {\n if (connected) {\n return;\n }\n unbindListeners();\n if (handshake) {\n handshake.close();\n } else {\n transport.close();\n }\n },\n forceMinPriority: p => {\n if (connected) {\n return;\n }\n if (this.priority < p) {\n if (handshake) {\n handshake.close();\n } else {\n transport.close();\n }\n }\n }\n };\n }\n}\n\nfunction failAttempt(error: Error, callback: Function) {\n Util.defer(function() {\n callback(error);\n });\n return {\n abort: function() {},\n forceMinPriority: function() {}\n };\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport TransportManager from '../transports/transport_manager';\nimport * as Errors from '../errors';\nimport Strategy from './strategy';\nimport TransportStrategy from './transport_strategy';\nimport StrategyOptions from '../strategies/strategy_options';\nimport { Config } from '../config';\nimport Runtime from 'runtime';\n\nconst { Transports } = Runtime;\n\nexport var defineTransport = function(\n config: Config,\n name: string,\n type: string,\n priority: number,\n options: StrategyOptions,\n manager?: TransportManager\n): Strategy {\n var transportClass = Transports[type];\n if (!transportClass) {\n throw new Errors.UnsupportedTransport(type);\n }\n\n var enabled =\n (!config.enabledTransports ||\n Collections.arrayIndexOf(config.enabledTransports, name) !== -1) &&\n (!config.disabledTransports ||\n Collections.arrayIndexOf(config.disabledTransports, name) === -1);\n\n var transport;\n if (enabled) {\n options = Object.assign(\n { ignoreNullOrigin: config.ignoreNullOrigin },\n options\n );\n\n transport = new TransportStrategy(\n name,\n priority,\n manager ? manager.getAssistant(transportClass) : transportClass,\n options\n );\n } else {\n transport = UnsupportedStrategy;\n }\n\n return transport;\n};\n\nvar UnsupportedStrategy: Strategy = {\n isSupported: function() {\n return false;\n },\n connect: function(_, callback) {\n var deferred = Util.defer(function() {\n callback(new Errors.UnsupportedStrategy());\n });\n return {\n abort: function() {\n deferred.ensureAborted();\n },\n forceMinPriority: function() {}\n };\n }\n};\n","import ConnectionManager from './connection/connection_manager';\nimport {\n ChannelAuthorizationOptions,\n UserAuthenticationOptions\n} from './auth/options';\nimport {\n ChannelAuthorizerGenerator,\n DeprecatedAuthOptions\n} from './auth/deprecated_channel_authorizer';\nimport { AuthTransport, Transport } from './config';\nimport * as nacl from 'tweetnacl';\nimport Logger from './logger';\n\nexport interface Options {\n activityTimeout?: number;\n\n auth?: DeprecatedAuthOptions; // DEPRECATED use channelAuthorization instead\n authEndpoint?: string; // DEPRECATED use channelAuthorization instead\n authTransport?: AuthTransport; // DEPRECATED use channelAuthorization instead\n authorizer?: ChannelAuthorizerGenerator; // DEPRECATED use channelAuthorization instead\n\n channelAuthorization?: ChannelAuthorizationOptions;\n userAuthentication?: UserAuthenticationOptions;\n\n cluster: string;\n enableStats?: boolean;\n disableStats?: boolean;\n disabledTransports?: Transport[];\n enabledTransports?: Transport[];\n forceTLS?: boolean;\n httpHost?: string;\n httpPath?: string;\n httpPort?: number;\n httpsPort?: number;\n ignoreNullOrigin?: boolean;\n nacl?: nacl;\n pongTimeout?: number;\n statsHost?: string;\n timelineParams?: any;\n unavailableTimeout?: number;\n wsHost?: string;\n wsPath?: string;\n wsPort?: number;\n wssPort?: number;\n}\n\nexport interface ClusterOptions {\n appKey: string;\n cluster: string;\n}\n\nexport function validateOptions(options) {\n if (options == null) {\n throw 'You must pass an options object';\n }\n if (options.cluster == null) {\n throw 'Options object must provide a cluster';\n }\n if ('disableStats' in options) {\n Logger.warn(\n 'The disableStats option is deprecated in favor of enableStats'\n );\n }\n}\n","import {\n UserAuthenticationCallback,\n InternalAuthOptions,\n UserAuthenticationHandler,\n UserAuthenticationRequestParams,\n AuthRequestType\n} from './options';\n\nimport Runtime from 'runtime';\n\nconst composeChannelQuery = (\n params: UserAuthenticationRequestParams,\n authOptions: InternalAuthOptions\n) => {\n var query = 'socket_id=' + encodeURIComponent(params.socketId);\n\n for (var key in authOptions.params) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(authOptions.params[key]);\n }\n\n if (authOptions.paramsProvider != null) {\n let dynamicParams = authOptions.paramsProvider();\n for (var key in dynamicParams) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(dynamicParams[key]);\n }\n }\n\n return query;\n};\n\nconst UserAuthenticator = (\n authOptions: InternalAuthOptions\n): UserAuthenticationHandler => {\n if (typeof Runtime.getAuthorizers()[authOptions.transport] === 'undefined') {\n throw `'${authOptions.transport}' is not a recognized auth transport`;\n }\n\n return (\n params: UserAuthenticationRequestParams,\n callback: UserAuthenticationCallback\n ) => {\n const query = composeChannelQuery(params, authOptions);\n\n Runtime.getAuthorizers()[authOptions.transport](\n Runtime,\n query,\n authOptions,\n AuthRequestType.UserAuthentication,\n callback\n );\n };\n};\n\nexport default UserAuthenticator;\n","import {\n AuthRequestType,\n InternalAuthOptions,\n ChannelAuthorizationHandler,\n ChannelAuthorizationRequestParams,\n ChannelAuthorizationCallback\n} from './options';\n\nimport Runtime from 'runtime';\n\nconst composeChannelQuery = (\n params: ChannelAuthorizationRequestParams,\n authOptions: InternalAuthOptions\n) => {\n var query = 'socket_id=' + encodeURIComponent(params.socketId);\n\n query += '&channel_name=' + encodeURIComponent(params.channelName);\n\n for (var key in authOptions.params) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(authOptions.params[key]);\n }\n\n if (authOptions.paramsProvider != null) {\n let dynamicParams = authOptions.paramsProvider();\n for (var key in dynamicParams) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(dynamicParams[key]);\n }\n }\n\n return query;\n};\n\nconst ChannelAuthorizer = (\n authOptions: InternalAuthOptions\n): ChannelAuthorizationHandler => {\n if (typeof Runtime.getAuthorizers()[authOptions.transport] === 'undefined') {\n throw `'${authOptions.transport}' is not a recognized auth transport`;\n }\n\n return (\n params: ChannelAuthorizationRequestParams,\n callback: ChannelAuthorizationCallback\n ) => {\n const query = composeChannelQuery(params, authOptions);\n\n Runtime.getAuthorizers()[authOptions.transport](\n Runtime,\n query,\n authOptions,\n AuthRequestType.ChannelAuthorization,\n callback\n );\n };\n};\n\nexport default ChannelAuthorizer;\n","import Channel from '../channels/channel';\nimport {\n ChannelAuthorizationCallback,\n ChannelAuthorizationHandler,\n ChannelAuthorizationRequestParams,\n InternalAuthOptions\n} from './options';\n\nexport interface DeprecatedChannelAuthorizer {\n authorize(socketId: string, callback: ChannelAuthorizationCallback): void;\n}\n\nexport interface ChannelAuthorizerGenerator {\n (\n channel: Channel,\n options: DeprecatedAuthorizerOptions\n ): DeprecatedChannelAuthorizer;\n}\n\nexport interface DeprecatedAuthOptions {\n params?: any;\n headers?: any;\n}\n\nexport interface DeprecatedAuthorizerOptions {\n authTransport: 'ajax' | 'jsonp';\n authEndpoint: string;\n auth?: DeprecatedAuthOptions;\n}\n\nexport const ChannelAuthorizerProxy = (\n pusher,\n authOptions: InternalAuthOptions,\n channelAuthorizerGenerator: ChannelAuthorizerGenerator\n): ChannelAuthorizationHandler => {\n const deprecatedAuthorizerOptions: DeprecatedAuthorizerOptions = {\n authTransport: authOptions.transport,\n authEndpoint: authOptions.endpoint,\n auth: {\n params: authOptions.params,\n headers: authOptions.headers\n }\n };\n return (\n params: ChannelAuthorizationRequestParams,\n callback: ChannelAuthorizationCallback\n ) => {\n const channel = pusher.channel(params.channelName);\n // This line creates a new channel authorizer every time.\n // In the past, this was only done once per channel and reused.\n // We can do that again if we want to keep this behavior intact.\n const channelAuthorizer: DeprecatedChannelAuthorizer = channelAuthorizerGenerator(\n channel,\n deprecatedAuthorizerOptions\n );\n channelAuthorizer.authorize(params.socketId, callback);\n };\n};\n","import { Options } from './options';\nimport Defaults from './defaults';\nimport {\n ChannelAuthorizationHandler,\n UserAuthenticationHandler,\n ChannelAuthorizationOptions\n} from './auth/options';\nimport UserAuthenticator from './auth/user_authenticator';\nimport ChannelAuthorizer from './auth/channel_authorizer';\nimport { ChannelAuthorizerProxy } from './auth/deprecated_channel_authorizer';\nimport Runtime from 'runtime';\nimport * as nacl from 'tweetnacl';\n\nexport type AuthTransport = 'ajax' | 'jsonp';\nexport type Transport =\n | 'ws'\n | 'wss'\n | 'xhr_streaming'\n | 'xhr_polling'\n | 'sockjs';\n\nexport interface Config {\n // these are all 'required' config parameters, it's not necessary for the user\n // to set them, but they have configured defaults.\n activityTimeout: number;\n enableStats: boolean;\n httpHost: string;\n httpPath: string;\n httpPort: number;\n httpsPort: number;\n pongTimeout: number;\n statsHost: string;\n unavailableTimeout: number;\n useTLS: boolean;\n wsHost: string;\n wsPath: string;\n wsPort: number;\n wssPort: number;\n userAuthenticator: UserAuthenticationHandler;\n channelAuthorizer: ChannelAuthorizationHandler;\n\n // these are all optional parameters or overrrides. The customer can set these\n // but it's not strictly necessary\n forceTLS?: boolean;\n cluster?: string;\n disabledTransports?: Transport[];\n enabledTransports?: Transport[];\n ignoreNullOrigin?: boolean;\n nacl?: nacl;\n timelineParams?: any;\n}\n\n// getConfig mainly sets the defaults for the options that are not provided\nexport function getConfig(opts: Options, pusher): Config {\n let config: Config = {\n activityTimeout: opts.activityTimeout || Defaults.activityTimeout,\n cluster: opts.cluster,\n httpPath: opts.httpPath || Defaults.httpPath,\n httpPort: opts.httpPort || Defaults.httpPort,\n httpsPort: opts.httpsPort || Defaults.httpsPort,\n pongTimeout: opts.pongTimeout || Defaults.pongTimeout,\n statsHost: opts.statsHost || Defaults.stats_host,\n unavailableTimeout: opts.unavailableTimeout || Defaults.unavailableTimeout,\n wsPath: opts.wsPath || Defaults.wsPath,\n wsPort: opts.wsPort || Defaults.wsPort,\n wssPort: opts.wssPort || Defaults.wssPort,\n\n enableStats: getEnableStatsConfig(opts),\n httpHost: getHttpHost(opts),\n useTLS: shouldUseTLS(opts),\n wsHost: getWebsocketHost(opts),\n\n userAuthenticator: buildUserAuthenticator(opts),\n channelAuthorizer: buildChannelAuthorizer(opts, pusher)\n };\n\n if ('disabledTransports' in opts)\n config.disabledTransports = opts.disabledTransports;\n if ('enabledTransports' in opts)\n config.enabledTransports = opts.enabledTransports;\n if ('ignoreNullOrigin' in opts)\n config.ignoreNullOrigin = opts.ignoreNullOrigin;\n if ('timelineParams' in opts) config.timelineParams = opts.timelineParams;\n if ('nacl' in opts) {\n config.nacl = opts.nacl;\n }\n\n return config;\n}\n\nfunction getHttpHost(opts: Options): string {\n if (opts.httpHost) {\n return opts.httpHost;\n }\n if (opts.cluster) {\n return `sockjs-${opts.cluster}.pusher.com`;\n }\n return Defaults.httpHost;\n}\n\nfunction getWebsocketHost(opts: Options): string {\n if (opts.wsHost) {\n return opts.wsHost;\n }\n return getWebsocketHostFromCluster(opts.cluster);\n}\n\nfunction getWebsocketHostFromCluster(cluster: string): string {\n return `ws-${cluster}.pusher.com`;\n}\n\nfunction shouldUseTLS(opts: Options): boolean {\n if (Runtime.getProtocol() === 'https:') {\n return true;\n } else if (opts.forceTLS === false) {\n return false;\n }\n return true;\n}\n\n// if enableStats is set take the value\n// if disableStats is set take the inverse\n// otherwise default to false\nfunction getEnableStatsConfig(opts: Options): boolean {\n if ('enableStats' in opts) {\n return opts.enableStats;\n }\n if ('disableStats' in opts) {\n return !opts.disableStats;\n }\n return false;\n}\n\nfunction buildUserAuthenticator(opts: Options): UserAuthenticationHandler {\n const userAuthentication = {\n ...Defaults.userAuthentication,\n ...opts.userAuthentication\n };\n if (\n 'customHandler' in userAuthentication &&\n userAuthentication['customHandler'] != null\n ) {\n return userAuthentication['customHandler'];\n }\n\n return UserAuthenticator(userAuthentication);\n}\n\nfunction buildChannelAuth(opts: Options, pusher): ChannelAuthorizationOptions {\n let channelAuthorization: ChannelAuthorizationOptions;\n if ('channelAuthorization' in opts) {\n channelAuthorization = {\n ...Defaults.channelAuthorization,\n ...opts.channelAuthorization\n };\n } else {\n channelAuthorization = {\n transport: opts.authTransport || Defaults.authTransport,\n endpoint: opts.authEndpoint || Defaults.authEndpoint\n };\n if ('auth' in opts) {\n if ('params' in opts.auth) channelAuthorization.params = opts.auth.params;\n if ('headers' in opts.auth)\n channelAuthorization.headers = opts.auth.headers;\n }\n if ('authorizer' in opts)\n channelAuthorization.customHandler = ChannelAuthorizerProxy(\n pusher,\n channelAuthorization,\n opts.authorizer\n );\n }\n return channelAuthorization;\n}\n\nfunction buildChannelAuthorizer(\n opts: Options,\n pusher\n): ChannelAuthorizationHandler {\n const channelAuthorization = buildChannelAuth(opts, pusher);\n if (\n 'customHandler' in channelAuthorization &&\n channelAuthorization['customHandler'] != null\n ) {\n return channelAuthorization['customHandler'];\n }\n\n return ChannelAuthorizer(channelAuthorization);\n}\n","import Logger from './logger';\nimport Pusher from './pusher';\nimport EventsDispatcher from './events/dispatcher';\n\nexport default class WatchlistFacade extends EventsDispatcher {\n private pusher: Pusher;\n\n public constructor(pusher: Pusher) {\n super(function(eventName, data) {\n Logger.debug(`No callbacks on watchlist events for ${eventName}`);\n });\n\n this.pusher = pusher;\n this.bindWatchlistInternalEvent();\n }\n\n handleEvent(pusherEvent) {\n pusherEvent.data.events.forEach(watchlistEvent => {\n this.emit(watchlistEvent.name, watchlistEvent);\n });\n }\n\n private bindWatchlistInternalEvent() {\n this.pusher.connection.bind('message', pusherEvent => {\n var eventName = pusherEvent.event;\n if (eventName === 'pusher_internal:watchlist_events') {\n this.handleEvent(pusherEvent);\n }\n });\n }\n}\n","function flatPromise() {\n let resolve, reject;\n const promise = new Promise((res, rej) => {\n resolve = res;\n reject = rej;\n });\n return { promise, resolve, reject };\n}\n\nexport default flatPromise;\n","import Pusher from './pusher';\nimport Logger from './logger';\nimport {\n UserAuthenticationData,\n UserAuthenticationCallback\n} from './auth/options';\nimport Channel from './channels/channel';\nimport WatchlistFacade from './watchlist';\nimport EventsDispatcher from './events/dispatcher';\nimport flatPromise from './utils/flat_promise';\n\nexport default class UserFacade extends EventsDispatcher {\n pusher: Pusher;\n signin_requested: boolean = false;\n user_data: any = null;\n serverToUserChannel: Channel = null;\n signinDonePromise: Promise = null;\n watchlist: WatchlistFacade;\n private _signinDoneResolve: Function = null;\n\n public constructor(pusher: Pusher) {\n super(function(eventName, data) {\n Logger.debug('No callbacks on user for ' + eventName);\n });\n this.pusher = pusher;\n this.pusher.connection.bind('state_change', ({ previous, current }) => {\n if (previous !== 'connected' && current === 'connected') {\n this._signin();\n }\n if (previous === 'connected' && current !== 'connected') {\n this._cleanup();\n this._newSigninPromiseIfNeeded();\n }\n });\n\n this.watchlist = new WatchlistFacade(pusher);\n\n this.pusher.connection.bind('message', event => {\n var eventName = event.event;\n if (eventName === 'pusher:signin_success') {\n this._onSigninSuccess(event.data);\n }\n if (\n this.serverToUserChannel &&\n this.serverToUserChannel.name === event.channel\n ) {\n this.serverToUserChannel.handleEvent(event);\n }\n });\n }\n\n public signin() {\n if (this.signin_requested) {\n return;\n }\n\n this.signin_requested = true;\n this._signin();\n }\n\n private _signin() {\n if (!this.signin_requested) {\n return;\n }\n\n this._newSigninPromiseIfNeeded();\n\n if (this.pusher.connection.state !== 'connected') {\n // Signin will be attempted when the connection is connected\n return;\n }\n\n this.pusher.config.userAuthenticator(\n {\n socketId: this.pusher.connection.socket_id\n },\n this._onAuthorize\n );\n }\n\n private _onAuthorize: UserAuthenticationCallback = (\n err,\n authData: UserAuthenticationData\n ) => {\n if (err) {\n Logger.warn(`Error during signin: ${err}`);\n this._cleanup();\n return;\n }\n\n this.pusher.send_event('pusher:signin', {\n auth: authData.auth,\n user_data: authData.user_data\n });\n\n // Later when we get pusher:singin_success event, the user will be marked as signed in\n };\n\n private _onSigninSuccess(data: any) {\n try {\n this.user_data = JSON.parse(data.user_data);\n } catch (e) {\n Logger.error(`Failed parsing user data after signin: ${data.user_data}`);\n this._cleanup();\n return;\n }\n\n if (typeof this.user_data.id !== 'string' || this.user_data.id === '') {\n Logger.error(\n `user_data doesn't contain an id. user_data: ${this.user_data}`\n );\n this._cleanup();\n return;\n }\n\n // Signin succeeded\n this._signinDoneResolve();\n this._subscribeChannels();\n }\n\n private _subscribeChannels() {\n const ensure_subscribed = channel => {\n if (channel.subscriptionPending && channel.subscriptionCancelled) {\n channel.reinstateSubscription();\n } else if (\n !channel.subscriptionPending &&\n this.pusher.connection.state === 'connected'\n ) {\n channel.subscribe();\n }\n };\n\n this.serverToUserChannel = new Channel(\n `#server-to-user-${this.user_data.id}`,\n this.pusher\n );\n this.serverToUserChannel.bind_global((eventName, data) => {\n if (\n eventName.indexOf('pusher_internal:') === 0 ||\n eventName.indexOf('pusher:') === 0\n ) {\n // ignore internal events\n return;\n }\n this.emit(eventName, data);\n });\n ensure_subscribed(this.serverToUserChannel);\n }\n\n private _cleanup() {\n this.user_data = null;\n if (this.serverToUserChannel) {\n this.serverToUserChannel.unbind_all();\n this.serverToUserChannel.disconnect();\n this.serverToUserChannel = null;\n }\n\n if (this.signin_requested) {\n // If signin is in progress and cleanup is called,\n // Mark the current signin process as done.\n this._signinDoneResolve();\n }\n }\n\n private _newSigninPromiseIfNeeded() {\n if (!this.signin_requested) {\n return;\n }\n\n // If there is a promise and it is not resolved, return without creating a new one.\n if (this.signinDonePromise && !(this.signinDonePromise as any).done) {\n return;\n }\n\n // This promise is never rejected.\n // It gets resolved when the signin process is done whether it failed or succeeded\n const { promise, resolve, reject: _ } = flatPromise();\n (promise as any).done = false;\n const setDone = () => {\n (promise as any).done = true;\n };\n promise.then(setDone).catch(setDone);\n this.signinDonePromise = promise;\n this._signinDoneResolve = resolve;\n }\n}\n","import AbstractRuntime from '../runtimes/interface';\nimport Runtime from 'runtime';\nimport * as Collections from './utils/collections';\nimport Channels from './channels/channels';\nimport Channel from './channels/channel';\nimport { default as EventsDispatcher } from './events/dispatcher';\nimport Timeline from './timeline/timeline';\nimport TimelineSender from './timeline/timeline_sender';\nimport TimelineLevel from './timeline/level';\nimport { defineTransport } from './strategies/strategy_builder';\nimport ConnectionManager from './connection/connection_manager';\nimport { PeriodicTimer } from './utils/timers';\nimport Defaults from './defaults';\nimport Logger from './logger';\nimport Factory from './utils/factory';\nimport { Options, ClusterOptions, validateOptions } from './options';\nimport { Config, getConfig } from './config';\nimport StrategyOptions from './strategies/strategy_options';\nimport UserFacade from './user';\n\nexport default class Pusher {\n /* STATIC PROPERTIES */\n static instances: Pusher[] = [];\n static isReady: boolean = false;\n static logToConsole: boolean = false;\n\n // for jsonp\n static Runtime: AbstractRuntime = Runtime;\n static ScriptReceivers: any = (Runtime).ScriptReceivers;\n static DependenciesReceivers: any = (Runtime).DependenciesReceivers;\n static auth_callbacks: any = (Runtime).auth_callbacks;\n\n static ready() {\n Pusher.isReady = true;\n for (var i = 0, l = Pusher.instances.length; i < l; i++) {\n Pusher.instances[i].connect();\n }\n }\n\n static log: (message: any) => void;\n\n private static getClientFeatures(): string[] {\n return Collections.keys(\n Collections.filterObject({ ws: Runtime.Transports.ws }, function(t) {\n return t.isSupported({});\n })\n );\n }\n\n /* INSTANCE PROPERTIES */\n key: string;\n options: Options;\n config: Config;\n channels: Channels;\n global_emitter: EventsDispatcher;\n sessionID: number;\n timeline: Timeline;\n timelineSender: TimelineSender;\n connection: ConnectionManager;\n timelineSenderTimer: PeriodicTimer;\n user: UserFacade;\n constructor(app_key: string, options: Options) {\n checkAppKey(app_key);\n validateOptions(options);\n this.key = app_key;\n this.config = getConfig(options, this);\n\n this.channels = Factory.createChannels();\n this.global_emitter = new EventsDispatcher();\n this.sessionID = Runtime.randomInt(1000000000);\n\n this.timeline = new Timeline(this.key, this.sessionID, {\n cluster: this.config.cluster,\n features: Pusher.getClientFeatures(),\n params: this.config.timelineParams || {},\n limit: 50,\n level: TimelineLevel.INFO,\n version: Defaults.VERSION\n });\n if (this.config.enableStats) {\n this.timelineSender = Factory.createTimelineSender(this.timeline, {\n host: this.config.statsHost,\n path: '/timeline/v2/' + Runtime.TimelineTransport.name\n });\n }\n\n var getStrategy = (options: StrategyOptions) => {\n return Runtime.getDefaultStrategy(this.config, options, defineTransport);\n };\n\n this.connection = Factory.createConnectionManager(this.key, {\n getStrategy: getStrategy,\n timeline: this.timeline,\n activityTimeout: this.config.activityTimeout,\n pongTimeout: this.config.pongTimeout,\n unavailableTimeout: this.config.unavailableTimeout,\n useTLS: Boolean(this.config.useTLS)\n });\n\n this.connection.bind('connected', () => {\n this.subscribeAll();\n if (this.timelineSender) {\n this.timelineSender.send(this.connection.isUsingTLS());\n }\n });\n\n this.connection.bind('message', event => {\n var eventName = event.event;\n var internal = eventName.indexOf('pusher_internal:') === 0;\n if (event.channel) {\n var channel = this.channel(event.channel);\n if (channel) {\n channel.handleEvent(event);\n }\n }\n // Emit globally [deprecated]\n if (!internal) {\n this.global_emitter.emit(event.event, event.data);\n }\n });\n this.connection.bind('connecting', () => {\n this.channels.disconnect();\n });\n this.connection.bind('disconnected', () => {\n this.channels.disconnect();\n });\n this.connection.bind('error', err => {\n Logger.warn(err);\n });\n\n Pusher.instances.push(this);\n this.timeline.info({ instances: Pusher.instances.length });\n\n this.user = new UserFacade(this);\n\n if (Pusher.isReady) {\n this.connect();\n }\n }\n\n /**\n * Allows you to switch Pusher cluster without\n * losing all the channels/subscription binding\n * as this is internally managed by the SDK.\n */\n switchCluster(options: ClusterOptions) {\n const { appKey, cluster } = options;\n this.key = appKey;\n this.options = { ...this.options, cluster };\n this.config = getConfig(this.options, this);\n this.connection.switchCluster(this.key);\n }\n\n channel(name: string): Channel {\n return this.channels.find(name);\n }\n\n allChannels(): Channel[] {\n return this.channels.all();\n }\n\n connect() {\n this.connection.connect();\n\n if (this.timelineSender) {\n if (!this.timelineSenderTimer) {\n var usingTLS = this.connection.isUsingTLS();\n var timelineSender = this.timelineSender;\n this.timelineSenderTimer = new PeriodicTimer(60000, function() {\n timelineSender.send(usingTLS);\n });\n }\n }\n }\n\n disconnect() {\n this.connection.disconnect();\n\n if (this.timelineSenderTimer) {\n this.timelineSenderTimer.ensureAborted();\n this.timelineSenderTimer = null;\n }\n }\n\n bind(event_name: string, callback: Function, context?: any): Pusher {\n this.global_emitter.bind(event_name, callback, context);\n return this;\n }\n\n unbind(event_name?: string, callback?: Function, context?: any): Pusher {\n this.global_emitter.unbind(event_name, callback, context);\n return this;\n }\n\n bind_global(callback: Function): Pusher {\n this.global_emitter.bind_global(callback);\n return this;\n }\n\n unbind_global(callback?: Function): Pusher {\n this.global_emitter.unbind_global(callback);\n return this;\n }\n\n unbind_all(callback?: Function): Pusher {\n this.global_emitter.unbind_all();\n return this;\n }\n\n subscribeAll() {\n var channelName;\n for (channelName in this.channels.channels) {\n if (this.channels.channels.hasOwnProperty(channelName)) {\n this.subscribe(channelName);\n }\n }\n }\n\n subscribe(channel_name: string) {\n var channel = this.channels.add(channel_name, this);\n if (channel.subscriptionPending && channel.subscriptionCancelled) {\n channel.reinstateSubscription();\n } else if (\n !channel.subscriptionPending &&\n this.connection.state === 'connected'\n ) {\n channel.subscribe();\n }\n return channel;\n }\n\n unsubscribe(channel_name: string) {\n var channel = this.channels.find(channel_name);\n if (channel && channel.subscriptionPending) {\n channel.cancelSubscription();\n } else {\n channel = this.channels.remove(channel_name);\n if (channel && channel.subscribed) {\n channel.unsubscribe();\n }\n }\n }\n\n send_event(event_name: string, data: any, channel?: string) {\n return this.connection.send_event(event_name, data, channel);\n }\n\n shouldUseTLS(): boolean {\n return this.config.useTLS;\n }\n\n signin() {\n this.user.signin();\n }\n}\n\nfunction checkAppKey(key) {\n if (key === null || key === undefined) {\n throw 'You must pass your app key when you instantiate Pusher.';\n }\n}\n\nRuntime.setup(Pusher);\n"],"sourceRoot":""} \ No newline at end of file +{"version":3,"sources":["webpack://Pusher/webpack/universalModuleDefinition","webpack://Pusher/webpack/bootstrap","webpack://Pusher/./node_modules/@stablelib/base64/base64.ts","webpack://Pusher/./node_modules/@stablelib/utf8/utf8.ts","webpack://Pusher/./src/core/pusher.js","webpack://Pusher/./src/runtimes/web/dom/script_receiver_factory.ts","webpack://Pusher/./src/core/defaults.ts","webpack://Pusher/./src/runtimes/web/dom/dependency_loader.ts","webpack://Pusher/./src/runtimes/web/dom/dependencies.ts","webpack://Pusher/./src/core/utils/url_store.ts","webpack://Pusher/./src/core/auth/options.ts","webpack://Pusher/./src/core/errors.ts","webpack://Pusher/./src/runtimes/isomorphic/auth/xhr_auth.ts","webpack://Pusher/./src/core/base64.ts","webpack://Pusher/./src/core/utils/timers/abstract_timer.ts","webpack://Pusher/./src/core/utils/timers/index.ts","webpack://Pusher/./src/core/util.ts","webpack://Pusher/./src/core/utils/collections.ts","webpack://Pusher/./src/core/logger.ts","webpack://Pusher/./src/runtimes/web/auth/jsonp_auth.ts","webpack://Pusher/./src/runtimes/web/dom/script_request.ts","webpack://Pusher/./src/runtimes/web/dom/jsonp_request.ts","webpack://Pusher/./src/runtimes/web/timeline/jsonp_timeline.ts","webpack://Pusher/./src/core/transports/url_schemes.ts","webpack://Pusher/./src/core/events/callback_registry.ts","webpack://Pusher/./src/core/events/dispatcher.ts","webpack://Pusher/./src/core/transports/transport_connection.ts","webpack://Pusher/./src/core/transports/transport.ts","webpack://Pusher/./src/runtimes/isomorphic/transports/transports.ts","webpack://Pusher/./src/runtimes/web/transports/transports.ts","webpack://Pusher/./src/runtimes/web/net_info.ts","webpack://Pusher/./src/core/transports/assistant_to_the_transport_manager.ts","webpack://Pusher/./src/core/connection/protocol/protocol.ts","webpack://Pusher/./src/core/connection/connection.ts","webpack://Pusher/./src/core/connection/handshake/index.ts","webpack://Pusher/./src/core/timeline/timeline_sender.ts","webpack://Pusher/./src/core/channels/channel.ts","webpack://Pusher/./src/core/channels/private_channel.ts","webpack://Pusher/./src/core/channels/members.ts","webpack://Pusher/./src/core/channels/presence_channel.ts","webpack://Pusher/./src/core/channels/encrypted_channel.ts","webpack://Pusher/./src/core/connection/connection_manager.ts","webpack://Pusher/./src/core/channels/channels.ts","webpack://Pusher/./src/core/utils/factory.ts","webpack://Pusher/./src/core/transports/transport_manager.ts","webpack://Pusher/./src/core/strategies/sequential_strategy.ts","webpack://Pusher/./src/core/strategies/best_connected_ever_strategy.ts","webpack://Pusher/./src/core/strategies/websocket_prioritized_cached_strategy.ts","webpack://Pusher/./src/core/strategies/delayed_strategy.ts","webpack://Pusher/./src/core/strategies/if_strategy.ts","webpack://Pusher/./src/core/strategies/first_connected_strategy.ts","webpack://Pusher/./src/runtimes/web/default_strategy.ts","webpack://Pusher/./src/runtimes/web/transports/transport_connection_initializer.ts","webpack://Pusher/./src/runtimes/web/http/http_xdomain_request.ts","webpack://Pusher/./src/core/http/http_request.ts","webpack://Pusher/./src/core/http/state.ts","webpack://Pusher/./src/core/http/http_socket.ts","webpack://Pusher/./src/core/http/http_streaming_socket.ts","webpack://Pusher/./src/core/http/http_polling_socket.ts","webpack://Pusher/./src/runtimes/isomorphic/http/http_xhr_request.ts","webpack://Pusher/./src/runtimes/isomorphic/http/http.ts","webpack://Pusher/./src/runtimes/web/http/http.ts","webpack://Pusher/./src/runtimes/web/runtime.ts","webpack://Pusher/./src/core/timeline/level.ts","webpack://Pusher/./src/core/timeline/timeline.ts","webpack://Pusher/./src/core/strategies/transport_strategy.ts","webpack://Pusher/./src/core/strategies/strategy_builder.ts","webpack://Pusher/./src/core/options.ts","webpack://Pusher/./src/core/auth/user_authenticator.ts","webpack://Pusher/./src/core/auth/channel_authorizer.ts","webpack://Pusher/./src/core/auth/deprecated_channel_authorizer.ts","webpack://Pusher/./src/core/config.ts","webpack://Pusher/./src/core/watchlist.ts","webpack://Pusher/./src/core/utils/flat_promise.ts","webpack://Pusher/./src/core/user.ts","webpack://Pusher/./src/core/pusher.ts"],"names":[],"mappings":";;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AACD,O;QCVA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;;QAEA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;;;QAGA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;QACA,0CAA0C,gCAAgC;QAC1E;QACA;;QAEA;QACA;QACA;QACA,wDAAwD,kBAAkB;QAC1E;QACA,iDAAiD,cAAc;QAC/D;;QAEA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA,yCAAyC,iCAAiC;QAC1E,gH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C","file":"pusher.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"Pusher\"] = factory();\n\telse\n\t\troot[\"Pusher\"] = factory();\n})(window, function() {\nreturn "," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 2);\n","// Copyright (C) 2016 Dmitry Chestnykh\n// MIT License. See LICENSE file for details.\n\n/**\n * Package base64 implements Base64 encoding and decoding.\n */\n\n// Invalid character used in decoding to indicate\n// that the character to decode is out of range of\n// alphabet and cannot be decoded.\nconst INVALID_BYTE = 256;\n\n/**\n * Implements standard Base64 encoding.\n *\n * Operates in constant time.\n */\nexport class Coder {\n // TODO(dchest): methods to encode chunk-by-chunk.\n\n constructor(private _paddingCharacter = \"=\") { }\n\n encodedLength(length: number): number {\n if (!this._paddingCharacter) {\n return (length * 8 + 5) / 6 | 0;\n }\n return (length + 2) / 3 * 4 | 0;\n }\n\n encode(data: Uint8Array): string {\n let out = \"\";\n\n let i = 0;\n for (; i < data.length - 2; i += 3) {\n let c = (data[i] << 16) | (data[i + 1] << 8) | (data[i + 2]);\n out += this._encodeByte((c >>> 3 * 6) & 63);\n out += this._encodeByte((c >>> 2 * 6) & 63);\n out += this._encodeByte((c >>> 1 * 6) & 63);\n out += this._encodeByte((c >>> 0 * 6) & 63);\n }\n\n const left = data.length - i;\n if (left > 0) {\n let c = (data[i] << 16) | (left === 2 ? data[i + 1] << 8 : 0);\n out += this._encodeByte((c >>> 3 * 6) & 63);\n out += this._encodeByte((c >>> 2 * 6) & 63);\n if (left === 2) {\n out += this._encodeByte((c >>> 1 * 6) & 63);\n } else {\n out += this._paddingCharacter || \"\";\n }\n out += this._paddingCharacter || \"\";\n }\n\n return out;\n }\n\n maxDecodedLength(length: number): number {\n if (!this._paddingCharacter) {\n return (length * 6 + 7) / 8 | 0;\n }\n return length / 4 * 3 | 0;\n }\n\n decodedLength(s: string): number {\n return this.maxDecodedLength(s.length - this._getPaddingLength(s));\n }\n\n decode(s: string): Uint8Array {\n if (s.length === 0) {\n return new Uint8Array(0);\n }\n const paddingLength = this._getPaddingLength(s);\n const length = s.length - paddingLength;\n const out = new Uint8Array(this.maxDecodedLength(length));\n let op = 0;\n let i = 0;\n let haveBad = 0;\n let v0 = 0, v1 = 0, v2 = 0, v3 = 0;\n for (; i < length - 4; i += 4) {\n v0 = this._decodeChar(s.charCodeAt(i + 0));\n v1 = this._decodeChar(s.charCodeAt(i + 1));\n v2 = this._decodeChar(s.charCodeAt(i + 2));\n v3 = this._decodeChar(s.charCodeAt(i + 3));\n out[op++] = (v0 << 2) | (v1 >>> 4);\n out[op++] = (v1 << 4) | (v2 >>> 2);\n out[op++] = (v2 << 6) | v3;\n haveBad |= v0 & INVALID_BYTE;\n haveBad |= v1 & INVALID_BYTE;\n haveBad |= v2 & INVALID_BYTE;\n haveBad |= v3 & INVALID_BYTE;\n }\n if (i < length - 1) {\n v0 = this._decodeChar(s.charCodeAt(i));\n v1 = this._decodeChar(s.charCodeAt(i + 1));\n out[op++] = (v0 << 2) | (v1 >>> 4);\n haveBad |= v0 & INVALID_BYTE;\n haveBad |= v1 & INVALID_BYTE;\n }\n if (i < length - 2) {\n v2 = this._decodeChar(s.charCodeAt(i + 2));\n out[op++] = (v1 << 4) | (v2 >>> 2);\n haveBad |= v2 & INVALID_BYTE;\n }\n if (i < length - 3) {\n v3 = this._decodeChar(s.charCodeAt(i + 3));\n out[op++] = (v2 << 6) | v3;\n haveBad |= v3 & INVALID_BYTE;\n }\n if (haveBad !== 0) {\n throw new Error(\"Base64Coder: incorrect characters for decoding\");\n }\n return out;\n }\n\n // Standard encoding have the following encoded/decoded ranges,\n // which we need to convert between.\n //\n // ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 0123456789 + /\n // Index: 0 - 25 26 - 51 52 - 61 62 63\n // ASCII: 65 - 90 97 - 122 48 - 57 43 47\n //\n\n // Encode 6 bits in b into a new character.\n protected _encodeByte(b: number): string {\n // Encoding uses constant time operations as follows:\n //\n // 1. Define comparison of A with B using (A - B) >>> 8:\n // if A > B, then result is positive integer\n // if A <= B, then result is 0\n //\n // 2. Define selection of C or 0 using bitwise AND: X & C:\n // if X == 0, then result is 0\n // if X != 0, then result is C\n //\n // 3. Start with the smallest comparison (b >= 0), which is always\n // true, so set the result to the starting ASCII value (65).\n //\n // 4. Continue comparing b to higher ASCII values, and selecting\n // zero if comparison isn't true, otherwise selecting a value\n // to add to result, which:\n //\n // a) undoes the previous addition\n // b) provides new value to add\n //\n let result = b;\n // b >= 0\n result += 65;\n // b > 25\n result += ((25 - b) >>> 8) & ((0 - 65) - 26 + 97);\n // b > 51\n result += ((51 - b) >>> 8) & ((26 - 97) - 52 + 48);\n // b > 61\n result += ((61 - b) >>> 8) & ((52 - 48) - 62 + 43);\n // b > 62\n result += ((62 - b) >>> 8) & ((62 - 43) - 63 + 47);\n\n return String.fromCharCode(result);\n }\n\n // Decode a character code into a byte.\n // Must return 256 if character is out of alphabet range.\n protected _decodeChar(c: number): number {\n // Decoding works similar to encoding: using the same comparison\n // function, but now it works on ranges: result is always incremented\n // by value, but this value becomes zero if the range is not\n // satisfied.\n //\n // Decoding starts with invalid value, 256, which is then\n // subtracted when the range is satisfied. If none of the ranges\n // apply, the function returns 256, which is then checked by\n // the caller to throw error.\n let result = INVALID_BYTE; // start with invalid character\n\n // c == 43 (c > 42 and c < 44)\n result += (((42 - c) & (c - 44)) >>> 8) & (-INVALID_BYTE + c - 43 + 62);\n // c == 47 (c > 46 and c < 48)\n result += (((46 - c) & (c - 48)) >>> 8) & (-INVALID_BYTE + c - 47 + 63);\n // c > 47 and c < 58\n result += (((47 - c) & (c - 58)) >>> 8) & (-INVALID_BYTE + c - 48 + 52);\n // c > 64 and c < 91\n result += (((64 - c) & (c - 91)) >>> 8) & (-INVALID_BYTE + c - 65 + 0);\n // c > 96 and c < 123\n result += (((96 - c) & (c - 123)) >>> 8) & (-INVALID_BYTE + c - 97 + 26);\n\n return result;\n }\n\n private _getPaddingLength(s: string): number {\n let paddingLength = 0;\n if (this._paddingCharacter) {\n for (let i = s.length - 1; i >= 0; i--) {\n if (s[i] !== this._paddingCharacter) {\n break;\n }\n paddingLength++;\n }\n if (s.length < 4 || paddingLength > 2) {\n throw new Error(\"Base64Coder: incorrect padding\");\n }\n }\n return paddingLength;\n }\n\n}\n\nconst stdCoder = new Coder();\n\nexport function encode(data: Uint8Array): string {\n return stdCoder.encode(data);\n}\n\nexport function decode(s: string): Uint8Array {\n return stdCoder.decode(s);\n}\n\n/**\n * Implements URL-safe Base64 encoding.\n * (Same as Base64, but '+' is replaced with '-', and '/' with '_').\n *\n * Operates in constant time.\n */\nexport class URLSafeCoder extends Coder {\n // URL-safe encoding have the following encoded/decoded ranges:\n //\n // ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 0123456789 - _\n // Index: 0 - 25 26 - 51 52 - 61 62 63\n // ASCII: 65 - 90 97 - 122 48 - 57 45 95\n //\n\n protected _encodeByte(b: number): string {\n let result = b;\n // b >= 0\n result += 65;\n // b > 25\n result += ((25 - b) >>> 8) & ((0 - 65) - 26 + 97);\n // b > 51\n result += ((51 - b) >>> 8) & ((26 - 97) - 52 + 48);\n // b > 61\n result += ((61 - b) >>> 8) & ((52 - 48) - 62 + 45);\n // b > 62\n result += ((62 - b) >>> 8) & ((62 - 45) - 63 + 95);\n\n return String.fromCharCode(result);\n }\n\n protected _decodeChar(c: number): number {\n let result = INVALID_BYTE;\n\n // c == 45 (c > 44 and c < 46)\n result += (((44 - c) & (c - 46)) >>> 8) & (-INVALID_BYTE + c - 45 + 62);\n // c == 95 (c > 94 and c < 96)\n result += (((94 - c) & (c - 96)) >>> 8) & (-INVALID_BYTE + c - 95 + 63);\n // c > 47 and c < 58\n result += (((47 - c) & (c - 58)) >>> 8) & (-INVALID_BYTE + c - 48 + 52);\n // c > 64 and c < 91\n result += (((64 - c) & (c - 91)) >>> 8) & (-INVALID_BYTE + c - 65 + 0);\n // c > 96 and c < 123\n result += (((96 - c) & (c - 123)) >>> 8) & (-INVALID_BYTE + c - 97 + 26);\n\n return result;\n }\n}\n\nconst urlSafeCoder = new URLSafeCoder();\n\nexport function encodeURLSafe(data: Uint8Array): string {\n return urlSafeCoder.encode(data);\n}\n\nexport function decodeURLSafe(s: string): Uint8Array {\n return urlSafeCoder.decode(s);\n}\n\n\nexport const encodedLength = (length: number) =>\n stdCoder.encodedLength(length);\n\nexport const maxDecodedLength = (length: number) =>\n stdCoder.maxDecodedLength(length);\n\nexport const decodedLength = (s: string) =>\n stdCoder.decodedLength(s);\n","// Copyright (C) 2016 Dmitry Chestnykh\n// MIT License. See LICENSE file for details.\n\n/**\n * Package utf8 implements UTF-8 encoding and decoding.\n */\n\nconst INVALID_UTF16 = \"utf8: invalid string\";\nconst INVALID_UTF8 = \"utf8: invalid source encoding\";\n\n/**\n * Encodes the given string into UTF-8 byte array.\n * Throws if the source string has invalid UTF-16 encoding.\n */\nexport function encode(s: string): Uint8Array {\n // Calculate result length and allocate output array.\n // encodedLength() also validates string and throws errors,\n // so we don't need repeat validation here.\n const arr = new Uint8Array(encodedLength(s));\n\n let pos = 0;\n for (let i = 0; i < s.length; i++) {\n let c = s.charCodeAt(i);\n if (c < 0x80) {\n arr[pos++] = c;\n } else if (c < 0x800) {\n arr[pos++] = 0xc0 | c >> 6;\n arr[pos++] = 0x80 | c & 0x3f;\n } else if (c < 0xd800) {\n arr[pos++] = 0xe0 | c >> 12;\n arr[pos++] = 0x80 | (c >> 6) & 0x3f;\n arr[pos++] = 0x80 | c & 0x3f;\n } else {\n i++; // get one more character\n c = (c & 0x3ff) << 10;\n c |= s.charCodeAt(i) & 0x3ff;\n c += 0x10000;\n\n arr[pos++] = 0xf0 | c >> 18;\n arr[pos++] = 0x80 | (c >> 12) & 0x3f;\n arr[pos++] = 0x80 | (c >> 6) & 0x3f;\n arr[pos++] = 0x80 | c & 0x3f;\n }\n }\n return arr;\n}\n\n/**\n * Returns the number of bytes required to encode the given string into UTF-8.\n * Throws if the source string has invalid UTF-16 encoding.\n */\nexport function encodedLength(s: string): number {\n let result = 0;\n for (let i = 0; i < s.length; i++) {\n const c = s.charCodeAt(i);\n if (c < 0x80) {\n result += 1;\n } else if (c < 0x800) {\n result += 2;\n } else if (c < 0xd800) {\n result += 3;\n } else if (c <= 0xdfff) {\n if (i >= s.length - 1) {\n throw new Error(INVALID_UTF16);\n }\n i++; // \"eat\" next character\n result += 4;\n } else {\n throw new Error(INVALID_UTF16);\n }\n }\n return result;\n}\n\n/**\n * Decodes the given byte array from UTF-8 into a string.\n * Throws if encoding is invalid.\n */\nexport function decode(arr: Uint8Array): string {\n const chars: string[] = [];\n for (let i = 0; i < arr.length; i++) {\n let b = arr[i];\n\n if (b & 0x80) {\n let min;\n if (b < 0xe0) {\n // Need 1 more byte.\n if (i >= arr.length) {\n throw new Error(INVALID_UTF8);\n }\n const n1 = arr[++i];\n if ((n1 & 0xc0) !== 0x80) {\n throw new Error(INVALID_UTF8);\n }\n b = (b & 0x1f) << 6 | (n1 & 0x3f);\n min = 0x80;\n } else if (b < 0xf0) {\n // Need 2 more bytes.\n if (i >= arr.length - 1) {\n throw new Error(INVALID_UTF8);\n }\n const n1 = arr[++i];\n const n2 = arr[++i];\n if ((n1 & 0xc0) !== 0x80 || (n2 & 0xc0) !== 0x80) {\n throw new Error(INVALID_UTF8);\n }\n b = (b & 0x0f) << 12 | (n1 & 0x3f) << 6 | (n2 & 0x3f);\n min = 0x800;\n } else if (b < 0xf8) {\n // Need 3 more bytes.\n if (i >= arr.length - 2) {\n throw new Error(INVALID_UTF8);\n }\n const n1 = arr[++i];\n const n2 = arr[++i];\n const n3 = arr[++i];\n if ((n1 & 0xc0) !== 0x80 || (n2 & 0xc0) !== 0x80 || (n3 & 0xc0) !== 0x80) {\n throw new Error(INVALID_UTF8);\n }\n b = (b & 0x0f) << 18 | (n1 & 0x3f) << 12 | (n2 & 0x3f) << 6 | (n3 & 0x3f);\n min = 0x10000;\n } else {\n throw new Error(INVALID_UTF8);\n }\n\n if (b < min || (b >= 0xd800 && b <= 0xdfff)) {\n throw new Error(INVALID_UTF8);\n }\n\n if (b >= 0x10000) {\n // Surrogate pair.\n if (b > 0x10ffff) {\n throw new Error(INVALID_UTF8);\n }\n b -= 0x10000;\n chars.push(String.fromCharCode(0xd800 | (b >> 10)));\n b = 0xdc00 | (b & 0x3ff);\n }\n }\n\n chars.push(String.fromCharCode(b));\n }\n return chars.join(\"\");\n}\n","// required so we don't have to do require('pusher').default etc.\nmodule.exports = require('./pusher').default;\n","import ScriptReceiver from './script_receiver';\n\n/** Builds receivers for JSONP and Script requests.\n *\n * Each receiver is an object with following fields:\n * - number - unique (for the factory instance), numerical id of the receiver\n * - id - a string ID that can be used in DOM attributes\n * - name - name of the function triggering the receiver\n * - callback - callback function\n *\n * Receivers are triggered only once, on the first callback call.\n *\n * Receivers can be called by their name or by accessing factory object\n * by the number key.\n *\n * @param {String} prefix the prefix used in ids\n * @param {String} name the name of the object\n */\nexport class ScriptReceiverFactory {\n lastId: number;\n prefix: string;\n name: string;\n\n constructor(prefix: string, name: string) {\n this.lastId = 0;\n this.prefix = prefix;\n this.name = name;\n }\n\n create(callback: Function): ScriptReceiver {\n this.lastId++;\n\n var number = this.lastId;\n var id = this.prefix + number;\n var name = this.name + '[' + number + ']';\n\n var called = false;\n var callbackWrapper = function() {\n if (!called) {\n callback.apply(null, arguments);\n called = true;\n }\n };\n\n this[number] = callbackWrapper;\n return { number: number, id: id, name: name, callback: callbackWrapper };\n }\n\n remove(receiver: ScriptReceiver) {\n delete this[receiver.number];\n }\n}\n\nexport var ScriptReceivers = new ScriptReceiverFactory(\n '_pusher_script_',\n 'Pusher.ScriptReceivers'\n);\n","import {\n ChannelAuthorizationOptions,\n UserAuthenticationOptions\n} from './auth/options';\nimport { AuthTransport } from './config';\n\nexport interface DefaultConfig {\n VERSION: string;\n PROTOCOL: number;\n wsPort: number;\n wssPort: number;\n wsPath: string;\n httpHost: string;\n httpPort: number;\n httpsPort: number;\n httpPath: string;\n stats_host: string;\n authEndpoint: string;\n authTransport: AuthTransport;\n activityTimeout: number;\n pongTimeout: number;\n unavailableTimeout: number;\n userAuthentication: UserAuthenticationOptions;\n channelAuthorization: ChannelAuthorizationOptions;\n\n cdn_http?: string;\n cdn_https?: string;\n dependency_suffix?: string;\n}\n\nvar Defaults: DefaultConfig = {\n VERSION: VERSION,\n PROTOCOL: 7,\n\n wsPort: 80,\n wssPort: 443,\n wsPath: '',\n // DEPRECATED: SockJS fallback parameters\n httpHost: 'sockjs.pusher.com',\n httpPort: 80,\n httpsPort: 443,\n httpPath: '/pusher',\n // DEPRECATED: Stats\n stats_host: 'stats.pusher.com',\n // DEPRECATED: Other settings\n authEndpoint: '/pusher/auth',\n authTransport: 'ajax',\n activityTimeout: 120000,\n pongTimeout: 30000,\n unavailableTimeout: 10000,\n userAuthentication: {\n endpoint: '/pusher/user-auth',\n transport: 'ajax'\n },\n channelAuthorization: {\n endpoint: '/pusher/auth',\n transport: 'ajax'\n },\n\n // CDN configuration\n cdn_http: CDN_HTTP,\n cdn_https: CDN_HTTPS,\n dependency_suffix: DEPENDENCY_SUFFIX\n};\n\nexport default Defaults;\n","import {\n ScriptReceivers,\n ScriptReceiverFactory\n} from './script_receiver_factory';\nimport Runtime from 'runtime';\nimport ScriptRequest from './script_request';\n\n/** Handles loading dependency files.\n *\n * Dependency loaders don't remember whether a resource has been loaded or\n * not. It is caller's responsibility to make sure the resource is not loaded\n * twice. This is because it's impossible to detect resource loading status\n * without knowing its content.\n *\n * Options:\n * - cdn_http - url to HTTP CND\n * - cdn_https - url to HTTPS CDN\n * - version - version of pusher-js\n * - suffix - suffix appended to all names of dependency files\n *\n * @param {Object} options\n */\nexport default class DependencyLoader {\n options: any;\n receivers: ScriptReceiverFactory;\n loading: any;\n\n constructor(options: any) {\n this.options = options;\n this.receivers = options.receivers || ScriptReceivers;\n this.loading = {};\n }\n\n /** Loads the dependency from CDN.\n *\n * @param {String} name\n * @param {Function} callback\n */\n load(name: string, options: any, callback: Function) {\n var self = this;\n\n if (self.loading[name] && self.loading[name].length > 0) {\n self.loading[name].push(callback);\n } else {\n self.loading[name] = [callback];\n\n var request = Runtime.createScriptRequest(self.getPath(name, options));\n var receiver = self.receivers.create(function(error) {\n self.receivers.remove(receiver);\n\n if (self.loading[name]) {\n var callbacks = self.loading[name];\n delete self.loading[name];\n\n var successCallback = function(wasSuccessful) {\n if (!wasSuccessful) {\n request.cleanup();\n }\n };\n for (var i = 0; i < callbacks.length; i++) {\n callbacks[i](error, successCallback);\n }\n }\n });\n request.send(receiver);\n }\n }\n\n /** Returns a root URL for pusher-js CDN.\n *\n * @returns {String}\n */\n getRoot(options: any): string {\n var cdn;\n var protocol = Runtime.getDocument().location.protocol;\n if ((options && options.useTLS) || protocol === 'https:') {\n cdn = this.options.cdn_https;\n } else {\n cdn = this.options.cdn_http;\n }\n // make sure there are no double slashes\n return cdn.replace(/\\/*$/, '') + '/' + this.options.version;\n }\n\n /** Returns a full path to a dependency file.\n *\n * @param {String} name\n * @returns {String}\n */\n getPath(name: string, options: any): string {\n return this.getRoot(options) + '/' + name + this.options.suffix + '.js';\n }\n}\n","import { ScriptReceiverFactory } from './script_receiver_factory';\nimport Defaults from 'core/defaults';\nimport DependencyLoader from './dependency_loader';\n\nexport var DependenciesReceivers = new ScriptReceiverFactory(\n '_pusher_dependencies',\n 'Pusher.DependenciesReceivers'\n);\n\nexport var Dependencies = new DependencyLoader({\n cdn_http: Defaults.cdn_http,\n cdn_https: Defaults.cdn_https,\n version: Defaults.VERSION,\n suffix: Defaults.dependency_suffix,\n receivers: DependenciesReceivers\n});\n","/**\n * A place to store help URLs for error messages etc\n */\n\nconst urlStore = {\n baseUrl: 'https://pusher.com',\n urls: {\n authenticationEndpoint: {\n path: '/docs/channels/server_api/authenticating_users'\n },\n authorizationEndpoint: {\n path: '/docs/channels/server_api/authorizing-users/'\n },\n javascriptQuickStart: {\n path: '/docs/javascript_quick_start'\n },\n triggeringClientEvents: {\n path: '/docs/client_api_guide/client_events#trigger-events'\n },\n encryptedChannelSupport: {\n fullUrl:\n 'https://github.com/pusher/pusher-js/tree/cc491015371a4bde5743d1c87a0fbac0feb53195#encrypted-channel-support'\n }\n }\n};\n\n/** Builds a consistent string with links to pusher documentation\n *\n * @param {string} key - relevant key in the url_store.urls object\n * @return {string} suffix string to append to log message\n */\nconst buildLogSuffix = function(key: string): string {\n const urlPrefix = 'See:';\n const urlObj = urlStore.urls[key];\n if (!urlObj) return '';\n\n let url;\n if (urlObj.fullUrl) {\n url = urlObj.fullUrl;\n } else if (urlObj.path) {\n url = urlStore.baseUrl + urlObj.path;\n }\n\n if (!url) return '';\n return `${urlPrefix} ${url}`;\n};\n\nexport default { buildLogSuffix };\n","export enum AuthRequestType {\n UserAuthentication = 'user-authentication',\n ChannelAuthorization = 'channel-authorization'\n}\n\nexport interface ChannelAuthorizationData {\n auth: string;\n channel_data?: string;\n shared_secret?: string;\n}\n\nexport type ChannelAuthorizationCallback = (\n error: Error | null,\n authData: ChannelAuthorizationData | null\n) => void;\n\nexport interface ChannelAuthorizationRequestParams {\n socketId: string;\n channelName: string;\n}\n\nexport interface ChannelAuthorizationHandler {\n (\n params: ChannelAuthorizationRequestParams,\n callback: ChannelAuthorizationCallback\n ): void;\n}\n\nexport interface UserAuthenticationData {\n auth: string;\n user_data: string;\n}\n\nexport type UserAuthenticationCallback = (\n error: Error | null,\n authData: UserAuthenticationData | null\n) => void;\n\nexport interface UserAuthenticationRequestParams {\n socketId: string;\n}\n\nexport interface UserAuthenticationHandler {\n (\n params: UserAuthenticationRequestParams,\n callback: UserAuthenticationCallback\n ): void;\n}\n\nexport type AuthTransportCallback =\n | ChannelAuthorizationCallback\n | UserAuthenticationCallback;\n\nexport interface InternalAuthOptions {\n transport: 'ajax' | 'jsonp';\n endpoint: string;\n params?: any;\n headers?: any;\n paramsProvider?: () => any;\n headersProvider?: () => any;\n}\n\nexport type CustomAuthOptions = {\n customHandler: AuthHandler;\n};\n\nexport type AuthOptionsT =\n | InternalAuthOptions\n | CustomAuthOptions;\n\nexport declare type UserAuthenticationOptions = AuthOptionsT<\n UserAuthenticationHandler\n>;\nexport declare type ChannelAuthorizationOptions = AuthOptionsT<\n ChannelAuthorizationHandler\n>;\n","/** Error classes used throughout the library. */\n// https://github.com/Microsoft/TypeScript-wiki/blob/master/Breaking-Changes.md#extending-built-ins-like-error-array-and-map-may-no-longer-work\nexport class BadEventName extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\nexport class BadChannelName extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\nexport class RequestTimedOut extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class TransportPriorityTooLow extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class TransportClosed extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class UnsupportedFeature extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class UnsupportedTransport extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class UnsupportedStrategy extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class HTTPAuthError extends Error {\n status: number;\n constructor(status: number, msg?: string) {\n super(msg);\n this.status = status;\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n","import TimelineSender from 'core/timeline/timeline_sender';\nimport * as Collections from 'core/utils/collections';\nimport Util from 'core/util';\nimport Runtime from 'runtime';\nimport { AuthTransport } from 'core/auth/auth_transports';\nimport AbstractRuntime from 'runtimes/interface';\nimport UrlStore from 'core/utils/url_store';\nimport {\n AuthRequestType,\n AuthTransportCallback,\n InternalAuthOptions\n} from 'core/auth/options';\nimport { HTTPAuthError } from 'core/errors';\n\nconst ajax: AuthTransport = function(\n context: AbstractRuntime,\n query: string,\n authOptions: InternalAuthOptions,\n authRequestType: AuthRequestType,\n callback: AuthTransportCallback\n) {\n const xhr = Runtime.createXHR();\n xhr.open('POST', authOptions.endpoint, true);\n\n // add request headers\n xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');\n for (var headerName in authOptions.headers) {\n xhr.setRequestHeader(headerName, authOptions.headers[headerName]);\n }\n if (authOptions.headersProvider != null) {\n let dynamicHeaders = authOptions.headersProvider();\n for (var headerName in dynamicHeaders) {\n xhr.setRequestHeader(headerName, dynamicHeaders[headerName]);\n }\n }\n\n xhr.onreadystatechange = function() {\n if (xhr.readyState === 4) {\n if (xhr.status === 200) {\n let data;\n let parsed = false;\n\n try {\n data = JSON.parse(xhr.responseText);\n parsed = true;\n } catch (e) {\n callback(\n new HTTPAuthError(\n 200,\n `JSON returned from ${authRequestType.toString()} endpoint was invalid, yet status code was 200. Data was: ${\n xhr.responseText\n }`\n ),\n null\n );\n }\n\n if (parsed) {\n // prevents double execution.\n callback(null, data);\n }\n } else {\n let suffix = '';\n switch (authRequestType) {\n case AuthRequestType.UserAuthentication:\n suffix = UrlStore.buildLogSuffix('authenticationEndpoint');\n break;\n case AuthRequestType.ChannelAuthorization:\n suffix = `Clients must be authorized to join private or presence channels. ${UrlStore.buildLogSuffix(\n 'authorizationEndpoint'\n )}`;\n break;\n }\n callback(\n new HTTPAuthError(\n xhr.status,\n `Unable to retrieve auth string from ${authRequestType.toString()} endpoint - ` +\n `received status: ${xhr.status} from ${authOptions.endpoint}. ${suffix}`\n ),\n null\n );\n }\n }\n };\n\n xhr.send(query);\n return xhr;\n};\n\nexport default ajax;\n","export default function encode(s: any): string {\n return btoa(utob(s));\n}\n\nvar fromCharCode = String.fromCharCode;\n\nvar b64chars =\n 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';\nvar b64tab = {};\n\nfor (var i = 0, l = b64chars.length; i < l; i++) {\n b64tab[b64chars.charAt(i)] = i;\n}\n\nvar cb_utob = function(c) {\n var cc = c.charCodeAt(0);\n return cc < 0x80\n ? c\n : cc < 0x800\n ? fromCharCode(0xc0 | (cc >>> 6)) + fromCharCode(0x80 | (cc & 0x3f))\n : fromCharCode(0xe0 | ((cc >>> 12) & 0x0f)) +\n fromCharCode(0x80 | ((cc >>> 6) & 0x3f)) +\n fromCharCode(0x80 | (cc & 0x3f));\n};\n\nvar utob = function(u) {\n return u.replace(/[^\\x00-\\x7F]/g, cb_utob);\n};\n\nvar cb_encode = function(ccc) {\n var padlen = [0, 2, 1][ccc.length % 3];\n var ord =\n (ccc.charCodeAt(0) << 16) |\n ((ccc.length > 1 ? ccc.charCodeAt(1) : 0) << 8) |\n (ccc.length > 2 ? ccc.charCodeAt(2) : 0);\n var chars = [\n b64chars.charAt(ord >>> 18),\n b64chars.charAt((ord >>> 12) & 63),\n padlen >= 2 ? '=' : b64chars.charAt((ord >>> 6) & 63),\n padlen >= 1 ? '=' : b64chars.charAt(ord & 63)\n ];\n return chars.join('');\n};\n\nvar btoa =\n global.btoa ||\n function(b) {\n return b.replace(/[\\s\\S]{1,3}/g, cb_encode);\n };\n","import TimedCallback from './timed_callback';\nimport { Delay, Scheduler, Canceller } from './scheduling';\n\nabstract class Timer {\n protected clear: Canceller;\n protected timer: number | void;\n\n constructor(\n set: Scheduler,\n clear: Canceller,\n delay: Delay,\n callback: TimedCallback\n ) {\n this.clear = clear;\n this.timer = set(() => {\n if (this.timer) {\n this.timer = callback(this.timer);\n }\n }, delay);\n }\n\n /** Returns whether the timer is still running.\n *\n * @return {Boolean}\n */\n isRunning(): boolean {\n return this.timer !== null;\n }\n\n /** Aborts a timer when it's running. */\n ensureAborted() {\n if (this.timer) {\n this.clear(this.timer);\n this.timer = null;\n }\n }\n}\n\nexport default Timer;\n","import Timer from './abstract_timer';\nimport TimedCallback from './timed_callback';\nimport { Delay } from './scheduling';\n\n// We need to bind clear functions this way to avoid exceptions on IE8\nfunction clearTimeout(timer) {\n global.clearTimeout(timer);\n}\nfunction clearInterval(timer) {\n global.clearInterval(timer);\n}\n\n/** Cross-browser compatible one-off timer abstraction.\n *\n * @param {Number} delay\n * @param {Function} callback\n */\nexport class OneOffTimer extends Timer {\n constructor(delay: Delay, callback: TimedCallback) {\n super(setTimeout, clearTimeout, delay, function(timer) {\n callback();\n return null;\n });\n }\n}\n\n/** Cross-browser compatible periodic timer abstraction.\n *\n * @param {Number} delay\n * @param {Function} callback\n */\nexport class PeriodicTimer extends Timer {\n constructor(delay: Delay, callback: TimedCallback) {\n super(setInterval, clearInterval, delay, function(timer) {\n callback();\n return timer;\n });\n }\n}\n","import * as Collections from './utils/collections';\nimport TimedCallback from './utils/timers/timed_callback';\nimport { OneOffTimer, PeriodicTimer } from './utils/timers';\n\nvar Util = {\n now(): number {\n if (Date.now) {\n return Date.now();\n } else {\n return new Date().valueOf();\n }\n },\n\n defer(callback: TimedCallback): OneOffTimer {\n return new OneOffTimer(0, callback);\n },\n\n /** Builds a function that will proxy a method call to its first argument.\n *\n * Allows partial application of arguments, so additional arguments are\n * prepended to the argument list.\n *\n * @param {String} name method name\n * @return {Function} proxy function\n */\n method(name: string, ...args: any[]): Function {\n var boundArguments = Array.prototype.slice.call(arguments, 1);\n return function(object) {\n return object[name].apply(object, boundArguments.concat(arguments));\n };\n }\n};\n\nexport default Util;\n","import base64encode from '../base64';\nimport Util from '../util';\n\n/** Merges multiple objects into the target argument.\n *\n * For properties that are plain Objects, performs a deep-merge. For the\n * rest it just copies the value of the property.\n *\n * To extend prototypes use it as following:\n * Pusher.Util.extend(Target.prototype, Base.prototype)\n *\n * You can also use it to merge objects without altering them:\n * Pusher.Util.extend({}, object1, object2)\n *\n * @param {Object} target\n * @return {Object} the target argument\n */\nexport function extend(target: any, ...sources: any[]): T {\n for (var i = 0; i < sources.length; i++) {\n var extensions = sources[i];\n for (var property in extensions) {\n if (\n extensions[property] &&\n extensions[property].constructor &&\n extensions[property].constructor === Object\n ) {\n target[property] = extend(target[property] || {}, extensions[property]);\n } else {\n target[property] = extensions[property];\n }\n }\n }\n return target;\n}\n\nexport function stringify(): string {\n var m = ['Pusher'];\n for (var i = 0; i < arguments.length; i++) {\n if (typeof arguments[i] === 'string') {\n m.push(arguments[i]);\n } else {\n m.push(safeJSONStringify(arguments[i]));\n }\n }\n return m.join(' : ');\n}\n\nexport function arrayIndexOf(array: any[], item: any): number {\n // MSIE doesn't have array.indexOf\n var nativeIndexOf = Array.prototype.indexOf;\n if (array === null) {\n return -1;\n }\n if (nativeIndexOf && array.indexOf === nativeIndexOf) {\n return array.indexOf(item);\n }\n for (var i = 0, l = array.length; i < l; i++) {\n if (array[i] === item) {\n return i;\n }\n }\n return -1;\n}\n\n/** Applies a function f to all properties of an object.\n *\n * Function f gets 3 arguments passed:\n * - element from the object\n * - key of the element\n * - reference to the object\n *\n * @param {Object} object\n * @param {Function} f\n */\nexport function objectApply(object: any, f: Function) {\n for (var key in object) {\n if (Object.prototype.hasOwnProperty.call(object, key)) {\n f(object[key], key, object);\n }\n }\n}\n\n/** Return a list of objects own proerty keys\n *\n * @param {Object} object\n * @returns {Array}\n */\nexport function keys(object: any): string[] {\n var keys = [];\n objectApply(object, function(_, key) {\n keys.push(key);\n });\n return keys;\n}\n\n/** Return a list of object's own property values\n *\n * @param {Object} object\n * @returns {Array}\n */\nexport function values(object: any): any[] {\n var values = [];\n objectApply(object, function(value) {\n values.push(value);\n });\n return values;\n}\n\n/** Applies a function f to all elements of an array.\n *\n * Function f gets 3 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function apply(array: any[], f: Function, context?: any) {\n for (var i = 0; i < array.length; i++) {\n f.call(context || global, array[i], i, array);\n }\n}\n\n/** Maps all elements of the array and returns the result.\n *\n * Function f gets 4 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n * - reference to the destination array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function map(array: any[], f: Function): any[] {\n var result = [];\n for (var i = 0; i < array.length; i++) {\n result.push(f(array[i], i, array, result));\n }\n return result;\n}\n\n/** Maps all elements of the object and returns the result.\n *\n * Function f gets 4 arguments passed:\n * - element from the object\n * - key of the element\n * - reference to the source object\n * - reference to the destination object\n *\n * @param {Object} object\n * @param {Function} f\n */\nexport function mapObject(object: any, f: Function): any {\n var result = {};\n objectApply(object, function(value, key) {\n result[key] = f(value);\n });\n return result;\n}\n\n/** Filters elements of the array using a test function.\n *\n * Function test gets 4 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n * - reference to the destination array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function filter(array: any[], test: Function): any[] {\n test =\n test ||\n function(value) {\n return !!value;\n };\n\n var result = [];\n for (var i = 0; i < array.length; i++) {\n if (test(array[i], i, array, result)) {\n result.push(array[i]);\n }\n }\n return result;\n}\n\n/** Filters properties of the object using a test function.\n *\n * Function test gets 4 arguments passed:\n * - element from the object\n * - key of the element\n * - reference to the source object\n * - reference to the destination object\n *\n * @param {Object} object\n * @param {Function} f\n */\nexport function filterObject(object: Object, test: Function) {\n var result = {};\n objectApply(object, function(value, key) {\n if ((test && test(value, key, object, result)) || Boolean(value)) {\n result[key] = value;\n }\n });\n return result;\n}\n\n/** Flattens an object into a two-dimensional array.\n *\n * @param {Object} object\n * @return {Array} resulting array of [key, value] pairs\n */\nexport function flatten(object: Object): any[] {\n var result = [];\n objectApply(object, function(value, key) {\n result.push([key, value]);\n });\n return result;\n}\n\n/** Checks whether any element of the array passes the test.\n *\n * Function test gets 3 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function any(array: any[], test: Function): boolean {\n for (var i = 0; i < array.length; i++) {\n if (test(array[i], i, array)) {\n return true;\n }\n }\n return false;\n}\n\n/** Checks whether all elements of the array pass the test.\n *\n * Function test gets 3 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function all(array: any[], test: Function): boolean {\n for (var i = 0; i < array.length; i++) {\n if (!test(array[i], i, array)) {\n return false;\n }\n }\n return true;\n}\n\nexport function encodeParamsObject(data): string {\n return mapObject(data, function(value) {\n if (typeof value === 'object') {\n value = safeJSONStringify(value);\n }\n return encodeURIComponent(base64encode(value.toString()));\n });\n}\n\nexport function buildQueryString(data: any): string {\n var params = filterObject(data, function(value) {\n return value !== undefined;\n });\n\n var query = map(\n flatten(encodeParamsObject(params)),\n Util.method('join', '=')\n ).join('&');\n\n return query;\n}\n\n/**\n * See https://github.com/douglascrockford/JSON-js/blob/master/cycle.js\n *\n * Remove circular references from an object. Required for JSON.stringify in\n * React Native, which tends to blow up a lot.\n *\n * @param {any} object\n * @return {any} Decycled object\n */\nexport function decycleObject(object: any): any {\n var objects = [],\n paths = [];\n\n return (function derez(value, path) {\n var i, name, nu;\n\n switch (typeof value) {\n case 'object':\n if (!value) {\n return null;\n }\n for (i = 0; i < objects.length; i += 1) {\n if (objects[i] === value) {\n return { $ref: paths[i] };\n }\n }\n\n objects.push(value);\n paths.push(path);\n\n if (Object.prototype.toString.apply(value) === '[object Array]') {\n nu = [];\n for (i = 0; i < value.length; i += 1) {\n nu[i] = derez(value[i], path + '[' + i + ']');\n }\n } else {\n nu = {};\n for (name in value) {\n if (Object.prototype.hasOwnProperty.call(value, name)) {\n nu[name] = derez(\n value[name],\n path + '[' + JSON.stringify(name) + ']'\n );\n }\n }\n }\n return nu;\n case 'number':\n case 'string':\n case 'boolean':\n return value;\n }\n })(object, '$');\n}\n\n/**\n * Provides a cross-browser and cross-platform way to safely stringify objects\n * into JSON. This is particularly necessary for ReactNative, where circular JSON\n * structures throw an exception.\n *\n * @param {any} source The object to stringify\n * @return {string} The serialized output.\n */\nexport function safeJSONStringify(source: any): string {\n try {\n return JSON.stringify(source);\n } catch (e) {\n return JSON.stringify(decycleObject(source));\n }\n}\n","import { stringify } from './utils/collections';\nimport Pusher from './pusher';\n\nclass Logger {\n debug(...args: any[]) {\n this.log(this.globalLog, args);\n }\n\n warn(...args: any[]) {\n this.log(this.globalLogWarn, args);\n }\n\n error(...args: any[]) {\n this.log(this.globalLogError, args);\n }\n\n private globalLog = (message: string) => {\n if (global.console && global.console.log) {\n global.console.log(message);\n }\n };\n\n private globalLogWarn(message: string) {\n if (global.console && global.console.warn) {\n global.console.warn(message);\n } else {\n this.globalLog(message);\n }\n }\n\n private globalLogError(message: string) {\n if (global.console && global.console.error) {\n global.console.error(message);\n } else {\n this.globalLogWarn(message);\n }\n }\n\n private log(\n defaultLoggingFunction: (message: string) => void,\n ...args: any[]\n ) {\n var message = stringify.apply(this, arguments);\n if (Pusher.log) {\n Pusher.log(message);\n } else if (Pusher.logToConsole) {\n const log = defaultLoggingFunction.bind(this);\n log(message);\n }\n }\n}\n\nexport default new Logger();\n","import Browser from '../browser';\nimport Logger from 'core/logger';\nimport JSONPRequest from '../dom/jsonp_request';\nimport { ScriptReceivers } from '../dom/script_receiver_factory';\nimport { AuthTransport } from 'core/auth/auth_transports';\nimport {\n AuthRequestType,\n AuthTransportCallback,\n InternalAuthOptions\n} from 'core/auth/options';\n\nvar jsonp: AuthTransport = function(\n context: Browser,\n query: string,\n authOptions: InternalAuthOptions,\n authRequestType: AuthRequestType,\n callback: AuthTransportCallback\n) {\n if (\n authOptions.headers !== undefined ||\n authOptions.headersProvider != null\n ) {\n Logger.warn(\n `To send headers with the ${authRequestType.toString()} request, you must use AJAX, rather than JSONP.`\n );\n }\n\n var callbackName = context.nextAuthCallbackID.toString();\n context.nextAuthCallbackID++;\n\n var document = context.getDocument();\n var script = document.createElement('script');\n // Hacked wrapper.\n context.auth_callbacks[callbackName] = function(data) {\n callback(null, data);\n };\n\n var callback_name = \"Pusher.auth_callbacks['\" + callbackName + \"']\";\n script.src =\n authOptions.endpoint +\n '?callback=' +\n encodeURIComponent(callback_name) +\n '&' +\n query;\n\n var head =\n document.getElementsByTagName('head')[0] || document.documentElement;\n head.insertBefore(script, head.firstChild);\n};\n\nexport default jsonp;\n","import ScriptReceiver from './script_receiver';\n\n/** Sends a generic HTTP GET request using a script tag.\n *\n * By constructing URL in a specific way, it can be used for loading\n * JavaScript resources or JSONP requests. It can notify about errors, but\n * only in certain environments. Please take care of monitoring the state of\n * the request yourself.\n *\n * @param {String} src\n */\nexport default class ScriptRequest {\n src: string;\n script: any;\n errorScript: any;\n\n constructor(src: string) {\n this.src = src;\n }\n\n send(receiver: ScriptReceiver) {\n var self = this;\n var errorString = 'Error loading ' + self.src;\n\n self.script = document.createElement('script');\n self.script.id = receiver.id;\n self.script.src = self.src;\n self.script.type = 'text/javascript';\n self.script.charset = 'UTF-8';\n\n if (self.script.addEventListener) {\n self.script.onerror = function() {\n receiver.callback(errorString);\n };\n self.script.onload = function() {\n receiver.callback(null);\n };\n } else {\n self.script.onreadystatechange = function() {\n if (\n self.script.readyState === 'loaded' ||\n self.script.readyState === 'complete'\n ) {\n receiver.callback(null);\n }\n };\n }\n\n // Opera<11.6 hack for missing onerror callback\n if (\n self.script.async === undefined &&\n (document).attachEvent &&\n /opera/i.test(navigator.userAgent)\n ) {\n self.errorScript = document.createElement('script');\n self.errorScript.id = receiver.id + '_error';\n self.errorScript.text = receiver.name + \"('\" + errorString + \"');\";\n self.script.async = self.errorScript.async = false;\n } else {\n self.script.async = true;\n }\n\n var head = document.getElementsByTagName('head')[0];\n head.insertBefore(self.script, head.firstChild);\n if (self.errorScript) {\n head.insertBefore(self.errorScript, self.script.nextSibling);\n }\n }\n\n /** Cleans up the DOM remains of the script request. */\n cleanup() {\n if (this.script) {\n this.script.onload = this.script.onerror = null;\n this.script.onreadystatechange = null;\n }\n if (this.script && this.script.parentNode) {\n this.script.parentNode.removeChild(this.script);\n }\n if (this.errorScript && this.errorScript.parentNode) {\n this.errorScript.parentNode.removeChild(this.errorScript);\n }\n this.script = null;\n this.errorScript = null;\n }\n}\n","import ScriptReceiver from './script_receiver';\nimport ScriptRequest from './script_request';\nimport * as Collections from 'core/utils/collections';\nimport Util from 'core/util';\nimport Runtime from '../runtime';\n\n/** Sends data via JSONP.\n *\n * Data is a key-value map. Its values are JSON-encoded and then passed\n * through base64. Finally, keys and encoded values are appended to the query\n * string.\n *\n * The class itself does not guarantee raising errors on failures, as it's not\n * possible to support such feature on all browsers. Instead, JSONP endpoint\n * should call back in a way that's easy to distinguish from browser calls,\n * for example by passing a second argument to the receiver.\n *\n * @param {String} url\n * @param {Object} data key-value map of data to be submitted\n */\nexport default class JSONPRequest {\n url: string;\n data: any;\n request: ScriptRequest;\n\n constructor(url: string, data: any) {\n this.url = url;\n this.data = data;\n }\n\n /** Sends the actual JSONP request.\n *\n * @param {ScriptReceiver} receiver\n */\n send(receiver: ScriptReceiver) {\n if (this.request) {\n return;\n }\n\n var query = Collections.buildQueryString(this.data);\n var url = this.url + '/' + receiver.number + '?' + query;\n this.request = Runtime.createScriptRequest(url);\n this.request.send(receiver);\n }\n\n /** Cleans up the DOM remains of the JSONP request. */\n cleanup() {\n if (this.request) {\n this.request.cleanup();\n }\n }\n}\n","import TimelineSender from 'core/timeline/timeline_sender';\nimport TimelineTransport from 'core/timeline/timeline_transport';\nimport Browser from 'runtime';\nimport { AuthTransport } from 'core/auth/auth_transports';\nimport { ScriptReceivers } from '../dom/script_receiver_factory';\n\nvar getAgent = function(sender: TimelineSender, useTLS: boolean) {\n return function(data: any, callback: Function) {\n var scheme = 'http' + (useTLS ? 's' : '') + '://';\n var url =\n scheme + (sender.host || sender.options.host) + sender.options.path;\n var request = Browser.createJSONPRequest(url, data);\n\n var receiver = Browser.ScriptReceivers.create(function(error, result) {\n ScriptReceivers.remove(receiver);\n request.cleanup();\n\n if (result && result.host) {\n sender.host = result.host;\n }\n if (callback) {\n callback(error, result);\n }\n });\n request.send(receiver);\n };\n};\n\nvar jsonp = {\n name: 'jsonp',\n getAgent\n};\n\nexport default jsonp;\n","import Defaults from '../defaults';\nimport { default as URLScheme, URLSchemeParams } from './url_scheme';\n\nfunction getGenericURL(\n baseScheme: string,\n params: URLSchemeParams,\n path: string\n): string {\n var scheme = baseScheme + (params.useTLS ? 's' : '');\n var host = params.useTLS ? params.hostTLS : params.hostNonTLS;\n return scheme + '://' + host + path;\n}\n\nfunction getGenericPath(key: string, queryString?: string): string {\n var path = '/app/' + key;\n var query =\n '?protocol=' +\n Defaults.PROTOCOL +\n '&client=js' +\n '&version=' +\n Defaults.VERSION +\n (queryString ? '&' + queryString : '');\n return path + query;\n}\n\nexport var ws: URLScheme = {\n getInitial: function(key: string, params: URLSchemeParams): string {\n var path = (params.httpPath || '') + getGenericPath(key, 'flash=false');\n return getGenericURL('ws', params, path);\n }\n};\n\nexport var http: URLScheme = {\n getInitial: function(key: string, params: URLSchemeParams): string {\n var path = (params.httpPath || '/pusher') + getGenericPath(key);\n return getGenericURL('http', params, path);\n }\n};\n\nexport var sockjs: URLScheme = {\n getInitial: function(key: string, params: URLSchemeParams): string {\n return getGenericURL('http', params, params.httpPath || '/pusher');\n },\n getPath: function(key: string, params: URLSchemeParams): string {\n return getGenericPath(key);\n }\n};\n","import Callback from './callback';\nimport * as Collections from '../utils/collections';\nimport CallbackTable from './callback_table';\n\nexport default class CallbackRegistry {\n _callbacks: CallbackTable;\n\n constructor() {\n this._callbacks = {};\n }\n\n get(name: string): Callback[] {\n return this._callbacks[prefix(name)];\n }\n\n add(name: string, callback: Function, context: any) {\n var prefixedEventName = prefix(name);\n this._callbacks[prefixedEventName] =\n this._callbacks[prefixedEventName] || [];\n this._callbacks[prefixedEventName].push({\n fn: callback,\n context: context\n });\n }\n\n remove(name?: string, callback?: Function, context?: any) {\n if (!name && !callback && !context) {\n this._callbacks = {};\n return;\n }\n\n var names = name ? [prefix(name)] : Collections.keys(this._callbacks);\n\n if (callback || context) {\n this.removeCallback(names, callback, context);\n } else {\n this.removeAllCallbacks(names);\n }\n }\n\n private removeCallback(names: string[], callback: Function, context: any) {\n Collections.apply(\n names,\n function(name) {\n this._callbacks[name] = Collections.filter(\n this._callbacks[name] || [],\n function(binding) {\n return (\n (callback && callback !== binding.fn) ||\n (context && context !== binding.context)\n );\n }\n );\n if (this._callbacks[name].length === 0) {\n delete this._callbacks[name];\n }\n },\n this\n );\n }\n\n private removeAllCallbacks(names: string[]) {\n Collections.apply(\n names,\n function(name) {\n delete this._callbacks[name];\n },\n this\n );\n }\n}\n\nfunction prefix(name: string): string {\n return '_' + name;\n}\n","import * as Collections from '../utils/collections';\nimport Callback from './callback';\nimport Metadata from '../channels/metadata';\nimport CallbackRegistry from './callback_registry';\n\n/** Manages callback bindings and event emitting.\n *\n * @param Function failThrough called when no listeners are bound to an event\n */\nexport default class Dispatcher {\n callbacks: CallbackRegistry;\n global_callbacks: Function[];\n failThrough: Function;\n\n constructor(failThrough?: Function) {\n this.callbacks = new CallbackRegistry();\n this.global_callbacks = [];\n this.failThrough = failThrough;\n }\n\n bind(eventName: string, callback: Function, context?: any) {\n this.callbacks.add(eventName, callback, context);\n return this;\n }\n\n bind_global(callback: Function) {\n this.global_callbacks.push(callback);\n return this;\n }\n\n unbind(eventName?: string, callback?: Function, context?: any) {\n this.callbacks.remove(eventName, callback, context);\n return this;\n }\n\n unbind_global(callback?: Function) {\n if (!callback) {\n this.global_callbacks = [];\n return this;\n }\n\n this.global_callbacks = Collections.filter(\n this.global_callbacks || [],\n c => c !== callback\n );\n\n return this;\n }\n\n unbind_all() {\n this.unbind();\n this.unbind_global();\n return this;\n }\n\n emit(eventName: string, data?: any, metadata?: Metadata): Dispatcher {\n for (var i = 0; i < this.global_callbacks.length; i++) {\n this.global_callbacks[i](eventName, data);\n }\n\n var callbacks = this.callbacks.get(eventName);\n var args = [];\n\n if (metadata) {\n // if there's a metadata argument, we need to call the callback with both\n // data and metadata regardless of whether data is undefined\n args.push(data, metadata);\n } else if (data) {\n // metadata is undefined, so we only need to call the callback with data\n // if data exists\n args.push(data);\n }\n\n if (callbacks && callbacks.length > 0) {\n for (var i = 0; i < callbacks.length; i++) {\n callbacks[i].fn.apply(callbacks[i].context || global, args);\n }\n } else if (this.failThrough) {\n this.failThrough(eventName, data);\n }\n\n return this;\n }\n}\n","import Util from '../util';\nimport * as Collections from '../utils/collections';\nimport { default as EventsDispatcher } from '../events/dispatcher';\nimport Logger from '../logger';\nimport TransportHooks from './transport_hooks';\nimport Socket from '../socket';\nimport Runtime from 'runtime';\nimport Timeline from '../timeline/timeline';\nimport TransportConnectionOptions from './transport_connection_options';\n\n/** Provides universal API for transport connections.\n *\n * Transport connection is a low-level object that wraps a connection method\n * and exposes a simple evented interface for the connection state and\n * messaging. It does not implement Pusher-specific WebSocket protocol.\n *\n * Additionally, it fetches resources needed for transport to work and exposes\n * an interface for querying transport features.\n *\n * States:\n * - new - initial state after constructing the object\n * - initializing - during initialization phase, usually fetching resources\n * - intialized - ready to establish a connection\n * - connection - when connection is being established\n * - open - when connection ready to be used\n * - closed - after connection was closed be either side\n *\n * Emits:\n * - error - after the connection raised an error\n *\n * Options:\n * - useTLS - whether connection should be over TLS\n * - hostTLS - host to connect to when connection is over TLS\n * - hostNonTLS - host to connect to when connection is over TLS\n *\n * @param {String} key application key\n * @param {Object} options\n */\nexport default class TransportConnection extends EventsDispatcher {\n hooks: TransportHooks;\n name: string;\n priority: number;\n key: string;\n options: TransportConnectionOptions;\n state: string;\n timeline: Timeline;\n activityTimeout: number;\n id: number;\n socket: Socket;\n beforeOpen: Function;\n initialize: Function;\n\n constructor(\n hooks: TransportHooks,\n name: string,\n priority: number,\n key: string,\n options: TransportConnectionOptions\n ) {\n super();\n this.initialize = Runtime.transportConnectionInitializer;\n this.hooks = hooks;\n this.name = name;\n this.priority = priority;\n this.key = key;\n this.options = options;\n\n this.state = 'new';\n this.timeline = options.timeline;\n this.activityTimeout = options.activityTimeout;\n this.id = this.timeline.generateUniqueID();\n }\n\n /** Checks whether the transport handles activity checks by itself.\n *\n * @return {Boolean}\n */\n handlesActivityChecks(): boolean {\n return Boolean(this.hooks.handlesActivityChecks);\n }\n\n /** Checks whether the transport supports the ping/pong API.\n *\n * @return {Boolean}\n */\n supportsPing(): boolean {\n return Boolean(this.hooks.supportsPing);\n }\n\n /** Tries to establish a connection.\n *\n * @returns {Boolean} false if transport is in invalid state\n */\n connect(): boolean {\n if (this.socket || this.state !== 'initialized') {\n return false;\n }\n\n var url = this.hooks.urls.getInitial(this.key, this.options);\n try {\n this.socket = this.hooks.getSocket(url, this.options);\n } catch (e) {\n Util.defer(() => {\n this.onError(e);\n this.changeState('closed');\n });\n return false;\n }\n\n this.bindListeners();\n\n Logger.debug('Connecting', { transport: this.name, url });\n this.changeState('connecting');\n return true;\n }\n\n /** Closes the connection.\n *\n * @return {Boolean} true if there was a connection to close\n */\n close(): boolean {\n if (this.socket) {\n this.socket.close();\n return true;\n } else {\n return false;\n }\n }\n\n /** Sends data over the open connection.\n *\n * @param {String} data\n * @return {Boolean} true only when in the \"open\" state\n */\n send(data: any): boolean {\n if (this.state === 'open') {\n // Workaround for MobileSafari bug (see https://gist.github.com/2052006)\n Util.defer(() => {\n if (this.socket) {\n this.socket.send(data);\n }\n });\n return true;\n } else {\n return false;\n }\n }\n\n /** Sends a ping if the connection is open and transport supports it. */\n ping() {\n if (this.state === 'open' && this.supportsPing()) {\n this.socket.ping();\n }\n }\n\n private onOpen() {\n if (this.hooks.beforeOpen) {\n this.hooks.beforeOpen(\n this.socket,\n this.hooks.urls.getPath(this.key, this.options)\n );\n }\n this.changeState('open');\n this.socket.onopen = undefined;\n }\n\n private onError(error) {\n this.emit('error', { type: 'WebSocketError', error: error });\n this.timeline.error(this.buildTimelineMessage({ error: error.toString() }));\n }\n\n private onClose(closeEvent?: any) {\n if (closeEvent) {\n this.changeState('closed', {\n code: closeEvent.code,\n reason: closeEvent.reason,\n wasClean: closeEvent.wasClean\n });\n } else {\n this.changeState('closed');\n }\n this.unbindListeners();\n this.socket = undefined;\n }\n\n private onMessage(message) {\n this.emit('message', message);\n }\n\n private onActivity() {\n this.emit('activity');\n }\n\n private bindListeners() {\n this.socket.onopen = () => {\n this.onOpen();\n };\n this.socket.onerror = error => {\n this.onError(error);\n };\n this.socket.onclose = closeEvent => {\n this.onClose(closeEvent);\n };\n this.socket.onmessage = message => {\n this.onMessage(message);\n };\n\n if (this.supportsPing()) {\n this.socket.onactivity = () => {\n this.onActivity();\n };\n }\n }\n\n private unbindListeners() {\n if (this.socket) {\n this.socket.onopen = undefined;\n this.socket.onerror = undefined;\n this.socket.onclose = undefined;\n this.socket.onmessage = undefined;\n if (this.supportsPing()) {\n this.socket.onactivity = undefined;\n }\n }\n }\n\n private changeState(state: string, params?: any) {\n this.state = state;\n this.timeline.info(\n this.buildTimelineMessage({\n state: state,\n params: params\n })\n );\n this.emit(state, params);\n }\n\n buildTimelineMessage(message): any {\n return Collections.extend({ cid: this.id }, message);\n }\n}\n","import Factory from '../utils/factory';\nimport TransportHooks from './transport_hooks';\nimport TransportConnection from './transport_connection';\nimport TransportConnectionOptions from './transport_connection_options';\n\n/** Provides interface for transport connection instantiation.\n *\n * Takes transport-specific hooks as the only argument, which allow checking\n * for transport support and creating its connections.\n *\n * Supported hooks: * - file - the name of the file to be fetched during initialization\n * - urls - URL scheme to be used by transport\n * - handlesActivityCheck - true when the transport handles activity checks\n * - supportsPing - true when the transport has a ping/activity API\n * - isSupported - tells whether the transport is supported in the environment\n * - getSocket - creates a WebSocket-compatible transport socket\n *\n * See transports.js for specific implementations.\n *\n * @param {Object} hooks object containing all needed transport hooks\n */\nexport default class Transport {\n hooks: TransportHooks;\n\n constructor(hooks: TransportHooks) {\n this.hooks = hooks;\n }\n\n /** Returns whether the transport is supported in the environment.\n *\n * @param {Object} envronment te environment details (encryption, settings)\n * @returns {Boolean} true when the transport is supported\n */\n isSupported(environment: any): boolean {\n return this.hooks.isSupported(environment);\n }\n\n /** Creates a transport connection.\n *\n * @param {String} name\n * @param {Number} priority\n * @param {String} key the application key\n * @param {Object} options\n * @returns {TransportConnection}\n */\n createConnection(\n name: string,\n priority: number,\n key: string,\n options: any\n ): TransportConnection {\n return new TransportConnection(this.hooks, name, priority, key, options);\n }\n}\n","import * as URLSchemes from 'core/transports/url_schemes';\nimport URLScheme from 'core/transports/url_scheme';\nimport Transport from 'core/transports/transport';\nimport Util from 'core/util';\nimport * as Collections from 'core/utils/collections';\nimport TransportHooks from 'core/transports/transport_hooks';\nimport TransportsTable from 'core/transports/transports_table';\nimport Runtime from 'runtime';\n\n/** WebSocket transport.\n *\n * Uses native WebSocket implementation, including MozWebSocket supported by\n * earlier Firefox versions.\n */\nvar WSTransport = new Transport({\n urls: URLSchemes.ws,\n handlesActivityChecks: false,\n supportsPing: false,\n\n isInitialized: function() {\n return Boolean(Runtime.getWebSocketAPI());\n },\n isSupported: function(): boolean {\n return Boolean(Runtime.getWebSocketAPI());\n },\n getSocket: function(url) {\n return Runtime.createWebSocket(url);\n }\n});\n\nvar httpConfiguration = {\n urls: URLSchemes.http,\n handlesActivityChecks: false,\n supportsPing: true,\n isInitialized: function() {\n return true;\n }\n};\n\nexport var streamingConfiguration = Collections.extend(\n {\n getSocket: function(url) {\n return Runtime.HTTPFactory.createStreamingSocket(url);\n }\n },\n httpConfiguration\n);\nexport var pollingConfiguration = Collections.extend(\n {\n getSocket: function(url) {\n return Runtime.HTTPFactory.createPollingSocket(url);\n }\n },\n httpConfiguration\n);\n\nvar xhrConfiguration = {\n isSupported: function(): boolean {\n return Runtime.isXHRSupported();\n }\n};\n\n/** HTTP streaming transport using CORS-enabled XMLHttpRequest. */\nvar XHRStreamingTransport = new Transport(\n (\n Collections.extend({}, streamingConfiguration, xhrConfiguration)\n )\n);\n\n/** HTTP long-polling transport using CORS-enabled XMLHttpRequest. */\nvar XHRPollingTransport = new Transport(\n Collections.extend({}, pollingConfiguration, xhrConfiguration)\n);\n\nvar Transports: TransportsTable = {\n ws: WSTransport,\n xhr_streaming: XHRStreamingTransport,\n xhr_polling: XHRPollingTransport\n};\n\nexport default Transports;\n","import {\n default as Transports,\n streamingConfiguration,\n pollingConfiguration\n} from 'isomorphic/transports/transports';\nimport Transport from 'core/transports/transport';\nimport TransportHooks from 'core/transports/transport_hooks';\nimport * as URLSchemes from 'core/transports/url_schemes';\nimport Runtime from 'runtime';\nimport { Dependencies } from '../dom/dependencies';\nimport * as Collections from 'core/utils/collections';\n\nvar SockJSTransport = new Transport({\n file: 'sockjs',\n urls: URLSchemes.sockjs,\n handlesActivityChecks: true,\n supportsPing: false,\n\n isSupported: function() {\n return true;\n },\n isInitialized: function() {\n return window.SockJS !== undefined;\n },\n getSocket: function(url, options) {\n return new window.SockJS(url, null, {\n js_path: Dependencies.getPath('sockjs', {\n useTLS: options.useTLS\n }),\n ignore_null_origin: options.ignoreNullOrigin\n });\n },\n beforeOpen: function(socket, path) {\n socket.send(\n JSON.stringify({\n path: path\n })\n );\n }\n});\n\nvar xdrConfiguration = {\n isSupported: function(environment): boolean {\n var yes = Runtime.isXDRSupported(environment.useTLS);\n return yes;\n }\n};\n\n/** HTTP streaming transport using XDomainRequest (IE 8,9). */\nvar XDRStreamingTransport = new Transport(\n (\n Collections.extend({}, streamingConfiguration, xdrConfiguration)\n )\n);\n\n/** HTTP long-polling transport using XDomainRequest (IE 8,9). */\nvar XDRPollingTransport = new Transport(\n Collections.extend({}, pollingConfiguration, xdrConfiguration)\n);\n\nTransports.xdr_streaming = XDRStreamingTransport;\nTransports.xdr_polling = XDRPollingTransport;\nTransports.sockjs = SockJSTransport;\n\nexport default Transports;\n","import Reachability from 'core/reachability';\nimport { default as EventsDispatcher } from 'core/events/dispatcher';\n\n/** Really basic interface providing network availability info.\n *\n * Emits:\n * - online - when browser goes online\n * - offline - when browser goes offline\n */\nexport class NetInfo extends EventsDispatcher implements Reachability {\n constructor() {\n super();\n var self = this;\n // This is okay, as IE doesn't support this stuff anyway.\n if (window.addEventListener !== undefined) {\n window.addEventListener(\n 'online',\n function() {\n self.emit('online');\n },\n false\n );\n window.addEventListener(\n 'offline',\n function() {\n self.emit('offline');\n },\n false\n );\n }\n }\n\n /** Returns whether browser is online or not\n *\n * Offline means definitely offline (no connection to router).\n * Inverse does NOT mean definitely online (only currently supported in Safari\n * and even there only means the device has a connection to the router).\n *\n * @return {Boolean}\n */\n isOnline(): boolean {\n if (window.navigator.onLine === undefined) {\n return true;\n } else {\n return window.navigator.onLine;\n }\n }\n}\n\nexport var Network = new NetInfo();\n","import Util from '../util';\nimport * as Collections from '../utils/collections';\nimport TransportManager from './transport_manager';\nimport TransportConnection from './transport_connection';\nimport Transport from './transport';\nimport PingDelayOptions from './ping_delay_options';\n\n/** Creates transport connections monitored by a transport manager.\n *\n * When a transport is closed, it might mean the environment does not support\n * it. It's possible that messages get stuck in an intermediate buffer or\n * proxies terminate inactive connections. To combat these problems,\n * assistants monitor the connection lifetime, report unclean exits and\n * adjust ping timeouts to keep the connection active. The decision to disable\n * a transport is the manager's responsibility.\n *\n * @param {TransportManager} manager\n * @param {TransportConnection} transport\n * @param {Object} options\n */\nexport default class AssistantToTheTransportManager {\n manager: TransportManager;\n transport: Transport;\n minPingDelay: number;\n maxPingDelay: number;\n pingDelay: number;\n\n constructor(\n manager: TransportManager,\n transport: Transport,\n options: PingDelayOptions\n ) {\n this.manager = manager;\n this.transport = transport;\n this.minPingDelay = options.minPingDelay;\n this.maxPingDelay = options.maxPingDelay;\n this.pingDelay = undefined;\n }\n\n /** Creates a transport connection.\n *\n * This function has the same API as Transport#createConnection.\n *\n * @param {String} name\n * @param {Number} priority\n * @param {String} key the application key\n * @param {Object} options\n * @returns {TransportConnection}\n */\n createConnection(\n name: string,\n priority: number,\n key: string,\n options: Object\n ): TransportConnection {\n options = Collections.extend({}, options, {\n activityTimeout: this.pingDelay\n });\n var connection = this.transport.createConnection(\n name,\n priority,\n key,\n options\n );\n\n var openTimestamp = null;\n\n var onOpen = function() {\n connection.unbind('open', onOpen);\n connection.bind('closed', onClosed);\n openTimestamp = Util.now();\n };\n var onClosed = closeEvent => {\n connection.unbind('closed', onClosed);\n\n if (closeEvent.code === 1002 || closeEvent.code === 1003) {\n // we don't want to use transports not obeying the protocol\n this.manager.reportDeath();\n } else if (!closeEvent.wasClean && openTimestamp) {\n // report deaths only for short-living transport\n var lifespan = Util.now() - openTimestamp;\n if (lifespan < 2 * this.maxPingDelay) {\n this.manager.reportDeath();\n this.pingDelay = Math.max(lifespan / 2, this.minPingDelay);\n }\n }\n };\n\n connection.bind('open', onOpen);\n return connection;\n }\n\n /** Returns whether the transport is supported in the environment.\n *\n * This function has the same API as Transport#isSupported. Might return false\n * when the manager decides to kill the transport.\n *\n * @param {Object} environment the environment details (encryption, settings)\n * @returns {Boolean} true when the transport is supported\n */\n isSupported(environment: string): boolean {\n return this.manager.isAlive() && this.transport.isSupported(environment);\n }\n}\n","import Action from './action';\nimport { PusherEvent } from './message-types';\n/**\n * Provides functions for handling Pusher protocol-specific messages.\n */\n\nconst Protocol = {\n /**\n * Decodes a message in a Pusher format.\n *\n * The MessageEvent we receive from the transport should contain a pusher event\n * (https://pusher.com/docs/pusher_protocol#events) serialized as JSON in the\n * data field\n *\n * The pusher event may contain a data field too, and it may also be\n * serialised as JSON\n *\n * Throws errors when messages are not parse'able.\n *\n * @param {MessageEvent} messageEvent\n * @return {PusherEvent}\n */\n decodeMessage: function(messageEvent: MessageEvent): PusherEvent {\n try {\n var messageData = JSON.parse(messageEvent.data);\n var pusherEventData = messageData.data;\n if (typeof pusherEventData === 'string') {\n try {\n pusherEventData = JSON.parse(messageData.data);\n } catch (e) {}\n }\n var pusherEvent: PusherEvent = {\n event: messageData.event,\n channel: messageData.channel,\n data: pusherEventData\n };\n if (messageData.user_id) {\n pusherEvent.user_id = messageData.user_id;\n }\n return pusherEvent;\n } catch (e) {\n throw { type: 'MessageParseError', error: e, data: messageEvent.data };\n }\n },\n\n /**\n * Encodes a message to be sent.\n *\n * @param {PusherEvent} event\n * @return {String}\n */\n encodeMessage: function(event: PusherEvent): string {\n return JSON.stringify(event);\n },\n\n /**\n * Processes a handshake message and returns appropriate actions.\n *\n * Returns an object with an 'action' and other action-specific properties.\n *\n * There are three outcomes when calling this function. First is a successful\n * connection attempt, when pusher:connection_established is received, which\n * results in a 'connected' action with an 'id' property. When passed a\n * pusher:error event, it returns a result with action appropriate to the\n * close code and an error. Otherwise, it raises an exception.\n *\n * @param {String} message\n * @result Object\n */\n processHandshake: function(messageEvent: MessageEvent): Action {\n var message = Protocol.decodeMessage(messageEvent);\n\n if (message.event === 'pusher:connection_established') {\n if (!message.data.activity_timeout) {\n throw 'No activity timeout specified in handshake';\n }\n return {\n action: 'connected',\n id: message.data.socket_id,\n activityTimeout: message.data.activity_timeout * 1000\n };\n } else if (message.event === 'pusher:error') {\n // From protocol 6 close codes are sent only once, so this only\n // happens when connection does not support close codes\n return {\n action: this.getCloseAction(message.data),\n error: this.getCloseError(message.data)\n };\n } else {\n throw 'Invalid handshake';\n }\n },\n\n /**\n * Dispatches the close event and returns an appropriate action name.\n *\n * See:\n * 1. https://developer.mozilla.org/en-US/docs/WebSockets/WebSockets_reference/CloseEvent\n * 2. http://pusher.com/docs/pusher_protocol\n *\n * @param {CloseEvent} closeEvent\n * @return {String} close action name\n */\n getCloseAction: function(closeEvent): string {\n if (closeEvent.code < 4000) {\n // ignore 1000 CLOSE_NORMAL, 1001 CLOSE_GOING_AWAY,\n // 1005 CLOSE_NO_STATUS, 1006 CLOSE_ABNORMAL\n // ignore 1007...3999\n // handle 1002 CLOSE_PROTOCOL_ERROR, 1003 CLOSE_UNSUPPORTED,\n // 1004 CLOSE_TOO_LARGE\n if (closeEvent.code >= 1002 && closeEvent.code <= 1004) {\n return 'backoff';\n } else {\n return null;\n }\n } else if (closeEvent.code === 4000) {\n return 'tls_only';\n } else if (closeEvent.code < 4100) {\n return 'refused';\n } else if (closeEvent.code < 4200) {\n return 'backoff';\n } else if (closeEvent.code < 4300) {\n return 'retry';\n } else {\n // unknown error\n return 'refused';\n }\n },\n\n /**\n * Returns an error or null basing on the close event.\n *\n * Null is returned when connection was closed cleanly. Otherwise, an object\n * with error details is returned.\n *\n * @param {CloseEvent} closeEvent\n * @return {Object} error object\n */\n getCloseError: function(closeEvent): any {\n if (closeEvent.code !== 1000 && closeEvent.code !== 1001) {\n return {\n type: 'PusherError',\n data: {\n code: closeEvent.code,\n message: closeEvent.reason || closeEvent.message\n }\n };\n } else {\n return null;\n }\n }\n};\n\nexport default Protocol;\n","import * as Collections from '../utils/collections';\nimport { default as EventsDispatcher } from '../events/dispatcher';\nimport Protocol from './protocol/protocol';\nimport { PusherEvent } from './protocol/message-types';\nimport Logger from '../logger';\nimport TransportConnection from '../transports/transport_connection';\nimport Socket from '../socket';\n/**\n * Provides Pusher protocol interface for transports.\n *\n * Emits following events:\n * - message - on received messages\n * - ping - on ping requests\n * - pong - on pong responses\n * - error - when the transport emits an error\n * - closed - after closing the transport\n *\n * It also emits more events when connection closes with a code.\n * See Protocol.getCloseAction to get more details.\n *\n * @param {Number} id\n * @param {AbstractTransport} transport\n */\nexport default class Connection extends EventsDispatcher implements Socket {\n id: string;\n transport: TransportConnection;\n activityTimeout: number;\n\n constructor(id: string, transport: TransportConnection) {\n super();\n this.id = id;\n this.transport = transport;\n this.activityTimeout = transport.activityTimeout;\n this.bindListeners();\n }\n\n /** Returns whether used transport handles activity checks by itself\n *\n * @returns {Boolean} true if activity checks are handled by the transport\n */\n handlesActivityChecks() {\n return this.transport.handlesActivityChecks();\n }\n\n /** Sends raw data.\n *\n * @param {String} data\n */\n send(data: any): boolean {\n return this.transport.send(data);\n }\n\n /** Sends an event.\n *\n * @param {String} name\n * @param {String} data\n * @param {String} [channel]\n * @returns {Boolean} whether message was sent or not\n */\n send_event(name: string, data: any, channel?: string): boolean {\n var event: PusherEvent = { event: name, data: data };\n if (channel) {\n event.channel = channel;\n }\n Logger.debug('Event sent', event);\n return this.send(Protocol.encodeMessage(event));\n }\n\n /** Sends a ping message to the server.\n *\n * Basing on the underlying transport, it might send either transport's\n * protocol-specific ping or pusher:ping event.\n */\n ping() {\n if (this.transport.supportsPing()) {\n this.transport.ping();\n } else {\n this.send_event('pusher:ping', {});\n }\n }\n\n /** Closes the connection. */\n close() {\n this.transport.close();\n }\n\n private bindListeners() {\n var listeners = {\n message: (messageEvent: MessageEvent) => {\n var pusherEvent;\n try {\n pusherEvent = Protocol.decodeMessage(messageEvent);\n } catch (e) {\n this.emit('error', {\n type: 'MessageParseError',\n error: e,\n data: messageEvent.data\n });\n }\n\n if (pusherEvent !== undefined) {\n Logger.debug('Event recd', pusherEvent);\n\n switch (pusherEvent.event) {\n case 'pusher:error':\n this.emit('error', {\n type: 'PusherError',\n data: pusherEvent.data\n });\n break;\n case 'pusher:ping':\n this.emit('ping');\n break;\n case 'pusher:pong':\n this.emit('pong');\n break;\n }\n this.emit('message', pusherEvent);\n }\n },\n activity: () => {\n this.emit('activity');\n },\n error: error => {\n this.emit('error', error);\n },\n closed: closeEvent => {\n unbindListeners();\n\n if (closeEvent && closeEvent.code) {\n this.handleCloseEvent(closeEvent);\n }\n\n this.transport = null;\n this.emit('closed');\n }\n };\n\n var unbindListeners = () => {\n Collections.objectApply(listeners, (listener, event) => {\n this.transport.unbind(event, listener);\n });\n };\n\n Collections.objectApply(listeners, (listener, event) => {\n this.transport.bind(event, listener);\n });\n }\n\n private handleCloseEvent(closeEvent: any) {\n var action = Protocol.getCloseAction(closeEvent);\n var error = Protocol.getCloseError(closeEvent);\n if (error) {\n this.emit('error', error);\n }\n if (action) {\n this.emit(action, { action: action, error: error });\n }\n }\n}\n","import Util from '../../util';\nimport * as Collections from '../../utils/collections';\nimport Protocol from '../protocol/protocol';\nimport Connection from '../connection';\nimport TransportConnection from '../../transports/transport_connection';\nimport HandshakePayload from './handshake_payload';\n\n/**\n * Handles Pusher protocol handshakes for transports.\n *\n * Calls back with a result object after handshake is completed. Results\n * always have two fields:\n * - action - string describing action to be taken after the handshake\n * - transport - the transport object passed to the constructor\n *\n * Different actions can set different additional properties on the result.\n * In the case of 'connected' action, there will be a 'connection' property\n * containing a Connection object for the transport. Other actions should\n * carry an 'error' property.\n *\n * @param {AbstractTransport} transport\n * @param {Function} callback\n */\nexport default class Handshake {\n transport: TransportConnection;\n callback: (HandshakePayload) => void;\n onMessage: Function;\n onClosed: Function;\n\n constructor(\n transport: TransportConnection,\n callback: (HandshakePayload) => void\n ) {\n this.transport = transport;\n this.callback = callback;\n this.bindListeners();\n }\n\n close() {\n this.unbindListeners();\n this.transport.close();\n }\n\n private bindListeners() {\n this.onMessage = m => {\n this.unbindListeners();\n\n var result;\n try {\n result = Protocol.processHandshake(m);\n } catch (e) {\n this.finish('error', { error: e });\n this.transport.close();\n return;\n }\n\n if (result.action === 'connected') {\n this.finish('connected', {\n connection: new Connection(result.id, this.transport),\n activityTimeout: result.activityTimeout\n });\n } else {\n this.finish(result.action, { error: result.error });\n this.transport.close();\n }\n };\n\n this.onClosed = closeEvent => {\n this.unbindListeners();\n\n var action = Protocol.getCloseAction(closeEvent) || 'backoff';\n var error = Protocol.getCloseError(closeEvent);\n this.finish(action, { error: error });\n };\n\n this.transport.bind('message', this.onMessage);\n this.transport.bind('closed', this.onClosed);\n }\n\n private unbindListeners() {\n this.transport.unbind('message', this.onMessage);\n this.transport.unbind('closed', this.onClosed);\n }\n\n private finish(action: string, params: any) {\n this.callback(\n Collections.extend({ transport: this.transport, action: action }, params)\n );\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport base64encode from '../base64';\nimport Timeline from './timeline';\nimport Runtime from 'runtime';\n\nexport interface TimelineSenderOptions {\n host?: string;\n port?: number;\n path?: string;\n}\n\nexport default class TimelineSender {\n timeline: Timeline;\n options: TimelineSenderOptions;\n host: string;\n\n constructor(timeline: Timeline, options: TimelineSenderOptions) {\n this.timeline = timeline;\n this.options = options || {};\n }\n\n send(useTLS: boolean, callback?: Function) {\n if (this.timeline.isEmpty()) {\n return;\n }\n\n this.timeline.send(\n Runtime.TimelineTransport.getAgent(this, useTLS),\n callback\n );\n }\n}\n","import { default as EventsDispatcher } from '../events/dispatcher';\nimport * as Errors from '../errors';\nimport Logger from '../logger';\nimport Pusher from '../pusher';\nimport { PusherEvent } from '../connection/protocol/message-types';\nimport Metadata from './metadata';\nimport UrlStore from '../utils/url_store';\nimport {\n ChannelAuthorizationData,\n ChannelAuthorizationCallback\n} from '../auth/options';\nimport { HTTPAuthError } from '../errors';\n\n/** Provides base public channel interface with an event emitter.\n *\n * Emits:\n * - pusher:subscription_succeeded - after subscribing successfully\n * - other non-internal events\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\nexport default class Channel extends EventsDispatcher {\n name: string;\n pusher: Pusher;\n subscribed: boolean;\n subscriptionPending: boolean;\n subscriptionCancelled: boolean;\n subscriptionCount: null;\n\n constructor(name: string, pusher: Pusher) {\n super(function(event, data) {\n Logger.debug('No callbacks on ' + name + ' for ' + event);\n });\n\n this.name = name;\n this.pusher = pusher;\n this.subscribed = false;\n this.subscriptionPending = false;\n this.subscriptionCancelled = false;\n }\n\n /** Skips authorization, since public channels don't require it.\n *\n * @param {Function} callback\n */\n authorize(socketId: string, callback: ChannelAuthorizationCallback) {\n return callback(null, { auth: '' });\n }\n\n /** Triggers an event */\n trigger(event: string, data: any) {\n if (event.indexOf('client-') !== 0) {\n throw new Errors.BadEventName(\n \"Event '\" + event + \"' does not start with 'client-'\"\n );\n }\n if (!this.subscribed) {\n var suffix = UrlStore.buildLogSuffix('triggeringClientEvents');\n Logger.warn(\n `Client event triggered before channel 'subscription_succeeded' event . ${suffix}`\n );\n }\n return this.pusher.send_event(event, data, this.name);\n }\n\n /** Signals disconnection to the channel. For internal use only. */\n disconnect() {\n this.subscribed = false;\n this.subscriptionPending = false;\n }\n\n /** Handles a PusherEvent. For internal use only.\n *\n * @param {PusherEvent} event\n */\n handleEvent(event: PusherEvent) {\n var eventName = event.event;\n var data = event.data;\n if (eventName === 'pusher_internal:subscription_succeeded') {\n this.handleSubscriptionSucceededEvent(event);\n } else if (eventName === 'pusher_internal:subscription_count') {\n this.handleSubscriptionCountEvent(event);\n } else if (eventName.indexOf('pusher_internal:') !== 0) {\n var metadata: Metadata = {};\n this.emit(eventName, data, metadata);\n }\n }\n\n handleSubscriptionSucceededEvent(event: PusherEvent) {\n this.subscriptionPending = false;\n this.subscribed = true;\n if (this.subscriptionCancelled) {\n this.pusher.unsubscribe(this.name);\n } else {\n this.emit('pusher:subscription_succeeded', event.data);\n }\n }\n\n handleSubscriptionCountEvent(event: PusherEvent) {\n if (event.data.subscription_count) {\n this.subscriptionCount = event.data.subscription_count;\n }\n\n this.emit('pusher:subscription_count', event.data);\n }\n\n /** Sends a subscription request. For internal use only. */\n subscribe() {\n if (this.subscribed) {\n return;\n }\n this.subscriptionPending = true;\n this.subscriptionCancelled = false;\n this.authorize(\n this.pusher.connection.socket_id,\n (error: Error | null, data: ChannelAuthorizationData) => {\n if (error) {\n this.subscriptionPending = false;\n // Why not bind to 'pusher:subscription_error' a level up, and log there?\n // Binding to this event would cause the warning about no callbacks being\n // bound (see constructor) to be suppressed, that's not what we want.\n Logger.error(error.toString());\n this.emit(\n 'pusher:subscription_error',\n Object.assign(\n {},\n {\n type: 'AuthError',\n error: error.message\n },\n error instanceof HTTPAuthError ? { status: error.status } : {}\n )\n );\n } else {\n this.pusher.send_event('pusher:subscribe', {\n auth: data.auth,\n channel_data: data.channel_data,\n channel: this.name\n });\n }\n }\n );\n }\n\n /** Sends an unsubscription request. For internal use only. */\n unsubscribe() {\n this.subscribed = false;\n this.pusher.send_event('pusher:unsubscribe', {\n channel: this.name\n });\n }\n\n /** Cancels an in progress subscription. For internal use only. */\n cancelSubscription() {\n this.subscriptionCancelled = true;\n }\n\n /** Reinstates an in progress subscripiton. For internal use only. */\n reinstateSubscription() {\n this.subscriptionCancelled = false;\n }\n}\n","import Factory from '../utils/factory';\nimport Channel from './channel';\nimport { ChannelAuthorizationCallback } from '../auth/options';\n\n/** Extends public channels to provide private channel interface.\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\nexport default class PrivateChannel extends Channel {\n /** Authorizes the connection to use the channel.\n *\n * @param {String} socketId\n * @param {Function} callback\n */\n authorize(socketId: string, callback: ChannelAuthorizationCallback) {\n return this.pusher.config.channelAuthorizer(\n {\n channelName: this.name,\n socketId: socketId\n },\n callback\n );\n }\n}\n","import * as Collections from '../utils/collections';\n\n/** Represents a collection of members of a presence channel. */\nexport default class Members {\n members: any;\n count: number;\n myID: any;\n me: any;\n\n constructor() {\n this.reset();\n }\n\n /** Returns member's info for given id.\n *\n * Resulting object containts two fields - id and info.\n *\n * @param {Number} id\n * @return {Object} member's info or null\n */\n get(id: string): any {\n if (Object.prototype.hasOwnProperty.call(this.members, id)) {\n return {\n id: id,\n info: this.members[id]\n };\n } else {\n return null;\n }\n }\n\n /** Calls back for each member in unspecified order.\n *\n * @param {Function} callback\n */\n each(callback: Function) {\n Collections.objectApply(this.members, (member, id) => {\n callback(this.get(id));\n });\n }\n\n /** Updates the id for connected member. For internal use only. */\n setMyID(id: string) {\n this.myID = id;\n }\n\n /** Handles subscription data. For internal use only. */\n onSubscription(subscriptionData: any) {\n this.members = subscriptionData.presence.hash;\n this.count = subscriptionData.presence.count;\n this.me = this.get(this.myID);\n }\n\n /** Adds a new member to the collection. For internal use only. */\n addMember(memberData: any) {\n if (this.get(memberData.user_id) === null) {\n this.count++;\n }\n this.members[memberData.user_id] = memberData.user_info;\n return this.get(memberData.user_id);\n }\n\n /** Adds a member from the collection. For internal use only. */\n removeMember(memberData: any) {\n var member = this.get(memberData.user_id);\n if (member) {\n delete this.members[memberData.user_id];\n this.count--;\n }\n return member;\n }\n\n /** Resets the collection to the initial state. For internal use only. */\n reset() {\n this.members = {};\n this.count = 0;\n this.myID = null;\n this.me = null;\n }\n}\n","import PrivateChannel from './private_channel';\nimport Logger from '../logger';\nimport Members from './members';\nimport Pusher from '../pusher';\nimport UrlStore from 'core/utils/url_store';\nimport { PusherEvent } from '../connection/protocol/message-types';\nimport Metadata from './metadata';\nimport { ChannelAuthorizationData } from '../auth/options';\n\nexport default class PresenceChannel extends PrivateChannel {\n members: Members;\n\n /** Adds presence channel functionality to private channels.\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\n constructor(name: string, pusher: Pusher) {\n super(name, pusher);\n this.members = new Members();\n }\n\n /** Authorizes the connection as a member of the channel.\n *\n * @param {String} socketId\n * @param {Function} callback\n */\n authorize(socketId: string, callback: Function) {\n super.authorize(socketId, async (error, authData) => {\n if (!error) {\n authData = authData as ChannelAuthorizationData;\n if (authData.channel_data != null) {\n var channelData = JSON.parse(authData.channel_data);\n this.members.setMyID(channelData.user_id);\n } else {\n await this.pusher.user.signinDonePromise;\n if (this.pusher.user.user_data != null) {\n // If the user is signed in, get the id of the authenticated user\n // and allow the presence authorization to continue.\n this.members.setMyID(this.pusher.user.user_data.id);\n } else {\n let suffix = UrlStore.buildLogSuffix('authorizationEndpoint');\n Logger.error(\n `Invalid auth response for channel '${this.name}', ` +\n `expected 'channel_data' field. ${suffix}, ` +\n `or the user should be signed in.`\n );\n callback('Invalid auth response');\n return;\n }\n }\n }\n callback(error, authData);\n });\n }\n\n /** Handles presence and subscription events. For internal use only.\n *\n * @param {PusherEvent} event\n */\n handleEvent(event: PusherEvent) {\n var eventName = event.event;\n if (eventName.indexOf('pusher_internal:') === 0) {\n this.handleInternalEvent(event);\n } else {\n var data = event.data;\n var metadata: Metadata = {};\n if (event.user_id) {\n metadata.user_id = event.user_id;\n }\n this.emit(eventName, data, metadata);\n }\n }\n handleInternalEvent(event: PusherEvent) {\n var eventName = event.event;\n var data = event.data;\n switch (eventName) {\n case 'pusher_internal:subscription_succeeded':\n this.handleSubscriptionSucceededEvent(event);\n break;\n case 'pusher_internal:subscription_count':\n this.handleSubscriptionCountEvent(event);\n break;\n case 'pusher_internal:member_added':\n var addedMember = this.members.addMember(data);\n this.emit('pusher:member_added', addedMember);\n break;\n case 'pusher_internal:member_removed':\n var removedMember = this.members.removeMember(data);\n if (removedMember) {\n this.emit('pusher:member_removed', removedMember);\n }\n break;\n }\n }\n\n handleSubscriptionSucceededEvent(event: PusherEvent) {\n this.subscriptionPending = false;\n this.subscribed = true;\n if (this.subscriptionCancelled) {\n this.pusher.unsubscribe(this.name);\n } else {\n this.members.onSubscription(event.data);\n this.emit('pusher:subscription_succeeded', this.members);\n }\n }\n\n /** Resets the channel state, including members map. For internal use only. */\n disconnect() {\n this.members.reset();\n super.disconnect();\n }\n}\n","import PrivateChannel from './private_channel';\nimport * as Errors from '../errors';\nimport Logger from '../logger';\nimport Pusher from '../pusher';\nimport { decode as encodeUTF8 } from '@stablelib/utf8';\nimport { decode as decodeBase64 } from '@stablelib/base64';\nimport Dispatcher from '../events/dispatcher';\nimport { PusherEvent } from '../connection/protocol/message-types';\nimport {\n ChannelAuthorizationData,\n ChannelAuthorizationCallback\n} from '../auth/options';\nimport * as nacl from 'tweetnacl';\n\n/** Extends private channels to provide encrypted channel interface.\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\nexport default class EncryptedChannel extends PrivateChannel {\n key: Uint8Array = null;\n nacl: nacl;\n\n constructor(name: string, pusher: Pusher, nacl: nacl) {\n super(name, pusher);\n this.nacl = nacl;\n }\n\n /** Authorizes the connection to use the channel.\n *\n * @param {String} socketId\n * @param {Function} callback\n */\n authorize(socketId: string, callback: ChannelAuthorizationCallback) {\n super.authorize(\n socketId,\n (error: Error | null, authData: ChannelAuthorizationData) => {\n if (error) {\n callback(error, authData);\n return;\n }\n let sharedSecret = authData['shared_secret'];\n if (!sharedSecret) {\n callback(\n new Error(\n `No shared_secret key in auth payload for encrypted channel: ${this.name}`\n ),\n null\n );\n return;\n }\n this.key = decodeBase64(sharedSecret);\n delete authData['shared_secret'];\n callback(null, authData);\n }\n );\n }\n\n trigger(event: string, data: any): boolean {\n throw new Errors.UnsupportedFeature(\n 'Client events are not currently supported for encrypted channels'\n );\n }\n\n /** Handles an event. For internal use only.\n *\n * @param {PusherEvent} event\n */\n handleEvent(event: PusherEvent) {\n var eventName = event.event;\n var data = event.data;\n if (\n eventName.indexOf('pusher_internal:') === 0 ||\n eventName.indexOf('pusher:') === 0\n ) {\n super.handleEvent(event);\n return;\n }\n this.handleEncryptedEvent(eventName, data);\n }\n\n private handleEncryptedEvent(event: string, data: any): void {\n if (!this.key) {\n Logger.debug(\n 'Received encrypted event before key has been retrieved from the authEndpoint'\n );\n return;\n }\n if (!data.ciphertext || !data.nonce) {\n Logger.error(\n 'Unexpected format for encrypted event, expected object with `ciphertext` and `nonce` fields, got: ' +\n data\n );\n return;\n }\n let cipherText = decodeBase64(data.ciphertext);\n if (cipherText.length < this.nacl.secretbox.overheadLength) {\n Logger.error(\n `Expected encrypted event ciphertext length to be ${this.nacl.secretbox.overheadLength}, got: ${cipherText.length}`\n );\n return;\n }\n let nonce = decodeBase64(data.nonce);\n if (nonce.length < this.nacl.secretbox.nonceLength) {\n Logger.error(\n `Expected encrypted event nonce length to be ${this.nacl.secretbox.nonceLength}, got: ${nonce.length}`\n );\n return;\n }\n\n let bytes = this.nacl.secretbox.open(cipherText, nonce, this.key);\n if (bytes === null) {\n Logger.debug(\n 'Failed to decrypt an event, probably because it was encrypted with a different key. Fetching a new key from the authEndpoint...'\n );\n // Try a single time to retrieve a new auth key and decrypt the event with it\n // If this fails, a new key will be requested when a new message is received\n this.authorize(this.pusher.connection.socket_id, (error, authData) => {\n if (error) {\n Logger.error(\n `Failed to make a request to the authEndpoint: ${authData}. Unable to fetch new key, so dropping encrypted event`\n );\n return;\n }\n bytes = this.nacl.secretbox.open(cipherText, nonce, this.key);\n if (bytes === null) {\n Logger.error(\n `Failed to decrypt event with new key. Dropping encrypted event`\n );\n return;\n }\n this.emit(event, this.getDataToEmit(bytes));\n return;\n });\n return;\n }\n this.emit(event, this.getDataToEmit(bytes));\n }\n\n // Try and parse the decrypted bytes as JSON. If we can't parse it, just\n // return the utf-8 string\n getDataToEmit(bytes: Uint8Array): string {\n let raw = encodeUTF8(bytes);\n try {\n return JSON.parse(raw);\n } catch {\n return raw;\n }\n }\n}\n","import { default as EventsDispatcher } from '../events/dispatcher';\nimport { OneOffTimer as Timer } from '../utils/timers';\nimport { Config } from '../config';\nimport Logger from '../logger';\nimport HandshakePayload from './handshake/handshake_payload';\nimport Connection from './connection';\nimport Strategy from '../strategies/strategy';\nimport StrategyRunner from '../strategies/strategy_runner';\nimport * as Collections from '../utils/collections';\nimport Timeline from '../timeline/timeline';\nimport ConnectionManagerOptions from './connection_manager_options';\nimport Runtime from 'runtime';\n\nimport {\n ErrorCallbacks,\n HandshakeCallbacks,\n ConnectionCallbacks\n} from './callbacks';\nimport Action from './protocol/action';\n\n/** Manages connection to Pusher.\n *\n * Uses a strategy (currently only default), timers and network availability\n * info to establish a connection and export its state. In case of failures,\n * manages reconnection attempts.\n *\n * Exports state changes as following events:\n * - \"state_change\", { previous: p, current: state }\n * - state\n *\n * States:\n * - initialized - initial state, never transitioned to\n * - connecting - connection is being established\n * - connected - connection has been fully established\n * - disconnected - on requested disconnection\n * - unavailable - after connection timeout or when there's no network\n * - failed - when the connection strategy is not supported\n *\n * Options:\n * - unavailableTimeout - time to transition to unavailable state\n * - activityTimeout - time after which ping message should be sent\n * - pongTimeout - time for Pusher to respond with pong before reconnecting\n *\n * @param {String} key application key\n * @param {Object} options\n */\nexport default class ConnectionManager extends EventsDispatcher {\n key: string;\n options: ConnectionManagerOptions;\n state: string;\n connection: Connection;\n usingTLS: boolean;\n timeline: Timeline;\n socket_id: string;\n unavailableTimer: Timer;\n activityTimer: Timer;\n retryTimer: Timer;\n activityTimeout: number;\n strategy: Strategy;\n runner: StrategyRunner;\n errorCallbacks: ErrorCallbacks;\n handshakeCallbacks: HandshakeCallbacks;\n connectionCallbacks: ConnectionCallbacks;\n\n constructor(key: string, options: ConnectionManagerOptions) {\n super();\n this.state = 'initialized';\n this.connection = null;\n\n this.key = key;\n this.options = options;\n this.timeline = this.options.timeline;\n this.usingTLS = this.options.useTLS;\n\n this.errorCallbacks = this.buildErrorCallbacks();\n this.connectionCallbacks = this.buildConnectionCallbacks(\n this.errorCallbacks\n );\n this.handshakeCallbacks = this.buildHandshakeCallbacks(this.errorCallbacks);\n\n var Network = Runtime.getNetwork();\n\n Network.bind('online', () => {\n this.timeline.info({ netinfo: 'online' });\n if (this.state === 'connecting' || this.state === 'unavailable') {\n this.retryIn(0);\n }\n });\n Network.bind('offline', () => {\n this.timeline.info({ netinfo: 'offline' });\n if (this.connection) {\n this.sendActivityCheck();\n }\n });\n\n this.updateStrategy();\n }\n\n switchCluster(key: string) {\n this.key = key;\n // This ensures that the new config coming from\n // pusher instance are taken into account\n // such as appKey and cluster\n this.updateStrategy();\n this.retryIn(0);\n }\n\n /** Establishes a connection to Pusher.\n *\n * Does nothing when connection is already established. See top-level doc\n * to find events emitted on connection attempts.\n */\n connect() {\n if (this.connection || this.runner) {\n return;\n }\n if (!this.strategy.isSupported()) {\n this.updateState('failed');\n return;\n }\n this.updateState('connecting');\n this.startConnecting();\n this.setUnavailableTimer();\n }\n\n /** Sends raw data.\n *\n * @param {String} data\n */\n send(data) {\n if (this.connection) {\n return this.connection.send(data);\n } else {\n return false;\n }\n }\n\n /** Sends an event.\n *\n * @param {String} name\n * @param {String} data\n * @param {String} [channel]\n * @returns {Boolean} whether message was sent or not\n */\n send_event(name: string, data: any, channel?: string) {\n if (this.connection) {\n return this.connection.send_event(name, data, channel);\n } else {\n return false;\n }\n }\n\n /** Closes the connection. */\n disconnect() {\n this.disconnectInternally();\n this.updateState('disconnected');\n }\n\n isUsingTLS() {\n return this.usingTLS;\n }\n\n private startConnecting() {\n var callback = (error, handshake) => {\n if (error) {\n this.runner = this.strategy.connect(0, callback);\n } else {\n if (handshake.action === 'error') {\n this.emit('error', {\n type: 'HandshakeError',\n error: handshake.error\n });\n this.timeline.error({ handshakeError: handshake.error });\n } else {\n this.abortConnecting(); // we don't support switching connections yet\n this.handshakeCallbacks[handshake.action](handshake);\n }\n }\n };\n this.runner = this.strategy.connect(0, callback);\n }\n\n private abortConnecting() {\n if (this.runner) {\n this.runner.abort();\n this.runner = null;\n }\n }\n\n private disconnectInternally() {\n this.abortConnecting();\n this.clearRetryTimer();\n this.clearUnavailableTimer();\n if (this.connection) {\n var connection = this.abandonConnection();\n connection.close();\n }\n }\n\n private updateStrategy() {\n this.strategy = this.options.getStrategy({\n key: this.key,\n timeline: this.timeline,\n useTLS: this.usingTLS\n });\n }\n\n private retryIn(delay) {\n this.timeline.info({ action: 'retry', delay: delay });\n if (delay > 0) {\n this.emit('connecting_in', Math.round(delay / 1000));\n }\n this.retryTimer = new Timer(delay || 0, () => {\n this.disconnectInternally();\n this.connect();\n });\n }\n\n private clearRetryTimer() {\n if (this.retryTimer) {\n this.retryTimer.ensureAborted();\n this.retryTimer = null;\n }\n }\n\n private setUnavailableTimer() {\n this.unavailableTimer = new Timer(this.options.unavailableTimeout, () => {\n this.updateState('unavailable');\n });\n }\n\n private clearUnavailableTimer() {\n if (this.unavailableTimer) {\n this.unavailableTimer.ensureAborted();\n }\n }\n\n private sendActivityCheck() {\n this.stopActivityCheck();\n this.connection.ping();\n // wait for pong response\n this.activityTimer = new Timer(this.options.pongTimeout, () => {\n this.timeline.error({ pong_timed_out: this.options.pongTimeout });\n this.retryIn(0);\n });\n }\n\n private resetActivityCheck() {\n this.stopActivityCheck();\n // send ping after inactivity\n if (this.connection && !this.connection.handlesActivityChecks()) {\n this.activityTimer = new Timer(this.activityTimeout, () => {\n this.sendActivityCheck();\n });\n }\n }\n\n private stopActivityCheck() {\n if (this.activityTimer) {\n this.activityTimer.ensureAborted();\n }\n }\n\n private buildConnectionCallbacks(\n errorCallbacks: ErrorCallbacks\n ): ConnectionCallbacks {\n return Collections.extend({}, errorCallbacks, {\n message: message => {\n // includes pong messages from server\n this.resetActivityCheck();\n this.emit('message', message);\n },\n ping: () => {\n this.send_event('pusher:pong', {});\n },\n activity: () => {\n this.resetActivityCheck();\n },\n error: error => {\n // just emit error to user - socket will already be closed by browser\n this.emit('error', error);\n },\n closed: () => {\n this.abandonConnection();\n if (this.shouldRetry()) {\n this.retryIn(1000);\n }\n }\n });\n }\n\n private buildHandshakeCallbacks(\n errorCallbacks: ErrorCallbacks\n ): HandshakeCallbacks {\n return Collections.extend({}, errorCallbacks, {\n connected: (handshake: HandshakePayload) => {\n this.activityTimeout = Math.min(\n this.options.activityTimeout,\n handshake.activityTimeout,\n handshake.connection.activityTimeout || Infinity\n );\n this.clearUnavailableTimer();\n this.setConnection(handshake.connection);\n this.socket_id = this.connection.id;\n this.updateState('connected', { socket_id: this.socket_id });\n }\n });\n }\n\n private buildErrorCallbacks(): ErrorCallbacks {\n let withErrorEmitted = callback => {\n return (result: Action | HandshakePayload) => {\n if (result.error) {\n this.emit('error', { type: 'WebSocketError', error: result.error });\n }\n callback(result);\n };\n };\n\n return {\n tls_only: withErrorEmitted(() => {\n this.usingTLS = true;\n this.updateStrategy();\n this.retryIn(0);\n }),\n refused: withErrorEmitted(() => {\n this.disconnect();\n }),\n backoff: withErrorEmitted(() => {\n this.retryIn(1000);\n }),\n retry: withErrorEmitted(() => {\n this.retryIn(0);\n })\n };\n }\n\n private setConnection(connection) {\n this.connection = connection;\n for (var event in this.connectionCallbacks) {\n this.connection.bind(event, this.connectionCallbacks[event]);\n }\n this.resetActivityCheck();\n }\n\n private abandonConnection() {\n if (!this.connection) {\n return;\n }\n this.stopActivityCheck();\n for (var event in this.connectionCallbacks) {\n this.connection.unbind(event, this.connectionCallbacks[event]);\n }\n var connection = this.connection;\n this.connection = null;\n return connection;\n }\n\n private updateState(newState: string, data?: any) {\n var previousState = this.state;\n this.state = newState;\n if (previousState !== newState) {\n var newStateDescription = newState;\n if (newStateDescription === 'connected') {\n newStateDescription += ' with new socket ID ' + data.socket_id;\n }\n Logger.debug(\n 'State changed',\n previousState + ' -> ' + newStateDescription\n );\n this.timeline.info({ state: newState, params: data });\n this.emit('state_change', { previous: previousState, current: newState });\n this.emit(newState, data);\n }\n }\n\n private shouldRetry(): boolean {\n return this.state === 'connecting' || this.state === 'connected';\n }\n}\n","import Channel from './channel';\nimport * as Collections from '../utils/collections';\nimport ChannelTable from './channel_table';\nimport Factory from '../utils/factory';\nimport Pusher from '../pusher';\nimport Logger from '../logger';\nimport * as Errors from '../errors';\nimport urlStore from '../utils/url_store';\n\n/** Handles a channel map. */\nexport default class Channels {\n channels: ChannelTable;\n\n constructor() {\n this.channels = {};\n }\n\n /** Creates or retrieves an existing channel by its name.\n *\n * @param {String} name\n * @param {Pusher} pusher\n * @return {Channel}\n */\n add(name: string, pusher: Pusher) {\n if (!this.channels[name]) {\n this.channels[name] = createChannel(name, pusher);\n }\n return this.channels[name];\n }\n\n /** Returns a list of all channels\n *\n * @return {Array}\n */\n all(): Channel[] {\n return Collections.values(this.channels);\n }\n\n /** Finds a channel by its name.\n *\n * @param {String} name\n * @return {Channel} channel or null if it doesn't exist\n */\n find(name: string) {\n return this.channels[name];\n }\n\n /** Removes a channel from the map.\n *\n * @param {String} name\n */\n remove(name: string) {\n var channel = this.channels[name];\n delete this.channels[name];\n return channel;\n }\n\n /** Proxies disconnection signal to all channels. */\n disconnect() {\n Collections.objectApply(this.channels, function(channel) {\n channel.disconnect();\n });\n }\n}\n\nfunction createChannel(name: string, pusher: Pusher): Channel {\n if (name.indexOf('private-encrypted-') === 0) {\n if (pusher.config.nacl) {\n return Factory.createEncryptedChannel(name, pusher, pusher.config.nacl);\n }\n let errMsg =\n 'Tried to subscribe to a private-encrypted- channel but no nacl implementation available';\n let suffix = urlStore.buildLogSuffix('encryptedChannelSupport');\n throw new Errors.UnsupportedFeature(`${errMsg}. ${suffix}`);\n } else if (name.indexOf('private-') === 0) {\n return Factory.createPrivateChannel(name, pusher);\n } else if (name.indexOf('presence-') === 0) {\n return Factory.createPresenceChannel(name, pusher);\n } else if (name.indexOf('#') === 0) {\n throw new Errors.BadChannelName(\n 'Cannot create a channel with name \"' + name + '\".'\n );\n } else {\n return Factory.createChannel(name, pusher);\n }\n}\n","import AssistantToTheTransportManager from '../transports/assistant_to_the_transport_manager';\nimport PingDelayOptions from '../transports/ping_delay_options';\nimport Transport from '../transports/transport';\nimport TransportManager from '../transports/transport_manager';\nimport Handshake from '../connection/handshake';\nimport TransportConnection from '../transports/transport_connection';\nimport SocketHooks from '../http/socket_hooks';\nimport HTTPSocket from '../http/http_socket';\n\nimport Timeline from '../timeline/timeline';\nimport {\n default as TimelineSender,\n TimelineSenderOptions\n} from '../timeline/timeline_sender';\nimport PresenceChannel from '../channels/presence_channel';\nimport PrivateChannel from '../channels/private_channel';\nimport EncryptedChannel from '../channels/encrypted_channel';\nimport Channel from '../channels/channel';\nimport ConnectionManager from '../connection/connection_manager';\nimport ConnectionManagerOptions from '../connection/connection_manager_options';\nimport Ajax from '../http/ajax';\nimport Channels from '../channels/channels';\nimport Pusher from '../pusher';\nimport { Config } from '../config';\nimport * as nacl from 'tweetnacl';\n\nvar Factory = {\n createChannels(): Channels {\n return new Channels();\n },\n\n createConnectionManager(\n key: string,\n options: ConnectionManagerOptions\n ): ConnectionManager {\n return new ConnectionManager(key, options);\n },\n\n createChannel(name: string, pusher: Pusher): Channel {\n return new Channel(name, pusher);\n },\n\n createPrivateChannel(name: string, pusher: Pusher): PrivateChannel {\n return new PrivateChannel(name, pusher);\n },\n\n createPresenceChannel(name: string, pusher: Pusher): PresenceChannel {\n return new PresenceChannel(name, pusher);\n },\n\n createEncryptedChannel(\n name: string,\n pusher: Pusher,\n nacl: nacl\n ): EncryptedChannel {\n return new EncryptedChannel(name, pusher, nacl);\n },\n\n createTimelineSender(timeline: Timeline, options: TimelineSenderOptions) {\n return new TimelineSender(timeline, options);\n },\n\n createHandshake(\n transport: TransportConnection,\n callback: (HandshakePayload) => void\n ): Handshake {\n return new Handshake(transport, callback);\n },\n\n createAssistantToTheTransportManager(\n manager: TransportManager,\n transport: Transport,\n options: PingDelayOptions\n ): AssistantToTheTransportManager {\n return new AssistantToTheTransportManager(manager, transport, options);\n }\n};\n\nexport default Factory;\n","import AssistantToTheTransportManager from './assistant_to_the_transport_manager';\nimport Transport from './transport';\nimport PingDelayOptions from './ping_delay_options';\nimport Factory from '../utils/factory';\n\nexport interface TransportManagerOptions extends PingDelayOptions {\n lives?: number;\n}\n\n/** Keeps track of the number of lives left for a transport.\n *\n * In the beginning of a session, transports may be assigned a number of\n * lives. When an AssistantToTheTransportManager instance reports a transport\n * connection closed uncleanly, the transport loses a life. When the number\n * of lives drops to zero, the transport gets disabled by its manager.\n *\n * @param {Object} options\n */\nexport default class TransportManager {\n options: TransportManagerOptions;\n livesLeft: number;\n\n constructor(options: TransportManagerOptions) {\n this.options = options || {};\n this.livesLeft = this.options.lives || Infinity;\n }\n\n /** Creates a assistant for the transport.\n *\n * @param {Transport} transport\n * @returns {AssistantToTheTransportManager}\n */\n getAssistant(transport: Transport): AssistantToTheTransportManager {\n return Factory.createAssistantToTheTransportManager(this, transport, {\n minPingDelay: this.options.minPingDelay,\n maxPingDelay: this.options.maxPingDelay\n });\n }\n\n /** Returns whether the transport has any lives left.\n *\n * @returns {Boolean}\n */\n isAlive(): boolean {\n return this.livesLeft > 0;\n }\n\n /** Takes one life from the transport. */\n reportDeath() {\n this.livesLeft -= 1;\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport { OneOffTimer as Timer } from '../utils/timers';\nimport Strategy from './strategy';\nimport StrategyOptions from './strategy_options';\n\n/** Loops through strategies with optional timeouts.\n *\n * Options:\n * - loop - whether it should loop through the substrategy list\n * - timeout - initial timeout for a single substrategy\n * - timeoutLimit - maximum timeout\n *\n * @param {Strategy[]} strategies\n * @param {Object} options\n */\nexport default class SequentialStrategy implements Strategy {\n strategies: Strategy[];\n loop: boolean;\n failFast: boolean;\n timeout: number;\n timeoutLimit: number;\n\n constructor(strategies: Strategy[], options: StrategyOptions) {\n this.strategies = strategies;\n this.loop = Boolean(options.loop);\n this.failFast = Boolean(options.failFast);\n this.timeout = options.timeout;\n this.timeoutLimit = options.timeoutLimit;\n }\n\n isSupported(): boolean {\n return Collections.any(this.strategies, Util.method('isSupported'));\n }\n\n connect(minPriority: number, callback: Function) {\n var strategies = this.strategies;\n var current = 0;\n var timeout = this.timeout;\n var runner = null;\n\n var tryNextStrategy = (error, handshake) => {\n if (handshake) {\n callback(null, handshake);\n } else {\n current = current + 1;\n if (this.loop) {\n current = current % strategies.length;\n }\n\n if (current < strategies.length) {\n if (timeout) {\n timeout = timeout * 2;\n if (this.timeoutLimit) {\n timeout = Math.min(timeout, this.timeoutLimit);\n }\n }\n runner = this.tryStrategy(\n strategies[current],\n minPriority,\n { timeout, failFast: this.failFast },\n tryNextStrategy\n );\n } else {\n callback(true);\n }\n }\n };\n\n runner = this.tryStrategy(\n strategies[current],\n minPriority,\n { timeout: timeout, failFast: this.failFast },\n tryNextStrategy\n );\n\n return {\n abort: function() {\n runner.abort();\n },\n forceMinPriority: function(p) {\n minPriority = p;\n if (runner) {\n runner.forceMinPriority(p);\n }\n }\n };\n }\n\n private tryStrategy(\n strategy: Strategy,\n minPriority: number,\n options: StrategyOptions,\n callback: Function\n ) {\n var timer = null;\n var runner = null;\n\n if (options.timeout > 0) {\n timer = new Timer(options.timeout, function() {\n runner.abort();\n callback(true);\n });\n }\n\n runner = strategy.connect(minPriority, function(error, handshake) {\n if (error && timer && timer.isRunning() && !options.failFast) {\n // advance to the next strategy after the timeout\n return;\n }\n if (timer) {\n timer.ensureAborted();\n }\n callback(error, handshake);\n });\n\n return {\n abort: function() {\n if (timer) {\n timer.ensureAborted();\n }\n runner.abort();\n },\n forceMinPriority: function(p) {\n runner.forceMinPriority(p);\n }\n };\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport Strategy from './strategy';\n\n/** Launches all substrategies and emits prioritized connected transports.\n *\n * @param {Array} strategies\n */\nexport default class BestConnectedEverStrategy implements Strategy {\n strategies: Strategy[];\n\n constructor(strategies: Strategy[]) {\n this.strategies = strategies;\n }\n\n isSupported(): boolean {\n return Collections.any(this.strategies, Util.method('isSupported'));\n }\n\n connect(minPriority: number, callback: Function) {\n return connect(this.strategies, minPriority, function(i, runners) {\n return function(error, handshake) {\n runners[i].error = error;\n if (error) {\n if (allRunnersFailed(runners)) {\n callback(true);\n }\n return;\n }\n Collections.apply(runners, function(runner) {\n runner.forceMinPriority(handshake.transport.priority);\n });\n callback(null, handshake);\n };\n });\n }\n}\n\n/** Connects to all strategies in parallel.\n *\n * Callback builder should be a function that takes two arguments: index\n * and a list of runners. It should return another function that will be\n * passed to the substrategy with given index. Runners can be aborted using\n * abortRunner(s) functions from this class.\n *\n * @param {Array} strategies\n * @param {Function} callbackBuilder\n * @return {Object} strategy runner\n */\nfunction connect(\n strategies: Strategy[],\n minPriority: number,\n callbackBuilder: Function\n) {\n var runners = Collections.map(strategies, function(strategy, i, _, rs) {\n return strategy.connect(minPriority, callbackBuilder(i, rs));\n });\n return {\n abort: function() {\n Collections.apply(runners, abortRunner);\n },\n forceMinPriority: function(p) {\n Collections.apply(runners, function(runner) {\n runner.forceMinPriority(p);\n });\n }\n };\n}\n\nfunction allRunnersFailed(runners): boolean {\n return Collections.all(runners, function(runner) {\n return Boolean(runner.error);\n });\n}\n\nfunction abortRunner(runner) {\n if (!runner.error && !runner.aborted) {\n runner.abort();\n runner.aborted = true;\n }\n}\n","import Util from '../util';\nimport Runtime from 'runtime';\nimport Strategy from './strategy';\nimport SequentialStrategy from './sequential_strategy';\nimport StrategyOptions from './strategy_options';\nimport TransportStrategy from './transport_strategy';\nimport Timeline from '../timeline/timeline';\nimport * as Collections from '../utils/collections';\n\nexport interface TransportStrategyDictionary {\n [key: string]: TransportStrategy;\n}\n\n/** Caches the last successful transport and, after the first few attempts,\n * uses the cached transport for subsequent attempts.\n *\n * @param {Strategy} strategy\n * @param {Object} transports\n * @param {Object} options\n */\nexport default class WebSocketPrioritizedCachedStrategy implements Strategy {\n strategy: Strategy;\n transports: TransportStrategyDictionary;\n ttl: number;\n usingTLS: boolean;\n timeline: Timeline;\n\n constructor(\n strategy: Strategy,\n transports: TransportStrategyDictionary,\n options: StrategyOptions\n ) {\n this.strategy = strategy;\n this.transports = transports;\n this.ttl = options.ttl || 1800 * 1000;\n this.usingTLS = options.useTLS;\n this.timeline = options.timeline;\n }\n\n isSupported(): boolean {\n return this.strategy.isSupported();\n }\n\n connect(minPriority: number, callback: Function) {\n var usingTLS = this.usingTLS;\n var info = fetchTransportCache(usingTLS);\n var cacheSkipCount = info && info.cacheSkipCount ? info.cacheSkipCount : 0;\n\n var strategies = [this.strategy];\n if (info && info.timestamp + this.ttl >= Util.now()) {\n var transport = this.transports[info.transport];\n if (transport) {\n if (['ws', 'wss'].includes(info.transport) || cacheSkipCount > 3) {\n this.timeline.info({\n cached: true,\n transport: info.transport,\n latency: info.latency\n });\n strategies.push(\n new SequentialStrategy([transport], {\n timeout: info.latency * 2 + 1000,\n failFast: true\n })\n );\n } else {\n cacheSkipCount++;\n }\n }\n }\n\n var startTimestamp = Util.now();\n var runner = strategies\n .pop()\n .connect(minPriority, function cb(error, handshake) {\n if (error) {\n flushTransportCache(usingTLS);\n if (strategies.length > 0) {\n startTimestamp = Util.now();\n runner = strategies.pop().connect(minPriority, cb);\n } else {\n callback(error);\n }\n } else {\n storeTransportCache(\n usingTLS,\n handshake.transport.name,\n Util.now() - startTimestamp,\n cacheSkipCount\n );\n callback(null, handshake);\n }\n });\n\n return {\n abort: function() {\n runner.abort();\n },\n forceMinPriority: function(p) {\n minPriority = p;\n if (runner) {\n runner.forceMinPriority(p);\n }\n }\n };\n }\n}\n\nfunction getTransportCacheKey(usingTLS: boolean): string {\n return 'pusherTransport' + (usingTLS ? 'TLS' : 'NonTLS');\n}\n\nfunction fetchTransportCache(usingTLS: boolean): any {\n var storage = Runtime.getLocalStorage();\n if (storage) {\n try {\n var serializedCache = storage[getTransportCacheKey(usingTLS)];\n if (serializedCache) {\n return JSON.parse(serializedCache);\n }\n } catch (e) {\n flushTransportCache(usingTLS);\n }\n }\n return null;\n}\n\nfunction storeTransportCache(\n usingTLS: boolean,\n transport: TransportStrategy,\n latency: number,\n cacheSkipCount: number\n) {\n var storage = Runtime.getLocalStorage();\n if (storage) {\n try {\n storage[getTransportCacheKey(usingTLS)] = Collections.safeJSONStringify({\n timestamp: Util.now(),\n transport: transport,\n latency: latency,\n cacheSkipCount: cacheSkipCount\n });\n } catch (e) {\n // catch over quota exceptions raised by localStorage\n }\n }\n}\n\nfunction flushTransportCache(usingTLS: boolean) {\n var storage = Runtime.getLocalStorage();\n if (storage) {\n try {\n delete storage[getTransportCacheKey(usingTLS)];\n } catch (e) {\n // catch exceptions raised by localStorage\n }\n }\n}\n","import { OneOffTimer as Timer } from '../utils/timers';\nimport Strategy from './strategy';\nimport StrategyOptions from './strategy_options';\n\n/** Runs substrategy after specified delay.\n *\n * Options:\n * - delay - time in miliseconds to delay the substrategy attempt\n *\n * @param {Strategy} strategy\n * @param {Object} options\n */\nexport default class DelayedStrategy implements Strategy {\n strategy: Strategy;\n options: { delay: number };\n\n constructor(strategy: Strategy, { delay: number }) {\n this.strategy = strategy;\n this.options = { delay: number };\n }\n\n isSupported(): boolean {\n return this.strategy.isSupported();\n }\n\n connect(minPriority: number, callback: Function) {\n var strategy = this.strategy;\n var runner;\n var timer = new Timer(this.options.delay, function() {\n runner = strategy.connect(minPriority, callback);\n });\n\n return {\n abort: function() {\n timer.ensureAborted();\n if (runner) {\n runner.abort();\n }\n },\n forceMinPriority: function(p) {\n minPriority = p;\n if (runner) {\n runner.forceMinPriority(p);\n }\n }\n };\n }\n}\n","import Strategy from './strategy';\nimport StrategyRunner from './strategy_runner';\n\n/** Proxies method calls to one of substrategies basing on the test function.\n *\n * @param {Function} test\n * @param {Strategy} trueBranch strategy used when test returns true\n * @param {Strategy} falseBranch strategy used when test returns false\n */\nexport default class IfStrategy implements Strategy {\n test: () => boolean;\n trueBranch: Strategy;\n falseBranch: Strategy;\n\n constructor(\n test: () => boolean,\n trueBranch: Strategy,\n falseBranch: Strategy\n ) {\n this.test = test;\n this.trueBranch = trueBranch;\n this.falseBranch = falseBranch;\n }\n\n isSupported(): boolean {\n var branch = this.test() ? this.trueBranch : this.falseBranch;\n return branch.isSupported();\n }\n\n connect(minPriority: number, callback: Function): StrategyRunner {\n var branch = this.test() ? this.trueBranch : this.falseBranch;\n return branch.connect(minPriority, callback);\n }\n}\n","import Strategy from './strategy';\nimport StrategyRunner from './strategy_runner';\n\n/** Launches the substrategy and terminates on the first open connection.\n *\n * @param {Strategy} strategy\n */\nexport default class FirstConnectedStrategy implements Strategy {\n strategy: Strategy;\n\n constructor(strategy: Strategy) {\n this.strategy = strategy;\n }\n\n isSupported(): boolean {\n return this.strategy.isSupported();\n }\n\n connect(minPriority: number, callback: Function): StrategyRunner {\n var runner = this.strategy.connect(minPriority, function(error, handshake) {\n if (handshake) {\n runner.abort();\n }\n callback(error, handshake);\n });\n return runner;\n }\n}\n","import * as Collections from 'core/utils/collections';\nimport TransportManager from 'core/transports/transport_manager';\nimport Strategy from 'core/strategies/strategy';\nimport StrategyOptions from 'core/strategies/strategy_options';\nimport SequentialStrategy from 'core/strategies/sequential_strategy';\nimport BestConnectedEverStrategy from 'core/strategies/best_connected_ever_strategy';\nimport WebSocketPrioritizedCachedStrategy, {\n TransportStrategyDictionary\n} from 'core/strategies/websocket_prioritized_cached_strategy';\nimport DelayedStrategy from 'core/strategies/delayed_strategy';\nimport IfStrategy from 'core/strategies/if_strategy';\nimport FirstConnectedStrategy from 'core/strategies/first_connected_strategy';\nimport { Config } from 'core/config';\n\nfunction testSupportsStrategy(strategy: Strategy) {\n return function() {\n return strategy.isSupported();\n };\n}\n\nvar getDefaultStrategy = function(\n config: Config,\n baseOptions: StrategyOptions,\n defineTransport: Function\n): Strategy {\n var definedTransports = {};\n\n function defineTransportStrategy(\n name: string,\n type: string,\n priority: number,\n options: StrategyOptions,\n manager?: TransportManager\n ) {\n var transport = defineTransport(\n config,\n name,\n type,\n priority,\n options,\n manager\n );\n\n definedTransports[name] = transport;\n\n return transport;\n }\n\n var ws_options: StrategyOptions = Object.assign({}, baseOptions, {\n hostNonTLS: config.wsHost + ':' + config.wsPort,\n hostTLS: config.wsHost + ':' + config.wssPort,\n httpPath: config.wsPath\n });\n var wss_options: StrategyOptions = Object.assign({}, ws_options, {\n useTLS: true\n });\n var sockjs_options: StrategyOptions = Object.assign({}, baseOptions, {\n hostNonTLS: config.httpHost + ':' + config.httpPort,\n hostTLS: config.httpHost + ':' + config.httpsPort,\n httpPath: config.httpPath\n });\n\n var timeouts = {\n loop: true,\n timeout: 15000,\n timeoutLimit: 60000\n };\n\n var ws_manager = new TransportManager({\n minPingDelay: 10000,\n maxPingDelay: config.activityTimeout\n });\n var streaming_manager = new TransportManager({\n lives: 2,\n minPingDelay: 10000,\n maxPingDelay: config.activityTimeout\n });\n\n var ws_transport = defineTransportStrategy(\n 'ws',\n 'ws',\n 3,\n ws_options,\n ws_manager\n );\n var wss_transport = defineTransportStrategy(\n 'wss',\n 'ws',\n 3,\n wss_options,\n ws_manager\n );\n var sockjs_transport = defineTransportStrategy(\n 'sockjs',\n 'sockjs',\n 1,\n sockjs_options\n );\n var xhr_streaming_transport = defineTransportStrategy(\n 'xhr_streaming',\n 'xhr_streaming',\n 1,\n sockjs_options,\n streaming_manager\n );\n var xdr_streaming_transport = defineTransportStrategy(\n 'xdr_streaming',\n 'xdr_streaming',\n 1,\n sockjs_options,\n streaming_manager\n );\n var xhr_polling_transport = defineTransportStrategy(\n 'xhr_polling',\n 'xhr_polling',\n 1,\n sockjs_options\n );\n var xdr_polling_transport = defineTransportStrategy(\n 'xdr_polling',\n 'xdr_polling',\n 1,\n sockjs_options\n );\n\n var ws_loop = new SequentialStrategy([ws_transport], timeouts);\n var wss_loop = new SequentialStrategy([wss_transport], timeouts);\n var sockjs_loop = new SequentialStrategy([sockjs_transport], timeouts);\n var streaming_loop = new SequentialStrategy(\n [\n new IfStrategy(\n testSupportsStrategy(xhr_streaming_transport),\n xhr_streaming_transport,\n xdr_streaming_transport\n )\n ],\n timeouts\n );\n var polling_loop = new SequentialStrategy(\n [\n new IfStrategy(\n testSupportsStrategy(xhr_polling_transport),\n xhr_polling_transport,\n xdr_polling_transport\n )\n ],\n timeouts\n );\n\n var http_loop = new SequentialStrategy(\n [\n new IfStrategy(\n testSupportsStrategy(streaming_loop),\n new BestConnectedEverStrategy([\n streaming_loop,\n new DelayedStrategy(polling_loop, { delay: 4000 })\n ]),\n polling_loop\n )\n ],\n timeouts\n );\n\n var http_fallback_loop = new IfStrategy(\n testSupportsStrategy(http_loop),\n http_loop,\n sockjs_loop\n );\n\n var wsStrategy;\n if (baseOptions.useTLS) {\n wsStrategy = new BestConnectedEverStrategy([\n ws_loop,\n new DelayedStrategy(http_fallback_loop, { delay: 2000 })\n ]);\n } else {\n wsStrategy = new BestConnectedEverStrategy([\n ws_loop,\n new DelayedStrategy(wss_loop, { delay: 2000 }),\n new DelayedStrategy(http_fallback_loop, { delay: 5000 })\n ]);\n }\n\n return new WebSocketPrioritizedCachedStrategy(\n new FirstConnectedStrategy(\n new IfStrategy(\n testSupportsStrategy(ws_transport),\n wsStrategy,\n http_fallback_loop\n )\n ),\n definedTransports,\n {\n ttl: 1800000,\n timeline: baseOptions.timeline,\n useTLS: baseOptions.useTLS\n }\n );\n};\n\nexport default getDefaultStrategy;\n","import { Dependencies } from '../dom/dependencies';\n\n/** Initializes the transport.\n *\n * Fetches resources if needed and then transitions to initialized.\n */\nexport default function() {\n var self = this;\n\n self.timeline.info(\n self.buildTimelineMessage({\n transport: self.name + (self.options.useTLS ? 's' : '')\n })\n );\n\n if (self.hooks.isInitialized()) {\n self.changeState('initialized');\n } else if (self.hooks.file) {\n self.changeState('initializing');\n Dependencies.load(\n self.hooks.file,\n { useTLS: self.options.useTLS },\n function(error, callback) {\n if (self.hooks.isInitialized()) {\n self.changeState('initialized');\n callback(true);\n } else {\n if (error) {\n self.onError(error);\n }\n self.onClose();\n callback(false);\n }\n }\n );\n } else {\n self.onClose();\n }\n}\n","import HTTPRequest from 'core/http/http_request';\nimport RequestHooks from 'core/http/request_hooks';\nimport Ajax from 'core/http/ajax';\nimport * as Errors from 'core/errors';\n\nvar hooks: RequestHooks = {\n getRequest: function(socket: HTTPRequest): Ajax {\n var xdr = new (window).XDomainRequest();\n xdr.ontimeout = function() {\n socket.emit('error', new Errors.RequestTimedOut());\n socket.close();\n };\n xdr.onerror = function(e) {\n socket.emit('error', e);\n socket.close();\n };\n xdr.onprogress = function() {\n if (xdr.responseText && xdr.responseText.length > 0) {\n socket.onChunk(200, xdr.responseText);\n }\n };\n xdr.onload = function() {\n if (xdr.responseText && xdr.responseText.length > 0) {\n socket.onChunk(200, xdr.responseText);\n }\n socket.emit('finished', 200);\n socket.close();\n };\n return xdr;\n },\n abortRequest: function(xdr: Ajax) {\n xdr.ontimeout = xdr.onerror = xdr.onprogress = xdr.onload = null;\n xdr.abort();\n }\n};\n\nexport default hooks;\n","import Runtime from 'runtime';\nimport RequestHooks from './request_hooks';\nimport Ajax from './ajax';\nimport { default as EventsDispatcher } from '../events/dispatcher';\n\nconst MAX_BUFFER_LENGTH = 256 * 1024;\n\nexport default class HTTPRequest extends EventsDispatcher {\n hooks: RequestHooks;\n method: string;\n url: string;\n position: number;\n xhr: Ajax;\n unloader: Function;\n\n constructor(hooks: RequestHooks, method: string, url: string) {\n super();\n this.hooks = hooks;\n this.method = method;\n this.url = url;\n }\n\n start(payload?: any) {\n this.position = 0;\n this.xhr = this.hooks.getRequest(this);\n\n this.unloader = () => {\n this.close();\n };\n Runtime.addUnloadListener(this.unloader);\n\n this.xhr.open(this.method, this.url, true);\n\n if (this.xhr.setRequestHeader) {\n this.xhr.setRequestHeader('Content-Type', 'application/json'); // ReactNative doesn't set this header by default.\n }\n this.xhr.send(payload);\n }\n\n close() {\n if (this.unloader) {\n Runtime.removeUnloadListener(this.unloader);\n this.unloader = null;\n }\n if (this.xhr) {\n this.hooks.abortRequest(this.xhr);\n this.xhr = null;\n }\n }\n\n onChunk(status: number, data: any) {\n while (true) {\n var chunk = this.advanceBuffer(data);\n if (chunk) {\n this.emit('chunk', { status: status, data: chunk });\n } else {\n break;\n }\n }\n if (this.isBufferTooLong(data)) {\n this.emit('buffer_too_long');\n }\n }\n\n private advanceBuffer(buffer: any[]): any {\n var unreadData = buffer.slice(this.position);\n var endOfLinePosition = unreadData.indexOf('\\n');\n\n if (endOfLinePosition !== -1) {\n this.position += endOfLinePosition + 1;\n return unreadData.slice(0, endOfLinePosition);\n } else {\n // chunk is not finished yet, don't move the buffer pointer\n return null;\n }\n }\n\n private isBufferTooLong(buffer: any): boolean {\n return this.position === buffer.length && buffer.length > MAX_BUFFER_LENGTH;\n }\n}\n","enum State {\n CONNECTING = 0,\n OPEN = 1,\n CLOSED = 3\n}\n\nexport default State;\n","import URLLocation from './url_location';\nimport State from './state';\nimport Socket from '../socket';\nimport SocketHooks from './socket_hooks';\nimport Util from '../util';\nimport Ajax from './ajax';\nimport HTTPRequest from './http_request';\nimport Runtime from 'runtime';\n\nvar autoIncrement = 1;\n\nclass HTTPSocket implements Socket {\n hooks: SocketHooks;\n session: string;\n location: URLLocation;\n readyState: State;\n stream: HTTPRequest;\n\n onopen: () => void;\n onerror: (error: any) => void;\n onclose: (closeEvent: any) => void;\n onmessage: (message: any) => void;\n onactivity: () => void;\n\n constructor(hooks: SocketHooks, url: string) {\n this.hooks = hooks;\n this.session = randomNumber(1000) + '/' + randomString(8);\n this.location = getLocation(url);\n this.readyState = State.CONNECTING;\n this.openStream();\n }\n\n send(payload: any) {\n return this.sendRaw(JSON.stringify([payload]));\n }\n\n ping() {\n this.hooks.sendHeartbeat(this);\n }\n\n close(code: any, reason: any) {\n this.onClose(code, reason, true);\n }\n\n /** For internal use only */\n sendRaw(payload: any): boolean {\n if (this.readyState === State.OPEN) {\n try {\n Runtime.createSocketRequest(\n 'POST',\n getUniqueURL(getSendURL(this.location, this.session))\n ).start(payload);\n return true;\n } catch (e) {\n return false;\n }\n } else {\n return false;\n }\n }\n\n /** For internal use only */\n reconnect() {\n this.closeStream();\n this.openStream();\n }\n\n /** For internal use only */\n onClose(code, reason, wasClean) {\n this.closeStream();\n this.readyState = State.CLOSED;\n if (this.onclose) {\n this.onclose({\n code: code,\n reason: reason,\n wasClean: wasClean\n });\n }\n }\n\n private onChunk(chunk) {\n if (chunk.status !== 200) {\n return;\n }\n if (this.readyState === State.OPEN) {\n this.onActivity();\n }\n\n var payload;\n var type = chunk.data.slice(0, 1);\n switch (type) {\n case 'o':\n payload = JSON.parse(chunk.data.slice(1) || '{}');\n this.onOpen(payload);\n break;\n case 'a':\n payload = JSON.parse(chunk.data.slice(1) || '[]');\n for (var i = 0; i < payload.length; i++) {\n this.onEvent(payload[i]);\n }\n break;\n case 'm':\n payload = JSON.parse(chunk.data.slice(1) || 'null');\n this.onEvent(payload);\n break;\n case 'h':\n this.hooks.onHeartbeat(this);\n break;\n case 'c':\n payload = JSON.parse(chunk.data.slice(1) || '[]');\n this.onClose(payload[0], payload[1], true);\n break;\n }\n }\n\n private onOpen(options) {\n if (this.readyState === State.CONNECTING) {\n if (options && options.hostname) {\n this.location.base = replaceHost(this.location.base, options.hostname);\n }\n this.readyState = State.OPEN;\n\n if (this.onopen) {\n this.onopen();\n }\n } else {\n this.onClose(1006, 'Server lost session', true);\n }\n }\n\n private onEvent(event) {\n if (this.readyState === State.OPEN && this.onmessage) {\n this.onmessage({ data: event });\n }\n }\n\n private onActivity() {\n if (this.onactivity) {\n this.onactivity();\n }\n }\n\n private onError(error) {\n if (this.onerror) {\n this.onerror(error);\n }\n }\n\n private openStream() {\n this.stream = Runtime.createSocketRequest(\n 'POST',\n getUniqueURL(this.hooks.getReceiveURL(this.location, this.session))\n );\n\n this.stream.bind('chunk', chunk => {\n this.onChunk(chunk);\n });\n this.stream.bind('finished', status => {\n this.hooks.onFinished(this, status);\n });\n this.stream.bind('buffer_too_long', () => {\n this.reconnect();\n });\n\n try {\n this.stream.start();\n } catch (error) {\n Util.defer(() => {\n this.onError(error);\n this.onClose(1006, 'Could not start streaming', false);\n });\n }\n }\n\n private closeStream() {\n if (this.stream) {\n this.stream.unbind_all();\n this.stream.close();\n this.stream = null;\n }\n }\n}\n\nfunction getLocation(url): URLLocation {\n var parts = /([^\\?]*)\\/*(\\??.*)/.exec(url);\n return {\n base: parts[1],\n queryString: parts[2]\n };\n}\n\nfunction getSendURL(url: URLLocation, session: string): string {\n return url.base + '/' + session + '/xhr_send';\n}\n\nfunction getUniqueURL(url: string): string {\n var separator = url.indexOf('?') === -1 ? '?' : '&';\n return url + separator + 't=' + +new Date() + '&n=' + autoIncrement++;\n}\n\nfunction replaceHost(url: string, hostname: string): string {\n var urlParts = /(https?:\\/\\/)([^\\/:]+)((\\/|:)?.*)/.exec(url);\n return urlParts[1] + hostname + urlParts[3];\n}\n\nfunction randomNumber(max: number): number {\n return Runtime.randomInt(max);\n}\n\nfunction randomString(length: number): string {\n var result = [];\n\n for (var i = 0; i < length; i++) {\n result.push(randomNumber(32).toString(32));\n }\n\n return result.join('');\n}\n\nexport default HTTPSocket;\n","import SocketHooks from './socket_hooks';\nimport HTTPSocket from './http_socket';\n\nvar hooks: SocketHooks = {\n getReceiveURL: function(url, session) {\n return url.base + '/' + session + '/xhr_streaming' + url.queryString;\n },\n onHeartbeat: function(socket) {\n socket.sendRaw('[]');\n },\n sendHeartbeat: function(socket) {\n socket.sendRaw('[]');\n },\n onFinished: function(socket, status) {\n socket.onClose(1006, 'Connection interrupted (' + status + ')', false);\n }\n};\n\nexport default hooks;\n","import SocketHooks from './socket_hooks';\nimport URLLocation from './url_location';\nimport HTTPSocket from './http_socket';\n\nvar hooks: SocketHooks = {\n getReceiveURL: function(url: URLLocation, session: string): string {\n return url.base + '/' + session + '/xhr' + url.queryString;\n },\n onHeartbeat: function() {\n // next HTTP request will reset server's activity timer\n },\n sendHeartbeat: function(socket) {\n socket.sendRaw('[]');\n },\n onFinished: function(socket, status) {\n if (status === 200) {\n socket.reconnect();\n } else {\n socket.onClose(1006, 'Connection interrupted (' + status + ')', false);\n }\n }\n};\n\nexport default hooks;\n","import HTTPRequest from 'core/http/http_request';\nimport RequestHooks from 'core/http/request_hooks';\nimport Ajax from 'core/http/ajax';\nimport Runtime from 'runtime';\n\nvar hooks: RequestHooks = {\n getRequest: function(socket: HTTPRequest): Ajax {\n var Constructor = Runtime.getXHRAPI();\n var xhr = new Constructor();\n xhr.onreadystatechange = xhr.onprogress = function() {\n switch (xhr.readyState) {\n case 3:\n if (xhr.responseText && xhr.responseText.length > 0) {\n socket.onChunk(xhr.status, xhr.responseText);\n }\n break;\n case 4:\n // this happens only on errors, never after calling close\n if (xhr.responseText && xhr.responseText.length > 0) {\n socket.onChunk(xhr.status, xhr.responseText);\n }\n socket.emit('finished', xhr.status);\n socket.close();\n break;\n }\n };\n return xhr;\n },\n abortRequest: function(xhr: Ajax) {\n xhr.onreadystatechange = null;\n xhr.abort();\n }\n};\n\nexport default hooks;\n","import HTTPRequest from 'core/http/http_request';\nimport HTTPSocket from 'core/http/http_socket';\nimport SocketHooks from 'core/http/socket_hooks';\nimport RequestHooks from 'core/http/request_hooks';\nimport streamingHooks from 'core/http/http_streaming_socket';\nimport pollingHooks from 'core/http/http_polling_socket';\nimport xhrHooks from './http_xhr_request';\nimport HTTPFactory from 'core/http/http_factory';\n\nvar HTTP: HTTPFactory = {\n createStreamingSocket(url: string): HTTPSocket {\n return this.createSocket(streamingHooks, url);\n },\n\n createPollingSocket(url: string): HTTPSocket {\n return this.createSocket(pollingHooks, url);\n },\n\n createSocket(hooks: SocketHooks, url: string): HTTPSocket {\n return new HTTPSocket(hooks, url);\n },\n\n createXHR(method: string, url: string): HTTPRequest {\n return this.createRequest(xhrHooks, method, url);\n },\n\n createRequest(hooks: RequestHooks, method: string, url: string): HTTPRequest {\n return new HTTPRequest(hooks, method, url);\n }\n};\n\nexport default HTTP;\n","import xdrHooks from './http_xdomain_request';\nimport HTTP from 'isomorphic/http/http';\n\nHTTP.createXDR = function(method, url) {\n return this.createRequest(xdrHooks, method, url);\n};\n\nexport default HTTP;\n","import Browser from './browser';\nimport { Dependencies, DependenciesReceivers } from './dom/dependencies';\nimport { AuthTransport, AuthTransports } from 'core/auth/auth_transports';\nimport xhrAuth from 'isomorphic/auth/xhr_auth';\nimport jsonpAuth from './auth/jsonp_auth';\nimport TimelineTransport from 'core/timeline/timeline_transport';\nimport TimelineSender from 'core/timeline/timeline_sender';\nimport ScriptRequest from './dom/script_request';\nimport JSONPRequest from './dom/jsonp_request';\nimport * as Collections from 'core/utils/collections';\nimport { ScriptReceivers } from './dom/script_receiver_factory';\nimport jsonpTimeline from './timeline/jsonp_timeline';\nimport Transports from './transports/transports';\nimport Ajax from 'core/http/ajax';\nimport { Network } from './net_info';\nimport getDefaultStrategy from './default_strategy';\nimport transportConnectionInitializer from './transports/transport_connection_initializer';\nimport HTTPFactory from './http/http';\nimport HTTPRequest from 'core/http/http_request';\n\nvar Runtime: Browser = {\n // for jsonp auth\n nextAuthCallbackID: 1,\n auth_callbacks: {},\n ScriptReceivers,\n DependenciesReceivers,\n getDefaultStrategy,\n Transports,\n transportConnectionInitializer,\n HTTPFactory,\n\n TimelineTransport: jsonpTimeline,\n\n getXHRAPI() {\n return window.XMLHttpRequest;\n },\n\n getWebSocketAPI() {\n return window.WebSocket || window.MozWebSocket;\n },\n\n setup(PusherClass): void {\n (window).Pusher = PusherClass; // JSONp requires Pusher to be in the global scope.\n var initializeOnDocumentBody = () => {\n this.onDocumentBody(PusherClass.ready);\n };\n if (!(window).JSON) {\n Dependencies.load('json2', {}, initializeOnDocumentBody);\n } else {\n initializeOnDocumentBody();\n }\n },\n\n getDocument(): Document {\n return document;\n },\n\n getProtocol(): string {\n return this.getDocument().location.protocol;\n },\n\n getAuthorizers(): AuthTransports {\n return { ajax: xhrAuth, jsonp: jsonpAuth };\n },\n\n onDocumentBody(callback: Function) {\n if (document.body) {\n callback();\n } else {\n setTimeout(() => {\n this.onDocumentBody(callback);\n }, 0);\n }\n },\n\n createJSONPRequest(url: string, data: any): JSONPRequest {\n return new JSONPRequest(url, data);\n },\n\n createScriptRequest(src: string): ScriptRequest {\n return new ScriptRequest(src);\n },\n\n getLocalStorage() {\n try {\n return window.localStorage;\n } catch (e) {\n return undefined;\n }\n },\n\n createXHR(): Ajax {\n if (this.getXHRAPI()) {\n return this.createXMLHttpRequest();\n } else {\n return this.createMicrosoftXHR();\n }\n },\n\n createXMLHttpRequest(): Ajax {\n var Constructor = this.getXHRAPI();\n return new Constructor();\n },\n\n createMicrosoftXHR(): Ajax {\n return new ActiveXObject('Microsoft.XMLHTTP');\n },\n\n getNetwork() {\n return Network;\n },\n\n createWebSocket(url: string): any {\n var Constructor = this.getWebSocketAPI();\n return new Constructor(url);\n },\n\n createSocketRequest(method: string, url: string): HTTPRequest {\n if (this.isXHRSupported()) {\n return this.HTTPFactory.createXHR(method, url);\n } else if (this.isXDRSupported(url.indexOf('https:') === 0)) {\n return this.HTTPFactory.createXDR(method, url);\n } else {\n throw 'Cross-origin HTTP requests are not supported';\n }\n },\n\n isXHRSupported(): boolean {\n var Constructor = this.getXHRAPI();\n return (\n Boolean(Constructor) && new Constructor().withCredentials !== undefined\n );\n },\n\n isXDRSupported(useTLS?: boolean): boolean {\n var protocol = useTLS ? 'https:' : 'http:';\n var documentProtocol = this.getProtocol();\n return (\n Boolean(window['XDomainRequest']) && documentProtocol === protocol\n );\n },\n\n addUnloadListener(listener: any) {\n if (window.addEventListener !== undefined) {\n window.addEventListener('unload', listener, false);\n } else if (window.attachEvent !== undefined) {\n window.attachEvent('onunload', listener);\n }\n },\n\n removeUnloadListener(listener: any) {\n if (window.addEventListener !== undefined) {\n window.removeEventListener('unload', listener, false);\n } else if (window.detachEvent !== undefined) {\n window.detachEvent('onunload', listener);\n }\n },\n\n randomInt(max: number): number {\n /**\n * Return values in the range of [0, 1[\n */\n const random = function() {\n const crypto = window.crypto || window['msCrypto'];\n const random = crypto.getRandomValues(new Uint32Array(1))[0];\n\n return random / 2 ** 32;\n };\n\n return Math.floor(random() * max);\n }\n};\n\nexport default Runtime;\n","enum TimelineLevel {\n ERROR = 3,\n INFO = 6,\n DEBUG = 7\n}\n\nexport default TimelineLevel;\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport { default as Level } from './level';\n\nexport interface TimelineOptions {\n level?: Level;\n limit?: number;\n version?: string;\n cluster?: string;\n features?: string[];\n params?: any;\n}\n\nexport default class Timeline {\n key: string;\n session: number;\n events: any[];\n options: TimelineOptions;\n sent: number;\n uniqueID: number;\n\n constructor(key: string, session: number, options: TimelineOptions) {\n this.key = key;\n this.session = session;\n this.events = [];\n this.options = options || {};\n this.sent = 0;\n this.uniqueID = 0;\n }\n\n log(level, event) {\n if (level <= this.options.level) {\n this.events.push(\n Collections.extend({}, event, { timestamp: Util.now() })\n );\n if (this.options.limit && this.events.length > this.options.limit) {\n this.events.shift();\n }\n }\n }\n\n error(event) {\n this.log(Level.ERROR, event);\n }\n\n info(event) {\n this.log(Level.INFO, event);\n }\n\n debug(event) {\n this.log(Level.DEBUG, event);\n }\n\n isEmpty() {\n return this.events.length === 0;\n }\n\n send(sendfn, callback) {\n var data = Collections.extend(\n {\n session: this.session,\n bundle: this.sent + 1,\n key: this.key,\n lib: 'js',\n version: this.options.version,\n cluster: this.options.cluster,\n features: this.options.features,\n timeline: this.events\n },\n this.options.params\n );\n\n this.events = [];\n sendfn(data, (error, result) => {\n if (!error) {\n this.sent++;\n }\n if (callback) {\n callback(error, result);\n }\n });\n\n return true;\n }\n\n generateUniqueID(): number {\n this.uniqueID++;\n return this.uniqueID;\n }\n}\n","import Factory from '../utils/factory';\nimport Util from '../util';\nimport * as Errors from '../errors';\nimport * as Collections from '../utils/collections';\nimport Strategy from './strategy';\nimport Transport from '../transports/transport';\nimport StrategyOptions from './strategy_options';\nimport Handshake from '../connection/handshake';\n\n/** Provides a strategy interface for transports.\n *\n * @param {String} name\n * @param {Number} priority\n * @param {Class} transport\n * @param {Object} options\n */\nexport default class TransportStrategy implements Strategy {\n name: string;\n priority: number;\n transport: Transport;\n options: StrategyOptions;\n\n constructor(\n name: string,\n priority: number,\n transport: Transport,\n options: StrategyOptions\n ) {\n this.name = name;\n this.priority = priority;\n this.transport = transport;\n this.options = options || {};\n }\n\n /** Returns whether the transport is supported in the browser.\n *\n * @returns {Boolean}\n */\n isSupported(): boolean {\n return this.transport.isSupported({\n useTLS: this.options.useTLS\n });\n }\n\n /** Launches a connection attempt and returns a strategy runner.\n *\n * @param {Function} callback\n * @return {Object} strategy runner\n */\n connect(minPriority: number, callback: Function) {\n if (!this.isSupported()) {\n return failAttempt(new Errors.UnsupportedStrategy(), callback);\n } else if (this.priority < minPriority) {\n return failAttempt(new Errors.TransportPriorityTooLow(), callback);\n }\n\n var connected = false;\n var transport = this.transport.createConnection(\n this.name,\n this.priority,\n this.options.key,\n this.options\n );\n var handshake = null;\n\n var onInitialized = function() {\n transport.unbind('initialized', onInitialized);\n transport.connect();\n };\n var onOpen = function() {\n handshake = Factory.createHandshake(transport, function(result) {\n connected = true;\n unbindListeners();\n callback(null, result);\n });\n };\n var onError = function(error) {\n unbindListeners();\n callback(error);\n };\n var onClosed = function() {\n unbindListeners();\n var serializedTransport;\n\n // The reason for this try/catch block is that on React Native\n // the WebSocket object is circular. Therefore transport.socket will\n // throw errors upon stringification. Collections.safeJSONStringify\n // discards circular references when serializing.\n serializedTransport = Collections.safeJSONStringify(transport);\n callback(new Errors.TransportClosed(serializedTransport));\n };\n\n var unbindListeners = function() {\n transport.unbind('initialized', onInitialized);\n transport.unbind('open', onOpen);\n transport.unbind('error', onError);\n transport.unbind('closed', onClosed);\n };\n\n transport.bind('initialized', onInitialized);\n transport.bind('open', onOpen);\n transport.bind('error', onError);\n transport.bind('closed', onClosed);\n\n // connect will be called automatically after initialization\n transport.initialize();\n\n return {\n abort: () => {\n if (connected) {\n return;\n }\n unbindListeners();\n if (handshake) {\n handshake.close();\n } else {\n transport.close();\n }\n },\n forceMinPriority: p => {\n if (connected) {\n return;\n }\n if (this.priority < p) {\n if (handshake) {\n handshake.close();\n } else {\n transport.close();\n }\n }\n }\n };\n }\n}\n\nfunction failAttempt(error: Error, callback: Function) {\n Util.defer(function() {\n callback(error);\n });\n return {\n abort: function() {},\n forceMinPriority: function() {}\n };\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport TransportManager from '../transports/transport_manager';\nimport * as Errors from '../errors';\nimport Strategy from './strategy';\nimport TransportStrategy from './transport_strategy';\nimport StrategyOptions from '../strategies/strategy_options';\nimport { Config } from '../config';\nimport Runtime from 'runtime';\n\nconst { Transports } = Runtime;\n\nexport var defineTransport = function(\n config: Config,\n name: string,\n type: string,\n priority: number,\n options: StrategyOptions,\n manager?: TransportManager\n): Strategy {\n var transportClass = Transports[type];\n if (!transportClass) {\n throw new Errors.UnsupportedTransport(type);\n }\n\n var enabled =\n (!config.enabledTransports ||\n Collections.arrayIndexOf(config.enabledTransports, name) !== -1) &&\n (!config.disabledTransports ||\n Collections.arrayIndexOf(config.disabledTransports, name) === -1);\n\n var transport;\n if (enabled) {\n options = Object.assign(\n { ignoreNullOrigin: config.ignoreNullOrigin },\n options\n );\n\n transport = new TransportStrategy(\n name,\n priority,\n manager ? manager.getAssistant(transportClass) : transportClass,\n options\n );\n } else {\n transport = UnsupportedStrategy;\n }\n\n return transport;\n};\n\nvar UnsupportedStrategy: Strategy = {\n isSupported: function() {\n return false;\n },\n connect: function(_, callback) {\n var deferred = Util.defer(function() {\n callback(new Errors.UnsupportedStrategy());\n });\n return {\n abort: function() {\n deferred.ensureAborted();\n },\n forceMinPriority: function() {}\n };\n }\n};\n","import ConnectionManager from './connection/connection_manager';\nimport {\n ChannelAuthorizationOptions,\n UserAuthenticationOptions\n} from './auth/options';\nimport {\n ChannelAuthorizerGenerator,\n DeprecatedAuthOptions\n} from './auth/deprecated_channel_authorizer';\nimport { AuthTransport, Transport } from './config';\nimport * as nacl from 'tweetnacl';\nimport Logger from './logger';\n\nexport interface Options {\n activityTimeout?: number;\n\n auth?: DeprecatedAuthOptions; // DEPRECATED use channelAuthorization instead\n authEndpoint?: string; // DEPRECATED use channelAuthorization instead\n authTransport?: AuthTransport; // DEPRECATED use channelAuthorization instead\n authorizer?: ChannelAuthorizerGenerator; // DEPRECATED use channelAuthorization instead\n\n channelAuthorization?: ChannelAuthorizationOptions;\n userAuthentication?: UserAuthenticationOptions;\n\n cluster: string;\n enableStats?: boolean;\n disableStats?: boolean;\n disabledTransports?: Transport[];\n enabledTransports?: Transport[];\n forceTLS?: boolean;\n httpHost?: string;\n httpPath?: string;\n httpPort?: number;\n httpsPort?: number;\n ignoreNullOrigin?: boolean;\n nacl?: nacl;\n pongTimeout?: number;\n statsHost?: string;\n timelineParams?: any;\n unavailableTimeout?: number;\n wsHost?: string;\n wsPath?: string;\n wsPort?: number;\n wssPort?: number;\n}\n\nexport interface ClusterOptions {\n appKey: string;\n cluster: string;\n}\n\nexport function validateOptions(options) {\n if (options == null) {\n throw 'You must pass an options object';\n }\n if (options.cluster == null) {\n throw 'Options object must provide a cluster';\n }\n if ('disableStats' in options) {\n Logger.warn(\n 'The disableStats option is deprecated in favor of enableStats'\n );\n }\n}\n","import {\n UserAuthenticationCallback,\n InternalAuthOptions,\n UserAuthenticationHandler,\n UserAuthenticationRequestParams,\n AuthRequestType\n} from './options';\n\nimport Runtime from 'runtime';\n\nconst composeChannelQuery = (\n params: UserAuthenticationRequestParams,\n authOptions: InternalAuthOptions\n) => {\n var query = 'socket_id=' + encodeURIComponent(params.socketId);\n\n for (var key in authOptions.params) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(authOptions.params[key]);\n }\n\n if (authOptions.paramsProvider != null) {\n let dynamicParams = authOptions.paramsProvider();\n for (var key in dynamicParams) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(dynamicParams[key]);\n }\n }\n\n return query;\n};\n\nconst UserAuthenticator = (\n authOptions: InternalAuthOptions\n): UserAuthenticationHandler => {\n if (typeof Runtime.getAuthorizers()[authOptions.transport] === 'undefined') {\n throw `'${authOptions.transport}' is not a recognized auth transport`;\n }\n\n return (\n params: UserAuthenticationRequestParams,\n callback: UserAuthenticationCallback\n ) => {\n const query = composeChannelQuery(params, authOptions);\n\n Runtime.getAuthorizers()[authOptions.transport](\n Runtime,\n query,\n authOptions,\n AuthRequestType.UserAuthentication,\n callback\n );\n };\n};\n\nexport default UserAuthenticator;\n","import {\n AuthRequestType,\n InternalAuthOptions,\n ChannelAuthorizationHandler,\n ChannelAuthorizationRequestParams,\n ChannelAuthorizationCallback\n} from './options';\n\nimport Runtime from 'runtime';\n\nconst composeChannelQuery = (\n params: ChannelAuthorizationRequestParams,\n authOptions: InternalAuthOptions\n) => {\n var query = 'socket_id=' + encodeURIComponent(params.socketId);\n\n query += '&channel_name=' + encodeURIComponent(params.channelName);\n\n for (var key in authOptions.params) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(authOptions.params[key]);\n }\n\n if (authOptions.paramsProvider != null) {\n let dynamicParams = authOptions.paramsProvider();\n for (var key in dynamicParams) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(dynamicParams[key]);\n }\n }\n\n return query;\n};\n\nconst ChannelAuthorizer = (\n authOptions: InternalAuthOptions\n): ChannelAuthorizationHandler => {\n if (typeof Runtime.getAuthorizers()[authOptions.transport] === 'undefined') {\n throw `'${authOptions.transport}' is not a recognized auth transport`;\n }\n\n return (\n params: ChannelAuthorizationRequestParams,\n callback: ChannelAuthorizationCallback\n ) => {\n const query = composeChannelQuery(params, authOptions);\n\n Runtime.getAuthorizers()[authOptions.transport](\n Runtime,\n query,\n authOptions,\n AuthRequestType.ChannelAuthorization,\n callback\n );\n };\n};\n\nexport default ChannelAuthorizer;\n","import Channel from '../channels/channel';\nimport {\n ChannelAuthorizationCallback,\n ChannelAuthorizationHandler,\n ChannelAuthorizationRequestParams,\n InternalAuthOptions\n} from './options';\n\nexport interface DeprecatedChannelAuthorizer {\n authorize(socketId: string, callback: ChannelAuthorizationCallback): void;\n}\n\nexport interface ChannelAuthorizerGenerator {\n (\n channel: Channel,\n options: DeprecatedAuthorizerOptions\n ): DeprecatedChannelAuthorizer;\n}\n\nexport interface DeprecatedAuthOptions {\n params?: any;\n headers?: any;\n}\n\nexport interface DeprecatedAuthorizerOptions {\n authTransport: 'ajax' | 'jsonp';\n authEndpoint: string;\n auth?: DeprecatedAuthOptions;\n}\n\nexport const ChannelAuthorizerProxy = (\n pusher,\n authOptions: InternalAuthOptions,\n channelAuthorizerGenerator: ChannelAuthorizerGenerator\n): ChannelAuthorizationHandler => {\n const deprecatedAuthorizerOptions: DeprecatedAuthorizerOptions = {\n authTransport: authOptions.transport,\n authEndpoint: authOptions.endpoint,\n auth: {\n params: authOptions.params,\n headers: authOptions.headers\n }\n };\n return (\n params: ChannelAuthorizationRequestParams,\n callback: ChannelAuthorizationCallback\n ) => {\n const channel = pusher.channel(params.channelName);\n // This line creates a new channel authorizer every time.\n // In the past, this was only done once per channel and reused.\n // We can do that again if we want to keep this behavior intact.\n const channelAuthorizer: DeprecatedChannelAuthorizer = channelAuthorizerGenerator(\n channel,\n deprecatedAuthorizerOptions\n );\n channelAuthorizer.authorize(params.socketId, callback);\n };\n};\n","import { Options } from './options';\nimport Defaults from './defaults';\nimport {\n ChannelAuthorizationHandler,\n UserAuthenticationHandler,\n ChannelAuthorizationOptions,\n AuthOptionsT,\n CustomAuthOptions\n} from './auth/options';\nimport UserAuthenticator from './auth/user_authenticator';\nimport ChannelAuthorizer from './auth/channel_authorizer';\nimport { ChannelAuthorizerProxy } from './auth/deprecated_channel_authorizer';\nimport Runtime from 'runtime';\nimport * as nacl from 'tweetnacl';\n\nexport type AuthTransport = 'ajax' | 'jsonp';\nexport type Transport =\n | 'ws'\n | 'wss'\n | 'xhr_streaming'\n | 'xhr_polling'\n | 'sockjs';\n\nexport interface Config {\n // these are all 'required' config parameters, it's not necessary for the user\n // to set them, but they have configured defaults.\n activityTimeout: number;\n enableStats: boolean;\n httpHost: string;\n httpPath: string;\n httpPort: number;\n httpsPort: number;\n pongTimeout: number;\n statsHost: string;\n unavailableTimeout: number;\n useTLS: boolean;\n wsHost: string;\n wsPath: string;\n wsPort: number;\n wssPort: number;\n userAuthenticator: UserAuthenticationHandler;\n channelAuthorizer: ChannelAuthorizationHandler;\n\n // these are all optional parameters or overrrides. The customer can set these\n // but it's not strictly necessary\n forceTLS?: boolean;\n cluster?: string;\n disabledTransports?: Transport[];\n enabledTransports?: Transport[];\n ignoreNullOrigin?: boolean;\n nacl?: nacl;\n timelineParams?: any;\n}\n\n// getConfig mainly sets the defaults for the options that are not provided\nexport function getConfig(opts: Options, pusher): Config {\n let config: Config = {\n activityTimeout: opts.activityTimeout || Defaults.activityTimeout,\n cluster: opts.cluster,\n httpPath: opts.httpPath || Defaults.httpPath,\n httpPort: opts.httpPort || Defaults.httpPort,\n httpsPort: opts.httpsPort || Defaults.httpsPort,\n pongTimeout: opts.pongTimeout || Defaults.pongTimeout,\n statsHost: opts.statsHost || Defaults.stats_host,\n unavailableTimeout: opts.unavailableTimeout || Defaults.unavailableTimeout,\n wsPath: opts.wsPath || Defaults.wsPath,\n wsPort: opts.wsPort || Defaults.wsPort,\n wssPort: opts.wssPort || Defaults.wssPort,\n\n enableStats: getEnableStatsConfig(opts),\n httpHost: getHttpHost(opts),\n useTLS: shouldUseTLS(opts),\n wsHost: getWebsocketHost(opts),\n\n userAuthenticator: buildUserAuthenticator(opts),\n channelAuthorizer: buildChannelAuthorizer(opts, pusher)\n };\n\n if ('disabledTransports' in opts)\n config.disabledTransports = opts.disabledTransports;\n if ('enabledTransports' in opts)\n config.enabledTransports = opts.enabledTransports;\n if ('ignoreNullOrigin' in opts)\n config.ignoreNullOrigin = opts.ignoreNullOrigin;\n if ('timelineParams' in opts) config.timelineParams = opts.timelineParams;\n if ('nacl' in opts) {\n config.nacl = opts.nacl;\n }\n\n return config;\n}\n\nfunction getHttpHost(opts: Options): string {\n if (opts.httpHost) {\n return opts.httpHost;\n }\n if (opts.cluster) {\n return `sockjs-${opts.cluster}.pusher.com`;\n }\n return Defaults.httpHost;\n}\n\nfunction getWebsocketHost(opts: Options): string {\n if (opts.wsHost) {\n return opts.wsHost;\n }\n return getWebsocketHostFromCluster(opts.cluster);\n}\n\nfunction getWebsocketHostFromCluster(cluster: string): string {\n return `ws-${cluster}.pusher.com`;\n}\n\nfunction shouldUseTLS(opts: Options): boolean {\n if (Runtime.getProtocol() === 'https:') {\n return true;\n } else if (opts.forceTLS === false) {\n return false;\n }\n return true;\n}\n\n// if enableStats is set take the value\n// if disableStats is set take the inverse\n// otherwise default to false\nfunction getEnableStatsConfig(opts: Options): boolean {\n if ('enableStats' in opts) {\n return opts.enableStats;\n }\n if ('disableStats' in opts) {\n return !opts.disableStats;\n }\n return false;\n}\n\nconst hasCustomHandler = (\n auth: AuthOptionsT\n): auth is CustomAuthOptions => {\n return 'customHandler' in auth && auth['customHandler'] != null;\n};\n\nfunction buildUserAuthenticator(opts: Options): UserAuthenticationHandler {\n const userAuthentication = {\n ...Defaults.userAuthentication,\n ...opts.userAuthentication\n };\n\n if (hasCustomHandler(userAuthentication)) {\n return userAuthentication['customHandler'];\n }\n\n return UserAuthenticator(userAuthentication);\n}\n\nfunction buildChannelAuth(opts: Options, pusher): ChannelAuthorizationOptions {\n let channelAuthorization: ChannelAuthorizationOptions;\n if ('channelAuthorization' in opts) {\n channelAuthorization = {\n ...Defaults.channelAuthorization,\n ...opts.channelAuthorization\n };\n } else {\n channelAuthorization = {\n transport: opts.authTransport || Defaults.authTransport,\n endpoint: opts.authEndpoint || Defaults.authEndpoint\n };\n\n if ('auth' in opts) {\n if ('params' in opts.auth) channelAuthorization.params = opts.auth.params;\n if ('headers' in opts.auth)\n channelAuthorization.headers = opts.auth.headers;\n }\n\n if ('authorizer' in opts) {\n return {\n customHandler: ChannelAuthorizerProxy(\n pusher,\n channelAuthorization,\n opts.authorizer\n )\n };\n }\n }\n return channelAuthorization;\n}\n\nfunction buildChannelAuthorizer(\n opts: Options,\n pusher\n): ChannelAuthorizationHandler {\n const channelAuthorization = buildChannelAuth(opts, pusher);\n\n if (hasCustomHandler(channelAuthorization)) {\n return channelAuthorization['customHandler'];\n }\n\n return ChannelAuthorizer(channelAuthorization);\n}\n","import Logger from './logger';\nimport Pusher from './pusher';\nimport EventsDispatcher from './events/dispatcher';\n\nexport default class WatchlistFacade extends EventsDispatcher {\n private pusher: Pusher;\n\n public constructor(pusher: Pusher) {\n super(function(eventName, data) {\n Logger.debug(`No callbacks on watchlist events for ${eventName}`);\n });\n\n this.pusher = pusher;\n this.bindWatchlistInternalEvent();\n }\n\n handleEvent(pusherEvent) {\n pusherEvent.data.events.forEach(watchlistEvent => {\n this.emit(watchlistEvent.name, watchlistEvent);\n });\n }\n\n private bindWatchlistInternalEvent() {\n this.pusher.connection.bind('message', pusherEvent => {\n var eventName = pusherEvent.event;\n if (eventName === 'pusher_internal:watchlist_events') {\n this.handleEvent(pusherEvent);\n }\n });\n }\n}\n","function flatPromise() {\n let resolve, reject;\n const promise = new Promise((res, rej) => {\n resolve = res;\n reject = rej;\n });\n return { promise, resolve, reject };\n}\n\nexport default flatPromise;\n","import Pusher from './pusher';\nimport Logger from './logger';\nimport {\n UserAuthenticationData,\n UserAuthenticationCallback\n} from './auth/options';\nimport Channel from './channels/channel';\nimport WatchlistFacade from './watchlist';\nimport EventsDispatcher from './events/dispatcher';\nimport flatPromise from './utils/flat_promise';\n\nexport default class UserFacade extends EventsDispatcher {\n pusher: Pusher;\n signin_requested: boolean = false;\n user_data: any = null;\n serverToUserChannel: Channel = null;\n signinDonePromise: Promise = null;\n watchlist: WatchlistFacade;\n private _signinDoneResolve: Function = null;\n\n public constructor(pusher: Pusher) {\n super(function(eventName, data) {\n Logger.debug('No callbacks on user for ' + eventName);\n });\n this.pusher = pusher;\n this.pusher.connection.bind('state_change', ({ previous, current }) => {\n if (previous !== 'connected' && current === 'connected') {\n this._signin();\n }\n if (previous === 'connected' && current !== 'connected') {\n this._cleanup();\n this._newSigninPromiseIfNeeded();\n }\n });\n\n this.watchlist = new WatchlistFacade(pusher);\n\n this.pusher.connection.bind('message', event => {\n var eventName = event.event;\n if (eventName === 'pusher:signin_success') {\n this._onSigninSuccess(event.data);\n }\n if (\n this.serverToUserChannel &&\n this.serverToUserChannel.name === event.channel\n ) {\n this.serverToUserChannel.handleEvent(event);\n }\n });\n }\n\n public signin() {\n if (this.signin_requested) {\n return;\n }\n\n this.signin_requested = true;\n this._signin();\n }\n\n private _signin() {\n if (!this.signin_requested) {\n return;\n }\n\n this._newSigninPromiseIfNeeded();\n\n if (this.pusher.connection.state !== 'connected') {\n // Signin will be attempted when the connection is connected\n return;\n }\n\n this.pusher.config.userAuthenticator(\n {\n socketId: this.pusher.connection.socket_id\n },\n this._onAuthorize\n );\n }\n\n private _onAuthorize: UserAuthenticationCallback = (\n err,\n authData: UserAuthenticationData\n ) => {\n if (err) {\n Logger.warn(`Error during signin: ${err}`);\n this._cleanup();\n return;\n }\n\n this.pusher.send_event('pusher:signin', {\n auth: authData.auth,\n user_data: authData.user_data\n });\n\n // Later when we get pusher:singin_success event, the user will be marked as signed in\n };\n\n private _onSigninSuccess(data: any) {\n try {\n this.user_data = JSON.parse(data.user_data);\n } catch (e) {\n Logger.error(`Failed parsing user data after signin: ${data.user_data}`);\n this._cleanup();\n return;\n }\n\n if (typeof this.user_data.id !== 'string' || this.user_data.id === '') {\n Logger.error(\n `user_data doesn't contain an id. user_data: ${this.user_data}`\n );\n this._cleanup();\n return;\n }\n\n // Signin succeeded\n this._signinDoneResolve();\n this._subscribeChannels();\n }\n\n private _subscribeChannels() {\n const ensure_subscribed = channel => {\n if (channel.subscriptionPending && channel.subscriptionCancelled) {\n channel.reinstateSubscription();\n } else if (\n !channel.subscriptionPending &&\n this.pusher.connection.state === 'connected'\n ) {\n channel.subscribe();\n }\n };\n\n this.serverToUserChannel = new Channel(\n `#server-to-user-${this.user_data.id}`,\n this.pusher\n );\n this.serverToUserChannel.bind_global((eventName, data) => {\n if (\n eventName.indexOf('pusher_internal:') === 0 ||\n eventName.indexOf('pusher:') === 0\n ) {\n // ignore internal events\n return;\n }\n this.emit(eventName, data);\n });\n ensure_subscribed(this.serverToUserChannel);\n }\n\n private _cleanup() {\n this.user_data = null;\n if (this.serverToUserChannel) {\n this.serverToUserChannel.unbind_all();\n this.serverToUserChannel.disconnect();\n this.serverToUserChannel = null;\n }\n\n if (this.signin_requested) {\n // If signin is in progress and cleanup is called,\n // Mark the current signin process as done.\n this._signinDoneResolve();\n }\n }\n\n private _newSigninPromiseIfNeeded() {\n if (!this.signin_requested) {\n return;\n }\n\n // If there is a promise and it is not resolved, return without creating a new one.\n if (this.signinDonePromise && !(this.signinDonePromise as any).done) {\n return;\n }\n\n // This promise is never rejected.\n // It gets resolved when the signin process is done whether it failed or succeeded\n const { promise, resolve, reject: _ } = flatPromise();\n (promise as any).done = false;\n const setDone = () => {\n (promise as any).done = true;\n };\n promise.then(setDone).catch(setDone);\n this.signinDonePromise = promise;\n this._signinDoneResolve = resolve;\n }\n}\n","import AbstractRuntime from '../runtimes/interface';\nimport Runtime from 'runtime';\nimport * as Collections from './utils/collections';\nimport Channels from './channels/channels';\nimport Channel from './channels/channel';\nimport { default as EventsDispatcher } from './events/dispatcher';\nimport Timeline from './timeline/timeline';\nimport TimelineSender from './timeline/timeline_sender';\nimport TimelineLevel from './timeline/level';\nimport { defineTransport } from './strategies/strategy_builder';\nimport ConnectionManager from './connection/connection_manager';\nimport { PeriodicTimer } from './utils/timers';\nimport Defaults from './defaults';\nimport Logger from './logger';\nimport Factory from './utils/factory';\nimport { Options, ClusterOptions, validateOptions } from './options';\nimport { Config, getConfig } from './config';\nimport StrategyOptions from './strategies/strategy_options';\nimport UserFacade from './user';\n\nexport default class Pusher {\n /* STATIC PROPERTIES */\n static instances: Pusher[] = [];\n static isReady: boolean = false;\n static logToConsole: boolean = false;\n\n // for jsonp\n static Runtime: AbstractRuntime = Runtime;\n static ScriptReceivers: any = (Runtime).ScriptReceivers;\n static DependenciesReceivers: any = (Runtime).DependenciesReceivers;\n static auth_callbacks: any = (Runtime).auth_callbacks;\n\n static ready() {\n Pusher.isReady = true;\n for (var i = 0, l = Pusher.instances.length; i < l; i++) {\n Pusher.instances[i].connect();\n }\n }\n\n static log: (message: any) => void;\n\n private static getClientFeatures(): string[] {\n return Collections.keys(\n Collections.filterObject({ ws: Runtime.Transports.ws }, function(t) {\n return t.isSupported({});\n })\n );\n }\n\n /* INSTANCE PROPERTIES */\n key: string;\n options: Options;\n config: Config;\n channels: Channels;\n global_emitter: EventsDispatcher;\n sessionID: number;\n timeline: Timeline;\n timelineSender: TimelineSender;\n connection: ConnectionManager;\n timelineSenderTimer: PeriodicTimer;\n user: UserFacade;\n constructor(app_key: string, options: Options) {\n checkAppKey(app_key);\n validateOptions(options);\n this.key = app_key;\n this.options = options;\n this.config = getConfig(this.options, this);\n\n this.channels = Factory.createChannels();\n this.global_emitter = new EventsDispatcher();\n this.sessionID = Runtime.randomInt(1000000000);\n\n this.timeline = new Timeline(this.key, this.sessionID, {\n cluster: this.config.cluster,\n features: Pusher.getClientFeatures(),\n params: this.config.timelineParams || {},\n limit: 50,\n level: TimelineLevel.INFO,\n version: Defaults.VERSION\n });\n if (this.config.enableStats) {\n this.timelineSender = Factory.createTimelineSender(this.timeline, {\n host: this.config.statsHost,\n path: '/timeline/v2/' + Runtime.TimelineTransport.name\n });\n }\n\n var getStrategy = (options: StrategyOptions) => {\n return Runtime.getDefaultStrategy(this.config, options, defineTransport);\n };\n\n this.connection = Factory.createConnectionManager(this.key, {\n getStrategy: getStrategy,\n timeline: this.timeline,\n activityTimeout: this.config.activityTimeout,\n pongTimeout: this.config.pongTimeout,\n unavailableTimeout: this.config.unavailableTimeout,\n useTLS: Boolean(this.config.useTLS)\n });\n\n this.connection.bind('connected', () => {\n this.subscribeAll();\n if (this.timelineSender) {\n this.timelineSender.send(this.connection.isUsingTLS());\n }\n });\n\n this.connection.bind('message', event => {\n var eventName = event.event;\n var internal = eventName.indexOf('pusher_internal:') === 0;\n if (event.channel) {\n var channel = this.channel(event.channel);\n if (channel) {\n channel.handleEvent(event);\n }\n }\n // Emit globally [deprecated]\n if (!internal) {\n this.global_emitter.emit(event.event, event.data);\n }\n });\n this.connection.bind('connecting', () => {\n this.channels.disconnect();\n });\n this.connection.bind('disconnected', () => {\n this.channels.disconnect();\n });\n this.connection.bind('error', err => {\n Logger.warn(err);\n });\n\n Pusher.instances.push(this);\n this.timeline.info({ instances: Pusher.instances.length });\n\n this.user = new UserFacade(this);\n\n if (Pusher.isReady) {\n this.connect();\n }\n }\n\n /**\n * Allows you to switch Pusher cluster without\n * losing all the channels/subscription binding\n * as this is internally managed by the SDK.\n */\n switchCluster(options: ClusterOptions) {\n const { appKey, cluster } = options;\n this.key = appKey;\n this.options = { ...this.options, cluster };\n this.config = getConfig(this.options, this);\n this.connection.switchCluster(this.key);\n }\n\n channel(name: string): Channel {\n return this.channels.find(name);\n }\n\n allChannels(): Channel[] {\n return this.channels.all();\n }\n\n connect() {\n this.connection.connect();\n\n if (this.timelineSender) {\n if (!this.timelineSenderTimer) {\n var usingTLS = this.connection.isUsingTLS();\n var timelineSender = this.timelineSender;\n this.timelineSenderTimer = new PeriodicTimer(60000, function() {\n timelineSender.send(usingTLS);\n });\n }\n }\n }\n\n disconnect() {\n this.connection.disconnect();\n\n if (this.timelineSenderTimer) {\n this.timelineSenderTimer.ensureAborted();\n this.timelineSenderTimer = null;\n }\n }\n\n bind(event_name: string, callback: Function, context?: any): Pusher {\n this.global_emitter.bind(event_name, callback, context);\n return this;\n }\n\n unbind(event_name?: string, callback?: Function, context?: any): Pusher {\n this.global_emitter.unbind(event_name, callback, context);\n return this;\n }\n\n bind_global(callback: Function): Pusher {\n this.global_emitter.bind_global(callback);\n return this;\n }\n\n unbind_global(callback?: Function): Pusher {\n this.global_emitter.unbind_global(callback);\n return this;\n }\n\n unbind_all(callback?: Function): Pusher {\n this.global_emitter.unbind_all();\n return this;\n }\n\n subscribeAll() {\n var channelName;\n for (channelName in this.channels.channels) {\n if (this.channels.channels.hasOwnProperty(channelName)) {\n this.subscribe(channelName);\n }\n }\n }\n\n subscribe(channel_name: string) {\n var channel = this.channels.add(channel_name, this);\n if (channel.subscriptionPending && channel.subscriptionCancelled) {\n channel.reinstateSubscription();\n } else if (\n !channel.subscriptionPending &&\n this.connection.state === 'connected'\n ) {\n channel.subscribe();\n }\n return channel;\n }\n\n unsubscribe(channel_name: string) {\n var channel = this.channels.find(channel_name);\n if (channel && channel.subscriptionPending) {\n channel.cancelSubscription();\n } else {\n channel = this.channels.remove(channel_name);\n if (channel && channel.subscribed) {\n channel.unsubscribe();\n }\n }\n }\n\n send_event(event_name: string, data: any, channel?: string) {\n return this.connection.send_event(event_name, data, channel);\n }\n\n shouldUseTLS(): boolean {\n return this.config.useTLS;\n }\n\n signin() {\n this.user.signin();\n }\n}\n\nfunction checkAppKey(key) {\n if (key === null || key === undefined) {\n throw 'You must pass your app key when you instantiate Pusher.';\n }\n}\n\nRuntime.setup(Pusher);\n"],"sourceRoot":""} \ No newline at end of file diff --git a/dist/web/pusher.min.js b/dist/web/pusher.min.js index a476ca263..8ce9b4f02 100644 --- a/dist/web/pusher.min.js +++ b/dist/web/pusher.min.js @@ -1,9 +1,9 @@ /*! - * Pusher JavaScript Library v8.4.0-rc1 + * Pusher JavaScript Library v8.4.0-rc2 * https://pusher.com/ * * Copyright 2020, Pusher * Released under the MIT licence. */ -!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.Pusher=e():t.Pusher=e()}(window,(function(){return function(t){var e={};function n(i){if(e[i])return e[i].exports;var r=e[i]={i:i,l:!1,exports:{}};return t[i].call(r.exports,r,r.exports,n),r.l=!0,r.exports}return n.m=t,n.c=e,n.d=function(t,e,i){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:i})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var i=Object.create(null);if(n.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var r in t)n.d(i,r,function(e){return t[e]}.bind(null,r));return i},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=2)}([function(t,e,n){"use strict";var i,r=this&&this.__extends||(i=function(t,e){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)},function(t,e){function n(){this.constructor=t}i(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)});Object.defineProperty(e,"__esModule",{value:!0});var s=function(){function t(t){void 0===t&&(t="="),this._paddingCharacter=t}return t.prototype.encodedLength=function(t){return this._paddingCharacter?(t+2)/3*4|0:(8*t+5)/6|0},t.prototype.encode=function(t){for(var e="",n=0;n>>18&63),e+=this._encodeByte(i>>>12&63),e+=this._encodeByte(i>>>6&63),e+=this._encodeByte(i>>>0&63)}var r=t.length-n;if(r>0){i=t[n]<<16|(2===r?t[n+1]<<8:0);e+=this._encodeByte(i>>>18&63),e+=this._encodeByte(i>>>12&63),e+=2===r?this._encodeByte(i>>>6&63):this._paddingCharacter||"",e+=this._paddingCharacter||""}return e},t.prototype.maxDecodedLength=function(t){return this._paddingCharacter?t/4*3|0:(6*t+7)/8|0},t.prototype.decodedLength=function(t){return this.maxDecodedLength(t.length-this._getPaddingLength(t))},t.prototype.decode=function(t){if(0===t.length)return new Uint8Array(0);for(var e=this._getPaddingLength(t),n=t.length-e,i=new Uint8Array(this.maxDecodedLength(n)),r=0,s=0,o=0,a=0,c=0,h=0,u=0;s>>4,i[r++]=c<<4|h>>>2,i[r++]=h<<6|u,o|=256&a,o|=256&c,o|=256&h,o|=256&u;if(s>>4,o|=256&a,o|=256&c),s>>2,o|=256&h),s>>8&6,e+=51-t>>>8&-75,e+=61-t>>>8&-15,e+=62-t>>>8&3,String.fromCharCode(e)},t.prototype._decodeChar=function(t){var e=256;return e+=(42-t&t-44)>>>8&-256+t-43+62,e+=(46-t&t-48)>>>8&-256+t-47+63,e+=(47-t&t-58)>>>8&-256+t-48+52,e+=(64-t&t-91)>>>8&-256+t-65+0,e+=(96-t&t-123)>>>8&-256+t-97+26},t.prototype._getPaddingLength=function(t){var e=0;if(this._paddingCharacter){for(var n=t.length-1;n>=0&&t[n]===this._paddingCharacter;n--)e++;if(t.length<4||e>2)throw new Error("Base64Coder: incorrect padding")}return e},t}();e.Coder=s;var o=new s;e.encode=function(t){return o.encode(t)},e.decode=function(t){return o.decode(t)};var a=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r(e,t),e.prototype._encodeByte=function(t){var e=t;return e+=65,e+=25-t>>>8&6,e+=51-t>>>8&-75,e+=61-t>>>8&-13,e+=62-t>>>8&49,String.fromCharCode(e)},e.prototype._decodeChar=function(t){var e=256;return e+=(44-t&t-46)>>>8&-256+t-45+62,e+=(94-t&t-96)>>>8&-256+t-95+63,e+=(47-t&t-58)>>>8&-256+t-48+52,e+=(64-t&t-91)>>>8&-256+t-65+0,e+=(96-t&t-123)>>>8&-256+t-97+26},e}(s);e.URLSafeCoder=a;var c=new a;e.encodeURLSafe=function(t){return c.encode(t)},e.decodeURLSafe=function(t){return c.decode(t)},e.encodedLength=function(t){return o.encodedLength(t)},e.maxDecodedLength=function(t){return o.maxDecodedLength(t)},e.decodedLength=function(t){return o.decodedLength(t)}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i="utf8: invalid source encoding";function r(t){for(var e=0,n=0;n=t.length-1)throw new Error("utf8: invalid string");n++,e+=4}}return e}e.encode=function(t){for(var e=new Uint8Array(r(t)),n=0,i=0;i>6,e[n++]=128|63&s):s<55296?(e[n++]=224|s>>12,e[n++]=128|s>>6&63,e[n++]=128|63&s):(i++,s=(1023&s)<<10,s|=1023&t.charCodeAt(i),s+=65536,e[n++]=240|s>>18,e[n++]=128|s>>12&63,e[n++]=128|s>>6&63,e[n++]=128|63&s)}return e},e.encodedLength=r,e.decode=function(t){for(var e=[],n=0;n=t.length)throw new Error(i);if(128!=(192&(o=t[++n])))throw new Error(i);r=(31&r)<<6|63&o,s=128}else if(r<240){if(n>=t.length-1)throw new Error(i);var o=t[++n],a=t[++n];if(128!=(192&o)||128!=(192&a))throw new Error(i);r=(15&r)<<12|(63&o)<<6|63&a,s=2048}else{if(!(r<248))throw new Error(i);if(n>=t.length-2)throw new Error(i);o=t[++n],a=t[++n];var c=t[++n];if(128!=(192&o)||128!=(192&a)||128!=(192&c))throw new Error(i);r=(15&r)<<18|(63&o)<<12|(63&a)<<6|63&c,s=65536}if(r=55296&&r<=57343)throw new Error(i);if(r>=65536){if(r>1114111)throw new Error(i);r-=65536,e.push(String.fromCharCode(55296|r>>10)),r=56320|1023&r}}e.push(String.fromCharCode(r))}return e.join("")}},function(t,e,n){t.exports=n(3).default},function(t,e,n){"use strict";n.r(e);class i{constructor(t,e){this.lastId=0,this.prefix=t,this.name=e}create(t){this.lastId++;var e=this.lastId,n=this.prefix+e,i=this.name+"["+e+"]",r=!1,s=function(){r||(t.apply(null,arguments),r=!0)};return this[e]=s,{number:e,id:n,name:i,callback:s}}remove(t){delete this[t.number]}}var r=new i("_pusher_script_","Pusher.ScriptReceivers"),s={VERSION:"8.4.0-rc1",PROTOCOL:7,wsPort:80,wssPort:443,wsPath:"",httpHost:"sockjs.pusher.com",httpPort:80,httpsPort:443,httpPath:"/pusher",stats_host:"stats.pusher.com",authEndpoint:"/pusher/auth",authTransport:"ajax",activityTimeout:12e4,pongTimeout:3e4,unavailableTimeout:1e4,userAuthentication:{endpoint:"/pusher/user-auth",transport:"ajax"},channelAuthorization:{endpoint:"/pusher/auth",transport:"ajax"},cdn_http:"http://js.pusher.com",cdn_https:"https://js.pusher.com",dependency_suffix:""};var o=new i("_pusher_dependencies","Pusher.DependenciesReceivers"),a=new class{constructor(t){this.options=t,this.receivers=t.receivers||r,this.loading={}}load(t,e,n){var i=this;if(i.loading[t]&&i.loading[t].length>0)i.loading[t].push(n);else{i.loading[t]=[n];var r=ue.createScriptRequest(i.getPath(t,e)),s=i.receivers.create((function(e){if(i.receivers.remove(s),i.loading[t]){var n=i.loading[t];delete i.loading[t];for(var o=function(t){t||r.cleanup()},a=0;a>>6)+S(128|63&e):S(224|e>>>12&15)+S(128|e>>>6&63)+S(128|63&e)},E=function(t){return t.replace(/[^\x00-\x7F]/g,P)},O=function(t){var e=[0,2,1][t.length%3],n=t.charCodeAt(0)<<16|(t.length>1?t.charCodeAt(1):0)<<8|(t.length>2?t.charCodeAt(2):0);return[_.charAt(n>>>18),_.charAt(n>>>12&63),e>=2?"=":_.charAt(n>>>6&63),e>=1?"=":_.charAt(63&n)].join("")},x=window.btoa||function(t){return t.replace(/[\s\S]{1,3}/g,O)};var L=class{constructor(t,e,n,i){this.clear=e,this.timer=t(()=>{this.timer&&(this.timer=i(this.timer))},n)}isRunning(){return null!==this.timer}ensureAborted(){this.timer&&(this.clear(this.timer),this.timer=null)}};function A(t){window.clearTimeout(t)}function R(t){window.clearInterval(t)}class I extends L{constructor(t,e){super(setTimeout,A,t,(function(t){return e(),null}))}}class D extends L{constructor(t,e){super(setInterval,R,t,(function(t){return e(),t}))}}var j={now:()=>Date.now?Date.now():(new Date).valueOf(),defer:t=>new I(0,t),method(t,...e){var n=Array.prototype.slice.call(arguments,1);return function(e){return e[t].apply(e,n.concat(arguments))}}};function N(t,...e){for(var n=0;n{window.console&&window.console.log&&window.console.log(t)}}debug(...t){this.log(this.globalLog,t)}warn(...t){this.log(this.globalLogWarn,t)}error(...t){this.log(this.globalLogError,t)}globalLogWarn(t){window.console&&window.console.warn?window.console.warn(t):this.globalLog(t)}globalLogError(t){window.console&&window.console.error?window.console.error(t):this.globalLogWarn(t)}log(t,...e){var n=H.apply(this,arguments);if(Ae.log)Ae.log(n);else if(Ae.logToConsole){t.bind(this)(n)}}},Y=function(t,e,n,i,r){void 0===n.headers&&null==n.headersProvider||V.warn(`To send headers with the ${i.toString()} request, you must use AJAX, rather than JSONP.`);var s=t.nextAuthCallbackID.toString();t.nextAuthCallbackID++;var o=t.getDocument(),a=o.createElement("script");t.auth_callbacks[s]=function(t){r(null,t)};var c="Pusher.auth_callbacks['"+s+"']";a.src=n.endpoint+"?callback="+encodeURIComponent(c)+"&"+e;var h=o.getElementsByTagName("head")[0]||o.documentElement;h.insertBefore(a,h.firstChild)};class K{constructor(t){this.src=t}send(t){var e=this,n="Error loading "+e.src;e.script=document.createElement("script"),e.script.id=t.id,e.script.src=e.src,e.script.type="text/javascript",e.script.charset="UTF-8",e.script.addEventListener?(e.script.onerror=function(){t.callback(n)},e.script.onload=function(){t.callback(null)}):e.script.onreadystatechange=function(){"loaded"!==e.script.readyState&&"complete"!==e.script.readyState||t.callback(null)},void 0===e.script.async&&document.attachEvent&&/opera/i.test(navigator.userAgent)?(e.errorScript=document.createElement("script"),e.errorScript.id=t.id+"_error",e.errorScript.text=t.name+"('"+n+"');",e.script.async=e.errorScript.async=!1):e.script.async=!0;var i=document.getElementsByTagName("head")[0];i.insertBefore(e.script,i.firstChild),e.errorScript&&i.insertBefore(e.errorScript,e.script.nextSibling)}cleanup(){this.script&&(this.script.onload=this.script.onerror=null,this.script.onreadystatechange=null),this.script&&this.script.parentNode&&this.script.parentNode.removeChild(this.script),this.errorScript&&this.errorScript.parentNode&&this.errorScript.parentNode.removeChild(this.errorScript),this.script=null,this.errorScript=null}}class Q{constructor(t,e){this.url=t,this.data=e}send(t){if(!this.request){var e=W(this.data),n=this.url+"/"+t.number+"?"+e;this.request=ue.createScriptRequest(n),this.request.send(t)}}cleanup(){this.request&&this.request.cleanup()}}var Z={name:"jsonp",getAgent:function(t,e){return function(n,i){var s="http"+(e?"s":"")+"://"+(t.host||t.options.host)+t.options.path,o=ue.createJSONPRequest(s,n),a=ue.ScriptReceivers.create((function(e,n){r.remove(a),o.cleanup(),n&&n.host&&(t.host=n.host),i&&i(e,n)}));o.send(a)}}};function tt(t,e,n){return t+(e.useTLS?"s":"")+"://"+(e.useTLS?e.hostTLS:e.hostNonTLS)+n}function et(t,e){return"/app/"+t+("?protocol="+s.PROTOCOL+"&client=js&version="+s.VERSION+(e?"&"+e:""))}var nt={getInitial:function(t,e){return tt("ws",e,(e.httpPath||"")+et(t,"flash=false"))}},it={getInitial:function(t,e){return tt("http",e,(e.httpPath||"/pusher")+et(t))}},rt={getInitial:function(t,e){return tt("http",e,e.httpPath||"/pusher")},getPath:function(t,e){return et(t)}};class st{constructor(){this._callbacks={}}get(t){return this._callbacks[ot(t)]}add(t,e,n){var i=ot(t);this._callbacks[i]=this._callbacks[i]||[],this._callbacks[i].push({fn:e,context:n})}remove(t,e,n){if(t||e||n){var i=t?[ot(t)]:z(this._callbacks);e||n?this.removeCallback(i,e,n):this.removeAllCallbacks(i)}else this._callbacks={}}removeCallback(t,e,n){q(t,(function(t){this._callbacks[t]=F(this._callbacks[t]||[],(function(t){return e&&e!==t.fn||n&&n!==t.context})),0===this._callbacks[t].length&&delete this._callbacks[t]}),this)}removeAllCallbacks(t){q(t,(function(t){delete this._callbacks[t]}),this)}}function ot(t){return"_"+t}class at{constructor(t){this.callbacks=new st,this.global_callbacks=[],this.failThrough=t}bind(t,e,n){return this.callbacks.add(t,e,n),this}bind_global(t){return this.global_callbacks.push(t),this}unbind(t,e,n){return this.callbacks.remove(t,e,n),this}unbind_global(t){return t?(this.global_callbacks=F(this.global_callbacks||[],e=>e!==t),this):(this.global_callbacks=[],this)}unbind_all(){return this.unbind(),this.unbind_global(),this}emit(t,e,n){for(var i=0;i0)for(i=0;i{this.onError(t),this.changeState("closed")}),!1}return this.bindListeners(),V.debug("Connecting",{transport:this.name,url:t}),this.changeState("connecting"),!0}close(){return!!this.socket&&(this.socket.close(),!0)}send(t){return"open"===this.state&&(j.defer(()=>{this.socket&&this.socket.send(t)}),!0)}ping(){"open"===this.state&&this.supportsPing()&&this.socket.ping()}onOpen(){this.hooks.beforeOpen&&this.hooks.beforeOpen(this.socket,this.hooks.urls.getPath(this.key,this.options)),this.changeState("open"),this.socket.onopen=void 0}onError(t){this.emit("error",{type:"WebSocketError",error:t}),this.timeline.error(this.buildTimelineMessage({error:t.toString()}))}onClose(t){t?this.changeState("closed",{code:t.code,reason:t.reason,wasClean:t.wasClean}):this.changeState("closed"),this.unbindListeners(),this.socket=void 0}onMessage(t){this.emit("message",t)}onActivity(){this.emit("activity")}bindListeners(){this.socket.onopen=()=>{this.onOpen()},this.socket.onerror=t=>{this.onError(t)},this.socket.onclose=t=>{this.onClose(t)},this.socket.onmessage=t=>{this.onMessage(t)},this.supportsPing()&&(this.socket.onactivity=()=>{this.onActivity()})}unbindListeners(){this.socket&&(this.socket.onopen=void 0,this.socket.onerror=void 0,this.socket.onclose=void 0,this.socket.onmessage=void 0,this.supportsPing()&&(this.socket.onactivity=void 0))}changeState(t,e){this.state=t,this.timeline.info(this.buildTimelineMessage({state:t,params:e})),this.emit(t,e)}buildTimelineMessage(t){return N({cid:this.id},t)}}class ht{constructor(t){this.hooks=t}isSupported(t){return this.hooks.isSupported(t)}createConnection(t,e,n,i){return new ct(this.hooks,t,e,n,i)}}var ut=new ht({urls:nt,handlesActivityChecks:!1,supportsPing:!1,isInitialized:function(){return Boolean(ue.getWebSocketAPI())},isSupported:function(){return Boolean(ue.getWebSocketAPI())},getSocket:function(t){return ue.createWebSocket(t)}}),lt={urls:it,handlesActivityChecks:!1,supportsPing:!0,isInitialized:function(){return!0}},dt=N({getSocket:function(t){return ue.HTTPFactory.createStreamingSocket(t)}},lt),pt=N({getSocket:function(t){return ue.HTTPFactory.createPollingSocket(t)}},lt),ft={isSupported:function(){return ue.isXHRSupported()}},gt={ws:ut,xhr_streaming:new ht(N({},dt,ft)),xhr_polling:new ht(N({},pt,ft))},vt=new ht({file:"sockjs",urls:rt,handlesActivityChecks:!0,supportsPing:!1,isSupported:function(){return!0},isInitialized:function(){return void 0!==window.SockJS},getSocket:function(t,e){return new window.SockJS(t,null,{js_path:a.getPath("sockjs",{useTLS:e.useTLS}),ignore_null_origin:e.ignoreNullOrigin})},beforeOpen:function(t,e){t.send(JSON.stringify({path:e}))}}),mt={isSupported:function(t){return ue.isXDRSupported(t.useTLS)}},bt=new ht(N({},dt,mt)),yt=new ht(N({},pt,mt));gt.xdr_streaming=bt,gt.xdr_polling=yt,gt.sockjs=vt;var wt=gt;var St=new class extends at{constructor(){super();var t=this;void 0!==window.addEventListener&&(window.addEventListener("online",(function(){t.emit("online")}),!1),window.addEventListener("offline",(function(){t.emit("offline")}),!1))}isOnline(){return void 0===window.navigator.onLine||window.navigator.onLine}};class _t{constructor(t,e,n){this.manager=t,this.transport=e,this.minPingDelay=n.minPingDelay,this.maxPingDelay=n.maxPingDelay,this.pingDelay=void 0}createConnection(t,e,n,i){i=N({},i,{activityTimeout:this.pingDelay});var r=this.transport.createConnection(t,e,n,i),s=null,o=function(){r.unbind("open",o),r.bind("closed",a),s=j.now()},a=t=>{if(r.unbind("closed",a),1002===t.code||1003===t.code)this.manager.reportDeath();else if(!t.wasClean&&s){var e=j.now()-s;e<2*this.maxPingDelay&&(this.manager.reportDeath(),this.pingDelay=Math.max(e/2,this.minPingDelay))}};return r.bind("open",o),r}isSupported(t){return this.manager.isAlive()&&this.transport.isSupported(t)}}const kt={decodeMessage:function(t){try{var e=JSON.parse(t.data),n=e.data;if("string"==typeof n)try{n=JSON.parse(e.data)}catch(t){}var i={event:e.event,channel:e.channel,data:n};return e.user_id&&(i.user_id=e.user_id),i}catch(e){throw{type:"MessageParseError",error:e,data:t.data}}},encodeMessage:function(t){return JSON.stringify(t)},processHandshake:function(t){var e=kt.decodeMessage(t);if("pusher:connection_established"===e.event){if(!e.data.activity_timeout)throw"No activity timeout specified in handshake";return{action:"connected",id:e.data.socket_id,activityTimeout:1e3*e.data.activity_timeout}}if("pusher:error"===e.event)return{action:this.getCloseAction(e.data),error:this.getCloseError(e.data)};throw"Invalid handshake"},getCloseAction:function(t){return t.code<4e3?t.code>=1002&&t.code<=1004?"backoff":null:4e3===t.code?"tls_only":t.code<4100?"refused":t.code<4200?"backoff":t.code<4300?"retry":"refused"},getCloseError:function(t){return 1e3!==t.code&&1001!==t.code?{type:"PusherError",data:{code:t.code,message:t.reason||t.message}}:null}};var Ct=kt;class Tt extends at{constructor(t,e){super(),this.id=t,this.transport=e,this.activityTimeout=e.activityTimeout,this.bindListeners()}handlesActivityChecks(){return this.transport.handlesActivityChecks()}send(t){return this.transport.send(t)}send_event(t,e,n){var i={event:t,data:e};return n&&(i.channel=n),V.debug("Event sent",i),this.send(Ct.encodeMessage(i))}ping(){this.transport.supportsPing()?this.transport.ping():this.send_event("pusher:ping",{})}close(){this.transport.close()}bindListeners(){var t={message:t=>{var e;try{e=Ct.decodeMessage(t)}catch(e){this.emit("error",{type:"MessageParseError",error:e,data:t.data})}if(void 0!==e){switch(V.debug("Event recd",e),e.event){case"pusher:error":this.emit("error",{type:"PusherError",data:e.data});break;case"pusher:ping":this.emit("ping");break;case"pusher:pong":this.emit("pong")}this.emit("message",e)}},activity:()=>{this.emit("activity")},error:t=>{this.emit("error",t)},closed:t=>{e(),t&&t.code&&this.handleCloseEvent(t),this.transport=null,this.emit("closed")}},e=()=>{M(t,(t,e)=>{this.transport.unbind(e,t)})};M(t,(t,e)=>{this.transport.bind(e,t)})}handleCloseEvent(t){var e=Ct.getCloseAction(t),n=Ct.getCloseError(t);n&&this.emit("error",n),e&&this.emit(e,{action:e,error:n})}}class Pt{constructor(t,e){this.transport=t,this.callback=e,this.bindListeners()}close(){this.unbindListeners(),this.transport.close()}bindListeners(){this.onMessage=t=>{var e;this.unbindListeners();try{e=Ct.processHandshake(t)}catch(t){return this.finish("error",{error:t}),void this.transport.close()}"connected"===e.action?this.finish("connected",{connection:new Tt(e.id,this.transport),activityTimeout:e.activityTimeout}):(this.finish(e.action,{error:e.error}),this.transport.close())},this.onClosed=t=>{this.unbindListeners();var e=Ct.getCloseAction(t)||"backoff",n=Ct.getCloseError(t);this.finish(e,{error:n})},this.transport.bind("message",this.onMessage),this.transport.bind("closed",this.onClosed)}unbindListeners(){this.transport.unbind("message",this.onMessage),this.transport.unbind("closed",this.onClosed)}finish(t,e){this.callback(N({transport:this.transport,action:t},e))}}class Et{constructor(t,e){this.timeline=t,this.options=e||{}}send(t,e){this.timeline.isEmpty()||this.timeline.send(ue.TimelineTransport.getAgent(this,t),e)}}class Ot extends at{constructor(t,e){super((function(e,n){V.debug("No callbacks on "+t+" for "+e)})),this.name=t,this.pusher=e,this.subscribed=!1,this.subscriptionPending=!1,this.subscriptionCancelled=!1}authorize(t,e){return e(null,{auth:""})}trigger(t,e){if(0!==t.indexOf("client-"))throw new l("Event '"+t+"' does not start with 'client-'");if(!this.subscribed){var n=u("triggeringClientEvents");V.warn("Client event triggered before channel 'subscription_succeeded' event . "+n)}return this.pusher.send_event(t,e,this.name)}disconnect(){this.subscribed=!1,this.subscriptionPending=!1}handleEvent(t){var e=t.event,n=t.data;if("pusher_internal:subscription_succeeded"===e)this.handleSubscriptionSucceededEvent(t);else if("pusher_internal:subscription_count"===e)this.handleSubscriptionCountEvent(t);else if(0!==e.indexOf("pusher_internal:")){this.emit(e,n,{})}}handleSubscriptionSucceededEvent(t){this.subscriptionPending=!1,this.subscribed=!0,this.subscriptionCancelled?this.pusher.unsubscribe(this.name):this.emit("pusher:subscription_succeeded",t.data)}handleSubscriptionCountEvent(t){t.data.subscription_count&&(this.subscriptionCount=t.data.subscription_count),this.emit("pusher:subscription_count",t.data)}subscribe(){this.subscribed||(this.subscriptionPending=!0,this.subscriptionCancelled=!1,this.authorize(this.pusher.connection.socket_id,(t,e)=>{t?(this.subscriptionPending=!1,V.error(t.toString()),this.emit("pusher:subscription_error",Object.assign({},{type:"AuthError",error:t.message},t instanceof y?{status:t.status}:{}))):this.pusher.send_event("pusher:subscribe",{auth:e.auth,channel_data:e.channel_data,channel:this.name})}))}unsubscribe(){this.subscribed=!1,this.pusher.send_event("pusher:unsubscribe",{channel:this.name})}cancelSubscription(){this.subscriptionCancelled=!0}reinstateSubscription(){this.subscriptionCancelled=!1}}class xt extends Ot{authorize(t,e){return this.pusher.config.channelAuthorizer({channelName:this.name,socketId:t},e)}}class Lt{constructor(){this.reset()}get(t){return Object.prototype.hasOwnProperty.call(this.members,t)?{id:t,info:this.members[t]}:null}each(t){M(this.members,(e,n)=>{t(this.get(n))})}setMyID(t){this.myID=t}onSubscription(t){this.members=t.presence.hash,this.count=t.presence.count,this.me=this.get(this.myID)}addMember(t){return null===this.get(t.user_id)&&this.count++,this.members[t.user_id]=t.user_info,this.get(t.user_id)}removeMember(t){var e=this.get(t.user_id);return e&&(delete this.members[t.user_id],this.count--),e}reset(){this.members={},this.count=0,this.myID=null,this.me=null}}var At=function(t,e,n,i){return new(n||(n=Promise))((function(r,s){function o(t){try{c(i.next(t))}catch(t){s(t)}}function a(t){try{c(i.throw(t))}catch(t){s(t)}}function c(t){var e;t.done?r(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(o,a)}c((i=i.apply(t,e||[])).next())}))};class Rt extends xt{constructor(t,e){super(t,e),this.members=new Lt}authorize(t,e){super.authorize(t,(t,n)=>At(this,void 0,void 0,(function*(){if(!t)if(null!=(n=n).channel_data){var i=JSON.parse(n.channel_data);this.members.setMyID(i.user_id)}else{if(yield this.pusher.user.signinDonePromise,null==this.pusher.user.user_data){let t=u("authorizationEndpoint");return V.error(`Invalid auth response for channel '${this.name}', expected 'channel_data' field. ${t}, or the user should be signed in.`),void e("Invalid auth response")}this.members.setMyID(this.pusher.user.user_data.id)}e(t,n)})))}handleEvent(t){var e=t.event;if(0===e.indexOf("pusher_internal:"))this.handleInternalEvent(t);else{var n=t.data,i={};t.user_id&&(i.user_id=t.user_id),this.emit(e,n,i)}}handleInternalEvent(t){var e=t.event,n=t.data;switch(e){case"pusher_internal:subscription_succeeded":this.handleSubscriptionSucceededEvent(t);break;case"pusher_internal:subscription_count":this.handleSubscriptionCountEvent(t);break;case"pusher_internal:member_added":var i=this.members.addMember(n);this.emit("pusher:member_added",i);break;case"pusher_internal:member_removed":var r=this.members.removeMember(n);r&&this.emit("pusher:member_removed",r)}}handleSubscriptionSucceededEvent(t){this.subscriptionPending=!1,this.subscribed=!0,this.subscriptionCancelled?this.pusher.unsubscribe(this.name):(this.members.onSubscription(t.data),this.emit("pusher:subscription_succeeded",this.members))}disconnect(){this.members.reset(),super.disconnect()}}var It=n(1),Dt=n(0);class jt extends xt{constructor(t,e,n){super(t,e),this.key=null,this.nacl=n}authorize(t,e){super.authorize(t,(t,n)=>{if(t)return void e(t,n);let i=n.shared_secret;i?(this.key=Object(Dt.decode)(i),delete n.shared_secret,e(null,n)):e(new Error("No shared_secret key in auth payload for encrypted channel: "+this.name),null)})}trigger(t,e){throw new v("Client events are not currently supported for encrypted channels")}handleEvent(t){var e=t.event,n=t.data;0!==e.indexOf("pusher_internal:")&&0!==e.indexOf("pusher:")?this.handleEncryptedEvent(e,n):super.handleEvent(t)}handleEncryptedEvent(t,e){if(!this.key)return void V.debug("Received encrypted event before key has been retrieved from the authEndpoint");if(!e.ciphertext||!e.nonce)return void V.error("Unexpected format for encrypted event, expected object with `ciphertext` and `nonce` fields, got: "+e);let n=Object(Dt.decode)(e.ciphertext);if(n.length{e?V.error(`Failed to make a request to the authEndpoint: ${s}. Unable to fetch new key, so dropping encrypted event`):(r=this.nacl.secretbox.open(n,i,this.key),null!==r?this.emit(t,this.getDataToEmit(r)):V.error("Failed to decrypt event with new key. Dropping encrypted event"))});this.emit(t,this.getDataToEmit(r))}getDataToEmit(t){let e=Object(It.decode)(t);try{return JSON.parse(e)}catch(t){return e}}}class Nt extends at{constructor(t,e){super(),this.state="initialized",this.connection=null,this.key=t,this.options=e,this.timeline=this.options.timeline,this.usingTLS=this.options.useTLS,this.errorCallbacks=this.buildErrorCallbacks(),this.connectionCallbacks=this.buildConnectionCallbacks(this.errorCallbacks),this.handshakeCallbacks=this.buildHandshakeCallbacks(this.errorCallbacks);var n=ue.getNetwork();n.bind("online",()=>{this.timeline.info({netinfo:"online"}),"connecting"!==this.state&&"unavailable"!==this.state||this.retryIn(0)}),n.bind("offline",()=>{this.timeline.info({netinfo:"offline"}),this.connection&&this.sendActivityCheck()}),this.updateStrategy()}switchCluster(t){this.key=t,this.updateStrategy(),this.retryIn(0)}connect(){this.connection||this.runner||(this.strategy.isSupported()?(this.updateState("connecting"),this.startConnecting(),this.setUnavailableTimer()):this.updateState("failed"))}send(t){return!!this.connection&&this.connection.send(t)}send_event(t,e,n){return!!this.connection&&this.connection.send_event(t,e,n)}disconnect(){this.disconnectInternally(),this.updateState("disconnected")}isUsingTLS(){return this.usingTLS}startConnecting(){var t=(e,n)=>{e?this.runner=this.strategy.connect(0,t):"error"===n.action?(this.emit("error",{type:"HandshakeError",error:n.error}),this.timeline.error({handshakeError:n.error})):(this.abortConnecting(),this.handshakeCallbacks[n.action](n))};this.runner=this.strategy.connect(0,t)}abortConnecting(){this.runner&&(this.runner.abort(),this.runner=null)}disconnectInternally(){(this.abortConnecting(),this.clearRetryTimer(),this.clearUnavailableTimer(),this.connection)&&this.abandonConnection().close()}updateStrategy(){this.strategy=this.options.getStrategy({key:this.key,timeline:this.timeline,useTLS:this.usingTLS})}retryIn(t){this.timeline.info({action:"retry",delay:t}),t>0&&this.emit("connecting_in",Math.round(t/1e3)),this.retryTimer=new I(t||0,()=>{this.disconnectInternally(),this.connect()})}clearRetryTimer(){this.retryTimer&&(this.retryTimer.ensureAborted(),this.retryTimer=null)}setUnavailableTimer(){this.unavailableTimer=new I(this.options.unavailableTimeout,()=>{this.updateState("unavailable")})}clearUnavailableTimer(){this.unavailableTimer&&this.unavailableTimer.ensureAborted()}sendActivityCheck(){this.stopActivityCheck(),this.connection.ping(),this.activityTimer=new I(this.options.pongTimeout,()=>{this.timeline.error({pong_timed_out:this.options.pongTimeout}),this.retryIn(0)})}resetActivityCheck(){this.stopActivityCheck(),this.connection&&!this.connection.handlesActivityChecks()&&(this.activityTimer=new I(this.activityTimeout,()=>{this.sendActivityCheck()}))}stopActivityCheck(){this.activityTimer&&this.activityTimer.ensureAborted()}buildConnectionCallbacks(t){return N({},t,{message:t=>{this.resetActivityCheck(),this.emit("message",t)},ping:()=>{this.send_event("pusher:pong",{})},activity:()=>{this.resetActivityCheck()},error:t=>{this.emit("error",t)},closed:()=>{this.abandonConnection(),this.shouldRetry()&&this.retryIn(1e3)}})}buildHandshakeCallbacks(t){return N({},t,{connected:t=>{this.activityTimeout=Math.min(this.options.activityTimeout,t.activityTimeout,t.connection.activityTimeout||1/0),this.clearUnavailableTimer(),this.setConnection(t.connection),this.socket_id=this.connection.id,this.updateState("connected",{socket_id:this.socket_id})}})}buildErrorCallbacks(){let t=t=>e=>{e.error&&this.emit("error",{type:"WebSocketError",error:e.error}),t(e)};return{tls_only:t(()=>{this.usingTLS=!0,this.updateStrategy(),this.retryIn(0)}),refused:t(()=>{this.disconnect()}),backoff:t(()=>{this.retryIn(1e3)}),retry:t(()=>{this.retryIn(0)})}}setConnection(t){for(var e in this.connection=t,this.connectionCallbacks)this.connection.bind(e,this.connectionCallbacks[e]);this.resetActivityCheck()}abandonConnection(){if(this.connection){for(var t in this.stopActivityCheck(),this.connectionCallbacks)this.connection.unbind(t,this.connectionCallbacks[t]);var e=this.connection;return this.connection=null,e}}updateState(t,e){var n=this.state;if(this.state=t,n!==t){var i=t;"connected"===i&&(i+=" with new socket ID "+e.socket_id),V.debug("State changed",n+" -> "+i),this.timeline.info({state:t,params:e}),this.emit("state_change",{previous:n,current:t}),this.emit(t,e)}}shouldRetry(){return"connecting"===this.state||"connected"===this.state}}class Ht{constructor(){this.channels={}}add(t,e){return this.channels[t]||(this.channels[t]=function(t,e){if(0===t.indexOf("private-encrypted-")){if(e.config.nacl)return Ut.createEncryptedChannel(t,e,e.config.nacl);let n="Tried to subscribe to a private-encrypted- channel but no nacl implementation available",i=u("encryptedChannelSupport");throw new v(`${n}. ${i}`)}if(0===t.indexOf("private-"))return Ut.createPrivateChannel(t,e);if(0===t.indexOf("presence-"))return Ut.createPresenceChannel(t,e);if(0===t.indexOf("#"))throw new d('Cannot create a channel with name "'+t+'".');return Ut.createChannel(t,e)}(t,e)),this.channels[t]}all(){return function(t){var e=[];return M(t,(function(t){e.push(t)})),e}(this.channels)}find(t){return this.channels[t]}remove(t){var e=this.channels[t];return delete this.channels[t],e}disconnect(){M(this.channels,(function(t){t.disconnect()}))}}var Ut={createChannels:()=>new Ht,createConnectionManager:(t,e)=>new Nt(t,e),createChannel:(t,e)=>new Ot(t,e),createPrivateChannel:(t,e)=>new xt(t,e),createPresenceChannel:(t,e)=>new Rt(t,e),createEncryptedChannel:(t,e,n)=>new jt(t,e,n),createTimelineSender:(t,e)=>new Et(t,e),createHandshake:(t,e)=>new Pt(t,e),createAssistantToTheTransportManager:(t,e,n)=>new _t(t,e,n)};class Mt{constructor(t){this.options=t||{},this.livesLeft=this.options.lives||1/0}getAssistant(t){return Ut.createAssistantToTheTransportManager(this,t,{minPingDelay:this.options.minPingDelay,maxPingDelay:this.options.maxPingDelay})}isAlive(){return this.livesLeft>0}reportDeath(){this.livesLeft-=1}}class zt{constructor(t,e){this.strategies=t,this.loop=Boolean(e.loop),this.failFast=Boolean(e.failFast),this.timeout=e.timeout,this.timeoutLimit=e.timeoutLimit}isSupported(){return J(this.strategies,j.method("isSupported"))}connect(t,e){var n=this.strategies,i=0,r=this.timeout,s=null,o=(a,c)=>{c?e(null,c):(i+=1,this.loop&&(i%=n.length),i0&&(r=new I(n.timeout,(function(){s.abort(),i(!0)}))),s=t.connect(e,(function(t,e){t&&r&&r.isRunning()&&!n.failFast||(r&&r.ensureAborted(),i(t,e))})),{abort:function(){r&&r.ensureAborted(),s.abort()},forceMinPriority:function(t){s.forceMinPriority(t)}}}}class qt{constructor(t){this.strategies=t}isSupported(){return J(this.strategies,j.method("isSupported"))}connect(t,e){return function(t,e,n){var i=B(t,(function(t,i,r,s){return t.connect(e,n(i,s))}));return{abort:function(){q(i,Bt)},forceMinPriority:function(t){q(i,(function(e){e.forceMinPriority(t)}))}}}(this.strategies,t,(function(t,n){return function(i,r){n[t].error=i,i?function(t){return function(t,e){for(var n=0;n=j.now()){var o=this.transports[i.transport];o&&(["ws","wss"].includes(i.transport)||r>3?(this.timeline.info({cached:!0,transport:i.transport,latency:i.latency}),s.push(new zt([o],{timeout:2*i.latency+1e3,failFast:!0}))):r++)}var a=j.now(),c=s.pop().connect(t,(function i(o,h){o?(Jt(n),s.length>0?(a=j.now(),c=s.pop().connect(t,i)):e(o)):(!function(t,e,n,i){var r=ue.getLocalStorage();if(r)try{r[Xt(t)]=G({timestamp:j.now(),transport:e,latency:n,cacheSkipCount:i})}catch(t){}}(n,h.transport.name,j.now()-a,r),e(null,h))}));return{abort:function(){c.abort()},forceMinPriority:function(e){t=e,c&&c.forceMinPriority(e)}}}}function Xt(t){return"pusherTransport"+(t?"TLS":"NonTLS")}function Jt(t){var e=ue.getLocalStorage();if(e)try{delete e[Xt(t)]}catch(t){}}class $t{constructor(t,{delay:e}){this.strategy=t,this.options={delay:e}}isSupported(){return this.strategy.isSupported()}connect(t,e){var n,i=this.strategy,r=new I(this.options.delay,(function(){n=i.connect(t,e)}));return{abort:function(){r.ensureAborted(),n&&n.abort()},forceMinPriority:function(e){t=e,n&&n.forceMinPriority(e)}}}}class Wt{constructor(t,e,n){this.test=t,this.trueBranch=e,this.falseBranch=n}isSupported(){return(this.test()?this.trueBranch:this.falseBranch).isSupported()}connect(t,e){return(this.test()?this.trueBranch:this.falseBranch).connect(t,e)}}class Gt{constructor(t){this.strategy=t}isSupported(){return this.strategy.isSupported()}connect(t,e){var n=this.strategy.connect(t,(function(t,i){i&&n.abort(),e(t,i)}));return n}}function Vt(t){return function(){return t.isSupported()}}var Yt=function(t,e,n){var i={};function r(e,r,s,o,a){var c=n(t,e,r,s,o,a);return i[e]=c,c}var s,o=Object.assign({},e,{hostNonTLS:t.wsHost+":"+t.wsPort,hostTLS:t.wsHost+":"+t.wssPort,httpPath:t.wsPath}),a=Object.assign({},o,{useTLS:!0}),c=Object.assign({},e,{hostNonTLS:t.httpHost+":"+t.httpPort,hostTLS:t.httpHost+":"+t.httpsPort,httpPath:t.httpPath}),h={loop:!0,timeout:15e3,timeoutLimit:6e4},u=new Mt({minPingDelay:1e4,maxPingDelay:t.activityTimeout}),l=new Mt({lives:2,minPingDelay:1e4,maxPingDelay:t.activityTimeout}),d=r("ws","ws",3,o,u),p=r("wss","ws",3,a,u),f=r("sockjs","sockjs",1,c),g=r("xhr_streaming","xhr_streaming",1,c,l),v=r("xdr_streaming","xdr_streaming",1,c,l),m=r("xhr_polling","xhr_polling",1,c),b=r("xdr_polling","xdr_polling",1,c),y=new zt([d],h),w=new zt([p],h),S=new zt([f],h),_=new zt([new Wt(Vt(g),g,v)],h),k=new zt([new Wt(Vt(m),m,b)],h),C=new zt([new Wt(Vt(_),new qt([_,new $t(k,{delay:4e3})]),k)],h),T=new Wt(Vt(C),C,S);return s=e.useTLS?new qt([y,new $t(T,{delay:2e3})]):new qt([y,new $t(w,{delay:2e3}),new $t(T,{delay:5e3})]),new Ft(new Gt(new Wt(Vt(d),s,T)),i,{ttl:18e5,timeline:e.timeline,useTLS:e.useTLS})},Kt={getRequest:function(t){var e=new window.XDomainRequest;return e.ontimeout=function(){t.emit("error",new p),t.close()},e.onerror=function(e){t.emit("error",e),t.close()},e.onprogress=function(){e.responseText&&e.responseText.length>0&&t.onChunk(200,e.responseText)},e.onload=function(){e.responseText&&e.responseText.length>0&&t.onChunk(200,e.responseText),t.emit("finished",200),t.close()},e},abortRequest:function(t){t.ontimeout=t.onerror=t.onprogress=t.onload=null,t.abort()}};class Qt extends at{constructor(t,e,n){super(),this.hooks=t,this.method=e,this.url=n}start(t){this.position=0,this.xhr=this.hooks.getRequest(this),this.unloader=()=>{this.close()},ue.addUnloadListener(this.unloader),this.xhr.open(this.method,this.url,!0),this.xhr.setRequestHeader&&this.xhr.setRequestHeader("Content-Type","application/json"),this.xhr.send(t)}close(){this.unloader&&(ue.removeUnloadListener(this.unloader),this.unloader=null),this.xhr&&(this.hooks.abortRequest(this.xhr),this.xhr=null)}onChunk(t,e){for(;;){var n=this.advanceBuffer(e);if(!n)break;this.emit("chunk",{status:t,data:n})}this.isBufferTooLong(e)&&this.emit("buffer_too_long")}advanceBuffer(t){var e=t.slice(this.position),n=e.indexOf("\n");return-1!==n?(this.position+=n+1,e.slice(0,n)):null}isBufferTooLong(t){return this.position===t.length&&t.length>262144}}var Zt;!function(t){t[t.CONNECTING=0]="CONNECTING",t[t.OPEN=1]="OPEN",t[t.CLOSED=3]="CLOSED"}(Zt||(Zt={}));var te=Zt,ee=1;function ne(t){var e=-1===t.indexOf("?")?"?":"&";return t+e+"t="+ +new Date+"&n="+ee++}function ie(t){return ue.randomInt(t)}var re,se=class{constructor(t,e){this.hooks=t,this.session=ie(1e3)+"/"+function(t){for(var e=[],n=0;n{this.onChunk(t)}),this.stream.bind("finished",t=>{this.hooks.onFinished(this,t)}),this.stream.bind("buffer_too_long",()=>{this.reconnect()});try{this.stream.start()}catch(t){j.defer(()=>{this.onError(t),this.onClose(1006,"Could not start streaming",!1)})}}closeStream(){this.stream&&(this.stream.unbind_all(),this.stream.close(),this.stream=null)}},oe={getReceiveURL:function(t,e){return t.base+"/"+e+"/xhr_streaming"+t.queryString},onHeartbeat:function(t){t.sendRaw("[]")},sendHeartbeat:function(t){t.sendRaw("[]")},onFinished:function(t,e){t.onClose(1006,"Connection interrupted ("+e+")",!1)}},ae={getReceiveURL:function(t,e){return t.base+"/"+e+"/xhr"+t.queryString},onHeartbeat:function(){},sendHeartbeat:function(t){t.sendRaw("[]")},onFinished:function(t,e){200===e?t.reconnect():t.onClose(1006,"Connection interrupted ("+e+")",!1)}},ce={getRequest:function(t){var e=new(ue.getXHRAPI());return e.onreadystatechange=e.onprogress=function(){switch(e.readyState){case 3:e.responseText&&e.responseText.length>0&&t.onChunk(e.status,e.responseText);break;case 4:e.responseText&&e.responseText.length>0&&t.onChunk(e.status,e.responseText),t.emit("finished",e.status),t.close()}},e},abortRequest:function(t){t.onreadystatechange=null,t.abort()}},he={createStreamingSocket(t){return this.createSocket(oe,t)},createPollingSocket(t){return this.createSocket(ae,t)},createSocket:(t,e)=>new se(t,e),createXHR(t,e){return this.createRequest(ce,t,e)},createRequest:(t,e,n)=>new Qt(t,e,n),createXDR:function(t,e){return this.createRequest(Kt,t,e)}},ue={nextAuthCallbackID:1,auth_callbacks:{},ScriptReceivers:r,DependenciesReceivers:o,getDefaultStrategy:Yt,Transports:wt,transportConnectionInitializer:function(){var t=this;t.timeline.info(t.buildTimelineMessage({transport:t.name+(t.options.useTLS?"s":"")})),t.hooks.isInitialized()?t.changeState("initialized"):t.hooks.file?(t.changeState("initializing"),a.load(t.hooks.file,{useTLS:t.options.useTLS},(function(e,n){t.hooks.isInitialized()?(t.changeState("initialized"),n(!0)):(e&&t.onError(e),t.onClose(),n(!1))}))):t.onClose()},HTTPFactory:he,TimelineTransport:Z,getXHRAPI:()=>window.XMLHttpRequest,getWebSocketAPI:()=>window.WebSocket||window.MozWebSocket,setup(t){window.Pusher=t;var e=()=>{this.onDocumentBody(t.ready)};window.JSON?e():a.load("json2",{},e)},getDocument:()=>document,getProtocol(){return this.getDocument().location.protocol},getAuthorizers:()=>({ajax:w,jsonp:Y}),onDocumentBody(t){document.body?t():setTimeout(()=>{this.onDocumentBody(t)},0)},createJSONPRequest:(t,e)=>new Q(t,e),createScriptRequest:t=>new K(t),getLocalStorage(){try{return window.localStorage}catch(t){return}},createXHR(){return this.getXHRAPI()?this.createXMLHttpRequest():this.createMicrosoftXHR()},createXMLHttpRequest(){return new(this.getXHRAPI())},createMicrosoftXHR:()=>new ActiveXObject("Microsoft.XMLHTTP"),getNetwork:()=>St,createWebSocket(t){return new(this.getWebSocketAPI())(t)},createSocketRequest(t,e){if(this.isXHRSupported())return this.HTTPFactory.createXHR(t,e);if(this.isXDRSupported(0===e.indexOf("https:")))return this.HTTPFactory.createXDR(t,e);throw"Cross-origin HTTP requests are not supported"},isXHRSupported(){var t=this.getXHRAPI();return Boolean(t)&&void 0!==(new t).withCredentials},isXDRSupported(t){var e=t?"https:":"http:",n=this.getProtocol();return Boolean(window.XDomainRequest)&&n===e},addUnloadListener(t){void 0!==window.addEventListener?window.addEventListener("unload",t,!1):void 0!==window.attachEvent&&window.attachEvent("onunload",t)},removeUnloadListener(t){void 0!==window.addEventListener?window.removeEventListener("unload",t,!1):void 0!==window.detachEvent&&window.detachEvent("onunload",t)},randomInt:t=>Math.floor((window.crypto||window.msCrypto).getRandomValues(new Uint32Array(1))[0]/Math.pow(2,32)*t)};!function(t){t[t.ERROR=3]="ERROR",t[t.INFO=6]="INFO",t[t.DEBUG=7]="DEBUG"}(re||(re={}));var le=re;class de{constructor(t,e,n){this.key=t,this.session=e,this.events=[],this.options=n||{},this.sent=0,this.uniqueID=0}log(t,e){t<=this.options.level&&(this.events.push(N({},e,{timestamp:j.now()})),this.options.limit&&this.events.length>this.options.limit&&this.events.shift())}error(t){this.log(le.ERROR,t)}info(t){this.log(le.INFO,t)}debug(t){this.log(le.DEBUG,t)}isEmpty(){return 0===this.events.length}send(t,e){var n=N({session:this.session,bundle:this.sent+1,key:this.key,lib:"js",version:this.options.version,cluster:this.options.cluster,features:this.options.features,timeline:this.events},this.options.params);return this.events=[],t(n,(t,n)=>{t||this.sent++,e&&e(t,n)}),!0}generateUniqueID(){return this.uniqueID++,this.uniqueID}}class pe{constructor(t,e,n,i){this.name=t,this.priority=e,this.transport=n,this.options=i||{}}isSupported(){return this.transport.isSupported({useTLS:this.options.useTLS})}connect(t,e){if(!this.isSupported())return fe(new b,e);if(this.priority{n||(h(),r?r.close():i.close())},forceMinPriority:t=>{n||this.priority{if(void 0===ue.getAuthorizers()[t.transport])throw`'${t.transport}' is not a recognized auth transport`;return(e,n)=>{const i=((t,e)=>{var n="socket_id="+encodeURIComponent(t.socketId);for(var i in e.params)n+="&"+encodeURIComponent(i)+"="+encodeURIComponent(e.params[i]);if(null!=e.paramsProvider){let t=e.paramsProvider();for(var i in t)n+="&"+encodeURIComponent(i)+"="+encodeURIComponent(t[i])}return n})(e,t);ue.getAuthorizers()[t.transport](ue,i,t,h.UserAuthentication,n)}};var ye=t=>{if(void 0===ue.getAuthorizers()[t.transport])throw`'${t.transport}' is not a recognized auth transport`;return(e,n)=>{const i=((t,e)=>{var n="socket_id="+encodeURIComponent(t.socketId);for(var i in n+="&channel_name="+encodeURIComponent(t.channelName),e.params)n+="&"+encodeURIComponent(i)+"="+encodeURIComponent(e.params[i]);if(null!=e.paramsProvider){let t=e.paramsProvider();for(var i in t)n+="&"+encodeURIComponent(i)+"="+encodeURIComponent(t[i])}return n})(e,t);ue.getAuthorizers()[t.transport](ue,i,t,h.ChannelAuthorization,n)}};function we(t,e){let n={activityTimeout:t.activityTimeout||s.activityTimeout,cluster:t.cluster,httpPath:t.httpPath||s.httpPath,httpPort:t.httpPort||s.httpPort,httpsPort:t.httpsPort||s.httpsPort,pongTimeout:t.pongTimeout||s.pongTimeout,statsHost:t.statsHost||s.stats_host,unavailableTimeout:t.unavailableTimeout||s.unavailableTimeout,wsPath:t.wsPath||s.wsPath,wsPort:t.wsPort||s.wsPort,wssPort:t.wssPort||s.wssPort,enableStats:Ce(t),httpHost:Se(t),useTLS:ke(t),wsHost:_e(t),userAuthenticator:Te(t),channelAuthorizer:Pe(t,e)};return"disabledTransports"in t&&(n.disabledTransports=t.disabledTransports),"enabledTransports"in t&&(n.enabledTransports=t.enabledTransports),"ignoreNullOrigin"in t&&(n.ignoreNullOrigin=t.ignoreNullOrigin),"timelineParams"in t&&(n.timelineParams=t.timelineParams),"nacl"in t&&(n.nacl=t.nacl),n}function Se(t){return t.httpHost?t.httpHost:t.cluster?`sockjs-${t.cluster}.pusher.com`:s.httpHost}function _e(t){return t.wsHost?t.wsHost:`ws-${t.cluster}.pusher.com`}function ke(t){return"https:"===ue.getProtocol()||!1!==t.forceTLS}function Ce(t){return"enableStats"in t?t.enableStats:"disableStats"in t&&!t.disableStats}function Te(t){const e=Object.assign(Object.assign({},s.userAuthentication),t.userAuthentication);return"customHandler"in e&&null!=e.customHandler?e.customHandler:be(e)}function Pe(t,e){const n=function(t,e){let n;return"channelAuthorization"in t?n=Object.assign(Object.assign({},s.channelAuthorization),t.channelAuthorization):(n={transport:t.authTransport||s.authTransport,endpoint:t.authEndpoint||s.authEndpoint},"auth"in t&&("params"in t.auth&&(n.params=t.auth.params),"headers"in t.auth&&(n.headers=t.auth.headers)),"authorizer"in t&&(n.customHandler=((t,e,n)=>{const i={authTransport:e.transport,authEndpoint:e.endpoint,auth:{params:e.params,headers:e.headers}};return(e,r)=>{const s=t.channel(e.channelName);n(s,i).authorize(e.socketId,r)}})(e,n,t.authorizer))),n}(t,e);return"customHandler"in n&&null!=n.customHandler?n.customHandler:ye(n)}class Ee extends at{constructor(t){super((function(t,e){V.debug("No callbacks on watchlist events for "+t)})),this.pusher=t,this.bindWatchlistInternalEvent()}handleEvent(t){t.data.events.forEach(t=>{this.emit(t.name,t)})}bindWatchlistInternalEvent(){this.pusher.connection.bind("message",t=>{"pusher_internal:watchlist_events"===t.event&&this.handleEvent(t)})}}var Oe=function(){let t,e;return{promise:new Promise((n,i)=>{t=n,e=i}),resolve:t,reject:e}};class xe extends at{constructor(t){super((function(t,e){V.debug("No callbacks on user for "+t)})),this.signin_requested=!1,this.user_data=null,this.serverToUserChannel=null,this.signinDonePromise=null,this._signinDoneResolve=null,this._onAuthorize=(t,e)=>{if(t)return V.warn("Error during signin: "+t),void this._cleanup();this.pusher.send_event("pusher:signin",{auth:e.auth,user_data:e.user_data})},this.pusher=t,this.pusher.connection.bind("state_change",({previous:t,current:e})=>{"connected"!==t&&"connected"===e&&this._signin(),"connected"===t&&"connected"!==e&&(this._cleanup(),this._newSigninPromiseIfNeeded())}),this.watchlist=new Ee(t),this.pusher.connection.bind("message",t=>{"pusher:signin_success"===t.event&&this._onSigninSuccess(t.data),this.serverToUserChannel&&this.serverToUserChannel.name===t.channel&&this.serverToUserChannel.handleEvent(t)})}signin(){this.signin_requested||(this.signin_requested=!0,this._signin())}_signin(){this.signin_requested&&(this._newSigninPromiseIfNeeded(),"connected"===this.pusher.connection.state&&this.pusher.config.userAuthenticator({socketId:this.pusher.connection.socket_id},this._onAuthorize))}_onSigninSuccess(t){try{this.user_data=JSON.parse(t.user_data)}catch(e){return V.error("Failed parsing user data after signin: "+t.user_data),void this._cleanup()}if("string"!=typeof this.user_data.id||""===this.user_data.id)return V.error("user_data doesn't contain an id. user_data: "+this.user_data),void this._cleanup();this._signinDoneResolve(),this._subscribeChannels()}_subscribeChannels(){this.serverToUserChannel=new Ot("#server-to-user-"+this.user_data.id,this.pusher),this.serverToUserChannel.bind_global((t,e)=>{0!==t.indexOf("pusher_internal:")&&0!==t.indexOf("pusher:")&&this.emit(t,e)}),(t=>{t.subscriptionPending&&t.subscriptionCancelled?t.reinstateSubscription():t.subscriptionPending||"connected"!==this.pusher.connection.state||t.subscribe()})(this.serverToUserChannel)}_cleanup(){this.user_data=null,this.serverToUserChannel&&(this.serverToUserChannel.unbind_all(),this.serverToUserChannel.disconnect(),this.serverToUserChannel=null),this.signin_requested&&this._signinDoneResolve()}_newSigninPromiseIfNeeded(){if(!this.signin_requested)return;if(this.signinDonePromise&&!this.signinDonePromise.done)return;const{promise:t,resolve:e,reject:n}=Oe();t.done=!1;const i=()=>{t.done=!0};t.then(i).catch(i),this.signinDonePromise=t,this._signinDoneResolve=e}}class Le{static ready(){Le.isReady=!0;for(var t=0,e=Le.instances.length;tue.getDefaultStrategy(this.config,t,ve),timeline:this.timeline,activityTimeout:this.config.activityTimeout,pongTimeout:this.config.pongTimeout,unavailableTimeout:this.config.unavailableTimeout,useTLS:Boolean(this.config.useTLS)}),this.connection.bind("connected",()=>{this.subscribeAll(),this.timelineSender&&this.timelineSender.send(this.connection.isUsingTLS())}),this.connection.bind("message",t=>{var e=0===t.event.indexOf("pusher_internal:");if(t.channel){var n=this.channel(t.channel);n&&n.handleEvent(t)}e||this.global_emitter.emit(t.event,t.data)}),this.connection.bind("connecting",()=>{this.channels.disconnect()}),this.connection.bind("disconnected",()=>{this.channels.disconnect()}),this.connection.bind("error",t=>{V.warn(t)}),Le.instances.push(this),this.timeline.info({instances:Le.instances.length}),this.user=new xe(this),Le.isReady&&this.connect()}switchCluster(t){const{appKey:e,cluster:n}=t;this.key=e,this.options=Object.assign(Object.assign({},this.options),{cluster:n}),this.config=we(this.options,this),this.connection.switchCluster(this.key)}channel(t){return this.channels.find(t)}allChannels(){return this.channels.all()}connect(){if(this.connection.connect(),this.timelineSender&&!this.timelineSenderTimer){var t=this.connection.isUsingTLS(),e=this.timelineSender;this.timelineSenderTimer=new D(6e4,(function(){e.send(t)}))}}disconnect(){this.connection.disconnect(),this.timelineSenderTimer&&(this.timelineSenderTimer.ensureAborted(),this.timelineSenderTimer=null)}bind(t,e,n){return this.global_emitter.bind(t,e,n),this}unbind(t,e,n){return this.global_emitter.unbind(t,e,n),this}bind_global(t){return this.global_emitter.bind_global(t),this}unbind_global(t){return this.global_emitter.unbind_global(t),this}unbind_all(t){return this.global_emitter.unbind_all(),this}subscribeAll(){var t;for(t in this.channels.channels)this.channels.channels.hasOwnProperty(t)&&this.subscribe(t)}subscribe(t){var e=this.channels.add(t,this);return e.subscriptionPending&&e.subscriptionCancelled?e.reinstateSubscription():e.subscriptionPending||"connected"!==this.connection.state||e.subscribe(),e}unsubscribe(t){var e=this.channels.find(t);e&&e.subscriptionPending?e.cancelSubscription():(e=this.channels.remove(t))&&e.subscribed&&e.unsubscribe()}send_event(t,e,n){return this.connection.send_event(t,e,n)}shouldUseTLS(){return this.config.useTLS}signin(){this.user.signin()}}Le.instances=[],Le.isReady=!1,Le.logToConsole=!1,Le.Runtime=ue,Le.ScriptReceivers=ue.ScriptReceivers,Le.DependenciesReceivers=ue.DependenciesReceivers,Le.auth_callbacks=ue.auth_callbacks;var Ae=e.default=Le;ue.setup(Le)}])})); +!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.Pusher=e():t.Pusher=e()}(window,(function(){return function(t){var e={};function n(i){if(e[i])return e[i].exports;var r=e[i]={i:i,l:!1,exports:{}};return t[i].call(r.exports,r,r.exports,n),r.l=!0,r.exports}return n.m=t,n.c=e,n.d=function(t,e,i){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:i})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var i=Object.create(null);if(n.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var r in t)n.d(i,r,function(e){return t[e]}.bind(null,r));return i},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=2)}([function(t,e,n){"use strict";var i,r=this&&this.__extends||(i=function(t,e){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)},function(t,e){function n(){this.constructor=t}i(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)});Object.defineProperty(e,"__esModule",{value:!0});var s=function(){function t(t){void 0===t&&(t="="),this._paddingCharacter=t}return t.prototype.encodedLength=function(t){return this._paddingCharacter?(t+2)/3*4|0:(8*t+5)/6|0},t.prototype.encode=function(t){for(var e="",n=0;n>>18&63),e+=this._encodeByte(i>>>12&63),e+=this._encodeByte(i>>>6&63),e+=this._encodeByte(i>>>0&63)}var r=t.length-n;if(r>0){i=t[n]<<16|(2===r?t[n+1]<<8:0);e+=this._encodeByte(i>>>18&63),e+=this._encodeByte(i>>>12&63),e+=2===r?this._encodeByte(i>>>6&63):this._paddingCharacter||"",e+=this._paddingCharacter||""}return e},t.prototype.maxDecodedLength=function(t){return this._paddingCharacter?t/4*3|0:(6*t+7)/8|0},t.prototype.decodedLength=function(t){return this.maxDecodedLength(t.length-this._getPaddingLength(t))},t.prototype.decode=function(t){if(0===t.length)return new Uint8Array(0);for(var e=this._getPaddingLength(t),n=t.length-e,i=new Uint8Array(this.maxDecodedLength(n)),r=0,s=0,o=0,a=0,c=0,h=0,u=0;s>>4,i[r++]=c<<4|h>>>2,i[r++]=h<<6|u,o|=256&a,o|=256&c,o|=256&h,o|=256&u;if(s>>4,o|=256&a,o|=256&c),s>>2,o|=256&h),s>>8&6,e+=51-t>>>8&-75,e+=61-t>>>8&-15,e+=62-t>>>8&3,String.fromCharCode(e)},t.prototype._decodeChar=function(t){var e=256;return e+=(42-t&t-44)>>>8&-256+t-43+62,e+=(46-t&t-48)>>>8&-256+t-47+63,e+=(47-t&t-58)>>>8&-256+t-48+52,e+=(64-t&t-91)>>>8&-256+t-65+0,e+=(96-t&t-123)>>>8&-256+t-97+26},t.prototype._getPaddingLength=function(t){var e=0;if(this._paddingCharacter){for(var n=t.length-1;n>=0&&t[n]===this._paddingCharacter;n--)e++;if(t.length<4||e>2)throw new Error("Base64Coder: incorrect padding")}return e},t}();e.Coder=s;var o=new s;e.encode=function(t){return o.encode(t)},e.decode=function(t){return o.decode(t)};var a=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r(e,t),e.prototype._encodeByte=function(t){var e=t;return e+=65,e+=25-t>>>8&6,e+=51-t>>>8&-75,e+=61-t>>>8&-13,e+=62-t>>>8&49,String.fromCharCode(e)},e.prototype._decodeChar=function(t){var e=256;return e+=(44-t&t-46)>>>8&-256+t-45+62,e+=(94-t&t-96)>>>8&-256+t-95+63,e+=(47-t&t-58)>>>8&-256+t-48+52,e+=(64-t&t-91)>>>8&-256+t-65+0,e+=(96-t&t-123)>>>8&-256+t-97+26},e}(s);e.URLSafeCoder=a;var c=new a;e.encodeURLSafe=function(t){return c.encode(t)},e.decodeURLSafe=function(t){return c.decode(t)},e.encodedLength=function(t){return o.encodedLength(t)},e.maxDecodedLength=function(t){return o.maxDecodedLength(t)},e.decodedLength=function(t){return o.decodedLength(t)}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i="utf8: invalid source encoding";function r(t){for(var e=0,n=0;n=t.length-1)throw new Error("utf8: invalid string");n++,e+=4}}return e}e.encode=function(t){for(var e=new Uint8Array(r(t)),n=0,i=0;i>6,e[n++]=128|63&s):s<55296?(e[n++]=224|s>>12,e[n++]=128|s>>6&63,e[n++]=128|63&s):(i++,s=(1023&s)<<10,s|=1023&t.charCodeAt(i),s+=65536,e[n++]=240|s>>18,e[n++]=128|s>>12&63,e[n++]=128|s>>6&63,e[n++]=128|63&s)}return e},e.encodedLength=r,e.decode=function(t){for(var e=[],n=0;n=t.length)throw new Error(i);if(128!=(192&(o=t[++n])))throw new Error(i);r=(31&r)<<6|63&o,s=128}else if(r<240){if(n>=t.length-1)throw new Error(i);var o=t[++n],a=t[++n];if(128!=(192&o)||128!=(192&a))throw new Error(i);r=(15&r)<<12|(63&o)<<6|63&a,s=2048}else{if(!(r<248))throw new Error(i);if(n>=t.length-2)throw new Error(i);o=t[++n],a=t[++n];var c=t[++n];if(128!=(192&o)||128!=(192&a)||128!=(192&c))throw new Error(i);r=(15&r)<<18|(63&o)<<12|(63&a)<<6|63&c,s=65536}if(r=55296&&r<=57343)throw new Error(i);if(r>=65536){if(r>1114111)throw new Error(i);r-=65536,e.push(String.fromCharCode(55296|r>>10)),r=56320|1023&r}}e.push(String.fromCharCode(r))}return e.join("")}},function(t,e,n){t.exports=n(3).default},function(t,e,n){"use strict";n.r(e);class i{constructor(t,e){this.lastId=0,this.prefix=t,this.name=e}create(t){this.lastId++;var e=this.lastId,n=this.prefix+e,i=this.name+"["+e+"]",r=!1,s=function(){r||(t.apply(null,arguments),r=!0)};return this[e]=s,{number:e,id:n,name:i,callback:s}}remove(t){delete this[t.number]}}var r=new i("_pusher_script_","Pusher.ScriptReceivers"),s={VERSION:"8.4.0-rc2",PROTOCOL:7,wsPort:80,wssPort:443,wsPath:"",httpHost:"sockjs.pusher.com",httpPort:80,httpsPort:443,httpPath:"/pusher",stats_host:"stats.pusher.com",authEndpoint:"/pusher/auth",authTransport:"ajax",activityTimeout:12e4,pongTimeout:3e4,unavailableTimeout:1e4,userAuthentication:{endpoint:"/pusher/user-auth",transport:"ajax"},channelAuthorization:{endpoint:"/pusher/auth",transport:"ajax"},cdn_http:"http://js.pusher.com",cdn_https:"https://js.pusher.com",dependency_suffix:""};var o=new i("_pusher_dependencies","Pusher.DependenciesReceivers"),a=new class{constructor(t){this.options=t,this.receivers=t.receivers||r,this.loading={}}load(t,e,n){var i=this;if(i.loading[t]&&i.loading[t].length>0)i.loading[t].push(n);else{i.loading[t]=[n];var r=ue.createScriptRequest(i.getPath(t,e)),s=i.receivers.create((function(e){if(i.receivers.remove(s),i.loading[t]){var n=i.loading[t];delete i.loading[t];for(var o=function(t){t||r.cleanup()},a=0;a>>6)+S(128|63&e):S(224|e>>>12&15)+S(128|e>>>6&63)+S(128|63&e)},E=function(t){return t.replace(/[^\x00-\x7F]/g,P)},O=function(t){var e=[0,2,1][t.length%3],n=t.charCodeAt(0)<<16|(t.length>1?t.charCodeAt(1):0)<<8|(t.length>2?t.charCodeAt(2):0);return[_.charAt(n>>>18),_.charAt(n>>>12&63),e>=2?"=":_.charAt(n>>>6&63),e>=1?"=":_.charAt(63&n)].join("")},x=window.btoa||function(t){return t.replace(/[\s\S]{1,3}/g,O)};var L=class{constructor(t,e,n,i){this.clear=e,this.timer=t(()=>{this.timer&&(this.timer=i(this.timer))},n)}isRunning(){return null!==this.timer}ensureAborted(){this.timer&&(this.clear(this.timer),this.timer=null)}};function A(t){window.clearTimeout(t)}function R(t){window.clearInterval(t)}class I extends L{constructor(t,e){super(setTimeout,A,t,(function(t){return e(),null}))}}class D extends L{constructor(t,e){super(setInterval,R,t,(function(t){return e(),t}))}}var j={now:()=>Date.now?Date.now():(new Date).valueOf(),defer:t=>new I(0,t),method(t,...e){var n=Array.prototype.slice.call(arguments,1);return function(e){return e[t].apply(e,n.concat(arguments))}}};function N(t,...e){for(var n=0;n{window.console&&window.console.log&&window.console.log(t)}}debug(...t){this.log(this.globalLog,t)}warn(...t){this.log(this.globalLogWarn,t)}error(...t){this.log(this.globalLogError,t)}globalLogWarn(t){window.console&&window.console.warn?window.console.warn(t):this.globalLog(t)}globalLogError(t){window.console&&window.console.error?window.console.error(t):this.globalLogWarn(t)}log(t,...e){var n=U.apply(this,arguments);if(Ie.log)Ie.log(n);else if(Ie.logToConsole){t.bind(this)(n)}}},Y=function(t,e,n,i,r){void 0===n.headers&&null==n.headersProvider||V.warn(`To send headers with the ${i.toString()} request, you must use AJAX, rather than JSONP.`);var s=t.nextAuthCallbackID.toString();t.nextAuthCallbackID++;var o=t.getDocument(),a=o.createElement("script");t.auth_callbacks[s]=function(t){r(null,t)};var c="Pusher.auth_callbacks['"+s+"']";a.src=n.endpoint+"?callback="+encodeURIComponent(c)+"&"+e;var h=o.getElementsByTagName("head")[0]||o.documentElement;h.insertBefore(a,h.firstChild)};class K{constructor(t){this.src=t}send(t){var e=this,n="Error loading "+e.src;e.script=document.createElement("script"),e.script.id=t.id,e.script.src=e.src,e.script.type="text/javascript",e.script.charset="UTF-8",e.script.addEventListener?(e.script.onerror=function(){t.callback(n)},e.script.onload=function(){t.callback(null)}):e.script.onreadystatechange=function(){"loaded"!==e.script.readyState&&"complete"!==e.script.readyState||t.callback(null)},void 0===e.script.async&&document.attachEvent&&/opera/i.test(navigator.userAgent)?(e.errorScript=document.createElement("script"),e.errorScript.id=t.id+"_error",e.errorScript.text=t.name+"('"+n+"');",e.script.async=e.errorScript.async=!1):e.script.async=!0;var i=document.getElementsByTagName("head")[0];i.insertBefore(e.script,i.firstChild),e.errorScript&&i.insertBefore(e.errorScript,e.script.nextSibling)}cleanup(){this.script&&(this.script.onload=this.script.onerror=null,this.script.onreadystatechange=null),this.script&&this.script.parentNode&&this.script.parentNode.removeChild(this.script),this.errorScript&&this.errorScript.parentNode&&this.errorScript.parentNode.removeChild(this.errorScript),this.script=null,this.errorScript=null}}class Q{constructor(t,e){this.url=t,this.data=e}send(t){if(!this.request){var e=W(this.data),n=this.url+"/"+t.number+"?"+e;this.request=ue.createScriptRequest(n),this.request.send(t)}}cleanup(){this.request&&this.request.cleanup()}}var Z={name:"jsonp",getAgent:function(t,e){return function(n,i){var s="http"+(e?"s":"")+"://"+(t.host||t.options.host)+t.options.path,o=ue.createJSONPRequest(s,n),a=ue.ScriptReceivers.create((function(e,n){r.remove(a),o.cleanup(),n&&n.host&&(t.host=n.host),i&&i(e,n)}));o.send(a)}}};function tt(t,e,n){return t+(e.useTLS?"s":"")+"://"+(e.useTLS?e.hostTLS:e.hostNonTLS)+n}function et(t,e){return"/app/"+t+("?protocol="+s.PROTOCOL+"&client=js&version="+s.VERSION+(e?"&"+e:""))}var nt={getInitial:function(t,e){return tt("ws",e,(e.httpPath||"")+et(t,"flash=false"))}},it={getInitial:function(t,e){return tt("http",e,(e.httpPath||"/pusher")+et(t))}},rt={getInitial:function(t,e){return tt("http",e,e.httpPath||"/pusher")},getPath:function(t,e){return et(t)}};class st{constructor(){this._callbacks={}}get(t){return this._callbacks[ot(t)]}add(t,e,n){var i=ot(t);this._callbacks[i]=this._callbacks[i]||[],this._callbacks[i].push({fn:e,context:n})}remove(t,e,n){if(t||e||n){var i=t?[ot(t)]:z(this._callbacks);e||n?this.removeCallback(i,e,n):this.removeAllCallbacks(i)}else this._callbacks={}}removeCallback(t,e,n){q(t,(function(t){this._callbacks[t]=F(this._callbacks[t]||[],(function(t){return e&&e!==t.fn||n&&n!==t.context})),0===this._callbacks[t].length&&delete this._callbacks[t]}),this)}removeAllCallbacks(t){q(t,(function(t){delete this._callbacks[t]}),this)}}function ot(t){return"_"+t}class at{constructor(t){this.callbacks=new st,this.global_callbacks=[],this.failThrough=t}bind(t,e,n){return this.callbacks.add(t,e,n),this}bind_global(t){return this.global_callbacks.push(t),this}unbind(t,e,n){return this.callbacks.remove(t,e,n),this}unbind_global(t){return t?(this.global_callbacks=F(this.global_callbacks||[],e=>e!==t),this):(this.global_callbacks=[],this)}unbind_all(){return this.unbind(),this.unbind_global(),this}emit(t,e,n){for(var i=0;i0)for(i=0;i{this.onError(t),this.changeState("closed")}),!1}return this.bindListeners(),V.debug("Connecting",{transport:this.name,url:t}),this.changeState("connecting"),!0}close(){return!!this.socket&&(this.socket.close(),!0)}send(t){return"open"===this.state&&(j.defer(()=>{this.socket&&this.socket.send(t)}),!0)}ping(){"open"===this.state&&this.supportsPing()&&this.socket.ping()}onOpen(){this.hooks.beforeOpen&&this.hooks.beforeOpen(this.socket,this.hooks.urls.getPath(this.key,this.options)),this.changeState("open"),this.socket.onopen=void 0}onError(t){this.emit("error",{type:"WebSocketError",error:t}),this.timeline.error(this.buildTimelineMessage({error:t.toString()}))}onClose(t){t?this.changeState("closed",{code:t.code,reason:t.reason,wasClean:t.wasClean}):this.changeState("closed"),this.unbindListeners(),this.socket=void 0}onMessage(t){this.emit("message",t)}onActivity(){this.emit("activity")}bindListeners(){this.socket.onopen=()=>{this.onOpen()},this.socket.onerror=t=>{this.onError(t)},this.socket.onclose=t=>{this.onClose(t)},this.socket.onmessage=t=>{this.onMessage(t)},this.supportsPing()&&(this.socket.onactivity=()=>{this.onActivity()})}unbindListeners(){this.socket&&(this.socket.onopen=void 0,this.socket.onerror=void 0,this.socket.onclose=void 0,this.socket.onmessage=void 0,this.supportsPing()&&(this.socket.onactivity=void 0))}changeState(t,e){this.state=t,this.timeline.info(this.buildTimelineMessage({state:t,params:e})),this.emit(t,e)}buildTimelineMessage(t){return N({cid:this.id},t)}}class ht{constructor(t){this.hooks=t}isSupported(t){return this.hooks.isSupported(t)}createConnection(t,e,n,i){return new ct(this.hooks,t,e,n,i)}}var ut=new ht({urls:nt,handlesActivityChecks:!1,supportsPing:!1,isInitialized:function(){return Boolean(ue.getWebSocketAPI())},isSupported:function(){return Boolean(ue.getWebSocketAPI())},getSocket:function(t){return ue.createWebSocket(t)}}),lt={urls:it,handlesActivityChecks:!1,supportsPing:!0,isInitialized:function(){return!0}},dt=N({getSocket:function(t){return ue.HTTPFactory.createStreamingSocket(t)}},lt),pt=N({getSocket:function(t){return ue.HTTPFactory.createPollingSocket(t)}},lt),ft={isSupported:function(){return ue.isXHRSupported()}},gt={ws:ut,xhr_streaming:new ht(N({},dt,ft)),xhr_polling:new ht(N({},pt,ft))},vt=new ht({file:"sockjs",urls:rt,handlesActivityChecks:!0,supportsPing:!1,isSupported:function(){return!0},isInitialized:function(){return void 0!==window.SockJS},getSocket:function(t,e){return new window.SockJS(t,null,{js_path:a.getPath("sockjs",{useTLS:e.useTLS}),ignore_null_origin:e.ignoreNullOrigin})},beforeOpen:function(t,e){t.send(JSON.stringify({path:e}))}}),bt={isSupported:function(t){return ue.isXDRSupported(t.useTLS)}},mt=new ht(N({},dt,bt)),yt=new ht(N({},pt,bt));gt.xdr_streaming=mt,gt.xdr_polling=yt,gt.sockjs=vt;var wt=gt;var St=new class extends at{constructor(){super();var t=this;void 0!==window.addEventListener&&(window.addEventListener("online",(function(){t.emit("online")}),!1),window.addEventListener("offline",(function(){t.emit("offline")}),!1))}isOnline(){return void 0===window.navigator.onLine||window.navigator.onLine}};class _t{constructor(t,e,n){this.manager=t,this.transport=e,this.minPingDelay=n.minPingDelay,this.maxPingDelay=n.maxPingDelay,this.pingDelay=void 0}createConnection(t,e,n,i){i=N({},i,{activityTimeout:this.pingDelay});var r=this.transport.createConnection(t,e,n,i),s=null,o=function(){r.unbind("open",o),r.bind("closed",a),s=j.now()},a=t=>{if(r.unbind("closed",a),1002===t.code||1003===t.code)this.manager.reportDeath();else if(!t.wasClean&&s){var e=j.now()-s;e<2*this.maxPingDelay&&(this.manager.reportDeath(),this.pingDelay=Math.max(e/2,this.minPingDelay))}};return r.bind("open",o),r}isSupported(t){return this.manager.isAlive()&&this.transport.isSupported(t)}}const kt={decodeMessage:function(t){try{var e=JSON.parse(t.data),n=e.data;if("string"==typeof n)try{n=JSON.parse(e.data)}catch(t){}var i={event:e.event,channel:e.channel,data:n};return e.user_id&&(i.user_id=e.user_id),i}catch(e){throw{type:"MessageParseError",error:e,data:t.data}}},encodeMessage:function(t){return JSON.stringify(t)},processHandshake:function(t){var e=kt.decodeMessage(t);if("pusher:connection_established"===e.event){if(!e.data.activity_timeout)throw"No activity timeout specified in handshake";return{action:"connected",id:e.data.socket_id,activityTimeout:1e3*e.data.activity_timeout}}if("pusher:error"===e.event)return{action:this.getCloseAction(e.data),error:this.getCloseError(e.data)};throw"Invalid handshake"},getCloseAction:function(t){return t.code<4e3?t.code>=1002&&t.code<=1004?"backoff":null:4e3===t.code?"tls_only":t.code<4100?"refused":t.code<4200?"backoff":t.code<4300?"retry":"refused"},getCloseError:function(t){return 1e3!==t.code&&1001!==t.code?{type:"PusherError",data:{code:t.code,message:t.reason||t.message}}:null}};var Ct=kt;class Tt extends at{constructor(t,e){super(),this.id=t,this.transport=e,this.activityTimeout=e.activityTimeout,this.bindListeners()}handlesActivityChecks(){return this.transport.handlesActivityChecks()}send(t){return this.transport.send(t)}send_event(t,e,n){var i={event:t,data:e};return n&&(i.channel=n),V.debug("Event sent",i),this.send(Ct.encodeMessage(i))}ping(){this.transport.supportsPing()?this.transport.ping():this.send_event("pusher:ping",{})}close(){this.transport.close()}bindListeners(){var t={message:t=>{var e;try{e=Ct.decodeMessage(t)}catch(e){this.emit("error",{type:"MessageParseError",error:e,data:t.data})}if(void 0!==e){switch(V.debug("Event recd",e),e.event){case"pusher:error":this.emit("error",{type:"PusherError",data:e.data});break;case"pusher:ping":this.emit("ping");break;case"pusher:pong":this.emit("pong")}this.emit("message",e)}},activity:()=>{this.emit("activity")},error:t=>{this.emit("error",t)},closed:t=>{e(),t&&t.code&&this.handleCloseEvent(t),this.transport=null,this.emit("closed")}},e=()=>{M(t,(t,e)=>{this.transport.unbind(e,t)})};M(t,(t,e)=>{this.transport.bind(e,t)})}handleCloseEvent(t){var e=Ct.getCloseAction(t),n=Ct.getCloseError(t);n&&this.emit("error",n),e&&this.emit(e,{action:e,error:n})}}class Pt{constructor(t,e){this.transport=t,this.callback=e,this.bindListeners()}close(){this.unbindListeners(),this.transport.close()}bindListeners(){this.onMessage=t=>{var e;this.unbindListeners();try{e=Ct.processHandshake(t)}catch(t){return this.finish("error",{error:t}),void this.transport.close()}"connected"===e.action?this.finish("connected",{connection:new Tt(e.id,this.transport),activityTimeout:e.activityTimeout}):(this.finish(e.action,{error:e.error}),this.transport.close())},this.onClosed=t=>{this.unbindListeners();var e=Ct.getCloseAction(t)||"backoff",n=Ct.getCloseError(t);this.finish(e,{error:n})},this.transport.bind("message",this.onMessage),this.transport.bind("closed",this.onClosed)}unbindListeners(){this.transport.unbind("message",this.onMessage),this.transport.unbind("closed",this.onClosed)}finish(t,e){this.callback(N({transport:this.transport,action:t},e))}}class Et{constructor(t,e){this.timeline=t,this.options=e||{}}send(t,e){this.timeline.isEmpty()||this.timeline.send(ue.TimelineTransport.getAgent(this,t),e)}}class Ot extends at{constructor(t,e){super((function(e,n){V.debug("No callbacks on "+t+" for "+e)})),this.name=t,this.pusher=e,this.subscribed=!1,this.subscriptionPending=!1,this.subscriptionCancelled=!1}authorize(t,e){return e(null,{auth:""})}trigger(t,e){if(0!==t.indexOf("client-"))throw new l("Event '"+t+"' does not start with 'client-'");if(!this.subscribed){var n=u("triggeringClientEvents");V.warn("Client event triggered before channel 'subscription_succeeded' event . "+n)}return this.pusher.send_event(t,e,this.name)}disconnect(){this.subscribed=!1,this.subscriptionPending=!1}handleEvent(t){var e=t.event,n=t.data;if("pusher_internal:subscription_succeeded"===e)this.handleSubscriptionSucceededEvent(t);else if("pusher_internal:subscription_count"===e)this.handleSubscriptionCountEvent(t);else if(0!==e.indexOf("pusher_internal:")){this.emit(e,n,{})}}handleSubscriptionSucceededEvent(t){this.subscriptionPending=!1,this.subscribed=!0,this.subscriptionCancelled?this.pusher.unsubscribe(this.name):this.emit("pusher:subscription_succeeded",t.data)}handleSubscriptionCountEvent(t){t.data.subscription_count&&(this.subscriptionCount=t.data.subscription_count),this.emit("pusher:subscription_count",t.data)}subscribe(){this.subscribed||(this.subscriptionPending=!0,this.subscriptionCancelled=!1,this.authorize(this.pusher.connection.socket_id,(t,e)=>{t?(this.subscriptionPending=!1,V.error(t.toString()),this.emit("pusher:subscription_error",Object.assign({},{type:"AuthError",error:t.message},t instanceof y?{status:t.status}:{}))):this.pusher.send_event("pusher:subscribe",{auth:e.auth,channel_data:e.channel_data,channel:this.name})}))}unsubscribe(){this.subscribed=!1,this.pusher.send_event("pusher:unsubscribe",{channel:this.name})}cancelSubscription(){this.subscriptionCancelled=!0}reinstateSubscription(){this.subscriptionCancelled=!1}}class xt extends Ot{authorize(t,e){return this.pusher.config.channelAuthorizer({channelName:this.name,socketId:t},e)}}class Lt{constructor(){this.reset()}get(t){return Object.prototype.hasOwnProperty.call(this.members,t)?{id:t,info:this.members[t]}:null}each(t){M(this.members,(e,n)=>{t(this.get(n))})}setMyID(t){this.myID=t}onSubscription(t){this.members=t.presence.hash,this.count=t.presence.count,this.me=this.get(this.myID)}addMember(t){return null===this.get(t.user_id)&&this.count++,this.members[t.user_id]=t.user_info,this.get(t.user_id)}removeMember(t){var e=this.get(t.user_id);return e&&(delete this.members[t.user_id],this.count--),e}reset(){this.members={},this.count=0,this.myID=null,this.me=null}}var At=function(t,e,n,i){return new(n||(n=Promise))((function(r,s){function o(t){try{c(i.next(t))}catch(t){s(t)}}function a(t){try{c(i.throw(t))}catch(t){s(t)}}function c(t){var e;t.done?r(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(o,a)}c((i=i.apply(t,e||[])).next())}))};class Rt extends xt{constructor(t,e){super(t,e),this.members=new Lt}authorize(t,e){super.authorize(t,(t,n)=>At(this,void 0,void 0,(function*(){if(!t)if(null!=(n=n).channel_data){var i=JSON.parse(n.channel_data);this.members.setMyID(i.user_id)}else{if(yield this.pusher.user.signinDonePromise,null==this.pusher.user.user_data){let t=u("authorizationEndpoint");return V.error(`Invalid auth response for channel '${this.name}', expected 'channel_data' field. ${t}, or the user should be signed in.`),void e("Invalid auth response")}this.members.setMyID(this.pusher.user.user_data.id)}e(t,n)})))}handleEvent(t){var e=t.event;if(0===e.indexOf("pusher_internal:"))this.handleInternalEvent(t);else{var n=t.data,i={};t.user_id&&(i.user_id=t.user_id),this.emit(e,n,i)}}handleInternalEvent(t){var e=t.event,n=t.data;switch(e){case"pusher_internal:subscription_succeeded":this.handleSubscriptionSucceededEvent(t);break;case"pusher_internal:subscription_count":this.handleSubscriptionCountEvent(t);break;case"pusher_internal:member_added":var i=this.members.addMember(n);this.emit("pusher:member_added",i);break;case"pusher_internal:member_removed":var r=this.members.removeMember(n);r&&this.emit("pusher:member_removed",r)}}handleSubscriptionSucceededEvent(t){this.subscriptionPending=!1,this.subscribed=!0,this.subscriptionCancelled?this.pusher.unsubscribe(this.name):(this.members.onSubscription(t.data),this.emit("pusher:subscription_succeeded",this.members))}disconnect(){this.members.reset(),super.disconnect()}}var It=n(1),Dt=n(0);class jt extends xt{constructor(t,e,n){super(t,e),this.key=null,this.nacl=n}authorize(t,e){super.authorize(t,(t,n)=>{if(t)return void e(t,n);let i=n.shared_secret;i?(this.key=Object(Dt.decode)(i),delete n.shared_secret,e(null,n)):e(new Error("No shared_secret key in auth payload for encrypted channel: "+this.name),null)})}trigger(t,e){throw new v("Client events are not currently supported for encrypted channels")}handleEvent(t){var e=t.event,n=t.data;0!==e.indexOf("pusher_internal:")&&0!==e.indexOf("pusher:")?this.handleEncryptedEvent(e,n):super.handleEvent(t)}handleEncryptedEvent(t,e){if(!this.key)return void V.debug("Received encrypted event before key has been retrieved from the authEndpoint");if(!e.ciphertext||!e.nonce)return void V.error("Unexpected format for encrypted event, expected object with `ciphertext` and `nonce` fields, got: "+e);let n=Object(Dt.decode)(e.ciphertext);if(n.length{e?V.error(`Failed to make a request to the authEndpoint: ${s}. Unable to fetch new key, so dropping encrypted event`):(r=this.nacl.secretbox.open(n,i,this.key),null!==r?this.emit(t,this.getDataToEmit(r)):V.error("Failed to decrypt event with new key. Dropping encrypted event"))});this.emit(t,this.getDataToEmit(r))}getDataToEmit(t){let e=Object(It.decode)(t);try{return JSON.parse(e)}catch(t){return e}}}class Nt extends at{constructor(t,e){super(),this.state="initialized",this.connection=null,this.key=t,this.options=e,this.timeline=this.options.timeline,this.usingTLS=this.options.useTLS,this.errorCallbacks=this.buildErrorCallbacks(),this.connectionCallbacks=this.buildConnectionCallbacks(this.errorCallbacks),this.handshakeCallbacks=this.buildHandshakeCallbacks(this.errorCallbacks);var n=ue.getNetwork();n.bind("online",()=>{this.timeline.info({netinfo:"online"}),"connecting"!==this.state&&"unavailable"!==this.state||this.retryIn(0)}),n.bind("offline",()=>{this.timeline.info({netinfo:"offline"}),this.connection&&this.sendActivityCheck()}),this.updateStrategy()}switchCluster(t){this.key=t,this.updateStrategy(),this.retryIn(0)}connect(){this.connection||this.runner||(this.strategy.isSupported()?(this.updateState("connecting"),this.startConnecting(),this.setUnavailableTimer()):this.updateState("failed"))}send(t){return!!this.connection&&this.connection.send(t)}send_event(t,e,n){return!!this.connection&&this.connection.send_event(t,e,n)}disconnect(){this.disconnectInternally(),this.updateState("disconnected")}isUsingTLS(){return this.usingTLS}startConnecting(){var t=(e,n)=>{e?this.runner=this.strategy.connect(0,t):"error"===n.action?(this.emit("error",{type:"HandshakeError",error:n.error}),this.timeline.error({handshakeError:n.error})):(this.abortConnecting(),this.handshakeCallbacks[n.action](n))};this.runner=this.strategy.connect(0,t)}abortConnecting(){this.runner&&(this.runner.abort(),this.runner=null)}disconnectInternally(){(this.abortConnecting(),this.clearRetryTimer(),this.clearUnavailableTimer(),this.connection)&&this.abandonConnection().close()}updateStrategy(){this.strategy=this.options.getStrategy({key:this.key,timeline:this.timeline,useTLS:this.usingTLS})}retryIn(t){this.timeline.info({action:"retry",delay:t}),t>0&&this.emit("connecting_in",Math.round(t/1e3)),this.retryTimer=new I(t||0,()=>{this.disconnectInternally(),this.connect()})}clearRetryTimer(){this.retryTimer&&(this.retryTimer.ensureAborted(),this.retryTimer=null)}setUnavailableTimer(){this.unavailableTimer=new I(this.options.unavailableTimeout,()=>{this.updateState("unavailable")})}clearUnavailableTimer(){this.unavailableTimer&&this.unavailableTimer.ensureAborted()}sendActivityCheck(){this.stopActivityCheck(),this.connection.ping(),this.activityTimer=new I(this.options.pongTimeout,()=>{this.timeline.error({pong_timed_out:this.options.pongTimeout}),this.retryIn(0)})}resetActivityCheck(){this.stopActivityCheck(),this.connection&&!this.connection.handlesActivityChecks()&&(this.activityTimer=new I(this.activityTimeout,()=>{this.sendActivityCheck()}))}stopActivityCheck(){this.activityTimer&&this.activityTimer.ensureAborted()}buildConnectionCallbacks(t){return N({},t,{message:t=>{this.resetActivityCheck(),this.emit("message",t)},ping:()=>{this.send_event("pusher:pong",{})},activity:()=>{this.resetActivityCheck()},error:t=>{this.emit("error",t)},closed:()=>{this.abandonConnection(),this.shouldRetry()&&this.retryIn(1e3)}})}buildHandshakeCallbacks(t){return N({},t,{connected:t=>{this.activityTimeout=Math.min(this.options.activityTimeout,t.activityTimeout,t.connection.activityTimeout||1/0),this.clearUnavailableTimer(),this.setConnection(t.connection),this.socket_id=this.connection.id,this.updateState("connected",{socket_id:this.socket_id})}})}buildErrorCallbacks(){let t=t=>e=>{e.error&&this.emit("error",{type:"WebSocketError",error:e.error}),t(e)};return{tls_only:t(()=>{this.usingTLS=!0,this.updateStrategy(),this.retryIn(0)}),refused:t(()=>{this.disconnect()}),backoff:t(()=>{this.retryIn(1e3)}),retry:t(()=>{this.retryIn(0)})}}setConnection(t){for(var e in this.connection=t,this.connectionCallbacks)this.connection.bind(e,this.connectionCallbacks[e]);this.resetActivityCheck()}abandonConnection(){if(this.connection){for(var t in this.stopActivityCheck(),this.connectionCallbacks)this.connection.unbind(t,this.connectionCallbacks[t]);var e=this.connection;return this.connection=null,e}}updateState(t,e){var n=this.state;if(this.state=t,n!==t){var i=t;"connected"===i&&(i+=" with new socket ID "+e.socket_id),V.debug("State changed",n+" -> "+i),this.timeline.info({state:t,params:e}),this.emit("state_change",{previous:n,current:t}),this.emit(t,e)}}shouldRetry(){return"connecting"===this.state||"connected"===this.state}}class Ut{constructor(){this.channels={}}add(t,e){return this.channels[t]||(this.channels[t]=function(t,e){if(0===t.indexOf("private-encrypted-")){if(e.config.nacl)return Ht.createEncryptedChannel(t,e,e.config.nacl);let n="Tried to subscribe to a private-encrypted- channel but no nacl implementation available",i=u("encryptedChannelSupport");throw new v(`${n}. ${i}`)}if(0===t.indexOf("private-"))return Ht.createPrivateChannel(t,e);if(0===t.indexOf("presence-"))return Ht.createPresenceChannel(t,e);if(0===t.indexOf("#"))throw new d('Cannot create a channel with name "'+t+'".');return Ht.createChannel(t,e)}(t,e)),this.channels[t]}all(){return function(t){var e=[];return M(t,(function(t){e.push(t)})),e}(this.channels)}find(t){return this.channels[t]}remove(t){var e=this.channels[t];return delete this.channels[t],e}disconnect(){M(this.channels,(function(t){t.disconnect()}))}}var Ht={createChannels:()=>new Ut,createConnectionManager:(t,e)=>new Nt(t,e),createChannel:(t,e)=>new Ot(t,e),createPrivateChannel:(t,e)=>new xt(t,e),createPresenceChannel:(t,e)=>new Rt(t,e),createEncryptedChannel:(t,e,n)=>new jt(t,e,n),createTimelineSender:(t,e)=>new Et(t,e),createHandshake:(t,e)=>new Pt(t,e),createAssistantToTheTransportManager:(t,e,n)=>new _t(t,e,n)};class Mt{constructor(t){this.options=t||{},this.livesLeft=this.options.lives||1/0}getAssistant(t){return Ht.createAssistantToTheTransportManager(this,t,{minPingDelay:this.options.minPingDelay,maxPingDelay:this.options.maxPingDelay})}isAlive(){return this.livesLeft>0}reportDeath(){this.livesLeft-=1}}class zt{constructor(t,e){this.strategies=t,this.loop=Boolean(e.loop),this.failFast=Boolean(e.failFast),this.timeout=e.timeout,this.timeoutLimit=e.timeoutLimit}isSupported(){return J(this.strategies,j.method("isSupported"))}connect(t,e){var n=this.strategies,i=0,r=this.timeout,s=null,o=(a,c)=>{c?e(null,c):(i+=1,this.loop&&(i%=n.length),i0&&(r=new I(n.timeout,(function(){s.abort(),i(!0)}))),s=t.connect(e,(function(t,e){t&&r&&r.isRunning()&&!n.failFast||(r&&r.ensureAborted(),i(t,e))})),{abort:function(){r&&r.ensureAborted(),s.abort()},forceMinPriority:function(t){s.forceMinPriority(t)}}}}class qt{constructor(t){this.strategies=t}isSupported(){return J(this.strategies,j.method("isSupported"))}connect(t,e){return function(t,e,n){var i=B(t,(function(t,i,r,s){return t.connect(e,n(i,s))}));return{abort:function(){q(i,Bt)},forceMinPriority:function(t){q(i,(function(e){e.forceMinPriority(t)}))}}}(this.strategies,t,(function(t,n){return function(i,r){n[t].error=i,i?function(t){return function(t,e){for(var n=0;n=j.now()){var o=this.transports[i.transport];o&&(["ws","wss"].includes(i.transport)||r>3?(this.timeline.info({cached:!0,transport:i.transport,latency:i.latency}),s.push(new zt([o],{timeout:2*i.latency+1e3,failFast:!0}))):r++)}var a=j.now(),c=s.pop().connect(t,(function i(o,h){o?(Jt(n),s.length>0?(a=j.now(),c=s.pop().connect(t,i)):e(o)):(!function(t,e,n,i){var r=ue.getLocalStorage();if(r)try{r[Xt(t)]=G({timestamp:j.now(),transport:e,latency:n,cacheSkipCount:i})}catch(t){}}(n,h.transport.name,j.now()-a,r),e(null,h))}));return{abort:function(){c.abort()},forceMinPriority:function(e){t=e,c&&c.forceMinPriority(e)}}}}function Xt(t){return"pusherTransport"+(t?"TLS":"NonTLS")}function Jt(t){var e=ue.getLocalStorage();if(e)try{delete e[Xt(t)]}catch(t){}}class $t{constructor(t,{delay:e}){this.strategy=t,this.options={delay:e}}isSupported(){return this.strategy.isSupported()}connect(t,e){var n,i=this.strategy,r=new I(this.options.delay,(function(){n=i.connect(t,e)}));return{abort:function(){r.ensureAborted(),n&&n.abort()},forceMinPriority:function(e){t=e,n&&n.forceMinPriority(e)}}}}class Wt{constructor(t,e,n){this.test=t,this.trueBranch=e,this.falseBranch=n}isSupported(){return(this.test()?this.trueBranch:this.falseBranch).isSupported()}connect(t,e){return(this.test()?this.trueBranch:this.falseBranch).connect(t,e)}}class Gt{constructor(t){this.strategy=t}isSupported(){return this.strategy.isSupported()}connect(t,e){var n=this.strategy.connect(t,(function(t,i){i&&n.abort(),e(t,i)}));return n}}function Vt(t){return function(){return t.isSupported()}}var Yt=function(t,e,n){var i={};function r(e,r,s,o,a){var c=n(t,e,r,s,o,a);return i[e]=c,c}var s,o=Object.assign({},e,{hostNonTLS:t.wsHost+":"+t.wsPort,hostTLS:t.wsHost+":"+t.wssPort,httpPath:t.wsPath}),a=Object.assign({},o,{useTLS:!0}),c=Object.assign({},e,{hostNonTLS:t.httpHost+":"+t.httpPort,hostTLS:t.httpHost+":"+t.httpsPort,httpPath:t.httpPath}),h={loop:!0,timeout:15e3,timeoutLimit:6e4},u=new Mt({minPingDelay:1e4,maxPingDelay:t.activityTimeout}),l=new Mt({lives:2,minPingDelay:1e4,maxPingDelay:t.activityTimeout}),d=r("ws","ws",3,o,u),p=r("wss","ws",3,a,u),f=r("sockjs","sockjs",1,c),g=r("xhr_streaming","xhr_streaming",1,c,l),v=r("xdr_streaming","xdr_streaming",1,c,l),b=r("xhr_polling","xhr_polling",1,c),m=r("xdr_polling","xdr_polling",1,c),y=new zt([d],h),w=new zt([p],h),S=new zt([f],h),_=new zt([new Wt(Vt(g),g,v)],h),k=new zt([new Wt(Vt(b),b,m)],h),C=new zt([new Wt(Vt(_),new qt([_,new $t(k,{delay:4e3})]),k)],h),T=new Wt(Vt(C),C,S);return s=e.useTLS?new qt([y,new $t(T,{delay:2e3})]):new qt([y,new $t(w,{delay:2e3}),new $t(T,{delay:5e3})]),new Ft(new Gt(new Wt(Vt(d),s,T)),i,{ttl:18e5,timeline:e.timeline,useTLS:e.useTLS})},Kt={getRequest:function(t){var e=new window.XDomainRequest;return e.ontimeout=function(){t.emit("error",new p),t.close()},e.onerror=function(e){t.emit("error",e),t.close()},e.onprogress=function(){e.responseText&&e.responseText.length>0&&t.onChunk(200,e.responseText)},e.onload=function(){e.responseText&&e.responseText.length>0&&t.onChunk(200,e.responseText),t.emit("finished",200),t.close()},e},abortRequest:function(t){t.ontimeout=t.onerror=t.onprogress=t.onload=null,t.abort()}};class Qt extends at{constructor(t,e,n){super(),this.hooks=t,this.method=e,this.url=n}start(t){this.position=0,this.xhr=this.hooks.getRequest(this),this.unloader=()=>{this.close()},ue.addUnloadListener(this.unloader),this.xhr.open(this.method,this.url,!0),this.xhr.setRequestHeader&&this.xhr.setRequestHeader("Content-Type","application/json"),this.xhr.send(t)}close(){this.unloader&&(ue.removeUnloadListener(this.unloader),this.unloader=null),this.xhr&&(this.hooks.abortRequest(this.xhr),this.xhr=null)}onChunk(t,e){for(;;){var n=this.advanceBuffer(e);if(!n)break;this.emit("chunk",{status:t,data:n})}this.isBufferTooLong(e)&&this.emit("buffer_too_long")}advanceBuffer(t){var e=t.slice(this.position),n=e.indexOf("\n");return-1!==n?(this.position+=n+1,e.slice(0,n)):null}isBufferTooLong(t){return this.position===t.length&&t.length>262144}}var Zt;!function(t){t[t.CONNECTING=0]="CONNECTING",t[t.OPEN=1]="OPEN",t[t.CLOSED=3]="CLOSED"}(Zt||(Zt={}));var te=Zt,ee=1;function ne(t){var e=-1===t.indexOf("?")?"?":"&";return t+e+"t="+ +new Date+"&n="+ee++}function ie(t){return ue.randomInt(t)}var re,se=class{constructor(t,e){this.hooks=t,this.session=ie(1e3)+"/"+function(t){for(var e=[],n=0;n{this.onChunk(t)}),this.stream.bind("finished",t=>{this.hooks.onFinished(this,t)}),this.stream.bind("buffer_too_long",()=>{this.reconnect()});try{this.stream.start()}catch(t){j.defer(()=>{this.onError(t),this.onClose(1006,"Could not start streaming",!1)})}}closeStream(){this.stream&&(this.stream.unbind_all(),this.stream.close(),this.stream=null)}},oe={getReceiveURL:function(t,e){return t.base+"/"+e+"/xhr_streaming"+t.queryString},onHeartbeat:function(t){t.sendRaw("[]")},sendHeartbeat:function(t){t.sendRaw("[]")},onFinished:function(t,e){t.onClose(1006,"Connection interrupted ("+e+")",!1)}},ae={getReceiveURL:function(t,e){return t.base+"/"+e+"/xhr"+t.queryString},onHeartbeat:function(){},sendHeartbeat:function(t){t.sendRaw("[]")},onFinished:function(t,e){200===e?t.reconnect():t.onClose(1006,"Connection interrupted ("+e+")",!1)}},ce={getRequest:function(t){var e=new(ue.getXHRAPI());return e.onreadystatechange=e.onprogress=function(){switch(e.readyState){case 3:e.responseText&&e.responseText.length>0&&t.onChunk(e.status,e.responseText);break;case 4:e.responseText&&e.responseText.length>0&&t.onChunk(e.status,e.responseText),t.emit("finished",e.status),t.close()}},e},abortRequest:function(t){t.onreadystatechange=null,t.abort()}},he={createStreamingSocket(t){return this.createSocket(oe,t)},createPollingSocket(t){return this.createSocket(ae,t)},createSocket:(t,e)=>new se(t,e),createXHR(t,e){return this.createRequest(ce,t,e)},createRequest:(t,e,n)=>new Qt(t,e,n),createXDR:function(t,e){return this.createRequest(Kt,t,e)}},ue={nextAuthCallbackID:1,auth_callbacks:{},ScriptReceivers:r,DependenciesReceivers:o,getDefaultStrategy:Yt,Transports:wt,transportConnectionInitializer:function(){var t=this;t.timeline.info(t.buildTimelineMessage({transport:t.name+(t.options.useTLS?"s":"")})),t.hooks.isInitialized()?t.changeState("initialized"):t.hooks.file?(t.changeState("initializing"),a.load(t.hooks.file,{useTLS:t.options.useTLS},(function(e,n){t.hooks.isInitialized()?(t.changeState("initialized"),n(!0)):(e&&t.onError(e),t.onClose(),n(!1))}))):t.onClose()},HTTPFactory:he,TimelineTransport:Z,getXHRAPI:()=>window.XMLHttpRequest,getWebSocketAPI:()=>window.WebSocket||window.MozWebSocket,setup(t){window.Pusher=t;var e=()=>{this.onDocumentBody(t.ready)};window.JSON?e():a.load("json2",{},e)},getDocument:()=>document,getProtocol(){return this.getDocument().location.protocol},getAuthorizers:()=>({ajax:w,jsonp:Y}),onDocumentBody(t){document.body?t():setTimeout(()=>{this.onDocumentBody(t)},0)},createJSONPRequest:(t,e)=>new Q(t,e),createScriptRequest:t=>new K(t),getLocalStorage(){try{return window.localStorage}catch(t){return}},createXHR(){return this.getXHRAPI()?this.createXMLHttpRequest():this.createMicrosoftXHR()},createXMLHttpRequest(){return new(this.getXHRAPI())},createMicrosoftXHR:()=>new ActiveXObject("Microsoft.XMLHTTP"),getNetwork:()=>St,createWebSocket(t){return new(this.getWebSocketAPI())(t)},createSocketRequest(t,e){if(this.isXHRSupported())return this.HTTPFactory.createXHR(t,e);if(this.isXDRSupported(0===e.indexOf("https:")))return this.HTTPFactory.createXDR(t,e);throw"Cross-origin HTTP requests are not supported"},isXHRSupported(){var t=this.getXHRAPI();return Boolean(t)&&void 0!==(new t).withCredentials},isXDRSupported(t){var e=t?"https:":"http:",n=this.getProtocol();return Boolean(window.XDomainRequest)&&n===e},addUnloadListener(t){void 0!==window.addEventListener?window.addEventListener("unload",t,!1):void 0!==window.attachEvent&&window.attachEvent("onunload",t)},removeUnloadListener(t){void 0!==window.addEventListener?window.removeEventListener("unload",t,!1):void 0!==window.detachEvent&&window.detachEvent("onunload",t)},randomInt:t=>Math.floor((window.crypto||window.msCrypto).getRandomValues(new Uint32Array(1))[0]/Math.pow(2,32)*t)};!function(t){t[t.ERROR=3]="ERROR",t[t.INFO=6]="INFO",t[t.DEBUG=7]="DEBUG"}(re||(re={}));var le=re;class de{constructor(t,e,n){this.key=t,this.session=e,this.events=[],this.options=n||{},this.sent=0,this.uniqueID=0}log(t,e){t<=this.options.level&&(this.events.push(N({},e,{timestamp:j.now()})),this.options.limit&&this.events.length>this.options.limit&&this.events.shift())}error(t){this.log(le.ERROR,t)}info(t){this.log(le.INFO,t)}debug(t){this.log(le.DEBUG,t)}isEmpty(){return 0===this.events.length}send(t,e){var n=N({session:this.session,bundle:this.sent+1,key:this.key,lib:"js",version:this.options.version,cluster:this.options.cluster,features:this.options.features,timeline:this.events},this.options.params);return this.events=[],t(n,(t,n)=>{t||this.sent++,e&&e(t,n)}),!0}generateUniqueID(){return this.uniqueID++,this.uniqueID}}class pe{constructor(t,e,n,i){this.name=t,this.priority=e,this.transport=n,this.options=i||{}}isSupported(){return this.transport.isSupported({useTLS:this.options.useTLS})}connect(t,e){if(!this.isSupported())return fe(new m,e);if(this.priority{n||(h(),r?r.close():i.close())},forceMinPriority:t=>{n||this.priority{if(void 0===ue.getAuthorizers()[t.transport])throw`'${t.transport}' is not a recognized auth transport`;return(e,n)=>{const i=((t,e)=>{var n="socket_id="+encodeURIComponent(t.socketId);for(var i in e.params)n+="&"+encodeURIComponent(i)+"="+encodeURIComponent(e.params[i]);if(null!=e.paramsProvider){let t=e.paramsProvider();for(var i in t)n+="&"+encodeURIComponent(i)+"="+encodeURIComponent(t[i])}return n})(e,t);ue.getAuthorizers()[t.transport](ue,i,t,h.UserAuthentication,n)}};var ye=t=>{if(void 0===ue.getAuthorizers()[t.transport])throw`'${t.transport}' is not a recognized auth transport`;return(e,n)=>{const i=((t,e)=>{var n="socket_id="+encodeURIComponent(t.socketId);for(var i in n+="&channel_name="+encodeURIComponent(t.channelName),e.params)n+="&"+encodeURIComponent(i)+"="+encodeURIComponent(e.params[i]);if(null!=e.paramsProvider){let t=e.paramsProvider();for(var i in t)n+="&"+encodeURIComponent(i)+"="+encodeURIComponent(t[i])}return n})(e,t);ue.getAuthorizers()[t.transport](ue,i,t,h.ChannelAuthorization,n)}};const we=(t,e,n)=>{const i={authTransport:e.transport,authEndpoint:e.endpoint,auth:{params:e.params,headers:e.headers}};return(e,r)=>{const s=t.channel(e.channelName);n(s,i).authorize(e.socketId,r)}};function Se(t,e){let n={activityTimeout:t.activityTimeout||s.activityTimeout,cluster:t.cluster,httpPath:t.httpPath||s.httpPath,httpPort:t.httpPort||s.httpPort,httpsPort:t.httpsPort||s.httpsPort,pongTimeout:t.pongTimeout||s.pongTimeout,statsHost:t.statsHost||s.stats_host,unavailableTimeout:t.unavailableTimeout||s.unavailableTimeout,wsPath:t.wsPath||s.wsPath,wsPort:t.wsPort||s.wsPort,wssPort:t.wssPort||s.wssPort,enableStats:Te(t),httpHost:_e(t),useTLS:Ce(t),wsHost:ke(t),userAuthenticator:Ee(t),channelAuthorizer:Oe(t,e)};return"disabledTransports"in t&&(n.disabledTransports=t.disabledTransports),"enabledTransports"in t&&(n.enabledTransports=t.enabledTransports),"ignoreNullOrigin"in t&&(n.ignoreNullOrigin=t.ignoreNullOrigin),"timelineParams"in t&&(n.timelineParams=t.timelineParams),"nacl"in t&&(n.nacl=t.nacl),n}function _e(t){return t.httpHost?t.httpHost:t.cluster?`sockjs-${t.cluster}.pusher.com`:s.httpHost}function ke(t){return t.wsHost?t.wsHost:`ws-${t.cluster}.pusher.com`}function Ce(t){return"https:"===ue.getProtocol()||!1!==t.forceTLS}function Te(t){return"enableStats"in t?t.enableStats:"disableStats"in t&&!t.disableStats}const Pe=t=>"customHandler"in t&&null!=t.customHandler;function Ee(t){const e=Object.assign(Object.assign({},s.userAuthentication),t.userAuthentication);return Pe(e)?e.customHandler:me(e)}function Oe(t,e){const n=function(t,e){let n;if("channelAuthorization"in t)n=Object.assign(Object.assign({},s.channelAuthorization),t.channelAuthorization);else if(n={transport:t.authTransport||s.authTransport,endpoint:t.authEndpoint||s.authEndpoint},"auth"in t&&("params"in t.auth&&(n.params=t.auth.params),"headers"in t.auth&&(n.headers=t.auth.headers)),"authorizer"in t)return{customHandler:we(e,n,t.authorizer)};return n}(t,e);return Pe(n)?n.customHandler:ye(n)}class xe extends at{constructor(t){super((function(t,e){V.debug("No callbacks on watchlist events for "+t)})),this.pusher=t,this.bindWatchlistInternalEvent()}handleEvent(t){t.data.events.forEach(t=>{this.emit(t.name,t)})}bindWatchlistInternalEvent(){this.pusher.connection.bind("message",t=>{"pusher_internal:watchlist_events"===t.event&&this.handleEvent(t)})}}var Le=function(){let t,e;return{promise:new Promise((n,i)=>{t=n,e=i}),resolve:t,reject:e}};class Ae extends at{constructor(t){super((function(t,e){V.debug("No callbacks on user for "+t)})),this.signin_requested=!1,this.user_data=null,this.serverToUserChannel=null,this.signinDonePromise=null,this._signinDoneResolve=null,this._onAuthorize=(t,e)=>{if(t)return V.warn("Error during signin: "+t),void this._cleanup();this.pusher.send_event("pusher:signin",{auth:e.auth,user_data:e.user_data})},this.pusher=t,this.pusher.connection.bind("state_change",({previous:t,current:e})=>{"connected"!==t&&"connected"===e&&this._signin(),"connected"===t&&"connected"!==e&&(this._cleanup(),this._newSigninPromiseIfNeeded())}),this.watchlist=new xe(t),this.pusher.connection.bind("message",t=>{"pusher:signin_success"===t.event&&this._onSigninSuccess(t.data),this.serverToUserChannel&&this.serverToUserChannel.name===t.channel&&this.serverToUserChannel.handleEvent(t)})}signin(){this.signin_requested||(this.signin_requested=!0,this._signin())}_signin(){this.signin_requested&&(this._newSigninPromiseIfNeeded(),"connected"===this.pusher.connection.state&&this.pusher.config.userAuthenticator({socketId:this.pusher.connection.socket_id},this._onAuthorize))}_onSigninSuccess(t){try{this.user_data=JSON.parse(t.user_data)}catch(e){return V.error("Failed parsing user data after signin: "+t.user_data),void this._cleanup()}if("string"!=typeof this.user_data.id||""===this.user_data.id)return V.error("user_data doesn't contain an id. user_data: "+this.user_data),void this._cleanup();this._signinDoneResolve(),this._subscribeChannels()}_subscribeChannels(){this.serverToUserChannel=new Ot("#server-to-user-"+this.user_data.id,this.pusher),this.serverToUserChannel.bind_global((t,e)=>{0!==t.indexOf("pusher_internal:")&&0!==t.indexOf("pusher:")&&this.emit(t,e)}),(t=>{t.subscriptionPending&&t.subscriptionCancelled?t.reinstateSubscription():t.subscriptionPending||"connected"!==this.pusher.connection.state||t.subscribe()})(this.serverToUserChannel)}_cleanup(){this.user_data=null,this.serverToUserChannel&&(this.serverToUserChannel.unbind_all(),this.serverToUserChannel.disconnect(),this.serverToUserChannel=null),this.signin_requested&&this._signinDoneResolve()}_newSigninPromiseIfNeeded(){if(!this.signin_requested)return;if(this.signinDonePromise&&!this.signinDonePromise.done)return;const{promise:t,resolve:e,reject:n}=Le();t.done=!1;const i=()=>{t.done=!0};t.then(i).catch(i),this.signinDonePromise=t,this._signinDoneResolve=e}}class Re{static ready(){Re.isReady=!0;for(var t=0,e=Re.instances.length;tue.getDefaultStrategy(this.config,t,ve),timeline:this.timeline,activityTimeout:this.config.activityTimeout,pongTimeout:this.config.pongTimeout,unavailableTimeout:this.config.unavailableTimeout,useTLS:Boolean(this.config.useTLS)}),this.connection.bind("connected",()=>{this.subscribeAll(),this.timelineSender&&this.timelineSender.send(this.connection.isUsingTLS())}),this.connection.bind("message",t=>{var e=0===t.event.indexOf("pusher_internal:");if(t.channel){var n=this.channel(t.channel);n&&n.handleEvent(t)}e||this.global_emitter.emit(t.event,t.data)}),this.connection.bind("connecting",()=>{this.channels.disconnect()}),this.connection.bind("disconnected",()=>{this.channels.disconnect()}),this.connection.bind("error",t=>{V.warn(t)}),Re.instances.push(this),this.timeline.info({instances:Re.instances.length}),this.user=new Ae(this),Re.isReady&&this.connect()}switchCluster(t){const{appKey:e,cluster:n}=t;this.key=e,this.options=Object.assign(Object.assign({},this.options),{cluster:n}),this.config=Se(this.options,this),this.connection.switchCluster(this.key)}channel(t){return this.channels.find(t)}allChannels(){return this.channels.all()}connect(){if(this.connection.connect(),this.timelineSender&&!this.timelineSenderTimer){var t=this.connection.isUsingTLS(),e=this.timelineSender;this.timelineSenderTimer=new D(6e4,(function(){e.send(t)}))}}disconnect(){this.connection.disconnect(),this.timelineSenderTimer&&(this.timelineSenderTimer.ensureAborted(),this.timelineSenderTimer=null)}bind(t,e,n){return this.global_emitter.bind(t,e,n),this}unbind(t,e,n){return this.global_emitter.unbind(t,e,n),this}bind_global(t){return this.global_emitter.bind_global(t),this}unbind_global(t){return this.global_emitter.unbind_global(t),this}unbind_all(t){return this.global_emitter.unbind_all(),this}subscribeAll(){var t;for(t in this.channels.channels)this.channels.channels.hasOwnProperty(t)&&this.subscribe(t)}subscribe(t){var e=this.channels.add(t,this);return e.subscriptionPending&&e.subscriptionCancelled?e.reinstateSubscription():e.subscriptionPending||"connected"!==this.connection.state||e.subscribe(),e}unsubscribe(t){var e=this.channels.find(t);e&&e.subscriptionPending?e.cancelSubscription():(e=this.channels.remove(t))&&e.subscribed&&e.unsubscribe()}send_event(t,e,n){return this.connection.send_event(t,e,n)}shouldUseTLS(){return this.config.useTLS}signin(){this.user.signin()}}Re.instances=[],Re.isReady=!1,Re.logToConsole=!1,Re.Runtime=ue,Re.ScriptReceivers=ue.ScriptReceivers,Re.DependenciesReceivers=ue.DependenciesReceivers,Re.auth_callbacks=ue.auth_callbacks;var Ie=e.default=Re;ue.setup(Re)}])})); //# sourceMappingURL=pusher.min.js.map \ No newline at end of file diff --git a/dist/web/pusher.min.js.map b/dist/web/pusher.min.js.map index 7d60b47a0..468cbf07f 100644 --- a/dist/web/pusher.min.js.map +++ b/dist/web/pusher.min.js.map @@ -1 +1 @@ -{"version":3,"sources":["webpack://Pusher/webpack/universalModuleDefinition","webpack://Pusher/webpack/bootstrap","webpack://Pusher/./node_modules/@stablelib/base64/base64.ts","webpack://Pusher/./node_modules/@stablelib/utf8/utf8.ts","webpack://Pusher/./src/core/pusher.js","webpack://Pusher/./src/runtimes/web/dom/script_receiver_factory.ts","webpack://Pusher/./src/core/defaults.ts","webpack://Pusher/./src/runtimes/web/dom/dependencies.ts","webpack://Pusher/./src/runtimes/web/dom/dependency_loader.ts","webpack://Pusher/./src/core/utils/url_store.ts","webpack://Pusher/./src/core/auth/options.ts","webpack://Pusher/./src/core/errors.ts","webpack://Pusher/./src/runtimes/isomorphic/auth/xhr_auth.ts","webpack://Pusher/./src/core/base64.ts","webpack://Pusher/./src/core/utils/timers/abstract_timer.ts","webpack://Pusher/./src/core/utils/timers/index.ts","webpack://Pusher/./src/core/util.ts","webpack://Pusher/./src/core/utils/collections.ts","webpack://Pusher/./src/core/logger.ts","webpack://Pusher/./src/runtimes/web/auth/jsonp_auth.ts","webpack://Pusher/./src/runtimes/web/dom/script_request.ts","webpack://Pusher/./src/runtimes/web/dom/jsonp_request.ts","webpack://Pusher/./src/runtimes/web/timeline/jsonp_timeline.ts","webpack://Pusher/./src/core/transports/url_schemes.ts","webpack://Pusher/./src/core/events/callback_registry.ts","webpack://Pusher/./src/core/events/dispatcher.ts","webpack://Pusher/./src/core/transports/transport_connection.ts","webpack://Pusher/./src/core/transports/transport.ts","webpack://Pusher/./src/runtimes/isomorphic/transports/transports.ts","webpack://Pusher/./src/runtimes/web/transports/transports.ts","webpack://Pusher/./src/runtimes/web/net_info.ts","webpack://Pusher/./src/core/transports/assistant_to_the_transport_manager.ts","webpack://Pusher/./src/core/connection/protocol/protocol.ts","webpack://Pusher/./src/core/connection/connection.ts","webpack://Pusher/./src/core/connection/handshake/index.ts","webpack://Pusher/./src/core/timeline/timeline_sender.ts","webpack://Pusher/./src/core/channels/channel.ts","webpack://Pusher/./src/core/channels/private_channel.ts","webpack://Pusher/./src/core/channels/members.ts","webpack://Pusher/./src/core/channels/presence_channel.ts","webpack://Pusher/./src/core/channels/encrypted_channel.ts","webpack://Pusher/./src/core/connection/connection_manager.ts","webpack://Pusher/./src/core/channels/channels.ts","webpack://Pusher/./src/core/utils/factory.ts","webpack://Pusher/./src/core/transports/transport_manager.ts","webpack://Pusher/./src/core/strategies/sequential_strategy.ts","webpack://Pusher/./src/core/strategies/best_connected_ever_strategy.ts","webpack://Pusher/./src/core/strategies/websocket_prioritized_cached_strategy.ts","webpack://Pusher/./src/core/strategies/delayed_strategy.ts","webpack://Pusher/./src/core/strategies/if_strategy.ts","webpack://Pusher/./src/core/strategies/first_connected_strategy.ts","webpack://Pusher/./src/runtimes/web/default_strategy.ts","webpack://Pusher/./src/runtimes/web/http/http_xdomain_request.ts","webpack://Pusher/./src/core/http/http_request.ts","webpack://Pusher/./src/core/http/state.ts","webpack://Pusher/./src/core/http/http_socket.ts","webpack://Pusher/./src/core/timeline/level.ts","webpack://Pusher/./src/core/http/http_streaming_socket.ts","webpack://Pusher/./src/core/http/http_polling_socket.ts","webpack://Pusher/./src/runtimes/isomorphic/http/http_xhr_request.ts","webpack://Pusher/./src/runtimes/isomorphic/http/http.ts","webpack://Pusher/./src/runtimes/web/http/http.ts","webpack://Pusher/./src/runtimes/web/runtime.ts","webpack://Pusher/./src/runtimes/web/transports/transport_connection_initializer.ts","webpack://Pusher/./src/core/timeline/timeline.ts","webpack://Pusher/./src/core/strategies/transport_strategy.ts","webpack://Pusher/./src/core/strategies/strategy_builder.ts","webpack://Pusher/./src/core/auth/user_authenticator.ts","webpack://Pusher/./src/core/auth/channel_authorizer.ts","webpack://Pusher/./src/core/config.ts","webpack://Pusher/./src/core/auth/deprecated_channel_authorizer.ts","webpack://Pusher/./src/core/watchlist.ts","webpack://Pusher/./src/core/utils/flat_promise.ts","webpack://Pusher/./src/core/user.ts","webpack://Pusher/./src/core/pusher.ts","webpack://Pusher/./src/core/options.ts"],"names":["root","factory","exports","module","define","amd","window","installedModules","__webpack_require__","moduleId","i","l","modules","call","m","c","d","name","getter","o","Object","defineProperty","enumerable","get","r","Symbol","toStringTag","value","t","mode","__esModule","ns","create","key","bind","n","object","property","prototype","hasOwnProperty","p","s","_paddingCharacter","encodedLength","length","this","encode","data","out","_encodeByte","left","maxDecodedLength","decodedLength","_getPaddingLength","decode","Uint8Array","paddingLength","op","haveBad","v0","v1","v2","v3","_decodeChar","charCodeAt","Error","b","result","String","fromCharCode","Coder","stdCoder","URLSafeCoder","urlSafeCoder","INVALID_UTF8","arr","pos","chars","min","n1","n2","n3","push","join","default","ScriptReceiverFactory","prefix","lastId","callback","number","id","called","callbackWrapper","apply","arguments","receiver","ScriptReceivers","VERSION","PROTOCOL","wsPort","wssPort","wsPath","httpHost","httpPort","httpsPort","httpPath","stats_host","authEndpoint","authTransport","activityTimeout","pongTimeout","unavailableTimeout","userAuthentication","endpoint","transport","channelAuthorization","cdn_http","cdn_https","dependency_suffix","DependenciesReceivers","Dependencies","options","receivers","loading","self","request","createScriptRequest","getPath","error","remove","callbacks","successCallback","wasSuccessful","cleanup","send","protocol","getDocument","location","useTLS","replace","version","getRoot","suffix","urlStore","baseUrl","urls","authenticationEndpoint","path","authorizationEndpoint","javascriptQuickStart","triggeringClientEvents","encryptedChannelSupport","fullUrl","AuthRequestType","urlObj","url","BadEventName","msg","super","setPrototypeOf","BadChannelName","RequestTimedOut","TransportPriorityTooLow","TransportClosed","UnsupportedFeature","UnsupportedTransport","UnsupportedStrategy","HTTPAuthError","status","context","query","authOptions","authRequestType","xhr","createXHR","headerName","open","setRequestHeader","headers","headersProvider","dynamicHeaders","onreadystatechange","readyState","parsed","JSON","parse","responseText","e","toString","UserAuthentication","ChannelAuthorization","b64chars","b64tab","charAt","cb_utob","cc","utob","u","cb_encode","ccc","padlen","ord","btoa","set","clear","delay","timer","clearTimeout","clearInterval","setTimeout","setInterval","now","Date","valueOf","defer","args","boundArguments","Array","slice","concat","extend","target","sources","extensions","constructor","stringify","safeJSONStringify","arrayIndexOf","array","item","nativeIndexOf","indexOf","objectApply","f","keys","_","map","filter","test","filterObject","Boolean","any","encodeParamsObject","encodeURIComponent","buildQueryString","params","undefined","method","source","objects","paths","derez","nu","$ref","globalLog","message","console","log","globalLogWarn","globalLogError","warn","defaultLoggingFunction","logToConsole","callbackName","nextAuthCallbackID","document","script","createElement","auth_callbacks","callback_name","src","head","getElementsByTagName","documentElement","insertBefore","firstChild","ScriptRequest","errorString","type","charset","addEventListener","onerror","onload","async","attachEvent","navigator","userAgent","errorScript","text","nextSibling","parentNode","removeChild","getAgent","sender","host","createJSONPRequest","getGenericURL","baseScheme","hostTLS","hostNonTLS","getGenericPath","queryString","ws","getInitial","http","sockjs","_callbacks","prefixedEventName","fn","names","removeCallback","removeAllCallbacks","binding","failThrough","global_callbacks","eventName","add","unbind","unbind_global","metadata","hooks","priority","initialize","transportConnectionInitializer","state","timeline","generateUniqueID","handlesActivityChecks","supportsPing","socket","getSocket","onError","changeState","bindListeners","debug","close","ping","beforeOpen","onopen","emit","buildTimelineMessage","closeEvent","code","reason","wasClean","unbindListeners","onOpen","onclose","onClose","onmessage","onMessage","onactivity","onActivity","info","cid","environment","isSupported","WSTransport","isInitialized","getWebSocketAPI","createWebSocket","httpConfiguration","streamingConfiguration","HTTPFactory","createStreamingSocket","pollingConfiguration","createPollingSocket","xhrConfiguration","isXHRSupported","xhr_streaming","xhr_polling","SockJSTransport","file","SockJS","js_path","ignore_null_origin","ignoreNullOrigin","xdrConfiguration","isXDRSupported","XDRStreamingTransport","XDRPollingTransport","xdr_streaming","xdr_polling","onLine","manager","minPingDelay","maxPingDelay","pingDelay","connection","createConnection","openTimestamp","onClosed","reportDeath","lifespan","Math","max","isAlive","Protocol","decodeMessage","messageEvent","messageData","pusherEventData","pusherEvent","event","channel","user_id","encodeMessage","processHandshake","activity_timeout","action","socket_id","getCloseAction","getCloseError","send_event","listeners","activity","closed","handleCloseEvent","listener","finish","isEmpty","TimelineTransport","pusher","subscribed","subscriptionPending","subscriptionCancelled","socketId","auth","handleSubscriptionSucceededEvent","handleSubscriptionCountEvent","unsubscribe","subscription_count","subscriptionCount","authorize","assign","channel_data","config","channelAuthorizer","channelName","reset","members","member","myID","subscriptionData","presence","hash","count","me","memberData","user_info","authData","channelData","setMyID","user","signinDonePromise","user_data","handleInternalEvent","addedMember","addMember","removedMember","removeMember","onSubscription","disconnect","nacl","sharedSecret","handleEncryptedEvent","handleEvent","ciphertext","nonce","cipherText","secretbox","overheadLength","nonceLength","bytes","getDataToEmit","raw","usingTLS","errorCallbacks","buildErrorCallbacks","connectionCallbacks","buildConnectionCallbacks","handshakeCallbacks","buildHandshakeCallbacks","Network","getNetwork","netinfo","retryIn","sendActivityCheck","updateStrategy","runner","strategy","updateState","startConnecting","setUnavailableTimer","disconnectInternally","handshake","connect","handshakeError","abortConnecting","abort","clearRetryTimer","clearUnavailableTimer","abandonConnection","getStrategy","round","retryTimer","ensureAborted","unavailableTimer","stopActivityCheck","activityTimer","pong_timed_out","resetActivityCheck","shouldRetry","connected","Infinity","setConnection","withErrorEmitted","tls_only","refused","backoff","retry","newState","previousState","newStateDescription","previous","current","channels","createEncryptedChannel","errMsg","createPrivateChannel","createPresenceChannel","createChannel","values","createChannels","createConnectionManager","createTimelineSender","createHandshake","createAssistantToTheTransportManager","livesLeft","lives","strategies","loop","failFast","timeout","timeoutLimit","minPriority","tryNextStrategy","tryStrategy","forceMinPriority","isRunning","callbackBuilder","runners","rs","abortRunner","allRunnersFailed","aborted","transports","ttl","storage","getLocalStorage","serializedCache","getTransportCacheKey","flushTransportCache","fetchTransportCache","cacheSkipCount","timestamp","includes","cached","latency","startTimestamp","pop","cb","storeTransportCache","IfStrategy","trueBranch","falseBranch","FirstConnectedStrategy","testSupportsStrategy","baseOptions","defineTransport","definedTransports","defineTransportStrategy","wsStrategy","ws_options","wsHost","wss_options","sockjs_options","timeouts","ws_manager","streaming_manager","ws_transport","wss_transport","sockjs_transport","xhr_streaming_transport","xdr_streaming_transport","xhr_polling_transport","xdr_polling_transport","ws_loop","wss_loop","sockjs_loop","streaming_loop","polling_loop","http_loop","http_fallback_loop","getRequest","xdr","XDomainRequest","ontimeout","onprogress","onChunk","abortRequest","payload","position","unloader","addUnloadListener","removeUnloadListener","chunk","advanceBuffer","isBufferTooLong","buffer","unreadData","endOfLinePosition","State","autoIncrement","getUniqueURL","separator","randomNumber","randomInt","TimelineLevel","session","randomString","parts","exec","base","getLocation","CONNECTING","openStream","sendRaw","sendHeartbeat","OPEN","createSocketRequest","start","closeStream","CLOSED","onEvent","onHeartbeat","hostname","urlParts","stream","getReceiveURL","onFinished","reconnect","unbind_all","getXHRAPI","createSocket","createRequest","getDefaultStrategy","Transports","load","XMLHttpRequest","WebSocket","MozWebSocket","PusherClass","Pusher","initializeOnDocumentBody","onDocumentBody","ready","getAuthorizers","ajax","jsonp","body","localStorage","createXMLHttpRequest","createMicrosoftXHR","ActiveXObject","createXDR","Constructor","withCredentials","documentProtocol","getProtocol","removeEventListener","detachEvent","floor","crypto","getRandomValues","Uint32Array","events","sent","uniqueID","level","limit","shift","ERROR","INFO","DEBUG","sendfn","bundle","lib","cluster","features","failAttempt","onInitialized","serializedTransport","transportClass","enabledTransports","disabledTransports","getAssistant","deferred","paramsProvider","dynamicParams","composeChannelQuery","getConfig","opts","statsHost","enableStats","getEnableStatsConfig","getHttpHost","shouldUseTLS","getWebsocketHost","userAuthenticator","buildUserAuthenticator","buildChannelAuthorizer","timelineParams","forceTLS","disableStats","customHandler","channelAuthorizerGenerator","deprecatedAuthorizerOptions","ChannelAuthorizerProxy","authorizer","buildChannelAuth","bindWatchlistInternalEvent","forEach","watchlistEvent","resolve","reject","promise","Promise","res","rej","signin_requested","serverToUserChannel","_signinDoneResolve","_onAuthorize","err","_cleanup","_signin","_newSigninPromiseIfNeeded","watchlist","_onSigninSuccess","_subscribeChannels","bind_global","reinstateSubscription","subscribe","ensure_subscribed","done","setDone","then","catch","isReady","instances","app_key","checkAppKey","validateOptions","global_emitter","sessionID","getClientFeatures","timelineSender","subscribeAll","isUsingTLS","internal","appKey","switchCluster","find","all","timelineSenderTimer","event_name","channel_name","cancelSubscription","signin","Runtime","setup"],"mappings":";;;;;;;CAAA,SAA2CA,EAAMC,GAC1B,iBAAZC,SAA0C,iBAAXC,OACxCA,OAAOD,QAAUD,IACQ,mBAAXG,QAAyBA,OAAOC,IAC9CD,OAAO,GAAIH,G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,UAtOL,GAAAnB,UAAsB,GACtB,GAAAD,SAAmB,EACnB,GAAAjf,cAAwB,EAGxB,GAAAsgB,QAA2B,GAC3B,GAAA5qB,gBAA6B,GAASA,gBACtC,GAAAuB,sBAAmC,GAASA,sBAC5C,GAAAqJ,eAA4B,GAASA,eAVzB,oBAkPrB,GAAQigB,MAAM","file":"pusher.min.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"Pusher\"] = factory();\n\telse\n\t\troot[\"Pusher\"] = factory();\n})(window, function() {\nreturn "," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 2);\n","// Copyright (C) 2016 Dmitry Chestnykh\n// MIT License. See LICENSE file for details.\n\n/**\n * Package base64 implements Base64 encoding and decoding.\n */\n\n// Invalid character used in decoding to indicate\n// that the character to decode is out of range of\n// alphabet and cannot be decoded.\nconst INVALID_BYTE = 256;\n\n/**\n * Implements standard Base64 encoding.\n *\n * Operates in constant time.\n */\nexport class Coder {\n // TODO(dchest): methods to encode chunk-by-chunk.\n\n constructor(private _paddingCharacter = \"=\") { }\n\n encodedLength(length: number): number {\n if (!this._paddingCharacter) {\n return (length * 8 + 5) / 6 | 0;\n }\n return (length + 2) / 3 * 4 | 0;\n }\n\n encode(data: Uint8Array): string {\n let out = \"\";\n\n let i = 0;\n for (; i < data.length - 2; i += 3) {\n let c = (data[i] << 16) | (data[i + 1] << 8) | (data[i + 2]);\n out += this._encodeByte((c >>> 3 * 6) & 63);\n out += this._encodeByte((c >>> 2 * 6) & 63);\n out += this._encodeByte((c >>> 1 * 6) & 63);\n out += this._encodeByte((c >>> 0 * 6) & 63);\n }\n\n const left = data.length - i;\n if (left > 0) {\n let c = (data[i] << 16) | (left === 2 ? data[i + 1] << 8 : 0);\n out += this._encodeByte((c >>> 3 * 6) & 63);\n out += this._encodeByte((c >>> 2 * 6) & 63);\n if (left === 2) {\n out += this._encodeByte((c >>> 1 * 6) & 63);\n } else {\n out += this._paddingCharacter || \"\";\n }\n out += this._paddingCharacter || \"\";\n }\n\n return out;\n }\n\n maxDecodedLength(length: number): number {\n if (!this._paddingCharacter) {\n return (length * 6 + 7) / 8 | 0;\n }\n return length / 4 * 3 | 0;\n }\n\n decodedLength(s: string): number {\n return this.maxDecodedLength(s.length - this._getPaddingLength(s));\n }\n\n decode(s: string): Uint8Array {\n if (s.length === 0) {\n return new Uint8Array(0);\n }\n const paddingLength = this._getPaddingLength(s);\n const length = s.length - paddingLength;\n const out = new Uint8Array(this.maxDecodedLength(length));\n let op = 0;\n let i = 0;\n let haveBad = 0;\n let v0 = 0, v1 = 0, v2 = 0, v3 = 0;\n for (; i < length - 4; i += 4) {\n v0 = this._decodeChar(s.charCodeAt(i + 0));\n v1 = this._decodeChar(s.charCodeAt(i + 1));\n v2 = this._decodeChar(s.charCodeAt(i + 2));\n v3 = this._decodeChar(s.charCodeAt(i + 3));\n out[op++] = (v0 << 2) | (v1 >>> 4);\n out[op++] = (v1 << 4) | (v2 >>> 2);\n out[op++] = (v2 << 6) | v3;\n haveBad |= v0 & INVALID_BYTE;\n haveBad |= v1 & INVALID_BYTE;\n haveBad |= v2 & INVALID_BYTE;\n haveBad |= v3 & INVALID_BYTE;\n }\n if (i < length - 1) {\n v0 = this._decodeChar(s.charCodeAt(i));\n v1 = this._decodeChar(s.charCodeAt(i + 1));\n out[op++] = (v0 << 2) | (v1 >>> 4);\n haveBad |= v0 & INVALID_BYTE;\n haveBad |= v1 & INVALID_BYTE;\n }\n if (i < length - 2) {\n v2 = this._decodeChar(s.charCodeAt(i + 2));\n out[op++] = (v1 << 4) | (v2 >>> 2);\n haveBad |= v2 & INVALID_BYTE;\n }\n if (i < length - 3) {\n v3 = this._decodeChar(s.charCodeAt(i + 3));\n out[op++] = (v2 << 6) | v3;\n haveBad |= v3 & INVALID_BYTE;\n }\n if (haveBad !== 0) {\n throw new Error(\"Base64Coder: incorrect characters for decoding\");\n }\n return out;\n }\n\n // Standard encoding have the following encoded/decoded ranges,\n // which we need to convert between.\n //\n // ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 0123456789 + /\n // Index: 0 - 25 26 - 51 52 - 61 62 63\n // ASCII: 65 - 90 97 - 122 48 - 57 43 47\n //\n\n // Encode 6 bits in b into a new character.\n protected _encodeByte(b: number): string {\n // Encoding uses constant time operations as follows:\n //\n // 1. Define comparison of A with B using (A - B) >>> 8:\n // if A > B, then result is positive integer\n // if A <= B, then result is 0\n //\n // 2. Define selection of C or 0 using bitwise AND: X & C:\n // if X == 0, then result is 0\n // if X != 0, then result is C\n //\n // 3. Start with the smallest comparison (b >= 0), which is always\n // true, so set the result to the starting ASCII value (65).\n //\n // 4. Continue comparing b to higher ASCII values, and selecting\n // zero if comparison isn't true, otherwise selecting a value\n // to add to result, which:\n //\n // a) undoes the previous addition\n // b) provides new value to add\n //\n let result = b;\n // b >= 0\n result += 65;\n // b > 25\n result += ((25 - b) >>> 8) & ((0 - 65) - 26 + 97);\n // b > 51\n result += ((51 - b) >>> 8) & ((26 - 97) - 52 + 48);\n // b > 61\n result += ((61 - b) >>> 8) & ((52 - 48) - 62 + 43);\n // b > 62\n result += ((62 - b) >>> 8) & ((62 - 43) - 63 + 47);\n\n return String.fromCharCode(result);\n }\n\n // Decode a character code into a byte.\n // Must return 256 if character is out of alphabet range.\n protected _decodeChar(c: number): number {\n // Decoding works similar to encoding: using the same comparison\n // function, but now it works on ranges: result is always incremented\n // by value, but this value becomes zero if the range is not\n // satisfied.\n //\n // Decoding starts with invalid value, 256, which is then\n // subtracted when the range is satisfied. If none of the ranges\n // apply, the function returns 256, which is then checked by\n // the caller to throw error.\n let result = INVALID_BYTE; // start with invalid character\n\n // c == 43 (c > 42 and c < 44)\n result += (((42 - c) & (c - 44)) >>> 8) & (-INVALID_BYTE + c - 43 + 62);\n // c == 47 (c > 46 and c < 48)\n result += (((46 - c) & (c - 48)) >>> 8) & (-INVALID_BYTE + c - 47 + 63);\n // c > 47 and c < 58\n result += (((47 - c) & (c - 58)) >>> 8) & (-INVALID_BYTE + c - 48 + 52);\n // c > 64 and c < 91\n result += (((64 - c) & (c - 91)) >>> 8) & (-INVALID_BYTE + c - 65 + 0);\n // c > 96 and c < 123\n result += (((96 - c) & (c - 123)) >>> 8) & (-INVALID_BYTE + c - 97 + 26);\n\n return result;\n }\n\n private _getPaddingLength(s: string): number {\n let paddingLength = 0;\n if (this._paddingCharacter) {\n for (let i = s.length - 1; i >= 0; i--) {\n if (s[i] !== this._paddingCharacter) {\n break;\n }\n paddingLength++;\n }\n if (s.length < 4 || paddingLength > 2) {\n throw new Error(\"Base64Coder: incorrect padding\");\n }\n }\n return paddingLength;\n }\n\n}\n\nconst stdCoder = new Coder();\n\nexport function encode(data: Uint8Array): string {\n return stdCoder.encode(data);\n}\n\nexport function decode(s: string): Uint8Array {\n return stdCoder.decode(s);\n}\n\n/**\n * Implements URL-safe Base64 encoding.\n * (Same as Base64, but '+' is replaced with '-', and '/' with '_').\n *\n * Operates in constant time.\n */\nexport class URLSafeCoder extends Coder {\n // URL-safe encoding have the following encoded/decoded ranges:\n //\n // ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 0123456789 - _\n // Index: 0 - 25 26 - 51 52 - 61 62 63\n // ASCII: 65 - 90 97 - 122 48 - 57 45 95\n //\n\n protected _encodeByte(b: number): string {\n let result = b;\n // b >= 0\n result += 65;\n // b > 25\n result += ((25 - b) >>> 8) & ((0 - 65) - 26 + 97);\n // b > 51\n result += ((51 - b) >>> 8) & ((26 - 97) - 52 + 48);\n // b > 61\n result += ((61 - b) >>> 8) & ((52 - 48) - 62 + 45);\n // b > 62\n result += ((62 - b) >>> 8) & ((62 - 45) - 63 + 95);\n\n return String.fromCharCode(result);\n }\n\n protected _decodeChar(c: number): number {\n let result = INVALID_BYTE;\n\n // c == 45 (c > 44 and c < 46)\n result += (((44 - c) & (c - 46)) >>> 8) & (-INVALID_BYTE + c - 45 + 62);\n // c == 95 (c > 94 and c < 96)\n result += (((94 - c) & (c - 96)) >>> 8) & (-INVALID_BYTE + c - 95 + 63);\n // c > 47 and c < 58\n result += (((47 - c) & (c - 58)) >>> 8) & (-INVALID_BYTE + c - 48 + 52);\n // c > 64 and c < 91\n result += (((64 - c) & (c - 91)) >>> 8) & (-INVALID_BYTE + c - 65 + 0);\n // c > 96 and c < 123\n result += (((96 - c) & (c - 123)) >>> 8) & (-INVALID_BYTE + c - 97 + 26);\n\n return result;\n }\n}\n\nconst urlSafeCoder = new URLSafeCoder();\n\nexport function encodeURLSafe(data: Uint8Array): string {\n return urlSafeCoder.encode(data);\n}\n\nexport function decodeURLSafe(s: string): Uint8Array {\n return urlSafeCoder.decode(s);\n}\n\n\nexport const encodedLength = (length: number) =>\n stdCoder.encodedLength(length);\n\nexport const maxDecodedLength = (length: number) =>\n stdCoder.maxDecodedLength(length);\n\nexport const decodedLength = (s: string) =>\n stdCoder.decodedLength(s);\n","// Copyright (C) 2016 Dmitry Chestnykh\n// MIT License. See LICENSE file for details.\n\n/**\n * Package utf8 implements UTF-8 encoding and decoding.\n */\n\nconst INVALID_UTF16 = \"utf8: invalid string\";\nconst INVALID_UTF8 = \"utf8: invalid source encoding\";\n\n/**\n * Encodes the given string into UTF-8 byte array.\n * Throws if the source string has invalid UTF-16 encoding.\n */\nexport function encode(s: string): Uint8Array {\n // Calculate result length and allocate output array.\n // encodedLength() also validates string and throws errors,\n // so we don't need repeat validation here.\n const arr = new Uint8Array(encodedLength(s));\n\n let pos = 0;\n for (let i = 0; i < s.length; i++) {\n let c = s.charCodeAt(i);\n if (c < 0x80) {\n arr[pos++] = c;\n } else if (c < 0x800) {\n arr[pos++] = 0xc0 | c >> 6;\n arr[pos++] = 0x80 | c & 0x3f;\n } else if (c < 0xd800) {\n arr[pos++] = 0xe0 | c >> 12;\n arr[pos++] = 0x80 | (c >> 6) & 0x3f;\n arr[pos++] = 0x80 | c & 0x3f;\n } else {\n i++; // get one more character\n c = (c & 0x3ff) << 10;\n c |= s.charCodeAt(i) & 0x3ff;\n c += 0x10000;\n\n arr[pos++] = 0xf0 | c >> 18;\n arr[pos++] = 0x80 | (c >> 12) & 0x3f;\n arr[pos++] = 0x80 | (c >> 6) & 0x3f;\n arr[pos++] = 0x80 | c & 0x3f;\n }\n }\n return arr;\n}\n\n/**\n * Returns the number of bytes required to encode the given string into UTF-8.\n * Throws if the source string has invalid UTF-16 encoding.\n */\nexport function encodedLength(s: string): number {\n let result = 0;\n for (let i = 0; i < s.length; i++) {\n const c = s.charCodeAt(i);\n if (c < 0x80) {\n result += 1;\n } else if (c < 0x800) {\n result += 2;\n } else if (c < 0xd800) {\n result += 3;\n } else if (c <= 0xdfff) {\n if (i >= s.length - 1) {\n throw new Error(INVALID_UTF16);\n }\n i++; // \"eat\" next character\n result += 4;\n } else {\n throw new Error(INVALID_UTF16);\n }\n }\n return result;\n}\n\n/**\n * Decodes the given byte array from UTF-8 into a string.\n * Throws if encoding is invalid.\n */\nexport function decode(arr: Uint8Array): string {\n const chars: string[] = [];\n for (let i = 0; i < arr.length; i++) {\n let b = arr[i];\n\n if (b & 0x80) {\n let min;\n if (b < 0xe0) {\n // Need 1 more byte.\n if (i >= arr.length) {\n throw new Error(INVALID_UTF8);\n }\n const n1 = arr[++i];\n if ((n1 & 0xc0) !== 0x80) {\n throw new Error(INVALID_UTF8);\n }\n b = (b & 0x1f) << 6 | (n1 & 0x3f);\n min = 0x80;\n } else if (b < 0xf0) {\n // Need 2 more bytes.\n if (i >= arr.length - 1) {\n throw new Error(INVALID_UTF8);\n }\n const n1 = arr[++i];\n const n2 = arr[++i];\n if ((n1 & 0xc0) !== 0x80 || (n2 & 0xc0) !== 0x80) {\n throw new Error(INVALID_UTF8);\n }\n b = (b & 0x0f) << 12 | (n1 & 0x3f) << 6 | (n2 & 0x3f);\n min = 0x800;\n } else if (b < 0xf8) {\n // Need 3 more bytes.\n if (i >= arr.length - 2) {\n throw new Error(INVALID_UTF8);\n }\n const n1 = arr[++i];\n const n2 = arr[++i];\n const n3 = arr[++i];\n if ((n1 & 0xc0) !== 0x80 || (n2 & 0xc0) !== 0x80 || (n3 & 0xc0) !== 0x80) {\n throw new Error(INVALID_UTF8);\n }\n b = (b & 0x0f) << 18 | (n1 & 0x3f) << 12 | (n2 & 0x3f) << 6 | (n3 & 0x3f);\n min = 0x10000;\n } else {\n throw new Error(INVALID_UTF8);\n }\n\n if (b < min || (b >= 0xd800 && b <= 0xdfff)) {\n throw new Error(INVALID_UTF8);\n }\n\n if (b >= 0x10000) {\n // Surrogate pair.\n if (b > 0x10ffff) {\n throw new Error(INVALID_UTF8);\n }\n b -= 0x10000;\n chars.push(String.fromCharCode(0xd800 | (b >> 10)));\n b = 0xdc00 | (b & 0x3ff);\n }\n }\n\n chars.push(String.fromCharCode(b));\n }\n return chars.join(\"\");\n}\n","// required so we don't have to do require('pusher').default etc.\nmodule.exports = require('./pusher').default;\n","import ScriptReceiver from './script_receiver';\n\n/** Builds receivers for JSONP and Script requests.\n *\n * Each receiver is an object with following fields:\n * - number - unique (for the factory instance), numerical id of the receiver\n * - id - a string ID that can be used in DOM attributes\n * - name - name of the function triggering the receiver\n * - callback - callback function\n *\n * Receivers are triggered only once, on the first callback call.\n *\n * Receivers can be called by their name or by accessing factory object\n * by the number key.\n *\n * @param {String} prefix the prefix used in ids\n * @param {String} name the name of the object\n */\nexport class ScriptReceiverFactory {\n lastId: number;\n prefix: string;\n name: string;\n\n constructor(prefix: string, name: string) {\n this.lastId = 0;\n this.prefix = prefix;\n this.name = name;\n }\n\n create(callback: Function): ScriptReceiver {\n this.lastId++;\n\n var number = this.lastId;\n var id = this.prefix + number;\n var name = this.name + '[' + number + ']';\n\n var called = false;\n var callbackWrapper = function() {\n if (!called) {\n callback.apply(null, arguments);\n called = true;\n }\n };\n\n this[number] = callbackWrapper;\n return { number: number, id: id, name: name, callback: callbackWrapper };\n }\n\n remove(receiver: ScriptReceiver) {\n delete this[receiver.number];\n }\n}\n\nexport var ScriptReceivers = new ScriptReceiverFactory(\n '_pusher_script_',\n 'Pusher.ScriptReceivers'\n);\n","import {\n ChannelAuthorizationOptions,\n UserAuthenticationOptions\n} from './auth/options';\nimport { AuthTransport } from './config';\n\nexport interface DefaultConfig {\n VERSION: string;\n PROTOCOL: number;\n wsPort: number;\n wssPort: number;\n wsPath: string;\n httpHost: string;\n httpPort: number;\n httpsPort: number;\n httpPath: string;\n stats_host: string;\n authEndpoint: string;\n authTransport: AuthTransport;\n activityTimeout: number;\n pongTimeout: number;\n unavailableTimeout: number;\n userAuthentication: UserAuthenticationOptions;\n channelAuthorization: ChannelAuthorizationOptions;\n\n cdn_http?: string;\n cdn_https?: string;\n dependency_suffix?: string;\n}\n\nvar Defaults: DefaultConfig = {\n VERSION: VERSION,\n PROTOCOL: 7,\n\n wsPort: 80,\n wssPort: 443,\n wsPath: '',\n // DEPRECATED: SockJS fallback parameters\n httpHost: 'sockjs.pusher.com',\n httpPort: 80,\n httpsPort: 443,\n httpPath: '/pusher',\n // DEPRECATED: Stats\n stats_host: 'stats.pusher.com',\n // DEPRECATED: Other settings\n authEndpoint: '/pusher/auth',\n authTransport: 'ajax',\n activityTimeout: 120000,\n pongTimeout: 30000,\n unavailableTimeout: 10000,\n userAuthentication: {\n endpoint: '/pusher/user-auth',\n transport: 'ajax'\n },\n channelAuthorization: {\n endpoint: '/pusher/auth',\n transport: 'ajax'\n },\n\n // CDN configuration\n cdn_http: CDN_HTTP,\n cdn_https: CDN_HTTPS,\n dependency_suffix: DEPENDENCY_SUFFIX\n};\n\nexport default Defaults;\n","import { ScriptReceiverFactory } from './script_receiver_factory';\nimport Defaults from 'core/defaults';\nimport DependencyLoader from './dependency_loader';\n\nexport var DependenciesReceivers = new ScriptReceiverFactory(\n '_pusher_dependencies',\n 'Pusher.DependenciesReceivers'\n);\n\nexport var Dependencies = new DependencyLoader({\n cdn_http: Defaults.cdn_http,\n cdn_https: Defaults.cdn_https,\n version: Defaults.VERSION,\n suffix: Defaults.dependency_suffix,\n receivers: DependenciesReceivers\n});\n","import {\n ScriptReceivers,\n ScriptReceiverFactory\n} from './script_receiver_factory';\nimport Runtime from 'runtime';\nimport ScriptRequest from './script_request';\n\n/** Handles loading dependency files.\n *\n * Dependency loaders don't remember whether a resource has been loaded or\n * not. It is caller's responsibility to make sure the resource is not loaded\n * twice. This is because it's impossible to detect resource loading status\n * without knowing its content.\n *\n * Options:\n * - cdn_http - url to HTTP CND\n * - cdn_https - url to HTTPS CDN\n * - version - version of pusher-js\n * - suffix - suffix appended to all names of dependency files\n *\n * @param {Object} options\n */\nexport default class DependencyLoader {\n options: any;\n receivers: ScriptReceiverFactory;\n loading: any;\n\n constructor(options: any) {\n this.options = options;\n this.receivers = options.receivers || ScriptReceivers;\n this.loading = {};\n }\n\n /** Loads the dependency from CDN.\n *\n * @param {String} name\n * @param {Function} callback\n */\n load(name: string, options: any, callback: Function) {\n var self = this;\n\n if (self.loading[name] && self.loading[name].length > 0) {\n self.loading[name].push(callback);\n } else {\n self.loading[name] = [callback];\n\n var request = Runtime.createScriptRequest(self.getPath(name, options));\n var receiver = self.receivers.create(function(error) {\n self.receivers.remove(receiver);\n\n if (self.loading[name]) {\n var callbacks = self.loading[name];\n delete self.loading[name];\n\n var successCallback = function(wasSuccessful) {\n if (!wasSuccessful) {\n request.cleanup();\n }\n };\n for (var i = 0; i < callbacks.length; i++) {\n callbacks[i](error, successCallback);\n }\n }\n });\n request.send(receiver);\n }\n }\n\n /** Returns a root URL for pusher-js CDN.\n *\n * @returns {String}\n */\n getRoot(options: any): string {\n var cdn;\n var protocol = Runtime.getDocument().location.protocol;\n if ((options && options.useTLS) || protocol === 'https:') {\n cdn = this.options.cdn_https;\n } else {\n cdn = this.options.cdn_http;\n }\n // make sure there are no double slashes\n return cdn.replace(/\\/*$/, '') + '/' + this.options.version;\n }\n\n /** Returns a full path to a dependency file.\n *\n * @param {String} name\n * @returns {String}\n */\n getPath(name: string, options: any): string {\n return this.getRoot(options) + '/' + name + this.options.suffix + '.js';\n }\n}\n","/**\n * A place to store help URLs for error messages etc\n */\n\nconst urlStore = {\n baseUrl: 'https://pusher.com',\n urls: {\n authenticationEndpoint: {\n path: '/docs/channels/server_api/authenticating_users'\n },\n authorizationEndpoint: {\n path: '/docs/channels/server_api/authorizing-users/'\n },\n javascriptQuickStart: {\n path: '/docs/javascript_quick_start'\n },\n triggeringClientEvents: {\n path: '/docs/client_api_guide/client_events#trigger-events'\n },\n encryptedChannelSupport: {\n fullUrl:\n 'https://github.com/pusher/pusher-js/tree/cc491015371a4bde5743d1c87a0fbac0feb53195#encrypted-channel-support'\n }\n }\n};\n\n/** Builds a consistent string with links to pusher documentation\n *\n * @param {string} key - relevant key in the url_store.urls object\n * @return {string} suffix string to append to log message\n */\nconst buildLogSuffix = function(key: string): string {\n const urlPrefix = 'See:';\n const urlObj = urlStore.urls[key];\n if (!urlObj) return '';\n\n let url;\n if (urlObj.fullUrl) {\n url = urlObj.fullUrl;\n } else if (urlObj.path) {\n url = urlStore.baseUrl + urlObj.path;\n }\n\n if (!url) return '';\n return `${urlPrefix} ${url}`;\n};\n\nexport default { buildLogSuffix };\n","export enum AuthRequestType {\n UserAuthentication = 'user-authentication',\n ChannelAuthorization = 'channel-authorization'\n}\n\nexport interface ChannelAuthorizationData {\n auth: string;\n channel_data?: string;\n shared_secret?: string;\n}\n\nexport type ChannelAuthorizationCallback = (\n error: Error | null,\n authData: ChannelAuthorizationData | null\n) => void;\n\nexport interface ChannelAuthorizationRequestParams {\n socketId: string;\n channelName: string;\n}\n\nexport interface ChannelAuthorizationHandler {\n (\n params: ChannelAuthorizationRequestParams,\n callback: ChannelAuthorizationCallback\n ): void;\n}\n\nexport interface UserAuthenticationData {\n auth: string;\n user_data: string;\n}\n\nexport type UserAuthenticationCallback = (\n error: Error | null,\n authData: UserAuthenticationData | null\n) => void;\n\nexport interface UserAuthenticationRequestParams {\n socketId: string;\n}\n\nexport interface UserAuthenticationHandler {\n (\n params: UserAuthenticationRequestParams,\n callback: UserAuthenticationCallback\n ): void;\n}\n\nexport type AuthTransportCallback =\n | ChannelAuthorizationCallback\n | UserAuthenticationCallback;\n\nexport interface AuthOptionsT {\n transport: 'ajax' | 'jsonp';\n endpoint: string;\n params?: any;\n headers?: any;\n paramsProvider?: () => any;\n headersProvider?: () => any;\n customHandler?: AuthHandler;\n}\n\nexport declare type UserAuthenticationOptions = AuthOptionsT<\n UserAuthenticationHandler\n>;\nexport declare type ChannelAuthorizationOptions = AuthOptionsT<\n ChannelAuthorizationHandler\n>;\n\nexport interface InternalAuthOptions {\n transport: 'ajax' | 'jsonp';\n endpoint: string;\n params?: any;\n headers?: any;\n paramsProvider?: () => any;\n headersProvider?: () => any;\n}\n","/** Error classes used throughout the library. */\n// https://github.com/Microsoft/TypeScript-wiki/blob/master/Breaking-Changes.md#extending-built-ins-like-error-array-and-map-may-no-longer-work\nexport class BadEventName extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\nexport class BadChannelName extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\nexport class RequestTimedOut extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class TransportPriorityTooLow extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class TransportClosed extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class UnsupportedFeature extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class UnsupportedTransport extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class UnsupportedStrategy extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class HTTPAuthError extends Error {\n status: number;\n constructor(status: number, msg?: string) {\n super(msg);\n this.status = status;\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n","import TimelineSender from 'core/timeline/timeline_sender';\nimport * as Collections from 'core/utils/collections';\nimport Util from 'core/util';\nimport Runtime from 'runtime';\nimport { AuthTransport } from 'core/auth/auth_transports';\nimport AbstractRuntime from 'runtimes/interface';\nimport UrlStore from 'core/utils/url_store';\nimport {\n AuthRequestType,\n AuthTransportCallback,\n InternalAuthOptions\n} from 'core/auth/options';\nimport { HTTPAuthError } from 'core/errors';\n\nconst ajax: AuthTransport = function(\n context: AbstractRuntime,\n query: string,\n authOptions: InternalAuthOptions,\n authRequestType: AuthRequestType,\n callback: AuthTransportCallback\n) {\n const xhr = Runtime.createXHR();\n xhr.open('POST', authOptions.endpoint, true);\n\n // add request headers\n xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');\n for (var headerName in authOptions.headers) {\n xhr.setRequestHeader(headerName, authOptions.headers[headerName]);\n }\n if (authOptions.headersProvider != null) {\n let dynamicHeaders = authOptions.headersProvider();\n for (var headerName in dynamicHeaders) {\n xhr.setRequestHeader(headerName, dynamicHeaders[headerName]);\n }\n }\n\n xhr.onreadystatechange = function() {\n if (xhr.readyState === 4) {\n if (xhr.status === 200) {\n let data;\n let parsed = false;\n\n try {\n data = JSON.parse(xhr.responseText);\n parsed = true;\n } catch (e) {\n callback(\n new HTTPAuthError(\n 200,\n `JSON returned from ${authRequestType.toString()} endpoint was invalid, yet status code was 200. Data was: ${\n xhr.responseText\n }`\n ),\n null\n );\n }\n\n if (parsed) {\n // prevents double execution.\n callback(null, data);\n }\n } else {\n let suffix = '';\n switch (authRequestType) {\n case AuthRequestType.UserAuthentication:\n suffix = UrlStore.buildLogSuffix('authenticationEndpoint');\n break;\n case AuthRequestType.ChannelAuthorization:\n suffix = `Clients must be authorized to join private or presence channels. ${UrlStore.buildLogSuffix(\n 'authorizationEndpoint'\n )}`;\n break;\n }\n callback(\n new HTTPAuthError(\n xhr.status,\n `Unable to retrieve auth string from ${authRequestType.toString()} endpoint - ` +\n `received status: ${xhr.status} from ${authOptions.endpoint}. ${suffix}`\n ),\n null\n );\n }\n }\n };\n\n xhr.send(query);\n return xhr;\n};\n\nexport default ajax;\n","export default function encode(s: any): string {\n return btoa(utob(s));\n}\n\nvar fromCharCode = String.fromCharCode;\n\nvar b64chars =\n 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';\nvar b64tab = {};\n\nfor (var i = 0, l = b64chars.length; i < l; i++) {\n b64tab[b64chars.charAt(i)] = i;\n}\n\nvar cb_utob = function(c) {\n var cc = c.charCodeAt(0);\n return cc < 0x80\n ? c\n : cc < 0x800\n ? fromCharCode(0xc0 | (cc >>> 6)) + fromCharCode(0x80 | (cc & 0x3f))\n : fromCharCode(0xe0 | ((cc >>> 12) & 0x0f)) +\n fromCharCode(0x80 | ((cc >>> 6) & 0x3f)) +\n fromCharCode(0x80 | (cc & 0x3f));\n};\n\nvar utob = function(u) {\n return u.replace(/[^\\x00-\\x7F]/g, cb_utob);\n};\n\nvar cb_encode = function(ccc) {\n var padlen = [0, 2, 1][ccc.length % 3];\n var ord =\n (ccc.charCodeAt(0) << 16) |\n ((ccc.length > 1 ? ccc.charCodeAt(1) : 0) << 8) |\n (ccc.length > 2 ? ccc.charCodeAt(2) : 0);\n var chars = [\n b64chars.charAt(ord >>> 18),\n b64chars.charAt((ord >>> 12) & 63),\n padlen >= 2 ? '=' : b64chars.charAt((ord >>> 6) & 63),\n padlen >= 1 ? '=' : b64chars.charAt(ord & 63)\n ];\n return chars.join('');\n};\n\nvar btoa =\n global.btoa ||\n function(b) {\n return b.replace(/[\\s\\S]{1,3}/g, cb_encode);\n };\n","import TimedCallback from './timed_callback';\nimport { Delay, Scheduler, Canceller } from './scheduling';\n\nabstract class Timer {\n protected clear: Canceller;\n protected timer: number | void;\n\n constructor(\n set: Scheduler,\n clear: Canceller,\n delay: Delay,\n callback: TimedCallback\n ) {\n this.clear = clear;\n this.timer = set(() => {\n if (this.timer) {\n this.timer = callback(this.timer);\n }\n }, delay);\n }\n\n /** Returns whether the timer is still running.\n *\n * @return {Boolean}\n */\n isRunning(): boolean {\n return this.timer !== null;\n }\n\n /** Aborts a timer when it's running. */\n ensureAborted() {\n if (this.timer) {\n this.clear(this.timer);\n this.timer = null;\n }\n }\n}\n\nexport default Timer;\n","import Timer from './abstract_timer';\nimport TimedCallback from './timed_callback';\nimport { Delay } from './scheduling';\n\n// We need to bind clear functions this way to avoid exceptions on IE8\nfunction clearTimeout(timer) {\n global.clearTimeout(timer);\n}\nfunction clearInterval(timer) {\n global.clearInterval(timer);\n}\n\n/** Cross-browser compatible one-off timer abstraction.\n *\n * @param {Number} delay\n * @param {Function} callback\n */\nexport class OneOffTimer extends Timer {\n constructor(delay: Delay, callback: TimedCallback) {\n super(setTimeout, clearTimeout, delay, function(timer) {\n callback();\n return null;\n });\n }\n}\n\n/** Cross-browser compatible periodic timer abstraction.\n *\n * @param {Number} delay\n * @param {Function} callback\n */\nexport class PeriodicTimer extends Timer {\n constructor(delay: Delay, callback: TimedCallback) {\n super(setInterval, clearInterval, delay, function(timer) {\n callback();\n return timer;\n });\n }\n}\n","import * as Collections from './utils/collections';\nimport TimedCallback from './utils/timers/timed_callback';\nimport { OneOffTimer, PeriodicTimer } from './utils/timers';\n\nvar Util = {\n now(): number {\n if (Date.now) {\n return Date.now();\n } else {\n return new Date().valueOf();\n }\n },\n\n defer(callback: TimedCallback): OneOffTimer {\n return new OneOffTimer(0, callback);\n },\n\n /** Builds a function that will proxy a method call to its first argument.\n *\n * Allows partial application of arguments, so additional arguments are\n * prepended to the argument list.\n *\n * @param {String} name method name\n * @return {Function} proxy function\n */\n method(name: string, ...args: any[]): Function {\n var boundArguments = Array.prototype.slice.call(arguments, 1);\n return function(object) {\n return object[name].apply(object, boundArguments.concat(arguments));\n };\n }\n};\n\nexport default Util;\n","import base64encode from '../base64';\nimport Util from '../util';\n\n/** Merges multiple objects into the target argument.\n *\n * For properties that are plain Objects, performs a deep-merge. For the\n * rest it just copies the value of the property.\n *\n * To extend prototypes use it as following:\n * Pusher.Util.extend(Target.prototype, Base.prototype)\n *\n * You can also use it to merge objects without altering them:\n * Pusher.Util.extend({}, object1, object2)\n *\n * @param {Object} target\n * @return {Object} the target argument\n */\nexport function extend(target: any, ...sources: any[]): T {\n for (var i = 0; i < sources.length; i++) {\n var extensions = sources[i];\n for (var property in extensions) {\n if (\n extensions[property] &&\n extensions[property].constructor &&\n extensions[property].constructor === Object\n ) {\n target[property] = extend(target[property] || {}, extensions[property]);\n } else {\n target[property] = extensions[property];\n }\n }\n }\n return target;\n}\n\nexport function stringify(): string {\n var m = ['Pusher'];\n for (var i = 0; i < arguments.length; i++) {\n if (typeof arguments[i] === 'string') {\n m.push(arguments[i]);\n } else {\n m.push(safeJSONStringify(arguments[i]));\n }\n }\n return m.join(' : ');\n}\n\nexport function arrayIndexOf(array: any[], item: any): number {\n // MSIE doesn't have array.indexOf\n var nativeIndexOf = Array.prototype.indexOf;\n if (array === null) {\n return -1;\n }\n if (nativeIndexOf && array.indexOf === nativeIndexOf) {\n return array.indexOf(item);\n }\n for (var i = 0, l = array.length; i < l; i++) {\n if (array[i] === item) {\n return i;\n }\n }\n return -1;\n}\n\n/** Applies a function f to all properties of an object.\n *\n * Function f gets 3 arguments passed:\n * - element from the object\n * - key of the element\n * - reference to the object\n *\n * @param {Object} object\n * @param {Function} f\n */\nexport function objectApply(object: any, f: Function) {\n for (var key in object) {\n if (Object.prototype.hasOwnProperty.call(object, key)) {\n f(object[key], key, object);\n }\n }\n}\n\n/** Return a list of objects own proerty keys\n *\n * @param {Object} object\n * @returns {Array}\n */\nexport function keys(object: any): string[] {\n var keys = [];\n objectApply(object, function(_, key) {\n keys.push(key);\n });\n return keys;\n}\n\n/** Return a list of object's own property values\n *\n * @param {Object} object\n * @returns {Array}\n */\nexport function values(object: any): any[] {\n var values = [];\n objectApply(object, function(value) {\n values.push(value);\n });\n return values;\n}\n\n/** Applies a function f to all elements of an array.\n *\n * Function f gets 3 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function apply(array: any[], f: Function, context?: any) {\n for (var i = 0; i < array.length; i++) {\n f.call(context || global, array[i], i, array);\n }\n}\n\n/** Maps all elements of the array and returns the result.\n *\n * Function f gets 4 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n * - reference to the destination array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function map(array: any[], f: Function): any[] {\n var result = [];\n for (var i = 0; i < array.length; i++) {\n result.push(f(array[i], i, array, result));\n }\n return result;\n}\n\n/** Maps all elements of the object and returns the result.\n *\n * Function f gets 4 arguments passed:\n * - element from the object\n * - key of the element\n * - reference to the source object\n * - reference to the destination object\n *\n * @param {Object} object\n * @param {Function} f\n */\nexport function mapObject(object: any, f: Function): any {\n var result = {};\n objectApply(object, function(value, key) {\n result[key] = f(value);\n });\n return result;\n}\n\n/** Filters elements of the array using a test function.\n *\n * Function test gets 4 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n * - reference to the destination array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function filter(array: any[], test: Function): any[] {\n test =\n test ||\n function(value) {\n return !!value;\n };\n\n var result = [];\n for (var i = 0; i < array.length; i++) {\n if (test(array[i], i, array, result)) {\n result.push(array[i]);\n }\n }\n return result;\n}\n\n/** Filters properties of the object using a test function.\n *\n * Function test gets 4 arguments passed:\n * - element from the object\n * - key of the element\n * - reference to the source object\n * - reference to the destination object\n *\n * @param {Object} object\n * @param {Function} f\n */\nexport function filterObject(object: Object, test: Function) {\n var result = {};\n objectApply(object, function(value, key) {\n if ((test && test(value, key, object, result)) || Boolean(value)) {\n result[key] = value;\n }\n });\n return result;\n}\n\n/** Flattens an object into a two-dimensional array.\n *\n * @param {Object} object\n * @return {Array} resulting array of [key, value] pairs\n */\nexport function flatten(object: Object): any[] {\n var result = [];\n objectApply(object, function(value, key) {\n result.push([key, value]);\n });\n return result;\n}\n\n/** Checks whether any element of the array passes the test.\n *\n * Function test gets 3 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function any(array: any[], test: Function): boolean {\n for (var i = 0; i < array.length; i++) {\n if (test(array[i], i, array)) {\n return true;\n }\n }\n return false;\n}\n\n/** Checks whether all elements of the array pass the test.\n *\n * Function test gets 3 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function all(array: any[], test: Function): boolean {\n for (var i = 0; i < array.length; i++) {\n if (!test(array[i], i, array)) {\n return false;\n }\n }\n return true;\n}\n\nexport function encodeParamsObject(data): string {\n return mapObject(data, function(value) {\n if (typeof value === 'object') {\n value = safeJSONStringify(value);\n }\n return encodeURIComponent(base64encode(value.toString()));\n });\n}\n\nexport function buildQueryString(data: any): string {\n var params = filterObject(data, function(value) {\n return value !== undefined;\n });\n\n var query = map(\n flatten(encodeParamsObject(params)),\n Util.method('join', '=')\n ).join('&');\n\n return query;\n}\n\n/**\n * See https://github.com/douglascrockford/JSON-js/blob/master/cycle.js\n *\n * Remove circular references from an object. Required for JSON.stringify in\n * React Native, which tends to blow up a lot.\n *\n * @param {any} object\n * @return {any} Decycled object\n */\nexport function decycleObject(object: any): any {\n var objects = [],\n paths = [];\n\n return (function derez(value, path) {\n var i, name, nu;\n\n switch (typeof value) {\n case 'object':\n if (!value) {\n return null;\n }\n for (i = 0; i < objects.length; i += 1) {\n if (objects[i] === value) {\n return { $ref: paths[i] };\n }\n }\n\n objects.push(value);\n paths.push(path);\n\n if (Object.prototype.toString.apply(value) === '[object Array]') {\n nu = [];\n for (i = 0; i < value.length; i += 1) {\n nu[i] = derez(value[i], path + '[' + i + ']');\n }\n } else {\n nu = {};\n for (name in value) {\n if (Object.prototype.hasOwnProperty.call(value, name)) {\n nu[name] = derez(\n value[name],\n path + '[' + JSON.stringify(name) + ']'\n );\n }\n }\n }\n return nu;\n case 'number':\n case 'string':\n case 'boolean':\n return value;\n }\n })(object, '$');\n}\n\n/**\n * Provides a cross-browser and cross-platform way to safely stringify objects\n * into JSON. This is particularly necessary for ReactNative, where circular JSON\n * structures throw an exception.\n *\n * @param {any} source The object to stringify\n * @return {string} The serialized output.\n */\nexport function safeJSONStringify(source: any): string {\n try {\n return JSON.stringify(source);\n } catch (e) {\n return JSON.stringify(decycleObject(source));\n }\n}\n","import { stringify } from './utils/collections';\nimport Pusher from './pusher';\n\nclass Logger {\n debug(...args: any[]) {\n this.log(this.globalLog, args);\n }\n\n warn(...args: any[]) {\n this.log(this.globalLogWarn, args);\n }\n\n error(...args: any[]) {\n this.log(this.globalLogError, args);\n }\n\n private globalLog = (message: string) => {\n if (global.console && global.console.log) {\n global.console.log(message);\n }\n };\n\n private globalLogWarn(message: string) {\n if (global.console && global.console.warn) {\n global.console.warn(message);\n } else {\n this.globalLog(message);\n }\n }\n\n private globalLogError(message: string) {\n if (global.console && global.console.error) {\n global.console.error(message);\n } else {\n this.globalLogWarn(message);\n }\n }\n\n private log(\n defaultLoggingFunction: (message: string) => void,\n ...args: any[]\n ) {\n var message = stringify.apply(this, arguments);\n if (Pusher.log) {\n Pusher.log(message);\n } else if (Pusher.logToConsole) {\n const log = defaultLoggingFunction.bind(this);\n log(message);\n }\n }\n}\n\nexport default new Logger();\n","import Browser from '../browser';\nimport Logger from 'core/logger';\nimport JSONPRequest from '../dom/jsonp_request';\nimport { ScriptReceivers } from '../dom/script_receiver_factory';\nimport { AuthTransport } from 'core/auth/auth_transports';\nimport {\n AuthRequestType,\n AuthTransportCallback,\n InternalAuthOptions\n} from 'core/auth/options';\n\nvar jsonp: AuthTransport = function(\n context: Browser,\n query: string,\n authOptions: InternalAuthOptions,\n authRequestType: AuthRequestType,\n callback: AuthTransportCallback\n) {\n if (\n authOptions.headers !== undefined ||\n authOptions.headersProvider != null\n ) {\n Logger.warn(\n `To send headers with the ${authRequestType.toString()} request, you must use AJAX, rather than JSONP.`\n );\n }\n\n var callbackName = context.nextAuthCallbackID.toString();\n context.nextAuthCallbackID++;\n\n var document = context.getDocument();\n var script = document.createElement('script');\n // Hacked wrapper.\n context.auth_callbacks[callbackName] = function(data) {\n callback(null, data);\n };\n\n var callback_name = \"Pusher.auth_callbacks['\" + callbackName + \"']\";\n script.src =\n authOptions.endpoint +\n '?callback=' +\n encodeURIComponent(callback_name) +\n '&' +\n query;\n\n var head =\n document.getElementsByTagName('head')[0] || document.documentElement;\n head.insertBefore(script, head.firstChild);\n};\n\nexport default jsonp;\n","import ScriptReceiver from './script_receiver';\n\n/** Sends a generic HTTP GET request using a script tag.\n *\n * By constructing URL in a specific way, it can be used for loading\n * JavaScript resources or JSONP requests. It can notify about errors, but\n * only in certain environments. Please take care of monitoring the state of\n * the request yourself.\n *\n * @param {String} src\n */\nexport default class ScriptRequest {\n src: string;\n script: any;\n errorScript: any;\n\n constructor(src: string) {\n this.src = src;\n }\n\n send(receiver: ScriptReceiver) {\n var self = this;\n var errorString = 'Error loading ' + self.src;\n\n self.script = document.createElement('script');\n self.script.id = receiver.id;\n self.script.src = self.src;\n self.script.type = 'text/javascript';\n self.script.charset = 'UTF-8';\n\n if (self.script.addEventListener) {\n self.script.onerror = function() {\n receiver.callback(errorString);\n };\n self.script.onload = function() {\n receiver.callback(null);\n };\n } else {\n self.script.onreadystatechange = function() {\n if (\n self.script.readyState === 'loaded' ||\n self.script.readyState === 'complete'\n ) {\n receiver.callback(null);\n }\n };\n }\n\n // Opera<11.6 hack for missing onerror callback\n if (\n self.script.async === undefined &&\n (document).attachEvent &&\n /opera/i.test(navigator.userAgent)\n ) {\n self.errorScript = document.createElement('script');\n self.errorScript.id = receiver.id + '_error';\n self.errorScript.text = receiver.name + \"('\" + errorString + \"');\";\n self.script.async = self.errorScript.async = false;\n } else {\n self.script.async = true;\n }\n\n var head = document.getElementsByTagName('head')[0];\n head.insertBefore(self.script, head.firstChild);\n if (self.errorScript) {\n head.insertBefore(self.errorScript, self.script.nextSibling);\n }\n }\n\n /** Cleans up the DOM remains of the script request. */\n cleanup() {\n if (this.script) {\n this.script.onload = this.script.onerror = null;\n this.script.onreadystatechange = null;\n }\n if (this.script && this.script.parentNode) {\n this.script.parentNode.removeChild(this.script);\n }\n if (this.errorScript && this.errorScript.parentNode) {\n this.errorScript.parentNode.removeChild(this.errorScript);\n }\n this.script = null;\n this.errorScript = null;\n }\n}\n","import ScriptReceiver from './script_receiver';\nimport ScriptRequest from './script_request';\nimport * as Collections from 'core/utils/collections';\nimport Util from 'core/util';\nimport Runtime from '../runtime';\n\n/** Sends data via JSONP.\n *\n * Data is a key-value map. Its values are JSON-encoded and then passed\n * through base64. Finally, keys and encoded values are appended to the query\n * string.\n *\n * The class itself does not guarantee raising errors on failures, as it's not\n * possible to support such feature on all browsers. Instead, JSONP endpoint\n * should call back in a way that's easy to distinguish from browser calls,\n * for example by passing a second argument to the receiver.\n *\n * @param {String} url\n * @param {Object} data key-value map of data to be submitted\n */\nexport default class JSONPRequest {\n url: string;\n data: any;\n request: ScriptRequest;\n\n constructor(url: string, data: any) {\n this.url = url;\n this.data = data;\n }\n\n /** Sends the actual JSONP request.\n *\n * @param {ScriptReceiver} receiver\n */\n send(receiver: ScriptReceiver) {\n if (this.request) {\n return;\n }\n\n var query = Collections.buildQueryString(this.data);\n var url = this.url + '/' + receiver.number + '?' + query;\n this.request = Runtime.createScriptRequest(url);\n this.request.send(receiver);\n }\n\n /** Cleans up the DOM remains of the JSONP request. */\n cleanup() {\n if (this.request) {\n this.request.cleanup();\n }\n }\n}\n","import TimelineSender from 'core/timeline/timeline_sender';\nimport TimelineTransport from 'core/timeline/timeline_transport';\nimport Browser from 'runtime';\nimport { AuthTransport } from 'core/auth/auth_transports';\nimport { ScriptReceivers } from '../dom/script_receiver_factory';\n\nvar getAgent = function(sender: TimelineSender, useTLS: boolean) {\n return function(data: any, callback: Function) {\n var scheme = 'http' + (useTLS ? 's' : '') + '://';\n var url =\n scheme + (sender.host || sender.options.host) + sender.options.path;\n var request = Browser.createJSONPRequest(url, data);\n\n var receiver = Browser.ScriptReceivers.create(function(error, result) {\n ScriptReceivers.remove(receiver);\n request.cleanup();\n\n if (result && result.host) {\n sender.host = result.host;\n }\n if (callback) {\n callback(error, result);\n }\n });\n request.send(receiver);\n };\n};\n\nvar jsonp = {\n name: 'jsonp',\n getAgent\n};\n\nexport default jsonp;\n","import Defaults from '../defaults';\nimport { default as URLScheme, URLSchemeParams } from './url_scheme';\n\nfunction getGenericURL(\n baseScheme: string,\n params: URLSchemeParams,\n path: string\n): string {\n var scheme = baseScheme + (params.useTLS ? 's' : '');\n var host = params.useTLS ? params.hostTLS : params.hostNonTLS;\n return scheme + '://' + host + path;\n}\n\nfunction getGenericPath(key: string, queryString?: string): string {\n var path = '/app/' + key;\n var query =\n '?protocol=' +\n Defaults.PROTOCOL +\n '&client=js' +\n '&version=' +\n Defaults.VERSION +\n (queryString ? '&' + queryString : '');\n return path + query;\n}\n\nexport var ws: URLScheme = {\n getInitial: function(key: string, params: URLSchemeParams): string {\n var path = (params.httpPath || '') + getGenericPath(key, 'flash=false');\n return getGenericURL('ws', params, path);\n }\n};\n\nexport var http: URLScheme = {\n getInitial: function(key: string, params: URLSchemeParams): string {\n var path = (params.httpPath || '/pusher') + getGenericPath(key);\n return getGenericURL('http', params, path);\n }\n};\n\nexport var sockjs: URLScheme = {\n getInitial: function(key: string, params: URLSchemeParams): string {\n return getGenericURL('http', params, params.httpPath || '/pusher');\n },\n getPath: function(key: string, params: URLSchemeParams): string {\n return getGenericPath(key);\n }\n};\n","import Callback from './callback';\nimport * as Collections from '../utils/collections';\nimport CallbackTable from './callback_table';\n\nexport default class CallbackRegistry {\n _callbacks: CallbackTable;\n\n constructor() {\n this._callbacks = {};\n }\n\n get(name: string): Callback[] {\n return this._callbacks[prefix(name)];\n }\n\n add(name: string, callback: Function, context: any) {\n var prefixedEventName = prefix(name);\n this._callbacks[prefixedEventName] =\n this._callbacks[prefixedEventName] || [];\n this._callbacks[prefixedEventName].push({\n fn: callback,\n context: context\n });\n }\n\n remove(name?: string, callback?: Function, context?: any) {\n if (!name && !callback && !context) {\n this._callbacks = {};\n return;\n }\n\n var names = name ? [prefix(name)] : Collections.keys(this._callbacks);\n\n if (callback || context) {\n this.removeCallback(names, callback, context);\n } else {\n this.removeAllCallbacks(names);\n }\n }\n\n private removeCallback(names: string[], callback: Function, context: any) {\n Collections.apply(\n names,\n function(name) {\n this._callbacks[name] = Collections.filter(\n this._callbacks[name] || [],\n function(binding) {\n return (\n (callback && callback !== binding.fn) ||\n (context && context !== binding.context)\n );\n }\n );\n if (this._callbacks[name].length === 0) {\n delete this._callbacks[name];\n }\n },\n this\n );\n }\n\n private removeAllCallbacks(names: string[]) {\n Collections.apply(\n names,\n function(name) {\n delete this._callbacks[name];\n },\n this\n );\n }\n}\n\nfunction prefix(name: string): string {\n return '_' + name;\n}\n","import * as Collections from '../utils/collections';\nimport Callback from './callback';\nimport Metadata from '../channels/metadata';\nimport CallbackRegistry from './callback_registry';\n\n/** Manages callback bindings and event emitting.\n *\n * @param Function failThrough called when no listeners are bound to an event\n */\nexport default class Dispatcher {\n callbacks: CallbackRegistry;\n global_callbacks: Function[];\n failThrough: Function;\n\n constructor(failThrough?: Function) {\n this.callbacks = new CallbackRegistry();\n this.global_callbacks = [];\n this.failThrough = failThrough;\n }\n\n bind(eventName: string, callback: Function, context?: any) {\n this.callbacks.add(eventName, callback, context);\n return this;\n }\n\n bind_global(callback: Function) {\n this.global_callbacks.push(callback);\n return this;\n }\n\n unbind(eventName?: string, callback?: Function, context?: any) {\n this.callbacks.remove(eventName, callback, context);\n return this;\n }\n\n unbind_global(callback?: Function) {\n if (!callback) {\n this.global_callbacks = [];\n return this;\n }\n\n this.global_callbacks = Collections.filter(\n this.global_callbacks || [],\n c => c !== callback\n );\n\n return this;\n }\n\n unbind_all() {\n this.unbind();\n this.unbind_global();\n return this;\n }\n\n emit(eventName: string, data?: any, metadata?: Metadata): Dispatcher {\n for (var i = 0; i < this.global_callbacks.length; i++) {\n this.global_callbacks[i](eventName, data);\n }\n\n var callbacks = this.callbacks.get(eventName);\n var args = [];\n\n if (metadata) {\n // if there's a metadata argument, we need to call the callback with both\n // data and metadata regardless of whether data is undefined\n args.push(data, metadata);\n } else if (data) {\n // metadata is undefined, so we only need to call the callback with data\n // if data exists\n args.push(data);\n }\n\n if (callbacks && callbacks.length > 0) {\n for (var i = 0; i < callbacks.length; i++) {\n callbacks[i].fn.apply(callbacks[i].context || global, args);\n }\n } else if (this.failThrough) {\n this.failThrough(eventName, data);\n }\n\n return this;\n }\n}\n","import Util from '../util';\nimport * as Collections from '../utils/collections';\nimport { default as EventsDispatcher } from '../events/dispatcher';\nimport Logger from '../logger';\nimport TransportHooks from './transport_hooks';\nimport Socket from '../socket';\nimport Runtime from 'runtime';\nimport Timeline from '../timeline/timeline';\nimport TransportConnectionOptions from './transport_connection_options';\n\n/** Provides universal API for transport connections.\n *\n * Transport connection is a low-level object that wraps a connection method\n * and exposes a simple evented interface for the connection state and\n * messaging. It does not implement Pusher-specific WebSocket protocol.\n *\n * Additionally, it fetches resources needed for transport to work and exposes\n * an interface for querying transport features.\n *\n * States:\n * - new - initial state after constructing the object\n * - initializing - during initialization phase, usually fetching resources\n * - intialized - ready to establish a connection\n * - connection - when connection is being established\n * - open - when connection ready to be used\n * - closed - after connection was closed be either side\n *\n * Emits:\n * - error - after the connection raised an error\n *\n * Options:\n * - useTLS - whether connection should be over TLS\n * - hostTLS - host to connect to when connection is over TLS\n * - hostNonTLS - host to connect to when connection is over TLS\n *\n * @param {String} key application key\n * @param {Object} options\n */\nexport default class TransportConnection extends EventsDispatcher {\n hooks: TransportHooks;\n name: string;\n priority: number;\n key: string;\n options: TransportConnectionOptions;\n state: string;\n timeline: Timeline;\n activityTimeout: number;\n id: number;\n socket: Socket;\n beforeOpen: Function;\n initialize: Function;\n\n constructor(\n hooks: TransportHooks,\n name: string,\n priority: number,\n key: string,\n options: TransportConnectionOptions\n ) {\n super();\n this.initialize = Runtime.transportConnectionInitializer;\n this.hooks = hooks;\n this.name = name;\n this.priority = priority;\n this.key = key;\n this.options = options;\n\n this.state = 'new';\n this.timeline = options.timeline;\n this.activityTimeout = options.activityTimeout;\n this.id = this.timeline.generateUniqueID();\n }\n\n /** Checks whether the transport handles activity checks by itself.\n *\n * @return {Boolean}\n */\n handlesActivityChecks(): boolean {\n return Boolean(this.hooks.handlesActivityChecks);\n }\n\n /** Checks whether the transport supports the ping/pong API.\n *\n * @return {Boolean}\n */\n supportsPing(): boolean {\n return Boolean(this.hooks.supportsPing);\n }\n\n /** Tries to establish a connection.\n *\n * @returns {Boolean} false if transport is in invalid state\n */\n connect(): boolean {\n if (this.socket || this.state !== 'initialized') {\n return false;\n }\n\n var url = this.hooks.urls.getInitial(this.key, this.options);\n try {\n this.socket = this.hooks.getSocket(url, this.options);\n } catch (e) {\n Util.defer(() => {\n this.onError(e);\n this.changeState('closed');\n });\n return false;\n }\n\n this.bindListeners();\n\n Logger.debug('Connecting', { transport: this.name, url });\n this.changeState('connecting');\n return true;\n }\n\n /** Closes the connection.\n *\n * @return {Boolean} true if there was a connection to close\n */\n close(): boolean {\n if (this.socket) {\n this.socket.close();\n return true;\n } else {\n return false;\n }\n }\n\n /** Sends data over the open connection.\n *\n * @param {String} data\n * @return {Boolean} true only when in the \"open\" state\n */\n send(data: any): boolean {\n if (this.state === 'open') {\n // Workaround for MobileSafari bug (see https://gist.github.com/2052006)\n Util.defer(() => {\n if (this.socket) {\n this.socket.send(data);\n }\n });\n return true;\n } else {\n return false;\n }\n }\n\n /** Sends a ping if the connection is open and transport supports it. */\n ping() {\n if (this.state === 'open' && this.supportsPing()) {\n this.socket.ping();\n }\n }\n\n private onOpen() {\n if (this.hooks.beforeOpen) {\n this.hooks.beforeOpen(\n this.socket,\n this.hooks.urls.getPath(this.key, this.options)\n );\n }\n this.changeState('open');\n this.socket.onopen = undefined;\n }\n\n private onError(error) {\n this.emit('error', { type: 'WebSocketError', error: error });\n this.timeline.error(this.buildTimelineMessage({ error: error.toString() }));\n }\n\n private onClose(closeEvent?: any) {\n if (closeEvent) {\n this.changeState('closed', {\n code: closeEvent.code,\n reason: closeEvent.reason,\n wasClean: closeEvent.wasClean\n });\n } else {\n this.changeState('closed');\n }\n this.unbindListeners();\n this.socket = undefined;\n }\n\n private onMessage(message) {\n this.emit('message', message);\n }\n\n private onActivity() {\n this.emit('activity');\n }\n\n private bindListeners() {\n this.socket.onopen = () => {\n this.onOpen();\n };\n this.socket.onerror = error => {\n this.onError(error);\n };\n this.socket.onclose = closeEvent => {\n this.onClose(closeEvent);\n };\n this.socket.onmessage = message => {\n this.onMessage(message);\n };\n\n if (this.supportsPing()) {\n this.socket.onactivity = () => {\n this.onActivity();\n };\n }\n }\n\n private unbindListeners() {\n if (this.socket) {\n this.socket.onopen = undefined;\n this.socket.onerror = undefined;\n this.socket.onclose = undefined;\n this.socket.onmessage = undefined;\n if (this.supportsPing()) {\n this.socket.onactivity = undefined;\n }\n }\n }\n\n private changeState(state: string, params?: any) {\n this.state = state;\n this.timeline.info(\n this.buildTimelineMessage({\n state: state,\n params: params\n })\n );\n this.emit(state, params);\n }\n\n buildTimelineMessage(message): any {\n return Collections.extend({ cid: this.id }, message);\n }\n}\n","import Factory from '../utils/factory';\nimport TransportHooks from './transport_hooks';\nimport TransportConnection from './transport_connection';\nimport TransportConnectionOptions from './transport_connection_options';\n\n/** Provides interface for transport connection instantiation.\n *\n * Takes transport-specific hooks as the only argument, which allow checking\n * for transport support and creating its connections.\n *\n * Supported hooks: * - file - the name of the file to be fetched during initialization\n * - urls - URL scheme to be used by transport\n * - handlesActivityCheck - true when the transport handles activity checks\n * - supportsPing - true when the transport has a ping/activity API\n * - isSupported - tells whether the transport is supported in the environment\n * - getSocket - creates a WebSocket-compatible transport socket\n *\n * See transports.js for specific implementations.\n *\n * @param {Object} hooks object containing all needed transport hooks\n */\nexport default class Transport {\n hooks: TransportHooks;\n\n constructor(hooks: TransportHooks) {\n this.hooks = hooks;\n }\n\n /** Returns whether the transport is supported in the environment.\n *\n * @param {Object} envronment te environment details (encryption, settings)\n * @returns {Boolean} true when the transport is supported\n */\n isSupported(environment: any): boolean {\n return this.hooks.isSupported(environment);\n }\n\n /** Creates a transport connection.\n *\n * @param {String} name\n * @param {Number} priority\n * @param {String} key the application key\n * @param {Object} options\n * @returns {TransportConnection}\n */\n createConnection(\n name: string,\n priority: number,\n key: string,\n options: any\n ): TransportConnection {\n return new TransportConnection(this.hooks, name, priority, key, options);\n }\n}\n","import * as URLSchemes from 'core/transports/url_schemes';\nimport URLScheme from 'core/transports/url_scheme';\nimport Transport from 'core/transports/transport';\nimport Util from 'core/util';\nimport * as Collections from 'core/utils/collections';\nimport TransportHooks from 'core/transports/transport_hooks';\nimport TransportsTable from 'core/transports/transports_table';\nimport Runtime from 'runtime';\n\n/** WebSocket transport.\n *\n * Uses native WebSocket implementation, including MozWebSocket supported by\n * earlier Firefox versions.\n */\nvar WSTransport = new Transport({\n urls: URLSchemes.ws,\n handlesActivityChecks: false,\n supportsPing: false,\n\n isInitialized: function() {\n return Boolean(Runtime.getWebSocketAPI());\n },\n isSupported: function(): boolean {\n return Boolean(Runtime.getWebSocketAPI());\n },\n getSocket: function(url) {\n return Runtime.createWebSocket(url);\n }\n});\n\nvar httpConfiguration = {\n urls: URLSchemes.http,\n handlesActivityChecks: false,\n supportsPing: true,\n isInitialized: function() {\n return true;\n }\n};\n\nexport var streamingConfiguration = Collections.extend(\n {\n getSocket: function(url) {\n return Runtime.HTTPFactory.createStreamingSocket(url);\n }\n },\n httpConfiguration\n);\nexport var pollingConfiguration = Collections.extend(\n {\n getSocket: function(url) {\n return Runtime.HTTPFactory.createPollingSocket(url);\n }\n },\n httpConfiguration\n);\n\nvar xhrConfiguration = {\n isSupported: function(): boolean {\n return Runtime.isXHRSupported();\n }\n};\n\n/** HTTP streaming transport using CORS-enabled XMLHttpRequest. */\nvar XHRStreamingTransport = new Transport(\n (\n Collections.extend({}, streamingConfiguration, xhrConfiguration)\n )\n);\n\n/** HTTP long-polling transport using CORS-enabled XMLHttpRequest. */\nvar XHRPollingTransport = new Transport(\n Collections.extend({}, pollingConfiguration, xhrConfiguration)\n);\n\nvar Transports: TransportsTable = {\n ws: WSTransport,\n xhr_streaming: XHRStreamingTransport,\n xhr_polling: XHRPollingTransport\n};\n\nexport default Transports;\n","import {\n default as Transports,\n streamingConfiguration,\n pollingConfiguration\n} from 'isomorphic/transports/transports';\nimport Transport from 'core/transports/transport';\nimport TransportHooks from 'core/transports/transport_hooks';\nimport * as URLSchemes from 'core/transports/url_schemes';\nimport Runtime from 'runtime';\nimport { Dependencies } from '../dom/dependencies';\nimport * as Collections from 'core/utils/collections';\n\nvar SockJSTransport = new Transport({\n file: 'sockjs',\n urls: URLSchemes.sockjs,\n handlesActivityChecks: true,\n supportsPing: false,\n\n isSupported: function() {\n return true;\n },\n isInitialized: function() {\n return window.SockJS !== undefined;\n },\n getSocket: function(url, options) {\n return new window.SockJS(url, null, {\n js_path: Dependencies.getPath('sockjs', {\n useTLS: options.useTLS\n }),\n ignore_null_origin: options.ignoreNullOrigin\n });\n },\n beforeOpen: function(socket, path) {\n socket.send(\n JSON.stringify({\n path: path\n })\n );\n }\n});\n\nvar xdrConfiguration = {\n isSupported: function(environment): boolean {\n var yes = Runtime.isXDRSupported(environment.useTLS);\n return yes;\n }\n};\n\n/** HTTP streaming transport using XDomainRequest (IE 8,9). */\nvar XDRStreamingTransport = new Transport(\n (\n Collections.extend({}, streamingConfiguration, xdrConfiguration)\n )\n);\n\n/** HTTP long-polling transport using XDomainRequest (IE 8,9). */\nvar XDRPollingTransport = new Transport(\n Collections.extend({}, pollingConfiguration, xdrConfiguration)\n);\n\nTransports.xdr_streaming = XDRStreamingTransport;\nTransports.xdr_polling = XDRPollingTransport;\nTransports.sockjs = SockJSTransport;\n\nexport default Transports;\n","import Reachability from 'core/reachability';\nimport { default as EventsDispatcher } from 'core/events/dispatcher';\n\n/** Really basic interface providing network availability info.\n *\n * Emits:\n * - online - when browser goes online\n * - offline - when browser goes offline\n */\nexport class NetInfo extends EventsDispatcher implements Reachability {\n constructor() {\n super();\n var self = this;\n // This is okay, as IE doesn't support this stuff anyway.\n if (window.addEventListener !== undefined) {\n window.addEventListener(\n 'online',\n function() {\n self.emit('online');\n },\n false\n );\n window.addEventListener(\n 'offline',\n function() {\n self.emit('offline');\n },\n false\n );\n }\n }\n\n /** Returns whether browser is online or not\n *\n * Offline means definitely offline (no connection to router).\n * Inverse does NOT mean definitely online (only currently supported in Safari\n * and even there only means the device has a connection to the router).\n *\n * @return {Boolean}\n */\n isOnline(): boolean {\n if (window.navigator.onLine === undefined) {\n return true;\n } else {\n return window.navigator.onLine;\n }\n }\n}\n\nexport var Network = new NetInfo();\n","import Util from '../util';\nimport * as Collections from '../utils/collections';\nimport TransportManager from './transport_manager';\nimport TransportConnection from './transport_connection';\nimport Transport from './transport';\nimport PingDelayOptions from './ping_delay_options';\n\n/** Creates transport connections monitored by a transport manager.\n *\n * When a transport is closed, it might mean the environment does not support\n * it. It's possible that messages get stuck in an intermediate buffer or\n * proxies terminate inactive connections. To combat these problems,\n * assistants monitor the connection lifetime, report unclean exits and\n * adjust ping timeouts to keep the connection active. The decision to disable\n * a transport is the manager's responsibility.\n *\n * @param {TransportManager} manager\n * @param {TransportConnection} transport\n * @param {Object} options\n */\nexport default class AssistantToTheTransportManager {\n manager: TransportManager;\n transport: Transport;\n minPingDelay: number;\n maxPingDelay: number;\n pingDelay: number;\n\n constructor(\n manager: TransportManager,\n transport: Transport,\n options: PingDelayOptions\n ) {\n this.manager = manager;\n this.transport = transport;\n this.minPingDelay = options.minPingDelay;\n this.maxPingDelay = options.maxPingDelay;\n this.pingDelay = undefined;\n }\n\n /** Creates a transport connection.\n *\n * This function has the same API as Transport#createConnection.\n *\n * @param {String} name\n * @param {Number} priority\n * @param {String} key the application key\n * @param {Object} options\n * @returns {TransportConnection}\n */\n createConnection(\n name: string,\n priority: number,\n key: string,\n options: Object\n ): TransportConnection {\n options = Collections.extend({}, options, {\n activityTimeout: this.pingDelay\n });\n var connection = this.transport.createConnection(\n name,\n priority,\n key,\n options\n );\n\n var openTimestamp = null;\n\n var onOpen = function() {\n connection.unbind('open', onOpen);\n connection.bind('closed', onClosed);\n openTimestamp = Util.now();\n };\n var onClosed = closeEvent => {\n connection.unbind('closed', onClosed);\n\n if (closeEvent.code === 1002 || closeEvent.code === 1003) {\n // we don't want to use transports not obeying the protocol\n this.manager.reportDeath();\n } else if (!closeEvent.wasClean && openTimestamp) {\n // report deaths only for short-living transport\n var lifespan = Util.now() - openTimestamp;\n if (lifespan < 2 * this.maxPingDelay) {\n this.manager.reportDeath();\n this.pingDelay = Math.max(lifespan / 2, this.minPingDelay);\n }\n }\n };\n\n connection.bind('open', onOpen);\n return connection;\n }\n\n /** Returns whether the transport is supported in the environment.\n *\n * This function has the same API as Transport#isSupported. Might return false\n * when the manager decides to kill the transport.\n *\n * @param {Object} environment the environment details (encryption, settings)\n * @returns {Boolean} true when the transport is supported\n */\n isSupported(environment: string): boolean {\n return this.manager.isAlive() && this.transport.isSupported(environment);\n }\n}\n","import Action from './action';\nimport { PusherEvent } from './message-types';\n/**\n * Provides functions for handling Pusher protocol-specific messages.\n */\n\nconst Protocol = {\n /**\n * Decodes a message in a Pusher format.\n *\n * The MessageEvent we receive from the transport should contain a pusher event\n * (https://pusher.com/docs/pusher_protocol#events) serialized as JSON in the\n * data field\n *\n * The pusher event may contain a data field too, and it may also be\n * serialised as JSON\n *\n * Throws errors when messages are not parse'able.\n *\n * @param {MessageEvent} messageEvent\n * @return {PusherEvent}\n */\n decodeMessage: function(messageEvent: MessageEvent): PusherEvent {\n try {\n var messageData = JSON.parse(messageEvent.data);\n var pusherEventData = messageData.data;\n if (typeof pusherEventData === 'string') {\n try {\n pusherEventData = JSON.parse(messageData.data);\n } catch (e) {}\n }\n var pusherEvent: PusherEvent = {\n event: messageData.event,\n channel: messageData.channel,\n data: pusherEventData\n };\n if (messageData.user_id) {\n pusherEvent.user_id = messageData.user_id;\n }\n return pusherEvent;\n } catch (e) {\n throw { type: 'MessageParseError', error: e, data: messageEvent.data };\n }\n },\n\n /**\n * Encodes a message to be sent.\n *\n * @param {PusherEvent} event\n * @return {String}\n */\n encodeMessage: function(event: PusherEvent): string {\n return JSON.stringify(event);\n },\n\n /**\n * Processes a handshake message and returns appropriate actions.\n *\n * Returns an object with an 'action' and other action-specific properties.\n *\n * There are three outcomes when calling this function. First is a successful\n * connection attempt, when pusher:connection_established is received, which\n * results in a 'connected' action with an 'id' property. When passed a\n * pusher:error event, it returns a result with action appropriate to the\n * close code and an error. Otherwise, it raises an exception.\n *\n * @param {String} message\n * @result Object\n */\n processHandshake: function(messageEvent: MessageEvent): Action {\n var message = Protocol.decodeMessage(messageEvent);\n\n if (message.event === 'pusher:connection_established') {\n if (!message.data.activity_timeout) {\n throw 'No activity timeout specified in handshake';\n }\n return {\n action: 'connected',\n id: message.data.socket_id,\n activityTimeout: message.data.activity_timeout * 1000\n };\n } else if (message.event === 'pusher:error') {\n // From protocol 6 close codes are sent only once, so this only\n // happens when connection does not support close codes\n return {\n action: this.getCloseAction(message.data),\n error: this.getCloseError(message.data)\n };\n } else {\n throw 'Invalid handshake';\n }\n },\n\n /**\n * Dispatches the close event and returns an appropriate action name.\n *\n * See:\n * 1. https://developer.mozilla.org/en-US/docs/WebSockets/WebSockets_reference/CloseEvent\n * 2. http://pusher.com/docs/pusher_protocol\n *\n * @param {CloseEvent} closeEvent\n * @return {String} close action name\n */\n getCloseAction: function(closeEvent): string {\n if (closeEvent.code < 4000) {\n // ignore 1000 CLOSE_NORMAL, 1001 CLOSE_GOING_AWAY,\n // 1005 CLOSE_NO_STATUS, 1006 CLOSE_ABNORMAL\n // ignore 1007...3999\n // handle 1002 CLOSE_PROTOCOL_ERROR, 1003 CLOSE_UNSUPPORTED,\n // 1004 CLOSE_TOO_LARGE\n if (closeEvent.code >= 1002 && closeEvent.code <= 1004) {\n return 'backoff';\n } else {\n return null;\n }\n } else if (closeEvent.code === 4000) {\n return 'tls_only';\n } else if (closeEvent.code < 4100) {\n return 'refused';\n } else if (closeEvent.code < 4200) {\n return 'backoff';\n } else if (closeEvent.code < 4300) {\n return 'retry';\n } else {\n // unknown error\n return 'refused';\n }\n },\n\n /**\n * Returns an error or null basing on the close event.\n *\n * Null is returned when connection was closed cleanly. Otherwise, an object\n * with error details is returned.\n *\n * @param {CloseEvent} closeEvent\n * @return {Object} error object\n */\n getCloseError: function(closeEvent): any {\n if (closeEvent.code !== 1000 && closeEvent.code !== 1001) {\n return {\n type: 'PusherError',\n data: {\n code: closeEvent.code,\n message: closeEvent.reason || closeEvent.message\n }\n };\n } else {\n return null;\n }\n }\n};\n\nexport default Protocol;\n","import * as Collections from '../utils/collections';\nimport { default as EventsDispatcher } from '../events/dispatcher';\nimport Protocol from './protocol/protocol';\nimport { PusherEvent } from './protocol/message-types';\nimport Logger from '../logger';\nimport TransportConnection from '../transports/transport_connection';\nimport Socket from '../socket';\n/**\n * Provides Pusher protocol interface for transports.\n *\n * Emits following events:\n * - message - on received messages\n * - ping - on ping requests\n * - pong - on pong responses\n * - error - when the transport emits an error\n * - closed - after closing the transport\n *\n * It also emits more events when connection closes with a code.\n * See Protocol.getCloseAction to get more details.\n *\n * @param {Number} id\n * @param {AbstractTransport} transport\n */\nexport default class Connection extends EventsDispatcher implements Socket {\n id: string;\n transport: TransportConnection;\n activityTimeout: number;\n\n constructor(id: string, transport: TransportConnection) {\n super();\n this.id = id;\n this.transport = transport;\n this.activityTimeout = transport.activityTimeout;\n this.bindListeners();\n }\n\n /** Returns whether used transport handles activity checks by itself\n *\n * @returns {Boolean} true if activity checks are handled by the transport\n */\n handlesActivityChecks() {\n return this.transport.handlesActivityChecks();\n }\n\n /** Sends raw data.\n *\n * @param {String} data\n */\n send(data: any): boolean {\n return this.transport.send(data);\n }\n\n /** Sends an event.\n *\n * @param {String} name\n * @param {String} data\n * @param {String} [channel]\n * @returns {Boolean} whether message was sent or not\n */\n send_event(name: string, data: any, channel?: string): boolean {\n var event: PusherEvent = { event: name, data: data };\n if (channel) {\n event.channel = channel;\n }\n Logger.debug('Event sent', event);\n return this.send(Protocol.encodeMessage(event));\n }\n\n /** Sends a ping message to the server.\n *\n * Basing on the underlying transport, it might send either transport's\n * protocol-specific ping or pusher:ping event.\n */\n ping() {\n if (this.transport.supportsPing()) {\n this.transport.ping();\n } else {\n this.send_event('pusher:ping', {});\n }\n }\n\n /** Closes the connection. */\n close() {\n this.transport.close();\n }\n\n private bindListeners() {\n var listeners = {\n message: (messageEvent: MessageEvent) => {\n var pusherEvent;\n try {\n pusherEvent = Protocol.decodeMessage(messageEvent);\n } catch (e) {\n this.emit('error', {\n type: 'MessageParseError',\n error: e,\n data: messageEvent.data\n });\n }\n\n if (pusherEvent !== undefined) {\n Logger.debug('Event recd', pusherEvent);\n\n switch (pusherEvent.event) {\n case 'pusher:error':\n this.emit('error', {\n type: 'PusherError',\n data: pusherEvent.data\n });\n break;\n case 'pusher:ping':\n this.emit('ping');\n break;\n case 'pusher:pong':\n this.emit('pong');\n break;\n }\n this.emit('message', pusherEvent);\n }\n },\n activity: () => {\n this.emit('activity');\n },\n error: error => {\n this.emit('error', error);\n },\n closed: closeEvent => {\n unbindListeners();\n\n if (closeEvent && closeEvent.code) {\n this.handleCloseEvent(closeEvent);\n }\n\n this.transport = null;\n this.emit('closed');\n }\n };\n\n var unbindListeners = () => {\n Collections.objectApply(listeners, (listener, event) => {\n this.transport.unbind(event, listener);\n });\n };\n\n Collections.objectApply(listeners, (listener, event) => {\n this.transport.bind(event, listener);\n });\n }\n\n private handleCloseEvent(closeEvent: any) {\n var action = Protocol.getCloseAction(closeEvent);\n var error = Protocol.getCloseError(closeEvent);\n if (error) {\n this.emit('error', error);\n }\n if (action) {\n this.emit(action, { action: action, error: error });\n }\n }\n}\n","import Util from '../../util';\nimport * as Collections from '../../utils/collections';\nimport Protocol from '../protocol/protocol';\nimport Connection from '../connection';\nimport TransportConnection from '../../transports/transport_connection';\nimport HandshakePayload from './handshake_payload';\n\n/**\n * Handles Pusher protocol handshakes for transports.\n *\n * Calls back with a result object after handshake is completed. Results\n * always have two fields:\n * - action - string describing action to be taken after the handshake\n * - transport - the transport object passed to the constructor\n *\n * Different actions can set different additional properties on the result.\n * In the case of 'connected' action, there will be a 'connection' property\n * containing a Connection object for the transport. Other actions should\n * carry an 'error' property.\n *\n * @param {AbstractTransport} transport\n * @param {Function} callback\n */\nexport default class Handshake {\n transport: TransportConnection;\n callback: (HandshakePayload) => void;\n onMessage: Function;\n onClosed: Function;\n\n constructor(\n transport: TransportConnection,\n callback: (HandshakePayload) => void\n ) {\n this.transport = transport;\n this.callback = callback;\n this.bindListeners();\n }\n\n close() {\n this.unbindListeners();\n this.transport.close();\n }\n\n private bindListeners() {\n this.onMessage = m => {\n this.unbindListeners();\n\n var result;\n try {\n result = Protocol.processHandshake(m);\n } catch (e) {\n this.finish('error', { error: e });\n this.transport.close();\n return;\n }\n\n if (result.action === 'connected') {\n this.finish('connected', {\n connection: new Connection(result.id, this.transport),\n activityTimeout: result.activityTimeout\n });\n } else {\n this.finish(result.action, { error: result.error });\n this.transport.close();\n }\n };\n\n this.onClosed = closeEvent => {\n this.unbindListeners();\n\n var action = Protocol.getCloseAction(closeEvent) || 'backoff';\n var error = Protocol.getCloseError(closeEvent);\n this.finish(action, { error: error });\n };\n\n this.transport.bind('message', this.onMessage);\n this.transport.bind('closed', this.onClosed);\n }\n\n private unbindListeners() {\n this.transport.unbind('message', this.onMessage);\n this.transport.unbind('closed', this.onClosed);\n }\n\n private finish(action: string, params: any) {\n this.callback(\n Collections.extend({ transport: this.transport, action: action }, params)\n );\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport base64encode from '../base64';\nimport Timeline from './timeline';\nimport Runtime from 'runtime';\n\nexport interface TimelineSenderOptions {\n host?: string;\n port?: number;\n path?: string;\n}\n\nexport default class TimelineSender {\n timeline: Timeline;\n options: TimelineSenderOptions;\n host: string;\n\n constructor(timeline: Timeline, options: TimelineSenderOptions) {\n this.timeline = timeline;\n this.options = options || {};\n }\n\n send(useTLS: boolean, callback?: Function) {\n if (this.timeline.isEmpty()) {\n return;\n }\n\n this.timeline.send(\n Runtime.TimelineTransport.getAgent(this, useTLS),\n callback\n );\n }\n}\n","import { default as EventsDispatcher } from '../events/dispatcher';\nimport * as Errors from '../errors';\nimport Logger from '../logger';\nimport Pusher from '../pusher';\nimport { PusherEvent } from '../connection/protocol/message-types';\nimport Metadata from './metadata';\nimport UrlStore from '../utils/url_store';\nimport {\n ChannelAuthorizationData,\n ChannelAuthorizationCallback\n} from '../auth/options';\nimport { HTTPAuthError } from '../errors';\n\n/** Provides base public channel interface with an event emitter.\n *\n * Emits:\n * - pusher:subscription_succeeded - after subscribing successfully\n * - other non-internal events\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\nexport default class Channel extends EventsDispatcher {\n name: string;\n pusher: Pusher;\n subscribed: boolean;\n subscriptionPending: boolean;\n subscriptionCancelled: boolean;\n subscriptionCount: null;\n\n constructor(name: string, pusher: Pusher) {\n super(function(event, data) {\n Logger.debug('No callbacks on ' + name + ' for ' + event);\n });\n\n this.name = name;\n this.pusher = pusher;\n this.subscribed = false;\n this.subscriptionPending = false;\n this.subscriptionCancelled = false;\n }\n\n /** Skips authorization, since public channels don't require it.\n *\n * @param {Function} callback\n */\n authorize(socketId: string, callback: ChannelAuthorizationCallback) {\n return callback(null, { auth: '' });\n }\n\n /** Triggers an event */\n trigger(event: string, data: any) {\n if (event.indexOf('client-') !== 0) {\n throw new Errors.BadEventName(\n \"Event '\" + event + \"' does not start with 'client-'\"\n );\n }\n if (!this.subscribed) {\n var suffix = UrlStore.buildLogSuffix('triggeringClientEvents');\n Logger.warn(\n `Client event triggered before channel 'subscription_succeeded' event . ${suffix}`\n );\n }\n return this.pusher.send_event(event, data, this.name);\n }\n\n /** Signals disconnection to the channel. For internal use only. */\n disconnect() {\n this.subscribed = false;\n this.subscriptionPending = false;\n }\n\n /** Handles a PusherEvent. For internal use only.\n *\n * @param {PusherEvent} event\n */\n handleEvent(event: PusherEvent) {\n var eventName = event.event;\n var data = event.data;\n if (eventName === 'pusher_internal:subscription_succeeded') {\n this.handleSubscriptionSucceededEvent(event);\n } else if (eventName === 'pusher_internal:subscription_count') {\n this.handleSubscriptionCountEvent(event);\n } else if (eventName.indexOf('pusher_internal:') !== 0) {\n var metadata: Metadata = {};\n this.emit(eventName, data, metadata);\n }\n }\n\n handleSubscriptionSucceededEvent(event: PusherEvent) {\n this.subscriptionPending = false;\n this.subscribed = true;\n if (this.subscriptionCancelled) {\n this.pusher.unsubscribe(this.name);\n } else {\n this.emit('pusher:subscription_succeeded', event.data);\n }\n }\n\n handleSubscriptionCountEvent(event: PusherEvent) {\n if (event.data.subscription_count) {\n this.subscriptionCount = event.data.subscription_count;\n }\n\n this.emit('pusher:subscription_count', event.data);\n }\n\n /** Sends a subscription request. For internal use only. */\n subscribe() {\n if (this.subscribed) {\n return;\n }\n this.subscriptionPending = true;\n this.subscriptionCancelled = false;\n this.authorize(\n this.pusher.connection.socket_id,\n (error: Error | null, data: ChannelAuthorizationData) => {\n if (error) {\n this.subscriptionPending = false;\n // Why not bind to 'pusher:subscription_error' a level up, and log there?\n // Binding to this event would cause the warning about no callbacks being\n // bound (see constructor) to be suppressed, that's not what we want.\n Logger.error(error.toString());\n this.emit(\n 'pusher:subscription_error',\n Object.assign(\n {},\n {\n type: 'AuthError',\n error: error.message\n },\n error instanceof HTTPAuthError ? { status: error.status } : {}\n )\n );\n } else {\n this.pusher.send_event('pusher:subscribe', {\n auth: data.auth,\n channel_data: data.channel_data,\n channel: this.name\n });\n }\n }\n );\n }\n\n /** Sends an unsubscription request. For internal use only. */\n unsubscribe() {\n this.subscribed = false;\n this.pusher.send_event('pusher:unsubscribe', {\n channel: this.name\n });\n }\n\n /** Cancels an in progress subscription. For internal use only. */\n cancelSubscription() {\n this.subscriptionCancelled = true;\n }\n\n /** Reinstates an in progress subscripiton. For internal use only. */\n reinstateSubscription() {\n this.subscriptionCancelled = false;\n }\n}\n","import Factory from '../utils/factory';\nimport Channel from './channel';\nimport { ChannelAuthorizationCallback } from '../auth/options';\n\n/** Extends public channels to provide private channel interface.\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\nexport default class PrivateChannel extends Channel {\n /** Authorizes the connection to use the channel.\n *\n * @param {String} socketId\n * @param {Function} callback\n */\n authorize(socketId: string, callback: ChannelAuthorizationCallback) {\n return this.pusher.config.channelAuthorizer(\n {\n channelName: this.name,\n socketId: socketId\n },\n callback\n );\n }\n}\n","import * as Collections from '../utils/collections';\n\n/** Represents a collection of members of a presence channel. */\nexport default class Members {\n members: any;\n count: number;\n myID: any;\n me: any;\n\n constructor() {\n this.reset();\n }\n\n /** Returns member's info for given id.\n *\n * Resulting object containts two fields - id and info.\n *\n * @param {Number} id\n * @return {Object} member's info or null\n */\n get(id: string): any {\n if (Object.prototype.hasOwnProperty.call(this.members, id)) {\n return {\n id: id,\n info: this.members[id]\n };\n } else {\n return null;\n }\n }\n\n /** Calls back for each member in unspecified order.\n *\n * @param {Function} callback\n */\n each(callback: Function) {\n Collections.objectApply(this.members, (member, id) => {\n callback(this.get(id));\n });\n }\n\n /** Updates the id for connected member. For internal use only. */\n setMyID(id: string) {\n this.myID = id;\n }\n\n /** Handles subscription data. For internal use only. */\n onSubscription(subscriptionData: any) {\n this.members = subscriptionData.presence.hash;\n this.count = subscriptionData.presence.count;\n this.me = this.get(this.myID);\n }\n\n /** Adds a new member to the collection. For internal use only. */\n addMember(memberData: any) {\n if (this.get(memberData.user_id) === null) {\n this.count++;\n }\n this.members[memberData.user_id] = memberData.user_info;\n return this.get(memberData.user_id);\n }\n\n /** Adds a member from the collection. For internal use only. */\n removeMember(memberData: any) {\n var member = this.get(memberData.user_id);\n if (member) {\n delete this.members[memberData.user_id];\n this.count--;\n }\n return member;\n }\n\n /** Resets the collection to the initial state. For internal use only. */\n reset() {\n this.members = {};\n this.count = 0;\n this.myID = null;\n this.me = null;\n }\n}\n","import PrivateChannel from './private_channel';\nimport Logger from '../logger';\nimport Members from './members';\nimport Pusher from '../pusher';\nimport UrlStore from 'core/utils/url_store';\nimport { PusherEvent } from '../connection/protocol/message-types';\nimport Metadata from './metadata';\nimport { ChannelAuthorizationData } from '../auth/options';\n\nexport default class PresenceChannel extends PrivateChannel {\n members: Members;\n\n /** Adds presence channel functionality to private channels.\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\n constructor(name: string, pusher: Pusher) {\n super(name, pusher);\n this.members = new Members();\n }\n\n /** Authorizes the connection as a member of the channel.\n *\n * @param {String} socketId\n * @param {Function} callback\n */\n authorize(socketId: string, callback: Function) {\n super.authorize(socketId, async (error, authData) => {\n if (!error) {\n authData = authData as ChannelAuthorizationData;\n if (authData.channel_data != null) {\n var channelData = JSON.parse(authData.channel_data);\n this.members.setMyID(channelData.user_id);\n } else {\n await this.pusher.user.signinDonePromise;\n if (this.pusher.user.user_data != null) {\n // If the user is signed in, get the id of the authenticated user\n // and allow the presence authorization to continue.\n this.members.setMyID(this.pusher.user.user_data.id);\n } else {\n let suffix = UrlStore.buildLogSuffix('authorizationEndpoint');\n Logger.error(\n `Invalid auth response for channel '${this.name}', ` +\n `expected 'channel_data' field. ${suffix}, ` +\n `or the user should be signed in.`\n );\n callback('Invalid auth response');\n return;\n }\n }\n }\n callback(error, authData);\n });\n }\n\n /** Handles presence and subscription events. For internal use only.\n *\n * @param {PusherEvent} event\n */\n handleEvent(event: PusherEvent) {\n var eventName = event.event;\n if (eventName.indexOf('pusher_internal:') === 0) {\n this.handleInternalEvent(event);\n } else {\n var data = event.data;\n var metadata: Metadata = {};\n if (event.user_id) {\n metadata.user_id = event.user_id;\n }\n this.emit(eventName, data, metadata);\n }\n }\n handleInternalEvent(event: PusherEvent) {\n var eventName = event.event;\n var data = event.data;\n switch (eventName) {\n case 'pusher_internal:subscription_succeeded':\n this.handleSubscriptionSucceededEvent(event);\n break;\n case 'pusher_internal:subscription_count':\n this.handleSubscriptionCountEvent(event);\n break;\n case 'pusher_internal:member_added':\n var addedMember = this.members.addMember(data);\n this.emit('pusher:member_added', addedMember);\n break;\n case 'pusher_internal:member_removed':\n var removedMember = this.members.removeMember(data);\n if (removedMember) {\n this.emit('pusher:member_removed', removedMember);\n }\n break;\n }\n }\n\n handleSubscriptionSucceededEvent(event: PusherEvent) {\n this.subscriptionPending = false;\n this.subscribed = true;\n if (this.subscriptionCancelled) {\n this.pusher.unsubscribe(this.name);\n } else {\n this.members.onSubscription(event.data);\n this.emit('pusher:subscription_succeeded', this.members);\n }\n }\n\n /** Resets the channel state, including members map. For internal use only. */\n disconnect() {\n this.members.reset();\n super.disconnect();\n }\n}\n","import PrivateChannel from './private_channel';\nimport * as Errors from '../errors';\nimport Logger from '../logger';\nimport Pusher from '../pusher';\nimport { decode as encodeUTF8 } from '@stablelib/utf8';\nimport { decode as decodeBase64 } from '@stablelib/base64';\nimport Dispatcher from '../events/dispatcher';\nimport { PusherEvent } from '../connection/protocol/message-types';\nimport {\n ChannelAuthorizationData,\n ChannelAuthorizationCallback\n} from '../auth/options';\nimport * as nacl from 'tweetnacl';\n\n/** Extends private channels to provide encrypted channel interface.\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\nexport default class EncryptedChannel extends PrivateChannel {\n key: Uint8Array = null;\n nacl: nacl;\n\n constructor(name: string, pusher: Pusher, nacl: nacl) {\n super(name, pusher);\n this.nacl = nacl;\n }\n\n /** Authorizes the connection to use the channel.\n *\n * @param {String} socketId\n * @param {Function} callback\n */\n authorize(socketId: string, callback: ChannelAuthorizationCallback) {\n super.authorize(\n socketId,\n (error: Error | null, authData: ChannelAuthorizationData) => {\n if (error) {\n callback(error, authData);\n return;\n }\n let sharedSecret = authData['shared_secret'];\n if (!sharedSecret) {\n callback(\n new Error(\n `No shared_secret key in auth payload for encrypted channel: ${this.name}`\n ),\n null\n );\n return;\n }\n this.key = decodeBase64(sharedSecret);\n delete authData['shared_secret'];\n callback(null, authData);\n }\n );\n }\n\n trigger(event: string, data: any): boolean {\n throw new Errors.UnsupportedFeature(\n 'Client events are not currently supported for encrypted channels'\n );\n }\n\n /** Handles an event. For internal use only.\n *\n * @param {PusherEvent} event\n */\n handleEvent(event: PusherEvent) {\n var eventName = event.event;\n var data = event.data;\n if (\n eventName.indexOf('pusher_internal:') === 0 ||\n eventName.indexOf('pusher:') === 0\n ) {\n super.handleEvent(event);\n return;\n }\n this.handleEncryptedEvent(eventName, data);\n }\n\n private handleEncryptedEvent(event: string, data: any): void {\n if (!this.key) {\n Logger.debug(\n 'Received encrypted event before key has been retrieved from the authEndpoint'\n );\n return;\n }\n if (!data.ciphertext || !data.nonce) {\n Logger.error(\n 'Unexpected format for encrypted event, expected object with `ciphertext` and `nonce` fields, got: ' +\n data\n );\n return;\n }\n let cipherText = decodeBase64(data.ciphertext);\n if (cipherText.length < this.nacl.secretbox.overheadLength) {\n Logger.error(\n `Expected encrypted event ciphertext length to be ${this.nacl.secretbox.overheadLength}, got: ${cipherText.length}`\n );\n return;\n }\n let nonce = decodeBase64(data.nonce);\n if (nonce.length < this.nacl.secretbox.nonceLength) {\n Logger.error(\n `Expected encrypted event nonce length to be ${this.nacl.secretbox.nonceLength}, got: ${nonce.length}`\n );\n return;\n }\n\n let bytes = this.nacl.secretbox.open(cipherText, nonce, this.key);\n if (bytes === null) {\n Logger.debug(\n 'Failed to decrypt an event, probably because it was encrypted with a different key. Fetching a new key from the authEndpoint...'\n );\n // Try a single time to retrieve a new auth key and decrypt the event with it\n // If this fails, a new key will be requested when a new message is received\n this.authorize(this.pusher.connection.socket_id, (error, authData) => {\n if (error) {\n Logger.error(\n `Failed to make a request to the authEndpoint: ${authData}. Unable to fetch new key, so dropping encrypted event`\n );\n return;\n }\n bytes = this.nacl.secretbox.open(cipherText, nonce, this.key);\n if (bytes === null) {\n Logger.error(\n `Failed to decrypt event with new key. Dropping encrypted event`\n );\n return;\n }\n this.emit(event, this.getDataToEmit(bytes));\n return;\n });\n return;\n }\n this.emit(event, this.getDataToEmit(bytes));\n }\n\n // Try and parse the decrypted bytes as JSON. If we can't parse it, just\n // return the utf-8 string\n getDataToEmit(bytes: Uint8Array): string {\n let raw = encodeUTF8(bytes);\n try {\n return JSON.parse(raw);\n } catch {\n return raw;\n }\n }\n}\n","import { default as EventsDispatcher } from '../events/dispatcher';\nimport { OneOffTimer as Timer } from '../utils/timers';\nimport { Config } from '../config';\nimport Logger from '../logger';\nimport HandshakePayload from './handshake/handshake_payload';\nimport Connection from './connection';\nimport Strategy from '../strategies/strategy';\nimport StrategyRunner from '../strategies/strategy_runner';\nimport * as Collections from '../utils/collections';\nimport Timeline from '../timeline/timeline';\nimport ConnectionManagerOptions from './connection_manager_options';\nimport Runtime from 'runtime';\n\nimport {\n ErrorCallbacks,\n HandshakeCallbacks,\n ConnectionCallbacks\n} from './callbacks';\nimport Action from './protocol/action';\n\n/** Manages connection to Pusher.\n *\n * Uses a strategy (currently only default), timers and network availability\n * info to establish a connection and export its state. In case of failures,\n * manages reconnection attempts.\n *\n * Exports state changes as following events:\n * - \"state_change\", { previous: p, current: state }\n * - state\n *\n * States:\n * - initialized - initial state, never transitioned to\n * - connecting - connection is being established\n * - connected - connection has been fully established\n * - disconnected - on requested disconnection\n * - unavailable - after connection timeout or when there's no network\n * - failed - when the connection strategy is not supported\n *\n * Options:\n * - unavailableTimeout - time to transition to unavailable state\n * - activityTimeout - time after which ping message should be sent\n * - pongTimeout - time for Pusher to respond with pong before reconnecting\n *\n * @param {String} key application key\n * @param {Object} options\n */\nexport default class ConnectionManager extends EventsDispatcher {\n key: string;\n options: ConnectionManagerOptions;\n state: string;\n connection: Connection;\n usingTLS: boolean;\n timeline: Timeline;\n socket_id: string;\n unavailableTimer: Timer;\n activityTimer: Timer;\n retryTimer: Timer;\n activityTimeout: number;\n strategy: Strategy;\n runner: StrategyRunner;\n errorCallbacks: ErrorCallbacks;\n handshakeCallbacks: HandshakeCallbacks;\n connectionCallbacks: ConnectionCallbacks;\n\n constructor(key: string, options: ConnectionManagerOptions) {\n super();\n this.state = 'initialized';\n this.connection = null;\n\n this.key = key;\n this.options = options;\n this.timeline = this.options.timeline;\n this.usingTLS = this.options.useTLS;\n\n this.errorCallbacks = this.buildErrorCallbacks();\n this.connectionCallbacks = this.buildConnectionCallbacks(\n this.errorCallbacks\n );\n this.handshakeCallbacks = this.buildHandshakeCallbacks(this.errorCallbacks);\n\n var Network = Runtime.getNetwork();\n\n Network.bind('online', () => {\n this.timeline.info({ netinfo: 'online' });\n if (this.state === 'connecting' || this.state === 'unavailable') {\n this.retryIn(0);\n }\n });\n Network.bind('offline', () => {\n this.timeline.info({ netinfo: 'offline' });\n if (this.connection) {\n this.sendActivityCheck();\n }\n });\n\n this.updateStrategy();\n }\n\n switchCluster(key: string) {\n this.key = key;\n // This ensures that the new config coming from\n // pusher instance are taken into account\n // such as appKey and cluster\n this.updateStrategy();\n this.retryIn(0);\n }\n\n /** Establishes a connection to Pusher.\n *\n * Does nothing when connection is already established. See top-level doc\n * to find events emitted on connection attempts.\n */\n connect() {\n if (this.connection || this.runner) {\n return;\n }\n if (!this.strategy.isSupported()) {\n this.updateState('failed');\n return;\n }\n this.updateState('connecting');\n this.startConnecting();\n this.setUnavailableTimer();\n }\n\n /** Sends raw data.\n *\n * @param {String} data\n */\n send(data) {\n if (this.connection) {\n return this.connection.send(data);\n } else {\n return false;\n }\n }\n\n /** Sends an event.\n *\n * @param {String} name\n * @param {String} data\n * @param {String} [channel]\n * @returns {Boolean} whether message was sent or not\n */\n send_event(name: string, data: any, channel?: string) {\n if (this.connection) {\n return this.connection.send_event(name, data, channel);\n } else {\n return false;\n }\n }\n\n /** Closes the connection. */\n disconnect() {\n this.disconnectInternally();\n this.updateState('disconnected');\n }\n\n isUsingTLS() {\n return this.usingTLS;\n }\n\n private startConnecting() {\n var callback = (error, handshake) => {\n if (error) {\n this.runner = this.strategy.connect(0, callback);\n } else {\n if (handshake.action === 'error') {\n this.emit('error', {\n type: 'HandshakeError',\n error: handshake.error\n });\n this.timeline.error({ handshakeError: handshake.error });\n } else {\n this.abortConnecting(); // we don't support switching connections yet\n this.handshakeCallbacks[handshake.action](handshake);\n }\n }\n };\n this.runner = this.strategy.connect(0, callback);\n }\n\n private abortConnecting() {\n if (this.runner) {\n this.runner.abort();\n this.runner = null;\n }\n }\n\n private disconnectInternally() {\n this.abortConnecting();\n this.clearRetryTimer();\n this.clearUnavailableTimer();\n if (this.connection) {\n var connection = this.abandonConnection();\n connection.close();\n }\n }\n\n private updateStrategy() {\n this.strategy = this.options.getStrategy({\n key: this.key,\n timeline: this.timeline,\n useTLS: this.usingTLS\n });\n }\n\n private retryIn(delay) {\n this.timeline.info({ action: 'retry', delay: delay });\n if (delay > 0) {\n this.emit('connecting_in', Math.round(delay / 1000));\n }\n this.retryTimer = new Timer(delay || 0, () => {\n this.disconnectInternally();\n this.connect();\n });\n }\n\n private clearRetryTimer() {\n if (this.retryTimer) {\n this.retryTimer.ensureAborted();\n this.retryTimer = null;\n }\n }\n\n private setUnavailableTimer() {\n this.unavailableTimer = new Timer(this.options.unavailableTimeout, () => {\n this.updateState('unavailable');\n });\n }\n\n private clearUnavailableTimer() {\n if (this.unavailableTimer) {\n this.unavailableTimer.ensureAborted();\n }\n }\n\n private sendActivityCheck() {\n this.stopActivityCheck();\n this.connection.ping();\n // wait for pong response\n this.activityTimer = new Timer(this.options.pongTimeout, () => {\n this.timeline.error({ pong_timed_out: this.options.pongTimeout });\n this.retryIn(0);\n });\n }\n\n private resetActivityCheck() {\n this.stopActivityCheck();\n // send ping after inactivity\n if (this.connection && !this.connection.handlesActivityChecks()) {\n this.activityTimer = new Timer(this.activityTimeout, () => {\n this.sendActivityCheck();\n });\n }\n }\n\n private stopActivityCheck() {\n if (this.activityTimer) {\n this.activityTimer.ensureAborted();\n }\n }\n\n private buildConnectionCallbacks(\n errorCallbacks: ErrorCallbacks\n ): ConnectionCallbacks {\n return Collections.extend({}, errorCallbacks, {\n message: message => {\n // includes pong messages from server\n this.resetActivityCheck();\n this.emit('message', message);\n },\n ping: () => {\n this.send_event('pusher:pong', {});\n },\n activity: () => {\n this.resetActivityCheck();\n },\n error: error => {\n // just emit error to user - socket will already be closed by browser\n this.emit('error', error);\n },\n closed: () => {\n this.abandonConnection();\n if (this.shouldRetry()) {\n this.retryIn(1000);\n }\n }\n });\n }\n\n private buildHandshakeCallbacks(\n errorCallbacks: ErrorCallbacks\n ): HandshakeCallbacks {\n return Collections.extend({}, errorCallbacks, {\n connected: (handshake: HandshakePayload) => {\n this.activityTimeout = Math.min(\n this.options.activityTimeout,\n handshake.activityTimeout,\n handshake.connection.activityTimeout || Infinity\n );\n this.clearUnavailableTimer();\n this.setConnection(handshake.connection);\n this.socket_id = this.connection.id;\n this.updateState('connected', { socket_id: this.socket_id });\n }\n });\n }\n\n private buildErrorCallbacks(): ErrorCallbacks {\n let withErrorEmitted = callback => {\n return (result: Action | HandshakePayload) => {\n if (result.error) {\n this.emit('error', { type: 'WebSocketError', error: result.error });\n }\n callback(result);\n };\n };\n\n return {\n tls_only: withErrorEmitted(() => {\n this.usingTLS = true;\n this.updateStrategy();\n this.retryIn(0);\n }),\n refused: withErrorEmitted(() => {\n this.disconnect();\n }),\n backoff: withErrorEmitted(() => {\n this.retryIn(1000);\n }),\n retry: withErrorEmitted(() => {\n this.retryIn(0);\n })\n };\n }\n\n private setConnection(connection) {\n this.connection = connection;\n for (var event in this.connectionCallbacks) {\n this.connection.bind(event, this.connectionCallbacks[event]);\n }\n this.resetActivityCheck();\n }\n\n private abandonConnection() {\n if (!this.connection) {\n return;\n }\n this.stopActivityCheck();\n for (var event in this.connectionCallbacks) {\n this.connection.unbind(event, this.connectionCallbacks[event]);\n }\n var connection = this.connection;\n this.connection = null;\n return connection;\n }\n\n private updateState(newState: string, data?: any) {\n var previousState = this.state;\n this.state = newState;\n if (previousState !== newState) {\n var newStateDescription = newState;\n if (newStateDescription === 'connected') {\n newStateDescription += ' with new socket ID ' + data.socket_id;\n }\n Logger.debug(\n 'State changed',\n previousState + ' -> ' + newStateDescription\n );\n this.timeline.info({ state: newState, params: data });\n this.emit('state_change', { previous: previousState, current: newState });\n this.emit(newState, data);\n }\n }\n\n private shouldRetry(): boolean {\n return this.state === 'connecting' || this.state === 'connected';\n }\n}\n","import Channel from './channel';\nimport * as Collections from '../utils/collections';\nimport ChannelTable from './channel_table';\nimport Factory from '../utils/factory';\nimport Pusher from '../pusher';\nimport Logger from '../logger';\nimport * as Errors from '../errors';\nimport urlStore from '../utils/url_store';\n\n/** Handles a channel map. */\nexport default class Channels {\n channels: ChannelTable;\n\n constructor() {\n this.channels = {};\n }\n\n /** Creates or retrieves an existing channel by its name.\n *\n * @param {String} name\n * @param {Pusher} pusher\n * @return {Channel}\n */\n add(name: string, pusher: Pusher) {\n if (!this.channels[name]) {\n this.channels[name] = createChannel(name, pusher);\n }\n return this.channels[name];\n }\n\n /** Returns a list of all channels\n *\n * @return {Array}\n */\n all(): Channel[] {\n return Collections.values(this.channels);\n }\n\n /** Finds a channel by its name.\n *\n * @param {String} name\n * @return {Channel} channel or null if it doesn't exist\n */\n find(name: string) {\n return this.channels[name];\n }\n\n /** Removes a channel from the map.\n *\n * @param {String} name\n */\n remove(name: string) {\n var channel = this.channels[name];\n delete this.channels[name];\n return channel;\n }\n\n /** Proxies disconnection signal to all channels. */\n disconnect() {\n Collections.objectApply(this.channels, function(channel) {\n channel.disconnect();\n });\n }\n}\n\nfunction createChannel(name: string, pusher: Pusher): Channel {\n if (name.indexOf('private-encrypted-') === 0) {\n if (pusher.config.nacl) {\n return Factory.createEncryptedChannel(name, pusher, pusher.config.nacl);\n }\n let errMsg =\n 'Tried to subscribe to a private-encrypted- channel but no nacl implementation available';\n let suffix = urlStore.buildLogSuffix('encryptedChannelSupport');\n throw new Errors.UnsupportedFeature(`${errMsg}. ${suffix}`);\n } else if (name.indexOf('private-') === 0) {\n return Factory.createPrivateChannel(name, pusher);\n } else if (name.indexOf('presence-') === 0) {\n return Factory.createPresenceChannel(name, pusher);\n } else if (name.indexOf('#') === 0) {\n throw new Errors.BadChannelName(\n 'Cannot create a channel with name \"' + name + '\".'\n );\n } else {\n return Factory.createChannel(name, pusher);\n }\n}\n","import AssistantToTheTransportManager from '../transports/assistant_to_the_transport_manager';\nimport PingDelayOptions from '../transports/ping_delay_options';\nimport Transport from '../transports/transport';\nimport TransportManager from '../transports/transport_manager';\nimport Handshake from '../connection/handshake';\nimport TransportConnection from '../transports/transport_connection';\nimport SocketHooks from '../http/socket_hooks';\nimport HTTPSocket from '../http/http_socket';\n\nimport Timeline from '../timeline/timeline';\nimport {\n default as TimelineSender,\n TimelineSenderOptions\n} from '../timeline/timeline_sender';\nimport PresenceChannel from '../channels/presence_channel';\nimport PrivateChannel from '../channels/private_channel';\nimport EncryptedChannel from '../channels/encrypted_channel';\nimport Channel from '../channels/channel';\nimport ConnectionManager from '../connection/connection_manager';\nimport ConnectionManagerOptions from '../connection/connection_manager_options';\nimport Ajax from '../http/ajax';\nimport Channels from '../channels/channels';\nimport Pusher from '../pusher';\nimport { Config } from '../config';\nimport * as nacl from 'tweetnacl';\n\nvar Factory = {\n createChannels(): Channels {\n return new Channels();\n },\n\n createConnectionManager(\n key: string,\n options: ConnectionManagerOptions\n ): ConnectionManager {\n return new ConnectionManager(key, options);\n },\n\n createChannel(name: string, pusher: Pusher): Channel {\n return new Channel(name, pusher);\n },\n\n createPrivateChannel(name: string, pusher: Pusher): PrivateChannel {\n return new PrivateChannel(name, pusher);\n },\n\n createPresenceChannel(name: string, pusher: Pusher): PresenceChannel {\n return new PresenceChannel(name, pusher);\n },\n\n createEncryptedChannel(\n name: string,\n pusher: Pusher,\n nacl: nacl\n ): EncryptedChannel {\n return new EncryptedChannel(name, pusher, nacl);\n },\n\n createTimelineSender(timeline: Timeline, options: TimelineSenderOptions) {\n return new TimelineSender(timeline, options);\n },\n\n createHandshake(\n transport: TransportConnection,\n callback: (HandshakePayload) => void\n ): Handshake {\n return new Handshake(transport, callback);\n },\n\n createAssistantToTheTransportManager(\n manager: TransportManager,\n transport: Transport,\n options: PingDelayOptions\n ): AssistantToTheTransportManager {\n return new AssistantToTheTransportManager(manager, transport, options);\n }\n};\n\nexport default Factory;\n","import AssistantToTheTransportManager from './assistant_to_the_transport_manager';\nimport Transport from './transport';\nimport PingDelayOptions from './ping_delay_options';\nimport Factory from '../utils/factory';\n\nexport interface TransportManagerOptions extends PingDelayOptions {\n lives?: number;\n}\n\n/** Keeps track of the number of lives left for a transport.\n *\n * In the beginning of a session, transports may be assigned a number of\n * lives. When an AssistantToTheTransportManager instance reports a transport\n * connection closed uncleanly, the transport loses a life. When the number\n * of lives drops to zero, the transport gets disabled by its manager.\n *\n * @param {Object} options\n */\nexport default class TransportManager {\n options: TransportManagerOptions;\n livesLeft: number;\n\n constructor(options: TransportManagerOptions) {\n this.options = options || {};\n this.livesLeft = this.options.lives || Infinity;\n }\n\n /** Creates a assistant for the transport.\n *\n * @param {Transport} transport\n * @returns {AssistantToTheTransportManager}\n */\n getAssistant(transport: Transport): AssistantToTheTransportManager {\n return Factory.createAssistantToTheTransportManager(this, transport, {\n minPingDelay: this.options.minPingDelay,\n maxPingDelay: this.options.maxPingDelay\n });\n }\n\n /** Returns whether the transport has any lives left.\n *\n * @returns {Boolean}\n */\n isAlive(): boolean {\n return this.livesLeft > 0;\n }\n\n /** Takes one life from the transport. */\n reportDeath() {\n this.livesLeft -= 1;\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport { OneOffTimer as Timer } from '../utils/timers';\nimport Strategy from './strategy';\nimport StrategyOptions from './strategy_options';\n\n/** Loops through strategies with optional timeouts.\n *\n * Options:\n * - loop - whether it should loop through the substrategy list\n * - timeout - initial timeout for a single substrategy\n * - timeoutLimit - maximum timeout\n *\n * @param {Strategy[]} strategies\n * @param {Object} options\n */\nexport default class SequentialStrategy implements Strategy {\n strategies: Strategy[];\n loop: boolean;\n failFast: boolean;\n timeout: number;\n timeoutLimit: number;\n\n constructor(strategies: Strategy[], options: StrategyOptions) {\n this.strategies = strategies;\n this.loop = Boolean(options.loop);\n this.failFast = Boolean(options.failFast);\n this.timeout = options.timeout;\n this.timeoutLimit = options.timeoutLimit;\n }\n\n isSupported(): boolean {\n return Collections.any(this.strategies, Util.method('isSupported'));\n }\n\n connect(minPriority: number, callback: Function) {\n var strategies = this.strategies;\n var current = 0;\n var timeout = this.timeout;\n var runner = null;\n\n var tryNextStrategy = (error, handshake) => {\n if (handshake) {\n callback(null, handshake);\n } else {\n current = current + 1;\n if (this.loop) {\n current = current % strategies.length;\n }\n\n if (current < strategies.length) {\n if (timeout) {\n timeout = timeout * 2;\n if (this.timeoutLimit) {\n timeout = Math.min(timeout, this.timeoutLimit);\n }\n }\n runner = this.tryStrategy(\n strategies[current],\n minPriority,\n { timeout, failFast: this.failFast },\n tryNextStrategy\n );\n } else {\n callback(true);\n }\n }\n };\n\n runner = this.tryStrategy(\n strategies[current],\n minPriority,\n { timeout: timeout, failFast: this.failFast },\n tryNextStrategy\n );\n\n return {\n abort: function() {\n runner.abort();\n },\n forceMinPriority: function(p) {\n minPriority = p;\n if (runner) {\n runner.forceMinPriority(p);\n }\n }\n };\n }\n\n private tryStrategy(\n strategy: Strategy,\n minPriority: number,\n options: StrategyOptions,\n callback: Function\n ) {\n var timer = null;\n var runner = null;\n\n if (options.timeout > 0) {\n timer = new Timer(options.timeout, function() {\n runner.abort();\n callback(true);\n });\n }\n\n runner = strategy.connect(minPriority, function(error, handshake) {\n if (error && timer && timer.isRunning() && !options.failFast) {\n // advance to the next strategy after the timeout\n return;\n }\n if (timer) {\n timer.ensureAborted();\n }\n callback(error, handshake);\n });\n\n return {\n abort: function() {\n if (timer) {\n timer.ensureAborted();\n }\n runner.abort();\n },\n forceMinPriority: function(p) {\n runner.forceMinPriority(p);\n }\n };\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport Strategy from './strategy';\n\n/** Launches all substrategies and emits prioritized connected transports.\n *\n * @param {Array} strategies\n */\nexport default class BestConnectedEverStrategy implements Strategy {\n strategies: Strategy[];\n\n constructor(strategies: Strategy[]) {\n this.strategies = strategies;\n }\n\n isSupported(): boolean {\n return Collections.any(this.strategies, Util.method('isSupported'));\n }\n\n connect(minPriority: number, callback: Function) {\n return connect(this.strategies, minPriority, function(i, runners) {\n return function(error, handshake) {\n runners[i].error = error;\n if (error) {\n if (allRunnersFailed(runners)) {\n callback(true);\n }\n return;\n }\n Collections.apply(runners, function(runner) {\n runner.forceMinPriority(handshake.transport.priority);\n });\n callback(null, handshake);\n };\n });\n }\n}\n\n/** Connects to all strategies in parallel.\n *\n * Callback builder should be a function that takes two arguments: index\n * and a list of runners. It should return another function that will be\n * passed to the substrategy with given index. Runners can be aborted using\n * abortRunner(s) functions from this class.\n *\n * @param {Array} strategies\n * @param {Function} callbackBuilder\n * @return {Object} strategy runner\n */\nfunction connect(\n strategies: Strategy[],\n minPriority: number,\n callbackBuilder: Function\n) {\n var runners = Collections.map(strategies, function(strategy, i, _, rs) {\n return strategy.connect(minPriority, callbackBuilder(i, rs));\n });\n return {\n abort: function() {\n Collections.apply(runners, abortRunner);\n },\n forceMinPriority: function(p) {\n Collections.apply(runners, function(runner) {\n runner.forceMinPriority(p);\n });\n }\n };\n}\n\nfunction allRunnersFailed(runners): boolean {\n return Collections.all(runners, function(runner) {\n return Boolean(runner.error);\n });\n}\n\nfunction abortRunner(runner) {\n if (!runner.error && !runner.aborted) {\n runner.abort();\n runner.aborted = true;\n }\n}\n","import Util from '../util';\nimport Runtime from 'runtime';\nimport Strategy from './strategy';\nimport SequentialStrategy from './sequential_strategy';\nimport StrategyOptions from './strategy_options';\nimport TransportStrategy from './transport_strategy';\nimport Timeline from '../timeline/timeline';\nimport * as Collections from '../utils/collections';\n\nexport interface TransportStrategyDictionary {\n [key: string]: TransportStrategy;\n}\n\n/** Caches the last successful transport and, after the first few attempts,\n * uses the cached transport for subsequent attempts.\n *\n * @param {Strategy} strategy\n * @param {Object} transports\n * @param {Object} options\n */\nexport default class WebSocketPrioritizedCachedStrategy implements Strategy {\n strategy: Strategy;\n transports: TransportStrategyDictionary;\n ttl: number;\n usingTLS: boolean;\n timeline: Timeline;\n\n constructor(\n strategy: Strategy,\n transports: TransportStrategyDictionary,\n options: StrategyOptions\n ) {\n this.strategy = strategy;\n this.transports = transports;\n this.ttl = options.ttl || 1800 * 1000;\n this.usingTLS = options.useTLS;\n this.timeline = options.timeline;\n }\n\n isSupported(): boolean {\n return this.strategy.isSupported();\n }\n\n connect(minPriority: number, callback: Function) {\n var usingTLS = this.usingTLS;\n var info = fetchTransportCache(usingTLS);\n var cacheSkipCount = info && info.cacheSkipCount ? info.cacheSkipCount : 0;\n\n var strategies = [this.strategy];\n if (info && info.timestamp + this.ttl >= Util.now()) {\n var transport = this.transports[info.transport];\n if (transport) {\n if (['ws', 'wss'].includes(info.transport) || cacheSkipCount > 3) {\n this.timeline.info({\n cached: true,\n transport: info.transport,\n latency: info.latency\n });\n strategies.push(\n new SequentialStrategy([transport], {\n timeout: info.latency * 2 + 1000,\n failFast: true\n })\n );\n } else {\n cacheSkipCount++;\n }\n }\n }\n\n var startTimestamp = Util.now();\n var runner = strategies\n .pop()\n .connect(minPriority, function cb(error, handshake) {\n if (error) {\n flushTransportCache(usingTLS);\n if (strategies.length > 0) {\n startTimestamp = Util.now();\n runner = strategies.pop().connect(minPriority, cb);\n } else {\n callback(error);\n }\n } else {\n storeTransportCache(\n usingTLS,\n handshake.transport.name,\n Util.now() - startTimestamp,\n cacheSkipCount\n );\n callback(null, handshake);\n }\n });\n\n return {\n abort: function() {\n runner.abort();\n },\n forceMinPriority: function(p) {\n minPriority = p;\n if (runner) {\n runner.forceMinPriority(p);\n }\n }\n };\n }\n}\n\nfunction getTransportCacheKey(usingTLS: boolean): string {\n return 'pusherTransport' + (usingTLS ? 'TLS' : 'NonTLS');\n}\n\nfunction fetchTransportCache(usingTLS: boolean): any {\n var storage = Runtime.getLocalStorage();\n if (storage) {\n try {\n var serializedCache = storage[getTransportCacheKey(usingTLS)];\n if (serializedCache) {\n return JSON.parse(serializedCache);\n }\n } catch (e) {\n flushTransportCache(usingTLS);\n }\n }\n return null;\n}\n\nfunction storeTransportCache(\n usingTLS: boolean,\n transport: TransportStrategy,\n latency: number,\n cacheSkipCount: number\n) {\n var storage = Runtime.getLocalStorage();\n if (storage) {\n try {\n storage[getTransportCacheKey(usingTLS)] = Collections.safeJSONStringify({\n timestamp: Util.now(),\n transport: transport,\n latency: latency,\n cacheSkipCount: cacheSkipCount\n });\n } catch (e) {\n // catch over quota exceptions raised by localStorage\n }\n }\n}\n\nfunction flushTransportCache(usingTLS: boolean) {\n var storage = Runtime.getLocalStorage();\n if (storage) {\n try {\n delete storage[getTransportCacheKey(usingTLS)];\n } catch (e) {\n // catch exceptions raised by localStorage\n }\n }\n}\n","import { OneOffTimer as Timer } from '../utils/timers';\nimport Strategy from './strategy';\nimport StrategyOptions from './strategy_options';\n\n/** Runs substrategy after specified delay.\n *\n * Options:\n * - delay - time in miliseconds to delay the substrategy attempt\n *\n * @param {Strategy} strategy\n * @param {Object} options\n */\nexport default class DelayedStrategy implements Strategy {\n strategy: Strategy;\n options: { delay: number };\n\n constructor(strategy: Strategy, { delay: number }) {\n this.strategy = strategy;\n this.options = { delay: number };\n }\n\n isSupported(): boolean {\n return this.strategy.isSupported();\n }\n\n connect(minPriority: number, callback: Function) {\n var strategy = this.strategy;\n var runner;\n var timer = new Timer(this.options.delay, function() {\n runner = strategy.connect(minPriority, callback);\n });\n\n return {\n abort: function() {\n timer.ensureAborted();\n if (runner) {\n runner.abort();\n }\n },\n forceMinPriority: function(p) {\n minPriority = p;\n if (runner) {\n runner.forceMinPriority(p);\n }\n }\n };\n }\n}\n","import Strategy from './strategy';\nimport StrategyRunner from './strategy_runner';\n\n/** Proxies method calls to one of substrategies basing on the test function.\n *\n * @param {Function} test\n * @param {Strategy} trueBranch strategy used when test returns true\n * @param {Strategy} falseBranch strategy used when test returns false\n */\nexport default class IfStrategy implements Strategy {\n test: () => boolean;\n trueBranch: Strategy;\n falseBranch: Strategy;\n\n constructor(\n test: () => boolean,\n trueBranch: Strategy,\n falseBranch: Strategy\n ) {\n this.test = test;\n this.trueBranch = trueBranch;\n this.falseBranch = falseBranch;\n }\n\n isSupported(): boolean {\n var branch = this.test() ? this.trueBranch : this.falseBranch;\n return branch.isSupported();\n }\n\n connect(minPriority: number, callback: Function): StrategyRunner {\n var branch = this.test() ? this.trueBranch : this.falseBranch;\n return branch.connect(minPriority, callback);\n }\n}\n","import Strategy from './strategy';\nimport StrategyRunner from './strategy_runner';\n\n/** Launches the substrategy and terminates on the first open connection.\n *\n * @param {Strategy} strategy\n */\nexport default class FirstConnectedStrategy implements Strategy {\n strategy: Strategy;\n\n constructor(strategy: Strategy) {\n this.strategy = strategy;\n }\n\n isSupported(): boolean {\n return this.strategy.isSupported();\n }\n\n connect(minPriority: number, callback: Function): StrategyRunner {\n var runner = this.strategy.connect(minPriority, function(error, handshake) {\n if (handshake) {\n runner.abort();\n }\n callback(error, handshake);\n });\n return runner;\n }\n}\n","import * as Collections from 'core/utils/collections';\nimport TransportManager from 'core/transports/transport_manager';\nimport Strategy from 'core/strategies/strategy';\nimport StrategyOptions from 'core/strategies/strategy_options';\nimport SequentialStrategy from 'core/strategies/sequential_strategy';\nimport BestConnectedEverStrategy from 'core/strategies/best_connected_ever_strategy';\nimport WebSocketPrioritizedCachedStrategy, {\n TransportStrategyDictionary\n} from 'core/strategies/websocket_prioritized_cached_strategy';\nimport DelayedStrategy from 'core/strategies/delayed_strategy';\nimport IfStrategy from 'core/strategies/if_strategy';\nimport FirstConnectedStrategy from 'core/strategies/first_connected_strategy';\nimport { Config } from 'core/config';\n\nfunction testSupportsStrategy(strategy: Strategy) {\n return function() {\n return strategy.isSupported();\n };\n}\n\nvar getDefaultStrategy = function(\n config: Config,\n baseOptions: StrategyOptions,\n defineTransport: Function\n): Strategy {\n var definedTransports = {};\n\n function defineTransportStrategy(\n name: string,\n type: string,\n priority: number,\n options: StrategyOptions,\n manager?: TransportManager\n ) {\n var transport = defineTransport(\n config,\n name,\n type,\n priority,\n options,\n manager\n );\n\n definedTransports[name] = transport;\n\n return transport;\n }\n\n var ws_options: StrategyOptions = Object.assign({}, baseOptions, {\n hostNonTLS: config.wsHost + ':' + config.wsPort,\n hostTLS: config.wsHost + ':' + config.wssPort,\n httpPath: config.wsPath\n });\n var wss_options: StrategyOptions = Object.assign({}, ws_options, {\n useTLS: true\n });\n var sockjs_options: StrategyOptions = Object.assign({}, baseOptions, {\n hostNonTLS: config.httpHost + ':' + config.httpPort,\n hostTLS: config.httpHost + ':' + config.httpsPort,\n httpPath: config.httpPath\n });\n\n var timeouts = {\n loop: true,\n timeout: 15000,\n timeoutLimit: 60000\n };\n\n var ws_manager = new TransportManager({\n minPingDelay: 10000,\n maxPingDelay: config.activityTimeout\n });\n var streaming_manager = new TransportManager({\n lives: 2,\n minPingDelay: 10000,\n maxPingDelay: config.activityTimeout\n });\n\n var ws_transport = defineTransportStrategy(\n 'ws',\n 'ws',\n 3,\n ws_options,\n ws_manager\n );\n var wss_transport = defineTransportStrategy(\n 'wss',\n 'ws',\n 3,\n wss_options,\n ws_manager\n );\n var sockjs_transport = defineTransportStrategy(\n 'sockjs',\n 'sockjs',\n 1,\n sockjs_options\n );\n var xhr_streaming_transport = defineTransportStrategy(\n 'xhr_streaming',\n 'xhr_streaming',\n 1,\n sockjs_options,\n streaming_manager\n );\n var xdr_streaming_transport = defineTransportStrategy(\n 'xdr_streaming',\n 'xdr_streaming',\n 1,\n sockjs_options,\n streaming_manager\n );\n var xhr_polling_transport = defineTransportStrategy(\n 'xhr_polling',\n 'xhr_polling',\n 1,\n sockjs_options\n );\n var xdr_polling_transport = defineTransportStrategy(\n 'xdr_polling',\n 'xdr_polling',\n 1,\n sockjs_options\n );\n\n var ws_loop = new SequentialStrategy([ws_transport], timeouts);\n var wss_loop = new SequentialStrategy([wss_transport], timeouts);\n var sockjs_loop = new SequentialStrategy([sockjs_transport], timeouts);\n var streaming_loop = new SequentialStrategy(\n [\n new IfStrategy(\n testSupportsStrategy(xhr_streaming_transport),\n xhr_streaming_transport,\n xdr_streaming_transport\n )\n ],\n timeouts\n );\n var polling_loop = new SequentialStrategy(\n [\n new IfStrategy(\n testSupportsStrategy(xhr_polling_transport),\n xhr_polling_transport,\n xdr_polling_transport\n )\n ],\n timeouts\n );\n\n var http_loop = new SequentialStrategy(\n [\n new IfStrategy(\n testSupportsStrategy(streaming_loop),\n new BestConnectedEverStrategy([\n streaming_loop,\n new DelayedStrategy(polling_loop, { delay: 4000 })\n ]),\n polling_loop\n )\n ],\n timeouts\n );\n\n var http_fallback_loop = new IfStrategy(\n testSupportsStrategy(http_loop),\n http_loop,\n sockjs_loop\n );\n\n var wsStrategy;\n if (baseOptions.useTLS) {\n wsStrategy = new BestConnectedEverStrategy([\n ws_loop,\n new DelayedStrategy(http_fallback_loop, { delay: 2000 })\n ]);\n } else {\n wsStrategy = new BestConnectedEverStrategy([\n ws_loop,\n new DelayedStrategy(wss_loop, { delay: 2000 }),\n new DelayedStrategy(http_fallback_loop, { delay: 5000 })\n ]);\n }\n\n return new WebSocketPrioritizedCachedStrategy(\n new FirstConnectedStrategy(\n new IfStrategy(\n testSupportsStrategy(ws_transport),\n wsStrategy,\n http_fallback_loop\n )\n ),\n definedTransports,\n {\n ttl: 1800000,\n timeline: baseOptions.timeline,\n useTLS: baseOptions.useTLS\n }\n );\n};\n\nexport default getDefaultStrategy;\n","import HTTPRequest from 'core/http/http_request';\nimport RequestHooks from 'core/http/request_hooks';\nimport Ajax from 'core/http/ajax';\nimport * as Errors from 'core/errors';\n\nvar hooks: RequestHooks = {\n getRequest: function(socket: HTTPRequest): Ajax {\n var xdr = new (window).XDomainRequest();\n xdr.ontimeout = function() {\n socket.emit('error', new Errors.RequestTimedOut());\n socket.close();\n };\n xdr.onerror = function(e) {\n socket.emit('error', e);\n socket.close();\n };\n xdr.onprogress = function() {\n if (xdr.responseText && xdr.responseText.length > 0) {\n socket.onChunk(200, xdr.responseText);\n }\n };\n xdr.onload = function() {\n if (xdr.responseText && xdr.responseText.length > 0) {\n socket.onChunk(200, xdr.responseText);\n }\n socket.emit('finished', 200);\n socket.close();\n };\n return xdr;\n },\n abortRequest: function(xdr: Ajax) {\n xdr.ontimeout = xdr.onerror = xdr.onprogress = xdr.onload = null;\n xdr.abort();\n }\n};\n\nexport default hooks;\n","import Runtime from 'runtime';\nimport RequestHooks from './request_hooks';\nimport Ajax from './ajax';\nimport { default as EventsDispatcher } from '../events/dispatcher';\n\nconst MAX_BUFFER_LENGTH = 256 * 1024;\n\nexport default class HTTPRequest extends EventsDispatcher {\n hooks: RequestHooks;\n method: string;\n url: string;\n position: number;\n xhr: Ajax;\n unloader: Function;\n\n constructor(hooks: RequestHooks, method: string, url: string) {\n super();\n this.hooks = hooks;\n this.method = method;\n this.url = url;\n }\n\n start(payload?: any) {\n this.position = 0;\n this.xhr = this.hooks.getRequest(this);\n\n this.unloader = () => {\n this.close();\n };\n Runtime.addUnloadListener(this.unloader);\n\n this.xhr.open(this.method, this.url, true);\n\n if (this.xhr.setRequestHeader) {\n this.xhr.setRequestHeader('Content-Type', 'application/json'); // ReactNative doesn't set this header by default.\n }\n this.xhr.send(payload);\n }\n\n close() {\n if (this.unloader) {\n Runtime.removeUnloadListener(this.unloader);\n this.unloader = null;\n }\n if (this.xhr) {\n this.hooks.abortRequest(this.xhr);\n this.xhr = null;\n }\n }\n\n onChunk(status: number, data: any) {\n while (true) {\n var chunk = this.advanceBuffer(data);\n if (chunk) {\n this.emit('chunk', { status: status, data: chunk });\n } else {\n break;\n }\n }\n if (this.isBufferTooLong(data)) {\n this.emit('buffer_too_long');\n }\n }\n\n private advanceBuffer(buffer: any[]): any {\n var unreadData = buffer.slice(this.position);\n var endOfLinePosition = unreadData.indexOf('\\n');\n\n if (endOfLinePosition !== -1) {\n this.position += endOfLinePosition + 1;\n return unreadData.slice(0, endOfLinePosition);\n } else {\n // chunk is not finished yet, don't move the buffer pointer\n return null;\n }\n }\n\n private isBufferTooLong(buffer: any): boolean {\n return this.position === buffer.length && buffer.length > MAX_BUFFER_LENGTH;\n }\n}\n","enum State {\n CONNECTING = 0,\n OPEN = 1,\n CLOSED = 3\n}\n\nexport default State;\n","import URLLocation from './url_location';\nimport State from './state';\nimport Socket from '../socket';\nimport SocketHooks from './socket_hooks';\nimport Util from '../util';\nimport Ajax from './ajax';\nimport HTTPRequest from './http_request';\nimport Runtime from 'runtime';\n\nvar autoIncrement = 1;\n\nclass HTTPSocket implements Socket {\n hooks: SocketHooks;\n session: string;\n location: URLLocation;\n readyState: State;\n stream: HTTPRequest;\n\n onopen: () => void;\n onerror: (error: any) => void;\n onclose: (closeEvent: any) => void;\n onmessage: (message: any) => void;\n onactivity: () => void;\n\n constructor(hooks: SocketHooks, url: string) {\n this.hooks = hooks;\n this.session = randomNumber(1000) + '/' + randomString(8);\n this.location = getLocation(url);\n this.readyState = State.CONNECTING;\n this.openStream();\n }\n\n send(payload: any) {\n return this.sendRaw(JSON.stringify([payload]));\n }\n\n ping() {\n this.hooks.sendHeartbeat(this);\n }\n\n close(code: any, reason: any) {\n this.onClose(code, reason, true);\n }\n\n /** For internal use only */\n sendRaw(payload: any): boolean {\n if (this.readyState === State.OPEN) {\n try {\n Runtime.createSocketRequest(\n 'POST',\n getUniqueURL(getSendURL(this.location, this.session))\n ).start(payload);\n return true;\n } catch (e) {\n return false;\n }\n } else {\n return false;\n }\n }\n\n /** For internal use only */\n reconnect() {\n this.closeStream();\n this.openStream();\n }\n\n /** For internal use only */\n onClose(code, reason, wasClean) {\n this.closeStream();\n this.readyState = State.CLOSED;\n if (this.onclose) {\n this.onclose({\n code: code,\n reason: reason,\n wasClean: wasClean\n });\n }\n }\n\n private onChunk(chunk) {\n if (chunk.status !== 200) {\n return;\n }\n if (this.readyState === State.OPEN) {\n this.onActivity();\n }\n\n var payload;\n var type = chunk.data.slice(0, 1);\n switch (type) {\n case 'o':\n payload = JSON.parse(chunk.data.slice(1) || '{}');\n this.onOpen(payload);\n break;\n case 'a':\n payload = JSON.parse(chunk.data.slice(1) || '[]');\n for (var i = 0; i < payload.length; i++) {\n this.onEvent(payload[i]);\n }\n break;\n case 'm':\n payload = JSON.parse(chunk.data.slice(1) || 'null');\n this.onEvent(payload);\n break;\n case 'h':\n this.hooks.onHeartbeat(this);\n break;\n case 'c':\n payload = JSON.parse(chunk.data.slice(1) || '[]');\n this.onClose(payload[0], payload[1], true);\n break;\n }\n }\n\n private onOpen(options) {\n if (this.readyState === State.CONNECTING) {\n if (options && options.hostname) {\n this.location.base = replaceHost(this.location.base, options.hostname);\n }\n this.readyState = State.OPEN;\n\n if (this.onopen) {\n this.onopen();\n }\n } else {\n this.onClose(1006, 'Server lost session', true);\n }\n }\n\n private onEvent(event) {\n if (this.readyState === State.OPEN && this.onmessage) {\n this.onmessage({ data: event });\n }\n }\n\n private onActivity() {\n if (this.onactivity) {\n this.onactivity();\n }\n }\n\n private onError(error) {\n if (this.onerror) {\n this.onerror(error);\n }\n }\n\n private openStream() {\n this.stream = Runtime.createSocketRequest(\n 'POST',\n getUniqueURL(this.hooks.getReceiveURL(this.location, this.session))\n );\n\n this.stream.bind('chunk', chunk => {\n this.onChunk(chunk);\n });\n this.stream.bind('finished', status => {\n this.hooks.onFinished(this, status);\n });\n this.stream.bind('buffer_too_long', () => {\n this.reconnect();\n });\n\n try {\n this.stream.start();\n } catch (error) {\n Util.defer(() => {\n this.onError(error);\n this.onClose(1006, 'Could not start streaming', false);\n });\n }\n }\n\n private closeStream() {\n if (this.stream) {\n this.stream.unbind_all();\n this.stream.close();\n this.stream = null;\n }\n }\n}\n\nfunction getLocation(url): URLLocation {\n var parts = /([^\\?]*)\\/*(\\??.*)/.exec(url);\n return {\n base: parts[1],\n queryString: parts[2]\n };\n}\n\nfunction getSendURL(url: URLLocation, session: string): string {\n return url.base + '/' + session + '/xhr_send';\n}\n\nfunction getUniqueURL(url: string): string {\n var separator = url.indexOf('?') === -1 ? '?' : '&';\n return url + separator + 't=' + +new Date() + '&n=' + autoIncrement++;\n}\n\nfunction replaceHost(url: string, hostname: string): string {\n var urlParts = /(https?:\\/\\/)([^\\/:]+)((\\/|:)?.*)/.exec(url);\n return urlParts[1] + hostname + urlParts[3];\n}\n\nfunction randomNumber(max: number): number {\n return Runtime.randomInt(max);\n}\n\nfunction randomString(length: number): string {\n var result = [];\n\n for (var i = 0; i < length; i++) {\n result.push(randomNumber(32).toString(32));\n }\n\n return result.join('');\n}\n\nexport default HTTPSocket;\n","enum TimelineLevel {\n ERROR = 3,\n INFO = 6,\n DEBUG = 7\n}\n\nexport default TimelineLevel;\n","import SocketHooks from './socket_hooks';\nimport HTTPSocket from './http_socket';\n\nvar hooks: SocketHooks = {\n getReceiveURL: function(url, session) {\n return url.base + '/' + session + '/xhr_streaming' + url.queryString;\n },\n onHeartbeat: function(socket) {\n socket.sendRaw('[]');\n },\n sendHeartbeat: function(socket) {\n socket.sendRaw('[]');\n },\n onFinished: function(socket, status) {\n socket.onClose(1006, 'Connection interrupted (' + status + ')', false);\n }\n};\n\nexport default hooks;\n","import SocketHooks from './socket_hooks';\nimport URLLocation from './url_location';\nimport HTTPSocket from './http_socket';\n\nvar hooks: SocketHooks = {\n getReceiveURL: function(url: URLLocation, session: string): string {\n return url.base + '/' + session + '/xhr' + url.queryString;\n },\n onHeartbeat: function() {\n // next HTTP request will reset server's activity timer\n },\n sendHeartbeat: function(socket) {\n socket.sendRaw('[]');\n },\n onFinished: function(socket, status) {\n if (status === 200) {\n socket.reconnect();\n } else {\n socket.onClose(1006, 'Connection interrupted (' + status + ')', false);\n }\n }\n};\n\nexport default hooks;\n","import HTTPRequest from 'core/http/http_request';\nimport RequestHooks from 'core/http/request_hooks';\nimport Ajax from 'core/http/ajax';\nimport Runtime from 'runtime';\n\nvar hooks: RequestHooks = {\n getRequest: function(socket: HTTPRequest): Ajax {\n var Constructor = Runtime.getXHRAPI();\n var xhr = new Constructor();\n xhr.onreadystatechange = xhr.onprogress = function() {\n switch (xhr.readyState) {\n case 3:\n if (xhr.responseText && xhr.responseText.length > 0) {\n socket.onChunk(xhr.status, xhr.responseText);\n }\n break;\n case 4:\n // this happens only on errors, never after calling close\n if (xhr.responseText && xhr.responseText.length > 0) {\n socket.onChunk(xhr.status, xhr.responseText);\n }\n socket.emit('finished', xhr.status);\n socket.close();\n break;\n }\n };\n return xhr;\n },\n abortRequest: function(xhr: Ajax) {\n xhr.onreadystatechange = null;\n xhr.abort();\n }\n};\n\nexport default hooks;\n","import HTTPRequest from 'core/http/http_request';\nimport HTTPSocket from 'core/http/http_socket';\nimport SocketHooks from 'core/http/socket_hooks';\nimport RequestHooks from 'core/http/request_hooks';\nimport streamingHooks from 'core/http/http_streaming_socket';\nimport pollingHooks from 'core/http/http_polling_socket';\nimport xhrHooks from './http_xhr_request';\nimport HTTPFactory from 'core/http/http_factory';\n\nvar HTTP: HTTPFactory = {\n createStreamingSocket(url: string): HTTPSocket {\n return this.createSocket(streamingHooks, url);\n },\n\n createPollingSocket(url: string): HTTPSocket {\n return this.createSocket(pollingHooks, url);\n },\n\n createSocket(hooks: SocketHooks, url: string): HTTPSocket {\n return new HTTPSocket(hooks, url);\n },\n\n createXHR(method: string, url: string): HTTPRequest {\n return this.createRequest(xhrHooks, method, url);\n },\n\n createRequest(hooks: RequestHooks, method: string, url: string): HTTPRequest {\n return new HTTPRequest(hooks, method, url);\n }\n};\n\nexport default HTTP;\n","import xdrHooks from './http_xdomain_request';\nimport HTTP from 'isomorphic/http/http';\n\nHTTP.createXDR = function(method, url) {\n return this.createRequest(xdrHooks, method, url);\n};\n\nexport default HTTP;\n","import Browser from './browser';\nimport { Dependencies, DependenciesReceivers } from './dom/dependencies';\nimport { AuthTransport, AuthTransports } from 'core/auth/auth_transports';\nimport xhrAuth from 'isomorphic/auth/xhr_auth';\nimport jsonpAuth from './auth/jsonp_auth';\nimport TimelineTransport from 'core/timeline/timeline_transport';\nimport TimelineSender from 'core/timeline/timeline_sender';\nimport ScriptRequest from './dom/script_request';\nimport JSONPRequest from './dom/jsonp_request';\nimport * as Collections from 'core/utils/collections';\nimport { ScriptReceivers } from './dom/script_receiver_factory';\nimport jsonpTimeline from './timeline/jsonp_timeline';\nimport Transports from './transports/transports';\nimport Ajax from 'core/http/ajax';\nimport { Network } from './net_info';\nimport getDefaultStrategy from './default_strategy';\nimport transportConnectionInitializer from './transports/transport_connection_initializer';\nimport HTTPFactory from './http/http';\nimport HTTPRequest from 'core/http/http_request';\n\nvar Runtime: Browser = {\n // for jsonp auth\n nextAuthCallbackID: 1,\n auth_callbacks: {},\n ScriptReceivers,\n DependenciesReceivers,\n getDefaultStrategy,\n Transports,\n transportConnectionInitializer,\n HTTPFactory,\n\n TimelineTransport: jsonpTimeline,\n\n getXHRAPI() {\n return window.XMLHttpRequest;\n },\n\n getWebSocketAPI() {\n return window.WebSocket || window.MozWebSocket;\n },\n\n setup(PusherClass): void {\n (window).Pusher = PusherClass; // JSONp requires Pusher to be in the global scope.\n var initializeOnDocumentBody = () => {\n this.onDocumentBody(PusherClass.ready);\n };\n if (!(window).JSON) {\n Dependencies.load('json2', {}, initializeOnDocumentBody);\n } else {\n initializeOnDocumentBody();\n }\n },\n\n getDocument(): Document {\n return document;\n },\n\n getProtocol(): string {\n return this.getDocument().location.protocol;\n },\n\n getAuthorizers(): AuthTransports {\n return { ajax: xhrAuth, jsonp: jsonpAuth };\n },\n\n onDocumentBody(callback: Function) {\n if (document.body) {\n callback();\n } else {\n setTimeout(() => {\n this.onDocumentBody(callback);\n }, 0);\n }\n },\n\n createJSONPRequest(url: string, data: any): JSONPRequest {\n return new JSONPRequest(url, data);\n },\n\n createScriptRequest(src: string): ScriptRequest {\n return new ScriptRequest(src);\n },\n\n getLocalStorage() {\n try {\n return window.localStorage;\n } catch (e) {\n return undefined;\n }\n },\n\n createXHR(): Ajax {\n if (this.getXHRAPI()) {\n return this.createXMLHttpRequest();\n } else {\n return this.createMicrosoftXHR();\n }\n },\n\n createXMLHttpRequest(): Ajax {\n var Constructor = this.getXHRAPI();\n return new Constructor();\n },\n\n createMicrosoftXHR(): Ajax {\n return new ActiveXObject('Microsoft.XMLHTTP');\n },\n\n getNetwork() {\n return Network;\n },\n\n createWebSocket(url: string): any {\n var Constructor = this.getWebSocketAPI();\n return new Constructor(url);\n },\n\n createSocketRequest(method: string, url: string): HTTPRequest {\n if (this.isXHRSupported()) {\n return this.HTTPFactory.createXHR(method, url);\n } else if (this.isXDRSupported(url.indexOf('https:') === 0)) {\n return this.HTTPFactory.createXDR(method, url);\n } else {\n throw 'Cross-origin HTTP requests are not supported';\n }\n },\n\n isXHRSupported(): boolean {\n var Constructor = this.getXHRAPI();\n return (\n Boolean(Constructor) && new Constructor().withCredentials !== undefined\n );\n },\n\n isXDRSupported(useTLS?: boolean): boolean {\n var protocol = useTLS ? 'https:' : 'http:';\n var documentProtocol = this.getProtocol();\n return (\n Boolean(window['XDomainRequest']) && documentProtocol === protocol\n );\n },\n\n addUnloadListener(listener: any) {\n if (window.addEventListener !== undefined) {\n window.addEventListener('unload', listener, false);\n } else if (window.attachEvent !== undefined) {\n window.attachEvent('onunload', listener);\n }\n },\n\n removeUnloadListener(listener: any) {\n if (window.addEventListener !== undefined) {\n window.removeEventListener('unload', listener, false);\n } else if (window.detachEvent !== undefined) {\n window.detachEvent('onunload', listener);\n }\n },\n\n randomInt(max: number): number {\n /**\n * Return values in the range of [0, 1[\n */\n const random = function() {\n const crypto = window.crypto || window['msCrypto'];\n const random = crypto.getRandomValues(new Uint32Array(1))[0];\n\n return random / 2 ** 32;\n };\n\n return Math.floor(random() * max);\n }\n};\n\nexport default Runtime;\n","import { Dependencies } from '../dom/dependencies';\n\n/** Initializes the transport.\n *\n * Fetches resources if needed and then transitions to initialized.\n */\nexport default function() {\n var self = this;\n\n self.timeline.info(\n self.buildTimelineMessage({\n transport: self.name + (self.options.useTLS ? 's' : '')\n })\n );\n\n if (self.hooks.isInitialized()) {\n self.changeState('initialized');\n } else if (self.hooks.file) {\n self.changeState('initializing');\n Dependencies.load(\n self.hooks.file,\n { useTLS: self.options.useTLS },\n function(error, callback) {\n if (self.hooks.isInitialized()) {\n self.changeState('initialized');\n callback(true);\n } else {\n if (error) {\n self.onError(error);\n }\n self.onClose();\n callback(false);\n }\n }\n );\n } else {\n self.onClose();\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport { default as Level } from './level';\n\nexport interface TimelineOptions {\n level?: Level;\n limit?: number;\n version?: string;\n cluster?: string;\n features?: string[];\n params?: any;\n}\n\nexport default class Timeline {\n key: string;\n session: number;\n events: any[];\n options: TimelineOptions;\n sent: number;\n uniqueID: number;\n\n constructor(key: string, session: number, options: TimelineOptions) {\n this.key = key;\n this.session = session;\n this.events = [];\n this.options = options || {};\n this.sent = 0;\n this.uniqueID = 0;\n }\n\n log(level, event) {\n if (level <= this.options.level) {\n this.events.push(\n Collections.extend({}, event, { timestamp: Util.now() })\n );\n if (this.options.limit && this.events.length > this.options.limit) {\n this.events.shift();\n }\n }\n }\n\n error(event) {\n this.log(Level.ERROR, event);\n }\n\n info(event) {\n this.log(Level.INFO, event);\n }\n\n debug(event) {\n this.log(Level.DEBUG, event);\n }\n\n isEmpty() {\n return this.events.length === 0;\n }\n\n send(sendfn, callback) {\n var data = Collections.extend(\n {\n session: this.session,\n bundle: this.sent + 1,\n key: this.key,\n lib: 'js',\n version: this.options.version,\n cluster: this.options.cluster,\n features: this.options.features,\n timeline: this.events\n },\n this.options.params\n );\n\n this.events = [];\n sendfn(data, (error, result) => {\n if (!error) {\n this.sent++;\n }\n if (callback) {\n callback(error, result);\n }\n });\n\n return true;\n }\n\n generateUniqueID(): number {\n this.uniqueID++;\n return this.uniqueID;\n }\n}\n","import Factory from '../utils/factory';\nimport Util from '../util';\nimport * as Errors from '../errors';\nimport * as Collections from '../utils/collections';\nimport Strategy from './strategy';\nimport Transport from '../transports/transport';\nimport StrategyOptions from './strategy_options';\nimport Handshake from '../connection/handshake';\n\n/** Provides a strategy interface for transports.\n *\n * @param {String} name\n * @param {Number} priority\n * @param {Class} transport\n * @param {Object} options\n */\nexport default class TransportStrategy implements Strategy {\n name: string;\n priority: number;\n transport: Transport;\n options: StrategyOptions;\n\n constructor(\n name: string,\n priority: number,\n transport: Transport,\n options: StrategyOptions\n ) {\n this.name = name;\n this.priority = priority;\n this.transport = transport;\n this.options = options || {};\n }\n\n /** Returns whether the transport is supported in the browser.\n *\n * @returns {Boolean}\n */\n isSupported(): boolean {\n return this.transport.isSupported({\n useTLS: this.options.useTLS\n });\n }\n\n /** Launches a connection attempt and returns a strategy runner.\n *\n * @param {Function} callback\n * @return {Object} strategy runner\n */\n connect(minPriority: number, callback: Function) {\n if (!this.isSupported()) {\n return failAttempt(new Errors.UnsupportedStrategy(), callback);\n } else if (this.priority < minPriority) {\n return failAttempt(new Errors.TransportPriorityTooLow(), callback);\n }\n\n var connected = false;\n var transport = this.transport.createConnection(\n this.name,\n this.priority,\n this.options.key,\n this.options\n );\n var handshake = null;\n\n var onInitialized = function() {\n transport.unbind('initialized', onInitialized);\n transport.connect();\n };\n var onOpen = function() {\n handshake = Factory.createHandshake(transport, function(result) {\n connected = true;\n unbindListeners();\n callback(null, result);\n });\n };\n var onError = function(error) {\n unbindListeners();\n callback(error);\n };\n var onClosed = function() {\n unbindListeners();\n var serializedTransport;\n\n // The reason for this try/catch block is that on React Native\n // the WebSocket object is circular. Therefore transport.socket will\n // throw errors upon stringification. Collections.safeJSONStringify\n // discards circular references when serializing.\n serializedTransport = Collections.safeJSONStringify(transport);\n callback(new Errors.TransportClosed(serializedTransport));\n };\n\n var unbindListeners = function() {\n transport.unbind('initialized', onInitialized);\n transport.unbind('open', onOpen);\n transport.unbind('error', onError);\n transport.unbind('closed', onClosed);\n };\n\n transport.bind('initialized', onInitialized);\n transport.bind('open', onOpen);\n transport.bind('error', onError);\n transport.bind('closed', onClosed);\n\n // connect will be called automatically after initialization\n transport.initialize();\n\n return {\n abort: () => {\n if (connected) {\n return;\n }\n unbindListeners();\n if (handshake) {\n handshake.close();\n } else {\n transport.close();\n }\n },\n forceMinPriority: p => {\n if (connected) {\n return;\n }\n if (this.priority < p) {\n if (handshake) {\n handshake.close();\n } else {\n transport.close();\n }\n }\n }\n };\n }\n}\n\nfunction failAttempt(error: Error, callback: Function) {\n Util.defer(function() {\n callback(error);\n });\n return {\n abort: function() {},\n forceMinPriority: function() {}\n };\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport TransportManager from '../transports/transport_manager';\nimport * as Errors from '../errors';\nimport Strategy from './strategy';\nimport TransportStrategy from './transport_strategy';\nimport StrategyOptions from '../strategies/strategy_options';\nimport { Config } from '../config';\nimport Runtime from 'runtime';\n\nconst { Transports } = Runtime;\n\nexport var defineTransport = function(\n config: Config,\n name: string,\n type: string,\n priority: number,\n options: StrategyOptions,\n manager?: TransportManager\n): Strategy {\n var transportClass = Transports[type];\n if (!transportClass) {\n throw new Errors.UnsupportedTransport(type);\n }\n\n var enabled =\n (!config.enabledTransports ||\n Collections.arrayIndexOf(config.enabledTransports, name) !== -1) &&\n (!config.disabledTransports ||\n Collections.arrayIndexOf(config.disabledTransports, name) === -1);\n\n var transport;\n if (enabled) {\n options = Object.assign(\n { ignoreNullOrigin: config.ignoreNullOrigin },\n options\n );\n\n transport = new TransportStrategy(\n name,\n priority,\n manager ? manager.getAssistant(transportClass) : transportClass,\n options\n );\n } else {\n transport = UnsupportedStrategy;\n }\n\n return transport;\n};\n\nvar UnsupportedStrategy: Strategy = {\n isSupported: function() {\n return false;\n },\n connect: function(_, callback) {\n var deferred = Util.defer(function() {\n callback(new Errors.UnsupportedStrategy());\n });\n return {\n abort: function() {\n deferred.ensureAborted();\n },\n forceMinPriority: function() {}\n };\n }\n};\n","import {\n UserAuthenticationCallback,\n InternalAuthOptions,\n UserAuthenticationHandler,\n UserAuthenticationRequestParams,\n AuthRequestType\n} from './options';\n\nimport Runtime from 'runtime';\n\nconst composeChannelQuery = (\n params: UserAuthenticationRequestParams,\n authOptions: InternalAuthOptions\n) => {\n var query = 'socket_id=' + encodeURIComponent(params.socketId);\n\n for (var key in authOptions.params) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(authOptions.params[key]);\n }\n\n if (authOptions.paramsProvider != null) {\n let dynamicParams = authOptions.paramsProvider();\n for (var key in dynamicParams) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(dynamicParams[key]);\n }\n }\n\n return query;\n};\n\nconst UserAuthenticator = (\n authOptions: InternalAuthOptions\n): UserAuthenticationHandler => {\n if (typeof Runtime.getAuthorizers()[authOptions.transport] === 'undefined') {\n throw `'${authOptions.transport}' is not a recognized auth transport`;\n }\n\n return (\n params: UserAuthenticationRequestParams,\n callback: UserAuthenticationCallback\n ) => {\n const query = composeChannelQuery(params, authOptions);\n\n Runtime.getAuthorizers()[authOptions.transport](\n Runtime,\n query,\n authOptions,\n AuthRequestType.UserAuthentication,\n callback\n );\n };\n};\n\nexport default UserAuthenticator;\n","import {\n AuthRequestType,\n InternalAuthOptions,\n ChannelAuthorizationHandler,\n ChannelAuthorizationRequestParams,\n ChannelAuthorizationCallback\n} from './options';\n\nimport Runtime from 'runtime';\n\nconst composeChannelQuery = (\n params: ChannelAuthorizationRequestParams,\n authOptions: InternalAuthOptions\n) => {\n var query = 'socket_id=' + encodeURIComponent(params.socketId);\n\n query += '&channel_name=' + encodeURIComponent(params.channelName);\n\n for (var key in authOptions.params) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(authOptions.params[key]);\n }\n\n if (authOptions.paramsProvider != null) {\n let dynamicParams = authOptions.paramsProvider();\n for (var key in dynamicParams) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(dynamicParams[key]);\n }\n }\n\n return query;\n};\n\nconst ChannelAuthorizer = (\n authOptions: InternalAuthOptions\n): ChannelAuthorizationHandler => {\n if (typeof Runtime.getAuthorizers()[authOptions.transport] === 'undefined') {\n throw `'${authOptions.transport}' is not a recognized auth transport`;\n }\n\n return (\n params: ChannelAuthorizationRequestParams,\n callback: ChannelAuthorizationCallback\n ) => {\n const query = composeChannelQuery(params, authOptions);\n\n Runtime.getAuthorizers()[authOptions.transport](\n Runtime,\n query,\n authOptions,\n AuthRequestType.ChannelAuthorization,\n callback\n );\n };\n};\n\nexport default ChannelAuthorizer;\n","import { Options } from './options';\nimport Defaults from './defaults';\nimport {\n ChannelAuthorizationHandler,\n UserAuthenticationHandler,\n ChannelAuthorizationOptions\n} from './auth/options';\nimport UserAuthenticator from './auth/user_authenticator';\nimport ChannelAuthorizer from './auth/channel_authorizer';\nimport { ChannelAuthorizerProxy } from './auth/deprecated_channel_authorizer';\nimport Runtime from 'runtime';\nimport * as nacl from 'tweetnacl';\n\nexport type AuthTransport = 'ajax' | 'jsonp';\nexport type Transport =\n | 'ws'\n | 'wss'\n | 'xhr_streaming'\n | 'xhr_polling'\n | 'sockjs';\n\nexport interface Config {\n // these are all 'required' config parameters, it's not necessary for the user\n // to set them, but they have configured defaults.\n activityTimeout: number;\n enableStats: boolean;\n httpHost: string;\n httpPath: string;\n httpPort: number;\n httpsPort: number;\n pongTimeout: number;\n statsHost: string;\n unavailableTimeout: number;\n useTLS: boolean;\n wsHost: string;\n wsPath: string;\n wsPort: number;\n wssPort: number;\n userAuthenticator: UserAuthenticationHandler;\n channelAuthorizer: ChannelAuthorizationHandler;\n\n // these are all optional parameters or overrrides. The customer can set these\n // but it's not strictly necessary\n forceTLS?: boolean;\n cluster?: string;\n disabledTransports?: Transport[];\n enabledTransports?: Transport[];\n ignoreNullOrigin?: boolean;\n nacl?: nacl;\n timelineParams?: any;\n}\n\n// getConfig mainly sets the defaults for the options that are not provided\nexport function getConfig(opts: Options, pusher): Config {\n let config: Config = {\n activityTimeout: opts.activityTimeout || Defaults.activityTimeout,\n cluster: opts.cluster,\n httpPath: opts.httpPath || Defaults.httpPath,\n httpPort: opts.httpPort || Defaults.httpPort,\n httpsPort: opts.httpsPort || Defaults.httpsPort,\n pongTimeout: opts.pongTimeout || Defaults.pongTimeout,\n statsHost: opts.statsHost || Defaults.stats_host,\n unavailableTimeout: opts.unavailableTimeout || Defaults.unavailableTimeout,\n wsPath: opts.wsPath || Defaults.wsPath,\n wsPort: opts.wsPort || Defaults.wsPort,\n wssPort: opts.wssPort || Defaults.wssPort,\n\n enableStats: getEnableStatsConfig(opts),\n httpHost: getHttpHost(opts),\n useTLS: shouldUseTLS(opts),\n wsHost: getWebsocketHost(opts),\n\n userAuthenticator: buildUserAuthenticator(opts),\n channelAuthorizer: buildChannelAuthorizer(opts, pusher)\n };\n\n if ('disabledTransports' in opts)\n config.disabledTransports = opts.disabledTransports;\n if ('enabledTransports' in opts)\n config.enabledTransports = opts.enabledTransports;\n if ('ignoreNullOrigin' in opts)\n config.ignoreNullOrigin = opts.ignoreNullOrigin;\n if ('timelineParams' in opts) config.timelineParams = opts.timelineParams;\n if ('nacl' in opts) {\n config.nacl = opts.nacl;\n }\n\n return config;\n}\n\nfunction getHttpHost(opts: Options): string {\n if (opts.httpHost) {\n return opts.httpHost;\n }\n if (opts.cluster) {\n return `sockjs-${opts.cluster}.pusher.com`;\n }\n return Defaults.httpHost;\n}\n\nfunction getWebsocketHost(opts: Options): string {\n if (opts.wsHost) {\n return opts.wsHost;\n }\n return getWebsocketHostFromCluster(opts.cluster);\n}\n\nfunction getWebsocketHostFromCluster(cluster: string): string {\n return `ws-${cluster}.pusher.com`;\n}\n\nfunction shouldUseTLS(opts: Options): boolean {\n if (Runtime.getProtocol() === 'https:') {\n return true;\n } else if (opts.forceTLS === false) {\n return false;\n }\n return true;\n}\n\n// if enableStats is set take the value\n// if disableStats is set take the inverse\n// otherwise default to false\nfunction getEnableStatsConfig(opts: Options): boolean {\n if ('enableStats' in opts) {\n return opts.enableStats;\n }\n if ('disableStats' in opts) {\n return !opts.disableStats;\n }\n return false;\n}\n\nfunction buildUserAuthenticator(opts: Options): UserAuthenticationHandler {\n const userAuthentication = {\n ...Defaults.userAuthentication,\n ...opts.userAuthentication\n };\n if (\n 'customHandler' in userAuthentication &&\n userAuthentication['customHandler'] != null\n ) {\n return userAuthentication['customHandler'];\n }\n\n return UserAuthenticator(userAuthentication);\n}\n\nfunction buildChannelAuth(opts: Options, pusher): ChannelAuthorizationOptions {\n let channelAuthorization: ChannelAuthorizationOptions;\n if ('channelAuthorization' in opts) {\n channelAuthorization = {\n ...Defaults.channelAuthorization,\n ...opts.channelAuthorization\n };\n } else {\n channelAuthorization = {\n transport: opts.authTransport || Defaults.authTransport,\n endpoint: opts.authEndpoint || Defaults.authEndpoint\n };\n if ('auth' in opts) {\n if ('params' in opts.auth) channelAuthorization.params = opts.auth.params;\n if ('headers' in opts.auth)\n channelAuthorization.headers = opts.auth.headers;\n }\n if ('authorizer' in opts)\n channelAuthorization.customHandler = ChannelAuthorizerProxy(\n pusher,\n channelAuthorization,\n opts.authorizer\n );\n }\n return channelAuthorization;\n}\n\nfunction buildChannelAuthorizer(\n opts: Options,\n pusher\n): ChannelAuthorizationHandler {\n const channelAuthorization = buildChannelAuth(opts, pusher);\n if (\n 'customHandler' in channelAuthorization &&\n channelAuthorization['customHandler'] != null\n ) {\n return channelAuthorization['customHandler'];\n }\n\n return ChannelAuthorizer(channelAuthorization);\n}\n","import Channel from '../channels/channel';\nimport {\n ChannelAuthorizationCallback,\n ChannelAuthorizationHandler,\n ChannelAuthorizationRequestParams,\n InternalAuthOptions\n} from './options';\n\nexport interface DeprecatedChannelAuthorizer {\n authorize(socketId: string, callback: ChannelAuthorizationCallback): void;\n}\n\nexport interface ChannelAuthorizerGenerator {\n (\n channel: Channel,\n options: DeprecatedAuthorizerOptions\n ): DeprecatedChannelAuthorizer;\n}\n\nexport interface DeprecatedAuthOptions {\n params?: any;\n headers?: any;\n}\n\nexport interface DeprecatedAuthorizerOptions {\n authTransport: 'ajax' | 'jsonp';\n authEndpoint: string;\n auth?: DeprecatedAuthOptions;\n}\n\nexport const ChannelAuthorizerProxy = (\n pusher,\n authOptions: InternalAuthOptions,\n channelAuthorizerGenerator: ChannelAuthorizerGenerator\n): ChannelAuthorizationHandler => {\n const deprecatedAuthorizerOptions: DeprecatedAuthorizerOptions = {\n authTransport: authOptions.transport,\n authEndpoint: authOptions.endpoint,\n auth: {\n params: authOptions.params,\n headers: authOptions.headers\n }\n };\n return (\n params: ChannelAuthorizationRequestParams,\n callback: ChannelAuthorizationCallback\n ) => {\n const channel = pusher.channel(params.channelName);\n // This line creates a new channel authorizer every time.\n // In the past, this was only done once per channel and reused.\n // We can do that again if we want to keep this behavior intact.\n const channelAuthorizer: DeprecatedChannelAuthorizer = channelAuthorizerGenerator(\n channel,\n deprecatedAuthorizerOptions\n );\n channelAuthorizer.authorize(params.socketId, callback);\n };\n};\n","import Logger from './logger';\nimport Pusher from './pusher';\nimport EventsDispatcher from './events/dispatcher';\n\nexport default class WatchlistFacade extends EventsDispatcher {\n private pusher: Pusher;\n\n public constructor(pusher: Pusher) {\n super(function(eventName, data) {\n Logger.debug(`No callbacks on watchlist events for ${eventName}`);\n });\n\n this.pusher = pusher;\n this.bindWatchlistInternalEvent();\n }\n\n handleEvent(pusherEvent) {\n pusherEvent.data.events.forEach(watchlistEvent => {\n this.emit(watchlistEvent.name, watchlistEvent);\n });\n }\n\n private bindWatchlistInternalEvent() {\n this.pusher.connection.bind('message', pusherEvent => {\n var eventName = pusherEvent.event;\n if (eventName === 'pusher_internal:watchlist_events') {\n this.handleEvent(pusherEvent);\n }\n });\n }\n}\n","function flatPromise() {\n let resolve, reject;\n const promise = new Promise((res, rej) => {\n resolve = res;\n reject = rej;\n });\n return { promise, resolve, reject };\n}\n\nexport default flatPromise;\n","import Pusher from './pusher';\nimport Logger from './logger';\nimport {\n UserAuthenticationData,\n UserAuthenticationCallback\n} from './auth/options';\nimport Channel from './channels/channel';\nimport WatchlistFacade from './watchlist';\nimport EventsDispatcher from './events/dispatcher';\nimport flatPromise from './utils/flat_promise';\n\nexport default class UserFacade extends EventsDispatcher {\n pusher: Pusher;\n signin_requested: boolean = false;\n user_data: any = null;\n serverToUserChannel: Channel = null;\n signinDonePromise: Promise = null;\n watchlist: WatchlistFacade;\n private _signinDoneResolve: Function = null;\n\n public constructor(pusher: Pusher) {\n super(function(eventName, data) {\n Logger.debug('No callbacks on user for ' + eventName);\n });\n this.pusher = pusher;\n this.pusher.connection.bind('state_change', ({ previous, current }) => {\n if (previous !== 'connected' && current === 'connected') {\n this._signin();\n }\n if (previous === 'connected' && current !== 'connected') {\n this._cleanup();\n this._newSigninPromiseIfNeeded();\n }\n });\n\n this.watchlist = new WatchlistFacade(pusher);\n\n this.pusher.connection.bind('message', event => {\n var eventName = event.event;\n if (eventName === 'pusher:signin_success') {\n this._onSigninSuccess(event.data);\n }\n if (\n this.serverToUserChannel &&\n this.serverToUserChannel.name === event.channel\n ) {\n this.serverToUserChannel.handleEvent(event);\n }\n });\n }\n\n public signin() {\n if (this.signin_requested) {\n return;\n }\n\n this.signin_requested = true;\n this._signin();\n }\n\n private _signin() {\n if (!this.signin_requested) {\n return;\n }\n\n this._newSigninPromiseIfNeeded();\n\n if (this.pusher.connection.state !== 'connected') {\n // Signin will be attempted when the connection is connected\n return;\n }\n\n this.pusher.config.userAuthenticator(\n {\n socketId: this.pusher.connection.socket_id\n },\n this._onAuthorize\n );\n }\n\n private _onAuthorize: UserAuthenticationCallback = (\n err,\n authData: UserAuthenticationData\n ) => {\n if (err) {\n Logger.warn(`Error during signin: ${err}`);\n this._cleanup();\n return;\n }\n\n this.pusher.send_event('pusher:signin', {\n auth: authData.auth,\n user_data: authData.user_data\n });\n\n // Later when we get pusher:singin_success event, the user will be marked as signed in\n };\n\n private _onSigninSuccess(data: any) {\n try {\n this.user_data = JSON.parse(data.user_data);\n } catch (e) {\n Logger.error(`Failed parsing user data after signin: ${data.user_data}`);\n this._cleanup();\n return;\n }\n\n if (typeof this.user_data.id !== 'string' || this.user_data.id === '') {\n Logger.error(\n `user_data doesn't contain an id. user_data: ${this.user_data}`\n );\n this._cleanup();\n return;\n }\n\n // Signin succeeded\n this._signinDoneResolve();\n this._subscribeChannels();\n }\n\n private _subscribeChannels() {\n const ensure_subscribed = channel => {\n if (channel.subscriptionPending && channel.subscriptionCancelled) {\n channel.reinstateSubscription();\n } else if (\n !channel.subscriptionPending &&\n this.pusher.connection.state === 'connected'\n ) {\n channel.subscribe();\n }\n };\n\n this.serverToUserChannel = new Channel(\n `#server-to-user-${this.user_data.id}`,\n this.pusher\n );\n this.serverToUserChannel.bind_global((eventName, data) => {\n if (\n eventName.indexOf('pusher_internal:') === 0 ||\n eventName.indexOf('pusher:') === 0\n ) {\n // ignore internal events\n return;\n }\n this.emit(eventName, data);\n });\n ensure_subscribed(this.serverToUserChannel);\n }\n\n private _cleanup() {\n this.user_data = null;\n if (this.serverToUserChannel) {\n this.serverToUserChannel.unbind_all();\n this.serverToUserChannel.disconnect();\n this.serverToUserChannel = null;\n }\n\n if (this.signin_requested) {\n // If signin is in progress and cleanup is called,\n // Mark the current signin process as done.\n this._signinDoneResolve();\n }\n }\n\n private _newSigninPromiseIfNeeded() {\n if (!this.signin_requested) {\n return;\n }\n\n // If there is a promise and it is not resolved, return without creating a new one.\n if (this.signinDonePromise && !(this.signinDonePromise as any).done) {\n return;\n }\n\n // This promise is never rejected.\n // It gets resolved when the signin process is done whether it failed or succeeded\n const { promise, resolve, reject: _ } = flatPromise();\n (promise as any).done = false;\n const setDone = () => {\n (promise as any).done = true;\n };\n promise.then(setDone).catch(setDone);\n this.signinDonePromise = promise;\n this._signinDoneResolve = resolve;\n }\n}\n","import AbstractRuntime from '../runtimes/interface';\nimport Runtime from 'runtime';\nimport * as Collections from './utils/collections';\nimport Channels from './channels/channels';\nimport Channel from './channels/channel';\nimport { default as EventsDispatcher } from './events/dispatcher';\nimport Timeline from './timeline/timeline';\nimport TimelineSender from './timeline/timeline_sender';\nimport TimelineLevel from './timeline/level';\nimport { defineTransport } from './strategies/strategy_builder';\nimport ConnectionManager from './connection/connection_manager';\nimport { PeriodicTimer } from './utils/timers';\nimport Defaults from './defaults';\nimport Logger from './logger';\nimport Factory from './utils/factory';\nimport { Options, ClusterOptions, validateOptions } from './options';\nimport { Config, getConfig } from './config';\nimport StrategyOptions from './strategies/strategy_options';\nimport UserFacade from './user';\n\nexport default class Pusher {\n /* STATIC PROPERTIES */\n static instances: Pusher[] = [];\n static isReady: boolean = false;\n static logToConsole: boolean = false;\n\n // for jsonp\n static Runtime: AbstractRuntime = Runtime;\n static ScriptReceivers: any = (Runtime).ScriptReceivers;\n static DependenciesReceivers: any = (Runtime).DependenciesReceivers;\n static auth_callbacks: any = (Runtime).auth_callbacks;\n\n static ready() {\n Pusher.isReady = true;\n for (var i = 0, l = Pusher.instances.length; i < l; i++) {\n Pusher.instances[i].connect();\n }\n }\n\n static log: (message: any) => void;\n\n private static getClientFeatures(): string[] {\n return Collections.keys(\n Collections.filterObject({ ws: Runtime.Transports.ws }, function(t) {\n return t.isSupported({});\n })\n );\n }\n\n /* INSTANCE PROPERTIES */\n key: string;\n options: Options;\n config: Config;\n channels: Channels;\n global_emitter: EventsDispatcher;\n sessionID: number;\n timeline: Timeline;\n timelineSender: TimelineSender;\n connection: ConnectionManager;\n timelineSenderTimer: PeriodicTimer;\n user: UserFacade;\n constructor(app_key: string, options: Options) {\n checkAppKey(app_key);\n validateOptions(options);\n this.key = app_key;\n this.config = getConfig(options, this);\n\n this.channels = Factory.createChannels();\n this.global_emitter = new EventsDispatcher();\n this.sessionID = Runtime.randomInt(1000000000);\n\n this.timeline = new Timeline(this.key, this.sessionID, {\n cluster: this.config.cluster,\n features: Pusher.getClientFeatures(),\n params: this.config.timelineParams || {},\n limit: 50,\n level: TimelineLevel.INFO,\n version: Defaults.VERSION\n });\n if (this.config.enableStats) {\n this.timelineSender = Factory.createTimelineSender(this.timeline, {\n host: this.config.statsHost,\n path: '/timeline/v2/' + Runtime.TimelineTransport.name\n });\n }\n\n var getStrategy = (options: StrategyOptions) => {\n return Runtime.getDefaultStrategy(this.config, options, defineTransport);\n };\n\n this.connection = Factory.createConnectionManager(this.key, {\n getStrategy: getStrategy,\n timeline: this.timeline,\n activityTimeout: this.config.activityTimeout,\n pongTimeout: this.config.pongTimeout,\n unavailableTimeout: this.config.unavailableTimeout,\n useTLS: Boolean(this.config.useTLS)\n });\n\n this.connection.bind('connected', () => {\n this.subscribeAll();\n if (this.timelineSender) {\n this.timelineSender.send(this.connection.isUsingTLS());\n }\n });\n\n this.connection.bind('message', event => {\n var eventName = event.event;\n var internal = eventName.indexOf('pusher_internal:') === 0;\n if (event.channel) {\n var channel = this.channel(event.channel);\n if (channel) {\n channel.handleEvent(event);\n }\n }\n // Emit globally [deprecated]\n if (!internal) {\n this.global_emitter.emit(event.event, event.data);\n }\n });\n this.connection.bind('connecting', () => {\n this.channels.disconnect();\n });\n this.connection.bind('disconnected', () => {\n this.channels.disconnect();\n });\n this.connection.bind('error', err => {\n Logger.warn(err);\n });\n\n Pusher.instances.push(this);\n this.timeline.info({ instances: Pusher.instances.length });\n\n this.user = new UserFacade(this);\n\n if (Pusher.isReady) {\n this.connect();\n }\n }\n\n /**\n * Allows you to switch Pusher cluster without\n * losing all the channels/subscription binding\n * as this is internally managed by the SDK.\n */\n switchCluster(options: ClusterOptions) {\n const { appKey, cluster } = options;\n this.key = appKey;\n this.options = { ...this.options, cluster };\n this.config = getConfig(this.options, this);\n this.connection.switchCluster(this.key);\n }\n\n channel(name: string): Channel {\n return this.channels.find(name);\n }\n\n allChannels(): Channel[] {\n return this.channels.all();\n }\n\n connect() {\n this.connection.connect();\n\n if (this.timelineSender) {\n if (!this.timelineSenderTimer) {\n var usingTLS = this.connection.isUsingTLS();\n var timelineSender = this.timelineSender;\n this.timelineSenderTimer = new PeriodicTimer(60000, function() {\n timelineSender.send(usingTLS);\n });\n }\n }\n }\n\n disconnect() {\n this.connection.disconnect();\n\n if (this.timelineSenderTimer) {\n this.timelineSenderTimer.ensureAborted();\n this.timelineSenderTimer = null;\n }\n }\n\n bind(event_name: string, callback: Function, context?: any): Pusher {\n this.global_emitter.bind(event_name, callback, context);\n return this;\n }\n\n unbind(event_name?: string, callback?: Function, context?: any): Pusher {\n this.global_emitter.unbind(event_name, callback, context);\n return this;\n }\n\n bind_global(callback: Function): Pusher {\n this.global_emitter.bind_global(callback);\n return this;\n }\n\n unbind_global(callback?: Function): Pusher {\n this.global_emitter.unbind_global(callback);\n return this;\n }\n\n unbind_all(callback?: Function): Pusher {\n this.global_emitter.unbind_all();\n return this;\n }\n\n subscribeAll() {\n var channelName;\n for (channelName in this.channels.channels) {\n if (this.channels.channels.hasOwnProperty(channelName)) {\n this.subscribe(channelName);\n }\n }\n }\n\n subscribe(channel_name: string) {\n var channel = this.channels.add(channel_name, this);\n if (channel.subscriptionPending && channel.subscriptionCancelled) {\n channel.reinstateSubscription();\n } else if (\n !channel.subscriptionPending &&\n this.connection.state === 'connected'\n ) {\n channel.subscribe();\n }\n return channel;\n }\n\n unsubscribe(channel_name: string) {\n var channel = this.channels.find(channel_name);\n if (channel && channel.subscriptionPending) {\n channel.cancelSubscription();\n } else {\n channel = this.channels.remove(channel_name);\n if (channel && channel.subscribed) {\n channel.unsubscribe();\n }\n }\n }\n\n send_event(event_name: string, data: any, channel?: string) {\n return this.connection.send_event(event_name, data, channel);\n }\n\n shouldUseTLS(): boolean {\n return this.config.useTLS;\n }\n\n signin() {\n this.user.signin();\n }\n}\n\nfunction checkAppKey(key) {\n if (key === null || key === undefined) {\n throw 'You must pass your app key when you instantiate Pusher.';\n }\n}\n\nRuntime.setup(Pusher);\n","import ConnectionManager from './connection/connection_manager';\nimport {\n ChannelAuthorizationOptions,\n UserAuthenticationOptions\n} from './auth/options';\nimport {\n ChannelAuthorizerGenerator,\n DeprecatedAuthOptions\n} from './auth/deprecated_channel_authorizer';\nimport { AuthTransport, Transport } from './config';\nimport * as nacl from 'tweetnacl';\nimport Logger from './logger';\n\nexport interface Options {\n activityTimeout?: number;\n\n auth?: DeprecatedAuthOptions; // DEPRECATED use channelAuthorization instead\n authEndpoint?: string; // DEPRECATED use channelAuthorization instead\n authTransport?: AuthTransport; // DEPRECATED use channelAuthorization instead\n authorizer?: ChannelAuthorizerGenerator; // DEPRECATED use channelAuthorization instead\n\n channelAuthorization?: ChannelAuthorizationOptions;\n userAuthentication?: UserAuthenticationOptions;\n\n cluster: string;\n enableStats?: boolean;\n disableStats?: boolean;\n disabledTransports?: Transport[];\n enabledTransports?: Transport[];\n forceTLS?: boolean;\n httpHost?: string;\n httpPath?: string;\n httpPort?: number;\n httpsPort?: number;\n ignoreNullOrigin?: boolean;\n nacl?: nacl;\n pongTimeout?: number;\n statsHost?: string;\n timelineParams?: any;\n unavailableTimeout?: number;\n wsHost?: string;\n wsPath?: string;\n wsPort?: number;\n wssPort?: number;\n}\n\nexport interface ClusterOptions {\n appKey: string;\n cluster: string;\n}\n\nexport function validateOptions(options) {\n if (options == null) {\n throw 'You must pass an options object';\n }\n if (options.cluster == null) {\n throw 'Options object must provide a cluster';\n }\n if ('disableStats' in options) {\n Logger.warn(\n 'The disableStats option is deprecated in favor of enableStats'\n );\n }\n}\n"],"sourceRoot":""} \ No newline at end of file +{"version":3,"sources":["webpack://Pusher/webpack/universalModuleDefinition","webpack://Pusher/webpack/bootstrap","webpack://Pusher/./node_modules/@stablelib/base64/base64.ts","webpack://Pusher/./node_modules/@stablelib/utf8/utf8.ts","webpack://Pusher/./src/core/pusher.js","webpack://Pusher/./src/runtimes/web/dom/script_receiver_factory.ts","webpack://Pusher/./src/core/defaults.ts","webpack://Pusher/./src/runtimes/web/dom/dependencies.ts","webpack://Pusher/./src/runtimes/web/dom/dependency_loader.ts","webpack://Pusher/./src/core/utils/url_store.ts","webpack://Pusher/./src/core/auth/options.ts","webpack://Pusher/./src/core/errors.ts","webpack://Pusher/./src/runtimes/isomorphic/auth/xhr_auth.ts","webpack://Pusher/./src/core/base64.ts","webpack://Pusher/./src/core/utils/timers/abstract_timer.ts","webpack://Pusher/./src/core/utils/timers/index.ts","webpack://Pusher/./src/core/util.ts","webpack://Pusher/./src/core/utils/collections.ts","webpack://Pusher/./src/core/logger.ts","webpack://Pusher/./src/runtimes/web/auth/jsonp_auth.ts","webpack://Pusher/./src/runtimes/web/dom/script_request.ts","webpack://Pusher/./src/runtimes/web/dom/jsonp_request.ts","webpack://Pusher/./src/runtimes/web/timeline/jsonp_timeline.ts","webpack://Pusher/./src/core/transports/url_schemes.ts","webpack://Pusher/./src/core/events/callback_registry.ts","webpack://Pusher/./src/core/events/dispatcher.ts","webpack://Pusher/./src/core/transports/transport_connection.ts","webpack://Pusher/./src/core/transports/transport.ts","webpack://Pusher/./src/runtimes/isomorphic/transports/transports.ts","webpack://Pusher/./src/runtimes/web/transports/transports.ts","webpack://Pusher/./src/runtimes/web/net_info.ts","webpack://Pusher/./src/core/transports/assistant_to_the_transport_manager.ts","webpack://Pusher/./src/core/connection/protocol/protocol.ts","webpack://Pusher/./src/core/connection/connection.ts","webpack://Pusher/./src/core/connection/handshake/index.ts","webpack://Pusher/./src/core/timeline/timeline_sender.ts","webpack://Pusher/./src/core/channels/channel.ts","webpack://Pusher/./src/core/channels/private_channel.ts","webpack://Pusher/./src/core/channels/members.ts","webpack://Pusher/./src/core/channels/presence_channel.ts","webpack://Pusher/./src/core/channels/encrypted_channel.ts","webpack://Pusher/./src/core/connection/connection_manager.ts","webpack://Pusher/./src/core/channels/channels.ts","webpack://Pusher/./src/core/utils/factory.ts","webpack://Pusher/./src/core/transports/transport_manager.ts","webpack://Pusher/./src/core/strategies/sequential_strategy.ts","webpack://Pusher/./src/core/strategies/best_connected_ever_strategy.ts","webpack://Pusher/./src/core/strategies/websocket_prioritized_cached_strategy.ts","webpack://Pusher/./src/core/strategies/delayed_strategy.ts","webpack://Pusher/./src/core/strategies/if_strategy.ts","webpack://Pusher/./src/core/strategies/first_connected_strategy.ts","webpack://Pusher/./src/runtimes/web/default_strategy.ts","webpack://Pusher/./src/runtimes/web/http/http_xdomain_request.ts","webpack://Pusher/./src/core/http/http_request.ts","webpack://Pusher/./src/core/http/state.ts","webpack://Pusher/./src/core/http/http_socket.ts","webpack://Pusher/./src/core/timeline/level.ts","webpack://Pusher/./src/core/http/http_streaming_socket.ts","webpack://Pusher/./src/core/http/http_polling_socket.ts","webpack://Pusher/./src/runtimes/isomorphic/http/http_xhr_request.ts","webpack://Pusher/./src/runtimes/isomorphic/http/http.ts","webpack://Pusher/./src/runtimes/web/http/http.ts","webpack://Pusher/./src/runtimes/web/runtime.ts","webpack://Pusher/./src/runtimes/web/transports/transport_connection_initializer.ts","webpack://Pusher/./src/core/timeline/timeline.ts","webpack://Pusher/./src/core/strategies/transport_strategy.ts","webpack://Pusher/./src/core/strategies/strategy_builder.ts","webpack://Pusher/./src/core/auth/user_authenticator.ts","webpack://Pusher/./src/core/auth/channel_authorizer.ts","webpack://Pusher/./src/core/auth/deprecated_channel_authorizer.ts","webpack://Pusher/./src/core/config.ts","webpack://Pusher/./src/core/watchlist.ts","webpack://Pusher/./src/core/utils/flat_promise.ts","webpack://Pusher/./src/core/user.ts","webpack://Pusher/./src/core/pusher.ts","webpack://Pusher/./src/core/options.ts"],"names":["root","factory","exports","module","define","amd","window","installedModules","__webpack_require__","moduleId","i","l","modules","call","m","c","d","name","getter","o","Object","defineProperty","enumerable","get","r","Symbol","toStringTag","value","t","mode","__esModule","ns","create","key","bind","n","object","property","prototype","hasOwnProperty","p","s","_paddingCharacter","encodedLength","length","this","encode","data","out","_encodeByte","left","maxDecodedLength","decodedLength","_getPaddingLength","decode","Uint8Array","paddingLength","op","haveBad","v0","v1","v2","v3","_decodeChar","charCodeAt","Error","b","result","String","fromCharCode","Coder","stdCoder","URLSafeCoder","urlSafeCoder","INVALID_UTF8","arr","pos","chars","min","n1","n2","n3","push","join","default","ScriptReceiverFactory","prefix","lastId","callback","number","id","called","callbackWrapper","apply","arguments","receiver","ScriptReceivers","VERSION","PROTOCOL","wsPort","wssPort","wsPath","httpHost","httpPort","httpsPort","httpPath","stats_host","authEndpoint","authTransport","activityTimeout","pongTimeout","unavailableTimeout","userAuthentication","endpoint","transport","channelAuthorization","cdn_http","cdn_https","dependency_suffix","DependenciesReceivers","Dependencies","options","receivers","loading","self","request","createScriptRequest","getPath","error","remove","callbacks","successCallback","wasSuccessful","cleanup","send","protocol","getDocument","location","useTLS","replace","version","getRoot","suffix","urlStore","baseUrl","urls","authenticationEndpoint","path","authorizationEndpoint","javascriptQuickStart","triggeringClientEvents","encryptedChannelSupport","fullUrl","AuthRequestType","urlObj","url","BadEventName","msg","super","setPrototypeOf","BadChannelName","RequestTimedOut","TransportPriorityTooLow","TransportClosed","UnsupportedFeature","UnsupportedTransport","UnsupportedStrategy","HTTPAuthError","status","context","query","authOptions","authRequestType","xhr","createXHR","headerName","open","setRequestHeader","headers","headersProvider","dynamicHeaders","onreadystatechange","readyState","parsed","JSON","parse","responseText","e","toString","UserAuthentication","ChannelAuthorization","b64chars","b64tab","charAt","cb_utob","cc","utob","u","cb_encode","ccc","padlen","ord","btoa","set","clear","delay","timer","clearTimeout","clearInterval","setTimeout","setInterval","now","Date","valueOf","defer","args","boundArguments","Array","slice","concat","extend","target","sources","extensions","constructor","stringify","safeJSONStringify","arrayIndexOf","array","item","nativeIndexOf","indexOf","objectApply","f","keys","_","map","filter","test","filterObject","Boolean","any","encodeParamsObject","encodeURIComponent","buildQueryString","params","undefined","method","source","objects","paths","derez","nu","$ref","globalLog","message","console","log","globalLogWarn","globalLogError","warn","defaultLoggingFunction","logToConsole","callbackName","nextAuthCallbackID","document","script","createElement","auth_callbacks","callback_name","src","head","getElementsByTagName","documentElement","insertBefore","firstChild","ScriptRequest","errorString","type","charset","addEventListener","onerror","onload","async","attachEvent","navigator","userAgent","errorScript","text","nextSibling","parentNode","removeChild","getAgent","sender","host","createJSONPRequest","getGenericURL","baseScheme","hostTLS","hostNonTLS","getGenericPath","queryString","ws","getInitial","http","sockjs","_callbacks","prefixedEventName","fn","names","removeCallback","removeAllCallbacks","binding","failThrough","global_callbacks","eventName","add","unbind","unbind_global","metadata","hooks","priority","initialize","transportConnectionInitializer","state","timeline","generateUniqueID","handlesActivityChecks","supportsPing","socket","getSocket","onError","changeState","bindListeners","debug","close","ping","beforeOpen","onopen","emit","buildTimelineMessage","closeEvent","code","reason","wasClean","unbindListeners","onOpen","onclose","onClose","onmessage","onMessage","onactivity","onActivity","info","cid","environment","isSupported","WSTransport","isInitialized","getWebSocketAPI","createWebSocket","httpConfiguration","streamingConfiguration","HTTPFactory","createStreamingSocket","pollingConfiguration","createPollingSocket","xhrConfiguration","isXHRSupported","xhr_streaming","xhr_polling","SockJSTransport","file","SockJS","js_path","ignore_null_origin","ignoreNullOrigin","xdrConfiguration","isXDRSupported","XDRStreamingTransport","XDRPollingTransport","xdr_streaming","xdr_polling","onLine","manager","minPingDelay","maxPingDelay","pingDelay","connection","createConnection","openTimestamp","onClosed","reportDeath","lifespan","Math","max","isAlive","Protocol","decodeMessage","messageEvent","messageData","pusherEventData","pusherEvent","event","channel","user_id","encodeMessage","processHandshake","activity_timeout","action","socket_id","getCloseAction","getCloseError","send_event","listeners","activity","closed","handleCloseEvent","listener","finish","isEmpty","TimelineTransport","pusher","subscribed","subscriptionPending","subscriptionCancelled","socketId","auth","handleSubscriptionSucceededEvent","handleSubscriptionCountEvent","unsubscribe","subscription_count","subscriptionCount","authorize","assign","channel_data","config","channelAuthorizer","channelName","reset","members","member","myID","subscriptionData","presence","hash","count","me","memberData","user_info","authData","channelData","setMyID","user","signinDonePromise","user_data","handleInternalEvent","addedMember","addMember","removedMember","removeMember","onSubscription","disconnect","nacl","sharedSecret","handleEncryptedEvent","handleEvent","ciphertext","nonce","cipherText","secretbox","overheadLength","nonceLength","bytes","getDataToEmit","raw","usingTLS","errorCallbacks","buildErrorCallbacks","connectionCallbacks","buildConnectionCallbacks","handshakeCallbacks","buildHandshakeCallbacks","Network","getNetwork","netinfo","retryIn","sendActivityCheck","updateStrategy","runner","strategy","updateState","startConnecting","setUnavailableTimer","disconnectInternally","handshake","connect","handshakeError","abortConnecting","abort","clearRetryTimer","clearUnavailableTimer","abandonConnection","getStrategy","round","retryTimer","ensureAborted","unavailableTimer","stopActivityCheck","activityTimer","pong_timed_out","resetActivityCheck","shouldRetry","connected","Infinity","setConnection","withErrorEmitted","tls_only","refused","backoff","retry","newState","previousState","newStateDescription","previous","current","channels","createEncryptedChannel","errMsg","createPrivateChannel","createPresenceChannel","createChannel","values","createChannels","createConnectionManager","createTimelineSender","createHandshake","createAssistantToTheTransportManager","livesLeft","lives","strategies","loop","failFast","timeout","timeoutLimit","minPriority","tryNextStrategy","tryStrategy","forceMinPriority","isRunning","callbackBuilder","runners","rs","abortRunner","allRunnersFailed","aborted","transports","ttl","storage","getLocalStorage","serializedCache","getTransportCacheKey","flushTransportCache","fetchTransportCache","cacheSkipCount","timestamp","includes","cached","latency","startTimestamp","pop","cb","storeTransportCache","IfStrategy","trueBranch","falseBranch","FirstConnectedStrategy","testSupportsStrategy","baseOptions","defineTransport","definedTransports","defineTransportStrategy","wsStrategy","ws_options","wsHost","wss_options","sockjs_options","timeouts","ws_manager","streaming_manager","ws_transport","wss_transport","sockjs_transport","xhr_streaming_transport","xdr_streaming_transport","xhr_polling_transport","xdr_polling_transport","ws_loop","wss_loop","sockjs_loop","streaming_loop","polling_loop","http_loop","http_fallback_loop","getRequest","xdr","XDomainRequest","ontimeout","onprogress","onChunk","abortRequest","payload","position","unloader","addUnloadListener","removeUnloadListener","chunk","advanceBuffer","isBufferTooLong","buffer","unreadData","endOfLinePosition","State","autoIncrement","getUniqueURL","separator","randomNumber","randomInt","TimelineLevel","session","randomString","parts","exec","base","getLocation","CONNECTING","openStream","sendRaw","sendHeartbeat","OPEN","createSocketRequest","start","closeStream","CLOSED","onEvent","onHeartbeat","hostname","urlParts","stream","getReceiveURL","onFinished","reconnect","unbind_all","getXHRAPI","createSocket","createRequest","getDefaultStrategy","Transports","load","XMLHttpRequest","WebSocket","MozWebSocket","PusherClass","Pusher","initializeOnDocumentBody","onDocumentBody","ready","getAuthorizers","ajax","jsonp","body","localStorage","createXMLHttpRequest","createMicrosoftXHR","ActiveXObject","createXDR","Constructor","withCredentials","documentProtocol","getProtocol","removeEventListener","detachEvent","floor","crypto","getRandomValues","Uint32Array","events","sent","uniqueID","level","limit","shift","ERROR","INFO","DEBUG","sendfn","bundle","lib","cluster","features","failAttempt","onInitialized","serializedTransport","transportClass","enabledTransports","disabledTransports","getAssistant","deferred","paramsProvider","dynamicParams","composeChannelQuery","ChannelAuthorizerProxy","channelAuthorizerGenerator","deprecatedAuthorizerOptions","getConfig","opts","statsHost","enableStats","getEnableStatsConfig","getHttpHost","shouldUseTLS","getWebsocketHost","userAuthenticator","buildUserAuthenticator","buildChannelAuthorizer","timelineParams","forceTLS","disableStats","hasCustomHandler","customHandler","authorizer","buildChannelAuth","bindWatchlistInternalEvent","forEach","watchlistEvent","resolve","reject","promise","Promise","res","rej","signin_requested","serverToUserChannel","_signinDoneResolve","_onAuthorize","err","_cleanup","_signin","_newSigninPromiseIfNeeded","watchlist","_onSigninSuccess","_subscribeChannels","bind_global","reinstateSubscription","subscribe","ensure_subscribed","done","setDone","then","catch","isReady","instances","app_key","checkAppKey","validateOptions","global_emitter","sessionID","getClientFeatures","timelineSender","subscribeAll","isUsingTLS","internal","appKey","switchCluster","find","all","timelineSenderTimer","event_name","channel_name","cancelSubscription","signin","Runtime","setup"],"mapp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AAUvW,KAAKie,SAAS7Y,OAAOyoB,KAChBtX,EAAQmB,YACrBnB,EAAQ0B,cAKd,WAAW2V,EAAoB1tB,EAAWqW,GACxC,OAAOvW,KAAKuV,WAAWyB,WAAW4W,EAAY1tB,EAAMqW,GAGtD,eACE,OAAOvW,KAAKuY,OAAO1S,OAGrB,SACE7F,KAAKwZ,KAAKuU,UAvOL,GAAAnB,UAAsB,GACtB,GAAAD,SAAmB,EACnB,GAAAlf,cAAwB,EAGxB,GAAAugB,QAA2B,GAC3B,GAAA7qB,gBAA6B,GAASA,gBACtC,GAAAuB,sBAAmC,GAASA,sBAC5C,GAAAqJ,eAA4B,GAASA,eAVzB,oBAmPrB,GAAQkgB,MAAM","file":"pusher.min.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"Pusher\"] = factory();\n\telse\n\t\troot[\"Pusher\"] = factory();\n})(window, function() {\nreturn "," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 2);\n","// Copyright (C) 2016 Dmitry Chestnykh\n// MIT License. See LICENSE file for details.\n\n/**\n * Package base64 implements Base64 encoding and decoding.\n */\n\n// Invalid character used in decoding to indicate\n// that the character to decode is out of range of\n// alphabet and cannot be decoded.\nconst INVALID_BYTE = 256;\n\n/**\n * Implements standard Base64 encoding.\n *\n * Operates in constant time.\n */\nexport class Coder {\n // TODO(dchest): methods to encode chunk-by-chunk.\n\n constructor(private _paddingCharacter = \"=\") { }\n\n encodedLength(length: number): number {\n if (!this._paddingCharacter) {\n return (length * 8 + 5) / 6 | 0;\n }\n return (length + 2) / 3 * 4 | 0;\n }\n\n encode(data: Uint8Array): string {\n let out = \"\";\n\n let i = 0;\n for (; i < data.length - 2; i += 3) {\n let c = (data[i] << 16) | (data[i + 1] << 8) | (data[i + 2]);\n out += this._encodeByte((c >>> 3 * 6) & 63);\n out += this._encodeByte((c >>> 2 * 6) & 63);\n out += this._encodeByte((c >>> 1 * 6) & 63);\n out += this._encodeByte((c >>> 0 * 6) & 63);\n }\n\n const left = data.length - i;\n if (left > 0) {\n let c = (data[i] << 16) | (left === 2 ? data[i + 1] << 8 : 0);\n out += this._encodeByte((c >>> 3 * 6) & 63);\n out += this._encodeByte((c >>> 2 * 6) & 63);\n if (left === 2) {\n out += this._encodeByte((c >>> 1 * 6) & 63);\n } else {\n out += this._paddingCharacter || \"\";\n }\n out += this._paddingCharacter || \"\";\n }\n\n return out;\n }\n\n maxDecodedLength(length: number): number {\n if (!this._paddingCharacter) {\n return (length * 6 + 7) / 8 | 0;\n }\n return length / 4 * 3 | 0;\n }\n\n decodedLength(s: string): number {\n return this.maxDecodedLength(s.length - this._getPaddingLength(s));\n }\n\n decode(s: string): Uint8Array {\n if (s.length === 0) {\n return new Uint8Array(0);\n }\n const paddingLength = this._getPaddingLength(s);\n const length = s.length - paddingLength;\n const out = new Uint8Array(this.maxDecodedLength(length));\n let op = 0;\n let i = 0;\n let haveBad = 0;\n let v0 = 0, v1 = 0, v2 = 0, v3 = 0;\n for (; i < length - 4; i += 4) {\n v0 = this._decodeChar(s.charCodeAt(i + 0));\n v1 = this._decodeChar(s.charCodeAt(i + 1));\n v2 = this._decodeChar(s.charCodeAt(i + 2));\n v3 = this._decodeChar(s.charCodeAt(i + 3));\n out[op++] = (v0 << 2) | (v1 >>> 4);\n out[op++] = (v1 << 4) | (v2 >>> 2);\n out[op++] = (v2 << 6) | v3;\n haveBad |= v0 & INVALID_BYTE;\n haveBad |= v1 & INVALID_BYTE;\n haveBad |= v2 & INVALID_BYTE;\n haveBad |= v3 & INVALID_BYTE;\n }\n if (i < length - 1) {\n v0 = this._decodeChar(s.charCodeAt(i));\n v1 = this._decodeChar(s.charCodeAt(i + 1));\n out[op++] = (v0 << 2) | (v1 >>> 4);\n haveBad |= v0 & INVALID_BYTE;\n haveBad |= v1 & INVALID_BYTE;\n }\n if (i < length - 2) {\n v2 = this._decodeChar(s.charCodeAt(i + 2));\n out[op++] = (v1 << 4) | (v2 >>> 2);\n haveBad |= v2 & INVALID_BYTE;\n }\n if (i < length - 3) {\n v3 = this._decodeChar(s.charCodeAt(i + 3));\n out[op++] = (v2 << 6) | v3;\n haveBad |= v3 & INVALID_BYTE;\n }\n if (haveBad !== 0) {\n throw new Error(\"Base64Coder: incorrect characters for decoding\");\n }\n return out;\n }\n\n // Standard encoding have the following encoded/decoded ranges,\n // which we need to convert between.\n //\n // ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 0123456789 + /\n // Index: 0 - 25 26 - 51 52 - 61 62 63\n // ASCII: 65 - 90 97 - 122 48 - 57 43 47\n //\n\n // Encode 6 bits in b into a new character.\n protected _encodeByte(b: number): string {\n // Encoding uses constant time operations as follows:\n //\n // 1. Define comparison of A with B using (A - B) >>> 8:\n // if A > B, then result is positive integer\n // if A <= B, then result is 0\n //\n // 2. Define selection of C or 0 using bitwise AND: X & C:\n // if X == 0, then result is 0\n // if X != 0, then result is C\n //\n // 3. Start with the smallest comparison (b >= 0), which is always\n // true, so set the result to the starting ASCII value (65).\n //\n // 4. Continue comparing b to higher ASCII values, and selecting\n // zero if comparison isn't true, otherwise selecting a value\n // to add to result, which:\n //\n // a) undoes the previous addition\n // b) provides new value to add\n //\n let result = b;\n // b >= 0\n result += 65;\n // b > 25\n result += ((25 - b) >>> 8) & ((0 - 65) - 26 + 97);\n // b > 51\n result += ((51 - b) >>> 8) & ((26 - 97) - 52 + 48);\n // b > 61\n result += ((61 - b) >>> 8) & ((52 - 48) - 62 + 43);\n // b > 62\n result += ((62 - b) >>> 8) & ((62 - 43) - 63 + 47);\n\n return String.fromCharCode(result);\n }\n\n // Decode a character code into a byte.\n // Must return 256 if character is out of alphabet range.\n protected _decodeChar(c: number): number {\n // Decoding works similar to encoding: using the same comparison\n // function, but now it works on ranges: result is always incremented\n // by value, but this value becomes zero if the range is not\n // satisfied.\n //\n // Decoding starts with invalid value, 256, which is then\n // subtracted when the range is satisfied. If none of the ranges\n // apply, the function returns 256, which is then checked by\n // the caller to throw error.\n let result = INVALID_BYTE; // start with invalid character\n\n // c == 43 (c > 42 and c < 44)\n result += (((42 - c) & (c - 44)) >>> 8) & (-INVALID_BYTE + c - 43 + 62);\n // c == 47 (c > 46 and c < 48)\n result += (((46 - c) & (c - 48)) >>> 8) & (-INVALID_BYTE + c - 47 + 63);\n // c > 47 and c < 58\n result += (((47 - c) & (c - 58)) >>> 8) & (-INVALID_BYTE + c - 48 + 52);\n // c > 64 and c < 91\n result += (((64 - c) & (c - 91)) >>> 8) & (-INVALID_BYTE + c - 65 + 0);\n // c > 96 and c < 123\n result += (((96 - c) & (c - 123)) >>> 8) & (-INVALID_BYTE + c - 97 + 26);\n\n return result;\n }\n\n private _getPaddingLength(s: string): number {\n let paddingLength = 0;\n if (this._paddingCharacter) {\n for (let i = s.length - 1; i >= 0; i--) {\n if (s[i] !== this._paddingCharacter) {\n break;\n }\n paddingLength++;\n }\n if (s.length < 4 || paddingLength > 2) {\n throw new Error(\"Base64Coder: incorrect padding\");\n }\n }\n return paddingLength;\n }\n\n}\n\nconst stdCoder = new Coder();\n\nexport function encode(data: Uint8Array): string {\n return stdCoder.encode(data);\n}\n\nexport function decode(s: string): Uint8Array {\n return stdCoder.decode(s);\n}\n\n/**\n * Implements URL-safe Base64 encoding.\n * (Same as Base64, but '+' is replaced with '-', and '/' with '_').\n *\n * Operates in constant time.\n */\nexport class URLSafeCoder extends Coder {\n // URL-safe encoding have the following encoded/decoded ranges:\n //\n // ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 0123456789 - _\n // Index: 0 - 25 26 - 51 52 - 61 62 63\n // ASCII: 65 - 90 97 - 122 48 - 57 45 95\n //\n\n protected _encodeByte(b: number): string {\n let result = b;\n // b >= 0\n result += 65;\n // b > 25\n result += ((25 - b) >>> 8) & ((0 - 65) - 26 + 97);\n // b > 51\n result += ((51 - b) >>> 8) & ((26 - 97) - 52 + 48);\n // b > 61\n result += ((61 - b) >>> 8) & ((52 - 48) - 62 + 45);\n // b > 62\n result += ((62 - b) >>> 8) & ((62 - 45) - 63 + 95);\n\n return String.fromCharCode(result);\n }\n\n protected _decodeChar(c: number): number {\n let result = INVALID_BYTE;\n\n // c == 45 (c > 44 and c < 46)\n result += (((44 - c) & (c - 46)) >>> 8) & (-INVALID_BYTE + c - 45 + 62);\n // c == 95 (c > 94 and c < 96)\n result += (((94 - c) & (c - 96)) >>> 8) & (-INVALID_BYTE + c - 95 + 63);\n // c > 47 and c < 58\n result += (((47 - c) & (c - 58)) >>> 8) & (-INVALID_BYTE + c - 48 + 52);\n // c > 64 and c < 91\n result += (((64 - c) & (c - 91)) >>> 8) & (-INVALID_BYTE + c - 65 + 0);\n // c > 96 and c < 123\n result += (((96 - c) & (c - 123)) >>> 8) & (-INVALID_BYTE + c - 97 + 26);\n\n return result;\n }\n}\n\nconst urlSafeCoder = new URLSafeCoder();\n\nexport function encodeURLSafe(data: Uint8Array): string {\n return urlSafeCoder.encode(data);\n}\n\nexport function decodeURLSafe(s: string): Uint8Array {\n return urlSafeCoder.decode(s);\n}\n\n\nexport const encodedLength = (length: number) =>\n stdCoder.encodedLength(length);\n\nexport const maxDecodedLength = (length: number) =>\n stdCoder.maxDecodedLength(length);\n\nexport const decodedLength = (s: string) =>\n stdCoder.decodedLength(s);\n","// Copyright (C) 2016 Dmitry Chestnykh\n// MIT License. See LICENSE file for details.\n\n/**\n * Package utf8 implements UTF-8 encoding and decoding.\n */\n\nconst INVALID_UTF16 = \"utf8: invalid string\";\nconst INVALID_UTF8 = \"utf8: invalid source encoding\";\n\n/**\n * Encodes the given string into UTF-8 byte array.\n * Throws if the source string has invalid UTF-16 encoding.\n */\nexport function encode(s: string): Uint8Array {\n // Calculate result length and allocate output array.\n // encodedLength() also validates string and throws errors,\n // so we don't need repeat validation here.\n const arr = new Uint8Array(encodedLength(s));\n\n let pos = 0;\n for (let i = 0; i < s.length; i++) {\n let c = s.charCodeAt(i);\n if (c < 0x80) {\n arr[pos++] = c;\n } else if (c < 0x800) {\n arr[pos++] = 0xc0 | c >> 6;\n arr[pos++] = 0x80 | c & 0x3f;\n } else if (c < 0xd800) {\n arr[pos++] = 0xe0 | c >> 12;\n arr[pos++] = 0x80 | (c >> 6) & 0x3f;\n arr[pos++] = 0x80 | c & 0x3f;\n } else {\n i++; // get one more character\n c = (c & 0x3ff) << 10;\n c |= s.charCodeAt(i) & 0x3ff;\n c += 0x10000;\n\n arr[pos++] = 0xf0 | c >> 18;\n arr[pos++] = 0x80 | (c >> 12) & 0x3f;\n arr[pos++] = 0x80 | (c >> 6) & 0x3f;\n arr[pos++] = 0x80 | c & 0x3f;\n }\n }\n return arr;\n}\n\n/**\n * Returns the number of bytes required to encode the given string into UTF-8.\n * Throws if the source string has invalid UTF-16 encoding.\n */\nexport function encodedLength(s: string): number {\n let result = 0;\n for (let i = 0; i < s.length; i++) {\n const c = s.charCodeAt(i);\n if (c < 0x80) {\n result += 1;\n } else if (c < 0x800) {\n result += 2;\n } else if (c < 0xd800) {\n result += 3;\n } else if (c <= 0xdfff) {\n if (i >= s.length - 1) {\n throw new Error(INVALID_UTF16);\n }\n i++; // \"eat\" next character\n result += 4;\n } else {\n throw new Error(INVALID_UTF16);\n }\n }\n return result;\n}\n\n/**\n * Decodes the given byte array from UTF-8 into a string.\n * Throws if encoding is invalid.\n */\nexport function decode(arr: Uint8Array): string {\n const chars: string[] = [];\n for (let i = 0; i < arr.length; i++) {\n let b = arr[i];\n\n if (b & 0x80) {\n let min;\n if (b < 0xe0) {\n // Need 1 more byte.\n if (i >= arr.length) {\n throw new Error(INVALID_UTF8);\n }\n const n1 = arr[++i];\n if ((n1 & 0xc0) !== 0x80) {\n throw new Error(INVALID_UTF8);\n }\n b = (b & 0x1f) << 6 | (n1 & 0x3f);\n min = 0x80;\n } else if (b < 0xf0) {\n // Need 2 more bytes.\n if (i >= arr.length - 1) {\n throw new Error(INVALID_UTF8);\n }\n const n1 = arr[++i];\n const n2 = arr[++i];\n if ((n1 & 0xc0) !== 0x80 || (n2 & 0xc0) !== 0x80) {\n throw new Error(INVALID_UTF8);\n }\n b = (b & 0x0f) << 12 | (n1 & 0x3f) << 6 | (n2 & 0x3f);\n min = 0x800;\n } else if (b < 0xf8) {\n // Need 3 more bytes.\n if (i >= arr.length - 2) {\n throw new Error(INVALID_UTF8);\n }\n const n1 = arr[++i];\n const n2 = arr[++i];\n const n3 = arr[++i];\n if ((n1 & 0xc0) !== 0x80 || (n2 & 0xc0) !== 0x80 || (n3 & 0xc0) !== 0x80) {\n throw new Error(INVALID_UTF8);\n }\n b = (b & 0x0f) << 18 | (n1 & 0x3f) << 12 | (n2 & 0x3f) << 6 | (n3 & 0x3f);\n min = 0x10000;\n } else {\n throw new Error(INVALID_UTF8);\n }\n\n if (b < min || (b >= 0xd800 && b <= 0xdfff)) {\n throw new Error(INVALID_UTF8);\n }\n\n if (b >= 0x10000) {\n // Surrogate pair.\n if (b > 0x10ffff) {\n throw new Error(INVALID_UTF8);\n }\n b -= 0x10000;\n chars.push(String.fromCharCode(0xd800 | (b >> 10)));\n b = 0xdc00 | (b & 0x3ff);\n }\n }\n\n chars.push(String.fromCharCode(b));\n }\n return chars.join(\"\");\n}\n","// required so we don't have to do require('pusher').default etc.\nmodule.exports = require('./pusher').default;\n","import ScriptReceiver from './script_receiver';\n\n/** Builds receivers for JSONP and Script requests.\n *\n * Each receiver is an object with following fields:\n * - number - unique (for the factory instance), numerical id of the receiver\n * - id - a string ID that can be used in DOM attributes\n * - name - name of the function triggering the receiver\n * - callback - callback function\n *\n * Receivers are triggered only once, on the first callback call.\n *\n * Receivers can be called by their name or by accessing factory object\n * by the number key.\n *\n * @param {String} prefix the prefix used in ids\n * @param {String} name the name of the object\n */\nexport class ScriptReceiverFactory {\n lastId: number;\n prefix: string;\n name: string;\n\n constructor(prefix: string, name: string) {\n this.lastId = 0;\n this.prefix = prefix;\n this.name = name;\n }\n\n create(callback: Function): ScriptReceiver {\n this.lastId++;\n\n var number = this.lastId;\n var id = this.prefix + number;\n var name = this.name + '[' + number + ']';\n\n var called = false;\n var callbackWrapper = function() {\n if (!called) {\n callback.apply(null, arguments);\n called = true;\n }\n };\n\n this[number] = callbackWrapper;\n return { number: number, id: id, name: name, callback: callbackWrapper };\n }\n\n remove(receiver: ScriptReceiver) {\n delete this[receiver.number];\n }\n}\n\nexport var ScriptReceivers = new ScriptReceiverFactory(\n '_pusher_script_',\n 'Pusher.ScriptReceivers'\n);\n","import {\n ChannelAuthorizationOptions,\n UserAuthenticationOptions\n} from './auth/options';\nimport { AuthTransport } from './config';\n\nexport interface DefaultConfig {\n VERSION: string;\n PROTOCOL: number;\n wsPort: number;\n wssPort: number;\n wsPath: string;\n httpHost: string;\n httpPort: number;\n httpsPort: number;\n httpPath: string;\n stats_host: string;\n authEndpoint: string;\n authTransport: AuthTransport;\n activityTimeout: number;\n pongTimeout: number;\n unavailableTimeout: number;\n userAuthentication: UserAuthenticationOptions;\n channelAuthorization: ChannelAuthorizationOptions;\n\n cdn_http?: string;\n cdn_https?: string;\n dependency_suffix?: string;\n}\n\nvar Defaults: DefaultConfig = {\n VERSION: VERSION,\n PROTOCOL: 7,\n\n wsPort: 80,\n wssPort: 443,\n wsPath: '',\n // DEPRECATED: SockJS fallback parameters\n httpHost: 'sockjs.pusher.com',\n httpPort: 80,\n httpsPort: 443,\n httpPath: '/pusher',\n // DEPRECATED: Stats\n stats_host: 'stats.pusher.com',\n // DEPRECATED: Other settings\n authEndpoint: '/pusher/auth',\n authTransport: 'ajax',\n activityTimeout: 120000,\n pongTimeout: 30000,\n unavailableTimeout: 10000,\n userAuthentication: {\n endpoint: '/pusher/user-auth',\n transport: 'ajax'\n },\n channelAuthorization: {\n endpoint: '/pusher/auth',\n transport: 'ajax'\n },\n\n // CDN configuration\n cdn_http: CDN_HTTP,\n cdn_https: CDN_HTTPS,\n dependency_suffix: DEPENDENCY_SUFFIX\n};\n\nexport default Defaults;\n","import { ScriptReceiverFactory } from './script_receiver_factory';\nimport Defaults from 'core/defaults';\nimport DependencyLoader from './dependency_loader';\n\nexport var DependenciesReceivers = new ScriptReceiverFactory(\n '_pusher_dependencies',\n 'Pusher.DependenciesReceivers'\n);\n\nexport var Dependencies = new DependencyLoader({\n cdn_http: Defaults.cdn_http,\n cdn_https: Defaults.cdn_https,\n version: Defaults.VERSION,\n suffix: Defaults.dependency_suffix,\n receivers: DependenciesReceivers\n});\n","import {\n ScriptReceivers,\n ScriptReceiverFactory\n} from './script_receiver_factory';\nimport Runtime from 'runtime';\nimport ScriptRequest from './script_request';\n\n/** Handles loading dependency files.\n *\n * Dependency loaders don't remember whether a resource has been loaded or\n * not. It is caller's responsibility to make sure the resource is not loaded\n * twice. This is because it's impossible to detect resource loading status\n * without knowing its content.\n *\n * Options:\n * - cdn_http - url to HTTP CND\n * - cdn_https - url to HTTPS CDN\n * - version - version of pusher-js\n * - suffix - suffix appended to all names of dependency files\n *\n * @param {Object} options\n */\nexport default class DependencyLoader {\n options: any;\n receivers: ScriptReceiverFactory;\n loading: any;\n\n constructor(options: any) {\n this.options = options;\n this.receivers = options.receivers || ScriptReceivers;\n this.loading = {};\n }\n\n /** Loads the dependency from CDN.\n *\n * @param {String} name\n * @param {Function} callback\n */\n load(name: string, options: any, callback: Function) {\n var self = this;\n\n if (self.loading[name] && self.loading[name].length > 0) {\n self.loading[name].push(callback);\n } else {\n self.loading[name] = [callback];\n\n var request = Runtime.createScriptRequest(self.getPath(name, options));\n var receiver = self.receivers.create(function(error) {\n self.receivers.remove(receiver);\n\n if (self.loading[name]) {\n var callbacks = self.loading[name];\n delete self.loading[name];\n\n var successCallback = function(wasSuccessful) {\n if (!wasSuccessful) {\n request.cleanup();\n }\n };\n for (var i = 0; i < callbacks.length; i++) {\n callbacks[i](error, successCallback);\n }\n }\n });\n request.send(receiver);\n }\n }\n\n /** Returns a root URL for pusher-js CDN.\n *\n * @returns {String}\n */\n getRoot(options: any): string {\n var cdn;\n var protocol = Runtime.getDocument().location.protocol;\n if ((options && options.useTLS) || protocol === 'https:') {\n cdn = this.options.cdn_https;\n } else {\n cdn = this.options.cdn_http;\n }\n // make sure there are no double slashes\n return cdn.replace(/\\/*$/, '') + '/' + this.options.version;\n }\n\n /** Returns a full path to a dependency file.\n *\n * @param {String} name\n * @returns {String}\n */\n getPath(name: string, options: any): string {\n return this.getRoot(options) + '/' + name + this.options.suffix + '.js';\n }\n}\n","/**\n * A place to store help URLs for error messages etc\n */\n\nconst urlStore = {\n baseUrl: 'https://pusher.com',\n urls: {\n authenticationEndpoint: {\n path: '/docs/channels/server_api/authenticating_users'\n },\n authorizationEndpoint: {\n path: '/docs/channels/server_api/authorizing-users/'\n },\n javascriptQuickStart: {\n path: '/docs/javascript_quick_start'\n },\n triggeringClientEvents: {\n path: '/docs/client_api_guide/client_events#trigger-events'\n },\n encryptedChannelSupport: {\n fullUrl:\n 'https://github.com/pusher/pusher-js/tree/cc491015371a4bde5743d1c87a0fbac0feb53195#encrypted-channel-support'\n }\n }\n};\n\n/** Builds a consistent string with links to pusher documentation\n *\n * @param {string} key - relevant key in the url_store.urls object\n * @return {string} suffix string to append to log message\n */\nconst buildLogSuffix = function(key: string): string {\n const urlPrefix = 'See:';\n const urlObj = urlStore.urls[key];\n if (!urlObj) return '';\n\n let url;\n if (urlObj.fullUrl) {\n url = urlObj.fullUrl;\n } else if (urlObj.path) {\n url = urlStore.baseUrl + urlObj.path;\n }\n\n if (!url) return '';\n return `${urlPrefix} ${url}`;\n};\n\nexport default { buildLogSuffix };\n","export enum AuthRequestType {\n UserAuthentication = 'user-authentication',\n ChannelAuthorization = 'channel-authorization'\n}\n\nexport interface ChannelAuthorizationData {\n auth: string;\n channel_data?: string;\n shared_secret?: string;\n}\n\nexport type ChannelAuthorizationCallback = (\n error: Error | null,\n authData: ChannelAuthorizationData | null\n) => void;\n\nexport interface ChannelAuthorizationRequestParams {\n socketId: string;\n channelName: string;\n}\n\nexport interface ChannelAuthorizationHandler {\n (\n params: ChannelAuthorizationRequestParams,\n callback: ChannelAuthorizationCallback\n ): void;\n}\n\nexport interface UserAuthenticationData {\n auth: string;\n user_data: string;\n}\n\nexport type UserAuthenticationCallback = (\n error: Error | null,\n authData: UserAuthenticationData | null\n) => void;\n\nexport interface UserAuthenticationRequestParams {\n socketId: string;\n}\n\nexport interface UserAuthenticationHandler {\n (\n params: UserAuthenticationRequestParams,\n callback: UserAuthenticationCallback\n ): void;\n}\n\nexport type AuthTransportCallback =\n | ChannelAuthorizationCallback\n | UserAuthenticationCallback;\n\nexport interface InternalAuthOptions {\n transport: 'ajax' | 'jsonp';\n endpoint: string;\n params?: any;\n headers?: any;\n paramsProvider?: () => any;\n headersProvider?: () => any;\n}\n\nexport type CustomAuthOptions = {\n customHandler: AuthHandler;\n};\n\nexport type AuthOptionsT =\n | InternalAuthOptions\n | CustomAuthOptions;\n\nexport declare type UserAuthenticationOptions = AuthOptionsT<\n UserAuthenticationHandler\n>;\nexport declare type ChannelAuthorizationOptions = AuthOptionsT<\n ChannelAuthorizationHandler\n>;\n","/** Error classes used throughout the library. */\n// https://github.com/Microsoft/TypeScript-wiki/blob/master/Breaking-Changes.md#extending-built-ins-like-error-array-and-map-may-no-longer-work\nexport class BadEventName extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\nexport class BadChannelName extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\nexport class RequestTimedOut extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class TransportPriorityTooLow extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class TransportClosed extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class UnsupportedFeature extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class UnsupportedTransport extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class UnsupportedStrategy extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class HTTPAuthError extends Error {\n status: number;\n constructor(status: number, msg?: string) {\n super(msg);\n this.status = status;\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n","import TimelineSender from 'core/timeline/timeline_sender';\nimport * as Collections from 'core/utils/collections';\nimport Util from 'core/util';\nimport Runtime from 'runtime';\nimport { AuthTransport } from 'core/auth/auth_transports';\nimport AbstractRuntime from 'runtimes/interface';\nimport UrlStore from 'core/utils/url_store';\nimport {\n AuthRequestType,\n AuthTransportCallback,\n InternalAuthOptions\n} from 'core/auth/options';\nimport { HTTPAuthError } from 'core/errors';\n\nconst ajax: AuthTransport = function(\n context: AbstractRuntime,\n query: string,\n authOptions: InternalAuthOptions,\n authRequestType: AuthRequestType,\n callback: AuthTransportCallback\n) {\n const xhr = Runtime.createXHR();\n xhr.open('POST', authOptions.endpoint, true);\n\n // add request headers\n xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');\n for (var headerName in authOptions.headers) {\n xhr.setRequestHeader(headerName, authOptions.headers[headerName]);\n }\n if (authOptions.headersProvider != null) {\n let dynamicHeaders = authOptions.headersProvider();\n for (var headerName in dynamicHeaders) {\n xhr.setRequestHeader(headerName, dynamicHeaders[headerName]);\n }\n }\n\n xhr.onreadystatechange = function() {\n if (xhr.readyState === 4) {\n if (xhr.status === 200) {\n let data;\n let parsed = false;\n\n try {\n data = JSON.parse(xhr.responseText);\n parsed = true;\n } catch (e) {\n callback(\n new HTTPAuthError(\n 200,\n `JSON returned from ${authRequestType.toString()} endpoint was invalid, yet status code was 200. Data was: ${\n xhr.responseText\n }`\n ),\n null\n );\n }\n\n if (parsed) {\n // prevents double execution.\n callback(null, data);\n }\n } else {\n let suffix = '';\n switch (authRequestType) {\n case AuthRequestType.UserAuthentication:\n suffix = UrlStore.buildLogSuffix('authenticationEndpoint');\n break;\n case AuthRequestType.ChannelAuthorization:\n suffix = `Clients must be authorized to join private or presence channels. ${UrlStore.buildLogSuffix(\n 'authorizationEndpoint'\n )}`;\n break;\n }\n callback(\n new HTTPAuthError(\n xhr.status,\n `Unable to retrieve auth string from ${authRequestType.toString()} endpoint - ` +\n `received status: ${xhr.status} from ${authOptions.endpoint}. ${suffix}`\n ),\n null\n );\n }\n }\n };\n\n xhr.send(query);\n return xhr;\n};\n\nexport default ajax;\n","export default function encode(s: any): string {\n return btoa(utob(s));\n}\n\nvar fromCharCode = String.fromCharCode;\n\nvar b64chars =\n 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';\nvar b64tab = {};\n\nfor (var i = 0, l = b64chars.length; i < l; i++) {\n b64tab[b64chars.charAt(i)] = i;\n}\n\nvar cb_utob = function(c) {\n var cc = c.charCodeAt(0);\n return cc < 0x80\n ? c\n : cc < 0x800\n ? fromCharCode(0xc0 | (cc >>> 6)) + fromCharCode(0x80 | (cc & 0x3f))\n : fromCharCode(0xe0 | ((cc >>> 12) & 0x0f)) +\n fromCharCode(0x80 | ((cc >>> 6) & 0x3f)) +\n fromCharCode(0x80 | (cc & 0x3f));\n};\n\nvar utob = function(u) {\n return u.replace(/[^\\x00-\\x7F]/g, cb_utob);\n};\n\nvar cb_encode = function(ccc) {\n var padlen = [0, 2, 1][ccc.length % 3];\n var ord =\n (ccc.charCodeAt(0) << 16) |\n ((ccc.length > 1 ? ccc.charCodeAt(1) : 0) << 8) |\n (ccc.length > 2 ? ccc.charCodeAt(2) : 0);\n var chars = [\n b64chars.charAt(ord >>> 18),\n b64chars.charAt((ord >>> 12) & 63),\n padlen >= 2 ? '=' : b64chars.charAt((ord >>> 6) & 63),\n padlen >= 1 ? '=' : b64chars.charAt(ord & 63)\n ];\n return chars.join('');\n};\n\nvar btoa =\n global.btoa ||\n function(b) {\n return b.replace(/[\\s\\S]{1,3}/g, cb_encode);\n };\n","import TimedCallback from './timed_callback';\nimport { Delay, Scheduler, Canceller } from './scheduling';\n\nabstract class Timer {\n protected clear: Canceller;\n protected timer: number | void;\n\n constructor(\n set: Scheduler,\n clear: Canceller,\n delay: Delay,\n callback: TimedCallback\n ) {\n this.clear = clear;\n this.timer = set(() => {\n if (this.timer) {\n this.timer = callback(this.timer);\n }\n }, delay);\n }\n\n /** Returns whether the timer is still running.\n *\n * @return {Boolean}\n */\n isRunning(): boolean {\n return this.timer !== null;\n }\n\n /** Aborts a timer when it's running. */\n ensureAborted() {\n if (this.timer) {\n this.clear(this.timer);\n this.timer = null;\n }\n }\n}\n\nexport default Timer;\n","import Timer from './abstract_timer';\nimport TimedCallback from './timed_callback';\nimport { Delay } from './scheduling';\n\n// We need to bind clear functions this way to avoid exceptions on IE8\nfunction clearTimeout(timer) {\n global.clearTimeout(timer);\n}\nfunction clearInterval(timer) {\n global.clearInterval(timer);\n}\n\n/** Cross-browser compatible one-off timer abstraction.\n *\n * @param {Number} delay\n * @param {Function} callback\n */\nexport class OneOffTimer extends Timer {\n constructor(delay: Delay, callback: TimedCallback) {\n super(setTimeout, clearTimeout, delay, function(timer) {\n callback();\n return null;\n });\n }\n}\n\n/** Cross-browser compatible periodic timer abstraction.\n *\n * @param {Number} delay\n * @param {Function} callback\n */\nexport class PeriodicTimer extends Timer {\n constructor(delay: Delay, callback: TimedCallback) {\n super(setInterval, clearInterval, delay, function(timer) {\n callback();\n return timer;\n });\n }\n}\n","import * as Collections from './utils/collections';\nimport TimedCallback from './utils/timers/timed_callback';\nimport { OneOffTimer, PeriodicTimer } from './utils/timers';\n\nvar Util = {\n now(): number {\n if (Date.now) {\n return Date.now();\n } else {\n return new Date().valueOf();\n }\n },\n\n defer(callback: TimedCallback): OneOffTimer {\n return new OneOffTimer(0, callback);\n },\n\n /** Builds a function that will proxy a method call to its first argument.\n *\n * Allows partial application of arguments, so additional arguments are\n * prepended to the argument list.\n *\n * @param {String} name method name\n * @return {Function} proxy function\n */\n method(name: string, ...args: any[]): Function {\n var boundArguments = Array.prototype.slice.call(arguments, 1);\n return function(object) {\n return object[name].apply(object, boundArguments.concat(arguments));\n };\n }\n};\n\nexport default Util;\n","import base64encode from '../base64';\nimport Util from '../util';\n\n/** Merges multiple objects into the target argument.\n *\n * For properties that are plain Objects, performs a deep-merge. For the\n * rest it just copies the value of the property.\n *\n * To extend prototypes use it as following:\n * Pusher.Util.extend(Target.prototype, Base.prototype)\n *\n * You can also use it to merge objects without altering them:\n * Pusher.Util.extend({}, object1, object2)\n *\n * @param {Object} target\n * @return {Object} the target argument\n */\nexport function extend(target: any, ...sources: any[]): T {\n for (var i = 0; i < sources.length; i++) {\n var extensions = sources[i];\n for (var property in extensions) {\n if (\n extensions[property] &&\n extensions[property].constructor &&\n extensions[property].constructor === Object\n ) {\n target[property] = extend(target[property] || {}, extensions[property]);\n } else {\n target[property] = extensions[property];\n }\n }\n }\n return target;\n}\n\nexport function stringify(): string {\n var m = ['Pusher'];\n for (var i = 0; i < arguments.length; i++) {\n if (typeof arguments[i] === 'string') {\n m.push(arguments[i]);\n } else {\n m.push(safeJSONStringify(arguments[i]));\n }\n }\n return m.join(' : ');\n}\n\nexport function arrayIndexOf(array: any[], item: any): number {\n // MSIE doesn't have array.indexOf\n var nativeIndexOf = Array.prototype.indexOf;\n if (array === null) {\n return -1;\n }\n if (nativeIndexOf && array.indexOf === nativeIndexOf) {\n return array.indexOf(item);\n }\n for (var i = 0, l = array.length; i < l; i++) {\n if (array[i] === item) {\n return i;\n }\n }\n return -1;\n}\n\n/** Applies a function f to all properties of an object.\n *\n * Function f gets 3 arguments passed:\n * - element from the object\n * - key of the element\n * - reference to the object\n *\n * @param {Object} object\n * @param {Function} f\n */\nexport function objectApply(object: any, f: Function) {\n for (var key in object) {\n if (Object.prototype.hasOwnProperty.call(object, key)) {\n f(object[key], key, object);\n }\n }\n}\n\n/** Return a list of objects own proerty keys\n *\n * @param {Object} object\n * @returns {Array}\n */\nexport function keys(object: any): string[] {\n var keys = [];\n objectApply(object, function(_, key) {\n keys.push(key);\n });\n return keys;\n}\n\n/** Return a list of object's own property values\n *\n * @param {Object} object\n * @returns {Array}\n */\nexport function values(object: any): any[] {\n var values = [];\n objectApply(object, function(value) {\n values.push(value);\n });\n return values;\n}\n\n/** Applies a function f to all elements of an array.\n *\n * Function f gets 3 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function apply(array: any[], f: Function, context?: any) {\n for (var i = 0; i < array.length; i++) {\n f.call(context || global, array[i], i, array);\n }\n}\n\n/** Maps all elements of the array and returns the result.\n *\n * Function f gets 4 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n * - reference to the destination array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function map(array: any[], f: Function): any[] {\n var result = [];\n for (var i = 0; i < array.length; i++) {\n result.push(f(array[i], i, array, result));\n }\n return result;\n}\n\n/** Maps all elements of the object and returns the result.\n *\n * Function f gets 4 arguments passed:\n * - element from the object\n * - key of the element\n * - reference to the source object\n * - reference to the destination object\n *\n * @param {Object} object\n * @param {Function} f\n */\nexport function mapObject(object: any, f: Function): any {\n var result = {};\n objectApply(object, function(value, key) {\n result[key] = f(value);\n });\n return result;\n}\n\n/** Filters elements of the array using a test function.\n *\n * Function test gets 4 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n * - reference to the destination array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function filter(array: any[], test: Function): any[] {\n test =\n test ||\n function(value) {\n return !!value;\n };\n\n var result = [];\n for (var i = 0; i < array.length; i++) {\n if (test(array[i], i, array, result)) {\n result.push(array[i]);\n }\n }\n return result;\n}\n\n/** Filters properties of the object using a test function.\n *\n * Function test gets 4 arguments passed:\n * - element from the object\n * - key of the element\n * - reference to the source object\n * - reference to the destination object\n *\n * @param {Object} object\n * @param {Function} f\n */\nexport function filterObject(object: Object, test: Function) {\n var result = {};\n objectApply(object, function(value, key) {\n if ((test && test(value, key, object, result)) || Boolean(value)) {\n result[key] = value;\n }\n });\n return result;\n}\n\n/** Flattens an object into a two-dimensional array.\n *\n * @param {Object} object\n * @return {Array} resulting array of [key, value] pairs\n */\nexport function flatten(object: Object): any[] {\n var result = [];\n objectApply(object, function(value, key) {\n result.push([key, value]);\n });\n return result;\n}\n\n/** Checks whether any element of the array passes the test.\n *\n * Function test gets 3 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function any(array: any[], test: Function): boolean {\n for (var i = 0; i < array.length; i++) {\n if (test(array[i], i, array)) {\n return true;\n }\n }\n return false;\n}\n\n/** Checks whether all elements of the array pass the test.\n *\n * Function test gets 3 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function all(array: any[], test: Function): boolean {\n for (var i = 0; i < array.length; i++) {\n if (!test(array[i], i, array)) {\n return false;\n }\n }\n return true;\n}\n\nexport function encodeParamsObject(data): string {\n return mapObject(data, function(value) {\n if (typeof value === 'object') {\n value = safeJSONStringify(value);\n }\n return encodeURIComponent(base64encode(value.toString()));\n });\n}\n\nexport function buildQueryString(data: any): string {\n var params = filterObject(data, function(value) {\n return value !== undefined;\n });\n\n var query = map(\n flatten(encodeParamsObject(params)),\n Util.method('join', '=')\n ).join('&');\n\n return query;\n}\n\n/**\n * See https://github.com/douglascrockford/JSON-js/blob/master/cycle.js\n *\n * Remove circular references from an object. Required for JSON.stringify in\n * React Native, which tends to blow up a lot.\n *\n * @param {any} object\n * @return {any} Decycled object\n */\nexport function decycleObject(object: any): any {\n var objects = [],\n paths = [];\n\n return (function derez(value, path) {\n var i, name, nu;\n\n switch (typeof value) {\n case 'object':\n if (!value) {\n return null;\n }\n for (i = 0; i < objects.length; i += 1) {\n if (objects[i] === value) {\n return { $ref: paths[i] };\n }\n }\n\n objects.push(value);\n paths.push(path);\n\n if (Object.prototype.toString.apply(value) === '[object Array]') {\n nu = [];\n for (i = 0; i < value.length; i += 1) {\n nu[i] = derez(value[i], path + '[' + i + ']');\n }\n } else {\n nu = {};\n for (name in value) {\n if (Object.prototype.hasOwnProperty.call(value, name)) {\n nu[name] = derez(\n value[name],\n path + '[' + JSON.stringify(name) + ']'\n );\n }\n }\n }\n return nu;\n case 'number':\n case 'string':\n case 'boolean':\n return value;\n }\n })(object, '$');\n}\n\n/**\n * Provides a cross-browser and cross-platform way to safely stringify objects\n * into JSON. This is particularly necessary for ReactNative, where circular JSON\n * structures throw an exception.\n *\n * @param {any} source The object to stringify\n * @return {string} The serialized output.\n */\nexport function safeJSONStringify(source: any): string {\n try {\n return JSON.stringify(source);\n } catch (e) {\n return JSON.stringify(decycleObject(source));\n }\n}\n","import { stringify } from './utils/collections';\nimport Pusher from './pusher';\n\nclass Logger {\n debug(...args: any[]) {\n this.log(this.globalLog, args);\n }\n\n warn(...args: any[]) {\n this.log(this.globalLogWarn, args);\n }\n\n error(...args: any[]) {\n this.log(this.globalLogError, args);\n }\n\n private globalLog = (message: string) => {\n if (global.console && global.console.log) {\n global.console.log(message);\n }\n };\n\n private globalLogWarn(message: string) {\n if (global.console && global.console.warn) {\n global.console.warn(message);\n } else {\n this.globalLog(message);\n }\n }\n\n private globalLogError(message: string) {\n if (global.console && global.console.error) {\n global.console.error(message);\n } else {\n this.globalLogWarn(message);\n }\n }\n\n private log(\n defaultLoggingFunction: (message: string) => void,\n ...args: any[]\n ) {\n var message = stringify.apply(this, arguments);\n if (Pusher.log) {\n Pusher.log(message);\n } else if (Pusher.logToConsole) {\n const log = defaultLoggingFunction.bind(this);\n log(message);\n }\n }\n}\n\nexport default new Logger();\n","import Browser from '../browser';\nimport Logger from 'core/logger';\nimport JSONPRequest from '../dom/jsonp_request';\nimport { ScriptReceivers } from '../dom/script_receiver_factory';\nimport { AuthTransport } from 'core/auth/auth_transports';\nimport {\n AuthRequestType,\n AuthTransportCallback,\n InternalAuthOptions\n} from 'core/auth/options';\n\nvar jsonp: AuthTransport = function(\n context: Browser,\n query: string,\n authOptions: InternalAuthOptions,\n authRequestType: AuthRequestType,\n callback: AuthTransportCallback\n) {\n if (\n authOptions.headers !== undefined ||\n authOptions.headersProvider != null\n ) {\n Logger.warn(\n `To send headers with the ${authRequestType.toString()} request, you must use AJAX, rather than JSONP.`\n );\n }\n\n var callbackName = context.nextAuthCallbackID.toString();\n context.nextAuthCallbackID++;\n\n var document = context.getDocument();\n var script = document.createElement('script');\n // Hacked wrapper.\n context.auth_callbacks[callbackName] = function(data) {\n callback(null, data);\n };\n\n var callback_name = \"Pusher.auth_callbacks['\" + callbackName + \"']\";\n script.src =\n authOptions.endpoint +\n '?callback=' +\n encodeURIComponent(callback_name) +\n '&' +\n query;\n\n var head =\n document.getElementsByTagName('head')[0] || document.documentElement;\n head.insertBefore(script, head.firstChild);\n};\n\nexport default jsonp;\n","import ScriptReceiver from './script_receiver';\n\n/** Sends a generic HTTP GET request using a script tag.\n *\n * By constructing URL in a specific way, it can be used for loading\n * JavaScript resources or JSONP requests. It can notify about errors, but\n * only in certain environments. Please take care of monitoring the state of\n * the request yourself.\n *\n * @param {String} src\n */\nexport default class ScriptRequest {\n src: string;\n script: any;\n errorScript: any;\n\n constructor(src: string) {\n this.src = src;\n }\n\n send(receiver: ScriptReceiver) {\n var self = this;\n var errorString = 'Error loading ' + self.src;\n\n self.script = document.createElement('script');\n self.script.id = receiver.id;\n self.script.src = self.src;\n self.script.type = 'text/javascript';\n self.script.charset = 'UTF-8';\n\n if (self.script.addEventListener) {\n self.script.onerror = function() {\n receiver.callback(errorString);\n };\n self.script.onload = function() {\n receiver.callback(null);\n };\n } else {\n self.script.onreadystatechange = function() {\n if (\n self.script.readyState === 'loaded' ||\n self.script.readyState === 'complete'\n ) {\n receiver.callback(null);\n }\n };\n }\n\n // Opera<11.6 hack for missing onerror callback\n if (\n self.script.async === undefined &&\n (document).attachEvent &&\n /opera/i.test(navigator.userAgent)\n ) {\n self.errorScript = document.createElement('script');\n self.errorScript.id = receiver.id + '_error';\n self.errorScript.text = receiver.name + \"('\" + errorString + \"');\";\n self.script.async = self.errorScript.async = false;\n } else {\n self.script.async = true;\n }\n\n var head = document.getElementsByTagName('head')[0];\n head.insertBefore(self.script, head.firstChild);\n if (self.errorScript) {\n head.insertBefore(self.errorScript, self.script.nextSibling);\n }\n }\n\n /** Cleans up the DOM remains of the script request. */\n cleanup() {\n if (this.script) {\n this.script.onload = this.script.onerror = null;\n this.script.onreadystatechange = null;\n }\n if (this.script && this.script.parentNode) {\n this.script.parentNode.removeChild(this.script);\n }\n if (this.errorScript && this.errorScript.parentNode) {\n this.errorScript.parentNode.removeChild(this.errorScript);\n }\n this.script = null;\n this.errorScript = null;\n }\n}\n","import ScriptReceiver from './script_receiver';\nimport ScriptRequest from './script_request';\nimport * as Collections from 'core/utils/collections';\nimport Util from 'core/util';\nimport Runtime from '../runtime';\n\n/** Sends data via JSONP.\n *\n * Data is a key-value map. Its values are JSON-encoded and then passed\n * through base64. Finally, keys and encoded values are appended to the query\n * string.\n *\n * The class itself does not guarantee raising errors on failures, as it's not\n * possible to support such feature on all browsers. Instead, JSONP endpoint\n * should call back in a way that's easy to distinguish from browser calls,\n * for example by passing a second argument to the receiver.\n *\n * @param {String} url\n * @param {Object} data key-value map of data to be submitted\n */\nexport default class JSONPRequest {\n url: string;\n data: any;\n request: ScriptRequest;\n\n constructor(url: string, data: any) {\n this.url = url;\n this.data = data;\n }\n\n /** Sends the actual JSONP request.\n *\n * @param {ScriptReceiver} receiver\n */\n send(receiver: ScriptReceiver) {\n if (this.request) {\n return;\n }\n\n var query = Collections.buildQueryString(this.data);\n var url = this.url + '/' + receiver.number + '?' + query;\n this.request = Runtime.createScriptRequest(url);\n this.request.send(receiver);\n }\n\n /** Cleans up the DOM remains of the JSONP request. */\n cleanup() {\n if (this.request) {\n this.request.cleanup();\n }\n }\n}\n","import TimelineSender from 'core/timeline/timeline_sender';\nimport TimelineTransport from 'core/timeline/timeline_transport';\nimport Browser from 'runtime';\nimport { AuthTransport } from 'core/auth/auth_transports';\nimport { ScriptReceivers } from '../dom/script_receiver_factory';\n\nvar getAgent = function(sender: TimelineSender, useTLS: boolean) {\n return function(data: any, callback: Function) {\n var scheme = 'http' + (useTLS ? 's' : '') + '://';\n var url =\n scheme + (sender.host || sender.options.host) + sender.options.path;\n var request = Browser.createJSONPRequest(url, data);\n\n var receiver = Browser.ScriptReceivers.create(function(error, result) {\n ScriptReceivers.remove(receiver);\n request.cleanup();\n\n if (result && result.host) {\n sender.host = result.host;\n }\n if (callback) {\n callback(error, result);\n }\n });\n request.send(receiver);\n };\n};\n\nvar jsonp = {\n name: 'jsonp',\n getAgent\n};\n\nexport default jsonp;\n","import Defaults from '../defaults';\nimport { default as URLScheme, URLSchemeParams } from './url_scheme';\n\nfunction getGenericURL(\n baseScheme: string,\n params: URLSchemeParams,\n path: string\n): string {\n var scheme = baseScheme + (params.useTLS ? 's' : '');\n var host = params.useTLS ? params.hostTLS : params.hostNonTLS;\n return scheme + '://' + host + path;\n}\n\nfunction getGenericPath(key: string, queryString?: string): string {\n var path = '/app/' + key;\n var query =\n '?protocol=' +\n Defaults.PROTOCOL +\n '&client=js' +\n '&version=' +\n Defaults.VERSION +\n (queryString ? '&' + queryString : '');\n return path + query;\n}\n\nexport var ws: URLScheme = {\n getInitial: function(key: string, params: URLSchemeParams): string {\n var path = (params.httpPath || '') + getGenericPath(key, 'flash=false');\n return getGenericURL('ws', params, path);\n }\n};\n\nexport var http: URLScheme = {\n getInitial: function(key: string, params: URLSchemeParams): string {\n var path = (params.httpPath || '/pusher') + getGenericPath(key);\n return getGenericURL('http', params, path);\n }\n};\n\nexport var sockjs: URLScheme = {\n getInitial: function(key: string, params: URLSchemeParams): string {\n return getGenericURL('http', params, params.httpPath || '/pusher');\n },\n getPath: function(key: string, params: URLSchemeParams): string {\n return getGenericPath(key);\n }\n};\n","import Callback from './callback';\nimport * as Collections from '../utils/collections';\nimport CallbackTable from './callback_table';\n\nexport default class CallbackRegistry {\n _callbacks: CallbackTable;\n\n constructor() {\n this._callbacks = {};\n }\n\n get(name: string): Callback[] {\n return this._callbacks[prefix(name)];\n }\n\n add(name: string, callback: Function, context: any) {\n var prefixedEventName = prefix(name);\n this._callbacks[prefixedEventName] =\n this._callbacks[prefixedEventName] || [];\n this._callbacks[prefixedEventName].push({\n fn: callback,\n context: context\n });\n }\n\n remove(name?: string, callback?: Function, context?: any) {\n if (!name && !callback && !context) {\n this._callbacks = {};\n return;\n }\n\n var names = name ? [prefix(name)] : Collections.keys(this._callbacks);\n\n if (callback || context) {\n this.removeCallback(names, callback, context);\n } else {\n this.removeAllCallbacks(names);\n }\n }\n\n private removeCallback(names: string[], callback: Function, context: any) {\n Collections.apply(\n names,\n function(name) {\n this._callbacks[name] = Collections.filter(\n this._callbacks[name] || [],\n function(binding) {\n return (\n (callback && callback !== binding.fn) ||\n (context && context !== binding.context)\n );\n }\n );\n if (this._callbacks[name].length === 0) {\n delete this._callbacks[name];\n }\n },\n this\n );\n }\n\n private removeAllCallbacks(names: string[]) {\n Collections.apply(\n names,\n function(name) {\n delete this._callbacks[name];\n },\n this\n );\n }\n}\n\nfunction prefix(name: string): string {\n return '_' + name;\n}\n","import * as Collections from '../utils/collections';\nimport Callback from './callback';\nimport Metadata from '../channels/metadata';\nimport CallbackRegistry from './callback_registry';\n\n/** Manages callback bindings and event emitting.\n *\n * @param Function failThrough called when no listeners are bound to an event\n */\nexport default class Dispatcher {\n callbacks: CallbackRegistry;\n global_callbacks: Function[];\n failThrough: Function;\n\n constructor(failThrough?: Function) {\n this.callbacks = new CallbackRegistry();\n this.global_callbacks = [];\n this.failThrough = failThrough;\n }\n\n bind(eventName: string, callback: Function, context?: any) {\n this.callbacks.add(eventName, callback, context);\n return this;\n }\n\n bind_global(callback: Function) {\n this.global_callbacks.push(callback);\n return this;\n }\n\n unbind(eventName?: string, callback?: Function, context?: any) {\n this.callbacks.remove(eventName, callback, context);\n return this;\n }\n\n unbind_global(callback?: Function) {\n if (!callback) {\n this.global_callbacks = [];\n return this;\n }\n\n this.global_callbacks = Collections.filter(\n this.global_callbacks || [],\n c => c !== callback\n );\n\n return this;\n }\n\n unbind_all() {\n this.unbind();\n this.unbind_global();\n return this;\n }\n\n emit(eventName: string, data?: any, metadata?: Metadata): Dispatcher {\n for (var i = 0; i < this.global_callbacks.length; i++) {\n this.global_callbacks[i](eventName, data);\n }\n\n var callbacks = this.callbacks.get(eventName);\n var args = [];\n\n if (metadata) {\n // if there's a metadata argument, we need to call the callback with both\n // data and metadata regardless of whether data is undefined\n args.push(data, metadata);\n } else if (data) {\n // metadata is undefined, so we only need to call the callback with data\n // if data exists\n args.push(data);\n }\n\n if (callbacks && callbacks.length > 0) {\n for (var i = 0; i < callbacks.length; i++) {\n callbacks[i].fn.apply(callbacks[i].context || global, args);\n }\n } else if (this.failThrough) {\n this.failThrough(eventName, data);\n }\n\n return this;\n }\n}\n","import Util from '../util';\nimport * as Collections from '../utils/collections';\nimport { default as EventsDispatcher } from '../events/dispatcher';\nimport Logger from '../logger';\nimport TransportHooks from './transport_hooks';\nimport Socket from '../socket';\nimport Runtime from 'runtime';\nimport Timeline from '../timeline/timeline';\nimport TransportConnectionOptions from './transport_connection_options';\n\n/** Provides universal API for transport connections.\n *\n * Transport connection is a low-level object that wraps a connection method\n * and exposes a simple evented interface for the connection state and\n * messaging. It does not implement Pusher-specific WebSocket protocol.\n *\n * Additionally, it fetches resources needed for transport to work and exposes\n * an interface for querying transport features.\n *\n * States:\n * - new - initial state after constructing the object\n * - initializing - during initialization phase, usually fetching resources\n * - intialized - ready to establish a connection\n * - connection - when connection is being established\n * - open - when connection ready to be used\n * - closed - after connection was closed be either side\n *\n * Emits:\n * - error - after the connection raised an error\n *\n * Options:\n * - useTLS - whether connection should be over TLS\n * - hostTLS - host to connect to when connection is over TLS\n * - hostNonTLS - host to connect to when connection is over TLS\n *\n * @param {String} key application key\n * @param {Object} options\n */\nexport default class TransportConnection extends EventsDispatcher {\n hooks: TransportHooks;\n name: string;\n priority: number;\n key: string;\n options: TransportConnectionOptions;\n state: string;\n timeline: Timeline;\n activityTimeout: number;\n id: number;\n socket: Socket;\n beforeOpen: Function;\n initialize: Function;\n\n constructor(\n hooks: TransportHooks,\n name: string,\n priority: number,\n key: string,\n options: TransportConnectionOptions\n ) {\n super();\n this.initialize = Runtime.transportConnectionInitializer;\n this.hooks = hooks;\n this.name = name;\n this.priority = priority;\n this.key = key;\n this.options = options;\n\n this.state = 'new';\n this.timeline = options.timeline;\n this.activityTimeout = options.activityTimeout;\n this.id = this.timeline.generateUniqueID();\n }\n\n /** Checks whether the transport handles activity checks by itself.\n *\n * @return {Boolean}\n */\n handlesActivityChecks(): boolean {\n return Boolean(this.hooks.handlesActivityChecks);\n }\n\n /** Checks whether the transport supports the ping/pong API.\n *\n * @return {Boolean}\n */\n supportsPing(): boolean {\n return Boolean(this.hooks.supportsPing);\n }\n\n /** Tries to establish a connection.\n *\n * @returns {Boolean} false if transport is in invalid state\n */\n connect(): boolean {\n if (this.socket || this.state !== 'initialized') {\n return false;\n }\n\n var url = this.hooks.urls.getInitial(this.key, this.options);\n try {\n this.socket = this.hooks.getSocket(url, this.options);\n } catch (e) {\n Util.defer(() => {\n this.onError(e);\n this.changeState('closed');\n });\n return false;\n }\n\n this.bindListeners();\n\n Logger.debug('Connecting', { transport: this.name, url });\n this.changeState('connecting');\n return true;\n }\n\n /** Closes the connection.\n *\n * @return {Boolean} true if there was a connection to close\n */\n close(): boolean {\n if (this.socket) {\n this.socket.close();\n return true;\n } else {\n return false;\n }\n }\n\n /** Sends data over the open connection.\n *\n * @param {String} data\n * @return {Boolean} true only when in the \"open\" state\n */\n send(data: any): boolean {\n if (this.state === 'open') {\n // Workaround for MobileSafari bug (see https://gist.github.com/2052006)\n Util.defer(() => {\n if (this.socket) {\n this.socket.send(data);\n }\n });\n return true;\n } else {\n return false;\n }\n }\n\n /** Sends a ping if the connection is open and transport supports it. */\n ping() {\n if (this.state === 'open' && this.supportsPing()) {\n this.socket.ping();\n }\n }\n\n private onOpen() {\n if (this.hooks.beforeOpen) {\n this.hooks.beforeOpen(\n this.socket,\n this.hooks.urls.getPath(this.key, this.options)\n );\n }\n this.changeState('open');\n this.socket.onopen = undefined;\n }\n\n private onError(error) {\n this.emit('error', { type: 'WebSocketError', error: error });\n this.timeline.error(this.buildTimelineMessage({ error: error.toString() }));\n }\n\n private onClose(closeEvent?: any) {\n if (closeEvent) {\n this.changeState('closed', {\n code: closeEvent.code,\n reason: closeEvent.reason,\n wasClean: closeEvent.wasClean\n });\n } else {\n this.changeState('closed');\n }\n this.unbindListeners();\n this.socket = undefined;\n }\n\n private onMessage(message) {\n this.emit('message', message);\n }\n\n private onActivity() {\n this.emit('activity');\n }\n\n private bindListeners() {\n this.socket.onopen = () => {\n this.onOpen();\n };\n this.socket.onerror = error => {\n this.onError(error);\n };\n this.socket.onclose = closeEvent => {\n this.onClose(closeEvent);\n };\n this.socket.onmessage = message => {\n this.onMessage(message);\n };\n\n if (this.supportsPing()) {\n this.socket.onactivity = () => {\n this.onActivity();\n };\n }\n }\n\n private unbindListeners() {\n if (this.socket) {\n this.socket.onopen = undefined;\n this.socket.onerror = undefined;\n this.socket.onclose = undefined;\n this.socket.onmessage = undefined;\n if (this.supportsPing()) {\n this.socket.onactivity = undefined;\n }\n }\n }\n\n private changeState(state: string, params?: any) {\n this.state = state;\n this.timeline.info(\n this.buildTimelineMessage({\n state: state,\n params: params\n })\n );\n this.emit(state, params);\n }\n\n buildTimelineMessage(message): any {\n return Collections.extend({ cid: this.id }, message);\n }\n}\n","import Factory from '../utils/factory';\nimport TransportHooks from './transport_hooks';\nimport TransportConnection from './transport_connection';\nimport TransportConnectionOptions from './transport_connection_options';\n\n/** Provides interface for transport connection instantiation.\n *\n * Takes transport-specific hooks as the only argument, which allow checking\n * for transport support and creating its connections.\n *\n * Supported hooks: * - file - the name of the file to be fetched during initialization\n * - urls - URL scheme to be used by transport\n * - handlesActivityCheck - true when the transport handles activity checks\n * - supportsPing - true when the transport has a ping/activity API\n * - isSupported - tells whether the transport is supported in the environment\n * - getSocket - creates a WebSocket-compatible transport socket\n *\n * See transports.js for specific implementations.\n *\n * @param {Object} hooks object containing all needed transport hooks\n */\nexport default class Transport {\n hooks: TransportHooks;\n\n constructor(hooks: TransportHooks) {\n this.hooks = hooks;\n }\n\n /** Returns whether the transport is supported in the environment.\n *\n * @param {Object} envronment te environment details (encryption, settings)\n * @returns {Boolean} true when the transport is supported\n */\n isSupported(environment: any): boolean {\n return this.hooks.isSupported(environment);\n }\n\n /** Creates a transport connection.\n *\n * @param {String} name\n * @param {Number} priority\n * @param {String} key the application key\n * @param {Object} options\n * @returns {TransportConnection}\n */\n createConnection(\n name: string,\n priority: number,\n key: string,\n options: any\n ): TransportConnection {\n return new TransportConnection(this.hooks, name, priority, key, options);\n }\n}\n","import * as URLSchemes from 'core/transports/url_schemes';\nimport URLScheme from 'core/transports/url_scheme';\nimport Transport from 'core/transports/transport';\nimport Util from 'core/util';\nimport * as Collections from 'core/utils/collections';\nimport TransportHooks from 'core/transports/transport_hooks';\nimport TransportsTable from 'core/transports/transports_table';\nimport Runtime from 'runtime';\n\n/** WebSocket transport.\n *\n * Uses native WebSocket implementation, including MozWebSocket supported by\n * earlier Firefox versions.\n */\nvar WSTransport = new Transport({\n urls: URLSchemes.ws,\n handlesActivityChecks: false,\n supportsPing: false,\n\n isInitialized: function() {\n return Boolean(Runtime.getWebSocketAPI());\n },\n isSupported: function(): boolean {\n return Boolean(Runtime.getWebSocketAPI());\n },\n getSocket: function(url) {\n return Runtime.createWebSocket(url);\n }\n});\n\nvar httpConfiguration = {\n urls: URLSchemes.http,\n handlesActivityChecks: false,\n supportsPing: true,\n isInitialized: function() {\n return true;\n }\n};\n\nexport var streamingConfiguration = Collections.extend(\n {\n getSocket: function(url) {\n return Runtime.HTTPFactory.createStreamingSocket(url);\n }\n },\n httpConfiguration\n);\nexport var pollingConfiguration = Collections.extend(\n {\n getSocket: function(url) {\n return Runtime.HTTPFactory.createPollingSocket(url);\n }\n },\n httpConfiguration\n);\n\nvar xhrConfiguration = {\n isSupported: function(): boolean {\n return Runtime.isXHRSupported();\n }\n};\n\n/** HTTP streaming transport using CORS-enabled XMLHttpRequest. */\nvar XHRStreamingTransport = new Transport(\n (\n Collections.extend({}, streamingConfiguration, xhrConfiguration)\n )\n);\n\n/** HTTP long-polling transport using CORS-enabled XMLHttpRequest. */\nvar XHRPollingTransport = new Transport(\n Collections.extend({}, pollingConfiguration, xhrConfiguration)\n);\n\nvar Transports: TransportsTable = {\n ws: WSTransport,\n xhr_streaming: XHRStreamingTransport,\n xhr_polling: XHRPollingTransport\n};\n\nexport default Transports;\n","import {\n default as Transports,\n streamingConfiguration,\n pollingConfiguration\n} from 'isomorphic/transports/transports';\nimport Transport from 'core/transports/transport';\nimport TransportHooks from 'core/transports/transport_hooks';\nimport * as URLSchemes from 'core/transports/url_schemes';\nimport Runtime from 'runtime';\nimport { Dependencies } from '../dom/dependencies';\nimport * as Collections from 'core/utils/collections';\n\nvar SockJSTransport = new Transport({\n file: 'sockjs',\n urls: URLSchemes.sockjs,\n handlesActivityChecks: true,\n supportsPing: false,\n\n isSupported: function() {\n return true;\n },\n isInitialized: function() {\n return window.SockJS !== undefined;\n },\n getSocket: function(url, options) {\n return new window.SockJS(url, null, {\n js_path: Dependencies.getPath('sockjs', {\n useTLS: options.useTLS\n }),\n ignore_null_origin: options.ignoreNullOrigin\n });\n },\n beforeOpen: function(socket, path) {\n socket.send(\n JSON.stringify({\n path: path\n })\n );\n }\n});\n\nvar xdrConfiguration = {\n isSupported: function(environment): boolean {\n var yes = Runtime.isXDRSupported(environment.useTLS);\n return yes;\n }\n};\n\n/** HTTP streaming transport using XDomainRequest (IE 8,9). */\nvar XDRStreamingTransport = new Transport(\n (\n Collections.extend({}, streamingConfiguration, xdrConfiguration)\n )\n);\n\n/** HTTP long-polling transport using XDomainRequest (IE 8,9). */\nvar XDRPollingTransport = new Transport(\n Collections.extend({}, pollingConfiguration, xdrConfiguration)\n);\n\nTransports.xdr_streaming = XDRStreamingTransport;\nTransports.xdr_polling = XDRPollingTransport;\nTransports.sockjs = SockJSTransport;\n\nexport default Transports;\n","import Reachability from 'core/reachability';\nimport { default as EventsDispatcher } from 'core/events/dispatcher';\n\n/** Really basic interface providing network availability info.\n *\n * Emits:\n * - online - when browser goes online\n * - offline - when browser goes offline\n */\nexport class NetInfo extends EventsDispatcher implements Reachability {\n constructor() {\n super();\n var self = this;\n // This is okay, as IE doesn't support this stuff anyway.\n if (window.addEventListener !== undefined) {\n window.addEventListener(\n 'online',\n function() {\n self.emit('online');\n },\n false\n );\n window.addEventListener(\n 'offline',\n function() {\n self.emit('offline');\n },\n false\n );\n }\n }\n\n /** Returns whether browser is online or not\n *\n * Offline means definitely offline (no connection to router).\n * Inverse does NOT mean definitely online (only currently supported in Safari\n * and even there only means the device has a connection to the router).\n *\n * @return {Boolean}\n */\n isOnline(): boolean {\n if (window.navigator.onLine === undefined) {\n return true;\n } else {\n return window.navigator.onLine;\n }\n }\n}\n\nexport var Network = new NetInfo();\n","import Util from '../util';\nimport * as Collections from '../utils/collections';\nimport TransportManager from './transport_manager';\nimport TransportConnection from './transport_connection';\nimport Transport from './transport';\nimport PingDelayOptions from './ping_delay_options';\n\n/** Creates transport connections monitored by a transport manager.\n *\n * When a transport is closed, it might mean the environment does not support\n * it. It's possible that messages get stuck in an intermediate buffer or\n * proxies terminate inactive connections. To combat these problems,\n * assistants monitor the connection lifetime, report unclean exits and\n * adjust ping timeouts to keep the connection active. The decision to disable\n * a transport is the manager's responsibility.\n *\n * @param {TransportManager} manager\n * @param {TransportConnection} transport\n * @param {Object} options\n */\nexport default class AssistantToTheTransportManager {\n manager: TransportManager;\n transport: Transport;\n minPingDelay: number;\n maxPingDelay: number;\n pingDelay: number;\n\n constructor(\n manager: TransportManager,\n transport: Transport,\n options: PingDelayOptions\n ) {\n this.manager = manager;\n this.transport = transport;\n this.minPingDelay = options.minPingDelay;\n this.maxPingDelay = options.maxPingDelay;\n this.pingDelay = undefined;\n }\n\n /** Creates a transport connection.\n *\n * This function has the same API as Transport#createConnection.\n *\n * @param {String} name\n * @param {Number} priority\n * @param {String} key the application key\n * @param {Object} options\n * @returns {TransportConnection}\n */\n createConnection(\n name: string,\n priority: number,\n key: string,\n options: Object\n ): TransportConnection {\n options = Collections.extend({}, options, {\n activityTimeout: this.pingDelay\n });\n var connection = this.transport.createConnection(\n name,\n priority,\n key,\n options\n );\n\n var openTimestamp = null;\n\n var onOpen = function() {\n connection.unbind('open', onOpen);\n connection.bind('closed', onClosed);\n openTimestamp = Util.now();\n };\n var onClosed = closeEvent => {\n connection.unbind('closed', onClosed);\n\n if (closeEvent.code === 1002 || closeEvent.code === 1003) {\n // we don't want to use transports not obeying the protocol\n this.manager.reportDeath();\n } else if (!closeEvent.wasClean && openTimestamp) {\n // report deaths only for short-living transport\n var lifespan = Util.now() - openTimestamp;\n if (lifespan < 2 * this.maxPingDelay) {\n this.manager.reportDeath();\n this.pingDelay = Math.max(lifespan / 2, this.minPingDelay);\n }\n }\n };\n\n connection.bind('open', onOpen);\n return connection;\n }\n\n /** Returns whether the transport is supported in the environment.\n *\n * This function has the same API as Transport#isSupported. Might return false\n * when the manager decides to kill the transport.\n *\n * @param {Object} environment the environment details (encryption, settings)\n * @returns {Boolean} true when the transport is supported\n */\n isSupported(environment: string): boolean {\n return this.manager.isAlive() && this.transport.isSupported(environment);\n }\n}\n","import Action from './action';\nimport { PusherEvent } from './message-types';\n/**\n * Provides functions for handling Pusher protocol-specific messages.\n */\n\nconst Protocol = {\n /**\n * Decodes a message in a Pusher format.\n *\n * The MessageEvent we receive from the transport should contain a pusher event\n * (https://pusher.com/docs/pusher_protocol#events) serialized as JSON in the\n * data field\n *\n * The pusher event may contain a data field too, and it may also be\n * serialised as JSON\n *\n * Throws errors when messages are not parse'able.\n *\n * @param {MessageEvent} messageEvent\n * @return {PusherEvent}\n */\n decodeMessage: function(messageEvent: MessageEvent): PusherEvent {\n try {\n var messageData = JSON.parse(messageEvent.data);\n var pusherEventData = messageData.data;\n if (typeof pusherEventData === 'string') {\n try {\n pusherEventData = JSON.parse(messageData.data);\n } catch (e) {}\n }\n var pusherEvent: PusherEvent = {\n event: messageData.event,\n channel: messageData.channel,\n data: pusherEventData\n };\n if (messageData.user_id) {\n pusherEvent.user_id = messageData.user_id;\n }\n return pusherEvent;\n } catch (e) {\n throw { type: 'MessageParseError', error: e, data: messageEvent.data };\n }\n },\n\n /**\n * Encodes a message to be sent.\n *\n * @param {PusherEvent} event\n * @return {String}\n */\n encodeMessage: function(event: PusherEvent): string {\n return JSON.stringify(event);\n },\n\n /**\n * Processes a handshake message and returns appropriate actions.\n *\n * Returns an object with an 'action' and other action-specific properties.\n *\n * There are three outcomes when calling this function. First is a successful\n * connection attempt, when pusher:connection_established is received, which\n * results in a 'connected' action with an 'id' property. When passed a\n * pusher:error event, it returns a result with action appropriate to the\n * close code and an error. Otherwise, it raises an exception.\n *\n * @param {String} message\n * @result Object\n */\n processHandshake: function(messageEvent: MessageEvent): Action {\n var message = Protocol.decodeMessage(messageEvent);\n\n if (message.event === 'pusher:connection_established') {\n if (!message.data.activity_timeout) {\n throw 'No activity timeout specified in handshake';\n }\n return {\n action: 'connected',\n id: message.data.socket_id,\n activityTimeout: message.data.activity_timeout * 1000\n };\n } else if (message.event === 'pusher:error') {\n // From protocol 6 close codes are sent only once, so this only\n // happens when connection does not support close codes\n return {\n action: this.getCloseAction(message.data),\n error: this.getCloseError(message.data)\n };\n } else {\n throw 'Invalid handshake';\n }\n },\n\n /**\n * Dispatches the close event and returns an appropriate action name.\n *\n * See:\n * 1. https://developer.mozilla.org/en-US/docs/WebSockets/WebSockets_reference/CloseEvent\n * 2. http://pusher.com/docs/pusher_protocol\n *\n * @param {CloseEvent} closeEvent\n * @return {String} close action name\n */\n getCloseAction: function(closeEvent): string {\n if (closeEvent.code < 4000) {\n // ignore 1000 CLOSE_NORMAL, 1001 CLOSE_GOING_AWAY,\n // 1005 CLOSE_NO_STATUS, 1006 CLOSE_ABNORMAL\n // ignore 1007...3999\n // handle 1002 CLOSE_PROTOCOL_ERROR, 1003 CLOSE_UNSUPPORTED,\n // 1004 CLOSE_TOO_LARGE\n if (closeEvent.code >= 1002 && closeEvent.code <= 1004) {\n return 'backoff';\n } else {\n return null;\n }\n } else if (closeEvent.code === 4000) {\n return 'tls_only';\n } else if (closeEvent.code < 4100) {\n return 'refused';\n } else if (closeEvent.code < 4200) {\n return 'backoff';\n } else if (closeEvent.code < 4300) {\n return 'retry';\n } else {\n // unknown error\n return 'refused';\n }\n },\n\n /**\n * Returns an error or null basing on the close event.\n *\n * Null is returned when connection was closed cleanly. Otherwise, an object\n * with error details is returned.\n *\n * @param {CloseEvent} closeEvent\n * @return {Object} error object\n */\n getCloseError: function(closeEvent): any {\n if (closeEvent.code !== 1000 && closeEvent.code !== 1001) {\n return {\n type: 'PusherError',\n data: {\n code: closeEvent.code,\n message: closeEvent.reason || closeEvent.message\n }\n };\n } else {\n return null;\n }\n }\n};\n\nexport default Protocol;\n","import * as Collections from '../utils/collections';\nimport { default as EventsDispatcher } from '../events/dispatcher';\nimport Protocol from './protocol/protocol';\nimport { PusherEvent } from './protocol/message-types';\nimport Logger from '../logger';\nimport TransportConnection from '../transports/transport_connection';\nimport Socket from '../socket';\n/**\n * Provides Pusher protocol interface for transports.\n *\n * Emits following events:\n * - message - on received messages\n * - ping - on ping requests\n * - pong - on pong responses\n * - error - when the transport emits an error\n * - closed - after closing the transport\n *\n * It also emits more events when connection closes with a code.\n * See Protocol.getCloseAction to get more details.\n *\n * @param {Number} id\n * @param {AbstractTransport} transport\n */\nexport default class Connection extends EventsDispatcher implements Socket {\n id: string;\n transport: TransportConnection;\n activityTimeout: number;\n\n constructor(id: string, transport: TransportConnection) {\n super();\n this.id = id;\n this.transport = transport;\n this.activityTimeout = transport.activityTimeout;\n this.bindListeners();\n }\n\n /** Returns whether used transport handles activity checks by itself\n *\n * @returns {Boolean} true if activity checks are handled by the transport\n */\n handlesActivityChecks() {\n return this.transport.handlesActivityChecks();\n }\n\n /** Sends raw data.\n *\n * @param {String} data\n */\n send(data: any): boolean {\n return this.transport.send(data);\n }\n\n /** Sends an event.\n *\n * @param {String} name\n * @param {String} data\n * @param {String} [channel]\n * @returns {Boolean} whether message was sent or not\n */\n send_event(name: string, data: any, channel?: string): boolean {\n var event: PusherEvent = { event: name, data: data };\n if (channel) {\n event.channel = channel;\n }\n Logger.debug('Event sent', event);\n return this.send(Protocol.encodeMessage(event));\n }\n\n /** Sends a ping message to the server.\n *\n * Basing on the underlying transport, it might send either transport's\n * protocol-specific ping or pusher:ping event.\n */\n ping() {\n if (this.transport.supportsPing()) {\n this.transport.ping();\n } else {\n this.send_event('pusher:ping', {});\n }\n }\n\n /** Closes the connection. */\n close() {\n this.transport.close();\n }\n\n private bindListeners() {\n var listeners = {\n message: (messageEvent: MessageEvent) => {\n var pusherEvent;\n try {\n pusherEvent = Protocol.decodeMessage(messageEvent);\n } catch (e) {\n this.emit('error', {\n type: 'MessageParseError',\n error: e,\n data: messageEvent.data\n });\n }\n\n if (pusherEvent !== undefined) {\n Logger.debug('Event recd', pusherEvent);\n\n switch (pusherEvent.event) {\n case 'pusher:error':\n this.emit('error', {\n type: 'PusherError',\n data: pusherEvent.data\n });\n break;\n case 'pusher:ping':\n this.emit('ping');\n break;\n case 'pusher:pong':\n this.emit('pong');\n break;\n }\n this.emit('message', pusherEvent);\n }\n },\n activity: () => {\n this.emit('activity');\n },\n error: error => {\n this.emit('error', error);\n },\n closed: closeEvent => {\n unbindListeners();\n\n if (closeEvent && closeEvent.code) {\n this.handleCloseEvent(closeEvent);\n }\n\n this.transport = null;\n this.emit('closed');\n }\n };\n\n var unbindListeners = () => {\n Collections.objectApply(listeners, (listener, event) => {\n this.transport.unbind(event, listener);\n });\n };\n\n Collections.objectApply(listeners, (listener, event) => {\n this.transport.bind(event, listener);\n });\n }\n\n private handleCloseEvent(closeEvent: any) {\n var action = Protocol.getCloseAction(closeEvent);\n var error = Protocol.getCloseError(closeEvent);\n if (error) {\n this.emit('error', error);\n }\n if (action) {\n this.emit(action, { action: action, error: error });\n }\n }\n}\n","import Util from '../../util';\nimport * as Collections from '../../utils/collections';\nimport Protocol from '../protocol/protocol';\nimport Connection from '../connection';\nimport TransportConnection from '../../transports/transport_connection';\nimport HandshakePayload from './handshake_payload';\n\n/**\n * Handles Pusher protocol handshakes for transports.\n *\n * Calls back with a result object after handshake is completed. Results\n * always have two fields:\n * - action - string describing action to be taken after the handshake\n * - transport - the transport object passed to the constructor\n *\n * Different actions can set different additional properties on the result.\n * In the case of 'connected' action, there will be a 'connection' property\n * containing a Connection object for the transport. Other actions should\n * carry an 'error' property.\n *\n * @param {AbstractTransport} transport\n * @param {Function} callback\n */\nexport default class Handshake {\n transport: TransportConnection;\n callback: (HandshakePayload) => void;\n onMessage: Function;\n onClosed: Function;\n\n constructor(\n transport: TransportConnection,\n callback: (HandshakePayload) => void\n ) {\n this.transport = transport;\n this.callback = callback;\n this.bindListeners();\n }\n\n close() {\n this.unbindListeners();\n this.transport.close();\n }\n\n private bindListeners() {\n this.onMessage = m => {\n this.unbindListeners();\n\n var result;\n try {\n result = Protocol.processHandshake(m);\n } catch (e) {\n this.finish('error', { error: e });\n this.transport.close();\n return;\n }\n\n if (result.action === 'connected') {\n this.finish('connected', {\n connection: new Connection(result.id, this.transport),\n activityTimeout: result.activityTimeout\n });\n } else {\n this.finish(result.action, { error: result.error });\n this.transport.close();\n }\n };\n\n this.onClosed = closeEvent => {\n this.unbindListeners();\n\n var action = Protocol.getCloseAction(closeEvent) || 'backoff';\n var error = Protocol.getCloseError(closeEvent);\n this.finish(action, { error: error });\n };\n\n this.transport.bind('message', this.onMessage);\n this.transport.bind('closed', this.onClosed);\n }\n\n private unbindListeners() {\n this.transport.unbind('message', this.onMessage);\n this.transport.unbind('closed', this.onClosed);\n }\n\n private finish(action: string, params: any) {\n this.callback(\n Collections.extend({ transport: this.transport, action: action }, params)\n );\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport base64encode from '../base64';\nimport Timeline from './timeline';\nimport Runtime from 'runtime';\n\nexport interface TimelineSenderOptions {\n host?: string;\n port?: number;\n path?: string;\n}\n\nexport default class TimelineSender {\n timeline: Timeline;\n options: TimelineSenderOptions;\n host: string;\n\n constructor(timeline: Timeline, options: TimelineSenderOptions) {\n this.timeline = timeline;\n this.options = options || {};\n }\n\n send(useTLS: boolean, callback?: Function) {\n if (this.timeline.isEmpty()) {\n return;\n }\n\n this.timeline.send(\n Runtime.TimelineTransport.getAgent(this, useTLS),\n callback\n );\n }\n}\n","import { default as EventsDispatcher } from '../events/dispatcher';\nimport * as Errors from '../errors';\nimport Logger from '../logger';\nimport Pusher from '../pusher';\nimport { PusherEvent } from '../connection/protocol/message-types';\nimport Metadata from './metadata';\nimport UrlStore from '../utils/url_store';\nimport {\n ChannelAuthorizationData,\n ChannelAuthorizationCallback\n} from '../auth/options';\nimport { HTTPAuthError } from '../errors';\n\n/** Provides base public channel interface with an event emitter.\n *\n * Emits:\n * - pusher:subscription_succeeded - after subscribing successfully\n * - other non-internal events\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\nexport default class Channel extends EventsDispatcher {\n name: string;\n pusher: Pusher;\n subscribed: boolean;\n subscriptionPending: boolean;\n subscriptionCancelled: boolean;\n subscriptionCount: null;\n\n constructor(name: string, pusher: Pusher) {\n super(function(event, data) {\n Logger.debug('No callbacks on ' + name + ' for ' + event);\n });\n\n this.name = name;\n this.pusher = pusher;\n this.subscribed = false;\n this.subscriptionPending = false;\n this.subscriptionCancelled = false;\n }\n\n /** Skips authorization, since public channels don't require it.\n *\n * @param {Function} callback\n */\n authorize(socketId: string, callback: ChannelAuthorizationCallback) {\n return callback(null, { auth: '' });\n }\n\n /** Triggers an event */\n trigger(event: string, data: any) {\n if (event.indexOf('client-') !== 0) {\n throw new Errors.BadEventName(\n \"Event '\" + event + \"' does not start with 'client-'\"\n );\n }\n if (!this.subscribed) {\n var suffix = UrlStore.buildLogSuffix('triggeringClientEvents');\n Logger.warn(\n `Client event triggered before channel 'subscription_succeeded' event . ${suffix}`\n );\n }\n return this.pusher.send_event(event, data, this.name);\n }\n\n /** Signals disconnection to the channel. For internal use only. */\n disconnect() {\n this.subscribed = false;\n this.subscriptionPending = false;\n }\n\n /** Handles a PusherEvent. For internal use only.\n *\n * @param {PusherEvent} event\n */\n handleEvent(event: PusherEvent) {\n var eventName = event.event;\n var data = event.data;\n if (eventName === 'pusher_internal:subscription_succeeded') {\n this.handleSubscriptionSucceededEvent(event);\n } else if (eventName === 'pusher_internal:subscription_count') {\n this.handleSubscriptionCountEvent(event);\n } else if (eventName.indexOf('pusher_internal:') !== 0) {\n var metadata: Metadata = {};\n this.emit(eventName, data, metadata);\n }\n }\n\n handleSubscriptionSucceededEvent(event: PusherEvent) {\n this.subscriptionPending = false;\n this.subscribed = true;\n if (this.subscriptionCancelled) {\n this.pusher.unsubscribe(this.name);\n } else {\n this.emit('pusher:subscription_succeeded', event.data);\n }\n }\n\n handleSubscriptionCountEvent(event: PusherEvent) {\n if (event.data.subscription_count) {\n this.subscriptionCount = event.data.subscription_count;\n }\n\n this.emit('pusher:subscription_count', event.data);\n }\n\n /** Sends a subscription request. For internal use only. */\n subscribe() {\n if (this.subscribed) {\n return;\n }\n this.subscriptionPending = true;\n this.subscriptionCancelled = false;\n this.authorize(\n this.pusher.connection.socket_id,\n (error: Error | null, data: ChannelAuthorizationData) => {\n if (error) {\n this.subscriptionPending = false;\n // Why not bind to 'pusher:subscription_error' a level up, and log there?\n // Binding to this event would cause the warning about no callbacks being\n // bound (see constructor) to be suppressed, that's not what we want.\n Logger.error(error.toString());\n this.emit(\n 'pusher:subscription_error',\n Object.assign(\n {},\n {\n type: 'AuthError',\n error: error.message\n },\n error instanceof HTTPAuthError ? { status: error.status } : {}\n )\n );\n } else {\n this.pusher.send_event('pusher:subscribe', {\n auth: data.auth,\n channel_data: data.channel_data,\n channel: this.name\n });\n }\n }\n );\n }\n\n /** Sends an unsubscription request. For internal use only. */\n unsubscribe() {\n this.subscribed = false;\n this.pusher.send_event('pusher:unsubscribe', {\n channel: this.name\n });\n }\n\n /** Cancels an in progress subscription. For internal use only. */\n cancelSubscription() {\n this.subscriptionCancelled = true;\n }\n\n /** Reinstates an in progress subscripiton. For internal use only. */\n reinstateSubscription() {\n this.subscriptionCancelled = false;\n }\n}\n","import Factory from '../utils/factory';\nimport Channel from './channel';\nimport { ChannelAuthorizationCallback } from '../auth/options';\n\n/** Extends public channels to provide private channel interface.\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\nexport default class PrivateChannel extends Channel {\n /** Authorizes the connection to use the channel.\n *\n * @param {String} socketId\n * @param {Function} callback\n */\n authorize(socketId: string, callback: ChannelAuthorizationCallback) {\n return this.pusher.config.channelAuthorizer(\n {\n channelName: this.name,\n socketId: socketId\n },\n callback\n );\n }\n}\n","import * as Collections from '../utils/collections';\n\n/** Represents a collection of members of a presence channel. */\nexport default class Members {\n members: any;\n count: number;\n myID: any;\n me: any;\n\n constructor() {\n this.reset();\n }\n\n /** Returns member's info for given id.\n *\n * Resulting object containts two fields - id and info.\n *\n * @param {Number} id\n * @return {Object} member's info or null\n */\n get(id: string): any {\n if (Object.prototype.hasOwnProperty.call(this.members, id)) {\n return {\n id: id,\n info: this.members[id]\n };\n } else {\n return null;\n }\n }\n\n /** Calls back for each member in unspecified order.\n *\n * @param {Function} callback\n */\n each(callback: Function) {\n Collections.objectApply(this.members, (member, id) => {\n callback(this.get(id));\n });\n }\n\n /** Updates the id for connected member. For internal use only. */\n setMyID(id: string) {\n this.myID = id;\n }\n\n /** Handles subscription data. For internal use only. */\n onSubscription(subscriptionData: any) {\n this.members = subscriptionData.presence.hash;\n this.count = subscriptionData.presence.count;\n this.me = this.get(this.myID);\n }\n\n /** Adds a new member to the collection. For internal use only. */\n addMember(memberData: any) {\n if (this.get(memberData.user_id) === null) {\n this.count++;\n }\n this.members[memberData.user_id] = memberData.user_info;\n return this.get(memberData.user_id);\n }\n\n /** Adds a member from the collection. For internal use only. */\n removeMember(memberData: any) {\n var member = this.get(memberData.user_id);\n if (member) {\n delete this.members[memberData.user_id];\n this.count--;\n }\n return member;\n }\n\n /** Resets the collection to the initial state. For internal use only. */\n reset() {\n this.members = {};\n this.count = 0;\n this.myID = null;\n this.me = null;\n }\n}\n","import PrivateChannel from './private_channel';\nimport Logger from '../logger';\nimport Members from './members';\nimport Pusher from '../pusher';\nimport UrlStore from 'core/utils/url_store';\nimport { PusherEvent } from '../connection/protocol/message-types';\nimport Metadata from './metadata';\nimport { ChannelAuthorizationData } from '../auth/options';\n\nexport default class PresenceChannel extends PrivateChannel {\n members: Members;\n\n /** Adds presence channel functionality to private channels.\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\n constructor(name: string, pusher: Pusher) {\n super(name, pusher);\n this.members = new Members();\n }\n\n /** Authorizes the connection as a member of the channel.\n *\n * @param {String} socketId\n * @param {Function} callback\n */\n authorize(socketId: string, callback: Function) {\n super.authorize(socketId, async (error, authData) => {\n if (!error) {\n authData = authData as ChannelAuthorizationData;\n if (authData.channel_data != null) {\n var channelData = JSON.parse(authData.channel_data);\n this.members.setMyID(channelData.user_id);\n } else {\n await this.pusher.user.signinDonePromise;\n if (this.pusher.user.user_data != null) {\n // If the user is signed in, get the id of the authenticated user\n // and allow the presence authorization to continue.\n this.members.setMyID(this.pusher.user.user_data.id);\n } else {\n let suffix = UrlStore.buildLogSuffix('authorizationEndpoint');\n Logger.error(\n `Invalid auth response for channel '${this.name}', ` +\n `expected 'channel_data' field. ${suffix}, ` +\n `or the user should be signed in.`\n );\n callback('Invalid auth response');\n return;\n }\n }\n }\n callback(error, authData);\n });\n }\n\n /** Handles presence and subscription events. For internal use only.\n *\n * @param {PusherEvent} event\n */\n handleEvent(event: PusherEvent) {\n var eventName = event.event;\n if (eventName.indexOf('pusher_internal:') === 0) {\n this.handleInternalEvent(event);\n } else {\n var data = event.data;\n var metadata: Metadata = {};\n if (event.user_id) {\n metadata.user_id = event.user_id;\n }\n this.emit(eventName, data, metadata);\n }\n }\n handleInternalEvent(event: PusherEvent) {\n var eventName = event.event;\n var data = event.data;\n switch (eventName) {\n case 'pusher_internal:subscription_succeeded':\n this.handleSubscriptionSucceededEvent(event);\n break;\n case 'pusher_internal:subscription_count':\n this.handleSubscriptionCountEvent(event);\n break;\n case 'pusher_internal:member_added':\n var addedMember = this.members.addMember(data);\n this.emit('pusher:member_added', addedMember);\n break;\n case 'pusher_internal:member_removed':\n var removedMember = this.members.removeMember(data);\n if (removedMember) {\n this.emit('pusher:member_removed', removedMember);\n }\n break;\n }\n }\n\n handleSubscriptionSucceededEvent(event: PusherEvent) {\n this.subscriptionPending = false;\n this.subscribed = true;\n if (this.subscriptionCancelled) {\n this.pusher.unsubscribe(this.name);\n } else {\n this.members.onSubscription(event.data);\n this.emit('pusher:subscription_succeeded', this.members);\n }\n }\n\n /** Resets the channel state, including members map. For internal use only. */\n disconnect() {\n this.members.reset();\n super.disconnect();\n }\n}\n","import PrivateChannel from './private_channel';\nimport * as Errors from '../errors';\nimport Logger from '../logger';\nimport Pusher from '../pusher';\nimport { decode as encodeUTF8 } from '@stablelib/utf8';\nimport { decode as decodeBase64 } from '@stablelib/base64';\nimport Dispatcher from '../events/dispatcher';\nimport { PusherEvent } from '../connection/protocol/message-types';\nimport {\n ChannelAuthorizationData,\n ChannelAuthorizationCallback\n} from '../auth/options';\nimport * as nacl from 'tweetnacl';\n\n/** Extends private channels to provide encrypted channel interface.\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\nexport default class EncryptedChannel extends PrivateChannel {\n key: Uint8Array = null;\n nacl: nacl;\n\n constructor(name: string, pusher: Pusher, nacl: nacl) {\n super(name, pusher);\n this.nacl = nacl;\n }\n\n /** Authorizes the connection to use the channel.\n *\n * @param {String} socketId\n * @param {Function} callback\n */\n authorize(socketId: string, callback: ChannelAuthorizationCallback) {\n super.authorize(\n socketId,\n (error: Error | null, authData: ChannelAuthorizationData) => {\n if (error) {\n callback(error, authData);\n return;\n }\n let sharedSecret = authData['shared_secret'];\n if (!sharedSecret) {\n callback(\n new Error(\n `No shared_secret key in auth payload for encrypted channel: ${this.name}`\n ),\n null\n );\n return;\n }\n this.key = decodeBase64(sharedSecret);\n delete authData['shared_secret'];\n callback(null, authData);\n }\n );\n }\n\n trigger(event: string, data: any): boolean {\n throw new Errors.UnsupportedFeature(\n 'Client events are not currently supported for encrypted channels'\n );\n }\n\n /** Handles an event. For internal use only.\n *\n * @param {PusherEvent} event\n */\n handleEvent(event: PusherEvent) {\n var eventName = event.event;\n var data = event.data;\n if (\n eventName.indexOf('pusher_internal:') === 0 ||\n eventName.indexOf('pusher:') === 0\n ) {\n super.handleEvent(event);\n return;\n }\n this.handleEncryptedEvent(eventName, data);\n }\n\n private handleEncryptedEvent(event: string, data: any): void {\n if (!this.key) {\n Logger.debug(\n 'Received encrypted event before key has been retrieved from the authEndpoint'\n );\n return;\n }\n if (!data.ciphertext || !data.nonce) {\n Logger.error(\n 'Unexpected format for encrypted event, expected object with `ciphertext` and `nonce` fields, got: ' +\n data\n );\n return;\n }\n let cipherText = decodeBase64(data.ciphertext);\n if (cipherText.length < this.nacl.secretbox.overheadLength) {\n Logger.error(\n `Expected encrypted event ciphertext length to be ${this.nacl.secretbox.overheadLength}, got: ${cipherText.length}`\n );\n return;\n }\n let nonce = decodeBase64(data.nonce);\n if (nonce.length < this.nacl.secretbox.nonceLength) {\n Logger.error(\n `Expected encrypted event nonce length to be ${this.nacl.secretbox.nonceLength}, got: ${nonce.length}`\n );\n return;\n }\n\n let bytes = this.nacl.secretbox.open(cipherText, nonce, this.key);\n if (bytes === null) {\n Logger.debug(\n 'Failed to decrypt an event, probably because it was encrypted with a different key. Fetching a new key from the authEndpoint...'\n );\n // Try a single time to retrieve a new auth key and decrypt the event with it\n // If this fails, a new key will be requested when a new message is received\n this.authorize(this.pusher.connection.socket_id, (error, authData) => {\n if (error) {\n Logger.error(\n `Failed to make a request to the authEndpoint: ${authData}. Unable to fetch new key, so dropping encrypted event`\n );\n return;\n }\n bytes = this.nacl.secretbox.open(cipherText, nonce, this.key);\n if (bytes === null) {\n Logger.error(\n `Failed to decrypt event with new key. Dropping encrypted event`\n );\n return;\n }\n this.emit(event, this.getDataToEmit(bytes));\n return;\n });\n return;\n }\n this.emit(event, this.getDataToEmit(bytes));\n }\n\n // Try and parse the decrypted bytes as JSON. If we can't parse it, just\n // return the utf-8 string\n getDataToEmit(bytes: Uint8Array): string {\n let raw = encodeUTF8(bytes);\n try {\n return JSON.parse(raw);\n } catch {\n return raw;\n }\n }\n}\n","import { default as EventsDispatcher } from '../events/dispatcher';\nimport { OneOffTimer as Timer } from '../utils/timers';\nimport { Config } from '../config';\nimport Logger from '../logger';\nimport HandshakePayload from './handshake/handshake_payload';\nimport Connection from './connection';\nimport Strategy from '../strategies/strategy';\nimport StrategyRunner from '../strategies/strategy_runner';\nimport * as Collections from '../utils/collections';\nimport Timeline from '../timeline/timeline';\nimport ConnectionManagerOptions from './connection_manager_options';\nimport Runtime from 'runtime';\n\nimport {\n ErrorCallbacks,\n HandshakeCallbacks,\n ConnectionCallbacks\n} from './callbacks';\nimport Action from './protocol/action';\n\n/** Manages connection to Pusher.\n *\n * Uses a strategy (currently only default), timers and network availability\n * info to establish a connection and export its state. In case of failures,\n * manages reconnection attempts.\n *\n * Exports state changes as following events:\n * - \"state_change\", { previous: p, current: state }\n * - state\n *\n * States:\n * - initialized - initial state, never transitioned to\n * - connecting - connection is being established\n * - connected - connection has been fully established\n * - disconnected - on requested disconnection\n * - unavailable - after connection timeout or when there's no network\n * - failed - when the connection strategy is not supported\n *\n * Options:\n * - unavailableTimeout - time to transition to unavailable state\n * - activityTimeout - time after which ping message should be sent\n * - pongTimeout - time for Pusher to respond with pong before reconnecting\n *\n * @param {String} key application key\n * @param {Object} options\n */\nexport default class ConnectionManager extends EventsDispatcher {\n key: string;\n options: ConnectionManagerOptions;\n state: string;\n connection: Connection;\n usingTLS: boolean;\n timeline: Timeline;\n socket_id: string;\n unavailableTimer: Timer;\n activityTimer: Timer;\n retryTimer: Timer;\n activityTimeout: number;\n strategy: Strategy;\n runner: StrategyRunner;\n errorCallbacks: ErrorCallbacks;\n handshakeCallbacks: HandshakeCallbacks;\n connectionCallbacks: ConnectionCallbacks;\n\n constructor(key: string, options: ConnectionManagerOptions) {\n super();\n this.state = 'initialized';\n this.connection = null;\n\n this.key = key;\n this.options = options;\n this.timeline = this.options.timeline;\n this.usingTLS = this.options.useTLS;\n\n this.errorCallbacks = this.buildErrorCallbacks();\n this.connectionCallbacks = this.buildConnectionCallbacks(\n this.errorCallbacks\n );\n this.handshakeCallbacks = this.buildHandshakeCallbacks(this.errorCallbacks);\n\n var Network = Runtime.getNetwork();\n\n Network.bind('online', () => {\n this.timeline.info({ netinfo: 'online' });\n if (this.state === 'connecting' || this.state === 'unavailable') {\n this.retryIn(0);\n }\n });\n Network.bind('offline', () => {\n this.timeline.info({ netinfo: 'offline' });\n if (this.connection) {\n this.sendActivityCheck();\n }\n });\n\n this.updateStrategy();\n }\n\n switchCluster(key: string) {\n this.key = key;\n // This ensures that the new config coming from\n // pusher instance are taken into account\n // such as appKey and cluster\n this.updateStrategy();\n this.retryIn(0);\n }\n\n /** Establishes a connection to Pusher.\n *\n * Does nothing when connection is already established. See top-level doc\n * to find events emitted on connection attempts.\n */\n connect() {\n if (this.connection || this.runner) {\n return;\n }\n if (!this.strategy.isSupported()) {\n this.updateState('failed');\n return;\n }\n this.updateState('connecting');\n this.startConnecting();\n this.setUnavailableTimer();\n }\n\n /** Sends raw data.\n *\n * @param {String} data\n */\n send(data) {\n if (this.connection) {\n return this.connection.send(data);\n } else {\n return false;\n }\n }\n\n /** Sends an event.\n *\n * @param {String} name\n * @param {String} data\n * @param {String} [channel]\n * @returns {Boolean} whether message was sent or not\n */\n send_event(name: string, data: any, channel?: string) {\n if (this.connection) {\n return this.connection.send_event(name, data, channel);\n } else {\n return false;\n }\n }\n\n /** Closes the connection. */\n disconnect() {\n this.disconnectInternally();\n this.updateState('disconnected');\n }\n\n isUsingTLS() {\n return this.usingTLS;\n }\n\n private startConnecting() {\n var callback = (error, handshake) => {\n if (error) {\n this.runner = this.strategy.connect(0, callback);\n } else {\n if (handshake.action === 'error') {\n this.emit('error', {\n type: 'HandshakeError',\n error: handshake.error\n });\n this.timeline.error({ handshakeError: handshake.error });\n } else {\n this.abortConnecting(); // we don't support switching connections yet\n this.handshakeCallbacks[handshake.action](handshake);\n }\n }\n };\n this.runner = this.strategy.connect(0, callback);\n }\n\n private abortConnecting() {\n if (this.runner) {\n this.runner.abort();\n this.runner = null;\n }\n }\n\n private disconnectInternally() {\n this.abortConnecting();\n this.clearRetryTimer();\n this.clearUnavailableTimer();\n if (this.connection) {\n var connection = this.abandonConnection();\n connection.close();\n }\n }\n\n private updateStrategy() {\n this.strategy = this.options.getStrategy({\n key: this.key,\n timeline: this.timeline,\n useTLS: this.usingTLS\n });\n }\n\n private retryIn(delay) {\n this.timeline.info({ action: 'retry', delay: delay });\n if (delay > 0) {\n this.emit('connecting_in', Math.round(delay / 1000));\n }\n this.retryTimer = new Timer(delay || 0, () => {\n this.disconnectInternally();\n this.connect();\n });\n }\n\n private clearRetryTimer() {\n if (this.retryTimer) {\n this.retryTimer.ensureAborted();\n this.retryTimer = null;\n }\n }\n\n private setUnavailableTimer() {\n this.unavailableTimer = new Timer(this.options.unavailableTimeout, () => {\n this.updateState('unavailable');\n });\n }\n\n private clearUnavailableTimer() {\n if (this.unavailableTimer) {\n this.unavailableTimer.ensureAborted();\n }\n }\n\n private sendActivityCheck() {\n this.stopActivityCheck();\n this.connection.ping();\n // wait for pong response\n this.activityTimer = new Timer(this.options.pongTimeout, () => {\n this.timeline.error({ pong_timed_out: this.options.pongTimeout });\n this.retryIn(0);\n });\n }\n\n private resetActivityCheck() {\n this.stopActivityCheck();\n // send ping after inactivity\n if (this.connection && !this.connection.handlesActivityChecks()) {\n this.activityTimer = new Timer(this.activityTimeout, () => {\n this.sendActivityCheck();\n });\n }\n }\n\n private stopActivityCheck() {\n if (this.activityTimer) {\n this.activityTimer.ensureAborted();\n }\n }\n\n private buildConnectionCallbacks(\n errorCallbacks: ErrorCallbacks\n ): ConnectionCallbacks {\n return Collections.extend({}, errorCallbacks, {\n message: message => {\n // includes pong messages from server\n this.resetActivityCheck();\n this.emit('message', message);\n },\n ping: () => {\n this.send_event('pusher:pong', {});\n },\n activity: () => {\n this.resetActivityCheck();\n },\n error: error => {\n // just emit error to user - socket will already be closed by browser\n this.emit('error', error);\n },\n closed: () => {\n this.abandonConnection();\n if (this.shouldRetry()) {\n this.retryIn(1000);\n }\n }\n });\n }\n\n private buildHandshakeCallbacks(\n errorCallbacks: ErrorCallbacks\n ): HandshakeCallbacks {\n return Collections.extend({}, errorCallbacks, {\n connected: (handshake: HandshakePayload) => {\n this.activityTimeout = Math.min(\n this.options.activityTimeout,\n handshake.activityTimeout,\n handshake.connection.activityTimeout || Infinity\n );\n this.clearUnavailableTimer();\n this.setConnection(handshake.connection);\n this.socket_id = this.connection.id;\n this.updateState('connected', { socket_id: this.socket_id });\n }\n });\n }\n\n private buildErrorCallbacks(): ErrorCallbacks {\n let withErrorEmitted = callback => {\n return (result: Action | HandshakePayload) => {\n if (result.error) {\n this.emit('error', { type: 'WebSocketError', error: result.error });\n }\n callback(result);\n };\n };\n\n return {\n tls_only: withErrorEmitted(() => {\n this.usingTLS = true;\n this.updateStrategy();\n this.retryIn(0);\n }),\n refused: withErrorEmitted(() => {\n this.disconnect();\n }),\n backoff: withErrorEmitted(() => {\n this.retryIn(1000);\n }),\n retry: withErrorEmitted(() => {\n this.retryIn(0);\n })\n };\n }\n\n private setConnection(connection) {\n this.connection = connection;\n for (var event in this.connectionCallbacks) {\n this.connection.bind(event, this.connectionCallbacks[event]);\n }\n this.resetActivityCheck();\n }\n\n private abandonConnection() {\n if (!this.connection) {\n return;\n }\n this.stopActivityCheck();\n for (var event in this.connectionCallbacks) {\n this.connection.unbind(event, this.connectionCallbacks[event]);\n }\n var connection = this.connection;\n this.connection = null;\n return connection;\n }\n\n private updateState(newState: string, data?: any) {\n var previousState = this.state;\n this.state = newState;\n if (previousState !== newState) {\n var newStateDescription = newState;\n if (newStateDescription === 'connected') {\n newStateDescription += ' with new socket ID ' + data.socket_id;\n }\n Logger.debug(\n 'State changed',\n previousState + ' -> ' + newStateDescription\n );\n this.timeline.info({ state: newState, params: data });\n this.emit('state_change', { previous: previousState, current: newState });\n this.emit(newState, data);\n }\n }\n\n private shouldRetry(): boolean {\n return this.state === 'connecting' || this.state === 'connected';\n }\n}\n","import Channel from './channel';\nimport * as Collections from '../utils/collections';\nimport ChannelTable from './channel_table';\nimport Factory from '../utils/factory';\nimport Pusher from '../pusher';\nimport Logger from '../logger';\nimport * as Errors from '../errors';\nimport urlStore from '../utils/url_store';\n\n/** Handles a channel map. */\nexport default class Channels {\n channels: ChannelTable;\n\n constructor() {\n this.channels = {};\n }\n\n /** Creates or retrieves an existing channel by its name.\n *\n * @param {String} name\n * @param {Pusher} pusher\n * @return {Channel}\n */\n add(name: string, pusher: Pusher) {\n if (!this.channels[name]) {\n this.channels[name] = createChannel(name, pusher);\n }\n return this.channels[name];\n }\n\n /** Returns a list of all channels\n *\n * @return {Array}\n */\n all(): Channel[] {\n return Collections.values(this.channels);\n }\n\n /** Finds a channel by its name.\n *\n * @param {String} name\n * @return {Channel} channel or null if it doesn't exist\n */\n find(name: string) {\n return this.channels[name];\n }\n\n /** Removes a channel from the map.\n *\n * @param {String} name\n */\n remove(name: string) {\n var channel = this.channels[name];\n delete this.channels[name];\n return channel;\n }\n\n /** Proxies disconnection signal to all channels. */\n disconnect() {\n Collections.objectApply(this.channels, function(channel) {\n channel.disconnect();\n });\n }\n}\n\nfunction createChannel(name: string, pusher: Pusher): Channel {\n if (name.indexOf('private-encrypted-') === 0) {\n if (pusher.config.nacl) {\n return Factory.createEncryptedChannel(name, pusher, pusher.config.nacl);\n }\n let errMsg =\n 'Tried to subscribe to a private-encrypted- channel but no nacl implementation available';\n let suffix = urlStore.buildLogSuffix('encryptedChannelSupport');\n throw new Errors.UnsupportedFeature(`${errMsg}. ${suffix}`);\n } else if (name.indexOf('private-') === 0) {\n return Factory.createPrivateChannel(name, pusher);\n } else if (name.indexOf('presence-') === 0) {\n return Factory.createPresenceChannel(name, pusher);\n } else if (name.indexOf('#') === 0) {\n throw new Errors.BadChannelName(\n 'Cannot create a channel with name \"' + name + '\".'\n );\n } else {\n return Factory.createChannel(name, pusher);\n }\n}\n","import AssistantToTheTransportManager from '../transports/assistant_to_the_transport_manager';\nimport PingDelayOptions from '../transports/ping_delay_options';\nimport Transport from '../transports/transport';\nimport TransportManager from '../transports/transport_manager';\nimport Handshake from '../connection/handshake';\nimport TransportConnection from '../transports/transport_connection';\nimport SocketHooks from '../http/socket_hooks';\nimport HTTPSocket from '../http/http_socket';\n\nimport Timeline from '../timeline/timeline';\nimport {\n default as TimelineSender,\n TimelineSenderOptions\n} from '../timeline/timeline_sender';\nimport PresenceChannel from '../channels/presence_channel';\nimport PrivateChannel from '../channels/private_channel';\nimport EncryptedChannel from '../channels/encrypted_channel';\nimport Channel from '../channels/channel';\nimport ConnectionManager from '../connection/connection_manager';\nimport ConnectionManagerOptions from '../connection/connection_manager_options';\nimport Ajax from '../http/ajax';\nimport Channels from '../channels/channels';\nimport Pusher from '../pusher';\nimport { Config } from '../config';\nimport * as nacl from 'tweetnacl';\n\nvar Factory = {\n createChannels(): Channels {\n return new Channels();\n },\n\n createConnectionManager(\n key: string,\n options: ConnectionManagerOptions\n ): ConnectionManager {\n return new ConnectionManager(key, options);\n },\n\n createChannel(name: string, pusher: Pusher): Channel {\n return new Channel(name, pusher);\n },\n\n createPrivateChannel(name: string, pusher: Pusher): PrivateChannel {\n return new PrivateChannel(name, pusher);\n },\n\n createPresenceChannel(name: string, pusher: Pusher): PresenceChannel {\n return new PresenceChannel(name, pusher);\n },\n\n createEncryptedChannel(\n name: string,\n pusher: Pusher,\n nacl: nacl\n ): EncryptedChannel {\n return new EncryptedChannel(name, pusher, nacl);\n },\n\n createTimelineSender(timeline: Timeline, options: TimelineSenderOptions) {\n return new TimelineSender(timeline, options);\n },\n\n createHandshake(\n transport: TransportConnection,\n callback: (HandshakePayload) => void\n ): Handshake {\n return new Handshake(transport, callback);\n },\n\n createAssistantToTheTransportManager(\n manager: TransportManager,\n transport: Transport,\n options: PingDelayOptions\n ): AssistantToTheTransportManager {\n return new AssistantToTheTransportManager(manager, transport, options);\n }\n};\n\nexport default Factory;\n","import AssistantToTheTransportManager from './assistant_to_the_transport_manager';\nimport Transport from './transport';\nimport PingDelayOptions from './ping_delay_options';\nimport Factory from '../utils/factory';\n\nexport interface TransportManagerOptions extends PingDelayOptions {\n lives?: number;\n}\n\n/** Keeps track of the number of lives left for a transport.\n *\n * In the beginning of a session, transports may be assigned a number of\n * lives. When an AssistantToTheTransportManager instance reports a transport\n * connection closed uncleanly, the transport loses a life. When the number\n * of lives drops to zero, the transport gets disabled by its manager.\n *\n * @param {Object} options\n */\nexport default class TransportManager {\n options: TransportManagerOptions;\n livesLeft: number;\n\n constructor(options: TransportManagerOptions) {\n this.options = options || {};\n this.livesLeft = this.options.lives || Infinity;\n }\n\n /** Creates a assistant for the transport.\n *\n * @param {Transport} transport\n * @returns {AssistantToTheTransportManager}\n */\n getAssistant(transport: Transport): AssistantToTheTransportManager {\n return Factory.createAssistantToTheTransportManager(this, transport, {\n minPingDelay: this.options.minPingDelay,\n maxPingDelay: this.options.maxPingDelay\n });\n }\n\n /** Returns whether the transport has any lives left.\n *\n * @returns {Boolean}\n */\n isAlive(): boolean {\n return this.livesLeft > 0;\n }\n\n /** Takes one life from the transport. */\n reportDeath() {\n this.livesLeft -= 1;\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport { OneOffTimer as Timer } from '../utils/timers';\nimport Strategy from './strategy';\nimport StrategyOptions from './strategy_options';\n\n/** Loops through strategies with optional timeouts.\n *\n * Options:\n * - loop - whether it should loop through the substrategy list\n * - timeout - initial timeout for a single substrategy\n * - timeoutLimit - maximum timeout\n *\n * @param {Strategy[]} strategies\n * @param {Object} options\n */\nexport default class SequentialStrategy implements Strategy {\n strategies: Strategy[];\n loop: boolean;\n failFast: boolean;\n timeout: number;\n timeoutLimit: number;\n\n constructor(strategies: Strategy[], options: StrategyOptions) {\n this.strategies = strategies;\n this.loop = Boolean(options.loop);\n this.failFast = Boolean(options.failFast);\n this.timeout = options.timeout;\n this.timeoutLimit = options.timeoutLimit;\n }\n\n isSupported(): boolean {\n return Collections.any(this.strategies, Util.method('isSupported'));\n }\n\n connect(minPriority: number, callback: Function) {\n var strategies = this.strategies;\n var current = 0;\n var timeout = this.timeout;\n var runner = null;\n\n var tryNextStrategy = (error, handshake) => {\n if (handshake) {\n callback(null, handshake);\n } else {\n current = current + 1;\n if (this.loop) {\n current = current % strategies.length;\n }\n\n if (current < strategies.length) {\n if (timeout) {\n timeout = timeout * 2;\n if (this.timeoutLimit) {\n timeout = Math.min(timeout, this.timeoutLimit);\n }\n }\n runner = this.tryStrategy(\n strategies[current],\n minPriority,\n { timeout, failFast: this.failFast },\n tryNextStrategy\n );\n } else {\n callback(true);\n }\n }\n };\n\n runner = this.tryStrategy(\n strategies[current],\n minPriority,\n { timeout: timeout, failFast: this.failFast },\n tryNextStrategy\n );\n\n return {\n abort: function() {\n runner.abort();\n },\n forceMinPriority: function(p) {\n minPriority = p;\n if (runner) {\n runner.forceMinPriority(p);\n }\n }\n };\n }\n\n private tryStrategy(\n strategy: Strategy,\n minPriority: number,\n options: StrategyOptions,\n callback: Function\n ) {\n var timer = null;\n var runner = null;\n\n if (options.timeout > 0) {\n timer = new Timer(options.timeout, function() {\n runner.abort();\n callback(true);\n });\n }\n\n runner = strategy.connect(minPriority, function(error, handshake) {\n if (error && timer && timer.isRunning() && !options.failFast) {\n // advance to the next strategy after the timeout\n return;\n }\n if (timer) {\n timer.ensureAborted();\n }\n callback(error, handshake);\n });\n\n return {\n abort: function() {\n if (timer) {\n timer.ensureAborted();\n }\n runner.abort();\n },\n forceMinPriority: function(p) {\n runner.forceMinPriority(p);\n }\n };\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport Strategy from './strategy';\n\n/** Launches all substrategies and emits prioritized connected transports.\n *\n * @param {Array} strategies\n */\nexport default class BestConnectedEverStrategy implements Strategy {\n strategies: Strategy[];\n\n constructor(strategies: Strategy[]) {\n this.strategies = strategies;\n }\n\n isSupported(): boolean {\n return Collections.any(this.strategies, Util.method('isSupported'));\n }\n\n connect(minPriority: number, callback: Function) {\n return connect(this.strategies, minPriority, function(i, runners) {\n return function(error, handshake) {\n runners[i].error = error;\n if (error) {\n if (allRunnersFailed(runners)) {\n callback(true);\n }\n return;\n }\n Collections.apply(runners, function(runner) {\n runner.forceMinPriority(handshake.transport.priority);\n });\n callback(null, handshake);\n };\n });\n }\n}\n\n/** Connects to all strategies in parallel.\n *\n * Callback builder should be a function that takes two arguments: index\n * and a list of runners. It should return another function that will be\n * passed to the substrategy with given index. Runners can be aborted using\n * abortRunner(s) functions from this class.\n *\n * @param {Array} strategies\n * @param {Function} callbackBuilder\n * @return {Object} strategy runner\n */\nfunction connect(\n strategies: Strategy[],\n minPriority: number,\n callbackBuilder: Function\n) {\n var runners = Collections.map(strategies, function(strategy, i, _, rs) {\n return strategy.connect(minPriority, callbackBuilder(i, rs));\n });\n return {\n abort: function() {\n Collections.apply(runners, abortRunner);\n },\n forceMinPriority: function(p) {\n Collections.apply(runners, function(runner) {\n runner.forceMinPriority(p);\n });\n }\n };\n}\n\nfunction allRunnersFailed(runners): boolean {\n return Collections.all(runners, function(runner) {\n return Boolean(runner.error);\n });\n}\n\nfunction abortRunner(runner) {\n if (!runner.error && !runner.aborted) {\n runner.abort();\n runner.aborted = true;\n }\n}\n","import Util from '../util';\nimport Runtime from 'runtime';\nimport Strategy from './strategy';\nimport SequentialStrategy from './sequential_strategy';\nimport StrategyOptions from './strategy_options';\nimport TransportStrategy from './transport_strategy';\nimport Timeline from '../timeline/timeline';\nimport * as Collections from '../utils/collections';\n\nexport interface TransportStrategyDictionary {\n [key: string]: TransportStrategy;\n}\n\n/** Caches the last successful transport and, after the first few attempts,\n * uses the cached transport for subsequent attempts.\n *\n * @param {Strategy} strategy\n * @param {Object} transports\n * @param {Object} options\n */\nexport default class WebSocketPrioritizedCachedStrategy implements Strategy {\n strategy: Strategy;\n transports: TransportStrategyDictionary;\n ttl: number;\n usingTLS: boolean;\n timeline: Timeline;\n\n constructor(\n strategy: Strategy,\n transports: TransportStrategyDictionary,\n options: StrategyOptions\n ) {\n this.strategy = strategy;\n this.transports = transports;\n this.ttl = options.ttl || 1800 * 1000;\n this.usingTLS = options.useTLS;\n this.timeline = options.timeline;\n }\n\n isSupported(): boolean {\n return this.strategy.isSupported();\n }\n\n connect(minPriority: number, callback: Function) {\n var usingTLS = this.usingTLS;\n var info = fetchTransportCache(usingTLS);\n var cacheSkipCount = info && info.cacheSkipCount ? info.cacheSkipCount : 0;\n\n var strategies = [this.strategy];\n if (info && info.timestamp + this.ttl >= Util.now()) {\n var transport = this.transports[info.transport];\n if (transport) {\n if (['ws', 'wss'].includes(info.transport) || cacheSkipCount > 3) {\n this.timeline.info({\n cached: true,\n transport: info.transport,\n latency: info.latency\n });\n strategies.push(\n new SequentialStrategy([transport], {\n timeout: info.latency * 2 + 1000,\n failFast: true\n })\n );\n } else {\n cacheSkipCount++;\n }\n }\n }\n\n var startTimestamp = Util.now();\n var runner = strategies\n .pop()\n .connect(minPriority, function cb(error, handshake) {\n if (error) {\n flushTransportCache(usingTLS);\n if (strategies.length > 0) {\n startTimestamp = Util.now();\n runner = strategies.pop().connect(minPriority, cb);\n } else {\n callback(error);\n }\n } else {\n storeTransportCache(\n usingTLS,\n handshake.transport.name,\n Util.now() - startTimestamp,\n cacheSkipCount\n );\n callback(null, handshake);\n }\n });\n\n return {\n abort: function() {\n runner.abort();\n },\n forceMinPriority: function(p) {\n minPriority = p;\n if (runner) {\n runner.forceMinPriority(p);\n }\n }\n };\n }\n}\n\nfunction getTransportCacheKey(usingTLS: boolean): string {\n return 'pusherTransport' + (usingTLS ? 'TLS' : 'NonTLS');\n}\n\nfunction fetchTransportCache(usingTLS: boolean): any {\n var storage = Runtime.getLocalStorage();\n if (storage) {\n try {\n var serializedCache = storage[getTransportCacheKey(usingTLS)];\n if (serializedCache) {\n return JSON.parse(serializedCache);\n }\n } catch (e) {\n flushTransportCache(usingTLS);\n }\n }\n return null;\n}\n\nfunction storeTransportCache(\n usingTLS: boolean,\n transport: TransportStrategy,\n latency: number,\n cacheSkipCount: number\n) {\n var storage = Runtime.getLocalStorage();\n if (storage) {\n try {\n storage[getTransportCacheKey(usingTLS)] = Collections.safeJSONStringify({\n timestamp: Util.now(),\n transport: transport,\n latency: latency,\n cacheSkipCount: cacheSkipCount\n });\n } catch (e) {\n // catch over quota exceptions raised by localStorage\n }\n }\n}\n\nfunction flushTransportCache(usingTLS: boolean) {\n var storage = Runtime.getLocalStorage();\n if (storage) {\n try {\n delete storage[getTransportCacheKey(usingTLS)];\n } catch (e) {\n // catch exceptions raised by localStorage\n }\n }\n}\n","import { OneOffTimer as Timer } from '../utils/timers';\nimport Strategy from './strategy';\nimport StrategyOptions from './strategy_options';\n\n/** Runs substrategy after specified delay.\n *\n * Options:\n * - delay - time in miliseconds to delay the substrategy attempt\n *\n * @param {Strategy} strategy\n * @param {Object} options\n */\nexport default class DelayedStrategy implements Strategy {\n strategy: Strategy;\n options: { delay: number };\n\n constructor(strategy: Strategy, { delay: number }) {\n this.strategy = strategy;\n this.options = { delay: number };\n }\n\n isSupported(): boolean {\n return this.strategy.isSupported();\n }\n\n connect(minPriority: number, callback: Function) {\n var strategy = this.strategy;\n var runner;\n var timer = new Timer(this.options.delay, function() {\n runner = strategy.connect(minPriority, callback);\n });\n\n return {\n abort: function() {\n timer.ensureAborted();\n if (runner) {\n runner.abort();\n }\n },\n forceMinPriority: function(p) {\n minPriority = p;\n if (runner) {\n runner.forceMinPriority(p);\n }\n }\n };\n }\n}\n","import Strategy from './strategy';\nimport StrategyRunner from './strategy_runner';\n\n/** Proxies method calls to one of substrategies basing on the test function.\n *\n * @param {Function} test\n * @param {Strategy} trueBranch strategy used when test returns true\n * @param {Strategy} falseBranch strategy used when test returns false\n */\nexport default class IfStrategy implements Strategy {\n test: () => boolean;\n trueBranch: Strategy;\n falseBranch: Strategy;\n\n constructor(\n test: () => boolean,\n trueBranch: Strategy,\n falseBranch: Strategy\n ) {\n this.test = test;\n this.trueBranch = trueBranch;\n this.falseBranch = falseBranch;\n }\n\n isSupported(): boolean {\n var branch = this.test() ? this.trueBranch : this.falseBranch;\n return branch.isSupported();\n }\n\n connect(minPriority: number, callback: Function): StrategyRunner {\n var branch = this.test() ? this.trueBranch : this.falseBranch;\n return branch.connect(minPriority, callback);\n }\n}\n","import Strategy from './strategy';\nimport StrategyRunner from './strategy_runner';\n\n/** Launches the substrategy and terminates on the first open connection.\n *\n * @param {Strategy} strategy\n */\nexport default class FirstConnectedStrategy implements Strategy {\n strategy: Strategy;\n\n constructor(strategy: Strategy) {\n this.strategy = strategy;\n }\n\n isSupported(): boolean {\n return this.strategy.isSupported();\n }\n\n connect(minPriority: number, callback: Function): StrategyRunner {\n var runner = this.strategy.connect(minPriority, function(error, handshake) {\n if (handshake) {\n runner.abort();\n }\n callback(error, handshake);\n });\n return runner;\n }\n}\n","import * as Collections from 'core/utils/collections';\nimport TransportManager from 'core/transports/transport_manager';\nimport Strategy from 'core/strategies/strategy';\nimport StrategyOptions from 'core/strategies/strategy_options';\nimport SequentialStrategy from 'core/strategies/sequential_strategy';\nimport BestConnectedEverStrategy from 'core/strategies/best_connected_ever_strategy';\nimport WebSocketPrioritizedCachedStrategy, {\n TransportStrategyDictionary\n} from 'core/strategies/websocket_prioritized_cached_strategy';\nimport DelayedStrategy from 'core/strategies/delayed_strategy';\nimport IfStrategy from 'core/strategies/if_strategy';\nimport FirstConnectedStrategy from 'core/strategies/first_connected_strategy';\nimport { Config } from 'core/config';\n\nfunction testSupportsStrategy(strategy: Strategy) {\n return function() {\n return strategy.isSupported();\n };\n}\n\nvar getDefaultStrategy = function(\n config: Config,\n baseOptions: StrategyOptions,\n defineTransport: Function\n): Strategy {\n var definedTransports = {};\n\n function defineTransportStrategy(\n name: string,\n type: string,\n priority: number,\n options: StrategyOptions,\n manager?: TransportManager\n ) {\n var transport = defineTransport(\n config,\n name,\n type,\n priority,\n options,\n manager\n );\n\n definedTransports[name] = transport;\n\n return transport;\n }\n\n var ws_options: StrategyOptions = Object.assign({}, baseOptions, {\n hostNonTLS: config.wsHost + ':' + config.wsPort,\n hostTLS: config.wsHost + ':' + config.wssPort,\n httpPath: config.wsPath\n });\n var wss_options: StrategyOptions = Object.assign({}, ws_options, {\n useTLS: true\n });\n var sockjs_options: StrategyOptions = Object.assign({}, baseOptions, {\n hostNonTLS: config.httpHost + ':' + config.httpPort,\n hostTLS: config.httpHost + ':' + config.httpsPort,\n httpPath: config.httpPath\n });\n\n var timeouts = {\n loop: true,\n timeout: 15000,\n timeoutLimit: 60000\n };\n\n var ws_manager = new TransportManager({\n minPingDelay: 10000,\n maxPingDelay: config.activityTimeout\n });\n var streaming_manager = new TransportManager({\n lives: 2,\n minPingDelay: 10000,\n maxPingDelay: config.activityTimeout\n });\n\n var ws_transport = defineTransportStrategy(\n 'ws',\n 'ws',\n 3,\n ws_options,\n ws_manager\n );\n var wss_transport = defineTransportStrategy(\n 'wss',\n 'ws',\n 3,\n wss_options,\n ws_manager\n );\n var sockjs_transport = defineTransportStrategy(\n 'sockjs',\n 'sockjs',\n 1,\n sockjs_options\n );\n var xhr_streaming_transport = defineTransportStrategy(\n 'xhr_streaming',\n 'xhr_streaming',\n 1,\n sockjs_options,\n streaming_manager\n );\n var xdr_streaming_transport = defineTransportStrategy(\n 'xdr_streaming',\n 'xdr_streaming',\n 1,\n sockjs_options,\n streaming_manager\n );\n var xhr_polling_transport = defineTransportStrategy(\n 'xhr_polling',\n 'xhr_polling',\n 1,\n sockjs_options\n );\n var xdr_polling_transport = defineTransportStrategy(\n 'xdr_polling',\n 'xdr_polling',\n 1,\n sockjs_options\n );\n\n var ws_loop = new SequentialStrategy([ws_transport], timeouts);\n var wss_loop = new SequentialStrategy([wss_transport], timeouts);\n var sockjs_loop = new SequentialStrategy([sockjs_transport], timeouts);\n var streaming_loop = new SequentialStrategy(\n [\n new IfStrategy(\n testSupportsStrategy(xhr_streaming_transport),\n xhr_streaming_transport,\n xdr_streaming_transport\n )\n ],\n timeouts\n );\n var polling_loop = new SequentialStrategy(\n [\n new IfStrategy(\n testSupportsStrategy(xhr_polling_transport),\n xhr_polling_transport,\n xdr_polling_transport\n )\n ],\n timeouts\n );\n\n var http_loop = new SequentialStrategy(\n [\n new IfStrategy(\n testSupportsStrategy(streaming_loop),\n new BestConnectedEverStrategy([\n streaming_loop,\n new DelayedStrategy(polling_loop, { delay: 4000 })\n ]),\n polling_loop\n )\n ],\n timeouts\n );\n\n var http_fallback_loop = new IfStrategy(\n testSupportsStrategy(http_loop),\n http_loop,\n sockjs_loop\n );\n\n var wsStrategy;\n if (baseOptions.useTLS) {\n wsStrategy = new BestConnectedEverStrategy([\n ws_loop,\n new DelayedStrategy(http_fallback_loop, { delay: 2000 })\n ]);\n } else {\n wsStrategy = new BestConnectedEverStrategy([\n ws_loop,\n new DelayedStrategy(wss_loop, { delay: 2000 }),\n new DelayedStrategy(http_fallback_loop, { delay: 5000 })\n ]);\n }\n\n return new WebSocketPrioritizedCachedStrategy(\n new FirstConnectedStrategy(\n new IfStrategy(\n testSupportsStrategy(ws_transport),\n wsStrategy,\n http_fallback_loop\n )\n ),\n definedTransports,\n {\n ttl: 1800000,\n timeline: baseOptions.timeline,\n useTLS: baseOptions.useTLS\n }\n );\n};\n\nexport default getDefaultStrategy;\n","import HTTPRequest from 'core/http/http_request';\nimport RequestHooks from 'core/http/request_hooks';\nimport Ajax from 'core/http/ajax';\nimport * as Errors from 'core/errors';\n\nvar hooks: RequestHooks = {\n getRequest: function(socket: HTTPRequest): Ajax {\n var xdr = new (window).XDomainRequest();\n xdr.ontimeout = function() {\n socket.emit('error', new Errors.RequestTimedOut());\n socket.close();\n };\n xdr.onerror = function(e) {\n socket.emit('error', e);\n socket.close();\n };\n xdr.onprogress = function() {\n if (xdr.responseText && xdr.responseText.length > 0) {\n socket.onChunk(200, xdr.responseText);\n }\n };\n xdr.onload = function() {\n if (xdr.responseText && xdr.responseText.length > 0) {\n socket.onChunk(200, xdr.responseText);\n }\n socket.emit('finished', 200);\n socket.close();\n };\n return xdr;\n },\n abortRequest: function(xdr: Ajax) {\n xdr.ontimeout = xdr.onerror = xdr.onprogress = xdr.onload = null;\n xdr.abort();\n }\n};\n\nexport default hooks;\n","import Runtime from 'runtime';\nimport RequestHooks from './request_hooks';\nimport Ajax from './ajax';\nimport { default as EventsDispatcher } from '../events/dispatcher';\n\nconst MAX_BUFFER_LENGTH = 256 * 1024;\n\nexport default class HTTPRequest extends EventsDispatcher {\n hooks: RequestHooks;\n method: string;\n url: string;\n position: number;\n xhr: Ajax;\n unloader: Function;\n\n constructor(hooks: RequestHooks, method: string, url: string) {\n super();\n this.hooks = hooks;\n this.method = method;\n this.url = url;\n }\n\n start(payload?: any) {\n this.position = 0;\n this.xhr = this.hooks.getRequest(this);\n\n this.unloader = () => {\n this.close();\n };\n Runtime.addUnloadListener(this.unloader);\n\n this.xhr.open(this.method, this.url, true);\n\n if (this.xhr.setRequestHeader) {\n this.xhr.setRequestHeader('Content-Type', 'application/json'); // ReactNative doesn't set this header by default.\n }\n this.xhr.send(payload);\n }\n\n close() {\n if (this.unloader) {\n Runtime.removeUnloadListener(this.unloader);\n this.unloader = null;\n }\n if (this.xhr) {\n this.hooks.abortRequest(this.xhr);\n this.xhr = null;\n }\n }\n\n onChunk(status: number, data: any) {\n while (true) {\n var chunk = this.advanceBuffer(data);\n if (chunk) {\n this.emit('chunk', { status: status, data: chunk });\n } else {\n break;\n }\n }\n if (this.isBufferTooLong(data)) {\n this.emit('buffer_too_long');\n }\n }\n\n private advanceBuffer(buffer: any[]): any {\n var unreadData = buffer.slice(this.position);\n var endOfLinePosition = unreadData.indexOf('\\n');\n\n if (endOfLinePosition !== -1) {\n this.position += endOfLinePosition + 1;\n return unreadData.slice(0, endOfLinePosition);\n } else {\n // chunk is not finished yet, don't move the buffer pointer\n return null;\n }\n }\n\n private isBufferTooLong(buffer: any): boolean {\n return this.position === buffer.length && buffer.length > MAX_BUFFER_LENGTH;\n }\n}\n","enum State {\n CONNECTING = 0,\n OPEN = 1,\n CLOSED = 3\n}\n\nexport default State;\n","import URLLocation from './url_location';\nimport State from './state';\nimport Socket from '../socket';\nimport SocketHooks from './socket_hooks';\nimport Util from '../util';\nimport Ajax from './ajax';\nimport HTTPRequest from './http_request';\nimport Runtime from 'runtime';\n\nvar autoIncrement = 1;\n\nclass HTTPSocket implements Socket {\n hooks: SocketHooks;\n session: string;\n location: URLLocation;\n readyState: State;\n stream: HTTPRequest;\n\n onopen: () => void;\n onerror: (error: any) => void;\n onclose: (closeEvent: any) => void;\n onmessage: (message: any) => void;\n onactivity: () => void;\n\n constructor(hooks: SocketHooks, url: string) {\n this.hooks = hooks;\n this.session = randomNumber(1000) + '/' + randomString(8);\n this.location = getLocation(url);\n this.readyState = State.CONNECTING;\n this.openStream();\n }\n\n send(payload: any) {\n return this.sendRaw(JSON.stringify([payload]));\n }\n\n ping() {\n this.hooks.sendHeartbeat(this);\n }\n\n close(code: any, reason: any) {\n this.onClose(code, reason, true);\n }\n\n /** For internal use only */\n sendRaw(payload: any): boolean {\n if (this.readyState === State.OPEN) {\n try {\n Runtime.createSocketRequest(\n 'POST',\n getUniqueURL(getSendURL(this.location, this.session))\n ).start(payload);\n return true;\n } catch (e) {\n return false;\n }\n } else {\n return false;\n }\n }\n\n /** For internal use only */\n reconnect() {\n this.closeStream();\n this.openStream();\n }\n\n /** For internal use only */\n onClose(code, reason, wasClean) {\n this.closeStream();\n this.readyState = State.CLOSED;\n if (this.onclose) {\n this.onclose({\n code: code,\n reason: reason,\n wasClean: wasClean\n });\n }\n }\n\n private onChunk(chunk) {\n if (chunk.status !== 200) {\n return;\n }\n if (this.readyState === State.OPEN) {\n this.onActivity();\n }\n\n var payload;\n var type = chunk.data.slice(0, 1);\n switch (type) {\n case 'o':\n payload = JSON.parse(chunk.data.slice(1) || '{}');\n this.onOpen(payload);\n break;\n case 'a':\n payload = JSON.parse(chunk.data.slice(1) || '[]');\n for (var i = 0; i < payload.length; i++) {\n this.onEvent(payload[i]);\n }\n break;\n case 'm':\n payload = JSON.parse(chunk.data.slice(1) || 'null');\n this.onEvent(payload);\n break;\n case 'h':\n this.hooks.onHeartbeat(this);\n break;\n case 'c':\n payload = JSON.parse(chunk.data.slice(1) || '[]');\n this.onClose(payload[0], payload[1], true);\n break;\n }\n }\n\n private onOpen(options) {\n if (this.readyState === State.CONNECTING) {\n if (options && options.hostname) {\n this.location.base = replaceHost(this.location.base, options.hostname);\n }\n this.readyState = State.OPEN;\n\n if (this.onopen) {\n this.onopen();\n }\n } else {\n this.onClose(1006, 'Server lost session', true);\n }\n }\n\n private onEvent(event) {\n if (this.readyState === State.OPEN && this.onmessage) {\n this.onmessage({ data: event });\n }\n }\n\n private onActivity() {\n if (this.onactivity) {\n this.onactivity();\n }\n }\n\n private onError(error) {\n if (this.onerror) {\n this.onerror(error);\n }\n }\n\n private openStream() {\n this.stream = Runtime.createSocketRequest(\n 'POST',\n getUniqueURL(this.hooks.getReceiveURL(this.location, this.session))\n );\n\n this.stream.bind('chunk', chunk => {\n this.onChunk(chunk);\n });\n this.stream.bind('finished', status => {\n this.hooks.onFinished(this, status);\n });\n this.stream.bind('buffer_too_long', () => {\n this.reconnect();\n });\n\n try {\n this.stream.start();\n } catch (error) {\n Util.defer(() => {\n this.onError(error);\n this.onClose(1006, 'Could not start streaming', false);\n });\n }\n }\n\n private closeStream() {\n if (this.stream) {\n this.stream.unbind_all();\n this.stream.close();\n this.stream = null;\n }\n }\n}\n\nfunction getLocation(url): URLLocation {\n var parts = /([^\\?]*)\\/*(\\??.*)/.exec(url);\n return {\n base: parts[1],\n queryString: parts[2]\n };\n}\n\nfunction getSendURL(url: URLLocation, session: string): string {\n return url.base + '/' + session + '/xhr_send';\n}\n\nfunction getUniqueURL(url: string): string {\n var separator = url.indexOf('?') === -1 ? '?' : '&';\n return url + separator + 't=' + +new Date() + '&n=' + autoIncrement++;\n}\n\nfunction replaceHost(url: string, hostname: string): string {\n var urlParts = /(https?:\\/\\/)([^\\/:]+)((\\/|:)?.*)/.exec(url);\n return urlParts[1] + hostname + urlParts[3];\n}\n\nfunction randomNumber(max: number): number {\n return Runtime.randomInt(max);\n}\n\nfunction randomString(length: number): string {\n var result = [];\n\n for (var i = 0; i < length; i++) {\n result.push(randomNumber(32).toString(32));\n }\n\n return result.join('');\n}\n\nexport default HTTPSocket;\n","enum TimelineLevel {\n ERROR = 3,\n INFO = 6,\n DEBUG = 7\n}\n\nexport default TimelineLevel;\n","import SocketHooks from './socket_hooks';\nimport HTTPSocket from './http_socket';\n\nvar hooks: SocketHooks = {\n getReceiveURL: function(url, session) {\n return url.base + '/' + session + '/xhr_streaming' + url.queryString;\n },\n onHeartbeat: function(socket) {\n socket.sendRaw('[]');\n },\n sendHeartbeat: function(socket) {\n socket.sendRaw('[]');\n },\n onFinished: function(socket, status) {\n socket.onClose(1006, 'Connection interrupted (' + status + ')', false);\n }\n};\n\nexport default hooks;\n","import SocketHooks from './socket_hooks';\nimport URLLocation from './url_location';\nimport HTTPSocket from './http_socket';\n\nvar hooks: SocketHooks = {\n getReceiveURL: function(url: URLLocation, session: string): string {\n return url.base + '/' + session + '/xhr' + url.queryString;\n },\n onHeartbeat: function() {\n // next HTTP request will reset server's activity timer\n },\n sendHeartbeat: function(socket) {\n socket.sendRaw('[]');\n },\n onFinished: function(socket, status) {\n if (status === 200) {\n socket.reconnect();\n } else {\n socket.onClose(1006, 'Connection interrupted (' + status + ')', false);\n }\n }\n};\n\nexport default hooks;\n","import HTTPRequest from 'core/http/http_request';\nimport RequestHooks from 'core/http/request_hooks';\nimport Ajax from 'core/http/ajax';\nimport Runtime from 'runtime';\n\nvar hooks: RequestHooks = {\n getRequest: function(socket: HTTPRequest): Ajax {\n var Constructor = Runtime.getXHRAPI();\n var xhr = new Constructor();\n xhr.onreadystatechange = xhr.onprogress = function() {\n switch (xhr.readyState) {\n case 3:\n if (xhr.responseText && xhr.responseText.length > 0) {\n socket.onChunk(xhr.status, xhr.responseText);\n }\n break;\n case 4:\n // this happens only on errors, never after calling close\n if (xhr.responseText && xhr.responseText.length > 0) {\n socket.onChunk(xhr.status, xhr.responseText);\n }\n socket.emit('finished', xhr.status);\n socket.close();\n break;\n }\n };\n return xhr;\n },\n abortRequest: function(xhr: Ajax) {\n xhr.onreadystatechange = null;\n xhr.abort();\n }\n};\n\nexport default hooks;\n","import HTTPRequest from 'core/http/http_request';\nimport HTTPSocket from 'core/http/http_socket';\nimport SocketHooks from 'core/http/socket_hooks';\nimport RequestHooks from 'core/http/request_hooks';\nimport streamingHooks from 'core/http/http_streaming_socket';\nimport pollingHooks from 'core/http/http_polling_socket';\nimport xhrHooks from './http_xhr_request';\nimport HTTPFactory from 'core/http/http_factory';\n\nvar HTTP: HTTPFactory = {\n createStreamingSocket(url: string): HTTPSocket {\n return this.createSocket(streamingHooks, url);\n },\n\n createPollingSocket(url: string): HTTPSocket {\n return this.createSocket(pollingHooks, url);\n },\n\n createSocket(hooks: SocketHooks, url: string): HTTPSocket {\n return new HTTPSocket(hooks, url);\n },\n\n createXHR(method: string, url: string): HTTPRequest {\n return this.createRequest(xhrHooks, method, url);\n },\n\n createRequest(hooks: RequestHooks, method: string, url: string): HTTPRequest {\n return new HTTPRequest(hooks, method, url);\n }\n};\n\nexport default HTTP;\n","import xdrHooks from './http_xdomain_request';\nimport HTTP from 'isomorphic/http/http';\n\nHTTP.createXDR = function(method, url) {\n return this.createRequest(xdrHooks, method, url);\n};\n\nexport default HTTP;\n","import Browser from './browser';\nimport { Dependencies, DependenciesReceivers } from './dom/dependencies';\nimport { AuthTransport, AuthTransports } from 'core/auth/auth_transports';\nimport xhrAuth from 'isomorphic/auth/xhr_auth';\nimport jsonpAuth from './auth/jsonp_auth';\nimport TimelineTransport from 'core/timeline/timeline_transport';\nimport TimelineSender from 'core/timeline/timeline_sender';\nimport ScriptRequest from './dom/script_request';\nimport JSONPRequest from './dom/jsonp_request';\nimport * as Collections from 'core/utils/collections';\nimport { ScriptReceivers } from './dom/script_receiver_factory';\nimport jsonpTimeline from './timeline/jsonp_timeline';\nimport Transports from './transports/transports';\nimport Ajax from 'core/http/ajax';\nimport { Network } from './net_info';\nimport getDefaultStrategy from './default_strategy';\nimport transportConnectionInitializer from './transports/transport_connection_initializer';\nimport HTTPFactory from './http/http';\nimport HTTPRequest from 'core/http/http_request';\n\nvar Runtime: Browser = {\n // for jsonp auth\n nextAuthCallbackID: 1,\n auth_callbacks: {},\n ScriptReceivers,\n DependenciesReceivers,\n getDefaultStrategy,\n Transports,\n transportConnectionInitializer,\n HTTPFactory,\n\n TimelineTransport: jsonpTimeline,\n\n getXHRAPI() {\n return window.XMLHttpRequest;\n },\n\n getWebSocketAPI() {\n return window.WebSocket || window.MozWebSocket;\n },\n\n setup(PusherClass): void {\n (window).Pusher = PusherClass; // JSONp requires Pusher to be in the global scope.\n var initializeOnDocumentBody = () => {\n this.onDocumentBody(PusherClass.ready);\n };\n if (!(window).JSON) {\n Dependencies.load('json2', {}, initializeOnDocumentBody);\n } else {\n initializeOnDocumentBody();\n }\n },\n\n getDocument(): Document {\n return document;\n },\n\n getProtocol(): string {\n return this.getDocument().location.protocol;\n },\n\n getAuthorizers(): AuthTransports {\n return { ajax: xhrAuth, jsonp: jsonpAuth };\n },\n\n onDocumentBody(callback: Function) {\n if (document.body) {\n callback();\n } else {\n setTimeout(() => {\n this.onDocumentBody(callback);\n }, 0);\n }\n },\n\n createJSONPRequest(url: string, data: any): JSONPRequest {\n return new JSONPRequest(url, data);\n },\n\n createScriptRequest(src: string): ScriptRequest {\n return new ScriptRequest(src);\n },\n\n getLocalStorage() {\n try {\n return window.localStorage;\n } catch (e) {\n return undefined;\n }\n },\n\n createXHR(): Ajax {\n if (this.getXHRAPI()) {\n return this.createXMLHttpRequest();\n } else {\n return this.createMicrosoftXHR();\n }\n },\n\n createXMLHttpRequest(): Ajax {\n var Constructor = this.getXHRAPI();\n return new Constructor();\n },\n\n createMicrosoftXHR(): Ajax {\n return new ActiveXObject('Microsoft.XMLHTTP');\n },\n\n getNetwork() {\n return Network;\n },\n\n createWebSocket(url: string): any {\n var Constructor = this.getWebSocketAPI();\n return new Constructor(url);\n },\n\n createSocketRequest(method: string, url: string): HTTPRequest {\n if (this.isXHRSupported()) {\n return this.HTTPFactory.createXHR(method, url);\n } else if (this.isXDRSupported(url.indexOf('https:') === 0)) {\n return this.HTTPFactory.createXDR(method, url);\n } else {\n throw 'Cross-origin HTTP requests are not supported';\n }\n },\n\n isXHRSupported(): boolean {\n var Constructor = this.getXHRAPI();\n return (\n Boolean(Constructor) && new Constructor().withCredentials !== undefined\n );\n },\n\n isXDRSupported(useTLS?: boolean): boolean {\n var protocol = useTLS ? 'https:' : 'http:';\n var documentProtocol = this.getProtocol();\n return (\n Boolean(window['XDomainRequest']) && documentProtocol === protocol\n );\n },\n\n addUnloadListener(listener: any) {\n if (window.addEventListener !== undefined) {\n window.addEventListener('unload', listener, false);\n } else if (window.attachEvent !== undefined) {\n window.attachEvent('onunload', listener);\n }\n },\n\n removeUnloadListener(listener: any) {\n if (window.addEventListener !== undefined) {\n window.removeEventListener('unload', listener, false);\n } else if (window.detachEvent !== undefined) {\n window.detachEvent('onunload', listener);\n }\n },\n\n randomInt(max: number): number {\n /**\n * Return values in the range of [0, 1[\n */\n const random = function() {\n const crypto = window.crypto || window['msCrypto'];\n const random = crypto.getRandomValues(new Uint32Array(1))[0];\n\n return random / 2 ** 32;\n };\n\n return Math.floor(random() * max);\n }\n};\n\nexport default Runtime;\n","import { Dependencies } from '../dom/dependencies';\n\n/** Initializes the transport.\n *\n * Fetches resources if needed and then transitions to initialized.\n */\nexport default function() {\n var self = this;\n\n self.timeline.info(\n self.buildTimelineMessage({\n transport: self.name + (self.options.useTLS ? 's' : '')\n })\n );\n\n if (self.hooks.isInitialized()) {\n self.changeState('initialized');\n } else if (self.hooks.file) {\n self.changeState('initializing');\n Dependencies.load(\n self.hooks.file,\n { useTLS: self.options.useTLS },\n function(error, callback) {\n if (self.hooks.isInitialized()) {\n self.changeState('initialized');\n callback(true);\n } else {\n if (error) {\n self.onError(error);\n }\n self.onClose();\n callback(false);\n }\n }\n );\n } else {\n self.onClose();\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport { default as Level } from './level';\n\nexport interface TimelineOptions {\n level?: Level;\n limit?: number;\n version?: string;\n cluster?: string;\n features?: string[];\n params?: any;\n}\n\nexport default class Timeline {\n key: string;\n session: number;\n events: any[];\n options: TimelineOptions;\n sent: number;\n uniqueID: number;\n\n constructor(key: string, session: number, options: TimelineOptions) {\n this.key = key;\n this.session = session;\n this.events = [];\n this.options = options || {};\n this.sent = 0;\n this.uniqueID = 0;\n }\n\n log(level, event) {\n if (level <= this.options.level) {\n this.events.push(\n Collections.extend({}, event, { timestamp: Util.now() })\n );\n if (this.options.limit && this.events.length > this.options.limit) {\n this.events.shift();\n }\n }\n }\n\n error(event) {\n this.log(Level.ERROR, event);\n }\n\n info(event) {\n this.log(Level.INFO, event);\n }\n\n debug(event) {\n this.log(Level.DEBUG, event);\n }\n\n isEmpty() {\n return this.events.length === 0;\n }\n\n send(sendfn, callback) {\n var data = Collections.extend(\n {\n session: this.session,\n bundle: this.sent + 1,\n key: this.key,\n lib: 'js',\n version: this.options.version,\n cluster: this.options.cluster,\n features: this.options.features,\n timeline: this.events\n },\n this.options.params\n );\n\n this.events = [];\n sendfn(data, (error, result) => {\n if (!error) {\n this.sent++;\n }\n if (callback) {\n callback(error, result);\n }\n });\n\n return true;\n }\n\n generateUniqueID(): number {\n this.uniqueID++;\n return this.uniqueID;\n }\n}\n","import Factory from '../utils/factory';\nimport Util from '../util';\nimport * as Errors from '../errors';\nimport * as Collections from '../utils/collections';\nimport Strategy from './strategy';\nimport Transport from '../transports/transport';\nimport StrategyOptions from './strategy_options';\nimport Handshake from '../connection/handshake';\n\n/** Provides a strategy interface for transports.\n *\n * @param {String} name\n * @param {Number} priority\n * @param {Class} transport\n * @param {Object} options\n */\nexport default class TransportStrategy implements Strategy {\n name: string;\n priority: number;\n transport: Transport;\n options: StrategyOptions;\n\n constructor(\n name: string,\n priority: number,\n transport: Transport,\n options: StrategyOptions\n ) {\n this.name = name;\n this.priority = priority;\n this.transport = transport;\n this.options = options || {};\n }\n\n /** Returns whether the transport is supported in the browser.\n *\n * @returns {Boolean}\n */\n isSupported(): boolean {\n return this.transport.isSupported({\n useTLS: this.options.useTLS\n });\n }\n\n /** Launches a connection attempt and returns a strategy runner.\n *\n * @param {Function} callback\n * @return {Object} strategy runner\n */\n connect(minPriority: number, callback: Function) {\n if (!this.isSupported()) {\n return failAttempt(new Errors.UnsupportedStrategy(), callback);\n } else if (this.priority < minPriority) {\n return failAttempt(new Errors.TransportPriorityTooLow(), callback);\n }\n\n var connected = false;\n var transport = this.transport.createConnection(\n this.name,\n this.priority,\n this.options.key,\n this.options\n );\n var handshake = null;\n\n var onInitialized = function() {\n transport.unbind('initialized', onInitialized);\n transport.connect();\n };\n var onOpen = function() {\n handshake = Factory.createHandshake(transport, function(result) {\n connected = true;\n unbindListeners();\n callback(null, result);\n });\n };\n var onError = function(error) {\n unbindListeners();\n callback(error);\n };\n var onClosed = function() {\n unbindListeners();\n var serializedTransport;\n\n // The reason for this try/catch block is that on React Native\n // the WebSocket object is circular. Therefore transport.socket will\n // throw errors upon stringification. Collections.safeJSONStringify\n // discards circular references when serializing.\n serializedTransport = Collections.safeJSONStringify(transport);\n callback(new Errors.TransportClosed(serializedTransport));\n };\n\n var unbindListeners = function() {\n transport.unbind('initialized', onInitialized);\n transport.unbind('open', onOpen);\n transport.unbind('error', onError);\n transport.unbind('closed', onClosed);\n };\n\n transport.bind('initialized', onInitialized);\n transport.bind('open', onOpen);\n transport.bind('error', onError);\n transport.bind('closed', onClosed);\n\n // connect will be called automatically after initialization\n transport.initialize();\n\n return {\n abort: () => {\n if (connected) {\n return;\n }\n unbindListeners();\n if (handshake) {\n handshake.close();\n } else {\n transport.close();\n }\n },\n forceMinPriority: p => {\n if (connected) {\n return;\n }\n if (this.priority < p) {\n if (handshake) {\n handshake.close();\n } else {\n transport.close();\n }\n }\n }\n };\n }\n}\n\nfunction failAttempt(error: Error, callback: Function) {\n Util.defer(function() {\n callback(error);\n });\n return {\n abort: function() {},\n forceMinPriority: function() {}\n };\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport TransportManager from '../transports/transport_manager';\nimport * as Errors from '../errors';\nimport Strategy from './strategy';\nimport TransportStrategy from './transport_strategy';\nimport StrategyOptions from '../strategies/strategy_options';\nimport { Config } from '../config';\nimport Runtime from 'runtime';\n\nconst { Transports } = Runtime;\n\nexport var defineTransport = function(\n config: Config,\n name: string,\n type: string,\n priority: number,\n options: StrategyOptions,\n manager?: TransportManager\n): Strategy {\n var transportClass = Transports[type];\n if (!transportClass) {\n throw new Errors.UnsupportedTransport(type);\n }\n\n var enabled =\n (!config.enabledTransports ||\n Collections.arrayIndexOf(config.enabledTransports, name) !== -1) &&\n (!config.disabledTransports ||\n Collections.arrayIndexOf(config.disabledTransports, name) === -1);\n\n var transport;\n if (enabled) {\n options = Object.assign(\n { ignoreNullOrigin: config.ignoreNullOrigin },\n options\n );\n\n transport = new TransportStrategy(\n name,\n priority,\n manager ? manager.getAssistant(transportClass) : transportClass,\n options\n );\n } else {\n transport = UnsupportedStrategy;\n }\n\n return transport;\n};\n\nvar UnsupportedStrategy: Strategy = {\n isSupported: function() {\n return false;\n },\n connect: function(_, callback) {\n var deferred = Util.defer(function() {\n callback(new Errors.UnsupportedStrategy());\n });\n return {\n abort: function() {\n deferred.ensureAborted();\n },\n forceMinPriority: function() {}\n };\n }\n};\n","import {\n UserAuthenticationCallback,\n InternalAuthOptions,\n UserAuthenticationHandler,\n UserAuthenticationRequestParams,\n AuthRequestType\n} from './options';\n\nimport Runtime from 'runtime';\n\nconst composeChannelQuery = (\n params: UserAuthenticationRequestParams,\n authOptions: InternalAuthOptions\n) => {\n var query = 'socket_id=' + encodeURIComponent(params.socketId);\n\n for (var key in authOptions.params) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(authOptions.params[key]);\n }\n\n if (authOptions.paramsProvider != null) {\n let dynamicParams = authOptions.paramsProvider();\n for (var key in dynamicParams) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(dynamicParams[key]);\n }\n }\n\n return query;\n};\n\nconst UserAuthenticator = (\n authOptions: InternalAuthOptions\n): UserAuthenticationHandler => {\n if (typeof Runtime.getAuthorizers()[authOptions.transport] === 'undefined') {\n throw `'${authOptions.transport}' is not a recognized auth transport`;\n }\n\n return (\n params: UserAuthenticationRequestParams,\n callback: UserAuthenticationCallback\n ) => {\n const query = composeChannelQuery(params, authOptions);\n\n Runtime.getAuthorizers()[authOptions.transport](\n Runtime,\n query,\n authOptions,\n AuthRequestType.UserAuthentication,\n callback\n );\n };\n};\n\nexport default UserAuthenticator;\n","import {\n AuthRequestType,\n InternalAuthOptions,\n ChannelAuthorizationHandler,\n ChannelAuthorizationRequestParams,\n ChannelAuthorizationCallback\n} from './options';\n\nimport Runtime from 'runtime';\n\nconst composeChannelQuery = (\n params: ChannelAuthorizationRequestParams,\n authOptions: InternalAuthOptions\n) => {\n var query = 'socket_id=' + encodeURIComponent(params.socketId);\n\n query += '&channel_name=' + encodeURIComponent(params.channelName);\n\n for (var key in authOptions.params) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(authOptions.params[key]);\n }\n\n if (authOptions.paramsProvider != null) {\n let dynamicParams = authOptions.paramsProvider();\n for (var key in dynamicParams) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(dynamicParams[key]);\n }\n }\n\n return query;\n};\n\nconst ChannelAuthorizer = (\n authOptions: InternalAuthOptions\n): ChannelAuthorizationHandler => {\n if (typeof Runtime.getAuthorizers()[authOptions.transport] === 'undefined') {\n throw `'${authOptions.transport}' is not a recognized auth transport`;\n }\n\n return (\n params: ChannelAuthorizationRequestParams,\n callback: ChannelAuthorizationCallback\n ) => {\n const query = composeChannelQuery(params, authOptions);\n\n Runtime.getAuthorizers()[authOptions.transport](\n Runtime,\n query,\n authOptions,\n AuthRequestType.ChannelAuthorization,\n callback\n );\n };\n};\n\nexport default ChannelAuthorizer;\n","import Channel from '../channels/channel';\nimport {\n ChannelAuthorizationCallback,\n ChannelAuthorizationHandler,\n ChannelAuthorizationRequestParams,\n InternalAuthOptions\n} from './options';\n\nexport interface DeprecatedChannelAuthorizer {\n authorize(socketId: string, callback: ChannelAuthorizationCallback): void;\n}\n\nexport interface ChannelAuthorizerGenerator {\n (\n channel: Channel,\n options: DeprecatedAuthorizerOptions\n ): DeprecatedChannelAuthorizer;\n}\n\nexport interface DeprecatedAuthOptions {\n params?: any;\n headers?: any;\n}\n\nexport interface DeprecatedAuthorizerOptions {\n authTransport: 'ajax' | 'jsonp';\n authEndpoint: string;\n auth?: DeprecatedAuthOptions;\n}\n\nexport const ChannelAuthorizerProxy = (\n pusher,\n authOptions: InternalAuthOptions,\n channelAuthorizerGenerator: ChannelAuthorizerGenerator\n): ChannelAuthorizationHandler => {\n const deprecatedAuthorizerOptions: DeprecatedAuthorizerOptions = {\n authTransport: authOptions.transport,\n authEndpoint: authOptions.endpoint,\n auth: {\n params: authOptions.params,\n headers: authOptions.headers\n }\n };\n return (\n params: ChannelAuthorizationRequestParams,\n callback: ChannelAuthorizationCallback\n ) => {\n const channel = pusher.channel(params.channelName);\n // This line creates a new channel authorizer every time.\n // In the past, this was only done once per channel and reused.\n // We can do that again if we want to keep this behavior intact.\n const channelAuthorizer: DeprecatedChannelAuthorizer = channelAuthorizerGenerator(\n channel,\n deprecatedAuthorizerOptions\n );\n channelAuthorizer.authorize(params.socketId, callback);\n };\n};\n","import { Options } from './options';\nimport Defaults from './defaults';\nimport {\n ChannelAuthorizationHandler,\n UserAuthenticationHandler,\n ChannelAuthorizationOptions,\n AuthOptionsT,\n CustomAuthOptions\n} from './auth/options';\nimport UserAuthenticator from './auth/user_authenticator';\nimport ChannelAuthorizer from './auth/channel_authorizer';\nimport { ChannelAuthorizerProxy } from './auth/deprecated_channel_authorizer';\nimport Runtime from 'runtime';\nimport * as nacl from 'tweetnacl';\n\nexport type AuthTransport = 'ajax' | 'jsonp';\nexport type Transport =\n | 'ws'\n | 'wss'\n | 'xhr_streaming'\n | 'xhr_polling'\n | 'sockjs';\n\nexport interface Config {\n // these are all 'required' config parameters, it's not necessary for the user\n // to set them, but they have configured defaults.\n activityTimeout: number;\n enableStats: boolean;\n httpHost: string;\n httpPath: string;\n httpPort: number;\n httpsPort: number;\n pongTimeout: number;\n statsHost: string;\n unavailableTimeout: number;\n useTLS: boolean;\n wsHost: string;\n wsPath: string;\n wsPort: number;\n wssPort: number;\n userAuthenticator: UserAuthenticationHandler;\n channelAuthorizer: ChannelAuthorizationHandler;\n\n // these are all optional parameters or overrrides. The customer can set these\n // but it's not strictly necessary\n forceTLS?: boolean;\n cluster?: string;\n disabledTransports?: Transport[];\n enabledTransports?: Transport[];\n ignoreNullOrigin?: boolean;\n nacl?: nacl;\n timelineParams?: any;\n}\n\n// getConfig mainly sets the defaults for the options that are not provided\nexport function getConfig(opts: Options, pusher): Config {\n let config: Config = {\n activityTimeout: opts.activityTimeout || Defaults.activityTimeout,\n cluster: opts.cluster,\n httpPath: opts.httpPath || Defaults.httpPath,\n httpPort: opts.httpPort || Defaults.httpPort,\n httpsPort: opts.httpsPort || Defaults.httpsPort,\n pongTimeout: opts.pongTimeout || Defaults.pongTimeout,\n statsHost: opts.statsHost || Defaults.stats_host,\n unavailableTimeout: opts.unavailableTimeout || Defaults.unavailableTimeout,\n wsPath: opts.wsPath || Defaults.wsPath,\n wsPort: opts.wsPort || Defaults.wsPort,\n wssPort: opts.wssPort || Defaults.wssPort,\n\n enableStats: getEnableStatsConfig(opts),\n httpHost: getHttpHost(opts),\n useTLS: shouldUseTLS(opts),\n wsHost: getWebsocketHost(opts),\n\n userAuthenticator: buildUserAuthenticator(opts),\n channelAuthorizer: buildChannelAuthorizer(opts, pusher)\n };\n\n if ('disabledTransports' in opts)\n config.disabledTransports = opts.disabledTransports;\n if ('enabledTransports' in opts)\n config.enabledTransports = opts.enabledTransports;\n if ('ignoreNullOrigin' in opts)\n config.ignoreNullOrigin = opts.ignoreNullOrigin;\n if ('timelineParams' in opts) config.timelineParams = opts.timelineParams;\n if ('nacl' in opts) {\n config.nacl = opts.nacl;\n }\n\n return config;\n}\n\nfunction getHttpHost(opts: Options): string {\n if (opts.httpHost) {\n return opts.httpHost;\n }\n if (opts.cluster) {\n return `sockjs-${opts.cluster}.pusher.com`;\n }\n return Defaults.httpHost;\n}\n\nfunction getWebsocketHost(opts: Options): string {\n if (opts.wsHost) {\n return opts.wsHost;\n }\n return getWebsocketHostFromCluster(opts.cluster);\n}\n\nfunction getWebsocketHostFromCluster(cluster: string): string {\n return `ws-${cluster}.pusher.com`;\n}\n\nfunction shouldUseTLS(opts: Options): boolean {\n if (Runtime.getProtocol() === 'https:') {\n return true;\n } else if (opts.forceTLS === false) {\n return false;\n }\n return true;\n}\n\n// if enableStats is set take the value\n// if disableStats is set take the inverse\n// otherwise default to false\nfunction getEnableStatsConfig(opts: Options): boolean {\n if ('enableStats' in opts) {\n return opts.enableStats;\n }\n if ('disableStats' in opts) {\n return !opts.disableStats;\n }\n return false;\n}\n\nconst hasCustomHandler = (\n auth: AuthOptionsT\n): auth is CustomAuthOptions => {\n return 'customHandler' in auth && auth['customHandler'] != null;\n};\n\nfunction buildUserAuthenticator(opts: Options): UserAuthenticationHandler {\n const userAuthentication = {\n ...Defaults.userAuthentication,\n ...opts.userAuthentication\n };\n\n if (hasCustomHandler(userAuthentication)) {\n return userAuthentication['customHandler'];\n }\n\n return UserAuthenticator(userAuthentication);\n}\n\nfunction buildChannelAuth(opts: Options, pusher): ChannelAuthorizationOptions {\n let channelAuthorization: ChannelAuthorizationOptions;\n if ('channelAuthorization' in opts) {\n channelAuthorization = {\n ...Defaults.channelAuthorization,\n ...opts.channelAuthorization\n };\n } else {\n channelAuthorization = {\n transport: opts.authTransport || Defaults.authTransport,\n endpoint: opts.authEndpoint || Defaults.authEndpoint\n };\n\n if ('auth' in opts) {\n if ('params' in opts.auth) channelAuthorization.params = opts.auth.params;\n if ('headers' in opts.auth)\n channelAuthorization.headers = opts.auth.headers;\n }\n\n if ('authorizer' in opts) {\n return {\n customHandler: ChannelAuthorizerProxy(\n pusher,\n channelAuthorization,\n opts.authorizer\n )\n };\n }\n }\n return channelAuthorization;\n}\n\nfunction buildChannelAuthorizer(\n opts: Options,\n pusher\n): ChannelAuthorizationHandler {\n const channelAuthorization = buildChannelAuth(opts, pusher);\n\n if (hasCustomHandler(channelAuthorization)) {\n return channelAuthorization['customHandler'];\n }\n\n return ChannelAuthorizer(channelAuthorization);\n}\n","import Logger from './logger';\nimport Pusher from './pusher';\nimport EventsDispatcher from './events/dispatcher';\n\nexport default class WatchlistFacade extends EventsDispatcher {\n private pusher: Pusher;\n\n public constructor(pusher: Pusher) {\n super(function(eventName, data) {\n Logger.debug(`No callbacks on watchlist events for ${eventName}`);\n });\n\n this.pusher = pusher;\n this.bindWatchlistInternalEvent();\n }\n\n handleEvent(pusherEvent) {\n pusherEvent.data.events.forEach(watchlistEvent => {\n this.emit(watchlistEvent.name, watchlistEvent);\n });\n }\n\n private bindWatchlistInternalEvent() {\n this.pusher.connection.bind('message', pusherEvent => {\n var eventName = pusherEvent.event;\n if (eventName === 'pusher_internal:watchlist_events') {\n this.handleEvent(pusherEvent);\n }\n });\n }\n}\n","function flatPromise() {\n let resolve, reject;\n const promise = new Promise((res, rej) => {\n resolve = res;\n reject = rej;\n });\n return { promise, resolve, reject };\n}\n\nexport default flatPromise;\n","import Pusher from './pusher';\nimport Logger from './logger';\nimport {\n UserAuthenticationData,\n UserAuthenticationCallback\n} from './auth/options';\nimport Channel from './channels/channel';\nimport WatchlistFacade from './watchlist';\nimport EventsDispatcher from './events/dispatcher';\nimport flatPromise from './utils/flat_promise';\n\nexport default class UserFacade extends EventsDispatcher {\n pusher: Pusher;\n signin_requested: boolean = false;\n user_data: any = null;\n serverToUserChannel: Channel = null;\n signinDonePromise: Promise = null;\n watchlist: WatchlistFacade;\n private _signinDoneResolve: Function = null;\n\n public constructor(pusher: Pusher) {\n super(function(eventName, data) {\n Logger.debug('No callbacks on user for ' + eventName);\n });\n this.pusher = pusher;\n this.pusher.connection.bind('state_change', ({ previous, current }) => {\n if (previous !== 'connected' && current === 'connected') {\n this._signin();\n }\n if (previous === 'connected' && current !== 'connected') {\n this._cleanup();\n this._newSigninPromiseIfNeeded();\n }\n });\n\n this.watchlist = new WatchlistFacade(pusher);\n\n this.pusher.connection.bind('message', event => {\n var eventName = event.event;\n if (eventName === 'pusher:signin_success') {\n this._onSigninSuccess(event.data);\n }\n if (\n this.serverToUserChannel &&\n this.serverToUserChannel.name === event.channel\n ) {\n this.serverToUserChannel.handleEvent(event);\n }\n });\n }\n\n public signin() {\n if (this.signin_requested) {\n return;\n }\n\n this.signin_requested = true;\n this._signin();\n }\n\n private _signin() {\n if (!this.signin_requested) {\n return;\n }\n\n this._newSigninPromiseIfNeeded();\n\n if (this.pusher.connection.state !== 'connected') {\n // Signin will be attempted when the connection is connected\n return;\n }\n\n this.pusher.config.userAuthenticator(\n {\n socketId: this.pusher.connection.socket_id\n },\n this._onAuthorize\n );\n }\n\n private _onAuthorize: UserAuthenticationCallback = (\n err,\n authData: UserAuthenticationData\n ) => {\n if (err) {\n Logger.warn(`Error during signin: ${err}`);\n this._cleanup();\n return;\n }\n\n this.pusher.send_event('pusher:signin', {\n auth: authData.auth,\n user_data: authData.user_data\n });\n\n // Later when we get pusher:singin_success event, the user will be marked as signed in\n };\n\n private _onSigninSuccess(data: any) {\n try {\n this.user_data = JSON.parse(data.user_data);\n } catch (e) {\n Logger.error(`Failed parsing user data after signin: ${data.user_data}`);\n this._cleanup();\n return;\n }\n\n if (typeof this.user_data.id !== 'string' || this.user_data.id === '') {\n Logger.error(\n `user_data doesn't contain an id. user_data: ${this.user_data}`\n );\n this._cleanup();\n return;\n }\n\n // Signin succeeded\n this._signinDoneResolve();\n this._subscribeChannels();\n }\n\n private _subscribeChannels() {\n const ensure_subscribed = channel => {\n if (channel.subscriptionPending && channel.subscriptionCancelled) {\n channel.reinstateSubscription();\n } else if (\n !channel.subscriptionPending &&\n this.pusher.connection.state === 'connected'\n ) {\n channel.subscribe();\n }\n };\n\n this.serverToUserChannel = new Channel(\n `#server-to-user-${this.user_data.id}`,\n this.pusher\n );\n this.serverToUserChannel.bind_global((eventName, data) => {\n if (\n eventName.indexOf('pusher_internal:') === 0 ||\n eventName.indexOf('pusher:') === 0\n ) {\n // ignore internal events\n return;\n }\n this.emit(eventName, data);\n });\n ensure_subscribed(this.serverToUserChannel);\n }\n\n private _cleanup() {\n this.user_data = null;\n if (this.serverToUserChannel) {\n this.serverToUserChannel.unbind_all();\n this.serverToUserChannel.disconnect();\n this.serverToUserChannel = null;\n }\n\n if (this.signin_requested) {\n // If signin is in progress and cleanup is called,\n // Mark the current signin process as done.\n this._signinDoneResolve();\n }\n }\n\n private _newSigninPromiseIfNeeded() {\n if (!this.signin_requested) {\n return;\n }\n\n // If there is a promise and it is not resolved, return without creating a new one.\n if (this.signinDonePromise && !(this.signinDonePromise as any).done) {\n return;\n }\n\n // This promise is never rejected.\n // It gets resolved when the signin process is done whether it failed or succeeded\n const { promise, resolve, reject: _ } = flatPromise();\n (promise as any).done = false;\n const setDone = () => {\n (promise as any).done = true;\n };\n promise.then(setDone).catch(setDone);\n this.signinDonePromise = promise;\n this._signinDoneResolve = resolve;\n }\n}\n","import AbstractRuntime from '../runtimes/interface';\nimport Runtime from 'runtime';\nimport * as Collections from './utils/collections';\nimport Channels from './channels/channels';\nimport Channel from './channels/channel';\nimport { default as EventsDispatcher } from './events/dispatcher';\nimport Timeline from './timeline/timeline';\nimport TimelineSender from './timeline/timeline_sender';\nimport TimelineLevel from './timeline/level';\nimport { defineTransport } from './strategies/strategy_builder';\nimport ConnectionManager from './connection/connection_manager';\nimport { PeriodicTimer } from './utils/timers';\nimport Defaults from './defaults';\nimport Logger from './logger';\nimport Factory from './utils/factory';\nimport { Options, ClusterOptions, validateOptions } from './options';\nimport { Config, getConfig } from './config';\nimport StrategyOptions from './strategies/strategy_options';\nimport UserFacade from './user';\n\nexport default class Pusher {\n /* STATIC PROPERTIES */\n static instances: Pusher[] = [];\n static isReady: boolean = false;\n static logToConsole: boolean = false;\n\n // for jsonp\n static Runtime: AbstractRuntime = Runtime;\n static ScriptReceivers: any = (Runtime).ScriptReceivers;\n static DependenciesReceivers: any = (Runtime).DependenciesReceivers;\n static auth_callbacks: any = (Runtime).auth_callbacks;\n\n static ready() {\n Pusher.isReady = true;\n for (var i = 0, l = Pusher.instances.length; i < l; i++) {\n Pusher.instances[i].connect();\n }\n }\n\n static log: (message: any) => void;\n\n private static getClientFeatures(): string[] {\n return Collections.keys(\n Collections.filterObject({ ws: Runtime.Transports.ws }, function(t) {\n return t.isSupported({});\n })\n );\n }\n\n /* INSTANCE PROPERTIES */\n key: string;\n options: Options;\n config: Config;\n channels: Channels;\n global_emitter: EventsDispatcher;\n sessionID: number;\n timeline: Timeline;\n timelineSender: TimelineSender;\n connection: ConnectionManager;\n timelineSenderTimer: PeriodicTimer;\n user: UserFacade;\n constructor(app_key: string, options: Options) {\n checkAppKey(app_key);\n validateOptions(options);\n this.key = app_key;\n this.options = options;\n this.config = getConfig(this.options, this);\n\n this.channels = Factory.createChannels();\n this.global_emitter = new EventsDispatcher();\n this.sessionID = Runtime.randomInt(1000000000);\n\n this.timeline = new Timeline(this.key, this.sessionID, {\n cluster: this.config.cluster,\n features: Pusher.getClientFeatures(),\n params: this.config.timelineParams || {},\n limit: 50,\n level: TimelineLevel.INFO,\n version: Defaults.VERSION\n });\n if (this.config.enableStats) {\n this.timelineSender = Factory.createTimelineSender(this.timeline, {\n host: this.config.statsHost,\n path: '/timeline/v2/' + Runtime.TimelineTransport.name\n });\n }\n\n var getStrategy = (options: StrategyOptions) => {\n return Runtime.getDefaultStrategy(this.config, options, defineTransport);\n };\n\n this.connection = Factory.createConnectionManager(this.key, {\n getStrategy: getStrategy,\n timeline: this.timeline,\n activityTimeout: this.config.activityTimeout,\n pongTimeout: this.config.pongTimeout,\n unavailableTimeout: this.config.unavailableTimeout,\n useTLS: Boolean(this.config.useTLS)\n });\n\n this.connection.bind('connected', () => {\n this.subscribeAll();\n if (this.timelineSender) {\n this.timelineSender.send(this.connection.isUsingTLS());\n }\n });\n\n this.connection.bind('message', event => {\n var eventName = event.event;\n var internal = eventName.indexOf('pusher_internal:') === 0;\n if (event.channel) {\n var channel = this.channel(event.channel);\n if (channel) {\n channel.handleEvent(event);\n }\n }\n // Emit globally [deprecated]\n if (!internal) {\n this.global_emitter.emit(event.event, event.data);\n }\n });\n this.connection.bind('connecting', () => {\n this.channels.disconnect();\n });\n this.connection.bind('disconnected', () => {\n this.channels.disconnect();\n });\n this.connection.bind('error', err => {\n Logger.warn(err);\n });\n\n Pusher.instances.push(this);\n this.timeline.info({ instances: Pusher.instances.length });\n\n this.user = new UserFacade(this);\n\n if (Pusher.isReady) {\n this.connect();\n }\n }\n\n /**\n * Allows you to switch Pusher cluster without\n * losing all the channels/subscription binding\n * as this is internally managed by the SDK.\n */\n switchCluster(options: ClusterOptions) {\n const { appKey, cluster } = options;\n this.key = appKey;\n this.options = { ...this.options, cluster };\n this.config = getConfig(this.options, this);\n this.connection.switchCluster(this.key);\n }\n\n channel(name: string): Channel {\n return this.channels.find(name);\n }\n\n allChannels(): Channel[] {\n return this.channels.all();\n }\n\n connect() {\n this.connection.connect();\n\n if (this.timelineSender) {\n if (!this.timelineSenderTimer) {\n var usingTLS = this.connection.isUsingTLS();\n var timelineSender = this.timelineSender;\n this.timelineSenderTimer = new PeriodicTimer(60000, function() {\n timelineSender.send(usingTLS);\n });\n }\n }\n }\n\n disconnect() {\n this.connection.disconnect();\n\n if (this.timelineSenderTimer) {\n this.timelineSenderTimer.ensureAborted();\n this.timelineSenderTimer = null;\n }\n }\n\n bind(event_name: string, callback: Function, context?: any): Pusher {\n this.global_emitter.bind(event_name, callback, context);\n return this;\n }\n\n unbind(event_name?: string, callback?: Function, context?: any): Pusher {\n this.global_emitter.unbind(event_name, callback, context);\n return this;\n }\n\n bind_global(callback: Function): Pusher {\n this.global_emitter.bind_global(callback);\n return this;\n }\n\n unbind_global(callback?: Function): Pusher {\n this.global_emitter.unbind_global(callback);\n return this;\n }\n\n unbind_all(callback?: Function): Pusher {\n this.global_emitter.unbind_all();\n return this;\n }\n\n subscribeAll() {\n var channelName;\n for (channelName in this.channels.channels) {\n if (this.channels.channels.hasOwnProperty(channelName)) {\n this.subscribe(channelName);\n }\n }\n }\n\n subscribe(channel_name: string) {\n var channel = this.channels.add(channel_name, this);\n if (channel.subscriptionPending && channel.subscriptionCancelled) {\n channel.reinstateSubscription();\n } else if (\n !channel.subscriptionPending &&\n this.connection.state === 'connected'\n ) {\n channel.subscribe();\n }\n return channel;\n }\n\n unsubscribe(channel_name: string) {\n var channel = this.channels.find(channel_name);\n if (channel && channel.subscriptionPending) {\n channel.cancelSubscription();\n } else {\n channel = this.channels.remove(channel_name);\n if (channel && channel.subscribed) {\n channel.unsubscribe();\n }\n }\n }\n\n send_event(event_name: string, data: any, channel?: string) {\n return this.connection.send_event(event_name, data, channel);\n }\n\n shouldUseTLS(): boolean {\n return this.config.useTLS;\n }\n\n signin() {\n this.user.signin();\n }\n}\n\nfunction checkAppKey(key) {\n if (key === null || key === undefined) {\n throw 'You must pass your app key when you instantiate Pusher.';\n }\n}\n\nRuntime.setup(Pusher);\n","import ConnectionManager from './connection/connection_manager';\nimport {\n ChannelAuthorizationOptions,\n UserAuthenticationOptions\n} from './auth/options';\nimport {\n ChannelAuthorizerGenerator,\n DeprecatedAuthOptions\n} from './auth/deprecated_channel_authorizer';\nimport { AuthTransport, Transport } from './config';\nimport * as nacl from 'tweetnacl';\nimport Logger from './logger';\n\nexport interface Options {\n activityTimeout?: number;\n\n auth?: DeprecatedAuthOptions; // DEPRECATED use channelAuthorization instead\n authEndpoint?: string; // DEPRECATED use channelAuthorization instead\n authTransport?: AuthTransport; // DEPRECATED use channelAuthorization instead\n authorizer?: ChannelAuthorizerGenerator; // DEPRECATED use channelAuthorization instead\n\n channelAuthorization?: ChannelAuthorizationOptions;\n userAuthentication?: UserAuthenticationOptions;\n\n cluster: string;\n enableStats?: boolean;\n disableStats?: boolean;\n disabledTransports?: Transport[];\n enabledTransports?: Transport[];\n forceTLS?: boolean;\n httpHost?: string;\n httpPath?: string;\n httpPort?: number;\n httpsPort?: number;\n ignoreNullOrigin?: boolean;\n nacl?: nacl;\n pongTimeout?: number;\n statsHost?: string;\n timelineParams?: any;\n unavailableTimeout?: number;\n wsHost?: string;\n wsPath?: string;\n wsPort?: number;\n wssPort?: number;\n}\n\nexport interface ClusterOptions {\n appKey: string;\n cluster: string;\n}\n\nexport function validateOptions(options) {\n if (options == null) {\n throw 'You must pass an options object';\n }\n if (options.cluster == null) {\n throw 'Options object must provide a cluster';\n }\n if ('disableStats' in options) {\n Logger.warn(\n 'The disableStats option is deprecated in favor of enableStats'\n );\n }\n}\n"],"sourceRoot":""} \ No newline at end of file diff --git a/dist/worker/pusher-with-encryption.worker.js b/dist/worker/pusher-with-encryption.worker.js index 9f2784ef8..bfd1cd7b9 100644 --- a/dist/worker/pusher-with-encryption.worker.js +++ b/dist/worker/pusher-with-encryption.worker.js @@ -1,5 +1,5 @@ /*! - * Pusher JavaScript Library v8.4.0-rc1 + * Pusher JavaScript Library v8.4.0-rc2 * https://pusher.com/ * * Copyright 2020, Pusher @@ -3273,7 +3273,7 @@ function safeJSONStringify(source) { // CONCATENATED MODULE: ./src/core/defaults.ts var Defaults = { - VERSION: "8.4.0-rc1", + VERSION: "8.4.0-rc2", PROTOCOL: 7, wsPort: 80, wssPort: 443, @@ -6199,10 +6199,12 @@ function getEnableStatsConfig(opts) { } return false; } +const hasCustomHandler = (auth) => { + return 'customHandler' in auth && auth['customHandler'] != null; +}; function buildUserAuthenticator(opts) { const userAuthentication = Object.assign(Object.assign({}, defaults.userAuthentication), opts.userAuthentication); - if ('customHandler' in userAuthentication && - userAuthentication['customHandler'] != null) { + if (hasCustomHandler(userAuthentication)) { return userAuthentication['customHandler']; } return user_authenticator(userAuthentication); @@ -6223,15 +6225,17 @@ function buildChannelAuth(opts, pusher) { if ('headers' in opts.auth) channelAuthorization.headers = opts.auth.headers; } - if ('authorizer' in opts) - channelAuthorization.customHandler = ChannelAuthorizerProxy(pusher, channelAuthorization, opts.authorizer); + if ('authorizer' in opts) { + return { + customHandler: ChannelAuthorizerProxy(pusher, channelAuthorization, opts.authorizer) + }; + } } return channelAuthorization; } function buildChannelAuthorizer(opts, pusher) { const channelAuthorization = buildChannelAuth(opts, pusher); - if ('customHandler' in channelAuthorization && - channelAuthorization['customHandler'] != null) { + if (hasCustomHandler(channelAuthorization)) { return channelAuthorization['customHandler']; } return channel_authorizer(channelAuthorization); @@ -6438,7 +6442,8 @@ class pusher_Pusher { checkAppKey(app_key); validateOptions(options); this.key = app_key; - this.config = getConfig(options, this); + this.options = options; + this.config = getConfig(this.options, this); this.channels = factory.createChannels(); this.global_emitter = new dispatcher_Dispatcher(); this.sessionID = worker_runtime.randomInt(1000000000); diff --git a/dist/worker/pusher-with-encryption.worker.js.map b/dist/worker/pusher-with-encryption.worker.js.map index 8e8d04a8d..d7f3e0a8e 100644 --- a/dist/worker/pusher-with-encryption.worker.js.map +++ b/dist/worker/pusher-with-encryption.worker.js.map @@ -1 +1 @@ -{"version":3,"sources":["webpack://Pusher/webpack/universalModuleDefinition","webpack://Pusher/webpack/bootstrap","webpack://Pusher/./node_modules/@stablelib/base64/base64.ts","webpack://Pusher/./node_modules/@stablelib/utf8/utf8.ts","webpack://Pusher/./node_modules/tweetnacl/nacl-fast.js","webpack://Pusher/./src/core/pusher-with-encryption.js","webpack://Pusher/crypto (ignored)","webpack://Pusher/./src/core/base64.ts","webpack://Pusher/./src/core/utils/timers/abstract_timer.ts","webpack://Pusher/./src/core/utils/timers/index.ts","webpack://Pusher/./src/core/util.ts","webpack://Pusher/./src/core/utils/collections.ts","webpack://Pusher/./src/core/defaults.ts","webpack://Pusher/./src/core/transports/url_schemes.ts","webpack://Pusher/./src/core/events/callback_registry.ts","webpack://Pusher/./src/core/events/dispatcher.ts","webpack://Pusher/./src/core/logger.ts","webpack://Pusher/./src/core/transports/transport_connection.ts","webpack://Pusher/./src/core/transports/transport.ts","webpack://Pusher/./src/runtimes/isomorphic/transports/transports.ts","webpack://Pusher/./src/core/transports/assistant_to_the_transport_manager.ts","webpack://Pusher/./src/core/connection/protocol/protocol.ts","webpack://Pusher/./src/core/connection/connection.ts","webpack://Pusher/./src/core/connection/handshake/index.ts","webpack://Pusher/./src/core/timeline/timeline_sender.ts","webpack://Pusher/./src/core/errors.ts","webpack://Pusher/./src/core/utils/url_store.ts","webpack://Pusher/./src/core/channels/channel.ts","webpack://Pusher/./src/core/channels/private_channel.ts","webpack://Pusher/./src/core/channels/members.ts","webpack://Pusher/./src/core/channels/presence_channel.ts","webpack://Pusher/./src/core/channels/encrypted_channel.ts","webpack://Pusher/./src/core/connection/connection_manager.ts","webpack://Pusher/./src/core/channels/channels.ts","webpack://Pusher/./src/core/utils/factory.ts","webpack://Pusher/./src/core/transports/transport_manager.ts","webpack://Pusher/./src/core/strategies/sequential_strategy.ts","webpack://Pusher/./src/core/strategies/best_connected_ever_strategy.ts","webpack://Pusher/./src/core/strategies/websocket_prioritized_cached_strategy.ts","webpack://Pusher/./src/core/strategies/delayed_strategy.ts","webpack://Pusher/./src/core/strategies/if_strategy.ts","webpack://Pusher/./src/core/strategies/first_connected_strategy.ts","webpack://Pusher/./src/runtimes/isomorphic/default_strategy.ts","webpack://Pusher/./src/runtimes/isomorphic/transports/transport_connection_initializer.ts","webpack://Pusher/./src/core/http/http_request.ts","webpack://Pusher/./src/core/http/state.ts","webpack://Pusher/./src/core/http/http_socket.ts","webpack://Pusher/./src/core/http/http_streaming_socket.ts","webpack://Pusher/./src/core/http/http_polling_socket.ts","webpack://Pusher/./src/runtimes/isomorphic/http/http_xhr_request.ts","webpack://Pusher/./src/runtimes/isomorphic/http/http.ts","webpack://Pusher/./src/runtimes/isomorphic/runtime.ts","webpack://Pusher/./src/runtimes/worker/net_info.ts","webpack://Pusher/./src/runtimes/worker/auth/fetch_auth.ts","webpack://Pusher/./src/runtimes/worker/timeline/fetch_timeline.ts","webpack://Pusher/./src/runtimes/worker/runtime.ts","webpack://Pusher/./src/core/timeline/level.ts","webpack://Pusher/./src/core/timeline/timeline.ts","webpack://Pusher/./src/core/strategies/transport_strategy.ts","webpack://Pusher/./src/core/strategies/strategy_builder.ts","webpack://Pusher/./src/core/options.ts","webpack://Pusher/./src/core/auth/options.ts","webpack://Pusher/./src/core/auth/user_authenticator.ts","webpack://Pusher/./src/core/auth/channel_authorizer.ts","webpack://Pusher/./src/core/auth/deprecated_channel_authorizer.ts","webpack://Pusher/./src/core/config.ts","webpack://Pusher/./src/core/watchlist.ts","webpack://Pusher/./src/core/utils/flat_promise.ts","webpack://Pusher/./src/core/user.ts","webpack://Pusher/./src/core/pusher.ts","webpack://Pusher/./src/core/pusher-with-encryption.ts"],"names":[],"mappings":";;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AACD,O;QCVA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;;QAEA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;;;QAGA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;QACA,0CAA0C,gCAAgC;QAC1E;QACA;;QAEA;QACA;QACA;QACA,wDAAwD,kBAAkB;QAC1E;QACA,iDAAiD,cAAc;QAC/D;;QAEA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA,yCAAyC,iCAAiC;QAC1E,gHAAgH,mBAAmB,EAAE;QACrI;QACA;;QAEA;QACA;QACA;QACA,2BAA2B,0BAA0B,EAAE;QACvD,iCAAiC,eAAe;QAChD;QACA;QACA;;QAEA;QACA,sDAAsD,+DAA+D;;QAErH;QACA;;;QAGA;QACA;;;;;;;;;AClFA,sCAAsC;AACtC,6CAA6C;;;;;;;;;;;;;;;AAE7C;;GAEG;AAEH,iDAAiD;AACjD,kDAAkD;AAClD,kCAAkC;AAClC,IAAM,YAAY,GAAG,GAAG,CAAC;AAEzB;;;;GAIG;AACH;IACI,kDAAkD;IAElD,eAAoB,iBAAuB;QAAvB,2DAAuB;QAAvB,sBAAiB,GAAjB,iBAAiB,CAAM;IAAI,CAAC;IAEhD,6BAAa,GAAb,UAAc,MAAc;QACxB,IAAI,CAAC,IAAI,CAAC,iBAAiB,EAAE;YACzB,OAAO,CAAC,MAAM,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;SACnC;QACD,OAAO,CAAC,MAAM,GAAG,CAAC,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CAAC,CAAC;iBACjC;gBACD,CAAC,IAAI,OAAO,CAAC;gBACb,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,MAAM,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;gBACpD,CAAC,GAAG,MAAM,GAAG,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC;aAC5B;SACJ;QAED,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC;KACtC;IACD,OAAO,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AAC1B,CAAC;AAjED,wBAiEC;;;;;;;AC/ID;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,uBAAuB,iBAAiB;AACxC;AACA;;AAEA;AACA,wCAAwC,4BAA4B;;AAEpE;AACA,4BAA4B;;AAE5B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa,OAAO;AACpB;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,aAAa,QAAQ;AACrB,aAAa,OAAO;AACpB;AACA;AACA,eAAe,QAAQ;AACvB;AACA,eAAe,QAAQ;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB;AACA;AACA;;AAEA;AACA;AACA;AACA,aAAa,QAAQ;AACrB,aAAa,OAAO;AACpB;AACA;AACA,eAAe,QAAQ;AACvB;AACA,eAAe,QAAQ;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,iBAAiB,OAAO;AACxB;AACA;;AAEA;AACA;AACA;AACA;AACA,iBAAiB,OAAO;AACxB;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA,8CAA8C;AAC9C,8CAA8C;AAC9C,8CAA8C;AAC9C,8CAA8C;AAC9C,8CAA8C;AAC9C;AACA,8CAA8C;AAC9C,8CAA8C;AAC9C,8CAA8C;AAC9C;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,sDAAsD;AACtD,sDAAsD;AACtD,sDAAsD;AACtD,sDAAsD;AACtD,sDAAsD;AACtD;AACA,sDAAsD;AACtD,sDAAsD;AACtD,sDAAsD;AACtD;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA,qBAAqB;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA,qBAAqB;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA,qBAAqB;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA,qBAAqB;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA,qBAAqB;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA,qBAAqB;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA,qBAAqB;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA,qBAAqB;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA,qBAAqB;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA,qBAAqB;;AAErB;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA,UAAU,QAAQ;AAClB;AACA;AACA;;AAEA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA;AACA;;AAEA;AACA,aAAa,QAAQ;AACrB;AACA,aAAa,QAAQ;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa,OAAO;AACpB;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,UAAU;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,eAAe,WAAW;AAC1B;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;;AAEA;AACA;AACA,aAAa,QAAQ;AACrB;;AAEA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA,aAAa,OAAO;AACpB;AACA,eAAe,QAAQ;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;;AAEA;AACA,iBAAiB,QAAQ;AACzB;;AAEA;AACA,iBAAiB,QAAQ;AACzB;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD;;AAEA;AACA;AACA,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA,aAAa,QAAQ;AACrB,eAAe,QAAQ;AACvB;AACA;AACA;AACA,aAAa,QAAQ;AACrB;;AAEA;AACA;AACA;AACA,aAAa,QAAQ;AACrB,eAAe,QAAQ;AACvB;AACA;AACA;AACA,aAAa,QAAQ;AACrB;;AAEA;AACA;AACA;AACA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA;AACA,aAAa,MAAM;AACnB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,eAAe,QAAQ;AACvB;AACA;AACA;AACA;AACA,eAAe,QAAQ;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA,qBAAqB;AACrB,qBAAqB;;AAErB;AACA;AACA;;AAEA,sBAAsB;AACtB,sBAAsB;;AAEtB;AACA;AACA;;AAEA,sBAAsB;AACtB,sBAAsB;;AAEtB;AACA;AACA;;AAEA,sBAAsB;AACtB,sBAAsB;;AAEtB;AACA;AACA;;AAEA,sBAAsB;AACtB,sBAAsB;;AAEtB;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA,qBAAqB;AACrB,qBAAqB;;AAErB;AACA;AACA;;AAEA,sBAAsB;AACtB,sBAAsB;;AAEtB;AACA;AACA;;AAEA,sBAAsB;AACtB,sBAAsB;;AAEtB;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA,qBAAqB;AACrB,qBAAqB;;AAErB;AACA;;AAEA,sBAAsB;AACtB,sBAAsB;;AAEtB;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,mBAAmB,QAAQ;AAC3B;AACA;AACA;;AAEA,yBAAyB;AACzB,yBAAyB;;AAEzB;AACA;;AAEA,0BAA0B;AAC1B,0BAA0B;;AAE1B;AACA;AACA;AACA;AACA;;AAEA,0BAA0B;AAC1B,0BAA0B;;AAE1B;AACA;AACA;AACA;AACA;;AAEA,0BAA0B;AAC1B,0BAA0B;;AAE1B;AACA;AAC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A;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa,OAAO;AACpB;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,QAAQ;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA,aAAa,QAAQ;AACrB;AACA;;AAEA;;AAEA;AACA;AACA,cAAc,SAAS;AACvB;AACA,gCAAgC,OAAO;AACvC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA;AACA,aAAa,QAAQ;AACrB,aAAa,QAAQ;AACrB;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa,QAAQ;AACrB,aAAa,QAAQ;AACrB;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA,aAAa,OAAO;AACpB,aAAa,QAAQ;;AAErB;AACA;AACA;AACA;;AAEA,cAAc,QAAQ;AACtB;AACA;;AAEA,aAAa,QAAQ;AACrB,aAAa,QAAQ;AACrB,aAAa,QAAQ;AACrB,eAAe,QAAQ;AACvB;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;;AAEA,aAAa,OAAO;AACpB,aAAa,QAAQ;AACrB;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA,eAAe,OAAO;AACtB;AACA;;AAEA,aAAa,OAAO;AACpB;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA,iBAAiB,sBAAsB;AACvC;AACA;AACA;AACA;;AAEA;AACA,iBAAiB,gBAAgB;AACjC;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,iBAAiB,gBAAgB;AACjC;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,iBAAiB,gBAAgB;AACjC;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA,UAAU;AACV;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,UAAU;AACV;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAiB,cAAc;AAC/B;AACA;;AAEA;AACA;AACA;AACA,iBAAiB,gBAAgB;AACjC;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa,uBAAuB;AACpC,aAAa,gBAAgB;AAC7B;AACA;;AAEA;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ACnB;AAEnB,MAAM,2CAAqB,SAAQ,WAAM;IACtD,YAAY,OAAe,EAAE,OAAgB;QAC3C,WAAM,CAAC,YAAY,GAAG,2CAAoB,CAAC,YAAY,CAAC;QACxD,WAAM,CAAC,GAAG,GAAG,2CAAoB,CAAC,GAAG,CAAC;QAEtC,eAAe,CAAC,OAAO,CAAC,CAAC;QACzB,OAAO,CAAC,IAAI,GAAG,SAAI,CAAC;QACpB,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAC1B,CAAC;CACF","file":"pusher-with-encryption.worker.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"Pusher\"] = factory();\n\telse\n\t\troot[\"Pusher\"] = factory();\n})(this, function() {\nreturn "," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 3);\n","// Copyright (C) 2016 Dmitry Chestnykh\n// MIT License. See LICENSE file for details.\n\n/**\n * Package base64 implements Base64 encoding and decoding.\n */\n\n// Invalid character used in decoding to indicate\n// that the character to decode is out of range of\n// alphabet and cannot be decoded.\nconst INVALID_BYTE = 256;\n\n/**\n * Implements standard Base64 encoding.\n *\n * Operates in constant time.\n */\nexport class Coder {\n // TODO(dchest): methods to encode chunk-by-chunk.\n\n constructor(private _paddingCharacter = \"=\") { }\n\n encodedLength(length: number): number {\n if (!this._paddingCharacter) {\n return (length * 8 + 5) / 6 | 0;\n }\n return (length + 2) / 3 * 4 | 0;\n }\n\n encode(data: Uint8Array): string {\n let out = \"\";\n\n let i = 0;\n for (; i < data.length - 2; i += 3) {\n let c = (data[i] << 16) | (data[i + 1] << 8) | (data[i + 2]);\n out += this._encodeByte((c >>> 3 * 6) & 63);\n out += this._encodeByte((c >>> 2 * 6) & 63);\n out += this._encodeByte((c >>> 1 * 6) & 63);\n out += this._encodeByte((c >>> 0 * 6) & 63);\n }\n\n const left = data.length - i;\n if (left > 0) {\n let c = (data[i] << 16) | (left === 2 ? data[i + 1] << 8 : 0);\n out += this._encodeByte((c >>> 3 * 6) & 63);\n out += this._encodeByte((c >>> 2 * 6) & 63);\n if (left === 2) {\n out += this._encodeByte((c >>> 1 * 6) & 63);\n } else {\n out += this._paddingCharacter || \"\";\n }\n out += this._paddingCharacter || \"\";\n }\n\n return out;\n }\n\n maxDecodedLength(length: number): number {\n if (!this._paddingCharacter) {\n return (length * 6 + 7) / 8 | 0;\n }\n return length / 4 * 3 | 0;\n }\n\n decodedLength(s: string): number {\n return this.maxDecodedLength(s.length - this._getPaddingLength(s));\n }\n\n decode(s: string): Uint8Array {\n if (s.length === 0) {\n return new Uint8Array(0);\n }\n const paddingLength = this._getPaddingLength(s);\n const length = s.length - paddingLength;\n const out = new Uint8Array(this.maxDecodedLength(length));\n let op = 0;\n let i = 0;\n let haveBad = 0;\n let v0 = 0, v1 = 0, v2 = 0, v3 = 0;\n for (; i < length - 4; i += 4) {\n v0 = this._decodeChar(s.charCodeAt(i + 0));\n v1 = this._decodeChar(s.charCodeAt(i + 1));\n v2 = this._decodeChar(s.charCodeAt(i + 2));\n v3 = this._decodeChar(s.charCodeAt(i + 3));\n out[op++] = (v0 << 2) | (v1 >>> 4);\n out[op++] = (v1 << 4) | (v2 >>> 2);\n out[op++] = (v2 << 6) | v3;\n haveBad |= v0 & INVALID_BYTE;\n haveBad |= v1 & INVALID_BYTE;\n haveBad |= v2 & INVALID_BYTE;\n haveBad |= v3 & INVALID_BYTE;\n }\n if (i < length - 1) {\n v0 = this._decodeChar(s.charCodeAt(i));\n v1 = this._decodeChar(s.charCodeAt(i + 1));\n out[op++] = (v0 << 2) | (v1 >>> 4);\n haveBad |= v0 & INVALID_BYTE;\n haveBad |= v1 & INVALID_BYTE;\n }\n if (i < length - 2) {\n v2 = this._decodeChar(s.charCodeAt(i + 2));\n out[op++] = (v1 << 4) | (v2 >>> 2);\n haveBad |= v2 & INVALID_BYTE;\n }\n if (i < length - 3) {\n v3 = this._decodeChar(s.charCodeAt(i + 3));\n out[op++] = (v2 << 6) | v3;\n haveBad |= v3 & INVALID_BYTE;\n }\n if (haveBad !== 0) {\n throw new Error(\"Base64Coder: incorrect characters for decoding\");\n }\n return out;\n }\n\n // Standard encoding have the following encoded/decoded ranges,\n // which we need to convert between.\n //\n // ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 0123456789 + /\n // Index: 0 - 25 26 - 51 52 - 61 62 63\n // ASCII: 65 - 90 97 - 122 48 - 57 43 47\n //\n\n // Encode 6 bits in b into a new character.\n protected _encodeByte(b: number): string {\n // Encoding uses constant time operations as follows:\n //\n // 1. Define comparison of A with B using (A - B) >>> 8:\n // if A > B, then result is positive integer\n // if A <= B, then result is 0\n //\n // 2. Define selection of C or 0 using bitwise AND: X & C:\n // if X == 0, then result is 0\n // if X != 0, then result is C\n //\n // 3. Start with the smallest comparison (b >= 0), which is always\n // true, so set the result to the starting ASCII value (65).\n //\n // 4. Continue comparing b to higher ASCII values, and selecting\n // zero if comparison isn't true, otherwise selecting a value\n // to add to result, which:\n //\n // a) undoes the previous addition\n // b) provides new value to add\n //\n let result = b;\n // b >= 0\n result += 65;\n // b > 25\n result += ((25 - b) >>> 8) & ((0 - 65) - 26 + 97);\n // b > 51\n result += ((51 - b) >>> 8) & ((26 - 97) - 52 + 48);\n // b > 61\n result += ((61 - b) >>> 8) & ((52 - 48) - 62 + 43);\n // b > 62\n result += ((62 - b) >>> 8) & ((62 - 43) - 63 + 47);\n\n return String.fromCharCode(result);\n }\n\n // Decode a character code into a byte.\n // Must return 256 if character is out of alphabet range.\n protected _decodeChar(c: number): number {\n // Decoding works similar to encoding: using the same comparison\n // function, but now it works on ranges: result is always incremented\n // by value, but this value becomes zero if the range is not\n // satisfied.\n //\n // Decoding starts with invalid value, 256, which is then\n // subtracted when the range is satisfied. If none of the ranges\n // apply, the function returns 256, which is then checked by\n // the caller to throw error.\n let result = INVALID_BYTE; // start with invalid character\n\n // c == 43 (c > 42 and c < 44)\n result += (((42 - c) & (c - 44)) >>> 8) & (-INVALID_BYTE + c - 43 + 62);\n // c == 47 (c > 46 and c < 48)\n result += (((46 - c) & (c - 48)) >>> 8) & (-INVALID_BYTE + c - 47 + 63);\n // c > 47 and c < 58\n result += (((47 - c) & (c - 58)) >>> 8) & (-INVALID_BYTE + c - 48 + 52);\n // c > 64 and c < 91\n result += (((64 - c) & (c - 91)) >>> 8) & (-INVALID_BYTE + c - 65 + 0);\n // c > 96 and c < 123\n result += (((96 - c) & (c - 123)) >>> 8) & (-INVALID_BYTE + c - 97 + 26);\n\n return result;\n }\n\n private _getPaddingLength(s: string): number {\n let paddingLength = 0;\n if (this._paddingCharacter) {\n for (let i = s.length - 1; i >= 0; i--) {\n if (s[i] !== this._paddingCharacter) {\n break;\n }\n paddingLength++;\n }\n if (s.length < 4 || paddingLength > 2) {\n throw new Error(\"Base64Coder: incorrect padding\");\n }\n }\n return paddingLength;\n }\n\n}\n\nconst stdCoder = new Coder();\n\nexport function encode(data: Uint8Array): string {\n return stdCoder.encode(data);\n}\n\nexport function decode(s: string): Uint8Array {\n return stdCoder.decode(s);\n}\n\n/**\n * Implements URL-safe Base64 encoding.\n * (Same as Base64, but '+' is replaced with '-', and '/' with '_').\n *\n * Operates in constant time.\n */\nexport class URLSafeCoder extends Coder {\n // URL-safe encoding have the following encoded/decoded ranges:\n //\n // ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 0123456789 - _\n // Index: 0 - 25 26 - 51 52 - 61 62 63\n // ASCII: 65 - 90 97 - 122 48 - 57 45 95\n //\n\n protected _encodeByte(b: number): string {\n let result = b;\n // b >= 0\n result += 65;\n // b > 25\n result += ((25 - b) >>> 8) & ((0 - 65) - 26 + 97);\n // b > 51\n result += ((51 - b) >>> 8) & ((26 - 97) - 52 + 48);\n // b > 61\n result += ((61 - b) >>> 8) & ((52 - 48) - 62 + 45);\n // b > 62\n result += ((62 - b) >>> 8) & ((62 - 45) - 63 + 95);\n\n return String.fromCharCode(result);\n }\n\n protected _decodeChar(c: number): number {\n let result = INVALID_BYTE;\n\n // c == 45 (c > 44 and c < 46)\n result += (((44 - c) & (c - 46)) >>> 8) & (-INVALID_BYTE + c - 45 + 62);\n // c == 95 (c > 94 and c < 96)\n result += (((94 - c) & (c - 96)) >>> 8) & (-INVALID_BYTE + c - 95 + 63);\n // c > 47 and c < 58\n result += (((47 - c) & (c - 58)) >>> 8) & (-INVALID_BYTE + c - 48 + 52);\n // c > 64 and c < 91\n result += (((64 - c) & (c - 91)) >>> 8) & (-INVALID_BYTE + c - 65 + 0);\n // c > 96 and c < 123\n result += (((96 - c) & (c - 123)) >>> 8) & (-INVALID_BYTE + c - 97 + 26);\n\n return result;\n }\n}\n\nconst urlSafeCoder = new URLSafeCoder();\n\nexport function encodeURLSafe(data: Uint8Array): string {\n return urlSafeCoder.encode(data);\n}\n\nexport function decodeURLSafe(s: string): Uint8Array {\n return urlSafeCoder.decode(s);\n}\n\n\nexport const encodedLength = (length: number) =>\n stdCoder.encodedLength(length);\n\nexport const maxDecodedLength = (length: number) =>\n stdCoder.maxDecodedLength(length);\n\nexport const decodedLength = (s: string) =>\n stdCoder.decodedLength(s);\n","// Copyright (C) 2016 Dmitry Chestnykh\n// MIT License. See LICENSE file for details.\n\n/**\n * Package utf8 implements UTF-8 encoding and decoding.\n */\n\nconst INVALID_UTF16 = \"utf8: invalid string\";\nconst INVALID_UTF8 = \"utf8: invalid source encoding\";\n\n/**\n * Encodes the given string into UTF-8 byte array.\n * Throws if the source string has invalid UTF-16 encoding.\n */\nexport function encode(s: string): Uint8Array {\n // Calculate result length and allocate output array.\n // encodedLength() also validates string and throws errors,\n // so we don't need repeat validation here.\n const arr = new Uint8Array(encodedLength(s));\n\n let pos = 0;\n for (let i = 0; i < s.length; i++) {\n let c = s.charCodeAt(i);\n if (c < 0x80) {\n arr[pos++] = c;\n } else if (c < 0x800) {\n arr[pos++] = 0xc0 | c >> 6;\n arr[pos++] = 0x80 | c & 0x3f;\n } else if (c < 0xd800) {\n arr[pos++] = 0xe0 | c >> 12;\n arr[pos++] = 0x80 | (c >> 6) & 0x3f;\n arr[pos++] = 0x80 | c & 0x3f;\n } else {\n i++; // get one more character\n c = (c & 0x3ff) << 10;\n c |= s.charCodeAt(i) & 0x3ff;\n c += 0x10000;\n\n arr[pos++] = 0xf0 | c >> 18;\n arr[pos++] = 0x80 | (c >> 12) & 0x3f;\n arr[pos++] = 0x80 | (c >> 6) & 0x3f;\n arr[pos++] = 0x80 | c & 0x3f;\n }\n }\n return arr;\n}\n\n/**\n * Returns the number of bytes required to encode the given string into UTF-8.\n * Throws if the source string has invalid UTF-16 encoding.\n */\nexport function encodedLength(s: string): number {\n let result = 0;\n for (let i = 0; i < s.length; i++) {\n const c = s.charCodeAt(i);\n if (c < 0x80) {\n result += 1;\n } else if (c < 0x800) {\n result += 2;\n } else if (c < 0xd800) {\n result += 3;\n } else if (c <= 0xdfff) {\n if (i >= s.length - 1) {\n throw new Error(INVALID_UTF16);\n }\n i++; // \"eat\" next character\n result += 4;\n } else {\n throw new Error(INVALID_UTF16);\n }\n }\n return result;\n}\n\n/**\n * Decodes the given byte array from UTF-8 into a string.\n * Throws if encoding is invalid.\n */\nexport function decode(arr: Uint8Array): string {\n const chars: string[] = [];\n for (let i = 0; i < arr.length; i++) {\n let b = arr[i];\n\n if (b & 0x80) {\n let min;\n if (b < 0xe0) {\n // Need 1 more byte.\n if (i >= arr.length) {\n throw new Error(INVALID_UTF8);\n }\n const n1 = arr[++i];\n if ((n1 & 0xc0) !== 0x80) {\n throw new Error(INVALID_UTF8);\n }\n b = (b & 0x1f) << 6 | (n1 & 0x3f);\n min = 0x80;\n } else if (b < 0xf0) {\n // Need 2 more bytes.\n if (i >= arr.length - 1) {\n throw new Error(INVALID_UTF8);\n }\n const n1 = arr[++i];\n const n2 = arr[++i];\n if ((n1 & 0xc0) !== 0x80 || (n2 & 0xc0) !== 0x80) {\n throw new Error(INVALID_UTF8);\n }\n b = (b & 0x0f) << 12 | (n1 & 0x3f) << 6 | (n2 & 0x3f);\n min = 0x800;\n } else if (b < 0xf8) {\n // Need 3 more bytes.\n if (i >= arr.length - 2) {\n throw new Error(INVALID_UTF8);\n }\n const n1 = arr[++i];\n const n2 = arr[++i];\n const n3 = arr[++i];\n if ((n1 & 0xc0) !== 0x80 || (n2 & 0xc0) !== 0x80 || (n3 & 0xc0) !== 0x80) {\n throw new Error(INVALID_UTF8);\n }\n b = (b & 0x0f) << 18 | (n1 & 0x3f) << 12 | (n2 & 0x3f) << 6 | (n3 & 0x3f);\n min = 0x10000;\n } else {\n throw new Error(INVALID_UTF8);\n }\n\n if (b < min || (b >= 0xd800 && b <= 0xdfff)) {\n throw new Error(INVALID_UTF8);\n }\n\n if (b >= 0x10000) {\n // Surrogate pair.\n if (b > 0x10ffff) {\n throw new Error(INVALID_UTF8);\n }\n b -= 0x10000;\n chars.push(String.fromCharCode(0xd800 | (b >> 10)));\n b = 0xdc00 | (b & 0x3ff);\n }\n }\n\n chars.push(String.fromCharCode(b));\n }\n return chars.join(\"\");\n}\n","(function(nacl) {\n'use strict';\n\n// Ported in 2014 by Dmitry Chestnykh and Devi Mandiri.\n// Public domain.\n//\n// Implementation derived from TweetNaCl version 20140427.\n// See for details: http://tweetnacl.cr.yp.to/\n\nvar gf = function(init) {\n var i, r = new Float64Array(16);\n if (init) for (i = 0; i < init.length; i++) r[i] = init[i];\n return r;\n};\n\n// Pluggable, initialized in high-level API below.\nvar randombytes = function(/* x, n */) { throw new Error('no PRNG'); };\n\nvar _0 = new Uint8Array(16);\nvar _9 = new Uint8Array(32); _9[0] = 9;\n\nvar gf0 = gf(),\n gf1 = gf([1]),\n _121665 = gf([0xdb41, 1]),\n D = gf([0x78a3, 0x1359, 0x4dca, 0x75eb, 0xd8ab, 0x4141, 0x0a4d, 0x0070, 0xe898, 0x7779, 0x4079, 0x8cc7, 0xfe73, 0x2b6f, 0x6cee, 0x5203]),\n D2 = gf([0xf159, 0x26b2, 0x9b94, 0xebd6, 0xb156, 0x8283, 0x149a, 0x00e0, 0xd130, 0xeef3, 0x80f2, 0x198e, 0xfce7, 0x56df, 0xd9dc, 0x2406]),\n X = gf([0xd51a, 0x8f25, 0x2d60, 0xc956, 0xa7b2, 0x9525, 0xc760, 0x692c, 0xdc5c, 0xfdd6, 0xe231, 0xc0a4, 0x53fe, 0xcd6e, 0x36d3, 0x2169]),\n Y = gf([0x6658, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666]),\n I = gf([0xa0b0, 0x4a0e, 0x1b27, 0xc4ee, 0xe478, 0xad2f, 0x1806, 0x2f43, 0xd7a7, 0x3dfb, 0x0099, 0x2b4d, 0xdf0b, 0x4fc1, 0x2480, 0x2b83]);\n\nfunction ts64(x, i, h, l) {\n x[i] = (h >> 24) & 0xff;\n x[i+1] = (h >> 16) & 0xff;\n x[i+2] = (h >> 8) & 0xff;\n x[i+3] = h & 0xff;\n x[i+4] = (l >> 24) & 0xff;\n x[i+5] = (l >> 16) & 0xff;\n x[i+6] = (l >> 8) & 0xff;\n x[i+7] = l & 0xff;\n}\n\nfunction vn(x, xi, y, yi, n) {\n var i,d = 0;\n for (i = 0; i < n; i++) d |= x[xi+i]^y[yi+i];\n return (1 & ((d - 1) >>> 8)) - 1;\n}\n\nfunction crypto_verify_16(x, xi, y, yi) {\n return vn(x,xi,y,yi,16);\n}\n\nfunction crypto_verify_32(x, xi, y, yi) {\n return vn(x,xi,y,yi,32);\n}\n\nfunction core_salsa20(o, p, k, c) {\n var j0 = c[ 0] & 0xff | (c[ 1] & 0xff)<<8 | (c[ 2] & 0xff)<<16 | (c[ 3] & 0xff)<<24,\n j1 = k[ 0] & 0xff | (k[ 1] & 0xff)<<8 | (k[ 2] & 0xff)<<16 | (k[ 3] & 0xff)<<24,\n j2 = k[ 4] & 0xff | (k[ 5] & 0xff)<<8 | (k[ 6] & 0xff)<<16 | (k[ 7] & 0xff)<<24,\n j3 = k[ 8] & 0xff | (k[ 9] & 0xff)<<8 | (k[10] & 0xff)<<16 | (k[11] & 0xff)<<24,\n j4 = k[12] & 0xff | (k[13] & 0xff)<<8 | (k[14] & 0xff)<<16 | (k[15] & 0xff)<<24,\n j5 = c[ 4] & 0xff | (c[ 5] & 0xff)<<8 | (c[ 6] & 0xff)<<16 | (c[ 7] & 0xff)<<24,\n j6 = p[ 0] & 0xff | (p[ 1] & 0xff)<<8 | (p[ 2] & 0xff)<<16 | (p[ 3] & 0xff)<<24,\n j7 = p[ 4] & 0xff | (p[ 5] & 0xff)<<8 | (p[ 6] & 0xff)<<16 | (p[ 7] & 0xff)<<24,\n j8 = p[ 8] & 0xff | (p[ 9] & 0xff)<<8 | (p[10] & 0xff)<<16 | (p[11] & 0xff)<<24,\n j9 = p[12] & 0xff | (p[13] & 0xff)<<8 | (p[14] & 0xff)<<16 | (p[15] & 0xff)<<24,\n j10 = c[ 8] & 0xff | (c[ 9] & 0xff)<<8 | (c[10] & 0xff)<<16 | (c[11] & 0xff)<<24,\n j11 = k[16] & 0xff | (k[17] & 0xff)<<8 | (k[18] & 0xff)<<16 | (k[19] & 0xff)<<24,\n j12 = k[20] & 0xff | (k[21] & 0xff)<<8 | (k[22] & 0xff)<<16 | (k[23] & 0xff)<<24,\n j13 = k[24] & 0xff | (k[25] & 0xff)<<8 | (k[26] & 0xff)<<16 | (k[27] & 0xff)<<24,\n j14 = k[28] & 0xff | (k[29] & 0xff)<<8 | (k[30] & 0xff)<<16 | (k[31] & 0xff)<<24,\n j15 = c[12] & 0xff | (c[13] & 0xff)<<8 | (c[14] & 0xff)<<16 | (c[15] & 0xff)<<24;\n\n var x0 = j0, x1 = j1, x2 = j2, x3 = j3, x4 = j4, x5 = j5, x6 = j6, x7 = j7,\n x8 = j8, x9 = j9, x10 = j10, x11 = j11, x12 = j12, x13 = j13, x14 = j14,\n x15 = j15, u;\n\n for (var i = 0; i < 20; i += 2) {\n u = x0 + x12 | 0;\n x4 ^= u<<7 | u>>>(32-7);\n u = x4 + x0 | 0;\n x8 ^= u<<9 | u>>>(32-9);\n u = x8 + x4 | 0;\n x12 ^= u<<13 | u>>>(32-13);\n u = x12 + x8 | 0;\n x0 ^= u<<18 | u>>>(32-18);\n\n u = x5 + x1 | 0;\n x9 ^= u<<7 | u>>>(32-7);\n u = x9 + x5 | 0;\n x13 ^= u<<9 | u>>>(32-9);\n u = x13 + x9 | 0;\n x1 ^= u<<13 | u>>>(32-13);\n u = x1 + x13 | 0;\n x5 ^= u<<18 | u>>>(32-18);\n\n u = x10 + x6 | 0;\n x14 ^= u<<7 | u>>>(32-7);\n u = x14 + x10 | 0;\n x2 ^= u<<9 | u>>>(32-9);\n u = x2 + x14 | 0;\n x6 ^= u<<13 | u>>>(32-13);\n u = x6 + x2 | 0;\n x10 ^= u<<18 | u>>>(32-18);\n\n u = x15 + x11 | 0;\n x3 ^= u<<7 | u>>>(32-7);\n u = x3 + x15 | 0;\n x7 ^= u<<9 | u>>>(32-9);\n u = x7 + x3 | 0;\n x11 ^= u<<13 | u>>>(32-13);\n u = x11 + x7 | 0;\n x15 ^= u<<18 | u>>>(32-18);\n\n u = x0 + x3 | 0;\n x1 ^= u<<7 | u>>>(32-7);\n u = x1 + x0 | 0;\n x2 ^= u<<9 | u>>>(32-9);\n u = x2 + x1 | 0;\n x3 ^= u<<13 | u>>>(32-13);\n u = x3 + x2 | 0;\n x0 ^= u<<18 | u>>>(32-18);\n\n u = x5 + x4 | 0;\n x6 ^= u<<7 | u>>>(32-7);\n u = x6 + x5 | 0;\n x7 ^= u<<9 | u>>>(32-9);\n u = x7 + x6 | 0;\n x4 ^= u<<13 | u>>>(32-13);\n u = x4 + x7 | 0;\n x5 ^= u<<18 | u>>>(32-18);\n\n u = x10 + x9 | 0;\n x11 ^= u<<7 | u>>>(32-7);\n u = x11 + x10 | 0;\n x8 ^= u<<9 | u>>>(32-9);\n u = x8 + x11 | 0;\n x9 ^= u<<13 | u>>>(32-13);\n u = x9 + x8 | 0;\n x10 ^= u<<18 | u>>>(32-18);\n\n u = x15 + x14 | 0;\n x12 ^= u<<7 | u>>>(32-7);\n u = x12 + x15 | 0;\n x13 ^= u<<9 | u>>>(32-9);\n u = x13 + x12 | 0;\n x14 ^= u<<13 | u>>>(32-13);\n u = x14 + x13 | 0;\n x15 ^= u<<18 | u>>>(32-18);\n }\n x0 = x0 + j0 | 0;\n x1 = x1 + j1 | 0;\n x2 = x2 + j2 | 0;\n x3 = x3 + j3 | 0;\n x4 = x4 + j4 | 0;\n x5 = x5 + j5 | 0;\n x6 = x6 + j6 | 0;\n x7 = x7 + j7 | 0;\n x8 = x8 + j8 | 0;\n x9 = x9 + j9 | 0;\n x10 = x10 + j10 | 0;\n x11 = x11 + j11 | 0;\n x12 = x12 + j12 | 0;\n x13 = x13 + j13 | 0;\n x14 = x14 + j14 | 0;\n x15 = x15 + j15 | 0;\n\n o[ 0] = x0 >>> 0 & 0xff;\n o[ 1] = x0 >>> 8 & 0xff;\n o[ 2] = x0 >>> 16 & 0xff;\n o[ 3] = x0 >>> 24 & 0xff;\n\n o[ 4] = x1 >>> 0 & 0xff;\n o[ 5] = x1 >>> 8 & 0xff;\n o[ 6] = x1 >>> 16 & 0xff;\n o[ 7] = x1 >>> 24 & 0xff;\n\n o[ 8] = x2 >>> 0 & 0xff;\n o[ 9] = x2 >>> 8 & 0xff;\n o[10] = x2 >>> 16 & 0xff;\n o[11] = x2 >>> 24 & 0xff;\n\n o[12] = x3 >>> 0 & 0xff;\n o[13] = x3 >>> 8 & 0xff;\n o[14] = x3 >>> 16 & 0xff;\n o[15] = x3 >>> 24 & 0xff;\n\n o[16] = x4 >>> 0 & 0xff;\n o[17] = x4 >>> 8 & 0xff;\n o[18] = x4 >>> 16 & 0xff;\n o[19] = x4 >>> 24 & 0xff;\n\n o[20] = x5 >>> 0 & 0xff;\n o[21] = x5 >>> 8 & 0xff;\n o[22] = x5 >>> 16 & 0xff;\n o[23] = x5 >>> 24 & 0xff;\n\n o[24] = x6 >>> 0 & 0xff;\n o[25] = x6 >>> 8 & 0xff;\n o[26] = x6 >>> 16 & 0xff;\n o[27] = x6 >>> 24 & 0xff;\n\n o[28] = x7 >>> 0 & 0xff;\n o[29] = x7 >>> 8 & 0xff;\n o[30] = x7 >>> 16 & 0xff;\n o[31] = x7 >>> 24 & 0xff;\n\n o[32] = x8 >>> 0 & 0xff;\n o[33] = x8 >>> 8 & 0xff;\n o[34] = x8 >>> 16 & 0xff;\n o[35] = x8 >>> 24 & 0xff;\n\n o[36] = x9 >>> 0 & 0xff;\n o[37] = x9 >>> 8 & 0xff;\n o[38] = x9 >>> 16 & 0xff;\n o[39] = x9 >>> 24 & 0xff;\n\n o[40] = x10 >>> 0 & 0xff;\n o[41] = x10 >>> 8 & 0xff;\n o[42] = x10 >>> 16 & 0xff;\n o[43] = x10 >>> 24 & 0xff;\n\n o[44] = x11 >>> 0 & 0xff;\n o[45] = x11 >>> 8 & 0xff;\n o[46] = x11 >>> 16 & 0xff;\n o[47] = x11 >>> 24 & 0xff;\n\n o[48] = x12 >>> 0 & 0xff;\n o[49] = x12 >>> 8 & 0xff;\n o[50] = x12 >>> 16 & 0xff;\n o[51] = x12 >>> 24 & 0xff;\n\n o[52] = x13 >>> 0 & 0xff;\n o[53] = x13 >>> 8 & 0xff;\n o[54] = x13 >>> 16 & 0xff;\n o[55] = x13 >>> 24 & 0xff;\n\n o[56] = x14 >>> 0 & 0xff;\n o[57] = x14 >>> 8 & 0xff;\n o[58] = x14 >>> 16 & 0xff;\n o[59] = x14 >>> 24 & 0xff;\n\n o[60] = x15 >>> 0 & 0xff;\n o[61] = x15 >>> 8 & 0xff;\n o[62] = x15 >>> 16 & 0xff;\n o[63] = x15 >>> 24 & 0xff;\n}\n\nfunction core_hsalsa20(o,p,k,c) {\n var j0 = c[ 0] & 0xff | (c[ 1] & 0xff)<<8 | (c[ 2] & 0xff)<<16 | (c[ 3] & 0xff)<<24,\n j1 = k[ 0] & 0xff | (k[ 1] & 0xff)<<8 | (k[ 2] & 0xff)<<16 | (k[ 3] & 0xff)<<24,\n j2 = k[ 4] & 0xff | (k[ 5] & 0xff)<<8 | (k[ 6] & 0xff)<<16 | (k[ 7] & 0xff)<<24,\n j3 = k[ 8] & 0xff | (k[ 9] & 0xff)<<8 | (k[10] & 0xff)<<16 | (k[11] & 0xff)<<24,\n j4 = k[12] & 0xff | (k[13] & 0xff)<<8 | (k[14] & 0xff)<<16 | (k[15] & 0xff)<<24,\n j5 = c[ 4] & 0xff | (c[ 5] & 0xff)<<8 | (c[ 6] & 0xff)<<16 | (c[ 7] & 0xff)<<24,\n j6 = p[ 0] & 0xff | (p[ 1] & 0xff)<<8 | (p[ 2] & 0xff)<<16 | (p[ 3] & 0xff)<<24,\n j7 = p[ 4] & 0xff | (p[ 5] & 0xff)<<8 | (p[ 6] & 0xff)<<16 | (p[ 7] & 0xff)<<24,\n j8 = p[ 8] & 0xff | (p[ 9] & 0xff)<<8 | (p[10] & 0xff)<<16 | (p[11] & 0xff)<<24,\n j9 = p[12] & 0xff | (p[13] & 0xff)<<8 | (p[14] & 0xff)<<16 | (p[15] & 0xff)<<24,\n j10 = c[ 8] & 0xff | (c[ 9] & 0xff)<<8 | (c[10] & 0xff)<<16 | (c[11] & 0xff)<<24,\n j11 = k[16] & 0xff | (k[17] & 0xff)<<8 | (k[18] & 0xff)<<16 | (k[19] & 0xff)<<24,\n j12 = k[20] & 0xff | (k[21] & 0xff)<<8 | (k[22] & 0xff)<<16 | (k[23] & 0xff)<<24,\n j13 = k[24] & 0xff | (k[25] & 0xff)<<8 | (k[26] & 0xff)<<16 | (k[27] & 0xff)<<24,\n j14 = k[28] & 0xff | (k[29] & 0xff)<<8 | (k[30] & 0xff)<<16 | (k[31] & 0xff)<<24,\n j15 = c[12] & 0xff | (c[13] & 0xff)<<8 | (c[14] & 0xff)<<16 | (c[15] & 0xff)<<24;\n\n var x0 = j0, x1 = j1, x2 = j2, x3 = j3, x4 = j4, x5 = j5, x6 = j6, x7 = j7,\n x8 = j8, x9 = j9, x10 = j10, x11 = j11, x12 = j12, x13 = j13, x14 = j14,\n x15 = j15, u;\n\n for (var i = 0; i < 20; i += 2) {\n u = x0 + x12 | 0;\n x4 ^= u<<7 | u>>>(32-7);\n u = x4 + x0 | 0;\n x8 ^= u<<9 | u>>>(32-9);\n u = x8 + x4 | 0;\n x12 ^= u<<13 | u>>>(32-13);\n u = x12 + x8 | 0;\n x0 ^= u<<18 | u>>>(32-18);\n\n u = x5 + x1 | 0;\n x9 ^= u<<7 | u>>>(32-7);\n u = x9 + x5 | 0;\n x13 ^= u<<9 | u>>>(32-9);\n u = x13 + x9 | 0;\n x1 ^= u<<13 | u>>>(32-13);\n u = x1 + x13 | 0;\n x5 ^= u<<18 | u>>>(32-18);\n\n u = x10 + x6 | 0;\n x14 ^= u<<7 | u>>>(32-7);\n u = x14 + x10 | 0;\n x2 ^= u<<9 | u>>>(32-9);\n u = x2 + x14 | 0;\n x6 ^= u<<13 | u>>>(32-13);\n u = x6 + x2 | 0;\n x10 ^= u<<18 | u>>>(32-18);\n\n u = x15 + x11 | 0;\n x3 ^= u<<7 | u>>>(32-7);\n u = x3 + x15 | 0;\n x7 ^= u<<9 | u>>>(32-9);\n u = x7 + x3 | 0;\n x11 ^= u<<13 | u>>>(32-13);\n u = x11 + x7 | 0;\n x15 ^= u<<18 | u>>>(32-18);\n\n u = x0 + x3 | 0;\n x1 ^= u<<7 | u>>>(32-7);\n u = x1 + x0 | 0;\n x2 ^= u<<9 | u>>>(32-9);\n u = x2 + x1 | 0;\n x3 ^= u<<13 | u>>>(32-13);\n u = x3 + x2 | 0;\n x0 ^= u<<18 | u>>>(32-18);\n\n u = x5 + x4 | 0;\n x6 ^= u<<7 | u>>>(32-7);\n u = x6 + x5 | 0;\n x7 ^= u<<9 | u>>>(32-9);\n u = x7 + x6 | 0;\n x4 ^= u<<13 | u>>>(32-13);\n u = x4 + x7 | 0;\n x5 ^= u<<18 | u>>>(32-18);\n\n u = x10 + x9 | 0;\n x11 ^= u<<7 | u>>>(32-7);\n u = x11 + x10 | 0;\n x8 ^= u<<9 | u>>>(32-9);\n u = x8 + x11 | 0;\n x9 ^= u<<13 | u>>>(32-13);\n u = x9 + x8 | 0;\n x10 ^= u<<18 | u>>>(32-18);\n\n u = x15 + x14 | 0;\n x12 ^= u<<7 | u>>>(32-7);\n u = x12 + x15 | 0;\n x13 ^= u<<9 | u>>>(32-9);\n u = x13 + x12 | 0;\n x14 ^= u<<13 | u>>>(32-13);\n u = x14 + x13 | 0;\n x15 ^= u<<18 | u>>>(32-18);\n }\n\n o[ 0] = x0 >>> 0 & 0xff;\n o[ 1] = x0 >>> 8 & 0xff;\n o[ 2] = x0 >>> 16 & 0xff;\n o[ 3] = x0 >>> 24 & 0xff;\n\n o[ 4] = x5 >>> 0 & 0xff;\n o[ 5] = x5 >>> 8 & 0xff;\n o[ 6] = x5 >>> 16 & 0xff;\n o[ 7] = x5 >>> 24 & 0xff;\n\n o[ 8] = x10 >>> 0 & 0xff;\n o[ 9] = x10 >>> 8 & 0xff;\n o[10] = x10 >>> 16 & 0xff;\n o[11] = x10 >>> 24 & 0xff;\n\n o[12] = x15 >>> 0 & 0xff;\n o[13] = x15 >>> 8 & 0xff;\n o[14] = x15 >>> 16 & 0xff;\n o[15] = x15 >>> 24 & 0xff;\n\n o[16] = x6 >>> 0 & 0xff;\n o[17] = x6 >>> 8 & 0xff;\n o[18] = x6 >>> 16 & 0xff;\n o[19] = x6 >>> 24 & 0xff;\n\n o[20] = x7 >>> 0 & 0xff;\n o[21] = x7 >>> 8 & 0xff;\n o[22] = x7 >>> 16 & 0xff;\n o[23] = x7 >>> 24 & 0xff;\n\n o[24] = x8 >>> 0 & 0xff;\n o[25] = x8 >>> 8 & 0xff;\n o[26] = x8 >>> 16 & 0xff;\n o[27] = x8 >>> 24 & 0xff;\n\n o[28] = x9 >>> 0 & 0xff;\n o[29] = x9 >>> 8 & 0xff;\n o[30] = x9 >>> 16 & 0xff;\n o[31] = x9 >>> 24 & 0xff;\n}\n\nfunction crypto_core_salsa20(out,inp,k,c) {\n core_salsa20(out,inp,k,c);\n}\n\nfunction crypto_core_hsalsa20(out,inp,k,c) {\n core_hsalsa20(out,inp,k,c);\n}\n\nvar sigma = new Uint8Array([101, 120, 112, 97, 110, 100, 32, 51, 50, 45, 98, 121, 116, 101, 32, 107]);\n // \"expand 32-byte k\"\n\nfunction crypto_stream_salsa20_xor(c,cpos,m,mpos,b,n,k) {\n var z = new Uint8Array(16), x = new Uint8Array(64);\n var u, i;\n for (i = 0; i < 16; i++) z[i] = 0;\n for (i = 0; i < 8; i++) z[i] = n[i];\n while (b >= 64) {\n crypto_core_salsa20(x,z,k,sigma);\n for (i = 0; i < 64; i++) c[cpos+i] = m[mpos+i] ^ x[i];\n u = 1;\n for (i = 8; i < 16; i++) {\n u = u + (z[i] & 0xff) | 0;\n z[i] = u & 0xff;\n u >>>= 8;\n }\n b -= 64;\n cpos += 64;\n mpos += 64;\n }\n if (b > 0) {\n crypto_core_salsa20(x,z,k,sigma);\n for (i = 0; i < b; i++) c[cpos+i] = m[mpos+i] ^ x[i];\n }\n return 0;\n}\n\nfunction crypto_stream_salsa20(c,cpos,b,n,k) {\n var z = new Uint8Array(16), x = new Uint8Array(64);\n var u, i;\n for (i = 0; i < 16; i++) z[i] = 0;\n for (i = 0; i < 8; i++) z[i] = n[i];\n while (b >= 64) {\n crypto_core_salsa20(x,z,k,sigma);\n for (i = 0; i < 64; i++) c[cpos+i] = x[i];\n u = 1;\n for (i = 8; i < 16; i++) {\n u = u + (z[i] & 0xff) | 0;\n z[i] = u & 0xff;\n u >>>= 8;\n }\n b -= 64;\n cpos += 64;\n }\n if (b > 0) {\n crypto_core_salsa20(x,z,k,sigma);\n for (i = 0; i < b; i++) c[cpos+i] = x[i];\n }\n return 0;\n}\n\nfunction crypto_stream(c,cpos,d,n,k) {\n var s = new Uint8Array(32);\n crypto_core_hsalsa20(s,n,k,sigma);\n var sn = new Uint8Array(8);\n for (var i = 0; i < 8; i++) sn[i] = n[i+16];\n return crypto_stream_salsa20(c,cpos,d,sn,s);\n}\n\nfunction crypto_stream_xor(c,cpos,m,mpos,d,n,k) {\n var s = new Uint8Array(32);\n crypto_core_hsalsa20(s,n,k,sigma);\n var sn = new Uint8Array(8);\n for (var i = 0; i < 8; i++) sn[i] = n[i+16];\n return crypto_stream_salsa20_xor(c,cpos,m,mpos,d,sn,s);\n}\n\n/*\n* Port of Andrew Moon's Poly1305-donna-16. Public domain.\n* https://github.com/floodyberry/poly1305-donna\n*/\n\nvar poly1305 = function(key) {\n this.buffer = new Uint8Array(16);\n this.r = new Uint16Array(10);\n this.h = new Uint16Array(10);\n this.pad = new Uint16Array(8);\n this.leftover = 0;\n this.fin = 0;\n\n var t0, t1, t2, t3, t4, t5, t6, t7;\n\n t0 = key[ 0] & 0xff | (key[ 1] & 0xff) << 8; this.r[0] = ( t0 ) & 0x1fff;\n t1 = key[ 2] & 0xff | (key[ 3] & 0xff) << 8; this.r[1] = ((t0 >>> 13) | (t1 << 3)) & 0x1fff;\n t2 = key[ 4] & 0xff | (key[ 5] & 0xff) << 8; this.r[2] = ((t1 >>> 10) | (t2 << 6)) & 0x1f03;\n t3 = key[ 6] & 0xff | (key[ 7] & 0xff) << 8; this.r[3] = ((t2 >>> 7) | (t3 << 9)) & 0x1fff;\n t4 = key[ 8] & 0xff | (key[ 9] & 0xff) << 8; this.r[4] = ((t3 >>> 4) | (t4 << 12)) & 0x00ff;\n this.r[5] = ((t4 >>> 1)) & 0x1ffe;\n t5 = key[10] & 0xff | (key[11] & 0xff) << 8; this.r[6] = ((t4 >>> 14) | (t5 << 2)) & 0x1fff;\n t6 = key[12] & 0xff | (key[13] & 0xff) << 8; this.r[7] = ((t5 >>> 11) | (t6 << 5)) & 0x1f81;\n t7 = key[14] & 0xff | (key[15] & 0xff) << 8; this.r[8] = ((t6 >>> 8) | (t7 << 8)) & 0x1fff;\n this.r[9] = ((t7 >>> 5)) & 0x007f;\n\n this.pad[0] = key[16] & 0xff | (key[17] & 0xff) << 8;\n this.pad[1] = key[18] & 0xff | (key[19] & 0xff) << 8;\n this.pad[2] = key[20] & 0xff | (key[21] & 0xff) << 8;\n this.pad[3] = key[22] & 0xff | (key[23] & 0xff) << 8;\n this.pad[4] = key[24] & 0xff | (key[25] & 0xff) << 8;\n this.pad[5] = key[26] & 0xff | (key[27] & 0xff) << 8;\n this.pad[6] = key[28] & 0xff | (key[29] & 0xff) << 8;\n this.pad[7] = key[30] & 0xff | (key[31] & 0xff) << 8;\n};\n\npoly1305.prototype.blocks = function(m, mpos, bytes) {\n var hibit = this.fin ? 0 : (1 << 11);\n var t0, t1, t2, t3, t4, t5, t6, t7, c;\n var d0, d1, d2, d3, d4, d5, d6, d7, d8, d9;\n\n var h0 = this.h[0],\n h1 = this.h[1],\n h2 = this.h[2],\n h3 = this.h[3],\n h4 = this.h[4],\n h5 = this.h[5],\n h6 = this.h[6],\n h7 = this.h[7],\n h8 = this.h[8],\n h9 = this.h[9];\n\n var r0 = this.r[0],\n r1 = this.r[1],\n r2 = this.r[2],\n r3 = this.r[3],\n r4 = this.r[4],\n r5 = this.r[5],\n r6 = this.r[6],\n r7 = this.r[7],\n r8 = this.r[8],\n r9 = this.r[9];\n\n while (bytes >= 16) {\n t0 = m[mpos+ 0] & 0xff | (m[mpos+ 1] & 0xff) << 8; h0 += ( t0 ) & 0x1fff;\n t1 = m[mpos+ 2] & 0xff | (m[mpos+ 3] & 0xff) << 8; h1 += ((t0 >>> 13) | (t1 << 3)) & 0x1fff;\n t2 = m[mpos+ 4] & 0xff | (m[mpos+ 5] & 0xff) << 8; h2 += ((t1 >>> 10) | (t2 << 6)) & 0x1fff;\n t3 = m[mpos+ 6] & 0xff | (m[mpos+ 7] & 0xff) << 8; h3 += ((t2 >>> 7) | (t3 << 9)) & 0x1fff;\n t4 = m[mpos+ 8] & 0xff | (m[mpos+ 9] & 0xff) << 8; h4 += ((t3 >>> 4) | (t4 << 12)) & 0x1fff;\n h5 += ((t4 >>> 1)) & 0x1fff;\n t5 = m[mpos+10] & 0xff | (m[mpos+11] & 0xff) << 8; h6 += ((t4 >>> 14) | (t5 << 2)) & 0x1fff;\n t6 = m[mpos+12] & 0xff | (m[mpos+13] & 0xff) << 8; h7 += ((t5 >>> 11) | (t6 << 5)) & 0x1fff;\n t7 = m[mpos+14] & 0xff | (m[mpos+15] & 0xff) << 8; h8 += ((t6 >>> 8) | (t7 << 8)) & 0x1fff;\n h9 += ((t7 >>> 5)) | hibit;\n\n c = 0;\n\n d0 = c;\n d0 += h0 * r0;\n d0 += h1 * (5 * r9);\n d0 += h2 * (5 * r8);\n d0 += h3 * (5 * r7);\n d0 += h4 * (5 * r6);\n c = (d0 >>> 13); d0 &= 0x1fff;\n d0 += h5 * (5 * r5);\n d0 += h6 * (5 * r4);\n d0 += h7 * (5 * r3);\n d0 += h8 * (5 * r2);\n d0 += h9 * (5 * r1);\n c += (d0 >>> 13); d0 &= 0x1fff;\n\n d1 = c;\n d1 += h0 * r1;\n d1 += h1 * r0;\n d1 += h2 * (5 * r9);\n d1 += h3 * (5 * r8);\n d1 += h4 * (5 * r7);\n c = (d1 >>> 13); d1 &= 0x1fff;\n d1 += h5 * (5 * r6);\n d1 += h6 * (5 * r5);\n d1 += h7 * (5 * r4);\n d1 += h8 * (5 * r3);\n d1 += h9 * (5 * r2);\n c += (d1 >>> 13); d1 &= 0x1fff;\n\n d2 = c;\n d2 += h0 * r2;\n d2 += h1 * r1;\n d2 += h2 * r0;\n d2 += h3 * (5 * r9);\n d2 += h4 * (5 * r8);\n c = (d2 >>> 13); d2 &= 0x1fff;\n d2 += h5 * (5 * r7);\n d2 += h6 * (5 * r6);\n d2 += h7 * (5 * r5);\n d2 += h8 * (5 * r4);\n d2 += h9 * (5 * r3);\n c += (d2 >>> 13); d2 &= 0x1fff;\n\n d3 = c;\n d3 += h0 * r3;\n d3 += h1 * r2;\n d3 += h2 * r1;\n d3 += h3 * r0;\n d3 += h4 * (5 * r9);\n c = (d3 >>> 13); d3 &= 0x1fff;\n d3 += h5 * (5 * r8);\n d3 += h6 * (5 * r7);\n d3 += h7 * (5 * r6);\n d3 += h8 * (5 * r5);\n d3 += h9 * (5 * r4);\n c += (d3 >>> 13); d3 &= 0x1fff;\n\n d4 = c;\n d4 += h0 * r4;\n d4 += h1 * r3;\n d4 += h2 * r2;\n d4 += h3 * r1;\n d4 += h4 * r0;\n c = (d4 >>> 13); d4 &= 0x1fff;\n d4 += h5 * (5 * r9);\n d4 += h6 * (5 * r8);\n d4 += h7 * (5 * r7);\n d4 += h8 * (5 * r6);\n d4 += h9 * (5 * r5);\n c += (d4 >>> 13); d4 &= 0x1fff;\n\n d5 = c;\n d5 += h0 * r5;\n d5 += h1 * r4;\n d5 += h2 * r3;\n d5 += h3 * r2;\n d5 += h4 * r1;\n c = (d5 >>> 13); d5 &= 0x1fff;\n d5 += h5 * r0;\n d5 += h6 * (5 * r9);\n d5 += h7 * (5 * r8);\n d5 += h8 * (5 * r7);\n d5 += h9 * (5 * r6);\n c += (d5 >>> 13); d5 &= 0x1fff;\n\n d6 = c;\n d6 += h0 * r6;\n d6 += h1 * r5;\n d6 += h2 * r4;\n d6 += h3 * r3;\n d6 += h4 * r2;\n c = (d6 >>> 13); d6 &= 0x1fff;\n d6 += h5 * r1;\n d6 += h6 * r0;\n d6 += h7 * (5 * r9);\n d6 += h8 * (5 * r8);\n d6 += h9 * (5 * r7);\n c += (d6 >>> 13); d6 &= 0x1fff;\n\n d7 = c;\n d7 += h0 * r7;\n d7 += h1 * r6;\n d7 += h2 * r5;\n d7 += h3 * r4;\n d7 += h4 * r3;\n c = (d7 >>> 13); d7 &= 0x1fff;\n d7 += h5 * r2;\n d7 += h6 * r1;\n d7 += h7 * r0;\n d7 += h8 * (5 * r9);\n d7 += h9 * (5 * r8);\n c += (d7 >>> 13); d7 &= 0x1fff;\n\n d8 = c;\n d8 += h0 * r8;\n d8 += h1 * r7;\n d8 += h2 * r6;\n d8 += h3 * r5;\n d8 += h4 * r4;\n c = (d8 >>> 13); d8 &= 0x1fff;\n d8 += h5 * r3;\n d8 += h6 * r2;\n d8 += h7 * r1;\n d8 += h8 * r0;\n d8 += h9 * (5 * r9);\n c += (d8 >>> 13); d8 &= 0x1fff;\n\n d9 = c;\n d9 += h0 * r9;\n d9 += h1 * r8;\n d9 += h2 * r7;\n d9 += h3 * r6;\n d9 += h4 * r5;\n c = (d9 >>> 13); d9 &= 0x1fff;\n d9 += h5 * r4;\n d9 += h6 * r3;\n d9 += h7 * r2;\n d9 += h8 * r1;\n d9 += h9 * r0;\n c += (d9 >>> 13); d9 &= 0x1fff;\n\n c = (((c << 2) + c)) | 0;\n c = (c + d0) | 0;\n d0 = c & 0x1fff;\n c = (c >>> 13);\n d1 += c;\n\n h0 = d0;\n h1 = d1;\n h2 = d2;\n h3 = d3;\n h4 = d4;\n h5 = d5;\n h6 = d6;\n h7 = d7;\n h8 = d8;\n h9 = d9;\n\n mpos += 16;\n bytes -= 16;\n }\n this.h[0] = h0;\n this.h[1] = h1;\n this.h[2] = h2;\n this.h[3] = h3;\n this.h[4] = h4;\n this.h[5] = h5;\n this.h[6] = h6;\n this.h[7] = h7;\n this.h[8] = h8;\n this.h[9] = h9;\n};\n\npoly1305.prototype.finish = function(mac, macpos) {\n var g = new Uint16Array(10);\n var c, mask, f, i;\n\n if (this.leftover) {\n i = this.leftover;\n this.buffer[i++] = 1;\n for (; i < 16; i++) this.buffer[i] = 0;\n this.fin = 1;\n this.blocks(this.buffer, 0, 16);\n }\n\n c = this.h[1] >>> 13;\n this.h[1] &= 0x1fff;\n for (i = 2; i < 10; i++) {\n this.h[i] += c;\n c = this.h[i] >>> 13;\n this.h[i] &= 0x1fff;\n }\n this.h[0] += (c * 5);\n c = this.h[0] >>> 13;\n this.h[0] &= 0x1fff;\n this.h[1] += c;\n c = this.h[1] >>> 13;\n this.h[1] &= 0x1fff;\n this.h[2] += c;\n\n g[0] = this.h[0] + 5;\n c = g[0] >>> 13;\n g[0] &= 0x1fff;\n for (i = 1; i < 10; i++) {\n g[i] = this.h[i] + c;\n c = g[i] >>> 13;\n g[i] &= 0x1fff;\n }\n g[9] -= (1 << 13);\n\n mask = (c ^ 1) - 1;\n for (i = 0; i < 10; i++) g[i] &= mask;\n mask = ~mask;\n for (i = 0; i < 10; i++) this.h[i] = (this.h[i] & mask) | g[i];\n\n this.h[0] = ((this.h[0] ) | (this.h[1] << 13) ) & 0xffff;\n this.h[1] = ((this.h[1] >>> 3) | (this.h[2] << 10) ) & 0xffff;\n this.h[2] = ((this.h[2] >>> 6) | (this.h[3] << 7) ) & 0xffff;\n this.h[3] = ((this.h[3] >>> 9) | (this.h[4] << 4) ) & 0xffff;\n this.h[4] = ((this.h[4] >>> 12) | (this.h[5] << 1) | (this.h[6] << 14)) & 0xffff;\n this.h[5] = ((this.h[6] >>> 2) | (this.h[7] << 11) ) & 0xffff;\n this.h[6] = ((this.h[7] >>> 5) | (this.h[8] << 8) ) & 0xffff;\n this.h[7] = ((this.h[8] >>> 8) | (this.h[9] << 5) ) & 0xffff;\n\n f = this.h[0] + this.pad[0];\n this.h[0] = f & 0xffff;\n for (i = 1; i < 8; i++) {\n f = (((this.h[i] + this.pad[i]) | 0) + (f >>> 16)) | 0;\n this.h[i] = f & 0xffff;\n }\n\n mac[macpos+ 0] = (this.h[0] >>> 0) & 0xff;\n mac[macpos+ 1] = (this.h[0] >>> 8) & 0xff;\n mac[macpos+ 2] = (this.h[1] >>> 0) & 0xff;\n mac[macpos+ 3] = (this.h[1] >>> 8) & 0xff;\n mac[macpos+ 4] = (this.h[2] >>> 0) & 0xff;\n mac[macpos+ 5] = (this.h[2] >>> 8) & 0xff;\n mac[macpos+ 6] = (this.h[3] >>> 0) & 0xff;\n mac[macpos+ 7] = (this.h[3] >>> 8) & 0xff;\n mac[macpos+ 8] = (this.h[4] >>> 0) & 0xff;\n mac[macpos+ 9] = (this.h[4] >>> 8) & 0xff;\n mac[macpos+10] = (this.h[5] >>> 0) & 0xff;\n mac[macpos+11] = (this.h[5] >>> 8) & 0xff;\n mac[macpos+12] = (this.h[6] >>> 0) & 0xff;\n mac[macpos+13] = (this.h[6] >>> 8) & 0xff;\n mac[macpos+14] = (this.h[7] >>> 0) & 0xff;\n mac[macpos+15] = (this.h[7] >>> 8) & 0xff;\n};\n\npoly1305.prototype.update = function(m, mpos, bytes) {\n var i, want;\n\n if (this.leftover) {\n want = (16 - this.leftover);\n if (want > bytes)\n want = bytes;\n for (i = 0; i < want; i++)\n this.buffer[this.leftover + i] = m[mpos+i];\n bytes -= want;\n mpos += want;\n this.leftover += want;\n if (this.leftover < 16)\n return;\n this.blocks(this.buffer, 0, 16);\n this.leftover = 0;\n }\n\n if (bytes >= 16) {\n want = bytes - (bytes % 16);\n this.blocks(m, mpos, want);\n mpos += want;\n bytes -= want;\n }\n\n if (bytes) {\n for (i = 0; i < bytes; i++)\n this.buffer[this.leftover + i] = m[mpos+i];\n this.leftover += bytes;\n }\n};\n\nfunction crypto_onetimeauth(out, outpos, m, mpos, n, k) {\n var s = new poly1305(k);\n s.update(m, mpos, n);\n s.finish(out, outpos);\n return 0;\n}\n\nfunction crypto_onetimeauth_verify(h, hpos, m, mpos, n, k) {\n var x = new Uint8Array(16);\n crypto_onetimeauth(x,0,m,mpos,n,k);\n return crypto_verify_16(h,hpos,x,0);\n}\n\nfunction crypto_secretbox(c,m,d,n,k) {\n var i;\n if (d < 32) return -1;\n crypto_stream_xor(c,0,m,0,d,n,k);\n crypto_onetimeauth(c, 16, c, 32, d - 32, c);\n for (i = 0; i < 16; i++) c[i] = 0;\n return 0;\n}\n\nfunction crypto_secretbox_open(m,c,d,n,k) {\n var i;\n var x = new Uint8Array(32);\n if (d < 32) return -1;\n crypto_stream(x,0,32,n,k);\n if (crypto_onetimeauth_verify(c, 16,c, 32,d - 32,x) !== 0) return -1;\n crypto_stream_xor(m,0,c,0,d,n,k);\n for (i = 0; i < 32; i++) m[i] = 0;\n return 0;\n}\n\nfunction set25519(r, a) {\n var i;\n for (i = 0; i < 16; i++) r[i] = a[i]|0;\n}\n\nfunction car25519(o) {\n var i, v, c = 1;\n for (i = 0; i < 16; i++) {\n v = o[i] + c + 65535;\n c = Math.floor(v / 65536);\n o[i] = v - c * 65536;\n }\n o[0] += c-1 + 37 * (c-1);\n}\n\nfunction sel25519(p, q, b) {\n var t, c = ~(b-1);\n for (var i = 0; i < 16; i++) {\n t = c & (p[i] ^ q[i]);\n p[i] ^= t;\n q[i] ^= t;\n }\n}\n\nfunction pack25519(o, n) {\n var i, j, b;\n var m = gf(), t = gf();\n for (i = 0; i < 16; i++) t[i] = n[i];\n car25519(t);\n car25519(t);\n car25519(t);\n for (j = 0; j < 2; j++) {\n m[0] = t[0] - 0xffed;\n for (i = 1; i < 15; i++) {\n m[i] = t[i] - 0xffff - ((m[i-1]>>16) & 1);\n m[i-1] &= 0xffff;\n }\n m[15] = t[15] - 0x7fff - ((m[14]>>16) & 1);\n b = (m[15]>>16) & 1;\n m[14] &= 0xffff;\n sel25519(t, m, 1-b);\n }\n for (i = 0; i < 16; i++) {\n o[2*i] = t[i] & 0xff;\n o[2*i+1] = t[i]>>8;\n }\n}\n\nfunction neq25519(a, b) {\n var c = new Uint8Array(32), d = new Uint8Array(32);\n pack25519(c, a);\n pack25519(d, b);\n return crypto_verify_32(c, 0, d, 0);\n}\n\nfunction par25519(a) {\n var d = new Uint8Array(32);\n pack25519(d, a);\n return d[0] & 1;\n}\n\nfunction unpack25519(o, n) {\n var i;\n for (i = 0; i < 16; i++) o[i] = n[2*i] + (n[2*i+1] << 8);\n o[15] &= 0x7fff;\n}\n\nfunction A(o, a, b) {\n for (var i = 0; i < 16; i++) o[i] = a[i] + b[i];\n}\n\nfunction Z(o, a, b) {\n for (var i = 0; i < 16; i++) o[i] = a[i] - b[i];\n}\n\nfunction M(o, a, b) {\n var v, c,\n t0 = 0, t1 = 0, t2 = 0, t3 = 0, t4 = 0, t5 = 0, t6 = 0, t7 = 0,\n t8 = 0, t9 = 0, t10 = 0, t11 = 0, t12 = 0, t13 = 0, t14 = 0, t15 = 0,\n t16 = 0, t17 = 0, t18 = 0, t19 = 0, t20 = 0, t21 = 0, t22 = 0, t23 = 0,\n t24 = 0, t25 = 0, t26 = 0, t27 = 0, t28 = 0, t29 = 0, t30 = 0,\n b0 = b[0],\n b1 = b[1],\n b2 = b[2],\n b3 = b[3],\n b4 = b[4],\n b5 = b[5],\n b6 = b[6],\n b7 = b[7],\n b8 = b[8],\n b9 = b[9],\n b10 = b[10],\n b11 = b[11],\n b12 = b[12],\n b13 = b[13],\n b14 = b[14],\n b15 = b[15];\n\n v = a[0];\n t0 += v * b0;\n t1 += v * b1;\n t2 += v * b2;\n t3 += v * b3;\n t4 += v * b4;\n t5 += v * b5;\n t6 += v * b6;\n t7 += v * b7;\n t8 += v * b8;\n t9 += v * b9;\n t10 += v * b10;\n t11 += v * b11;\n t12 += v * b12;\n t13 += v * b13;\n t14 += v * b14;\n t15 += v * b15;\n v = a[1];\n t1 += v * b0;\n t2 += v * b1;\n t3 += v * b2;\n t4 += v * b3;\n t5 += v * b4;\n t6 += v * b5;\n t7 += v * b6;\n t8 += v * b7;\n t9 += v * b8;\n t10 += v * b9;\n t11 += v * b10;\n t12 += v * b11;\n t13 += v * b12;\n t14 += v * b13;\n t15 += v * b14;\n t16 += v * b15;\n v = a[2];\n t2 += v * b0;\n t3 += v * b1;\n t4 += v * b2;\n t5 += v * b3;\n t6 += v * b4;\n t7 += v * b5;\n t8 += v * b6;\n t9 += v * b7;\n t10 += v * b8;\n t11 += v * b9;\n t12 += v * b10;\n t13 += v * b11;\n t14 += v * b12;\n t15 += v * b13;\n t16 += v * b14;\n t17 += v * b15;\n v = a[3];\n t3 += v * b0;\n t4 += v * b1;\n t5 += v * b2;\n t6 += v * b3;\n t7 += v * b4;\n t8 += v * b5;\n t9 += v * b6;\n t10 += v * b7;\n t11 += v * b8;\n t12 += v * b9;\n t13 += v * b10;\n t14 += v * b11;\n t15 += v * b12;\n t16 += v * b13;\n t17 += v * b14;\n t18 += v * b15;\n v = a[4];\n t4 += v * b0;\n t5 += v * b1;\n t6 += v * b2;\n t7 += v * b3;\n t8 += v * b4;\n t9 += v * b5;\n t10 += v * b6;\n t11 += v * b7;\n t12 += v * b8;\n t13 += v * b9;\n t14 += v * b10;\n t15 += v * b11;\n t16 += v * b12;\n t17 += v * b13;\n t18 += v * b14;\n t19 += v * b15;\n v = a[5];\n t5 += v * b0;\n t6 += v * b1;\n t7 += v * b2;\n t8 += v * b3;\n t9 += v * b4;\n t10 += v * b5;\n t11 += v * b6;\n t12 += v * b7;\n t13 += v * b8;\n t14 += v * b9;\n t15 += v * b10;\n t16 += v * b11;\n t17 += v * b12;\n t18 += v * b13;\n t19 += v * b14;\n t20 += v * b15;\n v = a[6];\n t6 += v * b0;\n t7 += v * b1;\n t8 += v * b2;\n t9 += v * b3;\n t10 += v * b4;\n t11 += v * b5;\n t12 += v * b6;\n t13 += v * b7;\n t14 += v * b8;\n t15 += v * b9;\n t16 += v * b10;\n t17 += v * b11;\n t18 += v * b12;\n t19 += v * b13;\n t20 += v * b14;\n t21 += v * b15;\n v = a[7];\n t7 += v * b0;\n t8 += v * b1;\n t9 += v * b2;\n t10 += v * b3;\n t11 += v * b4;\n t12 += v * b5;\n t13 += v * b6;\n t14 += v * b7;\n t15 += v * b8;\n t16 += v * b9;\n t17 += v * b10;\n t18 += v * b11;\n t19 += v * b12;\n t20 += v * b13;\n t21 += v * b14;\n t22 += v * b15;\n v = a[8];\n t8 += v * b0;\n t9 += v * b1;\n t10 += v * b2;\n t11 += v * b3;\n t12 += v * b4;\n t13 += v * b5;\n t14 += v * b6;\n t15 += v * b7;\n t16 += v * b8;\n t17 += v * b9;\n t18 += v * b10;\n t19 += v * b11;\n t20 += v * b12;\n t21 += v * b13;\n t22 += v * b14;\n t23 += v * b15;\n v = a[9];\n t9 += v * b0;\n t10 += v * b1;\n t11 += v * b2;\n t12 += v * b3;\n t13 += v * b4;\n t14 += v * b5;\n t15 += v * b6;\n t16 += v * b7;\n t17 += v * b8;\n t18 += v * b9;\n t19 += v * b10;\n t20 += v * b11;\n t21 += v * b12;\n t22 += v * b13;\n t23 += v * b14;\n t24 += v * b15;\n v = a[10];\n t10 += v * b0;\n t11 += v * b1;\n t12 += v * b2;\n t13 += v * b3;\n t14 += v * b4;\n t15 += v * b5;\n t16 += v * b6;\n t17 += v * b7;\n t18 += v * b8;\n t19 += v * b9;\n t20 += v * b10;\n t21 += v * b11;\n t22 += v * b12;\n t23 += v * b13;\n t24 += v * b14;\n t25 += v * b15;\n v = a[11];\n t11 += v * b0;\n t12 += v * b1;\n t13 += v * b2;\n t14 += v * b3;\n t15 += v * b4;\n t16 += v * b5;\n t17 += v * b6;\n t18 += v * b7;\n t19 += v * b8;\n t20 += v * b9;\n t21 += v * b10;\n t22 += v * b11;\n t23 += v * b12;\n t24 += v * b13;\n t25 += v * b14;\n t26 += v * b15;\n v = a[12];\n t12 += v * b0;\n t13 += v * b1;\n t14 += v * b2;\n t15 += v * b3;\n t16 += v * b4;\n t17 += v * b5;\n t18 += v * b6;\n t19 += v * b7;\n t20 += v * b8;\n t21 += v * b9;\n t22 += v * b10;\n t23 += v * b11;\n t24 += v * b12;\n t25 += v * b13;\n t26 += v * b14;\n t27 += v * b15;\n v = a[13];\n t13 += v * b0;\n t14 += v * b1;\n t15 += v * b2;\n t16 += v * b3;\n t17 += v * b4;\n t18 += v * b5;\n t19 += v * b6;\n t20 += v * b7;\n t21 += v * b8;\n t22 += v * b9;\n t23 += v * b10;\n t24 += v * b11;\n t25 += v * b12;\n t26 += v * b13;\n t27 += v * b14;\n t28 += v * b15;\n v = a[14];\n t14 += v * b0;\n t15 += v * b1;\n t16 += v * b2;\n t17 += v * b3;\n t18 += v * b4;\n t19 += v * b5;\n t20 += v * b6;\n t21 += v * b7;\n t22 += v * b8;\n t23 += v * b9;\n t24 += v * b10;\n t25 += v * b11;\n t26 += v * b12;\n t27 += v * b13;\n t28 += v * b14;\n t29 += v * b15;\n v = a[15];\n t15 += v * b0;\n t16 += v * b1;\n t17 += v * b2;\n t18 += v * b3;\n t19 += v * b4;\n t20 += v * b5;\n t21 += v * b6;\n t22 += v * b7;\n t23 += v * b8;\n t24 += v * b9;\n t25 += v * b10;\n t26 += v * b11;\n t27 += v * b12;\n t28 += v * b13;\n t29 += v * b14;\n t30 += v * b15;\n\n t0 += 38 * t16;\n t1 += 38 * t17;\n t2 += 38 * t18;\n t3 += 38 * t19;\n t4 += 38 * t20;\n t5 += 38 * t21;\n t6 += 38 * t22;\n t7 += 38 * t23;\n t8 += 38 * t24;\n t9 += 38 * t25;\n t10 += 38 * t26;\n t11 += 38 * t27;\n t12 += 38 * t28;\n t13 += 38 * t29;\n t14 += 38 * t30;\n // t15 left as is\n\n // first car\n c = 1;\n v = t0 + c + 65535; c = Math.floor(v / 65536); t0 = v - c * 65536;\n v = t1 + c + 65535; c = Math.floor(v / 65536); t1 = v - c * 65536;\n v = t2 + c + 65535; c = Math.floor(v / 65536); t2 = v - c * 65536;\n v = t3 + c + 65535; c = Math.floor(v / 65536); t3 = v - c * 65536;\n v = t4 + c + 65535; c = Math.floor(v / 65536); t4 = v - c * 65536;\n v = t5 + c + 65535; c = Math.floor(v / 65536); t5 = v - c * 65536;\n v = t6 + c + 65535; c = Math.floor(v / 65536); t6 = v - c * 65536;\n v = t7 + c + 65535; c = Math.floor(v / 65536); t7 = v - c * 65536;\n v = t8 + c + 65535; c = Math.floor(v / 65536); t8 = v - c * 65536;\n v = t9 + c + 65535; c = Math.floor(v / 65536); t9 = v - c * 65536;\n v = t10 + c + 65535; c = Math.floor(v / 65536); t10 = v - c * 65536;\n v = t11 + c + 65535; c = Math.floor(v / 65536); t11 = v - c * 65536;\n v = t12 + c + 65535; c = Math.floor(v / 65536); t12 = v - c * 65536;\n v = t13 + c + 65535; c = Math.floor(v / 65536); t13 = v - c * 65536;\n v = t14 + c + 65535; c = Math.floor(v / 65536); t14 = v - c * 65536;\n v = t15 + c + 65535; c = Math.floor(v / 65536); t15 = v - c * 65536;\n t0 += c-1 + 37 * (c-1);\n\n // second car\n c = 1;\n v = t0 + c + 65535; c = Math.floor(v / 65536); t0 = v - c * 65536;\n v = t1 + c + 65535; c = Math.floor(v / 65536); t1 = v - c * 65536;\n v = t2 + c + 65535; c = Math.floor(v / 65536); t2 = v - c * 65536;\n v = t3 + c + 65535; c = Math.floor(v / 65536); t3 = v - c * 65536;\n v = t4 + c + 65535; c = Math.floor(v / 65536); t4 = v - c * 65536;\n v = t5 + c + 65535; c = Math.floor(v / 65536); t5 = v - c * 65536;\n v = t6 + c + 65535; c = Math.floor(v / 65536); t6 = v - c * 65536;\n v = t7 + c + 65535; c = Math.floor(v / 65536); t7 = v - c * 65536;\n v = t8 + c + 65535; c = Math.floor(v / 65536); t8 = v - c * 65536;\n v = t9 + c + 65535; c = Math.floor(v / 65536); t9 = v - c * 65536;\n v = t10 + c + 65535; c = Math.floor(v / 65536); t10 = v - c * 65536;\n v = t11 + c + 65535; c = Math.floor(v / 65536); t11 = v - c * 65536;\n v = t12 + c + 65535; c = Math.floor(v / 65536); t12 = v - c * 65536;\n v = t13 + c + 65535; c = Math.floor(v / 65536); t13 = v - c * 65536;\n v = t14 + c + 65535; c = Math.floor(v / 65536); t14 = v - c * 65536;\n v = t15 + c + 65535; c = Math.floor(v / 65536); t15 = v - c * 65536;\n t0 += c-1 + 37 * (c-1);\n\n o[ 0] = t0;\n o[ 1] = t1;\n o[ 2] = t2;\n o[ 3] = t3;\n o[ 4] = t4;\n o[ 5] = t5;\n o[ 6] = t6;\n o[ 7] = t7;\n o[ 8] = t8;\n o[ 9] = t9;\n o[10] = t10;\n o[11] = t11;\n o[12] = t12;\n o[13] = t13;\n o[14] = t14;\n o[15] = t15;\n}\n\nfunction S(o, a) {\n M(o, a, a);\n}\n\nfunction inv25519(o, i) {\n var c = gf();\n var a;\n for (a = 0; a < 16; a++) c[a] = i[a];\n for (a = 253; a >= 0; a--) {\n S(c, c);\n if(a !== 2 && a !== 4) M(c, c, i);\n }\n for (a = 0; a < 16; a++) o[a] = c[a];\n}\n\nfunction pow2523(o, i) {\n var c = gf();\n var a;\n for (a = 0; a < 16; a++) c[a] = i[a];\n for (a = 250; a >= 0; a--) {\n S(c, c);\n if(a !== 1) M(c, c, i);\n }\n for (a = 0; a < 16; a++) o[a] = c[a];\n}\n\nfunction crypto_scalarmult(q, n, p) {\n var z = new Uint8Array(32);\n var x = new Float64Array(80), r, i;\n var a = gf(), b = gf(), c = gf(),\n d = gf(), e = gf(), f = gf();\n for (i = 0; i < 31; i++) z[i] = n[i];\n z[31]=(n[31]&127)|64;\n z[0]&=248;\n unpack25519(x,p);\n for (i = 0; i < 16; i++) {\n b[i]=x[i];\n d[i]=a[i]=c[i]=0;\n }\n a[0]=d[0]=1;\n for (i=254; i>=0; --i) {\n r=(z[i>>>3]>>>(i&7))&1;\n sel25519(a,b,r);\n sel25519(c,d,r);\n A(e,a,c);\n Z(a,a,c);\n A(c,b,d);\n Z(b,b,d);\n S(d,e);\n S(f,a);\n M(a,c,a);\n M(c,b,e);\n A(e,a,c);\n Z(a,a,c);\n S(b,a);\n Z(c,d,f);\n M(a,c,_121665);\n A(a,a,d);\n M(c,c,a);\n M(a,d,f);\n M(d,b,x);\n S(b,e);\n sel25519(a,b,r);\n sel25519(c,d,r);\n }\n for (i = 0; i < 16; i++) {\n x[i+16]=a[i];\n x[i+32]=c[i];\n x[i+48]=b[i];\n x[i+64]=d[i];\n }\n var x32 = x.subarray(32);\n var x16 = x.subarray(16);\n inv25519(x32,x32);\n M(x16,x16,x32);\n pack25519(q,x16);\n return 0;\n}\n\nfunction crypto_scalarmult_base(q, n) {\n return crypto_scalarmult(q, n, _9);\n}\n\nfunction crypto_box_keypair(y, x) {\n randombytes(x, 32);\n return crypto_scalarmult_base(y, x);\n}\n\nfunction crypto_box_beforenm(k, y, x) {\n var s = new Uint8Array(32);\n crypto_scalarmult(s, x, y);\n return crypto_core_hsalsa20(k, _0, s, sigma);\n}\n\nvar crypto_box_afternm = crypto_secretbox;\nvar crypto_box_open_afternm = crypto_secretbox_open;\n\nfunction crypto_box(c, m, d, n, y, x) {\n var k = new Uint8Array(32);\n crypto_box_beforenm(k, y, x);\n return crypto_box_afternm(c, m, d, n, k);\n}\n\nfunction crypto_box_open(m, c, d, n, y, x) {\n var k = new Uint8Array(32);\n crypto_box_beforenm(k, y, x);\n return crypto_box_open_afternm(m, c, d, n, k);\n}\n\nvar K = [\n 0x428a2f98, 0xd728ae22, 0x71374491, 0x23ef65cd,\n 0xb5c0fbcf, 0xec4d3b2f, 0xe9b5dba5, 0x8189dbbc,\n 0x3956c25b, 0xf348b538, 0x59f111f1, 0xb605d019,\n 0x923f82a4, 0xaf194f9b, 0xab1c5ed5, 0xda6d8118,\n 0xd807aa98, 0xa3030242, 0x12835b01, 0x45706fbe,\n 0x243185be, 0x4ee4b28c, 0x550c7dc3, 0xd5ffb4e2,\n 0x72be5d74, 0xf27b896f, 0x80deb1fe, 0x3b1696b1,\n 0x9bdc06a7, 0x25c71235, 0xc19bf174, 0xcf692694,\n 0xe49b69c1, 0x9ef14ad2, 0xefbe4786, 0x384f25e3,\n 0x0fc19dc6, 0x8b8cd5b5, 0x240ca1cc, 0x77ac9c65,\n 0x2de92c6f, 0x592b0275, 0x4a7484aa, 0x6ea6e483,\n 0x5cb0a9dc, 0xbd41fbd4, 0x76f988da, 0x831153b5,\n 0x983e5152, 0xee66dfab, 0xa831c66d, 0x2db43210,\n 0xb00327c8, 0x98fb213f, 0xbf597fc7, 0xbeef0ee4,\n 0xc6e00bf3, 0x3da88fc2, 0xd5a79147, 0x930aa725,\n 0x06ca6351, 0xe003826f, 0x14292967, 0x0a0e6e70,\n 0x27b70a85, 0x46d22ffc, 0x2e1b2138, 0x5c26c926,\n 0x4d2c6dfc, 0x5ac42aed, 0x53380d13, 0x9d95b3df,\n 0x650a7354, 0x8baf63de, 0x766a0abb, 0x3c77b2a8,\n 0x81c2c92e, 0x47edaee6, 0x92722c85, 0x1482353b,\n 0xa2bfe8a1, 0x4cf10364, 0xa81a664b, 0xbc423001,\n 0xc24b8b70, 0xd0f89791, 0xc76c51a3, 0x0654be30,\n 0xd192e819, 0xd6ef5218, 0xd6990624, 0x5565a910,\n 0xf40e3585, 0x5771202a, 0x106aa070, 0x32bbd1b8,\n 0x19a4c116, 0xb8d2d0c8, 0x1e376c08, 0x5141ab53,\n 0x2748774c, 0xdf8eeb99, 0x34b0bcb5, 0xe19b48a8,\n 0x391c0cb3, 0xc5c95a63, 0x4ed8aa4a, 0xe3418acb,\n 0x5b9cca4f, 0x7763e373, 0x682e6ff3, 0xd6b2b8a3,\n 0x748f82ee, 0x5defb2fc, 0x78a5636f, 0x43172f60,\n 0x84c87814, 0xa1f0ab72, 0x8cc70208, 0x1a6439ec,\n 0x90befffa, 0x23631e28, 0xa4506ceb, 0xde82bde9,\n 0xbef9a3f7, 0xb2c67915, 0xc67178f2, 0xe372532b,\n 0xca273ece, 0xea26619c, 0xd186b8c7, 0x21c0c207,\n 0xeada7dd6, 0xcde0eb1e, 0xf57d4f7f, 0xee6ed178,\n 0x06f067aa, 0x72176fba, 0x0a637dc5, 0xa2c898a6,\n 0x113f9804, 0xbef90dae, 0x1b710b35, 0x131c471b,\n 0x28db77f5, 0x23047d84, 0x32caab7b, 0x40c72493,\n 0x3c9ebe0a, 0x15c9bebc, 0x431d67c4, 0x9c100d4c,\n 0x4cc5d4be, 0xcb3e42b6, 0x597f299c, 0xfc657e2a,\n 0x5fcb6fab, 0x3ad6faec, 0x6c44198c, 0x4a475817\n];\n\nfunction crypto_hashblocks_hl(hh, hl, m, n) {\n var wh = new Int32Array(16), wl = new Int32Array(16),\n bh0, bh1, bh2, bh3, bh4, bh5, bh6, bh7,\n bl0, bl1, bl2, bl3, bl4, bl5, bl6, bl7,\n th, tl, i, j, h, l, a, b, c, d;\n\n var ah0 = hh[0],\n ah1 = hh[1],\n ah2 = hh[2],\n ah3 = hh[3],\n ah4 = hh[4],\n ah5 = hh[5],\n ah6 = hh[6],\n ah7 = hh[7],\n\n al0 = hl[0],\n al1 = hl[1],\n al2 = hl[2],\n al3 = hl[3],\n al4 = hl[4],\n al5 = hl[5],\n al6 = hl[6],\n al7 = hl[7];\n\n var pos = 0;\n while (n >= 128) {\n for (i = 0; i < 16; i++) {\n j = 8 * i + pos;\n wh[i] = (m[j+0] << 24) | (m[j+1] << 16) | (m[j+2] << 8) | m[j+3];\n wl[i] = (m[j+4] << 24) | (m[j+5] << 16) | (m[j+6] << 8) | m[j+7];\n }\n for (i = 0; i < 80; i++) {\n bh0 = ah0;\n bh1 = ah1;\n bh2 = ah2;\n bh3 = ah3;\n bh4 = ah4;\n bh5 = ah5;\n bh6 = ah6;\n bh7 = ah7;\n\n bl0 = al0;\n bl1 = al1;\n bl2 = al2;\n bl3 = al3;\n bl4 = al4;\n bl5 = al5;\n bl6 = al6;\n bl7 = al7;\n\n // add\n h = ah7;\n l = al7;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n // Sigma1\n h = ((ah4 >>> 14) | (al4 << (32-14))) ^ ((ah4 >>> 18) | (al4 << (32-18))) ^ ((al4 >>> (41-32)) | (ah4 << (32-(41-32))));\n l = ((al4 >>> 14) | (ah4 << (32-14))) ^ ((al4 >>> 18) | (ah4 << (32-18))) ^ ((ah4 >>> (41-32)) | (al4 << (32-(41-32))));\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // Ch\n h = (ah4 & ah5) ^ (~ah4 & ah6);\n l = (al4 & al5) ^ (~al4 & al6);\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // K\n h = K[i*2];\n l = K[i*2+1];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // w\n h = wh[i%16];\n l = wl[i%16];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n th = c & 0xffff | d << 16;\n tl = a & 0xffff | b << 16;\n\n // add\n h = th;\n l = tl;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n // Sigma0\n h = ((ah0 >>> 28) | (al0 << (32-28))) ^ ((al0 >>> (34-32)) | (ah0 << (32-(34-32)))) ^ ((al0 >>> (39-32)) | (ah0 << (32-(39-32))));\n l = ((al0 >>> 28) | (ah0 << (32-28))) ^ ((ah0 >>> (34-32)) | (al0 << (32-(34-32)))) ^ ((ah0 >>> (39-32)) | (al0 << (32-(39-32))));\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // Maj\n h = (ah0 & ah1) ^ (ah0 & ah2) ^ (ah1 & ah2);\n l = (al0 & al1) ^ (al0 & al2) ^ (al1 & al2);\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n bh7 = (c & 0xffff) | (d << 16);\n bl7 = (a & 0xffff) | (b << 16);\n\n // add\n h = bh3;\n l = bl3;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = th;\n l = tl;\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n bh3 = (c & 0xffff) | (d << 16);\n bl3 = (a & 0xffff) | (b << 16);\n\n ah1 = bh0;\n ah2 = bh1;\n ah3 = bh2;\n ah4 = bh3;\n ah5 = bh4;\n ah6 = bh5;\n ah7 = bh6;\n ah0 = bh7;\n\n al1 = bl0;\n al2 = bl1;\n al3 = bl2;\n al4 = bl3;\n al5 = bl4;\n al6 = bl5;\n al7 = bl6;\n al0 = bl7;\n\n if (i%16 === 15) {\n for (j = 0; j < 16; j++) {\n // add\n h = wh[j];\n l = wl[j];\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = wh[(j+9)%16];\n l = wl[(j+9)%16];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // sigma0\n th = wh[(j+1)%16];\n tl = wl[(j+1)%16];\n h = ((th >>> 1) | (tl << (32-1))) ^ ((th >>> 8) | (tl << (32-8))) ^ (th >>> 7);\n l = ((tl >>> 1) | (th << (32-1))) ^ ((tl >>> 8) | (th << (32-8))) ^ ((tl >>> 7) | (th << (32-7)));\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // sigma1\n th = wh[(j+14)%16];\n tl = wl[(j+14)%16];\n h = ((th >>> 19) | (tl << (32-19))) ^ ((tl >>> (61-32)) | (th << (32-(61-32)))) ^ (th >>> 6);\n l = ((tl >>> 19) | (th << (32-19))) ^ ((th >>> (61-32)) | (tl << (32-(61-32)))) ^ ((tl >>> 6) | (th << (32-6)));\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n wh[j] = (c & 0xffff) | (d << 16);\n wl[j] = (a & 0xffff) | (b << 16);\n }\n }\n }\n\n // add\n h = ah0;\n l = al0;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[0];\n l = hl[0];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[0] = ah0 = (c & 0xffff) | (d << 16);\n hl[0] = al0 = (a & 0xffff) | (b << 16);\n\n h = ah1;\n l = al1;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[1];\n l = hl[1];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[1] = ah1 = (c & 0xffff) | (d << 16);\n hl[1] = al1 = (a & 0xffff) | (b << 16);\n\n h = ah2;\n l = al2;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[2];\n l = hl[2];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[2] = ah2 = (c & 0xffff) | (d << 16);\n hl[2] = al2 = (a & 0xffff) | (b << 16);\n\n h = ah3;\n l = al3;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[3];\n l = hl[3];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[3] = ah3 = (c & 0xffff) | (d << 16);\n hl[3] = al3 = (a & 0xffff) | (b << 16);\n\n h = ah4;\n l = al4;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[4];\n l = hl[4];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[4] = ah4 = (c & 0xffff) | (d << 16);\n hl[4] = al4 = (a & 0xffff) | (b << 16);\n\n h = ah5;\n l = al5;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[5];\n l = hl[5];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[5] = ah5 = (c & 0xffff) | (d << 16);\n hl[5] = al5 = (a & 0xffff) | (b << 16);\n\n h = ah6;\n l = al6;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[6];\n l = hl[6];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[6] = ah6 = (c & 0xffff) | (d << 16);\n hl[6] = al6 = (a & 0xffff) | (b << 16);\n\n h = ah7;\n l = al7;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[7];\n l = hl[7];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[7] = ah7 = (c & 0xffff) | (d << 16);\n hl[7] = al7 = (a & 0xffff) | (b << 16);\n\n pos += 128;\n n -= 128;\n }\n\n return n;\n}\n\nfunction crypto_hash(out, m, n) {\n var hh = new Int32Array(8),\n hl = new Int32Array(8),\n x = new Uint8Array(256),\n i, b = n;\n\n hh[0] = 0x6a09e667;\n hh[1] = 0xbb67ae85;\n hh[2] = 0x3c6ef372;\n hh[3] = 0xa54ff53a;\n hh[4] = 0x510e527f;\n hh[5] = 0x9b05688c;\n hh[6] = 0x1f83d9ab;\n hh[7] = 0x5be0cd19;\n\n hl[0] = 0xf3bcc908;\n hl[1] = 0x84caa73b;\n hl[2] = 0xfe94f82b;\n hl[3] = 0x5f1d36f1;\n hl[4] = 0xade682d1;\n hl[5] = 0x2b3e6c1f;\n hl[6] = 0xfb41bd6b;\n hl[7] = 0x137e2179;\n\n crypto_hashblocks_hl(hh, hl, m, n);\n n %= 128;\n\n for (i = 0; i < n; i++) x[i] = m[b-n+i];\n x[n] = 128;\n\n n = 256-128*(n<112?1:0);\n x[n-9] = 0;\n ts64(x, n-8, (b / 0x20000000) | 0, b << 3);\n crypto_hashblocks_hl(hh, hl, x, n);\n\n for (i = 0; i < 8; i++) ts64(out, 8*i, hh[i], hl[i]);\n\n return 0;\n}\n\nfunction add(p, q) {\n var a = gf(), b = gf(), c = gf(),\n d = gf(), e = gf(), f = gf(),\n g = gf(), h = gf(), t = gf();\n\n Z(a, p[1], p[0]);\n Z(t, q[1], q[0]);\n M(a, a, t);\n A(b, p[0], p[1]);\n A(t, q[0], q[1]);\n M(b, b, t);\n M(c, p[3], q[3]);\n M(c, c, D2);\n M(d, p[2], q[2]);\n A(d, d, d);\n Z(e, b, a);\n Z(f, d, c);\n A(g, d, c);\n A(h, b, a);\n\n M(p[0], e, f);\n M(p[1], h, g);\n M(p[2], g, f);\n M(p[3], e, h);\n}\n\nfunction cswap(p, q, b) {\n var i;\n for (i = 0; i < 4; i++) {\n sel25519(p[i], q[i], b);\n }\n}\n\nfunction pack(r, p) {\n var tx = gf(), ty = gf(), zi = gf();\n inv25519(zi, p[2]);\n M(tx, p[0], zi);\n M(ty, p[1], zi);\n pack25519(r, ty);\n r[31] ^= par25519(tx) << 7;\n}\n\nfunction scalarmult(p, q, s) {\n var b, i;\n set25519(p[0], gf0);\n set25519(p[1], gf1);\n set25519(p[2], gf1);\n set25519(p[3], gf0);\n for (i = 255; i >= 0; --i) {\n b = (s[(i/8)|0] >> (i&7)) & 1;\n cswap(p, q, b);\n add(q, p);\n add(p, p);\n cswap(p, q, b);\n }\n}\n\nfunction scalarbase(p, s) {\n var q = [gf(), gf(), gf(), gf()];\n set25519(q[0], X);\n set25519(q[1], Y);\n set25519(q[2], gf1);\n M(q[3], X, Y);\n scalarmult(p, q, s);\n}\n\nfunction crypto_sign_keypair(pk, sk, seeded) {\n var d = new Uint8Array(64);\n var p = [gf(), gf(), gf(), gf()];\n var i;\n\n if (!seeded) randombytes(sk, 32);\n crypto_hash(d, sk, 32);\n d[0] &= 248;\n d[31] &= 127;\n d[31] |= 64;\n\n scalarbase(p, d);\n pack(pk, p);\n\n for (i = 0; i < 32; i++) sk[i+32] = pk[i];\n return 0;\n}\n\nvar L = new Float64Array([0xed, 0xd3, 0xf5, 0x5c, 0x1a, 0x63, 0x12, 0x58, 0xd6, 0x9c, 0xf7, 0xa2, 0xde, 0xf9, 0xde, 0x14, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x10]);\n\nfunction modL(r, x) {\n var carry, i, j, k;\n for (i = 63; i >= 32; --i) {\n carry = 0;\n for (j = i - 32, k = i - 12; j < k; ++j) {\n x[j] += carry - 16 * x[i] * L[j - (i - 32)];\n carry = Math.floor((x[j] + 128) / 256);\n x[j] -= carry * 256;\n }\n x[j] += carry;\n x[i] = 0;\n }\n carry = 0;\n for (j = 0; j < 32; j++) {\n x[j] += carry - (x[31] >> 4) * L[j];\n carry = x[j] >> 8;\n x[j] &= 255;\n }\n for (j = 0; j < 32; j++) x[j] -= carry * L[j];\n for (i = 0; i < 32; i++) {\n x[i+1] += x[i] >> 8;\n r[i] = x[i] & 255;\n }\n}\n\nfunction reduce(r) {\n var x = new Float64Array(64), i;\n for (i = 0; i < 64; i++) x[i] = r[i];\n for (i = 0; i < 64; i++) r[i] = 0;\n modL(r, x);\n}\n\n// Note: difference from C - smlen returned, not passed as argument.\nfunction crypto_sign(sm, m, n, sk) {\n var d = new Uint8Array(64), h = new Uint8Array(64), r = new Uint8Array(64);\n var i, j, x = new Float64Array(64);\n var p = [gf(), gf(), gf(), gf()];\n\n crypto_hash(d, sk, 32);\n d[0] &= 248;\n d[31] &= 127;\n d[31] |= 64;\n\n var smlen = n + 64;\n for (i = 0; i < n; i++) sm[64 + i] = m[i];\n for (i = 0; i < 32; i++) sm[32 + i] = d[32 + i];\n\n crypto_hash(r, sm.subarray(32), n+32);\n reduce(r);\n scalarbase(p, r);\n pack(sm, p);\n\n for (i = 32; i < 64; i++) sm[i] = sk[i];\n crypto_hash(h, sm, n + 64);\n reduce(h);\n\n for (i = 0; i < 64; i++) x[i] = 0;\n for (i = 0; i < 32; i++) x[i] = r[i];\n for (i = 0; i < 32; i++) {\n for (j = 0; j < 32; j++) {\n x[i+j] += h[i] * d[j];\n }\n }\n\n modL(sm.subarray(32), x);\n return smlen;\n}\n\nfunction unpackneg(r, p) {\n var t = gf(), chk = gf(), num = gf(),\n den = gf(), den2 = gf(), den4 = gf(),\n den6 = gf();\n\n set25519(r[2], gf1);\n unpack25519(r[1], p);\n S(num, r[1]);\n M(den, num, D);\n Z(num, num, r[2]);\n A(den, r[2], den);\n\n S(den2, den);\n S(den4, den2);\n M(den6, den4, den2);\n M(t, den6, num);\n M(t, t, den);\n\n pow2523(t, t);\n M(t, t, num);\n M(t, t, den);\n M(t, t, den);\n M(r[0], t, den);\n\n S(chk, r[0]);\n M(chk, chk, den);\n if (neq25519(chk, num)) M(r[0], r[0], I);\n\n S(chk, r[0]);\n M(chk, chk, den);\n if (neq25519(chk, num)) return -1;\n\n if (par25519(r[0]) === (p[31]>>7)) Z(r[0], gf0, r[0]);\n\n M(r[3], r[0], r[1]);\n return 0;\n}\n\nfunction crypto_sign_open(m, sm, n, pk) {\n var i;\n var t = new Uint8Array(32), h = new Uint8Array(64);\n var p = [gf(), gf(), gf(), gf()],\n q = [gf(), gf(), gf(), gf()];\n\n if (n < 64) return -1;\n\n if (unpackneg(q, pk)) return -1;\n\n for (i = 0; i < n; i++) m[i] = sm[i];\n for (i = 0; i < 32; i++) m[i+32] = pk[i];\n crypto_hash(h, m, n);\n reduce(h);\n scalarmult(p, q, h);\n\n scalarbase(q, sm.subarray(32));\n add(p, q);\n pack(t, p);\n\n n -= 64;\n if (crypto_verify_32(sm, 0, t, 0)) {\n for (i = 0; i < n; i++) m[i] = 0;\n return -1;\n }\n\n for (i = 0; i < n; i++) m[i] = sm[i + 64];\n return n;\n}\n\nvar crypto_secretbox_KEYBYTES = 32,\n crypto_secretbox_NONCEBYTES = 24,\n crypto_secretbox_ZEROBYTES = 32,\n crypto_secretbox_BOXZEROBYTES = 16,\n crypto_scalarmult_BYTES = 32,\n crypto_scalarmult_SCALARBYTES = 32,\n crypto_box_PUBLICKEYBYTES = 32,\n crypto_box_SECRETKEYBYTES = 32,\n crypto_box_BEFORENMBYTES = 32,\n crypto_box_NONCEBYTES = crypto_secretbox_NONCEBYTES,\n crypto_box_ZEROBYTES = crypto_secretbox_ZEROBYTES,\n crypto_box_BOXZEROBYTES = crypto_secretbox_BOXZEROBYTES,\n crypto_sign_BYTES = 64,\n crypto_sign_PUBLICKEYBYTES = 32,\n crypto_sign_SECRETKEYBYTES = 64,\n crypto_sign_SEEDBYTES = 32,\n crypto_hash_BYTES = 64;\n\nnacl.lowlevel = {\n crypto_core_hsalsa20: crypto_core_hsalsa20,\n crypto_stream_xor: crypto_stream_xor,\n crypto_stream: crypto_stream,\n crypto_stream_salsa20_xor: crypto_stream_salsa20_xor,\n crypto_stream_salsa20: crypto_stream_salsa20,\n crypto_onetimeauth: crypto_onetimeauth,\n crypto_onetimeauth_verify: crypto_onetimeauth_verify,\n crypto_verify_16: crypto_verify_16,\n crypto_verify_32: crypto_verify_32,\n crypto_secretbox: crypto_secretbox,\n crypto_secretbox_open: crypto_secretbox_open,\n crypto_scalarmult: crypto_scalarmult,\n crypto_scalarmult_base: crypto_scalarmult_base,\n crypto_box_beforenm: crypto_box_beforenm,\n crypto_box_afternm: crypto_box_afternm,\n crypto_box: crypto_box,\n crypto_box_open: crypto_box_open,\n crypto_box_keypair: crypto_box_keypair,\n crypto_hash: crypto_hash,\n crypto_sign: crypto_sign,\n crypto_sign_keypair: crypto_sign_keypair,\n crypto_sign_open: crypto_sign_open,\n\n crypto_secretbox_KEYBYTES: crypto_secretbox_KEYBYTES,\n crypto_secretbox_NONCEBYTES: crypto_secretbox_NONCEBYTES,\n crypto_secretbox_ZEROBYTES: crypto_secretbox_ZEROBYTES,\n crypto_secretbox_BOXZEROBYTES: crypto_secretbox_BOXZEROBYTES,\n crypto_scalarmult_BYTES: crypto_scalarmult_BYTES,\n crypto_scalarmult_SCALARBYTES: crypto_scalarmult_SCALARBYTES,\n crypto_box_PUBLICKEYBYTES: crypto_box_PUBLICKEYBYTES,\n crypto_box_SECRETKEYBYTES: crypto_box_SECRETKEYBYTES,\n crypto_box_BEFORENMBYTES: crypto_box_BEFORENMBYTES,\n crypto_box_NONCEBYTES: crypto_box_NONCEBYTES,\n crypto_box_ZEROBYTES: crypto_box_ZEROBYTES,\n crypto_box_BOXZEROBYTES: crypto_box_BOXZEROBYTES,\n crypto_sign_BYTES: crypto_sign_BYTES,\n crypto_sign_PUBLICKEYBYTES: crypto_sign_PUBLICKEYBYTES,\n crypto_sign_SECRETKEYBYTES: crypto_sign_SECRETKEYBYTES,\n crypto_sign_SEEDBYTES: crypto_sign_SEEDBYTES,\n crypto_hash_BYTES: crypto_hash_BYTES,\n\n gf: gf,\n D: D,\n L: L,\n pack25519: pack25519,\n unpack25519: unpack25519,\n M: M,\n A: A,\n S: S,\n Z: Z,\n pow2523: pow2523,\n add: add,\n set25519: set25519,\n modL: modL,\n scalarmult: scalarmult,\n scalarbase: scalarbase,\n};\n\n/* High-level API */\n\nfunction checkLengths(k, n) {\n if (k.length !== crypto_secretbox_KEYBYTES) throw new Error('bad key size');\n if (n.length !== crypto_secretbox_NONCEBYTES) throw new Error('bad nonce size');\n}\n\nfunction checkBoxLengths(pk, sk) {\n if (pk.length !== crypto_box_PUBLICKEYBYTES) throw new Error('bad public key size');\n if (sk.length !== crypto_box_SECRETKEYBYTES) throw new Error('bad secret key size');\n}\n\nfunction checkArrayTypes() {\n for (var i = 0; i < arguments.length; i++) {\n if (!(arguments[i] instanceof Uint8Array))\n throw new TypeError('unexpected type, use Uint8Array');\n }\n}\n\nfunction cleanup(arr) {\n for (var i = 0; i < arr.length; i++) arr[i] = 0;\n}\n\nnacl.randomBytes = function(n) {\n var b = new Uint8Array(n);\n randombytes(b, n);\n return b;\n};\n\nnacl.secretbox = function(msg, nonce, key) {\n checkArrayTypes(msg, nonce, key);\n checkLengths(key, nonce);\n var m = new Uint8Array(crypto_secretbox_ZEROBYTES + msg.length);\n var c = new Uint8Array(m.length);\n for (var i = 0; i < msg.length; i++) m[i+crypto_secretbox_ZEROBYTES] = msg[i];\n crypto_secretbox(c, m, m.length, nonce, key);\n return c.subarray(crypto_secretbox_BOXZEROBYTES);\n};\n\nnacl.secretbox.open = function(box, nonce, key) {\n checkArrayTypes(box, nonce, key);\n checkLengths(key, nonce);\n var c = new Uint8Array(crypto_secretbox_BOXZEROBYTES + box.length);\n var m = new Uint8Array(c.length);\n for (var i = 0; i < box.length; i++) c[i+crypto_secretbox_BOXZEROBYTES] = box[i];\n if (c.length < 32) return null;\n if (crypto_secretbox_open(m, c, c.length, nonce, key) !== 0) return null;\n return m.subarray(crypto_secretbox_ZEROBYTES);\n};\n\nnacl.secretbox.keyLength = crypto_secretbox_KEYBYTES;\nnacl.secretbox.nonceLength = crypto_secretbox_NONCEBYTES;\nnacl.secretbox.overheadLength = crypto_secretbox_BOXZEROBYTES;\n\nnacl.scalarMult = function(n, p) {\n checkArrayTypes(n, p);\n if (n.length !== crypto_scalarmult_SCALARBYTES) throw new Error('bad n size');\n if (p.length !== crypto_scalarmult_BYTES) throw new Error('bad p size');\n var q = new Uint8Array(crypto_scalarmult_BYTES);\n crypto_scalarmult(q, n, p);\n return q;\n};\n\nnacl.scalarMult.base = function(n) {\n checkArrayTypes(n);\n if (n.length !== crypto_scalarmult_SCALARBYTES) throw new Error('bad n size');\n var q = new Uint8Array(crypto_scalarmult_BYTES);\n crypto_scalarmult_base(q, n);\n return q;\n};\n\nnacl.scalarMult.scalarLength = crypto_scalarmult_SCALARBYTES;\nnacl.scalarMult.groupElementLength = crypto_scalarmult_BYTES;\n\nnacl.box = function(msg, nonce, publicKey, secretKey) {\n var k = nacl.box.before(publicKey, secretKey);\n return nacl.secretbox(msg, nonce, k);\n};\n\nnacl.box.before = function(publicKey, secretKey) {\n checkArrayTypes(publicKey, secretKey);\n checkBoxLengths(publicKey, secretKey);\n var k = new Uint8Array(crypto_box_BEFORENMBYTES);\n crypto_box_beforenm(k, publicKey, secretKey);\n return k;\n};\n\nnacl.box.after = nacl.secretbox;\n\nnacl.box.open = function(msg, nonce, publicKey, secretKey) {\n var k = nacl.box.before(publicKey, secretKey);\n return nacl.secretbox.open(msg, nonce, k);\n};\n\nnacl.box.open.after = nacl.secretbox.open;\n\nnacl.box.keyPair = function() {\n var pk = new Uint8Array(crypto_box_PUBLICKEYBYTES);\n var sk = new Uint8Array(crypto_box_SECRETKEYBYTES);\n crypto_box_keypair(pk, sk);\n return {publicKey: pk, secretKey: sk};\n};\n\nnacl.box.keyPair.fromSecretKey = function(secretKey) {\n checkArrayTypes(secretKey);\n if (secretKey.length !== crypto_box_SECRETKEYBYTES)\n throw new Error('bad secret key size');\n var pk = new Uint8Array(crypto_box_PUBLICKEYBYTES);\n crypto_scalarmult_base(pk, secretKey);\n return {publicKey: pk, secretKey: new Uint8Array(secretKey)};\n};\n\nnacl.box.publicKeyLength = crypto_box_PUBLICKEYBYTES;\nnacl.box.secretKeyLength = crypto_box_SECRETKEYBYTES;\nnacl.box.sharedKeyLength = crypto_box_BEFORENMBYTES;\nnacl.box.nonceLength = crypto_box_NONCEBYTES;\nnacl.box.overheadLength = nacl.secretbox.overheadLength;\n\nnacl.sign = function(msg, secretKey) {\n checkArrayTypes(msg, secretKey);\n if (secretKey.length !== crypto_sign_SECRETKEYBYTES)\n throw new Error('bad secret key size');\n var signedMsg = new Uint8Array(crypto_sign_BYTES+msg.length);\n crypto_sign(signedMsg, msg, msg.length, secretKey);\n return signedMsg;\n};\n\nnacl.sign.open = function(signedMsg, publicKey) {\n checkArrayTypes(signedMsg, publicKey);\n if (publicKey.length !== crypto_sign_PUBLICKEYBYTES)\n throw new Error('bad public key size');\n var tmp = new Uint8Array(signedMsg.length);\n var mlen = crypto_sign_open(tmp, signedMsg, signedMsg.length, publicKey);\n if (mlen < 0) return null;\n var m = new Uint8Array(mlen);\n for (var i = 0; i < m.length; i++) m[i] = tmp[i];\n return m;\n};\n\nnacl.sign.detached = function(msg, secretKey) {\n var signedMsg = nacl.sign(msg, secretKey);\n var sig = new Uint8Array(crypto_sign_BYTES);\n for (var i = 0; i < sig.length; i++) sig[i] = signedMsg[i];\n return sig;\n};\n\nnacl.sign.detached.verify = function(msg, sig, publicKey) {\n checkArrayTypes(msg, sig, publicKey);\n if (sig.length !== crypto_sign_BYTES)\n throw new Error('bad signature size');\n if (publicKey.length !== crypto_sign_PUBLICKEYBYTES)\n throw new Error('bad public key size');\n var sm = new Uint8Array(crypto_sign_BYTES + msg.length);\n var m = new Uint8Array(crypto_sign_BYTES + msg.length);\n var i;\n for (i = 0; i < crypto_sign_BYTES; i++) sm[i] = sig[i];\n for (i = 0; i < msg.length; i++) sm[i+crypto_sign_BYTES] = msg[i];\n return (crypto_sign_open(m, sm, sm.length, publicKey) >= 0);\n};\n\nnacl.sign.keyPair = function() {\n var pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);\n var sk = new Uint8Array(crypto_sign_SECRETKEYBYTES);\n crypto_sign_keypair(pk, sk);\n return {publicKey: pk, secretKey: sk};\n};\n\nnacl.sign.keyPair.fromSecretKey = function(secretKey) {\n checkArrayTypes(secretKey);\n if (secretKey.length !== crypto_sign_SECRETKEYBYTES)\n throw new Error('bad secret key size');\n var pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);\n for (var i = 0; i < pk.length; i++) pk[i] = secretKey[32+i];\n return {publicKey: pk, secretKey: new Uint8Array(secretKey)};\n};\n\nnacl.sign.keyPair.fromSeed = function(seed) {\n checkArrayTypes(seed);\n if (seed.length !== crypto_sign_SEEDBYTES)\n throw new Error('bad seed size');\n var pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);\n var sk = new Uint8Array(crypto_sign_SECRETKEYBYTES);\n for (var i = 0; i < 32; i++) sk[i] = seed[i];\n crypto_sign_keypair(pk, sk, true);\n return {publicKey: pk, secretKey: sk};\n};\n\nnacl.sign.publicKeyLength = crypto_sign_PUBLICKEYBYTES;\nnacl.sign.secretKeyLength = crypto_sign_SECRETKEYBYTES;\nnacl.sign.seedLength = crypto_sign_SEEDBYTES;\nnacl.sign.signatureLength = crypto_sign_BYTES;\n\nnacl.hash = function(msg) {\n checkArrayTypes(msg);\n var h = new Uint8Array(crypto_hash_BYTES);\n crypto_hash(h, msg, msg.length);\n return h;\n};\n\nnacl.hash.hashLength = crypto_hash_BYTES;\n\nnacl.verify = function(x, y) {\n checkArrayTypes(x, y);\n // Zero length arguments are considered not equal.\n if (x.length === 0 || y.length === 0) return false;\n if (x.length !== y.length) return false;\n return (vn(x, 0, y, 0, x.length) === 0) ? true : false;\n};\n\nnacl.setPRNG = function(fn) {\n randombytes = fn;\n};\n\n(function() {\n // Initialize PRNG if environment provides CSPRNG.\n // If not, methods calling randombytes will throw.\n var crypto = typeof self !== 'undefined' ? (self.crypto || self.msCrypto) : null;\n if (crypto && crypto.getRandomValues) {\n // Browsers.\n var QUOTA = 65536;\n nacl.setPRNG(function(x, n) {\n var i, v = new Uint8Array(n);\n for (i = 0; i < n; i += QUOTA) {\n crypto.getRandomValues(v.subarray(i, i + Math.min(n - i, QUOTA)));\n }\n for (i = 0; i < n; i++) x[i] = v[i];\n cleanup(v);\n });\n } else if (typeof require !== 'undefined') {\n // Node.js.\n crypto = require('crypto');\n if (crypto && crypto.randomBytes) {\n nacl.setPRNG(function(x, n) {\n var i, v = crypto.randomBytes(n);\n for (i = 0; i < n; i++) x[i] = v[i];\n cleanup(v);\n });\n }\n }\n})();\n\n})(typeof module !== 'undefined' && module.exports ? module.exports : (self.nacl = self.nacl || {}));\n","module.exports = require('./pusher-with-encryption').default;\n","/* (ignored) */","export default function encode(s: any): string {\n return btoa(utob(s));\n}\n\nvar fromCharCode = String.fromCharCode;\n\nvar b64chars =\n 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';\nvar b64tab = {};\n\nfor (var i = 0, l = b64chars.length; i < l; i++) {\n b64tab[b64chars.charAt(i)] = i;\n}\n\nvar cb_utob = function(c) {\n var cc = c.charCodeAt(0);\n return cc < 0x80\n ? c\n : cc < 0x800\n ? fromCharCode(0xc0 | (cc >>> 6)) + fromCharCode(0x80 | (cc & 0x3f))\n : fromCharCode(0xe0 | ((cc >>> 12) & 0x0f)) +\n fromCharCode(0x80 | ((cc >>> 6) & 0x3f)) +\n fromCharCode(0x80 | (cc & 0x3f));\n};\n\nvar utob = function(u) {\n return u.replace(/[^\\x00-\\x7F]/g, cb_utob);\n};\n\nvar cb_encode = function(ccc) {\n var padlen = [0, 2, 1][ccc.length % 3];\n var ord =\n (ccc.charCodeAt(0) << 16) |\n ((ccc.length > 1 ? ccc.charCodeAt(1) : 0) << 8) |\n (ccc.length > 2 ? ccc.charCodeAt(2) : 0);\n var chars = [\n b64chars.charAt(ord >>> 18),\n b64chars.charAt((ord >>> 12) & 63),\n padlen >= 2 ? '=' : b64chars.charAt((ord >>> 6) & 63),\n padlen >= 1 ? '=' : b64chars.charAt(ord & 63)\n ];\n return chars.join('');\n};\n\nvar btoa =\n global.btoa ||\n function(b) {\n return b.replace(/[\\s\\S]{1,3}/g, cb_encode);\n };\n","import TimedCallback from './timed_callback';\nimport { Delay, Scheduler, Canceller } from './scheduling';\n\nabstract class Timer {\n protected clear: Canceller;\n protected timer: number | void;\n\n constructor(\n set: Scheduler,\n clear: Canceller,\n delay: Delay,\n callback: TimedCallback\n ) {\n this.clear = clear;\n this.timer = set(() => {\n if (this.timer) {\n this.timer = callback(this.timer);\n }\n }, delay);\n }\n\n /** Returns whether the timer is still running.\n *\n * @return {Boolean}\n */\n isRunning(): boolean {\n return this.timer !== null;\n }\n\n /** Aborts a timer when it's running. */\n ensureAborted() {\n if (this.timer) {\n this.clear(this.timer);\n this.timer = null;\n }\n }\n}\n\nexport default Timer;\n","import Timer from './abstract_timer';\nimport TimedCallback from './timed_callback';\nimport { Delay } from './scheduling';\n\n// We need to bind clear functions this way to avoid exceptions on IE8\nfunction clearTimeout(timer) {\n global.clearTimeout(timer);\n}\nfunction clearInterval(timer) {\n global.clearInterval(timer);\n}\n\n/** Cross-browser compatible one-off timer abstraction.\n *\n * @param {Number} delay\n * @param {Function} callback\n */\nexport class OneOffTimer extends Timer {\n constructor(delay: Delay, callback: TimedCallback) {\n super(setTimeout, clearTimeout, delay, function(timer) {\n callback();\n return null;\n });\n }\n}\n\n/** Cross-browser compatible periodic timer abstraction.\n *\n * @param {Number} delay\n * @param {Function} callback\n */\nexport class PeriodicTimer extends Timer {\n constructor(delay: Delay, callback: TimedCallback) {\n super(setInterval, clearInterval, delay, function(timer) {\n callback();\n return timer;\n });\n }\n}\n","import * as Collections from './utils/collections';\nimport TimedCallback from './utils/timers/timed_callback';\nimport { OneOffTimer, PeriodicTimer } from './utils/timers';\n\nvar Util = {\n now(): number {\n if (Date.now) {\n return Date.now();\n } else {\n return new Date().valueOf();\n }\n },\n\n defer(callback: TimedCallback): OneOffTimer {\n return new OneOffTimer(0, callback);\n },\n\n /** Builds a function that will proxy a method call to its first argument.\n *\n * Allows partial application of arguments, so additional arguments are\n * prepended to the argument list.\n *\n * @param {String} name method name\n * @return {Function} proxy function\n */\n method(name: string, ...args: any[]): Function {\n var boundArguments = Array.prototype.slice.call(arguments, 1);\n return function(object) {\n return object[name].apply(object, boundArguments.concat(arguments));\n };\n }\n};\n\nexport default Util;\n","import base64encode from '../base64';\nimport Util from '../util';\n\n/** Merges multiple objects into the target argument.\n *\n * For properties that are plain Objects, performs a deep-merge. For the\n * rest it just copies the value of the property.\n *\n * To extend prototypes use it as following:\n * Pusher.Util.extend(Target.prototype, Base.prototype)\n *\n * You can also use it to merge objects without altering them:\n * Pusher.Util.extend({}, object1, object2)\n *\n * @param {Object} target\n * @return {Object} the target argument\n */\nexport function extend(target: any, ...sources: any[]): T {\n for (var i = 0; i < sources.length; i++) {\n var extensions = sources[i];\n for (var property in extensions) {\n if (\n extensions[property] &&\n extensions[property].constructor &&\n extensions[property].constructor === Object\n ) {\n target[property] = extend(target[property] || {}, extensions[property]);\n } else {\n target[property] = extensions[property];\n }\n }\n }\n return target;\n}\n\nexport function stringify(): string {\n var m = ['Pusher'];\n for (var i = 0; i < arguments.length; i++) {\n if (typeof arguments[i] === 'string') {\n m.push(arguments[i]);\n } else {\n m.push(safeJSONStringify(arguments[i]));\n }\n }\n return m.join(' : ');\n}\n\nexport function arrayIndexOf(array: any[], item: any): number {\n // MSIE doesn't have array.indexOf\n var nativeIndexOf = Array.prototype.indexOf;\n if (array === null) {\n return -1;\n }\n if (nativeIndexOf && array.indexOf === nativeIndexOf) {\n return array.indexOf(item);\n }\n for (var i = 0, l = array.length; i < l; i++) {\n if (array[i] === item) {\n return i;\n }\n }\n return -1;\n}\n\n/** Applies a function f to all properties of an object.\n *\n * Function f gets 3 arguments passed:\n * - element from the object\n * - key of the element\n * - reference to the object\n *\n * @param {Object} object\n * @param {Function} f\n */\nexport function objectApply(object: any, f: Function) {\n for (var key in object) {\n if (Object.prototype.hasOwnProperty.call(object, key)) {\n f(object[key], key, object);\n }\n }\n}\n\n/** Return a list of objects own proerty keys\n *\n * @param {Object} object\n * @returns {Array}\n */\nexport function keys(object: any): string[] {\n var keys = [];\n objectApply(object, function(_, key) {\n keys.push(key);\n });\n return keys;\n}\n\n/** Return a list of object's own property values\n *\n * @param {Object} object\n * @returns {Array}\n */\nexport function values(object: any): any[] {\n var values = [];\n objectApply(object, function(value) {\n values.push(value);\n });\n return values;\n}\n\n/** Applies a function f to all elements of an array.\n *\n * Function f gets 3 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function apply(array: any[], f: Function, context?: any) {\n for (var i = 0; i < array.length; i++) {\n f.call(context || global, array[i], i, array);\n }\n}\n\n/** Maps all elements of the array and returns the result.\n *\n * Function f gets 4 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n * - reference to the destination array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function map(array: any[], f: Function): any[] {\n var result = [];\n for (var i = 0; i < array.length; i++) {\n result.push(f(array[i], i, array, result));\n }\n return result;\n}\n\n/** Maps all elements of the object and returns the result.\n *\n * Function f gets 4 arguments passed:\n * - element from the object\n * - key of the element\n * - reference to the source object\n * - reference to the destination object\n *\n * @param {Object} object\n * @param {Function} f\n */\nexport function mapObject(object: any, f: Function): any {\n var result = {};\n objectApply(object, function(value, key) {\n result[key] = f(value);\n });\n return result;\n}\n\n/** Filters elements of the array using a test function.\n *\n * Function test gets 4 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n * - reference to the destination array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function filter(array: any[], test: Function): any[] {\n test =\n test ||\n function(value) {\n return !!value;\n };\n\n var result = [];\n for (var i = 0; i < array.length; i++) {\n if (test(array[i], i, array, result)) {\n result.push(array[i]);\n }\n }\n return result;\n}\n\n/** Filters properties of the object using a test function.\n *\n * Function test gets 4 arguments passed:\n * - element from the object\n * - key of the element\n * - reference to the source object\n * - reference to the destination object\n *\n * @param {Object} object\n * @param {Function} f\n */\nexport function filterObject(object: Object, test: Function) {\n var result = {};\n objectApply(object, function(value, key) {\n if ((test && test(value, key, object, result)) || Boolean(value)) {\n result[key] = value;\n }\n });\n return result;\n}\n\n/** Flattens an object into a two-dimensional array.\n *\n * @param {Object} object\n * @return {Array} resulting array of [key, value] pairs\n */\nexport function flatten(object: Object): any[] {\n var result = [];\n objectApply(object, function(value, key) {\n result.push([key, value]);\n });\n return result;\n}\n\n/** Checks whether any element of the array passes the test.\n *\n * Function test gets 3 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function any(array: any[], test: Function): boolean {\n for (var i = 0; i < array.length; i++) {\n if (test(array[i], i, array)) {\n return true;\n }\n }\n return false;\n}\n\n/** Checks whether all elements of the array pass the test.\n *\n * Function test gets 3 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function all(array: any[], test: Function): boolean {\n for (var i = 0; i < array.length; i++) {\n if (!test(array[i], i, array)) {\n return false;\n }\n }\n return true;\n}\n\nexport function encodeParamsObject(data): string {\n return mapObject(data, function(value) {\n if (typeof value === 'object') {\n value = safeJSONStringify(value);\n }\n return encodeURIComponent(base64encode(value.toString()));\n });\n}\n\nexport function buildQueryString(data: any): string {\n var params = filterObject(data, function(value) {\n return value !== undefined;\n });\n\n var query = map(\n flatten(encodeParamsObject(params)),\n Util.method('join', '=')\n ).join('&');\n\n return query;\n}\n\n/**\n * See https://github.com/douglascrockford/JSON-js/blob/master/cycle.js\n *\n * Remove circular references from an object. Required for JSON.stringify in\n * React Native, which tends to blow up a lot.\n *\n * @param {any} object\n * @return {any} Decycled object\n */\nexport function decycleObject(object: any): any {\n var objects = [],\n paths = [];\n\n return (function derez(value, path) {\n var i, name, nu;\n\n switch (typeof value) {\n case 'object':\n if (!value) {\n return null;\n }\n for (i = 0; i < objects.length; i += 1) {\n if (objects[i] === value) {\n return { $ref: paths[i] };\n }\n }\n\n objects.push(value);\n paths.push(path);\n\n if (Object.prototype.toString.apply(value) === '[object Array]') {\n nu = [];\n for (i = 0; i < value.length; i += 1) {\n nu[i] = derez(value[i], path + '[' + i + ']');\n }\n } else {\n nu = {};\n for (name in value) {\n if (Object.prototype.hasOwnProperty.call(value, name)) {\n nu[name] = derez(\n value[name],\n path + '[' + JSON.stringify(name) + ']'\n );\n }\n }\n }\n return nu;\n case 'number':\n case 'string':\n case 'boolean':\n return value;\n }\n })(object, '$');\n}\n\n/**\n * Provides a cross-browser and cross-platform way to safely stringify objects\n * into JSON. This is particularly necessary for ReactNative, where circular JSON\n * structures throw an exception.\n *\n * @param {any} source The object to stringify\n * @return {string} The serialized output.\n */\nexport function safeJSONStringify(source: any): string {\n try {\n return JSON.stringify(source);\n } catch (e) {\n return JSON.stringify(decycleObject(source));\n }\n}\n","import {\n ChannelAuthorizationOptions,\n UserAuthenticationOptions\n} from './auth/options';\nimport { AuthTransport } from './config';\n\nexport interface DefaultConfig {\n VERSION: string;\n PROTOCOL: number;\n wsPort: number;\n wssPort: number;\n wsPath: string;\n httpHost: string;\n httpPort: number;\n httpsPort: number;\n httpPath: string;\n stats_host: string;\n authEndpoint: string;\n authTransport: AuthTransport;\n activityTimeout: number;\n pongTimeout: number;\n unavailableTimeout: number;\n userAuthentication: UserAuthenticationOptions;\n channelAuthorization: ChannelAuthorizationOptions;\n\n cdn_http?: string;\n cdn_https?: string;\n dependency_suffix?: string;\n}\n\nvar Defaults: DefaultConfig = {\n VERSION: VERSION,\n PROTOCOL: 7,\n\n wsPort: 80,\n wssPort: 443,\n wsPath: '',\n // DEPRECATED: SockJS fallback parameters\n httpHost: 'sockjs.pusher.com',\n httpPort: 80,\n httpsPort: 443,\n httpPath: '/pusher',\n // DEPRECATED: Stats\n stats_host: 'stats.pusher.com',\n // DEPRECATED: Other settings\n authEndpoint: '/pusher/auth',\n authTransport: 'ajax',\n activityTimeout: 120000,\n pongTimeout: 30000,\n unavailableTimeout: 10000,\n userAuthentication: {\n endpoint: '/pusher/user-auth',\n transport: 'ajax'\n },\n channelAuthorization: {\n endpoint: '/pusher/auth',\n transport: 'ajax'\n },\n\n // CDN configuration\n cdn_http: CDN_HTTP,\n cdn_https: CDN_HTTPS,\n dependency_suffix: DEPENDENCY_SUFFIX\n};\n\nexport default Defaults;\n","import Defaults from '../defaults';\nimport { default as URLScheme, URLSchemeParams } from './url_scheme';\n\nfunction getGenericURL(\n baseScheme: string,\n params: URLSchemeParams,\n path: string\n): string {\n var scheme = baseScheme + (params.useTLS ? 's' : '');\n var host = params.useTLS ? params.hostTLS : params.hostNonTLS;\n return scheme + '://' + host + path;\n}\n\nfunction getGenericPath(key: string, queryString?: string): string {\n var path = '/app/' + key;\n var query =\n '?protocol=' +\n Defaults.PROTOCOL +\n '&client=js' +\n '&version=' +\n Defaults.VERSION +\n (queryString ? '&' + queryString : '');\n return path + query;\n}\n\nexport var ws: URLScheme = {\n getInitial: function(key: string, params: URLSchemeParams): string {\n var path = (params.httpPath || '') + getGenericPath(key, 'flash=false');\n return getGenericURL('ws', params, path);\n }\n};\n\nexport var http: URLScheme = {\n getInitial: function(key: string, params: URLSchemeParams): string {\n var path = (params.httpPath || '/pusher') + getGenericPath(key);\n return getGenericURL('http', params, path);\n }\n};\n\nexport var sockjs: URLScheme = {\n getInitial: function(key: string, params: URLSchemeParams): string {\n return getGenericURL('http', params, params.httpPath || '/pusher');\n },\n getPath: function(key: string, params: URLSchemeParams): string {\n return getGenericPath(key);\n }\n};\n","import Callback from './callback';\nimport * as Collections from '../utils/collections';\nimport CallbackTable from './callback_table';\n\nexport default class CallbackRegistry {\n _callbacks: CallbackTable;\n\n constructor() {\n this._callbacks = {};\n }\n\n get(name: string): Callback[] {\n return this._callbacks[prefix(name)];\n }\n\n add(name: string, callback: Function, context: any) {\n var prefixedEventName = prefix(name);\n this._callbacks[prefixedEventName] =\n this._callbacks[prefixedEventName] || [];\n this._callbacks[prefixedEventName].push({\n fn: callback,\n context: context\n });\n }\n\n remove(name?: string, callback?: Function, context?: any) {\n if (!name && !callback && !context) {\n this._callbacks = {};\n return;\n }\n\n var names = name ? [prefix(name)] : Collections.keys(this._callbacks);\n\n if (callback || context) {\n this.removeCallback(names, callback, context);\n } else {\n this.removeAllCallbacks(names);\n }\n }\n\n private removeCallback(names: string[], callback: Function, context: any) {\n Collections.apply(\n names,\n function(name) {\n this._callbacks[name] = Collections.filter(\n this._callbacks[name] || [],\n function(binding) {\n return (\n (callback && callback !== binding.fn) ||\n (context && context !== binding.context)\n );\n }\n );\n if (this._callbacks[name].length === 0) {\n delete this._callbacks[name];\n }\n },\n this\n );\n }\n\n private removeAllCallbacks(names: string[]) {\n Collections.apply(\n names,\n function(name) {\n delete this._callbacks[name];\n },\n this\n );\n }\n}\n\nfunction prefix(name: string): string {\n return '_' + name;\n}\n","import * as Collections from '../utils/collections';\nimport Callback from './callback';\nimport Metadata from '../channels/metadata';\nimport CallbackRegistry from './callback_registry';\n\n/** Manages callback bindings and event emitting.\n *\n * @param Function failThrough called when no listeners are bound to an event\n */\nexport default class Dispatcher {\n callbacks: CallbackRegistry;\n global_callbacks: Function[];\n failThrough: Function;\n\n constructor(failThrough?: Function) {\n this.callbacks = new CallbackRegistry();\n this.global_callbacks = [];\n this.failThrough = failThrough;\n }\n\n bind(eventName: string, callback: Function, context?: any) {\n this.callbacks.add(eventName, callback, context);\n return this;\n }\n\n bind_global(callback: Function) {\n this.global_callbacks.push(callback);\n return this;\n }\n\n unbind(eventName?: string, callback?: Function, context?: any) {\n this.callbacks.remove(eventName, callback, context);\n return this;\n }\n\n unbind_global(callback?: Function) {\n if (!callback) {\n this.global_callbacks = [];\n return this;\n }\n\n this.global_callbacks = Collections.filter(\n this.global_callbacks || [],\n c => c !== callback\n );\n\n return this;\n }\n\n unbind_all() {\n this.unbind();\n this.unbind_global();\n return this;\n }\n\n emit(eventName: string, data?: any, metadata?: Metadata): Dispatcher {\n for (var i = 0; i < this.global_callbacks.length; i++) {\n this.global_callbacks[i](eventName, data);\n }\n\n var callbacks = this.callbacks.get(eventName);\n var args = [];\n\n if (metadata) {\n // if there's a metadata argument, we need to call the callback with both\n // data and metadata regardless of whether data is undefined\n args.push(data, metadata);\n } else if (data) {\n // metadata is undefined, so we only need to call the callback with data\n // if data exists\n args.push(data);\n }\n\n if (callbacks && callbacks.length > 0) {\n for (var i = 0; i < callbacks.length; i++) {\n callbacks[i].fn.apply(callbacks[i].context || global, args);\n }\n } else if (this.failThrough) {\n this.failThrough(eventName, data);\n }\n\n return this;\n }\n}\n","import { stringify } from './utils/collections';\nimport Pusher from './pusher';\n\nclass Logger {\n debug(...args: any[]) {\n this.log(this.globalLog, args);\n }\n\n warn(...args: any[]) {\n this.log(this.globalLogWarn, args);\n }\n\n error(...args: any[]) {\n this.log(this.globalLogError, args);\n }\n\n private globalLog = (message: string) => {\n if (global.console && global.console.log) {\n global.console.log(message);\n }\n };\n\n private globalLogWarn(message: string) {\n if (global.console && global.console.warn) {\n global.console.warn(message);\n } else {\n this.globalLog(message);\n }\n }\n\n private globalLogError(message: string) {\n if (global.console && global.console.error) {\n global.console.error(message);\n } else {\n this.globalLogWarn(message);\n }\n }\n\n private log(\n defaultLoggingFunction: (message: string) => void,\n ...args: any[]\n ) {\n var message = stringify.apply(this, arguments);\n if (Pusher.log) {\n Pusher.log(message);\n } else if (Pusher.logToConsole) {\n const log = defaultLoggingFunction.bind(this);\n log(message);\n }\n }\n}\n\nexport default new Logger();\n","import Util from '../util';\nimport * as Collections from '../utils/collections';\nimport { default as EventsDispatcher } from '../events/dispatcher';\nimport Logger from '../logger';\nimport TransportHooks from './transport_hooks';\nimport Socket from '../socket';\nimport Runtime from 'runtime';\nimport Timeline from '../timeline/timeline';\nimport TransportConnectionOptions from './transport_connection_options';\n\n/** Provides universal API for transport connections.\n *\n * Transport connection is a low-level object that wraps a connection method\n * and exposes a simple evented interface for the connection state and\n * messaging. It does not implement Pusher-specific WebSocket protocol.\n *\n * Additionally, it fetches resources needed for transport to work and exposes\n * an interface for querying transport features.\n *\n * States:\n * - new - initial state after constructing the object\n * - initializing - during initialization phase, usually fetching resources\n * - intialized - ready to establish a connection\n * - connection - when connection is being established\n * - open - when connection ready to be used\n * - closed - after connection was closed be either side\n *\n * Emits:\n * - error - after the connection raised an error\n *\n * Options:\n * - useTLS - whether connection should be over TLS\n * - hostTLS - host to connect to when connection is over TLS\n * - hostNonTLS - host to connect to when connection is over TLS\n *\n * @param {String} key application key\n * @param {Object} options\n */\nexport default class TransportConnection extends EventsDispatcher {\n hooks: TransportHooks;\n name: string;\n priority: number;\n key: string;\n options: TransportConnectionOptions;\n state: string;\n timeline: Timeline;\n activityTimeout: number;\n id: number;\n socket: Socket;\n beforeOpen: Function;\n initialize: Function;\n\n constructor(\n hooks: TransportHooks,\n name: string,\n priority: number,\n key: string,\n options: TransportConnectionOptions\n ) {\n super();\n this.initialize = Runtime.transportConnectionInitializer;\n this.hooks = hooks;\n this.name = name;\n this.priority = priority;\n this.key = key;\n this.options = options;\n\n this.state = 'new';\n this.timeline = options.timeline;\n this.activityTimeout = options.activityTimeout;\n this.id = this.timeline.generateUniqueID();\n }\n\n /** Checks whether the transport handles activity checks by itself.\n *\n * @return {Boolean}\n */\n handlesActivityChecks(): boolean {\n return Boolean(this.hooks.handlesActivityChecks);\n }\n\n /** Checks whether the transport supports the ping/pong API.\n *\n * @return {Boolean}\n */\n supportsPing(): boolean {\n return Boolean(this.hooks.supportsPing);\n }\n\n /** Tries to establish a connection.\n *\n * @returns {Boolean} false if transport is in invalid state\n */\n connect(): boolean {\n if (this.socket || this.state !== 'initialized') {\n return false;\n }\n\n var url = this.hooks.urls.getInitial(this.key, this.options);\n try {\n this.socket = this.hooks.getSocket(url, this.options);\n } catch (e) {\n Util.defer(() => {\n this.onError(e);\n this.changeState('closed');\n });\n return false;\n }\n\n this.bindListeners();\n\n Logger.debug('Connecting', { transport: this.name, url });\n this.changeState('connecting');\n return true;\n }\n\n /** Closes the connection.\n *\n * @return {Boolean} true if there was a connection to close\n */\n close(): boolean {\n if (this.socket) {\n this.socket.close();\n return true;\n } else {\n return false;\n }\n }\n\n /** Sends data over the open connection.\n *\n * @param {String} data\n * @return {Boolean} true only when in the \"open\" state\n */\n send(data: any): boolean {\n if (this.state === 'open') {\n // Workaround for MobileSafari bug (see https://gist.github.com/2052006)\n Util.defer(() => {\n if (this.socket) {\n this.socket.send(data);\n }\n });\n return true;\n } else {\n return false;\n }\n }\n\n /** Sends a ping if the connection is open and transport supports it. */\n ping() {\n if (this.state === 'open' && this.supportsPing()) {\n this.socket.ping();\n }\n }\n\n private onOpen() {\n if (this.hooks.beforeOpen) {\n this.hooks.beforeOpen(\n this.socket,\n this.hooks.urls.getPath(this.key, this.options)\n );\n }\n this.changeState('open');\n this.socket.onopen = undefined;\n }\n\n private onError(error) {\n this.emit('error', { type: 'WebSocketError', error: error });\n this.timeline.error(this.buildTimelineMessage({ error: error.toString() }));\n }\n\n private onClose(closeEvent?: any) {\n if (closeEvent) {\n this.changeState('closed', {\n code: closeEvent.code,\n reason: closeEvent.reason,\n wasClean: closeEvent.wasClean\n });\n } else {\n this.changeState('closed');\n }\n this.unbindListeners();\n this.socket = undefined;\n }\n\n private onMessage(message) {\n this.emit('message', message);\n }\n\n private onActivity() {\n this.emit('activity');\n }\n\n private bindListeners() {\n this.socket.onopen = () => {\n this.onOpen();\n };\n this.socket.onerror = error => {\n this.onError(error);\n };\n this.socket.onclose = closeEvent => {\n this.onClose(closeEvent);\n };\n this.socket.onmessage = message => {\n this.onMessage(message);\n };\n\n if (this.supportsPing()) {\n this.socket.onactivity = () => {\n this.onActivity();\n };\n }\n }\n\n private unbindListeners() {\n if (this.socket) {\n this.socket.onopen = undefined;\n this.socket.onerror = undefined;\n this.socket.onclose = undefined;\n this.socket.onmessage = undefined;\n if (this.supportsPing()) {\n this.socket.onactivity = undefined;\n }\n }\n }\n\n private changeState(state: string, params?: any) {\n this.state = state;\n this.timeline.info(\n this.buildTimelineMessage({\n state: state,\n params: params\n })\n );\n this.emit(state, params);\n }\n\n buildTimelineMessage(message): any {\n return Collections.extend({ cid: this.id }, message);\n }\n}\n","import Factory from '../utils/factory';\nimport TransportHooks from './transport_hooks';\nimport TransportConnection from './transport_connection';\nimport TransportConnectionOptions from './transport_connection_options';\n\n/** Provides interface for transport connection instantiation.\n *\n * Takes transport-specific hooks as the only argument, which allow checking\n * for transport support and creating its connections.\n *\n * Supported hooks: * - file - the name of the file to be fetched during initialization\n * - urls - URL scheme to be used by transport\n * - handlesActivityCheck - true when the transport handles activity checks\n * - supportsPing - true when the transport has a ping/activity API\n * - isSupported - tells whether the transport is supported in the environment\n * - getSocket - creates a WebSocket-compatible transport socket\n *\n * See transports.js for specific implementations.\n *\n * @param {Object} hooks object containing all needed transport hooks\n */\nexport default class Transport {\n hooks: TransportHooks;\n\n constructor(hooks: TransportHooks) {\n this.hooks = hooks;\n }\n\n /** Returns whether the transport is supported in the environment.\n *\n * @param {Object} envronment te environment details (encryption, settings)\n * @returns {Boolean} true when the transport is supported\n */\n isSupported(environment: any): boolean {\n return this.hooks.isSupported(environment);\n }\n\n /** Creates a transport connection.\n *\n * @param {String} name\n * @param {Number} priority\n * @param {String} key the application key\n * @param {Object} options\n * @returns {TransportConnection}\n */\n createConnection(\n name: string,\n priority: number,\n key: string,\n options: any\n ): TransportConnection {\n return new TransportConnection(this.hooks, name, priority, key, options);\n }\n}\n","import * as URLSchemes from 'core/transports/url_schemes';\nimport URLScheme from 'core/transports/url_scheme';\nimport Transport from 'core/transports/transport';\nimport Util from 'core/util';\nimport * as Collections from 'core/utils/collections';\nimport TransportHooks from 'core/transports/transport_hooks';\nimport TransportsTable from 'core/transports/transports_table';\nimport Runtime from 'runtime';\n\n/** WebSocket transport.\n *\n * Uses native WebSocket implementation, including MozWebSocket supported by\n * earlier Firefox versions.\n */\nvar WSTransport = new Transport({\n urls: URLSchemes.ws,\n handlesActivityChecks: false,\n supportsPing: false,\n\n isInitialized: function() {\n return Boolean(Runtime.getWebSocketAPI());\n },\n isSupported: function(): boolean {\n return Boolean(Runtime.getWebSocketAPI());\n },\n getSocket: function(url) {\n return Runtime.createWebSocket(url);\n }\n});\n\nvar httpConfiguration = {\n urls: URLSchemes.http,\n handlesActivityChecks: false,\n supportsPing: true,\n isInitialized: function() {\n return true;\n }\n};\n\nexport var streamingConfiguration = Collections.extend(\n {\n getSocket: function(url) {\n return Runtime.HTTPFactory.createStreamingSocket(url);\n }\n },\n httpConfiguration\n);\nexport var pollingConfiguration = Collections.extend(\n {\n getSocket: function(url) {\n return Runtime.HTTPFactory.createPollingSocket(url);\n }\n },\n httpConfiguration\n);\n\nvar xhrConfiguration = {\n isSupported: function(): boolean {\n return Runtime.isXHRSupported();\n }\n};\n\n/** HTTP streaming transport using CORS-enabled XMLHttpRequest. */\nvar XHRStreamingTransport = new Transport(\n (\n Collections.extend({}, streamingConfiguration, xhrConfiguration)\n )\n);\n\n/** HTTP long-polling transport using CORS-enabled XMLHttpRequest. */\nvar XHRPollingTransport = new Transport(\n Collections.extend({}, pollingConfiguration, xhrConfiguration)\n);\n\nvar Transports: TransportsTable = {\n ws: WSTransport,\n xhr_streaming: XHRStreamingTransport,\n xhr_polling: XHRPollingTransport\n};\n\nexport default Transports;\n","import Util from '../util';\nimport * as Collections from '../utils/collections';\nimport TransportManager from './transport_manager';\nimport TransportConnection from './transport_connection';\nimport Transport from './transport';\nimport PingDelayOptions from './ping_delay_options';\n\n/** Creates transport connections monitored by a transport manager.\n *\n * When a transport is closed, it might mean the environment does not support\n * it. It's possible that messages get stuck in an intermediate buffer or\n * proxies terminate inactive connections. To combat these problems,\n * assistants monitor the connection lifetime, report unclean exits and\n * adjust ping timeouts to keep the connection active. The decision to disable\n * a transport is the manager's responsibility.\n *\n * @param {TransportManager} manager\n * @param {TransportConnection} transport\n * @param {Object} options\n */\nexport default class AssistantToTheTransportManager {\n manager: TransportManager;\n transport: Transport;\n minPingDelay: number;\n maxPingDelay: number;\n pingDelay: number;\n\n constructor(\n manager: TransportManager,\n transport: Transport,\n options: PingDelayOptions\n ) {\n this.manager = manager;\n this.transport = transport;\n this.minPingDelay = options.minPingDelay;\n this.maxPingDelay = options.maxPingDelay;\n this.pingDelay = undefined;\n }\n\n /** Creates a transport connection.\n *\n * This function has the same API as Transport#createConnection.\n *\n * @param {String} name\n * @param {Number} priority\n * @param {String} key the application key\n * @param {Object} options\n * @returns {TransportConnection}\n */\n createConnection(\n name: string,\n priority: number,\n key: string,\n options: Object\n ): TransportConnection {\n options = Collections.extend({}, options, {\n activityTimeout: this.pingDelay\n });\n var connection = this.transport.createConnection(\n name,\n priority,\n key,\n options\n );\n\n var openTimestamp = null;\n\n var onOpen = function() {\n connection.unbind('open', onOpen);\n connection.bind('closed', onClosed);\n openTimestamp = Util.now();\n };\n var onClosed = closeEvent => {\n connection.unbind('closed', onClosed);\n\n if (closeEvent.code === 1002 || closeEvent.code === 1003) {\n // we don't want to use transports not obeying the protocol\n this.manager.reportDeath();\n } else if (!closeEvent.wasClean && openTimestamp) {\n // report deaths only for short-living transport\n var lifespan = Util.now() - openTimestamp;\n if (lifespan < 2 * this.maxPingDelay) {\n this.manager.reportDeath();\n this.pingDelay = Math.max(lifespan / 2, this.minPingDelay);\n }\n }\n };\n\n connection.bind('open', onOpen);\n return connection;\n }\n\n /** Returns whether the transport is supported in the environment.\n *\n * This function has the same API as Transport#isSupported. Might return false\n * when the manager decides to kill the transport.\n *\n * @param {Object} environment the environment details (encryption, settings)\n * @returns {Boolean} true when the transport is supported\n */\n isSupported(environment: string): boolean {\n return this.manager.isAlive() && this.transport.isSupported(environment);\n }\n}\n","import Action from './action';\nimport { PusherEvent } from './message-types';\n/**\n * Provides functions for handling Pusher protocol-specific messages.\n */\n\nconst Protocol = {\n /**\n * Decodes a message in a Pusher format.\n *\n * The MessageEvent we receive from the transport should contain a pusher event\n * (https://pusher.com/docs/pusher_protocol#events) serialized as JSON in the\n * data field\n *\n * The pusher event may contain a data field too, and it may also be\n * serialised as JSON\n *\n * Throws errors when messages are not parse'able.\n *\n * @param {MessageEvent} messageEvent\n * @return {PusherEvent}\n */\n decodeMessage: function(messageEvent: MessageEvent): PusherEvent {\n try {\n var messageData = JSON.parse(messageEvent.data);\n var pusherEventData = messageData.data;\n if (typeof pusherEventData === 'string') {\n try {\n pusherEventData = JSON.parse(messageData.data);\n } catch (e) {}\n }\n var pusherEvent: PusherEvent = {\n event: messageData.event,\n channel: messageData.channel,\n data: pusherEventData\n };\n if (messageData.user_id) {\n pusherEvent.user_id = messageData.user_id;\n }\n return pusherEvent;\n } catch (e) {\n throw { type: 'MessageParseError', error: e, data: messageEvent.data };\n }\n },\n\n /**\n * Encodes a message to be sent.\n *\n * @param {PusherEvent} event\n * @return {String}\n */\n encodeMessage: function(event: PusherEvent): string {\n return JSON.stringify(event);\n },\n\n /**\n * Processes a handshake message and returns appropriate actions.\n *\n * Returns an object with an 'action' and other action-specific properties.\n *\n * There are three outcomes when calling this function. First is a successful\n * connection attempt, when pusher:connection_established is received, which\n * results in a 'connected' action with an 'id' property. When passed a\n * pusher:error event, it returns a result with action appropriate to the\n * close code and an error. Otherwise, it raises an exception.\n *\n * @param {String} message\n * @result Object\n */\n processHandshake: function(messageEvent: MessageEvent): Action {\n var message = Protocol.decodeMessage(messageEvent);\n\n if (message.event === 'pusher:connection_established') {\n if (!message.data.activity_timeout) {\n throw 'No activity timeout specified in handshake';\n }\n return {\n action: 'connected',\n id: message.data.socket_id,\n activityTimeout: message.data.activity_timeout * 1000\n };\n } else if (message.event === 'pusher:error') {\n // From protocol 6 close codes are sent only once, so this only\n // happens when connection does not support close codes\n return {\n action: this.getCloseAction(message.data),\n error: this.getCloseError(message.data)\n };\n } else {\n throw 'Invalid handshake';\n }\n },\n\n /**\n * Dispatches the close event and returns an appropriate action name.\n *\n * See:\n * 1. https://developer.mozilla.org/en-US/docs/WebSockets/WebSockets_reference/CloseEvent\n * 2. http://pusher.com/docs/pusher_protocol\n *\n * @param {CloseEvent} closeEvent\n * @return {String} close action name\n */\n getCloseAction: function(closeEvent): string {\n if (closeEvent.code < 4000) {\n // ignore 1000 CLOSE_NORMAL, 1001 CLOSE_GOING_AWAY,\n // 1005 CLOSE_NO_STATUS, 1006 CLOSE_ABNORMAL\n // ignore 1007...3999\n // handle 1002 CLOSE_PROTOCOL_ERROR, 1003 CLOSE_UNSUPPORTED,\n // 1004 CLOSE_TOO_LARGE\n if (closeEvent.code >= 1002 && closeEvent.code <= 1004) {\n return 'backoff';\n } else {\n return null;\n }\n } else if (closeEvent.code === 4000) {\n return 'tls_only';\n } else if (closeEvent.code < 4100) {\n return 'refused';\n } else if (closeEvent.code < 4200) {\n return 'backoff';\n } else if (closeEvent.code < 4300) {\n return 'retry';\n } else {\n // unknown error\n return 'refused';\n }\n },\n\n /**\n * Returns an error or null basing on the close event.\n *\n * Null is returned when connection was closed cleanly. Otherwise, an object\n * with error details is returned.\n *\n * @param {CloseEvent} closeEvent\n * @return {Object} error object\n */\n getCloseError: function(closeEvent): any {\n if (closeEvent.code !== 1000 && closeEvent.code !== 1001) {\n return {\n type: 'PusherError',\n data: {\n code: closeEvent.code,\n message: closeEvent.reason || closeEvent.message\n }\n };\n } else {\n return null;\n }\n }\n};\n\nexport default Protocol;\n","import * as Collections from '../utils/collections';\nimport { default as EventsDispatcher } from '../events/dispatcher';\nimport Protocol from './protocol/protocol';\nimport { PusherEvent } from './protocol/message-types';\nimport Logger from '../logger';\nimport TransportConnection from '../transports/transport_connection';\nimport Socket from '../socket';\n/**\n * Provides Pusher protocol interface for transports.\n *\n * Emits following events:\n * - message - on received messages\n * - ping - on ping requests\n * - pong - on pong responses\n * - error - when the transport emits an error\n * - closed - after closing the transport\n *\n * It also emits more events when connection closes with a code.\n * See Protocol.getCloseAction to get more details.\n *\n * @param {Number} id\n * @param {AbstractTransport} transport\n */\nexport default class Connection extends EventsDispatcher implements Socket {\n id: string;\n transport: TransportConnection;\n activityTimeout: number;\n\n constructor(id: string, transport: TransportConnection) {\n super();\n this.id = id;\n this.transport = transport;\n this.activityTimeout = transport.activityTimeout;\n this.bindListeners();\n }\n\n /** Returns whether used transport handles activity checks by itself\n *\n * @returns {Boolean} true if activity checks are handled by the transport\n */\n handlesActivityChecks() {\n return this.transport.handlesActivityChecks();\n }\n\n /** Sends raw data.\n *\n * @param {String} data\n */\n send(data: any): boolean {\n return this.transport.send(data);\n }\n\n /** Sends an event.\n *\n * @param {String} name\n * @param {String} data\n * @param {String} [channel]\n * @returns {Boolean} whether message was sent or not\n */\n send_event(name: string, data: any, channel?: string): boolean {\n var event: PusherEvent = { event: name, data: data };\n if (channel) {\n event.channel = channel;\n }\n Logger.debug('Event sent', event);\n return this.send(Protocol.encodeMessage(event));\n }\n\n /** Sends a ping message to the server.\n *\n * Basing on the underlying transport, it might send either transport's\n * protocol-specific ping or pusher:ping event.\n */\n ping() {\n if (this.transport.supportsPing()) {\n this.transport.ping();\n } else {\n this.send_event('pusher:ping', {});\n }\n }\n\n /** Closes the connection. */\n close() {\n this.transport.close();\n }\n\n private bindListeners() {\n var listeners = {\n message: (messageEvent: MessageEvent) => {\n var pusherEvent;\n try {\n pusherEvent = Protocol.decodeMessage(messageEvent);\n } catch (e) {\n this.emit('error', {\n type: 'MessageParseError',\n error: e,\n data: messageEvent.data\n });\n }\n\n if (pusherEvent !== undefined) {\n Logger.debug('Event recd', pusherEvent);\n\n switch (pusherEvent.event) {\n case 'pusher:error':\n this.emit('error', {\n type: 'PusherError',\n data: pusherEvent.data\n });\n break;\n case 'pusher:ping':\n this.emit('ping');\n break;\n case 'pusher:pong':\n this.emit('pong');\n break;\n }\n this.emit('message', pusherEvent);\n }\n },\n activity: () => {\n this.emit('activity');\n },\n error: error => {\n this.emit('error', error);\n },\n closed: closeEvent => {\n unbindListeners();\n\n if (closeEvent && closeEvent.code) {\n this.handleCloseEvent(closeEvent);\n }\n\n this.transport = null;\n this.emit('closed');\n }\n };\n\n var unbindListeners = () => {\n Collections.objectApply(listeners, (listener, event) => {\n this.transport.unbind(event, listener);\n });\n };\n\n Collections.objectApply(listeners, (listener, event) => {\n this.transport.bind(event, listener);\n });\n }\n\n private handleCloseEvent(closeEvent: any) {\n var action = Protocol.getCloseAction(closeEvent);\n var error = Protocol.getCloseError(closeEvent);\n if (error) {\n this.emit('error', error);\n }\n if (action) {\n this.emit(action, { action: action, error: error });\n }\n }\n}\n","import Util from '../../util';\nimport * as Collections from '../../utils/collections';\nimport Protocol from '../protocol/protocol';\nimport Connection from '../connection';\nimport TransportConnection from '../../transports/transport_connection';\nimport HandshakePayload from './handshake_payload';\n\n/**\n * Handles Pusher protocol handshakes for transports.\n *\n * Calls back with a result object after handshake is completed. Results\n * always have two fields:\n * - action - string describing action to be taken after the handshake\n * - transport - the transport object passed to the constructor\n *\n * Different actions can set different additional properties on the result.\n * In the case of 'connected' action, there will be a 'connection' property\n * containing a Connection object for the transport. Other actions should\n * carry an 'error' property.\n *\n * @param {AbstractTransport} transport\n * @param {Function} callback\n */\nexport default class Handshake {\n transport: TransportConnection;\n callback: (HandshakePayload) => void;\n onMessage: Function;\n onClosed: Function;\n\n constructor(\n transport: TransportConnection,\n callback: (HandshakePayload) => void\n ) {\n this.transport = transport;\n this.callback = callback;\n this.bindListeners();\n }\n\n close() {\n this.unbindListeners();\n this.transport.close();\n }\n\n private bindListeners() {\n this.onMessage = m => {\n this.unbindListeners();\n\n var result;\n try {\n result = Protocol.processHandshake(m);\n } catch (e) {\n this.finish('error', { error: e });\n this.transport.close();\n return;\n }\n\n if (result.action === 'connected') {\n this.finish('connected', {\n connection: new Connection(result.id, this.transport),\n activityTimeout: result.activityTimeout\n });\n } else {\n this.finish(result.action, { error: result.error });\n this.transport.close();\n }\n };\n\n this.onClosed = closeEvent => {\n this.unbindListeners();\n\n var action = Protocol.getCloseAction(closeEvent) || 'backoff';\n var error = Protocol.getCloseError(closeEvent);\n this.finish(action, { error: error });\n };\n\n this.transport.bind('message', this.onMessage);\n this.transport.bind('closed', this.onClosed);\n }\n\n private unbindListeners() {\n this.transport.unbind('message', this.onMessage);\n this.transport.unbind('closed', this.onClosed);\n }\n\n private finish(action: string, params: any) {\n this.callback(\n Collections.extend({ transport: this.transport, action: action }, params)\n );\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport base64encode from '../base64';\nimport Timeline from './timeline';\nimport Runtime from 'runtime';\n\nexport interface TimelineSenderOptions {\n host?: string;\n port?: number;\n path?: string;\n}\n\nexport default class TimelineSender {\n timeline: Timeline;\n options: TimelineSenderOptions;\n host: string;\n\n constructor(timeline: Timeline, options: TimelineSenderOptions) {\n this.timeline = timeline;\n this.options = options || {};\n }\n\n send(useTLS: boolean, callback?: Function) {\n if (this.timeline.isEmpty()) {\n return;\n }\n\n this.timeline.send(\n Runtime.TimelineTransport.getAgent(this, useTLS),\n callback\n );\n }\n}\n","/** Error classes used throughout the library. */\n// https://github.com/Microsoft/TypeScript-wiki/blob/master/Breaking-Changes.md#extending-built-ins-like-error-array-and-map-may-no-longer-work\nexport class BadEventName extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\nexport class BadChannelName extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\nexport class RequestTimedOut extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class TransportPriorityTooLow extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class TransportClosed extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class UnsupportedFeature extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class UnsupportedTransport extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class UnsupportedStrategy extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class HTTPAuthError extends Error {\n status: number;\n constructor(status: number, msg?: string) {\n super(msg);\n this.status = status;\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n","/**\n * A place to store help URLs for error messages etc\n */\n\nconst urlStore = {\n baseUrl: 'https://pusher.com',\n urls: {\n authenticationEndpoint: {\n path: '/docs/channels/server_api/authenticating_users'\n },\n authorizationEndpoint: {\n path: '/docs/channels/server_api/authorizing-users/'\n },\n javascriptQuickStart: {\n path: '/docs/javascript_quick_start'\n },\n triggeringClientEvents: {\n path: '/docs/client_api_guide/client_events#trigger-events'\n },\n encryptedChannelSupport: {\n fullUrl:\n 'https://github.com/pusher/pusher-js/tree/cc491015371a4bde5743d1c87a0fbac0feb53195#encrypted-channel-support'\n }\n }\n};\n\n/** Builds a consistent string with links to pusher documentation\n *\n * @param {string} key - relevant key in the url_store.urls object\n * @return {string} suffix string to append to log message\n */\nconst buildLogSuffix = function(key: string): string {\n const urlPrefix = 'See:';\n const urlObj = urlStore.urls[key];\n if (!urlObj) return '';\n\n let url;\n if (urlObj.fullUrl) {\n url = urlObj.fullUrl;\n } else if (urlObj.path) {\n url = urlStore.baseUrl + urlObj.path;\n }\n\n if (!url) return '';\n return `${urlPrefix} ${url}`;\n};\n\nexport default { buildLogSuffix };\n","import { default as EventsDispatcher } from '../events/dispatcher';\nimport * as Errors from '../errors';\nimport Logger from '../logger';\nimport Pusher from '../pusher';\nimport { PusherEvent } from '../connection/protocol/message-types';\nimport Metadata from './metadata';\nimport UrlStore from '../utils/url_store';\nimport {\n ChannelAuthorizationData,\n ChannelAuthorizationCallback\n} from '../auth/options';\nimport { HTTPAuthError } from '../errors';\n\n/** Provides base public channel interface with an event emitter.\n *\n * Emits:\n * - pusher:subscription_succeeded - after subscribing successfully\n * - other non-internal events\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\nexport default class Channel extends EventsDispatcher {\n name: string;\n pusher: Pusher;\n subscribed: boolean;\n subscriptionPending: boolean;\n subscriptionCancelled: boolean;\n subscriptionCount: null;\n\n constructor(name: string, pusher: Pusher) {\n super(function(event, data) {\n Logger.debug('No callbacks on ' + name + ' for ' + event);\n });\n\n this.name = name;\n this.pusher = pusher;\n this.subscribed = false;\n this.subscriptionPending = false;\n this.subscriptionCancelled = false;\n }\n\n /** Skips authorization, since public channels don't require it.\n *\n * @param {Function} callback\n */\n authorize(socketId: string, callback: ChannelAuthorizationCallback) {\n return callback(null, { auth: '' });\n }\n\n /** Triggers an event */\n trigger(event: string, data: any) {\n if (event.indexOf('client-') !== 0) {\n throw new Errors.BadEventName(\n \"Event '\" + event + \"' does not start with 'client-'\"\n );\n }\n if (!this.subscribed) {\n var suffix = UrlStore.buildLogSuffix('triggeringClientEvents');\n Logger.warn(\n `Client event triggered before channel 'subscription_succeeded' event . ${suffix}`\n );\n }\n return this.pusher.send_event(event, data, this.name);\n }\n\n /** Signals disconnection to the channel. For internal use only. */\n disconnect() {\n this.subscribed = false;\n this.subscriptionPending = false;\n }\n\n /** Handles a PusherEvent. For internal use only.\n *\n * @param {PusherEvent} event\n */\n handleEvent(event: PusherEvent) {\n var eventName = event.event;\n var data = event.data;\n if (eventName === 'pusher_internal:subscription_succeeded') {\n this.handleSubscriptionSucceededEvent(event);\n } else if (eventName === 'pusher_internal:subscription_count') {\n this.handleSubscriptionCountEvent(event);\n } else if (eventName.indexOf('pusher_internal:') !== 0) {\n var metadata: Metadata = {};\n this.emit(eventName, data, metadata);\n }\n }\n\n handleSubscriptionSucceededEvent(event: PusherEvent) {\n this.subscriptionPending = false;\n this.subscribed = true;\n if (this.subscriptionCancelled) {\n this.pusher.unsubscribe(this.name);\n } else {\n this.emit('pusher:subscription_succeeded', event.data);\n }\n }\n\n handleSubscriptionCountEvent(event: PusherEvent) {\n if (event.data.subscription_count) {\n this.subscriptionCount = event.data.subscription_count;\n }\n\n this.emit('pusher:subscription_count', event.data);\n }\n\n /** Sends a subscription request. For internal use only. */\n subscribe() {\n if (this.subscribed) {\n return;\n }\n this.subscriptionPending = true;\n this.subscriptionCancelled = false;\n this.authorize(\n this.pusher.connection.socket_id,\n (error: Error | null, data: ChannelAuthorizationData) => {\n if (error) {\n this.subscriptionPending = false;\n // Why not bind to 'pusher:subscription_error' a level up, and log there?\n // Binding to this event would cause the warning about no callbacks being\n // bound (see constructor) to be suppressed, that's not what we want.\n Logger.error(error.toString());\n this.emit(\n 'pusher:subscription_error',\n Object.assign(\n {},\n {\n type: 'AuthError',\n error: error.message\n },\n error instanceof HTTPAuthError ? { status: error.status } : {}\n )\n );\n } else {\n this.pusher.send_event('pusher:subscribe', {\n auth: data.auth,\n channel_data: data.channel_data,\n channel: this.name\n });\n }\n }\n );\n }\n\n /** Sends an unsubscription request. For internal use only. */\n unsubscribe() {\n this.subscribed = false;\n this.pusher.send_event('pusher:unsubscribe', {\n channel: this.name\n });\n }\n\n /** Cancels an in progress subscription. For internal use only. */\n cancelSubscription() {\n this.subscriptionCancelled = true;\n }\n\n /** Reinstates an in progress subscripiton. For internal use only. */\n reinstateSubscription() {\n this.subscriptionCancelled = false;\n }\n}\n","import Factory from '../utils/factory';\nimport Channel from './channel';\nimport { ChannelAuthorizationCallback } from '../auth/options';\n\n/** Extends public channels to provide private channel interface.\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\nexport default class PrivateChannel extends Channel {\n /** Authorizes the connection to use the channel.\n *\n * @param {String} socketId\n * @param {Function} callback\n */\n authorize(socketId: string, callback: ChannelAuthorizationCallback) {\n return this.pusher.config.channelAuthorizer(\n {\n channelName: this.name,\n socketId: socketId\n },\n callback\n );\n }\n}\n","import * as Collections from '../utils/collections';\n\n/** Represents a collection of members of a presence channel. */\nexport default class Members {\n members: any;\n count: number;\n myID: any;\n me: any;\n\n constructor() {\n this.reset();\n }\n\n /** Returns member's info for given id.\n *\n * Resulting object containts two fields - id and info.\n *\n * @param {Number} id\n * @return {Object} member's info or null\n */\n get(id: string): any {\n if (Object.prototype.hasOwnProperty.call(this.members, id)) {\n return {\n id: id,\n info: this.members[id]\n };\n } else {\n return null;\n }\n }\n\n /** Calls back for each member in unspecified order.\n *\n * @param {Function} callback\n */\n each(callback: Function) {\n Collections.objectApply(this.members, (member, id) => {\n callback(this.get(id));\n });\n }\n\n /** Updates the id for connected member. For internal use only. */\n setMyID(id: string) {\n this.myID = id;\n }\n\n /** Handles subscription data. For internal use only. */\n onSubscription(subscriptionData: any) {\n this.members = subscriptionData.presence.hash;\n this.count = subscriptionData.presence.count;\n this.me = this.get(this.myID);\n }\n\n /** Adds a new member to the collection. For internal use only. */\n addMember(memberData: any) {\n if (this.get(memberData.user_id) === null) {\n this.count++;\n }\n this.members[memberData.user_id] = memberData.user_info;\n return this.get(memberData.user_id);\n }\n\n /** Adds a member from the collection. For internal use only. */\n removeMember(memberData: any) {\n var member = this.get(memberData.user_id);\n if (member) {\n delete this.members[memberData.user_id];\n this.count--;\n }\n return member;\n }\n\n /** Resets the collection to the initial state. For internal use only. */\n reset() {\n this.members = {};\n this.count = 0;\n this.myID = null;\n this.me = null;\n }\n}\n","import PrivateChannel from './private_channel';\nimport Logger from '../logger';\nimport Members from './members';\nimport Pusher from '../pusher';\nimport UrlStore from 'core/utils/url_store';\nimport { PusherEvent } from '../connection/protocol/message-types';\nimport Metadata from './metadata';\nimport { ChannelAuthorizationData } from '../auth/options';\n\nexport default class PresenceChannel extends PrivateChannel {\n members: Members;\n\n /** Adds presence channel functionality to private channels.\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\n constructor(name: string, pusher: Pusher) {\n super(name, pusher);\n this.members = new Members();\n }\n\n /** Authorizes the connection as a member of the channel.\n *\n * @param {String} socketId\n * @param {Function} callback\n */\n authorize(socketId: string, callback: Function) {\n super.authorize(socketId, async (error, authData) => {\n if (!error) {\n authData = authData as ChannelAuthorizationData;\n if (authData.channel_data != null) {\n var channelData = JSON.parse(authData.channel_data);\n this.members.setMyID(channelData.user_id);\n } else {\n await this.pusher.user.signinDonePromise;\n if (this.pusher.user.user_data != null) {\n // If the user is signed in, get the id of the authenticated user\n // and allow the presence authorization to continue.\n this.members.setMyID(this.pusher.user.user_data.id);\n } else {\n let suffix = UrlStore.buildLogSuffix('authorizationEndpoint');\n Logger.error(\n `Invalid auth response for channel '${this.name}', ` +\n `expected 'channel_data' field. ${suffix}, ` +\n `or the user should be signed in.`\n );\n callback('Invalid auth response');\n return;\n }\n }\n }\n callback(error, authData);\n });\n }\n\n /** Handles presence and subscription events. For internal use only.\n *\n * @param {PusherEvent} event\n */\n handleEvent(event: PusherEvent) {\n var eventName = event.event;\n if (eventName.indexOf('pusher_internal:') === 0) {\n this.handleInternalEvent(event);\n } else {\n var data = event.data;\n var metadata: Metadata = {};\n if (event.user_id) {\n metadata.user_id = event.user_id;\n }\n this.emit(eventName, data, metadata);\n }\n }\n handleInternalEvent(event: PusherEvent) {\n var eventName = event.event;\n var data = event.data;\n switch (eventName) {\n case 'pusher_internal:subscription_succeeded':\n this.handleSubscriptionSucceededEvent(event);\n break;\n case 'pusher_internal:subscription_count':\n this.handleSubscriptionCountEvent(event);\n break;\n case 'pusher_internal:member_added':\n var addedMember = this.members.addMember(data);\n this.emit('pusher:member_added', addedMember);\n break;\n case 'pusher_internal:member_removed':\n var removedMember = this.members.removeMember(data);\n if (removedMember) {\n this.emit('pusher:member_removed', removedMember);\n }\n break;\n }\n }\n\n handleSubscriptionSucceededEvent(event: PusherEvent) {\n this.subscriptionPending = false;\n this.subscribed = true;\n if (this.subscriptionCancelled) {\n this.pusher.unsubscribe(this.name);\n } else {\n this.members.onSubscription(event.data);\n this.emit('pusher:subscription_succeeded', this.members);\n }\n }\n\n /** Resets the channel state, including members map. For internal use only. */\n disconnect() {\n this.members.reset();\n super.disconnect();\n }\n}\n","import PrivateChannel from './private_channel';\nimport * as Errors from '../errors';\nimport Logger from '../logger';\nimport Pusher from '../pusher';\nimport { decode as encodeUTF8 } from '@stablelib/utf8';\nimport { decode as decodeBase64 } from '@stablelib/base64';\nimport Dispatcher from '../events/dispatcher';\nimport { PusherEvent } from '../connection/protocol/message-types';\nimport {\n ChannelAuthorizationData,\n ChannelAuthorizationCallback\n} from '../auth/options';\nimport * as nacl from 'tweetnacl';\n\n/** Extends private channels to provide encrypted channel interface.\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\nexport default class EncryptedChannel extends PrivateChannel {\n key: Uint8Array = null;\n nacl: nacl;\n\n constructor(name: string, pusher: Pusher, nacl: nacl) {\n super(name, pusher);\n this.nacl = nacl;\n }\n\n /** Authorizes the connection to use the channel.\n *\n * @param {String} socketId\n * @param {Function} callback\n */\n authorize(socketId: string, callback: ChannelAuthorizationCallback) {\n super.authorize(\n socketId,\n (error: Error | null, authData: ChannelAuthorizationData) => {\n if (error) {\n callback(error, authData);\n return;\n }\n let sharedSecret = authData['shared_secret'];\n if (!sharedSecret) {\n callback(\n new Error(\n `No shared_secret key in auth payload for encrypted channel: ${this.name}`\n ),\n null\n );\n return;\n }\n this.key = decodeBase64(sharedSecret);\n delete authData['shared_secret'];\n callback(null, authData);\n }\n );\n }\n\n trigger(event: string, data: any): boolean {\n throw new Errors.UnsupportedFeature(\n 'Client events are not currently supported for encrypted channels'\n );\n }\n\n /** Handles an event. For internal use only.\n *\n * @param {PusherEvent} event\n */\n handleEvent(event: PusherEvent) {\n var eventName = event.event;\n var data = event.data;\n if (\n eventName.indexOf('pusher_internal:') === 0 ||\n eventName.indexOf('pusher:') === 0\n ) {\n super.handleEvent(event);\n return;\n }\n this.handleEncryptedEvent(eventName, data);\n }\n\n private handleEncryptedEvent(event: string, data: any): void {\n if (!this.key) {\n Logger.debug(\n 'Received encrypted event before key has been retrieved from the authEndpoint'\n );\n return;\n }\n if (!data.ciphertext || !data.nonce) {\n Logger.error(\n 'Unexpected format for encrypted event, expected object with `ciphertext` and `nonce` fields, got: ' +\n data\n );\n return;\n }\n let cipherText = decodeBase64(data.ciphertext);\n if (cipherText.length < this.nacl.secretbox.overheadLength) {\n Logger.error(\n `Expected encrypted event ciphertext length to be ${this.nacl.secretbox.overheadLength}, got: ${cipherText.length}`\n );\n return;\n }\n let nonce = decodeBase64(data.nonce);\n if (nonce.length < this.nacl.secretbox.nonceLength) {\n Logger.error(\n `Expected encrypted event nonce length to be ${this.nacl.secretbox.nonceLength}, got: ${nonce.length}`\n );\n return;\n }\n\n let bytes = this.nacl.secretbox.open(cipherText, nonce, this.key);\n if (bytes === null) {\n Logger.debug(\n 'Failed to decrypt an event, probably because it was encrypted with a different key. Fetching a new key from the authEndpoint...'\n );\n // Try a single time to retrieve a new auth key and decrypt the event with it\n // If this fails, a new key will be requested when a new message is received\n this.authorize(this.pusher.connection.socket_id, (error, authData) => {\n if (error) {\n Logger.error(\n `Failed to make a request to the authEndpoint: ${authData}. Unable to fetch new key, so dropping encrypted event`\n );\n return;\n }\n bytes = this.nacl.secretbox.open(cipherText, nonce, this.key);\n if (bytes === null) {\n Logger.error(\n `Failed to decrypt event with new key. Dropping encrypted event`\n );\n return;\n }\n this.emit(event, this.getDataToEmit(bytes));\n return;\n });\n return;\n }\n this.emit(event, this.getDataToEmit(bytes));\n }\n\n // Try and parse the decrypted bytes as JSON. If we can't parse it, just\n // return the utf-8 string\n getDataToEmit(bytes: Uint8Array): string {\n let raw = encodeUTF8(bytes);\n try {\n return JSON.parse(raw);\n } catch {\n return raw;\n }\n }\n}\n","import { default as EventsDispatcher } from '../events/dispatcher';\nimport { OneOffTimer as Timer } from '../utils/timers';\nimport { Config } from '../config';\nimport Logger from '../logger';\nimport HandshakePayload from './handshake/handshake_payload';\nimport Connection from './connection';\nimport Strategy from '../strategies/strategy';\nimport StrategyRunner from '../strategies/strategy_runner';\nimport * as Collections from '../utils/collections';\nimport Timeline from '../timeline/timeline';\nimport ConnectionManagerOptions from './connection_manager_options';\nimport Runtime from 'runtime';\n\nimport {\n ErrorCallbacks,\n HandshakeCallbacks,\n ConnectionCallbacks\n} from './callbacks';\nimport Action from './protocol/action';\n\n/** Manages connection to Pusher.\n *\n * Uses a strategy (currently only default), timers and network availability\n * info to establish a connection and export its state. In case of failures,\n * manages reconnection attempts.\n *\n * Exports state changes as following events:\n * - \"state_change\", { previous: p, current: state }\n * - state\n *\n * States:\n * - initialized - initial state, never transitioned to\n * - connecting - connection is being established\n * - connected - connection has been fully established\n * - disconnected - on requested disconnection\n * - unavailable - after connection timeout or when there's no network\n * - failed - when the connection strategy is not supported\n *\n * Options:\n * - unavailableTimeout - time to transition to unavailable state\n * - activityTimeout - time after which ping message should be sent\n * - pongTimeout - time for Pusher to respond with pong before reconnecting\n *\n * @param {String} key application key\n * @param {Object} options\n */\nexport default class ConnectionManager extends EventsDispatcher {\n key: string;\n options: ConnectionManagerOptions;\n state: string;\n connection: Connection;\n usingTLS: boolean;\n timeline: Timeline;\n socket_id: string;\n unavailableTimer: Timer;\n activityTimer: Timer;\n retryTimer: Timer;\n activityTimeout: number;\n strategy: Strategy;\n runner: StrategyRunner;\n errorCallbacks: ErrorCallbacks;\n handshakeCallbacks: HandshakeCallbacks;\n connectionCallbacks: ConnectionCallbacks;\n\n constructor(key: string, options: ConnectionManagerOptions) {\n super();\n this.state = 'initialized';\n this.connection = null;\n\n this.key = key;\n this.options = options;\n this.timeline = this.options.timeline;\n this.usingTLS = this.options.useTLS;\n\n this.errorCallbacks = this.buildErrorCallbacks();\n this.connectionCallbacks = this.buildConnectionCallbacks(\n this.errorCallbacks\n );\n this.handshakeCallbacks = this.buildHandshakeCallbacks(this.errorCallbacks);\n\n var Network = Runtime.getNetwork();\n\n Network.bind('online', () => {\n this.timeline.info({ netinfo: 'online' });\n if (this.state === 'connecting' || this.state === 'unavailable') {\n this.retryIn(0);\n }\n });\n Network.bind('offline', () => {\n this.timeline.info({ netinfo: 'offline' });\n if (this.connection) {\n this.sendActivityCheck();\n }\n });\n\n this.updateStrategy();\n }\n\n switchCluster(key: string) {\n this.key = key;\n // This ensures that the new config coming from\n // pusher instance are taken into account\n // such as appKey and cluster\n this.updateStrategy();\n this.retryIn(0);\n }\n\n /** Establishes a connection to Pusher.\n *\n * Does nothing when connection is already established. See top-level doc\n * to find events emitted on connection attempts.\n */\n connect() {\n if (this.connection || this.runner) {\n return;\n }\n if (!this.strategy.isSupported()) {\n this.updateState('failed');\n return;\n }\n this.updateState('connecting');\n this.startConnecting();\n this.setUnavailableTimer();\n }\n\n /** Sends raw data.\n *\n * @param {String} data\n */\n send(data) {\n if (this.connection) {\n return this.connection.send(data);\n } else {\n return false;\n }\n }\n\n /** Sends an event.\n *\n * @param {String} name\n * @param {String} data\n * @param {String} [channel]\n * @returns {Boolean} whether message was sent or not\n */\n send_event(name: string, data: any, channel?: string) {\n if (this.connection) {\n return this.connection.send_event(name, data, channel);\n } else {\n return false;\n }\n }\n\n /** Closes the connection. */\n disconnect() {\n this.disconnectInternally();\n this.updateState('disconnected');\n }\n\n isUsingTLS() {\n return this.usingTLS;\n }\n\n private startConnecting() {\n var callback = (error, handshake) => {\n if (error) {\n this.runner = this.strategy.connect(0, callback);\n } else {\n if (handshake.action === 'error') {\n this.emit('error', {\n type: 'HandshakeError',\n error: handshake.error\n });\n this.timeline.error({ handshakeError: handshake.error });\n } else {\n this.abortConnecting(); // we don't support switching connections yet\n this.handshakeCallbacks[handshake.action](handshake);\n }\n }\n };\n this.runner = this.strategy.connect(0, callback);\n }\n\n private abortConnecting() {\n if (this.runner) {\n this.runner.abort();\n this.runner = null;\n }\n }\n\n private disconnectInternally() {\n this.abortConnecting();\n this.clearRetryTimer();\n this.clearUnavailableTimer();\n if (this.connection) {\n var connection = this.abandonConnection();\n connection.close();\n }\n }\n\n private updateStrategy() {\n this.strategy = this.options.getStrategy({\n key: this.key,\n timeline: this.timeline,\n useTLS: this.usingTLS\n });\n }\n\n private retryIn(delay) {\n this.timeline.info({ action: 'retry', delay: delay });\n if (delay > 0) {\n this.emit('connecting_in', Math.round(delay / 1000));\n }\n this.retryTimer = new Timer(delay || 0, () => {\n this.disconnectInternally();\n this.connect();\n });\n }\n\n private clearRetryTimer() {\n if (this.retryTimer) {\n this.retryTimer.ensureAborted();\n this.retryTimer = null;\n }\n }\n\n private setUnavailableTimer() {\n this.unavailableTimer = new Timer(this.options.unavailableTimeout, () => {\n this.updateState('unavailable');\n });\n }\n\n private clearUnavailableTimer() {\n if (this.unavailableTimer) {\n this.unavailableTimer.ensureAborted();\n }\n }\n\n private sendActivityCheck() {\n this.stopActivityCheck();\n this.connection.ping();\n // wait for pong response\n this.activityTimer = new Timer(this.options.pongTimeout, () => {\n this.timeline.error({ pong_timed_out: this.options.pongTimeout });\n this.retryIn(0);\n });\n }\n\n private resetActivityCheck() {\n this.stopActivityCheck();\n // send ping after inactivity\n if (this.connection && !this.connection.handlesActivityChecks()) {\n this.activityTimer = new Timer(this.activityTimeout, () => {\n this.sendActivityCheck();\n });\n }\n }\n\n private stopActivityCheck() {\n if (this.activityTimer) {\n this.activityTimer.ensureAborted();\n }\n }\n\n private buildConnectionCallbacks(\n errorCallbacks: ErrorCallbacks\n ): ConnectionCallbacks {\n return Collections.extend({}, errorCallbacks, {\n message: message => {\n // includes pong messages from server\n this.resetActivityCheck();\n this.emit('message', message);\n },\n ping: () => {\n this.send_event('pusher:pong', {});\n },\n activity: () => {\n this.resetActivityCheck();\n },\n error: error => {\n // just emit error to user - socket will already be closed by browser\n this.emit('error', error);\n },\n closed: () => {\n this.abandonConnection();\n if (this.shouldRetry()) {\n this.retryIn(1000);\n }\n }\n });\n }\n\n private buildHandshakeCallbacks(\n errorCallbacks: ErrorCallbacks\n ): HandshakeCallbacks {\n return Collections.extend({}, errorCallbacks, {\n connected: (handshake: HandshakePayload) => {\n this.activityTimeout = Math.min(\n this.options.activityTimeout,\n handshake.activityTimeout,\n handshake.connection.activityTimeout || Infinity\n );\n this.clearUnavailableTimer();\n this.setConnection(handshake.connection);\n this.socket_id = this.connection.id;\n this.updateState('connected', { socket_id: this.socket_id });\n }\n });\n }\n\n private buildErrorCallbacks(): ErrorCallbacks {\n let withErrorEmitted = callback => {\n return (result: Action | HandshakePayload) => {\n if (result.error) {\n this.emit('error', { type: 'WebSocketError', error: result.error });\n }\n callback(result);\n };\n };\n\n return {\n tls_only: withErrorEmitted(() => {\n this.usingTLS = true;\n this.updateStrategy();\n this.retryIn(0);\n }),\n refused: withErrorEmitted(() => {\n this.disconnect();\n }),\n backoff: withErrorEmitted(() => {\n this.retryIn(1000);\n }),\n retry: withErrorEmitted(() => {\n this.retryIn(0);\n })\n };\n }\n\n private setConnection(connection) {\n this.connection = connection;\n for (var event in this.connectionCallbacks) {\n this.connection.bind(event, this.connectionCallbacks[event]);\n }\n this.resetActivityCheck();\n }\n\n private abandonConnection() {\n if (!this.connection) {\n return;\n }\n this.stopActivityCheck();\n for (var event in this.connectionCallbacks) {\n this.connection.unbind(event, this.connectionCallbacks[event]);\n }\n var connection = this.connection;\n this.connection = null;\n return connection;\n }\n\n private updateState(newState: string, data?: any) {\n var previousState = this.state;\n this.state = newState;\n if (previousState !== newState) {\n var newStateDescription = newState;\n if (newStateDescription === 'connected') {\n newStateDescription += ' with new socket ID ' + data.socket_id;\n }\n Logger.debug(\n 'State changed',\n previousState + ' -> ' + newStateDescription\n );\n this.timeline.info({ state: newState, params: data });\n this.emit('state_change', { previous: previousState, current: newState });\n this.emit(newState, data);\n }\n }\n\n private shouldRetry(): boolean {\n return this.state === 'connecting' || this.state === 'connected';\n }\n}\n","import Channel from './channel';\nimport * as Collections from '../utils/collections';\nimport ChannelTable from './channel_table';\nimport Factory from '../utils/factory';\nimport Pusher from '../pusher';\nimport Logger from '../logger';\nimport * as Errors from '../errors';\nimport urlStore from '../utils/url_store';\n\n/** Handles a channel map. */\nexport default class Channels {\n channels: ChannelTable;\n\n constructor() {\n this.channels = {};\n }\n\n /** Creates or retrieves an existing channel by its name.\n *\n * @param {String} name\n * @param {Pusher} pusher\n * @return {Channel}\n */\n add(name: string, pusher: Pusher) {\n if (!this.channels[name]) {\n this.channels[name] = createChannel(name, pusher);\n }\n return this.channels[name];\n }\n\n /** Returns a list of all channels\n *\n * @return {Array}\n */\n all(): Channel[] {\n return Collections.values(this.channels);\n }\n\n /** Finds a channel by its name.\n *\n * @param {String} name\n * @return {Channel} channel or null if it doesn't exist\n */\n find(name: string) {\n return this.channels[name];\n }\n\n /** Removes a channel from the map.\n *\n * @param {String} name\n */\n remove(name: string) {\n var channel = this.channels[name];\n delete this.channels[name];\n return channel;\n }\n\n /** Proxies disconnection signal to all channels. */\n disconnect() {\n Collections.objectApply(this.channels, function(channel) {\n channel.disconnect();\n });\n }\n}\n\nfunction createChannel(name: string, pusher: Pusher): Channel {\n if (name.indexOf('private-encrypted-') === 0) {\n if (pusher.config.nacl) {\n return Factory.createEncryptedChannel(name, pusher, pusher.config.nacl);\n }\n let errMsg =\n 'Tried to subscribe to a private-encrypted- channel but no nacl implementation available';\n let suffix = urlStore.buildLogSuffix('encryptedChannelSupport');\n throw new Errors.UnsupportedFeature(`${errMsg}. ${suffix}`);\n } else if (name.indexOf('private-') === 0) {\n return Factory.createPrivateChannel(name, pusher);\n } else if (name.indexOf('presence-') === 0) {\n return Factory.createPresenceChannel(name, pusher);\n } else if (name.indexOf('#') === 0) {\n throw new Errors.BadChannelName(\n 'Cannot create a channel with name \"' + name + '\".'\n );\n } else {\n return Factory.createChannel(name, pusher);\n }\n}\n","import AssistantToTheTransportManager from '../transports/assistant_to_the_transport_manager';\nimport PingDelayOptions from '../transports/ping_delay_options';\nimport Transport from '../transports/transport';\nimport TransportManager from '../transports/transport_manager';\nimport Handshake from '../connection/handshake';\nimport TransportConnection from '../transports/transport_connection';\nimport SocketHooks from '../http/socket_hooks';\nimport HTTPSocket from '../http/http_socket';\n\nimport Timeline from '../timeline/timeline';\nimport {\n default as TimelineSender,\n TimelineSenderOptions\n} from '../timeline/timeline_sender';\nimport PresenceChannel from '../channels/presence_channel';\nimport PrivateChannel from '../channels/private_channel';\nimport EncryptedChannel from '../channels/encrypted_channel';\nimport Channel from '../channels/channel';\nimport ConnectionManager from '../connection/connection_manager';\nimport ConnectionManagerOptions from '../connection/connection_manager_options';\nimport Ajax from '../http/ajax';\nimport Channels from '../channels/channels';\nimport Pusher from '../pusher';\nimport { Config } from '../config';\nimport * as nacl from 'tweetnacl';\n\nvar Factory = {\n createChannels(): Channels {\n return new Channels();\n },\n\n createConnectionManager(\n key: string,\n options: ConnectionManagerOptions\n ): ConnectionManager {\n return new ConnectionManager(key, options);\n },\n\n createChannel(name: string, pusher: Pusher): Channel {\n return new Channel(name, pusher);\n },\n\n createPrivateChannel(name: string, pusher: Pusher): PrivateChannel {\n return new PrivateChannel(name, pusher);\n },\n\n createPresenceChannel(name: string, pusher: Pusher): PresenceChannel {\n return new PresenceChannel(name, pusher);\n },\n\n createEncryptedChannel(\n name: string,\n pusher: Pusher,\n nacl: nacl\n ): EncryptedChannel {\n return new EncryptedChannel(name, pusher, nacl);\n },\n\n createTimelineSender(timeline: Timeline, options: TimelineSenderOptions) {\n return new TimelineSender(timeline, options);\n },\n\n createHandshake(\n transport: TransportConnection,\n callback: (HandshakePayload) => void\n ): Handshake {\n return new Handshake(transport, callback);\n },\n\n createAssistantToTheTransportManager(\n manager: TransportManager,\n transport: Transport,\n options: PingDelayOptions\n ): AssistantToTheTransportManager {\n return new AssistantToTheTransportManager(manager, transport, options);\n }\n};\n\nexport default Factory;\n","import AssistantToTheTransportManager from './assistant_to_the_transport_manager';\nimport Transport from './transport';\nimport PingDelayOptions from './ping_delay_options';\nimport Factory from '../utils/factory';\n\nexport interface TransportManagerOptions extends PingDelayOptions {\n lives?: number;\n}\n\n/** Keeps track of the number of lives left for a transport.\n *\n * In the beginning of a session, transports may be assigned a number of\n * lives. When an AssistantToTheTransportManager instance reports a transport\n * connection closed uncleanly, the transport loses a life. When the number\n * of lives drops to zero, the transport gets disabled by its manager.\n *\n * @param {Object} options\n */\nexport default class TransportManager {\n options: TransportManagerOptions;\n livesLeft: number;\n\n constructor(options: TransportManagerOptions) {\n this.options = options || {};\n this.livesLeft = this.options.lives || Infinity;\n }\n\n /** Creates a assistant for the transport.\n *\n * @param {Transport} transport\n * @returns {AssistantToTheTransportManager}\n */\n getAssistant(transport: Transport): AssistantToTheTransportManager {\n return Factory.createAssistantToTheTransportManager(this, transport, {\n minPingDelay: this.options.minPingDelay,\n maxPingDelay: this.options.maxPingDelay\n });\n }\n\n /** Returns whether the transport has any lives left.\n *\n * @returns {Boolean}\n */\n isAlive(): boolean {\n return this.livesLeft > 0;\n }\n\n /** Takes one life from the transport. */\n reportDeath() {\n this.livesLeft -= 1;\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport { OneOffTimer as Timer } from '../utils/timers';\nimport Strategy from './strategy';\nimport StrategyOptions from './strategy_options';\n\n/** Loops through strategies with optional timeouts.\n *\n * Options:\n * - loop - whether it should loop through the substrategy list\n * - timeout - initial timeout for a single substrategy\n * - timeoutLimit - maximum timeout\n *\n * @param {Strategy[]} strategies\n * @param {Object} options\n */\nexport default class SequentialStrategy implements Strategy {\n strategies: Strategy[];\n loop: boolean;\n failFast: boolean;\n timeout: number;\n timeoutLimit: number;\n\n constructor(strategies: Strategy[], options: StrategyOptions) {\n this.strategies = strategies;\n this.loop = Boolean(options.loop);\n this.failFast = Boolean(options.failFast);\n this.timeout = options.timeout;\n this.timeoutLimit = options.timeoutLimit;\n }\n\n isSupported(): boolean {\n return Collections.any(this.strategies, Util.method('isSupported'));\n }\n\n connect(minPriority: number, callback: Function) {\n var strategies = this.strategies;\n var current = 0;\n var timeout = this.timeout;\n var runner = null;\n\n var tryNextStrategy = (error, handshake) => {\n if (handshake) {\n callback(null, handshake);\n } else {\n current = current + 1;\n if (this.loop) {\n current = current % strategies.length;\n }\n\n if (current < strategies.length) {\n if (timeout) {\n timeout = timeout * 2;\n if (this.timeoutLimit) {\n timeout = Math.min(timeout, this.timeoutLimit);\n }\n }\n runner = this.tryStrategy(\n strategies[current],\n minPriority,\n { timeout, failFast: this.failFast },\n tryNextStrategy\n );\n } else {\n callback(true);\n }\n }\n };\n\n runner = this.tryStrategy(\n strategies[current],\n minPriority,\n { timeout: timeout, failFast: this.failFast },\n tryNextStrategy\n );\n\n return {\n abort: function() {\n runner.abort();\n },\n forceMinPriority: function(p) {\n minPriority = p;\n if (runner) {\n runner.forceMinPriority(p);\n }\n }\n };\n }\n\n private tryStrategy(\n strategy: Strategy,\n minPriority: number,\n options: StrategyOptions,\n callback: Function\n ) {\n var timer = null;\n var runner = null;\n\n if (options.timeout > 0) {\n timer = new Timer(options.timeout, function() {\n runner.abort();\n callback(true);\n });\n }\n\n runner = strategy.connect(minPriority, function(error, handshake) {\n if (error && timer && timer.isRunning() && !options.failFast) {\n // advance to the next strategy after the timeout\n return;\n }\n if (timer) {\n timer.ensureAborted();\n }\n callback(error, handshake);\n });\n\n return {\n abort: function() {\n if (timer) {\n timer.ensureAborted();\n }\n runner.abort();\n },\n forceMinPriority: function(p) {\n runner.forceMinPriority(p);\n }\n };\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport Strategy from './strategy';\n\n/** Launches all substrategies and emits prioritized connected transports.\n *\n * @param {Array} strategies\n */\nexport default class BestConnectedEverStrategy implements Strategy {\n strategies: Strategy[];\n\n constructor(strategies: Strategy[]) {\n this.strategies = strategies;\n }\n\n isSupported(): boolean {\n return Collections.any(this.strategies, Util.method('isSupported'));\n }\n\n connect(minPriority: number, callback: Function) {\n return connect(this.strategies, minPriority, function(i, runners) {\n return function(error, handshake) {\n runners[i].error = error;\n if (error) {\n if (allRunnersFailed(runners)) {\n callback(true);\n }\n return;\n }\n Collections.apply(runners, function(runner) {\n runner.forceMinPriority(handshake.transport.priority);\n });\n callback(null, handshake);\n };\n });\n }\n}\n\n/** Connects to all strategies in parallel.\n *\n * Callback builder should be a function that takes two arguments: index\n * and a list of runners. It should return another function that will be\n * passed to the substrategy with given index. Runners can be aborted using\n * abortRunner(s) functions from this class.\n *\n * @param {Array} strategies\n * @param {Function} callbackBuilder\n * @return {Object} strategy runner\n */\nfunction connect(\n strategies: Strategy[],\n minPriority: number,\n callbackBuilder: Function\n) {\n var runners = Collections.map(strategies, function(strategy, i, _, rs) {\n return strategy.connect(minPriority, callbackBuilder(i, rs));\n });\n return {\n abort: function() {\n Collections.apply(runners, abortRunner);\n },\n forceMinPriority: function(p) {\n Collections.apply(runners, function(runner) {\n runner.forceMinPriority(p);\n });\n }\n };\n}\n\nfunction allRunnersFailed(runners): boolean {\n return Collections.all(runners, function(runner) {\n return Boolean(runner.error);\n });\n}\n\nfunction abortRunner(runner) {\n if (!runner.error && !runner.aborted) {\n runner.abort();\n runner.aborted = true;\n }\n}\n","import Util from '../util';\nimport Runtime from 'runtime';\nimport Strategy from './strategy';\nimport SequentialStrategy from './sequential_strategy';\nimport StrategyOptions from './strategy_options';\nimport TransportStrategy from './transport_strategy';\nimport Timeline from '../timeline/timeline';\nimport * as Collections from '../utils/collections';\n\nexport interface TransportStrategyDictionary {\n [key: string]: TransportStrategy;\n}\n\n/** Caches the last successful transport and, after the first few attempts,\n * uses the cached transport for subsequent attempts.\n *\n * @param {Strategy} strategy\n * @param {Object} transports\n * @param {Object} options\n */\nexport default class WebSocketPrioritizedCachedStrategy implements Strategy {\n strategy: Strategy;\n transports: TransportStrategyDictionary;\n ttl: number;\n usingTLS: boolean;\n timeline: Timeline;\n\n constructor(\n strategy: Strategy,\n transports: TransportStrategyDictionary,\n options: StrategyOptions\n ) {\n this.strategy = strategy;\n this.transports = transports;\n this.ttl = options.ttl || 1800 * 1000;\n this.usingTLS = options.useTLS;\n this.timeline = options.timeline;\n }\n\n isSupported(): boolean {\n return this.strategy.isSupported();\n }\n\n connect(minPriority: number, callback: Function) {\n var usingTLS = this.usingTLS;\n var info = fetchTransportCache(usingTLS);\n var cacheSkipCount = info && info.cacheSkipCount ? info.cacheSkipCount : 0;\n\n var strategies = [this.strategy];\n if (info && info.timestamp + this.ttl >= Util.now()) {\n var transport = this.transports[info.transport];\n if (transport) {\n if (['ws', 'wss'].includes(info.transport) || cacheSkipCount > 3) {\n this.timeline.info({\n cached: true,\n transport: info.transport,\n latency: info.latency\n });\n strategies.push(\n new SequentialStrategy([transport], {\n timeout: info.latency * 2 + 1000,\n failFast: true\n })\n );\n } else {\n cacheSkipCount++;\n }\n }\n }\n\n var startTimestamp = Util.now();\n var runner = strategies\n .pop()\n .connect(minPriority, function cb(error, handshake) {\n if (error) {\n flushTransportCache(usingTLS);\n if (strategies.length > 0) {\n startTimestamp = Util.now();\n runner = strategies.pop().connect(minPriority, cb);\n } else {\n callback(error);\n }\n } else {\n storeTransportCache(\n usingTLS,\n handshake.transport.name,\n Util.now() - startTimestamp,\n cacheSkipCount\n );\n callback(null, handshake);\n }\n });\n\n return {\n abort: function() {\n runner.abort();\n },\n forceMinPriority: function(p) {\n minPriority = p;\n if (runner) {\n runner.forceMinPriority(p);\n }\n }\n };\n }\n}\n\nfunction getTransportCacheKey(usingTLS: boolean): string {\n return 'pusherTransport' + (usingTLS ? 'TLS' : 'NonTLS');\n}\n\nfunction fetchTransportCache(usingTLS: boolean): any {\n var storage = Runtime.getLocalStorage();\n if (storage) {\n try {\n var serializedCache = storage[getTransportCacheKey(usingTLS)];\n if (serializedCache) {\n return JSON.parse(serializedCache);\n }\n } catch (e) {\n flushTransportCache(usingTLS);\n }\n }\n return null;\n}\n\nfunction storeTransportCache(\n usingTLS: boolean,\n transport: TransportStrategy,\n latency: number,\n cacheSkipCount: number\n) {\n var storage = Runtime.getLocalStorage();\n if (storage) {\n try {\n storage[getTransportCacheKey(usingTLS)] = Collections.safeJSONStringify({\n timestamp: Util.now(),\n transport: transport,\n latency: latency,\n cacheSkipCount: cacheSkipCount\n });\n } catch (e) {\n // catch over quota exceptions raised by localStorage\n }\n }\n}\n\nfunction flushTransportCache(usingTLS: boolean) {\n var storage = Runtime.getLocalStorage();\n if (storage) {\n try {\n delete storage[getTransportCacheKey(usingTLS)];\n } catch (e) {\n // catch exceptions raised by localStorage\n }\n }\n}\n","import { OneOffTimer as Timer } from '../utils/timers';\nimport Strategy from './strategy';\nimport StrategyOptions from './strategy_options';\n\n/** Runs substrategy after specified delay.\n *\n * Options:\n * - delay - time in miliseconds to delay the substrategy attempt\n *\n * @param {Strategy} strategy\n * @param {Object} options\n */\nexport default class DelayedStrategy implements Strategy {\n strategy: Strategy;\n options: { delay: number };\n\n constructor(strategy: Strategy, { delay: number }) {\n this.strategy = strategy;\n this.options = { delay: number };\n }\n\n isSupported(): boolean {\n return this.strategy.isSupported();\n }\n\n connect(minPriority: number, callback: Function) {\n var strategy = this.strategy;\n var runner;\n var timer = new Timer(this.options.delay, function() {\n runner = strategy.connect(minPriority, callback);\n });\n\n return {\n abort: function() {\n timer.ensureAborted();\n if (runner) {\n runner.abort();\n }\n },\n forceMinPriority: function(p) {\n minPriority = p;\n if (runner) {\n runner.forceMinPriority(p);\n }\n }\n };\n }\n}\n","import Strategy from './strategy';\nimport StrategyRunner from './strategy_runner';\n\n/** Proxies method calls to one of substrategies basing on the test function.\n *\n * @param {Function} test\n * @param {Strategy} trueBranch strategy used when test returns true\n * @param {Strategy} falseBranch strategy used when test returns false\n */\nexport default class IfStrategy implements Strategy {\n test: () => boolean;\n trueBranch: Strategy;\n falseBranch: Strategy;\n\n constructor(\n test: () => boolean,\n trueBranch: Strategy,\n falseBranch: Strategy\n ) {\n this.test = test;\n this.trueBranch = trueBranch;\n this.falseBranch = falseBranch;\n }\n\n isSupported(): boolean {\n var branch = this.test() ? this.trueBranch : this.falseBranch;\n return branch.isSupported();\n }\n\n connect(minPriority: number, callback: Function): StrategyRunner {\n var branch = this.test() ? this.trueBranch : this.falseBranch;\n return branch.connect(minPriority, callback);\n }\n}\n","import Strategy from './strategy';\nimport StrategyRunner from './strategy_runner';\n\n/** Launches the substrategy and terminates on the first open connection.\n *\n * @param {Strategy} strategy\n */\nexport default class FirstConnectedStrategy implements Strategy {\n strategy: Strategy;\n\n constructor(strategy: Strategy) {\n this.strategy = strategy;\n }\n\n isSupported(): boolean {\n return this.strategy.isSupported();\n }\n\n connect(minPriority: number, callback: Function): StrategyRunner {\n var runner = this.strategy.connect(minPriority, function(error, handshake) {\n if (handshake) {\n runner.abort();\n }\n callback(error, handshake);\n });\n return runner;\n }\n}\n","import * as Collections from 'core/utils/collections';\nimport TransportManager from 'core/transports/transport_manager';\nimport Strategy from 'core/strategies/strategy';\nimport SequentialStrategy from 'core/strategies/sequential_strategy';\nimport BestConnectedEverStrategy from 'core/strategies/best_connected_ever_strategy';\nimport WebSocketPrioritizedCachedStrategy, {\n TransportStrategyDictionary\n} from 'core/strategies/websocket_prioritized_cached_strategy';\nimport DelayedStrategy from 'core/strategies/delayed_strategy';\nimport IfStrategy from 'core/strategies/if_strategy';\nimport FirstConnectedStrategy from 'core/strategies/first_connected_strategy';\nimport { Config } from 'core/config';\nimport StrategyOptions from 'core/strategies/strategy_options';\n\nfunction testSupportsStrategy(strategy: Strategy) {\n return function() {\n return strategy.isSupported();\n };\n}\n\nvar getDefaultStrategy = function(\n config: Config,\n baseOptions: StrategyOptions,\n defineTransport: Function\n): Strategy {\n var definedTransports = {};\n\n function defineTransportStrategy(\n name: string,\n type: string,\n priority: number,\n options: StrategyOptions,\n manager?: TransportManager\n ) {\n var transport = defineTransport(\n config,\n name,\n type,\n priority,\n options,\n manager\n );\n\n definedTransports[name] = transport;\n\n return transport;\n }\n\n var ws_options: StrategyOptions = Object.assign({}, baseOptions, {\n hostNonTLS: config.wsHost + ':' + config.wsPort,\n hostTLS: config.wsHost + ':' + config.wssPort,\n httpPath: config.wsPath\n });\n var wss_options: StrategyOptions = Collections.extend({}, ws_options, {\n useTLS: true\n });\n var http_options: StrategyOptions = Object.assign({}, baseOptions, {\n hostNonTLS: config.httpHost + ':' + config.httpPort,\n hostTLS: config.httpHost + ':' + config.httpsPort,\n httpPath: config.httpPath\n });\n var timeouts = {\n loop: true,\n timeout: 15000,\n timeoutLimit: 60000\n };\n\n var ws_manager = new TransportManager({\n minPingDelay: 10000,\n maxPingDelay: config.activityTimeout\n });\n var streaming_manager = new TransportManager({\n lives: 2,\n minPingDelay: 10000,\n maxPingDelay: config.activityTimeout\n });\n\n var ws_transport = defineTransportStrategy(\n 'ws',\n 'ws',\n 3,\n ws_options,\n ws_manager\n );\n var wss_transport = defineTransportStrategy(\n 'wss',\n 'ws',\n 3,\n wss_options,\n ws_manager\n );\n var xhr_streaming_transport = defineTransportStrategy(\n 'xhr_streaming',\n 'xhr_streaming',\n 1,\n http_options,\n streaming_manager\n );\n var xhr_polling_transport = defineTransportStrategy(\n 'xhr_polling',\n 'xhr_polling',\n 1,\n http_options\n );\n\n var ws_loop = new SequentialStrategy([ws_transport], timeouts);\n var wss_loop = new SequentialStrategy([wss_transport], timeouts);\n var streaming_loop = new SequentialStrategy(\n [xhr_streaming_transport],\n timeouts\n );\n var polling_loop = new SequentialStrategy([xhr_polling_transport], timeouts);\n\n var http_loop = new SequentialStrategy(\n [\n new IfStrategy(\n testSupportsStrategy(streaming_loop),\n new BestConnectedEverStrategy([\n streaming_loop,\n new DelayedStrategy(polling_loop, { delay: 4000 })\n ]),\n polling_loop\n )\n ],\n timeouts\n );\n\n var wsStrategy;\n if (baseOptions.useTLS) {\n wsStrategy = new BestConnectedEverStrategy([\n ws_loop,\n new DelayedStrategy(http_loop, { delay: 2000 })\n ]);\n } else {\n wsStrategy = new BestConnectedEverStrategy([\n ws_loop,\n new DelayedStrategy(wss_loop, { delay: 2000 }),\n new DelayedStrategy(http_loop, { delay: 5000 })\n ]);\n }\n\n return new WebSocketPrioritizedCachedStrategy(\n new FirstConnectedStrategy(\n new IfStrategy(testSupportsStrategy(ws_transport), wsStrategy, http_loop)\n ),\n definedTransports,\n {\n ttl: 1800000,\n timeline: baseOptions.timeline,\n useTLS: baseOptions.useTLS\n }\n );\n};\n\nexport default getDefaultStrategy;\n","/** Initializes the transport.\n *\n * Fetches resources if needed and then transitions to initialized.\n */\nexport default function() {\n var self = this;\n\n self.timeline.info(\n self.buildTimelineMessage({\n transport: self.name + (self.options.useTLS ? 's' : '')\n })\n );\n\n if (self.hooks.isInitialized()) {\n self.changeState('initialized');\n } else {\n self.onClose();\n }\n}\n","import Runtime from 'runtime';\nimport RequestHooks from './request_hooks';\nimport Ajax from './ajax';\nimport { default as EventsDispatcher } from '../events/dispatcher';\n\nconst MAX_BUFFER_LENGTH = 256 * 1024;\n\nexport default class HTTPRequest extends EventsDispatcher {\n hooks: RequestHooks;\n method: string;\n url: string;\n position: number;\n xhr: Ajax;\n unloader: Function;\n\n constructor(hooks: RequestHooks, method: string, url: string) {\n super();\n this.hooks = hooks;\n this.method = method;\n this.url = url;\n }\n\n start(payload?: any) {\n this.position = 0;\n this.xhr = this.hooks.getRequest(this);\n\n this.unloader = () => {\n this.close();\n };\n Runtime.addUnloadListener(this.unloader);\n\n this.xhr.open(this.method, this.url, true);\n\n if (this.xhr.setRequestHeader) {\n this.xhr.setRequestHeader('Content-Type', 'application/json'); // ReactNative doesn't set this header by default.\n }\n this.xhr.send(payload);\n }\n\n close() {\n if (this.unloader) {\n Runtime.removeUnloadListener(this.unloader);\n this.unloader = null;\n }\n if (this.xhr) {\n this.hooks.abortRequest(this.xhr);\n this.xhr = null;\n }\n }\n\n onChunk(status: number, data: any) {\n while (true) {\n var chunk = this.advanceBuffer(data);\n if (chunk) {\n this.emit('chunk', { status: status, data: chunk });\n } else {\n break;\n }\n }\n if (this.isBufferTooLong(data)) {\n this.emit('buffer_too_long');\n }\n }\n\n private advanceBuffer(buffer: any[]): any {\n var unreadData = buffer.slice(this.position);\n var endOfLinePosition = unreadData.indexOf('\\n');\n\n if (endOfLinePosition !== -1) {\n this.position += endOfLinePosition + 1;\n return unreadData.slice(0, endOfLinePosition);\n } else {\n // chunk is not finished yet, don't move the buffer pointer\n return null;\n }\n }\n\n private isBufferTooLong(buffer: any): boolean {\n return this.position === buffer.length && buffer.length > MAX_BUFFER_LENGTH;\n }\n}\n","enum State {\n CONNECTING = 0,\n OPEN = 1,\n CLOSED = 3\n}\n\nexport default State;\n","import URLLocation from './url_location';\nimport State from './state';\nimport Socket from '../socket';\nimport SocketHooks from './socket_hooks';\nimport Util from '../util';\nimport Ajax from './ajax';\nimport HTTPRequest from './http_request';\nimport Runtime from 'runtime';\n\nvar autoIncrement = 1;\n\nclass HTTPSocket implements Socket {\n hooks: SocketHooks;\n session: string;\n location: URLLocation;\n readyState: State;\n stream: HTTPRequest;\n\n onopen: () => void;\n onerror: (error: any) => void;\n onclose: (closeEvent: any) => void;\n onmessage: (message: any) => void;\n onactivity: () => void;\n\n constructor(hooks: SocketHooks, url: string) {\n this.hooks = hooks;\n this.session = randomNumber(1000) + '/' + randomString(8);\n this.location = getLocation(url);\n this.readyState = State.CONNECTING;\n this.openStream();\n }\n\n send(payload: any) {\n return this.sendRaw(JSON.stringify([payload]));\n }\n\n ping() {\n this.hooks.sendHeartbeat(this);\n }\n\n close(code: any, reason: any) {\n this.onClose(code, reason, true);\n }\n\n /** For internal use only */\n sendRaw(payload: any): boolean {\n if (this.readyState === State.OPEN) {\n try {\n Runtime.createSocketRequest(\n 'POST',\n getUniqueURL(getSendURL(this.location, this.session))\n ).start(payload);\n return true;\n } catch (e) {\n return false;\n }\n } else {\n return false;\n }\n }\n\n /** For internal use only */\n reconnect() {\n this.closeStream();\n this.openStream();\n }\n\n /** For internal use only */\n onClose(code, reason, wasClean) {\n this.closeStream();\n this.readyState = State.CLOSED;\n if (this.onclose) {\n this.onclose({\n code: code,\n reason: reason,\n wasClean: wasClean\n });\n }\n }\n\n private onChunk(chunk) {\n if (chunk.status !== 200) {\n return;\n }\n if (this.readyState === State.OPEN) {\n this.onActivity();\n }\n\n var payload;\n var type = chunk.data.slice(0, 1);\n switch (type) {\n case 'o':\n payload = JSON.parse(chunk.data.slice(1) || '{}');\n this.onOpen(payload);\n break;\n case 'a':\n payload = JSON.parse(chunk.data.slice(1) || '[]');\n for (var i = 0; i < payload.length; i++) {\n this.onEvent(payload[i]);\n }\n break;\n case 'm':\n payload = JSON.parse(chunk.data.slice(1) || 'null');\n this.onEvent(payload);\n break;\n case 'h':\n this.hooks.onHeartbeat(this);\n break;\n case 'c':\n payload = JSON.parse(chunk.data.slice(1) || '[]');\n this.onClose(payload[0], payload[1], true);\n break;\n }\n }\n\n private onOpen(options) {\n if (this.readyState === State.CONNECTING) {\n if (options && options.hostname) {\n this.location.base = replaceHost(this.location.base, options.hostname);\n }\n this.readyState = State.OPEN;\n\n if (this.onopen) {\n this.onopen();\n }\n } else {\n this.onClose(1006, 'Server lost session', true);\n }\n }\n\n private onEvent(event) {\n if (this.readyState === State.OPEN && this.onmessage) {\n this.onmessage({ data: event });\n }\n }\n\n private onActivity() {\n if (this.onactivity) {\n this.onactivity();\n }\n }\n\n private onError(error) {\n if (this.onerror) {\n this.onerror(error);\n }\n }\n\n private openStream() {\n this.stream = Runtime.createSocketRequest(\n 'POST',\n getUniqueURL(this.hooks.getReceiveURL(this.location, this.session))\n );\n\n this.stream.bind('chunk', chunk => {\n this.onChunk(chunk);\n });\n this.stream.bind('finished', status => {\n this.hooks.onFinished(this, status);\n });\n this.stream.bind('buffer_too_long', () => {\n this.reconnect();\n });\n\n try {\n this.stream.start();\n } catch (error) {\n Util.defer(() => {\n this.onError(error);\n this.onClose(1006, 'Could not start streaming', false);\n });\n }\n }\n\n private closeStream() {\n if (this.stream) {\n this.stream.unbind_all();\n this.stream.close();\n this.stream = null;\n }\n }\n}\n\nfunction getLocation(url): URLLocation {\n var parts = /([^\\?]*)\\/*(\\??.*)/.exec(url);\n return {\n base: parts[1],\n queryString: parts[2]\n };\n}\n\nfunction getSendURL(url: URLLocation, session: string): string {\n return url.base + '/' + session + '/xhr_send';\n}\n\nfunction getUniqueURL(url: string): string {\n var separator = url.indexOf('?') === -1 ? '?' : '&';\n return url + separator + 't=' + +new Date() + '&n=' + autoIncrement++;\n}\n\nfunction replaceHost(url: string, hostname: string): string {\n var urlParts = /(https?:\\/\\/)([^\\/:]+)((\\/|:)?.*)/.exec(url);\n return urlParts[1] + hostname + urlParts[3];\n}\n\nfunction randomNumber(max: number): number {\n return Runtime.randomInt(max);\n}\n\nfunction randomString(length: number): string {\n var result = [];\n\n for (var i = 0; i < length; i++) {\n result.push(randomNumber(32).toString(32));\n }\n\n return result.join('');\n}\n\nexport default HTTPSocket;\n","import SocketHooks from './socket_hooks';\nimport HTTPSocket from './http_socket';\n\nvar hooks: SocketHooks = {\n getReceiveURL: function(url, session) {\n return url.base + '/' + session + '/xhr_streaming' + url.queryString;\n },\n onHeartbeat: function(socket) {\n socket.sendRaw('[]');\n },\n sendHeartbeat: function(socket) {\n socket.sendRaw('[]');\n },\n onFinished: function(socket, status) {\n socket.onClose(1006, 'Connection interrupted (' + status + ')', false);\n }\n};\n\nexport default hooks;\n","import SocketHooks from './socket_hooks';\nimport URLLocation from './url_location';\nimport HTTPSocket from './http_socket';\n\nvar hooks: SocketHooks = {\n getReceiveURL: function(url: URLLocation, session: string): string {\n return url.base + '/' + session + '/xhr' + url.queryString;\n },\n onHeartbeat: function() {\n // next HTTP request will reset server's activity timer\n },\n sendHeartbeat: function(socket) {\n socket.sendRaw('[]');\n },\n onFinished: function(socket, status) {\n if (status === 200) {\n socket.reconnect();\n } else {\n socket.onClose(1006, 'Connection interrupted (' + status + ')', false);\n }\n }\n};\n\nexport default hooks;\n","import HTTPRequest from 'core/http/http_request';\nimport RequestHooks from 'core/http/request_hooks';\nimport Ajax from 'core/http/ajax';\nimport Runtime from 'runtime';\n\nvar hooks: RequestHooks = {\n getRequest: function(socket: HTTPRequest): Ajax {\n var Constructor = Runtime.getXHRAPI();\n var xhr = new Constructor();\n xhr.onreadystatechange = xhr.onprogress = function() {\n switch (xhr.readyState) {\n case 3:\n if (xhr.responseText && xhr.responseText.length > 0) {\n socket.onChunk(xhr.status, xhr.responseText);\n }\n break;\n case 4:\n // this happens only on errors, never after calling close\n if (xhr.responseText && xhr.responseText.length > 0) {\n socket.onChunk(xhr.status, xhr.responseText);\n }\n socket.emit('finished', xhr.status);\n socket.close();\n break;\n }\n };\n return xhr;\n },\n abortRequest: function(xhr: Ajax) {\n xhr.onreadystatechange = null;\n xhr.abort();\n }\n};\n\nexport default hooks;\n","import HTTPRequest from 'core/http/http_request';\nimport HTTPSocket from 'core/http/http_socket';\nimport SocketHooks from 'core/http/socket_hooks';\nimport RequestHooks from 'core/http/request_hooks';\nimport streamingHooks from 'core/http/http_streaming_socket';\nimport pollingHooks from 'core/http/http_polling_socket';\nimport xhrHooks from './http_xhr_request';\nimport HTTPFactory from 'core/http/http_factory';\n\nvar HTTP: HTTPFactory = {\n createStreamingSocket(url: string): HTTPSocket {\n return this.createSocket(streamingHooks, url);\n },\n\n createPollingSocket(url: string): HTTPSocket {\n return this.createSocket(pollingHooks, url);\n },\n\n createSocket(hooks: SocketHooks, url: string): HTTPSocket {\n return new HTTPSocket(hooks, url);\n },\n\n createXHR(method: string, url: string): HTTPRequest {\n return this.createRequest(xhrHooks, method, url);\n },\n\n createRequest(hooks: RequestHooks, method: string, url: string): HTTPRequest {\n return new HTTPRequest(hooks, method, url);\n }\n};\n\nexport default HTTP;\n","import * as Collections from 'core/utils/collections';\nimport Transports from 'isomorphic/transports/transports';\nimport TimelineSender from 'core/timeline/timeline_sender';\nimport Ajax from 'core/http/ajax';\nimport getDefaultStrategy from './default_strategy';\nimport TransportsTable from 'core/transports/transports_table';\nimport transportConnectionInitializer from './transports/transport_connection_initializer';\nimport HTTPFactory from './http/http';\n\nvar Isomorphic: any = {\n getDefaultStrategy,\n Transports: Transports,\n transportConnectionInitializer,\n HTTPFactory,\n\n setup(PusherClass): void {\n PusherClass.ready();\n },\n\n getLocalStorage(): any {\n return undefined;\n },\n\n getClientFeatures(): any[] {\n return Collections.keys(\n Collections.filterObject({ ws: Transports.ws }, function(t) {\n return t.isSupported({});\n })\n );\n },\n\n getProtocol(): string {\n return 'http:';\n },\n\n isXHRSupported(): boolean {\n return true;\n },\n\n createSocketRequest(method: string, url: string) {\n if (this.isXHRSupported()) {\n return this.HTTPFactory.createXHR(method, url);\n } else {\n throw 'Cross-origin HTTP requests are not supported';\n }\n },\n\n createXHR(): Ajax {\n var Constructor = this.getXHRAPI();\n return new Constructor();\n },\n\n createWebSocket(url: string): any {\n var Constructor = this.getWebSocketAPI();\n return new Constructor(url);\n },\n\n addUnloadListener(listener: any) {},\n removeUnloadListener(listener: any) {}\n};\n\nexport default Isomorphic;\n","import { default as EventsDispatcher } from 'core/events/dispatcher';\nimport Reachability from 'core/reachability';\n\nexport class NetInfo extends EventsDispatcher implements Reachability {\n isOnline(): boolean {\n return true;\n }\n}\n\nexport var Network = new NetInfo();\n","import AbstractRuntime from 'runtimes/interface';\nimport { AuthTransport } from 'core/auth/auth_transports';\nimport {\n AuthRequestType,\n AuthTransportCallback,\n InternalAuthOptions\n} from 'core/auth/options';\nimport { HTTPAuthError } from 'core/errors';\n\nvar fetchAuth: AuthTransport = function(\n context: AbstractRuntime,\n query: string,\n authOptions: InternalAuthOptions,\n authRequestType: AuthRequestType,\n callback: AuthTransportCallback\n) {\n var headers = new Headers();\n headers.set('Content-Type', 'application/x-www-form-urlencoded');\n\n for (var headerName in authOptions.headers) {\n headers.set(headerName, authOptions.headers[headerName]);\n }\n\n if (authOptions.headersProvider != null) {\n const dynamicHeaders = authOptions.headersProvider();\n for (var headerName in dynamicHeaders) {\n headers.set(headerName, dynamicHeaders[headerName]);\n }\n }\n\n var body = query;\n var request = new Request(authOptions.endpoint, {\n headers,\n body,\n credentials: 'same-origin',\n method: 'POST'\n });\n\n return fetch(request)\n .then(response => {\n let { status } = response;\n if (status === 200) {\n // manually parse the json so we can provide a more helpful error in\n // failure case\n return response.text();\n }\n throw new HTTPAuthError(\n status,\n `Could not get ${authRequestType.toString()} info from your auth endpoint, status: ${status}`\n );\n })\n .then(data => {\n let parsedData;\n try {\n parsedData = JSON.parse(data);\n } catch (e) {\n throw new HTTPAuthError(\n 200,\n `JSON returned from ${authRequestType.toString()} endpoint was invalid, yet status code was 200. Data was: ${data}`\n );\n }\n callback(null, parsedData);\n })\n .catch(err => {\n callback(err, null);\n });\n};\n\nexport default fetchAuth;\n","import Logger from 'core/logger';\nimport TimelineSender from 'core/timeline/timeline_sender';\nimport * as Collections from 'core/utils/collections';\nimport Util from 'core/util';\nimport Runtime from 'runtime';\nimport TimelineTransport from 'core/timeline/timeline_transport';\n\nvar getAgent = function(sender: TimelineSender, useTLS: boolean) {\n return function(data: any, callback: Function) {\n var scheme = 'http' + (useTLS ? 's' : '') + '://';\n var url =\n scheme + (sender.host || sender.options.host) + sender.options.path;\n var query = Collections.buildQueryString(data);\n url += '/' + 2 + '?' + query;\n\n fetch(url)\n .then(response => {\n if (response.status !== 200) {\n throw `received ${response.status} from stats.pusher.com`;\n }\n return response.json();\n })\n .then(({ host }) => {\n if (host) {\n sender.host = host;\n }\n })\n .catch(err => {\n Logger.debug('TimelineSender Error: ', err);\n });\n };\n};\n\nvar fetchTimeline = {\n name: 'xhr',\n getAgent\n};\n\nexport default fetchTimeline;\n","import Isomorphic from 'isomorphic/runtime';\nimport Runtime from '../interface';\nimport { Network } from './net_info';\nimport fetchAuth from './auth/fetch_auth';\nimport { AuthTransports } from 'core/auth/auth_transports';\nimport fetchTimeline from './timeline/fetch_timeline';\n\n// Very verbose but until unavoidable until\n// TypeScript 2.1, when spread attributes will be\n// supported\nconst {\n getDefaultStrategy,\n Transports,\n setup,\n getProtocol,\n isXHRSupported,\n getLocalStorage,\n createXHR,\n createWebSocket,\n addUnloadListener,\n removeUnloadListener,\n transportConnectionInitializer,\n createSocketRequest,\n HTTPFactory\n} = Isomorphic;\n\nconst Worker: Runtime = {\n getDefaultStrategy,\n Transports,\n setup,\n getProtocol,\n isXHRSupported,\n getLocalStorage,\n createXHR,\n createWebSocket,\n addUnloadListener,\n removeUnloadListener,\n transportConnectionInitializer,\n createSocketRequest,\n HTTPFactory,\n\n TimelineTransport: fetchTimeline,\n\n getAuthorizers(): AuthTransports {\n return { ajax: fetchAuth };\n },\n\n getWebSocketAPI() {\n return WebSocket;\n },\n\n getXHRAPI() {\n return XMLHttpRequest;\n },\n\n getNetwork() {\n return Network;\n },\n\n randomInt(max: number): number {\n /**\n * Return values in the range of [0, 1[\n */\n const random = function() {\n const crypto = globalThis.crypto || globalThis['msCrypto'];\n const random = crypto.getRandomValues(new Uint32Array(1))[0];\n\n return random / 2 ** 32;\n };\n\n return Math.floor(random() * max);\n }\n};\n\nexport default Worker;\n","enum TimelineLevel {\n ERROR = 3,\n INFO = 6,\n DEBUG = 7\n}\n\nexport default TimelineLevel;\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport { default as Level } from './level';\n\nexport interface TimelineOptions {\n level?: Level;\n limit?: number;\n version?: string;\n cluster?: string;\n features?: string[];\n params?: any;\n}\n\nexport default class Timeline {\n key: string;\n session: number;\n events: any[];\n options: TimelineOptions;\n sent: number;\n uniqueID: number;\n\n constructor(key: string, session: number, options: TimelineOptions) {\n this.key = key;\n this.session = session;\n this.events = [];\n this.options = options || {};\n this.sent = 0;\n this.uniqueID = 0;\n }\n\n log(level, event) {\n if (level <= this.options.level) {\n this.events.push(\n Collections.extend({}, event, { timestamp: Util.now() })\n );\n if (this.options.limit && this.events.length > this.options.limit) {\n this.events.shift();\n }\n }\n }\n\n error(event) {\n this.log(Level.ERROR, event);\n }\n\n info(event) {\n this.log(Level.INFO, event);\n }\n\n debug(event) {\n this.log(Level.DEBUG, event);\n }\n\n isEmpty() {\n return this.events.length === 0;\n }\n\n send(sendfn, callback) {\n var data = Collections.extend(\n {\n session: this.session,\n bundle: this.sent + 1,\n key: this.key,\n lib: 'js',\n version: this.options.version,\n cluster: this.options.cluster,\n features: this.options.features,\n timeline: this.events\n },\n this.options.params\n );\n\n this.events = [];\n sendfn(data, (error, result) => {\n if (!error) {\n this.sent++;\n }\n if (callback) {\n callback(error, result);\n }\n });\n\n return true;\n }\n\n generateUniqueID(): number {\n this.uniqueID++;\n return this.uniqueID;\n }\n}\n","import Factory from '../utils/factory';\nimport Util from '../util';\nimport * as Errors from '../errors';\nimport * as Collections from '../utils/collections';\nimport Strategy from './strategy';\nimport Transport from '../transports/transport';\nimport StrategyOptions from './strategy_options';\nimport Handshake from '../connection/handshake';\n\n/** Provides a strategy interface for transports.\n *\n * @param {String} name\n * @param {Number} priority\n * @param {Class} transport\n * @param {Object} options\n */\nexport default class TransportStrategy implements Strategy {\n name: string;\n priority: number;\n transport: Transport;\n options: StrategyOptions;\n\n constructor(\n name: string,\n priority: number,\n transport: Transport,\n options: StrategyOptions\n ) {\n this.name = name;\n this.priority = priority;\n this.transport = transport;\n this.options = options || {};\n }\n\n /** Returns whether the transport is supported in the browser.\n *\n * @returns {Boolean}\n */\n isSupported(): boolean {\n return this.transport.isSupported({\n useTLS: this.options.useTLS\n });\n }\n\n /** Launches a connection attempt and returns a strategy runner.\n *\n * @param {Function} callback\n * @return {Object} strategy runner\n */\n connect(minPriority: number, callback: Function) {\n if (!this.isSupported()) {\n return failAttempt(new Errors.UnsupportedStrategy(), callback);\n } else if (this.priority < minPriority) {\n return failAttempt(new Errors.TransportPriorityTooLow(), callback);\n }\n\n var connected = false;\n var transport = this.transport.createConnection(\n this.name,\n this.priority,\n this.options.key,\n this.options\n );\n var handshake = null;\n\n var onInitialized = function() {\n transport.unbind('initialized', onInitialized);\n transport.connect();\n };\n var onOpen = function() {\n handshake = Factory.createHandshake(transport, function(result) {\n connected = true;\n unbindListeners();\n callback(null, result);\n });\n };\n var onError = function(error) {\n unbindListeners();\n callback(error);\n };\n var onClosed = function() {\n unbindListeners();\n var serializedTransport;\n\n // The reason for this try/catch block is that on React Native\n // the WebSocket object is circular. Therefore transport.socket will\n // throw errors upon stringification. Collections.safeJSONStringify\n // discards circular references when serializing.\n serializedTransport = Collections.safeJSONStringify(transport);\n callback(new Errors.TransportClosed(serializedTransport));\n };\n\n var unbindListeners = function() {\n transport.unbind('initialized', onInitialized);\n transport.unbind('open', onOpen);\n transport.unbind('error', onError);\n transport.unbind('closed', onClosed);\n };\n\n transport.bind('initialized', onInitialized);\n transport.bind('open', onOpen);\n transport.bind('error', onError);\n transport.bind('closed', onClosed);\n\n // connect will be called automatically after initialization\n transport.initialize();\n\n return {\n abort: () => {\n if (connected) {\n return;\n }\n unbindListeners();\n if (handshake) {\n handshake.close();\n } else {\n transport.close();\n }\n },\n forceMinPriority: p => {\n if (connected) {\n return;\n }\n if (this.priority < p) {\n if (handshake) {\n handshake.close();\n } else {\n transport.close();\n }\n }\n }\n };\n }\n}\n\nfunction failAttempt(error: Error, callback: Function) {\n Util.defer(function() {\n callback(error);\n });\n return {\n abort: function() {},\n forceMinPriority: function() {}\n };\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport TransportManager from '../transports/transport_manager';\nimport * as Errors from '../errors';\nimport Strategy from './strategy';\nimport TransportStrategy from './transport_strategy';\nimport StrategyOptions from '../strategies/strategy_options';\nimport { Config } from '../config';\nimport Runtime from 'runtime';\n\nconst { Transports } = Runtime;\n\nexport var defineTransport = function(\n config: Config,\n name: string,\n type: string,\n priority: number,\n options: StrategyOptions,\n manager?: TransportManager\n): Strategy {\n var transportClass = Transports[type];\n if (!transportClass) {\n throw new Errors.UnsupportedTransport(type);\n }\n\n var enabled =\n (!config.enabledTransports ||\n Collections.arrayIndexOf(config.enabledTransports, name) !== -1) &&\n (!config.disabledTransports ||\n Collections.arrayIndexOf(config.disabledTransports, name) === -1);\n\n var transport;\n if (enabled) {\n options = Object.assign(\n { ignoreNullOrigin: config.ignoreNullOrigin },\n options\n );\n\n transport = new TransportStrategy(\n name,\n priority,\n manager ? manager.getAssistant(transportClass) : transportClass,\n options\n );\n } else {\n transport = UnsupportedStrategy;\n }\n\n return transport;\n};\n\nvar UnsupportedStrategy: Strategy = {\n isSupported: function() {\n return false;\n },\n connect: function(_, callback) {\n var deferred = Util.defer(function() {\n callback(new Errors.UnsupportedStrategy());\n });\n return {\n abort: function() {\n deferred.ensureAborted();\n },\n forceMinPriority: function() {}\n };\n }\n};\n","import ConnectionManager from './connection/connection_manager';\nimport {\n ChannelAuthorizationOptions,\n UserAuthenticationOptions\n} from './auth/options';\nimport {\n ChannelAuthorizerGenerator,\n DeprecatedAuthOptions\n} from './auth/deprecated_channel_authorizer';\nimport { AuthTransport, Transport } from './config';\nimport * as nacl from 'tweetnacl';\nimport Logger from './logger';\n\nexport interface Options {\n activityTimeout?: number;\n\n auth?: DeprecatedAuthOptions; // DEPRECATED use channelAuthorization instead\n authEndpoint?: string; // DEPRECATED use channelAuthorization instead\n authTransport?: AuthTransport; // DEPRECATED use channelAuthorization instead\n authorizer?: ChannelAuthorizerGenerator; // DEPRECATED use channelAuthorization instead\n\n channelAuthorization?: ChannelAuthorizationOptions;\n userAuthentication?: UserAuthenticationOptions;\n\n cluster: string;\n enableStats?: boolean;\n disableStats?: boolean;\n disabledTransports?: Transport[];\n enabledTransports?: Transport[];\n forceTLS?: boolean;\n httpHost?: string;\n httpPath?: string;\n httpPort?: number;\n httpsPort?: number;\n ignoreNullOrigin?: boolean;\n nacl?: nacl;\n pongTimeout?: number;\n statsHost?: string;\n timelineParams?: any;\n unavailableTimeout?: number;\n wsHost?: string;\n wsPath?: string;\n wsPort?: number;\n wssPort?: number;\n}\n\nexport interface ClusterOptions {\n appKey: string;\n cluster: string;\n}\n\nexport function validateOptions(options) {\n if (options == null) {\n throw 'You must pass an options object';\n }\n if (options.cluster == null) {\n throw 'Options object must provide a cluster';\n }\n if ('disableStats' in options) {\n Logger.warn(\n 'The disableStats option is deprecated in favor of enableStats'\n );\n }\n}\n","export enum AuthRequestType {\n UserAuthentication = 'user-authentication',\n ChannelAuthorization = 'channel-authorization'\n}\n\nexport interface ChannelAuthorizationData {\n auth: string;\n channel_data?: string;\n shared_secret?: string;\n}\n\nexport type ChannelAuthorizationCallback = (\n error: Error | null,\n authData: ChannelAuthorizationData | null\n) => void;\n\nexport interface ChannelAuthorizationRequestParams {\n socketId: string;\n channelName: string;\n}\n\nexport interface ChannelAuthorizationHandler {\n (\n params: ChannelAuthorizationRequestParams,\n callback: ChannelAuthorizationCallback\n ): void;\n}\n\nexport interface UserAuthenticationData {\n auth: string;\n user_data: string;\n}\n\nexport type UserAuthenticationCallback = (\n error: Error | null,\n authData: UserAuthenticationData | null\n) => void;\n\nexport interface UserAuthenticationRequestParams {\n socketId: string;\n}\n\nexport interface UserAuthenticationHandler {\n (\n params: UserAuthenticationRequestParams,\n callback: UserAuthenticationCallback\n ): void;\n}\n\nexport type AuthTransportCallback =\n | ChannelAuthorizationCallback\n | UserAuthenticationCallback;\n\nexport interface AuthOptionsT {\n transport: 'ajax' | 'jsonp';\n endpoint: string;\n params?: any;\n headers?: any;\n paramsProvider?: () => any;\n headersProvider?: () => any;\n customHandler?: AuthHandler;\n}\n\nexport declare type UserAuthenticationOptions = AuthOptionsT<\n UserAuthenticationHandler\n>;\nexport declare type ChannelAuthorizationOptions = AuthOptionsT<\n ChannelAuthorizationHandler\n>;\n\nexport interface InternalAuthOptions {\n transport: 'ajax' | 'jsonp';\n endpoint: string;\n params?: any;\n headers?: any;\n paramsProvider?: () => any;\n headersProvider?: () => any;\n}\n","import {\n UserAuthenticationCallback,\n InternalAuthOptions,\n UserAuthenticationHandler,\n UserAuthenticationRequestParams,\n AuthRequestType\n} from './options';\n\nimport Runtime from 'runtime';\n\nconst composeChannelQuery = (\n params: UserAuthenticationRequestParams,\n authOptions: InternalAuthOptions\n) => {\n var query = 'socket_id=' + encodeURIComponent(params.socketId);\n\n for (var key in authOptions.params) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(authOptions.params[key]);\n }\n\n if (authOptions.paramsProvider != null) {\n let dynamicParams = authOptions.paramsProvider();\n for (var key in dynamicParams) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(dynamicParams[key]);\n }\n }\n\n return query;\n};\n\nconst UserAuthenticator = (\n authOptions: InternalAuthOptions\n): UserAuthenticationHandler => {\n if (typeof Runtime.getAuthorizers()[authOptions.transport] === 'undefined') {\n throw `'${authOptions.transport}' is not a recognized auth transport`;\n }\n\n return (\n params: UserAuthenticationRequestParams,\n callback: UserAuthenticationCallback\n ) => {\n const query = composeChannelQuery(params, authOptions);\n\n Runtime.getAuthorizers()[authOptions.transport](\n Runtime,\n query,\n authOptions,\n AuthRequestType.UserAuthentication,\n callback\n );\n };\n};\n\nexport default UserAuthenticator;\n","import {\n AuthRequestType,\n InternalAuthOptions,\n ChannelAuthorizationHandler,\n ChannelAuthorizationRequestParams,\n ChannelAuthorizationCallback\n} from './options';\n\nimport Runtime from 'runtime';\n\nconst composeChannelQuery = (\n params: ChannelAuthorizationRequestParams,\n authOptions: InternalAuthOptions\n) => {\n var query = 'socket_id=' + encodeURIComponent(params.socketId);\n\n query += '&channel_name=' + encodeURIComponent(params.channelName);\n\n for (var key in authOptions.params) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(authOptions.params[key]);\n }\n\n if (authOptions.paramsProvider != null) {\n let dynamicParams = authOptions.paramsProvider();\n for (var key in dynamicParams) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(dynamicParams[key]);\n }\n }\n\n return query;\n};\n\nconst ChannelAuthorizer = (\n authOptions: InternalAuthOptions\n): ChannelAuthorizationHandler => {\n if (typeof Runtime.getAuthorizers()[authOptions.transport] === 'undefined') {\n throw `'${authOptions.transport}' is not a recognized auth transport`;\n }\n\n return (\n params: ChannelAuthorizationRequestParams,\n callback: ChannelAuthorizationCallback\n ) => {\n const query = composeChannelQuery(params, authOptions);\n\n Runtime.getAuthorizers()[authOptions.transport](\n Runtime,\n query,\n authOptions,\n AuthRequestType.ChannelAuthorization,\n callback\n );\n };\n};\n\nexport default ChannelAuthorizer;\n","import Channel from '../channels/channel';\nimport {\n ChannelAuthorizationCallback,\n ChannelAuthorizationHandler,\n ChannelAuthorizationRequestParams,\n InternalAuthOptions\n} from './options';\n\nexport interface DeprecatedChannelAuthorizer {\n authorize(socketId: string, callback: ChannelAuthorizationCallback): void;\n}\n\nexport interface ChannelAuthorizerGenerator {\n (\n channel: Channel,\n options: DeprecatedAuthorizerOptions\n ): DeprecatedChannelAuthorizer;\n}\n\nexport interface DeprecatedAuthOptions {\n params?: any;\n headers?: any;\n}\n\nexport interface DeprecatedAuthorizerOptions {\n authTransport: 'ajax' | 'jsonp';\n authEndpoint: string;\n auth?: DeprecatedAuthOptions;\n}\n\nexport const ChannelAuthorizerProxy = (\n pusher,\n authOptions: InternalAuthOptions,\n channelAuthorizerGenerator: ChannelAuthorizerGenerator\n): ChannelAuthorizationHandler => {\n const deprecatedAuthorizerOptions: DeprecatedAuthorizerOptions = {\n authTransport: authOptions.transport,\n authEndpoint: authOptions.endpoint,\n auth: {\n params: authOptions.params,\n headers: authOptions.headers\n }\n };\n return (\n params: ChannelAuthorizationRequestParams,\n callback: ChannelAuthorizationCallback\n ) => {\n const channel = pusher.channel(params.channelName);\n // This line creates a new channel authorizer every time.\n // In the past, this was only done once per channel and reused.\n // We can do that again if we want to keep this behavior intact.\n const channelAuthorizer: DeprecatedChannelAuthorizer = channelAuthorizerGenerator(\n channel,\n deprecatedAuthorizerOptions\n );\n channelAuthorizer.authorize(params.socketId, callback);\n };\n};\n","import { Options } from './options';\nimport Defaults from './defaults';\nimport {\n ChannelAuthorizationHandler,\n UserAuthenticationHandler,\n ChannelAuthorizationOptions\n} from './auth/options';\nimport UserAuthenticator from './auth/user_authenticator';\nimport ChannelAuthorizer from './auth/channel_authorizer';\nimport { ChannelAuthorizerProxy } from './auth/deprecated_channel_authorizer';\nimport Runtime from 'runtime';\nimport * as nacl from 'tweetnacl';\n\nexport type AuthTransport = 'ajax' | 'jsonp';\nexport type Transport =\n | 'ws'\n | 'wss'\n | 'xhr_streaming'\n | 'xhr_polling'\n | 'sockjs';\n\nexport interface Config {\n // these are all 'required' config parameters, it's not necessary for the user\n // to set them, but they have configured defaults.\n activityTimeout: number;\n enableStats: boolean;\n httpHost: string;\n httpPath: string;\n httpPort: number;\n httpsPort: number;\n pongTimeout: number;\n statsHost: string;\n unavailableTimeout: number;\n useTLS: boolean;\n wsHost: string;\n wsPath: string;\n wsPort: number;\n wssPort: number;\n userAuthenticator: UserAuthenticationHandler;\n channelAuthorizer: ChannelAuthorizationHandler;\n\n // these are all optional parameters or overrrides. The customer can set these\n // but it's not strictly necessary\n forceTLS?: boolean;\n cluster?: string;\n disabledTransports?: Transport[];\n enabledTransports?: Transport[];\n ignoreNullOrigin?: boolean;\n nacl?: nacl;\n timelineParams?: any;\n}\n\n// getConfig mainly sets the defaults for the options that are not provided\nexport function getConfig(opts: Options, pusher): Config {\n let config: Config = {\n activityTimeout: opts.activityTimeout || Defaults.activityTimeout,\n cluster: opts.cluster,\n httpPath: opts.httpPath || Defaults.httpPath,\n httpPort: opts.httpPort || Defaults.httpPort,\n httpsPort: opts.httpsPort || Defaults.httpsPort,\n pongTimeout: opts.pongTimeout || Defaults.pongTimeout,\n statsHost: opts.statsHost || Defaults.stats_host,\n unavailableTimeout: opts.unavailableTimeout || Defaults.unavailableTimeout,\n wsPath: opts.wsPath || Defaults.wsPath,\n wsPort: opts.wsPort || Defaults.wsPort,\n wssPort: opts.wssPort || Defaults.wssPort,\n\n enableStats: getEnableStatsConfig(opts),\n httpHost: getHttpHost(opts),\n useTLS: shouldUseTLS(opts),\n wsHost: getWebsocketHost(opts),\n\n userAuthenticator: buildUserAuthenticator(opts),\n channelAuthorizer: buildChannelAuthorizer(opts, pusher)\n };\n\n if ('disabledTransports' in opts)\n config.disabledTransports = opts.disabledTransports;\n if ('enabledTransports' in opts)\n config.enabledTransports = opts.enabledTransports;\n if ('ignoreNullOrigin' in opts)\n config.ignoreNullOrigin = opts.ignoreNullOrigin;\n if ('timelineParams' in opts) config.timelineParams = opts.timelineParams;\n if ('nacl' in opts) {\n config.nacl = opts.nacl;\n }\n\n return config;\n}\n\nfunction getHttpHost(opts: Options): string {\n if (opts.httpHost) {\n return opts.httpHost;\n }\n if (opts.cluster) {\n return `sockjs-${opts.cluster}.pusher.com`;\n }\n return Defaults.httpHost;\n}\n\nfunction getWebsocketHost(opts: Options): string {\n if (opts.wsHost) {\n return opts.wsHost;\n }\n return getWebsocketHostFromCluster(opts.cluster);\n}\n\nfunction getWebsocketHostFromCluster(cluster: string): string {\n return `ws-${cluster}.pusher.com`;\n}\n\nfunction shouldUseTLS(opts: Options): boolean {\n if (Runtime.getProtocol() === 'https:') {\n return true;\n } else if (opts.forceTLS === false) {\n return false;\n }\n return true;\n}\n\n// if enableStats is set take the value\n// if disableStats is set take the inverse\n// otherwise default to false\nfunction getEnableStatsConfig(opts: Options): boolean {\n if ('enableStats' in opts) {\n return opts.enableStats;\n }\n if ('disableStats' in opts) {\n return !opts.disableStats;\n }\n return false;\n}\n\nfunction buildUserAuthenticator(opts: Options): UserAuthenticationHandler {\n const userAuthentication = {\n ...Defaults.userAuthentication,\n ...opts.userAuthentication\n };\n if (\n 'customHandler' in userAuthentication &&\n userAuthentication['customHandler'] != null\n ) {\n return userAuthentication['customHandler'];\n }\n\n return UserAuthenticator(userAuthentication);\n}\n\nfunction buildChannelAuth(opts: Options, pusher): ChannelAuthorizationOptions {\n let channelAuthorization: ChannelAuthorizationOptions;\n if ('channelAuthorization' in opts) {\n channelAuthorization = {\n ...Defaults.channelAuthorization,\n ...opts.channelAuthorization\n };\n } else {\n channelAuthorization = {\n transport: opts.authTransport || Defaults.authTransport,\n endpoint: opts.authEndpoint || Defaults.authEndpoint\n };\n if ('auth' in opts) {\n if ('params' in opts.auth) channelAuthorization.params = opts.auth.params;\n if ('headers' in opts.auth)\n channelAuthorization.headers = opts.auth.headers;\n }\n if ('authorizer' in opts)\n channelAuthorization.customHandler = ChannelAuthorizerProxy(\n pusher,\n channelAuthorization,\n opts.authorizer\n );\n }\n return channelAuthorization;\n}\n\nfunction buildChannelAuthorizer(\n opts: Options,\n pusher\n): ChannelAuthorizationHandler {\n const channelAuthorization = buildChannelAuth(opts, pusher);\n if (\n 'customHandler' in channelAuthorization &&\n channelAuthorization['customHandler'] != null\n ) {\n return channelAuthorization['customHandler'];\n }\n\n return ChannelAuthorizer(channelAuthorization);\n}\n","import Logger from './logger';\nimport Pusher from './pusher';\nimport EventsDispatcher from './events/dispatcher';\n\nexport default class WatchlistFacade extends EventsDispatcher {\n private pusher: Pusher;\n\n public constructor(pusher: Pusher) {\n super(function(eventName, data) {\n Logger.debug(`No callbacks on watchlist events for ${eventName}`);\n });\n\n this.pusher = pusher;\n this.bindWatchlistInternalEvent();\n }\n\n handleEvent(pusherEvent) {\n pusherEvent.data.events.forEach(watchlistEvent => {\n this.emit(watchlistEvent.name, watchlistEvent);\n });\n }\n\n private bindWatchlistInternalEvent() {\n this.pusher.connection.bind('message', pusherEvent => {\n var eventName = pusherEvent.event;\n if (eventName === 'pusher_internal:watchlist_events') {\n this.handleEvent(pusherEvent);\n }\n });\n }\n}\n","function flatPromise() {\n let resolve, reject;\n const promise = new Promise((res, rej) => {\n resolve = res;\n reject = rej;\n });\n return { promise, resolve, reject };\n}\n\nexport default flatPromise;\n","import Pusher from './pusher';\nimport Logger from './logger';\nimport {\n UserAuthenticationData,\n UserAuthenticationCallback\n} from './auth/options';\nimport Channel from './channels/channel';\nimport WatchlistFacade from './watchlist';\nimport EventsDispatcher from './events/dispatcher';\nimport flatPromise from './utils/flat_promise';\n\nexport default class UserFacade extends EventsDispatcher {\n pusher: Pusher;\n signin_requested: boolean = false;\n user_data: any = null;\n serverToUserChannel: Channel = null;\n signinDonePromise: Promise = null;\n watchlist: WatchlistFacade;\n private _signinDoneResolve: Function = null;\n\n public constructor(pusher: Pusher) {\n super(function(eventName, data) {\n Logger.debug('No callbacks on user for ' + eventName);\n });\n this.pusher = pusher;\n this.pusher.connection.bind('state_change', ({ previous, current }) => {\n if (previous !== 'connected' && current === 'connected') {\n this._signin();\n }\n if (previous === 'connected' && current !== 'connected') {\n this._cleanup();\n this._newSigninPromiseIfNeeded();\n }\n });\n\n this.watchlist = new WatchlistFacade(pusher);\n\n this.pusher.connection.bind('message', event => {\n var eventName = event.event;\n if (eventName === 'pusher:signin_success') {\n this._onSigninSuccess(event.data);\n }\n if (\n this.serverToUserChannel &&\n this.serverToUserChannel.name === event.channel\n ) {\n this.serverToUserChannel.handleEvent(event);\n }\n });\n }\n\n public signin() {\n if (this.signin_requested) {\n return;\n }\n\n this.signin_requested = true;\n this._signin();\n }\n\n private _signin() {\n if (!this.signin_requested) {\n return;\n }\n\n this._newSigninPromiseIfNeeded();\n\n if (this.pusher.connection.state !== 'connected') {\n // Signin will be attempted when the connection is connected\n return;\n }\n\n this.pusher.config.userAuthenticator(\n {\n socketId: this.pusher.connection.socket_id\n },\n this._onAuthorize\n );\n }\n\n private _onAuthorize: UserAuthenticationCallback = (\n err,\n authData: UserAuthenticationData\n ) => {\n if (err) {\n Logger.warn(`Error during signin: ${err}`);\n this._cleanup();\n return;\n }\n\n this.pusher.send_event('pusher:signin', {\n auth: authData.auth,\n user_data: authData.user_data\n });\n\n // Later when we get pusher:singin_success event, the user will be marked as signed in\n };\n\n private _onSigninSuccess(data: any) {\n try {\n this.user_data = JSON.parse(data.user_data);\n } catch (e) {\n Logger.error(`Failed parsing user data after signin: ${data.user_data}`);\n this._cleanup();\n return;\n }\n\n if (typeof this.user_data.id !== 'string' || this.user_data.id === '') {\n Logger.error(\n `user_data doesn't contain an id. user_data: ${this.user_data}`\n );\n this._cleanup();\n return;\n }\n\n // Signin succeeded\n this._signinDoneResolve();\n this._subscribeChannels();\n }\n\n private _subscribeChannels() {\n const ensure_subscribed = channel => {\n if (channel.subscriptionPending && channel.subscriptionCancelled) {\n channel.reinstateSubscription();\n } else if (\n !channel.subscriptionPending &&\n this.pusher.connection.state === 'connected'\n ) {\n channel.subscribe();\n }\n };\n\n this.serverToUserChannel = new Channel(\n `#server-to-user-${this.user_data.id}`,\n this.pusher\n );\n this.serverToUserChannel.bind_global((eventName, data) => {\n if (\n eventName.indexOf('pusher_internal:') === 0 ||\n eventName.indexOf('pusher:') === 0\n ) {\n // ignore internal events\n return;\n }\n this.emit(eventName, data);\n });\n ensure_subscribed(this.serverToUserChannel);\n }\n\n private _cleanup() {\n this.user_data = null;\n if (this.serverToUserChannel) {\n this.serverToUserChannel.unbind_all();\n this.serverToUserChannel.disconnect();\n this.serverToUserChannel = null;\n }\n\n if (this.signin_requested) {\n // If signin is in progress and cleanup is called,\n // Mark the current signin process as done.\n this._signinDoneResolve();\n }\n }\n\n private _newSigninPromiseIfNeeded() {\n if (!this.signin_requested) {\n return;\n }\n\n // If there is a promise and it is not resolved, return without creating a new one.\n if (this.signinDonePromise && !(this.signinDonePromise as any).done) {\n return;\n }\n\n // This promise is never rejected.\n // It gets resolved when the signin process is done whether it failed or succeeded\n const { promise, resolve, reject: _ } = flatPromise();\n (promise as any).done = false;\n const setDone = () => {\n (promise as any).done = true;\n };\n promise.then(setDone).catch(setDone);\n this.signinDonePromise = promise;\n this._signinDoneResolve = resolve;\n }\n}\n","import AbstractRuntime from '../runtimes/interface';\nimport Runtime from 'runtime';\nimport * as Collections from './utils/collections';\nimport Channels from './channels/channels';\nimport Channel from './channels/channel';\nimport { default as EventsDispatcher } from './events/dispatcher';\nimport Timeline from './timeline/timeline';\nimport TimelineSender from './timeline/timeline_sender';\nimport TimelineLevel from './timeline/level';\nimport { defineTransport } from './strategies/strategy_builder';\nimport ConnectionManager from './connection/connection_manager';\nimport { PeriodicTimer } from './utils/timers';\nimport Defaults from './defaults';\nimport Logger from './logger';\nimport Factory from './utils/factory';\nimport { Options, ClusterOptions, validateOptions } from './options';\nimport { Config, getConfig } from './config';\nimport StrategyOptions from './strategies/strategy_options';\nimport UserFacade from './user';\n\nexport default class Pusher {\n /* STATIC PROPERTIES */\n static instances: Pusher[] = [];\n static isReady: boolean = false;\n static logToConsole: boolean = false;\n\n // for jsonp\n static Runtime: AbstractRuntime = Runtime;\n static ScriptReceivers: any = (Runtime).ScriptReceivers;\n static DependenciesReceivers: any = (Runtime).DependenciesReceivers;\n static auth_callbacks: any = (Runtime).auth_callbacks;\n\n static ready() {\n Pusher.isReady = true;\n for (var i = 0, l = Pusher.instances.length; i < l; i++) {\n Pusher.instances[i].connect();\n }\n }\n\n static log: (message: any) => void;\n\n private static getClientFeatures(): string[] {\n return Collections.keys(\n Collections.filterObject({ ws: Runtime.Transports.ws }, function(t) {\n return t.isSupported({});\n })\n );\n }\n\n /* INSTANCE PROPERTIES */\n key: string;\n options: Options;\n config: Config;\n channels: Channels;\n global_emitter: EventsDispatcher;\n sessionID: number;\n timeline: Timeline;\n timelineSender: TimelineSender;\n connection: ConnectionManager;\n timelineSenderTimer: PeriodicTimer;\n user: UserFacade;\n constructor(app_key: string, options: Options) {\n checkAppKey(app_key);\n validateOptions(options);\n this.key = app_key;\n this.config = getConfig(options, this);\n\n this.channels = Factory.createChannels();\n this.global_emitter = new EventsDispatcher();\n this.sessionID = Runtime.randomInt(1000000000);\n\n this.timeline = new Timeline(this.key, this.sessionID, {\n cluster: this.config.cluster,\n features: Pusher.getClientFeatures(),\n params: this.config.timelineParams || {},\n limit: 50,\n level: TimelineLevel.INFO,\n version: Defaults.VERSION\n });\n if (this.config.enableStats) {\n this.timelineSender = Factory.createTimelineSender(this.timeline, {\n host: this.config.statsHost,\n path: '/timeline/v2/' + Runtime.TimelineTransport.name\n });\n }\n\n var getStrategy = (options: StrategyOptions) => {\n return Runtime.getDefaultStrategy(this.config, options, defineTransport);\n };\n\n this.connection = Factory.createConnectionManager(this.key, {\n getStrategy: getStrategy,\n timeline: this.timeline,\n activityTimeout: this.config.activityTimeout,\n pongTimeout: this.config.pongTimeout,\n unavailableTimeout: this.config.unavailableTimeout,\n useTLS: Boolean(this.config.useTLS)\n });\n\n this.connection.bind('connected', () => {\n this.subscribeAll();\n if (this.timelineSender) {\n this.timelineSender.send(this.connection.isUsingTLS());\n }\n });\n\n this.connection.bind('message', event => {\n var eventName = event.event;\n var internal = eventName.indexOf('pusher_internal:') === 0;\n if (event.channel) {\n var channel = this.channel(event.channel);\n if (channel) {\n channel.handleEvent(event);\n }\n }\n // Emit globally [deprecated]\n if (!internal) {\n this.global_emitter.emit(event.event, event.data);\n }\n });\n this.connection.bind('connecting', () => {\n this.channels.disconnect();\n });\n this.connection.bind('disconnected', () => {\n this.channels.disconnect();\n });\n this.connection.bind('error', err => {\n Logger.warn(err);\n });\n\n Pusher.instances.push(this);\n this.timeline.info({ instances: Pusher.instances.length });\n\n this.user = new UserFacade(this);\n\n if (Pusher.isReady) {\n this.connect();\n }\n }\n\n /**\n * Allows you to switch Pusher cluster without\n * losing all the channels/subscription binding\n * as this is internally managed by the SDK.\n */\n switchCluster(options: ClusterOptions) {\n const { appKey, cluster } = options;\n this.key = appKey;\n this.options = { ...this.options, cluster };\n this.config = getConfig(this.options, this);\n this.connection.switchCluster(this.key);\n }\n\n channel(name: string): Channel {\n return this.channels.find(name);\n }\n\n allChannels(): Channel[] {\n return this.channels.all();\n }\n\n connect() {\n this.connection.connect();\n\n if (this.timelineSender) {\n if (!this.timelineSenderTimer) {\n var usingTLS = this.connection.isUsingTLS();\n var timelineSender = this.timelineSender;\n this.timelineSenderTimer = new PeriodicTimer(60000, function() {\n timelineSender.send(usingTLS);\n });\n }\n }\n }\n\n disconnect() {\n this.connection.disconnect();\n\n if (this.timelineSenderTimer) {\n this.timelineSenderTimer.ensureAborted();\n this.timelineSenderTimer = null;\n }\n }\n\n bind(event_name: string, callback: Function, context?: any): Pusher {\n this.global_emitter.bind(event_name, callback, context);\n return this;\n }\n\n unbind(event_name?: string, callback?: Function, context?: any): Pusher {\n this.global_emitter.unbind(event_name, callback, context);\n return this;\n }\n\n bind_global(callback: Function): Pusher {\n this.global_emitter.bind_global(callback);\n return this;\n }\n\n unbind_global(callback?: Function): Pusher {\n this.global_emitter.unbind_global(callback);\n return this;\n }\n\n unbind_all(callback?: Function): Pusher {\n this.global_emitter.unbind_all();\n return this;\n }\n\n subscribeAll() {\n var channelName;\n for (channelName in this.channels.channels) {\n if (this.channels.channels.hasOwnProperty(channelName)) {\n this.subscribe(channelName);\n }\n }\n }\n\n subscribe(channel_name: string) {\n var channel = this.channels.add(channel_name, this);\n if (channel.subscriptionPending && channel.subscriptionCancelled) {\n channel.reinstateSubscription();\n } else if (\n !channel.subscriptionPending &&\n this.connection.state === 'connected'\n ) {\n channel.subscribe();\n }\n return channel;\n }\n\n unsubscribe(channel_name: string) {\n var channel = this.channels.find(channel_name);\n if (channel && channel.subscriptionPending) {\n channel.cancelSubscription();\n } else {\n channel = this.channels.remove(channel_name);\n if (channel && channel.subscribed) {\n channel.unsubscribe();\n }\n }\n }\n\n send_event(event_name: string, data: any, channel?: string) {\n return this.connection.send_event(event_name, data, channel);\n }\n\n shouldUseTLS(): boolean {\n return this.config.useTLS;\n }\n\n signin() {\n this.user.signin();\n }\n}\n\nfunction checkAppKey(key) {\n if (key === null || key === undefined) {\n throw 'You must pass your app key when you instantiate Pusher.';\n }\n}\n\nRuntime.setup(Pusher);\n","import Pusher from './pusher';\nimport { Options, validateOptions } from './options';\nimport * as nacl from 'tweetnacl';\n\nexport default class PusherWithEncryption extends Pusher {\n constructor(app_key: string, options: Options) {\n Pusher.logToConsole = PusherWithEncryption.logToConsole;\n Pusher.log = PusherWithEncryption.log;\n\n validateOptions(options);\n options.nacl = nacl;\n super(app_key, options);\n }\n}\n"],"sourceRoot":""} \ No newline at end of file +{"version":3,"sources":["webpack://Pusher/webpack/universalModuleDefinition","webpack://Pusher/webpack/bootstrap","webpack://Pusher/./node_modules/@stablelib/base64/base64.ts","webpack://Pusher/./node_modules/@stablelib/utf8/utf8.ts","webpack://Pusher/./node_modules/tweetnacl/nacl-fast.js","webpack://Pusher/./src/core/pusher-with-encryption.js","webpack://Pusher/crypto (ignored)","webpack://Pusher/./src/core/base64.ts","webpack://Pusher/./src/core/utils/timers/abstract_timer.ts","webpack://Pusher/./src/core/utils/timers/index.ts","webpack://Pusher/./src/core/util.ts","webpack://Pusher/./src/core/utils/collections.ts","webpack://Pusher/./src/core/defaults.ts","webpack://Pusher/./src/core/transports/url_schemes.ts","webpack://Pusher/./src/core/events/callback_registry.ts","webpack://Pusher/./src/core/events/dispatcher.ts","webpack://Pusher/./src/core/logger.ts","webpack://Pusher/./src/core/transports/transport_connection.ts","webpack://Pusher/./src/core/transports/transport.ts","webpack://Pusher/./src/runtimes/isomorphic/transports/transports.ts","webpack://Pusher/./src/core/transports/assistant_to_the_transport_manager.ts","webpack://Pusher/./src/core/connection/protocol/protocol.ts","webpack://Pusher/./src/core/connection/connection.ts","webpack://Pusher/./src/core/connection/handshake/index.ts","webpack://Pusher/./src/core/timeline/timeline_sender.ts","webpack://Pusher/./src/core/errors.ts","webpack://Pusher/./src/core/utils/url_store.ts","webpack://Pusher/./src/core/channels/channel.ts","webpack://Pusher/./src/core/channels/private_channel.ts","webpack://Pusher/./src/core/channels/members.ts","webpack://Pusher/./src/core/channels/presence_channel.ts","webpack://Pusher/./src/core/channels/encrypted_channel.ts","webpack://Pusher/./src/core/connection/connection_manager.ts","webpack://Pusher/./src/core/channels/channels.ts","webpack://Pusher/./src/core/utils/factory.ts","webpack://Pusher/./src/core/transports/transport_manager.ts","webpack://Pusher/./src/core/strategies/sequential_strategy.ts","webpack://Pusher/./src/core/strategies/best_connected_ever_strategy.ts","webpack://Pusher/./src/core/strategies/websocket_prioritized_cached_strategy.ts","webpack://Pusher/./src/core/strategies/delayed_strategy.ts","webpack://Pusher/./src/core/strategies/if_strategy.ts","webpack://Pusher/./src/core/strategies/first_connected_strategy.ts","webpack://Pusher/./src/runtimes/isomorphic/default_strategy.ts","webpack://Pusher/./src/runtimes/isomorphic/transports/transport_connection_initializer.ts","webpack://Pusher/./src/core/http/http_request.ts","webpack://Pusher/./src/core/http/state.ts","webpack://Pusher/./src/core/http/http_socket.ts","webpack://Pusher/./src/core/http/http_streaming_socket.ts","webpack://Pusher/./src/core/http/http_polling_socket.ts","webpack://Pusher/./src/runtimes/isomorphic/http/http_xhr_request.ts","webpack://Pusher/./src/runtimes/isomorphic/http/http.ts","webpack://Pusher/./src/runtimes/isomorphic/runtime.ts","webpack://Pusher/./src/runtimes/worker/net_info.ts","webpack://Pusher/./src/runtimes/worker/auth/fetch_auth.ts","webpack://Pusher/./src/runtimes/worker/timeline/fetch_timeline.ts","webpack://Pusher/./src/runtimes/worker/runtime.ts","webpack://Pusher/./src/core/timeline/level.ts","webpack://Pusher/./src/core/timeline/timeline.ts","webpack://Pusher/./src/core/strategies/transport_strategy.ts","webpack://Pusher/./src/core/strategies/strategy_builder.ts","webpack://Pusher/./src/core/options.ts","webpack://Pusher/./src/core/auth/options.ts","webpack://Pusher/./src/core/auth/user_authenticator.ts","webpack://Pusher/./src/core/auth/channel_authorizer.ts","webpack://Pusher/./src/core/auth/deprecated_channel_authorizer.ts","webpack://Pusher/./src/core/config.ts","webpack://Pusher/./src/core/watchlist.ts","webpack://Pusher/./src/core/utils/flat_promise.ts","webpack://Pusher/./src/core/user.ts","webpack://Pusher/./src/core/pusher.ts","webpack://Pusher/./src/core/pusher-with-encryption.ts"],"names":[],"mappings":";;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AACD,O;QCVA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;;QAEA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;;;QAGA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;QACA,0CAA0C,gCAAgC;QAC1E;QACA;;QAEA;QACA;QACA;QACA,wDAAwD,kBAAkB;QAC1E;QACA,iDAAiD,cAAc;QAC/D;;QAEA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA,yCAAyC,iCAAiC;QAC1E,gHAAgH,mBAAmB,EAAE;QACrI;QACA;;QAEA;QACA;QACA;QACA,2BAA2B,0BAA0B,EAAE;QACvD,iCAAiC,eAAe;QAChD;QACA;QACA;;QAEA;QACA,sDAAsD,+DAA+D;;QAErH;QACA;;;QAGA;QACA;;;;;;;;;AClFA,sCAAsC;AACtC,6CAA6C;;;;;;;;;;;;;;;AAE7C;;GAEG;AAEH,iDAAiD;AACjD,kDAAkD;AAClD,kCAAkC;AAClC,IAAM,YAAY,GAAG,GAAG,CAAC;AAEzB;;;;GAIG;AACH;IACI,kDAAkD;IAElD,eAAoB,iBAAuB;QAAvB,2DAAuB;QAAvB,sBAAiB,GAAjB,iBAAiB,CAAM;IAAI,CAAC;IAEhD,6BAAa,GAAb,UAAc,MAAc;QACxB,IAAI,CAAC,IAAI,CAAC,iBAAiB,EAAE;YACzB,OAAO,CAAC,MAAM,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;SACnC;QACD,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IACpC,CAAC;IAED,sBAAM,GAAN,UAAO,IAAgB;QACnB,IAAI,GAAG,GAAG,EAAE,CAAC;QAEb,IAAI,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CAAC,CAAC,CAAC,CAAC;gBACpD,CAAC,GAAG,MAAM,GAAG,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC;aAC5B;SACJ;QAED,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC;KACtC;IACD,OAAO,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AAC1B,CAAC;AAjED,wBAiEC;;;;;;;AC/ID;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,uBAAuB,iBAAiB;AACxC;AACA;;AAEA;AACA,wCAAwC,4BAA4B;;AAEpE;AACA,4BAA4B;;AAE5B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa,OAAO;AACpB;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,aAAa,QAAQ;AACrB,aAAa,OAAO;AACpB;AACA;AACA,eAAe,QAAQ;AACvB;AACA,eAAe,QAAQ;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB;AACA;AACA;;AAEA;AACA;AACA;AACA,aAAa,QAAQ;AACrB,aAAa,OAAO;AACpB;AACA;AACA,eAAe,QAAQ;AACvB;AACA,eAAe,QAAQ;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,iBAAiB,OAAO;AACxB;AACA;;AAEA;AACA;AACA;AACA;AACA,iBAAiB,OAAO;AACxB;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA,8CAA8C;AAC9C,8CAA8C;AAC9C,8CAA8C;AAC9C,8CAA8C;AAC9C,8CAA8C;AAC9C;AACA,8CAA8C;AAC9C,8CAA8C;AAC9C,8CAA8C;AAC9C;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,sDAAsD;AACtD,sDAAsD;AACtD,sDAAsD;AACtD,sDAAsD;AACtD,sDAAsD;AACtD;AACA,sDAAsD;AACtD,sDAAsD;AACtD,sDAAsD;AACtD;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA,qBAAqB;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA,qBAAqB;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA,qBAAqB;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA,qBAAqB;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA,qBAAqB;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA,qBAAqB;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA,qBAAqB;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA,qBAAqB;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA,qBAAqB;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA,qBAAqB;;AAErB;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA,UAAU,QAAQ;AAClB;AACA;AACA;;AAEA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA;AACA;;AAEA;AACA,aAAa,QAAQ;AACrB;AACA,aAAa,QAAQ;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa,OAAO;AACpB;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,UAAU;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,eAAe,WAAW;AAC1B;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;;AAEA;AACA;AACA,aAAa,QAAQ;AACrB;;AAEA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA,aAAa,OAAO;AACpB;AACA,eAAe,QAAQ;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;;AAEA;AACA,iBAAiB,QAAQ;AACzB;;AAEA;AACA,iBAAiB,QAAQ;AACzB;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD;;AAEA;AACA;AACA,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD,sBAAsB,2BAA2B;AACjD;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA,aAAa,QAAQ;AACrB,eAAe,QAAQ;AACvB;AACA;AACA;AACA,aAAa,QAAQ;AACrB;;AAEA;AACA;AACA;AACA,aAAa,QAAQ;AACrB,eAAe,QAAQ;AACvB;AACA;AACA;AACA,aAAa,QAAQ;AACrB;;AAEA;AACA;AACA;AACA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA;AACA,aAAa,MAAM;AACnB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,eAAe,QAAQ;AACvB;AACA;AACA;AACA;AACA,eAAe,QAAQ;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA,qBAAqB;AACrB,qBAAqB;;AAErB;AACA;AACA;;AAEA,sBAAsB;AACtB,sBAAsB;;AAEtB;AACA;AACA;;AAEA,sBAAsB;AACtB,sBAAsB;;AAEtB;AACA;AACA;;AAEA,sBAAsB;AACtB,sBAAsB;;AAEtB;AACA;AACA;;AAEA,sBAAsB;AACtB,sBAAsB;;AAEtB;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA,qBAAqB;AACrB,qBAAqB;;AAErB;AACA;AACA;;AAEA,sBAAsB;AACtB,sBAAsB;;AAEtB;AACA;AACA;;AAEA,sBAAsB;AACtB,sBAAsB;;AAEtB;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA,qBAAqB;AACrB,qBAAqB;;AAErB;AACA;;AAEA,sBAAsB;AACtB,sBAAsB;;AAEtB;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,mBAAmB,QAAQ;AAC3B;AACA;AACA;;AAEA,yBAAyB;AACzB,yBAAyB;;AAEzB;AACA;;AAEA,0BAA0B;AAC1B,0BAA0B;;AAE1B;AACA;AACA;AACA;AACA;;AAEA,0BAA0B;AAC1B,0BAA0B;;AAE1B;AACA;AACA;AACA;AACA;;AAEA,0BAA0B;AAC1B,0BAA0B;;AAE1B;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA,mBAAmB;AACnB,mBAAmB;;AAEnB;AACA;;AAEA,oBAAoB;AACpB,oBAAoB;;AAEpB;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA,mBAAmB;AACnB,mBAAmB;;AAEnB;AACA;;AAEA,oBAAoB;AACpB,oBAAoB;;AAEpB;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA,mBAAmB;AACnB,mBAAmB;;AAEnB;AACA;;AAEA,oBAAoB;AACpB,oBAAoB;;AAEpB;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA,mBAAmB;AACnB,mBAAmB;;AAEnB;AACA;;AAEA,oBAAoB;AACpB,oBAAoB;;AAEpB;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA,mBAAmB;AACnB,mBAAmB;;AAEnB;AACA;;AAEA,oBAAoB;AACpB,oBAAoB;;AAEpB;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA,mBAAmB;AACnB,mBAAmB;;AAEnB;AACA;;AAEA,oBAAoB;AACpB,oBAAoB;;AAEpB;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA,mBAAmB;AACnB,mBAAmB;;AAEnB;AACA;;AAEA,oBAAoB;AACpB,oBAAoB;;AAEpB;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA,mBAAmB;AACnB,mBAAmB;;AAEnB;AACA;;AAEA,oBAAoB;AACpB,oBAAoB;;AAEpB;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA,aAAa,OAAO;AACpB;;AAEA;AACA;AACA;AACA;;AAEA,aAAa,OAAO;;AAEpB;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa,OAAO;AACpB;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,QAAQ;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA,aAAa,QAAQ;AACrB;AACA;;AAEA;;AAEA;AACA;AACA,cAAc,SAAS;AACvB;AACA,gCAAgC,OAAO;AACvC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA;AACA,aAAa,QAAQ;AACrB,aAAa,QAAQ;AACrB;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa,QAAQ;AACrB,aAAa,QAAQ;AACrB;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA,aAAa,OAAO;AACpB,aAAa,QAAQ;;AAErB;AACA;AACA;AACA;;AAEA,cAAc,QAAQ;AACtB;AACA;;AAEA,aAAa,QAAQ;AACrB,aAAa,QAAQ;AACrB,aAAa,QAAQ;AACrB,eAAe,QAAQ;AACvB;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;;AAEA,aAAa,OAAO;AACpB,aAAa,QAAQ;AACrB;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA,eAAe,OAAO;AACtB;AACA;;AAEA,aAAa,OAAO;AACpB;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA,iBAAiB,sBAAsB;AACvC;AACA;AACA;AACA;;AAEA;AACA,iBAAiB,gBAAgB;AACjC;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,iBAAiB,gBAAgB;AACjC;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,iBAAiB,gBAAgB;AACjC;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA,UAAU;AACV;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,UAAU;AACV;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAiB,cAAc;AAC/B;AACA;;AAEA;AACA;AACA;AACA,iBAAiB,gBAAgB;AACjC;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa,uBAAuB;AACpC,aAAa,gBAAgB;AAC7B;AACA;;AAEA;AACA;AACA;AACA;AACA,UAAU;AACV;;AAEA;AACA;AACA;AACA;AACA;AACA,iBAAiB,eAAe;AAChC,UAAU;AACV;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAiB,QA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;AACuB;AACnB;AAEnB,MAAM,2CAAqB,SAAQ,WAAM;IACtD,YAAY,OAAe,EAAE,OAAgB;QAC3C,WAAM,CAAC,YAAY,GAAG,2CAAoB,CAAC,YAAY,CAAC;QACxD,WAAM,CAAC,GAAG,GAAG,2CAAoB,CAAC,GAAG,CAAC;QAEtC,eAAe,CAAC,OAAO,CAAC,CAAC;QACzB,OAAO,CAAC,IAAI,GAAG,SAAI,CAAC;QACpB,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAC1B,CAAC;CACF","file":"pusher-with-encryption.worker.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"Pusher\"] = factory();\n\telse\n\t\troot[\"Pusher\"] = factory();\n})(this, function() {\nreturn "," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 3);\n","// Copyright (C) 2016 Dmitry Chestnykh\n// MIT License. See LICENSE file for details.\n\n/**\n * Package base64 implements Base64 encoding and decoding.\n */\n\n// Invalid character used in decoding to indicate\n// that the character to decode is out of range of\n// alphabet and cannot be decoded.\nconst INVALID_BYTE = 256;\n\n/**\n * Implements standard Base64 encoding.\n *\n * Operates in constant time.\n */\nexport class Coder {\n // TODO(dchest): methods to encode chunk-by-chunk.\n\n constructor(private _paddingCharacter = \"=\") { }\n\n encodedLength(length: number): number {\n if (!this._paddingCharacter) {\n return (length * 8 + 5) / 6 | 0;\n }\n return (length + 2) / 3 * 4 | 0;\n }\n\n encode(data: Uint8Array): string {\n let out = \"\";\n\n let i = 0;\n for (; i < data.length - 2; i += 3) {\n let c = (data[i] << 16) | (data[i + 1] << 8) | (data[i + 2]);\n out += this._encodeByte((c >>> 3 * 6) & 63);\n out += this._encodeByte((c >>> 2 * 6) & 63);\n out += this._encodeByte((c >>> 1 * 6) & 63);\n out += this._encodeByte((c >>> 0 * 6) & 63);\n }\n\n const left = data.length - i;\n if (left > 0) {\n let c = (data[i] << 16) | (left === 2 ? data[i + 1] << 8 : 0);\n out += this._encodeByte((c >>> 3 * 6) & 63);\n out += this._encodeByte((c >>> 2 * 6) & 63);\n if (left === 2) {\n out += this._encodeByte((c >>> 1 * 6) & 63);\n } else {\n out += this._paddingCharacter || \"\";\n }\n out += this._paddingCharacter || \"\";\n }\n\n return out;\n }\n\n maxDecodedLength(length: number): number {\n if (!this._paddingCharacter) {\n return (length * 6 + 7) / 8 | 0;\n }\n return length / 4 * 3 | 0;\n }\n\n decodedLength(s: string): number {\n return this.maxDecodedLength(s.length - this._getPaddingLength(s));\n }\n\n decode(s: string): Uint8Array {\n if (s.length === 0) {\n return new Uint8Array(0);\n }\n const paddingLength = this._getPaddingLength(s);\n const length = s.length - paddingLength;\n const out = new Uint8Array(this.maxDecodedLength(length));\n let op = 0;\n let i = 0;\n let haveBad = 0;\n let v0 = 0, v1 = 0, v2 = 0, v3 = 0;\n for (; i < length - 4; i += 4) {\n v0 = this._decodeChar(s.charCodeAt(i + 0));\n v1 = this._decodeChar(s.charCodeAt(i + 1));\n v2 = this._decodeChar(s.charCodeAt(i + 2));\n v3 = this._decodeChar(s.charCodeAt(i + 3));\n out[op++] = (v0 << 2) | (v1 >>> 4);\n out[op++] = (v1 << 4) | (v2 >>> 2);\n out[op++] = (v2 << 6) | v3;\n haveBad |= v0 & INVALID_BYTE;\n haveBad |= v1 & INVALID_BYTE;\n haveBad |= v2 & INVALID_BYTE;\n haveBad |= v3 & INVALID_BYTE;\n }\n if (i < length - 1) {\n v0 = this._decodeChar(s.charCodeAt(i));\n v1 = this._decodeChar(s.charCodeAt(i + 1));\n out[op++] = (v0 << 2) | (v1 >>> 4);\n haveBad |= v0 & INVALID_BYTE;\n haveBad |= v1 & INVALID_BYTE;\n }\n if (i < length - 2) {\n v2 = this._decodeChar(s.charCodeAt(i + 2));\n out[op++] = (v1 << 4) | (v2 >>> 2);\n haveBad |= v2 & INVALID_BYTE;\n }\n if (i < length - 3) {\n v3 = this._decodeChar(s.charCodeAt(i + 3));\n out[op++] = (v2 << 6) | v3;\n haveBad |= v3 & INVALID_BYTE;\n }\n if (haveBad !== 0) {\n throw new Error(\"Base64Coder: incorrect characters for decoding\");\n }\n return out;\n }\n\n // Standard encoding have the following encoded/decoded ranges,\n // which we need to convert between.\n //\n // ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 0123456789 + /\n // Index: 0 - 25 26 - 51 52 - 61 62 63\n // ASCII: 65 - 90 97 - 122 48 - 57 43 47\n //\n\n // Encode 6 bits in b into a new character.\n protected _encodeByte(b: number): string {\n // Encoding uses constant time operations as follows:\n //\n // 1. Define comparison of A with B using (A - B) >>> 8:\n // if A > B, then result is positive integer\n // if A <= B, then result is 0\n //\n // 2. Define selection of C or 0 using bitwise AND: X & C:\n // if X == 0, then result is 0\n // if X != 0, then result is C\n //\n // 3. Start with the smallest comparison (b >= 0), which is always\n // true, so set the result to the starting ASCII value (65).\n //\n // 4. Continue comparing b to higher ASCII values, and selecting\n // zero if comparison isn't true, otherwise selecting a value\n // to add to result, which:\n //\n // a) undoes the previous addition\n // b) provides new value to add\n //\n let result = b;\n // b >= 0\n result += 65;\n // b > 25\n result += ((25 - b) >>> 8) & ((0 - 65) - 26 + 97);\n // b > 51\n result += ((51 - b) >>> 8) & ((26 - 97) - 52 + 48);\n // b > 61\n result += ((61 - b) >>> 8) & ((52 - 48) - 62 + 43);\n // b > 62\n result += ((62 - b) >>> 8) & ((62 - 43) - 63 + 47);\n\n return String.fromCharCode(result);\n }\n\n // Decode a character code into a byte.\n // Must return 256 if character is out of alphabet range.\n protected _decodeChar(c: number): number {\n // Decoding works similar to encoding: using the same comparison\n // function, but now it works on ranges: result is always incremented\n // by value, but this value becomes zero if the range is not\n // satisfied.\n //\n // Decoding starts with invalid value, 256, which is then\n // subtracted when the range is satisfied. If none of the ranges\n // apply, the function returns 256, which is then checked by\n // the caller to throw error.\n let result = INVALID_BYTE; // start with invalid character\n\n // c == 43 (c > 42 and c < 44)\n result += (((42 - c) & (c - 44)) >>> 8) & (-INVALID_BYTE + c - 43 + 62);\n // c == 47 (c > 46 and c < 48)\n result += (((46 - c) & (c - 48)) >>> 8) & (-INVALID_BYTE + c - 47 + 63);\n // c > 47 and c < 58\n result += (((47 - c) & (c - 58)) >>> 8) & (-INVALID_BYTE + c - 48 + 52);\n // c > 64 and c < 91\n result += (((64 - c) & (c - 91)) >>> 8) & (-INVALID_BYTE + c - 65 + 0);\n // c > 96 and c < 123\n result += (((96 - c) & (c - 123)) >>> 8) & (-INVALID_BYTE + c - 97 + 26);\n\n return result;\n }\n\n private _getPaddingLength(s: string): number {\n let paddingLength = 0;\n if (this._paddingCharacter) {\n for (let i = s.length - 1; i >= 0; i--) {\n if (s[i] !== this._paddingCharacter) {\n break;\n }\n paddingLength++;\n }\n if (s.length < 4 || paddingLength > 2) {\n throw new Error(\"Base64Coder: incorrect padding\");\n }\n }\n return paddingLength;\n }\n\n}\n\nconst stdCoder = new Coder();\n\nexport function encode(data: Uint8Array): string {\n return stdCoder.encode(data);\n}\n\nexport function decode(s: string): Uint8Array {\n return stdCoder.decode(s);\n}\n\n/**\n * Implements URL-safe Base64 encoding.\n * (Same as Base64, but '+' is replaced with '-', and '/' with '_').\n *\n * Operates in constant time.\n */\nexport class URLSafeCoder extends Coder {\n // URL-safe encoding have the following encoded/decoded ranges:\n //\n // ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 0123456789 - _\n // Index: 0 - 25 26 - 51 52 - 61 62 63\n // ASCII: 65 - 90 97 - 122 48 - 57 45 95\n //\n\n protected _encodeByte(b: number): string {\n let result = b;\n // b >= 0\n result += 65;\n // b > 25\n result += ((25 - b) >>> 8) & ((0 - 65) - 26 + 97);\n // b > 51\n result += ((51 - b) >>> 8) & ((26 - 97) - 52 + 48);\n // b > 61\n result += ((61 - b) >>> 8) & ((52 - 48) - 62 + 45);\n // b > 62\n result += ((62 - b) >>> 8) & ((62 - 45) - 63 + 95);\n\n return String.fromCharCode(result);\n }\n\n protected _decodeChar(c: number): number {\n let result = INVALID_BYTE;\n\n // c == 45 (c > 44 and c < 46)\n result += (((44 - c) & (c - 46)) >>> 8) & (-INVALID_BYTE + c - 45 + 62);\n // c == 95 (c > 94 and c < 96)\n result += (((94 - c) & (c - 96)) >>> 8) & (-INVALID_BYTE + c - 95 + 63);\n // c > 47 and c < 58\n result += (((47 - c) & (c - 58)) >>> 8) & (-INVALID_BYTE + c - 48 + 52);\n // c > 64 and c < 91\n result += (((64 - c) & (c - 91)) >>> 8) & (-INVALID_BYTE + c - 65 + 0);\n // c > 96 and c < 123\n result += (((96 - c) & (c - 123)) >>> 8) & (-INVALID_BYTE + c - 97 + 26);\n\n return result;\n }\n}\n\nconst urlSafeCoder = new URLSafeCoder();\n\nexport function encodeURLSafe(data: Uint8Array): string {\n return urlSafeCoder.encode(data);\n}\n\nexport function decodeURLSafe(s: string): Uint8Array {\n return urlSafeCoder.decode(s);\n}\n\n\nexport const encodedLength = (length: number) =>\n stdCoder.encodedLength(length);\n\nexport const maxDecodedLength = (length: number) =>\n stdCoder.maxDecodedLength(length);\n\nexport const decodedLength = (s: string) =>\n stdCoder.decodedLength(s);\n","// Copyright (C) 2016 Dmitry Chestnykh\n// MIT License. See LICENSE file for details.\n\n/**\n * Package utf8 implements UTF-8 encoding and decoding.\n */\n\nconst INVALID_UTF16 = \"utf8: invalid string\";\nconst INVALID_UTF8 = \"utf8: invalid source encoding\";\n\n/**\n * Encodes the given string into UTF-8 byte array.\n * Throws if the source string has invalid UTF-16 encoding.\n */\nexport function encode(s: string): Uint8Array {\n // Calculate result length and allocate output array.\n // encodedLength() also validates string and throws errors,\n // so we don't need repeat validation here.\n const arr = new Uint8Array(encodedLength(s));\n\n let pos = 0;\n for (let i = 0; i < s.length; i++) {\n let c = s.charCodeAt(i);\n if (c < 0x80) {\n arr[pos++] = c;\n } else if (c < 0x800) {\n arr[pos++] = 0xc0 | c >> 6;\n arr[pos++] = 0x80 | c & 0x3f;\n } else if (c < 0xd800) {\n arr[pos++] = 0xe0 | c >> 12;\n arr[pos++] = 0x80 | (c >> 6) & 0x3f;\n arr[pos++] = 0x80 | c & 0x3f;\n } else {\n i++; // get one more character\n c = (c & 0x3ff) << 10;\n c |= s.charCodeAt(i) & 0x3ff;\n c += 0x10000;\n\n arr[pos++] = 0xf0 | c >> 18;\n arr[pos++] = 0x80 | (c >> 12) & 0x3f;\n arr[pos++] = 0x80 | (c >> 6) & 0x3f;\n arr[pos++] = 0x80 | c & 0x3f;\n }\n }\n return arr;\n}\n\n/**\n * Returns the number of bytes required to encode the given string into UTF-8.\n * Throws if the source string has invalid UTF-16 encoding.\n */\nexport function encodedLength(s: string): number {\n let result = 0;\n for (let i = 0; i < s.length; i++) {\n const c = s.charCodeAt(i);\n if (c < 0x80) {\n result += 1;\n } else if (c < 0x800) {\n result += 2;\n } else if (c < 0xd800) {\n result += 3;\n } else if (c <= 0xdfff) {\n if (i >= s.length - 1) {\n throw new Error(INVALID_UTF16);\n }\n i++; // \"eat\" next character\n result += 4;\n } else {\n throw new Error(INVALID_UTF16);\n }\n }\n return result;\n}\n\n/**\n * Decodes the given byte array from UTF-8 into a string.\n * Throws if encoding is invalid.\n */\nexport function decode(arr: Uint8Array): string {\n const chars: string[] = [];\n for (let i = 0; i < arr.length; i++) {\n let b = arr[i];\n\n if (b & 0x80) {\n let min;\n if (b < 0xe0) {\n // Need 1 more byte.\n if (i >= arr.length) {\n throw new Error(INVALID_UTF8);\n }\n const n1 = arr[++i];\n if ((n1 & 0xc0) !== 0x80) {\n throw new Error(INVALID_UTF8);\n }\n b = (b & 0x1f) << 6 | (n1 & 0x3f);\n min = 0x80;\n } else if (b < 0xf0) {\n // Need 2 more bytes.\n if (i >= arr.length - 1) {\n throw new Error(INVALID_UTF8);\n }\n const n1 = arr[++i];\n const n2 = arr[++i];\n if ((n1 & 0xc0) !== 0x80 || (n2 & 0xc0) !== 0x80) {\n throw new Error(INVALID_UTF8);\n }\n b = (b & 0x0f) << 12 | (n1 & 0x3f) << 6 | (n2 & 0x3f);\n min = 0x800;\n } else if (b < 0xf8) {\n // Need 3 more bytes.\n if (i >= arr.length - 2) {\n throw new Error(INVALID_UTF8);\n }\n const n1 = arr[++i];\n const n2 = arr[++i];\n const n3 = arr[++i];\n if ((n1 & 0xc0) !== 0x80 || (n2 & 0xc0) !== 0x80 || (n3 & 0xc0) !== 0x80) {\n throw new Error(INVALID_UTF8);\n }\n b = (b & 0x0f) << 18 | (n1 & 0x3f) << 12 | (n2 & 0x3f) << 6 | (n3 & 0x3f);\n min = 0x10000;\n } else {\n throw new Error(INVALID_UTF8);\n }\n\n if (b < min || (b >= 0xd800 && b <= 0xdfff)) {\n throw new Error(INVALID_UTF8);\n }\n\n if (b >= 0x10000) {\n // Surrogate pair.\n if (b > 0x10ffff) {\n throw new Error(INVALID_UTF8);\n }\n b -= 0x10000;\n chars.push(String.fromCharCode(0xd800 | (b >> 10)));\n b = 0xdc00 | (b & 0x3ff);\n }\n }\n\n chars.push(String.fromCharCode(b));\n }\n return chars.join(\"\");\n}\n","(function(nacl) {\n'use strict';\n\n// Ported in 2014 by Dmitry Chestnykh and Devi Mandiri.\n// Public domain.\n//\n// Implementation derived from TweetNaCl version 20140427.\n// See for details: http://tweetnacl.cr.yp.to/\n\nvar gf = function(init) {\n var i, r = new Float64Array(16);\n if (init) for (i = 0; i < init.length; i++) r[i] = init[i];\n return r;\n};\n\n// Pluggable, initialized in high-level API below.\nvar randombytes = function(/* x, n */) { throw new Error('no PRNG'); };\n\nvar _0 = new Uint8Array(16);\nvar _9 = new Uint8Array(32); _9[0] = 9;\n\nvar gf0 = gf(),\n gf1 = gf([1]),\n _121665 = gf([0xdb41, 1]),\n D = gf([0x78a3, 0x1359, 0x4dca, 0x75eb, 0xd8ab, 0x4141, 0x0a4d, 0x0070, 0xe898, 0x7779, 0x4079, 0x8cc7, 0xfe73, 0x2b6f, 0x6cee, 0x5203]),\n D2 = gf([0xf159, 0x26b2, 0x9b94, 0xebd6, 0xb156, 0x8283, 0x149a, 0x00e0, 0xd130, 0xeef3, 0x80f2, 0x198e, 0xfce7, 0x56df, 0xd9dc, 0x2406]),\n X = gf([0xd51a, 0x8f25, 0x2d60, 0xc956, 0xa7b2, 0x9525, 0xc760, 0x692c, 0xdc5c, 0xfdd6, 0xe231, 0xc0a4, 0x53fe, 0xcd6e, 0x36d3, 0x2169]),\n Y = gf([0x6658, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666]),\n I = gf([0xa0b0, 0x4a0e, 0x1b27, 0xc4ee, 0xe478, 0xad2f, 0x1806, 0x2f43, 0xd7a7, 0x3dfb, 0x0099, 0x2b4d, 0xdf0b, 0x4fc1, 0x2480, 0x2b83]);\n\nfunction ts64(x, i, h, l) {\n x[i] = (h >> 24) & 0xff;\n x[i+1] = (h >> 16) & 0xff;\n x[i+2] = (h >> 8) & 0xff;\n x[i+3] = h & 0xff;\n x[i+4] = (l >> 24) & 0xff;\n x[i+5] = (l >> 16) & 0xff;\n x[i+6] = (l >> 8) & 0xff;\n x[i+7] = l & 0xff;\n}\n\nfunction vn(x, xi, y, yi, n) {\n var i,d = 0;\n for (i = 0; i < n; i++) d |= x[xi+i]^y[yi+i];\n return (1 & ((d - 1) >>> 8)) - 1;\n}\n\nfunction crypto_verify_16(x, xi, y, yi) {\n return vn(x,xi,y,yi,16);\n}\n\nfunction crypto_verify_32(x, xi, y, yi) {\n return vn(x,xi,y,yi,32);\n}\n\nfunction core_salsa20(o, p, k, c) {\n var j0 = c[ 0] & 0xff | (c[ 1] & 0xff)<<8 | (c[ 2] & 0xff)<<16 | (c[ 3] & 0xff)<<24,\n j1 = k[ 0] & 0xff | (k[ 1] & 0xff)<<8 | (k[ 2] & 0xff)<<16 | (k[ 3] & 0xff)<<24,\n j2 = k[ 4] & 0xff | (k[ 5] & 0xff)<<8 | (k[ 6] & 0xff)<<16 | (k[ 7] & 0xff)<<24,\n j3 = k[ 8] & 0xff | (k[ 9] & 0xff)<<8 | (k[10] & 0xff)<<16 | (k[11] & 0xff)<<24,\n j4 = k[12] & 0xff | (k[13] & 0xff)<<8 | (k[14] & 0xff)<<16 | (k[15] & 0xff)<<24,\n j5 = c[ 4] & 0xff | (c[ 5] & 0xff)<<8 | (c[ 6] & 0xff)<<16 | (c[ 7] & 0xff)<<24,\n j6 = p[ 0] & 0xff | (p[ 1] & 0xff)<<8 | (p[ 2] & 0xff)<<16 | (p[ 3] & 0xff)<<24,\n j7 = p[ 4] & 0xff | (p[ 5] & 0xff)<<8 | (p[ 6] & 0xff)<<16 | (p[ 7] & 0xff)<<24,\n j8 = p[ 8] & 0xff | (p[ 9] & 0xff)<<8 | (p[10] & 0xff)<<16 | (p[11] & 0xff)<<24,\n j9 = p[12] & 0xff | (p[13] & 0xff)<<8 | (p[14] & 0xff)<<16 | (p[15] & 0xff)<<24,\n j10 = c[ 8] & 0xff | (c[ 9] & 0xff)<<8 | (c[10] & 0xff)<<16 | (c[11] & 0xff)<<24,\n j11 = k[16] & 0xff | (k[17] & 0xff)<<8 | (k[18] & 0xff)<<16 | (k[19] & 0xff)<<24,\n j12 = k[20] & 0xff | (k[21] & 0xff)<<8 | (k[22] & 0xff)<<16 | (k[23] & 0xff)<<24,\n j13 = k[24] & 0xff | (k[25] & 0xff)<<8 | (k[26] & 0xff)<<16 | (k[27] & 0xff)<<24,\n j14 = k[28] & 0xff | (k[29] & 0xff)<<8 | (k[30] & 0xff)<<16 | (k[31] & 0xff)<<24,\n j15 = c[12] & 0xff | (c[13] & 0xff)<<8 | (c[14] & 0xff)<<16 | (c[15] & 0xff)<<24;\n\n var x0 = j0, x1 = j1, x2 = j2, x3 = j3, x4 = j4, x5 = j5, x6 = j6, x7 = j7,\n x8 = j8, x9 = j9, x10 = j10, x11 = j11, x12 = j12, x13 = j13, x14 = j14,\n x15 = j15, u;\n\n for (var i = 0; i < 20; i += 2) {\n u = x0 + x12 | 0;\n x4 ^= u<<7 | u>>>(32-7);\n u = x4 + x0 | 0;\n x8 ^= u<<9 | u>>>(32-9);\n u = x8 + x4 | 0;\n x12 ^= u<<13 | u>>>(32-13);\n u = x12 + x8 | 0;\n x0 ^= u<<18 | u>>>(32-18);\n\n u = x5 + x1 | 0;\n x9 ^= u<<7 | u>>>(32-7);\n u = x9 + x5 | 0;\n x13 ^= u<<9 | u>>>(32-9);\n u = x13 + x9 | 0;\n x1 ^= u<<13 | u>>>(32-13);\n u = x1 + x13 | 0;\n x5 ^= u<<18 | u>>>(32-18);\n\n u = x10 + x6 | 0;\n x14 ^= u<<7 | u>>>(32-7);\n u = x14 + x10 | 0;\n x2 ^= u<<9 | u>>>(32-9);\n u = x2 + x14 | 0;\n x6 ^= u<<13 | u>>>(32-13);\n u = x6 + x2 | 0;\n x10 ^= u<<18 | u>>>(32-18);\n\n u = x15 + x11 | 0;\n x3 ^= u<<7 | u>>>(32-7);\n u = x3 + x15 | 0;\n x7 ^= u<<9 | u>>>(32-9);\n u = x7 + x3 | 0;\n x11 ^= u<<13 | u>>>(32-13);\n u = x11 + x7 | 0;\n x15 ^= u<<18 | u>>>(32-18);\n\n u = x0 + x3 | 0;\n x1 ^= u<<7 | u>>>(32-7);\n u = x1 + x0 | 0;\n x2 ^= u<<9 | u>>>(32-9);\n u = x2 + x1 | 0;\n x3 ^= u<<13 | u>>>(32-13);\n u = x3 + x2 | 0;\n x0 ^= u<<18 | u>>>(32-18);\n\n u = x5 + x4 | 0;\n x6 ^= u<<7 | u>>>(32-7);\n u = x6 + x5 | 0;\n x7 ^= u<<9 | u>>>(32-9);\n u = x7 + x6 | 0;\n x4 ^= u<<13 | u>>>(32-13);\n u = x4 + x7 | 0;\n x5 ^= u<<18 | u>>>(32-18);\n\n u = x10 + x9 | 0;\n x11 ^= u<<7 | u>>>(32-7);\n u = x11 + x10 | 0;\n x8 ^= u<<9 | u>>>(32-9);\n u = x8 + x11 | 0;\n x9 ^= u<<13 | u>>>(32-13);\n u = x9 + x8 | 0;\n x10 ^= u<<18 | u>>>(32-18);\n\n u = x15 + x14 | 0;\n x12 ^= u<<7 | u>>>(32-7);\n u = x12 + x15 | 0;\n x13 ^= u<<9 | u>>>(32-9);\n u = x13 + x12 | 0;\n x14 ^= u<<13 | u>>>(32-13);\n u = x14 + x13 | 0;\n x15 ^= u<<18 | u>>>(32-18);\n }\n x0 = x0 + j0 | 0;\n x1 = x1 + j1 | 0;\n x2 = x2 + j2 | 0;\n x3 = x3 + j3 | 0;\n x4 = x4 + j4 | 0;\n x5 = x5 + j5 | 0;\n x6 = x6 + j6 | 0;\n x7 = x7 + j7 | 0;\n x8 = x8 + j8 | 0;\n x9 = x9 + j9 | 0;\n x10 = x10 + j10 | 0;\n x11 = x11 + j11 | 0;\n x12 = x12 + j12 | 0;\n x13 = x13 + j13 | 0;\n x14 = x14 + j14 | 0;\n x15 = x15 + j15 | 0;\n\n o[ 0] = x0 >>> 0 & 0xff;\n o[ 1] = x0 >>> 8 & 0xff;\n o[ 2] = x0 >>> 16 & 0xff;\n o[ 3] = x0 >>> 24 & 0xff;\n\n o[ 4] = x1 >>> 0 & 0xff;\n o[ 5] = x1 >>> 8 & 0xff;\n o[ 6] = x1 >>> 16 & 0xff;\n o[ 7] = x1 >>> 24 & 0xff;\n\n o[ 8] = x2 >>> 0 & 0xff;\n o[ 9] = x2 >>> 8 & 0xff;\n o[10] = x2 >>> 16 & 0xff;\n o[11] = x2 >>> 24 & 0xff;\n\n o[12] = x3 >>> 0 & 0xff;\n o[13] = x3 >>> 8 & 0xff;\n o[14] = x3 >>> 16 & 0xff;\n o[15] = x3 >>> 24 & 0xff;\n\n o[16] = x4 >>> 0 & 0xff;\n o[17] = x4 >>> 8 & 0xff;\n o[18] = x4 >>> 16 & 0xff;\n o[19] = x4 >>> 24 & 0xff;\n\n o[20] = x5 >>> 0 & 0xff;\n o[21] = x5 >>> 8 & 0xff;\n o[22] = x5 >>> 16 & 0xff;\n o[23] = x5 >>> 24 & 0xff;\n\n o[24] = x6 >>> 0 & 0xff;\n o[25] = x6 >>> 8 & 0xff;\n o[26] = x6 >>> 16 & 0xff;\n o[27] = x6 >>> 24 & 0xff;\n\n o[28] = x7 >>> 0 & 0xff;\n o[29] = x7 >>> 8 & 0xff;\n o[30] = x7 >>> 16 & 0xff;\n o[31] = x7 >>> 24 & 0xff;\n\n o[32] = x8 >>> 0 & 0xff;\n o[33] = x8 >>> 8 & 0xff;\n o[34] = x8 >>> 16 & 0xff;\n o[35] = x8 >>> 24 & 0xff;\n\n o[36] = x9 >>> 0 & 0xff;\n o[37] = x9 >>> 8 & 0xff;\n o[38] = x9 >>> 16 & 0xff;\n o[39] = x9 >>> 24 & 0xff;\n\n o[40] = x10 >>> 0 & 0xff;\n o[41] = x10 >>> 8 & 0xff;\n o[42] = x10 >>> 16 & 0xff;\n o[43] = x10 >>> 24 & 0xff;\n\n o[44] = x11 >>> 0 & 0xff;\n o[45] = x11 >>> 8 & 0xff;\n o[46] = x11 >>> 16 & 0xff;\n o[47] = x11 >>> 24 & 0xff;\n\n o[48] = x12 >>> 0 & 0xff;\n o[49] = x12 >>> 8 & 0xff;\n o[50] = x12 >>> 16 & 0xff;\n o[51] = x12 >>> 24 & 0xff;\n\n o[52] = x13 >>> 0 & 0xff;\n o[53] = x13 >>> 8 & 0xff;\n o[54] = x13 >>> 16 & 0xff;\n o[55] = x13 >>> 24 & 0xff;\n\n o[56] = x14 >>> 0 & 0xff;\n o[57] = x14 >>> 8 & 0xff;\n o[58] = x14 >>> 16 & 0xff;\n o[59] = x14 >>> 24 & 0xff;\n\n o[60] = x15 >>> 0 & 0xff;\n o[61] = x15 >>> 8 & 0xff;\n o[62] = x15 >>> 16 & 0xff;\n o[63] = x15 >>> 24 & 0xff;\n}\n\nfunction core_hsalsa20(o,p,k,c) {\n var j0 = c[ 0] & 0xff | (c[ 1] & 0xff)<<8 | (c[ 2] & 0xff)<<16 | (c[ 3] & 0xff)<<24,\n j1 = k[ 0] & 0xff | (k[ 1] & 0xff)<<8 | (k[ 2] & 0xff)<<16 | (k[ 3] & 0xff)<<24,\n j2 = k[ 4] & 0xff | (k[ 5] & 0xff)<<8 | (k[ 6] & 0xff)<<16 | (k[ 7] & 0xff)<<24,\n j3 = k[ 8] & 0xff | (k[ 9] & 0xff)<<8 | (k[10] & 0xff)<<16 | (k[11] & 0xff)<<24,\n j4 = k[12] & 0xff | (k[13] & 0xff)<<8 | (k[14] & 0xff)<<16 | (k[15] & 0xff)<<24,\n j5 = c[ 4] & 0xff | (c[ 5] & 0xff)<<8 | (c[ 6] & 0xff)<<16 | (c[ 7] & 0xff)<<24,\n j6 = p[ 0] & 0xff | (p[ 1] & 0xff)<<8 | (p[ 2] & 0xff)<<16 | (p[ 3] & 0xff)<<24,\n j7 = p[ 4] & 0xff | (p[ 5] & 0xff)<<8 | (p[ 6] & 0xff)<<16 | (p[ 7] & 0xff)<<24,\n j8 = p[ 8] & 0xff | (p[ 9] & 0xff)<<8 | (p[10] & 0xff)<<16 | (p[11] & 0xff)<<24,\n j9 = p[12] & 0xff | (p[13] & 0xff)<<8 | (p[14] & 0xff)<<16 | (p[15] & 0xff)<<24,\n j10 = c[ 8] & 0xff | (c[ 9] & 0xff)<<8 | (c[10] & 0xff)<<16 | (c[11] & 0xff)<<24,\n j11 = k[16] & 0xff | (k[17] & 0xff)<<8 | (k[18] & 0xff)<<16 | (k[19] & 0xff)<<24,\n j12 = k[20] & 0xff | (k[21] & 0xff)<<8 | (k[22] & 0xff)<<16 | (k[23] & 0xff)<<24,\n j13 = k[24] & 0xff | (k[25] & 0xff)<<8 | (k[26] & 0xff)<<16 | (k[27] & 0xff)<<24,\n j14 = k[28] & 0xff | (k[29] & 0xff)<<8 | (k[30] & 0xff)<<16 | (k[31] & 0xff)<<24,\n j15 = c[12] & 0xff | (c[13] & 0xff)<<8 | (c[14] & 0xff)<<16 | (c[15] & 0xff)<<24;\n\n var x0 = j0, x1 = j1, x2 = j2, x3 = j3, x4 = j4, x5 = j5, x6 = j6, x7 = j7,\n x8 = j8, x9 = j9, x10 = j10, x11 = j11, x12 = j12, x13 = j13, x14 = j14,\n x15 = j15, u;\n\n for (var i = 0; i < 20; i += 2) {\n u = x0 + x12 | 0;\n x4 ^= u<<7 | u>>>(32-7);\n u = x4 + x0 | 0;\n x8 ^= u<<9 | u>>>(32-9);\n u = x8 + x4 | 0;\n x12 ^= u<<13 | u>>>(32-13);\n u = x12 + x8 | 0;\n x0 ^= u<<18 | u>>>(32-18);\n\n u = x5 + x1 | 0;\n x9 ^= u<<7 | u>>>(32-7);\n u = x9 + x5 | 0;\n x13 ^= u<<9 | u>>>(32-9);\n u = x13 + x9 | 0;\n x1 ^= u<<13 | u>>>(32-13);\n u = x1 + x13 | 0;\n x5 ^= u<<18 | u>>>(32-18);\n\n u = x10 + x6 | 0;\n x14 ^= u<<7 | u>>>(32-7);\n u = x14 + x10 | 0;\n x2 ^= u<<9 | u>>>(32-9);\n u = x2 + x14 | 0;\n x6 ^= u<<13 | u>>>(32-13);\n u = x6 + x2 | 0;\n x10 ^= u<<18 | u>>>(32-18);\n\n u = x15 + x11 | 0;\n x3 ^= u<<7 | u>>>(32-7);\n u = x3 + x15 | 0;\n x7 ^= u<<9 | u>>>(32-9);\n u = x7 + x3 | 0;\n x11 ^= u<<13 | u>>>(32-13);\n u = x11 + x7 | 0;\n x15 ^= u<<18 | u>>>(32-18);\n\n u = x0 + x3 | 0;\n x1 ^= u<<7 | u>>>(32-7);\n u = x1 + x0 | 0;\n x2 ^= u<<9 | u>>>(32-9);\n u = x2 + x1 | 0;\n x3 ^= u<<13 | u>>>(32-13);\n u = x3 + x2 | 0;\n x0 ^= u<<18 | u>>>(32-18);\n\n u = x5 + x4 | 0;\n x6 ^= u<<7 | u>>>(32-7);\n u = x6 + x5 | 0;\n x7 ^= u<<9 | u>>>(32-9);\n u = x7 + x6 | 0;\n x4 ^= u<<13 | u>>>(32-13);\n u = x4 + x7 | 0;\n x5 ^= u<<18 | u>>>(32-18);\n\n u = x10 + x9 | 0;\n x11 ^= u<<7 | u>>>(32-7);\n u = x11 + x10 | 0;\n x8 ^= u<<9 | u>>>(32-9);\n u = x8 + x11 | 0;\n x9 ^= u<<13 | u>>>(32-13);\n u = x9 + x8 | 0;\n x10 ^= u<<18 | u>>>(32-18);\n\n u = x15 + x14 | 0;\n x12 ^= u<<7 | u>>>(32-7);\n u = x12 + x15 | 0;\n x13 ^= u<<9 | u>>>(32-9);\n u = x13 + x12 | 0;\n x14 ^= u<<13 | u>>>(32-13);\n u = x14 + x13 | 0;\n x15 ^= u<<18 | u>>>(32-18);\n }\n\n o[ 0] = x0 >>> 0 & 0xff;\n o[ 1] = x0 >>> 8 & 0xff;\n o[ 2] = x0 >>> 16 & 0xff;\n o[ 3] = x0 >>> 24 & 0xff;\n\n o[ 4] = x5 >>> 0 & 0xff;\n o[ 5] = x5 >>> 8 & 0xff;\n o[ 6] = x5 >>> 16 & 0xff;\n o[ 7] = x5 >>> 24 & 0xff;\n\n o[ 8] = x10 >>> 0 & 0xff;\n o[ 9] = x10 >>> 8 & 0xff;\n o[10] = x10 >>> 16 & 0xff;\n o[11] = x10 >>> 24 & 0xff;\n\n o[12] = x15 >>> 0 & 0xff;\n o[13] = x15 >>> 8 & 0xff;\n o[14] = x15 >>> 16 & 0xff;\n o[15] = x15 >>> 24 & 0xff;\n\n o[16] = x6 >>> 0 & 0xff;\n o[17] = x6 >>> 8 & 0xff;\n o[18] = x6 >>> 16 & 0xff;\n o[19] = x6 >>> 24 & 0xff;\n\n o[20] = x7 >>> 0 & 0xff;\n o[21] = x7 >>> 8 & 0xff;\n o[22] = x7 >>> 16 & 0xff;\n o[23] = x7 >>> 24 & 0xff;\n\n o[24] = x8 >>> 0 & 0xff;\n o[25] = x8 >>> 8 & 0xff;\n o[26] = x8 >>> 16 & 0xff;\n o[27] = x8 >>> 24 & 0xff;\n\n o[28] = x9 >>> 0 & 0xff;\n o[29] = x9 >>> 8 & 0xff;\n o[30] = x9 >>> 16 & 0xff;\n o[31] = x9 >>> 24 & 0xff;\n}\n\nfunction crypto_core_salsa20(out,inp,k,c) {\n core_salsa20(out,inp,k,c);\n}\n\nfunction crypto_core_hsalsa20(out,inp,k,c) {\n core_hsalsa20(out,inp,k,c);\n}\n\nvar sigma = new Uint8Array([101, 120, 112, 97, 110, 100, 32, 51, 50, 45, 98, 121, 116, 101, 32, 107]);\n // \"expand 32-byte k\"\n\nfunction crypto_stream_salsa20_xor(c,cpos,m,mpos,b,n,k) {\n var z = new Uint8Array(16), x = new Uint8Array(64);\n var u, i;\n for (i = 0; i < 16; i++) z[i] = 0;\n for (i = 0; i < 8; i++) z[i] = n[i];\n while (b >= 64) {\n crypto_core_salsa20(x,z,k,sigma);\n for (i = 0; i < 64; i++) c[cpos+i] = m[mpos+i] ^ x[i];\n u = 1;\n for (i = 8; i < 16; i++) {\n u = u + (z[i] & 0xff) | 0;\n z[i] = u & 0xff;\n u >>>= 8;\n }\n b -= 64;\n cpos += 64;\n mpos += 64;\n }\n if (b > 0) {\n crypto_core_salsa20(x,z,k,sigma);\n for (i = 0; i < b; i++) c[cpos+i] = m[mpos+i] ^ x[i];\n }\n return 0;\n}\n\nfunction crypto_stream_salsa20(c,cpos,b,n,k) {\n var z = new Uint8Array(16), x = new Uint8Array(64);\n var u, i;\n for (i = 0; i < 16; i++) z[i] = 0;\n for (i = 0; i < 8; i++) z[i] = n[i];\n while (b >= 64) {\n crypto_core_salsa20(x,z,k,sigma);\n for (i = 0; i < 64; i++) c[cpos+i] = x[i];\n u = 1;\n for (i = 8; i < 16; i++) {\n u = u + (z[i] & 0xff) | 0;\n z[i] = u & 0xff;\n u >>>= 8;\n }\n b -= 64;\n cpos += 64;\n }\n if (b > 0) {\n crypto_core_salsa20(x,z,k,sigma);\n for (i = 0; i < b; i++) c[cpos+i] = x[i];\n }\n return 0;\n}\n\nfunction crypto_stream(c,cpos,d,n,k) {\n var s = new Uint8Array(32);\n crypto_core_hsalsa20(s,n,k,sigma);\n var sn = new Uint8Array(8);\n for (var i = 0; i < 8; i++) sn[i] = n[i+16];\n return crypto_stream_salsa20(c,cpos,d,sn,s);\n}\n\nfunction crypto_stream_xor(c,cpos,m,mpos,d,n,k) {\n var s = new Uint8Array(32);\n crypto_core_hsalsa20(s,n,k,sigma);\n var sn = new Uint8Array(8);\n for (var i = 0; i < 8; i++) sn[i] = n[i+16];\n return crypto_stream_salsa20_xor(c,cpos,m,mpos,d,sn,s);\n}\n\n/*\n* Port of Andrew Moon's Poly1305-donna-16. Public domain.\n* https://github.com/floodyberry/poly1305-donna\n*/\n\nvar poly1305 = function(key) {\n this.buffer = new Uint8Array(16);\n this.r = new Uint16Array(10);\n this.h = new Uint16Array(10);\n this.pad = new Uint16Array(8);\n this.leftover = 0;\n this.fin = 0;\n\n var t0, t1, t2, t3, t4, t5, t6, t7;\n\n t0 = key[ 0] & 0xff | (key[ 1] & 0xff) << 8; this.r[0] = ( t0 ) & 0x1fff;\n t1 = key[ 2] & 0xff | (key[ 3] & 0xff) << 8; this.r[1] = ((t0 >>> 13) | (t1 << 3)) & 0x1fff;\n t2 = key[ 4] & 0xff | (key[ 5] & 0xff) << 8; this.r[2] = ((t1 >>> 10) | (t2 << 6)) & 0x1f03;\n t3 = key[ 6] & 0xff | (key[ 7] & 0xff) << 8; this.r[3] = ((t2 >>> 7) | (t3 << 9)) & 0x1fff;\n t4 = key[ 8] & 0xff | (key[ 9] & 0xff) << 8; this.r[4] = ((t3 >>> 4) | (t4 << 12)) & 0x00ff;\n this.r[5] = ((t4 >>> 1)) & 0x1ffe;\n t5 = key[10] & 0xff | (key[11] & 0xff) << 8; this.r[6] = ((t4 >>> 14) | (t5 << 2)) & 0x1fff;\n t6 = key[12] & 0xff | (key[13] & 0xff) << 8; this.r[7] = ((t5 >>> 11) | (t6 << 5)) & 0x1f81;\n t7 = key[14] & 0xff | (key[15] & 0xff) << 8; this.r[8] = ((t6 >>> 8) | (t7 << 8)) & 0x1fff;\n this.r[9] = ((t7 >>> 5)) & 0x007f;\n\n this.pad[0] = key[16] & 0xff | (key[17] & 0xff) << 8;\n this.pad[1] = key[18] & 0xff | (key[19] & 0xff) << 8;\n this.pad[2] = key[20] & 0xff | (key[21] & 0xff) << 8;\n this.pad[3] = key[22] & 0xff | (key[23] & 0xff) << 8;\n this.pad[4] = key[24] & 0xff | (key[25] & 0xff) << 8;\n this.pad[5] = key[26] & 0xff | (key[27] & 0xff) << 8;\n this.pad[6] = key[28] & 0xff | (key[29] & 0xff) << 8;\n this.pad[7] = key[30] & 0xff | (key[31] & 0xff) << 8;\n};\n\npoly1305.prototype.blocks = function(m, mpos, bytes) {\n var hibit = this.fin ? 0 : (1 << 11);\n var t0, t1, t2, t3, t4, t5, t6, t7, c;\n var d0, d1, d2, d3, d4, d5, d6, d7, d8, d9;\n\n var h0 = this.h[0],\n h1 = this.h[1],\n h2 = this.h[2],\n h3 = this.h[3],\n h4 = this.h[4],\n h5 = this.h[5],\n h6 = this.h[6],\n h7 = this.h[7],\n h8 = this.h[8],\n h9 = this.h[9];\n\n var r0 = this.r[0],\n r1 = this.r[1],\n r2 = this.r[2],\n r3 = this.r[3],\n r4 = this.r[4],\n r5 = this.r[5],\n r6 = this.r[6],\n r7 = this.r[7],\n r8 = this.r[8],\n r9 = this.r[9];\n\n while (bytes >= 16) {\n t0 = m[mpos+ 0] & 0xff | (m[mpos+ 1] & 0xff) << 8; h0 += ( t0 ) & 0x1fff;\n t1 = m[mpos+ 2] & 0xff | (m[mpos+ 3] & 0xff) << 8; h1 += ((t0 >>> 13) | (t1 << 3)) & 0x1fff;\n t2 = m[mpos+ 4] & 0xff | (m[mpos+ 5] & 0xff) << 8; h2 += ((t1 >>> 10) | (t2 << 6)) & 0x1fff;\n t3 = m[mpos+ 6] & 0xff | (m[mpos+ 7] & 0xff) << 8; h3 += ((t2 >>> 7) | (t3 << 9)) & 0x1fff;\n t4 = m[mpos+ 8] & 0xff | (m[mpos+ 9] & 0xff) << 8; h4 += ((t3 >>> 4) | (t4 << 12)) & 0x1fff;\n h5 += ((t4 >>> 1)) & 0x1fff;\n t5 = m[mpos+10] & 0xff | (m[mpos+11] & 0xff) << 8; h6 += ((t4 >>> 14) | (t5 << 2)) & 0x1fff;\n t6 = m[mpos+12] & 0xff | (m[mpos+13] & 0xff) << 8; h7 += ((t5 >>> 11) | (t6 << 5)) & 0x1fff;\n t7 = m[mpos+14] & 0xff | (m[mpos+15] & 0xff) << 8; h8 += ((t6 >>> 8) | (t7 << 8)) & 0x1fff;\n h9 += ((t7 >>> 5)) | hibit;\n\n c = 0;\n\n d0 = c;\n d0 += h0 * r0;\n d0 += h1 * (5 * r9);\n d0 += h2 * (5 * r8);\n d0 += h3 * (5 * r7);\n d0 += h4 * (5 * r6);\n c = (d0 >>> 13); d0 &= 0x1fff;\n d0 += h5 * (5 * r5);\n d0 += h6 * (5 * r4);\n d0 += h7 * (5 * r3);\n d0 += h8 * (5 * r2);\n d0 += h9 * (5 * r1);\n c += (d0 >>> 13); d0 &= 0x1fff;\n\n d1 = c;\n d1 += h0 * r1;\n d1 += h1 * r0;\n d1 += h2 * (5 * r9);\n d1 += h3 * (5 * r8);\n d1 += h4 * (5 * r7);\n c = (d1 >>> 13); d1 &= 0x1fff;\n d1 += h5 * (5 * r6);\n d1 += h6 * (5 * r5);\n d1 += h7 * (5 * r4);\n d1 += h8 * (5 * r3);\n d1 += h9 * (5 * r2);\n c += (d1 >>> 13); d1 &= 0x1fff;\n\n d2 = c;\n d2 += h0 * r2;\n d2 += h1 * r1;\n d2 += h2 * r0;\n d2 += h3 * (5 * r9);\n d2 += h4 * (5 * r8);\n c = (d2 >>> 13); d2 &= 0x1fff;\n d2 += h5 * (5 * r7);\n d2 += h6 * (5 * r6);\n d2 += h7 * (5 * r5);\n d2 += h8 * (5 * r4);\n d2 += h9 * (5 * r3);\n c += (d2 >>> 13); d2 &= 0x1fff;\n\n d3 = c;\n d3 += h0 * r3;\n d3 += h1 * r2;\n d3 += h2 * r1;\n d3 += h3 * r0;\n d3 += h4 * (5 * r9);\n c = (d3 >>> 13); d3 &= 0x1fff;\n d3 += h5 * (5 * r8);\n d3 += h6 * (5 * r7);\n d3 += h7 * (5 * r6);\n d3 += h8 * (5 * r5);\n d3 += h9 * (5 * r4);\n c += (d3 >>> 13); d3 &= 0x1fff;\n\n d4 = c;\n d4 += h0 * r4;\n d4 += h1 * r3;\n d4 += h2 * r2;\n d4 += h3 * r1;\n d4 += h4 * r0;\n c = (d4 >>> 13); d4 &= 0x1fff;\n d4 += h5 * (5 * r9);\n d4 += h6 * (5 * r8);\n d4 += h7 * (5 * r7);\n d4 += h8 * (5 * r6);\n d4 += h9 * (5 * r5);\n c += (d4 >>> 13); d4 &= 0x1fff;\n\n d5 = c;\n d5 += h0 * r5;\n d5 += h1 * r4;\n d5 += h2 * r3;\n d5 += h3 * r2;\n d5 += h4 * r1;\n c = (d5 >>> 13); d5 &= 0x1fff;\n d5 += h5 * r0;\n d5 += h6 * (5 * r9);\n d5 += h7 * (5 * r8);\n d5 += h8 * (5 * r7);\n d5 += h9 * (5 * r6);\n c += (d5 >>> 13); d5 &= 0x1fff;\n\n d6 = c;\n d6 += h0 * r6;\n d6 += h1 * r5;\n d6 += h2 * r4;\n d6 += h3 * r3;\n d6 += h4 * r2;\n c = (d6 >>> 13); d6 &= 0x1fff;\n d6 += h5 * r1;\n d6 += h6 * r0;\n d6 += h7 * (5 * r9);\n d6 += h8 * (5 * r8);\n d6 += h9 * (5 * r7);\n c += (d6 >>> 13); d6 &= 0x1fff;\n\n d7 = c;\n d7 += h0 * r7;\n d7 += h1 * r6;\n d7 += h2 * r5;\n d7 += h3 * r4;\n d7 += h4 * r3;\n c = (d7 >>> 13); d7 &= 0x1fff;\n d7 += h5 * r2;\n d7 += h6 * r1;\n d7 += h7 * r0;\n d7 += h8 * (5 * r9);\n d7 += h9 * (5 * r8);\n c += (d7 >>> 13); d7 &= 0x1fff;\n\n d8 = c;\n d8 += h0 * r8;\n d8 += h1 * r7;\n d8 += h2 * r6;\n d8 += h3 * r5;\n d8 += h4 * r4;\n c = (d8 >>> 13); d8 &= 0x1fff;\n d8 += h5 * r3;\n d8 += h6 * r2;\n d8 += h7 * r1;\n d8 += h8 * r0;\n d8 += h9 * (5 * r9);\n c += (d8 >>> 13); d8 &= 0x1fff;\n\n d9 = c;\n d9 += h0 * r9;\n d9 += h1 * r8;\n d9 += h2 * r7;\n d9 += h3 * r6;\n d9 += h4 * r5;\n c = (d9 >>> 13); d9 &= 0x1fff;\n d9 += h5 * r4;\n d9 += h6 * r3;\n d9 += h7 * r2;\n d9 += h8 * r1;\n d9 += h9 * r0;\n c += (d9 >>> 13); d9 &= 0x1fff;\n\n c = (((c << 2) + c)) | 0;\n c = (c + d0) | 0;\n d0 = c & 0x1fff;\n c = (c >>> 13);\n d1 += c;\n\n h0 = d0;\n h1 = d1;\n h2 = d2;\n h3 = d3;\n h4 = d4;\n h5 = d5;\n h6 = d6;\n h7 = d7;\n h8 = d8;\n h9 = d9;\n\n mpos += 16;\n bytes -= 16;\n }\n this.h[0] = h0;\n this.h[1] = h1;\n this.h[2] = h2;\n this.h[3] = h3;\n this.h[4] = h4;\n this.h[5] = h5;\n this.h[6] = h6;\n this.h[7] = h7;\n this.h[8] = h8;\n this.h[9] = h9;\n};\n\npoly1305.prototype.finish = function(mac, macpos) {\n var g = new Uint16Array(10);\n var c, mask, f, i;\n\n if (this.leftover) {\n i = this.leftover;\n this.buffer[i++] = 1;\n for (; i < 16; i++) this.buffer[i] = 0;\n this.fin = 1;\n this.blocks(this.buffer, 0, 16);\n }\n\n c = this.h[1] >>> 13;\n this.h[1] &= 0x1fff;\n for (i = 2; i < 10; i++) {\n this.h[i] += c;\n c = this.h[i] >>> 13;\n this.h[i] &= 0x1fff;\n }\n this.h[0] += (c * 5);\n c = this.h[0] >>> 13;\n this.h[0] &= 0x1fff;\n this.h[1] += c;\n c = this.h[1] >>> 13;\n this.h[1] &= 0x1fff;\n this.h[2] += c;\n\n g[0] = this.h[0] + 5;\n c = g[0] >>> 13;\n g[0] &= 0x1fff;\n for (i = 1; i < 10; i++) {\n g[i] = this.h[i] + c;\n c = g[i] >>> 13;\n g[i] &= 0x1fff;\n }\n g[9] -= (1 << 13);\n\n mask = (c ^ 1) - 1;\n for (i = 0; i < 10; i++) g[i] &= mask;\n mask = ~mask;\n for (i = 0; i < 10; i++) this.h[i] = (this.h[i] & mask) | g[i];\n\n this.h[0] = ((this.h[0] ) | (this.h[1] << 13) ) & 0xffff;\n this.h[1] = ((this.h[1] >>> 3) | (this.h[2] << 10) ) & 0xffff;\n this.h[2] = ((this.h[2] >>> 6) | (this.h[3] << 7) ) & 0xffff;\n this.h[3] = ((this.h[3] >>> 9) | (this.h[4] << 4) ) & 0xffff;\n this.h[4] = ((this.h[4] >>> 12) | (this.h[5] << 1) | (this.h[6] << 14)) & 0xffff;\n this.h[5] = ((this.h[6] >>> 2) | (this.h[7] << 11) ) & 0xffff;\n this.h[6] = ((this.h[7] >>> 5) | (this.h[8] << 8) ) & 0xffff;\n this.h[7] = ((this.h[8] >>> 8) | (this.h[9] << 5) ) & 0xffff;\n\n f = this.h[0] + this.pad[0];\n this.h[0] = f & 0xffff;\n for (i = 1; i < 8; i++) {\n f = (((this.h[i] + this.pad[i]) | 0) + (f >>> 16)) | 0;\n this.h[i] = f & 0xffff;\n }\n\n mac[macpos+ 0] = (this.h[0] >>> 0) & 0xff;\n mac[macpos+ 1] = (this.h[0] >>> 8) & 0xff;\n mac[macpos+ 2] = (this.h[1] >>> 0) & 0xff;\n mac[macpos+ 3] = (this.h[1] >>> 8) & 0xff;\n mac[macpos+ 4] = (this.h[2] >>> 0) & 0xff;\n mac[macpos+ 5] = (this.h[2] >>> 8) & 0xff;\n mac[macpos+ 6] = (this.h[3] >>> 0) & 0xff;\n mac[macpos+ 7] = (this.h[3] >>> 8) & 0xff;\n mac[macpos+ 8] = (this.h[4] >>> 0) & 0xff;\n mac[macpos+ 9] = (this.h[4] >>> 8) & 0xff;\n mac[macpos+10] = (this.h[5] >>> 0) & 0xff;\n mac[macpos+11] = (this.h[5] >>> 8) & 0xff;\n mac[macpos+12] = (this.h[6] >>> 0) & 0xff;\n mac[macpos+13] = (this.h[6] >>> 8) & 0xff;\n mac[macpos+14] = (this.h[7] >>> 0) & 0xff;\n mac[macpos+15] = (this.h[7] >>> 8) & 0xff;\n};\n\npoly1305.prototype.update = function(m, mpos, bytes) {\n var i, want;\n\n if (this.leftover) {\n want = (16 - this.leftover);\n if (want > bytes)\n want = bytes;\n for (i = 0; i < want; i++)\n this.buffer[this.leftover + i] = m[mpos+i];\n bytes -= want;\n mpos += want;\n this.leftover += want;\n if (this.leftover < 16)\n return;\n this.blocks(this.buffer, 0, 16);\n this.leftover = 0;\n }\n\n if (bytes >= 16) {\n want = bytes - (bytes % 16);\n this.blocks(m, mpos, want);\n mpos += want;\n bytes -= want;\n }\n\n if (bytes) {\n for (i = 0; i < bytes; i++)\n this.buffer[this.leftover + i] = m[mpos+i];\n this.leftover += bytes;\n }\n};\n\nfunction crypto_onetimeauth(out, outpos, m, mpos, n, k) {\n var s = new poly1305(k);\n s.update(m, mpos, n);\n s.finish(out, outpos);\n return 0;\n}\n\nfunction crypto_onetimeauth_verify(h, hpos, m, mpos, n, k) {\n var x = new Uint8Array(16);\n crypto_onetimeauth(x,0,m,mpos,n,k);\n return crypto_verify_16(h,hpos,x,0);\n}\n\nfunction crypto_secretbox(c,m,d,n,k) {\n var i;\n if (d < 32) return -1;\n crypto_stream_xor(c,0,m,0,d,n,k);\n crypto_onetimeauth(c, 16, c, 32, d - 32, c);\n for (i = 0; i < 16; i++) c[i] = 0;\n return 0;\n}\n\nfunction crypto_secretbox_open(m,c,d,n,k) {\n var i;\n var x = new Uint8Array(32);\n if (d < 32) return -1;\n crypto_stream(x,0,32,n,k);\n if (crypto_onetimeauth_verify(c, 16,c, 32,d - 32,x) !== 0) return -1;\n crypto_stream_xor(m,0,c,0,d,n,k);\n for (i = 0; i < 32; i++) m[i] = 0;\n return 0;\n}\n\nfunction set25519(r, a) {\n var i;\n for (i = 0; i < 16; i++) r[i] = a[i]|0;\n}\n\nfunction car25519(o) {\n var i, v, c = 1;\n for (i = 0; i < 16; i++) {\n v = o[i] + c + 65535;\n c = Math.floor(v / 65536);\n o[i] = v - c * 65536;\n }\n o[0] += c-1 + 37 * (c-1);\n}\n\nfunction sel25519(p, q, b) {\n var t, c = ~(b-1);\n for (var i = 0; i < 16; i++) {\n t = c & (p[i] ^ q[i]);\n p[i] ^= t;\n q[i] ^= t;\n }\n}\n\nfunction pack25519(o, n) {\n var i, j, b;\n var m = gf(), t = gf();\n for (i = 0; i < 16; i++) t[i] = n[i];\n car25519(t);\n car25519(t);\n car25519(t);\n for (j = 0; j < 2; j++) {\n m[0] = t[0] - 0xffed;\n for (i = 1; i < 15; i++) {\n m[i] = t[i] - 0xffff - ((m[i-1]>>16) & 1);\n m[i-1] &= 0xffff;\n }\n m[15] = t[15] - 0x7fff - ((m[14]>>16) & 1);\n b = (m[15]>>16) & 1;\n m[14] &= 0xffff;\n sel25519(t, m, 1-b);\n }\n for (i = 0; i < 16; i++) {\n o[2*i] = t[i] & 0xff;\n o[2*i+1] = t[i]>>8;\n }\n}\n\nfunction neq25519(a, b) {\n var c = new Uint8Array(32), d = new Uint8Array(32);\n pack25519(c, a);\n pack25519(d, b);\n return crypto_verify_32(c, 0, d, 0);\n}\n\nfunction par25519(a) {\n var d = new Uint8Array(32);\n pack25519(d, a);\n return d[0] & 1;\n}\n\nfunction unpack25519(o, n) {\n var i;\n for (i = 0; i < 16; i++) o[i] = n[2*i] + (n[2*i+1] << 8);\n o[15] &= 0x7fff;\n}\n\nfunction A(o, a, b) {\n for (var i = 0; i < 16; i++) o[i] = a[i] + b[i];\n}\n\nfunction Z(o, a, b) {\n for (var i = 0; i < 16; i++) o[i] = a[i] - b[i];\n}\n\nfunction M(o, a, b) {\n var v, c,\n t0 = 0, t1 = 0, t2 = 0, t3 = 0, t4 = 0, t5 = 0, t6 = 0, t7 = 0,\n t8 = 0, t9 = 0, t10 = 0, t11 = 0, t12 = 0, t13 = 0, t14 = 0, t15 = 0,\n t16 = 0, t17 = 0, t18 = 0, t19 = 0, t20 = 0, t21 = 0, t22 = 0, t23 = 0,\n t24 = 0, t25 = 0, t26 = 0, t27 = 0, t28 = 0, t29 = 0, t30 = 0,\n b0 = b[0],\n b1 = b[1],\n b2 = b[2],\n b3 = b[3],\n b4 = b[4],\n b5 = b[5],\n b6 = b[6],\n b7 = b[7],\n b8 = b[8],\n b9 = b[9],\n b10 = b[10],\n b11 = b[11],\n b12 = b[12],\n b13 = b[13],\n b14 = b[14],\n b15 = b[15];\n\n v = a[0];\n t0 += v * b0;\n t1 += v * b1;\n t2 += v * b2;\n t3 += v * b3;\n t4 += v * b4;\n t5 += v * b5;\n t6 += v * b6;\n t7 += v * b7;\n t8 += v * b8;\n t9 += v * b9;\n t10 += v * b10;\n t11 += v * b11;\n t12 += v * b12;\n t13 += v * b13;\n t14 += v * b14;\n t15 += v * b15;\n v = a[1];\n t1 += v * b0;\n t2 += v * b1;\n t3 += v * b2;\n t4 += v * b3;\n t5 += v * b4;\n t6 += v * b5;\n t7 += v * b6;\n t8 += v * b7;\n t9 += v * b8;\n t10 += v * b9;\n t11 += v * b10;\n t12 += v * b11;\n t13 += v * b12;\n t14 += v * b13;\n t15 += v * b14;\n t16 += v * b15;\n v = a[2];\n t2 += v * b0;\n t3 += v * b1;\n t4 += v * b2;\n t5 += v * b3;\n t6 += v * b4;\n t7 += v * b5;\n t8 += v * b6;\n t9 += v * b7;\n t10 += v * b8;\n t11 += v * b9;\n t12 += v * b10;\n t13 += v * b11;\n t14 += v * b12;\n t15 += v * b13;\n t16 += v * b14;\n t17 += v * b15;\n v = a[3];\n t3 += v * b0;\n t4 += v * b1;\n t5 += v * b2;\n t6 += v * b3;\n t7 += v * b4;\n t8 += v * b5;\n t9 += v * b6;\n t10 += v * b7;\n t11 += v * b8;\n t12 += v * b9;\n t13 += v * b10;\n t14 += v * b11;\n t15 += v * b12;\n t16 += v * b13;\n t17 += v * b14;\n t18 += v * b15;\n v = a[4];\n t4 += v * b0;\n t5 += v * b1;\n t6 += v * b2;\n t7 += v * b3;\n t8 += v * b4;\n t9 += v * b5;\n t10 += v * b6;\n t11 += v * b7;\n t12 += v * b8;\n t13 += v * b9;\n t14 += v * b10;\n t15 += v * b11;\n t16 += v * b12;\n t17 += v * b13;\n t18 += v * b14;\n t19 += v * b15;\n v = a[5];\n t5 += v * b0;\n t6 += v * b1;\n t7 += v * b2;\n t8 += v * b3;\n t9 += v * b4;\n t10 += v * b5;\n t11 += v * b6;\n t12 += v * b7;\n t13 += v * b8;\n t14 += v * b9;\n t15 += v * b10;\n t16 += v * b11;\n t17 += v * b12;\n t18 += v * b13;\n t19 += v * b14;\n t20 += v * b15;\n v = a[6];\n t6 += v * b0;\n t7 += v * b1;\n t8 += v * b2;\n t9 += v * b3;\n t10 += v * b4;\n t11 += v * b5;\n t12 += v * b6;\n t13 += v * b7;\n t14 += v * b8;\n t15 += v * b9;\n t16 += v * b10;\n t17 += v * b11;\n t18 += v * b12;\n t19 += v * b13;\n t20 += v * b14;\n t21 += v * b15;\n v = a[7];\n t7 += v * b0;\n t8 += v * b1;\n t9 += v * b2;\n t10 += v * b3;\n t11 += v * b4;\n t12 += v * b5;\n t13 += v * b6;\n t14 += v * b7;\n t15 += v * b8;\n t16 += v * b9;\n t17 += v * b10;\n t18 += v * b11;\n t19 += v * b12;\n t20 += v * b13;\n t21 += v * b14;\n t22 += v * b15;\n v = a[8];\n t8 += v * b0;\n t9 += v * b1;\n t10 += v * b2;\n t11 += v * b3;\n t12 += v * b4;\n t13 += v * b5;\n t14 += v * b6;\n t15 += v * b7;\n t16 += v * b8;\n t17 += v * b9;\n t18 += v * b10;\n t19 += v * b11;\n t20 += v * b12;\n t21 += v * b13;\n t22 += v * b14;\n t23 += v * b15;\n v = a[9];\n t9 += v * b0;\n t10 += v * b1;\n t11 += v * b2;\n t12 += v * b3;\n t13 += v * b4;\n t14 += v * b5;\n t15 += v * b6;\n t16 += v * b7;\n t17 += v * b8;\n t18 += v * b9;\n t19 += v * b10;\n t20 += v * b11;\n t21 += v * b12;\n t22 += v * b13;\n t23 += v * b14;\n t24 += v * b15;\n v = a[10];\n t10 += v * b0;\n t11 += v * b1;\n t12 += v * b2;\n t13 += v * b3;\n t14 += v * b4;\n t15 += v * b5;\n t16 += v * b6;\n t17 += v * b7;\n t18 += v * b8;\n t19 += v * b9;\n t20 += v * b10;\n t21 += v * b11;\n t22 += v * b12;\n t23 += v * b13;\n t24 += v * b14;\n t25 += v * b15;\n v = a[11];\n t11 += v * b0;\n t12 += v * b1;\n t13 += v * b2;\n t14 += v * b3;\n t15 += v * b4;\n t16 += v * b5;\n t17 += v * b6;\n t18 += v * b7;\n t19 += v * b8;\n t20 += v * b9;\n t21 += v * b10;\n t22 += v * b11;\n t23 += v * b12;\n t24 += v * b13;\n t25 += v * b14;\n t26 += v * b15;\n v = a[12];\n t12 += v * b0;\n t13 += v * b1;\n t14 += v * b2;\n t15 += v * b3;\n t16 += v * b4;\n t17 += v * b5;\n t18 += v * b6;\n t19 += v * b7;\n t20 += v * b8;\n t21 += v * b9;\n t22 += v * b10;\n t23 += v * b11;\n t24 += v * b12;\n t25 += v * b13;\n t26 += v * b14;\n t27 += v * b15;\n v = a[13];\n t13 += v * b0;\n t14 += v * b1;\n t15 += v * b2;\n t16 += v * b3;\n t17 += v * b4;\n t18 += v * b5;\n t19 += v * b6;\n t20 += v * b7;\n t21 += v * b8;\n t22 += v * b9;\n t23 += v * b10;\n t24 += v * b11;\n t25 += v * b12;\n t26 += v * b13;\n t27 += v * b14;\n t28 += v * b15;\n v = a[14];\n t14 += v * b0;\n t15 += v * b1;\n t16 += v * b2;\n t17 += v * b3;\n t18 += v * b4;\n t19 += v * b5;\n t20 += v * b6;\n t21 += v * b7;\n t22 += v * b8;\n t23 += v * b9;\n t24 += v * b10;\n t25 += v * b11;\n t26 += v * b12;\n t27 += v * b13;\n t28 += v * b14;\n t29 += v * b15;\n v = a[15];\n t15 += v * b0;\n t16 += v * b1;\n t17 += v * b2;\n t18 += v * b3;\n t19 += v * b4;\n t20 += v * b5;\n t21 += v * b6;\n t22 += v * b7;\n t23 += v * b8;\n t24 += v * b9;\n t25 += v * b10;\n t26 += v * b11;\n t27 += v * b12;\n t28 += v * b13;\n t29 += v * b14;\n t30 += v * b15;\n\n t0 += 38 * t16;\n t1 += 38 * t17;\n t2 += 38 * t18;\n t3 += 38 * t19;\n t4 += 38 * t20;\n t5 += 38 * t21;\n t6 += 38 * t22;\n t7 += 38 * t23;\n t8 += 38 * t24;\n t9 += 38 * t25;\n t10 += 38 * t26;\n t11 += 38 * t27;\n t12 += 38 * t28;\n t13 += 38 * t29;\n t14 += 38 * t30;\n // t15 left as is\n\n // first car\n c = 1;\n v = t0 + c + 65535; c = Math.floor(v / 65536); t0 = v - c * 65536;\n v = t1 + c + 65535; c = Math.floor(v / 65536); t1 = v - c * 65536;\n v = t2 + c + 65535; c = Math.floor(v / 65536); t2 = v - c * 65536;\n v = t3 + c + 65535; c = Math.floor(v / 65536); t3 = v - c * 65536;\n v = t4 + c + 65535; c = Math.floor(v / 65536); t4 = v - c * 65536;\n v = t5 + c + 65535; c = Math.floor(v / 65536); t5 = v - c * 65536;\n v = t6 + c + 65535; c = Math.floor(v / 65536); t6 = v - c * 65536;\n v = t7 + c + 65535; c = Math.floor(v / 65536); t7 = v - c * 65536;\n v = t8 + c + 65535; c = Math.floor(v / 65536); t8 = v - c * 65536;\n v = t9 + c + 65535; c = Math.floor(v / 65536); t9 = v - c * 65536;\n v = t10 + c + 65535; c = Math.floor(v / 65536); t10 = v - c * 65536;\n v = t11 + c + 65535; c = Math.floor(v / 65536); t11 = v - c * 65536;\n v = t12 + c + 65535; c = Math.floor(v / 65536); t12 = v - c * 65536;\n v = t13 + c + 65535; c = Math.floor(v / 65536); t13 = v - c * 65536;\n v = t14 + c + 65535; c = Math.floor(v / 65536); t14 = v - c * 65536;\n v = t15 + c + 65535; c = Math.floor(v / 65536); t15 = v - c * 65536;\n t0 += c-1 + 37 * (c-1);\n\n // second car\n c = 1;\n v = t0 + c + 65535; c = Math.floor(v / 65536); t0 = v - c * 65536;\n v = t1 + c + 65535; c = Math.floor(v / 65536); t1 = v - c * 65536;\n v = t2 + c + 65535; c = Math.floor(v / 65536); t2 = v - c * 65536;\n v = t3 + c + 65535; c = Math.floor(v / 65536); t3 = v - c * 65536;\n v = t4 + c + 65535; c = Math.floor(v / 65536); t4 = v - c * 65536;\n v = t5 + c + 65535; c = Math.floor(v / 65536); t5 = v - c * 65536;\n v = t6 + c + 65535; c = Math.floor(v / 65536); t6 = v - c * 65536;\n v = t7 + c + 65535; c = Math.floor(v / 65536); t7 = v - c * 65536;\n v = t8 + c + 65535; c = Math.floor(v / 65536); t8 = v - c * 65536;\n v = t9 + c + 65535; c = Math.floor(v / 65536); t9 = v - c * 65536;\n v = t10 + c + 65535; c = Math.floor(v / 65536); t10 = v - c * 65536;\n v = t11 + c + 65535; c = Math.floor(v / 65536); t11 = v - c * 65536;\n v = t12 + c + 65535; c = Math.floor(v / 65536); t12 = v - c * 65536;\n v = t13 + c + 65535; c = Math.floor(v / 65536); t13 = v - c * 65536;\n v = t14 + c + 65535; c = Math.floor(v / 65536); t14 = v - c * 65536;\n v = t15 + c + 65535; c = Math.floor(v / 65536); t15 = v - c * 65536;\n t0 += c-1 + 37 * (c-1);\n\n o[ 0] = t0;\n o[ 1] = t1;\n o[ 2] = t2;\n o[ 3] = t3;\n o[ 4] = t4;\n o[ 5] = t5;\n o[ 6] = t6;\n o[ 7] = t7;\n o[ 8] = t8;\n o[ 9] = t9;\n o[10] = t10;\n o[11] = t11;\n o[12] = t12;\n o[13] = t13;\n o[14] = t14;\n o[15] = t15;\n}\n\nfunction S(o, a) {\n M(o, a, a);\n}\n\nfunction inv25519(o, i) {\n var c = gf();\n var a;\n for (a = 0; a < 16; a++) c[a] = i[a];\n for (a = 253; a >= 0; a--) {\n S(c, c);\n if(a !== 2 && a !== 4) M(c, c, i);\n }\n for (a = 0; a < 16; a++) o[a] = c[a];\n}\n\nfunction pow2523(o, i) {\n var c = gf();\n var a;\n for (a = 0; a < 16; a++) c[a] = i[a];\n for (a = 250; a >= 0; a--) {\n S(c, c);\n if(a !== 1) M(c, c, i);\n }\n for (a = 0; a < 16; a++) o[a] = c[a];\n}\n\nfunction crypto_scalarmult(q, n, p) {\n var z = new Uint8Array(32);\n var x = new Float64Array(80), r, i;\n var a = gf(), b = gf(), c = gf(),\n d = gf(), e = gf(), f = gf();\n for (i = 0; i < 31; i++) z[i] = n[i];\n z[31]=(n[31]&127)|64;\n z[0]&=248;\n unpack25519(x,p);\n for (i = 0; i < 16; i++) {\n b[i]=x[i];\n d[i]=a[i]=c[i]=0;\n }\n a[0]=d[0]=1;\n for (i=254; i>=0; --i) {\n r=(z[i>>>3]>>>(i&7))&1;\n sel25519(a,b,r);\n sel25519(c,d,r);\n A(e,a,c);\n Z(a,a,c);\n A(c,b,d);\n Z(b,b,d);\n S(d,e);\n S(f,a);\n M(a,c,a);\n M(c,b,e);\n A(e,a,c);\n Z(a,a,c);\n S(b,a);\n Z(c,d,f);\n M(a,c,_121665);\n A(a,a,d);\n M(c,c,a);\n M(a,d,f);\n M(d,b,x);\n S(b,e);\n sel25519(a,b,r);\n sel25519(c,d,r);\n }\n for (i = 0; i < 16; i++) {\n x[i+16]=a[i];\n x[i+32]=c[i];\n x[i+48]=b[i];\n x[i+64]=d[i];\n }\n var x32 = x.subarray(32);\n var x16 = x.subarray(16);\n inv25519(x32,x32);\n M(x16,x16,x32);\n pack25519(q,x16);\n return 0;\n}\n\nfunction crypto_scalarmult_base(q, n) {\n return crypto_scalarmult(q, n, _9);\n}\n\nfunction crypto_box_keypair(y, x) {\n randombytes(x, 32);\n return crypto_scalarmult_base(y, x);\n}\n\nfunction crypto_box_beforenm(k, y, x) {\n var s = new Uint8Array(32);\n crypto_scalarmult(s, x, y);\n return crypto_core_hsalsa20(k, _0, s, sigma);\n}\n\nvar crypto_box_afternm = crypto_secretbox;\nvar crypto_box_open_afternm = crypto_secretbox_open;\n\nfunction crypto_box(c, m, d, n, y, x) {\n var k = new Uint8Array(32);\n crypto_box_beforenm(k, y, x);\n return crypto_box_afternm(c, m, d, n, k);\n}\n\nfunction crypto_box_open(m, c, d, n, y, x) {\n var k = new Uint8Array(32);\n crypto_box_beforenm(k, y, x);\n return crypto_box_open_afternm(m, c, d, n, k);\n}\n\nvar K = [\n 0x428a2f98, 0xd728ae22, 0x71374491, 0x23ef65cd,\n 0xb5c0fbcf, 0xec4d3b2f, 0xe9b5dba5, 0x8189dbbc,\n 0x3956c25b, 0xf348b538, 0x59f111f1, 0xb605d019,\n 0x923f82a4, 0xaf194f9b, 0xab1c5ed5, 0xda6d8118,\n 0xd807aa98, 0xa3030242, 0x12835b01, 0x45706fbe,\n 0x243185be, 0x4ee4b28c, 0x550c7dc3, 0xd5ffb4e2,\n 0x72be5d74, 0xf27b896f, 0x80deb1fe, 0x3b1696b1,\n 0x9bdc06a7, 0x25c71235, 0xc19bf174, 0xcf692694,\n 0xe49b69c1, 0x9ef14ad2, 0xefbe4786, 0x384f25e3,\n 0x0fc19dc6, 0x8b8cd5b5, 0x240ca1cc, 0x77ac9c65,\n 0x2de92c6f, 0x592b0275, 0x4a7484aa, 0x6ea6e483,\n 0x5cb0a9dc, 0xbd41fbd4, 0x76f988da, 0x831153b5,\n 0x983e5152, 0xee66dfab, 0xa831c66d, 0x2db43210,\n 0xb00327c8, 0x98fb213f, 0xbf597fc7, 0xbeef0ee4,\n 0xc6e00bf3, 0x3da88fc2, 0xd5a79147, 0x930aa725,\n 0x06ca6351, 0xe003826f, 0x14292967, 0x0a0e6e70,\n 0x27b70a85, 0x46d22ffc, 0x2e1b2138, 0x5c26c926,\n 0x4d2c6dfc, 0x5ac42aed, 0x53380d13, 0x9d95b3df,\n 0x650a7354, 0x8baf63de, 0x766a0abb, 0x3c77b2a8,\n 0x81c2c92e, 0x47edaee6, 0x92722c85, 0x1482353b,\n 0xa2bfe8a1, 0x4cf10364, 0xa81a664b, 0xbc423001,\n 0xc24b8b70, 0xd0f89791, 0xc76c51a3, 0x0654be30,\n 0xd192e819, 0xd6ef5218, 0xd6990624, 0x5565a910,\n 0xf40e3585, 0x5771202a, 0x106aa070, 0x32bbd1b8,\n 0x19a4c116, 0xb8d2d0c8, 0x1e376c08, 0x5141ab53,\n 0x2748774c, 0xdf8eeb99, 0x34b0bcb5, 0xe19b48a8,\n 0x391c0cb3, 0xc5c95a63, 0x4ed8aa4a, 0xe3418acb,\n 0x5b9cca4f, 0x7763e373, 0x682e6ff3, 0xd6b2b8a3,\n 0x748f82ee, 0x5defb2fc, 0x78a5636f, 0x43172f60,\n 0x84c87814, 0xa1f0ab72, 0x8cc70208, 0x1a6439ec,\n 0x90befffa, 0x23631e28, 0xa4506ceb, 0xde82bde9,\n 0xbef9a3f7, 0xb2c67915, 0xc67178f2, 0xe372532b,\n 0xca273ece, 0xea26619c, 0xd186b8c7, 0x21c0c207,\n 0xeada7dd6, 0xcde0eb1e, 0xf57d4f7f, 0xee6ed178,\n 0x06f067aa, 0x72176fba, 0x0a637dc5, 0xa2c898a6,\n 0x113f9804, 0xbef90dae, 0x1b710b35, 0x131c471b,\n 0x28db77f5, 0x23047d84, 0x32caab7b, 0x40c72493,\n 0x3c9ebe0a, 0x15c9bebc, 0x431d67c4, 0x9c100d4c,\n 0x4cc5d4be, 0xcb3e42b6, 0x597f299c, 0xfc657e2a,\n 0x5fcb6fab, 0x3ad6faec, 0x6c44198c, 0x4a475817\n];\n\nfunction crypto_hashblocks_hl(hh, hl, m, n) {\n var wh = new Int32Array(16), wl = new Int32Array(16),\n bh0, bh1, bh2, bh3, bh4, bh5, bh6, bh7,\n bl0, bl1, bl2, bl3, bl4, bl5, bl6, bl7,\n th, tl, i, j, h, l, a, b, c, d;\n\n var ah0 = hh[0],\n ah1 = hh[1],\n ah2 = hh[2],\n ah3 = hh[3],\n ah4 = hh[4],\n ah5 = hh[5],\n ah6 = hh[6],\n ah7 = hh[7],\n\n al0 = hl[0],\n al1 = hl[1],\n al2 = hl[2],\n al3 = hl[3],\n al4 = hl[4],\n al5 = hl[5],\n al6 = hl[6],\n al7 = hl[7];\n\n var pos = 0;\n while (n >= 128) {\n for (i = 0; i < 16; i++) {\n j = 8 * i + pos;\n wh[i] = (m[j+0] << 24) | (m[j+1] << 16) | (m[j+2] << 8) | m[j+3];\n wl[i] = (m[j+4] << 24) | (m[j+5] << 16) | (m[j+6] << 8) | m[j+7];\n }\n for (i = 0; i < 80; i++) {\n bh0 = ah0;\n bh1 = ah1;\n bh2 = ah2;\n bh3 = ah3;\n bh4 = ah4;\n bh5 = ah5;\n bh6 = ah6;\n bh7 = ah7;\n\n bl0 = al0;\n bl1 = al1;\n bl2 = al2;\n bl3 = al3;\n bl4 = al4;\n bl5 = al5;\n bl6 = al6;\n bl7 = al7;\n\n // add\n h = ah7;\n l = al7;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n // Sigma1\n h = ((ah4 >>> 14) | (al4 << (32-14))) ^ ((ah4 >>> 18) | (al4 << (32-18))) ^ ((al4 >>> (41-32)) | (ah4 << (32-(41-32))));\n l = ((al4 >>> 14) | (ah4 << (32-14))) ^ ((al4 >>> 18) | (ah4 << (32-18))) ^ ((ah4 >>> (41-32)) | (al4 << (32-(41-32))));\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // Ch\n h = (ah4 & ah5) ^ (~ah4 & ah6);\n l = (al4 & al5) ^ (~al4 & al6);\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // K\n h = K[i*2];\n l = K[i*2+1];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // w\n h = wh[i%16];\n l = wl[i%16];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n th = c & 0xffff | d << 16;\n tl = a & 0xffff | b << 16;\n\n // add\n h = th;\n l = tl;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n // Sigma0\n h = ((ah0 >>> 28) | (al0 << (32-28))) ^ ((al0 >>> (34-32)) | (ah0 << (32-(34-32)))) ^ ((al0 >>> (39-32)) | (ah0 << (32-(39-32))));\n l = ((al0 >>> 28) | (ah0 << (32-28))) ^ ((ah0 >>> (34-32)) | (al0 << (32-(34-32)))) ^ ((ah0 >>> (39-32)) | (al0 << (32-(39-32))));\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // Maj\n h = (ah0 & ah1) ^ (ah0 & ah2) ^ (ah1 & ah2);\n l = (al0 & al1) ^ (al0 & al2) ^ (al1 & al2);\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n bh7 = (c & 0xffff) | (d << 16);\n bl7 = (a & 0xffff) | (b << 16);\n\n // add\n h = bh3;\n l = bl3;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = th;\n l = tl;\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n bh3 = (c & 0xffff) | (d << 16);\n bl3 = (a & 0xffff) | (b << 16);\n\n ah1 = bh0;\n ah2 = bh1;\n ah3 = bh2;\n ah4 = bh3;\n ah5 = bh4;\n ah6 = bh5;\n ah7 = bh6;\n ah0 = bh7;\n\n al1 = bl0;\n al2 = bl1;\n al3 = bl2;\n al4 = bl3;\n al5 = bl4;\n al6 = bl5;\n al7 = bl6;\n al0 = bl7;\n\n if (i%16 === 15) {\n for (j = 0; j < 16; j++) {\n // add\n h = wh[j];\n l = wl[j];\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = wh[(j+9)%16];\n l = wl[(j+9)%16];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // sigma0\n th = wh[(j+1)%16];\n tl = wl[(j+1)%16];\n h = ((th >>> 1) | (tl << (32-1))) ^ ((th >>> 8) | (tl << (32-8))) ^ (th >>> 7);\n l = ((tl >>> 1) | (th << (32-1))) ^ ((tl >>> 8) | (th << (32-8))) ^ ((tl >>> 7) | (th << (32-7)));\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // sigma1\n th = wh[(j+14)%16];\n tl = wl[(j+14)%16];\n h = ((th >>> 19) | (tl << (32-19))) ^ ((tl >>> (61-32)) | (th << (32-(61-32)))) ^ (th >>> 6);\n l = ((tl >>> 19) | (th << (32-19))) ^ ((th >>> (61-32)) | (tl << (32-(61-32)))) ^ ((tl >>> 6) | (th << (32-6)));\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n wh[j] = (c & 0xffff) | (d << 16);\n wl[j] = (a & 0xffff) | (b << 16);\n }\n }\n }\n\n // add\n h = ah0;\n l = al0;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[0];\n l = hl[0];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[0] = ah0 = (c & 0xffff) | (d << 16);\n hl[0] = al0 = (a & 0xffff) | (b << 16);\n\n h = ah1;\n l = al1;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[1];\n l = hl[1];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[1] = ah1 = (c & 0xffff) | (d << 16);\n hl[1] = al1 = (a & 0xffff) | (b << 16);\n\n h = ah2;\n l = al2;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[2];\n l = hl[2];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[2] = ah2 = (c & 0xffff) | (d << 16);\n hl[2] = al2 = (a & 0xffff) | (b << 16);\n\n h = ah3;\n l = al3;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[3];\n l = hl[3];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[3] = ah3 = (c & 0xffff) | (d << 16);\n hl[3] = al3 = (a & 0xffff) | (b << 16);\n\n h = ah4;\n l = al4;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[4];\n l = hl[4];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[4] = ah4 = (c & 0xffff) | (d << 16);\n hl[4] = al4 = (a & 0xffff) | (b << 16);\n\n h = ah5;\n l = al5;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[5];\n l = hl[5];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[5] = ah5 = (c & 0xffff) | (d << 16);\n hl[5] = al5 = (a & 0xffff) | (b << 16);\n\n h = ah6;\n l = al6;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[6];\n l = hl[6];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[6] = ah6 = (c & 0xffff) | (d << 16);\n hl[6] = al6 = (a & 0xffff) | (b << 16);\n\n h = ah7;\n l = al7;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[7];\n l = hl[7];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[7] = ah7 = (c & 0xffff) | (d << 16);\n hl[7] = al7 = (a & 0xffff) | (b << 16);\n\n pos += 128;\n n -= 128;\n }\n\n return n;\n}\n\nfunction crypto_hash(out, m, n) {\n var hh = new Int32Array(8),\n hl = new Int32Array(8),\n x = new Uint8Array(256),\n i, b = n;\n\n hh[0] = 0x6a09e667;\n hh[1] = 0xbb67ae85;\n hh[2] = 0x3c6ef372;\n hh[3] = 0xa54ff53a;\n hh[4] = 0x510e527f;\n hh[5] = 0x9b05688c;\n hh[6] = 0x1f83d9ab;\n hh[7] = 0x5be0cd19;\n\n hl[0] = 0xf3bcc908;\n hl[1] = 0x84caa73b;\n hl[2] = 0xfe94f82b;\n hl[3] = 0x5f1d36f1;\n hl[4] = 0xade682d1;\n hl[5] = 0x2b3e6c1f;\n hl[6] = 0xfb41bd6b;\n hl[7] = 0x137e2179;\n\n crypto_hashblocks_hl(hh, hl, m, n);\n n %= 128;\n\n for (i = 0; i < n; i++) x[i] = m[b-n+i];\n x[n] = 128;\n\n n = 256-128*(n<112?1:0);\n x[n-9] = 0;\n ts64(x, n-8, (b / 0x20000000) | 0, b << 3);\n crypto_hashblocks_hl(hh, hl, x, n);\n\n for (i = 0; i < 8; i++) ts64(out, 8*i, hh[i], hl[i]);\n\n return 0;\n}\n\nfunction add(p, q) {\n var a = gf(), b = gf(), c = gf(),\n d = gf(), e = gf(), f = gf(),\n g = gf(), h = gf(), t = gf();\n\n Z(a, p[1], p[0]);\n Z(t, q[1], q[0]);\n M(a, a, t);\n A(b, p[0], p[1]);\n A(t, q[0], q[1]);\n M(b, b, t);\n M(c, p[3], q[3]);\n M(c, c, D2);\n M(d, p[2], q[2]);\n A(d, d, d);\n Z(e, b, a);\n Z(f, d, c);\n A(g, d, c);\n A(h, b, a);\n\n M(p[0], e, f);\n M(p[1], h, g);\n M(p[2], g, f);\n M(p[3], e, h);\n}\n\nfunction cswap(p, q, b) {\n var i;\n for (i = 0; i < 4; i++) {\n sel25519(p[i], q[i], b);\n }\n}\n\nfunction pack(r, p) {\n var tx = gf(), ty = gf(), zi = gf();\n inv25519(zi, p[2]);\n M(tx, p[0], zi);\n M(ty, p[1], zi);\n pack25519(r, ty);\n r[31] ^= par25519(tx) << 7;\n}\n\nfunction scalarmult(p, q, s) {\n var b, i;\n set25519(p[0], gf0);\n set25519(p[1], gf1);\n set25519(p[2], gf1);\n set25519(p[3], gf0);\n for (i = 255; i >= 0; --i) {\n b = (s[(i/8)|0] >> (i&7)) & 1;\n cswap(p, q, b);\n add(q, p);\n add(p, p);\n cswap(p, q, b);\n }\n}\n\nfunction scalarbase(p, s) {\n var q = [gf(), gf(), gf(), gf()];\n set25519(q[0], X);\n set25519(q[1], Y);\n set25519(q[2], gf1);\n M(q[3], X, Y);\n scalarmult(p, q, s);\n}\n\nfunction crypto_sign_keypair(pk, sk, seeded) {\n var d = new Uint8Array(64);\n var p = [gf(), gf(), gf(), gf()];\n var i;\n\n if (!seeded) randombytes(sk, 32);\n crypto_hash(d, sk, 32);\n d[0] &= 248;\n d[31] &= 127;\n d[31] |= 64;\n\n scalarbase(p, d);\n pack(pk, p);\n\n for (i = 0; i < 32; i++) sk[i+32] = pk[i];\n return 0;\n}\n\nvar L = new Float64Array([0xed, 0xd3, 0xf5, 0x5c, 0x1a, 0x63, 0x12, 0x58, 0xd6, 0x9c, 0xf7, 0xa2, 0xde, 0xf9, 0xde, 0x14, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x10]);\n\nfunction modL(r, x) {\n var carry, i, j, k;\n for (i = 63; i >= 32; --i) {\n carry = 0;\n for (j = i - 32, k = i - 12; j < k; ++j) {\n x[j] += carry - 16 * x[i] * L[j - (i - 32)];\n carry = Math.floor((x[j] + 128) / 256);\n x[j] -= carry * 256;\n }\n x[j] += carry;\n x[i] = 0;\n }\n carry = 0;\n for (j = 0; j < 32; j++) {\n x[j] += carry - (x[31] >> 4) * L[j];\n carry = x[j] >> 8;\n x[j] &= 255;\n }\n for (j = 0; j < 32; j++) x[j] -= carry * L[j];\n for (i = 0; i < 32; i++) {\n x[i+1] += x[i] >> 8;\n r[i] = x[i] & 255;\n }\n}\n\nfunction reduce(r) {\n var x = new Float64Array(64), i;\n for (i = 0; i < 64; i++) x[i] = r[i];\n for (i = 0; i < 64; i++) r[i] = 0;\n modL(r, x);\n}\n\n// Note: difference from C - smlen returned, not passed as argument.\nfunction crypto_sign(sm, m, n, sk) {\n var d = new Uint8Array(64), h = new Uint8Array(64), r = new Uint8Array(64);\n var i, j, x = new Float64Array(64);\n var p = [gf(), gf(), gf(), gf()];\n\n crypto_hash(d, sk, 32);\n d[0] &= 248;\n d[31] &= 127;\n d[31] |= 64;\n\n var smlen = n + 64;\n for (i = 0; i < n; i++) sm[64 + i] = m[i];\n for (i = 0; i < 32; i++) sm[32 + i] = d[32 + i];\n\n crypto_hash(r, sm.subarray(32), n+32);\n reduce(r);\n scalarbase(p, r);\n pack(sm, p);\n\n for (i = 32; i < 64; i++) sm[i] = sk[i];\n crypto_hash(h, sm, n + 64);\n reduce(h);\n\n for (i = 0; i < 64; i++) x[i] = 0;\n for (i = 0; i < 32; i++) x[i] = r[i];\n for (i = 0; i < 32; i++) {\n for (j = 0; j < 32; j++) {\n x[i+j] += h[i] * d[j];\n }\n }\n\n modL(sm.subarray(32), x);\n return smlen;\n}\n\nfunction unpackneg(r, p) {\n var t = gf(), chk = gf(), num = gf(),\n den = gf(), den2 = gf(), den4 = gf(),\n den6 = gf();\n\n set25519(r[2], gf1);\n unpack25519(r[1], p);\n S(num, r[1]);\n M(den, num, D);\n Z(num, num, r[2]);\n A(den, r[2], den);\n\n S(den2, den);\n S(den4, den2);\n M(den6, den4, den2);\n M(t, den6, num);\n M(t, t, den);\n\n pow2523(t, t);\n M(t, t, num);\n M(t, t, den);\n M(t, t, den);\n M(r[0], t, den);\n\n S(chk, r[0]);\n M(chk, chk, den);\n if (neq25519(chk, num)) M(r[0], r[0], I);\n\n S(chk, r[0]);\n M(chk, chk, den);\n if (neq25519(chk, num)) return -1;\n\n if (par25519(r[0]) === (p[31]>>7)) Z(r[0], gf0, r[0]);\n\n M(r[3], r[0], r[1]);\n return 0;\n}\n\nfunction crypto_sign_open(m, sm, n, pk) {\n var i;\n var t = new Uint8Array(32), h = new Uint8Array(64);\n var p = [gf(), gf(), gf(), gf()],\n q = [gf(), gf(), gf(), gf()];\n\n if (n < 64) return -1;\n\n if (unpackneg(q, pk)) return -1;\n\n for (i = 0; i < n; i++) m[i] = sm[i];\n for (i = 0; i < 32; i++) m[i+32] = pk[i];\n crypto_hash(h, m, n);\n reduce(h);\n scalarmult(p, q, h);\n\n scalarbase(q, sm.subarray(32));\n add(p, q);\n pack(t, p);\n\n n -= 64;\n if (crypto_verify_32(sm, 0, t, 0)) {\n for (i = 0; i < n; i++) m[i] = 0;\n return -1;\n }\n\n for (i = 0; i < n; i++) m[i] = sm[i + 64];\n return n;\n}\n\nvar crypto_secretbox_KEYBYTES = 32,\n crypto_secretbox_NONCEBYTES = 24,\n crypto_secretbox_ZEROBYTES = 32,\n crypto_secretbox_BOXZEROBYTES = 16,\n crypto_scalarmult_BYTES = 32,\n crypto_scalarmult_SCALARBYTES = 32,\n crypto_box_PUBLICKEYBYTES = 32,\n crypto_box_SECRETKEYBYTES = 32,\n crypto_box_BEFORENMBYTES = 32,\n crypto_box_NONCEBYTES = crypto_secretbox_NONCEBYTES,\n crypto_box_ZEROBYTES = crypto_secretbox_ZEROBYTES,\n crypto_box_BOXZEROBYTES = crypto_secretbox_BOXZEROBYTES,\n crypto_sign_BYTES = 64,\n crypto_sign_PUBLICKEYBYTES = 32,\n crypto_sign_SECRETKEYBYTES = 64,\n crypto_sign_SEEDBYTES = 32,\n crypto_hash_BYTES = 64;\n\nnacl.lowlevel = {\n crypto_core_hsalsa20: crypto_core_hsalsa20,\n crypto_stream_xor: crypto_stream_xor,\n crypto_stream: crypto_stream,\n crypto_stream_salsa20_xor: crypto_stream_salsa20_xor,\n crypto_stream_salsa20: crypto_stream_salsa20,\n crypto_onetimeauth: crypto_onetimeauth,\n crypto_onetimeauth_verify: crypto_onetimeauth_verify,\n crypto_verify_16: crypto_verify_16,\n crypto_verify_32: crypto_verify_32,\n crypto_secretbox: crypto_secretbox,\n crypto_secretbox_open: crypto_secretbox_open,\n crypto_scalarmult: crypto_scalarmult,\n crypto_scalarmult_base: crypto_scalarmult_base,\n crypto_box_beforenm: crypto_box_beforenm,\n crypto_box_afternm: crypto_box_afternm,\n crypto_box: crypto_box,\n crypto_box_open: crypto_box_open,\n crypto_box_keypair: crypto_box_keypair,\n crypto_hash: crypto_hash,\n crypto_sign: crypto_sign,\n crypto_sign_keypair: crypto_sign_keypair,\n crypto_sign_open: crypto_sign_open,\n\n crypto_secretbox_KEYBYTES: crypto_secretbox_KEYBYTES,\n crypto_secretbox_NONCEBYTES: crypto_secretbox_NONCEBYTES,\n crypto_secretbox_ZEROBYTES: crypto_secretbox_ZEROBYTES,\n crypto_secretbox_BOXZEROBYTES: crypto_secretbox_BOXZEROBYTES,\n crypto_scalarmult_BYTES: crypto_scalarmult_BYTES,\n crypto_scalarmult_SCALARBYTES: crypto_scalarmult_SCALARBYTES,\n crypto_box_PUBLICKEYBYTES: crypto_box_PUBLICKEYBYTES,\n crypto_box_SECRETKEYBYTES: crypto_box_SECRETKEYBYTES,\n crypto_box_BEFORENMBYTES: crypto_box_BEFORENMBYTES,\n crypto_box_NONCEBYTES: crypto_box_NONCEBYTES,\n crypto_box_ZEROBYTES: crypto_box_ZEROBYTES,\n crypto_box_BOXZEROBYTES: crypto_box_BOXZEROBYTES,\n crypto_sign_BYTES: crypto_sign_BYTES,\n crypto_sign_PUBLICKEYBYTES: crypto_sign_PUBLICKEYBYTES,\n crypto_sign_SECRETKEYBYTES: crypto_sign_SECRETKEYBYTES,\n crypto_sign_SEEDBYTES: crypto_sign_SEEDBYTES,\n crypto_hash_BYTES: crypto_hash_BYTES,\n\n gf: gf,\n D: D,\n L: L,\n pack25519: pack25519,\n unpack25519: unpack25519,\n M: M,\n A: A,\n S: S,\n Z: Z,\n pow2523: pow2523,\n add: add,\n set25519: set25519,\n modL: modL,\n scalarmult: scalarmult,\n scalarbase: scalarbase,\n};\n\n/* High-level API */\n\nfunction checkLengths(k, n) {\n if (k.length !== crypto_secretbox_KEYBYTES) throw new Error('bad key size');\n if (n.length !== crypto_secretbox_NONCEBYTES) throw new Error('bad nonce size');\n}\n\nfunction checkBoxLengths(pk, sk) {\n if (pk.length !== crypto_box_PUBLICKEYBYTES) throw new Error('bad public key size');\n if (sk.length !== crypto_box_SECRETKEYBYTES) throw new Error('bad secret key size');\n}\n\nfunction checkArrayTypes() {\n for (var i = 0; i < arguments.length; i++) {\n if (!(arguments[i] instanceof Uint8Array))\n throw new TypeError('unexpected type, use Uint8Array');\n }\n}\n\nfunction cleanup(arr) {\n for (var i = 0; i < arr.length; i++) arr[i] = 0;\n}\n\nnacl.randomBytes = function(n) {\n var b = new Uint8Array(n);\n randombytes(b, n);\n return b;\n};\n\nnacl.secretbox = function(msg, nonce, key) {\n checkArrayTypes(msg, nonce, key);\n checkLengths(key, nonce);\n var m = new Uint8Array(crypto_secretbox_ZEROBYTES + msg.length);\n var c = new Uint8Array(m.length);\n for (var i = 0; i < msg.length; i++) m[i+crypto_secretbox_ZEROBYTES] = msg[i];\n crypto_secretbox(c, m, m.length, nonce, key);\n return c.subarray(crypto_secretbox_BOXZEROBYTES);\n};\n\nnacl.secretbox.open = function(box, nonce, key) {\n checkArrayTypes(box, nonce, key);\n checkLengths(key, nonce);\n var c = new Uint8Array(crypto_secretbox_BOXZEROBYTES + box.length);\n var m = new Uint8Array(c.length);\n for (var i = 0; i < box.length; i++) c[i+crypto_secretbox_BOXZEROBYTES] = box[i];\n if (c.length < 32) return null;\n if (crypto_secretbox_open(m, c, c.length, nonce, key) !== 0) return null;\n return m.subarray(crypto_secretbox_ZEROBYTES);\n};\n\nnacl.secretbox.keyLength = crypto_secretbox_KEYBYTES;\nnacl.secretbox.nonceLength = crypto_secretbox_NONCEBYTES;\nnacl.secretbox.overheadLength = crypto_secretbox_BOXZEROBYTES;\n\nnacl.scalarMult = function(n, p) {\n checkArrayTypes(n, p);\n if (n.length !== crypto_scalarmult_SCALARBYTES) throw new Error('bad n size');\n if (p.length !== crypto_scalarmult_BYTES) throw new Error('bad p size');\n var q = new Uint8Array(crypto_scalarmult_BYTES);\n crypto_scalarmult(q, n, p);\n return q;\n};\n\nnacl.scalarMult.base = function(n) {\n checkArrayTypes(n);\n if (n.length !== crypto_scalarmult_SCALARBYTES) throw new Error('bad n size');\n var q = new Uint8Array(crypto_scalarmult_BYTES);\n crypto_scalarmult_base(q, n);\n return q;\n};\n\nnacl.scalarMult.scalarLength = crypto_scalarmult_SCALARBYTES;\nnacl.scalarMult.groupElementLength = crypto_scalarmult_BYTES;\n\nnacl.box = function(msg, nonce, publicKey, secretKey) {\n var k = nacl.box.before(publicKey, secretKey);\n return nacl.secretbox(msg, nonce, k);\n};\n\nnacl.box.before = function(publicKey, secretKey) {\n checkArrayTypes(publicKey, secretKey);\n checkBoxLengths(publicKey, secretKey);\n var k = new Uint8Array(crypto_box_BEFORENMBYTES);\n crypto_box_beforenm(k, publicKey, secretKey);\n return k;\n};\n\nnacl.box.after = nacl.secretbox;\n\nnacl.box.open = function(msg, nonce, publicKey, secretKey) {\n var k = nacl.box.before(publicKey, secretKey);\n return nacl.secretbox.open(msg, nonce, k);\n};\n\nnacl.box.open.after = nacl.secretbox.open;\n\nnacl.box.keyPair = function() {\n var pk = new Uint8Array(crypto_box_PUBLICKEYBYTES);\n var sk = new Uint8Array(crypto_box_SECRETKEYBYTES);\n crypto_box_keypair(pk, sk);\n return {publicKey: pk, secretKey: sk};\n};\n\nnacl.box.keyPair.fromSecretKey = function(secretKey) {\n checkArrayTypes(secretKey);\n if (secretKey.length !== crypto_box_SECRETKEYBYTES)\n throw new Error('bad secret key size');\n var pk = new Uint8Array(crypto_box_PUBLICKEYBYTES);\n crypto_scalarmult_base(pk, secretKey);\n return {publicKey: pk, secretKey: new Uint8Array(secretKey)};\n};\n\nnacl.box.publicKeyLength = crypto_box_PUBLICKEYBYTES;\nnacl.box.secretKeyLength = crypto_box_SECRETKEYBYTES;\nnacl.box.sharedKeyLength = crypto_box_BEFORENMBYTES;\nnacl.box.nonceLength = crypto_box_NONCEBYTES;\nnacl.box.overheadLength = nacl.secretbox.overheadLength;\n\nnacl.sign = function(msg, secretKey) {\n checkArrayTypes(msg, secretKey);\n if (secretKey.length !== crypto_sign_SECRETKEYBYTES)\n throw new Error('bad secret key size');\n var signedMsg = new Uint8Array(crypto_sign_BYTES+msg.length);\n crypto_sign(signedMsg, msg, msg.length, secretKey);\n return signedMsg;\n};\n\nnacl.sign.open = function(signedMsg, publicKey) {\n checkArrayTypes(signedMsg, publicKey);\n if (publicKey.length !== crypto_sign_PUBLICKEYBYTES)\n throw new Error('bad public key size');\n var tmp = new Uint8Array(signedMsg.length);\n var mlen = crypto_sign_open(tmp, signedMsg, signedMsg.length, publicKey);\n if (mlen < 0) return null;\n var m = new Uint8Array(mlen);\n for (var i = 0; i < m.length; i++) m[i] = tmp[i];\n return m;\n};\n\nnacl.sign.detached = function(msg, secretKey) {\n var signedMsg = nacl.sign(msg, secretKey);\n var sig = new Uint8Array(crypto_sign_BYTES);\n for (var i = 0; i < sig.length; i++) sig[i] = signedMsg[i];\n return sig;\n};\n\nnacl.sign.detached.verify = function(msg, sig, publicKey) {\n checkArrayTypes(msg, sig, publicKey);\n if (sig.length !== crypto_sign_BYTES)\n throw new Error('bad signature size');\n if (publicKey.length !== crypto_sign_PUBLICKEYBYTES)\n throw new Error('bad public key size');\n var sm = new Uint8Array(crypto_sign_BYTES + msg.length);\n var m = new Uint8Array(crypto_sign_BYTES + msg.length);\n var i;\n for (i = 0; i < crypto_sign_BYTES; i++) sm[i] = sig[i];\n for (i = 0; i < msg.length; i++) sm[i+crypto_sign_BYTES] = msg[i];\n return (crypto_sign_open(m, sm, sm.length, publicKey) >= 0);\n};\n\nnacl.sign.keyPair = function() {\n var pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);\n var sk = new Uint8Array(crypto_sign_SECRETKEYBYTES);\n crypto_sign_keypair(pk, sk);\n return {publicKey: pk, secretKey: sk};\n};\n\nnacl.sign.keyPair.fromSecretKey = function(secretKey) {\n checkArrayTypes(secretKey);\n if (secretKey.length !== crypto_sign_SECRETKEYBYTES)\n throw new Error('bad secret key size');\n var pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);\n for (var i = 0; i < pk.length; i++) pk[i] = secretKey[32+i];\n return {publicKey: pk, secretKey: new Uint8Array(secretKey)};\n};\n\nnacl.sign.keyPair.fromSeed = function(seed) {\n checkArrayTypes(seed);\n if (seed.length !== crypto_sign_SEEDBYTES)\n throw new Error('bad seed size');\n var pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);\n var sk = new Uint8Array(crypto_sign_SECRETKEYBYTES);\n for (var i = 0; i < 32; i++) sk[i] = seed[i];\n crypto_sign_keypair(pk, sk, true);\n return {publicKey: pk, secretKey: sk};\n};\n\nnacl.sign.publicKeyLength = crypto_sign_PUBLICKEYBYTES;\nnacl.sign.secretKeyLength = crypto_sign_SECRETKEYBYTES;\nnacl.sign.seedLength = crypto_sign_SEEDBYTES;\nnacl.sign.signatureLength = crypto_sign_BYTES;\n\nnacl.hash = function(msg) {\n checkArrayTypes(msg);\n var h = new Uint8Array(crypto_hash_BYTES);\n crypto_hash(h, msg, msg.length);\n return h;\n};\n\nnacl.hash.hashLength = crypto_hash_BYTES;\n\nnacl.verify = function(x, y) {\n checkArrayTypes(x, y);\n // Zero length arguments are considered not equal.\n if (x.length === 0 || y.length === 0) return false;\n if (x.length !== y.length) return false;\n return (vn(x, 0, y, 0, x.length) === 0) ? true : false;\n};\n\nnacl.setPRNG = function(fn) {\n randombytes = fn;\n};\n\n(function() {\n // Initialize PRNG if environment provides CSPRNG.\n // If not, methods calling randombytes will throw.\n var crypto = typeof self !== 'undefined' ? (self.crypto || self.msCrypto) : null;\n if (crypto && crypto.getRandomValues) {\n // Browsers.\n var QUOTA = 65536;\n nacl.setPRNG(function(x, n) {\n var i, v = new Uint8Array(n);\n for (i = 0; i < n; i += QUOTA) {\n crypto.getRandomValues(v.subarray(i, i + Math.min(n - i, QUOTA)));\n }\n for (i = 0; i < n; i++) x[i] = v[i];\n cleanup(v);\n });\n } else if (typeof require !== 'undefined') {\n // Node.js.\n crypto = require('crypto');\n if (crypto && crypto.randomBytes) {\n nacl.setPRNG(function(x, n) {\n var i, v = crypto.randomBytes(n);\n for (i = 0; i < n; i++) x[i] = v[i];\n cleanup(v);\n });\n }\n }\n})();\n\n})(typeof module !== 'undefined' && module.exports ? module.exports : (self.nacl = self.nacl || {}));\n","module.exports = require('./pusher-with-encryption').default;\n","/* (ignored) */","export default function encode(s: any): string {\n return btoa(utob(s));\n}\n\nvar fromCharCode = String.fromCharCode;\n\nvar b64chars =\n 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';\nvar b64tab = {};\n\nfor (var i = 0, l = b64chars.length; i < l; i++) {\n b64tab[b64chars.charAt(i)] = i;\n}\n\nvar cb_utob = function(c) {\n var cc = c.charCodeAt(0);\n return cc < 0x80\n ? c\n : cc < 0x800\n ? fromCharCode(0xc0 | (cc >>> 6)) + fromCharCode(0x80 | (cc & 0x3f))\n : fromCharCode(0xe0 | ((cc >>> 12) & 0x0f)) +\n fromCharCode(0x80 | ((cc >>> 6) & 0x3f)) +\n fromCharCode(0x80 | (cc & 0x3f));\n};\n\nvar utob = function(u) {\n return u.replace(/[^\\x00-\\x7F]/g, cb_utob);\n};\n\nvar cb_encode = function(ccc) {\n var padlen = [0, 2, 1][ccc.length % 3];\n var ord =\n (ccc.charCodeAt(0) << 16) |\n ((ccc.length > 1 ? ccc.charCodeAt(1) : 0) << 8) |\n (ccc.length > 2 ? ccc.charCodeAt(2) : 0);\n var chars = [\n b64chars.charAt(ord >>> 18),\n b64chars.charAt((ord >>> 12) & 63),\n padlen >= 2 ? '=' : b64chars.charAt((ord >>> 6) & 63),\n padlen >= 1 ? '=' : b64chars.charAt(ord & 63)\n ];\n return chars.join('');\n};\n\nvar btoa =\n global.btoa ||\n function(b) {\n return b.replace(/[\\s\\S]{1,3}/g, cb_encode);\n };\n","import TimedCallback from './timed_callback';\nimport { Delay, Scheduler, Canceller } from './scheduling';\n\nabstract class Timer {\n protected clear: Canceller;\n protected timer: number | void;\n\n constructor(\n set: Scheduler,\n clear: Canceller,\n delay: Delay,\n callback: TimedCallback\n ) {\n this.clear = clear;\n this.timer = set(() => {\n if (this.timer) {\n this.timer = callback(this.timer);\n }\n }, delay);\n }\n\n /** Returns whether the timer is still running.\n *\n * @return {Boolean}\n */\n isRunning(): boolean {\n return this.timer !== null;\n }\n\n /** Aborts a timer when it's running. */\n ensureAborted() {\n if (this.timer) {\n this.clear(this.timer);\n this.timer = null;\n }\n }\n}\n\nexport default Timer;\n","import Timer from './abstract_timer';\nimport TimedCallback from './timed_callback';\nimport { Delay } from './scheduling';\n\n// We need to bind clear functions this way to avoid exceptions on IE8\nfunction clearTimeout(timer) {\n global.clearTimeout(timer);\n}\nfunction clearInterval(timer) {\n global.clearInterval(timer);\n}\n\n/** Cross-browser compatible one-off timer abstraction.\n *\n * @param {Number} delay\n * @param {Function} callback\n */\nexport class OneOffTimer extends Timer {\n constructor(delay: Delay, callback: TimedCallback) {\n super(setTimeout, clearTimeout, delay, function(timer) {\n callback();\n return null;\n });\n }\n}\n\n/** Cross-browser compatible periodic timer abstraction.\n *\n * @param {Number} delay\n * @param {Function} callback\n */\nexport class PeriodicTimer extends Timer {\n constructor(delay: Delay, callback: TimedCallback) {\n super(setInterval, clearInterval, delay, function(timer) {\n callback();\n return timer;\n });\n }\n}\n","import * as Collections from './utils/collections';\nimport TimedCallback from './utils/timers/timed_callback';\nimport { OneOffTimer, PeriodicTimer } from './utils/timers';\n\nvar Util = {\n now(): number {\n if (Date.now) {\n return Date.now();\n } else {\n return new Date().valueOf();\n }\n },\n\n defer(callback: TimedCallback): OneOffTimer {\n return new OneOffTimer(0, callback);\n },\n\n /** Builds a function that will proxy a method call to its first argument.\n *\n * Allows partial application of arguments, so additional arguments are\n * prepended to the argument list.\n *\n * @param {String} name method name\n * @return {Function} proxy function\n */\n method(name: string, ...args: any[]): Function {\n var boundArguments = Array.prototype.slice.call(arguments, 1);\n return function(object) {\n return object[name].apply(object, boundArguments.concat(arguments));\n };\n }\n};\n\nexport default Util;\n","import base64encode from '../base64';\nimport Util from '../util';\n\n/** Merges multiple objects into the target argument.\n *\n * For properties that are plain Objects, performs a deep-merge. For the\n * rest it just copies the value of the property.\n *\n * To extend prototypes use it as following:\n * Pusher.Util.extend(Target.prototype, Base.prototype)\n *\n * You can also use it to merge objects without altering them:\n * Pusher.Util.extend({}, object1, object2)\n *\n * @param {Object} target\n * @return {Object} the target argument\n */\nexport function extend(target: any, ...sources: any[]): T {\n for (var i = 0; i < sources.length; i++) {\n var extensions = sources[i];\n for (var property in extensions) {\n if (\n extensions[property] &&\n extensions[property].constructor &&\n extensions[property].constructor === Object\n ) {\n target[property] = extend(target[property] || {}, extensions[property]);\n } else {\n target[property] = extensions[property];\n }\n }\n }\n return target;\n}\n\nexport function stringify(): string {\n var m = ['Pusher'];\n for (var i = 0; i < arguments.length; i++) {\n if (typeof arguments[i] === 'string') {\n m.push(arguments[i]);\n } else {\n m.push(safeJSONStringify(arguments[i]));\n }\n }\n return m.join(' : ');\n}\n\nexport function arrayIndexOf(array: any[], item: any): number {\n // MSIE doesn't have array.indexOf\n var nativeIndexOf = Array.prototype.indexOf;\n if (array === null) {\n return -1;\n }\n if (nativeIndexOf && array.indexOf === nativeIndexOf) {\n return array.indexOf(item);\n }\n for (var i = 0, l = array.length; i < l; i++) {\n if (array[i] === item) {\n return i;\n }\n }\n return -1;\n}\n\n/** Applies a function f to all properties of an object.\n *\n * Function f gets 3 arguments passed:\n * - element from the object\n * - key of the element\n * - reference to the object\n *\n * @param {Object} object\n * @param {Function} f\n */\nexport function objectApply(object: any, f: Function) {\n for (var key in object) {\n if (Object.prototype.hasOwnProperty.call(object, key)) {\n f(object[key], key, object);\n }\n }\n}\n\n/** Return a list of objects own proerty keys\n *\n * @param {Object} object\n * @returns {Array}\n */\nexport function keys(object: any): string[] {\n var keys = [];\n objectApply(object, function(_, key) {\n keys.push(key);\n });\n return keys;\n}\n\n/** Return a list of object's own property values\n *\n * @param {Object} object\n * @returns {Array}\n */\nexport function values(object: any): any[] {\n var values = [];\n objectApply(object, function(value) {\n values.push(value);\n });\n return values;\n}\n\n/** Applies a function f to all elements of an array.\n *\n * Function f gets 3 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function apply(array: any[], f: Function, context?: any) {\n for (var i = 0; i < array.length; i++) {\n f.call(context || global, array[i], i, array);\n }\n}\n\n/** Maps all elements of the array and returns the result.\n *\n * Function f gets 4 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n * - reference to the destination array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function map(array: any[], f: Function): any[] {\n var result = [];\n for (var i = 0; i < array.length; i++) {\n result.push(f(array[i], i, array, result));\n }\n return result;\n}\n\n/** Maps all elements of the object and returns the result.\n *\n * Function f gets 4 arguments passed:\n * - element from the object\n * - key of the element\n * - reference to the source object\n * - reference to the destination object\n *\n * @param {Object} object\n * @param {Function} f\n */\nexport function mapObject(object: any, f: Function): any {\n var result = {};\n objectApply(object, function(value, key) {\n result[key] = f(value);\n });\n return result;\n}\n\n/** Filters elements of the array using a test function.\n *\n * Function test gets 4 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n * - reference to the destination array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function filter(array: any[], test: Function): any[] {\n test =\n test ||\n function(value) {\n return !!value;\n };\n\n var result = [];\n for (var i = 0; i < array.length; i++) {\n if (test(array[i], i, array, result)) {\n result.push(array[i]);\n }\n }\n return result;\n}\n\n/** Filters properties of the object using a test function.\n *\n * Function test gets 4 arguments passed:\n * - element from the object\n * - key of the element\n * - reference to the source object\n * - reference to the destination object\n *\n * @param {Object} object\n * @param {Function} f\n */\nexport function filterObject(object: Object, test: Function) {\n var result = {};\n objectApply(object, function(value, key) {\n if ((test && test(value, key, object, result)) || Boolean(value)) {\n result[key] = value;\n }\n });\n return result;\n}\n\n/** Flattens an object into a two-dimensional array.\n *\n * @param {Object} object\n * @return {Array} resulting array of [key, value] pairs\n */\nexport function flatten(object: Object): any[] {\n var result = [];\n objectApply(object, function(value, key) {\n result.push([key, value]);\n });\n return result;\n}\n\n/** Checks whether any element of the array passes the test.\n *\n * Function test gets 3 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function any(array: any[], test: Function): boolean {\n for (var i = 0; i < array.length; i++) {\n if (test(array[i], i, array)) {\n return true;\n }\n }\n return false;\n}\n\n/** Checks whether all elements of the array pass the test.\n *\n * Function test gets 3 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function all(array: any[], test: Function): boolean {\n for (var i = 0; i < array.length; i++) {\n if (!test(array[i], i, array)) {\n return false;\n }\n }\n return true;\n}\n\nexport function encodeParamsObject(data): string {\n return mapObject(data, function(value) {\n if (typeof value === 'object') {\n value = safeJSONStringify(value);\n }\n return encodeURIComponent(base64encode(value.toString()));\n });\n}\n\nexport function buildQueryString(data: any): string {\n var params = filterObject(data, function(value) {\n return value !== undefined;\n });\n\n var query = map(\n flatten(encodeParamsObject(params)),\n Util.method('join', '=')\n ).join('&');\n\n return query;\n}\n\n/**\n * See https://github.com/douglascrockford/JSON-js/blob/master/cycle.js\n *\n * Remove circular references from an object. Required for JSON.stringify in\n * React Native, which tends to blow up a lot.\n *\n * @param {any} object\n * @return {any} Decycled object\n */\nexport function decycleObject(object: any): any {\n var objects = [],\n paths = [];\n\n return (function derez(value, path) {\n var i, name, nu;\n\n switch (typeof value) {\n case 'object':\n if (!value) {\n return null;\n }\n for (i = 0; i < objects.length; i += 1) {\n if (objects[i] === value) {\n return { $ref: paths[i] };\n }\n }\n\n objects.push(value);\n paths.push(path);\n\n if (Object.prototype.toString.apply(value) === '[object Array]') {\n nu = [];\n for (i = 0; i < value.length; i += 1) {\n nu[i] = derez(value[i], path + '[' + i + ']');\n }\n } else {\n nu = {};\n for (name in value) {\n if (Object.prototype.hasOwnProperty.call(value, name)) {\n nu[name] = derez(\n value[name],\n path + '[' + JSON.stringify(name) + ']'\n );\n }\n }\n }\n return nu;\n case 'number':\n case 'string':\n case 'boolean':\n return value;\n }\n })(object, '$');\n}\n\n/**\n * Provides a cross-browser and cross-platform way to safely stringify objects\n * into JSON. This is particularly necessary for ReactNative, where circular JSON\n * structures throw an exception.\n *\n * @param {any} source The object to stringify\n * @return {string} The serialized output.\n */\nexport function safeJSONStringify(source: any): string {\n try {\n return JSON.stringify(source);\n } catch (e) {\n return JSON.stringify(decycleObject(source));\n }\n}\n","import {\n ChannelAuthorizationOptions,\n UserAuthenticationOptions\n} from './auth/options';\nimport { AuthTransport } from './config';\n\nexport interface DefaultConfig {\n VERSION: string;\n PROTOCOL: number;\n wsPort: number;\n wssPort: number;\n wsPath: string;\n httpHost: string;\n httpPort: number;\n httpsPort: number;\n httpPath: string;\n stats_host: string;\n authEndpoint: string;\n authTransport: AuthTransport;\n activityTimeout: number;\n pongTimeout: number;\n unavailableTimeout: number;\n userAuthentication: UserAuthenticationOptions;\n channelAuthorization: ChannelAuthorizationOptions;\n\n cdn_http?: string;\n cdn_https?: string;\n dependency_suffix?: string;\n}\n\nvar Defaults: DefaultConfig = {\n VERSION: VERSION,\n PROTOCOL: 7,\n\n wsPort: 80,\n wssPort: 443,\n wsPath: '',\n // DEPRECATED: SockJS fallback parameters\n httpHost: 'sockjs.pusher.com',\n httpPort: 80,\n httpsPort: 443,\n httpPath: '/pusher',\n // DEPRECATED: Stats\n stats_host: 'stats.pusher.com',\n // DEPRECATED: Other settings\n authEndpoint: '/pusher/auth',\n authTransport: 'ajax',\n activityTimeout: 120000,\n pongTimeout: 30000,\n unavailableTimeout: 10000,\n userAuthentication: {\n endpoint: '/pusher/user-auth',\n transport: 'ajax'\n },\n channelAuthorization: {\n endpoint: '/pusher/auth',\n transport: 'ajax'\n },\n\n // CDN configuration\n cdn_http: CDN_HTTP,\n cdn_https: CDN_HTTPS,\n dependency_suffix: DEPENDENCY_SUFFIX\n};\n\nexport default Defaults;\n","import Defaults from '../defaults';\nimport { default as URLScheme, URLSchemeParams } from './url_scheme';\n\nfunction getGenericURL(\n baseScheme: string,\n params: URLSchemeParams,\n path: string\n): string {\n var scheme = baseScheme + (params.useTLS ? 's' : '');\n var host = params.useTLS ? params.hostTLS : params.hostNonTLS;\n return scheme + '://' + host + path;\n}\n\nfunction getGenericPath(key: string, queryString?: string): string {\n var path = '/app/' + key;\n var query =\n '?protocol=' +\n Defaults.PROTOCOL +\n '&client=js' +\n '&version=' +\n Defaults.VERSION +\n (queryString ? '&' + queryString : '');\n return path + query;\n}\n\nexport var ws: URLScheme = {\n getInitial: function(key: string, params: URLSchemeParams): string {\n var path = (params.httpPath || '') + getGenericPath(key, 'flash=false');\n return getGenericURL('ws', params, path);\n }\n};\n\nexport var http: URLScheme = {\n getInitial: function(key: string, params: URLSchemeParams): string {\n var path = (params.httpPath || '/pusher') + getGenericPath(key);\n return getGenericURL('http', params, path);\n }\n};\n\nexport var sockjs: URLScheme = {\n getInitial: function(key: string, params: URLSchemeParams): string {\n return getGenericURL('http', params, params.httpPath || '/pusher');\n },\n getPath: function(key: string, params: URLSchemeParams): string {\n return getGenericPath(key);\n }\n};\n","import Callback from './callback';\nimport * as Collections from '../utils/collections';\nimport CallbackTable from './callback_table';\n\nexport default class CallbackRegistry {\n _callbacks: CallbackTable;\n\n constructor() {\n this._callbacks = {};\n }\n\n get(name: string): Callback[] {\n return this._callbacks[prefix(name)];\n }\n\n add(name: string, callback: Function, context: any) {\n var prefixedEventName = prefix(name);\n this._callbacks[prefixedEventName] =\n this._callbacks[prefixedEventName] || [];\n this._callbacks[prefixedEventName].push({\n fn: callback,\n context: context\n });\n }\n\n remove(name?: string, callback?: Function, context?: any) {\n if (!name && !callback && !context) {\n this._callbacks = {};\n return;\n }\n\n var names = name ? [prefix(name)] : Collections.keys(this._callbacks);\n\n if (callback || context) {\n this.removeCallback(names, callback, context);\n } else {\n this.removeAllCallbacks(names);\n }\n }\n\n private removeCallback(names: string[], callback: Function, context: any) {\n Collections.apply(\n names,\n function(name) {\n this._callbacks[name] = Collections.filter(\n this._callbacks[name] || [],\n function(binding) {\n return (\n (callback && callback !== binding.fn) ||\n (context && context !== binding.context)\n );\n }\n );\n if (this._callbacks[name].length === 0) {\n delete this._callbacks[name];\n }\n },\n this\n );\n }\n\n private removeAllCallbacks(names: string[]) {\n Collections.apply(\n names,\n function(name) {\n delete this._callbacks[name];\n },\n this\n );\n }\n}\n\nfunction prefix(name: string): string {\n return '_' + name;\n}\n","import * as Collections from '../utils/collections';\nimport Callback from './callback';\nimport Metadata from '../channels/metadata';\nimport CallbackRegistry from './callback_registry';\n\n/** Manages callback bindings and event emitting.\n *\n * @param Function failThrough called when no listeners are bound to an event\n */\nexport default class Dispatcher {\n callbacks: CallbackRegistry;\n global_callbacks: Function[];\n failThrough: Function;\n\n constructor(failThrough?: Function) {\n this.callbacks = new CallbackRegistry();\n this.global_callbacks = [];\n this.failThrough = failThrough;\n }\n\n bind(eventName: string, callback: Function, context?: any) {\n this.callbacks.add(eventName, callback, context);\n return this;\n }\n\n bind_global(callback: Function) {\n this.global_callbacks.push(callback);\n return this;\n }\n\n unbind(eventName?: string, callback?: Function, context?: any) {\n this.callbacks.remove(eventName, callback, context);\n return this;\n }\n\n unbind_global(callback?: Function) {\n if (!callback) {\n this.global_callbacks = [];\n return this;\n }\n\n this.global_callbacks = Collections.filter(\n this.global_callbacks || [],\n c => c !== callback\n );\n\n return this;\n }\n\n unbind_all() {\n this.unbind();\n this.unbind_global();\n return this;\n }\n\n emit(eventName: string, data?: any, metadata?: Metadata): Dispatcher {\n for (var i = 0; i < this.global_callbacks.length; i++) {\n this.global_callbacks[i](eventName, data);\n }\n\n var callbacks = this.callbacks.get(eventName);\n var args = [];\n\n if (metadata) {\n // if there's a metadata argument, we need to call the callback with both\n // data and metadata regardless of whether data is undefined\n args.push(data, metadata);\n } else if (data) {\n // metadata is undefined, so we only need to call the callback with data\n // if data exists\n args.push(data);\n }\n\n if (callbacks && callbacks.length > 0) {\n for (var i = 0; i < callbacks.length; i++) {\n callbacks[i].fn.apply(callbacks[i].context || global, args);\n }\n } else if (this.failThrough) {\n this.failThrough(eventName, data);\n }\n\n return this;\n }\n}\n","import { stringify } from './utils/collections';\nimport Pusher from './pusher';\n\nclass Logger {\n debug(...args: any[]) {\n this.log(this.globalLog, args);\n }\n\n warn(...args: any[]) {\n this.log(this.globalLogWarn, args);\n }\n\n error(...args: any[]) {\n this.log(this.globalLogError, args);\n }\n\n private globalLog = (message: string) => {\n if (global.console && global.console.log) {\n global.console.log(message);\n }\n };\n\n private globalLogWarn(message: string) {\n if (global.console && global.console.warn) {\n global.console.warn(message);\n } else {\n this.globalLog(message);\n }\n }\n\n private globalLogError(message: string) {\n if (global.console && global.console.error) {\n global.console.error(message);\n } else {\n this.globalLogWarn(message);\n }\n }\n\n private log(\n defaultLoggingFunction: (message: string) => void,\n ...args: any[]\n ) {\n var message = stringify.apply(this, arguments);\n if (Pusher.log) {\n Pusher.log(message);\n } else if (Pusher.logToConsole) {\n const log = defaultLoggingFunction.bind(this);\n log(message);\n }\n }\n}\n\nexport default new Logger();\n","import Util from '../util';\nimport * as Collections from '../utils/collections';\nimport { default as EventsDispatcher } from '../events/dispatcher';\nimport Logger from '../logger';\nimport TransportHooks from './transport_hooks';\nimport Socket from '../socket';\nimport Runtime from 'runtime';\nimport Timeline from '../timeline/timeline';\nimport TransportConnectionOptions from './transport_connection_options';\n\n/** Provides universal API for transport connections.\n *\n * Transport connection is a low-level object that wraps a connection method\n * and exposes a simple evented interface for the connection state and\n * messaging. It does not implement Pusher-specific WebSocket protocol.\n *\n * Additionally, it fetches resources needed for transport to work and exposes\n * an interface for querying transport features.\n *\n * States:\n * - new - initial state after constructing the object\n * - initializing - during initialization phase, usually fetching resources\n * - intialized - ready to establish a connection\n * - connection - when connection is being established\n * - open - when connection ready to be used\n * - closed - after connection was closed be either side\n *\n * Emits:\n * - error - after the connection raised an error\n *\n * Options:\n * - useTLS - whether connection should be over TLS\n * - hostTLS - host to connect to when connection is over TLS\n * - hostNonTLS - host to connect to when connection is over TLS\n *\n * @param {String} key application key\n * @param {Object} options\n */\nexport default class TransportConnection extends EventsDispatcher {\n hooks: TransportHooks;\n name: string;\n priority: number;\n key: string;\n options: TransportConnectionOptions;\n state: string;\n timeline: Timeline;\n activityTimeout: number;\n id: number;\n socket: Socket;\n beforeOpen: Function;\n initialize: Function;\n\n constructor(\n hooks: TransportHooks,\n name: string,\n priority: number,\n key: string,\n options: TransportConnectionOptions\n ) {\n super();\n this.initialize = Runtime.transportConnectionInitializer;\n this.hooks = hooks;\n this.name = name;\n this.priority = priority;\n this.key = key;\n this.options = options;\n\n this.state = 'new';\n this.timeline = options.timeline;\n this.activityTimeout = options.activityTimeout;\n this.id = this.timeline.generateUniqueID();\n }\n\n /** Checks whether the transport handles activity checks by itself.\n *\n * @return {Boolean}\n */\n handlesActivityChecks(): boolean {\n return Boolean(this.hooks.handlesActivityChecks);\n }\n\n /** Checks whether the transport supports the ping/pong API.\n *\n * @return {Boolean}\n */\n supportsPing(): boolean {\n return Boolean(this.hooks.supportsPing);\n }\n\n /** Tries to establish a connection.\n *\n * @returns {Boolean} false if transport is in invalid state\n */\n connect(): boolean {\n if (this.socket || this.state !== 'initialized') {\n return false;\n }\n\n var url = this.hooks.urls.getInitial(this.key, this.options);\n try {\n this.socket = this.hooks.getSocket(url, this.options);\n } catch (e) {\n Util.defer(() => {\n this.onError(e);\n this.changeState('closed');\n });\n return false;\n }\n\n this.bindListeners();\n\n Logger.debug('Connecting', { transport: this.name, url });\n this.changeState('connecting');\n return true;\n }\n\n /** Closes the connection.\n *\n * @return {Boolean} true if there was a connection to close\n */\n close(): boolean {\n if (this.socket) {\n this.socket.close();\n return true;\n } else {\n return false;\n }\n }\n\n /** Sends data over the open connection.\n *\n * @param {String} data\n * @return {Boolean} true only when in the \"open\" state\n */\n send(data: any): boolean {\n if (this.state === 'open') {\n // Workaround for MobileSafari bug (see https://gist.github.com/2052006)\n Util.defer(() => {\n if (this.socket) {\n this.socket.send(data);\n }\n });\n return true;\n } else {\n return false;\n }\n }\n\n /** Sends a ping if the connection is open and transport supports it. */\n ping() {\n if (this.state === 'open' && this.supportsPing()) {\n this.socket.ping();\n }\n }\n\n private onOpen() {\n if (this.hooks.beforeOpen) {\n this.hooks.beforeOpen(\n this.socket,\n this.hooks.urls.getPath(this.key, this.options)\n );\n }\n this.changeState('open');\n this.socket.onopen = undefined;\n }\n\n private onError(error) {\n this.emit('error', { type: 'WebSocketError', error: error });\n this.timeline.error(this.buildTimelineMessage({ error: error.toString() }));\n }\n\n private onClose(closeEvent?: any) {\n if (closeEvent) {\n this.changeState('closed', {\n code: closeEvent.code,\n reason: closeEvent.reason,\n wasClean: closeEvent.wasClean\n });\n } else {\n this.changeState('closed');\n }\n this.unbindListeners();\n this.socket = undefined;\n }\n\n private onMessage(message) {\n this.emit('message', message);\n }\n\n private onActivity() {\n this.emit('activity');\n }\n\n private bindListeners() {\n this.socket.onopen = () => {\n this.onOpen();\n };\n this.socket.onerror = error => {\n this.onError(error);\n };\n this.socket.onclose = closeEvent => {\n this.onClose(closeEvent);\n };\n this.socket.onmessage = message => {\n this.onMessage(message);\n };\n\n if (this.supportsPing()) {\n this.socket.onactivity = () => {\n this.onActivity();\n };\n }\n }\n\n private unbindListeners() {\n if (this.socket) {\n this.socket.onopen = undefined;\n this.socket.onerror = undefined;\n this.socket.onclose = undefined;\n this.socket.onmessage = undefined;\n if (this.supportsPing()) {\n this.socket.onactivity = undefined;\n }\n }\n }\n\n private changeState(state: string, params?: any) {\n this.state = state;\n this.timeline.info(\n this.buildTimelineMessage({\n state: state,\n params: params\n })\n );\n this.emit(state, params);\n }\n\n buildTimelineMessage(message): any {\n return Collections.extend({ cid: this.id }, message);\n }\n}\n","import Factory from '../utils/factory';\nimport TransportHooks from './transport_hooks';\nimport TransportConnection from './transport_connection';\nimport TransportConnectionOptions from './transport_connection_options';\n\n/** Provides interface for transport connection instantiation.\n *\n * Takes transport-specific hooks as the only argument, which allow checking\n * for transport support and creating its connections.\n *\n * Supported hooks: * - file - the name of the file to be fetched during initialization\n * - urls - URL scheme to be used by transport\n * - handlesActivityCheck - true when the transport handles activity checks\n * - supportsPing - true when the transport has a ping/activity API\n * - isSupported - tells whether the transport is supported in the environment\n * - getSocket - creates a WebSocket-compatible transport socket\n *\n * See transports.js for specific implementations.\n *\n * @param {Object} hooks object containing all needed transport hooks\n */\nexport default class Transport {\n hooks: TransportHooks;\n\n constructor(hooks: TransportHooks) {\n this.hooks = hooks;\n }\n\n /** Returns whether the transport is supported in the environment.\n *\n * @param {Object} envronment te environment details (encryption, settings)\n * @returns {Boolean} true when the transport is supported\n */\n isSupported(environment: any): boolean {\n return this.hooks.isSupported(environment);\n }\n\n /** Creates a transport connection.\n *\n * @param {String} name\n * @param {Number} priority\n * @param {String} key the application key\n * @param {Object} options\n * @returns {TransportConnection}\n */\n createConnection(\n name: string,\n priority: number,\n key: string,\n options: any\n ): TransportConnection {\n return new TransportConnection(this.hooks, name, priority, key, options);\n }\n}\n","import * as URLSchemes from 'core/transports/url_schemes';\nimport URLScheme from 'core/transports/url_scheme';\nimport Transport from 'core/transports/transport';\nimport Util from 'core/util';\nimport * as Collections from 'core/utils/collections';\nimport TransportHooks from 'core/transports/transport_hooks';\nimport TransportsTable from 'core/transports/transports_table';\nimport Runtime from 'runtime';\n\n/** WebSocket transport.\n *\n * Uses native WebSocket implementation, including MozWebSocket supported by\n * earlier Firefox versions.\n */\nvar WSTransport = new Transport({\n urls: URLSchemes.ws,\n handlesActivityChecks: false,\n supportsPing: false,\n\n isInitialized: function() {\n return Boolean(Runtime.getWebSocketAPI());\n },\n isSupported: function(): boolean {\n return Boolean(Runtime.getWebSocketAPI());\n },\n getSocket: function(url) {\n return Runtime.createWebSocket(url);\n }\n});\n\nvar httpConfiguration = {\n urls: URLSchemes.http,\n handlesActivityChecks: false,\n supportsPing: true,\n isInitialized: function() {\n return true;\n }\n};\n\nexport var streamingConfiguration = Collections.extend(\n {\n getSocket: function(url) {\n return Runtime.HTTPFactory.createStreamingSocket(url);\n }\n },\n httpConfiguration\n);\nexport var pollingConfiguration = Collections.extend(\n {\n getSocket: function(url) {\n return Runtime.HTTPFactory.createPollingSocket(url);\n }\n },\n httpConfiguration\n);\n\nvar xhrConfiguration = {\n isSupported: function(): boolean {\n return Runtime.isXHRSupported();\n }\n};\n\n/** HTTP streaming transport using CORS-enabled XMLHttpRequest. */\nvar XHRStreamingTransport = new Transport(\n (\n Collections.extend({}, streamingConfiguration, xhrConfiguration)\n )\n);\n\n/** HTTP long-polling transport using CORS-enabled XMLHttpRequest. */\nvar XHRPollingTransport = new Transport(\n Collections.extend({}, pollingConfiguration, xhrConfiguration)\n);\n\nvar Transports: TransportsTable = {\n ws: WSTransport,\n xhr_streaming: XHRStreamingTransport,\n xhr_polling: XHRPollingTransport\n};\n\nexport default Transports;\n","import Util from '../util';\nimport * as Collections from '../utils/collections';\nimport TransportManager from './transport_manager';\nimport TransportConnection from './transport_connection';\nimport Transport from './transport';\nimport PingDelayOptions from './ping_delay_options';\n\n/** Creates transport connections monitored by a transport manager.\n *\n * When a transport is closed, it might mean the environment does not support\n * it. It's possible that messages get stuck in an intermediate buffer or\n * proxies terminate inactive connections. To combat these problems,\n * assistants monitor the connection lifetime, report unclean exits and\n * adjust ping timeouts to keep the connection active. The decision to disable\n * a transport is the manager's responsibility.\n *\n * @param {TransportManager} manager\n * @param {TransportConnection} transport\n * @param {Object} options\n */\nexport default class AssistantToTheTransportManager {\n manager: TransportManager;\n transport: Transport;\n minPingDelay: number;\n maxPingDelay: number;\n pingDelay: number;\n\n constructor(\n manager: TransportManager,\n transport: Transport,\n options: PingDelayOptions\n ) {\n this.manager = manager;\n this.transport = transport;\n this.minPingDelay = options.minPingDelay;\n this.maxPingDelay = options.maxPingDelay;\n this.pingDelay = undefined;\n }\n\n /** Creates a transport connection.\n *\n * This function has the same API as Transport#createConnection.\n *\n * @param {String} name\n * @param {Number} priority\n * @param {String} key the application key\n * @param {Object} options\n * @returns {TransportConnection}\n */\n createConnection(\n name: string,\n priority: number,\n key: string,\n options: Object\n ): TransportConnection {\n options = Collections.extend({}, options, {\n activityTimeout: this.pingDelay\n });\n var connection = this.transport.createConnection(\n name,\n priority,\n key,\n options\n );\n\n var openTimestamp = null;\n\n var onOpen = function() {\n connection.unbind('open', onOpen);\n connection.bind('closed', onClosed);\n openTimestamp = Util.now();\n };\n var onClosed = closeEvent => {\n connection.unbind('closed', onClosed);\n\n if (closeEvent.code === 1002 || closeEvent.code === 1003) {\n // we don't want to use transports not obeying the protocol\n this.manager.reportDeath();\n } else if (!closeEvent.wasClean && openTimestamp) {\n // report deaths only for short-living transport\n var lifespan = Util.now() - openTimestamp;\n if (lifespan < 2 * this.maxPingDelay) {\n this.manager.reportDeath();\n this.pingDelay = Math.max(lifespan / 2, this.minPingDelay);\n }\n }\n };\n\n connection.bind('open', onOpen);\n return connection;\n }\n\n /** Returns whether the transport is supported in the environment.\n *\n * This function has the same API as Transport#isSupported. Might return false\n * when the manager decides to kill the transport.\n *\n * @param {Object} environment the environment details (encryption, settings)\n * @returns {Boolean} true when the transport is supported\n */\n isSupported(environment: string): boolean {\n return this.manager.isAlive() && this.transport.isSupported(environment);\n }\n}\n","import Action from './action';\nimport { PusherEvent } from './message-types';\n/**\n * Provides functions for handling Pusher protocol-specific messages.\n */\n\nconst Protocol = {\n /**\n * Decodes a message in a Pusher format.\n *\n * The MessageEvent we receive from the transport should contain a pusher event\n * (https://pusher.com/docs/pusher_protocol#events) serialized as JSON in the\n * data field\n *\n * The pusher event may contain a data field too, and it may also be\n * serialised as JSON\n *\n * Throws errors when messages are not parse'able.\n *\n * @param {MessageEvent} messageEvent\n * @return {PusherEvent}\n */\n decodeMessage: function(messageEvent: MessageEvent): PusherEvent {\n try {\n var messageData = JSON.parse(messageEvent.data);\n var pusherEventData = messageData.data;\n if (typeof pusherEventData === 'string') {\n try {\n pusherEventData = JSON.parse(messageData.data);\n } catch (e) {}\n }\n var pusherEvent: PusherEvent = {\n event: messageData.event,\n channel: messageData.channel,\n data: pusherEventData\n };\n if (messageData.user_id) {\n pusherEvent.user_id = messageData.user_id;\n }\n return pusherEvent;\n } catch (e) {\n throw { type: 'MessageParseError', error: e, data: messageEvent.data };\n }\n },\n\n /**\n * Encodes a message to be sent.\n *\n * @param {PusherEvent} event\n * @return {String}\n */\n encodeMessage: function(event: PusherEvent): string {\n return JSON.stringify(event);\n },\n\n /**\n * Processes a handshake message and returns appropriate actions.\n *\n * Returns an object with an 'action' and other action-specific properties.\n *\n * There are three outcomes when calling this function. First is a successful\n * connection attempt, when pusher:connection_established is received, which\n * results in a 'connected' action with an 'id' property. When passed a\n * pusher:error event, it returns a result with action appropriate to the\n * close code and an error. Otherwise, it raises an exception.\n *\n * @param {String} message\n * @result Object\n */\n processHandshake: function(messageEvent: MessageEvent): Action {\n var message = Protocol.decodeMessage(messageEvent);\n\n if (message.event === 'pusher:connection_established') {\n if (!message.data.activity_timeout) {\n throw 'No activity timeout specified in handshake';\n }\n return {\n action: 'connected',\n id: message.data.socket_id,\n activityTimeout: message.data.activity_timeout * 1000\n };\n } else if (message.event === 'pusher:error') {\n // From protocol 6 close codes are sent only once, so this only\n // happens when connection does not support close codes\n return {\n action: this.getCloseAction(message.data),\n error: this.getCloseError(message.data)\n };\n } else {\n throw 'Invalid handshake';\n }\n },\n\n /**\n * Dispatches the close event and returns an appropriate action name.\n *\n * See:\n * 1. https://developer.mozilla.org/en-US/docs/WebSockets/WebSockets_reference/CloseEvent\n * 2. http://pusher.com/docs/pusher_protocol\n *\n * @param {CloseEvent} closeEvent\n * @return {String} close action name\n */\n getCloseAction: function(closeEvent): string {\n if (closeEvent.code < 4000) {\n // ignore 1000 CLOSE_NORMAL, 1001 CLOSE_GOING_AWAY,\n // 1005 CLOSE_NO_STATUS, 1006 CLOSE_ABNORMAL\n // ignore 1007...3999\n // handle 1002 CLOSE_PROTOCOL_ERROR, 1003 CLOSE_UNSUPPORTED,\n // 1004 CLOSE_TOO_LARGE\n if (closeEvent.code >= 1002 && closeEvent.code <= 1004) {\n return 'backoff';\n } else {\n return null;\n }\n } else if (closeEvent.code === 4000) {\n return 'tls_only';\n } else if (closeEvent.code < 4100) {\n return 'refused';\n } else if (closeEvent.code < 4200) {\n return 'backoff';\n } else if (closeEvent.code < 4300) {\n return 'retry';\n } else {\n // unknown error\n return 'refused';\n }\n },\n\n /**\n * Returns an error or null basing on the close event.\n *\n * Null is returned when connection was closed cleanly. Otherwise, an object\n * with error details is returned.\n *\n * @param {CloseEvent} closeEvent\n * @return {Object} error object\n */\n getCloseError: function(closeEvent): any {\n if (closeEvent.code !== 1000 && closeEvent.code !== 1001) {\n return {\n type: 'PusherError',\n data: {\n code: closeEvent.code,\n message: closeEvent.reason || closeEvent.message\n }\n };\n } else {\n return null;\n }\n }\n};\n\nexport default Protocol;\n","import * as Collections from '../utils/collections';\nimport { default as EventsDispatcher } from '../events/dispatcher';\nimport Protocol from './protocol/protocol';\nimport { PusherEvent } from './protocol/message-types';\nimport Logger from '../logger';\nimport TransportConnection from '../transports/transport_connection';\nimport Socket from '../socket';\n/**\n * Provides Pusher protocol interface for transports.\n *\n * Emits following events:\n * - message - on received messages\n * - ping - on ping requests\n * - pong - on pong responses\n * - error - when the transport emits an error\n * - closed - after closing the transport\n *\n * It also emits more events when connection closes with a code.\n * See Protocol.getCloseAction to get more details.\n *\n * @param {Number} id\n * @param {AbstractTransport} transport\n */\nexport default class Connection extends EventsDispatcher implements Socket {\n id: string;\n transport: TransportConnection;\n activityTimeout: number;\n\n constructor(id: string, transport: TransportConnection) {\n super();\n this.id = id;\n this.transport = transport;\n this.activityTimeout = transport.activityTimeout;\n this.bindListeners();\n }\n\n /** Returns whether used transport handles activity checks by itself\n *\n * @returns {Boolean} true if activity checks are handled by the transport\n */\n handlesActivityChecks() {\n return this.transport.handlesActivityChecks();\n }\n\n /** Sends raw data.\n *\n * @param {String} data\n */\n send(data: any): boolean {\n return this.transport.send(data);\n }\n\n /** Sends an event.\n *\n * @param {String} name\n * @param {String} data\n * @param {String} [channel]\n * @returns {Boolean} whether message was sent or not\n */\n send_event(name: string, data: any, channel?: string): boolean {\n var event: PusherEvent = { event: name, data: data };\n if (channel) {\n event.channel = channel;\n }\n Logger.debug('Event sent', event);\n return this.send(Protocol.encodeMessage(event));\n }\n\n /** Sends a ping message to the server.\n *\n * Basing on the underlying transport, it might send either transport's\n * protocol-specific ping or pusher:ping event.\n */\n ping() {\n if (this.transport.supportsPing()) {\n this.transport.ping();\n } else {\n this.send_event('pusher:ping', {});\n }\n }\n\n /** Closes the connection. */\n close() {\n this.transport.close();\n }\n\n private bindListeners() {\n var listeners = {\n message: (messageEvent: MessageEvent) => {\n var pusherEvent;\n try {\n pusherEvent = Protocol.decodeMessage(messageEvent);\n } catch (e) {\n this.emit('error', {\n type: 'MessageParseError',\n error: e,\n data: messageEvent.data\n });\n }\n\n if (pusherEvent !== undefined) {\n Logger.debug('Event recd', pusherEvent);\n\n switch (pusherEvent.event) {\n case 'pusher:error':\n this.emit('error', {\n type: 'PusherError',\n data: pusherEvent.data\n });\n break;\n case 'pusher:ping':\n this.emit('ping');\n break;\n case 'pusher:pong':\n this.emit('pong');\n break;\n }\n this.emit('message', pusherEvent);\n }\n },\n activity: () => {\n this.emit('activity');\n },\n error: error => {\n this.emit('error', error);\n },\n closed: closeEvent => {\n unbindListeners();\n\n if (closeEvent && closeEvent.code) {\n this.handleCloseEvent(closeEvent);\n }\n\n this.transport = null;\n this.emit('closed');\n }\n };\n\n var unbindListeners = () => {\n Collections.objectApply(listeners, (listener, event) => {\n this.transport.unbind(event, listener);\n });\n };\n\n Collections.objectApply(listeners, (listener, event) => {\n this.transport.bind(event, listener);\n });\n }\n\n private handleCloseEvent(closeEvent: any) {\n var action = Protocol.getCloseAction(closeEvent);\n var error = Protocol.getCloseError(closeEvent);\n if (error) {\n this.emit('error', error);\n }\n if (action) {\n this.emit(action, { action: action, error: error });\n }\n }\n}\n","import Util from '../../util';\nimport * as Collections from '../../utils/collections';\nimport Protocol from '../protocol/protocol';\nimport Connection from '../connection';\nimport TransportConnection from '../../transports/transport_connection';\nimport HandshakePayload from './handshake_payload';\n\n/**\n * Handles Pusher protocol handshakes for transports.\n *\n * Calls back with a result object after handshake is completed. Results\n * always have two fields:\n * - action - string describing action to be taken after the handshake\n * - transport - the transport object passed to the constructor\n *\n * Different actions can set different additional properties on the result.\n * In the case of 'connected' action, there will be a 'connection' property\n * containing a Connection object for the transport. Other actions should\n * carry an 'error' property.\n *\n * @param {AbstractTransport} transport\n * @param {Function} callback\n */\nexport default class Handshake {\n transport: TransportConnection;\n callback: (HandshakePayload) => void;\n onMessage: Function;\n onClosed: Function;\n\n constructor(\n transport: TransportConnection,\n callback: (HandshakePayload) => void\n ) {\n this.transport = transport;\n this.callback = callback;\n this.bindListeners();\n }\n\n close() {\n this.unbindListeners();\n this.transport.close();\n }\n\n private bindListeners() {\n this.onMessage = m => {\n this.unbindListeners();\n\n var result;\n try {\n result = Protocol.processHandshake(m);\n } catch (e) {\n this.finish('error', { error: e });\n this.transport.close();\n return;\n }\n\n if (result.action === 'connected') {\n this.finish('connected', {\n connection: new Connection(result.id, this.transport),\n activityTimeout: result.activityTimeout\n });\n } else {\n this.finish(result.action, { error: result.error });\n this.transport.close();\n }\n };\n\n this.onClosed = closeEvent => {\n this.unbindListeners();\n\n var action = Protocol.getCloseAction(closeEvent) || 'backoff';\n var error = Protocol.getCloseError(closeEvent);\n this.finish(action, { error: error });\n };\n\n this.transport.bind('message', this.onMessage);\n this.transport.bind('closed', this.onClosed);\n }\n\n private unbindListeners() {\n this.transport.unbind('message', this.onMessage);\n this.transport.unbind('closed', this.onClosed);\n }\n\n private finish(action: string, params: any) {\n this.callback(\n Collections.extend({ transport: this.transport, action: action }, params)\n );\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport base64encode from '../base64';\nimport Timeline from './timeline';\nimport Runtime from 'runtime';\n\nexport interface TimelineSenderOptions {\n host?: string;\n port?: number;\n path?: string;\n}\n\nexport default class TimelineSender {\n timeline: Timeline;\n options: TimelineSenderOptions;\n host: string;\n\n constructor(timeline: Timeline, options: TimelineSenderOptions) {\n this.timeline = timeline;\n this.options = options || {};\n }\n\n send(useTLS: boolean, callback?: Function) {\n if (this.timeline.isEmpty()) {\n return;\n }\n\n this.timeline.send(\n Runtime.TimelineTransport.getAgent(this, useTLS),\n callback\n );\n }\n}\n","/** Error classes used throughout the library. */\n// https://github.com/Microsoft/TypeScript-wiki/blob/master/Breaking-Changes.md#extending-built-ins-like-error-array-and-map-may-no-longer-work\nexport class BadEventName extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\nexport class BadChannelName extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\nexport class RequestTimedOut extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class TransportPriorityTooLow extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class TransportClosed extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class UnsupportedFeature extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class UnsupportedTransport extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class UnsupportedStrategy extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class HTTPAuthError extends Error {\n status: number;\n constructor(status: number, msg?: string) {\n super(msg);\n this.status = status;\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n","/**\n * A place to store help URLs for error messages etc\n */\n\nconst urlStore = {\n baseUrl: 'https://pusher.com',\n urls: {\n authenticationEndpoint: {\n path: '/docs/channels/server_api/authenticating_users'\n },\n authorizationEndpoint: {\n path: '/docs/channels/server_api/authorizing-users/'\n },\n javascriptQuickStart: {\n path: '/docs/javascript_quick_start'\n },\n triggeringClientEvents: {\n path: '/docs/client_api_guide/client_events#trigger-events'\n },\n encryptedChannelSupport: {\n fullUrl:\n 'https://github.com/pusher/pusher-js/tree/cc491015371a4bde5743d1c87a0fbac0feb53195#encrypted-channel-support'\n }\n }\n};\n\n/** Builds a consistent string with links to pusher documentation\n *\n * @param {string} key - relevant key in the url_store.urls object\n * @return {string} suffix string to append to log message\n */\nconst buildLogSuffix = function(key: string): string {\n const urlPrefix = 'See:';\n const urlObj = urlStore.urls[key];\n if (!urlObj) return '';\n\n let url;\n if (urlObj.fullUrl) {\n url = urlObj.fullUrl;\n } else if (urlObj.path) {\n url = urlStore.baseUrl + urlObj.path;\n }\n\n if (!url) return '';\n return `${urlPrefix} ${url}`;\n};\n\nexport default { buildLogSuffix };\n","import { default as EventsDispatcher } from '../events/dispatcher';\nimport * as Errors from '../errors';\nimport Logger from '../logger';\nimport Pusher from '../pusher';\nimport { PusherEvent } from '../connection/protocol/message-types';\nimport Metadata from './metadata';\nimport UrlStore from '../utils/url_store';\nimport {\n ChannelAuthorizationData,\n ChannelAuthorizationCallback\n} from '../auth/options';\nimport { HTTPAuthError } from '../errors';\n\n/** Provides base public channel interface with an event emitter.\n *\n * Emits:\n * - pusher:subscription_succeeded - after subscribing successfully\n * - other non-internal events\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\nexport default class Channel extends EventsDispatcher {\n name: string;\n pusher: Pusher;\n subscribed: boolean;\n subscriptionPending: boolean;\n subscriptionCancelled: boolean;\n subscriptionCount: null;\n\n constructor(name: string, pusher: Pusher) {\n super(function(event, data) {\n Logger.debug('No callbacks on ' + name + ' for ' + event);\n });\n\n this.name = name;\n this.pusher = pusher;\n this.subscribed = false;\n this.subscriptionPending = false;\n this.subscriptionCancelled = false;\n }\n\n /** Skips authorization, since public channels don't require it.\n *\n * @param {Function} callback\n */\n authorize(socketId: string, callback: ChannelAuthorizationCallback) {\n return callback(null, { auth: '' });\n }\n\n /** Triggers an event */\n trigger(event: string, data: any) {\n if (event.indexOf('client-') !== 0) {\n throw new Errors.BadEventName(\n \"Event '\" + event + \"' does not start with 'client-'\"\n );\n }\n if (!this.subscribed) {\n var suffix = UrlStore.buildLogSuffix('triggeringClientEvents');\n Logger.warn(\n `Client event triggered before channel 'subscription_succeeded' event . ${suffix}`\n );\n }\n return this.pusher.send_event(event, data, this.name);\n }\n\n /** Signals disconnection to the channel. For internal use only. */\n disconnect() {\n this.subscribed = false;\n this.subscriptionPending = false;\n }\n\n /** Handles a PusherEvent. For internal use only.\n *\n * @param {PusherEvent} event\n */\n handleEvent(event: PusherEvent) {\n var eventName = event.event;\n var data = event.data;\n if (eventName === 'pusher_internal:subscription_succeeded') {\n this.handleSubscriptionSucceededEvent(event);\n } else if (eventName === 'pusher_internal:subscription_count') {\n this.handleSubscriptionCountEvent(event);\n } else if (eventName.indexOf('pusher_internal:') !== 0) {\n var metadata: Metadata = {};\n this.emit(eventName, data, metadata);\n }\n }\n\n handleSubscriptionSucceededEvent(event: PusherEvent) {\n this.subscriptionPending = false;\n this.subscribed = true;\n if (this.subscriptionCancelled) {\n this.pusher.unsubscribe(this.name);\n } else {\n this.emit('pusher:subscription_succeeded', event.data);\n }\n }\n\n handleSubscriptionCountEvent(event: PusherEvent) {\n if (event.data.subscription_count) {\n this.subscriptionCount = event.data.subscription_count;\n }\n\n this.emit('pusher:subscription_count', event.data);\n }\n\n /** Sends a subscription request. For internal use only. */\n subscribe() {\n if (this.subscribed) {\n return;\n }\n this.subscriptionPending = true;\n this.subscriptionCancelled = false;\n this.authorize(\n this.pusher.connection.socket_id,\n (error: Error | null, data: ChannelAuthorizationData) => {\n if (error) {\n this.subscriptionPending = false;\n // Why not bind to 'pusher:subscription_error' a level up, and log there?\n // Binding to this event would cause the warning about no callbacks being\n // bound (see constructor) to be suppressed, that's not what we want.\n Logger.error(error.toString());\n this.emit(\n 'pusher:subscription_error',\n Object.assign(\n {},\n {\n type: 'AuthError',\n error: error.message\n },\n error instanceof HTTPAuthError ? { status: error.status } : {}\n )\n );\n } else {\n this.pusher.send_event('pusher:subscribe', {\n auth: data.auth,\n channel_data: data.channel_data,\n channel: this.name\n });\n }\n }\n );\n }\n\n /** Sends an unsubscription request. For internal use only. */\n unsubscribe() {\n this.subscribed = false;\n this.pusher.send_event('pusher:unsubscribe', {\n channel: this.name\n });\n }\n\n /** Cancels an in progress subscription. For internal use only. */\n cancelSubscription() {\n this.subscriptionCancelled = true;\n }\n\n /** Reinstates an in progress subscripiton. For internal use only. */\n reinstateSubscription() {\n this.subscriptionCancelled = false;\n }\n}\n","import Factory from '../utils/factory';\nimport Channel from './channel';\nimport { ChannelAuthorizationCallback } from '../auth/options';\n\n/** Extends public channels to provide private channel interface.\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\nexport default class PrivateChannel extends Channel {\n /** Authorizes the connection to use the channel.\n *\n * @param {String} socketId\n * @param {Function} callback\n */\n authorize(socketId: string, callback: ChannelAuthorizationCallback) {\n return this.pusher.config.channelAuthorizer(\n {\n channelName: this.name,\n socketId: socketId\n },\n callback\n );\n }\n}\n","import * as Collections from '../utils/collections';\n\n/** Represents a collection of members of a presence channel. */\nexport default class Members {\n members: any;\n count: number;\n myID: any;\n me: any;\n\n constructor() {\n this.reset();\n }\n\n /** Returns member's info for given id.\n *\n * Resulting object containts two fields - id and info.\n *\n * @param {Number} id\n * @return {Object} member's info or null\n */\n get(id: string): any {\n if (Object.prototype.hasOwnProperty.call(this.members, id)) {\n return {\n id: id,\n info: this.members[id]\n };\n } else {\n return null;\n }\n }\n\n /** Calls back for each member in unspecified order.\n *\n * @param {Function} callback\n */\n each(callback: Function) {\n Collections.objectApply(this.members, (member, id) => {\n callback(this.get(id));\n });\n }\n\n /** Updates the id for connected member. For internal use only. */\n setMyID(id: string) {\n this.myID = id;\n }\n\n /** Handles subscription data. For internal use only. */\n onSubscription(subscriptionData: any) {\n this.members = subscriptionData.presence.hash;\n this.count = subscriptionData.presence.count;\n this.me = this.get(this.myID);\n }\n\n /** Adds a new member to the collection. For internal use only. */\n addMember(memberData: any) {\n if (this.get(memberData.user_id) === null) {\n this.count++;\n }\n this.members[memberData.user_id] = memberData.user_info;\n return this.get(memberData.user_id);\n }\n\n /** Adds a member from the collection. For internal use only. */\n removeMember(memberData: any) {\n var member = this.get(memberData.user_id);\n if (member) {\n delete this.members[memberData.user_id];\n this.count--;\n }\n return member;\n }\n\n /** Resets the collection to the initial state. For internal use only. */\n reset() {\n this.members = {};\n this.count = 0;\n this.myID = null;\n this.me = null;\n }\n}\n","import PrivateChannel from './private_channel';\nimport Logger from '../logger';\nimport Members from './members';\nimport Pusher from '../pusher';\nimport UrlStore from 'core/utils/url_store';\nimport { PusherEvent } from '../connection/protocol/message-types';\nimport Metadata from './metadata';\nimport { ChannelAuthorizationData } from '../auth/options';\n\nexport default class PresenceChannel extends PrivateChannel {\n members: Members;\n\n /** Adds presence channel functionality to private channels.\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\n constructor(name: string, pusher: Pusher) {\n super(name, pusher);\n this.members = new Members();\n }\n\n /** Authorizes the connection as a member of the channel.\n *\n * @param {String} socketId\n * @param {Function} callback\n */\n authorize(socketId: string, callback: Function) {\n super.authorize(socketId, async (error, authData) => {\n if (!error) {\n authData = authData as ChannelAuthorizationData;\n if (authData.channel_data != null) {\n var channelData = JSON.parse(authData.channel_data);\n this.members.setMyID(channelData.user_id);\n } else {\n await this.pusher.user.signinDonePromise;\n if (this.pusher.user.user_data != null) {\n // If the user is signed in, get the id of the authenticated user\n // and allow the presence authorization to continue.\n this.members.setMyID(this.pusher.user.user_data.id);\n } else {\n let suffix = UrlStore.buildLogSuffix('authorizationEndpoint');\n Logger.error(\n `Invalid auth response for channel '${this.name}', ` +\n `expected 'channel_data' field. ${suffix}, ` +\n `or the user should be signed in.`\n );\n callback('Invalid auth response');\n return;\n }\n }\n }\n callback(error, authData);\n });\n }\n\n /** Handles presence and subscription events. For internal use only.\n *\n * @param {PusherEvent} event\n */\n handleEvent(event: PusherEvent) {\n var eventName = event.event;\n if (eventName.indexOf('pusher_internal:') === 0) {\n this.handleInternalEvent(event);\n } else {\n var data = event.data;\n var metadata: Metadata = {};\n if (event.user_id) {\n metadata.user_id = event.user_id;\n }\n this.emit(eventName, data, metadata);\n }\n }\n handleInternalEvent(event: PusherEvent) {\n var eventName = event.event;\n var data = event.data;\n switch (eventName) {\n case 'pusher_internal:subscription_succeeded':\n this.handleSubscriptionSucceededEvent(event);\n break;\n case 'pusher_internal:subscription_count':\n this.handleSubscriptionCountEvent(event);\n break;\n case 'pusher_internal:member_added':\n var addedMember = this.members.addMember(data);\n this.emit('pusher:member_added', addedMember);\n break;\n case 'pusher_internal:member_removed':\n var removedMember = this.members.removeMember(data);\n if (removedMember) {\n this.emit('pusher:member_removed', removedMember);\n }\n break;\n }\n }\n\n handleSubscriptionSucceededEvent(event: PusherEvent) {\n this.subscriptionPending = false;\n this.subscribed = true;\n if (this.subscriptionCancelled) {\n this.pusher.unsubscribe(this.name);\n } else {\n this.members.onSubscription(event.data);\n this.emit('pusher:subscription_succeeded', this.members);\n }\n }\n\n /** Resets the channel state, including members map. For internal use only. */\n disconnect() {\n this.members.reset();\n super.disconnect();\n }\n}\n","import PrivateChannel from './private_channel';\nimport * as Errors from '../errors';\nimport Logger from '../logger';\nimport Pusher from '../pusher';\nimport { decode as encodeUTF8 } from '@stablelib/utf8';\nimport { decode as decodeBase64 } from '@stablelib/base64';\nimport Dispatcher from '../events/dispatcher';\nimport { PusherEvent } from '../connection/protocol/message-types';\nimport {\n ChannelAuthorizationData,\n ChannelAuthorizationCallback\n} from '../auth/options';\nimport * as nacl from 'tweetnacl';\n\n/** Extends private channels to provide encrypted channel interface.\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\nexport default class EncryptedChannel extends PrivateChannel {\n key: Uint8Array = null;\n nacl: nacl;\n\n constructor(name: string, pusher: Pusher, nacl: nacl) {\n super(name, pusher);\n this.nacl = nacl;\n }\n\n /** Authorizes the connection to use the channel.\n *\n * @param {String} socketId\n * @param {Function} callback\n */\n authorize(socketId: string, callback: ChannelAuthorizationCallback) {\n super.authorize(\n socketId,\n (error: Error | null, authData: ChannelAuthorizationData) => {\n if (error) {\n callback(error, authData);\n return;\n }\n let sharedSecret = authData['shared_secret'];\n if (!sharedSecret) {\n callback(\n new Error(\n `No shared_secret key in auth payload for encrypted channel: ${this.name}`\n ),\n null\n );\n return;\n }\n this.key = decodeBase64(sharedSecret);\n delete authData['shared_secret'];\n callback(null, authData);\n }\n );\n }\n\n trigger(event: string, data: any): boolean {\n throw new Errors.UnsupportedFeature(\n 'Client events are not currently supported for encrypted channels'\n );\n }\n\n /** Handles an event. For internal use only.\n *\n * @param {PusherEvent} event\n */\n handleEvent(event: PusherEvent) {\n var eventName = event.event;\n var data = event.data;\n if (\n eventName.indexOf('pusher_internal:') === 0 ||\n eventName.indexOf('pusher:') === 0\n ) {\n super.handleEvent(event);\n return;\n }\n this.handleEncryptedEvent(eventName, data);\n }\n\n private handleEncryptedEvent(event: string, data: any): void {\n if (!this.key) {\n Logger.debug(\n 'Received encrypted event before key has been retrieved from the authEndpoint'\n );\n return;\n }\n if (!data.ciphertext || !data.nonce) {\n Logger.error(\n 'Unexpected format for encrypted event, expected object with `ciphertext` and `nonce` fields, got: ' +\n data\n );\n return;\n }\n let cipherText = decodeBase64(data.ciphertext);\n if (cipherText.length < this.nacl.secretbox.overheadLength) {\n Logger.error(\n `Expected encrypted event ciphertext length to be ${this.nacl.secretbox.overheadLength}, got: ${cipherText.length}`\n );\n return;\n }\n let nonce = decodeBase64(data.nonce);\n if (nonce.length < this.nacl.secretbox.nonceLength) {\n Logger.error(\n `Expected encrypted event nonce length to be ${this.nacl.secretbox.nonceLength}, got: ${nonce.length}`\n );\n return;\n }\n\n let bytes = this.nacl.secretbox.open(cipherText, nonce, this.key);\n if (bytes === null) {\n Logger.debug(\n 'Failed to decrypt an event, probably because it was encrypted with a different key. Fetching a new key from the authEndpoint...'\n );\n // Try a single time to retrieve a new auth key and decrypt the event with it\n // If this fails, a new key will be requested when a new message is received\n this.authorize(this.pusher.connection.socket_id, (error, authData) => {\n if (error) {\n Logger.error(\n `Failed to make a request to the authEndpoint: ${authData}. Unable to fetch new key, so dropping encrypted event`\n );\n return;\n }\n bytes = this.nacl.secretbox.open(cipherText, nonce, this.key);\n if (bytes === null) {\n Logger.error(\n `Failed to decrypt event with new key. Dropping encrypted event`\n );\n return;\n }\n this.emit(event, this.getDataToEmit(bytes));\n return;\n });\n return;\n }\n this.emit(event, this.getDataToEmit(bytes));\n }\n\n // Try and parse the decrypted bytes as JSON. If we can't parse it, just\n // return the utf-8 string\n getDataToEmit(bytes: Uint8Array): string {\n let raw = encodeUTF8(bytes);\n try {\n return JSON.parse(raw);\n } catch {\n return raw;\n }\n }\n}\n","import { default as EventsDispatcher } from '../events/dispatcher';\nimport { OneOffTimer as Timer } from '../utils/timers';\nimport { Config } from '../config';\nimport Logger from '../logger';\nimport HandshakePayload from './handshake/handshake_payload';\nimport Connection from './connection';\nimport Strategy from '../strategies/strategy';\nimport StrategyRunner from '../strategies/strategy_runner';\nimport * as Collections from '../utils/collections';\nimport Timeline from '../timeline/timeline';\nimport ConnectionManagerOptions from './connection_manager_options';\nimport Runtime from 'runtime';\n\nimport {\n ErrorCallbacks,\n HandshakeCallbacks,\n ConnectionCallbacks\n} from './callbacks';\nimport Action from './protocol/action';\n\n/** Manages connection to Pusher.\n *\n * Uses a strategy (currently only default), timers and network availability\n * info to establish a connection and export its state. In case of failures,\n * manages reconnection attempts.\n *\n * Exports state changes as following events:\n * - \"state_change\", { previous: p, current: state }\n * - state\n *\n * States:\n * - initialized - initial state, never transitioned to\n * - connecting - connection is being established\n * - connected - connection has been fully established\n * - disconnected - on requested disconnection\n * - unavailable - after connection timeout or when there's no network\n * - failed - when the connection strategy is not supported\n *\n * Options:\n * - unavailableTimeout - time to transition to unavailable state\n * - activityTimeout - time after which ping message should be sent\n * - pongTimeout - time for Pusher to respond with pong before reconnecting\n *\n * @param {String} key application key\n * @param {Object} options\n */\nexport default class ConnectionManager extends EventsDispatcher {\n key: string;\n options: ConnectionManagerOptions;\n state: string;\n connection: Connection;\n usingTLS: boolean;\n timeline: Timeline;\n socket_id: string;\n unavailableTimer: Timer;\n activityTimer: Timer;\n retryTimer: Timer;\n activityTimeout: number;\n strategy: Strategy;\n runner: StrategyRunner;\n errorCallbacks: ErrorCallbacks;\n handshakeCallbacks: HandshakeCallbacks;\n connectionCallbacks: ConnectionCallbacks;\n\n constructor(key: string, options: ConnectionManagerOptions) {\n super();\n this.state = 'initialized';\n this.connection = null;\n\n this.key = key;\n this.options = options;\n this.timeline = this.options.timeline;\n this.usingTLS = this.options.useTLS;\n\n this.errorCallbacks = this.buildErrorCallbacks();\n this.connectionCallbacks = this.buildConnectionCallbacks(\n this.errorCallbacks\n );\n this.handshakeCallbacks = this.buildHandshakeCallbacks(this.errorCallbacks);\n\n var Network = Runtime.getNetwork();\n\n Network.bind('online', () => {\n this.timeline.info({ netinfo: 'online' });\n if (this.state === 'connecting' || this.state === 'unavailable') {\n this.retryIn(0);\n }\n });\n Network.bind('offline', () => {\n this.timeline.info({ netinfo: 'offline' });\n if (this.connection) {\n this.sendActivityCheck();\n }\n });\n\n this.updateStrategy();\n }\n\n switchCluster(key: string) {\n this.key = key;\n // This ensures that the new config coming from\n // pusher instance are taken into account\n // such as appKey and cluster\n this.updateStrategy();\n this.retryIn(0);\n }\n\n /** Establishes a connection to Pusher.\n *\n * Does nothing when connection is already established. See top-level doc\n * to find events emitted on connection attempts.\n */\n connect() {\n if (this.connection || this.runner) {\n return;\n }\n if (!this.strategy.isSupported()) {\n this.updateState('failed');\n return;\n }\n this.updateState('connecting');\n this.startConnecting();\n this.setUnavailableTimer();\n }\n\n /** Sends raw data.\n *\n * @param {String} data\n */\n send(data) {\n if (this.connection) {\n return this.connection.send(data);\n } else {\n return false;\n }\n }\n\n /** Sends an event.\n *\n * @param {String} name\n * @param {String} data\n * @param {String} [channel]\n * @returns {Boolean} whether message was sent or not\n */\n send_event(name: string, data: any, channel?: string) {\n if (this.connection) {\n return this.connection.send_event(name, data, channel);\n } else {\n return false;\n }\n }\n\n /** Closes the connection. */\n disconnect() {\n this.disconnectInternally();\n this.updateState('disconnected');\n }\n\n isUsingTLS() {\n return this.usingTLS;\n }\n\n private startConnecting() {\n var callback = (error, handshake) => {\n if (error) {\n this.runner = this.strategy.connect(0, callback);\n } else {\n if (handshake.action === 'error') {\n this.emit('error', {\n type: 'HandshakeError',\n error: handshake.error\n });\n this.timeline.error({ handshakeError: handshake.error });\n } else {\n this.abortConnecting(); // we don't support switching connections yet\n this.handshakeCallbacks[handshake.action](handshake);\n }\n }\n };\n this.runner = this.strategy.connect(0, callback);\n }\n\n private abortConnecting() {\n if (this.runner) {\n this.runner.abort();\n this.runner = null;\n }\n }\n\n private disconnectInternally() {\n this.abortConnecting();\n this.clearRetryTimer();\n this.clearUnavailableTimer();\n if (this.connection) {\n var connection = this.abandonConnection();\n connection.close();\n }\n }\n\n private updateStrategy() {\n this.strategy = this.options.getStrategy({\n key: this.key,\n timeline: this.timeline,\n useTLS: this.usingTLS\n });\n }\n\n private retryIn(delay) {\n this.timeline.info({ action: 'retry', delay: delay });\n if (delay > 0) {\n this.emit('connecting_in', Math.round(delay / 1000));\n }\n this.retryTimer = new Timer(delay || 0, () => {\n this.disconnectInternally();\n this.connect();\n });\n }\n\n private clearRetryTimer() {\n if (this.retryTimer) {\n this.retryTimer.ensureAborted();\n this.retryTimer = null;\n }\n }\n\n private setUnavailableTimer() {\n this.unavailableTimer = new Timer(this.options.unavailableTimeout, () => {\n this.updateState('unavailable');\n });\n }\n\n private clearUnavailableTimer() {\n if (this.unavailableTimer) {\n this.unavailableTimer.ensureAborted();\n }\n }\n\n private sendActivityCheck() {\n this.stopActivityCheck();\n this.connection.ping();\n // wait for pong response\n this.activityTimer = new Timer(this.options.pongTimeout, () => {\n this.timeline.error({ pong_timed_out: this.options.pongTimeout });\n this.retryIn(0);\n });\n }\n\n private resetActivityCheck() {\n this.stopActivityCheck();\n // send ping after inactivity\n if (this.connection && !this.connection.handlesActivityChecks()) {\n this.activityTimer = new Timer(this.activityTimeout, () => {\n this.sendActivityCheck();\n });\n }\n }\n\n private stopActivityCheck() {\n if (this.activityTimer) {\n this.activityTimer.ensureAborted();\n }\n }\n\n private buildConnectionCallbacks(\n errorCallbacks: ErrorCallbacks\n ): ConnectionCallbacks {\n return Collections.extend({}, errorCallbacks, {\n message: message => {\n // includes pong messages from server\n this.resetActivityCheck();\n this.emit('message', message);\n },\n ping: () => {\n this.send_event('pusher:pong', {});\n },\n activity: () => {\n this.resetActivityCheck();\n },\n error: error => {\n // just emit error to user - socket will already be closed by browser\n this.emit('error', error);\n },\n closed: () => {\n this.abandonConnection();\n if (this.shouldRetry()) {\n this.retryIn(1000);\n }\n }\n });\n }\n\n private buildHandshakeCallbacks(\n errorCallbacks: ErrorCallbacks\n ): HandshakeCallbacks {\n return Collections.extend({}, errorCallbacks, {\n connected: (handshake: HandshakePayload) => {\n this.activityTimeout = Math.min(\n this.options.activityTimeout,\n handshake.activityTimeout,\n handshake.connection.activityTimeout || Infinity\n );\n this.clearUnavailableTimer();\n this.setConnection(handshake.connection);\n this.socket_id = this.connection.id;\n this.updateState('connected', { socket_id: this.socket_id });\n }\n });\n }\n\n private buildErrorCallbacks(): ErrorCallbacks {\n let withErrorEmitted = callback => {\n return (result: Action | HandshakePayload) => {\n if (result.error) {\n this.emit('error', { type: 'WebSocketError', error: result.error });\n }\n callback(result);\n };\n };\n\n return {\n tls_only: withErrorEmitted(() => {\n this.usingTLS = true;\n this.updateStrategy();\n this.retryIn(0);\n }),\n refused: withErrorEmitted(() => {\n this.disconnect();\n }),\n backoff: withErrorEmitted(() => {\n this.retryIn(1000);\n }),\n retry: withErrorEmitted(() => {\n this.retryIn(0);\n })\n };\n }\n\n private setConnection(connection) {\n this.connection = connection;\n for (var event in this.connectionCallbacks) {\n this.connection.bind(event, this.connectionCallbacks[event]);\n }\n this.resetActivityCheck();\n }\n\n private abandonConnection() {\n if (!this.connection) {\n return;\n }\n this.stopActivityCheck();\n for (var event in this.connectionCallbacks) {\n this.connection.unbind(event, this.connectionCallbacks[event]);\n }\n var connection = this.connection;\n this.connection = null;\n return connection;\n }\n\n private updateState(newState: string, data?: any) {\n var previousState = this.state;\n this.state = newState;\n if (previousState !== newState) {\n var newStateDescription = newState;\n if (newStateDescription === 'connected') {\n newStateDescription += ' with new socket ID ' + data.socket_id;\n }\n Logger.debug(\n 'State changed',\n previousState + ' -> ' + newStateDescription\n );\n this.timeline.info({ state: newState, params: data });\n this.emit('state_change', { previous: previousState, current: newState });\n this.emit(newState, data);\n }\n }\n\n private shouldRetry(): boolean {\n return this.state === 'connecting' || this.state === 'connected';\n }\n}\n","import Channel from './channel';\nimport * as Collections from '../utils/collections';\nimport ChannelTable from './channel_table';\nimport Factory from '../utils/factory';\nimport Pusher from '../pusher';\nimport Logger from '../logger';\nimport * as Errors from '../errors';\nimport urlStore from '../utils/url_store';\n\n/** Handles a channel map. */\nexport default class Channels {\n channels: ChannelTable;\n\n constructor() {\n this.channels = {};\n }\n\n /** Creates or retrieves an existing channel by its name.\n *\n * @param {String} name\n * @param {Pusher} pusher\n * @return {Channel}\n */\n add(name: string, pusher: Pusher) {\n if (!this.channels[name]) {\n this.channels[name] = createChannel(name, pusher);\n }\n return this.channels[name];\n }\n\n /** Returns a list of all channels\n *\n * @return {Array}\n */\n all(): Channel[] {\n return Collections.values(this.channels);\n }\n\n /** Finds a channel by its name.\n *\n * @param {String} name\n * @return {Channel} channel or null if it doesn't exist\n */\n find(name: string) {\n return this.channels[name];\n }\n\n /** Removes a channel from the map.\n *\n * @param {String} name\n */\n remove(name: string) {\n var channel = this.channels[name];\n delete this.channels[name];\n return channel;\n }\n\n /** Proxies disconnection signal to all channels. */\n disconnect() {\n Collections.objectApply(this.channels, function(channel) {\n channel.disconnect();\n });\n }\n}\n\nfunction createChannel(name: string, pusher: Pusher): Channel {\n if (name.indexOf('private-encrypted-') === 0) {\n if (pusher.config.nacl) {\n return Factory.createEncryptedChannel(name, pusher, pusher.config.nacl);\n }\n let errMsg =\n 'Tried to subscribe to a private-encrypted- channel but no nacl implementation available';\n let suffix = urlStore.buildLogSuffix('encryptedChannelSupport');\n throw new Errors.UnsupportedFeature(`${errMsg}. ${suffix}`);\n } else if (name.indexOf('private-') === 0) {\n return Factory.createPrivateChannel(name, pusher);\n } else if (name.indexOf('presence-') === 0) {\n return Factory.createPresenceChannel(name, pusher);\n } else if (name.indexOf('#') === 0) {\n throw new Errors.BadChannelName(\n 'Cannot create a channel with name \"' + name + '\".'\n );\n } else {\n return Factory.createChannel(name, pusher);\n }\n}\n","import AssistantToTheTransportManager from '../transports/assistant_to_the_transport_manager';\nimport PingDelayOptions from '../transports/ping_delay_options';\nimport Transport from '../transports/transport';\nimport TransportManager from '../transports/transport_manager';\nimport Handshake from '../connection/handshake';\nimport TransportConnection from '../transports/transport_connection';\nimport SocketHooks from '../http/socket_hooks';\nimport HTTPSocket from '../http/http_socket';\n\nimport Timeline from '../timeline/timeline';\nimport {\n default as TimelineSender,\n TimelineSenderOptions\n} from '../timeline/timeline_sender';\nimport PresenceChannel from '../channels/presence_channel';\nimport PrivateChannel from '../channels/private_channel';\nimport EncryptedChannel from '../channels/encrypted_channel';\nimport Channel from '../channels/channel';\nimport ConnectionManager from '../connection/connection_manager';\nimport ConnectionManagerOptions from '../connection/connection_manager_options';\nimport Ajax from '../http/ajax';\nimport Channels from '../channels/channels';\nimport Pusher from '../pusher';\nimport { Config } from '../config';\nimport * as nacl from 'tweetnacl';\n\nvar Factory = {\n createChannels(): Channels {\n return new Channels();\n },\n\n createConnectionManager(\n key: string,\n options: ConnectionManagerOptions\n ): ConnectionManager {\n return new ConnectionManager(key, options);\n },\n\n createChannel(name: string, pusher: Pusher): Channel {\n return new Channel(name, pusher);\n },\n\n createPrivateChannel(name: string, pusher: Pusher): PrivateChannel {\n return new PrivateChannel(name, pusher);\n },\n\n createPresenceChannel(name: string, pusher: Pusher): PresenceChannel {\n return new PresenceChannel(name, pusher);\n },\n\n createEncryptedChannel(\n name: string,\n pusher: Pusher,\n nacl: nacl\n ): EncryptedChannel {\n return new EncryptedChannel(name, pusher, nacl);\n },\n\n createTimelineSender(timeline: Timeline, options: TimelineSenderOptions) {\n return new TimelineSender(timeline, options);\n },\n\n createHandshake(\n transport: TransportConnection,\n callback: (HandshakePayload) => void\n ): Handshake {\n return new Handshake(transport, callback);\n },\n\n createAssistantToTheTransportManager(\n manager: TransportManager,\n transport: Transport,\n options: PingDelayOptions\n ): AssistantToTheTransportManager {\n return new AssistantToTheTransportManager(manager, transport, options);\n }\n};\n\nexport default Factory;\n","import AssistantToTheTransportManager from './assistant_to_the_transport_manager';\nimport Transport from './transport';\nimport PingDelayOptions from './ping_delay_options';\nimport Factory from '../utils/factory';\n\nexport interface TransportManagerOptions extends PingDelayOptions {\n lives?: number;\n}\n\n/** Keeps track of the number of lives left for a transport.\n *\n * In the beginning of a session, transports may be assigned a number of\n * lives. When an AssistantToTheTransportManager instance reports a transport\n * connection closed uncleanly, the transport loses a life. When the number\n * of lives drops to zero, the transport gets disabled by its manager.\n *\n * @param {Object} options\n */\nexport default class TransportManager {\n options: TransportManagerOptions;\n livesLeft: number;\n\n constructor(options: TransportManagerOptions) {\n this.options = options || {};\n this.livesLeft = this.options.lives || Infinity;\n }\n\n /** Creates a assistant for the transport.\n *\n * @param {Transport} transport\n * @returns {AssistantToTheTransportManager}\n */\n getAssistant(transport: Transport): AssistantToTheTransportManager {\n return Factory.createAssistantToTheTransportManager(this, transport, {\n minPingDelay: this.options.minPingDelay,\n maxPingDelay: this.options.maxPingDelay\n });\n }\n\n /** Returns whether the transport has any lives left.\n *\n * @returns {Boolean}\n */\n isAlive(): boolean {\n return this.livesLeft > 0;\n }\n\n /** Takes one life from the transport. */\n reportDeath() {\n this.livesLeft -= 1;\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport { OneOffTimer as Timer } from '../utils/timers';\nimport Strategy from './strategy';\nimport StrategyOptions from './strategy_options';\n\n/** Loops through strategies with optional timeouts.\n *\n * Options:\n * - loop - whether it should loop through the substrategy list\n * - timeout - initial timeout for a single substrategy\n * - timeoutLimit - maximum timeout\n *\n * @param {Strategy[]} strategies\n * @param {Object} options\n */\nexport default class SequentialStrategy implements Strategy {\n strategies: Strategy[];\n loop: boolean;\n failFast: boolean;\n timeout: number;\n timeoutLimit: number;\n\n constructor(strategies: Strategy[], options: StrategyOptions) {\n this.strategies = strategies;\n this.loop = Boolean(options.loop);\n this.failFast = Boolean(options.failFast);\n this.timeout = options.timeout;\n this.timeoutLimit = options.timeoutLimit;\n }\n\n isSupported(): boolean {\n return Collections.any(this.strategies, Util.method('isSupported'));\n }\n\n connect(minPriority: number, callback: Function) {\n var strategies = this.strategies;\n var current = 0;\n var timeout = this.timeout;\n var runner = null;\n\n var tryNextStrategy = (error, handshake) => {\n if (handshake) {\n callback(null, handshake);\n } else {\n current = current + 1;\n if (this.loop) {\n current = current % strategies.length;\n }\n\n if (current < strategies.length) {\n if (timeout) {\n timeout = timeout * 2;\n if (this.timeoutLimit) {\n timeout = Math.min(timeout, this.timeoutLimit);\n }\n }\n runner = this.tryStrategy(\n strategies[current],\n minPriority,\n { timeout, failFast: this.failFast },\n tryNextStrategy\n );\n } else {\n callback(true);\n }\n }\n };\n\n runner = this.tryStrategy(\n strategies[current],\n minPriority,\n { timeout: timeout, failFast: this.failFast },\n tryNextStrategy\n );\n\n return {\n abort: function() {\n runner.abort();\n },\n forceMinPriority: function(p) {\n minPriority = p;\n if (runner) {\n runner.forceMinPriority(p);\n }\n }\n };\n }\n\n private tryStrategy(\n strategy: Strategy,\n minPriority: number,\n options: StrategyOptions,\n callback: Function\n ) {\n var timer = null;\n var runner = null;\n\n if (options.timeout > 0) {\n timer = new Timer(options.timeout, function() {\n runner.abort();\n callback(true);\n });\n }\n\n runner = strategy.connect(minPriority, function(error, handshake) {\n if (error && timer && timer.isRunning() && !options.failFast) {\n // advance to the next strategy after the timeout\n return;\n }\n if (timer) {\n timer.ensureAborted();\n }\n callback(error, handshake);\n });\n\n return {\n abort: function() {\n if (timer) {\n timer.ensureAborted();\n }\n runner.abort();\n },\n forceMinPriority: function(p) {\n runner.forceMinPriority(p);\n }\n };\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport Strategy from './strategy';\n\n/** Launches all substrategies and emits prioritized connected transports.\n *\n * @param {Array} strategies\n */\nexport default class BestConnectedEverStrategy implements Strategy {\n strategies: Strategy[];\n\n constructor(strategies: Strategy[]) {\n this.strategies = strategies;\n }\n\n isSupported(): boolean {\n return Collections.any(this.strategies, Util.method('isSupported'));\n }\n\n connect(minPriority: number, callback: Function) {\n return connect(this.strategies, minPriority, function(i, runners) {\n return function(error, handshake) {\n runners[i].error = error;\n if (error) {\n if (allRunnersFailed(runners)) {\n callback(true);\n }\n return;\n }\n Collections.apply(runners, function(runner) {\n runner.forceMinPriority(handshake.transport.priority);\n });\n callback(null, handshake);\n };\n });\n }\n}\n\n/** Connects to all strategies in parallel.\n *\n * Callback builder should be a function that takes two arguments: index\n * and a list of runners. It should return another function that will be\n * passed to the substrategy with given index. Runners can be aborted using\n * abortRunner(s) functions from this class.\n *\n * @param {Array} strategies\n * @param {Function} callbackBuilder\n * @return {Object} strategy runner\n */\nfunction connect(\n strategies: Strategy[],\n minPriority: number,\n callbackBuilder: Function\n) {\n var runners = Collections.map(strategies, function(strategy, i, _, rs) {\n return strategy.connect(minPriority, callbackBuilder(i, rs));\n });\n return {\n abort: function() {\n Collections.apply(runners, abortRunner);\n },\n forceMinPriority: function(p) {\n Collections.apply(runners, function(runner) {\n runner.forceMinPriority(p);\n });\n }\n };\n}\n\nfunction allRunnersFailed(runners): boolean {\n return Collections.all(runners, function(runner) {\n return Boolean(runner.error);\n });\n}\n\nfunction abortRunner(runner) {\n if (!runner.error && !runner.aborted) {\n runner.abort();\n runner.aborted = true;\n }\n}\n","import Util from '../util';\nimport Runtime from 'runtime';\nimport Strategy from './strategy';\nimport SequentialStrategy from './sequential_strategy';\nimport StrategyOptions from './strategy_options';\nimport TransportStrategy from './transport_strategy';\nimport Timeline from '../timeline/timeline';\nimport * as Collections from '../utils/collections';\n\nexport interface TransportStrategyDictionary {\n [key: string]: TransportStrategy;\n}\n\n/** Caches the last successful transport and, after the first few attempts,\n * uses the cached transport for subsequent attempts.\n *\n * @param {Strategy} strategy\n * @param {Object} transports\n * @param {Object} options\n */\nexport default class WebSocketPrioritizedCachedStrategy implements Strategy {\n strategy: Strategy;\n transports: TransportStrategyDictionary;\n ttl: number;\n usingTLS: boolean;\n timeline: Timeline;\n\n constructor(\n strategy: Strategy,\n transports: TransportStrategyDictionary,\n options: StrategyOptions\n ) {\n this.strategy = strategy;\n this.transports = transports;\n this.ttl = options.ttl || 1800 * 1000;\n this.usingTLS = options.useTLS;\n this.timeline = options.timeline;\n }\n\n isSupported(): boolean {\n return this.strategy.isSupported();\n }\n\n connect(minPriority: number, callback: Function) {\n var usingTLS = this.usingTLS;\n var info = fetchTransportCache(usingTLS);\n var cacheSkipCount = info && info.cacheSkipCount ? info.cacheSkipCount : 0;\n\n var strategies = [this.strategy];\n if (info && info.timestamp + this.ttl >= Util.now()) {\n var transport = this.transports[info.transport];\n if (transport) {\n if (['ws', 'wss'].includes(info.transport) || cacheSkipCount > 3) {\n this.timeline.info({\n cached: true,\n transport: info.transport,\n latency: info.latency\n });\n strategies.push(\n new SequentialStrategy([transport], {\n timeout: info.latency * 2 + 1000,\n failFast: true\n })\n );\n } else {\n cacheSkipCount++;\n }\n }\n }\n\n var startTimestamp = Util.now();\n var runner = strategies\n .pop()\n .connect(minPriority, function cb(error, handshake) {\n if (error) {\n flushTransportCache(usingTLS);\n if (strategies.length > 0) {\n startTimestamp = Util.now();\n runner = strategies.pop().connect(minPriority, cb);\n } else {\n callback(error);\n }\n } else {\n storeTransportCache(\n usingTLS,\n handshake.transport.name,\n Util.now() - startTimestamp,\n cacheSkipCount\n );\n callback(null, handshake);\n }\n });\n\n return {\n abort: function() {\n runner.abort();\n },\n forceMinPriority: function(p) {\n minPriority = p;\n if (runner) {\n runner.forceMinPriority(p);\n }\n }\n };\n }\n}\n\nfunction getTransportCacheKey(usingTLS: boolean): string {\n return 'pusherTransport' + (usingTLS ? 'TLS' : 'NonTLS');\n}\n\nfunction fetchTransportCache(usingTLS: boolean): any {\n var storage = Runtime.getLocalStorage();\n if (storage) {\n try {\n var serializedCache = storage[getTransportCacheKey(usingTLS)];\n if (serializedCache) {\n return JSON.parse(serializedCache);\n }\n } catch (e) {\n flushTransportCache(usingTLS);\n }\n }\n return null;\n}\n\nfunction storeTransportCache(\n usingTLS: boolean,\n transport: TransportStrategy,\n latency: number,\n cacheSkipCount: number\n) {\n var storage = Runtime.getLocalStorage();\n if (storage) {\n try {\n storage[getTransportCacheKey(usingTLS)] = Collections.safeJSONStringify({\n timestamp: Util.now(),\n transport: transport,\n latency: latency,\n cacheSkipCount: cacheSkipCount\n });\n } catch (e) {\n // catch over quota exceptions raised by localStorage\n }\n }\n}\n\nfunction flushTransportCache(usingTLS: boolean) {\n var storage = Runtime.getLocalStorage();\n if (storage) {\n try {\n delete storage[getTransportCacheKey(usingTLS)];\n } catch (e) {\n // catch exceptions raised by localStorage\n }\n }\n}\n","import { OneOffTimer as Timer } from '../utils/timers';\nimport Strategy from './strategy';\nimport StrategyOptions from './strategy_options';\n\n/** Runs substrategy after specified delay.\n *\n * Options:\n * - delay - time in miliseconds to delay the substrategy attempt\n *\n * @param {Strategy} strategy\n * @param {Object} options\n */\nexport default class DelayedStrategy implements Strategy {\n strategy: Strategy;\n options: { delay: number };\n\n constructor(strategy: Strategy, { delay: number }) {\n this.strategy = strategy;\n this.options = { delay: number };\n }\n\n isSupported(): boolean {\n return this.strategy.isSupported();\n }\n\n connect(minPriority: number, callback: Function) {\n var strategy = this.strategy;\n var runner;\n var timer = new Timer(this.options.delay, function() {\n runner = strategy.connect(minPriority, callback);\n });\n\n return {\n abort: function() {\n timer.ensureAborted();\n if (runner) {\n runner.abort();\n }\n },\n forceMinPriority: function(p) {\n minPriority = p;\n if (runner) {\n runner.forceMinPriority(p);\n }\n }\n };\n }\n}\n","import Strategy from './strategy';\nimport StrategyRunner from './strategy_runner';\n\n/** Proxies method calls to one of substrategies basing on the test function.\n *\n * @param {Function} test\n * @param {Strategy} trueBranch strategy used when test returns true\n * @param {Strategy} falseBranch strategy used when test returns false\n */\nexport default class IfStrategy implements Strategy {\n test: () => boolean;\n trueBranch: Strategy;\n falseBranch: Strategy;\n\n constructor(\n test: () => boolean,\n trueBranch: Strategy,\n falseBranch: Strategy\n ) {\n this.test = test;\n this.trueBranch = trueBranch;\n this.falseBranch = falseBranch;\n }\n\n isSupported(): boolean {\n var branch = this.test() ? this.trueBranch : this.falseBranch;\n return branch.isSupported();\n }\n\n connect(minPriority: number, callback: Function): StrategyRunner {\n var branch = this.test() ? this.trueBranch : this.falseBranch;\n return branch.connect(minPriority, callback);\n }\n}\n","import Strategy from './strategy';\nimport StrategyRunner from './strategy_runner';\n\n/** Launches the substrategy and terminates on the first open connection.\n *\n * @param {Strategy} strategy\n */\nexport default class FirstConnectedStrategy implements Strategy {\n strategy: Strategy;\n\n constructor(strategy: Strategy) {\n this.strategy = strategy;\n }\n\n isSupported(): boolean {\n return this.strategy.isSupported();\n }\n\n connect(minPriority: number, callback: Function): StrategyRunner {\n var runner = this.strategy.connect(minPriority, function(error, handshake) {\n if (handshake) {\n runner.abort();\n }\n callback(error, handshake);\n });\n return runner;\n }\n}\n","import * as Collections from 'core/utils/collections';\nimport TransportManager from 'core/transports/transport_manager';\nimport Strategy from 'core/strategies/strategy';\nimport SequentialStrategy from 'core/strategies/sequential_strategy';\nimport BestConnectedEverStrategy from 'core/strategies/best_connected_ever_strategy';\nimport WebSocketPrioritizedCachedStrategy, {\n TransportStrategyDictionary\n} from 'core/strategies/websocket_prioritized_cached_strategy';\nimport DelayedStrategy from 'core/strategies/delayed_strategy';\nimport IfStrategy from 'core/strategies/if_strategy';\nimport FirstConnectedStrategy from 'core/strategies/first_connected_strategy';\nimport { Config } from 'core/config';\nimport StrategyOptions from 'core/strategies/strategy_options';\n\nfunction testSupportsStrategy(strategy: Strategy) {\n return function() {\n return strategy.isSupported();\n };\n}\n\nvar getDefaultStrategy = function(\n config: Config,\n baseOptions: StrategyOptions,\n defineTransport: Function\n): Strategy {\n var definedTransports = {};\n\n function defineTransportStrategy(\n name: string,\n type: string,\n priority: number,\n options: StrategyOptions,\n manager?: TransportManager\n ) {\n var transport = defineTransport(\n config,\n name,\n type,\n priority,\n options,\n manager\n );\n\n definedTransports[name] = transport;\n\n return transport;\n }\n\n var ws_options: StrategyOptions = Object.assign({}, baseOptions, {\n hostNonTLS: config.wsHost + ':' + config.wsPort,\n hostTLS: config.wsHost + ':' + config.wssPort,\n httpPath: config.wsPath\n });\n var wss_options: StrategyOptions = Collections.extend({}, ws_options, {\n useTLS: true\n });\n var http_options: StrategyOptions = Object.assign({}, baseOptions, {\n hostNonTLS: config.httpHost + ':' + config.httpPort,\n hostTLS: config.httpHost + ':' + config.httpsPort,\n httpPath: config.httpPath\n });\n var timeouts = {\n loop: true,\n timeout: 15000,\n timeoutLimit: 60000\n };\n\n var ws_manager = new TransportManager({\n minPingDelay: 10000,\n maxPingDelay: config.activityTimeout\n });\n var streaming_manager = new TransportManager({\n lives: 2,\n minPingDelay: 10000,\n maxPingDelay: config.activityTimeout\n });\n\n var ws_transport = defineTransportStrategy(\n 'ws',\n 'ws',\n 3,\n ws_options,\n ws_manager\n );\n var wss_transport = defineTransportStrategy(\n 'wss',\n 'ws',\n 3,\n wss_options,\n ws_manager\n );\n var xhr_streaming_transport = defineTransportStrategy(\n 'xhr_streaming',\n 'xhr_streaming',\n 1,\n http_options,\n streaming_manager\n );\n var xhr_polling_transport = defineTransportStrategy(\n 'xhr_polling',\n 'xhr_polling',\n 1,\n http_options\n );\n\n var ws_loop = new SequentialStrategy([ws_transport], timeouts);\n var wss_loop = new SequentialStrategy([wss_transport], timeouts);\n var streaming_loop = new SequentialStrategy(\n [xhr_streaming_transport],\n timeouts\n );\n var polling_loop = new SequentialStrategy([xhr_polling_transport], timeouts);\n\n var http_loop = new SequentialStrategy(\n [\n new IfStrategy(\n testSupportsStrategy(streaming_loop),\n new BestConnectedEverStrategy([\n streaming_loop,\n new DelayedStrategy(polling_loop, { delay: 4000 })\n ]),\n polling_loop\n )\n ],\n timeouts\n );\n\n var wsStrategy;\n if (baseOptions.useTLS) {\n wsStrategy = new BestConnectedEverStrategy([\n ws_loop,\n new DelayedStrategy(http_loop, { delay: 2000 })\n ]);\n } else {\n wsStrategy = new BestConnectedEverStrategy([\n ws_loop,\n new DelayedStrategy(wss_loop, { delay: 2000 }),\n new DelayedStrategy(http_loop, { delay: 5000 })\n ]);\n }\n\n return new WebSocketPrioritizedCachedStrategy(\n new FirstConnectedStrategy(\n new IfStrategy(testSupportsStrategy(ws_transport), wsStrategy, http_loop)\n ),\n definedTransports,\n {\n ttl: 1800000,\n timeline: baseOptions.timeline,\n useTLS: baseOptions.useTLS\n }\n );\n};\n\nexport default getDefaultStrategy;\n","/** Initializes the transport.\n *\n * Fetches resources if needed and then transitions to initialized.\n */\nexport default function() {\n var self = this;\n\n self.timeline.info(\n self.buildTimelineMessage({\n transport: self.name + (self.options.useTLS ? 's' : '')\n })\n );\n\n if (self.hooks.isInitialized()) {\n self.changeState('initialized');\n } else {\n self.onClose();\n }\n}\n","import Runtime from 'runtime';\nimport RequestHooks from './request_hooks';\nimport Ajax from './ajax';\nimport { default as EventsDispatcher } from '../events/dispatcher';\n\nconst MAX_BUFFER_LENGTH = 256 * 1024;\n\nexport default class HTTPRequest extends EventsDispatcher {\n hooks: RequestHooks;\n method: string;\n url: string;\n position: number;\n xhr: Ajax;\n unloader: Function;\n\n constructor(hooks: RequestHooks, method: string, url: string) {\n super();\n this.hooks = hooks;\n this.method = method;\n this.url = url;\n }\n\n start(payload?: any) {\n this.position = 0;\n this.xhr = this.hooks.getRequest(this);\n\n this.unloader = () => {\n this.close();\n };\n Runtime.addUnloadListener(this.unloader);\n\n this.xhr.open(this.method, this.url, true);\n\n if (this.xhr.setRequestHeader) {\n this.xhr.setRequestHeader('Content-Type', 'application/json'); // ReactNative doesn't set this header by default.\n }\n this.xhr.send(payload);\n }\n\n close() {\n if (this.unloader) {\n Runtime.removeUnloadListener(this.unloader);\n this.unloader = null;\n }\n if (this.xhr) {\n this.hooks.abortRequest(this.xhr);\n this.xhr = null;\n }\n }\n\n onChunk(status: number, data: any) {\n while (true) {\n var chunk = this.advanceBuffer(data);\n if (chunk) {\n this.emit('chunk', { status: status, data: chunk });\n } else {\n break;\n }\n }\n if (this.isBufferTooLong(data)) {\n this.emit('buffer_too_long');\n }\n }\n\n private advanceBuffer(buffer: any[]): any {\n var unreadData = buffer.slice(this.position);\n var endOfLinePosition = unreadData.indexOf('\\n');\n\n if (endOfLinePosition !== -1) {\n this.position += endOfLinePosition + 1;\n return unreadData.slice(0, endOfLinePosition);\n } else {\n // chunk is not finished yet, don't move the buffer pointer\n return null;\n }\n }\n\n private isBufferTooLong(buffer: any): boolean {\n return this.position === buffer.length && buffer.length > MAX_BUFFER_LENGTH;\n }\n}\n","enum State {\n CONNECTING = 0,\n OPEN = 1,\n CLOSED = 3\n}\n\nexport default State;\n","import URLLocation from './url_location';\nimport State from './state';\nimport Socket from '../socket';\nimport SocketHooks from './socket_hooks';\nimport Util from '../util';\nimport Ajax from './ajax';\nimport HTTPRequest from './http_request';\nimport Runtime from 'runtime';\n\nvar autoIncrement = 1;\n\nclass HTTPSocket implements Socket {\n hooks: SocketHooks;\n session: string;\n location: URLLocation;\n readyState: State;\n stream: HTTPRequest;\n\n onopen: () => void;\n onerror: (error: any) => void;\n onclose: (closeEvent: any) => void;\n onmessage: (message: any) => void;\n onactivity: () => void;\n\n constructor(hooks: SocketHooks, url: string) {\n this.hooks = hooks;\n this.session = randomNumber(1000) + '/' + randomString(8);\n this.location = getLocation(url);\n this.readyState = State.CONNECTING;\n this.openStream();\n }\n\n send(payload: any) {\n return this.sendRaw(JSON.stringify([payload]));\n }\n\n ping() {\n this.hooks.sendHeartbeat(this);\n }\n\n close(code: any, reason: any) {\n this.onClose(code, reason, true);\n }\n\n /** For internal use only */\n sendRaw(payload: any): boolean {\n if (this.readyState === State.OPEN) {\n try {\n Runtime.createSocketRequest(\n 'POST',\n getUniqueURL(getSendURL(this.location, this.session))\n ).start(payload);\n return true;\n } catch (e) {\n return false;\n }\n } else {\n return false;\n }\n }\n\n /** For internal use only */\n reconnect() {\n this.closeStream();\n this.openStream();\n }\n\n /** For internal use only */\n onClose(code, reason, wasClean) {\n this.closeStream();\n this.readyState = State.CLOSED;\n if (this.onclose) {\n this.onclose({\n code: code,\n reason: reason,\n wasClean: wasClean\n });\n }\n }\n\n private onChunk(chunk) {\n if (chunk.status !== 200) {\n return;\n }\n if (this.readyState === State.OPEN) {\n this.onActivity();\n }\n\n var payload;\n var type = chunk.data.slice(0, 1);\n switch (type) {\n case 'o':\n payload = JSON.parse(chunk.data.slice(1) || '{}');\n this.onOpen(payload);\n break;\n case 'a':\n payload = JSON.parse(chunk.data.slice(1) || '[]');\n for (var i = 0; i < payload.length; i++) {\n this.onEvent(payload[i]);\n }\n break;\n case 'm':\n payload = JSON.parse(chunk.data.slice(1) || 'null');\n this.onEvent(payload);\n break;\n case 'h':\n this.hooks.onHeartbeat(this);\n break;\n case 'c':\n payload = JSON.parse(chunk.data.slice(1) || '[]');\n this.onClose(payload[0], payload[1], true);\n break;\n }\n }\n\n private onOpen(options) {\n if (this.readyState === State.CONNECTING) {\n if (options && options.hostname) {\n this.location.base = replaceHost(this.location.base, options.hostname);\n }\n this.readyState = State.OPEN;\n\n if (this.onopen) {\n this.onopen();\n }\n } else {\n this.onClose(1006, 'Server lost session', true);\n }\n }\n\n private onEvent(event) {\n if (this.readyState === State.OPEN && this.onmessage) {\n this.onmessage({ data: event });\n }\n }\n\n private onActivity() {\n if (this.onactivity) {\n this.onactivity();\n }\n }\n\n private onError(error) {\n if (this.onerror) {\n this.onerror(error);\n }\n }\n\n private openStream() {\n this.stream = Runtime.createSocketRequest(\n 'POST',\n getUniqueURL(this.hooks.getReceiveURL(this.location, this.session))\n );\n\n this.stream.bind('chunk', chunk => {\n this.onChunk(chunk);\n });\n this.stream.bind('finished', status => {\n this.hooks.onFinished(this, status);\n });\n this.stream.bind('buffer_too_long', () => {\n this.reconnect();\n });\n\n try {\n this.stream.start();\n } catch (error) {\n Util.defer(() => {\n this.onError(error);\n this.onClose(1006, 'Could not start streaming', false);\n });\n }\n }\n\n private closeStream() {\n if (this.stream) {\n this.stream.unbind_all();\n this.stream.close();\n this.stream = null;\n }\n }\n}\n\nfunction getLocation(url): URLLocation {\n var parts = /([^\\?]*)\\/*(\\??.*)/.exec(url);\n return {\n base: parts[1],\n queryString: parts[2]\n };\n}\n\nfunction getSendURL(url: URLLocation, session: string): string {\n return url.base + '/' + session + '/xhr_send';\n}\n\nfunction getUniqueURL(url: string): string {\n var separator = url.indexOf('?') === -1 ? '?' : '&';\n return url + separator + 't=' + +new Date() + '&n=' + autoIncrement++;\n}\n\nfunction replaceHost(url: string, hostname: string): string {\n var urlParts = /(https?:\\/\\/)([^\\/:]+)((\\/|:)?.*)/.exec(url);\n return urlParts[1] + hostname + urlParts[3];\n}\n\nfunction randomNumber(max: number): number {\n return Runtime.randomInt(max);\n}\n\nfunction randomString(length: number): string {\n var result = [];\n\n for (var i = 0; i < length; i++) {\n result.push(randomNumber(32).toString(32));\n }\n\n return result.join('');\n}\n\nexport default HTTPSocket;\n","import SocketHooks from './socket_hooks';\nimport HTTPSocket from './http_socket';\n\nvar hooks: SocketHooks = {\n getReceiveURL: function(url, session) {\n return url.base + '/' + session + '/xhr_streaming' + url.queryString;\n },\n onHeartbeat: function(socket) {\n socket.sendRaw('[]');\n },\n sendHeartbeat: function(socket) {\n socket.sendRaw('[]');\n },\n onFinished: function(socket, status) {\n socket.onClose(1006, 'Connection interrupted (' + status + ')', false);\n }\n};\n\nexport default hooks;\n","import SocketHooks from './socket_hooks';\nimport URLLocation from './url_location';\nimport HTTPSocket from './http_socket';\n\nvar hooks: SocketHooks = {\n getReceiveURL: function(url: URLLocation, session: string): string {\n return url.base + '/' + session + '/xhr' + url.queryString;\n },\n onHeartbeat: function() {\n // next HTTP request will reset server's activity timer\n },\n sendHeartbeat: function(socket) {\n socket.sendRaw('[]');\n },\n onFinished: function(socket, status) {\n if (status === 200) {\n socket.reconnect();\n } else {\n socket.onClose(1006, 'Connection interrupted (' + status + ')', false);\n }\n }\n};\n\nexport default hooks;\n","import HTTPRequest from 'core/http/http_request';\nimport RequestHooks from 'core/http/request_hooks';\nimport Ajax from 'core/http/ajax';\nimport Runtime from 'runtime';\n\nvar hooks: RequestHooks = {\n getRequest: function(socket: HTTPRequest): Ajax {\n var Constructor = Runtime.getXHRAPI();\n var xhr = new Constructor();\n xhr.onreadystatechange = xhr.onprogress = function() {\n switch (xhr.readyState) {\n case 3:\n if (xhr.responseText && xhr.responseText.length > 0) {\n socket.onChunk(xhr.status, xhr.responseText);\n }\n break;\n case 4:\n // this happens only on errors, never after calling close\n if (xhr.responseText && xhr.responseText.length > 0) {\n socket.onChunk(xhr.status, xhr.responseText);\n }\n socket.emit('finished', xhr.status);\n socket.close();\n break;\n }\n };\n return xhr;\n },\n abortRequest: function(xhr: Ajax) {\n xhr.onreadystatechange = null;\n xhr.abort();\n }\n};\n\nexport default hooks;\n","import HTTPRequest from 'core/http/http_request';\nimport HTTPSocket from 'core/http/http_socket';\nimport SocketHooks from 'core/http/socket_hooks';\nimport RequestHooks from 'core/http/request_hooks';\nimport streamingHooks from 'core/http/http_streaming_socket';\nimport pollingHooks from 'core/http/http_polling_socket';\nimport xhrHooks from './http_xhr_request';\nimport HTTPFactory from 'core/http/http_factory';\n\nvar HTTP: HTTPFactory = {\n createStreamingSocket(url: string): HTTPSocket {\n return this.createSocket(streamingHooks, url);\n },\n\n createPollingSocket(url: string): HTTPSocket {\n return this.createSocket(pollingHooks, url);\n },\n\n createSocket(hooks: SocketHooks, url: string): HTTPSocket {\n return new HTTPSocket(hooks, url);\n },\n\n createXHR(method: string, url: string): HTTPRequest {\n return this.createRequest(xhrHooks, method, url);\n },\n\n createRequest(hooks: RequestHooks, method: string, url: string): HTTPRequest {\n return new HTTPRequest(hooks, method, url);\n }\n};\n\nexport default HTTP;\n","import * as Collections from 'core/utils/collections';\nimport Transports from 'isomorphic/transports/transports';\nimport TimelineSender from 'core/timeline/timeline_sender';\nimport Ajax from 'core/http/ajax';\nimport getDefaultStrategy from './default_strategy';\nimport TransportsTable from 'core/transports/transports_table';\nimport transportConnectionInitializer from './transports/transport_connection_initializer';\nimport HTTPFactory from './http/http';\n\nvar Isomorphic: any = {\n getDefaultStrategy,\n Transports: Transports,\n transportConnectionInitializer,\n HTTPFactory,\n\n setup(PusherClass): void {\n PusherClass.ready();\n },\n\n getLocalStorage(): any {\n return undefined;\n },\n\n getClientFeatures(): any[] {\n return Collections.keys(\n Collections.filterObject({ ws: Transports.ws }, function(t) {\n return t.isSupported({});\n })\n );\n },\n\n getProtocol(): string {\n return 'http:';\n },\n\n isXHRSupported(): boolean {\n return true;\n },\n\n createSocketRequest(method: string, url: string) {\n if (this.isXHRSupported()) {\n return this.HTTPFactory.createXHR(method, url);\n } else {\n throw 'Cross-origin HTTP requests are not supported';\n }\n },\n\n createXHR(): Ajax {\n var Constructor = this.getXHRAPI();\n return new Constructor();\n },\n\n createWebSocket(url: string): any {\n var Constructor = this.getWebSocketAPI();\n return new Constructor(url);\n },\n\n addUnloadListener(listener: any) {},\n removeUnloadListener(listener: any) {}\n};\n\nexport default Isomorphic;\n","import { default as EventsDispatcher } from 'core/events/dispatcher';\nimport Reachability from 'core/reachability';\n\nexport class NetInfo extends EventsDispatcher implements Reachability {\n isOnline(): boolean {\n return true;\n }\n}\n\nexport var Network = new NetInfo();\n","import AbstractRuntime from 'runtimes/interface';\nimport { AuthTransport } from 'core/auth/auth_transports';\nimport {\n AuthRequestType,\n AuthTransportCallback,\n InternalAuthOptions\n} from 'core/auth/options';\nimport { HTTPAuthError } from 'core/errors';\n\nvar fetchAuth: AuthTransport = function(\n context: AbstractRuntime,\n query: string,\n authOptions: InternalAuthOptions,\n authRequestType: AuthRequestType,\n callback: AuthTransportCallback\n) {\n var headers = new Headers();\n headers.set('Content-Type', 'application/x-www-form-urlencoded');\n\n for (var headerName in authOptions.headers) {\n headers.set(headerName, authOptions.headers[headerName]);\n }\n\n if (authOptions.headersProvider != null) {\n const dynamicHeaders = authOptions.headersProvider();\n for (var headerName in dynamicHeaders) {\n headers.set(headerName, dynamicHeaders[headerName]);\n }\n }\n\n var body = query;\n var request = new Request(authOptions.endpoint, {\n headers,\n body,\n credentials: 'same-origin',\n method: 'POST'\n });\n\n return fetch(request)\n .then(response => {\n let { status } = response;\n if (status === 200) {\n // manually parse the json so we can provide a more helpful error in\n // failure case\n return response.text();\n }\n throw new HTTPAuthError(\n status,\n `Could not get ${authRequestType.toString()} info from your auth endpoint, status: ${status}`\n );\n })\n .then(data => {\n let parsedData;\n try {\n parsedData = JSON.parse(data);\n } catch (e) {\n throw new HTTPAuthError(\n 200,\n `JSON returned from ${authRequestType.toString()} endpoint was invalid, yet status code was 200. Data was: ${data}`\n );\n }\n callback(null, parsedData);\n })\n .catch(err => {\n callback(err, null);\n });\n};\n\nexport default fetchAuth;\n","import Logger from 'core/logger';\nimport TimelineSender from 'core/timeline/timeline_sender';\nimport * as Collections from 'core/utils/collections';\nimport Util from 'core/util';\nimport Runtime from 'runtime';\nimport TimelineTransport from 'core/timeline/timeline_transport';\n\nvar getAgent = function(sender: TimelineSender, useTLS: boolean) {\n return function(data: any, callback: Function) {\n var scheme = 'http' + (useTLS ? 's' : '') + '://';\n var url =\n scheme + (sender.host || sender.options.host) + sender.options.path;\n var query = Collections.buildQueryString(data);\n url += '/' + 2 + '?' + query;\n\n fetch(url)\n .then(response => {\n if (response.status !== 200) {\n throw `received ${response.status} from stats.pusher.com`;\n }\n return response.json();\n })\n .then(({ host }) => {\n if (host) {\n sender.host = host;\n }\n })\n .catch(err => {\n Logger.debug('TimelineSender Error: ', err);\n });\n };\n};\n\nvar fetchTimeline = {\n name: 'xhr',\n getAgent\n};\n\nexport default fetchTimeline;\n","import Isomorphic from 'isomorphic/runtime';\nimport Runtime from '../interface';\nimport { Network } from './net_info';\nimport fetchAuth from './auth/fetch_auth';\nimport { AuthTransports } from 'core/auth/auth_transports';\nimport fetchTimeline from './timeline/fetch_timeline';\n\n// Very verbose but until unavoidable until\n// TypeScript 2.1, when spread attributes will be\n// supported\nconst {\n getDefaultStrategy,\n Transports,\n setup,\n getProtocol,\n isXHRSupported,\n getLocalStorage,\n createXHR,\n createWebSocket,\n addUnloadListener,\n removeUnloadListener,\n transportConnectionInitializer,\n createSocketRequest,\n HTTPFactory\n} = Isomorphic;\n\nconst Worker: Runtime = {\n getDefaultStrategy,\n Transports,\n setup,\n getProtocol,\n isXHRSupported,\n getLocalStorage,\n createXHR,\n createWebSocket,\n addUnloadListener,\n removeUnloadListener,\n transportConnectionInitializer,\n createSocketRequest,\n HTTPFactory,\n\n TimelineTransport: fetchTimeline,\n\n getAuthorizers(): AuthTransports {\n return { ajax: fetchAuth };\n },\n\n getWebSocketAPI() {\n return WebSocket;\n },\n\n getXHRAPI() {\n return XMLHttpRequest;\n },\n\n getNetwork() {\n return Network;\n },\n\n randomInt(max: number): number {\n /**\n * Return values in the range of [0, 1[\n */\n const random = function() {\n const crypto = globalThis.crypto || globalThis['msCrypto'];\n const random = crypto.getRandomValues(new Uint32Array(1))[0];\n\n return random / 2 ** 32;\n };\n\n return Math.floor(random() * max);\n }\n};\n\nexport default Worker;\n","enum TimelineLevel {\n ERROR = 3,\n INFO = 6,\n DEBUG = 7\n}\n\nexport default TimelineLevel;\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport { default as Level } from './level';\n\nexport interface TimelineOptions {\n level?: Level;\n limit?: number;\n version?: string;\n cluster?: string;\n features?: string[];\n params?: any;\n}\n\nexport default class Timeline {\n key: string;\n session: number;\n events: any[];\n options: TimelineOptions;\n sent: number;\n uniqueID: number;\n\n constructor(key: string, session: number, options: TimelineOptions) {\n this.key = key;\n this.session = session;\n this.events = [];\n this.options = options || {};\n this.sent = 0;\n this.uniqueID = 0;\n }\n\n log(level, event) {\n if (level <= this.options.level) {\n this.events.push(\n Collections.extend({}, event, { timestamp: Util.now() })\n );\n if (this.options.limit && this.events.length > this.options.limit) {\n this.events.shift();\n }\n }\n }\n\n error(event) {\n this.log(Level.ERROR, event);\n }\n\n info(event) {\n this.log(Level.INFO, event);\n }\n\n debug(event) {\n this.log(Level.DEBUG, event);\n }\n\n isEmpty() {\n return this.events.length === 0;\n }\n\n send(sendfn, callback) {\n var data = Collections.extend(\n {\n session: this.session,\n bundle: this.sent + 1,\n key: this.key,\n lib: 'js',\n version: this.options.version,\n cluster: this.options.cluster,\n features: this.options.features,\n timeline: this.events\n },\n this.options.params\n );\n\n this.events = [];\n sendfn(data, (error, result) => {\n if (!error) {\n this.sent++;\n }\n if (callback) {\n callback(error, result);\n }\n });\n\n return true;\n }\n\n generateUniqueID(): number {\n this.uniqueID++;\n return this.uniqueID;\n }\n}\n","import Factory from '../utils/factory';\nimport Util from '../util';\nimport * as Errors from '../errors';\nimport * as Collections from '../utils/collections';\nimport Strategy from './strategy';\nimport Transport from '../transports/transport';\nimport StrategyOptions from './strategy_options';\nimport Handshake from '../connection/handshake';\n\n/** Provides a strategy interface for transports.\n *\n * @param {String} name\n * @param {Number} priority\n * @param {Class} transport\n * @param {Object} options\n */\nexport default class TransportStrategy implements Strategy {\n name: string;\n priority: number;\n transport: Transport;\n options: StrategyOptions;\n\n constructor(\n name: string,\n priority: number,\n transport: Transport,\n options: StrategyOptions\n ) {\n this.name = name;\n this.priority = priority;\n this.transport = transport;\n this.options = options || {};\n }\n\n /** Returns whether the transport is supported in the browser.\n *\n * @returns {Boolean}\n */\n isSupported(): boolean {\n return this.transport.isSupported({\n useTLS: this.options.useTLS\n });\n }\n\n /** Launches a connection attempt and returns a strategy runner.\n *\n * @param {Function} callback\n * @return {Object} strategy runner\n */\n connect(minPriority: number, callback: Function) {\n if (!this.isSupported()) {\n return failAttempt(new Errors.UnsupportedStrategy(), callback);\n } else if (this.priority < minPriority) {\n return failAttempt(new Errors.TransportPriorityTooLow(), callback);\n }\n\n var connected = false;\n var transport = this.transport.createConnection(\n this.name,\n this.priority,\n this.options.key,\n this.options\n );\n var handshake = null;\n\n var onInitialized = function() {\n transport.unbind('initialized', onInitialized);\n transport.connect();\n };\n var onOpen = function() {\n handshake = Factory.createHandshake(transport, function(result) {\n connected = true;\n unbindListeners();\n callback(null, result);\n });\n };\n var onError = function(error) {\n unbindListeners();\n callback(error);\n };\n var onClosed = function() {\n unbindListeners();\n var serializedTransport;\n\n // The reason for this try/catch block is that on React Native\n // the WebSocket object is circular. Therefore transport.socket will\n // throw errors upon stringification. Collections.safeJSONStringify\n // discards circular references when serializing.\n serializedTransport = Collections.safeJSONStringify(transport);\n callback(new Errors.TransportClosed(serializedTransport));\n };\n\n var unbindListeners = function() {\n transport.unbind('initialized', onInitialized);\n transport.unbind('open', onOpen);\n transport.unbind('error', onError);\n transport.unbind('closed', onClosed);\n };\n\n transport.bind('initialized', onInitialized);\n transport.bind('open', onOpen);\n transport.bind('error', onError);\n transport.bind('closed', onClosed);\n\n // connect will be called automatically after initialization\n transport.initialize();\n\n return {\n abort: () => {\n if (connected) {\n return;\n }\n unbindListeners();\n if (handshake) {\n handshake.close();\n } else {\n transport.close();\n }\n },\n forceMinPriority: p => {\n if (connected) {\n return;\n }\n if (this.priority < p) {\n if (handshake) {\n handshake.close();\n } else {\n transport.close();\n }\n }\n }\n };\n }\n}\n\nfunction failAttempt(error: Error, callback: Function) {\n Util.defer(function() {\n callback(error);\n });\n return {\n abort: function() {},\n forceMinPriority: function() {}\n };\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport TransportManager from '../transports/transport_manager';\nimport * as Errors from '../errors';\nimport Strategy from './strategy';\nimport TransportStrategy from './transport_strategy';\nimport StrategyOptions from '../strategies/strategy_options';\nimport { Config } from '../config';\nimport Runtime from 'runtime';\n\nconst { Transports } = Runtime;\n\nexport var defineTransport = function(\n config: Config,\n name: string,\n type: string,\n priority: number,\n options: StrategyOptions,\n manager?: TransportManager\n): Strategy {\n var transportClass = Transports[type];\n if (!transportClass) {\n throw new Errors.UnsupportedTransport(type);\n }\n\n var enabled =\n (!config.enabledTransports ||\n Collections.arrayIndexOf(config.enabledTransports, name) !== -1) &&\n (!config.disabledTransports ||\n Collections.arrayIndexOf(config.disabledTransports, name) === -1);\n\n var transport;\n if (enabled) {\n options = Object.assign(\n { ignoreNullOrigin: config.ignoreNullOrigin },\n options\n );\n\n transport = new TransportStrategy(\n name,\n priority,\n manager ? manager.getAssistant(transportClass) : transportClass,\n options\n );\n } else {\n transport = UnsupportedStrategy;\n }\n\n return transport;\n};\n\nvar UnsupportedStrategy: Strategy = {\n isSupported: function() {\n return false;\n },\n connect: function(_, callback) {\n var deferred = Util.defer(function() {\n callback(new Errors.UnsupportedStrategy());\n });\n return {\n abort: function() {\n deferred.ensureAborted();\n },\n forceMinPriority: function() {}\n };\n }\n};\n","import ConnectionManager from './connection/connection_manager';\nimport {\n ChannelAuthorizationOptions,\n UserAuthenticationOptions\n} from './auth/options';\nimport {\n ChannelAuthorizerGenerator,\n DeprecatedAuthOptions\n} from './auth/deprecated_channel_authorizer';\nimport { AuthTransport, Transport } from './config';\nimport * as nacl from 'tweetnacl';\nimport Logger from './logger';\n\nexport interface Options {\n activityTimeout?: number;\n\n auth?: DeprecatedAuthOptions; // DEPRECATED use channelAuthorization instead\n authEndpoint?: string; // DEPRECATED use channelAuthorization instead\n authTransport?: AuthTransport; // DEPRECATED use channelAuthorization instead\n authorizer?: ChannelAuthorizerGenerator; // DEPRECATED use channelAuthorization instead\n\n channelAuthorization?: ChannelAuthorizationOptions;\n userAuthentication?: UserAuthenticationOptions;\n\n cluster: string;\n enableStats?: boolean;\n disableStats?: boolean;\n disabledTransports?: Transport[];\n enabledTransports?: Transport[];\n forceTLS?: boolean;\n httpHost?: string;\n httpPath?: string;\n httpPort?: number;\n httpsPort?: number;\n ignoreNullOrigin?: boolean;\n nacl?: nacl;\n pongTimeout?: number;\n statsHost?: string;\n timelineParams?: any;\n unavailableTimeout?: number;\n wsHost?: string;\n wsPath?: string;\n wsPort?: number;\n wssPort?: number;\n}\n\nexport interface ClusterOptions {\n appKey: string;\n cluster: string;\n}\n\nexport function validateOptions(options) {\n if (options == null) {\n throw 'You must pass an options object';\n }\n if (options.cluster == null) {\n throw 'Options object must provide a cluster';\n }\n if ('disableStats' in options) {\n Logger.warn(\n 'The disableStats option is deprecated in favor of enableStats'\n );\n }\n}\n","export enum AuthRequestType {\n UserAuthentication = 'user-authentication',\n ChannelAuthorization = 'channel-authorization'\n}\n\nexport interface ChannelAuthorizationData {\n auth: string;\n channel_data?: string;\n shared_secret?: string;\n}\n\nexport type ChannelAuthorizationCallback = (\n error: Error | null,\n authData: ChannelAuthorizationData | null\n) => void;\n\nexport interface ChannelAuthorizationRequestParams {\n socketId: string;\n channelName: string;\n}\n\nexport interface ChannelAuthorizationHandler {\n (\n params: ChannelAuthorizationRequestParams,\n callback: ChannelAuthorizationCallback\n ): void;\n}\n\nexport interface UserAuthenticationData {\n auth: string;\n user_data: string;\n}\n\nexport type UserAuthenticationCallback = (\n error: Error | null,\n authData: UserAuthenticationData | null\n) => void;\n\nexport interface UserAuthenticationRequestParams {\n socketId: string;\n}\n\nexport interface UserAuthenticationHandler {\n (\n params: UserAuthenticationRequestParams,\n callback: UserAuthenticationCallback\n ): void;\n}\n\nexport type AuthTransportCallback =\n | ChannelAuthorizationCallback\n | UserAuthenticationCallback;\n\nexport interface InternalAuthOptions {\n transport: 'ajax' | 'jsonp';\n endpoint: string;\n params?: any;\n headers?: any;\n paramsProvider?: () => any;\n headersProvider?: () => any;\n}\n\nexport type CustomAuthOptions = {\n customHandler: AuthHandler;\n};\n\nexport type AuthOptionsT =\n | InternalAuthOptions\n | CustomAuthOptions;\n\nexport declare type UserAuthenticationOptions = AuthOptionsT<\n UserAuthenticationHandler\n>;\nexport declare type ChannelAuthorizationOptions = AuthOptionsT<\n ChannelAuthorizationHandler\n>;\n","import {\n UserAuthenticationCallback,\n InternalAuthOptions,\n UserAuthenticationHandler,\n UserAuthenticationRequestParams,\n AuthRequestType\n} from './options';\n\nimport Runtime from 'runtime';\n\nconst composeChannelQuery = (\n params: UserAuthenticationRequestParams,\n authOptions: InternalAuthOptions\n) => {\n var query = 'socket_id=' + encodeURIComponent(params.socketId);\n\n for (var key in authOptions.params) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(authOptions.params[key]);\n }\n\n if (authOptions.paramsProvider != null) {\n let dynamicParams = authOptions.paramsProvider();\n for (var key in dynamicParams) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(dynamicParams[key]);\n }\n }\n\n return query;\n};\n\nconst UserAuthenticator = (\n authOptions: InternalAuthOptions\n): UserAuthenticationHandler => {\n if (typeof Runtime.getAuthorizers()[authOptions.transport] === 'undefined') {\n throw `'${authOptions.transport}' is not a recognized auth transport`;\n }\n\n return (\n params: UserAuthenticationRequestParams,\n callback: UserAuthenticationCallback\n ) => {\n const query = composeChannelQuery(params, authOptions);\n\n Runtime.getAuthorizers()[authOptions.transport](\n Runtime,\n query,\n authOptions,\n AuthRequestType.UserAuthentication,\n callback\n );\n };\n};\n\nexport default UserAuthenticator;\n","import {\n AuthRequestType,\n InternalAuthOptions,\n ChannelAuthorizationHandler,\n ChannelAuthorizationRequestParams,\n ChannelAuthorizationCallback\n} from './options';\n\nimport Runtime from 'runtime';\n\nconst composeChannelQuery = (\n params: ChannelAuthorizationRequestParams,\n authOptions: InternalAuthOptions\n) => {\n var query = 'socket_id=' + encodeURIComponent(params.socketId);\n\n query += '&channel_name=' + encodeURIComponent(params.channelName);\n\n for (var key in authOptions.params) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(authOptions.params[key]);\n }\n\n if (authOptions.paramsProvider != null) {\n let dynamicParams = authOptions.paramsProvider();\n for (var key in dynamicParams) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(dynamicParams[key]);\n }\n }\n\n return query;\n};\n\nconst ChannelAuthorizer = (\n authOptions: InternalAuthOptions\n): ChannelAuthorizationHandler => {\n if (typeof Runtime.getAuthorizers()[authOptions.transport] === 'undefined') {\n throw `'${authOptions.transport}' is not a recognized auth transport`;\n }\n\n return (\n params: ChannelAuthorizationRequestParams,\n callback: ChannelAuthorizationCallback\n ) => {\n const query = composeChannelQuery(params, authOptions);\n\n Runtime.getAuthorizers()[authOptions.transport](\n Runtime,\n query,\n authOptions,\n AuthRequestType.ChannelAuthorization,\n callback\n );\n };\n};\n\nexport default ChannelAuthorizer;\n","import Channel from '../channels/channel';\nimport {\n ChannelAuthorizationCallback,\n ChannelAuthorizationHandler,\n ChannelAuthorizationRequestParams,\n InternalAuthOptions\n} from './options';\n\nexport interface DeprecatedChannelAuthorizer {\n authorize(socketId: string, callback: ChannelAuthorizationCallback): void;\n}\n\nexport interface ChannelAuthorizerGenerator {\n (\n channel: Channel,\n options: DeprecatedAuthorizerOptions\n ): DeprecatedChannelAuthorizer;\n}\n\nexport interface DeprecatedAuthOptions {\n params?: any;\n headers?: any;\n}\n\nexport interface DeprecatedAuthorizerOptions {\n authTransport: 'ajax' | 'jsonp';\n authEndpoint: string;\n auth?: DeprecatedAuthOptions;\n}\n\nexport const ChannelAuthorizerProxy = (\n pusher,\n authOptions: InternalAuthOptions,\n channelAuthorizerGenerator: ChannelAuthorizerGenerator\n): ChannelAuthorizationHandler => {\n const deprecatedAuthorizerOptions: DeprecatedAuthorizerOptions = {\n authTransport: authOptions.transport,\n authEndpoint: authOptions.endpoint,\n auth: {\n params: authOptions.params,\n headers: authOptions.headers\n }\n };\n return (\n params: ChannelAuthorizationRequestParams,\n callback: ChannelAuthorizationCallback\n ) => {\n const channel = pusher.channel(params.channelName);\n // This line creates a new channel authorizer every time.\n // In the past, this was only done once per channel and reused.\n // We can do that again if we want to keep this behavior intact.\n const channelAuthorizer: DeprecatedChannelAuthorizer = channelAuthorizerGenerator(\n channel,\n deprecatedAuthorizerOptions\n );\n channelAuthorizer.authorize(params.socketId, callback);\n };\n};\n","import { Options } from './options';\nimport Defaults from './defaults';\nimport {\n ChannelAuthorizationHandler,\n UserAuthenticationHandler,\n ChannelAuthorizationOptions,\n AuthOptionsT,\n CustomAuthOptions\n} from './auth/options';\nimport UserAuthenticator from './auth/user_authenticator';\nimport ChannelAuthorizer from './auth/channel_authorizer';\nimport { ChannelAuthorizerProxy } from './auth/deprecated_channel_authorizer';\nimport Runtime from 'runtime';\nimport * as nacl from 'tweetnacl';\n\nexport type AuthTransport = 'ajax' | 'jsonp';\nexport type Transport =\n | 'ws'\n | 'wss'\n | 'xhr_streaming'\n | 'xhr_polling'\n | 'sockjs';\n\nexport interface Config {\n // these are all 'required' config parameters, it's not necessary for the user\n // to set them, but they have configured defaults.\n activityTimeout: number;\n enableStats: boolean;\n httpHost: string;\n httpPath: string;\n httpPort: number;\n httpsPort: number;\n pongTimeout: number;\n statsHost: string;\n unavailableTimeout: number;\n useTLS: boolean;\n wsHost: string;\n wsPath: string;\n wsPort: number;\n wssPort: number;\n userAuthenticator: UserAuthenticationHandler;\n channelAuthorizer: ChannelAuthorizationHandler;\n\n // these are all optional parameters or overrrides. The customer can set these\n // but it's not strictly necessary\n forceTLS?: boolean;\n cluster?: string;\n disabledTransports?: Transport[];\n enabledTransports?: Transport[];\n ignoreNullOrigin?: boolean;\n nacl?: nacl;\n timelineParams?: any;\n}\n\n// getConfig mainly sets the defaults for the options that are not provided\nexport function getConfig(opts: Options, pusher): Config {\n let config: Config = {\n activityTimeout: opts.activityTimeout || Defaults.activityTimeout,\n cluster: opts.cluster,\n httpPath: opts.httpPath || Defaults.httpPath,\n httpPort: opts.httpPort || Defaults.httpPort,\n httpsPort: opts.httpsPort || Defaults.httpsPort,\n pongTimeout: opts.pongTimeout || Defaults.pongTimeout,\n statsHost: opts.statsHost || Defaults.stats_host,\n unavailableTimeout: opts.unavailableTimeout || Defaults.unavailableTimeout,\n wsPath: opts.wsPath || Defaults.wsPath,\n wsPort: opts.wsPort || Defaults.wsPort,\n wssPort: opts.wssPort || Defaults.wssPort,\n\n enableStats: getEnableStatsConfig(opts),\n httpHost: getHttpHost(opts),\n useTLS: shouldUseTLS(opts),\n wsHost: getWebsocketHost(opts),\n\n userAuthenticator: buildUserAuthenticator(opts),\n channelAuthorizer: buildChannelAuthorizer(opts, pusher)\n };\n\n if ('disabledTransports' in opts)\n config.disabledTransports = opts.disabledTransports;\n if ('enabledTransports' in opts)\n config.enabledTransports = opts.enabledTransports;\n if ('ignoreNullOrigin' in opts)\n config.ignoreNullOrigin = opts.ignoreNullOrigin;\n if ('timelineParams' in opts) config.timelineParams = opts.timelineParams;\n if ('nacl' in opts) {\n config.nacl = opts.nacl;\n }\n\n return config;\n}\n\nfunction getHttpHost(opts: Options): string {\n if (opts.httpHost) {\n return opts.httpHost;\n }\n if (opts.cluster) {\n return `sockjs-${opts.cluster}.pusher.com`;\n }\n return Defaults.httpHost;\n}\n\nfunction getWebsocketHost(opts: Options): string {\n if (opts.wsHost) {\n return opts.wsHost;\n }\n return getWebsocketHostFromCluster(opts.cluster);\n}\n\nfunction getWebsocketHostFromCluster(cluster: string): string {\n return `ws-${cluster}.pusher.com`;\n}\n\nfunction shouldUseTLS(opts: Options): boolean {\n if (Runtime.getProtocol() === 'https:') {\n return true;\n } else if (opts.forceTLS === false) {\n return false;\n }\n return true;\n}\n\n// if enableStats is set take the value\n// if disableStats is set take the inverse\n// otherwise default to false\nfunction getEnableStatsConfig(opts: Options): boolean {\n if ('enableStats' in opts) {\n return opts.enableStats;\n }\n if ('disableStats' in opts) {\n return !opts.disableStats;\n }\n return false;\n}\n\nconst hasCustomHandler = (\n auth: AuthOptionsT\n): auth is CustomAuthOptions => {\n return 'customHandler' in auth && auth['customHandler'] != null;\n};\n\nfunction buildUserAuthenticator(opts: Options): UserAuthenticationHandler {\n const userAuthentication = {\n ...Defaults.userAuthentication,\n ...opts.userAuthentication\n };\n\n if (hasCustomHandler(userAuthentication)) {\n return userAuthentication['customHandler'];\n }\n\n return UserAuthenticator(userAuthentication);\n}\n\nfunction buildChannelAuth(opts: Options, pusher): ChannelAuthorizationOptions {\n let channelAuthorization: ChannelAuthorizationOptions;\n if ('channelAuthorization' in opts) {\n channelAuthorization = {\n ...Defaults.channelAuthorization,\n ...opts.channelAuthorization\n };\n } else {\n channelAuthorization = {\n transport: opts.authTransport || Defaults.authTransport,\n endpoint: opts.authEndpoint || Defaults.authEndpoint\n };\n\n if ('auth' in opts) {\n if ('params' in opts.auth) channelAuthorization.params = opts.auth.params;\n if ('headers' in opts.auth)\n channelAuthorization.headers = opts.auth.headers;\n }\n\n if ('authorizer' in opts) {\n return {\n customHandler: ChannelAuthorizerProxy(\n pusher,\n channelAuthorization,\n opts.authorizer\n )\n };\n }\n }\n return channelAuthorization;\n}\n\nfunction buildChannelAuthorizer(\n opts: Options,\n pusher\n): ChannelAuthorizationHandler {\n const channelAuthorization = buildChannelAuth(opts, pusher);\n\n if (hasCustomHandler(channelAuthorization)) {\n return channelAuthorization['customHandler'];\n }\n\n return ChannelAuthorizer(channelAuthorization);\n}\n","import Logger from './logger';\nimport Pusher from './pusher';\nimport EventsDispatcher from './events/dispatcher';\n\nexport default class WatchlistFacade extends EventsDispatcher {\n private pusher: Pusher;\n\n public constructor(pusher: Pusher) {\n super(function(eventName, data) {\n Logger.debug(`No callbacks on watchlist events for ${eventName}`);\n });\n\n this.pusher = pusher;\n this.bindWatchlistInternalEvent();\n }\n\n handleEvent(pusherEvent) {\n pusherEvent.data.events.forEach(watchlistEvent => {\n this.emit(watchlistEvent.name, watchlistEvent);\n });\n }\n\n private bindWatchlistInternalEvent() {\n this.pusher.connection.bind('message', pusherEvent => {\n var eventName = pusherEvent.event;\n if (eventName === 'pusher_internal:watchlist_events') {\n this.handleEvent(pusherEvent);\n }\n });\n }\n}\n","function flatPromise() {\n let resolve, reject;\n const promise = new Promise((res, rej) => {\n resolve = res;\n reject = rej;\n });\n return { promise, resolve, reject };\n}\n\nexport default flatPromise;\n","import Pusher from './pusher';\nimport Logger from './logger';\nimport {\n UserAuthenticationData,\n UserAuthenticationCallback\n} from './auth/options';\nimport Channel from './channels/channel';\nimport WatchlistFacade from './watchlist';\nimport EventsDispatcher from './events/dispatcher';\nimport flatPromise from './utils/flat_promise';\n\nexport default class UserFacade extends EventsDispatcher {\n pusher: Pusher;\n signin_requested: boolean = false;\n user_data: any = null;\n serverToUserChannel: Channel = null;\n signinDonePromise: Promise = null;\n watchlist: WatchlistFacade;\n private _signinDoneResolve: Function = null;\n\n public constructor(pusher: Pusher) {\n super(function(eventName, data) {\n Logger.debug('No callbacks on user for ' + eventName);\n });\n this.pusher = pusher;\n this.pusher.connection.bind('state_change', ({ previous, current }) => {\n if (previous !== 'connected' && current === 'connected') {\n this._signin();\n }\n if (previous === 'connected' && current !== 'connected') {\n this._cleanup();\n this._newSigninPromiseIfNeeded();\n }\n });\n\n this.watchlist = new WatchlistFacade(pusher);\n\n this.pusher.connection.bind('message', event => {\n var eventName = event.event;\n if (eventName === 'pusher:signin_success') {\n this._onSigninSuccess(event.data);\n }\n if (\n this.serverToUserChannel &&\n this.serverToUserChannel.name === event.channel\n ) {\n this.serverToUserChannel.handleEvent(event);\n }\n });\n }\n\n public signin() {\n if (this.signin_requested) {\n return;\n }\n\n this.signin_requested = true;\n this._signin();\n }\n\n private _signin() {\n if (!this.signin_requested) {\n return;\n }\n\n this._newSigninPromiseIfNeeded();\n\n if (this.pusher.connection.state !== 'connected') {\n // Signin will be attempted when the connection is connected\n return;\n }\n\n this.pusher.config.userAuthenticator(\n {\n socketId: this.pusher.connection.socket_id\n },\n this._onAuthorize\n );\n }\n\n private _onAuthorize: UserAuthenticationCallback = (\n err,\n authData: UserAuthenticationData\n ) => {\n if (err) {\n Logger.warn(`Error during signin: ${err}`);\n this._cleanup();\n return;\n }\n\n this.pusher.send_event('pusher:signin', {\n auth: authData.auth,\n user_data: authData.user_data\n });\n\n // Later when we get pusher:singin_success event, the user will be marked as signed in\n };\n\n private _onSigninSuccess(data: any) {\n try {\n this.user_data = JSON.parse(data.user_data);\n } catch (e) {\n Logger.error(`Failed parsing user data after signin: ${data.user_data}`);\n this._cleanup();\n return;\n }\n\n if (typeof this.user_data.id !== 'string' || this.user_data.id === '') {\n Logger.error(\n `user_data doesn't contain an id. user_data: ${this.user_data}`\n );\n this._cleanup();\n return;\n }\n\n // Signin succeeded\n this._signinDoneResolve();\n this._subscribeChannels();\n }\n\n private _subscribeChannels() {\n const ensure_subscribed = channel => {\n if (channel.subscriptionPending && channel.subscriptionCancelled) {\n channel.reinstateSubscription();\n } else if (\n !channel.subscriptionPending &&\n this.pusher.connection.state === 'connected'\n ) {\n channel.subscribe();\n }\n };\n\n this.serverToUserChannel = new Channel(\n `#server-to-user-${this.user_data.id}`,\n this.pusher\n );\n this.serverToUserChannel.bind_global((eventName, data) => {\n if (\n eventName.indexOf('pusher_internal:') === 0 ||\n eventName.indexOf('pusher:') === 0\n ) {\n // ignore internal events\n return;\n }\n this.emit(eventName, data);\n });\n ensure_subscribed(this.serverToUserChannel);\n }\n\n private _cleanup() {\n this.user_data = null;\n if (this.serverToUserChannel) {\n this.serverToUserChannel.unbind_all();\n this.serverToUserChannel.disconnect();\n this.serverToUserChannel = null;\n }\n\n if (this.signin_requested) {\n // If signin is in progress and cleanup is called,\n // Mark the current signin process as done.\n this._signinDoneResolve();\n }\n }\n\n private _newSigninPromiseIfNeeded() {\n if (!this.signin_requested) {\n return;\n }\n\n // If there is a promise and it is not resolved, return without creating a new one.\n if (this.signinDonePromise && !(this.signinDonePromise as any).done) {\n return;\n }\n\n // This promise is never rejected.\n // It gets resolved when the signin process is done whether it failed or succeeded\n const { promise, resolve, reject: _ } = flatPromise();\n (promise as any).done = false;\n const setDone = () => {\n (promise as any).done = true;\n };\n promise.then(setDone).catch(setDone);\n this.signinDonePromise = promise;\n this._signinDoneResolve = resolve;\n }\n}\n","import AbstractRuntime from '../runtimes/interface';\nimport Runtime from 'runtime';\nimport * as Collections from './utils/collections';\nimport Channels from './channels/channels';\nimport Channel from './channels/channel';\nimport { default as EventsDispatcher } from './events/dispatcher';\nimport Timeline from './timeline/timeline';\nimport TimelineSender from './timeline/timeline_sender';\nimport TimelineLevel from './timeline/level';\nimport { defineTransport } from './strategies/strategy_builder';\nimport ConnectionManager from './connection/connection_manager';\nimport { PeriodicTimer } from './utils/timers';\nimport Defaults from './defaults';\nimport Logger from './logger';\nimport Factory from './utils/factory';\nimport { Options, ClusterOptions, validateOptions } from './options';\nimport { Config, getConfig } from './config';\nimport StrategyOptions from './strategies/strategy_options';\nimport UserFacade from './user';\n\nexport default class Pusher {\n /* STATIC PROPERTIES */\n static instances: Pusher[] = [];\n static isReady: boolean = false;\n static logToConsole: boolean = false;\n\n // for jsonp\n static Runtime: AbstractRuntime = Runtime;\n static ScriptReceivers: any = (Runtime).ScriptReceivers;\n static DependenciesReceivers: any = (Runtime).DependenciesReceivers;\n static auth_callbacks: any = (Runtime).auth_callbacks;\n\n static ready() {\n Pusher.isReady = true;\n for (var i = 0, l = Pusher.instances.length; i < l; i++) {\n Pusher.instances[i].connect();\n }\n }\n\n static log: (message: any) => void;\n\n private static getClientFeatures(): string[] {\n return Collections.keys(\n Collections.filterObject({ ws: Runtime.Transports.ws }, function(t) {\n return t.isSupported({});\n })\n );\n }\n\n /* INSTANCE PROPERTIES */\n key: string;\n options: Options;\n config: Config;\n channels: Channels;\n global_emitter: EventsDispatcher;\n sessionID: number;\n timeline: Timeline;\n timelineSender: TimelineSender;\n connection: ConnectionManager;\n timelineSenderTimer: PeriodicTimer;\n user: UserFacade;\n constructor(app_key: string, options: Options) {\n checkAppKey(app_key);\n validateOptions(options);\n this.key = app_key;\n this.options = options;\n this.config = getConfig(this.options, this);\n\n this.channels = Factory.createChannels();\n this.global_emitter = new EventsDispatcher();\n this.sessionID = Runtime.randomInt(1000000000);\n\n this.timeline = new Timeline(this.key, this.sessionID, {\n cluster: this.config.cluster,\n features: Pusher.getClientFeatures(),\n params: this.config.timelineParams || {},\n limit: 50,\n level: TimelineLevel.INFO,\n version: Defaults.VERSION\n });\n if (this.config.enableStats) {\n this.timelineSender = Factory.createTimelineSender(this.timeline, {\n host: this.config.statsHost,\n path: '/timeline/v2/' + Runtime.TimelineTransport.name\n });\n }\n\n var getStrategy = (options: StrategyOptions) => {\n return Runtime.getDefaultStrategy(this.config, options, defineTransport);\n };\n\n this.connection = Factory.createConnectionManager(this.key, {\n getStrategy: getStrategy,\n timeline: this.timeline,\n activityTimeout: this.config.activityTimeout,\n pongTimeout: this.config.pongTimeout,\n unavailableTimeout: this.config.unavailableTimeout,\n useTLS: Boolean(this.config.useTLS)\n });\n\n this.connection.bind('connected', () => {\n this.subscribeAll();\n if (this.timelineSender) {\n this.timelineSender.send(this.connection.isUsingTLS());\n }\n });\n\n this.connection.bind('message', event => {\n var eventName = event.event;\n var internal = eventName.indexOf('pusher_internal:') === 0;\n if (event.channel) {\n var channel = this.channel(event.channel);\n if (channel) {\n channel.handleEvent(event);\n }\n }\n // Emit globally [deprecated]\n if (!internal) {\n this.global_emitter.emit(event.event, event.data);\n }\n });\n this.connection.bind('connecting', () => {\n this.channels.disconnect();\n });\n this.connection.bind('disconnected', () => {\n this.channels.disconnect();\n });\n this.connection.bind('error', err => {\n Logger.warn(err);\n });\n\n Pusher.instances.push(this);\n this.timeline.info({ instances: Pusher.instances.length });\n\n this.user = new UserFacade(this);\n\n if (Pusher.isReady) {\n this.connect();\n }\n }\n\n /**\n * Allows you to switch Pusher cluster without\n * losing all the channels/subscription binding\n * as this is internally managed by the SDK.\n */\n switchCluster(options: ClusterOptions) {\n const { appKey, cluster } = options;\n this.key = appKey;\n this.options = { ...this.options, cluster };\n this.config = getConfig(this.options, this);\n this.connection.switchCluster(this.key);\n }\n\n channel(name: string): Channel {\n return this.channels.find(name);\n }\n\n allChannels(): Channel[] {\n return this.channels.all();\n }\n\n connect() {\n this.connection.connect();\n\n if (this.timelineSender) {\n if (!this.timelineSenderTimer) {\n var usingTLS = this.connection.isUsingTLS();\n var timelineSender = this.timelineSender;\n this.timelineSenderTimer = new PeriodicTimer(60000, function() {\n timelineSender.send(usingTLS);\n });\n }\n }\n }\n\n disconnect() {\n this.connection.disconnect();\n\n if (this.timelineSenderTimer) {\n this.timelineSenderTimer.ensureAborted();\n this.timelineSenderTimer = null;\n }\n }\n\n bind(event_name: string, callback: Function, context?: any): Pusher {\n this.global_emitter.bind(event_name, callback, context);\n return this;\n }\n\n unbind(event_name?: string, callback?: Function, context?: any): Pusher {\n this.global_emitter.unbind(event_name, callback, context);\n return this;\n }\n\n bind_global(callback: Function): Pusher {\n this.global_emitter.bind_global(callback);\n return this;\n }\n\n unbind_global(callback?: Function): Pusher {\n this.global_emitter.unbind_global(callback);\n return this;\n }\n\n unbind_all(callback?: Function): Pusher {\n this.global_emitter.unbind_all();\n return this;\n }\n\n subscribeAll() {\n var channelName;\n for (channelName in this.channels.channels) {\n if (this.channels.channels.hasOwnProperty(channelName)) {\n this.subscribe(channelName);\n }\n }\n }\n\n subscribe(channel_name: string) {\n var channel = this.channels.add(channel_name, this);\n if (channel.subscriptionPending && channel.subscriptionCancelled) {\n channel.reinstateSubscription();\n } else if (\n !channel.subscriptionPending &&\n this.connection.state === 'connected'\n ) {\n channel.subscribe();\n }\n return channel;\n }\n\n unsubscribe(channel_name: string) {\n var channel = this.channels.find(channel_name);\n if (channel && channel.subscriptionPending) {\n channel.cancelSubscription();\n } else {\n channel = this.channels.remove(channel_name);\n if (channel && channel.subscribed) {\n channel.unsubscribe();\n }\n }\n }\n\n send_event(event_name: string, data: any, channel?: string) {\n return this.connection.send_event(event_name, data, channel);\n }\n\n shouldUseTLS(): boolean {\n return this.config.useTLS;\n }\n\n signin() {\n this.user.signin();\n }\n}\n\nfunction checkAppKey(key) {\n if (key === null || key === undefined) {\n throw 'You must pass your app key when you instantiate Pusher.';\n }\n}\n\nRuntime.setup(Pusher);\n","import Pusher from './pusher';\nimport { Options, validateOptions } from './options';\nimport * as nacl from 'tweetnacl';\n\nexport default class PusherWithEncryption extends Pusher {\n constructor(app_key: string, options: Options) {\n Pusher.logToConsole = PusherWithEncryption.logToConsole;\n Pusher.log = PusherWithEncryption.log;\n\n validateOptions(options);\n options.nacl = nacl;\n super(app_key, options);\n }\n}\n"],"sourceRoot":""} \ No newline at end of file diff --git a/dist/worker/pusher-with-encryption.worker.min.js b/dist/worker/pusher-with-encryption.worker.min.js index 6513b89c1..d9d86e4f0 100644 --- a/dist/worker/pusher-with-encryption.worker.min.js +++ b/dist/worker/pusher-with-encryption.worker.min.js @@ -1,9 +1,9 @@ /*! - * Pusher JavaScript Library v8.4.0-rc1 + * Pusher JavaScript Library v8.4.0-rc2 * https://pusher.com/ * * Copyright 2020, Pusher * Released under the MIT licence. */ -!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.Pusher=e():t.Pusher=e()}(this,(function(){return function(t){var e={};function n(r){if(e[r])return e[r].exports;var i=e[r]={i:r,l:!1,exports:{}};return t[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)n.d(r,i,function(e){return t[e]}.bind(null,i));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=3)}([function(t,e,n){"use strict";var r,i=this&&this.__extends||(r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)},function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)});Object.defineProperty(e,"__esModule",{value:!0});var s=function(){function t(t){void 0===t&&(t="="),this._paddingCharacter=t}return t.prototype.encodedLength=function(t){return this._paddingCharacter?(t+2)/3*4|0:(8*t+5)/6|0},t.prototype.encode=function(t){for(var e="",n=0;n>>18&63),e+=this._encodeByte(r>>>12&63),e+=this._encodeByte(r>>>6&63),e+=this._encodeByte(r>>>0&63)}var i=t.length-n;if(i>0){r=t[n]<<16|(2===i?t[n+1]<<8:0);e+=this._encodeByte(r>>>18&63),e+=this._encodeByte(r>>>12&63),e+=2===i?this._encodeByte(r>>>6&63):this._paddingCharacter||"",e+=this._paddingCharacter||""}return e},t.prototype.maxDecodedLength=function(t){return this._paddingCharacter?t/4*3|0:(6*t+7)/8|0},t.prototype.decodedLength=function(t){return this.maxDecodedLength(t.length-this._getPaddingLength(t))},t.prototype.decode=function(t){if(0===t.length)return new Uint8Array(0);for(var e=this._getPaddingLength(t),n=t.length-e,r=new Uint8Array(this.maxDecodedLength(n)),i=0,s=0,o=0,a=0,h=0,c=0,u=0;s>>4,r[i++]=h<<4|c>>>2,r[i++]=c<<6|u,o|=256&a,o|=256&h,o|=256&c,o|=256&u;if(s>>4,o|=256&a,o|=256&h),s>>2,o|=256&c),s>>8&6,e+=51-t>>>8&-75,e+=61-t>>>8&-15,e+=62-t>>>8&3,String.fromCharCode(e)},t.prototype._decodeChar=function(t){var e=256;return e+=(42-t&t-44)>>>8&-256+t-43+62,e+=(46-t&t-48)>>>8&-256+t-47+63,e+=(47-t&t-58)>>>8&-256+t-48+52,e+=(64-t&t-91)>>>8&-256+t-65+0,e+=(96-t&t-123)>>>8&-256+t-97+26},t.prototype._getPaddingLength=function(t){var e=0;if(this._paddingCharacter){for(var n=t.length-1;n>=0&&t[n]===this._paddingCharacter;n--)e++;if(t.length<4||e>2)throw new Error("Base64Coder: incorrect padding")}return e},t}();e.Coder=s;var o=new s;e.encode=function(t){return o.encode(t)},e.decode=function(t){return o.decode(t)};var a=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return i(e,t),e.prototype._encodeByte=function(t){var e=t;return e+=65,e+=25-t>>>8&6,e+=51-t>>>8&-75,e+=61-t>>>8&-13,e+=62-t>>>8&49,String.fromCharCode(e)},e.prototype._decodeChar=function(t){var e=256;return e+=(44-t&t-46)>>>8&-256+t-45+62,e+=(94-t&t-96)>>>8&-256+t-95+63,e+=(47-t&t-58)>>>8&-256+t-48+52,e+=(64-t&t-91)>>>8&-256+t-65+0,e+=(96-t&t-123)>>>8&-256+t-97+26},e}(s);e.URLSafeCoder=a;var h=new a;e.encodeURLSafe=function(t){return h.encode(t)},e.decodeURLSafe=function(t){return h.decode(t)},e.encodedLength=function(t){return o.encodedLength(t)},e.maxDecodedLength=function(t){return o.maxDecodedLength(t)},e.decodedLength=function(t){return o.decodedLength(t)}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r="utf8: invalid source encoding";function i(t){for(var e=0,n=0;n=t.length-1)throw new Error("utf8: invalid string");n++,e+=4}}return e}e.encode=function(t){for(var e=new Uint8Array(i(t)),n=0,r=0;r>6,e[n++]=128|63&s):s<55296?(e[n++]=224|s>>12,e[n++]=128|s>>6&63,e[n++]=128|63&s):(r++,s=(1023&s)<<10,s|=1023&t.charCodeAt(r),s+=65536,e[n++]=240|s>>18,e[n++]=128|s>>12&63,e[n++]=128|s>>6&63,e[n++]=128|63&s)}return e},e.encodedLength=i,e.decode=function(t){for(var e=[],n=0;n=t.length)throw new Error(r);if(128!=(192&(o=t[++n])))throw new Error(r);i=(31&i)<<6|63&o,s=128}else if(i<240){if(n>=t.length-1)throw new Error(r);var o=t[++n],a=t[++n];if(128!=(192&o)||128!=(192&a))throw new Error(r);i=(15&i)<<12|(63&o)<<6|63&a,s=2048}else{if(!(i<248))throw new Error(r);if(n>=t.length-2)throw new Error(r);o=t[++n],a=t[++n];var h=t[++n];if(128!=(192&o)||128!=(192&a)||128!=(192&h))throw new Error(r);i=(15&i)<<18|(63&o)<<12|(63&a)<<6|63&h,s=65536}if(i=55296&&i<=57343)throw new Error(r);if(i>=65536){if(i>1114111)throw new Error(r);i-=65536,e.push(String.fromCharCode(55296|i>>10)),i=56320|1023&i}}e.push(String.fromCharCode(i))}return e.join("")}},function(t,e,n){!function(t){"use strict";var e=function(t){var e,n=new Float64Array(16);if(t)for(e=0;e>24&255,t[e+1]=n>>16&255,t[e+2]=n>>8&255,t[e+3]=255&n,t[e+4]=r>>24&255,t[e+5]=r>>16&255,t[e+6]=r>>8&255,t[e+7]=255&r}function g(t,e,n,r,i){var s,o=0;for(s=0;s>>8)-1}function b(t,e,n,r){return g(t,e,n,r,16)}function v(t,e,n,r){return g(t,e,n,r,32)}function y(t,e,n,r){!function(t,e,n,r){for(var i,s=255&r[0]|(255&r[1])<<8|(255&r[2])<<16|(255&r[3])<<24,o=255&n[0]|(255&n[1])<<8|(255&n[2])<<16|(255&n[3])<<24,a=255&n[4]|(255&n[5])<<8|(255&n[6])<<16|(255&n[7])<<24,h=255&n[8]|(255&n[9])<<8|(255&n[10])<<16|(255&n[11])<<24,c=255&n[12]|(255&n[13])<<8|(255&n[14])<<16|(255&n[15])<<24,u=255&r[4]|(255&r[5])<<8|(255&r[6])<<16|(255&r[7])<<24,l=255&e[0]|(255&e[1])<<8|(255&e[2])<<16|(255&e[3])<<24,d=255&e[4]|(255&e[5])<<8|(255&e[6])<<16|(255&e[7])<<24,p=255&e[8]|(255&e[9])<<8|(255&e[10])<<16|(255&e[11])<<24,f=255&e[12]|(255&e[13])<<8|(255&e[14])<<16|(255&e[15])<<24,g=255&r[8]|(255&r[9])<<8|(255&r[10])<<16|(255&r[11])<<24,b=255&n[16]|(255&n[17])<<8|(255&n[18])<<16|(255&n[19])<<24,v=255&n[20]|(255&n[21])<<8|(255&n[22])<<16|(255&n[23])<<24,y=255&n[24]|(255&n[25])<<8|(255&n[26])<<16|(255&n[27])<<24,m=255&n[28]|(255&n[29])<<8|(255&n[30])<<16|(255&n[31])<<24,w=255&r[12]|(255&r[13])<<8|(255&r[14])<<16|(255&r[15])<<24,_=s,S=o,k=a,C=h,T=c,P=u,A=l,E=d,x=p,O=f,L=g,U=b,R=v,M=y,I=m,N=w,D=0;D<20;D+=2)_^=(i=(R^=(i=(x^=(i=(T^=(i=_+R|0)<<7|i>>>25)+_|0)<<9|i>>>23)+T|0)<<13|i>>>19)+x|0)<<18|i>>>14,P^=(i=(S^=(i=(M^=(i=(O^=(i=P+S|0)<<7|i>>>25)+P|0)<<9|i>>>23)+O|0)<<13|i>>>19)+M|0)<<18|i>>>14,L^=(i=(A^=(i=(k^=(i=(I^=(i=L+A|0)<<7|i>>>25)+L|0)<<9|i>>>23)+I|0)<<13|i>>>19)+k|0)<<18|i>>>14,N^=(i=(U^=(i=(E^=(i=(C^=(i=N+U|0)<<7|i>>>25)+N|0)<<9|i>>>23)+C|0)<<13|i>>>19)+E|0)<<18|i>>>14,_^=(i=(C^=(i=(k^=(i=(S^=(i=_+C|0)<<7|i>>>25)+_|0)<<9|i>>>23)+S|0)<<13|i>>>19)+k|0)<<18|i>>>14,P^=(i=(T^=(i=(E^=(i=(A^=(i=P+T|0)<<7|i>>>25)+P|0)<<9|i>>>23)+A|0)<<13|i>>>19)+E|0)<<18|i>>>14,L^=(i=(O^=(i=(x^=(i=(U^=(i=L+O|0)<<7|i>>>25)+L|0)<<9|i>>>23)+U|0)<<13|i>>>19)+x|0)<<18|i>>>14,N^=(i=(I^=(i=(M^=(i=(R^=(i=N+I|0)<<7|i>>>25)+N|0)<<9|i>>>23)+R|0)<<13|i>>>19)+M|0)<<18|i>>>14;_=_+s|0,S=S+o|0,k=k+a|0,C=C+h|0,T=T+c|0,P=P+u|0,A=A+l|0,E=E+d|0,x=x+p|0,O=O+f|0,L=L+g|0,U=U+b|0,R=R+v|0,M=M+y|0,I=I+m|0,N=N+w|0,t[0]=_>>>0&255,t[1]=_>>>8&255,t[2]=_>>>16&255,t[3]=_>>>24&255,t[4]=S>>>0&255,t[5]=S>>>8&255,t[6]=S>>>16&255,t[7]=S>>>24&255,t[8]=k>>>0&255,t[9]=k>>>8&255,t[10]=k>>>16&255,t[11]=k>>>24&255,t[12]=C>>>0&255,t[13]=C>>>8&255,t[14]=C>>>16&255,t[15]=C>>>24&255,t[16]=T>>>0&255,t[17]=T>>>8&255,t[18]=T>>>16&255,t[19]=T>>>24&255,t[20]=P>>>0&255,t[21]=P>>>8&255,t[22]=P>>>16&255,t[23]=P>>>24&255,t[24]=A>>>0&255,t[25]=A>>>8&255,t[26]=A>>>16&255,t[27]=A>>>24&255,t[28]=E>>>0&255,t[29]=E>>>8&255,t[30]=E>>>16&255,t[31]=E>>>24&255,t[32]=x>>>0&255,t[33]=x>>>8&255,t[34]=x>>>16&255,t[35]=x>>>24&255,t[36]=O>>>0&255,t[37]=O>>>8&255,t[38]=O>>>16&255,t[39]=O>>>24&255,t[40]=L>>>0&255,t[41]=L>>>8&255,t[42]=L>>>16&255,t[43]=L>>>24&255,t[44]=U>>>0&255,t[45]=U>>>8&255,t[46]=U>>>16&255,t[47]=U>>>24&255,t[48]=R>>>0&255,t[49]=R>>>8&255,t[50]=R>>>16&255,t[51]=R>>>24&255,t[52]=M>>>0&255,t[53]=M>>>8&255,t[54]=M>>>16&255,t[55]=M>>>24&255,t[56]=I>>>0&255,t[57]=I>>>8&255,t[58]=I>>>16&255,t[59]=I>>>24&255,t[60]=N>>>0&255,t[61]=N>>>8&255,t[62]=N>>>16&255,t[63]=N>>>24&255}(t,e,n,r)}function m(t,e,n,r){!function(t,e,n,r){for(var i,s=255&r[0]|(255&r[1])<<8|(255&r[2])<<16|(255&r[3])<<24,o=255&n[0]|(255&n[1])<<8|(255&n[2])<<16|(255&n[3])<<24,a=255&n[4]|(255&n[5])<<8|(255&n[6])<<16|(255&n[7])<<24,h=255&n[8]|(255&n[9])<<8|(255&n[10])<<16|(255&n[11])<<24,c=255&n[12]|(255&n[13])<<8|(255&n[14])<<16|(255&n[15])<<24,u=255&r[4]|(255&r[5])<<8|(255&r[6])<<16|(255&r[7])<<24,l=255&e[0]|(255&e[1])<<8|(255&e[2])<<16|(255&e[3])<<24,d=255&e[4]|(255&e[5])<<8|(255&e[6])<<16|(255&e[7])<<24,p=255&e[8]|(255&e[9])<<8|(255&e[10])<<16|(255&e[11])<<24,f=255&e[12]|(255&e[13])<<8|(255&e[14])<<16|(255&e[15])<<24,g=255&r[8]|(255&r[9])<<8|(255&r[10])<<16|(255&r[11])<<24,b=255&n[16]|(255&n[17])<<8|(255&n[18])<<16|(255&n[19])<<24,v=255&n[20]|(255&n[21])<<8|(255&n[22])<<16|(255&n[23])<<24,y=255&n[24]|(255&n[25])<<8|(255&n[26])<<16|(255&n[27])<<24,m=255&n[28]|(255&n[29])<<8|(255&n[30])<<16|(255&n[31])<<24,w=255&r[12]|(255&r[13])<<8|(255&r[14])<<16|(255&r[15])<<24,_=0;_<20;_+=2)s^=(i=(v^=(i=(p^=(i=(c^=(i=s+v|0)<<7|i>>>25)+s|0)<<9|i>>>23)+c|0)<<13|i>>>19)+p|0)<<18|i>>>14,u^=(i=(o^=(i=(y^=(i=(f^=(i=u+o|0)<<7|i>>>25)+u|0)<<9|i>>>23)+f|0)<<13|i>>>19)+y|0)<<18|i>>>14,g^=(i=(l^=(i=(a^=(i=(m^=(i=g+l|0)<<7|i>>>25)+g|0)<<9|i>>>23)+m|0)<<13|i>>>19)+a|0)<<18|i>>>14,w^=(i=(b^=(i=(d^=(i=(h^=(i=w+b|0)<<7|i>>>25)+w|0)<<9|i>>>23)+h|0)<<13|i>>>19)+d|0)<<18|i>>>14,s^=(i=(h^=(i=(a^=(i=(o^=(i=s+h|0)<<7|i>>>25)+s|0)<<9|i>>>23)+o|0)<<13|i>>>19)+a|0)<<18|i>>>14,u^=(i=(c^=(i=(d^=(i=(l^=(i=u+c|0)<<7|i>>>25)+u|0)<<9|i>>>23)+l|0)<<13|i>>>19)+d|0)<<18|i>>>14,g^=(i=(f^=(i=(p^=(i=(b^=(i=g+f|0)<<7|i>>>25)+g|0)<<9|i>>>23)+b|0)<<13|i>>>19)+p|0)<<18|i>>>14,w^=(i=(m^=(i=(y^=(i=(v^=(i=w+m|0)<<7|i>>>25)+w|0)<<9|i>>>23)+v|0)<<13|i>>>19)+y|0)<<18|i>>>14;t[0]=s>>>0&255,t[1]=s>>>8&255,t[2]=s>>>16&255,t[3]=s>>>24&255,t[4]=u>>>0&255,t[5]=u>>>8&255,t[6]=u>>>16&255,t[7]=u>>>24&255,t[8]=g>>>0&255,t[9]=g>>>8&255,t[10]=g>>>16&255,t[11]=g>>>24&255,t[12]=w>>>0&255,t[13]=w>>>8&255,t[14]=w>>>16&255,t[15]=w>>>24&255,t[16]=l>>>0&255,t[17]=l>>>8&255,t[18]=l>>>16&255,t[19]=l>>>24&255,t[20]=d>>>0&255,t[21]=d>>>8&255,t[22]=d>>>16&255,t[23]=d>>>24&255,t[24]=p>>>0&255,t[25]=p>>>8&255,t[26]=p>>>16&255,t[27]=p>>>24&255,t[28]=f>>>0&255,t[29]=f>>>8&255,t[30]=f>>>16&255,t[31]=f>>>24&255}(t,e,n,r)}var w=new Uint8Array([101,120,112,97,110,100,32,51,50,45,98,121,116,101,32,107]);function _(t,e,n,r,i,s,o){var a,h,c=new Uint8Array(16),u=new Uint8Array(64);for(h=0;h<16;h++)c[h]=0;for(h=0;h<8;h++)c[h]=s[h];for(;i>=64;){for(y(u,c,o,w),h=0;h<64;h++)t[e+h]=n[r+h]^u[h];for(a=1,h=8;h<16;h++)a=a+(255&c[h])|0,c[h]=255&a,a>>>=8;i-=64,e+=64,r+=64}if(i>0)for(y(u,c,o,w),h=0;h=64;){for(y(h,a,i,w),o=0;o<64;o++)t[e+o]=h[o];for(s=1,o=8;o<16;o++)s=s+(255&a[o])|0,a[o]=255&s,s>>>=8;n-=64,e+=64}if(n>0)for(y(h,a,i,w),o=0;o>>13|n<<3),r=255&t[4]|(255&t[5])<<8,this.r[2]=7939&(n>>>10|r<<6),i=255&t[6]|(255&t[7])<<8,this.r[3]=8191&(r>>>7|i<<9),s=255&t[8]|(255&t[9])<<8,this.r[4]=255&(i>>>4|s<<12),this.r[5]=s>>>1&8190,o=255&t[10]|(255&t[11])<<8,this.r[6]=8191&(s>>>14|o<<2),a=255&t[12]|(255&t[13])<<8,this.r[7]=8065&(o>>>11|a<<5),h=255&t[14]|(255&t[15])<<8,this.r[8]=8191&(a>>>8|h<<8),this.r[9]=h>>>5&127,this.pad[0]=255&t[16]|(255&t[17])<<8,this.pad[1]=255&t[18]|(255&t[19])<<8,this.pad[2]=255&t[20]|(255&t[21])<<8,this.pad[3]=255&t[22]|(255&t[23])<<8,this.pad[4]=255&t[24]|(255&t[25])<<8,this.pad[5]=255&t[26]|(255&t[27])<<8,this.pad[6]=255&t[28]|(255&t[29])<<8,this.pad[7]=255&t[30]|(255&t[31])<<8};function P(t,e,n,r,i,s){var o=new T(s);return o.update(n,r,i),o.finish(t,e),0}function A(t,e,n,r,i,s){var o=new Uint8Array(16);return P(o,0,n,r,i,s),b(t,e,o,0)}function E(t,e,n,r,i){var s;if(n<32)return-1;for(C(t,0,e,0,n,r,i),P(t,16,t,32,n-32,t),s=0;s<16;s++)t[s]=0;return 0}function x(t,e,n,r,i){var s,o=new Uint8Array(32);if(n<32)return-1;if(k(o,0,32,r,i),0!==A(e,16,e,32,n-32,o))return-1;for(C(t,0,e,0,n,r,i),s=0;s<32;s++)t[s]=0;return 0}function O(t,e){var n;for(n=0;n<16;n++)t[n]=0|e[n]}function L(t){var e,n,r=1;for(e=0;e<16;e++)n=t[e]+r+65535,r=Math.floor(n/65536),t[e]=n-65536*r;t[0]+=r-1+37*(r-1)}function U(t,e,n){for(var r,i=~(n-1),s=0;s<16;s++)r=i&(t[s]^e[s]),t[s]^=r,e[s]^=r}function R(t,n){var r,i,s,o=e(),a=e();for(r=0;r<16;r++)a[r]=n[r];for(L(a),L(a),L(a),i=0;i<2;i++){for(o[0]=a[0]-65517,r=1;r<15;r++)o[r]=a[r]-65535-(o[r-1]>>16&1),o[r-1]&=65535;o[15]=a[15]-32767-(o[14]>>16&1),s=o[15]>>16&1,o[14]&=65535,U(a,o,1-s)}for(r=0;r<16;r++)t[2*r]=255&a[r],t[2*r+1]=a[r]>>8}function M(t,e){var n=new Uint8Array(32),r=new Uint8Array(32);return R(n,t),R(r,e),v(n,0,r,0)}function I(t){var e=new Uint8Array(32);return R(e,t),1&e[0]}function N(t,e){var n;for(n=0;n<16;n++)t[n]=e[2*n]+(e[2*n+1]<<8);t[15]&=32767}function D(t,e,n){for(var r=0;r<16;r++)t[r]=e[r]+n[r]}function j(t,e,n){for(var r=0;r<16;r++)t[r]=e[r]-n[r]}function z(t,e,n){var r,i,s=0,o=0,a=0,h=0,c=0,u=0,l=0,d=0,p=0,f=0,g=0,b=0,v=0,y=0,m=0,w=0,_=0,S=0,k=0,C=0,T=0,P=0,A=0,E=0,x=0,O=0,L=0,U=0,R=0,M=0,I=0,N=n[0],D=n[1],j=n[2],z=n[3],H=n[4],B=n[5],F=n[6],q=n[7],Y=n[8],K=n[9],$=n[10],J=n[11],W=n[12],X=n[13],G=n[14],V=n[15];s+=(r=e[0])*N,o+=r*D,a+=r*j,h+=r*z,c+=r*H,u+=r*B,l+=r*F,d+=r*q,p+=r*Y,f+=r*K,g+=r*$,b+=r*J,v+=r*W,y+=r*X,m+=r*G,w+=r*V,o+=(r=e[1])*N,a+=r*D,h+=r*j,c+=r*z,u+=r*H,l+=r*B,d+=r*F,p+=r*q,f+=r*Y,g+=r*K,b+=r*$,v+=r*J,y+=r*W,m+=r*X,w+=r*G,_+=r*V,a+=(r=e[2])*N,h+=r*D,c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=r*W,E+=r*X,x+=r*G,O+=r*V,b+=(r=e[11])*N,v+=r*D,y+=r*j,m+=r*z,w+=r*H,_+=r*B,S+=r*F,k+=r*q,C+=r*Y,T+=r*K,P+=r*$,A+=r*J,E+=r*W,x+=r*X,O+=r*G,L+=r*V,v+=(r=e[12])*N,y+=r*D,m+=r*j,w+=r*z,_+=r*H,S+=r*B,k+=r*F,C+=r*q,T+=r*Y,P+=r*K,A+=r*$,E+=r*J,x+=r*W,O+=r*X,L+=r*G,U+=r*V,y+=(r=e[13])*N,m+=r*D,w+=r*j,_+=r*z,S+=r*H,k+=r*B,C+=r*F,T+=r*q,P+=r*Y,A+=r*K,E+=r*$,x+=r*J,O+=r*W,L+=r*X,U+=r*G,R+=r*V,m+=(r=e[14])*N,w+=r*D,_+=r*j,S+=r*z,k+=r*H,C+=r*B,T+=r*F,P+=r*q,A+=r*Y,E+=r*K,x+=r*$,O+=r*J,L+=r*W,U+=r*X,R+=r*G,M+=r*V,w+=(r=e[15])*N,o+=38*(S+=r*j),a+=38*(k+=r*z),h+=38*(C+=r*H),c+=38*(T+=r*B),u+=38*(P+=r*F),l+=38*(A+=r*q),d+=38*(E+=r*Y),p+=38*(x+=r*K),f+=38*(O+=r*$),g+=38*(L+=r*J),b+=38*(U+=r*W),v+=38*(R+=r*X),y+=38*(M+=r*G),m+=38*(I+=r*V),s=(r=(s+=38*(_+=r*D))+(i=1)+65535)-65536*(i=Math.floor(r/65536)),o=(r=o+i+65535)-65536*(i=Math.floor(r/65536)),a=(r=a+i+65535)-65536*(i=Math.floor(r/65536)),h=(r=h+i+65535)-65536*(i=Math.floor(r/65536)),c=(r=c+i+65535)-65536*(i=Math.floor(r/65536)),u=(r=u+i+65535)-65536*(i=Math.floor(r/65536)),l=(r=l+i+65535)-65536*(i=Math.floor(r/65536)),d=(r=d+i+65535)-65536*(i=Math.floor(r/65536)),p=(r=p+i+65535)-65536*(i=Math.floor(r/65536)),f=(r=f+i+65535)-65536*(i=Math.floor(r/65536)),g=(r=g+i+65535)-65536*(i=Math.floor(r/65536)),b=(r=b+i+65535)-65536*(i=Math.floor(r/65536)),v=(r=v+i+65535)-65536*(i=Math.floor(r/65536)),y=(r=y+i+65535)-65536*(i=Math.floor(r/65536)),m=(r=m+i+65535)-65536*(i=Math.floor(r/65536)),w=(r=w+i+65535)-65536*(i=Math.floor(r/65536)),s=(r=(s+=i-1+37*(i-1))+(i=1)+65535)-65536*(i=Math.floor(r/65536)),o=(r=o+i+65535)-65536*(i=Math.floor(r/65536)),a=(r=a+i+65535)-65536*(i=Math.floor(r/65536)),h=(r=h+i+65535)-65536*(i=Math.floor(r/65536)),c=(r=c+i+65535)-65536*(i=Math.floor(r/65536)),u=(r=u+i+65535)-65536*(i=Math.floor(r/65536)),l=(r=l+i+65535)-65536*(i=Math.floor(r/65536)),d=(r=d+i+65535)-65536*(i=Math.floor(r/65536)),p=(r=p+i+65535)-65536*(i=Math.floor(r/65536)),f=(r=f+i+65535)-65536*(i=Math.floor(r/65536)),g=(r=g+i+65535)-65536*(i=Math.floor(r/65536)),b=(r=b+i+65535)-65536*(i=Math.floor(r/65536)),v=(r=v+i+65535)-65536*(i=Math.floor(r/65536)),y=(r=y+i+65535)-65536*(i=Math.floor(r/65536)),m=(r=m+i+65535)-65536*(i=Math.floor(r/65536)),w=(r=w+i+65535)-65536*(i=Math.floor(r/65536)),s+=i-1+37*(i-1),t[0]=s,t[1]=o,t[2]=a,t[3]=h,t[4]=c,t[5]=u,t[6]=l,t[7]=d,t[8]=p,t[9]=f,t[10]=g,t[11]=b,t[12]=v,t[13]=y,t[14]=m,t[15]=w}function H(t,e){z(t,e,e)}function B(t,n){var r,i=e();for(r=0;r<16;r++)i[r]=n[r];for(r=253;r>=0;r--)H(i,i),2!==r&&4!==r&&z(i,i,n);for(r=0;r<16;r++)t[r]=i[r]}function F(t,n){var r,i=e();for(r=0;r<16;r++)i[r]=n[r];for(r=250;r>=0;r--)H(i,i),1!==r&&z(i,i,n);for(r=0;r<16;r++)t[r]=i[r]}function q(t,n,r){var i,s,o=new Uint8Array(32),a=new Float64Array(80),c=e(),u=e(),l=e(),d=e(),p=e(),f=e();for(s=0;s<31;s++)o[s]=n[s];for(o[31]=127&n[31]|64,o[0]&=248,N(a,r),s=0;s<16;s++)u[s]=a[s],d[s]=c[s]=l[s]=0;for(c[0]=d[0]=1,s=254;s>=0;--s)U(c,u,i=o[s>>>3]>>>(7&s)&1),U(l,d,i),D(p,c,l),j(c,c,l),D(l,u,d),j(u,u,d),H(d,p),H(f,c),z(c,l,c),z(l,u,p),D(p,c,l),j(c,c,l),H(u,c),j(l,d,f),z(c,l,h),D(c,c,d),z(l,l,c),z(c,d,f),z(d,u,a),H(u,p),U(c,u,i),U(l,d,i);for(s=0;s<16;s++)a[s+16]=c[s],a[s+32]=l[s],a[s+48]=u[s],a[s+64]=d[s];var g=a.subarray(32),b=a.subarray(16);return B(g,g),z(b,b,g),R(t,b),0}function Y(t,e){return q(t,e,s)}function K(t,e){return r(e,32),Y(t,e)}function $(t,e,n){var r=new Uint8Array(32);return q(r,n,e),m(t,i,r,w)}T.prototype.blocks=function(t,e,n){for(var r,i,s,o,a,h,c,u,l,d,p,f,g,b,v,y,m,w,_,S=this.fin?0:2048,k=this.h[0],C=this.h[1],T=this.h[2],P=this.h[3],A=this.h[4],E=this.h[5],x=this.h[6],O=this.h[7],L=this.h[8],U=this.h[9],R=this.r[0],M=this.r[1],I=this.r[2],N=this.r[3],D=this.r[4],j=this.r[5],z=this.r[6],H=this.r[7],B=this.r[8],F=this.r[9];n>=16;)d=l=0,d+=(k+=8191&(r=255&t[e+0]|(255&t[e+1])<<8))*R,d+=(C+=8191&(r>>>13|(i=255&t[e+2]|(255&t[e+3])<<8)<<3))*(5*F),d+=(T+=8191&(i>>>10|(s=255&t[e+4]|(255&t[e+5])<<8)<<6))*(5*B),d+=(P+=8191&(s>>>7|(o=255&t[e+6]|(255&t[e+7])<<8)<<9))*(5*H),l=(d+=(A+=8191&(o>>>4|(a=255&t[e+8]|(255&t[e+9])<<8)<<12))*(5*z))>>>13,d&=8191,d+=(E+=a>>>1&8191)*(5*j),d+=(x+=8191&(a>>>14|(h=255&t[e+10]|(255&t[e+11])<<8)<<2))*(5*D),d+=(O+=8191&(h>>>11|(c=255&t[e+12]|(255&t[e+13])<<8)<<5))*(5*N),d+=(L+=8191&(c>>>8|(u=255&t[e+14]|(255&t[e+15])<<8)<<8))*(5*I),p=l+=(d+=(U+=u>>>5|S)*(5*M))>>>13,p+=k*M,p+=C*R,p+=T*(5*F),p+=P*(5*B),l=(p+=A*(5*H))>>>13,p&=8191,p+=E*(5*z),p+=x*(5*j),p+=O*(5*D),p+=L*(5*N),l+=(p+=U*(5*I))>>>13,p&=8191,f=l,f+=k*I,f+=C*M,f+=T*R,f+=P*(5*F),l=(f+=A*(5*B))>>>13,f&=8191,f+=E*(5*H),f+=x*(5*z),f+=O*(5*j),f+=L*(5*D),g=l+=(f+=U*(5*N))>>>13,g+=k*N,g+=C*I,g+=T*M,g+=P*R,l=(g+=A*(5*F))>>>13,g&=8191,g+=E*(5*B),g+=x*(5*H),g+=O*(5*z),g+=L*(5*j),b=l+=(g+=U*(5*D))>>>13,b+=k*D,b+=C*N,b+=T*I,b+=P*M,l=(b+=A*R)>>>13,b&=8191,b+=E*(5*F),b+=x*(5*B),b+=O*(5*H),b+=L*(5*z),v=l+=(b+=U*(5*j))>>>13,v+=k*j,v+=C*D,v+=T*N,v+=P*I,l=(v+=A*M)>>>13,v&=8191,v+=E*R,v+=x*(5*F),v+=O*(5*B),v+=L*(5*H),y=l+=(v+=U*(5*z))>>>13,y+=k*z,y+=C*j,y+=T*D,y+=P*N,l=(y+=A*I)>>>13,y&=8191,y+=E*M,y+=x*R,y+=O*(5*F),y+=L*(5*B),m=l+=(y+=U*(5*H))>>>13,m+=k*H,m+=C*z,m+=T*j,m+=P*D,l=(m+=A*N)>>>13,m&=8191,m+=E*I,m+=x*M,m+=O*R,m+=L*(5*F),w=l+=(m+=U*(5*B))>>>13,w+=k*B,w+=C*H,w+=T*z,w+=P*j,l=(w+=A*D)>>>13,w&=8191,w+=E*N,w+=x*I,w+=O*M,w+=L*R,_=l+=(w+=U*(5*F))>>>13,_+=k*F,_+=C*B,_+=T*H,_+=P*z,l=(_+=A*j)>>>13,_&=8191,_+=E*D,_+=x*N,_+=O*I,_+=L*M,k=d=8191&(l=(l=((l+=(_+=U*R)>>>13)<<2)+l|0)+(d&=8191)|0),C=p+=l>>>=13,T=f&=8191,P=g&=8191,A=b&=8191,E=v&=8191,x=y&=8191,O=m&=8191,L=w&=8191,U=_&=8191,e+=16,n-=16;this.h[0]=k,this.h[1]=C,this.h[2]=T,this.h[3]=P,this.h[4]=A,this.h[5]=E,this.h[6]=x,this.h[7]=O,this.h[8]=L,this.h[9]=U},T.prototype.finish=function(t,e){var n,r,i,s,o=new Uint16Array(10);if(this.leftover){for(s=this.leftover,this.buffer[s++]=1;s<16;s++)this.buffer[s]=0;this.fin=1,this.blocks(this.buffer,0,16)}for(n=this.h[1]>>>13,this.h[1]&=8191,s=2;s<10;s++)this.h[s]+=n,n=this.h[s]>>>13,this.h[s]&=8191;for(this.h[0]+=5*n,n=this.h[0]>>>13,this.h[0]&=8191,this.h[1]+=n,n=this.h[1]>>>13,this.h[1]&=8191,this.h[2]+=n,o[0]=this.h[0]+5,n=o[0]>>>13,o[0]&=8191,s=1;s<10;s++)o[s]=this.h[s]+n,n=o[s]>>>13,o[s]&=8191;for(o[9]-=8192,r=(1^n)-1,s=0;s<10;s++)o[s]&=r;for(r=~r,s=0;s<10;s++)this.h[s]=this.h[s]&r|o[s];for(this.h[0]=65535&(this.h[0]|this.h[1]<<13),this.h[1]=65535&(this.h[1]>>>3|this.h[2]<<10),this.h[2]=65535&(this.h[2]>>>6|this.h[3]<<7),this.h[3]=65535&(this.h[3]>>>9|this.h[4]<<4),this.h[4]=65535&(this.h[4]>>>12|this.h[5]<<1|this.h[6]<<14),this.h[5]=65535&(this.h[6]>>>2|this.h[7]<<11),this.h[6]=65535&(this.h[7]>>>5|this.h[8]<<8),this.h[7]=65535&(this.h[8]>>>8|this.h[9]<<5),i=this.h[0]+this.pad[0],this.h[0]=65535&i,s=1;s<8;s++)i=(this.h[s]+this.pad[s]|0)+(i>>>16)|0,this.h[s]=65535&i;t[e+0]=this.h[0]>>>0&255,t[e+1]=this.h[0]>>>8&255,t[e+2]=this.h[1]>>>0&255,t[e+3]=this.h[1]>>>8&255,t[e+4]=this.h[2]>>>0&255,t[e+5]=this.h[2]>>>8&255,t[e+6]=this.h[3]>>>0&255,t[e+7]=this.h[3]>>>8&255,t[e+8]=this.h[4]>>>0&255,t[e+9]=this.h[4]>>>8&255,t[e+10]=this.h[5]>>>0&255,t[e+11]=this.h[5]>>>8&255,t[e+12]=this.h[6]>>>0&255,t[e+13]=this.h[6]>>>8&255,t[e+14]=this.h[7]>>>0&255,t[e+15]=this.h[7]>>>8&255},T.prototype.update=function(t,e,n){var r,i;if(this.leftover){for((i=16-this.leftover)>n&&(i=n),r=0;r=16&&(i=n-n%16,this.blocks(t,e,i),e+=i,n-=i),n){for(r=0;r=128;){for(S=0;S<16;S++)k=8*S+W,O[S]=n[k+0]<<24|n[k+1]<<16|n[k+2]<<8|n[k+3],L[S]=n[k+4]<<24|n[k+5]<<16|n[k+6]<<8|n[k+7];for(S=0;S<80;S++)if(i=U,s=R,o=M,a=I,h=N,c=D,u=j,z,d=H,p=B,f=F,g=q,b=Y,v=K,y=$,J,P=65535&(T=J),A=T>>>16,E=65535&(C=z),x=C>>>16,P+=65535&(T=(Y>>>14|N<<18)^(Y>>>18|N<<14)^(N>>>9|Y<<23)),A+=T>>>16,E+=65535&(C=(N>>>14|Y<<18)^(N>>>18|Y<<14)^(Y>>>9|N<<23)),x+=C>>>16,P+=65535&(T=Y&K^~Y&$),A+=T>>>16,E+=65535&(C=N&D^~N&j),x+=C>>>16,P+=65535&(T=X[2*S+1]),A+=T>>>16,E+=65535&(C=X[2*S]),x+=C>>>16,C=O[S%16],A+=(T=L[S%16])>>>16,E+=65535&C,x+=C>>>16,E+=(A+=(P+=65535&T)>>>16)>>>16,P=65535&(T=_=65535&P|A<<16),A=T>>>16,E=65535&(C=w=65535&E|(x+=E>>>16)<<16),x=C>>>16,P+=65535&(T=(H>>>28|U<<4)^(U>>>2|H<<30)^(U>>>7|H<<25)),A+=T>>>16,E+=65535&(C=(U>>>28|H<<4)^(H>>>2|U<<30)^(H>>>7|U<<25)),x+=C>>>16,A+=(T=H&B^H&F^B&F)>>>16,E+=65535&(C=U&R^U&M^R&M),x+=C>>>16,l=65535&(E+=(A+=(P+=65535&T)>>>16)>>>16)|(x+=E>>>16)<<16,m=65535&P|A<<16,P=65535&(T=g),A=T>>>16,E=65535&(C=a),x=C>>>16,A+=(T=_)>>>16,E+=65535&(C=w),x+=C>>>16,R=i,M=s,I=o,N=a=65535&(E+=(A+=(P+=65535&T)>>>16)>>>16)|(x+=E>>>16)<<16,D=h,j=c,z=u,U=l,B=d,F=p,q=f,Y=g=65535&P|A<<16,K=b,$=v,J=y,H=m,S%16==15)for(k=0;k<16;k++)C=O[k],P=65535&(T=L[k]),A=T>>>16,E=65535&C,x=C>>>16,C=O[(k+9)%16],P+=65535&(T=L[(k+9)%16]),A+=T>>>16,E+=65535&C,x+=C>>>16,w=O[(k+1)%16],P+=65535&(T=((_=L[(k+1)%16])>>>1|w<<31)^(_>>>8|w<<24)^(_>>>7|w<<25)),A+=T>>>16,E+=65535&(C=(w>>>1|_<<31)^(w>>>8|_<<24)^w>>>7),x+=C>>>16,w=O[(k+14)%16],A+=(T=((_=L[(k+14)%16])>>>19|w<<13)^(w>>>29|_<<3)^(_>>>6|w<<26))>>>16,E+=65535&(C=(w>>>19|_<<13)^(_>>>29|w<<3)^w>>>6),x+=C>>>16,x+=(E+=(A+=(P+=65535&T)>>>16)>>>16)>>>16,O[k]=65535&E|x<<16,L[k]=65535&P|A<<16;P=65535&(T=H),A=T>>>16,E=65535&(C=U),x=C>>>16,C=t[0],A+=(T=e[0])>>>16,E+=65535&C,x+=C>>>16,x+=(E+=(A+=(P+=65535&T)>>>16)>>>16)>>>16,t[0]=U=65535&E|x<<16,e[0]=H=65535&P|A<<16,P=65535&(T=B),A=T>>>16,E=65535&(C=R),x=C>>>16,C=t[1],A+=(T=e[1])>>>16,E+=65535&C,x+=C>>>16,x+=(E+=(A+=(P+=65535&T)>>>16)>>>16)>>>16,t[1]=R=65535&E|x<<16,e[1]=B=65535&P|A<<16,P=65535&(T=F),A=T>>>16,E=65535&(C=M),x=C>>>16,C=t[2],A+=(T=e[2])>>>16,E+=65535&C,x+=C>>>16,x+=(E+=(A+=(P+=65535&T)>>>16)>>>16)>>>16,t[2]=M=65535&E|x<<16,e[2]=F=65535&P|A<<16,P=65535&(T=q),A=T>>>16,E=65535&(C=I),x=C>>>16,C=t[3],A+=(T=e[3])>>>16,E+=65535&C,x+=C>>>16,x+=(E+=(A+=(P+=65535&T)>>>16)>>>16)>>>16,t[3]=I=65535&E|x<<16,e[3]=q=65535&P|A<<16,P=65535&(T=Y),A=T>>>16,E=65535&(C=N),x=C>>>16,C=t[4],A+=(T=e[4])>>>16,E+=65535&C,x+=C>>>16,x+=(E+=(A+=(P+=65535&T)>>>16)>>>16)>>>16,t[4]=N=65535&E|x<<16,e[4]=Y=65535&P|A<<16,P=65535&(T=K),A=T>>>16,E=65535&(C=D),x=C>>>16,C=t[5],A+=(T=e[5])>>>16,E+=65535&C,x+=C>>>16,x+=(E+=(A+=(P+=65535&T)>>>16)>>>16)>>>16,t[5]=D=65535&E|x<<16,e[5]=K=65535&P|A<<16,P=65535&(T=$),A=T>>>16,E=65535&(C=j),x=C>>>16,C=t[6],A+=(T=e[6])>>>16,E+=65535&C,x+=C>>>16,x+=(E+=(A+=(P+=65535&T)>>>16)>>>16)>>>16,t[6]=j=65535&E|x<<16,e[6]=$=65535&P|A<<16,P=65535&(T=J),A=T>>>16,E=65535&(C=z),x=C>>>16,C=t[7],A+=(T=e[7])>>>16,E+=65535&C,x+=C>>>16,x+=(E+=(A+=(P+=65535&T)>>>16)>>>16)>>>16,t[7]=z=65535&E|x<<16,e[7]=J=65535&P|A<<16,W+=128,r-=128}return r}function V(t,e,n){var r,i=new Int32Array(8),s=new Int32Array(8),o=new Uint8Array(256),a=n;for(i[0]=1779033703,i[1]=3144134277,i[2]=1013904242,i[3]=2773480762,i[4]=1359893119,i[5]=2600822924,i[6]=528734635,i[7]=1541459225,s[0]=4089235720,s[1]=2227873595,s[2]=4271175723,s[3]=1595750129,s[4]=2917565137,s[5]=725511199,s[6]=4215389547,s[7]=327033209,G(i,s,e,n),n%=128,r=0;r=0;--i)Q(t,e,r=n[i/8|0]>>(7&i)&1),Z(e,t),Z(t,t),Q(t,e,r)}function nt(t,n){var r=[e(),e(),e(),e()];O(r[0],l),O(r[1],d),O(r[2],a),z(r[3],l,d),et(t,r,n)}function rt(t,n,i){var s,o=new Uint8Array(64),a=[e(),e(),e(),e()];for(i||r(n,32),V(o,n,32),o[0]&=248,o[31]&=127,o[31]|=64,nt(a,o),tt(t,a),s=0;s<32;s++)n[s+32]=t[s];return 0}var it=new Float64Array([237,211,245,92,26,99,18,88,214,156,247,162,222,249,222,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16]);function st(t,e){var n,r,i,s;for(r=63;r>=32;--r){for(n=0,i=r-32,s=r-12;i>4)*it[i],n=e[i]>>8,e[i]&=255;for(i=0;i<32;i++)e[i]-=n*it[i];for(r=0;r<32;r++)e[r+1]+=e[r]>>8,t[r]=255&e[r]}function ot(t){var e,n=new Float64Array(64);for(e=0;e<64;e++)n[e]=t[e];for(e=0;e<64;e++)t[e]=0;st(t,n)}function at(t,n,r,i){var s,o,a=new Uint8Array(64),h=new Uint8Array(64),c=new Uint8Array(64),u=new Float64Array(64),l=[e(),e(),e(),e()];V(a,i,32),a[0]&=248,a[31]&=127,a[31]|=64;var d=r+64;for(s=0;s>7&&j(t[0],o,t[0]),z(t[3],t[0],t[1]),0)}(d,i))return-1;for(s=0;s=0},t.sign.keyPair=function(){var t=new Uint8Array(32),e=new Uint8Array(64);return rt(t,e),{publicKey:t,secretKey:e}},t.sign.keyPair.fromSecretKey=function(t){if(ut(t),64!==t.length)throw new Error("bad secret key size");for(var e=new Uint8Array(32),n=0;n>>6)+r(128|63&e):r(224|e>>>12&15)+r(128|e>>>6&63)+r(128|63&e)},c=function(t){return t.replace(/[^\x00-\x7F]/g,h)},u=function(t){var e=[0,2,1][t.length%3],n=t.charCodeAt(0)<<16|(t.length>1?t.charCodeAt(1):0)<<8|(t.length>2?t.charCodeAt(2):0);return[i.charAt(n>>>18),i.charAt(n>>>12&63),e>=2?"=":i.charAt(n>>>6&63),e>=1?"=":i.charAt(63&n)].join("")},l=self.btoa||function(t){return t.replace(/[\s\S]{1,3}/g,u)};var d=class{constructor(t,e,n,r){this.clear=e,this.timer=t(()=>{this.timer&&(this.timer=r(this.timer))},n)}isRunning(){return null!==this.timer}ensureAborted(){this.timer&&(this.clear(this.timer),this.timer=null)}};function p(t){self.clearTimeout(t)}function f(t){self.clearInterval(t)}class g extends d{constructor(t,e){super(setTimeout,p,t,(function(t){return e(),null}))}}class b extends d{constructor(t,e){super(setInterval,f,t,(function(t){return e(),t}))}}var v={now:()=>Date.now?Date.now():(new Date).valueOf(),defer:t=>new g(0,t),method(t,...e){var n=Array.prototype.slice.call(arguments,1);return function(e){return e[t].apply(e,n.concat(arguments))}}};function y(t,...e){for(var n=0;ne!==t),this):(this.global_callbacks=[],this)}unbind_all(){return this.unbind(),this.unbind_global(),this}emit(t,e,n){for(var r=0;r0)for(r=0;r{self.console&&self.console.log&&self.console.log(t)}}debug(...t){this.log(this.globalLog,t)}warn(...t){this.log(this.globalLogWarn,t)}error(...t){this.log(this.globalLogError,t)}globalLogWarn(t){self.console&&self.console.warn?self.console.warn(t):this.globalLog(t)}globalLogError(t){self.console&&self.console.error?self.console.error(t):this.globalLogWarn(t)}log(t,...e){var n=m.apply(this,arguments);if(Oe.log)Oe.log(n);else if(Oe.logToConsole){t.bind(this)(n)}}};class H extends j{constructor(t,e,n,r,i){super(),this.initialize=ae.transportConnectionInitializer,this.hooks=t,this.name=e,this.priority=n,this.key=r,this.options=i,this.state="new",this.timeline=i.timeline,this.activityTimeout=i.activityTimeout,this.id=this.timeline.generateUniqueID()}handlesActivityChecks(){return Boolean(this.hooks.handlesActivityChecks)}supportsPing(){return Boolean(this.hooks.supportsPing)}connect(){if(this.socket||"initialized"!==this.state)return!1;var t=this.hooks.urls.getInitial(this.key,this.options);try{this.socket=this.hooks.getSocket(t,this.options)}catch(t){return v.defer(()=>{this.onError(t),this.changeState("closed")}),!1}return this.bindListeners(),z.debug("Connecting",{transport:this.name,url:t}),this.changeState("connecting"),!0}close(){return!!this.socket&&(this.socket.close(),!0)}send(t){return"open"===this.state&&(v.defer(()=>{this.socket&&this.socket.send(t)}),!0)}ping(){"open"===this.state&&this.supportsPing()&&this.socket.ping()}onOpen(){this.hooks.beforeOpen&&this.hooks.beforeOpen(this.socket,this.hooks.urls.getPath(this.key,this.options)),this.changeState("open"),this.socket.onopen=void 0}onError(t){this.emit("error",{type:"WebSocketError",error:t}),this.timeline.error(this.buildTimelineMessage({error:t.toString()}))}onClose(t){t?this.changeState("closed",{code:t.code,reason:t.reason,wasClean:t.wasClean}):this.changeState("closed"),this.unbindListeners(),this.socket=void 0}onMessage(t){this.emit("message",t)}onActivity(){this.emit("activity")}bindListeners(){this.socket.onopen=()=>{this.onOpen()},this.socket.onerror=t=>{this.onError(t)},this.socket.onclose=t=>{this.onClose(t)},this.socket.onmessage=t=>{this.onMessage(t)},this.supportsPing()&&(this.socket.onactivity=()=>{this.onActivity()})}unbindListeners(){this.socket&&(this.socket.onopen=void 0,this.socket.onerror=void 0,this.socket.onclose=void 0,this.socket.onmessage=void 0,this.supportsPing()&&(this.socket.onactivity=void 0))}changeState(t,e){this.state=t,this.timeline.info(this.buildTimelineMessage({state:t,params:e})),this.emit(t,e)}buildTimelineMessage(t){return y({cid:this.id},t)}}class B{constructor(t){this.hooks=t}isSupported(t){return this.hooks.isSupported(t)}createConnection(t,e,n,r){return new H(this.hooks,t,e,n,r)}}var F=new B({urls:M,handlesActivityChecks:!1,supportsPing:!1,isInitialized:function(){return Boolean(ae.getWebSocketAPI())},isSupported:function(){return Boolean(ae.getWebSocketAPI())},getSocket:function(t){return ae.createWebSocket(t)}}),q={urls:I,handlesActivityChecks:!1,supportsPing:!0,isInitialized:function(){return!0}},Y=y({getSocket:function(t){return ae.HTTPFactory.createStreamingSocket(t)}},q),K=y({getSocket:function(t){return ae.HTTPFactory.createPollingSocket(t)}},q),$={isSupported:function(){return ae.isXHRSupported()}},J={ws:F,xhr_streaming:new B(y({},Y,$)),xhr_polling:new B(y({},K,$))};class W{constructor(t,e,n){this.manager=t,this.transport=e,this.minPingDelay=n.minPingDelay,this.maxPingDelay=n.maxPingDelay,this.pingDelay=void 0}createConnection(t,e,n,r){r=y({},r,{activityTimeout:this.pingDelay});var i=this.transport.createConnection(t,e,n,r),s=null,o=function(){i.unbind("open",o),i.bind("closed",a),s=v.now()},a=t=>{if(i.unbind("closed",a),1002===t.code||1003===t.code)this.manager.reportDeath();else if(!t.wasClean&&s){var e=v.now()-s;e<2*this.maxPingDelay&&(this.manager.reportDeath(),this.pingDelay=Math.max(e/2,this.minPingDelay))}};return i.bind("open",o),i}isSupported(t){return this.manager.isAlive()&&this.transport.isSupported(t)}}const X={decodeMessage:function(t){try{var e=JSON.parse(t.data),n=e.data;if("string"==typeof n)try{n=JSON.parse(e.data)}catch(t){}var r={event:e.event,channel:e.channel,data:n};return e.user_id&&(r.user_id=e.user_id),r}catch(e){throw{type:"MessageParseError",error:e,data:t.data}}},encodeMessage:function(t){return JSON.stringify(t)},processHandshake:function(t){var e=X.decodeMessage(t);if("pusher:connection_established"===e.event){if(!e.data.activity_timeout)throw"No activity timeout specified in handshake";return{action:"connected",id:e.data.socket_id,activityTimeout:1e3*e.data.activity_timeout}}if("pusher:error"===e.event)return{action:this.getCloseAction(e.data),error:this.getCloseError(e.data)};throw"Invalid handshake"},getCloseAction:function(t){return t.code<4e3?t.code>=1002&&t.code<=1004?"backoff":null:4e3===t.code?"tls_only":t.code<4100?"refused":t.code<4200?"backoff":t.code<4300?"retry":"refused"},getCloseError:function(t){return 1e3!==t.code&&1001!==t.code?{type:"PusherError",data:{code:t.code,message:t.reason||t.message}}:null}};var G=X;class V extends j{constructor(t,e){super(),this.id=t,this.transport=e,this.activityTimeout=e.activityTimeout,this.bindListeners()}handlesActivityChecks(){return this.transport.handlesActivityChecks()}send(t){return this.transport.send(t)}send_event(t,e,n){var r={event:t,data:e};return n&&(r.channel=n),z.debug("Event sent",r),this.send(G.encodeMessage(r))}ping(){this.transport.supportsPing()?this.transport.ping():this.send_event("pusher:ping",{})}close(){this.transport.close()}bindListeners(){var t={message:t=>{var e;try{e=G.decodeMessage(t)}catch(e){this.emit("error",{type:"MessageParseError",error:e,data:t.data})}if(void 0!==e){switch(z.debug("Event recd",e),e.event){case"pusher:error":this.emit("error",{type:"PusherError",data:e.data});break;case"pusher:ping":this.emit("ping");break;case"pusher:pong":this.emit("pong")}this.emit("message",e)}},activity:()=>{this.emit("activity")},error:t=>{this.emit("error",t)},closed:t=>{e(),t&&t.code&&this.handleCloseEvent(t),this.transport=null,this.emit("closed")}},e=()=>{_(t,(t,e)=>{this.transport.unbind(e,t)})};_(t,(t,e)=>{this.transport.bind(e,t)})}handleCloseEvent(t){var e=G.getCloseAction(t),n=G.getCloseError(t);n&&this.emit("error",n),e&&this.emit(e,{action:e,error:n})}}class Z{constructor(t,e){this.transport=t,this.callback=e,this.bindListeners()}close(){this.unbindListeners(),this.transport.close()}bindListeners(){this.onMessage=t=>{var e;this.unbindListeners();try{e=G.processHandshake(t)}catch(t){return this.finish("error",{error:t}),void this.transport.close()}"connected"===e.action?this.finish("connected",{connection:new V(e.id,this.transport),activityTimeout:e.activityTimeout}):(this.finish(e.action,{error:e.error}),this.transport.close())},this.onClosed=t=>{this.unbindListeners();var e=G.getCloseAction(t)||"backoff",n=G.getCloseError(t);this.finish(e,{error:n})},this.transport.bind("message",this.onMessage),this.transport.bind("closed",this.onClosed)}unbindListeners(){this.transport.unbind("message",this.onMessage),this.transport.unbind("closed",this.onClosed)}finish(t,e){this.callback(y({transport:this.transport,action:t},e))}}class Q{constructor(t,e){this.timeline=t,this.options=e||{}}send(t,e){this.timeline.isEmpty()||this.timeline.send(ae.TimelineTransport.getAgent(this,t),e)}}class tt extends Error{constructor(t){super(t),Object.setPrototypeOf(this,new.target.prototype)}}class et extends Error{constructor(t){super(t),Object.setPrototypeOf(this,new.target.prototype)}}Error;class nt extends Error{constructor(t){super(t),Object.setPrototypeOf(this,new.target.prototype)}}class rt extends Error{constructor(t){super(t),Object.setPrototypeOf(this,new.target.prototype)}}class it extends Error{constructor(t){super(t),Object.setPrototypeOf(this,new.target.prototype)}}class st extends Error{constructor(t){super(t),Object.setPrototypeOf(this,new.target.prototype)}}class ot extends Error{constructor(t){super(t),Object.setPrototypeOf(this,new.target.prototype)}}class at extends Error{constructor(t,e){super(e),this.status=t,Object.setPrototypeOf(this,new.target.prototype)}}const ht={baseUrl:"https://pusher.com",urls:{authenticationEndpoint:{path:"/docs/channels/server_api/authenticating_users"},authorizationEndpoint:{path:"/docs/channels/server_api/authorizing-users/"},javascriptQuickStart:{path:"/docs/javascript_quick_start"},triggeringClientEvents:{path:"/docs/client_api_guide/client_events#trigger-events"},encryptedChannelSupport:{fullUrl:"https://github.com/pusher/pusher-js/tree/cc491015371a4bde5743d1c87a0fbac0feb53195#encrypted-channel-support"}}};var ct=function(t){const e=ht.urls[t];if(!e)return"";let n;return e.fullUrl?n=e.fullUrl:e.path&&(n=ht.baseUrl+e.path),n?"See: "+n:""};class ut extends j{constructor(t,e){super((function(e,n){z.debug("No callbacks on "+t+" for "+e)})),this.name=t,this.pusher=e,this.subscribed=!1,this.subscriptionPending=!1,this.subscriptionCancelled=!1}authorize(t,e){return e(null,{auth:""})}trigger(t,e){if(0!==t.indexOf("client-"))throw new tt("Event '"+t+"' does not start with 'client-'");if(!this.subscribed){var n=ct("triggeringClientEvents");z.warn("Client event triggered before channel 'subscription_succeeded' event . "+n)}return this.pusher.send_event(t,e,this.name)}disconnect(){this.subscribed=!1,this.subscriptionPending=!1}handleEvent(t){var e=t.event,n=t.data;if("pusher_internal:subscription_succeeded"===e)this.handleSubscriptionSucceededEvent(t);else if("pusher_internal:subscription_count"===e)this.handleSubscriptionCountEvent(t);else if(0!==e.indexOf("pusher_internal:")){this.emit(e,n,{})}}handleSubscriptionSucceededEvent(t){this.subscriptionPending=!1,this.subscribed=!0,this.subscriptionCancelled?this.pusher.unsubscribe(this.name):this.emit("pusher:subscription_succeeded",t.data)}handleSubscriptionCountEvent(t){t.data.subscription_count&&(this.subscriptionCount=t.data.subscription_count),this.emit("pusher:subscription_count",t.data)}subscribe(){this.subscribed||(this.subscriptionPending=!0,this.subscriptionCancelled=!1,this.authorize(this.pusher.connection.socket_id,(t,e)=>{t?(this.subscriptionPending=!1,z.error(t.toString()),this.emit("pusher:subscription_error",Object.assign({},{type:"AuthError",error:t.message},t instanceof at?{status:t.status}:{}))):this.pusher.send_event("pusher:subscribe",{auth:e.auth,channel_data:e.channel_data,channel:this.name})}))}unsubscribe(){this.subscribed=!1,this.pusher.send_event("pusher:unsubscribe",{channel:this.name})}cancelSubscription(){this.subscriptionCancelled=!0}reinstateSubscription(){this.subscriptionCancelled=!1}}class lt extends ut{authorize(t,e){return this.pusher.config.channelAuthorizer({channelName:this.name,socketId:t},e)}}class dt{constructor(){this.reset()}get(t){return Object.prototype.hasOwnProperty.call(this.members,t)?{id:t,info:this.members[t]}:null}each(t){_(this.members,(e,n)=>{t(this.get(n))})}setMyID(t){this.myID=t}onSubscription(t){this.members=t.presence.hash,this.count=t.presence.count,this.me=this.get(this.myID)}addMember(t){return null===this.get(t.user_id)&&this.count++,this.members[t.user_id]=t.user_info,this.get(t.user_id)}removeMember(t){var e=this.get(t.user_id);return e&&(delete this.members[t.user_id],this.count--),e}reset(){this.members={},this.count=0,this.myID=null,this.me=null}}var pt=function(t,e,n,r){return new(n||(n=Promise))((function(i,s){function o(t){try{h(r.next(t))}catch(t){s(t)}}function a(t){try{h(r.throw(t))}catch(t){s(t)}}function h(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(o,a)}h((r=r.apply(t,e||[])).next())}))};class ft extends lt{constructor(t,e){super(t,e),this.members=new dt}authorize(t,e){super.authorize(t,(t,n)=>pt(this,void 0,void 0,(function*(){if(!t)if(null!=(n=n).channel_data){var r=JSON.parse(n.channel_data);this.members.setMyID(r.user_id)}else{if(yield this.pusher.user.signinDonePromise,null==this.pusher.user.user_data){let t=ct("authorizationEndpoint");return z.error(`Invalid auth response for channel '${this.name}', expected 'channel_data' field. ${t}, or the user should be signed in.`),void e("Invalid auth response")}this.members.setMyID(this.pusher.user.user_data.id)}e(t,n)})))}handleEvent(t){var e=t.event;if(0===e.indexOf("pusher_internal:"))this.handleInternalEvent(t);else{var n=t.data,r={};t.user_id&&(r.user_id=t.user_id),this.emit(e,n,r)}}handleInternalEvent(t){var e=t.event,n=t.data;switch(e){case"pusher_internal:subscription_succeeded":this.handleSubscriptionSucceededEvent(t);break;case"pusher_internal:subscription_count":this.handleSubscriptionCountEvent(t);break;case"pusher_internal:member_added":var r=this.members.addMember(n);this.emit("pusher:member_added",r);break;case"pusher_internal:member_removed":var i=this.members.removeMember(n);i&&this.emit("pusher:member_removed",i)}}handleSubscriptionSucceededEvent(t){this.subscriptionPending=!1,this.subscribed=!0,this.subscriptionCancelled?this.pusher.unsubscribe(this.name):(this.members.onSubscription(t.data),this.emit("pusher:subscription_succeeded",this.members))}disconnect(){this.members.reset(),super.disconnect()}}var gt=n(1),bt=n(0);class vt extends lt{constructor(t,e,n){super(t,e),this.key=null,this.nacl=n}authorize(t,e){super.authorize(t,(t,n)=>{if(t)return void e(t,n);let r=n.shared_secret;r?(this.key=Object(bt.decode)(r),delete n.shared_secret,e(null,n)):e(new Error("No shared_secret key in auth payload for encrypted channel: "+this.name),null)})}trigger(t,e){throw new it("Client events are not currently supported for encrypted channels")}handleEvent(t){var e=t.event,n=t.data;0!==e.indexOf("pusher_internal:")&&0!==e.indexOf("pusher:")?this.handleEncryptedEvent(e,n):super.handleEvent(t)}handleEncryptedEvent(t,e){if(!this.key)return void z.debug("Received encrypted event before key has been retrieved from the authEndpoint");if(!e.ciphertext||!e.nonce)return void z.error("Unexpected format for encrypted event, expected object with `ciphertext` and `nonce` fields, got: "+e);let n=Object(bt.decode)(e.ciphertext);if(n.length{e?z.error(`Failed to make a request to the authEndpoint: ${s}. Unable to fetch new key, so dropping encrypted event`):(i=this.nacl.secretbox.open(n,r,this.key),null!==i?this.emit(t,this.getDataToEmit(i)):z.error("Failed to decrypt event with new key. Dropping encrypted event"))});this.emit(t,this.getDataToEmit(i))}getDataToEmit(t){let e=Object(gt.decode)(t);try{return JSON.parse(e)}catch(t){return e}}}class yt extends j{constructor(t,e){super(),this.state="initialized",this.connection=null,this.key=t,this.options=e,this.timeline=this.options.timeline,this.usingTLS=this.options.useTLS,this.errorCallbacks=this.buildErrorCallbacks(),this.connectionCallbacks=this.buildConnectionCallbacks(this.errorCallbacks),this.handshakeCallbacks=this.buildHandshakeCallbacks(this.errorCallbacks);var n=ae.getNetwork();n.bind("online",()=>{this.timeline.info({netinfo:"online"}),"connecting"!==this.state&&"unavailable"!==this.state||this.retryIn(0)}),n.bind("offline",()=>{this.timeline.info({netinfo:"offline"}),this.connection&&this.sendActivityCheck()}),this.updateStrategy()}switchCluster(t){this.key=t,this.updateStrategy(),this.retryIn(0)}connect(){this.connection||this.runner||(this.strategy.isSupported()?(this.updateState("connecting"),this.startConnecting(),this.setUnavailableTimer()):this.updateState("failed"))}send(t){return!!this.connection&&this.connection.send(t)}send_event(t,e,n){return!!this.connection&&this.connection.send_event(t,e,n)}disconnect(){this.disconnectInternally(),this.updateState("disconnected")}isUsingTLS(){return this.usingTLS}startConnecting(){var t=(e,n)=>{e?this.runner=this.strategy.connect(0,t):"error"===n.action?(this.emit("error",{type:"HandshakeError",error:n.error}),this.timeline.error({handshakeError:n.error})):(this.abortConnecting(),this.handshakeCallbacks[n.action](n))};this.runner=this.strategy.connect(0,t)}abortConnecting(){this.runner&&(this.runner.abort(),this.runner=null)}disconnectInternally(){(this.abortConnecting(),this.clearRetryTimer(),this.clearUnavailableTimer(),this.connection)&&this.abandonConnection().close()}updateStrategy(){this.strategy=this.options.getStrategy({key:this.key,timeline:this.timeline,useTLS:this.usingTLS})}retryIn(t){this.timeline.info({action:"retry",delay:t}),t>0&&this.emit("connecting_in",Math.round(t/1e3)),this.retryTimer=new g(t||0,()=>{this.disconnectInternally(),this.connect()})}clearRetryTimer(){this.retryTimer&&(this.retryTimer.ensureAborted(),this.retryTimer=null)}setUnavailableTimer(){this.unavailableTimer=new g(this.options.unavailableTimeout,()=>{this.updateState("unavailable")})}clearUnavailableTimer(){this.unavailableTimer&&this.unavailableTimer.ensureAborted()}sendActivityCheck(){this.stopActivityCheck(),this.connection.ping(),this.activityTimer=new g(this.options.pongTimeout,()=>{this.timeline.error({pong_timed_out:this.options.pongTimeout}),this.retryIn(0)})}resetActivityCheck(){this.stopActivityCheck(),this.connection&&!this.connection.handlesActivityChecks()&&(this.activityTimer=new g(this.activityTimeout,()=>{this.sendActivityCheck()}))}stopActivityCheck(){this.activityTimer&&this.activityTimer.ensureAborted()}buildConnectionCallbacks(t){return y({},t,{message:t=>{this.resetActivityCheck(),this.emit("message",t)},ping:()=>{this.send_event("pusher:pong",{})},activity:()=>{this.resetActivityCheck()},error:t=>{this.emit("error",t)},closed:()=>{this.abandonConnection(),this.shouldRetry()&&this.retryIn(1e3)}})}buildHandshakeCallbacks(t){return y({},t,{connected:t=>{this.activityTimeout=Math.min(this.options.activityTimeout,t.activityTimeout,t.connection.activityTimeout||1/0),this.clearUnavailableTimer(),this.setConnection(t.connection),this.socket_id=this.connection.id,this.updateState("connected",{socket_id:this.socket_id})}})}buildErrorCallbacks(){let t=t=>e=>{e.error&&this.emit("error",{type:"WebSocketError",error:e.error}),t(e)};return{tls_only:t(()=>{this.usingTLS=!0,this.updateStrategy(),this.retryIn(0)}),refused:t(()=>{this.disconnect()}),backoff:t(()=>{this.retryIn(1e3)}),retry:t(()=>{this.retryIn(0)})}}setConnection(t){for(var e in this.connection=t,this.connectionCallbacks)this.connection.bind(e,this.connectionCallbacks[e]);this.resetActivityCheck()}abandonConnection(){if(this.connection){for(var t in this.stopActivityCheck(),this.connectionCallbacks)this.connection.unbind(t,this.connectionCallbacks[t]);var e=this.connection;return this.connection=null,e}}updateState(t,e){var n=this.state;if(this.state=t,n!==t){var r=t;"connected"===r&&(r+=" with new socket ID "+e.socket_id),z.debug("State changed",n+" -> "+r),this.timeline.info({state:t,params:e}),this.emit("state_change",{previous:n,current:t}),this.emit(t,e)}}shouldRetry(){return"connecting"===this.state||"connected"===this.state}}class mt{constructor(){this.channels={}}add(t,e){return this.channels[t]||(this.channels[t]=function(t,e){if(0===t.indexOf("private-encrypted-")){if(e.config.nacl)return wt.createEncryptedChannel(t,e,e.config.nacl);let n="Tried to subscribe to a private-encrypted- channel but no nacl implementation available",r=ct("encryptedChannelSupport");throw new it(`${n}. ${r}`)}if(0===t.indexOf("private-"))return wt.createPrivateChannel(t,e);if(0===t.indexOf("presence-"))return wt.createPresenceChannel(t,e);if(0===t.indexOf("#"))throw new et('Cannot create a channel with name "'+t+'".');return wt.createChannel(t,e)}(t,e)),this.channels[t]}all(){return function(t){var e=[];return _(t,(function(t){e.push(t)})),e}(this.channels)}find(t){return this.channels[t]}remove(t){var e=this.channels[t];return delete this.channels[t],e}disconnect(){_(this.channels,(function(t){t.disconnect()}))}}var wt={createChannels:()=>new mt,createConnectionManager:(t,e)=>new yt(t,e),createChannel:(t,e)=>new ut(t,e),createPrivateChannel:(t,e)=>new lt(t,e),createPresenceChannel:(t,e)=>new ft(t,e),createEncryptedChannel:(t,e,n)=>new vt(t,e,n),createTimelineSender:(t,e)=>new Q(t,e),createHandshake:(t,e)=>new Z(t,e),createAssistantToTheTransportManager:(t,e,n)=>new W(t,e,n)};class _t{constructor(t){this.options=t||{},this.livesLeft=this.options.lives||1/0}getAssistant(t){return wt.createAssistantToTheTransportManager(this,t,{minPingDelay:this.options.minPingDelay,maxPingDelay:this.options.maxPingDelay})}isAlive(){return this.livesLeft>0}reportDeath(){this.livesLeft-=1}}class St{constructor(t,e){this.strategies=t,this.loop=Boolean(e.loop),this.failFast=Boolean(e.failFast),this.timeout=e.timeout,this.timeoutLimit=e.timeoutLimit}isSupported(){return A(this.strategies,v.method("isSupported"))}connect(t,e){var n=this.strategies,r=0,i=this.timeout,s=null,o=(a,h)=>{h?e(null,h):(r+=1,this.loop&&(r%=n.length),r0&&(i=new g(n.timeout,(function(){s.abort(),r(!0)}))),s=t.connect(e,(function(t,e){t&&i&&i.isRunning()&&!n.failFast||(i&&i.ensureAborted(),r(t,e))})),{abort:function(){i&&i.ensureAborted(),s.abort()},forceMinPriority:function(t){s.forceMinPriority(t)}}}}class kt{constructor(t){this.strategies=t}isSupported(){return A(this.strategies,v.method("isSupported"))}connect(t,e){return function(t,e,n){var r=C(t,(function(t,r,i,s){return t.connect(e,n(r,s))}));return{abort:function(){k(r,Ct)},forceMinPriority:function(t){k(r,(function(e){e.forceMinPriority(t)}))}}}(this.strategies,t,(function(t,n){return function(r,i){n[t].error=r,r?function(t){return function(t,e){for(var n=0;n=v.now()){var o=this.transports[r.transport];o&&(["ws","wss"].includes(r.transport)||i>3?(this.timeline.info({cached:!0,transport:r.transport,latency:r.latency}),s.push(new St([o],{timeout:2*r.latency+1e3,failFast:!0}))):i++)}var a=v.now(),h=s.pop().connect(t,(function r(o,c){o?(At(n),s.length>0?(a=v.now(),h=s.pop().connect(t,r)):e(o)):(!function(t,e,n,r){var i=ae.getLocalStorage();if(i)try{i[Pt(t)]=O({timestamp:v.now(),transport:e,latency:n,cacheSkipCount:r})}catch(t){}}(n,c.transport.name,v.now()-a,i),e(null,c))}));return{abort:function(){h.abort()},forceMinPriority:function(e){t=e,h&&h.forceMinPriority(e)}}}}function Pt(t){return"pusherTransport"+(t?"TLS":"NonTLS")}function At(t){var e=ae.getLocalStorage();if(e)try{delete e[Pt(t)]}catch(t){}}class Et{constructor(t,{delay:e}){this.strategy=t,this.options={delay:e}}isSupported(){return this.strategy.isSupported()}connect(t,e){var n,r=this.strategy,i=new g(this.options.delay,(function(){n=r.connect(t,e)}));return{abort:function(){i.ensureAborted(),n&&n.abort()},forceMinPriority:function(e){t=e,n&&n.forceMinPriority(e)}}}}class xt{constructor(t,e,n){this.test=t,this.trueBranch=e,this.falseBranch=n}isSupported(){return(this.test()?this.trueBranch:this.falseBranch).isSupported()}connect(t,e){return(this.test()?this.trueBranch:this.falseBranch).connect(t,e)}}class Ot{constructor(t){this.strategy=t}isSupported(){return this.strategy.isSupported()}connect(t,e){var n=this.strategy.connect(t,(function(t,r){r&&n.abort(),e(t,r)}));return n}}function Lt(t){return function(){return t.isSupported()}}var Ut=function(t,e,n){var r={};function i(e,i,s,o,a){var h=n(t,e,i,s,o,a);return r[e]=h,h}var s,o=Object.assign({},e,{hostNonTLS:t.wsHost+":"+t.wsPort,hostTLS:t.wsHost+":"+t.wssPort,httpPath:t.wsPath}),a=y({},o,{useTLS:!0}),h=Object.assign({},e,{hostNonTLS:t.httpHost+":"+t.httpPort,hostTLS:t.httpHost+":"+t.httpsPort,httpPath:t.httpPath}),c={loop:!0,timeout:15e3,timeoutLimit:6e4},u=new _t({minPingDelay:1e4,maxPingDelay:t.activityTimeout}),l=new _t({lives:2,minPingDelay:1e4,maxPingDelay:t.activityTimeout}),d=i("ws","ws",3,o,u),p=i("wss","ws",3,a,u),f=i("xhr_streaming","xhr_streaming",1,h,l),g=i("xhr_polling","xhr_polling",1,h),b=new St([d],c),v=new St([p],c),m=new St([f],c),w=new St([g],c),_=new St([new xt(Lt(m),new kt([m,new Et(w,{delay:4e3})]),w)],c);return s=e.useTLS?new kt([b,new Et(_,{delay:2e3})]):new kt([b,new Et(v,{delay:2e3}),new Et(_,{delay:5e3})]),new Tt(new Ot(new xt(Lt(d),s,_)),r,{ttl:18e5,timeline:e.timeline,useTLS:e.useTLS})};class Rt extends j{constructor(t,e,n){super(),this.hooks=t,this.method=e,this.url=n}start(t){this.position=0,this.xhr=this.hooks.getRequest(this),this.unloader=()=>{this.close()},ae.addUnloadListener(this.unloader),this.xhr.open(this.method,this.url,!0),this.xhr.setRequestHeader&&this.xhr.setRequestHeader("Content-Type","application/json"),this.xhr.send(t)}close(){this.unloader&&(ae.removeUnloadListener(this.unloader),this.unloader=null),this.xhr&&(this.hooks.abortRequest(this.xhr),this.xhr=null)}onChunk(t,e){for(;;){var n=this.advanceBuffer(e);if(!n)break;this.emit("chunk",{status:t,data:n})}this.isBufferTooLong(e)&&this.emit("buffer_too_long")}advanceBuffer(t){var e=t.slice(this.position),n=e.indexOf("\n");return-1!==n?(this.position+=n+1,e.slice(0,n)):null}isBufferTooLong(t){return this.position===t.length&&t.length>262144}}var Mt;!function(t){t[t.CONNECTING=0]="CONNECTING",t[t.OPEN=1]="OPEN",t[t.CLOSED=3]="CLOSED"}(Mt||(Mt={}));var It=Mt,Nt=1;function Dt(t){var e=-1===t.indexOf("?")?"?":"&";return t+e+"t="+ +new Date+"&n="+Nt++}function jt(t){return ae.randomInt(t)}var zt=class{constructor(t,e){this.hooks=t,this.session=jt(1e3)+"/"+function(t){for(var e=[],n=0;n{this.onChunk(t)}),this.stream.bind("finished",t=>{this.hooks.onFinished(this,t)}),this.stream.bind("buffer_too_long",()=>{this.reconnect()});try{this.stream.start()}catch(t){v.defer(()=>{this.onError(t),this.onClose(1006,"Could not start streaming",!1)})}}closeStream(){this.stream&&(this.stream.unbind_all(),this.stream.close(),this.stream=null)}},Ht={getReceiveURL:function(t,e){return t.base+"/"+e+"/xhr_streaming"+t.queryString},onHeartbeat:function(t){t.sendRaw("[]")},sendHeartbeat:function(t){t.sendRaw("[]")},onFinished:function(t,e){t.onClose(1006,"Connection interrupted ("+e+")",!1)}},Bt={getReceiveURL:function(t,e){return t.base+"/"+e+"/xhr"+t.queryString},onHeartbeat:function(){},sendHeartbeat:function(t){t.sendRaw("[]")},onFinished:function(t,e){200===e?t.reconnect():t.onClose(1006,"Connection interrupted ("+e+")",!1)}},Ft={getRequest:function(t){var e=new(ae.getXHRAPI());return e.onreadystatechange=e.onprogress=function(){switch(e.readyState){case 3:e.responseText&&e.responseText.length>0&&t.onChunk(e.status,e.responseText);break;case 4:e.responseText&&e.responseText.length>0&&t.onChunk(e.status,e.responseText),t.emit("finished",e.status),t.close()}},e},abortRequest:function(t){t.onreadystatechange=null,t.abort()}},qt={getDefaultStrategy:Ut,Transports:J,transportConnectionInitializer:function(){this.timeline.info(this.buildTimelineMessage({transport:this.name+(this.options.useTLS?"s":"")})),this.hooks.isInitialized()?this.changeState("initialized"):this.onClose()},HTTPFactory:{createStreamingSocket(t){return this.createSocket(Ht,t)},createPollingSocket(t){return this.createSocket(Bt,t)},createSocket:(t,e)=>new zt(t,e),createXHR(t,e){return this.createRequest(Ft,t,e)},createRequest:(t,e,n)=>new Rt(t,e,n)},setup(t){t.ready()},getLocalStorage(){},getClientFeatures:()=>S(P({ws:J.ws},(function(t){return t.isSupported({})}))),getProtocol:()=>"http:",isXHRSupported:()=>!0,createSocketRequest(t,e){if(this.isXHRSupported())return this.HTTPFactory.createXHR(t,e);throw"Cross-origin HTTP requests are not supported"},createXHR(){return new(this.getXHRAPI())},createWebSocket(t){return new(this.getWebSocketAPI())(t)},addUnloadListener(t){},removeUnloadListener(t){}};var Yt=new class extends j{isOnline(){return!0}},Kt=function(t,e,n,r,i){var s=new Headers;for(var o in s.set("Content-Type","application/x-www-form-urlencoded"),n.headers)s.set(o,n.headers[o]);if(null!=n.headersProvider){const t=n.headersProvider();for(var o in t)s.set(o,t[o])}var a=e,h=new Request(n.endpoint,{headers:s,body:a,credentials:"same-origin",method:"POST"});return fetch(h).then(t=>{let{status:e}=t;if(200===e)return t.text();throw new at(e,`Could not get ${r.toString()} info from your auth endpoint, status: ${e}`)}).then(t=>{let e;try{e=JSON.parse(t)}catch(e){throw new at(200,`JSON returned from ${r.toString()} endpoint was invalid, yet status code was 200. Data was: ${t}`)}i(null,e)}).catch(t=>{i(t,null)})},$t={name:"xhr",getAgent:function(t,e){return function(n,r){var i="http"+(e?"s":"")+"://"+(t.host||t.options.host)+t.options.path,s=x(n);fetch(i+="/2?"+s).then(t=>{if(200!==t.status)throw`received ${t.status} from stats.pusher.com`;return t.json()}).then(({host:e})=>{e&&(t.host=e)}).catch(t=>{z.debug("TimelineSender Error: ",t)})}}};const{getDefaultStrategy:Jt,Transports:Wt,setup:Xt,getProtocol:Gt,isXHRSupported:Vt,getLocalStorage:Zt,createXHR:Qt,createWebSocket:te,addUnloadListener:ee,removeUnloadListener:ne,transportConnectionInitializer:re,createSocketRequest:ie,HTTPFactory:se}=qt;var oe,ae={getDefaultStrategy:Jt,Transports:Wt,setup:Xt,getProtocol:Gt,isXHRSupported:Vt,getLocalStorage:Zt,createXHR:Qt,createWebSocket:te,addUnloadListener:ee,removeUnloadListener:ne,transportConnectionInitializer:re,createSocketRequest:ie,HTTPFactory:se,TimelineTransport:$t,getAuthorizers:()=>({ajax:Kt}),getWebSocketAPI:()=>WebSocket,getXHRAPI:()=>XMLHttpRequest,getNetwork:()=>Yt,randomInt:t=>Math.floor((globalThis.crypto||globalThis.msCrypto).getRandomValues(new Uint32Array(1))[0]/Math.pow(2,32)*t)};!function(t){t[t.ERROR=3]="ERROR",t[t.INFO=6]="INFO",t[t.DEBUG=7]="DEBUG"}(oe||(oe={}));var he=oe;class ce{constructor(t,e,n){this.key=t,this.session=e,this.events=[],this.options=n||{},this.sent=0,this.uniqueID=0}log(t,e){t<=this.options.level&&(this.events.push(y({},e,{timestamp:v.now()})),this.options.limit&&this.events.length>this.options.limit&&this.events.shift())}error(t){this.log(he.ERROR,t)}info(t){this.log(he.INFO,t)}debug(t){this.log(he.DEBUG,t)}isEmpty(){return 0===this.events.length}send(t,e){var n=y({session:this.session,bundle:this.sent+1,key:this.key,lib:"js",version:this.options.version,cluster:this.options.cluster,features:this.options.features,timeline:this.events},this.options.params);return this.events=[],t(n,(t,n)=>{t||this.sent++,e&&e(t,n)}),!0}generateUniqueID(){return this.uniqueID++,this.uniqueID}}class ue{constructor(t,e,n,r){this.name=t,this.priority=e,this.transport=n,this.options=r||{}}isSupported(){return this.transport.isSupported({useTLS:this.options.useTLS})}connect(t,e){if(!this.isSupported())return le(new ot,e);if(this.priority{n||(c(),i?i.close():r.close())},forceMinPriority:t=>{n||this.priority{if(void 0===ae.getAuthorizers()[t.transport])throw`'${t.transport}' is not a recognized auth transport`;return(e,n)=>{const r=((t,e)=>{var n="socket_id="+encodeURIComponent(t.socketId);for(var r in e.params)n+="&"+encodeURIComponent(r)+"="+encodeURIComponent(e.params[r]);if(null!=e.paramsProvider){let t=e.paramsProvider();for(var r in t)n+="&"+encodeURIComponent(r)+"="+encodeURIComponent(t[r])}return n})(e,t);ae.getAuthorizers()[t.transport](ae,r,t,pe.UserAuthentication,n)}};var ye=t=>{if(void 0===ae.getAuthorizers()[t.transport])throw`'${t.transport}' is not a recognized auth transport`;return(e,n)=>{const r=((t,e)=>{var n="socket_id="+encodeURIComponent(t.socketId);for(var r in n+="&channel_name="+encodeURIComponent(t.channelName),e.params)n+="&"+encodeURIComponent(r)+"="+encodeURIComponent(e.params[r]);if(null!=e.paramsProvider){let t=e.paramsProvider();for(var r in t)n+="&"+encodeURIComponent(r)+"="+encodeURIComponent(t[r])}return n})(e,t);ae.getAuthorizers()[t.transport](ae,r,t,pe.ChannelAuthorization,n)}};function me(t,e){let n={activityTimeout:t.activityTimeout||L.activityTimeout,cluster:t.cluster,httpPath:t.httpPath||L.httpPath,httpPort:t.httpPort||L.httpPort,httpsPort:t.httpsPort||L.httpsPort,pongTimeout:t.pongTimeout||L.pongTimeout,statsHost:t.statsHost||L.stats_host,unavailableTimeout:t.unavailableTimeout||L.unavailableTimeout,wsPath:t.wsPath||L.wsPath,wsPort:t.wsPort||L.wsPort,wssPort:t.wssPort||L.wssPort,enableStats:ke(t),httpHost:we(t),useTLS:Se(t),wsHost:_e(t),userAuthenticator:Ce(t),channelAuthorizer:Te(t,e)};return"disabledTransports"in t&&(n.disabledTransports=t.disabledTransports),"enabledTransports"in t&&(n.enabledTransports=t.enabledTransports),"ignoreNullOrigin"in t&&(n.ignoreNullOrigin=t.ignoreNullOrigin),"timelineParams"in t&&(n.timelineParams=t.timelineParams),"nacl"in t&&(n.nacl=t.nacl),n}function we(t){return t.httpHost?t.httpHost:t.cluster?`sockjs-${t.cluster}.pusher.com`:L.httpHost}function _e(t){return t.wsHost?t.wsHost:`ws-${t.cluster}.pusher.com`}function Se(t){return"https:"===ae.getProtocol()||!1!==t.forceTLS}function ke(t){return"enableStats"in t?t.enableStats:"disableStats"in t&&!t.disableStats}function Ce(t){const e=Object.assign(Object.assign({},L.userAuthentication),t.userAuthentication);return"customHandler"in e&&null!=e.customHandler?e.customHandler:ve(e)}function Te(t,e){const n=function(t,e){let n;return"channelAuthorization"in t?n=Object.assign(Object.assign({},L.channelAuthorization),t.channelAuthorization):(n={transport:t.authTransport||L.authTransport,endpoint:t.authEndpoint||L.authEndpoint},"auth"in t&&("params"in t.auth&&(n.params=t.auth.params),"headers"in t.auth&&(n.headers=t.auth.headers)),"authorizer"in t&&(n.customHandler=((t,e,n)=>{const r={authTransport:e.transport,authEndpoint:e.endpoint,auth:{params:e.params,headers:e.headers}};return(e,i)=>{const s=t.channel(e.channelName);n(s,r).authorize(e.socketId,i)}})(e,n,t.authorizer))),n}(t,e);return"customHandler"in n&&null!=n.customHandler?n.customHandler:ye(n)}class Pe extends j{constructor(t){super((function(t,e){z.debug("No callbacks on watchlist events for "+t)})),this.pusher=t,this.bindWatchlistInternalEvent()}handleEvent(t){t.data.events.forEach(t=>{this.emit(t.name,t)})}bindWatchlistInternalEvent(){this.pusher.connection.bind("message",t=>{"pusher_internal:watchlist_events"===t.event&&this.handleEvent(t)})}}var Ae=function(){let t,e;return{promise:new Promise((n,r)=>{t=n,e=r}),resolve:t,reject:e}};class Ee extends j{constructor(t){super((function(t,e){z.debug("No callbacks on user for "+t)})),this.signin_requested=!1,this.user_data=null,this.serverToUserChannel=null,this.signinDonePromise=null,this._signinDoneResolve=null,this._onAuthorize=(t,e)=>{if(t)return z.warn("Error during signin: "+t),void this._cleanup();this.pusher.send_event("pusher:signin",{auth:e.auth,user_data:e.user_data})},this.pusher=t,this.pusher.connection.bind("state_change",({previous:t,current:e})=>{"connected"!==t&&"connected"===e&&this._signin(),"connected"===t&&"connected"!==e&&(this._cleanup(),this._newSigninPromiseIfNeeded())}),this.watchlist=new Pe(t),this.pusher.connection.bind("message",t=>{"pusher:signin_success"===t.event&&this._onSigninSuccess(t.data),this.serverToUserChannel&&this.serverToUserChannel.name===t.channel&&this.serverToUserChannel.handleEvent(t)})}signin(){this.signin_requested||(this.signin_requested=!0,this._signin())}_signin(){this.signin_requested&&(this._newSigninPromiseIfNeeded(),"connected"===this.pusher.connection.state&&this.pusher.config.userAuthenticator({socketId:this.pusher.connection.socket_id},this._onAuthorize))}_onSigninSuccess(t){try{this.user_data=JSON.parse(t.user_data)}catch(e){return z.error("Failed parsing user data after signin: "+t.user_data),void this._cleanup()}if("string"!=typeof this.user_data.id||""===this.user_data.id)return z.error("user_data doesn't contain an id. user_data: "+this.user_data),void this._cleanup();this._signinDoneResolve(),this._subscribeChannels()}_subscribeChannels(){this.serverToUserChannel=new ut("#server-to-user-"+this.user_data.id,this.pusher),this.serverToUserChannel.bind_global((t,e)=>{0!==t.indexOf("pusher_internal:")&&0!==t.indexOf("pusher:")&&this.emit(t,e)}),(t=>{t.subscriptionPending&&t.subscriptionCancelled?t.reinstateSubscription():t.subscriptionPending||"connected"!==this.pusher.connection.state||t.subscribe()})(this.serverToUserChannel)}_cleanup(){this.user_data=null,this.serverToUserChannel&&(this.serverToUserChannel.unbind_all(),this.serverToUserChannel.disconnect(),this.serverToUserChannel=null),this.signin_requested&&this._signinDoneResolve()}_newSigninPromiseIfNeeded(){if(!this.signin_requested)return;if(this.signinDonePromise&&!this.signinDonePromise.done)return;const{promise:t,resolve:e,reject:n}=Ae();t.done=!1;const r=()=>{t.done=!0};t.then(r).catch(r),this.signinDonePromise=t,this._signinDoneResolve=e}}class xe{static ready(){xe.isReady=!0;for(var t=0,e=xe.instances.length;tae.getDefaultStrategy(this.config,t,fe),timeline:this.timeline,activityTimeout:this.config.activityTimeout,pongTimeout:this.config.pongTimeout,unavailableTimeout:this.config.unavailableTimeout,useTLS:Boolean(this.config.useTLS)}),this.connection.bind("connected",()=>{this.subscribeAll(),this.timelineSender&&this.timelineSender.send(this.connection.isUsingTLS())}),this.connection.bind("message",t=>{var e=0===t.event.indexOf("pusher_internal:");if(t.channel){var n=this.channel(t.channel);n&&n.handleEvent(t)}e||this.global_emitter.emit(t.event,t.data)}),this.connection.bind("connecting",()=>{this.channels.disconnect()}),this.connection.bind("disconnected",()=>{this.channels.disconnect()}),this.connection.bind("error",t=>{z.warn(t)}),xe.instances.push(this),this.timeline.info({instances:xe.instances.length}),this.user=new Ee(this),xe.isReady&&this.connect()}switchCluster(t){const{appKey:e,cluster:n}=t;this.key=e,this.options=Object.assign(Object.assign({},this.options),{cluster:n}),this.config=me(this.options,this),this.connection.switchCluster(this.key)}channel(t){return this.channels.find(t)}allChannels(){return this.channels.all()}connect(){if(this.connection.connect(),this.timelineSender&&!this.timelineSenderTimer){var t=this.connection.isUsingTLS(),e=this.timelineSender;this.timelineSenderTimer=new b(6e4,(function(){e.send(t)}))}}disconnect(){this.connection.disconnect(),this.timelineSenderTimer&&(this.timelineSenderTimer.ensureAborted(),this.timelineSenderTimer=null)}bind(t,e,n){return this.global_emitter.bind(t,e,n),this}unbind(t,e,n){return this.global_emitter.unbind(t,e,n),this}bind_global(t){return this.global_emitter.bind_global(t),this}unbind_global(t){return this.global_emitter.unbind_global(t),this}unbind_all(t){return this.global_emitter.unbind_all(),this}subscribeAll(){var t;for(t in this.channels.channels)this.channels.channels.hasOwnProperty(t)&&this.subscribe(t)}subscribe(t){var e=this.channels.add(t,this);return e.subscriptionPending&&e.subscriptionCancelled?e.reinstateSubscription():e.subscriptionPending||"connected"!==this.connection.state||e.subscribe(),e}unsubscribe(t){var e=this.channels.find(t);e&&e.subscriptionPending?e.cancelSubscription():(e=this.channels.remove(t))&&e.subscribed&&e.unsubscribe()}send_event(t,e,n){return this.connection.send_event(t,e,n)}shouldUseTLS(){return this.config.useTLS}signin(){this.user.signin()}}xe.instances=[],xe.isReady=!1,xe.logToConsole=!1,xe.Runtime=ae,xe.ScriptReceivers=ae.ScriptReceivers,xe.DependenciesReceivers=ae.DependenciesReceivers,xe.auth_callbacks=ae.auth_callbacks;var Oe=xe;ae.setup(xe);var Le=n(2);class Ue extends Oe{constructor(t,e){Oe.logToConsole=Ue.logToConsole,Oe.log=Ue.log,be(e),e.nacl=Le,super(t,e)}}}])})); +!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.Pusher=e():t.Pusher=e()}(this,(function(){return function(t){var e={};function n(r){if(e[r])return e[r].exports;var i=e[r]={i:r,l:!1,exports:{}};return t[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)n.d(r,i,function(e){return t[e]}.bind(null,i));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=3)}([function(t,e,n){"use strict";var r,i=this&&this.__extends||(r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)},function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)});Object.defineProperty(e,"__esModule",{value:!0});var s=function(){function t(t){void 0===t&&(t="="),this._paddingCharacter=t}return t.prototype.encodedLength=function(t){return this._paddingCharacter?(t+2)/3*4|0:(8*t+5)/6|0},t.prototype.encode=function(t){for(var e="",n=0;n>>18&63),e+=this._encodeByte(r>>>12&63),e+=this._encodeByte(r>>>6&63),e+=this._encodeByte(r>>>0&63)}var i=t.length-n;if(i>0){r=t[n]<<16|(2===i?t[n+1]<<8:0);e+=this._encodeByte(r>>>18&63),e+=this._encodeByte(r>>>12&63),e+=2===i?this._encodeByte(r>>>6&63):this._paddingCharacter||"",e+=this._paddingCharacter||""}return e},t.prototype.maxDecodedLength=function(t){return this._paddingCharacter?t/4*3|0:(6*t+7)/8|0},t.prototype.decodedLength=function(t){return this.maxDecodedLength(t.length-this._getPaddingLength(t))},t.prototype.decode=function(t){if(0===t.length)return new Uint8Array(0);for(var e=this._getPaddingLength(t),n=t.length-e,r=new Uint8Array(this.maxDecodedLength(n)),i=0,s=0,o=0,a=0,h=0,c=0,u=0;s>>4,r[i++]=h<<4|c>>>2,r[i++]=c<<6|u,o|=256&a,o|=256&h,o|=256&c,o|=256&u;if(s>>4,o|=256&a,o|=256&h),s>>2,o|=256&c),s>>8&6,e+=51-t>>>8&-75,e+=61-t>>>8&-15,e+=62-t>>>8&3,String.fromCharCode(e)},t.prototype._decodeChar=function(t){var e=256;return e+=(42-t&t-44)>>>8&-256+t-43+62,e+=(46-t&t-48)>>>8&-256+t-47+63,e+=(47-t&t-58)>>>8&-256+t-48+52,e+=(64-t&t-91)>>>8&-256+t-65+0,e+=(96-t&t-123)>>>8&-256+t-97+26},t.prototype._getPaddingLength=function(t){var e=0;if(this._paddingCharacter){for(var n=t.length-1;n>=0&&t[n]===this._paddingCharacter;n--)e++;if(t.length<4||e>2)throw new Error("Base64Coder: incorrect padding")}return e},t}();e.Coder=s;var o=new s;e.encode=function(t){return o.encode(t)},e.decode=function(t){return o.decode(t)};var a=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return i(e,t),e.prototype._encodeByte=function(t){var e=t;return e+=65,e+=25-t>>>8&6,e+=51-t>>>8&-75,e+=61-t>>>8&-13,e+=62-t>>>8&49,String.fromCharCode(e)},e.prototype._decodeChar=function(t){var e=256;return e+=(44-t&t-46)>>>8&-256+t-45+62,e+=(94-t&t-96)>>>8&-256+t-95+63,e+=(47-t&t-58)>>>8&-256+t-48+52,e+=(64-t&t-91)>>>8&-256+t-65+0,e+=(96-t&t-123)>>>8&-256+t-97+26},e}(s);e.URLSafeCoder=a;var h=new a;e.encodeURLSafe=function(t){return h.encode(t)},e.decodeURLSafe=function(t){return h.decode(t)},e.encodedLength=function(t){return o.encodedLength(t)},e.maxDecodedLength=function(t){return o.maxDecodedLength(t)},e.decodedLength=function(t){return o.decodedLength(t)}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r="utf8: invalid source encoding";function i(t){for(var e=0,n=0;n=t.length-1)throw new Error("utf8: invalid string");n++,e+=4}}return e}e.encode=function(t){for(var e=new Uint8Array(i(t)),n=0,r=0;r>6,e[n++]=128|63&s):s<55296?(e[n++]=224|s>>12,e[n++]=128|s>>6&63,e[n++]=128|63&s):(r++,s=(1023&s)<<10,s|=1023&t.charCodeAt(r),s+=65536,e[n++]=240|s>>18,e[n++]=128|s>>12&63,e[n++]=128|s>>6&63,e[n++]=128|63&s)}return e},e.encodedLength=i,e.decode=function(t){for(var e=[],n=0;n=t.length)throw new Error(r);if(128!=(192&(o=t[++n])))throw new Error(r);i=(31&i)<<6|63&o,s=128}else if(i<240){if(n>=t.length-1)throw new Error(r);var o=t[++n],a=t[++n];if(128!=(192&o)||128!=(192&a))throw new Error(r);i=(15&i)<<12|(63&o)<<6|63&a,s=2048}else{if(!(i<248))throw new Error(r);if(n>=t.length-2)throw new Error(r);o=t[++n],a=t[++n];var h=t[++n];if(128!=(192&o)||128!=(192&a)||128!=(192&h))throw new Error(r);i=(15&i)<<18|(63&o)<<12|(63&a)<<6|63&h,s=65536}if(i=55296&&i<=57343)throw new Error(r);if(i>=65536){if(i>1114111)throw new Error(r);i-=65536,e.push(String.fromCharCode(55296|i>>10)),i=56320|1023&i}}e.push(String.fromCharCode(i))}return e.join("")}},function(t,e,n){!function(t){"use strict";var e=function(t){var e,n=new Float64Array(16);if(t)for(e=0;e>24&255,t[e+1]=n>>16&255,t[e+2]=n>>8&255,t[e+3]=255&n,t[e+4]=r>>24&255,t[e+5]=r>>16&255,t[e+6]=r>>8&255,t[e+7]=255&r}function g(t,e,n,r,i){var s,o=0;for(s=0;s>>8)-1}function b(t,e,n,r){return g(t,e,n,r,16)}function v(t,e,n,r){return g(t,e,n,r,32)}function y(t,e,n,r){!function(t,e,n,r){for(var i,s=255&r[0]|(255&r[1])<<8|(255&r[2])<<16|(255&r[3])<<24,o=255&n[0]|(255&n[1])<<8|(255&n[2])<<16|(255&n[3])<<24,a=255&n[4]|(255&n[5])<<8|(255&n[6])<<16|(255&n[7])<<24,h=255&n[8]|(255&n[9])<<8|(255&n[10])<<16|(255&n[11])<<24,c=255&n[12]|(255&n[13])<<8|(255&n[14])<<16|(255&n[15])<<24,u=255&r[4]|(255&r[5])<<8|(255&r[6])<<16|(255&r[7])<<24,l=255&e[0]|(255&e[1])<<8|(255&e[2])<<16|(255&e[3])<<24,d=255&e[4]|(255&e[5])<<8|(255&e[6])<<16|(255&e[7])<<24,p=255&e[8]|(255&e[9])<<8|(255&e[10])<<16|(255&e[11])<<24,f=255&e[12]|(255&e[13])<<8|(255&e[14])<<16|(255&e[15])<<24,g=255&r[8]|(255&r[9])<<8|(255&r[10])<<16|(255&r[11])<<24,b=255&n[16]|(255&n[17])<<8|(255&n[18])<<16|(255&n[19])<<24,v=255&n[20]|(255&n[21])<<8|(255&n[22])<<16|(255&n[23])<<24,y=255&n[24]|(255&n[25])<<8|(255&n[26])<<16|(255&n[27])<<24,m=255&n[28]|(255&n[29])<<8|(255&n[30])<<16|(255&n[31])<<24,w=255&r[12]|(255&r[13])<<8|(255&r[14])<<16|(255&r[15])<<24,_=s,S=o,k=a,C=h,T=c,P=u,A=l,E=d,x=p,O=f,L=g,U=b,R=v,M=y,I=m,N=w,D=0;D<20;D+=2)_^=(i=(R^=(i=(x^=(i=(T^=(i=_+R|0)<<7|i>>>25)+_|0)<<9|i>>>23)+T|0)<<13|i>>>19)+x|0)<<18|i>>>14,P^=(i=(S^=(i=(M^=(i=(O^=(i=P+S|0)<<7|i>>>25)+P|0)<<9|i>>>23)+O|0)<<13|i>>>19)+M|0)<<18|i>>>14,L^=(i=(A^=(i=(k^=(i=(I^=(i=L+A|0)<<7|i>>>25)+L|0)<<9|i>>>23)+I|0)<<13|i>>>19)+k|0)<<18|i>>>14,N^=(i=(U^=(i=(E^=(i=(C^=(i=N+U|0)<<7|i>>>25)+N|0)<<9|i>>>23)+C|0)<<13|i>>>19)+E|0)<<18|i>>>14,_^=(i=(C^=(i=(k^=(i=(S^=(i=_+C|0)<<7|i>>>25)+_|0)<<9|i>>>23)+S|0)<<13|i>>>19)+k|0)<<18|i>>>14,P^=(i=(T^=(i=(E^=(i=(A^=(i=P+T|0)<<7|i>>>25)+P|0)<<9|i>>>23)+A|0)<<13|i>>>19)+E|0)<<18|i>>>14,L^=(i=(O^=(i=(x^=(i=(U^=(i=L+O|0)<<7|i>>>25)+L|0)<<9|i>>>23)+U|0)<<13|i>>>19)+x|0)<<18|i>>>14,N^=(i=(I^=(i=(M^=(i=(R^=(i=N+I|0)<<7|i>>>25)+N|0)<<9|i>>>23)+R|0)<<13|i>>>19)+M|0)<<18|i>>>14;_=_+s|0,S=S+o|0,k=k+a|0,C=C+h|0,T=T+c|0,P=P+u|0,A=A+l|0,E=E+d|0,x=x+p|0,O=O+f|0,L=L+g|0,U=U+b|0,R=R+v|0,M=M+y|0,I=I+m|0,N=N+w|0,t[0]=_>>>0&255,t[1]=_>>>8&255,t[2]=_>>>16&255,t[3]=_>>>24&255,t[4]=S>>>0&255,t[5]=S>>>8&255,t[6]=S>>>16&255,t[7]=S>>>24&255,t[8]=k>>>0&255,t[9]=k>>>8&255,t[10]=k>>>16&255,t[11]=k>>>24&255,t[12]=C>>>0&255,t[13]=C>>>8&255,t[14]=C>>>16&255,t[15]=C>>>24&255,t[16]=T>>>0&255,t[17]=T>>>8&255,t[18]=T>>>16&255,t[19]=T>>>24&255,t[20]=P>>>0&255,t[21]=P>>>8&255,t[22]=P>>>16&255,t[23]=P>>>24&255,t[24]=A>>>0&255,t[25]=A>>>8&255,t[26]=A>>>16&255,t[27]=A>>>24&255,t[28]=E>>>0&255,t[29]=E>>>8&255,t[30]=E>>>16&255,t[31]=E>>>24&255,t[32]=x>>>0&255,t[33]=x>>>8&255,t[34]=x>>>16&255,t[35]=x>>>24&255,t[36]=O>>>0&255,t[37]=O>>>8&255,t[38]=O>>>16&255,t[39]=O>>>24&255,t[40]=L>>>0&255,t[41]=L>>>8&255,t[42]=L>>>16&255,t[43]=L>>>24&255,t[44]=U>>>0&255,t[45]=U>>>8&255,t[46]=U>>>16&255,t[47]=U>>>24&255,t[48]=R>>>0&255,t[49]=R>>>8&255,t[50]=R>>>16&255,t[51]=R>>>24&255,t[52]=M>>>0&255,t[53]=M>>>8&255,t[54]=M>>>16&255,t[55]=M>>>24&255,t[56]=I>>>0&255,t[57]=I>>>8&255,t[58]=I>>>16&255,t[59]=I>>>24&255,t[60]=N>>>0&255,t[61]=N>>>8&255,t[62]=N>>>16&255,t[63]=N>>>24&255}(t,e,n,r)}function m(t,e,n,r){!function(t,e,n,r){for(var i,s=255&r[0]|(255&r[1])<<8|(255&r[2])<<16|(255&r[3])<<24,o=255&n[0]|(255&n[1])<<8|(255&n[2])<<16|(255&n[3])<<24,a=255&n[4]|(255&n[5])<<8|(255&n[6])<<16|(255&n[7])<<24,h=255&n[8]|(255&n[9])<<8|(255&n[10])<<16|(255&n[11])<<24,c=255&n[12]|(255&n[13])<<8|(255&n[14])<<16|(255&n[15])<<24,u=255&r[4]|(255&r[5])<<8|(255&r[6])<<16|(255&r[7])<<24,l=255&e[0]|(255&e[1])<<8|(255&e[2])<<16|(255&e[3])<<24,d=255&e[4]|(255&e[5])<<8|(255&e[6])<<16|(255&e[7])<<24,p=255&e[8]|(255&e[9])<<8|(255&e[10])<<16|(255&e[11])<<24,f=255&e[12]|(255&e[13])<<8|(255&e[14])<<16|(255&e[15])<<24,g=255&r[8]|(255&r[9])<<8|(255&r[10])<<16|(255&r[11])<<24,b=255&n[16]|(255&n[17])<<8|(255&n[18])<<16|(255&n[19])<<24,v=255&n[20]|(255&n[21])<<8|(255&n[22])<<16|(255&n[23])<<24,y=255&n[24]|(255&n[25])<<8|(255&n[26])<<16|(255&n[27])<<24,m=255&n[28]|(255&n[29])<<8|(255&n[30])<<16|(255&n[31])<<24,w=255&r[12]|(255&r[13])<<8|(255&r[14])<<16|(255&r[15])<<24,_=0;_<20;_+=2)s^=(i=(v^=(i=(p^=(i=(c^=(i=s+v|0)<<7|i>>>25)+s|0)<<9|i>>>23)+c|0)<<13|i>>>19)+p|0)<<18|i>>>14,u^=(i=(o^=(i=(y^=(i=(f^=(i=u+o|0)<<7|i>>>25)+u|0)<<9|i>>>23)+f|0)<<13|i>>>19)+y|0)<<18|i>>>14,g^=(i=(l^=(i=(a^=(i=(m^=(i=g+l|0)<<7|i>>>25)+g|0)<<9|i>>>23)+m|0)<<13|i>>>19)+a|0)<<18|i>>>14,w^=(i=(b^=(i=(d^=(i=(h^=(i=w+b|0)<<7|i>>>25)+w|0)<<9|i>>>23)+h|0)<<13|i>>>19)+d|0)<<18|i>>>14,s^=(i=(h^=(i=(a^=(i=(o^=(i=s+h|0)<<7|i>>>25)+s|0)<<9|i>>>23)+o|0)<<13|i>>>19)+a|0)<<18|i>>>14,u^=(i=(c^=(i=(d^=(i=(l^=(i=u+c|0)<<7|i>>>25)+u|0)<<9|i>>>23)+l|0)<<13|i>>>19)+d|0)<<18|i>>>14,g^=(i=(f^=(i=(p^=(i=(b^=(i=g+f|0)<<7|i>>>25)+g|0)<<9|i>>>23)+b|0)<<13|i>>>19)+p|0)<<18|i>>>14,w^=(i=(m^=(i=(y^=(i=(v^=(i=w+m|0)<<7|i>>>25)+w|0)<<9|i>>>23)+v|0)<<13|i>>>19)+y|0)<<18|i>>>14;t[0]=s>>>0&255,t[1]=s>>>8&255,t[2]=s>>>16&255,t[3]=s>>>24&255,t[4]=u>>>0&255,t[5]=u>>>8&255,t[6]=u>>>16&255,t[7]=u>>>24&255,t[8]=g>>>0&255,t[9]=g>>>8&255,t[10]=g>>>16&255,t[11]=g>>>24&255,t[12]=w>>>0&255,t[13]=w>>>8&255,t[14]=w>>>16&255,t[15]=w>>>24&255,t[16]=l>>>0&255,t[17]=l>>>8&255,t[18]=l>>>16&255,t[19]=l>>>24&255,t[20]=d>>>0&255,t[21]=d>>>8&255,t[22]=d>>>16&255,t[23]=d>>>24&255,t[24]=p>>>0&255,t[25]=p>>>8&255,t[26]=p>>>16&255,t[27]=p>>>24&255,t[28]=f>>>0&255,t[29]=f>>>8&255,t[30]=f>>>16&255,t[31]=f>>>24&255}(t,e,n,r)}var w=new Uint8Array([101,120,112,97,110,100,32,51,50,45,98,121,116,101,32,107]);function _(t,e,n,r,i,s,o){var a,h,c=new Uint8Array(16),u=new Uint8Array(64);for(h=0;h<16;h++)c[h]=0;for(h=0;h<8;h++)c[h]=s[h];for(;i>=64;){for(y(u,c,o,w),h=0;h<64;h++)t[e+h]=n[r+h]^u[h];for(a=1,h=8;h<16;h++)a=a+(255&c[h])|0,c[h]=255&a,a>>>=8;i-=64,e+=64,r+=64}if(i>0)for(y(u,c,o,w),h=0;h=64;){for(y(h,a,i,w),o=0;o<64;o++)t[e+o]=h[o];for(s=1,o=8;o<16;o++)s=s+(255&a[o])|0,a[o]=255&s,s>>>=8;n-=64,e+=64}if(n>0)for(y(h,a,i,w),o=0;o>>13|n<<3),r=255&t[4]|(255&t[5])<<8,this.r[2]=7939&(n>>>10|r<<6),i=255&t[6]|(255&t[7])<<8,this.r[3]=8191&(r>>>7|i<<9),s=255&t[8]|(255&t[9])<<8,this.r[4]=255&(i>>>4|s<<12),this.r[5]=s>>>1&8190,o=255&t[10]|(255&t[11])<<8,this.r[6]=8191&(s>>>14|o<<2),a=255&t[12]|(255&t[13])<<8,this.r[7]=8065&(o>>>11|a<<5),h=255&t[14]|(255&t[15])<<8,this.r[8]=8191&(a>>>8|h<<8),this.r[9]=h>>>5&127,this.pad[0]=255&t[16]|(255&t[17])<<8,this.pad[1]=255&t[18]|(255&t[19])<<8,this.pad[2]=255&t[20]|(255&t[21])<<8,this.pad[3]=255&t[22]|(255&t[23])<<8,this.pad[4]=255&t[24]|(255&t[25])<<8,this.pad[5]=255&t[26]|(255&t[27])<<8,this.pad[6]=255&t[28]|(255&t[29])<<8,this.pad[7]=255&t[30]|(255&t[31])<<8};function P(t,e,n,r,i,s){var o=new T(s);return o.update(n,r,i),o.finish(t,e),0}function A(t,e,n,r,i,s){var o=new Uint8Array(16);return P(o,0,n,r,i,s),b(t,e,o,0)}function E(t,e,n,r,i){var s;if(n<32)return-1;for(C(t,0,e,0,n,r,i),P(t,16,t,32,n-32,t),s=0;s<16;s++)t[s]=0;return 0}function x(t,e,n,r,i){var s,o=new Uint8Array(32);if(n<32)return-1;if(k(o,0,32,r,i),0!==A(e,16,e,32,n-32,o))return-1;for(C(t,0,e,0,n,r,i),s=0;s<32;s++)t[s]=0;return 0}function O(t,e){var n;for(n=0;n<16;n++)t[n]=0|e[n]}function L(t){var e,n,r=1;for(e=0;e<16;e++)n=t[e]+r+65535,r=Math.floor(n/65536),t[e]=n-65536*r;t[0]+=r-1+37*(r-1)}function U(t,e,n){for(var r,i=~(n-1),s=0;s<16;s++)r=i&(t[s]^e[s]),t[s]^=r,e[s]^=r}function R(t,n){var r,i,s,o=e(),a=e();for(r=0;r<16;r++)a[r]=n[r];for(L(a),L(a),L(a),i=0;i<2;i++){for(o[0]=a[0]-65517,r=1;r<15;r++)o[r]=a[r]-65535-(o[r-1]>>16&1),o[r-1]&=65535;o[15]=a[15]-32767-(o[14]>>16&1),s=o[15]>>16&1,o[14]&=65535,U(a,o,1-s)}for(r=0;r<16;r++)t[2*r]=255&a[r],t[2*r+1]=a[r]>>8}function M(t,e){var n=new Uint8Array(32),r=new Uint8Array(32);return R(n,t),R(r,e),v(n,0,r,0)}function I(t){var e=new Uint8Array(32);return R(e,t),1&e[0]}function N(t,e){var n;for(n=0;n<16;n++)t[n]=e[2*n]+(e[2*n+1]<<8);t[15]&=32767}function D(t,e,n){for(var r=0;r<16;r++)t[r]=e[r]+n[r]}function j(t,e,n){for(var r=0;r<16;r++)t[r]=e[r]-n[r]}function z(t,e,n){var r,i,s=0,o=0,a=0,h=0,c=0,u=0,l=0,d=0,p=0,f=0,g=0,b=0,v=0,y=0,m=0,w=0,_=0,S=0,k=0,C=0,T=0,P=0,A=0,E=0,x=0,O=0,L=0,U=0,R=0,M=0,I=0,N=n[0],D=n[1],j=n[2],z=n[3],B=n[4],H=n[5],F=n[6],q=n[7],Y=n[8],K=n[9],$=n[10],J=n[11],W=n[12],X=n[13],G=n[14],V=n[15];s+=(r=e[0])*N,o+=r*D,a+=r*j,h+=r*z,c+=r*B,u+=r*H,l+=r*F,d+=r*q,p+=r*Y,f+=r*K,g+=r*$,b+=r*J,v+=r*W,y+=r*X,m+=r*G,w+=r*V,o+=(r=e[1])*N,a+=r*D,h+=r*j,c+=r*z,u+=r*B,l+=r*H,d+=r*F,p+=r*q,f+=r*Y,g+=r*K,b+=r*$,v+=r*J,y+=r*W,m+=r*X,w+=r*G,_+=r*V,a+=(r=e[2])*N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P+=r*J,A+=r*W,E+=r*X,x+=r*G,O+=r*V,b+=(r=e[11])*N,v+=r*D,y+=r*j,m+=r*z,w+=r*B,_+=r*H,S+=r*F,k+=r*q,C+=r*Y,T+=r*K,P+=r*$,A+=r*J,E+=r*W,x+=r*X,O+=r*G,L+=r*V,v+=(r=e[12])*N,y+=r*D,m+=r*j,w+=r*z,_+=r*B,S+=r*H,k+=r*F,C+=r*q,T+=r*Y,P+=r*K,A+=r*$,E+=r*J,x+=r*W,O+=r*X,L+=r*G,U+=r*V,y+=(r=e[13])*N,m+=r*D,w+=r*j,_+=r*z,S+=r*B,k+=r*H,C+=r*F,T+=r*q,P+=r*Y,A+=r*K,E+=r*$,x+=r*J,O+=r*W,L+=r*X,U+=r*G,R+=r*V,m+=(r=e[14])*N,w+=r*D,_+=r*j,S+=r*z,k+=r*B,C+=r*H,T+=r*F,P+=r*q,A+=r*Y,E+=r*K,x+=r*$,O+=r*J,L+=r*W,U+=r*X,R+=r*G,M+=r*V,w+=(r=e[15])*N,o+=38*(S+=r*j),a+=38*(k+=r*z),h+=38*(C+=r*B),c+=38*(T+=r*H),u+=38*(P+=r*F),l+=38*(A+=r*q),d+=38*(E+=r*Y),p+=38*(x+=r*K),f+=38*(O+=r*$),g+=38*(L+=r*J),b+=38*(U+=r*W),v+=38*(R+=r*X),y+=38*(M+=r*G),m+=38*(I+=r*V),s=(r=(s+=38*(_+=r*D))+(i=1)+65535)-65536*(i=Math.floor(r/65536)),o=(r=o+i+65535)-65536*(i=Math.floor(r/65536)),a=(r=a+i+65535)-65536*(i=Math.floor(r/65536)),h=(r=h+i+65535)-65536*(i=Math.floor(r/65536)),c=(r=c+i+65535)-65536*(i=Math.floor(r/65536)),u=(r=u+i+65535)-65536*(i=Math.floor(r/65536)),l=(r=l+i+65535)-65536*(i=Math.floor(r/65536)),d=(r=d+i+65535)-65536*(i=Math.floor(r/65536)),p=(r=p+i+65535)-65536*(i=Math.floor(r/65536)),f=(r=f+i+65535)-65536*(i=Math.floor(r/65536)),g=(r=g+i+65535)-65536*(i=Math.floor(r/65536)),b=(r=b+i+65535)-65536*(i=Math.floor(r/65536)),v=(r=v+i+65535)-65536*(i=Math.floor(r/65536)),y=(r=y+i+65535)-65536*(i=Math.floor(r/65536)),m=(r=m+i+65535)-65536*(i=Math.floor(r/65536)),w=(r=w+i+65535)-65536*(i=Math.floor(r/65536)),s=(r=(s+=i-1+37*(i-1))+(i=1)+65535)-65536*(i=Math.floor(r/65536)),o=(r=o+i+65535)-65536*(i=Math.floor(r/65536)),a=(r=a+i+65535)-65536*(i=Math.floor(r/65536)),h=(r=h+i+65535)-65536*(i=Math.floor(r/65536)),c=(r=c+i+65535)-65536*(i=Math.floor(r/65536)),u=(r=u+i+65535)-65536*(i=Math.floor(r/65536)),l=(r=l+i+65535)-65536*(i=Math.floor(r/65536)),d=(r=d+i+65535)-65536*(i=Math.floor(r/65536)),p=(r=p+i+65535)-65536*(i=Math.floor(r/65536)),f=(r=f+i+65535)-65536*(i=Math.floor(r/65536)),g=(r=g+i+65535)-65536*(i=Math.floor(r/65536)),b=(r=b+i+65535)-65536*(i=Math.floor(r/65536)),v=(r=v+i+65535)-65536*(i=Math.floor(r/65536)),y=(r=y+i+65535)-65536*(i=Math.floor(r/65536)),m=(r=m+i+65535)-65536*(i=Math.floor(r/65536)),w=(r=w+i+65535)-65536*(i=Math.floor(r/65536)),s+=i-1+37*(i-1),t[0]=s,t[1]=o,t[2]=a,t[3]=h,t[4]=c,t[5]=u,t[6]=l,t[7]=d,t[8]=p,t[9]=f,t[10]=g,t[11]=b,t[12]=v,t[13]=y,t[14]=m,t[15]=w}function B(t,e){z(t,e,e)}function H(t,n){var r,i=e();for(r=0;r<16;r++)i[r]=n[r];for(r=253;r>=0;r--)B(i,i),2!==r&&4!==r&&z(i,i,n);for(r=0;r<16;r++)t[r]=i[r]}function F(t,n){var r,i=e();for(r=0;r<16;r++)i[r]=n[r];for(r=250;r>=0;r--)B(i,i),1!==r&&z(i,i,n);for(r=0;r<16;r++)t[r]=i[r]}function q(t,n,r){var i,s,o=new Uint8Array(32),a=new Float64Array(80),c=e(),u=e(),l=e(),d=e(),p=e(),f=e();for(s=0;s<31;s++)o[s]=n[s];for(o[31]=127&n[31]|64,o[0]&=248,N(a,r),s=0;s<16;s++)u[s]=a[s],d[s]=c[s]=l[s]=0;for(c[0]=d[0]=1,s=254;s>=0;--s)U(c,u,i=o[s>>>3]>>>(7&s)&1),U(l,d,i),D(p,c,l),j(c,c,l),D(l,u,d),j(u,u,d),B(d,p),B(f,c),z(c,l,c),z(l,u,p),D(p,c,l),j(c,c,l),B(u,c),j(l,d,f),z(c,l,h),D(c,c,d),z(l,l,c),z(c,d,f),z(d,u,a),B(u,p),U(c,u,i),U(l,d,i);for(s=0;s<16;s++)a[s+16]=c[s],a[s+32]=l[s],a[s+48]=u[s],a[s+64]=d[s];var g=a.subarray(32),b=a.subarray(16);return H(g,g),z(b,b,g),R(t,b),0}function Y(t,e){return q(t,e,s)}function K(t,e){return r(e,32),Y(t,e)}function $(t,e,n){var r=new Uint8Array(32);return q(r,n,e),m(t,i,r,w)}T.prototype.blocks=function(t,e,n){for(var r,i,s,o,a,h,c,u,l,d,p,f,g,b,v,y,m,w,_,S=this.fin?0:2048,k=this.h[0],C=this.h[1],T=this.h[2],P=this.h[3],A=this.h[4],E=this.h[5],x=this.h[6],O=this.h[7],L=this.h[8],U=this.h[9],R=this.r[0],M=this.r[1],I=this.r[2],N=this.r[3],D=this.r[4],j=this.r[5],z=this.r[6],B=this.r[7],H=this.r[8],F=this.r[9];n>=16;)d=l=0,d+=(k+=8191&(r=255&t[e+0]|(255&t[e+1])<<8))*R,d+=(C+=8191&(r>>>13|(i=255&t[e+2]|(255&t[e+3])<<8)<<3))*(5*F),d+=(T+=8191&(i>>>10|(s=255&t[e+4]|(255&t[e+5])<<8)<<6))*(5*H),d+=(P+=8191&(s>>>7|(o=255&t[e+6]|(255&t[e+7])<<8)<<9))*(5*B),l=(d+=(A+=8191&(o>>>4|(a=255&t[e+8]|(255&t[e+9])<<8)<<12))*(5*z))>>>13,d&=8191,d+=(E+=a>>>1&8191)*(5*j),d+=(x+=8191&(a>>>14|(h=255&t[e+10]|(255&t[e+11])<<8)<<2))*(5*D),d+=(O+=8191&(h>>>11|(c=255&t[e+12]|(255&t[e+13])<<8)<<5))*(5*N),d+=(L+=8191&(c>>>8|(u=255&t[e+14]|(255&t[e+15])<<8)<<8))*(5*I),p=l+=(d+=(U+=u>>>5|S)*(5*M))>>>13,p+=k*M,p+=C*R,p+=T*(5*F),p+=P*(5*H),l=(p+=A*(5*B))>>>13,p&=8191,p+=E*(5*z),p+=x*(5*j),p+=O*(5*D),p+=L*(5*N),l+=(p+=U*(5*I))>>>13,p&=8191,f=l,f+=k*I,f+=C*M,f+=T*R,f+=P*(5*F),l=(f+=A*(5*H))>>>13,f&=8191,f+=E*(5*B),f+=x*(5*z),f+=O*(5*j),f+=L*(5*D),g=l+=(f+=U*(5*N))>>>13,g+=k*N,g+=C*I,g+=T*M,g+=P*R,l=(g+=A*(5*F))>>>13,g&=8191,g+=E*(5*H),g+=x*(5*B),g+=O*(5*z),g+=L*(5*j),b=l+=(g+=U*(5*D))>>>13,b+=k*D,b+=C*N,b+=T*I,b+=P*M,l=(b+=A*R)>>>13,b&=8191,b+=E*(5*F),b+=x*(5*H),b+=O*(5*B),b+=L*(5*z),v=l+=(b+=U*(5*j))>>>13,v+=k*j,v+=C*D,v+=T*N,v+=P*I,l=(v+=A*M)>>>13,v&=8191,v+=E*R,v+=x*(5*F),v+=O*(5*H),v+=L*(5*B),y=l+=(v+=U*(5*z))>>>13,y+=k*z,y+=C*j,y+=T*D,y+=P*N,l=(y+=A*I)>>>13,y&=8191,y+=E*M,y+=x*R,y+=O*(5*F),y+=L*(5*H),m=l+=(y+=U*(5*B))>>>13,m+=k*B,m+=C*z,m+=T*j,m+=P*D,l=(m+=A*N)>>>13,m&=8191,m+=E*I,m+=x*M,m+=O*R,m+=L*(5*F),w=l+=(m+=U*(5*H))>>>13,w+=k*H,w+=C*B,w+=T*z,w+=P*j,l=(w+=A*D)>>>13,w&=8191,w+=E*N,w+=x*I,w+=O*M,w+=L*R,_=l+=(w+=U*(5*F))>>>13,_+=k*F,_+=C*H,_+=T*B,_+=P*z,l=(_+=A*j)>>>13,_&=8191,_+=E*D,_+=x*N,_+=O*I,_+=L*M,k=d=8191&(l=(l=((l+=(_+=U*R)>>>13)<<2)+l|0)+(d&=8191)|0),C=p+=l>>>=13,T=f&=8191,P=g&=8191,A=b&=8191,E=v&=8191,x=y&=8191,O=m&=8191,L=w&=8191,U=_&=8191,e+=16,n-=16;this.h[0]=k,this.h[1]=C,this.h[2]=T,this.h[3]=P,this.h[4]=A,this.h[5]=E,this.h[6]=x,this.h[7]=O,this.h[8]=L,this.h[9]=U},T.prototype.finish=function(t,e){var n,r,i,s,o=new Uint16Array(10);if(this.leftover){for(s=this.leftover,this.buffer[s++]=1;s<16;s++)this.buffer[s]=0;this.fin=1,this.blocks(this.buffer,0,16)}for(n=this.h[1]>>>13,this.h[1]&=8191,s=2;s<10;s++)this.h[s]+=n,n=this.h[s]>>>13,this.h[s]&=8191;for(this.h[0]+=5*n,n=this.h[0]>>>13,this.h[0]&=8191,this.h[1]+=n,n=this.h[1]>>>13,this.h[1]&=8191,this.h[2]+=n,o[0]=this.h[0]+5,n=o[0]>>>13,o[0]&=8191,s=1;s<10;s++)o[s]=this.h[s]+n,n=o[s]>>>13,o[s]&=8191;for(o[9]-=8192,r=(1^n)-1,s=0;s<10;s++)o[s]&=r;for(r=~r,s=0;s<10;s++)this.h[s]=this.h[s]&r|o[s];for(this.h[0]=65535&(this.h[0]|this.h[1]<<13),this.h[1]=65535&(this.h[1]>>>3|this.h[2]<<10),this.h[2]=65535&(this.h[2]>>>6|this.h[3]<<7),this.h[3]=65535&(this.h[3]>>>9|this.h[4]<<4),this.h[4]=65535&(this.h[4]>>>12|this.h[5]<<1|this.h[6]<<14),this.h[5]=65535&(this.h[6]>>>2|this.h[7]<<11),this.h[6]=65535&(this.h[7]>>>5|this.h[8]<<8),this.h[7]=65535&(this.h[8]>>>8|this.h[9]<<5),i=this.h[0]+this.pad[0],this.h[0]=65535&i,s=1;s<8;s++)i=(this.h[s]+this.pad[s]|0)+(i>>>16)|0,this.h[s]=65535&i;t[e+0]=this.h[0]>>>0&255,t[e+1]=this.h[0]>>>8&255,t[e+2]=this.h[1]>>>0&255,t[e+3]=this.h[1]>>>8&255,t[e+4]=this.h[2]>>>0&255,t[e+5]=this.h[2]>>>8&255,t[e+6]=this.h[3]>>>0&255,t[e+7]=this.h[3]>>>8&255,t[e+8]=this.h[4]>>>0&255,t[e+9]=this.h[4]>>>8&255,t[e+10]=this.h[5]>>>0&255,t[e+11]=this.h[5]>>>8&255,t[e+12]=this.h[6]>>>0&255,t[e+13]=this.h[6]>>>8&255,t[e+14]=this.h[7]>>>0&255,t[e+15]=this.h[7]>>>8&255},T.prototype.update=function(t,e,n){var r,i;if(this.leftover){for((i=16-this.leftover)>n&&(i=n),r=0;r=16&&(i=n-n%16,this.blocks(t,e,i),e+=i,n-=i),n){for(r=0;r=128;){for(S=0;S<16;S++)k=8*S+W,O[S]=n[k+0]<<24|n[k+1]<<16|n[k+2]<<8|n[k+3],L[S]=n[k+4]<<24|n[k+5]<<16|n[k+6]<<8|n[k+7];for(S=0;S<80;S++)if(i=U,s=R,o=M,a=I,h=N,c=D,u=j,z,d=B,p=H,f=F,g=q,b=Y,v=K,y=$,J,P=65535&(T=J),A=T>>>16,E=65535&(C=z),x=C>>>16,P+=65535&(T=(Y>>>14|N<<18)^(Y>>>18|N<<14)^(N>>>9|Y<<23)),A+=T>>>16,E+=65535&(C=(N>>>14|Y<<18)^(N>>>18|Y<<14)^(Y>>>9|N<<23)),x+=C>>>16,P+=65535&(T=Y&K^~Y&$),A+=T>>>16,E+=65535&(C=N&D^~N&j),x+=C>>>16,P+=65535&(T=X[2*S+1]),A+=T>>>16,E+=65535&(C=X[2*S]),x+=C>>>16,C=O[S%16],A+=(T=L[S%16])>>>16,E+=65535&C,x+=C>>>16,E+=(A+=(P+=65535&T)>>>16)>>>16,P=65535&(T=_=65535&P|A<<16),A=T>>>16,E=65535&(C=w=65535&E|(x+=E>>>16)<<16),x=C>>>16,P+=65535&(T=(B>>>28|U<<4)^(U>>>2|B<<30)^(U>>>7|B<<25)),A+=T>>>16,E+=65535&(C=(U>>>28|B<<4)^(B>>>2|U<<30)^(B>>>7|U<<25)),x+=C>>>16,A+=(T=B&H^B&F^H&F)>>>16,E+=65535&(C=U&R^U&M^R&M),x+=C>>>16,l=65535&(E+=(A+=(P+=65535&T)>>>16)>>>16)|(x+=E>>>16)<<16,m=65535&P|A<<16,P=65535&(T=g),A=T>>>16,E=65535&(C=a),x=C>>>16,A+=(T=_)>>>16,E+=65535&(C=w),x+=C>>>16,R=i,M=s,I=o,N=a=65535&(E+=(A+=(P+=65535&T)>>>16)>>>16)|(x+=E>>>16)<<16,D=h,j=c,z=u,U=l,H=d,F=p,q=f,Y=g=65535&P|A<<16,K=b,$=v,J=y,B=m,S%16==15)for(k=0;k<16;k++)C=O[k],P=65535&(T=L[k]),A=T>>>16,E=65535&C,x=C>>>16,C=O[(k+9)%16],P+=65535&(T=L[(k+9)%16]),A+=T>>>16,E+=65535&C,x+=C>>>16,w=O[(k+1)%16],P+=65535&(T=((_=L[(k+1)%16])>>>1|w<<31)^(_>>>8|w<<24)^(_>>>7|w<<25)),A+=T>>>16,E+=65535&(C=(w>>>1|_<<31)^(w>>>8|_<<24)^w>>>7),x+=C>>>16,w=O[(k+14)%16],A+=(T=((_=L[(k+14)%16])>>>19|w<<13)^(w>>>29|_<<3)^(_>>>6|w<<26))>>>16,E+=65535&(C=(w>>>19|_<<13)^(_>>>29|w<<3)^w>>>6),x+=C>>>16,x+=(E+=(A+=(P+=65535&T)>>>16)>>>16)>>>16,O[k]=65535&E|x<<16,L[k]=65535&P|A<<16;P=65535&(T=B),A=T>>>16,E=65535&(C=U),x=C>>>16,C=t[0],A+=(T=e[0])>>>16,E+=65535&C,x+=C>>>16,x+=(E+=(A+=(P+=65535&T)>>>16)>>>16)>>>16,t[0]=U=65535&E|x<<16,e[0]=B=65535&P|A<<16,P=65535&(T=H),A=T>>>16,E=65535&(C=R),x=C>>>16,C=t[1],A+=(T=e[1])>>>16,E+=65535&C,x+=C>>>16,x+=(E+=(A+=(P+=65535&T)>>>16)>>>16)>>>16,t[1]=R=65535&E|x<<16,e[1]=H=65535&P|A<<16,P=65535&(T=F),A=T>>>16,E=65535&(C=M),x=C>>>16,C=t[2],A+=(T=e[2])>>>16,E+=65535&C,x+=C>>>16,x+=(E+=(A+=(P+=65535&T)>>>16)>>>16)>>>16,t[2]=M=65535&E|x<<16,e[2]=F=65535&P|A<<16,P=65535&(T=q),A=T>>>16,E=65535&(C=I),x=C>>>16,C=t[3],A+=(T=e[3])>>>16,E+=65535&C,x+=C>>>16,x+=(E+=(A+=(P+=65535&T)>>>16)>>>16)>>>16,t[3]=I=65535&E|x<<16,e[3]=q=65535&P|A<<16,P=65535&(T=Y),A=T>>>16,E=65535&(C=N),x=C>>>16,C=t[4],A+=(T=e[4])>>>16,E+=65535&C,x+=C>>>16,x+=(E+=(A+=(P+=65535&T)>>>16)>>>16)>>>16,t[4]=N=65535&E|x<<16,e[4]=Y=65535&P|A<<16,P=65535&(T=K),A=T>>>16,E=65535&(C=D),x=C>>>16,C=t[5],A+=(T=e[5])>>>16,E+=65535&C,x+=C>>>16,x+=(E+=(A+=(P+=65535&T)>>>16)>>>16)>>>16,t[5]=D=65535&E|x<<16,e[5]=K=65535&P|A<<16,P=65535&(T=$),A=T>>>16,E=65535&(C=j),x=C>>>16,C=t[6],A+=(T=e[6])>>>16,E+=65535&C,x+=C>>>16,x+=(E+=(A+=(P+=65535&T)>>>16)>>>16)>>>16,t[6]=j=65535&E|x<<16,e[6]=$=65535&P|A<<16,P=65535&(T=J),A=T>>>16,E=65535&(C=z),x=C>>>16,C=t[7],A+=(T=e[7])>>>16,E+=65535&C,x+=C>>>16,x+=(E+=(A+=(P+=65535&T)>>>16)>>>16)>>>16,t[7]=z=65535&E|x<<16,e[7]=J=65535&P|A<<16,W+=128,r-=128}return r}function V(t,e,n){var r,i=new Int32Array(8),s=new Int32Array(8),o=new Uint8Array(256),a=n;for(i[0]=1779033703,i[1]=3144134277,i[2]=1013904242,i[3]=2773480762,i[4]=1359893119,i[5]=2600822924,i[6]=528734635,i[7]=1541459225,s[0]=4089235720,s[1]=2227873595,s[2]=4271175723,s[3]=1595750129,s[4]=2917565137,s[5]=725511199,s[6]=4215389547,s[7]=327033209,G(i,s,e,n),n%=128,r=0;r=0;--i)Q(t,e,r=n[i/8|0]>>(7&i)&1),Z(e,t),Z(t,t),Q(t,e,r)}function nt(t,n){var r=[e(),e(),e(),e()];O(r[0],l),O(r[1],d),O(r[2],a),z(r[3],l,d),et(t,r,n)}function rt(t,n,i){var s,o=new Uint8Array(64),a=[e(),e(),e(),e()];for(i||r(n,32),V(o,n,32),o[0]&=248,o[31]&=127,o[31]|=64,nt(a,o),tt(t,a),s=0;s<32;s++)n[s+32]=t[s];return 0}var it=new Float64Array([237,211,245,92,26,99,18,88,214,156,247,162,222,249,222,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16]);function st(t,e){var n,r,i,s;for(r=63;r>=32;--r){for(n=0,i=r-32,s=r-12;i>4)*it[i],n=e[i]>>8,e[i]&=255;for(i=0;i<32;i++)e[i]-=n*it[i];for(r=0;r<32;r++)e[r+1]+=e[r]>>8,t[r]=255&e[r]}function ot(t){var e,n=new Float64Array(64);for(e=0;e<64;e++)n[e]=t[e];for(e=0;e<64;e++)t[e]=0;st(t,n)}function at(t,n,r,i){var s,o,a=new Uint8Array(64),h=new Uint8Array(64),c=new Uint8Array(64),u=new Float64Array(64),l=[e(),e(),e(),e()];V(a,i,32),a[0]&=248,a[31]&=127,a[31]|=64;var d=r+64;for(s=0;s>7&&j(t[0],o,t[0]),z(t[3],t[0],t[1]),0)}(d,i))return-1;for(s=0;s=0},t.sign.keyPair=function(){var t=new Uint8Array(32),e=new Uint8Array(64);return rt(t,e),{publicKey:t,secretKey:e}},t.sign.keyPair.fromSecretKey=function(t){if(ut(t),64!==t.length)throw new Error("bad secret key size");for(var e=new Uint8Array(32),n=0;n>>6)+r(128|63&e):r(224|e>>>12&15)+r(128|e>>>6&63)+r(128|63&e)},c=function(t){return t.replace(/[^\x00-\x7F]/g,h)},u=function(t){var e=[0,2,1][t.length%3],n=t.charCodeAt(0)<<16|(t.length>1?t.charCodeAt(1):0)<<8|(t.length>2?t.charCodeAt(2):0);return[i.charAt(n>>>18),i.charAt(n>>>12&63),e>=2?"=":i.charAt(n>>>6&63),e>=1?"=":i.charAt(63&n)].join("")},l=self.btoa||function(t){return t.replace(/[\s\S]{1,3}/g,u)};var d=class{constructor(t,e,n,r){this.clear=e,this.timer=t(()=>{this.timer&&(this.timer=r(this.timer))},n)}isRunning(){return null!==this.timer}ensureAborted(){this.timer&&(this.clear(this.timer),this.timer=null)}};function p(t){self.clearTimeout(t)}function f(t){self.clearInterval(t)}class g extends d{constructor(t,e){super(setTimeout,p,t,(function(t){return e(),null}))}}class b extends d{constructor(t,e){super(setInterval,f,t,(function(t){return e(),t}))}}var v={now:()=>Date.now?Date.now():(new Date).valueOf(),defer:t=>new g(0,t),method(t,...e){var n=Array.prototype.slice.call(arguments,1);return function(e){return e[t].apply(e,n.concat(arguments))}}};function y(t,...e){for(var n=0;ne!==t),this):(this.global_callbacks=[],this)}unbind_all(){return this.unbind(),this.unbind_global(),this}emit(t,e,n){for(var r=0;r0)for(r=0;r{self.console&&self.console.log&&self.console.log(t)}}debug(...t){this.log(this.globalLog,t)}warn(...t){this.log(this.globalLogWarn,t)}error(...t){this.log(this.globalLogError,t)}globalLogWarn(t){self.console&&self.console.warn?self.console.warn(t):this.globalLog(t)}globalLogError(t){self.console&&self.console.error?self.console.error(t):this.globalLogWarn(t)}log(t,...e){var n=m.apply(this,arguments);if(Ue.log)Ue.log(n);else if(Ue.logToConsole){t.bind(this)(n)}}};class B extends j{constructor(t,e,n,r,i){super(),this.initialize=ae.transportConnectionInitializer,this.hooks=t,this.name=e,this.priority=n,this.key=r,this.options=i,this.state="new",this.timeline=i.timeline,this.activityTimeout=i.activityTimeout,this.id=this.timeline.generateUniqueID()}handlesActivityChecks(){return Boolean(this.hooks.handlesActivityChecks)}supportsPing(){return Boolean(this.hooks.supportsPing)}connect(){if(this.socket||"initialized"!==this.state)return!1;var t=this.hooks.urls.getInitial(this.key,this.options);try{this.socket=this.hooks.getSocket(t,this.options)}catch(t){return v.defer(()=>{this.onError(t),this.changeState("closed")}),!1}return this.bindListeners(),z.debug("Connecting",{transport:this.name,url:t}),this.changeState("connecting"),!0}close(){return!!this.socket&&(this.socket.close(),!0)}send(t){return"open"===this.state&&(v.defer(()=>{this.socket&&this.socket.send(t)}),!0)}ping(){"open"===this.state&&this.supportsPing()&&this.socket.ping()}onOpen(){this.hooks.beforeOpen&&this.hooks.beforeOpen(this.socket,this.hooks.urls.getPath(this.key,this.options)),this.changeState("open"),this.socket.onopen=void 0}onError(t){this.emit("error",{type:"WebSocketError",error:t}),this.timeline.error(this.buildTimelineMessage({error:t.toString()}))}onClose(t){t?this.changeState("closed",{code:t.code,reason:t.reason,wasClean:t.wasClean}):this.changeState("closed"),this.unbindListeners(),this.socket=void 0}onMessage(t){this.emit("message",t)}onActivity(){this.emit("activity")}bindListeners(){this.socket.onopen=()=>{this.onOpen()},this.socket.onerror=t=>{this.onError(t)},this.socket.onclose=t=>{this.onClose(t)},this.socket.onmessage=t=>{this.onMessage(t)},this.supportsPing()&&(this.socket.onactivity=()=>{this.onActivity()})}unbindListeners(){this.socket&&(this.socket.onopen=void 0,this.socket.onerror=void 0,this.socket.onclose=void 0,this.socket.onmessage=void 0,this.supportsPing()&&(this.socket.onactivity=void 0))}changeState(t,e){this.state=t,this.timeline.info(this.buildTimelineMessage({state:t,params:e})),this.emit(t,e)}buildTimelineMessage(t){return y({cid:this.id},t)}}class H{constructor(t){this.hooks=t}isSupported(t){return this.hooks.isSupported(t)}createConnection(t,e,n,r){return new B(this.hooks,t,e,n,r)}}var F=new H({urls:M,handlesActivityChecks:!1,supportsPing:!1,isInitialized:function(){return Boolean(ae.getWebSocketAPI())},isSupported:function(){return Boolean(ae.getWebSocketAPI())},getSocket:function(t){return ae.createWebSocket(t)}}),q={urls:I,handlesActivityChecks:!1,supportsPing:!0,isInitialized:function(){return!0}},Y=y({getSocket:function(t){return ae.HTTPFactory.createStreamingSocket(t)}},q),K=y({getSocket:function(t){return ae.HTTPFactory.createPollingSocket(t)}},q),$={isSupported:function(){return ae.isXHRSupported()}},J={ws:F,xhr_streaming:new H(y({},Y,$)),xhr_polling:new H(y({},K,$))};class W{constructor(t,e,n){this.manager=t,this.transport=e,this.minPingDelay=n.minPingDelay,this.maxPingDelay=n.maxPingDelay,this.pingDelay=void 0}createConnection(t,e,n,r){r=y({},r,{activityTimeout:this.pingDelay});var i=this.transport.createConnection(t,e,n,r),s=null,o=function(){i.unbind("open",o),i.bind("closed",a),s=v.now()},a=t=>{if(i.unbind("closed",a),1002===t.code||1003===t.code)this.manager.reportDeath();else if(!t.wasClean&&s){var e=v.now()-s;e<2*this.maxPingDelay&&(this.manager.reportDeath(),this.pingDelay=Math.max(e/2,this.minPingDelay))}};return i.bind("open",o),i}isSupported(t){return this.manager.isAlive()&&this.transport.isSupported(t)}}const X={decodeMessage:function(t){try{var e=JSON.parse(t.data),n=e.data;if("string"==typeof n)try{n=JSON.parse(e.data)}catch(t){}var r={event:e.event,channel:e.channel,data:n};return e.user_id&&(r.user_id=e.user_id),r}catch(e){throw{type:"MessageParseError",error:e,data:t.data}}},encodeMessage:function(t){return JSON.stringify(t)},processHandshake:function(t){var e=X.decodeMessage(t);if("pusher:connection_established"===e.event){if(!e.data.activity_timeout)throw"No activity timeout specified in handshake";return{action:"connected",id:e.data.socket_id,activityTimeout:1e3*e.data.activity_timeout}}if("pusher:error"===e.event)return{action:this.getCloseAction(e.data),error:this.getCloseError(e.data)};throw"Invalid handshake"},getCloseAction:function(t){return t.code<4e3?t.code>=1002&&t.code<=1004?"backoff":null:4e3===t.code?"tls_only":t.code<4100?"refused":t.code<4200?"backoff":t.code<4300?"retry":"refused"},getCloseError:function(t){return 1e3!==t.code&&1001!==t.code?{type:"PusherError",data:{code:t.code,message:t.reason||t.message}}:null}};var G=X;class V extends j{constructor(t,e){super(),this.id=t,this.transport=e,this.activityTimeout=e.activityTimeout,this.bindListeners()}handlesActivityChecks(){return this.transport.handlesActivityChecks()}send(t){return this.transport.send(t)}send_event(t,e,n){var r={event:t,data:e};return n&&(r.channel=n),z.debug("Event sent",r),this.send(G.encodeMessage(r))}ping(){this.transport.supportsPing()?this.transport.ping():this.send_event("pusher:ping",{})}close(){this.transport.close()}bindListeners(){var t={message:t=>{var e;try{e=G.decodeMessage(t)}catch(e){this.emit("error",{type:"MessageParseError",error:e,data:t.data})}if(void 0!==e){switch(z.debug("Event recd",e),e.event){case"pusher:error":this.emit("error",{type:"PusherError",data:e.data});break;case"pusher:ping":this.emit("ping");break;case"pusher:pong":this.emit("pong")}this.emit("message",e)}},activity:()=>{this.emit("activity")},error:t=>{this.emit("error",t)},closed:t=>{e(),t&&t.code&&this.handleCloseEvent(t),this.transport=null,this.emit("closed")}},e=()=>{_(t,(t,e)=>{this.transport.unbind(e,t)})};_(t,(t,e)=>{this.transport.bind(e,t)})}handleCloseEvent(t){var e=G.getCloseAction(t),n=G.getCloseError(t);n&&this.emit("error",n),e&&this.emit(e,{action:e,error:n})}}class Z{constructor(t,e){this.transport=t,this.callback=e,this.bindListeners()}close(){this.unbindListeners(),this.transport.close()}bindListeners(){this.onMessage=t=>{var e;this.unbindListeners();try{e=G.processHandshake(t)}catch(t){return this.finish("error",{error:t}),void this.transport.close()}"connected"===e.action?this.finish("connected",{connection:new V(e.id,this.transport),activityTimeout:e.activityTimeout}):(this.finish(e.action,{error:e.error}),this.transport.close())},this.onClosed=t=>{this.unbindListeners();var e=G.getCloseAction(t)||"backoff",n=G.getCloseError(t);this.finish(e,{error:n})},this.transport.bind("message",this.onMessage),this.transport.bind("closed",this.onClosed)}unbindListeners(){this.transport.unbind("message",this.onMessage),this.transport.unbind("closed",this.onClosed)}finish(t,e){this.callback(y({transport:this.transport,action:t},e))}}class Q{constructor(t,e){this.timeline=t,this.options=e||{}}send(t,e){this.timeline.isEmpty()||this.timeline.send(ae.TimelineTransport.getAgent(this,t),e)}}class tt extends Error{constructor(t){super(t),Object.setPrototypeOf(this,new.target.prototype)}}class et extends Error{constructor(t){super(t),Object.setPrototypeOf(this,new.target.prototype)}}Error;class nt extends Error{constructor(t){super(t),Object.setPrototypeOf(this,new.target.prototype)}}class rt extends Error{constructor(t){super(t),Object.setPrototypeOf(this,new.target.prototype)}}class it extends Error{constructor(t){super(t),Object.setPrototypeOf(this,new.target.prototype)}}class st extends Error{constructor(t){super(t),Object.setPrototypeOf(this,new.target.prototype)}}class ot extends Error{constructor(t){super(t),Object.setPrototypeOf(this,new.target.prototype)}}class at extends Error{constructor(t,e){super(e),this.status=t,Object.setPrototypeOf(this,new.target.prototype)}}const ht={baseUrl:"https://pusher.com",urls:{authenticationEndpoint:{path:"/docs/channels/server_api/authenticating_users"},authorizationEndpoint:{path:"/docs/channels/server_api/authorizing-users/"},javascriptQuickStart:{path:"/docs/javascript_quick_start"},triggeringClientEvents:{path:"/docs/client_api_guide/client_events#trigger-events"},encryptedChannelSupport:{fullUrl:"https://github.com/pusher/pusher-js/tree/cc491015371a4bde5743d1c87a0fbac0feb53195#encrypted-channel-support"}}};var ct=function(t){const e=ht.urls[t];if(!e)return"";let n;return e.fullUrl?n=e.fullUrl:e.path&&(n=ht.baseUrl+e.path),n?"See: "+n:""};class ut extends j{constructor(t,e){super((function(e,n){z.debug("No callbacks on "+t+" for "+e)})),this.name=t,this.pusher=e,this.subscribed=!1,this.subscriptionPending=!1,this.subscriptionCancelled=!1}authorize(t,e){return e(null,{auth:""})}trigger(t,e){if(0!==t.indexOf("client-"))throw new tt("Event '"+t+"' does not start with 'client-'");if(!this.subscribed){var n=ct("triggeringClientEvents");z.warn("Client event triggered before channel 'subscription_succeeded' event . "+n)}return this.pusher.send_event(t,e,this.name)}disconnect(){this.subscribed=!1,this.subscriptionPending=!1}handleEvent(t){var e=t.event,n=t.data;if("pusher_internal:subscription_succeeded"===e)this.handleSubscriptionSucceededEvent(t);else if("pusher_internal:subscription_count"===e)this.handleSubscriptionCountEvent(t);else if(0!==e.indexOf("pusher_internal:")){this.emit(e,n,{})}}handleSubscriptionSucceededEvent(t){this.subscriptionPending=!1,this.subscribed=!0,this.subscriptionCancelled?this.pusher.unsubscribe(this.name):this.emit("pusher:subscription_succeeded",t.data)}handleSubscriptionCountEvent(t){t.data.subscription_count&&(this.subscriptionCount=t.data.subscription_count),this.emit("pusher:subscription_count",t.data)}subscribe(){this.subscribed||(this.subscriptionPending=!0,this.subscriptionCancelled=!1,this.authorize(this.pusher.connection.socket_id,(t,e)=>{t?(this.subscriptionPending=!1,z.error(t.toString()),this.emit("pusher:subscription_error",Object.assign({},{type:"AuthError",error:t.message},t instanceof at?{status:t.status}:{}))):this.pusher.send_event("pusher:subscribe",{auth:e.auth,channel_data:e.channel_data,channel:this.name})}))}unsubscribe(){this.subscribed=!1,this.pusher.send_event("pusher:unsubscribe",{channel:this.name})}cancelSubscription(){this.subscriptionCancelled=!0}reinstateSubscription(){this.subscriptionCancelled=!1}}class lt extends ut{authorize(t,e){return this.pusher.config.channelAuthorizer({channelName:this.name,socketId:t},e)}}class dt{constructor(){this.reset()}get(t){return Object.prototype.hasOwnProperty.call(this.members,t)?{id:t,info:this.members[t]}:null}each(t){_(this.members,(e,n)=>{t(this.get(n))})}setMyID(t){this.myID=t}onSubscription(t){this.members=t.presence.hash,this.count=t.presence.count,this.me=this.get(this.myID)}addMember(t){return null===this.get(t.user_id)&&this.count++,this.members[t.user_id]=t.user_info,this.get(t.user_id)}removeMember(t){var e=this.get(t.user_id);return e&&(delete this.members[t.user_id],this.count--),e}reset(){this.members={},this.count=0,this.myID=null,this.me=null}}var pt=function(t,e,n,r){return new(n||(n=Promise))((function(i,s){function o(t){try{h(r.next(t))}catch(t){s(t)}}function a(t){try{h(r.throw(t))}catch(t){s(t)}}function h(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(o,a)}h((r=r.apply(t,e||[])).next())}))};class ft extends lt{constructor(t,e){super(t,e),this.members=new dt}authorize(t,e){super.authorize(t,(t,n)=>pt(this,void 0,void 0,(function*(){if(!t)if(null!=(n=n).channel_data){var r=JSON.parse(n.channel_data);this.members.setMyID(r.user_id)}else{if(yield this.pusher.user.signinDonePromise,null==this.pusher.user.user_data){let t=ct("authorizationEndpoint");return z.error(`Invalid auth response for channel '${this.name}', expected 'channel_data' field. ${t}, or the user should be signed in.`),void e("Invalid auth response")}this.members.setMyID(this.pusher.user.user_data.id)}e(t,n)})))}handleEvent(t){var e=t.event;if(0===e.indexOf("pusher_internal:"))this.handleInternalEvent(t);else{var n=t.data,r={};t.user_id&&(r.user_id=t.user_id),this.emit(e,n,r)}}handleInternalEvent(t){var e=t.event,n=t.data;switch(e){case"pusher_internal:subscription_succeeded":this.handleSubscriptionSucceededEvent(t);break;case"pusher_internal:subscription_count":this.handleSubscriptionCountEvent(t);break;case"pusher_internal:member_added":var r=this.members.addMember(n);this.emit("pusher:member_added",r);break;case"pusher_internal:member_removed":var i=this.members.removeMember(n);i&&this.emit("pusher:member_removed",i)}}handleSubscriptionSucceededEvent(t){this.subscriptionPending=!1,this.subscribed=!0,this.subscriptionCancelled?this.pusher.unsubscribe(this.name):(this.members.onSubscription(t.data),this.emit("pusher:subscription_succeeded",this.members))}disconnect(){this.members.reset(),super.disconnect()}}var gt=n(1),bt=n(0);class vt extends lt{constructor(t,e,n){super(t,e),this.key=null,this.nacl=n}authorize(t,e){super.authorize(t,(t,n)=>{if(t)return void e(t,n);let r=n.shared_secret;r?(this.key=Object(bt.decode)(r),delete n.shared_secret,e(null,n)):e(new Error("No shared_secret key in auth payload for encrypted channel: "+this.name),null)})}trigger(t,e){throw new it("Client events are not currently supported for encrypted channels")}handleEvent(t){var e=t.event,n=t.data;0!==e.indexOf("pusher_internal:")&&0!==e.indexOf("pusher:")?this.handleEncryptedEvent(e,n):super.handleEvent(t)}handleEncryptedEvent(t,e){if(!this.key)return void z.debug("Received encrypted event before key has been retrieved from the authEndpoint");if(!e.ciphertext||!e.nonce)return void z.error("Unexpected format for encrypted event, expected object with `ciphertext` and `nonce` fields, got: "+e);let n=Object(bt.decode)(e.ciphertext);if(n.length{e?z.error(`Failed to make a request to the authEndpoint: ${s}. Unable to fetch new key, so dropping encrypted event`):(i=this.nacl.secretbox.open(n,r,this.key),null!==i?this.emit(t,this.getDataToEmit(i)):z.error("Failed to decrypt event with new key. Dropping encrypted event"))});this.emit(t,this.getDataToEmit(i))}getDataToEmit(t){let e=Object(gt.decode)(t);try{return JSON.parse(e)}catch(t){return e}}}class yt extends j{constructor(t,e){super(),this.state="initialized",this.connection=null,this.key=t,this.options=e,this.timeline=this.options.timeline,this.usingTLS=this.options.useTLS,this.errorCallbacks=this.buildErrorCallbacks(),this.connectionCallbacks=this.buildConnectionCallbacks(this.errorCallbacks),this.handshakeCallbacks=this.buildHandshakeCallbacks(this.errorCallbacks);var n=ae.getNetwork();n.bind("online",()=>{this.timeline.info({netinfo:"online"}),"connecting"!==this.state&&"unavailable"!==this.state||this.retryIn(0)}),n.bind("offline",()=>{this.timeline.info({netinfo:"offline"}),this.connection&&this.sendActivityCheck()}),this.updateStrategy()}switchCluster(t){this.key=t,this.updateStrategy(),this.retryIn(0)}connect(){this.connection||this.runner||(this.strategy.isSupported()?(this.updateState("connecting"),this.startConnecting(),this.setUnavailableTimer()):this.updateState("failed"))}send(t){return!!this.connection&&this.connection.send(t)}send_event(t,e,n){return!!this.connection&&this.connection.send_event(t,e,n)}disconnect(){this.disconnectInternally(),this.updateState("disconnected")}isUsingTLS(){return this.usingTLS}startConnecting(){var t=(e,n)=>{e?this.runner=this.strategy.connect(0,t):"error"===n.action?(this.emit("error",{type:"HandshakeError",error:n.error}),this.timeline.error({handshakeError:n.error})):(this.abortConnecting(),this.handshakeCallbacks[n.action](n))};this.runner=this.strategy.connect(0,t)}abortConnecting(){this.runner&&(this.runner.abort(),this.runner=null)}disconnectInternally(){(this.abortConnecting(),this.clearRetryTimer(),this.clearUnavailableTimer(),this.connection)&&this.abandonConnection().close()}updateStrategy(){this.strategy=this.options.getStrategy({key:this.key,timeline:this.timeline,useTLS:this.usingTLS})}retryIn(t){this.timeline.info({action:"retry",delay:t}),t>0&&this.emit("connecting_in",Math.round(t/1e3)),this.retryTimer=new g(t||0,()=>{this.disconnectInternally(),this.connect()})}clearRetryTimer(){this.retryTimer&&(this.retryTimer.ensureAborted(),this.retryTimer=null)}setUnavailableTimer(){this.unavailableTimer=new g(this.options.unavailableTimeout,()=>{this.updateState("unavailable")})}clearUnavailableTimer(){this.unavailableTimer&&this.unavailableTimer.ensureAborted()}sendActivityCheck(){this.stopActivityCheck(),this.connection.ping(),this.activityTimer=new g(this.options.pongTimeout,()=>{this.timeline.error({pong_timed_out:this.options.pongTimeout}),this.retryIn(0)})}resetActivityCheck(){this.stopActivityCheck(),this.connection&&!this.connection.handlesActivityChecks()&&(this.activityTimer=new g(this.activityTimeout,()=>{this.sendActivityCheck()}))}stopActivityCheck(){this.activityTimer&&this.activityTimer.ensureAborted()}buildConnectionCallbacks(t){return y({},t,{message:t=>{this.resetActivityCheck(),this.emit("message",t)},ping:()=>{this.send_event("pusher:pong",{})},activity:()=>{this.resetActivityCheck()},error:t=>{this.emit("error",t)},closed:()=>{this.abandonConnection(),this.shouldRetry()&&this.retryIn(1e3)}})}buildHandshakeCallbacks(t){return y({},t,{connected:t=>{this.activityTimeout=Math.min(this.options.activityTimeout,t.activityTimeout,t.connection.activityTimeout||1/0),this.clearUnavailableTimer(),this.setConnection(t.connection),this.socket_id=this.connection.id,this.updateState("connected",{socket_id:this.socket_id})}})}buildErrorCallbacks(){let t=t=>e=>{e.error&&this.emit("error",{type:"WebSocketError",error:e.error}),t(e)};return{tls_only:t(()=>{this.usingTLS=!0,this.updateStrategy(),this.retryIn(0)}),refused:t(()=>{this.disconnect()}),backoff:t(()=>{this.retryIn(1e3)}),retry:t(()=>{this.retryIn(0)})}}setConnection(t){for(var e in this.connection=t,this.connectionCallbacks)this.connection.bind(e,this.connectionCallbacks[e]);this.resetActivityCheck()}abandonConnection(){if(this.connection){for(var t in this.stopActivityCheck(),this.connectionCallbacks)this.connection.unbind(t,this.connectionCallbacks[t]);var e=this.connection;return this.connection=null,e}}updateState(t,e){var n=this.state;if(this.state=t,n!==t){var r=t;"connected"===r&&(r+=" with new socket ID "+e.socket_id),z.debug("State changed",n+" -> "+r),this.timeline.info({state:t,params:e}),this.emit("state_change",{previous:n,current:t}),this.emit(t,e)}}shouldRetry(){return"connecting"===this.state||"connected"===this.state}}class mt{constructor(){this.channels={}}add(t,e){return this.channels[t]||(this.channels[t]=function(t,e){if(0===t.indexOf("private-encrypted-")){if(e.config.nacl)return wt.createEncryptedChannel(t,e,e.config.nacl);let n="Tried to subscribe to a private-encrypted- channel but no nacl implementation available",r=ct("encryptedChannelSupport");throw new it(`${n}. ${r}`)}if(0===t.indexOf("private-"))return wt.createPrivateChannel(t,e);if(0===t.indexOf("presence-"))return wt.createPresenceChannel(t,e);if(0===t.indexOf("#"))throw new et('Cannot create a channel with name "'+t+'".');return wt.createChannel(t,e)}(t,e)),this.channels[t]}all(){return function(t){var e=[];return _(t,(function(t){e.push(t)})),e}(this.channels)}find(t){return this.channels[t]}remove(t){var e=this.channels[t];return delete this.channels[t],e}disconnect(){_(this.channels,(function(t){t.disconnect()}))}}var wt={createChannels:()=>new mt,createConnectionManager:(t,e)=>new yt(t,e),createChannel:(t,e)=>new ut(t,e),createPrivateChannel:(t,e)=>new lt(t,e),createPresenceChannel:(t,e)=>new ft(t,e),createEncryptedChannel:(t,e,n)=>new vt(t,e,n),createTimelineSender:(t,e)=>new Q(t,e),createHandshake:(t,e)=>new Z(t,e),createAssistantToTheTransportManager:(t,e,n)=>new W(t,e,n)};class _t{constructor(t){this.options=t||{},this.livesLeft=this.options.lives||1/0}getAssistant(t){return wt.createAssistantToTheTransportManager(this,t,{minPingDelay:this.options.minPingDelay,maxPingDelay:this.options.maxPingDelay})}isAlive(){return this.livesLeft>0}reportDeath(){this.livesLeft-=1}}class St{constructor(t,e){this.strategies=t,this.loop=Boolean(e.loop),this.failFast=Boolean(e.failFast),this.timeout=e.timeout,this.timeoutLimit=e.timeoutLimit}isSupported(){return A(this.strategies,v.method("isSupported"))}connect(t,e){var n=this.strategies,r=0,i=this.timeout,s=null,o=(a,h)=>{h?e(null,h):(r+=1,this.loop&&(r%=n.length),r0&&(i=new g(n.timeout,(function(){s.abort(),r(!0)}))),s=t.connect(e,(function(t,e){t&&i&&i.isRunning()&&!n.failFast||(i&&i.ensureAborted(),r(t,e))})),{abort:function(){i&&i.ensureAborted(),s.abort()},forceMinPriority:function(t){s.forceMinPriority(t)}}}}class kt{constructor(t){this.strategies=t}isSupported(){return A(this.strategies,v.method("isSupported"))}connect(t,e){return function(t,e,n){var r=C(t,(function(t,r,i,s){return t.connect(e,n(r,s))}));return{abort:function(){k(r,Ct)},forceMinPriority:function(t){k(r,(function(e){e.forceMinPriority(t)}))}}}(this.strategies,t,(function(t,n){return function(r,i){n[t].error=r,r?function(t){return function(t,e){for(var n=0;n=v.now()){var o=this.transports[r.transport];o&&(["ws","wss"].includes(r.transport)||i>3?(this.timeline.info({cached:!0,transport:r.transport,latency:r.latency}),s.push(new St([o],{timeout:2*r.latency+1e3,failFast:!0}))):i++)}var a=v.now(),h=s.pop().connect(t,(function r(o,c){o?(At(n),s.length>0?(a=v.now(),h=s.pop().connect(t,r)):e(o)):(!function(t,e,n,r){var i=ae.getLocalStorage();if(i)try{i[Pt(t)]=O({timestamp:v.now(),transport:e,latency:n,cacheSkipCount:r})}catch(t){}}(n,c.transport.name,v.now()-a,i),e(null,c))}));return{abort:function(){h.abort()},forceMinPriority:function(e){t=e,h&&h.forceMinPriority(e)}}}}function Pt(t){return"pusherTransport"+(t?"TLS":"NonTLS")}function At(t){var e=ae.getLocalStorage();if(e)try{delete e[Pt(t)]}catch(t){}}class Et{constructor(t,{delay:e}){this.strategy=t,this.options={delay:e}}isSupported(){return this.strategy.isSupported()}connect(t,e){var n,r=this.strategy,i=new g(this.options.delay,(function(){n=r.connect(t,e)}));return{abort:function(){i.ensureAborted(),n&&n.abort()},forceMinPriority:function(e){t=e,n&&n.forceMinPriority(e)}}}}class xt{constructor(t,e,n){this.test=t,this.trueBranch=e,this.falseBranch=n}isSupported(){return(this.test()?this.trueBranch:this.falseBranch).isSupported()}connect(t,e){return(this.test()?this.trueBranch:this.falseBranch).connect(t,e)}}class Ot{constructor(t){this.strategy=t}isSupported(){return this.strategy.isSupported()}connect(t,e){var n=this.strategy.connect(t,(function(t,r){r&&n.abort(),e(t,r)}));return n}}function Lt(t){return function(){return t.isSupported()}}var Ut=function(t,e,n){var r={};function i(e,i,s,o,a){var h=n(t,e,i,s,o,a);return r[e]=h,h}var s,o=Object.assign({},e,{hostNonTLS:t.wsHost+":"+t.wsPort,hostTLS:t.wsHost+":"+t.wssPort,httpPath:t.wsPath}),a=y({},o,{useTLS:!0}),h=Object.assign({},e,{hostNonTLS:t.httpHost+":"+t.httpPort,hostTLS:t.httpHost+":"+t.httpsPort,httpPath:t.httpPath}),c={loop:!0,timeout:15e3,timeoutLimit:6e4},u=new _t({minPingDelay:1e4,maxPingDelay:t.activityTimeout}),l=new _t({lives:2,minPingDelay:1e4,maxPingDelay:t.activityTimeout}),d=i("ws","ws",3,o,u),p=i("wss","ws",3,a,u),f=i("xhr_streaming","xhr_streaming",1,h,l),g=i("xhr_polling","xhr_polling",1,h),b=new St([d],c),v=new St([p],c),m=new St([f],c),w=new St([g],c),_=new St([new xt(Lt(m),new kt([m,new Et(w,{delay:4e3})]),w)],c);return s=e.useTLS?new kt([b,new Et(_,{delay:2e3})]):new kt([b,new Et(v,{delay:2e3}),new Et(_,{delay:5e3})]),new Tt(new Ot(new xt(Lt(d),s,_)),r,{ttl:18e5,timeline:e.timeline,useTLS:e.useTLS})};class Rt extends j{constructor(t,e,n){super(),this.hooks=t,this.method=e,this.url=n}start(t){this.position=0,this.xhr=this.hooks.getRequest(this),this.unloader=()=>{this.close()},ae.addUnloadListener(this.unloader),this.xhr.open(this.method,this.url,!0),this.xhr.setRequestHeader&&this.xhr.setRequestHeader("Content-Type","application/json"),this.xhr.send(t)}close(){this.unloader&&(ae.removeUnloadListener(this.unloader),this.unloader=null),this.xhr&&(this.hooks.abortRequest(this.xhr),this.xhr=null)}onChunk(t,e){for(;;){var n=this.advanceBuffer(e);if(!n)break;this.emit("chunk",{status:t,data:n})}this.isBufferTooLong(e)&&this.emit("buffer_too_long")}advanceBuffer(t){var e=t.slice(this.position),n=e.indexOf("\n");return-1!==n?(this.position+=n+1,e.slice(0,n)):null}isBufferTooLong(t){return this.position===t.length&&t.length>262144}}var Mt;!function(t){t[t.CONNECTING=0]="CONNECTING",t[t.OPEN=1]="OPEN",t[t.CLOSED=3]="CLOSED"}(Mt||(Mt={}));var It=Mt,Nt=1;function Dt(t){var e=-1===t.indexOf("?")?"?":"&";return t+e+"t="+ +new Date+"&n="+Nt++}function jt(t){return ae.randomInt(t)}var zt=class{constructor(t,e){this.hooks=t,this.session=jt(1e3)+"/"+function(t){for(var e=[],n=0;n{this.onChunk(t)}),this.stream.bind("finished",t=>{this.hooks.onFinished(this,t)}),this.stream.bind("buffer_too_long",()=>{this.reconnect()});try{this.stream.start()}catch(t){v.defer(()=>{this.onError(t),this.onClose(1006,"Could not start streaming",!1)})}}closeStream(){this.stream&&(this.stream.unbind_all(),this.stream.close(),this.stream=null)}},Bt={getReceiveURL:function(t,e){return t.base+"/"+e+"/xhr_streaming"+t.queryString},onHeartbeat:function(t){t.sendRaw("[]")},sendHeartbeat:function(t){t.sendRaw("[]")},onFinished:function(t,e){t.onClose(1006,"Connection interrupted ("+e+")",!1)}},Ht={getReceiveURL:function(t,e){return t.base+"/"+e+"/xhr"+t.queryString},onHeartbeat:function(){},sendHeartbeat:function(t){t.sendRaw("[]")},onFinished:function(t,e){200===e?t.reconnect():t.onClose(1006,"Connection interrupted ("+e+")",!1)}},Ft={getRequest:function(t){var e=new(ae.getXHRAPI());return e.onreadystatechange=e.onprogress=function(){switch(e.readyState){case 3:e.responseText&&e.responseText.length>0&&t.onChunk(e.status,e.responseText);break;case 4:e.responseText&&e.responseText.length>0&&t.onChunk(e.status,e.responseText),t.emit("finished",e.status),t.close()}},e},abortRequest:function(t){t.onreadystatechange=null,t.abort()}},qt={getDefaultStrategy:Ut,Transports:J,transportConnectionInitializer:function(){this.timeline.info(this.buildTimelineMessage({transport:this.name+(this.options.useTLS?"s":"")})),this.hooks.isInitialized()?this.changeState("initialized"):this.onClose()},HTTPFactory:{createStreamingSocket(t){return this.createSocket(Bt,t)},createPollingSocket(t){return this.createSocket(Ht,t)},createSocket:(t,e)=>new zt(t,e),createXHR(t,e){return this.createRequest(Ft,t,e)},createRequest:(t,e,n)=>new Rt(t,e,n)},setup(t){t.ready()},getLocalStorage(){},getClientFeatures:()=>S(P({ws:J.ws},(function(t){return t.isSupported({})}))),getProtocol:()=>"http:",isXHRSupported:()=>!0,createSocketRequest(t,e){if(this.isXHRSupported())return this.HTTPFactory.createXHR(t,e);throw"Cross-origin HTTP requests are not supported"},createXHR(){return new(this.getXHRAPI())},createWebSocket(t){return new(this.getWebSocketAPI())(t)},addUnloadListener(t){},removeUnloadListener(t){}};var Yt=new class extends j{isOnline(){return!0}},Kt=function(t,e,n,r,i){var s=new Headers;for(var o in s.set("Content-Type","application/x-www-form-urlencoded"),n.headers)s.set(o,n.headers[o]);if(null!=n.headersProvider){const t=n.headersProvider();for(var o in t)s.set(o,t[o])}var a=e,h=new Request(n.endpoint,{headers:s,body:a,credentials:"same-origin",method:"POST"});return fetch(h).then(t=>{let{status:e}=t;if(200===e)return t.text();throw new at(e,`Could not get ${r.toString()} info from your auth endpoint, status: ${e}`)}).then(t=>{let e;try{e=JSON.parse(t)}catch(e){throw new at(200,`JSON returned from ${r.toString()} endpoint was invalid, yet status code was 200. Data was: ${t}`)}i(null,e)}).catch(t=>{i(t,null)})},$t={name:"xhr",getAgent:function(t,e){return function(n,r){var i="http"+(e?"s":"")+"://"+(t.host||t.options.host)+t.options.path,s=x(n);fetch(i+="/2?"+s).then(t=>{if(200!==t.status)throw`received ${t.status} from stats.pusher.com`;return t.json()}).then(({host:e})=>{e&&(t.host=e)}).catch(t=>{z.debug("TimelineSender Error: ",t)})}}};const{getDefaultStrategy:Jt,Transports:Wt,setup:Xt,getProtocol:Gt,isXHRSupported:Vt,getLocalStorage:Zt,createXHR:Qt,createWebSocket:te,addUnloadListener:ee,removeUnloadListener:ne,transportConnectionInitializer:re,createSocketRequest:ie,HTTPFactory:se}=qt;var oe,ae={getDefaultStrategy:Jt,Transports:Wt,setup:Xt,getProtocol:Gt,isXHRSupported:Vt,getLocalStorage:Zt,createXHR:Qt,createWebSocket:te,addUnloadListener:ee,removeUnloadListener:ne,transportConnectionInitializer:re,createSocketRequest:ie,HTTPFactory:se,TimelineTransport:$t,getAuthorizers:()=>({ajax:Kt}),getWebSocketAPI:()=>WebSocket,getXHRAPI:()=>XMLHttpRequest,getNetwork:()=>Yt,randomInt:t=>Math.floor((globalThis.crypto||globalThis.msCrypto).getRandomValues(new Uint32Array(1))[0]/Math.pow(2,32)*t)};!function(t){t[t.ERROR=3]="ERROR",t[t.INFO=6]="INFO",t[t.DEBUG=7]="DEBUG"}(oe||(oe={}));var he=oe;class ce{constructor(t,e,n){this.key=t,this.session=e,this.events=[],this.options=n||{},this.sent=0,this.uniqueID=0}log(t,e){t<=this.options.level&&(this.events.push(y({},e,{timestamp:v.now()})),this.options.limit&&this.events.length>this.options.limit&&this.events.shift())}error(t){this.log(he.ERROR,t)}info(t){this.log(he.INFO,t)}debug(t){this.log(he.DEBUG,t)}isEmpty(){return 0===this.events.length}send(t,e){var n=y({session:this.session,bundle:this.sent+1,key:this.key,lib:"js",version:this.options.version,cluster:this.options.cluster,features:this.options.features,timeline:this.events},this.options.params);return this.events=[],t(n,(t,n)=>{t||this.sent++,e&&e(t,n)}),!0}generateUniqueID(){return this.uniqueID++,this.uniqueID}}class ue{constructor(t,e,n,r){this.name=t,this.priority=e,this.transport=n,this.options=r||{}}isSupported(){return this.transport.isSupported({useTLS:this.options.useTLS})}connect(t,e){if(!this.isSupported())return le(new ot,e);if(this.priority{n||(c(),i?i.close():r.close())},forceMinPriority:t=>{n||this.priority{if(void 0===ae.getAuthorizers()[t.transport])throw`'${t.transport}' is not a recognized auth transport`;return(e,n)=>{const r=((t,e)=>{var n="socket_id="+encodeURIComponent(t.socketId);for(var r in e.params)n+="&"+encodeURIComponent(r)+"="+encodeURIComponent(e.params[r]);if(null!=e.paramsProvider){let t=e.paramsProvider();for(var r in t)n+="&"+encodeURIComponent(r)+"="+encodeURIComponent(t[r])}return n})(e,t);ae.getAuthorizers()[t.transport](ae,r,t,pe.UserAuthentication,n)}};var ye=t=>{if(void 0===ae.getAuthorizers()[t.transport])throw`'${t.transport}' is not a recognized auth transport`;return(e,n)=>{const r=((t,e)=>{var n="socket_id="+encodeURIComponent(t.socketId);for(var r in n+="&channel_name="+encodeURIComponent(t.channelName),e.params)n+="&"+encodeURIComponent(r)+"="+encodeURIComponent(e.params[r]);if(null!=e.paramsProvider){let t=e.paramsProvider();for(var r in t)n+="&"+encodeURIComponent(r)+"="+encodeURIComponent(t[r])}return n})(e,t);ae.getAuthorizers()[t.transport](ae,r,t,pe.ChannelAuthorization,n)}};const me=(t,e,n)=>{const r={authTransport:e.transport,authEndpoint:e.endpoint,auth:{params:e.params,headers:e.headers}};return(e,i)=>{const s=t.channel(e.channelName);n(s,r).authorize(e.socketId,i)}};function we(t,e){let n={activityTimeout:t.activityTimeout||L.activityTimeout,cluster:t.cluster,httpPath:t.httpPath||L.httpPath,httpPort:t.httpPort||L.httpPort,httpsPort:t.httpsPort||L.httpsPort,pongTimeout:t.pongTimeout||L.pongTimeout,statsHost:t.statsHost||L.stats_host,unavailableTimeout:t.unavailableTimeout||L.unavailableTimeout,wsPath:t.wsPath||L.wsPath,wsPort:t.wsPort||L.wsPort,wssPort:t.wssPort||L.wssPort,enableStats:Ce(t),httpHost:_e(t),useTLS:ke(t),wsHost:Se(t),userAuthenticator:Pe(t),channelAuthorizer:Ae(t,e)};return"disabledTransports"in t&&(n.disabledTransports=t.disabledTransports),"enabledTransports"in t&&(n.enabledTransports=t.enabledTransports),"ignoreNullOrigin"in t&&(n.ignoreNullOrigin=t.ignoreNullOrigin),"timelineParams"in t&&(n.timelineParams=t.timelineParams),"nacl"in t&&(n.nacl=t.nacl),n}function _e(t){return t.httpHost?t.httpHost:t.cluster?`sockjs-${t.cluster}.pusher.com`:L.httpHost}function Se(t){return t.wsHost?t.wsHost:`ws-${t.cluster}.pusher.com`}function ke(t){return"https:"===ae.getProtocol()||!1!==t.forceTLS}function Ce(t){return"enableStats"in t?t.enableStats:"disableStats"in t&&!t.disableStats}const Te=t=>"customHandler"in t&&null!=t.customHandler;function Pe(t){const e=Object.assign(Object.assign({},L.userAuthentication),t.userAuthentication);return Te(e)?e.customHandler:ve(e)}function Ae(t,e){const n=function(t,e){let n;if("channelAuthorization"in t)n=Object.assign(Object.assign({},L.channelAuthorization),t.channelAuthorization);else if(n={transport:t.authTransport||L.authTransport,endpoint:t.authEndpoint||L.authEndpoint},"auth"in t&&("params"in t.auth&&(n.params=t.auth.params),"headers"in t.auth&&(n.headers=t.auth.headers)),"authorizer"in t)return{customHandler:me(e,n,t.authorizer)};return n}(t,e);return Te(n)?n.customHandler:ye(n)}class Ee extends j{constructor(t){super((function(t,e){z.debug("No callbacks on watchlist events for "+t)})),this.pusher=t,this.bindWatchlistInternalEvent()}handleEvent(t){t.data.events.forEach(t=>{this.emit(t.name,t)})}bindWatchlistInternalEvent(){this.pusher.connection.bind("message",t=>{"pusher_internal:watchlist_events"===t.event&&this.handleEvent(t)})}}var xe=function(){let t,e;return{promise:new Promise((n,r)=>{t=n,e=r}),resolve:t,reject:e}};class Oe extends j{constructor(t){super((function(t,e){z.debug("No callbacks on user for "+t)})),this.signin_requested=!1,this.user_data=null,this.serverToUserChannel=null,this.signinDonePromise=null,this._signinDoneResolve=null,this._onAuthorize=(t,e)=>{if(t)return z.warn("Error during signin: "+t),void this._cleanup();this.pusher.send_event("pusher:signin",{auth:e.auth,user_data:e.user_data})},this.pusher=t,this.pusher.connection.bind("state_change",({previous:t,current:e})=>{"connected"!==t&&"connected"===e&&this._signin(),"connected"===t&&"connected"!==e&&(this._cleanup(),this._newSigninPromiseIfNeeded())}),this.watchlist=new Ee(t),this.pusher.connection.bind("message",t=>{"pusher:signin_success"===t.event&&this._onSigninSuccess(t.data),this.serverToUserChannel&&this.serverToUserChannel.name===t.channel&&this.serverToUserChannel.handleEvent(t)})}signin(){this.signin_requested||(this.signin_requested=!0,this._signin())}_signin(){this.signin_requested&&(this._newSigninPromiseIfNeeded(),"connected"===this.pusher.connection.state&&this.pusher.config.userAuthenticator({socketId:this.pusher.connection.socket_id},this._onAuthorize))}_onSigninSuccess(t){try{this.user_data=JSON.parse(t.user_data)}catch(e){return z.error("Failed parsing user data after signin: "+t.user_data),void this._cleanup()}if("string"!=typeof this.user_data.id||""===this.user_data.id)return z.error("user_data doesn't contain an id. user_data: "+this.user_data),void this._cleanup();this._signinDoneResolve(),this._subscribeChannels()}_subscribeChannels(){this.serverToUserChannel=new ut("#server-to-user-"+this.user_data.id,this.pusher),this.serverToUserChannel.bind_global((t,e)=>{0!==t.indexOf("pusher_internal:")&&0!==t.indexOf("pusher:")&&this.emit(t,e)}),(t=>{t.subscriptionPending&&t.subscriptionCancelled?t.reinstateSubscription():t.subscriptionPending||"connected"!==this.pusher.connection.state||t.subscribe()})(this.serverToUserChannel)}_cleanup(){this.user_data=null,this.serverToUserChannel&&(this.serverToUserChannel.unbind_all(),this.serverToUserChannel.disconnect(),this.serverToUserChannel=null),this.signin_requested&&this._signinDoneResolve()}_newSigninPromiseIfNeeded(){if(!this.signin_requested)return;if(this.signinDonePromise&&!this.signinDonePromise.done)return;const{promise:t,resolve:e,reject:n}=xe();t.done=!1;const r=()=>{t.done=!0};t.then(r).catch(r),this.signinDonePromise=t,this._signinDoneResolve=e}}class Le{static ready(){Le.isReady=!0;for(var t=0,e=Le.instances.length;tae.getDefaultStrategy(this.config,t,fe),timeline:this.timeline,activityTimeout:this.config.activityTimeout,pongTimeout:this.config.pongTimeout,unavailableTimeout:this.config.unavailableTimeout,useTLS:Boolean(this.config.useTLS)}),this.connection.bind("connected",()=>{this.subscribeAll(),this.timelineSender&&this.timelineSender.send(this.connection.isUsingTLS())}),this.connection.bind("message",t=>{var e=0===t.event.indexOf("pusher_internal:");if(t.channel){var n=this.channel(t.channel);n&&n.handleEvent(t)}e||this.global_emitter.emit(t.event,t.data)}),this.connection.bind("connecting",()=>{this.channels.disconnect()}),this.connection.bind("disconnected",()=>{this.channels.disconnect()}),this.connection.bind("error",t=>{z.warn(t)}),Le.instances.push(this),this.timeline.info({instances:Le.instances.length}),this.user=new Oe(this),Le.isReady&&this.connect()}switchCluster(t){const{appKey:e,cluster:n}=t;this.key=e,this.options=Object.assign(Object.assign({},this.options),{cluster:n}),this.config=we(this.options,this),this.connection.switchCluster(this.key)}channel(t){return this.channels.find(t)}allChannels(){return this.channels.all()}connect(){if(this.connection.connect(),this.timelineSender&&!this.timelineSenderTimer){var t=this.connection.isUsingTLS(),e=this.timelineSender;this.timelineSenderTimer=new b(6e4,(function(){e.send(t)}))}}disconnect(){this.connection.disconnect(),this.timelineSenderTimer&&(this.timelineSenderTimer.ensureAborted(),this.timelineSenderTimer=null)}bind(t,e,n){return this.global_emitter.bind(t,e,n),this}unbind(t,e,n){return this.global_emitter.unbind(t,e,n),this}bind_global(t){return this.global_emitter.bind_global(t),this}unbind_global(t){return this.global_emitter.unbind_global(t),this}unbind_all(t){return this.global_emitter.unbind_all(),this}subscribeAll(){var t;for(t in this.channels.channels)this.channels.channels.hasOwnProperty(t)&&this.subscribe(t)}subscribe(t){var e=this.channels.add(t,this);return e.subscriptionPending&&e.subscriptionCancelled?e.reinstateSubscription():e.subscriptionPending||"connected"!==this.connection.state||e.subscribe(),e}unsubscribe(t){var e=this.channels.find(t);e&&e.subscriptionPending?e.cancelSubscription():(e=this.channels.remove(t))&&e.subscribed&&e.unsubscribe()}send_event(t,e,n){return this.connection.send_event(t,e,n)}shouldUseTLS(){return this.config.useTLS}signin(){this.user.signin()}}Le.instances=[],Le.isReady=!1,Le.logToConsole=!1,Le.Runtime=ae,Le.ScriptReceivers=ae.ScriptReceivers,Le.DependenciesReceivers=ae.DependenciesReceivers,Le.auth_callbacks=ae.auth_callbacks;var Ue=Le;ae.setup(Le);var Re=n(2);class Me extends Ue{constructor(t,e){Ue.logToConsole=Me.logToConsole,Ue.log=Me.log,be(e),e.nacl=Re,super(t,e)}}}])})); //# sourceMappingURL=pusher-with-encryption.worker.min.js.map \ No newline at end of file diff --git a/dist/worker/pusher-with-encryption.worker.min.js.map b/dist/worker/pusher-with-encryption.worker.min.js.map index 3a198b0af..825a06235 100644 --- a/dist/worker/pusher-with-encryption.worker.min.js.map +++ b/dist/worker/pusher-with-encryption.worker.min.js.map @@ -1 +1 @@ -{"version":3,"sources":["webpack://Pusher/webpack/universalModuleDefinition","webpack://Pusher/webpack/bootstrap","webpack://Pusher/./node_modules/@stablelib/base64/base64.ts","webpack://Pusher/./node_modules/@stablelib/utf8/utf8.ts","webpack://Pusher/./node_modules/tweetnacl/nacl-fast.js","webpack://Pusher/./src/core/pusher-with-encryption.js","webpack://Pusher/./src/core/base64.ts","webpack://Pusher/./src/core/utils/timers/abstract_timer.ts","webpack://Pusher/./src/core/utils/timers/index.ts","webpack://Pusher/./src/core/util.ts","webpack://Pusher/./src/core/utils/collections.ts","webpack://Pusher/./src/core/defaults.ts","webpack://Pusher/./src/core/transports/url_schemes.ts","webpack://Pusher/./src/core/events/callback_registry.ts","webpack://Pusher/./src/core/events/dispatcher.ts","webpack://Pusher/./src/core/logger.ts","webpack://Pusher/./src/core/transports/transport_connection.ts","webpack://Pusher/./src/core/transports/transport.ts","webpack://Pusher/./src/runtimes/isomorphic/transports/transports.ts","webpack://Pusher/./src/core/transports/assistant_to_the_transport_manager.ts","webpack://Pusher/./src/core/connection/protocol/protocol.ts","webpack://Pusher/./src/core/connection/connection.ts","webpack://Pusher/./src/core/connection/handshake/index.ts","webpack://Pusher/./src/core/timeline/timeline_sender.ts","webpack://Pusher/./src/core/errors.ts","webpack://Pusher/./src/core/utils/url_store.ts","webpack://Pusher/./src/core/channels/channel.ts","webpack://Pusher/./src/core/channels/private_channel.ts","webpack://Pusher/./src/core/channels/members.ts","webpack://Pusher/./src/core/channels/presence_channel.ts","webpack://Pusher/./src/core/channels/encrypted_channel.ts","webpack://Pusher/./src/core/connection/connection_manager.ts","webpack://Pusher/./src/core/channels/channels.ts","webpack://Pusher/./src/core/utils/factory.ts","webpack://Pusher/./src/core/transports/transport_manager.ts","webpack://Pusher/./src/core/strategies/sequential_strategy.ts","webpack://Pusher/./src/core/strategies/best_connected_ever_strategy.ts","webpack://Pusher/./src/core/strategies/websocket_prioritized_cached_strategy.ts","webpack://Pusher/./src/core/strategies/delayed_strategy.ts","webpack://Pusher/./src/core/strategies/if_strategy.ts","webpack://Pusher/./src/core/strategies/first_connected_strategy.ts","webpack://Pusher/./src/runtimes/isomorphic/default_strategy.ts","webpack://Pusher/./src/core/http/http_request.ts","webpack://Pusher/./src/core/http/state.ts","webpack://Pusher/./src/core/http/http_socket.ts","webpack://Pusher/./src/core/http/http_streaming_socket.ts","webpack://Pusher/./src/core/http/http_polling_socket.ts","webpack://Pusher/./src/runtimes/isomorphic/http/http_xhr_request.ts","webpack://Pusher/./src/runtimes/isomorphic/runtime.ts","webpack://Pusher/./src/runtimes/isomorphic/transports/transport_connection_initializer.ts","webpack://Pusher/./src/runtimes/isomorphic/http/http.ts","webpack://Pusher/./src/runtimes/worker/net_info.ts","webpack://Pusher/./src/runtimes/worker/auth/fetch_auth.ts","webpack://Pusher/./src/runtimes/worker/timeline/fetch_timeline.ts","webpack://Pusher/./src/runtimes/worker/runtime.ts","webpack://Pusher/./src/core/timeline/level.ts","webpack://Pusher/./src/core/timeline/timeline.ts","webpack://Pusher/./src/core/strategies/transport_strategy.ts","webpack://Pusher/./src/core/strategies/strategy_builder.ts","webpack://Pusher/./src/core/auth/options.ts","webpack://Pusher/./src/core/options.ts","webpack://Pusher/./src/core/auth/user_authenticator.ts","webpack://Pusher/./src/core/auth/channel_authorizer.ts","webpack://Pusher/./src/core/config.ts","webpack://Pusher/./src/core/auth/deprecated_channel_authorizer.ts","webpack://Pusher/./src/core/watchlist.ts","webpack://Pusher/./src/core/utils/flat_promise.ts","webpack://Pusher/./src/core/user.ts","webpack://Pusher/./src/core/pusher.ts","webpack://Pusher/./src/core/pusher-with-encryption.ts"],"names":["root","factory","exports","module","define","amd","this","installedModules","__webpack_require__","moduleId","i","l","modules","call","m","c","d","name","getter","o","Object","defineProperty","enumerable","get","r","Symbol","toStringTag","value","t","mode","__esModule","ns","create","key","bind","n","object","property","prototype","hasOwnProperty","p","s","_paddingCharacter","encodedLength","length","encode","data","out","_encodeByte","left","maxDecodedLength","decodedLength","_getPaddingLength","decode","Uint8Array","paddingLength","op","haveBad","v0","v1","v2","v3","_decodeChar","charCodeAt","Error","b","result","String","fromCharCode","Coder","stdCoder","URLSafeCoder","urlSafeCoder","INVALID_UTF8","arr","pos","chars","min","n1","n2","n3","push","join","nacl","gf","init","Float64Array","randombytes","_0","_9","gf0","gf1","_121665","D","D2","X","Y","I","ts64","x","h","vn","xi","y","yi","crypto_verify_16","crypto_verify_32","crypto_core_salsa20","inp","k","u","j0","j1","j2","j3","j4","j5","j6","j7","j8","j9","j10","j11","j12","j13","j14","j15","x0","x1","x2","x3","x4","x5","x6","x7","x8","x9","x10","x11","x12","x13","x14","x15","core_salsa20","crypto_core_hsalsa20","core_hsalsa20","sigma","crypto_stream_salsa20_xor","cpos","mpos","z","crypto_stream_salsa20","crypto_stream","sn","crypto_stream_xor","poly1305","t0","t1","t2","t3","t4","t5","t6","t7","buffer","Uint16Array","pad","leftover","fin","crypto_onetimeauth","outpos","update","finish","crypto_onetimeauth_verify","hpos","crypto_secretbox","crypto_secretbox_open","set25519","a","car25519","v","Math","floor","sel25519","q","pack25519","j","neq25519","par25519","unpack25519","A","Z","M","t8","t9","t10","t11","t12","t13","t14","t15","t16","t17","t18","t19","t20","t21","t22","t23","t24","t25","t26","t27","t28","t29","t30","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","b10","b11","b12","b13","b14","b15","S","inv25519","pow2523","crypto_scalarmult","e","f","x32","subarray","x16","crypto_scalarmult_base","crypto_box_keypair","crypto_box_beforenm","blocks","bytes","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","hibit","h0","h1","h2","h3","h4","h5","h6","h7","h8","h9","r0","r1","r2","r3","r4","r5","r6","r7","r8","r9","mac","macpos","mask","g","want","crypto_box_afternm","crypto_box_open_afternm","K","crypto_hashblocks_hl","hh","hl","bh0","bh1","bh2","bh3","bh4","bh5","bh6","bh7","bl0","bl1","bl2","bl3","bl4","bl5","bl6","bl7","th","tl","wh","Int32Array","wl","ah0","ah1","ah2","ah3","ah4","ah5","ah6","ah7","al0","al1","al2","al3","al4","al5","al6","al7","crypto_hash","add","cswap","pack","tx","ty","zi","scalarmult","scalarbase","crypto_sign_keypair","pk","sk","seeded","L","modL","carry","reduce","crypto_sign","sm","smlen","crypto_sign_open","chk","num","den","den2","den4","den6","unpackneg","checkLengths","checkArrayTypes","arguments","TypeError","cleanup","lowlevel","crypto_box","crypto_box_open","crypto_secretbox_KEYBYTES","crypto_secretbox_NONCEBYTES","crypto_secretbox_ZEROBYTES","crypto_secretbox_BOXZEROBYTES","crypto_scalarmult_BYTES","crypto_scalarmult_SCALARBYTES","crypto_box_PUBLICKEYBYTES","crypto_box_SECRETKEYBYTES","crypto_box_BEFORENMBYTES","crypto_box_NONCEBYTES","crypto_box_ZEROBYTES","crypto_box_BOXZEROBYTES","crypto_sign_BYTES","crypto_sign_PUBLICKEYBYTES","crypto_sign_SECRETKEYBYTES","crypto_sign_SEEDBYTES","crypto_hash_BYTES","randomBytes","secretbox","msg","nonce","open","box","keyLength","nonceLength","overheadLength","scalarMult","base","scalarLength","groupElementLength","publicKey","secretKey","before","checkBoxLengths","after","keyPair","fromSecretKey","publicKeyLength","secretKeyLength","sharedKeyLength","sign","signedMsg","tmp","mlen","detached","sig","verify","fromSeed","seed","seedLength","signatureLength","hash","hashLength","setPRNG","fn","crypto","self","msCrypto","getRandomValues","default","b64chars","b64tab","charAt","cb_utob","cc","utob","replace","cb_encode","ccc","padlen","ord","btoa","set","clear","delay","callback","timer","clearTimeout","clearInterval","super","setTimeout","setInterval","now","Date","valueOf","defer","args","boundArguments","Array","slice","apply","concat","extend","target","sources","extensions","constructor","stringify","safeJSONStringify","arrayIndexOf","array","item","nativeIndexOf","indexOf","objectApply","keys","_","context","map","filter","test","filterObject","Boolean","any","encodeParamsObject","encodeURIComponent","toString","buildQueryString","params","undefined","method","source","JSON","objects","paths","derez","path","nu","$ref","VERSION","PROTOCOL","wsPort","wssPort","wsPath","httpHost","httpPort","httpsPort","httpPath","stats_host","authEndpoint","authTransport","activityTimeout","pongTimeout","unavailableTimeout","userAuthentication","endpoint","transport","channelAuthorization","cdn_http","cdn_https","dependency_suffix","getGenericURL","baseScheme","useTLS","hostTLS","hostNonTLS","getGenericPath","queryString","ws","getInitial","http","_callbacks","prefix","prefixedEventName","names","removeCallback","removeAllCallbacks","binding","failThrough","callbacks","global_callbacks","eventName","remove","unbind","unbind_global","metadata","globalLog","message","console","log","globalLogWarn","globalLogError","warn","error","defaultLoggingFunction","logToConsole","hooks","priority","options","initialize","transportConnectionInitializer","state","timeline","id","generateUniqueID","handlesActivityChecks","supportsPing","socket","url","urls","getSocket","onError","changeState","bindListeners","debug","close","send","ping","beforeOpen","getPath","onopen","emit","type","buildTimelineMessage","closeEvent","code","reason","wasClean","unbindListeners","onOpen","onerror","onclose","onClose","onmessage","onMessage","onactivity","onActivity","info","cid","environment","isSupported","WSTransport","isInitialized","getWebSocketAPI","createWebSocket","httpConfiguration","streamingConfiguration","HTTPFactory","createStreamingSocket","pollingConfiguration","createPollingSocket","xhrConfiguration","isXHRSupported","xhr_streaming","xhr_polling","manager","minPingDelay","maxPingDelay","pingDelay","connection","createConnection","openTimestamp","onClosed","reportDeath","lifespan","max","isAlive","Protocol","decodeMessage","messageEvent","messageData","parse","pusherEventData","pusherEvent","event","channel","user_id","encodeMessage","processHandshake","activity_timeout","action","socket_id","getCloseAction","getCloseError","send_event","listeners","activity","closed","handleCloseEvent","listener","isEmpty","TimelineTransport","getAgent","BadEventName","setPrototypeOf","BadChannelName","TransportPriorityTooLow","TransportClosed","UnsupportedFeature","UnsupportedTransport","UnsupportedStrategy","HTTPAuthError","status","urlStore","baseUrl","authenticationEndpoint","authorizationEndpoint","javascriptQuickStart","triggeringClientEvents","encryptedChannelSupport","fullUrl","urlObj","pusher","subscribed","subscriptionPending","subscriptionCancelled","socketId","auth","suffix","handleSubscriptionSucceededEvent","handleSubscriptionCountEvent","unsubscribe","subscription_count","subscriptionCount","authorize","assign","channel_data","config","channelAuthorizer","channelName","reset","members","member","myID","subscriptionData","presence","count","me","memberData","user_info","authData","channelData","setMyID","user","signinDonePromise","user_data","handleInternalEvent","addedMember","addMember","removedMember","removeMember","onSubscription","disconnect","sharedSecret","handleEncryptedEvent","handleEvent","ciphertext","cipherText","getDataToEmit","raw","usingTLS","errorCallbacks","buildErrorCallbacks","connectionCallbacks","buildConnectionCallbacks","handshakeCallbacks","buildHandshakeCallbacks","Network","getNetwork","netinfo","retryIn","sendActivityCheck","updateStrategy","runner","strategy","updateState","startConnecting","setUnavailableTimer","disconnectInternally","handshake","connect","handshakeError","abortConnecting","abort","clearRetryTimer","clearUnavailableTimer","abandonConnection","getStrategy","round","retryTimer","ensureAborted","unavailableTimer","stopActivityCheck","activityTimer","pong_timed_out","resetActivityCheck","shouldRetry","connected","Infinity","setConnection","withErrorEmitted","tls_only","refused","backoff","retry","newState","previousState","newStateDescription","previous","current","channels","createEncryptedChannel","errMsg","createPrivateChannel","createPresenceChannel","createChannel","values","createChannels","createConnectionManager","createTimelineSender","createHandshake","createAssistantToTheTransportManager","livesLeft","lives","strategies","loop","failFast","timeout","timeoutLimit","minPriority","tryNextStrategy","tryStrategy","forceMinPriority","isRunning","callbackBuilder","runners","rs","abortRunner","allRunnersFailed","aborted","transports","ttl","storage","getLocalStorage","serializedCache","getTransportCacheKey","flushTransportCache","fetchTransportCache","cacheSkipCount","timestamp","includes","cached","latency","startTimestamp","pop","cb","storeTransportCache","number","IfStrategy","trueBranch","falseBranch","FirstConnectedStrategy","testSupportsStrategy","baseOptions","defineTransport","definedTransports","defineTransportStrategy","wsStrategy","ws_options","wsHost","wss_options","http_options","timeouts","ws_manager","streaming_manager","ws_transport","wss_transport","xhr_streaming_transport","xhr_polling_transport","ws_loop","wss_loop","streaming_loop","polling_loop","http_loop","payload","position","xhr","getRequest","unloader","addUnloadListener","setRequestHeader","removeUnloadListener","abortRequest","chunk","advanceBuffer","isBufferTooLong","unreadData","endOfLinePosition","State","autoIncrement","getUniqueURL","separator","randomNumber","randomInt","session","randomString","location","parts","exec","getLocation","readyState","CONNECTING","openStream","sendRaw","sendHeartbeat","OPEN","createSocketRequest","start","closeStream","CLOSED","onEvent","onHeartbeat","hostname","urlParts","stream","getReceiveURL","onChunk","onFinished","reconnect","unbind_all","getXHRAPI","onreadystatechange","onprogress","responseText","getDefaultStrategy","Transports","createSocket","createRequest","PusherClass","ready","getClientFeatures","getProtocol","createXHR","query","authOptions","authRequestType","headers","Headers","headerName","headersProvider","dynamicHeaders","body","request","Request","credentials","fetch","then","response","text","parsedData","catch","err","sender","host","json","setup","TimelineLevel","getAuthorizers","ajax","WebSocket","XMLHttpRequest","globalThis","Uint32Array","events","sent","uniqueID","level","limit","shift","ERROR","INFO","DEBUG","sendfn","bundle","lib","version","cluster","features","failAttempt","onInitialized","serializedTransport","AuthRequestType","transportClass","enabledTransports","disabledTransports","ignoreNullOrigin","getAssistant","deferred","validateOptions","paramsProvider","dynamicParams","composeChannelQuery","UserAuthentication","ChannelAuthorization","getConfig","opts","statsHost","enableStats","getEnableStatsConfig","getHttpHost","shouldUseTLS","getWebsocketHost","userAuthenticator","buildUserAuthenticator","buildChannelAuthorizer","timelineParams","forceTLS","disableStats","customHandler","channelAuthorizerGenerator","deprecatedAuthorizerOptions","ChannelAuthorizerProxy","authorizer","buildChannelAuth","bindWatchlistInternalEvent","forEach","watchlistEvent","resolve","reject","promise","Promise","res","rej","signin_requested","serverToUserChannel","_signinDoneResolve","_onAuthorize","_cleanup","_signin","_newSigninPromiseIfNeeded","watchlist","_onSigninSuccess","_subscribeChannels","bind_global","reinstateSubscription","subscribe","ensure_subscribed","done","setDone","isReady","instances","app_key","checkAppKey","global_emitter","sessionID","timelineSender","subscribeAll","isUsingTLS","internal","appKey","switchCluster","find","all","timelineSenderTimer","event_name","channel_name","cancelSubscription","signin","Runtime","ScriptReceivers","DependenciesReceivers","auth_callbacks"],"mappings":";;;;;;;CAAA,SAA2CA,EAAMC,GAC1B,iBAAZC,SAA0C,iBAAXC,OACxCA,OAAOD,QAAUD,IACQ,mBAAXG,QAAyBA,OAAOC,IAC9CD,OAAO,GAAIH,GACe,iBAAZC,QACdA,QAAgB,OAAID,IAEpBD,EAAa,OAAIC,IARnB,CASGK,MAAM,WACT,O,YCTE,IAAIC,EAAmB,GAGvB,SAASC,EAAoBC,GAG5B,GAAGF,EAAiBE,GACnB,OAAOF,EAAiBE,GAAUP,QAGnC,IAAIC,EAASI,EAAiBE,GAAY,CACzCC,EAAGD,EACHE,GAAG,EACHT,QAAS,IAUV,OANAU,EAAQH,GAAUI,KAAKV,EAAOD,QAASC,EAAQA,EAAOD,QAASM,GAG/DL,EAAOQ,GAAI,EAGJR,EAAOD,QA0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AYsF,EAAiBrc,GAC3B,GAAOH,aAAe,GAAqBA,aAC3C,GAAON,IAAM,GAAqBA,IAElCyZ,GAAgBhZ,GAChBA,EAAQld,KAAO,GACfqW,MAAMkjB,EAASrc","file":"pusher-with-encryption.worker.min.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"Pusher\"] = factory();\n\telse\n\t\troot[\"Pusher\"] = factory();\n})(this, function() {\nreturn "," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 3);\n","// Copyright (C) 2016 Dmitry Chestnykh\n// MIT License. See LICENSE file for details.\n\n/**\n * Package base64 implements Base64 encoding and decoding.\n */\n\n// Invalid character used in decoding to indicate\n// that the character to decode is out of range of\n// alphabet and cannot be decoded.\nconst INVALID_BYTE = 256;\n\n/**\n * Implements standard Base64 encoding.\n *\n * Operates in constant time.\n */\nexport class Coder {\n // TODO(dchest): methods to encode chunk-by-chunk.\n\n constructor(private _paddingCharacter = \"=\") { }\n\n encodedLength(length: number): number {\n if (!this._paddingCharacter) {\n return (length * 8 + 5) / 6 | 0;\n }\n return (length + 2) / 3 * 4 | 0;\n }\n\n encode(data: Uint8Array): string {\n let out = \"\";\n\n let i = 0;\n for (; i < data.length - 2; i += 3) {\n let c = (data[i] << 16) | (data[i + 1] << 8) | (data[i + 2]);\n out += this._encodeByte((c >>> 3 * 6) & 63);\n out += this._encodeByte((c >>> 2 * 6) & 63);\n out += this._encodeByte((c >>> 1 * 6) & 63);\n out += this._encodeByte((c >>> 0 * 6) & 63);\n }\n\n const left = data.length - i;\n if (left > 0) {\n let c = (data[i] << 16) | (left === 2 ? data[i + 1] << 8 : 0);\n out += this._encodeByte((c >>> 3 * 6) & 63);\n out += this._encodeByte((c >>> 2 * 6) & 63);\n if (left === 2) {\n out += this._encodeByte((c >>> 1 * 6) & 63);\n } else {\n out += this._paddingCharacter || \"\";\n }\n out += this._paddingCharacter || \"\";\n }\n\n return out;\n }\n\n maxDecodedLength(length: number): number {\n if (!this._paddingCharacter) {\n return (length * 6 + 7) / 8 | 0;\n }\n return length / 4 * 3 | 0;\n }\n\n decodedLength(s: string): number {\n return this.maxDecodedLength(s.length - this._getPaddingLength(s));\n }\n\n decode(s: string): Uint8Array {\n if (s.length === 0) {\n return new Uint8Array(0);\n }\n const paddingLength = this._getPaddingLength(s);\n const length = s.length - paddingLength;\n const out = new Uint8Array(this.maxDecodedLength(length));\n let op = 0;\n let i = 0;\n let haveBad = 0;\n let v0 = 0, v1 = 0, v2 = 0, v3 = 0;\n for (; i < length - 4; i += 4) {\n v0 = this._decodeChar(s.charCodeAt(i + 0));\n v1 = this._decodeChar(s.charCodeAt(i + 1));\n v2 = this._decodeChar(s.charCodeAt(i + 2));\n v3 = this._decodeChar(s.charCodeAt(i + 3));\n out[op++] = (v0 << 2) | (v1 >>> 4);\n out[op++] = (v1 << 4) | (v2 >>> 2);\n out[op++] = (v2 << 6) | v3;\n haveBad |= v0 & INVALID_BYTE;\n haveBad |= v1 & INVALID_BYTE;\n haveBad |= v2 & INVALID_BYTE;\n haveBad |= v3 & INVALID_BYTE;\n }\n if (i < length - 1) {\n v0 = this._decodeChar(s.charCodeAt(i));\n v1 = this._decodeChar(s.charCodeAt(i + 1));\n out[op++] = (v0 << 2) | (v1 >>> 4);\n haveBad |= v0 & INVALID_BYTE;\n haveBad |= v1 & INVALID_BYTE;\n }\n if (i < length - 2) {\n v2 = this._decodeChar(s.charCodeAt(i + 2));\n out[op++] = (v1 << 4) | (v2 >>> 2);\n haveBad |= v2 & INVALID_BYTE;\n }\n if (i < length - 3) {\n v3 = this._decodeChar(s.charCodeAt(i + 3));\n out[op++] = (v2 << 6) | v3;\n haveBad |= v3 & INVALID_BYTE;\n }\n if (haveBad !== 0) {\n throw new Error(\"Base64Coder: incorrect characters for decoding\");\n }\n return out;\n }\n\n // Standard encoding have the following encoded/decoded ranges,\n // which we need to convert between.\n //\n // ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 0123456789 + /\n // Index: 0 - 25 26 - 51 52 - 61 62 63\n // ASCII: 65 - 90 97 - 122 48 - 57 43 47\n //\n\n // Encode 6 bits in b into a new character.\n protected _encodeByte(b: number): string {\n // Encoding uses constant time operations as follows:\n //\n // 1. Define comparison of A with B using (A - B) >>> 8:\n // if A > B, then result is positive integer\n // if A <= B, then result is 0\n //\n // 2. Define selection of C or 0 using bitwise AND: X & C:\n // if X == 0, then result is 0\n // if X != 0, then result is C\n //\n // 3. Start with the smallest comparison (b >= 0), which is always\n // true, so set the result to the starting ASCII value (65).\n //\n // 4. Continue comparing b to higher ASCII values, and selecting\n // zero if comparison isn't true, otherwise selecting a value\n // to add to result, which:\n //\n // a) undoes the previous addition\n // b) provides new value to add\n //\n let result = b;\n // b >= 0\n result += 65;\n // b > 25\n result += ((25 - b) >>> 8) & ((0 - 65) - 26 + 97);\n // b > 51\n result += ((51 - b) >>> 8) & ((26 - 97) - 52 + 48);\n // b > 61\n result += ((61 - b) >>> 8) & ((52 - 48) - 62 + 43);\n // b > 62\n result += ((62 - b) >>> 8) & ((62 - 43) - 63 + 47);\n\n return String.fromCharCode(result);\n }\n\n // Decode a character code into a byte.\n // Must return 256 if character is out of alphabet range.\n protected _decodeChar(c: number): number {\n // Decoding works similar to encoding: using the same comparison\n // function, but now it works on ranges: result is always incremented\n // by value, but this value becomes zero if the range is not\n // satisfied.\n //\n // Decoding starts with invalid value, 256, which is then\n // subtracted when the range is satisfied. If none of the ranges\n // apply, the function returns 256, which is then checked by\n // the caller to throw error.\n let result = INVALID_BYTE; // start with invalid character\n\n // c == 43 (c > 42 and c < 44)\n result += (((42 - c) & (c - 44)) >>> 8) & (-INVALID_BYTE + c - 43 + 62);\n // c == 47 (c > 46 and c < 48)\n result += (((46 - c) & (c - 48)) >>> 8) & (-INVALID_BYTE + c - 47 + 63);\n // c > 47 and c < 58\n result += (((47 - c) & (c - 58)) >>> 8) & (-INVALID_BYTE + c - 48 + 52);\n // c > 64 and c < 91\n result += (((64 - c) & (c - 91)) >>> 8) & (-INVALID_BYTE + c - 65 + 0);\n // c > 96 and c < 123\n result += (((96 - c) & (c - 123)) >>> 8) & (-INVALID_BYTE + c - 97 + 26);\n\n return result;\n }\n\n private _getPaddingLength(s: string): number {\n let paddingLength = 0;\n if (this._paddingCharacter) {\n for (let i = s.length - 1; i >= 0; i--) {\n if (s[i] !== this._paddingCharacter) {\n break;\n }\n paddingLength++;\n }\n if (s.length < 4 || paddingLength > 2) {\n throw new Error(\"Base64Coder: incorrect padding\");\n }\n }\n return paddingLength;\n }\n\n}\n\nconst stdCoder = new Coder();\n\nexport function encode(data: Uint8Array): string {\n return stdCoder.encode(data);\n}\n\nexport function decode(s: string): Uint8Array {\n return stdCoder.decode(s);\n}\n\n/**\n * Implements URL-safe Base64 encoding.\n * (Same as Base64, but '+' is replaced with '-', and '/' with '_').\n *\n * Operates in constant time.\n */\nexport class URLSafeCoder extends Coder {\n // URL-safe encoding have the following encoded/decoded ranges:\n //\n // ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 0123456789 - _\n // Index: 0 - 25 26 - 51 52 - 61 62 63\n // ASCII: 65 - 90 97 - 122 48 - 57 45 95\n //\n\n protected _encodeByte(b: number): string {\n let result = b;\n // b >= 0\n result += 65;\n // b > 25\n result += ((25 - b) >>> 8) & ((0 - 65) - 26 + 97);\n // b > 51\n result += ((51 - b) >>> 8) & ((26 - 97) - 52 + 48);\n // b > 61\n result += ((61 - b) >>> 8) & ((52 - 48) - 62 + 45);\n // b > 62\n result += ((62 - b) >>> 8) & ((62 - 45) - 63 + 95);\n\n return String.fromCharCode(result);\n }\n\n protected _decodeChar(c: number): number {\n let result = INVALID_BYTE;\n\n // c == 45 (c > 44 and c < 46)\n result += (((44 - c) & (c - 46)) >>> 8) & (-INVALID_BYTE + c - 45 + 62);\n // c == 95 (c > 94 and c < 96)\n result += (((94 - c) & (c - 96)) >>> 8) & (-INVALID_BYTE + c - 95 + 63);\n // c > 47 and c < 58\n result += (((47 - c) & (c - 58)) >>> 8) & (-INVALID_BYTE + c - 48 + 52);\n // c > 64 and c < 91\n result += (((64 - c) & (c - 91)) >>> 8) & (-INVALID_BYTE + c - 65 + 0);\n // c > 96 and c < 123\n result += (((96 - c) & (c - 123)) >>> 8) & (-INVALID_BYTE + c - 97 + 26);\n\n return result;\n }\n}\n\nconst urlSafeCoder = new URLSafeCoder();\n\nexport function encodeURLSafe(data: Uint8Array): string {\n return urlSafeCoder.encode(data);\n}\n\nexport function decodeURLSafe(s: string): Uint8Array {\n return urlSafeCoder.decode(s);\n}\n\n\nexport const encodedLength = (length: number) =>\n stdCoder.encodedLength(length);\n\nexport const maxDecodedLength = (length: number) =>\n stdCoder.maxDecodedLength(length);\n\nexport const decodedLength = (s: string) =>\n stdCoder.decodedLength(s);\n","// Copyright (C) 2016 Dmitry Chestnykh\n// MIT License. See LICENSE file for details.\n\n/**\n * Package utf8 implements UTF-8 encoding and decoding.\n */\n\nconst INVALID_UTF16 = \"utf8: invalid string\";\nconst INVALID_UTF8 = \"utf8: invalid source encoding\";\n\n/**\n * Encodes the given string into UTF-8 byte array.\n * Throws if the source string has invalid UTF-16 encoding.\n */\nexport function encode(s: string): Uint8Array {\n // Calculate result length and allocate output array.\n // encodedLength() also validates string and throws errors,\n // so we don't need repeat validation here.\n const arr = new Uint8Array(encodedLength(s));\n\n let pos = 0;\n for (let i = 0; i < s.length; i++) {\n let c = s.charCodeAt(i);\n if (c < 0x80) {\n arr[pos++] = c;\n } else if (c < 0x800) {\n arr[pos++] = 0xc0 | c >> 6;\n arr[pos++] = 0x80 | c & 0x3f;\n } else if (c < 0xd800) {\n arr[pos++] = 0xe0 | c >> 12;\n arr[pos++] = 0x80 | (c >> 6) & 0x3f;\n arr[pos++] = 0x80 | c & 0x3f;\n } else {\n i++; // get one more character\n c = (c & 0x3ff) << 10;\n c |= s.charCodeAt(i) & 0x3ff;\n c += 0x10000;\n\n arr[pos++] = 0xf0 | c >> 18;\n arr[pos++] = 0x80 | (c >> 12) & 0x3f;\n arr[pos++] = 0x80 | (c >> 6) & 0x3f;\n arr[pos++] = 0x80 | c & 0x3f;\n }\n }\n return arr;\n}\n\n/**\n * Returns the number of bytes required to encode the given string into UTF-8.\n * Throws if the source string has invalid UTF-16 encoding.\n */\nexport function encodedLength(s: string): number {\n let result = 0;\n for (let i = 0; i < s.length; i++) {\n const c = s.charCodeAt(i);\n if (c < 0x80) {\n result += 1;\n } else if (c < 0x800) {\n result += 2;\n } else if (c < 0xd800) {\n result += 3;\n } else if (c <= 0xdfff) {\n if (i >= s.length - 1) {\n throw new Error(INVALID_UTF16);\n }\n i++; // \"eat\" next character\n result += 4;\n } else {\n throw new Error(INVALID_UTF16);\n }\n }\n return result;\n}\n\n/**\n * Decodes the given byte array from UTF-8 into a string.\n * Throws if encoding is invalid.\n */\nexport function decode(arr: Uint8Array): string {\n const chars: string[] = [];\n for (let i = 0; i < arr.length; i++) {\n let b = arr[i];\n\n if (b & 0x80) {\n let min;\n if (b < 0xe0) {\n // Need 1 more byte.\n if (i >= arr.length) {\n throw new Error(INVALID_UTF8);\n }\n const n1 = arr[++i];\n if ((n1 & 0xc0) !== 0x80) {\n throw new Error(INVALID_UTF8);\n }\n b = (b & 0x1f) << 6 | (n1 & 0x3f);\n min = 0x80;\n } else if (b < 0xf0) {\n // Need 2 more bytes.\n if (i >= arr.length - 1) {\n throw new Error(INVALID_UTF8);\n }\n const n1 = arr[++i];\n const n2 = arr[++i];\n if ((n1 & 0xc0) !== 0x80 || (n2 & 0xc0) !== 0x80) {\n throw new Error(INVALID_UTF8);\n }\n b = (b & 0x0f) << 12 | (n1 & 0x3f) << 6 | (n2 & 0x3f);\n min = 0x800;\n } else if (b < 0xf8) {\n // Need 3 more bytes.\n if (i >= arr.length - 2) {\n throw new Error(INVALID_UTF8);\n }\n const n1 = arr[++i];\n const n2 = arr[++i];\n const n3 = arr[++i];\n if ((n1 & 0xc0) !== 0x80 || (n2 & 0xc0) !== 0x80 || (n3 & 0xc0) !== 0x80) {\n throw new Error(INVALID_UTF8);\n }\n b = (b & 0x0f) << 18 | (n1 & 0x3f) << 12 | (n2 & 0x3f) << 6 | (n3 & 0x3f);\n min = 0x10000;\n } else {\n throw new Error(INVALID_UTF8);\n }\n\n if (b < min || (b >= 0xd800 && b <= 0xdfff)) {\n throw new Error(INVALID_UTF8);\n }\n\n if (b >= 0x10000) {\n // Surrogate pair.\n if (b > 0x10ffff) {\n throw new Error(INVALID_UTF8);\n }\n b -= 0x10000;\n chars.push(String.fromCharCode(0xd800 | (b >> 10)));\n b = 0xdc00 | (b & 0x3ff);\n }\n }\n\n chars.push(String.fromCharCode(b));\n }\n return chars.join(\"\");\n}\n","(function(nacl) {\n'use strict';\n\n// Ported in 2014 by Dmitry Chestnykh and Devi Mandiri.\n// Public domain.\n//\n// Implementation derived from TweetNaCl version 20140427.\n// See for details: http://tweetnacl.cr.yp.to/\n\nvar gf = function(init) {\n var i, r = new Float64Array(16);\n if (init) for (i = 0; i < init.length; i++) r[i] = init[i];\n return r;\n};\n\n// Pluggable, initialized in high-level API below.\nvar randombytes = function(/* x, n */) { throw new Error('no PRNG'); };\n\nvar _0 = new Uint8Array(16);\nvar _9 = new Uint8Array(32); _9[0] = 9;\n\nvar gf0 = gf(),\n gf1 = gf([1]),\n _121665 = gf([0xdb41, 1]),\n D = gf([0x78a3, 0x1359, 0x4dca, 0x75eb, 0xd8ab, 0x4141, 0x0a4d, 0x0070, 0xe898, 0x7779, 0x4079, 0x8cc7, 0xfe73, 0x2b6f, 0x6cee, 0x5203]),\n D2 = gf([0xf159, 0x26b2, 0x9b94, 0xebd6, 0xb156, 0x8283, 0x149a, 0x00e0, 0xd130, 0xeef3, 0x80f2, 0x198e, 0xfce7, 0x56df, 0xd9dc, 0x2406]),\n X = gf([0xd51a, 0x8f25, 0x2d60, 0xc956, 0xa7b2, 0x9525, 0xc760, 0x692c, 0xdc5c, 0xfdd6, 0xe231, 0xc0a4, 0x53fe, 0xcd6e, 0x36d3, 0x2169]),\n Y = gf([0x6658, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666]),\n I = gf([0xa0b0, 0x4a0e, 0x1b27, 0xc4ee, 0xe478, 0xad2f, 0x1806, 0x2f43, 0xd7a7, 0x3dfb, 0x0099, 0x2b4d, 0xdf0b, 0x4fc1, 0x2480, 0x2b83]);\n\nfunction ts64(x, i, h, l) {\n x[i] = (h >> 24) & 0xff;\n x[i+1] = (h >> 16) & 0xff;\n x[i+2] = (h >> 8) & 0xff;\n x[i+3] = h & 0xff;\n x[i+4] = (l >> 24) & 0xff;\n x[i+5] = (l >> 16) & 0xff;\n x[i+6] = (l >> 8) & 0xff;\n x[i+7] = l & 0xff;\n}\n\nfunction vn(x, xi, y, yi, n) {\n var i,d = 0;\n for (i = 0; i < n; i++) d |= x[xi+i]^y[yi+i];\n return (1 & ((d - 1) >>> 8)) - 1;\n}\n\nfunction crypto_verify_16(x, xi, y, yi) {\n return vn(x,xi,y,yi,16);\n}\n\nfunction crypto_verify_32(x, xi, y, yi) {\n return vn(x,xi,y,yi,32);\n}\n\nfunction core_salsa20(o, p, k, c) {\n var j0 = c[ 0] & 0xff | (c[ 1] & 0xff)<<8 | (c[ 2] & 0xff)<<16 | (c[ 3] & 0xff)<<24,\n j1 = k[ 0] & 0xff | (k[ 1] & 0xff)<<8 | (k[ 2] & 0xff)<<16 | (k[ 3] & 0xff)<<24,\n j2 = k[ 4] & 0xff | (k[ 5] & 0xff)<<8 | (k[ 6] & 0xff)<<16 | (k[ 7] & 0xff)<<24,\n j3 = k[ 8] & 0xff | (k[ 9] & 0xff)<<8 | (k[10] & 0xff)<<16 | (k[11] & 0xff)<<24,\n j4 = k[12] & 0xff | (k[13] & 0xff)<<8 | (k[14] & 0xff)<<16 | (k[15] & 0xff)<<24,\n j5 = c[ 4] & 0xff | (c[ 5] & 0xff)<<8 | (c[ 6] & 0xff)<<16 | (c[ 7] & 0xff)<<24,\n j6 = p[ 0] & 0xff | (p[ 1] & 0xff)<<8 | (p[ 2] & 0xff)<<16 | (p[ 3] & 0xff)<<24,\n j7 = p[ 4] & 0xff | (p[ 5] & 0xff)<<8 | (p[ 6] & 0xff)<<16 | (p[ 7] & 0xff)<<24,\n j8 = p[ 8] & 0xff | (p[ 9] & 0xff)<<8 | (p[10] & 0xff)<<16 | (p[11] & 0xff)<<24,\n j9 = p[12] & 0xff | (p[13] & 0xff)<<8 | (p[14] & 0xff)<<16 | (p[15] & 0xff)<<24,\n j10 = c[ 8] & 0xff | (c[ 9] & 0xff)<<8 | (c[10] & 0xff)<<16 | (c[11] & 0xff)<<24,\n j11 = k[16] & 0xff | (k[17] & 0xff)<<8 | (k[18] & 0xff)<<16 | (k[19] & 0xff)<<24,\n j12 = k[20] & 0xff | (k[21] & 0xff)<<8 | (k[22] & 0xff)<<16 | (k[23] & 0xff)<<24,\n j13 = k[24] & 0xff | (k[25] & 0xff)<<8 | (k[26] & 0xff)<<16 | (k[27] & 0xff)<<24,\n j14 = k[28] & 0xff | (k[29] & 0xff)<<8 | (k[30] & 0xff)<<16 | (k[31] & 0xff)<<24,\n j15 = c[12] & 0xff | (c[13] & 0xff)<<8 | (c[14] & 0xff)<<16 | (c[15] & 0xff)<<24;\n\n var x0 = j0, x1 = j1, x2 = j2, x3 = j3, x4 = j4, x5 = j5, x6 = j6, x7 = j7,\n x8 = j8, x9 = j9, x10 = j10, x11 = j11, x12 = j12, x13 = j13, x14 = j14,\n x15 = j15, u;\n\n for (var i = 0; i < 20; i += 2) {\n u = x0 + x12 | 0;\n x4 ^= u<<7 | u>>>(32-7);\n u = x4 + x0 | 0;\n x8 ^= u<<9 | u>>>(32-9);\n u = x8 + x4 | 0;\n x12 ^= u<<13 | u>>>(32-13);\n u = x12 + x8 | 0;\n x0 ^= u<<18 | u>>>(32-18);\n\n u = x5 + x1 | 0;\n x9 ^= u<<7 | u>>>(32-7);\n u = x9 + x5 | 0;\n x13 ^= u<<9 | u>>>(32-9);\n u = x13 + x9 | 0;\n x1 ^= u<<13 | u>>>(32-13);\n u = x1 + x13 | 0;\n x5 ^= u<<18 | u>>>(32-18);\n\n u = x10 + x6 | 0;\n x14 ^= u<<7 | u>>>(32-7);\n u = x14 + x10 | 0;\n x2 ^= u<<9 | u>>>(32-9);\n u = x2 + x14 | 0;\n x6 ^= u<<13 | u>>>(32-13);\n u = x6 + x2 | 0;\n x10 ^= u<<18 | u>>>(32-18);\n\n u = x15 + x11 | 0;\n x3 ^= u<<7 | u>>>(32-7);\n u = x3 + x15 | 0;\n x7 ^= u<<9 | u>>>(32-9);\n u = x7 + x3 | 0;\n x11 ^= u<<13 | u>>>(32-13);\n u = x11 + x7 | 0;\n x15 ^= u<<18 | u>>>(32-18);\n\n u = x0 + x3 | 0;\n x1 ^= u<<7 | u>>>(32-7);\n u = x1 + x0 | 0;\n x2 ^= u<<9 | u>>>(32-9);\n u = x2 + x1 | 0;\n x3 ^= u<<13 | u>>>(32-13);\n u = x3 + x2 | 0;\n x0 ^= u<<18 | u>>>(32-18);\n\n u = x5 + x4 | 0;\n x6 ^= u<<7 | u>>>(32-7);\n u = x6 + x5 | 0;\n x7 ^= u<<9 | u>>>(32-9);\n u = x7 + x6 | 0;\n x4 ^= u<<13 | u>>>(32-13);\n u = x4 + x7 | 0;\n x5 ^= u<<18 | u>>>(32-18);\n\n u = x10 + x9 | 0;\n x11 ^= u<<7 | u>>>(32-7);\n u = x11 + x10 | 0;\n x8 ^= u<<9 | u>>>(32-9);\n u = x8 + x11 | 0;\n x9 ^= u<<13 | u>>>(32-13);\n u = x9 + x8 | 0;\n x10 ^= u<<18 | u>>>(32-18);\n\n u = x15 + x14 | 0;\n x12 ^= u<<7 | u>>>(32-7);\n u = x12 + x15 | 0;\n x13 ^= u<<9 | u>>>(32-9);\n u = x13 + x12 | 0;\n x14 ^= u<<13 | u>>>(32-13);\n u = x14 + x13 | 0;\n x15 ^= u<<18 | u>>>(32-18);\n }\n x0 = x0 + j0 | 0;\n x1 = x1 + j1 | 0;\n x2 = x2 + j2 | 0;\n x3 = x3 + j3 | 0;\n x4 = x4 + j4 | 0;\n x5 = x5 + j5 | 0;\n x6 = x6 + j6 | 0;\n x7 = x7 + j7 | 0;\n x8 = x8 + j8 | 0;\n x9 = x9 + j9 | 0;\n x10 = x10 + j10 | 0;\n x11 = x11 + j11 | 0;\n x12 = x12 + j12 | 0;\n x13 = x13 + j13 | 0;\n x14 = x14 + j14 | 0;\n x15 = x15 + j15 | 0;\n\n o[ 0] = x0 >>> 0 & 0xff;\n o[ 1] = x0 >>> 8 & 0xff;\n o[ 2] = x0 >>> 16 & 0xff;\n o[ 3] = x0 >>> 24 & 0xff;\n\n o[ 4] = x1 >>> 0 & 0xff;\n o[ 5] = x1 >>> 8 & 0xff;\n o[ 6] = x1 >>> 16 & 0xff;\n o[ 7] = x1 >>> 24 & 0xff;\n\n o[ 8] = x2 >>> 0 & 0xff;\n o[ 9] = x2 >>> 8 & 0xff;\n o[10] = x2 >>> 16 & 0xff;\n o[11] = x2 >>> 24 & 0xff;\n\n o[12] = x3 >>> 0 & 0xff;\n o[13] = x3 >>> 8 & 0xff;\n o[14] = x3 >>> 16 & 0xff;\n o[15] = x3 >>> 24 & 0xff;\n\n o[16] = x4 >>> 0 & 0xff;\n o[17] = x4 >>> 8 & 0xff;\n o[18] = x4 >>> 16 & 0xff;\n o[19] = x4 >>> 24 & 0xff;\n\n o[20] = x5 >>> 0 & 0xff;\n o[21] = x5 >>> 8 & 0xff;\n o[22] = x5 >>> 16 & 0xff;\n o[23] = x5 >>> 24 & 0xff;\n\n o[24] = x6 >>> 0 & 0xff;\n o[25] = x6 >>> 8 & 0xff;\n o[26] = x6 >>> 16 & 0xff;\n o[27] = x6 >>> 24 & 0xff;\n\n o[28] = x7 >>> 0 & 0xff;\n o[29] = x7 >>> 8 & 0xff;\n o[30] = x7 >>> 16 & 0xff;\n o[31] = x7 >>> 24 & 0xff;\n\n o[32] = x8 >>> 0 & 0xff;\n o[33] = x8 >>> 8 & 0xff;\n o[34] = x8 >>> 16 & 0xff;\n o[35] = x8 >>> 24 & 0xff;\n\n o[36] = x9 >>> 0 & 0xff;\n o[37] = x9 >>> 8 & 0xff;\n o[38] = x9 >>> 16 & 0xff;\n o[39] = x9 >>> 24 & 0xff;\n\n o[40] = x10 >>> 0 & 0xff;\n o[41] = x10 >>> 8 & 0xff;\n o[42] = x10 >>> 16 & 0xff;\n o[43] = x10 >>> 24 & 0xff;\n\n o[44] = x11 >>> 0 & 0xff;\n o[45] = x11 >>> 8 & 0xff;\n o[46] = x11 >>> 16 & 0xff;\n o[47] = x11 >>> 24 & 0xff;\n\n o[48] = x12 >>> 0 & 0xff;\n o[49] = x12 >>> 8 & 0xff;\n o[50] = x12 >>> 16 & 0xff;\n o[51] = x12 >>> 24 & 0xff;\n\n o[52] = x13 >>> 0 & 0xff;\n o[53] = x13 >>> 8 & 0xff;\n o[54] = x13 >>> 16 & 0xff;\n o[55] = x13 >>> 24 & 0xff;\n\n o[56] = x14 >>> 0 & 0xff;\n o[57] = x14 >>> 8 & 0xff;\n o[58] = x14 >>> 16 & 0xff;\n o[59] = x14 >>> 24 & 0xff;\n\n o[60] = x15 >>> 0 & 0xff;\n o[61] = x15 >>> 8 & 0xff;\n o[62] = x15 >>> 16 & 0xff;\n o[63] = x15 >>> 24 & 0xff;\n}\n\nfunction core_hsalsa20(o,p,k,c) {\n var j0 = c[ 0] & 0xff | (c[ 1] & 0xff)<<8 | (c[ 2] & 0xff)<<16 | (c[ 3] & 0xff)<<24,\n j1 = k[ 0] & 0xff | (k[ 1] & 0xff)<<8 | (k[ 2] & 0xff)<<16 | (k[ 3] & 0xff)<<24,\n j2 = k[ 4] & 0xff | (k[ 5] & 0xff)<<8 | (k[ 6] & 0xff)<<16 | (k[ 7] & 0xff)<<24,\n j3 = k[ 8] & 0xff | (k[ 9] & 0xff)<<8 | (k[10] & 0xff)<<16 | (k[11] & 0xff)<<24,\n j4 = k[12] & 0xff | (k[13] & 0xff)<<8 | (k[14] & 0xff)<<16 | (k[15] & 0xff)<<24,\n j5 = c[ 4] & 0xff | (c[ 5] & 0xff)<<8 | (c[ 6] & 0xff)<<16 | (c[ 7] & 0xff)<<24,\n j6 = p[ 0] & 0xff | (p[ 1] & 0xff)<<8 | (p[ 2] & 0xff)<<16 | (p[ 3] & 0xff)<<24,\n j7 = p[ 4] & 0xff | (p[ 5] & 0xff)<<8 | (p[ 6] & 0xff)<<16 | (p[ 7] & 0xff)<<24,\n j8 = p[ 8] & 0xff | (p[ 9] & 0xff)<<8 | (p[10] & 0xff)<<16 | (p[11] & 0xff)<<24,\n j9 = p[12] & 0xff | (p[13] & 0xff)<<8 | (p[14] & 0xff)<<16 | (p[15] & 0xff)<<24,\n j10 = c[ 8] & 0xff | (c[ 9] & 0xff)<<8 | (c[10] & 0xff)<<16 | (c[11] & 0xff)<<24,\n j11 = k[16] & 0xff | (k[17] & 0xff)<<8 | (k[18] & 0xff)<<16 | (k[19] & 0xff)<<24,\n j12 = k[20] & 0xff | (k[21] & 0xff)<<8 | (k[22] & 0xff)<<16 | (k[23] & 0xff)<<24,\n j13 = k[24] & 0xff | (k[25] & 0xff)<<8 | (k[26] & 0xff)<<16 | (k[27] & 0xff)<<24,\n j14 = k[28] & 0xff | (k[29] & 0xff)<<8 | (k[30] & 0xff)<<16 | (k[31] & 0xff)<<24,\n j15 = c[12] & 0xff | (c[13] & 0xff)<<8 | (c[14] & 0xff)<<16 | (c[15] & 0xff)<<24;\n\n var x0 = j0, x1 = j1, x2 = j2, x3 = j3, x4 = j4, x5 = j5, x6 = j6, x7 = j7,\n x8 = j8, x9 = j9, x10 = j10, x11 = j11, x12 = j12, x13 = j13, x14 = j14,\n x15 = j15, u;\n\n for (var i = 0; i < 20; i += 2) {\n u = x0 + x12 | 0;\n x4 ^= u<<7 | u>>>(32-7);\n u = x4 + x0 | 0;\n x8 ^= u<<9 | u>>>(32-9);\n u = x8 + x4 | 0;\n x12 ^= u<<13 | u>>>(32-13);\n u = x12 + x8 | 0;\n x0 ^= u<<18 | u>>>(32-18);\n\n u = x5 + x1 | 0;\n x9 ^= u<<7 | u>>>(32-7);\n u = x9 + x5 | 0;\n x13 ^= u<<9 | u>>>(32-9);\n u = x13 + x9 | 0;\n x1 ^= u<<13 | u>>>(32-13);\n u = x1 + x13 | 0;\n x5 ^= u<<18 | u>>>(32-18);\n\n u = x10 + x6 | 0;\n x14 ^= u<<7 | u>>>(32-7);\n u = x14 + x10 | 0;\n x2 ^= u<<9 | u>>>(32-9);\n u = x2 + x14 | 0;\n x6 ^= u<<13 | u>>>(32-13);\n u = x6 + x2 | 0;\n x10 ^= u<<18 | u>>>(32-18);\n\n u = x15 + x11 | 0;\n x3 ^= u<<7 | u>>>(32-7);\n u = x3 + x15 | 0;\n x7 ^= u<<9 | u>>>(32-9);\n u = x7 + x3 | 0;\n x11 ^= u<<13 | u>>>(32-13);\n u = x11 + x7 | 0;\n x15 ^= u<<18 | u>>>(32-18);\n\n u = x0 + x3 | 0;\n x1 ^= u<<7 | u>>>(32-7);\n u = x1 + x0 | 0;\n x2 ^= u<<9 | u>>>(32-9);\n u = x2 + x1 | 0;\n x3 ^= u<<13 | u>>>(32-13);\n u = x3 + x2 | 0;\n x0 ^= u<<18 | u>>>(32-18);\n\n u = x5 + x4 | 0;\n x6 ^= u<<7 | u>>>(32-7);\n u = x6 + x5 | 0;\n x7 ^= u<<9 | u>>>(32-9);\n u = x7 + x6 | 0;\n x4 ^= u<<13 | u>>>(32-13);\n u = x4 + x7 | 0;\n x5 ^= u<<18 | u>>>(32-18);\n\n u = x10 + x9 | 0;\n x11 ^= u<<7 | u>>>(32-7);\n u = x11 + x10 | 0;\n x8 ^= u<<9 | u>>>(32-9);\n u = x8 + x11 | 0;\n x9 ^= u<<13 | u>>>(32-13);\n u = x9 + x8 | 0;\n x10 ^= u<<18 | u>>>(32-18);\n\n u = x15 + x14 | 0;\n x12 ^= u<<7 | u>>>(32-7);\n u = x12 + x15 | 0;\n x13 ^= u<<9 | u>>>(32-9);\n u = x13 + x12 | 0;\n x14 ^= u<<13 | u>>>(32-13);\n u = x14 + x13 | 0;\n x15 ^= u<<18 | u>>>(32-18);\n }\n\n o[ 0] = x0 >>> 0 & 0xff;\n o[ 1] = x0 >>> 8 & 0xff;\n o[ 2] = x0 >>> 16 & 0xff;\n o[ 3] = x0 >>> 24 & 0xff;\n\n o[ 4] = x5 >>> 0 & 0xff;\n o[ 5] = x5 >>> 8 & 0xff;\n o[ 6] = x5 >>> 16 & 0xff;\n o[ 7] = x5 >>> 24 & 0xff;\n\n o[ 8] = x10 >>> 0 & 0xff;\n o[ 9] = x10 >>> 8 & 0xff;\n o[10] = x10 >>> 16 & 0xff;\n o[11] = x10 >>> 24 & 0xff;\n\n o[12] = x15 >>> 0 & 0xff;\n o[13] = x15 >>> 8 & 0xff;\n o[14] = x15 >>> 16 & 0xff;\n o[15] = x15 >>> 24 & 0xff;\n\n o[16] = x6 >>> 0 & 0xff;\n o[17] = x6 >>> 8 & 0xff;\n o[18] = x6 >>> 16 & 0xff;\n o[19] = x6 >>> 24 & 0xff;\n\n o[20] = x7 >>> 0 & 0xff;\n o[21] = x7 >>> 8 & 0xff;\n o[22] = x7 >>> 16 & 0xff;\n o[23] = x7 >>> 24 & 0xff;\n\n o[24] = x8 >>> 0 & 0xff;\n o[25] = x8 >>> 8 & 0xff;\n o[26] = x8 >>> 16 & 0xff;\n o[27] = x8 >>> 24 & 0xff;\n\n o[28] = x9 >>> 0 & 0xff;\n o[29] = x9 >>> 8 & 0xff;\n o[30] = x9 >>> 16 & 0xff;\n o[31] = x9 >>> 24 & 0xff;\n}\n\nfunction crypto_core_salsa20(out,inp,k,c) {\n core_salsa20(out,inp,k,c);\n}\n\nfunction crypto_core_hsalsa20(out,inp,k,c) {\n core_hsalsa20(out,inp,k,c);\n}\n\nvar sigma = new Uint8Array([101, 120, 112, 97, 110, 100, 32, 51, 50, 45, 98, 121, 116, 101, 32, 107]);\n // \"expand 32-byte k\"\n\nfunction crypto_stream_salsa20_xor(c,cpos,m,mpos,b,n,k) {\n var z = new Uint8Array(16), x = new Uint8Array(64);\n var u, i;\n for (i = 0; i < 16; i++) z[i] = 0;\n for (i = 0; i < 8; i++) z[i] = n[i];\n while (b >= 64) {\n crypto_core_salsa20(x,z,k,sigma);\n for (i = 0; i < 64; i++) c[cpos+i] = m[mpos+i] ^ x[i];\n u = 1;\n for (i = 8; i < 16; i++) {\n u = u + (z[i] & 0xff) | 0;\n z[i] = u & 0xff;\n u >>>= 8;\n }\n b -= 64;\n cpos += 64;\n mpos += 64;\n }\n if (b > 0) {\n crypto_core_salsa20(x,z,k,sigma);\n for (i = 0; i < b; i++) c[cpos+i] = m[mpos+i] ^ x[i];\n }\n return 0;\n}\n\nfunction crypto_stream_salsa20(c,cpos,b,n,k) {\n var z = new Uint8Array(16), x = new Uint8Array(64);\n var u, i;\n for (i = 0; i < 16; i++) z[i] = 0;\n for (i = 0; i < 8; i++) z[i] = n[i];\n while (b >= 64) {\n crypto_core_salsa20(x,z,k,sigma);\n for (i = 0; i < 64; i++) c[cpos+i] = x[i];\n u = 1;\n for (i = 8; i < 16; i++) {\n u = u + (z[i] & 0xff) | 0;\n z[i] = u & 0xff;\n u >>>= 8;\n }\n b -= 64;\n cpos += 64;\n }\n if (b > 0) {\n crypto_core_salsa20(x,z,k,sigma);\n for (i = 0; i < b; i++) c[cpos+i] = x[i];\n }\n return 0;\n}\n\nfunction crypto_stream(c,cpos,d,n,k) {\n var s = new Uint8Array(32);\n crypto_core_hsalsa20(s,n,k,sigma);\n var sn = new Uint8Array(8);\n for (var i = 0; i < 8; i++) sn[i] = n[i+16];\n return crypto_stream_salsa20(c,cpos,d,sn,s);\n}\n\nfunction crypto_stream_xor(c,cpos,m,mpos,d,n,k) {\n var s = new Uint8Array(32);\n crypto_core_hsalsa20(s,n,k,sigma);\n var sn = new Uint8Array(8);\n for (var i = 0; i < 8; i++) sn[i] = n[i+16];\n return crypto_stream_salsa20_xor(c,cpos,m,mpos,d,sn,s);\n}\n\n/*\n* Port of Andrew Moon's Poly1305-donna-16. Public domain.\n* https://github.com/floodyberry/poly1305-donna\n*/\n\nvar poly1305 = function(key) {\n this.buffer = new Uint8Array(16);\n this.r = new Uint16Array(10);\n this.h = new Uint16Array(10);\n this.pad = new Uint16Array(8);\n this.leftover = 0;\n this.fin = 0;\n\n var t0, t1, t2, t3, t4, t5, t6, t7;\n\n t0 = key[ 0] & 0xff | (key[ 1] & 0xff) << 8; this.r[0] = ( t0 ) & 0x1fff;\n t1 = key[ 2] & 0xff | (key[ 3] & 0xff) << 8; this.r[1] = ((t0 >>> 13) | (t1 << 3)) & 0x1fff;\n t2 = key[ 4] & 0xff | (key[ 5] & 0xff) << 8; this.r[2] = ((t1 >>> 10) | (t2 << 6)) & 0x1f03;\n t3 = key[ 6] & 0xff | (key[ 7] & 0xff) << 8; this.r[3] = ((t2 >>> 7) | (t3 << 9)) & 0x1fff;\n t4 = key[ 8] & 0xff | (key[ 9] & 0xff) << 8; this.r[4] = ((t3 >>> 4) | (t4 << 12)) & 0x00ff;\n this.r[5] = ((t4 >>> 1)) & 0x1ffe;\n t5 = key[10] & 0xff | (key[11] & 0xff) << 8; this.r[6] = ((t4 >>> 14) | (t5 << 2)) & 0x1fff;\n t6 = key[12] & 0xff | (key[13] & 0xff) << 8; this.r[7] = ((t5 >>> 11) | (t6 << 5)) & 0x1f81;\n t7 = key[14] & 0xff | (key[15] & 0xff) << 8; this.r[8] = ((t6 >>> 8) | (t7 << 8)) & 0x1fff;\n this.r[9] = ((t7 >>> 5)) & 0x007f;\n\n this.pad[0] = key[16] & 0xff | (key[17] & 0xff) << 8;\n this.pad[1] = key[18] & 0xff | (key[19] & 0xff) << 8;\n this.pad[2] = key[20] & 0xff | (key[21] & 0xff) << 8;\n this.pad[3] = key[22] & 0xff | (key[23] & 0xff) << 8;\n this.pad[4] = key[24] & 0xff | (key[25] & 0xff) << 8;\n this.pad[5] = key[26] & 0xff | (key[27] & 0xff) << 8;\n this.pad[6] = key[28] & 0xff | (key[29] & 0xff) << 8;\n this.pad[7] = key[30] & 0xff | (key[31] & 0xff) << 8;\n};\n\npoly1305.prototype.blocks = function(m, mpos, bytes) {\n var hibit = this.fin ? 0 : (1 << 11);\n var t0, t1, t2, t3, t4, t5, t6, t7, c;\n var d0, d1, d2, d3, d4, d5, d6, d7, d8, d9;\n\n var h0 = this.h[0],\n h1 = this.h[1],\n h2 = this.h[2],\n h3 = this.h[3],\n h4 = this.h[4],\n h5 = this.h[5],\n h6 = this.h[6],\n h7 = this.h[7],\n h8 = this.h[8],\n h9 = this.h[9];\n\n var r0 = this.r[0],\n r1 = this.r[1],\n r2 = this.r[2],\n r3 = this.r[3],\n r4 = this.r[4],\n r5 = this.r[5],\n r6 = this.r[6],\n r7 = this.r[7],\n r8 = this.r[8],\n r9 = this.r[9];\n\n while (bytes >= 16) {\n t0 = m[mpos+ 0] & 0xff | (m[mpos+ 1] & 0xff) << 8; h0 += ( t0 ) & 0x1fff;\n t1 = m[mpos+ 2] & 0xff | (m[mpos+ 3] & 0xff) << 8; h1 += ((t0 >>> 13) | (t1 << 3)) & 0x1fff;\n t2 = m[mpos+ 4] & 0xff | (m[mpos+ 5] & 0xff) << 8; h2 += ((t1 >>> 10) | (t2 << 6)) & 0x1fff;\n t3 = m[mpos+ 6] & 0xff | (m[mpos+ 7] & 0xff) << 8; h3 += ((t2 >>> 7) | (t3 << 9)) & 0x1fff;\n t4 = m[mpos+ 8] & 0xff | (m[mpos+ 9] & 0xff) << 8; h4 += ((t3 >>> 4) | (t4 << 12)) & 0x1fff;\n h5 += ((t4 >>> 1)) & 0x1fff;\n t5 = m[mpos+10] & 0xff | (m[mpos+11] & 0xff) << 8; h6 += ((t4 >>> 14) | (t5 << 2)) & 0x1fff;\n t6 = m[mpos+12] & 0xff | (m[mpos+13] & 0xff) << 8; h7 += ((t5 >>> 11) | (t6 << 5)) & 0x1fff;\n t7 = m[mpos+14] & 0xff | (m[mpos+15] & 0xff) << 8; h8 += ((t6 >>> 8) | (t7 << 8)) & 0x1fff;\n h9 += ((t7 >>> 5)) | hibit;\n\n c = 0;\n\n d0 = c;\n d0 += h0 * r0;\n d0 += h1 * (5 * r9);\n d0 += h2 * (5 * r8);\n d0 += h3 * (5 * r7);\n d0 += h4 * (5 * r6);\n c = (d0 >>> 13); d0 &= 0x1fff;\n d0 += h5 * (5 * r5);\n d0 += h6 * (5 * r4);\n d0 += h7 * (5 * r3);\n d0 += h8 * (5 * r2);\n d0 += h9 * (5 * r1);\n c += (d0 >>> 13); d0 &= 0x1fff;\n\n d1 = c;\n d1 += h0 * r1;\n d1 += h1 * r0;\n d1 += h2 * (5 * r9);\n d1 += h3 * (5 * r8);\n d1 += h4 * (5 * r7);\n c = (d1 >>> 13); d1 &= 0x1fff;\n d1 += h5 * (5 * r6);\n d1 += h6 * (5 * r5);\n d1 += h7 * (5 * r4);\n d1 += h8 * (5 * r3);\n d1 += h9 * (5 * r2);\n c += (d1 >>> 13); d1 &= 0x1fff;\n\n d2 = c;\n d2 += h0 * r2;\n d2 += h1 * r1;\n d2 += h2 * r0;\n d2 += h3 * (5 * r9);\n d2 += h4 * (5 * r8);\n c = (d2 >>> 13); d2 &= 0x1fff;\n d2 += h5 * (5 * r7);\n d2 += h6 * (5 * r6);\n d2 += h7 * (5 * r5);\n d2 += h8 * (5 * r4);\n d2 += h9 * (5 * r3);\n c += (d2 >>> 13); d2 &= 0x1fff;\n\n d3 = c;\n d3 += h0 * r3;\n d3 += h1 * r2;\n d3 += h2 * r1;\n d3 += h3 * r0;\n d3 += h4 * (5 * r9);\n c = (d3 >>> 13); d3 &= 0x1fff;\n d3 += h5 * (5 * r8);\n d3 += h6 * (5 * r7);\n d3 += h7 * (5 * r6);\n d3 += h8 * (5 * r5);\n d3 += h9 * (5 * r4);\n c += (d3 >>> 13); d3 &= 0x1fff;\n\n d4 = c;\n d4 += h0 * r4;\n d4 += h1 * r3;\n d4 += h2 * r2;\n d4 += h3 * r1;\n d4 += h4 * r0;\n c = (d4 >>> 13); d4 &= 0x1fff;\n d4 += h5 * (5 * r9);\n d4 += h6 * (5 * r8);\n d4 += h7 * (5 * r7);\n d4 += h8 * (5 * r6);\n d4 += h9 * (5 * r5);\n c += (d4 >>> 13); d4 &= 0x1fff;\n\n d5 = c;\n d5 += h0 * r5;\n d5 += h1 * r4;\n d5 += h2 * r3;\n d5 += h3 * r2;\n d5 += h4 * r1;\n c = (d5 >>> 13); d5 &= 0x1fff;\n d5 += h5 * r0;\n d5 += h6 * (5 * r9);\n d5 += h7 * (5 * r8);\n d5 += h8 * (5 * r7);\n d5 += h9 * (5 * r6);\n c += (d5 >>> 13); d5 &= 0x1fff;\n\n d6 = c;\n d6 += h0 * r6;\n d6 += h1 * r5;\n d6 += h2 * r4;\n d6 += h3 * r3;\n d6 += h4 * r2;\n c = (d6 >>> 13); d6 &= 0x1fff;\n d6 += h5 * r1;\n d6 += h6 * r0;\n d6 += h7 * (5 * r9);\n d6 += h8 * (5 * r8);\n d6 += h9 * (5 * r7);\n c += (d6 >>> 13); d6 &= 0x1fff;\n\n d7 = c;\n d7 += h0 * r7;\n d7 += h1 * r6;\n d7 += h2 * r5;\n d7 += h3 * r4;\n d7 += h4 * r3;\n c = (d7 >>> 13); d7 &= 0x1fff;\n d7 += h5 * r2;\n d7 += h6 * r1;\n d7 += h7 * r0;\n d7 += h8 * (5 * r9);\n d7 += h9 * (5 * r8);\n c += (d7 >>> 13); d7 &= 0x1fff;\n\n d8 = c;\n d8 += h0 * r8;\n d8 += h1 * r7;\n d8 += h2 * r6;\n d8 += h3 * r5;\n d8 += h4 * r4;\n c = (d8 >>> 13); d8 &= 0x1fff;\n d8 += h5 * r3;\n d8 += h6 * r2;\n d8 += h7 * r1;\n d8 += h8 * r0;\n d8 += h9 * (5 * r9);\n c += (d8 >>> 13); d8 &= 0x1fff;\n\n d9 = c;\n d9 += h0 * r9;\n d9 += h1 * r8;\n d9 += h2 * r7;\n d9 += h3 * r6;\n d9 += h4 * r5;\n c = (d9 >>> 13); d9 &= 0x1fff;\n d9 += h5 * r4;\n d9 += h6 * r3;\n d9 += h7 * r2;\n d9 += h8 * r1;\n d9 += h9 * r0;\n c += (d9 >>> 13); d9 &= 0x1fff;\n\n c = (((c << 2) + c)) | 0;\n c = (c + d0) | 0;\n d0 = c & 0x1fff;\n c = (c >>> 13);\n d1 += c;\n\n h0 = d0;\n h1 = d1;\n h2 = d2;\n h3 = d3;\n h4 = d4;\n h5 = d5;\n h6 = d6;\n h7 = d7;\n h8 = d8;\n h9 = d9;\n\n mpos += 16;\n bytes -= 16;\n }\n this.h[0] = h0;\n this.h[1] = h1;\n this.h[2] = h2;\n this.h[3] = h3;\n this.h[4] = h4;\n this.h[5] = h5;\n this.h[6] = h6;\n this.h[7] = h7;\n this.h[8] = h8;\n this.h[9] = h9;\n};\n\npoly1305.prototype.finish = function(mac, macpos) {\n var g = new Uint16Array(10);\n var c, mask, f, i;\n\n if (this.leftover) {\n i = this.leftover;\n this.buffer[i++] = 1;\n for (; i < 16; i++) this.buffer[i] = 0;\n this.fin = 1;\n this.blocks(this.buffer, 0, 16);\n }\n\n c = this.h[1] >>> 13;\n this.h[1] &= 0x1fff;\n for (i = 2; i < 10; i++) {\n this.h[i] += c;\n c = this.h[i] >>> 13;\n this.h[i] &= 0x1fff;\n }\n this.h[0] += (c * 5);\n c = this.h[0] >>> 13;\n this.h[0] &= 0x1fff;\n this.h[1] += c;\n c = this.h[1] >>> 13;\n this.h[1] &= 0x1fff;\n this.h[2] += c;\n\n g[0] = this.h[0] + 5;\n c = g[0] >>> 13;\n g[0] &= 0x1fff;\n for (i = 1; i < 10; i++) {\n g[i] = this.h[i] + c;\n c = g[i] >>> 13;\n g[i] &= 0x1fff;\n }\n g[9] -= (1 << 13);\n\n mask = (c ^ 1) - 1;\n for (i = 0; i < 10; i++) g[i] &= mask;\n mask = ~mask;\n for (i = 0; i < 10; i++) this.h[i] = (this.h[i] & mask) | g[i];\n\n this.h[0] = ((this.h[0] ) | (this.h[1] << 13) ) & 0xffff;\n this.h[1] = ((this.h[1] >>> 3) | (this.h[2] << 10) ) & 0xffff;\n this.h[2] = ((this.h[2] >>> 6) | (this.h[3] << 7) ) & 0xffff;\n this.h[3] = ((this.h[3] >>> 9) | (this.h[4] << 4) ) & 0xffff;\n this.h[4] = ((this.h[4] >>> 12) | (this.h[5] << 1) | (this.h[6] << 14)) & 0xffff;\n this.h[5] = ((this.h[6] >>> 2) | (this.h[7] << 11) ) & 0xffff;\n this.h[6] = ((this.h[7] >>> 5) | (this.h[8] << 8) ) & 0xffff;\n this.h[7] = ((this.h[8] >>> 8) | (this.h[9] << 5) ) & 0xffff;\n\n f = this.h[0] + this.pad[0];\n this.h[0] = f & 0xffff;\n for (i = 1; i < 8; i++) {\n f = (((this.h[i] + this.pad[i]) | 0) + (f >>> 16)) | 0;\n this.h[i] = f & 0xffff;\n }\n\n mac[macpos+ 0] = (this.h[0] >>> 0) & 0xff;\n mac[macpos+ 1] = (this.h[0] >>> 8) & 0xff;\n mac[macpos+ 2] = (this.h[1] >>> 0) & 0xff;\n mac[macpos+ 3] = (this.h[1] >>> 8) & 0xff;\n mac[macpos+ 4] = (this.h[2] >>> 0) & 0xff;\n mac[macpos+ 5] = (this.h[2] >>> 8) & 0xff;\n mac[macpos+ 6] = (this.h[3] >>> 0) & 0xff;\n mac[macpos+ 7] = (this.h[3] >>> 8) & 0xff;\n mac[macpos+ 8] = (this.h[4] >>> 0) & 0xff;\n mac[macpos+ 9] = (this.h[4] >>> 8) & 0xff;\n mac[macpos+10] = (this.h[5] >>> 0) & 0xff;\n mac[macpos+11] = (this.h[5] >>> 8) & 0xff;\n mac[macpos+12] = (this.h[6] >>> 0) & 0xff;\n mac[macpos+13] = (this.h[6] >>> 8) & 0xff;\n mac[macpos+14] = (this.h[7] >>> 0) & 0xff;\n mac[macpos+15] = (this.h[7] >>> 8) & 0xff;\n};\n\npoly1305.prototype.update = function(m, mpos, bytes) {\n var i, want;\n\n if (this.leftover) {\n want = (16 - this.leftover);\n if (want > bytes)\n want = bytes;\n for (i = 0; i < want; i++)\n this.buffer[this.leftover + i] = m[mpos+i];\n bytes -= want;\n mpos += want;\n this.leftover += want;\n if (this.leftover < 16)\n return;\n this.blocks(this.buffer, 0, 16);\n this.leftover = 0;\n }\n\n if (bytes >= 16) {\n want = bytes - (bytes % 16);\n this.blocks(m, mpos, want);\n mpos += want;\n bytes -= want;\n }\n\n if (bytes) {\n for (i = 0; i < bytes; i++)\n this.buffer[this.leftover + i] = m[mpos+i];\n this.leftover += bytes;\n }\n};\n\nfunction crypto_onetimeauth(out, outpos, m, mpos, n, k) {\n var s = new poly1305(k);\n s.update(m, mpos, n);\n s.finish(out, outpos);\n return 0;\n}\n\nfunction crypto_onetimeauth_verify(h, hpos, m, mpos, n, k) {\n var x = new Uint8Array(16);\n crypto_onetimeauth(x,0,m,mpos,n,k);\n return crypto_verify_16(h,hpos,x,0);\n}\n\nfunction crypto_secretbox(c,m,d,n,k) {\n var i;\n if (d < 32) return -1;\n crypto_stream_xor(c,0,m,0,d,n,k);\n crypto_onetimeauth(c, 16, c, 32, d - 32, c);\n for (i = 0; i < 16; i++) c[i] = 0;\n return 0;\n}\n\nfunction crypto_secretbox_open(m,c,d,n,k) {\n var i;\n var x = new Uint8Array(32);\n if (d < 32) return -1;\n crypto_stream(x,0,32,n,k);\n if (crypto_onetimeauth_verify(c, 16,c, 32,d - 32,x) !== 0) return -1;\n crypto_stream_xor(m,0,c,0,d,n,k);\n for (i = 0; i < 32; i++) m[i] = 0;\n return 0;\n}\n\nfunction set25519(r, a) {\n var i;\n for (i = 0; i < 16; i++) r[i] = a[i]|0;\n}\n\nfunction car25519(o) {\n var i, v, c = 1;\n for (i = 0; i < 16; i++) {\n v = o[i] + c + 65535;\n c = Math.floor(v / 65536);\n o[i] = v - c * 65536;\n }\n o[0] += c-1 + 37 * (c-1);\n}\n\nfunction sel25519(p, q, b) {\n var t, c = ~(b-1);\n for (var i = 0; i < 16; i++) {\n t = c & (p[i] ^ q[i]);\n p[i] ^= t;\n q[i] ^= t;\n }\n}\n\nfunction pack25519(o, n) {\n var i, j, b;\n var m = gf(), t = gf();\n for (i = 0; i < 16; i++) t[i] = n[i];\n car25519(t);\n car25519(t);\n car25519(t);\n for (j = 0; j < 2; j++) {\n m[0] = t[0] - 0xffed;\n for (i = 1; i < 15; i++) {\n m[i] = t[i] - 0xffff - ((m[i-1]>>16) & 1);\n m[i-1] &= 0xffff;\n }\n m[15] = t[15] - 0x7fff - ((m[14]>>16) & 1);\n b = (m[15]>>16) & 1;\n m[14] &= 0xffff;\n sel25519(t, m, 1-b);\n }\n for (i = 0; i < 16; i++) {\n o[2*i] = t[i] & 0xff;\n o[2*i+1] = t[i]>>8;\n }\n}\n\nfunction neq25519(a, b) {\n var c = new Uint8Array(32), d = new Uint8Array(32);\n pack25519(c, a);\n pack25519(d, b);\n return crypto_verify_32(c, 0, d, 0);\n}\n\nfunction par25519(a) {\n var d = new Uint8Array(32);\n pack25519(d, a);\n return d[0] & 1;\n}\n\nfunction unpack25519(o, n) {\n var i;\n for (i = 0; i < 16; i++) o[i] = n[2*i] + (n[2*i+1] << 8);\n o[15] &= 0x7fff;\n}\n\nfunction A(o, a, b) {\n for (var i = 0; i < 16; i++) o[i] = a[i] + b[i];\n}\n\nfunction Z(o, a, b) {\n for (var i = 0; i < 16; i++) o[i] = a[i] - b[i];\n}\n\nfunction M(o, a, b) {\n var v, c,\n t0 = 0, t1 = 0, t2 = 0, t3 = 0, t4 = 0, t5 = 0, t6 = 0, t7 = 0,\n t8 = 0, t9 = 0, t10 = 0, t11 = 0, t12 = 0, t13 = 0, t14 = 0, t15 = 0,\n t16 = 0, t17 = 0, t18 = 0, t19 = 0, t20 = 0, t21 = 0, t22 = 0, t23 = 0,\n t24 = 0, t25 = 0, t26 = 0, t27 = 0, t28 = 0, t29 = 0, t30 = 0,\n b0 = b[0],\n b1 = b[1],\n b2 = b[2],\n b3 = b[3],\n b4 = b[4],\n b5 = b[5],\n b6 = b[6],\n b7 = b[7],\n b8 = b[8],\n b9 = b[9],\n b10 = b[10],\n b11 = b[11],\n b12 = b[12],\n b13 = b[13],\n b14 = b[14],\n b15 = b[15];\n\n v = a[0];\n t0 += v * b0;\n t1 += v * b1;\n t2 += v * b2;\n t3 += v * b3;\n t4 += v * b4;\n t5 += v * b5;\n t6 += v * b6;\n t7 += v * b7;\n t8 += v * b8;\n t9 += v * b9;\n t10 += v * b10;\n t11 += v * b11;\n t12 += v * b12;\n t13 += v * b13;\n t14 += v * b14;\n t15 += v * b15;\n v = a[1];\n t1 += v * b0;\n t2 += v * b1;\n t3 += v * b2;\n t4 += v * b3;\n t5 += v * b4;\n t6 += v * b5;\n t7 += v * b6;\n t8 += v * b7;\n t9 += v * b8;\n t10 += v * b9;\n t11 += v * b10;\n t12 += v * b11;\n t13 += v * b12;\n t14 += v * b13;\n t15 += v * b14;\n t16 += v * b15;\n v = a[2];\n t2 += v * b0;\n t3 += v * b1;\n t4 += v * b2;\n t5 += v * b3;\n t6 += v * b4;\n t7 += v * b5;\n t8 += v * b6;\n t9 += v * b7;\n t10 += v * b8;\n t11 += v * b9;\n t12 += v * b10;\n t13 += v * b11;\n t14 += v * b12;\n t15 += v * b13;\n t16 += v * b14;\n t17 += v * b15;\n v = a[3];\n t3 += v * b0;\n t4 += v * b1;\n t5 += v * b2;\n t6 += v * b3;\n t7 += v * b4;\n t8 += v * b5;\n t9 += v * b6;\n t10 += v * b7;\n t11 += v * b8;\n t12 += v * b9;\n t13 += v * b10;\n t14 += v * b11;\n t15 += v * b12;\n t16 += v * b13;\n t17 += v * b14;\n t18 += v * b15;\n v = a[4];\n t4 += v * b0;\n t5 += v * b1;\n t6 += v * b2;\n t7 += v * b3;\n t8 += v * b4;\n t9 += v * b5;\n t10 += v * b6;\n t11 += v * b7;\n t12 += v * b8;\n t13 += v * b9;\n t14 += v * b10;\n t15 += v * b11;\n t16 += v * b12;\n t17 += v * b13;\n t18 += v * b14;\n t19 += v * b15;\n v = a[5];\n t5 += v * b0;\n t6 += v * b1;\n t7 += v * b2;\n t8 += v * b3;\n t9 += v * b4;\n t10 += v * b5;\n t11 += v * b6;\n t12 += v * b7;\n t13 += v * b8;\n t14 += v * b9;\n t15 += v * b10;\n t16 += v * b11;\n t17 += v * b12;\n t18 += v * b13;\n t19 += v * b14;\n t20 += v * b15;\n v = a[6];\n t6 += v * b0;\n t7 += v * b1;\n t8 += v * b2;\n t9 += v * b3;\n t10 += v * b4;\n t11 += v * b5;\n t12 += v * b6;\n t13 += v * b7;\n t14 += v * b8;\n t15 += v * b9;\n t16 += v * b10;\n t17 += v * b11;\n t18 += v * b12;\n t19 += v * b13;\n t20 += v * b14;\n t21 += v * b15;\n v = a[7];\n t7 += v * b0;\n t8 += v * b1;\n t9 += v * b2;\n t10 += v * b3;\n t11 += v * b4;\n t12 += v * b5;\n t13 += v * b6;\n t14 += v * b7;\n t15 += v * b8;\n t16 += v * b9;\n t17 += v * b10;\n t18 += v * b11;\n t19 += v * b12;\n t20 += v * b13;\n t21 += v * b14;\n t22 += v * b15;\n v = a[8];\n t8 += v * b0;\n t9 += v * b1;\n t10 += v * b2;\n t11 += v * b3;\n t12 += v * b4;\n t13 += v * b5;\n t14 += v * b6;\n t15 += v * b7;\n t16 += v * b8;\n t17 += v * b9;\n t18 += v * b10;\n t19 += v * b11;\n t20 += v * b12;\n t21 += v * b13;\n t22 += v * b14;\n t23 += v * b15;\n v = a[9];\n t9 += v * b0;\n t10 += v * b1;\n t11 += v * b2;\n t12 += v * b3;\n t13 += v * b4;\n t14 += v * b5;\n t15 += v * b6;\n t16 += v * b7;\n t17 += v * b8;\n t18 += v * b9;\n t19 += v * b10;\n t20 += v * b11;\n t21 += v * b12;\n t22 += v * b13;\n t23 += v * b14;\n t24 += v * b15;\n v = a[10];\n t10 += v * b0;\n t11 += v * b1;\n t12 += v * b2;\n t13 += v * b3;\n t14 += v * b4;\n t15 += v * b5;\n t16 += v * b6;\n t17 += v * b7;\n t18 += v * b8;\n t19 += v * b9;\n t20 += v * b10;\n t21 += v * b11;\n t22 += v * b12;\n t23 += v * b13;\n t24 += v * b14;\n t25 += v * b15;\n v = a[11];\n t11 += v * b0;\n t12 += v * b1;\n t13 += v * b2;\n t14 += v * b3;\n t15 += v * b4;\n t16 += v * b5;\n t17 += v * b6;\n t18 += v * b7;\n t19 += v * b8;\n t20 += v * b9;\n t21 += v * b10;\n t22 += v * b11;\n t23 += v * b12;\n t24 += v * b13;\n t25 += v * b14;\n t26 += v * b15;\n v = a[12];\n t12 += v * b0;\n t13 += v * b1;\n t14 += v * b2;\n t15 += v * b3;\n t16 += v * b4;\n t17 += v * b5;\n t18 += v * b6;\n t19 += v * b7;\n t20 += v * b8;\n t21 += v * b9;\n t22 += v * b10;\n t23 += v * b11;\n t24 += v * b12;\n t25 += v * b13;\n t26 += v * b14;\n t27 += v * b15;\n v = a[13];\n t13 += v * b0;\n t14 += v * b1;\n t15 += v * b2;\n t16 += v * b3;\n t17 += v * b4;\n t18 += v * b5;\n t19 += v * b6;\n t20 += v * b7;\n t21 += v * b8;\n t22 += v * b9;\n t23 += v * b10;\n t24 += v * b11;\n t25 += v * b12;\n t26 += v * b13;\n t27 += v * b14;\n t28 += v * b15;\n v = a[14];\n t14 += v * b0;\n t15 += v * b1;\n t16 += v * b2;\n t17 += v * b3;\n t18 += v * b4;\n t19 += v * b5;\n t20 += v * b6;\n t21 += v * b7;\n t22 += v * b8;\n t23 += v * b9;\n t24 += v * b10;\n t25 += v * b11;\n t26 += v * b12;\n t27 += v * b13;\n t28 += v * b14;\n t29 += v * b15;\n v = a[15];\n t15 += v * b0;\n t16 += v * b1;\n t17 += v * b2;\n t18 += v * b3;\n t19 += v * b4;\n t20 += v * b5;\n t21 += v * b6;\n t22 += v * b7;\n t23 += v * b8;\n t24 += v * b9;\n t25 += v * b10;\n t26 += v * b11;\n t27 += v * b12;\n t28 += v * b13;\n t29 += v * b14;\n t30 += v * b15;\n\n t0 += 38 * t16;\n t1 += 38 * t17;\n t2 += 38 * t18;\n t3 += 38 * t19;\n t4 += 38 * t20;\n t5 += 38 * t21;\n t6 += 38 * t22;\n t7 += 38 * t23;\n t8 += 38 * t24;\n t9 += 38 * t25;\n t10 += 38 * t26;\n t11 += 38 * t27;\n t12 += 38 * t28;\n t13 += 38 * t29;\n t14 += 38 * t30;\n // t15 left as is\n\n // first car\n c = 1;\n v = t0 + c + 65535; c = Math.floor(v / 65536); t0 = v - c * 65536;\n v = t1 + c + 65535; c = Math.floor(v / 65536); t1 = v - c * 65536;\n v = t2 + c + 65535; c = Math.floor(v / 65536); t2 = v - c * 65536;\n v = t3 + c + 65535; c = Math.floor(v / 65536); t3 = v - c * 65536;\n v = t4 + c + 65535; c = Math.floor(v / 65536); t4 = v - c * 65536;\n v = t5 + c + 65535; c = Math.floor(v / 65536); t5 = v - c * 65536;\n v = t6 + c + 65535; c = Math.floor(v / 65536); t6 = v - c * 65536;\n v = t7 + c + 65535; c = Math.floor(v / 65536); t7 = v - c * 65536;\n v = t8 + c + 65535; c = Math.floor(v / 65536); t8 = v - c * 65536;\n v = t9 + c + 65535; c = Math.floor(v / 65536); t9 = v - c * 65536;\n v = t10 + c + 65535; c = Math.floor(v / 65536); t10 = v - c * 65536;\n v = t11 + c + 65535; c = Math.floor(v / 65536); t11 = v - c * 65536;\n v = t12 + c + 65535; c = Math.floor(v / 65536); t12 = v - c * 65536;\n v = t13 + c + 65535; c = Math.floor(v / 65536); t13 = v - c * 65536;\n v = t14 + c + 65535; c = Math.floor(v / 65536); t14 = v - c * 65536;\n v = t15 + c + 65535; c = Math.floor(v / 65536); t15 = v - c * 65536;\n t0 += c-1 + 37 * (c-1);\n\n // second car\n c = 1;\n v = t0 + c + 65535; c = Math.floor(v / 65536); t0 = v - c * 65536;\n v = t1 + c + 65535; c = Math.floor(v / 65536); t1 = v - c * 65536;\n v = t2 + c + 65535; c = Math.floor(v / 65536); t2 = v - c * 65536;\n v = t3 + c + 65535; c = Math.floor(v / 65536); t3 = v - c * 65536;\n v = t4 + c + 65535; c = Math.floor(v / 65536); t4 = v - c * 65536;\n v = t5 + c + 65535; c = Math.floor(v / 65536); t5 = v - c * 65536;\n v = t6 + c + 65535; c = Math.floor(v / 65536); t6 = v - c * 65536;\n v = t7 + c + 65535; c = Math.floor(v / 65536); t7 = v - c * 65536;\n v = t8 + c + 65535; c = Math.floor(v / 65536); t8 = v - c * 65536;\n v = t9 + c + 65535; c = Math.floor(v / 65536); t9 = v - c * 65536;\n v = t10 + c + 65535; c = Math.floor(v / 65536); t10 = v - c * 65536;\n v = t11 + c + 65535; c = Math.floor(v / 65536); t11 = v - c * 65536;\n v = t12 + c + 65535; c = Math.floor(v / 65536); t12 = v - c * 65536;\n v = t13 + c + 65535; c = Math.floor(v / 65536); t13 = v - c * 65536;\n v = t14 + c + 65535; c = Math.floor(v / 65536); t14 = v - c * 65536;\n v = t15 + c + 65535; c = Math.floor(v / 65536); t15 = v - c * 65536;\n t0 += c-1 + 37 * (c-1);\n\n o[ 0] = t0;\n o[ 1] = t1;\n o[ 2] = t2;\n o[ 3] = t3;\n o[ 4] = t4;\n o[ 5] = t5;\n o[ 6] = t6;\n o[ 7] = t7;\n o[ 8] = t8;\n o[ 9] = t9;\n o[10] = t10;\n o[11] = t11;\n o[12] = t12;\n o[13] = t13;\n o[14] = t14;\n o[15] = t15;\n}\n\nfunction S(o, a) {\n M(o, a, a);\n}\n\nfunction inv25519(o, i) {\n var c = gf();\n var a;\n for (a = 0; a < 16; a++) c[a] = i[a];\n for (a = 253; a >= 0; a--) {\n S(c, c);\n if(a !== 2 && a !== 4) M(c, c, i);\n }\n for (a = 0; a < 16; a++) o[a] = c[a];\n}\n\nfunction pow2523(o, i) {\n var c = gf();\n var a;\n for (a = 0; a < 16; a++) c[a] = i[a];\n for (a = 250; a >= 0; a--) {\n S(c, c);\n if(a !== 1) M(c, c, i);\n }\n for (a = 0; a < 16; a++) o[a] = c[a];\n}\n\nfunction crypto_scalarmult(q, n, p) {\n var z = new Uint8Array(32);\n var x = new Float64Array(80), r, i;\n var a = gf(), b = gf(), c = gf(),\n d = gf(), e = gf(), f = gf();\n for (i = 0; i < 31; i++) z[i] = n[i];\n z[31]=(n[31]&127)|64;\n z[0]&=248;\n unpack25519(x,p);\n for (i = 0; i < 16; i++) {\n b[i]=x[i];\n d[i]=a[i]=c[i]=0;\n }\n a[0]=d[0]=1;\n for (i=254; i>=0; --i) {\n r=(z[i>>>3]>>>(i&7))&1;\n sel25519(a,b,r);\n sel25519(c,d,r);\n A(e,a,c);\n Z(a,a,c);\n A(c,b,d);\n Z(b,b,d);\n S(d,e);\n S(f,a);\n M(a,c,a);\n M(c,b,e);\n A(e,a,c);\n Z(a,a,c);\n S(b,a);\n Z(c,d,f);\n M(a,c,_121665);\n A(a,a,d);\n M(c,c,a);\n M(a,d,f);\n M(d,b,x);\n S(b,e);\n sel25519(a,b,r);\n sel25519(c,d,r);\n }\n for (i = 0; i < 16; i++) {\n x[i+16]=a[i];\n x[i+32]=c[i];\n x[i+48]=b[i];\n x[i+64]=d[i];\n }\n var x32 = x.subarray(32);\n var x16 = x.subarray(16);\n inv25519(x32,x32);\n M(x16,x16,x32);\n pack25519(q,x16);\n return 0;\n}\n\nfunction crypto_scalarmult_base(q, n) {\n return crypto_scalarmult(q, n, _9);\n}\n\nfunction crypto_box_keypair(y, x) {\n randombytes(x, 32);\n return crypto_scalarmult_base(y, x);\n}\n\nfunction crypto_box_beforenm(k, y, x) {\n var s = new Uint8Array(32);\n crypto_scalarmult(s, x, y);\n return crypto_core_hsalsa20(k, _0, s, sigma);\n}\n\nvar crypto_box_afternm = crypto_secretbox;\nvar crypto_box_open_afternm = crypto_secretbox_open;\n\nfunction crypto_box(c, m, d, n, y, x) {\n var k = new Uint8Array(32);\n crypto_box_beforenm(k, y, x);\n return crypto_box_afternm(c, m, d, n, k);\n}\n\nfunction crypto_box_open(m, c, d, n, y, x) {\n var k = new Uint8Array(32);\n crypto_box_beforenm(k, y, x);\n return crypto_box_open_afternm(m, c, d, n, k);\n}\n\nvar K = [\n 0x428a2f98, 0xd728ae22, 0x71374491, 0x23ef65cd,\n 0xb5c0fbcf, 0xec4d3b2f, 0xe9b5dba5, 0x8189dbbc,\n 0x3956c25b, 0xf348b538, 0x59f111f1, 0xb605d019,\n 0x923f82a4, 0xaf194f9b, 0xab1c5ed5, 0xda6d8118,\n 0xd807aa98, 0xa3030242, 0x12835b01, 0x45706fbe,\n 0x243185be, 0x4ee4b28c, 0x550c7dc3, 0xd5ffb4e2,\n 0x72be5d74, 0xf27b896f, 0x80deb1fe, 0x3b1696b1,\n 0x9bdc06a7, 0x25c71235, 0xc19bf174, 0xcf692694,\n 0xe49b69c1, 0x9ef14ad2, 0xefbe4786, 0x384f25e3,\n 0x0fc19dc6, 0x8b8cd5b5, 0x240ca1cc, 0x77ac9c65,\n 0x2de92c6f, 0x592b0275, 0x4a7484aa, 0x6ea6e483,\n 0x5cb0a9dc, 0xbd41fbd4, 0x76f988da, 0x831153b5,\n 0x983e5152, 0xee66dfab, 0xa831c66d, 0x2db43210,\n 0xb00327c8, 0x98fb213f, 0xbf597fc7, 0xbeef0ee4,\n 0xc6e00bf3, 0x3da88fc2, 0xd5a79147, 0x930aa725,\n 0x06ca6351, 0xe003826f, 0x14292967, 0x0a0e6e70,\n 0x27b70a85, 0x46d22ffc, 0x2e1b2138, 0x5c26c926,\n 0x4d2c6dfc, 0x5ac42aed, 0x53380d13, 0x9d95b3df,\n 0x650a7354, 0x8baf63de, 0x766a0abb, 0x3c77b2a8,\n 0x81c2c92e, 0x47edaee6, 0x92722c85, 0x1482353b,\n 0xa2bfe8a1, 0x4cf10364, 0xa81a664b, 0xbc423001,\n 0xc24b8b70, 0xd0f89791, 0xc76c51a3, 0x0654be30,\n 0xd192e819, 0xd6ef5218, 0xd6990624, 0x5565a910,\n 0xf40e3585, 0x5771202a, 0x106aa070, 0x32bbd1b8,\n 0x19a4c116, 0xb8d2d0c8, 0x1e376c08, 0x5141ab53,\n 0x2748774c, 0xdf8eeb99, 0x34b0bcb5, 0xe19b48a8,\n 0x391c0cb3, 0xc5c95a63, 0x4ed8aa4a, 0xe3418acb,\n 0x5b9cca4f, 0x7763e373, 0x682e6ff3, 0xd6b2b8a3,\n 0x748f82ee, 0x5defb2fc, 0x78a5636f, 0x43172f60,\n 0x84c87814, 0xa1f0ab72, 0x8cc70208, 0x1a6439ec,\n 0x90befffa, 0x23631e28, 0xa4506ceb, 0xde82bde9,\n 0xbef9a3f7, 0xb2c67915, 0xc67178f2, 0xe372532b,\n 0xca273ece, 0xea26619c, 0xd186b8c7, 0x21c0c207,\n 0xeada7dd6, 0xcde0eb1e, 0xf57d4f7f, 0xee6ed178,\n 0x06f067aa, 0x72176fba, 0x0a637dc5, 0xa2c898a6,\n 0x113f9804, 0xbef90dae, 0x1b710b35, 0x131c471b,\n 0x28db77f5, 0x23047d84, 0x32caab7b, 0x40c72493,\n 0x3c9ebe0a, 0x15c9bebc, 0x431d67c4, 0x9c100d4c,\n 0x4cc5d4be, 0xcb3e42b6, 0x597f299c, 0xfc657e2a,\n 0x5fcb6fab, 0x3ad6faec, 0x6c44198c, 0x4a475817\n];\n\nfunction crypto_hashblocks_hl(hh, hl, m, n) {\n var wh = new Int32Array(16), wl = new Int32Array(16),\n bh0, bh1, bh2, bh3, bh4, bh5, bh6, bh7,\n bl0, bl1, bl2, bl3, bl4, bl5, bl6, bl7,\n th, tl, i, j, h, l, a, b, c, d;\n\n var ah0 = hh[0],\n ah1 = hh[1],\n ah2 = hh[2],\n ah3 = hh[3],\n ah4 = hh[4],\n ah5 = hh[5],\n ah6 = hh[6],\n ah7 = hh[7],\n\n al0 = hl[0],\n al1 = hl[1],\n al2 = hl[2],\n al3 = hl[3],\n al4 = hl[4],\n al5 = hl[5],\n al6 = hl[6],\n al7 = hl[7];\n\n var pos = 0;\n while (n >= 128) {\n for (i = 0; i < 16; i++) {\n j = 8 * i + pos;\n wh[i] = (m[j+0] << 24) | (m[j+1] << 16) | (m[j+2] << 8) | m[j+3];\n wl[i] = (m[j+4] << 24) | (m[j+5] << 16) | (m[j+6] << 8) | m[j+7];\n }\n for (i = 0; i < 80; i++) {\n bh0 = ah0;\n bh1 = ah1;\n bh2 = ah2;\n bh3 = ah3;\n bh4 = ah4;\n bh5 = ah5;\n bh6 = ah6;\n bh7 = ah7;\n\n bl0 = al0;\n bl1 = al1;\n bl2 = al2;\n bl3 = al3;\n bl4 = al4;\n bl5 = al5;\n bl6 = al6;\n bl7 = al7;\n\n // add\n h = ah7;\n l = al7;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n // Sigma1\n h = ((ah4 >>> 14) | (al4 << (32-14))) ^ ((ah4 >>> 18) | (al4 << (32-18))) ^ ((al4 >>> (41-32)) | (ah4 << (32-(41-32))));\n l = ((al4 >>> 14) | (ah4 << (32-14))) ^ ((al4 >>> 18) | (ah4 << (32-18))) ^ ((ah4 >>> (41-32)) | (al4 << (32-(41-32))));\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // Ch\n h = (ah4 & ah5) ^ (~ah4 & ah6);\n l = (al4 & al5) ^ (~al4 & al6);\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // K\n h = K[i*2];\n l = K[i*2+1];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // w\n h = wh[i%16];\n l = wl[i%16];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n th = c & 0xffff | d << 16;\n tl = a & 0xffff | b << 16;\n\n // add\n h = th;\n l = tl;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n // Sigma0\n h = ((ah0 >>> 28) | (al0 << (32-28))) ^ ((al0 >>> (34-32)) | (ah0 << (32-(34-32)))) ^ ((al0 >>> (39-32)) | (ah0 << (32-(39-32))));\n l = ((al0 >>> 28) | (ah0 << (32-28))) ^ ((ah0 >>> (34-32)) | (al0 << (32-(34-32)))) ^ ((ah0 >>> (39-32)) | (al0 << (32-(39-32))));\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // Maj\n h = (ah0 & ah1) ^ (ah0 & ah2) ^ (ah1 & ah2);\n l = (al0 & al1) ^ (al0 & al2) ^ (al1 & al2);\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n bh7 = (c & 0xffff) | (d << 16);\n bl7 = (a & 0xffff) | (b << 16);\n\n // add\n h = bh3;\n l = bl3;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = th;\n l = tl;\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n bh3 = (c & 0xffff) | (d << 16);\n bl3 = (a & 0xffff) | (b << 16);\n\n ah1 = bh0;\n ah2 = bh1;\n ah3 = bh2;\n ah4 = bh3;\n ah5 = bh4;\n ah6 = bh5;\n ah7 = bh6;\n ah0 = bh7;\n\n al1 = bl0;\n al2 = bl1;\n al3 = bl2;\n al4 = bl3;\n al5 = bl4;\n al6 = bl5;\n al7 = bl6;\n al0 = bl7;\n\n if (i%16 === 15) {\n for (j = 0; j < 16; j++) {\n // add\n h = wh[j];\n l = wl[j];\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = wh[(j+9)%16];\n l = wl[(j+9)%16];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // sigma0\n th = wh[(j+1)%16];\n tl = wl[(j+1)%16];\n h = ((th >>> 1) | (tl << (32-1))) ^ ((th >>> 8) | (tl << (32-8))) ^ (th >>> 7);\n l = ((tl >>> 1) | (th << (32-1))) ^ ((tl >>> 8) | (th << (32-8))) ^ ((tl >>> 7) | (th << (32-7)));\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // sigma1\n th = wh[(j+14)%16];\n tl = wl[(j+14)%16];\n h = ((th >>> 19) | (tl << (32-19))) ^ ((tl >>> (61-32)) | (th << (32-(61-32)))) ^ (th >>> 6);\n l = ((tl >>> 19) | (th << (32-19))) ^ ((th >>> (61-32)) | (tl << (32-(61-32)))) ^ ((tl >>> 6) | (th << (32-6)));\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n wh[j] = (c & 0xffff) | (d << 16);\n wl[j] = (a & 0xffff) | (b << 16);\n }\n }\n }\n\n // add\n h = ah0;\n l = al0;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[0];\n l = hl[0];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[0] = ah0 = (c & 0xffff) | (d << 16);\n hl[0] = al0 = (a & 0xffff) | (b << 16);\n\n h = ah1;\n l = al1;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[1];\n l = hl[1];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[1] = ah1 = (c & 0xffff) | (d << 16);\n hl[1] = al1 = (a & 0xffff) | (b << 16);\n\n h = ah2;\n l = al2;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[2];\n l = hl[2];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[2] = ah2 = (c & 0xffff) | (d << 16);\n hl[2] = al2 = (a & 0xffff) | (b << 16);\n\n h = ah3;\n l = al3;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[3];\n l = hl[3];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[3] = ah3 = (c & 0xffff) | (d << 16);\n hl[3] = al3 = (a & 0xffff) | (b << 16);\n\n h = ah4;\n l = al4;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[4];\n l = hl[4];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[4] = ah4 = (c & 0xffff) | (d << 16);\n hl[4] = al4 = (a & 0xffff) | (b << 16);\n\n h = ah5;\n l = al5;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[5];\n l = hl[5];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[5] = ah5 = (c & 0xffff) | (d << 16);\n hl[5] = al5 = (a & 0xffff) | (b << 16);\n\n h = ah6;\n l = al6;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[6];\n l = hl[6];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[6] = ah6 = (c & 0xffff) | (d << 16);\n hl[6] = al6 = (a & 0xffff) | (b << 16);\n\n h = ah7;\n l = al7;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[7];\n l = hl[7];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[7] = ah7 = (c & 0xffff) | (d << 16);\n hl[7] = al7 = (a & 0xffff) | (b << 16);\n\n pos += 128;\n n -= 128;\n }\n\n return n;\n}\n\nfunction crypto_hash(out, m, n) {\n var hh = new Int32Array(8),\n hl = new Int32Array(8),\n x = new Uint8Array(256),\n i, b = n;\n\n hh[0] = 0x6a09e667;\n hh[1] = 0xbb67ae85;\n hh[2] = 0x3c6ef372;\n hh[3] = 0xa54ff53a;\n hh[4] = 0x510e527f;\n hh[5] = 0x9b05688c;\n hh[6] = 0x1f83d9ab;\n hh[7] = 0x5be0cd19;\n\n hl[0] = 0xf3bcc908;\n hl[1] = 0x84caa73b;\n hl[2] = 0xfe94f82b;\n hl[3] = 0x5f1d36f1;\n hl[4] = 0xade682d1;\n hl[5] = 0x2b3e6c1f;\n hl[6] = 0xfb41bd6b;\n hl[7] = 0x137e2179;\n\n crypto_hashblocks_hl(hh, hl, m, n);\n n %= 128;\n\n for (i = 0; i < n; i++) x[i] = m[b-n+i];\n x[n] = 128;\n\n n = 256-128*(n<112?1:0);\n x[n-9] = 0;\n ts64(x, n-8, (b / 0x20000000) | 0, b << 3);\n crypto_hashblocks_hl(hh, hl, x, n);\n\n for (i = 0; i < 8; i++) ts64(out, 8*i, hh[i], hl[i]);\n\n return 0;\n}\n\nfunction add(p, q) {\n var a = gf(), b = gf(), c = gf(),\n d = gf(), e = gf(), f = gf(),\n g = gf(), h = gf(), t = gf();\n\n Z(a, p[1], p[0]);\n Z(t, q[1], q[0]);\n M(a, a, t);\n A(b, p[0], p[1]);\n A(t, q[0], q[1]);\n M(b, b, t);\n M(c, p[3], q[3]);\n M(c, c, D2);\n M(d, p[2], q[2]);\n A(d, d, d);\n Z(e, b, a);\n Z(f, d, c);\n A(g, d, c);\n A(h, b, a);\n\n M(p[0], e, f);\n M(p[1], h, g);\n M(p[2], g, f);\n M(p[3], e, h);\n}\n\nfunction cswap(p, q, b) {\n var i;\n for (i = 0; i < 4; i++) {\n sel25519(p[i], q[i], b);\n }\n}\n\nfunction pack(r, p) {\n var tx = gf(), ty = gf(), zi = gf();\n inv25519(zi, p[2]);\n M(tx, p[0], zi);\n M(ty, p[1], zi);\n pack25519(r, ty);\n r[31] ^= par25519(tx) << 7;\n}\n\nfunction scalarmult(p, q, s) {\n var b, i;\n set25519(p[0], gf0);\n set25519(p[1], gf1);\n set25519(p[2], gf1);\n set25519(p[3], gf0);\n for (i = 255; i >= 0; --i) {\n b = (s[(i/8)|0] >> (i&7)) & 1;\n cswap(p, q, b);\n add(q, p);\n add(p, p);\n cswap(p, q, b);\n }\n}\n\nfunction scalarbase(p, s) {\n var q = [gf(), gf(), gf(), gf()];\n set25519(q[0], X);\n set25519(q[1], Y);\n set25519(q[2], gf1);\n M(q[3], X, Y);\n scalarmult(p, q, s);\n}\n\nfunction crypto_sign_keypair(pk, sk, seeded) {\n var d = new Uint8Array(64);\n var p = [gf(), gf(), gf(), gf()];\n var i;\n\n if (!seeded) randombytes(sk, 32);\n crypto_hash(d, sk, 32);\n d[0] &= 248;\n d[31] &= 127;\n d[31] |= 64;\n\n scalarbase(p, d);\n pack(pk, p);\n\n for (i = 0; i < 32; i++) sk[i+32] = pk[i];\n return 0;\n}\n\nvar L = new Float64Array([0xed, 0xd3, 0xf5, 0x5c, 0x1a, 0x63, 0x12, 0x58, 0xd6, 0x9c, 0xf7, 0xa2, 0xde, 0xf9, 0xde, 0x14, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x10]);\n\nfunction modL(r, x) {\n var carry, i, j, k;\n for (i = 63; i >= 32; --i) {\n carry = 0;\n for (j = i - 32, k = i - 12; j < k; ++j) {\n x[j] += carry - 16 * x[i] * L[j - (i - 32)];\n carry = Math.floor((x[j] + 128) / 256);\n x[j] -= carry * 256;\n }\n x[j] += carry;\n x[i] = 0;\n }\n carry = 0;\n for (j = 0; j < 32; j++) {\n x[j] += carry - (x[31] >> 4) * L[j];\n carry = x[j] >> 8;\n x[j] &= 255;\n }\n for (j = 0; j < 32; j++) x[j] -= carry * L[j];\n for (i = 0; i < 32; i++) {\n x[i+1] += x[i] >> 8;\n r[i] = x[i] & 255;\n }\n}\n\nfunction reduce(r) {\n var x = new Float64Array(64), i;\n for (i = 0; i < 64; i++) x[i] = r[i];\n for (i = 0; i < 64; i++) r[i] = 0;\n modL(r, x);\n}\n\n// Note: difference from C - smlen returned, not passed as argument.\nfunction crypto_sign(sm, m, n, sk) {\n var d = new Uint8Array(64), h = new Uint8Array(64), r = new Uint8Array(64);\n var i, j, x = new Float64Array(64);\n var p = [gf(), gf(), gf(), gf()];\n\n crypto_hash(d, sk, 32);\n d[0] &= 248;\n d[31] &= 127;\n d[31] |= 64;\n\n var smlen = n + 64;\n for (i = 0; i < n; i++) sm[64 + i] = m[i];\n for (i = 0; i < 32; i++) sm[32 + i] = d[32 + i];\n\n crypto_hash(r, sm.subarray(32), n+32);\n reduce(r);\n scalarbase(p, r);\n pack(sm, p);\n\n for (i = 32; i < 64; i++) sm[i] = sk[i];\n crypto_hash(h, sm, n + 64);\n reduce(h);\n\n for (i = 0; i < 64; i++) x[i] = 0;\n for (i = 0; i < 32; i++) x[i] = r[i];\n for (i = 0; i < 32; i++) {\n for (j = 0; j < 32; j++) {\n x[i+j] += h[i] * d[j];\n }\n }\n\n modL(sm.subarray(32), x);\n return smlen;\n}\n\nfunction unpackneg(r, p) {\n var t = gf(), chk = gf(), num = gf(),\n den = gf(), den2 = gf(), den4 = gf(),\n den6 = gf();\n\n set25519(r[2], gf1);\n unpack25519(r[1], p);\n S(num, r[1]);\n M(den, num, D);\n Z(num, num, r[2]);\n A(den, r[2], den);\n\n S(den2, den);\n S(den4, den2);\n M(den6, den4, den2);\n M(t, den6, num);\n M(t, t, den);\n\n pow2523(t, t);\n M(t, t, num);\n M(t, t, den);\n M(t, t, den);\n M(r[0], t, den);\n\n S(chk, r[0]);\n M(chk, chk, den);\n if (neq25519(chk, num)) M(r[0], r[0], I);\n\n S(chk, r[0]);\n M(chk, chk, den);\n if (neq25519(chk, num)) return -1;\n\n if (par25519(r[0]) === (p[31]>>7)) Z(r[0], gf0, r[0]);\n\n M(r[3], r[0], r[1]);\n return 0;\n}\n\nfunction crypto_sign_open(m, sm, n, pk) {\n var i;\n var t = new Uint8Array(32), h = new Uint8Array(64);\n var p = [gf(), gf(), gf(), gf()],\n q = [gf(), gf(), gf(), gf()];\n\n if (n < 64) return -1;\n\n if (unpackneg(q, pk)) return -1;\n\n for (i = 0; i < n; i++) m[i] = sm[i];\n for (i = 0; i < 32; i++) m[i+32] = pk[i];\n crypto_hash(h, m, n);\n reduce(h);\n scalarmult(p, q, h);\n\n scalarbase(q, sm.subarray(32));\n add(p, q);\n pack(t, p);\n\n n -= 64;\n if (crypto_verify_32(sm, 0, t, 0)) {\n for (i = 0; i < n; i++) m[i] = 0;\n return -1;\n }\n\n for (i = 0; i < n; i++) m[i] = sm[i + 64];\n return n;\n}\n\nvar crypto_secretbox_KEYBYTES = 32,\n crypto_secretbox_NONCEBYTES = 24,\n crypto_secretbox_ZEROBYTES = 32,\n crypto_secretbox_BOXZEROBYTES = 16,\n crypto_scalarmult_BYTES = 32,\n crypto_scalarmult_SCALARBYTES = 32,\n crypto_box_PUBLICKEYBYTES = 32,\n crypto_box_SECRETKEYBYTES = 32,\n crypto_box_BEFORENMBYTES = 32,\n crypto_box_NONCEBYTES = crypto_secretbox_NONCEBYTES,\n crypto_box_ZEROBYTES = crypto_secretbox_ZEROBYTES,\n crypto_box_BOXZEROBYTES = crypto_secretbox_BOXZEROBYTES,\n crypto_sign_BYTES = 64,\n crypto_sign_PUBLICKEYBYTES = 32,\n crypto_sign_SECRETKEYBYTES = 64,\n crypto_sign_SEEDBYTES = 32,\n crypto_hash_BYTES = 64;\n\nnacl.lowlevel = {\n crypto_core_hsalsa20: crypto_core_hsalsa20,\n crypto_stream_xor: crypto_stream_xor,\n crypto_stream: crypto_stream,\n crypto_stream_salsa20_xor: crypto_stream_salsa20_xor,\n crypto_stream_salsa20: crypto_stream_salsa20,\n crypto_onetimeauth: crypto_onetimeauth,\n crypto_onetimeauth_verify: crypto_onetimeauth_verify,\n crypto_verify_16: crypto_verify_16,\n crypto_verify_32: crypto_verify_32,\n crypto_secretbox: crypto_secretbox,\n crypto_secretbox_open: crypto_secretbox_open,\n crypto_scalarmult: crypto_scalarmult,\n crypto_scalarmult_base: crypto_scalarmult_base,\n crypto_box_beforenm: crypto_box_beforenm,\n crypto_box_afternm: crypto_box_afternm,\n crypto_box: crypto_box,\n crypto_box_open: crypto_box_open,\n crypto_box_keypair: crypto_box_keypair,\n crypto_hash: crypto_hash,\n crypto_sign: crypto_sign,\n crypto_sign_keypair: crypto_sign_keypair,\n crypto_sign_open: crypto_sign_open,\n\n crypto_secretbox_KEYBYTES: crypto_secretbox_KEYBYTES,\n crypto_secretbox_NONCEBYTES: crypto_secretbox_NONCEBYTES,\n crypto_secretbox_ZEROBYTES: crypto_secretbox_ZEROBYTES,\n crypto_secretbox_BOXZEROBYTES: crypto_secretbox_BOXZEROBYTES,\n crypto_scalarmult_BYTES: crypto_scalarmult_BYTES,\n crypto_scalarmult_SCALARBYTES: crypto_scalarmult_SCALARBYTES,\n crypto_box_PUBLICKEYBYTES: crypto_box_PUBLICKEYBYTES,\n crypto_box_SECRETKEYBYTES: crypto_box_SECRETKEYBYTES,\n crypto_box_BEFORENMBYTES: crypto_box_BEFORENMBYTES,\n crypto_box_NONCEBYTES: crypto_box_NONCEBYTES,\n crypto_box_ZEROBYTES: crypto_box_ZEROBYTES,\n crypto_box_BOXZEROBYTES: crypto_box_BOXZEROBYTES,\n crypto_sign_BYTES: crypto_sign_BYTES,\n crypto_sign_PUBLICKEYBYTES: crypto_sign_PUBLICKEYBYTES,\n crypto_sign_SECRETKEYBYTES: crypto_sign_SECRETKEYBYTES,\n crypto_sign_SEEDBYTES: crypto_sign_SEEDBYTES,\n crypto_hash_BYTES: crypto_hash_BYTES,\n\n gf: gf,\n D: D,\n L: L,\n pack25519: pack25519,\n unpack25519: unpack25519,\n M: M,\n A: A,\n S: S,\n Z: Z,\n pow2523: pow2523,\n add: add,\n set25519: set25519,\n modL: modL,\n scalarmult: scalarmult,\n scalarbase: scalarbase,\n};\n\n/* High-level API */\n\nfunction checkLengths(k, n) {\n if (k.length !== crypto_secretbox_KEYBYTES) throw new Error('bad key size');\n if (n.length !== crypto_secretbox_NONCEBYTES) throw new Error('bad nonce size');\n}\n\nfunction checkBoxLengths(pk, sk) {\n if (pk.length !== crypto_box_PUBLICKEYBYTES) throw new Error('bad public key size');\n if (sk.length !== crypto_box_SECRETKEYBYTES) throw new Error('bad secret key size');\n}\n\nfunction checkArrayTypes() {\n for (var i = 0; i < arguments.length; i++) {\n if (!(arguments[i] instanceof Uint8Array))\n throw new TypeError('unexpected type, use Uint8Array');\n }\n}\n\nfunction cleanup(arr) {\n for (var i = 0; i < arr.length; i++) arr[i] = 0;\n}\n\nnacl.randomBytes = function(n) {\n var b = new Uint8Array(n);\n randombytes(b, n);\n return b;\n};\n\nnacl.secretbox = function(msg, nonce, key) {\n checkArrayTypes(msg, nonce, key);\n checkLengths(key, nonce);\n var m = new Uint8Array(crypto_secretbox_ZEROBYTES + msg.length);\n var c = new Uint8Array(m.length);\n for (var i = 0; i < msg.length; i++) m[i+crypto_secretbox_ZEROBYTES] = msg[i];\n crypto_secretbox(c, m, m.length, nonce, key);\n return c.subarray(crypto_secretbox_BOXZEROBYTES);\n};\n\nnacl.secretbox.open = function(box, nonce, key) {\n checkArrayTypes(box, nonce, key);\n checkLengths(key, nonce);\n var c = new Uint8Array(crypto_secretbox_BOXZEROBYTES + box.length);\n var m = new Uint8Array(c.length);\n for (var i = 0; i < box.length; i++) c[i+crypto_secretbox_BOXZEROBYTES] = box[i];\n if (c.length < 32) return null;\n if (crypto_secretbox_open(m, c, c.length, nonce, key) !== 0) return null;\n return m.subarray(crypto_secretbox_ZEROBYTES);\n};\n\nnacl.secretbox.keyLength = crypto_secretbox_KEYBYTES;\nnacl.secretbox.nonceLength = crypto_secretbox_NONCEBYTES;\nnacl.secretbox.overheadLength = crypto_secretbox_BOXZEROBYTES;\n\nnacl.scalarMult = function(n, p) {\n checkArrayTypes(n, p);\n if (n.length !== crypto_scalarmult_SCALARBYTES) throw new Error('bad n size');\n if (p.length !== crypto_scalarmult_BYTES) throw new Error('bad p size');\n var q = new Uint8Array(crypto_scalarmult_BYTES);\n crypto_scalarmult(q, n, p);\n return q;\n};\n\nnacl.scalarMult.base = function(n) {\n checkArrayTypes(n);\n if (n.length !== crypto_scalarmult_SCALARBYTES) throw new Error('bad n size');\n var q = new Uint8Array(crypto_scalarmult_BYTES);\n crypto_scalarmult_base(q, n);\n return q;\n};\n\nnacl.scalarMult.scalarLength = crypto_scalarmult_SCALARBYTES;\nnacl.scalarMult.groupElementLength = crypto_scalarmult_BYTES;\n\nnacl.box = function(msg, nonce, publicKey, secretKey) {\n var k = nacl.box.before(publicKey, secretKey);\n return nacl.secretbox(msg, nonce, k);\n};\n\nnacl.box.before = function(publicKey, secretKey) {\n checkArrayTypes(publicKey, secretKey);\n checkBoxLengths(publicKey, secretKey);\n var k = new Uint8Array(crypto_box_BEFORENMBYTES);\n crypto_box_beforenm(k, publicKey, secretKey);\n return k;\n};\n\nnacl.box.after = nacl.secretbox;\n\nnacl.box.open = function(msg, nonce, publicKey, secretKey) {\n var k = nacl.box.before(publicKey, secretKey);\n return nacl.secretbox.open(msg, nonce, k);\n};\n\nnacl.box.open.after = nacl.secretbox.open;\n\nnacl.box.keyPair = function() {\n var pk = new Uint8Array(crypto_box_PUBLICKEYBYTES);\n var sk = new Uint8Array(crypto_box_SECRETKEYBYTES);\n crypto_box_keypair(pk, sk);\n return {publicKey: pk, secretKey: sk};\n};\n\nnacl.box.keyPair.fromSecretKey = function(secretKey) {\n checkArrayTypes(secretKey);\n if (secretKey.length !== crypto_box_SECRETKEYBYTES)\n throw new Error('bad secret key size');\n var pk = new Uint8Array(crypto_box_PUBLICKEYBYTES);\n crypto_scalarmult_base(pk, secretKey);\n return {publicKey: pk, secretKey: new Uint8Array(secretKey)};\n};\n\nnacl.box.publicKeyLength = crypto_box_PUBLICKEYBYTES;\nnacl.box.secretKeyLength = crypto_box_SECRETKEYBYTES;\nnacl.box.sharedKeyLength = crypto_box_BEFORENMBYTES;\nnacl.box.nonceLength = crypto_box_NONCEBYTES;\nnacl.box.overheadLength = nacl.secretbox.overheadLength;\n\nnacl.sign = function(msg, secretKey) {\n checkArrayTypes(msg, secretKey);\n if (secretKey.length !== crypto_sign_SECRETKEYBYTES)\n throw new Error('bad secret key size');\n var signedMsg = new Uint8Array(crypto_sign_BYTES+msg.length);\n crypto_sign(signedMsg, msg, msg.length, secretKey);\n return signedMsg;\n};\n\nnacl.sign.open = function(signedMsg, publicKey) {\n checkArrayTypes(signedMsg, publicKey);\n if (publicKey.length !== crypto_sign_PUBLICKEYBYTES)\n throw new Error('bad public key size');\n var tmp = new Uint8Array(signedMsg.length);\n var mlen = crypto_sign_open(tmp, signedMsg, signedMsg.length, publicKey);\n if (mlen < 0) return null;\n var m = new Uint8Array(mlen);\n for (var i = 0; i < m.length; i++) m[i] = tmp[i];\n return m;\n};\n\nnacl.sign.detached = function(msg, secretKey) {\n var signedMsg = nacl.sign(msg, secretKey);\n var sig = new Uint8Array(crypto_sign_BYTES);\n for (var i = 0; i < sig.length; i++) sig[i] = signedMsg[i];\n return sig;\n};\n\nnacl.sign.detached.verify = function(msg, sig, publicKey) {\n checkArrayTypes(msg, sig, publicKey);\n if (sig.length !== crypto_sign_BYTES)\n throw new Error('bad signature size');\n if (publicKey.length !== crypto_sign_PUBLICKEYBYTES)\n throw new Error('bad public key size');\n var sm = new Uint8Array(crypto_sign_BYTES + msg.length);\n var m = new Uint8Array(crypto_sign_BYTES + msg.length);\n var i;\n for (i = 0; i < crypto_sign_BYTES; i++) sm[i] = sig[i];\n for (i = 0; i < msg.length; i++) sm[i+crypto_sign_BYTES] = msg[i];\n return (crypto_sign_open(m, sm, sm.length, publicKey) >= 0);\n};\n\nnacl.sign.keyPair = function() {\n var pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);\n var sk = new Uint8Array(crypto_sign_SECRETKEYBYTES);\n crypto_sign_keypair(pk, sk);\n return {publicKey: pk, secretKey: sk};\n};\n\nnacl.sign.keyPair.fromSecretKey = function(secretKey) {\n checkArrayTypes(secretKey);\n if (secretKey.length !== crypto_sign_SECRETKEYBYTES)\n throw new Error('bad secret key size');\n var pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);\n for (var i = 0; i < pk.length; i++) pk[i] = secretKey[32+i];\n return {publicKey: pk, secretKey: new Uint8Array(secretKey)};\n};\n\nnacl.sign.keyPair.fromSeed = function(seed) {\n checkArrayTypes(seed);\n if (seed.length !== crypto_sign_SEEDBYTES)\n throw new Error('bad seed size');\n var pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);\n var sk = new Uint8Array(crypto_sign_SECRETKEYBYTES);\n for (var i = 0; i < 32; i++) sk[i] = seed[i];\n crypto_sign_keypair(pk, sk, true);\n return {publicKey: pk, secretKey: sk};\n};\n\nnacl.sign.publicKeyLength = crypto_sign_PUBLICKEYBYTES;\nnacl.sign.secretKeyLength = crypto_sign_SECRETKEYBYTES;\nnacl.sign.seedLength = crypto_sign_SEEDBYTES;\nnacl.sign.signatureLength = crypto_sign_BYTES;\n\nnacl.hash = function(msg) {\n checkArrayTypes(msg);\n var h = new Uint8Array(crypto_hash_BYTES);\n crypto_hash(h, msg, msg.length);\n return h;\n};\n\nnacl.hash.hashLength = crypto_hash_BYTES;\n\nnacl.verify = function(x, y) {\n checkArrayTypes(x, y);\n // Zero length arguments are considered not equal.\n if (x.length === 0 || y.length === 0) return false;\n if (x.length !== y.length) return false;\n return (vn(x, 0, y, 0, x.length) === 0) ? true : false;\n};\n\nnacl.setPRNG = function(fn) {\n randombytes = fn;\n};\n\n(function() {\n // Initialize PRNG if environment provides CSPRNG.\n // If not, methods calling randombytes will throw.\n var crypto = typeof self !== 'undefined' ? (self.crypto || self.msCrypto) : null;\n if (crypto && crypto.getRandomValues) {\n // Browsers.\n var QUOTA = 65536;\n nacl.setPRNG(function(x, n) {\n var i, v = new Uint8Array(n);\n for (i = 0; i < n; i += QUOTA) {\n crypto.getRandomValues(v.subarray(i, i + Math.min(n - i, QUOTA)));\n }\n for (i = 0; i < n; i++) x[i] = v[i];\n cleanup(v);\n });\n } else if (typeof require !== 'undefined') {\n // Node.js.\n crypto = require('crypto');\n if (crypto && crypto.randomBytes) {\n nacl.setPRNG(function(x, n) {\n var i, v = crypto.randomBytes(n);\n for (i = 0; i < n; i++) x[i] = v[i];\n cleanup(v);\n });\n }\n }\n})();\n\n})(typeof module !== 'undefined' && module.exports ? module.exports : (self.nacl = self.nacl || {}));\n","module.exports = require('./pusher-with-encryption').default;\n","export default function encode(s: any): string {\n return btoa(utob(s));\n}\n\nvar fromCharCode = String.fromCharCode;\n\nvar b64chars =\n 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';\nvar b64tab = {};\n\nfor (var i = 0, l = b64chars.length; i < l; i++) {\n b64tab[b64chars.charAt(i)] = i;\n}\n\nvar cb_utob = function(c) {\n var cc = c.charCodeAt(0);\n return cc < 0x80\n ? c\n : cc < 0x800\n ? fromCharCode(0xc0 | (cc >>> 6)) + fromCharCode(0x80 | (cc & 0x3f))\n : fromCharCode(0xe0 | ((cc >>> 12) & 0x0f)) +\n fromCharCode(0x80 | ((cc >>> 6) & 0x3f)) +\n fromCharCode(0x80 | (cc & 0x3f));\n};\n\nvar utob = function(u) {\n return u.replace(/[^\\x00-\\x7F]/g, cb_utob);\n};\n\nvar cb_encode = function(ccc) {\n var padlen = [0, 2, 1][ccc.length % 3];\n var ord =\n (ccc.charCodeAt(0) << 16) |\n ((ccc.length > 1 ? ccc.charCodeAt(1) : 0) << 8) |\n (ccc.length > 2 ? ccc.charCodeAt(2) : 0);\n var chars = [\n b64chars.charAt(ord >>> 18),\n b64chars.charAt((ord >>> 12) & 63),\n padlen >= 2 ? '=' : b64chars.charAt((ord >>> 6) & 63),\n padlen >= 1 ? '=' : b64chars.charAt(ord & 63)\n ];\n return chars.join('');\n};\n\nvar btoa =\n global.btoa ||\n function(b) {\n return b.replace(/[\\s\\S]{1,3}/g, cb_encode);\n };\n","import TimedCallback from './timed_callback';\nimport { Delay, Scheduler, Canceller } from './scheduling';\n\nabstract class Timer {\n protected clear: Canceller;\n protected timer: number | void;\n\n constructor(\n set: Scheduler,\n clear: Canceller,\n delay: Delay,\n callback: TimedCallback\n ) {\n this.clear = clear;\n this.timer = set(() => {\n if (this.timer) {\n this.timer = callback(this.timer);\n }\n }, delay);\n }\n\n /** Returns whether the timer is still running.\n *\n * @return {Boolean}\n */\n isRunning(): boolean {\n return this.timer !== null;\n }\n\n /** Aborts a timer when it's running. */\n ensureAborted() {\n if (this.timer) {\n this.clear(this.timer);\n this.timer = null;\n }\n }\n}\n\nexport default Timer;\n","import Timer from './abstract_timer';\nimport TimedCallback from './timed_callback';\nimport { Delay } from './scheduling';\n\n// We need to bind clear functions this way to avoid exceptions on IE8\nfunction clearTimeout(timer) {\n global.clearTimeout(timer);\n}\nfunction clearInterval(timer) {\n global.clearInterval(timer);\n}\n\n/** Cross-browser compatible one-off timer abstraction.\n *\n * @param {Number} delay\n * @param {Function} callback\n */\nexport class OneOffTimer extends Timer {\n constructor(delay: Delay, callback: TimedCallback) {\n super(setTimeout, clearTimeout, delay, function(timer) {\n callback();\n return null;\n });\n }\n}\n\n/** Cross-browser compatible periodic timer abstraction.\n *\n * @param {Number} delay\n * @param {Function} callback\n */\nexport class PeriodicTimer extends Timer {\n constructor(delay: Delay, callback: TimedCallback) {\n super(setInterval, clearInterval, delay, function(timer) {\n callback();\n return timer;\n });\n }\n}\n","import * as Collections from './utils/collections';\nimport TimedCallback from './utils/timers/timed_callback';\nimport { OneOffTimer, PeriodicTimer } from './utils/timers';\n\nvar Util = {\n now(): number {\n if (Date.now) {\n return Date.now();\n } else {\n return new Date().valueOf();\n }\n },\n\n defer(callback: TimedCallback): OneOffTimer {\n return new OneOffTimer(0, callback);\n },\n\n /** Builds a function that will proxy a method call to its first argument.\n *\n * Allows partial application of arguments, so additional arguments are\n * prepended to the argument list.\n *\n * @param {String} name method name\n * @return {Function} proxy function\n */\n method(name: string, ...args: any[]): Function {\n var boundArguments = Array.prototype.slice.call(arguments, 1);\n return function(object) {\n return object[name].apply(object, boundArguments.concat(arguments));\n };\n }\n};\n\nexport default Util;\n","import base64encode from '../base64';\nimport Util from '../util';\n\n/** Merges multiple objects into the target argument.\n *\n * For properties that are plain Objects, performs a deep-merge. For the\n * rest it just copies the value of the property.\n *\n * To extend prototypes use it as following:\n * Pusher.Util.extend(Target.prototype, Base.prototype)\n *\n * You can also use it to merge objects without altering them:\n * Pusher.Util.extend({}, object1, object2)\n *\n * @param {Object} target\n * @return {Object} the target argument\n */\nexport function extend(target: any, ...sources: any[]): T {\n for (var i = 0; i < sources.length; i++) {\n var extensions = sources[i];\n for (var property in extensions) {\n if (\n extensions[property] &&\n extensions[property].constructor &&\n extensions[property].constructor === Object\n ) {\n target[property] = extend(target[property] || {}, extensions[property]);\n } else {\n target[property] = extensions[property];\n }\n }\n }\n return target;\n}\n\nexport function stringify(): string {\n var m = ['Pusher'];\n for (var i = 0; i < arguments.length; i++) {\n if (typeof arguments[i] === 'string') {\n m.push(arguments[i]);\n } else {\n m.push(safeJSONStringify(arguments[i]));\n }\n }\n return m.join(' : ');\n}\n\nexport function arrayIndexOf(array: any[], item: any): number {\n // MSIE doesn't have array.indexOf\n var nativeIndexOf = Array.prototype.indexOf;\n if (array === null) {\n return -1;\n }\n if (nativeIndexOf && array.indexOf === nativeIndexOf) {\n return array.indexOf(item);\n }\n for (var i = 0, l = array.length; i < l; i++) {\n if (array[i] === item) {\n return i;\n }\n }\n return -1;\n}\n\n/** Applies a function f to all properties of an object.\n *\n * Function f gets 3 arguments passed:\n * - element from the object\n * - key of the element\n * - reference to the object\n *\n * @param {Object} object\n * @param {Function} f\n */\nexport function objectApply(object: any, f: Function) {\n for (var key in object) {\n if (Object.prototype.hasOwnProperty.call(object, key)) {\n f(object[key], key, object);\n }\n }\n}\n\n/** Return a list of objects own proerty keys\n *\n * @param {Object} object\n * @returns {Array}\n */\nexport function keys(object: any): string[] {\n var keys = [];\n objectApply(object, function(_, key) {\n keys.push(key);\n });\n return keys;\n}\n\n/** Return a list of object's own property values\n *\n * @param {Object} object\n * @returns {Array}\n */\nexport function values(object: any): any[] {\n var values = [];\n objectApply(object, function(value) {\n values.push(value);\n });\n return values;\n}\n\n/** Applies a function f to all elements of an array.\n *\n * Function f gets 3 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function apply(array: any[], f: Function, context?: any) {\n for (var i = 0; i < array.length; i++) {\n f.call(context || global, array[i], i, array);\n }\n}\n\n/** Maps all elements of the array and returns the result.\n *\n * Function f gets 4 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n * - reference to the destination array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function map(array: any[], f: Function): any[] {\n var result = [];\n for (var i = 0; i < array.length; i++) {\n result.push(f(array[i], i, array, result));\n }\n return result;\n}\n\n/** Maps all elements of the object and returns the result.\n *\n * Function f gets 4 arguments passed:\n * - element from the object\n * - key of the element\n * - reference to the source object\n * - reference to the destination object\n *\n * @param {Object} object\n * @param {Function} f\n */\nexport function mapObject(object: any, f: Function): any {\n var result = {};\n objectApply(object, function(value, key) {\n result[key] = f(value);\n });\n return result;\n}\n\n/** Filters elements of the array using a test function.\n *\n * Function test gets 4 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n * - reference to the destination array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function filter(array: any[], test: Function): any[] {\n test =\n test ||\n function(value) {\n return !!value;\n };\n\n var result = [];\n for (var i = 0; i < array.length; i++) {\n if (test(array[i], i, array, result)) {\n result.push(array[i]);\n }\n }\n return result;\n}\n\n/** Filters properties of the object using a test function.\n *\n * Function test gets 4 arguments passed:\n * - element from the object\n * - key of the element\n * - reference to the source object\n * - reference to the destination object\n *\n * @param {Object} object\n * @param {Function} f\n */\nexport function filterObject(object: Object, test: Function) {\n var result = {};\n objectApply(object, function(value, key) {\n if ((test && test(value, key, object, result)) || Boolean(value)) {\n result[key] = value;\n }\n });\n return result;\n}\n\n/** Flattens an object into a two-dimensional array.\n *\n * @param {Object} object\n * @return {Array} resulting array of [key, value] pairs\n */\nexport function flatten(object: Object): any[] {\n var result = [];\n objectApply(object, function(value, key) {\n result.push([key, value]);\n });\n return result;\n}\n\n/** Checks whether any element of the array passes the test.\n *\n * Function test gets 3 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function any(array: any[], test: Function): boolean {\n for (var i = 0; i < array.length; i++) {\n if (test(array[i], i, array)) {\n return true;\n }\n }\n return false;\n}\n\n/** Checks whether all elements of the array pass the test.\n *\n * Function test gets 3 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function all(array: any[], test: Function): boolean {\n for (var i = 0; i < array.length; i++) {\n if (!test(array[i], i, array)) {\n return false;\n }\n }\n return true;\n}\n\nexport function encodeParamsObject(data): string {\n return mapObject(data, function(value) {\n if (typeof value === 'object') {\n value = safeJSONStringify(value);\n }\n return encodeURIComponent(base64encode(value.toString()));\n });\n}\n\nexport function buildQueryString(data: any): string {\n var params = filterObject(data, function(value) {\n return value !== undefined;\n });\n\n var query = map(\n flatten(encodeParamsObject(params)),\n Util.method('join', '=')\n ).join('&');\n\n return query;\n}\n\n/**\n * See https://github.com/douglascrockford/JSON-js/blob/master/cycle.js\n *\n * Remove circular references from an object. Required for JSON.stringify in\n * React Native, which tends to blow up a lot.\n *\n * @param {any} object\n * @return {any} Decycled object\n */\nexport function decycleObject(object: any): any {\n var objects = [],\n paths = [];\n\n return (function derez(value, path) {\n var i, name, nu;\n\n switch (typeof value) {\n case 'object':\n if (!value) {\n return null;\n }\n for (i = 0; i < objects.length; i += 1) {\n if (objects[i] === value) {\n return { $ref: paths[i] };\n }\n }\n\n objects.push(value);\n paths.push(path);\n\n if (Object.prototype.toString.apply(value) === '[object Array]') {\n nu = [];\n for (i = 0; i < value.length; i += 1) {\n nu[i] = derez(value[i], path + '[' + i + ']');\n }\n } else {\n nu = {};\n for (name in value) {\n if (Object.prototype.hasOwnProperty.call(value, name)) {\n nu[name] = derez(\n value[name],\n path + '[' + JSON.stringify(name) + ']'\n );\n }\n }\n }\n return nu;\n case 'number':\n case 'string':\n case 'boolean':\n return value;\n }\n })(object, '$');\n}\n\n/**\n * Provides a cross-browser and cross-platform way to safely stringify objects\n * into JSON. This is particularly necessary for ReactNative, where circular JSON\n * structures throw an exception.\n *\n * @param {any} source The object to stringify\n * @return {string} The serialized output.\n */\nexport function safeJSONStringify(source: any): string {\n try {\n return JSON.stringify(source);\n } catch (e) {\n return JSON.stringify(decycleObject(source));\n }\n}\n","import {\n ChannelAuthorizationOptions,\n UserAuthenticationOptions\n} from './auth/options';\nimport { AuthTransport } from './config';\n\nexport interface DefaultConfig {\n VERSION: string;\n PROTOCOL: number;\n wsPort: number;\n wssPort: number;\n wsPath: string;\n httpHost: string;\n httpPort: number;\n httpsPort: number;\n httpPath: string;\n stats_host: string;\n authEndpoint: string;\n authTransport: AuthTransport;\n activityTimeout: number;\n pongTimeout: number;\n unavailableTimeout: number;\n userAuthentication: UserAuthenticationOptions;\n channelAuthorization: ChannelAuthorizationOptions;\n\n cdn_http?: string;\n cdn_https?: string;\n dependency_suffix?: string;\n}\n\nvar Defaults: DefaultConfig = {\n VERSION: VERSION,\n PROTOCOL: 7,\n\n wsPort: 80,\n wssPort: 443,\n wsPath: '',\n // DEPRECATED: SockJS fallback parameters\n httpHost: 'sockjs.pusher.com',\n httpPort: 80,\n httpsPort: 443,\n httpPath: '/pusher',\n // DEPRECATED: Stats\n stats_host: 'stats.pusher.com',\n // DEPRECATED: Other settings\n authEndpoint: '/pusher/auth',\n authTransport: 'ajax',\n activityTimeout: 120000,\n pongTimeout: 30000,\n unavailableTimeout: 10000,\n userAuthentication: {\n endpoint: '/pusher/user-auth',\n transport: 'ajax'\n },\n channelAuthorization: {\n endpoint: '/pusher/auth',\n transport: 'ajax'\n },\n\n // CDN configuration\n cdn_http: CDN_HTTP,\n cdn_https: CDN_HTTPS,\n dependency_suffix: DEPENDENCY_SUFFIX\n};\n\nexport default Defaults;\n","import Defaults from '../defaults';\nimport { default as URLScheme, URLSchemeParams } from './url_scheme';\n\nfunction getGenericURL(\n baseScheme: string,\n params: URLSchemeParams,\n path: string\n): string {\n var scheme = baseScheme + (params.useTLS ? 's' : '');\n var host = params.useTLS ? params.hostTLS : params.hostNonTLS;\n return scheme + '://' + host + path;\n}\n\nfunction getGenericPath(key: string, queryString?: string): string {\n var path = '/app/' + key;\n var query =\n '?protocol=' +\n Defaults.PROTOCOL +\n '&client=js' +\n '&version=' +\n Defaults.VERSION +\n (queryString ? '&' + queryString : '');\n return path + query;\n}\n\nexport var ws: URLScheme = {\n getInitial: function(key: string, params: URLSchemeParams): string {\n var path = (params.httpPath || '') + getGenericPath(key, 'flash=false');\n return getGenericURL('ws', params, path);\n }\n};\n\nexport var http: URLScheme = {\n getInitial: function(key: string, params: URLSchemeParams): string {\n var path = (params.httpPath || '/pusher') + getGenericPath(key);\n return getGenericURL('http', params, path);\n }\n};\n\nexport var sockjs: URLScheme = {\n getInitial: function(key: string, params: URLSchemeParams): string {\n return getGenericURL('http', params, params.httpPath || '/pusher');\n },\n getPath: function(key: string, params: URLSchemeParams): string {\n return getGenericPath(key);\n }\n};\n","import Callback from './callback';\nimport * as Collections from '../utils/collections';\nimport CallbackTable from './callback_table';\n\nexport default class CallbackRegistry {\n _callbacks: CallbackTable;\n\n constructor() {\n this._callbacks = {};\n }\n\n get(name: string): Callback[] {\n return this._callbacks[prefix(name)];\n }\n\n add(name: string, callback: Function, context: any) {\n var prefixedEventName = prefix(name);\n this._callbacks[prefixedEventName] =\n this._callbacks[prefixedEventName] || [];\n this._callbacks[prefixedEventName].push({\n fn: callback,\n context: context\n });\n }\n\n remove(name?: string, callback?: Function, context?: any) {\n if (!name && !callback && !context) {\n this._callbacks = {};\n return;\n }\n\n var names = name ? [prefix(name)] : Collections.keys(this._callbacks);\n\n if (callback || context) {\n this.removeCallback(names, callback, context);\n } else {\n this.removeAllCallbacks(names);\n }\n }\n\n private removeCallback(names: string[], callback: Function, context: any) {\n Collections.apply(\n names,\n function(name) {\n this._callbacks[name] = Collections.filter(\n this._callbacks[name] || [],\n function(binding) {\n return (\n (callback && callback !== binding.fn) ||\n (context && context !== binding.context)\n );\n }\n );\n if (this._callbacks[name].length === 0) {\n delete this._callbacks[name];\n }\n },\n this\n );\n }\n\n private removeAllCallbacks(names: string[]) {\n Collections.apply(\n names,\n function(name) {\n delete this._callbacks[name];\n },\n this\n );\n }\n}\n\nfunction prefix(name: string): string {\n return '_' + name;\n}\n","import * as Collections from '../utils/collections';\nimport Callback from './callback';\nimport Metadata from '../channels/metadata';\nimport CallbackRegistry from './callback_registry';\n\n/** Manages callback bindings and event emitting.\n *\n * @param Function failThrough called when no listeners are bound to an event\n */\nexport default class Dispatcher {\n callbacks: CallbackRegistry;\n global_callbacks: Function[];\n failThrough: Function;\n\n constructor(failThrough?: Function) {\n this.callbacks = new CallbackRegistry();\n this.global_callbacks = [];\n this.failThrough = failThrough;\n }\n\n bind(eventName: string, callback: Function, context?: any) {\n this.callbacks.add(eventName, callback, context);\n return this;\n }\n\n bind_global(callback: Function) {\n this.global_callbacks.push(callback);\n return this;\n }\n\n unbind(eventName?: string, callback?: Function, context?: any) {\n this.callbacks.remove(eventName, callback, context);\n return this;\n }\n\n unbind_global(callback?: Function) {\n if (!callback) {\n this.global_callbacks = [];\n return this;\n }\n\n this.global_callbacks = Collections.filter(\n this.global_callbacks || [],\n c => c !== callback\n );\n\n return this;\n }\n\n unbind_all() {\n this.unbind();\n this.unbind_global();\n return this;\n }\n\n emit(eventName: string, data?: any, metadata?: Metadata): Dispatcher {\n for (var i = 0; i < this.global_callbacks.length; i++) {\n this.global_callbacks[i](eventName, data);\n }\n\n var callbacks = this.callbacks.get(eventName);\n var args = [];\n\n if (metadata) {\n // if there's a metadata argument, we need to call the callback with both\n // data and metadata regardless of whether data is undefined\n args.push(data, metadata);\n } else if (data) {\n // metadata is undefined, so we only need to call the callback with data\n // if data exists\n args.push(data);\n }\n\n if (callbacks && callbacks.length > 0) {\n for (var i = 0; i < callbacks.length; i++) {\n callbacks[i].fn.apply(callbacks[i].context || global, args);\n }\n } else if (this.failThrough) {\n this.failThrough(eventName, data);\n }\n\n return this;\n }\n}\n","import { stringify } from './utils/collections';\nimport Pusher from './pusher';\n\nclass Logger {\n debug(...args: any[]) {\n this.log(this.globalLog, args);\n }\n\n warn(...args: any[]) {\n this.log(this.globalLogWarn, args);\n }\n\n error(...args: any[]) {\n this.log(this.globalLogError, args);\n }\n\n private globalLog = (message: string) => {\n if (global.console && global.console.log) {\n global.console.log(message);\n }\n };\n\n private globalLogWarn(message: string) {\n if (global.console && global.console.warn) {\n global.console.warn(message);\n } else {\n this.globalLog(message);\n }\n }\n\n private globalLogError(message: string) {\n if (global.console && global.console.error) {\n global.console.error(message);\n } else {\n this.globalLogWarn(message);\n }\n }\n\n private log(\n defaultLoggingFunction: (message: string) => void,\n ...args: any[]\n ) {\n var message = stringify.apply(this, arguments);\n if (Pusher.log) {\n Pusher.log(message);\n } else if (Pusher.logToConsole) {\n const log = defaultLoggingFunction.bind(this);\n log(message);\n }\n }\n}\n\nexport default new Logger();\n","import Util from '../util';\nimport * as Collections from '../utils/collections';\nimport { default as EventsDispatcher } from '../events/dispatcher';\nimport Logger from '../logger';\nimport TransportHooks from './transport_hooks';\nimport Socket from '../socket';\nimport Runtime from 'runtime';\nimport Timeline from '../timeline/timeline';\nimport TransportConnectionOptions from './transport_connection_options';\n\n/** Provides universal API for transport connections.\n *\n * Transport connection is a low-level object that wraps a connection method\n * and exposes a simple evented interface for the connection state and\n * messaging. It does not implement Pusher-specific WebSocket protocol.\n *\n * Additionally, it fetches resources needed for transport to work and exposes\n * an interface for querying transport features.\n *\n * States:\n * - new - initial state after constructing the object\n * - initializing - during initialization phase, usually fetching resources\n * - intialized - ready to establish a connection\n * - connection - when connection is being established\n * - open - when connection ready to be used\n * - closed - after connection was closed be either side\n *\n * Emits:\n * - error - after the connection raised an error\n *\n * Options:\n * - useTLS - whether connection should be over TLS\n * - hostTLS - host to connect to when connection is over TLS\n * - hostNonTLS - host to connect to when connection is over TLS\n *\n * @param {String} key application key\n * @param {Object} options\n */\nexport default class TransportConnection extends EventsDispatcher {\n hooks: TransportHooks;\n name: string;\n priority: number;\n key: string;\n options: TransportConnectionOptions;\n state: string;\n timeline: Timeline;\n activityTimeout: number;\n id: number;\n socket: Socket;\n beforeOpen: Function;\n initialize: Function;\n\n constructor(\n hooks: TransportHooks,\n name: string,\n priority: number,\n key: string,\n options: TransportConnectionOptions\n ) {\n super();\n this.initialize = Runtime.transportConnectionInitializer;\n this.hooks = hooks;\n this.name = name;\n this.priority = priority;\n this.key = key;\n this.options = options;\n\n this.state = 'new';\n this.timeline = options.timeline;\n this.activityTimeout = options.activityTimeout;\n this.id = this.timeline.generateUniqueID();\n }\n\n /** Checks whether the transport handles activity checks by itself.\n *\n * @return {Boolean}\n */\n handlesActivityChecks(): boolean {\n return Boolean(this.hooks.handlesActivityChecks);\n }\n\n /** Checks whether the transport supports the ping/pong API.\n *\n * @return {Boolean}\n */\n supportsPing(): boolean {\n return Boolean(this.hooks.supportsPing);\n }\n\n /** Tries to establish a connection.\n *\n * @returns {Boolean} false if transport is in invalid state\n */\n connect(): boolean {\n if (this.socket || this.state !== 'initialized') {\n return false;\n }\n\n var url = this.hooks.urls.getInitial(this.key, this.options);\n try {\n this.socket = this.hooks.getSocket(url, this.options);\n } catch (e) {\n Util.defer(() => {\n this.onError(e);\n this.changeState('closed');\n });\n return false;\n }\n\n this.bindListeners();\n\n Logger.debug('Connecting', { transport: this.name, url });\n this.changeState('connecting');\n return true;\n }\n\n /** Closes the connection.\n *\n * @return {Boolean} true if there was a connection to close\n */\n close(): boolean {\n if (this.socket) {\n this.socket.close();\n return true;\n } else {\n return false;\n }\n }\n\n /** Sends data over the open connection.\n *\n * @param {String} data\n * @return {Boolean} true only when in the \"open\" state\n */\n send(data: any): boolean {\n if (this.state === 'open') {\n // Workaround for MobileSafari bug (see https://gist.github.com/2052006)\n Util.defer(() => {\n if (this.socket) {\n this.socket.send(data);\n }\n });\n return true;\n } else {\n return false;\n }\n }\n\n /** Sends a ping if the connection is open and transport supports it. */\n ping() {\n if (this.state === 'open' && this.supportsPing()) {\n this.socket.ping();\n }\n }\n\n private onOpen() {\n if (this.hooks.beforeOpen) {\n this.hooks.beforeOpen(\n this.socket,\n this.hooks.urls.getPath(this.key, this.options)\n );\n }\n this.changeState('open');\n this.socket.onopen = undefined;\n }\n\n private onError(error) {\n this.emit('error', { type: 'WebSocketError', error: error });\n this.timeline.error(this.buildTimelineMessage({ error: error.toString() }));\n }\n\n private onClose(closeEvent?: any) {\n if (closeEvent) {\n this.changeState('closed', {\n code: closeEvent.code,\n reason: closeEvent.reason,\n wasClean: closeEvent.wasClean\n });\n } else {\n this.changeState('closed');\n }\n this.unbindListeners();\n this.socket = undefined;\n }\n\n private onMessage(message) {\n this.emit('message', message);\n }\n\n private onActivity() {\n this.emit('activity');\n }\n\n private bindListeners() {\n this.socket.onopen = () => {\n this.onOpen();\n };\n this.socket.onerror = error => {\n this.onError(error);\n };\n this.socket.onclose = closeEvent => {\n this.onClose(closeEvent);\n };\n this.socket.onmessage = message => {\n this.onMessage(message);\n };\n\n if (this.supportsPing()) {\n this.socket.onactivity = () => {\n this.onActivity();\n };\n }\n }\n\n private unbindListeners() {\n if (this.socket) {\n this.socket.onopen = undefined;\n this.socket.onerror = undefined;\n this.socket.onclose = undefined;\n this.socket.onmessage = undefined;\n if (this.supportsPing()) {\n this.socket.onactivity = undefined;\n }\n }\n }\n\n private changeState(state: string, params?: any) {\n this.state = state;\n this.timeline.info(\n this.buildTimelineMessage({\n state: state,\n params: params\n })\n );\n this.emit(state, params);\n }\n\n buildTimelineMessage(message): any {\n return Collections.extend({ cid: this.id }, message);\n }\n}\n","import Factory from '../utils/factory';\nimport TransportHooks from './transport_hooks';\nimport TransportConnection from './transport_connection';\nimport TransportConnectionOptions from './transport_connection_options';\n\n/** Provides interface for transport connection instantiation.\n *\n * Takes transport-specific hooks as the only argument, which allow checking\n * for transport support and creating its connections.\n *\n * Supported hooks: * - file - the name of the file to be fetched during initialization\n * - urls - URL scheme to be used by transport\n * - handlesActivityCheck - true when the transport handles activity checks\n * - supportsPing - true when the transport has a ping/activity API\n * - isSupported - tells whether the transport is supported in the environment\n * - getSocket - creates a WebSocket-compatible transport socket\n *\n * See transports.js for specific implementations.\n *\n * @param {Object} hooks object containing all needed transport hooks\n */\nexport default class Transport {\n hooks: TransportHooks;\n\n constructor(hooks: TransportHooks) {\n this.hooks = hooks;\n }\n\n /** Returns whether the transport is supported in the environment.\n *\n * @param {Object} envronment te environment details (encryption, settings)\n * @returns {Boolean} true when the transport is supported\n */\n isSupported(environment: any): boolean {\n return this.hooks.isSupported(environment);\n }\n\n /** Creates a transport connection.\n *\n * @param {String} name\n * @param {Number} priority\n * @param {String} key the application key\n * @param {Object} options\n * @returns {TransportConnection}\n */\n createConnection(\n name: string,\n priority: number,\n key: string,\n options: any\n ): TransportConnection {\n return new TransportConnection(this.hooks, name, priority, key, options);\n }\n}\n","import * as URLSchemes from 'core/transports/url_schemes';\nimport URLScheme from 'core/transports/url_scheme';\nimport Transport from 'core/transports/transport';\nimport Util from 'core/util';\nimport * as Collections from 'core/utils/collections';\nimport TransportHooks from 'core/transports/transport_hooks';\nimport TransportsTable from 'core/transports/transports_table';\nimport Runtime from 'runtime';\n\n/** WebSocket transport.\n *\n * Uses native WebSocket implementation, including MozWebSocket supported by\n * earlier Firefox versions.\n */\nvar WSTransport = new Transport({\n urls: URLSchemes.ws,\n handlesActivityChecks: false,\n supportsPing: false,\n\n isInitialized: function() {\n return Boolean(Runtime.getWebSocketAPI());\n },\n isSupported: function(): boolean {\n return Boolean(Runtime.getWebSocketAPI());\n },\n getSocket: function(url) {\n return Runtime.createWebSocket(url);\n }\n});\n\nvar httpConfiguration = {\n urls: URLSchemes.http,\n handlesActivityChecks: false,\n supportsPing: true,\n isInitialized: function() {\n return true;\n }\n};\n\nexport var streamingConfiguration = Collections.extend(\n {\n getSocket: function(url) {\n return Runtime.HTTPFactory.createStreamingSocket(url);\n }\n },\n httpConfiguration\n);\nexport var pollingConfiguration = Collections.extend(\n {\n getSocket: function(url) {\n return Runtime.HTTPFactory.createPollingSocket(url);\n }\n },\n httpConfiguration\n);\n\nvar xhrConfiguration = {\n isSupported: function(): boolean {\n return Runtime.isXHRSupported();\n }\n};\n\n/** HTTP streaming transport using CORS-enabled XMLHttpRequest. */\nvar XHRStreamingTransport = new Transport(\n (\n Collections.extend({}, streamingConfiguration, xhrConfiguration)\n )\n);\n\n/** HTTP long-polling transport using CORS-enabled XMLHttpRequest. */\nvar XHRPollingTransport = new Transport(\n Collections.extend({}, pollingConfiguration, xhrConfiguration)\n);\n\nvar Transports: TransportsTable = {\n ws: WSTransport,\n xhr_streaming: XHRStreamingTransport,\n xhr_polling: XHRPollingTransport\n};\n\nexport default Transports;\n","import Util from '../util';\nimport * as Collections from '../utils/collections';\nimport TransportManager from './transport_manager';\nimport TransportConnection from './transport_connection';\nimport Transport from './transport';\nimport PingDelayOptions from './ping_delay_options';\n\n/** Creates transport connections monitored by a transport manager.\n *\n * When a transport is closed, it might mean the environment does not support\n * it. It's possible that messages get stuck in an intermediate buffer or\n * proxies terminate inactive connections. To combat these problems,\n * assistants monitor the connection lifetime, report unclean exits and\n * adjust ping timeouts to keep the connection active. The decision to disable\n * a transport is the manager's responsibility.\n *\n * @param {TransportManager} manager\n * @param {TransportConnection} transport\n * @param {Object} options\n */\nexport default class AssistantToTheTransportManager {\n manager: TransportManager;\n transport: Transport;\n minPingDelay: number;\n maxPingDelay: number;\n pingDelay: number;\n\n constructor(\n manager: TransportManager,\n transport: Transport,\n options: PingDelayOptions\n ) {\n this.manager = manager;\n this.transport = transport;\n this.minPingDelay = options.minPingDelay;\n this.maxPingDelay = options.maxPingDelay;\n this.pingDelay = undefined;\n }\n\n /** Creates a transport connection.\n *\n * This function has the same API as Transport#createConnection.\n *\n * @param {String} name\n * @param {Number} priority\n * @param {String} key the application key\n * @param {Object} options\n * @returns {TransportConnection}\n */\n createConnection(\n name: string,\n priority: number,\n key: string,\n options: Object\n ): TransportConnection {\n options = Collections.extend({}, options, {\n activityTimeout: this.pingDelay\n });\n var connection = this.transport.createConnection(\n name,\n priority,\n key,\n options\n );\n\n var openTimestamp = null;\n\n var onOpen = function() {\n connection.unbind('open', onOpen);\n connection.bind('closed', onClosed);\n openTimestamp = Util.now();\n };\n var onClosed = closeEvent => {\n connection.unbind('closed', onClosed);\n\n if (closeEvent.code === 1002 || closeEvent.code === 1003) {\n // we don't want to use transports not obeying the protocol\n this.manager.reportDeath();\n } else if (!closeEvent.wasClean && openTimestamp) {\n // report deaths only for short-living transport\n var lifespan = Util.now() - openTimestamp;\n if (lifespan < 2 * this.maxPingDelay) {\n this.manager.reportDeath();\n this.pingDelay = Math.max(lifespan / 2, this.minPingDelay);\n }\n }\n };\n\n connection.bind('open', onOpen);\n return connection;\n }\n\n /** Returns whether the transport is supported in the environment.\n *\n * This function has the same API as Transport#isSupported. Might return false\n * when the manager decides to kill the transport.\n *\n * @param {Object} environment the environment details (encryption, settings)\n * @returns {Boolean} true when the transport is supported\n */\n isSupported(environment: string): boolean {\n return this.manager.isAlive() && this.transport.isSupported(environment);\n }\n}\n","import Action from './action';\nimport { PusherEvent } from './message-types';\n/**\n * Provides functions for handling Pusher protocol-specific messages.\n */\n\nconst Protocol = {\n /**\n * Decodes a message in a Pusher format.\n *\n * The MessageEvent we receive from the transport should contain a pusher event\n * (https://pusher.com/docs/pusher_protocol#events) serialized as JSON in the\n * data field\n *\n * The pusher event may contain a data field too, and it may also be\n * serialised as JSON\n *\n * Throws errors when messages are not parse'able.\n *\n * @param {MessageEvent} messageEvent\n * @return {PusherEvent}\n */\n decodeMessage: function(messageEvent: MessageEvent): PusherEvent {\n try {\n var messageData = JSON.parse(messageEvent.data);\n var pusherEventData = messageData.data;\n if (typeof pusherEventData === 'string') {\n try {\n pusherEventData = JSON.parse(messageData.data);\n } catch (e) {}\n }\n var pusherEvent: PusherEvent = {\n event: messageData.event,\n channel: messageData.channel,\n data: pusherEventData\n };\n if (messageData.user_id) {\n pusherEvent.user_id = messageData.user_id;\n }\n return pusherEvent;\n } catch (e) {\n throw { type: 'MessageParseError', error: e, data: messageEvent.data };\n }\n },\n\n /**\n * Encodes a message to be sent.\n *\n * @param {PusherEvent} event\n * @return {String}\n */\n encodeMessage: function(event: PusherEvent): string {\n return JSON.stringify(event);\n },\n\n /**\n * Processes a handshake message and returns appropriate actions.\n *\n * Returns an object with an 'action' and other action-specific properties.\n *\n * There are three outcomes when calling this function. First is a successful\n * connection attempt, when pusher:connection_established is received, which\n * results in a 'connected' action with an 'id' property. When passed a\n * pusher:error event, it returns a result with action appropriate to the\n * close code and an error. Otherwise, it raises an exception.\n *\n * @param {String} message\n * @result Object\n */\n processHandshake: function(messageEvent: MessageEvent): Action {\n var message = Protocol.decodeMessage(messageEvent);\n\n if (message.event === 'pusher:connection_established') {\n if (!message.data.activity_timeout) {\n throw 'No activity timeout specified in handshake';\n }\n return {\n action: 'connected',\n id: message.data.socket_id,\n activityTimeout: message.data.activity_timeout * 1000\n };\n } else if (message.event === 'pusher:error') {\n // From protocol 6 close codes are sent only once, so this only\n // happens when connection does not support close codes\n return {\n action: this.getCloseAction(message.data),\n error: this.getCloseError(message.data)\n };\n } else {\n throw 'Invalid handshake';\n }\n },\n\n /**\n * Dispatches the close event and returns an appropriate action name.\n *\n * See:\n * 1. https://developer.mozilla.org/en-US/docs/WebSockets/WebSockets_reference/CloseEvent\n * 2. http://pusher.com/docs/pusher_protocol\n *\n * @param {CloseEvent} closeEvent\n * @return {String} close action name\n */\n getCloseAction: function(closeEvent): string {\n if (closeEvent.code < 4000) {\n // ignore 1000 CLOSE_NORMAL, 1001 CLOSE_GOING_AWAY,\n // 1005 CLOSE_NO_STATUS, 1006 CLOSE_ABNORMAL\n // ignore 1007...3999\n // handle 1002 CLOSE_PROTOCOL_ERROR, 1003 CLOSE_UNSUPPORTED,\n // 1004 CLOSE_TOO_LARGE\n if (closeEvent.code >= 1002 && closeEvent.code <= 1004) {\n return 'backoff';\n } else {\n return null;\n }\n } else if (closeEvent.code === 4000) {\n return 'tls_only';\n } else if (closeEvent.code < 4100) {\n return 'refused';\n } else if (closeEvent.code < 4200) {\n return 'backoff';\n } else if (closeEvent.code < 4300) {\n return 'retry';\n } else {\n // unknown error\n return 'refused';\n }\n },\n\n /**\n * Returns an error or null basing on the close event.\n *\n * Null is returned when connection was closed cleanly. Otherwise, an object\n * with error details is returned.\n *\n * @param {CloseEvent} closeEvent\n * @return {Object} error object\n */\n getCloseError: function(closeEvent): any {\n if (closeEvent.code !== 1000 && closeEvent.code !== 1001) {\n return {\n type: 'PusherError',\n data: {\n code: closeEvent.code,\n message: closeEvent.reason || closeEvent.message\n }\n };\n } else {\n return null;\n }\n }\n};\n\nexport default Protocol;\n","import * as Collections from '../utils/collections';\nimport { default as EventsDispatcher } from '../events/dispatcher';\nimport Protocol from './protocol/protocol';\nimport { PusherEvent } from './protocol/message-types';\nimport Logger from '../logger';\nimport TransportConnection from '../transports/transport_connection';\nimport Socket from '../socket';\n/**\n * Provides Pusher protocol interface for transports.\n *\n * Emits following events:\n * - message - on received messages\n * - ping - on ping requests\n * - pong - on pong responses\n * - error - when the transport emits an error\n * - closed - after closing the transport\n *\n * It also emits more events when connection closes with a code.\n * See Protocol.getCloseAction to get more details.\n *\n * @param {Number} id\n * @param {AbstractTransport} transport\n */\nexport default class Connection extends EventsDispatcher implements Socket {\n id: string;\n transport: TransportConnection;\n activityTimeout: number;\n\n constructor(id: string, transport: TransportConnection) {\n super();\n this.id = id;\n this.transport = transport;\n this.activityTimeout = transport.activityTimeout;\n this.bindListeners();\n }\n\n /** Returns whether used transport handles activity checks by itself\n *\n * @returns {Boolean} true if activity checks are handled by the transport\n */\n handlesActivityChecks() {\n return this.transport.handlesActivityChecks();\n }\n\n /** Sends raw data.\n *\n * @param {String} data\n */\n send(data: any): boolean {\n return this.transport.send(data);\n }\n\n /** Sends an event.\n *\n * @param {String} name\n * @param {String} data\n * @param {String} [channel]\n * @returns {Boolean} whether message was sent or not\n */\n send_event(name: string, data: any, channel?: string): boolean {\n var event: PusherEvent = { event: name, data: data };\n if (channel) {\n event.channel = channel;\n }\n Logger.debug('Event sent', event);\n return this.send(Protocol.encodeMessage(event));\n }\n\n /** Sends a ping message to the server.\n *\n * Basing on the underlying transport, it might send either transport's\n * protocol-specific ping or pusher:ping event.\n */\n ping() {\n if (this.transport.supportsPing()) {\n this.transport.ping();\n } else {\n this.send_event('pusher:ping', {});\n }\n }\n\n /** Closes the connection. */\n close() {\n this.transport.close();\n }\n\n private bindListeners() {\n var listeners = {\n message: (messageEvent: MessageEvent) => {\n var pusherEvent;\n try {\n pusherEvent = Protocol.decodeMessage(messageEvent);\n } catch (e) {\n this.emit('error', {\n type: 'MessageParseError',\n error: e,\n data: messageEvent.data\n });\n }\n\n if (pusherEvent !== undefined) {\n Logger.debug('Event recd', pusherEvent);\n\n switch (pusherEvent.event) {\n case 'pusher:error':\n this.emit('error', {\n type: 'PusherError',\n data: pusherEvent.data\n });\n break;\n case 'pusher:ping':\n this.emit('ping');\n break;\n case 'pusher:pong':\n this.emit('pong');\n break;\n }\n this.emit('message', pusherEvent);\n }\n },\n activity: () => {\n this.emit('activity');\n },\n error: error => {\n this.emit('error', error);\n },\n closed: closeEvent => {\n unbindListeners();\n\n if (closeEvent && closeEvent.code) {\n this.handleCloseEvent(closeEvent);\n }\n\n this.transport = null;\n this.emit('closed');\n }\n };\n\n var unbindListeners = () => {\n Collections.objectApply(listeners, (listener, event) => {\n this.transport.unbind(event, listener);\n });\n };\n\n Collections.objectApply(listeners, (listener, event) => {\n this.transport.bind(event, listener);\n });\n }\n\n private handleCloseEvent(closeEvent: any) {\n var action = Protocol.getCloseAction(closeEvent);\n var error = Protocol.getCloseError(closeEvent);\n if (error) {\n this.emit('error', error);\n }\n if (action) {\n this.emit(action, { action: action, error: error });\n }\n }\n}\n","import Util from '../../util';\nimport * as Collections from '../../utils/collections';\nimport Protocol from '../protocol/protocol';\nimport Connection from '../connection';\nimport TransportConnection from '../../transports/transport_connection';\nimport HandshakePayload from './handshake_payload';\n\n/**\n * Handles Pusher protocol handshakes for transports.\n *\n * Calls back with a result object after handshake is completed. Results\n * always have two fields:\n * - action - string describing action to be taken after the handshake\n * - transport - the transport object passed to the constructor\n *\n * Different actions can set different additional properties on the result.\n * In the case of 'connected' action, there will be a 'connection' property\n * containing a Connection object for the transport. Other actions should\n * carry an 'error' property.\n *\n * @param {AbstractTransport} transport\n * @param {Function} callback\n */\nexport default class Handshake {\n transport: TransportConnection;\n callback: (HandshakePayload) => void;\n onMessage: Function;\n onClosed: Function;\n\n constructor(\n transport: TransportConnection,\n callback: (HandshakePayload) => void\n ) {\n this.transport = transport;\n this.callback = callback;\n this.bindListeners();\n }\n\n close() {\n this.unbindListeners();\n this.transport.close();\n }\n\n private bindListeners() {\n this.onMessage = m => {\n this.unbindListeners();\n\n var result;\n try {\n result = Protocol.processHandshake(m);\n } catch (e) {\n this.finish('error', { error: e });\n this.transport.close();\n return;\n }\n\n if (result.action === 'connected') {\n this.finish('connected', {\n connection: new Connection(result.id, this.transport),\n activityTimeout: result.activityTimeout\n });\n } else {\n this.finish(result.action, { error: result.error });\n this.transport.close();\n }\n };\n\n this.onClosed = closeEvent => {\n this.unbindListeners();\n\n var action = Protocol.getCloseAction(closeEvent) || 'backoff';\n var error = Protocol.getCloseError(closeEvent);\n this.finish(action, { error: error });\n };\n\n this.transport.bind('message', this.onMessage);\n this.transport.bind('closed', this.onClosed);\n }\n\n private unbindListeners() {\n this.transport.unbind('message', this.onMessage);\n this.transport.unbind('closed', this.onClosed);\n }\n\n private finish(action: string, params: any) {\n this.callback(\n Collections.extend({ transport: this.transport, action: action }, params)\n );\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport base64encode from '../base64';\nimport Timeline from './timeline';\nimport Runtime from 'runtime';\n\nexport interface TimelineSenderOptions {\n host?: string;\n port?: number;\n path?: string;\n}\n\nexport default class TimelineSender {\n timeline: Timeline;\n options: TimelineSenderOptions;\n host: string;\n\n constructor(timeline: Timeline, options: TimelineSenderOptions) {\n this.timeline = timeline;\n this.options = options || {};\n }\n\n send(useTLS: boolean, callback?: Function) {\n if (this.timeline.isEmpty()) {\n return;\n }\n\n this.timeline.send(\n Runtime.TimelineTransport.getAgent(this, useTLS),\n callback\n );\n }\n}\n","/** Error classes used throughout the library. */\n// https://github.com/Microsoft/TypeScript-wiki/blob/master/Breaking-Changes.md#extending-built-ins-like-error-array-and-map-may-no-longer-work\nexport class BadEventName extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\nexport class BadChannelName extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\nexport class RequestTimedOut extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class TransportPriorityTooLow extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class TransportClosed extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class UnsupportedFeature extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class UnsupportedTransport extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class UnsupportedStrategy extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class HTTPAuthError extends Error {\n status: number;\n constructor(status: number, msg?: string) {\n super(msg);\n this.status = status;\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n","/**\n * A place to store help URLs for error messages etc\n */\n\nconst urlStore = {\n baseUrl: 'https://pusher.com',\n urls: {\n authenticationEndpoint: {\n path: '/docs/channels/server_api/authenticating_users'\n },\n authorizationEndpoint: {\n path: '/docs/channels/server_api/authorizing-users/'\n },\n javascriptQuickStart: {\n path: '/docs/javascript_quick_start'\n },\n triggeringClientEvents: {\n path: '/docs/client_api_guide/client_events#trigger-events'\n },\n encryptedChannelSupport: {\n fullUrl:\n 'https://github.com/pusher/pusher-js/tree/cc491015371a4bde5743d1c87a0fbac0feb53195#encrypted-channel-support'\n }\n }\n};\n\n/** Builds a consistent string with links to pusher documentation\n *\n * @param {string} key - relevant key in the url_store.urls object\n * @return {string} suffix string to append to log message\n */\nconst buildLogSuffix = function(key: string): string {\n const urlPrefix = 'See:';\n const urlObj = urlStore.urls[key];\n if (!urlObj) return '';\n\n let url;\n if (urlObj.fullUrl) {\n url = urlObj.fullUrl;\n } else if (urlObj.path) {\n url = urlStore.baseUrl + urlObj.path;\n }\n\n if (!url) return '';\n return `${urlPrefix} ${url}`;\n};\n\nexport default { buildLogSuffix };\n","import { default as EventsDispatcher } from '../events/dispatcher';\nimport * as Errors from '../errors';\nimport Logger from '../logger';\nimport Pusher from '../pusher';\nimport { PusherEvent } from '../connection/protocol/message-types';\nimport Metadata from './metadata';\nimport UrlStore from '../utils/url_store';\nimport {\n ChannelAuthorizationData,\n ChannelAuthorizationCallback\n} from '../auth/options';\nimport { HTTPAuthError } from '../errors';\n\n/** Provides base public channel interface with an event emitter.\n *\n * Emits:\n * - pusher:subscription_succeeded - after subscribing successfully\n * - other non-internal events\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\nexport default class Channel extends EventsDispatcher {\n name: string;\n pusher: Pusher;\n subscribed: boolean;\n subscriptionPending: boolean;\n subscriptionCancelled: boolean;\n subscriptionCount: null;\n\n constructor(name: string, pusher: Pusher) {\n super(function(event, data) {\n Logger.debug('No callbacks on ' + name + ' for ' + event);\n });\n\n this.name = name;\n this.pusher = pusher;\n this.subscribed = false;\n this.subscriptionPending = false;\n this.subscriptionCancelled = false;\n }\n\n /** Skips authorization, since public channels don't require it.\n *\n * @param {Function} callback\n */\n authorize(socketId: string, callback: ChannelAuthorizationCallback) {\n return callback(null, { auth: '' });\n }\n\n /** Triggers an event */\n trigger(event: string, data: any) {\n if (event.indexOf('client-') !== 0) {\n throw new Errors.BadEventName(\n \"Event '\" + event + \"' does not start with 'client-'\"\n );\n }\n if (!this.subscribed) {\n var suffix = UrlStore.buildLogSuffix('triggeringClientEvents');\n Logger.warn(\n `Client event triggered before channel 'subscription_succeeded' event . ${suffix}`\n );\n }\n return this.pusher.send_event(event, data, this.name);\n }\n\n /** Signals disconnection to the channel. For internal use only. */\n disconnect() {\n this.subscribed = false;\n this.subscriptionPending = false;\n }\n\n /** Handles a PusherEvent. For internal use only.\n *\n * @param {PusherEvent} event\n */\n handleEvent(event: PusherEvent) {\n var eventName = event.event;\n var data = event.data;\n if (eventName === 'pusher_internal:subscription_succeeded') {\n this.handleSubscriptionSucceededEvent(event);\n } else if (eventName === 'pusher_internal:subscription_count') {\n this.handleSubscriptionCountEvent(event);\n } else if (eventName.indexOf('pusher_internal:') !== 0) {\n var metadata: Metadata = {};\n this.emit(eventName, data, metadata);\n }\n }\n\n handleSubscriptionSucceededEvent(event: PusherEvent) {\n this.subscriptionPending = false;\n this.subscribed = true;\n if (this.subscriptionCancelled) {\n this.pusher.unsubscribe(this.name);\n } else {\n this.emit('pusher:subscription_succeeded', event.data);\n }\n }\n\n handleSubscriptionCountEvent(event: PusherEvent) {\n if (event.data.subscription_count) {\n this.subscriptionCount = event.data.subscription_count;\n }\n\n this.emit('pusher:subscription_count', event.data);\n }\n\n /** Sends a subscription request. For internal use only. */\n subscribe() {\n if (this.subscribed) {\n return;\n }\n this.subscriptionPending = true;\n this.subscriptionCancelled = false;\n this.authorize(\n this.pusher.connection.socket_id,\n (error: Error | null, data: ChannelAuthorizationData) => {\n if (error) {\n this.subscriptionPending = false;\n // Why not bind to 'pusher:subscription_error' a level up, and log there?\n // Binding to this event would cause the warning about no callbacks being\n // bound (see constructor) to be suppressed, that's not what we want.\n Logger.error(error.toString());\n this.emit(\n 'pusher:subscription_error',\n Object.assign(\n {},\n {\n type: 'AuthError',\n error: error.message\n },\n error instanceof HTTPAuthError ? { status: error.status } : {}\n )\n );\n } else {\n this.pusher.send_event('pusher:subscribe', {\n auth: data.auth,\n channel_data: data.channel_data,\n channel: this.name\n });\n }\n }\n );\n }\n\n /** Sends an unsubscription request. For internal use only. */\n unsubscribe() {\n this.subscribed = false;\n this.pusher.send_event('pusher:unsubscribe', {\n channel: this.name\n });\n }\n\n /** Cancels an in progress subscription. For internal use only. */\n cancelSubscription() {\n this.subscriptionCancelled = true;\n }\n\n /** Reinstates an in progress subscripiton. For internal use only. */\n reinstateSubscription() {\n this.subscriptionCancelled = false;\n }\n}\n","import Factory from '../utils/factory';\nimport Channel from './channel';\nimport { ChannelAuthorizationCallback } from '../auth/options';\n\n/** Extends public channels to provide private channel interface.\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\nexport default class PrivateChannel extends Channel {\n /** Authorizes the connection to use the channel.\n *\n * @param {String} socketId\n * @param {Function} callback\n */\n authorize(socketId: string, callback: ChannelAuthorizationCallback) {\n return this.pusher.config.channelAuthorizer(\n {\n channelName: this.name,\n socketId: socketId\n },\n callback\n );\n }\n}\n","import * as Collections from '../utils/collections';\n\n/** Represents a collection of members of a presence channel. */\nexport default class Members {\n members: any;\n count: number;\n myID: any;\n me: any;\n\n constructor() {\n this.reset();\n }\n\n /** Returns member's info for given id.\n *\n * Resulting object containts two fields - id and info.\n *\n * @param {Number} id\n * @return {Object} member's info or null\n */\n get(id: string): any {\n if (Object.prototype.hasOwnProperty.call(this.members, id)) {\n return {\n id: id,\n info: this.members[id]\n };\n } else {\n return null;\n }\n }\n\n /** Calls back for each member in unspecified order.\n *\n * @param {Function} callback\n */\n each(callback: Function) {\n Collections.objectApply(this.members, (member, id) => {\n callback(this.get(id));\n });\n }\n\n /** Updates the id for connected member. For internal use only. */\n setMyID(id: string) {\n this.myID = id;\n }\n\n /** Handles subscription data. For internal use only. */\n onSubscription(subscriptionData: any) {\n this.members = subscriptionData.presence.hash;\n this.count = subscriptionData.presence.count;\n this.me = this.get(this.myID);\n }\n\n /** Adds a new member to the collection. For internal use only. */\n addMember(memberData: any) {\n if (this.get(memberData.user_id) === null) {\n this.count++;\n }\n this.members[memberData.user_id] = memberData.user_info;\n return this.get(memberData.user_id);\n }\n\n /** Adds a member from the collection. For internal use only. */\n removeMember(memberData: any) {\n var member = this.get(memberData.user_id);\n if (member) {\n delete this.members[memberData.user_id];\n this.count--;\n }\n return member;\n }\n\n /** Resets the collection to the initial state. For internal use only. */\n reset() {\n this.members = {};\n this.count = 0;\n this.myID = null;\n this.me = null;\n }\n}\n","import PrivateChannel from './private_channel';\nimport Logger from '../logger';\nimport Members from './members';\nimport Pusher from '../pusher';\nimport UrlStore from 'core/utils/url_store';\nimport { PusherEvent } from '../connection/protocol/message-types';\nimport Metadata from './metadata';\nimport { ChannelAuthorizationData } from '../auth/options';\n\nexport default class PresenceChannel extends PrivateChannel {\n members: Members;\n\n /** Adds presence channel functionality to private channels.\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\n constructor(name: string, pusher: Pusher) {\n super(name, pusher);\n this.members = new Members();\n }\n\n /** Authorizes the connection as a member of the channel.\n *\n * @param {String} socketId\n * @param {Function} callback\n */\n authorize(socketId: string, callback: Function) {\n super.authorize(socketId, async (error, authData) => {\n if (!error) {\n authData = authData as ChannelAuthorizationData;\n if (authData.channel_data != null) {\n var channelData = JSON.parse(authData.channel_data);\n this.members.setMyID(channelData.user_id);\n } else {\n await this.pusher.user.signinDonePromise;\n if (this.pusher.user.user_data != null) {\n // If the user is signed in, get the id of the authenticated user\n // and allow the presence authorization to continue.\n this.members.setMyID(this.pusher.user.user_data.id);\n } else {\n let suffix = UrlStore.buildLogSuffix('authorizationEndpoint');\n Logger.error(\n `Invalid auth response for channel '${this.name}', ` +\n `expected 'channel_data' field. ${suffix}, ` +\n `or the user should be signed in.`\n );\n callback('Invalid auth response');\n return;\n }\n }\n }\n callback(error, authData);\n });\n }\n\n /** Handles presence and subscription events. For internal use only.\n *\n * @param {PusherEvent} event\n */\n handleEvent(event: PusherEvent) {\n var eventName = event.event;\n if (eventName.indexOf('pusher_internal:') === 0) {\n this.handleInternalEvent(event);\n } else {\n var data = event.data;\n var metadata: Metadata = {};\n if (event.user_id) {\n metadata.user_id = event.user_id;\n }\n this.emit(eventName, data, metadata);\n }\n }\n handleInternalEvent(event: PusherEvent) {\n var eventName = event.event;\n var data = event.data;\n switch (eventName) {\n case 'pusher_internal:subscription_succeeded':\n this.handleSubscriptionSucceededEvent(event);\n break;\n case 'pusher_internal:subscription_count':\n this.handleSubscriptionCountEvent(event);\n break;\n case 'pusher_internal:member_added':\n var addedMember = this.members.addMember(data);\n this.emit('pusher:member_added', addedMember);\n break;\n case 'pusher_internal:member_removed':\n var removedMember = this.members.removeMember(data);\n if (removedMember) {\n this.emit('pusher:member_removed', removedMember);\n }\n break;\n }\n }\n\n handleSubscriptionSucceededEvent(event: PusherEvent) {\n this.subscriptionPending = false;\n this.subscribed = true;\n if (this.subscriptionCancelled) {\n this.pusher.unsubscribe(this.name);\n } else {\n this.members.onSubscription(event.data);\n this.emit('pusher:subscription_succeeded', this.members);\n }\n }\n\n /** Resets the channel state, including members map. For internal use only. */\n disconnect() {\n this.members.reset();\n super.disconnect();\n }\n}\n","import PrivateChannel from './private_channel';\nimport * as Errors from '../errors';\nimport Logger from '../logger';\nimport Pusher from '../pusher';\nimport { decode as encodeUTF8 } from '@stablelib/utf8';\nimport { decode as decodeBase64 } from '@stablelib/base64';\nimport Dispatcher from '../events/dispatcher';\nimport { PusherEvent } from '../connection/protocol/message-types';\nimport {\n ChannelAuthorizationData,\n ChannelAuthorizationCallback\n} from '../auth/options';\nimport * as nacl from 'tweetnacl';\n\n/** Extends private channels to provide encrypted channel interface.\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\nexport default class EncryptedChannel extends PrivateChannel {\n key: Uint8Array = null;\n nacl: nacl;\n\n constructor(name: string, pusher: Pusher, nacl: nacl) {\n super(name, pusher);\n this.nacl = nacl;\n }\n\n /** Authorizes the connection to use the channel.\n *\n * @param {String} socketId\n * @param {Function} callback\n */\n authorize(socketId: string, callback: ChannelAuthorizationCallback) {\n super.authorize(\n socketId,\n (error: Error | null, authData: ChannelAuthorizationData) => {\n if (error) {\n callback(error, authData);\n return;\n }\n let sharedSecret = authData['shared_secret'];\n if (!sharedSecret) {\n callback(\n new Error(\n `No shared_secret key in auth payload for encrypted channel: ${this.name}`\n ),\n null\n );\n return;\n }\n this.key = decodeBase64(sharedSecret);\n delete authData['shared_secret'];\n callback(null, authData);\n }\n );\n }\n\n trigger(event: string, data: any): boolean {\n throw new Errors.UnsupportedFeature(\n 'Client events are not currently supported for encrypted channels'\n );\n }\n\n /** Handles an event. For internal use only.\n *\n * @param {PusherEvent} event\n */\n handleEvent(event: PusherEvent) {\n var eventName = event.event;\n var data = event.data;\n if (\n eventName.indexOf('pusher_internal:') === 0 ||\n eventName.indexOf('pusher:') === 0\n ) {\n super.handleEvent(event);\n return;\n }\n this.handleEncryptedEvent(eventName, data);\n }\n\n private handleEncryptedEvent(event: string, data: any): void {\n if (!this.key) {\n Logger.debug(\n 'Received encrypted event before key has been retrieved from the authEndpoint'\n );\n return;\n }\n if (!data.ciphertext || !data.nonce) {\n Logger.error(\n 'Unexpected format for encrypted event, expected object with `ciphertext` and `nonce` fields, got: ' +\n data\n );\n return;\n }\n let cipherText = decodeBase64(data.ciphertext);\n if (cipherText.length < this.nacl.secretbox.overheadLength) {\n Logger.error(\n `Expected encrypted event ciphertext length to be ${this.nacl.secretbox.overheadLength}, got: ${cipherText.length}`\n );\n return;\n }\n let nonce = decodeBase64(data.nonce);\n if (nonce.length < this.nacl.secretbox.nonceLength) {\n Logger.error(\n `Expected encrypted event nonce length to be ${this.nacl.secretbox.nonceLength}, got: ${nonce.length}`\n );\n return;\n }\n\n let bytes = this.nacl.secretbox.open(cipherText, nonce, this.key);\n if (bytes === null) {\n Logger.debug(\n 'Failed to decrypt an event, probably because it was encrypted with a different key. Fetching a new key from the authEndpoint...'\n );\n // Try a single time to retrieve a new auth key and decrypt the event with it\n // If this fails, a new key will be requested when a new message is received\n this.authorize(this.pusher.connection.socket_id, (error, authData) => {\n if (error) {\n Logger.error(\n `Failed to make a request to the authEndpoint: ${authData}. Unable to fetch new key, so dropping encrypted event`\n );\n return;\n }\n bytes = this.nacl.secretbox.open(cipherText, nonce, this.key);\n if (bytes === null) {\n Logger.error(\n `Failed to decrypt event with new key. Dropping encrypted event`\n );\n return;\n }\n this.emit(event, this.getDataToEmit(bytes));\n return;\n });\n return;\n }\n this.emit(event, this.getDataToEmit(bytes));\n }\n\n // Try and parse the decrypted bytes as JSON. If we can't parse it, just\n // return the utf-8 string\n getDataToEmit(bytes: Uint8Array): string {\n let raw = encodeUTF8(bytes);\n try {\n return JSON.parse(raw);\n } catch {\n return raw;\n }\n }\n}\n","import { default as EventsDispatcher } from '../events/dispatcher';\nimport { OneOffTimer as Timer } from '../utils/timers';\nimport { Config } from '../config';\nimport Logger from '../logger';\nimport HandshakePayload from './handshake/handshake_payload';\nimport Connection from './connection';\nimport Strategy from '../strategies/strategy';\nimport StrategyRunner from '../strategies/strategy_runner';\nimport * as Collections from '../utils/collections';\nimport Timeline from '../timeline/timeline';\nimport ConnectionManagerOptions from './connection_manager_options';\nimport Runtime from 'runtime';\n\nimport {\n ErrorCallbacks,\n HandshakeCallbacks,\n ConnectionCallbacks\n} from './callbacks';\nimport Action from './protocol/action';\n\n/** Manages connection to Pusher.\n *\n * Uses a strategy (currently only default), timers and network availability\n * info to establish a connection and export its state. In case of failures,\n * manages reconnection attempts.\n *\n * Exports state changes as following events:\n * - \"state_change\", { previous: p, current: state }\n * - state\n *\n * States:\n * - initialized - initial state, never transitioned to\n * - connecting - connection is being established\n * - connected - connection has been fully established\n * - disconnected - on requested disconnection\n * - unavailable - after connection timeout or when there's no network\n * - failed - when the connection strategy is not supported\n *\n * Options:\n * - unavailableTimeout - time to transition to unavailable state\n * - activityTimeout - time after which ping message should be sent\n * - pongTimeout - time for Pusher to respond with pong before reconnecting\n *\n * @param {String} key application key\n * @param {Object} options\n */\nexport default class ConnectionManager extends EventsDispatcher {\n key: string;\n options: ConnectionManagerOptions;\n state: string;\n connection: Connection;\n usingTLS: boolean;\n timeline: Timeline;\n socket_id: string;\n unavailableTimer: Timer;\n activityTimer: Timer;\n retryTimer: Timer;\n activityTimeout: number;\n strategy: Strategy;\n runner: StrategyRunner;\n errorCallbacks: ErrorCallbacks;\n handshakeCallbacks: HandshakeCallbacks;\n connectionCallbacks: ConnectionCallbacks;\n\n constructor(key: string, options: ConnectionManagerOptions) {\n super();\n this.state = 'initialized';\n this.connection = null;\n\n this.key = key;\n this.options = options;\n this.timeline = this.options.timeline;\n this.usingTLS = this.options.useTLS;\n\n this.errorCallbacks = this.buildErrorCallbacks();\n this.connectionCallbacks = this.buildConnectionCallbacks(\n this.errorCallbacks\n );\n this.handshakeCallbacks = this.buildHandshakeCallbacks(this.errorCallbacks);\n\n var Network = Runtime.getNetwork();\n\n Network.bind('online', () => {\n this.timeline.info({ netinfo: 'online' });\n if (this.state === 'connecting' || this.state === 'unavailable') {\n this.retryIn(0);\n }\n });\n Network.bind('offline', () => {\n this.timeline.info({ netinfo: 'offline' });\n if (this.connection) {\n this.sendActivityCheck();\n }\n });\n\n this.updateStrategy();\n }\n\n switchCluster(key: string) {\n this.key = key;\n // This ensures that the new config coming from\n // pusher instance are taken into account\n // such as appKey and cluster\n this.updateStrategy();\n this.retryIn(0);\n }\n\n /** Establishes a connection to Pusher.\n *\n * Does nothing when connection is already established. See top-level doc\n * to find events emitted on connection attempts.\n */\n connect() {\n if (this.connection || this.runner) {\n return;\n }\n if (!this.strategy.isSupported()) {\n this.updateState('failed');\n return;\n }\n this.updateState('connecting');\n this.startConnecting();\n this.setUnavailableTimer();\n }\n\n /** Sends raw data.\n *\n * @param {String} data\n */\n send(data) {\n if (this.connection) {\n return this.connection.send(data);\n } else {\n return false;\n }\n }\n\n /** Sends an event.\n *\n * @param {String} name\n * @param {String} data\n * @param {String} [channel]\n * @returns {Boolean} whether message was sent or not\n */\n send_event(name: string, data: any, channel?: string) {\n if (this.connection) {\n return this.connection.send_event(name, data, channel);\n } else {\n return false;\n }\n }\n\n /** Closes the connection. */\n disconnect() {\n this.disconnectInternally();\n this.updateState('disconnected');\n }\n\n isUsingTLS() {\n return this.usingTLS;\n }\n\n private startConnecting() {\n var callback = (error, handshake) => {\n if (error) {\n this.runner = this.strategy.connect(0, callback);\n } else {\n if (handshake.action === 'error') {\n this.emit('error', {\n type: 'HandshakeError',\n error: handshake.error\n });\n this.timeline.error({ handshakeError: handshake.error });\n } else {\n this.abortConnecting(); // we don't support switching connections yet\n this.handshakeCallbacks[handshake.action](handshake);\n }\n }\n };\n this.runner = this.strategy.connect(0, callback);\n }\n\n private abortConnecting() {\n if (this.runner) {\n this.runner.abort();\n this.runner = null;\n }\n }\n\n private disconnectInternally() {\n this.abortConnecting();\n this.clearRetryTimer();\n this.clearUnavailableTimer();\n if (this.connection) {\n var connection = this.abandonConnection();\n connection.close();\n }\n }\n\n private updateStrategy() {\n this.strategy = this.options.getStrategy({\n key: this.key,\n timeline: this.timeline,\n useTLS: this.usingTLS\n });\n }\n\n private retryIn(delay) {\n this.timeline.info({ action: 'retry', delay: delay });\n if (delay > 0) {\n this.emit('connecting_in', Math.round(delay / 1000));\n }\n this.retryTimer = new Timer(delay || 0, () => {\n this.disconnectInternally();\n this.connect();\n });\n }\n\n private clearRetryTimer() {\n if (this.retryTimer) {\n this.retryTimer.ensureAborted();\n this.retryTimer = null;\n }\n }\n\n private setUnavailableTimer() {\n this.unavailableTimer = new Timer(this.options.unavailableTimeout, () => {\n this.updateState('unavailable');\n });\n }\n\n private clearUnavailableTimer() {\n if (this.unavailableTimer) {\n this.unavailableTimer.ensureAborted();\n }\n }\n\n private sendActivityCheck() {\n this.stopActivityCheck();\n this.connection.ping();\n // wait for pong response\n this.activityTimer = new Timer(this.options.pongTimeout, () => {\n this.timeline.error({ pong_timed_out: this.options.pongTimeout });\n this.retryIn(0);\n });\n }\n\n private resetActivityCheck() {\n this.stopActivityCheck();\n // send ping after inactivity\n if (this.connection && !this.connection.handlesActivityChecks()) {\n this.activityTimer = new Timer(this.activityTimeout, () => {\n this.sendActivityCheck();\n });\n }\n }\n\n private stopActivityCheck() {\n if (this.activityTimer) {\n this.activityTimer.ensureAborted();\n }\n }\n\n private buildConnectionCallbacks(\n errorCallbacks: ErrorCallbacks\n ): ConnectionCallbacks {\n return Collections.extend({}, errorCallbacks, {\n message: message => {\n // includes pong messages from server\n this.resetActivityCheck();\n this.emit('message', message);\n },\n ping: () => {\n this.send_event('pusher:pong', {});\n },\n activity: () => {\n this.resetActivityCheck();\n },\n error: error => {\n // just emit error to user - socket will already be closed by browser\n this.emit('error', error);\n },\n closed: () => {\n this.abandonConnection();\n if (this.shouldRetry()) {\n this.retryIn(1000);\n }\n }\n });\n }\n\n private buildHandshakeCallbacks(\n errorCallbacks: ErrorCallbacks\n ): HandshakeCallbacks {\n return Collections.extend({}, errorCallbacks, {\n connected: (handshake: HandshakePayload) => {\n this.activityTimeout = Math.min(\n this.options.activityTimeout,\n handshake.activityTimeout,\n handshake.connection.activityTimeout || Infinity\n );\n this.clearUnavailableTimer();\n this.setConnection(handshake.connection);\n this.socket_id = this.connection.id;\n this.updateState('connected', { socket_id: this.socket_id });\n }\n });\n }\n\n private buildErrorCallbacks(): ErrorCallbacks {\n let withErrorEmitted = callback => {\n return (result: Action | HandshakePayload) => {\n if (result.error) {\n this.emit('error', { type: 'WebSocketError', error: result.error });\n }\n callback(result);\n };\n };\n\n return {\n tls_only: withErrorEmitted(() => {\n this.usingTLS = true;\n this.updateStrategy();\n this.retryIn(0);\n }),\n refused: withErrorEmitted(() => {\n this.disconnect();\n }),\n backoff: withErrorEmitted(() => {\n this.retryIn(1000);\n }),\n retry: withErrorEmitted(() => {\n this.retryIn(0);\n })\n };\n }\n\n private setConnection(connection) {\n this.connection = connection;\n for (var event in this.connectionCallbacks) {\n this.connection.bind(event, this.connectionCallbacks[event]);\n }\n this.resetActivityCheck();\n }\n\n private abandonConnection() {\n if (!this.connection) {\n return;\n }\n this.stopActivityCheck();\n for (var event in this.connectionCallbacks) {\n this.connection.unbind(event, this.connectionCallbacks[event]);\n }\n var connection = this.connection;\n this.connection = null;\n return connection;\n }\n\n private updateState(newState: string, data?: any) {\n var previousState = this.state;\n this.state = newState;\n if (previousState !== newState) {\n var newStateDescription = newState;\n if (newStateDescription === 'connected') {\n newStateDescription += ' with new socket ID ' + data.socket_id;\n }\n Logger.debug(\n 'State changed',\n previousState + ' -> ' + newStateDescription\n );\n this.timeline.info({ state: newState, params: data });\n this.emit('state_change', { previous: previousState, current: newState });\n this.emit(newState, data);\n }\n }\n\n private shouldRetry(): boolean {\n return this.state === 'connecting' || this.state === 'connected';\n }\n}\n","import Channel from './channel';\nimport * as Collections from '../utils/collections';\nimport ChannelTable from './channel_table';\nimport Factory from '../utils/factory';\nimport Pusher from '../pusher';\nimport Logger from '../logger';\nimport * as Errors from '../errors';\nimport urlStore from '../utils/url_store';\n\n/** Handles a channel map. */\nexport default class Channels {\n channels: ChannelTable;\n\n constructor() {\n this.channels = {};\n }\n\n /** Creates or retrieves an existing channel by its name.\n *\n * @param {String} name\n * @param {Pusher} pusher\n * @return {Channel}\n */\n add(name: string, pusher: Pusher) {\n if (!this.channels[name]) {\n this.channels[name] = createChannel(name, pusher);\n }\n return this.channels[name];\n }\n\n /** Returns a list of all channels\n *\n * @return {Array}\n */\n all(): Channel[] {\n return Collections.values(this.channels);\n }\n\n /** Finds a channel by its name.\n *\n * @param {String} name\n * @return {Channel} channel or null if it doesn't exist\n */\n find(name: string) {\n return this.channels[name];\n }\n\n /** Removes a channel from the map.\n *\n * @param {String} name\n */\n remove(name: string) {\n var channel = this.channels[name];\n delete this.channels[name];\n return channel;\n }\n\n /** Proxies disconnection signal to all channels. */\n disconnect() {\n Collections.objectApply(this.channels, function(channel) {\n channel.disconnect();\n });\n }\n}\n\nfunction createChannel(name: string, pusher: Pusher): Channel {\n if (name.indexOf('private-encrypted-') === 0) {\n if (pusher.config.nacl) {\n return Factory.createEncryptedChannel(name, pusher, pusher.config.nacl);\n }\n let errMsg =\n 'Tried to subscribe to a private-encrypted- channel but no nacl implementation available';\n let suffix = urlStore.buildLogSuffix('encryptedChannelSupport');\n throw new Errors.UnsupportedFeature(`${errMsg}. ${suffix}`);\n } else if (name.indexOf('private-') === 0) {\n return Factory.createPrivateChannel(name, pusher);\n } else if (name.indexOf('presence-') === 0) {\n return Factory.createPresenceChannel(name, pusher);\n } else if (name.indexOf('#') === 0) {\n throw new Errors.BadChannelName(\n 'Cannot create a channel with name \"' + name + '\".'\n );\n } else {\n return Factory.createChannel(name, pusher);\n }\n}\n","import AssistantToTheTransportManager from '../transports/assistant_to_the_transport_manager';\nimport PingDelayOptions from '../transports/ping_delay_options';\nimport Transport from '../transports/transport';\nimport TransportManager from '../transports/transport_manager';\nimport Handshake from '../connection/handshake';\nimport TransportConnection from '../transports/transport_connection';\nimport SocketHooks from '../http/socket_hooks';\nimport HTTPSocket from '../http/http_socket';\n\nimport Timeline from '../timeline/timeline';\nimport {\n default as TimelineSender,\n TimelineSenderOptions\n} from '../timeline/timeline_sender';\nimport PresenceChannel from '../channels/presence_channel';\nimport PrivateChannel from '../channels/private_channel';\nimport EncryptedChannel from '../channels/encrypted_channel';\nimport Channel from '../channels/channel';\nimport ConnectionManager from '../connection/connection_manager';\nimport ConnectionManagerOptions from '../connection/connection_manager_options';\nimport Ajax from '../http/ajax';\nimport Channels from '../channels/channels';\nimport Pusher from '../pusher';\nimport { Config } from '../config';\nimport * as nacl from 'tweetnacl';\n\nvar Factory = {\n createChannels(): Channels {\n return new Channels();\n },\n\n createConnectionManager(\n key: string,\n options: ConnectionManagerOptions\n ): ConnectionManager {\n return new ConnectionManager(key, options);\n },\n\n createChannel(name: string, pusher: Pusher): Channel {\n return new Channel(name, pusher);\n },\n\n createPrivateChannel(name: string, pusher: Pusher): PrivateChannel {\n return new PrivateChannel(name, pusher);\n },\n\n createPresenceChannel(name: string, pusher: Pusher): PresenceChannel {\n return new PresenceChannel(name, pusher);\n },\n\n createEncryptedChannel(\n name: string,\n pusher: Pusher,\n nacl: nacl\n ): EncryptedChannel {\n return new EncryptedChannel(name, pusher, nacl);\n },\n\n createTimelineSender(timeline: Timeline, options: TimelineSenderOptions) {\n return new TimelineSender(timeline, options);\n },\n\n createHandshake(\n transport: TransportConnection,\n callback: (HandshakePayload) => void\n ): Handshake {\n return new Handshake(transport, callback);\n },\n\n createAssistantToTheTransportManager(\n manager: TransportManager,\n transport: Transport,\n options: PingDelayOptions\n ): AssistantToTheTransportManager {\n return new AssistantToTheTransportManager(manager, transport, options);\n }\n};\n\nexport default Factory;\n","import AssistantToTheTransportManager from './assistant_to_the_transport_manager';\nimport Transport from './transport';\nimport PingDelayOptions from './ping_delay_options';\nimport Factory from '../utils/factory';\n\nexport interface TransportManagerOptions extends PingDelayOptions {\n lives?: number;\n}\n\n/** Keeps track of the number of lives left for a transport.\n *\n * In the beginning of a session, transports may be assigned a number of\n * lives. When an AssistantToTheTransportManager instance reports a transport\n * connection closed uncleanly, the transport loses a life. When the number\n * of lives drops to zero, the transport gets disabled by its manager.\n *\n * @param {Object} options\n */\nexport default class TransportManager {\n options: TransportManagerOptions;\n livesLeft: number;\n\n constructor(options: TransportManagerOptions) {\n this.options = options || {};\n this.livesLeft = this.options.lives || Infinity;\n }\n\n /** Creates a assistant for the transport.\n *\n * @param {Transport} transport\n * @returns {AssistantToTheTransportManager}\n */\n getAssistant(transport: Transport): AssistantToTheTransportManager {\n return Factory.createAssistantToTheTransportManager(this, transport, {\n minPingDelay: this.options.minPingDelay,\n maxPingDelay: this.options.maxPingDelay\n });\n }\n\n /** Returns whether the transport has any lives left.\n *\n * @returns {Boolean}\n */\n isAlive(): boolean {\n return this.livesLeft > 0;\n }\n\n /** Takes one life from the transport. */\n reportDeath() {\n this.livesLeft -= 1;\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport { OneOffTimer as Timer } from '../utils/timers';\nimport Strategy from './strategy';\nimport StrategyOptions from './strategy_options';\n\n/** Loops through strategies with optional timeouts.\n *\n * Options:\n * - loop - whether it should loop through the substrategy list\n * - timeout - initial timeout for a single substrategy\n * - timeoutLimit - maximum timeout\n *\n * @param {Strategy[]} strategies\n * @param {Object} options\n */\nexport default class SequentialStrategy implements Strategy {\n strategies: Strategy[];\n loop: boolean;\n failFast: boolean;\n timeout: number;\n timeoutLimit: number;\n\n constructor(strategies: Strategy[], options: StrategyOptions) {\n this.strategies = strategies;\n this.loop = Boolean(options.loop);\n this.failFast = Boolean(options.failFast);\n this.timeout = options.timeout;\n this.timeoutLimit = options.timeoutLimit;\n }\n\n isSupported(): boolean {\n return Collections.any(this.strategies, Util.method('isSupported'));\n }\n\n connect(minPriority: number, callback: Function) {\n var strategies = this.strategies;\n var current = 0;\n var timeout = this.timeout;\n var runner = null;\n\n var tryNextStrategy = (error, handshake) => {\n if (handshake) {\n callback(null, handshake);\n } else {\n current = current + 1;\n if (this.loop) {\n current = current % strategies.length;\n }\n\n if (current < strategies.length) {\n if (timeout) {\n timeout = timeout * 2;\n if (this.timeoutLimit) {\n timeout = Math.min(timeout, this.timeoutLimit);\n }\n }\n runner = this.tryStrategy(\n strategies[current],\n minPriority,\n { timeout, failFast: this.failFast },\n tryNextStrategy\n );\n } else {\n callback(true);\n }\n }\n };\n\n runner = this.tryStrategy(\n strategies[current],\n minPriority,\n { timeout: timeout, failFast: this.failFast },\n tryNextStrategy\n );\n\n return {\n abort: function() {\n runner.abort();\n },\n forceMinPriority: function(p) {\n minPriority = p;\n if (runner) {\n runner.forceMinPriority(p);\n }\n }\n };\n }\n\n private tryStrategy(\n strategy: Strategy,\n minPriority: number,\n options: StrategyOptions,\n callback: Function\n ) {\n var timer = null;\n var runner = null;\n\n if (options.timeout > 0) {\n timer = new Timer(options.timeout, function() {\n runner.abort();\n callback(true);\n });\n }\n\n runner = strategy.connect(minPriority, function(error, handshake) {\n if (error && timer && timer.isRunning() && !options.failFast) {\n // advance to the next strategy after the timeout\n return;\n }\n if (timer) {\n timer.ensureAborted();\n }\n callback(error, handshake);\n });\n\n return {\n abort: function() {\n if (timer) {\n timer.ensureAborted();\n }\n runner.abort();\n },\n forceMinPriority: function(p) {\n runner.forceMinPriority(p);\n }\n };\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport Strategy from './strategy';\n\n/** Launches all substrategies and emits prioritized connected transports.\n *\n * @param {Array} strategies\n */\nexport default class BestConnectedEverStrategy implements Strategy {\n strategies: Strategy[];\n\n constructor(strategies: Strategy[]) {\n this.strategies = strategies;\n }\n\n isSupported(): boolean {\n return Collections.any(this.strategies, Util.method('isSupported'));\n }\n\n connect(minPriority: number, callback: Function) {\n return connect(this.strategies, minPriority, function(i, runners) {\n return function(error, handshake) {\n runners[i].error = error;\n if (error) {\n if (allRunnersFailed(runners)) {\n callback(true);\n }\n return;\n }\n Collections.apply(runners, function(runner) {\n runner.forceMinPriority(handshake.transport.priority);\n });\n callback(null, handshake);\n };\n });\n }\n}\n\n/** Connects to all strategies in parallel.\n *\n * Callback builder should be a function that takes two arguments: index\n * and a list of runners. It should return another function that will be\n * passed to the substrategy with given index. Runners can be aborted using\n * abortRunner(s) functions from this class.\n *\n * @param {Array} strategies\n * @param {Function} callbackBuilder\n * @return {Object} strategy runner\n */\nfunction connect(\n strategies: Strategy[],\n minPriority: number,\n callbackBuilder: Function\n) {\n var runners = Collections.map(strategies, function(strategy, i, _, rs) {\n return strategy.connect(minPriority, callbackBuilder(i, rs));\n });\n return {\n abort: function() {\n Collections.apply(runners, abortRunner);\n },\n forceMinPriority: function(p) {\n Collections.apply(runners, function(runner) {\n runner.forceMinPriority(p);\n });\n }\n };\n}\n\nfunction allRunnersFailed(runners): boolean {\n return Collections.all(runners, function(runner) {\n return Boolean(runner.error);\n });\n}\n\nfunction abortRunner(runner) {\n if (!runner.error && !runner.aborted) {\n runner.abort();\n runner.aborted = true;\n }\n}\n","import Util from '../util';\nimport Runtime from 'runtime';\nimport Strategy from './strategy';\nimport SequentialStrategy from './sequential_strategy';\nimport StrategyOptions from './strategy_options';\nimport TransportStrategy from './transport_strategy';\nimport Timeline from '../timeline/timeline';\nimport * as Collections from '../utils/collections';\n\nexport interface TransportStrategyDictionary {\n [key: string]: TransportStrategy;\n}\n\n/** Caches the last successful transport and, after the first few attempts,\n * uses the cached transport for subsequent attempts.\n *\n * @param {Strategy} strategy\n * @param {Object} transports\n * @param {Object} options\n */\nexport default class WebSocketPrioritizedCachedStrategy implements Strategy {\n strategy: Strategy;\n transports: TransportStrategyDictionary;\n ttl: number;\n usingTLS: boolean;\n timeline: Timeline;\n\n constructor(\n strategy: Strategy,\n transports: TransportStrategyDictionary,\n options: StrategyOptions\n ) {\n this.strategy = strategy;\n this.transports = transports;\n this.ttl = options.ttl || 1800 * 1000;\n this.usingTLS = options.useTLS;\n this.timeline = options.timeline;\n }\n\n isSupported(): boolean {\n return this.strategy.isSupported();\n }\n\n connect(minPriority: number, callback: Function) {\n var usingTLS = this.usingTLS;\n var info = fetchTransportCache(usingTLS);\n var cacheSkipCount = info && info.cacheSkipCount ? info.cacheSkipCount : 0;\n\n var strategies = [this.strategy];\n if (info && info.timestamp + this.ttl >= Util.now()) {\n var transport = this.transports[info.transport];\n if (transport) {\n if (['ws', 'wss'].includes(info.transport) || cacheSkipCount > 3) {\n this.timeline.info({\n cached: true,\n transport: info.transport,\n latency: info.latency\n });\n strategies.push(\n new SequentialStrategy([transport], {\n timeout: info.latency * 2 + 1000,\n failFast: true\n })\n );\n } else {\n cacheSkipCount++;\n }\n }\n }\n\n var startTimestamp = Util.now();\n var runner = strategies\n .pop()\n .connect(minPriority, function cb(error, handshake) {\n if (error) {\n flushTransportCache(usingTLS);\n if (strategies.length > 0) {\n startTimestamp = Util.now();\n runner = strategies.pop().connect(minPriority, cb);\n } else {\n callback(error);\n }\n } else {\n storeTransportCache(\n usingTLS,\n handshake.transport.name,\n Util.now() - startTimestamp,\n cacheSkipCount\n );\n callback(null, handshake);\n }\n });\n\n return {\n abort: function() {\n runner.abort();\n },\n forceMinPriority: function(p) {\n minPriority = p;\n if (runner) {\n runner.forceMinPriority(p);\n }\n }\n };\n }\n}\n\nfunction getTransportCacheKey(usingTLS: boolean): string {\n return 'pusherTransport' + (usingTLS ? 'TLS' : 'NonTLS');\n}\n\nfunction fetchTransportCache(usingTLS: boolean): any {\n var storage = Runtime.getLocalStorage();\n if (storage) {\n try {\n var serializedCache = storage[getTransportCacheKey(usingTLS)];\n if (serializedCache) {\n return JSON.parse(serializedCache);\n }\n } catch (e) {\n flushTransportCache(usingTLS);\n }\n }\n return null;\n}\n\nfunction storeTransportCache(\n usingTLS: boolean,\n transport: TransportStrategy,\n latency: number,\n cacheSkipCount: number\n) {\n var storage = Runtime.getLocalStorage();\n if (storage) {\n try {\n storage[getTransportCacheKey(usingTLS)] = Collections.safeJSONStringify({\n timestamp: Util.now(),\n transport: transport,\n latency: latency,\n cacheSkipCount: cacheSkipCount\n });\n } catch (e) {\n // catch over quota exceptions raised by localStorage\n }\n }\n}\n\nfunction flushTransportCache(usingTLS: boolean) {\n var storage = Runtime.getLocalStorage();\n if (storage) {\n try {\n delete storage[getTransportCacheKey(usingTLS)];\n } catch (e) {\n // catch exceptions raised by localStorage\n }\n }\n}\n","import { OneOffTimer as Timer } from '../utils/timers';\nimport Strategy from './strategy';\nimport StrategyOptions from './strategy_options';\n\n/** Runs substrategy after specified delay.\n *\n * Options:\n * - delay - time in miliseconds to delay the substrategy attempt\n *\n * @param {Strategy} strategy\n * @param {Object} options\n */\nexport default class DelayedStrategy implements Strategy {\n strategy: Strategy;\n options: { delay: number };\n\n constructor(strategy: Strategy, { delay: number }) {\n this.strategy = strategy;\n this.options = { delay: number };\n }\n\n isSupported(): boolean {\n return this.strategy.isSupported();\n }\n\n connect(minPriority: number, callback: Function) {\n var strategy = this.strategy;\n var runner;\n var timer = new Timer(this.options.delay, function() {\n runner = strategy.connect(minPriority, callback);\n });\n\n return {\n abort: function() {\n timer.ensureAborted();\n if (runner) {\n runner.abort();\n }\n },\n forceMinPriority: function(p) {\n minPriority = p;\n if (runner) {\n runner.forceMinPriority(p);\n }\n }\n };\n }\n}\n","import Strategy from './strategy';\nimport StrategyRunner from './strategy_runner';\n\n/** Proxies method calls to one of substrategies basing on the test function.\n *\n * @param {Function} test\n * @param {Strategy} trueBranch strategy used when test returns true\n * @param {Strategy} falseBranch strategy used when test returns false\n */\nexport default class IfStrategy implements Strategy {\n test: () => boolean;\n trueBranch: Strategy;\n falseBranch: Strategy;\n\n constructor(\n test: () => boolean,\n trueBranch: Strategy,\n falseBranch: Strategy\n ) {\n this.test = test;\n this.trueBranch = trueBranch;\n this.falseBranch = falseBranch;\n }\n\n isSupported(): boolean {\n var branch = this.test() ? this.trueBranch : this.falseBranch;\n return branch.isSupported();\n }\n\n connect(minPriority: number, callback: Function): StrategyRunner {\n var branch = this.test() ? this.trueBranch : this.falseBranch;\n return branch.connect(minPriority, callback);\n }\n}\n","import Strategy from './strategy';\nimport StrategyRunner from './strategy_runner';\n\n/** Launches the substrategy and terminates on the first open connection.\n *\n * @param {Strategy} strategy\n */\nexport default class FirstConnectedStrategy implements Strategy {\n strategy: Strategy;\n\n constructor(strategy: Strategy) {\n this.strategy = strategy;\n }\n\n isSupported(): boolean {\n return this.strategy.isSupported();\n }\n\n connect(minPriority: number, callback: Function): StrategyRunner {\n var runner = this.strategy.connect(minPriority, function(error, handshake) {\n if (handshake) {\n runner.abort();\n }\n callback(error, handshake);\n });\n return runner;\n }\n}\n","import * as Collections from 'core/utils/collections';\nimport TransportManager from 'core/transports/transport_manager';\nimport Strategy from 'core/strategies/strategy';\nimport SequentialStrategy from 'core/strategies/sequential_strategy';\nimport BestConnectedEverStrategy from 'core/strategies/best_connected_ever_strategy';\nimport WebSocketPrioritizedCachedStrategy, {\n TransportStrategyDictionary\n} from 'core/strategies/websocket_prioritized_cached_strategy';\nimport DelayedStrategy from 'core/strategies/delayed_strategy';\nimport IfStrategy from 'core/strategies/if_strategy';\nimport FirstConnectedStrategy from 'core/strategies/first_connected_strategy';\nimport { Config } from 'core/config';\nimport StrategyOptions from 'core/strategies/strategy_options';\n\nfunction testSupportsStrategy(strategy: Strategy) {\n return function() {\n return strategy.isSupported();\n };\n}\n\nvar getDefaultStrategy = function(\n config: Config,\n baseOptions: StrategyOptions,\n defineTransport: Function\n): Strategy {\n var definedTransports = {};\n\n function defineTransportStrategy(\n name: string,\n type: string,\n priority: number,\n options: StrategyOptions,\n manager?: TransportManager\n ) {\n var transport = defineTransport(\n config,\n name,\n type,\n priority,\n options,\n manager\n );\n\n definedTransports[name] = transport;\n\n return transport;\n }\n\n var ws_options: StrategyOptions = Object.assign({}, baseOptions, {\n hostNonTLS: config.wsHost + ':' + config.wsPort,\n hostTLS: config.wsHost + ':' + config.wssPort,\n httpPath: config.wsPath\n });\n var wss_options: StrategyOptions = Collections.extend({}, ws_options, {\n useTLS: true\n });\n var http_options: StrategyOptions = Object.assign({}, baseOptions, {\n hostNonTLS: config.httpHost + ':' + config.httpPort,\n hostTLS: config.httpHost + ':' + config.httpsPort,\n httpPath: config.httpPath\n });\n var timeouts = {\n loop: true,\n timeout: 15000,\n timeoutLimit: 60000\n };\n\n var ws_manager = new TransportManager({\n minPingDelay: 10000,\n maxPingDelay: config.activityTimeout\n });\n var streaming_manager = new TransportManager({\n lives: 2,\n minPingDelay: 10000,\n maxPingDelay: config.activityTimeout\n });\n\n var ws_transport = defineTransportStrategy(\n 'ws',\n 'ws',\n 3,\n ws_options,\n ws_manager\n );\n var wss_transport = defineTransportStrategy(\n 'wss',\n 'ws',\n 3,\n wss_options,\n ws_manager\n );\n var xhr_streaming_transport = defineTransportStrategy(\n 'xhr_streaming',\n 'xhr_streaming',\n 1,\n http_options,\n streaming_manager\n );\n var xhr_polling_transport = defineTransportStrategy(\n 'xhr_polling',\n 'xhr_polling',\n 1,\n http_options\n );\n\n var ws_loop = new SequentialStrategy([ws_transport], timeouts);\n var wss_loop = new SequentialStrategy([wss_transport], timeouts);\n var streaming_loop = new SequentialStrategy(\n [xhr_streaming_transport],\n timeouts\n );\n var polling_loop = new SequentialStrategy([xhr_polling_transport], timeouts);\n\n var http_loop = new SequentialStrategy(\n [\n new IfStrategy(\n testSupportsStrategy(streaming_loop),\n new BestConnectedEverStrategy([\n streaming_loop,\n new DelayedStrategy(polling_loop, { delay: 4000 })\n ]),\n polling_loop\n )\n ],\n timeouts\n );\n\n var wsStrategy;\n if (baseOptions.useTLS) {\n wsStrategy = new BestConnectedEverStrategy([\n ws_loop,\n new DelayedStrategy(http_loop, { delay: 2000 })\n ]);\n } else {\n wsStrategy = new BestConnectedEverStrategy([\n ws_loop,\n new DelayedStrategy(wss_loop, { delay: 2000 }),\n new DelayedStrategy(http_loop, { delay: 5000 })\n ]);\n }\n\n return new WebSocketPrioritizedCachedStrategy(\n new FirstConnectedStrategy(\n new IfStrategy(testSupportsStrategy(ws_transport), wsStrategy, http_loop)\n ),\n definedTransports,\n {\n ttl: 1800000,\n timeline: baseOptions.timeline,\n useTLS: baseOptions.useTLS\n }\n );\n};\n\nexport default getDefaultStrategy;\n","import Runtime from 'runtime';\nimport RequestHooks from './request_hooks';\nimport Ajax from './ajax';\nimport { default as EventsDispatcher } from '../events/dispatcher';\n\nconst MAX_BUFFER_LENGTH = 256 * 1024;\n\nexport default class HTTPRequest extends EventsDispatcher {\n hooks: RequestHooks;\n method: string;\n url: string;\n position: number;\n xhr: Ajax;\n unloader: Function;\n\n constructor(hooks: RequestHooks, method: string, url: string) {\n super();\n this.hooks = hooks;\n this.method = method;\n this.url = url;\n }\n\n start(payload?: any) {\n this.position = 0;\n this.xhr = this.hooks.getRequest(this);\n\n this.unloader = () => {\n this.close();\n };\n Runtime.addUnloadListener(this.unloader);\n\n this.xhr.open(this.method, this.url, true);\n\n if (this.xhr.setRequestHeader) {\n this.xhr.setRequestHeader('Content-Type', 'application/json'); // ReactNative doesn't set this header by default.\n }\n this.xhr.send(payload);\n }\n\n close() {\n if (this.unloader) {\n Runtime.removeUnloadListener(this.unloader);\n this.unloader = null;\n }\n if (this.xhr) {\n this.hooks.abortRequest(this.xhr);\n this.xhr = null;\n }\n }\n\n onChunk(status: number, data: any) {\n while (true) {\n var chunk = this.advanceBuffer(data);\n if (chunk) {\n this.emit('chunk', { status: status, data: chunk });\n } else {\n break;\n }\n }\n if (this.isBufferTooLong(data)) {\n this.emit('buffer_too_long');\n }\n }\n\n private advanceBuffer(buffer: any[]): any {\n var unreadData = buffer.slice(this.position);\n var endOfLinePosition = unreadData.indexOf('\\n');\n\n if (endOfLinePosition !== -1) {\n this.position += endOfLinePosition + 1;\n return unreadData.slice(0, endOfLinePosition);\n } else {\n // chunk is not finished yet, don't move the buffer pointer\n return null;\n }\n }\n\n private isBufferTooLong(buffer: any): boolean {\n return this.position === buffer.length && buffer.length > MAX_BUFFER_LENGTH;\n }\n}\n","enum State {\n CONNECTING = 0,\n OPEN = 1,\n CLOSED = 3\n}\n\nexport default State;\n","import URLLocation from './url_location';\nimport State from './state';\nimport Socket from '../socket';\nimport SocketHooks from './socket_hooks';\nimport Util from '../util';\nimport Ajax from './ajax';\nimport HTTPRequest from './http_request';\nimport Runtime from 'runtime';\n\nvar autoIncrement = 1;\n\nclass HTTPSocket implements Socket {\n hooks: SocketHooks;\n session: string;\n location: URLLocation;\n readyState: State;\n stream: HTTPRequest;\n\n onopen: () => void;\n onerror: (error: any) => void;\n onclose: (closeEvent: any) => void;\n onmessage: (message: any) => void;\n onactivity: () => void;\n\n constructor(hooks: SocketHooks, url: string) {\n this.hooks = hooks;\n this.session = randomNumber(1000) + '/' + randomString(8);\n this.location = getLocation(url);\n this.readyState = State.CONNECTING;\n this.openStream();\n }\n\n send(payload: any) {\n return this.sendRaw(JSON.stringify([payload]));\n }\n\n ping() {\n this.hooks.sendHeartbeat(this);\n }\n\n close(code: any, reason: any) {\n this.onClose(code, reason, true);\n }\n\n /** For internal use only */\n sendRaw(payload: any): boolean {\n if (this.readyState === State.OPEN) {\n try {\n Runtime.createSocketRequest(\n 'POST',\n getUniqueURL(getSendURL(this.location, this.session))\n ).start(payload);\n return true;\n } catch (e) {\n return false;\n }\n } else {\n return false;\n }\n }\n\n /** For internal use only */\n reconnect() {\n this.closeStream();\n this.openStream();\n }\n\n /** For internal use only */\n onClose(code, reason, wasClean) {\n this.closeStream();\n this.readyState = State.CLOSED;\n if (this.onclose) {\n this.onclose({\n code: code,\n reason: reason,\n wasClean: wasClean\n });\n }\n }\n\n private onChunk(chunk) {\n if (chunk.status !== 200) {\n return;\n }\n if (this.readyState === State.OPEN) {\n this.onActivity();\n }\n\n var payload;\n var type = chunk.data.slice(0, 1);\n switch (type) {\n case 'o':\n payload = JSON.parse(chunk.data.slice(1) || '{}');\n this.onOpen(payload);\n break;\n case 'a':\n payload = JSON.parse(chunk.data.slice(1) || '[]');\n for (var i = 0; i < payload.length; i++) {\n this.onEvent(payload[i]);\n }\n break;\n case 'm':\n payload = JSON.parse(chunk.data.slice(1) || 'null');\n this.onEvent(payload);\n break;\n case 'h':\n this.hooks.onHeartbeat(this);\n break;\n case 'c':\n payload = JSON.parse(chunk.data.slice(1) || '[]');\n this.onClose(payload[0], payload[1], true);\n break;\n }\n }\n\n private onOpen(options) {\n if (this.readyState === State.CONNECTING) {\n if (options && options.hostname) {\n this.location.base = replaceHost(this.location.base, options.hostname);\n }\n this.readyState = State.OPEN;\n\n if (this.onopen) {\n this.onopen();\n }\n } else {\n this.onClose(1006, 'Server lost session', true);\n }\n }\n\n private onEvent(event) {\n if (this.readyState === State.OPEN && this.onmessage) {\n this.onmessage({ data: event });\n }\n }\n\n private onActivity() {\n if (this.onactivity) {\n this.onactivity();\n }\n }\n\n private onError(error) {\n if (this.onerror) {\n this.onerror(error);\n }\n }\n\n private openStream() {\n this.stream = Runtime.createSocketRequest(\n 'POST',\n getUniqueURL(this.hooks.getReceiveURL(this.location, this.session))\n );\n\n this.stream.bind('chunk', chunk => {\n this.onChunk(chunk);\n });\n this.stream.bind('finished', status => {\n this.hooks.onFinished(this, status);\n });\n this.stream.bind('buffer_too_long', () => {\n this.reconnect();\n });\n\n try {\n this.stream.start();\n } catch (error) {\n Util.defer(() => {\n this.onError(error);\n this.onClose(1006, 'Could not start streaming', false);\n });\n }\n }\n\n private closeStream() {\n if (this.stream) {\n this.stream.unbind_all();\n this.stream.close();\n this.stream = null;\n }\n }\n}\n\nfunction getLocation(url): URLLocation {\n var parts = /([^\\?]*)\\/*(\\??.*)/.exec(url);\n return {\n base: parts[1],\n queryString: parts[2]\n };\n}\n\nfunction getSendURL(url: URLLocation, session: string): string {\n return url.base + '/' + session + '/xhr_send';\n}\n\nfunction getUniqueURL(url: string): string {\n var separator = url.indexOf('?') === -1 ? '?' : '&';\n return url + separator + 't=' + +new Date() + '&n=' + autoIncrement++;\n}\n\nfunction replaceHost(url: string, hostname: string): string {\n var urlParts = /(https?:\\/\\/)([^\\/:]+)((\\/|:)?.*)/.exec(url);\n return urlParts[1] + hostname + urlParts[3];\n}\n\nfunction randomNumber(max: number): number {\n return Runtime.randomInt(max);\n}\n\nfunction randomString(length: number): string {\n var result = [];\n\n for (var i = 0; i < length; i++) {\n result.push(randomNumber(32).toString(32));\n }\n\n return result.join('');\n}\n\nexport default HTTPSocket;\n","import SocketHooks from './socket_hooks';\nimport HTTPSocket from './http_socket';\n\nvar hooks: SocketHooks = {\n getReceiveURL: function(url, session) {\n return url.base + '/' + session + '/xhr_streaming' + url.queryString;\n },\n onHeartbeat: function(socket) {\n socket.sendRaw('[]');\n },\n sendHeartbeat: function(socket) {\n socket.sendRaw('[]');\n },\n onFinished: function(socket, status) {\n socket.onClose(1006, 'Connection interrupted (' + status + ')', false);\n }\n};\n\nexport default hooks;\n","import SocketHooks from './socket_hooks';\nimport URLLocation from './url_location';\nimport HTTPSocket from './http_socket';\n\nvar hooks: SocketHooks = {\n getReceiveURL: function(url: URLLocation, session: string): string {\n return url.base + '/' + session + '/xhr' + url.queryString;\n },\n onHeartbeat: function() {\n // next HTTP request will reset server's activity timer\n },\n sendHeartbeat: function(socket) {\n socket.sendRaw('[]');\n },\n onFinished: function(socket, status) {\n if (status === 200) {\n socket.reconnect();\n } else {\n socket.onClose(1006, 'Connection interrupted (' + status + ')', false);\n }\n }\n};\n\nexport default hooks;\n","import HTTPRequest from 'core/http/http_request';\nimport RequestHooks from 'core/http/request_hooks';\nimport Ajax from 'core/http/ajax';\nimport Runtime from 'runtime';\n\nvar hooks: RequestHooks = {\n getRequest: function(socket: HTTPRequest): Ajax {\n var Constructor = Runtime.getXHRAPI();\n var xhr = new Constructor();\n xhr.onreadystatechange = xhr.onprogress = function() {\n switch (xhr.readyState) {\n case 3:\n if (xhr.responseText && xhr.responseText.length > 0) {\n socket.onChunk(xhr.status, xhr.responseText);\n }\n break;\n case 4:\n // this happens only on errors, never after calling close\n if (xhr.responseText && xhr.responseText.length > 0) {\n socket.onChunk(xhr.status, xhr.responseText);\n }\n socket.emit('finished', xhr.status);\n socket.close();\n break;\n }\n };\n return xhr;\n },\n abortRequest: function(xhr: Ajax) {\n xhr.onreadystatechange = null;\n xhr.abort();\n }\n};\n\nexport default hooks;\n","import * as Collections from 'core/utils/collections';\nimport Transports from 'isomorphic/transports/transports';\nimport TimelineSender from 'core/timeline/timeline_sender';\nimport Ajax from 'core/http/ajax';\nimport getDefaultStrategy from './default_strategy';\nimport TransportsTable from 'core/transports/transports_table';\nimport transportConnectionInitializer from './transports/transport_connection_initializer';\nimport HTTPFactory from './http/http';\n\nvar Isomorphic: any = {\n getDefaultStrategy,\n Transports: Transports,\n transportConnectionInitializer,\n HTTPFactory,\n\n setup(PusherClass): void {\n PusherClass.ready();\n },\n\n getLocalStorage(): any {\n return undefined;\n },\n\n getClientFeatures(): any[] {\n return Collections.keys(\n Collections.filterObject({ ws: Transports.ws }, function(t) {\n return t.isSupported({});\n })\n );\n },\n\n getProtocol(): string {\n return 'http:';\n },\n\n isXHRSupported(): boolean {\n return true;\n },\n\n createSocketRequest(method: string, url: string) {\n if (this.isXHRSupported()) {\n return this.HTTPFactory.createXHR(method, url);\n } else {\n throw 'Cross-origin HTTP requests are not supported';\n }\n },\n\n createXHR(): Ajax {\n var Constructor = this.getXHRAPI();\n return new Constructor();\n },\n\n createWebSocket(url: string): any {\n var Constructor = this.getWebSocketAPI();\n return new Constructor(url);\n },\n\n addUnloadListener(listener: any) {},\n removeUnloadListener(listener: any) {}\n};\n\nexport default Isomorphic;\n","/** Initializes the transport.\n *\n * Fetches resources if needed and then transitions to initialized.\n */\nexport default function() {\n var self = this;\n\n self.timeline.info(\n self.buildTimelineMessage({\n transport: self.name + (self.options.useTLS ? 's' : '')\n })\n );\n\n if (self.hooks.isInitialized()) {\n self.changeState('initialized');\n } else {\n self.onClose();\n }\n}\n","import HTTPRequest from 'core/http/http_request';\nimport HTTPSocket from 'core/http/http_socket';\nimport SocketHooks from 'core/http/socket_hooks';\nimport RequestHooks from 'core/http/request_hooks';\nimport streamingHooks from 'core/http/http_streaming_socket';\nimport pollingHooks from 'core/http/http_polling_socket';\nimport xhrHooks from './http_xhr_request';\nimport HTTPFactory from 'core/http/http_factory';\n\nvar HTTP: HTTPFactory = {\n createStreamingSocket(url: string): HTTPSocket {\n return this.createSocket(streamingHooks, url);\n },\n\n createPollingSocket(url: string): HTTPSocket {\n return this.createSocket(pollingHooks, url);\n },\n\n createSocket(hooks: SocketHooks, url: string): HTTPSocket {\n return new HTTPSocket(hooks, url);\n },\n\n createXHR(method: string, url: string): HTTPRequest {\n return this.createRequest(xhrHooks, method, url);\n },\n\n createRequest(hooks: RequestHooks, method: string, url: string): HTTPRequest {\n return new HTTPRequest(hooks, method, url);\n }\n};\n\nexport default HTTP;\n","import { default as EventsDispatcher } from 'core/events/dispatcher';\nimport Reachability from 'core/reachability';\n\nexport class NetInfo extends EventsDispatcher implements Reachability {\n isOnline(): boolean {\n return true;\n }\n}\n\nexport var Network = new NetInfo();\n","import AbstractRuntime from 'runtimes/interface';\nimport { AuthTransport } from 'core/auth/auth_transports';\nimport {\n AuthRequestType,\n AuthTransportCallback,\n InternalAuthOptions\n} from 'core/auth/options';\nimport { HTTPAuthError } from 'core/errors';\n\nvar fetchAuth: AuthTransport = function(\n context: AbstractRuntime,\n query: string,\n authOptions: InternalAuthOptions,\n authRequestType: AuthRequestType,\n callback: AuthTransportCallback\n) {\n var headers = new Headers();\n headers.set('Content-Type', 'application/x-www-form-urlencoded');\n\n for (var headerName in authOptions.headers) {\n headers.set(headerName, authOptions.headers[headerName]);\n }\n\n if (authOptions.headersProvider != null) {\n const dynamicHeaders = authOptions.headersProvider();\n for (var headerName in dynamicHeaders) {\n headers.set(headerName, dynamicHeaders[headerName]);\n }\n }\n\n var body = query;\n var request = new Request(authOptions.endpoint, {\n headers,\n body,\n credentials: 'same-origin',\n method: 'POST'\n });\n\n return fetch(request)\n .then(response => {\n let { status } = response;\n if (status === 200) {\n // manually parse the json so we can provide a more helpful error in\n // failure case\n return response.text();\n }\n throw new HTTPAuthError(\n status,\n `Could not get ${authRequestType.toString()} info from your auth endpoint, status: ${status}`\n );\n })\n .then(data => {\n let parsedData;\n try {\n parsedData = JSON.parse(data);\n } catch (e) {\n throw new HTTPAuthError(\n 200,\n `JSON returned from ${authRequestType.toString()} endpoint was invalid, yet status code was 200. Data was: ${data}`\n );\n }\n callback(null, parsedData);\n })\n .catch(err => {\n callback(err, null);\n });\n};\n\nexport default fetchAuth;\n","import Logger from 'core/logger';\nimport TimelineSender from 'core/timeline/timeline_sender';\nimport * as Collections from 'core/utils/collections';\nimport Util from 'core/util';\nimport Runtime from 'runtime';\nimport TimelineTransport from 'core/timeline/timeline_transport';\n\nvar getAgent = function(sender: TimelineSender, useTLS: boolean) {\n return function(data: any, callback: Function) {\n var scheme = 'http' + (useTLS ? 's' : '') + '://';\n var url =\n scheme + (sender.host || sender.options.host) + sender.options.path;\n var query = Collections.buildQueryString(data);\n url += '/' + 2 + '?' + query;\n\n fetch(url)\n .then(response => {\n if (response.status !== 200) {\n throw `received ${response.status} from stats.pusher.com`;\n }\n return response.json();\n })\n .then(({ host }) => {\n if (host) {\n sender.host = host;\n }\n })\n .catch(err => {\n Logger.debug('TimelineSender Error: ', err);\n });\n };\n};\n\nvar fetchTimeline = {\n name: 'xhr',\n getAgent\n};\n\nexport default fetchTimeline;\n","import Isomorphic from 'isomorphic/runtime';\nimport Runtime from '../interface';\nimport { Network } from './net_info';\nimport fetchAuth from './auth/fetch_auth';\nimport { AuthTransports } from 'core/auth/auth_transports';\nimport fetchTimeline from './timeline/fetch_timeline';\n\n// Very verbose but until unavoidable until\n// TypeScript 2.1, when spread attributes will be\n// supported\nconst {\n getDefaultStrategy,\n Transports,\n setup,\n getProtocol,\n isXHRSupported,\n getLocalStorage,\n createXHR,\n createWebSocket,\n addUnloadListener,\n removeUnloadListener,\n transportConnectionInitializer,\n createSocketRequest,\n HTTPFactory\n} = Isomorphic;\n\nconst Worker: Runtime = {\n getDefaultStrategy,\n Transports,\n setup,\n getProtocol,\n isXHRSupported,\n getLocalStorage,\n createXHR,\n createWebSocket,\n addUnloadListener,\n removeUnloadListener,\n transportConnectionInitializer,\n createSocketRequest,\n HTTPFactory,\n\n TimelineTransport: fetchTimeline,\n\n getAuthorizers(): AuthTransports {\n return { ajax: fetchAuth };\n },\n\n getWebSocketAPI() {\n return WebSocket;\n },\n\n getXHRAPI() {\n return XMLHttpRequest;\n },\n\n getNetwork() {\n return Network;\n },\n\n randomInt(max: number): number {\n /**\n * Return values in the range of [0, 1[\n */\n const random = function() {\n const crypto = globalThis.crypto || globalThis['msCrypto'];\n const random = crypto.getRandomValues(new Uint32Array(1))[0];\n\n return random / 2 ** 32;\n };\n\n return Math.floor(random() * max);\n }\n};\n\nexport default Worker;\n","enum TimelineLevel {\n ERROR = 3,\n INFO = 6,\n DEBUG = 7\n}\n\nexport default TimelineLevel;\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport { default as Level } from './level';\n\nexport interface TimelineOptions {\n level?: Level;\n limit?: number;\n version?: string;\n cluster?: string;\n features?: string[];\n params?: any;\n}\n\nexport default class Timeline {\n key: string;\n session: number;\n events: any[];\n options: TimelineOptions;\n sent: number;\n uniqueID: number;\n\n constructor(key: string, session: number, options: TimelineOptions) {\n this.key = key;\n this.session = session;\n this.events = [];\n this.options = options || {};\n this.sent = 0;\n this.uniqueID = 0;\n }\n\n log(level, event) {\n if (level <= this.options.level) {\n this.events.push(\n Collections.extend({}, event, { timestamp: Util.now() })\n );\n if (this.options.limit && this.events.length > this.options.limit) {\n this.events.shift();\n }\n }\n }\n\n error(event) {\n this.log(Level.ERROR, event);\n }\n\n info(event) {\n this.log(Level.INFO, event);\n }\n\n debug(event) {\n this.log(Level.DEBUG, event);\n }\n\n isEmpty() {\n return this.events.length === 0;\n }\n\n send(sendfn, callback) {\n var data = Collections.extend(\n {\n session: this.session,\n bundle: this.sent + 1,\n key: this.key,\n lib: 'js',\n version: this.options.version,\n cluster: this.options.cluster,\n features: this.options.features,\n timeline: this.events\n },\n this.options.params\n );\n\n this.events = [];\n sendfn(data, (error, result) => {\n if (!error) {\n this.sent++;\n }\n if (callback) {\n callback(error, result);\n }\n });\n\n return true;\n }\n\n generateUniqueID(): number {\n this.uniqueID++;\n return this.uniqueID;\n }\n}\n","import Factory from '../utils/factory';\nimport Util from '../util';\nimport * as Errors from '../errors';\nimport * as Collections from '../utils/collections';\nimport Strategy from './strategy';\nimport Transport from '../transports/transport';\nimport StrategyOptions from './strategy_options';\nimport Handshake from '../connection/handshake';\n\n/** Provides a strategy interface for transports.\n *\n * @param {String} name\n * @param {Number} priority\n * @param {Class} transport\n * @param {Object} options\n */\nexport default class TransportStrategy implements Strategy {\n name: string;\n priority: number;\n transport: Transport;\n options: StrategyOptions;\n\n constructor(\n name: string,\n priority: number,\n transport: Transport,\n options: StrategyOptions\n ) {\n this.name = name;\n this.priority = priority;\n this.transport = transport;\n this.options = options || {};\n }\n\n /** Returns whether the transport is supported in the browser.\n *\n * @returns {Boolean}\n */\n isSupported(): boolean {\n return this.transport.isSupported({\n useTLS: this.options.useTLS\n });\n }\n\n /** Launches a connection attempt and returns a strategy runner.\n *\n * @param {Function} callback\n * @return {Object} strategy runner\n */\n connect(minPriority: number, callback: Function) {\n if (!this.isSupported()) {\n return failAttempt(new Errors.UnsupportedStrategy(), callback);\n } else if (this.priority < minPriority) {\n return failAttempt(new Errors.TransportPriorityTooLow(), callback);\n }\n\n var connected = false;\n var transport = this.transport.createConnection(\n this.name,\n this.priority,\n this.options.key,\n this.options\n );\n var handshake = null;\n\n var onInitialized = function() {\n transport.unbind('initialized', onInitialized);\n transport.connect();\n };\n var onOpen = function() {\n handshake = Factory.createHandshake(transport, function(result) {\n connected = true;\n unbindListeners();\n callback(null, result);\n });\n };\n var onError = function(error) {\n unbindListeners();\n callback(error);\n };\n var onClosed = function() {\n unbindListeners();\n var serializedTransport;\n\n // The reason for this try/catch block is that on React Native\n // the WebSocket object is circular. Therefore transport.socket will\n // throw errors upon stringification. Collections.safeJSONStringify\n // discards circular references when serializing.\n serializedTransport = Collections.safeJSONStringify(transport);\n callback(new Errors.TransportClosed(serializedTransport));\n };\n\n var unbindListeners = function() {\n transport.unbind('initialized', onInitialized);\n transport.unbind('open', onOpen);\n transport.unbind('error', onError);\n transport.unbind('closed', onClosed);\n };\n\n transport.bind('initialized', onInitialized);\n transport.bind('open', onOpen);\n transport.bind('error', onError);\n transport.bind('closed', onClosed);\n\n // connect will be called automatically after initialization\n transport.initialize();\n\n return {\n abort: () => {\n if (connected) {\n return;\n }\n unbindListeners();\n if (handshake) {\n handshake.close();\n } else {\n transport.close();\n }\n },\n forceMinPriority: p => {\n if (connected) {\n return;\n }\n if (this.priority < p) {\n if (handshake) {\n handshake.close();\n } else {\n transport.close();\n }\n }\n }\n };\n }\n}\n\nfunction failAttempt(error: Error, callback: Function) {\n Util.defer(function() {\n callback(error);\n });\n return {\n abort: function() {},\n forceMinPriority: function() {}\n };\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport TransportManager from '../transports/transport_manager';\nimport * as Errors from '../errors';\nimport Strategy from './strategy';\nimport TransportStrategy from './transport_strategy';\nimport StrategyOptions from '../strategies/strategy_options';\nimport { Config } from '../config';\nimport Runtime from 'runtime';\n\nconst { Transports } = Runtime;\n\nexport var defineTransport = function(\n config: Config,\n name: string,\n type: string,\n priority: number,\n options: StrategyOptions,\n manager?: TransportManager\n): Strategy {\n var transportClass = Transports[type];\n if (!transportClass) {\n throw new Errors.UnsupportedTransport(type);\n }\n\n var enabled =\n (!config.enabledTransports ||\n Collections.arrayIndexOf(config.enabledTransports, name) !== -1) &&\n (!config.disabledTransports ||\n Collections.arrayIndexOf(config.disabledTransports, name) === -1);\n\n var transport;\n if (enabled) {\n options = Object.assign(\n { ignoreNullOrigin: config.ignoreNullOrigin },\n options\n );\n\n transport = new TransportStrategy(\n name,\n priority,\n manager ? manager.getAssistant(transportClass) : transportClass,\n options\n );\n } else {\n transport = UnsupportedStrategy;\n }\n\n return transport;\n};\n\nvar UnsupportedStrategy: Strategy = {\n isSupported: function() {\n return false;\n },\n connect: function(_, callback) {\n var deferred = Util.defer(function() {\n callback(new Errors.UnsupportedStrategy());\n });\n return {\n abort: function() {\n deferred.ensureAborted();\n },\n forceMinPriority: function() {}\n };\n }\n};\n","export enum AuthRequestType {\n UserAuthentication = 'user-authentication',\n ChannelAuthorization = 'channel-authorization'\n}\n\nexport interface ChannelAuthorizationData {\n auth: string;\n channel_data?: string;\n shared_secret?: string;\n}\n\nexport type ChannelAuthorizationCallback = (\n error: Error | null,\n authData: ChannelAuthorizationData | null\n) => void;\n\nexport interface ChannelAuthorizationRequestParams {\n socketId: string;\n channelName: string;\n}\n\nexport interface ChannelAuthorizationHandler {\n (\n params: ChannelAuthorizationRequestParams,\n callback: ChannelAuthorizationCallback\n ): void;\n}\n\nexport interface UserAuthenticationData {\n auth: string;\n user_data: string;\n}\n\nexport type UserAuthenticationCallback = (\n error: Error | null,\n authData: UserAuthenticationData | null\n) => void;\n\nexport interface UserAuthenticationRequestParams {\n socketId: string;\n}\n\nexport interface UserAuthenticationHandler {\n (\n params: UserAuthenticationRequestParams,\n callback: UserAuthenticationCallback\n ): void;\n}\n\nexport type AuthTransportCallback =\n | ChannelAuthorizationCallback\n | UserAuthenticationCallback;\n\nexport interface AuthOptionsT {\n transport: 'ajax' | 'jsonp';\n endpoint: string;\n params?: any;\n headers?: any;\n paramsProvider?: () => any;\n headersProvider?: () => any;\n customHandler?: AuthHandler;\n}\n\nexport declare type UserAuthenticationOptions = AuthOptionsT<\n UserAuthenticationHandler\n>;\nexport declare type ChannelAuthorizationOptions = AuthOptionsT<\n ChannelAuthorizationHandler\n>;\n\nexport interface InternalAuthOptions {\n transport: 'ajax' | 'jsonp';\n endpoint: string;\n params?: any;\n headers?: any;\n paramsProvider?: () => any;\n headersProvider?: () => any;\n}\n","import ConnectionManager from './connection/connection_manager';\nimport {\n ChannelAuthorizationOptions,\n UserAuthenticationOptions\n} from './auth/options';\nimport {\n ChannelAuthorizerGenerator,\n DeprecatedAuthOptions\n} from './auth/deprecated_channel_authorizer';\nimport { AuthTransport, Transport } from './config';\nimport * as nacl from 'tweetnacl';\nimport Logger from './logger';\n\nexport interface Options {\n activityTimeout?: number;\n\n auth?: DeprecatedAuthOptions; // DEPRECATED use channelAuthorization instead\n authEndpoint?: string; // DEPRECATED use channelAuthorization instead\n authTransport?: AuthTransport; // DEPRECATED use channelAuthorization instead\n authorizer?: ChannelAuthorizerGenerator; // DEPRECATED use channelAuthorization instead\n\n channelAuthorization?: ChannelAuthorizationOptions;\n userAuthentication?: UserAuthenticationOptions;\n\n cluster: string;\n enableStats?: boolean;\n disableStats?: boolean;\n disabledTransports?: Transport[];\n enabledTransports?: Transport[];\n forceTLS?: boolean;\n httpHost?: string;\n httpPath?: string;\n httpPort?: number;\n httpsPort?: number;\n ignoreNullOrigin?: boolean;\n nacl?: nacl;\n pongTimeout?: number;\n statsHost?: string;\n timelineParams?: any;\n unavailableTimeout?: number;\n wsHost?: string;\n wsPath?: string;\n wsPort?: number;\n wssPort?: number;\n}\n\nexport interface ClusterOptions {\n appKey: string;\n cluster: string;\n}\n\nexport function validateOptions(options) {\n if (options == null) {\n throw 'You must pass an options object';\n }\n if (options.cluster == null) {\n throw 'Options object must provide a cluster';\n }\n if ('disableStats' in options) {\n Logger.warn(\n 'The disableStats option is deprecated in favor of enableStats'\n );\n }\n}\n","import {\n UserAuthenticationCallback,\n InternalAuthOptions,\n UserAuthenticationHandler,\n UserAuthenticationRequestParams,\n AuthRequestType\n} from './options';\n\nimport Runtime from 'runtime';\n\nconst composeChannelQuery = (\n params: UserAuthenticationRequestParams,\n authOptions: InternalAuthOptions\n) => {\n var query = 'socket_id=' + encodeURIComponent(params.socketId);\n\n for (var key in authOptions.params) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(authOptions.params[key]);\n }\n\n if (authOptions.paramsProvider != null) {\n let dynamicParams = authOptions.paramsProvider();\n for (var key in dynamicParams) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(dynamicParams[key]);\n }\n }\n\n return query;\n};\n\nconst UserAuthenticator = (\n authOptions: InternalAuthOptions\n): UserAuthenticationHandler => {\n if (typeof Runtime.getAuthorizers()[authOptions.transport] === 'undefined') {\n throw `'${authOptions.transport}' is not a recognized auth transport`;\n }\n\n return (\n params: UserAuthenticationRequestParams,\n callback: UserAuthenticationCallback\n ) => {\n const query = composeChannelQuery(params, authOptions);\n\n Runtime.getAuthorizers()[authOptions.transport](\n Runtime,\n query,\n authOptions,\n AuthRequestType.UserAuthentication,\n callback\n );\n };\n};\n\nexport default UserAuthenticator;\n","import {\n AuthRequestType,\n InternalAuthOptions,\n ChannelAuthorizationHandler,\n ChannelAuthorizationRequestParams,\n ChannelAuthorizationCallback\n} from './options';\n\nimport Runtime from 'runtime';\n\nconst composeChannelQuery = (\n params: ChannelAuthorizationRequestParams,\n authOptions: InternalAuthOptions\n) => {\n var query = 'socket_id=' + encodeURIComponent(params.socketId);\n\n query += '&channel_name=' + encodeURIComponent(params.channelName);\n\n for (var key in authOptions.params) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(authOptions.params[key]);\n }\n\n if (authOptions.paramsProvider != null) {\n let dynamicParams = authOptions.paramsProvider();\n for (var key in dynamicParams) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(dynamicParams[key]);\n }\n }\n\n return query;\n};\n\nconst ChannelAuthorizer = (\n authOptions: InternalAuthOptions\n): ChannelAuthorizationHandler => {\n if (typeof Runtime.getAuthorizers()[authOptions.transport] === 'undefined') {\n throw `'${authOptions.transport}' is not a recognized auth transport`;\n }\n\n return (\n params: ChannelAuthorizationRequestParams,\n callback: ChannelAuthorizationCallback\n ) => {\n const query = composeChannelQuery(params, authOptions);\n\n Runtime.getAuthorizers()[authOptions.transport](\n Runtime,\n query,\n authOptions,\n AuthRequestType.ChannelAuthorization,\n callback\n );\n };\n};\n\nexport default ChannelAuthorizer;\n","import { Options } from './options';\nimport Defaults from './defaults';\nimport {\n ChannelAuthorizationHandler,\n UserAuthenticationHandler,\n ChannelAuthorizationOptions\n} from './auth/options';\nimport UserAuthenticator from './auth/user_authenticator';\nimport ChannelAuthorizer from './auth/channel_authorizer';\nimport { ChannelAuthorizerProxy } from './auth/deprecated_channel_authorizer';\nimport Runtime from 'runtime';\nimport * as nacl from 'tweetnacl';\n\nexport type AuthTransport = 'ajax' | 'jsonp';\nexport type Transport =\n | 'ws'\n | 'wss'\n | 'xhr_streaming'\n | 'xhr_polling'\n | 'sockjs';\n\nexport interface Config {\n // these are all 'required' config parameters, it's not necessary for the user\n // to set them, but they have configured defaults.\n activityTimeout: number;\n enableStats: boolean;\n httpHost: string;\n httpPath: string;\n httpPort: number;\n httpsPort: number;\n pongTimeout: number;\n statsHost: string;\n unavailableTimeout: number;\n useTLS: boolean;\n wsHost: string;\n wsPath: string;\n wsPort: number;\n wssPort: number;\n userAuthenticator: UserAuthenticationHandler;\n channelAuthorizer: ChannelAuthorizationHandler;\n\n // these are all optional parameters or overrrides. The customer can set these\n // but it's not strictly necessary\n forceTLS?: boolean;\n cluster?: string;\n disabledTransports?: Transport[];\n enabledTransports?: Transport[];\n ignoreNullOrigin?: boolean;\n nacl?: nacl;\n timelineParams?: any;\n}\n\n// getConfig mainly sets the defaults for the options that are not provided\nexport function getConfig(opts: Options, pusher): Config {\n let config: Config = {\n activityTimeout: opts.activityTimeout || Defaults.activityTimeout,\n cluster: opts.cluster,\n httpPath: opts.httpPath || Defaults.httpPath,\n httpPort: opts.httpPort || Defaults.httpPort,\n httpsPort: opts.httpsPort || Defaults.httpsPort,\n pongTimeout: opts.pongTimeout || Defaults.pongTimeout,\n statsHost: opts.statsHost || Defaults.stats_host,\n unavailableTimeout: opts.unavailableTimeout || Defaults.unavailableTimeout,\n wsPath: opts.wsPath || Defaults.wsPath,\n wsPort: opts.wsPort || Defaults.wsPort,\n wssPort: opts.wssPort || Defaults.wssPort,\n\n enableStats: getEnableStatsConfig(opts),\n httpHost: getHttpHost(opts),\n useTLS: shouldUseTLS(opts),\n wsHost: getWebsocketHost(opts),\n\n userAuthenticator: buildUserAuthenticator(opts),\n channelAuthorizer: buildChannelAuthorizer(opts, pusher)\n };\n\n if ('disabledTransports' in opts)\n config.disabledTransports = opts.disabledTransports;\n if ('enabledTransports' in opts)\n config.enabledTransports = opts.enabledTransports;\n if ('ignoreNullOrigin' in opts)\n config.ignoreNullOrigin = opts.ignoreNullOrigin;\n if ('timelineParams' in opts) config.timelineParams = opts.timelineParams;\n if ('nacl' in opts) {\n config.nacl = opts.nacl;\n }\n\n return config;\n}\n\nfunction getHttpHost(opts: Options): string {\n if (opts.httpHost) {\n return opts.httpHost;\n }\n if (opts.cluster) {\n return `sockjs-${opts.cluster}.pusher.com`;\n }\n return Defaults.httpHost;\n}\n\nfunction getWebsocketHost(opts: Options): string {\n if (opts.wsHost) {\n return opts.wsHost;\n }\n return getWebsocketHostFromCluster(opts.cluster);\n}\n\nfunction getWebsocketHostFromCluster(cluster: string): string {\n return `ws-${cluster}.pusher.com`;\n}\n\nfunction shouldUseTLS(opts: Options): boolean {\n if (Runtime.getProtocol() === 'https:') {\n return true;\n } else if (opts.forceTLS === false) {\n return false;\n }\n return true;\n}\n\n// if enableStats is set take the value\n// if disableStats is set take the inverse\n// otherwise default to false\nfunction getEnableStatsConfig(opts: Options): boolean {\n if ('enableStats' in opts) {\n return opts.enableStats;\n }\n if ('disableStats' in opts) {\n return !opts.disableStats;\n }\n return false;\n}\n\nfunction buildUserAuthenticator(opts: Options): UserAuthenticationHandler {\n const userAuthentication = {\n ...Defaults.userAuthentication,\n ...opts.userAuthentication\n };\n if (\n 'customHandler' in userAuthentication &&\n userAuthentication['customHandler'] != null\n ) {\n return userAuthentication['customHandler'];\n }\n\n return UserAuthenticator(userAuthentication);\n}\n\nfunction buildChannelAuth(opts: Options, pusher): ChannelAuthorizationOptions {\n let channelAuthorization: ChannelAuthorizationOptions;\n if ('channelAuthorization' in opts) {\n channelAuthorization = {\n ...Defaults.channelAuthorization,\n ...opts.channelAuthorization\n };\n } else {\n channelAuthorization = {\n transport: opts.authTransport || Defaults.authTransport,\n endpoint: opts.authEndpoint || Defaults.authEndpoint\n };\n if ('auth' in opts) {\n if ('params' in opts.auth) channelAuthorization.params = opts.auth.params;\n if ('headers' in opts.auth)\n channelAuthorization.headers = opts.auth.headers;\n }\n if ('authorizer' in opts)\n channelAuthorization.customHandler = ChannelAuthorizerProxy(\n pusher,\n channelAuthorization,\n opts.authorizer\n );\n }\n return channelAuthorization;\n}\n\nfunction buildChannelAuthorizer(\n opts: Options,\n pusher\n): ChannelAuthorizationHandler {\n const channelAuthorization = buildChannelAuth(opts, pusher);\n if (\n 'customHandler' in channelAuthorization &&\n channelAuthorization['customHandler'] != null\n ) {\n return channelAuthorization['customHandler'];\n }\n\n return ChannelAuthorizer(channelAuthorization);\n}\n","import Channel from '../channels/channel';\nimport {\n ChannelAuthorizationCallback,\n ChannelAuthorizationHandler,\n ChannelAuthorizationRequestParams,\n InternalAuthOptions\n} from './options';\n\nexport interface DeprecatedChannelAuthorizer {\n authorize(socketId: string, callback: ChannelAuthorizationCallback): void;\n}\n\nexport interface ChannelAuthorizerGenerator {\n (\n channel: Channel,\n options: DeprecatedAuthorizerOptions\n ): DeprecatedChannelAuthorizer;\n}\n\nexport interface DeprecatedAuthOptions {\n params?: any;\n headers?: any;\n}\n\nexport interface DeprecatedAuthorizerOptions {\n authTransport: 'ajax' | 'jsonp';\n authEndpoint: string;\n auth?: DeprecatedAuthOptions;\n}\n\nexport const ChannelAuthorizerProxy = (\n pusher,\n authOptions: InternalAuthOptions,\n channelAuthorizerGenerator: ChannelAuthorizerGenerator\n): ChannelAuthorizationHandler => {\n const deprecatedAuthorizerOptions: DeprecatedAuthorizerOptions = {\n authTransport: authOptions.transport,\n authEndpoint: authOptions.endpoint,\n auth: {\n params: authOptions.params,\n headers: authOptions.headers\n }\n };\n return (\n params: ChannelAuthorizationRequestParams,\n callback: ChannelAuthorizationCallback\n ) => {\n const channel = pusher.channel(params.channelName);\n // This line creates a new channel authorizer every time.\n // In the past, this was only done once per channel and reused.\n // We can do that again if we want to keep this behavior intact.\n const channelAuthorizer: DeprecatedChannelAuthorizer = channelAuthorizerGenerator(\n channel,\n deprecatedAuthorizerOptions\n );\n channelAuthorizer.authorize(params.socketId, callback);\n };\n};\n","import Logger from './logger';\nimport Pusher from './pusher';\nimport EventsDispatcher from './events/dispatcher';\n\nexport default class WatchlistFacade extends EventsDispatcher {\n private pusher: Pusher;\n\n public constructor(pusher: Pusher) {\n super(function(eventName, data) {\n Logger.debug(`No callbacks on watchlist events for ${eventName}`);\n });\n\n this.pusher = pusher;\n this.bindWatchlistInternalEvent();\n }\n\n handleEvent(pusherEvent) {\n pusherEvent.data.events.forEach(watchlistEvent => {\n this.emit(watchlistEvent.name, watchlistEvent);\n });\n }\n\n private bindWatchlistInternalEvent() {\n this.pusher.connection.bind('message', pusherEvent => {\n var eventName = pusherEvent.event;\n if (eventName === 'pusher_internal:watchlist_events') {\n this.handleEvent(pusherEvent);\n }\n });\n }\n}\n","function flatPromise() {\n let resolve, reject;\n const promise = new Promise((res, rej) => {\n resolve = res;\n reject = rej;\n });\n return { promise, resolve, reject };\n}\n\nexport default flatPromise;\n","import Pusher from './pusher';\nimport Logger from './logger';\nimport {\n UserAuthenticationData,\n UserAuthenticationCallback\n} from './auth/options';\nimport Channel from './channels/channel';\nimport WatchlistFacade from './watchlist';\nimport EventsDispatcher from './events/dispatcher';\nimport flatPromise from './utils/flat_promise';\n\nexport default class UserFacade extends EventsDispatcher {\n pusher: Pusher;\n signin_requested: boolean = false;\n user_data: any = null;\n serverToUserChannel: Channel = null;\n signinDonePromise: Promise = null;\n watchlist: WatchlistFacade;\n private _signinDoneResolve: Function = null;\n\n public constructor(pusher: Pusher) {\n super(function(eventName, data) {\n Logger.debug('No callbacks on user for ' + eventName);\n });\n this.pusher = pusher;\n this.pusher.connection.bind('state_change', ({ previous, current }) => {\n if (previous !== 'connected' && current === 'connected') {\n this._signin();\n }\n if (previous === 'connected' && current !== 'connected') {\n this._cleanup();\n this._newSigninPromiseIfNeeded();\n }\n });\n\n this.watchlist = new WatchlistFacade(pusher);\n\n this.pusher.connection.bind('message', event => {\n var eventName = event.event;\n if (eventName === 'pusher:signin_success') {\n this._onSigninSuccess(event.data);\n }\n if (\n this.serverToUserChannel &&\n this.serverToUserChannel.name === event.channel\n ) {\n this.serverToUserChannel.handleEvent(event);\n }\n });\n }\n\n public signin() {\n if (this.signin_requested) {\n return;\n }\n\n this.signin_requested = true;\n this._signin();\n }\n\n private _signin() {\n if (!this.signin_requested) {\n return;\n }\n\n this._newSigninPromiseIfNeeded();\n\n if (this.pusher.connection.state !== 'connected') {\n // Signin will be attempted when the connection is connected\n return;\n }\n\n this.pusher.config.userAuthenticator(\n {\n socketId: this.pusher.connection.socket_id\n },\n this._onAuthorize\n );\n }\n\n private _onAuthorize: UserAuthenticationCallback = (\n err,\n authData: UserAuthenticationData\n ) => {\n if (err) {\n Logger.warn(`Error during signin: ${err}`);\n this._cleanup();\n return;\n }\n\n this.pusher.send_event('pusher:signin', {\n auth: authData.auth,\n user_data: authData.user_data\n });\n\n // Later when we get pusher:singin_success event, the user will be marked as signed in\n };\n\n private _onSigninSuccess(data: any) {\n try {\n this.user_data = JSON.parse(data.user_data);\n } catch (e) {\n Logger.error(`Failed parsing user data after signin: ${data.user_data}`);\n this._cleanup();\n return;\n }\n\n if (typeof this.user_data.id !== 'string' || this.user_data.id === '') {\n Logger.error(\n `user_data doesn't contain an id. user_data: ${this.user_data}`\n );\n this._cleanup();\n return;\n }\n\n // Signin succeeded\n this._signinDoneResolve();\n this._subscribeChannels();\n }\n\n private _subscribeChannels() {\n const ensure_subscribed = channel => {\n if (channel.subscriptionPending && channel.subscriptionCancelled) {\n channel.reinstateSubscription();\n } else if (\n !channel.subscriptionPending &&\n this.pusher.connection.state === 'connected'\n ) {\n channel.subscribe();\n }\n };\n\n this.serverToUserChannel = new Channel(\n `#server-to-user-${this.user_data.id}`,\n this.pusher\n );\n this.serverToUserChannel.bind_global((eventName, data) => {\n if (\n eventName.indexOf('pusher_internal:') === 0 ||\n eventName.indexOf('pusher:') === 0\n ) {\n // ignore internal events\n return;\n }\n this.emit(eventName, data);\n });\n ensure_subscribed(this.serverToUserChannel);\n }\n\n private _cleanup() {\n this.user_data = null;\n if (this.serverToUserChannel) {\n this.serverToUserChannel.unbind_all();\n this.serverToUserChannel.disconnect();\n this.serverToUserChannel = null;\n }\n\n if (this.signin_requested) {\n // If signin is in progress and cleanup is called,\n // Mark the current signin process as done.\n this._signinDoneResolve();\n }\n }\n\n private _newSigninPromiseIfNeeded() {\n if (!this.signin_requested) {\n return;\n }\n\n // If there is a promise and it is not resolved, return without creating a new one.\n if (this.signinDonePromise && !(this.signinDonePromise as any).done) {\n return;\n }\n\n // This promise is never rejected.\n // It gets resolved when the signin process is done whether it failed or succeeded\n const { promise, resolve, reject: _ } = flatPromise();\n (promise as any).done = false;\n const setDone = () => {\n (promise as any).done = true;\n };\n promise.then(setDone).catch(setDone);\n this.signinDonePromise = promise;\n this._signinDoneResolve = resolve;\n }\n}\n","import AbstractRuntime from '../runtimes/interface';\nimport Runtime from 'runtime';\nimport * as Collections from './utils/collections';\nimport Channels from './channels/channels';\nimport Channel from './channels/channel';\nimport { default as EventsDispatcher } from './events/dispatcher';\nimport Timeline from './timeline/timeline';\nimport TimelineSender from './timeline/timeline_sender';\nimport TimelineLevel from './timeline/level';\nimport { defineTransport } from './strategies/strategy_builder';\nimport ConnectionManager from './connection/connection_manager';\nimport { PeriodicTimer } from './utils/timers';\nimport Defaults from './defaults';\nimport Logger from './logger';\nimport Factory from './utils/factory';\nimport { Options, ClusterOptions, validateOptions } from './options';\nimport { Config, getConfig } from './config';\nimport StrategyOptions from './strategies/strategy_options';\nimport UserFacade from './user';\n\nexport default class Pusher {\n /* STATIC PROPERTIES */\n static instances: Pusher[] = [];\n static isReady: boolean = false;\n static logToConsole: boolean = false;\n\n // for jsonp\n static Runtime: AbstractRuntime = Runtime;\n static ScriptReceivers: any = (Runtime).ScriptReceivers;\n static DependenciesReceivers: any = (Runtime).DependenciesReceivers;\n static auth_callbacks: any = (Runtime).auth_callbacks;\n\n static ready() {\n Pusher.isReady = true;\n for (var i = 0, l = Pusher.instances.length; i < l; i++) {\n Pusher.instances[i].connect();\n }\n }\n\n static log: (message: any) => void;\n\n private static getClientFeatures(): string[] {\n return Collections.keys(\n Collections.filterObject({ ws: Runtime.Transports.ws }, function(t) {\n return t.isSupported({});\n })\n );\n }\n\n /* INSTANCE PROPERTIES */\n key: string;\n options: Options;\n config: Config;\n channels: Channels;\n global_emitter: EventsDispatcher;\n sessionID: number;\n timeline: Timeline;\n timelineSender: TimelineSender;\n connection: ConnectionManager;\n timelineSenderTimer: PeriodicTimer;\n user: UserFacade;\n constructor(app_key: string, options: Options) {\n checkAppKey(app_key);\n validateOptions(options);\n this.key = app_key;\n this.config = getConfig(options, this);\n\n this.channels = Factory.createChannels();\n this.global_emitter = new EventsDispatcher();\n this.sessionID = Runtime.randomInt(1000000000);\n\n this.timeline = new Timeline(this.key, this.sessionID, {\n cluster: this.config.cluster,\n features: Pusher.getClientFeatures(),\n params: this.config.timelineParams || {},\n limit: 50,\n level: TimelineLevel.INFO,\n version: Defaults.VERSION\n });\n if (this.config.enableStats) {\n this.timelineSender = Factory.createTimelineSender(this.timeline, {\n host: this.config.statsHost,\n path: '/timeline/v2/' + Runtime.TimelineTransport.name\n });\n }\n\n var getStrategy = (options: StrategyOptions) => {\n return Runtime.getDefaultStrategy(this.config, options, defineTransport);\n };\n\n this.connection = Factory.createConnectionManager(this.key, {\n getStrategy: getStrategy,\n timeline: this.timeline,\n activityTimeout: this.config.activityTimeout,\n pongTimeout: this.config.pongTimeout,\n unavailableTimeout: this.config.unavailableTimeout,\n useTLS: Boolean(this.config.useTLS)\n });\n\n this.connection.bind('connected', () => {\n this.subscribeAll();\n if (this.timelineSender) {\n this.timelineSender.send(this.connection.isUsingTLS());\n }\n });\n\n this.connection.bind('message', event => {\n var eventName = event.event;\n var internal = eventName.indexOf('pusher_internal:') === 0;\n if (event.channel) {\n var channel = this.channel(event.channel);\n if (channel) {\n channel.handleEvent(event);\n }\n }\n // Emit globally [deprecated]\n if (!internal) {\n this.global_emitter.emit(event.event, event.data);\n }\n });\n this.connection.bind('connecting', () => {\n this.channels.disconnect();\n });\n this.connection.bind('disconnected', () => {\n this.channels.disconnect();\n });\n this.connection.bind('error', err => {\n Logger.warn(err);\n });\n\n Pusher.instances.push(this);\n this.timeline.info({ instances: Pusher.instances.length });\n\n this.user = new UserFacade(this);\n\n if (Pusher.isReady) {\n this.connect();\n }\n }\n\n /**\n * Allows you to switch Pusher cluster without\n * losing all the channels/subscription binding\n * as this is internally managed by the SDK.\n */\n switchCluster(options: ClusterOptions) {\n const { appKey, cluster } = options;\n this.key = appKey;\n this.options = { ...this.options, cluster };\n this.config = getConfig(this.options, this);\n this.connection.switchCluster(this.key);\n }\n\n channel(name: string): Channel {\n return this.channels.find(name);\n }\n\n allChannels(): Channel[] {\n return this.channels.all();\n }\n\n connect() {\n this.connection.connect();\n\n if (this.timelineSender) {\n if (!this.timelineSenderTimer) {\n var usingTLS = this.connection.isUsingTLS();\n var timelineSender = this.timelineSender;\n this.timelineSenderTimer = new PeriodicTimer(60000, function() {\n timelineSender.send(usingTLS);\n });\n }\n }\n }\n\n disconnect() {\n this.connection.disconnect();\n\n if (this.timelineSenderTimer) {\n this.timelineSenderTimer.ensureAborted();\n this.timelineSenderTimer = null;\n }\n }\n\n bind(event_name: string, callback: Function, context?: any): Pusher {\n this.global_emitter.bind(event_name, callback, context);\n return this;\n }\n\n unbind(event_name?: string, callback?: Function, context?: any): Pusher {\n this.global_emitter.unbind(event_name, callback, context);\n return this;\n }\n\n bind_global(callback: Function): Pusher {\n this.global_emitter.bind_global(callback);\n return this;\n }\n\n unbind_global(callback?: Function): Pusher {\n this.global_emitter.unbind_global(callback);\n return this;\n }\n\n unbind_all(callback?: Function): Pusher {\n this.global_emitter.unbind_all();\n return this;\n }\n\n subscribeAll() {\n var channelName;\n for (channelName in this.channels.channels) {\n if (this.channels.channels.hasOwnProperty(channelName)) {\n this.subscribe(channelName);\n }\n }\n }\n\n subscribe(channel_name: string) {\n var channel = this.channels.add(channel_name, this);\n if (channel.subscriptionPending && channel.subscriptionCancelled) {\n channel.reinstateSubscription();\n } else if (\n !channel.subscriptionPending &&\n this.connection.state === 'connected'\n ) {\n channel.subscribe();\n }\n return channel;\n }\n\n unsubscribe(channel_name: string) {\n var channel = this.channels.find(channel_name);\n if (channel && channel.subscriptionPending) {\n channel.cancelSubscription();\n } else {\n channel = this.channels.remove(channel_name);\n if (channel && channel.subscribed) {\n channel.unsubscribe();\n }\n }\n }\n\n send_event(event_name: string, data: any, channel?: string) {\n return this.connection.send_event(event_name, data, channel);\n }\n\n shouldUseTLS(): boolean {\n return this.config.useTLS;\n }\n\n signin() {\n this.user.signin();\n }\n}\n\nfunction checkAppKey(key) {\n if (key === null || key === undefined) {\n throw 'You must pass your app key when you instantiate Pusher.';\n }\n}\n\nRuntime.setup(Pusher);\n","import Pusher from './pusher';\nimport { Options, validateOptions } from './options';\nimport * as nacl from 'tweetnacl';\n\nexport default class PusherWithEncryption extends Pusher {\n constructor(app_key: string, options: Options) {\n Pusher.logToConsole = PusherWithEncryption.logToConsole;\n Pusher.log = PusherWithEncryption.log;\n\n validateOptions(options);\n options.nacl = nacl;\n super(app_key, options);\n }\n}\n"],"sourceRoot":""} \ No newline at end of file +{"version":3,"sources":["webpack://Pusher/webpack/universalModuleDefinition","webpack://Pusher/webpack/bootstrap","webpack://Pusher/./node_modules/@stablelib/base64/base64.ts","webpack://Pusher/./node_modules/@stablelib/utf8/utf8.ts","webpack://Pusher/./node_modules/tweetnacl/nacl-fast.js","webpack://Pusher/./src/core/pusher-with-encryption.js","webpack://Pusher/./src/core/base64.ts","webpack://Pusher/./src/core/utils/timers/abstract_timer.ts","webpack://Pusher/./src/core/utils/timers/index.ts","webpack://Pusher/./src/core/util.ts","webpack://Pusher/./src/core/utils/collections.ts","webpack://Pusher/./src/core/defaults.ts","webpack://Pusher/./src/core/transports/url_schemes.ts","webpack://Pusher/./src/core/events/callback_registry.ts","webpack://Pusher/./src/core/events/dispatcher.ts","webpack://Pusher/./src/core/logger.ts","webpack://Pusher/./src/core/transports/transport_connection.ts","webpack://Pusher/./src/core/transports/transport.ts","webpack://Pusher/./src/runtimes/isomorphic/transports/transports.ts","webpack://Pusher/./src/core/transports/assistant_to_the_transport_manager.ts","webpack://Pusher/./src/core/connection/protocol/protocol.ts","webpack://Pusher/./src/core/connection/connection.ts","webpack://Pusher/./src/core/connection/handshake/index.ts","webpack://Pusher/./src/core/timeline/timeline_sender.ts","webpack://Pusher/./src/core/errors.ts","webpack://Pusher/./src/core/utils/url_store.ts","webpack://Pusher/./src/core/channels/channel.ts","webpack://Pusher/./src/core/channels/private_channel.ts","webpack://Pusher/./src/core/channels/members.ts","webpack://Pusher/./src/core/channels/presence_channel.ts","webpack://Pusher/./src/core/channels/encrypted_channel.ts","webpack://Pusher/./src/core/connection/connection_manager.ts","webpack://Pusher/./src/core/channels/channels.ts","webpack://Pusher/./src/core/utils/factory.ts","webpack://Pusher/./src/core/transports/transport_manager.ts","webpack://Pusher/./src/core/strategies/sequential_strategy.ts","webpack://Pusher/./src/core/strategies/best_connected_ever_strategy.ts","webpack://Pusher/./src/core/strategies/websocket_prioritized_cached_strategy.ts","webpack://Pusher/./src/core/strategies/delayed_strategy.ts","webpack://Pusher/./src/core/strategies/if_strategy.ts","webpack://Pusher/./src/core/strategies/first_connected_strategy.ts","webpack://Pusher/./src/runtimes/isomorphic/default_strategy.ts","webpack://Pusher/./src/core/http/http_request.ts","webpack://Pusher/./src/core/http/state.ts","webpack://Pusher/./src/core/http/http_socket.ts","webpack://Pusher/./src/core/http/http_streaming_socket.ts","webpack://Pusher/./src/core/http/http_polling_socket.ts","webpack://Pusher/./src/runtimes/isomorphic/http/http_xhr_request.ts","webpack://Pusher/./src/runtimes/isomorphic/runtime.ts","webpack://Pusher/./src/runtimes/isomorphic/transports/transport_connection_initializer.ts","webpack://Pusher/./src/runtimes/isomorphic/http/http.ts","webpack://Pusher/./src/runtimes/worker/net_info.ts","webpack://Pusher/./src/runtimes/worker/auth/fetch_auth.ts","webpack://Pusher/./src/runtimes/worker/timeline/fetch_timeline.ts","webpack://Pusher/./src/runtimes/worker/runtime.ts","webpack://Pusher/./src/core/timeline/level.ts","webpack://Pusher/./src/core/timeline/timeline.ts","webpack://Pusher/./src/core/strategies/transport_strategy.ts","webpack://Pusher/./src/core/strategies/strategy_builder.ts","webpack://Pusher/./src/core/auth/options.ts","webpack://Pusher/./src/core/options.ts","webpack://Pusher/./src/core/auth/user_authenticator.ts","webpack://Pusher/./src/core/auth/channel_authorizer.ts","webpack://Pusher/./src/core/auth/deprecated_channel_authorizer.ts","webpack://Pusher/./src/core/config.ts","webpack://Pusher/./src/core/watchlist.ts","webpack://Pusher/./src/core/utils/flat_promise.ts","webpack://Pusher/./src/core/user.ts","webpack://Pusher/./src/core/pusher.ts","webpack://Pusher/./src/core/pusher-with-encryption.ts"],"names":["root","factory","exports","module","define","amd","this","installedModules","__webpack_require__","moduleId","i","l","modules","call","m","c","d","name","getter","o","Object","defineProperty","enumerable","get","r","Symbol","toStringTag","value","t","mode","__esModule","ns","create","key","bind","n","object","property","prototype","hasOwnProperty","p","s","_paddingCharacter","encodedLength","length","encode","data","out","_encodeByte","left","maxDecodedLength","decodedLength","_getPaddingLength","decode","Uint8Array","paddingLength","op","haveBad","v0","v1","v2","v3","_decodeChar","charCodeAt","Error","b","result","String","fromCharCode","Coder","stdCoder","URLSafeCoder","urlSafeCoder","INVALID_UTF8","arr","pos","chars","min","n1","n2","n3","push","join","nacl","gf","init","Float64Array","randombytes","_0","_9","gf0","gf1","_121665","D","D2","X","Y","I","ts64","x","h","vn","xi","y","yi","crypto_verify_16","crypto_verify_32","crypto_core_salsa20","inp","k","u","j0","j1","j2","j3","j4","j5","j6","j7","j8","j9","j10","j11","j12","j13","j14","j15","x0","x1","x2","x3","x4","x5","x6","x7","x8","x9","x10","x11","x12","x13","x14","x15","core_salsa20","crypto_core_hsalsa20","core_hsalsa20","sigma","crypto_stream_salsa20_xor","cpos","mpos","z","crypto_stream_salsa20","crypto_stream","sn","crypto_stream_xor","poly1305","t0","t1","t2","t3","t4","t5","t6","t7","buffer","Uint16Array","pad","leftover","fin","crypto_onetimeauth","outpos","update","finish","crypto_onetimeauth_verify","hpos","crypto_secretbox","crypto_secretbox_open","set25519","a","car25519","v","Math","floor","sel25519","q","pack25519","j","neq25519","par25519","unpack25519","A","Z","M","t8","t9","t10","t11","t12","t13","t14","t15","t16","t17","t18","t19","t20","t21","t22","t23","t24","t25","t26","t27","t28","t29","t30","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","b10","b11","b12","b13","b14","b15","S","inv25519","pow2523","crypto_scalarmult","e","f","x32","subarray","x16","crypto_scalarmult_base","crypto_box_keypair","crypto_box_beforenm","blocks","bytes","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","hibit","h0","h1","h2","h3","h4","h5","h6","h7","h8","h9","r0","r1","r2","r3","r4","r5","r6","r7","r8","r9","mac","macpos","mask","g","want","crypto_box_afternm","crypto_box_open_afternm","K","crypto_hashblocks_hl","hh","hl","bh0","bh1","bh2","bh3","bh4","bh5","bh6","bh7","bl0","bl1","bl2","bl3","bl4","bl5","bl6","bl7","th","tl","wh","Int32Array","wl","ah0","ah1","ah2","ah3","ah4","ah5","ah6","ah7","al0","al1","al2","al3","al4","al5","al6","al7","crypto_hash","add","cswap","pack","tx","ty","zi","scalarmult","scalarbase","crypto_sign_keypair","pk","sk","seeded","L","modL","carry","reduce","crypto_sign","sm","smlen","crypto_sign_open","chk","num","den","den2","den4","den6","unpackneg","checkLengths","checkArrayTypes","arguments","TypeError","cleanup","lowlevel","crypto_box","crypto_box_open","crypto_secretbox_KEYBYTES","crypto_secretbox_NONCEBYTES","crypto_secretbox_ZEROBYTES","crypto_secretbox_BOXZEROBYTES","crypto_scalarmult_BYTES","crypto_scalarmult_SCALARBYTES","crypto_box_PUBLICKEYBYTES","crypto_box_SECRETKEYBYTES","crypto_box_BEFORENMBYTES","crypto_box_NONCEBYTES","crypto_box_ZEROBYTES","crypto_box_BOXZEROBYTES","crypto_sign_BYTES","crypto_sign_PUBLICKEYBYTES","crypto_sign_SECRETKEYBYTES","crypto_sign_SEEDBYTES","crypto_hash_BYTES","randomBytes","secretbox","msg","nonce","open","box","keyLength","nonceLength","overheadLength","scalarMult","base","scalarLength","groupElementLength","publicKey","secretKey","before","checkBoxLengths","after","keyPair","fromSecretKey","publicKeyLength","secretKeyLength","sharedKeyLength","sign","signedMsg","tmp","mlen","detached","sig","verify","fromSeed","seed","seedLength","signatureLength","hash","hashLength","setPRNG","fn","crypto","self","msCrypto","getRandomValues","default","b64chars","b64tab","charAt","cb_utob","cc","utob","replace","cb_encode","ccc","padlen","ord","btoa","set","clear","delay","callback","timer","clearTimeout","clearInterval","super","setTimeout","setInterval","now","Date","valueOf","defer","args","boundArguments","Array","slice","apply","concat","extend","target","sources","extensions","constructor","stringify","safeJSONStringify","arrayIndexOf","array","item","nativeIndexOf","indexOf","objectApply","keys","_","context","map","filter","test","filterObject","Boolean","any","encodeParamsObject","encodeURIComponent","toString","buildQueryString","params","undefined","method","source","JSON","objects","paths","derez","path","nu","$ref","VERSION","PROTOCOL","wsPort","wssPort","wsPath","httpHost","httpPort","httpsPort","httpPath","stats_host","authEndpoint","authTransport","activityTimeout","pongTimeout","unavailableTimeout","userAuthentication","endpoint","transport","channelAuthorization","cdn_http","cdn_https","dependency_suffix","getGenericURL","baseScheme","useTLS","hostTLS","hostNonTLS","getGenericPath","queryString","ws","getInitial","http","_callbacks","prefix","prefixedEventName","names","removeCallback","removeAllCallbacks","binding","failThrough","callbacks","global_callbacks","eventName","remove","unbind","unbind_global","metadata","globalLog","message","console","log","globalLogWarn","globalLogError","warn","error","defaultLoggingFunction","logToConsole","hooks","priority","options","initialize","transportConnectionInitializer","state","timeline","id","generateUniqueID","handlesActivityChecks","supportsPing","socket","url","urls","getSocket","onError","changeState","bindListeners","debug","close","send","ping","beforeOpen","getPath","onopen","emit","type","buildTimelineMessage","closeEvent","code","reason","wasClean","unbindListeners","onOpen","onerror","onclose","onClose","onmessage","onMessage","onactivity","onActivity","info","cid","environment","isSupported","WSTransport","isInitialized","getWebSocketAPI","createWebSocket","httpConfiguration","streamingConfiguration","HTTPFactory","createStreamingSocket","pollingConfiguration","createPollingSocket","xhrConfiguration","isXHRSupported","xhr_streaming","xhr_polling","manager","minPingDelay","maxPingDelay","pingDelay","connection","createConnection","openTimestamp","onClosed","reportDeath","lifespan","max","isAlive","Protocol","decodeMessage","messageEvent","messageData","parse","pusherEventData","pusherEvent","event","channel","user_id","encodeMessage","processHandshake","activity_timeout","action","socket_id","getCloseAction","getCloseError","send_event","listeners","activity","closed","handleCloseEvent","listener","isEmpty","TimelineTransport","getAgent","BadEventName","setPrototypeOf","BadChannelName","TransportPriorityTooLow","TransportClosed","UnsupportedFeature","UnsupportedTransport","UnsupportedStrategy","HTTPAuthError","status","urlStore","baseUrl","authenticationEndpoint","authorizationEndpoint","javascriptQuickStart","triggeringClientEvents","encryptedChannelSupport","fullUrl","urlObj","pusher","subscribed","subscriptionPending","subscriptionCancelled","socketId","auth","suffix","handleSubscriptionSucceededEvent","handleSubscriptionCountEvent","unsubscribe","subscription_count","subscriptionCount","authorize","assign","channel_data","config","channelAuthorizer","channelName","reset","members","member","myID","subscriptionData","presence","count","me","memberData","user_info","authData","channelData","setMyID","user","signinDonePromise","user_data","handleInternalEvent","addedMember","addMember","removedMember","removeMember","onSubscription","disconnect","sharedSecret","handleEncryptedEvent","handleEvent","ciphertext","cipherText","getDataToEmit","raw","usingTLS","errorCallbacks","buildErrorCallbacks","connectionCallbacks","buildConnectionCallbacks","handshakeCallbacks","buildHandshakeCallbacks","Network","getNetwork","netinfo","retryIn","sendActivityCheck","updateStrategy","runner","strategy","updateState","startConnecting","setUnavailableTimer","disconnectInternally","handshake","connect","handshakeError","abortConnecting","abort","clearRetryTimer","clearUnavailableTimer","abandonConnection","getStrategy","round","retryTimer","ensureAborted","unavailableTimer","stopActivityCheck","activityTimer","pong_timed_out","resetActivityCheck","shouldRetry","connected","Infinity","setConnection","withErrorEmitted","tls_only","refused","backoff","retry","newState","previousState","newStateDescription","previous","current","channels","createEncryptedChannel","errMsg","createPrivateChannel","createPresenceChannel","createChannel","values","createChannels","createConnectionManager","createTimelineSender","createHandshake","createAssistantToTheTransportManager","livesLeft","lives","strategies","loop","failFast","timeout","timeoutLimit","minPriority","tryNextStrategy","tryStrategy","forceMinPriority","isRunning","callbackBuilder","runners","rs","abortRunner","allRunnersFailed","aborted","transports","ttl","storage","getLocalStorage","serializedCache","getTransportCacheKey","flushTransportCache","fetchTransportCache","cacheSkipCount","timestamp","includes","cached","latency","startTimestamp","pop","cb","storeTransportCache","number","IfStrategy","trueBranch","falseBranch","FirstConnectedStrategy","testSupportsStrategy","baseOptions","defineTransport","definedTransports","defineTransportStrategy","wsStrategy","ws_options","wsHost","wss_options","http_options","timeouts","ws_manager","streaming_manager","ws_transport","wss_transport","xhr_streaming_transport","xhr_polling_transport","ws_loop","wss_loop","streaming_loop","polling_loop","http_loop","payload","position","xhr","getRequest","unloader","addUnloadListener","setRequestHeader","removeUnloadListener","abortRequest","chunk","advanceBuffer","isBufferTooLong","unreadData","endOfLinePosition","State","autoIncrement","getUniqueURL","separator","randomNumber","randomInt","session","randomString","location","parts","exec","getLocation","readyState","CONNECTING","openStream","sendRaw","sendHeartbeat","OPEN","createSocketRequest","start","closeStream","CLOSED","onEvent","onHeartbeat","hostname","urlParts","stream","getReceiveURL","onChunk","onFinished","reconnect","unbind_all","getXHRAPI","onreadystatechange","onprogress","responseText","getDefaultStrategy","Transports","createSocket","createRequest","PusherClass","ready","getClientFeatures","getProtocol","createXHR","query","authOptions","authRequestType","headers","Headers","headerName","headersProvider","dynamicHeaders","body","request","Request","credentials","fetch","then","response","text","parsedData","catch","err","sender","host","json","setup","TimelineLevel","getAuthorizers","ajax","WebSocket","XMLHttpRequest","globalThis","Uint32Array","events","sent","uniqueID","level","limit","shift","ERROR","INFO","DEBUG","sendfn","bundle","lib","version","cluster","features","failAttempt","onInitialized","serializedTransport","AuthRequestType","transportClass","enabledTransports","disabledTransports","ignoreNullOrigin","getAssistant","deferred","validateOptions","paramsProvider","dynamicParams","composeChannelQuery","UserAuthentication","ChannelAuthorization","ChannelAuthorizerProxy","channelAuthorizerGenerator","deprecatedAuthorizerOptions","getConfig","opts","statsHost","enableStats","getEnableStatsConfig","getHttpHost","shouldUseTLS","getWebsocketHost","userAuthenticator","buildUserAuthenticator","buildChannelAuthorizer","timelineParams","forceTLS","disableStats","hasCustomHandler","customHandler","authorizer","buildChannelAuth","bindWatchlistInternalEvent","forEach","watchlistEvent","resolve","reject","promise","Promise","res","rej","signin_requested","serverToUserChannel","_signinDoneResolve","_onAuthorize","_cleanup","_signin","_newSigninPromiseIfNeeded","watchlist","_onSigninSuccess","_subscribeChannels","bind_global","reinstateSubscription","subscribe","ensure_subscribed","done","setDone","isReady","instances","app_key","checkAppKey","global_emitter","sessionID","timelineSender","subscribeAll","isUsingTLS","internal","appKey","switchCluster","find","all","timelineSenderTimer","event_name","channel_name","cancelSubscription","signin","Runtime","ScriptReceivers","DependenciesReceivers","auth_callbacks"],"mappings":";;;;;;;CAAA,SAA2CA,EAAMC,GAC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T,WAAW8a,GAET,OADA9a,KAAKu+B,eAAe7H,aACb12B,KAGT,eACE,IAAIkqB,EACJ,IAAKA,KAAelqB,KAAKmvB,SAASA,SAC5BnvB,KAAKmvB,SAASA,SAASltB,eAAeioB,IACxClqB,KAAK+9B,UAAU7T,GAKrB,UAAUiV,GACR,IAAIvY,EAAU5mB,KAAKmvB,SAASnb,IAAImrB,EAAcn/B,MAS9C,OARI4mB,EAAQuC,qBAAuBvC,EAAQwC,sBACzCxC,EAAQkX,wBAEPlX,EAAQuC,qBACiB,cAA1BnpB,KAAK4lB,WAAW1D,OAEhB0E,EAAQmX,YAEHnX,EAGT,YAAYuY,GACV,IAAIvY,EAAU5mB,KAAKmvB,SAAS4P,KAAKI,GAC7BvY,GAAWA,EAAQuC,oBACrBvC,EAAQwY,sBAERxY,EAAU5mB,KAAKmvB,SAASpO,OAAOoe,KAChBvY,EAAQsC,YACrBtC,EAAQ8C,cAKd,WAAWwV,EAAoB18B,EAAWokB,GACxC,OAAO5mB,KAAK4lB,WAAWyB,WAAW6X,EAAY18B,EAAMokB,GAGtD,eACE,OAAO5mB,KAAKgqB,OAAOpK,OAGrB,SACE5f,KAAKgrB,KAAKqU,UAvOL,GAAAjB,UAAsB,GACtB,GAAAD,SAAmB,EACnB,GAAAvc,cAAwB,EAGxB,GAAA0d,QAA2B,GAC3B,GAAAC,gBAA6B,GAASA,gBACtC,GAAAC,sBAAmC,GAASA,sBAC5C,GAAAC,eAA4B,GAASA,eAVzB,UAmPrB,GAAQ3G,MAAM,I,YCnQC,MAAM,WAA6B,GAChD,YAAYuF,EAAiBtc,GAC3B,GAAOH,aAAe,GAAqBA,aAC3C,GAAON,IAAM,GAAqBA,IAElCyZ,GAAgBhZ,GAChBA,EAAQld,KAAO,GACfqW,MAAMmjB,EAAStc","file":"pusher-with-encryption.worker.min.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"Pusher\"] = factory();\n\telse\n\t\troot[\"Pusher\"] = factory();\n})(this, function() {\nreturn "," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 3);\n","// Copyright (C) 2016 Dmitry Chestnykh\n// MIT License. See LICENSE file for details.\n\n/**\n * Package base64 implements Base64 encoding and decoding.\n */\n\n// Invalid character used in decoding to indicate\n// that the character to decode is out of range of\n// alphabet and cannot be decoded.\nconst INVALID_BYTE = 256;\n\n/**\n * Implements standard Base64 encoding.\n *\n * Operates in constant time.\n */\nexport class Coder {\n // TODO(dchest): methods to encode chunk-by-chunk.\n\n constructor(private _paddingCharacter = \"=\") { }\n\n encodedLength(length: number): number {\n if (!this._paddingCharacter) {\n return (length * 8 + 5) / 6 | 0;\n }\n return (length + 2) / 3 * 4 | 0;\n }\n\n encode(data: Uint8Array): string {\n let out = \"\";\n\n let i = 0;\n for (; i < data.length - 2; i += 3) {\n let c = (data[i] << 16) | (data[i + 1] << 8) | (data[i + 2]);\n out += this._encodeByte((c >>> 3 * 6) & 63);\n out += this._encodeByte((c >>> 2 * 6) & 63);\n out += this._encodeByte((c >>> 1 * 6) & 63);\n out += this._encodeByte((c >>> 0 * 6) & 63);\n }\n\n const left = data.length - i;\n if (left > 0) {\n let c = (data[i] << 16) | (left === 2 ? data[i + 1] << 8 : 0);\n out += this._encodeByte((c >>> 3 * 6) & 63);\n out += this._encodeByte((c >>> 2 * 6) & 63);\n if (left === 2) {\n out += this._encodeByte((c >>> 1 * 6) & 63);\n } else {\n out += this._paddingCharacter || \"\";\n }\n out += this._paddingCharacter || \"\";\n }\n\n return out;\n }\n\n maxDecodedLength(length: number): number {\n if (!this._paddingCharacter) {\n return (length * 6 + 7) / 8 | 0;\n }\n return length / 4 * 3 | 0;\n }\n\n decodedLength(s: string): number {\n return this.maxDecodedLength(s.length - this._getPaddingLength(s));\n }\n\n decode(s: string): Uint8Array {\n if (s.length === 0) {\n return new Uint8Array(0);\n }\n const paddingLength = this._getPaddingLength(s);\n const length = s.length - paddingLength;\n const out = new Uint8Array(this.maxDecodedLength(length));\n let op = 0;\n let i = 0;\n let haveBad = 0;\n let v0 = 0, v1 = 0, v2 = 0, v3 = 0;\n for (; i < length - 4; i += 4) {\n v0 = this._decodeChar(s.charCodeAt(i + 0));\n v1 = this._decodeChar(s.charCodeAt(i + 1));\n v2 = this._decodeChar(s.charCodeAt(i + 2));\n v3 = this._decodeChar(s.charCodeAt(i + 3));\n out[op++] = (v0 << 2) | (v1 >>> 4);\n out[op++] = (v1 << 4) | (v2 >>> 2);\n out[op++] = (v2 << 6) | v3;\n haveBad |= v0 & INVALID_BYTE;\n haveBad |= v1 & INVALID_BYTE;\n haveBad |= v2 & INVALID_BYTE;\n haveBad |= v3 & INVALID_BYTE;\n }\n if (i < length - 1) {\n v0 = this._decodeChar(s.charCodeAt(i));\n v1 = this._decodeChar(s.charCodeAt(i + 1));\n out[op++] = (v0 << 2) | (v1 >>> 4);\n haveBad |= v0 & INVALID_BYTE;\n haveBad |= v1 & INVALID_BYTE;\n }\n if (i < length - 2) {\n v2 = this._decodeChar(s.charCodeAt(i + 2));\n out[op++] = (v1 << 4) | (v2 >>> 2);\n haveBad |= v2 & INVALID_BYTE;\n }\n if (i < length - 3) {\n v3 = this._decodeChar(s.charCodeAt(i + 3));\n out[op++] = (v2 << 6) | v3;\n haveBad |= v3 & INVALID_BYTE;\n }\n if (haveBad !== 0) {\n throw new Error(\"Base64Coder: incorrect characters for decoding\");\n }\n return out;\n }\n\n // Standard encoding have the following encoded/decoded ranges,\n // which we need to convert between.\n //\n // ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 0123456789 + /\n // Index: 0 - 25 26 - 51 52 - 61 62 63\n // ASCII: 65 - 90 97 - 122 48 - 57 43 47\n //\n\n // Encode 6 bits in b into a new character.\n protected _encodeByte(b: number): string {\n // Encoding uses constant time operations as follows:\n //\n // 1. Define comparison of A with B using (A - B) >>> 8:\n // if A > B, then result is positive integer\n // if A <= B, then result is 0\n //\n // 2. Define selection of C or 0 using bitwise AND: X & C:\n // if X == 0, then result is 0\n // if X != 0, then result is C\n //\n // 3. Start with the smallest comparison (b >= 0), which is always\n // true, so set the result to the starting ASCII value (65).\n //\n // 4. Continue comparing b to higher ASCII values, and selecting\n // zero if comparison isn't true, otherwise selecting a value\n // to add to result, which:\n //\n // a) undoes the previous addition\n // b) provides new value to add\n //\n let result = b;\n // b >= 0\n result += 65;\n // b > 25\n result += ((25 - b) >>> 8) & ((0 - 65) - 26 + 97);\n // b > 51\n result += ((51 - b) >>> 8) & ((26 - 97) - 52 + 48);\n // b > 61\n result += ((61 - b) >>> 8) & ((52 - 48) - 62 + 43);\n // b > 62\n result += ((62 - b) >>> 8) & ((62 - 43) - 63 + 47);\n\n return String.fromCharCode(result);\n }\n\n // Decode a character code into a byte.\n // Must return 256 if character is out of alphabet range.\n protected _decodeChar(c: number): number {\n // Decoding works similar to encoding: using the same comparison\n // function, but now it works on ranges: result is always incremented\n // by value, but this value becomes zero if the range is not\n // satisfied.\n //\n // Decoding starts with invalid value, 256, which is then\n // subtracted when the range is satisfied. If none of the ranges\n // apply, the function returns 256, which is then checked by\n // the caller to throw error.\n let result = INVALID_BYTE; // start with invalid character\n\n // c == 43 (c > 42 and c < 44)\n result += (((42 - c) & (c - 44)) >>> 8) & (-INVALID_BYTE + c - 43 + 62);\n // c == 47 (c > 46 and c < 48)\n result += (((46 - c) & (c - 48)) >>> 8) & (-INVALID_BYTE + c - 47 + 63);\n // c > 47 and c < 58\n result += (((47 - c) & (c - 58)) >>> 8) & (-INVALID_BYTE + c - 48 + 52);\n // c > 64 and c < 91\n result += (((64 - c) & (c - 91)) >>> 8) & (-INVALID_BYTE + c - 65 + 0);\n // c > 96 and c < 123\n result += (((96 - c) & (c - 123)) >>> 8) & (-INVALID_BYTE + c - 97 + 26);\n\n return result;\n }\n\n private _getPaddingLength(s: string): number {\n let paddingLength = 0;\n if (this._paddingCharacter) {\n for (let i = s.length - 1; i >= 0; i--) {\n if (s[i] !== this._paddingCharacter) {\n break;\n }\n paddingLength++;\n }\n if (s.length < 4 || paddingLength > 2) {\n throw new Error(\"Base64Coder: incorrect padding\");\n }\n }\n return paddingLength;\n }\n\n}\n\nconst stdCoder = new Coder();\n\nexport function encode(data: Uint8Array): string {\n return stdCoder.encode(data);\n}\n\nexport function decode(s: string): Uint8Array {\n return stdCoder.decode(s);\n}\n\n/**\n * Implements URL-safe Base64 encoding.\n * (Same as Base64, but '+' is replaced with '-', and '/' with '_').\n *\n * Operates in constant time.\n */\nexport class URLSafeCoder extends Coder {\n // URL-safe encoding have the following encoded/decoded ranges:\n //\n // ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 0123456789 - _\n // Index: 0 - 25 26 - 51 52 - 61 62 63\n // ASCII: 65 - 90 97 - 122 48 - 57 45 95\n //\n\n protected _encodeByte(b: number): string {\n let result = b;\n // b >= 0\n result += 65;\n // b > 25\n result += ((25 - b) >>> 8) & ((0 - 65) - 26 + 97);\n // b > 51\n result += ((51 - b) >>> 8) & ((26 - 97) - 52 + 48);\n // b > 61\n result += ((61 - b) >>> 8) & ((52 - 48) - 62 + 45);\n // b > 62\n result += ((62 - b) >>> 8) & ((62 - 45) - 63 + 95);\n\n return String.fromCharCode(result);\n }\n\n protected _decodeChar(c: number): number {\n let result = INVALID_BYTE;\n\n // c == 45 (c > 44 and c < 46)\n result += (((44 - c) & (c - 46)) >>> 8) & (-INVALID_BYTE + c - 45 + 62);\n // c == 95 (c > 94 and c < 96)\n result += (((94 - c) & (c - 96)) >>> 8) & (-INVALID_BYTE + c - 95 + 63);\n // c > 47 and c < 58\n result += (((47 - c) & (c - 58)) >>> 8) & (-INVALID_BYTE + c - 48 + 52);\n // c > 64 and c < 91\n result += (((64 - c) & (c - 91)) >>> 8) & (-INVALID_BYTE + c - 65 + 0);\n // c > 96 and c < 123\n result += (((96 - c) & (c - 123)) >>> 8) & (-INVALID_BYTE + c - 97 + 26);\n\n return result;\n }\n}\n\nconst urlSafeCoder = new URLSafeCoder();\n\nexport function encodeURLSafe(data: Uint8Array): string {\n return urlSafeCoder.encode(data);\n}\n\nexport function decodeURLSafe(s: string): Uint8Array {\n return urlSafeCoder.decode(s);\n}\n\n\nexport const encodedLength = (length: number) =>\n stdCoder.encodedLength(length);\n\nexport const maxDecodedLength = (length: number) =>\n stdCoder.maxDecodedLength(length);\n\nexport const decodedLength = (s: string) =>\n stdCoder.decodedLength(s);\n","// Copyright (C) 2016 Dmitry Chestnykh\n// MIT License. See LICENSE file for details.\n\n/**\n * Package utf8 implements UTF-8 encoding and decoding.\n */\n\nconst INVALID_UTF16 = \"utf8: invalid string\";\nconst INVALID_UTF8 = \"utf8: invalid source encoding\";\n\n/**\n * Encodes the given string into UTF-8 byte array.\n * Throws if the source string has invalid UTF-16 encoding.\n */\nexport function encode(s: string): Uint8Array {\n // Calculate result length and allocate output array.\n // encodedLength() also validates string and throws errors,\n // so we don't need repeat validation here.\n const arr = new Uint8Array(encodedLength(s));\n\n let pos = 0;\n for (let i = 0; i < s.length; i++) {\n let c = s.charCodeAt(i);\n if (c < 0x80) {\n arr[pos++] = c;\n } else if (c < 0x800) {\n arr[pos++] = 0xc0 | c >> 6;\n arr[pos++] = 0x80 | c & 0x3f;\n } else if (c < 0xd800) {\n arr[pos++] = 0xe0 | c >> 12;\n arr[pos++] = 0x80 | (c >> 6) & 0x3f;\n arr[pos++] = 0x80 | c & 0x3f;\n } else {\n i++; // get one more character\n c = (c & 0x3ff) << 10;\n c |= s.charCodeAt(i) & 0x3ff;\n c += 0x10000;\n\n arr[pos++] = 0xf0 | c >> 18;\n arr[pos++] = 0x80 | (c >> 12) & 0x3f;\n arr[pos++] = 0x80 | (c >> 6) & 0x3f;\n arr[pos++] = 0x80 | c & 0x3f;\n }\n }\n return arr;\n}\n\n/**\n * Returns the number of bytes required to encode the given string into UTF-8.\n * Throws if the source string has invalid UTF-16 encoding.\n */\nexport function encodedLength(s: string): number {\n let result = 0;\n for (let i = 0; i < s.length; i++) {\n const c = s.charCodeAt(i);\n if (c < 0x80) {\n result += 1;\n } else if (c < 0x800) {\n result += 2;\n } else if (c < 0xd800) {\n result += 3;\n } else if (c <= 0xdfff) {\n if (i >= s.length - 1) {\n throw new Error(INVALID_UTF16);\n }\n i++; // \"eat\" next character\n result += 4;\n } else {\n throw new Error(INVALID_UTF16);\n }\n }\n return result;\n}\n\n/**\n * Decodes the given byte array from UTF-8 into a string.\n * Throws if encoding is invalid.\n */\nexport function decode(arr: Uint8Array): string {\n const chars: string[] = [];\n for (let i = 0; i < arr.length; i++) {\n let b = arr[i];\n\n if (b & 0x80) {\n let min;\n if (b < 0xe0) {\n // Need 1 more byte.\n if (i >= arr.length) {\n throw new Error(INVALID_UTF8);\n }\n const n1 = arr[++i];\n if ((n1 & 0xc0) !== 0x80) {\n throw new Error(INVALID_UTF8);\n }\n b = (b & 0x1f) << 6 | (n1 & 0x3f);\n min = 0x80;\n } else if (b < 0xf0) {\n // Need 2 more bytes.\n if (i >= arr.length - 1) {\n throw new Error(INVALID_UTF8);\n }\n const n1 = arr[++i];\n const n2 = arr[++i];\n if ((n1 & 0xc0) !== 0x80 || (n2 & 0xc0) !== 0x80) {\n throw new Error(INVALID_UTF8);\n }\n b = (b & 0x0f) << 12 | (n1 & 0x3f) << 6 | (n2 & 0x3f);\n min = 0x800;\n } else if (b < 0xf8) {\n // Need 3 more bytes.\n if (i >= arr.length - 2) {\n throw new Error(INVALID_UTF8);\n }\n const n1 = arr[++i];\n const n2 = arr[++i];\n const n3 = arr[++i];\n if ((n1 & 0xc0) !== 0x80 || (n2 & 0xc0) !== 0x80 || (n3 & 0xc0) !== 0x80) {\n throw new Error(INVALID_UTF8);\n }\n b = (b & 0x0f) << 18 | (n1 & 0x3f) << 12 | (n2 & 0x3f) << 6 | (n3 & 0x3f);\n min = 0x10000;\n } else {\n throw new Error(INVALID_UTF8);\n }\n\n if (b < min || (b >= 0xd800 && b <= 0xdfff)) {\n throw new Error(INVALID_UTF8);\n }\n\n if (b >= 0x10000) {\n // Surrogate pair.\n if (b > 0x10ffff) {\n throw new Error(INVALID_UTF8);\n }\n b -= 0x10000;\n chars.push(String.fromCharCode(0xd800 | (b >> 10)));\n b = 0xdc00 | (b & 0x3ff);\n }\n }\n\n chars.push(String.fromCharCode(b));\n }\n return chars.join(\"\");\n}\n","(function(nacl) {\n'use strict';\n\n// Ported in 2014 by Dmitry Chestnykh and Devi Mandiri.\n// Public domain.\n//\n// Implementation derived from TweetNaCl version 20140427.\n// See for details: http://tweetnacl.cr.yp.to/\n\nvar gf = function(init) {\n var i, r = new Float64Array(16);\n if (init) for (i = 0; i < init.length; i++) r[i] = init[i];\n return r;\n};\n\n// Pluggable, initialized in high-level API below.\nvar randombytes = function(/* x, n */) { throw new Error('no PRNG'); };\n\nvar _0 = new Uint8Array(16);\nvar _9 = new Uint8Array(32); _9[0] = 9;\n\nvar gf0 = gf(),\n gf1 = gf([1]),\n _121665 = gf([0xdb41, 1]),\n D = gf([0x78a3, 0x1359, 0x4dca, 0x75eb, 0xd8ab, 0x4141, 0x0a4d, 0x0070, 0xe898, 0x7779, 0x4079, 0x8cc7, 0xfe73, 0x2b6f, 0x6cee, 0x5203]),\n D2 = gf([0xf159, 0x26b2, 0x9b94, 0xebd6, 0xb156, 0x8283, 0x149a, 0x00e0, 0xd130, 0xeef3, 0x80f2, 0x198e, 0xfce7, 0x56df, 0xd9dc, 0x2406]),\n X = gf([0xd51a, 0x8f25, 0x2d60, 0xc956, 0xa7b2, 0x9525, 0xc760, 0x692c, 0xdc5c, 0xfdd6, 0xe231, 0xc0a4, 0x53fe, 0xcd6e, 0x36d3, 0x2169]),\n Y = gf([0x6658, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666]),\n I = gf([0xa0b0, 0x4a0e, 0x1b27, 0xc4ee, 0xe478, 0xad2f, 0x1806, 0x2f43, 0xd7a7, 0x3dfb, 0x0099, 0x2b4d, 0xdf0b, 0x4fc1, 0x2480, 0x2b83]);\n\nfunction ts64(x, i, h, l) {\n x[i] = (h >> 24) & 0xff;\n x[i+1] = (h >> 16) & 0xff;\n x[i+2] = (h >> 8) & 0xff;\n x[i+3] = h & 0xff;\n x[i+4] = (l >> 24) & 0xff;\n x[i+5] = (l >> 16) & 0xff;\n x[i+6] = (l >> 8) & 0xff;\n x[i+7] = l & 0xff;\n}\n\nfunction vn(x, xi, y, yi, n) {\n var i,d = 0;\n for (i = 0; i < n; i++) d |= x[xi+i]^y[yi+i];\n return (1 & ((d - 1) >>> 8)) - 1;\n}\n\nfunction crypto_verify_16(x, xi, y, yi) {\n return vn(x,xi,y,yi,16);\n}\n\nfunction crypto_verify_32(x, xi, y, yi) {\n return vn(x,xi,y,yi,32);\n}\n\nfunction core_salsa20(o, p, k, c) {\n var j0 = c[ 0] & 0xff | (c[ 1] & 0xff)<<8 | (c[ 2] & 0xff)<<16 | (c[ 3] & 0xff)<<24,\n j1 = k[ 0] & 0xff | (k[ 1] & 0xff)<<8 | (k[ 2] & 0xff)<<16 | (k[ 3] & 0xff)<<24,\n j2 = k[ 4] & 0xff | (k[ 5] & 0xff)<<8 | (k[ 6] & 0xff)<<16 | (k[ 7] & 0xff)<<24,\n j3 = k[ 8] & 0xff | (k[ 9] & 0xff)<<8 | (k[10] & 0xff)<<16 | (k[11] & 0xff)<<24,\n j4 = k[12] & 0xff | (k[13] & 0xff)<<8 | (k[14] & 0xff)<<16 | (k[15] & 0xff)<<24,\n j5 = c[ 4] & 0xff | (c[ 5] & 0xff)<<8 | (c[ 6] & 0xff)<<16 | (c[ 7] & 0xff)<<24,\n j6 = p[ 0] & 0xff | (p[ 1] & 0xff)<<8 | (p[ 2] & 0xff)<<16 | (p[ 3] & 0xff)<<24,\n j7 = p[ 4] & 0xff | (p[ 5] & 0xff)<<8 | (p[ 6] & 0xff)<<16 | (p[ 7] & 0xff)<<24,\n j8 = p[ 8] & 0xff | (p[ 9] & 0xff)<<8 | (p[10] & 0xff)<<16 | (p[11] & 0xff)<<24,\n j9 = p[12] & 0xff | (p[13] & 0xff)<<8 | (p[14] & 0xff)<<16 | (p[15] & 0xff)<<24,\n j10 = c[ 8] & 0xff | (c[ 9] & 0xff)<<8 | (c[10] & 0xff)<<16 | (c[11] & 0xff)<<24,\n j11 = k[16] & 0xff | (k[17] & 0xff)<<8 | (k[18] & 0xff)<<16 | (k[19] & 0xff)<<24,\n j12 = k[20] & 0xff | (k[21] & 0xff)<<8 | (k[22] & 0xff)<<16 | (k[23] & 0xff)<<24,\n j13 = k[24] & 0xff | (k[25] & 0xff)<<8 | (k[26] & 0xff)<<16 | (k[27] & 0xff)<<24,\n j14 = k[28] & 0xff | (k[29] & 0xff)<<8 | (k[30] & 0xff)<<16 | (k[31] & 0xff)<<24,\n j15 = c[12] & 0xff | (c[13] & 0xff)<<8 | (c[14] & 0xff)<<16 | (c[15] & 0xff)<<24;\n\n var x0 = j0, x1 = j1, x2 = j2, x3 = j3, x4 = j4, x5 = j5, x6 = j6, x7 = j7,\n x8 = j8, x9 = j9, x10 = j10, x11 = j11, x12 = j12, x13 = j13, x14 = j14,\n x15 = j15, u;\n\n for (var i = 0; i < 20; i += 2) {\n u = x0 + x12 | 0;\n x4 ^= u<<7 | u>>>(32-7);\n u = x4 + x0 | 0;\n x8 ^= u<<9 | u>>>(32-9);\n u = x8 + x4 | 0;\n x12 ^= u<<13 | u>>>(32-13);\n u = x12 + x8 | 0;\n x0 ^= u<<18 | u>>>(32-18);\n\n u = x5 + x1 | 0;\n x9 ^= u<<7 | u>>>(32-7);\n u = x9 + x5 | 0;\n x13 ^= u<<9 | u>>>(32-9);\n u = x13 + x9 | 0;\n x1 ^= u<<13 | u>>>(32-13);\n u = x1 + x13 | 0;\n x5 ^= u<<18 | u>>>(32-18);\n\n u = x10 + x6 | 0;\n x14 ^= u<<7 | u>>>(32-7);\n u = x14 + x10 | 0;\n x2 ^= u<<9 | u>>>(32-9);\n u = x2 + x14 | 0;\n x6 ^= u<<13 | u>>>(32-13);\n u = x6 + x2 | 0;\n x10 ^= u<<18 | u>>>(32-18);\n\n u = x15 + x11 | 0;\n x3 ^= u<<7 | u>>>(32-7);\n u = x3 + x15 | 0;\n x7 ^= u<<9 | u>>>(32-9);\n u = x7 + x3 | 0;\n x11 ^= u<<13 | u>>>(32-13);\n u = x11 + x7 | 0;\n x15 ^= u<<18 | u>>>(32-18);\n\n u = x0 + x3 | 0;\n x1 ^= u<<7 | u>>>(32-7);\n u = x1 + x0 | 0;\n x2 ^= u<<9 | u>>>(32-9);\n u = x2 + x1 | 0;\n x3 ^= u<<13 | u>>>(32-13);\n u = x3 + x2 | 0;\n x0 ^= u<<18 | u>>>(32-18);\n\n u = x5 + x4 | 0;\n x6 ^= u<<7 | u>>>(32-7);\n u = x6 + x5 | 0;\n x7 ^= u<<9 | u>>>(32-9);\n u = x7 + x6 | 0;\n x4 ^= u<<13 | u>>>(32-13);\n u = x4 + x7 | 0;\n x5 ^= u<<18 | u>>>(32-18);\n\n u = x10 + x9 | 0;\n x11 ^= u<<7 | u>>>(32-7);\n u = x11 + x10 | 0;\n x8 ^= u<<9 | u>>>(32-9);\n u = x8 + x11 | 0;\n x9 ^= u<<13 | u>>>(32-13);\n u = x9 + x8 | 0;\n x10 ^= u<<18 | u>>>(32-18);\n\n u = x15 + x14 | 0;\n x12 ^= u<<7 | u>>>(32-7);\n u = x12 + x15 | 0;\n x13 ^= u<<9 | u>>>(32-9);\n u = x13 + x12 | 0;\n x14 ^= u<<13 | u>>>(32-13);\n u = x14 + x13 | 0;\n x15 ^= u<<18 | u>>>(32-18);\n }\n x0 = x0 + j0 | 0;\n x1 = x1 + j1 | 0;\n x2 = x2 + j2 | 0;\n x3 = x3 + j3 | 0;\n x4 = x4 + j4 | 0;\n x5 = x5 + j5 | 0;\n x6 = x6 + j6 | 0;\n x7 = x7 + j7 | 0;\n x8 = x8 + j8 | 0;\n x9 = x9 + j9 | 0;\n x10 = x10 + j10 | 0;\n x11 = x11 + j11 | 0;\n x12 = x12 + j12 | 0;\n x13 = x13 + j13 | 0;\n x14 = x14 + j14 | 0;\n x15 = x15 + j15 | 0;\n\n o[ 0] = x0 >>> 0 & 0xff;\n o[ 1] = x0 >>> 8 & 0xff;\n o[ 2] = x0 >>> 16 & 0xff;\n o[ 3] = x0 >>> 24 & 0xff;\n\n o[ 4] = x1 >>> 0 & 0xff;\n o[ 5] = x1 >>> 8 & 0xff;\n o[ 6] = x1 >>> 16 & 0xff;\n o[ 7] = x1 >>> 24 & 0xff;\n\n o[ 8] = x2 >>> 0 & 0xff;\n o[ 9] = x2 >>> 8 & 0xff;\n o[10] = x2 >>> 16 & 0xff;\n o[11] = x2 >>> 24 & 0xff;\n\n o[12] = x3 >>> 0 & 0xff;\n o[13] = x3 >>> 8 & 0xff;\n o[14] = x3 >>> 16 & 0xff;\n o[15] = x3 >>> 24 & 0xff;\n\n o[16] = x4 >>> 0 & 0xff;\n o[17] = x4 >>> 8 & 0xff;\n o[18] = x4 >>> 16 & 0xff;\n o[19] = x4 >>> 24 & 0xff;\n\n o[20] = x5 >>> 0 & 0xff;\n o[21] = x5 >>> 8 & 0xff;\n o[22] = x5 >>> 16 & 0xff;\n o[23] = x5 >>> 24 & 0xff;\n\n o[24] = x6 >>> 0 & 0xff;\n o[25] = x6 >>> 8 & 0xff;\n o[26] = x6 >>> 16 & 0xff;\n o[27] = x6 >>> 24 & 0xff;\n\n o[28] = x7 >>> 0 & 0xff;\n o[29] = x7 >>> 8 & 0xff;\n o[30] = x7 >>> 16 & 0xff;\n o[31] = x7 >>> 24 & 0xff;\n\n o[32] = x8 >>> 0 & 0xff;\n o[33] = x8 >>> 8 & 0xff;\n o[34] = x8 >>> 16 & 0xff;\n o[35] = x8 >>> 24 & 0xff;\n\n o[36] = x9 >>> 0 & 0xff;\n o[37] = x9 >>> 8 & 0xff;\n o[38] = x9 >>> 16 & 0xff;\n o[39] = x9 >>> 24 & 0xff;\n\n o[40] = x10 >>> 0 & 0xff;\n o[41] = x10 >>> 8 & 0xff;\n o[42] = x10 >>> 16 & 0xff;\n o[43] = x10 >>> 24 & 0xff;\n\n o[44] = x11 >>> 0 & 0xff;\n o[45] = x11 >>> 8 & 0xff;\n o[46] = x11 >>> 16 & 0xff;\n o[47] = x11 >>> 24 & 0xff;\n\n o[48] = x12 >>> 0 & 0xff;\n o[49] = x12 >>> 8 & 0xff;\n o[50] = x12 >>> 16 & 0xff;\n o[51] = x12 >>> 24 & 0xff;\n\n o[52] = x13 >>> 0 & 0xff;\n o[53] = x13 >>> 8 & 0xff;\n o[54] = x13 >>> 16 & 0xff;\n o[55] = x13 >>> 24 & 0xff;\n\n o[56] = x14 >>> 0 & 0xff;\n o[57] = x14 >>> 8 & 0xff;\n o[58] = x14 >>> 16 & 0xff;\n o[59] = x14 >>> 24 & 0xff;\n\n o[60] = x15 >>> 0 & 0xff;\n o[61] = x15 >>> 8 & 0xff;\n o[62] = x15 >>> 16 & 0xff;\n o[63] = x15 >>> 24 & 0xff;\n}\n\nfunction core_hsalsa20(o,p,k,c) {\n var j0 = c[ 0] & 0xff | (c[ 1] & 0xff)<<8 | (c[ 2] & 0xff)<<16 | (c[ 3] & 0xff)<<24,\n j1 = k[ 0] & 0xff | (k[ 1] & 0xff)<<8 | (k[ 2] & 0xff)<<16 | (k[ 3] & 0xff)<<24,\n j2 = k[ 4] & 0xff | (k[ 5] & 0xff)<<8 | (k[ 6] & 0xff)<<16 | (k[ 7] & 0xff)<<24,\n j3 = k[ 8] & 0xff | (k[ 9] & 0xff)<<8 | (k[10] & 0xff)<<16 | (k[11] & 0xff)<<24,\n j4 = k[12] & 0xff | (k[13] & 0xff)<<8 | (k[14] & 0xff)<<16 | (k[15] & 0xff)<<24,\n j5 = c[ 4] & 0xff | (c[ 5] & 0xff)<<8 | (c[ 6] & 0xff)<<16 | (c[ 7] & 0xff)<<24,\n j6 = p[ 0] & 0xff | (p[ 1] & 0xff)<<8 | (p[ 2] & 0xff)<<16 | (p[ 3] & 0xff)<<24,\n j7 = p[ 4] & 0xff | (p[ 5] & 0xff)<<8 | (p[ 6] & 0xff)<<16 | (p[ 7] & 0xff)<<24,\n j8 = p[ 8] & 0xff | (p[ 9] & 0xff)<<8 | (p[10] & 0xff)<<16 | (p[11] & 0xff)<<24,\n j9 = p[12] & 0xff | (p[13] & 0xff)<<8 | (p[14] & 0xff)<<16 | (p[15] & 0xff)<<24,\n j10 = c[ 8] & 0xff | (c[ 9] & 0xff)<<8 | (c[10] & 0xff)<<16 | (c[11] & 0xff)<<24,\n j11 = k[16] & 0xff | (k[17] & 0xff)<<8 | (k[18] & 0xff)<<16 | (k[19] & 0xff)<<24,\n j12 = k[20] & 0xff | (k[21] & 0xff)<<8 | (k[22] & 0xff)<<16 | (k[23] & 0xff)<<24,\n j13 = k[24] & 0xff | (k[25] & 0xff)<<8 | (k[26] & 0xff)<<16 | (k[27] & 0xff)<<24,\n j14 = k[28] & 0xff | (k[29] & 0xff)<<8 | (k[30] & 0xff)<<16 | (k[31] & 0xff)<<24,\n j15 = c[12] & 0xff | (c[13] & 0xff)<<8 | (c[14] & 0xff)<<16 | (c[15] & 0xff)<<24;\n\n var x0 = j0, x1 = j1, x2 = j2, x3 = j3, x4 = j4, x5 = j5, x6 = j6, x7 = j7,\n x8 = j8, x9 = j9, x10 = j10, x11 = j11, x12 = j12, x13 = j13, x14 = j14,\n x15 = j15, u;\n\n for (var i = 0; i < 20; i += 2) {\n u = x0 + x12 | 0;\n x4 ^= u<<7 | u>>>(32-7);\n u = x4 + x0 | 0;\n x8 ^= u<<9 | u>>>(32-9);\n u = x8 + x4 | 0;\n x12 ^= u<<13 | u>>>(32-13);\n u = x12 + x8 | 0;\n x0 ^= u<<18 | u>>>(32-18);\n\n u = x5 + x1 | 0;\n x9 ^= u<<7 | u>>>(32-7);\n u = x9 + x5 | 0;\n x13 ^= u<<9 | u>>>(32-9);\n u = x13 + x9 | 0;\n x1 ^= u<<13 | u>>>(32-13);\n u = x1 + x13 | 0;\n x5 ^= u<<18 | u>>>(32-18);\n\n u = x10 + x6 | 0;\n x14 ^= u<<7 | u>>>(32-7);\n u = x14 + x10 | 0;\n x2 ^= u<<9 | u>>>(32-9);\n u = x2 + x14 | 0;\n x6 ^= u<<13 | u>>>(32-13);\n u = x6 + x2 | 0;\n x10 ^= u<<18 | u>>>(32-18);\n\n u = x15 + x11 | 0;\n x3 ^= u<<7 | u>>>(32-7);\n u = x3 + x15 | 0;\n x7 ^= u<<9 | u>>>(32-9);\n u = x7 + x3 | 0;\n x11 ^= u<<13 | u>>>(32-13);\n u = x11 + x7 | 0;\n x15 ^= u<<18 | u>>>(32-18);\n\n u = x0 + x3 | 0;\n x1 ^= u<<7 | u>>>(32-7);\n u = x1 + x0 | 0;\n x2 ^= u<<9 | u>>>(32-9);\n u = x2 + x1 | 0;\n x3 ^= u<<13 | u>>>(32-13);\n u = x3 + x2 | 0;\n x0 ^= u<<18 | u>>>(32-18);\n\n u = x5 + x4 | 0;\n x6 ^= u<<7 | u>>>(32-7);\n u = x6 + x5 | 0;\n x7 ^= u<<9 | u>>>(32-9);\n u = x7 + x6 | 0;\n x4 ^= u<<13 | u>>>(32-13);\n u = x4 + x7 | 0;\n x5 ^= u<<18 | u>>>(32-18);\n\n u = x10 + x9 | 0;\n x11 ^= u<<7 | u>>>(32-7);\n u = x11 + x10 | 0;\n x8 ^= u<<9 | u>>>(32-9);\n u = x8 + x11 | 0;\n x9 ^= u<<13 | u>>>(32-13);\n u = x9 + x8 | 0;\n x10 ^= u<<18 | u>>>(32-18);\n\n u = x15 + x14 | 0;\n x12 ^= u<<7 | u>>>(32-7);\n u = x12 + x15 | 0;\n x13 ^= u<<9 | u>>>(32-9);\n u = x13 + x12 | 0;\n x14 ^= u<<13 | u>>>(32-13);\n u = x14 + x13 | 0;\n x15 ^= u<<18 | u>>>(32-18);\n }\n\n o[ 0] = x0 >>> 0 & 0xff;\n o[ 1] = x0 >>> 8 & 0xff;\n o[ 2] = x0 >>> 16 & 0xff;\n o[ 3] = x0 >>> 24 & 0xff;\n\n o[ 4] = x5 >>> 0 & 0xff;\n o[ 5] = x5 >>> 8 & 0xff;\n o[ 6] = x5 >>> 16 & 0xff;\n o[ 7] = x5 >>> 24 & 0xff;\n\n o[ 8] = x10 >>> 0 & 0xff;\n o[ 9] = x10 >>> 8 & 0xff;\n o[10] = x10 >>> 16 & 0xff;\n o[11] = x10 >>> 24 & 0xff;\n\n o[12] = x15 >>> 0 & 0xff;\n o[13] = x15 >>> 8 & 0xff;\n o[14] = x15 >>> 16 & 0xff;\n o[15] = x15 >>> 24 & 0xff;\n\n o[16] = x6 >>> 0 & 0xff;\n o[17] = x6 >>> 8 & 0xff;\n o[18] = x6 >>> 16 & 0xff;\n o[19] = x6 >>> 24 & 0xff;\n\n o[20] = x7 >>> 0 & 0xff;\n o[21] = x7 >>> 8 & 0xff;\n o[22] = x7 >>> 16 & 0xff;\n o[23] = x7 >>> 24 & 0xff;\n\n o[24] = x8 >>> 0 & 0xff;\n o[25] = x8 >>> 8 & 0xff;\n o[26] = x8 >>> 16 & 0xff;\n o[27] = x8 >>> 24 & 0xff;\n\n o[28] = x9 >>> 0 & 0xff;\n o[29] = x9 >>> 8 & 0xff;\n o[30] = x9 >>> 16 & 0xff;\n o[31] = x9 >>> 24 & 0xff;\n}\n\nfunction crypto_core_salsa20(out,inp,k,c) {\n core_salsa20(out,inp,k,c);\n}\n\nfunction crypto_core_hsalsa20(out,inp,k,c) {\n core_hsalsa20(out,inp,k,c);\n}\n\nvar sigma = new Uint8Array([101, 120, 112, 97, 110, 100, 32, 51, 50, 45, 98, 121, 116, 101, 32, 107]);\n // \"expand 32-byte k\"\n\nfunction crypto_stream_salsa20_xor(c,cpos,m,mpos,b,n,k) {\n var z = new Uint8Array(16), x = new Uint8Array(64);\n var u, i;\n for (i = 0; i < 16; i++) z[i] = 0;\n for (i = 0; i < 8; i++) z[i] = n[i];\n while (b >= 64) {\n crypto_core_salsa20(x,z,k,sigma);\n for (i = 0; i < 64; i++) c[cpos+i] = m[mpos+i] ^ x[i];\n u = 1;\n for (i = 8; i < 16; i++) {\n u = u + (z[i] & 0xff) | 0;\n z[i] = u & 0xff;\n u >>>= 8;\n }\n b -= 64;\n cpos += 64;\n mpos += 64;\n }\n if (b > 0) {\n crypto_core_salsa20(x,z,k,sigma);\n for (i = 0; i < b; i++) c[cpos+i] = m[mpos+i] ^ x[i];\n }\n return 0;\n}\n\nfunction crypto_stream_salsa20(c,cpos,b,n,k) {\n var z = new Uint8Array(16), x = new Uint8Array(64);\n var u, i;\n for (i = 0; i < 16; i++) z[i] = 0;\n for (i = 0; i < 8; i++) z[i] = n[i];\n while (b >= 64) {\n crypto_core_salsa20(x,z,k,sigma);\n for (i = 0; i < 64; i++) c[cpos+i] = x[i];\n u = 1;\n for (i = 8; i < 16; i++) {\n u = u + (z[i] & 0xff) | 0;\n z[i] = u & 0xff;\n u >>>= 8;\n }\n b -= 64;\n cpos += 64;\n }\n if (b > 0) {\n crypto_core_salsa20(x,z,k,sigma);\n for (i = 0; i < b; i++) c[cpos+i] = x[i];\n }\n return 0;\n}\n\nfunction crypto_stream(c,cpos,d,n,k) {\n var s = new Uint8Array(32);\n crypto_core_hsalsa20(s,n,k,sigma);\n var sn = new Uint8Array(8);\n for (var i = 0; i < 8; i++) sn[i] = n[i+16];\n return crypto_stream_salsa20(c,cpos,d,sn,s);\n}\n\nfunction crypto_stream_xor(c,cpos,m,mpos,d,n,k) {\n var s = new Uint8Array(32);\n crypto_core_hsalsa20(s,n,k,sigma);\n var sn = new Uint8Array(8);\n for (var i = 0; i < 8; i++) sn[i] = n[i+16];\n return crypto_stream_salsa20_xor(c,cpos,m,mpos,d,sn,s);\n}\n\n/*\n* Port of Andrew Moon's Poly1305-donna-16. Public domain.\n* https://github.com/floodyberry/poly1305-donna\n*/\n\nvar poly1305 = function(key) {\n this.buffer = new Uint8Array(16);\n this.r = new Uint16Array(10);\n this.h = new Uint16Array(10);\n this.pad = new Uint16Array(8);\n this.leftover = 0;\n this.fin = 0;\n\n var t0, t1, t2, t3, t4, t5, t6, t7;\n\n t0 = key[ 0] & 0xff | (key[ 1] & 0xff) << 8; this.r[0] = ( t0 ) & 0x1fff;\n t1 = key[ 2] & 0xff | (key[ 3] & 0xff) << 8; this.r[1] = ((t0 >>> 13) | (t1 << 3)) & 0x1fff;\n t2 = key[ 4] & 0xff | (key[ 5] & 0xff) << 8; this.r[2] = ((t1 >>> 10) | (t2 << 6)) & 0x1f03;\n t3 = key[ 6] & 0xff | (key[ 7] & 0xff) << 8; this.r[3] = ((t2 >>> 7) | (t3 << 9)) & 0x1fff;\n t4 = key[ 8] & 0xff | (key[ 9] & 0xff) << 8; this.r[4] = ((t3 >>> 4) | (t4 << 12)) & 0x00ff;\n this.r[5] = ((t4 >>> 1)) & 0x1ffe;\n t5 = key[10] & 0xff | (key[11] & 0xff) << 8; this.r[6] = ((t4 >>> 14) | (t5 << 2)) & 0x1fff;\n t6 = key[12] & 0xff | (key[13] & 0xff) << 8; this.r[7] = ((t5 >>> 11) | (t6 << 5)) & 0x1f81;\n t7 = key[14] & 0xff | (key[15] & 0xff) << 8; this.r[8] = ((t6 >>> 8) | (t7 << 8)) & 0x1fff;\n this.r[9] = ((t7 >>> 5)) & 0x007f;\n\n this.pad[0] = key[16] & 0xff | (key[17] & 0xff) << 8;\n this.pad[1] = key[18] & 0xff | (key[19] & 0xff) << 8;\n this.pad[2] = key[20] & 0xff | (key[21] & 0xff) << 8;\n this.pad[3] = key[22] & 0xff | (key[23] & 0xff) << 8;\n this.pad[4] = key[24] & 0xff | (key[25] & 0xff) << 8;\n this.pad[5] = key[26] & 0xff | (key[27] & 0xff) << 8;\n this.pad[6] = key[28] & 0xff | (key[29] & 0xff) << 8;\n this.pad[7] = key[30] & 0xff | (key[31] & 0xff) << 8;\n};\n\npoly1305.prototype.blocks = function(m, mpos, bytes) {\n var hibit = this.fin ? 0 : (1 << 11);\n var t0, t1, t2, t3, t4, t5, t6, t7, c;\n var d0, d1, d2, d3, d4, d5, d6, d7, d8, d9;\n\n var h0 = this.h[0],\n h1 = this.h[1],\n h2 = this.h[2],\n h3 = this.h[3],\n h4 = this.h[4],\n h5 = this.h[5],\n h6 = this.h[6],\n h7 = this.h[7],\n h8 = this.h[8],\n h9 = this.h[9];\n\n var r0 = this.r[0],\n r1 = this.r[1],\n r2 = this.r[2],\n r3 = this.r[3],\n r4 = this.r[4],\n r5 = this.r[5],\n r6 = this.r[6],\n r7 = this.r[7],\n r8 = this.r[8],\n r9 = this.r[9];\n\n while (bytes >= 16) {\n t0 = m[mpos+ 0] & 0xff | (m[mpos+ 1] & 0xff) << 8; h0 += ( t0 ) & 0x1fff;\n t1 = m[mpos+ 2] & 0xff | (m[mpos+ 3] & 0xff) << 8; h1 += ((t0 >>> 13) | (t1 << 3)) & 0x1fff;\n t2 = m[mpos+ 4] & 0xff | (m[mpos+ 5] & 0xff) << 8; h2 += ((t1 >>> 10) | (t2 << 6)) & 0x1fff;\n t3 = m[mpos+ 6] & 0xff | (m[mpos+ 7] & 0xff) << 8; h3 += ((t2 >>> 7) | (t3 << 9)) & 0x1fff;\n t4 = m[mpos+ 8] & 0xff | (m[mpos+ 9] & 0xff) << 8; h4 += ((t3 >>> 4) | (t4 << 12)) & 0x1fff;\n h5 += ((t4 >>> 1)) & 0x1fff;\n t5 = m[mpos+10] & 0xff | (m[mpos+11] & 0xff) << 8; h6 += ((t4 >>> 14) | (t5 << 2)) & 0x1fff;\n t6 = m[mpos+12] & 0xff | (m[mpos+13] & 0xff) << 8; h7 += ((t5 >>> 11) | (t6 << 5)) & 0x1fff;\n t7 = m[mpos+14] & 0xff | (m[mpos+15] & 0xff) << 8; h8 += ((t6 >>> 8) | (t7 << 8)) & 0x1fff;\n h9 += ((t7 >>> 5)) | hibit;\n\n c = 0;\n\n d0 = c;\n d0 += h0 * r0;\n d0 += h1 * (5 * r9);\n d0 += h2 * (5 * r8);\n d0 += h3 * (5 * r7);\n d0 += h4 * (5 * r6);\n c = (d0 >>> 13); d0 &= 0x1fff;\n d0 += h5 * (5 * r5);\n d0 += h6 * (5 * r4);\n d0 += h7 * (5 * r3);\n d0 += h8 * (5 * r2);\n d0 += h9 * (5 * r1);\n c += (d0 >>> 13); d0 &= 0x1fff;\n\n d1 = c;\n d1 += h0 * r1;\n d1 += h1 * r0;\n d1 += h2 * (5 * r9);\n d1 += h3 * (5 * r8);\n d1 += h4 * (5 * r7);\n c = (d1 >>> 13); d1 &= 0x1fff;\n d1 += h5 * (5 * r6);\n d1 += h6 * (5 * r5);\n d1 += h7 * (5 * r4);\n d1 += h8 * (5 * r3);\n d1 += h9 * (5 * r2);\n c += (d1 >>> 13); d1 &= 0x1fff;\n\n d2 = c;\n d2 += h0 * r2;\n d2 += h1 * r1;\n d2 += h2 * r0;\n d2 += h3 * (5 * r9);\n d2 += h4 * (5 * r8);\n c = (d2 >>> 13); d2 &= 0x1fff;\n d2 += h5 * (5 * r7);\n d2 += h6 * (5 * r6);\n d2 += h7 * (5 * r5);\n d2 += h8 * (5 * r4);\n d2 += h9 * (5 * r3);\n c += (d2 >>> 13); d2 &= 0x1fff;\n\n d3 = c;\n d3 += h0 * r3;\n d3 += h1 * r2;\n d3 += h2 * r1;\n d3 += h3 * r0;\n d3 += h4 * (5 * r9);\n c = (d3 >>> 13); d3 &= 0x1fff;\n d3 += h5 * (5 * r8);\n d3 += h6 * (5 * r7);\n d3 += h7 * (5 * r6);\n d3 += h8 * (5 * r5);\n d3 += h9 * (5 * r4);\n c += (d3 >>> 13); d3 &= 0x1fff;\n\n d4 = c;\n d4 += h0 * r4;\n d4 += h1 * r3;\n d4 += h2 * r2;\n d4 += h3 * r1;\n d4 += h4 * r0;\n c = (d4 >>> 13); d4 &= 0x1fff;\n d4 += h5 * (5 * r9);\n d4 += h6 * (5 * r8);\n d4 += h7 * (5 * r7);\n d4 += h8 * (5 * r6);\n d4 += h9 * (5 * r5);\n c += (d4 >>> 13); d4 &= 0x1fff;\n\n d5 = c;\n d5 += h0 * r5;\n d5 += h1 * r4;\n d5 += h2 * r3;\n d5 += h3 * r2;\n d5 += h4 * r1;\n c = (d5 >>> 13); d5 &= 0x1fff;\n d5 += h5 * r0;\n d5 += h6 * (5 * r9);\n d5 += h7 * (5 * r8);\n d5 += h8 * (5 * r7);\n d5 += h9 * (5 * r6);\n c += (d5 >>> 13); d5 &= 0x1fff;\n\n d6 = c;\n d6 += h0 * r6;\n d6 += h1 * r5;\n d6 += h2 * r4;\n d6 += h3 * r3;\n d6 += h4 * r2;\n c = (d6 >>> 13); d6 &= 0x1fff;\n d6 += h5 * r1;\n d6 += h6 * r0;\n d6 += h7 * (5 * r9);\n d6 += h8 * (5 * r8);\n d6 += h9 * (5 * r7);\n c += (d6 >>> 13); d6 &= 0x1fff;\n\n d7 = c;\n d7 += h0 * r7;\n d7 += h1 * r6;\n d7 += h2 * r5;\n d7 += h3 * r4;\n d7 += h4 * r3;\n c = (d7 >>> 13); d7 &= 0x1fff;\n d7 += h5 * r2;\n d7 += h6 * r1;\n d7 += h7 * r0;\n d7 += h8 * (5 * r9);\n d7 += h9 * (5 * r8);\n c += (d7 >>> 13); d7 &= 0x1fff;\n\n d8 = c;\n d8 += h0 * r8;\n d8 += h1 * r7;\n d8 += h2 * r6;\n d8 += h3 * r5;\n d8 += h4 * r4;\n c = (d8 >>> 13); d8 &= 0x1fff;\n d8 += h5 * r3;\n d8 += h6 * r2;\n d8 += h7 * r1;\n d8 += h8 * r0;\n d8 += h9 * (5 * r9);\n c += (d8 >>> 13); d8 &= 0x1fff;\n\n d9 = c;\n d9 += h0 * r9;\n d9 += h1 * r8;\n d9 += h2 * r7;\n d9 += h3 * r6;\n d9 += h4 * r5;\n c = (d9 >>> 13); d9 &= 0x1fff;\n d9 += h5 * r4;\n d9 += h6 * r3;\n d9 += h7 * r2;\n d9 += h8 * r1;\n d9 += h9 * r0;\n c += (d9 >>> 13); d9 &= 0x1fff;\n\n c = (((c << 2) + c)) | 0;\n c = (c + d0) | 0;\n d0 = c & 0x1fff;\n c = (c >>> 13);\n d1 += c;\n\n h0 = d0;\n h1 = d1;\n h2 = d2;\n h3 = d3;\n h4 = d4;\n h5 = d5;\n h6 = d6;\n h7 = d7;\n h8 = d8;\n h9 = d9;\n\n mpos += 16;\n bytes -= 16;\n }\n this.h[0] = h0;\n this.h[1] = h1;\n this.h[2] = h2;\n this.h[3] = h3;\n this.h[4] = h4;\n this.h[5] = h5;\n this.h[6] = h6;\n this.h[7] = h7;\n this.h[8] = h8;\n this.h[9] = h9;\n};\n\npoly1305.prototype.finish = function(mac, macpos) {\n var g = new Uint16Array(10);\n var c, mask, f, i;\n\n if (this.leftover) {\n i = this.leftover;\n this.buffer[i++] = 1;\n for (; i < 16; i++) this.buffer[i] = 0;\n this.fin = 1;\n this.blocks(this.buffer, 0, 16);\n }\n\n c = this.h[1] >>> 13;\n this.h[1] &= 0x1fff;\n for (i = 2; i < 10; i++) {\n this.h[i] += c;\n c = this.h[i] >>> 13;\n this.h[i] &= 0x1fff;\n }\n this.h[0] += (c * 5);\n c = this.h[0] >>> 13;\n this.h[0] &= 0x1fff;\n this.h[1] += c;\n c = this.h[1] >>> 13;\n this.h[1] &= 0x1fff;\n this.h[2] += c;\n\n g[0] = this.h[0] + 5;\n c = g[0] >>> 13;\n g[0] &= 0x1fff;\n for (i = 1; i < 10; i++) {\n g[i] = this.h[i] + c;\n c = g[i] >>> 13;\n g[i] &= 0x1fff;\n }\n g[9] -= (1 << 13);\n\n mask = (c ^ 1) - 1;\n for (i = 0; i < 10; i++) g[i] &= mask;\n mask = ~mask;\n for (i = 0; i < 10; i++) this.h[i] = (this.h[i] & mask) | g[i];\n\n this.h[0] = ((this.h[0] ) | (this.h[1] << 13) ) & 0xffff;\n this.h[1] = ((this.h[1] >>> 3) | (this.h[2] << 10) ) & 0xffff;\n this.h[2] = ((this.h[2] >>> 6) | (this.h[3] << 7) ) & 0xffff;\n this.h[3] = ((this.h[3] >>> 9) | (this.h[4] << 4) ) & 0xffff;\n this.h[4] = ((this.h[4] >>> 12) | (this.h[5] << 1) | (this.h[6] << 14)) & 0xffff;\n this.h[5] = ((this.h[6] >>> 2) | (this.h[7] << 11) ) & 0xffff;\n this.h[6] = ((this.h[7] >>> 5) | (this.h[8] << 8) ) & 0xffff;\n this.h[7] = ((this.h[8] >>> 8) | (this.h[9] << 5) ) & 0xffff;\n\n f = this.h[0] + this.pad[0];\n this.h[0] = f & 0xffff;\n for (i = 1; i < 8; i++) {\n f = (((this.h[i] + this.pad[i]) | 0) + (f >>> 16)) | 0;\n this.h[i] = f & 0xffff;\n }\n\n mac[macpos+ 0] = (this.h[0] >>> 0) & 0xff;\n mac[macpos+ 1] = (this.h[0] >>> 8) & 0xff;\n mac[macpos+ 2] = (this.h[1] >>> 0) & 0xff;\n mac[macpos+ 3] = (this.h[1] >>> 8) & 0xff;\n mac[macpos+ 4] = (this.h[2] >>> 0) & 0xff;\n mac[macpos+ 5] = (this.h[2] >>> 8) & 0xff;\n mac[macpos+ 6] = (this.h[3] >>> 0) & 0xff;\n mac[macpos+ 7] = (this.h[3] >>> 8) & 0xff;\n mac[macpos+ 8] = (this.h[4] >>> 0) & 0xff;\n mac[macpos+ 9] = (this.h[4] >>> 8) & 0xff;\n mac[macpos+10] = (this.h[5] >>> 0) & 0xff;\n mac[macpos+11] = (this.h[5] >>> 8) & 0xff;\n mac[macpos+12] = (this.h[6] >>> 0) & 0xff;\n mac[macpos+13] = (this.h[6] >>> 8) & 0xff;\n mac[macpos+14] = (this.h[7] >>> 0) & 0xff;\n mac[macpos+15] = (this.h[7] >>> 8) & 0xff;\n};\n\npoly1305.prototype.update = function(m, mpos, bytes) {\n var i, want;\n\n if (this.leftover) {\n want = (16 - this.leftover);\n if (want > bytes)\n want = bytes;\n for (i = 0; i < want; i++)\n this.buffer[this.leftover + i] = m[mpos+i];\n bytes -= want;\n mpos += want;\n this.leftover += want;\n if (this.leftover < 16)\n return;\n this.blocks(this.buffer, 0, 16);\n this.leftover = 0;\n }\n\n if (bytes >= 16) {\n want = bytes - (bytes % 16);\n this.blocks(m, mpos, want);\n mpos += want;\n bytes -= want;\n }\n\n if (bytes) {\n for (i = 0; i < bytes; i++)\n this.buffer[this.leftover + i] = m[mpos+i];\n this.leftover += bytes;\n }\n};\n\nfunction crypto_onetimeauth(out, outpos, m, mpos, n, k) {\n var s = new poly1305(k);\n s.update(m, mpos, n);\n s.finish(out, outpos);\n return 0;\n}\n\nfunction crypto_onetimeauth_verify(h, hpos, m, mpos, n, k) {\n var x = new Uint8Array(16);\n crypto_onetimeauth(x,0,m,mpos,n,k);\n return crypto_verify_16(h,hpos,x,0);\n}\n\nfunction crypto_secretbox(c,m,d,n,k) {\n var i;\n if (d < 32) return -1;\n crypto_stream_xor(c,0,m,0,d,n,k);\n crypto_onetimeauth(c, 16, c, 32, d - 32, c);\n for (i = 0; i < 16; i++) c[i] = 0;\n return 0;\n}\n\nfunction crypto_secretbox_open(m,c,d,n,k) {\n var i;\n var x = new Uint8Array(32);\n if (d < 32) return -1;\n crypto_stream(x,0,32,n,k);\n if (crypto_onetimeauth_verify(c, 16,c, 32,d - 32,x) !== 0) return -1;\n crypto_stream_xor(m,0,c,0,d,n,k);\n for (i = 0; i < 32; i++) m[i] = 0;\n return 0;\n}\n\nfunction set25519(r, a) {\n var i;\n for (i = 0; i < 16; i++) r[i] = a[i]|0;\n}\n\nfunction car25519(o) {\n var i, v, c = 1;\n for (i = 0; i < 16; i++) {\n v = o[i] + c + 65535;\n c = Math.floor(v / 65536);\n o[i] = v - c * 65536;\n }\n o[0] += c-1 + 37 * (c-1);\n}\n\nfunction sel25519(p, q, b) {\n var t, c = ~(b-1);\n for (var i = 0; i < 16; i++) {\n t = c & (p[i] ^ q[i]);\n p[i] ^= t;\n q[i] ^= t;\n }\n}\n\nfunction pack25519(o, n) {\n var i, j, b;\n var m = gf(), t = gf();\n for (i = 0; i < 16; i++) t[i] = n[i];\n car25519(t);\n car25519(t);\n car25519(t);\n for (j = 0; j < 2; j++) {\n m[0] = t[0] - 0xffed;\n for (i = 1; i < 15; i++) {\n m[i] = t[i] - 0xffff - ((m[i-1]>>16) & 1);\n m[i-1] &= 0xffff;\n }\n m[15] = t[15] - 0x7fff - ((m[14]>>16) & 1);\n b = (m[15]>>16) & 1;\n m[14] &= 0xffff;\n sel25519(t, m, 1-b);\n }\n for (i = 0; i < 16; i++) {\n o[2*i] = t[i] & 0xff;\n o[2*i+1] = t[i]>>8;\n }\n}\n\nfunction neq25519(a, b) {\n var c = new Uint8Array(32), d = new Uint8Array(32);\n pack25519(c, a);\n pack25519(d, b);\n return crypto_verify_32(c, 0, d, 0);\n}\n\nfunction par25519(a) {\n var d = new Uint8Array(32);\n pack25519(d, a);\n return d[0] & 1;\n}\n\nfunction unpack25519(o, n) {\n var i;\n for (i = 0; i < 16; i++) o[i] = n[2*i] + (n[2*i+1] << 8);\n o[15] &= 0x7fff;\n}\n\nfunction A(o, a, b) {\n for (var i = 0; i < 16; i++) o[i] = a[i] + b[i];\n}\n\nfunction Z(o, a, b) {\n for (var i = 0; i < 16; i++) o[i] = a[i] - b[i];\n}\n\nfunction M(o, a, b) {\n var v, c,\n t0 = 0, t1 = 0, t2 = 0, t3 = 0, t4 = 0, t5 = 0, t6 = 0, t7 = 0,\n t8 = 0, t9 = 0, t10 = 0, t11 = 0, t12 = 0, t13 = 0, t14 = 0, t15 = 0,\n t16 = 0, t17 = 0, t18 = 0, t19 = 0, t20 = 0, t21 = 0, t22 = 0, t23 = 0,\n t24 = 0, t25 = 0, t26 = 0, t27 = 0, t28 = 0, t29 = 0, t30 = 0,\n b0 = b[0],\n b1 = b[1],\n b2 = b[2],\n b3 = b[3],\n b4 = b[4],\n b5 = b[5],\n b6 = b[6],\n b7 = b[7],\n b8 = b[8],\n b9 = b[9],\n b10 = b[10],\n b11 = b[11],\n b12 = b[12],\n b13 = b[13],\n b14 = b[14],\n b15 = b[15];\n\n v = a[0];\n t0 += v * b0;\n t1 += v * b1;\n t2 += v * b2;\n t3 += v * b3;\n t4 += v * b4;\n t5 += v * b5;\n t6 += v * b6;\n t7 += v * b7;\n t8 += v * b8;\n t9 += v * b9;\n t10 += v * b10;\n t11 += v * b11;\n t12 += v * b12;\n t13 += v * b13;\n t14 += v * b14;\n t15 += v * b15;\n v = a[1];\n t1 += v * b0;\n t2 += v * b1;\n t3 += v * b2;\n t4 += v * b3;\n t5 += v * b4;\n t6 += v * b5;\n t7 += v * b6;\n t8 += v * b7;\n t9 += v * b8;\n t10 += v * b9;\n t11 += v * b10;\n t12 += v * b11;\n t13 += v * b12;\n t14 += v * b13;\n t15 += v * b14;\n t16 += v * b15;\n v = a[2];\n t2 += v * b0;\n t3 += v * b1;\n t4 += v * b2;\n t5 += v * b3;\n t6 += v * b4;\n t7 += v * b5;\n t8 += v * b6;\n t9 += v * b7;\n t10 += v * b8;\n t11 += v * b9;\n t12 += v * b10;\n t13 += v * b11;\n t14 += v * b12;\n t15 += v * b13;\n t16 += v * b14;\n t17 += v * b15;\n v = a[3];\n t3 += v * b0;\n t4 += v * b1;\n t5 += v * b2;\n t6 += v * b3;\n t7 += v * b4;\n t8 += v * b5;\n t9 += v * b6;\n t10 += v * b7;\n t11 += v * b8;\n t12 += v * b9;\n t13 += v * b10;\n t14 += v * b11;\n t15 += v * b12;\n t16 += v * b13;\n t17 += v * b14;\n t18 += v * b15;\n v = a[4];\n t4 += v * b0;\n t5 += v * b1;\n t6 += v * b2;\n t7 += v * b3;\n t8 += v * b4;\n t9 += v * b5;\n t10 += v * b6;\n t11 += v * b7;\n t12 += v * b8;\n t13 += v * b9;\n t14 += v * b10;\n t15 += v * b11;\n t16 += v * b12;\n t17 += v * b13;\n t18 += v * b14;\n t19 += v * b15;\n v = a[5];\n t5 += v * b0;\n t6 += v * b1;\n t7 += v * b2;\n t8 += v * b3;\n t9 += v * b4;\n t10 += v * b5;\n t11 += v * b6;\n t12 += v * b7;\n t13 += v * b8;\n t14 += v * b9;\n t15 += v * b10;\n t16 += v * b11;\n t17 += v * b12;\n t18 += v * b13;\n t19 += v * b14;\n t20 += v * b15;\n v = a[6];\n t6 += v * b0;\n t7 += v * b1;\n t8 += v * b2;\n t9 += v * b3;\n t10 += v * b4;\n t11 += v * b5;\n t12 += v * b6;\n t13 += v * b7;\n t14 += v * b8;\n t15 += v * b9;\n t16 += v * b10;\n t17 += v * b11;\n t18 += v * b12;\n t19 += v * b13;\n t20 += v * b14;\n t21 += v * b15;\n v = a[7];\n t7 += v * b0;\n t8 += v * b1;\n t9 += v * b2;\n t10 += v * b3;\n t11 += v * b4;\n t12 += v * b5;\n t13 += v * b6;\n t14 += v * b7;\n t15 += v * b8;\n t16 += v * b9;\n t17 += v * b10;\n t18 += v * b11;\n t19 += v * b12;\n t20 += v * b13;\n t21 += v * b14;\n t22 += v * b15;\n v = a[8];\n t8 += v * b0;\n t9 += v * b1;\n t10 += v * b2;\n t11 += v * b3;\n t12 += v * b4;\n t13 += v * b5;\n t14 += v * b6;\n t15 += v * b7;\n t16 += v * b8;\n t17 += v * b9;\n t18 += v * b10;\n t19 += v * b11;\n t20 += v * b12;\n t21 += v * b13;\n t22 += v * b14;\n t23 += v * b15;\n v = a[9];\n t9 += v * b0;\n t10 += v * b1;\n t11 += v * b2;\n t12 += v * b3;\n t13 += v * b4;\n t14 += v * b5;\n t15 += v * b6;\n t16 += v * b7;\n t17 += v * b8;\n t18 += v * b9;\n t19 += v * b10;\n t20 += v * b11;\n t21 += v * b12;\n t22 += v * b13;\n t23 += v * b14;\n t24 += v * b15;\n v = a[10];\n t10 += v * b0;\n t11 += v * b1;\n t12 += v * b2;\n t13 += v * b3;\n t14 += v * b4;\n t15 += v * b5;\n t16 += v * b6;\n t17 += v * b7;\n t18 += v * b8;\n t19 += v * b9;\n t20 += v * b10;\n t21 += v * b11;\n t22 += v * b12;\n t23 += v * b13;\n t24 += v * b14;\n t25 += v * b15;\n v = a[11];\n t11 += v * b0;\n t12 += v * b1;\n t13 += v * b2;\n t14 += v * b3;\n t15 += v * b4;\n t16 += v * b5;\n t17 += v * b6;\n t18 += v * b7;\n t19 += v * b8;\n t20 += v * b9;\n t21 += v * b10;\n t22 += v * b11;\n t23 += v * b12;\n t24 += v * b13;\n t25 += v * b14;\n t26 += v * b15;\n v = a[12];\n t12 += v * b0;\n t13 += v * b1;\n t14 += v * b2;\n t15 += v * b3;\n t16 += v * b4;\n t17 += v * b5;\n t18 += v * b6;\n t19 += v * b7;\n t20 += v * b8;\n t21 += v * b9;\n t22 += v * b10;\n t23 += v * b11;\n t24 += v * b12;\n t25 += v * b13;\n t26 += v * b14;\n t27 += v * b15;\n v = a[13];\n t13 += v * b0;\n t14 += v * b1;\n t15 += v * b2;\n t16 += v * b3;\n t17 += v * b4;\n t18 += v * b5;\n t19 += v * b6;\n t20 += v * b7;\n t21 += v * b8;\n t22 += v * b9;\n t23 += v * b10;\n t24 += v * b11;\n t25 += v * b12;\n t26 += v * b13;\n t27 += v * b14;\n t28 += v * b15;\n v = a[14];\n t14 += v * b0;\n t15 += v * b1;\n t16 += v * b2;\n t17 += v * b3;\n t18 += v * b4;\n t19 += v * b5;\n t20 += v * b6;\n t21 += v * b7;\n t22 += v * b8;\n t23 += v * b9;\n t24 += v * b10;\n t25 += v * b11;\n t26 += v * b12;\n t27 += v * b13;\n t28 += v * b14;\n t29 += v * b15;\n v = a[15];\n t15 += v * b0;\n t16 += v * b1;\n t17 += v * b2;\n t18 += v * b3;\n t19 += v * b4;\n t20 += v * b5;\n t21 += v * b6;\n t22 += v * b7;\n t23 += v * b8;\n t24 += v * b9;\n t25 += v * b10;\n t26 += v * b11;\n t27 += v * b12;\n t28 += v * b13;\n t29 += v * b14;\n t30 += v * b15;\n\n t0 += 38 * t16;\n t1 += 38 * t17;\n t2 += 38 * t18;\n t3 += 38 * t19;\n t4 += 38 * t20;\n t5 += 38 * t21;\n t6 += 38 * t22;\n t7 += 38 * t23;\n t8 += 38 * t24;\n t9 += 38 * t25;\n t10 += 38 * t26;\n t11 += 38 * t27;\n t12 += 38 * t28;\n t13 += 38 * t29;\n t14 += 38 * t30;\n // t15 left as is\n\n // first car\n c = 1;\n v = t0 + c + 65535; c = Math.floor(v / 65536); t0 = v - c * 65536;\n v = t1 + c + 65535; c = Math.floor(v / 65536); t1 = v - c * 65536;\n v = t2 + c + 65535; c = Math.floor(v / 65536); t2 = v - c * 65536;\n v = t3 + c + 65535; c = Math.floor(v / 65536); t3 = v - c * 65536;\n v = t4 + c + 65535; c = Math.floor(v / 65536); t4 = v - c * 65536;\n v = t5 + c + 65535; c = Math.floor(v / 65536); t5 = v - c * 65536;\n v = t6 + c + 65535; c = Math.floor(v / 65536); t6 = v - c * 65536;\n v = t7 + c + 65535; c = Math.floor(v / 65536); t7 = v - c * 65536;\n v = t8 + c + 65535; c = Math.floor(v / 65536); t8 = v - c * 65536;\n v = t9 + c + 65535; c = Math.floor(v / 65536); t9 = v - c * 65536;\n v = t10 + c + 65535; c = Math.floor(v / 65536); t10 = v - c * 65536;\n v = t11 + c + 65535; c = Math.floor(v / 65536); t11 = v - c * 65536;\n v = t12 + c + 65535; c = Math.floor(v / 65536); t12 = v - c * 65536;\n v = t13 + c + 65535; c = Math.floor(v / 65536); t13 = v - c * 65536;\n v = t14 + c + 65535; c = Math.floor(v / 65536); t14 = v - c * 65536;\n v = t15 + c + 65535; c = Math.floor(v / 65536); t15 = v - c * 65536;\n t0 += c-1 + 37 * (c-1);\n\n // second car\n c = 1;\n v = t0 + c + 65535; c = Math.floor(v / 65536); t0 = v - c * 65536;\n v = t1 + c + 65535; c = Math.floor(v / 65536); t1 = v - c * 65536;\n v = t2 + c + 65535; c = Math.floor(v / 65536); t2 = v - c * 65536;\n v = t3 + c + 65535; c = Math.floor(v / 65536); t3 = v - c * 65536;\n v = t4 + c + 65535; c = Math.floor(v / 65536); t4 = v - c * 65536;\n v = t5 + c + 65535; c = Math.floor(v / 65536); t5 = v - c * 65536;\n v = t6 + c + 65535; c = Math.floor(v / 65536); t6 = v - c * 65536;\n v = t7 + c + 65535; c = Math.floor(v / 65536); t7 = v - c * 65536;\n v = t8 + c + 65535; c = Math.floor(v / 65536); t8 = v - c * 65536;\n v = t9 + c + 65535; c = Math.floor(v / 65536); t9 = v - c * 65536;\n v = t10 + c + 65535; c = Math.floor(v / 65536); t10 = v - c * 65536;\n v = t11 + c + 65535; c = Math.floor(v / 65536); t11 = v - c * 65536;\n v = t12 + c + 65535; c = Math.floor(v / 65536); t12 = v - c * 65536;\n v = t13 + c + 65535; c = Math.floor(v / 65536); t13 = v - c * 65536;\n v = t14 + c + 65535; c = Math.floor(v / 65536); t14 = v - c * 65536;\n v = t15 + c + 65535; c = Math.floor(v / 65536); t15 = v - c * 65536;\n t0 += c-1 + 37 * (c-1);\n\n o[ 0] = t0;\n o[ 1] = t1;\n o[ 2] = t2;\n o[ 3] = t3;\n o[ 4] = t4;\n o[ 5] = t5;\n o[ 6] = t6;\n o[ 7] = t7;\n o[ 8] = t8;\n o[ 9] = t9;\n o[10] = t10;\n o[11] = t11;\n o[12] = t12;\n o[13] = t13;\n o[14] = t14;\n o[15] = t15;\n}\n\nfunction S(o, a) {\n M(o, a, a);\n}\n\nfunction inv25519(o, i) {\n var c = gf();\n var a;\n for (a = 0; a < 16; a++) c[a] = i[a];\n for (a = 253; a >= 0; a--) {\n S(c, c);\n if(a !== 2 && a !== 4) M(c, c, i);\n }\n for (a = 0; a < 16; a++) o[a] = c[a];\n}\n\nfunction pow2523(o, i) {\n var c = gf();\n var a;\n for (a = 0; a < 16; a++) c[a] = i[a];\n for (a = 250; a >= 0; a--) {\n S(c, c);\n if(a !== 1) M(c, c, i);\n }\n for (a = 0; a < 16; a++) o[a] = c[a];\n}\n\nfunction crypto_scalarmult(q, n, p) {\n var z = new Uint8Array(32);\n var x = new Float64Array(80), r, i;\n var a = gf(), b = gf(), c = gf(),\n d = gf(), e = gf(), f = gf();\n for (i = 0; i < 31; i++) z[i] = n[i];\n z[31]=(n[31]&127)|64;\n z[0]&=248;\n unpack25519(x,p);\n for (i = 0; i < 16; i++) {\n b[i]=x[i];\n d[i]=a[i]=c[i]=0;\n }\n a[0]=d[0]=1;\n for (i=254; i>=0; --i) {\n r=(z[i>>>3]>>>(i&7))&1;\n sel25519(a,b,r);\n sel25519(c,d,r);\n A(e,a,c);\n Z(a,a,c);\n A(c,b,d);\n Z(b,b,d);\n S(d,e);\n S(f,a);\n M(a,c,a);\n M(c,b,e);\n A(e,a,c);\n Z(a,a,c);\n S(b,a);\n Z(c,d,f);\n M(a,c,_121665);\n A(a,a,d);\n M(c,c,a);\n M(a,d,f);\n M(d,b,x);\n S(b,e);\n sel25519(a,b,r);\n sel25519(c,d,r);\n }\n for (i = 0; i < 16; i++) {\n x[i+16]=a[i];\n x[i+32]=c[i];\n x[i+48]=b[i];\n x[i+64]=d[i];\n }\n var x32 = x.subarray(32);\n var x16 = x.subarray(16);\n inv25519(x32,x32);\n M(x16,x16,x32);\n pack25519(q,x16);\n return 0;\n}\n\nfunction crypto_scalarmult_base(q, n) {\n return crypto_scalarmult(q, n, _9);\n}\n\nfunction crypto_box_keypair(y, x) {\n randombytes(x, 32);\n return crypto_scalarmult_base(y, x);\n}\n\nfunction crypto_box_beforenm(k, y, x) {\n var s = new Uint8Array(32);\n crypto_scalarmult(s, x, y);\n return crypto_core_hsalsa20(k, _0, s, sigma);\n}\n\nvar crypto_box_afternm = crypto_secretbox;\nvar crypto_box_open_afternm = crypto_secretbox_open;\n\nfunction crypto_box(c, m, d, n, y, x) {\n var k = new Uint8Array(32);\n crypto_box_beforenm(k, y, x);\n return crypto_box_afternm(c, m, d, n, k);\n}\n\nfunction crypto_box_open(m, c, d, n, y, x) {\n var k = new Uint8Array(32);\n crypto_box_beforenm(k, y, x);\n return crypto_box_open_afternm(m, c, d, n, k);\n}\n\nvar K = [\n 0x428a2f98, 0xd728ae22, 0x71374491, 0x23ef65cd,\n 0xb5c0fbcf, 0xec4d3b2f, 0xe9b5dba5, 0x8189dbbc,\n 0x3956c25b, 0xf348b538, 0x59f111f1, 0xb605d019,\n 0x923f82a4, 0xaf194f9b, 0xab1c5ed5, 0xda6d8118,\n 0xd807aa98, 0xa3030242, 0x12835b01, 0x45706fbe,\n 0x243185be, 0x4ee4b28c, 0x550c7dc3, 0xd5ffb4e2,\n 0x72be5d74, 0xf27b896f, 0x80deb1fe, 0x3b1696b1,\n 0x9bdc06a7, 0x25c71235, 0xc19bf174, 0xcf692694,\n 0xe49b69c1, 0x9ef14ad2, 0xefbe4786, 0x384f25e3,\n 0x0fc19dc6, 0x8b8cd5b5, 0x240ca1cc, 0x77ac9c65,\n 0x2de92c6f, 0x592b0275, 0x4a7484aa, 0x6ea6e483,\n 0x5cb0a9dc, 0xbd41fbd4, 0x76f988da, 0x831153b5,\n 0x983e5152, 0xee66dfab, 0xa831c66d, 0x2db43210,\n 0xb00327c8, 0x98fb213f, 0xbf597fc7, 0xbeef0ee4,\n 0xc6e00bf3, 0x3da88fc2, 0xd5a79147, 0x930aa725,\n 0x06ca6351, 0xe003826f, 0x14292967, 0x0a0e6e70,\n 0x27b70a85, 0x46d22ffc, 0x2e1b2138, 0x5c26c926,\n 0x4d2c6dfc, 0x5ac42aed, 0x53380d13, 0x9d95b3df,\n 0x650a7354, 0x8baf63de, 0x766a0abb, 0x3c77b2a8,\n 0x81c2c92e, 0x47edaee6, 0x92722c85, 0x1482353b,\n 0xa2bfe8a1, 0x4cf10364, 0xa81a664b, 0xbc423001,\n 0xc24b8b70, 0xd0f89791, 0xc76c51a3, 0x0654be30,\n 0xd192e819, 0xd6ef5218, 0xd6990624, 0x5565a910,\n 0xf40e3585, 0x5771202a, 0x106aa070, 0x32bbd1b8,\n 0x19a4c116, 0xb8d2d0c8, 0x1e376c08, 0x5141ab53,\n 0x2748774c, 0xdf8eeb99, 0x34b0bcb5, 0xe19b48a8,\n 0x391c0cb3, 0xc5c95a63, 0x4ed8aa4a, 0xe3418acb,\n 0x5b9cca4f, 0x7763e373, 0x682e6ff3, 0xd6b2b8a3,\n 0x748f82ee, 0x5defb2fc, 0x78a5636f, 0x43172f60,\n 0x84c87814, 0xa1f0ab72, 0x8cc70208, 0x1a6439ec,\n 0x90befffa, 0x23631e28, 0xa4506ceb, 0xde82bde9,\n 0xbef9a3f7, 0xb2c67915, 0xc67178f2, 0xe372532b,\n 0xca273ece, 0xea26619c, 0xd186b8c7, 0x21c0c207,\n 0xeada7dd6, 0xcde0eb1e, 0xf57d4f7f, 0xee6ed178,\n 0x06f067aa, 0x72176fba, 0x0a637dc5, 0xa2c898a6,\n 0x113f9804, 0xbef90dae, 0x1b710b35, 0x131c471b,\n 0x28db77f5, 0x23047d84, 0x32caab7b, 0x40c72493,\n 0x3c9ebe0a, 0x15c9bebc, 0x431d67c4, 0x9c100d4c,\n 0x4cc5d4be, 0xcb3e42b6, 0x597f299c, 0xfc657e2a,\n 0x5fcb6fab, 0x3ad6faec, 0x6c44198c, 0x4a475817\n];\n\nfunction crypto_hashblocks_hl(hh, hl, m, n) {\n var wh = new Int32Array(16), wl = new Int32Array(16),\n bh0, bh1, bh2, bh3, bh4, bh5, bh6, bh7,\n bl0, bl1, bl2, bl3, bl4, bl5, bl6, bl7,\n th, tl, i, j, h, l, a, b, c, d;\n\n var ah0 = hh[0],\n ah1 = hh[1],\n ah2 = hh[2],\n ah3 = hh[3],\n ah4 = hh[4],\n ah5 = hh[5],\n ah6 = hh[6],\n ah7 = hh[7],\n\n al0 = hl[0],\n al1 = hl[1],\n al2 = hl[2],\n al3 = hl[3],\n al4 = hl[4],\n al5 = hl[5],\n al6 = hl[6],\n al7 = hl[7];\n\n var pos = 0;\n while (n >= 128) {\n for (i = 0; i < 16; i++) {\n j = 8 * i + pos;\n wh[i] = (m[j+0] << 24) | (m[j+1] << 16) | (m[j+2] << 8) | m[j+3];\n wl[i] = (m[j+4] << 24) | (m[j+5] << 16) | (m[j+6] << 8) | m[j+7];\n }\n for (i = 0; i < 80; i++) {\n bh0 = ah0;\n bh1 = ah1;\n bh2 = ah2;\n bh3 = ah3;\n bh4 = ah4;\n bh5 = ah5;\n bh6 = ah6;\n bh7 = ah7;\n\n bl0 = al0;\n bl1 = al1;\n bl2 = al2;\n bl3 = al3;\n bl4 = al4;\n bl5 = al5;\n bl6 = al6;\n bl7 = al7;\n\n // add\n h = ah7;\n l = al7;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n // Sigma1\n h = ((ah4 >>> 14) | (al4 << (32-14))) ^ ((ah4 >>> 18) | (al4 << (32-18))) ^ ((al4 >>> (41-32)) | (ah4 << (32-(41-32))));\n l = ((al4 >>> 14) | (ah4 << (32-14))) ^ ((al4 >>> 18) | (ah4 << (32-18))) ^ ((ah4 >>> (41-32)) | (al4 << (32-(41-32))));\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // Ch\n h = (ah4 & ah5) ^ (~ah4 & ah6);\n l = (al4 & al5) ^ (~al4 & al6);\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // K\n h = K[i*2];\n l = K[i*2+1];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // w\n h = wh[i%16];\n l = wl[i%16];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n th = c & 0xffff | d << 16;\n tl = a & 0xffff | b << 16;\n\n // add\n h = th;\n l = tl;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n // Sigma0\n h = ((ah0 >>> 28) | (al0 << (32-28))) ^ ((al0 >>> (34-32)) | (ah0 << (32-(34-32)))) ^ ((al0 >>> (39-32)) | (ah0 << (32-(39-32))));\n l = ((al0 >>> 28) | (ah0 << (32-28))) ^ ((ah0 >>> (34-32)) | (al0 << (32-(34-32)))) ^ ((ah0 >>> (39-32)) | (al0 << (32-(39-32))));\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // Maj\n h = (ah0 & ah1) ^ (ah0 & ah2) ^ (ah1 & ah2);\n l = (al0 & al1) ^ (al0 & al2) ^ (al1 & al2);\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n bh7 = (c & 0xffff) | (d << 16);\n bl7 = (a & 0xffff) | (b << 16);\n\n // add\n h = bh3;\n l = bl3;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = th;\n l = tl;\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n bh3 = (c & 0xffff) | (d << 16);\n bl3 = (a & 0xffff) | (b << 16);\n\n ah1 = bh0;\n ah2 = bh1;\n ah3 = bh2;\n ah4 = bh3;\n ah5 = bh4;\n ah6 = bh5;\n ah7 = bh6;\n ah0 = bh7;\n\n al1 = bl0;\n al2 = bl1;\n al3 = bl2;\n al4 = bl3;\n al5 = bl4;\n al6 = bl5;\n al7 = bl6;\n al0 = bl7;\n\n if (i%16 === 15) {\n for (j = 0; j < 16; j++) {\n // add\n h = wh[j];\n l = wl[j];\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = wh[(j+9)%16];\n l = wl[(j+9)%16];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // sigma0\n th = wh[(j+1)%16];\n tl = wl[(j+1)%16];\n h = ((th >>> 1) | (tl << (32-1))) ^ ((th >>> 8) | (tl << (32-8))) ^ (th >>> 7);\n l = ((tl >>> 1) | (th << (32-1))) ^ ((tl >>> 8) | (th << (32-8))) ^ ((tl >>> 7) | (th << (32-7)));\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n // sigma1\n th = wh[(j+14)%16];\n tl = wl[(j+14)%16];\n h = ((th >>> 19) | (tl << (32-19))) ^ ((tl >>> (61-32)) | (th << (32-(61-32)))) ^ (th >>> 6);\n l = ((tl >>> 19) | (th << (32-19))) ^ ((th >>> (61-32)) | (tl << (32-(61-32)))) ^ ((tl >>> 6) | (th << (32-6)));\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n wh[j] = (c & 0xffff) | (d << 16);\n wl[j] = (a & 0xffff) | (b << 16);\n }\n }\n }\n\n // add\n h = ah0;\n l = al0;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[0];\n l = hl[0];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[0] = ah0 = (c & 0xffff) | (d << 16);\n hl[0] = al0 = (a & 0xffff) | (b << 16);\n\n h = ah1;\n l = al1;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[1];\n l = hl[1];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[1] = ah1 = (c & 0xffff) | (d << 16);\n hl[1] = al1 = (a & 0xffff) | (b << 16);\n\n h = ah2;\n l = al2;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[2];\n l = hl[2];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[2] = ah2 = (c & 0xffff) | (d << 16);\n hl[2] = al2 = (a & 0xffff) | (b << 16);\n\n h = ah3;\n l = al3;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[3];\n l = hl[3];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[3] = ah3 = (c & 0xffff) | (d << 16);\n hl[3] = al3 = (a & 0xffff) | (b << 16);\n\n h = ah4;\n l = al4;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[4];\n l = hl[4];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[4] = ah4 = (c & 0xffff) | (d << 16);\n hl[4] = al4 = (a & 0xffff) | (b << 16);\n\n h = ah5;\n l = al5;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[5];\n l = hl[5];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[5] = ah5 = (c & 0xffff) | (d << 16);\n hl[5] = al5 = (a & 0xffff) | (b << 16);\n\n h = ah6;\n l = al6;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[6];\n l = hl[6];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[6] = ah6 = (c & 0xffff) | (d << 16);\n hl[6] = al6 = (a & 0xffff) | (b << 16);\n\n h = ah7;\n l = al7;\n\n a = l & 0xffff; b = l >>> 16;\n c = h & 0xffff; d = h >>> 16;\n\n h = hh[7];\n l = hl[7];\n\n a += l & 0xffff; b += l >>> 16;\n c += h & 0xffff; d += h >>> 16;\n\n b += a >>> 16;\n c += b >>> 16;\n d += c >>> 16;\n\n hh[7] = ah7 = (c & 0xffff) | (d << 16);\n hl[7] = al7 = (a & 0xffff) | (b << 16);\n\n pos += 128;\n n -= 128;\n }\n\n return n;\n}\n\nfunction crypto_hash(out, m, n) {\n var hh = new Int32Array(8),\n hl = new Int32Array(8),\n x = new Uint8Array(256),\n i, b = n;\n\n hh[0] = 0x6a09e667;\n hh[1] = 0xbb67ae85;\n hh[2] = 0x3c6ef372;\n hh[3] = 0xa54ff53a;\n hh[4] = 0x510e527f;\n hh[5] = 0x9b05688c;\n hh[6] = 0x1f83d9ab;\n hh[7] = 0x5be0cd19;\n\n hl[0] = 0xf3bcc908;\n hl[1] = 0x84caa73b;\n hl[2] = 0xfe94f82b;\n hl[3] = 0x5f1d36f1;\n hl[4] = 0xade682d1;\n hl[5] = 0x2b3e6c1f;\n hl[6] = 0xfb41bd6b;\n hl[7] = 0x137e2179;\n\n crypto_hashblocks_hl(hh, hl, m, n);\n n %= 128;\n\n for (i = 0; i < n; i++) x[i] = m[b-n+i];\n x[n] = 128;\n\n n = 256-128*(n<112?1:0);\n x[n-9] = 0;\n ts64(x, n-8, (b / 0x20000000) | 0, b << 3);\n crypto_hashblocks_hl(hh, hl, x, n);\n\n for (i = 0; i < 8; i++) ts64(out, 8*i, hh[i], hl[i]);\n\n return 0;\n}\n\nfunction add(p, q) {\n var a = gf(), b = gf(), c = gf(),\n d = gf(), e = gf(), f = gf(),\n g = gf(), h = gf(), t = gf();\n\n Z(a, p[1], p[0]);\n Z(t, q[1], q[0]);\n M(a, a, t);\n A(b, p[0], p[1]);\n A(t, q[0], q[1]);\n M(b, b, t);\n M(c, p[3], q[3]);\n M(c, c, D2);\n M(d, p[2], q[2]);\n A(d, d, d);\n Z(e, b, a);\n Z(f, d, c);\n A(g, d, c);\n A(h, b, a);\n\n M(p[0], e, f);\n M(p[1], h, g);\n M(p[2], g, f);\n M(p[3], e, h);\n}\n\nfunction cswap(p, q, b) {\n var i;\n for (i = 0; i < 4; i++) {\n sel25519(p[i], q[i], b);\n }\n}\n\nfunction pack(r, p) {\n var tx = gf(), ty = gf(), zi = gf();\n inv25519(zi, p[2]);\n M(tx, p[0], zi);\n M(ty, p[1], zi);\n pack25519(r, ty);\n r[31] ^= par25519(tx) << 7;\n}\n\nfunction scalarmult(p, q, s) {\n var b, i;\n set25519(p[0], gf0);\n set25519(p[1], gf1);\n set25519(p[2], gf1);\n set25519(p[3], gf0);\n for (i = 255; i >= 0; --i) {\n b = (s[(i/8)|0] >> (i&7)) & 1;\n cswap(p, q, b);\n add(q, p);\n add(p, p);\n cswap(p, q, b);\n }\n}\n\nfunction scalarbase(p, s) {\n var q = [gf(), gf(), gf(), gf()];\n set25519(q[0], X);\n set25519(q[1], Y);\n set25519(q[2], gf1);\n M(q[3], X, Y);\n scalarmult(p, q, s);\n}\n\nfunction crypto_sign_keypair(pk, sk, seeded) {\n var d = new Uint8Array(64);\n var p = [gf(), gf(), gf(), gf()];\n var i;\n\n if (!seeded) randombytes(sk, 32);\n crypto_hash(d, sk, 32);\n d[0] &= 248;\n d[31] &= 127;\n d[31] |= 64;\n\n scalarbase(p, d);\n pack(pk, p);\n\n for (i = 0; i < 32; i++) sk[i+32] = pk[i];\n return 0;\n}\n\nvar L = new Float64Array([0xed, 0xd3, 0xf5, 0x5c, 0x1a, 0x63, 0x12, 0x58, 0xd6, 0x9c, 0xf7, 0xa2, 0xde, 0xf9, 0xde, 0x14, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x10]);\n\nfunction modL(r, x) {\n var carry, i, j, k;\n for (i = 63; i >= 32; --i) {\n carry = 0;\n for (j = i - 32, k = i - 12; j < k; ++j) {\n x[j] += carry - 16 * x[i] * L[j - (i - 32)];\n carry = Math.floor((x[j] + 128) / 256);\n x[j] -= carry * 256;\n }\n x[j] += carry;\n x[i] = 0;\n }\n carry = 0;\n for (j = 0; j < 32; j++) {\n x[j] += carry - (x[31] >> 4) * L[j];\n carry = x[j] >> 8;\n x[j] &= 255;\n }\n for (j = 0; j < 32; j++) x[j] -= carry * L[j];\n for (i = 0; i < 32; i++) {\n x[i+1] += x[i] >> 8;\n r[i] = x[i] & 255;\n }\n}\n\nfunction reduce(r) {\n var x = new Float64Array(64), i;\n for (i = 0; i < 64; i++) x[i] = r[i];\n for (i = 0; i < 64; i++) r[i] = 0;\n modL(r, x);\n}\n\n// Note: difference from C - smlen returned, not passed as argument.\nfunction crypto_sign(sm, m, n, sk) {\n var d = new Uint8Array(64), h = new Uint8Array(64), r = new Uint8Array(64);\n var i, j, x = new Float64Array(64);\n var p = [gf(), gf(), gf(), gf()];\n\n crypto_hash(d, sk, 32);\n d[0] &= 248;\n d[31] &= 127;\n d[31] |= 64;\n\n var smlen = n + 64;\n for (i = 0; i < n; i++) sm[64 + i] = m[i];\n for (i = 0; i < 32; i++) sm[32 + i] = d[32 + i];\n\n crypto_hash(r, sm.subarray(32), n+32);\n reduce(r);\n scalarbase(p, r);\n pack(sm, p);\n\n for (i = 32; i < 64; i++) sm[i] = sk[i];\n crypto_hash(h, sm, n + 64);\n reduce(h);\n\n for (i = 0; i < 64; i++) x[i] = 0;\n for (i = 0; i < 32; i++) x[i] = r[i];\n for (i = 0; i < 32; i++) {\n for (j = 0; j < 32; j++) {\n x[i+j] += h[i] * d[j];\n }\n }\n\n modL(sm.subarray(32), x);\n return smlen;\n}\n\nfunction unpackneg(r, p) {\n var t = gf(), chk = gf(), num = gf(),\n den = gf(), den2 = gf(), den4 = gf(),\n den6 = gf();\n\n set25519(r[2], gf1);\n unpack25519(r[1], p);\n S(num, r[1]);\n M(den, num, D);\n Z(num, num, r[2]);\n A(den, r[2], den);\n\n S(den2, den);\n S(den4, den2);\n M(den6, den4, den2);\n M(t, den6, num);\n M(t, t, den);\n\n pow2523(t, t);\n M(t, t, num);\n M(t, t, den);\n M(t, t, den);\n M(r[0], t, den);\n\n S(chk, r[0]);\n M(chk, chk, den);\n if (neq25519(chk, num)) M(r[0], r[0], I);\n\n S(chk, r[0]);\n M(chk, chk, den);\n if (neq25519(chk, num)) return -1;\n\n if (par25519(r[0]) === (p[31]>>7)) Z(r[0], gf0, r[0]);\n\n M(r[3], r[0], r[1]);\n return 0;\n}\n\nfunction crypto_sign_open(m, sm, n, pk) {\n var i;\n var t = new Uint8Array(32), h = new Uint8Array(64);\n var p = [gf(), gf(), gf(), gf()],\n q = [gf(), gf(), gf(), gf()];\n\n if (n < 64) return -1;\n\n if (unpackneg(q, pk)) return -1;\n\n for (i = 0; i < n; i++) m[i] = sm[i];\n for (i = 0; i < 32; i++) m[i+32] = pk[i];\n crypto_hash(h, m, n);\n reduce(h);\n scalarmult(p, q, h);\n\n scalarbase(q, sm.subarray(32));\n add(p, q);\n pack(t, p);\n\n n -= 64;\n if (crypto_verify_32(sm, 0, t, 0)) {\n for (i = 0; i < n; i++) m[i] = 0;\n return -1;\n }\n\n for (i = 0; i < n; i++) m[i] = sm[i + 64];\n return n;\n}\n\nvar crypto_secretbox_KEYBYTES = 32,\n crypto_secretbox_NONCEBYTES = 24,\n crypto_secretbox_ZEROBYTES = 32,\n crypto_secretbox_BOXZEROBYTES = 16,\n crypto_scalarmult_BYTES = 32,\n crypto_scalarmult_SCALARBYTES = 32,\n crypto_box_PUBLICKEYBYTES = 32,\n crypto_box_SECRETKEYBYTES = 32,\n crypto_box_BEFORENMBYTES = 32,\n crypto_box_NONCEBYTES = crypto_secretbox_NONCEBYTES,\n crypto_box_ZEROBYTES = crypto_secretbox_ZEROBYTES,\n crypto_box_BOXZEROBYTES = crypto_secretbox_BOXZEROBYTES,\n crypto_sign_BYTES = 64,\n crypto_sign_PUBLICKEYBYTES = 32,\n crypto_sign_SECRETKEYBYTES = 64,\n crypto_sign_SEEDBYTES = 32,\n crypto_hash_BYTES = 64;\n\nnacl.lowlevel = {\n crypto_core_hsalsa20: crypto_core_hsalsa20,\n crypto_stream_xor: crypto_stream_xor,\n crypto_stream: crypto_stream,\n crypto_stream_salsa20_xor: crypto_stream_salsa20_xor,\n crypto_stream_salsa20: crypto_stream_salsa20,\n crypto_onetimeauth: crypto_onetimeauth,\n crypto_onetimeauth_verify: crypto_onetimeauth_verify,\n crypto_verify_16: crypto_verify_16,\n crypto_verify_32: crypto_verify_32,\n crypto_secretbox: crypto_secretbox,\n crypto_secretbox_open: crypto_secretbox_open,\n crypto_scalarmult: crypto_scalarmult,\n crypto_scalarmult_base: crypto_scalarmult_base,\n crypto_box_beforenm: crypto_box_beforenm,\n crypto_box_afternm: crypto_box_afternm,\n crypto_box: crypto_box,\n crypto_box_open: crypto_box_open,\n crypto_box_keypair: crypto_box_keypair,\n crypto_hash: crypto_hash,\n crypto_sign: crypto_sign,\n crypto_sign_keypair: crypto_sign_keypair,\n crypto_sign_open: crypto_sign_open,\n\n crypto_secretbox_KEYBYTES: crypto_secretbox_KEYBYTES,\n crypto_secretbox_NONCEBYTES: crypto_secretbox_NONCEBYTES,\n crypto_secretbox_ZEROBYTES: crypto_secretbox_ZEROBYTES,\n crypto_secretbox_BOXZEROBYTES: crypto_secretbox_BOXZEROBYTES,\n crypto_scalarmult_BYTES: crypto_scalarmult_BYTES,\n crypto_scalarmult_SCALARBYTES: crypto_scalarmult_SCALARBYTES,\n crypto_box_PUBLICKEYBYTES: crypto_box_PUBLICKEYBYTES,\n crypto_box_SECRETKEYBYTES: crypto_box_SECRETKEYBYTES,\n crypto_box_BEFORENMBYTES: crypto_box_BEFORENMBYTES,\n crypto_box_NONCEBYTES: crypto_box_NONCEBYTES,\n crypto_box_ZEROBYTES: crypto_box_ZEROBYTES,\n crypto_box_BOXZEROBYTES: crypto_box_BOXZEROBYTES,\n crypto_sign_BYTES: crypto_sign_BYTES,\n crypto_sign_PUBLICKEYBYTES: crypto_sign_PUBLICKEYBYTES,\n crypto_sign_SECRETKEYBYTES: crypto_sign_SECRETKEYBYTES,\n crypto_sign_SEEDBYTES: crypto_sign_SEEDBYTES,\n crypto_hash_BYTES: crypto_hash_BYTES,\n\n gf: gf,\n D: D,\n L: L,\n pack25519: pack25519,\n unpack25519: unpack25519,\n M: M,\n A: A,\n S: S,\n Z: Z,\n pow2523: pow2523,\n add: add,\n set25519: set25519,\n modL: modL,\n scalarmult: scalarmult,\n scalarbase: scalarbase,\n};\n\n/* High-level API */\n\nfunction checkLengths(k, n) {\n if (k.length !== crypto_secretbox_KEYBYTES) throw new Error('bad key size');\n if (n.length !== crypto_secretbox_NONCEBYTES) throw new Error('bad nonce size');\n}\n\nfunction checkBoxLengths(pk, sk) {\n if (pk.length !== crypto_box_PUBLICKEYBYTES) throw new Error('bad public key size');\n if (sk.length !== crypto_box_SECRETKEYBYTES) throw new Error('bad secret key size');\n}\n\nfunction checkArrayTypes() {\n for (var i = 0; i < arguments.length; i++) {\n if (!(arguments[i] instanceof Uint8Array))\n throw new TypeError('unexpected type, use Uint8Array');\n }\n}\n\nfunction cleanup(arr) {\n for (var i = 0; i < arr.length; i++) arr[i] = 0;\n}\n\nnacl.randomBytes = function(n) {\n var b = new Uint8Array(n);\n randombytes(b, n);\n return b;\n};\n\nnacl.secretbox = function(msg, nonce, key) {\n checkArrayTypes(msg, nonce, key);\n checkLengths(key, nonce);\n var m = new Uint8Array(crypto_secretbox_ZEROBYTES + msg.length);\n var c = new Uint8Array(m.length);\n for (var i = 0; i < msg.length; i++) m[i+crypto_secretbox_ZEROBYTES] = msg[i];\n crypto_secretbox(c, m, m.length, nonce, key);\n return c.subarray(crypto_secretbox_BOXZEROBYTES);\n};\n\nnacl.secretbox.open = function(box, nonce, key) {\n checkArrayTypes(box, nonce, key);\n checkLengths(key, nonce);\n var c = new Uint8Array(crypto_secretbox_BOXZEROBYTES + box.length);\n var m = new Uint8Array(c.length);\n for (var i = 0; i < box.length; i++) c[i+crypto_secretbox_BOXZEROBYTES] = box[i];\n if (c.length < 32) return null;\n if (crypto_secretbox_open(m, c, c.length, nonce, key) !== 0) return null;\n return m.subarray(crypto_secretbox_ZEROBYTES);\n};\n\nnacl.secretbox.keyLength = crypto_secretbox_KEYBYTES;\nnacl.secretbox.nonceLength = crypto_secretbox_NONCEBYTES;\nnacl.secretbox.overheadLength = crypto_secretbox_BOXZEROBYTES;\n\nnacl.scalarMult = function(n, p) {\n checkArrayTypes(n, p);\n if (n.length !== crypto_scalarmult_SCALARBYTES) throw new Error('bad n size');\n if (p.length !== crypto_scalarmult_BYTES) throw new Error('bad p size');\n var q = new Uint8Array(crypto_scalarmult_BYTES);\n crypto_scalarmult(q, n, p);\n return q;\n};\n\nnacl.scalarMult.base = function(n) {\n checkArrayTypes(n);\n if (n.length !== crypto_scalarmult_SCALARBYTES) throw new Error('bad n size');\n var q = new Uint8Array(crypto_scalarmult_BYTES);\n crypto_scalarmult_base(q, n);\n return q;\n};\n\nnacl.scalarMult.scalarLength = crypto_scalarmult_SCALARBYTES;\nnacl.scalarMult.groupElementLength = crypto_scalarmult_BYTES;\n\nnacl.box = function(msg, nonce, publicKey, secretKey) {\n var k = nacl.box.before(publicKey, secretKey);\n return nacl.secretbox(msg, nonce, k);\n};\n\nnacl.box.before = function(publicKey, secretKey) {\n checkArrayTypes(publicKey, secretKey);\n checkBoxLengths(publicKey, secretKey);\n var k = new Uint8Array(crypto_box_BEFORENMBYTES);\n crypto_box_beforenm(k, publicKey, secretKey);\n return k;\n};\n\nnacl.box.after = nacl.secretbox;\n\nnacl.box.open = function(msg, nonce, publicKey, secretKey) {\n var k = nacl.box.before(publicKey, secretKey);\n return nacl.secretbox.open(msg, nonce, k);\n};\n\nnacl.box.open.after = nacl.secretbox.open;\n\nnacl.box.keyPair = function() {\n var pk = new Uint8Array(crypto_box_PUBLICKEYBYTES);\n var sk = new Uint8Array(crypto_box_SECRETKEYBYTES);\n crypto_box_keypair(pk, sk);\n return {publicKey: pk, secretKey: sk};\n};\n\nnacl.box.keyPair.fromSecretKey = function(secretKey) {\n checkArrayTypes(secretKey);\n if (secretKey.length !== crypto_box_SECRETKEYBYTES)\n throw new Error('bad secret key size');\n var pk = new Uint8Array(crypto_box_PUBLICKEYBYTES);\n crypto_scalarmult_base(pk, secretKey);\n return {publicKey: pk, secretKey: new Uint8Array(secretKey)};\n};\n\nnacl.box.publicKeyLength = crypto_box_PUBLICKEYBYTES;\nnacl.box.secretKeyLength = crypto_box_SECRETKEYBYTES;\nnacl.box.sharedKeyLength = crypto_box_BEFORENMBYTES;\nnacl.box.nonceLength = crypto_box_NONCEBYTES;\nnacl.box.overheadLength = nacl.secretbox.overheadLength;\n\nnacl.sign = function(msg, secretKey) {\n checkArrayTypes(msg, secretKey);\n if (secretKey.length !== crypto_sign_SECRETKEYBYTES)\n throw new Error('bad secret key size');\n var signedMsg = new Uint8Array(crypto_sign_BYTES+msg.length);\n crypto_sign(signedMsg, msg, msg.length, secretKey);\n return signedMsg;\n};\n\nnacl.sign.open = function(signedMsg, publicKey) {\n checkArrayTypes(signedMsg, publicKey);\n if (publicKey.length !== crypto_sign_PUBLICKEYBYTES)\n throw new Error('bad public key size');\n var tmp = new Uint8Array(signedMsg.length);\n var mlen = crypto_sign_open(tmp, signedMsg, signedMsg.length, publicKey);\n if (mlen < 0) return null;\n var m = new Uint8Array(mlen);\n for (var i = 0; i < m.length; i++) m[i] = tmp[i];\n return m;\n};\n\nnacl.sign.detached = function(msg, secretKey) {\n var signedMsg = nacl.sign(msg, secretKey);\n var sig = new Uint8Array(crypto_sign_BYTES);\n for (var i = 0; i < sig.length; i++) sig[i] = signedMsg[i];\n return sig;\n};\n\nnacl.sign.detached.verify = function(msg, sig, publicKey) {\n checkArrayTypes(msg, sig, publicKey);\n if (sig.length !== crypto_sign_BYTES)\n throw new Error('bad signature size');\n if (publicKey.length !== crypto_sign_PUBLICKEYBYTES)\n throw new Error('bad public key size');\n var sm = new Uint8Array(crypto_sign_BYTES + msg.length);\n var m = new Uint8Array(crypto_sign_BYTES + msg.length);\n var i;\n for (i = 0; i < crypto_sign_BYTES; i++) sm[i] = sig[i];\n for (i = 0; i < msg.length; i++) sm[i+crypto_sign_BYTES] = msg[i];\n return (crypto_sign_open(m, sm, sm.length, publicKey) >= 0);\n};\n\nnacl.sign.keyPair = function() {\n var pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);\n var sk = new Uint8Array(crypto_sign_SECRETKEYBYTES);\n crypto_sign_keypair(pk, sk);\n return {publicKey: pk, secretKey: sk};\n};\n\nnacl.sign.keyPair.fromSecretKey = function(secretKey) {\n checkArrayTypes(secretKey);\n if (secretKey.length !== crypto_sign_SECRETKEYBYTES)\n throw new Error('bad secret key size');\n var pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);\n for (var i = 0; i < pk.length; i++) pk[i] = secretKey[32+i];\n return {publicKey: pk, secretKey: new Uint8Array(secretKey)};\n};\n\nnacl.sign.keyPair.fromSeed = function(seed) {\n checkArrayTypes(seed);\n if (seed.length !== crypto_sign_SEEDBYTES)\n throw new Error('bad seed size');\n var pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);\n var sk = new Uint8Array(crypto_sign_SECRETKEYBYTES);\n for (var i = 0; i < 32; i++) sk[i] = seed[i];\n crypto_sign_keypair(pk, sk, true);\n return {publicKey: pk, secretKey: sk};\n};\n\nnacl.sign.publicKeyLength = crypto_sign_PUBLICKEYBYTES;\nnacl.sign.secretKeyLength = crypto_sign_SECRETKEYBYTES;\nnacl.sign.seedLength = crypto_sign_SEEDBYTES;\nnacl.sign.signatureLength = crypto_sign_BYTES;\n\nnacl.hash = function(msg) {\n checkArrayTypes(msg);\n var h = new Uint8Array(crypto_hash_BYTES);\n crypto_hash(h, msg, msg.length);\n return h;\n};\n\nnacl.hash.hashLength = crypto_hash_BYTES;\n\nnacl.verify = function(x, y) {\n checkArrayTypes(x, y);\n // Zero length arguments are considered not equal.\n if (x.length === 0 || y.length === 0) return false;\n if (x.length !== y.length) return false;\n return (vn(x, 0, y, 0, x.length) === 0) ? true : false;\n};\n\nnacl.setPRNG = function(fn) {\n randombytes = fn;\n};\n\n(function() {\n // Initialize PRNG if environment provides CSPRNG.\n // If not, methods calling randombytes will throw.\n var crypto = typeof self !== 'undefined' ? (self.crypto || self.msCrypto) : null;\n if (crypto && crypto.getRandomValues) {\n // Browsers.\n var QUOTA = 65536;\n nacl.setPRNG(function(x, n) {\n var i, v = new Uint8Array(n);\n for (i = 0; i < n; i += QUOTA) {\n crypto.getRandomValues(v.subarray(i, i + Math.min(n - i, QUOTA)));\n }\n for (i = 0; i < n; i++) x[i] = v[i];\n cleanup(v);\n });\n } else if (typeof require !== 'undefined') {\n // Node.js.\n crypto = require('crypto');\n if (crypto && crypto.randomBytes) {\n nacl.setPRNG(function(x, n) {\n var i, v = crypto.randomBytes(n);\n for (i = 0; i < n; i++) x[i] = v[i];\n cleanup(v);\n });\n }\n }\n})();\n\n})(typeof module !== 'undefined' && module.exports ? module.exports : (self.nacl = self.nacl || {}));\n","module.exports = require('./pusher-with-encryption').default;\n","export default function encode(s: any): string {\n return btoa(utob(s));\n}\n\nvar fromCharCode = String.fromCharCode;\n\nvar b64chars =\n 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';\nvar b64tab = {};\n\nfor (var i = 0, l = b64chars.length; i < l; i++) {\n b64tab[b64chars.charAt(i)] = i;\n}\n\nvar cb_utob = function(c) {\n var cc = c.charCodeAt(0);\n return cc < 0x80\n ? c\n : cc < 0x800\n ? fromCharCode(0xc0 | (cc >>> 6)) + fromCharCode(0x80 | (cc & 0x3f))\n : fromCharCode(0xe0 | ((cc >>> 12) & 0x0f)) +\n fromCharCode(0x80 | ((cc >>> 6) & 0x3f)) +\n fromCharCode(0x80 | (cc & 0x3f));\n};\n\nvar utob = function(u) {\n return u.replace(/[^\\x00-\\x7F]/g, cb_utob);\n};\n\nvar cb_encode = function(ccc) {\n var padlen = [0, 2, 1][ccc.length % 3];\n var ord =\n (ccc.charCodeAt(0) << 16) |\n ((ccc.length > 1 ? ccc.charCodeAt(1) : 0) << 8) |\n (ccc.length > 2 ? ccc.charCodeAt(2) : 0);\n var chars = [\n b64chars.charAt(ord >>> 18),\n b64chars.charAt((ord >>> 12) & 63),\n padlen >= 2 ? '=' : b64chars.charAt((ord >>> 6) & 63),\n padlen >= 1 ? '=' : b64chars.charAt(ord & 63)\n ];\n return chars.join('');\n};\n\nvar btoa =\n global.btoa ||\n function(b) {\n return b.replace(/[\\s\\S]{1,3}/g, cb_encode);\n };\n","import TimedCallback from './timed_callback';\nimport { Delay, Scheduler, Canceller } from './scheduling';\n\nabstract class Timer {\n protected clear: Canceller;\n protected timer: number | void;\n\n constructor(\n set: Scheduler,\n clear: Canceller,\n delay: Delay,\n callback: TimedCallback\n ) {\n this.clear = clear;\n this.timer = set(() => {\n if (this.timer) {\n this.timer = callback(this.timer);\n }\n }, delay);\n }\n\n /** Returns whether the timer is still running.\n *\n * @return {Boolean}\n */\n isRunning(): boolean {\n return this.timer !== null;\n }\n\n /** Aborts a timer when it's running. */\n ensureAborted() {\n if (this.timer) {\n this.clear(this.timer);\n this.timer = null;\n }\n }\n}\n\nexport default Timer;\n","import Timer from './abstract_timer';\nimport TimedCallback from './timed_callback';\nimport { Delay } from './scheduling';\n\n// We need to bind clear functions this way to avoid exceptions on IE8\nfunction clearTimeout(timer) {\n global.clearTimeout(timer);\n}\nfunction clearInterval(timer) {\n global.clearInterval(timer);\n}\n\n/** Cross-browser compatible one-off timer abstraction.\n *\n * @param {Number} delay\n * @param {Function} callback\n */\nexport class OneOffTimer extends Timer {\n constructor(delay: Delay, callback: TimedCallback) {\n super(setTimeout, clearTimeout, delay, function(timer) {\n callback();\n return null;\n });\n }\n}\n\n/** Cross-browser compatible periodic timer abstraction.\n *\n * @param {Number} delay\n * @param {Function} callback\n */\nexport class PeriodicTimer extends Timer {\n constructor(delay: Delay, callback: TimedCallback) {\n super(setInterval, clearInterval, delay, function(timer) {\n callback();\n return timer;\n });\n }\n}\n","import * as Collections from './utils/collections';\nimport TimedCallback from './utils/timers/timed_callback';\nimport { OneOffTimer, PeriodicTimer } from './utils/timers';\n\nvar Util = {\n now(): number {\n if (Date.now) {\n return Date.now();\n } else {\n return new Date().valueOf();\n }\n },\n\n defer(callback: TimedCallback): OneOffTimer {\n return new OneOffTimer(0, callback);\n },\n\n /** Builds a function that will proxy a method call to its first argument.\n *\n * Allows partial application of arguments, so additional arguments are\n * prepended to the argument list.\n *\n * @param {String} name method name\n * @return {Function} proxy function\n */\n method(name: string, ...args: any[]): Function {\n var boundArguments = Array.prototype.slice.call(arguments, 1);\n return function(object) {\n return object[name].apply(object, boundArguments.concat(arguments));\n };\n }\n};\n\nexport default Util;\n","import base64encode from '../base64';\nimport Util from '../util';\n\n/** Merges multiple objects into the target argument.\n *\n * For properties that are plain Objects, performs a deep-merge. For the\n * rest it just copies the value of the property.\n *\n * To extend prototypes use it as following:\n * Pusher.Util.extend(Target.prototype, Base.prototype)\n *\n * You can also use it to merge objects without altering them:\n * Pusher.Util.extend({}, object1, object2)\n *\n * @param {Object} target\n * @return {Object} the target argument\n */\nexport function extend(target: any, ...sources: any[]): T {\n for (var i = 0; i < sources.length; i++) {\n var extensions = sources[i];\n for (var property in extensions) {\n if (\n extensions[property] &&\n extensions[property].constructor &&\n extensions[property].constructor === Object\n ) {\n target[property] = extend(target[property] || {}, extensions[property]);\n } else {\n target[property] = extensions[property];\n }\n }\n }\n return target;\n}\n\nexport function stringify(): string {\n var m = ['Pusher'];\n for (var i = 0; i < arguments.length; i++) {\n if (typeof arguments[i] === 'string') {\n m.push(arguments[i]);\n } else {\n m.push(safeJSONStringify(arguments[i]));\n }\n }\n return m.join(' : ');\n}\n\nexport function arrayIndexOf(array: any[], item: any): number {\n // MSIE doesn't have array.indexOf\n var nativeIndexOf = Array.prototype.indexOf;\n if (array === null) {\n return -1;\n }\n if (nativeIndexOf && array.indexOf === nativeIndexOf) {\n return array.indexOf(item);\n }\n for (var i = 0, l = array.length; i < l; i++) {\n if (array[i] === item) {\n return i;\n }\n }\n return -1;\n}\n\n/** Applies a function f to all properties of an object.\n *\n * Function f gets 3 arguments passed:\n * - element from the object\n * - key of the element\n * - reference to the object\n *\n * @param {Object} object\n * @param {Function} f\n */\nexport function objectApply(object: any, f: Function) {\n for (var key in object) {\n if (Object.prototype.hasOwnProperty.call(object, key)) {\n f(object[key], key, object);\n }\n }\n}\n\n/** Return a list of objects own proerty keys\n *\n * @param {Object} object\n * @returns {Array}\n */\nexport function keys(object: any): string[] {\n var keys = [];\n objectApply(object, function(_, key) {\n keys.push(key);\n });\n return keys;\n}\n\n/** Return a list of object's own property values\n *\n * @param {Object} object\n * @returns {Array}\n */\nexport function values(object: any): any[] {\n var values = [];\n objectApply(object, function(value) {\n values.push(value);\n });\n return values;\n}\n\n/** Applies a function f to all elements of an array.\n *\n * Function f gets 3 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function apply(array: any[], f: Function, context?: any) {\n for (var i = 0; i < array.length; i++) {\n f.call(context || global, array[i], i, array);\n }\n}\n\n/** Maps all elements of the array and returns the result.\n *\n * Function f gets 4 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n * - reference to the destination array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function map(array: any[], f: Function): any[] {\n var result = [];\n for (var i = 0; i < array.length; i++) {\n result.push(f(array[i], i, array, result));\n }\n return result;\n}\n\n/** Maps all elements of the object and returns the result.\n *\n * Function f gets 4 arguments passed:\n * - element from the object\n * - key of the element\n * - reference to the source object\n * - reference to the destination object\n *\n * @param {Object} object\n * @param {Function} f\n */\nexport function mapObject(object: any, f: Function): any {\n var result = {};\n objectApply(object, function(value, key) {\n result[key] = f(value);\n });\n return result;\n}\n\n/** Filters elements of the array using a test function.\n *\n * Function test gets 4 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n * - reference to the destination array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function filter(array: any[], test: Function): any[] {\n test =\n test ||\n function(value) {\n return !!value;\n };\n\n var result = [];\n for (var i = 0; i < array.length; i++) {\n if (test(array[i], i, array, result)) {\n result.push(array[i]);\n }\n }\n return result;\n}\n\n/** Filters properties of the object using a test function.\n *\n * Function test gets 4 arguments passed:\n * - element from the object\n * - key of the element\n * - reference to the source object\n * - reference to the destination object\n *\n * @param {Object} object\n * @param {Function} f\n */\nexport function filterObject(object: Object, test: Function) {\n var result = {};\n objectApply(object, function(value, key) {\n if ((test && test(value, key, object, result)) || Boolean(value)) {\n result[key] = value;\n }\n });\n return result;\n}\n\n/** Flattens an object into a two-dimensional array.\n *\n * @param {Object} object\n * @return {Array} resulting array of [key, value] pairs\n */\nexport function flatten(object: Object): any[] {\n var result = [];\n objectApply(object, function(value, key) {\n result.push([key, value]);\n });\n return result;\n}\n\n/** Checks whether any element of the array passes the test.\n *\n * Function test gets 3 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function any(array: any[], test: Function): boolean {\n for (var i = 0; i < array.length; i++) {\n if (test(array[i], i, array)) {\n return true;\n }\n }\n return false;\n}\n\n/** Checks whether all elements of the array pass the test.\n *\n * Function test gets 3 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function all(array: any[], test: Function): boolean {\n for (var i = 0; i < array.length; i++) {\n if (!test(array[i], i, array)) {\n return false;\n }\n }\n return true;\n}\n\nexport function encodeParamsObject(data): string {\n return mapObject(data, function(value) {\n if (typeof value === 'object') {\n value = safeJSONStringify(value);\n }\n return encodeURIComponent(base64encode(value.toString()));\n });\n}\n\nexport function buildQueryString(data: any): string {\n var params = filterObject(data, function(value) {\n return value !== undefined;\n });\n\n var query = map(\n flatten(encodeParamsObject(params)),\n Util.method('join', '=')\n ).join('&');\n\n return query;\n}\n\n/**\n * See https://github.com/douglascrockford/JSON-js/blob/master/cycle.js\n *\n * Remove circular references from an object. Required for JSON.stringify in\n * React Native, which tends to blow up a lot.\n *\n * @param {any} object\n * @return {any} Decycled object\n */\nexport function decycleObject(object: any): any {\n var objects = [],\n paths = [];\n\n return (function derez(value, path) {\n var i, name, nu;\n\n switch (typeof value) {\n case 'object':\n if (!value) {\n return null;\n }\n for (i = 0; i < objects.length; i += 1) {\n if (objects[i] === value) {\n return { $ref: paths[i] };\n }\n }\n\n objects.push(value);\n paths.push(path);\n\n if (Object.prototype.toString.apply(value) === '[object Array]') {\n nu = [];\n for (i = 0; i < value.length; i += 1) {\n nu[i] = derez(value[i], path + '[' + i + ']');\n }\n } else {\n nu = {};\n for (name in value) {\n if (Object.prototype.hasOwnProperty.call(value, name)) {\n nu[name] = derez(\n value[name],\n path + '[' + JSON.stringify(name) + ']'\n );\n }\n }\n }\n return nu;\n case 'number':\n case 'string':\n case 'boolean':\n return value;\n }\n })(object, '$');\n}\n\n/**\n * Provides a cross-browser and cross-platform way to safely stringify objects\n * into JSON. This is particularly necessary for ReactNative, where circular JSON\n * structures throw an exception.\n *\n * @param {any} source The object to stringify\n * @return {string} The serialized output.\n */\nexport function safeJSONStringify(source: any): string {\n try {\n return JSON.stringify(source);\n } catch (e) {\n return JSON.stringify(decycleObject(source));\n }\n}\n","import {\n ChannelAuthorizationOptions,\n UserAuthenticationOptions\n} from './auth/options';\nimport { AuthTransport } from './config';\n\nexport interface DefaultConfig {\n VERSION: string;\n PROTOCOL: number;\n wsPort: number;\n wssPort: number;\n wsPath: string;\n httpHost: string;\n httpPort: number;\n httpsPort: number;\n httpPath: string;\n stats_host: string;\n authEndpoint: string;\n authTransport: AuthTransport;\n activityTimeout: number;\n pongTimeout: number;\n unavailableTimeout: number;\n userAuthentication: UserAuthenticationOptions;\n channelAuthorization: ChannelAuthorizationOptions;\n\n cdn_http?: string;\n cdn_https?: string;\n dependency_suffix?: string;\n}\n\nvar Defaults: DefaultConfig = {\n VERSION: VERSION,\n PROTOCOL: 7,\n\n wsPort: 80,\n wssPort: 443,\n wsPath: '',\n // DEPRECATED: SockJS fallback parameters\n httpHost: 'sockjs.pusher.com',\n httpPort: 80,\n httpsPort: 443,\n httpPath: '/pusher',\n // DEPRECATED: Stats\n stats_host: 'stats.pusher.com',\n // DEPRECATED: Other settings\n authEndpoint: '/pusher/auth',\n authTransport: 'ajax',\n activityTimeout: 120000,\n pongTimeout: 30000,\n unavailableTimeout: 10000,\n userAuthentication: {\n endpoint: '/pusher/user-auth',\n transport: 'ajax'\n },\n channelAuthorization: {\n endpoint: '/pusher/auth',\n transport: 'ajax'\n },\n\n // CDN configuration\n cdn_http: CDN_HTTP,\n cdn_https: CDN_HTTPS,\n dependency_suffix: DEPENDENCY_SUFFIX\n};\n\nexport default Defaults;\n","import Defaults from '../defaults';\nimport { default as URLScheme, URLSchemeParams } from './url_scheme';\n\nfunction getGenericURL(\n baseScheme: string,\n params: URLSchemeParams,\n path: string\n): string {\n var scheme = baseScheme + (params.useTLS ? 's' : '');\n var host = params.useTLS ? params.hostTLS : params.hostNonTLS;\n return scheme + '://' + host + path;\n}\n\nfunction getGenericPath(key: string, queryString?: string): string {\n var path = '/app/' + key;\n var query =\n '?protocol=' +\n Defaults.PROTOCOL +\n '&client=js' +\n '&version=' +\n Defaults.VERSION +\n (queryString ? '&' + queryString : '');\n return path + query;\n}\n\nexport var ws: URLScheme = {\n getInitial: function(key: string, params: URLSchemeParams): string {\n var path = (params.httpPath || '') + getGenericPath(key, 'flash=false');\n return getGenericURL('ws', params, path);\n }\n};\n\nexport var http: URLScheme = {\n getInitial: function(key: string, params: URLSchemeParams): string {\n var path = (params.httpPath || '/pusher') + getGenericPath(key);\n return getGenericURL('http', params, path);\n }\n};\n\nexport var sockjs: URLScheme = {\n getInitial: function(key: string, params: URLSchemeParams): string {\n return getGenericURL('http', params, params.httpPath || '/pusher');\n },\n getPath: function(key: string, params: URLSchemeParams): string {\n return getGenericPath(key);\n }\n};\n","import Callback from './callback';\nimport * as Collections from '../utils/collections';\nimport CallbackTable from './callback_table';\n\nexport default class CallbackRegistry {\n _callbacks: CallbackTable;\n\n constructor() {\n this._callbacks = {};\n }\n\n get(name: string): Callback[] {\n return this._callbacks[prefix(name)];\n }\n\n add(name: string, callback: Function, context: any) {\n var prefixedEventName = prefix(name);\n this._callbacks[prefixedEventName] =\n this._callbacks[prefixedEventName] || [];\n this._callbacks[prefixedEventName].push({\n fn: callback,\n context: context\n });\n }\n\n remove(name?: string, callback?: Function, context?: any) {\n if (!name && !callback && !context) {\n this._callbacks = {};\n return;\n }\n\n var names = name ? [prefix(name)] : Collections.keys(this._callbacks);\n\n if (callback || context) {\n this.removeCallback(names, callback, context);\n } else {\n this.removeAllCallbacks(names);\n }\n }\n\n private removeCallback(names: string[], callback: Function, context: any) {\n Collections.apply(\n names,\n function(name) {\n this._callbacks[name] = Collections.filter(\n this._callbacks[name] || [],\n function(binding) {\n return (\n (callback && callback !== binding.fn) ||\n (context && context !== binding.context)\n );\n }\n );\n if (this._callbacks[name].length === 0) {\n delete this._callbacks[name];\n }\n },\n this\n );\n }\n\n private removeAllCallbacks(names: string[]) {\n Collections.apply(\n names,\n function(name) {\n delete this._callbacks[name];\n },\n this\n );\n }\n}\n\nfunction prefix(name: string): string {\n return '_' + name;\n}\n","import * as Collections from '../utils/collections';\nimport Callback from './callback';\nimport Metadata from '../channels/metadata';\nimport CallbackRegistry from './callback_registry';\n\n/** Manages callback bindings and event emitting.\n *\n * @param Function failThrough called when no listeners are bound to an event\n */\nexport default class Dispatcher {\n callbacks: CallbackRegistry;\n global_callbacks: Function[];\n failThrough: Function;\n\n constructor(failThrough?: Function) {\n this.callbacks = new CallbackRegistry();\n this.global_callbacks = [];\n this.failThrough = failThrough;\n }\n\n bind(eventName: string, callback: Function, context?: any) {\n this.callbacks.add(eventName, callback, context);\n return this;\n }\n\n bind_global(callback: Function) {\n this.global_callbacks.push(callback);\n return this;\n }\n\n unbind(eventName?: string, callback?: Function, context?: any) {\n this.callbacks.remove(eventName, callback, context);\n return this;\n }\n\n unbind_global(callback?: Function) {\n if (!callback) {\n this.global_callbacks = [];\n return this;\n }\n\n this.global_callbacks = Collections.filter(\n this.global_callbacks || [],\n c => c !== callback\n );\n\n return this;\n }\n\n unbind_all() {\n this.unbind();\n this.unbind_global();\n return this;\n }\n\n emit(eventName: string, data?: any, metadata?: Metadata): Dispatcher {\n for (var i = 0; i < this.global_callbacks.length; i++) {\n this.global_callbacks[i](eventName, data);\n }\n\n var callbacks = this.callbacks.get(eventName);\n var args = [];\n\n if (metadata) {\n // if there's a metadata argument, we need to call the callback with both\n // data and metadata regardless of whether data is undefined\n args.push(data, metadata);\n } else if (data) {\n // metadata is undefined, so we only need to call the callback with data\n // if data exists\n args.push(data);\n }\n\n if (callbacks && callbacks.length > 0) {\n for (var i = 0; i < callbacks.length; i++) {\n callbacks[i].fn.apply(callbacks[i].context || global, args);\n }\n } else if (this.failThrough) {\n this.failThrough(eventName, data);\n }\n\n return this;\n }\n}\n","import { stringify } from './utils/collections';\nimport Pusher from './pusher';\n\nclass Logger {\n debug(...args: any[]) {\n this.log(this.globalLog, args);\n }\n\n warn(...args: any[]) {\n this.log(this.globalLogWarn, args);\n }\n\n error(...args: any[]) {\n this.log(this.globalLogError, args);\n }\n\n private globalLog = (message: string) => {\n if (global.console && global.console.log) {\n global.console.log(message);\n }\n };\n\n private globalLogWarn(message: string) {\n if (global.console && global.console.warn) {\n global.console.warn(message);\n } else {\n this.globalLog(message);\n }\n }\n\n private globalLogError(message: string) {\n if (global.console && global.console.error) {\n global.console.error(message);\n } else {\n this.globalLogWarn(message);\n }\n }\n\n private log(\n defaultLoggingFunction: (message: string) => void,\n ...args: any[]\n ) {\n var message = stringify.apply(this, arguments);\n if (Pusher.log) {\n Pusher.log(message);\n } else if (Pusher.logToConsole) {\n const log = defaultLoggingFunction.bind(this);\n log(message);\n }\n }\n}\n\nexport default new Logger();\n","import Util from '../util';\nimport * as Collections from '../utils/collections';\nimport { default as EventsDispatcher } from '../events/dispatcher';\nimport Logger from '../logger';\nimport TransportHooks from './transport_hooks';\nimport Socket from '../socket';\nimport Runtime from 'runtime';\nimport Timeline from '../timeline/timeline';\nimport TransportConnectionOptions from './transport_connection_options';\n\n/** Provides universal API for transport connections.\n *\n * Transport connection is a low-level object that wraps a connection method\n * and exposes a simple evented interface for the connection state and\n * messaging. It does not implement Pusher-specific WebSocket protocol.\n *\n * Additionally, it fetches resources needed for transport to work and exposes\n * an interface for querying transport features.\n *\n * States:\n * - new - initial state after constructing the object\n * - initializing - during initialization phase, usually fetching resources\n * - intialized - ready to establish a connection\n * - connection - when connection is being established\n * - open - when connection ready to be used\n * - closed - after connection was closed be either side\n *\n * Emits:\n * - error - after the connection raised an error\n *\n * Options:\n * - useTLS - whether connection should be over TLS\n * - hostTLS - host to connect to when connection is over TLS\n * - hostNonTLS - host to connect to when connection is over TLS\n *\n * @param {String} key application key\n * @param {Object} options\n */\nexport default class TransportConnection extends EventsDispatcher {\n hooks: TransportHooks;\n name: string;\n priority: number;\n key: string;\n options: TransportConnectionOptions;\n state: string;\n timeline: Timeline;\n activityTimeout: number;\n id: number;\n socket: Socket;\n beforeOpen: Function;\n initialize: Function;\n\n constructor(\n hooks: TransportHooks,\n name: string,\n priority: number,\n key: string,\n options: TransportConnectionOptions\n ) {\n super();\n this.initialize = Runtime.transportConnectionInitializer;\n this.hooks = hooks;\n this.name = name;\n this.priority = priority;\n this.key = key;\n this.options = options;\n\n this.state = 'new';\n this.timeline = options.timeline;\n this.activityTimeout = options.activityTimeout;\n this.id = this.timeline.generateUniqueID();\n }\n\n /** Checks whether the transport handles activity checks by itself.\n *\n * @return {Boolean}\n */\n handlesActivityChecks(): boolean {\n return Boolean(this.hooks.handlesActivityChecks);\n }\n\n /** Checks whether the transport supports the ping/pong API.\n *\n * @return {Boolean}\n */\n supportsPing(): boolean {\n return Boolean(this.hooks.supportsPing);\n }\n\n /** Tries to establish a connection.\n *\n * @returns {Boolean} false if transport is in invalid state\n */\n connect(): boolean {\n if (this.socket || this.state !== 'initialized') {\n return false;\n }\n\n var url = this.hooks.urls.getInitial(this.key, this.options);\n try {\n this.socket = this.hooks.getSocket(url, this.options);\n } catch (e) {\n Util.defer(() => {\n this.onError(e);\n this.changeState('closed');\n });\n return false;\n }\n\n this.bindListeners();\n\n Logger.debug('Connecting', { transport: this.name, url });\n this.changeState('connecting');\n return true;\n }\n\n /** Closes the connection.\n *\n * @return {Boolean} true if there was a connection to close\n */\n close(): boolean {\n if (this.socket) {\n this.socket.close();\n return true;\n } else {\n return false;\n }\n }\n\n /** Sends data over the open connection.\n *\n * @param {String} data\n * @return {Boolean} true only when in the \"open\" state\n */\n send(data: any): boolean {\n if (this.state === 'open') {\n // Workaround for MobileSafari bug (see https://gist.github.com/2052006)\n Util.defer(() => {\n if (this.socket) {\n this.socket.send(data);\n }\n });\n return true;\n } else {\n return false;\n }\n }\n\n /** Sends a ping if the connection is open and transport supports it. */\n ping() {\n if (this.state === 'open' && this.supportsPing()) {\n this.socket.ping();\n }\n }\n\n private onOpen() {\n if (this.hooks.beforeOpen) {\n this.hooks.beforeOpen(\n this.socket,\n this.hooks.urls.getPath(this.key, this.options)\n );\n }\n this.changeState('open');\n this.socket.onopen = undefined;\n }\n\n private onError(error) {\n this.emit('error', { type: 'WebSocketError', error: error });\n this.timeline.error(this.buildTimelineMessage({ error: error.toString() }));\n }\n\n private onClose(closeEvent?: any) {\n if (closeEvent) {\n this.changeState('closed', {\n code: closeEvent.code,\n reason: closeEvent.reason,\n wasClean: closeEvent.wasClean\n });\n } else {\n this.changeState('closed');\n }\n this.unbindListeners();\n this.socket = undefined;\n }\n\n private onMessage(message) {\n this.emit('message', message);\n }\n\n private onActivity() {\n this.emit('activity');\n }\n\n private bindListeners() {\n this.socket.onopen = () => {\n this.onOpen();\n };\n this.socket.onerror = error => {\n this.onError(error);\n };\n this.socket.onclose = closeEvent => {\n this.onClose(closeEvent);\n };\n this.socket.onmessage = message => {\n this.onMessage(message);\n };\n\n if (this.supportsPing()) {\n this.socket.onactivity = () => {\n this.onActivity();\n };\n }\n }\n\n private unbindListeners() {\n if (this.socket) {\n this.socket.onopen = undefined;\n this.socket.onerror = undefined;\n this.socket.onclose = undefined;\n this.socket.onmessage = undefined;\n if (this.supportsPing()) {\n this.socket.onactivity = undefined;\n }\n }\n }\n\n private changeState(state: string, params?: any) {\n this.state = state;\n this.timeline.info(\n this.buildTimelineMessage({\n state: state,\n params: params\n })\n );\n this.emit(state, params);\n }\n\n buildTimelineMessage(message): any {\n return Collections.extend({ cid: this.id }, message);\n }\n}\n","import Factory from '../utils/factory';\nimport TransportHooks from './transport_hooks';\nimport TransportConnection from './transport_connection';\nimport TransportConnectionOptions from './transport_connection_options';\n\n/** Provides interface for transport connection instantiation.\n *\n * Takes transport-specific hooks as the only argument, which allow checking\n * for transport support and creating its connections.\n *\n * Supported hooks: * - file - the name of the file to be fetched during initialization\n * - urls - URL scheme to be used by transport\n * - handlesActivityCheck - true when the transport handles activity checks\n * - supportsPing - true when the transport has a ping/activity API\n * - isSupported - tells whether the transport is supported in the environment\n * - getSocket - creates a WebSocket-compatible transport socket\n *\n * See transports.js for specific implementations.\n *\n * @param {Object} hooks object containing all needed transport hooks\n */\nexport default class Transport {\n hooks: TransportHooks;\n\n constructor(hooks: TransportHooks) {\n this.hooks = hooks;\n }\n\n /** Returns whether the transport is supported in the environment.\n *\n * @param {Object} envronment te environment details (encryption, settings)\n * @returns {Boolean} true when the transport is supported\n */\n isSupported(environment: any): boolean {\n return this.hooks.isSupported(environment);\n }\n\n /** Creates a transport connection.\n *\n * @param {String} name\n * @param {Number} priority\n * @param {String} key the application key\n * @param {Object} options\n * @returns {TransportConnection}\n */\n createConnection(\n name: string,\n priority: number,\n key: string,\n options: any\n ): TransportConnection {\n return new TransportConnection(this.hooks, name, priority, key, options);\n }\n}\n","import * as URLSchemes from 'core/transports/url_schemes';\nimport URLScheme from 'core/transports/url_scheme';\nimport Transport from 'core/transports/transport';\nimport Util from 'core/util';\nimport * as Collections from 'core/utils/collections';\nimport TransportHooks from 'core/transports/transport_hooks';\nimport TransportsTable from 'core/transports/transports_table';\nimport Runtime from 'runtime';\n\n/** WebSocket transport.\n *\n * Uses native WebSocket implementation, including MozWebSocket supported by\n * earlier Firefox versions.\n */\nvar WSTransport = new Transport({\n urls: URLSchemes.ws,\n handlesActivityChecks: false,\n supportsPing: false,\n\n isInitialized: function() {\n return Boolean(Runtime.getWebSocketAPI());\n },\n isSupported: function(): boolean {\n return Boolean(Runtime.getWebSocketAPI());\n },\n getSocket: function(url) {\n return Runtime.createWebSocket(url);\n }\n});\n\nvar httpConfiguration = {\n urls: URLSchemes.http,\n handlesActivityChecks: false,\n supportsPing: true,\n isInitialized: function() {\n return true;\n }\n};\n\nexport var streamingConfiguration = Collections.extend(\n {\n getSocket: function(url) {\n return Runtime.HTTPFactory.createStreamingSocket(url);\n }\n },\n httpConfiguration\n);\nexport var pollingConfiguration = Collections.extend(\n {\n getSocket: function(url) {\n return Runtime.HTTPFactory.createPollingSocket(url);\n }\n },\n httpConfiguration\n);\n\nvar xhrConfiguration = {\n isSupported: function(): boolean {\n return Runtime.isXHRSupported();\n }\n};\n\n/** HTTP streaming transport using CORS-enabled XMLHttpRequest. */\nvar XHRStreamingTransport = new Transport(\n (\n Collections.extend({}, streamingConfiguration, xhrConfiguration)\n )\n);\n\n/** HTTP long-polling transport using CORS-enabled XMLHttpRequest. */\nvar XHRPollingTransport = new Transport(\n Collections.extend({}, pollingConfiguration, xhrConfiguration)\n);\n\nvar Transports: TransportsTable = {\n ws: WSTransport,\n xhr_streaming: XHRStreamingTransport,\n xhr_polling: XHRPollingTransport\n};\n\nexport default Transports;\n","import Util from '../util';\nimport * as Collections from '../utils/collections';\nimport TransportManager from './transport_manager';\nimport TransportConnection from './transport_connection';\nimport Transport from './transport';\nimport PingDelayOptions from './ping_delay_options';\n\n/** Creates transport connections monitored by a transport manager.\n *\n * When a transport is closed, it might mean the environment does not support\n * it. It's possible that messages get stuck in an intermediate buffer or\n * proxies terminate inactive connections. To combat these problems,\n * assistants monitor the connection lifetime, report unclean exits and\n * adjust ping timeouts to keep the connection active. The decision to disable\n * a transport is the manager's responsibility.\n *\n * @param {TransportManager} manager\n * @param {TransportConnection} transport\n * @param {Object} options\n */\nexport default class AssistantToTheTransportManager {\n manager: TransportManager;\n transport: Transport;\n minPingDelay: number;\n maxPingDelay: number;\n pingDelay: number;\n\n constructor(\n manager: TransportManager,\n transport: Transport,\n options: PingDelayOptions\n ) {\n this.manager = manager;\n this.transport = transport;\n this.minPingDelay = options.minPingDelay;\n this.maxPingDelay = options.maxPingDelay;\n this.pingDelay = undefined;\n }\n\n /** Creates a transport connection.\n *\n * This function has the same API as Transport#createConnection.\n *\n * @param {String} name\n * @param {Number} priority\n * @param {String} key the application key\n * @param {Object} options\n * @returns {TransportConnection}\n */\n createConnection(\n name: string,\n priority: number,\n key: string,\n options: Object\n ): TransportConnection {\n options = Collections.extend({}, options, {\n activityTimeout: this.pingDelay\n });\n var connection = this.transport.createConnection(\n name,\n priority,\n key,\n options\n );\n\n var openTimestamp = null;\n\n var onOpen = function() {\n connection.unbind('open', onOpen);\n connection.bind('closed', onClosed);\n openTimestamp = Util.now();\n };\n var onClosed = closeEvent => {\n connection.unbind('closed', onClosed);\n\n if (closeEvent.code === 1002 || closeEvent.code === 1003) {\n // we don't want to use transports not obeying the protocol\n this.manager.reportDeath();\n } else if (!closeEvent.wasClean && openTimestamp) {\n // report deaths only for short-living transport\n var lifespan = Util.now() - openTimestamp;\n if (lifespan < 2 * this.maxPingDelay) {\n this.manager.reportDeath();\n this.pingDelay = Math.max(lifespan / 2, this.minPingDelay);\n }\n }\n };\n\n connection.bind('open', onOpen);\n return connection;\n }\n\n /** Returns whether the transport is supported in the environment.\n *\n * This function has the same API as Transport#isSupported. Might return false\n * when the manager decides to kill the transport.\n *\n * @param {Object} environment the environment details (encryption, settings)\n * @returns {Boolean} true when the transport is supported\n */\n isSupported(environment: string): boolean {\n return this.manager.isAlive() && this.transport.isSupported(environment);\n }\n}\n","import Action from './action';\nimport { PusherEvent } from './message-types';\n/**\n * Provides functions for handling Pusher protocol-specific messages.\n */\n\nconst Protocol = {\n /**\n * Decodes a message in a Pusher format.\n *\n * The MessageEvent we receive from the transport should contain a pusher event\n * (https://pusher.com/docs/pusher_protocol#events) serialized as JSON in the\n * data field\n *\n * The pusher event may contain a data field too, and it may also be\n * serialised as JSON\n *\n * Throws errors when messages are not parse'able.\n *\n * @param {MessageEvent} messageEvent\n * @return {PusherEvent}\n */\n decodeMessage: function(messageEvent: MessageEvent): PusherEvent {\n try {\n var messageData = JSON.parse(messageEvent.data);\n var pusherEventData = messageData.data;\n if (typeof pusherEventData === 'string') {\n try {\n pusherEventData = JSON.parse(messageData.data);\n } catch (e) {}\n }\n var pusherEvent: PusherEvent = {\n event: messageData.event,\n channel: messageData.channel,\n data: pusherEventData\n };\n if (messageData.user_id) {\n pusherEvent.user_id = messageData.user_id;\n }\n return pusherEvent;\n } catch (e) {\n throw { type: 'MessageParseError', error: e, data: messageEvent.data };\n }\n },\n\n /**\n * Encodes a message to be sent.\n *\n * @param {PusherEvent} event\n * @return {String}\n */\n encodeMessage: function(event: PusherEvent): string {\n return JSON.stringify(event);\n },\n\n /**\n * Processes a handshake message and returns appropriate actions.\n *\n * Returns an object with an 'action' and other action-specific properties.\n *\n * There are three outcomes when calling this function. First is a successful\n * connection attempt, when pusher:connection_established is received, which\n * results in a 'connected' action with an 'id' property. When passed a\n * pusher:error event, it returns a result with action appropriate to the\n * close code and an error. Otherwise, it raises an exception.\n *\n * @param {String} message\n * @result Object\n */\n processHandshake: function(messageEvent: MessageEvent): Action {\n var message = Protocol.decodeMessage(messageEvent);\n\n if (message.event === 'pusher:connection_established') {\n if (!message.data.activity_timeout) {\n throw 'No activity timeout specified in handshake';\n }\n return {\n action: 'connected',\n id: message.data.socket_id,\n activityTimeout: message.data.activity_timeout * 1000\n };\n } else if (message.event === 'pusher:error') {\n // From protocol 6 close codes are sent only once, so this only\n // happens when connection does not support close codes\n return {\n action: this.getCloseAction(message.data),\n error: this.getCloseError(message.data)\n };\n } else {\n throw 'Invalid handshake';\n }\n },\n\n /**\n * Dispatches the close event and returns an appropriate action name.\n *\n * See:\n * 1. https://developer.mozilla.org/en-US/docs/WebSockets/WebSockets_reference/CloseEvent\n * 2. http://pusher.com/docs/pusher_protocol\n *\n * @param {CloseEvent} closeEvent\n * @return {String} close action name\n */\n getCloseAction: function(closeEvent): string {\n if (closeEvent.code < 4000) {\n // ignore 1000 CLOSE_NORMAL, 1001 CLOSE_GOING_AWAY,\n // 1005 CLOSE_NO_STATUS, 1006 CLOSE_ABNORMAL\n // ignore 1007...3999\n // handle 1002 CLOSE_PROTOCOL_ERROR, 1003 CLOSE_UNSUPPORTED,\n // 1004 CLOSE_TOO_LARGE\n if (closeEvent.code >= 1002 && closeEvent.code <= 1004) {\n return 'backoff';\n } else {\n return null;\n }\n } else if (closeEvent.code === 4000) {\n return 'tls_only';\n } else if (closeEvent.code < 4100) {\n return 'refused';\n } else if (closeEvent.code < 4200) {\n return 'backoff';\n } else if (closeEvent.code < 4300) {\n return 'retry';\n } else {\n // unknown error\n return 'refused';\n }\n },\n\n /**\n * Returns an error or null basing on the close event.\n *\n * Null is returned when connection was closed cleanly. Otherwise, an object\n * with error details is returned.\n *\n * @param {CloseEvent} closeEvent\n * @return {Object} error object\n */\n getCloseError: function(closeEvent): any {\n if (closeEvent.code !== 1000 && closeEvent.code !== 1001) {\n return {\n type: 'PusherError',\n data: {\n code: closeEvent.code,\n message: closeEvent.reason || closeEvent.message\n }\n };\n } else {\n return null;\n }\n }\n};\n\nexport default Protocol;\n","import * as Collections from '../utils/collections';\nimport { default as EventsDispatcher } from '../events/dispatcher';\nimport Protocol from './protocol/protocol';\nimport { PusherEvent } from './protocol/message-types';\nimport Logger from '../logger';\nimport TransportConnection from '../transports/transport_connection';\nimport Socket from '../socket';\n/**\n * Provides Pusher protocol interface for transports.\n *\n * Emits following events:\n * - message - on received messages\n * - ping - on ping requests\n * - pong - on pong responses\n * - error - when the transport emits an error\n * - closed - after closing the transport\n *\n * It also emits more events when connection closes with a code.\n * See Protocol.getCloseAction to get more details.\n *\n * @param {Number} id\n * @param {AbstractTransport} transport\n */\nexport default class Connection extends EventsDispatcher implements Socket {\n id: string;\n transport: TransportConnection;\n activityTimeout: number;\n\n constructor(id: string, transport: TransportConnection) {\n super();\n this.id = id;\n this.transport = transport;\n this.activityTimeout = transport.activityTimeout;\n this.bindListeners();\n }\n\n /** Returns whether used transport handles activity checks by itself\n *\n * @returns {Boolean} true if activity checks are handled by the transport\n */\n handlesActivityChecks() {\n return this.transport.handlesActivityChecks();\n }\n\n /** Sends raw data.\n *\n * @param {String} data\n */\n send(data: any): boolean {\n return this.transport.send(data);\n }\n\n /** Sends an event.\n *\n * @param {String} name\n * @param {String} data\n * @param {String} [channel]\n * @returns {Boolean} whether message was sent or not\n */\n send_event(name: string, data: any, channel?: string): boolean {\n var event: PusherEvent = { event: name, data: data };\n if (channel) {\n event.channel = channel;\n }\n Logger.debug('Event sent', event);\n return this.send(Protocol.encodeMessage(event));\n }\n\n /** Sends a ping message to the server.\n *\n * Basing on the underlying transport, it might send either transport's\n * protocol-specific ping or pusher:ping event.\n */\n ping() {\n if (this.transport.supportsPing()) {\n this.transport.ping();\n } else {\n this.send_event('pusher:ping', {});\n }\n }\n\n /** Closes the connection. */\n close() {\n this.transport.close();\n }\n\n private bindListeners() {\n var listeners = {\n message: (messageEvent: MessageEvent) => {\n var pusherEvent;\n try {\n pusherEvent = Protocol.decodeMessage(messageEvent);\n } catch (e) {\n this.emit('error', {\n type: 'MessageParseError',\n error: e,\n data: messageEvent.data\n });\n }\n\n if (pusherEvent !== undefined) {\n Logger.debug('Event recd', pusherEvent);\n\n switch (pusherEvent.event) {\n case 'pusher:error':\n this.emit('error', {\n type: 'PusherError',\n data: pusherEvent.data\n });\n break;\n case 'pusher:ping':\n this.emit('ping');\n break;\n case 'pusher:pong':\n this.emit('pong');\n break;\n }\n this.emit('message', pusherEvent);\n }\n },\n activity: () => {\n this.emit('activity');\n },\n error: error => {\n this.emit('error', error);\n },\n closed: closeEvent => {\n unbindListeners();\n\n if (closeEvent && closeEvent.code) {\n this.handleCloseEvent(closeEvent);\n }\n\n this.transport = null;\n this.emit('closed');\n }\n };\n\n var unbindListeners = () => {\n Collections.objectApply(listeners, (listener, event) => {\n this.transport.unbind(event, listener);\n });\n };\n\n Collections.objectApply(listeners, (listener, event) => {\n this.transport.bind(event, listener);\n });\n }\n\n private handleCloseEvent(closeEvent: any) {\n var action = Protocol.getCloseAction(closeEvent);\n var error = Protocol.getCloseError(closeEvent);\n if (error) {\n this.emit('error', error);\n }\n if (action) {\n this.emit(action, { action: action, error: error });\n }\n }\n}\n","import Util from '../../util';\nimport * as Collections from '../../utils/collections';\nimport Protocol from '../protocol/protocol';\nimport Connection from '../connection';\nimport TransportConnection from '../../transports/transport_connection';\nimport HandshakePayload from './handshake_payload';\n\n/**\n * Handles Pusher protocol handshakes for transports.\n *\n * Calls back with a result object after handshake is completed. Results\n * always have two fields:\n * - action - string describing action to be taken after the handshake\n * - transport - the transport object passed to the constructor\n *\n * Different actions can set different additional properties on the result.\n * In the case of 'connected' action, there will be a 'connection' property\n * containing a Connection object for the transport. Other actions should\n * carry an 'error' property.\n *\n * @param {AbstractTransport} transport\n * @param {Function} callback\n */\nexport default class Handshake {\n transport: TransportConnection;\n callback: (HandshakePayload) => void;\n onMessage: Function;\n onClosed: Function;\n\n constructor(\n transport: TransportConnection,\n callback: (HandshakePayload) => void\n ) {\n this.transport = transport;\n this.callback = callback;\n this.bindListeners();\n }\n\n close() {\n this.unbindListeners();\n this.transport.close();\n }\n\n private bindListeners() {\n this.onMessage = m => {\n this.unbindListeners();\n\n var result;\n try {\n result = Protocol.processHandshake(m);\n } catch (e) {\n this.finish('error', { error: e });\n this.transport.close();\n return;\n }\n\n if (result.action === 'connected') {\n this.finish('connected', {\n connection: new Connection(result.id, this.transport),\n activityTimeout: result.activityTimeout\n });\n } else {\n this.finish(result.action, { error: result.error });\n this.transport.close();\n }\n };\n\n this.onClosed = closeEvent => {\n this.unbindListeners();\n\n var action = Protocol.getCloseAction(closeEvent) || 'backoff';\n var error = Protocol.getCloseError(closeEvent);\n this.finish(action, { error: error });\n };\n\n this.transport.bind('message', this.onMessage);\n this.transport.bind('closed', this.onClosed);\n }\n\n private unbindListeners() {\n this.transport.unbind('message', this.onMessage);\n this.transport.unbind('closed', this.onClosed);\n }\n\n private finish(action: string, params: any) {\n this.callback(\n Collections.extend({ transport: this.transport, action: action }, params)\n );\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport base64encode from '../base64';\nimport Timeline from './timeline';\nimport Runtime from 'runtime';\n\nexport interface TimelineSenderOptions {\n host?: string;\n port?: number;\n path?: string;\n}\n\nexport default class TimelineSender {\n timeline: Timeline;\n options: TimelineSenderOptions;\n host: string;\n\n constructor(timeline: Timeline, options: TimelineSenderOptions) {\n this.timeline = timeline;\n this.options = options || {};\n }\n\n send(useTLS: boolean, callback?: Function) {\n if (this.timeline.isEmpty()) {\n return;\n }\n\n this.timeline.send(\n Runtime.TimelineTransport.getAgent(this, useTLS),\n callback\n );\n }\n}\n","/** Error classes used throughout the library. */\n// https://github.com/Microsoft/TypeScript-wiki/blob/master/Breaking-Changes.md#extending-built-ins-like-error-array-and-map-may-no-longer-work\nexport class BadEventName extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\nexport class BadChannelName extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\nexport class RequestTimedOut extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class TransportPriorityTooLow extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class TransportClosed extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class UnsupportedFeature extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class UnsupportedTransport extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class UnsupportedStrategy extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class HTTPAuthError extends Error {\n status: number;\n constructor(status: number, msg?: string) {\n super(msg);\n this.status = status;\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n","/**\n * A place to store help URLs for error messages etc\n */\n\nconst urlStore = {\n baseUrl: 'https://pusher.com',\n urls: {\n authenticationEndpoint: {\n path: '/docs/channels/server_api/authenticating_users'\n },\n authorizationEndpoint: {\n path: '/docs/channels/server_api/authorizing-users/'\n },\n javascriptQuickStart: {\n path: '/docs/javascript_quick_start'\n },\n triggeringClientEvents: {\n path: '/docs/client_api_guide/client_events#trigger-events'\n },\n encryptedChannelSupport: {\n fullUrl:\n 'https://github.com/pusher/pusher-js/tree/cc491015371a4bde5743d1c87a0fbac0feb53195#encrypted-channel-support'\n }\n }\n};\n\n/** Builds a consistent string with links to pusher documentation\n *\n * @param {string} key - relevant key in the url_store.urls object\n * @return {string} suffix string to append to log message\n */\nconst buildLogSuffix = function(key: string): string {\n const urlPrefix = 'See:';\n const urlObj = urlStore.urls[key];\n if (!urlObj) return '';\n\n let url;\n if (urlObj.fullUrl) {\n url = urlObj.fullUrl;\n } else if (urlObj.path) {\n url = urlStore.baseUrl + urlObj.path;\n }\n\n if (!url) return '';\n return `${urlPrefix} ${url}`;\n};\n\nexport default { buildLogSuffix };\n","import { default as EventsDispatcher } from '../events/dispatcher';\nimport * as Errors from '../errors';\nimport Logger from '../logger';\nimport Pusher from '../pusher';\nimport { PusherEvent } from '../connection/protocol/message-types';\nimport Metadata from './metadata';\nimport UrlStore from '../utils/url_store';\nimport {\n ChannelAuthorizationData,\n ChannelAuthorizationCallback\n} from '../auth/options';\nimport { HTTPAuthError } from '../errors';\n\n/** Provides base public channel interface with an event emitter.\n *\n * Emits:\n * - pusher:subscription_succeeded - after subscribing successfully\n * - other non-internal events\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\nexport default class Channel extends EventsDispatcher {\n name: string;\n pusher: Pusher;\n subscribed: boolean;\n subscriptionPending: boolean;\n subscriptionCancelled: boolean;\n subscriptionCount: null;\n\n constructor(name: string, pusher: Pusher) {\n super(function(event, data) {\n Logger.debug('No callbacks on ' + name + ' for ' + event);\n });\n\n this.name = name;\n this.pusher = pusher;\n this.subscribed = false;\n this.subscriptionPending = false;\n this.subscriptionCancelled = false;\n }\n\n /** Skips authorization, since public channels don't require it.\n *\n * @param {Function} callback\n */\n authorize(socketId: string, callback: ChannelAuthorizationCallback) {\n return callback(null, { auth: '' });\n }\n\n /** Triggers an event */\n trigger(event: string, data: any) {\n if (event.indexOf('client-') !== 0) {\n throw new Errors.BadEventName(\n \"Event '\" + event + \"' does not start with 'client-'\"\n );\n }\n if (!this.subscribed) {\n var suffix = UrlStore.buildLogSuffix('triggeringClientEvents');\n Logger.warn(\n `Client event triggered before channel 'subscription_succeeded' event . ${suffix}`\n );\n }\n return this.pusher.send_event(event, data, this.name);\n }\n\n /** Signals disconnection to the channel. For internal use only. */\n disconnect() {\n this.subscribed = false;\n this.subscriptionPending = false;\n }\n\n /** Handles a PusherEvent. For internal use only.\n *\n * @param {PusherEvent} event\n */\n handleEvent(event: PusherEvent) {\n var eventName = event.event;\n var data = event.data;\n if (eventName === 'pusher_internal:subscription_succeeded') {\n this.handleSubscriptionSucceededEvent(event);\n } else if (eventName === 'pusher_internal:subscription_count') {\n this.handleSubscriptionCountEvent(event);\n } else if (eventName.indexOf('pusher_internal:') !== 0) {\n var metadata: Metadata = {};\n this.emit(eventName, data, metadata);\n }\n }\n\n handleSubscriptionSucceededEvent(event: PusherEvent) {\n this.subscriptionPending = false;\n this.subscribed = true;\n if (this.subscriptionCancelled) {\n this.pusher.unsubscribe(this.name);\n } else {\n this.emit('pusher:subscription_succeeded', event.data);\n }\n }\n\n handleSubscriptionCountEvent(event: PusherEvent) {\n if (event.data.subscription_count) {\n this.subscriptionCount = event.data.subscription_count;\n }\n\n this.emit('pusher:subscription_count', event.data);\n }\n\n /** Sends a subscription request. For internal use only. */\n subscribe() {\n if (this.subscribed) {\n return;\n }\n this.subscriptionPending = true;\n this.subscriptionCancelled = false;\n this.authorize(\n this.pusher.connection.socket_id,\n (error: Error | null, data: ChannelAuthorizationData) => {\n if (error) {\n this.subscriptionPending = false;\n // Why not bind to 'pusher:subscription_error' a level up, and log there?\n // Binding to this event would cause the warning about no callbacks being\n // bound (see constructor) to be suppressed, that's not what we want.\n Logger.error(error.toString());\n this.emit(\n 'pusher:subscription_error',\n Object.assign(\n {},\n {\n type: 'AuthError',\n error: error.message\n },\n error instanceof HTTPAuthError ? { status: error.status } : {}\n )\n );\n } else {\n this.pusher.send_event('pusher:subscribe', {\n auth: data.auth,\n channel_data: data.channel_data,\n channel: this.name\n });\n }\n }\n );\n }\n\n /** Sends an unsubscription request. For internal use only. */\n unsubscribe() {\n this.subscribed = false;\n this.pusher.send_event('pusher:unsubscribe', {\n channel: this.name\n });\n }\n\n /** Cancels an in progress subscription. For internal use only. */\n cancelSubscription() {\n this.subscriptionCancelled = true;\n }\n\n /** Reinstates an in progress subscripiton. For internal use only. */\n reinstateSubscription() {\n this.subscriptionCancelled = false;\n }\n}\n","import Factory from '../utils/factory';\nimport Channel from './channel';\nimport { ChannelAuthorizationCallback } from '../auth/options';\n\n/** Extends public channels to provide private channel interface.\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\nexport default class PrivateChannel extends Channel {\n /** Authorizes the connection to use the channel.\n *\n * @param {String} socketId\n * @param {Function} callback\n */\n authorize(socketId: string, callback: ChannelAuthorizationCallback) {\n return this.pusher.config.channelAuthorizer(\n {\n channelName: this.name,\n socketId: socketId\n },\n callback\n );\n }\n}\n","import * as Collections from '../utils/collections';\n\n/** Represents a collection of members of a presence channel. */\nexport default class Members {\n members: any;\n count: number;\n myID: any;\n me: any;\n\n constructor() {\n this.reset();\n }\n\n /** Returns member's info for given id.\n *\n * Resulting object containts two fields - id and info.\n *\n * @param {Number} id\n * @return {Object} member's info or null\n */\n get(id: string): any {\n if (Object.prototype.hasOwnProperty.call(this.members, id)) {\n return {\n id: id,\n info: this.members[id]\n };\n } else {\n return null;\n }\n }\n\n /** Calls back for each member in unspecified order.\n *\n * @param {Function} callback\n */\n each(callback: Function) {\n Collections.objectApply(this.members, (member, id) => {\n callback(this.get(id));\n });\n }\n\n /** Updates the id for connected member. For internal use only. */\n setMyID(id: string) {\n this.myID = id;\n }\n\n /** Handles subscription data. For internal use only. */\n onSubscription(subscriptionData: any) {\n this.members = subscriptionData.presence.hash;\n this.count = subscriptionData.presence.count;\n this.me = this.get(this.myID);\n }\n\n /** Adds a new member to the collection. For internal use only. */\n addMember(memberData: any) {\n if (this.get(memberData.user_id) === null) {\n this.count++;\n }\n this.members[memberData.user_id] = memberData.user_info;\n return this.get(memberData.user_id);\n }\n\n /** Adds a member from the collection. For internal use only. */\n removeMember(memberData: any) {\n var member = this.get(memberData.user_id);\n if (member) {\n delete this.members[memberData.user_id];\n this.count--;\n }\n return member;\n }\n\n /** Resets the collection to the initial state. For internal use only. */\n reset() {\n this.members = {};\n this.count = 0;\n this.myID = null;\n this.me = null;\n }\n}\n","import PrivateChannel from './private_channel';\nimport Logger from '../logger';\nimport Members from './members';\nimport Pusher from '../pusher';\nimport UrlStore from 'core/utils/url_store';\nimport { PusherEvent } from '../connection/protocol/message-types';\nimport Metadata from './metadata';\nimport { ChannelAuthorizationData } from '../auth/options';\n\nexport default class PresenceChannel extends PrivateChannel {\n members: Members;\n\n /** Adds presence channel functionality to private channels.\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\n constructor(name: string, pusher: Pusher) {\n super(name, pusher);\n this.members = new Members();\n }\n\n /** Authorizes the connection as a member of the channel.\n *\n * @param {String} socketId\n * @param {Function} callback\n */\n authorize(socketId: string, callback: Function) {\n super.authorize(socketId, async (error, authData) => {\n if (!error) {\n authData = authData as ChannelAuthorizationData;\n if (authData.channel_data != null) {\n var channelData = JSON.parse(authData.channel_data);\n this.members.setMyID(channelData.user_id);\n } else {\n await this.pusher.user.signinDonePromise;\n if (this.pusher.user.user_data != null) {\n // If the user is signed in, get the id of the authenticated user\n // and allow the presence authorization to continue.\n this.members.setMyID(this.pusher.user.user_data.id);\n } else {\n let suffix = UrlStore.buildLogSuffix('authorizationEndpoint');\n Logger.error(\n `Invalid auth response for channel '${this.name}', ` +\n `expected 'channel_data' field. ${suffix}, ` +\n `or the user should be signed in.`\n );\n callback('Invalid auth response');\n return;\n }\n }\n }\n callback(error, authData);\n });\n }\n\n /** Handles presence and subscription events. For internal use only.\n *\n * @param {PusherEvent} event\n */\n handleEvent(event: PusherEvent) {\n var eventName = event.event;\n if (eventName.indexOf('pusher_internal:') === 0) {\n this.handleInternalEvent(event);\n } else {\n var data = event.data;\n var metadata: Metadata = {};\n if (event.user_id) {\n metadata.user_id = event.user_id;\n }\n this.emit(eventName, data, metadata);\n }\n }\n handleInternalEvent(event: PusherEvent) {\n var eventName = event.event;\n var data = event.data;\n switch (eventName) {\n case 'pusher_internal:subscription_succeeded':\n this.handleSubscriptionSucceededEvent(event);\n break;\n case 'pusher_internal:subscription_count':\n this.handleSubscriptionCountEvent(event);\n break;\n case 'pusher_internal:member_added':\n var addedMember = this.members.addMember(data);\n this.emit('pusher:member_added', addedMember);\n break;\n case 'pusher_internal:member_removed':\n var removedMember = this.members.removeMember(data);\n if (removedMember) {\n this.emit('pusher:member_removed', removedMember);\n }\n break;\n }\n }\n\n handleSubscriptionSucceededEvent(event: PusherEvent) {\n this.subscriptionPending = false;\n this.subscribed = true;\n if (this.subscriptionCancelled) {\n this.pusher.unsubscribe(this.name);\n } else {\n this.members.onSubscription(event.data);\n this.emit('pusher:subscription_succeeded', this.members);\n }\n }\n\n /** Resets the channel state, including members map. For internal use only. */\n disconnect() {\n this.members.reset();\n super.disconnect();\n }\n}\n","import PrivateChannel from './private_channel';\nimport * as Errors from '../errors';\nimport Logger from '../logger';\nimport Pusher from '../pusher';\nimport { decode as encodeUTF8 } from '@stablelib/utf8';\nimport { decode as decodeBase64 } from '@stablelib/base64';\nimport Dispatcher from '../events/dispatcher';\nimport { PusherEvent } from '../connection/protocol/message-types';\nimport {\n ChannelAuthorizationData,\n ChannelAuthorizationCallback\n} from '../auth/options';\nimport * as nacl from 'tweetnacl';\n\n/** Extends private channels to provide encrypted channel interface.\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\nexport default class EncryptedChannel extends PrivateChannel {\n key: Uint8Array = null;\n nacl: nacl;\n\n constructor(name: string, pusher: Pusher, nacl: nacl) {\n super(name, pusher);\n this.nacl = nacl;\n }\n\n /** Authorizes the connection to use the channel.\n *\n * @param {String} socketId\n * @param {Function} callback\n */\n authorize(socketId: string, callback: ChannelAuthorizationCallback) {\n super.authorize(\n socketId,\n (error: Error | null, authData: ChannelAuthorizationData) => {\n if (error) {\n callback(error, authData);\n return;\n }\n let sharedSecret = authData['shared_secret'];\n if (!sharedSecret) {\n callback(\n new Error(\n `No shared_secret key in auth payload for encrypted channel: ${this.name}`\n ),\n null\n );\n return;\n }\n this.key = decodeBase64(sharedSecret);\n delete authData['shared_secret'];\n callback(null, authData);\n }\n );\n }\n\n trigger(event: string, data: any): boolean {\n throw new Errors.UnsupportedFeature(\n 'Client events are not currently supported for encrypted channels'\n );\n }\n\n /** Handles an event. For internal use only.\n *\n * @param {PusherEvent} event\n */\n handleEvent(event: PusherEvent) {\n var eventName = event.event;\n var data = event.data;\n if (\n eventName.indexOf('pusher_internal:') === 0 ||\n eventName.indexOf('pusher:') === 0\n ) {\n super.handleEvent(event);\n return;\n }\n this.handleEncryptedEvent(eventName, data);\n }\n\n private handleEncryptedEvent(event: string, data: any): void {\n if (!this.key) {\n Logger.debug(\n 'Received encrypted event before key has been retrieved from the authEndpoint'\n );\n return;\n }\n if (!data.ciphertext || !data.nonce) {\n Logger.error(\n 'Unexpected format for encrypted event, expected object with `ciphertext` and `nonce` fields, got: ' +\n data\n );\n return;\n }\n let cipherText = decodeBase64(data.ciphertext);\n if (cipherText.length < this.nacl.secretbox.overheadLength) {\n Logger.error(\n `Expected encrypted event ciphertext length to be ${this.nacl.secretbox.overheadLength}, got: ${cipherText.length}`\n );\n return;\n }\n let nonce = decodeBase64(data.nonce);\n if (nonce.length < this.nacl.secretbox.nonceLength) {\n Logger.error(\n `Expected encrypted event nonce length to be ${this.nacl.secretbox.nonceLength}, got: ${nonce.length}`\n );\n return;\n }\n\n let bytes = this.nacl.secretbox.open(cipherText, nonce, this.key);\n if (bytes === null) {\n Logger.debug(\n 'Failed to decrypt an event, probably because it was encrypted with a different key. Fetching a new key from the authEndpoint...'\n );\n // Try a single time to retrieve a new auth key and decrypt the event with it\n // If this fails, a new key will be requested when a new message is received\n this.authorize(this.pusher.connection.socket_id, (error, authData) => {\n if (error) {\n Logger.error(\n `Failed to make a request to the authEndpoint: ${authData}. Unable to fetch new key, so dropping encrypted event`\n );\n return;\n }\n bytes = this.nacl.secretbox.open(cipherText, nonce, this.key);\n if (bytes === null) {\n Logger.error(\n `Failed to decrypt event with new key. Dropping encrypted event`\n );\n return;\n }\n this.emit(event, this.getDataToEmit(bytes));\n return;\n });\n return;\n }\n this.emit(event, this.getDataToEmit(bytes));\n }\n\n // Try and parse the decrypted bytes as JSON. If we can't parse it, just\n // return the utf-8 string\n getDataToEmit(bytes: Uint8Array): string {\n let raw = encodeUTF8(bytes);\n try {\n return JSON.parse(raw);\n } catch {\n return raw;\n }\n }\n}\n","import { default as EventsDispatcher } from '../events/dispatcher';\nimport { OneOffTimer as Timer } from '../utils/timers';\nimport { Config } from '../config';\nimport Logger from '../logger';\nimport HandshakePayload from './handshake/handshake_payload';\nimport Connection from './connection';\nimport Strategy from '../strategies/strategy';\nimport StrategyRunner from '../strategies/strategy_runner';\nimport * as Collections from '../utils/collections';\nimport Timeline from '../timeline/timeline';\nimport ConnectionManagerOptions from './connection_manager_options';\nimport Runtime from 'runtime';\n\nimport {\n ErrorCallbacks,\n HandshakeCallbacks,\n ConnectionCallbacks\n} from './callbacks';\nimport Action from './protocol/action';\n\n/** Manages connection to Pusher.\n *\n * Uses a strategy (currently only default), timers and network availability\n * info to establish a connection and export its state. In case of failures,\n * manages reconnection attempts.\n *\n * Exports state changes as following events:\n * - \"state_change\", { previous: p, current: state }\n * - state\n *\n * States:\n * - initialized - initial state, never transitioned to\n * - connecting - connection is being established\n * - connected - connection has been fully established\n * - disconnected - on requested disconnection\n * - unavailable - after connection timeout or when there's no network\n * - failed - when the connection strategy is not supported\n *\n * Options:\n * - unavailableTimeout - time to transition to unavailable state\n * - activityTimeout - time after which ping message should be sent\n * - pongTimeout - time for Pusher to respond with pong before reconnecting\n *\n * @param {String} key application key\n * @param {Object} options\n */\nexport default class ConnectionManager extends EventsDispatcher {\n key: string;\n options: ConnectionManagerOptions;\n state: string;\n connection: Connection;\n usingTLS: boolean;\n timeline: Timeline;\n socket_id: string;\n unavailableTimer: Timer;\n activityTimer: Timer;\n retryTimer: Timer;\n activityTimeout: number;\n strategy: Strategy;\n runner: StrategyRunner;\n errorCallbacks: ErrorCallbacks;\n handshakeCallbacks: HandshakeCallbacks;\n connectionCallbacks: ConnectionCallbacks;\n\n constructor(key: string, options: ConnectionManagerOptions) {\n super();\n this.state = 'initialized';\n this.connection = null;\n\n this.key = key;\n this.options = options;\n this.timeline = this.options.timeline;\n this.usingTLS = this.options.useTLS;\n\n this.errorCallbacks = this.buildErrorCallbacks();\n this.connectionCallbacks = this.buildConnectionCallbacks(\n this.errorCallbacks\n );\n this.handshakeCallbacks = this.buildHandshakeCallbacks(this.errorCallbacks);\n\n var Network = Runtime.getNetwork();\n\n Network.bind('online', () => {\n this.timeline.info({ netinfo: 'online' });\n if (this.state === 'connecting' || this.state === 'unavailable') {\n this.retryIn(0);\n }\n });\n Network.bind('offline', () => {\n this.timeline.info({ netinfo: 'offline' });\n if (this.connection) {\n this.sendActivityCheck();\n }\n });\n\n this.updateStrategy();\n }\n\n switchCluster(key: string) {\n this.key = key;\n // This ensures that the new config coming from\n // pusher instance are taken into account\n // such as appKey and cluster\n this.updateStrategy();\n this.retryIn(0);\n }\n\n /** Establishes a connection to Pusher.\n *\n * Does nothing when connection is already established. See top-level doc\n * to find events emitted on connection attempts.\n */\n connect() {\n if (this.connection || this.runner) {\n return;\n }\n if (!this.strategy.isSupported()) {\n this.updateState('failed');\n return;\n }\n this.updateState('connecting');\n this.startConnecting();\n this.setUnavailableTimer();\n }\n\n /** Sends raw data.\n *\n * @param {String} data\n */\n send(data) {\n if (this.connection) {\n return this.connection.send(data);\n } else {\n return false;\n }\n }\n\n /** Sends an event.\n *\n * @param {String} name\n * @param {String} data\n * @param {String} [channel]\n * @returns {Boolean} whether message was sent or not\n */\n send_event(name: string, data: any, channel?: string) {\n if (this.connection) {\n return this.connection.send_event(name, data, channel);\n } else {\n return false;\n }\n }\n\n /** Closes the connection. */\n disconnect() {\n this.disconnectInternally();\n this.updateState('disconnected');\n }\n\n isUsingTLS() {\n return this.usingTLS;\n }\n\n private startConnecting() {\n var callback = (error, handshake) => {\n if (error) {\n this.runner = this.strategy.connect(0, callback);\n } else {\n if (handshake.action === 'error') {\n this.emit('error', {\n type: 'HandshakeError',\n error: handshake.error\n });\n this.timeline.error({ handshakeError: handshake.error });\n } else {\n this.abortConnecting(); // we don't support switching connections yet\n this.handshakeCallbacks[handshake.action](handshake);\n }\n }\n };\n this.runner = this.strategy.connect(0, callback);\n }\n\n private abortConnecting() {\n if (this.runner) {\n this.runner.abort();\n this.runner = null;\n }\n }\n\n private disconnectInternally() {\n this.abortConnecting();\n this.clearRetryTimer();\n this.clearUnavailableTimer();\n if (this.connection) {\n var connection = this.abandonConnection();\n connection.close();\n }\n }\n\n private updateStrategy() {\n this.strategy = this.options.getStrategy({\n key: this.key,\n timeline: this.timeline,\n useTLS: this.usingTLS\n });\n }\n\n private retryIn(delay) {\n this.timeline.info({ action: 'retry', delay: delay });\n if (delay > 0) {\n this.emit('connecting_in', Math.round(delay / 1000));\n }\n this.retryTimer = new Timer(delay || 0, () => {\n this.disconnectInternally();\n this.connect();\n });\n }\n\n private clearRetryTimer() {\n if (this.retryTimer) {\n this.retryTimer.ensureAborted();\n this.retryTimer = null;\n }\n }\n\n private setUnavailableTimer() {\n this.unavailableTimer = new Timer(this.options.unavailableTimeout, () => {\n this.updateState('unavailable');\n });\n }\n\n private clearUnavailableTimer() {\n if (this.unavailableTimer) {\n this.unavailableTimer.ensureAborted();\n }\n }\n\n private sendActivityCheck() {\n this.stopActivityCheck();\n this.connection.ping();\n // wait for pong response\n this.activityTimer = new Timer(this.options.pongTimeout, () => {\n this.timeline.error({ pong_timed_out: this.options.pongTimeout });\n this.retryIn(0);\n });\n }\n\n private resetActivityCheck() {\n this.stopActivityCheck();\n // send ping after inactivity\n if (this.connection && !this.connection.handlesActivityChecks()) {\n this.activityTimer = new Timer(this.activityTimeout, () => {\n this.sendActivityCheck();\n });\n }\n }\n\n private stopActivityCheck() {\n if (this.activityTimer) {\n this.activityTimer.ensureAborted();\n }\n }\n\n private buildConnectionCallbacks(\n errorCallbacks: ErrorCallbacks\n ): ConnectionCallbacks {\n return Collections.extend({}, errorCallbacks, {\n message: message => {\n // includes pong messages from server\n this.resetActivityCheck();\n this.emit('message', message);\n },\n ping: () => {\n this.send_event('pusher:pong', {});\n },\n activity: () => {\n this.resetActivityCheck();\n },\n error: error => {\n // just emit error to user - socket will already be closed by browser\n this.emit('error', error);\n },\n closed: () => {\n this.abandonConnection();\n if (this.shouldRetry()) {\n this.retryIn(1000);\n }\n }\n });\n }\n\n private buildHandshakeCallbacks(\n errorCallbacks: ErrorCallbacks\n ): HandshakeCallbacks {\n return Collections.extend({}, errorCallbacks, {\n connected: (handshake: HandshakePayload) => {\n this.activityTimeout = Math.min(\n this.options.activityTimeout,\n handshake.activityTimeout,\n handshake.connection.activityTimeout || Infinity\n );\n this.clearUnavailableTimer();\n this.setConnection(handshake.connection);\n this.socket_id = this.connection.id;\n this.updateState('connected', { socket_id: this.socket_id });\n }\n });\n }\n\n private buildErrorCallbacks(): ErrorCallbacks {\n let withErrorEmitted = callback => {\n return (result: Action | HandshakePayload) => {\n if (result.error) {\n this.emit('error', { type: 'WebSocketError', error: result.error });\n }\n callback(result);\n };\n };\n\n return {\n tls_only: withErrorEmitted(() => {\n this.usingTLS = true;\n this.updateStrategy();\n this.retryIn(0);\n }),\n refused: withErrorEmitted(() => {\n this.disconnect();\n }),\n backoff: withErrorEmitted(() => {\n this.retryIn(1000);\n }),\n retry: withErrorEmitted(() => {\n this.retryIn(0);\n })\n };\n }\n\n private setConnection(connection) {\n this.connection = connection;\n for (var event in this.connectionCallbacks) {\n this.connection.bind(event, this.connectionCallbacks[event]);\n }\n this.resetActivityCheck();\n }\n\n private abandonConnection() {\n if (!this.connection) {\n return;\n }\n this.stopActivityCheck();\n for (var event in this.connectionCallbacks) {\n this.connection.unbind(event, this.connectionCallbacks[event]);\n }\n var connection = this.connection;\n this.connection = null;\n return connection;\n }\n\n private updateState(newState: string, data?: any) {\n var previousState = this.state;\n this.state = newState;\n if (previousState !== newState) {\n var newStateDescription = newState;\n if (newStateDescription === 'connected') {\n newStateDescription += ' with new socket ID ' + data.socket_id;\n }\n Logger.debug(\n 'State changed',\n previousState + ' -> ' + newStateDescription\n );\n this.timeline.info({ state: newState, params: data });\n this.emit('state_change', { previous: previousState, current: newState });\n this.emit(newState, data);\n }\n }\n\n private shouldRetry(): boolean {\n return this.state === 'connecting' || this.state === 'connected';\n }\n}\n","import Channel from './channel';\nimport * as Collections from '../utils/collections';\nimport ChannelTable from './channel_table';\nimport Factory from '../utils/factory';\nimport Pusher from '../pusher';\nimport Logger from '../logger';\nimport * as Errors from '../errors';\nimport urlStore from '../utils/url_store';\n\n/** Handles a channel map. */\nexport default class Channels {\n channels: ChannelTable;\n\n constructor() {\n this.channels = {};\n }\n\n /** Creates or retrieves an existing channel by its name.\n *\n * @param {String} name\n * @param {Pusher} pusher\n * @return {Channel}\n */\n add(name: string, pusher: Pusher) {\n if (!this.channels[name]) {\n this.channels[name] = createChannel(name, pusher);\n }\n return this.channels[name];\n }\n\n /** Returns a list of all channels\n *\n * @return {Array}\n */\n all(): Channel[] {\n return Collections.values(this.channels);\n }\n\n /** Finds a channel by its name.\n *\n * @param {String} name\n * @return {Channel} channel or null if it doesn't exist\n */\n find(name: string) {\n return this.channels[name];\n }\n\n /** Removes a channel from the map.\n *\n * @param {String} name\n */\n remove(name: string) {\n var channel = this.channels[name];\n delete this.channels[name];\n return channel;\n }\n\n /** Proxies disconnection signal to all channels. */\n disconnect() {\n Collections.objectApply(this.channels, function(channel) {\n channel.disconnect();\n });\n }\n}\n\nfunction createChannel(name: string, pusher: Pusher): Channel {\n if (name.indexOf('private-encrypted-') === 0) {\n if (pusher.config.nacl) {\n return Factory.createEncryptedChannel(name, pusher, pusher.config.nacl);\n }\n let errMsg =\n 'Tried to subscribe to a private-encrypted- channel but no nacl implementation available';\n let suffix = urlStore.buildLogSuffix('encryptedChannelSupport');\n throw new Errors.UnsupportedFeature(`${errMsg}. ${suffix}`);\n } else if (name.indexOf('private-') === 0) {\n return Factory.createPrivateChannel(name, pusher);\n } else if (name.indexOf('presence-') === 0) {\n return Factory.createPresenceChannel(name, pusher);\n } else if (name.indexOf('#') === 0) {\n throw new Errors.BadChannelName(\n 'Cannot create a channel with name \"' + name + '\".'\n );\n } else {\n return Factory.createChannel(name, pusher);\n }\n}\n","import AssistantToTheTransportManager from '../transports/assistant_to_the_transport_manager';\nimport PingDelayOptions from '../transports/ping_delay_options';\nimport Transport from '../transports/transport';\nimport TransportManager from '../transports/transport_manager';\nimport Handshake from '../connection/handshake';\nimport TransportConnection from '../transports/transport_connection';\nimport SocketHooks from '../http/socket_hooks';\nimport HTTPSocket from '../http/http_socket';\n\nimport Timeline from '../timeline/timeline';\nimport {\n default as TimelineSender,\n TimelineSenderOptions\n} from '../timeline/timeline_sender';\nimport PresenceChannel from '../channels/presence_channel';\nimport PrivateChannel from '../channels/private_channel';\nimport EncryptedChannel from '../channels/encrypted_channel';\nimport Channel from '../channels/channel';\nimport ConnectionManager from '../connection/connection_manager';\nimport ConnectionManagerOptions from '../connection/connection_manager_options';\nimport Ajax from '../http/ajax';\nimport Channels from '../channels/channels';\nimport Pusher from '../pusher';\nimport { Config } from '../config';\nimport * as nacl from 'tweetnacl';\n\nvar Factory = {\n createChannels(): Channels {\n return new Channels();\n },\n\n createConnectionManager(\n key: string,\n options: ConnectionManagerOptions\n ): ConnectionManager {\n return new ConnectionManager(key, options);\n },\n\n createChannel(name: string, pusher: Pusher): Channel {\n return new Channel(name, pusher);\n },\n\n createPrivateChannel(name: string, pusher: Pusher): PrivateChannel {\n return new PrivateChannel(name, pusher);\n },\n\n createPresenceChannel(name: string, pusher: Pusher): PresenceChannel {\n return new PresenceChannel(name, pusher);\n },\n\n createEncryptedChannel(\n name: string,\n pusher: Pusher,\n nacl: nacl\n ): EncryptedChannel {\n return new EncryptedChannel(name, pusher, nacl);\n },\n\n createTimelineSender(timeline: Timeline, options: TimelineSenderOptions) {\n return new TimelineSender(timeline, options);\n },\n\n createHandshake(\n transport: TransportConnection,\n callback: (HandshakePayload) => void\n ): Handshake {\n return new Handshake(transport, callback);\n },\n\n createAssistantToTheTransportManager(\n manager: TransportManager,\n transport: Transport,\n options: PingDelayOptions\n ): AssistantToTheTransportManager {\n return new AssistantToTheTransportManager(manager, transport, options);\n }\n};\n\nexport default Factory;\n","import AssistantToTheTransportManager from './assistant_to_the_transport_manager';\nimport Transport from './transport';\nimport PingDelayOptions from './ping_delay_options';\nimport Factory from '../utils/factory';\n\nexport interface TransportManagerOptions extends PingDelayOptions {\n lives?: number;\n}\n\n/** Keeps track of the number of lives left for a transport.\n *\n * In the beginning of a session, transports may be assigned a number of\n * lives. When an AssistantToTheTransportManager instance reports a transport\n * connection closed uncleanly, the transport loses a life. When the number\n * of lives drops to zero, the transport gets disabled by its manager.\n *\n * @param {Object} options\n */\nexport default class TransportManager {\n options: TransportManagerOptions;\n livesLeft: number;\n\n constructor(options: TransportManagerOptions) {\n this.options = options || {};\n this.livesLeft = this.options.lives || Infinity;\n }\n\n /** Creates a assistant for the transport.\n *\n * @param {Transport} transport\n * @returns {AssistantToTheTransportManager}\n */\n getAssistant(transport: Transport): AssistantToTheTransportManager {\n return Factory.createAssistantToTheTransportManager(this, transport, {\n minPingDelay: this.options.minPingDelay,\n maxPingDelay: this.options.maxPingDelay\n });\n }\n\n /** Returns whether the transport has any lives left.\n *\n * @returns {Boolean}\n */\n isAlive(): boolean {\n return this.livesLeft > 0;\n }\n\n /** Takes one life from the transport. */\n reportDeath() {\n this.livesLeft -= 1;\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport { OneOffTimer as Timer } from '../utils/timers';\nimport Strategy from './strategy';\nimport StrategyOptions from './strategy_options';\n\n/** Loops through strategies with optional timeouts.\n *\n * Options:\n * - loop - whether it should loop through the substrategy list\n * - timeout - initial timeout for a single substrategy\n * - timeoutLimit - maximum timeout\n *\n * @param {Strategy[]} strategies\n * @param {Object} options\n */\nexport default class SequentialStrategy implements Strategy {\n strategies: Strategy[];\n loop: boolean;\n failFast: boolean;\n timeout: number;\n timeoutLimit: number;\n\n constructor(strategies: Strategy[], options: StrategyOptions) {\n this.strategies = strategies;\n this.loop = Boolean(options.loop);\n this.failFast = Boolean(options.failFast);\n this.timeout = options.timeout;\n this.timeoutLimit = options.timeoutLimit;\n }\n\n isSupported(): boolean {\n return Collections.any(this.strategies, Util.method('isSupported'));\n }\n\n connect(minPriority: number, callback: Function) {\n var strategies = this.strategies;\n var current = 0;\n var timeout = this.timeout;\n var runner = null;\n\n var tryNextStrategy = (error, handshake) => {\n if (handshake) {\n callback(null, handshake);\n } else {\n current = current + 1;\n if (this.loop) {\n current = current % strategies.length;\n }\n\n if (current < strategies.length) {\n if (timeout) {\n timeout = timeout * 2;\n if (this.timeoutLimit) {\n timeout = Math.min(timeout, this.timeoutLimit);\n }\n }\n runner = this.tryStrategy(\n strategies[current],\n minPriority,\n { timeout, failFast: this.failFast },\n tryNextStrategy\n );\n } else {\n callback(true);\n }\n }\n };\n\n runner = this.tryStrategy(\n strategies[current],\n minPriority,\n { timeout: timeout, failFast: this.failFast },\n tryNextStrategy\n );\n\n return {\n abort: function() {\n runner.abort();\n },\n forceMinPriority: function(p) {\n minPriority = p;\n if (runner) {\n runner.forceMinPriority(p);\n }\n }\n };\n }\n\n private tryStrategy(\n strategy: Strategy,\n minPriority: number,\n options: StrategyOptions,\n callback: Function\n ) {\n var timer = null;\n var runner = null;\n\n if (options.timeout > 0) {\n timer = new Timer(options.timeout, function() {\n runner.abort();\n callback(true);\n });\n }\n\n runner = strategy.connect(minPriority, function(error, handshake) {\n if (error && timer && timer.isRunning() && !options.failFast) {\n // advance to the next strategy after the timeout\n return;\n }\n if (timer) {\n timer.ensureAborted();\n }\n callback(error, handshake);\n });\n\n return {\n abort: function() {\n if (timer) {\n timer.ensureAborted();\n }\n runner.abort();\n },\n forceMinPriority: function(p) {\n runner.forceMinPriority(p);\n }\n };\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport Strategy from './strategy';\n\n/** Launches all substrategies and emits prioritized connected transports.\n *\n * @param {Array} strategies\n */\nexport default class BestConnectedEverStrategy implements Strategy {\n strategies: Strategy[];\n\n constructor(strategies: Strategy[]) {\n this.strategies = strategies;\n }\n\n isSupported(): boolean {\n return Collections.any(this.strategies, Util.method('isSupported'));\n }\n\n connect(minPriority: number, callback: Function) {\n return connect(this.strategies, minPriority, function(i, runners) {\n return function(error, handshake) {\n runners[i].error = error;\n if (error) {\n if (allRunnersFailed(runners)) {\n callback(true);\n }\n return;\n }\n Collections.apply(runners, function(runner) {\n runner.forceMinPriority(handshake.transport.priority);\n });\n callback(null, handshake);\n };\n });\n }\n}\n\n/** Connects to all strategies in parallel.\n *\n * Callback builder should be a function that takes two arguments: index\n * and a list of runners. It should return another function that will be\n * passed to the substrategy with given index. Runners can be aborted using\n * abortRunner(s) functions from this class.\n *\n * @param {Array} strategies\n * @param {Function} callbackBuilder\n * @return {Object} strategy runner\n */\nfunction connect(\n strategies: Strategy[],\n minPriority: number,\n callbackBuilder: Function\n) {\n var runners = Collections.map(strategies, function(strategy, i, _, rs) {\n return strategy.connect(minPriority, callbackBuilder(i, rs));\n });\n return {\n abort: function() {\n Collections.apply(runners, abortRunner);\n },\n forceMinPriority: function(p) {\n Collections.apply(runners, function(runner) {\n runner.forceMinPriority(p);\n });\n }\n };\n}\n\nfunction allRunnersFailed(runners): boolean {\n return Collections.all(runners, function(runner) {\n return Boolean(runner.error);\n });\n}\n\nfunction abortRunner(runner) {\n if (!runner.error && !runner.aborted) {\n runner.abort();\n runner.aborted = true;\n }\n}\n","import Util from '../util';\nimport Runtime from 'runtime';\nimport Strategy from './strategy';\nimport SequentialStrategy from './sequential_strategy';\nimport StrategyOptions from './strategy_options';\nimport TransportStrategy from './transport_strategy';\nimport Timeline from '../timeline/timeline';\nimport * as Collections from '../utils/collections';\n\nexport interface TransportStrategyDictionary {\n [key: string]: TransportStrategy;\n}\n\n/** Caches the last successful transport and, after the first few attempts,\n * uses the cached transport for subsequent attempts.\n *\n * @param {Strategy} strategy\n * @param {Object} transports\n * @param {Object} options\n */\nexport default class WebSocketPrioritizedCachedStrategy implements Strategy {\n strategy: Strategy;\n transports: TransportStrategyDictionary;\n ttl: number;\n usingTLS: boolean;\n timeline: Timeline;\n\n constructor(\n strategy: Strategy,\n transports: TransportStrategyDictionary,\n options: StrategyOptions\n ) {\n this.strategy = strategy;\n this.transports = transports;\n this.ttl = options.ttl || 1800 * 1000;\n this.usingTLS = options.useTLS;\n this.timeline = options.timeline;\n }\n\n isSupported(): boolean {\n return this.strategy.isSupported();\n }\n\n connect(minPriority: number, callback: Function) {\n var usingTLS = this.usingTLS;\n var info = fetchTransportCache(usingTLS);\n var cacheSkipCount = info && info.cacheSkipCount ? info.cacheSkipCount : 0;\n\n var strategies = [this.strategy];\n if (info && info.timestamp + this.ttl >= Util.now()) {\n var transport = this.transports[info.transport];\n if (transport) {\n if (['ws', 'wss'].includes(info.transport) || cacheSkipCount > 3) {\n this.timeline.info({\n cached: true,\n transport: info.transport,\n latency: info.latency\n });\n strategies.push(\n new SequentialStrategy([transport], {\n timeout: info.latency * 2 + 1000,\n failFast: true\n })\n );\n } else {\n cacheSkipCount++;\n }\n }\n }\n\n var startTimestamp = Util.now();\n var runner = strategies\n .pop()\n .connect(minPriority, function cb(error, handshake) {\n if (error) {\n flushTransportCache(usingTLS);\n if (strategies.length > 0) {\n startTimestamp = Util.now();\n runner = strategies.pop().connect(minPriority, cb);\n } else {\n callback(error);\n }\n } else {\n storeTransportCache(\n usingTLS,\n handshake.transport.name,\n Util.now() - startTimestamp,\n cacheSkipCount\n );\n callback(null, handshake);\n }\n });\n\n return {\n abort: function() {\n runner.abort();\n },\n forceMinPriority: function(p) {\n minPriority = p;\n if (runner) {\n runner.forceMinPriority(p);\n }\n }\n };\n }\n}\n\nfunction getTransportCacheKey(usingTLS: boolean): string {\n return 'pusherTransport' + (usingTLS ? 'TLS' : 'NonTLS');\n}\n\nfunction fetchTransportCache(usingTLS: boolean): any {\n var storage = Runtime.getLocalStorage();\n if (storage) {\n try {\n var serializedCache = storage[getTransportCacheKey(usingTLS)];\n if (serializedCache) {\n return JSON.parse(serializedCache);\n }\n } catch (e) {\n flushTransportCache(usingTLS);\n }\n }\n return null;\n}\n\nfunction storeTransportCache(\n usingTLS: boolean,\n transport: TransportStrategy,\n latency: number,\n cacheSkipCount: number\n) {\n var storage = Runtime.getLocalStorage();\n if (storage) {\n try {\n storage[getTransportCacheKey(usingTLS)] = Collections.safeJSONStringify({\n timestamp: Util.now(),\n transport: transport,\n latency: latency,\n cacheSkipCount: cacheSkipCount\n });\n } catch (e) {\n // catch over quota exceptions raised by localStorage\n }\n }\n}\n\nfunction flushTransportCache(usingTLS: boolean) {\n var storage = Runtime.getLocalStorage();\n if (storage) {\n try {\n delete storage[getTransportCacheKey(usingTLS)];\n } catch (e) {\n // catch exceptions raised by localStorage\n }\n }\n}\n","import { OneOffTimer as Timer } from '../utils/timers';\nimport Strategy from './strategy';\nimport StrategyOptions from './strategy_options';\n\n/** Runs substrategy after specified delay.\n *\n * Options:\n * - delay - time in miliseconds to delay the substrategy attempt\n *\n * @param {Strategy} strategy\n * @param {Object} options\n */\nexport default class DelayedStrategy implements Strategy {\n strategy: Strategy;\n options: { delay: number };\n\n constructor(strategy: Strategy, { delay: number }) {\n this.strategy = strategy;\n this.options = { delay: number };\n }\n\n isSupported(): boolean {\n return this.strategy.isSupported();\n }\n\n connect(minPriority: number, callback: Function) {\n var strategy = this.strategy;\n var runner;\n var timer = new Timer(this.options.delay, function() {\n runner = strategy.connect(minPriority, callback);\n });\n\n return {\n abort: function() {\n timer.ensureAborted();\n if (runner) {\n runner.abort();\n }\n },\n forceMinPriority: function(p) {\n minPriority = p;\n if (runner) {\n runner.forceMinPriority(p);\n }\n }\n };\n }\n}\n","import Strategy from './strategy';\nimport StrategyRunner from './strategy_runner';\n\n/** Proxies method calls to one of substrategies basing on the test function.\n *\n * @param {Function} test\n * @param {Strategy} trueBranch strategy used when test returns true\n * @param {Strategy} falseBranch strategy used when test returns false\n */\nexport default class IfStrategy implements Strategy {\n test: () => boolean;\n trueBranch: Strategy;\n falseBranch: Strategy;\n\n constructor(\n test: () => boolean,\n trueBranch: Strategy,\n falseBranch: Strategy\n ) {\n this.test = test;\n this.trueBranch = trueBranch;\n this.falseBranch = falseBranch;\n }\n\n isSupported(): boolean {\n var branch = this.test() ? this.trueBranch : this.falseBranch;\n return branch.isSupported();\n }\n\n connect(minPriority: number, callback: Function): StrategyRunner {\n var branch = this.test() ? this.trueBranch : this.falseBranch;\n return branch.connect(minPriority, callback);\n }\n}\n","import Strategy from './strategy';\nimport StrategyRunner from './strategy_runner';\n\n/** Launches the substrategy and terminates on the first open connection.\n *\n * @param {Strategy} strategy\n */\nexport default class FirstConnectedStrategy implements Strategy {\n strategy: Strategy;\n\n constructor(strategy: Strategy) {\n this.strategy = strategy;\n }\n\n isSupported(): boolean {\n return this.strategy.isSupported();\n }\n\n connect(minPriority: number, callback: Function): StrategyRunner {\n var runner = this.strategy.connect(minPriority, function(error, handshake) {\n if (handshake) {\n runner.abort();\n }\n callback(error, handshake);\n });\n return runner;\n }\n}\n","import * as Collections from 'core/utils/collections';\nimport TransportManager from 'core/transports/transport_manager';\nimport Strategy from 'core/strategies/strategy';\nimport SequentialStrategy from 'core/strategies/sequential_strategy';\nimport BestConnectedEverStrategy from 'core/strategies/best_connected_ever_strategy';\nimport WebSocketPrioritizedCachedStrategy, {\n TransportStrategyDictionary\n} from 'core/strategies/websocket_prioritized_cached_strategy';\nimport DelayedStrategy from 'core/strategies/delayed_strategy';\nimport IfStrategy from 'core/strategies/if_strategy';\nimport FirstConnectedStrategy from 'core/strategies/first_connected_strategy';\nimport { Config } from 'core/config';\nimport StrategyOptions from 'core/strategies/strategy_options';\n\nfunction testSupportsStrategy(strategy: Strategy) {\n return function() {\n return strategy.isSupported();\n };\n}\n\nvar getDefaultStrategy = function(\n config: Config,\n baseOptions: StrategyOptions,\n defineTransport: Function\n): Strategy {\n var definedTransports = {};\n\n function defineTransportStrategy(\n name: string,\n type: string,\n priority: number,\n options: StrategyOptions,\n manager?: TransportManager\n ) {\n var transport = defineTransport(\n config,\n name,\n type,\n priority,\n options,\n manager\n );\n\n definedTransports[name] = transport;\n\n return transport;\n }\n\n var ws_options: StrategyOptions = Object.assign({}, baseOptions, {\n hostNonTLS: config.wsHost + ':' + config.wsPort,\n hostTLS: config.wsHost + ':' + config.wssPort,\n httpPath: config.wsPath\n });\n var wss_options: StrategyOptions = Collections.extend({}, ws_options, {\n useTLS: true\n });\n var http_options: StrategyOptions = Object.assign({}, baseOptions, {\n hostNonTLS: config.httpHost + ':' + config.httpPort,\n hostTLS: config.httpHost + ':' + config.httpsPort,\n httpPath: config.httpPath\n });\n var timeouts = {\n loop: true,\n timeout: 15000,\n timeoutLimit: 60000\n };\n\n var ws_manager = new TransportManager({\n minPingDelay: 10000,\n maxPingDelay: config.activityTimeout\n });\n var streaming_manager = new TransportManager({\n lives: 2,\n minPingDelay: 10000,\n maxPingDelay: config.activityTimeout\n });\n\n var ws_transport = defineTransportStrategy(\n 'ws',\n 'ws',\n 3,\n ws_options,\n ws_manager\n );\n var wss_transport = defineTransportStrategy(\n 'wss',\n 'ws',\n 3,\n wss_options,\n ws_manager\n );\n var xhr_streaming_transport = defineTransportStrategy(\n 'xhr_streaming',\n 'xhr_streaming',\n 1,\n http_options,\n streaming_manager\n );\n var xhr_polling_transport = defineTransportStrategy(\n 'xhr_polling',\n 'xhr_polling',\n 1,\n http_options\n );\n\n var ws_loop = new SequentialStrategy([ws_transport], timeouts);\n var wss_loop = new SequentialStrategy([wss_transport], timeouts);\n var streaming_loop = new SequentialStrategy(\n [xhr_streaming_transport],\n timeouts\n );\n var polling_loop = new SequentialStrategy([xhr_polling_transport], timeouts);\n\n var http_loop = new SequentialStrategy(\n [\n new IfStrategy(\n testSupportsStrategy(streaming_loop),\n new BestConnectedEverStrategy([\n streaming_loop,\n new DelayedStrategy(polling_loop, { delay: 4000 })\n ]),\n polling_loop\n )\n ],\n timeouts\n );\n\n var wsStrategy;\n if (baseOptions.useTLS) {\n wsStrategy = new BestConnectedEverStrategy([\n ws_loop,\n new DelayedStrategy(http_loop, { delay: 2000 })\n ]);\n } else {\n wsStrategy = new BestConnectedEverStrategy([\n ws_loop,\n new DelayedStrategy(wss_loop, { delay: 2000 }),\n new DelayedStrategy(http_loop, { delay: 5000 })\n ]);\n }\n\n return new WebSocketPrioritizedCachedStrategy(\n new FirstConnectedStrategy(\n new IfStrategy(testSupportsStrategy(ws_transport), wsStrategy, http_loop)\n ),\n definedTransports,\n {\n ttl: 1800000,\n timeline: baseOptions.timeline,\n useTLS: baseOptions.useTLS\n }\n );\n};\n\nexport default getDefaultStrategy;\n","import Runtime from 'runtime';\nimport RequestHooks from './request_hooks';\nimport Ajax from './ajax';\nimport { default as EventsDispatcher } from '../events/dispatcher';\n\nconst MAX_BUFFER_LENGTH = 256 * 1024;\n\nexport default class HTTPRequest extends EventsDispatcher {\n hooks: RequestHooks;\n method: string;\n url: string;\n position: number;\n xhr: Ajax;\n unloader: Function;\n\n constructor(hooks: RequestHooks, method: string, url: string) {\n super();\n this.hooks = hooks;\n this.method = method;\n this.url = url;\n }\n\n start(payload?: any) {\n this.position = 0;\n this.xhr = this.hooks.getRequest(this);\n\n this.unloader = () => {\n this.close();\n };\n Runtime.addUnloadListener(this.unloader);\n\n this.xhr.open(this.method, this.url, true);\n\n if (this.xhr.setRequestHeader) {\n this.xhr.setRequestHeader('Content-Type', 'application/json'); // ReactNative doesn't set this header by default.\n }\n this.xhr.send(payload);\n }\n\n close() {\n if (this.unloader) {\n Runtime.removeUnloadListener(this.unloader);\n this.unloader = null;\n }\n if (this.xhr) {\n this.hooks.abortRequest(this.xhr);\n this.xhr = null;\n }\n }\n\n onChunk(status: number, data: any) {\n while (true) {\n var chunk = this.advanceBuffer(data);\n if (chunk) {\n this.emit('chunk', { status: status, data: chunk });\n } else {\n break;\n }\n }\n if (this.isBufferTooLong(data)) {\n this.emit('buffer_too_long');\n }\n }\n\n private advanceBuffer(buffer: any[]): any {\n var unreadData = buffer.slice(this.position);\n var endOfLinePosition = unreadData.indexOf('\\n');\n\n if (endOfLinePosition !== -1) {\n this.position += endOfLinePosition + 1;\n return unreadData.slice(0, endOfLinePosition);\n } else {\n // chunk is not finished yet, don't move the buffer pointer\n return null;\n }\n }\n\n private isBufferTooLong(buffer: any): boolean {\n return this.position === buffer.length && buffer.length > MAX_BUFFER_LENGTH;\n }\n}\n","enum State {\n CONNECTING = 0,\n OPEN = 1,\n CLOSED = 3\n}\n\nexport default State;\n","import URLLocation from './url_location';\nimport State from './state';\nimport Socket from '../socket';\nimport SocketHooks from './socket_hooks';\nimport Util from '../util';\nimport Ajax from './ajax';\nimport HTTPRequest from './http_request';\nimport Runtime from 'runtime';\n\nvar autoIncrement = 1;\n\nclass HTTPSocket implements Socket {\n hooks: SocketHooks;\n session: string;\n location: URLLocation;\n readyState: State;\n stream: HTTPRequest;\n\n onopen: () => void;\n onerror: (error: any) => void;\n onclose: (closeEvent: any) => void;\n onmessage: (message: any) => void;\n onactivity: () => void;\n\n constructor(hooks: SocketHooks, url: string) {\n this.hooks = hooks;\n this.session = randomNumber(1000) + '/' + randomString(8);\n this.location = getLocation(url);\n this.readyState = State.CONNECTING;\n this.openStream();\n }\n\n send(payload: any) {\n return this.sendRaw(JSON.stringify([payload]));\n }\n\n ping() {\n this.hooks.sendHeartbeat(this);\n }\n\n close(code: any, reason: any) {\n this.onClose(code, reason, true);\n }\n\n /** For internal use only */\n sendRaw(payload: any): boolean {\n if (this.readyState === State.OPEN) {\n try {\n Runtime.createSocketRequest(\n 'POST',\n getUniqueURL(getSendURL(this.location, this.session))\n ).start(payload);\n return true;\n } catch (e) {\n return false;\n }\n } else {\n return false;\n }\n }\n\n /** For internal use only */\n reconnect() {\n this.closeStream();\n this.openStream();\n }\n\n /** For internal use only */\n onClose(code, reason, wasClean) {\n this.closeStream();\n this.readyState = State.CLOSED;\n if (this.onclose) {\n this.onclose({\n code: code,\n reason: reason,\n wasClean: wasClean\n });\n }\n }\n\n private onChunk(chunk) {\n if (chunk.status !== 200) {\n return;\n }\n if (this.readyState === State.OPEN) {\n this.onActivity();\n }\n\n var payload;\n var type = chunk.data.slice(0, 1);\n switch (type) {\n case 'o':\n payload = JSON.parse(chunk.data.slice(1) || '{}');\n this.onOpen(payload);\n break;\n case 'a':\n payload = JSON.parse(chunk.data.slice(1) || '[]');\n for (var i = 0; i < payload.length; i++) {\n this.onEvent(payload[i]);\n }\n break;\n case 'm':\n payload = JSON.parse(chunk.data.slice(1) || 'null');\n this.onEvent(payload);\n break;\n case 'h':\n this.hooks.onHeartbeat(this);\n break;\n case 'c':\n payload = JSON.parse(chunk.data.slice(1) || '[]');\n this.onClose(payload[0], payload[1], true);\n break;\n }\n }\n\n private onOpen(options) {\n if (this.readyState === State.CONNECTING) {\n if (options && options.hostname) {\n this.location.base = replaceHost(this.location.base, options.hostname);\n }\n this.readyState = State.OPEN;\n\n if (this.onopen) {\n this.onopen();\n }\n } else {\n this.onClose(1006, 'Server lost session', true);\n }\n }\n\n private onEvent(event) {\n if (this.readyState === State.OPEN && this.onmessage) {\n this.onmessage({ data: event });\n }\n }\n\n private onActivity() {\n if (this.onactivity) {\n this.onactivity();\n }\n }\n\n private onError(error) {\n if (this.onerror) {\n this.onerror(error);\n }\n }\n\n private openStream() {\n this.stream = Runtime.createSocketRequest(\n 'POST',\n getUniqueURL(this.hooks.getReceiveURL(this.location, this.session))\n );\n\n this.stream.bind('chunk', chunk => {\n this.onChunk(chunk);\n });\n this.stream.bind('finished', status => {\n this.hooks.onFinished(this, status);\n });\n this.stream.bind('buffer_too_long', () => {\n this.reconnect();\n });\n\n try {\n this.stream.start();\n } catch (error) {\n Util.defer(() => {\n this.onError(error);\n this.onClose(1006, 'Could not start streaming', false);\n });\n }\n }\n\n private closeStream() {\n if (this.stream) {\n this.stream.unbind_all();\n this.stream.close();\n this.stream = null;\n }\n }\n}\n\nfunction getLocation(url): URLLocation {\n var parts = /([^\\?]*)\\/*(\\??.*)/.exec(url);\n return {\n base: parts[1],\n queryString: parts[2]\n };\n}\n\nfunction getSendURL(url: URLLocation, session: string): string {\n return url.base + '/' + session + '/xhr_send';\n}\n\nfunction getUniqueURL(url: string): string {\n var separator = url.indexOf('?') === -1 ? '?' : '&';\n return url + separator + 't=' + +new Date() + '&n=' + autoIncrement++;\n}\n\nfunction replaceHost(url: string, hostname: string): string {\n var urlParts = /(https?:\\/\\/)([^\\/:]+)((\\/|:)?.*)/.exec(url);\n return urlParts[1] + hostname + urlParts[3];\n}\n\nfunction randomNumber(max: number): number {\n return Runtime.randomInt(max);\n}\n\nfunction randomString(length: number): string {\n var result = [];\n\n for (var i = 0; i < length; i++) {\n result.push(randomNumber(32).toString(32));\n }\n\n return result.join('');\n}\n\nexport default HTTPSocket;\n","import SocketHooks from './socket_hooks';\nimport HTTPSocket from './http_socket';\n\nvar hooks: SocketHooks = {\n getReceiveURL: function(url, session) {\n return url.base + '/' + session + '/xhr_streaming' + url.queryString;\n },\n onHeartbeat: function(socket) {\n socket.sendRaw('[]');\n },\n sendHeartbeat: function(socket) {\n socket.sendRaw('[]');\n },\n onFinished: function(socket, status) {\n socket.onClose(1006, 'Connection interrupted (' + status + ')', false);\n }\n};\n\nexport default hooks;\n","import SocketHooks from './socket_hooks';\nimport URLLocation from './url_location';\nimport HTTPSocket from './http_socket';\n\nvar hooks: SocketHooks = {\n getReceiveURL: function(url: URLLocation, session: string): string {\n return url.base + '/' + session + '/xhr' + url.queryString;\n },\n onHeartbeat: function() {\n // next HTTP request will reset server's activity timer\n },\n sendHeartbeat: function(socket) {\n socket.sendRaw('[]');\n },\n onFinished: function(socket, status) {\n if (status === 200) {\n socket.reconnect();\n } else {\n socket.onClose(1006, 'Connection interrupted (' + status + ')', false);\n }\n }\n};\n\nexport default hooks;\n","import HTTPRequest from 'core/http/http_request';\nimport RequestHooks from 'core/http/request_hooks';\nimport Ajax from 'core/http/ajax';\nimport Runtime from 'runtime';\n\nvar hooks: RequestHooks = {\n getRequest: function(socket: HTTPRequest): Ajax {\n var Constructor = Runtime.getXHRAPI();\n var xhr = new Constructor();\n xhr.onreadystatechange = xhr.onprogress = function() {\n switch (xhr.readyState) {\n case 3:\n if (xhr.responseText && xhr.responseText.length > 0) {\n socket.onChunk(xhr.status, xhr.responseText);\n }\n break;\n case 4:\n // this happens only on errors, never after calling close\n if (xhr.responseText && xhr.responseText.length > 0) {\n socket.onChunk(xhr.status, xhr.responseText);\n }\n socket.emit('finished', xhr.status);\n socket.close();\n break;\n }\n };\n return xhr;\n },\n abortRequest: function(xhr: Ajax) {\n xhr.onreadystatechange = null;\n xhr.abort();\n }\n};\n\nexport default hooks;\n","import * as Collections from 'core/utils/collections';\nimport Transports from 'isomorphic/transports/transports';\nimport TimelineSender from 'core/timeline/timeline_sender';\nimport Ajax from 'core/http/ajax';\nimport getDefaultStrategy from './default_strategy';\nimport TransportsTable from 'core/transports/transports_table';\nimport transportConnectionInitializer from './transports/transport_connection_initializer';\nimport HTTPFactory from './http/http';\n\nvar Isomorphic: any = {\n getDefaultStrategy,\n Transports: Transports,\n transportConnectionInitializer,\n HTTPFactory,\n\n setup(PusherClass): void {\n PusherClass.ready();\n },\n\n getLocalStorage(): any {\n return undefined;\n },\n\n getClientFeatures(): any[] {\n return Collections.keys(\n Collections.filterObject({ ws: Transports.ws }, function(t) {\n return t.isSupported({});\n })\n );\n },\n\n getProtocol(): string {\n return 'http:';\n },\n\n isXHRSupported(): boolean {\n return true;\n },\n\n createSocketRequest(method: string, url: string) {\n if (this.isXHRSupported()) {\n return this.HTTPFactory.createXHR(method, url);\n } else {\n throw 'Cross-origin HTTP requests are not supported';\n }\n },\n\n createXHR(): Ajax {\n var Constructor = this.getXHRAPI();\n return new Constructor();\n },\n\n createWebSocket(url: string): any {\n var Constructor = this.getWebSocketAPI();\n return new Constructor(url);\n },\n\n addUnloadListener(listener: any) {},\n removeUnloadListener(listener: any) {}\n};\n\nexport default Isomorphic;\n","/** Initializes the transport.\n *\n * Fetches resources if needed and then transitions to initialized.\n */\nexport default function() {\n var self = this;\n\n self.timeline.info(\n self.buildTimelineMessage({\n transport: self.name + (self.options.useTLS ? 's' : '')\n })\n );\n\n if (self.hooks.isInitialized()) {\n self.changeState('initialized');\n } else {\n self.onClose();\n }\n}\n","import HTTPRequest from 'core/http/http_request';\nimport HTTPSocket from 'core/http/http_socket';\nimport SocketHooks from 'core/http/socket_hooks';\nimport RequestHooks from 'core/http/request_hooks';\nimport streamingHooks from 'core/http/http_streaming_socket';\nimport pollingHooks from 'core/http/http_polling_socket';\nimport xhrHooks from './http_xhr_request';\nimport HTTPFactory from 'core/http/http_factory';\n\nvar HTTP: HTTPFactory = {\n createStreamingSocket(url: string): HTTPSocket {\n return this.createSocket(streamingHooks, url);\n },\n\n createPollingSocket(url: string): HTTPSocket {\n return this.createSocket(pollingHooks, url);\n },\n\n createSocket(hooks: SocketHooks, url: string): HTTPSocket {\n return new HTTPSocket(hooks, url);\n },\n\n createXHR(method: string, url: string): HTTPRequest {\n return this.createRequest(xhrHooks, method, url);\n },\n\n createRequest(hooks: RequestHooks, method: string, url: string): HTTPRequest {\n return new HTTPRequest(hooks, method, url);\n }\n};\n\nexport default HTTP;\n","import { default as EventsDispatcher } from 'core/events/dispatcher';\nimport Reachability from 'core/reachability';\n\nexport class NetInfo extends EventsDispatcher implements Reachability {\n isOnline(): boolean {\n return true;\n }\n}\n\nexport var Network = new NetInfo();\n","import AbstractRuntime from 'runtimes/interface';\nimport { AuthTransport } from 'core/auth/auth_transports';\nimport {\n AuthRequestType,\n AuthTransportCallback,\n InternalAuthOptions\n} from 'core/auth/options';\nimport { HTTPAuthError } from 'core/errors';\n\nvar fetchAuth: AuthTransport = function(\n context: AbstractRuntime,\n query: string,\n authOptions: InternalAuthOptions,\n authRequestType: AuthRequestType,\n callback: AuthTransportCallback\n) {\n var headers = new Headers();\n headers.set('Content-Type', 'application/x-www-form-urlencoded');\n\n for (var headerName in authOptions.headers) {\n headers.set(headerName, authOptions.headers[headerName]);\n }\n\n if (authOptions.headersProvider != null) {\n const dynamicHeaders = authOptions.headersProvider();\n for (var headerName in dynamicHeaders) {\n headers.set(headerName, dynamicHeaders[headerName]);\n }\n }\n\n var body = query;\n var request = new Request(authOptions.endpoint, {\n headers,\n body,\n credentials: 'same-origin',\n method: 'POST'\n });\n\n return fetch(request)\n .then(response => {\n let { status } = response;\n if (status === 200) {\n // manually parse the json so we can provide a more helpful error in\n // failure case\n return response.text();\n }\n throw new HTTPAuthError(\n status,\n `Could not get ${authRequestType.toString()} info from your auth endpoint, status: ${status}`\n );\n })\n .then(data => {\n let parsedData;\n try {\n parsedData = JSON.parse(data);\n } catch (e) {\n throw new HTTPAuthError(\n 200,\n `JSON returned from ${authRequestType.toString()} endpoint was invalid, yet status code was 200. Data was: ${data}`\n );\n }\n callback(null, parsedData);\n })\n .catch(err => {\n callback(err, null);\n });\n};\n\nexport default fetchAuth;\n","import Logger from 'core/logger';\nimport TimelineSender from 'core/timeline/timeline_sender';\nimport * as Collections from 'core/utils/collections';\nimport Util from 'core/util';\nimport Runtime from 'runtime';\nimport TimelineTransport from 'core/timeline/timeline_transport';\n\nvar getAgent = function(sender: TimelineSender, useTLS: boolean) {\n return function(data: any, callback: Function) {\n var scheme = 'http' + (useTLS ? 's' : '') + '://';\n var url =\n scheme + (sender.host || sender.options.host) + sender.options.path;\n var query = Collections.buildQueryString(data);\n url += '/' + 2 + '?' + query;\n\n fetch(url)\n .then(response => {\n if (response.status !== 200) {\n throw `received ${response.status} from stats.pusher.com`;\n }\n return response.json();\n })\n .then(({ host }) => {\n if (host) {\n sender.host = host;\n }\n })\n .catch(err => {\n Logger.debug('TimelineSender Error: ', err);\n });\n };\n};\n\nvar fetchTimeline = {\n name: 'xhr',\n getAgent\n};\n\nexport default fetchTimeline;\n","import Isomorphic from 'isomorphic/runtime';\nimport Runtime from '../interface';\nimport { Network } from './net_info';\nimport fetchAuth from './auth/fetch_auth';\nimport { AuthTransports } from 'core/auth/auth_transports';\nimport fetchTimeline from './timeline/fetch_timeline';\n\n// Very verbose but until unavoidable until\n// TypeScript 2.1, when spread attributes will be\n// supported\nconst {\n getDefaultStrategy,\n Transports,\n setup,\n getProtocol,\n isXHRSupported,\n getLocalStorage,\n createXHR,\n createWebSocket,\n addUnloadListener,\n removeUnloadListener,\n transportConnectionInitializer,\n createSocketRequest,\n HTTPFactory\n} = Isomorphic;\n\nconst Worker: Runtime = {\n getDefaultStrategy,\n Transports,\n setup,\n getProtocol,\n isXHRSupported,\n getLocalStorage,\n createXHR,\n createWebSocket,\n addUnloadListener,\n removeUnloadListener,\n transportConnectionInitializer,\n createSocketRequest,\n HTTPFactory,\n\n TimelineTransport: fetchTimeline,\n\n getAuthorizers(): AuthTransports {\n return { ajax: fetchAuth };\n },\n\n getWebSocketAPI() {\n return WebSocket;\n },\n\n getXHRAPI() {\n return XMLHttpRequest;\n },\n\n getNetwork() {\n return Network;\n },\n\n randomInt(max: number): number {\n /**\n * Return values in the range of [0, 1[\n */\n const random = function() {\n const crypto = globalThis.crypto || globalThis['msCrypto'];\n const random = crypto.getRandomValues(new Uint32Array(1))[0];\n\n return random / 2 ** 32;\n };\n\n return Math.floor(random() * max);\n }\n};\n\nexport default Worker;\n","enum TimelineLevel {\n ERROR = 3,\n INFO = 6,\n DEBUG = 7\n}\n\nexport default TimelineLevel;\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport { default as Level } from './level';\n\nexport interface TimelineOptions {\n level?: Level;\n limit?: number;\n version?: string;\n cluster?: string;\n features?: string[];\n params?: any;\n}\n\nexport default class Timeline {\n key: string;\n session: number;\n events: any[];\n options: TimelineOptions;\n sent: number;\n uniqueID: number;\n\n constructor(key: string, session: number, options: TimelineOptions) {\n this.key = key;\n this.session = session;\n this.events = [];\n this.options = options || {};\n this.sent = 0;\n this.uniqueID = 0;\n }\n\n log(level, event) {\n if (level <= this.options.level) {\n this.events.push(\n Collections.extend({}, event, { timestamp: Util.now() })\n );\n if (this.options.limit && this.events.length > this.options.limit) {\n this.events.shift();\n }\n }\n }\n\n error(event) {\n this.log(Level.ERROR, event);\n }\n\n info(event) {\n this.log(Level.INFO, event);\n }\n\n debug(event) {\n this.log(Level.DEBUG, event);\n }\n\n isEmpty() {\n return this.events.length === 0;\n }\n\n send(sendfn, callback) {\n var data = Collections.extend(\n {\n session: this.session,\n bundle: this.sent + 1,\n key: this.key,\n lib: 'js',\n version: this.options.version,\n cluster: this.options.cluster,\n features: this.options.features,\n timeline: this.events\n },\n this.options.params\n );\n\n this.events = [];\n sendfn(data, (error, result) => {\n if (!error) {\n this.sent++;\n }\n if (callback) {\n callback(error, result);\n }\n });\n\n return true;\n }\n\n generateUniqueID(): number {\n this.uniqueID++;\n return this.uniqueID;\n }\n}\n","import Factory from '../utils/factory';\nimport Util from '../util';\nimport * as Errors from '../errors';\nimport * as Collections from '../utils/collections';\nimport Strategy from './strategy';\nimport Transport from '../transports/transport';\nimport StrategyOptions from './strategy_options';\nimport Handshake from '../connection/handshake';\n\n/** Provides a strategy interface for transports.\n *\n * @param {String} name\n * @param {Number} priority\n * @param {Class} transport\n * @param {Object} options\n */\nexport default class TransportStrategy implements Strategy {\n name: string;\n priority: number;\n transport: Transport;\n options: StrategyOptions;\n\n constructor(\n name: string,\n priority: number,\n transport: Transport,\n options: StrategyOptions\n ) {\n this.name = name;\n this.priority = priority;\n this.transport = transport;\n this.options = options || {};\n }\n\n /** Returns whether the transport is supported in the browser.\n *\n * @returns {Boolean}\n */\n isSupported(): boolean {\n return this.transport.isSupported({\n useTLS: this.options.useTLS\n });\n }\n\n /** Launches a connection attempt and returns a strategy runner.\n *\n * @param {Function} callback\n * @return {Object} strategy runner\n */\n connect(minPriority: number, callback: Function) {\n if (!this.isSupported()) {\n return failAttempt(new Errors.UnsupportedStrategy(), callback);\n } else if (this.priority < minPriority) {\n return failAttempt(new Errors.TransportPriorityTooLow(), callback);\n }\n\n var connected = false;\n var transport = this.transport.createConnection(\n this.name,\n this.priority,\n this.options.key,\n this.options\n );\n var handshake = null;\n\n var onInitialized = function() {\n transport.unbind('initialized', onInitialized);\n transport.connect();\n };\n var onOpen = function() {\n handshake = Factory.createHandshake(transport, function(result) {\n connected = true;\n unbindListeners();\n callback(null, result);\n });\n };\n var onError = function(error) {\n unbindListeners();\n callback(error);\n };\n var onClosed = function() {\n unbindListeners();\n var serializedTransport;\n\n // The reason for this try/catch block is that on React Native\n // the WebSocket object is circular. Therefore transport.socket will\n // throw errors upon stringification. Collections.safeJSONStringify\n // discards circular references when serializing.\n serializedTransport = Collections.safeJSONStringify(transport);\n callback(new Errors.TransportClosed(serializedTransport));\n };\n\n var unbindListeners = function() {\n transport.unbind('initialized', onInitialized);\n transport.unbind('open', onOpen);\n transport.unbind('error', onError);\n transport.unbind('closed', onClosed);\n };\n\n transport.bind('initialized', onInitialized);\n transport.bind('open', onOpen);\n transport.bind('error', onError);\n transport.bind('closed', onClosed);\n\n // connect will be called automatically after initialization\n transport.initialize();\n\n return {\n abort: () => {\n if (connected) {\n return;\n }\n unbindListeners();\n if (handshake) {\n handshake.close();\n } else {\n transport.close();\n }\n },\n forceMinPriority: p => {\n if (connected) {\n return;\n }\n if (this.priority < p) {\n if (handshake) {\n handshake.close();\n } else {\n transport.close();\n }\n }\n }\n };\n }\n}\n\nfunction failAttempt(error: Error, callback: Function) {\n Util.defer(function() {\n callback(error);\n });\n return {\n abort: function() {},\n forceMinPriority: function() {}\n };\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport TransportManager from '../transports/transport_manager';\nimport * as Errors from '../errors';\nimport Strategy from './strategy';\nimport TransportStrategy from './transport_strategy';\nimport StrategyOptions from '../strategies/strategy_options';\nimport { Config } from '../config';\nimport Runtime from 'runtime';\n\nconst { Transports } = Runtime;\n\nexport var defineTransport = function(\n config: Config,\n name: string,\n type: string,\n priority: number,\n options: StrategyOptions,\n manager?: TransportManager\n): Strategy {\n var transportClass = Transports[type];\n if (!transportClass) {\n throw new Errors.UnsupportedTransport(type);\n }\n\n var enabled =\n (!config.enabledTransports ||\n Collections.arrayIndexOf(config.enabledTransports, name) !== -1) &&\n (!config.disabledTransports ||\n Collections.arrayIndexOf(config.disabledTransports, name) === -1);\n\n var transport;\n if (enabled) {\n options = Object.assign(\n { ignoreNullOrigin: config.ignoreNullOrigin },\n options\n );\n\n transport = new TransportStrategy(\n name,\n priority,\n manager ? manager.getAssistant(transportClass) : transportClass,\n options\n );\n } else {\n transport = UnsupportedStrategy;\n }\n\n return transport;\n};\n\nvar UnsupportedStrategy: Strategy = {\n isSupported: function() {\n return false;\n },\n connect: function(_, callback) {\n var deferred = Util.defer(function() {\n callback(new Errors.UnsupportedStrategy());\n });\n return {\n abort: function() {\n deferred.ensureAborted();\n },\n forceMinPriority: function() {}\n };\n }\n};\n","export enum AuthRequestType {\n UserAuthentication = 'user-authentication',\n ChannelAuthorization = 'channel-authorization'\n}\n\nexport interface ChannelAuthorizationData {\n auth: string;\n channel_data?: string;\n shared_secret?: string;\n}\n\nexport type ChannelAuthorizationCallback = (\n error: Error | null,\n authData: ChannelAuthorizationData | null\n) => void;\n\nexport interface ChannelAuthorizationRequestParams {\n socketId: string;\n channelName: string;\n}\n\nexport interface ChannelAuthorizationHandler {\n (\n params: ChannelAuthorizationRequestParams,\n callback: ChannelAuthorizationCallback\n ): void;\n}\n\nexport interface UserAuthenticationData {\n auth: string;\n user_data: string;\n}\n\nexport type UserAuthenticationCallback = (\n error: Error | null,\n authData: UserAuthenticationData | null\n) => void;\n\nexport interface UserAuthenticationRequestParams {\n socketId: string;\n}\n\nexport interface UserAuthenticationHandler {\n (\n params: UserAuthenticationRequestParams,\n callback: UserAuthenticationCallback\n ): void;\n}\n\nexport type AuthTransportCallback =\n | ChannelAuthorizationCallback\n | UserAuthenticationCallback;\n\nexport interface InternalAuthOptions {\n transport: 'ajax' | 'jsonp';\n endpoint: string;\n params?: any;\n headers?: any;\n paramsProvider?: () => any;\n headersProvider?: () => any;\n}\n\nexport type CustomAuthOptions = {\n customHandler: AuthHandler;\n};\n\nexport type AuthOptionsT =\n | InternalAuthOptions\n | CustomAuthOptions;\n\nexport declare type UserAuthenticationOptions = AuthOptionsT<\n UserAuthenticationHandler\n>;\nexport declare type ChannelAuthorizationOptions = AuthOptionsT<\n ChannelAuthorizationHandler\n>;\n","import ConnectionManager from './connection/connection_manager';\nimport {\n ChannelAuthorizationOptions,\n UserAuthenticationOptions\n} from './auth/options';\nimport {\n ChannelAuthorizerGenerator,\n DeprecatedAuthOptions\n} from './auth/deprecated_channel_authorizer';\nimport { AuthTransport, Transport } from './config';\nimport * as nacl from 'tweetnacl';\nimport Logger from './logger';\n\nexport interface Options {\n activityTimeout?: number;\n\n auth?: DeprecatedAuthOptions; // DEPRECATED use channelAuthorization instead\n authEndpoint?: string; // DEPRECATED use channelAuthorization instead\n authTransport?: AuthTransport; // DEPRECATED use channelAuthorization instead\n authorizer?: ChannelAuthorizerGenerator; // DEPRECATED use channelAuthorization instead\n\n channelAuthorization?: ChannelAuthorizationOptions;\n userAuthentication?: UserAuthenticationOptions;\n\n cluster: string;\n enableStats?: boolean;\n disableStats?: boolean;\n disabledTransports?: Transport[];\n enabledTransports?: Transport[];\n forceTLS?: boolean;\n httpHost?: string;\n httpPath?: string;\n httpPort?: number;\n httpsPort?: number;\n ignoreNullOrigin?: boolean;\n nacl?: nacl;\n pongTimeout?: number;\n statsHost?: string;\n timelineParams?: any;\n unavailableTimeout?: number;\n wsHost?: string;\n wsPath?: string;\n wsPort?: number;\n wssPort?: number;\n}\n\nexport interface ClusterOptions {\n appKey: string;\n cluster: string;\n}\n\nexport function validateOptions(options) {\n if (options == null) {\n throw 'You must pass an options object';\n }\n if (options.cluster == null) {\n throw 'Options object must provide a cluster';\n }\n if ('disableStats' in options) {\n Logger.warn(\n 'The disableStats option is deprecated in favor of enableStats'\n );\n }\n}\n","import {\n UserAuthenticationCallback,\n InternalAuthOptions,\n UserAuthenticationHandler,\n UserAuthenticationRequestParams,\n AuthRequestType\n} from './options';\n\nimport Runtime from 'runtime';\n\nconst composeChannelQuery = (\n params: UserAuthenticationRequestParams,\n authOptions: InternalAuthOptions\n) => {\n var query = 'socket_id=' + encodeURIComponent(params.socketId);\n\n for (var key in authOptions.params) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(authOptions.params[key]);\n }\n\n if (authOptions.paramsProvider != null) {\n let dynamicParams = authOptions.paramsProvider();\n for (var key in dynamicParams) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(dynamicParams[key]);\n }\n }\n\n return query;\n};\n\nconst UserAuthenticator = (\n authOptions: InternalAuthOptions\n): UserAuthenticationHandler => {\n if (typeof Runtime.getAuthorizers()[authOptions.transport] === 'undefined') {\n throw `'${authOptions.transport}' is not a recognized auth transport`;\n }\n\n return (\n params: UserAuthenticationRequestParams,\n callback: UserAuthenticationCallback\n ) => {\n const query = composeChannelQuery(params, authOptions);\n\n Runtime.getAuthorizers()[authOptions.transport](\n Runtime,\n query,\n authOptions,\n AuthRequestType.UserAuthentication,\n callback\n );\n };\n};\n\nexport default UserAuthenticator;\n","import {\n AuthRequestType,\n InternalAuthOptions,\n ChannelAuthorizationHandler,\n ChannelAuthorizationRequestParams,\n ChannelAuthorizationCallback\n} from './options';\n\nimport Runtime from 'runtime';\n\nconst composeChannelQuery = (\n params: ChannelAuthorizationRequestParams,\n authOptions: InternalAuthOptions\n) => {\n var query = 'socket_id=' + encodeURIComponent(params.socketId);\n\n query += '&channel_name=' + encodeURIComponent(params.channelName);\n\n for (var key in authOptions.params) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(authOptions.params[key]);\n }\n\n if (authOptions.paramsProvider != null) {\n let dynamicParams = authOptions.paramsProvider();\n for (var key in dynamicParams) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(dynamicParams[key]);\n }\n }\n\n return query;\n};\n\nconst ChannelAuthorizer = (\n authOptions: InternalAuthOptions\n): ChannelAuthorizationHandler => {\n if (typeof Runtime.getAuthorizers()[authOptions.transport] === 'undefined') {\n throw `'${authOptions.transport}' is not a recognized auth transport`;\n }\n\n return (\n params: ChannelAuthorizationRequestParams,\n callback: ChannelAuthorizationCallback\n ) => {\n const query = composeChannelQuery(params, authOptions);\n\n Runtime.getAuthorizers()[authOptions.transport](\n Runtime,\n query,\n authOptions,\n AuthRequestType.ChannelAuthorization,\n callback\n );\n };\n};\n\nexport default ChannelAuthorizer;\n","import Channel from '../channels/channel';\nimport {\n ChannelAuthorizationCallback,\n ChannelAuthorizationHandler,\n ChannelAuthorizationRequestParams,\n InternalAuthOptions\n} from './options';\n\nexport interface DeprecatedChannelAuthorizer {\n authorize(socketId: string, callback: ChannelAuthorizationCallback): void;\n}\n\nexport interface ChannelAuthorizerGenerator {\n (\n channel: Channel,\n options: DeprecatedAuthorizerOptions\n ): DeprecatedChannelAuthorizer;\n}\n\nexport interface DeprecatedAuthOptions {\n params?: any;\n headers?: any;\n}\n\nexport interface DeprecatedAuthorizerOptions {\n authTransport: 'ajax' | 'jsonp';\n authEndpoint: string;\n auth?: DeprecatedAuthOptions;\n}\n\nexport const ChannelAuthorizerProxy = (\n pusher,\n authOptions: InternalAuthOptions,\n channelAuthorizerGenerator: ChannelAuthorizerGenerator\n): ChannelAuthorizationHandler => {\n const deprecatedAuthorizerOptions: DeprecatedAuthorizerOptions = {\n authTransport: authOptions.transport,\n authEndpoint: authOptions.endpoint,\n auth: {\n params: authOptions.params,\n headers: authOptions.headers\n }\n };\n return (\n params: ChannelAuthorizationRequestParams,\n callback: ChannelAuthorizationCallback\n ) => {\n const channel = pusher.channel(params.channelName);\n // This line creates a new channel authorizer every time.\n // In the past, this was only done once per channel and reused.\n // We can do that again if we want to keep this behavior intact.\n const channelAuthorizer: DeprecatedChannelAuthorizer = channelAuthorizerGenerator(\n channel,\n deprecatedAuthorizerOptions\n );\n channelAuthorizer.authorize(params.socketId, callback);\n };\n};\n","import { Options } from './options';\nimport Defaults from './defaults';\nimport {\n ChannelAuthorizationHandler,\n UserAuthenticationHandler,\n ChannelAuthorizationOptions,\n AuthOptionsT,\n CustomAuthOptions\n} from './auth/options';\nimport UserAuthenticator from './auth/user_authenticator';\nimport ChannelAuthorizer from './auth/channel_authorizer';\nimport { ChannelAuthorizerProxy } from './auth/deprecated_channel_authorizer';\nimport Runtime from 'runtime';\nimport * as nacl from 'tweetnacl';\n\nexport type AuthTransport = 'ajax' | 'jsonp';\nexport type Transport =\n | 'ws'\n | 'wss'\n | 'xhr_streaming'\n | 'xhr_polling'\n | 'sockjs';\n\nexport interface Config {\n // these are all 'required' config parameters, it's not necessary for the user\n // to set them, but they have configured defaults.\n activityTimeout: number;\n enableStats: boolean;\n httpHost: string;\n httpPath: string;\n httpPort: number;\n httpsPort: number;\n pongTimeout: number;\n statsHost: string;\n unavailableTimeout: number;\n useTLS: boolean;\n wsHost: string;\n wsPath: string;\n wsPort: number;\n wssPort: number;\n userAuthenticator: UserAuthenticationHandler;\n channelAuthorizer: ChannelAuthorizationHandler;\n\n // these are all optional parameters or overrrides. The customer can set these\n // but it's not strictly necessary\n forceTLS?: boolean;\n cluster?: string;\n disabledTransports?: Transport[];\n enabledTransports?: Transport[];\n ignoreNullOrigin?: boolean;\n nacl?: nacl;\n timelineParams?: any;\n}\n\n// getConfig mainly sets the defaults for the options that are not provided\nexport function getConfig(opts: Options, pusher): Config {\n let config: Config = {\n activityTimeout: opts.activityTimeout || Defaults.activityTimeout,\n cluster: opts.cluster,\n httpPath: opts.httpPath || Defaults.httpPath,\n httpPort: opts.httpPort || Defaults.httpPort,\n httpsPort: opts.httpsPort || Defaults.httpsPort,\n pongTimeout: opts.pongTimeout || Defaults.pongTimeout,\n statsHost: opts.statsHost || Defaults.stats_host,\n unavailableTimeout: opts.unavailableTimeout || Defaults.unavailableTimeout,\n wsPath: opts.wsPath || Defaults.wsPath,\n wsPort: opts.wsPort || Defaults.wsPort,\n wssPort: opts.wssPort || Defaults.wssPort,\n\n enableStats: getEnableStatsConfig(opts),\n httpHost: getHttpHost(opts),\n useTLS: shouldUseTLS(opts),\n wsHost: getWebsocketHost(opts),\n\n userAuthenticator: buildUserAuthenticator(opts),\n channelAuthorizer: buildChannelAuthorizer(opts, pusher)\n };\n\n if ('disabledTransports' in opts)\n config.disabledTransports = opts.disabledTransports;\n if ('enabledTransports' in opts)\n config.enabledTransports = opts.enabledTransports;\n if ('ignoreNullOrigin' in opts)\n config.ignoreNullOrigin = opts.ignoreNullOrigin;\n if ('timelineParams' in opts) config.timelineParams = opts.timelineParams;\n if ('nacl' in opts) {\n config.nacl = opts.nacl;\n }\n\n return config;\n}\n\nfunction getHttpHost(opts: Options): string {\n if (opts.httpHost) {\n return opts.httpHost;\n }\n if (opts.cluster) {\n return `sockjs-${opts.cluster}.pusher.com`;\n }\n return Defaults.httpHost;\n}\n\nfunction getWebsocketHost(opts: Options): string {\n if (opts.wsHost) {\n return opts.wsHost;\n }\n return getWebsocketHostFromCluster(opts.cluster);\n}\n\nfunction getWebsocketHostFromCluster(cluster: string): string {\n return `ws-${cluster}.pusher.com`;\n}\n\nfunction shouldUseTLS(opts: Options): boolean {\n if (Runtime.getProtocol() === 'https:') {\n return true;\n } else if (opts.forceTLS === false) {\n return false;\n }\n return true;\n}\n\n// if enableStats is set take the value\n// if disableStats is set take the inverse\n// otherwise default to false\nfunction getEnableStatsConfig(opts: Options): boolean {\n if ('enableStats' in opts) {\n return opts.enableStats;\n }\n if ('disableStats' in opts) {\n return !opts.disableStats;\n }\n return false;\n}\n\nconst hasCustomHandler = (\n auth: AuthOptionsT\n): auth is CustomAuthOptions => {\n return 'customHandler' in auth && auth['customHandler'] != null;\n};\n\nfunction buildUserAuthenticator(opts: Options): UserAuthenticationHandler {\n const userAuthentication = {\n ...Defaults.userAuthentication,\n ...opts.userAuthentication\n };\n\n if (hasCustomHandler(userAuthentication)) {\n return userAuthentication['customHandler'];\n }\n\n return UserAuthenticator(userAuthentication);\n}\n\nfunction buildChannelAuth(opts: Options, pusher): ChannelAuthorizationOptions {\n let channelAuthorization: ChannelAuthorizationOptions;\n if ('channelAuthorization' in opts) {\n channelAuthorization = {\n ...Defaults.channelAuthorization,\n ...opts.channelAuthorization\n };\n } else {\n channelAuthorization = {\n transport: opts.authTransport || Defaults.authTransport,\n endpoint: opts.authEndpoint || Defaults.authEndpoint\n };\n\n if ('auth' in opts) {\n if ('params' in opts.auth) channelAuthorization.params = opts.auth.params;\n if ('headers' in opts.auth)\n channelAuthorization.headers = opts.auth.headers;\n }\n\n if ('authorizer' in opts) {\n return {\n customHandler: ChannelAuthorizerProxy(\n pusher,\n channelAuthorization,\n opts.authorizer\n )\n };\n }\n }\n return channelAuthorization;\n}\n\nfunction buildChannelAuthorizer(\n opts: Options,\n pusher\n): ChannelAuthorizationHandler {\n const channelAuthorization = buildChannelAuth(opts, pusher);\n\n if (hasCustomHandler(channelAuthorization)) {\n return channelAuthorization['customHandler'];\n }\n\n return ChannelAuthorizer(channelAuthorization);\n}\n","import Logger from './logger';\nimport Pusher from './pusher';\nimport EventsDispatcher from './events/dispatcher';\n\nexport default class WatchlistFacade extends EventsDispatcher {\n private pusher: Pusher;\n\n public constructor(pusher: Pusher) {\n super(function(eventName, data) {\n Logger.debug(`No callbacks on watchlist events for ${eventName}`);\n });\n\n this.pusher = pusher;\n this.bindWatchlistInternalEvent();\n }\n\n handleEvent(pusherEvent) {\n pusherEvent.data.events.forEach(watchlistEvent => {\n this.emit(watchlistEvent.name, watchlistEvent);\n });\n }\n\n private bindWatchlistInternalEvent() {\n this.pusher.connection.bind('message', pusherEvent => {\n var eventName = pusherEvent.event;\n if (eventName === 'pusher_internal:watchlist_events') {\n this.handleEvent(pusherEvent);\n }\n });\n }\n}\n","function flatPromise() {\n let resolve, reject;\n const promise = new Promise((res, rej) => {\n resolve = res;\n reject = rej;\n });\n return { promise, resolve, reject };\n}\n\nexport default flatPromise;\n","import Pusher from './pusher';\nimport Logger from './logger';\nimport {\n UserAuthenticationData,\n UserAuthenticationCallback\n} from './auth/options';\nimport Channel from './channels/channel';\nimport WatchlistFacade from './watchlist';\nimport EventsDispatcher from './events/dispatcher';\nimport flatPromise from './utils/flat_promise';\n\nexport default class UserFacade extends EventsDispatcher {\n pusher: Pusher;\n signin_requested: boolean = false;\n user_data: any = null;\n serverToUserChannel: Channel = null;\n signinDonePromise: Promise = null;\n watchlist: WatchlistFacade;\n private _signinDoneResolve: Function = null;\n\n public constructor(pusher: Pusher) {\n super(function(eventName, data) {\n Logger.debug('No callbacks on user for ' + eventName);\n });\n this.pusher = pusher;\n this.pusher.connection.bind('state_change', ({ previous, current }) => {\n if (previous !== 'connected' && current === 'connected') {\n this._signin();\n }\n if (previous === 'connected' && current !== 'connected') {\n this._cleanup();\n this._newSigninPromiseIfNeeded();\n }\n });\n\n this.watchlist = new WatchlistFacade(pusher);\n\n this.pusher.connection.bind('message', event => {\n var eventName = event.event;\n if (eventName === 'pusher:signin_success') {\n this._onSigninSuccess(event.data);\n }\n if (\n this.serverToUserChannel &&\n this.serverToUserChannel.name === event.channel\n ) {\n this.serverToUserChannel.handleEvent(event);\n }\n });\n }\n\n public signin() {\n if (this.signin_requested) {\n return;\n }\n\n this.signin_requested = true;\n this._signin();\n }\n\n private _signin() {\n if (!this.signin_requested) {\n return;\n }\n\n this._newSigninPromiseIfNeeded();\n\n if (this.pusher.connection.state !== 'connected') {\n // Signin will be attempted when the connection is connected\n return;\n }\n\n this.pusher.config.userAuthenticator(\n {\n socketId: this.pusher.connection.socket_id\n },\n this._onAuthorize\n );\n }\n\n private _onAuthorize: UserAuthenticationCallback = (\n err,\n authData: UserAuthenticationData\n ) => {\n if (err) {\n Logger.warn(`Error during signin: ${err}`);\n this._cleanup();\n return;\n }\n\n this.pusher.send_event('pusher:signin', {\n auth: authData.auth,\n user_data: authData.user_data\n });\n\n // Later when we get pusher:singin_success event, the user will be marked as signed in\n };\n\n private _onSigninSuccess(data: any) {\n try {\n this.user_data = JSON.parse(data.user_data);\n } catch (e) {\n Logger.error(`Failed parsing user data after signin: ${data.user_data}`);\n this._cleanup();\n return;\n }\n\n if (typeof this.user_data.id !== 'string' || this.user_data.id === '') {\n Logger.error(\n `user_data doesn't contain an id. user_data: ${this.user_data}`\n );\n this._cleanup();\n return;\n }\n\n // Signin succeeded\n this._signinDoneResolve();\n this._subscribeChannels();\n }\n\n private _subscribeChannels() {\n const ensure_subscribed = channel => {\n if (channel.subscriptionPending && channel.subscriptionCancelled) {\n channel.reinstateSubscription();\n } else if (\n !channel.subscriptionPending &&\n this.pusher.connection.state === 'connected'\n ) {\n channel.subscribe();\n }\n };\n\n this.serverToUserChannel = new Channel(\n `#server-to-user-${this.user_data.id}`,\n this.pusher\n );\n this.serverToUserChannel.bind_global((eventName, data) => {\n if (\n eventName.indexOf('pusher_internal:') === 0 ||\n eventName.indexOf('pusher:') === 0\n ) {\n // ignore internal events\n return;\n }\n this.emit(eventName, data);\n });\n ensure_subscribed(this.serverToUserChannel);\n }\n\n private _cleanup() {\n this.user_data = null;\n if (this.serverToUserChannel) {\n this.serverToUserChannel.unbind_all();\n this.serverToUserChannel.disconnect();\n this.serverToUserChannel = null;\n }\n\n if (this.signin_requested) {\n // If signin is in progress and cleanup is called,\n // Mark the current signin process as done.\n this._signinDoneResolve();\n }\n }\n\n private _newSigninPromiseIfNeeded() {\n if (!this.signin_requested) {\n return;\n }\n\n // If there is a promise and it is not resolved, return without creating a new one.\n if (this.signinDonePromise && !(this.signinDonePromise as any).done) {\n return;\n }\n\n // This promise is never rejected.\n // It gets resolved when the signin process is done whether it failed or succeeded\n const { promise, resolve, reject: _ } = flatPromise();\n (promise as any).done = false;\n const setDone = () => {\n (promise as any).done = true;\n };\n promise.then(setDone).catch(setDone);\n this.signinDonePromise = promise;\n this._signinDoneResolve = resolve;\n }\n}\n","import AbstractRuntime from '../runtimes/interface';\nimport Runtime from 'runtime';\nimport * as Collections from './utils/collections';\nimport Channels from './channels/channels';\nimport Channel from './channels/channel';\nimport { default as EventsDispatcher } from './events/dispatcher';\nimport Timeline from './timeline/timeline';\nimport TimelineSender from './timeline/timeline_sender';\nimport TimelineLevel from './timeline/level';\nimport { defineTransport } from './strategies/strategy_builder';\nimport ConnectionManager from './connection/connection_manager';\nimport { PeriodicTimer } from './utils/timers';\nimport Defaults from './defaults';\nimport Logger from './logger';\nimport Factory from './utils/factory';\nimport { Options, ClusterOptions, validateOptions } from './options';\nimport { Config, getConfig } from './config';\nimport StrategyOptions from './strategies/strategy_options';\nimport UserFacade from './user';\n\nexport default class Pusher {\n /* STATIC PROPERTIES */\n static instances: Pusher[] = [];\n static isReady: boolean = false;\n static logToConsole: boolean = false;\n\n // for jsonp\n static Runtime: AbstractRuntime = Runtime;\n static ScriptReceivers: any = (Runtime).ScriptReceivers;\n static DependenciesReceivers: any = (Runtime).DependenciesReceivers;\n static auth_callbacks: any = (Runtime).auth_callbacks;\n\n static ready() {\n Pusher.isReady = true;\n for (var i = 0, l = Pusher.instances.length; i < l; i++) {\n Pusher.instances[i].connect();\n }\n }\n\n static log: (message: any) => void;\n\n private static getClientFeatures(): string[] {\n return Collections.keys(\n Collections.filterObject({ ws: Runtime.Transports.ws }, function(t) {\n return t.isSupported({});\n })\n );\n }\n\n /* INSTANCE PROPERTIES */\n key: string;\n options: Options;\n config: Config;\n channels: Channels;\n global_emitter: EventsDispatcher;\n sessionID: number;\n timeline: Timeline;\n timelineSender: TimelineSender;\n connection: ConnectionManager;\n timelineSenderTimer: PeriodicTimer;\n user: UserFacade;\n constructor(app_key: string, options: Options) {\n checkAppKey(app_key);\n validateOptions(options);\n this.key = app_key;\n this.options = options;\n this.config = getConfig(this.options, this);\n\n this.channels = Factory.createChannels();\n this.global_emitter = new EventsDispatcher();\n this.sessionID = Runtime.randomInt(1000000000);\n\n this.timeline = new Timeline(this.key, this.sessionID, {\n cluster: this.config.cluster,\n features: Pusher.getClientFeatures(),\n params: this.config.timelineParams || {},\n limit: 50,\n level: TimelineLevel.INFO,\n version: Defaults.VERSION\n });\n if (this.config.enableStats) {\n this.timelineSender = Factory.createTimelineSender(this.timeline, {\n host: this.config.statsHost,\n path: '/timeline/v2/' + Runtime.TimelineTransport.name\n });\n }\n\n var getStrategy = (options: StrategyOptions) => {\n return Runtime.getDefaultStrategy(this.config, options, defineTransport);\n };\n\n this.connection = Factory.createConnectionManager(this.key, {\n getStrategy: getStrategy,\n timeline: this.timeline,\n activityTimeout: this.config.activityTimeout,\n pongTimeout: this.config.pongTimeout,\n unavailableTimeout: this.config.unavailableTimeout,\n useTLS: Boolean(this.config.useTLS)\n });\n\n this.connection.bind('connected', () => {\n this.subscribeAll();\n if (this.timelineSender) {\n this.timelineSender.send(this.connection.isUsingTLS());\n }\n });\n\n this.connection.bind('message', event => {\n var eventName = event.event;\n var internal = eventName.indexOf('pusher_internal:') === 0;\n if (event.channel) {\n var channel = this.channel(event.channel);\n if (channel) {\n channel.handleEvent(event);\n }\n }\n // Emit globally [deprecated]\n if (!internal) {\n this.global_emitter.emit(event.event, event.data);\n }\n });\n this.connection.bind('connecting', () => {\n this.channels.disconnect();\n });\n this.connection.bind('disconnected', () => {\n this.channels.disconnect();\n });\n this.connection.bind('error', err => {\n Logger.warn(err);\n });\n\n Pusher.instances.push(this);\n this.timeline.info({ instances: Pusher.instances.length });\n\n this.user = new UserFacade(this);\n\n if (Pusher.isReady) {\n this.connect();\n }\n }\n\n /**\n * Allows you to switch Pusher cluster without\n * losing all the channels/subscription binding\n * as this is internally managed by the SDK.\n */\n switchCluster(options: ClusterOptions) {\n const { appKey, cluster } = options;\n this.key = appKey;\n this.options = { ...this.options, cluster };\n this.config = getConfig(this.options, this);\n this.connection.switchCluster(this.key);\n }\n\n channel(name: string): Channel {\n return this.channels.find(name);\n }\n\n allChannels(): Channel[] {\n return this.channels.all();\n }\n\n connect() {\n this.connection.connect();\n\n if (this.timelineSender) {\n if (!this.timelineSenderTimer) {\n var usingTLS = this.connection.isUsingTLS();\n var timelineSender = this.timelineSender;\n this.timelineSenderTimer = new PeriodicTimer(60000, function() {\n timelineSender.send(usingTLS);\n });\n }\n }\n }\n\n disconnect() {\n this.connection.disconnect();\n\n if (this.timelineSenderTimer) {\n this.timelineSenderTimer.ensureAborted();\n this.timelineSenderTimer = null;\n }\n }\n\n bind(event_name: string, callback: Function, context?: any): Pusher {\n this.global_emitter.bind(event_name, callback, context);\n return this;\n }\n\n unbind(event_name?: string, callback?: Function, context?: any): Pusher {\n this.global_emitter.unbind(event_name, callback, context);\n return this;\n }\n\n bind_global(callback: Function): Pusher {\n this.global_emitter.bind_global(callback);\n return this;\n }\n\n unbind_global(callback?: Function): Pusher {\n this.global_emitter.unbind_global(callback);\n return this;\n }\n\n unbind_all(callback?: Function): Pusher {\n this.global_emitter.unbind_all();\n return this;\n }\n\n subscribeAll() {\n var channelName;\n for (channelName in this.channels.channels) {\n if (this.channels.channels.hasOwnProperty(channelName)) {\n this.subscribe(channelName);\n }\n }\n }\n\n subscribe(channel_name: string) {\n var channel = this.channels.add(channel_name, this);\n if (channel.subscriptionPending && channel.subscriptionCancelled) {\n channel.reinstateSubscription();\n } else if (\n !channel.subscriptionPending &&\n this.connection.state === 'connected'\n ) {\n channel.subscribe();\n }\n return channel;\n }\n\n unsubscribe(channel_name: string) {\n var channel = this.channels.find(channel_name);\n if (channel && channel.subscriptionPending) {\n channel.cancelSubscription();\n } else {\n channel = this.channels.remove(channel_name);\n if (channel && channel.subscribed) {\n channel.unsubscribe();\n }\n }\n }\n\n send_event(event_name: string, data: any, channel?: string) {\n return this.connection.send_event(event_name, data, channel);\n }\n\n shouldUseTLS(): boolean {\n return this.config.useTLS;\n }\n\n signin() {\n this.user.signin();\n }\n}\n\nfunction checkAppKey(key) {\n if (key === null || key === undefined) {\n throw 'You must pass your app key when you instantiate Pusher.';\n }\n}\n\nRuntime.setup(Pusher);\n","import Pusher from './pusher';\nimport { Options, validateOptions } from './options';\nimport * as nacl from 'tweetnacl';\n\nexport default class PusherWithEncryption extends Pusher {\n constructor(app_key: string, options: Options) {\n Pusher.logToConsole = PusherWithEncryption.logToConsole;\n Pusher.log = PusherWithEncryption.log;\n\n validateOptions(options);\n options.nacl = nacl;\n super(app_key, options);\n }\n}\n"],"sourceRoot":""} \ No newline at end of file diff --git a/dist/worker/pusher.worker.js b/dist/worker/pusher.worker.js index 7699c92c0..1161b01f5 100644 --- a/dist/worker/pusher.worker.js +++ b/dist/worker/pusher.worker.js @@ -1,5 +1,5 @@ /*! - * Pusher JavaScript Library v8.4.0-rc1 + * Pusher JavaScript Library v8.4.0-rc2 * https://pusher.com/ * * Copyright 2020, Pusher @@ -868,7 +868,7 @@ function safeJSONStringify(source) { // CONCATENATED MODULE: ./src/core/defaults.ts var Defaults = { - VERSION: "8.4.0-rc1", + VERSION: "8.4.0-rc2", PROTOCOL: 7, wsPort: 80, wssPort: 443, @@ -3794,10 +3794,12 @@ function getEnableStatsConfig(opts) { } return false; } +const hasCustomHandler = (auth) => { + return 'customHandler' in auth && auth['customHandler'] != null; +}; function buildUserAuthenticator(opts) { const userAuthentication = Object.assign(Object.assign({}, defaults.userAuthentication), opts.userAuthentication); - if ('customHandler' in userAuthentication && - userAuthentication['customHandler'] != null) { + if (hasCustomHandler(userAuthentication)) { return userAuthentication['customHandler']; } return user_authenticator(userAuthentication); @@ -3818,15 +3820,17 @@ function buildChannelAuth(opts, pusher) { if ('headers' in opts.auth) channelAuthorization.headers = opts.auth.headers; } - if ('authorizer' in opts) - channelAuthorization.customHandler = ChannelAuthorizerProxy(pusher, channelAuthorization, opts.authorizer); + if ('authorizer' in opts) { + return { + customHandler: ChannelAuthorizerProxy(pusher, channelAuthorization, opts.authorizer) + }; + } } return channelAuthorization; } function buildChannelAuthorizer(opts, pusher) { const channelAuthorization = buildChannelAuth(opts, pusher); - if ('customHandler' in channelAuthorization && - channelAuthorization['customHandler'] != null) { + if (hasCustomHandler(channelAuthorization)) { return channelAuthorization['customHandler']; } return channel_authorizer(channelAuthorization); @@ -4033,7 +4037,8 @@ class pusher_Pusher { checkAppKey(app_key); validateOptions(options); this.key = app_key; - this.config = getConfig(options, this); + this.options = options; + this.config = getConfig(this.options, this); this.channels = factory.createChannels(); this.global_emitter = new dispatcher_Dispatcher(); this.sessionID = worker_runtime.randomInt(1000000000); diff --git a/dist/worker/pusher.worker.js.map b/dist/worker/pusher.worker.js.map index 0d44eba5f..2feb17373 100644 --- a/dist/worker/pusher.worker.js.map +++ b/dist/worker/pusher.worker.js.map @@ -1 +1 @@ -{"version":3,"sources":["webpack://Pusher/webpack/universalModuleDefinition","webpack://Pusher/webpack/bootstrap","webpack://Pusher/./node_modules/@stablelib/base64/base64.ts","webpack://Pusher/./node_modules/@stablelib/utf8/utf8.ts","webpack://Pusher/./src/core/pusher.js","webpack://Pusher/./src/core/base64.ts","webpack://Pusher/./src/core/utils/timers/abstract_timer.ts","webpack://Pusher/./src/core/utils/timers/index.ts","webpack://Pusher/./src/core/util.ts","webpack://Pusher/./src/core/utils/collections.ts","webpack://Pusher/./src/core/defaults.ts","webpack://Pusher/./src/core/transports/url_schemes.ts","webpack://Pusher/./src/core/events/callback_registry.ts","webpack://Pusher/./src/core/events/dispatcher.ts","webpack://Pusher/./src/core/logger.ts","webpack://Pusher/./src/core/transports/transport_connection.ts","webpack://Pusher/./src/core/transports/transport.ts","webpack://Pusher/./src/runtimes/isomorphic/transports/transports.ts","webpack://Pusher/./src/core/transports/assistant_to_the_transport_manager.ts","webpack://Pusher/./src/core/connection/protocol/protocol.ts","webpack://Pusher/./src/core/connection/connection.ts","webpack://Pusher/./src/core/connection/handshake/index.ts","webpack://Pusher/./src/core/timeline/timeline_sender.ts","webpack://Pusher/./src/core/errors.ts","webpack://Pusher/./src/core/utils/url_store.ts","webpack://Pusher/./src/core/channels/channel.ts","webpack://Pusher/./src/core/channels/private_channel.ts","webpack://Pusher/./src/core/channels/members.ts","webpack://Pusher/./src/core/channels/presence_channel.ts","webpack://Pusher/./src/core/channels/encrypted_channel.ts","webpack://Pusher/./src/core/connection/connection_manager.ts","webpack://Pusher/./src/core/channels/channels.ts","webpack://Pusher/./src/core/utils/factory.ts","webpack://Pusher/./src/core/transports/transport_manager.ts","webpack://Pusher/./src/core/strategies/sequential_strategy.ts","webpack://Pusher/./src/core/strategies/best_connected_ever_strategy.ts","webpack://Pusher/./src/core/strategies/websocket_prioritized_cached_strategy.ts","webpack://Pusher/./src/core/strategies/delayed_strategy.ts","webpack://Pusher/./src/core/strategies/if_strategy.ts","webpack://Pusher/./src/core/strategies/first_connected_strategy.ts","webpack://Pusher/./src/runtimes/isomorphic/default_strategy.ts","webpack://Pusher/./src/runtimes/isomorphic/transports/transport_connection_initializer.ts","webpack://Pusher/./src/core/http/http_request.ts","webpack://Pusher/./src/core/http/state.ts","webpack://Pusher/./src/core/http/http_socket.ts","webpack://Pusher/./src/core/http/http_streaming_socket.ts","webpack://Pusher/./src/core/http/http_polling_socket.ts","webpack://Pusher/./src/runtimes/isomorphic/http/http_xhr_request.ts","webpack://Pusher/./src/runtimes/isomorphic/http/http.ts","webpack://Pusher/./src/runtimes/isomorphic/runtime.ts","webpack://Pusher/./src/runtimes/worker/net_info.ts","webpack://Pusher/./src/runtimes/worker/auth/fetch_auth.ts","webpack://Pusher/./src/runtimes/worker/timeline/fetch_timeline.ts","webpack://Pusher/./src/runtimes/worker/runtime.ts","webpack://Pusher/./src/core/timeline/level.ts","webpack://Pusher/./src/core/timeline/timeline.ts","webpack://Pusher/./src/core/strategies/transport_strategy.ts","webpack://Pusher/./src/core/strategies/strategy_builder.ts","webpack://Pusher/./src/core/options.ts","webpack://Pusher/./src/core/auth/options.ts","webpack://Pusher/./src/core/auth/user_authenticator.ts","webpack://Pusher/./src/core/auth/channel_authorizer.ts","webpack://Pusher/./src/core/auth/deprecated_channel_authorizer.ts","webpack://Pusher/./src/core/config.ts","webpack://Pusher/./src/core/watchlist.ts","webpack://Pusher/./src/core/utils/flat_promise.ts","webpack://Pusher/./src/core/user.ts","webpack://Pusher/./src/core/pusher.ts"],"names":[],"mappings":";;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AACD,O;QCVA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;;QAEA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;;;QAGA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;QACA,0CAA0C,gCAAgC;QAC1E;QACA;;QAEA;QACA;QACA;QACA,wDAAwD,kBAAkB;QAC1E;QACA,iDAAiD,cAAc;QAC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;IAED,MAAM;QACJ,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;IACrB,CAAC;;AAvOM,uBAAS,GAAa,EAAE,CAAC;AACzB,qBAAO,GAAY,KAAK,CAAC;AACzB,0BAAY,GAAY,KAAK,CAAC;AAG9B,qBAAO,GAAoB,cAAO,CAAC;AACnC,6BAAe,GAAc,cAAQ,CAAC,eAAe,CAAC;AACtD,mCAAqB,GAAc,cAAQ,CAAC,qBAAqB,CAAC;AAClE,4BAAc,GAAc,cAAQ,CAAC,cAAc,CAAC;AAVxC,8FAAM;AA4O3B,SAAS,WAAW,CAAC,GAAG;IACtB,IAAI,GAAG,KAAK,IAAI,IAAI,GAAG,KAAK,SAAS,EAAE;QACrC,MAAM,yDAAyD,CAAC;KACjE;AACH,CAAC;AAED,cAAO,CAAC,KAAK,CAAC,aAAM,CAAC,CAAC","file":"pusher.worker.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"Pusher\"] = factory();\n\telse\n\t\troot[\"Pusher\"] = factory();\n})(this, function() {\nreturn "," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 2);\n","// Copyright (C) 2016 Dmitry Chestnykh\n// MIT License. See LICENSE file for details.\n\n/**\n * Package base64 implements Base64 encoding and decoding.\n */\n\n// Invalid character used in decoding to indicate\n// that the character to decode is out of range of\n// alphabet and cannot be decoded.\nconst INVALID_BYTE = 256;\n\n/**\n * Implements standard Base64 encoding.\n *\n * Operates in constant time.\n */\nexport class Coder {\n // TODO(dchest): methods to encode chunk-by-chunk.\n\n constructor(private _paddingCharacter = \"=\") { }\n\n encodedLength(length: number): number {\n if (!this._paddingCharacter) {\n return (length * 8 + 5) / 6 | 0;\n }\n return (length + 2) / 3 * 4 | 0;\n }\n\n encode(data: Uint8Array): string {\n let out = \"\";\n\n let i = 0;\n for (; i < data.length - 2; i += 3) {\n let c = (data[i] << 16) | (data[i + 1] << 8) | (data[i + 2]);\n out += this._encodeByte((c >>> 3 * 6) & 63);\n out += this._encodeByte((c >>> 2 * 6) & 63);\n out += this._encodeByte((c >>> 1 * 6) & 63);\n out += this._encodeByte((c >>> 0 * 6) & 63);\n }\n\n const left = data.length - i;\n if (left > 0) {\n let c = (data[i] << 16) | (left === 2 ? data[i + 1] << 8 : 0);\n out += this._encodeByte((c >>> 3 * 6) & 63);\n out += this._encodeByte((c >>> 2 * 6) & 63);\n if (left === 2) {\n out += this._encodeByte((c >>> 1 * 6) & 63);\n } else {\n out += this._paddingCharacter || \"\";\n }\n out += this._paddingCharacter || \"\";\n }\n\n return out;\n }\n\n maxDecodedLength(length: number): number {\n if (!this._paddingCharacter) {\n return (length * 6 + 7) / 8 | 0;\n }\n return length / 4 * 3 | 0;\n }\n\n decodedLength(s: string): number {\n return this.maxDecodedLength(s.length - this._getPaddingLength(s));\n }\n\n decode(s: string): Uint8Array {\n if (s.length === 0) {\n return new Uint8Array(0);\n }\n const paddingLength = this._getPaddingLength(s);\n const length = s.length - paddingLength;\n const out = new Uint8Array(this.maxDecodedLength(length));\n let op = 0;\n let i = 0;\n let haveBad = 0;\n let v0 = 0, v1 = 0, v2 = 0, v3 = 0;\n for (; i < length - 4; i += 4) {\n v0 = this._decodeChar(s.charCodeAt(i + 0));\n v1 = this._decodeChar(s.charCodeAt(i + 1));\n v2 = this._decodeChar(s.charCodeAt(i + 2));\n v3 = this._decodeChar(s.charCodeAt(i + 3));\n out[op++] = (v0 << 2) | (v1 >>> 4);\n out[op++] = (v1 << 4) | (v2 >>> 2);\n out[op++] = (v2 << 6) | v3;\n haveBad |= v0 & INVALID_BYTE;\n haveBad |= v1 & INVALID_BYTE;\n haveBad |= v2 & INVALID_BYTE;\n haveBad |= v3 & INVALID_BYTE;\n }\n if (i < length - 1) {\n v0 = this._decodeChar(s.charCodeAt(i));\n v1 = this._decodeChar(s.charCodeAt(i + 1));\n out[op++] = (v0 << 2) | (v1 >>> 4);\n haveBad |= v0 & INVALID_BYTE;\n haveBad |= v1 & INVALID_BYTE;\n }\n if (i < length - 2) {\n v2 = this._decodeChar(s.charCodeAt(i + 2));\n out[op++] = (v1 << 4) | (v2 >>> 2);\n haveBad |= v2 & INVALID_BYTE;\n }\n if (i < length - 3) {\n v3 = this._decodeChar(s.charCodeAt(i + 3));\n out[op++] = (v2 << 6) | v3;\n haveBad |= v3 & INVALID_BYTE;\n }\n if (haveBad !== 0) {\n throw new Error(\"Base64Coder: incorrect characters for decoding\");\n }\n return out;\n }\n\n // Standard encoding have the following encoded/decoded ranges,\n // which we need to convert between.\n //\n // ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 0123456789 + /\n // Index: 0 - 25 26 - 51 52 - 61 62 63\n // ASCII: 65 - 90 97 - 122 48 - 57 43 47\n //\n\n // Encode 6 bits in b into a new character.\n protected _encodeByte(b: number): string {\n // Encoding uses constant time operations as follows:\n //\n // 1. Define comparison of A with B using (A - B) >>> 8:\n // if A > B, then result is positive integer\n // if A <= B, then result is 0\n //\n // 2. Define selection of C or 0 using bitwise AND: X & C:\n // if X == 0, then result is 0\n // if X != 0, then result is C\n //\n // 3. Start with the smallest comparison (b >= 0), which is always\n // true, so set the result to the starting ASCII value (65).\n //\n // 4. Continue comparing b to higher ASCII values, and selecting\n // zero if comparison isn't true, otherwise selecting a value\n // to add to result, which:\n //\n // a) undoes the previous addition\n // b) provides new value to add\n //\n let result = b;\n // b >= 0\n result += 65;\n // b > 25\n result += ((25 - b) >>> 8) & ((0 - 65) - 26 + 97);\n // b > 51\n result += ((51 - b) >>> 8) & ((26 - 97) - 52 + 48);\n // b > 61\n result += ((61 - b) >>> 8) & ((52 - 48) - 62 + 43);\n // b > 62\n result += ((62 - b) >>> 8) & ((62 - 43) - 63 + 47);\n\n return String.fromCharCode(result);\n }\n\n // Decode a character code into a byte.\n // Must return 256 if character is out of alphabet range.\n protected _decodeChar(c: number): number {\n // Decoding works similar to encoding: using the same comparison\n // function, but now it works on ranges: result is always incremented\n // by value, but this value becomes zero if the range is not\n // satisfied.\n //\n // Decoding starts with invalid value, 256, which is then\n // subtracted when the range is satisfied. If none of the ranges\n // apply, the function returns 256, which is then checked by\n // the caller to throw error.\n let result = INVALID_BYTE; // start with invalid character\n\n // c == 43 (c > 42 and c < 44)\n result += (((42 - c) & (c - 44)) >>> 8) & (-INVALID_BYTE + c - 43 + 62);\n // c == 47 (c > 46 and c < 48)\n result += (((46 - c) & (c - 48)) >>> 8) & (-INVALID_BYTE + c - 47 + 63);\n // c > 47 and c < 58\n result += (((47 - c) & (c - 58)) >>> 8) & (-INVALID_BYTE + c - 48 + 52);\n // c > 64 and c < 91\n result += (((64 - c) & (c - 91)) >>> 8) & (-INVALID_BYTE + c - 65 + 0);\n // c > 96 and c < 123\n result += (((96 - c) & (c - 123)) >>> 8) & (-INVALID_BYTE + c - 97 + 26);\n\n return result;\n }\n\n private _getPaddingLength(s: string): number {\n let paddingLength = 0;\n if (this._paddingCharacter) {\n for (let i = s.length - 1; i >= 0; i--) {\n if (s[i] !== this._paddingCharacter) {\n break;\n }\n paddingLength++;\n }\n if (s.length < 4 || paddingLength > 2) {\n throw new Error(\"Base64Coder: incorrect padding\");\n }\n }\n return paddingLength;\n }\n\n}\n\nconst stdCoder = new Coder();\n\nexport function encode(data: Uint8Array): string {\n return stdCoder.encode(data);\n}\n\nexport function decode(s: string): Uint8Array {\n return stdCoder.decode(s);\n}\n\n/**\n * Implements URL-safe Base64 encoding.\n * (Same as Base64, but '+' is replaced with '-', and '/' with '_').\n *\n * Operates in constant time.\n */\nexport class URLSafeCoder extends Coder {\n // URL-safe encoding have the following encoded/decoded ranges:\n //\n // ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 0123456789 - _\n // Index: 0 - 25 26 - 51 52 - 61 62 63\n // ASCII: 65 - 90 97 - 122 48 - 57 45 95\n //\n\n protected _encodeByte(b: number): string {\n let result = b;\n // b >= 0\n result += 65;\n // b > 25\n result += ((25 - b) >>> 8) & ((0 - 65) - 26 + 97);\n // b > 51\n result += ((51 - b) >>> 8) & ((26 - 97) - 52 + 48);\n // b > 61\n result += ((61 - b) >>> 8) & ((52 - 48) - 62 + 45);\n // b > 62\n result += ((62 - b) >>> 8) & ((62 - 45) - 63 + 95);\n\n return String.fromCharCode(result);\n }\n\n protected _decodeChar(c: number): number {\n let result = INVALID_BYTE;\n\n // c == 45 (c > 44 and c < 46)\n result += (((44 - c) & (c - 46)) >>> 8) & (-INVALID_BYTE + c - 45 + 62);\n // c == 95 (c > 94 and c < 96)\n result += (((94 - c) & (c - 96)) >>> 8) & (-INVALID_BYTE + c - 95 + 63);\n // c > 47 and c < 58\n result += (((47 - c) & (c - 58)) >>> 8) & (-INVALID_BYTE + c - 48 + 52);\n // c > 64 and c < 91\n result += (((64 - c) & (c - 91)) >>> 8) & (-INVALID_BYTE + c - 65 + 0);\n // c > 96 and c < 123\n result += (((96 - c) & (c - 123)) >>> 8) & (-INVALID_BYTE + c - 97 + 26);\n\n return result;\n }\n}\n\nconst urlSafeCoder = new URLSafeCoder();\n\nexport function encodeURLSafe(data: Uint8Array): string {\n return urlSafeCoder.encode(data);\n}\n\nexport function decodeURLSafe(s: string): Uint8Array {\n return urlSafeCoder.decode(s);\n}\n\n\nexport const encodedLength = (length: number) =>\n stdCoder.encodedLength(length);\n\nexport const maxDecodedLength = (length: number) =>\n stdCoder.maxDecodedLength(length);\n\nexport const decodedLength = (s: string) =>\n stdCoder.decodedLength(s);\n","// Copyright (C) 2016 Dmitry Chestnykh\n// MIT License. See LICENSE file for details.\n\n/**\n * Package utf8 implements UTF-8 encoding and decoding.\n */\n\nconst INVALID_UTF16 = \"utf8: invalid string\";\nconst INVALID_UTF8 = \"utf8: invalid source encoding\";\n\n/**\n * Encodes the given string into UTF-8 byte array.\n * Throws if the source string has invalid UTF-16 encoding.\n */\nexport function encode(s: string): Uint8Array {\n // Calculate result length and allocate output array.\n // encodedLength() also validates string and throws errors,\n // so we don't need repeat validation here.\n const arr = new Uint8Array(encodedLength(s));\n\n let pos = 0;\n for (let i = 0; i < s.length; i++) {\n let c = s.charCodeAt(i);\n if (c < 0x80) {\n arr[pos++] = c;\n } else if (c < 0x800) {\n arr[pos++] = 0xc0 | c >> 6;\n arr[pos++] = 0x80 | c & 0x3f;\n } else if (c < 0xd800) {\n arr[pos++] = 0xe0 | c >> 12;\n arr[pos++] = 0x80 | (c >> 6) & 0x3f;\n arr[pos++] = 0x80 | c & 0x3f;\n } else {\n i++; // get one more character\n c = (c & 0x3ff) << 10;\n c |= s.charCodeAt(i) & 0x3ff;\n c += 0x10000;\n\n arr[pos++] = 0xf0 | c >> 18;\n arr[pos++] = 0x80 | (c >> 12) & 0x3f;\n arr[pos++] = 0x80 | (c >> 6) & 0x3f;\n arr[pos++] = 0x80 | c & 0x3f;\n }\n }\n return arr;\n}\n\n/**\n * Returns the number of bytes required to encode the given string into UTF-8.\n * Throws if the source string has invalid UTF-16 encoding.\n */\nexport function encodedLength(s: string): number {\n let result = 0;\n for (let i = 0; i < s.length; i++) {\n const c = s.charCodeAt(i);\n if (c < 0x80) {\n result += 1;\n } else if (c < 0x800) {\n result += 2;\n } else if (c < 0xd800) {\n result += 3;\n } else if (c <= 0xdfff) {\n if (i >= s.length - 1) {\n throw new Error(INVALID_UTF16);\n }\n i++; // \"eat\" next character\n result += 4;\n } else {\n throw new Error(INVALID_UTF16);\n }\n }\n return result;\n}\n\n/**\n * Decodes the given byte array from UTF-8 into a string.\n * Throws if encoding is invalid.\n */\nexport function decode(arr: Uint8Array): string {\n const chars: string[] = [];\n for (let i = 0; i < arr.length; i++) {\n let b = arr[i];\n\n if (b & 0x80) {\n let min;\n if (b < 0xe0) {\n // Need 1 more byte.\n if (i >= arr.length) {\n throw new Error(INVALID_UTF8);\n }\n const n1 = arr[++i];\n if ((n1 & 0xc0) !== 0x80) {\n throw new Error(INVALID_UTF8);\n }\n b = (b & 0x1f) << 6 | (n1 & 0x3f);\n min = 0x80;\n } else if (b < 0xf0) {\n // Need 2 more bytes.\n if (i >= arr.length - 1) {\n throw new Error(INVALID_UTF8);\n }\n const n1 = arr[++i];\n const n2 = arr[++i];\n if ((n1 & 0xc0) !== 0x80 || (n2 & 0xc0) !== 0x80) {\n throw new Error(INVALID_UTF8);\n }\n b = (b & 0x0f) << 12 | (n1 & 0x3f) << 6 | (n2 & 0x3f);\n min = 0x800;\n } else if (b < 0xf8) {\n // Need 3 more bytes.\n if (i >= arr.length - 2) {\n throw new Error(INVALID_UTF8);\n }\n const n1 = arr[++i];\n const n2 = arr[++i];\n const n3 = arr[++i];\n if ((n1 & 0xc0) !== 0x80 || (n2 & 0xc0) !== 0x80 || (n3 & 0xc0) !== 0x80) {\n throw new Error(INVALID_UTF8);\n }\n b = (b & 0x0f) << 18 | (n1 & 0x3f) << 12 | (n2 & 0x3f) << 6 | (n3 & 0x3f);\n min = 0x10000;\n } else {\n throw new Error(INVALID_UTF8);\n }\n\n if (b < min || (b >= 0xd800 && b <= 0xdfff)) {\n throw new Error(INVALID_UTF8);\n }\n\n if (b >= 0x10000) {\n // Surrogate pair.\n if (b > 0x10ffff) {\n throw new Error(INVALID_UTF8);\n }\n b -= 0x10000;\n chars.push(String.fromCharCode(0xd800 | (b >> 10)));\n b = 0xdc00 | (b & 0x3ff);\n }\n }\n\n chars.push(String.fromCharCode(b));\n }\n return chars.join(\"\");\n}\n","// required so we don't have to do require('pusher').default etc.\nmodule.exports = require('./pusher').default;\n","export default function encode(s: any): string {\n return btoa(utob(s));\n}\n\nvar fromCharCode = String.fromCharCode;\n\nvar b64chars =\n 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';\nvar b64tab = {};\n\nfor (var i = 0, l = b64chars.length; i < l; i++) {\n b64tab[b64chars.charAt(i)] = i;\n}\n\nvar cb_utob = function(c) {\n var cc = c.charCodeAt(0);\n return cc < 0x80\n ? c\n : cc < 0x800\n ? fromCharCode(0xc0 | (cc >>> 6)) + fromCharCode(0x80 | (cc & 0x3f))\n : fromCharCode(0xe0 | ((cc >>> 12) & 0x0f)) +\n fromCharCode(0x80 | ((cc >>> 6) & 0x3f)) +\n fromCharCode(0x80 | (cc & 0x3f));\n};\n\nvar utob = function(u) {\n return u.replace(/[^\\x00-\\x7F]/g, cb_utob);\n};\n\nvar cb_encode = function(ccc) {\n var padlen = [0, 2, 1][ccc.length % 3];\n var ord =\n (ccc.charCodeAt(0) << 16) |\n ((ccc.length > 1 ? ccc.charCodeAt(1) : 0) << 8) |\n (ccc.length > 2 ? ccc.charCodeAt(2) : 0);\n var chars = [\n b64chars.charAt(ord >>> 18),\n b64chars.charAt((ord >>> 12) & 63),\n padlen >= 2 ? '=' : b64chars.charAt((ord >>> 6) & 63),\n padlen >= 1 ? '=' : b64chars.charAt(ord & 63)\n ];\n return chars.join('');\n};\n\nvar btoa =\n global.btoa ||\n function(b) {\n return b.replace(/[\\s\\S]{1,3}/g, cb_encode);\n };\n","import TimedCallback from './timed_callback';\nimport { Delay, Scheduler, Canceller } from './scheduling';\n\nabstract class Timer {\n protected clear: Canceller;\n protected timer: number | void;\n\n constructor(\n set: Scheduler,\n clear: Canceller,\n delay: Delay,\n callback: TimedCallback\n ) {\n this.clear = clear;\n this.timer = set(() => {\n if (this.timer) {\n this.timer = callback(this.timer);\n }\n }, delay);\n }\n\n /** Returns whether the timer is still running.\n *\n * @return {Boolean}\n */\n isRunning(): boolean {\n return this.timer !== null;\n }\n\n /** Aborts a timer when it's running. */\n ensureAborted() {\n if (this.timer) {\n this.clear(this.timer);\n this.timer = null;\n }\n }\n}\n\nexport default Timer;\n","import Timer from './abstract_timer';\nimport TimedCallback from './timed_callback';\nimport { Delay } from './scheduling';\n\n// We need to bind clear functions this way to avoid exceptions on IE8\nfunction clearTimeout(timer) {\n global.clearTimeout(timer);\n}\nfunction clearInterval(timer) {\n global.clearInterval(timer);\n}\n\n/** Cross-browser compatible one-off timer abstraction.\n *\n * @param {Number} delay\n * @param {Function} callback\n */\nexport class OneOffTimer extends Timer {\n constructor(delay: Delay, callback: TimedCallback) {\n super(setTimeout, clearTimeout, delay, function(timer) {\n callback();\n return null;\n });\n }\n}\n\n/** Cross-browser compatible periodic timer abstraction.\n *\n * @param {Number} delay\n * @param {Function} callback\n */\nexport class PeriodicTimer extends Timer {\n constructor(delay: Delay, callback: TimedCallback) {\n super(setInterval, clearInterval, delay, function(timer) {\n callback();\n return timer;\n });\n }\n}\n","import * as Collections from './utils/collections';\nimport TimedCallback from './utils/timers/timed_callback';\nimport { OneOffTimer, PeriodicTimer } from './utils/timers';\n\nvar Util = {\n now(): number {\n if (Date.now) {\n return Date.now();\n } else {\n return new Date().valueOf();\n }\n },\n\n defer(callback: TimedCallback): OneOffTimer {\n return new OneOffTimer(0, callback);\n },\n\n /** Builds a function that will proxy a method call to its first argument.\n *\n * Allows partial application of arguments, so additional arguments are\n * prepended to the argument list.\n *\n * @param {String} name method name\n * @return {Function} proxy function\n */\n method(name: string, ...args: any[]): Function {\n var boundArguments = Array.prototype.slice.call(arguments, 1);\n return function(object) {\n return object[name].apply(object, boundArguments.concat(arguments));\n };\n }\n};\n\nexport default Util;\n","import base64encode from '../base64';\nimport Util from '../util';\n\n/** Merges multiple objects into the target argument.\n *\n * For properties that are plain Objects, performs a deep-merge. For the\n * rest it just copies the value of the property.\n *\n * To extend prototypes use it as following:\n * Pusher.Util.extend(Target.prototype, Base.prototype)\n *\n * You can also use it to merge objects without altering them:\n * Pusher.Util.extend({}, object1, object2)\n *\n * @param {Object} target\n * @return {Object} the target argument\n */\nexport function extend(target: any, ...sources: any[]): T {\n for (var i = 0; i < sources.length; i++) {\n var extensions = sources[i];\n for (var property in extensions) {\n if (\n extensions[property] &&\n extensions[property].constructor &&\n extensions[property].constructor === Object\n ) {\n target[property] = extend(target[property] || {}, extensions[property]);\n } else {\n target[property] = extensions[property];\n }\n }\n }\n return target;\n}\n\nexport function stringify(): string {\n var m = ['Pusher'];\n for (var i = 0; i < arguments.length; i++) {\n if (typeof arguments[i] === 'string') {\n m.push(arguments[i]);\n } else {\n m.push(safeJSONStringify(arguments[i]));\n }\n }\n return m.join(' : ');\n}\n\nexport function arrayIndexOf(array: any[], item: any): number {\n // MSIE doesn't have array.indexOf\n var nativeIndexOf = Array.prototype.indexOf;\n if (array === null) {\n return -1;\n }\n if (nativeIndexOf && array.indexOf === nativeIndexOf) {\n return array.indexOf(item);\n }\n for (var i = 0, l = array.length; i < l; i++) {\n if (array[i] === item) {\n return i;\n }\n }\n return -1;\n}\n\n/** Applies a function f to all properties of an object.\n *\n * Function f gets 3 arguments passed:\n * - element from the object\n * - key of the element\n * - reference to the object\n *\n * @param {Object} object\n * @param {Function} f\n */\nexport function objectApply(object: any, f: Function) {\n for (var key in object) {\n if (Object.prototype.hasOwnProperty.call(object, key)) {\n f(object[key], key, object);\n }\n }\n}\n\n/** Return a list of objects own proerty keys\n *\n * @param {Object} object\n * @returns {Array}\n */\nexport function keys(object: any): string[] {\n var keys = [];\n objectApply(object, function(_, key) {\n keys.push(key);\n });\n return keys;\n}\n\n/** Return a list of object's own property values\n *\n * @param {Object} object\n * @returns {Array}\n */\nexport function values(object: any): any[] {\n var values = [];\n objectApply(object, function(value) {\n values.push(value);\n });\n return values;\n}\n\n/** Applies a function f to all elements of an array.\n *\n * Function f gets 3 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function apply(array: any[], f: Function, context?: any) {\n for (var i = 0; i < array.length; i++) {\n f.call(context || global, array[i], i, array);\n }\n}\n\n/** Maps all elements of the array and returns the result.\n *\n * Function f gets 4 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n * - reference to the destination array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function map(array: any[], f: Function): any[] {\n var result = [];\n for (var i = 0; i < array.length; i++) {\n result.push(f(array[i], i, array, result));\n }\n return result;\n}\n\n/** Maps all elements of the object and returns the result.\n *\n * Function f gets 4 arguments passed:\n * - element from the object\n * - key of the element\n * - reference to the source object\n * - reference to the destination object\n *\n * @param {Object} object\n * @param {Function} f\n */\nexport function mapObject(object: any, f: Function): any {\n var result = {};\n objectApply(object, function(value, key) {\n result[key] = f(value);\n });\n return result;\n}\n\n/** Filters elements of the array using a test function.\n *\n * Function test gets 4 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n * - reference to the destination array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function filter(array: any[], test: Function): any[] {\n test =\n test ||\n function(value) {\n return !!value;\n };\n\n var result = [];\n for (var i = 0; i < array.length; i++) {\n if (test(array[i], i, array, result)) {\n result.push(array[i]);\n }\n }\n return result;\n}\n\n/** Filters properties of the object using a test function.\n *\n * Function test gets 4 arguments passed:\n * - element from the object\n * - key of the element\n * - reference to the source object\n * - reference to the destination object\n *\n * @param {Object} object\n * @param {Function} f\n */\nexport function filterObject(object: Object, test: Function) {\n var result = {};\n objectApply(object, function(value, key) {\n if ((test && test(value, key, object, result)) || Boolean(value)) {\n result[key] = value;\n }\n });\n return result;\n}\n\n/** Flattens an object into a two-dimensional array.\n *\n * @param {Object} object\n * @return {Array} resulting array of [key, value] pairs\n */\nexport function flatten(object: Object): any[] {\n var result = [];\n objectApply(object, function(value, key) {\n result.push([key, value]);\n });\n return result;\n}\n\n/** Checks whether any element of the array passes the test.\n *\n * Function test gets 3 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function any(array: any[], test: Function): boolean {\n for (var i = 0; i < array.length; i++) {\n if (test(array[i], i, array)) {\n return true;\n }\n }\n return false;\n}\n\n/** Checks whether all elements of the array pass the test.\n *\n * Function test gets 3 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function all(array: any[], test: Function): boolean {\n for (var i = 0; i < array.length; i++) {\n if (!test(array[i], i, array)) {\n return false;\n }\n }\n return true;\n}\n\nexport function encodeParamsObject(data): string {\n return mapObject(data, function(value) {\n if (typeof value === 'object') {\n value = safeJSONStringify(value);\n }\n return encodeURIComponent(base64encode(value.toString()));\n });\n}\n\nexport function buildQueryString(data: any): string {\n var params = filterObject(data, function(value) {\n return value !== undefined;\n });\n\n var query = map(\n flatten(encodeParamsObject(params)),\n Util.method('join', '=')\n ).join('&');\n\n return query;\n}\n\n/**\n * See https://github.com/douglascrockford/JSON-js/blob/master/cycle.js\n *\n * Remove circular references from an object. Required for JSON.stringify in\n * React Native, which tends to blow up a lot.\n *\n * @param {any} object\n * @return {any} Decycled object\n */\nexport function decycleObject(object: any): any {\n var objects = [],\n paths = [];\n\n return (function derez(value, path) {\n var i, name, nu;\n\n switch (typeof value) {\n case 'object':\n if (!value) {\n return null;\n }\n for (i = 0; i < objects.length; i += 1) {\n if (objects[i] === value) {\n return { $ref: paths[i] };\n }\n }\n\n objects.push(value);\n paths.push(path);\n\n if (Object.prototype.toString.apply(value) === '[object Array]') {\n nu = [];\n for (i = 0; i < value.length; i += 1) {\n nu[i] = derez(value[i], path + '[' + i + ']');\n }\n } else {\n nu = {};\n for (name in value) {\n if (Object.prototype.hasOwnProperty.call(value, name)) {\n nu[name] = derez(\n value[name],\n path + '[' + JSON.stringify(name) + ']'\n );\n }\n }\n }\n return nu;\n case 'number':\n case 'string':\n case 'boolean':\n return value;\n }\n })(object, '$');\n}\n\n/**\n * Provides a cross-browser and cross-platform way to safely stringify objects\n * into JSON. This is particularly necessary for ReactNative, where circular JSON\n * structures throw an exception.\n *\n * @param {any} source The object to stringify\n * @return {string} The serialized output.\n */\nexport function safeJSONStringify(source: any): string {\n try {\n return JSON.stringify(source);\n } catch (e) {\n return JSON.stringify(decycleObject(source));\n }\n}\n","import {\n ChannelAuthorizationOptions,\n UserAuthenticationOptions\n} from './auth/options';\nimport { AuthTransport } from './config';\n\nexport interface DefaultConfig {\n VERSION: string;\n PROTOCOL: number;\n wsPort: number;\n wssPort: number;\n wsPath: string;\n httpHost: string;\n httpPort: number;\n httpsPort: number;\n httpPath: string;\n stats_host: string;\n authEndpoint: string;\n authTransport: AuthTransport;\n activityTimeout: number;\n pongTimeout: number;\n unavailableTimeout: number;\n userAuthentication: UserAuthenticationOptions;\n channelAuthorization: ChannelAuthorizationOptions;\n\n cdn_http?: string;\n cdn_https?: string;\n dependency_suffix?: string;\n}\n\nvar Defaults: DefaultConfig = {\n VERSION: VERSION,\n PROTOCOL: 7,\n\n wsPort: 80,\n wssPort: 443,\n wsPath: '',\n // DEPRECATED: SockJS fallback parameters\n httpHost: 'sockjs.pusher.com',\n httpPort: 80,\n httpsPort: 443,\n httpPath: '/pusher',\n // DEPRECATED: Stats\n stats_host: 'stats.pusher.com',\n // DEPRECATED: Other settings\n authEndpoint: '/pusher/auth',\n authTransport: 'ajax',\n activityTimeout: 120000,\n pongTimeout: 30000,\n unavailableTimeout: 10000,\n userAuthentication: {\n endpoint: '/pusher/user-auth',\n transport: 'ajax'\n },\n channelAuthorization: {\n endpoint: '/pusher/auth',\n transport: 'ajax'\n },\n\n // CDN configuration\n cdn_http: CDN_HTTP,\n cdn_https: CDN_HTTPS,\n dependency_suffix: DEPENDENCY_SUFFIX\n};\n\nexport default Defaults;\n","import Defaults from '../defaults';\nimport { default as URLScheme, URLSchemeParams } from './url_scheme';\n\nfunction getGenericURL(\n baseScheme: string,\n params: URLSchemeParams,\n path: string\n): string {\n var scheme = baseScheme + (params.useTLS ? 's' : '');\n var host = params.useTLS ? params.hostTLS : params.hostNonTLS;\n return scheme + '://' + host + path;\n}\n\nfunction getGenericPath(key: string, queryString?: string): string {\n var path = '/app/' + key;\n var query =\n '?protocol=' +\n Defaults.PROTOCOL +\n '&client=js' +\n '&version=' +\n Defaults.VERSION +\n (queryString ? '&' + queryString : '');\n return path + query;\n}\n\nexport var ws: URLScheme = {\n getInitial: function(key: string, params: URLSchemeParams): string {\n var path = (params.httpPath || '') + getGenericPath(key, 'flash=false');\n return getGenericURL('ws', params, path);\n }\n};\n\nexport var http: URLScheme = {\n getInitial: function(key: string, params: URLSchemeParams): string {\n var path = (params.httpPath || '/pusher') + getGenericPath(key);\n return getGenericURL('http', params, path);\n }\n};\n\nexport var sockjs: URLScheme = {\n getInitial: function(key: string, params: URLSchemeParams): string {\n return getGenericURL('http', params, params.httpPath || '/pusher');\n },\n getPath: function(key: string, params: URLSchemeParams): string {\n return getGenericPath(key);\n }\n};\n","import Callback from './callback';\nimport * as Collections from '../utils/collections';\nimport CallbackTable from './callback_table';\n\nexport default class CallbackRegistry {\n _callbacks: CallbackTable;\n\n constructor() {\n this._callbacks = {};\n }\n\n get(name: string): Callback[] {\n return this._callbacks[prefix(name)];\n }\n\n add(name: string, callback: Function, context: any) {\n var prefixedEventName = prefix(name);\n this._callbacks[prefixedEventName] =\n this._callbacks[prefixedEventName] || [];\n this._callbacks[prefixedEventName].push({\n fn: callback,\n context: context\n });\n }\n\n remove(name?: string, callback?: Function, context?: any) {\n if (!name && !callback && !context) {\n this._callbacks = {};\n return;\n }\n\n var names = name ? [prefix(name)] : Collections.keys(this._callbacks);\n\n if (callback || context) {\n this.removeCallback(names, callback, context);\n } else {\n this.removeAllCallbacks(names);\n }\n }\n\n private removeCallback(names: string[], callback: Function, context: any) {\n Collections.apply(\n names,\n function(name) {\n this._callbacks[name] = Collections.filter(\n this._callbacks[name] || [],\n function(binding) {\n return (\n (callback && callback !== binding.fn) ||\n (context && context !== binding.context)\n );\n }\n );\n if (this._callbacks[name].length === 0) {\n delete this._callbacks[name];\n }\n },\n this\n );\n }\n\n private removeAllCallbacks(names: string[]) {\n Collections.apply(\n names,\n function(name) {\n delete this._callbacks[name];\n },\n this\n );\n }\n}\n\nfunction prefix(name: string): string {\n return '_' + name;\n}\n","import * as Collections from '../utils/collections';\nimport Callback from './callback';\nimport Metadata from '../channels/metadata';\nimport CallbackRegistry from './callback_registry';\n\n/** Manages callback bindings and event emitting.\n *\n * @param Function failThrough called when no listeners are bound to an event\n */\nexport default class Dispatcher {\n callbacks: CallbackRegistry;\n global_callbacks: Function[];\n failThrough: Function;\n\n constructor(failThrough?: Function) {\n this.callbacks = new CallbackRegistry();\n this.global_callbacks = [];\n this.failThrough = failThrough;\n }\n\n bind(eventName: string, callback: Function, context?: any) {\n this.callbacks.add(eventName, callback, context);\n return this;\n }\n\n bind_global(callback: Function) {\n this.global_callbacks.push(callback);\n return this;\n }\n\n unbind(eventName?: string, callback?: Function, context?: any) {\n this.callbacks.remove(eventName, callback, context);\n return this;\n }\n\n unbind_global(callback?: Function) {\n if (!callback) {\n this.global_callbacks = [];\n return this;\n }\n\n this.global_callbacks = Collections.filter(\n this.global_callbacks || [],\n c => c !== callback\n );\n\n return this;\n }\n\n unbind_all() {\n this.unbind();\n this.unbind_global();\n return this;\n }\n\n emit(eventName: string, data?: any, metadata?: Metadata): Dispatcher {\n for (var i = 0; i < this.global_callbacks.length; i++) {\n this.global_callbacks[i](eventName, data);\n }\n\n var callbacks = this.callbacks.get(eventName);\n var args = [];\n\n if (metadata) {\n // if there's a metadata argument, we need to call the callback with both\n // data and metadata regardless of whether data is undefined\n args.push(data, metadata);\n } else if (data) {\n // metadata is undefined, so we only need to call the callback with data\n // if data exists\n args.push(data);\n }\n\n if (callbacks && callbacks.length > 0) {\n for (var i = 0; i < callbacks.length; i++) {\n callbacks[i].fn.apply(callbacks[i].context || global, args);\n }\n } else if (this.failThrough) {\n this.failThrough(eventName, data);\n }\n\n return this;\n }\n}\n","import { stringify } from './utils/collections';\nimport Pusher from './pusher';\n\nclass Logger {\n debug(...args: any[]) {\n this.log(this.globalLog, args);\n }\n\n warn(...args: any[]) {\n this.log(this.globalLogWarn, args);\n }\n\n error(...args: any[]) {\n this.log(this.globalLogError, args);\n }\n\n private globalLog = (message: string) => {\n if (global.console && global.console.log) {\n global.console.log(message);\n }\n };\n\n private globalLogWarn(message: string) {\n if (global.console && global.console.warn) {\n global.console.warn(message);\n } else {\n this.globalLog(message);\n }\n }\n\n private globalLogError(message: string) {\n if (global.console && global.console.error) {\n global.console.error(message);\n } else {\n this.globalLogWarn(message);\n }\n }\n\n private log(\n defaultLoggingFunction: (message: string) => void,\n ...args: any[]\n ) {\n var message = stringify.apply(this, arguments);\n if (Pusher.log) {\n Pusher.log(message);\n } else if (Pusher.logToConsole) {\n const log = defaultLoggingFunction.bind(this);\n log(message);\n }\n }\n}\n\nexport default new Logger();\n","import Util from '../util';\nimport * as Collections from '../utils/collections';\nimport { default as EventsDispatcher } from '../events/dispatcher';\nimport Logger from '../logger';\nimport TransportHooks from './transport_hooks';\nimport Socket from '../socket';\nimport Runtime from 'runtime';\nimport Timeline from '../timeline/timeline';\nimport TransportConnectionOptions from './transport_connection_options';\n\n/** Provides universal API for transport connections.\n *\n * Transport connection is a low-level object that wraps a connection method\n * and exposes a simple evented interface for the connection state and\n * messaging. It does not implement Pusher-specific WebSocket protocol.\n *\n * Additionally, it fetches resources needed for transport to work and exposes\n * an interface for querying transport features.\n *\n * States:\n * - new - initial state after constructing the object\n * - initializing - during initialization phase, usually fetching resources\n * - intialized - ready to establish a connection\n * - connection - when connection is being established\n * - open - when connection ready to be used\n * - closed - after connection was closed be either side\n *\n * Emits:\n * - error - after the connection raised an error\n *\n * Options:\n * - useTLS - whether connection should be over TLS\n * - hostTLS - host to connect to when connection is over TLS\n * - hostNonTLS - host to connect to when connection is over TLS\n *\n * @param {String} key application key\n * @param {Object} options\n */\nexport default class TransportConnection extends EventsDispatcher {\n hooks: TransportHooks;\n name: string;\n priority: number;\n key: string;\n options: TransportConnectionOptions;\n state: string;\n timeline: Timeline;\n activityTimeout: number;\n id: number;\n socket: Socket;\n beforeOpen: Function;\n initialize: Function;\n\n constructor(\n hooks: TransportHooks,\n name: string,\n priority: number,\n key: string,\n options: TransportConnectionOptions\n ) {\n super();\n this.initialize = Runtime.transportConnectionInitializer;\n this.hooks = hooks;\n this.name = name;\n this.priority = priority;\n this.key = key;\n this.options = options;\n\n this.state = 'new';\n this.timeline = options.timeline;\n this.activityTimeout = options.activityTimeout;\n this.id = this.timeline.generateUniqueID();\n }\n\n /** Checks whether the transport handles activity checks by itself.\n *\n * @return {Boolean}\n */\n handlesActivityChecks(): boolean {\n return Boolean(this.hooks.handlesActivityChecks);\n }\n\n /** Checks whether the transport supports the ping/pong API.\n *\n * @return {Boolean}\n */\n supportsPing(): boolean {\n return Boolean(this.hooks.supportsPing);\n }\n\n /** Tries to establish a connection.\n *\n * @returns {Boolean} false if transport is in invalid state\n */\n connect(): boolean {\n if (this.socket || this.state !== 'initialized') {\n return false;\n }\n\n var url = this.hooks.urls.getInitial(this.key, this.options);\n try {\n this.socket = this.hooks.getSocket(url, this.options);\n } catch (e) {\n Util.defer(() => {\n this.onError(e);\n this.changeState('closed');\n });\n return false;\n }\n\n this.bindListeners();\n\n Logger.debug('Connecting', { transport: this.name, url });\n this.changeState('connecting');\n return true;\n }\n\n /** Closes the connection.\n *\n * @return {Boolean} true if there was a connection to close\n */\n close(): boolean {\n if (this.socket) {\n this.socket.close();\n return true;\n } else {\n return false;\n }\n }\n\n /** Sends data over the open connection.\n *\n * @param {String} data\n * @return {Boolean} true only when in the \"open\" state\n */\n send(data: any): boolean {\n if (this.state === 'open') {\n // Workaround for MobileSafari bug (see https://gist.github.com/2052006)\n Util.defer(() => {\n if (this.socket) {\n this.socket.send(data);\n }\n });\n return true;\n } else {\n return false;\n }\n }\n\n /** Sends a ping if the connection is open and transport supports it. */\n ping() {\n if (this.state === 'open' && this.supportsPing()) {\n this.socket.ping();\n }\n }\n\n private onOpen() {\n if (this.hooks.beforeOpen) {\n this.hooks.beforeOpen(\n this.socket,\n this.hooks.urls.getPath(this.key, this.options)\n );\n }\n this.changeState('open');\n this.socket.onopen = undefined;\n }\n\n private onError(error) {\n this.emit('error', { type: 'WebSocketError', error: error });\n this.timeline.error(this.buildTimelineMessage({ error: error.toString() }));\n }\n\n private onClose(closeEvent?: any) {\n if (closeEvent) {\n this.changeState('closed', {\n code: closeEvent.code,\n reason: closeEvent.reason,\n wasClean: closeEvent.wasClean\n });\n } else {\n this.changeState('closed');\n }\n this.unbindListeners();\n this.socket = undefined;\n }\n\n private onMessage(message) {\n this.emit('message', message);\n }\n\n private onActivity() {\n this.emit('activity');\n }\n\n private bindListeners() {\n this.socket.onopen = () => {\n this.onOpen();\n };\n this.socket.onerror = error => {\n this.onError(error);\n };\n this.socket.onclose = closeEvent => {\n this.onClose(closeEvent);\n };\n this.socket.onmessage = message => {\n this.onMessage(message);\n };\n\n if (this.supportsPing()) {\n this.socket.onactivity = () => {\n this.onActivity();\n };\n }\n }\n\n private unbindListeners() {\n if (this.socket) {\n this.socket.onopen = undefined;\n this.socket.onerror = undefined;\n this.socket.onclose = undefined;\n this.socket.onmessage = undefined;\n if (this.supportsPing()) {\n this.socket.onactivity = undefined;\n }\n }\n }\n\n private changeState(state: string, params?: any) {\n this.state = state;\n this.timeline.info(\n this.buildTimelineMessage({\n state: state,\n params: params\n })\n );\n this.emit(state, params);\n }\n\n buildTimelineMessage(message): any {\n return Collections.extend({ cid: this.id }, message);\n }\n}\n","import Factory from '../utils/factory';\nimport TransportHooks from './transport_hooks';\nimport TransportConnection from './transport_connection';\nimport TransportConnectionOptions from './transport_connection_options';\n\n/** Provides interface for transport connection instantiation.\n *\n * Takes transport-specific hooks as the only argument, which allow checking\n * for transport support and creating its connections.\n *\n * Supported hooks: * - file - the name of the file to be fetched during initialization\n * - urls - URL scheme to be used by transport\n * - handlesActivityCheck - true when the transport handles activity checks\n * - supportsPing - true when the transport has a ping/activity API\n * - isSupported - tells whether the transport is supported in the environment\n * - getSocket - creates a WebSocket-compatible transport socket\n *\n * See transports.js for specific implementations.\n *\n * @param {Object} hooks object containing all needed transport hooks\n */\nexport default class Transport {\n hooks: TransportHooks;\n\n constructor(hooks: TransportHooks) {\n this.hooks = hooks;\n }\n\n /** Returns whether the transport is supported in the environment.\n *\n * @param {Object} envronment te environment details (encryption, settings)\n * @returns {Boolean} true when the transport is supported\n */\n isSupported(environment: any): boolean {\n return this.hooks.isSupported(environment);\n }\n\n /** Creates a transport connection.\n *\n * @param {String} name\n * @param {Number} priority\n * @param {String} key the application key\n * @param {Object} options\n * @returns {TransportConnection}\n */\n createConnection(\n name: string,\n priority: number,\n key: string,\n options: any\n ): TransportConnection {\n return new TransportConnection(this.hooks, name, priority, key, options);\n }\n}\n","import * as URLSchemes from 'core/transports/url_schemes';\nimport URLScheme from 'core/transports/url_scheme';\nimport Transport from 'core/transports/transport';\nimport Util from 'core/util';\nimport * as Collections from 'core/utils/collections';\nimport TransportHooks from 'core/transports/transport_hooks';\nimport TransportsTable from 'core/transports/transports_table';\nimport Runtime from 'runtime';\n\n/** WebSocket transport.\n *\n * Uses native WebSocket implementation, including MozWebSocket supported by\n * earlier Firefox versions.\n */\nvar WSTransport = new Transport({\n urls: URLSchemes.ws,\n handlesActivityChecks: false,\n supportsPing: false,\n\n isInitialized: function() {\n return Boolean(Runtime.getWebSocketAPI());\n },\n isSupported: function(): boolean {\n return Boolean(Runtime.getWebSocketAPI());\n },\n getSocket: function(url) {\n return Runtime.createWebSocket(url);\n }\n});\n\nvar httpConfiguration = {\n urls: URLSchemes.http,\n handlesActivityChecks: false,\n supportsPing: true,\n isInitialized: function() {\n return true;\n }\n};\n\nexport var streamingConfiguration = Collections.extend(\n {\n getSocket: function(url) {\n return Runtime.HTTPFactory.createStreamingSocket(url);\n }\n },\n httpConfiguration\n);\nexport var pollingConfiguration = Collections.extend(\n {\n getSocket: function(url) {\n return Runtime.HTTPFactory.createPollingSocket(url);\n }\n },\n httpConfiguration\n);\n\nvar xhrConfiguration = {\n isSupported: function(): boolean {\n return Runtime.isXHRSupported();\n }\n};\n\n/** HTTP streaming transport using CORS-enabled XMLHttpRequest. */\nvar XHRStreamingTransport = new Transport(\n (\n Collections.extend({}, streamingConfiguration, xhrConfiguration)\n )\n);\n\n/** HTTP long-polling transport using CORS-enabled XMLHttpRequest. */\nvar XHRPollingTransport = new Transport(\n Collections.extend({}, pollingConfiguration, xhrConfiguration)\n);\n\nvar Transports: TransportsTable = {\n ws: WSTransport,\n xhr_streaming: XHRStreamingTransport,\n xhr_polling: XHRPollingTransport\n};\n\nexport default Transports;\n","import Util from '../util';\nimport * as Collections from '../utils/collections';\nimport TransportManager from './transport_manager';\nimport TransportConnection from './transport_connection';\nimport Transport from './transport';\nimport PingDelayOptions from './ping_delay_options';\n\n/** Creates transport connections monitored by a transport manager.\n *\n * When a transport is closed, it might mean the environment does not support\n * it. It's possible that messages get stuck in an intermediate buffer or\n * proxies terminate inactive connections. To combat these problems,\n * assistants monitor the connection lifetime, report unclean exits and\n * adjust ping timeouts to keep the connection active. The decision to disable\n * a transport is the manager's responsibility.\n *\n * @param {TransportManager} manager\n * @param {TransportConnection} transport\n * @param {Object} options\n */\nexport default class AssistantToTheTransportManager {\n manager: TransportManager;\n transport: Transport;\n minPingDelay: number;\n maxPingDelay: number;\n pingDelay: number;\n\n constructor(\n manager: TransportManager,\n transport: Transport,\n options: PingDelayOptions\n ) {\n this.manager = manager;\n this.transport = transport;\n this.minPingDelay = options.minPingDelay;\n this.maxPingDelay = options.maxPingDelay;\n this.pingDelay = undefined;\n }\n\n /** Creates a transport connection.\n *\n * This function has the same API as Transport#createConnection.\n *\n * @param {String} name\n * @param {Number} priority\n * @param {String} key the application key\n * @param {Object} options\n * @returns {TransportConnection}\n */\n createConnection(\n name: string,\n priority: number,\n key: string,\n options: Object\n ): TransportConnection {\n options = Collections.extend({}, options, {\n activityTimeout: this.pingDelay\n });\n var connection = this.transport.createConnection(\n name,\n priority,\n key,\n options\n );\n\n var openTimestamp = null;\n\n var onOpen = function() {\n connection.unbind('open', onOpen);\n connection.bind('closed', onClosed);\n openTimestamp = Util.now();\n };\n var onClosed = closeEvent => {\n connection.unbind('closed', onClosed);\n\n if (closeEvent.code === 1002 || closeEvent.code === 1003) {\n // we don't want to use transports not obeying the protocol\n this.manager.reportDeath();\n } else if (!closeEvent.wasClean && openTimestamp) {\n // report deaths only for short-living transport\n var lifespan = Util.now() - openTimestamp;\n if (lifespan < 2 * this.maxPingDelay) {\n this.manager.reportDeath();\n this.pingDelay = Math.max(lifespan / 2, this.minPingDelay);\n }\n }\n };\n\n connection.bind('open', onOpen);\n return connection;\n }\n\n /** Returns whether the transport is supported in the environment.\n *\n * This function has the same API as Transport#isSupported. Might return false\n * when the manager decides to kill the transport.\n *\n * @param {Object} environment the environment details (encryption, settings)\n * @returns {Boolean} true when the transport is supported\n */\n isSupported(environment: string): boolean {\n return this.manager.isAlive() && this.transport.isSupported(environment);\n }\n}\n","import Action from './action';\nimport { PusherEvent } from './message-types';\n/**\n * Provides functions for handling Pusher protocol-specific messages.\n */\n\nconst Protocol = {\n /**\n * Decodes a message in a Pusher format.\n *\n * The MessageEvent we receive from the transport should contain a pusher event\n * (https://pusher.com/docs/pusher_protocol#events) serialized as JSON in the\n * data field\n *\n * The pusher event may contain a data field too, and it may also be\n * serialised as JSON\n *\n * Throws errors when messages are not parse'able.\n *\n * @param {MessageEvent} messageEvent\n * @return {PusherEvent}\n */\n decodeMessage: function(messageEvent: MessageEvent): PusherEvent {\n try {\n var messageData = JSON.parse(messageEvent.data);\n var pusherEventData = messageData.data;\n if (typeof pusherEventData === 'string') {\n try {\n pusherEventData = JSON.parse(messageData.data);\n } catch (e) {}\n }\n var pusherEvent: PusherEvent = {\n event: messageData.event,\n channel: messageData.channel,\n data: pusherEventData\n };\n if (messageData.user_id) {\n pusherEvent.user_id = messageData.user_id;\n }\n return pusherEvent;\n } catch (e) {\n throw { type: 'MessageParseError', error: e, data: messageEvent.data };\n }\n },\n\n /**\n * Encodes a message to be sent.\n *\n * @param {PusherEvent} event\n * @return {String}\n */\n encodeMessage: function(event: PusherEvent): string {\n return JSON.stringify(event);\n },\n\n /**\n * Processes a handshake message and returns appropriate actions.\n *\n * Returns an object with an 'action' and other action-specific properties.\n *\n * There are three outcomes when calling this function. First is a successful\n * connection attempt, when pusher:connection_established is received, which\n * results in a 'connected' action with an 'id' property. When passed a\n * pusher:error event, it returns a result with action appropriate to the\n * close code and an error. Otherwise, it raises an exception.\n *\n * @param {String} message\n * @result Object\n */\n processHandshake: function(messageEvent: MessageEvent): Action {\n var message = Protocol.decodeMessage(messageEvent);\n\n if (message.event === 'pusher:connection_established') {\n if (!message.data.activity_timeout) {\n throw 'No activity timeout specified in handshake';\n }\n return {\n action: 'connected',\n id: message.data.socket_id,\n activityTimeout: message.data.activity_timeout * 1000\n };\n } else if (message.event === 'pusher:error') {\n // From protocol 6 close codes are sent only once, so this only\n // happens when connection does not support close codes\n return {\n action: this.getCloseAction(message.data),\n error: this.getCloseError(message.data)\n };\n } else {\n throw 'Invalid handshake';\n }\n },\n\n /**\n * Dispatches the close event and returns an appropriate action name.\n *\n * See:\n * 1. https://developer.mozilla.org/en-US/docs/WebSockets/WebSockets_reference/CloseEvent\n * 2. http://pusher.com/docs/pusher_protocol\n *\n * @param {CloseEvent} closeEvent\n * @return {String} close action name\n */\n getCloseAction: function(closeEvent): string {\n if (closeEvent.code < 4000) {\n // ignore 1000 CLOSE_NORMAL, 1001 CLOSE_GOING_AWAY,\n // 1005 CLOSE_NO_STATUS, 1006 CLOSE_ABNORMAL\n // ignore 1007...3999\n // handle 1002 CLOSE_PROTOCOL_ERROR, 1003 CLOSE_UNSUPPORTED,\n // 1004 CLOSE_TOO_LARGE\n if (closeEvent.code >= 1002 && closeEvent.code <= 1004) {\n return 'backoff';\n } else {\n return null;\n }\n } else if (closeEvent.code === 4000) {\n return 'tls_only';\n } else if (closeEvent.code < 4100) {\n return 'refused';\n } else if (closeEvent.code < 4200) {\n return 'backoff';\n } else if (closeEvent.code < 4300) {\n return 'retry';\n } else {\n // unknown error\n return 'refused';\n }\n },\n\n /**\n * Returns an error or null basing on the close event.\n *\n * Null is returned when connection was closed cleanly. Otherwise, an object\n * with error details is returned.\n *\n * @param {CloseEvent} closeEvent\n * @return {Object} error object\n */\n getCloseError: function(closeEvent): any {\n if (closeEvent.code !== 1000 && closeEvent.code !== 1001) {\n return {\n type: 'PusherError',\n data: {\n code: closeEvent.code,\n message: closeEvent.reason || closeEvent.message\n }\n };\n } else {\n return null;\n }\n }\n};\n\nexport default Protocol;\n","import * as Collections from '../utils/collections';\nimport { default as EventsDispatcher } from '../events/dispatcher';\nimport Protocol from './protocol/protocol';\nimport { PusherEvent } from './protocol/message-types';\nimport Logger from '../logger';\nimport TransportConnection from '../transports/transport_connection';\nimport Socket from '../socket';\n/**\n * Provides Pusher protocol interface for transports.\n *\n * Emits following events:\n * - message - on received messages\n * - ping - on ping requests\n * - pong - on pong responses\n * - error - when the transport emits an error\n * - closed - after closing the transport\n *\n * It also emits more events when connection closes with a code.\n * See Protocol.getCloseAction to get more details.\n *\n * @param {Number} id\n * @param {AbstractTransport} transport\n */\nexport default class Connection extends EventsDispatcher implements Socket {\n id: string;\n transport: TransportConnection;\n activityTimeout: number;\n\n constructor(id: string, transport: TransportConnection) {\n super();\n this.id = id;\n this.transport = transport;\n this.activityTimeout = transport.activityTimeout;\n this.bindListeners();\n }\n\n /** Returns whether used transport handles activity checks by itself\n *\n * @returns {Boolean} true if activity checks are handled by the transport\n */\n handlesActivityChecks() {\n return this.transport.handlesActivityChecks();\n }\n\n /** Sends raw data.\n *\n * @param {String} data\n */\n send(data: any): boolean {\n return this.transport.send(data);\n }\n\n /** Sends an event.\n *\n * @param {String} name\n * @param {String} data\n * @param {String} [channel]\n * @returns {Boolean} whether message was sent or not\n */\n send_event(name: string, data: any, channel?: string): boolean {\n var event: PusherEvent = { event: name, data: data };\n if (channel) {\n event.channel = channel;\n }\n Logger.debug('Event sent', event);\n return this.send(Protocol.encodeMessage(event));\n }\n\n /** Sends a ping message to the server.\n *\n * Basing on the underlying transport, it might send either transport's\n * protocol-specific ping or pusher:ping event.\n */\n ping() {\n if (this.transport.supportsPing()) {\n this.transport.ping();\n } else {\n this.send_event('pusher:ping', {});\n }\n }\n\n /** Closes the connection. */\n close() {\n this.transport.close();\n }\n\n private bindListeners() {\n var listeners = {\n message: (messageEvent: MessageEvent) => {\n var pusherEvent;\n try {\n pusherEvent = Protocol.decodeMessage(messageEvent);\n } catch (e) {\n this.emit('error', {\n type: 'MessageParseError',\n error: e,\n data: messageEvent.data\n });\n }\n\n if (pusherEvent !== undefined) {\n Logger.debug('Event recd', pusherEvent);\n\n switch (pusherEvent.event) {\n case 'pusher:error':\n this.emit('error', {\n type: 'PusherError',\n data: pusherEvent.data\n });\n break;\n case 'pusher:ping':\n this.emit('ping');\n break;\n case 'pusher:pong':\n this.emit('pong');\n break;\n }\n this.emit('message', pusherEvent);\n }\n },\n activity: () => {\n this.emit('activity');\n },\n error: error => {\n this.emit('error', error);\n },\n closed: closeEvent => {\n unbindListeners();\n\n if (closeEvent && closeEvent.code) {\n this.handleCloseEvent(closeEvent);\n }\n\n this.transport = null;\n this.emit('closed');\n }\n };\n\n var unbindListeners = () => {\n Collections.objectApply(listeners, (listener, event) => {\n this.transport.unbind(event, listener);\n });\n };\n\n Collections.objectApply(listeners, (listener, event) => {\n this.transport.bind(event, listener);\n });\n }\n\n private handleCloseEvent(closeEvent: any) {\n var action = Protocol.getCloseAction(closeEvent);\n var error = Protocol.getCloseError(closeEvent);\n if (error) {\n this.emit('error', error);\n }\n if (action) {\n this.emit(action, { action: action, error: error });\n }\n }\n}\n","import Util from '../../util';\nimport * as Collections from '../../utils/collections';\nimport Protocol from '../protocol/protocol';\nimport Connection from '../connection';\nimport TransportConnection from '../../transports/transport_connection';\nimport HandshakePayload from './handshake_payload';\n\n/**\n * Handles Pusher protocol handshakes for transports.\n *\n * Calls back with a result object after handshake is completed. Results\n * always have two fields:\n * - action - string describing action to be taken after the handshake\n * - transport - the transport object passed to the constructor\n *\n * Different actions can set different additional properties on the result.\n * In the case of 'connected' action, there will be a 'connection' property\n * containing a Connection object for the transport. Other actions should\n * carry an 'error' property.\n *\n * @param {AbstractTransport} transport\n * @param {Function} callback\n */\nexport default class Handshake {\n transport: TransportConnection;\n callback: (HandshakePayload) => void;\n onMessage: Function;\n onClosed: Function;\n\n constructor(\n transport: TransportConnection,\n callback: (HandshakePayload) => void\n ) {\n this.transport = transport;\n this.callback = callback;\n this.bindListeners();\n }\n\n close() {\n this.unbindListeners();\n this.transport.close();\n }\n\n private bindListeners() {\n this.onMessage = m => {\n this.unbindListeners();\n\n var result;\n try {\n result = Protocol.processHandshake(m);\n } catch (e) {\n this.finish('error', { error: e });\n this.transport.close();\n return;\n }\n\n if (result.action === 'connected') {\n this.finish('connected', {\n connection: new Connection(result.id, this.transport),\n activityTimeout: result.activityTimeout\n });\n } else {\n this.finish(result.action, { error: result.error });\n this.transport.close();\n }\n };\n\n this.onClosed = closeEvent => {\n this.unbindListeners();\n\n var action = Protocol.getCloseAction(closeEvent) || 'backoff';\n var error = Protocol.getCloseError(closeEvent);\n this.finish(action, { error: error });\n };\n\n this.transport.bind('message', this.onMessage);\n this.transport.bind('closed', this.onClosed);\n }\n\n private unbindListeners() {\n this.transport.unbind('message', this.onMessage);\n this.transport.unbind('closed', this.onClosed);\n }\n\n private finish(action: string, params: any) {\n this.callback(\n Collections.extend({ transport: this.transport, action: action }, params)\n );\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport base64encode from '../base64';\nimport Timeline from './timeline';\nimport Runtime from 'runtime';\n\nexport interface TimelineSenderOptions {\n host?: string;\n port?: number;\n path?: string;\n}\n\nexport default class TimelineSender {\n timeline: Timeline;\n options: TimelineSenderOptions;\n host: string;\n\n constructor(timeline: Timeline, options: TimelineSenderOptions) {\n this.timeline = timeline;\n this.options = options || {};\n }\n\n send(useTLS: boolean, callback?: Function) {\n if (this.timeline.isEmpty()) {\n return;\n }\n\n this.timeline.send(\n Runtime.TimelineTransport.getAgent(this, useTLS),\n callback\n );\n }\n}\n","/** Error classes used throughout the library. */\n// https://github.com/Microsoft/TypeScript-wiki/blob/master/Breaking-Changes.md#extending-built-ins-like-error-array-and-map-may-no-longer-work\nexport class BadEventName extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\nexport class BadChannelName extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\nexport class RequestTimedOut extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class TransportPriorityTooLow extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class TransportClosed extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class UnsupportedFeature extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class UnsupportedTransport extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class UnsupportedStrategy extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class HTTPAuthError extends Error {\n status: number;\n constructor(status: number, msg?: string) {\n super(msg);\n this.status = status;\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n","/**\n * A place to store help URLs for error messages etc\n */\n\nconst urlStore = {\n baseUrl: 'https://pusher.com',\n urls: {\n authenticationEndpoint: {\n path: '/docs/channels/server_api/authenticating_users'\n },\n authorizationEndpoint: {\n path: '/docs/channels/server_api/authorizing-users/'\n },\n javascriptQuickStart: {\n path: '/docs/javascript_quick_start'\n },\n triggeringClientEvents: {\n path: '/docs/client_api_guide/client_events#trigger-events'\n },\n encryptedChannelSupport: {\n fullUrl:\n 'https://github.com/pusher/pusher-js/tree/cc491015371a4bde5743d1c87a0fbac0feb53195#encrypted-channel-support'\n }\n }\n};\n\n/** Builds a consistent string with links to pusher documentation\n *\n * @param {string} key - relevant key in the url_store.urls object\n * @return {string} suffix string to append to log message\n */\nconst buildLogSuffix = function(key: string): string {\n const urlPrefix = 'See:';\n const urlObj = urlStore.urls[key];\n if (!urlObj) return '';\n\n let url;\n if (urlObj.fullUrl) {\n url = urlObj.fullUrl;\n } else if (urlObj.path) {\n url = urlStore.baseUrl + urlObj.path;\n }\n\n if (!url) return '';\n return `${urlPrefix} ${url}`;\n};\n\nexport default { buildLogSuffix };\n","import { default as EventsDispatcher } from '../events/dispatcher';\nimport * as Errors from '../errors';\nimport Logger from '../logger';\nimport Pusher from '../pusher';\nimport { PusherEvent } from '../connection/protocol/message-types';\nimport Metadata from './metadata';\nimport UrlStore from '../utils/url_store';\nimport {\n ChannelAuthorizationData,\n ChannelAuthorizationCallback\n} from '../auth/options';\nimport { HTTPAuthError } from '../errors';\n\n/** Provides base public channel interface with an event emitter.\n *\n * Emits:\n * - pusher:subscription_succeeded - after subscribing successfully\n * - other non-internal events\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\nexport default class Channel extends EventsDispatcher {\n name: string;\n pusher: Pusher;\n subscribed: boolean;\n subscriptionPending: boolean;\n subscriptionCancelled: boolean;\n subscriptionCount: null;\n\n constructor(name: string, pusher: Pusher) {\n super(function(event, data) {\n Logger.debug('No callbacks on ' + name + ' for ' + event);\n });\n\n this.name = name;\n this.pusher = pusher;\n this.subscribed = false;\n this.subscriptionPending = false;\n this.subscriptionCancelled = false;\n }\n\n /** Skips authorization, since public channels don't require it.\n *\n * @param {Function} callback\n */\n authorize(socketId: string, callback: ChannelAuthorizationCallback) {\n return callback(null, { auth: '' });\n }\n\n /** Triggers an event */\n trigger(event: string, data: any) {\n if (event.indexOf('client-') !== 0) {\n throw new Errors.BadEventName(\n \"Event '\" + event + \"' does not start with 'client-'\"\n );\n }\n if (!this.subscribed) {\n var suffix = UrlStore.buildLogSuffix('triggeringClientEvents');\n Logger.warn(\n `Client event triggered before channel 'subscription_succeeded' event . ${suffix}`\n );\n }\n return this.pusher.send_event(event, data, this.name);\n }\n\n /** Signals disconnection to the channel. For internal use only. */\n disconnect() {\n this.subscribed = false;\n this.subscriptionPending = false;\n }\n\n /** Handles a PusherEvent. For internal use only.\n *\n * @param {PusherEvent} event\n */\n handleEvent(event: PusherEvent) {\n var eventName = event.event;\n var data = event.data;\n if (eventName === 'pusher_internal:subscription_succeeded') {\n this.handleSubscriptionSucceededEvent(event);\n } else if (eventName === 'pusher_internal:subscription_count') {\n this.handleSubscriptionCountEvent(event);\n } else if (eventName.indexOf('pusher_internal:') !== 0) {\n var metadata: Metadata = {};\n this.emit(eventName, data, metadata);\n }\n }\n\n handleSubscriptionSucceededEvent(event: PusherEvent) {\n this.subscriptionPending = false;\n this.subscribed = true;\n if (this.subscriptionCancelled) {\n this.pusher.unsubscribe(this.name);\n } else {\n this.emit('pusher:subscription_succeeded', event.data);\n }\n }\n\n handleSubscriptionCountEvent(event: PusherEvent) {\n if (event.data.subscription_count) {\n this.subscriptionCount = event.data.subscription_count;\n }\n\n this.emit('pusher:subscription_count', event.data);\n }\n\n /** Sends a subscription request. For internal use only. */\n subscribe() {\n if (this.subscribed) {\n return;\n }\n this.subscriptionPending = true;\n this.subscriptionCancelled = false;\n this.authorize(\n this.pusher.connection.socket_id,\n (error: Error | null, data: ChannelAuthorizationData) => {\n if (error) {\n this.subscriptionPending = false;\n // Why not bind to 'pusher:subscription_error' a level up, and log there?\n // Binding to this event would cause the warning about no callbacks being\n // bound (see constructor) to be suppressed, that's not what we want.\n Logger.error(error.toString());\n this.emit(\n 'pusher:subscription_error',\n Object.assign(\n {},\n {\n type: 'AuthError',\n error: error.message\n },\n error instanceof HTTPAuthError ? { status: error.status } : {}\n )\n );\n } else {\n this.pusher.send_event('pusher:subscribe', {\n auth: data.auth,\n channel_data: data.channel_data,\n channel: this.name\n });\n }\n }\n );\n }\n\n /** Sends an unsubscription request. For internal use only. */\n unsubscribe() {\n this.subscribed = false;\n this.pusher.send_event('pusher:unsubscribe', {\n channel: this.name\n });\n }\n\n /** Cancels an in progress subscription. For internal use only. */\n cancelSubscription() {\n this.subscriptionCancelled = true;\n }\n\n /** Reinstates an in progress subscripiton. For internal use only. */\n reinstateSubscription() {\n this.subscriptionCancelled = false;\n }\n}\n","import Factory from '../utils/factory';\nimport Channel from './channel';\nimport { ChannelAuthorizationCallback } from '../auth/options';\n\n/** Extends public channels to provide private channel interface.\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\nexport default class PrivateChannel extends Channel {\n /** Authorizes the connection to use the channel.\n *\n * @param {String} socketId\n * @param {Function} callback\n */\n authorize(socketId: string, callback: ChannelAuthorizationCallback) {\n return this.pusher.config.channelAuthorizer(\n {\n channelName: this.name,\n socketId: socketId\n },\n callback\n );\n }\n}\n","import * as Collections from '../utils/collections';\n\n/** Represents a collection of members of a presence channel. */\nexport default class Members {\n members: any;\n count: number;\n myID: any;\n me: any;\n\n constructor() {\n this.reset();\n }\n\n /** Returns member's info for given id.\n *\n * Resulting object containts two fields - id and info.\n *\n * @param {Number} id\n * @return {Object} member's info or null\n */\n get(id: string): any {\n if (Object.prototype.hasOwnProperty.call(this.members, id)) {\n return {\n id: id,\n info: this.members[id]\n };\n } else {\n return null;\n }\n }\n\n /** Calls back for each member in unspecified order.\n *\n * @param {Function} callback\n */\n each(callback: Function) {\n Collections.objectApply(this.members, (member, id) => {\n callback(this.get(id));\n });\n }\n\n /** Updates the id for connected member. For internal use only. */\n setMyID(id: string) {\n this.myID = id;\n }\n\n /** Handles subscription data. For internal use only. */\n onSubscription(subscriptionData: any) {\n this.members = subscriptionData.presence.hash;\n this.count = subscriptionData.presence.count;\n this.me = this.get(this.myID);\n }\n\n /** Adds a new member to the collection. For internal use only. */\n addMember(memberData: any) {\n if (this.get(memberData.user_id) === null) {\n this.count++;\n }\n this.members[memberData.user_id] = memberData.user_info;\n return this.get(memberData.user_id);\n }\n\n /** Adds a member from the collection. For internal use only. */\n removeMember(memberData: any) {\n var member = this.get(memberData.user_id);\n if (member) {\n delete this.members[memberData.user_id];\n this.count--;\n }\n return member;\n }\n\n /** Resets the collection to the initial state. For internal use only. */\n reset() {\n this.members = {};\n this.count = 0;\n this.myID = null;\n this.me = null;\n }\n}\n","import PrivateChannel from './private_channel';\nimport Logger from '../logger';\nimport Members from './members';\nimport Pusher from '../pusher';\nimport UrlStore from 'core/utils/url_store';\nimport { PusherEvent } from '../connection/protocol/message-types';\nimport Metadata from './metadata';\nimport { ChannelAuthorizationData } from '../auth/options';\n\nexport default class PresenceChannel extends PrivateChannel {\n members: Members;\n\n /** Adds presence channel functionality to private channels.\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\n constructor(name: string, pusher: Pusher) {\n super(name, pusher);\n this.members = new Members();\n }\n\n /** Authorizes the connection as a member of the channel.\n *\n * @param {String} socketId\n * @param {Function} callback\n */\n authorize(socketId: string, callback: Function) {\n super.authorize(socketId, async (error, authData) => {\n if (!error) {\n authData = authData as ChannelAuthorizationData;\n if (authData.channel_data != null) {\n var channelData = JSON.parse(authData.channel_data);\n this.members.setMyID(channelData.user_id);\n } else {\n await this.pusher.user.signinDonePromise;\n if (this.pusher.user.user_data != null) {\n // If the user is signed in, get the id of the authenticated user\n // and allow the presence authorization to continue.\n this.members.setMyID(this.pusher.user.user_data.id);\n } else {\n let suffix = UrlStore.buildLogSuffix('authorizationEndpoint');\n Logger.error(\n `Invalid auth response for channel '${this.name}', ` +\n `expected 'channel_data' field. ${suffix}, ` +\n `or the user should be signed in.`\n );\n callback('Invalid auth response');\n return;\n }\n }\n }\n callback(error, authData);\n });\n }\n\n /** Handles presence and subscription events. For internal use only.\n *\n * @param {PusherEvent} event\n */\n handleEvent(event: PusherEvent) {\n var eventName = event.event;\n if (eventName.indexOf('pusher_internal:') === 0) {\n this.handleInternalEvent(event);\n } else {\n var data = event.data;\n var metadata: Metadata = {};\n if (event.user_id) {\n metadata.user_id = event.user_id;\n }\n this.emit(eventName, data, metadata);\n }\n }\n handleInternalEvent(event: PusherEvent) {\n var eventName = event.event;\n var data = event.data;\n switch (eventName) {\n case 'pusher_internal:subscription_succeeded':\n this.handleSubscriptionSucceededEvent(event);\n break;\n case 'pusher_internal:subscription_count':\n this.handleSubscriptionCountEvent(event);\n break;\n case 'pusher_internal:member_added':\n var addedMember = this.members.addMember(data);\n this.emit('pusher:member_added', addedMember);\n break;\n case 'pusher_internal:member_removed':\n var removedMember = this.members.removeMember(data);\n if (removedMember) {\n this.emit('pusher:member_removed', removedMember);\n }\n break;\n }\n }\n\n handleSubscriptionSucceededEvent(event: PusherEvent) {\n this.subscriptionPending = false;\n this.subscribed = true;\n if (this.subscriptionCancelled) {\n this.pusher.unsubscribe(this.name);\n } else {\n this.members.onSubscription(event.data);\n this.emit('pusher:subscription_succeeded', this.members);\n }\n }\n\n /** Resets the channel state, including members map. For internal use only. */\n disconnect() {\n this.members.reset();\n super.disconnect();\n }\n}\n","import PrivateChannel from './private_channel';\nimport * as Errors from '../errors';\nimport Logger from '../logger';\nimport Pusher from '../pusher';\nimport { decode as encodeUTF8 } from '@stablelib/utf8';\nimport { decode as decodeBase64 } from '@stablelib/base64';\nimport Dispatcher from '../events/dispatcher';\nimport { PusherEvent } from '../connection/protocol/message-types';\nimport {\n ChannelAuthorizationData,\n ChannelAuthorizationCallback\n} from '../auth/options';\nimport * as nacl from 'tweetnacl';\n\n/** Extends private channels to provide encrypted channel interface.\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\nexport default class EncryptedChannel extends PrivateChannel {\n key: Uint8Array = null;\n nacl: nacl;\n\n constructor(name: string, pusher: Pusher, nacl: nacl) {\n super(name, pusher);\n this.nacl = nacl;\n }\n\n /** Authorizes the connection to use the channel.\n *\n * @param {String} socketId\n * @param {Function} callback\n */\n authorize(socketId: string, callback: ChannelAuthorizationCallback) {\n super.authorize(\n socketId,\n (error: Error | null, authData: ChannelAuthorizationData) => {\n if (error) {\n callback(error, authData);\n return;\n }\n let sharedSecret = authData['shared_secret'];\n if (!sharedSecret) {\n callback(\n new Error(\n `No shared_secret key in auth payload for encrypted channel: ${this.name}`\n ),\n null\n );\n return;\n }\n this.key = decodeBase64(sharedSecret);\n delete authData['shared_secret'];\n callback(null, authData);\n }\n );\n }\n\n trigger(event: string, data: any): boolean {\n throw new Errors.UnsupportedFeature(\n 'Client events are not currently supported for encrypted channels'\n );\n }\n\n /** Handles an event. For internal use only.\n *\n * @param {PusherEvent} event\n */\n handleEvent(event: PusherEvent) {\n var eventName = event.event;\n var data = event.data;\n if (\n eventName.indexOf('pusher_internal:') === 0 ||\n eventName.indexOf('pusher:') === 0\n ) {\n super.handleEvent(event);\n return;\n }\n this.handleEncryptedEvent(eventName, data);\n }\n\n private handleEncryptedEvent(event: string, data: any): void {\n if (!this.key) {\n Logger.debug(\n 'Received encrypted event before key has been retrieved from the authEndpoint'\n );\n return;\n }\n if (!data.ciphertext || !data.nonce) {\n Logger.error(\n 'Unexpected format for encrypted event, expected object with `ciphertext` and `nonce` fields, got: ' +\n data\n );\n return;\n }\n let cipherText = decodeBase64(data.ciphertext);\n if (cipherText.length < this.nacl.secretbox.overheadLength) {\n Logger.error(\n `Expected encrypted event ciphertext length to be ${this.nacl.secretbox.overheadLength}, got: ${cipherText.length}`\n );\n return;\n }\n let nonce = decodeBase64(data.nonce);\n if (nonce.length < this.nacl.secretbox.nonceLength) {\n Logger.error(\n `Expected encrypted event nonce length to be ${this.nacl.secretbox.nonceLength}, got: ${nonce.length}`\n );\n return;\n }\n\n let bytes = this.nacl.secretbox.open(cipherText, nonce, this.key);\n if (bytes === null) {\n Logger.debug(\n 'Failed to decrypt an event, probably because it was encrypted with a different key. Fetching a new key from the authEndpoint...'\n );\n // Try a single time to retrieve a new auth key and decrypt the event with it\n // If this fails, a new key will be requested when a new message is received\n this.authorize(this.pusher.connection.socket_id, (error, authData) => {\n if (error) {\n Logger.error(\n `Failed to make a request to the authEndpoint: ${authData}. Unable to fetch new key, so dropping encrypted event`\n );\n return;\n }\n bytes = this.nacl.secretbox.open(cipherText, nonce, this.key);\n if (bytes === null) {\n Logger.error(\n `Failed to decrypt event with new key. Dropping encrypted event`\n );\n return;\n }\n this.emit(event, this.getDataToEmit(bytes));\n return;\n });\n return;\n }\n this.emit(event, this.getDataToEmit(bytes));\n }\n\n // Try and parse the decrypted bytes as JSON. If we can't parse it, just\n // return the utf-8 string\n getDataToEmit(bytes: Uint8Array): string {\n let raw = encodeUTF8(bytes);\n try {\n return JSON.parse(raw);\n } catch {\n return raw;\n }\n }\n}\n","import { default as EventsDispatcher } from '../events/dispatcher';\nimport { OneOffTimer as Timer } from '../utils/timers';\nimport { Config } from '../config';\nimport Logger from '../logger';\nimport HandshakePayload from './handshake/handshake_payload';\nimport Connection from './connection';\nimport Strategy from '../strategies/strategy';\nimport StrategyRunner from '../strategies/strategy_runner';\nimport * as Collections from '../utils/collections';\nimport Timeline from '../timeline/timeline';\nimport ConnectionManagerOptions from './connection_manager_options';\nimport Runtime from 'runtime';\n\nimport {\n ErrorCallbacks,\n HandshakeCallbacks,\n ConnectionCallbacks\n} from './callbacks';\nimport Action from './protocol/action';\n\n/** Manages connection to Pusher.\n *\n * Uses a strategy (currently only default), timers and network availability\n * info to establish a connection and export its state. In case of failures,\n * manages reconnection attempts.\n *\n * Exports state changes as following events:\n * - \"state_change\", { previous: p, current: state }\n * - state\n *\n * States:\n * - initialized - initial state, never transitioned to\n * - connecting - connection is being established\n * - connected - connection has been fully established\n * - disconnected - on requested disconnection\n * - unavailable - after connection timeout or when there's no network\n * - failed - when the connection strategy is not supported\n *\n * Options:\n * - unavailableTimeout - time to transition to unavailable state\n * - activityTimeout - time after which ping message should be sent\n * - pongTimeout - time for Pusher to respond with pong before reconnecting\n *\n * @param {String} key application key\n * @param {Object} options\n */\nexport default class ConnectionManager extends EventsDispatcher {\n key: string;\n options: ConnectionManagerOptions;\n state: string;\n connection: Connection;\n usingTLS: boolean;\n timeline: Timeline;\n socket_id: string;\n unavailableTimer: Timer;\n activityTimer: Timer;\n retryTimer: Timer;\n activityTimeout: number;\n strategy: Strategy;\n runner: StrategyRunner;\n errorCallbacks: ErrorCallbacks;\n handshakeCallbacks: HandshakeCallbacks;\n connectionCallbacks: ConnectionCallbacks;\n\n constructor(key: string, options: ConnectionManagerOptions) {\n super();\n this.state = 'initialized';\n this.connection = null;\n\n this.key = key;\n this.options = options;\n this.timeline = this.options.timeline;\n this.usingTLS = this.options.useTLS;\n\n this.errorCallbacks = this.buildErrorCallbacks();\n this.connectionCallbacks = this.buildConnectionCallbacks(\n this.errorCallbacks\n );\n this.handshakeCallbacks = this.buildHandshakeCallbacks(this.errorCallbacks);\n\n var Network = Runtime.getNetwork();\n\n Network.bind('online', () => {\n this.timeline.info({ netinfo: 'online' });\n if (this.state === 'connecting' || this.state === 'unavailable') {\n this.retryIn(0);\n }\n });\n Network.bind('offline', () => {\n this.timeline.info({ netinfo: 'offline' });\n if (this.connection) {\n this.sendActivityCheck();\n }\n });\n\n this.updateStrategy();\n }\n\n switchCluster(key: string) {\n this.key = key;\n // This ensures that the new config coming from\n // pusher instance are taken into account\n // such as appKey and cluster\n this.updateStrategy();\n this.retryIn(0);\n }\n\n /** Establishes a connection to Pusher.\n *\n * Does nothing when connection is already established. See top-level doc\n * to find events emitted on connection attempts.\n */\n connect() {\n if (this.connection || this.runner) {\n return;\n }\n if (!this.strategy.isSupported()) {\n this.updateState('failed');\n return;\n }\n this.updateState('connecting');\n this.startConnecting();\n this.setUnavailableTimer();\n }\n\n /** Sends raw data.\n *\n * @param {String} data\n */\n send(data) {\n if (this.connection) {\n return this.connection.send(data);\n } else {\n return false;\n }\n }\n\n /** Sends an event.\n *\n * @param {String} name\n * @param {String} data\n * @param {String} [channel]\n * @returns {Boolean} whether message was sent or not\n */\n send_event(name: string, data: any, channel?: string) {\n if (this.connection) {\n return this.connection.send_event(name, data, channel);\n } else {\n return false;\n }\n }\n\n /** Closes the connection. */\n disconnect() {\n this.disconnectInternally();\n this.updateState('disconnected');\n }\n\n isUsingTLS() {\n return this.usingTLS;\n }\n\n private startConnecting() {\n var callback = (error, handshake) => {\n if (error) {\n this.runner = this.strategy.connect(0, callback);\n } else {\n if (handshake.action === 'error') {\n this.emit('error', {\n type: 'HandshakeError',\n error: handshake.error\n });\n this.timeline.error({ handshakeError: handshake.error });\n } else {\n this.abortConnecting(); // we don't support switching connections yet\n this.handshakeCallbacks[handshake.action](handshake);\n }\n }\n };\n this.runner = this.strategy.connect(0, callback);\n }\n\n private abortConnecting() {\n if (this.runner) {\n this.runner.abort();\n this.runner = null;\n }\n }\n\n private disconnectInternally() {\n this.abortConnecting();\n this.clearRetryTimer();\n this.clearUnavailableTimer();\n if (this.connection) {\n var connection = this.abandonConnection();\n connection.close();\n }\n }\n\n private updateStrategy() {\n this.strategy = this.options.getStrategy({\n key: this.key,\n timeline: this.timeline,\n useTLS: this.usingTLS\n });\n }\n\n private retryIn(delay) {\n this.timeline.info({ action: 'retry', delay: delay });\n if (delay > 0) {\n this.emit('connecting_in', Math.round(delay / 1000));\n }\n this.retryTimer = new Timer(delay || 0, () => {\n this.disconnectInternally();\n this.connect();\n });\n }\n\n private clearRetryTimer() {\n if (this.retryTimer) {\n this.retryTimer.ensureAborted();\n this.retryTimer = null;\n }\n }\n\n private setUnavailableTimer() {\n this.unavailableTimer = new Timer(this.options.unavailableTimeout, () => {\n this.updateState('unavailable');\n });\n }\n\n private clearUnavailableTimer() {\n if (this.unavailableTimer) {\n this.unavailableTimer.ensureAborted();\n }\n }\n\n private sendActivityCheck() {\n this.stopActivityCheck();\n this.connection.ping();\n // wait for pong response\n this.activityTimer = new Timer(this.options.pongTimeout, () => {\n this.timeline.error({ pong_timed_out: this.options.pongTimeout });\n this.retryIn(0);\n });\n }\n\n private resetActivityCheck() {\n this.stopActivityCheck();\n // send ping after inactivity\n if (this.connection && !this.connection.handlesActivityChecks()) {\n this.activityTimer = new Timer(this.activityTimeout, () => {\n this.sendActivityCheck();\n });\n }\n }\n\n private stopActivityCheck() {\n if (this.activityTimer) {\n this.activityTimer.ensureAborted();\n }\n }\n\n private buildConnectionCallbacks(\n errorCallbacks: ErrorCallbacks\n ): ConnectionCallbacks {\n return Collections.extend({}, errorCallbacks, {\n message: message => {\n // includes pong messages from server\n this.resetActivityCheck();\n this.emit('message', message);\n },\n ping: () => {\n this.send_event('pusher:pong', {});\n },\n activity: () => {\n this.resetActivityCheck();\n },\n error: error => {\n // just emit error to user - socket will already be closed by browser\n this.emit('error', error);\n },\n closed: () => {\n this.abandonConnection();\n if (this.shouldRetry()) {\n this.retryIn(1000);\n }\n }\n });\n }\n\n private buildHandshakeCallbacks(\n errorCallbacks: ErrorCallbacks\n ): HandshakeCallbacks {\n return Collections.extend({}, errorCallbacks, {\n connected: (handshake: HandshakePayload) => {\n this.activityTimeout = Math.min(\n this.options.activityTimeout,\n handshake.activityTimeout,\n handshake.connection.activityTimeout || Infinity\n );\n this.clearUnavailableTimer();\n this.setConnection(handshake.connection);\n this.socket_id = this.connection.id;\n this.updateState('connected', { socket_id: this.socket_id });\n }\n });\n }\n\n private buildErrorCallbacks(): ErrorCallbacks {\n let withErrorEmitted = callback => {\n return (result: Action | HandshakePayload) => {\n if (result.error) {\n this.emit('error', { type: 'WebSocketError', error: result.error });\n }\n callback(result);\n };\n };\n\n return {\n tls_only: withErrorEmitted(() => {\n this.usingTLS = true;\n this.updateStrategy();\n this.retryIn(0);\n }),\n refused: withErrorEmitted(() => {\n this.disconnect();\n }),\n backoff: withErrorEmitted(() => {\n this.retryIn(1000);\n }),\n retry: withErrorEmitted(() => {\n this.retryIn(0);\n })\n };\n }\n\n private setConnection(connection) {\n this.connection = connection;\n for (var event in this.connectionCallbacks) {\n this.connection.bind(event, this.connectionCallbacks[event]);\n }\n this.resetActivityCheck();\n }\n\n private abandonConnection() {\n if (!this.connection) {\n return;\n }\n this.stopActivityCheck();\n for (var event in this.connectionCallbacks) {\n this.connection.unbind(event, this.connectionCallbacks[event]);\n }\n var connection = this.connection;\n this.connection = null;\n return connection;\n }\n\n private updateState(newState: string, data?: any) {\n var previousState = this.state;\n this.state = newState;\n if (previousState !== newState) {\n var newStateDescription = newState;\n if (newStateDescription === 'connected') {\n newStateDescription += ' with new socket ID ' + data.socket_id;\n }\n Logger.debug(\n 'State changed',\n previousState + ' -> ' + newStateDescription\n );\n this.timeline.info({ state: newState, params: data });\n this.emit('state_change', { previous: previousState, current: newState });\n this.emit(newState, data);\n }\n }\n\n private shouldRetry(): boolean {\n return this.state === 'connecting' || this.state === 'connected';\n }\n}\n","import Channel from './channel';\nimport * as Collections from '../utils/collections';\nimport ChannelTable from './channel_table';\nimport Factory from '../utils/factory';\nimport Pusher from '../pusher';\nimport Logger from '../logger';\nimport * as Errors from '../errors';\nimport urlStore from '../utils/url_store';\n\n/** Handles a channel map. */\nexport default class Channels {\n channels: ChannelTable;\n\n constructor() {\n this.channels = {};\n }\n\n /** Creates or retrieves an existing channel by its name.\n *\n * @param {String} name\n * @param {Pusher} pusher\n * @return {Channel}\n */\n add(name: string, pusher: Pusher) {\n if (!this.channels[name]) {\n this.channels[name] = createChannel(name, pusher);\n }\n return this.channels[name];\n }\n\n /** Returns a list of all channels\n *\n * @return {Array}\n */\n all(): Channel[] {\n return Collections.values(this.channels);\n }\n\n /** Finds a channel by its name.\n *\n * @param {String} name\n * @return {Channel} channel or null if it doesn't exist\n */\n find(name: string) {\n return this.channels[name];\n }\n\n /** Removes a channel from the map.\n *\n * @param {String} name\n */\n remove(name: string) {\n var channel = this.channels[name];\n delete this.channels[name];\n return channel;\n }\n\n /** Proxies disconnection signal to all channels. */\n disconnect() {\n Collections.objectApply(this.channels, function(channel) {\n channel.disconnect();\n });\n }\n}\n\nfunction createChannel(name: string, pusher: Pusher): Channel {\n if (name.indexOf('private-encrypted-') === 0) {\n if (pusher.config.nacl) {\n return Factory.createEncryptedChannel(name, pusher, pusher.config.nacl);\n }\n let errMsg =\n 'Tried to subscribe to a private-encrypted- channel but no nacl implementation available';\n let suffix = urlStore.buildLogSuffix('encryptedChannelSupport');\n throw new Errors.UnsupportedFeature(`${errMsg}. ${suffix}`);\n } else if (name.indexOf('private-') === 0) {\n return Factory.createPrivateChannel(name, pusher);\n } else if (name.indexOf('presence-') === 0) {\n return Factory.createPresenceChannel(name, pusher);\n } else if (name.indexOf('#') === 0) {\n throw new Errors.BadChannelName(\n 'Cannot create a channel with name \"' + name + '\".'\n );\n } else {\n return Factory.createChannel(name, pusher);\n }\n}\n","import AssistantToTheTransportManager from '../transports/assistant_to_the_transport_manager';\nimport PingDelayOptions from '../transports/ping_delay_options';\nimport Transport from '../transports/transport';\nimport TransportManager from '../transports/transport_manager';\nimport Handshake from '../connection/handshake';\nimport TransportConnection from '../transports/transport_connection';\nimport SocketHooks from '../http/socket_hooks';\nimport HTTPSocket from '../http/http_socket';\n\nimport Timeline from '../timeline/timeline';\nimport {\n default as TimelineSender,\n TimelineSenderOptions\n} from '../timeline/timeline_sender';\nimport PresenceChannel from '../channels/presence_channel';\nimport PrivateChannel from '../channels/private_channel';\nimport EncryptedChannel from '../channels/encrypted_channel';\nimport Channel from '../channels/channel';\nimport ConnectionManager from '../connection/connection_manager';\nimport ConnectionManagerOptions from '../connection/connection_manager_options';\nimport Ajax from '../http/ajax';\nimport Channels from '../channels/channels';\nimport Pusher from '../pusher';\nimport { Config } from '../config';\nimport * as nacl from 'tweetnacl';\n\nvar Factory = {\n createChannels(): Channels {\n return new Channels();\n },\n\n createConnectionManager(\n key: string,\n options: ConnectionManagerOptions\n ): ConnectionManager {\n return new ConnectionManager(key, options);\n },\n\n createChannel(name: string, pusher: Pusher): Channel {\n return new Channel(name, pusher);\n },\n\n createPrivateChannel(name: string, pusher: Pusher): PrivateChannel {\n return new PrivateChannel(name, pusher);\n },\n\n createPresenceChannel(name: string, pusher: Pusher): PresenceChannel {\n return new PresenceChannel(name, pusher);\n },\n\n createEncryptedChannel(\n name: string,\n pusher: Pusher,\n nacl: nacl\n ): EncryptedChannel {\n return new EncryptedChannel(name, pusher, nacl);\n },\n\n createTimelineSender(timeline: Timeline, options: TimelineSenderOptions) {\n return new TimelineSender(timeline, options);\n },\n\n createHandshake(\n transport: TransportConnection,\n callback: (HandshakePayload) => void\n ): Handshake {\n return new Handshake(transport, callback);\n },\n\n createAssistantToTheTransportManager(\n manager: TransportManager,\n transport: Transport,\n options: PingDelayOptions\n ): AssistantToTheTransportManager {\n return new AssistantToTheTransportManager(manager, transport, options);\n }\n};\n\nexport default Factory;\n","import AssistantToTheTransportManager from './assistant_to_the_transport_manager';\nimport Transport from './transport';\nimport PingDelayOptions from './ping_delay_options';\nimport Factory from '../utils/factory';\n\nexport interface TransportManagerOptions extends PingDelayOptions {\n lives?: number;\n}\n\n/** Keeps track of the number of lives left for a transport.\n *\n * In the beginning of a session, transports may be assigned a number of\n * lives. When an AssistantToTheTransportManager instance reports a transport\n * connection closed uncleanly, the transport loses a life. When the number\n * of lives drops to zero, the transport gets disabled by its manager.\n *\n * @param {Object} options\n */\nexport default class TransportManager {\n options: TransportManagerOptions;\n livesLeft: number;\n\n constructor(options: TransportManagerOptions) {\n this.options = options || {};\n this.livesLeft = this.options.lives || Infinity;\n }\n\n /** Creates a assistant for the transport.\n *\n * @param {Transport} transport\n * @returns {AssistantToTheTransportManager}\n */\n getAssistant(transport: Transport): AssistantToTheTransportManager {\n return Factory.createAssistantToTheTransportManager(this, transport, {\n minPingDelay: this.options.minPingDelay,\n maxPingDelay: this.options.maxPingDelay\n });\n }\n\n /** Returns whether the transport has any lives left.\n *\n * @returns {Boolean}\n */\n isAlive(): boolean {\n return this.livesLeft > 0;\n }\n\n /** Takes one life from the transport. */\n reportDeath() {\n this.livesLeft -= 1;\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport { OneOffTimer as Timer } from '../utils/timers';\nimport Strategy from './strategy';\nimport StrategyOptions from './strategy_options';\n\n/** Loops through strategies with optional timeouts.\n *\n * Options:\n * - loop - whether it should loop through the substrategy list\n * - timeout - initial timeout for a single substrategy\n * - timeoutLimit - maximum timeout\n *\n * @param {Strategy[]} strategies\n * @param {Object} options\n */\nexport default class SequentialStrategy implements Strategy {\n strategies: Strategy[];\n loop: boolean;\n failFast: boolean;\n timeout: number;\n timeoutLimit: number;\n\n constructor(strategies: Strategy[], options: StrategyOptions) {\n this.strategies = strategies;\n this.loop = Boolean(options.loop);\n this.failFast = Boolean(options.failFast);\n this.timeout = options.timeout;\n this.timeoutLimit = options.timeoutLimit;\n }\n\n isSupported(): boolean {\n return Collections.any(this.strategies, Util.method('isSupported'));\n }\n\n connect(minPriority: number, callback: Function) {\n var strategies = this.strategies;\n var current = 0;\n var timeout = this.timeout;\n var runner = null;\n\n var tryNextStrategy = (error, handshake) => {\n if (handshake) {\n callback(null, handshake);\n } else {\n current = current + 1;\n if (this.loop) {\n current = current % strategies.length;\n }\n\n if (current < strategies.length) {\n if (timeout) {\n timeout = timeout * 2;\n if (this.timeoutLimit) {\n timeout = Math.min(timeout, this.timeoutLimit);\n }\n }\n runner = this.tryStrategy(\n strategies[current],\n minPriority,\n { timeout, failFast: this.failFast },\n tryNextStrategy\n );\n } else {\n callback(true);\n }\n }\n };\n\n runner = this.tryStrategy(\n strategies[current],\n minPriority,\n { timeout: timeout, failFast: this.failFast },\n tryNextStrategy\n );\n\n return {\n abort: function() {\n runner.abort();\n },\n forceMinPriority: function(p) {\n minPriority = p;\n if (runner) {\n runner.forceMinPriority(p);\n }\n }\n };\n }\n\n private tryStrategy(\n strategy: Strategy,\n minPriority: number,\n options: StrategyOptions,\n callback: Function\n ) {\n var timer = null;\n var runner = null;\n\n if (options.timeout > 0) {\n timer = new Timer(options.timeout, function() {\n runner.abort();\n callback(true);\n });\n }\n\n runner = strategy.connect(minPriority, function(error, handshake) {\n if (error && timer && timer.isRunning() && !options.failFast) {\n // advance to the next strategy after the timeout\n return;\n }\n if (timer) {\n timer.ensureAborted();\n }\n callback(error, handshake);\n });\n\n return {\n abort: function() {\n if (timer) {\n timer.ensureAborted();\n }\n runner.abort();\n },\n forceMinPriority: function(p) {\n runner.forceMinPriority(p);\n }\n };\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport Strategy from './strategy';\n\n/** Launches all substrategies and emits prioritized connected transports.\n *\n * @param {Array} strategies\n */\nexport default class BestConnectedEverStrategy implements Strategy {\n strategies: Strategy[];\n\n constructor(strategies: Strategy[]) {\n this.strategies = strategies;\n }\n\n isSupported(): boolean {\n return Collections.any(this.strategies, Util.method('isSupported'));\n }\n\n connect(minPriority: number, callback: Function) {\n return connect(this.strategies, minPriority, function(i, runners) {\n return function(error, handshake) {\n runners[i].error = error;\n if (error) {\n if (allRunnersFailed(runners)) {\n callback(true);\n }\n return;\n }\n Collections.apply(runners, function(runner) {\n runner.forceMinPriority(handshake.transport.priority);\n });\n callback(null, handshake);\n };\n });\n }\n}\n\n/** Connects to all strategies in parallel.\n *\n * Callback builder should be a function that takes two arguments: index\n * and a list of runners. It should return another function that will be\n * passed to the substrategy with given index. Runners can be aborted using\n * abortRunner(s) functions from this class.\n *\n * @param {Array} strategies\n * @param {Function} callbackBuilder\n * @return {Object} strategy runner\n */\nfunction connect(\n strategies: Strategy[],\n minPriority: number,\n callbackBuilder: Function\n) {\n var runners = Collections.map(strategies, function(strategy, i, _, rs) {\n return strategy.connect(minPriority, callbackBuilder(i, rs));\n });\n return {\n abort: function() {\n Collections.apply(runners, abortRunner);\n },\n forceMinPriority: function(p) {\n Collections.apply(runners, function(runner) {\n runner.forceMinPriority(p);\n });\n }\n };\n}\n\nfunction allRunnersFailed(runners): boolean {\n return Collections.all(runners, function(runner) {\n return Boolean(runner.error);\n });\n}\n\nfunction abortRunner(runner) {\n if (!runner.error && !runner.aborted) {\n runner.abort();\n runner.aborted = true;\n }\n}\n","import Util from '../util';\nimport Runtime from 'runtime';\nimport Strategy from './strategy';\nimport SequentialStrategy from './sequential_strategy';\nimport StrategyOptions from './strategy_options';\nimport TransportStrategy from './transport_strategy';\nimport Timeline from '../timeline/timeline';\nimport * as Collections from '../utils/collections';\n\nexport interface TransportStrategyDictionary {\n [key: string]: TransportStrategy;\n}\n\n/** Caches the last successful transport and, after the first few attempts,\n * uses the cached transport for subsequent attempts.\n *\n * @param {Strategy} strategy\n * @param {Object} transports\n * @param {Object} options\n */\nexport default class WebSocketPrioritizedCachedStrategy implements Strategy {\n strategy: Strategy;\n transports: TransportStrategyDictionary;\n ttl: number;\n usingTLS: boolean;\n timeline: Timeline;\n\n constructor(\n strategy: Strategy,\n transports: TransportStrategyDictionary,\n options: StrategyOptions\n ) {\n this.strategy = strategy;\n this.transports = transports;\n this.ttl = options.ttl || 1800 * 1000;\n this.usingTLS = options.useTLS;\n this.timeline = options.timeline;\n }\n\n isSupported(): boolean {\n return this.strategy.isSupported();\n }\n\n connect(minPriority: number, callback: Function) {\n var usingTLS = this.usingTLS;\n var info = fetchTransportCache(usingTLS);\n var cacheSkipCount = info && info.cacheSkipCount ? info.cacheSkipCount : 0;\n\n var strategies = [this.strategy];\n if (info && info.timestamp + this.ttl >= Util.now()) {\n var transport = this.transports[info.transport];\n if (transport) {\n if (['ws', 'wss'].includes(info.transport) || cacheSkipCount > 3) {\n this.timeline.info({\n cached: true,\n transport: info.transport,\n latency: info.latency\n });\n strategies.push(\n new SequentialStrategy([transport], {\n timeout: info.latency * 2 + 1000,\n failFast: true\n })\n );\n } else {\n cacheSkipCount++;\n }\n }\n }\n\n var startTimestamp = Util.now();\n var runner = strategies\n .pop()\n .connect(minPriority, function cb(error, handshake) {\n if (error) {\n flushTransportCache(usingTLS);\n if (strategies.length > 0) {\n startTimestamp = Util.now();\n runner = strategies.pop().connect(minPriority, cb);\n } else {\n callback(error);\n }\n } else {\n storeTransportCache(\n usingTLS,\n handshake.transport.name,\n Util.now() - startTimestamp,\n cacheSkipCount\n );\n callback(null, handshake);\n }\n });\n\n return {\n abort: function() {\n runner.abort();\n },\n forceMinPriority: function(p) {\n minPriority = p;\n if (runner) {\n runner.forceMinPriority(p);\n }\n }\n };\n }\n}\n\nfunction getTransportCacheKey(usingTLS: boolean): string {\n return 'pusherTransport' + (usingTLS ? 'TLS' : 'NonTLS');\n}\n\nfunction fetchTransportCache(usingTLS: boolean): any {\n var storage = Runtime.getLocalStorage();\n if (storage) {\n try {\n var serializedCache = storage[getTransportCacheKey(usingTLS)];\n if (serializedCache) {\n return JSON.parse(serializedCache);\n }\n } catch (e) {\n flushTransportCache(usingTLS);\n }\n }\n return null;\n}\n\nfunction storeTransportCache(\n usingTLS: boolean,\n transport: TransportStrategy,\n latency: number,\n cacheSkipCount: number\n) {\n var storage = Runtime.getLocalStorage();\n if (storage) {\n try {\n storage[getTransportCacheKey(usingTLS)] = Collections.safeJSONStringify({\n timestamp: Util.now(),\n transport: transport,\n latency: latency,\n cacheSkipCount: cacheSkipCount\n });\n } catch (e) {\n // catch over quota exceptions raised by localStorage\n }\n }\n}\n\nfunction flushTransportCache(usingTLS: boolean) {\n var storage = Runtime.getLocalStorage();\n if (storage) {\n try {\n delete storage[getTransportCacheKey(usingTLS)];\n } catch (e) {\n // catch exceptions raised by localStorage\n }\n }\n}\n","import { OneOffTimer as Timer } from '../utils/timers';\nimport Strategy from './strategy';\nimport StrategyOptions from './strategy_options';\n\n/** Runs substrategy after specified delay.\n *\n * Options:\n * - delay - time in miliseconds to delay the substrategy attempt\n *\n * @param {Strategy} strategy\n * @param {Object} options\n */\nexport default class DelayedStrategy implements Strategy {\n strategy: Strategy;\n options: { delay: number };\n\n constructor(strategy: Strategy, { delay: number }) {\n this.strategy = strategy;\n this.options = { delay: number };\n }\n\n isSupported(): boolean {\n return this.strategy.isSupported();\n }\n\n connect(minPriority: number, callback: Function) {\n var strategy = this.strategy;\n var runner;\n var timer = new Timer(this.options.delay, function() {\n runner = strategy.connect(minPriority, callback);\n });\n\n return {\n abort: function() {\n timer.ensureAborted();\n if (runner) {\n runner.abort();\n }\n },\n forceMinPriority: function(p) {\n minPriority = p;\n if (runner) {\n runner.forceMinPriority(p);\n }\n }\n };\n }\n}\n","import Strategy from './strategy';\nimport StrategyRunner from './strategy_runner';\n\n/** Proxies method calls to one of substrategies basing on the test function.\n *\n * @param {Function} test\n * @param {Strategy} trueBranch strategy used when test returns true\n * @param {Strategy} falseBranch strategy used when test returns false\n */\nexport default class IfStrategy implements Strategy {\n test: () => boolean;\n trueBranch: Strategy;\n falseBranch: Strategy;\n\n constructor(\n test: () => boolean,\n trueBranch: Strategy,\n falseBranch: Strategy\n ) {\n this.test = test;\n this.trueBranch = trueBranch;\n this.falseBranch = falseBranch;\n }\n\n isSupported(): boolean {\n var branch = this.test() ? this.trueBranch : this.falseBranch;\n return branch.isSupported();\n }\n\n connect(minPriority: number, callback: Function): StrategyRunner {\n var branch = this.test() ? this.trueBranch : this.falseBranch;\n return branch.connect(minPriority, callback);\n }\n}\n","import Strategy from './strategy';\nimport StrategyRunner from './strategy_runner';\n\n/** Launches the substrategy and terminates on the first open connection.\n *\n * @param {Strategy} strategy\n */\nexport default class FirstConnectedStrategy implements Strategy {\n strategy: Strategy;\n\n constructor(strategy: Strategy) {\n this.strategy = strategy;\n }\n\n isSupported(): boolean {\n return this.strategy.isSupported();\n }\n\n connect(minPriority: number, callback: Function): StrategyRunner {\n var runner = this.strategy.connect(minPriority, function(error, handshake) {\n if (handshake) {\n runner.abort();\n }\n callback(error, handshake);\n });\n return runner;\n }\n}\n","import * as Collections from 'core/utils/collections';\nimport TransportManager from 'core/transports/transport_manager';\nimport Strategy from 'core/strategies/strategy';\nimport SequentialStrategy from 'core/strategies/sequential_strategy';\nimport BestConnectedEverStrategy from 'core/strategies/best_connected_ever_strategy';\nimport WebSocketPrioritizedCachedStrategy, {\n TransportStrategyDictionary\n} from 'core/strategies/websocket_prioritized_cached_strategy';\nimport DelayedStrategy from 'core/strategies/delayed_strategy';\nimport IfStrategy from 'core/strategies/if_strategy';\nimport FirstConnectedStrategy from 'core/strategies/first_connected_strategy';\nimport { Config } from 'core/config';\nimport StrategyOptions from 'core/strategies/strategy_options';\n\nfunction testSupportsStrategy(strategy: Strategy) {\n return function() {\n return strategy.isSupported();\n };\n}\n\nvar getDefaultStrategy = function(\n config: Config,\n baseOptions: StrategyOptions,\n defineTransport: Function\n): Strategy {\n var definedTransports = {};\n\n function defineTransportStrategy(\n name: string,\n type: string,\n priority: number,\n options: StrategyOptions,\n manager?: TransportManager\n ) {\n var transport = defineTransport(\n config,\n name,\n type,\n priority,\n options,\n manager\n );\n\n definedTransports[name] = transport;\n\n return transport;\n }\n\n var ws_options: StrategyOptions = Object.assign({}, baseOptions, {\n hostNonTLS: config.wsHost + ':' + config.wsPort,\n hostTLS: config.wsHost + ':' + config.wssPort,\n httpPath: config.wsPath\n });\n var wss_options: StrategyOptions = Collections.extend({}, ws_options, {\n useTLS: true\n });\n var http_options: StrategyOptions = Object.assign({}, baseOptions, {\n hostNonTLS: config.httpHost + ':' + config.httpPort,\n hostTLS: config.httpHost + ':' + config.httpsPort,\n httpPath: config.httpPath\n });\n var timeouts = {\n loop: true,\n timeout: 15000,\n timeoutLimit: 60000\n };\n\n var ws_manager = new TransportManager({\n minPingDelay: 10000,\n maxPingDelay: config.activityTimeout\n });\n var streaming_manager = new TransportManager({\n lives: 2,\n minPingDelay: 10000,\n maxPingDelay: config.activityTimeout\n });\n\n var ws_transport = defineTransportStrategy(\n 'ws',\n 'ws',\n 3,\n ws_options,\n ws_manager\n );\n var wss_transport = defineTransportStrategy(\n 'wss',\n 'ws',\n 3,\n wss_options,\n ws_manager\n );\n var xhr_streaming_transport = defineTransportStrategy(\n 'xhr_streaming',\n 'xhr_streaming',\n 1,\n http_options,\n streaming_manager\n );\n var xhr_polling_transport = defineTransportStrategy(\n 'xhr_polling',\n 'xhr_polling',\n 1,\n http_options\n );\n\n var ws_loop = new SequentialStrategy([ws_transport], timeouts);\n var wss_loop = new SequentialStrategy([wss_transport], timeouts);\n var streaming_loop = new SequentialStrategy(\n [xhr_streaming_transport],\n timeouts\n );\n var polling_loop = new SequentialStrategy([xhr_polling_transport], timeouts);\n\n var http_loop = new SequentialStrategy(\n [\n new IfStrategy(\n testSupportsStrategy(streaming_loop),\n new BestConnectedEverStrategy([\n streaming_loop,\n new DelayedStrategy(polling_loop, { delay: 4000 })\n ]),\n polling_loop\n )\n ],\n timeouts\n );\n\n var wsStrategy;\n if (baseOptions.useTLS) {\n wsStrategy = new BestConnectedEverStrategy([\n ws_loop,\n new DelayedStrategy(http_loop, { delay: 2000 })\n ]);\n } else {\n wsStrategy = new BestConnectedEverStrategy([\n ws_loop,\n new DelayedStrategy(wss_loop, { delay: 2000 }),\n new DelayedStrategy(http_loop, { delay: 5000 })\n ]);\n }\n\n return new WebSocketPrioritizedCachedStrategy(\n new FirstConnectedStrategy(\n new IfStrategy(testSupportsStrategy(ws_transport), wsStrategy, http_loop)\n ),\n definedTransports,\n {\n ttl: 1800000,\n timeline: baseOptions.timeline,\n useTLS: baseOptions.useTLS\n }\n );\n};\n\nexport default getDefaultStrategy;\n","/** Initializes the transport.\n *\n * Fetches resources if needed and then transitions to initialized.\n */\nexport default function() {\n var self = this;\n\n self.timeline.info(\n self.buildTimelineMessage({\n transport: self.name + (self.options.useTLS ? 's' : '')\n })\n );\n\n if (self.hooks.isInitialized()) {\n self.changeState('initialized');\n } else {\n self.onClose();\n }\n}\n","import Runtime from 'runtime';\nimport RequestHooks from './request_hooks';\nimport Ajax from './ajax';\nimport { default as EventsDispatcher } from '../events/dispatcher';\n\nconst MAX_BUFFER_LENGTH = 256 * 1024;\n\nexport default class HTTPRequest extends EventsDispatcher {\n hooks: RequestHooks;\n method: string;\n url: string;\n position: number;\n xhr: Ajax;\n unloader: Function;\n\n constructor(hooks: RequestHooks, method: string, url: string) {\n super();\n this.hooks = hooks;\n this.method = method;\n this.url = url;\n }\n\n start(payload?: any) {\n this.position = 0;\n this.xhr = this.hooks.getRequest(this);\n\n this.unloader = () => {\n this.close();\n };\n Runtime.addUnloadListener(this.unloader);\n\n this.xhr.open(this.method, this.url, true);\n\n if (this.xhr.setRequestHeader) {\n this.xhr.setRequestHeader('Content-Type', 'application/json'); // ReactNative doesn't set this header by default.\n }\n this.xhr.send(payload);\n }\n\n close() {\n if (this.unloader) {\n Runtime.removeUnloadListener(this.unloader);\n this.unloader = null;\n }\n if (this.xhr) {\n this.hooks.abortRequest(this.xhr);\n this.xhr = null;\n }\n }\n\n onChunk(status: number, data: any) {\n while (true) {\n var chunk = this.advanceBuffer(data);\n if (chunk) {\n this.emit('chunk', { status: status, data: chunk });\n } else {\n break;\n }\n }\n if (this.isBufferTooLong(data)) {\n this.emit('buffer_too_long');\n }\n }\n\n private advanceBuffer(buffer: any[]): any {\n var unreadData = buffer.slice(this.position);\n var endOfLinePosition = unreadData.indexOf('\\n');\n\n if (endOfLinePosition !== -1) {\n this.position += endOfLinePosition + 1;\n return unreadData.slice(0, endOfLinePosition);\n } else {\n // chunk is not finished yet, don't move the buffer pointer\n return null;\n }\n }\n\n private isBufferTooLong(buffer: any): boolean {\n return this.position === buffer.length && buffer.length > MAX_BUFFER_LENGTH;\n }\n}\n","enum State {\n CONNECTING = 0,\n OPEN = 1,\n CLOSED = 3\n}\n\nexport default State;\n","import URLLocation from './url_location';\nimport State from './state';\nimport Socket from '../socket';\nimport SocketHooks from './socket_hooks';\nimport Util from '../util';\nimport Ajax from './ajax';\nimport HTTPRequest from './http_request';\nimport Runtime from 'runtime';\n\nvar autoIncrement = 1;\n\nclass HTTPSocket implements Socket {\n hooks: SocketHooks;\n session: string;\n location: URLLocation;\n readyState: State;\n stream: HTTPRequest;\n\n onopen: () => void;\n onerror: (error: any) => void;\n onclose: (closeEvent: any) => void;\n onmessage: (message: any) => void;\n onactivity: () => void;\n\n constructor(hooks: SocketHooks, url: string) {\n this.hooks = hooks;\n this.session = randomNumber(1000) + '/' + randomString(8);\n this.location = getLocation(url);\n this.readyState = State.CONNECTING;\n this.openStream();\n }\n\n send(payload: any) {\n return this.sendRaw(JSON.stringify([payload]));\n }\n\n ping() {\n this.hooks.sendHeartbeat(this);\n }\n\n close(code: any, reason: any) {\n this.onClose(code, reason, true);\n }\n\n /** For internal use only */\n sendRaw(payload: any): boolean {\n if (this.readyState === State.OPEN) {\n try {\n Runtime.createSocketRequest(\n 'POST',\n getUniqueURL(getSendURL(this.location, this.session))\n ).start(payload);\n return true;\n } catch (e) {\n return false;\n }\n } else {\n return false;\n }\n }\n\n /** For internal use only */\n reconnect() {\n this.closeStream();\n this.openStream();\n }\n\n /** For internal use only */\n onClose(code, reason, wasClean) {\n this.closeStream();\n this.readyState = State.CLOSED;\n if (this.onclose) {\n this.onclose({\n code: code,\n reason: reason,\n wasClean: wasClean\n });\n }\n }\n\n private onChunk(chunk) {\n if (chunk.status !== 200) {\n return;\n }\n if (this.readyState === State.OPEN) {\n this.onActivity();\n }\n\n var payload;\n var type = chunk.data.slice(0, 1);\n switch (type) {\n case 'o':\n payload = JSON.parse(chunk.data.slice(1) || '{}');\n this.onOpen(payload);\n break;\n case 'a':\n payload = JSON.parse(chunk.data.slice(1) || '[]');\n for (var i = 0; i < payload.length; i++) {\n this.onEvent(payload[i]);\n }\n break;\n case 'm':\n payload = JSON.parse(chunk.data.slice(1) || 'null');\n this.onEvent(payload);\n break;\n case 'h':\n this.hooks.onHeartbeat(this);\n break;\n case 'c':\n payload = JSON.parse(chunk.data.slice(1) || '[]');\n this.onClose(payload[0], payload[1], true);\n break;\n }\n }\n\n private onOpen(options) {\n if (this.readyState === State.CONNECTING) {\n if (options && options.hostname) {\n this.location.base = replaceHost(this.location.base, options.hostname);\n }\n this.readyState = State.OPEN;\n\n if (this.onopen) {\n this.onopen();\n }\n } else {\n this.onClose(1006, 'Server lost session', true);\n }\n }\n\n private onEvent(event) {\n if (this.readyState === State.OPEN && this.onmessage) {\n this.onmessage({ data: event });\n }\n }\n\n private onActivity() {\n if (this.onactivity) {\n this.onactivity();\n }\n }\n\n private onError(error) {\n if (this.onerror) {\n this.onerror(error);\n }\n }\n\n private openStream() {\n this.stream = Runtime.createSocketRequest(\n 'POST',\n getUniqueURL(this.hooks.getReceiveURL(this.location, this.session))\n );\n\n this.stream.bind('chunk', chunk => {\n this.onChunk(chunk);\n });\n this.stream.bind('finished', status => {\n this.hooks.onFinished(this, status);\n });\n this.stream.bind('buffer_too_long', () => {\n this.reconnect();\n });\n\n try {\n this.stream.start();\n } catch (error) {\n Util.defer(() => {\n this.onError(error);\n this.onClose(1006, 'Could not start streaming', false);\n });\n }\n }\n\n private closeStream() {\n if (this.stream) {\n this.stream.unbind_all();\n this.stream.close();\n this.stream = null;\n }\n }\n}\n\nfunction getLocation(url): URLLocation {\n var parts = /([^\\?]*)\\/*(\\??.*)/.exec(url);\n return {\n base: parts[1],\n queryString: parts[2]\n };\n}\n\nfunction getSendURL(url: URLLocation, session: string): string {\n return url.base + '/' + session + '/xhr_send';\n}\n\nfunction getUniqueURL(url: string): string {\n var separator = url.indexOf('?') === -1 ? '?' : '&';\n return url + separator + 't=' + +new Date() + '&n=' + autoIncrement++;\n}\n\nfunction replaceHost(url: string, hostname: string): string {\n var urlParts = /(https?:\\/\\/)([^\\/:]+)((\\/|:)?.*)/.exec(url);\n return urlParts[1] + hostname + urlParts[3];\n}\n\nfunction randomNumber(max: number): number {\n return Runtime.randomInt(max);\n}\n\nfunction randomString(length: number): string {\n var result = [];\n\n for (var i = 0; i < length; i++) {\n result.push(randomNumber(32).toString(32));\n }\n\n return result.join('');\n}\n\nexport default HTTPSocket;\n","import SocketHooks from './socket_hooks';\nimport HTTPSocket from './http_socket';\n\nvar hooks: SocketHooks = {\n getReceiveURL: function(url, session) {\n return url.base + '/' + session + '/xhr_streaming' + url.queryString;\n },\n onHeartbeat: function(socket) {\n socket.sendRaw('[]');\n },\n sendHeartbeat: function(socket) {\n socket.sendRaw('[]');\n },\n onFinished: function(socket, status) {\n socket.onClose(1006, 'Connection interrupted (' + status + ')', false);\n }\n};\n\nexport default hooks;\n","import SocketHooks from './socket_hooks';\nimport URLLocation from './url_location';\nimport HTTPSocket from './http_socket';\n\nvar hooks: SocketHooks = {\n getReceiveURL: function(url: URLLocation, session: string): string {\n return url.base + '/' + session + '/xhr' + url.queryString;\n },\n onHeartbeat: function() {\n // next HTTP request will reset server's activity timer\n },\n sendHeartbeat: function(socket) {\n socket.sendRaw('[]');\n },\n onFinished: function(socket, status) {\n if (status === 200) {\n socket.reconnect();\n } else {\n socket.onClose(1006, 'Connection interrupted (' + status + ')', false);\n }\n }\n};\n\nexport default hooks;\n","import HTTPRequest from 'core/http/http_request';\nimport RequestHooks from 'core/http/request_hooks';\nimport Ajax from 'core/http/ajax';\nimport Runtime from 'runtime';\n\nvar hooks: RequestHooks = {\n getRequest: function(socket: HTTPRequest): Ajax {\n var Constructor = Runtime.getXHRAPI();\n var xhr = new Constructor();\n xhr.onreadystatechange = xhr.onprogress = function() {\n switch (xhr.readyState) {\n case 3:\n if (xhr.responseText && xhr.responseText.length > 0) {\n socket.onChunk(xhr.status, xhr.responseText);\n }\n break;\n case 4:\n // this happens only on errors, never after calling close\n if (xhr.responseText && xhr.responseText.length > 0) {\n socket.onChunk(xhr.status, xhr.responseText);\n }\n socket.emit('finished', xhr.status);\n socket.close();\n break;\n }\n };\n return xhr;\n },\n abortRequest: function(xhr: Ajax) {\n xhr.onreadystatechange = null;\n xhr.abort();\n }\n};\n\nexport default hooks;\n","import HTTPRequest from 'core/http/http_request';\nimport HTTPSocket from 'core/http/http_socket';\nimport SocketHooks from 'core/http/socket_hooks';\nimport RequestHooks from 'core/http/request_hooks';\nimport streamingHooks from 'core/http/http_streaming_socket';\nimport pollingHooks from 'core/http/http_polling_socket';\nimport xhrHooks from './http_xhr_request';\nimport HTTPFactory from 'core/http/http_factory';\n\nvar HTTP: HTTPFactory = {\n createStreamingSocket(url: string): HTTPSocket {\n return this.createSocket(streamingHooks, url);\n },\n\n createPollingSocket(url: string): HTTPSocket {\n return this.createSocket(pollingHooks, url);\n },\n\n createSocket(hooks: SocketHooks, url: string): HTTPSocket {\n return new HTTPSocket(hooks, url);\n },\n\n createXHR(method: string, url: string): HTTPRequest {\n return this.createRequest(xhrHooks, method, url);\n },\n\n createRequest(hooks: RequestHooks, method: string, url: string): HTTPRequest {\n return new HTTPRequest(hooks, method, url);\n }\n};\n\nexport default HTTP;\n","import * as Collections from 'core/utils/collections';\nimport Transports from 'isomorphic/transports/transports';\nimport TimelineSender from 'core/timeline/timeline_sender';\nimport Ajax from 'core/http/ajax';\nimport getDefaultStrategy from './default_strategy';\nimport TransportsTable from 'core/transports/transports_table';\nimport transportConnectionInitializer from './transports/transport_connection_initializer';\nimport HTTPFactory from './http/http';\n\nvar Isomorphic: any = {\n getDefaultStrategy,\n Transports: Transports,\n transportConnectionInitializer,\n HTTPFactory,\n\n setup(PusherClass): void {\n PusherClass.ready();\n },\n\n getLocalStorage(): any {\n return undefined;\n },\n\n getClientFeatures(): any[] {\n return Collections.keys(\n Collections.filterObject({ ws: Transports.ws }, function(t) {\n return t.isSupported({});\n })\n );\n },\n\n getProtocol(): string {\n return 'http:';\n },\n\n isXHRSupported(): boolean {\n return true;\n },\n\n createSocketRequest(method: string, url: string) {\n if (this.isXHRSupported()) {\n return this.HTTPFactory.createXHR(method, url);\n } else {\n throw 'Cross-origin HTTP requests are not supported';\n }\n },\n\n createXHR(): Ajax {\n var Constructor = this.getXHRAPI();\n return new Constructor();\n },\n\n createWebSocket(url: string): any {\n var Constructor = this.getWebSocketAPI();\n return new Constructor(url);\n },\n\n addUnloadListener(listener: any) {},\n removeUnloadListener(listener: any) {}\n};\n\nexport default Isomorphic;\n","import { default as EventsDispatcher } from 'core/events/dispatcher';\nimport Reachability from 'core/reachability';\n\nexport class NetInfo extends EventsDispatcher implements Reachability {\n isOnline(): boolean {\n return true;\n }\n}\n\nexport var Network = new NetInfo();\n","import AbstractRuntime from 'runtimes/interface';\nimport { AuthTransport } from 'core/auth/auth_transports';\nimport {\n AuthRequestType,\n AuthTransportCallback,\n InternalAuthOptions\n} from 'core/auth/options';\nimport { HTTPAuthError } from 'core/errors';\n\nvar fetchAuth: AuthTransport = function(\n context: AbstractRuntime,\n query: string,\n authOptions: InternalAuthOptions,\n authRequestType: AuthRequestType,\n callback: AuthTransportCallback\n) {\n var headers = new Headers();\n headers.set('Content-Type', 'application/x-www-form-urlencoded');\n\n for (var headerName in authOptions.headers) {\n headers.set(headerName, authOptions.headers[headerName]);\n }\n\n if (authOptions.headersProvider != null) {\n const dynamicHeaders = authOptions.headersProvider();\n for (var headerName in dynamicHeaders) {\n headers.set(headerName, dynamicHeaders[headerName]);\n }\n }\n\n var body = query;\n var request = new Request(authOptions.endpoint, {\n headers,\n body,\n credentials: 'same-origin',\n method: 'POST'\n });\n\n return fetch(request)\n .then(response => {\n let { status } = response;\n if (status === 200) {\n // manually parse the json so we can provide a more helpful error in\n // failure case\n return response.text();\n }\n throw new HTTPAuthError(\n status,\n `Could not get ${authRequestType.toString()} info from your auth endpoint, status: ${status}`\n );\n })\n .then(data => {\n let parsedData;\n try {\n parsedData = JSON.parse(data);\n } catch (e) {\n throw new HTTPAuthError(\n 200,\n `JSON returned from ${authRequestType.toString()} endpoint was invalid, yet status code was 200. Data was: ${data}`\n );\n }\n callback(null, parsedData);\n })\n .catch(err => {\n callback(err, null);\n });\n};\n\nexport default fetchAuth;\n","import Logger from 'core/logger';\nimport TimelineSender from 'core/timeline/timeline_sender';\nimport * as Collections from 'core/utils/collections';\nimport Util from 'core/util';\nimport Runtime from 'runtime';\nimport TimelineTransport from 'core/timeline/timeline_transport';\n\nvar getAgent = function(sender: TimelineSender, useTLS: boolean) {\n return function(data: any, callback: Function) {\n var scheme = 'http' + (useTLS ? 's' : '') + '://';\n var url =\n scheme + (sender.host || sender.options.host) + sender.options.path;\n var query = Collections.buildQueryString(data);\n url += '/' + 2 + '?' + query;\n\n fetch(url)\n .then(response => {\n if (response.status !== 200) {\n throw `received ${response.status} from stats.pusher.com`;\n }\n return response.json();\n })\n .then(({ host }) => {\n if (host) {\n sender.host = host;\n }\n })\n .catch(err => {\n Logger.debug('TimelineSender Error: ', err);\n });\n };\n};\n\nvar fetchTimeline = {\n name: 'xhr',\n getAgent\n};\n\nexport default fetchTimeline;\n","import Isomorphic from 'isomorphic/runtime';\nimport Runtime from '../interface';\nimport { Network } from './net_info';\nimport fetchAuth from './auth/fetch_auth';\nimport { AuthTransports } from 'core/auth/auth_transports';\nimport fetchTimeline from './timeline/fetch_timeline';\n\n// Very verbose but until unavoidable until\n// TypeScript 2.1, when spread attributes will be\n// supported\nconst {\n getDefaultStrategy,\n Transports,\n setup,\n getProtocol,\n isXHRSupported,\n getLocalStorage,\n createXHR,\n createWebSocket,\n addUnloadListener,\n removeUnloadListener,\n transportConnectionInitializer,\n createSocketRequest,\n HTTPFactory\n} = Isomorphic;\n\nconst Worker: Runtime = {\n getDefaultStrategy,\n Transports,\n setup,\n getProtocol,\n isXHRSupported,\n getLocalStorage,\n createXHR,\n createWebSocket,\n addUnloadListener,\n removeUnloadListener,\n transportConnectionInitializer,\n createSocketRequest,\n HTTPFactory,\n\n TimelineTransport: fetchTimeline,\n\n getAuthorizers(): AuthTransports {\n return { ajax: fetchAuth };\n },\n\n getWebSocketAPI() {\n return WebSocket;\n },\n\n getXHRAPI() {\n return XMLHttpRequest;\n },\n\n getNetwork() {\n return Network;\n },\n\n randomInt(max: number): number {\n /**\n * Return values in the range of [0, 1[\n */\n const random = function() {\n const crypto = globalThis.crypto || globalThis['msCrypto'];\n const random = crypto.getRandomValues(new Uint32Array(1))[0];\n\n return random / 2 ** 32;\n };\n\n return Math.floor(random() * max);\n }\n};\n\nexport default Worker;\n","enum TimelineLevel {\n ERROR = 3,\n INFO = 6,\n DEBUG = 7\n}\n\nexport default TimelineLevel;\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport { default as Level } from './level';\n\nexport interface TimelineOptions {\n level?: Level;\n limit?: number;\n version?: string;\n cluster?: string;\n features?: string[];\n params?: any;\n}\n\nexport default class Timeline {\n key: string;\n session: number;\n events: any[];\n options: TimelineOptions;\n sent: number;\n uniqueID: number;\n\n constructor(key: string, session: number, options: TimelineOptions) {\n this.key = key;\n this.session = session;\n this.events = [];\n this.options = options || {};\n this.sent = 0;\n this.uniqueID = 0;\n }\n\n log(level, event) {\n if (level <= this.options.level) {\n this.events.push(\n Collections.extend({}, event, { timestamp: Util.now() })\n );\n if (this.options.limit && this.events.length > this.options.limit) {\n this.events.shift();\n }\n }\n }\n\n error(event) {\n this.log(Level.ERROR, event);\n }\n\n info(event) {\n this.log(Level.INFO, event);\n }\n\n debug(event) {\n this.log(Level.DEBUG, event);\n }\n\n isEmpty() {\n return this.events.length === 0;\n }\n\n send(sendfn, callback) {\n var data = Collections.extend(\n {\n session: this.session,\n bundle: this.sent + 1,\n key: this.key,\n lib: 'js',\n version: this.options.version,\n cluster: this.options.cluster,\n features: this.options.features,\n timeline: this.events\n },\n this.options.params\n );\n\n this.events = [];\n sendfn(data, (error, result) => {\n if (!error) {\n this.sent++;\n }\n if (callback) {\n callback(error, result);\n }\n });\n\n return true;\n }\n\n generateUniqueID(): number {\n this.uniqueID++;\n return this.uniqueID;\n }\n}\n","import Factory from '../utils/factory';\nimport Util from '../util';\nimport * as Errors from '../errors';\nimport * as Collections from '../utils/collections';\nimport Strategy from './strategy';\nimport Transport from '../transports/transport';\nimport StrategyOptions from './strategy_options';\nimport Handshake from '../connection/handshake';\n\n/** Provides a strategy interface for transports.\n *\n * @param {String} name\n * @param {Number} priority\n * @param {Class} transport\n * @param {Object} options\n */\nexport default class TransportStrategy implements Strategy {\n name: string;\n priority: number;\n transport: Transport;\n options: StrategyOptions;\n\n constructor(\n name: string,\n priority: number,\n transport: Transport,\n options: StrategyOptions\n ) {\n this.name = name;\n this.priority = priority;\n this.transport = transport;\n this.options = options || {};\n }\n\n /** Returns whether the transport is supported in the browser.\n *\n * @returns {Boolean}\n */\n isSupported(): boolean {\n return this.transport.isSupported({\n useTLS: this.options.useTLS\n });\n }\n\n /** Launches a connection attempt and returns a strategy runner.\n *\n * @param {Function} callback\n * @return {Object} strategy runner\n */\n connect(minPriority: number, callback: Function) {\n if (!this.isSupported()) {\n return failAttempt(new Errors.UnsupportedStrategy(), callback);\n } else if (this.priority < minPriority) {\n return failAttempt(new Errors.TransportPriorityTooLow(), callback);\n }\n\n var connected = false;\n var transport = this.transport.createConnection(\n this.name,\n this.priority,\n this.options.key,\n this.options\n );\n var handshake = null;\n\n var onInitialized = function() {\n transport.unbind('initialized', onInitialized);\n transport.connect();\n };\n var onOpen = function() {\n handshake = Factory.createHandshake(transport, function(result) {\n connected = true;\n unbindListeners();\n callback(null, result);\n });\n };\n var onError = function(error) {\n unbindListeners();\n callback(error);\n };\n var onClosed = function() {\n unbindListeners();\n var serializedTransport;\n\n // The reason for this try/catch block is that on React Native\n // the WebSocket object is circular. Therefore transport.socket will\n // throw errors upon stringification. Collections.safeJSONStringify\n // discards circular references when serializing.\n serializedTransport = Collections.safeJSONStringify(transport);\n callback(new Errors.TransportClosed(serializedTransport));\n };\n\n var unbindListeners = function() {\n transport.unbind('initialized', onInitialized);\n transport.unbind('open', onOpen);\n transport.unbind('error', onError);\n transport.unbind('closed', onClosed);\n };\n\n transport.bind('initialized', onInitialized);\n transport.bind('open', onOpen);\n transport.bind('error', onError);\n transport.bind('closed', onClosed);\n\n // connect will be called automatically after initialization\n transport.initialize();\n\n return {\n abort: () => {\n if (connected) {\n return;\n }\n unbindListeners();\n if (handshake) {\n handshake.close();\n } else {\n transport.close();\n }\n },\n forceMinPriority: p => {\n if (connected) {\n return;\n }\n if (this.priority < p) {\n if (handshake) {\n handshake.close();\n } else {\n transport.close();\n }\n }\n }\n };\n }\n}\n\nfunction failAttempt(error: Error, callback: Function) {\n Util.defer(function() {\n callback(error);\n });\n return {\n abort: function() {},\n forceMinPriority: function() {}\n };\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport TransportManager from '../transports/transport_manager';\nimport * as Errors from '../errors';\nimport Strategy from './strategy';\nimport TransportStrategy from './transport_strategy';\nimport StrategyOptions from '../strategies/strategy_options';\nimport { Config } from '../config';\nimport Runtime from 'runtime';\n\nconst { Transports } = Runtime;\n\nexport var defineTransport = function(\n config: Config,\n name: string,\n type: string,\n priority: number,\n options: StrategyOptions,\n manager?: TransportManager\n): Strategy {\n var transportClass = Transports[type];\n if (!transportClass) {\n throw new Errors.UnsupportedTransport(type);\n }\n\n var enabled =\n (!config.enabledTransports ||\n Collections.arrayIndexOf(config.enabledTransports, name) !== -1) &&\n (!config.disabledTransports ||\n Collections.arrayIndexOf(config.disabledTransports, name) === -1);\n\n var transport;\n if (enabled) {\n options = Object.assign(\n { ignoreNullOrigin: config.ignoreNullOrigin },\n options\n );\n\n transport = new TransportStrategy(\n name,\n priority,\n manager ? manager.getAssistant(transportClass) : transportClass,\n options\n );\n } else {\n transport = UnsupportedStrategy;\n }\n\n return transport;\n};\n\nvar UnsupportedStrategy: Strategy = {\n isSupported: function() {\n return false;\n },\n connect: function(_, callback) {\n var deferred = Util.defer(function() {\n callback(new Errors.UnsupportedStrategy());\n });\n return {\n abort: function() {\n deferred.ensureAborted();\n },\n forceMinPriority: function() {}\n };\n }\n};\n","import ConnectionManager from './connection/connection_manager';\nimport {\n ChannelAuthorizationOptions,\n UserAuthenticationOptions\n} from './auth/options';\nimport {\n ChannelAuthorizerGenerator,\n DeprecatedAuthOptions\n} from './auth/deprecated_channel_authorizer';\nimport { AuthTransport, Transport } from './config';\nimport * as nacl from 'tweetnacl';\nimport Logger from './logger';\n\nexport interface Options {\n activityTimeout?: number;\n\n auth?: DeprecatedAuthOptions; // DEPRECATED use channelAuthorization instead\n authEndpoint?: string; // DEPRECATED use channelAuthorization instead\n authTransport?: AuthTransport; // DEPRECATED use channelAuthorization instead\n authorizer?: ChannelAuthorizerGenerator; // DEPRECATED use channelAuthorization instead\n\n channelAuthorization?: ChannelAuthorizationOptions;\n userAuthentication?: UserAuthenticationOptions;\n\n cluster: string;\n enableStats?: boolean;\n disableStats?: boolean;\n disabledTransports?: Transport[];\n enabledTransports?: Transport[];\n forceTLS?: boolean;\n httpHost?: string;\n httpPath?: string;\n httpPort?: number;\n httpsPort?: number;\n ignoreNullOrigin?: boolean;\n nacl?: nacl;\n pongTimeout?: number;\n statsHost?: string;\n timelineParams?: any;\n unavailableTimeout?: number;\n wsHost?: string;\n wsPath?: string;\n wsPort?: number;\n wssPort?: number;\n}\n\nexport interface ClusterOptions {\n appKey: string;\n cluster: string;\n}\n\nexport function validateOptions(options) {\n if (options == null) {\n throw 'You must pass an options object';\n }\n if (options.cluster == null) {\n throw 'Options object must provide a cluster';\n }\n if ('disableStats' in options) {\n Logger.warn(\n 'The disableStats option is deprecated in favor of enableStats'\n );\n }\n}\n","export enum AuthRequestType {\n UserAuthentication = 'user-authentication',\n ChannelAuthorization = 'channel-authorization'\n}\n\nexport interface ChannelAuthorizationData {\n auth: string;\n channel_data?: string;\n shared_secret?: string;\n}\n\nexport type ChannelAuthorizationCallback = (\n error: Error | null,\n authData: ChannelAuthorizationData | null\n) => void;\n\nexport interface ChannelAuthorizationRequestParams {\n socketId: string;\n channelName: string;\n}\n\nexport interface ChannelAuthorizationHandler {\n (\n params: ChannelAuthorizationRequestParams,\n callback: ChannelAuthorizationCallback\n ): void;\n}\n\nexport interface UserAuthenticationData {\n auth: string;\n user_data: string;\n}\n\nexport type UserAuthenticationCallback = (\n error: Error | null,\n authData: UserAuthenticationData | null\n) => void;\n\nexport interface UserAuthenticationRequestParams {\n socketId: string;\n}\n\nexport interface UserAuthenticationHandler {\n (\n params: UserAuthenticationRequestParams,\n callback: UserAuthenticationCallback\n ): void;\n}\n\nexport type AuthTransportCallback =\n | ChannelAuthorizationCallback\n | UserAuthenticationCallback;\n\nexport interface AuthOptionsT {\n transport: 'ajax' | 'jsonp';\n endpoint: string;\n params?: any;\n headers?: any;\n paramsProvider?: () => any;\n headersProvider?: () => any;\n customHandler?: AuthHandler;\n}\n\nexport declare type UserAuthenticationOptions = AuthOptionsT<\n UserAuthenticationHandler\n>;\nexport declare type ChannelAuthorizationOptions = AuthOptionsT<\n ChannelAuthorizationHandler\n>;\n\nexport interface InternalAuthOptions {\n transport: 'ajax' | 'jsonp';\n endpoint: string;\n params?: any;\n headers?: any;\n paramsProvider?: () => any;\n headersProvider?: () => any;\n}\n","import {\n UserAuthenticationCallback,\n InternalAuthOptions,\n UserAuthenticationHandler,\n UserAuthenticationRequestParams,\n AuthRequestType\n} from './options';\n\nimport Runtime from 'runtime';\n\nconst composeChannelQuery = (\n params: UserAuthenticationRequestParams,\n authOptions: InternalAuthOptions\n) => {\n var query = 'socket_id=' + encodeURIComponent(params.socketId);\n\n for (var key in authOptions.params) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(authOptions.params[key]);\n }\n\n if (authOptions.paramsProvider != null) {\n let dynamicParams = authOptions.paramsProvider();\n for (var key in dynamicParams) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(dynamicParams[key]);\n }\n }\n\n return query;\n};\n\nconst UserAuthenticator = (\n authOptions: InternalAuthOptions\n): UserAuthenticationHandler => {\n if (typeof Runtime.getAuthorizers()[authOptions.transport] === 'undefined') {\n throw `'${authOptions.transport}' is not a recognized auth transport`;\n }\n\n return (\n params: UserAuthenticationRequestParams,\n callback: UserAuthenticationCallback\n ) => {\n const query = composeChannelQuery(params, authOptions);\n\n Runtime.getAuthorizers()[authOptions.transport](\n Runtime,\n query,\n authOptions,\n AuthRequestType.UserAuthentication,\n callback\n );\n };\n};\n\nexport default UserAuthenticator;\n","import {\n AuthRequestType,\n InternalAuthOptions,\n ChannelAuthorizationHandler,\n ChannelAuthorizationRequestParams,\n ChannelAuthorizationCallback\n} from './options';\n\nimport Runtime from 'runtime';\n\nconst composeChannelQuery = (\n params: ChannelAuthorizationRequestParams,\n authOptions: InternalAuthOptions\n) => {\n var query = 'socket_id=' + encodeURIComponent(params.socketId);\n\n query += '&channel_name=' + encodeURIComponent(params.channelName);\n\n for (var key in authOptions.params) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(authOptions.params[key]);\n }\n\n if (authOptions.paramsProvider != null) {\n let dynamicParams = authOptions.paramsProvider();\n for (var key in dynamicParams) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(dynamicParams[key]);\n }\n }\n\n return query;\n};\n\nconst ChannelAuthorizer = (\n authOptions: InternalAuthOptions\n): ChannelAuthorizationHandler => {\n if (typeof Runtime.getAuthorizers()[authOptions.transport] === 'undefined') {\n throw `'${authOptions.transport}' is not a recognized auth transport`;\n }\n\n return (\n params: ChannelAuthorizationRequestParams,\n callback: ChannelAuthorizationCallback\n ) => {\n const query = composeChannelQuery(params, authOptions);\n\n Runtime.getAuthorizers()[authOptions.transport](\n Runtime,\n query,\n authOptions,\n AuthRequestType.ChannelAuthorization,\n callback\n );\n };\n};\n\nexport default ChannelAuthorizer;\n","import Channel from '../channels/channel';\nimport {\n ChannelAuthorizationCallback,\n ChannelAuthorizationHandler,\n ChannelAuthorizationRequestParams,\n InternalAuthOptions\n} from './options';\n\nexport interface DeprecatedChannelAuthorizer {\n authorize(socketId: string, callback: ChannelAuthorizationCallback): void;\n}\n\nexport interface ChannelAuthorizerGenerator {\n (\n channel: Channel,\n options: DeprecatedAuthorizerOptions\n ): DeprecatedChannelAuthorizer;\n}\n\nexport interface DeprecatedAuthOptions {\n params?: any;\n headers?: any;\n}\n\nexport interface DeprecatedAuthorizerOptions {\n authTransport: 'ajax' | 'jsonp';\n authEndpoint: string;\n auth?: DeprecatedAuthOptions;\n}\n\nexport const ChannelAuthorizerProxy = (\n pusher,\n authOptions: InternalAuthOptions,\n channelAuthorizerGenerator: ChannelAuthorizerGenerator\n): ChannelAuthorizationHandler => {\n const deprecatedAuthorizerOptions: DeprecatedAuthorizerOptions = {\n authTransport: authOptions.transport,\n authEndpoint: authOptions.endpoint,\n auth: {\n params: authOptions.params,\n headers: authOptions.headers\n }\n };\n return (\n params: ChannelAuthorizationRequestParams,\n callback: ChannelAuthorizationCallback\n ) => {\n const channel = pusher.channel(params.channelName);\n // This line creates a new channel authorizer every time.\n // In the past, this was only done once per channel and reused.\n // We can do that again if we want to keep this behavior intact.\n const channelAuthorizer: DeprecatedChannelAuthorizer = channelAuthorizerGenerator(\n channel,\n deprecatedAuthorizerOptions\n );\n channelAuthorizer.authorize(params.socketId, callback);\n };\n};\n","import { Options } from './options';\nimport Defaults from './defaults';\nimport {\n ChannelAuthorizationHandler,\n UserAuthenticationHandler,\n ChannelAuthorizationOptions\n} from './auth/options';\nimport UserAuthenticator from './auth/user_authenticator';\nimport ChannelAuthorizer from './auth/channel_authorizer';\nimport { ChannelAuthorizerProxy } from './auth/deprecated_channel_authorizer';\nimport Runtime from 'runtime';\nimport * as nacl from 'tweetnacl';\n\nexport type AuthTransport = 'ajax' | 'jsonp';\nexport type Transport =\n | 'ws'\n | 'wss'\n | 'xhr_streaming'\n | 'xhr_polling'\n | 'sockjs';\n\nexport interface Config {\n // these are all 'required' config parameters, it's not necessary for the user\n // to set them, but they have configured defaults.\n activityTimeout: number;\n enableStats: boolean;\n httpHost: string;\n httpPath: string;\n httpPort: number;\n httpsPort: number;\n pongTimeout: number;\n statsHost: string;\n unavailableTimeout: number;\n useTLS: boolean;\n wsHost: string;\n wsPath: string;\n wsPort: number;\n wssPort: number;\n userAuthenticator: UserAuthenticationHandler;\n channelAuthorizer: ChannelAuthorizationHandler;\n\n // these are all optional parameters or overrrides. The customer can set these\n // but it's not strictly necessary\n forceTLS?: boolean;\n cluster?: string;\n disabledTransports?: Transport[];\n enabledTransports?: Transport[];\n ignoreNullOrigin?: boolean;\n nacl?: nacl;\n timelineParams?: any;\n}\n\n// getConfig mainly sets the defaults for the options that are not provided\nexport function getConfig(opts: Options, pusher): Config {\n let config: Config = {\n activityTimeout: opts.activityTimeout || Defaults.activityTimeout,\n cluster: opts.cluster,\n httpPath: opts.httpPath || Defaults.httpPath,\n httpPort: opts.httpPort || Defaults.httpPort,\n httpsPort: opts.httpsPort || Defaults.httpsPort,\n pongTimeout: opts.pongTimeout || Defaults.pongTimeout,\n statsHost: opts.statsHost || Defaults.stats_host,\n unavailableTimeout: opts.unavailableTimeout || Defaults.unavailableTimeout,\n wsPath: opts.wsPath || Defaults.wsPath,\n wsPort: opts.wsPort || Defaults.wsPort,\n wssPort: opts.wssPort || Defaults.wssPort,\n\n enableStats: getEnableStatsConfig(opts),\n httpHost: getHttpHost(opts),\n useTLS: shouldUseTLS(opts),\n wsHost: getWebsocketHost(opts),\n\n userAuthenticator: buildUserAuthenticator(opts),\n channelAuthorizer: buildChannelAuthorizer(opts, pusher)\n };\n\n if ('disabledTransports' in opts)\n config.disabledTransports = opts.disabledTransports;\n if ('enabledTransports' in opts)\n config.enabledTransports = opts.enabledTransports;\n if ('ignoreNullOrigin' in opts)\n config.ignoreNullOrigin = opts.ignoreNullOrigin;\n if ('timelineParams' in opts) config.timelineParams = opts.timelineParams;\n if ('nacl' in opts) {\n config.nacl = opts.nacl;\n }\n\n return config;\n}\n\nfunction getHttpHost(opts: Options): string {\n if (opts.httpHost) {\n return opts.httpHost;\n }\n if (opts.cluster) {\n return `sockjs-${opts.cluster}.pusher.com`;\n }\n return Defaults.httpHost;\n}\n\nfunction getWebsocketHost(opts: Options): string {\n if (opts.wsHost) {\n return opts.wsHost;\n }\n return getWebsocketHostFromCluster(opts.cluster);\n}\n\nfunction getWebsocketHostFromCluster(cluster: string): string {\n return `ws-${cluster}.pusher.com`;\n}\n\nfunction shouldUseTLS(opts: Options): boolean {\n if (Runtime.getProtocol() === 'https:') {\n return true;\n } else if (opts.forceTLS === false) {\n return false;\n }\n return true;\n}\n\n// if enableStats is set take the value\n// if disableStats is set take the inverse\n// otherwise default to false\nfunction getEnableStatsConfig(opts: Options): boolean {\n if ('enableStats' in opts) {\n return opts.enableStats;\n }\n if ('disableStats' in opts) {\n return !opts.disableStats;\n }\n return false;\n}\n\nfunction buildUserAuthenticator(opts: Options): UserAuthenticationHandler {\n const userAuthentication = {\n ...Defaults.userAuthentication,\n ...opts.userAuthentication\n };\n if (\n 'customHandler' in userAuthentication &&\n userAuthentication['customHandler'] != null\n ) {\n return userAuthentication['customHandler'];\n }\n\n return UserAuthenticator(userAuthentication);\n}\n\nfunction buildChannelAuth(opts: Options, pusher): ChannelAuthorizationOptions {\n let channelAuthorization: ChannelAuthorizationOptions;\n if ('channelAuthorization' in opts) {\n channelAuthorization = {\n ...Defaults.channelAuthorization,\n ...opts.channelAuthorization\n };\n } else {\n channelAuthorization = {\n transport: opts.authTransport || Defaults.authTransport,\n endpoint: opts.authEndpoint || Defaults.authEndpoint\n };\n if ('auth' in opts) {\n if ('params' in opts.auth) channelAuthorization.params = opts.auth.params;\n if ('headers' in opts.auth)\n channelAuthorization.headers = opts.auth.headers;\n }\n if ('authorizer' in opts)\n channelAuthorization.customHandler = ChannelAuthorizerProxy(\n pusher,\n channelAuthorization,\n opts.authorizer\n );\n }\n return channelAuthorization;\n}\n\nfunction buildChannelAuthorizer(\n opts: Options,\n pusher\n): ChannelAuthorizationHandler {\n const channelAuthorization = buildChannelAuth(opts, pusher);\n if (\n 'customHandler' in channelAuthorization &&\n channelAuthorization['customHandler'] != null\n ) {\n return channelAuthorization['customHandler'];\n }\n\n return ChannelAuthorizer(channelAuthorization);\n}\n","import Logger from './logger';\nimport Pusher from './pusher';\nimport EventsDispatcher from './events/dispatcher';\n\nexport default class WatchlistFacade extends EventsDispatcher {\n private pusher: Pusher;\n\n public constructor(pusher: Pusher) {\n super(function(eventName, data) {\n Logger.debug(`No callbacks on watchlist events for ${eventName}`);\n });\n\n this.pusher = pusher;\n this.bindWatchlistInternalEvent();\n }\n\n handleEvent(pusherEvent) {\n pusherEvent.data.events.forEach(watchlistEvent => {\n this.emit(watchlistEvent.name, watchlistEvent);\n });\n }\n\n private bindWatchlistInternalEvent() {\n this.pusher.connection.bind('message', pusherEvent => {\n var eventName = pusherEvent.event;\n if (eventName === 'pusher_internal:watchlist_events') {\n this.handleEvent(pusherEvent);\n }\n });\n }\n}\n","function flatPromise() {\n let resolve, reject;\n const promise = new Promise((res, rej) => {\n resolve = res;\n reject = rej;\n });\n return { promise, resolve, reject };\n}\n\nexport default flatPromise;\n","import Pusher from './pusher';\nimport Logger from './logger';\nimport {\n UserAuthenticationData,\n UserAuthenticationCallback\n} from './auth/options';\nimport Channel from './channels/channel';\nimport WatchlistFacade from './watchlist';\nimport EventsDispatcher from './events/dispatcher';\nimport flatPromise from './utils/flat_promise';\n\nexport default class UserFacade extends EventsDispatcher {\n pusher: Pusher;\n signin_requested: boolean = false;\n user_data: any = null;\n serverToUserChannel: Channel = null;\n signinDonePromise: Promise = null;\n watchlist: WatchlistFacade;\n private _signinDoneResolve: Function = null;\n\n public constructor(pusher: Pusher) {\n super(function(eventName, data) {\n Logger.debug('No callbacks on user for ' + eventName);\n });\n this.pusher = pusher;\n this.pusher.connection.bind('state_change', ({ previous, current }) => {\n if (previous !== 'connected' && current === 'connected') {\n this._signin();\n }\n if (previous === 'connected' && current !== 'connected') {\n this._cleanup();\n this._newSigninPromiseIfNeeded();\n }\n });\n\n this.watchlist = new WatchlistFacade(pusher);\n\n this.pusher.connection.bind('message', event => {\n var eventName = event.event;\n if (eventName === 'pusher:signin_success') {\n this._onSigninSuccess(event.data);\n }\n if (\n this.serverToUserChannel &&\n this.serverToUserChannel.name === event.channel\n ) {\n this.serverToUserChannel.handleEvent(event);\n }\n });\n }\n\n public signin() {\n if (this.signin_requested) {\n return;\n }\n\n this.signin_requested = true;\n this._signin();\n }\n\n private _signin() {\n if (!this.signin_requested) {\n return;\n }\n\n this._newSigninPromiseIfNeeded();\n\n if (this.pusher.connection.state !== 'connected') {\n // Signin will be attempted when the connection is connected\n return;\n }\n\n this.pusher.config.userAuthenticator(\n {\n socketId: this.pusher.connection.socket_id\n },\n this._onAuthorize\n );\n }\n\n private _onAuthorize: UserAuthenticationCallback = (\n err,\n authData: UserAuthenticationData\n ) => {\n if (err) {\n Logger.warn(`Error during signin: ${err}`);\n this._cleanup();\n return;\n }\n\n this.pusher.send_event('pusher:signin', {\n auth: authData.auth,\n user_data: authData.user_data\n });\n\n // Later when we get pusher:singin_success event, the user will be marked as signed in\n };\n\n private _onSigninSuccess(data: any) {\n try {\n this.user_data = JSON.parse(data.user_data);\n } catch (e) {\n Logger.error(`Failed parsing user data after signin: ${data.user_data}`);\n this._cleanup();\n return;\n }\n\n if (typeof this.user_data.id !== 'string' || this.user_data.id === '') {\n Logger.error(\n `user_data doesn't contain an id. user_data: ${this.user_data}`\n );\n this._cleanup();\n return;\n }\n\n // Signin succeeded\n this._signinDoneResolve();\n this._subscribeChannels();\n }\n\n private _subscribeChannels() {\n const ensure_subscribed = channel => {\n if (channel.subscriptionPending && channel.subscriptionCancelled) {\n channel.reinstateSubscription();\n } else if (\n !channel.subscriptionPending &&\n this.pusher.connection.state === 'connected'\n ) {\n channel.subscribe();\n }\n };\n\n this.serverToUserChannel = new Channel(\n `#server-to-user-${this.user_data.id}`,\n this.pusher\n );\n this.serverToUserChannel.bind_global((eventName, data) => {\n if (\n eventName.indexOf('pusher_internal:') === 0 ||\n eventName.indexOf('pusher:') === 0\n ) {\n // ignore internal events\n return;\n }\n this.emit(eventName, data);\n });\n ensure_subscribed(this.serverToUserChannel);\n }\n\n private _cleanup() {\n this.user_data = null;\n if (this.serverToUserChannel) {\n this.serverToUserChannel.unbind_all();\n this.serverToUserChannel.disconnect();\n this.serverToUserChannel = null;\n }\n\n if (this.signin_requested) {\n // If signin is in progress and cleanup is called,\n // Mark the current signin process as done.\n this._signinDoneResolve();\n }\n }\n\n private _newSigninPromiseIfNeeded() {\n if (!this.signin_requested) {\n return;\n }\n\n // If there is a promise and it is not resolved, return without creating a new one.\n if (this.signinDonePromise && !(this.signinDonePromise as any).done) {\n return;\n }\n\n // This promise is never rejected.\n // It gets resolved when the signin process is done whether it failed or succeeded\n const { promise, resolve, reject: _ } = flatPromise();\n (promise as any).done = false;\n const setDone = () => {\n (promise as any).done = true;\n };\n promise.then(setDone).catch(setDone);\n this.signinDonePromise = promise;\n this._signinDoneResolve = resolve;\n }\n}\n","import AbstractRuntime from '../runtimes/interface';\nimport Runtime from 'runtime';\nimport * as Collections from './utils/collections';\nimport Channels from './channels/channels';\nimport Channel from './channels/channel';\nimport { default as EventsDispatcher } from './events/dispatcher';\nimport Timeline from './timeline/timeline';\nimport TimelineSender from './timeline/timeline_sender';\nimport TimelineLevel from './timeline/level';\nimport { defineTransport } from './strategies/strategy_builder';\nimport ConnectionManager from './connection/connection_manager';\nimport { PeriodicTimer } from './utils/timers';\nimport Defaults from './defaults';\nimport Logger from './logger';\nimport Factory from './utils/factory';\nimport { Options, ClusterOptions, validateOptions } from './options';\nimport { Config, getConfig } from './config';\nimport StrategyOptions from './strategies/strategy_options';\nimport UserFacade from './user';\n\nexport default class Pusher {\n /* STATIC PROPERTIES */\n static instances: Pusher[] = [];\n static isReady: boolean = false;\n static logToConsole: boolean = false;\n\n // for jsonp\n static Runtime: AbstractRuntime = Runtime;\n static ScriptReceivers: any = (Runtime).ScriptReceivers;\n static DependenciesReceivers: any = (Runtime).DependenciesReceivers;\n static auth_callbacks: any = (Runtime).auth_callbacks;\n\n static ready() {\n Pusher.isReady = true;\n for (var i = 0, l = Pusher.instances.length; i < l; i++) {\n Pusher.instances[i].connect();\n }\n }\n\n static log: (message: any) => void;\n\n private static getClientFeatures(): string[] {\n return Collections.keys(\n Collections.filterObject({ ws: Runtime.Transports.ws }, function(t) {\n return t.isSupported({});\n })\n );\n }\n\n /* INSTANCE PROPERTIES */\n key: string;\n options: Options;\n config: Config;\n channels: Channels;\n global_emitter: EventsDispatcher;\n sessionID: number;\n timeline: Timeline;\n timelineSender: TimelineSender;\n connection: ConnectionManager;\n timelineSenderTimer: PeriodicTimer;\n user: UserFacade;\n constructor(app_key: string, options: Options) {\n checkAppKey(app_key);\n validateOptions(options);\n this.key = app_key;\n this.config = getConfig(options, this);\n\n this.channels = Factory.createChannels();\n this.global_emitter = new EventsDispatcher();\n this.sessionID = Runtime.randomInt(1000000000);\n\n this.timeline = new Timeline(this.key, this.sessionID, {\n cluster: this.config.cluster,\n features: Pusher.getClientFeatures(),\n params: this.config.timelineParams || {},\n limit: 50,\n level: TimelineLevel.INFO,\n version: Defaults.VERSION\n });\n if (this.config.enableStats) {\n this.timelineSender = Factory.createTimelineSender(this.timeline, {\n host: this.config.statsHost,\n path: '/timeline/v2/' + Runtime.TimelineTransport.name\n });\n }\n\n var getStrategy = (options: StrategyOptions) => {\n return Runtime.getDefaultStrategy(this.config, options, defineTransport);\n };\n\n this.connection = Factory.createConnectionManager(this.key, {\n getStrategy: getStrategy,\n timeline: this.timeline,\n activityTimeout: this.config.activityTimeout,\n pongTimeout: this.config.pongTimeout,\n unavailableTimeout: this.config.unavailableTimeout,\n useTLS: Boolean(this.config.useTLS)\n });\n\n this.connection.bind('connected', () => {\n this.subscribeAll();\n if (this.timelineSender) {\n this.timelineSender.send(this.connection.isUsingTLS());\n }\n });\n\n this.connection.bind('message', event => {\n var eventName = event.event;\n var internal = eventName.indexOf('pusher_internal:') === 0;\n if (event.channel) {\n var channel = this.channel(event.channel);\n if (channel) {\n channel.handleEvent(event);\n }\n }\n // Emit globally [deprecated]\n if (!internal) {\n this.global_emitter.emit(event.event, event.data);\n }\n });\n this.connection.bind('connecting', () => {\n this.channels.disconnect();\n });\n this.connection.bind('disconnected', () => {\n this.channels.disconnect();\n });\n this.connection.bind('error', err => {\n Logger.warn(err);\n });\n\n Pusher.instances.push(this);\n this.timeline.info({ instances: Pusher.instances.length });\n\n this.user = new UserFacade(this);\n\n if (Pusher.isReady) {\n this.connect();\n }\n }\n\n /**\n * Allows you to switch Pusher cluster without\n * losing all the channels/subscription binding\n * as this is internally managed by the SDK.\n */\n switchCluster(options: ClusterOptions) {\n const { appKey, cluster } = options;\n this.key = appKey;\n this.options = { ...this.options, cluster };\n this.config = getConfig(this.options, this);\n this.connection.switchCluster(this.key);\n }\n\n channel(name: string): Channel {\n return this.channels.find(name);\n }\n\n allChannels(): Channel[] {\n return this.channels.all();\n }\n\n connect() {\n this.connection.connect();\n\n if (this.timelineSender) {\n if (!this.timelineSenderTimer) {\n var usingTLS = this.connection.isUsingTLS();\n var timelineSender = this.timelineSender;\n this.timelineSenderTimer = new PeriodicTimer(60000, function() {\n timelineSender.send(usingTLS);\n });\n }\n }\n }\n\n disconnect() {\n this.connection.disconnect();\n\n if (this.timelineSenderTimer) {\n this.timelineSenderTimer.ensureAborted();\n this.timelineSenderTimer = null;\n }\n }\n\n bind(event_name: string, callback: Function, context?: any): Pusher {\n this.global_emitter.bind(event_name, callback, context);\n return this;\n }\n\n unbind(event_name?: string, callback?: Function, context?: any): Pusher {\n this.global_emitter.unbind(event_name, callback, context);\n return this;\n }\n\n bind_global(callback: Function): Pusher {\n this.global_emitter.bind_global(callback);\n return this;\n }\n\n unbind_global(callback?: Function): Pusher {\n this.global_emitter.unbind_global(callback);\n return this;\n }\n\n unbind_all(callback?: Function): Pusher {\n this.global_emitter.unbind_all();\n return this;\n }\n\n subscribeAll() {\n var channelName;\n for (channelName in this.channels.channels) {\n if (this.channels.channels.hasOwnProperty(channelName)) {\n this.subscribe(channelName);\n }\n }\n }\n\n subscribe(channel_name: string) {\n var channel = this.channels.add(channel_name, this);\n if (channel.subscriptionPending && channel.subscriptionCancelled) {\n channel.reinstateSubscription();\n } else if (\n !channel.subscriptionPending &&\n this.connection.state === 'connected'\n ) {\n channel.subscribe();\n }\n return channel;\n }\n\n unsubscribe(channel_name: string) {\n var channel = this.channels.find(channel_name);\n if (channel && channel.subscriptionPending) {\n channel.cancelSubscription();\n } else {\n channel = this.channels.remove(channel_name);\n if (channel && channel.subscribed) {\n channel.unsubscribe();\n }\n }\n }\n\n send_event(event_name: string, data: any, channel?: string) {\n return this.connection.send_event(event_name, data, channel);\n }\n\n shouldUseTLS(): boolean {\n return this.config.useTLS;\n }\n\n signin() {\n this.user.signin();\n }\n}\n\nfunction checkAppKey(key) {\n if (key === null || key === undefined) {\n throw 'You must pass your app key when you instantiate Pusher.';\n }\n}\n\nRuntime.setup(Pusher);\n"],"sourceRoot":""} \ No newline at end of file +{"version":3,"sources":["webpack://Pusher/webpack/universalModuleDefinition","webpack://Pusher/webpack/bootstrap","webpack://Pusher/./node_modules/@stablelib/base64/base64.ts","webpack://Pusher/./node_modules/@stablelib/utf8/utf8.ts","webpack://Pusher/./src/core/pusher.js","webpack://Pusher/./src/core/base64.ts","webpack://Pusher/./src/core/utils/timers/abstract_timer.ts","webpack://Pusher/./src/core/utils/timers/index.ts","webpack://Pusher/./src/core/util.ts","webpack://Pusher/./src/core/utils/collections.ts","webpack://Pusher/./src/core/defaults.ts","webpack://Pusher/./src/core/transports/url_schemes.ts","webpack://Pusher/./src/core/events/callback_registry.ts","webpack://Pusher/./src/core/events/dispatcher.ts","webpack://Pusher/./src/core/logger.ts","webpack://Pusher/./src/core/transports/transport_connection.ts","webpack://Pusher/./src/core/transports/transport.ts","webpack://Pusher/./src/runtimes/isomorphic/transports/transports.ts","webpack://Pusher/./src/core/transports/assistant_to_the_transport_manager.ts","webpack://Pusher/./src/core/connection/protocol/protocol.ts","webpack://Pusher/./src/core/connection/connection.ts","webpack://Pusher/./src/core/connection/handshake/index.ts","webpack://Pusher/./src/core/timeline/timeline_sender.ts","webpack://Pusher/./src/core/errors.ts","webpack://Pusher/./src/core/utils/url_store.ts","webpack://Pusher/./src/core/channels/channel.ts","webpack://Pusher/./src/core/channels/private_channel.ts","webpack://Pusher/./src/core/channels/members.ts","webpack://Pusher/./src/core/channels/presence_channel.ts","webpack://Pusher/./src/core/channels/encrypted_channel.ts","webpack://Pusher/./src/core/connection/connection_manager.ts","webpack://Pusher/./src/core/channels/channels.ts","webpack://Pusher/./src/core/utils/factory.ts","webpack://Pusher/./src/core/transports/transport_manager.ts","webpack://Pusher/./src/core/strategies/sequential_strategy.ts","webpack://Pusher/./src/core/strategies/best_connected_ever_strategy.ts","webpack://Pusher/./src/core/strategies/websocket_prioritized_cached_strategy.ts","webpack://Pusher/./src/core/strategies/delayed_strategy.ts","webpack://Pusher/./src/core/strategies/if_strategy.ts","webpack://Pusher/./src/core/strategies/first_connected_strategy.ts","webpack://Pusher/./src/runtimes/isomorphic/default_strategy.ts","webpack://Pusher/./src/runtimes/isomorphic/transports/transport_connection_initializer.ts","webpack://Pusher/./src/core/http/http_request.ts","webpack://Pusher/./src/core/http/state.ts","webpack://Pusher/./src/core/http/http_socket.ts","webpack://Pusher/./src/core/http/http_streaming_socket.ts","webpack://Pusher/./src/core/http/http_polling_socket.ts","webpack://Pusher/./src/runtimes/isomorphic/http/http_xhr_request.ts","webpack://Pusher/./src/runtimes/isomorphic/http/http.ts","webpack://Pusher/./src/runtimes/isomorphic/runtime.ts","webpack://Pusher/./src/runtimes/worker/net_info.ts","webpack://Pusher/./src/runtimes/worker/auth/fetch_auth.ts","webpack://Pusher/./src/runtimes/worker/timeline/fetch_timeline.ts","webpack://Pusher/./src/runtimes/worker/runtime.ts","webpack://Pusher/./src/core/timeline/level.ts","webpack://Pusher/./src/core/timeline/timeline.ts","webpack://Pusher/./src/core/strategies/transport_strategy.ts","webpack://Pusher/./src/core/strategies/strategy_builder.ts","webpack://Pusher/./src/core/options.ts","webpack://Pusher/./src/core/auth/options.ts","webpack://Pusher/./src/core/auth/user_authenticator.ts","webpack://Pusher/./src/core/auth/channel_authorizer.ts","webpack://Pusher/./src/core/auth/deprecated_channel_authorizer.ts","webpack://Pusher/./src/core/config.ts","webpack://Pusher/./src/core/watchlist.ts","webpack://Pusher/./src/core/utils/flat_promise.ts","webpack://Pusher/./src/core/user.ts","webpack://Pusher/./src/core/pusher.ts"],"names":[],"mappings":";;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AACD,O;QCVA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;;QAEA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;;;QAGA;QACA;;QA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,OAAO,CAAC,WAAW,EAAE,CAAC;aACvB;SACF;IACH,CAAC;IAED,UAAU,CAAC,UAAkB,EAAE,IAAS,EAAE,OAAgB;QACxD,OAAO,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC,UAAU,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;IAC/D,CAAC;IAED,YAAY;QACV,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC;IAC5B,CAAC;IAED,MAAM;QACJ,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;IACrB,CAAC;;AAxOM,uBAAS,GAAa,EAAE,CAAC;AACzB,qBAAO,GAAY,KAAK,CAAC;AACzB,0BAAY,GAAY,KAAK,CAAC;AAG9B,qBAAO,GAAoB,cAAO,CAAC;AACnC,6BAAe,GAAc,cAAQ,CAAC,eAAe,CAAC;AACtD,mCAAqB,GAAc,cAAQ,CAAC,qBAAqB,CAAC;AAClE,4BAAc,GAAc,cAAQ,CAAC,cAAc,CAAC;AAVxC,8FAAM;AA6O3B,SAAS,WAAW,CAAC,GAAG;IACtB,IAAI,GAAG,KAAK,IAAI,IAAI,GAAG,KAAK,SAAS,EAAE;QACrC,MAAM,yDAAyD,CAAC;KACjE;AACH,CAAC;AAED,cAAO,CAAC,KAAK,CAAC,aAAM,CAAC,CAAC","file":"pusher.worker.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"Pusher\"] = factory();\n\telse\n\t\troot[\"Pusher\"] = factory();\n})(this, function() {\nreturn "," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 2);\n","// Copyright (C) 2016 Dmitry Chestnykh\n// MIT License. See LICENSE file for details.\n\n/**\n * Package base64 implements Base64 encoding and decoding.\n */\n\n// Invalid character used in decoding to indicate\n// that the character to decode is out of range of\n// alphabet and cannot be decoded.\nconst INVALID_BYTE = 256;\n\n/**\n * Implements standard Base64 encoding.\n *\n * Operates in constant time.\n */\nexport class Coder {\n // TODO(dchest): methods to encode chunk-by-chunk.\n\n constructor(private _paddingCharacter = \"=\") { }\n\n encodedLength(length: number): number {\n if (!this._paddingCharacter) {\n return (length * 8 + 5) / 6 | 0;\n }\n return (length + 2) / 3 * 4 | 0;\n }\n\n encode(data: Uint8Array): string {\n let out = \"\";\n\n let i = 0;\n for (; i < data.length - 2; i += 3) {\n let c = (data[i] << 16) | (data[i + 1] << 8) | (data[i + 2]);\n out += this._encodeByte((c >>> 3 * 6) & 63);\n out += this._encodeByte((c >>> 2 * 6) & 63);\n out += this._encodeByte((c >>> 1 * 6) & 63);\n out += this._encodeByte((c >>> 0 * 6) & 63);\n }\n\n const left = data.length - i;\n if (left > 0) {\n let c = (data[i] << 16) | (left === 2 ? data[i + 1] << 8 : 0);\n out += this._encodeByte((c >>> 3 * 6) & 63);\n out += this._encodeByte((c >>> 2 * 6) & 63);\n if (left === 2) {\n out += this._encodeByte((c >>> 1 * 6) & 63);\n } else {\n out += this._paddingCharacter || \"\";\n }\n out += this._paddingCharacter || \"\";\n }\n\n return out;\n }\n\n maxDecodedLength(length: number): number {\n if (!this._paddingCharacter) {\n return (length * 6 + 7) / 8 | 0;\n }\n return length / 4 * 3 | 0;\n }\n\n decodedLength(s: string): number {\n return this.maxDecodedLength(s.length - this._getPaddingLength(s));\n }\n\n decode(s: string): Uint8Array {\n if (s.length === 0) {\n return new Uint8Array(0);\n }\n const paddingLength = this._getPaddingLength(s);\n const length = s.length - paddingLength;\n const out = new Uint8Array(this.maxDecodedLength(length));\n let op = 0;\n let i = 0;\n let haveBad = 0;\n let v0 = 0, v1 = 0, v2 = 0, v3 = 0;\n for (; i < length - 4; i += 4) {\n v0 = this._decodeChar(s.charCodeAt(i + 0));\n v1 = this._decodeChar(s.charCodeAt(i + 1));\n v2 = this._decodeChar(s.charCodeAt(i + 2));\n v3 = this._decodeChar(s.charCodeAt(i + 3));\n out[op++] = (v0 << 2) | (v1 >>> 4);\n out[op++] = (v1 << 4) | (v2 >>> 2);\n out[op++] = (v2 << 6) | v3;\n haveBad |= v0 & INVALID_BYTE;\n haveBad |= v1 & INVALID_BYTE;\n haveBad |= v2 & INVALID_BYTE;\n haveBad |= v3 & INVALID_BYTE;\n }\n if (i < length - 1) {\n v0 = this._decodeChar(s.charCodeAt(i));\n v1 = this._decodeChar(s.charCodeAt(i + 1));\n out[op++] = (v0 << 2) | (v1 >>> 4);\n haveBad |= v0 & INVALID_BYTE;\n haveBad |= v1 & INVALID_BYTE;\n }\n if (i < length - 2) {\n v2 = this._decodeChar(s.charCodeAt(i + 2));\n out[op++] = (v1 << 4) | (v2 >>> 2);\n haveBad |= v2 & INVALID_BYTE;\n }\n if (i < length - 3) {\n v3 = this._decodeChar(s.charCodeAt(i + 3));\n out[op++] = (v2 << 6) | v3;\n haveBad |= v3 & INVALID_BYTE;\n }\n if (haveBad !== 0) {\n throw new Error(\"Base64Coder: incorrect characters for decoding\");\n }\n return out;\n }\n\n // Standard encoding have the following encoded/decoded ranges,\n // which we need to convert between.\n //\n // ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 0123456789 + /\n // Index: 0 - 25 26 - 51 52 - 61 62 63\n // ASCII: 65 - 90 97 - 122 48 - 57 43 47\n //\n\n // Encode 6 bits in b into a new character.\n protected _encodeByte(b: number): string {\n // Encoding uses constant time operations as follows:\n //\n // 1. Define comparison of A with B using (A - B) >>> 8:\n // if A > B, then result is positive integer\n // if A <= B, then result is 0\n //\n // 2. Define selection of C or 0 using bitwise AND: X & C:\n // if X == 0, then result is 0\n // if X != 0, then result is C\n //\n // 3. Start with the smallest comparison (b >= 0), which is always\n // true, so set the result to the starting ASCII value (65).\n //\n // 4. Continue comparing b to higher ASCII values, and selecting\n // zero if comparison isn't true, otherwise selecting a value\n // to add to result, which:\n //\n // a) undoes the previous addition\n // b) provides new value to add\n //\n let result = b;\n // b >= 0\n result += 65;\n // b > 25\n result += ((25 - b) >>> 8) & ((0 - 65) - 26 + 97);\n // b > 51\n result += ((51 - b) >>> 8) & ((26 - 97) - 52 + 48);\n // b > 61\n result += ((61 - b) >>> 8) & ((52 - 48) - 62 + 43);\n // b > 62\n result += ((62 - b) >>> 8) & ((62 - 43) - 63 + 47);\n\n return String.fromCharCode(result);\n }\n\n // Decode a character code into a byte.\n // Must return 256 if character is out of alphabet range.\n protected _decodeChar(c: number): number {\n // Decoding works similar to encoding: using the same comparison\n // function, but now it works on ranges: result is always incremented\n // by value, but this value becomes zero if the range is not\n // satisfied.\n //\n // Decoding starts with invalid value, 256, which is then\n // subtracted when the range is satisfied. If none of the ranges\n // apply, the function returns 256, which is then checked by\n // the caller to throw error.\n let result = INVALID_BYTE; // start with invalid character\n\n // c == 43 (c > 42 and c < 44)\n result += (((42 - c) & (c - 44)) >>> 8) & (-INVALID_BYTE + c - 43 + 62);\n // c == 47 (c > 46 and c < 48)\n result += (((46 - c) & (c - 48)) >>> 8) & (-INVALID_BYTE + c - 47 + 63);\n // c > 47 and c < 58\n result += (((47 - c) & (c - 58)) >>> 8) & (-INVALID_BYTE + c - 48 + 52);\n // c > 64 and c < 91\n result += (((64 - c) & (c - 91)) >>> 8) & (-INVALID_BYTE + c - 65 + 0);\n // c > 96 and c < 123\n result += (((96 - c) & (c - 123)) >>> 8) & (-INVALID_BYTE + c - 97 + 26);\n\n return result;\n }\n\n private _getPaddingLength(s: string): number {\n let paddingLength = 0;\n if (this._paddingCharacter) {\n for (let i = s.length - 1; i >= 0; i--) {\n if (s[i] !== this._paddingCharacter) {\n break;\n }\n paddingLength++;\n }\n if (s.length < 4 || paddingLength > 2) {\n throw new Error(\"Base64Coder: incorrect padding\");\n }\n }\n return paddingLength;\n }\n\n}\n\nconst stdCoder = new Coder();\n\nexport function encode(data: Uint8Array): string {\n return stdCoder.encode(data);\n}\n\nexport function decode(s: string): Uint8Array {\n return stdCoder.decode(s);\n}\n\n/**\n * Implements URL-safe Base64 encoding.\n * (Same as Base64, but '+' is replaced with '-', and '/' with '_').\n *\n * Operates in constant time.\n */\nexport class URLSafeCoder extends Coder {\n // URL-safe encoding have the following encoded/decoded ranges:\n //\n // ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 0123456789 - _\n // Index: 0 - 25 26 - 51 52 - 61 62 63\n // ASCII: 65 - 90 97 - 122 48 - 57 45 95\n //\n\n protected _encodeByte(b: number): string {\n let result = b;\n // b >= 0\n result += 65;\n // b > 25\n result += ((25 - b) >>> 8) & ((0 - 65) - 26 + 97);\n // b > 51\n result += ((51 - b) >>> 8) & ((26 - 97) - 52 + 48);\n // b > 61\n result += ((61 - b) >>> 8) & ((52 - 48) - 62 + 45);\n // b > 62\n result += ((62 - b) >>> 8) & ((62 - 45) - 63 + 95);\n\n return String.fromCharCode(result);\n }\n\n protected _decodeChar(c: number): number {\n let result = INVALID_BYTE;\n\n // c == 45 (c > 44 and c < 46)\n result += (((44 - c) & (c - 46)) >>> 8) & (-INVALID_BYTE + c - 45 + 62);\n // c == 95 (c > 94 and c < 96)\n result += (((94 - c) & (c - 96)) >>> 8) & (-INVALID_BYTE + c - 95 + 63);\n // c > 47 and c < 58\n result += (((47 - c) & (c - 58)) >>> 8) & (-INVALID_BYTE + c - 48 + 52);\n // c > 64 and c < 91\n result += (((64 - c) & (c - 91)) >>> 8) & (-INVALID_BYTE + c - 65 + 0);\n // c > 96 and c < 123\n result += (((96 - c) & (c - 123)) >>> 8) & (-INVALID_BYTE + c - 97 + 26);\n\n return result;\n }\n}\n\nconst urlSafeCoder = new URLSafeCoder();\n\nexport function encodeURLSafe(data: Uint8Array): string {\n return urlSafeCoder.encode(data);\n}\n\nexport function decodeURLSafe(s: string): Uint8Array {\n return urlSafeCoder.decode(s);\n}\n\n\nexport const encodedLength = (length: number) =>\n stdCoder.encodedLength(length);\n\nexport const maxDecodedLength = (length: number) =>\n stdCoder.maxDecodedLength(length);\n\nexport const decodedLength = (s: string) =>\n stdCoder.decodedLength(s);\n","// Copyright (C) 2016 Dmitry Chestnykh\n// MIT License. See LICENSE file for details.\n\n/**\n * Package utf8 implements UTF-8 encoding and decoding.\n */\n\nconst INVALID_UTF16 = \"utf8: invalid string\";\nconst INVALID_UTF8 = \"utf8: invalid source encoding\";\n\n/**\n * Encodes the given string into UTF-8 byte array.\n * Throws if the source string has invalid UTF-16 encoding.\n */\nexport function encode(s: string): Uint8Array {\n // Calculate result length and allocate output array.\n // encodedLength() also validates string and throws errors,\n // so we don't need repeat validation here.\n const arr = new Uint8Array(encodedLength(s));\n\n let pos = 0;\n for (let i = 0; i < s.length; i++) {\n let c = s.charCodeAt(i);\n if (c < 0x80) {\n arr[pos++] = c;\n } else if (c < 0x800) {\n arr[pos++] = 0xc0 | c >> 6;\n arr[pos++] = 0x80 | c & 0x3f;\n } else if (c < 0xd800) {\n arr[pos++] = 0xe0 | c >> 12;\n arr[pos++] = 0x80 | (c >> 6) & 0x3f;\n arr[pos++] = 0x80 | c & 0x3f;\n } else {\n i++; // get one more character\n c = (c & 0x3ff) << 10;\n c |= s.charCodeAt(i) & 0x3ff;\n c += 0x10000;\n\n arr[pos++] = 0xf0 | c >> 18;\n arr[pos++] = 0x80 | (c >> 12) & 0x3f;\n arr[pos++] = 0x80 | (c >> 6) & 0x3f;\n arr[pos++] = 0x80 | c & 0x3f;\n }\n }\n return arr;\n}\n\n/**\n * Returns the number of bytes required to encode the given string into UTF-8.\n * Throws if the source string has invalid UTF-16 encoding.\n */\nexport function encodedLength(s: string): number {\n let result = 0;\n for (let i = 0; i < s.length; i++) {\n const c = s.charCodeAt(i);\n if (c < 0x80) {\n result += 1;\n } else if (c < 0x800) {\n result += 2;\n } else if (c < 0xd800) {\n result += 3;\n } else if (c <= 0xdfff) {\n if (i >= s.length - 1) {\n throw new Error(INVALID_UTF16);\n }\n i++; // \"eat\" next character\n result += 4;\n } else {\n throw new Error(INVALID_UTF16);\n }\n }\n return result;\n}\n\n/**\n * Decodes the given byte array from UTF-8 into a string.\n * Throws if encoding is invalid.\n */\nexport function decode(arr: Uint8Array): string {\n const chars: string[] = [];\n for (let i = 0; i < arr.length; i++) {\n let b = arr[i];\n\n if (b & 0x80) {\n let min;\n if (b < 0xe0) {\n // Need 1 more byte.\n if (i >= arr.length) {\n throw new Error(INVALID_UTF8);\n }\n const n1 = arr[++i];\n if ((n1 & 0xc0) !== 0x80) {\n throw new Error(INVALID_UTF8);\n }\n b = (b & 0x1f) << 6 | (n1 & 0x3f);\n min = 0x80;\n } else if (b < 0xf0) {\n // Need 2 more bytes.\n if (i >= arr.length - 1) {\n throw new Error(INVALID_UTF8);\n }\n const n1 = arr[++i];\n const n2 = arr[++i];\n if ((n1 & 0xc0) !== 0x80 || (n2 & 0xc0) !== 0x80) {\n throw new Error(INVALID_UTF8);\n }\n b = (b & 0x0f) << 12 | (n1 & 0x3f) << 6 | (n2 & 0x3f);\n min = 0x800;\n } else if (b < 0xf8) {\n // Need 3 more bytes.\n if (i >= arr.length - 2) {\n throw new Error(INVALID_UTF8);\n }\n const n1 = arr[++i];\n const n2 = arr[++i];\n const n3 = arr[++i];\n if ((n1 & 0xc0) !== 0x80 || (n2 & 0xc0) !== 0x80 || (n3 & 0xc0) !== 0x80) {\n throw new Error(INVALID_UTF8);\n }\n b = (b & 0x0f) << 18 | (n1 & 0x3f) << 12 | (n2 & 0x3f) << 6 | (n3 & 0x3f);\n min = 0x10000;\n } else {\n throw new Error(INVALID_UTF8);\n }\n\n if (b < min || (b >= 0xd800 && b <= 0xdfff)) {\n throw new Error(INVALID_UTF8);\n }\n\n if (b >= 0x10000) {\n // Surrogate pair.\n if (b > 0x10ffff) {\n throw new Error(INVALID_UTF8);\n }\n b -= 0x10000;\n chars.push(String.fromCharCode(0xd800 | (b >> 10)));\n b = 0xdc00 | (b & 0x3ff);\n }\n }\n\n chars.push(String.fromCharCode(b));\n }\n return chars.join(\"\");\n}\n","// required so we don't have to do require('pusher').default etc.\nmodule.exports = require('./pusher').default;\n","export default function encode(s: any): string {\n return btoa(utob(s));\n}\n\nvar fromCharCode = String.fromCharCode;\n\nvar b64chars =\n 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';\nvar b64tab = {};\n\nfor (var i = 0, l = b64chars.length; i < l; i++) {\n b64tab[b64chars.charAt(i)] = i;\n}\n\nvar cb_utob = function(c) {\n var cc = c.charCodeAt(0);\n return cc < 0x80\n ? c\n : cc < 0x800\n ? fromCharCode(0xc0 | (cc >>> 6)) + fromCharCode(0x80 | (cc & 0x3f))\n : fromCharCode(0xe0 | ((cc >>> 12) & 0x0f)) +\n fromCharCode(0x80 | ((cc >>> 6) & 0x3f)) +\n fromCharCode(0x80 | (cc & 0x3f));\n};\n\nvar utob = function(u) {\n return u.replace(/[^\\x00-\\x7F]/g, cb_utob);\n};\n\nvar cb_encode = function(ccc) {\n var padlen = [0, 2, 1][ccc.length % 3];\n var ord =\n (ccc.charCodeAt(0) << 16) |\n ((ccc.length > 1 ? ccc.charCodeAt(1) : 0) << 8) |\n (ccc.length > 2 ? ccc.charCodeAt(2) : 0);\n var chars = [\n b64chars.charAt(ord >>> 18),\n b64chars.charAt((ord >>> 12) & 63),\n padlen >= 2 ? '=' : b64chars.charAt((ord >>> 6) & 63),\n padlen >= 1 ? '=' : b64chars.charAt(ord & 63)\n ];\n return chars.join('');\n};\n\nvar btoa =\n global.btoa ||\n function(b) {\n return b.replace(/[\\s\\S]{1,3}/g, cb_encode);\n };\n","import TimedCallback from './timed_callback';\nimport { Delay, Scheduler, Canceller } from './scheduling';\n\nabstract class Timer {\n protected clear: Canceller;\n protected timer: number | void;\n\n constructor(\n set: Scheduler,\n clear: Canceller,\n delay: Delay,\n callback: TimedCallback\n ) {\n this.clear = clear;\n this.timer = set(() => {\n if (this.timer) {\n this.timer = callback(this.timer);\n }\n }, delay);\n }\n\n /** Returns whether the timer is still running.\n *\n * @return {Boolean}\n */\n isRunning(): boolean {\n return this.timer !== null;\n }\n\n /** Aborts a timer when it's running. */\n ensureAborted() {\n if (this.timer) {\n this.clear(this.timer);\n this.timer = null;\n }\n }\n}\n\nexport default Timer;\n","import Timer from './abstract_timer';\nimport TimedCallback from './timed_callback';\nimport { Delay } from './scheduling';\n\n// We need to bind clear functions this way to avoid exceptions on IE8\nfunction clearTimeout(timer) {\n global.clearTimeout(timer);\n}\nfunction clearInterval(timer) {\n global.clearInterval(timer);\n}\n\n/** Cross-browser compatible one-off timer abstraction.\n *\n * @param {Number} delay\n * @param {Function} callback\n */\nexport class OneOffTimer extends Timer {\n constructor(delay: Delay, callback: TimedCallback) {\n super(setTimeout, clearTimeout, delay, function(timer) {\n callback();\n return null;\n });\n }\n}\n\n/** Cross-browser compatible periodic timer abstraction.\n *\n * @param {Number} delay\n * @param {Function} callback\n */\nexport class PeriodicTimer extends Timer {\n constructor(delay: Delay, callback: TimedCallback) {\n super(setInterval, clearInterval, delay, function(timer) {\n callback();\n return timer;\n });\n }\n}\n","import * as Collections from './utils/collections';\nimport TimedCallback from './utils/timers/timed_callback';\nimport { OneOffTimer, PeriodicTimer } from './utils/timers';\n\nvar Util = {\n now(): number {\n if (Date.now) {\n return Date.now();\n } else {\n return new Date().valueOf();\n }\n },\n\n defer(callback: TimedCallback): OneOffTimer {\n return new OneOffTimer(0, callback);\n },\n\n /** Builds a function that will proxy a method call to its first argument.\n *\n * Allows partial application of arguments, so additional arguments are\n * prepended to the argument list.\n *\n * @param {String} name method name\n * @return {Function} proxy function\n */\n method(name: string, ...args: any[]): Function {\n var boundArguments = Array.prototype.slice.call(arguments, 1);\n return function(object) {\n return object[name].apply(object, boundArguments.concat(arguments));\n };\n }\n};\n\nexport default Util;\n","import base64encode from '../base64';\nimport Util from '../util';\n\n/** Merges multiple objects into the target argument.\n *\n * For properties that are plain Objects, performs a deep-merge. For the\n * rest it just copies the value of the property.\n *\n * To extend prototypes use it as following:\n * Pusher.Util.extend(Target.prototype, Base.prototype)\n *\n * You can also use it to merge objects without altering them:\n * Pusher.Util.extend({}, object1, object2)\n *\n * @param {Object} target\n * @return {Object} the target argument\n */\nexport function extend(target: any, ...sources: any[]): T {\n for (var i = 0; i < sources.length; i++) {\n var extensions = sources[i];\n for (var property in extensions) {\n if (\n extensions[property] &&\n extensions[property].constructor &&\n extensions[property].constructor === Object\n ) {\n target[property] = extend(target[property] || {}, extensions[property]);\n } else {\n target[property] = extensions[property];\n }\n }\n }\n return target;\n}\n\nexport function stringify(): string {\n var m = ['Pusher'];\n for (var i = 0; i < arguments.length; i++) {\n if (typeof arguments[i] === 'string') {\n m.push(arguments[i]);\n } else {\n m.push(safeJSONStringify(arguments[i]));\n }\n }\n return m.join(' : ');\n}\n\nexport function arrayIndexOf(array: any[], item: any): number {\n // MSIE doesn't have array.indexOf\n var nativeIndexOf = Array.prototype.indexOf;\n if (array === null) {\n return -1;\n }\n if (nativeIndexOf && array.indexOf === nativeIndexOf) {\n return array.indexOf(item);\n }\n for (var i = 0, l = array.length; i < l; i++) {\n if (array[i] === item) {\n return i;\n }\n }\n return -1;\n}\n\n/** Applies a function f to all properties of an object.\n *\n * Function f gets 3 arguments passed:\n * - element from the object\n * - key of the element\n * - reference to the object\n *\n * @param {Object} object\n * @param {Function} f\n */\nexport function objectApply(object: any, f: Function) {\n for (var key in object) {\n if (Object.prototype.hasOwnProperty.call(object, key)) {\n f(object[key], key, object);\n }\n }\n}\n\n/** Return a list of objects own proerty keys\n *\n * @param {Object} object\n * @returns {Array}\n */\nexport function keys(object: any): string[] {\n var keys = [];\n objectApply(object, function(_, key) {\n keys.push(key);\n });\n return keys;\n}\n\n/** Return a list of object's own property values\n *\n * @param {Object} object\n * @returns {Array}\n */\nexport function values(object: any): any[] {\n var values = [];\n objectApply(object, function(value) {\n values.push(value);\n });\n return values;\n}\n\n/** Applies a function f to all elements of an array.\n *\n * Function f gets 3 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function apply(array: any[], f: Function, context?: any) {\n for (var i = 0; i < array.length; i++) {\n f.call(context || global, array[i], i, array);\n }\n}\n\n/** Maps all elements of the array and returns the result.\n *\n * Function f gets 4 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n * - reference to the destination array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function map(array: any[], f: Function): any[] {\n var result = [];\n for (var i = 0; i < array.length; i++) {\n result.push(f(array[i], i, array, result));\n }\n return result;\n}\n\n/** Maps all elements of the object and returns the result.\n *\n * Function f gets 4 arguments passed:\n * - element from the object\n * - key of the element\n * - reference to the source object\n * - reference to the destination object\n *\n * @param {Object} object\n * @param {Function} f\n */\nexport function mapObject(object: any, f: Function): any {\n var result = {};\n objectApply(object, function(value, key) {\n result[key] = f(value);\n });\n return result;\n}\n\n/** Filters elements of the array using a test function.\n *\n * Function test gets 4 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n * - reference to the destination array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function filter(array: any[], test: Function): any[] {\n test =\n test ||\n function(value) {\n return !!value;\n };\n\n var result = [];\n for (var i = 0; i < array.length; i++) {\n if (test(array[i], i, array, result)) {\n result.push(array[i]);\n }\n }\n return result;\n}\n\n/** Filters properties of the object using a test function.\n *\n * Function test gets 4 arguments passed:\n * - element from the object\n * - key of the element\n * - reference to the source object\n * - reference to the destination object\n *\n * @param {Object} object\n * @param {Function} f\n */\nexport function filterObject(object: Object, test: Function) {\n var result = {};\n objectApply(object, function(value, key) {\n if ((test && test(value, key, object, result)) || Boolean(value)) {\n result[key] = value;\n }\n });\n return result;\n}\n\n/** Flattens an object into a two-dimensional array.\n *\n * @param {Object} object\n * @return {Array} resulting array of [key, value] pairs\n */\nexport function flatten(object: Object): any[] {\n var result = [];\n objectApply(object, function(value, key) {\n result.push([key, value]);\n });\n return result;\n}\n\n/** Checks whether any element of the array passes the test.\n *\n * Function test gets 3 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function any(array: any[], test: Function): boolean {\n for (var i = 0; i < array.length; i++) {\n if (test(array[i], i, array)) {\n return true;\n }\n }\n return false;\n}\n\n/** Checks whether all elements of the array pass the test.\n *\n * Function test gets 3 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function all(array: any[], test: Function): boolean {\n for (var i = 0; i < array.length; i++) {\n if (!test(array[i], i, array)) {\n return false;\n }\n }\n return true;\n}\n\nexport function encodeParamsObject(data): string {\n return mapObject(data, function(value) {\n if (typeof value === 'object') {\n value = safeJSONStringify(value);\n }\n return encodeURIComponent(base64encode(value.toString()));\n });\n}\n\nexport function buildQueryString(data: any): string {\n var params = filterObject(data, function(value) {\n return value !== undefined;\n });\n\n var query = map(\n flatten(encodeParamsObject(params)),\n Util.method('join', '=')\n ).join('&');\n\n return query;\n}\n\n/**\n * See https://github.com/douglascrockford/JSON-js/blob/master/cycle.js\n *\n * Remove circular references from an object. Required for JSON.stringify in\n * React Native, which tends to blow up a lot.\n *\n * @param {any} object\n * @return {any} Decycled object\n */\nexport function decycleObject(object: any): any {\n var objects = [],\n paths = [];\n\n return (function derez(value, path) {\n var i, name, nu;\n\n switch (typeof value) {\n case 'object':\n if (!value) {\n return null;\n }\n for (i = 0; i < objects.length; i += 1) {\n if (objects[i] === value) {\n return { $ref: paths[i] };\n }\n }\n\n objects.push(value);\n paths.push(path);\n\n if (Object.prototype.toString.apply(value) === '[object Array]') {\n nu = [];\n for (i = 0; i < value.length; i += 1) {\n nu[i] = derez(value[i], path + '[' + i + ']');\n }\n } else {\n nu = {};\n for (name in value) {\n if (Object.prototype.hasOwnProperty.call(value, name)) {\n nu[name] = derez(\n value[name],\n path + '[' + JSON.stringify(name) + ']'\n );\n }\n }\n }\n return nu;\n case 'number':\n case 'string':\n case 'boolean':\n return value;\n }\n })(object, '$');\n}\n\n/**\n * Provides a cross-browser and cross-platform way to safely stringify objects\n * into JSON. This is particularly necessary for ReactNative, where circular JSON\n * structures throw an exception.\n *\n * @param {any} source The object to stringify\n * @return {string} The serialized output.\n */\nexport function safeJSONStringify(source: any): string {\n try {\n return JSON.stringify(source);\n } catch (e) {\n return JSON.stringify(decycleObject(source));\n }\n}\n","import {\n ChannelAuthorizationOptions,\n UserAuthenticationOptions\n} from './auth/options';\nimport { AuthTransport } from './config';\n\nexport interface DefaultConfig {\n VERSION: string;\n PROTOCOL: number;\n wsPort: number;\n wssPort: number;\n wsPath: string;\n httpHost: string;\n httpPort: number;\n httpsPort: number;\n httpPath: string;\n stats_host: string;\n authEndpoint: string;\n authTransport: AuthTransport;\n activityTimeout: number;\n pongTimeout: number;\n unavailableTimeout: number;\n userAuthentication: UserAuthenticationOptions;\n channelAuthorization: ChannelAuthorizationOptions;\n\n cdn_http?: string;\n cdn_https?: string;\n dependency_suffix?: string;\n}\n\nvar Defaults: DefaultConfig = {\n VERSION: VERSION,\n PROTOCOL: 7,\n\n wsPort: 80,\n wssPort: 443,\n wsPath: '',\n // DEPRECATED: SockJS fallback parameters\n httpHost: 'sockjs.pusher.com',\n httpPort: 80,\n httpsPort: 443,\n httpPath: '/pusher',\n // DEPRECATED: Stats\n stats_host: 'stats.pusher.com',\n // DEPRECATED: Other settings\n authEndpoint: '/pusher/auth',\n authTransport: 'ajax',\n activityTimeout: 120000,\n pongTimeout: 30000,\n unavailableTimeout: 10000,\n userAuthentication: {\n endpoint: '/pusher/user-auth',\n transport: 'ajax'\n },\n channelAuthorization: {\n endpoint: '/pusher/auth',\n transport: 'ajax'\n },\n\n // CDN configuration\n cdn_http: CDN_HTTP,\n cdn_https: CDN_HTTPS,\n dependency_suffix: DEPENDENCY_SUFFIX\n};\n\nexport default Defaults;\n","import Defaults from '../defaults';\nimport { default as URLScheme, URLSchemeParams } from './url_scheme';\n\nfunction getGenericURL(\n baseScheme: string,\n params: URLSchemeParams,\n path: string\n): string {\n var scheme = baseScheme + (params.useTLS ? 's' : '');\n var host = params.useTLS ? params.hostTLS : params.hostNonTLS;\n return scheme + '://' + host + path;\n}\n\nfunction getGenericPath(key: string, queryString?: string): string {\n var path = '/app/' + key;\n var query =\n '?protocol=' +\n Defaults.PROTOCOL +\n '&client=js' +\n '&version=' +\n Defaults.VERSION +\n (queryString ? '&' + queryString : '');\n return path + query;\n}\n\nexport var ws: URLScheme = {\n getInitial: function(key: string, params: URLSchemeParams): string {\n var path = (params.httpPath || '') + getGenericPath(key, 'flash=false');\n return getGenericURL('ws', params, path);\n }\n};\n\nexport var http: URLScheme = {\n getInitial: function(key: string, params: URLSchemeParams): string {\n var path = (params.httpPath || '/pusher') + getGenericPath(key);\n return getGenericURL('http', params, path);\n }\n};\n\nexport var sockjs: URLScheme = {\n getInitial: function(key: string, params: URLSchemeParams): string {\n return getGenericURL('http', params, params.httpPath || '/pusher');\n },\n getPath: function(key: string, params: URLSchemeParams): string {\n return getGenericPath(key);\n }\n};\n","import Callback from './callback';\nimport * as Collections from '../utils/collections';\nimport CallbackTable from './callback_table';\n\nexport default class CallbackRegistry {\n _callbacks: CallbackTable;\n\n constructor() {\n this._callbacks = {};\n }\n\n get(name: string): Callback[] {\n return this._callbacks[prefix(name)];\n }\n\n add(name: string, callback: Function, context: any) {\n var prefixedEventName = prefix(name);\n this._callbacks[prefixedEventName] =\n this._callbacks[prefixedEventName] || [];\n this._callbacks[prefixedEventName].push({\n fn: callback,\n context: context\n });\n }\n\n remove(name?: string, callback?: Function, context?: any) {\n if (!name && !callback && !context) {\n this._callbacks = {};\n return;\n }\n\n var names = name ? [prefix(name)] : Collections.keys(this._callbacks);\n\n if (callback || context) {\n this.removeCallback(names, callback, context);\n } else {\n this.removeAllCallbacks(names);\n }\n }\n\n private removeCallback(names: string[], callback: Function, context: any) {\n Collections.apply(\n names,\n function(name) {\n this._callbacks[name] = Collections.filter(\n this._callbacks[name] || [],\n function(binding) {\n return (\n (callback && callback !== binding.fn) ||\n (context && context !== binding.context)\n );\n }\n );\n if (this._callbacks[name].length === 0) {\n delete this._callbacks[name];\n }\n },\n this\n );\n }\n\n private removeAllCallbacks(names: string[]) {\n Collections.apply(\n names,\n function(name) {\n delete this._callbacks[name];\n },\n this\n );\n }\n}\n\nfunction prefix(name: string): string {\n return '_' + name;\n}\n","import * as Collections from '../utils/collections';\nimport Callback from './callback';\nimport Metadata from '../channels/metadata';\nimport CallbackRegistry from './callback_registry';\n\n/** Manages callback bindings and event emitting.\n *\n * @param Function failThrough called when no listeners are bound to an event\n */\nexport default class Dispatcher {\n callbacks: CallbackRegistry;\n global_callbacks: Function[];\n failThrough: Function;\n\n constructor(failThrough?: Function) {\n this.callbacks = new CallbackRegistry();\n this.global_callbacks = [];\n this.failThrough = failThrough;\n }\n\n bind(eventName: string, callback: Function, context?: any) {\n this.callbacks.add(eventName, callback, context);\n return this;\n }\n\n bind_global(callback: Function) {\n this.global_callbacks.push(callback);\n return this;\n }\n\n unbind(eventName?: string, callback?: Function, context?: any) {\n this.callbacks.remove(eventName, callback, context);\n return this;\n }\n\n unbind_global(callback?: Function) {\n if (!callback) {\n this.global_callbacks = [];\n return this;\n }\n\n this.global_callbacks = Collections.filter(\n this.global_callbacks || [],\n c => c !== callback\n );\n\n return this;\n }\n\n unbind_all() {\n this.unbind();\n this.unbind_global();\n return this;\n }\n\n emit(eventName: string, data?: any, metadata?: Metadata): Dispatcher {\n for (var i = 0; i < this.global_callbacks.length; i++) {\n this.global_callbacks[i](eventName, data);\n }\n\n var callbacks = this.callbacks.get(eventName);\n var args = [];\n\n if (metadata) {\n // if there's a metadata argument, we need to call the callback with both\n // data and metadata regardless of whether data is undefined\n args.push(data, metadata);\n } else if (data) {\n // metadata is undefined, so we only need to call the callback with data\n // if data exists\n args.push(data);\n }\n\n if (callbacks && callbacks.length > 0) {\n for (var i = 0; i < callbacks.length; i++) {\n callbacks[i].fn.apply(callbacks[i].context || global, args);\n }\n } else if (this.failThrough) {\n this.failThrough(eventName, data);\n }\n\n return this;\n }\n}\n","import { stringify } from './utils/collections';\nimport Pusher from './pusher';\n\nclass Logger {\n debug(...args: any[]) {\n this.log(this.globalLog, args);\n }\n\n warn(...args: any[]) {\n this.log(this.globalLogWarn, args);\n }\n\n error(...args: any[]) {\n this.log(this.globalLogError, args);\n }\n\n private globalLog = (message: string) => {\n if (global.console && global.console.log) {\n global.console.log(message);\n }\n };\n\n private globalLogWarn(message: string) {\n if (global.console && global.console.warn) {\n global.console.warn(message);\n } else {\n this.globalLog(message);\n }\n }\n\n private globalLogError(message: string) {\n if (global.console && global.console.error) {\n global.console.error(message);\n } else {\n this.globalLogWarn(message);\n }\n }\n\n private log(\n defaultLoggingFunction: (message: string) => void,\n ...args: any[]\n ) {\n var message = stringify.apply(this, arguments);\n if (Pusher.log) {\n Pusher.log(message);\n } else if (Pusher.logToConsole) {\n const log = defaultLoggingFunction.bind(this);\n log(message);\n }\n }\n}\n\nexport default new Logger();\n","import Util from '../util';\nimport * as Collections from '../utils/collections';\nimport { default as EventsDispatcher } from '../events/dispatcher';\nimport Logger from '../logger';\nimport TransportHooks from './transport_hooks';\nimport Socket from '../socket';\nimport Runtime from 'runtime';\nimport Timeline from '../timeline/timeline';\nimport TransportConnectionOptions from './transport_connection_options';\n\n/** Provides universal API for transport connections.\n *\n * Transport connection is a low-level object that wraps a connection method\n * and exposes a simple evented interface for the connection state and\n * messaging. It does not implement Pusher-specific WebSocket protocol.\n *\n * Additionally, it fetches resources needed for transport to work and exposes\n * an interface for querying transport features.\n *\n * States:\n * - new - initial state after constructing the object\n * - initializing - during initialization phase, usually fetching resources\n * - intialized - ready to establish a connection\n * - connection - when connection is being established\n * - open - when connection ready to be used\n * - closed - after connection was closed be either side\n *\n * Emits:\n * - error - after the connection raised an error\n *\n * Options:\n * - useTLS - whether connection should be over TLS\n * - hostTLS - host to connect to when connection is over TLS\n * - hostNonTLS - host to connect to when connection is over TLS\n *\n * @param {String} key application key\n * @param {Object} options\n */\nexport default class TransportConnection extends EventsDispatcher {\n hooks: TransportHooks;\n name: string;\n priority: number;\n key: string;\n options: TransportConnectionOptions;\n state: string;\n timeline: Timeline;\n activityTimeout: number;\n id: number;\n socket: Socket;\n beforeOpen: Function;\n initialize: Function;\n\n constructor(\n hooks: TransportHooks,\n name: string,\n priority: number,\n key: string,\n options: TransportConnectionOptions\n ) {\n super();\n this.initialize = Runtime.transportConnectionInitializer;\n this.hooks = hooks;\n this.name = name;\n this.priority = priority;\n this.key = key;\n this.options = options;\n\n this.state = 'new';\n this.timeline = options.timeline;\n this.activityTimeout = options.activityTimeout;\n this.id = this.timeline.generateUniqueID();\n }\n\n /** Checks whether the transport handles activity checks by itself.\n *\n * @return {Boolean}\n */\n handlesActivityChecks(): boolean {\n return Boolean(this.hooks.handlesActivityChecks);\n }\n\n /** Checks whether the transport supports the ping/pong API.\n *\n * @return {Boolean}\n */\n supportsPing(): boolean {\n return Boolean(this.hooks.supportsPing);\n }\n\n /** Tries to establish a connection.\n *\n * @returns {Boolean} false if transport is in invalid state\n */\n connect(): boolean {\n if (this.socket || this.state !== 'initialized') {\n return false;\n }\n\n var url = this.hooks.urls.getInitial(this.key, this.options);\n try {\n this.socket = this.hooks.getSocket(url, this.options);\n } catch (e) {\n Util.defer(() => {\n this.onError(e);\n this.changeState('closed');\n });\n return false;\n }\n\n this.bindListeners();\n\n Logger.debug('Connecting', { transport: this.name, url });\n this.changeState('connecting');\n return true;\n }\n\n /** Closes the connection.\n *\n * @return {Boolean} true if there was a connection to close\n */\n close(): boolean {\n if (this.socket) {\n this.socket.close();\n return true;\n } else {\n return false;\n }\n }\n\n /** Sends data over the open connection.\n *\n * @param {String} data\n * @return {Boolean} true only when in the \"open\" state\n */\n send(data: any): boolean {\n if (this.state === 'open') {\n // Workaround for MobileSafari bug (see https://gist.github.com/2052006)\n Util.defer(() => {\n if (this.socket) {\n this.socket.send(data);\n }\n });\n return true;\n } else {\n return false;\n }\n }\n\n /** Sends a ping if the connection is open and transport supports it. */\n ping() {\n if (this.state === 'open' && this.supportsPing()) {\n this.socket.ping();\n }\n }\n\n private onOpen() {\n if (this.hooks.beforeOpen) {\n this.hooks.beforeOpen(\n this.socket,\n this.hooks.urls.getPath(this.key, this.options)\n );\n }\n this.changeState('open');\n this.socket.onopen = undefined;\n }\n\n private onError(error) {\n this.emit('error', { type: 'WebSocketError', error: error });\n this.timeline.error(this.buildTimelineMessage({ error: error.toString() }));\n }\n\n private onClose(closeEvent?: any) {\n if (closeEvent) {\n this.changeState('closed', {\n code: closeEvent.code,\n reason: closeEvent.reason,\n wasClean: closeEvent.wasClean\n });\n } else {\n this.changeState('closed');\n }\n this.unbindListeners();\n this.socket = undefined;\n }\n\n private onMessage(message) {\n this.emit('message', message);\n }\n\n private onActivity() {\n this.emit('activity');\n }\n\n private bindListeners() {\n this.socket.onopen = () => {\n this.onOpen();\n };\n this.socket.onerror = error => {\n this.onError(error);\n };\n this.socket.onclose = closeEvent => {\n this.onClose(closeEvent);\n };\n this.socket.onmessage = message => {\n this.onMessage(message);\n };\n\n if (this.supportsPing()) {\n this.socket.onactivity = () => {\n this.onActivity();\n };\n }\n }\n\n private unbindListeners() {\n if (this.socket) {\n this.socket.onopen = undefined;\n this.socket.onerror = undefined;\n this.socket.onclose = undefined;\n this.socket.onmessage = undefined;\n if (this.supportsPing()) {\n this.socket.onactivity = undefined;\n }\n }\n }\n\n private changeState(state: string, params?: any) {\n this.state = state;\n this.timeline.info(\n this.buildTimelineMessage({\n state: state,\n params: params\n })\n );\n this.emit(state, params);\n }\n\n buildTimelineMessage(message): any {\n return Collections.extend({ cid: this.id }, message);\n }\n}\n","import Factory from '../utils/factory';\nimport TransportHooks from './transport_hooks';\nimport TransportConnection from './transport_connection';\nimport TransportConnectionOptions from './transport_connection_options';\n\n/** Provides interface for transport connection instantiation.\n *\n * Takes transport-specific hooks as the only argument, which allow checking\n * for transport support and creating its connections.\n *\n * Supported hooks: * - file - the name of the file to be fetched during initialization\n * - urls - URL scheme to be used by transport\n * - handlesActivityCheck - true when the transport handles activity checks\n * - supportsPing - true when the transport has a ping/activity API\n * - isSupported - tells whether the transport is supported in the environment\n * - getSocket - creates a WebSocket-compatible transport socket\n *\n * See transports.js for specific implementations.\n *\n * @param {Object} hooks object containing all needed transport hooks\n */\nexport default class Transport {\n hooks: TransportHooks;\n\n constructor(hooks: TransportHooks) {\n this.hooks = hooks;\n }\n\n /** Returns whether the transport is supported in the environment.\n *\n * @param {Object} envronment te environment details (encryption, settings)\n * @returns {Boolean} true when the transport is supported\n */\n isSupported(environment: any): boolean {\n return this.hooks.isSupported(environment);\n }\n\n /** Creates a transport connection.\n *\n * @param {String} name\n * @param {Number} priority\n * @param {String} key the application key\n * @param {Object} options\n * @returns {TransportConnection}\n */\n createConnection(\n name: string,\n priority: number,\n key: string,\n options: any\n ): TransportConnection {\n return new TransportConnection(this.hooks, name, priority, key, options);\n }\n}\n","import * as URLSchemes from 'core/transports/url_schemes';\nimport URLScheme from 'core/transports/url_scheme';\nimport Transport from 'core/transports/transport';\nimport Util from 'core/util';\nimport * as Collections from 'core/utils/collections';\nimport TransportHooks from 'core/transports/transport_hooks';\nimport TransportsTable from 'core/transports/transports_table';\nimport Runtime from 'runtime';\n\n/** WebSocket transport.\n *\n * Uses native WebSocket implementation, including MozWebSocket supported by\n * earlier Firefox versions.\n */\nvar WSTransport = new Transport({\n urls: URLSchemes.ws,\n handlesActivityChecks: false,\n supportsPing: false,\n\n isInitialized: function() {\n return Boolean(Runtime.getWebSocketAPI());\n },\n isSupported: function(): boolean {\n return Boolean(Runtime.getWebSocketAPI());\n },\n getSocket: function(url) {\n return Runtime.createWebSocket(url);\n }\n});\n\nvar httpConfiguration = {\n urls: URLSchemes.http,\n handlesActivityChecks: false,\n supportsPing: true,\n isInitialized: function() {\n return true;\n }\n};\n\nexport var streamingConfiguration = Collections.extend(\n {\n getSocket: function(url) {\n return Runtime.HTTPFactory.createStreamingSocket(url);\n }\n },\n httpConfiguration\n);\nexport var pollingConfiguration = Collections.extend(\n {\n getSocket: function(url) {\n return Runtime.HTTPFactory.createPollingSocket(url);\n }\n },\n httpConfiguration\n);\n\nvar xhrConfiguration = {\n isSupported: function(): boolean {\n return Runtime.isXHRSupported();\n }\n};\n\n/** HTTP streaming transport using CORS-enabled XMLHttpRequest. */\nvar XHRStreamingTransport = new Transport(\n (\n Collections.extend({}, streamingConfiguration, xhrConfiguration)\n )\n);\n\n/** HTTP long-polling transport using CORS-enabled XMLHttpRequest. */\nvar XHRPollingTransport = new Transport(\n Collections.extend({}, pollingConfiguration, xhrConfiguration)\n);\n\nvar Transports: TransportsTable = {\n ws: WSTransport,\n xhr_streaming: XHRStreamingTransport,\n xhr_polling: XHRPollingTransport\n};\n\nexport default Transports;\n","import Util from '../util';\nimport * as Collections from '../utils/collections';\nimport TransportManager from './transport_manager';\nimport TransportConnection from './transport_connection';\nimport Transport from './transport';\nimport PingDelayOptions from './ping_delay_options';\n\n/** Creates transport connections monitored by a transport manager.\n *\n * When a transport is closed, it might mean the environment does not support\n * it. It's possible that messages get stuck in an intermediate buffer or\n * proxies terminate inactive connections. To combat these problems,\n * assistants monitor the connection lifetime, report unclean exits and\n * adjust ping timeouts to keep the connection active. The decision to disable\n * a transport is the manager's responsibility.\n *\n * @param {TransportManager} manager\n * @param {TransportConnection} transport\n * @param {Object} options\n */\nexport default class AssistantToTheTransportManager {\n manager: TransportManager;\n transport: Transport;\n minPingDelay: number;\n maxPingDelay: number;\n pingDelay: number;\n\n constructor(\n manager: TransportManager,\n transport: Transport,\n options: PingDelayOptions\n ) {\n this.manager = manager;\n this.transport = transport;\n this.minPingDelay = options.minPingDelay;\n this.maxPingDelay = options.maxPingDelay;\n this.pingDelay = undefined;\n }\n\n /** Creates a transport connection.\n *\n * This function has the same API as Transport#createConnection.\n *\n * @param {String} name\n * @param {Number} priority\n * @param {String} key the application key\n * @param {Object} options\n * @returns {TransportConnection}\n */\n createConnection(\n name: string,\n priority: number,\n key: string,\n options: Object\n ): TransportConnection {\n options = Collections.extend({}, options, {\n activityTimeout: this.pingDelay\n });\n var connection = this.transport.createConnection(\n name,\n priority,\n key,\n options\n );\n\n var openTimestamp = null;\n\n var onOpen = function() {\n connection.unbind('open', onOpen);\n connection.bind('closed', onClosed);\n openTimestamp = Util.now();\n };\n var onClosed = closeEvent => {\n connection.unbind('closed', onClosed);\n\n if (closeEvent.code === 1002 || closeEvent.code === 1003) {\n // we don't want to use transports not obeying the protocol\n this.manager.reportDeath();\n } else if (!closeEvent.wasClean && openTimestamp) {\n // report deaths only for short-living transport\n var lifespan = Util.now() - openTimestamp;\n if (lifespan < 2 * this.maxPingDelay) {\n this.manager.reportDeath();\n this.pingDelay = Math.max(lifespan / 2, this.minPingDelay);\n }\n }\n };\n\n connection.bind('open', onOpen);\n return connection;\n }\n\n /** Returns whether the transport is supported in the environment.\n *\n * This function has the same API as Transport#isSupported. Might return false\n * when the manager decides to kill the transport.\n *\n * @param {Object} environment the environment details (encryption, settings)\n * @returns {Boolean} true when the transport is supported\n */\n isSupported(environment: string): boolean {\n return this.manager.isAlive() && this.transport.isSupported(environment);\n }\n}\n","import Action from './action';\nimport { PusherEvent } from './message-types';\n/**\n * Provides functions for handling Pusher protocol-specific messages.\n */\n\nconst Protocol = {\n /**\n * Decodes a message in a Pusher format.\n *\n * The MessageEvent we receive from the transport should contain a pusher event\n * (https://pusher.com/docs/pusher_protocol#events) serialized as JSON in the\n * data field\n *\n * The pusher event may contain a data field too, and it may also be\n * serialised as JSON\n *\n * Throws errors when messages are not parse'able.\n *\n * @param {MessageEvent} messageEvent\n * @return {PusherEvent}\n */\n decodeMessage: function(messageEvent: MessageEvent): PusherEvent {\n try {\n var messageData = JSON.parse(messageEvent.data);\n var pusherEventData = messageData.data;\n if (typeof pusherEventData === 'string') {\n try {\n pusherEventData = JSON.parse(messageData.data);\n } catch (e) {}\n }\n var pusherEvent: PusherEvent = {\n event: messageData.event,\n channel: messageData.channel,\n data: pusherEventData\n };\n if (messageData.user_id) {\n pusherEvent.user_id = messageData.user_id;\n }\n return pusherEvent;\n } catch (e) {\n throw { type: 'MessageParseError', error: e, data: messageEvent.data };\n }\n },\n\n /**\n * Encodes a message to be sent.\n *\n * @param {PusherEvent} event\n * @return {String}\n */\n encodeMessage: function(event: PusherEvent): string {\n return JSON.stringify(event);\n },\n\n /**\n * Processes a handshake message and returns appropriate actions.\n *\n * Returns an object with an 'action' and other action-specific properties.\n *\n * There are three outcomes when calling this function. First is a successful\n * connection attempt, when pusher:connection_established is received, which\n * results in a 'connected' action with an 'id' property. When passed a\n * pusher:error event, it returns a result with action appropriate to the\n * close code and an error. Otherwise, it raises an exception.\n *\n * @param {String} message\n * @result Object\n */\n processHandshake: function(messageEvent: MessageEvent): Action {\n var message = Protocol.decodeMessage(messageEvent);\n\n if (message.event === 'pusher:connection_established') {\n if (!message.data.activity_timeout) {\n throw 'No activity timeout specified in handshake';\n }\n return {\n action: 'connected',\n id: message.data.socket_id,\n activityTimeout: message.data.activity_timeout * 1000\n };\n } else if (message.event === 'pusher:error') {\n // From protocol 6 close codes are sent only once, so this only\n // happens when connection does not support close codes\n return {\n action: this.getCloseAction(message.data),\n error: this.getCloseError(message.data)\n };\n } else {\n throw 'Invalid handshake';\n }\n },\n\n /**\n * Dispatches the close event and returns an appropriate action name.\n *\n * See:\n * 1. https://developer.mozilla.org/en-US/docs/WebSockets/WebSockets_reference/CloseEvent\n * 2. http://pusher.com/docs/pusher_protocol\n *\n * @param {CloseEvent} closeEvent\n * @return {String} close action name\n */\n getCloseAction: function(closeEvent): string {\n if (closeEvent.code < 4000) {\n // ignore 1000 CLOSE_NORMAL, 1001 CLOSE_GOING_AWAY,\n // 1005 CLOSE_NO_STATUS, 1006 CLOSE_ABNORMAL\n // ignore 1007...3999\n // handle 1002 CLOSE_PROTOCOL_ERROR, 1003 CLOSE_UNSUPPORTED,\n // 1004 CLOSE_TOO_LARGE\n if (closeEvent.code >= 1002 && closeEvent.code <= 1004) {\n return 'backoff';\n } else {\n return null;\n }\n } else if (closeEvent.code === 4000) {\n return 'tls_only';\n } else if (closeEvent.code < 4100) {\n return 'refused';\n } else if (closeEvent.code < 4200) {\n return 'backoff';\n } else if (closeEvent.code < 4300) {\n return 'retry';\n } else {\n // unknown error\n return 'refused';\n }\n },\n\n /**\n * Returns an error or null basing on the close event.\n *\n * Null is returned when connection was closed cleanly. Otherwise, an object\n * with error details is returned.\n *\n * @param {CloseEvent} closeEvent\n * @return {Object} error object\n */\n getCloseError: function(closeEvent): any {\n if (closeEvent.code !== 1000 && closeEvent.code !== 1001) {\n return {\n type: 'PusherError',\n data: {\n code: closeEvent.code,\n message: closeEvent.reason || closeEvent.message\n }\n };\n } else {\n return null;\n }\n }\n};\n\nexport default Protocol;\n","import * as Collections from '../utils/collections';\nimport { default as EventsDispatcher } from '../events/dispatcher';\nimport Protocol from './protocol/protocol';\nimport { PusherEvent } from './protocol/message-types';\nimport Logger from '../logger';\nimport TransportConnection from '../transports/transport_connection';\nimport Socket from '../socket';\n/**\n * Provides Pusher protocol interface for transports.\n *\n * Emits following events:\n * - message - on received messages\n * - ping - on ping requests\n * - pong - on pong responses\n * - error - when the transport emits an error\n * - closed - after closing the transport\n *\n * It also emits more events when connection closes with a code.\n * See Protocol.getCloseAction to get more details.\n *\n * @param {Number} id\n * @param {AbstractTransport} transport\n */\nexport default class Connection extends EventsDispatcher implements Socket {\n id: string;\n transport: TransportConnection;\n activityTimeout: number;\n\n constructor(id: string, transport: TransportConnection) {\n super();\n this.id = id;\n this.transport = transport;\n this.activityTimeout = transport.activityTimeout;\n this.bindListeners();\n }\n\n /** Returns whether used transport handles activity checks by itself\n *\n * @returns {Boolean} true if activity checks are handled by the transport\n */\n handlesActivityChecks() {\n return this.transport.handlesActivityChecks();\n }\n\n /** Sends raw data.\n *\n * @param {String} data\n */\n send(data: any): boolean {\n return this.transport.send(data);\n }\n\n /** Sends an event.\n *\n * @param {String} name\n * @param {String} data\n * @param {String} [channel]\n * @returns {Boolean} whether message was sent or not\n */\n send_event(name: string, data: any, channel?: string): boolean {\n var event: PusherEvent = { event: name, data: data };\n if (channel) {\n event.channel = channel;\n }\n Logger.debug('Event sent', event);\n return this.send(Protocol.encodeMessage(event));\n }\n\n /** Sends a ping message to the server.\n *\n * Basing on the underlying transport, it might send either transport's\n * protocol-specific ping or pusher:ping event.\n */\n ping() {\n if (this.transport.supportsPing()) {\n this.transport.ping();\n } else {\n this.send_event('pusher:ping', {});\n }\n }\n\n /** Closes the connection. */\n close() {\n this.transport.close();\n }\n\n private bindListeners() {\n var listeners = {\n message: (messageEvent: MessageEvent) => {\n var pusherEvent;\n try {\n pusherEvent = Protocol.decodeMessage(messageEvent);\n } catch (e) {\n this.emit('error', {\n type: 'MessageParseError',\n error: e,\n data: messageEvent.data\n });\n }\n\n if (pusherEvent !== undefined) {\n Logger.debug('Event recd', pusherEvent);\n\n switch (pusherEvent.event) {\n case 'pusher:error':\n this.emit('error', {\n type: 'PusherError',\n data: pusherEvent.data\n });\n break;\n case 'pusher:ping':\n this.emit('ping');\n break;\n case 'pusher:pong':\n this.emit('pong');\n break;\n }\n this.emit('message', pusherEvent);\n }\n },\n activity: () => {\n this.emit('activity');\n },\n error: error => {\n this.emit('error', error);\n },\n closed: closeEvent => {\n unbindListeners();\n\n if (closeEvent && closeEvent.code) {\n this.handleCloseEvent(closeEvent);\n }\n\n this.transport = null;\n this.emit('closed');\n }\n };\n\n var unbindListeners = () => {\n Collections.objectApply(listeners, (listener, event) => {\n this.transport.unbind(event, listener);\n });\n };\n\n Collections.objectApply(listeners, (listener, event) => {\n this.transport.bind(event, listener);\n });\n }\n\n private handleCloseEvent(closeEvent: any) {\n var action = Protocol.getCloseAction(closeEvent);\n var error = Protocol.getCloseError(closeEvent);\n if (error) {\n this.emit('error', error);\n }\n if (action) {\n this.emit(action, { action: action, error: error });\n }\n }\n}\n","import Util from '../../util';\nimport * as Collections from '../../utils/collections';\nimport Protocol from '../protocol/protocol';\nimport Connection from '../connection';\nimport TransportConnection from '../../transports/transport_connection';\nimport HandshakePayload from './handshake_payload';\n\n/**\n * Handles Pusher protocol handshakes for transports.\n *\n * Calls back with a result object after handshake is completed. Results\n * always have two fields:\n * - action - string describing action to be taken after the handshake\n * - transport - the transport object passed to the constructor\n *\n * Different actions can set different additional properties on the result.\n * In the case of 'connected' action, there will be a 'connection' property\n * containing a Connection object for the transport. Other actions should\n * carry an 'error' property.\n *\n * @param {AbstractTransport} transport\n * @param {Function} callback\n */\nexport default class Handshake {\n transport: TransportConnection;\n callback: (HandshakePayload) => void;\n onMessage: Function;\n onClosed: Function;\n\n constructor(\n transport: TransportConnection,\n callback: (HandshakePayload) => void\n ) {\n this.transport = transport;\n this.callback = callback;\n this.bindListeners();\n }\n\n close() {\n this.unbindListeners();\n this.transport.close();\n }\n\n private bindListeners() {\n this.onMessage = m => {\n this.unbindListeners();\n\n var result;\n try {\n result = Protocol.processHandshake(m);\n } catch (e) {\n this.finish('error', { error: e });\n this.transport.close();\n return;\n }\n\n if (result.action === 'connected') {\n this.finish('connected', {\n connection: new Connection(result.id, this.transport),\n activityTimeout: result.activityTimeout\n });\n } else {\n this.finish(result.action, { error: result.error });\n this.transport.close();\n }\n };\n\n this.onClosed = closeEvent => {\n this.unbindListeners();\n\n var action = Protocol.getCloseAction(closeEvent) || 'backoff';\n var error = Protocol.getCloseError(closeEvent);\n this.finish(action, { error: error });\n };\n\n this.transport.bind('message', this.onMessage);\n this.transport.bind('closed', this.onClosed);\n }\n\n private unbindListeners() {\n this.transport.unbind('message', this.onMessage);\n this.transport.unbind('closed', this.onClosed);\n }\n\n private finish(action: string, params: any) {\n this.callback(\n Collections.extend({ transport: this.transport, action: action }, params)\n );\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport base64encode from '../base64';\nimport Timeline from './timeline';\nimport Runtime from 'runtime';\n\nexport interface TimelineSenderOptions {\n host?: string;\n port?: number;\n path?: string;\n}\n\nexport default class TimelineSender {\n timeline: Timeline;\n options: TimelineSenderOptions;\n host: string;\n\n constructor(timeline: Timeline, options: TimelineSenderOptions) {\n this.timeline = timeline;\n this.options = options || {};\n }\n\n send(useTLS: boolean, callback?: Function) {\n if (this.timeline.isEmpty()) {\n return;\n }\n\n this.timeline.send(\n Runtime.TimelineTransport.getAgent(this, useTLS),\n callback\n );\n }\n}\n","/** Error classes used throughout the library. */\n// https://github.com/Microsoft/TypeScript-wiki/blob/master/Breaking-Changes.md#extending-built-ins-like-error-array-and-map-may-no-longer-work\nexport class BadEventName extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\nexport class BadChannelName extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\nexport class RequestTimedOut extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class TransportPriorityTooLow extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class TransportClosed extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class UnsupportedFeature extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class UnsupportedTransport extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class UnsupportedStrategy extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class HTTPAuthError extends Error {\n status: number;\n constructor(status: number, msg?: string) {\n super(msg);\n this.status = status;\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n","/**\n * A place to store help URLs for error messages etc\n */\n\nconst urlStore = {\n baseUrl: 'https://pusher.com',\n urls: {\n authenticationEndpoint: {\n path: '/docs/channels/server_api/authenticating_users'\n },\n authorizationEndpoint: {\n path: '/docs/channels/server_api/authorizing-users/'\n },\n javascriptQuickStart: {\n path: '/docs/javascript_quick_start'\n },\n triggeringClientEvents: {\n path: '/docs/client_api_guide/client_events#trigger-events'\n },\n encryptedChannelSupport: {\n fullUrl:\n 'https://github.com/pusher/pusher-js/tree/cc491015371a4bde5743d1c87a0fbac0feb53195#encrypted-channel-support'\n }\n }\n};\n\n/** Builds a consistent string with links to pusher documentation\n *\n * @param {string} key - relevant key in the url_store.urls object\n * @return {string} suffix string to append to log message\n */\nconst buildLogSuffix = function(key: string): string {\n const urlPrefix = 'See:';\n const urlObj = urlStore.urls[key];\n if (!urlObj) return '';\n\n let url;\n if (urlObj.fullUrl) {\n url = urlObj.fullUrl;\n } else if (urlObj.path) {\n url = urlStore.baseUrl + urlObj.path;\n }\n\n if (!url) return '';\n return `${urlPrefix} ${url}`;\n};\n\nexport default { buildLogSuffix };\n","import { default as EventsDispatcher } from '../events/dispatcher';\nimport * as Errors from '../errors';\nimport Logger from '../logger';\nimport Pusher from '../pusher';\nimport { PusherEvent } from '../connection/protocol/message-types';\nimport Metadata from './metadata';\nimport UrlStore from '../utils/url_store';\nimport {\n ChannelAuthorizationData,\n ChannelAuthorizationCallback\n} from '../auth/options';\nimport { HTTPAuthError } from '../errors';\n\n/** Provides base public channel interface with an event emitter.\n *\n * Emits:\n * - pusher:subscription_succeeded - after subscribing successfully\n * - other non-internal events\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\nexport default class Channel extends EventsDispatcher {\n name: string;\n pusher: Pusher;\n subscribed: boolean;\n subscriptionPending: boolean;\n subscriptionCancelled: boolean;\n subscriptionCount: null;\n\n constructor(name: string, pusher: Pusher) {\n super(function(event, data) {\n Logger.debug('No callbacks on ' + name + ' for ' + event);\n });\n\n this.name = name;\n this.pusher = pusher;\n this.subscribed = false;\n this.subscriptionPending = false;\n this.subscriptionCancelled = false;\n }\n\n /** Skips authorization, since public channels don't require it.\n *\n * @param {Function} callback\n */\n authorize(socketId: string, callback: ChannelAuthorizationCallback) {\n return callback(null, { auth: '' });\n }\n\n /** Triggers an event */\n trigger(event: string, data: any) {\n if (event.indexOf('client-') !== 0) {\n throw new Errors.BadEventName(\n \"Event '\" + event + \"' does not start with 'client-'\"\n );\n }\n if (!this.subscribed) {\n var suffix = UrlStore.buildLogSuffix('triggeringClientEvents');\n Logger.warn(\n `Client event triggered before channel 'subscription_succeeded' event . ${suffix}`\n );\n }\n return this.pusher.send_event(event, data, this.name);\n }\n\n /** Signals disconnection to the channel. For internal use only. */\n disconnect() {\n this.subscribed = false;\n this.subscriptionPending = false;\n }\n\n /** Handles a PusherEvent. For internal use only.\n *\n * @param {PusherEvent} event\n */\n handleEvent(event: PusherEvent) {\n var eventName = event.event;\n var data = event.data;\n if (eventName === 'pusher_internal:subscription_succeeded') {\n this.handleSubscriptionSucceededEvent(event);\n } else if (eventName === 'pusher_internal:subscription_count') {\n this.handleSubscriptionCountEvent(event);\n } else if (eventName.indexOf('pusher_internal:') !== 0) {\n var metadata: Metadata = {};\n this.emit(eventName, data, metadata);\n }\n }\n\n handleSubscriptionSucceededEvent(event: PusherEvent) {\n this.subscriptionPending = false;\n this.subscribed = true;\n if (this.subscriptionCancelled) {\n this.pusher.unsubscribe(this.name);\n } else {\n this.emit('pusher:subscription_succeeded', event.data);\n }\n }\n\n handleSubscriptionCountEvent(event: PusherEvent) {\n if (event.data.subscription_count) {\n this.subscriptionCount = event.data.subscription_count;\n }\n\n this.emit('pusher:subscription_count', event.data);\n }\n\n /** Sends a subscription request. For internal use only. */\n subscribe() {\n if (this.subscribed) {\n return;\n }\n this.subscriptionPending = true;\n this.subscriptionCancelled = false;\n this.authorize(\n this.pusher.connection.socket_id,\n (error: Error | null, data: ChannelAuthorizationData) => {\n if (error) {\n this.subscriptionPending = false;\n // Why not bind to 'pusher:subscription_error' a level up, and log there?\n // Binding to this event would cause the warning about no callbacks being\n // bound (see constructor) to be suppressed, that's not what we want.\n Logger.error(error.toString());\n this.emit(\n 'pusher:subscription_error',\n Object.assign(\n {},\n {\n type: 'AuthError',\n error: error.message\n },\n error instanceof HTTPAuthError ? { status: error.status } : {}\n )\n );\n } else {\n this.pusher.send_event('pusher:subscribe', {\n auth: data.auth,\n channel_data: data.channel_data,\n channel: this.name\n });\n }\n }\n );\n }\n\n /** Sends an unsubscription request. For internal use only. */\n unsubscribe() {\n this.subscribed = false;\n this.pusher.send_event('pusher:unsubscribe', {\n channel: this.name\n });\n }\n\n /** Cancels an in progress subscription. For internal use only. */\n cancelSubscription() {\n this.subscriptionCancelled = true;\n }\n\n /** Reinstates an in progress subscripiton. For internal use only. */\n reinstateSubscription() {\n this.subscriptionCancelled = false;\n }\n}\n","import Factory from '../utils/factory';\nimport Channel from './channel';\nimport { ChannelAuthorizationCallback } from '../auth/options';\n\n/** Extends public channels to provide private channel interface.\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\nexport default class PrivateChannel extends Channel {\n /** Authorizes the connection to use the channel.\n *\n * @param {String} socketId\n * @param {Function} callback\n */\n authorize(socketId: string, callback: ChannelAuthorizationCallback) {\n return this.pusher.config.channelAuthorizer(\n {\n channelName: this.name,\n socketId: socketId\n },\n callback\n );\n }\n}\n","import * as Collections from '../utils/collections';\n\n/** Represents a collection of members of a presence channel. */\nexport default class Members {\n members: any;\n count: number;\n myID: any;\n me: any;\n\n constructor() {\n this.reset();\n }\n\n /** Returns member's info for given id.\n *\n * Resulting object containts two fields - id and info.\n *\n * @param {Number} id\n * @return {Object} member's info or null\n */\n get(id: string): any {\n if (Object.prototype.hasOwnProperty.call(this.members, id)) {\n return {\n id: id,\n info: this.members[id]\n };\n } else {\n return null;\n }\n }\n\n /** Calls back for each member in unspecified order.\n *\n * @param {Function} callback\n */\n each(callback: Function) {\n Collections.objectApply(this.members, (member, id) => {\n callback(this.get(id));\n });\n }\n\n /** Updates the id for connected member. For internal use only. */\n setMyID(id: string) {\n this.myID = id;\n }\n\n /** Handles subscription data. For internal use only. */\n onSubscription(subscriptionData: any) {\n this.members = subscriptionData.presence.hash;\n this.count = subscriptionData.presence.count;\n this.me = this.get(this.myID);\n }\n\n /** Adds a new member to the collection. For internal use only. */\n addMember(memberData: any) {\n if (this.get(memberData.user_id) === null) {\n this.count++;\n }\n this.members[memberData.user_id] = memberData.user_info;\n return this.get(memberData.user_id);\n }\n\n /** Adds a member from the collection. For internal use only. */\n removeMember(memberData: any) {\n var member = this.get(memberData.user_id);\n if (member) {\n delete this.members[memberData.user_id];\n this.count--;\n }\n return member;\n }\n\n /** Resets the collection to the initial state. For internal use only. */\n reset() {\n this.members = {};\n this.count = 0;\n this.myID = null;\n this.me = null;\n }\n}\n","import PrivateChannel from './private_channel';\nimport Logger from '../logger';\nimport Members from './members';\nimport Pusher from '../pusher';\nimport UrlStore from 'core/utils/url_store';\nimport { PusherEvent } from '../connection/protocol/message-types';\nimport Metadata from './metadata';\nimport { ChannelAuthorizationData } from '../auth/options';\n\nexport default class PresenceChannel extends PrivateChannel {\n members: Members;\n\n /** Adds presence channel functionality to private channels.\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\n constructor(name: string, pusher: Pusher) {\n super(name, pusher);\n this.members = new Members();\n }\n\n /** Authorizes the connection as a member of the channel.\n *\n * @param {String} socketId\n * @param {Function} callback\n */\n authorize(socketId: string, callback: Function) {\n super.authorize(socketId, async (error, authData) => {\n if (!error) {\n authData = authData as ChannelAuthorizationData;\n if (authData.channel_data != null) {\n var channelData = JSON.parse(authData.channel_data);\n this.members.setMyID(channelData.user_id);\n } else {\n await this.pusher.user.signinDonePromise;\n if (this.pusher.user.user_data != null) {\n // If the user is signed in, get the id of the authenticated user\n // and allow the presence authorization to continue.\n this.members.setMyID(this.pusher.user.user_data.id);\n } else {\n let suffix = UrlStore.buildLogSuffix('authorizationEndpoint');\n Logger.error(\n `Invalid auth response for channel '${this.name}', ` +\n `expected 'channel_data' field. ${suffix}, ` +\n `or the user should be signed in.`\n );\n callback('Invalid auth response');\n return;\n }\n }\n }\n callback(error, authData);\n });\n }\n\n /** Handles presence and subscription events. For internal use only.\n *\n * @param {PusherEvent} event\n */\n handleEvent(event: PusherEvent) {\n var eventName = event.event;\n if (eventName.indexOf('pusher_internal:') === 0) {\n this.handleInternalEvent(event);\n } else {\n var data = event.data;\n var metadata: Metadata = {};\n if (event.user_id) {\n metadata.user_id = event.user_id;\n }\n this.emit(eventName, data, metadata);\n }\n }\n handleInternalEvent(event: PusherEvent) {\n var eventName = event.event;\n var data = event.data;\n switch (eventName) {\n case 'pusher_internal:subscription_succeeded':\n this.handleSubscriptionSucceededEvent(event);\n break;\n case 'pusher_internal:subscription_count':\n this.handleSubscriptionCountEvent(event);\n break;\n case 'pusher_internal:member_added':\n var addedMember = this.members.addMember(data);\n this.emit('pusher:member_added', addedMember);\n break;\n case 'pusher_internal:member_removed':\n var removedMember = this.members.removeMember(data);\n if (removedMember) {\n this.emit('pusher:member_removed', removedMember);\n }\n break;\n }\n }\n\n handleSubscriptionSucceededEvent(event: PusherEvent) {\n this.subscriptionPending = false;\n this.subscribed = true;\n if (this.subscriptionCancelled) {\n this.pusher.unsubscribe(this.name);\n } else {\n this.members.onSubscription(event.data);\n this.emit('pusher:subscription_succeeded', this.members);\n }\n }\n\n /** Resets the channel state, including members map. For internal use only. */\n disconnect() {\n this.members.reset();\n super.disconnect();\n }\n}\n","import PrivateChannel from './private_channel';\nimport * as Errors from '../errors';\nimport Logger from '../logger';\nimport Pusher from '../pusher';\nimport { decode as encodeUTF8 } from '@stablelib/utf8';\nimport { decode as decodeBase64 } from '@stablelib/base64';\nimport Dispatcher from '../events/dispatcher';\nimport { PusherEvent } from '../connection/protocol/message-types';\nimport {\n ChannelAuthorizationData,\n ChannelAuthorizationCallback\n} from '../auth/options';\nimport * as nacl from 'tweetnacl';\n\n/** Extends private channels to provide encrypted channel interface.\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\nexport default class EncryptedChannel extends PrivateChannel {\n key: Uint8Array = null;\n nacl: nacl;\n\n constructor(name: string, pusher: Pusher, nacl: nacl) {\n super(name, pusher);\n this.nacl = nacl;\n }\n\n /** Authorizes the connection to use the channel.\n *\n * @param {String} socketId\n * @param {Function} callback\n */\n authorize(socketId: string, callback: ChannelAuthorizationCallback) {\n super.authorize(\n socketId,\n (error: Error | null, authData: ChannelAuthorizationData) => {\n if (error) {\n callback(error, authData);\n return;\n }\n let sharedSecret = authData['shared_secret'];\n if (!sharedSecret) {\n callback(\n new Error(\n `No shared_secret key in auth payload for encrypted channel: ${this.name}`\n ),\n null\n );\n return;\n }\n this.key = decodeBase64(sharedSecret);\n delete authData['shared_secret'];\n callback(null, authData);\n }\n );\n }\n\n trigger(event: string, data: any): boolean {\n throw new Errors.UnsupportedFeature(\n 'Client events are not currently supported for encrypted channels'\n );\n }\n\n /** Handles an event. For internal use only.\n *\n * @param {PusherEvent} event\n */\n handleEvent(event: PusherEvent) {\n var eventName = event.event;\n var data = event.data;\n if (\n eventName.indexOf('pusher_internal:') === 0 ||\n eventName.indexOf('pusher:') === 0\n ) {\n super.handleEvent(event);\n return;\n }\n this.handleEncryptedEvent(eventName, data);\n }\n\n private handleEncryptedEvent(event: string, data: any): void {\n if (!this.key) {\n Logger.debug(\n 'Received encrypted event before key has been retrieved from the authEndpoint'\n );\n return;\n }\n if (!data.ciphertext || !data.nonce) {\n Logger.error(\n 'Unexpected format for encrypted event, expected object with `ciphertext` and `nonce` fields, got: ' +\n data\n );\n return;\n }\n let cipherText = decodeBase64(data.ciphertext);\n if (cipherText.length < this.nacl.secretbox.overheadLength) {\n Logger.error(\n `Expected encrypted event ciphertext length to be ${this.nacl.secretbox.overheadLength}, got: ${cipherText.length}`\n );\n return;\n }\n let nonce = decodeBase64(data.nonce);\n if (nonce.length < this.nacl.secretbox.nonceLength) {\n Logger.error(\n `Expected encrypted event nonce length to be ${this.nacl.secretbox.nonceLength}, got: ${nonce.length}`\n );\n return;\n }\n\n let bytes = this.nacl.secretbox.open(cipherText, nonce, this.key);\n if (bytes === null) {\n Logger.debug(\n 'Failed to decrypt an event, probably because it was encrypted with a different key. Fetching a new key from the authEndpoint...'\n );\n // Try a single time to retrieve a new auth key and decrypt the event with it\n // If this fails, a new key will be requested when a new message is received\n this.authorize(this.pusher.connection.socket_id, (error, authData) => {\n if (error) {\n Logger.error(\n `Failed to make a request to the authEndpoint: ${authData}. Unable to fetch new key, so dropping encrypted event`\n );\n return;\n }\n bytes = this.nacl.secretbox.open(cipherText, nonce, this.key);\n if (bytes === null) {\n Logger.error(\n `Failed to decrypt event with new key. Dropping encrypted event`\n );\n return;\n }\n this.emit(event, this.getDataToEmit(bytes));\n return;\n });\n return;\n }\n this.emit(event, this.getDataToEmit(bytes));\n }\n\n // Try and parse the decrypted bytes as JSON. If we can't parse it, just\n // return the utf-8 string\n getDataToEmit(bytes: Uint8Array): string {\n let raw = encodeUTF8(bytes);\n try {\n return JSON.parse(raw);\n } catch {\n return raw;\n }\n }\n}\n","import { default as EventsDispatcher } from '../events/dispatcher';\nimport { OneOffTimer as Timer } from '../utils/timers';\nimport { Config } from '../config';\nimport Logger from '../logger';\nimport HandshakePayload from './handshake/handshake_payload';\nimport Connection from './connection';\nimport Strategy from '../strategies/strategy';\nimport StrategyRunner from '../strategies/strategy_runner';\nimport * as Collections from '../utils/collections';\nimport Timeline from '../timeline/timeline';\nimport ConnectionManagerOptions from './connection_manager_options';\nimport Runtime from 'runtime';\n\nimport {\n ErrorCallbacks,\n HandshakeCallbacks,\n ConnectionCallbacks\n} from './callbacks';\nimport Action from './protocol/action';\n\n/** Manages connection to Pusher.\n *\n * Uses a strategy (currently only default), timers and network availability\n * info to establish a connection and export its state. In case of failures,\n * manages reconnection attempts.\n *\n * Exports state changes as following events:\n * - \"state_change\", { previous: p, current: state }\n * - state\n *\n * States:\n * - initialized - initial state, never transitioned to\n * - connecting - connection is being established\n * - connected - connection has been fully established\n * - disconnected - on requested disconnection\n * - unavailable - after connection timeout or when there's no network\n * - failed - when the connection strategy is not supported\n *\n * Options:\n * - unavailableTimeout - time to transition to unavailable state\n * - activityTimeout - time after which ping message should be sent\n * - pongTimeout - time for Pusher to respond with pong before reconnecting\n *\n * @param {String} key application key\n * @param {Object} options\n */\nexport default class ConnectionManager extends EventsDispatcher {\n key: string;\n options: ConnectionManagerOptions;\n state: string;\n connection: Connection;\n usingTLS: boolean;\n timeline: Timeline;\n socket_id: string;\n unavailableTimer: Timer;\n activityTimer: Timer;\n retryTimer: Timer;\n activityTimeout: number;\n strategy: Strategy;\n runner: StrategyRunner;\n errorCallbacks: ErrorCallbacks;\n handshakeCallbacks: HandshakeCallbacks;\n connectionCallbacks: ConnectionCallbacks;\n\n constructor(key: string, options: ConnectionManagerOptions) {\n super();\n this.state = 'initialized';\n this.connection = null;\n\n this.key = key;\n this.options = options;\n this.timeline = this.options.timeline;\n this.usingTLS = this.options.useTLS;\n\n this.errorCallbacks = this.buildErrorCallbacks();\n this.connectionCallbacks = this.buildConnectionCallbacks(\n this.errorCallbacks\n );\n this.handshakeCallbacks = this.buildHandshakeCallbacks(this.errorCallbacks);\n\n var Network = Runtime.getNetwork();\n\n Network.bind('online', () => {\n this.timeline.info({ netinfo: 'online' });\n if (this.state === 'connecting' || this.state === 'unavailable') {\n this.retryIn(0);\n }\n });\n Network.bind('offline', () => {\n this.timeline.info({ netinfo: 'offline' });\n if (this.connection) {\n this.sendActivityCheck();\n }\n });\n\n this.updateStrategy();\n }\n\n switchCluster(key: string) {\n this.key = key;\n // This ensures that the new config coming from\n // pusher instance are taken into account\n // such as appKey and cluster\n this.updateStrategy();\n this.retryIn(0);\n }\n\n /** Establishes a connection to Pusher.\n *\n * Does nothing when connection is already established. See top-level doc\n * to find events emitted on connection attempts.\n */\n connect() {\n if (this.connection || this.runner) {\n return;\n }\n if (!this.strategy.isSupported()) {\n this.updateState('failed');\n return;\n }\n this.updateState('connecting');\n this.startConnecting();\n this.setUnavailableTimer();\n }\n\n /** Sends raw data.\n *\n * @param {String} data\n */\n send(data) {\n if (this.connection) {\n return this.connection.send(data);\n } else {\n return false;\n }\n }\n\n /** Sends an event.\n *\n * @param {String} name\n * @param {String} data\n * @param {String} [channel]\n * @returns {Boolean} whether message was sent or not\n */\n send_event(name: string, data: any, channel?: string) {\n if (this.connection) {\n return this.connection.send_event(name, data, channel);\n } else {\n return false;\n }\n }\n\n /** Closes the connection. */\n disconnect() {\n this.disconnectInternally();\n this.updateState('disconnected');\n }\n\n isUsingTLS() {\n return this.usingTLS;\n }\n\n private startConnecting() {\n var callback = (error, handshake) => {\n if (error) {\n this.runner = this.strategy.connect(0, callback);\n } else {\n if (handshake.action === 'error') {\n this.emit('error', {\n type: 'HandshakeError',\n error: handshake.error\n });\n this.timeline.error({ handshakeError: handshake.error });\n } else {\n this.abortConnecting(); // we don't support switching connections yet\n this.handshakeCallbacks[handshake.action](handshake);\n }\n }\n };\n this.runner = this.strategy.connect(0, callback);\n }\n\n private abortConnecting() {\n if (this.runner) {\n this.runner.abort();\n this.runner = null;\n }\n }\n\n private disconnectInternally() {\n this.abortConnecting();\n this.clearRetryTimer();\n this.clearUnavailableTimer();\n if (this.connection) {\n var connection = this.abandonConnection();\n connection.close();\n }\n }\n\n private updateStrategy() {\n this.strategy = this.options.getStrategy({\n key: this.key,\n timeline: this.timeline,\n useTLS: this.usingTLS\n });\n }\n\n private retryIn(delay) {\n this.timeline.info({ action: 'retry', delay: delay });\n if (delay > 0) {\n this.emit('connecting_in', Math.round(delay / 1000));\n }\n this.retryTimer = new Timer(delay || 0, () => {\n this.disconnectInternally();\n this.connect();\n });\n }\n\n private clearRetryTimer() {\n if (this.retryTimer) {\n this.retryTimer.ensureAborted();\n this.retryTimer = null;\n }\n }\n\n private setUnavailableTimer() {\n this.unavailableTimer = new Timer(this.options.unavailableTimeout, () => {\n this.updateState('unavailable');\n });\n }\n\n private clearUnavailableTimer() {\n if (this.unavailableTimer) {\n this.unavailableTimer.ensureAborted();\n }\n }\n\n private sendActivityCheck() {\n this.stopActivityCheck();\n this.connection.ping();\n // wait for pong response\n this.activityTimer = new Timer(this.options.pongTimeout, () => {\n this.timeline.error({ pong_timed_out: this.options.pongTimeout });\n this.retryIn(0);\n });\n }\n\n private resetActivityCheck() {\n this.stopActivityCheck();\n // send ping after inactivity\n if (this.connection && !this.connection.handlesActivityChecks()) {\n this.activityTimer = new Timer(this.activityTimeout, () => {\n this.sendActivityCheck();\n });\n }\n }\n\n private stopActivityCheck() {\n if (this.activityTimer) {\n this.activityTimer.ensureAborted();\n }\n }\n\n private buildConnectionCallbacks(\n errorCallbacks: ErrorCallbacks\n ): ConnectionCallbacks {\n return Collections.extend({}, errorCallbacks, {\n message: message => {\n // includes pong messages from server\n this.resetActivityCheck();\n this.emit('message', message);\n },\n ping: () => {\n this.send_event('pusher:pong', {});\n },\n activity: () => {\n this.resetActivityCheck();\n },\n error: error => {\n // just emit error to user - socket will already be closed by browser\n this.emit('error', error);\n },\n closed: () => {\n this.abandonConnection();\n if (this.shouldRetry()) {\n this.retryIn(1000);\n }\n }\n });\n }\n\n private buildHandshakeCallbacks(\n errorCallbacks: ErrorCallbacks\n ): HandshakeCallbacks {\n return Collections.extend({}, errorCallbacks, {\n connected: (handshake: HandshakePayload) => {\n this.activityTimeout = Math.min(\n this.options.activityTimeout,\n handshake.activityTimeout,\n handshake.connection.activityTimeout || Infinity\n );\n this.clearUnavailableTimer();\n this.setConnection(handshake.connection);\n this.socket_id = this.connection.id;\n this.updateState('connected', { socket_id: this.socket_id });\n }\n });\n }\n\n private buildErrorCallbacks(): ErrorCallbacks {\n let withErrorEmitted = callback => {\n return (result: Action | HandshakePayload) => {\n if (result.error) {\n this.emit('error', { type: 'WebSocketError', error: result.error });\n }\n callback(result);\n };\n };\n\n return {\n tls_only: withErrorEmitted(() => {\n this.usingTLS = true;\n this.updateStrategy();\n this.retryIn(0);\n }),\n refused: withErrorEmitted(() => {\n this.disconnect();\n }),\n backoff: withErrorEmitted(() => {\n this.retryIn(1000);\n }),\n retry: withErrorEmitted(() => {\n this.retryIn(0);\n })\n };\n }\n\n private setConnection(connection) {\n this.connection = connection;\n for (var event in this.connectionCallbacks) {\n this.connection.bind(event, this.connectionCallbacks[event]);\n }\n this.resetActivityCheck();\n }\n\n private abandonConnection() {\n if (!this.connection) {\n return;\n }\n this.stopActivityCheck();\n for (var event in this.connectionCallbacks) {\n this.connection.unbind(event, this.connectionCallbacks[event]);\n }\n var connection = this.connection;\n this.connection = null;\n return connection;\n }\n\n private updateState(newState: string, data?: any) {\n var previousState = this.state;\n this.state = newState;\n if (previousState !== newState) {\n var newStateDescription = newState;\n if (newStateDescription === 'connected') {\n newStateDescription += ' with new socket ID ' + data.socket_id;\n }\n Logger.debug(\n 'State changed',\n previousState + ' -> ' + newStateDescription\n );\n this.timeline.info({ state: newState, params: data });\n this.emit('state_change', { previous: previousState, current: newState });\n this.emit(newState, data);\n }\n }\n\n private shouldRetry(): boolean {\n return this.state === 'connecting' || this.state === 'connected';\n }\n}\n","import Channel from './channel';\nimport * as Collections from '../utils/collections';\nimport ChannelTable from './channel_table';\nimport Factory from '../utils/factory';\nimport Pusher from '../pusher';\nimport Logger from '../logger';\nimport * as Errors from '../errors';\nimport urlStore from '../utils/url_store';\n\n/** Handles a channel map. */\nexport default class Channels {\n channels: ChannelTable;\n\n constructor() {\n this.channels = {};\n }\n\n /** Creates or retrieves an existing channel by its name.\n *\n * @param {String} name\n * @param {Pusher} pusher\n * @return {Channel}\n */\n add(name: string, pusher: Pusher) {\n if (!this.channels[name]) {\n this.channels[name] = createChannel(name, pusher);\n }\n return this.channels[name];\n }\n\n /** Returns a list of all channels\n *\n * @return {Array}\n */\n all(): Channel[] {\n return Collections.values(this.channels);\n }\n\n /** Finds a channel by its name.\n *\n * @param {String} name\n * @return {Channel} channel or null if it doesn't exist\n */\n find(name: string) {\n return this.channels[name];\n }\n\n /** Removes a channel from the map.\n *\n * @param {String} name\n */\n remove(name: string) {\n var channel = this.channels[name];\n delete this.channels[name];\n return channel;\n }\n\n /** Proxies disconnection signal to all channels. */\n disconnect() {\n Collections.objectApply(this.channels, function(channel) {\n channel.disconnect();\n });\n }\n}\n\nfunction createChannel(name: string, pusher: Pusher): Channel {\n if (name.indexOf('private-encrypted-') === 0) {\n if (pusher.config.nacl) {\n return Factory.createEncryptedChannel(name, pusher, pusher.config.nacl);\n }\n let errMsg =\n 'Tried to subscribe to a private-encrypted- channel but no nacl implementation available';\n let suffix = urlStore.buildLogSuffix('encryptedChannelSupport');\n throw new Errors.UnsupportedFeature(`${errMsg}. ${suffix}`);\n } else if (name.indexOf('private-') === 0) {\n return Factory.createPrivateChannel(name, pusher);\n } else if (name.indexOf('presence-') === 0) {\n return Factory.createPresenceChannel(name, pusher);\n } else if (name.indexOf('#') === 0) {\n throw new Errors.BadChannelName(\n 'Cannot create a channel with name \"' + name + '\".'\n );\n } else {\n return Factory.createChannel(name, pusher);\n }\n}\n","import AssistantToTheTransportManager from '../transports/assistant_to_the_transport_manager';\nimport PingDelayOptions from '../transports/ping_delay_options';\nimport Transport from '../transports/transport';\nimport TransportManager from '../transports/transport_manager';\nimport Handshake from '../connection/handshake';\nimport TransportConnection from '../transports/transport_connection';\nimport SocketHooks from '../http/socket_hooks';\nimport HTTPSocket from '../http/http_socket';\n\nimport Timeline from '../timeline/timeline';\nimport {\n default as TimelineSender,\n TimelineSenderOptions\n} from '../timeline/timeline_sender';\nimport PresenceChannel from '../channels/presence_channel';\nimport PrivateChannel from '../channels/private_channel';\nimport EncryptedChannel from '../channels/encrypted_channel';\nimport Channel from '../channels/channel';\nimport ConnectionManager from '../connection/connection_manager';\nimport ConnectionManagerOptions from '../connection/connection_manager_options';\nimport Ajax from '../http/ajax';\nimport Channels from '../channels/channels';\nimport Pusher from '../pusher';\nimport { Config } from '../config';\nimport * as nacl from 'tweetnacl';\n\nvar Factory = {\n createChannels(): Channels {\n return new Channels();\n },\n\n createConnectionManager(\n key: string,\n options: ConnectionManagerOptions\n ): ConnectionManager {\n return new ConnectionManager(key, options);\n },\n\n createChannel(name: string, pusher: Pusher): Channel {\n return new Channel(name, pusher);\n },\n\n createPrivateChannel(name: string, pusher: Pusher): PrivateChannel {\n return new PrivateChannel(name, pusher);\n },\n\n createPresenceChannel(name: string, pusher: Pusher): PresenceChannel {\n return new PresenceChannel(name, pusher);\n },\n\n createEncryptedChannel(\n name: string,\n pusher: Pusher,\n nacl: nacl\n ): EncryptedChannel {\n return new EncryptedChannel(name, pusher, nacl);\n },\n\n createTimelineSender(timeline: Timeline, options: TimelineSenderOptions) {\n return new TimelineSender(timeline, options);\n },\n\n createHandshake(\n transport: TransportConnection,\n callback: (HandshakePayload) => void\n ): Handshake {\n return new Handshake(transport, callback);\n },\n\n createAssistantToTheTransportManager(\n manager: TransportManager,\n transport: Transport,\n options: PingDelayOptions\n ): AssistantToTheTransportManager {\n return new AssistantToTheTransportManager(manager, transport, options);\n }\n};\n\nexport default Factory;\n","import AssistantToTheTransportManager from './assistant_to_the_transport_manager';\nimport Transport from './transport';\nimport PingDelayOptions from './ping_delay_options';\nimport Factory from '../utils/factory';\n\nexport interface TransportManagerOptions extends PingDelayOptions {\n lives?: number;\n}\n\n/** Keeps track of the number of lives left for a transport.\n *\n * In the beginning of a session, transports may be assigned a number of\n * lives. When an AssistantToTheTransportManager instance reports a transport\n * connection closed uncleanly, the transport loses a life. When the number\n * of lives drops to zero, the transport gets disabled by its manager.\n *\n * @param {Object} options\n */\nexport default class TransportManager {\n options: TransportManagerOptions;\n livesLeft: number;\n\n constructor(options: TransportManagerOptions) {\n this.options = options || {};\n this.livesLeft = this.options.lives || Infinity;\n }\n\n /** Creates a assistant for the transport.\n *\n * @param {Transport} transport\n * @returns {AssistantToTheTransportManager}\n */\n getAssistant(transport: Transport): AssistantToTheTransportManager {\n return Factory.createAssistantToTheTransportManager(this, transport, {\n minPingDelay: this.options.minPingDelay,\n maxPingDelay: this.options.maxPingDelay\n });\n }\n\n /** Returns whether the transport has any lives left.\n *\n * @returns {Boolean}\n */\n isAlive(): boolean {\n return this.livesLeft > 0;\n }\n\n /** Takes one life from the transport. */\n reportDeath() {\n this.livesLeft -= 1;\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport { OneOffTimer as Timer } from '../utils/timers';\nimport Strategy from './strategy';\nimport StrategyOptions from './strategy_options';\n\n/** Loops through strategies with optional timeouts.\n *\n * Options:\n * - loop - whether it should loop through the substrategy list\n * - timeout - initial timeout for a single substrategy\n * - timeoutLimit - maximum timeout\n *\n * @param {Strategy[]} strategies\n * @param {Object} options\n */\nexport default class SequentialStrategy implements Strategy {\n strategies: Strategy[];\n loop: boolean;\n failFast: boolean;\n timeout: number;\n timeoutLimit: number;\n\n constructor(strategies: Strategy[], options: StrategyOptions) {\n this.strategies = strategies;\n this.loop = Boolean(options.loop);\n this.failFast = Boolean(options.failFast);\n this.timeout = options.timeout;\n this.timeoutLimit = options.timeoutLimit;\n }\n\n isSupported(): boolean {\n return Collections.any(this.strategies, Util.method('isSupported'));\n }\n\n connect(minPriority: number, callback: Function) {\n var strategies = this.strategies;\n var current = 0;\n var timeout = this.timeout;\n var runner = null;\n\n var tryNextStrategy = (error, handshake) => {\n if (handshake) {\n callback(null, handshake);\n } else {\n current = current + 1;\n if (this.loop) {\n current = current % strategies.length;\n }\n\n if (current < strategies.length) {\n if (timeout) {\n timeout = timeout * 2;\n if (this.timeoutLimit) {\n timeout = Math.min(timeout, this.timeoutLimit);\n }\n }\n runner = this.tryStrategy(\n strategies[current],\n minPriority,\n { timeout, failFast: this.failFast },\n tryNextStrategy\n );\n } else {\n callback(true);\n }\n }\n };\n\n runner = this.tryStrategy(\n strategies[current],\n minPriority,\n { timeout: timeout, failFast: this.failFast },\n tryNextStrategy\n );\n\n return {\n abort: function() {\n runner.abort();\n },\n forceMinPriority: function(p) {\n minPriority = p;\n if (runner) {\n runner.forceMinPriority(p);\n }\n }\n };\n }\n\n private tryStrategy(\n strategy: Strategy,\n minPriority: number,\n options: StrategyOptions,\n callback: Function\n ) {\n var timer = null;\n var runner = null;\n\n if (options.timeout > 0) {\n timer = new Timer(options.timeout, function() {\n runner.abort();\n callback(true);\n });\n }\n\n runner = strategy.connect(minPriority, function(error, handshake) {\n if (error && timer && timer.isRunning() && !options.failFast) {\n // advance to the next strategy after the timeout\n return;\n }\n if (timer) {\n timer.ensureAborted();\n }\n callback(error, handshake);\n });\n\n return {\n abort: function() {\n if (timer) {\n timer.ensureAborted();\n }\n runner.abort();\n },\n forceMinPriority: function(p) {\n runner.forceMinPriority(p);\n }\n };\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport Strategy from './strategy';\n\n/** Launches all substrategies and emits prioritized connected transports.\n *\n * @param {Array} strategies\n */\nexport default class BestConnectedEverStrategy implements Strategy {\n strategies: Strategy[];\n\n constructor(strategies: Strategy[]) {\n this.strategies = strategies;\n }\n\n isSupported(): boolean {\n return Collections.any(this.strategies, Util.method('isSupported'));\n }\n\n connect(minPriority: number, callback: Function) {\n return connect(this.strategies, minPriority, function(i, runners) {\n return function(error, handshake) {\n runners[i].error = error;\n if (error) {\n if (allRunnersFailed(runners)) {\n callback(true);\n }\n return;\n }\n Collections.apply(runners, function(runner) {\n runner.forceMinPriority(handshake.transport.priority);\n });\n callback(null, handshake);\n };\n });\n }\n}\n\n/** Connects to all strategies in parallel.\n *\n * Callback builder should be a function that takes two arguments: index\n * and a list of runners. It should return another function that will be\n * passed to the substrategy with given index. Runners can be aborted using\n * abortRunner(s) functions from this class.\n *\n * @param {Array} strategies\n * @param {Function} callbackBuilder\n * @return {Object} strategy runner\n */\nfunction connect(\n strategies: Strategy[],\n minPriority: number,\n callbackBuilder: Function\n) {\n var runners = Collections.map(strategies, function(strategy, i, _, rs) {\n return strategy.connect(minPriority, callbackBuilder(i, rs));\n });\n return {\n abort: function() {\n Collections.apply(runners, abortRunner);\n },\n forceMinPriority: function(p) {\n Collections.apply(runners, function(runner) {\n runner.forceMinPriority(p);\n });\n }\n };\n}\n\nfunction allRunnersFailed(runners): boolean {\n return Collections.all(runners, function(runner) {\n return Boolean(runner.error);\n });\n}\n\nfunction abortRunner(runner) {\n if (!runner.error && !runner.aborted) {\n runner.abort();\n runner.aborted = true;\n }\n}\n","import Util from '../util';\nimport Runtime from 'runtime';\nimport Strategy from './strategy';\nimport SequentialStrategy from './sequential_strategy';\nimport StrategyOptions from './strategy_options';\nimport TransportStrategy from './transport_strategy';\nimport Timeline from '../timeline/timeline';\nimport * as Collections from '../utils/collections';\n\nexport interface TransportStrategyDictionary {\n [key: string]: TransportStrategy;\n}\n\n/** Caches the last successful transport and, after the first few attempts,\n * uses the cached transport for subsequent attempts.\n *\n * @param {Strategy} strategy\n * @param {Object} transports\n * @param {Object} options\n */\nexport default class WebSocketPrioritizedCachedStrategy implements Strategy {\n strategy: Strategy;\n transports: TransportStrategyDictionary;\n ttl: number;\n usingTLS: boolean;\n timeline: Timeline;\n\n constructor(\n strategy: Strategy,\n transports: TransportStrategyDictionary,\n options: StrategyOptions\n ) {\n this.strategy = strategy;\n this.transports = transports;\n this.ttl = options.ttl || 1800 * 1000;\n this.usingTLS = options.useTLS;\n this.timeline = options.timeline;\n }\n\n isSupported(): boolean {\n return this.strategy.isSupported();\n }\n\n connect(minPriority: number, callback: Function) {\n var usingTLS = this.usingTLS;\n var info = fetchTransportCache(usingTLS);\n var cacheSkipCount = info && info.cacheSkipCount ? info.cacheSkipCount : 0;\n\n var strategies = [this.strategy];\n if (info && info.timestamp + this.ttl >= Util.now()) {\n var transport = this.transports[info.transport];\n if (transport) {\n if (['ws', 'wss'].includes(info.transport) || cacheSkipCount > 3) {\n this.timeline.info({\n cached: true,\n transport: info.transport,\n latency: info.latency\n });\n strategies.push(\n new SequentialStrategy([transport], {\n timeout: info.latency * 2 + 1000,\n failFast: true\n })\n );\n } else {\n cacheSkipCount++;\n }\n }\n }\n\n var startTimestamp = Util.now();\n var runner = strategies\n .pop()\n .connect(minPriority, function cb(error, handshake) {\n if (error) {\n flushTransportCache(usingTLS);\n if (strategies.length > 0) {\n startTimestamp = Util.now();\n runner = strategies.pop().connect(minPriority, cb);\n } else {\n callback(error);\n }\n } else {\n storeTransportCache(\n usingTLS,\n handshake.transport.name,\n Util.now() - startTimestamp,\n cacheSkipCount\n );\n callback(null, handshake);\n }\n });\n\n return {\n abort: function() {\n runner.abort();\n },\n forceMinPriority: function(p) {\n minPriority = p;\n if (runner) {\n runner.forceMinPriority(p);\n }\n }\n };\n }\n}\n\nfunction getTransportCacheKey(usingTLS: boolean): string {\n return 'pusherTransport' + (usingTLS ? 'TLS' : 'NonTLS');\n}\n\nfunction fetchTransportCache(usingTLS: boolean): any {\n var storage = Runtime.getLocalStorage();\n if (storage) {\n try {\n var serializedCache = storage[getTransportCacheKey(usingTLS)];\n if (serializedCache) {\n return JSON.parse(serializedCache);\n }\n } catch (e) {\n flushTransportCache(usingTLS);\n }\n }\n return null;\n}\n\nfunction storeTransportCache(\n usingTLS: boolean,\n transport: TransportStrategy,\n latency: number,\n cacheSkipCount: number\n) {\n var storage = Runtime.getLocalStorage();\n if (storage) {\n try {\n storage[getTransportCacheKey(usingTLS)] = Collections.safeJSONStringify({\n timestamp: Util.now(),\n transport: transport,\n latency: latency,\n cacheSkipCount: cacheSkipCount\n });\n } catch (e) {\n // catch over quota exceptions raised by localStorage\n }\n }\n}\n\nfunction flushTransportCache(usingTLS: boolean) {\n var storage = Runtime.getLocalStorage();\n if (storage) {\n try {\n delete storage[getTransportCacheKey(usingTLS)];\n } catch (e) {\n // catch exceptions raised by localStorage\n }\n }\n}\n","import { OneOffTimer as Timer } from '../utils/timers';\nimport Strategy from './strategy';\nimport StrategyOptions from './strategy_options';\n\n/** Runs substrategy after specified delay.\n *\n * Options:\n * - delay - time in miliseconds to delay the substrategy attempt\n *\n * @param {Strategy} strategy\n * @param {Object} options\n */\nexport default class DelayedStrategy implements Strategy {\n strategy: Strategy;\n options: { delay: number };\n\n constructor(strategy: Strategy, { delay: number }) {\n this.strategy = strategy;\n this.options = { delay: number };\n }\n\n isSupported(): boolean {\n return this.strategy.isSupported();\n }\n\n connect(minPriority: number, callback: Function) {\n var strategy = this.strategy;\n var runner;\n var timer = new Timer(this.options.delay, function() {\n runner = strategy.connect(minPriority, callback);\n });\n\n return {\n abort: function() {\n timer.ensureAborted();\n if (runner) {\n runner.abort();\n }\n },\n forceMinPriority: function(p) {\n minPriority = p;\n if (runner) {\n runner.forceMinPriority(p);\n }\n }\n };\n }\n}\n","import Strategy from './strategy';\nimport StrategyRunner from './strategy_runner';\n\n/** Proxies method calls to one of substrategies basing on the test function.\n *\n * @param {Function} test\n * @param {Strategy} trueBranch strategy used when test returns true\n * @param {Strategy} falseBranch strategy used when test returns false\n */\nexport default class IfStrategy implements Strategy {\n test: () => boolean;\n trueBranch: Strategy;\n falseBranch: Strategy;\n\n constructor(\n test: () => boolean,\n trueBranch: Strategy,\n falseBranch: Strategy\n ) {\n this.test = test;\n this.trueBranch = trueBranch;\n this.falseBranch = falseBranch;\n }\n\n isSupported(): boolean {\n var branch = this.test() ? this.trueBranch : this.falseBranch;\n return branch.isSupported();\n }\n\n connect(minPriority: number, callback: Function): StrategyRunner {\n var branch = this.test() ? this.trueBranch : this.falseBranch;\n return branch.connect(minPriority, callback);\n }\n}\n","import Strategy from './strategy';\nimport StrategyRunner from './strategy_runner';\n\n/** Launches the substrategy and terminates on the first open connection.\n *\n * @param {Strategy} strategy\n */\nexport default class FirstConnectedStrategy implements Strategy {\n strategy: Strategy;\n\n constructor(strategy: Strategy) {\n this.strategy = strategy;\n }\n\n isSupported(): boolean {\n return this.strategy.isSupported();\n }\n\n connect(minPriority: number, callback: Function): StrategyRunner {\n var runner = this.strategy.connect(minPriority, function(error, handshake) {\n if (handshake) {\n runner.abort();\n }\n callback(error, handshake);\n });\n return runner;\n }\n}\n","import * as Collections from 'core/utils/collections';\nimport TransportManager from 'core/transports/transport_manager';\nimport Strategy from 'core/strategies/strategy';\nimport SequentialStrategy from 'core/strategies/sequential_strategy';\nimport BestConnectedEverStrategy from 'core/strategies/best_connected_ever_strategy';\nimport WebSocketPrioritizedCachedStrategy, {\n TransportStrategyDictionary\n} from 'core/strategies/websocket_prioritized_cached_strategy';\nimport DelayedStrategy from 'core/strategies/delayed_strategy';\nimport IfStrategy from 'core/strategies/if_strategy';\nimport FirstConnectedStrategy from 'core/strategies/first_connected_strategy';\nimport { Config } from 'core/config';\nimport StrategyOptions from 'core/strategies/strategy_options';\n\nfunction testSupportsStrategy(strategy: Strategy) {\n return function() {\n return strategy.isSupported();\n };\n}\n\nvar getDefaultStrategy = function(\n config: Config,\n baseOptions: StrategyOptions,\n defineTransport: Function\n): Strategy {\n var definedTransports = {};\n\n function defineTransportStrategy(\n name: string,\n type: string,\n priority: number,\n options: StrategyOptions,\n manager?: TransportManager\n ) {\n var transport = defineTransport(\n config,\n name,\n type,\n priority,\n options,\n manager\n );\n\n definedTransports[name] = transport;\n\n return transport;\n }\n\n var ws_options: StrategyOptions = Object.assign({}, baseOptions, {\n hostNonTLS: config.wsHost + ':' + config.wsPort,\n hostTLS: config.wsHost + ':' + config.wssPort,\n httpPath: config.wsPath\n });\n var wss_options: StrategyOptions = Collections.extend({}, ws_options, {\n useTLS: true\n });\n var http_options: StrategyOptions = Object.assign({}, baseOptions, {\n hostNonTLS: config.httpHost + ':' + config.httpPort,\n hostTLS: config.httpHost + ':' + config.httpsPort,\n httpPath: config.httpPath\n });\n var timeouts = {\n loop: true,\n timeout: 15000,\n timeoutLimit: 60000\n };\n\n var ws_manager = new TransportManager({\n minPingDelay: 10000,\n maxPingDelay: config.activityTimeout\n });\n var streaming_manager = new TransportManager({\n lives: 2,\n minPingDelay: 10000,\n maxPingDelay: config.activityTimeout\n });\n\n var ws_transport = defineTransportStrategy(\n 'ws',\n 'ws',\n 3,\n ws_options,\n ws_manager\n );\n var wss_transport = defineTransportStrategy(\n 'wss',\n 'ws',\n 3,\n wss_options,\n ws_manager\n );\n var xhr_streaming_transport = defineTransportStrategy(\n 'xhr_streaming',\n 'xhr_streaming',\n 1,\n http_options,\n streaming_manager\n );\n var xhr_polling_transport = defineTransportStrategy(\n 'xhr_polling',\n 'xhr_polling',\n 1,\n http_options\n );\n\n var ws_loop = new SequentialStrategy([ws_transport], timeouts);\n var wss_loop = new SequentialStrategy([wss_transport], timeouts);\n var streaming_loop = new SequentialStrategy(\n [xhr_streaming_transport],\n timeouts\n );\n var polling_loop = new SequentialStrategy([xhr_polling_transport], timeouts);\n\n var http_loop = new SequentialStrategy(\n [\n new IfStrategy(\n testSupportsStrategy(streaming_loop),\n new BestConnectedEverStrategy([\n streaming_loop,\n new DelayedStrategy(polling_loop, { delay: 4000 })\n ]),\n polling_loop\n )\n ],\n timeouts\n );\n\n var wsStrategy;\n if (baseOptions.useTLS) {\n wsStrategy = new BestConnectedEverStrategy([\n ws_loop,\n new DelayedStrategy(http_loop, { delay: 2000 })\n ]);\n } else {\n wsStrategy = new BestConnectedEverStrategy([\n ws_loop,\n new DelayedStrategy(wss_loop, { delay: 2000 }),\n new DelayedStrategy(http_loop, { delay: 5000 })\n ]);\n }\n\n return new WebSocketPrioritizedCachedStrategy(\n new FirstConnectedStrategy(\n new IfStrategy(testSupportsStrategy(ws_transport), wsStrategy, http_loop)\n ),\n definedTransports,\n {\n ttl: 1800000,\n timeline: baseOptions.timeline,\n useTLS: baseOptions.useTLS\n }\n );\n};\n\nexport default getDefaultStrategy;\n","/** Initializes the transport.\n *\n * Fetches resources if needed and then transitions to initialized.\n */\nexport default function() {\n var self = this;\n\n self.timeline.info(\n self.buildTimelineMessage({\n transport: self.name + (self.options.useTLS ? 's' : '')\n })\n );\n\n if (self.hooks.isInitialized()) {\n self.changeState('initialized');\n } else {\n self.onClose();\n }\n}\n","import Runtime from 'runtime';\nimport RequestHooks from './request_hooks';\nimport Ajax from './ajax';\nimport { default as EventsDispatcher } from '../events/dispatcher';\n\nconst MAX_BUFFER_LENGTH = 256 * 1024;\n\nexport default class HTTPRequest extends EventsDispatcher {\n hooks: RequestHooks;\n method: string;\n url: string;\n position: number;\n xhr: Ajax;\n unloader: Function;\n\n constructor(hooks: RequestHooks, method: string, url: string) {\n super();\n this.hooks = hooks;\n this.method = method;\n this.url = url;\n }\n\n start(payload?: any) {\n this.position = 0;\n this.xhr = this.hooks.getRequest(this);\n\n this.unloader = () => {\n this.close();\n };\n Runtime.addUnloadListener(this.unloader);\n\n this.xhr.open(this.method, this.url, true);\n\n if (this.xhr.setRequestHeader) {\n this.xhr.setRequestHeader('Content-Type', 'application/json'); // ReactNative doesn't set this header by default.\n }\n this.xhr.send(payload);\n }\n\n close() {\n if (this.unloader) {\n Runtime.removeUnloadListener(this.unloader);\n this.unloader = null;\n }\n if (this.xhr) {\n this.hooks.abortRequest(this.xhr);\n this.xhr = null;\n }\n }\n\n onChunk(status: number, data: any) {\n while (true) {\n var chunk = this.advanceBuffer(data);\n if (chunk) {\n this.emit('chunk', { status: status, data: chunk });\n } else {\n break;\n }\n }\n if (this.isBufferTooLong(data)) {\n this.emit('buffer_too_long');\n }\n }\n\n private advanceBuffer(buffer: any[]): any {\n var unreadData = buffer.slice(this.position);\n var endOfLinePosition = unreadData.indexOf('\\n');\n\n if (endOfLinePosition !== -1) {\n this.position += endOfLinePosition + 1;\n return unreadData.slice(0, endOfLinePosition);\n } else {\n // chunk is not finished yet, don't move the buffer pointer\n return null;\n }\n }\n\n private isBufferTooLong(buffer: any): boolean {\n return this.position === buffer.length && buffer.length > MAX_BUFFER_LENGTH;\n }\n}\n","enum State {\n CONNECTING = 0,\n OPEN = 1,\n CLOSED = 3\n}\n\nexport default State;\n","import URLLocation from './url_location';\nimport State from './state';\nimport Socket from '../socket';\nimport SocketHooks from './socket_hooks';\nimport Util from '../util';\nimport Ajax from './ajax';\nimport HTTPRequest from './http_request';\nimport Runtime from 'runtime';\n\nvar autoIncrement = 1;\n\nclass HTTPSocket implements Socket {\n hooks: SocketHooks;\n session: string;\n location: URLLocation;\n readyState: State;\n stream: HTTPRequest;\n\n onopen: () => void;\n onerror: (error: any) => void;\n onclose: (closeEvent: any) => void;\n onmessage: (message: any) => void;\n onactivity: () => void;\n\n constructor(hooks: SocketHooks, url: string) {\n this.hooks = hooks;\n this.session = randomNumber(1000) + '/' + randomString(8);\n this.location = getLocation(url);\n this.readyState = State.CONNECTING;\n this.openStream();\n }\n\n send(payload: any) {\n return this.sendRaw(JSON.stringify([payload]));\n }\n\n ping() {\n this.hooks.sendHeartbeat(this);\n }\n\n close(code: any, reason: any) {\n this.onClose(code, reason, true);\n }\n\n /** For internal use only */\n sendRaw(payload: any): boolean {\n if (this.readyState === State.OPEN) {\n try {\n Runtime.createSocketRequest(\n 'POST',\n getUniqueURL(getSendURL(this.location, this.session))\n ).start(payload);\n return true;\n } catch (e) {\n return false;\n }\n } else {\n return false;\n }\n }\n\n /** For internal use only */\n reconnect() {\n this.closeStream();\n this.openStream();\n }\n\n /** For internal use only */\n onClose(code, reason, wasClean) {\n this.closeStream();\n this.readyState = State.CLOSED;\n if (this.onclose) {\n this.onclose({\n code: code,\n reason: reason,\n wasClean: wasClean\n });\n }\n }\n\n private onChunk(chunk) {\n if (chunk.status !== 200) {\n return;\n }\n if (this.readyState === State.OPEN) {\n this.onActivity();\n }\n\n var payload;\n var type = chunk.data.slice(0, 1);\n switch (type) {\n case 'o':\n payload = JSON.parse(chunk.data.slice(1) || '{}');\n this.onOpen(payload);\n break;\n case 'a':\n payload = JSON.parse(chunk.data.slice(1) || '[]');\n for (var i = 0; i < payload.length; i++) {\n this.onEvent(payload[i]);\n }\n break;\n case 'm':\n payload = JSON.parse(chunk.data.slice(1) || 'null');\n this.onEvent(payload);\n break;\n case 'h':\n this.hooks.onHeartbeat(this);\n break;\n case 'c':\n payload = JSON.parse(chunk.data.slice(1) || '[]');\n this.onClose(payload[0], payload[1], true);\n break;\n }\n }\n\n private onOpen(options) {\n if (this.readyState === State.CONNECTING) {\n if (options && options.hostname) {\n this.location.base = replaceHost(this.location.base, options.hostname);\n }\n this.readyState = State.OPEN;\n\n if (this.onopen) {\n this.onopen();\n }\n } else {\n this.onClose(1006, 'Server lost session', true);\n }\n }\n\n private onEvent(event) {\n if (this.readyState === State.OPEN && this.onmessage) {\n this.onmessage({ data: event });\n }\n }\n\n private onActivity() {\n if (this.onactivity) {\n this.onactivity();\n }\n }\n\n private onError(error) {\n if (this.onerror) {\n this.onerror(error);\n }\n }\n\n private openStream() {\n this.stream = Runtime.createSocketRequest(\n 'POST',\n getUniqueURL(this.hooks.getReceiveURL(this.location, this.session))\n );\n\n this.stream.bind('chunk', chunk => {\n this.onChunk(chunk);\n });\n this.stream.bind('finished', status => {\n this.hooks.onFinished(this, status);\n });\n this.stream.bind('buffer_too_long', () => {\n this.reconnect();\n });\n\n try {\n this.stream.start();\n } catch (error) {\n Util.defer(() => {\n this.onError(error);\n this.onClose(1006, 'Could not start streaming', false);\n });\n }\n }\n\n private closeStream() {\n if (this.stream) {\n this.stream.unbind_all();\n this.stream.close();\n this.stream = null;\n }\n }\n}\n\nfunction getLocation(url): URLLocation {\n var parts = /([^\\?]*)\\/*(\\??.*)/.exec(url);\n return {\n base: parts[1],\n queryString: parts[2]\n };\n}\n\nfunction getSendURL(url: URLLocation, session: string): string {\n return url.base + '/' + session + '/xhr_send';\n}\n\nfunction getUniqueURL(url: string): string {\n var separator = url.indexOf('?') === -1 ? '?' : '&';\n return url + separator + 't=' + +new Date() + '&n=' + autoIncrement++;\n}\n\nfunction replaceHost(url: string, hostname: string): string {\n var urlParts = /(https?:\\/\\/)([^\\/:]+)((\\/|:)?.*)/.exec(url);\n return urlParts[1] + hostname + urlParts[3];\n}\n\nfunction randomNumber(max: number): number {\n return Runtime.randomInt(max);\n}\n\nfunction randomString(length: number): string {\n var result = [];\n\n for (var i = 0; i < length; i++) {\n result.push(randomNumber(32).toString(32));\n }\n\n return result.join('');\n}\n\nexport default HTTPSocket;\n","import SocketHooks from './socket_hooks';\nimport HTTPSocket from './http_socket';\n\nvar hooks: SocketHooks = {\n getReceiveURL: function(url, session) {\n return url.base + '/' + session + '/xhr_streaming' + url.queryString;\n },\n onHeartbeat: function(socket) {\n socket.sendRaw('[]');\n },\n sendHeartbeat: function(socket) {\n socket.sendRaw('[]');\n },\n onFinished: function(socket, status) {\n socket.onClose(1006, 'Connection interrupted (' + status + ')', false);\n }\n};\n\nexport default hooks;\n","import SocketHooks from './socket_hooks';\nimport URLLocation from './url_location';\nimport HTTPSocket from './http_socket';\n\nvar hooks: SocketHooks = {\n getReceiveURL: function(url: URLLocation, session: string): string {\n return url.base + '/' + session + '/xhr' + url.queryString;\n },\n onHeartbeat: function() {\n // next HTTP request will reset server's activity timer\n },\n sendHeartbeat: function(socket) {\n socket.sendRaw('[]');\n },\n onFinished: function(socket, status) {\n if (status === 200) {\n socket.reconnect();\n } else {\n socket.onClose(1006, 'Connection interrupted (' + status + ')', false);\n }\n }\n};\n\nexport default hooks;\n","import HTTPRequest from 'core/http/http_request';\nimport RequestHooks from 'core/http/request_hooks';\nimport Ajax from 'core/http/ajax';\nimport Runtime from 'runtime';\n\nvar hooks: RequestHooks = {\n getRequest: function(socket: HTTPRequest): Ajax {\n var Constructor = Runtime.getXHRAPI();\n var xhr = new Constructor();\n xhr.onreadystatechange = xhr.onprogress = function() {\n switch (xhr.readyState) {\n case 3:\n if (xhr.responseText && xhr.responseText.length > 0) {\n socket.onChunk(xhr.status, xhr.responseText);\n }\n break;\n case 4:\n // this happens only on errors, never after calling close\n if (xhr.responseText && xhr.responseText.length > 0) {\n socket.onChunk(xhr.status, xhr.responseText);\n }\n socket.emit('finished', xhr.status);\n socket.close();\n break;\n }\n };\n return xhr;\n },\n abortRequest: function(xhr: Ajax) {\n xhr.onreadystatechange = null;\n xhr.abort();\n }\n};\n\nexport default hooks;\n","import HTTPRequest from 'core/http/http_request';\nimport HTTPSocket from 'core/http/http_socket';\nimport SocketHooks from 'core/http/socket_hooks';\nimport RequestHooks from 'core/http/request_hooks';\nimport streamingHooks from 'core/http/http_streaming_socket';\nimport pollingHooks from 'core/http/http_polling_socket';\nimport xhrHooks from './http_xhr_request';\nimport HTTPFactory from 'core/http/http_factory';\n\nvar HTTP: HTTPFactory = {\n createStreamingSocket(url: string): HTTPSocket {\n return this.createSocket(streamingHooks, url);\n },\n\n createPollingSocket(url: string): HTTPSocket {\n return this.createSocket(pollingHooks, url);\n },\n\n createSocket(hooks: SocketHooks, url: string): HTTPSocket {\n return new HTTPSocket(hooks, url);\n },\n\n createXHR(method: string, url: string): HTTPRequest {\n return this.createRequest(xhrHooks, method, url);\n },\n\n createRequest(hooks: RequestHooks, method: string, url: string): HTTPRequest {\n return new HTTPRequest(hooks, method, url);\n }\n};\n\nexport default HTTP;\n","import * as Collections from 'core/utils/collections';\nimport Transports from 'isomorphic/transports/transports';\nimport TimelineSender from 'core/timeline/timeline_sender';\nimport Ajax from 'core/http/ajax';\nimport getDefaultStrategy from './default_strategy';\nimport TransportsTable from 'core/transports/transports_table';\nimport transportConnectionInitializer from './transports/transport_connection_initializer';\nimport HTTPFactory from './http/http';\n\nvar Isomorphic: any = {\n getDefaultStrategy,\n Transports: Transports,\n transportConnectionInitializer,\n HTTPFactory,\n\n setup(PusherClass): void {\n PusherClass.ready();\n },\n\n getLocalStorage(): any {\n return undefined;\n },\n\n getClientFeatures(): any[] {\n return Collections.keys(\n Collections.filterObject({ ws: Transports.ws }, function(t) {\n return t.isSupported({});\n })\n );\n },\n\n getProtocol(): string {\n return 'http:';\n },\n\n isXHRSupported(): boolean {\n return true;\n },\n\n createSocketRequest(method: string, url: string) {\n if (this.isXHRSupported()) {\n return this.HTTPFactory.createXHR(method, url);\n } else {\n throw 'Cross-origin HTTP requests are not supported';\n }\n },\n\n createXHR(): Ajax {\n var Constructor = this.getXHRAPI();\n return new Constructor();\n },\n\n createWebSocket(url: string): any {\n var Constructor = this.getWebSocketAPI();\n return new Constructor(url);\n },\n\n addUnloadListener(listener: any) {},\n removeUnloadListener(listener: any) {}\n};\n\nexport default Isomorphic;\n","import { default as EventsDispatcher } from 'core/events/dispatcher';\nimport Reachability from 'core/reachability';\n\nexport class NetInfo extends EventsDispatcher implements Reachability {\n isOnline(): boolean {\n return true;\n }\n}\n\nexport var Network = new NetInfo();\n","import AbstractRuntime from 'runtimes/interface';\nimport { AuthTransport } from 'core/auth/auth_transports';\nimport {\n AuthRequestType,\n AuthTransportCallback,\n InternalAuthOptions\n} from 'core/auth/options';\nimport { HTTPAuthError } from 'core/errors';\n\nvar fetchAuth: AuthTransport = function(\n context: AbstractRuntime,\n query: string,\n authOptions: InternalAuthOptions,\n authRequestType: AuthRequestType,\n callback: AuthTransportCallback\n) {\n var headers = new Headers();\n headers.set('Content-Type', 'application/x-www-form-urlencoded');\n\n for (var headerName in authOptions.headers) {\n headers.set(headerName, authOptions.headers[headerName]);\n }\n\n if (authOptions.headersProvider != null) {\n const dynamicHeaders = authOptions.headersProvider();\n for (var headerName in dynamicHeaders) {\n headers.set(headerName, dynamicHeaders[headerName]);\n }\n }\n\n var body = query;\n var request = new Request(authOptions.endpoint, {\n headers,\n body,\n credentials: 'same-origin',\n method: 'POST'\n });\n\n return fetch(request)\n .then(response => {\n let { status } = response;\n if (status === 200) {\n // manually parse the json so we can provide a more helpful error in\n // failure case\n return response.text();\n }\n throw new HTTPAuthError(\n status,\n `Could not get ${authRequestType.toString()} info from your auth endpoint, status: ${status}`\n );\n })\n .then(data => {\n let parsedData;\n try {\n parsedData = JSON.parse(data);\n } catch (e) {\n throw new HTTPAuthError(\n 200,\n `JSON returned from ${authRequestType.toString()} endpoint was invalid, yet status code was 200. Data was: ${data}`\n );\n }\n callback(null, parsedData);\n })\n .catch(err => {\n callback(err, null);\n });\n};\n\nexport default fetchAuth;\n","import Logger from 'core/logger';\nimport TimelineSender from 'core/timeline/timeline_sender';\nimport * as Collections from 'core/utils/collections';\nimport Util from 'core/util';\nimport Runtime from 'runtime';\nimport TimelineTransport from 'core/timeline/timeline_transport';\n\nvar getAgent = function(sender: TimelineSender, useTLS: boolean) {\n return function(data: any, callback: Function) {\n var scheme = 'http' + (useTLS ? 's' : '') + '://';\n var url =\n scheme + (sender.host || sender.options.host) + sender.options.path;\n var query = Collections.buildQueryString(data);\n url += '/' + 2 + '?' + query;\n\n fetch(url)\n .then(response => {\n if (response.status !== 200) {\n throw `received ${response.status} from stats.pusher.com`;\n }\n return response.json();\n })\n .then(({ host }) => {\n if (host) {\n sender.host = host;\n }\n })\n .catch(err => {\n Logger.debug('TimelineSender Error: ', err);\n });\n };\n};\n\nvar fetchTimeline = {\n name: 'xhr',\n getAgent\n};\n\nexport default fetchTimeline;\n","import Isomorphic from 'isomorphic/runtime';\nimport Runtime from '../interface';\nimport { Network } from './net_info';\nimport fetchAuth from './auth/fetch_auth';\nimport { AuthTransports } from 'core/auth/auth_transports';\nimport fetchTimeline from './timeline/fetch_timeline';\n\n// Very verbose but until unavoidable until\n// TypeScript 2.1, when spread attributes will be\n// supported\nconst {\n getDefaultStrategy,\n Transports,\n setup,\n getProtocol,\n isXHRSupported,\n getLocalStorage,\n createXHR,\n createWebSocket,\n addUnloadListener,\n removeUnloadListener,\n transportConnectionInitializer,\n createSocketRequest,\n HTTPFactory\n} = Isomorphic;\n\nconst Worker: Runtime = {\n getDefaultStrategy,\n Transports,\n setup,\n getProtocol,\n isXHRSupported,\n getLocalStorage,\n createXHR,\n createWebSocket,\n addUnloadListener,\n removeUnloadListener,\n transportConnectionInitializer,\n createSocketRequest,\n HTTPFactory,\n\n TimelineTransport: fetchTimeline,\n\n getAuthorizers(): AuthTransports {\n return { ajax: fetchAuth };\n },\n\n getWebSocketAPI() {\n return WebSocket;\n },\n\n getXHRAPI() {\n return XMLHttpRequest;\n },\n\n getNetwork() {\n return Network;\n },\n\n randomInt(max: number): number {\n /**\n * Return values in the range of [0, 1[\n */\n const random = function() {\n const crypto = globalThis.crypto || globalThis['msCrypto'];\n const random = crypto.getRandomValues(new Uint32Array(1))[0];\n\n return random / 2 ** 32;\n };\n\n return Math.floor(random() * max);\n }\n};\n\nexport default Worker;\n","enum TimelineLevel {\n ERROR = 3,\n INFO = 6,\n DEBUG = 7\n}\n\nexport default TimelineLevel;\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport { default as Level } from './level';\n\nexport interface TimelineOptions {\n level?: Level;\n limit?: number;\n version?: string;\n cluster?: string;\n features?: string[];\n params?: any;\n}\n\nexport default class Timeline {\n key: string;\n session: number;\n events: any[];\n options: TimelineOptions;\n sent: number;\n uniqueID: number;\n\n constructor(key: string, session: number, options: TimelineOptions) {\n this.key = key;\n this.session = session;\n this.events = [];\n this.options = options || {};\n this.sent = 0;\n this.uniqueID = 0;\n }\n\n log(level, event) {\n if (level <= this.options.level) {\n this.events.push(\n Collections.extend({}, event, { timestamp: Util.now() })\n );\n if (this.options.limit && this.events.length > this.options.limit) {\n this.events.shift();\n }\n }\n }\n\n error(event) {\n this.log(Level.ERROR, event);\n }\n\n info(event) {\n this.log(Level.INFO, event);\n }\n\n debug(event) {\n this.log(Level.DEBUG, event);\n }\n\n isEmpty() {\n return this.events.length === 0;\n }\n\n send(sendfn, callback) {\n var data = Collections.extend(\n {\n session: this.session,\n bundle: this.sent + 1,\n key: this.key,\n lib: 'js',\n version: this.options.version,\n cluster: this.options.cluster,\n features: this.options.features,\n timeline: this.events\n },\n this.options.params\n );\n\n this.events = [];\n sendfn(data, (error, result) => {\n if (!error) {\n this.sent++;\n }\n if (callback) {\n callback(error, result);\n }\n });\n\n return true;\n }\n\n generateUniqueID(): number {\n this.uniqueID++;\n return this.uniqueID;\n }\n}\n","import Factory from '../utils/factory';\nimport Util from '../util';\nimport * as Errors from '../errors';\nimport * as Collections from '../utils/collections';\nimport Strategy from './strategy';\nimport Transport from '../transports/transport';\nimport StrategyOptions from './strategy_options';\nimport Handshake from '../connection/handshake';\n\n/** Provides a strategy interface for transports.\n *\n * @param {String} name\n * @param {Number} priority\n * @param {Class} transport\n * @param {Object} options\n */\nexport default class TransportStrategy implements Strategy {\n name: string;\n priority: number;\n transport: Transport;\n options: StrategyOptions;\n\n constructor(\n name: string,\n priority: number,\n transport: Transport,\n options: StrategyOptions\n ) {\n this.name = name;\n this.priority = priority;\n this.transport = transport;\n this.options = options || {};\n }\n\n /** Returns whether the transport is supported in the browser.\n *\n * @returns {Boolean}\n */\n isSupported(): boolean {\n return this.transport.isSupported({\n useTLS: this.options.useTLS\n });\n }\n\n /** Launches a connection attempt and returns a strategy runner.\n *\n * @param {Function} callback\n * @return {Object} strategy runner\n */\n connect(minPriority: number, callback: Function) {\n if (!this.isSupported()) {\n return failAttempt(new Errors.UnsupportedStrategy(), callback);\n } else if (this.priority < minPriority) {\n return failAttempt(new Errors.TransportPriorityTooLow(), callback);\n }\n\n var connected = false;\n var transport = this.transport.createConnection(\n this.name,\n this.priority,\n this.options.key,\n this.options\n );\n var handshake = null;\n\n var onInitialized = function() {\n transport.unbind('initialized', onInitialized);\n transport.connect();\n };\n var onOpen = function() {\n handshake = Factory.createHandshake(transport, function(result) {\n connected = true;\n unbindListeners();\n callback(null, result);\n });\n };\n var onError = function(error) {\n unbindListeners();\n callback(error);\n };\n var onClosed = function() {\n unbindListeners();\n var serializedTransport;\n\n // The reason for this try/catch block is that on React Native\n // the WebSocket object is circular. Therefore transport.socket will\n // throw errors upon stringification. Collections.safeJSONStringify\n // discards circular references when serializing.\n serializedTransport = Collections.safeJSONStringify(transport);\n callback(new Errors.TransportClosed(serializedTransport));\n };\n\n var unbindListeners = function() {\n transport.unbind('initialized', onInitialized);\n transport.unbind('open', onOpen);\n transport.unbind('error', onError);\n transport.unbind('closed', onClosed);\n };\n\n transport.bind('initialized', onInitialized);\n transport.bind('open', onOpen);\n transport.bind('error', onError);\n transport.bind('closed', onClosed);\n\n // connect will be called automatically after initialization\n transport.initialize();\n\n return {\n abort: () => {\n if (connected) {\n return;\n }\n unbindListeners();\n if (handshake) {\n handshake.close();\n } else {\n transport.close();\n }\n },\n forceMinPriority: p => {\n if (connected) {\n return;\n }\n if (this.priority < p) {\n if (handshake) {\n handshake.close();\n } else {\n transport.close();\n }\n }\n }\n };\n }\n}\n\nfunction failAttempt(error: Error, callback: Function) {\n Util.defer(function() {\n callback(error);\n });\n return {\n abort: function() {},\n forceMinPriority: function() {}\n };\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport TransportManager from '../transports/transport_manager';\nimport * as Errors from '../errors';\nimport Strategy from './strategy';\nimport TransportStrategy from './transport_strategy';\nimport StrategyOptions from '../strategies/strategy_options';\nimport { Config } from '../config';\nimport Runtime from 'runtime';\n\nconst { Transports } = Runtime;\n\nexport var defineTransport = function(\n config: Config,\n name: string,\n type: string,\n priority: number,\n options: StrategyOptions,\n manager?: TransportManager\n): Strategy {\n var transportClass = Transports[type];\n if (!transportClass) {\n throw new Errors.UnsupportedTransport(type);\n }\n\n var enabled =\n (!config.enabledTransports ||\n Collections.arrayIndexOf(config.enabledTransports, name) !== -1) &&\n (!config.disabledTransports ||\n Collections.arrayIndexOf(config.disabledTransports, name) === -1);\n\n var transport;\n if (enabled) {\n options = Object.assign(\n { ignoreNullOrigin: config.ignoreNullOrigin },\n options\n );\n\n transport = new TransportStrategy(\n name,\n priority,\n manager ? manager.getAssistant(transportClass) : transportClass,\n options\n );\n } else {\n transport = UnsupportedStrategy;\n }\n\n return transport;\n};\n\nvar UnsupportedStrategy: Strategy = {\n isSupported: function() {\n return false;\n },\n connect: function(_, callback) {\n var deferred = Util.defer(function() {\n callback(new Errors.UnsupportedStrategy());\n });\n return {\n abort: function() {\n deferred.ensureAborted();\n },\n forceMinPriority: function() {}\n };\n }\n};\n","import ConnectionManager from './connection/connection_manager';\nimport {\n ChannelAuthorizationOptions,\n UserAuthenticationOptions\n} from './auth/options';\nimport {\n ChannelAuthorizerGenerator,\n DeprecatedAuthOptions\n} from './auth/deprecated_channel_authorizer';\nimport { AuthTransport, Transport } from './config';\nimport * as nacl from 'tweetnacl';\nimport Logger from './logger';\n\nexport interface Options {\n activityTimeout?: number;\n\n auth?: DeprecatedAuthOptions; // DEPRECATED use channelAuthorization instead\n authEndpoint?: string; // DEPRECATED use channelAuthorization instead\n authTransport?: AuthTransport; // DEPRECATED use channelAuthorization instead\n authorizer?: ChannelAuthorizerGenerator; // DEPRECATED use channelAuthorization instead\n\n channelAuthorization?: ChannelAuthorizationOptions;\n userAuthentication?: UserAuthenticationOptions;\n\n cluster: string;\n enableStats?: boolean;\n disableStats?: boolean;\n disabledTransports?: Transport[];\n enabledTransports?: Transport[];\n forceTLS?: boolean;\n httpHost?: string;\n httpPath?: string;\n httpPort?: number;\n httpsPort?: number;\n ignoreNullOrigin?: boolean;\n nacl?: nacl;\n pongTimeout?: number;\n statsHost?: string;\n timelineParams?: any;\n unavailableTimeout?: number;\n wsHost?: string;\n wsPath?: string;\n wsPort?: number;\n wssPort?: number;\n}\n\nexport interface ClusterOptions {\n appKey: string;\n cluster: string;\n}\n\nexport function validateOptions(options) {\n if (options == null) {\n throw 'You must pass an options object';\n }\n if (options.cluster == null) {\n throw 'Options object must provide a cluster';\n }\n if ('disableStats' in options) {\n Logger.warn(\n 'The disableStats option is deprecated in favor of enableStats'\n );\n }\n}\n","export enum AuthRequestType {\n UserAuthentication = 'user-authentication',\n ChannelAuthorization = 'channel-authorization'\n}\n\nexport interface ChannelAuthorizationData {\n auth: string;\n channel_data?: string;\n shared_secret?: string;\n}\n\nexport type ChannelAuthorizationCallback = (\n error: Error | null,\n authData: ChannelAuthorizationData | null\n) => void;\n\nexport interface ChannelAuthorizationRequestParams {\n socketId: string;\n channelName: string;\n}\n\nexport interface ChannelAuthorizationHandler {\n (\n params: ChannelAuthorizationRequestParams,\n callback: ChannelAuthorizationCallback\n ): void;\n}\n\nexport interface UserAuthenticationData {\n auth: string;\n user_data: string;\n}\n\nexport type UserAuthenticationCallback = (\n error: Error | null,\n authData: UserAuthenticationData | null\n) => void;\n\nexport interface UserAuthenticationRequestParams {\n socketId: string;\n}\n\nexport interface UserAuthenticationHandler {\n (\n params: UserAuthenticationRequestParams,\n callback: UserAuthenticationCallback\n ): void;\n}\n\nexport type AuthTransportCallback =\n | ChannelAuthorizationCallback\n | UserAuthenticationCallback;\n\nexport interface InternalAuthOptions {\n transport: 'ajax' | 'jsonp';\n endpoint: string;\n params?: any;\n headers?: any;\n paramsProvider?: () => any;\n headersProvider?: () => any;\n}\n\nexport type CustomAuthOptions = {\n customHandler: AuthHandler;\n};\n\nexport type AuthOptionsT =\n | InternalAuthOptions\n | CustomAuthOptions;\n\nexport declare type UserAuthenticationOptions = AuthOptionsT<\n UserAuthenticationHandler\n>;\nexport declare type ChannelAuthorizationOptions = AuthOptionsT<\n ChannelAuthorizationHandler\n>;\n","import {\n UserAuthenticationCallback,\n InternalAuthOptions,\n UserAuthenticationHandler,\n UserAuthenticationRequestParams,\n AuthRequestType\n} from './options';\n\nimport Runtime from 'runtime';\n\nconst composeChannelQuery = (\n params: UserAuthenticationRequestParams,\n authOptions: InternalAuthOptions\n) => {\n var query = 'socket_id=' + encodeURIComponent(params.socketId);\n\n for (var key in authOptions.params) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(authOptions.params[key]);\n }\n\n if (authOptions.paramsProvider != null) {\n let dynamicParams = authOptions.paramsProvider();\n for (var key in dynamicParams) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(dynamicParams[key]);\n }\n }\n\n return query;\n};\n\nconst UserAuthenticator = (\n authOptions: InternalAuthOptions\n): UserAuthenticationHandler => {\n if (typeof Runtime.getAuthorizers()[authOptions.transport] === 'undefined') {\n throw `'${authOptions.transport}' is not a recognized auth transport`;\n }\n\n return (\n params: UserAuthenticationRequestParams,\n callback: UserAuthenticationCallback\n ) => {\n const query = composeChannelQuery(params, authOptions);\n\n Runtime.getAuthorizers()[authOptions.transport](\n Runtime,\n query,\n authOptions,\n AuthRequestType.UserAuthentication,\n callback\n );\n };\n};\n\nexport default UserAuthenticator;\n","import {\n AuthRequestType,\n InternalAuthOptions,\n ChannelAuthorizationHandler,\n ChannelAuthorizationRequestParams,\n ChannelAuthorizationCallback\n} from './options';\n\nimport Runtime from 'runtime';\n\nconst composeChannelQuery = (\n params: ChannelAuthorizationRequestParams,\n authOptions: InternalAuthOptions\n) => {\n var query = 'socket_id=' + encodeURIComponent(params.socketId);\n\n query += '&channel_name=' + encodeURIComponent(params.channelName);\n\n for (var key in authOptions.params) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(authOptions.params[key]);\n }\n\n if (authOptions.paramsProvider != null) {\n let dynamicParams = authOptions.paramsProvider();\n for (var key in dynamicParams) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(dynamicParams[key]);\n }\n }\n\n return query;\n};\n\nconst ChannelAuthorizer = (\n authOptions: InternalAuthOptions\n): ChannelAuthorizationHandler => {\n if (typeof Runtime.getAuthorizers()[authOptions.transport] === 'undefined') {\n throw `'${authOptions.transport}' is not a recognized auth transport`;\n }\n\n return (\n params: ChannelAuthorizationRequestParams,\n callback: ChannelAuthorizationCallback\n ) => {\n const query = composeChannelQuery(params, authOptions);\n\n Runtime.getAuthorizers()[authOptions.transport](\n Runtime,\n query,\n authOptions,\n AuthRequestType.ChannelAuthorization,\n callback\n );\n };\n};\n\nexport default ChannelAuthorizer;\n","import Channel from '../channels/channel';\nimport {\n ChannelAuthorizationCallback,\n ChannelAuthorizationHandler,\n ChannelAuthorizationRequestParams,\n InternalAuthOptions\n} from './options';\n\nexport interface DeprecatedChannelAuthorizer {\n authorize(socketId: string, callback: ChannelAuthorizationCallback): void;\n}\n\nexport interface ChannelAuthorizerGenerator {\n (\n channel: Channel,\n options: DeprecatedAuthorizerOptions\n ): DeprecatedChannelAuthorizer;\n}\n\nexport interface DeprecatedAuthOptions {\n params?: any;\n headers?: any;\n}\n\nexport interface DeprecatedAuthorizerOptions {\n authTransport: 'ajax' | 'jsonp';\n authEndpoint: string;\n auth?: DeprecatedAuthOptions;\n}\n\nexport const ChannelAuthorizerProxy = (\n pusher,\n authOptions: InternalAuthOptions,\n channelAuthorizerGenerator: ChannelAuthorizerGenerator\n): ChannelAuthorizationHandler => {\n const deprecatedAuthorizerOptions: DeprecatedAuthorizerOptions = {\n authTransport: authOptions.transport,\n authEndpoint: authOptions.endpoint,\n auth: {\n params: authOptions.params,\n headers: authOptions.headers\n }\n };\n return (\n params: ChannelAuthorizationRequestParams,\n callback: ChannelAuthorizationCallback\n ) => {\n const channel = pusher.channel(params.channelName);\n // This line creates a new channel authorizer every time.\n // In the past, this was only done once per channel and reused.\n // We can do that again if we want to keep this behavior intact.\n const channelAuthorizer: DeprecatedChannelAuthorizer = channelAuthorizerGenerator(\n channel,\n deprecatedAuthorizerOptions\n );\n channelAuthorizer.authorize(params.socketId, callback);\n };\n};\n","import { Options } from './options';\nimport Defaults from './defaults';\nimport {\n ChannelAuthorizationHandler,\n UserAuthenticationHandler,\n ChannelAuthorizationOptions,\n AuthOptionsT,\n CustomAuthOptions\n} from './auth/options';\nimport UserAuthenticator from './auth/user_authenticator';\nimport ChannelAuthorizer from './auth/channel_authorizer';\nimport { ChannelAuthorizerProxy } from './auth/deprecated_channel_authorizer';\nimport Runtime from 'runtime';\nimport * as nacl from 'tweetnacl';\n\nexport type AuthTransport = 'ajax' | 'jsonp';\nexport type Transport =\n | 'ws'\n | 'wss'\n | 'xhr_streaming'\n | 'xhr_polling'\n | 'sockjs';\n\nexport interface Config {\n // these are all 'required' config parameters, it's not necessary for the user\n // to set them, but they have configured defaults.\n activityTimeout: number;\n enableStats: boolean;\n httpHost: string;\n httpPath: string;\n httpPort: number;\n httpsPort: number;\n pongTimeout: number;\n statsHost: string;\n unavailableTimeout: number;\n useTLS: boolean;\n wsHost: string;\n wsPath: string;\n wsPort: number;\n wssPort: number;\n userAuthenticator: UserAuthenticationHandler;\n channelAuthorizer: ChannelAuthorizationHandler;\n\n // these are all optional parameters or overrrides. The customer can set these\n // but it's not strictly necessary\n forceTLS?: boolean;\n cluster?: string;\n disabledTransports?: Transport[];\n enabledTransports?: Transport[];\n ignoreNullOrigin?: boolean;\n nacl?: nacl;\n timelineParams?: any;\n}\n\n// getConfig mainly sets the defaults for the options that are not provided\nexport function getConfig(opts: Options, pusher): Config {\n let config: Config = {\n activityTimeout: opts.activityTimeout || Defaults.activityTimeout,\n cluster: opts.cluster,\n httpPath: opts.httpPath || Defaults.httpPath,\n httpPort: opts.httpPort || Defaults.httpPort,\n httpsPort: opts.httpsPort || Defaults.httpsPort,\n pongTimeout: opts.pongTimeout || Defaults.pongTimeout,\n statsHost: opts.statsHost || Defaults.stats_host,\n unavailableTimeout: opts.unavailableTimeout || Defaults.unavailableTimeout,\n wsPath: opts.wsPath || Defaults.wsPath,\n wsPort: opts.wsPort || Defaults.wsPort,\n wssPort: opts.wssPort || Defaults.wssPort,\n\n enableStats: getEnableStatsConfig(opts),\n httpHost: getHttpHost(opts),\n useTLS: shouldUseTLS(opts),\n wsHost: getWebsocketHost(opts),\n\n userAuthenticator: buildUserAuthenticator(opts),\n channelAuthorizer: buildChannelAuthorizer(opts, pusher)\n };\n\n if ('disabledTransports' in opts)\n config.disabledTransports = opts.disabledTransports;\n if ('enabledTransports' in opts)\n config.enabledTransports = opts.enabledTransports;\n if ('ignoreNullOrigin' in opts)\n config.ignoreNullOrigin = opts.ignoreNullOrigin;\n if ('timelineParams' in opts) config.timelineParams = opts.timelineParams;\n if ('nacl' in opts) {\n config.nacl = opts.nacl;\n }\n\n return config;\n}\n\nfunction getHttpHost(opts: Options): string {\n if (opts.httpHost) {\n return opts.httpHost;\n }\n if (opts.cluster) {\n return `sockjs-${opts.cluster}.pusher.com`;\n }\n return Defaults.httpHost;\n}\n\nfunction getWebsocketHost(opts: Options): string {\n if (opts.wsHost) {\n return opts.wsHost;\n }\n return getWebsocketHostFromCluster(opts.cluster);\n}\n\nfunction getWebsocketHostFromCluster(cluster: string): string {\n return `ws-${cluster}.pusher.com`;\n}\n\nfunction shouldUseTLS(opts: Options): boolean {\n if (Runtime.getProtocol() === 'https:') {\n return true;\n } else if (opts.forceTLS === false) {\n return false;\n }\n return true;\n}\n\n// if enableStats is set take the value\n// if disableStats is set take the inverse\n// otherwise default to false\nfunction getEnableStatsConfig(opts: Options): boolean {\n if ('enableStats' in opts) {\n return opts.enableStats;\n }\n if ('disableStats' in opts) {\n return !opts.disableStats;\n }\n return false;\n}\n\nconst hasCustomHandler = (\n auth: AuthOptionsT\n): auth is CustomAuthOptions => {\n return 'customHandler' in auth && auth['customHandler'] != null;\n};\n\nfunction buildUserAuthenticator(opts: Options): UserAuthenticationHandler {\n const userAuthentication = {\n ...Defaults.userAuthentication,\n ...opts.userAuthentication\n };\n\n if (hasCustomHandler(userAuthentication)) {\n return userAuthentication['customHandler'];\n }\n\n return UserAuthenticator(userAuthentication);\n}\n\nfunction buildChannelAuth(opts: Options, pusher): ChannelAuthorizationOptions {\n let channelAuthorization: ChannelAuthorizationOptions;\n if ('channelAuthorization' in opts) {\n channelAuthorization = {\n ...Defaults.channelAuthorization,\n ...opts.channelAuthorization\n };\n } else {\n channelAuthorization = {\n transport: opts.authTransport || Defaults.authTransport,\n endpoint: opts.authEndpoint || Defaults.authEndpoint\n };\n\n if ('auth' in opts) {\n if ('params' in opts.auth) channelAuthorization.params = opts.auth.params;\n if ('headers' in opts.auth)\n channelAuthorization.headers = opts.auth.headers;\n }\n\n if ('authorizer' in opts) {\n return {\n customHandler: ChannelAuthorizerProxy(\n pusher,\n channelAuthorization,\n opts.authorizer\n )\n };\n }\n }\n return channelAuthorization;\n}\n\nfunction buildChannelAuthorizer(\n opts: Options,\n pusher\n): ChannelAuthorizationHandler {\n const channelAuthorization = buildChannelAuth(opts, pusher);\n\n if (hasCustomHandler(channelAuthorization)) {\n return channelAuthorization['customHandler'];\n }\n\n return ChannelAuthorizer(channelAuthorization);\n}\n","import Logger from './logger';\nimport Pusher from './pusher';\nimport EventsDispatcher from './events/dispatcher';\n\nexport default class WatchlistFacade extends EventsDispatcher {\n private pusher: Pusher;\n\n public constructor(pusher: Pusher) {\n super(function(eventName, data) {\n Logger.debug(`No callbacks on watchlist events for ${eventName}`);\n });\n\n this.pusher = pusher;\n this.bindWatchlistInternalEvent();\n }\n\n handleEvent(pusherEvent) {\n pusherEvent.data.events.forEach(watchlistEvent => {\n this.emit(watchlistEvent.name, watchlistEvent);\n });\n }\n\n private bindWatchlistInternalEvent() {\n this.pusher.connection.bind('message', pusherEvent => {\n var eventName = pusherEvent.event;\n if (eventName === 'pusher_internal:watchlist_events') {\n this.handleEvent(pusherEvent);\n }\n });\n }\n}\n","function flatPromise() {\n let resolve, reject;\n const promise = new Promise((res, rej) => {\n resolve = res;\n reject = rej;\n });\n return { promise, resolve, reject };\n}\n\nexport default flatPromise;\n","import Pusher from './pusher';\nimport Logger from './logger';\nimport {\n UserAuthenticationData,\n UserAuthenticationCallback\n} from './auth/options';\nimport Channel from './channels/channel';\nimport WatchlistFacade from './watchlist';\nimport EventsDispatcher from './events/dispatcher';\nimport flatPromise from './utils/flat_promise';\n\nexport default class UserFacade extends EventsDispatcher {\n pusher: Pusher;\n signin_requested: boolean = false;\n user_data: any = null;\n serverToUserChannel: Channel = null;\n signinDonePromise: Promise = null;\n watchlist: WatchlistFacade;\n private _signinDoneResolve: Function = null;\n\n public constructor(pusher: Pusher) {\n super(function(eventName, data) {\n Logger.debug('No callbacks on user for ' + eventName);\n });\n this.pusher = pusher;\n this.pusher.connection.bind('state_change', ({ previous, current }) => {\n if (previous !== 'connected' && current === 'connected') {\n this._signin();\n }\n if (previous === 'connected' && current !== 'connected') {\n this._cleanup();\n this._newSigninPromiseIfNeeded();\n }\n });\n\n this.watchlist = new WatchlistFacade(pusher);\n\n this.pusher.connection.bind('message', event => {\n var eventName = event.event;\n if (eventName === 'pusher:signin_success') {\n this._onSigninSuccess(event.data);\n }\n if (\n this.serverToUserChannel &&\n this.serverToUserChannel.name === event.channel\n ) {\n this.serverToUserChannel.handleEvent(event);\n }\n });\n }\n\n public signin() {\n if (this.signin_requested) {\n return;\n }\n\n this.signin_requested = true;\n this._signin();\n }\n\n private _signin() {\n if (!this.signin_requested) {\n return;\n }\n\n this._newSigninPromiseIfNeeded();\n\n if (this.pusher.connection.state !== 'connected') {\n // Signin will be attempted when the connection is connected\n return;\n }\n\n this.pusher.config.userAuthenticator(\n {\n socketId: this.pusher.connection.socket_id\n },\n this._onAuthorize\n );\n }\n\n private _onAuthorize: UserAuthenticationCallback = (\n err,\n authData: UserAuthenticationData\n ) => {\n if (err) {\n Logger.warn(`Error during signin: ${err}`);\n this._cleanup();\n return;\n }\n\n this.pusher.send_event('pusher:signin', {\n auth: authData.auth,\n user_data: authData.user_data\n });\n\n // Later when we get pusher:singin_success event, the user will be marked as signed in\n };\n\n private _onSigninSuccess(data: any) {\n try {\n this.user_data = JSON.parse(data.user_data);\n } catch (e) {\n Logger.error(`Failed parsing user data after signin: ${data.user_data}`);\n this._cleanup();\n return;\n }\n\n if (typeof this.user_data.id !== 'string' || this.user_data.id === '') {\n Logger.error(\n `user_data doesn't contain an id. user_data: ${this.user_data}`\n );\n this._cleanup();\n return;\n }\n\n // Signin succeeded\n this._signinDoneResolve();\n this._subscribeChannels();\n }\n\n private _subscribeChannels() {\n const ensure_subscribed = channel => {\n if (channel.subscriptionPending && channel.subscriptionCancelled) {\n channel.reinstateSubscription();\n } else if (\n !channel.subscriptionPending &&\n this.pusher.connection.state === 'connected'\n ) {\n channel.subscribe();\n }\n };\n\n this.serverToUserChannel = new Channel(\n `#server-to-user-${this.user_data.id}`,\n this.pusher\n );\n this.serverToUserChannel.bind_global((eventName, data) => {\n if (\n eventName.indexOf('pusher_internal:') === 0 ||\n eventName.indexOf('pusher:') === 0\n ) {\n // ignore internal events\n return;\n }\n this.emit(eventName, data);\n });\n ensure_subscribed(this.serverToUserChannel);\n }\n\n private _cleanup() {\n this.user_data = null;\n if (this.serverToUserChannel) {\n this.serverToUserChannel.unbind_all();\n this.serverToUserChannel.disconnect();\n this.serverToUserChannel = null;\n }\n\n if (this.signin_requested) {\n // If signin is in progress and cleanup is called,\n // Mark the current signin process as done.\n this._signinDoneResolve();\n }\n }\n\n private _newSigninPromiseIfNeeded() {\n if (!this.signin_requested) {\n return;\n }\n\n // If there is a promise and it is not resolved, return without creating a new one.\n if (this.signinDonePromise && !(this.signinDonePromise as any).done) {\n return;\n }\n\n // This promise is never rejected.\n // It gets resolved when the signin process is done whether it failed or succeeded\n const { promise, resolve, reject: _ } = flatPromise();\n (promise as any).done = false;\n const setDone = () => {\n (promise as any).done = true;\n };\n promise.then(setDone).catch(setDone);\n this.signinDonePromise = promise;\n this._signinDoneResolve = resolve;\n }\n}\n","import AbstractRuntime from '../runtimes/interface';\nimport Runtime from 'runtime';\nimport * as Collections from './utils/collections';\nimport Channels from './channels/channels';\nimport Channel from './channels/channel';\nimport { default as EventsDispatcher } from './events/dispatcher';\nimport Timeline from './timeline/timeline';\nimport TimelineSender from './timeline/timeline_sender';\nimport TimelineLevel from './timeline/level';\nimport { defineTransport } from './strategies/strategy_builder';\nimport ConnectionManager from './connection/connection_manager';\nimport { PeriodicTimer } from './utils/timers';\nimport Defaults from './defaults';\nimport Logger from './logger';\nimport Factory from './utils/factory';\nimport { Options, ClusterOptions, validateOptions } from './options';\nimport { Config, getConfig } from './config';\nimport StrategyOptions from './strategies/strategy_options';\nimport UserFacade from './user';\n\nexport default class Pusher {\n /* STATIC PROPERTIES */\n static instances: Pusher[] = [];\n static isReady: boolean = false;\n static logToConsole: boolean = false;\n\n // for jsonp\n static Runtime: AbstractRuntime = Runtime;\n static ScriptReceivers: any = (Runtime).ScriptReceivers;\n static DependenciesReceivers: any = (Runtime).DependenciesReceivers;\n static auth_callbacks: any = (Runtime).auth_callbacks;\n\n static ready() {\n Pusher.isReady = true;\n for (var i = 0, l = Pusher.instances.length; i < l; i++) {\n Pusher.instances[i].connect();\n }\n }\n\n static log: (message: any) => void;\n\n private static getClientFeatures(): string[] {\n return Collections.keys(\n Collections.filterObject({ ws: Runtime.Transports.ws }, function(t) {\n return t.isSupported({});\n })\n );\n }\n\n /* INSTANCE PROPERTIES */\n key: string;\n options: Options;\n config: Config;\n channels: Channels;\n global_emitter: EventsDispatcher;\n sessionID: number;\n timeline: Timeline;\n timelineSender: TimelineSender;\n connection: ConnectionManager;\n timelineSenderTimer: PeriodicTimer;\n user: UserFacade;\n constructor(app_key: string, options: Options) {\n checkAppKey(app_key);\n validateOptions(options);\n this.key = app_key;\n this.options = options;\n this.config = getConfig(this.options, this);\n\n this.channels = Factory.createChannels();\n this.global_emitter = new EventsDispatcher();\n this.sessionID = Runtime.randomInt(1000000000);\n\n this.timeline = new Timeline(this.key, this.sessionID, {\n cluster: this.config.cluster,\n features: Pusher.getClientFeatures(),\n params: this.config.timelineParams || {},\n limit: 50,\n level: TimelineLevel.INFO,\n version: Defaults.VERSION\n });\n if (this.config.enableStats) {\n this.timelineSender = Factory.createTimelineSender(this.timeline, {\n host: this.config.statsHost,\n path: '/timeline/v2/' + Runtime.TimelineTransport.name\n });\n }\n\n var getStrategy = (options: StrategyOptions) => {\n return Runtime.getDefaultStrategy(this.config, options, defineTransport);\n };\n\n this.connection = Factory.createConnectionManager(this.key, {\n getStrategy: getStrategy,\n timeline: this.timeline,\n activityTimeout: this.config.activityTimeout,\n pongTimeout: this.config.pongTimeout,\n unavailableTimeout: this.config.unavailableTimeout,\n useTLS: Boolean(this.config.useTLS)\n });\n\n this.connection.bind('connected', () => {\n this.subscribeAll();\n if (this.timelineSender) {\n this.timelineSender.send(this.connection.isUsingTLS());\n }\n });\n\n this.connection.bind('message', event => {\n var eventName = event.event;\n var internal = eventName.indexOf('pusher_internal:') === 0;\n if (event.channel) {\n var channel = this.channel(event.channel);\n if (channel) {\n channel.handleEvent(event);\n }\n }\n // Emit globally [deprecated]\n if (!internal) {\n this.global_emitter.emit(event.event, event.data);\n }\n });\n this.connection.bind('connecting', () => {\n this.channels.disconnect();\n });\n this.connection.bind('disconnected', () => {\n this.channels.disconnect();\n });\n this.connection.bind('error', err => {\n Logger.warn(err);\n });\n\n Pusher.instances.push(this);\n this.timeline.info({ instances: Pusher.instances.length });\n\n this.user = new UserFacade(this);\n\n if (Pusher.isReady) {\n this.connect();\n }\n }\n\n /**\n * Allows you to switch Pusher cluster without\n * losing all the channels/subscription binding\n * as this is internally managed by the SDK.\n */\n switchCluster(options: ClusterOptions) {\n const { appKey, cluster } = options;\n this.key = appKey;\n this.options = { ...this.options, cluster };\n this.config = getConfig(this.options, this);\n this.connection.switchCluster(this.key);\n }\n\n channel(name: string): Channel {\n return this.channels.find(name);\n }\n\n allChannels(): Channel[] {\n return this.channels.all();\n }\n\n connect() {\n this.connection.connect();\n\n if (this.timelineSender) {\n if (!this.timelineSenderTimer) {\n var usingTLS = this.connection.isUsingTLS();\n var timelineSender = this.timelineSender;\n this.timelineSenderTimer = new PeriodicTimer(60000, function() {\n timelineSender.send(usingTLS);\n });\n }\n }\n }\n\n disconnect() {\n this.connection.disconnect();\n\n if (this.timelineSenderTimer) {\n this.timelineSenderTimer.ensureAborted();\n this.timelineSenderTimer = null;\n }\n }\n\n bind(event_name: string, callback: Function, context?: any): Pusher {\n this.global_emitter.bind(event_name, callback, context);\n return this;\n }\n\n unbind(event_name?: string, callback?: Function, context?: any): Pusher {\n this.global_emitter.unbind(event_name, callback, context);\n return this;\n }\n\n bind_global(callback: Function): Pusher {\n this.global_emitter.bind_global(callback);\n return this;\n }\n\n unbind_global(callback?: Function): Pusher {\n this.global_emitter.unbind_global(callback);\n return this;\n }\n\n unbind_all(callback?: Function): Pusher {\n this.global_emitter.unbind_all();\n return this;\n }\n\n subscribeAll() {\n var channelName;\n for (channelName in this.channels.channels) {\n if (this.channels.channels.hasOwnProperty(channelName)) {\n this.subscribe(channelName);\n }\n }\n }\n\n subscribe(channel_name: string) {\n var channel = this.channels.add(channel_name, this);\n if (channel.subscriptionPending && channel.subscriptionCancelled) {\n channel.reinstateSubscription();\n } else if (\n !channel.subscriptionPending &&\n this.connection.state === 'connected'\n ) {\n channel.subscribe();\n }\n return channel;\n }\n\n unsubscribe(channel_name: string) {\n var channel = this.channels.find(channel_name);\n if (channel && channel.subscriptionPending) {\n channel.cancelSubscription();\n } else {\n channel = this.channels.remove(channel_name);\n if (channel && channel.subscribed) {\n channel.unsubscribe();\n }\n }\n }\n\n send_event(event_name: string, data: any, channel?: string) {\n return this.connection.send_event(event_name, data, channel);\n }\n\n shouldUseTLS(): boolean {\n return this.config.useTLS;\n }\n\n signin() {\n this.user.signin();\n }\n}\n\nfunction checkAppKey(key) {\n if (key === null || key === undefined) {\n throw 'You must pass your app key when you instantiate Pusher.';\n }\n}\n\nRuntime.setup(Pusher);\n"],"sourceRoot":""} \ No newline at end of file diff --git a/dist/worker/pusher.worker.min.js b/dist/worker/pusher.worker.min.js index 3093a9f8d..7b4512955 100644 --- a/dist/worker/pusher.worker.min.js +++ b/dist/worker/pusher.worker.min.js @@ -1,9 +1,9 @@ /*! - * Pusher JavaScript Library v8.4.0-rc1 + * Pusher JavaScript Library v8.4.0-rc2 * https://pusher.com/ * * Copyright 2020, Pusher * Released under the MIT licence. */ -!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.Pusher=e():t.Pusher=e()}(this,(function(){return function(t){var e={};function n(i){if(e[i])return e[i].exports;var s=e[i]={i:i,l:!1,exports:{}};return t[i].call(s.exports,s,s.exports,n),s.l=!0,s.exports}return n.m=t,n.c=e,n.d=function(t,e,i){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:i})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var i=Object.create(null);if(n.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var s in t)n.d(i,s,function(e){return t[e]}.bind(null,s));return i},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=2)}([function(t,e,n){"use strict";var i,s=this&&this.__extends||(i=function(t,e){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)},function(t,e){function n(){this.constructor=t}i(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)});Object.defineProperty(e,"__esModule",{value:!0});var r=function(){function t(t){void 0===t&&(t="="),this._paddingCharacter=t}return t.prototype.encodedLength=function(t){return this._paddingCharacter?(t+2)/3*4|0:(8*t+5)/6|0},t.prototype.encode=function(t){for(var e="",n=0;n>>18&63),e+=this._encodeByte(i>>>12&63),e+=this._encodeByte(i>>>6&63),e+=this._encodeByte(i>>>0&63)}var s=t.length-n;if(s>0){i=t[n]<<16|(2===s?t[n+1]<<8:0);e+=this._encodeByte(i>>>18&63),e+=this._encodeByte(i>>>12&63),e+=2===s?this._encodeByte(i>>>6&63):this._paddingCharacter||"",e+=this._paddingCharacter||""}return e},t.prototype.maxDecodedLength=function(t){return this._paddingCharacter?t/4*3|0:(6*t+7)/8|0},t.prototype.decodedLength=function(t){return this.maxDecodedLength(t.length-this._getPaddingLength(t))},t.prototype.decode=function(t){if(0===t.length)return new Uint8Array(0);for(var e=this._getPaddingLength(t),n=t.length-e,i=new Uint8Array(this.maxDecodedLength(n)),s=0,r=0,o=0,a=0,c=0,h=0,u=0;r>>4,i[s++]=c<<4|h>>>2,i[s++]=h<<6|u,o|=256&a,o|=256&c,o|=256&h,o|=256&u;if(r>>4,o|=256&a,o|=256&c),r>>2,o|=256&h),r>>8&6,e+=51-t>>>8&-75,e+=61-t>>>8&-15,e+=62-t>>>8&3,String.fromCharCode(e)},t.prototype._decodeChar=function(t){var e=256;return e+=(42-t&t-44)>>>8&-256+t-43+62,e+=(46-t&t-48)>>>8&-256+t-47+63,e+=(47-t&t-58)>>>8&-256+t-48+52,e+=(64-t&t-91)>>>8&-256+t-65+0,e+=(96-t&t-123)>>>8&-256+t-97+26},t.prototype._getPaddingLength=function(t){var e=0;if(this._paddingCharacter){for(var n=t.length-1;n>=0&&t[n]===this._paddingCharacter;n--)e++;if(t.length<4||e>2)throw new Error("Base64Coder: incorrect padding")}return e},t}();e.Coder=r;var o=new r;e.encode=function(t){return o.encode(t)},e.decode=function(t){return o.decode(t)};var a=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return s(e,t),e.prototype._encodeByte=function(t){var e=t;return e+=65,e+=25-t>>>8&6,e+=51-t>>>8&-75,e+=61-t>>>8&-13,e+=62-t>>>8&49,String.fromCharCode(e)},e.prototype._decodeChar=function(t){var e=256;return e+=(44-t&t-46)>>>8&-256+t-45+62,e+=(94-t&t-96)>>>8&-256+t-95+63,e+=(47-t&t-58)>>>8&-256+t-48+52,e+=(64-t&t-91)>>>8&-256+t-65+0,e+=(96-t&t-123)>>>8&-256+t-97+26},e}(r);e.URLSafeCoder=a;var c=new a;e.encodeURLSafe=function(t){return c.encode(t)},e.decodeURLSafe=function(t){return c.decode(t)},e.encodedLength=function(t){return o.encodedLength(t)},e.maxDecodedLength=function(t){return o.maxDecodedLength(t)},e.decodedLength=function(t){return o.decodedLength(t)}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i="utf8: invalid source encoding";function s(t){for(var e=0,n=0;n=t.length-1)throw new Error("utf8: invalid string");n++,e+=4}}return e}e.encode=function(t){for(var e=new Uint8Array(s(t)),n=0,i=0;i>6,e[n++]=128|63&r):r<55296?(e[n++]=224|r>>12,e[n++]=128|r>>6&63,e[n++]=128|63&r):(i++,r=(1023&r)<<10,r|=1023&t.charCodeAt(i),r+=65536,e[n++]=240|r>>18,e[n++]=128|r>>12&63,e[n++]=128|r>>6&63,e[n++]=128|63&r)}return e},e.encodedLength=s,e.decode=function(t){for(var e=[],n=0;n=t.length)throw new Error(i);if(128!=(192&(o=t[++n])))throw new Error(i);s=(31&s)<<6|63&o,r=128}else if(s<240){if(n>=t.length-1)throw new Error(i);var o=t[++n],a=t[++n];if(128!=(192&o)||128!=(192&a))throw new Error(i);s=(15&s)<<12|(63&o)<<6|63&a,r=2048}else{if(!(s<248))throw new Error(i);if(n>=t.length-2)throw new Error(i);o=t[++n],a=t[++n];var c=t[++n];if(128!=(192&o)||128!=(192&a)||128!=(192&c))throw new Error(i);s=(15&s)<<18|(63&o)<<12|(63&a)<<6|63&c,r=65536}if(s=55296&&s<=57343)throw new Error(i);if(s>=65536){if(s>1114111)throw new Error(i);s-=65536,e.push(String.fromCharCode(55296|s>>10)),s=56320|1023&s}}e.push(String.fromCharCode(s))}return e.join("")}},function(t,e,n){t.exports=n(3).default},function(t,e,n){"use strict";n.r(e);for(var i=String.fromCharCode,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",r={},o=0,a=s.length;o>>6)+i(128|63&e):i(224|e>>>12&15)+i(128|e>>>6&63)+i(128|63&e)},h=function(t){return t.replace(/[^\x00-\x7F]/g,c)},u=function(t){var e=[0,2,1][t.length%3],n=t.charCodeAt(0)<<16|(t.length>1?t.charCodeAt(1):0)<<8|(t.length>2?t.charCodeAt(2):0);return[s.charAt(n>>>18),s.charAt(n>>>12&63),e>=2?"=":s.charAt(n>>>6&63),e>=1?"=":s.charAt(63&n)].join("")},l=self.btoa||function(t){return t.replace(/[\s\S]{1,3}/g,u)};var d=class{constructor(t,e,n,i){this.clear=e,this.timer=t(()=>{this.timer&&(this.timer=i(this.timer))},n)}isRunning(){return null!==this.timer}ensureAborted(){this.timer&&(this.clear(this.timer),this.timer=null)}};function p(t){self.clearTimeout(t)}function f(t){self.clearInterval(t)}class g extends d{constructor(t,e){super(setTimeout,p,t,(function(t){return e(),null}))}}class b extends d{constructor(t,e){super(setInterval,f,t,(function(t){return e(),t}))}}var m={now:()=>Date.now?Date.now():(new Date).valueOf(),defer:t=>new g(0,t),method(t,...e){var n=Array.prototype.slice.call(arguments,1);return function(e){return e[t].apply(e,n.concat(arguments))}}};function v(t,...e){for(var n=0;ne!==t),this):(this.global_callbacks=[],this)}unbind_all(){return this.unbind(),this.unbind_global(),this}emit(t,e,n){for(var i=0;i0)for(i=0;i{self.console&&self.console.log&&self.console.log(t)}}debug(...t){this.log(this.globalLog,t)}warn(...t){this.log(this.globalLogWarn,t)}error(...t){this.log(this.globalLogError,t)}globalLogWarn(t){self.console&&self.console.warn?self.console.warn(t):this.globalLog(t)}globalLogError(t){self.console&&self.console.error?self.console.error(t):this.globalLogWarn(t)}log(t,...e){var n=y.apply(this,arguments);if(xe.log)xe.log(n);else if(xe.logToConsole){t.bind(this)(n)}}};class z extends H{constructor(t,e,n,i,s){super(),this.initialize=ae.transportConnectionInitializer,this.hooks=t,this.name=e,this.priority=n,this.key=i,this.options=s,this.state="new",this.timeline=s.timeline,this.activityTimeout=s.activityTimeout,this.id=this.timeline.generateUniqueID()}handlesActivityChecks(){return Boolean(this.hooks.handlesActivityChecks)}supportsPing(){return Boolean(this.hooks.supportsPing)}connect(){if(this.socket||"initialized"!==this.state)return!1;var t=this.hooks.urls.getInitial(this.key,this.options);try{this.socket=this.hooks.getSocket(t,this.options)}catch(t){return m.defer(()=>{this.onError(t),this.changeState("closed")}),!1}return this.bindListeners(),M.debug("Connecting",{transport:this.name,url:t}),this.changeState("connecting"),!0}close(){return!!this.socket&&(this.socket.close(),!0)}send(t){return"open"===this.state&&(m.defer(()=>{this.socket&&this.socket.send(t)}),!0)}ping(){"open"===this.state&&this.supportsPing()&&this.socket.ping()}onOpen(){this.hooks.beforeOpen&&this.hooks.beforeOpen(this.socket,this.hooks.urls.getPath(this.key,this.options)),this.changeState("open"),this.socket.onopen=void 0}onError(t){this.emit("error",{type:"WebSocketError",error:t}),this.timeline.error(this.buildTimelineMessage({error:t.toString()}))}onClose(t){t?this.changeState("closed",{code:t.code,reason:t.reason,wasClean:t.wasClean}):this.changeState("closed"),this.unbindListeners(),this.socket=void 0}onMessage(t){this.emit("message",t)}onActivity(){this.emit("activity")}bindListeners(){this.socket.onopen=()=>{this.onOpen()},this.socket.onerror=t=>{this.onError(t)},this.socket.onclose=t=>{this.onClose(t)},this.socket.onmessage=t=>{this.onMessage(t)},this.supportsPing()&&(this.socket.onactivity=()=>{this.onActivity()})}unbindListeners(){this.socket&&(this.socket.onopen=void 0,this.socket.onerror=void 0,this.socket.onclose=void 0,this.socket.onmessage=void 0,this.supportsPing()&&(this.socket.onactivity=void 0))}changeState(t,e){this.state=t,this.timeline.info(this.buildTimelineMessage({state:t,params:e})),this.emit(t,e)}buildTimelineMessage(t){return v({cid:this.id},t)}}class B{constructor(t){this.hooks=t}isSupported(t){return this.hooks.isSupported(t)}createConnection(t,e,n,i){return new z(this.hooks,t,e,n,i)}}var q=new B({urls:j,handlesActivityChecks:!1,supportsPing:!1,isInitialized:function(){return Boolean(ae.getWebSocketAPI())},isSupported:function(){return Boolean(ae.getWebSocketAPI())},getSocket:function(t){return ae.createWebSocket(t)}}),F={urls:D,handlesActivityChecks:!1,supportsPing:!0,isInitialized:function(){return!0}},$=v({getSocket:function(t){return ae.HTTPFactory.createStreamingSocket(t)}},F),J=v({getSocket:function(t){return ae.HTTPFactory.createPollingSocket(t)}},F),W={isSupported:function(){return ae.isXHRSupported()}},X={ws:q,xhr_streaming:new B(v({},$,W)),xhr_polling:new B(v({},J,W))};class G{constructor(t,e,n){this.manager=t,this.transport=e,this.minPingDelay=n.minPingDelay,this.maxPingDelay=n.maxPingDelay,this.pingDelay=void 0}createConnection(t,e,n,i){i=v({},i,{activityTimeout:this.pingDelay});var s=this.transport.createConnection(t,e,n,i),r=null,o=function(){s.unbind("open",o),s.bind("closed",a),r=m.now()},a=t=>{if(s.unbind("closed",a),1002===t.code||1003===t.code)this.manager.reportDeath();else if(!t.wasClean&&r){var e=m.now()-r;e<2*this.maxPingDelay&&(this.manager.reportDeath(),this.pingDelay=Math.max(e/2,this.minPingDelay))}};return s.bind("open",o),s}isSupported(t){return this.manager.isAlive()&&this.transport.isSupported(t)}}const V={decodeMessage:function(t){try{var e=JSON.parse(t.data),n=e.data;if("string"==typeof n)try{n=JSON.parse(e.data)}catch(t){}var i={event:e.event,channel:e.channel,data:n};return e.user_id&&(i.user_id=e.user_id),i}catch(e){throw{type:"MessageParseError",error:e,data:t.data}}},encodeMessage:function(t){return JSON.stringify(t)},processHandshake:function(t){var e=V.decodeMessage(t);if("pusher:connection_established"===e.event){if(!e.data.activity_timeout)throw"No activity timeout specified in handshake";return{action:"connected",id:e.data.socket_id,activityTimeout:1e3*e.data.activity_timeout}}if("pusher:error"===e.event)return{action:this.getCloseAction(e.data),error:this.getCloseError(e.data)};throw"Invalid handshake"},getCloseAction:function(t){return t.code<4e3?t.code>=1002&&t.code<=1004?"backoff":null:4e3===t.code?"tls_only":t.code<4100?"refused":t.code<4200?"backoff":t.code<4300?"retry":"refused"},getCloseError:function(t){return 1e3!==t.code&&1001!==t.code?{type:"PusherError",data:{code:t.code,message:t.reason||t.message}}:null}};var Y=V;class K extends H{constructor(t,e){super(),this.id=t,this.transport=e,this.activityTimeout=e.activityTimeout,this.bindListeners()}handlesActivityChecks(){return this.transport.handlesActivityChecks()}send(t){return this.transport.send(t)}send_event(t,e,n){var i={event:t,data:e};return n&&(i.channel=n),M.debug("Event sent",i),this.send(Y.encodeMessage(i))}ping(){this.transport.supportsPing()?this.transport.ping():this.send_event("pusher:ping",{})}close(){this.transport.close()}bindListeners(){var t={message:t=>{var e;try{e=Y.decodeMessage(t)}catch(e){this.emit("error",{type:"MessageParseError",error:e,data:t.data})}if(void 0!==e){switch(M.debug("Event recd",e),e.event){case"pusher:error":this.emit("error",{type:"PusherError",data:e.data});break;case"pusher:ping":this.emit("ping");break;case"pusher:pong":this.emit("pong")}this.emit("message",e)}},activity:()=>{this.emit("activity")},error:t=>{this.emit("error",t)},closed:t=>{e(),t&&t.code&&this.handleCloseEvent(t),this.transport=null,this.emit("closed")}},e=()=>{_(t,(t,e)=>{this.transport.unbind(e,t)})};_(t,(t,e)=>{this.transport.bind(e,t)})}handleCloseEvent(t){var e=Y.getCloseAction(t),n=Y.getCloseError(t);n&&this.emit("error",n),e&&this.emit(e,{action:e,error:n})}}class Q{constructor(t,e){this.transport=t,this.callback=e,this.bindListeners()}close(){this.unbindListeners(),this.transport.close()}bindListeners(){this.onMessage=t=>{var e;this.unbindListeners();try{e=Y.processHandshake(t)}catch(t){return this.finish("error",{error:t}),void this.transport.close()}"connected"===e.action?this.finish("connected",{connection:new K(e.id,this.transport),activityTimeout:e.activityTimeout}):(this.finish(e.action,{error:e.error}),this.transport.close())},this.onClosed=t=>{this.unbindListeners();var e=Y.getCloseAction(t)||"backoff",n=Y.getCloseError(t);this.finish(e,{error:n})},this.transport.bind("message",this.onMessage),this.transport.bind("closed",this.onClosed)}unbindListeners(){this.transport.unbind("message",this.onMessage),this.transport.unbind("closed",this.onClosed)}finish(t,e){this.callback(v({transport:this.transport,action:t},e))}}class Z{constructor(t,e){this.timeline=t,this.options=e||{}}send(t,e){this.timeline.isEmpty()||this.timeline.send(ae.TimelineTransport.getAgent(this,t),e)}}class tt extends Error{constructor(t){super(t),Object.setPrototypeOf(this,new.target.prototype)}}class et extends Error{constructor(t){super(t),Object.setPrototypeOf(this,new.target.prototype)}}Error;class nt extends Error{constructor(t){super(t),Object.setPrototypeOf(this,new.target.prototype)}}class it extends Error{constructor(t){super(t),Object.setPrototypeOf(this,new.target.prototype)}}class st extends Error{constructor(t){super(t),Object.setPrototypeOf(this,new.target.prototype)}}class rt extends Error{constructor(t){super(t),Object.setPrototypeOf(this,new.target.prototype)}}class ot extends Error{constructor(t){super(t),Object.setPrototypeOf(this,new.target.prototype)}}class at extends Error{constructor(t,e){super(e),this.status=t,Object.setPrototypeOf(this,new.target.prototype)}}const ct={baseUrl:"https://pusher.com",urls:{authenticationEndpoint:{path:"/docs/channels/server_api/authenticating_users"},authorizationEndpoint:{path:"/docs/channels/server_api/authorizing-users/"},javascriptQuickStart:{path:"/docs/javascript_quick_start"},triggeringClientEvents:{path:"/docs/client_api_guide/client_events#trigger-events"},encryptedChannelSupport:{fullUrl:"https://github.com/pusher/pusher-js/tree/cc491015371a4bde5743d1c87a0fbac0feb53195#encrypted-channel-support"}}};var ht=function(t){const e=ct.urls[t];if(!e)return"";let n;return e.fullUrl?n=e.fullUrl:e.path&&(n=ct.baseUrl+e.path),n?"See: "+n:""};class ut extends H{constructor(t,e){super((function(e,n){M.debug("No callbacks on "+t+" for "+e)})),this.name=t,this.pusher=e,this.subscribed=!1,this.subscriptionPending=!1,this.subscriptionCancelled=!1}authorize(t,e){return e(null,{auth:""})}trigger(t,e){if(0!==t.indexOf("client-"))throw new tt("Event '"+t+"' does not start with 'client-'");if(!this.subscribed){var n=ht("triggeringClientEvents");M.warn("Client event triggered before channel 'subscription_succeeded' event . "+n)}return this.pusher.send_event(t,e,this.name)}disconnect(){this.subscribed=!1,this.subscriptionPending=!1}handleEvent(t){var e=t.event,n=t.data;if("pusher_internal:subscription_succeeded"===e)this.handleSubscriptionSucceededEvent(t);else if("pusher_internal:subscription_count"===e)this.handleSubscriptionCountEvent(t);else if(0!==e.indexOf("pusher_internal:")){this.emit(e,n,{})}}handleSubscriptionSucceededEvent(t){this.subscriptionPending=!1,this.subscribed=!0,this.subscriptionCancelled?this.pusher.unsubscribe(this.name):this.emit("pusher:subscription_succeeded",t.data)}handleSubscriptionCountEvent(t){t.data.subscription_count&&(this.subscriptionCount=t.data.subscription_count),this.emit("pusher:subscription_count",t.data)}subscribe(){this.subscribed||(this.subscriptionPending=!0,this.subscriptionCancelled=!1,this.authorize(this.pusher.connection.socket_id,(t,e)=>{t?(this.subscriptionPending=!1,M.error(t.toString()),this.emit("pusher:subscription_error",Object.assign({},{type:"AuthError",error:t.message},t instanceof at?{status:t.status}:{}))):this.pusher.send_event("pusher:subscribe",{auth:e.auth,channel_data:e.channel_data,channel:this.name})}))}unsubscribe(){this.subscribed=!1,this.pusher.send_event("pusher:unsubscribe",{channel:this.name})}cancelSubscription(){this.subscriptionCancelled=!0}reinstateSubscription(){this.subscriptionCancelled=!1}}class lt extends ut{authorize(t,e){return this.pusher.config.channelAuthorizer({channelName:this.name,socketId:t},e)}}class dt{constructor(){this.reset()}get(t){return Object.prototype.hasOwnProperty.call(this.members,t)?{id:t,info:this.members[t]}:null}each(t){_(this.members,(e,n)=>{t(this.get(n))})}setMyID(t){this.myID=t}onSubscription(t){this.members=t.presence.hash,this.count=t.presence.count,this.me=this.get(this.myID)}addMember(t){return null===this.get(t.user_id)&&this.count++,this.members[t.user_id]=t.user_info,this.get(t.user_id)}removeMember(t){var e=this.get(t.user_id);return e&&(delete this.members[t.user_id],this.count--),e}reset(){this.members={},this.count=0,this.myID=null,this.me=null}}var pt=function(t,e,n,i){return new(n||(n=Promise))((function(s,r){function o(t){try{c(i.next(t))}catch(t){r(t)}}function a(t){try{c(i.throw(t))}catch(t){r(t)}}function c(t){var e;t.done?s(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(o,a)}c((i=i.apply(t,e||[])).next())}))};class ft extends lt{constructor(t,e){super(t,e),this.members=new dt}authorize(t,e){super.authorize(t,(t,n)=>pt(this,void 0,void 0,(function*(){if(!t)if(null!=(n=n).channel_data){var i=JSON.parse(n.channel_data);this.members.setMyID(i.user_id)}else{if(yield this.pusher.user.signinDonePromise,null==this.pusher.user.user_data){let t=ht("authorizationEndpoint");return M.error(`Invalid auth response for channel '${this.name}', expected 'channel_data' field. ${t}, or the user should be signed in.`),void e("Invalid auth response")}this.members.setMyID(this.pusher.user.user_data.id)}e(t,n)})))}handleEvent(t){var e=t.event;if(0===e.indexOf("pusher_internal:"))this.handleInternalEvent(t);else{var n=t.data,i={};t.user_id&&(i.user_id=t.user_id),this.emit(e,n,i)}}handleInternalEvent(t){var e=t.event,n=t.data;switch(e){case"pusher_internal:subscription_succeeded":this.handleSubscriptionSucceededEvent(t);break;case"pusher_internal:subscription_count":this.handleSubscriptionCountEvent(t);break;case"pusher_internal:member_added":var i=this.members.addMember(n);this.emit("pusher:member_added",i);break;case"pusher_internal:member_removed":var s=this.members.removeMember(n);s&&this.emit("pusher:member_removed",s)}}handleSubscriptionSucceededEvent(t){this.subscriptionPending=!1,this.subscribed=!0,this.subscriptionCancelled?this.pusher.unsubscribe(this.name):(this.members.onSubscription(t.data),this.emit("pusher:subscription_succeeded",this.members))}disconnect(){this.members.reset(),super.disconnect()}}var gt=n(1),bt=n(0);class mt extends lt{constructor(t,e,n){super(t,e),this.key=null,this.nacl=n}authorize(t,e){super.authorize(t,(t,n)=>{if(t)return void e(t,n);let i=n.shared_secret;i?(this.key=Object(bt.decode)(i),delete n.shared_secret,e(null,n)):e(new Error("No shared_secret key in auth payload for encrypted channel: "+this.name),null)})}trigger(t,e){throw new st("Client events are not currently supported for encrypted channels")}handleEvent(t){var e=t.event,n=t.data;0!==e.indexOf("pusher_internal:")&&0!==e.indexOf("pusher:")?this.handleEncryptedEvent(e,n):super.handleEvent(t)}handleEncryptedEvent(t,e){if(!this.key)return void M.debug("Received encrypted event before key has been retrieved from the authEndpoint");if(!e.ciphertext||!e.nonce)return void M.error("Unexpected format for encrypted event, expected object with `ciphertext` and `nonce` fields, got: "+e);let n=Object(bt.decode)(e.ciphertext);if(n.length{e?M.error(`Failed to make a request to the authEndpoint: ${r}. Unable to fetch new key, so dropping encrypted event`):(s=this.nacl.secretbox.open(n,i,this.key),null!==s?this.emit(t,this.getDataToEmit(s)):M.error("Failed to decrypt event with new key. Dropping encrypted event"))});this.emit(t,this.getDataToEmit(s))}getDataToEmit(t){let e=Object(gt.decode)(t);try{return JSON.parse(e)}catch(t){return e}}}class vt extends H{constructor(t,e){super(),this.state="initialized",this.connection=null,this.key=t,this.options=e,this.timeline=this.options.timeline,this.usingTLS=this.options.useTLS,this.errorCallbacks=this.buildErrorCallbacks(),this.connectionCallbacks=this.buildConnectionCallbacks(this.errorCallbacks),this.handshakeCallbacks=this.buildHandshakeCallbacks(this.errorCallbacks);var n=ae.getNetwork();n.bind("online",()=>{this.timeline.info({netinfo:"online"}),"connecting"!==this.state&&"unavailable"!==this.state||this.retryIn(0)}),n.bind("offline",()=>{this.timeline.info({netinfo:"offline"}),this.connection&&this.sendActivityCheck()}),this.updateStrategy()}switchCluster(t){this.key=t,this.updateStrategy(),this.retryIn(0)}connect(){this.connection||this.runner||(this.strategy.isSupported()?(this.updateState("connecting"),this.startConnecting(),this.setUnavailableTimer()):this.updateState("failed"))}send(t){return!!this.connection&&this.connection.send(t)}send_event(t,e,n){return!!this.connection&&this.connection.send_event(t,e,n)}disconnect(){this.disconnectInternally(),this.updateState("disconnected")}isUsingTLS(){return this.usingTLS}startConnecting(){var t=(e,n)=>{e?this.runner=this.strategy.connect(0,t):"error"===n.action?(this.emit("error",{type:"HandshakeError",error:n.error}),this.timeline.error({handshakeError:n.error})):(this.abortConnecting(),this.handshakeCallbacks[n.action](n))};this.runner=this.strategy.connect(0,t)}abortConnecting(){this.runner&&(this.runner.abort(),this.runner=null)}disconnectInternally(){(this.abortConnecting(),this.clearRetryTimer(),this.clearUnavailableTimer(),this.connection)&&this.abandonConnection().close()}updateStrategy(){this.strategy=this.options.getStrategy({key:this.key,timeline:this.timeline,useTLS:this.usingTLS})}retryIn(t){this.timeline.info({action:"retry",delay:t}),t>0&&this.emit("connecting_in",Math.round(t/1e3)),this.retryTimer=new g(t||0,()=>{this.disconnectInternally(),this.connect()})}clearRetryTimer(){this.retryTimer&&(this.retryTimer.ensureAborted(),this.retryTimer=null)}setUnavailableTimer(){this.unavailableTimer=new g(this.options.unavailableTimeout,()=>{this.updateState("unavailable")})}clearUnavailableTimer(){this.unavailableTimer&&this.unavailableTimer.ensureAborted()}sendActivityCheck(){this.stopActivityCheck(),this.connection.ping(),this.activityTimer=new g(this.options.pongTimeout,()=>{this.timeline.error({pong_timed_out:this.options.pongTimeout}),this.retryIn(0)})}resetActivityCheck(){this.stopActivityCheck(),this.connection&&!this.connection.handlesActivityChecks()&&(this.activityTimer=new g(this.activityTimeout,()=>{this.sendActivityCheck()}))}stopActivityCheck(){this.activityTimer&&this.activityTimer.ensureAborted()}buildConnectionCallbacks(t){return v({},t,{message:t=>{this.resetActivityCheck(),this.emit("message",t)},ping:()=>{this.send_event("pusher:pong",{})},activity:()=>{this.resetActivityCheck()},error:t=>{this.emit("error",t)},closed:()=>{this.abandonConnection(),this.shouldRetry()&&this.retryIn(1e3)}})}buildHandshakeCallbacks(t){return v({},t,{connected:t=>{this.activityTimeout=Math.min(this.options.activityTimeout,t.activityTimeout,t.connection.activityTimeout||1/0),this.clearUnavailableTimer(),this.setConnection(t.connection),this.socket_id=this.connection.id,this.updateState("connected",{socket_id:this.socket_id})}})}buildErrorCallbacks(){let t=t=>e=>{e.error&&this.emit("error",{type:"WebSocketError",error:e.error}),t(e)};return{tls_only:t(()=>{this.usingTLS=!0,this.updateStrategy(),this.retryIn(0)}),refused:t(()=>{this.disconnect()}),backoff:t(()=>{this.retryIn(1e3)}),retry:t(()=>{this.retryIn(0)})}}setConnection(t){for(var e in this.connection=t,this.connectionCallbacks)this.connection.bind(e,this.connectionCallbacks[e]);this.resetActivityCheck()}abandonConnection(){if(this.connection){for(var t in this.stopActivityCheck(),this.connectionCallbacks)this.connection.unbind(t,this.connectionCallbacks[t]);var e=this.connection;return this.connection=null,e}}updateState(t,e){var n=this.state;if(this.state=t,n!==t){var i=t;"connected"===i&&(i+=" with new socket ID "+e.socket_id),M.debug("State changed",n+" -> "+i),this.timeline.info({state:t,params:e}),this.emit("state_change",{previous:n,current:t}),this.emit(t,e)}}shouldRetry(){return"connecting"===this.state||"connected"===this.state}}class yt{constructor(){this.channels={}}add(t,e){return this.channels[t]||(this.channels[t]=function(t,e){if(0===t.indexOf("private-encrypted-")){if(e.config.nacl)return St.createEncryptedChannel(t,e,e.config.nacl);let n="Tried to subscribe to a private-encrypted- channel but no nacl implementation available",i=ht("encryptedChannelSupport");throw new st(`${n}. ${i}`)}if(0===t.indexOf("private-"))return St.createPrivateChannel(t,e);if(0===t.indexOf("presence-"))return St.createPresenceChannel(t,e);if(0===t.indexOf("#"))throw new et('Cannot create a channel with name "'+t+'".');return St.createChannel(t,e)}(t,e)),this.channels[t]}all(){return function(t){var e=[];return _(t,(function(t){e.push(t)})),e}(this.channels)}find(t){return this.channels[t]}remove(t){var e=this.channels[t];return delete this.channels[t],e}disconnect(){_(this.channels,(function(t){t.disconnect()}))}}var St={createChannels:()=>new yt,createConnectionManager:(t,e)=>new vt(t,e),createChannel:(t,e)=>new ut(t,e),createPrivateChannel:(t,e)=>new lt(t,e),createPresenceChannel:(t,e)=>new ft(t,e),createEncryptedChannel:(t,e,n)=>new mt(t,e,n),createTimelineSender:(t,e)=>new Z(t,e),createHandshake:(t,e)=>new Q(t,e),createAssistantToTheTransportManager:(t,e,n)=>new G(t,e,n)};class _t{constructor(t){this.options=t||{},this.livesLeft=this.options.lives||1/0}getAssistant(t){return St.createAssistantToTheTransportManager(this,t,{minPingDelay:this.options.minPingDelay,maxPingDelay:this.options.maxPingDelay})}isAlive(){return this.livesLeft>0}reportDeath(){this.livesLeft-=1}}class wt{constructor(t,e){this.strategies=t,this.loop=Boolean(e.loop),this.failFast=Boolean(e.failFast),this.timeout=e.timeout,this.timeoutLimit=e.timeoutLimit}isSupported(){return O(this.strategies,m.method("isSupported"))}connect(t,e){var n=this.strategies,i=0,s=this.timeout,r=null,o=(a,c)=>{c?e(null,c):(i+=1,this.loop&&(i%=n.length),i0&&(s=new g(n.timeout,(function(){r.abort(),i(!0)}))),r=t.connect(e,(function(t,e){t&&s&&s.isRunning()&&!n.failFast||(s&&s.ensureAborted(),i(t,e))})),{abort:function(){s&&s.ensureAborted(),r.abort()},forceMinPriority:function(t){r.forceMinPriority(t)}}}}class Ct{constructor(t){this.strategies=t}isSupported(){return O(this.strategies,m.method("isSupported"))}connect(t,e){return function(t,e,n){var i=k(t,(function(t,i,s,r){return t.connect(e,n(i,r))}));return{abort:function(){C(i,kt)},forceMinPriority:function(t){C(i,(function(e){e.forceMinPriority(t)}))}}}(this.strategies,t,(function(t,n){return function(i,s){n[t].error=i,i?function(t){return function(t,e){for(var n=0;n=m.now()){var o=this.transports[i.transport];o&&(["ws","wss"].includes(i.transport)||s>3?(this.timeline.info({cached:!0,transport:i.transport,latency:i.latency}),r.push(new wt([o],{timeout:2*i.latency+1e3,failFast:!0}))):s++)}var a=m.now(),c=r.pop().connect(t,(function i(o,h){o?(Ot(n),r.length>0?(a=m.now(),c=r.pop().connect(t,i)):e(o)):(!function(t,e,n,i){var s=ae.getLocalStorage();if(s)try{s[Pt(t)]=L({timestamp:m.now(),transport:e,latency:n,cacheSkipCount:i})}catch(t){}}(n,h.transport.name,m.now()-a,s),e(null,h))}));return{abort:function(){c.abort()},forceMinPriority:function(e){t=e,c&&c.forceMinPriority(e)}}}}function Pt(t){return"pusherTransport"+(t?"TLS":"NonTLS")}function Ot(t){var e=ae.getLocalStorage();if(e)try{delete e[Pt(t)]}catch(t){}}class Et{constructor(t,{delay:e}){this.strategy=t,this.options={delay:e}}isSupported(){return this.strategy.isSupported()}connect(t,e){var n,i=this.strategy,s=new g(this.options.delay,(function(){n=i.connect(t,e)}));return{abort:function(){s.ensureAborted(),n&&n.abort()},forceMinPriority:function(e){t=e,n&&n.forceMinPriority(e)}}}}class xt{constructor(t,e,n){this.test=t,this.trueBranch=e,this.falseBranch=n}isSupported(){return(this.test()?this.trueBranch:this.falseBranch).isSupported()}connect(t,e){return(this.test()?this.trueBranch:this.falseBranch).connect(t,e)}}class Lt{constructor(t){this.strategy=t}isSupported(){return this.strategy.isSupported()}connect(t,e){var n=this.strategy.connect(t,(function(t,i){i&&n.abort(),e(t,i)}));return n}}function At(t){return function(){return t.isSupported()}}var Rt=function(t,e,n){var i={};function s(e,s,r,o,a){var c=n(t,e,s,r,o,a);return i[e]=c,c}var r,o=Object.assign({},e,{hostNonTLS:t.wsHost+":"+t.wsPort,hostTLS:t.wsHost+":"+t.wssPort,httpPath:t.wsPath}),a=v({},o,{useTLS:!0}),c=Object.assign({},e,{hostNonTLS:t.httpHost+":"+t.httpPort,hostTLS:t.httpHost+":"+t.httpsPort,httpPath:t.httpPath}),h={loop:!0,timeout:15e3,timeoutLimit:6e4},u=new _t({minPingDelay:1e4,maxPingDelay:t.activityTimeout}),l=new _t({lives:2,minPingDelay:1e4,maxPingDelay:t.activityTimeout}),d=s("ws","ws",3,o,u),p=s("wss","ws",3,a,u),f=s("xhr_streaming","xhr_streaming",1,c,l),g=s("xhr_polling","xhr_polling",1,c),b=new wt([d],h),m=new wt([p],h),y=new wt([f],h),S=new wt([g],h),_=new wt([new xt(At(y),new Ct([y,new Et(S,{delay:4e3})]),S)],h);return r=e.useTLS?new Ct([b,new Et(_,{delay:2e3})]):new Ct([b,new Et(m,{delay:2e3}),new Et(_,{delay:5e3})]),new Tt(new Lt(new xt(At(d),r,_)),i,{ttl:18e5,timeline:e.timeline,useTLS:e.useTLS})};class It extends H{constructor(t,e,n){super(),this.hooks=t,this.method=e,this.url=n}start(t){this.position=0,this.xhr=this.hooks.getRequest(this),this.unloader=()=>{this.close()},ae.addUnloadListener(this.unloader),this.xhr.open(this.method,this.url,!0),this.xhr.setRequestHeader&&this.xhr.setRequestHeader("Content-Type","application/json"),this.xhr.send(t)}close(){this.unloader&&(ae.removeUnloadListener(this.unloader),this.unloader=null),this.xhr&&(this.hooks.abortRequest(this.xhr),this.xhr=null)}onChunk(t,e){for(;;){var n=this.advanceBuffer(e);if(!n)break;this.emit("chunk",{status:t,data:n})}this.isBufferTooLong(e)&&this.emit("buffer_too_long")}advanceBuffer(t){var e=t.slice(this.position),n=e.indexOf("\n");return-1!==n?(this.position+=n+1,e.slice(0,n)):null}isBufferTooLong(t){return this.position===t.length&&t.length>262144}}var jt;!function(t){t[t.CONNECTING=0]="CONNECTING",t[t.OPEN=1]="OPEN",t[t.CLOSED=3]="CLOSED"}(jt||(jt={}));var Dt=jt,Nt=1;function Ut(t){var e=-1===t.indexOf("?")?"?":"&";return t+e+"t="+ +new Date+"&n="+Nt++}function Ht(t){return ae.randomInt(t)}var Mt=class{constructor(t,e){this.hooks=t,this.session=Ht(1e3)+"/"+function(t){for(var e=[],n=0;n{this.onChunk(t)}),this.stream.bind("finished",t=>{this.hooks.onFinished(this,t)}),this.stream.bind("buffer_too_long",()=>{this.reconnect()});try{this.stream.start()}catch(t){m.defer(()=>{this.onError(t),this.onClose(1006,"Could not start streaming",!1)})}}closeStream(){this.stream&&(this.stream.unbind_all(),this.stream.close(),this.stream=null)}},zt={getReceiveURL:function(t,e){return t.base+"/"+e+"/xhr_streaming"+t.queryString},onHeartbeat:function(t){t.sendRaw("[]")},sendHeartbeat:function(t){t.sendRaw("[]")},onFinished:function(t,e){t.onClose(1006,"Connection interrupted ("+e+")",!1)}},Bt={getReceiveURL:function(t,e){return t.base+"/"+e+"/xhr"+t.queryString},onHeartbeat:function(){},sendHeartbeat:function(t){t.sendRaw("[]")},onFinished:function(t,e){200===e?t.reconnect():t.onClose(1006,"Connection interrupted ("+e+")",!1)}},qt={getRequest:function(t){var e=new(ae.getXHRAPI());return e.onreadystatechange=e.onprogress=function(){switch(e.readyState){case 3:e.responseText&&e.responseText.length>0&&t.onChunk(e.status,e.responseText);break;case 4:e.responseText&&e.responseText.length>0&&t.onChunk(e.status,e.responseText),t.emit("finished",e.status),t.close()}},e},abortRequest:function(t){t.onreadystatechange=null,t.abort()}},Ft={getDefaultStrategy:Rt,Transports:X,transportConnectionInitializer:function(){this.timeline.info(this.buildTimelineMessage({transport:this.name+(this.options.useTLS?"s":"")})),this.hooks.isInitialized()?this.changeState("initialized"):this.onClose()},HTTPFactory:{createStreamingSocket(t){return this.createSocket(zt,t)},createPollingSocket(t){return this.createSocket(Bt,t)},createSocket:(t,e)=>new Mt(t,e),createXHR(t,e){return this.createRequest(qt,t,e)},createRequest:(t,e,n)=>new It(t,e,n)},setup(t){t.ready()},getLocalStorage(){},getClientFeatures:()=>w(P({ws:X.ws},(function(t){return t.isSupported({})}))),getProtocol:()=>"http:",isXHRSupported:()=>!0,createSocketRequest(t,e){if(this.isXHRSupported())return this.HTTPFactory.createXHR(t,e);throw"Cross-origin HTTP requests are not supported"},createXHR(){return new(this.getXHRAPI())},createWebSocket(t){return new(this.getWebSocketAPI())(t)},addUnloadListener(t){},removeUnloadListener(t){}};var $t=new class extends H{isOnline(){return!0}},Jt=function(t,e,n,i,s){var r=new Headers;for(var o in r.set("Content-Type","application/x-www-form-urlencoded"),n.headers)r.set(o,n.headers[o]);if(null!=n.headersProvider){const t=n.headersProvider();for(var o in t)r.set(o,t[o])}var a=e,c=new Request(n.endpoint,{headers:r,body:a,credentials:"same-origin",method:"POST"});return fetch(c).then(t=>{let{status:e}=t;if(200===e)return t.text();throw new at(e,`Could not get ${i.toString()} info from your auth endpoint, status: ${e}`)}).then(t=>{let e;try{e=JSON.parse(t)}catch(e){throw new at(200,`JSON returned from ${i.toString()} endpoint was invalid, yet status code was 200. Data was: ${t}`)}s(null,e)}).catch(t=>{s(t,null)})},Wt={name:"xhr",getAgent:function(t,e){return function(n,i){var s="http"+(e?"s":"")+"://"+(t.host||t.options.host)+t.options.path,r=x(n);fetch(s+="/2?"+r).then(t=>{if(200!==t.status)throw`received ${t.status} from stats.pusher.com`;return t.json()}).then(({host:e})=>{e&&(t.host=e)}).catch(t=>{M.debug("TimelineSender Error: ",t)})}}};const{getDefaultStrategy:Xt,Transports:Gt,setup:Vt,getProtocol:Yt,isXHRSupported:Kt,getLocalStorage:Qt,createXHR:Zt,createWebSocket:te,addUnloadListener:ee,removeUnloadListener:ne,transportConnectionInitializer:ie,createSocketRequest:se,HTTPFactory:re}=Ft;var oe,ae={getDefaultStrategy:Xt,Transports:Gt,setup:Vt,getProtocol:Yt,isXHRSupported:Kt,getLocalStorage:Qt,createXHR:Zt,createWebSocket:te,addUnloadListener:ee,removeUnloadListener:ne,transportConnectionInitializer:ie,createSocketRequest:se,HTTPFactory:re,TimelineTransport:Wt,getAuthorizers:()=>({ajax:Jt}),getWebSocketAPI:()=>WebSocket,getXHRAPI:()=>XMLHttpRequest,getNetwork:()=>$t,randomInt:t=>Math.floor((globalThis.crypto||globalThis.msCrypto).getRandomValues(new Uint32Array(1))[0]/Math.pow(2,32)*t)};!function(t){t[t.ERROR=3]="ERROR",t[t.INFO=6]="INFO",t[t.DEBUG=7]="DEBUG"}(oe||(oe={}));var ce=oe;class he{constructor(t,e,n){this.key=t,this.session=e,this.events=[],this.options=n||{},this.sent=0,this.uniqueID=0}log(t,e){t<=this.options.level&&(this.events.push(v({},e,{timestamp:m.now()})),this.options.limit&&this.events.length>this.options.limit&&this.events.shift())}error(t){this.log(ce.ERROR,t)}info(t){this.log(ce.INFO,t)}debug(t){this.log(ce.DEBUG,t)}isEmpty(){return 0===this.events.length}send(t,e){var n=v({session:this.session,bundle:this.sent+1,key:this.key,lib:"js",version:this.options.version,cluster:this.options.cluster,features:this.options.features,timeline:this.events},this.options.params);return this.events=[],t(n,(t,n)=>{t||this.sent++,e&&e(t,n)}),!0}generateUniqueID(){return this.uniqueID++,this.uniqueID}}class ue{constructor(t,e,n,i){this.name=t,this.priority=e,this.transport=n,this.options=i||{}}isSupported(){return this.transport.isSupported({useTLS:this.options.useTLS})}connect(t,e){if(!this.isSupported())return le(new ot,e);if(this.priority{n||(h(),s?s.close():i.close())},forceMinPriority:t=>{n||this.priority{if(void 0===ae.getAuthorizers()[t.transport])throw`'${t.transport}' is not a recognized auth transport`;return(e,n)=>{const i=((t,e)=>{var n="socket_id="+encodeURIComponent(t.socketId);for(var i in e.params)n+="&"+encodeURIComponent(i)+"="+encodeURIComponent(e.params[i]);if(null!=e.paramsProvider){let t=e.paramsProvider();for(var i in t)n+="&"+encodeURIComponent(i)+"="+encodeURIComponent(t[i])}return n})(e,t);ae.getAuthorizers()[t.transport](ae,i,t,pe.UserAuthentication,n)}};var me=t=>{if(void 0===ae.getAuthorizers()[t.transport])throw`'${t.transport}' is not a recognized auth transport`;return(e,n)=>{const i=((t,e)=>{var n="socket_id="+encodeURIComponent(t.socketId);for(var i in n+="&channel_name="+encodeURIComponent(t.channelName),e.params)n+="&"+encodeURIComponent(i)+"="+encodeURIComponent(e.params[i]);if(null!=e.paramsProvider){let t=e.paramsProvider();for(var i in t)n+="&"+encodeURIComponent(i)+"="+encodeURIComponent(t[i])}return n})(e,t);ae.getAuthorizers()[t.transport](ae,i,t,pe.ChannelAuthorization,n)}};function ve(t,e){let n={activityTimeout:t.activityTimeout||A.activityTimeout,cluster:t.cluster,httpPath:t.httpPath||A.httpPath,httpPort:t.httpPort||A.httpPort,httpsPort:t.httpsPort||A.httpsPort,pongTimeout:t.pongTimeout||A.pongTimeout,statsHost:t.statsHost||A.stats_host,unavailableTimeout:t.unavailableTimeout||A.unavailableTimeout,wsPath:t.wsPath||A.wsPath,wsPort:t.wsPort||A.wsPort,wssPort:t.wssPort||A.wssPort,enableStats:we(t),httpHost:ye(t),useTLS:_e(t),wsHost:Se(t),userAuthenticator:Ce(t),channelAuthorizer:ke(t,e)};return"disabledTransports"in t&&(n.disabledTransports=t.disabledTransports),"enabledTransports"in t&&(n.enabledTransports=t.enabledTransports),"ignoreNullOrigin"in t&&(n.ignoreNullOrigin=t.ignoreNullOrigin),"timelineParams"in t&&(n.timelineParams=t.timelineParams),"nacl"in t&&(n.nacl=t.nacl),n}function ye(t){return t.httpHost?t.httpHost:t.cluster?`sockjs-${t.cluster}.pusher.com`:A.httpHost}function Se(t){return t.wsHost?t.wsHost:`ws-${t.cluster}.pusher.com`}function _e(t){return"https:"===ae.getProtocol()||!1!==t.forceTLS}function we(t){return"enableStats"in t?t.enableStats:"disableStats"in t&&!t.disableStats}function Ce(t){const e=Object.assign(Object.assign({},A.userAuthentication),t.userAuthentication);return"customHandler"in e&&null!=e.customHandler?e.customHandler:be(e)}function ke(t,e){const n=function(t,e){let n;return"channelAuthorization"in t?n=Object.assign(Object.assign({},A.channelAuthorization),t.channelAuthorization):(n={transport:t.authTransport||A.authTransport,endpoint:t.authEndpoint||A.authEndpoint},"auth"in t&&("params"in t.auth&&(n.params=t.auth.params),"headers"in t.auth&&(n.headers=t.auth.headers)),"authorizer"in t&&(n.customHandler=((t,e,n)=>{const i={authTransport:e.transport,authEndpoint:e.endpoint,auth:{params:e.params,headers:e.headers}};return(e,s)=>{const r=t.channel(e.channelName);n(r,i).authorize(e.socketId,s)}})(e,n,t.authorizer))),n}(t,e);return"customHandler"in n&&null!=n.customHandler?n.customHandler:me(n)}class Te extends H{constructor(t){super((function(t,e){M.debug("No callbacks on watchlist events for "+t)})),this.pusher=t,this.bindWatchlistInternalEvent()}handleEvent(t){t.data.events.forEach(t=>{this.emit(t.name,t)})}bindWatchlistInternalEvent(){this.pusher.connection.bind("message",t=>{"pusher_internal:watchlist_events"===t.event&&this.handleEvent(t)})}}var Pe=function(){let t,e;return{promise:new Promise((n,i)=>{t=n,e=i}),resolve:t,reject:e}};class Oe extends H{constructor(t){super((function(t,e){M.debug("No callbacks on user for "+t)})),this.signin_requested=!1,this.user_data=null,this.serverToUserChannel=null,this.signinDonePromise=null,this._signinDoneResolve=null,this._onAuthorize=(t,e)=>{if(t)return M.warn("Error during signin: "+t),void this._cleanup();this.pusher.send_event("pusher:signin",{auth:e.auth,user_data:e.user_data})},this.pusher=t,this.pusher.connection.bind("state_change",({previous:t,current:e})=>{"connected"!==t&&"connected"===e&&this._signin(),"connected"===t&&"connected"!==e&&(this._cleanup(),this._newSigninPromiseIfNeeded())}),this.watchlist=new Te(t),this.pusher.connection.bind("message",t=>{"pusher:signin_success"===t.event&&this._onSigninSuccess(t.data),this.serverToUserChannel&&this.serverToUserChannel.name===t.channel&&this.serverToUserChannel.handleEvent(t)})}signin(){this.signin_requested||(this.signin_requested=!0,this._signin())}_signin(){this.signin_requested&&(this._newSigninPromiseIfNeeded(),"connected"===this.pusher.connection.state&&this.pusher.config.userAuthenticator({socketId:this.pusher.connection.socket_id},this._onAuthorize))}_onSigninSuccess(t){try{this.user_data=JSON.parse(t.user_data)}catch(e){return M.error("Failed parsing user data after signin: "+t.user_data),void this._cleanup()}if("string"!=typeof this.user_data.id||""===this.user_data.id)return M.error("user_data doesn't contain an id. user_data: "+this.user_data),void this._cleanup();this._signinDoneResolve(),this._subscribeChannels()}_subscribeChannels(){this.serverToUserChannel=new ut("#server-to-user-"+this.user_data.id,this.pusher),this.serverToUserChannel.bind_global((t,e)=>{0!==t.indexOf("pusher_internal:")&&0!==t.indexOf("pusher:")&&this.emit(t,e)}),(t=>{t.subscriptionPending&&t.subscriptionCancelled?t.reinstateSubscription():t.subscriptionPending||"connected"!==this.pusher.connection.state||t.subscribe()})(this.serverToUserChannel)}_cleanup(){this.user_data=null,this.serverToUserChannel&&(this.serverToUserChannel.unbind_all(),this.serverToUserChannel.disconnect(),this.serverToUserChannel=null),this.signin_requested&&this._signinDoneResolve()}_newSigninPromiseIfNeeded(){if(!this.signin_requested)return;if(this.signinDonePromise&&!this.signinDonePromise.done)return;const{promise:t,resolve:e,reject:n}=Pe();t.done=!1;const i=()=>{t.done=!0};t.then(i).catch(i),this.signinDonePromise=t,this._signinDoneResolve=e}}class Ee{static ready(){Ee.isReady=!0;for(var t=0,e=Ee.instances.length;tae.getDefaultStrategy(this.config,t,fe),timeline:this.timeline,activityTimeout:this.config.activityTimeout,pongTimeout:this.config.pongTimeout,unavailableTimeout:this.config.unavailableTimeout,useTLS:Boolean(this.config.useTLS)}),this.connection.bind("connected",()=>{this.subscribeAll(),this.timelineSender&&this.timelineSender.send(this.connection.isUsingTLS())}),this.connection.bind("message",t=>{var e=0===t.event.indexOf("pusher_internal:");if(t.channel){var n=this.channel(t.channel);n&&n.handleEvent(t)}e||this.global_emitter.emit(t.event,t.data)}),this.connection.bind("connecting",()=>{this.channels.disconnect()}),this.connection.bind("disconnected",()=>{this.channels.disconnect()}),this.connection.bind("error",t=>{M.warn(t)}),Ee.instances.push(this),this.timeline.info({instances:Ee.instances.length}),this.user=new Oe(this),Ee.isReady&&this.connect()}switchCluster(t){const{appKey:e,cluster:n}=t;this.key=e,this.options=Object.assign(Object.assign({},this.options),{cluster:n}),this.config=ve(this.options,this),this.connection.switchCluster(this.key)}channel(t){return this.channels.find(t)}allChannels(){return this.channels.all()}connect(){if(this.connection.connect(),this.timelineSender&&!this.timelineSenderTimer){var t=this.connection.isUsingTLS(),e=this.timelineSender;this.timelineSenderTimer=new b(6e4,(function(){e.send(t)}))}}disconnect(){this.connection.disconnect(),this.timelineSenderTimer&&(this.timelineSenderTimer.ensureAborted(),this.timelineSenderTimer=null)}bind(t,e,n){return this.global_emitter.bind(t,e,n),this}unbind(t,e,n){return this.global_emitter.unbind(t,e,n),this}bind_global(t){return this.global_emitter.bind_global(t),this}unbind_global(t){return this.global_emitter.unbind_global(t),this}unbind_all(t){return this.global_emitter.unbind_all(),this}subscribeAll(){var t;for(t in this.channels.channels)this.channels.channels.hasOwnProperty(t)&&this.subscribe(t)}subscribe(t){var e=this.channels.add(t,this);return e.subscriptionPending&&e.subscriptionCancelled?e.reinstateSubscription():e.subscriptionPending||"connected"!==this.connection.state||e.subscribe(),e}unsubscribe(t){var e=this.channels.find(t);e&&e.subscriptionPending?e.cancelSubscription():(e=this.channels.remove(t))&&e.subscribed&&e.unsubscribe()}send_event(t,e,n){return this.connection.send_event(t,e,n)}shouldUseTLS(){return this.config.useTLS}signin(){this.user.signin()}}Ee.instances=[],Ee.isReady=!1,Ee.logToConsole=!1,Ee.Runtime=ae,Ee.ScriptReceivers=ae.ScriptReceivers,Ee.DependenciesReceivers=ae.DependenciesReceivers,Ee.auth_callbacks=ae.auth_callbacks;var xe=e.default=Ee;ae.setup(Ee)}])})); +!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.Pusher=e():t.Pusher=e()}(this,(function(){return function(t){var e={};function n(i){if(e[i])return e[i].exports;var s=e[i]={i:i,l:!1,exports:{}};return t[i].call(s.exports,s,s.exports,n),s.l=!0,s.exports}return n.m=t,n.c=e,n.d=function(t,e,i){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:i})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var i=Object.create(null);if(n.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var s in t)n.d(i,s,function(e){return t[e]}.bind(null,s));return i},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=2)}([function(t,e,n){"use strict";var i,s=this&&this.__extends||(i=function(t,e){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)},function(t,e){function n(){this.constructor=t}i(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)});Object.defineProperty(e,"__esModule",{value:!0});var r=function(){function t(t){void 0===t&&(t="="),this._paddingCharacter=t}return t.prototype.encodedLength=function(t){return this._paddingCharacter?(t+2)/3*4|0:(8*t+5)/6|0},t.prototype.encode=function(t){for(var e="",n=0;n>>18&63),e+=this._encodeByte(i>>>12&63),e+=this._encodeByte(i>>>6&63),e+=this._encodeByte(i>>>0&63)}var s=t.length-n;if(s>0){i=t[n]<<16|(2===s?t[n+1]<<8:0);e+=this._encodeByte(i>>>18&63),e+=this._encodeByte(i>>>12&63),e+=2===s?this._encodeByte(i>>>6&63):this._paddingCharacter||"",e+=this._paddingCharacter||""}return e},t.prototype.maxDecodedLength=function(t){return this._paddingCharacter?t/4*3|0:(6*t+7)/8|0},t.prototype.decodedLength=function(t){return this.maxDecodedLength(t.length-this._getPaddingLength(t))},t.prototype.decode=function(t){if(0===t.length)return new Uint8Array(0);for(var e=this._getPaddingLength(t),n=t.length-e,i=new Uint8Array(this.maxDecodedLength(n)),s=0,r=0,o=0,a=0,c=0,h=0,u=0;r>>4,i[s++]=c<<4|h>>>2,i[s++]=h<<6|u,o|=256&a,o|=256&c,o|=256&h,o|=256&u;if(r>>4,o|=256&a,o|=256&c),r>>2,o|=256&h),r>>8&6,e+=51-t>>>8&-75,e+=61-t>>>8&-15,e+=62-t>>>8&3,String.fromCharCode(e)},t.prototype._decodeChar=function(t){var e=256;return e+=(42-t&t-44)>>>8&-256+t-43+62,e+=(46-t&t-48)>>>8&-256+t-47+63,e+=(47-t&t-58)>>>8&-256+t-48+52,e+=(64-t&t-91)>>>8&-256+t-65+0,e+=(96-t&t-123)>>>8&-256+t-97+26},t.prototype._getPaddingLength=function(t){var e=0;if(this._paddingCharacter){for(var n=t.length-1;n>=0&&t[n]===this._paddingCharacter;n--)e++;if(t.length<4||e>2)throw new Error("Base64Coder: incorrect padding")}return e},t}();e.Coder=r;var o=new r;e.encode=function(t){return o.encode(t)},e.decode=function(t){return o.decode(t)};var a=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return s(e,t),e.prototype._encodeByte=function(t){var e=t;return e+=65,e+=25-t>>>8&6,e+=51-t>>>8&-75,e+=61-t>>>8&-13,e+=62-t>>>8&49,String.fromCharCode(e)},e.prototype._decodeChar=function(t){var e=256;return e+=(44-t&t-46)>>>8&-256+t-45+62,e+=(94-t&t-96)>>>8&-256+t-95+63,e+=(47-t&t-58)>>>8&-256+t-48+52,e+=(64-t&t-91)>>>8&-256+t-65+0,e+=(96-t&t-123)>>>8&-256+t-97+26},e}(r);e.URLSafeCoder=a;var c=new a;e.encodeURLSafe=function(t){return c.encode(t)},e.decodeURLSafe=function(t){return c.decode(t)},e.encodedLength=function(t){return o.encodedLength(t)},e.maxDecodedLength=function(t){return o.maxDecodedLength(t)},e.decodedLength=function(t){return o.decodedLength(t)}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i="utf8: invalid source encoding";function s(t){for(var e=0,n=0;n=t.length-1)throw new Error("utf8: invalid string");n++,e+=4}}return e}e.encode=function(t){for(var e=new Uint8Array(s(t)),n=0,i=0;i>6,e[n++]=128|63&r):r<55296?(e[n++]=224|r>>12,e[n++]=128|r>>6&63,e[n++]=128|63&r):(i++,r=(1023&r)<<10,r|=1023&t.charCodeAt(i),r+=65536,e[n++]=240|r>>18,e[n++]=128|r>>12&63,e[n++]=128|r>>6&63,e[n++]=128|63&r)}return e},e.encodedLength=s,e.decode=function(t){for(var e=[],n=0;n=t.length)throw new Error(i);if(128!=(192&(o=t[++n])))throw new Error(i);s=(31&s)<<6|63&o,r=128}else if(s<240){if(n>=t.length-1)throw new Error(i);var o=t[++n],a=t[++n];if(128!=(192&o)||128!=(192&a))throw new Error(i);s=(15&s)<<12|(63&o)<<6|63&a,r=2048}else{if(!(s<248))throw new Error(i);if(n>=t.length-2)throw new Error(i);o=t[++n],a=t[++n];var c=t[++n];if(128!=(192&o)||128!=(192&a)||128!=(192&c))throw new Error(i);s=(15&s)<<18|(63&o)<<12|(63&a)<<6|63&c,r=65536}if(s=55296&&s<=57343)throw new Error(i);if(s>=65536){if(s>1114111)throw new Error(i);s-=65536,e.push(String.fromCharCode(55296|s>>10)),s=56320|1023&s}}e.push(String.fromCharCode(s))}return e.join("")}},function(t,e,n){t.exports=n(3).default},function(t,e,n){"use strict";n.r(e);for(var i=String.fromCharCode,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",r={},o=0,a=s.length;o>>6)+i(128|63&e):i(224|e>>>12&15)+i(128|e>>>6&63)+i(128|63&e)},h=function(t){return t.replace(/[^\x00-\x7F]/g,c)},u=function(t){var e=[0,2,1][t.length%3],n=t.charCodeAt(0)<<16|(t.length>1?t.charCodeAt(1):0)<<8|(t.length>2?t.charCodeAt(2):0);return[s.charAt(n>>>18),s.charAt(n>>>12&63),e>=2?"=":s.charAt(n>>>6&63),e>=1?"=":s.charAt(63&n)].join("")},l=self.btoa||function(t){return t.replace(/[\s\S]{1,3}/g,u)};var d=class{constructor(t,e,n,i){this.clear=e,this.timer=t(()=>{this.timer&&(this.timer=i(this.timer))},n)}isRunning(){return null!==this.timer}ensureAborted(){this.timer&&(this.clear(this.timer),this.timer=null)}};function p(t){self.clearTimeout(t)}function f(t){self.clearInterval(t)}class g extends d{constructor(t,e){super(setTimeout,p,t,(function(t){return e(),null}))}}class b extends d{constructor(t,e){super(setInterval,f,t,(function(t){return e(),t}))}}var m={now:()=>Date.now?Date.now():(new Date).valueOf(),defer:t=>new g(0,t),method(t,...e){var n=Array.prototype.slice.call(arguments,1);return function(e){return e[t].apply(e,n.concat(arguments))}}};function v(t,...e){for(var n=0;ne!==t),this):(this.global_callbacks=[],this)}unbind_all(){return this.unbind(),this.unbind_global(),this}emit(t,e,n){for(var i=0;i0)for(i=0;i{self.console&&self.console.log&&self.console.log(t)}}debug(...t){this.log(this.globalLog,t)}warn(...t){this.log(this.globalLogWarn,t)}error(...t){this.log(this.globalLogError,t)}globalLogWarn(t){self.console&&self.console.warn?self.console.warn(t):this.globalLog(t)}globalLogError(t){self.console&&self.console.error?self.console.error(t):this.globalLogWarn(t)}log(t,...e){var n=y.apply(this,arguments);if(Ae.log)Ae.log(n);else if(Ae.logToConsole){t.bind(this)(n)}}};class z extends H{constructor(t,e,n,i,s){super(),this.initialize=ae.transportConnectionInitializer,this.hooks=t,this.name=e,this.priority=n,this.key=i,this.options=s,this.state="new",this.timeline=s.timeline,this.activityTimeout=s.activityTimeout,this.id=this.timeline.generateUniqueID()}handlesActivityChecks(){return Boolean(this.hooks.handlesActivityChecks)}supportsPing(){return Boolean(this.hooks.supportsPing)}connect(){if(this.socket||"initialized"!==this.state)return!1;var t=this.hooks.urls.getInitial(this.key,this.options);try{this.socket=this.hooks.getSocket(t,this.options)}catch(t){return m.defer(()=>{this.onError(t),this.changeState("closed")}),!1}return this.bindListeners(),M.debug("Connecting",{transport:this.name,url:t}),this.changeState("connecting"),!0}close(){return!!this.socket&&(this.socket.close(),!0)}send(t){return"open"===this.state&&(m.defer(()=>{this.socket&&this.socket.send(t)}),!0)}ping(){"open"===this.state&&this.supportsPing()&&this.socket.ping()}onOpen(){this.hooks.beforeOpen&&this.hooks.beforeOpen(this.socket,this.hooks.urls.getPath(this.key,this.options)),this.changeState("open"),this.socket.onopen=void 0}onError(t){this.emit("error",{type:"WebSocketError",error:t}),this.timeline.error(this.buildTimelineMessage({error:t.toString()}))}onClose(t){t?this.changeState("closed",{code:t.code,reason:t.reason,wasClean:t.wasClean}):this.changeState("closed"),this.unbindListeners(),this.socket=void 0}onMessage(t){this.emit("message",t)}onActivity(){this.emit("activity")}bindListeners(){this.socket.onopen=()=>{this.onOpen()},this.socket.onerror=t=>{this.onError(t)},this.socket.onclose=t=>{this.onClose(t)},this.socket.onmessage=t=>{this.onMessage(t)},this.supportsPing()&&(this.socket.onactivity=()=>{this.onActivity()})}unbindListeners(){this.socket&&(this.socket.onopen=void 0,this.socket.onerror=void 0,this.socket.onclose=void 0,this.socket.onmessage=void 0,this.supportsPing()&&(this.socket.onactivity=void 0))}changeState(t,e){this.state=t,this.timeline.info(this.buildTimelineMessage({state:t,params:e})),this.emit(t,e)}buildTimelineMessage(t){return v({cid:this.id},t)}}class B{constructor(t){this.hooks=t}isSupported(t){return this.hooks.isSupported(t)}createConnection(t,e,n,i){return new z(this.hooks,t,e,n,i)}}var q=new B({urls:j,handlesActivityChecks:!1,supportsPing:!1,isInitialized:function(){return Boolean(ae.getWebSocketAPI())},isSupported:function(){return Boolean(ae.getWebSocketAPI())},getSocket:function(t){return ae.createWebSocket(t)}}),F={urls:D,handlesActivityChecks:!1,supportsPing:!0,isInitialized:function(){return!0}},$=v({getSocket:function(t){return ae.HTTPFactory.createStreamingSocket(t)}},F),J=v({getSocket:function(t){return ae.HTTPFactory.createPollingSocket(t)}},F),W={isSupported:function(){return ae.isXHRSupported()}},X={ws:q,xhr_streaming:new B(v({},$,W)),xhr_polling:new B(v({},J,W))};class G{constructor(t,e,n){this.manager=t,this.transport=e,this.minPingDelay=n.minPingDelay,this.maxPingDelay=n.maxPingDelay,this.pingDelay=void 0}createConnection(t,e,n,i){i=v({},i,{activityTimeout:this.pingDelay});var s=this.transport.createConnection(t,e,n,i),r=null,o=function(){s.unbind("open",o),s.bind("closed",a),r=m.now()},a=t=>{if(s.unbind("closed",a),1002===t.code||1003===t.code)this.manager.reportDeath();else if(!t.wasClean&&r){var e=m.now()-r;e<2*this.maxPingDelay&&(this.manager.reportDeath(),this.pingDelay=Math.max(e/2,this.minPingDelay))}};return s.bind("open",o),s}isSupported(t){return this.manager.isAlive()&&this.transport.isSupported(t)}}const V={decodeMessage:function(t){try{var e=JSON.parse(t.data),n=e.data;if("string"==typeof n)try{n=JSON.parse(e.data)}catch(t){}var i={event:e.event,channel:e.channel,data:n};return e.user_id&&(i.user_id=e.user_id),i}catch(e){throw{type:"MessageParseError",error:e,data:t.data}}},encodeMessage:function(t){return JSON.stringify(t)},processHandshake:function(t){var e=V.decodeMessage(t);if("pusher:connection_established"===e.event){if(!e.data.activity_timeout)throw"No activity timeout specified in handshake";return{action:"connected",id:e.data.socket_id,activityTimeout:1e3*e.data.activity_timeout}}if("pusher:error"===e.event)return{action:this.getCloseAction(e.data),error:this.getCloseError(e.data)};throw"Invalid handshake"},getCloseAction:function(t){return t.code<4e3?t.code>=1002&&t.code<=1004?"backoff":null:4e3===t.code?"tls_only":t.code<4100?"refused":t.code<4200?"backoff":t.code<4300?"retry":"refused"},getCloseError:function(t){return 1e3!==t.code&&1001!==t.code?{type:"PusherError",data:{code:t.code,message:t.reason||t.message}}:null}};var Y=V;class K extends H{constructor(t,e){super(),this.id=t,this.transport=e,this.activityTimeout=e.activityTimeout,this.bindListeners()}handlesActivityChecks(){return this.transport.handlesActivityChecks()}send(t){return this.transport.send(t)}send_event(t,e,n){var i={event:t,data:e};return n&&(i.channel=n),M.debug("Event sent",i),this.send(Y.encodeMessage(i))}ping(){this.transport.supportsPing()?this.transport.ping():this.send_event("pusher:ping",{})}close(){this.transport.close()}bindListeners(){var t={message:t=>{var e;try{e=Y.decodeMessage(t)}catch(e){this.emit("error",{type:"MessageParseError",error:e,data:t.data})}if(void 0!==e){switch(M.debug("Event recd",e),e.event){case"pusher:error":this.emit("error",{type:"PusherError",data:e.data});break;case"pusher:ping":this.emit("ping");break;case"pusher:pong":this.emit("pong")}this.emit("message",e)}},activity:()=>{this.emit("activity")},error:t=>{this.emit("error",t)},closed:t=>{e(),t&&t.code&&this.handleCloseEvent(t),this.transport=null,this.emit("closed")}},e=()=>{_(t,(t,e)=>{this.transport.unbind(e,t)})};_(t,(t,e)=>{this.transport.bind(e,t)})}handleCloseEvent(t){var e=Y.getCloseAction(t),n=Y.getCloseError(t);n&&this.emit("error",n),e&&this.emit(e,{action:e,error:n})}}class Q{constructor(t,e){this.transport=t,this.callback=e,this.bindListeners()}close(){this.unbindListeners(),this.transport.close()}bindListeners(){this.onMessage=t=>{var e;this.unbindListeners();try{e=Y.processHandshake(t)}catch(t){return this.finish("error",{error:t}),void this.transport.close()}"connected"===e.action?this.finish("connected",{connection:new K(e.id,this.transport),activityTimeout:e.activityTimeout}):(this.finish(e.action,{error:e.error}),this.transport.close())},this.onClosed=t=>{this.unbindListeners();var e=Y.getCloseAction(t)||"backoff",n=Y.getCloseError(t);this.finish(e,{error:n})},this.transport.bind("message",this.onMessage),this.transport.bind("closed",this.onClosed)}unbindListeners(){this.transport.unbind("message",this.onMessage),this.transport.unbind("closed",this.onClosed)}finish(t,e){this.callback(v({transport:this.transport,action:t},e))}}class Z{constructor(t,e){this.timeline=t,this.options=e||{}}send(t,e){this.timeline.isEmpty()||this.timeline.send(ae.TimelineTransport.getAgent(this,t),e)}}class tt extends Error{constructor(t){super(t),Object.setPrototypeOf(this,new.target.prototype)}}class et extends Error{constructor(t){super(t),Object.setPrototypeOf(this,new.target.prototype)}}Error;class nt extends Error{constructor(t){super(t),Object.setPrototypeOf(this,new.target.prototype)}}class it extends Error{constructor(t){super(t),Object.setPrototypeOf(this,new.target.prototype)}}class st extends Error{constructor(t){super(t),Object.setPrototypeOf(this,new.target.prototype)}}class rt extends Error{constructor(t){super(t),Object.setPrototypeOf(this,new.target.prototype)}}class ot extends Error{constructor(t){super(t),Object.setPrototypeOf(this,new.target.prototype)}}class at extends Error{constructor(t,e){super(e),this.status=t,Object.setPrototypeOf(this,new.target.prototype)}}const ct={baseUrl:"https://pusher.com",urls:{authenticationEndpoint:{path:"/docs/channels/server_api/authenticating_users"},authorizationEndpoint:{path:"/docs/channels/server_api/authorizing-users/"},javascriptQuickStart:{path:"/docs/javascript_quick_start"},triggeringClientEvents:{path:"/docs/client_api_guide/client_events#trigger-events"},encryptedChannelSupport:{fullUrl:"https://github.com/pusher/pusher-js/tree/cc491015371a4bde5743d1c87a0fbac0feb53195#encrypted-channel-support"}}};var ht=function(t){const e=ct.urls[t];if(!e)return"";let n;return e.fullUrl?n=e.fullUrl:e.path&&(n=ct.baseUrl+e.path),n?"See: "+n:""};class ut extends H{constructor(t,e){super((function(e,n){M.debug("No callbacks on "+t+" for "+e)})),this.name=t,this.pusher=e,this.subscribed=!1,this.subscriptionPending=!1,this.subscriptionCancelled=!1}authorize(t,e){return e(null,{auth:""})}trigger(t,e){if(0!==t.indexOf("client-"))throw new tt("Event '"+t+"' does not start with 'client-'");if(!this.subscribed){var n=ht("triggeringClientEvents");M.warn("Client event triggered before channel 'subscription_succeeded' event . "+n)}return this.pusher.send_event(t,e,this.name)}disconnect(){this.subscribed=!1,this.subscriptionPending=!1}handleEvent(t){var e=t.event,n=t.data;if("pusher_internal:subscription_succeeded"===e)this.handleSubscriptionSucceededEvent(t);else if("pusher_internal:subscription_count"===e)this.handleSubscriptionCountEvent(t);else if(0!==e.indexOf("pusher_internal:")){this.emit(e,n,{})}}handleSubscriptionSucceededEvent(t){this.subscriptionPending=!1,this.subscribed=!0,this.subscriptionCancelled?this.pusher.unsubscribe(this.name):this.emit("pusher:subscription_succeeded",t.data)}handleSubscriptionCountEvent(t){t.data.subscription_count&&(this.subscriptionCount=t.data.subscription_count),this.emit("pusher:subscription_count",t.data)}subscribe(){this.subscribed||(this.subscriptionPending=!0,this.subscriptionCancelled=!1,this.authorize(this.pusher.connection.socket_id,(t,e)=>{t?(this.subscriptionPending=!1,M.error(t.toString()),this.emit("pusher:subscription_error",Object.assign({},{type:"AuthError",error:t.message},t instanceof at?{status:t.status}:{}))):this.pusher.send_event("pusher:subscribe",{auth:e.auth,channel_data:e.channel_data,channel:this.name})}))}unsubscribe(){this.subscribed=!1,this.pusher.send_event("pusher:unsubscribe",{channel:this.name})}cancelSubscription(){this.subscriptionCancelled=!0}reinstateSubscription(){this.subscriptionCancelled=!1}}class lt extends ut{authorize(t,e){return this.pusher.config.channelAuthorizer({channelName:this.name,socketId:t},e)}}class dt{constructor(){this.reset()}get(t){return Object.prototype.hasOwnProperty.call(this.members,t)?{id:t,info:this.members[t]}:null}each(t){_(this.members,(e,n)=>{t(this.get(n))})}setMyID(t){this.myID=t}onSubscription(t){this.members=t.presence.hash,this.count=t.presence.count,this.me=this.get(this.myID)}addMember(t){return null===this.get(t.user_id)&&this.count++,this.members[t.user_id]=t.user_info,this.get(t.user_id)}removeMember(t){var e=this.get(t.user_id);return e&&(delete this.members[t.user_id],this.count--),e}reset(){this.members={},this.count=0,this.myID=null,this.me=null}}var pt=function(t,e,n,i){return new(n||(n=Promise))((function(s,r){function o(t){try{c(i.next(t))}catch(t){r(t)}}function a(t){try{c(i.throw(t))}catch(t){r(t)}}function c(t){var e;t.done?s(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(o,a)}c((i=i.apply(t,e||[])).next())}))};class ft extends lt{constructor(t,e){super(t,e),this.members=new dt}authorize(t,e){super.authorize(t,(t,n)=>pt(this,void 0,void 0,(function*(){if(!t)if(null!=(n=n).channel_data){var i=JSON.parse(n.channel_data);this.members.setMyID(i.user_id)}else{if(yield this.pusher.user.signinDonePromise,null==this.pusher.user.user_data){let t=ht("authorizationEndpoint");return M.error(`Invalid auth response for channel '${this.name}', expected 'channel_data' field. ${t}, or the user should be signed in.`),void e("Invalid auth response")}this.members.setMyID(this.pusher.user.user_data.id)}e(t,n)})))}handleEvent(t){var e=t.event;if(0===e.indexOf("pusher_internal:"))this.handleInternalEvent(t);else{var n=t.data,i={};t.user_id&&(i.user_id=t.user_id),this.emit(e,n,i)}}handleInternalEvent(t){var e=t.event,n=t.data;switch(e){case"pusher_internal:subscription_succeeded":this.handleSubscriptionSucceededEvent(t);break;case"pusher_internal:subscription_count":this.handleSubscriptionCountEvent(t);break;case"pusher_internal:member_added":var i=this.members.addMember(n);this.emit("pusher:member_added",i);break;case"pusher_internal:member_removed":var s=this.members.removeMember(n);s&&this.emit("pusher:member_removed",s)}}handleSubscriptionSucceededEvent(t){this.subscriptionPending=!1,this.subscribed=!0,this.subscriptionCancelled?this.pusher.unsubscribe(this.name):(this.members.onSubscription(t.data),this.emit("pusher:subscription_succeeded",this.members))}disconnect(){this.members.reset(),super.disconnect()}}var gt=n(1),bt=n(0);class mt extends lt{constructor(t,e,n){super(t,e),this.key=null,this.nacl=n}authorize(t,e){super.authorize(t,(t,n)=>{if(t)return void e(t,n);let i=n.shared_secret;i?(this.key=Object(bt.decode)(i),delete n.shared_secret,e(null,n)):e(new Error("No shared_secret key in auth payload for encrypted channel: "+this.name),null)})}trigger(t,e){throw new st("Client events are not currently supported for encrypted channels")}handleEvent(t){var e=t.event,n=t.data;0!==e.indexOf("pusher_internal:")&&0!==e.indexOf("pusher:")?this.handleEncryptedEvent(e,n):super.handleEvent(t)}handleEncryptedEvent(t,e){if(!this.key)return void M.debug("Received encrypted event before key has been retrieved from the authEndpoint");if(!e.ciphertext||!e.nonce)return void M.error("Unexpected format for encrypted event, expected object with `ciphertext` and `nonce` fields, got: "+e);let n=Object(bt.decode)(e.ciphertext);if(n.length{e?M.error(`Failed to make a request to the authEndpoint: ${r}. Unable to fetch new key, so dropping encrypted event`):(s=this.nacl.secretbox.open(n,i,this.key),null!==s?this.emit(t,this.getDataToEmit(s)):M.error("Failed to decrypt event with new key. Dropping encrypted event"))});this.emit(t,this.getDataToEmit(s))}getDataToEmit(t){let e=Object(gt.decode)(t);try{return JSON.parse(e)}catch(t){return e}}}class vt extends H{constructor(t,e){super(),this.state="initialized",this.connection=null,this.key=t,this.options=e,this.timeline=this.options.timeline,this.usingTLS=this.options.useTLS,this.errorCallbacks=this.buildErrorCallbacks(),this.connectionCallbacks=this.buildConnectionCallbacks(this.errorCallbacks),this.handshakeCallbacks=this.buildHandshakeCallbacks(this.errorCallbacks);var n=ae.getNetwork();n.bind("online",()=>{this.timeline.info({netinfo:"online"}),"connecting"!==this.state&&"unavailable"!==this.state||this.retryIn(0)}),n.bind("offline",()=>{this.timeline.info({netinfo:"offline"}),this.connection&&this.sendActivityCheck()}),this.updateStrategy()}switchCluster(t){this.key=t,this.updateStrategy(),this.retryIn(0)}connect(){this.connection||this.runner||(this.strategy.isSupported()?(this.updateState("connecting"),this.startConnecting(),this.setUnavailableTimer()):this.updateState("failed"))}send(t){return!!this.connection&&this.connection.send(t)}send_event(t,e,n){return!!this.connection&&this.connection.send_event(t,e,n)}disconnect(){this.disconnectInternally(),this.updateState("disconnected")}isUsingTLS(){return this.usingTLS}startConnecting(){var t=(e,n)=>{e?this.runner=this.strategy.connect(0,t):"error"===n.action?(this.emit("error",{type:"HandshakeError",error:n.error}),this.timeline.error({handshakeError:n.error})):(this.abortConnecting(),this.handshakeCallbacks[n.action](n))};this.runner=this.strategy.connect(0,t)}abortConnecting(){this.runner&&(this.runner.abort(),this.runner=null)}disconnectInternally(){(this.abortConnecting(),this.clearRetryTimer(),this.clearUnavailableTimer(),this.connection)&&this.abandonConnection().close()}updateStrategy(){this.strategy=this.options.getStrategy({key:this.key,timeline:this.timeline,useTLS:this.usingTLS})}retryIn(t){this.timeline.info({action:"retry",delay:t}),t>0&&this.emit("connecting_in",Math.round(t/1e3)),this.retryTimer=new g(t||0,()=>{this.disconnectInternally(),this.connect()})}clearRetryTimer(){this.retryTimer&&(this.retryTimer.ensureAborted(),this.retryTimer=null)}setUnavailableTimer(){this.unavailableTimer=new g(this.options.unavailableTimeout,()=>{this.updateState("unavailable")})}clearUnavailableTimer(){this.unavailableTimer&&this.unavailableTimer.ensureAborted()}sendActivityCheck(){this.stopActivityCheck(),this.connection.ping(),this.activityTimer=new g(this.options.pongTimeout,()=>{this.timeline.error({pong_timed_out:this.options.pongTimeout}),this.retryIn(0)})}resetActivityCheck(){this.stopActivityCheck(),this.connection&&!this.connection.handlesActivityChecks()&&(this.activityTimer=new g(this.activityTimeout,()=>{this.sendActivityCheck()}))}stopActivityCheck(){this.activityTimer&&this.activityTimer.ensureAborted()}buildConnectionCallbacks(t){return v({},t,{message:t=>{this.resetActivityCheck(),this.emit("message",t)},ping:()=>{this.send_event("pusher:pong",{})},activity:()=>{this.resetActivityCheck()},error:t=>{this.emit("error",t)},closed:()=>{this.abandonConnection(),this.shouldRetry()&&this.retryIn(1e3)}})}buildHandshakeCallbacks(t){return v({},t,{connected:t=>{this.activityTimeout=Math.min(this.options.activityTimeout,t.activityTimeout,t.connection.activityTimeout||1/0),this.clearUnavailableTimer(),this.setConnection(t.connection),this.socket_id=this.connection.id,this.updateState("connected",{socket_id:this.socket_id})}})}buildErrorCallbacks(){let t=t=>e=>{e.error&&this.emit("error",{type:"WebSocketError",error:e.error}),t(e)};return{tls_only:t(()=>{this.usingTLS=!0,this.updateStrategy(),this.retryIn(0)}),refused:t(()=>{this.disconnect()}),backoff:t(()=>{this.retryIn(1e3)}),retry:t(()=>{this.retryIn(0)})}}setConnection(t){for(var e in this.connection=t,this.connectionCallbacks)this.connection.bind(e,this.connectionCallbacks[e]);this.resetActivityCheck()}abandonConnection(){if(this.connection){for(var t in this.stopActivityCheck(),this.connectionCallbacks)this.connection.unbind(t,this.connectionCallbacks[t]);var e=this.connection;return this.connection=null,e}}updateState(t,e){var n=this.state;if(this.state=t,n!==t){var i=t;"connected"===i&&(i+=" with new socket ID "+e.socket_id),M.debug("State changed",n+" -> "+i),this.timeline.info({state:t,params:e}),this.emit("state_change",{previous:n,current:t}),this.emit(t,e)}}shouldRetry(){return"connecting"===this.state||"connected"===this.state}}class yt{constructor(){this.channels={}}add(t,e){return this.channels[t]||(this.channels[t]=function(t,e){if(0===t.indexOf("private-encrypted-")){if(e.config.nacl)return St.createEncryptedChannel(t,e,e.config.nacl);let n="Tried to subscribe to a private-encrypted- channel but no nacl implementation available",i=ht("encryptedChannelSupport");throw new st(`${n}. ${i}`)}if(0===t.indexOf("private-"))return St.createPrivateChannel(t,e);if(0===t.indexOf("presence-"))return St.createPresenceChannel(t,e);if(0===t.indexOf("#"))throw new et('Cannot create a channel with name "'+t+'".');return St.createChannel(t,e)}(t,e)),this.channels[t]}all(){return function(t){var e=[];return _(t,(function(t){e.push(t)})),e}(this.channels)}find(t){return this.channels[t]}remove(t){var e=this.channels[t];return delete this.channels[t],e}disconnect(){_(this.channels,(function(t){t.disconnect()}))}}var St={createChannels:()=>new yt,createConnectionManager:(t,e)=>new vt(t,e),createChannel:(t,e)=>new ut(t,e),createPrivateChannel:(t,e)=>new lt(t,e),createPresenceChannel:(t,e)=>new ft(t,e),createEncryptedChannel:(t,e,n)=>new mt(t,e,n),createTimelineSender:(t,e)=>new Z(t,e),createHandshake:(t,e)=>new Q(t,e),createAssistantToTheTransportManager:(t,e,n)=>new G(t,e,n)};class _t{constructor(t){this.options=t||{},this.livesLeft=this.options.lives||1/0}getAssistant(t){return St.createAssistantToTheTransportManager(this,t,{minPingDelay:this.options.minPingDelay,maxPingDelay:this.options.maxPingDelay})}isAlive(){return this.livesLeft>0}reportDeath(){this.livesLeft-=1}}class wt{constructor(t,e){this.strategies=t,this.loop=Boolean(e.loop),this.failFast=Boolean(e.failFast),this.timeout=e.timeout,this.timeoutLimit=e.timeoutLimit}isSupported(){return O(this.strategies,m.method("isSupported"))}connect(t,e){var n=this.strategies,i=0,s=this.timeout,r=null,o=(a,c)=>{c?e(null,c):(i+=1,this.loop&&(i%=n.length),i0&&(s=new g(n.timeout,(function(){r.abort(),i(!0)}))),r=t.connect(e,(function(t,e){t&&s&&s.isRunning()&&!n.failFast||(s&&s.ensureAborted(),i(t,e))})),{abort:function(){s&&s.ensureAborted(),r.abort()},forceMinPriority:function(t){r.forceMinPriority(t)}}}}class Ct{constructor(t){this.strategies=t}isSupported(){return O(this.strategies,m.method("isSupported"))}connect(t,e){return function(t,e,n){var i=k(t,(function(t,i,s,r){return t.connect(e,n(i,r))}));return{abort:function(){C(i,kt)},forceMinPriority:function(t){C(i,(function(e){e.forceMinPriority(t)}))}}}(this.strategies,t,(function(t,n){return function(i,s){n[t].error=i,i?function(t){return function(t,e){for(var n=0;n=m.now()){var o=this.transports[i.transport];o&&(["ws","wss"].includes(i.transport)||s>3?(this.timeline.info({cached:!0,transport:i.transport,latency:i.latency}),r.push(new wt([o],{timeout:2*i.latency+1e3,failFast:!0}))):s++)}var a=m.now(),c=r.pop().connect(t,(function i(o,h){o?(Ot(n),r.length>0?(a=m.now(),c=r.pop().connect(t,i)):e(o)):(!function(t,e,n,i){var s=ae.getLocalStorage();if(s)try{s[Pt(t)]=L({timestamp:m.now(),transport:e,latency:n,cacheSkipCount:i})}catch(t){}}(n,h.transport.name,m.now()-a,s),e(null,h))}));return{abort:function(){c.abort()},forceMinPriority:function(e){t=e,c&&c.forceMinPriority(e)}}}}function Pt(t){return"pusherTransport"+(t?"TLS":"NonTLS")}function Ot(t){var e=ae.getLocalStorage();if(e)try{delete e[Pt(t)]}catch(t){}}class Et{constructor(t,{delay:e}){this.strategy=t,this.options={delay:e}}isSupported(){return this.strategy.isSupported()}connect(t,e){var n,i=this.strategy,s=new g(this.options.delay,(function(){n=i.connect(t,e)}));return{abort:function(){s.ensureAborted(),n&&n.abort()},forceMinPriority:function(e){t=e,n&&n.forceMinPriority(e)}}}}class xt{constructor(t,e,n){this.test=t,this.trueBranch=e,this.falseBranch=n}isSupported(){return(this.test()?this.trueBranch:this.falseBranch).isSupported()}connect(t,e){return(this.test()?this.trueBranch:this.falseBranch).connect(t,e)}}class Lt{constructor(t){this.strategy=t}isSupported(){return this.strategy.isSupported()}connect(t,e){var n=this.strategy.connect(t,(function(t,i){i&&n.abort(),e(t,i)}));return n}}function At(t){return function(){return t.isSupported()}}var Rt=function(t,e,n){var i={};function s(e,s,r,o,a){var c=n(t,e,s,r,o,a);return i[e]=c,c}var r,o=Object.assign({},e,{hostNonTLS:t.wsHost+":"+t.wsPort,hostTLS:t.wsHost+":"+t.wssPort,httpPath:t.wsPath}),a=v({},o,{useTLS:!0}),c=Object.assign({},e,{hostNonTLS:t.httpHost+":"+t.httpPort,hostTLS:t.httpHost+":"+t.httpsPort,httpPath:t.httpPath}),h={loop:!0,timeout:15e3,timeoutLimit:6e4},u=new _t({minPingDelay:1e4,maxPingDelay:t.activityTimeout}),l=new _t({lives:2,minPingDelay:1e4,maxPingDelay:t.activityTimeout}),d=s("ws","ws",3,o,u),p=s("wss","ws",3,a,u),f=s("xhr_streaming","xhr_streaming",1,c,l),g=s("xhr_polling","xhr_polling",1,c),b=new wt([d],h),m=new wt([p],h),y=new wt([f],h),S=new wt([g],h),_=new wt([new xt(At(y),new Ct([y,new Et(S,{delay:4e3})]),S)],h);return r=e.useTLS?new Ct([b,new Et(_,{delay:2e3})]):new Ct([b,new Et(m,{delay:2e3}),new Et(_,{delay:5e3})]),new Tt(new Lt(new xt(At(d),r,_)),i,{ttl:18e5,timeline:e.timeline,useTLS:e.useTLS})};class It extends H{constructor(t,e,n){super(),this.hooks=t,this.method=e,this.url=n}start(t){this.position=0,this.xhr=this.hooks.getRequest(this),this.unloader=()=>{this.close()},ae.addUnloadListener(this.unloader),this.xhr.open(this.method,this.url,!0),this.xhr.setRequestHeader&&this.xhr.setRequestHeader("Content-Type","application/json"),this.xhr.send(t)}close(){this.unloader&&(ae.removeUnloadListener(this.unloader),this.unloader=null),this.xhr&&(this.hooks.abortRequest(this.xhr),this.xhr=null)}onChunk(t,e){for(;;){var n=this.advanceBuffer(e);if(!n)break;this.emit("chunk",{status:t,data:n})}this.isBufferTooLong(e)&&this.emit("buffer_too_long")}advanceBuffer(t){var e=t.slice(this.position),n=e.indexOf("\n");return-1!==n?(this.position+=n+1,e.slice(0,n)):null}isBufferTooLong(t){return this.position===t.length&&t.length>262144}}var jt;!function(t){t[t.CONNECTING=0]="CONNECTING",t[t.OPEN=1]="OPEN",t[t.CLOSED=3]="CLOSED"}(jt||(jt={}));var Dt=jt,Nt=1;function Ut(t){var e=-1===t.indexOf("?")?"?":"&";return t+e+"t="+ +new Date+"&n="+Nt++}function Ht(t){return ae.randomInt(t)}var Mt=class{constructor(t,e){this.hooks=t,this.session=Ht(1e3)+"/"+function(t){for(var e=[],n=0;n{this.onChunk(t)}),this.stream.bind("finished",t=>{this.hooks.onFinished(this,t)}),this.stream.bind("buffer_too_long",()=>{this.reconnect()});try{this.stream.start()}catch(t){m.defer(()=>{this.onError(t),this.onClose(1006,"Could not start streaming",!1)})}}closeStream(){this.stream&&(this.stream.unbind_all(),this.stream.close(),this.stream=null)}},zt={getReceiveURL:function(t,e){return t.base+"/"+e+"/xhr_streaming"+t.queryString},onHeartbeat:function(t){t.sendRaw("[]")},sendHeartbeat:function(t){t.sendRaw("[]")},onFinished:function(t,e){t.onClose(1006,"Connection interrupted ("+e+")",!1)}},Bt={getReceiveURL:function(t,e){return t.base+"/"+e+"/xhr"+t.queryString},onHeartbeat:function(){},sendHeartbeat:function(t){t.sendRaw("[]")},onFinished:function(t,e){200===e?t.reconnect():t.onClose(1006,"Connection interrupted ("+e+")",!1)}},qt={getRequest:function(t){var e=new(ae.getXHRAPI());return e.onreadystatechange=e.onprogress=function(){switch(e.readyState){case 3:e.responseText&&e.responseText.length>0&&t.onChunk(e.status,e.responseText);break;case 4:e.responseText&&e.responseText.length>0&&t.onChunk(e.status,e.responseText),t.emit("finished",e.status),t.close()}},e},abortRequest:function(t){t.onreadystatechange=null,t.abort()}},Ft={getDefaultStrategy:Rt,Transports:X,transportConnectionInitializer:function(){this.timeline.info(this.buildTimelineMessage({transport:this.name+(this.options.useTLS?"s":"")})),this.hooks.isInitialized()?this.changeState("initialized"):this.onClose()},HTTPFactory:{createStreamingSocket(t){return this.createSocket(zt,t)},createPollingSocket(t){return this.createSocket(Bt,t)},createSocket:(t,e)=>new Mt(t,e),createXHR(t,e){return this.createRequest(qt,t,e)},createRequest:(t,e,n)=>new It(t,e,n)},setup(t){t.ready()},getLocalStorage(){},getClientFeatures:()=>w(P({ws:X.ws},(function(t){return t.isSupported({})}))),getProtocol:()=>"http:",isXHRSupported:()=>!0,createSocketRequest(t,e){if(this.isXHRSupported())return this.HTTPFactory.createXHR(t,e);throw"Cross-origin HTTP requests are not supported"},createXHR(){return new(this.getXHRAPI())},createWebSocket(t){return new(this.getWebSocketAPI())(t)},addUnloadListener(t){},removeUnloadListener(t){}};var $t=new class extends H{isOnline(){return!0}},Jt=function(t,e,n,i,s){var r=new Headers;for(var o in r.set("Content-Type","application/x-www-form-urlencoded"),n.headers)r.set(o,n.headers[o]);if(null!=n.headersProvider){const t=n.headersProvider();for(var o in t)r.set(o,t[o])}var a=e,c=new Request(n.endpoint,{headers:r,body:a,credentials:"same-origin",method:"POST"});return fetch(c).then(t=>{let{status:e}=t;if(200===e)return t.text();throw new at(e,`Could not get ${i.toString()} info from your auth endpoint, status: ${e}`)}).then(t=>{let e;try{e=JSON.parse(t)}catch(e){throw new at(200,`JSON returned from ${i.toString()} endpoint was invalid, yet status code was 200. Data was: ${t}`)}s(null,e)}).catch(t=>{s(t,null)})},Wt={name:"xhr",getAgent:function(t,e){return function(n,i){var s="http"+(e?"s":"")+"://"+(t.host||t.options.host)+t.options.path,r=x(n);fetch(s+="/2?"+r).then(t=>{if(200!==t.status)throw`received ${t.status} from stats.pusher.com`;return t.json()}).then(({host:e})=>{e&&(t.host=e)}).catch(t=>{M.debug("TimelineSender Error: ",t)})}}};const{getDefaultStrategy:Xt,Transports:Gt,setup:Vt,getProtocol:Yt,isXHRSupported:Kt,getLocalStorage:Qt,createXHR:Zt,createWebSocket:te,addUnloadListener:ee,removeUnloadListener:ne,transportConnectionInitializer:ie,createSocketRequest:se,HTTPFactory:re}=Ft;var oe,ae={getDefaultStrategy:Xt,Transports:Gt,setup:Vt,getProtocol:Yt,isXHRSupported:Kt,getLocalStorage:Qt,createXHR:Zt,createWebSocket:te,addUnloadListener:ee,removeUnloadListener:ne,transportConnectionInitializer:ie,createSocketRequest:se,HTTPFactory:re,TimelineTransport:Wt,getAuthorizers:()=>({ajax:Jt}),getWebSocketAPI:()=>WebSocket,getXHRAPI:()=>XMLHttpRequest,getNetwork:()=>$t,randomInt:t=>Math.floor((globalThis.crypto||globalThis.msCrypto).getRandomValues(new Uint32Array(1))[0]/Math.pow(2,32)*t)};!function(t){t[t.ERROR=3]="ERROR",t[t.INFO=6]="INFO",t[t.DEBUG=7]="DEBUG"}(oe||(oe={}));var ce=oe;class he{constructor(t,e,n){this.key=t,this.session=e,this.events=[],this.options=n||{},this.sent=0,this.uniqueID=0}log(t,e){t<=this.options.level&&(this.events.push(v({},e,{timestamp:m.now()})),this.options.limit&&this.events.length>this.options.limit&&this.events.shift())}error(t){this.log(ce.ERROR,t)}info(t){this.log(ce.INFO,t)}debug(t){this.log(ce.DEBUG,t)}isEmpty(){return 0===this.events.length}send(t,e){var n=v({session:this.session,bundle:this.sent+1,key:this.key,lib:"js",version:this.options.version,cluster:this.options.cluster,features:this.options.features,timeline:this.events},this.options.params);return this.events=[],t(n,(t,n)=>{t||this.sent++,e&&e(t,n)}),!0}generateUniqueID(){return this.uniqueID++,this.uniqueID}}class ue{constructor(t,e,n,i){this.name=t,this.priority=e,this.transport=n,this.options=i||{}}isSupported(){return this.transport.isSupported({useTLS:this.options.useTLS})}connect(t,e){if(!this.isSupported())return le(new ot,e);if(this.priority{n||(h(),s?s.close():i.close())},forceMinPriority:t=>{n||this.priority{if(void 0===ae.getAuthorizers()[t.transport])throw`'${t.transport}' is not a recognized auth transport`;return(e,n)=>{const i=((t,e)=>{var n="socket_id="+encodeURIComponent(t.socketId);for(var i in e.params)n+="&"+encodeURIComponent(i)+"="+encodeURIComponent(e.params[i]);if(null!=e.paramsProvider){let t=e.paramsProvider();for(var i in t)n+="&"+encodeURIComponent(i)+"="+encodeURIComponent(t[i])}return n})(e,t);ae.getAuthorizers()[t.transport](ae,i,t,pe.UserAuthentication,n)}};var me=t=>{if(void 0===ae.getAuthorizers()[t.transport])throw`'${t.transport}' is not a recognized auth transport`;return(e,n)=>{const i=((t,e)=>{var n="socket_id="+encodeURIComponent(t.socketId);for(var i in n+="&channel_name="+encodeURIComponent(t.channelName),e.params)n+="&"+encodeURIComponent(i)+"="+encodeURIComponent(e.params[i]);if(null!=e.paramsProvider){let t=e.paramsProvider();for(var i in t)n+="&"+encodeURIComponent(i)+"="+encodeURIComponent(t[i])}return n})(e,t);ae.getAuthorizers()[t.transport](ae,i,t,pe.ChannelAuthorization,n)}};const ve=(t,e,n)=>{const i={authTransport:e.transport,authEndpoint:e.endpoint,auth:{params:e.params,headers:e.headers}};return(e,s)=>{const r=t.channel(e.channelName);n(r,i).authorize(e.socketId,s)}};function ye(t,e){let n={activityTimeout:t.activityTimeout||A.activityTimeout,cluster:t.cluster,httpPath:t.httpPath||A.httpPath,httpPort:t.httpPort||A.httpPort,httpsPort:t.httpsPort||A.httpsPort,pongTimeout:t.pongTimeout||A.pongTimeout,statsHost:t.statsHost||A.stats_host,unavailableTimeout:t.unavailableTimeout||A.unavailableTimeout,wsPath:t.wsPath||A.wsPath,wsPort:t.wsPort||A.wsPort,wssPort:t.wssPort||A.wssPort,enableStats:Ce(t),httpHost:Se(t),useTLS:we(t),wsHost:_e(t),userAuthenticator:Te(t),channelAuthorizer:Pe(t,e)};return"disabledTransports"in t&&(n.disabledTransports=t.disabledTransports),"enabledTransports"in t&&(n.enabledTransports=t.enabledTransports),"ignoreNullOrigin"in t&&(n.ignoreNullOrigin=t.ignoreNullOrigin),"timelineParams"in t&&(n.timelineParams=t.timelineParams),"nacl"in t&&(n.nacl=t.nacl),n}function Se(t){return t.httpHost?t.httpHost:t.cluster?`sockjs-${t.cluster}.pusher.com`:A.httpHost}function _e(t){return t.wsHost?t.wsHost:`ws-${t.cluster}.pusher.com`}function we(t){return"https:"===ae.getProtocol()||!1!==t.forceTLS}function Ce(t){return"enableStats"in t?t.enableStats:"disableStats"in t&&!t.disableStats}const ke=t=>"customHandler"in t&&null!=t.customHandler;function Te(t){const e=Object.assign(Object.assign({},A.userAuthentication),t.userAuthentication);return ke(e)?e.customHandler:be(e)}function Pe(t,e){const n=function(t,e){let n;if("channelAuthorization"in t)n=Object.assign(Object.assign({},A.channelAuthorization),t.channelAuthorization);else if(n={transport:t.authTransport||A.authTransport,endpoint:t.authEndpoint||A.authEndpoint},"auth"in t&&("params"in t.auth&&(n.params=t.auth.params),"headers"in t.auth&&(n.headers=t.auth.headers)),"authorizer"in t)return{customHandler:ve(e,n,t.authorizer)};return n}(t,e);return ke(n)?n.customHandler:me(n)}class Oe extends H{constructor(t){super((function(t,e){M.debug("No callbacks on watchlist events for "+t)})),this.pusher=t,this.bindWatchlistInternalEvent()}handleEvent(t){t.data.events.forEach(t=>{this.emit(t.name,t)})}bindWatchlistInternalEvent(){this.pusher.connection.bind("message",t=>{"pusher_internal:watchlist_events"===t.event&&this.handleEvent(t)})}}var Ee=function(){let t,e;return{promise:new Promise((n,i)=>{t=n,e=i}),resolve:t,reject:e}};class xe extends H{constructor(t){super((function(t,e){M.debug("No callbacks on user for "+t)})),this.signin_requested=!1,this.user_data=null,this.serverToUserChannel=null,this.signinDonePromise=null,this._signinDoneResolve=null,this._onAuthorize=(t,e)=>{if(t)return M.warn("Error during signin: "+t),void this._cleanup();this.pusher.send_event("pusher:signin",{auth:e.auth,user_data:e.user_data})},this.pusher=t,this.pusher.connection.bind("state_change",({previous:t,current:e})=>{"connected"!==t&&"connected"===e&&this._signin(),"connected"===t&&"connected"!==e&&(this._cleanup(),this._newSigninPromiseIfNeeded())}),this.watchlist=new Oe(t),this.pusher.connection.bind("message",t=>{"pusher:signin_success"===t.event&&this._onSigninSuccess(t.data),this.serverToUserChannel&&this.serverToUserChannel.name===t.channel&&this.serverToUserChannel.handleEvent(t)})}signin(){this.signin_requested||(this.signin_requested=!0,this._signin())}_signin(){this.signin_requested&&(this._newSigninPromiseIfNeeded(),"connected"===this.pusher.connection.state&&this.pusher.config.userAuthenticator({socketId:this.pusher.connection.socket_id},this._onAuthorize))}_onSigninSuccess(t){try{this.user_data=JSON.parse(t.user_data)}catch(e){return M.error("Failed parsing user data after signin: "+t.user_data),void this._cleanup()}if("string"!=typeof this.user_data.id||""===this.user_data.id)return M.error("user_data doesn't contain an id. user_data: "+this.user_data),void this._cleanup();this._signinDoneResolve(),this._subscribeChannels()}_subscribeChannels(){this.serverToUserChannel=new ut("#server-to-user-"+this.user_data.id,this.pusher),this.serverToUserChannel.bind_global((t,e)=>{0!==t.indexOf("pusher_internal:")&&0!==t.indexOf("pusher:")&&this.emit(t,e)}),(t=>{t.subscriptionPending&&t.subscriptionCancelled?t.reinstateSubscription():t.subscriptionPending||"connected"!==this.pusher.connection.state||t.subscribe()})(this.serverToUserChannel)}_cleanup(){this.user_data=null,this.serverToUserChannel&&(this.serverToUserChannel.unbind_all(),this.serverToUserChannel.disconnect(),this.serverToUserChannel=null),this.signin_requested&&this._signinDoneResolve()}_newSigninPromiseIfNeeded(){if(!this.signin_requested)return;if(this.signinDonePromise&&!this.signinDonePromise.done)return;const{promise:t,resolve:e,reject:n}=Ee();t.done=!1;const i=()=>{t.done=!0};t.then(i).catch(i),this.signinDonePromise=t,this._signinDoneResolve=e}}class Le{static ready(){Le.isReady=!0;for(var t=0,e=Le.instances.length;tae.getDefaultStrategy(this.config,t,fe),timeline:this.timeline,activityTimeout:this.config.activityTimeout,pongTimeout:this.config.pongTimeout,unavailableTimeout:this.config.unavailableTimeout,useTLS:Boolean(this.config.useTLS)}),this.connection.bind("connected",()=>{this.subscribeAll(),this.timelineSender&&this.timelineSender.send(this.connection.isUsingTLS())}),this.connection.bind("message",t=>{var e=0===t.event.indexOf("pusher_internal:");if(t.channel){var n=this.channel(t.channel);n&&n.handleEvent(t)}e||this.global_emitter.emit(t.event,t.data)}),this.connection.bind("connecting",()=>{this.channels.disconnect()}),this.connection.bind("disconnected",()=>{this.channels.disconnect()}),this.connection.bind("error",t=>{M.warn(t)}),Le.instances.push(this),this.timeline.info({instances:Le.instances.length}),this.user=new xe(this),Le.isReady&&this.connect()}switchCluster(t){const{appKey:e,cluster:n}=t;this.key=e,this.options=Object.assign(Object.assign({},this.options),{cluster:n}),this.config=ye(this.options,this),this.connection.switchCluster(this.key)}channel(t){return this.channels.find(t)}allChannels(){return this.channels.all()}connect(){if(this.connection.connect(),this.timelineSender&&!this.timelineSenderTimer){var t=this.connection.isUsingTLS(),e=this.timelineSender;this.timelineSenderTimer=new b(6e4,(function(){e.send(t)}))}}disconnect(){this.connection.disconnect(),this.timelineSenderTimer&&(this.timelineSenderTimer.ensureAborted(),this.timelineSenderTimer=null)}bind(t,e,n){return this.global_emitter.bind(t,e,n),this}unbind(t,e,n){return this.global_emitter.unbind(t,e,n),this}bind_global(t){return this.global_emitter.bind_global(t),this}unbind_global(t){return this.global_emitter.unbind_global(t),this}unbind_all(t){return this.global_emitter.unbind_all(),this}subscribeAll(){var t;for(t in this.channels.channels)this.channels.channels.hasOwnProperty(t)&&this.subscribe(t)}subscribe(t){var e=this.channels.add(t,this);return e.subscriptionPending&&e.subscriptionCancelled?e.reinstateSubscription():e.subscriptionPending||"connected"!==this.connection.state||e.subscribe(),e}unsubscribe(t){var e=this.channels.find(t);e&&e.subscriptionPending?e.cancelSubscription():(e=this.channels.remove(t))&&e.subscribed&&e.unsubscribe()}send_event(t,e,n){return this.connection.send_event(t,e,n)}shouldUseTLS(){return this.config.useTLS}signin(){this.user.signin()}}Le.instances=[],Le.isReady=!1,Le.logToConsole=!1,Le.Runtime=ae,Le.ScriptReceivers=ae.ScriptReceivers,Le.DependenciesReceivers=ae.DependenciesReceivers,Le.auth_callbacks=ae.auth_callbacks;var Ae=e.default=Le;ae.setup(Le)}])})); //# sourceMappingURL=pusher.worker.min.js.map \ No newline at end of file diff --git a/dist/worker/pusher.worker.min.js.map b/dist/worker/pusher.worker.min.js.map index 676f9e479..eeb9dddc7 100644 --- a/dist/worker/pusher.worker.min.js.map +++ b/dist/worker/pusher.worker.min.js.map @@ -1 +1 @@ -{"version":3,"sources":["webpack://Pusher/webpack/universalModuleDefinition","webpack://Pusher/webpack/bootstrap","webpack://Pusher/./node_modules/@stablelib/base64/base64.ts","webpack://Pusher/./node_modules/@stablelib/utf8/utf8.ts","webpack://Pusher/./src/core/pusher.js","webpack://Pusher/./src/core/base64.ts","webpack://Pusher/./src/core/utils/timers/abstract_timer.ts","webpack://Pusher/./src/core/utils/timers/index.ts","webpack://Pusher/./src/core/util.ts","webpack://Pusher/./src/core/utils/collections.ts","webpack://Pusher/./src/core/defaults.ts","webpack://Pusher/./src/core/transports/url_schemes.ts","webpack://Pusher/./src/core/events/callback_registry.ts","webpack://Pusher/./src/core/events/dispatcher.ts","webpack://Pusher/./src/core/logger.ts","webpack://Pusher/./src/core/transports/transport_connection.ts","webpack://Pusher/./src/core/transports/transport.ts","webpack://Pusher/./src/runtimes/isomorphic/transports/transports.ts","webpack://Pusher/./src/core/transports/assistant_to_the_transport_manager.ts","webpack://Pusher/./src/core/connection/protocol/protocol.ts","webpack://Pusher/./src/core/connection/connection.ts","webpack://Pusher/./src/core/connection/handshake/index.ts","webpack://Pusher/./src/core/timeline/timeline_sender.ts","webpack://Pusher/./src/core/errors.ts","webpack://Pusher/./src/core/utils/url_store.ts","webpack://Pusher/./src/core/channels/channel.ts","webpack://Pusher/./src/core/channels/private_channel.ts","webpack://Pusher/./src/core/channels/members.ts","webpack://Pusher/./src/core/channels/presence_channel.ts","webpack://Pusher/./src/core/channels/encrypted_channel.ts","webpack://Pusher/./src/core/connection/connection_manager.ts","webpack://Pusher/./src/core/channels/channels.ts","webpack://Pusher/./src/core/utils/factory.ts","webpack://Pusher/./src/core/transports/transport_manager.ts","webpack://Pusher/./src/core/strategies/sequential_strategy.ts","webpack://Pusher/./src/core/strategies/best_connected_ever_strategy.ts","webpack://Pusher/./src/core/strategies/websocket_prioritized_cached_strategy.ts","webpack://Pusher/./src/core/strategies/delayed_strategy.ts","webpack://Pusher/./src/core/strategies/if_strategy.ts","webpack://Pusher/./src/core/strategies/first_connected_strategy.ts","webpack://Pusher/./src/runtimes/isomorphic/default_strategy.ts","webpack://Pusher/./src/core/http/http_request.ts","webpack://Pusher/./src/core/http/state.ts","webpack://Pusher/./src/core/http/http_socket.ts","webpack://Pusher/./src/core/http/http_streaming_socket.ts","webpack://Pusher/./src/core/http/http_polling_socket.ts","webpack://Pusher/./src/runtimes/isomorphic/http/http_xhr_request.ts","webpack://Pusher/./src/runtimes/isomorphic/runtime.ts","webpack://Pusher/./src/runtimes/isomorphic/transports/transport_connection_initializer.ts","webpack://Pusher/./src/runtimes/isomorphic/http/http.ts","webpack://Pusher/./src/runtimes/worker/net_info.ts","webpack://Pusher/./src/runtimes/worker/auth/fetch_auth.ts","webpack://Pusher/./src/runtimes/worker/timeline/fetch_timeline.ts","webpack://Pusher/./src/runtimes/worker/runtime.ts","webpack://Pusher/./src/core/timeline/level.ts","webpack://Pusher/./src/core/timeline/timeline.ts","webpack://Pusher/./src/core/strategies/transport_strategy.ts","webpack://Pusher/./src/core/strategies/strategy_builder.ts","webpack://Pusher/./src/core/auth/options.ts","webpack://Pusher/./src/core/auth/user_authenticator.ts","webpack://Pusher/./src/core/auth/channel_authorizer.ts","webpack://Pusher/./src/core/config.ts","webpack://Pusher/./src/core/auth/deprecated_channel_authorizer.ts","webpack://Pusher/./src/core/watchlist.ts","webpack://Pusher/./src/core/utils/flat_promise.ts","webpack://Pusher/./src/core/user.ts","webpack://Pusher/./src/core/pusher.ts","webpack://Pusher/./src/core/options.ts"],"names":["root","factory","exports","module","define","amd","this","installedModules","__webpack_require__","moduleId","i","l","modules","call","m","c","d","name","getter","o","Object","defineProperty","enumerable","get","r","Symbol","toStringTag","value","t","mode","__esModule","ns","create","key","bind","n","object","property","prototype","hasOwnProperty","p","s","_paddingCharacter","encodedLength","length","encode","data","out","_encodeByte","left","maxDecodedLength","decodedLength","_getPaddingLength","decode","Uint8Array","paddingLength","op","haveBad","v0","v1","v2","v3","_decodeChar","charCodeAt","Error","b","result","String","fromCharCode","Coder","stdCoder","URLSafeCoder","urlSafeCoder","INVALID_UTF8","arr","pos","chars","min","n1","n2","n3","push","join","default","b64chars","b64tab","charAt","cb_utob","cc","utob","u","replace","cb_encode","ccc","padlen","ord","btoa","set","clear","delay","callback","timer","clearTimeout","clearInterval","super","setTimeout","setInterval","now","Date","valueOf","defer","args","boundArguments","Array","slice","arguments","apply","concat","extend","target","sources","extensions","constructor","stringify","safeJSONStringify","arrayIndexOf","array","item","nativeIndexOf","indexOf","objectApply","f","keys","_","context","map","filter","test","filterObject","Boolean","any","encodeParamsObject","encodeURIComponent","toString","buildQueryString","params","undefined","method","source","JSON","e","objects","paths","derez","path","nu","$ref","VERSION","PROTOCOL","wsPort","wssPort","wsPath","httpHost","httpPort","httpsPort","httpPath","stats_host","authEndpoint","authTransport","activityTimeout","pongTimeout","unavailableTimeout","userAuthentication","endpoint","transport","channelAuthorization","cdn_http","cdn_https","dependency_suffix","getGenericURL","baseScheme","useTLS","hostTLS","hostNonTLS","getGenericPath","queryString","ws","getInitial","http","_callbacks","prefix","prefixedEventName","fn","names","removeCallback","removeAllCallbacks","binding","failThrough","callbacks","global_callbacks","eventName","add","remove","unbind","unbind_global","metadata","globalLog","message","console","log","globalLogWarn","globalLogError","warn","error","defaultLoggingFunction","logToConsole","hooks","priority","options","initialize","transportConnectionInitializer","state","timeline","id","generateUniqueID","handlesActivityChecks","supportsPing","socket","url","urls","getSocket","onError","changeState","bindListeners","debug","close","send","ping","beforeOpen","getPath","onopen","emit","type","buildTimelineMessage","closeEvent","code","reason","wasClean","unbindListeners","onOpen","onerror","onclose","onClose","onmessage","onMessage","onactivity","onActivity","info","cid","environment","isSupported","WSTransport","isInitialized","getWebSocketAPI","createWebSocket","httpConfiguration","streamingConfiguration","HTTPFactory","createStreamingSocket","pollingConfiguration","createPollingSocket","xhrConfiguration","isXHRSupported","xhr_streaming","xhr_polling","manager","minPingDelay","maxPingDelay","pingDelay","connection","createConnection","openTimestamp","onClosed","reportDeath","lifespan","Math","max","isAlive","Protocol","decodeMessage","messageEvent","messageData","parse","pusherEventData","pusherEvent","event","channel","user_id","encodeMessage","processHandshake","activity_timeout","action","socket_id","getCloseAction","getCloseError","send_event","listeners","activity","closed","handleCloseEvent","listener","finish","isEmpty","TimelineTransport","getAgent","BadEventName","msg","setPrototypeOf","BadChannelName","TransportPriorityTooLow","TransportClosed","UnsupportedFeature","UnsupportedTransport","UnsupportedStrategy","HTTPAuthError","status","urlStore","baseUrl","authenticationEndpoint","authorizationEndpoint","javascriptQuickStart","triggeringClientEvents","encryptedChannelSupport","fullUrl","urlObj","pusher","subscribed","subscriptionPending","subscriptionCancelled","socketId","auth","suffix","handleSubscriptionSucceededEvent","handleSubscriptionCountEvent","unsubscribe","subscription_count","subscriptionCount","authorize","assign","channel_data","config","channelAuthorizer","channelName","reset","members","member","myID","subscriptionData","presence","hash","count","me","memberData","user_info","authData","channelData","setMyID","user","signinDonePromise","user_data","handleInternalEvent","addedMember","addMember","removedMember","removeMember","onSubscription","disconnect","nacl","sharedSecret","handleEncryptedEvent","handleEvent","ciphertext","nonce","cipherText","secretbox","overheadLength","nonceLength","bytes","open","getDataToEmit","raw","usingTLS","errorCallbacks","buildErrorCallbacks","connectionCallbacks","buildConnectionCallbacks","handshakeCallbacks","buildHandshakeCallbacks","Network","getNetwork","netinfo","retryIn","sendActivityCheck","updateStrategy","runner","strategy","updateState","startConnecting","setUnavailableTimer","disconnectInternally","handshake","connect","handshakeError","abortConnecting","abort","clearRetryTimer","clearUnavailableTimer","abandonConnection","getStrategy","round","retryTimer","ensureAborted","unavailableTimer","stopActivityCheck","activityTimer","pong_timed_out","resetActivityCheck","shouldRetry","connected","Infinity","setConnection","withErrorEmitted","tls_only","refused","backoff","retry","newState","previousState","newStateDescription","previous","current","channels","createEncryptedChannel","errMsg","createPrivateChannel","createPresenceChannel","createChannel","values","createChannels","createConnectionManager","createTimelineSender","createHandshake","createAssistantToTheTransportManager","livesLeft","lives","strategies","loop","failFast","timeout","timeoutLimit","minPriority","tryNextStrategy","tryStrategy","forceMinPriority","isRunning","callbackBuilder","runners","rs","abortRunner","allRunnersFailed","aborted","transports","ttl","storage","getLocalStorage","serializedCache","getTransportCacheKey","flushTransportCache","fetchTransportCache","cacheSkipCount","timestamp","includes","cached","latency","startTimestamp","pop","cb","storeTransportCache","number","IfStrategy","trueBranch","falseBranch","FirstConnectedStrategy","testSupportsStrategy","baseOptions","defineTransport","definedTransports","defineTransportStrategy","wsStrategy","ws_options","wsHost","wss_options","http_options","timeouts","ws_manager","streaming_manager","ws_transport","wss_transport","xhr_streaming_transport","xhr_polling_transport","ws_loop","wss_loop","streaming_loop","polling_loop","http_loop","payload","position","xhr","getRequest","unloader","addUnloadListener","setRequestHeader","removeUnloadListener","abortRequest","chunk","advanceBuffer","isBufferTooLong","buffer","unreadData","endOfLinePosition","State","autoIncrement","getUniqueURL","separator","randomNumber","randomInt","session","randomString","location","parts","exec","base","getLocation","readyState","CONNECTING","openStream","sendRaw","sendHeartbeat","OPEN","createSocketRequest","start","closeStream","CLOSED","onEvent","onHeartbeat","hostname","urlParts","stream","getReceiveURL","onChunk","onFinished","reconnect","unbind_all","getXHRAPI","onreadystatechange","onprogress","responseText","getDefaultStrategy","Transports","createSocket","createRequest","PusherClass","ready","getClientFeatures","getProtocol","createXHR","query","authOptions","authRequestType","headers","Headers","headerName","headersProvider","dynamicHeaders","body","request","Request","credentials","fetch","then","response","text","parsedData","catch","err","sender","host","json","setup","TimelineLevel","getAuthorizers","ajax","WebSocket","XMLHttpRequest","floor","globalThis","crypto","getRandomValues","Uint32Array","events","sent","uniqueID","level","limit","shift","ERROR","INFO","DEBUG","sendfn","bundle","lib","version","cluster","features","failAttempt","onInitialized","serializedTransport","AuthRequestType","transportClass","enabledTransports","disabledTransports","ignoreNullOrigin","getAssistant","deferred","paramsProvider","dynamicParams","composeChannelQuery","UserAuthentication","ChannelAuthorization","getConfig","opts","statsHost","enableStats","getEnableStatsConfig","getHttpHost","shouldUseTLS","getWebsocketHost","userAuthenticator","buildUserAuthenticator","buildChannelAuthorizer","timelineParams","forceTLS","disableStats","customHandler","channelAuthorizerGenerator","deprecatedAuthorizerOptions","ChannelAuthorizerProxy","authorizer","buildChannelAuth","bindWatchlistInternalEvent","forEach","watchlistEvent","resolve","reject","promise","Promise","res","rej","signin_requested","serverToUserChannel","_signinDoneResolve","_onAuthorize","_cleanup","_signin","_newSigninPromiseIfNeeded","watchlist","_onSigninSuccess","_subscribeChannels","bind_global","reinstateSubscription","subscribe","ensure_subscribed","done","setDone","isReady","instances","app_key","checkAppKey","validateOptions","global_emitter","sessionID","timelineSender","subscribeAll","isUsingTLS","internal","appKey","switchCluster","find","all","timelineSenderTimer","event_name","channel_name","cancelSubscription","signin","Runtime","ScriptReceivers","DependenciesReceivers","auth_callbacks"],"mappings":";;;;;;;CAAA,SAA2CA,EAAMC,GAC1B,iBAAZC,SAA0C,iBAAXC,OACxCA,OAAOD,QAAUD,IACQ,mBAAXG,QAAyBA,OAAOC,IAC9CD,OAAO,GAAIH,GACe,iBAAZC,QACdA,QAAgB,OAAID,IAEpBD,EAAa,OAAIC,IARnB,CASGK,MAAM,WACT,O,YCTE,IAAIC,EAAmB,GAGvB,SAASC,EAAoBC,GAG5B,GAAGF,EAAiBE,GACnB,OAAOF,EAAiBE,GAAUP,QAGnC,IAAIC,EAASI,EAAiBE,GAAY,CACzCC,EAAGD,EACHE,GAAG,EACHT,QAAS,IAUV,OANAU,EAAQH,GAAUI,KAAKV,EAAOD,QAASC,EAAQA,EAAOD,QAASM,G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B,EAAqBkC,GAE/C,OADAhI,KAAK2qB,eAAete,OAAOif,EAAYxlB,EAAUkC,GAC1ChI,KAGT,YAAY8F,GAEV,OADA9F,KAAK2qB,eAAeX,YAAYlkB,GACzB9F,KAGT,cAAc8F,GAEZ,OADA9F,KAAK2qB,eAAere,cAAcxG,GAC3B9F,KAGT,WAAW8F,GAET,OADA9F,KAAK2qB,eAAe/H,aACb5iB,KAGT,eACE,IAAI0V,EACJ,IAAKA,KAAe1V,KAAKmb,SAASA,SAC5Bnb,KAAKmb,SAASA,SAASlZ,eAAeyT,IACxC1V,KAAKkqB,UAAUxU,GAKrB,UAAU6V,GACR,IAAIrZ,EAAUlS,KAAKmb,SAAShP,IAAIof,EAAcvrB,MAS9C,OARIkS,EAAQyC,qBAAuBzC,EAAQ0C,sBACzC1C,EAAQ+X,wBAEP/X,EAAQyC,qBACiB,cAA1B3U,KAAKiR,WAAW1D,OAEhB2E,EAAQgY,YAEHhY,EAGT,YAAYqZ,GACV,IAAIrZ,EAAUlS,KAAKmb,SAASgQ,KAAKI,GAC7BrZ,GAAWA,EAAQyC,oBACrBzC,EAAQsZ,sBAERtZ,EAAUlS,KAAKmb,SAAS/O,OAAOmf,KAChBrZ,EAAQwC,YACrBxC,EAAQgD,cAKd,WAAWoW,EAAoB9oB,EAAW0P,GACxC,OAAOlS,KAAKiR,WAAW0B,WAAW2Y,EAAY9oB,EAAM0P,GAGtD,eACE,OAAOlS,KAAKwV,OAAOzK,OAGrB,SACE/K,KAAKyW,KAAKgV,UAtOL,GAAAlB,UAAsB,GACtB,GAAAD,SAAmB,EACnB,GAAArd,cAAwB,EAGxB,GAAAye,QAA2B,GAC3B,GAAAC,gBAA6B,GAASA,gBACtC,GAAAC,sBAAmC,GAASA,sBAC5C,GAAAC,eAA4B,GAASA,eAVzB,oBAkPrB,GAAQ7G,MAAM","file":"pusher.worker.min.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"Pusher\"] = factory();\n\telse\n\t\troot[\"Pusher\"] = factory();\n})(this, function() {\nreturn "," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 2);\n","// Copyright (C) 2016 Dmitry Chestnykh\n// MIT License. See LICENSE file for details.\n\n/**\n * Package base64 implements Base64 encoding and decoding.\n */\n\n// Invalid character used in decoding to indicate\n// that the character to decode is out of range of\n// alphabet and cannot be decoded.\nconst INVALID_BYTE = 256;\n\n/**\n * Implements standard Base64 encoding.\n *\n * Operates in constant time.\n */\nexport class Coder {\n // TODO(dchest): methods to encode chunk-by-chunk.\n\n constructor(private _paddingCharacter = \"=\") { }\n\n encodedLength(length: number): number {\n if (!this._paddingCharacter) {\n return (length * 8 + 5) / 6 | 0;\n }\n return (length + 2) / 3 * 4 | 0;\n }\n\n encode(data: Uint8Array): string {\n let out = \"\";\n\n let i = 0;\n for (; i < data.length - 2; i += 3) {\n let c = (data[i] << 16) | (data[i + 1] << 8) | (data[i + 2]);\n out += this._encodeByte((c >>> 3 * 6) & 63);\n out += this._encodeByte((c >>> 2 * 6) & 63);\n out += this._encodeByte((c >>> 1 * 6) & 63);\n out += this._encodeByte((c >>> 0 * 6) & 63);\n }\n\n const left = data.length - i;\n if (left > 0) {\n let c = (data[i] << 16) | (left === 2 ? data[i + 1] << 8 : 0);\n out += this._encodeByte((c >>> 3 * 6) & 63);\n out += this._encodeByte((c >>> 2 * 6) & 63);\n if (left === 2) {\n out += this._encodeByte((c >>> 1 * 6) & 63);\n } else {\n out += this._paddingCharacter || \"\";\n }\n out += this._paddingCharacter || \"\";\n }\n\n return out;\n }\n\n maxDecodedLength(length: number): number {\n if (!this._paddingCharacter) {\n return (length * 6 + 7) / 8 | 0;\n }\n return length / 4 * 3 | 0;\n }\n\n decodedLength(s: string): number {\n return this.maxDecodedLength(s.length - this._getPaddingLength(s));\n }\n\n decode(s: string): Uint8Array {\n if (s.length === 0) {\n return new Uint8Array(0);\n }\n const paddingLength = this._getPaddingLength(s);\n const length = s.length - paddingLength;\n const out = new Uint8Array(this.maxDecodedLength(length));\n let op = 0;\n let i = 0;\n let haveBad = 0;\n let v0 = 0, v1 = 0, v2 = 0, v3 = 0;\n for (; i < length - 4; i += 4) {\n v0 = this._decodeChar(s.charCodeAt(i + 0));\n v1 = this._decodeChar(s.charCodeAt(i + 1));\n v2 = this._decodeChar(s.charCodeAt(i + 2));\n v3 = this._decodeChar(s.charCodeAt(i + 3));\n out[op++] = (v0 << 2) | (v1 >>> 4);\n out[op++] = (v1 << 4) | (v2 >>> 2);\n out[op++] = (v2 << 6) | v3;\n haveBad |= v0 & INVALID_BYTE;\n haveBad |= v1 & INVALID_BYTE;\n haveBad |= v2 & INVALID_BYTE;\n haveBad |= v3 & INVALID_BYTE;\n }\n if (i < length - 1) {\n v0 = this._decodeChar(s.charCodeAt(i));\n v1 = this._decodeChar(s.charCodeAt(i + 1));\n out[op++] = (v0 << 2) | (v1 >>> 4);\n haveBad |= v0 & INVALID_BYTE;\n haveBad |= v1 & INVALID_BYTE;\n }\n if (i < length - 2) {\n v2 = this._decodeChar(s.charCodeAt(i + 2));\n out[op++] = (v1 << 4) | (v2 >>> 2);\n haveBad |= v2 & INVALID_BYTE;\n }\n if (i < length - 3) {\n v3 = this._decodeChar(s.charCodeAt(i + 3));\n out[op++] = (v2 << 6) | v3;\n haveBad |= v3 & INVALID_BYTE;\n }\n if (haveBad !== 0) {\n throw new Error(\"Base64Coder: incorrect characters for decoding\");\n }\n return out;\n }\n\n // Standard encoding have the following encoded/decoded ranges,\n // which we need to convert between.\n //\n // ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 0123456789 + /\n // Index: 0 - 25 26 - 51 52 - 61 62 63\n // ASCII: 65 - 90 97 - 122 48 - 57 43 47\n //\n\n // Encode 6 bits in b into a new character.\n protected _encodeByte(b: number): string {\n // Encoding uses constant time operations as follows:\n //\n // 1. Define comparison of A with B using (A - B) >>> 8:\n // if A > B, then result is positive integer\n // if A <= B, then result is 0\n //\n // 2. Define selection of C or 0 using bitwise AND: X & C:\n // if X == 0, then result is 0\n // if X != 0, then result is C\n //\n // 3. Start with the smallest comparison (b >= 0), which is always\n // true, so set the result to the starting ASCII value (65).\n //\n // 4. Continue comparing b to higher ASCII values, and selecting\n // zero if comparison isn't true, otherwise selecting a value\n // to add to result, which:\n //\n // a) undoes the previous addition\n // b) provides new value to add\n //\n let result = b;\n // b >= 0\n result += 65;\n // b > 25\n result += ((25 - b) >>> 8) & ((0 - 65) - 26 + 97);\n // b > 51\n result += ((51 - b) >>> 8) & ((26 - 97) - 52 + 48);\n // b > 61\n result += ((61 - b) >>> 8) & ((52 - 48) - 62 + 43);\n // b > 62\n result += ((62 - b) >>> 8) & ((62 - 43) - 63 + 47);\n\n return String.fromCharCode(result);\n }\n\n // Decode a character code into a byte.\n // Must return 256 if character is out of alphabet range.\n protected _decodeChar(c: number): number {\n // Decoding works similar to encoding: using the same comparison\n // function, but now it works on ranges: result is always incremented\n // by value, but this value becomes zero if the range is not\n // satisfied.\n //\n // Decoding starts with invalid value, 256, which is then\n // subtracted when the range is satisfied. If none of the ranges\n // apply, the function returns 256, which is then checked by\n // the caller to throw error.\n let result = INVALID_BYTE; // start with invalid character\n\n // c == 43 (c > 42 and c < 44)\n result += (((42 - c) & (c - 44)) >>> 8) & (-INVALID_BYTE + c - 43 + 62);\n // c == 47 (c > 46 and c < 48)\n result += (((46 - c) & (c - 48)) >>> 8) & (-INVALID_BYTE + c - 47 + 63);\n // c > 47 and c < 58\n result += (((47 - c) & (c - 58)) >>> 8) & (-INVALID_BYTE + c - 48 + 52);\n // c > 64 and c < 91\n result += (((64 - c) & (c - 91)) >>> 8) & (-INVALID_BYTE + c - 65 + 0);\n // c > 96 and c < 123\n result += (((96 - c) & (c - 123)) >>> 8) & (-INVALID_BYTE + c - 97 + 26);\n\n return result;\n }\n\n private _getPaddingLength(s: string): number {\n let paddingLength = 0;\n if (this._paddingCharacter) {\n for (let i = s.length - 1; i >= 0; i--) {\n if (s[i] !== this._paddingCharacter) {\n break;\n }\n paddingLength++;\n }\n if (s.length < 4 || paddingLength > 2) {\n throw new Error(\"Base64Coder: incorrect padding\");\n }\n }\n return paddingLength;\n }\n\n}\n\nconst stdCoder = new Coder();\n\nexport function encode(data: Uint8Array): string {\n return stdCoder.encode(data);\n}\n\nexport function decode(s: string): Uint8Array {\n return stdCoder.decode(s);\n}\n\n/**\n * Implements URL-safe Base64 encoding.\n * (Same as Base64, but '+' is replaced with '-', and '/' with '_').\n *\n * Operates in constant time.\n */\nexport class URLSafeCoder extends Coder {\n // URL-safe encoding have the following encoded/decoded ranges:\n //\n // ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 0123456789 - _\n // Index: 0 - 25 26 - 51 52 - 61 62 63\n // ASCII: 65 - 90 97 - 122 48 - 57 45 95\n //\n\n protected _encodeByte(b: number): string {\n let result = b;\n // b >= 0\n result += 65;\n // b > 25\n result += ((25 - b) >>> 8) & ((0 - 65) - 26 + 97);\n // b > 51\n result += ((51 - b) >>> 8) & ((26 - 97) - 52 + 48);\n // b > 61\n result += ((61 - b) >>> 8) & ((52 - 48) - 62 + 45);\n // b > 62\n result += ((62 - b) >>> 8) & ((62 - 45) - 63 + 95);\n\n return String.fromCharCode(result);\n }\n\n protected _decodeChar(c: number): number {\n let result = INVALID_BYTE;\n\n // c == 45 (c > 44 and c < 46)\n result += (((44 - c) & (c - 46)) >>> 8) & (-INVALID_BYTE + c - 45 + 62);\n // c == 95 (c > 94 and c < 96)\n result += (((94 - c) & (c - 96)) >>> 8) & (-INVALID_BYTE + c - 95 + 63);\n // c > 47 and c < 58\n result += (((47 - c) & (c - 58)) >>> 8) & (-INVALID_BYTE + c - 48 + 52);\n // c > 64 and c < 91\n result += (((64 - c) & (c - 91)) >>> 8) & (-INVALID_BYTE + c - 65 + 0);\n // c > 96 and c < 123\n result += (((96 - c) & (c - 123)) >>> 8) & (-INVALID_BYTE + c - 97 + 26);\n\n return result;\n }\n}\n\nconst urlSafeCoder = new URLSafeCoder();\n\nexport function encodeURLSafe(data: Uint8Array): string {\n return urlSafeCoder.encode(data);\n}\n\nexport function decodeURLSafe(s: string): Uint8Array {\n return urlSafeCoder.decode(s);\n}\n\n\nexport const encodedLength = (length: number) =>\n stdCoder.encodedLength(length);\n\nexport const maxDecodedLength = (length: number) =>\n stdCoder.maxDecodedLength(length);\n\nexport const decodedLength = (s: string) =>\n stdCoder.decodedLength(s);\n","// Copyright (C) 2016 Dmitry Chestnykh\n// MIT License. See LICENSE file for details.\n\n/**\n * Package utf8 implements UTF-8 encoding and decoding.\n */\n\nconst INVALID_UTF16 = \"utf8: invalid string\";\nconst INVALID_UTF8 = \"utf8: invalid source encoding\";\n\n/**\n * Encodes the given string into UTF-8 byte array.\n * Throws if the source string has invalid UTF-16 encoding.\n */\nexport function encode(s: string): Uint8Array {\n // Calculate result length and allocate output array.\n // encodedLength() also validates string and throws errors,\n // so we don't need repeat validation here.\n const arr = new Uint8Array(encodedLength(s));\n\n let pos = 0;\n for (let i = 0; i < s.length; i++) {\n let c = s.charCodeAt(i);\n if (c < 0x80) {\n arr[pos++] = c;\n } else if (c < 0x800) {\n arr[pos++] = 0xc0 | c >> 6;\n arr[pos++] = 0x80 | c & 0x3f;\n } else if (c < 0xd800) {\n arr[pos++] = 0xe0 | c >> 12;\n arr[pos++] = 0x80 | (c >> 6) & 0x3f;\n arr[pos++] = 0x80 | c & 0x3f;\n } else {\n i++; // get one more character\n c = (c & 0x3ff) << 10;\n c |= s.charCodeAt(i) & 0x3ff;\n c += 0x10000;\n\n arr[pos++] = 0xf0 | c >> 18;\n arr[pos++] = 0x80 | (c >> 12) & 0x3f;\n arr[pos++] = 0x80 | (c >> 6) & 0x3f;\n arr[pos++] = 0x80 | c & 0x3f;\n }\n }\n return arr;\n}\n\n/**\n * Returns the number of bytes required to encode the given string into UTF-8.\n * Throws if the source string has invalid UTF-16 encoding.\n */\nexport function encodedLength(s: string): number {\n let result = 0;\n for (let i = 0; i < s.length; i++) {\n const c = s.charCodeAt(i);\n if (c < 0x80) {\n result += 1;\n } else if (c < 0x800) {\n result += 2;\n } else if (c < 0xd800) {\n result += 3;\n } else if (c <= 0xdfff) {\n if (i >= s.length - 1) {\n throw new Error(INVALID_UTF16);\n }\n i++; // \"eat\" next character\n result += 4;\n } else {\n throw new Error(INVALID_UTF16);\n }\n }\n return result;\n}\n\n/**\n * Decodes the given byte array from UTF-8 into a string.\n * Throws if encoding is invalid.\n */\nexport function decode(arr: Uint8Array): string {\n const chars: string[] = [];\n for (let i = 0; i < arr.length; i++) {\n let b = arr[i];\n\n if (b & 0x80) {\n let min;\n if (b < 0xe0) {\n // Need 1 more byte.\n if (i >= arr.length) {\n throw new Error(INVALID_UTF8);\n }\n const n1 = arr[++i];\n if ((n1 & 0xc0) !== 0x80) {\n throw new Error(INVALID_UTF8);\n }\n b = (b & 0x1f) << 6 | (n1 & 0x3f);\n min = 0x80;\n } else if (b < 0xf0) {\n // Need 2 more bytes.\n if (i >= arr.length - 1) {\n throw new Error(INVALID_UTF8);\n }\n const n1 = arr[++i];\n const n2 = arr[++i];\n if ((n1 & 0xc0) !== 0x80 || (n2 & 0xc0) !== 0x80) {\n throw new Error(INVALID_UTF8);\n }\n b = (b & 0x0f) << 12 | (n1 & 0x3f) << 6 | (n2 & 0x3f);\n min = 0x800;\n } else if (b < 0xf8) {\n // Need 3 more bytes.\n if (i >= arr.length - 2) {\n throw new Error(INVALID_UTF8);\n }\n const n1 = arr[++i];\n const n2 = arr[++i];\n const n3 = arr[++i];\n if ((n1 & 0xc0) !== 0x80 || (n2 & 0xc0) !== 0x80 || (n3 & 0xc0) !== 0x80) {\n throw new Error(INVALID_UTF8);\n }\n b = (b & 0x0f) << 18 | (n1 & 0x3f) << 12 | (n2 & 0x3f) << 6 | (n3 & 0x3f);\n min = 0x10000;\n } else {\n throw new Error(INVALID_UTF8);\n }\n\n if (b < min || (b >= 0xd800 && b <= 0xdfff)) {\n throw new Error(INVALID_UTF8);\n }\n\n if (b >= 0x10000) {\n // Surrogate pair.\n if (b > 0x10ffff) {\n throw new Error(INVALID_UTF8);\n }\n b -= 0x10000;\n chars.push(String.fromCharCode(0xd800 | (b >> 10)));\n b = 0xdc00 | (b & 0x3ff);\n }\n }\n\n chars.push(String.fromCharCode(b));\n }\n return chars.join(\"\");\n}\n","// required so we don't have to do require('pusher').default etc.\nmodule.exports = require('./pusher').default;\n","export default function encode(s: any): string {\n return btoa(utob(s));\n}\n\nvar fromCharCode = String.fromCharCode;\n\nvar b64chars =\n 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';\nvar b64tab = {};\n\nfor (var i = 0, l = b64chars.length; i < l; i++) {\n b64tab[b64chars.charAt(i)] = i;\n}\n\nvar cb_utob = function(c) {\n var cc = c.charCodeAt(0);\n return cc < 0x80\n ? c\n : cc < 0x800\n ? fromCharCode(0xc0 | (cc >>> 6)) + fromCharCode(0x80 | (cc & 0x3f))\n : fromCharCode(0xe0 | ((cc >>> 12) & 0x0f)) +\n fromCharCode(0x80 | ((cc >>> 6) & 0x3f)) +\n fromCharCode(0x80 | (cc & 0x3f));\n};\n\nvar utob = function(u) {\n return u.replace(/[^\\x00-\\x7F]/g, cb_utob);\n};\n\nvar cb_encode = function(ccc) {\n var padlen = [0, 2, 1][ccc.length % 3];\n var ord =\n (ccc.charCodeAt(0) << 16) |\n ((ccc.length > 1 ? ccc.charCodeAt(1) : 0) << 8) |\n (ccc.length > 2 ? ccc.charCodeAt(2) : 0);\n var chars = [\n b64chars.charAt(ord >>> 18),\n b64chars.charAt((ord >>> 12) & 63),\n padlen >= 2 ? '=' : b64chars.charAt((ord >>> 6) & 63),\n padlen >= 1 ? '=' : b64chars.charAt(ord & 63)\n ];\n return chars.join('');\n};\n\nvar btoa =\n global.btoa ||\n function(b) {\n return b.replace(/[\\s\\S]{1,3}/g, cb_encode);\n };\n","import TimedCallback from './timed_callback';\nimport { Delay, Scheduler, Canceller } from './scheduling';\n\nabstract class Timer {\n protected clear: Canceller;\n protected timer: number | void;\n\n constructor(\n set: Scheduler,\n clear: Canceller,\n delay: Delay,\n callback: TimedCallback\n ) {\n this.clear = clear;\n this.timer = set(() => {\n if (this.timer) {\n this.timer = callback(this.timer);\n }\n }, delay);\n }\n\n /** Returns whether the timer is still running.\n *\n * @return {Boolean}\n */\n isRunning(): boolean {\n return this.timer !== null;\n }\n\n /** Aborts a timer when it's running. */\n ensureAborted() {\n if (this.timer) {\n this.clear(this.timer);\n this.timer = null;\n }\n }\n}\n\nexport default Timer;\n","import Timer from './abstract_timer';\nimport TimedCallback from './timed_callback';\nimport { Delay } from './scheduling';\n\n// We need to bind clear functions this way to avoid exceptions on IE8\nfunction clearTimeout(timer) {\n global.clearTimeout(timer);\n}\nfunction clearInterval(timer) {\n global.clearInterval(timer);\n}\n\n/** Cross-browser compatible one-off timer abstraction.\n *\n * @param {Number} delay\n * @param {Function} callback\n */\nexport class OneOffTimer extends Timer {\n constructor(delay: Delay, callback: TimedCallback) {\n super(setTimeout, clearTimeout, delay, function(timer) {\n callback();\n return null;\n });\n }\n}\n\n/** Cross-browser compatible periodic timer abstraction.\n *\n * @param {Number} delay\n * @param {Function} callback\n */\nexport class PeriodicTimer extends Timer {\n constructor(delay: Delay, callback: TimedCallback) {\n super(setInterval, clearInterval, delay, function(timer) {\n callback();\n return timer;\n });\n }\n}\n","import * as Collections from './utils/collections';\nimport TimedCallback from './utils/timers/timed_callback';\nimport { OneOffTimer, PeriodicTimer } from './utils/timers';\n\nvar Util = {\n now(): number {\n if (Date.now) {\n return Date.now();\n } else {\n return new Date().valueOf();\n }\n },\n\n defer(callback: TimedCallback): OneOffTimer {\n return new OneOffTimer(0, callback);\n },\n\n /** Builds a function that will proxy a method call to its first argument.\n *\n * Allows partial application of arguments, so additional arguments are\n * prepended to the argument list.\n *\n * @param {String} name method name\n * @return {Function} proxy function\n */\n method(name: string, ...args: any[]): Function {\n var boundArguments = Array.prototype.slice.call(arguments, 1);\n return function(object) {\n return object[name].apply(object, boundArguments.concat(arguments));\n };\n }\n};\n\nexport default Util;\n","import base64encode from '../base64';\nimport Util from '../util';\n\n/** Merges multiple objects into the target argument.\n *\n * For properties that are plain Objects, performs a deep-merge. For the\n * rest it just copies the value of the property.\n *\n * To extend prototypes use it as following:\n * Pusher.Util.extend(Target.prototype, Base.prototype)\n *\n * You can also use it to merge objects without altering them:\n * Pusher.Util.extend({}, object1, object2)\n *\n * @param {Object} target\n * @return {Object} the target argument\n */\nexport function extend(target: any, ...sources: any[]): T {\n for (var i = 0; i < sources.length; i++) {\n var extensions = sources[i];\n for (var property in extensions) {\n if (\n extensions[property] &&\n extensions[property].constructor &&\n extensions[property].constructor === Object\n ) {\n target[property] = extend(target[property] || {}, extensions[property]);\n } else {\n target[property] = extensions[property];\n }\n }\n }\n return target;\n}\n\nexport function stringify(): string {\n var m = ['Pusher'];\n for (var i = 0; i < arguments.length; i++) {\n if (typeof arguments[i] === 'string') {\n m.push(arguments[i]);\n } else {\n m.push(safeJSONStringify(arguments[i]));\n }\n }\n return m.join(' : ');\n}\n\nexport function arrayIndexOf(array: any[], item: any): number {\n // MSIE doesn't have array.indexOf\n var nativeIndexOf = Array.prototype.indexOf;\n if (array === null) {\n return -1;\n }\n if (nativeIndexOf && array.indexOf === nativeIndexOf) {\n return array.indexOf(item);\n }\n for (var i = 0, l = array.length; i < l; i++) {\n if (array[i] === item) {\n return i;\n }\n }\n return -1;\n}\n\n/** Applies a function f to all properties of an object.\n *\n * Function f gets 3 arguments passed:\n * - element from the object\n * - key of the element\n * - reference to the object\n *\n * @param {Object} object\n * @param {Function} f\n */\nexport function objectApply(object: any, f: Function) {\n for (var key in object) {\n if (Object.prototype.hasOwnProperty.call(object, key)) {\n f(object[key], key, object);\n }\n }\n}\n\n/** Return a list of objects own proerty keys\n *\n * @param {Object} object\n * @returns {Array}\n */\nexport function keys(object: any): string[] {\n var keys = [];\n objectApply(object, function(_, key) {\n keys.push(key);\n });\n return keys;\n}\n\n/** Return a list of object's own property values\n *\n * @param {Object} object\n * @returns {Array}\n */\nexport function values(object: any): any[] {\n var values = [];\n objectApply(object, function(value) {\n values.push(value);\n });\n return values;\n}\n\n/** Applies a function f to all elements of an array.\n *\n * Function f gets 3 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function apply(array: any[], f: Function, context?: any) {\n for (var i = 0; i < array.length; i++) {\n f.call(context || global, array[i], i, array);\n }\n}\n\n/** Maps all elements of the array and returns the result.\n *\n * Function f gets 4 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n * - reference to the destination array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function map(array: any[], f: Function): any[] {\n var result = [];\n for (var i = 0; i < array.length; i++) {\n result.push(f(array[i], i, array, result));\n }\n return result;\n}\n\n/** Maps all elements of the object and returns the result.\n *\n * Function f gets 4 arguments passed:\n * - element from the object\n * - key of the element\n * - reference to the source object\n * - reference to the destination object\n *\n * @param {Object} object\n * @param {Function} f\n */\nexport function mapObject(object: any, f: Function): any {\n var result = {};\n objectApply(object, function(value, key) {\n result[key] = f(value);\n });\n return result;\n}\n\n/** Filters elements of the array using a test function.\n *\n * Function test gets 4 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n * - reference to the destination array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function filter(array: any[], test: Function): any[] {\n test =\n test ||\n function(value) {\n return !!value;\n };\n\n var result = [];\n for (var i = 0; i < array.length; i++) {\n if (test(array[i], i, array, result)) {\n result.push(array[i]);\n }\n }\n return result;\n}\n\n/** Filters properties of the object using a test function.\n *\n * Function test gets 4 arguments passed:\n * - element from the object\n * - key of the element\n * - reference to the source object\n * - reference to the destination object\n *\n * @param {Object} object\n * @param {Function} f\n */\nexport function filterObject(object: Object, test: Function) {\n var result = {};\n objectApply(object, function(value, key) {\n if ((test && test(value, key, object, result)) || Boolean(value)) {\n result[key] = value;\n }\n });\n return result;\n}\n\n/** Flattens an object into a two-dimensional array.\n *\n * @param {Object} object\n * @return {Array} resulting array of [key, value] pairs\n */\nexport function flatten(object: Object): any[] {\n var result = [];\n objectApply(object, function(value, key) {\n result.push([key, value]);\n });\n return result;\n}\n\n/** Checks whether any element of the array passes the test.\n *\n * Function test gets 3 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function any(array: any[], test: Function): boolean {\n for (var i = 0; i < array.length; i++) {\n if (test(array[i], i, array)) {\n return true;\n }\n }\n return false;\n}\n\n/** Checks whether all elements of the array pass the test.\n *\n * Function test gets 3 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function all(array: any[], test: Function): boolean {\n for (var i = 0; i < array.length; i++) {\n if (!test(array[i], i, array)) {\n return false;\n }\n }\n return true;\n}\n\nexport function encodeParamsObject(data): string {\n return mapObject(data, function(value) {\n if (typeof value === 'object') {\n value = safeJSONStringify(value);\n }\n return encodeURIComponent(base64encode(value.toString()));\n });\n}\n\nexport function buildQueryString(data: any): string {\n var params = filterObject(data, function(value) {\n return value !== undefined;\n });\n\n var query = map(\n flatten(encodeParamsObject(params)),\n Util.method('join', '=')\n ).join('&');\n\n return query;\n}\n\n/**\n * See https://github.com/douglascrockford/JSON-js/blob/master/cycle.js\n *\n * Remove circular references from an object. Required for JSON.stringify in\n * React Native, which tends to blow up a lot.\n *\n * @param {any} object\n * @return {any} Decycled object\n */\nexport function decycleObject(object: any): any {\n var objects = [],\n paths = [];\n\n return (function derez(value, path) {\n var i, name, nu;\n\n switch (typeof value) {\n case 'object':\n if (!value) {\n return null;\n }\n for (i = 0; i < objects.length; i += 1) {\n if (objects[i] === value) {\n return { $ref: paths[i] };\n }\n }\n\n objects.push(value);\n paths.push(path);\n\n if (Object.prototype.toString.apply(value) === '[object Array]') {\n nu = [];\n for (i = 0; i < value.length; i += 1) {\n nu[i] = derez(value[i], path + '[' + i + ']');\n }\n } else {\n nu = {};\n for (name in value) {\n if (Object.prototype.hasOwnProperty.call(value, name)) {\n nu[name] = derez(\n value[name],\n path + '[' + JSON.stringify(name) + ']'\n );\n }\n }\n }\n return nu;\n case 'number':\n case 'string':\n case 'boolean':\n return value;\n }\n })(object, '$');\n}\n\n/**\n * Provides a cross-browser and cross-platform way to safely stringify objects\n * into JSON. This is particularly necessary for ReactNative, where circular JSON\n * structures throw an exception.\n *\n * @param {any} source The object to stringify\n * @return {string} The serialized output.\n */\nexport function safeJSONStringify(source: any): string {\n try {\n return JSON.stringify(source);\n } catch (e) {\n return JSON.stringify(decycleObject(source));\n }\n}\n","import {\n ChannelAuthorizationOptions,\n UserAuthenticationOptions\n} from './auth/options';\nimport { AuthTransport } from './config';\n\nexport interface DefaultConfig {\n VERSION: string;\n PROTOCOL: number;\n wsPort: number;\n wssPort: number;\n wsPath: string;\n httpHost: string;\n httpPort: number;\n httpsPort: number;\n httpPath: string;\n stats_host: string;\n authEndpoint: string;\n authTransport: AuthTransport;\n activityTimeout: number;\n pongTimeout: number;\n unavailableTimeout: number;\n userAuthentication: UserAuthenticationOptions;\n channelAuthorization: ChannelAuthorizationOptions;\n\n cdn_http?: string;\n cdn_https?: string;\n dependency_suffix?: string;\n}\n\nvar Defaults: DefaultConfig = {\n VERSION: VERSION,\n PROTOCOL: 7,\n\n wsPort: 80,\n wssPort: 443,\n wsPath: '',\n // DEPRECATED: SockJS fallback parameters\n httpHost: 'sockjs.pusher.com',\n httpPort: 80,\n httpsPort: 443,\n httpPath: '/pusher',\n // DEPRECATED: Stats\n stats_host: 'stats.pusher.com',\n // DEPRECATED: Other settings\n authEndpoint: '/pusher/auth',\n authTransport: 'ajax',\n activityTimeout: 120000,\n pongTimeout: 30000,\n unavailableTimeout: 10000,\n userAuthentication: {\n endpoint: '/pusher/user-auth',\n transport: 'ajax'\n },\n channelAuthorization: {\n endpoint: '/pusher/auth',\n transport: 'ajax'\n },\n\n // CDN configuration\n cdn_http: CDN_HTTP,\n cdn_https: CDN_HTTPS,\n dependency_suffix: DEPENDENCY_SUFFIX\n};\n\nexport default Defaults;\n","import Defaults from '../defaults';\nimport { default as URLScheme, URLSchemeParams } from './url_scheme';\n\nfunction getGenericURL(\n baseScheme: string,\n params: URLSchemeParams,\n path: string\n): string {\n var scheme = baseScheme + (params.useTLS ? 's' : '');\n var host = params.useTLS ? params.hostTLS : params.hostNonTLS;\n return scheme + '://' + host + path;\n}\n\nfunction getGenericPath(key: string, queryString?: string): string {\n var path = '/app/' + key;\n var query =\n '?protocol=' +\n Defaults.PROTOCOL +\n '&client=js' +\n '&version=' +\n Defaults.VERSION +\n (queryString ? '&' + queryString : '');\n return path + query;\n}\n\nexport var ws: URLScheme = {\n getInitial: function(key: string, params: URLSchemeParams): string {\n var path = (params.httpPath || '') + getGenericPath(key, 'flash=false');\n return getGenericURL('ws', params, path);\n }\n};\n\nexport var http: URLScheme = {\n getInitial: function(key: string, params: URLSchemeParams): string {\n var path = (params.httpPath || '/pusher') + getGenericPath(key);\n return getGenericURL('http', params, path);\n }\n};\n\nexport var sockjs: URLScheme = {\n getInitial: function(key: string, params: URLSchemeParams): string {\n return getGenericURL('http', params, params.httpPath || '/pusher');\n },\n getPath: function(key: string, params: URLSchemeParams): string {\n return getGenericPath(key);\n }\n};\n","import Callback from './callback';\nimport * as Collections from '../utils/collections';\nimport CallbackTable from './callback_table';\n\nexport default class CallbackRegistry {\n _callbacks: CallbackTable;\n\n constructor() {\n this._callbacks = {};\n }\n\n get(name: string): Callback[] {\n return this._callbacks[prefix(name)];\n }\n\n add(name: string, callback: Function, context: any) {\n var prefixedEventName = prefix(name);\n this._callbacks[prefixedEventName] =\n this._callbacks[prefixedEventName] || [];\n this._callbacks[prefixedEventName].push({\n fn: callback,\n context: context\n });\n }\n\n remove(name?: string, callback?: Function, context?: any) {\n if (!name && !callback && !context) {\n this._callbacks = {};\n return;\n }\n\n var names = name ? [prefix(name)] : Collections.keys(this._callbacks);\n\n if (callback || context) {\n this.removeCallback(names, callback, context);\n } else {\n this.removeAllCallbacks(names);\n }\n }\n\n private removeCallback(names: string[], callback: Function, context: any) {\n Collections.apply(\n names,\n function(name) {\n this._callbacks[name] = Collections.filter(\n this._callbacks[name] || [],\n function(binding) {\n return (\n (callback && callback !== binding.fn) ||\n (context && context !== binding.context)\n );\n }\n );\n if (this._callbacks[name].length === 0) {\n delete this._callbacks[name];\n }\n },\n this\n );\n }\n\n private removeAllCallbacks(names: string[]) {\n Collections.apply(\n names,\n function(name) {\n delete this._callbacks[name];\n },\n this\n );\n }\n}\n\nfunction prefix(name: string): string {\n return '_' + name;\n}\n","import * as Collections from '../utils/collections';\nimport Callback from './callback';\nimport Metadata from '../channels/metadata';\nimport CallbackRegistry from './callback_registry';\n\n/** Manages callback bindings and event emitting.\n *\n * @param Function failThrough called when no listeners are bound to an event\n */\nexport default class Dispatcher {\n callbacks: CallbackRegistry;\n global_callbacks: Function[];\n failThrough: Function;\n\n constructor(failThrough?: Function) {\n this.callbacks = new CallbackRegistry();\n this.global_callbacks = [];\n this.failThrough = failThrough;\n }\n\n bind(eventName: string, callback: Function, context?: any) {\n this.callbacks.add(eventName, callback, context);\n return this;\n }\n\n bind_global(callback: Function) {\n this.global_callbacks.push(callback);\n return this;\n }\n\n unbind(eventName?: string, callback?: Function, context?: any) {\n this.callbacks.remove(eventName, callback, context);\n return this;\n }\n\n unbind_global(callback?: Function) {\n if (!callback) {\n this.global_callbacks = [];\n return this;\n }\n\n this.global_callbacks = Collections.filter(\n this.global_callbacks || [],\n c => c !== callback\n );\n\n return this;\n }\n\n unbind_all() {\n this.unbind();\n this.unbind_global();\n return this;\n }\n\n emit(eventName: string, data?: any, metadata?: Metadata): Dispatcher {\n for (var i = 0; i < this.global_callbacks.length; i++) {\n this.global_callbacks[i](eventName, data);\n }\n\n var callbacks = this.callbacks.get(eventName);\n var args = [];\n\n if (metadata) {\n // if there's a metadata argument, we need to call the callback with both\n // data and metadata regardless of whether data is undefined\n args.push(data, metadata);\n } else if (data) {\n // metadata is undefined, so we only need to call the callback with data\n // if data exists\n args.push(data);\n }\n\n if (callbacks && callbacks.length > 0) {\n for (var i = 0; i < callbacks.length; i++) {\n callbacks[i].fn.apply(callbacks[i].context || global, args);\n }\n } else if (this.failThrough) {\n this.failThrough(eventName, data);\n }\n\n return this;\n }\n}\n","import { stringify } from './utils/collections';\nimport Pusher from './pusher';\n\nclass Logger {\n debug(...args: any[]) {\n this.log(this.globalLog, args);\n }\n\n warn(...args: any[]) {\n this.log(this.globalLogWarn, args);\n }\n\n error(...args: any[]) {\n this.log(this.globalLogError, args);\n }\n\n private globalLog = (message: string) => {\n if (global.console && global.console.log) {\n global.console.log(message);\n }\n };\n\n private globalLogWarn(message: string) {\n if (global.console && global.console.warn) {\n global.console.warn(message);\n } else {\n this.globalLog(message);\n }\n }\n\n private globalLogError(message: string) {\n if (global.console && global.console.error) {\n global.console.error(message);\n } else {\n this.globalLogWarn(message);\n }\n }\n\n private log(\n defaultLoggingFunction: (message: string) => void,\n ...args: any[]\n ) {\n var message = stringify.apply(this, arguments);\n if (Pusher.log) {\n Pusher.log(message);\n } else if (Pusher.logToConsole) {\n const log = defaultLoggingFunction.bind(this);\n log(message);\n }\n }\n}\n\nexport default new Logger();\n","import Util from '../util';\nimport * as Collections from '../utils/collections';\nimport { default as EventsDispatcher } from '../events/dispatcher';\nimport Logger from '../logger';\nimport TransportHooks from './transport_hooks';\nimport Socket from '../socket';\nimport Runtime from 'runtime';\nimport Timeline from '../timeline/timeline';\nimport TransportConnectionOptions from './transport_connection_options';\n\n/** Provides universal API for transport connections.\n *\n * Transport connection is a low-level object that wraps a connection method\n * and exposes a simple evented interface for the connection state and\n * messaging. It does not implement Pusher-specific WebSocket protocol.\n *\n * Additionally, it fetches resources needed for transport to work and exposes\n * an interface for querying transport features.\n *\n * States:\n * - new - initial state after constructing the object\n * - initializing - during initialization phase, usually fetching resources\n * - intialized - ready to establish a connection\n * - connection - when connection is being established\n * - open - when connection ready to be used\n * - closed - after connection was closed be either side\n *\n * Emits:\n * - error - after the connection raised an error\n *\n * Options:\n * - useTLS - whether connection should be over TLS\n * - hostTLS - host to connect to when connection is over TLS\n * - hostNonTLS - host to connect to when connection is over TLS\n *\n * @param {String} key application key\n * @param {Object} options\n */\nexport default class TransportConnection extends EventsDispatcher {\n hooks: TransportHooks;\n name: string;\n priority: number;\n key: string;\n options: TransportConnectionOptions;\n state: string;\n timeline: Timeline;\n activityTimeout: number;\n id: number;\n socket: Socket;\n beforeOpen: Function;\n initialize: Function;\n\n constructor(\n hooks: TransportHooks,\n name: string,\n priority: number,\n key: string,\n options: TransportConnectionOptions\n ) {\n super();\n this.initialize = Runtime.transportConnectionInitializer;\n this.hooks = hooks;\n this.name = name;\n this.priority = priority;\n this.key = key;\n this.options = options;\n\n this.state = 'new';\n this.timeline = options.timeline;\n this.activityTimeout = options.activityTimeout;\n this.id = this.timeline.generateUniqueID();\n }\n\n /** Checks whether the transport handles activity checks by itself.\n *\n * @return {Boolean}\n */\n handlesActivityChecks(): boolean {\n return Boolean(this.hooks.handlesActivityChecks);\n }\n\n /** Checks whether the transport supports the ping/pong API.\n *\n * @return {Boolean}\n */\n supportsPing(): boolean {\n return Boolean(this.hooks.supportsPing);\n }\n\n /** Tries to establish a connection.\n *\n * @returns {Boolean} false if transport is in invalid state\n */\n connect(): boolean {\n if (this.socket || this.state !== 'initialized') {\n return false;\n }\n\n var url = this.hooks.urls.getInitial(this.key, this.options);\n try {\n this.socket = this.hooks.getSocket(url, this.options);\n } catch (e) {\n Util.defer(() => {\n this.onError(e);\n this.changeState('closed');\n });\n return false;\n }\n\n this.bindListeners();\n\n Logger.debug('Connecting', { transport: this.name, url });\n this.changeState('connecting');\n return true;\n }\n\n /** Closes the connection.\n *\n * @return {Boolean} true if there was a connection to close\n */\n close(): boolean {\n if (this.socket) {\n this.socket.close();\n return true;\n } else {\n return false;\n }\n }\n\n /** Sends data over the open connection.\n *\n * @param {String} data\n * @return {Boolean} true only when in the \"open\" state\n */\n send(data: any): boolean {\n if (this.state === 'open') {\n // Workaround for MobileSafari bug (see https://gist.github.com/2052006)\n Util.defer(() => {\n if (this.socket) {\n this.socket.send(data);\n }\n });\n return true;\n } else {\n return false;\n }\n }\n\n /** Sends a ping if the connection is open and transport supports it. */\n ping() {\n if (this.state === 'open' && this.supportsPing()) {\n this.socket.ping();\n }\n }\n\n private onOpen() {\n if (this.hooks.beforeOpen) {\n this.hooks.beforeOpen(\n this.socket,\n this.hooks.urls.getPath(this.key, this.options)\n );\n }\n this.changeState('open');\n this.socket.onopen = undefined;\n }\n\n private onError(error) {\n this.emit('error', { type: 'WebSocketError', error: error });\n this.timeline.error(this.buildTimelineMessage({ error: error.toString() }));\n }\n\n private onClose(closeEvent?: any) {\n if (closeEvent) {\n this.changeState('closed', {\n code: closeEvent.code,\n reason: closeEvent.reason,\n wasClean: closeEvent.wasClean\n });\n } else {\n this.changeState('closed');\n }\n this.unbindListeners();\n this.socket = undefined;\n }\n\n private onMessage(message) {\n this.emit('message', message);\n }\n\n private onActivity() {\n this.emit('activity');\n }\n\n private bindListeners() {\n this.socket.onopen = () => {\n this.onOpen();\n };\n this.socket.onerror = error => {\n this.onError(error);\n };\n this.socket.onclose = closeEvent => {\n this.onClose(closeEvent);\n };\n this.socket.onmessage = message => {\n this.onMessage(message);\n };\n\n if (this.supportsPing()) {\n this.socket.onactivity = () => {\n this.onActivity();\n };\n }\n }\n\n private unbindListeners() {\n if (this.socket) {\n this.socket.onopen = undefined;\n this.socket.onerror = undefined;\n this.socket.onclose = undefined;\n this.socket.onmessage = undefined;\n if (this.supportsPing()) {\n this.socket.onactivity = undefined;\n }\n }\n }\n\n private changeState(state: string, params?: any) {\n this.state = state;\n this.timeline.info(\n this.buildTimelineMessage({\n state: state,\n params: params\n })\n );\n this.emit(state, params);\n }\n\n buildTimelineMessage(message): any {\n return Collections.extend({ cid: this.id }, message);\n }\n}\n","import Factory from '../utils/factory';\nimport TransportHooks from './transport_hooks';\nimport TransportConnection from './transport_connection';\nimport TransportConnectionOptions from './transport_connection_options';\n\n/** Provides interface for transport connection instantiation.\n *\n * Takes transport-specific hooks as the only argument, which allow checking\n * for transport support and creating its connections.\n *\n * Supported hooks: * - file - the name of the file to be fetched during initialization\n * - urls - URL scheme to be used by transport\n * - handlesActivityCheck - true when the transport handles activity checks\n * - supportsPing - true when the transport has a ping/activity API\n * - isSupported - tells whether the transport is supported in the environment\n * - getSocket - creates a WebSocket-compatible transport socket\n *\n * See transports.js for specific implementations.\n *\n * @param {Object} hooks object containing all needed transport hooks\n */\nexport default class Transport {\n hooks: TransportHooks;\n\n constructor(hooks: TransportHooks) {\n this.hooks = hooks;\n }\n\n /** Returns whether the transport is supported in the environment.\n *\n * @param {Object} envronment te environment details (encryption, settings)\n * @returns {Boolean} true when the transport is supported\n */\n isSupported(environment: any): boolean {\n return this.hooks.isSupported(environment);\n }\n\n /** Creates a transport connection.\n *\n * @param {String} name\n * @param {Number} priority\n * @param {String} key the application key\n * @param {Object} options\n * @returns {TransportConnection}\n */\n createConnection(\n name: string,\n priority: number,\n key: string,\n options: any\n ): TransportConnection {\n return new TransportConnection(this.hooks, name, priority, key, options);\n }\n}\n","import * as URLSchemes from 'core/transports/url_schemes';\nimport URLScheme from 'core/transports/url_scheme';\nimport Transport from 'core/transports/transport';\nimport Util from 'core/util';\nimport * as Collections from 'core/utils/collections';\nimport TransportHooks from 'core/transports/transport_hooks';\nimport TransportsTable from 'core/transports/transports_table';\nimport Runtime from 'runtime';\n\n/** WebSocket transport.\n *\n * Uses native WebSocket implementation, including MozWebSocket supported by\n * earlier Firefox versions.\n */\nvar WSTransport = new Transport({\n urls: URLSchemes.ws,\n handlesActivityChecks: false,\n supportsPing: false,\n\n isInitialized: function() {\n return Boolean(Runtime.getWebSocketAPI());\n },\n isSupported: function(): boolean {\n return Boolean(Runtime.getWebSocketAPI());\n },\n getSocket: function(url) {\n return Runtime.createWebSocket(url);\n }\n});\n\nvar httpConfiguration = {\n urls: URLSchemes.http,\n handlesActivityChecks: false,\n supportsPing: true,\n isInitialized: function() {\n return true;\n }\n};\n\nexport var streamingConfiguration = Collections.extend(\n {\n getSocket: function(url) {\n return Runtime.HTTPFactory.createStreamingSocket(url);\n }\n },\n httpConfiguration\n);\nexport var pollingConfiguration = Collections.extend(\n {\n getSocket: function(url) {\n return Runtime.HTTPFactory.createPollingSocket(url);\n }\n },\n httpConfiguration\n);\n\nvar xhrConfiguration = {\n isSupported: function(): boolean {\n return Runtime.isXHRSupported();\n }\n};\n\n/** HTTP streaming transport using CORS-enabled XMLHttpRequest. */\nvar XHRStreamingTransport = new Transport(\n (\n Collections.extend({}, streamingConfiguration, xhrConfiguration)\n )\n);\n\n/** HTTP long-polling transport using CORS-enabled XMLHttpRequest. */\nvar XHRPollingTransport = new Transport(\n Collections.extend({}, pollingConfiguration, xhrConfiguration)\n);\n\nvar Transports: TransportsTable = {\n ws: WSTransport,\n xhr_streaming: XHRStreamingTransport,\n xhr_polling: XHRPollingTransport\n};\n\nexport default Transports;\n","import Util from '../util';\nimport * as Collections from '../utils/collections';\nimport TransportManager from './transport_manager';\nimport TransportConnection from './transport_connection';\nimport Transport from './transport';\nimport PingDelayOptions from './ping_delay_options';\n\n/** Creates transport connections monitored by a transport manager.\n *\n * When a transport is closed, it might mean the environment does not support\n * it. It's possible that messages get stuck in an intermediate buffer or\n * proxies terminate inactive connections. To combat these problems,\n * assistants monitor the connection lifetime, report unclean exits and\n * adjust ping timeouts to keep the connection active. The decision to disable\n * a transport is the manager's responsibility.\n *\n * @param {TransportManager} manager\n * @param {TransportConnection} transport\n * @param {Object} options\n */\nexport default class AssistantToTheTransportManager {\n manager: TransportManager;\n transport: Transport;\n minPingDelay: number;\n maxPingDelay: number;\n pingDelay: number;\n\n constructor(\n manager: TransportManager,\n transport: Transport,\n options: PingDelayOptions\n ) {\n this.manager = manager;\n this.transport = transport;\n this.minPingDelay = options.minPingDelay;\n this.maxPingDelay = options.maxPingDelay;\n this.pingDelay = undefined;\n }\n\n /** Creates a transport connection.\n *\n * This function has the same API as Transport#createConnection.\n *\n * @param {String} name\n * @param {Number} priority\n * @param {String} key the application key\n * @param {Object} options\n * @returns {TransportConnection}\n */\n createConnection(\n name: string,\n priority: number,\n key: string,\n options: Object\n ): TransportConnection {\n options = Collections.extend({}, options, {\n activityTimeout: this.pingDelay\n });\n var connection = this.transport.createConnection(\n name,\n priority,\n key,\n options\n );\n\n var openTimestamp = null;\n\n var onOpen = function() {\n connection.unbind('open', onOpen);\n connection.bind('closed', onClosed);\n openTimestamp = Util.now();\n };\n var onClosed = closeEvent => {\n connection.unbind('closed', onClosed);\n\n if (closeEvent.code === 1002 || closeEvent.code === 1003) {\n // we don't want to use transports not obeying the protocol\n this.manager.reportDeath();\n } else if (!closeEvent.wasClean && openTimestamp) {\n // report deaths only for short-living transport\n var lifespan = Util.now() - openTimestamp;\n if (lifespan < 2 * this.maxPingDelay) {\n this.manager.reportDeath();\n this.pingDelay = Math.max(lifespan / 2, this.minPingDelay);\n }\n }\n };\n\n connection.bind('open', onOpen);\n return connection;\n }\n\n /** Returns whether the transport is supported in the environment.\n *\n * This function has the same API as Transport#isSupported. Might return false\n * when the manager decides to kill the transport.\n *\n * @param {Object} environment the environment details (encryption, settings)\n * @returns {Boolean} true when the transport is supported\n */\n isSupported(environment: string): boolean {\n return this.manager.isAlive() && this.transport.isSupported(environment);\n }\n}\n","import Action from './action';\nimport { PusherEvent } from './message-types';\n/**\n * Provides functions for handling Pusher protocol-specific messages.\n */\n\nconst Protocol = {\n /**\n * Decodes a message in a Pusher format.\n *\n * The MessageEvent we receive from the transport should contain a pusher event\n * (https://pusher.com/docs/pusher_protocol#events) serialized as JSON in the\n * data field\n *\n * The pusher event may contain a data field too, and it may also be\n * serialised as JSON\n *\n * Throws errors when messages are not parse'able.\n *\n * @param {MessageEvent} messageEvent\n * @return {PusherEvent}\n */\n decodeMessage: function(messageEvent: MessageEvent): PusherEvent {\n try {\n var messageData = JSON.parse(messageEvent.data);\n var pusherEventData = messageData.data;\n if (typeof pusherEventData === 'string') {\n try {\n pusherEventData = JSON.parse(messageData.data);\n } catch (e) {}\n }\n var pusherEvent: PusherEvent = {\n event: messageData.event,\n channel: messageData.channel,\n data: pusherEventData\n };\n if (messageData.user_id) {\n pusherEvent.user_id = messageData.user_id;\n }\n return pusherEvent;\n } catch (e) {\n throw { type: 'MessageParseError', error: e, data: messageEvent.data };\n }\n },\n\n /**\n * Encodes a message to be sent.\n *\n * @param {PusherEvent} event\n * @return {String}\n */\n encodeMessage: function(event: PusherEvent): string {\n return JSON.stringify(event);\n },\n\n /**\n * Processes a handshake message and returns appropriate actions.\n *\n * Returns an object with an 'action' and other action-specific properties.\n *\n * There are three outcomes when calling this function. First is a successful\n * connection attempt, when pusher:connection_established is received, which\n * results in a 'connected' action with an 'id' property. When passed a\n * pusher:error event, it returns a result with action appropriate to the\n * close code and an error. Otherwise, it raises an exception.\n *\n * @param {String} message\n * @result Object\n */\n processHandshake: function(messageEvent: MessageEvent): Action {\n var message = Protocol.decodeMessage(messageEvent);\n\n if (message.event === 'pusher:connection_established') {\n if (!message.data.activity_timeout) {\n throw 'No activity timeout specified in handshake';\n }\n return {\n action: 'connected',\n id: message.data.socket_id,\n activityTimeout: message.data.activity_timeout * 1000\n };\n } else if (message.event === 'pusher:error') {\n // From protocol 6 close codes are sent only once, so this only\n // happens when connection does not support close codes\n return {\n action: this.getCloseAction(message.data),\n error: this.getCloseError(message.data)\n };\n } else {\n throw 'Invalid handshake';\n }\n },\n\n /**\n * Dispatches the close event and returns an appropriate action name.\n *\n * See:\n * 1. https://developer.mozilla.org/en-US/docs/WebSockets/WebSockets_reference/CloseEvent\n * 2. http://pusher.com/docs/pusher_protocol\n *\n * @param {CloseEvent} closeEvent\n * @return {String} close action name\n */\n getCloseAction: function(closeEvent): string {\n if (closeEvent.code < 4000) {\n // ignore 1000 CLOSE_NORMAL, 1001 CLOSE_GOING_AWAY,\n // 1005 CLOSE_NO_STATUS, 1006 CLOSE_ABNORMAL\n // ignore 1007...3999\n // handle 1002 CLOSE_PROTOCOL_ERROR, 1003 CLOSE_UNSUPPORTED,\n // 1004 CLOSE_TOO_LARGE\n if (closeEvent.code >= 1002 && closeEvent.code <= 1004) {\n return 'backoff';\n } else {\n return null;\n }\n } else if (closeEvent.code === 4000) {\n return 'tls_only';\n } else if (closeEvent.code < 4100) {\n return 'refused';\n } else if (closeEvent.code < 4200) {\n return 'backoff';\n } else if (closeEvent.code < 4300) {\n return 'retry';\n } else {\n // unknown error\n return 'refused';\n }\n },\n\n /**\n * Returns an error or null basing on the close event.\n *\n * Null is returned when connection was closed cleanly. Otherwise, an object\n * with error details is returned.\n *\n * @param {CloseEvent} closeEvent\n * @return {Object} error object\n */\n getCloseError: function(closeEvent): any {\n if (closeEvent.code !== 1000 && closeEvent.code !== 1001) {\n return {\n type: 'PusherError',\n data: {\n code: closeEvent.code,\n message: closeEvent.reason || closeEvent.message\n }\n };\n } else {\n return null;\n }\n }\n};\n\nexport default Protocol;\n","import * as Collections from '../utils/collections';\nimport { default as EventsDispatcher } from '../events/dispatcher';\nimport Protocol from './protocol/protocol';\nimport { PusherEvent } from './protocol/message-types';\nimport Logger from '../logger';\nimport TransportConnection from '../transports/transport_connection';\nimport Socket from '../socket';\n/**\n * Provides Pusher protocol interface for transports.\n *\n * Emits following events:\n * - message - on received messages\n * - ping - on ping requests\n * - pong - on pong responses\n * - error - when the transport emits an error\n * - closed - after closing the transport\n *\n * It also emits more events when connection closes with a code.\n * See Protocol.getCloseAction to get more details.\n *\n * @param {Number} id\n * @param {AbstractTransport} transport\n */\nexport default class Connection extends EventsDispatcher implements Socket {\n id: string;\n transport: TransportConnection;\n activityTimeout: number;\n\n constructor(id: string, transport: TransportConnection) {\n super();\n this.id = id;\n this.transport = transport;\n this.activityTimeout = transport.activityTimeout;\n this.bindListeners();\n }\n\n /** Returns whether used transport handles activity checks by itself\n *\n * @returns {Boolean} true if activity checks are handled by the transport\n */\n handlesActivityChecks() {\n return this.transport.handlesActivityChecks();\n }\n\n /** Sends raw data.\n *\n * @param {String} data\n */\n send(data: any): boolean {\n return this.transport.send(data);\n }\n\n /** Sends an event.\n *\n * @param {String} name\n * @param {String} data\n * @param {String} [channel]\n * @returns {Boolean} whether message was sent or not\n */\n send_event(name: string, data: any, channel?: string): boolean {\n var event: PusherEvent = { event: name, data: data };\n if (channel) {\n event.channel = channel;\n }\n Logger.debug('Event sent', event);\n return this.send(Protocol.encodeMessage(event));\n }\n\n /** Sends a ping message to the server.\n *\n * Basing on the underlying transport, it might send either transport's\n * protocol-specific ping or pusher:ping event.\n */\n ping() {\n if (this.transport.supportsPing()) {\n this.transport.ping();\n } else {\n this.send_event('pusher:ping', {});\n }\n }\n\n /** Closes the connection. */\n close() {\n this.transport.close();\n }\n\n private bindListeners() {\n var listeners = {\n message: (messageEvent: MessageEvent) => {\n var pusherEvent;\n try {\n pusherEvent = Protocol.decodeMessage(messageEvent);\n } catch (e) {\n this.emit('error', {\n type: 'MessageParseError',\n error: e,\n data: messageEvent.data\n });\n }\n\n if (pusherEvent !== undefined) {\n Logger.debug('Event recd', pusherEvent);\n\n switch (pusherEvent.event) {\n case 'pusher:error':\n this.emit('error', {\n type: 'PusherError',\n data: pusherEvent.data\n });\n break;\n case 'pusher:ping':\n this.emit('ping');\n break;\n case 'pusher:pong':\n this.emit('pong');\n break;\n }\n this.emit('message', pusherEvent);\n }\n },\n activity: () => {\n this.emit('activity');\n },\n error: error => {\n this.emit('error', error);\n },\n closed: closeEvent => {\n unbindListeners();\n\n if (closeEvent && closeEvent.code) {\n this.handleCloseEvent(closeEvent);\n }\n\n this.transport = null;\n this.emit('closed');\n }\n };\n\n var unbindListeners = () => {\n Collections.objectApply(listeners, (listener, event) => {\n this.transport.unbind(event, listener);\n });\n };\n\n Collections.objectApply(listeners, (listener, event) => {\n this.transport.bind(event, listener);\n });\n }\n\n private handleCloseEvent(closeEvent: any) {\n var action = Protocol.getCloseAction(closeEvent);\n var error = Protocol.getCloseError(closeEvent);\n if (error) {\n this.emit('error', error);\n }\n if (action) {\n this.emit(action, { action: action, error: error });\n }\n }\n}\n","import Util from '../../util';\nimport * as Collections from '../../utils/collections';\nimport Protocol from '../protocol/protocol';\nimport Connection from '../connection';\nimport TransportConnection from '../../transports/transport_connection';\nimport HandshakePayload from './handshake_payload';\n\n/**\n * Handles Pusher protocol handshakes for transports.\n *\n * Calls back with a result object after handshake is completed. Results\n * always have two fields:\n * - action - string describing action to be taken after the handshake\n * - transport - the transport object passed to the constructor\n *\n * Different actions can set different additional properties on the result.\n * In the case of 'connected' action, there will be a 'connection' property\n * containing a Connection object for the transport. Other actions should\n * carry an 'error' property.\n *\n * @param {AbstractTransport} transport\n * @param {Function} callback\n */\nexport default class Handshake {\n transport: TransportConnection;\n callback: (HandshakePayload) => void;\n onMessage: Function;\n onClosed: Function;\n\n constructor(\n transport: TransportConnection,\n callback: (HandshakePayload) => void\n ) {\n this.transport = transport;\n this.callback = callback;\n this.bindListeners();\n }\n\n close() {\n this.unbindListeners();\n this.transport.close();\n }\n\n private bindListeners() {\n this.onMessage = m => {\n this.unbindListeners();\n\n var result;\n try {\n result = Protocol.processHandshake(m);\n } catch (e) {\n this.finish('error', { error: e });\n this.transport.close();\n return;\n }\n\n if (result.action === 'connected') {\n this.finish('connected', {\n connection: new Connection(result.id, this.transport),\n activityTimeout: result.activityTimeout\n });\n } else {\n this.finish(result.action, { error: result.error });\n this.transport.close();\n }\n };\n\n this.onClosed = closeEvent => {\n this.unbindListeners();\n\n var action = Protocol.getCloseAction(closeEvent) || 'backoff';\n var error = Protocol.getCloseError(closeEvent);\n this.finish(action, { error: error });\n };\n\n this.transport.bind('message', this.onMessage);\n this.transport.bind('closed', this.onClosed);\n }\n\n private unbindListeners() {\n this.transport.unbind('message', this.onMessage);\n this.transport.unbind('closed', this.onClosed);\n }\n\n private finish(action: string, params: any) {\n this.callback(\n Collections.extend({ transport: this.transport, action: action }, params)\n );\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport base64encode from '../base64';\nimport Timeline from './timeline';\nimport Runtime from 'runtime';\n\nexport interface TimelineSenderOptions {\n host?: string;\n port?: number;\n path?: string;\n}\n\nexport default class TimelineSender {\n timeline: Timeline;\n options: TimelineSenderOptions;\n host: string;\n\n constructor(timeline: Timeline, options: TimelineSenderOptions) {\n this.timeline = timeline;\n this.options = options || {};\n }\n\n send(useTLS: boolean, callback?: Function) {\n if (this.timeline.isEmpty()) {\n return;\n }\n\n this.timeline.send(\n Runtime.TimelineTransport.getAgent(this, useTLS),\n callback\n );\n }\n}\n","/** Error classes used throughout the library. */\n// https://github.com/Microsoft/TypeScript-wiki/blob/master/Breaking-Changes.md#extending-built-ins-like-error-array-and-map-may-no-longer-work\nexport class BadEventName extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\nexport class BadChannelName extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\nexport class RequestTimedOut extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class TransportPriorityTooLow extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class TransportClosed extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class UnsupportedFeature extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class UnsupportedTransport extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class UnsupportedStrategy extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class HTTPAuthError extends Error {\n status: number;\n constructor(status: number, msg?: string) {\n super(msg);\n this.status = status;\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n","/**\n * A place to store help URLs for error messages etc\n */\n\nconst urlStore = {\n baseUrl: 'https://pusher.com',\n urls: {\n authenticationEndpoint: {\n path: '/docs/channels/server_api/authenticating_users'\n },\n authorizationEndpoint: {\n path: '/docs/channels/server_api/authorizing-users/'\n },\n javascriptQuickStart: {\n path: '/docs/javascript_quick_start'\n },\n triggeringClientEvents: {\n path: '/docs/client_api_guide/client_events#trigger-events'\n },\n encryptedChannelSupport: {\n fullUrl:\n 'https://github.com/pusher/pusher-js/tree/cc491015371a4bde5743d1c87a0fbac0feb53195#encrypted-channel-support'\n }\n }\n};\n\n/** Builds a consistent string with links to pusher documentation\n *\n * @param {string} key - relevant key in the url_store.urls object\n * @return {string} suffix string to append to log message\n */\nconst buildLogSuffix = function(key: string): string {\n const urlPrefix = 'See:';\n const urlObj = urlStore.urls[key];\n if (!urlObj) return '';\n\n let url;\n if (urlObj.fullUrl) {\n url = urlObj.fullUrl;\n } else if (urlObj.path) {\n url = urlStore.baseUrl + urlObj.path;\n }\n\n if (!url) return '';\n return `${urlPrefix} ${url}`;\n};\n\nexport default { buildLogSuffix };\n","import { default as EventsDispatcher } from '../events/dispatcher';\nimport * as Errors from '../errors';\nimport Logger from '../logger';\nimport Pusher from '../pusher';\nimport { PusherEvent } from '../connection/protocol/message-types';\nimport Metadata from './metadata';\nimport UrlStore from '../utils/url_store';\nimport {\n ChannelAuthorizationData,\n ChannelAuthorizationCallback\n} from '../auth/options';\nimport { HTTPAuthError } from '../errors';\n\n/** Provides base public channel interface with an event emitter.\n *\n * Emits:\n * - pusher:subscription_succeeded - after subscribing successfully\n * - other non-internal events\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\nexport default class Channel extends EventsDispatcher {\n name: string;\n pusher: Pusher;\n subscribed: boolean;\n subscriptionPending: boolean;\n subscriptionCancelled: boolean;\n subscriptionCount: null;\n\n constructor(name: string, pusher: Pusher) {\n super(function(event, data) {\n Logger.debug('No callbacks on ' + name + ' for ' + event);\n });\n\n this.name = name;\n this.pusher = pusher;\n this.subscribed = false;\n this.subscriptionPending = false;\n this.subscriptionCancelled = false;\n }\n\n /** Skips authorization, since public channels don't require it.\n *\n * @param {Function} callback\n */\n authorize(socketId: string, callback: ChannelAuthorizationCallback) {\n return callback(null, { auth: '' });\n }\n\n /** Triggers an event */\n trigger(event: string, data: any) {\n if (event.indexOf('client-') !== 0) {\n throw new Errors.BadEventName(\n \"Event '\" + event + \"' does not start with 'client-'\"\n );\n }\n if (!this.subscribed) {\n var suffix = UrlStore.buildLogSuffix('triggeringClientEvents');\n Logger.warn(\n `Client event triggered before channel 'subscription_succeeded' event . ${suffix}`\n );\n }\n return this.pusher.send_event(event, data, this.name);\n }\n\n /** Signals disconnection to the channel. For internal use only. */\n disconnect() {\n this.subscribed = false;\n this.subscriptionPending = false;\n }\n\n /** Handles a PusherEvent. For internal use only.\n *\n * @param {PusherEvent} event\n */\n handleEvent(event: PusherEvent) {\n var eventName = event.event;\n var data = event.data;\n if (eventName === 'pusher_internal:subscription_succeeded') {\n this.handleSubscriptionSucceededEvent(event);\n } else if (eventName === 'pusher_internal:subscription_count') {\n this.handleSubscriptionCountEvent(event);\n } else if (eventName.indexOf('pusher_internal:') !== 0) {\n var metadata: Metadata = {};\n this.emit(eventName, data, metadata);\n }\n }\n\n handleSubscriptionSucceededEvent(event: PusherEvent) {\n this.subscriptionPending = false;\n this.subscribed = true;\n if (this.subscriptionCancelled) {\n this.pusher.unsubscribe(this.name);\n } else {\n this.emit('pusher:subscription_succeeded', event.data);\n }\n }\n\n handleSubscriptionCountEvent(event: PusherEvent) {\n if (event.data.subscription_count) {\n this.subscriptionCount = event.data.subscription_count;\n }\n\n this.emit('pusher:subscription_count', event.data);\n }\n\n /** Sends a subscription request. For internal use only. */\n subscribe() {\n if (this.subscribed) {\n return;\n }\n this.subscriptionPending = true;\n this.subscriptionCancelled = false;\n this.authorize(\n this.pusher.connection.socket_id,\n (error: Error | null, data: ChannelAuthorizationData) => {\n if (error) {\n this.subscriptionPending = false;\n // Why not bind to 'pusher:subscription_error' a level up, and log there?\n // Binding to this event would cause the warning about no callbacks being\n // bound (see constructor) to be suppressed, that's not what we want.\n Logger.error(error.toString());\n this.emit(\n 'pusher:subscription_error',\n Object.assign(\n {},\n {\n type: 'AuthError',\n error: error.message\n },\n error instanceof HTTPAuthError ? { status: error.status } : {}\n )\n );\n } else {\n this.pusher.send_event('pusher:subscribe', {\n auth: data.auth,\n channel_data: data.channel_data,\n channel: this.name\n });\n }\n }\n );\n }\n\n /** Sends an unsubscription request. For internal use only. */\n unsubscribe() {\n this.subscribed = false;\n this.pusher.send_event('pusher:unsubscribe', {\n channel: this.name\n });\n }\n\n /** Cancels an in progress subscription. For internal use only. */\n cancelSubscription() {\n this.subscriptionCancelled = true;\n }\n\n /** Reinstates an in progress subscripiton. For internal use only. */\n reinstateSubscription() {\n this.subscriptionCancelled = false;\n }\n}\n","import Factory from '../utils/factory';\nimport Channel from './channel';\nimport { ChannelAuthorizationCallback } from '../auth/options';\n\n/** Extends public channels to provide private channel interface.\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\nexport default class PrivateChannel extends Channel {\n /** Authorizes the connection to use the channel.\n *\n * @param {String} socketId\n * @param {Function} callback\n */\n authorize(socketId: string, callback: ChannelAuthorizationCallback) {\n return this.pusher.config.channelAuthorizer(\n {\n channelName: this.name,\n socketId: socketId\n },\n callback\n );\n }\n}\n","import * as Collections from '../utils/collections';\n\n/** Represents a collection of members of a presence channel. */\nexport default class Members {\n members: any;\n count: number;\n myID: any;\n me: any;\n\n constructor() {\n this.reset();\n }\n\n /** Returns member's info for given id.\n *\n * Resulting object containts two fields - id and info.\n *\n * @param {Number} id\n * @return {Object} member's info or null\n */\n get(id: string): any {\n if (Object.prototype.hasOwnProperty.call(this.members, id)) {\n return {\n id: id,\n info: this.members[id]\n };\n } else {\n return null;\n }\n }\n\n /** Calls back for each member in unspecified order.\n *\n * @param {Function} callback\n */\n each(callback: Function) {\n Collections.objectApply(this.members, (member, id) => {\n callback(this.get(id));\n });\n }\n\n /** Updates the id for connected member. For internal use only. */\n setMyID(id: string) {\n this.myID = id;\n }\n\n /** Handles subscription data. For internal use only. */\n onSubscription(subscriptionData: any) {\n this.members = subscriptionData.presence.hash;\n this.count = subscriptionData.presence.count;\n this.me = this.get(this.myID);\n }\n\n /** Adds a new member to the collection. For internal use only. */\n addMember(memberData: any) {\n if (this.get(memberData.user_id) === null) {\n this.count++;\n }\n this.members[memberData.user_id] = memberData.user_info;\n return this.get(memberData.user_id);\n }\n\n /** Adds a member from the collection. For internal use only. */\n removeMember(memberData: any) {\n var member = this.get(memberData.user_id);\n if (member) {\n delete this.members[memberData.user_id];\n this.count--;\n }\n return member;\n }\n\n /** Resets the collection to the initial state. For internal use only. */\n reset() {\n this.members = {};\n this.count = 0;\n this.myID = null;\n this.me = null;\n }\n}\n","import PrivateChannel from './private_channel';\nimport Logger from '../logger';\nimport Members from './members';\nimport Pusher from '../pusher';\nimport UrlStore from 'core/utils/url_store';\nimport { PusherEvent } from '../connection/protocol/message-types';\nimport Metadata from './metadata';\nimport { ChannelAuthorizationData } from '../auth/options';\n\nexport default class PresenceChannel extends PrivateChannel {\n members: Members;\n\n /** Adds presence channel functionality to private channels.\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\n constructor(name: string, pusher: Pusher) {\n super(name, pusher);\n this.members = new Members();\n }\n\n /** Authorizes the connection as a member of the channel.\n *\n * @param {String} socketId\n * @param {Function} callback\n */\n authorize(socketId: string, callback: Function) {\n super.authorize(socketId, async (error, authData) => {\n if (!error) {\n authData = authData as ChannelAuthorizationData;\n if (authData.channel_data != null) {\n var channelData = JSON.parse(authData.channel_data);\n this.members.setMyID(channelData.user_id);\n } else {\n await this.pusher.user.signinDonePromise;\n if (this.pusher.user.user_data != null) {\n // If the user is signed in, get the id of the authenticated user\n // and allow the presence authorization to continue.\n this.members.setMyID(this.pusher.user.user_data.id);\n } else {\n let suffix = UrlStore.buildLogSuffix('authorizationEndpoint');\n Logger.error(\n `Invalid auth response for channel '${this.name}', ` +\n `expected 'channel_data' field. ${suffix}, ` +\n `or the user should be signed in.`\n );\n callback('Invalid auth response');\n return;\n }\n }\n }\n callback(error, authData);\n });\n }\n\n /** Handles presence and subscription events. For internal use only.\n *\n * @param {PusherEvent} event\n */\n handleEvent(event: PusherEvent) {\n var eventName = event.event;\n if (eventName.indexOf('pusher_internal:') === 0) {\n this.handleInternalEvent(event);\n } else {\n var data = event.data;\n var metadata: Metadata = {};\n if (event.user_id) {\n metadata.user_id = event.user_id;\n }\n this.emit(eventName, data, metadata);\n }\n }\n handleInternalEvent(event: PusherEvent) {\n var eventName = event.event;\n var data = event.data;\n switch (eventName) {\n case 'pusher_internal:subscription_succeeded':\n this.handleSubscriptionSucceededEvent(event);\n break;\n case 'pusher_internal:subscription_count':\n this.handleSubscriptionCountEvent(event);\n break;\n case 'pusher_internal:member_added':\n var addedMember = this.members.addMember(data);\n this.emit('pusher:member_added', addedMember);\n break;\n case 'pusher_internal:member_removed':\n var removedMember = this.members.removeMember(data);\n if (removedMember) {\n this.emit('pusher:member_removed', removedMember);\n }\n break;\n }\n }\n\n handleSubscriptionSucceededEvent(event: PusherEvent) {\n this.subscriptionPending = false;\n this.subscribed = true;\n if (this.subscriptionCancelled) {\n this.pusher.unsubscribe(this.name);\n } else {\n this.members.onSubscription(event.data);\n this.emit('pusher:subscription_succeeded', this.members);\n }\n }\n\n /** Resets the channel state, including members map. For internal use only. */\n disconnect() {\n this.members.reset();\n super.disconnect();\n }\n}\n","import PrivateChannel from './private_channel';\nimport * as Errors from '../errors';\nimport Logger from '../logger';\nimport Pusher from '../pusher';\nimport { decode as encodeUTF8 } from '@stablelib/utf8';\nimport { decode as decodeBase64 } from '@stablelib/base64';\nimport Dispatcher from '../events/dispatcher';\nimport { PusherEvent } from '../connection/protocol/message-types';\nimport {\n ChannelAuthorizationData,\n ChannelAuthorizationCallback\n} from '../auth/options';\nimport * as nacl from 'tweetnacl';\n\n/** Extends private channels to provide encrypted channel interface.\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\nexport default class EncryptedChannel extends PrivateChannel {\n key: Uint8Array = null;\n nacl: nacl;\n\n constructor(name: string, pusher: Pusher, nacl: nacl) {\n super(name, pusher);\n this.nacl = nacl;\n }\n\n /** Authorizes the connection to use the channel.\n *\n * @param {String} socketId\n * @param {Function} callback\n */\n authorize(socketId: string, callback: ChannelAuthorizationCallback) {\n super.authorize(\n socketId,\n (error: Error | null, authData: ChannelAuthorizationData) => {\n if (error) {\n callback(error, authData);\n return;\n }\n let sharedSecret = authData['shared_secret'];\n if (!sharedSecret) {\n callback(\n new Error(\n `No shared_secret key in auth payload for encrypted channel: ${this.name}`\n ),\n null\n );\n return;\n }\n this.key = decodeBase64(sharedSecret);\n delete authData['shared_secret'];\n callback(null, authData);\n }\n );\n }\n\n trigger(event: string, data: any): boolean {\n throw new Errors.UnsupportedFeature(\n 'Client events are not currently supported for encrypted channels'\n );\n }\n\n /** Handles an event. For internal use only.\n *\n * @param {PusherEvent} event\n */\n handleEvent(event: PusherEvent) {\n var eventName = event.event;\n var data = event.data;\n if (\n eventName.indexOf('pusher_internal:') === 0 ||\n eventName.indexOf('pusher:') === 0\n ) {\n super.handleEvent(event);\n return;\n }\n this.handleEncryptedEvent(eventName, data);\n }\n\n private handleEncryptedEvent(event: string, data: any): void {\n if (!this.key) {\n Logger.debug(\n 'Received encrypted event before key has been retrieved from the authEndpoint'\n );\n return;\n }\n if (!data.ciphertext || !data.nonce) {\n Logger.error(\n 'Unexpected format for encrypted event, expected object with `ciphertext` and `nonce` fields, got: ' +\n data\n );\n return;\n }\n let cipherText = decodeBase64(data.ciphertext);\n if (cipherText.length < this.nacl.secretbox.overheadLength) {\n Logger.error(\n `Expected encrypted event ciphertext length to be ${this.nacl.secretbox.overheadLength}, got: ${cipherText.length}`\n );\n return;\n }\n let nonce = decodeBase64(data.nonce);\n if (nonce.length < this.nacl.secretbox.nonceLength) {\n Logger.error(\n `Expected encrypted event nonce length to be ${this.nacl.secretbox.nonceLength}, got: ${nonce.length}`\n );\n return;\n }\n\n let bytes = this.nacl.secretbox.open(cipherText, nonce, this.key);\n if (bytes === null) {\n Logger.debug(\n 'Failed to decrypt an event, probably because it was encrypted with a different key. Fetching a new key from the authEndpoint...'\n );\n // Try a single time to retrieve a new auth key and decrypt the event with it\n // If this fails, a new key will be requested when a new message is received\n this.authorize(this.pusher.connection.socket_id, (error, authData) => {\n if (error) {\n Logger.error(\n `Failed to make a request to the authEndpoint: ${authData}. Unable to fetch new key, so dropping encrypted event`\n );\n return;\n }\n bytes = this.nacl.secretbox.open(cipherText, nonce, this.key);\n if (bytes === null) {\n Logger.error(\n `Failed to decrypt event with new key. Dropping encrypted event`\n );\n return;\n }\n this.emit(event, this.getDataToEmit(bytes));\n return;\n });\n return;\n }\n this.emit(event, this.getDataToEmit(bytes));\n }\n\n // Try and parse the decrypted bytes as JSON. If we can't parse it, just\n // return the utf-8 string\n getDataToEmit(bytes: Uint8Array): string {\n let raw = encodeUTF8(bytes);\n try {\n return JSON.parse(raw);\n } catch {\n return raw;\n }\n }\n}\n","import { default as EventsDispatcher } from '../events/dispatcher';\nimport { OneOffTimer as Timer } from '../utils/timers';\nimport { Config } from '../config';\nimport Logger from '../logger';\nimport HandshakePayload from './handshake/handshake_payload';\nimport Connection from './connection';\nimport Strategy from '../strategies/strategy';\nimport StrategyRunner from '../strategies/strategy_runner';\nimport * as Collections from '../utils/collections';\nimport Timeline from '../timeline/timeline';\nimport ConnectionManagerOptions from './connection_manager_options';\nimport Runtime from 'runtime';\n\nimport {\n ErrorCallbacks,\n HandshakeCallbacks,\n ConnectionCallbacks\n} from './callbacks';\nimport Action from './protocol/action';\n\n/** Manages connection to Pusher.\n *\n * Uses a strategy (currently only default), timers and network availability\n * info to establish a connection and export its state. In case of failures,\n * manages reconnection attempts.\n *\n * Exports state changes as following events:\n * - \"state_change\", { previous: p, current: state }\n * - state\n *\n * States:\n * - initialized - initial state, never transitioned to\n * - connecting - connection is being established\n * - connected - connection has been fully established\n * - disconnected - on requested disconnection\n * - unavailable - after connection timeout or when there's no network\n * - failed - when the connection strategy is not supported\n *\n * Options:\n * - unavailableTimeout - time to transition to unavailable state\n * - activityTimeout - time after which ping message should be sent\n * - pongTimeout - time for Pusher to respond with pong before reconnecting\n *\n * @param {String} key application key\n * @param {Object} options\n */\nexport default class ConnectionManager extends EventsDispatcher {\n key: string;\n options: ConnectionManagerOptions;\n state: string;\n connection: Connection;\n usingTLS: boolean;\n timeline: Timeline;\n socket_id: string;\n unavailableTimer: Timer;\n activityTimer: Timer;\n retryTimer: Timer;\n activityTimeout: number;\n strategy: Strategy;\n runner: StrategyRunner;\n errorCallbacks: ErrorCallbacks;\n handshakeCallbacks: HandshakeCallbacks;\n connectionCallbacks: ConnectionCallbacks;\n\n constructor(key: string, options: ConnectionManagerOptions) {\n super();\n this.state = 'initialized';\n this.connection = null;\n\n this.key = key;\n this.options = options;\n this.timeline = this.options.timeline;\n this.usingTLS = this.options.useTLS;\n\n this.errorCallbacks = this.buildErrorCallbacks();\n this.connectionCallbacks = this.buildConnectionCallbacks(\n this.errorCallbacks\n );\n this.handshakeCallbacks = this.buildHandshakeCallbacks(this.errorCallbacks);\n\n var Network = Runtime.getNetwork();\n\n Network.bind('online', () => {\n this.timeline.info({ netinfo: 'online' });\n if (this.state === 'connecting' || this.state === 'unavailable') {\n this.retryIn(0);\n }\n });\n Network.bind('offline', () => {\n this.timeline.info({ netinfo: 'offline' });\n if (this.connection) {\n this.sendActivityCheck();\n }\n });\n\n this.updateStrategy();\n }\n\n switchCluster(key: string) {\n this.key = key;\n // This ensures that the new config coming from\n // pusher instance are taken into account\n // such as appKey and cluster\n this.updateStrategy();\n this.retryIn(0);\n }\n\n /** Establishes a connection to Pusher.\n *\n * Does nothing when connection is already established. See top-level doc\n * to find events emitted on connection attempts.\n */\n connect() {\n if (this.connection || this.runner) {\n return;\n }\n if (!this.strategy.isSupported()) {\n this.updateState('failed');\n return;\n }\n this.updateState('connecting');\n this.startConnecting();\n this.setUnavailableTimer();\n }\n\n /** Sends raw data.\n *\n * @param {String} data\n */\n send(data) {\n if (this.connection) {\n return this.connection.send(data);\n } else {\n return false;\n }\n }\n\n /** Sends an event.\n *\n * @param {String} name\n * @param {String} data\n * @param {String} [channel]\n * @returns {Boolean} whether message was sent or not\n */\n send_event(name: string, data: any, channel?: string) {\n if (this.connection) {\n return this.connection.send_event(name, data, channel);\n } else {\n return false;\n }\n }\n\n /** Closes the connection. */\n disconnect() {\n this.disconnectInternally();\n this.updateState('disconnected');\n }\n\n isUsingTLS() {\n return this.usingTLS;\n }\n\n private startConnecting() {\n var callback = (error, handshake) => {\n if (error) {\n this.runner = this.strategy.connect(0, callback);\n } else {\n if (handshake.action === 'error') {\n this.emit('error', {\n type: 'HandshakeError',\n error: handshake.error\n });\n this.timeline.error({ handshakeError: handshake.error });\n } else {\n this.abortConnecting(); // we don't support switching connections yet\n this.handshakeCallbacks[handshake.action](handshake);\n }\n }\n };\n this.runner = this.strategy.connect(0, callback);\n }\n\n private abortConnecting() {\n if (this.runner) {\n this.runner.abort();\n this.runner = null;\n }\n }\n\n private disconnectInternally() {\n this.abortConnecting();\n this.clearRetryTimer();\n this.clearUnavailableTimer();\n if (this.connection) {\n var connection = this.abandonConnection();\n connection.close();\n }\n }\n\n private updateStrategy() {\n this.strategy = this.options.getStrategy({\n key: this.key,\n timeline: this.timeline,\n useTLS: this.usingTLS\n });\n }\n\n private retryIn(delay) {\n this.timeline.info({ action: 'retry', delay: delay });\n if (delay > 0) {\n this.emit('connecting_in', Math.round(delay / 1000));\n }\n this.retryTimer = new Timer(delay || 0, () => {\n this.disconnectInternally();\n this.connect();\n });\n }\n\n private clearRetryTimer() {\n if (this.retryTimer) {\n this.retryTimer.ensureAborted();\n this.retryTimer = null;\n }\n }\n\n private setUnavailableTimer() {\n this.unavailableTimer = new Timer(this.options.unavailableTimeout, () => {\n this.updateState('unavailable');\n });\n }\n\n private clearUnavailableTimer() {\n if (this.unavailableTimer) {\n this.unavailableTimer.ensureAborted();\n }\n }\n\n private sendActivityCheck() {\n this.stopActivityCheck();\n this.connection.ping();\n // wait for pong response\n this.activityTimer = new Timer(this.options.pongTimeout, () => {\n this.timeline.error({ pong_timed_out: this.options.pongTimeout });\n this.retryIn(0);\n });\n }\n\n private resetActivityCheck() {\n this.stopActivityCheck();\n // send ping after inactivity\n if (this.connection && !this.connection.handlesActivityChecks()) {\n this.activityTimer = new Timer(this.activityTimeout, () => {\n this.sendActivityCheck();\n });\n }\n }\n\n private stopActivityCheck() {\n if (this.activityTimer) {\n this.activityTimer.ensureAborted();\n }\n }\n\n private buildConnectionCallbacks(\n errorCallbacks: ErrorCallbacks\n ): ConnectionCallbacks {\n return Collections.extend({}, errorCallbacks, {\n message: message => {\n // includes pong messages from server\n this.resetActivityCheck();\n this.emit('message', message);\n },\n ping: () => {\n this.send_event('pusher:pong', {});\n },\n activity: () => {\n this.resetActivityCheck();\n },\n error: error => {\n // just emit error to user - socket will already be closed by browser\n this.emit('error', error);\n },\n closed: () => {\n this.abandonConnection();\n if (this.shouldRetry()) {\n this.retryIn(1000);\n }\n }\n });\n }\n\n private buildHandshakeCallbacks(\n errorCallbacks: ErrorCallbacks\n ): HandshakeCallbacks {\n return Collections.extend({}, errorCallbacks, {\n connected: (handshake: HandshakePayload) => {\n this.activityTimeout = Math.min(\n this.options.activityTimeout,\n handshake.activityTimeout,\n handshake.connection.activityTimeout || Infinity\n );\n this.clearUnavailableTimer();\n this.setConnection(handshake.connection);\n this.socket_id = this.connection.id;\n this.updateState('connected', { socket_id: this.socket_id });\n }\n });\n }\n\n private buildErrorCallbacks(): ErrorCallbacks {\n let withErrorEmitted = callback => {\n return (result: Action | HandshakePayload) => {\n if (result.error) {\n this.emit('error', { type: 'WebSocketError', error: result.error });\n }\n callback(result);\n };\n };\n\n return {\n tls_only: withErrorEmitted(() => {\n this.usingTLS = true;\n this.updateStrategy();\n this.retryIn(0);\n }),\n refused: withErrorEmitted(() => {\n this.disconnect();\n }),\n backoff: withErrorEmitted(() => {\n this.retryIn(1000);\n }),\n retry: withErrorEmitted(() => {\n this.retryIn(0);\n })\n };\n }\n\n private setConnection(connection) {\n this.connection = connection;\n for (var event in this.connectionCallbacks) {\n this.connection.bind(event, this.connectionCallbacks[event]);\n }\n this.resetActivityCheck();\n }\n\n private abandonConnection() {\n if (!this.connection) {\n return;\n }\n this.stopActivityCheck();\n for (var event in this.connectionCallbacks) {\n this.connection.unbind(event, this.connectionCallbacks[event]);\n }\n var connection = this.connection;\n this.connection = null;\n return connection;\n }\n\n private updateState(newState: string, data?: any) {\n var previousState = this.state;\n this.state = newState;\n if (previousState !== newState) {\n var newStateDescription = newState;\n if (newStateDescription === 'connected') {\n newStateDescription += ' with new socket ID ' + data.socket_id;\n }\n Logger.debug(\n 'State changed',\n previousState + ' -> ' + newStateDescription\n );\n this.timeline.info({ state: newState, params: data });\n this.emit('state_change', { previous: previousState, current: newState });\n this.emit(newState, data);\n }\n }\n\n private shouldRetry(): boolean {\n return this.state === 'connecting' || this.state === 'connected';\n }\n}\n","import Channel from './channel';\nimport * as Collections from '../utils/collections';\nimport ChannelTable from './channel_table';\nimport Factory from '../utils/factory';\nimport Pusher from '../pusher';\nimport Logger from '../logger';\nimport * as Errors from '../errors';\nimport urlStore from '../utils/url_store';\n\n/** Handles a channel map. */\nexport default class Channels {\n channels: ChannelTable;\n\n constructor() {\n this.channels = {};\n }\n\n /** Creates or retrieves an existing channel by its name.\n *\n * @param {String} name\n * @param {Pusher} pusher\n * @return {Channel}\n */\n add(name: string, pusher: Pusher) {\n if (!this.channels[name]) {\n this.channels[name] = createChannel(name, pusher);\n }\n return this.channels[name];\n }\n\n /** Returns a list of all channels\n *\n * @return {Array}\n */\n all(): Channel[] {\n return Collections.values(this.channels);\n }\n\n /** Finds a channel by its name.\n *\n * @param {String} name\n * @return {Channel} channel or null if it doesn't exist\n */\n find(name: string) {\n return this.channels[name];\n }\n\n /** Removes a channel from the map.\n *\n * @param {String} name\n */\n remove(name: string) {\n var channel = this.channels[name];\n delete this.channels[name];\n return channel;\n }\n\n /** Proxies disconnection signal to all channels. */\n disconnect() {\n Collections.objectApply(this.channels, function(channel) {\n channel.disconnect();\n });\n }\n}\n\nfunction createChannel(name: string, pusher: Pusher): Channel {\n if (name.indexOf('private-encrypted-') === 0) {\n if (pusher.config.nacl) {\n return Factory.createEncryptedChannel(name, pusher, pusher.config.nacl);\n }\n let errMsg =\n 'Tried to subscribe to a private-encrypted- channel but no nacl implementation available';\n let suffix = urlStore.buildLogSuffix('encryptedChannelSupport');\n throw new Errors.UnsupportedFeature(`${errMsg}. ${suffix}`);\n } else if (name.indexOf('private-') === 0) {\n return Factory.createPrivateChannel(name, pusher);\n } else if (name.indexOf('presence-') === 0) {\n return Factory.createPresenceChannel(name, pusher);\n } else if (name.indexOf('#') === 0) {\n throw new Errors.BadChannelName(\n 'Cannot create a channel with name \"' + name + '\".'\n );\n } else {\n return Factory.createChannel(name, pusher);\n }\n}\n","import AssistantToTheTransportManager from '../transports/assistant_to_the_transport_manager';\nimport PingDelayOptions from '../transports/ping_delay_options';\nimport Transport from '../transports/transport';\nimport TransportManager from '../transports/transport_manager';\nimport Handshake from '../connection/handshake';\nimport TransportConnection from '../transports/transport_connection';\nimport SocketHooks from '../http/socket_hooks';\nimport HTTPSocket from '../http/http_socket';\n\nimport Timeline from '../timeline/timeline';\nimport {\n default as TimelineSender,\n TimelineSenderOptions\n} from '../timeline/timeline_sender';\nimport PresenceChannel from '../channels/presence_channel';\nimport PrivateChannel from '../channels/private_channel';\nimport EncryptedChannel from '../channels/encrypted_channel';\nimport Channel from '../channels/channel';\nimport ConnectionManager from '../connection/connection_manager';\nimport ConnectionManagerOptions from '../connection/connection_manager_options';\nimport Ajax from '../http/ajax';\nimport Channels from '../channels/channels';\nimport Pusher from '../pusher';\nimport { Config } from '../config';\nimport * as nacl from 'tweetnacl';\n\nvar Factory = {\n createChannels(): Channels {\n return new Channels();\n },\n\n createConnectionManager(\n key: string,\n options: ConnectionManagerOptions\n ): ConnectionManager {\n return new ConnectionManager(key, options);\n },\n\n createChannel(name: string, pusher: Pusher): Channel {\n return new Channel(name, pusher);\n },\n\n createPrivateChannel(name: string, pusher: Pusher): PrivateChannel {\n return new PrivateChannel(name, pusher);\n },\n\n createPresenceChannel(name: string, pusher: Pusher): PresenceChannel {\n return new PresenceChannel(name, pusher);\n },\n\n createEncryptedChannel(\n name: string,\n pusher: Pusher,\n nacl: nacl\n ): EncryptedChannel {\n return new EncryptedChannel(name, pusher, nacl);\n },\n\n createTimelineSender(timeline: Timeline, options: TimelineSenderOptions) {\n return new TimelineSender(timeline, options);\n },\n\n createHandshake(\n transport: TransportConnection,\n callback: (HandshakePayload) => void\n ): Handshake {\n return new Handshake(transport, callback);\n },\n\n createAssistantToTheTransportManager(\n manager: TransportManager,\n transport: Transport,\n options: PingDelayOptions\n ): AssistantToTheTransportManager {\n return new AssistantToTheTransportManager(manager, transport, options);\n }\n};\n\nexport default Factory;\n","import AssistantToTheTransportManager from './assistant_to_the_transport_manager';\nimport Transport from './transport';\nimport PingDelayOptions from './ping_delay_options';\nimport Factory from '../utils/factory';\n\nexport interface TransportManagerOptions extends PingDelayOptions {\n lives?: number;\n}\n\n/** Keeps track of the number of lives left for a transport.\n *\n * In the beginning of a session, transports may be assigned a number of\n * lives. When an AssistantToTheTransportManager instance reports a transport\n * connection closed uncleanly, the transport loses a life. When the number\n * of lives drops to zero, the transport gets disabled by its manager.\n *\n * @param {Object} options\n */\nexport default class TransportManager {\n options: TransportManagerOptions;\n livesLeft: number;\n\n constructor(options: TransportManagerOptions) {\n this.options = options || {};\n this.livesLeft = this.options.lives || Infinity;\n }\n\n /** Creates a assistant for the transport.\n *\n * @param {Transport} transport\n * @returns {AssistantToTheTransportManager}\n */\n getAssistant(transport: Transport): AssistantToTheTransportManager {\n return Factory.createAssistantToTheTransportManager(this, transport, {\n minPingDelay: this.options.minPingDelay,\n maxPingDelay: this.options.maxPingDelay\n });\n }\n\n /** Returns whether the transport has any lives left.\n *\n * @returns {Boolean}\n */\n isAlive(): boolean {\n return this.livesLeft > 0;\n }\n\n /** Takes one life from the transport. */\n reportDeath() {\n this.livesLeft -= 1;\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport { OneOffTimer as Timer } from '../utils/timers';\nimport Strategy from './strategy';\nimport StrategyOptions from './strategy_options';\n\n/** Loops through strategies with optional timeouts.\n *\n * Options:\n * - loop - whether it should loop through the substrategy list\n * - timeout - initial timeout for a single substrategy\n * - timeoutLimit - maximum timeout\n *\n * @param {Strategy[]} strategies\n * @param {Object} options\n */\nexport default class SequentialStrategy implements Strategy {\n strategies: Strategy[];\n loop: boolean;\n failFast: boolean;\n timeout: number;\n timeoutLimit: number;\n\n constructor(strategies: Strategy[], options: StrategyOptions) {\n this.strategies = strategies;\n this.loop = Boolean(options.loop);\n this.failFast = Boolean(options.failFast);\n this.timeout = options.timeout;\n this.timeoutLimit = options.timeoutLimit;\n }\n\n isSupported(): boolean {\n return Collections.any(this.strategies, Util.method('isSupported'));\n }\n\n connect(minPriority: number, callback: Function) {\n var strategies = this.strategies;\n var current = 0;\n var timeout = this.timeout;\n var runner = null;\n\n var tryNextStrategy = (error, handshake) => {\n if (handshake) {\n callback(null, handshake);\n } else {\n current = current + 1;\n if (this.loop) {\n current = current % strategies.length;\n }\n\n if (current < strategies.length) {\n if (timeout) {\n timeout = timeout * 2;\n if (this.timeoutLimit) {\n timeout = Math.min(timeout, this.timeoutLimit);\n }\n }\n runner = this.tryStrategy(\n strategies[current],\n minPriority,\n { timeout, failFast: this.failFast },\n tryNextStrategy\n );\n } else {\n callback(true);\n }\n }\n };\n\n runner = this.tryStrategy(\n strategies[current],\n minPriority,\n { timeout: timeout, failFast: this.failFast },\n tryNextStrategy\n );\n\n return {\n abort: function() {\n runner.abort();\n },\n forceMinPriority: function(p) {\n minPriority = p;\n if (runner) {\n runner.forceMinPriority(p);\n }\n }\n };\n }\n\n private tryStrategy(\n strategy: Strategy,\n minPriority: number,\n options: StrategyOptions,\n callback: Function\n ) {\n var timer = null;\n var runner = null;\n\n if (options.timeout > 0) {\n timer = new Timer(options.timeout, function() {\n runner.abort();\n callback(true);\n });\n }\n\n runner = strategy.connect(minPriority, function(error, handshake) {\n if (error && timer && timer.isRunning() && !options.failFast) {\n // advance to the next strategy after the timeout\n return;\n }\n if (timer) {\n timer.ensureAborted();\n }\n callback(error, handshake);\n });\n\n return {\n abort: function() {\n if (timer) {\n timer.ensureAborted();\n }\n runner.abort();\n },\n forceMinPriority: function(p) {\n runner.forceMinPriority(p);\n }\n };\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport Strategy from './strategy';\n\n/** Launches all substrategies and emits prioritized connected transports.\n *\n * @param {Array} strategies\n */\nexport default class BestConnectedEverStrategy implements Strategy {\n strategies: Strategy[];\n\n constructor(strategies: Strategy[]) {\n this.strategies = strategies;\n }\n\n isSupported(): boolean {\n return Collections.any(this.strategies, Util.method('isSupported'));\n }\n\n connect(minPriority: number, callback: Function) {\n return connect(this.strategies, minPriority, function(i, runners) {\n return function(error, handshake) {\n runners[i].error = error;\n if (error) {\n if (allRunnersFailed(runners)) {\n callback(true);\n }\n return;\n }\n Collections.apply(runners, function(runner) {\n runner.forceMinPriority(handshake.transport.priority);\n });\n callback(null, handshake);\n };\n });\n }\n}\n\n/** Connects to all strategies in parallel.\n *\n * Callback builder should be a function that takes two arguments: index\n * and a list of runners. It should return another function that will be\n * passed to the substrategy with given index. Runners can be aborted using\n * abortRunner(s) functions from this class.\n *\n * @param {Array} strategies\n * @param {Function} callbackBuilder\n * @return {Object} strategy runner\n */\nfunction connect(\n strategies: Strategy[],\n minPriority: number,\n callbackBuilder: Function\n) {\n var runners = Collections.map(strategies, function(strategy, i, _, rs) {\n return strategy.connect(minPriority, callbackBuilder(i, rs));\n });\n return {\n abort: function() {\n Collections.apply(runners, abortRunner);\n },\n forceMinPriority: function(p) {\n Collections.apply(runners, function(runner) {\n runner.forceMinPriority(p);\n });\n }\n };\n}\n\nfunction allRunnersFailed(runners): boolean {\n return Collections.all(runners, function(runner) {\n return Boolean(runner.error);\n });\n}\n\nfunction abortRunner(runner) {\n if (!runner.error && !runner.aborted) {\n runner.abort();\n runner.aborted = true;\n }\n}\n","import Util from '../util';\nimport Runtime from 'runtime';\nimport Strategy from './strategy';\nimport SequentialStrategy from './sequential_strategy';\nimport StrategyOptions from './strategy_options';\nimport TransportStrategy from './transport_strategy';\nimport Timeline from '../timeline/timeline';\nimport * as Collections from '../utils/collections';\n\nexport interface TransportStrategyDictionary {\n [key: string]: TransportStrategy;\n}\n\n/** Caches the last successful transport and, after the first few attempts,\n * uses the cached transport for subsequent attempts.\n *\n * @param {Strategy} strategy\n * @param {Object} transports\n * @param {Object} options\n */\nexport default class WebSocketPrioritizedCachedStrategy implements Strategy {\n strategy: Strategy;\n transports: TransportStrategyDictionary;\n ttl: number;\n usingTLS: boolean;\n timeline: Timeline;\n\n constructor(\n strategy: Strategy,\n transports: TransportStrategyDictionary,\n options: StrategyOptions\n ) {\n this.strategy = strategy;\n this.transports = transports;\n this.ttl = options.ttl || 1800 * 1000;\n this.usingTLS = options.useTLS;\n this.timeline = options.timeline;\n }\n\n isSupported(): boolean {\n return this.strategy.isSupported();\n }\n\n connect(minPriority: number, callback: Function) {\n var usingTLS = this.usingTLS;\n var info = fetchTransportCache(usingTLS);\n var cacheSkipCount = info && info.cacheSkipCount ? info.cacheSkipCount : 0;\n\n var strategies = [this.strategy];\n if (info && info.timestamp + this.ttl >= Util.now()) {\n var transport = this.transports[info.transport];\n if (transport) {\n if (['ws', 'wss'].includes(info.transport) || cacheSkipCount > 3) {\n this.timeline.info({\n cached: true,\n transport: info.transport,\n latency: info.latency\n });\n strategies.push(\n new SequentialStrategy([transport], {\n timeout: info.latency * 2 + 1000,\n failFast: true\n })\n );\n } else {\n cacheSkipCount++;\n }\n }\n }\n\n var startTimestamp = Util.now();\n var runner = strategies\n .pop()\n .connect(minPriority, function cb(error, handshake) {\n if (error) {\n flushTransportCache(usingTLS);\n if (strategies.length > 0) {\n startTimestamp = Util.now();\n runner = strategies.pop().connect(minPriority, cb);\n } else {\n callback(error);\n }\n } else {\n storeTransportCache(\n usingTLS,\n handshake.transport.name,\n Util.now() - startTimestamp,\n cacheSkipCount\n );\n callback(null, handshake);\n }\n });\n\n return {\n abort: function() {\n runner.abort();\n },\n forceMinPriority: function(p) {\n minPriority = p;\n if (runner) {\n runner.forceMinPriority(p);\n }\n }\n };\n }\n}\n\nfunction getTransportCacheKey(usingTLS: boolean): string {\n return 'pusherTransport' + (usingTLS ? 'TLS' : 'NonTLS');\n}\n\nfunction fetchTransportCache(usingTLS: boolean): any {\n var storage = Runtime.getLocalStorage();\n if (storage) {\n try {\n var serializedCache = storage[getTransportCacheKey(usingTLS)];\n if (serializedCache) {\n return JSON.parse(serializedCache);\n }\n } catch (e) {\n flushTransportCache(usingTLS);\n }\n }\n return null;\n}\n\nfunction storeTransportCache(\n usingTLS: boolean,\n transport: TransportStrategy,\n latency: number,\n cacheSkipCount: number\n) {\n var storage = Runtime.getLocalStorage();\n if (storage) {\n try {\n storage[getTransportCacheKey(usingTLS)] = Collections.safeJSONStringify({\n timestamp: Util.now(),\n transport: transport,\n latency: latency,\n cacheSkipCount: cacheSkipCount\n });\n } catch (e) {\n // catch over quota exceptions raised by localStorage\n }\n }\n}\n\nfunction flushTransportCache(usingTLS: boolean) {\n var storage = Runtime.getLocalStorage();\n if (storage) {\n try {\n delete storage[getTransportCacheKey(usingTLS)];\n } catch (e) {\n // catch exceptions raised by localStorage\n }\n }\n}\n","import { OneOffTimer as Timer } from '../utils/timers';\nimport Strategy from './strategy';\nimport StrategyOptions from './strategy_options';\n\n/** Runs substrategy after specified delay.\n *\n * Options:\n * - delay - time in miliseconds to delay the substrategy attempt\n *\n * @param {Strategy} strategy\n * @param {Object} options\n */\nexport default class DelayedStrategy implements Strategy {\n strategy: Strategy;\n options: { delay: number };\n\n constructor(strategy: Strategy, { delay: number }) {\n this.strategy = strategy;\n this.options = { delay: number };\n }\n\n isSupported(): boolean {\n return this.strategy.isSupported();\n }\n\n connect(minPriority: number, callback: Function) {\n var strategy = this.strategy;\n var runner;\n var timer = new Timer(this.options.delay, function() {\n runner = strategy.connect(minPriority, callback);\n });\n\n return {\n abort: function() {\n timer.ensureAborted();\n if (runner) {\n runner.abort();\n }\n },\n forceMinPriority: function(p) {\n minPriority = p;\n if (runner) {\n runner.forceMinPriority(p);\n }\n }\n };\n }\n}\n","import Strategy from './strategy';\nimport StrategyRunner from './strategy_runner';\n\n/** Proxies method calls to one of substrategies basing on the test function.\n *\n * @param {Function} test\n * @param {Strategy} trueBranch strategy used when test returns true\n * @param {Strategy} falseBranch strategy used when test returns false\n */\nexport default class IfStrategy implements Strategy {\n test: () => boolean;\n trueBranch: Strategy;\n falseBranch: Strategy;\n\n constructor(\n test: () => boolean,\n trueBranch: Strategy,\n falseBranch: Strategy\n ) {\n this.test = test;\n this.trueBranch = trueBranch;\n this.falseBranch = falseBranch;\n }\n\n isSupported(): boolean {\n var branch = this.test() ? this.trueBranch : this.falseBranch;\n return branch.isSupported();\n }\n\n connect(minPriority: number, callback: Function): StrategyRunner {\n var branch = this.test() ? this.trueBranch : this.falseBranch;\n return branch.connect(minPriority, callback);\n }\n}\n","import Strategy from './strategy';\nimport StrategyRunner from './strategy_runner';\n\n/** Launches the substrategy and terminates on the first open connection.\n *\n * @param {Strategy} strategy\n */\nexport default class FirstConnectedStrategy implements Strategy {\n strategy: Strategy;\n\n constructor(strategy: Strategy) {\n this.strategy = strategy;\n }\n\n isSupported(): boolean {\n return this.strategy.isSupported();\n }\n\n connect(minPriority: number, callback: Function): StrategyRunner {\n var runner = this.strategy.connect(minPriority, function(error, handshake) {\n if (handshake) {\n runner.abort();\n }\n callback(error, handshake);\n });\n return runner;\n }\n}\n","import * as Collections from 'core/utils/collections';\nimport TransportManager from 'core/transports/transport_manager';\nimport Strategy from 'core/strategies/strategy';\nimport SequentialStrategy from 'core/strategies/sequential_strategy';\nimport BestConnectedEverStrategy from 'core/strategies/best_connected_ever_strategy';\nimport WebSocketPrioritizedCachedStrategy, {\n TransportStrategyDictionary\n} from 'core/strategies/websocket_prioritized_cached_strategy';\nimport DelayedStrategy from 'core/strategies/delayed_strategy';\nimport IfStrategy from 'core/strategies/if_strategy';\nimport FirstConnectedStrategy from 'core/strategies/first_connected_strategy';\nimport { Config } from 'core/config';\nimport StrategyOptions from 'core/strategies/strategy_options';\n\nfunction testSupportsStrategy(strategy: Strategy) {\n return function() {\n return strategy.isSupported();\n };\n}\n\nvar getDefaultStrategy = function(\n config: Config,\n baseOptions: StrategyOptions,\n defineTransport: Function\n): Strategy {\n var definedTransports = {};\n\n function defineTransportStrategy(\n name: string,\n type: string,\n priority: number,\n options: StrategyOptions,\n manager?: TransportManager\n ) {\n var transport = defineTransport(\n config,\n name,\n type,\n priority,\n options,\n manager\n );\n\n definedTransports[name] = transport;\n\n return transport;\n }\n\n var ws_options: StrategyOptions = Object.assign({}, baseOptions, {\n hostNonTLS: config.wsHost + ':' + config.wsPort,\n hostTLS: config.wsHost + ':' + config.wssPort,\n httpPath: config.wsPath\n });\n var wss_options: StrategyOptions = Collections.extend({}, ws_options, {\n useTLS: true\n });\n var http_options: StrategyOptions = Object.assign({}, baseOptions, {\n hostNonTLS: config.httpHost + ':' + config.httpPort,\n hostTLS: config.httpHost + ':' + config.httpsPort,\n httpPath: config.httpPath\n });\n var timeouts = {\n loop: true,\n timeout: 15000,\n timeoutLimit: 60000\n };\n\n var ws_manager = new TransportManager({\n minPingDelay: 10000,\n maxPingDelay: config.activityTimeout\n });\n var streaming_manager = new TransportManager({\n lives: 2,\n minPingDelay: 10000,\n maxPingDelay: config.activityTimeout\n });\n\n var ws_transport = defineTransportStrategy(\n 'ws',\n 'ws',\n 3,\n ws_options,\n ws_manager\n );\n var wss_transport = defineTransportStrategy(\n 'wss',\n 'ws',\n 3,\n wss_options,\n ws_manager\n );\n var xhr_streaming_transport = defineTransportStrategy(\n 'xhr_streaming',\n 'xhr_streaming',\n 1,\n http_options,\n streaming_manager\n );\n var xhr_polling_transport = defineTransportStrategy(\n 'xhr_polling',\n 'xhr_polling',\n 1,\n http_options\n );\n\n var ws_loop = new SequentialStrategy([ws_transport], timeouts);\n var wss_loop = new SequentialStrategy([wss_transport], timeouts);\n var streaming_loop = new SequentialStrategy(\n [xhr_streaming_transport],\n timeouts\n );\n var polling_loop = new SequentialStrategy([xhr_polling_transport], timeouts);\n\n var http_loop = new SequentialStrategy(\n [\n new IfStrategy(\n testSupportsStrategy(streaming_loop),\n new BestConnectedEverStrategy([\n streaming_loop,\n new DelayedStrategy(polling_loop, { delay: 4000 })\n ]),\n polling_loop\n )\n ],\n timeouts\n );\n\n var wsStrategy;\n if (baseOptions.useTLS) {\n wsStrategy = new BestConnectedEverStrategy([\n ws_loop,\n new DelayedStrategy(http_loop, { delay: 2000 })\n ]);\n } else {\n wsStrategy = new BestConnectedEverStrategy([\n ws_loop,\n new DelayedStrategy(wss_loop, { delay: 2000 }),\n new DelayedStrategy(http_loop, { delay: 5000 })\n ]);\n }\n\n return new WebSocketPrioritizedCachedStrategy(\n new FirstConnectedStrategy(\n new IfStrategy(testSupportsStrategy(ws_transport), wsStrategy, http_loop)\n ),\n definedTransports,\n {\n ttl: 1800000,\n timeline: baseOptions.timeline,\n useTLS: baseOptions.useTLS\n }\n );\n};\n\nexport default getDefaultStrategy;\n","import Runtime from 'runtime';\nimport RequestHooks from './request_hooks';\nimport Ajax from './ajax';\nimport { default as EventsDispatcher } from '../events/dispatcher';\n\nconst MAX_BUFFER_LENGTH = 256 * 1024;\n\nexport default class HTTPRequest extends EventsDispatcher {\n hooks: RequestHooks;\n method: string;\n url: string;\n position: number;\n xhr: Ajax;\n unloader: Function;\n\n constructor(hooks: RequestHooks, method: string, url: string) {\n super();\n this.hooks = hooks;\n this.method = method;\n this.url = url;\n }\n\n start(payload?: any) {\n this.position = 0;\n this.xhr = this.hooks.getRequest(this);\n\n this.unloader = () => {\n this.close();\n };\n Runtime.addUnloadListener(this.unloader);\n\n this.xhr.open(this.method, this.url, true);\n\n if (this.xhr.setRequestHeader) {\n this.xhr.setRequestHeader('Content-Type', 'application/json'); // ReactNative doesn't set this header by default.\n }\n this.xhr.send(payload);\n }\n\n close() {\n if (this.unloader) {\n Runtime.removeUnloadListener(this.unloader);\n this.unloader = null;\n }\n if (this.xhr) {\n this.hooks.abortRequest(this.xhr);\n this.xhr = null;\n }\n }\n\n onChunk(status: number, data: any) {\n while (true) {\n var chunk = this.advanceBuffer(data);\n if (chunk) {\n this.emit('chunk', { status: status, data: chunk });\n } else {\n break;\n }\n }\n if (this.isBufferTooLong(data)) {\n this.emit('buffer_too_long');\n }\n }\n\n private advanceBuffer(buffer: any[]): any {\n var unreadData = buffer.slice(this.position);\n var endOfLinePosition = unreadData.indexOf('\\n');\n\n if (endOfLinePosition !== -1) {\n this.position += endOfLinePosition + 1;\n return unreadData.slice(0, endOfLinePosition);\n } else {\n // chunk is not finished yet, don't move the buffer pointer\n return null;\n }\n }\n\n private isBufferTooLong(buffer: any): boolean {\n return this.position === buffer.length && buffer.length > MAX_BUFFER_LENGTH;\n }\n}\n","enum State {\n CONNECTING = 0,\n OPEN = 1,\n CLOSED = 3\n}\n\nexport default State;\n","import URLLocation from './url_location';\nimport State from './state';\nimport Socket from '../socket';\nimport SocketHooks from './socket_hooks';\nimport Util from '../util';\nimport Ajax from './ajax';\nimport HTTPRequest from './http_request';\nimport Runtime from 'runtime';\n\nvar autoIncrement = 1;\n\nclass HTTPSocket implements Socket {\n hooks: SocketHooks;\n session: string;\n location: URLLocation;\n readyState: State;\n stream: HTTPRequest;\n\n onopen: () => void;\n onerror: (error: any) => void;\n onclose: (closeEvent: any) => void;\n onmessage: (message: any) => void;\n onactivity: () => void;\n\n constructor(hooks: SocketHooks, url: string) {\n this.hooks = hooks;\n this.session = randomNumber(1000) + '/' + randomString(8);\n this.location = getLocation(url);\n this.readyState = State.CONNECTING;\n this.openStream();\n }\n\n send(payload: any) {\n return this.sendRaw(JSON.stringify([payload]));\n }\n\n ping() {\n this.hooks.sendHeartbeat(this);\n }\n\n close(code: any, reason: any) {\n this.onClose(code, reason, true);\n }\n\n /** For internal use only */\n sendRaw(payload: any): boolean {\n if (this.readyState === State.OPEN) {\n try {\n Runtime.createSocketRequest(\n 'POST',\n getUniqueURL(getSendURL(this.location, this.session))\n ).start(payload);\n return true;\n } catch (e) {\n return false;\n }\n } else {\n return false;\n }\n }\n\n /** For internal use only */\n reconnect() {\n this.closeStream();\n this.openStream();\n }\n\n /** For internal use only */\n onClose(code, reason, wasClean) {\n this.closeStream();\n this.readyState = State.CLOSED;\n if (this.onclose) {\n this.onclose({\n code: code,\n reason: reason,\n wasClean: wasClean\n });\n }\n }\n\n private onChunk(chunk) {\n if (chunk.status !== 200) {\n return;\n }\n if (this.readyState === State.OPEN) {\n this.onActivity();\n }\n\n var payload;\n var type = chunk.data.slice(0, 1);\n switch (type) {\n case 'o':\n payload = JSON.parse(chunk.data.slice(1) || '{}');\n this.onOpen(payload);\n break;\n case 'a':\n payload = JSON.parse(chunk.data.slice(1) || '[]');\n for (var i = 0; i < payload.length; i++) {\n this.onEvent(payload[i]);\n }\n break;\n case 'm':\n payload = JSON.parse(chunk.data.slice(1) || 'null');\n this.onEvent(payload);\n break;\n case 'h':\n this.hooks.onHeartbeat(this);\n break;\n case 'c':\n payload = JSON.parse(chunk.data.slice(1) || '[]');\n this.onClose(payload[0], payload[1], true);\n break;\n }\n }\n\n private onOpen(options) {\n if (this.readyState === State.CONNECTING) {\n if (options && options.hostname) {\n this.location.base = replaceHost(this.location.base, options.hostname);\n }\n this.readyState = State.OPEN;\n\n if (this.onopen) {\n this.onopen();\n }\n } else {\n this.onClose(1006, 'Server lost session', true);\n }\n }\n\n private onEvent(event) {\n if (this.readyState === State.OPEN && this.onmessage) {\n this.onmessage({ data: event });\n }\n }\n\n private onActivity() {\n if (this.onactivity) {\n this.onactivity();\n }\n }\n\n private onError(error) {\n if (this.onerror) {\n this.onerror(error);\n }\n }\n\n private openStream() {\n this.stream = Runtime.createSocketRequest(\n 'POST',\n getUniqueURL(this.hooks.getReceiveURL(this.location, this.session))\n );\n\n this.stream.bind('chunk', chunk => {\n this.onChunk(chunk);\n });\n this.stream.bind('finished', status => {\n this.hooks.onFinished(this, status);\n });\n this.stream.bind('buffer_too_long', () => {\n this.reconnect();\n });\n\n try {\n this.stream.start();\n } catch (error) {\n Util.defer(() => {\n this.onError(error);\n this.onClose(1006, 'Could not start streaming', false);\n });\n }\n }\n\n private closeStream() {\n if (this.stream) {\n this.stream.unbind_all();\n this.stream.close();\n this.stream = null;\n }\n }\n}\n\nfunction getLocation(url): URLLocation {\n var parts = /([^\\?]*)\\/*(\\??.*)/.exec(url);\n return {\n base: parts[1],\n queryString: parts[2]\n };\n}\n\nfunction getSendURL(url: URLLocation, session: string): string {\n return url.base + '/' + session + '/xhr_send';\n}\n\nfunction getUniqueURL(url: string): string {\n var separator = url.indexOf('?') === -1 ? '?' : '&';\n return url + separator + 't=' + +new Date() + '&n=' + autoIncrement++;\n}\n\nfunction replaceHost(url: string, hostname: string): string {\n var urlParts = /(https?:\\/\\/)([^\\/:]+)((\\/|:)?.*)/.exec(url);\n return urlParts[1] + hostname + urlParts[3];\n}\n\nfunction randomNumber(max: number): number {\n return Runtime.randomInt(max);\n}\n\nfunction randomString(length: number): string {\n var result = [];\n\n for (var i = 0; i < length; i++) {\n result.push(randomNumber(32).toString(32));\n }\n\n return result.join('');\n}\n\nexport default HTTPSocket;\n","import SocketHooks from './socket_hooks';\nimport HTTPSocket from './http_socket';\n\nvar hooks: SocketHooks = {\n getReceiveURL: function(url, session) {\n return url.base + '/' + session + '/xhr_streaming' + url.queryString;\n },\n onHeartbeat: function(socket) {\n socket.sendRaw('[]');\n },\n sendHeartbeat: function(socket) {\n socket.sendRaw('[]');\n },\n onFinished: function(socket, status) {\n socket.onClose(1006, 'Connection interrupted (' + status + ')', false);\n }\n};\n\nexport default hooks;\n","import SocketHooks from './socket_hooks';\nimport URLLocation from './url_location';\nimport HTTPSocket from './http_socket';\n\nvar hooks: SocketHooks = {\n getReceiveURL: function(url: URLLocation, session: string): string {\n return url.base + '/' + session + '/xhr' + url.queryString;\n },\n onHeartbeat: function() {\n // next HTTP request will reset server's activity timer\n },\n sendHeartbeat: function(socket) {\n socket.sendRaw('[]');\n },\n onFinished: function(socket, status) {\n if (status === 200) {\n socket.reconnect();\n } else {\n socket.onClose(1006, 'Connection interrupted (' + status + ')', false);\n }\n }\n};\n\nexport default hooks;\n","import HTTPRequest from 'core/http/http_request';\nimport RequestHooks from 'core/http/request_hooks';\nimport Ajax from 'core/http/ajax';\nimport Runtime from 'runtime';\n\nvar hooks: RequestHooks = {\n getRequest: function(socket: HTTPRequest): Ajax {\n var Constructor = Runtime.getXHRAPI();\n var xhr = new Constructor();\n xhr.onreadystatechange = xhr.onprogress = function() {\n switch (xhr.readyState) {\n case 3:\n if (xhr.responseText && xhr.responseText.length > 0) {\n socket.onChunk(xhr.status, xhr.responseText);\n }\n break;\n case 4:\n // this happens only on errors, never after calling close\n if (xhr.responseText && xhr.responseText.length > 0) {\n socket.onChunk(xhr.status, xhr.responseText);\n }\n socket.emit('finished', xhr.status);\n socket.close();\n break;\n }\n };\n return xhr;\n },\n abortRequest: function(xhr: Ajax) {\n xhr.onreadystatechange = null;\n xhr.abort();\n }\n};\n\nexport default hooks;\n","import * as Collections from 'core/utils/collections';\nimport Transports from 'isomorphic/transports/transports';\nimport TimelineSender from 'core/timeline/timeline_sender';\nimport Ajax from 'core/http/ajax';\nimport getDefaultStrategy from './default_strategy';\nimport TransportsTable from 'core/transports/transports_table';\nimport transportConnectionInitializer from './transports/transport_connection_initializer';\nimport HTTPFactory from './http/http';\n\nvar Isomorphic: any = {\n getDefaultStrategy,\n Transports: Transports,\n transportConnectionInitializer,\n HTTPFactory,\n\n setup(PusherClass): void {\n PusherClass.ready();\n },\n\n getLocalStorage(): any {\n return undefined;\n },\n\n getClientFeatures(): any[] {\n return Collections.keys(\n Collections.filterObject({ ws: Transports.ws }, function(t) {\n return t.isSupported({});\n })\n );\n },\n\n getProtocol(): string {\n return 'http:';\n },\n\n isXHRSupported(): boolean {\n return true;\n },\n\n createSocketRequest(method: string, url: string) {\n if (this.isXHRSupported()) {\n return this.HTTPFactory.createXHR(method, url);\n } else {\n throw 'Cross-origin HTTP requests are not supported';\n }\n },\n\n createXHR(): Ajax {\n var Constructor = this.getXHRAPI();\n return new Constructor();\n },\n\n createWebSocket(url: string): any {\n var Constructor = this.getWebSocketAPI();\n return new Constructor(url);\n },\n\n addUnloadListener(listener: any) {},\n removeUnloadListener(listener: any) {}\n};\n\nexport default Isomorphic;\n","/** Initializes the transport.\n *\n * Fetches resources if needed and then transitions to initialized.\n */\nexport default function() {\n var self = this;\n\n self.timeline.info(\n self.buildTimelineMessage({\n transport: self.name + (self.options.useTLS ? 's' : '')\n })\n );\n\n if (self.hooks.isInitialized()) {\n self.changeState('initialized');\n } else {\n self.onClose();\n }\n}\n","import HTTPRequest from 'core/http/http_request';\nimport HTTPSocket from 'core/http/http_socket';\nimport SocketHooks from 'core/http/socket_hooks';\nimport RequestHooks from 'core/http/request_hooks';\nimport streamingHooks from 'core/http/http_streaming_socket';\nimport pollingHooks from 'core/http/http_polling_socket';\nimport xhrHooks from './http_xhr_request';\nimport HTTPFactory from 'core/http/http_factory';\n\nvar HTTP: HTTPFactory = {\n createStreamingSocket(url: string): HTTPSocket {\n return this.createSocket(streamingHooks, url);\n },\n\n createPollingSocket(url: string): HTTPSocket {\n return this.createSocket(pollingHooks, url);\n },\n\n createSocket(hooks: SocketHooks, url: string): HTTPSocket {\n return new HTTPSocket(hooks, url);\n },\n\n createXHR(method: string, url: string): HTTPRequest {\n return this.createRequest(xhrHooks, method, url);\n },\n\n createRequest(hooks: RequestHooks, method: string, url: string): HTTPRequest {\n return new HTTPRequest(hooks, method, url);\n }\n};\n\nexport default HTTP;\n","import { default as EventsDispatcher } from 'core/events/dispatcher';\nimport Reachability from 'core/reachability';\n\nexport class NetInfo extends EventsDispatcher implements Reachability {\n isOnline(): boolean {\n return true;\n }\n}\n\nexport var Network = new NetInfo();\n","import AbstractRuntime from 'runtimes/interface';\nimport { AuthTransport } from 'core/auth/auth_transports';\nimport {\n AuthRequestType,\n AuthTransportCallback,\n InternalAuthOptions\n} from 'core/auth/options';\nimport { HTTPAuthError } from 'core/errors';\n\nvar fetchAuth: AuthTransport = function(\n context: AbstractRuntime,\n query: string,\n authOptions: InternalAuthOptions,\n authRequestType: AuthRequestType,\n callback: AuthTransportCallback\n) {\n var headers = new Headers();\n headers.set('Content-Type', 'application/x-www-form-urlencoded');\n\n for (var headerName in authOptions.headers) {\n headers.set(headerName, authOptions.headers[headerName]);\n }\n\n if (authOptions.headersProvider != null) {\n const dynamicHeaders = authOptions.headersProvider();\n for (var headerName in dynamicHeaders) {\n headers.set(headerName, dynamicHeaders[headerName]);\n }\n }\n\n var body = query;\n var request = new Request(authOptions.endpoint, {\n headers,\n body,\n credentials: 'same-origin',\n method: 'POST'\n });\n\n return fetch(request)\n .then(response => {\n let { status } = response;\n if (status === 200) {\n // manually parse the json so we can provide a more helpful error in\n // failure case\n return response.text();\n }\n throw new HTTPAuthError(\n status,\n `Could not get ${authRequestType.toString()} info from your auth endpoint, status: ${status}`\n );\n })\n .then(data => {\n let parsedData;\n try {\n parsedData = JSON.parse(data);\n } catch (e) {\n throw new HTTPAuthError(\n 200,\n `JSON returned from ${authRequestType.toString()} endpoint was invalid, yet status code was 200. Data was: ${data}`\n );\n }\n callback(null, parsedData);\n })\n .catch(err => {\n callback(err, null);\n });\n};\n\nexport default fetchAuth;\n","import Logger from 'core/logger';\nimport TimelineSender from 'core/timeline/timeline_sender';\nimport * as Collections from 'core/utils/collections';\nimport Util from 'core/util';\nimport Runtime from 'runtime';\nimport TimelineTransport from 'core/timeline/timeline_transport';\n\nvar getAgent = function(sender: TimelineSender, useTLS: boolean) {\n return function(data: any, callback: Function) {\n var scheme = 'http' + (useTLS ? 's' : '') + '://';\n var url =\n scheme + (sender.host || sender.options.host) + sender.options.path;\n var query = Collections.buildQueryString(data);\n url += '/' + 2 + '?' + query;\n\n fetch(url)\n .then(response => {\n if (response.status !== 200) {\n throw `received ${response.status} from stats.pusher.com`;\n }\n return response.json();\n })\n .then(({ host }) => {\n if (host) {\n sender.host = host;\n }\n })\n .catch(err => {\n Logger.debug('TimelineSender Error: ', err);\n });\n };\n};\n\nvar fetchTimeline = {\n name: 'xhr',\n getAgent\n};\n\nexport default fetchTimeline;\n","import Isomorphic from 'isomorphic/runtime';\nimport Runtime from '../interface';\nimport { Network } from './net_info';\nimport fetchAuth from './auth/fetch_auth';\nimport { AuthTransports } from 'core/auth/auth_transports';\nimport fetchTimeline from './timeline/fetch_timeline';\n\n// Very verbose but until unavoidable until\n// TypeScript 2.1, when spread attributes will be\n// supported\nconst {\n getDefaultStrategy,\n Transports,\n setup,\n getProtocol,\n isXHRSupported,\n getLocalStorage,\n createXHR,\n createWebSocket,\n addUnloadListener,\n removeUnloadListener,\n transportConnectionInitializer,\n createSocketRequest,\n HTTPFactory\n} = Isomorphic;\n\nconst Worker: Runtime = {\n getDefaultStrategy,\n Transports,\n setup,\n getProtocol,\n isXHRSupported,\n getLocalStorage,\n createXHR,\n createWebSocket,\n addUnloadListener,\n removeUnloadListener,\n transportConnectionInitializer,\n createSocketRequest,\n HTTPFactory,\n\n TimelineTransport: fetchTimeline,\n\n getAuthorizers(): AuthTransports {\n return { ajax: fetchAuth };\n },\n\n getWebSocketAPI() {\n return WebSocket;\n },\n\n getXHRAPI() {\n return XMLHttpRequest;\n },\n\n getNetwork() {\n return Network;\n },\n\n randomInt(max: number): number {\n /**\n * Return values in the range of [0, 1[\n */\n const random = function() {\n const crypto = globalThis.crypto || globalThis['msCrypto'];\n const random = crypto.getRandomValues(new Uint32Array(1))[0];\n\n return random / 2 ** 32;\n };\n\n return Math.floor(random() * max);\n }\n};\n\nexport default Worker;\n","enum TimelineLevel {\n ERROR = 3,\n INFO = 6,\n DEBUG = 7\n}\n\nexport default TimelineLevel;\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport { default as Level } from './level';\n\nexport interface TimelineOptions {\n level?: Level;\n limit?: number;\n version?: string;\n cluster?: string;\n features?: string[];\n params?: any;\n}\n\nexport default class Timeline {\n key: string;\n session: number;\n events: any[];\n options: TimelineOptions;\n sent: number;\n uniqueID: number;\n\n constructor(key: string, session: number, options: TimelineOptions) {\n this.key = key;\n this.session = session;\n this.events = [];\n this.options = options || {};\n this.sent = 0;\n this.uniqueID = 0;\n }\n\n log(level, event) {\n if (level <= this.options.level) {\n this.events.push(\n Collections.extend({}, event, { timestamp: Util.now() })\n );\n if (this.options.limit && this.events.length > this.options.limit) {\n this.events.shift();\n }\n }\n }\n\n error(event) {\n this.log(Level.ERROR, event);\n }\n\n info(event) {\n this.log(Level.INFO, event);\n }\n\n debug(event) {\n this.log(Level.DEBUG, event);\n }\n\n isEmpty() {\n return this.events.length === 0;\n }\n\n send(sendfn, callback) {\n var data = Collections.extend(\n {\n session: this.session,\n bundle: this.sent + 1,\n key: this.key,\n lib: 'js',\n version: this.options.version,\n cluster: this.options.cluster,\n features: this.options.features,\n timeline: this.events\n },\n this.options.params\n );\n\n this.events = [];\n sendfn(data, (error, result) => {\n if (!error) {\n this.sent++;\n }\n if (callback) {\n callback(error, result);\n }\n });\n\n return true;\n }\n\n generateUniqueID(): number {\n this.uniqueID++;\n return this.uniqueID;\n }\n}\n","import Factory from '../utils/factory';\nimport Util from '../util';\nimport * as Errors from '../errors';\nimport * as Collections from '../utils/collections';\nimport Strategy from './strategy';\nimport Transport from '../transports/transport';\nimport StrategyOptions from './strategy_options';\nimport Handshake from '../connection/handshake';\n\n/** Provides a strategy interface for transports.\n *\n * @param {String} name\n * @param {Number} priority\n * @param {Class} transport\n * @param {Object} options\n */\nexport default class TransportStrategy implements Strategy {\n name: string;\n priority: number;\n transport: Transport;\n options: StrategyOptions;\n\n constructor(\n name: string,\n priority: number,\n transport: Transport,\n options: StrategyOptions\n ) {\n this.name = name;\n this.priority = priority;\n this.transport = transport;\n this.options = options || {};\n }\n\n /** Returns whether the transport is supported in the browser.\n *\n * @returns {Boolean}\n */\n isSupported(): boolean {\n return this.transport.isSupported({\n useTLS: this.options.useTLS\n });\n }\n\n /** Launches a connection attempt and returns a strategy runner.\n *\n * @param {Function} callback\n * @return {Object} strategy runner\n */\n connect(minPriority: number, callback: Function) {\n if (!this.isSupported()) {\n return failAttempt(new Errors.UnsupportedStrategy(), callback);\n } else if (this.priority < minPriority) {\n return failAttempt(new Errors.TransportPriorityTooLow(), callback);\n }\n\n var connected = false;\n var transport = this.transport.createConnection(\n this.name,\n this.priority,\n this.options.key,\n this.options\n );\n var handshake = null;\n\n var onInitialized = function() {\n transport.unbind('initialized', onInitialized);\n transport.connect();\n };\n var onOpen = function() {\n handshake = Factory.createHandshake(transport, function(result) {\n connected = true;\n unbindListeners();\n callback(null, result);\n });\n };\n var onError = function(error) {\n unbindListeners();\n callback(error);\n };\n var onClosed = function() {\n unbindListeners();\n var serializedTransport;\n\n // The reason for this try/catch block is that on React Native\n // the WebSocket object is circular. Therefore transport.socket will\n // throw errors upon stringification. Collections.safeJSONStringify\n // discards circular references when serializing.\n serializedTransport = Collections.safeJSONStringify(transport);\n callback(new Errors.TransportClosed(serializedTransport));\n };\n\n var unbindListeners = function() {\n transport.unbind('initialized', onInitialized);\n transport.unbind('open', onOpen);\n transport.unbind('error', onError);\n transport.unbind('closed', onClosed);\n };\n\n transport.bind('initialized', onInitialized);\n transport.bind('open', onOpen);\n transport.bind('error', onError);\n transport.bind('closed', onClosed);\n\n // connect will be called automatically after initialization\n transport.initialize();\n\n return {\n abort: () => {\n if (connected) {\n return;\n }\n unbindListeners();\n if (handshake) {\n handshake.close();\n } else {\n transport.close();\n }\n },\n forceMinPriority: p => {\n if (connected) {\n return;\n }\n if (this.priority < p) {\n if (handshake) {\n handshake.close();\n } else {\n transport.close();\n }\n }\n }\n };\n }\n}\n\nfunction failAttempt(error: Error, callback: Function) {\n Util.defer(function() {\n callback(error);\n });\n return {\n abort: function() {},\n forceMinPriority: function() {}\n };\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport TransportManager from '../transports/transport_manager';\nimport * as Errors from '../errors';\nimport Strategy from './strategy';\nimport TransportStrategy from './transport_strategy';\nimport StrategyOptions from '../strategies/strategy_options';\nimport { Config } from '../config';\nimport Runtime from 'runtime';\n\nconst { Transports } = Runtime;\n\nexport var defineTransport = function(\n config: Config,\n name: string,\n type: string,\n priority: number,\n options: StrategyOptions,\n manager?: TransportManager\n): Strategy {\n var transportClass = Transports[type];\n if (!transportClass) {\n throw new Errors.UnsupportedTransport(type);\n }\n\n var enabled =\n (!config.enabledTransports ||\n Collections.arrayIndexOf(config.enabledTransports, name) !== -1) &&\n (!config.disabledTransports ||\n Collections.arrayIndexOf(config.disabledTransports, name) === -1);\n\n var transport;\n if (enabled) {\n options = Object.assign(\n { ignoreNullOrigin: config.ignoreNullOrigin },\n options\n );\n\n transport = new TransportStrategy(\n name,\n priority,\n manager ? manager.getAssistant(transportClass) : transportClass,\n options\n );\n } else {\n transport = UnsupportedStrategy;\n }\n\n return transport;\n};\n\nvar UnsupportedStrategy: Strategy = {\n isSupported: function() {\n return false;\n },\n connect: function(_, callback) {\n var deferred = Util.defer(function() {\n callback(new Errors.UnsupportedStrategy());\n });\n return {\n abort: function() {\n deferred.ensureAborted();\n },\n forceMinPriority: function() {}\n };\n }\n};\n","export enum AuthRequestType {\n UserAuthentication = 'user-authentication',\n ChannelAuthorization = 'channel-authorization'\n}\n\nexport interface ChannelAuthorizationData {\n auth: string;\n channel_data?: string;\n shared_secret?: string;\n}\n\nexport type ChannelAuthorizationCallback = (\n error: Error | null,\n authData: ChannelAuthorizationData | null\n) => void;\n\nexport interface ChannelAuthorizationRequestParams {\n socketId: string;\n channelName: string;\n}\n\nexport interface ChannelAuthorizationHandler {\n (\n params: ChannelAuthorizationRequestParams,\n callback: ChannelAuthorizationCallback\n ): void;\n}\n\nexport interface UserAuthenticationData {\n auth: string;\n user_data: string;\n}\n\nexport type UserAuthenticationCallback = (\n error: Error | null,\n authData: UserAuthenticationData | null\n) => void;\n\nexport interface UserAuthenticationRequestParams {\n socketId: string;\n}\n\nexport interface UserAuthenticationHandler {\n (\n params: UserAuthenticationRequestParams,\n callback: UserAuthenticationCallback\n ): void;\n}\n\nexport type AuthTransportCallback =\n | ChannelAuthorizationCallback\n | UserAuthenticationCallback;\n\nexport interface AuthOptionsT {\n transport: 'ajax' | 'jsonp';\n endpoint: string;\n params?: any;\n headers?: any;\n paramsProvider?: () => any;\n headersProvider?: () => any;\n customHandler?: AuthHandler;\n}\n\nexport declare type UserAuthenticationOptions = AuthOptionsT<\n UserAuthenticationHandler\n>;\nexport declare type ChannelAuthorizationOptions = AuthOptionsT<\n ChannelAuthorizationHandler\n>;\n\nexport interface InternalAuthOptions {\n transport: 'ajax' | 'jsonp';\n endpoint: string;\n params?: any;\n headers?: any;\n paramsProvider?: () => any;\n headersProvider?: () => any;\n}\n","import {\n UserAuthenticationCallback,\n InternalAuthOptions,\n UserAuthenticationHandler,\n UserAuthenticationRequestParams,\n AuthRequestType\n} from './options';\n\nimport Runtime from 'runtime';\n\nconst composeChannelQuery = (\n params: UserAuthenticationRequestParams,\n authOptions: InternalAuthOptions\n) => {\n var query = 'socket_id=' + encodeURIComponent(params.socketId);\n\n for (var key in authOptions.params) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(authOptions.params[key]);\n }\n\n if (authOptions.paramsProvider != null) {\n let dynamicParams = authOptions.paramsProvider();\n for (var key in dynamicParams) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(dynamicParams[key]);\n }\n }\n\n return query;\n};\n\nconst UserAuthenticator = (\n authOptions: InternalAuthOptions\n): UserAuthenticationHandler => {\n if (typeof Runtime.getAuthorizers()[authOptions.transport] === 'undefined') {\n throw `'${authOptions.transport}' is not a recognized auth transport`;\n }\n\n return (\n params: UserAuthenticationRequestParams,\n callback: UserAuthenticationCallback\n ) => {\n const query = composeChannelQuery(params, authOptions);\n\n Runtime.getAuthorizers()[authOptions.transport](\n Runtime,\n query,\n authOptions,\n AuthRequestType.UserAuthentication,\n callback\n );\n };\n};\n\nexport default UserAuthenticator;\n","import {\n AuthRequestType,\n InternalAuthOptions,\n ChannelAuthorizationHandler,\n ChannelAuthorizationRequestParams,\n ChannelAuthorizationCallback\n} from './options';\n\nimport Runtime from 'runtime';\n\nconst composeChannelQuery = (\n params: ChannelAuthorizationRequestParams,\n authOptions: InternalAuthOptions\n) => {\n var query = 'socket_id=' + encodeURIComponent(params.socketId);\n\n query += '&channel_name=' + encodeURIComponent(params.channelName);\n\n for (var key in authOptions.params) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(authOptions.params[key]);\n }\n\n if (authOptions.paramsProvider != null) {\n let dynamicParams = authOptions.paramsProvider();\n for (var key in dynamicParams) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(dynamicParams[key]);\n }\n }\n\n return query;\n};\n\nconst ChannelAuthorizer = (\n authOptions: InternalAuthOptions\n): ChannelAuthorizationHandler => {\n if (typeof Runtime.getAuthorizers()[authOptions.transport] === 'undefined') {\n throw `'${authOptions.transport}' is not a recognized auth transport`;\n }\n\n return (\n params: ChannelAuthorizationRequestParams,\n callback: ChannelAuthorizationCallback\n ) => {\n const query = composeChannelQuery(params, authOptions);\n\n Runtime.getAuthorizers()[authOptions.transport](\n Runtime,\n query,\n authOptions,\n AuthRequestType.ChannelAuthorization,\n callback\n );\n };\n};\n\nexport default ChannelAuthorizer;\n","import { Options } from './options';\nimport Defaults from './defaults';\nimport {\n ChannelAuthorizationHandler,\n UserAuthenticationHandler,\n ChannelAuthorizationOptions\n} from './auth/options';\nimport UserAuthenticator from './auth/user_authenticator';\nimport ChannelAuthorizer from './auth/channel_authorizer';\nimport { ChannelAuthorizerProxy } from './auth/deprecated_channel_authorizer';\nimport Runtime from 'runtime';\nimport * as nacl from 'tweetnacl';\n\nexport type AuthTransport = 'ajax' | 'jsonp';\nexport type Transport =\n | 'ws'\n | 'wss'\n | 'xhr_streaming'\n | 'xhr_polling'\n | 'sockjs';\n\nexport interface Config {\n // these are all 'required' config parameters, it's not necessary for the user\n // to set them, but they have configured defaults.\n activityTimeout: number;\n enableStats: boolean;\n httpHost: string;\n httpPath: string;\n httpPort: number;\n httpsPort: number;\n pongTimeout: number;\n statsHost: string;\n unavailableTimeout: number;\n useTLS: boolean;\n wsHost: string;\n wsPath: string;\n wsPort: number;\n wssPort: number;\n userAuthenticator: UserAuthenticationHandler;\n channelAuthorizer: ChannelAuthorizationHandler;\n\n // these are all optional parameters or overrrides. The customer can set these\n // but it's not strictly necessary\n forceTLS?: boolean;\n cluster?: string;\n disabledTransports?: Transport[];\n enabledTransports?: Transport[];\n ignoreNullOrigin?: boolean;\n nacl?: nacl;\n timelineParams?: any;\n}\n\n// getConfig mainly sets the defaults for the options that are not provided\nexport function getConfig(opts: Options, pusher): Config {\n let config: Config = {\n activityTimeout: opts.activityTimeout || Defaults.activityTimeout,\n cluster: opts.cluster,\n httpPath: opts.httpPath || Defaults.httpPath,\n httpPort: opts.httpPort || Defaults.httpPort,\n httpsPort: opts.httpsPort || Defaults.httpsPort,\n pongTimeout: opts.pongTimeout || Defaults.pongTimeout,\n statsHost: opts.statsHost || Defaults.stats_host,\n unavailableTimeout: opts.unavailableTimeout || Defaults.unavailableTimeout,\n wsPath: opts.wsPath || Defaults.wsPath,\n wsPort: opts.wsPort || Defaults.wsPort,\n wssPort: opts.wssPort || Defaults.wssPort,\n\n enableStats: getEnableStatsConfig(opts),\n httpHost: getHttpHost(opts),\n useTLS: shouldUseTLS(opts),\n wsHost: getWebsocketHost(opts),\n\n userAuthenticator: buildUserAuthenticator(opts),\n channelAuthorizer: buildChannelAuthorizer(opts, pusher)\n };\n\n if ('disabledTransports' in opts)\n config.disabledTransports = opts.disabledTransports;\n if ('enabledTransports' in opts)\n config.enabledTransports = opts.enabledTransports;\n if ('ignoreNullOrigin' in opts)\n config.ignoreNullOrigin = opts.ignoreNullOrigin;\n if ('timelineParams' in opts) config.timelineParams = opts.timelineParams;\n if ('nacl' in opts) {\n config.nacl = opts.nacl;\n }\n\n return config;\n}\n\nfunction getHttpHost(opts: Options): string {\n if (opts.httpHost) {\n return opts.httpHost;\n }\n if (opts.cluster) {\n return `sockjs-${opts.cluster}.pusher.com`;\n }\n return Defaults.httpHost;\n}\n\nfunction getWebsocketHost(opts: Options): string {\n if (opts.wsHost) {\n return opts.wsHost;\n }\n return getWebsocketHostFromCluster(opts.cluster);\n}\n\nfunction getWebsocketHostFromCluster(cluster: string): string {\n return `ws-${cluster}.pusher.com`;\n}\n\nfunction shouldUseTLS(opts: Options): boolean {\n if (Runtime.getProtocol() === 'https:') {\n return true;\n } else if (opts.forceTLS === false) {\n return false;\n }\n return true;\n}\n\n// if enableStats is set take the value\n// if disableStats is set take the inverse\n// otherwise default to false\nfunction getEnableStatsConfig(opts: Options): boolean {\n if ('enableStats' in opts) {\n return opts.enableStats;\n }\n if ('disableStats' in opts) {\n return !opts.disableStats;\n }\n return false;\n}\n\nfunction buildUserAuthenticator(opts: Options): UserAuthenticationHandler {\n const userAuthentication = {\n ...Defaults.userAuthentication,\n ...opts.userAuthentication\n };\n if (\n 'customHandler' in userAuthentication &&\n userAuthentication['customHandler'] != null\n ) {\n return userAuthentication['customHandler'];\n }\n\n return UserAuthenticator(userAuthentication);\n}\n\nfunction buildChannelAuth(opts: Options, pusher): ChannelAuthorizationOptions {\n let channelAuthorization: ChannelAuthorizationOptions;\n if ('channelAuthorization' in opts) {\n channelAuthorization = {\n ...Defaults.channelAuthorization,\n ...opts.channelAuthorization\n };\n } else {\n channelAuthorization = {\n transport: opts.authTransport || Defaults.authTransport,\n endpoint: opts.authEndpoint || Defaults.authEndpoint\n };\n if ('auth' in opts) {\n if ('params' in opts.auth) channelAuthorization.params = opts.auth.params;\n if ('headers' in opts.auth)\n channelAuthorization.headers = opts.auth.headers;\n }\n if ('authorizer' in opts)\n channelAuthorization.customHandler = ChannelAuthorizerProxy(\n pusher,\n channelAuthorization,\n opts.authorizer\n );\n }\n return channelAuthorization;\n}\n\nfunction buildChannelAuthorizer(\n opts: Options,\n pusher\n): ChannelAuthorizationHandler {\n const channelAuthorization = buildChannelAuth(opts, pusher);\n if (\n 'customHandler' in channelAuthorization &&\n channelAuthorization['customHandler'] != null\n ) {\n return channelAuthorization['customHandler'];\n }\n\n return ChannelAuthorizer(channelAuthorization);\n}\n","import Channel from '../channels/channel';\nimport {\n ChannelAuthorizationCallback,\n ChannelAuthorizationHandler,\n ChannelAuthorizationRequestParams,\n InternalAuthOptions\n} from './options';\n\nexport interface DeprecatedChannelAuthorizer {\n authorize(socketId: string, callback: ChannelAuthorizationCallback): void;\n}\n\nexport interface ChannelAuthorizerGenerator {\n (\n channel: Channel,\n options: DeprecatedAuthorizerOptions\n ): DeprecatedChannelAuthorizer;\n}\n\nexport interface DeprecatedAuthOptions {\n params?: any;\n headers?: any;\n}\n\nexport interface DeprecatedAuthorizerOptions {\n authTransport: 'ajax' | 'jsonp';\n authEndpoint: string;\n auth?: DeprecatedAuthOptions;\n}\n\nexport const ChannelAuthorizerProxy = (\n pusher,\n authOptions: InternalAuthOptions,\n channelAuthorizerGenerator: ChannelAuthorizerGenerator\n): ChannelAuthorizationHandler => {\n const deprecatedAuthorizerOptions: DeprecatedAuthorizerOptions = {\n authTransport: authOptions.transport,\n authEndpoint: authOptions.endpoint,\n auth: {\n params: authOptions.params,\n headers: authOptions.headers\n }\n };\n return (\n params: ChannelAuthorizationRequestParams,\n callback: ChannelAuthorizationCallback\n ) => {\n const channel = pusher.channel(params.channelName);\n // This line creates a new channel authorizer every time.\n // In the past, this was only done once per channel and reused.\n // We can do that again if we want to keep this behavior intact.\n const channelAuthorizer: DeprecatedChannelAuthorizer = channelAuthorizerGenerator(\n channel,\n deprecatedAuthorizerOptions\n );\n channelAuthorizer.authorize(params.socketId, callback);\n };\n};\n","import Logger from './logger';\nimport Pusher from './pusher';\nimport EventsDispatcher from './events/dispatcher';\n\nexport default class WatchlistFacade extends EventsDispatcher {\n private pusher: Pusher;\n\n public constructor(pusher: Pusher) {\n super(function(eventName, data) {\n Logger.debug(`No callbacks on watchlist events for ${eventName}`);\n });\n\n this.pusher = pusher;\n this.bindWatchlistInternalEvent();\n }\n\n handleEvent(pusherEvent) {\n pusherEvent.data.events.forEach(watchlistEvent => {\n this.emit(watchlistEvent.name, watchlistEvent);\n });\n }\n\n private bindWatchlistInternalEvent() {\n this.pusher.connection.bind('message', pusherEvent => {\n var eventName = pusherEvent.event;\n if (eventName === 'pusher_internal:watchlist_events') {\n this.handleEvent(pusherEvent);\n }\n });\n }\n}\n","function flatPromise() {\n let resolve, reject;\n const promise = new Promise((res, rej) => {\n resolve = res;\n reject = rej;\n });\n return { promise, resolve, reject };\n}\n\nexport default flatPromise;\n","import Pusher from './pusher';\nimport Logger from './logger';\nimport {\n UserAuthenticationData,\n UserAuthenticationCallback\n} from './auth/options';\nimport Channel from './channels/channel';\nimport WatchlistFacade from './watchlist';\nimport EventsDispatcher from './events/dispatcher';\nimport flatPromise from './utils/flat_promise';\n\nexport default class UserFacade extends EventsDispatcher {\n pusher: Pusher;\n signin_requested: boolean = false;\n user_data: any = null;\n serverToUserChannel: Channel = null;\n signinDonePromise: Promise = null;\n watchlist: WatchlistFacade;\n private _signinDoneResolve: Function = null;\n\n public constructor(pusher: Pusher) {\n super(function(eventName, data) {\n Logger.debug('No callbacks on user for ' + eventName);\n });\n this.pusher = pusher;\n this.pusher.connection.bind('state_change', ({ previous, current }) => {\n if (previous !== 'connected' && current === 'connected') {\n this._signin();\n }\n if (previous === 'connected' && current !== 'connected') {\n this._cleanup();\n this._newSigninPromiseIfNeeded();\n }\n });\n\n this.watchlist = new WatchlistFacade(pusher);\n\n this.pusher.connection.bind('message', event => {\n var eventName = event.event;\n if (eventName === 'pusher:signin_success') {\n this._onSigninSuccess(event.data);\n }\n if (\n this.serverToUserChannel &&\n this.serverToUserChannel.name === event.channel\n ) {\n this.serverToUserChannel.handleEvent(event);\n }\n });\n }\n\n public signin() {\n if (this.signin_requested) {\n return;\n }\n\n this.signin_requested = true;\n this._signin();\n }\n\n private _signin() {\n if (!this.signin_requested) {\n return;\n }\n\n this._newSigninPromiseIfNeeded();\n\n if (this.pusher.connection.state !== 'connected') {\n // Signin will be attempted when the connection is connected\n return;\n }\n\n this.pusher.config.userAuthenticator(\n {\n socketId: this.pusher.connection.socket_id\n },\n this._onAuthorize\n );\n }\n\n private _onAuthorize: UserAuthenticationCallback = (\n err,\n authData: UserAuthenticationData\n ) => {\n if (err) {\n Logger.warn(`Error during signin: ${err}`);\n this._cleanup();\n return;\n }\n\n this.pusher.send_event('pusher:signin', {\n auth: authData.auth,\n user_data: authData.user_data\n });\n\n // Later when we get pusher:singin_success event, the user will be marked as signed in\n };\n\n private _onSigninSuccess(data: any) {\n try {\n this.user_data = JSON.parse(data.user_data);\n } catch (e) {\n Logger.error(`Failed parsing user data after signin: ${data.user_data}`);\n this._cleanup();\n return;\n }\n\n if (typeof this.user_data.id !== 'string' || this.user_data.id === '') {\n Logger.error(\n `user_data doesn't contain an id. user_data: ${this.user_data}`\n );\n this._cleanup();\n return;\n }\n\n // Signin succeeded\n this._signinDoneResolve();\n this._subscribeChannels();\n }\n\n private _subscribeChannels() {\n const ensure_subscribed = channel => {\n if (channel.subscriptionPending && channel.subscriptionCancelled) {\n channel.reinstateSubscription();\n } else if (\n !channel.subscriptionPending &&\n this.pusher.connection.state === 'connected'\n ) {\n channel.subscribe();\n }\n };\n\n this.serverToUserChannel = new Channel(\n `#server-to-user-${this.user_data.id}`,\n this.pusher\n );\n this.serverToUserChannel.bind_global((eventName, data) => {\n if (\n eventName.indexOf('pusher_internal:') === 0 ||\n eventName.indexOf('pusher:') === 0\n ) {\n // ignore internal events\n return;\n }\n this.emit(eventName, data);\n });\n ensure_subscribed(this.serverToUserChannel);\n }\n\n private _cleanup() {\n this.user_data = null;\n if (this.serverToUserChannel) {\n this.serverToUserChannel.unbind_all();\n this.serverToUserChannel.disconnect();\n this.serverToUserChannel = null;\n }\n\n if (this.signin_requested) {\n // If signin is in progress and cleanup is called,\n // Mark the current signin process as done.\n this._signinDoneResolve();\n }\n }\n\n private _newSigninPromiseIfNeeded() {\n if (!this.signin_requested) {\n return;\n }\n\n // If there is a promise and it is not resolved, return without creating a new one.\n if (this.signinDonePromise && !(this.signinDonePromise as any).done) {\n return;\n }\n\n // This promise is never rejected.\n // It gets resolved when the signin process is done whether it failed or succeeded\n const { promise, resolve, reject: _ } = flatPromise();\n (promise as any).done = false;\n const setDone = () => {\n (promise as any).done = true;\n };\n promise.then(setDone).catch(setDone);\n this.signinDonePromise = promise;\n this._signinDoneResolve = resolve;\n }\n}\n","import AbstractRuntime from '../runtimes/interface';\nimport Runtime from 'runtime';\nimport * as Collections from './utils/collections';\nimport Channels from './channels/channels';\nimport Channel from './channels/channel';\nimport { default as EventsDispatcher } from './events/dispatcher';\nimport Timeline from './timeline/timeline';\nimport TimelineSender from './timeline/timeline_sender';\nimport TimelineLevel from './timeline/level';\nimport { defineTransport } from './strategies/strategy_builder';\nimport ConnectionManager from './connection/connection_manager';\nimport { PeriodicTimer } from './utils/timers';\nimport Defaults from './defaults';\nimport Logger from './logger';\nimport Factory from './utils/factory';\nimport { Options, ClusterOptions, validateOptions } from './options';\nimport { Config, getConfig } from './config';\nimport StrategyOptions from './strategies/strategy_options';\nimport UserFacade from './user';\n\nexport default class Pusher {\n /* STATIC PROPERTIES */\n static instances: Pusher[] = [];\n static isReady: boolean = false;\n static logToConsole: boolean = false;\n\n // for jsonp\n static Runtime: AbstractRuntime = Runtime;\n static ScriptReceivers: any = (Runtime).ScriptReceivers;\n static DependenciesReceivers: any = (Runtime).DependenciesReceivers;\n static auth_callbacks: any = (Runtime).auth_callbacks;\n\n static ready() {\n Pusher.isReady = true;\n for (var i = 0, l = Pusher.instances.length; i < l; i++) {\n Pusher.instances[i].connect();\n }\n }\n\n static log: (message: any) => void;\n\n private static getClientFeatures(): string[] {\n return Collections.keys(\n Collections.filterObject({ ws: Runtime.Transports.ws }, function(t) {\n return t.isSupported({});\n })\n );\n }\n\n /* INSTANCE PROPERTIES */\n key: string;\n options: Options;\n config: Config;\n channels: Channels;\n global_emitter: EventsDispatcher;\n sessionID: number;\n timeline: Timeline;\n timelineSender: TimelineSender;\n connection: ConnectionManager;\n timelineSenderTimer: PeriodicTimer;\n user: UserFacade;\n constructor(app_key: string, options: Options) {\n checkAppKey(app_key);\n validateOptions(options);\n this.key = app_key;\n this.config = getConfig(options, this);\n\n this.channels = Factory.createChannels();\n this.global_emitter = new EventsDispatcher();\n this.sessionID = Runtime.randomInt(1000000000);\n\n this.timeline = new Timeline(this.key, this.sessionID, {\n cluster: this.config.cluster,\n features: Pusher.getClientFeatures(),\n params: this.config.timelineParams || {},\n limit: 50,\n level: TimelineLevel.INFO,\n version: Defaults.VERSION\n });\n if (this.config.enableStats) {\n this.timelineSender = Factory.createTimelineSender(this.timeline, {\n host: this.config.statsHost,\n path: '/timeline/v2/' + Runtime.TimelineTransport.name\n });\n }\n\n var getStrategy = (options: StrategyOptions) => {\n return Runtime.getDefaultStrategy(this.config, options, defineTransport);\n };\n\n this.connection = Factory.createConnectionManager(this.key, {\n getStrategy: getStrategy,\n timeline: this.timeline,\n activityTimeout: this.config.activityTimeout,\n pongTimeout: this.config.pongTimeout,\n unavailableTimeout: this.config.unavailableTimeout,\n useTLS: Boolean(this.config.useTLS)\n });\n\n this.connection.bind('connected', () => {\n this.subscribeAll();\n if (this.timelineSender) {\n this.timelineSender.send(this.connection.isUsingTLS());\n }\n });\n\n this.connection.bind('message', event => {\n var eventName = event.event;\n var internal = eventName.indexOf('pusher_internal:') === 0;\n if (event.channel) {\n var channel = this.channel(event.channel);\n if (channel) {\n channel.handleEvent(event);\n }\n }\n // Emit globally [deprecated]\n if (!internal) {\n this.global_emitter.emit(event.event, event.data);\n }\n });\n this.connection.bind('connecting', () => {\n this.channels.disconnect();\n });\n this.connection.bind('disconnected', () => {\n this.channels.disconnect();\n });\n this.connection.bind('error', err => {\n Logger.warn(err);\n });\n\n Pusher.instances.push(this);\n this.timeline.info({ instances: Pusher.instances.length });\n\n this.user = new UserFacade(this);\n\n if (Pusher.isReady) {\n this.connect();\n }\n }\n\n /**\n * Allows you to switch Pusher cluster without\n * losing all the channels/subscription binding\n * as this is internally managed by the SDK.\n */\n switchCluster(options: ClusterOptions) {\n const { appKey, cluster } = options;\n this.key = appKey;\n this.options = { ...this.options, cluster };\n this.config = getConfig(this.options, this);\n this.connection.switchCluster(this.key);\n }\n\n channel(name: string): Channel {\n return this.channels.find(name);\n }\n\n allChannels(): Channel[] {\n return this.channels.all();\n }\n\n connect() {\n this.connection.connect();\n\n if (this.timelineSender) {\n if (!this.timelineSenderTimer) {\n var usingTLS = this.connection.isUsingTLS();\n var timelineSender = this.timelineSender;\n this.timelineSenderTimer = new PeriodicTimer(60000, function() {\n timelineSender.send(usingTLS);\n });\n }\n }\n }\n\n disconnect() {\n this.connection.disconnect();\n\n if (this.timelineSenderTimer) {\n this.timelineSenderTimer.ensureAborted();\n this.timelineSenderTimer = null;\n }\n }\n\n bind(event_name: string, callback: Function, context?: any): Pusher {\n this.global_emitter.bind(event_name, callback, context);\n return this;\n }\n\n unbind(event_name?: string, callback?: Function, context?: any): Pusher {\n this.global_emitter.unbind(event_name, callback, context);\n return this;\n }\n\n bind_global(callback: Function): Pusher {\n this.global_emitter.bind_global(callback);\n return this;\n }\n\n unbind_global(callback?: Function): Pusher {\n this.global_emitter.unbind_global(callback);\n return this;\n }\n\n unbind_all(callback?: Function): Pusher {\n this.global_emitter.unbind_all();\n return this;\n }\n\n subscribeAll() {\n var channelName;\n for (channelName in this.channels.channels) {\n if (this.channels.channels.hasOwnProperty(channelName)) {\n this.subscribe(channelName);\n }\n }\n }\n\n subscribe(channel_name: string) {\n var channel = this.channels.add(channel_name, this);\n if (channel.subscriptionPending && channel.subscriptionCancelled) {\n channel.reinstateSubscription();\n } else if (\n !channel.subscriptionPending &&\n this.connection.state === 'connected'\n ) {\n channel.subscribe();\n }\n return channel;\n }\n\n unsubscribe(channel_name: string) {\n var channel = this.channels.find(channel_name);\n if (channel && channel.subscriptionPending) {\n channel.cancelSubscription();\n } else {\n channel = this.channels.remove(channel_name);\n if (channel && channel.subscribed) {\n channel.unsubscribe();\n }\n }\n }\n\n send_event(event_name: string, data: any, channel?: string) {\n return this.connection.send_event(event_name, data, channel);\n }\n\n shouldUseTLS(): boolean {\n return this.config.useTLS;\n }\n\n signin() {\n this.user.signin();\n }\n}\n\nfunction checkAppKey(key) {\n if (key === null || key === undefined) {\n throw 'You must pass your app key when you instantiate Pusher.';\n }\n}\n\nRuntime.setup(Pusher);\n","import ConnectionManager from './connection/connection_manager';\nimport {\n ChannelAuthorizationOptions,\n UserAuthenticationOptions\n} from './auth/options';\nimport {\n ChannelAuthorizerGenerator,\n DeprecatedAuthOptions\n} from './auth/deprecated_channel_authorizer';\nimport { AuthTransport, Transport } from './config';\nimport * as nacl from 'tweetnacl';\nimport Logger from './logger';\n\nexport interface Options {\n activityTimeout?: number;\n\n auth?: DeprecatedAuthOptions; // DEPRECATED use channelAuthorization instead\n authEndpoint?: string; // DEPRECATED use channelAuthorization instead\n authTransport?: AuthTransport; // DEPRECATED use channelAuthorization instead\n authorizer?: ChannelAuthorizerGenerator; // DEPRECATED use channelAuthorization instead\n\n channelAuthorization?: ChannelAuthorizationOptions;\n userAuthentication?: UserAuthenticationOptions;\n\n cluster: string;\n enableStats?: boolean;\n disableStats?: boolean;\n disabledTransports?: Transport[];\n enabledTransports?: Transport[];\n forceTLS?: boolean;\n httpHost?: string;\n httpPath?: string;\n httpPort?: number;\n httpsPort?: number;\n ignoreNullOrigin?: boolean;\n nacl?: nacl;\n pongTimeout?: number;\n statsHost?: string;\n timelineParams?: any;\n unavailableTimeout?: number;\n wsHost?: string;\n wsPath?: string;\n wsPort?: number;\n wssPort?: number;\n}\n\nexport interface ClusterOptions {\n appKey: string;\n cluster: string;\n}\n\nexport function validateOptions(options) {\n if (options == null) {\n throw 'You must pass an options object';\n }\n if (options.cluster == null) {\n throw 'Options object must provide a cluster';\n }\n if ('disableStats' in options) {\n Logger.warn(\n 'The disableStats option is deprecated in favor of enableStats'\n );\n }\n}\n"],"sourceRoot":""} \ No newline at end of file +{"version":3,"sources":["webpack://Pusher/webpack/universalModuleDefinition","webpack://Pusher/webpack/bootstrap","webpack://Pusher/./node_modules/@stablelib/base64/base64.ts","webpack://Pusher/./node_modules/@stablelib/utf8/utf8.ts","webpack://Pusher/./src/core/pusher.js","webpack://Pusher/./src/core/base64.ts","webpack://Pusher/./src/core/utils/timers/abstract_timer.ts","webpack://Pusher/./src/core/utils/timers/index.ts","webpack://Pusher/./src/core/util.ts","webpack://Pusher/./src/core/utils/collections.ts","webpack://Pusher/./src/core/defaults.ts","webpack://Pusher/./src/core/transports/url_schemes.ts","webpack://Pusher/./src/core/events/callback_registry.ts","webpack://Pusher/./src/core/events/dispatcher.ts","webpack://Pusher/./src/core/logger.ts","webpack://Pusher/./src/core/transports/transport_connection.ts","webpack://Pusher/./src/core/transports/transport.ts","webpack://Pusher/./src/runtimes/isomorphic/transports/transports.ts","webpack://Pusher/./src/core/transports/assistant_to_the_transport_manager.ts","webpack://Pusher/./src/core/connection/protocol/protocol.ts","webpack://Pusher/./src/core/connection/connection.ts","webpack://Pusher/./src/core/connection/handshake/index.ts","webpack://Pusher/./src/core/timeline/timeline_sender.ts","webpack://Pusher/./src/core/errors.ts","webpack://Pusher/./src/core/utils/url_store.ts","webpack://Pusher/./src/core/channels/channel.ts","webpack://Pusher/./src/core/channels/private_channel.ts","webpack://Pusher/./src/core/channels/members.ts","webpack://Pusher/./src/core/channels/presence_channel.ts","webpack://Pusher/./src/core/channels/encrypted_channel.ts","webpack://Pusher/./src/core/connection/connection_manager.ts","webpack://Pusher/./src/core/channels/channels.ts","webpack://Pusher/./src/core/utils/factory.ts","webpack://Pusher/./src/core/transports/transport_manager.ts","webpack://Pusher/./src/core/strategies/sequential_strategy.ts","webpack://Pusher/./src/core/strategies/best_connected_ever_strategy.ts","webpack://Pusher/./src/core/strategies/websocket_prioritized_cached_strategy.ts","webpack://Pusher/./src/core/strategies/delayed_strategy.ts","webpack://Pusher/./src/core/strategies/if_strategy.ts","webpack://Pusher/./src/core/strategies/first_connected_strategy.ts","webpack://Pusher/./src/runtimes/isomorphic/default_strategy.ts","webpack://Pusher/./src/core/http/http_request.ts","webpack://Pusher/./src/core/http/state.ts","webpack://Pusher/./src/core/http/http_socket.ts","webpack://Pusher/./src/core/http/http_streaming_socket.ts","webpack://Pusher/./src/core/http/http_polling_socket.ts","webpack://Pusher/./src/runtimes/isomorphic/http/http_xhr_request.ts","webpack://Pusher/./src/runtimes/isomorphic/runtime.ts","webpack://Pusher/./src/runtimes/isomorphic/transports/transport_connection_initializer.ts","webpack://Pusher/./src/runtimes/isomorphic/http/http.ts","webpack://Pusher/./src/runtimes/worker/net_info.ts","webpack://Pusher/./src/runtimes/worker/auth/fetch_auth.ts","webpack://Pusher/./src/runtimes/worker/timeline/fetch_timeline.ts","webpack://Pusher/./src/runtimes/worker/runtime.ts","webpack://Pusher/./src/core/timeline/level.ts","webpack://Pusher/./src/core/timeline/timeline.ts","webpack://Pusher/./src/core/strategies/transport_strategy.ts","webpack://Pusher/./src/core/strategies/strategy_builder.ts","webpack://Pusher/./src/core/auth/options.ts","webpack://Pusher/./src/core/auth/user_authenticator.ts","webpack://Pusher/./src/core/auth/channel_authorizer.ts","webpack://Pusher/./src/core/auth/deprecated_channel_authorizer.ts","webpack://Pusher/./src/core/config.ts","webpack://Pusher/./src/core/watchlist.ts","webpack://Pusher/./src/core/utils/flat_promise.ts","webpack://Pusher/./src/core/user.ts","webpack://Pusher/./src/core/pusher.ts","webpack://Pusher/./src/core/options.ts"],"names":["root","factory","exports","module","define","amd","this","installedModules","__webpack_require__","moduleId","i","l","modules","call","m","c","d","name","getter","o","Object","defineProperty","enumerable","get","r","Symbol","toStringTag","value","t","mode","__esModule","ns","create","key","bind","n","object","property","prototype","hasOwnProperty","p","s","_paddingCharacter","encodedLength","length","encode","data","out","_encodeByte","left","maxDecodedLength","decodedLength","_getPaddingLength","decode","Uint8Array","paddingLength","op","haveBad","v0","v1","v2","v3","_decodeChar","charCodeAt","Error","b","result","String","fromCharCode","Coder","stdCoder","URLSafeCoder","urlSafeCoder","INVALID_UTF8","arr","pos","chars","min","n1","n2","n3","push","join","default","b64chars","b64tab","charAt","cb_utob","cc","utob","u","replace","cb_encode","ccc","padlen","ord","btoa","set","clear","delay","callback","timer","clearTimeout","clearInterval","super","setTimeout","setInterval","now","Date","valueOf","defer","args","boundArguments","Array","slice","arguments","apply","concat","extend","target","sources","extensions","constructor","stringify","safeJSONStringify","arrayIndexOf","array","item","nativeIndexOf","indexOf","objectApply","f","keys","_","context","map","filter","test","filterObject","Boolean","any","encodeParamsObject","encodeURIComponent","toString","buildQueryString","params","undefined","method","source","JSON","e","objects","paths","derez","path","nu","$ref","VERSION","PROTOCOL","wsPort","wssPort","wsPath","httpHost","httpPort","httpsPort","httpPath","stats_host","authEndpoint","authTransport","activityTimeout","pongTimeout","unavailableTimeout","userAuthentication","endpoint","transport","channelAuthorization","cdn_http","cdn_https","dependency_suffix","getGenericURL","baseScheme","useTLS","hostTLS","hostNonTLS","getGenericPath","queryString","ws","getInitial","http","_callbacks","prefix","prefixedEventName","fn","names","removeCallback","removeAllCallbacks","binding","failThrough","callbacks","global_callbacks","eventName","add","remove","unbind","unbind_global","metadata","globalLog","message","console","log","globalLogWarn","globalLogError","warn","error","defaultLoggingFunction","logToConsole","hooks","priority","options","initialize","transportConnectionInitializer","state","timeline","id","generateUniqueID","handlesActivityChecks","supportsPing","socket","url","urls","getSocket","onError","changeState","bindListeners","debug","close","send","ping","beforeOpen","getPath","onopen","emit","type","buildTimelineMessage","closeEvent","code","reason","wasClean","unbindListeners","onOpen","onerror","onclose","onClose","onmessage","onMessage","onactivity","onActivity","info","cid","environment","isSupported","WSTransport","isInitialized","getWebSocketAPI","createWebSocket","httpConfiguration","streamingConfiguration","HTTPFactory","createStreamingSocket","pollingConfiguration","createPollingSocket","xhrConfiguration","isXHRSupported","xhr_streaming","xhr_polling","manager","minPingDelay","maxPingDelay","pingDelay","connection","createConnection","openTimestamp","onClosed","reportDeath","lifespan","Math","max","isAlive","Protocol","decodeMessage","messageEvent","messageData","parse","pusherEventData","pusherEvent","event","channel","user_id","encodeMessage","processHandshake","activity_timeout","action","socket_id","getCloseAction","getCloseError","send_event","listeners","activity","closed","handleCloseEvent","listener","finish","isEmpty","TimelineTransport","getAgent","BadEventName","msg","setPrototypeOf","BadChannelName","TransportPriorityTooLow","TransportClosed","UnsupportedFeature","UnsupportedTransport","UnsupportedStrategy","HTTPAuthError","status","urlStore","baseUrl","authenticationEndpoint","authorizationEndpoint","javascriptQuickStart","triggeringClientEvents","encryptedChannelSupport","fullUrl","urlObj","pusher","subscribed","subscriptionPending","subscriptionCancelled","socketId","auth","suffix","handleSubscriptionSucceededEvent","handleSubscriptionCountEvent","unsubscribe","subscription_count","subscriptionCount","authorize","assign","channel_data","config","channelAuthorizer","channelName","reset","members","member","myID","subscriptionData","presence","hash","count","me","memberData","user_info","authData","channelData","setMyID","user","signinDonePromise","user_data","handleInternalEvent","addedMember","addMember","removedMember","removeMember","onSubscription","disconnect","nacl","sharedSecret","handleEncryptedEvent","handleEvent","ciphertext","nonce","cipherText","secretbox","overheadLength","nonceLength","bytes","open","getDataToEmit","raw","usingTLS","errorCallbacks","buildErrorCallbacks","connectionCallbacks","buildConnectionCallbacks","handshakeCallbacks","buildHandshakeCallbacks","Network","getNetwork","netinfo","retryIn","sendActivityCheck","updateStrategy","runner","strategy","updateState","startConnecting","setUnavailableTimer","disconnectInternally","handshake","connect","handshakeError","abortConnecting","abort","clearRetryTimer","clearUnavailableTimer","abandonConnection","getStrategy","round","retryTimer","ensureAborted","unavailableTimer","stopActivityCheck","activityTimer","pong_timed_out","resetActivityCheck","shouldRetry","connected","Infinity","setConnection","withErrorEmitted","tls_only","refused","backoff","retry","newState","previousState","newStateDescription","previous","current","channels","createEncryptedChannel","errMsg","createPrivateChannel","createPresenceChannel","createChannel","values","createChannels","createConnectionManager","createTimelineSender","createHandshake","createAssistantToTheTransportManager","livesLeft","lives","strategies","loop","failFast","timeout","timeoutLimit","minPriority","tryNextStrategy","tryStrategy","forceMinPriority","isRunning","callbackBuilder","runners","rs","abortRunner","allRunnersFailed","aborted","transports","ttl","storage","getLocalStorage","serializedCache","getTransportCacheKey","flushTransportCache","fetchTransportCache","cacheSkipCount","timestamp","includes","cached","latency","startTimestamp","pop","cb","storeTransportCache","number","IfStrategy","trueBranch","falseBranch","FirstConnectedStrategy","testSupportsStrategy","baseOptions","defineTransport","definedTransports","defineTransportStrategy","wsStrategy","ws_options","wsHost","wss_options","http_options","timeouts","ws_manager","streaming_manager","ws_transport","wss_transport","xhr_streaming_transport","xhr_polling_transport","ws_loop","wss_loop","streaming_loop","polling_loop","http_loop","payload","position","xhr","getRequest","unloader","addUnloadListener","setRequestHeader","removeUnloadListener","abortRequest","chunk","advanceBuffer","isBufferTooLong","buffer","unreadData","endOfLinePosition","State","autoIncrement","getUniqueURL","separator","randomNumber","randomInt","session","randomString","location","parts","exec","base","getLocation","readyState","CONNECTING","openStream","sendRaw","sendHeartbeat","OPEN","createSocketRequest","start","closeStream","CLOSED","onEvent","onHeartbeat","hostname","urlParts","stream","getReceiveURL","onChunk","onFinished","reconnect","unbind_all","getXHRAPI","onreadystatechange","onprogress","responseText","getDefaultStrategy","Transports","createSocket","createRequest","PusherClass","ready","getClientFeatures","getProtocol","createXHR","query","authOptions","authRequestType","headers","Headers","headerName","headersProvider","dynamicHeaders","body","request","Request","credentials","fetch","then","response","text","parsedData","catch","err","sender","host","json","setup","TimelineLevel","getAuthorizers","ajax","WebSocket","XMLHttpRequest","floor","globalThis","crypto","getRandomValues","Uint32Array","events","sent","uniqueID","level","limit","shift","ERROR","INFO","DEBUG","sendfn","bundle","lib","version","cluster","features","failAttempt","onInitialized","serializedTransport","AuthRequestType","transportClass","enabledTransports","disabledTransports","ignoreNullOrigin","getAssistant","deferred","paramsProvider","dynamicParams","composeChannelQuery","UserAuthentication","ChannelAuthorization","ChannelAuthorizerProxy","channelAuthorizerGenerator","deprecatedAuthorizerOptions","getConfig","opts","statsHost","enableStats","getEnableStatsConfig","getHttpHost","shouldUseTLS","getWebsocketHost","userAuthenticator","buildUserAuthenticator","buildChannelAuthorizer","timelineParams","forceTLS","disableStats","hasCustomHandler","customHandler","authorizer","buildChannelAuth","bindWatchlistInternalEvent","forEach","watchlistEvent","resolve","reject","promise","Promise","res","rej","signin_requested","serverToUserChannel","_signinDoneResolve","_onAuthorize","_cleanup","_signin","_newSigninPromiseIfNeeded","watchlist","_onSigninSuccess","_subscribeChannels","bind_global","reinstateSubscription","subscribe","ensure_subscribed","done","setDone","isReady","instances","app_key","checkAppKey","validateOptions","global_emitter","sessionID","timelineSender","subscribeAll","isUsingTLS","internal","appKey","switchCluster","find","all","timelineSenderTimer","event_name","channel_name","cancelSubscription","signin","Runtime","ScriptReceivers","DependenciesReceivers","auth_callbacks"],"mappings":";;;;;;;CAAA,SAA2CA,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of,KAChBtZ,EAAQwC,YACrBxC,EAAQgD,cAKd,WAAWqW,EAAoB/oB,EAAW0P,GACxC,OAAOlS,KAAKiR,WAAW0B,WAAW4Y,EAAY/oB,EAAM0P,GAGtD,eACE,OAAOlS,KAAKwV,OAAOzK,OAGrB,SACE/K,KAAKyW,KAAKiV,UAvOL,GAAAlB,UAAsB,GACtB,GAAAD,SAAmB,EACnB,GAAAtd,cAAwB,EAGxB,GAAA0e,QAA2B,GAC3B,GAAAC,gBAA6B,GAASA,gBACtC,GAAAC,sBAAmC,GAASA,sBAC5C,GAAAC,eAA4B,GAASA,eAVzB,oBAmPrB,GAAQ9G,MAAM","file":"pusher.worker.min.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"Pusher\"] = factory();\n\telse\n\t\troot[\"Pusher\"] = factory();\n})(this, function() {\nreturn "," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 2);\n","// Copyright (C) 2016 Dmitry Chestnykh\n// MIT License. See LICENSE file for details.\n\n/**\n * Package base64 implements Base64 encoding and decoding.\n */\n\n// Invalid character used in decoding to indicate\n// that the character to decode is out of range of\n// alphabet and cannot be decoded.\nconst INVALID_BYTE = 256;\n\n/**\n * Implements standard Base64 encoding.\n *\n * Operates in constant time.\n */\nexport class Coder {\n // TODO(dchest): methods to encode chunk-by-chunk.\n\n constructor(private _paddingCharacter = \"=\") { }\n\n encodedLength(length: number): number {\n if (!this._paddingCharacter) {\n return (length * 8 + 5) / 6 | 0;\n }\n return (length + 2) / 3 * 4 | 0;\n }\n\n encode(data: Uint8Array): string {\n let out = \"\";\n\n let i = 0;\n for (; i < data.length - 2; i += 3) {\n let c = (data[i] << 16) | (data[i + 1] << 8) | (data[i + 2]);\n out += this._encodeByte((c >>> 3 * 6) & 63);\n out += this._encodeByte((c >>> 2 * 6) & 63);\n out += this._encodeByte((c >>> 1 * 6) & 63);\n out += this._encodeByte((c >>> 0 * 6) & 63);\n }\n\n const left = data.length - i;\n if (left > 0) {\n let c = (data[i] << 16) | (left === 2 ? data[i + 1] << 8 : 0);\n out += this._encodeByte((c >>> 3 * 6) & 63);\n out += this._encodeByte((c >>> 2 * 6) & 63);\n if (left === 2) {\n out += this._encodeByte((c >>> 1 * 6) & 63);\n } else {\n out += this._paddingCharacter || \"\";\n }\n out += this._paddingCharacter || \"\";\n }\n\n return out;\n }\n\n maxDecodedLength(length: number): number {\n if (!this._paddingCharacter) {\n return (length * 6 + 7) / 8 | 0;\n }\n return length / 4 * 3 | 0;\n }\n\n decodedLength(s: string): number {\n return this.maxDecodedLength(s.length - this._getPaddingLength(s));\n }\n\n decode(s: string): Uint8Array {\n if (s.length === 0) {\n return new Uint8Array(0);\n }\n const paddingLength = this._getPaddingLength(s);\n const length = s.length - paddingLength;\n const out = new Uint8Array(this.maxDecodedLength(length));\n let op = 0;\n let i = 0;\n let haveBad = 0;\n let v0 = 0, v1 = 0, v2 = 0, v3 = 0;\n for (; i < length - 4; i += 4) {\n v0 = this._decodeChar(s.charCodeAt(i + 0));\n v1 = this._decodeChar(s.charCodeAt(i + 1));\n v2 = this._decodeChar(s.charCodeAt(i + 2));\n v3 = this._decodeChar(s.charCodeAt(i + 3));\n out[op++] = (v0 << 2) | (v1 >>> 4);\n out[op++] = (v1 << 4) | (v2 >>> 2);\n out[op++] = (v2 << 6) | v3;\n haveBad |= v0 & INVALID_BYTE;\n haveBad |= v1 & INVALID_BYTE;\n haveBad |= v2 & INVALID_BYTE;\n haveBad |= v3 & INVALID_BYTE;\n }\n if (i < length - 1) {\n v0 = this._decodeChar(s.charCodeAt(i));\n v1 = this._decodeChar(s.charCodeAt(i + 1));\n out[op++] = (v0 << 2) | (v1 >>> 4);\n haveBad |= v0 & INVALID_BYTE;\n haveBad |= v1 & INVALID_BYTE;\n }\n if (i < length - 2) {\n v2 = this._decodeChar(s.charCodeAt(i + 2));\n out[op++] = (v1 << 4) | (v2 >>> 2);\n haveBad |= v2 & INVALID_BYTE;\n }\n if (i < length - 3) {\n v3 = this._decodeChar(s.charCodeAt(i + 3));\n out[op++] = (v2 << 6) | v3;\n haveBad |= v3 & INVALID_BYTE;\n }\n if (haveBad !== 0) {\n throw new Error(\"Base64Coder: incorrect characters for decoding\");\n }\n return out;\n }\n\n // Standard encoding have the following encoded/decoded ranges,\n // which we need to convert between.\n //\n // ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 0123456789 + /\n // Index: 0 - 25 26 - 51 52 - 61 62 63\n // ASCII: 65 - 90 97 - 122 48 - 57 43 47\n //\n\n // Encode 6 bits in b into a new character.\n protected _encodeByte(b: number): string {\n // Encoding uses constant time operations as follows:\n //\n // 1. Define comparison of A with B using (A - B) >>> 8:\n // if A > B, then result is positive integer\n // if A <= B, then result is 0\n //\n // 2. Define selection of C or 0 using bitwise AND: X & C:\n // if X == 0, then result is 0\n // if X != 0, then result is C\n //\n // 3. Start with the smallest comparison (b >= 0), which is always\n // true, so set the result to the starting ASCII value (65).\n //\n // 4. Continue comparing b to higher ASCII values, and selecting\n // zero if comparison isn't true, otherwise selecting a value\n // to add to result, which:\n //\n // a) undoes the previous addition\n // b) provides new value to add\n //\n let result = b;\n // b >= 0\n result += 65;\n // b > 25\n result += ((25 - b) >>> 8) & ((0 - 65) - 26 + 97);\n // b > 51\n result += ((51 - b) >>> 8) & ((26 - 97) - 52 + 48);\n // b > 61\n result += ((61 - b) >>> 8) & ((52 - 48) - 62 + 43);\n // b > 62\n result += ((62 - b) >>> 8) & ((62 - 43) - 63 + 47);\n\n return String.fromCharCode(result);\n }\n\n // Decode a character code into a byte.\n // Must return 256 if character is out of alphabet range.\n protected _decodeChar(c: number): number {\n // Decoding works similar to encoding: using the same comparison\n // function, but now it works on ranges: result is always incremented\n // by value, but this value becomes zero if the range is not\n // satisfied.\n //\n // Decoding starts with invalid value, 256, which is then\n // subtracted when the range is satisfied. If none of the ranges\n // apply, the function returns 256, which is then checked by\n // the caller to throw error.\n let result = INVALID_BYTE; // start with invalid character\n\n // c == 43 (c > 42 and c < 44)\n result += (((42 - c) & (c - 44)) >>> 8) & (-INVALID_BYTE + c - 43 + 62);\n // c == 47 (c > 46 and c < 48)\n result += (((46 - c) & (c - 48)) >>> 8) & (-INVALID_BYTE + c - 47 + 63);\n // c > 47 and c < 58\n result += (((47 - c) & (c - 58)) >>> 8) & (-INVALID_BYTE + c - 48 + 52);\n // c > 64 and c < 91\n result += (((64 - c) & (c - 91)) >>> 8) & (-INVALID_BYTE + c - 65 + 0);\n // c > 96 and c < 123\n result += (((96 - c) & (c - 123)) >>> 8) & (-INVALID_BYTE + c - 97 + 26);\n\n return result;\n }\n\n private _getPaddingLength(s: string): number {\n let paddingLength = 0;\n if (this._paddingCharacter) {\n for (let i = s.length - 1; i >= 0; i--) {\n if (s[i] !== this._paddingCharacter) {\n break;\n }\n paddingLength++;\n }\n if (s.length < 4 || paddingLength > 2) {\n throw new Error(\"Base64Coder: incorrect padding\");\n }\n }\n return paddingLength;\n }\n\n}\n\nconst stdCoder = new Coder();\n\nexport function encode(data: Uint8Array): string {\n return stdCoder.encode(data);\n}\n\nexport function decode(s: string): Uint8Array {\n return stdCoder.decode(s);\n}\n\n/**\n * Implements URL-safe Base64 encoding.\n * (Same as Base64, but '+' is replaced with '-', and '/' with '_').\n *\n * Operates in constant time.\n */\nexport class URLSafeCoder extends Coder {\n // URL-safe encoding have the following encoded/decoded ranges:\n //\n // ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 0123456789 - _\n // Index: 0 - 25 26 - 51 52 - 61 62 63\n // ASCII: 65 - 90 97 - 122 48 - 57 45 95\n //\n\n protected _encodeByte(b: number): string {\n let result = b;\n // b >= 0\n result += 65;\n // b > 25\n result += ((25 - b) >>> 8) & ((0 - 65) - 26 + 97);\n // b > 51\n result += ((51 - b) >>> 8) & ((26 - 97) - 52 + 48);\n // b > 61\n result += ((61 - b) >>> 8) & ((52 - 48) - 62 + 45);\n // b > 62\n result += ((62 - b) >>> 8) & ((62 - 45) - 63 + 95);\n\n return String.fromCharCode(result);\n }\n\n protected _decodeChar(c: number): number {\n let result = INVALID_BYTE;\n\n // c == 45 (c > 44 and c < 46)\n result += (((44 - c) & (c - 46)) >>> 8) & (-INVALID_BYTE + c - 45 + 62);\n // c == 95 (c > 94 and c < 96)\n result += (((94 - c) & (c - 96)) >>> 8) & (-INVALID_BYTE + c - 95 + 63);\n // c > 47 and c < 58\n result += (((47 - c) & (c - 58)) >>> 8) & (-INVALID_BYTE + c - 48 + 52);\n // c > 64 and c < 91\n result += (((64 - c) & (c - 91)) >>> 8) & (-INVALID_BYTE + c - 65 + 0);\n // c > 96 and c < 123\n result += (((96 - c) & (c - 123)) >>> 8) & (-INVALID_BYTE + c - 97 + 26);\n\n return result;\n }\n}\n\nconst urlSafeCoder = new URLSafeCoder();\n\nexport function encodeURLSafe(data: Uint8Array): string {\n return urlSafeCoder.encode(data);\n}\n\nexport function decodeURLSafe(s: string): Uint8Array {\n return urlSafeCoder.decode(s);\n}\n\n\nexport const encodedLength = (length: number) =>\n stdCoder.encodedLength(length);\n\nexport const maxDecodedLength = (length: number) =>\n stdCoder.maxDecodedLength(length);\n\nexport const decodedLength = (s: string) =>\n stdCoder.decodedLength(s);\n","// Copyright (C) 2016 Dmitry Chestnykh\n// MIT License. See LICENSE file for details.\n\n/**\n * Package utf8 implements UTF-8 encoding and decoding.\n */\n\nconst INVALID_UTF16 = \"utf8: invalid string\";\nconst INVALID_UTF8 = \"utf8: invalid source encoding\";\n\n/**\n * Encodes the given string into UTF-8 byte array.\n * Throws if the source string has invalid UTF-16 encoding.\n */\nexport function encode(s: string): Uint8Array {\n // Calculate result length and allocate output array.\n // encodedLength() also validates string and throws errors,\n // so we don't need repeat validation here.\n const arr = new Uint8Array(encodedLength(s));\n\n let pos = 0;\n for (let i = 0; i < s.length; i++) {\n let c = s.charCodeAt(i);\n if (c < 0x80) {\n arr[pos++] = c;\n } else if (c < 0x800) {\n arr[pos++] = 0xc0 | c >> 6;\n arr[pos++] = 0x80 | c & 0x3f;\n } else if (c < 0xd800) {\n arr[pos++] = 0xe0 | c >> 12;\n arr[pos++] = 0x80 | (c >> 6) & 0x3f;\n arr[pos++] = 0x80 | c & 0x3f;\n } else {\n i++; // get one more character\n c = (c & 0x3ff) << 10;\n c |= s.charCodeAt(i) & 0x3ff;\n c += 0x10000;\n\n arr[pos++] = 0xf0 | c >> 18;\n arr[pos++] = 0x80 | (c >> 12) & 0x3f;\n arr[pos++] = 0x80 | (c >> 6) & 0x3f;\n arr[pos++] = 0x80 | c & 0x3f;\n }\n }\n return arr;\n}\n\n/**\n * Returns the number of bytes required to encode the given string into UTF-8.\n * Throws if the source string has invalid UTF-16 encoding.\n */\nexport function encodedLength(s: string): number {\n let result = 0;\n for (let i = 0; i < s.length; i++) {\n const c = s.charCodeAt(i);\n if (c < 0x80) {\n result += 1;\n } else if (c < 0x800) {\n result += 2;\n } else if (c < 0xd800) {\n result += 3;\n } else if (c <= 0xdfff) {\n if (i >= s.length - 1) {\n throw new Error(INVALID_UTF16);\n }\n i++; // \"eat\" next character\n result += 4;\n } else {\n throw new Error(INVALID_UTF16);\n }\n }\n return result;\n}\n\n/**\n * Decodes the given byte array from UTF-8 into a string.\n * Throws if encoding is invalid.\n */\nexport function decode(arr: Uint8Array): string {\n const chars: string[] = [];\n for (let i = 0; i < arr.length; i++) {\n let b = arr[i];\n\n if (b & 0x80) {\n let min;\n if (b < 0xe0) {\n // Need 1 more byte.\n if (i >= arr.length) {\n throw new Error(INVALID_UTF8);\n }\n const n1 = arr[++i];\n if ((n1 & 0xc0) !== 0x80) {\n throw new Error(INVALID_UTF8);\n }\n b = (b & 0x1f) << 6 | (n1 & 0x3f);\n min = 0x80;\n } else if (b < 0xf0) {\n // Need 2 more bytes.\n if (i >= arr.length - 1) {\n throw new Error(INVALID_UTF8);\n }\n const n1 = arr[++i];\n const n2 = arr[++i];\n if ((n1 & 0xc0) !== 0x80 || (n2 & 0xc0) !== 0x80) {\n throw new Error(INVALID_UTF8);\n }\n b = (b & 0x0f) << 12 | (n1 & 0x3f) << 6 | (n2 & 0x3f);\n min = 0x800;\n } else if (b < 0xf8) {\n // Need 3 more bytes.\n if (i >= arr.length - 2) {\n throw new Error(INVALID_UTF8);\n }\n const n1 = arr[++i];\n const n2 = arr[++i];\n const n3 = arr[++i];\n if ((n1 & 0xc0) !== 0x80 || (n2 & 0xc0) !== 0x80 || (n3 & 0xc0) !== 0x80) {\n throw new Error(INVALID_UTF8);\n }\n b = (b & 0x0f) << 18 | (n1 & 0x3f) << 12 | (n2 & 0x3f) << 6 | (n3 & 0x3f);\n min = 0x10000;\n } else {\n throw new Error(INVALID_UTF8);\n }\n\n if (b < min || (b >= 0xd800 && b <= 0xdfff)) {\n throw new Error(INVALID_UTF8);\n }\n\n if (b >= 0x10000) {\n // Surrogate pair.\n if (b > 0x10ffff) {\n throw new Error(INVALID_UTF8);\n }\n b -= 0x10000;\n chars.push(String.fromCharCode(0xd800 | (b >> 10)));\n b = 0xdc00 | (b & 0x3ff);\n }\n }\n\n chars.push(String.fromCharCode(b));\n }\n return chars.join(\"\");\n}\n","// required so we don't have to do require('pusher').default etc.\nmodule.exports = require('./pusher').default;\n","export default function encode(s: any): string {\n return btoa(utob(s));\n}\n\nvar fromCharCode = String.fromCharCode;\n\nvar b64chars =\n 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';\nvar b64tab = {};\n\nfor (var i = 0, l = b64chars.length; i < l; i++) {\n b64tab[b64chars.charAt(i)] = i;\n}\n\nvar cb_utob = function(c) {\n var cc = c.charCodeAt(0);\n return cc < 0x80\n ? c\n : cc < 0x800\n ? fromCharCode(0xc0 | (cc >>> 6)) + fromCharCode(0x80 | (cc & 0x3f))\n : fromCharCode(0xe0 | ((cc >>> 12) & 0x0f)) +\n fromCharCode(0x80 | ((cc >>> 6) & 0x3f)) +\n fromCharCode(0x80 | (cc & 0x3f));\n};\n\nvar utob = function(u) {\n return u.replace(/[^\\x00-\\x7F]/g, cb_utob);\n};\n\nvar cb_encode = function(ccc) {\n var padlen = [0, 2, 1][ccc.length % 3];\n var ord =\n (ccc.charCodeAt(0) << 16) |\n ((ccc.length > 1 ? ccc.charCodeAt(1) : 0) << 8) |\n (ccc.length > 2 ? ccc.charCodeAt(2) : 0);\n var chars = [\n b64chars.charAt(ord >>> 18),\n b64chars.charAt((ord >>> 12) & 63),\n padlen >= 2 ? '=' : b64chars.charAt((ord >>> 6) & 63),\n padlen >= 1 ? '=' : b64chars.charAt(ord & 63)\n ];\n return chars.join('');\n};\n\nvar btoa =\n global.btoa ||\n function(b) {\n return b.replace(/[\\s\\S]{1,3}/g, cb_encode);\n };\n","import TimedCallback from './timed_callback';\nimport { Delay, Scheduler, Canceller } from './scheduling';\n\nabstract class Timer {\n protected clear: Canceller;\n protected timer: number | void;\n\n constructor(\n set: Scheduler,\n clear: Canceller,\n delay: Delay,\n callback: TimedCallback\n ) {\n this.clear = clear;\n this.timer = set(() => {\n if (this.timer) {\n this.timer = callback(this.timer);\n }\n }, delay);\n }\n\n /** Returns whether the timer is still running.\n *\n * @return {Boolean}\n */\n isRunning(): boolean {\n return this.timer !== null;\n }\n\n /** Aborts a timer when it's running. */\n ensureAborted() {\n if (this.timer) {\n this.clear(this.timer);\n this.timer = null;\n }\n }\n}\n\nexport default Timer;\n","import Timer from './abstract_timer';\nimport TimedCallback from './timed_callback';\nimport { Delay } from './scheduling';\n\n// We need to bind clear functions this way to avoid exceptions on IE8\nfunction clearTimeout(timer) {\n global.clearTimeout(timer);\n}\nfunction clearInterval(timer) {\n global.clearInterval(timer);\n}\n\n/** Cross-browser compatible one-off timer abstraction.\n *\n * @param {Number} delay\n * @param {Function} callback\n */\nexport class OneOffTimer extends Timer {\n constructor(delay: Delay, callback: TimedCallback) {\n super(setTimeout, clearTimeout, delay, function(timer) {\n callback();\n return null;\n });\n }\n}\n\n/** Cross-browser compatible periodic timer abstraction.\n *\n * @param {Number} delay\n * @param {Function} callback\n */\nexport class PeriodicTimer extends Timer {\n constructor(delay: Delay, callback: TimedCallback) {\n super(setInterval, clearInterval, delay, function(timer) {\n callback();\n return timer;\n });\n }\n}\n","import * as Collections from './utils/collections';\nimport TimedCallback from './utils/timers/timed_callback';\nimport { OneOffTimer, PeriodicTimer } from './utils/timers';\n\nvar Util = {\n now(): number {\n if (Date.now) {\n return Date.now();\n } else {\n return new Date().valueOf();\n }\n },\n\n defer(callback: TimedCallback): OneOffTimer {\n return new OneOffTimer(0, callback);\n },\n\n /** Builds a function that will proxy a method call to its first argument.\n *\n * Allows partial application of arguments, so additional arguments are\n * prepended to the argument list.\n *\n * @param {String} name method name\n * @return {Function} proxy function\n */\n method(name: string, ...args: any[]): Function {\n var boundArguments = Array.prototype.slice.call(arguments, 1);\n return function(object) {\n return object[name].apply(object, boundArguments.concat(arguments));\n };\n }\n};\n\nexport default Util;\n","import base64encode from '../base64';\nimport Util from '../util';\n\n/** Merges multiple objects into the target argument.\n *\n * For properties that are plain Objects, performs a deep-merge. For the\n * rest it just copies the value of the property.\n *\n * To extend prototypes use it as following:\n * Pusher.Util.extend(Target.prototype, Base.prototype)\n *\n * You can also use it to merge objects without altering them:\n * Pusher.Util.extend({}, object1, object2)\n *\n * @param {Object} target\n * @return {Object} the target argument\n */\nexport function extend(target: any, ...sources: any[]): T {\n for (var i = 0; i < sources.length; i++) {\n var extensions = sources[i];\n for (var property in extensions) {\n if (\n extensions[property] &&\n extensions[property].constructor &&\n extensions[property].constructor === Object\n ) {\n target[property] = extend(target[property] || {}, extensions[property]);\n } else {\n target[property] = extensions[property];\n }\n }\n }\n return target;\n}\n\nexport function stringify(): string {\n var m = ['Pusher'];\n for (var i = 0; i < arguments.length; i++) {\n if (typeof arguments[i] === 'string') {\n m.push(arguments[i]);\n } else {\n m.push(safeJSONStringify(arguments[i]));\n }\n }\n return m.join(' : ');\n}\n\nexport function arrayIndexOf(array: any[], item: any): number {\n // MSIE doesn't have array.indexOf\n var nativeIndexOf = Array.prototype.indexOf;\n if (array === null) {\n return -1;\n }\n if (nativeIndexOf && array.indexOf === nativeIndexOf) {\n return array.indexOf(item);\n }\n for (var i = 0, l = array.length; i < l; i++) {\n if (array[i] === item) {\n return i;\n }\n }\n return -1;\n}\n\n/** Applies a function f to all properties of an object.\n *\n * Function f gets 3 arguments passed:\n * - element from the object\n * - key of the element\n * - reference to the object\n *\n * @param {Object} object\n * @param {Function} f\n */\nexport function objectApply(object: any, f: Function) {\n for (var key in object) {\n if (Object.prototype.hasOwnProperty.call(object, key)) {\n f(object[key], key, object);\n }\n }\n}\n\n/** Return a list of objects own proerty keys\n *\n * @param {Object} object\n * @returns {Array}\n */\nexport function keys(object: any): string[] {\n var keys = [];\n objectApply(object, function(_, key) {\n keys.push(key);\n });\n return keys;\n}\n\n/** Return a list of object's own property values\n *\n * @param {Object} object\n * @returns {Array}\n */\nexport function values(object: any): any[] {\n var values = [];\n objectApply(object, function(value) {\n values.push(value);\n });\n return values;\n}\n\n/** Applies a function f to all elements of an array.\n *\n * Function f gets 3 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function apply(array: any[], f: Function, context?: any) {\n for (var i = 0; i < array.length; i++) {\n f.call(context || global, array[i], i, array);\n }\n}\n\n/** Maps all elements of the array and returns the result.\n *\n * Function f gets 4 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n * - reference to the destination array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function map(array: any[], f: Function): any[] {\n var result = [];\n for (var i = 0; i < array.length; i++) {\n result.push(f(array[i], i, array, result));\n }\n return result;\n}\n\n/** Maps all elements of the object and returns the result.\n *\n * Function f gets 4 arguments passed:\n * - element from the object\n * - key of the element\n * - reference to the source object\n * - reference to the destination object\n *\n * @param {Object} object\n * @param {Function} f\n */\nexport function mapObject(object: any, f: Function): any {\n var result = {};\n objectApply(object, function(value, key) {\n result[key] = f(value);\n });\n return result;\n}\n\n/** Filters elements of the array using a test function.\n *\n * Function test gets 4 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n * - reference to the destination array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function filter(array: any[], test: Function): any[] {\n test =\n test ||\n function(value) {\n return !!value;\n };\n\n var result = [];\n for (var i = 0; i < array.length; i++) {\n if (test(array[i], i, array, result)) {\n result.push(array[i]);\n }\n }\n return result;\n}\n\n/** Filters properties of the object using a test function.\n *\n * Function test gets 4 arguments passed:\n * - element from the object\n * - key of the element\n * - reference to the source object\n * - reference to the destination object\n *\n * @param {Object} object\n * @param {Function} f\n */\nexport function filterObject(object: Object, test: Function) {\n var result = {};\n objectApply(object, function(value, key) {\n if ((test && test(value, key, object, result)) || Boolean(value)) {\n result[key] = value;\n }\n });\n return result;\n}\n\n/** Flattens an object into a two-dimensional array.\n *\n * @param {Object} object\n * @return {Array} resulting array of [key, value] pairs\n */\nexport function flatten(object: Object): any[] {\n var result = [];\n objectApply(object, function(value, key) {\n result.push([key, value]);\n });\n return result;\n}\n\n/** Checks whether any element of the array passes the test.\n *\n * Function test gets 3 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function any(array: any[], test: Function): boolean {\n for (var i = 0; i < array.length; i++) {\n if (test(array[i], i, array)) {\n return true;\n }\n }\n return false;\n}\n\n/** Checks whether all elements of the array pass the test.\n *\n * Function test gets 3 arguments passed:\n * - element from the array\n * - index of the element\n * - reference to the source array\n *\n * @param {Array} array\n * @param {Function} f\n */\nexport function all(array: any[], test: Function): boolean {\n for (var i = 0; i < array.length; i++) {\n if (!test(array[i], i, array)) {\n return false;\n }\n }\n return true;\n}\n\nexport function encodeParamsObject(data): string {\n return mapObject(data, function(value) {\n if (typeof value === 'object') {\n value = safeJSONStringify(value);\n }\n return encodeURIComponent(base64encode(value.toString()));\n });\n}\n\nexport function buildQueryString(data: any): string {\n var params = filterObject(data, function(value) {\n return value !== undefined;\n });\n\n var query = map(\n flatten(encodeParamsObject(params)),\n Util.method('join', '=')\n ).join('&');\n\n return query;\n}\n\n/**\n * See https://github.com/douglascrockford/JSON-js/blob/master/cycle.js\n *\n * Remove circular references from an object. Required for JSON.stringify in\n * React Native, which tends to blow up a lot.\n *\n * @param {any} object\n * @return {any} Decycled object\n */\nexport function decycleObject(object: any): any {\n var objects = [],\n paths = [];\n\n return (function derez(value, path) {\n var i, name, nu;\n\n switch (typeof value) {\n case 'object':\n if (!value) {\n return null;\n }\n for (i = 0; i < objects.length; i += 1) {\n if (objects[i] === value) {\n return { $ref: paths[i] };\n }\n }\n\n objects.push(value);\n paths.push(path);\n\n if (Object.prototype.toString.apply(value) === '[object Array]') {\n nu = [];\n for (i = 0; i < value.length; i += 1) {\n nu[i] = derez(value[i], path + '[' + i + ']');\n }\n } else {\n nu = {};\n for (name in value) {\n if (Object.prototype.hasOwnProperty.call(value, name)) {\n nu[name] = derez(\n value[name],\n path + '[' + JSON.stringify(name) + ']'\n );\n }\n }\n }\n return nu;\n case 'number':\n case 'string':\n case 'boolean':\n return value;\n }\n })(object, '$');\n}\n\n/**\n * Provides a cross-browser and cross-platform way to safely stringify objects\n * into JSON. This is particularly necessary for ReactNative, where circular JSON\n * structures throw an exception.\n *\n * @param {any} source The object to stringify\n * @return {string} The serialized output.\n */\nexport function safeJSONStringify(source: any): string {\n try {\n return JSON.stringify(source);\n } catch (e) {\n return JSON.stringify(decycleObject(source));\n }\n}\n","import {\n ChannelAuthorizationOptions,\n UserAuthenticationOptions\n} from './auth/options';\nimport { AuthTransport } from './config';\n\nexport interface DefaultConfig {\n VERSION: string;\n PROTOCOL: number;\n wsPort: number;\n wssPort: number;\n wsPath: string;\n httpHost: string;\n httpPort: number;\n httpsPort: number;\n httpPath: string;\n stats_host: string;\n authEndpoint: string;\n authTransport: AuthTransport;\n activityTimeout: number;\n pongTimeout: number;\n unavailableTimeout: number;\n userAuthentication: UserAuthenticationOptions;\n channelAuthorization: ChannelAuthorizationOptions;\n\n cdn_http?: string;\n cdn_https?: string;\n dependency_suffix?: string;\n}\n\nvar Defaults: DefaultConfig = {\n VERSION: VERSION,\n PROTOCOL: 7,\n\n wsPort: 80,\n wssPort: 443,\n wsPath: '',\n // DEPRECATED: SockJS fallback parameters\n httpHost: 'sockjs.pusher.com',\n httpPort: 80,\n httpsPort: 443,\n httpPath: '/pusher',\n // DEPRECATED: Stats\n stats_host: 'stats.pusher.com',\n // DEPRECATED: Other settings\n authEndpoint: '/pusher/auth',\n authTransport: 'ajax',\n activityTimeout: 120000,\n pongTimeout: 30000,\n unavailableTimeout: 10000,\n userAuthentication: {\n endpoint: '/pusher/user-auth',\n transport: 'ajax'\n },\n channelAuthorization: {\n endpoint: '/pusher/auth',\n transport: 'ajax'\n },\n\n // CDN configuration\n cdn_http: CDN_HTTP,\n cdn_https: CDN_HTTPS,\n dependency_suffix: DEPENDENCY_SUFFIX\n};\n\nexport default Defaults;\n","import Defaults from '../defaults';\nimport { default as URLScheme, URLSchemeParams } from './url_scheme';\n\nfunction getGenericURL(\n baseScheme: string,\n params: URLSchemeParams,\n path: string\n): string {\n var scheme = baseScheme + (params.useTLS ? 's' : '');\n var host = params.useTLS ? params.hostTLS : params.hostNonTLS;\n return scheme + '://' + host + path;\n}\n\nfunction getGenericPath(key: string, queryString?: string): string {\n var path = '/app/' + key;\n var query =\n '?protocol=' +\n Defaults.PROTOCOL +\n '&client=js' +\n '&version=' +\n Defaults.VERSION +\n (queryString ? '&' + queryString : '');\n return path + query;\n}\n\nexport var ws: URLScheme = {\n getInitial: function(key: string, params: URLSchemeParams): string {\n var path = (params.httpPath || '') + getGenericPath(key, 'flash=false');\n return getGenericURL('ws', params, path);\n }\n};\n\nexport var http: URLScheme = {\n getInitial: function(key: string, params: URLSchemeParams): string {\n var path = (params.httpPath || '/pusher') + getGenericPath(key);\n return getGenericURL('http', params, path);\n }\n};\n\nexport var sockjs: URLScheme = {\n getInitial: function(key: string, params: URLSchemeParams): string {\n return getGenericURL('http', params, params.httpPath || '/pusher');\n },\n getPath: function(key: string, params: URLSchemeParams): string {\n return getGenericPath(key);\n }\n};\n","import Callback from './callback';\nimport * as Collections from '../utils/collections';\nimport CallbackTable from './callback_table';\n\nexport default class CallbackRegistry {\n _callbacks: CallbackTable;\n\n constructor() {\n this._callbacks = {};\n }\n\n get(name: string): Callback[] {\n return this._callbacks[prefix(name)];\n }\n\n add(name: string, callback: Function, context: any) {\n var prefixedEventName = prefix(name);\n this._callbacks[prefixedEventName] =\n this._callbacks[prefixedEventName] || [];\n this._callbacks[prefixedEventName].push({\n fn: callback,\n context: context\n });\n }\n\n remove(name?: string, callback?: Function, context?: any) {\n if (!name && !callback && !context) {\n this._callbacks = {};\n return;\n }\n\n var names = name ? [prefix(name)] : Collections.keys(this._callbacks);\n\n if (callback || context) {\n this.removeCallback(names, callback, context);\n } else {\n this.removeAllCallbacks(names);\n }\n }\n\n private removeCallback(names: string[], callback: Function, context: any) {\n Collections.apply(\n names,\n function(name) {\n this._callbacks[name] = Collections.filter(\n this._callbacks[name] || [],\n function(binding) {\n return (\n (callback && callback !== binding.fn) ||\n (context && context !== binding.context)\n );\n }\n );\n if (this._callbacks[name].length === 0) {\n delete this._callbacks[name];\n }\n },\n this\n );\n }\n\n private removeAllCallbacks(names: string[]) {\n Collections.apply(\n names,\n function(name) {\n delete this._callbacks[name];\n },\n this\n );\n }\n}\n\nfunction prefix(name: string): string {\n return '_' + name;\n}\n","import * as Collections from '../utils/collections';\nimport Callback from './callback';\nimport Metadata from '../channels/metadata';\nimport CallbackRegistry from './callback_registry';\n\n/** Manages callback bindings and event emitting.\n *\n * @param Function failThrough called when no listeners are bound to an event\n */\nexport default class Dispatcher {\n callbacks: CallbackRegistry;\n global_callbacks: Function[];\n failThrough: Function;\n\n constructor(failThrough?: Function) {\n this.callbacks = new CallbackRegistry();\n this.global_callbacks = [];\n this.failThrough = failThrough;\n }\n\n bind(eventName: string, callback: Function, context?: any) {\n this.callbacks.add(eventName, callback, context);\n return this;\n }\n\n bind_global(callback: Function) {\n this.global_callbacks.push(callback);\n return this;\n }\n\n unbind(eventName?: string, callback?: Function, context?: any) {\n this.callbacks.remove(eventName, callback, context);\n return this;\n }\n\n unbind_global(callback?: Function) {\n if (!callback) {\n this.global_callbacks = [];\n return this;\n }\n\n this.global_callbacks = Collections.filter(\n this.global_callbacks || [],\n c => c !== callback\n );\n\n return this;\n }\n\n unbind_all() {\n this.unbind();\n this.unbind_global();\n return this;\n }\n\n emit(eventName: string, data?: any, metadata?: Metadata): Dispatcher {\n for (var i = 0; i < this.global_callbacks.length; i++) {\n this.global_callbacks[i](eventName, data);\n }\n\n var callbacks = this.callbacks.get(eventName);\n var args = [];\n\n if (metadata) {\n // if there's a metadata argument, we need to call the callback with both\n // data and metadata regardless of whether data is undefined\n args.push(data, metadata);\n } else if (data) {\n // metadata is undefined, so we only need to call the callback with data\n // if data exists\n args.push(data);\n }\n\n if (callbacks && callbacks.length > 0) {\n for (var i = 0; i < callbacks.length; i++) {\n callbacks[i].fn.apply(callbacks[i].context || global, args);\n }\n } else if (this.failThrough) {\n this.failThrough(eventName, data);\n }\n\n return this;\n }\n}\n","import { stringify } from './utils/collections';\nimport Pusher from './pusher';\n\nclass Logger {\n debug(...args: any[]) {\n this.log(this.globalLog, args);\n }\n\n warn(...args: any[]) {\n this.log(this.globalLogWarn, args);\n }\n\n error(...args: any[]) {\n this.log(this.globalLogError, args);\n }\n\n private globalLog = (message: string) => {\n if (global.console && global.console.log) {\n global.console.log(message);\n }\n };\n\n private globalLogWarn(message: string) {\n if (global.console && global.console.warn) {\n global.console.warn(message);\n } else {\n this.globalLog(message);\n }\n }\n\n private globalLogError(message: string) {\n if (global.console && global.console.error) {\n global.console.error(message);\n } else {\n this.globalLogWarn(message);\n }\n }\n\n private log(\n defaultLoggingFunction: (message: string) => void,\n ...args: any[]\n ) {\n var message = stringify.apply(this, arguments);\n if (Pusher.log) {\n Pusher.log(message);\n } else if (Pusher.logToConsole) {\n const log = defaultLoggingFunction.bind(this);\n log(message);\n }\n }\n}\n\nexport default new Logger();\n","import Util from '../util';\nimport * as Collections from '../utils/collections';\nimport { default as EventsDispatcher } from '../events/dispatcher';\nimport Logger from '../logger';\nimport TransportHooks from './transport_hooks';\nimport Socket from '../socket';\nimport Runtime from 'runtime';\nimport Timeline from '../timeline/timeline';\nimport TransportConnectionOptions from './transport_connection_options';\n\n/** Provides universal API for transport connections.\n *\n * Transport connection is a low-level object that wraps a connection method\n * and exposes a simple evented interface for the connection state and\n * messaging. It does not implement Pusher-specific WebSocket protocol.\n *\n * Additionally, it fetches resources needed for transport to work and exposes\n * an interface for querying transport features.\n *\n * States:\n * - new - initial state after constructing the object\n * - initializing - during initialization phase, usually fetching resources\n * - intialized - ready to establish a connection\n * - connection - when connection is being established\n * - open - when connection ready to be used\n * - closed - after connection was closed be either side\n *\n * Emits:\n * - error - after the connection raised an error\n *\n * Options:\n * - useTLS - whether connection should be over TLS\n * - hostTLS - host to connect to when connection is over TLS\n * - hostNonTLS - host to connect to when connection is over TLS\n *\n * @param {String} key application key\n * @param {Object} options\n */\nexport default class TransportConnection extends EventsDispatcher {\n hooks: TransportHooks;\n name: string;\n priority: number;\n key: string;\n options: TransportConnectionOptions;\n state: string;\n timeline: Timeline;\n activityTimeout: number;\n id: number;\n socket: Socket;\n beforeOpen: Function;\n initialize: Function;\n\n constructor(\n hooks: TransportHooks,\n name: string,\n priority: number,\n key: string,\n options: TransportConnectionOptions\n ) {\n super();\n this.initialize = Runtime.transportConnectionInitializer;\n this.hooks = hooks;\n this.name = name;\n this.priority = priority;\n this.key = key;\n this.options = options;\n\n this.state = 'new';\n this.timeline = options.timeline;\n this.activityTimeout = options.activityTimeout;\n this.id = this.timeline.generateUniqueID();\n }\n\n /** Checks whether the transport handles activity checks by itself.\n *\n * @return {Boolean}\n */\n handlesActivityChecks(): boolean {\n return Boolean(this.hooks.handlesActivityChecks);\n }\n\n /** Checks whether the transport supports the ping/pong API.\n *\n * @return {Boolean}\n */\n supportsPing(): boolean {\n return Boolean(this.hooks.supportsPing);\n }\n\n /** Tries to establish a connection.\n *\n * @returns {Boolean} false if transport is in invalid state\n */\n connect(): boolean {\n if (this.socket || this.state !== 'initialized') {\n return false;\n }\n\n var url = this.hooks.urls.getInitial(this.key, this.options);\n try {\n this.socket = this.hooks.getSocket(url, this.options);\n } catch (e) {\n Util.defer(() => {\n this.onError(e);\n this.changeState('closed');\n });\n return false;\n }\n\n this.bindListeners();\n\n Logger.debug('Connecting', { transport: this.name, url });\n this.changeState('connecting');\n return true;\n }\n\n /** Closes the connection.\n *\n * @return {Boolean} true if there was a connection to close\n */\n close(): boolean {\n if (this.socket) {\n this.socket.close();\n return true;\n } else {\n return false;\n }\n }\n\n /** Sends data over the open connection.\n *\n * @param {String} data\n * @return {Boolean} true only when in the \"open\" state\n */\n send(data: any): boolean {\n if (this.state === 'open') {\n // Workaround for MobileSafari bug (see https://gist.github.com/2052006)\n Util.defer(() => {\n if (this.socket) {\n this.socket.send(data);\n }\n });\n return true;\n } else {\n return false;\n }\n }\n\n /** Sends a ping if the connection is open and transport supports it. */\n ping() {\n if (this.state === 'open' && this.supportsPing()) {\n this.socket.ping();\n }\n }\n\n private onOpen() {\n if (this.hooks.beforeOpen) {\n this.hooks.beforeOpen(\n this.socket,\n this.hooks.urls.getPath(this.key, this.options)\n );\n }\n this.changeState('open');\n this.socket.onopen = undefined;\n }\n\n private onError(error) {\n this.emit('error', { type: 'WebSocketError', error: error });\n this.timeline.error(this.buildTimelineMessage({ error: error.toString() }));\n }\n\n private onClose(closeEvent?: any) {\n if (closeEvent) {\n this.changeState('closed', {\n code: closeEvent.code,\n reason: closeEvent.reason,\n wasClean: closeEvent.wasClean\n });\n } else {\n this.changeState('closed');\n }\n this.unbindListeners();\n this.socket = undefined;\n }\n\n private onMessage(message) {\n this.emit('message', message);\n }\n\n private onActivity() {\n this.emit('activity');\n }\n\n private bindListeners() {\n this.socket.onopen = () => {\n this.onOpen();\n };\n this.socket.onerror = error => {\n this.onError(error);\n };\n this.socket.onclose = closeEvent => {\n this.onClose(closeEvent);\n };\n this.socket.onmessage = message => {\n this.onMessage(message);\n };\n\n if (this.supportsPing()) {\n this.socket.onactivity = () => {\n this.onActivity();\n };\n }\n }\n\n private unbindListeners() {\n if (this.socket) {\n this.socket.onopen = undefined;\n this.socket.onerror = undefined;\n this.socket.onclose = undefined;\n this.socket.onmessage = undefined;\n if (this.supportsPing()) {\n this.socket.onactivity = undefined;\n }\n }\n }\n\n private changeState(state: string, params?: any) {\n this.state = state;\n this.timeline.info(\n this.buildTimelineMessage({\n state: state,\n params: params\n })\n );\n this.emit(state, params);\n }\n\n buildTimelineMessage(message): any {\n return Collections.extend({ cid: this.id }, message);\n }\n}\n","import Factory from '../utils/factory';\nimport TransportHooks from './transport_hooks';\nimport TransportConnection from './transport_connection';\nimport TransportConnectionOptions from './transport_connection_options';\n\n/** Provides interface for transport connection instantiation.\n *\n * Takes transport-specific hooks as the only argument, which allow checking\n * for transport support and creating its connections.\n *\n * Supported hooks: * - file - the name of the file to be fetched during initialization\n * - urls - URL scheme to be used by transport\n * - handlesActivityCheck - true when the transport handles activity checks\n * - supportsPing - true when the transport has a ping/activity API\n * - isSupported - tells whether the transport is supported in the environment\n * - getSocket - creates a WebSocket-compatible transport socket\n *\n * See transports.js for specific implementations.\n *\n * @param {Object} hooks object containing all needed transport hooks\n */\nexport default class Transport {\n hooks: TransportHooks;\n\n constructor(hooks: TransportHooks) {\n this.hooks = hooks;\n }\n\n /** Returns whether the transport is supported in the environment.\n *\n * @param {Object} envronment te environment details (encryption, settings)\n * @returns {Boolean} true when the transport is supported\n */\n isSupported(environment: any): boolean {\n return this.hooks.isSupported(environment);\n }\n\n /** Creates a transport connection.\n *\n * @param {String} name\n * @param {Number} priority\n * @param {String} key the application key\n * @param {Object} options\n * @returns {TransportConnection}\n */\n createConnection(\n name: string,\n priority: number,\n key: string,\n options: any\n ): TransportConnection {\n return new TransportConnection(this.hooks, name, priority, key, options);\n }\n}\n","import * as URLSchemes from 'core/transports/url_schemes';\nimport URLScheme from 'core/transports/url_scheme';\nimport Transport from 'core/transports/transport';\nimport Util from 'core/util';\nimport * as Collections from 'core/utils/collections';\nimport TransportHooks from 'core/transports/transport_hooks';\nimport TransportsTable from 'core/transports/transports_table';\nimport Runtime from 'runtime';\n\n/** WebSocket transport.\n *\n * Uses native WebSocket implementation, including MozWebSocket supported by\n * earlier Firefox versions.\n */\nvar WSTransport = new Transport({\n urls: URLSchemes.ws,\n handlesActivityChecks: false,\n supportsPing: false,\n\n isInitialized: function() {\n return Boolean(Runtime.getWebSocketAPI());\n },\n isSupported: function(): boolean {\n return Boolean(Runtime.getWebSocketAPI());\n },\n getSocket: function(url) {\n return Runtime.createWebSocket(url);\n }\n});\n\nvar httpConfiguration = {\n urls: URLSchemes.http,\n handlesActivityChecks: false,\n supportsPing: true,\n isInitialized: function() {\n return true;\n }\n};\n\nexport var streamingConfiguration = Collections.extend(\n {\n getSocket: function(url) {\n return Runtime.HTTPFactory.createStreamingSocket(url);\n }\n },\n httpConfiguration\n);\nexport var pollingConfiguration = Collections.extend(\n {\n getSocket: function(url) {\n return Runtime.HTTPFactory.createPollingSocket(url);\n }\n },\n httpConfiguration\n);\n\nvar xhrConfiguration = {\n isSupported: function(): boolean {\n return Runtime.isXHRSupported();\n }\n};\n\n/** HTTP streaming transport using CORS-enabled XMLHttpRequest. */\nvar XHRStreamingTransport = new Transport(\n (\n Collections.extend({}, streamingConfiguration, xhrConfiguration)\n )\n);\n\n/** HTTP long-polling transport using CORS-enabled XMLHttpRequest. */\nvar XHRPollingTransport = new Transport(\n Collections.extend({}, pollingConfiguration, xhrConfiguration)\n);\n\nvar Transports: TransportsTable = {\n ws: WSTransport,\n xhr_streaming: XHRStreamingTransport,\n xhr_polling: XHRPollingTransport\n};\n\nexport default Transports;\n","import Util from '../util';\nimport * as Collections from '../utils/collections';\nimport TransportManager from './transport_manager';\nimport TransportConnection from './transport_connection';\nimport Transport from './transport';\nimport PingDelayOptions from './ping_delay_options';\n\n/** Creates transport connections monitored by a transport manager.\n *\n * When a transport is closed, it might mean the environment does not support\n * it. It's possible that messages get stuck in an intermediate buffer or\n * proxies terminate inactive connections. To combat these problems,\n * assistants monitor the connection lifetime, report unclean exits and\n * adjust ping timeouts to keep the connection active. The decision to disable\n * a transport is the manager's responsibility.\n *\n * @param {TransportManager} manager\n * @param {TransportConnection} transport\n * @param {Object} options\n */\nexport default class AssistantToTheTransportManager {\n manager: TransportManager;\n transport: Transport;\n minPingDelay: number;\n maxPingDelay: number;\n pingDelay: number;\n\n constructor(\n manager: TransportManager,\n transport: Transport,\n options: PingDelayOptions\n ) {\n this.manager = manager;\n this.transport = transport;\n this.minPingDelay = options.minPingDelay;\n this.maxPingDelay = options.maxPingDelay;\n this.pingDelay = undefined;\n }\n\n /** Creates a transport connection.\n *\n * This function has the same API as Transport#createConnection.\n *\n * @param {String} name\n * @param {Number} priority\n * @param {String} key the application key\n * @param {Object} options\n * @returns {TransportConnection}\n */\n createConnection(\n name: string,\n priority: number,\n key: string,\n options: Object\n ): TransportConnection {\n options = Collections.extend({}, options, {\n activityTimeout: this.pingDelay\n });\n var connection = this.transport.createConnection(\n name,\n priority,\n key,\n options\n );\n\n var openTimestamp = null;\n\n var onOpen = function() {\n connection.unbind('open', onOpen);\n connection.bind('closed', onClosed);\n openTimestamp = Util.now();\n };\n var onClosed = closeEvent => {\n connection.unbind('closed', onClosed);\n\n if (closeEvent.code === 1002 || closeEvent.code === 1003) {\n // we don't want to use transports not obeying the protocol\n this.manager.reportDeath();\n } else if (!closeEvent.wasClean && openTimestamp) {\n // report deaths only for short-living transport\n var lifespan = Util.now() - openTimestamp;\n if (lifespan < 2 * this.maxPingDelay) {\n this.manager.reportDeath();\n this.pingDelay = Math.max(lifespan / 2, this.minPingDelay);\n }\n }\n };\n\n connection.bind('open', onOpen);\n return connection;\n }\n\n /** Returns whether the transport is supported in the environment.\n *\n * This function has the same API as Transport#isSupported. Might return false\n * when the manager decides to kill the transport.\n *\n * @param {Object} environment the environment details (encryption, settings)\n * @returns {Boolean} true when the transport is supported\n */\n isSupported(environment: string): boolean {\n return this.manager.isAlive() && this.transport.isSupported(environment);\n }\n}\n","import Action from './action';\nimport { PusherEvent } from './message-types';\n/**\n * Provides functions for handling Pusher protocol-specific messages.\n */\n\nconst Protocol = {\n /**\n * Decodes a message in a Pusher format.\n *\n * The MessageEvent we receive from the transport should contain a pusher event\n * (https://pusher.com/docs/pusher_protocol#events) serialized as JSON in the\n * data field\n *\n * The pusher event may contain a data field too, and it may also be\n * serialised as JSON\n *\n * Throws errors when messages are not parse'able.\n *\n * @param {MessageEvent} messageEvent\n * @return {PusherEvent}\n */\n decodeMessage: function(messageEvent: MessageEvent): PusherEvent {\n try {\n var messageData = JSON.parse(messageEvent.data);\n var pusherEventData = messageData.data;\n if (typeof pusherEventData === 'string') {\n try {\n pusherEventData = JSON.parse(messageData.data);\n } catch (e) {}\n }\n var pusherEvent: PusherEvent = {\n event: messageData.event,\n channel: messageData.channel,\n data: pusherEventData\n };\n if (messageData.user_id) {\n pusherEvent.user_id = messageData.user_id;\n }\n return pusherEvent;\n } catch (e) {\n throw { type: 'MessageParseError', error: e, data: messageEvent.data };\n }\n },\n\n /**\n * Encodes a message to be sent.\n *\n * @param {PusherEvent} event\n * @return {String}\n */\n encodeMessage: function(event: PusherEvent): string {\n return JSON.stringify(event);\n },\n\n /**\n * Processes a handshake message and returns appropriate actions.\n *\n * Returns an object with an 'action' and other action-specific properties.\n *\n * There are three outcomes when calling this function. First is a successful\n * connection attempt, when pusher:connection_established is received, which\n * results in a 'connected' action with an 'id' property. When passed a\n * pusher:error event, it returns a result with action appropriate to the\n * close code and an error. Otherwise, it raises an exception.\n *\n * @param {String} message\n * @result Object\n */\n processHandshake: function(messageEvent: MessageEvent): Action {\n var message = Protocol.decodeMessage(messageEvent);\n\n if (message.event === 'pusher:connection_established') {\n if (!message.data.activity_timeout) {\n throw 'No activity timeout specified in handshake';\n }\n return {\n action: 'connected',\n id: message.data.socket_id,\n activityTimeout: message.data.activity_timeout * 1000\n };\n } else if (message.event === 'pusher:error') {\n // From protocol 6 close codes are sent only once, so this only\n // happens when connection does not support close codes\n return {\n action: this.getCloseAction(message.data),\n error: this.getCloseError(message.data)\n };\n } else {\n throw 'Invalid handshake';\n }\n },\n\n /**\n * Dispatches the close event and returns an appropriate action name.\n *\n * See:\n * 1. https://developer.mozilla.org/en-US/docs/WebSockets/WebSockets_reference/CloseEvent\n * 2. http://pusher.com/docs/pusher_protocol\n *\n * @param {CloseEvent} closeEvent\n * @return {String} close action name\n */\n getCloseAction: function(closeEvent): string {\n if (closeEvent.code < 4000) {\n // ignore 1000 CLOSE_NORMAL, 1001 CLOSE_GOING_AWAY,\n // 1005 CLOSE_NO_STATUS, 1006 CLOSE_ABNORMAL\n // ignore 1007...3999\n // handle 1002 CLOSE_PROTOCOL_ERROR, 1003 CLOSE_UNSUPPORTED,\n // 1004 CLOSE_TOO_LARGE\n if (closeEvent.code >= 1002 && closeEvent.code <= 1004) {\n return 'backoff';\n } else {\n return null;\n }\n } else if (closeEvent.code === 4000) {\n return 'tls_only';\n } else if (closeEvent.code < 4100) {\n return 'refused';\n } else if (closeEvent.code < 4200) {\n return 'backoff';\n } else if (closeEvent.code < 4300) {\n return 'retry';\n } else {\n // unknown error\n return 'refused';\n }\n },\n\n /**\n * Returns an error or null basing on the close event.\n *\n * Null is returned when connection was closed cleanly. Otherwise, an object\n * with error details is returned.\n *\n * @param {CloseEvent} closeEvent\n * @return {Object} error object\n */\n getCloseError: function(closeEvent): any {\n if (closeEvent.code !== 1000 && closeEvent.code !== 1001) {\n return {\n type: 'PusherError',\n data: {\n code: closeEvent.code,\n message: closeEvent.reason || closeEvent.message\n }\n };\n } else {\n return null;\n }\n }\n};\n\nexport default Protocol;\n","import * as Collections from '../utils/collections';\nimport { default as EventsDispatcher } from '../events/dispatcher';\nimport Protocol from './protocol/protocol';\nimport { PusherEvent } from './protocol/message-types';\nimport Logger from '../logger';\nimport TransportConnection from '../transports/transport_connection';\nimport Socket from '../socket';\n/**\n * Provides Pusher protocol interface for transports.\n *\n * Emits following events:\n * - message - on received messages\n * - ping - on ping requests\n * - pong - on pong responses\n * - error - when the transport emits an error\n * - closed - after closing the transport\n *\n * It also emits more events when connection closes with a code.\n * See Protocol.getCloseAction to get more details.\n *\n * @param {Number} id\n * @param {AbstractTransport} transport\n */\nexport default class Connection extends EventsDispatcher implements Socket {\n id: string;\n transport: TransportConnection;\n activityTimeout: number;\n\n constructor(id: string, transport: TransportConnection) {\n super();\n this.id = id;\n this.transport = transport;\n this.activityTimeout = transport.activityTimeout;\n this.bindListeners();\n }\n\n /** Returns whether used transport handles activity checks by itself\n *\n * @returns {Boolean} true if activity checks are handled by the transport\n */\n handlesActivityChecks() {\n return this.transport.handlesActivityChecks();\n }\n\n /** Sends raw data.\n *\n * @param {String} data\n */\n send(data: any): boolean {\n return this.transport.send(data);\n }\n\n /** Sends an event.\n *\n * @param {String} name\n * @param {String} data\n * @param {String} [channel]\n * @returns {Boolean} whether message was sent or not\n */\n send_event(name: string, data: any, channel?: string): boolean {\n var event: PusherEvent = { event: name, data: data };\n if (channel) {\n event.channel = channel;\n }\n Logger.debug('Event sent', event);\n return this.send(Protocol.encodeMessage(event));\n }\n\n /** Sends a ping message to the server.\n *\n * Basing on the underlying transport, it might send either transport's\n * protocol-specific ping or pusher:ping event.\n */\n ping() {\n if (this.transport.supportsPing()) {\n this.transport.ping();\n } else {\n this.send_event('pusher:ping', {});\n }\n }\n\n /** Closes the connection. */\n close() {\n this.transport.close();\n }\n\n private bindListeners() {\n var listeners = {\n message: (messageEvent: MessageEvent) => {\n var pusherEvent;\n try {\n pusherEvent = Protocol.decodeMessage(messageEvent);\n } catch (e) {\n this.emit('error', {\n type: 'MessageParseError',\n error: e,\n data: messageEvent.data\n });\n }\n\n if (pusherEvent !== undefined) {\n Logger.debug('Event recd', pusherEvent);\n\n switch (pusherEvent.event) {\n case 'pusher:error':\n this.emit('error', {\n type: 'PusherError',\n data: pusherEvent.data\n });\n break;\n case 'pusher:ping':\n this.emit('ping');\n break;\n case 'pusher:pong':\n this.emit('pong');\n break;\n }\n this.emit('message', pusherEvent);\n }\n },\n activity: () => {\n this.emit('activity');\n },\n error: error => {\n this.emit('error', error);\n },\n closed: closeEvent => {\n unbindListeners();\n\n if (closeEvent && closeEvent.code) {\n this.handleCloseEvent(closeEvent);\n }\n\n this.transport = null;\n this.emit('closed');\n }\n };\n\n var unbindListeners = () => {\n Collections.objectApply(listeners, (listener, event) => {\n this.transport.unbind(event, listener);\n });\n };\n\n Collections.objectApply(listeners, (listener, event) => {\n this.transport.bind(event, listener);\n });\n }\n\n private handleCloseEvent(closeEvent: any) {\n var action = Protocol.getCloseAction(closeEvent);\n var error = Protocol.getCloseError(closeEvent);\n if (error) {\n this.emit('error', error);\n }\n if (action) {\n this.emit(action, { action: action, error: error });\n }\n }\n}\n","import Util from '../../util';\nimport * as Collections from '../../utils/collections';\nimport Protocol from '../protocol/protocol';\nimport Connection from '../connection';\nimport TransportConnection from '../../transports/transport_connection';\nimport HandshakePayload from './handshake_payload';\n\n/**\n * Handles Pusher protocol handshakes for transports.\n *\n * Calls back with a result object after handshake is completed. Results\n * always have two fields:\n * - action - string describing action to be taken after the handshake\n * - transport - the transport object passed to the constructor\n *\n * Different actions can set different additional properties on the result.\n * In the case of 'connected' action, there will be a 'connection' property\n * containing a Connection object for the transport. Other actions should\n * carry an 'error' property.\n *\n * @param {AbstractTransport} transport\n * @param {Function} callback\n */\nexport default class Handshake {\n transport: TransportConnection;\n callback: (HandshakePayload) => void;\n onMessage: Function;\n onClosed: Function;\n\n constructor(\n transport: TransportConnection,\n callback: (HandshakePayload) => void\n ) {\n this.transport = transport;\n this.callback = callback;\n this.bindListeners();\n }\n\n close() {\n this.unbindListeners();\n this.transport.close();\n }\n\n private bindListeners() {\n this.onMessage = m => {\n this.unbindListeners();\n\n var result;\n try {\n result = Protocol.processHandshake(m);\n } catch (e) {\n this.finish('error', { error: e });\n this.transport.close();\n return;\n }\n\n if (result.action === 'connected') {\n this.finish('connected', {\n connection: new Connection(result.id, this.transport),\n activityTimeout: result.activityTimeout\n });\n } else {\n this.finish(result.action, { error: result.error });\n this.transport.close();\n }\n };\n\n this.onClosed = closeEvent => {\n this.unbindListeners();\n\n var action = Protocol.getCloseAction(closeEvent) || 'backoff';\n var error = Protocol.getCloseError(closeEvent);\n this.finish(action, { error: error });\n };\n\n this.transport.bind('message', this.onMessage);\n this.transport.bind('closed', this.onClosed);\n }\n\n private unbindListeners() {\n this.transport.unbind('message', this.onMessage);\n this.transport.unbind('closed', this.onClosed);\n }\n\n private finish(action: string, params: any) {\n this.callback(\n Collections.extend({ transport: this.transport, action: action }, params)\n );\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport base64encode from '../base64';\nimport Timeline from './timeline';\nimport Runtime from 'runtime';\n\nexport interface TimelineSenderOptions {\n host?: string;\n port?: number;\n path?: string;\n}\n\nexport default class TimelineSender {\n timeline: Timeline;\n options: TimelineSenderOptions;\n host: string;\n\n constructor(timeline: Timeline, options: TimelineSenderOptions) {\n this.timeline = timeline;\n this.options = options || {};\n }\n\n send(useTLS: boolean, callback?: Function) {\n if (this.timeline.isEmpty()) {\n return;\n }\n\n this.timeline.send(\n Runtime.TimelineTransport.getAgent(this, useTLS),\n callback\n );\n }\n}\n","/** Error classes used throughout the library. */\n// https://github.com/Microsoft/TypeScript-wiki/blob/master/Breaking-Changes.md#extending-built-ins-like-error-array-and-map-may-no-longer-work\nexport class BadEventName extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\nexport class BadChannelName extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\nexport class RequestTimedOut extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class TransportPriorityTooLow extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class TransportClosed extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class UnsupportedFeature extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class UnsupportedTransport extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class UnsupportedStrategy extends Error {\n constructor(msg?: string) {\n super(msg);\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\nexport class HTTPAuthError extends Error {\n status: number;\n constructor(status: number, msg?: string) {\n super(msg);\n this.status = status;\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n","/**\n * A place to store help URLs for error messages etc\n */\n\nconst urlStore = {\n baseUrl: 'https://pusher.com',\n urls: {\n authenticationEndpoint: {\n path: '/docs/channels/server_api/authenticating_users'\n },\n authorizationEndpoint: {\n path: '/docs/channels/server_api/authorizing-users/'\n },\n javascriptQuickStart: {\n path: '/docs/javascript_quick_start'\n },\n triggeringClientEvents: {\n path: '/docs/client_api_guide/client_events#trigger-events'\n },\n encryptedChannelSupport: {\n fullUrl:\n 'https://github.com/pusher/pusher-js/tree/cc491015371a4bde5743d1c87a0fbac0feb53195#encrypted-channel-support'\n }\n }\n};\n\n/** Builds a consistent string with links to pusher documentation\n *\n * @param {string} key - relevant key in the url_store.urls object\n * @return {string} suffix string to append to log message\n */\nconst buildLogSuffix = function(key: string): string {\n const urlPrefix = 'See:';\n const urlObj = urlStore.urls[key];\n if (!urlObj) return '';\n\n let url;\n if (urlObj.fullUrl) {\n url = urlObj.fullUrl;\n } else if (urlObj.path) {\n url = urlStore.baseUrl + urlObj.path;\n }\n\n if (!url) return '';\n return `${urlPrefix} ${url}`;\n};\n\nexport default { buildLogSuffix };\n","import { default as EventsDispatcher } from '../events/dispatcher';\nimport * as Errors from '../errors';\nimport Logger from '../logger';\nimport Pusher from '../pusher';\nimport { PusherEvent } from '../connection/protocol/message-types';\nimport Metadata from './metadata';\nimport UrlStore from '../utils/url_store';\nimport {\n ChannelAuthorizationData,\n ChannelAuthorizationCallback\n} from '../auth/options';\nimport { HTTPAuthError } from '../errors';\n\n/** Provides base public channel interface with an event emitter.\n *\n * Emits:\n * - pusher:subscription_succeeded - after subscribing successfully\n * - other non-internal events\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\nexport default class Channel extends EventsDispatcher {\n name: string;\n pusher: Pusher;\n subscribed: boolean;\n subscriptionPending: boolean;\n subscriptionCancelled: boolean;\n subscriptionCount: null;\n\n constructor(name: string, pusher: Pusher) {\n super(function(event, data) {\n Logger.debug('No callbacks on ' + name + ' for ' + event);\n });\n\n this.name = name;\n this.pusher = pusher;\n this.subscribed = false;\n this.subscriptionPending = false;\n this.subscriptionCancelled = false;\n }\n\n /** Skips authorization, since public channels don't require it.\n *\n * @param {Function} callback\n */\n authorize(socketId: string, callback: ChannelAuthorizationCallback) {\n return callback(null, { auth: '' });\n }\n\n /** Triggers an event */\n trigger(event: string, data: any) {\n if (event.indexOf('client-') !== 0) {\n throw new Errors.BadEventName(\n \"Event '\" + event + \"' does not start with 'client-'\"\n );\n }\n if (!this.subscribed) {\n var suffix = UrlStore.buildLogSuffix('triggeringClientEvents');\n Logger.warn(\n `Client event triggered before channel 'subscription_succeeded' event . ${suffix}`\n );\n }\n return this.pusher.send_event(event, data, this.name);\n }\n\n /** Signals disconnection to the channel. For internal use only. */\n disconnect() {\n this.subscribed = false;\n this.subscriptionPending = false;\n }\n\n /** Handles a PusherEvent. For internal use only.\n *\n * @param {PusherEvent} event\n */\n handleEvent(event: PusherEvent) {\n var eventName = event.event;\n var data = event.data;\n if (eventName === 'pusher_internal:subscription_succeeded') {\n this.handleSubscriptionSucceededEvent(event);\n } else if (eventName === 'pusher_internal:subscription_count') {\n this.handleSubscriptionCountEvent(event);\n } else if (eventName.indexOf('pusher_internal:') !== 0) {\n var metadata: Metadata = {};\n this.emit(eventName, data, metadata);\n }\n }\n\n handleSubscriptionSucceededEvent(event: PusherEvent) {\n this.subscriptionPending = false;\n this.subscribed = true;\n if (this.subscriptionCancelled) {\n this.pusher.unsubscribe(this.name);\n } else {\n this.emit('pusher:subscription_succeeded', event.data);\n }\n }\n\n handleSubscriptionCountEvent(event: PusherEvent) {\n if (event.data.subscription_count) {\n this.subscriptionCount = event.data.subscription_count;\n }\n\n this.emit('pusher:subscription_count', event.data);\n }\n\n /** Sends a subscription request. For internal use only. */\n subscribe() {\n if (this.subscribed) {\n return;\n }\n this.subscriptionPending = true;\n this.subscriptionCancelled = false;\n this.authorize(\n this.pusher.connection.socket_id,\n (error: Error | null, data: ChannelAuthorizationData) => {\n if (error) {\n this.subscriptionPending = false;\n // Why not bind to 'pusher:subscription_error' a level up, and log there?\n // Binding to this event would cause the warning about no callbacks being\n // bound (see constructor) to be suppressed, that's not what we want.\n Logger.error(error.toString());\n this.emit(\n 'pusher:subscription_error',\n Object.assign(\n {},\n {\n type: 'AuthError',\n error: error.message\n },\n error instanceof HTTPAuthError ? { status: error.status } : {}\n )\n );\n } else {\n this.pusher.send_event('pusher:subscribe', {\n auth: data.auth,\n channel_data: data.channel_data,\n channel: this.name\n });\n }\n }\n );\n }\n\n /** Sends an unsubscription request. For internal use only. */\n unsubscribe() {\n this.subscribed = false;\n this.pusher.send_event('pusher:unsubscribe', {\n channel: this.name\n });\n }\n\n /** Cancels an in progress subscription. For internal use only. */\n cancelSubscription() {\n this.subscriptionCancelled = true;\n }\n\n /** Reinstates an in progress subscripiton. For internal use only. */\n reinstateSubscription() {\n this.subscriptionCancelled = false;\n }\n}\n","import Factory from '../utils/factory';\nimport Channel from './channel';\nimport { ChannelAuthorizationCallback } from '../auth/options';\n\n/** Extends public channels to provide private channel interface.\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\nexport default class PrivateChannel extends Channel {\n /** Authorizes the connection to use the channel.\n *\n * @param {String} socketId\n * @param {Function} callback\n */\n authorize(socketId: string, callback: ChannelAuthorizationCallback) {\n return this.pusher.config.channelAuthorizer(\n {\n channelName: this.name,\n socketId: socketId\n },\n callback\n );\n }\n}\n","import * as Collections from '../utils/collections';\n\n/** Represents a collection of members of a presence channel. */\nexport default class Members {\n members: any;\n count: number;\n myID: any;\n me: any;\n\n constructor() {\n this.reset();\n }\n\n /** Returns member's info for given id.\n *\n * Resulting object containts two fields - id and info.\n *\n * @param {Number} id\n * @return {Object} member's info or null\n */\n get(id: string): any {\n if (Object.prototype.hasOwnProperty.call(this.members, id)) {\n return {\n id: id,\n info: this.members[id]\n };\n } else {\n return null;\n }\n }\n\n /** Calls back for each member in unspecified order.\n *\n * @param {Function} callback\n */\n each(callback: Function) {\n Collections.objectApply(this.members, (member, id) => {\n callback(this.get(id));\n });\n }\n\n /** Updates the id for connected member. For internal use only. */\n setMyID(id: string) {\n this.myID = id;\n }\n\n /** Handles subscription data. For internal use only. */\n onSubscription(subscriptionData: any) {\n this.members = subscriptionData.presence.hash;\n this.count = subscriptionData.presence.count;\n this.me = this.get(this.myID);\n }\n\n /** Adds a new member to the collection. For internal use only. */\n addMember(memberData: any) {\n if (this.get(memberData.user_id) === null) {\n this.count++;\n }\n this.members[memberData.user_id] = memberData.user_info;\n return this.get(memberData.user_id);\n }\n\n /** Adds a member from the collection. For internal use only. */\n removeMember(memberData: any) {\n var member = this.get(memberData.user_id);\n if (member) {\n delete this.members[memberData.user_id];\n this.count--;\n }\n return member;\n }\n\n /** Resets the collection to the initial state. For internal use only. */\n reset() {\n this.members = {};\n this.count = 0;\n this.myID = null;\n this.me = null;\n }\n}\n","import PrivateChannel from './private_channel';\nimport Logger from '../logger';\nimport Members from './members';\nimport Pusher from '../pusher';\nimport UrlStore from 'core/utils/url_store';\nimport { PusherEvent } from '../connection/protocol/message-types';\nimport Metadata from './metadata';\nimport { ChannelAuthorizationData } from '../auth/options';\n\nexport default class PresenceChannel extends PrivateChannel {\n members: Members;\n\n /** Adds presence channel functionality to private channels.\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\n constructor(name: string, pusher: Pusher) {\n super(name, pusher);\n this.members = new Members();\n }\n\n /** Authorizes the connection as a member of the channel.\n *\n * @param {String} socketId\n * @param {Function} callback\n */\n authorize(socketId: string, callback: Function) {\n super.authorize(socketId, async (error, authData) => {\n if (!error) {\n authData = authData as ChannelAuthorizationData;\n if (authData.channel_data != null) {\n var channelData = JSON.parse(authData.channel_data);\n this.members.setMyID(channelData.user_id);\n } else {\n await this.pusher.user.signinDonePromise;\n if (this.pusher.user.user_data != null) {\n // If the user is signed in, get the id of the authenticated user\n // and allow the presence authorization to continue.\n this.members.setMyID(this.pusher.user.user_data.id);\n } else {\n let suffix = UrlStore.buildLogSuffix('authorizationEndpoint');\n Logger.error(\n `Invalid auth response for channel '${this.name}', ` +\n `expected 'channel_data' field. ${suffix}, ` +\n `or the user should be signed in.`\n );\n callback('Invalid auth response');\n return;\n }\n }\n }\n callback(error, authData);\n });\n }\n\n /** Handles presence and subscription events. For internal use only.\n *\n * @param {PusherEvent} event\n */\n handleEvent(event: PusherEvent) {\n var eventName = event.event;\n if (eventName.indexOf('pusher_internal:') === 0) {\n this.handleInternalEvent(event);\n } else {\n var data = event.data;\n var metadata: Metadata = {};\n if (event.user_id) {\n metadata.user_id = event.user_id;\n }\n this.emit(eventName, data, metadata);\n }\n }\n handleInternalEvent(event: PusherEvent) {\n var eventName = event.event;\n var data = event.data;\n switch (eventName) {\n case 'pusher_internal:subscription_succeeded':\n this.handleSubscriptionSucceededEvent(event);\n break;\n case 'pusher_internal:subscription_count':\n this.handleSubscriptionCountEvent(event);\n break;\n case 'pusher_internal:member_added':\n var addedMember = this.members.addMember(data);\n this.emit('pusher:member_added', addedMember);\n break;\n case 'pusher_internal:member_removed':\n var removedMember = this.members.removeMember(data);\n if (removedMember) {\n this.emit('pusher:member_removed', removedMember);\n }\n break;\n }\n }\n\n handleSubscriptionSucceededEvent(event: PusherEvent) {\n this.subscriptionPending = false;\n this.subscribed = true;\n if (this.subscriptionCancelled) {\n this.pusher.unsubscribe(this.name);\n } else {\n this.members.onSubscription(event.data);\n this.emit('pusher:subscription_succeeded', this.members);\n }\n }\n\n /** Resets the channel state, including members map. For internal use only. */\n disconnect() {\n this.members.reset();\n super.disconnect();\n }\n}\n","import PrivateChannel from './private_channel';\nimport * as Errors from '../errors';\nimport Logger from '../logger';\nimport Pusher from '../pusher';\nimport { decode as encodeUTF8 } from '@stablelib/utf8';\nimport { decode as decodeBase64 } from '@stablelib/base64';\nimport Dispatcher from '../events/dispatcher';\nimport { PusherEvent } from '../connection/protocol/message-types';\nimport {\n ChannelAuthorizationData,\n ChannelAuthorizationCallback\n} from '../auth/options';\nimport * as nacl from 'tweetnacl';\n\n/** Extends private channels to provide encrypted channel interface.\n *\n * @param {String} name\n * @param {Pusher} pusher\n */\nexport default class EncryptedChannel extends PrivateChannel {\n key: Uint8Array = null;\n nacl: nacl;\n\n constructor(name: string, pusher: Pusher, nacl: nacl) {\n super(name, pusher);\n this.nacl = nacl;\n }\n\n /** Authorizes the connection to use the channel.\n *\n * @param {String} socketId\n * @param {Function} callback\n */\n authorize(socketId: string, callback: ChannelAuthorizationCallback) {\n super.authorize(\n socketId,\n (error: Error | null, authData: ChannelAuthorizationData) => {\n if (error) {\n callback(error, authData);\n return;\n }\n let sharedSecret = authData['shared_secret'];\n if (!sharedSecret) {\n callback(\n new Error(\n `No shared_secret key in auth payload for encrypted channel: ${this.name}`\n ),\n null\n );\n return;\n }\n this.key = decodeBase64(sharedSecret);\n delete authData['shared_secret'];\n callback(null, authData);\n }\n );\n }\n\n trigger(event: string, data: any): boolean {\n throw new Errors.UnsupportedFeature(\n 'Client events are not currently supported for encrypted channels'\n );\n }\n\n /** Handles an event. For internal use only.\n *\n * @param {PusherEvent} event\n */\n handleEvent(event: PusherEvent) {\n var eventName = event.event;\n var data = event.data;\n if (\n eventName.indexOf('pusher_internal:') === 0 ||\n eventName.indexOf('pusher:') === 0\n ) {\n super.handleEvent(event);\n return;\n }\n this.handleEncryptedEvent(eventName, data);\n }\n\n private handleEncryptedEvent(event: string, data: any): void {\n if (!this.key) {\n Logger.debug(\n 'Received encrypted event before key has been retrieved from the authEndpoint'\n );\n return;\n }\n if (!data.ciphertext || !data.nonce) {\n Logger.error(\n 'Unexpected format for encrypted event, expected object with `ciphertext` and `nonce` fields, got: ' +\n data\n );\n return;\n }\n let cipherText = decodeBase64(data.ciphertext);\n if (cipherText.length < this.nacl.secretbox.overheadLength) {\n Logger.error(\n `Expected encrypted event ciphertext length to be ${this.nacl.secretbox.overheadLength}, got: ${cipherText.length}`\n );\n return;\n }\n let nonce = decodeBase64(data.nonce);\n if (nonce.length < this.nacl.secretbox.nonceLength) {\n Logger.error(\n `Expected encrypted event nonce length to be ${this.nacl.secretbox.nonceLength}, got: ${nonce.length}`\n );\n return;\n }\n\n let bytes = this.nacl.secretbox.open(cipherText, nonce, this.key);\n if (bytes === null) {\n Logger.debug(\n 'Failed to decrypt an event, probably because it was encrypted with a different key. Fetching a new key from the authEndpoint...'\n );\n // Try a single time to retrieve a new auth key and decrypt the event with it\n // If this fails, a new key will be requested when a new message is received\n this.authorize(this.pusher.connection.socket_id, (error, authData) => {\n if (error) {\n Logger.error(\n `Failed to make a request to the authEndpoint: ${authData}. Unable to fetch new key, so dropping encrypted event`\n );\n return;\n }\n bytes = this.nacl.secretbox.open(cipherText, nonce, this.key);\n if (bytes === null) {\n Logger.error(\n `Failed to decrypt event with new key. Dropping encrypted event`\n );\n return;\n }\n this.emit(event, this.getDataToEmit(bytes));\n return;\n });\n return;\n }\n this.emit(event, this.getDataToEmit(bytes));\n }\n\n // Try and parse the decrypted bytes as JSON. If we can't parse it, just\n // return the utf-8 string\n getDataToEmit(bytes: Uint8Array): string {\n let raw = encodeUTF8(bytes);\n try {\n return JSON.parse(raw);\n } catch {\n return raw;\n }\n }\n}\n","import { default as EventsDispatcher } from '../events/dispatcher';\nimport { OneOffTimer as Timer } from '../utils/timers';\nimport { Config } from '../config';\nimport Logger from '../logger';\nimport HandshakePayload from './handshake/handshake_payload';\nimport Connection from './connection';\nimport Strategy from '../strategies/strategy';\nimport StrategyRunner from '../strategies/strategy_runner';\nimport * as Collections from '../utils/collections';\nimport Timeline from '../timeline/timeline';\nimport ConnectionManagerOptions from './connection_manager_options';\nimport Runtime from 'runtime';\n\nimport {\n ErrorCallbacks,\n HandshakeCallbacks,\n ConnectionCallbacks\n} from './callbacks';\nimport Action from './protocol/action';\n\n/** Manages connection to Pusher.\n *\n * Uses a strategy (currently only default), timers and network availability\n * info to establish a connection and export its state. In case of failures,\n * manages reconnection attempts.\n *\n * Exports state changes as following events:\n * - \"state_change\", { previous: p, current: state }\n * - state\n *\n * States:\n * - initialized - initial state, never transitioned to\n * - connecting - connection is being established\n * - connected - connection has been fully established\n * - disconnected - on requested disconnection\n * - unavailable - after connection timeout or when there's no network\n * - failed - when the connection strategy is not supported\n *\n * Options:\n * - unavailableTimeout - time to transition to unavailable state\n * - activityTimeout - time after which ping message should be sent\n * - pongTimeout - time for Pusher to respond with pong before reconnecting\n *\n * @param {String} key application key\n * @param {Object} options\n */\nexport default class ConnectionManager extends EventsDispatcher {\n key: string;\n options: ConnectionManagerOptions;\n state: string;\n connection: Connection;\n usingTLS: boolean;\n timeline: Timeline;\n socket_id: string;\n unavailableTimer: Timer;\n activityTimer: Timer;\n retryTimer: Timer;\n activityTimeout: number;\n strategy: Strategy;\n runner: StrategyRunner;\n errorCallbacks: ErrorCallbacks;\n handshakeCallbacks: HandshakeCallbacks;\n connectionCallbacks: ConnectionCallbacks;\n\n constructor(key: string, options: ConnectionManagerOptions) {\n super();\n this.state = 'initialized';\n this.connection = null;\n\n this.key = key;\n this.options = options;\n this.timeline = this.options.timeline;\n this.usingTLS = this.options.useTLS;\n\n this.errorCallbacks = this.buildErrorCallbacks();\n this.connectionCallbacks = this.buildConnectionCallbacks(\n this.errorCallbacks\n );\n this.handshakeCallbacks = this.buildHandshakeCallbacks(this.errorCallbacks);\n\n var Network = Runtime.getNetwork();\n\n Network.bind('online', () => {\n this.timeline.info({ netinfo: 'online' });\n if (this.state === 'connecting' || this.state === 'unavailable') {\n this.retryIn(0);\n }\n });\n Network.bind('offline', () => {\n this.timeline.info({ netinfo: 'offline' });\n if (this.connection) {\n this.sendActivityCheck();\n }\n });\n\n this.updateStrategy();\n }\n\n switchCluster(key: string) {\n this.key = key;\n // This ensures that the new config coming from\n // pusher instance are taken into account\n // such as appKey and cluster\n this.updateStrategy();\n this.retryIn(0);\n }\n\n /** Establishes a connection to Pusher.\n *\n * Does nothing when connection is already established. See top-level doc\n * to find events emitted on connection attempts.\n */\n connect() {\n if (this.connection || this.runner) {\n return;\n }\n if (!this.strategy.isSupported()) {\n this.updateState('failed');\n return;\n }\n this.updateState('connecting');\n this.startConnecting();\n this.setUnavailableTimer();\n }\n\n /** Sends raw data.\n *\n * @param {String} data\n */\n send(data) {\n if (this.connection) {\n return this.connection.send(data);\n } else {\n return false;\n }\n }\n\n /** Sends an event.\n *\n * @param {String} name\n * @param {String} data\n * @param {String} [channel]\n * @returns {Boolean} whether message was sent or not\n */\n send_event(name: string, data: any, channel?: string) {\n if (this.connection) {\n return this.connection.send_event(name, data, channel);\n } else {\n return false;\n }\n }\n\n /** Closes the connection. */\n disconnect() {\n this.disconnectInternally();\n this.updateState('disconnected');\n }\n\n isUsingTLS() {\n return this.usingTLS;\n }\n\n private startConnecting() {\n var callback = (error, handshake) => {\n if (error) {\n this.runner = this.strategy.connect(0, callback);\n } else {\n if (handshake.action === 'error') {\n this.emit('error', {\n type: 'HandshakeError',\n error: handshake.error\n });\n this.timeline.error({ handshakeError: handshake.error });\n } else {\n this.abortConnecting(); // we don't support switching connections yet\n this.handshakeCallbacks[handshake.action](handshake);\n }\n }\n };\n this.runner = this.strategy.connect(0, callback);\n }\n\n private abortConnecting() {\n if (this.runner) {\n this.runner.abort();\n this.runner = null;\n }\n }\n\n private disconnectInternally() {\n this.abortConnecting();\n this.clearRetryTimer();\n this.clearUnavailableTimer();\n if (this.connection) {\n var connection = this.abandonConnection();\n connection.close();\n }\n }\n\n private updateStrategy() {\n this.strategy = this.options.getStrategy({\n key: this.key,\n timeline: this.timeline,\n useTLS: this.usingTLS\n });\n }\n\n private retryIn(delay) {\n this.timeline.info({ action: 'retry', delay: delay });\n if (delay > 0) {\n this.emit('connecting_in', Math.round(delay / 1000));\n }\n this.retryTimer = new Timer(delay || 0, () => {\n this.disconnectInternally();\n this.connect();\n });\n }\n\n private clearRetryTimer() {\n if (this.retryTimer) {\n this.retryTimer.ensureAborted();\n this.retryTimer = null;\n }\n }\n\n private setUnavailableTimer() {\n this.unavailableTimer = new Timer(this.options.unavailableTimeout, () => {\n this.updateState('unavailable');\n });\n }\n\n private clearUnavailableTimer() {\n if (this.unavailableTimer) {\n this.unavailableTimer.ensureAborted();\n }\n }\n\n private sendActivityCheck() {\n this.stopActivityCheck();\n this.connection.ping();\n // wait for pong response\n this.activityTimer = new Timer(this.options.pongTimeout, () => {\n this.timeline.error({ pong_timed_out: this.options.pongTimeout });\n this.retryIn(0);\n });\n }\n\n private resetActivityCheck() {\n this.stopActivityCheck();\n // send ping after inactivity\n if (this.connection && !this.connection.handlesActivityChecks()) {\n this.activityTimer = new Timer(this.activityTimeout, () => {\n this.sendActivityCheck();\n });\n }\n }\n\n private stopActivityCheck() {\n if (this.activityTimer) {\n this.activityTimer.ensureAborted();\n }\n }\n\n private buildConnectionCallbacks(\n errorCallbacks: ErrorCallbacks\n ): ConnectionCallbacks {\n return Collections.extend({}, errorCallbacks, {\n message: message => {\n // includes pong messages from server\n this.resetActivityCheck();\n this.emit('message', message);\n },\n ping: () => {\n this.send_event('pusher:pong', {});\n },\n activity: () => {\n this.resetActivityCheck();\n },\n error: error => {\n // just emit error to user - socket will already be closed by browser\n this.emit('error', error);\n },\n closed: () => {\n this.abandonConnection();\n if (this.shouldRetry()) {\n this.retryIn(1000);\n }\n }\n });\n }\n\n private buildHandshakeCallbacks(\n errorCallbacks: ErrorCallbacks\n ): HandshakeCallbacks {\n return Collections.extend({}, errorCallbacks, {\n connected: (handshake: HandshakePayload) => {\n this.activityTimeout = Math.min(\n this.options.activityTimeout,\n handshake.activityTimeout,\n handshake.connection.activityTimeout || Infinity\n );\n this.clearUnavailableTimer();\n this.setConnection(handshake.connection);\n this.socket_id = this.connection.id;\n this.updateState('connected', { socket_id: this.socket_id });\n }\n });\n }\n\n private buildErrorCallbacks(): ErrorCallbacks {\n let withErrorEmitted = callback => {\n return (result: Action | HandshakePayload) => {\n if (result.error) {\n this.emit('error', { type: 'WebSocketError', error: result.error });\n }\n callback(result);\n };\n };\n\n return {\n tls_only: withErrorEmitted(() => {\n this.usingTLS = true;\n this.updateStrategy();\n this.retryIn(0);\n }),\n refused: withErrorEmitted(() => {\n this.disconnect();\n }),\n backoff: withErrorEmitted(() => {\n this.retryIn(1000);\n }),\n retry: withErrorEmitted(() => {\n this.retryIn(0);\n })\n };\n }\n\n private setConnection(connection) {\n this.connection = connection;\n for (var event in this.connectionCallbacks) {\n this.connection.bind(event, this.connectionCallbacks[event]);\n }\n this.resetActivityCheck();\n }\n\n private abandonConnection() {\n if (!this.connection) {\n return;\n }\n this.stopActivityCheck();\n for (var event in this.connectionCallbacks) {\n this.connection.unbind(event, this.connectionCallbacks[event]);\n }\n var connection = this.connection;\n this.connection = null;\n return connection;\n }\n\n private updateState(newState: string, data?: any) {\n var previousState = this.state;\n this.state = newState;\n if (previousState !== newState) {\n var newStateDescription = newState;\n if (newStateDescription === 'connected') {\n newStateDescription += ' with new socket ID ' + data.socket_id;\n }\n Logger.debug(\n 'State changed',\n previousState + ' -> ' + newStateDescription\n );\n this.timeline.info({ state: newState, params: data });\n this.emit('state_change', { previous: previousState, current: newState });\n this.emit(newState, data);\n }\n }\n\n private shouldRetry(): boolean {\n return this.state === 'connecting' || this.state === 'connected';\n }\n}\n","import Channel from './channel';\nimport * as Collections from '../utils/collections';\nimport ChannelTable from './channel_table';\nimport Factory from '../utils/factory';\nimport Pusher from '../pusher';\nimport Logger from '../logger';\nimport * as Errors from '../errors';\nimport urlStore from '../utils/url_store';\n\n/** Handles a channel map. */\nexport default class Channels {\n channels: ChannelTable;\n\n constructor() {\n this.channels = {};\n }\n\n /** Creates or retrieves an existing channel by its name.\n *\n * @param {String} name\n * @param {Pusher} pusher\n * @return {Channel}\n */\n add(name: string, pusher: Pusher) {\n if (!this.channels[name]) {\n this.channels[name] = createChannel(name, pusher);\n }\n return this.channels[name];\n }\n\n /** Returns a list of all channels\n *\n * @return {Array}\n */\n all(): Channel[] {\n return Collections.values(this.channels);\n }\n\n /** Finds a channel by its name.\n *\n * @param {String} name\n * @return {Channel} channel or null if it doesn't exist\n */\n find(name: string) {\n return this.channels[name];\n }\n\n /** Removes a channel from the map.\n *\n * @param {String} name\n */\n remove(name: string) {\n var channel = this.channels[name];\n delete this.channels[name];\n return channel;\n }\n\n /** Proxies disconnection signal to all channels. */\n disconnect() {\n Collections.objectApply(this.channels, function(channel) {\n channel.disconnect();\n });\n }\n}\n\nfunction createChannel(name: string, pusher: Pusher): Channel {\n if (name.indexOf('private-encrypted-') === 0) {\n if (pusher.config.nacl) {\n return Factory.createEncryptedChannel(name, pusher, pusher.config.nacl);\n }\n let errMsg =\n 'Tried to subscribe to a private-encrypted- channel but no nacl implementation available';\n let suffix = urlStore.buildLogSuffix('encryptedChannelSupport');\n throw new Errors.UnsupportedFeature(`${errMsg}. ${suffix}`);\n } else if (name.indexOf('private-') === 0) {\n return Factory.createPrivateChannel(name, pusher);\n } else if (name.indexOf('presence-') === 0) {\n return Factory.createPresenceChannel(name, pusher);\n } else if (name.indexOf('#') === 0) {\n throw new Errors.BadChannelName(\n 'Cannot create a channel with name \"' + name + '\".'\n );\n } else {\n return Factory.createChannel(name, pusher);\n }\n}\n","import AssistantToTheTransportManager from '../transports/assistant_to_the_transport_manager';\nimport PingDelayOptions from '../transports/ping_delay_options';\nimport Transport from '../transports/transport';\nimport TransportManager from '../transports/transport_manager';\nimport Handshake from '../connection/handshake';\nimport TransportConnection from '../transports/transport_connection';\nimport SocketHooks from '../http/socket_hooks';\nimport HTTPSocket from '../http/http_socket';\n\nimport Timeline from '../timeline/timeline';\nimport {\n default as TimelineSender,\n TimelineSenderOptions\n} from '../timeline/timeline_sender';\nimport PresenceChannel from '../channels/presence_channel';\nimport PrivateChannel from '../channels/private_channel';\nimport EncryptedChannel from '../channels/encrypted_channel';\nimport Channel from '../channels/channel';\nimport ConnectionManager from '../connection/connection_manager';\nimport ConnectionManagerOptions from '../connection/connection_manager_options';\nimport Ajax from '../http/ajax';\nimport Channels from '../channels/channels';\nimport Pusher from '../pusher';\nimport { Config } from '../config';\nimport * as nacl from 'tweetnacl';\n\nvar Factory = {\n createChannels(): Channels {\n return new Channels();\n },\n\n createConnectionManager(\n key: string,\n options: ConnectionManagerOptions\n ): ConnectionManager {\n return new ConnectionManager(key, options);\n },\n\n createChannel(name: string, pusher: Pusher): Channel {\n return new Channel(name, pusher);\n },\n\n createPrivateChannel(name: string, pusher: Pusher): PrivateChannel {\n return new PrivateChannel(name, pusher);\n },\n\n createPresenceChannel(name: string, pusher: Pusher): PresenceChannel {\n return new PresenceChannel(name, pusher);\n },\n\n createEncryptedChannel(\n name: string,\n pusher: Pusher,\n nacl: nacl\n ): EncryptedChannel {\n return new EncryptedChannel(name, pusher, nacl);\n },\n\n createTimelineSender(timeline: Timeline, options: TimelineSenderOptions) {\n return new TimelineSender(timeline, options);\n },\n\n createHandshake(\n transport: TransportConnection,\n callback: (HandshakePayload) => void\n ): Handshake {\n return new Handshake(transport, callback);\n },\n\n createAssistantToTheTransportManager(\n manager: TransportManager,\n transport: Transport,\n options: PingDelayOptions\n ): AssistantToTheTransportManager {\n return new AssistantToTheTransportManager(manager, transport, options);\n }\n};\n\nexport default Factory;\n","import AssistantToTheTransportManager from './assistant_to_the_transport_manager';\nimport Transport from './transport';\nimport PingDelayOptions from './ping_delay_options';\nimport Factory from '../utils/factory';\n\nexport interface TransportManagerOptions extends PingDelayOptions {\n lives?: number;\n}\n\n/** Keeps track of the number of lives left for a transport.\n *\n * In the beginning of a session, transports may be assigned a number of\n * lives. When an AssistantToTheTransportManager instance reports a transport\n * connection closed uncleanly, the transport loses a life. When the number\n * of lives drops to zero, the transport gets disabled by its manager.\n *\n * @param {Object} options\n */\nexport default class TransportManager {\n options: TransportManagerOptions;\n livesLeft: number;\n\n constructor(options: TransportManagerOptions) {\n this.options = options || {};\n this.livesLeft = this.options.lives || Infinity;\n }\n\n /** Creates a assistant for the transport.\n *\n * @param {Transport} transport\n * @returns {AssistantToTheTransportManager}\n */\n getAssistant(transport: Transport): AssistantToTheTransportManager {\n return Factory.createAssistantToTheTransportManager(this, transport, {\n minPingDelay: this.options.minPingDelay,\n maxPingDelay: this.options.maxPingDelay\n });\n }\n\n /** Returns whether the transport has any lives left.\n *\n * @returns {Boolean}\n */\n isAlive(): boolean {\n return this.livesLeft > 0;\n }\n\n /** Takes one life from the transport. */\n reportDeath() {\n this.livesLeft -= 1;\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport { OneOffTimer as Timer } from '../utils/timers';\nimport Strategy from './strategy';\nimport StrategyOptions from './strategy_options';\n\n/** Loops through strategies with optional timeouts.\n *\n * Options:\n * - loop - whether it should loop through the substrategy list\n * - timeout - initial timeout for a single substrategy\n * - timeoutLimit - maximum timeout\n *\n * @param {Strategy[]} strategies\n * @param {Object} options\n */\nexport default class SequentialStrategy implements Strategy {\n strategies: Strategy[];\n loop: boolean;\n failFast: boolean;\n timeout: number;\n timeoutLimit: number;\n\n constructor(strategies: Strategy[], options: StrategyOptions) {\n this.strategies = strategies;\n this.loop = Boolean(options.loop);\n this.failFast = Boolean(options.failFast);\n this.timeout = options.timeout;\n this.timeoutLimit = options.timeoutLimit;\n }\n\n isSupported(): boolean {\n return Collections.any(this.strategies, Util.method('isSupported'));\n }\n\n connect(minPriority: number, callback: Function) {\n var strategies = this.strategies;\n var current = 0;\n var timeout = this.timeout;\n var runner = null;\n\n var tryNextStrategy = (error, handshake) => {\n if (handshake) {\n callback(null, handshake);\n } else {\n current = current + 1;\n if (this.loop) {\n current = current % strategies.length;\n }\n\n if (current < strategies.length) {\n if (timeout) {\n timeout = timeout * 2;\n if (this.timeoutLimit) {\n timeout = Math.min(timeout, this.timeoutLimit);\n }\n }\n runner = this.tryStrategy(\n strategies[current],\n minPriority,\n { timeout, failFast: this.failFast },\n tryNextStrategy\n );\n } else {\n callback(true);\n }\n }\n };\n\n runner = this.tryStrategy(\n strategies[current],\n minPriority,\n { timeout: timeout, failFast: this.failFast },\n tryNextStrategy\n );\n\n return {\n abort: function() {\n runner.abort();\n },\n forceMinPriority: function(p) {\n minPriority = p;\n if (runner) {\n runner.forceMinPriority(p);\n }\n }\n };\n }\n\n private tryStrategy(\n strategy: Strategy,\n minPriority: number,\n options: StrategyOptions,\n callback: Function\n ) {\n var timer = null;\n var runner = null;\n\n if (options.timeout > 0) {\n timer = new Timer(options.timeout, function() {\n runner.abort();\n callback(true);\n });\n }\n\n runner = strategy.connect(minPriority, function(error, handshake) {\n if (error && timer && timer.isRunning() && !options.failFast) {\n // advance to the next strategy after the timeout\n return;\n }\n if (timer) {\n timer.ensureAborted();\n }\n callback(error, handshake);\n });\n\n return {\n abort: function() {\n if (timer) {\n timer.ensureAborted();\n }\n runner.abort();\n },\n forceMinPriority: function(p) {\n runner.forceMinPriority(p);\n }\n };\n }\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport Strategy from './strategy';\n\n/** Launches all substrategies and emits prioritized connected transports.\n *\n * @param {Array} strategies\n */\nexport default class BestConnectedEverStrategy implements Strategy {\n strategies: Strategy[];\n\n constructor(strategies: Strategy[]) {\n this.strategies = strategies;\n }\n\n isSupported(): boolean {\n return Collections.any(this.strategies, Util.method('isSupported'));\n }\n\n connect(minPriority: number, callback: Function) {\n return connect(this.strategies, minPriority, function(i, runners) {\n return function(error, handshake) {\n runners[i].error = error;\n if (error) {\n if (allRunnersFailed(runners)) {\n callback(true);\n }\n return;\n }\n Collections.apply(runners, function(runner) {\n runner.forceMinPriority(handshake.transport.priority);\n });\n callback(null, handshake);\n };\n });\n }\n}\n\n/** Connects to all strategies in parallel.\n *\n * Callback builder should be a function that takes two arguments: index\n * and a list of runners. It should return another function that will be\n * passed to the substrategy with given index. Runners can be aborted using\n * abortRunner(s) functions from this class.\n *\n * @param {Array} strategies\n * @param {Function} callbackBuilder\n * @return {Object} strategy runner\n */\nfunction connect(\n strategies: Strategy[],\n minPriority: number,\n callbackBuilder: Function\n) {\n var runners = Collections.map(strategies, function(strategy, i, _, rs) {\n return strategy.connect(minPriority, callbackBuilder(i, rs));\n });\n return {\n abort: function() {\n Collections.apply(runners, abortRunner);\n },\n forceMinPriority: function(p) {\n Collections.apply(runners, function(runner) {\n runner.forceMinPriority(p);\n });\n }\n };\n}\n\nfunction allRunnersFailed(runners): boolean {\n return Collections.all(runners, function(runner) {\n return Boolean(runner.error);\n });\n}\n\nfunction abortRunner(runner) {\n if (!runner.error && !runner.aborted) {\n runner.abort();\n runner.aborted = true;\n }\n}\n","import Util from '../util';\nimport Runtime from 'runtime';\nimport Strategy from './strategy';\nimport SequentialStrategy from './sequential_strategy';\nimport StrategyOptions from './strategy_options';\nimport TransportStrategy from './transport_strategy';\nimport Timeline from '../timeline/timeline';\nimport * as Collections from '../utils/collections';\n\nexport interface TransportStrategyDictionary {\n [key: string]: TransportStrategy;\n}\n\n/** Caches the last successful transport and, after the first few attempts,\n * uses the cached transport for subsequent attempts.\n *\n * @param {Strategy} strategy\n * @param {Object} transports\n * @param {Object} options\n */\nexport default class WebSocketPrioritizedCachedStrategy implements Strategy {\n strategy: Strategy;\n transports: TransportStrategyDictionary;\n ttl: number;\n usingTLS: boolean;\n timeline: Timeline;\n\n constructor(\n strategy: Strategy,\n transports: TransportStrategyDictionary,\n options: StrategyOptions\n ) {\n this.strategy = strategy;\n this.transports = transports;\n this.ttl = options.ttl || 1800 * 1000;\n this.usingTLS = options.useTLS;\n this.timeline = options.timeline;\n }\n\n isSupported(): boolean {\n return this.strategy.isSupported();\n }\n\n connect(minPriority: number, callback: Function) {\n var usingTLS = this.usingTLS;\n var info = fetchTransportCache(usingTLS);\n var cacheSkipCount = info && info.cacheSkipCount ? info.cacheSkipCount : 0;\n\n var strategies = [this.strategy];\n if (info && info.timestamp + this.ttl >= Util.now()) {\n var transport = this.transports[info.transport];\n if (transport) {\n if (['ws', 'wss'].includes(info.transport) || cacheSkipCount > 3) {\n this.timeline.info({\n cached: true,\n transport: info.transport,\n latency: info.latency\n });\n strategies.push(\n new SequentialStrategy([transport], {\n timeout: info.latency * 2 + 1000,\n failFast: true\n })\n );\n } else {\n cacheSkipCount++;\n }\n }\n }\n\n var startTimestamp = Util.now();\n var runner = strategies\n .pop()\n .connect(minPriority, function cb(error, handshake) {\n if (error) {\n flushTransportCache(usingTLS);\n if (strategies.length > 0) {\n startTimestamp = Util.now();\n runner = strategies.pop().connect(minPriority, cb);\n } else {\n callback(error);\n }\n } else {\n storeTransportCache(\n usingTLS,\n handshake.transport.name,\n Util.now() - startTimestamp,\n cacheSkipCount\n );\n callback(null, handshake);\n }\n });\n\n return {\n abort: function() {\n runner.abort();\n },\n forceMinPriority: function(p) {\n minPriority = p;\n if (runner) {\n runner.forceMinPriority(p);\n }\n }\n };\n }\n}\n\nfunction getTransportCacheKey(usingTLS: boolean): string {\n return 'pusherTransport' + (usingTLS ? 'TLS' : 'NonTLS');\n}\n\nfunction fetchTransportCache(usingTLS: boolean): any {\n var storage = Runtime.getLocalStorage();\n if (storage) {\n try {\n var serializedCache = storage[getTransportCacheKey(usingTLS)];\n if (serializedCache) {\n return JSON.parse(serializedCache);\n }\n } catch (e) {\n flushTransportCache(usingTLS);\n }\n }\n return null;\n}\n\nfunction storeTransportCache(\n usingTLS: boolean,\n transport: TransportStrategy,\n latency: number,\n cacheSkipCount: number\n) {\n var storage = Runtime.getLocalStorage();\n if (storage) {\n try {\n storage[getTransportCacheKey(usingTLS)] = Collections.safeJSONStringify({\n timestamp: Util.now(),\n transport: transport,\n latency: latency,\n cacheSkipCount: cacheSkipCount\n });\n } catch (e) {\n // catch over quota exceptions raised by localStorage\n }\n }\n}\n\nfunction flushTransportCache(usingTLS: boolean) {\n var storage = Runtime.getLocalStorage();\n if (storage) {\n try {\n delete storage[getTransportCacheKey(usingTLS)];\n } catch (e) {\n // catch exceptions raised by localStorage\n }\n }\n}\n","import { OneOffTimer as Timer } from '../utils/timers';\nimport Strategy from './strategy';\nimport StrategyOptions from './strategy_options';\n\n/** Runs substrategy after specified delay.\n *\n * Options:\n * - delay - time in miliseconds to delay the substrategy attempt\n *\n * @param {Strategy} strategy\n * @param {Object} options\n */\nexport default class DelayedStrategy implements Strategy {\n strategy: Strategy;\n options: { delay: number };\n\n constructor(strategy: Strategy, { delay: number }) {\n this.strategy = strategy;\n this.options = { delay: number };\n }\n\n isSupported(): boolean {\n return this.strategy.isSupported();\n }\n\n connect(minPriority: number, callback: Function) {\n var strategy = this.strategy;\n var runner;\n var timer = new Timer(this.options.delay, function() {\n runner = strategy.connect(minPriority, callback);\n });\n\n return {\n abort: function() {\n timer.ensureAborted();\n if (runner) {\n runner.abort();\n }\n },\n forceMinPriority: function(p) {\n minPriority = p;\n if (runner) {\n runner.forceMinPriority(p);\n }\n }\n };\n }\n}\n","import Strategy from './strategy';\nimport StrategyRunner from './strategy_runner';\n\n/** Proxies method calls to one of substrategies basing on the test function.\n *\n * @param {Function} test\n * @param {Strategy} trueBranch strategy used when test returns true\n * @param {Strategy} falseBranch strategy used when test returns false\n */\nexport default class IfStrategy implements Strategy {\n test: () => boolean;\n trueBranch: Strategy;\n falseBranch: Strategy;\n\n constructor(\n test: () => boolean,\n trueBranch: Strategy,\n falseBranch: Strategy\n ) {\n this.test = test;\n this.trueBranch = trueBranch;\n this.falseBranch = falseBranch;\n }\n\n isSupported(): boolean {\n var branch = this.test() ? this.trueBranch : this.falseBranch;\n return branch.isSupported();\n }\n\n connect(minPriority: number, callback: Function): StrategyRunner {\n var branch = this.test() ? this.trueBranch : this.falseBranch;\n return branch.connect(minPriority, callback);\n }\n}\n","import Strategy from './strategy';\nimport StrategyRunner from './strategy_runner';\n\n/** Launches the substrategy and terminates on the first open connection.\n *\n * @param {Strategy} strategy\n */\nexport default class FirstConnectedStrategy implements Strategy {\n strategy: Strategy;\n\n constructor(strategy: Strategy) {\n this.strategy = strategy;\n }\n\n isSupported(): boolean {\n return this.strategy.isSupported();\n }\n\n connect(minPriority: number, callback: Function): StrategyRunner {\n var runner = this.strategy.connect(minPriority, function(error, handshake) {\n if (handshake) {\n runner.abort();\n }\n callback(error, handshake);\n });\n return runner;\n }\n}\n","import * as Collections from 'core/utils/collections';\nimport TransportManager from 'core/transports/transport_manager';\nimport Strategy from 'core/strategies/strategy';\nimport SequentialStrategy from 'core/strategies/sequential_strategy';\nimport BestConnectedEverStrategy from 'core/strategies/best_connected_ever_strategy';\nimport WebSocketPrioritizedCachedStrategy, {\n TransportStrategyDictionary\n} from 'core/strategies/websocket_prioritized_cached_strategy';\nimport DelayedStrategy from 'core/strategies/delayed_strategy';\nimport IfStrategy from 'core/strategies/if_strategy';\nimport FirstConnectedStrategy from 'core/strategies/first_connected_strategy';\nimport { Config } from 'core/config';\nimport StrategyOptions from 'core/strategies/strategy_options';\n\nfunction testSupportsStrategy(strategy: Strategy) {\n return function() {\n return strategy.isSupported();\n };\n}\n\nvar getDefaultStrategy = function(\n config: Config,\n baseOptions: StrategyOptions,\n defineTransport: Function\n): Strategy {\n var definedTransports = {};\n\n function defineTransportStrategy(\n name: string,\n type: string,\n priority: number,\n options: StrategyOptions,\n manager?: TransportManager\n ) {\n var transport = defineTransport(\n config,\n name,\n type,\n priority,\n options,\n manager\n );\n\n definedTransports[name] = transport;\n\n return transport;\n }\n\n var ws_options: StrategyOptions = Object.assign({}, baseOptions, {\n hostNonTLS: config.wsHost + ':' + config.wsPort,\n hostTLS: config.wsHost + ':' + config.wssPort,\n httpPath: config.wsPath\n });\n var wss_options: StrategyOptions = Collections.extend({}, ws_options, {\n useTLS: true\n });\n var http_options: StrategyOptions = Object.assign({}, baseOptions, {\n hostNonTLS: config.httpHost + ':' + config.httpPort,\n hostTLS: config.httpHost + ':' + config.httpsPort,\n httpPath: config.httpPath\n });\n var timeouts = {\n loop: true,\n timeout: 15000,\n timeoutLimit: 60000\n };\n\n var ws_manager = new TransportManager({\n minPingDelay: 10000,\n maxPingDelay: config.activityTimeout\n });\n var streaming_manager = new TransportManager({\n lives: 2,\n minPingDelay: 10000,\n maxPingDelay: config.activityTimeout\n });\n\n var ws_transport = defineTransportStrategy(\n 'ws',\n 'ws',\n 3,\n ws_options,\n ws_manager\n );\n var wss_transport = defineTransportStrategy(\n 'wss',\n 'ws',\n 3,\n wss_options,\n ws_manager\n );\n var xhr_streaming_transport = defineTransportStrategy(\n 'xhr_streaming',\n 'xhr_streaming',\n 1,\n http_options,\n streaming_manager\n );\n var xhr_polling_transport = defineTransportStrategy(\n 'xhr_polling',\n 'xhr_polling',\n 1,\n http_options\n );\n\n var ws_loop = new SequentialStrategy([ws_transport], timeouts);\n var wss_loop = new SequentialStrategy([wss_transport], timeouts);\n var streaming_loop = new SequentialStrategy(\n [xhr_streaming_transport],\n timeouts\n );\n var polling_loop = new SequentialStrategy([xhr_polling_transport], timeouts);\n\n var http_loop = new SequentialStrategy(\n [\n new IfStrategy(\n testSupportsStrategy(streaming_loop),\n new BestConnectedEverStrategy([\n streaming_loop,\n new DelayedStrategy(polling_loop, { delay: 4000 })\n ]),\n polling_loop\n )\n ],\n timeouts\n );\n\n var wsStrategy;\n if (baseOptions.useTLS) {\n wsStrategy = new BestConnectedEverStrategy([\n ws_loop,\n new DelayedStrategy(http_loop, { delay: 2000 })\n ]);\n } else {\n wsStrategy = new BestConnectedEverStrategy([\n ws_loop,\n new DelayedStrategy(wss_loop, { delay: 2000 }),\n new DelayedStrategy(http_loop, { delay: 5000 })\n ]);\n }\n\n return new WebSocketPrioritizedCachedStrategy(\n new FirstConnectedStrategy(\n new IfStrategy(testSupportsStrategy(ws_transport), wsStrategy, http_loop)\n ),\n definedTransports,\n {\n ttl: 1800000,\n timeline: baseOptions.timeline,\n useTLS: baseOptions.useTLS\n }\n );\n};\n\nexport default getDefaultStrategy;\n","import Runtime from 'runtime';\nimport RequestHooks from './request_hooks';\nimport Ajax from './ajax';\nimport { default as EventsDispatcher } from '../events/dispatcher';\n\nconst MAX_BUFFER_LENGTH = 256 * 1024;\n\nexport default class HTTPRequest extends EventsDispatcher {\n hooks: RequestHooks;\n method: string;\n url: string;\n position: number;\n xhr: Ajax;\n unloader: Function;\n\n constructor(hooks: RequestHooks, method: string, url: string) {\n super();\n this.hooks = hooks;\n this.method = method;\n this.url = url;\n }\n\n start(payload?: any) {\n this.position = 0;\n this.xhr = this.hooks.getRequest(this);\n\n this.unloader = () => {\n this.close();\n };\n Runtime.addUnloadListener(this.unloader);\n\n this.xhr.open(this.method, this.url, true);\n\n if (this.xhr.setRequestHeader) {\n this.xhr.setRequestHeader('Content-Type', 'application/json'); // ReactNative doesn't set this header by default.\n }\n this.xhr.send(payload);\n }\n\n close() {\n if (this.unloader) {\n Runtime.removeUnloadListener(this.unloader);\n this.unloader = null;\n }\n if (this.xhr) {\n this.hooks.abortRequest(this.xhr);\n this.xhr = null;\n }\n }\n\n onChunk(status: number, data: any) {\n while (true) {\n var chunk = this.advanceBuffer(data);\n if (chunk) {\n this.emit('chunk', { status: status, data: chunk });\n } else {\n break;\n }\n }\n if (this.isBufferTooLong(data)) {\n this.emit('buffer_too_long');\n }\n }\n\n private advanceBuffer(buffer: any[]): any {\n var unreadData = buffer.slice(this.position);\n var endOfLinePosition = unreadData.indexOf('\\n');\n\n if (endOfLinePosition !== -1) {\n this.position += endOfLinePosition + 1;\n return unreadData.slice(0, endOfLinePosition);\n } else {\n // chunk is not finished yet, don't move the buffer pointer\n return null;\n }\n }\n\n private isBufferTooLong(buffer: any): boolean {\n return this.position === buffer.length && buffer.length > MAX_BUFFER_LENGTH;\n }\n}\n","enum State {\n CONNECTING = 0,\n OPEN = 1,\n CLOSED = 3\n}\n\nexport default State;\n","import URLLocation from './url_location';\nimport State from './state';\nimport Socket from '../socket';\nimport SocketHooks from './socket_hooks';\nimport Util from '../util';\nimport Ajax from './ajax';\nimport HTTPRequest from './http_request';\nimport Runtime from 'runtime';\n\nvar autoIncrement = 1;\n\nclass HTTPSocket implements Socket {\n hooks: SocketHooks;\n session: string;\n location: URLLocation;\n readyState: State;\n stream: HTTPRequest;\n\n onopen: () => void;\n onerror: (error: any) => void;\n onclose: (closeEvent: any) => void;\n onmessage: (message: any) => void;\n onactivity: () => void;\n\n constructor(hooks: SocketHooks, url: string) {\n this.hooks = hooks;\n this.session = randomNumber(1000) + '/' + randomString(8);\n this.location = getLocation(url);\n this.readyState = State.CONNECTING;\n this.openStream();\n }\n\n send(payload: any) {\n return this.sendRaw(JSON.stringify([payload]));\n }\n\n ping() {\n this.hooks.sendHeartbeat(this);\n }\n\n close(code: any, reason: any) {\n this.onClose(code, reason, true);\n }\n\n /** For internal use only */\n sendRaw(payload: any): boolean {\n if (this.readyState === State.OPEN) {\n try {\n Runtime.createSocketRequest(\n 'POST',\n getUniqueURL(getSendURL(this.location, this.session))\n ).start(payload);\n return true;\n } catch (e) {\n return false;\n }\n } else {\n return false;\n }\n }\n\n /** For internal use only */\n reconnect() {\n this.closeStream();\n this.openStream();\n }\n\n /** For internal use only */\n onClose(code, reason, wasClean) {\n this.closeStream();\n this.readyState = State.CLOSED;\n if (this.onclose) {\n this.onclose({\n code: code,\n reason: reason,\n wasClean: wasClean\n });\n }\n }\n\n private onChunk(chunk) {\n if (chunk.status !== 200) {\n return;\n }\n if (this.readyState === State.OPEN) {\n this.onActivity();\n }\n\n var payload;\n var type = chunk.data.slice(0, 1);\n switch (type) {\n case 'o':\n payload = JSON.parse(chunk.data.slice(1) || '{}');\n this.onOpen(payload);\n break;\n case 'a':\n payload = JSON.parse(chunk.data.slice(1) || '[]');\n for (var i = 0; i < payload.length; i++) {\n this.onEvent(payload[i]);\n }\n break;\n case 'm':\n payload = JSON.parse(chunk.data.slice(1) || 'null');\n this.onEvent(payload);\n break;\n case 'h':\n this.hooks.onHeartbeat(this);\n break;\n case 'c':\n payload = JSON.parse(chunk.data.slice(1) || '[]');\n this.onClose(payload[0], payload[1], true);\n break;\n }\n }\n\n private onOpen(options) {\n if (this.readyState === State.CONNECTING) {\n if (options && options.hostname) {\n this.location.base = replaceHost(this.location.base, options.hostname);\n }\n this.readyState = State.OPEN;\n\n if (this.onopen) {\n this.onopen();\n }\n } else {\n this.onClose(1006, 'Server lost session', true);\n }\n }\n\n private onEvent(event) {\n if (this.readyState === State.OPEN && this.onmessage) {\n this.onmessage({ data: event });\n }\n }\n\n private onActivity() {\n if (this.onactivity) {\n this.onactivity();\n }\n }\n\n private onError(error) {\n if (this.onerror) {\n this.onerror(error);\n }\n }\n\n private openStream() {\n this.stream = Runtime.createSocketRequest(\n 'POST',\n getUniqueURL(this.hooks.getReceiveURL(this.location, this.session))\n );\n\n this.stream.bind('chunk', chunk => {\n this.onChunk(chunk);\n });\n this.stream.bind('finished', status => {\n this.hooks.onFinished(this, status);\n });\n this.stream.bind('buffer_too_long', () => {\n this.reconnect();\n });\n\n try {\n this.stream.start();\n } catch (error) {\n Util.defer(() => {\n this.onError(error);\n this.onClose(1006, 'Could not start streaming', false);\n });\n }\n }\n\n private closeStream() {\n if (this.stream) {\n this.stream.unbind_all();\n this.stream.close();\n this.stream = null;\n }\n }\n}\n\nfunction getLocation(url): URLLocation {\n var parts = /([^\\?]*)\\/*(\\??.*)/.exec(url);\n return {\n base: parts[1],\n queryString: parts[2]\n };\n}\n\nfunction getSendURL(url: URLLocation, session: string): string {\n return url.base + '/' + session + '/xhr_send';\n}\n\nfunction getUniqueURL(url: string): string {\n var separator = url.indexOf('?') === -1 ? '?' : '&';\n return url + separator + 't=' + +new Date() + '&n=' + autoIncrement++;\n}\n\nfunction replaceHost(url: string, hostname: string): string {\n var urlParts = /(https?:\\/\\/)([^\\/:]+)((\\/|:)?.*)/.exec(url);\n return urlParts[1] + hostname + urlParts[3];\n}\n\nfunction randomNumber(max: number): number {\n return Runtime.randomInt(max);\n}\n\nfunction randomString(length: number): string {\n var result = [];\n\n for (var i = 0; i < length; i++) {\n result.push(randomNumber(32).toString(32));\n }\n\n return result.join('');\n}\n\nexport default HTTPSocket;\n","import SocketHooks from './socket_hooks';\nimport HTTPSocket from './http_socket';\n\nvar hooks: SocketHooks = {\n getReceiveURL: function(url, session) {\n return url.base + '/' + session + '/xhr_streaming' + url.queryString;\n },\n onHeartbeat: function(socket) {\n socket.sendRaw('[]');\n },\n sendHeartbeat: function(socket) {\n socket.sendRaw('[]');\n },\n onFinished: function(socket, status) {\n socket.onClose(1006, 'Connection interrupted (' + status + ')', false);\n }\n};\n\nexport default hooks;\n","import SocketHooks from './socket_hooks';\nimport URLLocation from './url_location';\nimport HTTPSocket from './http_socket';\n\nvar hooks: SocketHooks = {\n getReceiveURL: function(url: URLLocation, session: string): string {\n return url.base + '/' + session + '/xhr' + url.queryString;\n },\n onHeartbeat: function() {\n // next HTTP request will reset server's activity timer\n },\n sendHeartbeat: function(socket) {\n socket.sendRaw('[]');\n },\n onFinished: function(socket, status) {\n if (status === 200) {\n socket.reconnect();\n } else {\n socket.onClose(1006, 'Connection interrupted (' + status + ')', false);\n }\n }\n};\n\nexport default hooks;\n","import HTTPRequest from 'core/http/http_request';\nimport RequestHooks from 'core/http/request_hooks';\nimport Ajax from 'core/http/ajax';\nimport Runtime from 'runtime';\n\nvar hooks: RequestHooks = {\n getRequest: function(socket: HTTPRequest): Ajax {\n var Constructor = Runtime.getXHRAPI();\n var xhr = new Constructor();\n xhr.onreadystatechange = xhr.onprogress = function() {\n switch (xhr.readyState) {\n case 3:\n if (xhr.responseText && xhr.responseText.length > 0) {\n socket.onChunk(xhr.status, xhr.responseText);\n }\n break;\n case 4:\n // this happens only on errors, never after calling close\n if (xhr.responseText && xhr.responseText.length > 0) {\n socket.onChunk(xhr.status, xhr.responseText);\n }\n socket.emit('finished', xhr.status);\n socket.close();\n break;\n }\n };\n return xhr;\n },\n abortRequest: function(xhr: Ajax) {\n xhr.onreadystatechange = null;\n xhr.abort();\n }\n};\n\nexport default hooks;\n","import * as Collections from 'core/utils/collections';\nimport Transports from 'isomorphic/transports/transports';\nimport TimelineSender from 'core/timeline/timeline_sender';\nimport Ajax from 'core/http/ajax';\nimport getDefaultStrategy from './default_strategy';\nimport TransportsTable from 'core/transports/transports_table';\nimport transportConnectionInitializer from './transports/transport_connection_initializer';\nimport HTTPFactory from './http/http';\n\nvar Isomorphic: any = {\n getDefaultStrategy,\n Transports: Transports,\n transportConnectionInitializer,\n HTTPFactory,\n\n setup(PusherClass): void {\n PusherClass.ready();\n },\n\n getLocalStorage(): any {\n return undefined;\n },\n\n getClientFeatures(): any[] {\n return Collections.keys(\n Collections.filterObject({ ws: Transports.ws }, function(t) {\n return t.isSupported({});\n })\n );\n },\n\n getProtocol(): string {\n return 'http:';\n },\n\n isXHRSupported(): boolean {\n return true;\n },\n\n createSocketRequest(method: string, url: string) {\n if (this.isXHRSupported()) {\n return this.HTTPFactory.createXHR(method, url);\n } else {\n throw 'Cross-origin HTTP requests are not supported';\n }\n },\n\n createXHR(): Ajax {\n var Constructor = this.getXHRAPI();\n return new Constructor();\n },\n\n createWebSocket(url: string): any {\n var Constructor = this.getWebSocketAPI();\n return new Constructor(url);\n },\n\n addUnloadListener(listener: any) {},\n removeUnloadListener(listener: any) {}\n};\n\nexport default Isomorphic;\n","/** Initializes the transport.\n *\n * Fetches resources if needed and then transitions to initialized.\n */\nexport default function() {\n var self = this;\n\n self.timeline.info(\n self.buildTimelineMessage({\n transport: self.name + (self.options.useTLS ? 's' : '')\n })\n );\n\n if (self.hooks.isInitialized()) {\n self.changeState('initialized');\n } else {\n self.onClose();\n }\n}\n","import HTTPRequest from 'core/http/http_request';\nimport HTTPSocket from 'core/http/http_socket';\nimport SocketHooks from 'core/http/socket_hooks';\nimport RequestHooks from 'core/http/request_hooks';\nimport streamingHooks from 'core/http/http_streaming_socket';\nimport pollingHooks from 'core/http/http_polling_socket';\nimport xhrHooks from './http_xhr_request';\nimport HTTPFactory from 'core/http/http_factory';\n\nvar HTTP: HTTPFactory = {\n createStreamingSocket(url: string): HTTPSocket {\n return this.createSocket(streamingHooks, url);\n },\n\n createPollingSocket(url: string): HTTPSocket {\n return this.createSocket(pollingHooks, url);\n },\n\n createSocket(hooks: SocketHooks, url: string): HTTPSocket {\n return new HTTPSocket(hooks, url);\n },\n\n createXHR(method: string, url: string): HTTPRequest {\n return this.createRequest(xhrHooks, method, url);\n },\n\n createRequest(hooks: RequestHooks, method: string, url: string): HTTPRequest {\n return new HTTPRequest(hooks, method, url);\n }\n};\n\nexport default HTTP;\n","import { default as EventsDispatcher } from 'core/events/dispatcher';\nimport Reachability from 'core/reachability';\n\nexport class NetInfo extends EventsDispatcher implements Reachability {\n isOnline(): boolean {\n return true;\n }\n}\n\nexport var Network = new NetInfo();\n","import AbstractRuntime from 'runtimes/interface';\nimport { AuthTransport } from 'core/auth/auth_transports';\nimport {\n AuthRequestType,\n AuthTransportCallback,\n InternalAuthOptions\n} from 'core/auth/options';\nimport { HTTPAuthError } from 'core/errors';\n\nvar fetchAuth: AuthTransport = function(\n context: AbstractRuntime,\n query: string,\n authOptions: InternalAuthOptions,\n authRequestType: AuthRequestType,\n callback: AuthTransportCallback\n) {\n var headers = new Headers();\n headers.set('Content-Type', 'application/x-www-form-urlencoded');\n\n for (var headerName in authOptions.headers) {\n headers.set(headerName, authOptions.headers[headerName]);\n }\n\n if (authOptions.headersProvider != null) {\n const dynamicHeaders = authOptions.headersProvider();\n for (var headerName in dynamicHeaders) {\n headers.set(headerName, dynamicHeaders[headerName]);\n }\n }\n\n var body = query;\n var request = new Request(authOptions.endpoint, {\n headers,\n body,\n credentials: 'same-origin',\n method: 'POST'\n });\n\n return fetch(request)\n .then(response => {\n let { status } = response;\n if (status === 200) {\n // manually parse the json so we can provide a more helpful error in\n // failure case\n return response.text();\n }\n throw new HTTPAuthError(\n status,\n `Could not get ${authRequestType.toString()} info from your auth endpoint, status: ${status}`\n );\n })\n .then(data => {\n let parsedData;\n try {\n parsedData = JSON.parse(data);\n } catch (e) {\n throw new HTTPAuthError(\n 200,\n `JSON returned from ${authRequestType.toString()} endpoint was invalid, yet status code was 200. Data was: ${data}`\n );\n }\n callback(null, parsedData);\n })\n .catch(err => {\n callback(err, null);\n });\n};\n\nexport default fetchAuth;\n","import Logger from 'core/logger';\nimport TimelineSender from 'core/timeline/timeline_sender';\nimport * as Collections from 'core/utils/collections';\nimport Util from 'core/util';\nimport Runtime from 'runtime';\nimport TimelineTransport from 'core/timeline/timeline_transport';\n\nvar getAgent = function(sender: TimelineSender, useTLS: boolean) {\n return function(data: any, callback: Function) {\n var scheme = 'http' + (useTLS ? 's' : '') + '://';\n var url =\n scheme + (sender.host || sender.options.host) + sender.options.path;\n var query = Collections.buildQueryString(data);\n url += '/' + 2 + '?' + query;\n\n fetch(url)\n .then(response => {\n if (response.status !== 200) {\n throw `received ${response.status} from stats.pusher.com`;\n }\n return response.json();\n })\n .then(({ host }) => {\n if (host) {\n sender.host = host;\n }\n })\n .catch(err => {\n Logger.debug('TimelineSender Error: ', err);\n });\n };\n};\n\nvar fetchTimeline = {\n name: 'xhr',\n getAgent\n};\n\nexport default fetchTimeline;\n","import Isomorphic from 'isomorphic/runtime';\nimport Runtime from '../interface';\nimport { Network } from './net_info';\nimport fetchAuth from './auth/fetch_auth';\nimport { AuthTransports } from 'core/auth/auth_transports';\nimport fetchTimeline from './timeline/fetch_timeline';\n\n// Very verbose but until unavoidable until\n// TypeScript 2.1, when spread attributes will be\n// supported\nconst {\n getDefaultStrategy,\n Transports,\n setup,\n getProtocol,\n isXHRSupported,\n getLocalStorage,\n createXHR,\n createWebSocket,\n addUnloadListener,\n removeUnloadListener,\n transportConnectionInitializer,\n createSocketRequest,\n HTTPFactory\n} = Isomorphic;\n\nconst Worker: Runtime = {\n getDefaultStrategy,\n Transports,\n setup,\n getProtocol,\n isXHRSupported,\n getLocalStorage,\n createXHR,\n createWebSocket,\n addUnloadListener,\n removeUnloadListener,\n transportConnectionInitializer,\n createSocketRequest,\n HTTPFactory,\n\n TimelineTransport: fetchTimeline,\n\n getAuthorizers(): AuthTransports {\n return { ajax: fetchAuth };\n },\n\n getWebSocketAPI() {\n return WebSocket;\n },\n\n getXHRAPI() {\n return XMLHttpRequest;\n },\n\n getNetwork() {\n return Network;\n },\n\n randomInt(max: number): number {\n /**\n * Return values in the range of [0, 1[\n */\n const random = function() {\n const crypto = globalThis.crypto || globalThis['msCrypto'];\n const random = crypto.getRandomValues(new Uint32Array(1))[0];\n\n return random / 2 ** 32;\n };\n\n return Math.floor(random() * max);\n }\n};\n\nexport default Worker;\n","enum TimelineLevel {\n ERROR = 3,\n INFO = 6,\n DEBUG = 7\n}\n\nexport default TimelineLevel;\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport { default as Level } from './level';\n\nexport interface TimelineOptions {\n level?: Level;\n limit?: number;\n version?: string;\n cluster?: string;\n features?: string[];\n params?: any;\n}\n\nexport default class Timeline {\n key: string;\n session: number;\n events: any[];\n options: TimelineOptions;\n sent: number;\n uniqueID: number;\n\n constructor(key: string, session: number, options: TimelineOptions) {\n this.key = key;\n this.session = session;\n this.events = [];\n this.options = options || {};\n this.sent = 0;\n this.uniqueID = 0;\n }\n\n log(level, event) {\n if (level <= this.options.level) {\n this.events.push(\n Collections.extend({}, event, { timestamp: Util.now() })\n );\n if (this.options.limit && this.events.length > this.options.limit) {\n this.events.shift();\n }\n }\n }\n\n error(event) {\n this.log(Level.ERROR, event);\n }\n\n info(event) {\n this.log(Level.INFO, event);\n }\n\n debug(event) {\n this.log(Level.DEBUG, event);\n }\n\n isEmpty() {\n return this.events.length === 0;\n }\n\n send(sendfn, callback) {\n var data = Collections.extend(\n {\n session: this.session,\n bundle: this.sent + 1,\n key: this.key,\n lib: 'js',\n version: this.options.version,\n cluster: this.options.cluster,\n features: this.options.features,\n timeline: this.events\n },\n this.options.params\n );\n\n this.events = [];\n sendfn(data, (error, result) => {\n if (!error) {\n this.sent++;\n }\n if (callback) {\n callback(error, result);\n }\n });\n\n return true;\n }\n\n generateUniqueID(): number {\n this.uniqueID++;\n return this.uniqueID;\n }\n}\n","import Factory from '../utils/factory';\nimport Util from '../util';\nimport * as Errors from '../errors';\nimport * as Collections from '../utils/collections';\nimport Strategy from './strategy';\nimport Transport from '../transports/transport';\nimport StrategyOptions from './strategy_options';\nimport Handshake from '../connection/handshake';\n\n/** Provides a strategy interface for transports.\n *\n * @param {String} name\n * @param {Number} priority\n * @param {Class} transport\n * @param {Object} options\n */\nexport default class TransportStrategy implements Strategy {\n name: string;\n priority: number;\n transport: Transport;\n options: StrategyOptions;\n\n constructor(\n name: string,\n priority: number,\n transport: Transport,\n options: StrategyOptions\n ) {\n this.name = name;\n this.priority = priority;\n this.transport = transport;\n this.options = options || {};\n }\n\n /** Returns whether the transport is supported in the browser.\n *\n * @returns {Boolean}\n */\n isSupported(): boolean {\n return this.transport.isSupported({\n useTLS: this.options.useTLS\n });\n }\n\n /** Launches a connection attempt and returns a strategy runner.\n *\n * @param {Function} callback\n * @return {Object} strategy runner\n */\n connect(minPriority: number, callback: Function) {\n if (!this.isSupported()) {\n return failAttempt(new Errors.UnsupportedStrategy(), callback);\n } else if (this.priority < minPriority) {\n return failAttempt(new Errors.TransportPriorityTooLow(), callback);\n }\n\n var connected = false;\n var transport = this.transport.createConnection(\n this.name,\n this.priority,\n this.options.key,\n this.options\n );\n var handshake = null;\n\n var onInitialized = function() {\n transport.unbind('initialized', onInitialized);\n transport.connect();\n };\n var onOpen = function() {\n handshake = Factory.createHandshake(transport, function(result) {\n connected = true;\n unbindListeners();\n callback(null, result);\n });\n };\n var onError = function(error) {\n unbindListeners();\n callback(error);\n };\n var onClosed = function() {\n unbindListeners();\n var serializedTransport;\n\n // The reason for this try/catch block is that on React Native\n // the WebSocket object is circular. Therefore transport.socket will\n // throw errors upon stringification. Collections.safeJSONStringify\n // discards circular references when serializing.\n serializedTransport = Collections.safeJSONStringify(transport);\n callback(new Errors.TransportClosed(serializedTransport));\n };\n\n var unbindListeners = function() {\n transport.unbind('initialized', onInitialized);\n transport.unbind('open', onOpen);\n transport.unbind('error', onError);\n transport.unbind('closed', onClosed);\n };\n\n transport.bind('initialized', onInitialized);\n transport.bind('open', onOpen);\n transport.bind('error', onError);\n transport.bind('closed', onClosed);\n\n // connect will be called automatically after initialization\n transport.initialize();\n\n return {\n abort: () => {\n if (connected) {\n return;\n }\n unbindListeners();\n if (handshake) {\n handshake.close();\n } else {\n transport.close();\n }\n },\n forceMinPriority: p => {\n if (connected) {\n return;\n }\n if (this.priority < p) {\n if (handshake) {\n handshake.close();\n } else {\n transport.close();\n }\n }\n }\n };\n }\n}\n\nfunction failAttempt(error: Error, callback: Function) {\n Util.defer(function() {\n callback(error);\n });\n return {\n abort: function() {},\n forceMinPriority: function() {}\n };\n}\n","import * as Collections from '../utils/collections';\nimport Util from '../util';\nimport TransportManager from '../transports/transport_manager';\nimport * as Errors from '../errors';\nimport Strategy from './strategy';\nimport TransportStrategy from './transport_strategy';\nimport StrategyOptions from '../strategies/strategy_options';\nimport { Config } from '../config';\nimport Runtime from 'runtime';\n\nconst { Transports } = Runtime;\n\nexport var defineTransport = function(\n config: Config,\n name: string,\n type: string,\n priority: number,\n options: StrategyOptions,\n manager?: TransportManager\n): Strategy {\n var transportClass = Transports[type];\n if (!transportClass) {\n throw new Errors.UnsupportedTransport(type);\n }\n\n var enabled =\n (!config.enabledTransports ||\n Collections.arrayIndexOf(config.enabledTransports, name) !== -1) &&\n (!config.disabledTransports ||\n Collections.arrayIndexOf(config.disabledTransports, name) === -1);\n\n var transport;\n if (enabled) {\n options = Object.assign(\n { ignoreNullOrigin: config.ignoreNullOrigin },\n options\n );\n\n transport = new TransportStrategy(\n name,\n priority,\n manager ? manager.getAssistant(transportClass) : transportClass,\n options\n );\n } else {\n transport = UnsupportedStrategy;\n }\n\n return transport;\n};\n\nvar UnsupportedStrategy: Strategy = {\n isSupported: function() {\n return false;\n },\n connect: function(_, callback) {\n var deferred = Util.defer(function() {\n callback(new Errors.UnsupportedStrategy());\n });\n return {\n abort: function() {\n deferred.ensureAborted();\n },\n forceMinPriority: function() {}\n };\n }\n};\n","export enum AuthRequestType {\n UserAuthentication = 'user-authentication',\n ChannelAuthorization = 'channel-authorization'\n}\n\nexport interface ChannelAuthorizationData {\n auth: string;\n channel_data?: string;\n shared_secret?: string;\n}\n\nexport type ChannelAuthorizationCallback = (\n error: Error | null,\n authData: ChannelAuthorizationData | null\n) => void;\n\nexport interface ChannelAuthorizationRequestParams {\n socketId: string;\n channelName: string;\n}\n\nexport interface ChannelAuthorizationHandler {\n (\n params: ChannelAuthorizationRequestParams,\n callback: ChannelAuthorizationCallback\n ): void;\n}\n\nexport interface UserAuthenticationData {\n auth: string;\n user_data: string;\n}\n\nexport type UserAuthenticationCallback = (\n error: Error | null,\n authData: UserAuthenticationData | null\n) => void;\n\nexport interface UserAuthenticationRequestParams {\n socketId: string;\n}\n\nexport interface UserAuthenticationHandler {\n (\n params: UserAuthenticationRequestParams,\n callback: UserAuthenticationCallback\n ): void;\n}\n\nexport type AuthTransportCallback =\n | ChannelAuthorizationCallback\n | UserAuthenticationCallback;\n\nexport interface InternalAuthOptions {\n transport: 'ajax' | 'jsonp';\n endpoint: string;\n params?: any;\n headers?: any;\n paramsProvider?: () => any;\n headersProvider?: () => any;\n}\n\nexport type CustomAuthOptions = {\n customHandler: AuthHandler;\n};\n\nexport type AuthOptionsT =\n | InternalAuthOptions\n | CustomAuthOptions;\n\nexport declare type UserAuthenticationOptions = AuthOptionsT<\n UserAuthenticationHandler\n>;\nexport declare type ChannelAuthorizationOptions = AuthOptionsT<\n ChannelAuthorizationHandler\n>;\n","import {\n UserAuthenticationCallback,\n InternalAuthOptions,\n UserAuthenticationHandler,\n UserAuthenticationRequestParams,\n AuthRequestType\n} from './options';\n\nimport Runtime from 'runtime';\n\nconst composeChannelQuery = (\n params: UserAuthenticationRequestParams,\n authOptions: InternalAuthOptions\n) => {\n var query = 'socket_id=' + encodeURIComponent(params.socketId);\n\n for (var key in authOptions.params) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(authOptions.params[key]);\n }\n\n if (authOptions.paramsProvider != null) {\n let dynamicParams = authOptions.paramsProvider();\n for (var key in dynamicParams) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(dynamicParams[key]);\n }\n }\n\n return query;\n};\n\nconst UserAuthenticator = (\n authOptions: InternalAuthOptions\n): UserAuthenticationHandler => {\n if (typeof Runtime.getAuthorizers()[authOptions.transport] === 'undefined') {\n throw `'${authOptions.transport}' is not a recognized auth transport`;\n }\n\n return (\n params: UserAuthenticationRequestParams,\n callback: UserAuthenticationCallback\n ) => {\n const query = composeChannelQuery(params, authOptions);\n\n Runtime.getAuthorizers()[authOptions.transport](\n Runtime,\n query,\n authOptions,\n AuthRequestType.UserAuthentication,\n callback\n );\n };\n};\n\nexport default UserAuthenticator;\n","import {\n AuthRequestType,\n InternalAuthOptions,\n ChannelAuthorizationHandler,\n ChannelAuthorizationRequestParams,\n ChannelAuthorizationCallback\n} from './options';\n\nimport Runtime from 'runtime';\n\nconst composeChannelQuery = (\n params: ChannelAuthorizationRequestParams,\n authOptions: InternalAuthOptions\n) => {\n var query = 'socket_id=' + encodeURIComponent(params.socketId);\n\n query += '&channel_name=' + encodeURIComponent(params.channelName);\n\n for (var key in authOptions.params) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(authOptions.params[key]);\n }\n\n if (authOptions.paramsProvider != null) {\n let dynamicParams = authOptions.paramsProvider();\n for (var key in dynamicParams) {\n query +=\n '&' +\n encodeURIComponent(key) +\n '=' +\n encodeURIComponent(dynamicParams[key]);\n }\n }\n\n return query;\n};\n\nconst ChannelAuthorizer = (\n authOptions: InternalAuthOptions\n): ChannelAuthorizationHandler => {\n if (typeof Runtime.getAuthorizers()[authOptions.transport] === 'undefined') {\n throw `'${authOptions.transport}' is not a recognized auth transport`;\n }\n\n return (\n params: ChannelAuthorizationRequestParams,\n callback: ChannelAuthorizationCallback\n ) => {\n const query = composeChannelQuery(params, authOptions);\n\n Runtime.getAuthorizers()[authOptions.transport](\n Runtime,\n query,\n authOptions,\n AuthRequestType.ChannelAuthorization,\n callback\n );\n };\n};\n\nexport default ChannelAuthorizer;\n","import Channel from '../channels/channel';\nimport {\n ChannelAuthorizationCallback,\n ChannelAuthorizationHandler,\n ChannelAuthorizationRequestParams,\n InternalAuthOptions\n} from './options';\n\nexport interface DeprecatedChannelAuthorizer {\n authorize(socketId: string, callback: ChannelAuthorizationCallback): void;\n}\n\nexport interface ChannelAuthorizerGenerator {\n (\n channel: Channel,\n options: DeprecatedAuthorizerOptions\n ): DeprecatedChannelAuthorizer;\n}\n\nexport interface DeprecatedAuthOptions {\n params?: any;\n headers?: any;\n}\n\nexport interface DeprecatedAuthorizerOptions {\n authTransport: 'ajax' | 'jsonp';\n authEndpoint: string;\n auth?: DeprecatedAuthOptions;\n}\n\nexport const ChannelAuthorizerProxy = (\n pusher,\n authOptions: InternalAuthOptions,\n channelAuthorizerGenerator: ChannelAuthorizerGenerator\n): ChannelAuthorizationHandler => {\n const deprecatedAuthorizerOptions: DeprecatedAuthorizerOptions = {\n authTransport: authOptions.transport,\n authEndpoint: authOptions.endpoint,\n auth: {\n params: authOptions.params,\n headers: authOptions.headers\n }\n };\n return (\n params: ChannelAuthorizationRequestParams,\n callback: ChannelAuthorizationCallback\n ) => {\n const channel = pusher.channel(params.channelName);\n // This line creates a new channel authorizer every time.\n // In the past, this was only done once per channel and reused.\n // We can do that again if we want to keep this behavior intact.\n const channelAuthorizer: DeprecatedChannelAuthorizer = channelAuthorizerGenerator(\n channel,\n deprecatedAuthorizerOptions\n );\n channelAuthorizer.authorize(params.socketId, callback);\n };\n};\n","import { Options } from './options';\nimport Defaults from './defaults';\nimport {\n ChannelAuthorizationHandler,\n UserAuthenticationHandler,\n ChannelAuthorizationOptions,\n AuthOptionsT,\n CustomAuthOptions\n} from './auth/options';\nimport UserAuthenticator from './auth/user_authenticator';\nimport ChannelAuthorizer from './auth/channel_authorizer';\nimport { ChannelAuthorizerProxy } from './auth/deprecated_channel_authorizer';\nimport Runtime from 'runtime';\nimport * as nacl from 'tweetnacl';\n\nexport type AuthTransport = 'ajax' | 'jsonp';\nexport type Transport =\n | 'ws'\n | 'wss'\n | 'xhr_streaming'\n | 'xhr_polling'\n | 'sockjs';\n\nexport interface Config {\n // these are all 'required' config parameters, it's not necessary for the user\n // to set them, but they have configured defaults.\n activityTimeout: number;\n enableStats: boolean;\n httpHost: string;\n httpPath: string;\n httpPort: number;\n httpsPort: number;\n pongTimeout: number;\n statsHost: string;\n unavailableTimeout: number;\n useTLS: boolean;\n wsHost: string;\n wsPath: string;\n wsPort: number;\n wssPort: number;\n userAuthenticator: UserAuthenticationHandler;\n channelAuthorizer: ChannelAuthorizationHandler;\n\n // these are all optional parameters or overrrides. The customer can set these\n // but it's not strictly necessary\n forceTLS?: boolean;\n cluster?: string;\n disabledTransports?: Transport[];\n enabledTransports?: Transport[];\n ignoreNullOrigin?: boolean;\n nacl?: nacl;\n timelineParams?: any;\n}\n\n// getConfig mainly sets the defaults for the options that are not provided\nexport function getConfig(opts: Options, pusher): Config {\n let config: Config = {\n activityTimeout: opts.activityTimeout || Defaults.activityTimeout,\n cluster: opts.cluster,\n httpPath: opts.httpPath || Defaults.httpPath,\n httpPort: opts.httpPort || Defaults.httpPort,\n httpsPort: opts.httpsPort || Defaults.httpsPort,\n pongTimeout: opts.pongTimeout || Defaults.pongTimeout,\n statsHost: opts.statsHost || Defaults.stats_host,\n unavailableTimeout: opts.unavailableTimeout || Defaults.unavailableTimeout,\n wsPath: opts.wsPath || Defaults.wsPath,\n wsPort: opts.wsPort || Defaults.wsPort,\n wssPort: opts.wssPort || Defaults.wssPort,\n\n enableStats: getEnableStatsConfig(opts),\n httpHost: getHttpHost(opts),\n useTLS: shouldUseTLS(opts),\n wsHost: getWebsocketHost(opts),\n\n userAuthenticator: buildUserAuthenticator(opts),\n channelAuthorizer: buildChannelAuthorizer(opts, pusher)\n };\n\n if ('disabledTransports' in opts)\n config.disabledTransports = opts.disabledTransports;\n if ('enabledTransports' in opts)\n config.enabledTransports = opts.enabledTransports;\n if ('ignoreNullOrigin' in opts)\n config.ignoreNullOrigin = opts.ignoreNullOrigin;\n if ('timelineParams' in opts) config.timelineParams = opts.timelineParams;\n if ('nacl' in opts) {\n config.nacl = opts.nacl;\n }\n\n return config;\n}\n\nfunction getHttpHost(opts: Options): string {\n if (opts.httpHost) {\n return opts.httpHost;\n }\n if (opts.cluster) {\n return `sockjs-${opts.cluster}.pusher.com`;\n }\n return Defaults.httpHost;\n}\n\nfunction getWebsocketHost(opts: Options): string {\n if (opts.wsHost) {\n return opts.wsHost;\n }\n return getWebsocketHostFromCluster(opts.cluster);\n}\n\nfunction getWebsocketHostFromCluster(cluster: string): string {\n return `ws-${cluster}.pusher.com`;\n}\n\nfunction shouldUseTLS(opts: Options): boolean {\n if (Runtime.getProtocol() === 'https:') {\n return true;\n } else if (opts.forceTLS === false) {\n return false;\n }\n return true;\n}\n\n// if enableStats is set take the value\n// if disableStats is set take the inverse\n// otherwise default to false\nfunction getEnableStatsConfig(opts: Options): boolean {\n if ('enableStats' in opts) {\n return opts.enableStats;\n }\n if ('disableStats' in opts) {\n return !opts.disableStats;\n }\n return false;\n}\n\nconst hasCustomHandler = (\n auth: AuthOptionsT\n): auth is CustomAuthOptions => {\n return 'customHandler' in auth && auth['customHandler'] != null;\n};\n\nfunction buildUserAuthenticator(opts: Options): UserAuthenticationHandler {\n const userAuthentication = {\n ...Defaults.userAuthentication,\n ...opts.userAuthentication\n };\n\n if (hasCustomHandler(userAuthentication)) {\n return userAuthentication['customHandler'];\n }\n\n return UserAuthenticator(userAuthentication);\n}\n\nfunction buildChannelAuth(opts: Options, pusher): ChannelAuthorizationOptions {\n let channelAuthorization: ChannelAuthorizationOptions;\n if ('channelAuthorization' in opts) {\n channelAuthorization = {\n ...Defaults.channelAuthorization,\n ...opts.channelAuthorization\n };\n } else {\n channelAuthorization = {\n transport: opts.authTransport || Defaults.authTransport,\n endpoint: opts.authEndpoint || Defaults.authEndpoint\n };\n\n if ('auth' in opts) {\n if ('params' in opts.auth) channelAuthorization.params = opts.auth.params;\n if ('headers' in opts.auth)\n channelAuthorization.headers = opts.auth.headers;\n }\n\n if ('authorizer' in opts) {\n return {\n customHandler: ChannelAuthorizerProxy(\n pusher,\n channelAuthorization,\n opts.authorizer\n )\n };\n }\n }\n return channelAuthorization;\n}\n\nfunction buildChannelAuthorizer(\n opts: Options,\n pusher\n): ChannelAuthorizationHandler {\n const channelAuthorization = buildChannelAuth(opts, pusher);\n\n if (hasCustomHandler(channelAuthorization)) {\n return channelAuthorization['customHandler'];\n }\n\n return ChannelAuthorizer(channelAuthorization);\n}\n","import Logger from './logger';\nimport Pusher from './pusher';\nimport EventsDispatcher from './events/dispatcher';\n\nexport default class WatchlistFacade extends EventsDispatcher {\n private pusher: Pusher;\n\n public constructor(pusher: Pusher) {\n super(function(eventName, data) {\n Logger.debug(`No callbacks on watchlist events for ${eventName}`);\n });\n\n this.pusher = pusher;\n this.bindWatchlistInternalEvent();\n }\n\n handleEvent(pusherEvent) {\n pusherEvent.data.events.forEach(watchlistEvent => {\n this.emit(watchlistEvent.name, watchlistEvent);\n });\n }\n\n private bindWatchlistInternalEvent() {\n this.pusher.connection.bind('message', pusherEvent => {\n var eventName = pusherEvent.event;\n if (eventName === 'pusher_internal:watchlist_events') {\n this.handleEvent(pusherEvent);\n }\n });\n }\n}\n","function flatPromise() {\n let resolve, reject;\n const promise = new Promise((res, rej) => {\n resolve = res;\n reject = rej;\n });\n return { promise, resolve, reject };\n}\n\nexport default flatPromise;\n","import Pusher from './pusher';\nimport Logger from './logger';\nimport {\n UserAuthenticationData,\n UserAuthenticationCallback\n} from './auth/options';\nimport Channel from './channels/channel';\nimport WatchlistFacade from './watchlist';\nimport EventsDispatcher from './events/dispatcher';\nimport flatPromise from './utils/flat_promise';\n\nexport default class UserFacade extends EventsDispatcher {\n pusher: Pusher;\n signin_requested: boolean = false;\n user_data: any = null;\n serverToUserChannel: Channel = null;\n signinDonePromise: Promise = null;\n watchlist: WatchlistFacade;\n private _signinDoneResolve: Function = null;\n\n public constructor(pusher: Pusher) {\n super(function(eventName, data) {\n Logger.debug('No callbacks on user for ' + eventName);\n });\n this.pusher = pusher;\n this.pusher.connection.bind('state_change', ({ previous, current }) => {\n if (previous !== 'connected' && current === 'connected') {\n this._signin();\n }\n if (previous === 'connected' && current !== 'connected') {\n this._cleanup();\n this._newSigninPromiseIfNeeded();\n }\n });\n\n this.watchlist = new WatchlistFacade(pusher);\n\n this.pusher.connection.bind('message', event => {\n var eventName = event.event;\n if (eventName === 'pusher:signin_success') {\n this._onSigninSuccess(event.data);\n }\n if (\n this.serverToUserChannel &&\n this.serverToUserChannel.name === event.channel\n ) {\n this.serverToUserChannel.handleEvent(event);\n }\n });\n }\n\n public signin() {\n if (this.signin_requested) {\n return;\n }\n\n this.signin_requested = true;\n this._signin();\n }\n\n private _signin() {\n if (!this.signin_requested) {\n return;\n }\n\n this._newSigninPromiseIfNeeded();\n\n if (this.pusher.connection.state !== 'connected') {\n // Signin will be attempted when the connection is connected\n return;\n }\n\n this.pusher.config.userAuthenticator(\n {\n socketId: this.pusher.connection.socket_id\n },\n this._onAuthorize\n );\n }\n\n private _onAuthorize: UserAuthenticationCallback = (\n err,\n authData: UserAuthenticationData\n ) => {\n if (err) {\n Logger.warn(`Error during signin: ${err}`);\n this._cleanup();\n return;\n }\n\n this.pusher.send_event('pusher:signin', {\n auth: authData.auth,\n user_data: authData.user_data\n });\n\n // Later when we get pusher:singin_success event, the user will be marked as signed in\n };\n\n private _onSigninSuccess(data: any) {\n try {\n this.user_data = JSON.parse(data.user_data);\n } catch (e) {\n Logger.error(`Failed parsing user data after signin: ${data.user_data}`);\n this._cleanup();\n return;\n }\n\n if (typeof this.user_data.id !== 'string' || this.user_data.id === '') {\n Logger.error(\n `user_data doesn't contain an id. user_data: ${this.user_data}`\n );\n this._cleanup();\n return;\n }\n\n // Signin succeeded\n this._signinDoneResolve();\n this._subscribeChannels();\n }\n\n private _subscribeChannels() {\n const ensure_subscribed = channel => {\n if (channel.subscriptionPending && channel.subscriptionCancelled) {\n channel.reinstateSubscription();\n } else if (\n !channel.subscriptionPending &&\n this.pusher.connection.state === 'connected'\n ) {\n channel.subscribe();\n }\n };\n\n this.serverToUserChannel = new Channel(\n `#server-to-user-${this.user_data.id}`,\n this.pusher\n );\n this.serverToUserChannel.bind_global((eventName, data) => {\n if (\n eventName.indexOf('pusher_internal:') === 0 ||\n eventName.indexOf('pusher:') === 0\n ) {\n // ignore internal events\n return;\n }\n this.emit(eventName, data);\n });\n ensure_subscribed(this.serverToUserChannel);\n }\n\n private _cleanup() {\n this.user_data = null;\n if (this.serverToUserChannel) {\n this.serverToUserChannel.unbind_all();\n this.serverToUserChannel.disconnect();\n this.serverToUserChannel = null;\n }\n\n if (this.signin_requested) {\n // If signin is in progress and cleanup is called,\n // Mark the current signin process as done.\n this._signinDoneResolve();\n }\n }\n\n private _newSigninPromiseIfNeeded() {\n if (!this.signin_requested) {\n return;\n }\n\n // If there is a promise and it is not resolved, return without creating a new one.\n if (this.signinDonePromise && !(this.signinDonePromise as any).done) {\n return;\n }\n\n // This promise is never rejected.\n // It gets resolved when the signin process is done whether it failed or succeeded\n const { promise, resolve, reject: _ } = flatPromise();\n (promise as any).done = false;\n const setDone = () => {\n (promise as any).done = true;\n };\n promise.then(setDone).catch(setDone);\n this.signinDonePromise = promise;\n this._signinDoneResolve = resolve;\n }\n}\n","import AbstractRuntime from '../runtimes/interface';\nimport Runtime from 'runtime';\nimport * as Collections from './utils/collections';\nimport Channels from './channels/channels';\nimport Channel from './channels/channel';\nimport { default as EventsDispatcher } from './events/dispatcher';\nimport Timeline from './timeline/timeline';\nimport TimelineSender from './timeline/timeline_sender';\nimport TimelineLevel from './timeline/level';\nimport { defineTransport } from './strategies/strategy_builder';\nimport ConnectionManager from './connection/connection_manager';\nimport { PeriodicTimer } from './utils/timers';\nimport Defaults from './defaults';\nimport Logger from './logger';\nimport Factory from './utils/factory';\nimport { Options, ClusterOptions, validateOptions } from './options';\nimport { Config, getConfig } from './config';\nimport StrategyOptions from './strategies/strategy_options';\nimport UserFacade from './user';\n\nexport default class Pusher {\n /* STATIC PROPERTIES */\n static instances: Pusher[] = [];\n static isReady: boolean = false;\n static logToConsole: boolean = false;\n\n // for jsonp\n static Runtime: AbstractRuntime = Runtime;\n static ScriptReceivers: any = (Runtime).ScriptReceivers;\n static DependenciesReceivers: any = (Runtime).DependenciesReceivers;\n static auth_callbacks: any = (Runtime).auth_callbacks;\n\n static ready() {\n Pusher.isReady = true;\n for (var i = 0, l = Pusher.instances.length; i < l; i++) {\n Pusher.instances[i].connect();\n }\n }\n\n static log: (message: any) => void;\n\n private static getClientFeatures(): string[] {\n return Collections.keys(\n Collections.filterObject({ ws: Runtime.Transports.ws }, function(t) {\n return t.isSupported({});\n })\n );\n }\n\n /* INSTANCE PROPERTIES */\n key: string;\n options: Options;\n config: Config;\n channels: Channels;\n global_emitter: EventsDispatcher;\n sessionID: number;\n timeline: Timeline;\n timelineSender: TimelineSender;\n connection: ConnectionManager;\n timelineSenderTimer: PeriodicTimer;\n user: UserFacade;\n constructor(app_key: string, options: Options) {\n checkAppKey(app_key);\n validateOptions(options);\n this.key = app_key;\n this.options = options;\n this.config = getConfig(this.options, this);\n\n this.channels = Factory.createChannels();\n this.global_emitter = new EventsDispatcher();\n this.sessionID = Runtime.randomInt(1000000000);\n\n this.timeline = new Timeline(this.key, this.sessionID, {\n cluster: this.config.cluster,\n features: Pusher.getClientFeatures(),\n params: this.config.timelineParams || {},\n limit: 50,\n level: TimelineLevel.INFO,\n version: Defaults.VERSION\n });\n if (this.config.enableStats) {\n this.timelineSender = Factory.createTimelineSender(this.timeline, {\n host: this.config.statsHost,\n path: '/timeline/v2/' + Runtime.TimelineTransport.name\n });\n }\n\n var getStrategy = (options: StrategyOptions) => {\n return Runtime.getDefaultStrategy(this.config, options, defineTransport);\n };\n\n this.connection = Factory.createConnectionManager(this.key, {\n getStrategy: getStrategy,\n timeline: this.timeline,\n activityTimeout: this.config.activityTimeout,\n pongTimeout: this.config.pongTimeout,\n unavailableTimeout: this.config.unavailableTimeout,\n useTLS: Boolean(this.config.useTLS)\n });\n\n this.connection.bind('connected', () => {\n this.subscribeAll();\n if (this.timelineSender) {\n this.timelineSender.send(this.connection.isUsingTLS());\n }\n });\n\n this.connection.bind('message', event => {\n var eventName = event.event;\n var internal = eventName.indexOf('pusher_internal:') === 0;\n if (event.channel) {\n var channel = this.channel(event.channel);\n if (channel) {\n channel.handleEvent(event);\n }\n }\n // Emit globally [deprecated]\n if (!internal) {\n this.global_emitter.emit(event.event, event.data);\n }\n });\n this.connection.bind('connecting', () => {\n this.channels.disconnect();\n });\n this.connection.bind('disconnected', () => {\n this.channels.disconnect();\n });\n this.connection.bind('error', err => {\n Logger.warn(err);\n });\n\n Pusher.instances.push(this);\n this.timeline.info({ instances: Pusher.instances.length });\n\n this.user = new UserFacade(this);\n\n if (Pusher.isReady) {\n this.connect();\n }\n }\n\n /**\n * Allows you to switch Pusher cluster without\n * losing all the channels/subscription binding\n * as this is internally managed by the SDK.\n */\n switchCluster(options: ClusterOptions) {\n const { appKey, cluster } = options;\n this.key = appKey;\n this.options = { ...this.options, cluster };\n this.config = getConfig(this.options, this);\n this.connection.switchCluster(this.key);\n }\n\n channel(name: string): Channel {\n return this.channels.find(name);\n }\n\n allChannels(): Channel[] {\n return this.channels.all();\n }\n\n connect() {\n this.connection.connect();\n\n if (this.timelineSender) {\n if (!this.timelineSenderTimer) {\n var usingTLS = this.connection.isUsingTLS();\n var timelineSender = this.timelineSender;\n this.timelineSenderTimer = new PeriodicTimer(60000, function() {\n timelineSender.send(usingTLS);\n });\n }\n }\n }\n\n disconnect() {\n this.connection.disconnect();\n\n if (this.timelineSenderTimer) {\n this.timelineSenderTimer.ensureAborted();\n this.timelineSenderTimer = null;\n }\n }\n\n bind(event_name: string, callback: Function, context?: any): Pusher {\n this.global_emitter.bind(event_name, callback, context);\n return this;\n }\n\n unbind(event_name?: string, callback?: Function, context?: any): Pusher {\n this.global_emitter.unbind(event_name, callback, context);\n return this;\n }\n\n bind_global(callback: Function): Pusher {\n this.global_emitter.bind_global(callback);\n return this;\n }\n\n unbind_global(callback?: Function): Pusher {\n this.global_emitter.unbind_global(callback);\n return this;\n }\n\n unbind_all(callback?: Function): Pusher {\n this.global_emitter.unbind_all();\n return this;\n }\n\n subscribeAll() {\n var channelName;\n for (channelName in this.channels.channels) {\n if (this.channels.channels.hasOwnProperty(channelName)) {\n this.subscribe(channelName);\n }\n }\n }\n\n subscribe(channel_name: string) {\n var channel = this.channels.add(channel_name, this);\n if (channel.subscriptionPending && channel.subscriptionCancelled) {\n channel.reinstateSubscription();\n } else if (\n !channel.subscriptionPending &&\n this.connection.state === 'connected'\n ) {\n channel.subscribe();\n }\n return channel;\n }\n\n unsubscribe(channel_name: string) {\n var channel = this.channels.find(channel_name);\n if (channel && channel.subscriptionPending) {\n channel.cancelSubscription();\n } else {\n channel = this.channels.remove(channel_name);\n if (channel && channel.subscribed) {\n channel.unsubscribe();\n }\n }\n }\n\n send_event(event_name: string, data: any, channel?: string) {\n return this.connection.send_event(event_name, data, channel);\n }\n\n shouldUseTLS(): boolean {\n return this.config.useTLS;\n }\n\n signin() {\n this.user.signin();\n }\n}\n\nfunction checkAppKey(key) {\n if (key === null || key === undefined) {\n throw 'You must pass your app key when you instantiate Pusher.';\n }\n}\n\nRuntime.setup(Pusher);\n","import ConnectionManager from './connection/connection_manager';\nimport {\n ChannelAuthorizationOptions,\n UserAuthenticationOptions\n} from './auth/options';\nimport {\n ChannelAuthorizerGenerator,\n DeprecatedAuthOptions\n} from './auth/deprecated_channel_authorizer';\nimport { AuthTransport, Transport } from './config';\nimport * as nacl from 'tweetnacl';\nimport Logger from './logger';\n\nexport interface Options {\n activityTimeout?: number;\n\n auth?: DeprecatedAuthOptions; // DEPRECATED use channelAuthorization instead\n authEndpoint?: string; // DEPRECATED use channelAuthorization instead\n authTransport?: AuthTransport; // DEPRECATED use channelAuthorization instead\n authorizer?: ChannelAuthorizerGenerator; // DEPRECATED use channelAuthorization instead\n\n channelAuthorization?: ChannelAuthorizationOptions;\n userAuthentication?: UserAuthenticationOptions;\n\n cluster: string;\n enableStats?: boolean;\n disableStats?: boolean;\n disabledTransports?: Transport[];\n enabledTransports?: Transport[];\n forceTLS?: boolean;\n httpHost?: string;\n httpPath?: string;\n httpPort?: number;\n httpsPort?: number;\n ignoreNullOrigin?: boolean;\n nacl?: nacl;\n pongTimeout?: number;\n statsHost?: string;\n timelineParams?: any;\n unavailableTimeout?: number;\n wsHost?: string;\n wsPath?: string;\n wsPort?: number;\n wssPort?: number;\n}\n\nexport interface ClusterOptions {\n appKey: string;\n cluster: string;\n}\n\nexport function validateOptions(options) {\n if (options == null) {\n throw 'You must pass an options object';\n }\n if (options.cluster == null) {\n throw 'Options object must provide a cluster';\n }\n if ('disableStats' in options) {\n Logger.warn(\n 'The disableStats option is deprecated in favor of enableStats'\n );\n }\n}\n"],"sourceRoot":""} \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 888e0e6e6..34554b94d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "pusher-js", - "version": "8.4.0-rc1", + "version": "8.4.0-rc2", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "pusher-js", - "version": "8.4.0-rc1", + "version": "8.4.0-rc2", "license": "MIT", "dependencies": { "tweetnacl": "^1.0.3" diff --git a/package.json b/package.json index bb331796a..4e06d393c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "pusher-js", - "version": "8.4.0-rc1", + "version": "8.4.0-rc2", "description": "Pusher Channels JavaScript library for browsers, React Native, NodeJS and web workers", "main": "dist/node/pusher.js", "browser": "dist/web/pusher.js",